diff --git a/.arcignore b/.arcignore new file mode 100644 index 00000000000..cd917b06fb7 --- /dev/null +++ b/.arcignore @@ -0,0 +1,12 @@ +# .arcignore is the same as .gitignore but for Arc VCS. +# Arc VCS is a proprietary VCS in Yandex that is very similar to Git +# from the user perspective but with the following differences: +# 1. Data is stored in distributed object storage. +# 2. Local copy works via FUSE without downloading all the objects. +# For this reason, it is better suited for huge monorepositories that can be found in large companies (e.g. Yandex, Google). +# As ClickHouse developers, we don't use Arc as a VCS (we use Git). +# But the ClickHouse source code is also mirrored into internal monorepository and our collegues are using Arc. +# You can read more about Arc here: https://habr.com/en/company/yandex/blog/482926/ + +# Repository is synchronized without 3rd-party submodules. +contrib diff --git a/.clang-tidy b/.clang-tidy index 3c222fbf8da..b0971418e0e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,7 +9,7 @@ Checks: '-*, misc-unused-alias-decls, misc-unused-parameters, misc-unused-using-decls, - + modernize-avoid-bind, modernize-loop-convert, modernize-make-shared, @@ -33,7 +33,7 @@ Checks: '-*, performance-no-automatic-move, performance-trivially-destructible, performance-unnecessary-copy-initialization, - + readability-avoid-const-params-in-decls, readability-const-return-type, readability-container-size-empty, @@ -58,7 +58,7 @@ Checks: '-*, readability-simplify-boolean-expr, readability-inconsistent-declaration-parameter-name, readability-identifier-naming, - + bugprone-undelegated-constructor, bugprone-argument-comment, bugprone-bad-signal-to-kill-thread, @@ -102,7 +102,7 @@ Checks: '-*, bugprone-unused-return-value, bugprone-use-after-move, bugprone-virtual-near-miss, - + cert-dcl21-cpp, cert-dcl50-cpp, cert-env33-c, @@ -112,7 +112,7 @@ Checks: '-*, cert-mem57-cpp, cert-msc50-cpp, cert-oop58-cpp, - + google-build-explicit-make-pair, google-build-namespaces, google-default-arguments, @@ -121,9 +121,9 @@ Checks: '-*, google-readability-avoid-underscore-in-googletest-name, google-runtime-int, google-runtime-operator, - + hicpp-exception-baseclass, - + clang-analyzer-core.CallAndMessage, clang-analyzer-core.DivideZero, clang-analyzer-core.NonNullParamChecker, diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 330bab44533..3dffbd7ecfc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,7 +9,7 @@ Changelog category (leave one): - Build/Testing/Packaging Improvement - Documentation (changelog entry is not required) - Other -- Non-significant (changelog entry is not required) +- Not for changelog (changelog entry is not required) Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md): diff --git a/.gitignore b/.gitignore index 7acee3ad016..6bd57911ac8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /build /build_* /build-* + /docs/build /docs/publish /docs/edit @@ -57,143 +58,9 @@ cmake-build-* __pycache__ *.pytest_cache -# ignore generated files -*-metrika-yandex - test.cpp -utils/compressor/compressor -utils/corrector_utf8/corrector_utf8 -utils/iotest/iotest -utils/iotest/iotest_aio -utils/iotest/iotest_nonblock -utils/config-processor/config-processor CPackConfig.cmake CPackSourceConfig.cmake -contrib/libpoco/Poco/ -contrib/libpoco/bin/ -contrib/libpoco/cmake_uninstall.cmake -contrib/libre2/re2_st/ -src/Client/clickhouse-benchmark -src/Client/clickhouse-client -src/Client/tests/test-connect -src/Common/tests/arena_with_free_lists -src/Common/tests/auto_array -src/Common/tests/compact_array -src/Common/tests/hash_table -src/Common/tests/hashes_test -src/Common/tests/int_hashes_perf -src/Common/tests/lru_cache -src/Common/tests/parallel_aggregation -src/Common/tests/parallel_aggregation2 -src/Common/tests/radix_sort -src/Common/tests/shell_command_test -src/Common/tests/simple_cache -src/Common/tests/sip_hash -src/Common/tests/sip_hash_perf -src/Common/tests/small_table -src/Core/tests/exception -src/Core/tests/field -src/Core/tests/rvo_test -src/Core/tests/string_pool -src/DataStreams/tests/aggregating_stream -src/DataStreams/tests/block_tab_separated_streams -src/DataStreams/tests/collapsing_sorted_stream -src/DataStreams/tests/expression_stream -src/DataStreams/tests/filter_stream -src/DataStreams/tests/filter_stream_hitlog -src/DataStreams/tests/fork_streams -src/DataStreams/tests/glue_streams -src/DataStreams/tests/json_streams -src/DataStreams/tests/native_streams -src/DataStreams/tests/sorting_stream -src/DataStreams/tests/tab_separated_streams -src/DataStreams/tests/union_stream -src/DataStreams/tests/union_stream2 -src/DataTypes/tests/data_type_string -src/DataTypes/tests/data_types_number_fixed -src/Functions/tests/functions_arithmetic -src/Functions/tests/logical_functions_performance -src/Functions/tests/number_traits -src/IO/tests/async_write -src/IO/tests/cached_compressed_read_buffer -src/IO/tests/compressed_buffer -src/IO/tests/hashing_read_buffer -src/IO/tests/hashing_write_buffer -src/IO/tests/io_and_exceptions -src/IO/tests/io_operators -src/IO/tests/mempbrk -src/IO/tests/o_direct_and_dirty_pages -src/IO/tests/parse_int_perf -src/IO/tests/parse_int_perf2 -src/IO/tests/read_buffer -src/IO/tests/read_buffer_aio -src/IO/tests/read_buffer_perf -src/IO/tests/read_escaped_string -src/IO/tests/read_float_perf -src/IO/tests/read_write_int -src/IO/tests/valid_utf8 -src/IO/tests/valid_utf8_perf -src/IO/tests/var_uint -src/IO/tests/write_buffer -src/IO/tests/write_buffer_aio -src/IO/tests/write_buffer_perf -src/Interpreters/tests/address_patterns -src/Interpreters/tests/aggregate -src/Interpreters/tests/compiler_test -src/Interpreters/tests/create_query -src/Interpreters/tests/expression -src/Interpreters/tests/expression_analyzer -src/Interpreters/tests/hash_map -src/Interpreters/tests/hash_map2 -src/Interpreters/tests/hash_map3 -src/Interpreters/tests/hash_map_string -src/Interpreters/tests/hash_map_string_2 -src/Interpreters/tests/hash_map_string_3 -src/Interpreters/tests/hash_map_string_small -src/Interpreters/tests/in_join_subqueries_preprocessor -src/Interpreters/tests/logical_expressions_optimizer -src/Interpreters/tests/select_query -src/Interpreters/tests/two_level_hash_map -src/Interpreters/tests/users -src/Parsers/tests/create_parser -src/Parsers/tests/select_parser -src/Server/clickhouse-server -src/Server/clickhouse-server.init -src/Storages/tests/hit_log -src/Storages/tests/merge_tree -src/Storages/tests/part_checker -src/Storages/tests/part_name -src/Storages/tests/pk_condition -src/Storages/tests/seek_speed_test -src/Storages/tests/storage_log -src/Storages/tests/system_numbers -libs/libcommon/src/revision.h -libs/libcommon/src/tests/date_lut2 -libs/libcommon/src/tests/date_lut3 -libs/libcommon/src/tests/date_lut4 -libs/libcommon/src/tests/date_lut_init -libs/libcommon/src/tests/multi_version -libs/libmysqlxx/src/tests/failover -libs/libmysqlxx/src/tests/mysqlxx_test -libs/libzkutil/src/tests/zkutil_expiration_test -libs/libzkutil/src/tests/zkutil_test -libs/libzkutil/src/tests/zkutil_test_async -libs/libzkutil/src/tests/zkutil_test_commands -libs/libzkutil/src/tests/zkutil_test_lock -libs/libzkutil/src/tests/zkutil_zookeeper_holder -utils/zookeeper-create-entry-to-download-part/zookeeper-create-entry-to-download-part -utils/zookeeper-dump-tree/zookeeper-dump-tree -utils/zookeeper-remove-by-list/zookeeper-remove-by-list -src/Storages/tests/remove_symlink_directory -libs/libcommon/src/tests/json_test -utils/compressor/zstd_test -utils/wikistat-loader/wikistat-loader -src/Common/tests/pod_array - -src/Server/data/* -src/Server/metadata/* -src/Server/status -config-9001.xml *-preprocessed.xml @@ -241,9 +108,6 @@ website/package-lock.json .DS_Store */.DS_Store -# Ignore files for locally disabled tests -/src/queries/**/*.disabled - # cquery cache /.cquery-cache diff --git a/.gitmodules b/.gitmodules index cebde5699d8..c05da0c9ff9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -148,9 +148,23 @@ path = contrib/avro url = https://github.com/ClickHouse-Extras/avro.git ignore = untracked -[submodule "website/images/feathericons"] - path = website/images/feathericons - url = https://github.com/feathericons/feather [submodule "contrib/msgpack-c"] path = contrib/msgpack-c url = https://github.com/msgpack/msgpack-c +[submodule "contrib/libcpuid"] + path = contrib/libcpuid + url = https://github.com/ClickHouse-Extras/libcpuid.git +[submodule "contrib/openldap"] + path = contrib/openldap + url = https://github.com/openldap/openldap.git +[submodule "contrib/cassandra"] + path = contrib/cassandra + url = https://github.com/ClickHouse-Extras/cpp-driver.git + branch = clickhouse +[submodule "contrib/libuv"] + path = contrib/libuv + url = https://github.com/ClickHouse-Extras/libuv.git + branch = clickhouse +[submodule "contrib/fmtlib"] + path = contrib/fmtlib + url = https://github.com/fmtlib/fmt.git diff --git a/CHANGELOG.md b/CHANGELOG.md index e5d1c90bf22..6a4666f08bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,400 @@ +## ClickHouse release v20.4 + +### ClickHouse release v20.4.3.16-stable 2020-05-23 + +#### Bug Fix + +* Removed logging from mutation finalization task if nothing was finalized. [#11109](https://github.com/ClickHouse/ClickHouse/pull/11109) ([alesapin](https://github.com/alesapin)). +* Fixed memory leak in registerDiskS3. [#11074](https://github.com/ClickHouse/ClickHouse/pull/11074) ([Pavel Kovalenko](https://github.com/Jokser)). +* Fixed the potential missed data during termination of Kafka engine table. [#11048](https://github.com/ClickHouse/ClickHouse/pull/11048) ([filimonov](https://github.com/filimonov)). +* Fixed `parseDateTime64BestEffort` argument resolution bugs. [#11038](https://github.com/ClickHouse/ClickHouse/pull/11038) ([Vasily Nemkov](https://github.com/Enmk)). +* Fixed very rare potential use-after-free error in `MergeTree` if table was not created successfully. [#10986](https://github.com/ClickHouse/ClickHouse/pull/10986), [#10970](https://github.com/ClickHouse/ClickHouse/pull/10970) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed metadata (relative path for rename) and data (relative path for symlink) handling for Atomic database. [#10980](https://github.com/ClickHouse/ClickHouse/pull/10980) ([Azat Khuzhin](https://github.com/azat)). +* Fixed server crash on concurrent `ALTER` and `DROP DATABASE` queries with `Atomic` database engine. [#10968](https://github.com/ClickHouse/ClickHouse/pull/10968) ([tavplubix](https://github.com/tavplubix)). +* Fixed incorrect raw data size in `getRawData()` method. [#10964](https://github.com/ClickHouse/ClickHouse/pull/10964) ([Igr](https://github.com/ObjatieGroba)). +* Fixed incompatibility of two-level aggregation between versions 20.1 and earlier. This incompatibility happens when different versions of ClickHouse are used on initiator node and remote nodes and the size of GROUP BY result is large and aggregation is performed by a single String field. It leads to several unmerged rows for a single key in result. [#10952](https://github.com/ClickHouse/ClickHouse/pull/10952) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed sending partially written files by the `DistributedBlockOutputStream`. [#10940](https://github.com/ClickHouse/ClickHouse/pull/10940) ([Azat Khuzhin](https://github.com/azat)). +* Fixed crash in `SELECT count(notNullIn(NULL, []))`. [#10920](https://github.com/ClickHouse/ClickHouse/pull/10920) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed the hang which was happening sometimes during `DROP` of `Kafka` table engine. (or during server restarts). [#10910](https://github.com/ClickHouse/ClickHouse/pull/10910) ([filimonov](https://github.com/filimonov)). +* Fixed the impossibility of executing multiple `ALTER RENAME` like `a TO b, c TO a`. [#10895](https://github.com/ClickHouse/ClickHouse/pull/10895) ([alesapin](https://github.com/alesapin)). +* Fixed possible race which could happen when you get result from aggregate function state from multiple thread for the same column. The only way it can happen is when you use `finalizeAggregation` function while reading from table with `Memory` engine which stores `AggregateFunction` state for `quantile*` function. [#10890](https://github.com/ClickHouse/ClickHouse/pull/10890) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed backward compatibility with tuples in Distributed tables. [#10889](https://github.com/ClickHouse/ClickHouse/pull/10889) ([Anton Popov](https://github.com/CurtizJ)). +* Fixed `SIGSEGV` in `StringHashTable` if such a key does not exist. [#10870](https://github.com/ClickHouse/ClickHouse/pull/10870) ([Azat Khuzhin](https://github.com/azat)). +* Fixed `WATCH` hangs after `LiveView` table was dropped from database with `Atomic` engine. [#10859](https://github.com/ClickHouse/ClickHouse/pull/10859) ([tavplubix](https://github.com/tavplubix)). +* Fixed bug in `ReplicatedMergeTree` which might cause some `ALTER` on `OPTIMIZE` query to hang waiting for some replica after it become inactive. [#10849](https://github.com/ClickHouse/ClickHouse/pull/10849) ([tavplubix](https://github.com/tavplubix)). +* Now constraints are updated if the column participating in `CONSTRAINT` expression was renamed. Fixes [#10844](https://github.com/ClickHouse/ClickHouse/issues/10844). [#10847](https://github.com/ClickHouse/ClickHouse/pull/10847) ([alesapin](https://github.com/alesapin)). +* Fixed potential read of uninitialized memory in cache-dictionary. [#10834](https://github.com/ClickHouse/ClickHouse/pull/10834) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed columns order after `Block::sortColumns()`. [#10826](https://github.com/ClickHouse/ClickHouse/pull/10826) ([Azat Khuzhin](https://github.com/azat)). +* Fixed the issue with `ODBC` bridge when no quoting of identifiers is requested. Fixes [#7984] (https://github.com/ClickHouse/ClickHouse/issues/7984). [#10821](https://github.com/ClickHouse/ClickHouse/pull/10821) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed `UBSan` and `MSan` report in `DateLUT`. [#10798](https://github.com/ClickHouse/ClickHouse/pull/10798) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed incorrect type conversion in key conditions. Fixes [#6287](https://github.com/ClickHouse/ClickHouse/issues/6287). [#10791](https://github.com/ClickHouse/ClickHouse/pull/10791) ([Andrew Onyshchuk](https://github.com/oandrew)). +* Fixed `parallel_view_processing` behavior. Now all insertions into `MATERIALIZED VIEW` without exception should be finished if exception happened. Fixes [#10241](https://github.com/ClickHouse/ClickHouse/issues/10241). [#10757](https://github.com/ClickHouse/ClickHouse/pull/10757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed combinator `-OrNull` and `-OrDefault` when combined with `-State`. [#10741](https://github.com/ClickHouse/ClickHouse/pull/10741) ([hcz](https://github.com/hczhcz)). +* Fixed possible buffer overflow in function `h3EdgeAngle`. [#10711](https://github.com/ClickHouse/ClickHouse/pull/10711) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed bug which locks concurrent alters when table has a lot of parts. [#10659](https://github.com/ClickHouse/ClickHouse/pull/10659) ([alesapin](https://github.com/alesapin)). +* Fixed `nullptr` dereference in `StorageBuffer` if server was shutdown before table startup. [#10641](https://github.com/ClickHouse/ClickHouse/pull/10641) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed `optimize_skip_unused_shards` with `LowCardinality`. [#10611](https://github.com/ClickHouse/ClickHouse/pull/10611) ([Azat Khuzhin](https://github.com/azat)). +* Fixed handling condition variable for synchronous mutations. In some cases signals to that condition variable could be lost. [#10588](https://github.com/ClickHouse/ClickHouse/pull/10588) ([Vladimir Chebotarev](https://github.com/excitoon)). +* Fixed possible crash when `createDictionary()` is called before `loadStoredObject()` has finished. [#10587](https://github.com/ClickHouse/ClickHouse/pull/10587) ([Vitaly Baranov](https://github.com/vitlibar)). +* Fixed `SELECT` of column `ALIAS` which default expression type different from column type. [#10563](https://github.com/ClickHouse/ClickHouse/pull/10563) ([Azat Khuzhin](https://github.com/azat)). +* Implemented comparison between DateTime64 and String values. [#10560](https://github.com/ClickHouse/ClickHouse/pull/10560) ([Vasily Nemkov](https://github.com/Enmk)). +* Disable `GROUP BY` sharding_key optimization by default (`optimize_distributed_group_by_sharding_key` had been introduced and turned of by default, due to trickery of sharding_key analyzing, simple example is `if` in sharding key) and fix it for `WITH ROLLUP/CUBE/TOTALS`. [#10516](https://github.com/ClickHouse/ClickHouse/pull/10516) ([Azat Khuzhin](https://github.com/azat)). +* Fixed [#10263](https://github.com/ClickHouse/ClickHouse/issues/10263). [#10486](https://github.com/ClickHouse/ClickHouse/pull/10486) ([Azat Khuzhin](https://github.com/azat)). +* Added tests about `max_rows_to_sort` setting. [#10268](https://github.com/ClickHouse/ClickHouse/pull/10268) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Added backward compatibility for create bloom filter index. [#10551](https://github.com/ClickHouse/ClickHouse/issues/10551). [#10569](https://github.com/ClickHouse/ClickHouse/pull/10569) ([Winter Zhang](https://github.com/zhang2014)). + +### ClickHouse release v20.4.2.9, 2020-05-12 + +#### Backward Incompatible Change +* System tables (e.g. system.query_log, system.trace_log, system.metric_log) are using compact data part format for parts smaller than 10 MiB in size. Compact data part format is supported since version 20.3. If you are going to downgrade to version less than 20.3, you should manually delete table data for system logs in `/var/lib/clickhouse/data/system/`. +* When string comparison involves FixedString and compared arguments are of different sizes, do comparison as if smaller string is padded to the length of the larger. This is intented for SQL compatibility if we imagine that FixedString data type corresponds to SQL CHAR. This closes [#9272](https://github.com/ClickHouse/ClickHouse/issues/9272). [#10363](https://github.com/ClickHouse/ClickHouse/pull/10363) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Make SHOW CREATE TABLE multiline. Now it is more readable and more like MySQL. [#10049](https://github.com/ClickHouse/ClickHouse/pull/10049) ([Azat Khuzhin](https://github.com/azat)) +* Added a setting `validate_polygons` that is used in `pointInPolygon` function and enabled by default. [#9857](https://github.com/ClickHouse/ClickHouse/pull/9857) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### New Feature +* Add support for secured connection from ClickHouse to Zookeeper [#10184](https://github.com/ClickHouse/ClickHouse/pull/10184) ([Konstantin Lebedev](https://github.com/xzkostyan)) +* Support custom HTTP handlers. See ISSUES-5436 for description. [#7572](https://github.com/ClickHouse/ClickHouse/pull/7572) ([Winter Zhang](https://github.com/zhang2014)) +* Add MessagePack Input/Output format. [#9889](https://github.com/ClickHouse/ClickHouse/pull/9889) ([Kruglov Pavel](https://github.com/Avogar)) +* Add Regexp input format. [#9196](https://github.com/ClickHouse/ClickHouse/pull/9196) ([Kruglov Pavel](https://github.com/Avogar)) +* Added output format `Markdown` for embedding tables in markdown documents. [#10317](https://github.com/ClickHouse/ClickHouse/pull/10317) ([Kruglov Pavel](https://github.com/Avogar)) +* Added support for custom settings section in dictionaries. Also fixes issue [#2829](https://github.com/ClickHouse/ClickHouse/issues/2829). [#10137](https://github.com/ClickHouse/ClickHouse/pull/10137) ([Artem Streltsov](https://github.com/kekekekule)) +* Added custom settings support in DDL-queries for CREATE DICTIONARY [#10465](https://github.com/ClickHouse/ClickHouse/pull/10465) ([Artem Streltsov](https://github.com/kekekekule)) +* Add simple server-wide memory profiler that will collect allocation contexts when server memory usage becomes higher than the next allocation threshold. [#10444](https://github.com/ClickHouse/ClickHouse/pull/10444) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add setting `always_fetch_merged_part` which restrict replica to merge parts by itself and always prefer dowloading from other replicas. [#10379](https://github.com/ClickHouse/ClickHouse/pull/10379) ([alesapin](https://github.com/alesapin)) +* Add function JSONExtractKeysAndValuesRaw which extracts raw data from JSON objects [#10378](https://github.com/ClickHouse/ClickHouse/pull/10378) ([hcz](https://github.com/hczhcz)) +* Add memory usage from OS to `system.asynchronous_metrics`. [#10361](https://github.com/ClickHouse/ClickHouse/pull/10361) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Added generic variants for functions `least` and `greatest`. Now they work with arbitrary number of arguments of arbitrary types. This fixes [#4767](https://github.com/ClickHouse/ClickHouse/issues/4767) [#10318](https://github.com/ClickHouse/ClickHouse/pull/10318) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Now ClickHouse controls timeouts of dictionary sources on its side. Two new settings added to cache dictionary configuration: `strict_max_lifetime_seconds`, which is `max_lifetime` by default, and `query_wait_timeout_milliseconds`, which is one minute by default. The first settings is also useful with `allow_read_expired_keys` settings (to forbid reading very expired keys). [#10337](https://github.com/ClickHouse/ClickHouse/pull/10337) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +* Add log_queries_min_type to filter which entries will be written to query_log [#10053](https://github.com/ClickHouse/ClickHouse/pull/10053) ([Azat Khuzhin](https://github.com/azat)) +* Added function `isConstant`. This function checks whether its argument is constant expression and returns 1 or 0. It is intended for development, debugging and demonstration purposes. [#10198](https://github.com/ClickHouse/ClickHouse/pull/10198) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* add joinGetOrNull to return NULL when key is missing instead of returning the default value. [#10094](https://github.com/ClickHouse/ClickHouse/pull/10094) ([Amos Bird](https://github.com/amosbird)) +* Consider `NULL` to be equal to `NULL` in `IN` operator, if the option `transform_null_in` is set. [#10085](https://github.com/ClickHouse/ClickHouse/pull/10085) ([achimbab](https://github.com/achimbab)) +* Add `ALTER TABLE ... RENAME COLUMN` for MergeTree table engines family. [#9948](https://github.com/ClickHouse/ClickHouse/pull/9948) ([alesapin](https://github.com/alesapin)) +* Support parallel distributed INSERT SELECT. [#9759](https://github.com/ClickHouse/ClickHouse/pull/9759) ([vxider](https://github.com/Vxider)) +* Add ability to query Distributed over Distributed (w/o `distributed_group_by_no_merge`) ... [#9923](https://github.com/ClickHouse/ClickHouse/pull/9923) ([Azat Khuzhin](https://github.com/azat)) +* Add function `arrayReduceInRanges` which aggregates array elements in given ranges. [#9598](https://github.com/ClickHouse/ClickHouse/pull/9598) ([hcz](https://github.com/hczhcz)) +* Add Dictionary Status on prometheus exporter. [#9622](https://github.com/ClickHouse/ClickHouse/pull/9622) ([Guillaume Tassery](https://github.com/YiuRULE)) +* Add function arrayAUC [#8698](https://github.com/ClickHouse/ClickHouse/pull/8698) ([taiyang-li](https://github.com/taiyang-li)) +* Support `DROP VIEW` statement for better TPC-H compatibility. [#9831](https://github.com/ClickHouse/ClickHouse/pull/9831) ([Amos Bird](https://github.com/amosbird)) +* Add 'strict_order' option to windowFunnel() [#9773](https://github.com/ClickHouse/ClickHouse/pull/9773) ([achimbab](https://github.com/achimbab)) +* Support `DATE` and `TIMESTAMP` SQL operators, e.g. `SELECT date '2001-01-01'` [#9691](https://github.com/ClickHouse/ClickHouse/pull/9691) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Experimental Feature +* Added experimental database engine Atomic. It supports non-blocking `DROP` and `RENAME TABLE` queries and atomic `EXCHANGE TABLES t1 AND t2` query [#7512](https://github.com/ClickHouse/ClickHouse/pull/7512) ([tavplubix](https://github.com/tavplubix)) +* Initial support for ReplicatedMergeTree over S3 (it works in suboptimal way) [#10126](https://github.com/ClickHouse/ClickHouse/pull/10126) ([Pavel Kovalenko](https://github.com/Jokser)) + +#### Bug Fix +* Fixed incorrect scalar results inside inner query of `MATERIALIZED VIEW` in case if this query contained dependent table [#10603](https://github.com/ClickHouse/ClickHouse/pull/10603) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fixed bug, which caused HTTP requests to get stuck on client closing connection when `readonly=2` and `cancel_http_readonly_queries_on_client_close=1`. [#10684](https://github.com/ClickHouse/ClickHouse/pull/10684) ([tavplubix](https://github.com/tavplubix)) +* Fix segfault in StorageBuffer when exception is thrown on server startup. Fixes [#10550](https://github.com/ClickHouse/ClickHouse/issues/10550) [#10609](https://github.com/ClickHouse/ClickHouse/pull/10609) ([tavplubix](https://github.com/tavplubix)) +* The query`SYSTEM DROP DNS CACHE` now also drops caches used to check if user is allowed to connect from some IP addresses [#10608](https://github.com/ClickHouse/ClickHouse/pull/10608) ([tavplubix](https://github.com/tavplubix)) +* Fix usage of multiple `IN` operators with an identical set in one query. Fixes [#10539](https://github.com/ClickHouse/ClickHouse/issues/10539) [#10686](https://github.com/ClickHouse/ClickHouse/pull/10686) ([Anton Popov](https://github.com/CurtizJ)) +* Fix crash in `generateRandom` with nested types. Fixes [#10583](https://github.com/ClickHouse/ClickHouse/issues/10583). [#10734](https://github.com/ClickHouse/ClickHouse/pull/10734) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix data corruption for `LowCardinality(FixedString)` key column in `SummingMergeTree` which could have happened after merge. Fixes [#10489](https://github.com/ClickHouse/ClickHouse/issues/10489). [#10721](https://github.com/ClickHouse/ClickHouse/pull/10721) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix logic for aggregation_memory_efficient_merge_threads setting. [#10667](https://github.com/ClickHouse/ClickHouse/pull/10667) ([palasonic1](https://github.com/palasonic1)) +* Fix disappearing totals. Totals could have being filtered if query had `JOIN` or subquery with external `WHERE` condition. Fixes [#10674](https://github.com/ClickHouse/ClickHouse/issues/10674) [#10698](https://github.com/ClickHouse/ClickHouse/pull/10698) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix the lack of parallel execution of remote queries with `distributed_aggregation_memory_efficient` enabled. Fixes [#10655](https://github.com/ClickHouse/ClickHouse/issues/10655) [#10664](https://github.com/ClickHouse/ClickHouse/pull/10664) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix possible incorrect number of rows for queries with `LIMIT`. Fixes [#10566](https://github.com/ClickHouse/ClickHouse/issues/10566), [#10709](https://github.com/ClickHouse/ClickHouse/issues/10709) [#10660](https://github.com/ClickHouse/ClickHouse/pull/10660) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix index corruption, which may occur in some cases after merging compact parts into another compact part. [#10531](https://github.com/ClickHouse/ClickHouse/pull/10531) ([Anton Popov](https://github.com/CurtizJ)) +* Fix the situation, when mutation finished all parts, but hung up in `is_done=0`. [#10526](https://github.com/ClickHouse/ClickHouse/pull/10526) ([alesapin](https://github.com/alesapin)) +* Fix overflow at beginning of unix epoch for timezones with fractional offset from UTC. Fixes [#9335](https://github.com/ClickHouse/ClickHouse/issues/9335). [#10513](https://github.com/ClickHouse/ClickHouse/pull/10513) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Better diagnostics for input formats. Fixes [#10204](https://github.com/ClickHouse/ClickHouse/issues/10204) [#10418](https://github.com/ClickHouse/ClickHouse/pull/10418) ([tavplubix](https://github.com/tavplubix)) +* Fix numeric overflow in `simpleLinearRegression()` over large integers [#10474](https://github.com/ClickHouse/ClickHouse/pull/10474) ([hcz](https://github.com/hczhcz)) +* Fix use-after-free in Distributed shutdown, avoid waiting for sending all batches [#10491](https://github.com/ClickHouse/ClickHouse/pull/10491) ([Azat Khuzhin](https://github.com/azat)) +* Add CA certificates to clickhouse-server docker image [#10476](https://github.com/ClickHouse/ClickHouse/pull/10476) ([filimonov](https://github.com/filimonov)) +* Fix a rare endless loop that might have occurred when using the `addressToLine` function or AggregateFunctionState columns. [#10466](https://github.com/ClickHouse/ClickHouse/pull/10466) ([Alexander Kuzmenkov](https://github.com/akuzm)) +* Handle zookeeper "no node error" during distributed query [#10050](https://github.com/ClickHouse/ClickHouse/pull/10050) ([Daniel Chen](https://github.com/Phantomape)) +* Fix bug when server cannot attach table after column's default was altered. [#10441](https://github.com/ClickHouse/ClickHouse/pull/10441) ([alesapin](https://github.com/alesapin)) +* Implicitly cast the default expression type to the column type for the ALIAS columns [#10563](https://github.com/ClickHouse/ClickHouse/pull/10563) ([Azat Khuzhin](https://github.com/azat)) +* Don't remove metadata directory if `ATTACH DATABASE` fails [#10442](https://github.com/ClickHouse/ClickHouse/pull/10442) ([Winter Zhang](https://github.com/zhang2014)) +* Avoid dependency on system tzdata. Fixes loading of `Africa/Casablanca` timezone on CentOS 8. Fixes [#10211](https://github.com/ClickHouse/ClickHouse/issues/10211) [#10425](https://github.com/ClickHouse/ClickHouse/pull/10425) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix some issues if data is inserted with quorum and then gets deleted (DROP PARTITION, TTL, etc.). It led to stuck of INSERTs or false-positive exceptions in SELECTs. Fixes [#9946](https://github.com/ClickHouse/ClickHouse/issues/9946) [#10188](https://github.com/ClickHouse/ClickHouse/pull/10188) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +* Check the number and type of arguments when creating BloomFilter index [#9623](https://github.com/ClickHouse/ClickHouse/issues/9623) [#10431](https://github.com/ClickHouse/ClickHouse/pull/10431) ([Winter Zhang](https://github.com/zhang2014)) +* Prefer `fallback_to_stale_replicas` over `skip_unavailable_shards`, otherwise when both settings specified and there are no up-to-date replicas the query will fail (patch from @alex-zaitsev ) [#10422](https://github.com/ClickHouse/ClickHouse/pull/10422) ([Azat Khuzhin](https://github.com/azat)) +* Fix the issue when a query with ARRAY JOIN, ORDER BY and LIMIT may return incomplete result. Fixes [#10226](https://github.com/ClickHouse/ClickHouse/issues/10226). [#10427](https://github.com/ClickHouse/ClickHouse/pull/10427) ([Vadim Plakhtinskiy](https://github.com/VadimPlh)) +* Add database name to dictionary name after DETACH/ATTACH. Fixes system.dictionaries table and `SYSTEM RELOAD` query [#10415](https://github.com/ClickHouse/ClickHouse/pull/10415) ([Azat Khuzhin](https://github.com/azat)) +* Fix possible incorrect result for extremes in processors pipeline. [#10131](https://github.com/ClickHouse/ClickHouse/pull/10131) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix possible segfault when the setting `distributed_group_by_no_merge` is enabled (introduced in 20.3.7.46 by [#10131](https://github.com/ClickHouse/ClickHouse/issues/10131)). [#10399](https://github.com/ClickHouse/ClickHouse/pull/10399) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix wrong flattening of `Array(Tuple(...))` data types. Fixes [#10259](https://github.com/ClickHouse/ClickHouse/issues/10259) [#10390](https://github.com/ClickHouse/ClickHouse/pull/10390) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix column names of constants inside JOIN that may clash with names of constants outside of JOIN [#9950](https://github.com/ClickHouse/ClickHouse/pull/9950) ([Alexander Kuzmenkov](https://github.com/akuzm)) +* Fix order of columns after Block::sortColumns() [#10826](https://github.com/ClickHouse/ClickHouse/pull/10826) ([Azat Khuzhin](https://github.com/azat)) +* Fix possible `Pipeline stuck` error in `ConcatProcessor` which may happen in remote query. [#10381](https://github.com/ClickHouse/ClickHouse/pull/10381) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Don't make disk reservations for aggregations. Fixes [#9241](https://github.com/ClickHouse/ClickHouse/issues/9241) [#10375](https://github.com/ClickHouse/ClickHouse/pull/10375) ([Azat Khuzhin](https://github.com/azat)) +* Fix wrong behaviour of datetime functions for timezones that has altered between positive and negative offsets from UTC (e.g. Pacific/Kiritimati). Fixes [#7202](https://github.com/ClickHouse/ClickHouse/issues/7202) [#10369](https://github.com/ClickHouse/ClickHouse/pull/10369) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Avoid infinite loop in `dictIsIn` function. Fixes #515 [#10365](https://github.com/ClickHouse/ClickHouse/pull/10365) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Disable GROUP BY sharding_key optimization by default and fix it for WITH ROLLUP/CUBE/TOTALS [#10516](https://github.com/ClickHouse/ClickHouse/pull/10516) ([Azat Khuzhin](https://github.com/azat)) +* Check for error code when checking parts and don't mark part as broken if the error is like "not enough memory". Fixes [#6269](https://github.com/ClickHouse/ClickHouse/issues/6269) [#10364](https://github.com/ClickHouse/ClickHouse/pull/10364) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Show information about not loaded dictionaries in system tables. [#10234](https://github.com/ClickHouse/ClickHouse/pull/10234) ([Vitaly Baranov](https://github.com/vitlibar)) +* Fix nullptr dereference in StorageBuffer if server was shutdown before table startup. [#10641](https://github.com/ClickHouse/ClickHouse/pull/10641) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fixed `DROP` vs `OPTIMIZE` race in `ReplicatedMergeTree`. `DROP` could left some garbage in replica path in ZooKeeper if there was concurrent `OPTIMIZE` query. [#10312](https://github.com/ClickHouse/ClickHouse/pull/10312) ([tavplubix](https://github.com/tavplubix)) +* Fix 'Logical error: CROSS JOIN has expressions' error for queries with comma and names joins mix. Fixes [#9910](https://github.com/ClickHouse/ClickHouse/issues/9910) [#10311](https://github.com/ClickHouse/ClickHouse/pull/10311) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix queries with `max_bytes_before_external_group_by`. [#10302](https://github.com/ClickHouse/ClickHouse/pull/10302) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix the issue with limiting maximum recursion depth in parser in certain cases. This fixes [#10283](https://github.com/ClickHouse/ClickHouse/issues/10283) This fix may introduce minor incompatibility: long and deep queries via clickhouse-client may refuse to work, and you should adjust settings `max_query_size` and `max_parser_depth` accordingly. [#10295](https://github.com/ClickHouse/ClickHouse/pull/10295) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Allow to use `count(*)` with multiple JOINs. Fixes [#9853](https://github.com/ClickHouse/ClickHouse/issues/9853) [#10291](https://github.com/ClickHouse/ClickHouse/pull/10291) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix error `Pipeline stuck` with `max_rows_to_group_by` and `group_by_overflow_mode = 'break'`. [#10279](https://github.com/ClickHouse/ClickHouse/pull/10279) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix 'Cannot add column' error while creating `range_hashed` dictionary using DDL query. Fixes [#10093](https://github.com/ClickHouse/ClickHouse/issues/10093). [#10235](https://github.com/ClickHouse/ClickHouse/pull/10235) ([alesapin](https://github.com/alesapin)) +* Fix rare possible exception `Cannot drain connections: cancel first`. [#10239](https://github.com/ClickHouse/ClickHouse/pull/10239) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fixed bug where ClickHouse would throw "Unknown function lambda." error message when user tries to run ALTER UPDATE/DELETE on tables with ENGINE = Replicated*. Check for nondeterministic functions now handles lambda expressions correctly. [#10237](https://github.com/ClickHouse/ClickHouse/pull/10237) ([Alexander Kazakov](https://github.com/Akazz)) +* Fixed reasonably rare segfault in StorageSystemTables that happens when SELECT ... FROM system.tables is run on a database with Lazy engine. [#10209](https://github.com/ClickHouse/ClickHouse/pull/10209) ([Alexander Kazakov](https://github.com/Akazz)) +* Fix possible infinite query execution when the query actually should stop on LIMIT, while reading from infinite source like `system.numbers` or `system.zeros`. [#10206](https://github.com/ClickHouse/ClickHouse/pull/10206) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fixed "generateRandom" function for Date type. This fixes [#9973](https://github.com/ClickHouse/ClickHouse/issues/9973). Fix an edge case when dates with year 2106 are inserted to MergeTree tables with old-style partitioning but partitions are named with year 1970. [#10218](https://github.com/ClickHouse/ClickHouse/pull/10218) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Convert types if the table definition of a View does not correspond to the SELECT query. This fixes [#10180](https://github.com/ClickHouse/ClickHouse/issues/10180) and [#10022](https://github.com/ClickHouse/ClickHouse/issues/10022) [#10217](https://github.com/ClickHouse/ClickHouse/pull/10217) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix `parseDateTimeBestEffort` for strings in RFC-2822 when day of week is Tuesday or Thursday. This fixes [#10082](https://github.com/ClickHouse/ClickHouse/issues/10082) [#10214](https://github.com/ClickHouse/ClickHouse/pull/10214) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix column names of constants inside JOIN that may clash with names of constants outside of JOIN. [#10207](https://github.com/ClickHouse/ClickHouse/pull/10207) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix move-to-prewhere optimization in presense of arrayJoin functions (in certain cases). This fixes [#10092](https://github.com/ClickHouse/ClickHouse/issues/10092) [#10195](https://github.com/ClickHouse/ClickHouse/pull/10195) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix issue with separator appearing in SCRAMBLE for native mysql-connector-java (JDBC) [#10140](https://github.com/ClickHouse/ClickHouse/pull/10140) ([BohuTANG](https://github.com/BohuTANG)) +* Fix using the current database for an access checking when the database isn't specified. [#10192](https://github.com/ClickHouse/ClickHouse/pull/10192) ([Vitaly Baranov](https://github.com/vitlibar)) +* Fix ALTER of tables with compact parts. [#10130](https://github.com/ClickHouse/ClickHouse/pull/10130) ([Anton Popov](https://github.com/CurtizJ)) +* Add the ability to relax the restriction on non-deterministic functions usage in mutations with `allow_nondeterministic_mutations` setting. [#10186](https://github.com/ClickHouse/ClickHouse/pull/10186) ([filimonov](https://github.com/filimonov)) +* Fix `DROP TABLE` invoked for dictionary [#10165](https://github.com/ClickHouse/ClickHouse/pull/10165) ([Azat Khuzhin](https://github.com/azat)) +* Convert blocks if structure does not match when doing `INSERT` into Distributed table [#10135](https://github.com/ClickHouse/ClickHouse/pull/10135) ([Azat Khuzhin](https://github.com/azat)) +* The number of rows was logged incorrectly (as sum across all parts) when inserted block is split by parts with partition key. [#10138](https://github.com/ClickHouse/ClickHouse/pull/10138) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add some arguments check and support identifier arguments for MySQL Database Engine [#10077](https://github.com/ClickHouse/ClickHouse/pull/10077) ([Winter Zhang](https://github.com/zhang2014)) +* Fix incorrect `index_granularity_bytes` check while creating new replica. Fixes [#10098](https://github.com/ClickHouse/ClickHouse/issues/10098). [#10121](https://github.com/ClickHouse/ClickHouse/pull/10121) ([alesapin](https://github.com/alesapin)) +* Fix bug in `CHECK TABLE` query when table contain skip indices. [#10068](https://github.com/ClickHouse/ClickHouse/pull/10068) ([alesapin](https://github.com/alesapin)) +* Fix Distributed-over-Distributed with the only one shard in a nested table [#9997](https://github.com/ClickHouse/ClickHouse/pull/9997) ([Azat Khuzhin](https://github.com/azat)) +* Fix possible rows loss for queries with `JOIN` and `UNION ALL`. Fixes [#9826](https://github.com/ClickHouse/ClickHouse/issues/9826), [#10113](https://github.com/ClickHouse/ClickHouse/issues/10113). ... [#10099](https://github.com/ClickHouse/ClickHouse/pull/10099) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix bug in dictionary when local clickhouse server is used as source. It may caused memory corruption if types in dictionary and source are not compatible. [#10071](https://github.com/ClickHouse/ClickHouse/pull/10071) ([alesapin](https://github.com/alesapin)) +* Fixed replicated tables startup when updating from an old ClickHouse version where `/table/replicas/replica_name/metadata` node doesn't exist. Fixes [#10037](https://github.com/ClickHouse/ClickHouse/issues/10037). [#10095](https://github.com/ClickHouse/ClickHouse/pull/10095) ([alesapin](https://github.com/alesapin)) +* Fix error `Cannot clone block with columns because block has 0 columns ... While executing GroupingAggregatedTransform`. It happened when setting `distributed_aggregation_memory_efficient` was enabled, and distributed query read aggregating data with mixed single and two-level aggregation from different shards. [#10063](https://github.com/ClickHouse/ClickHouse/pull/10063) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix deadlock when database with materialized view failed attach at start [#10054](https://github.com/ClickHouse/ClickHouse/pull/10054) ([Azat Khuzhin](https://github.com/azat)) +* Fix a segmentation fault that could occur in GROUP BY over string keys containing trailing zero bytes ([#8636](https://github.com/ClickHouse/ClickHouse/issues/8636), [#8925](https://github.com/ClickHouse/ClickHouse/issues/8925)). ... [#10025](https://github.com/ClickHouse/ClickHouse/pull/10025) ([Alexander Kuzmenkov](https://github.com/akuzm)) +* Fix wrong results of distributed queries when alias could override qualified column name. Fixes [#9672](https://github.com/ClickHouse/ClickHouse/issues/9672) [#9714](https://github.com/ClickHouse/ClickHouse/issues/9714) [#9972](https://github.com/ClickHouse/ClickHouse/pull/9972) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix possible deadlock in `SYSTEM RESTART REPLICAS` [#9955](https://github.com/ClickHouse/ClickHouse/pull/9955) ([tavplubix](https://github.com/tavplubix)) +* Fix the number of threads used for remote query execution (performance regression, since 20.3). This happened when query from `Distributed` table was executed simultaneously on local and remote shards. Fixes [#9965](https://github.com/ClickHouse/ClickHouse/issues/9965) [#9971](https://github.com/ClickHouse/ClickHouse/pull/9971) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fixed `DeleteOnDestroy` logic in `ATTACH PART` which could lead to automatic removal of attached part and added few tests [#9410](https://github.com/ClickHouse/ClickHouse/pull/9410) ([Vladimir Chebotarev](https://github.com/excitoon)) +* Fix a bug with `ON CLUSTER` DDL queries freezing on server startup. [#9927](https://github.com/ClickHouse/ClickHouse/pull/9927) ([Gagan Arneja](https://github.com/garneja)) +* Fix bug in which the necessary tables weren't retrieved at one of the processing stages of queries to some databases. Fixes [#9699](https://github.com/ClickHouse/ClickHouse/issues/9699). [#9949](https://github.com/ClickHouse/ClickHouse/pull/9949) ([achulkov2](https://github.com/achulkov2)) +* Fix 'Not found column in block' error when `JOIN` appears with `TOTALS`. Fixes [#9839](https://github.com/ClickHouse/ClickHouse/issues/9839) [#9939](https://github.com/ClickHouse/ClickHouse/pull/9939) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix parsing multiple hosts set in the CREATE USER command [#9924](https://github.com/ClickHouse/ClickHouse/pull/9924) ([Vitaly Baranov](https://github.com/vitlibar)) +* Fix `TRUNCATE` for Join table engine ([#9917](https://github.com/ClickHouse/ClickHouse/issues/9917)). [#9920](https://github.com/ClickHouse/ClickHouse/pull/9920) ([Amos Bird](https://github.com/amosbird)) +* Fix race condition between drop and optimize in `ReplicatedMergeTree`. [#9901](https://github.com/ClickHouse/ClickHouse/pull/9901) ([alesapin](https://github.com/alesapin)) +* Fix `DISTINCT` for Distributed when `optimize_skip_unused_shards` is set. [#9808](https://github.com/ClickHouse/ClickHouse/pull/9808) ([Azat Khuzhin](https://github.com/azat)) +* Fix "scalar doesn't exist" error in ALTERs ([#9878](https://github.com/ClickHouse/ClickHouse/issues/9878)). ... [#9904](https://github.com/ClickHouse/ClickHouse/pull/9904) ([Amos Bird](https://github.com/amosbird)) +* Fix error with qualified names in `distributed_product_mode=\'local\'`. Fixes [#4756](https://github.com/ClickHouse/ClickHouse/issues/4756) [#9891](https://github.com/ClickHouse/ClickHouse/pull/9891) ([Artem Zuikov](https://github.com/4ertus2)) +* For INSERT queries shards now do clamp the settings from the initiator to their constraints instead of throwing an exception. This fix allows to send INSERT queries to a shard with another constraints. This change improves fix [#9447](https://github.com/ClickHouse/ClickHouse/issues/9447). [#9852](https://github.com/ClickHouse/ClickHouse/pull/9852) ([Vitaly Baranov](https://github.com/vitlibar)) +* Add some retries when commiting offsets to Kafka broker, since it can reject commit if during `offsets.commit.timeout.ms` there were no enough replicas available for the `__consumer_offsets` topic [#9884](https://github.com/ClickHouse/ClickHouse/pull/9884) ([filimonov](https://github.com/filimonov)) +* Fix Distributed engine behavior when virtual columns of the underlying table used in `WHERE` [#9847](https://github.com/ClickHouse/ClickHouse/pull/9847) ([Azat Khuzhin](https://github.com/azat)) +* Fixed some cases when timezone of the function argument wasn't used properly. [#9574](https://github.com/ClickHouse/ClickHouse/pull/9574) ([Vasily Nemkov](https://github.com/Enmk)) +* Fix 'Different expressions with the same alias' error when query has PREWHERE and WHERE on distributed table and `SET distributed_product_mode = 'local'`. [#9871](https://github.com/ClickHouse/ClickHouse/pull/9871) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix mutations excessive memory consumption for tables with a composite primary key. This fixes [#9850](https://github.com/ClickHouse/ClickHouse/issues/9850). [#9860](https://github.com/ClickHouse/ClickHouse/pull/9860) ([alesapin](https://github.com/alesapin)) +* Fix calculating grants for introspection functions from the setting `allow_introspection_functions`. [#9840](https://github.com/ClickHouse/ClickHouse/pull/9840) ([Vitaly Baranov](https://github.com/vitlibar)) +* Fix max_distributed_connections (w/ and w/o Processors) [#9673](https://github.com/ClickHouse/ClickHouse/pull/9673) ([Azat Khuzhin](https://github.com/azat)) +* Fix possible exception `Got 0 in totals chunk, expected 1` on client. It happened for queries with `JOIN` in case if right joined table had zero rows. Example: `select * from system.one t1 join system.one t2 on t1.dummy = t2.dummy limit 0 FORMAT TabSeparated;`. Fixes [#9777](https://github.com/ClickHouse/ClickHouse/issues/9777). ... [#9823](https://github.com/ClickHouse/ClickHouse/pull/9823) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix 'COMMA to CROSS JOIN rewriter is not enabled or cannot rewrite query' error in case of subqueries with COMMA JOIN out of tables lists (i.e. in WHERE). Fixes [#9782](https://github.com/ClickHouse/ClickHouse/issues/9782) [#9830](https://github.com/ClickHouse/ClickHouse/pull/9830) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix server crashing when `optimize_skip_unused_shards` is set and expression for key can't be converted to its field type [#9804](https://github.com/ClickHouse/ClickHouse/pull/9804) ([Azat Khuzhin](https://github.com/azat)) +* Fix empty string handling in `splitByString`. [#9767](https://github.com/ClickHouse/ClickHouse/pull/9767) ([hcz](https://github.com/hczhcz)) +* Fix broken `ALTER TABLE DELETE COLUMN` query for compact parts. [#9779](https://github.com/ClickHouse/ClickHouse/pull/9779) ([alesapin](https://github.com/alesapin)) +* Fixed missing `rows_before_limit_at_least` for queries over http (with processors pipeline). Fixes [#9730](https://github.com/ClickHouse/ClickHouse/issues/9730) [#9757](https://github.com/ClickHouse/ClickHouse/pull/9757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix excessive memory consumption in `ALTER` queries (mutations). This fixes [#9533](https://github.com/ClickHouse/ClickHouse/issues/9533) and [#9670](https://github.com/ClickHouse/ClickHouse/issues/9670). [#9754](https://github.com/ClickHouse/ClickHouse/pull/9754) ([alesapin](https://github.com/alesapin)) +* Fix possible permanent "Cannot schedule a task" error. [#9154](https://github.com/ClickHouse/ClickHouse/pull/9154) ([Azat Khuzhin](https://github.com/azat)) +* Fix bug in backquoting in external dictionaries DDL. Fixes [#9619](https://github.com/ClickHouse/ClickHouse/issues/9619). [#9734](https://github.com/ClickHouse/ClickHouse/pull/9734) ([alesapin](https://github.com/alesapin)) +* Fixed data race in `text_log`. It does not correspond to any real bug. [#9726](https://github.com/ClickHouse/ClickHouse/pull/9726) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix bug in a replication that doesn't allow replication to work if the user has executed mutations on the previous version. This fixes [#9645](https://github.com/ClickHouse/ClickHouse/issues/9645). [#9652](https://github.com/ClickHouse/ClickHouse/pull/9652) ([alesapin](https://github.com/alesapin)) +* Fixed incorrect internal function names for `sumKahan` and `sumWithOverflow`. It led to exception while using this functions in remote queries. [#9636](https://github.com/ClickHouse/ClickHouse/pull/9636) ([Azat Khuzhin](https://github.com/azat)) +* Add setting `use_compact_format_in_distributed_parts_names` which allows to write files for `INSERT` queries into `Distributed` table with more compact format. This fixes [#9647](https://github.com/ClickHouse/ClickHouse/issues/9647). [#9653](https://github.com/ClickHouse/ClickHouse/pull/9653) ([alesapin](https://github.com/alesapin)) +* Fix RIGHT and FULL JOIN with LowCardinality in JOIN keys. [#9610](https://github.com/ClickHouse/ClickHouse/pull/9610) ([Artem Zuikov](https://github.com/4ertus2)) +* Fix possible exceptions `Size of filter doesn't match size of column` and `Invalid number of rows in Chunk` in `MergeTreeRangeReader`. They could appear while executing `PREWHERE` in some cases. [#9612](https://github.com/ClickHouse/ClickHouse/pull/9612) ([Anton Popov](https://github.com/CurtizJ)) +* Allow `ALTER ON CLUSTER` of Distributed tables with internal replication. This fixes [#3268](https://github.com/ClickHouse/ClickHouse/issues/3268) [#9617](https://github.com/ClickHouse/ClickHouse/pull/9617) ([shinoi2](https://github.com/shinoi2)) +* Fix issue when timezone was not preserved if you write a simple arithmetic expression like `time + 1` (in contrast to an expression like `time + INTERVAL 1 SECOND`). This fixes [#5743](https://github.com/ClickHouse/ClickHouse/issues/5743) [#9323](https://github.com/ClickHouse/ClickHouse/pull/9323) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Improvement +* Use time zone when comparing DateTime with string literal. This fixes [#5206](https://github.com/ClickHouse/ClickHouse/issues/5206). [#10515](https://github.com/ClickHouse/ClickHouse/pull/10515) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Print verbose diagnostic info if Decimal value cannot be parsed from text input format. [#10205](https://github.com/ClickHouse/ClickHouse/pull/10205) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add tasks/memory metrics for distributed/buffer schedule pools [#10449](https://github.com/ClickHouse/ClickHouse/pull/10449) ([Azat Khuzhin](https://github.com/azat)) +* Display result as soon as it's ready for SELECT DISTINCT queries in clickhouse-local and HTTP interface. This fixes [#8951](https://github.com/ClickHouse/ClickHouse/issues/8951) [#9559](https://github.com/ClickHouse/ClickHouse/pull/9559) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Allow to use `SAMPLE OFFSET` query instead of `cityHash64(PRIMARY KEY) % N == n` for splitting in `clickhouse-copier`. To use this feature, pass `--experimental-use-sample-offset 1` as a command line argument. [#10414](https://github.com/ClickHouse/ClickHouse/pull/10414) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +* Allow to parse BOM in TSV if the first column cannot contain BOM in its value. This fixes [#10301](https://github.com/ClickHouse/ClickHouse/issues/10301) [#10424](https://github.com/ClickHouse/ClickHouse/pull/10424) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add Avro nested fields insert support [#10354](https://github.com/ClickHouse/ClickHouse/pull/10354) ([Andrew Onyshchuk](https://github.com/oandrew)) +* Allowed to alter column in non-modifying data mode when the same type is specified. [#10382](https://github.com/ClickHouse/ClickHouse/pull/10382) ([Vladimir Chebotarev](https://github.com/excitoon)) +* Auto `distributed_group_by_no_merge` on GROUP BY sharding key (if `optimize_skip_unused_shards` is set) [#10341](https://github.com/ClickHouse/ClickHouse/pull/10341) ([Azat Khuzhin](https://github.com/azat)) +* Optimize queries with LIMIT/LIMIT BY/ORDER BY for distributed with GROUP BY sharding_key [#10373](https://github.com/ClickHouse/ClickHouse/pull/10373) ([Azat Khuzhin](https://github.com/azat)) +* Added a setting `max_server_memory_usage` to limit total memory usage of the server. The metric `MemoryTracking` is now calculated without a drift. The setting `max_memory_usage_for_all_queries` is now obsolete and does nothing. This closes [#10293](https://github.com/ClickHouse/ClickHouse/issues/10293). [#10362](https://github.com/ClickHouse/ClickHouse/pull/10362) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add config option `system_tables_lazy_load`. If it's set to false, then system tables with logs are loaded at the server startup. [Alexander Burmak](https://github.com/Alex-Burmak), [Svyatoslav Tkhon Il Pak](https://github.com/DeifyTheGod), [#9642](https://github.com/ClickHouse/ClickHouse/pull/9642) [#10359](https://github.com/ClickHouse/ClickHouse/pull/10359) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Use background thread pool (background_schedule_pool_size) for distributed sends [#10263](https://github.com/ClickHouse/ClickHouse/pull/10263) ([Azat Khuzhin](https://github.com/azat)) +* Use background thread pool for background buffer flushes. [#10315](https://github.com/ClickHouse/ClickHouse/pull/10315) ([Azat Khuzhin](https://github.com/azat)) +* Support for one special case of removing incompletely written parts. This fixes [#9940](https://github.com/ClickHouse/ClickHouse/issues/9940). [#10221](https://github.com/ClickHouse/ClickHouse/pull/10221) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Use isInjective() over manual list of such functions for GROUP BY optimization. [#10342](https://github.com/ClickHouse/ClickHouse/pull/10342) ([Azat Khuzhin](https://github.com/azat)) +* Avoid printing error message in log if client sends RST packet immediately on connect. It is typical behaviour of IPVS balancer with keepalived and VRRP. This fixes [#1851](https://github.com/ClickHouse/ClickHouse/issues/1851) [#10274](https://github.com/ClickHouse/ClickHouse/pull/10274) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Allow to parse `+inf` for floating point types. This closes [#1839](https://github.com/ClickHouse/ClickHouse/issues/1839) [#10272](https://github.com/ClickHouse/ClickHouse/pull/10272) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Implemented `generateRandom` table function for Nested types. This closes [#9903](https://github.com/ClickHouse/ClickHouse/issues/9903) [#10219](https://github.com/ClickHouse/ClickHouse/pull/10219) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Provide `max_allowed_packed` in MySQL compatibility interface that will help some clients to communicate with ClickHouse via MySQL protocol. [#10199](https://github.com/ClickHouse/ClickHouse/pull/10199) ([BohuTANG](https://github.com/BohuTANG)) +* Allow literals for GLOBAL IN (i.e. `SELECT * FROM remote('localhost', system.one) WHERE dummy global in (0)`) [#10196](https://github.com/ClickHouse/ClickHouse/pull/10196) ([Azat Khuzhin](https://github.com/azat)) +* Fix various small issues in interactive mode of clickhouse-client [#10194](https://github.com/ClickHouse/ClickHouse/pull/10194) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Avoid superfluous dictionaries load (system.tables, DROP/SHOW CREATE TABLE) [#10164](https://github.com/ClickHouse/ClickHouse/pull/10164) ([Azat Khuzhin](https://github.com/azat)) +* Update to RWLock: timeout parameter for getLock() + implementation reworked to be phase fair [#10073](https://github.com/ClickHouse/ClickHouse/pull/10073) ([Alexander Kazakov](https://github.com/Akazz)) +* Enhanced compatibility with native mysql-connector-java(JDBC) [#10021](https://github.com/ClickHouse/ClickHouse/pull/10021) ([BohuTANG](https://github.com/BohuTANG)) +* The function `toString` is considered monotonic and can be used for index analysis even when applied in tautological cases with String or LowCardinality(String) argument. [#10110](https://github.com/ClickHouse/ClickHouse/pull/10110) ([Amos Bird](https://github.com/amosbird)) +* Add `ON CLUSTER` clause support to commands `{CREATE|DROP} USER/ROLE/ROW POLICY/SETTINGS PROFILE/QUOTA`, `GRANT`. [#9811](https://github.com/ClickHouse/ClickHouse/pull/9811) ([Vitaly Baranov](https://github.com/vitlibar)) +* Virtual hosted-style support for S3 URI [#9998](https://github.com/ClickHouse/ClickHouse/pull/9998) ([Pavel Kovalenko](https://github.com/Jokser)) +* Now layout type for dictionaries with no arguments can be specified without round brackets in dictionaries DDL-queries. Fixes [#10057](https://github.com/ClickHouse/ClickHouse/issues/10057). [#10064](https://github.com/ClickHouse/ClickHouse/pull/10064) ([alesapin](https://github.com/alesapin)) +* Add ability to use number ranges with leading zeros in filepath [#9989](https://github.com/ClickHouse/ClickHouse/pull/9989) ([Olga Khvostikova](https://github.com/stavrolia)) +* Better memory usage in CROSS JOIN. [#10029](https://github.com/ClickHouse/ClickHouse/pull/10029) ([Artem Zuikov](https://github.com/4ertus2)) +* Try to connect to all shards in cluster when getting structure of remote table and skip_unavailable_shards is set. [#7278](https://github.com/ClickHouse/ClickHouse/pull/7278) ([nvartolomei](https://github.com/nvartolomei)) +* Add `total_rows`/`total_bytes` into the `system.tables` table. [#9919](https://github.com/ClickHouse/ClickHouse/pull/9919) ([Azat Khuzhin](https://github.com/azat)) +* System log tables now use polymorpic parts by default. [#9905](https://github.com/ClickHouse/ClickHouse/pull/9905) ([Anton Popov](https://github.com/CurtizJ)) +* Add type column into system.settings/merge_tree_settings [#9909](https://github.com/ClickHouse/ClickHouse/pull/9909) ([Azat Khuzhin](https://github.com/azat)) +* Check for available CPU instructions at server startup as early as possible. [#9888](https://github.com/ClickHouse/ClickHouse/pull/9888) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Remove `ORDER BY` stage from mutations because we read from a single ordered part in a single thread. Also add check that the rows in mutation are ordered by sorting key and this order is not violated. [#9886](https://github.com/ClickHouse/ClickHouse/pull/9886) ([alesapin](https://github.com/alesapin)) +* Implement operator LIKE for FixedString at left hand side. This is needed to better support TPC-DS queries. [#9890](https://github.com/ClickHouse/ClickHouse/pull/9890) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add `force_optimize_skip_unused_shards_no_nested` that will disable `force_optimize_skip_unused_shards` for nested Distributed table [#9812](https://github.com/ClickHouse/ClickHouse/pull/9812) ([Azat Khuzhin](https://github.com/azat)) +* Now columns size is calculated only once for MergeTree data parts. [#9827](https://github.com/ClickHouse/ClickHouse/pull/9827) ([alesapin](https://github.com/alesapin)) +* Evaluate constant expressions for `optimize_skip_unused_shards` (i.e. `SELECT * FROM foo_dist WHERE key=xxHash32(0)`) [#8846](https://github.com/ClickHouse/ClickHouse/pull/8846) ([Azat Khuzhin](https://github.com/azat)) +* Check for using `Date` or `DateTime` column from TTL expressions was removed. [#9967](https://github.com/ClickHouse/ClickHouse/pull/9967) ([Vladimir Chebotarev](https://github.com/excitoon)) +* DiskS3 hard links optimal implementation. [#9760](https://github.com/ClickHouse/ClickHouse/pull/9760) ([Pavel Kovalenko](https://github.com/Jokser)) +* If `set multiple_joins_rewriter_version = 2` enables second version of multiple JOIN rewrites that keeps not clashed column names as is. It supports multiple JOINs with `USING` and allow `select *` for JOINs with subqueries. [#9739](https://github.com/ClickHouse/ClickHouse/pull/9739) ([Artem Zuikov](https://github.com/4ertus2)) +* Implementation of "non-blocking" alter for StorageMergeTree [#9606](https://github.com/ClickHouse/ClickHouse/pull/9606) ([alesapin](https://github.com/alesapin)) +* Add MergeTree full support for DiskS3 [#9646](https://github.com/ClickHouse/ClickHouse/pull/9646) ([Pavel Kovalenko](https://github.com/Jokser)) +* Extend `splitByString` to support empty strings as separators. [#9742](https://github.com/ClickHouse/ClickHouse/pull/9742) ([hcz](https://github.com/hczhcz)) +* Add a `timestamp_ns` column to `system.trace_log`. It contains a high-definition timestamp of the trace event, and allows to build timelines of thread profiles ("flame charts"). [#9696](https://github.com/ClickHouse/ClickHouse/pull/9696) ([Alexander Kuzmenkov](https://github.com/akuzm)) +* When the setting `send_logs_level` is enabled, avoid intermixing of log messages and query progress. [#9634](https://github.com/ClickHouse/ClickHouse/pull/9634) ([Azat Khuzhin](https://github.com/azat)) +* Added support of `MATERIALIZE TTL IN PARTITION`. [#9581](https://github.com/ClickHouse/ClickHouse/pull/9581) ([Vladimir Chebotarev](https://github.com/excitoon)) +* Support complex types inside Avro nested fields [#10502](https://github.com/ClickHouse/ClickHouse/pull/10502) ([Andrew Onyshchuk](https://github.com/oandrew)) + +#### Performance Improvement +* Better insert logic for right table for Partial MergeJoin. [#10467](https://github.com/ClickHouse/ClickHouse/pull/10467) ([Artem Zuikov](https://github.com/4ertus2)) +* Improved performance of row-oriented formats (more than 10% for CSV and more than 35% for Avro in case of narrow tables). [#10503](https://github.com/ClickHouse/ClickHouse/pull/10503) ([Andrew Onyshchuk](https://github.com/oandrew)) +* Improved performance of queries with explicitly defined sets at right side of IN operator and tuples on the left side. [#10385](https://github.com/ClickHouse/ClickHouse/pull/10385) ([Anton Popov](https://github.com/CurtizJ)) +* Use less memory for hash table in HashJoin. [#10416](https://github.com/ClickHouse/ClickHouse/pull/10416) ([Artem Zuikov](https://github.com/4ertus2)) +* Special HashJoin over StorageDictionary. Allow rewrite `dictGet()` functions with JOINs. It's not backward incompatible itself but could uncover [#8400](https://github.com/ClickHouse/ClickHouse/issues/8400) on some installations. [#10133](https://github.com/ClickHouse/ClickHouse/pull/10133) ([Artem Zuikov](https://github.com/4ertus2)) +* Enable parallel insert of materialized view when its target table supports. [#10052](https://github.com/ClickHouse/ClickHouse/pull/10052) ([vxider](https://github.com/Vxider)) +* Improved performance of index analysis with monotonic functions. [#9607](https://github.com/ClickHouse/ClickHouse/pull/9607)[#10026](https://github.com/ClickHouse/ClickHouse/pull/10026) ([Anton Popov](https://github.com/CurtizJ)) +* Using SSE2 or SSE4.2 SIMD intrinsics to speed up tokenization in bloom filters. [#9968](https://github.com/ClickHouse/ClickHouse/pull/9968) ([Vasily Nemkov](https://github.com/Enmk)) +* Improved performance of queries with explicitly defined sets at right side of `IN` operator. This fixes performance regression in version 20.3. [#9740](https://github.com/ClickHouse/ClickHouse/pull/9740) ([Anton Popov](https://github.com/CurtizJ)) +* Now clickhouse-copier splits each partition in number of pieces and copies them independently. [#9075](https://github.com/ClickHouse/ClickHouse/pull/9075) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +* Adding more aggregation methods. For example TPC-H query 1 will now pick `FixedHashMap` and gets 25% performance gain [#9829](https://github.com/ClickHouse/ClickHouse/pull/9829) ([Amos Bird](https://github.com/amosbird)) +* Use single row counter for multiple streams in pre-limit transform. This helps to avoid uniting pipeline streams in queries with `limit` but without `order by` (like `select f(x) from (select x from t limit 1000000000)`) and use multiple threads for further processing. [#9602](https://github.com/ClickHouse/ClickHouse/pull/9602) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +#### Build/Testing/Packaging Improvement +* Use a fork of AWS SDK libraries from ClickHouse-Extras [#10527](https://github.com/ClickHouse/ClickHouse/pull/10527) ([Pavel Kovalenko](https://github.com/Jokser)) +* Add integration tests for new ALTER RENAME COLUMN query. [#10654](https://github.com/ClickHouse/ClickHouse/pull/10654) ([vzakaznikov](https://github.com/vzakaznikov)) +* Fix possible signed integer overflow in invocation of function `now64` with wrong arguments. This fixes [#8973](https://github.com/ClickHouse/ClickHouse/issues/8973) [#10511](https://github.com/ClickHouse/ClickHouse/pull/10511) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Split fuzzer and sanitizer configurations to make build config compatible with Oss-fuzz. [#10494](https://github.com/ClickHouse/ClickHouse/pull/10494) ([kyprizel](https://github.com/kyprizel)) +* Fixes for clang-tidy on clang-10. [#10420](https://github.com/ClickHouse/ClickHouse/pull/10420) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Display absolute paths in error messages. Otherwise KDevelop fails to navigate to correct file and opens a new file instead. [#10434](https://github.com/ClickHouse/ClickHouse/pull/10434) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Added `ASAN_OPTIONS` environment variable to investigate errors in CI stress tests with Address sanitizer. [#10440](https://github.com/ClickHouse/ClickHouse/pull/10440) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +* Enable ThinLTO for clang builds (experimental). [#10435](https://github.com/ClickHouse/ClickHouse/pull/10435) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Remove accidential dependency on Z3 that may be introduced if the system has Z3 solver installed. [#10426](https://github.com/ClickHouse/ClickHouse/pull/10426) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Move integration tests docker files to docker/ directory. [#10335](https://github.com/ClickHouse/ClickHouse/pull/10335) ([Ilya Yatsishin](https://github.com/qoega)) +* Allow to use `clang-10` in CI. It ensures that [#10238](https://github.com/ClickHouse/ClickHouse/issues/10238) is fixed. [#10384](https://github.com/ClickHouse/ClickHouse/pull/10384) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Update OpenSSL to upstream master. Fixed the issue when TLS connections may fail with the message `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error` and `SSL Exception: error:2400006E:random number generator::error retrieving entropy`. The issue was present in version 20.1. [#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix clang-10 build. https://github.com/ClickHouse/ClickHouse/issues/10238 [#10370](https://github.com/ClickHouse/ClickHouse/pull/10370) ([Amos Bird](https://github.com/amosbird)) +* Add performance test for [Parallel INSERT for materialized view](https://github.com/ClickHouse/ClickHouse/pull/10052). [#10345](https://github.com/ClickHouse/ClickHouse/pull/10345) ([vxider](https://github.com/Vxider)) +* Fix flaky test `test_settings_constraints_distributed.test_insert_clamps_settings`. [#10346](https://github.com/ClickHouse/ClickHouse/pull/10346) ([Vitaly Baranov](https://github.com/vitlibar)) +* Add util to test results upload in CI ClickHouse [#10330](https://github.com/ClickHouse/ClickHouse/pull/10330) ([Ilya Yatsishin](https://github.com/qoega)) +* Convert test results to JSONEachRow format in junit_to_html tool [#10323](https://github.com/ClickHouse/ClickHouse/pull/10323) ([Ilya Yatsishin](https://github.com/qoega)) +* Update cctz. [#10215](https://github.com/ClickHouse/ClickHouse/pull/10215) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Allow to create HTML report from the purest JUnit XML report. [#10247](https://github.com/ClickHouse/ClickHouse/pull/10247) ([Ilya Yatsishin](https://github.com/qoega)) +* Update the check for minimal compiler version. Fix the root cause of the issue [#10250](https://github.com/ClickHouse/ClickHouse/issues/10250) [#10256](https://github.com/ClickHouse/ClickHouse/pull/10256) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Initial support for live view tables over distributed [#10179](https://github.com/ClickHouse/ClickHouse/pull/10179) ([vzakaznikov](https://github.com/vzakaznikov)) +* Fix (false) MSan report in MergeTreeIndexFullText. The issue first appeared in [#9968](https://github.com/ClickHouse/ClickHouse/issues/9968). [#10801](https://github.com/ClickHouse/ClickHouse/pull/10801) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* clickhouse-docker-util [#10151](https://github.com/ClickHouse/ClickHouse/pull/10151) ([filimonov](https://github.com/filimonov)) +* Update pdqsort to recent version [#10171](https://github.com/ClickHouse/ClickHouse/pull/10171) ([Ivan](https://github.com/abyss7)) +* Update libdivide to v3.0 [#10169](https://github.com/ClickHouse/ClickHouse/pull/10169) ([Ivan](https://github.com/abyss7)) +* Add check with enabled polymorphic parts. [#10086](https://github.com/ClickHouse/ClickHouse/pull/10086) ([Anton Popov](https://github.com/CurtizJ)) +* Add cross-compile build for FreeBSD. This fixes [#9465](https://github.com/ClickHouse/ClickHouse/issues/9465) [#9643](https://github.com/ClickHouse/ClickHouse/pull/9643) ([Ivan](https://github.com/abyss7)) +* Add performance test for [#6924](https://github.com/ClickHouse/ClickHouse/issues/6924) [#6980](https://github.com/ClickHouse/ClickHouse/pull/6980) ([filimonov](https://github.com/filimonov)) +* Add support of `/dev/null` in the `File` engine for better performance testing [#8455](https://github.com/ClickHouse/ClickHouse/pull/8455) ([Amos Bird](https://github.com/amosbird)) +* Move all folders inside /dbms one level up [#9974](https://github.com/ClickHouse/ClickHouse/pull/9974) ([Ivan](https://github.com/abyss7)) +* Add a test that checks that read from MergeTree with single thread is performed in order. Addition to [#9670](https://github.com/ClickHouse/ClickHouse/issues/9670) [#9762](https://github.com/ClickHouse/ClickHouse/pull/9762) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix the `00964_live_view_watch_events_heartbeat.py` test to avoid race condition. [#9944](https://github.com/ClickHouse/ClickHouse/pull/9944) ([vzakaznikov](https://github.com/vzakaznikov)) +* Fix integration test `test_settings_constraints` [#9962](https://github.com/ClickHouse/ClickHouse/pull/9962) ([Vitaly Baranov](https://github.com/vitlibar)) +* Every function in its own file, part 12. [#9922](https://github.com/ClickHouse/ClickHouse/pull/9922) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Added performance test for the case of extremely slow analysis of array of tuples. [#9872](https://github.com/ClickHouse/ClickHouse/pull/9872) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Update zstd to 1.4.4. It has some minor improvements in performance and compression ratio. If you run replicas with different versions of ClickHouse you may see reasonable error messages `Data after merge is not byte-identical to data on another replicas.` with explanation. These messages are Ok and you should not worry. [#10663](https://github.com/ClickHouse/ClickHouse/pull/10663) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix TSan report in `system.stack_trace`. [#9832](https://github.com/ClickHouse/ClickHouse/pull/9832) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Removed dependency on `clock_getres`. [#9833](https://github.com/ClickHouse/ClickHouse/pull/9833) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Added identifier names check with clang-tidy. [#9799](https://github.com/ClickHouse/ClickHouse/pull/9799) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Update "builder" docker image. This image is not used in CI but is useful for developers. [#9809](https://github.com/ClickHouse/ClickHouse/pull/9809) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Remove old `performance-test` tool that is no longer used in CI. `clickhouse-performance-test` is great but now we are using way superior tool that is doing comparison testing with sophisticated statistical formulas to achieve confident results regardless to various changes in environment. [#9796](https://github.com/ClickHouse/ClickHouse/pull/9796) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Added most of clang-static-analyzer checks. [#9765](https://github.com/ClickHouse/ClickHouse/pull/9765) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Update Poco to 1.9.3 in preparation for MongoDB URI support. [#6892](https://github.com/ClickHouse/ClickHouse/pull/6892) ([Alexander Kuzmenkov](https://github.com/akuzm)) +* Fix build with `-DUSE_STATIC_LIBRARIES=0 -DENABLE_JEMALLOC=0` [#9651](https://github.com/ClickHouse/ClickHouse/pull/9651) ([Artem Zuikov](https://github.com/4ertus2)) +* For change log script, if merge commit was cherry-picked to release branch, take PR name from commit description. [#9708](https://github.com/ClickHouse/ClickHouse/pull/9708) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Support `vX.X-conflicts` tag in backport script. [#9705](https://github.com/ClickHouse/ClickHouse/pull/9705) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix `auto-label` for backporting script. [#9685](https://github.com/ClickHouse/ClickHouse/pull/9685) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Use libc++ in Darwin cross-build to make it consistent with native build. [#9665](https://github.com/ClickHouse/ClickHouse/pull/9665) ([Hui Wang](https://github.com/huiwang)) +* Fix flacky test `01017_uniqCombined_memory_usage`. Continuation of [#7236](https://github.com/ClickHouse/ClickHouse/issues/7236). [#9667](https://github.com/ClickHouse/ClickHouse/pull/9667) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix build for native MacOS Clang compiler [#9649](https://github.com/ClickHouse/ClickHouse/pull/9649) ([Ivan](https://github.com/abyss7)) +* Allow to add various glitches around `pthread_mutex_lock`, `pthread_mutex_unlock` functions. [#9635](https://github.com/ClickHouse/ClickHouse/pull/9635) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add support for `clang-tidy` in `packager` script. [#9625](https://github.com/ClickHouse/ClickHouse/pull/9625) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Add ability to use unbundled msgpack. [#10168](https://github.com/ClickHouse/ClickHouse/pull/10168) ([Azat Khuzhin](https://github.com/azat)) + + ## ClickHouse release v20.3 +### ClickHouse release v20.3.10.75-lts 2020-05-23 + +#### Bug Fix + +* Removed logging from mutation finalization task if nothing was finalized. [#11109](https://github.com/ClickHouse/ClickHouse/pull/11109) ([alesapin](https://github.com/alesapin)). +* Fixed `parseDateTime64BestEffort` argument resolution bugs. [#11038](https://github.com/ClickHouse/ClickHouse/pull/11038) ([Vasily Nemkov](https://github.com/Enmk)). +* Fixed incorrect raw data size in method `getRawData()`. [#10964](https://github.com/ClickHouse/ClickHouse/pull/10964) ([Igr](https://github.com/ObjatieGroba)). +* Fixed incompatibility of two-level aggregation between versions 20.1 and earlier. This incompatibility happens when different versions of ClickHouse are used on initiator node and remote nodes and the size of `GROUP BY` result is large and aggregation is performed by a single `String` field. It leads to several unmerged rows for a single key in result. [#10952](https://github.com/ClickHouse/ClickHouse/pull/10952) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed backward compatibility with tuples in `Distributed` tables. [#10889](https://github.com/ClickHouse/ClickHouse/pull/10889) ([Anton Popov](https://github.com/CurtizJ)). +* Fixed `SIGSEGV` in `StringHashTable` if such a key does not exist. [#10870](https://github.com/ClickHouse/ClickHouse/pull/10870) ([Azat Khuzhin](https://github.com/azat)). +* Fixed bug in `ReplicatedMergeTree` which might cause some `ALTER` on `OPTIMIZE` query to hang waiting for some replica after it become inactive. [#10849](https://github.com/ClickHouse/ClickHouse/pull/10849) ([tavplubix](https://github.com/tavplubix)). +* Fixed columns order after `Block::sortColumns()`. [#10826](https://github.com/ClickHouse/ClickHouse/pull/10826) ([Azat Khuzhin](https://github.com/azat)). +* Fixed the issue with `ODBC` bridge when no quoting of identifiers is requested. Fixes [#7984] (https://github.com/ClickHouse/ClickHouse/issues/7984). [#10821](https://github.com/ClickHouse/ClickHouse/pull/10821) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed `UBSan` and `MSan` report in `DateLUT`. [#10798](https://github.com/ClickHouse/ClickHouse/pull/10798) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed incorrect type conversion in key conditions. Fixes [#6287](https://github.com/ClickHouse/ClickHouse/issues/6287). [#10791](https://github.com/ClickHouse/ClickHouse/pull/10791) ([Andrew Onyshchuk](https://github.com/oandrew)) +* Fixed `parallel_view_processing` behavior. Now all insertions into `MATERIALIZED VIEW` without exception should be finished if exception happened. Fixes [#10241](https://github.com/ClickHouse/ClickHouse/issues/10241). [#10757](https://github.com/ClickHouse/ClickHouse/pull/10757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed combinator -`OrNull` and `-OrDefault` when combined with `-State`. [#10741](https://github.com/ClickHouse/ClickHouse/pull/10741) ([hcz](https://github.com/hczhcz)). +* Fixed crash in `generateRandom` with nested types. Fixes [#10583](https://github.com/ClickHouse/ClickHouse/issues/10583). [#10734](https://github.com/ClickHouse/ClickHouse/pull/10734) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed data corruption for `LowCardinality(FixedString)` key column in `SummingMergeTree` which could have happened after merge. Fixes [#10489](https://github.com/ClickHouse/ClickHouse/issues/10489). [#10721](https://github.com/ClickHouse/ClickHouse/pull/10721) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed possible buffer overflow in function `h3EdgeAngle`. [#10711](https://github.com/ClickHouse/ClickHouse/pull/10711) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed disappearing totals. Totals could have being filtered if query had had join or subquery with external where condition. Fixes [#10674](https://github.com/ClickHouse/ClickHouse/issues/10674). [#10698](https://github.com/ClickHouse/ClickHouse/pull/10698) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed multiple usages of `IN` operator with the identical set in one query. [#10686](https://github.com/ClickHouse/ClickHouse/pull/10686) ([Anton Popov](https://github.com/CurtizJ)). +* Fixed bug, which causes http requests stuck on client close when `readonly=2` and `cancel_http_readonly_queries_on_client_close=1`. Fixes [#7939](https://github.com/ClickHouse/ClickHouse/issues/7939), [#7019](https://github.com/ClickHouse/ClickHouse/issues/7019), [#7736](https://github.com/ClickHouse/ClickHouse/issues/7736), [#7091](https://github.com/ClickHouse/ClickHouse/issues/7091). [#10684](https://github.com/ClickHouse/ClickHouse/pull/10684) ([tavplubix](https://github.com/tavplubix)). +* Fixed order of parameters in `AggregateTransform` constructor. [#10667](https://github.com/ClickHouse/ClickHouse/pull/10667) ([palasonic1](https://github.com/palasonic1)). +* Fixed the lack of parallel execution of remote queries with `distributed_aggregation_memory_efficient` enabled. Fixes [#10655](https://github.com/ClickHouse/ClickHouse/issues/10655). [#10664](https://github.com/ClickHouse/ClickHouse/pull/10664) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed possible incorrect number of rows for queries with `LIMIT`. Fixes [#10566](https://github.com/ClickHouse/ClickHouse/issues/10566), [#10709](https://github.com/ClickHouse/ClickHouse/issues/10709). [#10660](https://github.com/ClickHouse/ClickHouse/pull/10660) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed a bug which locks concurrent alters when table has a lot of parts. [#10659](https://github.com/ClickHouse/ClickHouse/pull/10659) ([alesapin](https://github.com/alesapin)). +* Fixed a bug when on `SYSTEM DROP DNS CACHE` query also drop caches, which are used to check if user is allowed to connect from some IP addresses. [#10608](https://github.com/ClickHouse/ClickHouse/pull/10608) ([tavplubix](https://github.com/tavplubix)). +* Fixed incorrect scalar results inside inner query of `MATERIALIZED VIEW` in case if this query contained dependent table. [#10603](https://github.com/ClickHouse/ClickHouse/pull/10603) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed `SELECT` of column `ALIAS` which default expression type different from column type. [#10563](https://github.com/ClickHouse/ClickHouse/pull/10563) ([Azat Khuzhin](https://github.com/azat)). +* Implemented comparison between DateTime64 and String values. [#10560](https://github.com/ClickHouse/ClickHouse/pull/10560) ([Vasily Nemkov](https://github.com/Enmk)). +* Fixed index corruption, which may accur in some cases after merge compact parts into another compact part. [#10531](https://github.com/ClickHouse/ClickHouse/pull/10531) ([Anton Popov](https://github.com/CurtizJ)). +* Fixed the situation, when mutation finished all parts, but hung up in `is_done=0`. [#10526](https://github.com/ClickHouse/ClickHouse/pull/10526) ([alesapin](https://github.com/alesapin)). +* Fixed overflow at beginning of unix epoch for timezones with fractional offset from `UTC`. This fixes [#9335](https://github.com/ClickHouse/ClickHouse/issues/9335). [#10513](https://github.com/ClickHouse/ClickHouse/pull/10513) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed improper shutdown of `Distributed` storage. [#10491](https://github.com/ClickHouse/ClickHouse/pull/10491) ([Azat Khuzhin](https://github.com/azat)). +* Fixed numeric overflow in `simpleLinearRegression` over large integers. [#10474](https://github.com/ClickHouse/ClickHouse/pull/10474) ([hcz](https://github.com/hczhcz)). + + +#### Build/Testing/Packaging Improvement + +* Fix UBSan report in LZ4 library. [#10631](https://github.com/ClickHouse/ClickHouse/pull/10631) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fix clang-10 build. https://github.com/ClickHouse/ClickHouse/issues/10238. [#10370](https://github.com/ClickHouse/ClickHouse/pull/10370) ([Amos Bird](https://github.com/amosbird)). +* Added failing tests about `max_rows_to_sort` setting. [#10268](https://github.com/ClickHouse/ClickHouse/pull/10268) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Added some improvements in printing diagnostic info in input formats. Fixes [#10204](https://github.com/ClickHouse/ClickHouse/issues/10204). [#10418](https://github.com/ClickHouse/ClickHouse/pull/10418) ([tavplubix](https://github.com/tavplubix)). +* Added CA certificates to clickhouse-server docker image. [#10476](https://github.com/ClickHouse/ClickHouse/pull/10476) ([filimonov](https://github.com/filimonov)). + +#### Bug fix + +* #10551. [#10569](https://github.com/ClickHouse/ClickHouse/pull/10569) ([Winter Zhang](https://github.com/zhang2014)). + + +### ClickHouse release v20.3.8.53, 2020-04-23 + +#### Bug Fix +* Fixed wrong behaviour of datetime functions for timezones that has altered between positive and negative offsets from UTC (e.g. Pacific/Kiritimati). This fixes [#7202](https://github.com/ClickHouse/ClickHouse/issues/7202) [#10369](https://github.com/ClickHouse/ClickHouse/pull/10369) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Fix possible segfault with `distributed_group_by_no_merge` enabled (introduced in 20.3.7.46 by [#10131](https://github.com/ClickHouse/ClickHouse/issues/10131)). [#10399](https://github.com/ClickHouse/ClickHouse/pull/10399) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fix wrong flattening of `Array(Tuple(...))` data types. This fixes [#10259](https://github.com/ClickHouse/ClickHouse/issues/10259) [#10390](https://github.com/ClickHouse/ClickHouse/pull/10390) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Drop disks reservation in Aggregator. This fixes bug in disk space reservation, which may cause big external aggregation to fail even if it could be completed successfully [#10375](https://github.com/ClickHouse/ClickHouse/pull/10375) ([Azat Khuzhin](https://github.com/azat)) +* Fixed `DROP` vs `OPTIMIZE` race in `ReplicatedMergeTree`. `DROP` could left some garbage in replica path in ZooKeeper if there was concurrent `OPTIMIZE` query. [#10312](https://github.com/ClickHouse/ClickHouse/pull/10312) ([tavplubix](https://github.com/tavplubix)) +* Fix bug when server cannot attach table after column default was altered. [#10441](https://github.com/ClickHouse/ClickHouse/pull/10441) ([alesapin](https://github.com/alesapin)) +* Do not remove metadata directory when attach database fails before loading tables. [#10442](https://github.com/ClickHouse/ClickHouse/pull/10442) ([Winter Zhang](https://github.com/zhang2014)) +* Fixed several bugs when some data was inserted with quorum, then deleted somehow (DROP PARTITION, TTL) and this leaded to the stuck of INSERTs or false-positive exceptions in SELECTs. This fixes [#9946](https://github.com/ClickHouse/ClickHouse/issues/9946) [#10188](https://github.com/ClickHouse/ClickHouse/pull/10188) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +* Fix possible `Pipeline stuck` error in `ConcatProcessor` which could have happened in remote query. [#10381](https://github.com/ClickHouse/ClickHouse/pull/10381) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +* Fixed wrong behavior in HashTable that caused compilation error when trying to read HashMap from buffer. [#10386](https://github.com/ClickHouse/ClickHouse/pull/10386) ([palasonic1](https://github.com/palasonic1)) +* Allow to use `count(*)` with multiple JOINs. Fixes [#9853](https://github.com/ClickHouse/ClickHouse/issues/9853) [#10291](https://github.com/ClickHouse/ClickHouse/pull/10291) ([Artem Zuikov](https://github.com/4ertus2)) +* Prefer `fallback_to_stale_replicas` over `skip_unavailable_shards`, otherwise when both settings specified and there are no up-to-date replicas the query will fail (patch from @alex-zaitsev). Fixes: [#2564](https://github.com/ClickHouse/ClickHouse/issues/2564). [#10422](https://github.com/ClickHouse/ClickHouse/pull/10422) ([Azat Khuzhin](https://github.com/azat)) +* Fix the issue when a query with ARRAY JOIN, ORDER BY and LIMIT may return incomplete result. This fixes [#10226](https://github.com/ClickHouse/ClickHouse/issues/10226). Author: [Vadim Plakhtinskiy](https://github.com/VadimPlh). [#10427](https://github.com/ClickHouse/ClickHouse/pull/10427) ([alexey-milovidov](https://github.com/alexey-milovidov)) +* Check the number and type of arguments when creating BloomFilter index [#9623](https://github.com/ClickHouse/ClickHouse/issues/9623) [#10431](https://github.com/ClickHouse/ClickHouse/pull/10431) ([Winter Zhang](https://github.com/zhang2014)) + +#### Performance Improvement +* Improved performance of queries with explicitly defined sets at right side of `IN` operator and tuples in the left side. This fixes performance regression in version 20.3. [#9740](https://github.com/ClickHouse/ClickHouse/pull/9740), [#10385](https://github.com/ClickHouse/ClickHouse/pull/10385) ([Anton Popov](https://github.com/CurtizJ)) + ### ClickHouse release v20.3.7.46, 2020-04-17 #### Bug Fix @@ -38,7 +433,6 @@ * Fix bug in `CHECK TABLE` query when table contain skip indices. [#10068](https://github.com/ClickHouse/ClickHouse/pull/10068) ([alesapin](https://github.com/alesapin)). * Fix error `Cannot clone block with columns because block has 0 columns ... While executing GroupingAggregatedTransform`. It happened when setting `distributed_aggregation_memory_efficient` was enabled, and distributed query read aggregating data with different level from different shards (mixed single and two level aggregation). [#10063](https://github.com/ClickHouse/ClickHouse/pull/10063) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix a segmentation fault that could occur in GROUP BY over string keys containing trailing zero bytes ([#8636](https://github.com/ClickHouse/ClickHouse/issues/8636), [#8925](https://github.com/ClickHouse/ClickHouse/issues/8925)). [#10025](https://github.com/ClickHouse/ClickHouse/pull/10025) ([Alexander Kuzmenkov](https://github.com/akuzm)). -* Fix parallel distributed INSERT SELECT for remote table. This PR fixes the solution provided in [#9759](https://github.com/ClickHouse/ClickHouse/pull/9759). [#9999](https://github.com/ClickHouse/ClickHouse/pull/9999) ([Vitaly Baranov](https://github.com/vitlibar)). * Fix the number of threads used for remote query execution (performance regression, since 20.3). This happened when query from `Distributed` table was executed simultaneously on local and remote shards. Fixes [#9965](https://github.com/ClickHouse/ClickHouse/issues/9965). [#9971](https://github.com/ClickHouse/ClickHouse/pull/9971) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix bug in which the necessary tables weren't retrieved at one of the processing stages of queries to some databases. Fixes [#9699](https://github.com/ClickHouse/ClickHouse/issues/9699). [#9949](https://github.com/ClickHouse/ClickHouse/pull/9949) ([achulkov2](https://github.com/achulkov2)). * Fix 'Not found column in block' error when `JOIN` appears with `TOTALS`. Fixes [#9839](https://github.com/ClickHouse/ClickHouse/issues/9839). [#9939](https://github.com/ClickHouse/ClickHouse/pull/9939) ([Artem Zuikov](https://github.com/4ertus2)). @@ -330,6 +724,35 @@ ## ClickHouse release v20.1 +### ClickHouse release v20.1.12.86, 2020-05-26 + +#### Bug Fix + +* Fixed incompatibility of two-level aggregation between versions 20.1 and earlier. This incompatibility happens when different versions of ClickHouse are used on initiator node and remote nodes and the size of GROUP BY result is large and aggregation is performed by a single String field. It leads to several unmerged rows for a single key in result. [#10952](https://github.com/ClickHouse/ClickHouse/pull/10952) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed data corruption for `LowCardinality(FixedString)` key column in `SummingMergeTree` which could have happened after merge. Fixes [#10489](https://github.com/ClickHouse/ClickHouse/issues/10489). [#10721](https://github.com/ClickHouse/ClickHouse/pull/10721) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed bug, which causes http requests stuck on client close when `readonly=2` and `cancel_http_readonly_queries_on_client_close=1`. Fixes [#7939](https://github.com/ClickHouse/ClickHouse/issues/7939), [#7019](https://github.com/ClickHouse/ClickHouse/issues/7019), [#7736](https://github.com/ClickHouse/ClickHouse/issues/7736), [#7091](https://github.com/ClickHouse/ClickHouse/issues/7091). [#10684](https://github.com/ClickHouse/ClickHouse/pull/10684) ([tavplubix](https://github.com/tavplubix)). +* Fixed a bug when on `SYSTEM DROP DNS CACHE` query also drop caches, which are used to check if user is allowed to connect from some IP addresses. [#10608](https://github.com/ClickHouse/ClickHouse/pull/10608) ([tavplubix](https://github.com/tavplubix)). +* Fixed incorrect scalar results inside inner query of `MATERIALIZED VIEW` in case if this query contained dependent table. [#10603](https://github.com/ClickHouse/ClickHouse/pull/10603) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed the situation when mutation finished all parts, but hung up in `is_done=0`. [#10526](https://github.com/ClickHouse/ClickHouse/pull/10526) ([alesapin](https://github.com/alesapin)). +* Fixed overflow at beginning of unix epoch for timezones with fractional offset from UTC. This fixes [#9335](https://github.com/ClickHouse/ClickHouse/issues/9335). [#10513](https://github.com/ClickHouse/ClickHouse/pull/10513) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed improper shutdown of Distributed storage. [#10491](https://github.com/ClickHouse/ClickHouse/pull/10491) ([Azat Khuzhin](https://github.com/azat)). +* Fixed numeric overflow in `simpleLinearRegression` over large integers. [#10474](https://github.com/ClickHouse/ClickHouse/pull/10474) ([hcz](https://github.com/hczhcz)). +* Fixed removing metadata directory when attach database fails. [#10442](https://github.com/ClickHouse/ClickHouse/pull/10442) ([Winter Zhang](https://github.com/zhang2014)). +* Added a check of number and type of arguments when creating `BloomFilter` index [#9623](https://github.com/ClickHouse/ClickHouse/issues/9623). [#10431](https://github.com/ClickHouse/ClickHouse/pull/10431) ([Winter Zhang](https://github.com/zhang2014)). +* Fixed the issue when a query with `ARRAY JOIN`, `ORDER BY` and `LIMIT` may return incomplete result. This fixes [#10226](https://github.com/ClickHouse/ClickHouse/issues/10226). [#10427](https://github.com/ClickHouse/ClickHouse/pull/10427) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Prefer `fallback_to_stale_replicas` over `skip_unavailable_shards`. [#10422](https://github.com/ClickHouse/ClickHouse/pull/10422) ([Azat Khuzhin](https://github.com/azat)). +* Fixed wrong flattening of `Array(Tuple(...))` data types. This fixes [#10259](https://github.com/ClickHouse/ClickHouse/issues/10259). [#10390](https://github.com/ClickHouse/ClickHouse/pull/10390) ([alexey-milovidov](https://github.com/alexey-milovidov)). +* Fixed wrong behavior in `HashTable` that caused compilation error when trying to read HashMap from buffer. [#10386](https://github.com/ClickHouse/ClickHouse/pull/10386) ([palasonic1](https://github.com/palasonic1)). +* Fixed possible `Pipeline stuck` error in `ConcatProcessor` which could have happened in remote query. [#10381](https://github.com/ClickHouse/ClickHouse/pull/10381) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed error `Pipeline stuck` with `max_rows_to_group_by` and `group_by_overflow_mode = 'break'`. [#10279](https://github.com/ClickHouse/ClickHouse/pull/10279) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed several bugs when some data was inserted with quorum, then deleted somehow (DROP PARTITION, TTL) and this leaded to the stuck of INSERTs or false-positive exceptions in SELECTs. This fixes [#9946](https://github.com/ClickHouse/ClickHouse/issues/9946). [#10188](https://github.com/ClickHouse/ClickHouse/pull/10188) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Fixed incompatibility when versions prior to 18.12.17 are used on remote servers and newer is used on initiating server, and GROUP BY both fixed and non-fixed keys, and when two-level group by method is activated. [#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) ([alexey-milovidov](https://github.com/alexey-milovidov)). + +#### Build/Testing/Packaging Improvement + +* Added CA certificates to clickhouse-server docker image. [#10476](https://github.com/ClickHouse/ClickHouse/pull/10476) ([filimonov](https://github.com/filimonov)). + + ### ClickHouse release v20.1.10.70, 2020-04-17 #### Bug Fix @@ -765,4 +1188,4 @@ #### Security Fix * Fixed the possibility of reading directories structure in tables with `File` table engine. This fixes [#8536](https://github.com/ClickHouse/ClickHouse/issues/8536). [#8537](https://github.com/ClickHouse/ClickHouse/pull/8537) ([alexey-milovidov](https://github.com/alexey-milovidov)) -## [Changelog for 2019](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/whats_new/changelog/2019.md) +## [Changelog for 2019](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/whats-new/changelog/2019.md) diff --git a/CMakeLists.txt b/CMakeLists.txt index feef2e1a678..4683bf8dec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,11 @@ set(CMAKE_LINK_DEPENDS_NO_SHARED 1) # Do not relink all depended targets on .so set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Debug;Release;MinSizeRel" CACHE STRING "" FORCE) set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Generate debug library name with a postfix.") # To be consistent with CMakeLists from contrib libs. -option(ENABLE_IPO "Enable inter-procedural optimization (aka LTO)" OFF) # need cmake 3.9+ +# Enable the ability to organize targets into hierarchies of "folders" for capable GUI-based IDEs. +# For more info see https://cmake.org/cmake/help/latest/prop_gbl/USE_FOLDERS.html +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +option(ENABLE_IPO "Enable full link time optimization (it's usually impractical; see also ENABLE_THINLTO)" OFF) # need cmake 3.9+ if(ENABLE_IPO) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) @@ -53,12 +57,12 @@ endif () include (cmake/find/ccache.cmake) if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None") - message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = RELWITHDEBINFO") - set (CMAKE_BUILD_TYPE "RELWITHDEBINFO") + set (CMAKE_BUILD_TYPE "RelWithDebInfo") + message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}") endif () -string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) option (USE_STATIC_LIBRARIES "Set to FALSE to use shared libraries" ON) option (MAKE_STATIC_LIBRARIES "Set to FALSE to make shared libraries" ${USE_STATIC_LIBRARIES}) @@ -99,16 +103,7 @@ endif () include (cmake/add_warning.cmake) if (NOT MSVC) - set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wall") # -Werror is also added inside directories with our own code. -endif () - -if (COMPILER_GCC OR COMPILER_CLANG) - set (CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS} -Wnon-virtual-dtor") -endif () - -if (COMPILER_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "8.3.0") - # Warnings in protobuf generating - set (CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS} -Wno-array-bounds") + set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wall") # -Werror and many more is also added inside cmake/warnings.cmake endif () if (COMPILER_CLANG) @@ -188,16 +183,16 @@ endif () option(WITH_COVERAGE "Build with coverage." 0) -if(WITH_COVERAGE AND COMPILER_CLANG) - set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-instr-generate -fcoverage-mapping") - # If we want to disable coverage for specific translation units - set(WITHOUT_COVERAGE "-fno-profile-instr-generate -fno-coverage-mapping") +if (WITH_COVERAGE AND COMPILER_CLANG) + set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-instr-generate -fcoverage-mapping") + # If we want to disable coverage for specific translation units + set(WITHOUT_COVERAGE "-fno-profile-instr-generate -fno-coverage-mapping") endif() -if(WITH_COVERAGE AND COMPILER_GCC) - set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-arcs -ftest-coverage") - set(COVERAGE_OPTION "-lgcov") - set(WITHOUT_COVERAGE "-fno-profile-arcs -fno-test-coverage") +if (WITH_COVERAGE AND COMPILER_GCC) + set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-arcs -ftest-coverage") + set(COVERAGE_OPTION "-lgcov") + set(WITHOUT_COVERAGE "-fno-profile-arcs -fno-test-coverage") endif() set (CMAKE_BUILD_COLOR_MAKEFILE ON) @@ -210,18 +205,44 @@ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 ${ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline ${CMAKE_C_FLAGS_ADD}") if (COMPILER_CLANG) - # Exception unwinding doesn't work in clang release build without this option - # TODO investigate that - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer") - if (OS_DARWIN) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wl,-U,_inside_main") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-U,_inside_main") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-U,_inside_main") endif() # Display absolute paths in error messages. Otherwise KDevelop fails to navigate to correct file and opens a new file instead. - set(COMPILER_FLAGS "${COMPILER_FLAGS} -fdiagnostics-absolute-paths") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-absolute-paths") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-absolute-paths") + + option(ENABLE_THINLTO "Enable Thin LTO. Only applicable for clang. It's also suppressed when building with tests or sanitizers." ON) + + # We cannot afford to use LTO when compiling unitests, and it's not enough + # to only supply -fno-lto at the final linking stage. So we disable it + # completely. + if (ENABLE_THINLTO AND NOT ENABLE_TESTS AND NOT SANITIZE) + # Link time optimization + set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin") + set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -flto=thin") + set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -flto=thin") + endif () + + # Always prefer llvm tools when using clang. For instance, we cannot use GNU ar when llvm LTO is enabled + + find_program (LLVM_AR_PATH NAMES "llvm-ar" "llvm-ar-10" "llvm-ar-9" "llvm-ar-8") + if (LLVM_AR_PATH) + message(STATUS "Using llvm-ar: ${LLVM_AR_PATH}.") + set (CMAKE_AR ${LLVM_AR_PATH}) + else () + message(WARNING "Cannot find llvm-ar. System ar will be used instead. It does not work with ThinLTO.") + endif () + + find_program (LLVM_RANLIB_PATH NAMES "llvm-ranlib" "llvm-ranlib-10" "llvm-ranlib-9" "llvm-ranlib-8") + if (LLVM_RANLIB_PATH) + message(STATUS "Using llvm-ranlib: ${LLVM_RANLIB_PATH}.") + set (CMAKE_RANLIB ${LLVM_RANLIB_PATH}) + else () + message(WARNING "Cannot find llvm-ranlib. System ranlib will be used instead. It does not work with ThinLTO.") + endif () endif () option (ENABLE_LIBRARIES "Enable all libraries (Global default switch)" ON) @@ -247,7 +268,7 @@ endif () # Make this extra-checks for correct library dependencies. if (OS_LINUX AND NOT SANITIZE) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") - set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") + set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") endif () include(cmake/dbms_glob_sources.cmake) @@ -264,7 +285,6 @@ endif () ### Add targets below this comment ### ###################################### -string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) set (CMAKE_POSTFIX_VARIABLE "CMAKE_${CMAKE_BUILD_TYPE_UC}_POSTFIX") if (MAKE_STATIC_LIBRARIES) @@ -305,34 +325,26 @@ endif () message (STATUS "Building for: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_LIBRARY_ARCHITECTURE} ; USE_STATIC_LIBRARIES=${USE_STATIC_LIBRARIES} MAKE_STATIC_LIBRARIES=${MAKE_STATIC_LIBRARIES} SPLIT_SHARED=${SPLIT_SHARED_LIBRARIES} UNBUNDLED=${UNBUNDLED} CCACHE=${CCACHE_FOUND} ${CCACHE_VERSION}") -include(GNUInstallDirs) +include (GNUInstallDirs) include (cmake/contrib_finder.cmake) -include (cmake/lib_name.cmake) find_contrib_lib(double-conversion) # Must be before parquet include (cmake/find/ssl.cmake) +include (cmake/find/ldap.cmake) # after ssl include (cmake/find/icu.cmake) -include (cmake/find/boost.cmake) include (cmake/find/zlib.cmake) include (cmake/find/zstd.cmake) include (cmake/find/ltdl.cmake) # for odbc include (cmake/find/termcap.cmake) -include (cmake/find/odbc.cmake) -# openssl, zlib, odbc before poco -include (cmake/find/poco.cmake) -include (cmake/find/lz4.cmake) -include (cmake/find/xxhash.cmake) +# openssl, zlib before poco include (cmake/find/sparsehash.cmake) include (cmake/find/re2.cmake) include (cmake/find/libgsasl.cmake) include (cmake/find/rdkafka.cmake) include (cmake/find/capnp.cmake) include (cmake/find/llvm.cmake) +include (cmake/find/opencl.cmake) include (cmake/find/h3.cmake) -include (cmake/find/cpuid.cmake) # Freebsd, bundled -if (NOT USE_CPUID) - include (cmake/find/cpuinfo.cmake) # Debian -endif() include (cmake/find/libxml2.cmake) include (cmake/find/brotli.cmake) include (cmake/find/protobuf.cmake) @@ -342,17 +354,16 @@ include (cmake/find/hdfs3.cmake) # uses protobuf include (cmake/find/s3.cmake) include (cmake/find/base64.cmake) include (cmake/find/parquet.cmake) -include (cmake/find/hyperscan.cmake) include (cmake/find/simdjson.cmake) include (cmake/find/rapidjson.cmake) include (cmake/find/fastops.cmake) include (cmake/find/orc.cmake) include (cmake/find/avro.cmake) include (cmake/find/msgpack.cmake) +include (cmake/find/cassandra.cmake) find_contrib_lib(cityhash) find_contrib_lib(farmhash) -find_contrib_lib(metrohash) find_contrib_lib(btrie) if (ENABLE_TESTS) @@ -368,6 +379,13 @@ if (OS_LINUX AND NOT ENABLE_JEMALLOC) message (WARNING "Non default allocator is disabled. This is not recommended for production Linux builds.") endif () +if (USE_OPENCL) + if (OS_DARWIN) + set(OPENCL_LINKER_FLAGS "-framework OpenCL") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCL_LINKER_FLAGS}") + endif () +endif () + include (cmake/print_flags.cmake) if (TARGET global-group) @@ -390,6 +408,9 @@ endmacro() set(ConfigIncludePath ${CMAKE_CURRENT_BINARY_DIR}/includes/configs CACHE INTERNAL "Path to generated configuration files.") include_directories(${ConfigIncludePath}) +# Add as many warnings as possible for our own code. +include (cmake/warnings.cmake) + add_subdirectory (base) add_subdirectory (programs) add_subdirectory (src) diff --git a/README.md b/README.md index 955f9d1a5d1..2008e5d2750 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,12 @@ ClickHouse is an open-source column-oriented database management system that all * [YouTube channel](https://www.youtube.com/c/ClickHouseDB) has a lot of content about ClickHouse in video format. * [Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-d2zxkf9e-XyxDa_ucfPxzuH4SJIm~Ng) and [Telegram](https://telegram.me/clickhouse_en) allow to chat with ClickHouse users in real-time. * [Blog](https://clickhouse.yandex/blog/en/) contains various ClickHouse-related articles, as well as announces and reports about events. +* [Yandex.Messenger channel](https://yandex.ru/chat/#/join/20e380d9-c7be-4123-ab06-e95fb946975e) shares announcements and useful links in Russian. * [Contacts](https://clickhouse.tech/#contacts) can help to get your questions answered if there are any. * You can also [fill this form](https://clickhouse.tech/#meet) to meet Yandex ClickHouse team in person. ## Upcoming Events +* [ClickHouse Online Meetup (in Russian)](https://events.yandex.ru/events/click-house-onlajn-vs-18-06-2020) on June 18, 2020. * [ClickHouse Workshop in Novosibirsk](https://2020.codefest.ru/lecture/1628) on TBD date. * [Yandex C++ Open-Source Sprints in Moscow](https://events.yandex.ru/events/otkrytyj-kod-v-yandek-28-03-2020) on TBD date. diff --git a/base/common/CMakeLists.txt b/base/common/CMakeLists.txt index 8f5887d0f38..074f73b158b 100644 --- a/base/common/CMakeLists.txt +++ b/base/common/CMakeLists.txt @@ -1,5 +1,3 @@ -configure_file (config_common.h.in config_common.h) - set (SRCS argsToConfig.cpp coverage.cpp @@ -13,11 +11,12 @@ set (SRCS LineReader.cpp mremap.cpp phdr_cache.cpp - preciseExp10.c + preciseExp10.cpp setTerminalEcho.cpp shift10.cpp sleep.cpp terminalColors.cpp + errnoToString.cpp ) if (ENABLE_REPLXX) @@ -45,15 +44,7 @@ endif() target_include_directories(common PUBLIC .. ${CMAKE_CURRENT_BINARY_DIR}/..) -if (NOT USE_INTERNAL_BOOST_LIBRARY) - target_include_directories (common SYSTEM BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) -endif () - -if(NOT USE_INTERNAL_POCO_LIBRARY) - target_include_directories (common SYSTEM BEFORE PUBLIC ${Poco_Foundation_INCLUDE_DIR}) -endif() - -# allow explicitly fallback to readline +# Allow explicit fallback to readline if (NOT ENABLE_REPLXX AND ENABLE_READLINE) message (STATUS "Attempt to fallback to readline explicitly") set (READLINE_PATHS "/usr/local/opt/readline/lib") @@ -77,13 +68,16 @@ endif () target_link_libraries (common PUBLIC - ${Poco_Net_LIBRARY} - ${Poco_Util_LIBRARY} - ${Poco_Foundation_LIBRARY} ${CITYHASH_LIBRARIES} - ${Boost_SYSTEM_LIBRARY} + boost::headers_only + boost::system FastMemcpy + Poco::Net + Poco::Net::SSL + Poco::Util + Poco::Foundation replxx + fmt PRIVATE cctz diff --git a/base/common/DateLUTImpl.cpp b/base/common/DateLUTImpl.cpp index 9668b73fb05..83a4d1e9149 100644 --- a/base/common/DateLUTImpl.cpp +++ b/base/common/DateLUTImpl.cpp @@ -31,9 +31,8 @@ UInt8 getDayOfWeek(const cctz::civil_day & date) case cctz::weekday::friday: return 5; case cctz::weekday::saturday: return 6; case cctz::weekday::sunday: return 7; - default: - throw Poco::Exception("Logical error: incorrect week day."); } + __builtin_unreachable(); } } @@ -75,6 +74,11 @@ DateLUTImpl::DateLUTImpl(const std::string & time_zone_) values.day_of_week = getDayOfWeek(date); values.date = start_of_day; + assert(values.year >= DATE_LUT_MIN_YEAR && values.year <= DATE_LUT_MAX_YEAR); + assert(values.month >= 1 && values.month <= 12); + assert(values.day_of_month >= 1 && values.day_of_month <= 31); + assert(values.day_of_week >= 1 && values.day_of_week <= 7); + if (values.day_of_month == 1) { cctz::civil_month month(date); @@ -131,7 +135,7 @@ DateLUTImpl::DateLUTImpl(const std::string & time_zone_) /// Fill excessive part of lookup table. This is needed only to simplify handling of overflow cases. while (i < DATE_LUT_SIZE) { - lut[i] = lut[DATE_LUT_MAX_DAY_NUM]; + lut[i] = lut[i - 1]; ++i; } diff --git a/base/common/DateLUTImpl.h b/base/common/DateLUTImpl.h index 6841598b7ca..18078299cd9 100644 --- a/base/common/DateLUTImpl.h +++ b/base/common/DateLUTImpl.h @@ -37,7 +37,12 @@ using YearWeek = std::pair; class DateLUTImpl { public: - DateLUTImpl(const std::string & time_zone); + explicit DateLUTImpl(const std::string & time_zone); + + DateLUTImpl(const DateLUTImpl &) = delete; + DateLUTImpl & operator=(const DateLUTImpl &) = delete; + DateLUTImpl(const DateLUTImpl &&) = delete; + DateLUTImpl & operator=(const DateLUTImpl &&) = delete; public: /// The order of fields matters for alignment and sizeof. diff --git a/base/common/ErrorHandlers.h b/base/common/ErrorHandlers.h index b35cdcab93d..67194ee043b 100644 --- a/base/common/ErrorHandlers.h +++ b/base/common/ErrorHandlers.h @@ -28,7 +28,7 @@ public: void exception() override { logException(); } private: - Logger * log = &Logger::get("ServerErrorHandler"); + Poco::Logger * log = &Poco::Logger::get("ServerErrorHandler"); void logException() { diff --git a/base/common/JSON.cpp b/base/common/JSON.cpp index 10a1bab92f1..9823591a2b6 100644 --- a/base/common/JSON.cpp +++ b/base/common/JSON.cpp @@ -451,7 +451,10 @@ JSON JSON::operator[] (size_t n) const size_t i = 0; const_iterator it = begin(); while (i < n && it != end()) - ++it, ++i; + { + ++it; + ++i; + } if (i != n) throw JSONException("JSON: array index " + std::to_string(n) + " out of bounds."); @@ -626,7 +629,7 @@ std::string JSON::getString() const { unicode = Poco::NumberParser::parseHex(hex); } - catch (const Poco::SyntaxException & e) + catch (const Poco::SyntaxException &) { throw JSONException("JSON: incorrect syntax: incorrect HEX code."); } diff --git a/base/common/LineReader.cpp b/base/common/LineReader.cpp index 0d06e5ef225..dd2e09b0393 100644 --- a/base/common/LineReader.cpp +++ b/base/common/LineReader.cpp @@ -67,8 +67,8 @@ LineReader::Suggest::WordsRange LineReader::Suggest::getCompletions(const String }); } -LineReader::LineReader(const String & history_file_path_, char extender_, char delimiter_) - : history_file_path(history_file_path_), extender(extender_), delimiter(delimiter_) +LineReader::LineReader(const String & history_file_path_, bool multiline_, Patterns extenders_, Patterns delimiters_) + : history_file_path(history_file_path_), multiline(multiline_), extenders(std::move(extenders_)), delimiters(std::move(delimiters_)) { /// FIXME: check extender != delimiter } @@ -76,38 +76,60 @@ LineReader::LineReader(const String & history_file_path_, char extender_, char d String LineReader::readLine(const String & first_prompt, const String & second_prompt) { String line; - bool is_multiline = false; + bool need_next_line = false; - while (auto status = readOneLine(is_multiline ? second_prompt : first_prompt)) + while (auto status = readOneLine(need_next_line ? second_prompt : first_prompt)) { if (status == RESET_LINE) { line.clear(); - is_multiline = false; + need_next_line = false; continue; } if (input.empty()) { - if (!line.empty() && !delimiter && !hasInputData()) + if (!line.empty() && !multiline && !hasInputData()) break; else continue; } - is_multiline = (input.back() == extender) || (delimiter && input.back() != delimiter) || hasInputData(); - - if (input.back() == extender) +#if !defined(ARCADIA_BUILD) /// C++20 + const char * has_extender = nullptr; + for (const auto * extender : extenders) { - input = input.substr(0, input.size() - 1); + if (input.ends_with(extender)) + { + has_extender = extender; + break; + } + } + + const char * has_delimiter = nullptr; + for (const auto * delimiter : delimiters) + { + if (input.ends_with(delimiter)) + { + has_delimiter = delimiter; + break; + } + } + + need_next_line = has_extender || (multiline && !has_delimiter) || hasInputData(); + + if (has_extender) + { + input.resize(input.size() - strlen(has_extender)); trim(input); if (input.empty()) continue; } +#endif line += (line.empty() ? "" : " ") + input; - if (!is_multiline) + if (!need_next_line) break; } diff --git a/base/common/LineReader.h b/base/common/LineReader.h index 3e64bc858ad..f31459078ab 100644 --- a/base/common/LineReader.h +++ b/base/common/LineReader.h @@ -21,7 +21,9 @@ public: WordsRange getCompletions(const String & prefix, size_t prefix_length) const; }; - LineReader(const String & history_file_path, char extender, char delimiter = 0); /// if delimiter != 0, then it's multiline mode + using Patterns = std::vector; + + LineReader(const String & history_file_path, bool multiline, Patterns extenders, Patterns delimiters); virtual ~LineReader() {} /// Reads the whole line until delimiter (in multiline mode) or until the last line without extender. @@ -51,8 +53,10 @@ protected: String input; private: - const char extender; - const char delimiter; + bool multiline; + + Patterns extenders; + Patterns delimiters; String prev_line; diff --git a/base/common/ReadlineLineReader.cpp b/base/common/ReadlineLineReader.cpp index ee9a37d2168..d52ac0e9769 100644 --- a/base/common/ReadlineLineReader.cpp +++ b/base/common/ReadlineLineReader.cpp @@ -56,8 +56,9 @@ static char * generate(const char * text, int state) return nextMatch(); }; -ReadlineLineReader::ReadlineLineReader(const Suggest & suggest_, const String & history_file_path_, char extender_, char delimiter_) - : LineReader(history_file_path_, extender_, delimiter_) +ReadlineLineReader::ReadlineLineReader( + const Suggest & suggest_, const String & history_file_path_, bool multiline_, Patterns extenders_, Patterns delimiters_) + : LineReader(history_file_path_, multiline_, std::move(extenders_), std::move(delimiters_)) { suggest = &suggest_; diff --git a/base/common/ReadlineLineReader.h b/base/common/ReadlineLineReader.h index 395ae56c724..95bd23b4634 100644 --- a/base/common/ReadlineLineReader.h +++ b/base/common/ReadlineLineReader.h @@ -8,7 +8,7 @@ class ReadlineLineReader : public LineReader { public: - ReadlineLineReader(const Suggest & suggest, const String & history_file_path, char extender, char delimiter = 0); + ReadlineLineReader(const Suggest & suggest, const String & history_file_path, bool multiline, Patterns extenders_, Patterns delimiters_); ~ReadlineLineReader() override; void enableBracketedPaste() override; diff --git a/base/common/ReplxxLineReader.cpp b/base/common/ReplxxLineReader.cpp index 52c42235f1b..251170ab5c1 100644 --- a/base/common/ReplxxLineReader.cpp +++ b/base/common/ReplxxLineReader.cpp @@ -1,9 +1,11 @@ #include +#include #include #include #include #include +#include namespace { @@ -16,14 +18,42 @@ void trim(String & s) } -ReplxxLineReader::ReplxxLineReader(const Suggest & suggest, const String & history_file_path_, char extender_, char delimiter_) - : LineReader(history_file_path_, extender_, delimiter_) +ReplxxLineReader::ReplxxLineReader( + const Suggest & suggest, + const String & history_file_path_, + bool multiline_, + Patterns extenders_, + Patterns delimiters_, + replxx::Replxx::highlighter_callback_t highlighter_) + : LineReader(history_file_path_, multiline_, std::move(extenders_), std::move(delimiters_)), highlighter(std::move(highlighter_)) { using namespace std::placeholders; using Replxx = replxx::Replxx; if (!history_file_path.empty()) - rx.history_load(history_file_path); + { + history_file_fd = open(history_file_path.c_str(), O_RDWR); + if (history_file_fd < 0) + { + rx.print("Open of history file failed: %s\n", errnoToString(errno).c_str()); + } + else + { + if (flock(history_file_fd, LOCK_SH)) + { + rx.print("Shared lock of history file failed: %s\n", errnoToString(errno).c_str()); + } + else + { + rx.history_load(history_file_path); + + if (flock(history_file_fd, LOCK_UN)) + { + rx.print("Unlock of history file failed: %s\n", errnoToString(errno).c_str()); + } + } + } + } auto callback = [&suggest] (const String & context, size_t context_size) { @@ -35,6 +65,9 @@ ReplxxLineReader::ReplxxLineReader(const Suggest & suggest, const String & histo rx.set_complete_on_empty(false); rx.set_word_break_characters(word_break_characters); + if (highlighter) + rx.set_highlighter_callback(highlighter); + /// By default C-p/C-n binded to COMPLETE_NEXT/COMPLETE_PREV, /// bind C-p/C-n to history-previous/history-next like readline. rx.bind_key(Replxx::KEY::control('N'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::HISTORY_NEXT, code); }); @@ -48,8 +81,8 @@ ReplxxLineReader::ReplxxLineReader(const Suggest & suggest, const String & histo ReplxxLineReader::~ReplxxLineReader() { - if (!history_file_path.empty()) - rx.history_save(history_file_path); + if (close(history_file_fd)) + rx.print("Close of history file failed: %s\n", strerror(errno)); } LineReader::InputStatus ReplxxLineReader::readOneLine(const String & prompt) @@ -67,7 +100,20 @@ LineReader::InputStatus ReplxxLineReader::readOneLine(const String & prompt) void ReplxxLineReader::addToHistory(const String & line) { + // locking history file to prevent from inconsistent concurrent changes + bool locked = false; + if (flock(history_file_fd, LOCK_EX)) + rx.print("Lock of history file failed: %s\n", strerror(errno)); + else + locked = true; + rx.history_add(line); + + // flush changes to the disk + rx.history_save(history_file_path); + + if (locked && 0 != flock(history_file_fd, LOCK_UN)) + rx.print("Unlock of history file failed: %s\n", strerror(errno)); } void ReplxxLineReader::enableBracketedPaste() diff --git a/base/common/ReplxxLineReader.h b/base/common/ReplxxLineReader.h index e7821f54ad3..1fbfd53457b 100644 --- a/base/common/ReplxxLineReader.h +++ b/base/common/ReplxxLineReader.h @@ -4,10 +4,17 @@ #include + class ReplxxLineReader : public LineReader { public: - ReplxxLineReader(const Suggest & suggest, const String & history_file_path, char extender, char delimiter = 0); + ReplxxLineReader( + const Suggest & suggest, + const String & history_file_path, + bool multiline, + Patterns extenders_, + Patterns delimiters_, + replxx::Replxx::highlighter_callback_t highlighter_); ~ReplxxLineReader() override; void enableBracketedPaste() override; @@ -17,4 +24,8 @@ private: void addToHistory(const String & line) override; replxx::Replxx rx; + replxx::Replxx::highlighter_callback_t highlighter; + + // used to call flock() to synchronize multiple clients using same history file + int history_file_fd = -1; }; diff --git a/base/common/argsToConfig.cpp b/base/common/argsToConfig.cpp index 36801bea7a8..d7983779d2d 100644 --- a/base/common/argsToConfig.cpp +++ b/base/common/argsToConfig.cpp @@ -1,6 +1,5 @@ #include "argsToConfig.h" -#include #include #include diff --git a/base/common/config_common.h.in b/base/common/config_common.h.in deleted file mode 100644 index 29d487c3ab5..00000000000 --- a/base/common/config_common.h.in +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -// .h autogenerated by cmake ! - -#cmakedefine01 UNBUNDLED diff --git a/base/common/demangle.cpp b/base/common/demangle.cpp index a034f7a9c05..d7fac7c6990 100644 --- a/base/common/demangle.cpp +++ b/base/common/demangle.cpp @@ -1,16 +1,8 @@ #include -#if defined(__has_feature) - #if __has_feature(memory_sanitizer) - #define MEMORY_SANITIZER 1 - #endif -#elif defined(__MEMORY_SANITIZER__) - #define MEMORY_SANITIZER 1 -#endif +#if defined(_MSC_VER) -#if _MSC_VER || MEMORY_SANITIZER - -DemangleResult tryDemangle(const char * name) +DemangleResult tryDemangle(const char *) { return DemangleResult{}; } diff --git a/base/common/errnoToString.cpp b/base/common/errnoToString.cpp new file mode 100644 index 00000000000..cdadba2c615 --- /dev/null +++ b/base/common/errnoToString.cpp @@ -0,0 +1,29 @@ +#include "errnoToString.h" + +#include + + +std::string errnoToString(int code, int the_errno) +{ + const size_t buf_size = 128; + char buf[buf_size]; +#ifndef _GNU_SOURCE + int rc = strerror_r(the_errno, buf, buf_size); +#ifdef __APPLE__ + if (rc != 0 && rc != EINVAL) +#else + if (rc != 0) +#endif + { + std::string tmp = std::to_string(code); + const char * code_str = tmp.c_str(); + const char * unknown_message = "Unknown error "; + strcpy(buf, unknown_message); + strcpy(buf + strlen(unknown_message), code_str); + } + return fmt::format("errno: {}, strerror: {}", the_errno, buf); +#else + (void)code; + return fmt::format("errno: {}, strerror: {}", the_errno, strerror_r(the_errno, buf, sizeof(buf))); +#endif +} diff --git a/base/common/errnoToString.h b/base/common/errnoToString.h new file mode 100644 index 00000000000..fd5f81ec2c7 --- /dev/null +++ b/base/common/errnoToString.h @@ -0,0 +1,6 @@ +#pragma once + +#include +#include + +std::string errnoToString(int code, int the_errno = errno); diff --git a/base/common/getThreadId.cpp b/base/common/getThreadId.cpp index 2542b14acf1..2575aba3844 100644 --- a/base/common/getThreadId.cpp +++ b/base/common/getThreadId.cpp @@ -1,9 +1,9 @@ #include -#if OS_LINUX +#if defined(OS_LINUX) #include #include -#elif OS_FREEBSD +#elif defined(OS_FREEBSD) #include #else #include @@ -16,9 +16,9 @@ uint64_t getThreadId() { if (!current_tid) { -#if OS_LINUX +#if defined(OS_LINUX) current_tid = syscall(SYS_gettid); /// This call is always successful. - man gettid -#elif OS_FREEBSD +#elif defined(OS_FREEBSD) current_tid = pthread_getthreadid_np(); #else if (0 != pthread_threadid_np(nullptr, ¤t_tid)) diff --git a/base/common/logger_useful.h b/base/common/logger_useful.h index ea1a25cc8fa..f760d59de45 100644 --- a/base/common/logger_useful.h +++ b/base/common/logger_useful.h @@ -2,38 +2,40 @@ /// Macros for convenient usage of Poco logger. -#include +#include +#include #include #include -#include #include -#ifndef QUERY_PREVIEW_LENGTH -#define QUERY_PREVIEW_LENGTH 160 -#endif -using Poco::Logger; -using Poco::Message; -using DB::LogsLevel; -using DB::CurrentThread; +namespace +{ + template constexpr size_t numArgs(Ts &&...) { return sizeof...(Ts); } + template constexpr auto firstArg(T && x, Ts &&...) { return std::forward(x); } +} + /// Logs a message to a specified logger with that level. +/// If more than one argument is provided, +/// the first argument is interpreted as template with {}-substitutions +/// and the latter arguments treat as values to substitute. +/// If only one argument is provided, it is threat as message without substitutions. -#define LOG_SIMPLE(logger, message, priority, PRIORITY) do \ +#define LOG_IMPL(logger, priority, PRIORITY, ...) do \ { \ - const bool is_clients_log = (CurrentThread::getGroup() != nullptr) && \ - (CurrentThread::getGroup()->client_logs_level >= (priority)); \ + const bool is_clients_log = (DB::CurrentThread::getGroup() != nullptr) && \ + (DB::CurrentThread::getGroup()->client_logs_level >= (priority)); \ if ((logger)->is((PRIORITY)) || is_clients_log) \ { \ - std::stringstream oss_internal_rare; \ - oss_internal_rare << message; \ + std::string formatted_message = numArgs(__VA_ARGS__) > 1 ? fmt::format(__VA_ARGS__) : firstArg(__VA_ARGS__); \ if (auto channel = (logger)->getChannel()) \ { \ std::string file_function; \ file_function += __FILE__; \ file_function += "; "; \ file_function += __PRETTY_FUNCTION__; \ - Message poco_message((logger)->name(), oss_internal_rare.str(), \ + Poco::Message poco_message((logger)->name(), formatted_message, \ (PRIORITY), file_function.c_str(), __LINE__); \ channel->log(poco_message); \ } \ @@ -41,10 +43,18 @@ using DB::CurrentThread; } while (false) -#define LOG_TRACE(logger, message) LOG_SIMPLE(logger, message, LogsLevel::trace, Message::PRIO_TRACE) -#define LOG_DEBUG(logger, message) LOG_SIMPLE(logger, message, LogsLevel::debug, Message::PRIO_DEBUG) -#define LOG_INFO(logger, message) LOG_SIMPLE(logger, message, LogsLevel::information, Message::PRIO_INFORMATION) -#define LOG_WARNING(logger, message) LOG_SIMPLE(logger, message, LogsLevel::warning, Message::PRIO_WARNING) -#define LOG_ERROR(logger, message) LOG_SIMPLE(logger, message, LogsLevel::error, Message::PRIO_ERROR) -#define LOG_FATAL(logger, message) LOG_SIMPLE(logger, message, LogsLevel::error, Message::PRIO_FATAL) +#define LOG_TRACE(logger, ...) LOG_IMPL(logger, DB::LogsLevel::trace, Poco::Message::PRIO_TRACE, __VA_ARGS__) +#define LOG_DEBUG(logger, ...) LOG_IMPL(logger, DB::LogsLevel::debug, Poco::Message::PRIO_DEBUG, __VA_ARGS__) +#define LOG_INFO(logger, ...) LOG_IMPL(logger, DB::LogsLevel::information, Poco::Message::PRIO_INFORMATION, __VA_ARGS__) +#define LOG_WARNING(logger, ...) LOG_IMPL(logger, DB::LogsLevel::warning, Poco::Message::PRIO_WARNING, __VA_ARGS__) +#define LOG_ERROR(logger, ...) LOG_IMPL(logger, DB::LogsLevel::error, Poco::Message::PRIO_ERROR, __VA_ARGS__) +#define LOG_FATAL(logger, ...) LOG_IMPL(logger, DB::LogsLevel::error, Poco::Message::PRIO_FATAL, __VA_ARGS__) + +/// Compatibility for external projects. +#if defined(ARCADIA_BUILD) + using Poco::Logger; + using Poco::Message; + using DB::LogsLevel; + using DB::CurrentThread; +#endif diff --git a/base/common/memory.h b/base/common/memory.h index e2bd8d618da..e82c019ceab 100644 --- a/base/common/memory.h +++ b/base/common/memory.h @@ -3,20 +3,12 @@ #include #include "defines.h" -#if __has_include() -#include -#endif - #if USE_JEMALLOC -#include - -#if JEMALLOC_VERSION_MAJOR < 4 - #undef USE_JEMALLOC - #define USE_JEMALLOC 0 - #include +# include #endif -#else -#include + +#if !USE_JEMALLOC || JEMALLOC_VERSION_MAJOR < 4 +# include #endif @@ -43,7 +35,7 @@ inline ALWAYS_INLINE void deleteImpl(void * ptr) noexcept free(ptr); } -#if USE_JEMALLOC +#if USE_JEMALLOC && JEMALLOC_VERSION_MAJOR >= 4 inline ALWAYS_INLINE void deleteSized(void * ptr, std::size_t size) noexcept { diff --git a/base/common/mremap.cpp b/base/common/mremap.cpp index 00c6f260734..d2d8d7fde4f 100644 --- a/base/common/mremap.cpp +++ b/base/common/mremap.cpp @@ -19,7 +19,7 @@ void * mremap_fallback( return MAP_FAILED; } -#if _MSC_VER +#if defined(_MSC_VER) void * new_address = ::operator new(new_size); #else void * new_address = mmap(nullptr, new_size, mmap_prot, mmap_flags, mmap_fd, mmap_offset); @@ -29,7 +29,7 @@ void * mremap_fallback( memcpy(new_address, old_address, old_size); -#if _MSC_VER +#if defined(_MSC_VER) delete old_address; #else if (munmap(old_address, old_size)) diff --git a/base/common/phdr_cache.cpp b/base/common/phdr_cache.cpp index cef386a85b8..f362fb64285 100644 --- a/base/common/phdr_cache.cpp +++ b/base/common/phdr_cache.cpp @@ -1,25 +1,19 @@ /// This code was based on the code by Fedor Korotkiy (prime@yandex-team.ru) for YT product in Yandex. -#if defined(__has_feature) - #if __has_feature(address_sanitizer) - #define ADDRESS_SANITIZER 1 - #endif - #if __has_feature(thread_sanitizer) - #define THREAD_SANITIZER 1 - #endif -#else - #if defined(__SANITIZE_ADDRESS__) - #define ADDRESS_SANITIZER 1 - #endif - #if defined(__SANITIZE_THREAD__) - #define THREAD_SANITIZER 1 - #endif -#endif +#include #if defined(__linux__) && !defined(THREAD_SANITIZER) #define USE_PHDR_CACHE 1 #endif +/// Thread Sanitizer uses dl_iterate_phdr function on initialization and fails if we provide our own. +#ifdef USE_PHDR_CACHE + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wreserved-id-macro" +# pragma clang diagnostic ignored "-Wunused-macros" +#endif + #define __msan_unpoison(X, Y) #if defined(__has_feature) # if __has_feature(memory_sanitizer) @@ -28,9 +22,6 @@ # endif #endif -/// Thread Sanitizer uses dl_iterate_phdr function on initialization and fails if we provide our own. -#ifdef USE_PHDR_CACHE - #include #include #include diff --git a/base/common/preciseExp10.c b/base/common/preciseExp10.c deleted file mode 100644 index 49c87217e20..00000000000 --- a/base/common/preciseExp10.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - -https://www.musl-libc.org/ -http://git.musl-libc.org/cgit/musl/tree/src/math/exp10.c - -musl as a whole is licensed under the following standard MIT license: - ----------------------------------------------------------------------- -Copyright © 2005-2014 Rich Felker, et al. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- - -Authors/contributors include: - -Alex Dowad -Alexander Monakov -Anthony G. Basile -Arvid Picciani -Bobby Bingham -Boris Brezillon -Brent Cook -Chris Spiegel -Clément Vasseur -Daniel Micay -Denys Vlasenko -Emil Renner Berthing -Felix Fietkau -Felix Janda -Gianluca Anzolin -Hauke Mehrtens -Hiltjo Posthuma -Isaac Dunham -Jaydeep Patil -Jens Gustedt -Jeremy Huntwork -Jo-Philipp Wich -Joakim Sindholt -John Spencer -Josiah Worcester -Justin Cormack -Khem Raj -Kylie McClain -Luca Barbato -Luka Perkov -M Farkas-Dyck (Strake) -Mahesh Bodapati -Michael Forney -Natanael Copa -Nicholas J. Kain -orc -Pascal Cuoq -Petr Hosek -Pierre Carrier -Rich Felker -Richard Pennington -Shiz -sin -Solar Designer -Stefan Kristiansson -Szabolcs Nagy -Timo Teräs -Trutz Behn -Valentin Ochs -William Haddon - -Portions of this software are derived from third-party works licensed -under terms compatible with the above MIT license: - -The TRE regular expression implementation (src/regex/reg* and -src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed -under a 2-clause BSD license (license text in the source files). The -included version has been heavily modified by Rich Felker in 2012, in -the interests of size, simplicity, and namespace cleanliness. - -Much of the math library code (src/math/ * and src/complex/ *) is -Copyright © 1993,2004 Sun Microsystems or -Copyright © 2003-2011 David Schultz or -Copyright © 2003-2009 Steven G. Kargl or -Copyright © 2003-2009 Bruce D. Evans or -Copyright © 2008 Stephen L. Moshier -and labelled as such in comments in the individual source files. All -have been licensed under extremely permissive terms. - -The ARM memcpy code (src/string/arm/memcpy_el.S) is Copyright © 2008 -The Android Open Source Project and is licensed under a two-clause BSD -license. It was taken from Bionic libc, used on Android. - -The implementation of DES for crypt (src/crypt/crypt_des.c) is -Copyright © 1994 David Burren. It is licensed under a BSD license. - -The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was -originally written by Solar Designer and placed into the public -domain. The code also comes with a fallback permissive license for use -in jurisdictions that may not recognize the public domain. - -The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 -Valentin Ochs and is licensed under an MIT-style license. - -The BSD PRNG implementation (src/prng/random.c) and XSI search API -(src/search/ *.c) functions are Copyright © 2011 Szabolcs Nagy and -licensed under following terms: "Permission to use, copy, modify, -and/or distribute this code for any purpose with or without fee is -hereby granted. There is no warranty." - -The x86_64 port was written by Nicholas J. Kain and is licensed under -the standard MIT terms. - -The mips and microblaze ports were originally written by Richard -Pennington for use in the ellcc project. The original code was adapted -by Rich Felker for build system and code conventions during upstream -integration. It is licensed under the standard MIT terms. - -The mips64 port was contributed by Imagination Technologies and is -licensed under the standard MIT terms. - -The powerpc port was also originally written by Richard Pennington, -and later supplemented and integrated by John Spencer. It is licensed -under the standard MIT terms. - -All other files which have no copyright comments are original works -produced specifically for use as part of this library, written either -by Rich Felker, the main author of the library, or by one or more -contibutors listed above. Details on authorship of individual files -can be found in the git version control history of the project. The -omission of copyright and license comments in each file is in the -interest of source tree size. - -In addition, permission is hereby granted for all public header files -(include/ * and arch/ * /bits/ *) and crt files intended to be linked into -applications (crt/ *, ldso/dlstart.c, and arch/ * /crt_arch.h) to omit -the copyright notice and permission notice otherwise required by the -license, and to use these files without any requirement of -attribution. These files include substantial contributions from: - -Bobby Bingham -John Spencer -Nicholas J. Kain -Rich Felker -Richard Pennington -Stefan Kristiansson -Szabolcs Nagy - -all of whom have explicitly granted such permission. - -This file previously contained text expressing a belief that most of -the files covered by the above exception were sufficiently trivial not -to be subject to copyright, resulting in confusion over whether it -negated the permissions granted in the license. In the spirit of -permissive licensing, and of not having licensing issues being an -obstacle to adoption, that text has been removed. - -*/ - -#include -#include -#include - -double preciseExp10(double x) -{ - if (isnan(x)) return NAN; - - // ranging between DBL_TRUE_MIN and DBL_MAX. Outsiders are treated as zeros or infinities - static const double p10[] - = {1e-323, 1e-322, 1e-321, 1e-320, 1e-319, 1e-318, 1e-317, 1e-316, 1e-315, 1e-314, 1e-313, 1e-312, 1e-311, 1e-310, 1e-309, 1e-308, 1e-307, - 1e-306, 1e-305, 1e-304, 1e-303, 1e-302, 1e-301, 1e-300, 1e-299, 1e-298, 1e-297, 1e-296, 1e-295, 1e-294, 1e-293, 1e-292, 1e-291, 1e-290, - 1e-289, 1e-288, 1e-287, 1e-286, 1e-285, 1e-284, 1e-283, 1e-282, 1e-281, 1e-280, 1e-279, 1e-278, 1e-277, 1e-276, 1e-275, 1e-274, 1e-273, - 1e-272, 1e-271, 1e-270, 1e-269, 1e-268, 1e-267, 1e-266, 1e-265, 1e-264, 1e-263, 1e-262, 1e-261, 1e-260, 1e-259, 1e-258, 1e-257, 1e-256, - 1e-255, 1e-254, 1e-253, 1e-252, 1e-251, 1e-250, 1e-249, 1e-248, 1e-247, 1e-246, 1e-245, 1e-244, 1e-243, 1e-242, 1e-241, 1e-240, 1e-239, - 1e-238, 1e-237, 1e-236, 1e-235, 1e-234, 1e-233, 1e-232, 1e-231, 1e-230, 1e-229, 1e-228, 1e-227, 1e-226, 1e-225, 1e-224, 1e-223, 1e-222, - 1e-221, 1e-220, 1e-219, 1e-218, 1e-217, 1e-216, 1e-215, 1e-214, 1e-213, 1e-212, 1e-211, 1e-210, 1e-209, 1e-208, 1e-207, 1e-206, 1e-205, - 1e-204, 1e-203, 1e-202, 1e-201, 1e-200, 1e-199, 1e-198, 1e-197, 1e-196, 1e-195, 1e-194, 1e-193, 1e-192, 1e-191, 1e-190, 1e-189, 1e-188, - 1e-187, 1e-186, 1e-185, 1e-184, 1e-183, 1e-182, 1e-181, 1e-180, 1e-179, 1e-178, 1e-177, 1e-176, 1e-175, 1e-174, 1e-173, 1e-172, 1e-171, - 1e-170, 1e-169, 1e-168, 1e-167, 1e-166, 1e-165, 1e-164, 1e-163, 1e-162, 1e-161, 1e-160, 1e-159, 1e-158, 1e-157, 1e-156, 1e-155, 1e-154, - 1e-153, 1e-152, 1e-151, 1e-150, 1e-149, 1e-148, 1e-147, 1e-146, 1e-145, 1e-144, 1e-143, 1e-142, 1e-141, 1e-140, 1e-139, 1e-138, 1e-137, - 1e-136, 1e-135, 1e-134, 1e-133, 1e-132, 1e-131, 1e-130, 1e-129, 1e-128, 1e-127, 1e-126, 1e-125, 1e-124, 1e-123, 1e-122, 1e-121, 1e-120, - 1e-119, 1e-118, 1e-117, 1e-116, 1e-115, 1e-114, 1e-113, 1e-112, 1e-111, 1e-110, 1e-109, 1e-108, 1e-107, 1e-106, 1e-105, 1e-104, 1e-103, - 1e-102, 1e-101, 1e-100, 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, - 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, - 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, - 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, - 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 1e-19, 1e-18, - 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, - 1e0, 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, - 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, - 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, - 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, - 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 1e+81, 1e+82, 1e+83, 1e+84, - 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 1e+101, - 1e+102, 1e+103, 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109, 1e+110, 1e+111, 1e+112, 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118, - 1e+119, 1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, 1e+129, 1e+130, 1e+131, 1e+132, 1e+133, 1e+134, 1e+135, - 1e+136, 1e+137, 1e+138, 1e+139, 1e+140, 1e+141, 1e+142, 1e+143, 1e+144, 1e+145, 1e+146, 1e+147, 1e+148, 1e+149, 1e+150, 1e+151, 1e+152, - 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159, 1e+160, 1e+161, 1e+162, 1e+163, 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169, - 1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, 1e+177, 1e+178, 1e+179, 1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, - 1e+187, 1e+188, 1e+189, 1e+190, 1e+191, 1e+192, 1e+193, 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199, 1e+200, 1e+201, 1e+202, 1e+203, - 1e+204, 1e+205, 1e+206, 1e+207, 1e+208, 1e+209, 1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219, 1e+220, - 1e+221, 1e+222, 1e+223, 1e+224, 1e+225, 1e+226, 1e+227, 1e+228, 1e+229, 1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, - 1e+238, 1e+239, 1e+240, 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249, 1e+250, 1e+251, 1e+252, 1e+253, 1e+254, - 1e+255, 1e+256, 1e+257, 1e+258, 1e+259, 1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268, 1e+269, 1e+270, 1e+271, - 1e+272, 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279, 1e+280, 1e+281, 1e+282, 1e+283, 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, - 1e+289, 1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298, 1e+299, 1e+300, 1e+301, 1e+302, 1e+303, 1e+304, 1e+305, - 1e+306, 1e+307, 1e+308}; - - double n, y = modf(x, &n); - if (n > 308) return INFINITY; - if (n < -323) return 0; - - // Using lookup table based formula to get accurate results for integer arguments. - return exp2(3.32192809488736234787031942948939 * y) * p10[(int)n + 323]; -} diff --git a/base/common/preciseExp10.cpp b/base/common/preciseExp10.cpp new file mode 100644 index 00000000000..a034ae2357b --- /dev/null +++ b/base/common/preciseExp10.cpp @@ -0,0 +1,227 @@ +/* + +https://www.musl-libc.org/ +http://git.musl-libc.org/cgit/musl/tree/src/math/exp10.c + +musl as a whole is licensed under the following standard MIT license: + +---------------------------------------------------------------------- +Copyright © 2005-2014 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------------------------------------------------------------- + +Authors/contributors include: + +Alex Dowad +Alexander Monakov +Anthony G. Basile +Arvid Picciani +Bobby Bingham +Boris Brezillon +Brent Cook +Chris Spiegel +Clément Vasseur +Daniel Micay +Denys Vlasenko +Emil Renner Berthing +Felix Fietkau +Felix Janda +Gianluca Anzolin +Hauke Mehrtens +Hiltjo Posthuma +Isaac Dunham +Jaydeep Patil +Jens Gustedt +Jeremy Huntwork +Jo-Philipp Wich +Joakim Sindholt +John Spencer +Josiah Worcester +Justin Cormack +Khem Raj +Kylie McClain +Luca Barbato +Luka Perkov +M Farkas-Dyck (Strake) +Mahesh Bodapati +Michael Forney +Natanael Copa +Nicholas J. Kain +orc +Pascal Cuoq +Petr Hosek +Pierre Carrier +Rich Felker +Richard Pennington +Shiz +sin +Solar Designer +Stefan Kristiansson +Szabolcs Nagy +Timo Teräs +Trutz Behn +Valentin Ochs +William Haddon + +Portions of this software are derived from third-party works licensed +under terms compatible with the above MIT license: + +The TRE regular expression implementation (src/regex/reg* and +src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed +under a 2-clause BSD license (license text in the source files). The +included version has been heavily modified by Rich Felker in 2012, in +the interests of size, simplicity, and namespace cleanliness. + +Much of the math library code (src/math/ * and src/complex/ *) is +Copyright © 1993,2004 Sun Microsystems or +Copyright © 2003-2011 David Schultz or +Copyright © 2003-2009 Steven G. Kargl or +Copyright © 2003-2009 Bruce D. Evans or +Copyright © 2008 Stephen L. Moshier +and labelled as such in comments in the individual source files. All +have been licensed under extremely permissive terms. + +The ARM memcpy code (src/string/arm/memcpy_el.S) is Copyright © 2008 +The Android Open Source Project and is licensed under a two-clause BSD +license. It was taken from Bionic libc, used on Android. + +The implementation of DES for crypt (src/crypt/crypt_des.c) is +Copyright © 1994 David Burren. It is licensed under a BSD license. + +The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was +originally written by Solar Designer and placed into the public +domain. The code also comes with a fallback permissive license for use +in jurisdictions that may not recognize the public domain. + +The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 +Valentin Ochs and is licensed under an MIT-style license. + +The BSD PRNG implementation (src/prng/random.c) and XSI search API +(src/search/ *.c) functions are Copyright © 2011 Szabolcs Nagy and +licensed under following terms: "Permission to use, copy, modify, +and/or distribute this code for any purpose with or without fee is +hereby granted. There is no warranty." + +The x86_64 port was written by Nicholas J. Kain and is licensed under +the standard MIT terms. + +The mips and microblaze ports were originally written by Richard +Pennington for use in the ellcc project. The original code was adapted +by Rich Felker for build system and code conventions during upstream +integration. It is licensed under the standard MIT terms. + +The mips64 port was contributed by Imagination Technologies and is +licensed under the standard MIT terms. + +The powerpc port was also originally written by Richard Pennington, +and later supplemented and integrated by John Spencer. It is licensed +under the standard MIT terms. + +All other files which have no copyright comments are original works +produced specifically for use as part of this library, written either +by Rich Felker, the main author of the library, or by one or more +contibutors listed above. Details on authorship of individual files +can be found in the git version control history of the project. The +omission of copyright and license comments in each file is in the +interest of source tree size. + +In addition, permission is hereby granted for all public header files +(include/ * and arch/ * /bits/ *) and crt files intended to be linked into +applications (crt/ *, ldso/dlstart.c, and arch/ * /crt_arch.h) to omit +the copyright notice and permission notice otherwise required by the +license, and to use these files without any requirement of +attribution. These files include substantial contributions from: + +Bobby Bingham +John Spencer +Nicholas J. Kain +Rich Felker +Richard Pennington +Stefan Kristiansson +Szabolcs Nagy + +all of whom have explicitly granted such permission. + +This file previously contained text expressing a belief that most of +the files covered by the above exception were sufficiently trivial not +to be subject to copyright, resulting in confusion over whether it +negated the permissions granted in the license. In the spirit of +permissive licensing, and of not having licensing issues being an +obstacle to adoption, that text has been removed. + +*/ + +#include +#include +#include + +double preciseExp10(double x) +{ + if (isnan(x)) return NAN; + + // ranging between DBL_TRUE_MIN and DBL_MAX. Outsiders are treated as zeros or infinities + static const double p10[] + = {1e-323, 1e-322, 1e-321, 1e-320, 1e-319, 1e-318, 1e-317, 1e-316, 1e-315, 1e-314, 1e-313, 1e-312, 1e-311, 1e-310, 1e-309, 1e-308, 1e-307, + 1e-306, 1e-305, 1e-304, 1e-303, 1e-302, 1e-301, 1e-300, 1e-299, 1e-298, 1e-297, 1e-296, 1e-295, 1e-294, 1e-293, 1e-292, 1e-291, 1e-290, + 1e-289, 1e-288, 1e-287, 1e-286, 1e-285, 1e-284, 1e-283, 1e-282, 1e-281, 1e-280, 1e-279, 1e-278, 1e-277, 1e-276, 1e-275, 1e-274, 1e-273, + 1e-272, 1e-271, 1e-270, 1e-269, 1e-268, 1e-267, 1e-266, 1e-265, 1e-264, 1e-263, 1e-262, 1e-261, 1e-260, 1e-259, 1e-258, 1e-257, 1e-256, + 1e-255, 1e-254, 1e-253, 1e-252, 1e-251, 1e-250, 1e-249, 1e-248, 1e-247, 1e-246, 1e-245, 1e-244, 1e-243, 1e-242, 1e-241, 1e-240, 1e-239, + 1e-238, 1e-237, 1e-236, 1e-235, 1e-234, 1e-233, 1e-232, 1e-231, 1e-230, 1e-229, 1e-228, 1e-227, 1e-226, 1e-225, 1e-224, 1e-223, 1e-222, + 1e-221, 1e-220, 1e-219, 1e-218, 1e-217, 1e-216, 1e-215, 1e-214, 1e-213, 1e-212, 1e-211, 1e-210, 1e-209, 1e-208, 1e-207, 1e-206, 1e-205, + 1e-204, 1e-203, 1e-202, 1e-201, 1e-200, 1e-199, 1e-198, 1e-197, 1e-196, 1e-195, 1e-194, 1e-193, 1e-192, 1e-191, 1e-190, 1e-189, 1e-188, + 1e-187, 1e-186, 1e-185, 1e-184, 1e-183, 1e-182, 1e-181, 1e-180, 1e-179, 1e-178, 1e-177, 1e-176, 1e-175, 1e-174, 1e-173, 1e-172, 1e-171, + 1e-170, 1e-169, 1e-168, 1e-167, 1e-166, 1e-165, 1e-164, 1e-163, 1e-162, 1e-161, 1e-160, 1e-159, 1e-158, 1e-157, 1e-156, 1e-155, 1e-154, + 1e-153, 1e-152, 1e-151, 1e-150, 1e-149, 1e-148, 1e-147, 1e-146, 1e-145, 1e-144, 1e-143, 1e-142, 1e-141, 1e-140, 1e-139, 1e-138, 1e-137, + 1e-136, 1e-135, 1e-134, 1e-133, 1e-132, 1e-131, 1e-130, 1e-129, 1e-128, 1e-127, 1e-126, 1e-125, 1e-124, 1e-123, 1e-122, 1e-121, 1e-120, + 1e-119, 1e-118, 1e-117, 1e-116, 1e-115, 1e-114, 1e-113, 1e-112, 1e-111, 1e-110, 1e-109, 1e-108, 1e-107, 1e-106, 1e-105, 1e-104, 1e-103, + 1e-102, 1e-101, 1e-100, 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, + 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, + 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, + 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, + 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 1e-19, 1e-18, + 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, + 1e0, 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, + 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, + 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, + 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, + 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 1e+81, 1e+82, 1e+83, 1e+84, + 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 1e+101, + 1e+102, 1e+103, 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109, 1e+110, 1e+111, 1e+112, 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118, + 1e+119, 1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, 1e+129, 1e+130, 1e+131, 1e+132, 1e+133, 1e+134, 1e+135, + 1e+136, 1e+137, 1e+138, 1e+139, 1e+140, 1e+141, 1e+142, 1e+143, 1e+144, 1e+145, 1e+146, 1e+147, 1e+148, 1e+149, 1e+150, 1e+151, 1e+152, + 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159, 1e+160, 1e+161, 1e+162, 1e+163, 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169, + 1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, 1e+177, 1e+178, 1e+179, 1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, + 1e+187, 1e+188, 1e+189, 1e+190, 1e+191, 1e+192, 1e+193, 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199, 1e+200, 1e+201, 1e+202, 1e+203, + 1e+204, 1e+205, 1e+206, 1e+207, 1e+208, 1e+209, 1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219, 1e+220, + 1e+221, 1e+222, 1e+223, 1e+224, 1e+225, 1e+226, 1e+227, 1e+228, 1e+229, 1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, + 1e+238, 1e+239, 1e+240, 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249, 1e+250, 1e+251, 1e+252, 1e+253, 1e+254, + 1e+255, 1e+256, 1e+257, 1e+258, 1e+259, 1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268, 1e+269, 1e+270, 1e+271, + 1e+272, 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279, 1e+280, 1e+281, 1e+282, 1e+283, 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, + 1e+289, 1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298, 1e+299, 1e+300, 1e+301, 1e+302, 1e+303, 1e+304, 1e+305, + 1e+306, 1e+307, 1e+308}; + + double n, y = modf(x, &n); + if (n > 308) return INFINITY; + if (n < -323) return 0; + + // Using lookup table based formula to get accurate results for integer arguments. + return exp2(3.32192809488736234787031942948939 * y) * p10[static_cast(n) + 323]; +} diff --git a/base/common/preciseExp10.h b/base/common/preciseExp10.h index 137205c484c..26a88318172 100644 --- a/base/common/preciseExp10.h +++ b/base/common/preciseExp10.h @@ -8,9 +8,4 @@ * Note: the function names are different to avoid confusion with symbols from the system libm. */ -extern "C" -{ - double preciseExp10(double x); - -} diff --git a/base/common/sleep.cpp b/base/common/sleep.cpp index f65864b369d..85bbc8edfcc 100644 --- a/base/common/sleep.cpp +++ b/base/common/sleep.cpp @@ -22,7 +22,7 @@ void sleepForNanoseconds(uint64_t nanoseconds) #if defined(OS_DARWIN) //https://developer.apple.com/library/archive/technotes/tn2169/_index.html //https://dshil.github.io/blog/missed-os-x-clock-guide/ - static mach_timebase_info_data_t timebase_info = {0}; + static mach_timebase_info_data_t timebase_info{}; if (timebase_info.denom == 0) mach_timebase_info(&timebase_info); diff --git a/base/common/strong_typedef.h b/base/common/strong_typedef.h index a46eb415e15..d9850a25c37 100644 --- a/base/common/strong_typedef.h +++ b/base/common/strong_typedef.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include template struct StrongTypedef diff --git a/base/common/tests/gtest_strong_typedef.cpp b/base/common/tests/gtest_strong_typedef.cpp index 8ee9535ce81..cb358459e68 100644 --- a/base/common/tests/gtest_strong_typedef.cpp +++ b/base/common/tests/gtest_strong_typedef.cpp @@ -1,5 +1,3 @@ -#define BOOST_TEST_MODULE StrongTypedef - #include #include #include @@ -12,15 +10,15 @@ TEST(StrongTypedefSuite, TypedefsOfTheSameType) { /// check that strong typedefs of same type differ - STRONG_TYPEDEF(int, Int); - STRONG_TYPEDEF(int, AnotherInt); + STRONG_TYPEDEF(int, Int) + STRONG_TYPEDEF(int, AnotherInt) EXPECT_TRUE(!(std::is_same::value)); } TEST(StrongTypedefSuite, Map) { - STRONG_TYPEDEF(int, Int); + STRONG_TYPEDEF(int, Int) /// check that this code compiles std::set int_set; @@ -31,13 +29,13 @@ TEST(StrongTypedefSuite, Map) TEST(StrongTypedefSuite, CopyAndMoveCtor) { - STRONG_TYPEDEF(int, Int); + STRONG_TYPEDEF(int, Int) Int a(1); Int b(2); a = b; EXPECT_EQ(a.toUnderType(), 2); - STRONG_TYPEDEF(std::unique_ptr, IntPtr); + STRONG_TYPEDEF(std::unique_ptr, IntPtr) { IntPtr ptr; ptr = IntPtr(std::make_unique(3)); @@ -57,6 +55,6 @@ TEST(StrongTypedefSuite, NoDefaultCtor) NoDefaultCtor(int) {} // NOLINT }; - STRONG_TYPEDEF(NoDefaultCtor, MyStruct); + STRONG_TYPEDEF(NoDefaultCtor, MyStruct) MyStruct m(1); } diff --git a/base/common/ya.make b/base/common/ya.make index 31a66893330..d40b1f5abfd 100644 --- a/base/common/ya.make +++ b/base/common/ya.make @@ -7,6 +7,10 @@ ADDINCL( CFLAGS (GLOBAL -DARCADIA_BUILD) +CFLAGS (GLOBAL -DUSE_CPUID=1) +CFLAGS (GLOBAL -DUSE_JEMALLOC=0) +CFLAGS (GLOBAL -DUSE_RAPIDJSON=1) + IF (OS_DARWIN) CFLAGS (GLOBAL -DOS_DARWIN) ELSEIF (OS_FREEBSD) @@ -20,6 +24,7 @@ PEERDIR( contrib/libs/cxxsupp/libcxx-filesystem contrib/libs/poco/Net contrib/libs/poco/Util + contrib/libs/fmt contrib/restricted/boost contrib/restricted/cityhash-1.0.2 ) @@ -37,11 +42,12 @@ SRCS( LineReader.cpp mremap.cpp phdr_cache.cpp - preciseExp10.c + preciseExp10.cpp setTerminalEcho.cpp shift10.cpp sleep.cpp terminalColors.cpp + errnoToString.cpp ) END() diff --git a/base/daemon/BaseDaemon.cpp b/base/daemon/BaseDaemon.cpp index c7012a3ba04..2a36777218e 100644 --- a/base/daemon/BaseDaemon.cpp +++ b/base/daemon/BaseDaemon.cpp @@ -52,11 +52,12 @@ #include #if !defined(ARCADIA_BUILD) -# include +# include #endif #if defined(OS_DARWIN) -# define _XOPEN_SOURCE 700 // ucontext is not available without _XOPEN_SOURCE +# pragma GCC diagnostic ignored "-Wunused-macros" +# define _XOPEN_SOURCE 700 // ucontext is not available without _XOPEN_SOURCE #endif #include @@ -76,7 +77,7 @@ static void call_default_signal_handler(int sig) static constexpr size_t max_query_id_size = 127; -static const size_t buf_size = +static const size_t signal_pipe_buf_size = sizeof(int) + sizeof(siginfo_t) + sizeof(ucontext_t) @@ -91,8 +92,8 @@ static void writeSignalIDtoSignalPipe(int sig) { auto saved_errno = errno; /// We must restore previous value of errno in signal handler. - char buf[buf_size]; - DB::WriteBufferFromFileDescriptor out(signal_pipe.fds_rw[1], buf_size, buf); + char buf[signal_pipe_buf_size]; + DB::WriteBufferFromFileDescriptor out(signal_pipe.fds_rw[1], signal_pipe_buf_size, buf); DB::writeBinary(sig, out); out.next(); @@ -117,13 +118,13 @@ static void signalHandler(int sig, siginfo_t * info, void * context) { auto saved_errno = errno; /// We must restore previous value of errno in signal handler. - char buf[buf_size]; - DB::WriteBufferFromFileDescriptorDiscardOnFailure out(signal_pipe.fds_rw[1], buf_size, buf); + char buf[signal_pipe_buf_size]; + DB::WriteBufferFromFileDescriptorDiscardOnFailure out(signal_pipe.fds_rw[1], signal_pipe_buf_size, buf); const ucontext_t signal_context = *reinterpret_cast(context); const StackTrace stack_trace(signal_context); - StringRef query_id = CurrentThread::getQueryId(); /// This is signal safe. + StringRef query_id = DB::CurrentThread::getQueryId(); /// This is signal safe. query_id.size = std::min(query_id.size, max_query_id_size); DB::writeBinary(sig, out); @@ -161,15 +162,15 @@ public: }; explicit SignalListener(BaseDaemon & daemon_) - : log(&Logger::get("BaseDaemon")) + : log(&Poco::Logger::get("BaseDaemon")) , daemon(daemon_) { } - void run() + void run() override { - char buf[buf_size]; - DB::ReadBufferFromFileDescriptor in(signal_pipe.fds_rw[0], buf_size, buf); + char buf[signal_pipe_buf_size]; + DB::ReadBufferFromFileDescriptor in(signal_pipe.fds_rw[0], signal_pipe_buf_size, buf); while (!in.eof()) { @@ -179,7 +180,7 @@ public: // levels and more info, but for completeness we log all signals // here at trace level. // Don't use strsignal here, because it's not thread-safe. - LOG_TRACE(log, "Received signal " << sig); + LOG_TRACE(log, "Received signal {}", sig); if (sig == Signals::StopThread) { @@ -230,12 +231,12 @@ public: } private: - Logger * log; + Poco::Logger * log; BaseDaemon & daemon; void onTerminate(const std::string & message, UInt32 thread_num) const { - LOG_FATAL(log, "(version " << VERSION_STRING << VERSION_OFFICIAL << ") (from thread " << thread_num << ") " << message); + LOG_FATAL(log, "(version {}{}) (from thread {}) {}", VERSION_STRING, VERSION_OFFICIAL, thread_num, message); } void onFault( @@ -256,9 +257,9 @@ private: message << " (no query)"; else message << " (query_id: " << query_id << ")"; - message << " Received signal " << strsignal(sig) << " (" << sig << ")" << "."; + message << " Received signal " << strsignal(sig) << " (" << sig << ")."; - LOG_FATAL(log, message.rdbuf()); + LOG_FATAL(log, message.str()); } LOG_FATAL(log, signalToErrorMessage(sig, info, context)); @@ -273,7 +274,7 @@ private: for (size_t i = stack_trace.getOffset(); i < stack_trace.getSize(); ++i) bare_stacktrace << ' ' << stack_trace.getFrames()[i]; - LOG_FATAL(log, bare_stacktrace.rdbuf()); + LOG_FATAL(log, bare_stacktrace.str()); } /// Write symbolized stack trace line by line for better grep-ability. @@ -282,19 +283,56 @@ private: }; +#if defined(SANITIZER) +extern "C" void __sanitizer_set_death_callback(void (*)()); + +static void sanitizerDeathCallback() +{ + Poco::Logger * log = &Poco::Logger::get("BaseDaemon"); + + StringRef query_id = DB::CurrentThread::getQueryId(); /// This is signal safe. + + { + std::stringstream message; + message << "(version " << VERSION_STRING << VERSION_OFFICIAL << ")"; + message << " (from thread " << getThreadId() << ")"; + if (query_id.size == 0) + message << " (no query)"; + else + message << " (query_id: " << query_id << ")"; + message << " Sanitizer trap."; + + LOG_FATAL(log, message.str()); + } + + /// Just in case print our own stack trace. In case when llvm-symbolizer does not work. + StackTrace stack_trace; + if (stack_trace.getSize()) + { + std::stringstream bare_stacktrace; + bare_stacktrace << "Stack trace:"; + for (size_t i = stack_trace.getOffset(); i < stack_trace.getSize(); ++i) + bare_stacktrace << ' ' << stack_trace.getFrames()[i]; + + LOG_FATAL(log, bare_stacktrace.str()); + } + + /// Write symbolized stack trace line by line for better grep-ability. + stack_trace.toStringEveryLine([&](const std::string & s) { LOG_FATAL(log, s); }); +} +#endif + + /** To use with std::set_terminate. * Collects slightly more info than __gnu_cxx::__verbose_terminate_handler, * and send it to pipe. Other thread will read this info from pipe and asynchronously write it to log. * Look at libstdc++-v3/libsupc++/vterminate.cc for example. */ -static void terminate_handler() +[[noreturn]] static void terminate_handler() { static thread_local bool terminating = false; if (terminating) - { abort(); - return; /// Just for convenience. - } terminating = true; @@ -341,7 +379,7 @@ static bool tryCreateDirectories(Poco::Logger * logger, const std::string & path } catch (...) { - LOG_WARNING(logger, __PRETTY_FUNCTION__ << ": when creating " << path << ", " << DB::getCurrentExceptionMessage(true)); + LOG_WARNING(logger, "{}: when creating {}, {}", __PRETTY_FUNCTION__, path, DB::getCurrentExceptionMessage(true)); } return false; } @@ -460,11 +498,10 @@ void debugIncreaseOOMScore() } catch (const Poco::Exception & e) { - LOG_WARNING(&Logger::root(), "Failed to adjust OOM score: '" + - e.displayText() + "'."); + LOG_WARNING(&Poco::Logger::root(), "Failed to adjust OOM score: '{}'.", e.displayText()); return; } - LOG_INFO(&Logger::root(), "Set OOM score adjustment to " + new_score); + LOG_INFO(&Poco::Logger::root(), "Set OOM score adjustment to {}", new_score); } #else void debugIncreaseOOMScore() {} @@ -524,12 +561,12 @@ void BaseDaemon::initialize(Application & self) /// This must be done before any usage of DateLUT. In particular, before any logging. if (config().has("timezone")) { - const std::string timezone = config().getString("timezone"); - if (0 != setenv("TZ", timezone.data(), 1)) + const std::string config_timezone = config().getString("timezone"); + if (0 != setenv("TZ", config_timezone.data(), 1)) throw Poco::Exception("Cannot setenv TZ variable"); tzset(); - DateLUT::setDefaultTimezone(timezone); + DateLUT::setDefaultTimezone(config_timezone); } std::string log_path = config().getString("logger.log", ""); @@ -547,6 +584,9 @@ void BaseDaemon::initialize(Application & self) std::string stderr_path = config().getString("logger.stderr", log_path + "/stderr.log"); if (!freopen(stderr_path.c_str(), "a+", stderr)) throw Poco::OpenFileException("Cannot attach stderr to " + stderr_path); + + /// Disable buffering for stderr + setbuf(stderr, nullptr); } if ((!log_path.empty() && is_daemon) || config().has("logger.stdout")) @@ -633,12 +673,18 @@ void BaseDaemon::initializeTerminationAndSignalProcessing() sa.sa_flags = SA_SIGINFO; { +#if defined(OS_DARWIN) + sigemptyset(&sa.sa_mask); + for (auto signal : signals) + sigaddset(&sa.sa_mask, signal); +#else if (sigemptyset(&sa.sa_mask)) throw Poco::Exception("Cannot set signal handler."); for (auto signal : signals) if (sigaddset(&sa.sa_mask, signal)) throw Poco::Exception("Cannot set signal handler."); +#endif for (auto signal : signals) if (sigaction(signal, &sa, nullptr)) @@ -652,6 +698,10 @@ void BaseDaemon::initializeTerminationAndSignalProcessing() add_signal_handler({SIGHUP, SIGUSR1}, closeLogsSignalHandler); add_signal_handler({SIGINT, SIGQUIT, SIGTERM}, terminateRequestedSignalHandler); +#if defined(SANITIZER) + __sanitizer_set_death_callback(sanitizerDeathCallback); +#endif + /// Set up Poco ErrorHandler for Poco Threads. static KillingErrorHandler killing_error_handler; Poco::ErrorHandler::set(&killing_error_handler); @@ -665,7 +715,7 @@ void BaseDaemon::initializeTerminationAndSignalProcessing() void BaseDaemon::logRevision() const { - Logger::root().information("Starting " + std::string{VERSION_FULL} + Poco::Logger::root().information("Starting " + std::string{VERSION_FULL} + " with revision " + std::to_string(ClickHouseRevision::get()) + ", PID " + std::to_string(getpid())); } @@ -682,42 +732,42 @@ void BaseDaemon::handleNotification(Poco::TaskFailedNotification *_tfn) { task_failed = true; Poco::AutoPtr fn(_tfn); - Logger *lg = &(logger()); - LOG_ERROR(lg, "Task '" << fn->task()->name() << "' failed. Daemon is shutting down. Reason - " << fn->reason().displayText()); + Poco::Logger * lg = &(logger()); + LOG_ERROR(lg, "Task '{}' failed. Daemon is shutting down. Reason - {}", fn->task()->name(), fn->reason().displayText()); ServerApplication::terminate(); } -void BaseDaemon::defineOptions(Poco::Util::OptionSet& _options) +void BaseDaemon::defineOptions(Poco::Util::OptionSet & new_options) { - Poco::Util::ServerApplication::defineOptions (_options); - - _options.addOption( + new_options.addOption( Poco::Util::Option("config-file", "C", "load configuration from a given file") .required(false) .repeatable(false) .argument("") .binding("config-file")); - _options.addOption( + new_options.addOption( Poco::Util::Option("log-file", "L", "use given log file") .required(false) .repeatable(false) .argument("") .binding("logger.log")); - _options.addOption( + new_options.addOption( Poco::Util::Option("errorlog-file", "E", "use given log file for errors only") .required(false) .repeatable(false) .argument("") .binding("logger.errorlog")); - _options.addOption( + new_options.addOption( Poco::Util::Option("pid-file", "P", "use given pidfile") .required(false) .repeatable(false) .argument("") .binding("pid")); + + Poco::Util::ServerApplication::defineOptions(new_options); } bool isPidRunning(pid_t pid) @@ -799,7 +849,7 @@ void BaseDaemon::handleSignal(int signal_id) void BaseDaemon::onInterruptSignals(int signal_id) { is_cancelled = true; - LOG_INFO(&logger(), "Received termination signal (" << strsignal(signal_id) << ")"); + LOG_INFO(&logger(), "Received termination signal ({})", strsignal(signal_id)); if (sigint_signals_counter >= 2) { diff --git a/base/daemon/BaseDaemon.h b/base/daemon/BaseDaemon.h index f55dbb2a549..39332cfe963 100644 --- a/base/daemon/BaseDaemon.h +++ b/base/daemon/BaseDaemon.h @@ -58,7 +58,7 @@ public: void reloadConfiguration(); /// Определяет параметр командной строки - void defineOptions(Poco::Util::OptionSet & _options) override; + void defineOptions(Poco::Util::OptionSet & new_options) override; /// Заставляет демон завершаться, если хотя бы одна задача завершилась неудачно void exitOnTaskError(); diff --git a/base/daemon/CMakeLists.txt b/base/daemon/CMakeLists.txt index e541d7633ef..5d9a37dc75e 100644 --- a/base/daemon/CMakeLists.txt +++ b/base/daemon/CMakeLists.txt @@ -4,4 +4,4 @@ add_library (daemon ) target_include_directories (daemon PUBLIC ..) -target_link_libraries (daemon PUBLIC loggers PRIVATE clickhouse_common_io clickhouse_common_config common ${Poco_Net_LIBRARY} ${Poco_Util_LIBRARY} ${EXECINFO_LIBRARIES}) +target_link_libraries (daemon PUBLIC loggers PRIVATE clickhouse_common_io clickhouse_common_config common ${EXECINFO_LIBRARIES}) diff --git a/base/daemon/GraphiteWriter.h b/base/daemon/GraphiteWriter.h index a19f6396831..fc07d2b7a40 100644 --- a/base/daemon/GraphiteWriter.h +++ b/base/daemon/GraphiteWriter.h @@ -52,8 +52,7 @@ private: } catch (const Poco::Exception & e) { - LOG_WARNING(&Poco::Util::Application::instance().logger(), - "Fail to write to Graphite " << host << ":" << port << ". e.what() = " << e.what() << ", e.message() = " << e.message()); + LOG_WARNING(&Poco::Util::Application::instance().logger(), "Fail to write to Graphite {}:{}. e.what() = {}, e.message() = {}", host, port, e.what(), e.message()); } } diff --git a/base/ext/chrono_io.h b/base/ext/chrono_io.h index 40b76a96478..392ec25d526 100644 --- a/base/ext/chrono_io.h +++ b/base/ext/chrono_io.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace ext diff --git a/base/ext/range.h b/base/ext/range.h index c379d453f7b..266016f5779 100644 --- a/base/ext/range.h +++ b/base/ext/range.h @@ -1,42 +1,62 @@ #pragma once -#include #include #include +#include namespace ext { - /// For loop adaptor which is used to iterate through a half-closed interval [begin, end). - template - inline auto range(BeginType begin, EndType end) +namespace internal +{ + template + auto rangeImpl(BeginType begin, EndType end) { - using CommonType = typename std::common_type::type; - return boost::counting_range(begin, end); - } - - template - inline auto range(Type end) - { - return range(static_cast(0), end); - } - - /// The same as range(), but every value is casted statically to a specified `ValueType`. - /// This is useful to iterate through all constants of a enum. - template - inline auto range_with_static_cast(BeginType begin, EndType end) - { - using CommonType = typename std::common_type::type; - if constexpr (std::is_same_v) - return boost::counting_range(begin, end); + if constexpr (std::is_same_v) + return boost::counting_range(static_cast(begin), static_cast(end)); else - return boost::counting_range(begin, end) - | boost::adaptors::transformed([](CommonType x) -> ValueType { return static_cast(x); }); - } - - template - inline auto range_with_static_cast(EndType end) - { - return range_with_static_cast(static_cast(0), end); + return boost::counting_range(static_cast(begin), static_cast(end)) + | boost::adaptors::transformed([](CountingType x) { return static_cast(x); }); } } + + +/// For loop adaptor which is used to iterate through a half-closed interval [begin, end). +/// The parameters `begin` and `end` can have any integral or enum types. +template || std::is_enum_v) && + (std::is_integral_v || std::is_enum_v) && + (!std::is_enum_v || !std::is_enum_v || std::is_same_v), void>> +inline auto range(BeginType begin, EndType end) +{ + if constexpr (std::is_integral_v && std::is_integral_v) + { + using CommonType = std::common_type_t; + return internal::rangeImpl(begin, end); + } + else if constexpr (std::is_enum_v) + { + return internal::rangeImpl>(begin, end); + } + else + { + return internal::rangeImpl>(begin, end); + } +} + + +/// For loop adaptor which is used to iterate through a half-closed interval [0, end). +/// The parameter `end` can have any integral or enum type. +/// The same as range(0, end). +template || std::is_enum_v, void>> +inline auto range(Type end) +{ + if constexpr (std::is_integral_v) + return internal::rangeImpl(0, end); + else + return internal::rangeImpl>(0, end); +} +} diff --git a/base/loggers/CMakeLists.txt b/base/loggers/CMakeLists.txt index bada5a2fe1d..48868cf1e0d 100644 --- a/base/loggers/CMakeLists.txt +++ b/base/loggers/CMakeLists.txt @@ -1,5 +1,5 @@ include(${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake) add_headers_and_sources(loggers .) add_library(loggers ${loggers_sources} ${loggers_headers}) -target_link_libraries(loggers PRIVATE dbms clickhouse_common_io ${Poco_Foundation_LIBRARY}) +target_link_libraries(loggers PRIVATE dbms clickhouse_common_io) target_include_directories(loggers PUBLIC ..) diff --git a/base/loggers/OwnFormattingChannel.cpp b/base/loggers/OwnFormattingChannel.cpp index 9fccc929364..f03d155bde7 100644 --- a/base/loggers/OwnFormattingChannel.cpp +++ b/base/loggers/OwnFormattingChannel.cpp @@ -4,6 +4,7 @@ namespace DB { + void OwnFormattingChannel::logExtended(const ExtendedLogMessage & msg) { if (pChannel && priority >= msg.base.getPriority()) @@ -28,5 +29,4 @@ void OwnFormattingChannel::log(const Poco::Message & msg) OwnFormattingChannel::~OwnFormattingChannel() = default; - } diff --git a/base/loggers/OwnSplitChannel.cpp b/base/loggers/OwnSplitChannel.cpp index 3f77b594fbb..22951d1b509 100644 --- a/base/loggers/OwnSplitChannel.cpp +++ b/base/loggers/OwnSplitChannel.cpp @@ -69,7 +69,6 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg) logs_queue->emplace(std::move(columns)); } - /// Also log to system.text_log table, if message is not too noisy auto text_log_max_priority_loaded = text_log_max_priority.load(std::memory_order_relaxed); if (text_log_max_priority_loaded && msg.getPriority() <= text_log_max_priority_loaded) diff --git a/base/mysqlxx/CMakeLists.txt b/base/mysqlxx/CMakeLists.txt index 6263de79be9..7d35c1bd31d 100644 --- a/base/mysqlxx/CMakeLists.txt +++ b/base/mysqlxx/CMakeLists.txt @@ -32,10 +32,18 @@ else () endif () endif () -target_link_libraries(mysqlxx PUBLIC common ${Poco_Util_LIBRARY} ${Poco_Foundation_LIBRARY} PRIVATE ${MYSQLCLIENT_LIBRARIES} PUBLIC ${Boost_SYSTEM_LIBRARY} PRIVATE ${ZLIB_LIBRARIES}) +target_link_libraries (mysqlxx + PUBLIC + common + PRIVATE + ${MYSQLCLIENT_LIBRARIES} + ${ZLIB_LIBRARIES} +) + if(OPENSSL_LIBRARIES) target_link_libraries(mysqlxx PRIVATE ${OPENSSL_LIBRARIES}) endif() + target_link_libraries(mysqlxx PRIVATE ${PLATFORM_LIBRARIES}) if (NOT USE_INTERNAL_MYSQL_LIBRARY AND OPENSSL_INCLUDE_DIR) diff --git a/base/mysqlxx/Exception.cpp b/base/mysqlxx/Exception.cpp index b065d17ed51..188e7bd740d 100644 --- a/base/mysqlxx/Exception.cpp +++ b/base/mysqlxx/Exception.cpp @@ -18,8 +18,6 @@ std::string errorMessage(MYSQL * driver) return res.str(); } - -/// Для внутренних нужд библиотеки. void checkError(MYSQL * driver) { unsigned num = mysql_errno(driver); @@ -28,8 +26,6 @@ void checkError(MYSQL * driver) throw Exception(errorMessage(driver), num); } - -/// Для внутренних нужд библиотеки. void onError(MYSQL * driver) { throw Exception(errorMessage(driver), mysql_errno(driver)); diff --git a/base/mysqlxx/Exception.h b/base/mysqlxx/Exception.h index 92f3f34806f..eaeb3565af1 100644 --- a/base/mysqlxx/Exception.h +++ b/base/mysqlxx/Exception.h @@ -48,6 +48,6 @@ std::string errorMessage(MYSQL * driver); /// For internal need of library. void checkError(MYSQL * driver); -void onError(MYSQL * driver); +[[noreturn]] void onError(MYSQL * driver); } diff --git a/base/mysqlxx/Null.h b/base/mysqlxx/Null.h index a3ba3a48cb1..b12e1e7f0bf 100644 --- a/base/mysqlxx/Null.h +++ b/base/mysqlxx/Null.h @@ -27,7 +27,7 @@ public: Null() : is_null(true) {} Null(const Null &) = default; Null(Null &&) noexcept = default; - Null(NullType data) : is_null(true) {} + Null(NullType) : is_null(true) {} explicit Null(const T & data_) : data(data_), is_null(false) {} operator T & () @@ -47,7 +47,7 @@ public: Null & operator= (Null &&) noexcept = default; Null & operator= (const Null &) = default; Null & operator= (const T & data_) { is_null = false; data = data_; return *this; } - Null & operator= (const NullType other) { is_null = true; data = T(); return *this; } + Null & operator= (const NullType) { is_null = true; data = T(); return *this; } bool isNull() const { return is_null; } @@ -57,7 +57,7 @@ public: || (is_null == other.is_null && data < other.data); } - bool operator< (const NullType other) const { return false; } + bool operator< (const NullType) const { return false; } bool operator== (const Null & other) const { @@ -69,14 +69,14 @@ public: return !is_null && data == other; } - bool operator== (const NullType other) const { return is_null; } + bool operator== (const NullType) const { return is_null; } bool operator!= (const Null & other) const { return !(*this == other); } - bool operator!= (const NullType other) const { return !is_null; } + bool operator!= (const NullType) const { return !is_null; } bool operator!= (const T & other) const { diff --git a/base/mysqlxx/PoolWithFailover.cpp b/base/mysqlxx/PoolWithFailover.cpp index a763988331b..5bee75aab1b 100644 --- a/base/mysqlxx/PoolWithFailover.cpp +++ b/base/mysqlxx/PoolWithFailover.cpp @@ -10,46 +10,47 @@ static bool startsWith(const std::string & s, const char * prefix) using namespace mysqlxx; -PoolWithFailover::PoolWithFailover(const Poco::Util::AbstractConfiguration & config, - const std::string & config_name, const unsigned default_connections, - const unsigned max_connections, const size_t max_tries) - : max_tries(max_tries) +PoolWithFailover::PoolWithFailover(const Poco::Util::AbstractConfiguration & config_, + const std::string & config_name_, const unsigned default_connections_, + const unsigned max_connections_, const size_t max_tries_) + : max_tries(max_tries_) { - shareable = config.getBool(config_name + ".share_connection", false); - if (config.has(config_name + ".replica")) + shareable = config_.getBool(config_name_ + ".share_connection", false); + if (config_.has(config_name_ + ".replica")) { Poco::Util::AbstractConfiguration::Keys replica_keys; - config.keys(config_name, replica_keys); + config_.keys(config_name_, replica_keys); for (const auto & replica_config_key : replica_keys) { /// There could be another elements in the same level in configuration file, like "password", "port"... if (startsWith(replica_config_key, "replica")) { - std::string replica_name = config_name + "." + replica_config_key; + std::string replica_name = config_name_ + "." + replica_config_key; - int priority = config.getInt(replica_name + ".priority", 0); + int priority = config_.getInt(replica_name + ".priority", 0); replicas_by_priority[priority].emplace_back( - std::make_shared(config, replica_name, default_connections, max_connections, config_name.c_str())); + std::make_shared(config_, replica_name, default_connections_, max_connections_, config_name_.c_str())); } } } else { replicas_by_priority[0].emplace_back( - std::make_shared(config, config_name, default_connections, max_connections)); + std::make_shared(config_, config_name_, default_connections_, max_connections_)); } } -PoolWithFailover::PoolWithFailover(const std::string & config_name, const unsigned default_connections, - const unsigned max_connections, const size_t max_tries) +PoolWithFailover::PoolWithFailover(const std::string & config_name_, const unsigned default_connections_, + const unsigned max_connections_, const size_t max_tries_) : PoolWithFailover{ - Poco::Util::Application::instance().config(), config_name, - default_connections, max_connections, max_tries} -{} + Poco::Util::Application::instance().config(), config_name_, + default_connections_, max_connections_, max_tries_} +{ +} PoolWithFailover::PoolWithFailover(const PoolWithFailover & other) - : max_tries{other.max_tries}, config_name{other.config_name}, shareable{other.shareable} + : max_tries{other.max_tries}, shareable{other.shareable} { if (shareable) { diff --git a/base/mysqlxx/PoolWithFailover.h b/base/mysqlxx/PoolWithFailover.h index 9db29db5efa..029fc3ebad3 100644 --- a/base/mysqlxx/PoolWithFailover.h +++ b/base/mysqlxx/PoolWithFailover.h @@ -77,7 +77,6 @@ namespace mysqlxx size_t max_tries; /// Mutex for set of replicas. std::mutex mutex; - std::string config_name; /// Can the Pool be shared bool shareable; @@ -91,16 +90,16 @@ namespace mysqlxx * max_connections Maximum number of connections in pool to each replica. * max_tries_ Max number of connection tries. */ - PoolWithFailover(const std::string & config_name, - unsigned default_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS, - unsigned max_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS, - size_t max_tries = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES); + PoolWithFailover(const std::string & config_name_, + unsigned default_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS, + unsigned max_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS, + size_t max_tries_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES); - PoolWithFailover(const Poco::Util::AbstractConfiguration & config, - const std::string & config_name, - unsigned default_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS, - unsigned max_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS, - size_t max_tries = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES); + PoolWithFailover(const Poco::Util::AbstractConfiguration & config_, + const std::string & config_name_, + unsigned default_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS, + unsigned max_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS, + size_t max_tries_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES); PoolWithFailover(const PoolWithFailover & other); diff --git a/base/mysqlxx/Query.cpp b/base/mysqlxx/Query.cpp index a0e7cf1a483..ab9bb174d4a 100644 --- a/base/mysqlxx/Query.cpp +++ b/base/mysqlxx/Query.cpp @@ -11,29 +11,23 @@ namespace mysqlxx { -Query::Query(Connection * conn_, const std::string & query_string) : std::ostream(nullptr), conn(conn_) +Query::Query(Connection * conn_, const std::string & query_string) : conn(conn_) { /// Важно в случае, если Query используется не из того же потока, что Connection. mysql_thread_init(); - init(&query_buf); - if (!query_string.empty()) - { - query_buf.str(query_string); - seekp(0, std::ios::end); - } + query_buf << query_string; - imbue(std::locale::classic()); + query_buf.imbue(std::locale::classic()); } -Query::Query(const Query & other) : std::ostream(nullptr), conn(other.conn) +Query::Query(const Query & other) : conn(other.conn) { /// Важно в случае, если Query используется не из того же потока, что Connection. mysql_thread_init(); - init(&query_buf); - imbue(std::locale::classic()); + query_buf.imbue(std::locale::classic()); *this << other.str(); } @@ -45,9 +39,7 @@ Query & Query::operator= (const Query & other) conn = other.conn; - seekp(0); - clear(); - *this << other.str(); + query_buf.str(other.str()); return *this; } @@ -59,9 +51,7 @@ Query::~Query() void Query::reset() { - seekp(0); - clear(); - query_buf.str(""); + query_buf.str({}); } void Query::executeImpl() diff --git a/base/mysqlxx/Query.h b/base/mysqlxx/Query.h index 66371bc7af0..1d3ab9678d5 100644 --- a/base/mysqlxx/Query.h +++ b/base/mysqlxx/Query.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include @@ -28,7 +27,7 @@ namespace mysqlxx * * Внимание! Один объект запроса можно использовать только из одного потока. */ -class Query : public std::ostream +class Query { public: Query(Connection * conn_, const std::string & query_string = ""); @@ -64,9 +63,21 @@ public: return query_buf.str(); } + auto rdbuf() const + { + return query_buf.rdbuf(); + } + + template + inline Query & operator<< (T && x) + { + query_buf << std::forward(x); + return *this; + } + private: Connection * conn; - std::stringbuf query_buf; + std::ostringstream query_buf; void executeImpl(); }; diff --git a/base/mysqlxx/ResultBase.h b/base/mysqlxx/ResultBase.h index 00247b6c90b..126a5c1ecca 100644 --- a/base/mysqlxx/ResultBase.h +++ b/base/mysqlxx/ResultBase.h @@ -22,11 +22,11 @@ class ResultBase public: ResultBase(MYSQL_RES * res_, Connection * conn_, const Query * query_); - Connection * getConnection() { return conn; } - MYSQL_FIELDS getFields() { return fields; } - unsigned getNumFields() { return num_fields; } - MYSQL_RES * getRes() { return res; } - const Query * getQuery() const { return query; } + Connection * getConnection() { return conn; } + MYSQL_FIELDS getFields() { return fields; } + unsigned getNumFields() { return num_fields; } + MYSQL_RES * getRes() { return res; } + const Query * getQuery() const { return query; } virtual ~ResultBase(); diff --git a/base/mysqlxx/StoreQueryResult.cpp b/base/mysqlxx/StoreQueryResult.cpp index a09986a3014..620ed8def56 100644 --- a/base/mysqlxx/StoreQueryResult.cpp +++ b/base/mysqlxx/StoreQueryResult.cpp @@ -14,16 +14,15 @@ namespace mysqlxx StoreQueryResult::StoreQueryResult(MYSQL_RES * res_, Connection * conn_, const Query * query_) : ResultBase(res_, conn_, query_) { UInt64 rows = mysql_num_rows(res); - UInt32 fields = getNumFields(); reserve(rows); - lengths.resize(rows * fields); + lengths.resize(rows * num_fields); for (UInt64 i = 0; MYSQL_ROW row = mysql_fetch_row(res); ++i) { MYSQL_LENGTHS lengths_for_row = mysql_fetch_lengths(res); - memcpy(&lengths[i * fields], lengths_for_row, sizeof(lengths[0]) * fields); + memcpy(&lengths[i * num_fields], lengths_for_row, sizeof(lengths[0]) * num_fields); - push_back(Row(row, this, &lengths[i * fields])); + push_back(Row(row, this, &lengths[i * num_fields])); } checkError(conn->getDriver()); } diff --git a/base/mysqlxx/tests/mysqlxx_test.cpp b/base/mysqlxx/tests/mysqlxx_test.cpp index e5e2ec1f592..cf304a5cb5f 100644 --- a/base/mysqlxx/tests/mysqlxx_test.cpp +++ b/base/mysqlxx/tests/mysqlxx_test.cpp @@ -68,10 +68,10 @@ int main(int, char **) Queries queries; queries.push_back(query); - for (auto & query : queries) + for (auto & q : queries) { - std::cerr << query.str() << std::endl; - std::cerr << query.store().at(0) << std::endl; + std::cerr << q.str() << std::endl; + std::cerr << q.store().at(0) << std::endl; } } diff --git a/cmake/Modules/FindODBC.cmake b/cmake/Modules/FindODBC.cmake deleted file mode 100644 index 9e209c15777..00000000000 --- a/cmake/Modules/FindODBC.cmake +++ /dev/null @@ -1,147 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindMySQL -# ------- -# -# Find ODBC Runtime -# -# This will define the following variables:: -# -# ODBC_FOUND - True if the system has the libraries -# ODBC_INCLUDE_DIRS - where to find the headers -# ODBC_LIBRARIES - where to find the libraries -# ODBC_DEFINITIONS - compile definitons -# -# Hints: -# Set ``ODBC_ROOT_DIR`` to the root directory of an installation. -# -include(FindPackageHandleStandardArgs) - -find_package(PkgConfig QUIET) -pkg_check_modules(PC_ODBC QUIET odbc) - -if(WIN32) - get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH) - get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH) -endif() - -find_path(ODBC_INCLUDE_DIR - NAMES sql.h - HINTS - ${ODBC_ROOT_DIR}/include - ${ODBC_ROOT_INCLUDE_DIRS} - PATHS - ${PC_ODBC_INCLUDE_DIRS} - /usr/include - /usr/local/include - /usr/local/odbc/include - /usr/local/iodbc/include - "C:/Program Files/ODBC/include" - "C:/Program Files/Microsoft SDKs/Windows/v7.0/include" - "C:/Program Files/Microsoft SDKs/Windows/v6.0a/include" - "C:/ODBC/include" - "${kit_dir}/Include/um" - "${kit81_dir}/Include/um" - PATH_SUFFIXES - odbc - iodbc - DOC "Specify the directory containing sql.h." -) - -if(NOT ODBC_INCLUDE_DIR AND WIN32) - set(ODBC_INCLUDE_DIR "") -else() - set(REQUIRED_INCLUDE_DIR ODBC_INCLUDE_DIR) -endif() - -if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) - set(WIN_ARCH x64) -elseif(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) - set(WIN_ARCH x86) -endif() - -find_library(ODBC_LIBRARY - NAMES unixodbc iodbc odbc odbc32 - HINTS - ${ODBC_ROOT_DIR}/lib - ${ODBC_ROOT_LIBRARY_DIRS} - PATHS - ${PC_ODBC_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - /usr/local/odbc/lib - /usr/local/iodbc/lib - "C:/Program Files/ODBC/lib" - "C:/ODBC/lib/debug" - "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib" - "${kit81_dir}/Lib/winv6.3/um" - "${kit_dir}/Lib/win8/um" - PATH_SUFIXES - odbc - ${WIN_ARCH} - DOC "Specify the ODBC driver manager library here." -) - -if(NOT ODBC_LIBRARY AND WIN32) - # List names of ODBC libraries on Windows - set(ODBC_LIBRARY odbc32.lib) -endif() - -# List additional libraries required to use ODBC library -if(WIN32 AND MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - set(_odbc_required_libs_names odbccp32;ws2_32) -endif() -foreach(_lib_name IN LISTS _odbc_required_libs_names) - find_library(_lib_path - NAMES ${_lib_name} - HINTS - ${ODBC_ROOT_DIR}/lib - ${ODBC_ROOT_LIBRARY_DIRS} - PATHS - ${PC_ODBC_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - /usr/local/odbc/lib - /usr/local/iodbc/lib - "C:/Program Files/ODBC/lib" - "C:/ODBC/lib/debug" - "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib" - PATH_SUFFIXES - odbc - ) - if (_lib_path) - list(APPEND _odbc_required_libs_paths ${_lib_path}) - endif() - unset(_lib_path CACHE) -endforeach() -unset(_odbc_lib_paths) -unset(_odbc_required_libs_names) - - -find_package_handle_standard_args(ODBC - FOUND_VAR ODBC_FOUND - REQUIRED_VARS - ODBC_LIBRARY - ${REQUIRED_INCLUDE_DIR} - VERSION_VAR ODBC_VERSION -) - -if(ODBC_FOUND) - set(ODBC_LIBRARIES ${ODBC_LIBRARY} ${_odbc_required_libs_paths} ${LTDL_LIBRARY}) - set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR}) - set(ODBC_DEFINITIONS ${PC_ODBC_CFLAGS_OTHER}) -endif() - -if(ODBC_FOUND AND NOT TARGET ODBC::ODBC) - add_library(ODBC::ODBC UNKNOWN IMPORTED) - set_target_properties(ODBC::ODBC PROPERTIES - IMPORTED_LOCATION "${ODBC_LIBRARY}" - INTERFACE_LINK_LIBRARIES "${_odbc_required_libs_paths}" - INTERFACE_COMPILE_OPTIONS "${PC_ODBC_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}" - ) -endif() - -mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR) diff --git a/cmake/Modules/FindOpenLDAP.cmake b/cmake/Modules/FindOpenLDAP.cmake new file mode 100644 index 00000000000..c33eafdcb2e --- /dev/null +++ b/cmake/Modules/FindOpenLDAP.cmake @@ -0,0 +1,55 @@ +# Find OpenLDAP libraries. +# +# Can be configured with: +# OPENLDAP_ROOT_DIR - path to the OpenLDAP installation prefix +# OPENLDAP_USE_STATIC_LIBS - look for static version of the libraries +# OPENLDAP_USE_REENTRANT_LIBS - look for thread-safe version of the libraries +# +# Sets values of: +# OPENLDAP_FOUND - TRUE if found +# OPENLDAP_INCLUDE_DIR - path to the include directory +# OPENLDAP_LIBRARIES - paths to the libldap and liblber libraries +# OPENLDAP_LDAP_LIBRARY - paths to the libldap library +# OPENLDAP_LBER_LIBRARY - paths to the liblber library +# + +if(OPENLDAP_USE_STATIC_LIBS) + set(_orig_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a" ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() +endif() + +set(_r_suffix) +if(OPENLDAP_USE_REENTRANT_LIBS) + set(_r_suffix "_r") +endif() + +if(OPENLDAP_ROOT_DIR) + find_path(OPENLDAP_INCLUDE_DIR NAMES "ldap.h" "lber.h" PATHS "${OPENLDAP_ROOT_DIR}" PATH_SUFFIXES "include" NO_DEFAULT_PATH) + find_library(OPENLDAP_LDAP_LIBRARY NAMES "ldap${_r_suffix}" PATHS "${OPENLDAP_ROOT_DIR}" PATH_SUFFIXES "lib" NO_DEFAULT_PATH) + find_library(OPENLDAP_LBER_LIBRARY NAMES "lber" PATHS "${OPENLDAP_ROOT_DIR}" PATH_SUFFIXES "lib" NO_DEFAULT_PATH) +else() + find_path(OPENLDAP_INCLUDE_DIR NAMES "ldap.h" "lber.h") + find_library(OPENLDAP_LDAP_LIBRARY NAMES "ldap${_r_suffix}") + find_library(OPENLDAP_LBER_LIBRARY NAMES "lber") +endif() + +unset(_r_suffix) + +set(OPENLDAP_LIBRARIES ${OPENLDAP_LDAP_LIBRARY} ${OPENLDAP_LBER_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + OpenLDAP DEFAULT_MSG + OPENLDAP_INCLUDE_DIR OPENLDAP_LDAP_LIBRARY OPENLDAP_LBER_LIBRARY +) + +mark_as_advanced(OPENLDAP_INCLUDE_DIR OPENLDAP_LIBRARIES OPENLDAP_LDAP_LIBRARY OPENLDAP_LBER_LIBRARY) + +if(OPENLDAP_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_orig_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_orig_CMAKE_FIND_LIBRARY_SUFFIXES) +endif() diff --git a/cmake/Modules/FindPoco.cmake b/cmake/Modules/FindPoco.cmake deleted file mode 100644 index cad7e9afc8f..00000000000 --- a/cmake/Modules/FindPoco.cmake +++ /dev/null @@ -1,247 +0,0 @@ -# https://github.com/astahl/poco-cmake/blob/master/cmake/FindPoco.cmake - -# - finds the Poco C++ libraries -# This module finds the Applied Informatics Poco libraries. -# It supports the following components: -# -# Util (loaded by default) -# Foundation (loaded by default) -# XML -# Zip -# Crypto -# Data -# Net -# NetSSL -# OSP -# -# Usage: -# set(ENV{Poco_DIR} path/to/poco/sdk) -# find_package(Poco REQUIRED OSP Data Crypto) -# -# On completion, the script defines the following variables: -# -# - Compound variables: -# Poco_FOUND -# - true if all requested components were found. -# Poco_LIBRARIES -# - contains release (and debug if available) libraries for all requested components. -# It has the form "optimized LIB1 debug LIBd1 optimized LIB2 ...", ready for use with the target_link_libraries command. -# Poco_INCLUDE_DIRS -# - Contains include directories for all requested components. -# -# - Component variables: -# Poco_Xxx_FOUND -# - Where Xxx is the properly cased component name (eg. 'Util', 'OSP'). -# True if a component's library or debug library was found successfully. -# Poco_Xxx_LIBRARY -# - Library for component Xxx. -# Poco_Xxx_LIBRARY_DEBUG -# - debug library for component Xxx -# Poco_Xxx_INCLUDE_DIR -# - include directory for component Xxx -# -# - OSP BundleCreator variables: (i.e. bundle.exe on windows, bundle on unix-likes) -# (is only discovered if OSP is a requested component) -# Poco_OSP_Bundle_EXECUTABLE_FOUND -# - true if the bundle-creator executable was found. -# Poco_OSP_Bundle_EXECUTABLE -# - the path to the bundle-creator executable. -# -# Author: Andreas Stahl andreas.stahl@tu-dresden.de - -set(Poco_HINTS - /usr/local - /usr/local/include/Poco - C:/AppliedInformatics - ${Poco_DIR} - $ENV{Poco_DIR} -) - -if(NOT Poco_ROOT_DIR) - # look for the root directory, first for the source-tree variant - find_path(Poco_ROOT_DIR - NAMES Foundation/include/Poco/Poco.h - HINTS ${Poco_HINTS} - ) - if(NOT Poco_ROOT_DIR) - # this means poco may have a different directory structure, maybe it was installed, let's check for that - message(STATUS "Looking for Poco install directory structure.") - find_path(Poco_ROOT_DIR - NAMES include/Poco/Poco.h - HINTS ${Poco_HINTS} - ) - if(NOT Poco_ROOT_DIR) - # poco was still not found -> Fail - if(Poco_FIND_REQUIRED) - message(FATAL_ERROR "Poco: Could not find Poco install directory") - endif() - if(NOT Poco_FIND_QUIETLY) - message(STATUS "Poco: Could not find Poco install directory") - endif() - return() - else() - # poco was found with the make install directory structure - message(STATUS "Assuming Poco install directory structure at ${Poco_ROOT_DIR}.") - set(Poco_INSTALLED true) - endif() - endif() -endif() - -# add dynamic library directory -if(WIN32) - find_path(Poco_RUNTIME_LIBRARY_DIRS - NAMES PocoFoundation.dll - HINTS ${Poco_ROOT_DIR} - PATH_SUFFIXES - bin - lib - ) -endif() - -# if installed directory structure, set full include dir -if(Poco_INSTALLED) - set(Poco_INCLUDE_DIRS ${Poco_ROOT_DIR}/include/ CACHE PATH "The global include path for Poco") -endif() - -# append the default minimum components to the list to find -list(APPEND components - ${Poco_FIND_COMPONENTS} - # default components: - "Util" - "Foundation" -) -list(REMOVE_DUPLICATES components) # remove duplicate defaults - -foreach( component ${components} ) - #if(NOT Poco_${component}_FOUND) - - # include directory for the component - if(NOT Poco_${component}_INCLUDE_DIR) - set (component_alt "${component}") - set (component_root "${component}") - if (${component} STREQUAL "DataODBC") - set (component_top "Data") - set (component_in "ODBC") - set (component_root "Data/ODBC") - endif () - if (${component} STREQUAL "SQLODBC") - set (component_top "SQL") - set (component_in "ODBC") - set (component_root "SQL/ODBC") - endif () - if (${component} STREQUAL "NetSSL") - set (component_alt "Net") - set (component_root "NetSSL_OpenSSL") - endif () - find_path(Poco_${component}_INCLUDE_DIR - NAMES - Poco/${component}.h # e.g. Foundation.h - Poco/${component}/${component}.h # e.g. OSP/OSP.h Util/Util.h - Poco/${component_alt}/${component}.h # e.g. Net/NetSSL.h - Poco/${component_top}/${component_in}/${component_in}.h # e.g. Data/ODBC/ODBC.h - HINTS - ${Poco_ROOT_DIR} - PATH_SUFFIXES - include - ${component_root}/include - ) - # message(STATUS "poco include debug: {component}: ${Poco_${component}_INCLUDE_DIR}") - endif() - if(NOT Poco_${component}_INCLUDE_DIR) - message(WARNING "Poco_${component}_INCLUDE_DIR NOT FOUND") - else() - list(APPEND Poco_INCLUDE_DIRS ${Poco_${component}_INCLUDE_DIR}) - endif() - - # release library - if(NOT Poco_${component}_LIBRARY) - find_library( - Poco_${component}_LIBRARY - NAMES Poco${component} - HINTS ${Poco_ROOT_DIR} - PATH_SUFFIXES - lib - bin - ) - if(Poco_${component}_LIBRARY) - message(STATUS "Found Poco ${component}: ${Poco_${component}_LIBRARY}") - endif() - endif() - if(Poco_${component}_LIBRARY) - list(APPEND Poco_LIBRARIES "optimized" ${Poco_${component}_LIBRARY} ) - mark_as_advanced(Poco_${component}_LIBRARY) - endif() - - # debug library - if(NOT Poco_${component}_LIBRARY_DEBUG) - find_library( - Poco_${component}_LIBRARY_DEBUG - Names Poco${component}d - HINTS ${Poco_ROOT_DIR} - PATH_SUFFIXES - lib - bin - ) - if(Poco_${component}_LIBRARY_DEBUG) - message(STATUS "Found Poco ${component} (debug): ${Poco_${component}_LIBRARY_DEBUG}") - endif() - endif(NOT Poco_${component}_LIBRARY_DEBUG) - if(Poco_${component}_LIBRARY_DEBUG) - list(APPEND Poco_LIBRARIES "debug" ${Poco_${component}_LIBRARY_DEBUG}) - mark_as_advanced(Poco_${component}_LIBRARY_DEBUG) - endif() - - # mark component as found or handle not finding it - if(Poco_${component}_LIBRARY_DEBUG OR Poco_${component}_LIBRARY) - set(Poco_${component}_FOUND TRUE) - elseif(NOT Poco_FIND_QUIETLY) - message(WARNING "Could not find Poco component ${component}!") - endif() - - # message(STATUS "Poco component ${component}: Poco_${component}_LIBRARY : Poco_${component}_INCLUDE_DIR") -endforeach() - -if(Poco_DataODBC_LIBRARY) - list(APPEND Poco_DataODBC_LIBRARY ${ODBC_LIBRARIES} ${LTDL_LIBRARY}) - list(APPEND Poco_INCLUDE_DIRS ${ODBC_INCLUDE_DIRS}) -endif() - -if(Poco_SQLODBC_LIBRARY) - list(APPEND Poco_SQLODBC_LIBRARY ${ODBC_LIBRARIES} ${LTDL_LIBRARY}) - list(APPEND Poco_INCLUDE_DIRS ${ODBC_INCLUDE_DIRS}) -endif() - -if(Poco_NetSSL_LIBRARY) - list(APPEND Poco_NetSSL_LIBRARY ${OPENSSL_LIBRARIES}) - list(APPEND Poco_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) -endif() - -if(DEFINED Poco_LIBRARIES) - set(Poco_FOUND true) -endif() - -if(${Poco_OSP_FOUND}) - # find the osp bundle program - find_program( - Poco_OSP_Bundle_EXECUTABLE - NAMES bundle - HINTS - ${Poco_RUNTIME_LIBRARY_DIRS} - ${Poco_ROOT_DIR} - PATH_SUFFIXES - bin - OSP/BundleCreator/bin/Darwin/x86_64 - OSP/BundleCreator/bin/Darwin/i386 - DOC "The executable that bundles OSP packages according to a .bndlspec specification." - ) - if(Poco_OSP_Bundle_EXECUTABLE) - set(Poco_OSP_Bundle_EXECUTABLE_FOUND true) - endif() - # include bundle script file - find_file(Poco_OSP_Bundles_file NAMES PocoBundles.cmake HINTS ${CMAKE_MODULE_PATH}) - if(${Poco_OSP_Bundles_file}) - include(${Poco_OSP_Bundles_file}) - endif() -endif() - -message(STATUS "Found Poco: ${Poco_LIBRARIES}") diff --git a/cmake/Modules/Findmetrohash.cmake b/cmake/Modules/Findmetrohash.cmake deleted file mode 100644 index c51665795bd..00000000000 --- a/cmake/Modules/Findmetrohash.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# - Try to find metrohash headers and libraries. -# -# Usage of this module as follows: -# -# find_package(metrohash) -# -# Variables used by this module, they can change the default behaviour and need -# to be set before calling find_package: -# -# METROHASH_ROOT_DIR Set this variable to the root installation of -# metrohash if the module has problems finding -# the proper installation path. -# -# Variables defined by this module: -# -# METROHASH_FOUND System has metrohash libs/headers -# METROHASH_LIBRARIES The metrohash library/libraries -# METROHASH_INCLUDE_DIR The location of metrohash headers - -find_path(METROHASH_ROOT_DIR - NAMES include/metrohash.h -) - -find_library(METROHASH_LIBRARIES - NAMES metrohash - PATHS ${METROHASH_ROOT_DIR}/lib ${METROHASH_LIBRARIES_PATHS} -) - -find_path(METROHASH_INCLUDE_DIR - NAMES metrohash.h - PATHS ${METROHASH_ROOT_DIR}/include PATH_SUFFIXES metrohash ${METROHASH_INCLUDE_PATHS} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(metrohash DEFAULT_MSG - METROHASH_LIBRARIES - METROHASH_INCLUDE_DIR -) - -mark_as_advanced( - METROHASH_ROOT_DIR - METROHASH_LIBRARIES - METROHASH_INCLUDE_DIR -) diff --git a/cmake/autogenerated_versions.txt b/cmake/autogenerated_versions.txt new file mode 100644 index 00000000000..72959d3c1d8 --- /dev/null +++ b/cmake/autogenerated_versions.txt @@ -0,0 +1,9 @@ +# This strings autochanged from release_lib.sh: +SET(VERSION_REVISION 54435) +SET(VERSION_MAJOR 20) +SET(VERSION_MINOR 5) +SET(VERSION_PATCH 1) +SET(VERSION_GITHASH 91df18a906dcffdbee6816e5389df6c65f86e35f) +SET(VERSION_DESCRIBE v20.5.1.1-prestable) +SET(VERSION_STRING 20.5.1.1) +# end of autochange diff --git a/cmake/find/boost.cmake b/cmake/find/boost.cmake deleted file mode 100644 index ec10a34d839..00000000000 --- a/cmake/find/boost.cmake +++ /dev/null @@ -1,52 +0,0 @@ -option (USE_INTERNAL_BOOST_LIBRARY "Set to FALSE to use system boost library instead of bundled" ${NOT_UNBUNDLED}) - -# Test random file existing in all package variants -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/boost/libs/system/src/error_code.cpp") - if(USE_INTERNAL_BOOST_LIBRARY) - message(WARNING "submodules in contrib/boost is missing. to fix try run: \n git submodule update --init --recursive") - endif() - set (USE_INTERNAL_BOOST_LIBRARY 0) - set (MISSING_INTERNAL_BOOST_LIBRARY 1) -endif () - -if (NOT USE_INTERNAL_BOOST_LIBRARY) - set (Boost_USE_STATIC_LIBS ${USE_STATIC_LIBRARIES}) - set (BOOST_ROOT "/usr/local") - find_package (Boost 1.60 COMPONENTS program_options system filesystem thread regex) - # incomplete, no include search, who use it? - if (NOT Boost_FOUND) - # # Try to find manually. - # set (BOOST_PATHS "") - # find_library (Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options PATHS ${BOOST_PATHS}) - # find_library (Boost_SYSTEM_LIBRARY boost_system PATHS ${BOOST_PATHS}) - # find_library (Boost_FILESYSTEM_LIBRARY boost_filesystem PATHS ${BOOST_PATHS}) - # maybe found but incorrect version. - set (Boost_INCLUDE_DIRS "") - set (Boost_SYSTEM_LIBRARY "") - endif () -endif () - -if (NOT Boost_SYSTEM_LIBRARY AND NOT MISSING_INTERNAL_BOOST_LIBRARY) - set (USE_INTERNAL_BOOST_LIBRARY 1) - set (Boost_SYSTEM_LIBRARY boost_system_internal) - set (Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options_internal) - set (Boost_FILESYSTEM_LIBRARY boost_filesystem_internal ${Boost_SYSTEM_LIBRARY}) - set (Boost_IOSTREAMS_LIBRARY boost_iostreams_internal) - set (Boost_REGEX_LIBRARY boost_regex_internal) - - set (Boost_INCLUDE_DIRS) - - set (BOOST_ROOT "${ClickHouse_SOURCE_DIR}/contrib/boost") - - # For boost from github: - file (GLOB Boost_INCLUDE_DIRS_ "${ClickHouse_SOURCE_DIR}/contrib/boost/libs/*/include") - list (APPEND Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS_}) - # numeric has additional level - file (GLOB Boost_INCLUDE_DIRS_ "${ClickHouse_SOURCE_DIR}/contrib/boost/libs/numeric/*/include") - list (APPEND Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS_}) - - # For packaged version: - list (APPEND Boost_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/boost") -endif () - -message (STATUS "Using Boost: ${Boost_INCLUDE_DIRS} : ${Boost_PROGRAM_OPTIONS_LIBRARY},${Boost_SYSTEM_LIBRARY},${Boost_FILESYSTEM_LIBRARY},${Boost_IOSTREAMS_LIBRARY},${Boost_REGEX_LIBRARY}") diff --git a/cmake/find/cassandra.cmake b/cmake/find/cassandra.cmake new file mode 100644 index 00000000000..f41e0f645f4 --- /dev/null +++ b/cmake/find/cassandra.cmake @@ -0,0 +1,26 @@ +option(ENABLE_CASSANDRA "Enable Cassandra" ${ENABLE_LIBRARIES}) + +if (ENABLE_CASSANDRA) + if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/libuv") + message (ERROR "submodule contrib/libuv is missing. to fix try run: \n git submodule update --init --recursive") + elseif (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/cassandra") + message (ERROR "submodule contrib/cassandra is missing. to fix try run: \n git submodule update --init --recursive") + else() + set (LIBUV_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/libuv") + set (CASSANDRA_INCLUDE_DIR + "${ClickHouse_SOURCE_DIR}/contrib/cassandra/include/") + if (USE_STATIC_LIBRARIES) + set (LIBUV_LIBRARY uv_a) + set (CASSANDRA_LIBRARY cassandra_static) + else() + set (LIBUV_LIBRARY uv) + set (CASSANDRA_LIBRARY cassandra) + endif() + set (USE_CASSANDRA 1) + set (CASS_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/cassandra") + + endif() +endif() + +message (STATUS "Using cassandra=${USE_CASSANDRA}: ${CASSANDRA_INCLUDE_DIR} : ${CASSANDRA_LIBRARY}") +message (STATUS "Using libuv: ${LIBUV_ROOT_DIR} : ${LIBUV_LIBRARY}") diff --git a/cmake/find/cpuid.cmake b/cmake/find/cpuid.cmake deleted file mode 100644 index 552cf3fb3d9..00000000000 --- a/cmake/find/cpuid.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# ARM: Cannot cpuid_get_raw_data: CPUID instruction is not supported -if (NOT ARCH_ARM) - option (USE_INTERNAL_CPUID_LIBRARY "Set to FALSE to use system cpuid library instead of bundled" ${NOT_UNBUNDLED}) -endif () - -if (USE_INTERNAL_CPUID_LIBRARY AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/libcpuid/CMakeLists.txt") - message (WARNING "submodule contrib/libcpuid is missing. to fix try run: \n git submodule update --init --recursive") - set (USE_INTERNAL_CPUID_LIBRARY 0) - set (MISSING_INTERNAL_CPUID_LIBRARY 1) -endif () - -if (NOT USE_INTERNAL_CPUID_LIBRARY) - find_library (CPUID_LIBRARY cpuid) - find_path (CPUID_INCLUDE_DIR NAMES libcpuid/libcpuid.h PATHS ${CPUID_INCLUDE_PATHS}) -endif () - -if (CPUID_LIBRARY AND CPUID_INCLUDE_DIR) - if (OS_FREEBSD) - # need in /usr/local/include/libcpuid/libcpuid_types.h - # Freebsd: /usr/local/include/libcpuid/libcpuid_types.h:61:29: error: conflicting declaration 'typedef long long int int64_t' - add_definitions(-DHAVE_STDINT_H) - # TODO: make virtual target cpuid:cpuid with COMPILE_DEFINITIONS property - endif () - set (USE_CPUID 1) -elseif (NOT ARCH_ARM AND NOT MISSING_INTERNAL_CPUID_LIBRARY) - set (CPUID_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libcpuid/include) - set (USE_INTERNAL_CPUID_LIBRARY 1) - set (CPUID_LIBRARY cpuid) - set (USE_CPUID 1) -endif () - -message (STATUS "Using cpuid=${USE_CPUID}: ${CPUID_INCLUDE_DIR} : ${CPUID_LIBRARY}") diff --git a/cmake/find/cpuinfo.cmake b/cmake/find/cpuinfo.cmake deleted file mode 100644 index 9553372109b..00000000000 --- a/cmake/find/cpuinfo.cmake +++ /dev/null @@ -1,24 +0,0 @@ -option(USE_INTERNAL_CPUINFO_LIBRARY "Set to FALSE to use system cpuinfo library instead of bundled" ${NOT_UNBUNDLED}) - -# Now we have no contrib/libcpuinfo, use from system. -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/libcpuinfo/include") - #message (WARNING "submodule contrib/libcpuinfo is missing. to fix try run: \n git submodule update --init --recursive") - set (USE_INTERNAL_CPUINFO_LIBRARY 0) - set (MISSING_INTERNAL_CPUINFO_LIBRARY 1) -endif () - -if(NOT USE_INTERNAL_CPUINFO_LIBRARY) - find_library(CPUINFO_LIBRARY cpuinfo) - find_path(CPUINFO_INCLUDE_DIR NAMES cpuinfo.h PATHS ${CPUINFO_INCLUDE_PATHS}) -endif() - -if(CPUINFO_LIBRARY AND CPUINFO_INCLUDE_DIR) - set(USE_CPUINFO 1) -elseif(NOT MISSING_INTERNAL_CPUINFO_LIBRARY) - set(CPUINFO_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libcpuinfo/include) - set(USE_INTERNAL_CPUINFO_LIBRARY 1) - set(CPUINFO_LIBRARY cpuinfo) - set(USE_CPUINFO 1) -endif() - -message(STATUS "Using cpuinfo=${USE_CPUINFO}: ${CPUINFO_INCLUDE_DIR} : ${CPUINFO_LIBRARY}") diff --git a/cmake/find/grpc.cmake b/cmake/find/grpc.cmake index e19cac5cf5f..0019dbd5eed 100644 --- a/cmake/find/grpc.cmake +++ b/cmake/find/grpc.cmake @@ -1,57 +1,26 @@ -set(_PROTOBUF_PROTOC $) -set(_GRPC_CPP_PLUGIN_EXECUTABLE $) +option (ENABLE_GRPC "Use gRPC" ${ENABLE_LIBRARIES}) -function(PROTOBUF_GENERATE_GRPC_CPP SRCS HDRS) - if(NOT ARGN) - message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files") - return() - endif() +if (ENABLE_GRPC) + option (USE_INTERNAL_GRPC_LIBRARY "Set to FALSE to use system gRPC library instead of bundled" ${NOT_UNBUNDLED}) - if(PROTOBUF_GENERATE_CPP_APPEND_PATH) - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(ABS_PATH ${ABS_FIL} PATH) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - else() - set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) - endif() + if (USE_INTERNAL_GRPC_LIBRARY) + if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/grpc/include/grpc++/grpc++.h") + message(WARNING "submodule contrib/grpc is missing. To fix try run: \n git submodule update --init --recursive") + set (USE_INTERNAL_GRPC_LIBRARY OFF) + elif (NOT USE_PROTOBUF) + message(WARNING "gRPC requires protobuf which is disabled") + set (USE_INTERNAL_GRPC_LIBRARY OFF) + else() + set (GRPC_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/grpc/include") + set (GRPC_LIBRARY "libgrpc++") + set (USE_GRPC ON) + endif() + else() + find_package(grpc) + if (GRPC_INCLUDE_DIR AND GRPC_LIBRARY) + set (USE_GRPC ON) + endif() + endif() +endif() - if(DEFINED PROTOBUF_IMPORT_DIRS) - foreach(DIR ${Protobuf_IMPORT_DIRS}) - get_filename_component(ABS_PATH ${DIR} ABSOLUTE) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - endif() - - set(${SRCS}) - set(${HDRS}) - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - - list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.cc") - list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.h") - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.h" - COMMAND ${_PROTOBUF_PROTOC} - ARGS --grpc_out=${CMAKE_CURRENT_BINARY_DIR} - --plugin=protoc-gen-grpc=${_GRPC_CPP_PLUGIN_EXECUTABLE} - ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} - COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}" - VERBATIM) - endforeach() - - set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) - set(${SRCS} ${${SRCS}} PARENT_SCOPE) - set(${HDRS} ${${HDRS}} PARENT_SCOPE) -endfunction() +message(STATUS "Using gRPC=${USE_GRPC}: ${GRPC_INCLUDE_DIR} : ${GRPC_LIBRARY}") diff --git a/cmake/find/hyperscan.cmake b/cmake/find/hyperscan.cmake deleted file mode 100644 index 039981fce81..00000000000 --- a/cmake/find/hyperscan.cmake +++ /dev/null @@ -1,33 +0,0 @@ -if (HAVE_SSSE3) - option (ENABLE_HYPERSCAN "Enable hyperscan" ${ENABLE_LIBRARIES}) -endif () - -if (ENABLE_HYPERSCAN) - -option (USE_INTERNAL_HYPERSCAN_LIBRARY "Set to FALSE to use system hyperscan instead of the bundled" ${NOT_UNBUNDLED}) - -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/hyperscan/CMakeLists.txt") - if (USE_INTERNAL_HYPERSCAN_LIBRARY) - message (WARNING "submodule contrib/hyperscan is missing. to fix try run: \n git submodule update --init --recursive") - endif () - set (MISSING_INTERNAL_HYPERSCAN_LIBRARY 1) - set (USE_INTERNAL_HYPERSCAN_LIBRARY 0) -endif () - -if (NOT USE_INTERNAL_HYPERSCAN_LIBRARY) - find_library (HYPERSCAN_LIBRARY hs) - find_path (HYPERSCAN_INCLUDE_DIR NAMES hs/hs.h hs.h PATHS ${HYPERSCAN_INCLUDE_PATHS}) -endif () - -if (HYPERSCAN_LIBRARY AND HYPERSCAN_INCLUDE_DIR) - set (USE_HYPERSCAN 1) -elseif (NOT MISSING_INTERNAL_HYPERSCAN_LIBRARY) - set (HYPERSCAN_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/hyperscan/src) - set (HYPERSCAN_LIBRARY hs) - set (USE_HYPERSCAN 1) - set (USE_INTERNAL_HYPERSCAN_LIBRARY 1) -endif() - -message (STATUS "Using hyperscan=${USE_HYPERSCAN}: ${HYPERSCAN_INCLUDE_DIR} : ${HYPERSCAN_LIBRARY}") - -endif () diff --git a/cmake/find/ldap.cmake b/cmake/find/ldap.cmake new file mode 100644 index 00000000000..230727819e4 --- /dev/null +++ b/cmake/find/ldap.cmake @@ -0,0 +1,76 @@ +option (ENABLE_LDAP "Enable LDAP" ${ENABLE_LIBRARIES}) + +if (ENABLE_LDAP) + option (USE_INTERNAL_LDAP_LIBRARY "Set to FALSE to use system *LDAP library instead of bundled" ${NOT_UNBUNDLED}) + + if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/openldap/README") + if (USE_INTERNAL_LDAP_LIBRARY) + message (WARNING "Submodule contrib/openldap is missing. To fix try running:\n git submodule update --init --recursive") + endif () + + set (USE_INTERNAL_LDAP_LIBRARY 0) + set (MISSING_INTERNAL_LDAP_LIBRARY 1) + endif () + + set (OPENLDAP_USE_STATIC_LIBS ${USE_STATIC_LIBRARIES}) + set (OPENLDAP_USE_REENTRANT_LIBS 1) + + if (NOT USE_INTERNAL_LDAP_LIBRARY) + if (APPLE AND NOT OPENLDAP_ROOT_DIR) + set (OPENLDAP_ROOT_DIR "/usr/local/opt/openldap") + endif () + + find_package (OpenLDAP) + endif () + + if (NOT OPENLDAP_FOUND AND NOT MISSING_INTERNAL_LDAP_LIBRARY) + string (TOLOWER "${CMAKE_SYSTEM_NAME}" _system_name) + string (TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _system_processor) + + if ( + "${_system_processor}" STREQUAL "amd64" OR + "${_system_processor}" STREQUAL "x64" + ) + set (_system_processor "x86_64") + elseif ( + "${_system_processor}" STREQUAL "arm64" + ) + set (_system_processor "aarch64") + endif () + + if ( + ( "${_system_name}" STREQUAL "linux" AND "${_system_processor}" STREQUAL "x86_64" ) OR + ( "${_system_name}" STREQUAL "linux" AND "${_system_processor}" STREQUAL "aarch64" ) OR + ( "${_system_name}" STREQUAL "freebsd" AND "${_system_processor}" STREQUAL "x86_64" ) OR + ( "${_system_name}" STREQUAL "darwin" AND "${_system_processor}" STREQUAL "x86_64" ) + ) + set (_ldap_supported_platform TRUE) + endif () + + if (NOT _ldap_supported_platform) + message (WARNING "LDAP support using the bundled library is not implemented for ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR} platform.") + elseif (NOT USE_SSL) + message (WARNING "LDAP support using the bundled library is not possible if SSL is not used.") + else () + set (USE_INTERNAL_LDAP_LIBRARY 1) + set (OPENLDAP_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/openldap") + set (OPENLDAP_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/openldap/include") + # Below, 'ldap'/'ldap_r' and 'lber' will be resolved to + # the targets defined in contrib/openldap-cmake/CMakeLists.txt + if (OPENLDAP_USE_REENTRANT_LIBS) + set (OPENLDAP_LDAP_LIBRARY "ldap_r") + else () + set (OPENLDAP_LDAP_LIBRARY "ldap") + endif() + set (OPENLDAP_LBER_LIBRARY "lber") + set (OPENLDAP_LIBRARIES ${OPENLDAP_LDAP_LIBRARY} ${OPENLDAP_LBER_LIBRARY}) + set (OPENLDAP_FOUND 1) + endif () + endif () + + if (OPENLDAP_FOUND) + set (USE_LDAP 1) + endif () +endif () + +message (STATUS "Using ldap=${USE_LDAP}: ${OPENLDAP_INCLUDE_DIR} : ${OPENLDAP_LIBRARIES}") diff --git a/cmake/find/lz4.cmake b/cmake/find/lz4.cmake deleted file mode 100644 index 5f5e058b53d..00000000000 --- a/cmake/find/lz4.cmake +++ /dev/null @@ -1,23 +0,0 @@ -option (USE_INTERNAL_LZ4_LIBRARY "Set to FALSE to use system lz4 library instead of bundled" ${NOT_UNBUNDLED}) - -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/lz4/lib/lz4.h") - if (USE_INTERNAL_LZ4_LIBRARY) - message (WARNING "submodule contrib/lz4 is missing. to fix try run: \n git submodule update --init --recursive") - set (USE_INTERNAL_LZ4_LIBRARY 0) - endif () - set (MISSING_INTERNAL_LZ4_LIBRARY 1) -endif () - -if (NOT USE_INTERNAL_LZ4_LIBRARY) - find_library (LZ4_LIBRARY lz4) - find_path (LZ4_INCLUDE_DIR NAMES lz4.h PATHS ${LZ4_INCLUDE_PATHS}) -endif () - -if (LZ4_LIBRARY AND LZ4_INCLUDE_DIR) -elseif (NOT MISSING_INTERNAL_LZ4_LIBRARY) - set (LZ4_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4/lib) - set (USE_INTERNAL_LZ4_LIBRARY 1) - set (LZ4_LIBRARY lz4) -endif () - -message (STATUS "Using lz4: ${LZ4_INCLUDE_DIR} : ${LZ4_LIBRARY}") diff --git a/cmake/find/odbc.cmake b/cmake/find/odbc.cmake deleted file mode 100644 index 65e09d5c96d..00000000000 --- a/cmake/find/odbc.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# This file copied from contrib/poco/cmake/FindODBC.cmake to allow build without submodules - -if(OS_LINUX) - option (ENABLE_ODBC "Enable ODBC" ${ENABLE_LIBRARIES}) -endif() - -if(ENABLE_ODBC) - if (OS_LINUX) - option(USE_INTERNAL_ODBC_LIBRARY "Set to FALSE to use system odbc library instead of bundled" ${NOT_UNBUNDLED}) - else () - option(USE_INTERNAL_ODBC_LIBRARY "Set to FALSE to use system odbc library instead of bundled" OFF) - endif() - - if(USE_INTERNAL_ODBC_LIBRARY AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/unixodbc/README") - message(WARNING "submodule contrib/unixodbc is missing. to fix try run: \n git submodule update --init --recursive") - set(USE_INTERNAL_ODBC_LIBRARY 0) - set(MISSING_INTERNAL_ODBC_LIBRARY 1) - endif() - - set(ODBC_INCLUDE_DIRS ) # Include directories will be either used automatically by target_include_directories or set later. - if(USE_INTERNAL_ODBC_LIBRARY AND NOT MISSING_INTERNAL_ODBC_LIBRARY) - set(ODBC_LIBRARY unixodbc) - set(ODBC_LIBRARIES ${ODBC_LIBRARY}) - set(ODBC_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/unixodbc/include") - set(ODBC_FOUND 1) - else() - find_package(ODBC) - endif () - - if(ODBC_FOUND) - set(USE_ODBC 1) - set(ODBC_INCLUDE_DIRECTORIES ${ODBC_INCLUDE_DIRS}) # for old poco - set(ODBC_INCLUDE_DIR ${ODBC_INCLUDE_DIRS}) # for old poco - endif() - - message(STATUS "Using odbc=${USE_ODBC}: ${ODBC_INCLUDE_DIRS} : ${ODBC_LIBRARIES}") -endif() diff --git a/cmake/find/opencl.cmake b/cmake/find/opencl.cmake new file mode 100644 index 00000000000..0f307350cb8 --- /dev/null +++ b/cmake/find/opencl.cmake @@ -0,0 +1,23 @@ +# TODO: enable by default +if(0) + option(ENABLE_OPENCL "Enable OpenCL support" ${ENABLE_LIBRARIES}) +endif() + +if(ENABLE_OPENCL) + +# Intel OpenCl driver: sudo apt install intel-opencl-icd +# @sa https://github.com/intel/compute-runtime/releases + +# OpenCL applications should link wiht ICD loader +# sudo apt install opencl-headers ocl-icd-libopencl1 +# sudo ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /usr/lib/libOpenCL.so +# TODO: add https://github.com/OCL-dev/ocl-icd as submodule instead + +find_package(OpenCL) +if(OpenCL_FOUND) + set(USE_OPENCL 1) +endif() + +endif() + +message(STATUS "Using opencl=${USE_OPENCL}: ${OpenCL_INCLUDE_DIRS} : ${OpenCL_LIBRARIES}") diff --git a/cmake/find/parquet.cmake b/cmake/find/parquet.cmake index c57aa9c9212..d4f62b87d29 100644 --- a/cmake/find/parquet.cmake +++ b/cmake/find/parquet.cmake @@ -63,13 +63,14 @@ elseif(NOT MISSING_INTERNAL_PARQUET_LIBRARY AND NOT OS_FREEBSD) set(ARROW_LIBRARY arrow_shared) set(PARQUET_LIBRARY parquet_shared) if(USE_INTERNAL_PARQUET_LIBRARY_NATIVE_CMAKE) - list(APPEND PARQUET_LIBRARY ${Boost_REGEX_LIBRARY}) + list(APPEND PARQUET_LIBRARY boost::regex) endif() set(THRIFT_LIBRARY thrift) endif() set(USE_PARQUET 1) set(USE_ORC 1) + set(USE_ARROW 1) endif() endif() diff --git a/cmake/find/poco.cmake b/cmake/find/poco.cmake deleted file mode 100644 index 0c676d374f1..00000000000 --- a/cmake/find/poco.cmake +++ /dev/null @@ -1,178 +0,0 @@ -option (USE_INTERNAL_POCO_LIBRARY "Set to FALSE to use system poco library instead of bundled" ${NOT_UNBUNDLED}) - -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/poco/CMakeLists.txt") - if (USE_INTERNAL_POCO_LIBRARY) - message (WARNING "submodule contrib/poco is missing. to fix try run: \n git submodule update --init --recursive") - endif () - set (USE_INTERNAL_POCO_LIBRARY 0) - set (MISSING_INTERNAL_POCO_LIBRARY 1) -endif () - -if (NOT ENABLE_LIBRARIES) - set (ENABLE_POCO_NETSSL ${ENABLE_LIBRARIES} CACHE BOOL "") - set (ENABLE_POCO_MONGODB ${ENABLE_LIBRARIES} CACHE BOOL "") - set (ENABLE_POCO_REDIS ${ENABLE_LIBRARIES} CACHE BOOL "") - set (ENABLE_POCO_ODBC ${ENABLE_LIBRARIES} CACHE BOOL "") - set (ENABLE_POCO_SQL ${ENABLE_LIBRARIES} CACHE BOOL "") - set (ENABLE_POCO_JSON ${ENABLE_LIBRARIES} CACHE BOOL "") -endif () - -set (POCO_COMPONENTS Net XML SQL Data) -if (NOT DEFINED ENABLE_POCO_NETSSL OR ENABLE_POCO_NETSSL) - list (APPEND POCO_COMPONENTS Crypto NetSSL) -endif () -if (NOT DEFINED ENABLE_POCO_MONGODB OR ENABLE_POCO_MONGODB) - set(ENABLE_POCO_MONGODB 1 CACHE BOOL "") - list (APPEND POCO_COMPONENTS MongoDB) -else () - set(ENABLE_POCO_MONGODB 0 CACHE BOOL "") -endif () -if (NOT DEFINED ENABLE_POCO_REDIS OR ENABLE_POCO_REDIS) - list (APPEND POCO_COMPONENTS Redis) -endif () -# TODO: after new poco release with SQL library rename ENABLE_POCO_ODBC -> ENABLE_POCO_SQLODBC -if (NOT DEFINED ENABLE_POCO_ODBC OR ENABLE_POCO_ODBC) - list (APPEND POCO_COMPONENTS DataODBC) - list (APPEND POCO_COMPONENTS SQLODBC) -endif () -if (NOT DEFINED ENABLE_POCO_JSON OR ENABLE_POCO_JSON) - list (APPEND POCO_COMPONENTS JSON) -endif () - -if (NOT USE_INTERNAL_POCO_LIBRARY) - find_package (Poco COMPONENTS ${POCO_COMPONENTS}) -endif () - -if (Poco_INCLUDE_DIRS AND Poco_Foundation_LIBRARY) -elseif (NOT MISSING_INTERNAL_POCO_LIBRARY) - set (USE_INTERNAL_POCO_LIBRARY 1) - - set (ENABLE_ZIP 0 CACHE BOOL "") - set (ENABLE_PAGECOMPILER 0 CACHE BOOL "") - set (ENABLE_PAGECOMPILER_FILE2PAGE 0 CACHE BOOL "") - set (ENABLE_DATA_SQLITE 0 CACHE BOOL "") - set (ENABLE_DATA_MYSQL 0 CACHE BOOL "") - set (ENABLE_DATA_POSTGRESQL 0 CACHE BOOL "") - set (ENABLE_ENCODINGS 0 CACHE BOOL "") - set (ENABLE_MONGODB ${ENABLE_POCO_MONGODB} CACHE BOOL "" FORCE) - - # new after 2.0.0: - set (POCO_ENABLE_ZIP 0 CACHE BOOL "") - set (POCO_ENABLE_PAGECOMPILER 0 CACHE BOOL "") - set (POCO_ENABLE_PAGECOMPILER_FILE2PAGE 0 CACHE BOOL "") - set (POCO_ENABLE_SQL_SQLITE 0 CACHE BOOL "") - set (POCO_ENABLE_SQL_MYSQL 0 CACHE BOOL "") - set (POCO_ENABLE_SQL_POSTGRESQL 0 CACHE BOOL "") - - set (POCO_UNBUNDLED 1 CACHE BOOL "") - set (POCO_UNBUNDLED_PCRE 0 CACHE BOOL "") - set (POCO_UNBUNDLED_EXPAT 0 CACHE BOOL "") - set (POCO_STATIC ${MAKE_STATIC_LIBRARIES} CACHE BOOL "") - set (POCO_VERBOSE_MESSAGES 1 CACHE BOOL "") - - - # used in internal compiler - list (APPEND Poco_INCLUDE_DIRS - "${ClickHouse_SOURCE_DIR}/contrib/poco/Foundation/include/" - "${ClickHouse_SOURCE_DIR}/contrib/poco/Util/include/" - ) - - if (ENABLE_POCO_MONGODB) - set (Poco_MongoDB_LIBRARY PocoMongoDB) - set (Poco_MongoDB_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/poco/MongoDB/include/") - endif () - - if (NOT DEFINED ENABLE_POCO_REDIS OR ENABLE_POCO_REDIS) - set (Poco_Redis_LIBRARY PocoRedis) - set (Poco_Redis_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/poco/Redis/include/") - endif () - - if (EXISTS "${ClickHouse_SOURCE_DIR}/contrib/poco/SQL/ODBC/include/") - set (Poco_SQL_FOUND 1) - set (Poco_SQL_LIBRARY PocoSQL) - set (Poco_SQL_INCLUDE_DIR - "${ClickHouse_SOURCE_DIR}/contrib/poco/SQL/include" - "${ClickHouse_SOURCE_DIR}/contrib/poco/Data/include" - ) - if ((NOT DEFINED POCO_ENABLE_SQL_ODBC OR POCO_ENABLE_SQL_ODBC) AND ODBC_FOUND) - set (Poco_SQLODBC_INCLUDE_DIR - "${ClickHouse_SOURCE_DIR}/contrib/poco/SQL/ODBC/include/" - "${ClickHouse_SOURCE_DIR}/contrib/poco/Data/ODBC/include/" - ${ODBC_INCLUDE_DIRS} - ) - set (Poco_SQLODBC_LIBRARY PocoSQLODBC ${ODBC_LIBRARIES} ${LTDL_LIBRARY}) - endif () - else () - set (Poco_Data_FOUND 1) - set (Poco_Data_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/poco/Data/include") - set (Poco_Data_LIBRARY PocoData) - if ((NOT DEFINED ENABLE_DATA_ODBC OR ENABLE_DATA_ODBC) AND ODBC_FOUND) - set (USE_POCO_DATAODBC 1) - set (Poco_DataODBC_INCLUDE_DIR - "${ClickHouse_SOURCE_DIR}/contrib/poco/Data/ODBC/include/" - ${ODBC_INCLUDE_DIRS} - ) - set (Poco_DataODBC_LIBRARY PocoDataODBC ${ODBC_LIBRARIES} ${LTDL_LIBRARY}) - endif () - endif () - - if (NOT DEFINED ENABLE_POCO_JSON OR ENABLE_POCO_JSON) - set (Poco_JSON_LIBRARY PocoJSON) - set (Poco_JSON_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/poco/JSON/include/") - endif () - - if (OPENSSL_FOUND AND (NOT DEFINED ENABLE_POCO_NETSSL OR ENABLE_POCO_NETSSL)) - set (Poco_NetSSL_LIBRARY PocoNetSSL ${OPENSSL_LIBRARIES}) - set (Poco_Crypto_LIBRARY PocoCrypto ${OPENSSL_LIBRARIES}) - endif () - - if (USE_STATIC_LIBRARIES AND USE_INTERNAL_ZLIB_LIBRARY) - list (APPEND Poco_INCLUDE_DIRS - "${ClickHouse_SOURCE_DIR}/contrib/${INTERNAL_ZLIB_NAME}/" - "${ClickHouse_BINARY_DIR}/contrib/${INTERNAL_ZLIB_NAME}/" - ) - endif () - - set (Poco_Foundation_LIBRARY PocoFoundation) - set (Poco_Util_LIBRARY PocoUtil) - set (Poco_Net_LIBRARY PocoNet) - set (Poco_XML_LIBRARY PocoXML) -endif () - -if (Poco_NetSSL_LIBRARY AND Poco_Crypto_LIBRARY) - set (USE_POCO_NETSSL 1) -endif () -if (Poco_MongoDB_LIBRARY) - set (USE_POCO_MONGODB 1) -endif () -if (Poco_Redis_LIBRARY) - set (USE_POCO_REDIS 1) -endif () -if (Poco_DataODBC_LIBRARY AND ODBC_FOUND) - set (USE_POCO_DATAODBC 1) -endif () -if (Poco_SQLODBC_LIBRARY AND ODBC_FOUND) - set (USE_POCO_SQLODBC 1) -endif () -if (Poco_JSON_LIBRARY) - set (USE_POCO_JSON 1) -endif () - -message(STATUS "Using Poco: ${Poco_INCLUDE_DIRS} : ${Poco_Foundation_LIBRARY},${Poco_Util_LIBRARY},${Poco_Net_LIBRARY},${Poco_NetSSL_LIBRARY},${Poco_Crypto_LIBRARY},${Poco_XML_LIBRARY},${Poco_Data_LIBRARY},${Poco_DataODBC_LIBRARY},${Poco_SQL_LIBRARY},${Poco_SQLODBC_LIBRARY},${Poco_MongoDB_LIBRARY},${Poco_Redis_LIBRARY},${Poco_JSON_LIBRARY}; MongoDB=${USE_POCO_MONGODB}, Redis=${USE_POCO_REDIS}, DataODBC=${USE_POCO_DATAODBC}, NetSSL=${USE_POCO_NETSSL}, JSON=${USE_POCO_JSON}") - -# How to make sutable poco: -# use branch: -# develop OR poco-1.7.9-release + 6a49c94d18c654d7a20b8c8ea47071b1fdd4813b -# and merge: -# ClickHouse-Extras/clickhouse_unbundled -# ClickHouse-Extras/clickhouse_unbundled_zlib -# ClickHouse-Extras/clickhouse_task -# ClickHouse-Extras/clickhouse_misc -# ClickHouse-Extras/clickhouse_anl -# ClickHouse-Extras/clickhouse_http_header https://github.com/pocoproject/poco/pull/1574 -# ClickHouse-Extras/clickhouse_socket -# ClickHouse-Extras/clickhouse_warning -# ClickHouse-Extras/clickhouse-purge-logs-on-no-space -# ClickHouse-Extras/clickhouse_freebsd -# ClickHouse-Extras/clikhouse_no_zlib -# ClickHouse-Extras/clickhouse-fix-atomic diff --git a/cmake/find/protobuf.cmake b/cmake/find/protobuf.cmake index e3330a32e7c..51110d3b6a3 100644 --- a/cmake/find/protobuf.cmake +++ b/cmake/find/protobuf.cmake @@ -27,69 +27,7 @@ elseif(NOT MISSING_INTERNAL_PROTOBUF_LIBRARY) set(Protobuf_PROTOC_LIBRARY libprotoc) set(Protobuf_LITE_LIBRARY libprotobuf-lite) - set(Protobuf_PROTOC_EXECUTABLE ${ClickHouse_BINARY_DIR}/contrib/protobuf/cmake/protoc) - - if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH) - set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE) - endif() - - function(PROTOBUF_GENERATE_CPP SRCS HDRS) - if(NOT ARGN) - message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files") - return() - endif() - - if(PROTOBUF_GENERATE_CPP_APPEND_PATH) - # Create an include path for each file specified - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(ABS_PATH ${ABS_FIL} PATH) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - else() - set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) - endif() - - if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS) - set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}") - endif() - - if(DEFINED Protobuf_IMPORT_DIRS) - foreach(DIR ${Protobuf_IMPORT_DIRS}) - get_filename_component(ABS_PATH ${DIR} ABSOLUTE) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - endif() - - set(${SRCS}) - set(${HDRS}) - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - - list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") - list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} - ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} - COMMENT "Running C++ protocol buffer compiler on ${FIL}" - VERBATIM ) - endforeach() - - set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) - set(${SRCS} ${${SRCS}} PARENT_SCOPE) - set(${HDRS} ${${HDRS}} PARENT_SCOPE) - endfunction() + set(Protobuf_PROTOC_EXECUTABLE "$") endif() if(OS_FREEBSD AND SANITIZE STREQUAL "address") @@ -102,6 +40,7 @@ if(OS_FREEBSD AND SANITIZE STREQUAL "address") endif() endif() +include (${ClickHouse_SOURCE_DIR}/cmake/protobuf_generate_cpp.cmake) endif() message(STATUS "Using protobuf=${USE_PROTOBUF}: ${Protobuf_INCLUDE_DIR} : ${Protobuf_LIBRARY} : ${Protobuf_PROTOC_EXECUTABLE}") diff --git a/cmake/find/xxhash.cmake b/cmake/find/xxhash.cmake deleted file mode 100644 index 8af871e8fd5..00000000000 --- a/cmake/find/xxhash.cmake +++ /dev/null @@ -1,22 +0,0 @@ -option (USE_INTERNAL_XXHASH_LIBRARY "Set to FALSE to use system xxHash library instead of bundled" ${NOT_UNBUNDLED}) - -if (USE_INTERNAL_XXHASH_LIBRARY AND NOT USE_INTERNAL_LZ4_LIBRARY) - message (WARNING "can not use internal xxhash without internal lz4") - set (USE_INTERNAL_XXHASH_LIBRARY 0) -endif () - -if (USE_INTERNAL_XXHASH_LIBRARY) - set (XXHASH_LIBRARY lz4) - set (XXHASH_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4/lib) -else () - find_library (XXHASH_LIBRARY xxhash) - find_path (XXHASH_INCLUDE_DIR NAMES xxhash.h PATHS ${XXHASH_INCLUDE_PATHS}) -endif () - -if (XXHASH_LIBRARY AND XXHASH_INCLUDE_DIR) - set (USE_XXHASH 1) -else () - set (USE_XXHASH 0) -endif () - -message (STATUS "Using xxhash=${USE_XXHASH}: ${XXHASH_INCLUDE_DIR} : ${XXHASH_LIBRARY}") diff --git a/cmake/freebsd/toolchain-x86_64.cmake b/cmake/freebsd/toolchain-x86_64.cmake index 30468731b69..d9839ec74ee 100644 --- a/cmake/freebsd/toolchain-x86_64.cmake +++ b/cmake/freebsd/toolchain-x86_64.cmake @@ -1,12 +1,15 @@ set (CMAKE_SYSTEM_NAME "FreeBSD") set (CMAKE_SYSTEM_PROCESSOR "x86_64") -set (CMAKE_C_COMPILER_TARGET "x86_64-pc-freebsd12.1") -set (CMAKE_CXX_COMPILER_TARGET "x86_64-pc-freebsd12.1") -set (CMAKE_ASM_COMPILER_TARGET "x86_64-pc-freebsd12.1") +set (CMAKE_C_COMPILER_TARGET "x86_64-pc-freebsd11") +set (CMAKE_CXX_COMPILER_TARGET "x86_64-pc-freebsd11") +set (CMAKE_ASM_COMPILER_TARGET "x86_64-pc-freebsd11") set (CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/../toolchain/freebsd-x86_64") set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) # disable linkage check - it doesn't work in CMake +set (CMAKE_AR "/usr/bin/ar" CACHE FILEPATH "" FORCE) +set (CMAKE_RANLIB "/usr/bin/ranlib" CACHE FILEPATH "" FORCE) + set (LINKER_NAME "lld" CACHE STRING "" FORCE) set (CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld") diff --git a/cmake/lib_name.cmake b/cmake/lib_name.cmake deleted file mode 100644 index f18b2e52576..00000000000 --- a/cmake/lib_name.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(DIVIDE_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libdivide) -set(DBMS_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/src ${ClickHouse_BINARY_DIR}/src) -set(DOUBLE_CONVERSION_CONTRIB_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/double-conversion) -set(METROHASH_CONTRIB_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libmetrohash/src) diff --git a/cmake/linux/default_libs.cmake b/cmake/linux/default_libs.cmake index d18a996e2c9..0ecdfd2a3ad 100644 --- a/cmake/linux/default_libs.cmake +++ b/cmake/linux/default_libs.cmake @@ -21,7 +21,7 @@ set(CMAKE_C_STANDARD_LIBRARIES ${DEFAULT_LIBS}) # glibc-compatibility library relies to fixed version of libc headers # (because minor changes in function attributes between different glibc versions will introduce incompatibilities) # This is for x86_64. For other architectures we have separate toolchains. -if (ARCH_AMD64) +if (ARCH_AMD64 AND NOT_UNBUNDLED) set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${ClickHouse_SOURCE_DIR}/contrib/libc-headers/x86_64-linux-gnu ${ClickHouse_SOURCE_DIR}/contrib/libc-headers) set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${ClickHouse_SOURCE_DIR}/contrib/libc-headers/x86_64-linux-gnu ${ClickHouse_SOURCE_DIR}/contrib/libc-headers) endif () diff --git a/cmake/print_include_directories.cmake b/cmake/print_include_directories.cmake index fe5e9e8e6e9..cc2098cb397 100644 --- a/cmake/print_include_directories.cmake +++ b/cmake/print_include_directories.cmake @@ -21,15 +21,6 @@ if (TARGET double-conversion) list(APPEND dirs ${dirs1}) endif () -if (TARGET ${Boost_PROGRAM_OPTIONS_LIBRARY}) - get_property (dirs1 TARGET ${Boost_PROGRAM_OPTIONS_LIBRARY} PROPERTY INCLUDE_DIRECTORIES) - list(APPEND dirs ${dirs1}) -endif () - -if (USE_INTERNAL_POCO_LIBRARY) - list(APPEND dirs "./contrib/poco/Foundation/include") -endif () - list(REMOVE_DUPLICATES dirs) file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/include_directories.txt "") foreach (dir ${dirs}) diff --git a/cmake/protobuf_generate_cpp.cmake b/cmake/protobuf_generate_cpp.cmake new file mode 100644 index 00000000000..cc2502e5eeb --- /dev/null +++ b/cmake/protobuf_generate_cpp.cmake @@ -0,0 +1,172 @@ +# This file declares functions adding custom commands for generating C++ files from *.proto files: +# function (protobuf_generate_cpp SRCS HDRS) +# function (protobuf_generate_grpc_cpp SRCS HDRS) + +if (NOT USE_PROTOBUF) + message (WARNING "Could not use protobuf_generate_cpp() without the protobuf library") + return() +endif() + +if (NOT DEFINED PROTOBUF_PROTOC_EXECUTABLE) + set (PROTOBUF_PROTOC_EXECUTABLE "$") +endif() + +if (NOT DEFINED GRPC_CPP_PLUGIN_EXECUTABLE) + set (GRPC_CPP_PLUGIN_EXECUTABLE $) +endif() + +if (NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH) + set (PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE) +endif() + + +function(protobuf_generate_cpp_impl SRCS HDRS MODES OUTPUT_FILE_EXTS PLUGIN) + if(NOT ARGN) + message(SEND_ERROR "Error: protobuf_generate_cpp() called without any proto files") + return() + endif() + + if(PROTOBUF_GENERATE_CPP_APPEND_PATH) + # Create an include path for each file specified + foreach(FIL ${ARGN}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(ABS_PATH ${ABS_FIL} PATH) + list(FIND protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + else() + set(protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + + if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS) + set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}") + endif() + + if(DEFINED Protobuf_IMPORT_DIRS) + foreach(DIR ${Protobuf_IMPORT_DIRS}) + get_filename_component(ABS_PATH ${DIR} ABSOLUTE) + list(FIND protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + endif() + + set (intermediate_dir ${CMAKE_CURRENT_BINARY_DIR}/intermediate) + file (MAKE_DIRECTORY ${intermediate_dir}) + + set (protoc_args) + foreach (mode ${MODES}) + list (APPEND protoc_args "--${mode}_out" ${intermediate_dir}) + endforeach() + if (PLUGIN) + list (APPEND protoc_args "--plugin=${PLUGIN}") + endif() + + set(srcs) + set(hdrs) + set(all_intermediate_outputs) + + foreach(input_name ${ARGN}) + get_filename_component(abs_name ${input_name} ABSOLUTE) + get_filename_component(name ${input_name} NAME_WE) + + set (intermediate_outputs) + foreach (ext ${OUTPUT_FILE_EXTS}) + set (filename "${name}${ext}") + set (output "${CMAKE_CURRENT_BINARY_DIR}/${filename}") + set (intermediate_output "${intermediate_dir}/${filename}") + list (APPEND intermediate_outputs "${intermediate_output}") + list (APPEND all_intermediate_outputs "${intermediate_output}") + + if (${ext} MATCHES ".*\\.h") + list(APPEND hdrs "${output}") + else() + list(APPEND srcs "${output}") + endif() + + add_custom_command( + OUTPUT ${output} + COMMAND ${CMAKE_COMMAND} -DPROTOBUF_GENERATE_CPP_SCRIPT_MODE=1 -DUSE_PROTOBUF=1 -DDIR=${CMAKE_CURRENT_BINARY_DIR} -DFILENAME=${filename} -DCOMPILER_ID=${CMAKE_CXX_COMPILER_ID} -P ${ClickHouse_SOURCE_DIR}/cmake/protobuf_generate_cpp.cmake + DEPENDS ${intermediate_output}) + endforeach() + + add_custom_command( + OUTPUT ${intermediate_outputs} + COMMAND ${Protobuf_PROTOC_EXECUTABLE} + ARGS ${protobuf_include_path} ${protoc_args} ${abs_name} + DEPENDS ${abs_name} ${Protobuf_PROTOC_EXECUTABLE} ${PLUGIN} + COMMENT "Running C++ protocol buffer compiler on ${name}" + VERBATIM ) + endforeach() + + set_source_files_properties(${srcs} ${hdrs} ${all_intermediate_outputs} PROPERTIES GENERATED TRUE) + set(${SRCS} ${srcs} PARENT_SCOPE) + set(${HDRS} ${hdrs} PARENT_SCOPE) +endfunction() + + +if (PROTOBUF_GENERATE_CPP_SCRIPT_MODE) + set (output "${DIR}/${FILENAME}") + set (intermediate_dir ${DIR}/intermediate) + set (intermediate_output "${intermediate_dir}/${FILENAME}") + + if (COMPILER_ID MATCHES "Clang") + set (pragma_push "#pragma clang diagnostic push\n") + set (pragma_pop "#pragma clang diagnostic pop\n") + set (pragma_disable_warnings "#pragma clang diagnostic ignored \"-Weverything\"\n") + elseif (COMPILER_ID MATCHES "GNU") + set (pragma_push "#pragma GCC diagnostic push\n") + set (pragma_pop "#pragma GCC diagnostic pop\n") + set (pragma_disable_warnings "#pragma GCC diagnostic ignored \"-Wall\"\n" + "#pragma GCC diagnostic ignored \"-Wextra\"\n" + "#pragma GCC diagnostic ignored \"-Warray-bounds\"\n" + "#pragma GCC diagnostic ignored \"-Wold-style-cast\"\n" + "#pragma GCC diagnostic ignored \"-Wshadow\"\n" + "#pragma GCC diagnostic ignored \"-Wsuggest-override\"\n" + "#pragma GCC diagnostic ignored \"-Wcast-qual\"\n" + "#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n") + endif() + + if (${FILENAME} MATCHES ".*\\.h") + file(WRITE "${output}" + "#pragma once\n" + ${pragma_push} + ${pragma_disable_warnings} + "#include \"${intermediate_output}\"\n" + ${pragma_pop} + ) + else() + file(WRITE "${output}" + ${pragma_disable_warnings} + "#include \"${intermediate_output}\"\n" + ) + endif() + return() +endif() + + +function(protobuf_generate_cpp SRCS HDRS) + set (modes cpp) + set (output_file_exts ".pb.cc" ".pb.h") + set (plugin) + + protobuf_generate_cpp_impl(srcs hdrs "${modes}" "${output_file_exts}" "${plugin}" ${ARGN}) + + set(${SRCS} ${srcs} PARENT_SCOPE) + set(${HDRS} ${hdrs} PARENT_SCOPE) +endfunction() + + +function(protobuf_generate_grpc_cpp SRCS HDRS) + set (modes cpp grpc) + set (output_file_exts ".pb.cc" ".pb.h" ".grpc.pb.cc" ".grpc.pb.h") + set (plugin "protoc-gen-grpc=${GRPC_CPP_PLUGIN_EXECUTABLE}") + + protobuf_generate_cpp_impl(srcs hdrs "${modes}" "${output_file_exts}" "${plugin}" ${ARGN}) + + set(${SRCS} ${srcs} PARENT_SCOPE) + set(${HDRS} ${hdrs} PARENT_SCOPE) +endfunction() diff --git a/cmake/sanitize.cmake b/cmake/sanitize.cmake index e9fa0a01d4a..32443ed78c3 100644 --- a/cmake/sanitize.cmake +++ b/cmake/sanitize.cmake @@ -36,8 +36,10 @@ if (SANITIZE) endif () elseif (SANITIZE STREQUAL "thread") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} -fsanitize=thread") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} -fsanitize=thread") + set (TSAN_FLAGS "-fsanitize=thread -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/tests/tsan_suppressions.txt") + + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} ${TSAN_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} ${TSAN_FLAGS}") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") endif() diff --git a/cmake/target.cmake b/cmake/target.cmake index 03d470b0aea..1325758811f 100644 --- a/cmake/target.cmake +++ b/cmake/target.cmake @@ -27,6 +27,7 @@ if (CMAKE_CROSSCOMPILING) elseif (OS_FREEBSD) # FIXME: broken dependencies set (ENABLE_PROTOBUF OFF CACHE INTERNAL "") + set (ENABLE_EMBEDDED_COMPILER OFF CACHE INTERNAL "") else () message (FATAL_ERROR "Trying to cross-compile to unsupported system: ${CMAKE_SYSTEM_NAME}!") endif () diff --git a/cmake/toolchain/freebsd-x86_64/README.txt b/cmake/toolchain/freebsd-x86_64/README.txt new file mode 100644 index 00000000000..f9fb74f417b --- /dev/null +++ b/cmake/toolchain/freebsd-x86_64/README.txt @@ -0,0 +1,2 @@ +wget https://clickhouse-datasets.s3.yandex.net/toolchains/toolchains/freebsd-11.3-toolchain.tar.xz +tar xJf freebsd-11.3-toolchain.tar.xz --strip-components=1 diff --git a/cmake/tools.cmake b/cmake/tools.cmake index 5eeec3b2f0a..d261b62eca3 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -1,6 +1,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (COMPILER_GCC 1) -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + set (COMPILER_CLANG 1) # Safe to treat AppleClang as a regular Clang, in general. +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set (COMPILER_CLANG 1) endif () @@ -11,10 +13,25 @@ if (COMPILER_GCC) message (FATAL_ERROR "GCC version must be at least ${GCC_MINIMUM_VERSION}. For example, if GCC ${GCC_MINIMUM_VERSION} is available under gcc-${GCC_MINIMUM_VERSION}, g++-${GCC_MINIMUM_VERSION} names, do the following: export CC=gcc-${GCC_MINIMUM_VERSION} CXX=g++-${GCC_MINIMUM_VERSION}; rm -rf CMakeCache.txt CMakeFiles; and re run cmake or ./release.") endif () elseif (COMPILER_CLANG) - # Require minimum version of clang - set (CLANG_MINIMUM_VERSION 8) - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${CLANG_MINIMUM_VERSION}) - message (FATAL_ERROR "Clang version must be at least ${CLANG_MINIMUM_VERSION}.") + # Require minimum version of clang/apple-clang + if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + # AppleClang 10.0.1 (Xcode 10.2) corresponds to LLVM/Clang upstream version 7.0.0 + # AppleClang 11.0.0 (Xcode 11.0) corresponds to LLVM/Clang upstream version 8.0.0 + set (XCODE_MINIMUM_VERSION 10.2) + set (APPLE_CLANG_MINIMUM_VERSION 10.0.1) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${APPLE_CLANG_MINIMUM_VERSION}) + message (FATAL_ERROR "AppleClang compiler version must be at least ${APPLE_CLANG_MINIMUM_VERSION} (Xcode ${XCODE_MINIMUM_VERSION}).") + elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.0) + # char8_t is available staring (upstream vanilla) Clang 7, but prior to Clang 8, + # it is not enabled by -std=c++20 and can be enabled with an explicit -fchar8_t. + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fchar8_t") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fchar8_t") + endif () + else () + set (CLANG_MINIMUM_VERSION 8) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${CLANG_MINIMUM_VERSION}) + message (FATAL_ERROR "Clang version must be at least ${CLANG_MINIMUM_VERSION}.") + endif () endif () else () message (WARNING "You are using an unsupported compiler. Compilation has only been tested with Clang and GCC.") diff --git a/cmake/version.cmake b/cmake/version.cmake index 3f51f59cf0f..eea17f68c47 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -1,12 +1,4 @@ -# This strings autochanged from release_lib.sh: -set(VERSION_REVISION 54435) -set(VERSION_MAJOR 20) -set(VERSION_MINOR 5) -set(VERSION_PATCH 1) -set(VERSION_GITHASH 91df18a906dcffdbee6816e5389df6c65f86e35f) -set(VERSION_DESCRIBE v20.5.1.1-prestable) -set(VERSION_STRING 20.5.1.1) -# end of autochange +include(${CMAKE_SOURCE_DIR}/cmake/autogenerated_versions.txt) set(VERSION_EXTRA "" CACHE STRING "") set(VERSION_TWEAK "" CACHE STRING "") diff --git a/cmake/warnings.cmake b/cmake/warnings.cmake new file mode 100644 index 00000000000..63cb153a0b4 --- /dev/null +++ b/cmake/warnings.cmake @@ -0,0 +1,171 @@ +# Our principle is to enable as many warnings as possible and always do it with "warnings as errors" flag. +# +# But it comes with some cost: +# - we have to disable some warnings in 3rd party libraries (they are located in "contrib" directory) +# - we have to include headers of these libraries as -isystem to avoid warnings from headers +# (this is the same behaviour as if these libraries were located in /usr/include) +# - sometimes warnings from 3rd party libraries may come from macro substitutions in our code +# and we have to wrap them with #pragma GCC/clang diagnostic ignored + +if (NOT MSVC) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +endif () + +if (USE_DEBUG_HELPERS) + set (INCLUDE_DEBUG_HELPERS "-I${ClickHouse_SOURCE_DIR}/base -include ${ClickHouse_SOURCE_DIR}/src/Core/iostream_debug_helpers.h") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}") +endif () + +# Add some warnings that are not available even with -Wall -Wextra -Wpedantic. + +option (WEVERYTHING "Enables -Weverything option with some exceptions. This is intended for exploration of new compiler warnings that may be found to be useful. Only makes sense for clang." ON) + +if (COMPILER_CLANG) + add_warning(pedantic) + no_warning(vla-extension) + no_warning(zero-length-array) + + add_warning(comma) + add_warning(conditional-uninitialized) + add_warning(covered-switch-default) + add_warning(deprecated) + add_warning(embedded-directive) + add_warning(empty-init-stmt) # linux-only + add_warning(extra-semi-stmt) # linux-only + add_warning(extra-semi) + add_warning(gnu-case-range) + add_warning(inconsistent-missing-destructor-override) + add_warning(newline-eof) + add_warning(old-style-cast) + add_warning(range-loop-analysis) + add_warning(redundant-parens) + add_warning(reserved-id-macro) + add_warning(shadow-field) # clang 8+ + add_warning(shadow-uncaptured-local) + add_warning(shadow) + add_warning(string-plus-int) # clang 8+ + add_warning(undef) + add_warning(unreachable-code-return) + add_warning(unreachable-code) + add_warning(unused-exception-parameter) + add_warning(unused-macros) + add_warning(unused-member-function) + add_warning(zero-as-null-pointer-constant) + + if (WEVERYTHING) + add_warning(everything) + no_warning(c++98-compat-pedantic) + no_warning(c++98-compat) + no_warning(c99-extensions) + no_warning(conversion) + no_warning(ctad-maybe-unsupported) # clang 9+, linux-only + no_warning(deprecated-dynamic-exception-spec) + no_warning(disabled-macro-expansion) + no_warning(documentation-unknown-command) + no_warning(double-promotion) + no_warning(exit-time-destructors) + no_warning(float-equal) + no_warning(global-constructors) + no_warning(missing-prototypes) + no_warning(missing-variable-declarations) + no_warning(nested-anon-types) + no_warning(packed) + no_warning(padded) + no_warning(return-std-move-in-c++11) # clang 7+ + no_warning(shift-sign-overflow) + no_warning(sign-conversion) + no_warning(switch-enum) + no_warning(undefined-func-template) + no_warning(unused-template) + no_warning(vla) + no_warning(weak-template-vtables) + no_warning(weak-vtables) + + # TODO Enable conversion, sign-conversion, double-promotion warnings. + endif () +elseif (COMPILER_GCC) + # Add compiler options only to c++ compiler + function(add_cxx_compile_options option) + add_compile_options("$<$,CXX>:${option}>") + endfunction() + # Warn about boolean expression compared with an integer value different from true/false + add_cxx_compile_options(-Wbool-compare) + # Warn whenever a pointer is cast such that the required alignment of the target is increased. + add_cxx_compile_options(-Wcast-align) + # Warn whenever a pointer is cast so as to remove a type qualifier from the target type. + add_cxx_compile_options(-Wcast-qual) + # Warn when deleting a pointer to incomplete type, which may cause undefined behavior at runtime + add_cxx_compile_options(-Wdelete-incomplete) + # Warn if a requested optimization pass is disabled. Code is too big or too complex + add_cxx_compile_options(-Wdisabled-optimization) + # Warn about duplicated conditions in an if-else-if chain + add_cxx_compile_options(-Wduplicated-cond) + # Warn about a comparison between values of different enumerated types + add_cxx_compile_options(-Wenum-compare) + # Warn about uninitialized variables that are initialized with themselves + add_cxx_compile_options(-Winit-self) + # Warn about logical not used on the left hand side operand of a comparison + add_cxx_compile_options(-Wlogical-not-parentheses) + # Warn about suspicious uses of logical operators in expressions + add_cxx_compile_options(-Wlogical-op) + # Warn if there exists a path from the function entry to a use of the variable that is uninitialized. + add_cxx_compile_options(-Wmaybe-uninitialized) + # Warn when the indentation of the code does not reflect the block structure + add_cxx_compile_options(-Wmisleading-indentation) + # Warn if a global function is defined without a previous declaration - disabled because of build times + # add_cxx_compile_options(-Wmissing-declarations) + # Warn if a user-supplied include directory does not exist + add_cxx_compile_options(-Wmissing-include-dirs) + # Obvious + add_cxx_compile_options(-Wnon-virtual-dtor) + # Obvious + add_cxx_compile_options(-Wno-return-local-addr) + # This warning is disabled due to false positives if compiled with libc++: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90037 + #add_cxx_compile_options(-Wnull-dereference) + # Obvious + add_cxx_compile_options(-Wodr) + # Obvious + add_cxx_compile_options(-Wold-style-cast) + # Warn when a function declaration hides virtual functions from a base class + # add_cxx_compile_options(-Woverloaded-virtual) + # Warn about placement new expressions with undefined behavior + add_cxx_compile_options(-Wplacement-new=2) + # Warn about anything that depends on the “size of” a function type or of void + add_cxx_compile_options(-Wpointer-arith) + # Warn if anything is declared more than once in the same scope + add_cxx_compile_options(-Wredundant-decls) + # Member initialization reordering + add_cxx_compile_options(-Wreorder) + # Obvious + add_cxx_compile_options(-Wshadow) + # Warn if left shifting a negative value + add_cxx_compile_options(-Wshift-negative-value) + # Warn about a definition of an unsized deallocation function + add_cxx_compile_options(-Wsized-deallocation) + # Warn when the sizeof operator is applied to a parameter that is declared as an array in a function definition + add_cxx_compile_options(-Wsizeof-array-argument) + # Warn for suspicious length parameters to certain string and memory built-in functions if the argument uses sizeof + add_cxx_compile_options(-Wsizeof-pointer-memaccess) + + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9) + # Warn about overriding virtual functions that are not marked with the override keyword + add_cxx_compile_options(-Wsuggest-override) + endif () + + # Warn whenever a switch statement has an index of boolean type and the case values are outside the range of a boolean type + add_cxx_compile_options(-Wswitch-bool) + # Warn if a self-comparison always evaluates to true or false + add_cxx_compile_options(-Wtautological-compare) + # Warn about trampolines generated for pointers to nested functions + add_cxx_compile_options(-Wtrampolines) + # Obvious + add_cxx_compile_options(-Wunused) + # Warn if vector operation is not implemented via SIMD capabilities of the architecture + add_cxx_compile_options(-Wvector-operation-performance) + + # XXX: gcc10 stuck with this option while compiling GatherUtils code + # (anyway there are builds with clang, that will warn) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10) + add_cxx_compile_options(-Wno-sequence-point) + endif() +endif () diff --git a/cmake/yandex/ya.make.versions.inc b/cmake/yandex/ya.make.versions.inc new file mode 100644 index 00000000000..3ac401cb108 --- /dev/null +++ b/cmake/yandex/ya.make.versions.inc @@ -0,0 +1,25 @@ +INCLUDE(${ARCADIA_ROOT}/clickhouse/cmake/autogenerated_versions.txt) + +# TODO: not sure if this is customizable per-binary +SET(VERSION_NAME "ClickHouse") + +# TODO: not quite sure how to replace dash with space in ya.make +SET(VERSION_FULL "${VERSION_NAME}-${VERSION_STRING}") + +CFLAGS (GLOBAL -DDBMS_NAME=\"ClickHouse\") +CFLAGS (GLOBAL -DDBMS_VERSION_MAJOR=${VERSION_MAJOR}) +CFLAGS (GLOBAL -DDBMS_VERSION_MINOR=${VERSION_MINOR}) +CFLAGS (GLOBAL -DDBMS_VERSION_PATCH=${VERSION_PATCH}) +CFLAGS (GLOBAL -DVERSION_FULL=\"\\\"${VERSION_FULL}\\\"\") +CFLAGS (GLOBAL -DVERSION_MAJOR=${VERSION_MAJOR}) +CFLAGS (GLOBAL -DVERSION_MINOR=${VERSION_MINOR}) +CFLAGS (GLOBAL -DVERSION_PATCH=${VERSION_PATCH}) + +# TODO: not supported yet, not sure if ya.make supports arithmetics. +CFLAGS (GLOBAL -DVERSION_INTEGER=0) + +CFLAGS (GLOBAL -DVERSION_NAME=\"\\\"${VERSION_NAME}\\\"\") +CFLAGS (GLOBAL -DVERSION_OFFICIAL=\"-arcadia\") +CFLAGS (GLOBAL -DVERSION_REVISION=${VERSION_REVISION}) +CFLAGS (GLOBAL -DVERSION_STRING=\"\\\"${VERSION_STRING}\\\"\") + diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 1d438e29dae..b8029124712 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,17 +1,42 @@ # Third-party libraries may have substandard code. +# Put all targets defined here and in added subfolders under "contrib/" folder in GUI-based IDEs by default. +# Some of third-party projects may override CMAKE_FOLDER or FOLDER property of their targets, so they will +# appear not in "contrib/" as originally planned here. +get_filename_component (_current_dir_name "${CMAKE_CURRENT_LIST_DIR}" NAME) +if (CMAKE_FOLDER) + set (CMAKE_FOLDER "${CMAKE_FOLDER}/${_current_dir_name}") +else () + set (CMAKE_FOLDER "${_current_dir_name}") +endif () +unset (_current_dir_name) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL 1) -if (USE_INTERNAL_BOOST_LIBRARY) - add_subdirectory (boost-cmake) -endif () +add_subdirectory (boost-cmake) +add_subdirectory (cctz-cmake) +add_subdirectory (consistent-hashing-sumbur) +add_subdirectory (consistent-hashing) +add_subdirectory (croaring) +add_subdirectory (FastMemcpy) +add_subdirectory (hyperscan-cmake) +add_subdirectory (jemalloc-cmake) +add_subdirectory (libcpuid-cmake) +add_subdirectory (libdivide) +add_subdirectory (libmetrohash) +add_subdirectory (lz4-cmake) +add_subdirectory (murmurhash) +add_subdirectory (replxx-cmake) +add_subdirectory (ryu-cmake) +add_subdirectory (unixodbc-cmake) -if (USE_INTERNAL_LZ4_LIBRARY) - add_subdirectory (lz4-cmake) -endif () +add_subdirectory (poco-cmake) + + +# TODO: refactor the contrib libraries below this comment. if (USE_INTERNAL_ZSTD_LIBRARY) add_subdirectory (zstd-cmake) @@ -27,8 +52,6 @@ if (USE_INTERNAL_DOUBLE_CONVERSION_LIBRARY) add_subdirectory (double-conversion-cmake) endif () -add_subdirectory (ryu-cmake) - if (USE_INTERNAL_CITYHASH_LIBRARY) add_subdirectory (cityhash102) endif () @@ -37,13 +60,6 @@ if (USE_INTERNAL_FARMHASH_LIBRARY) add_subdirectory (libfarmhash) endif () -if (USE_INTERNAL_METROHASH_LIBRARY) - add_subdirectory (libmetrohash) -endif () - -add_subdirectory (murmurhash) -add_subdirectory (croaring) - if (USE_INTERNAL_BTRIE_LIBRARY) add_subdirectory (libbtrie) endif () @@ -75,14 +91,6 @@ if (USE_INTERNAL_ZLIB_LIBRARY) endif () endif () -add_subdirectory (cctz-cmake) - -add_subdirectory (jemalloc-cmake) - -if (USE_INTERNAL_CPUID_LIBRARY) - add_subdirectory (libcpuid) -endif () - if (USE_INTERNAL_H3_LIBRARY) add_subdirectory(h3-cmake) endif () @@ -90,12 +98,14 @@ endif () if (USE_INTERNAL_SSL_LIBRARY) add_subdirectory (openssl-cmake) - # This is for Poco library - set (POCO_SKIP_OPENSSL_FIND 1) add_library(OpenSSL::Crypto ALIAS ${OPENSSL_CRYPTO_LIBRARY}) add_library(OpenSSL::SSL ALIAS ${OPENSSL_SSL_LIBRARY}) endif () +if (ENABLE_LDAP AND USE_INTERNAL_LDAP_LIBRARY) + add_subdirectory (openldap-cmake) +endif () + function(mysql_support) set(CLIENT_PLUGIN_CACHING_SHA2_PASSWORD STATIC) set(CLIENT_PLUGIN_SHA256_PASSWORD STATIC) @@ -131,11 +141,6 @@ if (USE_RDKAFKA) add_subdirectory (cppkafka-cmake) endif() -if (ENABLE_ODBC AND USE_INTERNAL_ODBC_LIBRARY) - add_subdirectory (unixodbc-cmake) - add_library(ODBC::ODBC ALIAS ${ODBC_LIBRARIES}) -endif () - if (ENABLE_ICU AND USE_INTERNAL_ICU_LIBRARY) add_subdirectory (icu-cmake) endif () @@ -174,24 +179,27 @@ if (USE_INTERNAL_PARQUET_LIBRARY_NATIVE_CMAKE) set (PARQUET_ARROW_LINKAGE "static" CACHE INTERNAL "") set (ARROW_TEST_LINKAGE "static" CACHE INTERNAL "") set (ARROW_BUILD_STATIC ${MAKE_STATIC_LIBRARIES} CACHE INTERNAL "") - else() + else () set (PARQUET_ARROW_LINKAGE "shared" CACHE INTERNAL "") set (ARROW_TEST_LINKAGE "shared" CACHE INTERNAL "") - endif() + endif () - if(CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") - set(_save_build_type ${CMAKE_BUILD_TYPE}) - set(CMAKE_BUILD_TYPE RELEASE) - endif() + if (CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO") + set (_save_build_type ${CMAKE_BUILD_TYPE}) + set (CMAKE_BUILD_TYPE Release) + string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) + endif () # Because Arrow uses CMAKE_SOURCE_DIR as a project path # Hopefully will be fixed in https://github.com/apache/arrow/pull/2676 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${ClickHouse_SOURCE_DIR}/contrib/arrow/cpp/cmake_modules") add_subdirectory (arrow/cpp) - if(_save_build_type) - set(CMAKE_BUILD_TYPE ${_save_build_type}) - endif() + if (_save_build_type) + set (CMAKE_BUILD_TYPE ${_save_build_type}) + unset (_save_build_type) + string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) + endif () else() add_subdirectory(arrow-cmake) @@ -207,29 +215,6 @@ if (USE_INTERNAL_AVRO_LIBRARY) add_subdirectory(avro-cmake) endif() -if (USE_INTERNAL_POCO_LIBRARY) - set (POCO_VERBOSE_MESSAGES 0 CACHE INTERNAL "") - set (save_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - set (save_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) - set (_save ${ENABLE_TESTS}) - set (ENABLE_TESTS 0) - set (POCO_ENABLE_TESTS 0) - set (CMAKE_DISABLE_FIND_PACKAGE_ZLIB 1) - if (MSVC OR NOT USE_POCO_DATAODBC) - set (ENABLE_DATA_ODBC 0 CACHE INTERNAL "") # TODO (build fail) - endif () - add_subdirectory (poco) - unset (CMAKE_DISABLE_FIND_PACKAGE_ZLIB) - set (ENABLE_TESTS ${_save}) - set (CMAKE_CXX_FLAGS ${save_CMAKE_CXX_FLAGS}) - set (CMAKE_C_FLAGS ${save_CMAKE_C_FLAGS}) - - if (OPENSSL_FOUND AND TARGET Crypto AND (NOT DEFINED ENABLE_POCO_NETSSL OR ENABLE_POCO_NETSSL)) - # Bug in poco https://github.com/pocoproject/poco/pull/2100 found on macos - target_include_directories(Crypto SYSTEM PUBLIC ${OPENSSL_INCLUDE_DIR}) - endif () -endif () - if(USE_INTERNAL_GTEST_LIBRARY) # Google Test from sources add_subdirectory(${ClickHouse_SOURCE_DIR}/contrib/googletest/googletest ${CMAKE_CURRENT_BINARY_DIR}/googletest) @@ -267,20 +252,17 @@ if (USE_INTERNAL_BROTLI_LIBRARY) endif () if (USE_INTERNAL_PROTOBUF_LIBRARY) - if (MAKE_STATIC_LIBRARIES) - set(protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) - else () - set(protobuf_BUILD_SHARED_LIBS ON CACHE INTERNAL "" FORCE) - endif () - set(protobuf_WITH_ZLIB 0 CACHE INTERNAL "" FORCE) # actually will use zlib, but skip find - set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) - add_subdirectory(protobuf/cmake) + add_subdirectory(protobuf-cmake) endif () if (USE_INTERNAL_HDFS3_LIBRARY) add_subdirectory(libhdfs3-cmake) endif () +if (USE_INTERNAL_GRPC_LIBRARY) + add_subdirectory(grpc-cmake) +endif () + if (USE_INTERNAL_AWS_S3_LIBRARY) set (save_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) set (save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -305,33 +287,18 @@ if (USE_BASE64) add_subdirectory (base64-cmake) endif() -if (USE_INTERNAL_HYPERSCAN_LIBRARY) - # The library is large - avoid bloat. - if (USE_STATIC_LIBRARIES) - add_subdirectory (hyperscan) - target_compile_options (hs PRIVATE -g0) - else () - set(BUILD_SHARED_LIBS 1 CACHE INTERNAL "") - add_subdirectory (hyperscan) - target_compile_options (hs_shared PRIVATE -g0) - endif () -endif() - if (USE_SIMDJSON) add_subdirectory (simdjson-cmake) endif() -if (USE_MIMALLOC) - add_subdirectory (mimalloc) -endif() - if (USE_FASTOPS) add_subdirectory (fastops-cmake) endif() -add_subdirectory(grpc-cmake) +if (USE_CASSANDRA) + add_subdirectory (libuv) + add_subdirectory (cassandra) +endif() + +add_subdirectory (fmtlib-cmake) -add_subdirectory(replxx-cmake) -add_subdirectory(FastMemcpy) -add_subdirectory(consistent-hashing) -add_subdirectory(consistent-hashing-sumbur) diff --git a/contrib/arrow-cmake/CMakeLists.txt b/contrib/arrow-cmake/CMakeLists.txt index 20ff5c49eea..afcdae68e77 100644 --- a/contrib/arrow-cmake/CMakeLists.txt +++ b/contrib/arrow-cmake/CMakeLists.txt @@ -47,7 +47,8 @@ set(thriftcpp_threads_SOURCES ) add_library(${THRIFT_LIBRARY} ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES}) set_target_properties(${THRIFT_LIBRARY} PROPERTIES CXX_STANDARD 14) # REMOVE after https://github.com/apache/thrift/pull/1641 -target_include_directories(${THRIFT_LIBRARY} SYSTEM PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/thrift/lib/cpp/src PRIVATE ${Boost_INCLUDE_DIRS}) +target_include_directories(${THRIFT_LIBRARY} SYSTEM PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/thrift/lib/cpp/src) +target_link_libraries (${THRIFT_LIBRARY} PRIVATE boost::headers_only) # === orc @@ -83,7 +84,7 @@ add_custom_command(OUTPUT orc_proto.pb.h orc_proto.pb.cc set(FLATBUFFERS_SRC_DIR ${ClickHouse_SOURCE_DIR}/contrib/flatbuffers) set(FLATBUFFERS_BINARY_DIR ${ClickHouse_BINARY_DIR}/contrib/flatbuffers) set(FLATBUFFERS_INCLUDE_DIR ${FLATBUFFERS_SRC_DIR}/include) -set(FLATBUFFERS_COMPILER "${FLATBUFFERS_BINARY_DIR}/flatc") +set(FLATBUFFERS_COMPILER "$") # set flatbuffers CMake options if (${USE_STATIC_LIBRARIES}) @@ -146,7 +147,7 @@ add_custom_target(metadata_fbs DEPENDS ${FBS_OUTPUT_FILES}) add_dependencies(metadata_fbs flatc) # arrow-cmake cmake file calling orc cmake subroutine which detects certain compiler features. -# Apple Clang compiler failed to compile this code without specifying c++11 standard. +# Apple Clang compiler failed to compile this code without specifying c++11 standard. # As result these compiler features detected as absent. In result it failed to compile orc itself. # In orc makefile there is code that sets flags, but arrow-cmake ignores these flags. if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") @@ -286,10 +287,6 @@ set(ARROW_SRCS ${ARROW_SRCS} ${LIBRARY_DIR}/compute/kernels/util_internal.cc ) -if (LZ4_INCLUDE_DIR AND LZ4_LIBRARY) - set(ARROW_WITH_LZ4 1) -endif () - if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY) set(ARROW_WITH_SNAPPY 1) endif () @@ -302,10 +299,8 @@ if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) set(ARROW_WITH_ZSTD 1) endif () -if (ARROW_WITH_LZ4) - add_definitions(-DARROW_WITH_LZ4) - SET(ARROW_SRCS ${LIBRARY_DIR}/util/compression_lz4.cc ${ARROW_SRCS}) -endif () +add_definitions(-DARROW_WITH_LZ4) +SET(ARROW_SRCS ${LIBRARY_DIR}/util/compression_lz4.cc ${ARROW_SRCS}) if (ARROW_WITH_SNAPPY) add_definitions(-DARROW_WITH_SNAPPY) @@ -328,18 +323,15 @@ add_library(${ARROW_LIBRARY} ${ARROW_SRCS}) # Arrow dependencies add_dependencies(${ARROW_LIBRARY} ${FLATBUFFERS_LIBRARY} metadata_fbs) -target_link_libraries(${ARROW_LIBRARY} PRIVATE boost_system_internal boost_filesystem_internal boost_regex_internal) -target_link_libraries(${ARROW_LIBRARY} PRIVATE ${FLATBUFFERS_LIBRARY}) +target_link_libraries(${ARROW_LIBRARY} PRIVATE ${FLATBUFFERS_LIBRARY} boost::filesystem) if (USE_INTERNAL_PROTOBUF_LIBRARY) add_dependencies(${ARROW_LIBRARY} protoc) endif () -target_include_directories(${ARROW_LIBRARY} SYSTEM PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/arrow/cpp/src PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp/src ${Boost_INCLUDE_DIRS}) +target_include_directories(${ARROW_LIBRARY} SYSTEM PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/arrow/cpp/src PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp/src) target_link_libraries(${ARROW_LIBRARY} PRIVATE ${DOUBLE_CONVERSION_LIBRARIES} ${Protobuf_LIBRARY}) -if (ARROW_WITH_LZ4) - target_link_libraries(${ARROW_LIBRARY} PRIVATE ${LZ4_LIBRARY}) -endif () +target_link_libraries(${ARROW_LIBRARY} PRIVATE lz4) if (ARROW_WITH_SNAPPY) target_link_libraries(${ARROW_LIBRARY} PRIVATE ${SNAPPY_LIBRARY}) endif () @@ -396,8 +388,7 @@ list(APPEND PARQUET_SRCS add_library(${PARQUET_LIBRARY} ${PARQUET_SRCS}) target_include_directories(${PARQUET_LIBRARY} SYSTEM PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/arrow/cpp/src ${CMAKE_CURRENT_SOURCE_DIR}/cpp/src) include(${ClickHouse_SOURCE_DIR}/contrib/thrift/build/cmake/ConfigureChecks.cmake) # makes config.h -target_link_libraries(${PARQUET_LIBRARY} PUBLIC ${ARROW_LIBRARY} PRIVATE ${THRIFT_LIBRARY} ${Boost_REGEX_LIBRARY}) -target_include_directories(${PARQUET_LIBRARY} PRIVATE ${Boost_INCLUDE_DIRS}) +target_link_libraries(${PARQUET_LIBRARY} PUBLIC ${ARROW_LIBRARY} PRIVATE ${THRIFT_LIBRARY} boost::headers_only boost::regex) if (SANITIZE STREQUAL "undefined") target_compile_options(${PARQUET_LIBRARY} PRIVATE -fno-sanitize=undefined) diff --git a/contrib/avro-cmake/CMakeLists.txt b/contrib/avro-cmake/CMakeLists.txt index f544b3c50cd..052a19ee804 100644 --- a/contrib/avro-cmake/CMakeLists.txt +++ b/contrib/avro-cmake/CMakeLists.txt @@ -45,13 +45,12 @@ set_target_properties (avrocpp PROPERTIES VERSION ${AVRO_VERSION_MAJOR}.${AVRO_V target_include_directories(avrocpp SYSTEM PUBLIC ${AVROCPP_INCLUDE_DIR}) -target_include_directories(avrocpp SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) -target_link_libraries (avrocpp ${Boost_IOSTREAMS_LIBRARY}) +target_link_libraries (avrocpp PRIVATE boost::headers_only boost::iostreams) if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY) target_compile_definitions (avrocpp PUBLIC SNAPPY_CODEC_AVAILABLE) target_include_directories (avrocpp PRIVATE ${SNAPPY_INCLUDE_DIR}) - target_link_libraries (avrocpp ${SNAPPY_LIBRARY}) + target_link_libraries (avrocpp PRIVATE ${SNAPPY_LIBRARY}) endif () if (COMPILER_GCC) @@ -67,4 +66,4 @@ ADD_CUSTOM_TARGET(avro_symlink_headers ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${AVROCPP_ROOT_DIR}/include COMMAND ${CMAKE_COMMAND} -E create_symlink ${AVROCPP_ROOT_DIR}/api ${AVROCPP_ROOT_DIR}/include/avro ) -add_dependencies(avrocpp avro_symlink_headers) \ No newline at end of file +add_dependencies(avrocpp avro_symlink_headers) diff --git a/contrib/aws b/contrib/aws index 45dd8552d3c..17e10c0fc77 160000 --- a/contrib/aws +++ b/contrib/aws @@ -1 +1 @@ -Subproject commit 45dd8552d3c492defca79d2720bcc809e35654da +Subproject commit 17e10c0fc77f22afe890fa6d1b283760e5edaa56 diff --git a/contrib/aws-s3-cmake/CMakeLists.txt b/contrib/aws-s3-cmake/CMakeLists.txt index 6ed6434dcfd..d889fca197f 100644 --- a/contrib/aws-s3-cmake/CMakeLists.txt +++ b/contrib/aws-s3-cmake/CMakeLists.txt @@ -83,7 +83,7 @@ set(S3_INCLUDES add_library(aws_s3_checksums ${AWS_CHECKSUMS_SOURCES}) target_include_directories(aws_s3_checksums PUBLIC "${AWS_CHECKSUMS_LIBRARY_DIR}/include/") -if(CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE STREQUAL "Debug") +if(CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG") target_compile_definitions(aws_s3_checksums PRIVATE "-DDEBUG_BUILD") endif() set_target_properties(aws_s3_checksums PROPERTIES LINKER_LANGUAGE C) diff --git a/contrib/base64-cmake/CMakeLists.txt b/contrib/base64-cmake/CMakeLists.txt index b8e6fa536a6..63b4e324d29 100644 --- a/contrib/base64-cmake/CMakeLists.txt +++ b/contrib/base64-cmake/CMakeLists.txt @@ -31,3 +31,13 @@ else () endif () target_include_directories(base64 SYSTEM PUBLIC ${LIBRARY_DIR}) + +if (XCODE OR XCODE_VERSION) + # https://gitlab.kitware.com/cmake/cmake/issues/17457 + # Some native build systems may not like targets that have only object files, so consider adding at least one real source file + # This applies to Xcode. + if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dummy.c") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.c" "") + endif () + target_sources(base64 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/dummy.c") +endif () diff --git a/contrib/boost b/contrib/boost index 86be2aef20b..a04e72c0464 160000 --- a/contrib/boost +++ b/contrib/boost @@ -1 +1 @@ -Subproject commit 86be2aef20bee2356b744e5569eed6eaded85dbe +Subproject commit a04e72c0464f0c31d3384f18f0c0db36a05538e0 diff --git a/contrib/boost-cmake/CMakeLists.txt b/contrib/boost-cmake/CMakeLists.txt index 582cc84a552..e92fe4b7159 100644 --- a/contrib/boost-cmake/CMakeLists.txt +++ b/contrib/boost-cmake/CMakeLists.txt @@ -1,45 +1,133 @@ -# Supported contrib/boost source variants: -# 1. Default - Minimized vrsion from release archive : https://github.com/ClickHouse-Extras/boost -# 2. Release archive unpacked to contrib/boost -# 3. Full boost https://github.com/boostorg/boost +option (USE_INTERNAL_BOOST_LIBRARY "Use internal Boost library" ${NOT_UNBUNDLED}) -# if boostorg/boost connected as submodule: Update all boost internal submodules to tag: -# git submodule foreach "git fetch --all && git checkout boost-1.66.0 || true" +if (USE_INTERNAL_BOOST_LIBRARY) + set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/boost) -# -# Important boost patch: 094c18b -# + # filesystem -include(${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake) + set (SRCS_FILESYSTEM + ${LIBRARY_DIR}/libs/filesystem/src/codecvt_error_category.cpp + ${LIBRARY_DIR}/libs/filesystem/src/operations.cpp + ${LIBRARY_DIR}/libs/filesystem/src/path_traits.cpp + ${LIBRARY_DIR}/libs/filesystem/src/path.cpp + ${LIBRARY_DIR}/libs/filesystem/src/portability.cpp + ${LIBRARY_DIR}/libs/filesystem/src/unique_path.cpp + ${LIBRARY_DIR}/libs/filesystem/src/utf8_codecvt_facet.cpp + ${LIBRARY_DIR}/libs/filesystem/src/windows_file_codecvt.cpp + ) -set(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/boost) + add_library (_boost_filesystem ${SRCS_FILESYSTEM}) + add_library (boost::filesystem ALIAS _boost_filesystem) + target_include_directories (_boost_filesystem SYSTEM BEFORE PUBLIC ${LIBRARY_DIR}) -if(NOT MSVC) - add_definitions(-Wno-unused-variable -Wno-deprecated-declarations) -endif() + # headers-only -macro(add_boost_lib lib_name) - add_headers_and_sources(boost_${lib_name} ${LIBRARY_DIR}/libs/${lib_name}/src) - add_library(boost_${lib_name}_internal ${boost_${lib_name}_sources}) - target_include_directories(boost_${lib_name}_internal SYSTEM BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) - target_compile_definitions(boost_${lib_name}_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) -endmacro() + add_library (_boost_headers_only INTERFACE) + add_library (boost::headers_only ALIAS _boost_headers_only) + target_include_directories (_boost_headers_only SYSTEM BEFORE INTERFACE ${LIBRARY_DIR}) -add_boost_lib(system) + # iostreams -add_boost_lib(program_options) + set (SRCS_IOSTREAMS + ${LIBRARY_DIR}/libs/iostreams/src/file_descriptor.cpp + ${LIBRARY_DIR}/libs/iostreams/src/gzip.cpp + ${LIBRARY_DIR}/libs/iostreams/src/mapped_file.cpp + ${LIBRARY_DIR}/libs/iostreams/src/zlib.cpp + ) -add_boost_lib(filesystem) -target_link_libraries(boost_filesystem_internal PRIVATE boost_system_internal) + add_library (_boost_iostreams ${SRCS_IOSTREAMS}) + add_library (boost::iostreams ALIAS _boost_iostreams) + target_include_directories (_boost_iostreams PRIVATE ${LIBRARY_DIR}) + target_link_libraries (_boost_iostreams PRIVATE zlib) -#add_boost_lib(random) + # program_options -if (USE_INTERNAL_PARQUET_LIBRARY) - add_boost_lib(regex) -endif() + set (SRCS_PROGRAM_OPTIONS + ${LIBRARY_DIR}/libs/program_options/src/cmdline.cpp + ${LIBRARY_DIR}/libs/program_options/src/config_file.cpp + ${LIBRARY_DIR}/libs/program_options/src/convert.cpp + ${LIBRARY_DIR}/libs/program_options/src/options_description.cpp + ${LIBRARY_DIR}/libs/program_options/src/parsers.cpp + ${LIBRARY_DIR}/libs/program_options/src/positional_options.cpp + ${LIBRARY_DIR}/libs/program_options/src/split.cpp + ${LIBRARY_DIR}/libs/program_options/src/utf8_codecvt_facet.cpp + ${LIBRARY_DIR}/libs/program_options/src/value_semantic.cpp + ${LIBRARY_DIR}/libs/program_options/src/variables_map.cpp + ${LIBRARY_DIR}/libs/program_options/src/winmain.cpp + ) -if (USE_INTERNAL_AVRO_LIBRARY) - add_boost_lib(iostreams) - target_link_libraries(boost_iostreams_internal PUBLIC ${ZLIB_LIBRARIES}) - target_include_directories(boost_iostreams_internal SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR}) -endif() + add_library (_boost_program_options ${SRCS_PROGRAM_OPTIONS}) + add_library (boost::program_options ALIAS _boost_program_options) + target_include_directories (_boost_program_options SYSTEM BEFORE PUBLIC ${LIBRARY_DIR}) + + # regex + + set (SRCS_REGEX + ${LIBRARY_DIR}/libs/regex/src/c_regex_traits.cpp + ${LIBRARY_DIR}/libs/regex/src/cpp_regex_traits.cpp + ${LIBRARY_DIR}/libs/regex/src/cregex.cpp + ${LIBRARY_DIR}/libs/regex/src/fileiter.cpp + ${LIBRARY_DIR}/libs/regex/src/icu.cpp + ${LIBRARY_DIR}/libs/regex/src/instances.cpp + ${LIBRARY_DIR}/libs/regex/src/internals.hpp + ${LIBRARY_DIR}/libs/regex/src/posix_api.cpp + ${LIBRARY_DIR}/libs/regex/src/regex_debug.cpp + ${LIBRARY_DIR}/libs/regex/src/regex_raw_buffer.cpp + ${LIBRARY_DIR}/libs/regex/src/regex_traits_defaults.cpp + ${LIBRARY_DIR}/libs/regex/src/regex.cpp + ${LIBRARY_DIR}/libs/regex/src/static_mutex.cpp + ${LIBRARY_DIR}/libs/regex/src/usinstances.cpp + ${LIBRARY_DIR}/libs/regex/src/w32_regex_traits.cpp + ${LIBRARY_DIR}/libs/regex/src/wc_regex_traits.cpp + ${LIBRARY_DIR}/libs/regex/src/wide_posix_api.cpp + ${LIBRARY_DIR}/libs/regex/src/winstances.cpp + ) + + add_library (_boost_regex ${SRCS_REGEX}) + add_library (boost::regex ALIAS _boost_regex) + target_include_directories (_boost_regex PRIVATE ${LIBRARY_DIR}) + + # system + + set (SRCS_SYSTEM + ${LIBRARY_DIR}/libs/system/src/error_code.cpp + ) + + add_library (_boost_system ${SRCS_SYSTEM}) + add_library (boost::system ALIAS _boost_system) + target_include_directories (_boost_system PRIVATE ${LIBRARY_DIR}) +else () + # 1.70 like in contrib/boost + # 1.67 on CI + set(BOOST_VERSION 1.67) + + find_package(Boost ${BOOST_VERSION} COMPONENTS + system + filesystem + iostreams + program_options + regex + REQUIRED) + + add_library (_boost_headers_only INTERFACE) + add_library (boost::headers_only ALIAS _boost_headers_only) + target_include_directories (_boost_headers_only SYSTEM BEFORE INTERFACE ${Boost_INCLUDE_DIR}) + + add_library (_boost_filesystem INTERFACE) + add_library (_boost_iostreams INTERFACE) + add_library (_boost_program_options INTERFACE) + add_library (_boost_regex INTERFACE) + add_library (_boost_system INTERFACE) + + target_link_libraries (_boost_filesystem INTERFACE ${Boost_FILESYSTEM_LIBRARY}) + target_link_libraries (_boost_iostreams INTERFACE ${Boost_IOSTREAMS_LIBRARY}) + target_link_libraries (_boost_program_options INTERFACE ${Boost_PROGRAM_OPTIONS_LIBRARY}) + target_link_libraries (_boost_regex INTERFACE ${Boost_REGEX_LIBRARY}) + target_link_libraries (_boost_system INTERFACE ${Boost_SYSTEM_LIBRARY}) + + add_library (boost::filesystem ALIAS _boost_filesystem) + add_library (boost::iostreams ALIAS _boost_iostreams) + add_library (boost::program_options ALIAS _boost_program_options) + add_library (boost::regex ALIAS _boost_regex) + add_library (boost::system ALIAS _boost_system) +endif () diff --git a/contrib/cassandra b/contrib/cassandra new file mode 160000 index 00000000000..a49b4e0e269 --- /dev/null +++ b/contrib/cassandra @@ -0,0 +1 @@ +Subproject commit a49b4e0e2696a4b8ef286a5b9538d1cbe8490509 diff --git a/contrib/cctz-cmake/CMakeLists.txt b/contrib/cctz-cmake/CMakeLists.txt index 434b8ffb4ae..0837a366f20 100644 --- a/contrib/cctz-cmake/CMakeLists.txt +++ b/contrib/cctz-cmake/CMakeLists.txt @@ -26,11 +26,15 @@ if (USE_INTERNAL_CCTZ) # Build a libray with embedded tzdata - # We invoke 'ld' and 'objcopy' directly because lld linker has no option to generate object file with binary data. - # Note: we can invoke specific ld from toolchain and relax condition on ARCH_AMD64. - if (OS_LINUX AND ARCH_AMD64) + find_program (OBJCOPY_PATH NAMES "llvm-objcopy" "llvm-objcopy-10" "llvm-objcopy-9" "llvm-objcopy-8" "objcopy") + if (OBJCOPY_PATH) + message(STATUS "Using objcopy: ${OBJCOPY_PATH}.") + else () + message(FATAL_ERROR "Cannot find objcopy.") + endif () + set (TIMEZONES Africa/Abidjan Africa/Accra @@ -605,8 +609,8 @@ if (USE_INTERNAL_CCTZ) # https://stackoverflow.com/questions/14776463/compile-and-add-an-object-file-from-a-binary-with-cmake add_custom_command(OUTPUT ${TZ_OBJ} - COMMAND cd ${TZDIR} && ld -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/${TZ_OBJ} ${TIMEZONE} - COMMAND objcopy --rename-section .data=.rodata,alloc,load,readonly,data,contents + COMMAND cd ${TZDIR} && ${OBJCOPY_PATH} -I binary -O elf64-x86-64 -B i386 ${TIMEZONE} ${CMAKE_CURRENT_BINARY_DIR}/${TZ_OBJ} + COMMAND ${OBJCOPY_PATH} --rename-section .data=.rodata,alloc,load,readonly,data,contents ${CMAKE_CURRENT_BINARY_DIR}/${TZ_OBJ} ${CMAKE_CURRENT_BINARY_DIR}/${TZ_OBJ}) set_source_files_properties(${TZ_OBJ} PROPERTIES EXTERNAL_OBJECT true GENERATED true) @@ -614,7 +618,12 @@ if (USE_INTERNAL_CCTZ) add_library(tzdata STATIC ${TZ_OBJS}) set_target_properties(tzdata PROPERTIES LINKER_LANGUAGE C) - target_link_libraries(cctz -Wl,--whole-archive tzdata -Wl,--no-whole-archive) # whole-archive prevents symbols from being discarded + # whole-archive prevents symbols from being discarded for unknown reason + # CMake can shuffle each of target_link_libraries arguments with other + # libraries in linker command. To avoid this we hardcode whole-archive + # library into single string. + add_dependencies(cctz tzdata) + target_link_libraries(cctz INTERFACE "-Wl,--whole-archive $ -Wl,--no-whole-archive") endif () else () diff --git a/contrib/cppkafka b/contrib/cppkafka index 9b184d881c1..f555ee36aaa 160000 --- a/contrib/cppkafka +++ b/contrib/cppkafka @@ -1 +1 @@ -Subproject commit 9b184d881c15cc50784b28688c7c99d3d764db24 +Subproject commit f555ee36aaa74d17ca0dab3ce472070a610b2966 diff --git a/contrib/cppkafka-cmake/CMakeLists.txt b/contrib/cppkafka-cmake/CMakeLists.txt index 2725eaf7a77..9f512974948 100644 --- a/contrib/cppkafka-cmake/CMakeLists.txt +++ b/contrib/cppkafka-cmake/CMakeLists.txt @@ -1,31 +1,33 @@ -set(CPPKAFKA_DIR ${ClickHouse_SOURCE_DIR}/contrib/cppkafka) +set(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/cppkafka) set(SRCS - ${CPPKAFKA_DIR}/src/configuration.cpp - ${CPPKAFKA_DIR}/src/topic_configuration.cpp - ${CPPKAFKA_DIR}/src/configuration_option.cpp - ${CPPKAFKA_DIR}/src/exceptions.cpp - ${CPPKAFKA_DIR}/src/topic.cpp - ${CPPKAFKA_DIR}/src/buffer.cpp - ${CPPKAFKA_DIR}/src/queue.cpp - ${CPPKAFKA_DIR}/src/message.cpp - ${CPPKAFKA_DIR}/src/message_timestamp.cpp - ${CPPKAFKA_DIR}/src/message_internal.cpp - ${CPPKAFKA_DIR}/src/topic_partition.cpp - ${CPPKAFKA_DIR}/src/topic_partition_list.cpp - ${CPPKAFKA_DIR}/src/metadata.cpp - ${CPPKAFKA_DIR}/src/group_information.cpp - ${CPPKAFKA_DIR}/src/error.cpp - ${CPPKAFKA_DIR}/src/event.cpp - - ${CPPKAFKA_DIR}/src/kafka_handle_base.cpp - ${CPPKAFKA_DIR}/src/producer.cpp - ${CPPKAFKA_DIR}/src/consumer.cpp + ${LIBRARY_DIR}/src/buffer.cpp + ${LIBRARY_DIR}/src/configuration_option.cpp + ${LIBRARY_DIR}/src/configuration.cpp + ${LIBRARY_DIR}/src/consumer.cpp + ${LIBRARY_DIR}/src/error.cpp + ${LIBRARY_DIR}/src/event.cpp + ${LIBRARY_DIR}/src/exceptions.cpp + ${LIBRARY_DIR}/src/group_information.cpp + ${LIBRARY_DIR}/src/kafka_handle_base.cpp + ${LIBRARY_DIR}/src/message_internal.cpp + ${LIBRARY_DIR}/src/message_timestamp.cpp + ${LIBRARY_DIR}/src/message.cpp + ${LIBRARY_DIR}/src/metadata.cpp + ${LIBRARY_DIR}/src/producer.cpp + ${LIBRARY_DIR}/src/queue.cpp + ${LIBRARY_DIR}/src/topic_configuration.cpp + ${LIBRARY_DIR}/src/topic_partition_list.cpp + ${LIBRARY_DIR}/src/topic_partition.cpp + ${LIBRARY_DIR}/src/topic.cpp ) add_library(cppkafka ${SRCS}) -target_link_libraries(cppkafka PRIVATE ${RDKAFKA_LIBRARY}) -target_include_directories(cppkafka PRIVATE ${CPPKAFKA_DIR}/include/cppkafka) -target_include_directories(cppkafka PRIVATE ${Boost_INCLUDE_DIRS}) -target_include_directories(cppkafka SYSTEM PUBLIC ${CPPKAFKA_DIR}/include) +target_link_libraries(cppkafka + PRIVATE + ${RDKAFKA_LIBRARY} + boost::headers_only +) +target_include_directories(cppkafka PRIVATE ${LIBRARY_DIR}/include/cppkafka) +target_include_directories(cppkafka SYSTEM BEFORE PUBLIC ${LIBRARY_DIR}/include) diff --git a/contrib/fmtlib b/contrib/fmtlib new file mode 160000 index 00000000000..297c3b2ed55 --- /dev/null +++ b/contrib/fmtlib @@ -0,0 +1 @@ +Subproject commit 297c3b2ed551a4989826fc8c4780bf533e964bd9 diff --git a/contrib/fmtlib-cmake/CMakeLists.txt b/contrib/fmtlib-cmake/CMakeLists.txt new file mode 100644 index 00000000000..f3bf73d7dbc --- /dev/null +++ b/contrib/fmtlib-cmake/CMakeLists.txt @@ -0,0 +1,20 @@ +set (SRCS + ../fmtlib/src/format.cc + ../fmtlib/src/os.cc + + ../fmtlib/include/fmt/chrono.h + ../fmtlib/include/fmt/color.h + ../fmtlib/include/fmt/compile.h + ../fmtlib/include/fmt/core.h + ../fmtlib/include/fmt/format.h + ../fmtlib/include/fmt/format-inl.h + ../fmtlib/include/fmt/locale.h + ../fmtlib/include/fmt/os.h + ../fmtlib/include/fmt/ostream.h + ../fmtlib/include/fmt/posix.h + ../fmtlib/include/fmt/printf.h + ../fmtlib/include/fmt/ranges.h +) + +add_library(fmt ${SRCS}) +target_include_directories(fmt SYSTEM PUBLIC ../fmtlib/include) diff --git a/contrib/grpc b/contrib/grpc index c1d176528fd..8aea4e168e7 160000 --- a/contrib/grpc +++ b/contrib/grpc @@ -1 +1 @@ -Subproject commit c1d176528fd8da9dd4066d16554bcd216d29033f +Subproject commit 8aea4e168e78f3eb9828080740fc8cb73d53bf79 diff --git a/contrib/grpc-cmake/CMakeLists.txt b/contrib/grpc-cmake/CMakeLists.txt index a4b5c80a75a..a70c155da53 100644 --- a/contrib/grpc-cmake/CMakeLists.txt +++ b/contrib/grpc-cmake/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.5.1) + set(GRPC_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/grpc) set(GRPC_INCLUDE_DIR ${GRPC_SOURCE_DIR}/include/) set(GRPC_BINARY_DIR ${ClickHouse_BINARY_DIR}/contrib/grpc) + if(UNIX) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(_gRPC_PLATFORM_LINUX ON) @@ -14,82 +16,28 @@ if(UNIX) endif() endif() -set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_gRPC_C_CXX_FLAGS} -w") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_gRPC_C_CXX_FLAGS} -w") - -set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf") - -if(gRPC_BACKWARDS_COMPATIBILITY_MODE) - add_definitions(-DGPR_BACKWARDS_COMPATIBILITY_MODE) - if (_gRPC_PLATFORM_MAC) - # some C++11 constructs not supported before OS X 10.9 - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9) - endif() +if(_gRPC_PLATFORM_MAC) + set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m pthread) +elseif(UNIX) + set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} rt m pthread) endif() -if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC) - set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti) -else() - set(_gRPC_CORE_NOSTDCXX_FLAGS "") -endif() # address_sorting.cmake -include(${GRPC_SOURCE_DIR}/cmake/address_sorting.cmake) set(_gRPC_ADDRESS_SORTING_INCLUDE_DIR "${GRPC_SOURCE_DIR}/third_party/address_sorting/include") set(_gRPC_ADDRESS_SORTING_LIBRARIES address_sorting) # cares.cmake set(CARES_ROOT_DIR ${GRPC_SOURCE_DIR}/third_party/cares/cares) set(CARES_BINARY_DIR ${GRPC_BINARY_DIR}/third_party/cares/cares) -set(CARES_SHARED OFF CACHE BOOL "disable shared library") -set(CARES_STATIC ON CACHE BOOL "link cares statically") -if(gRPC_BACKWARDS_COMPATIBILITY_MODE) - # See https://github.com/grpc/grpc/issues/17255 - set(HAVE_LIBNSL OFF CACHE BOOL "avoid cares dependency on libnsl") +set(CARES_SHARED ${BUILD_SHARED_LIBS} CACHE BOOL "" FORCE) +if(BUILD_SHARED_LIBS) + set(CARES_STATIC OFF CACHE BOOL "" FORCE) +else() + set(CARES_STATIC ON CACHE BOOL "" FORCE) endif() +set(_gRPC_CARES_LIBRARIES c-ares) add_subdirectory(${CARES_ROOT_DIR} ${CARES_BINARY_DIR}) -if(TARGET c-ares) - set(_gRPC_CARES_LIBRARIES c-ares) -endif() - -# protobuf.cmake -set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../protobuf) -# if(NOT protobuf_BUILD_TESTS) - # set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") -# endif() -set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") -if(NOT protobuf_WITH_ZLIB) - set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") -endif() -set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries") -if(NOT USE_INTERNAL_PROTOBUF_LIBRARY) - add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake ${GRPC_BINARY_DIR}/third_party/protobuf) -endif() -if(TARGET ${_gRPC_PROTOBUF_LIBRARY_NAME}) - set(_gRPC_PROTOBUF_LIBRARIES ${_gRPC_PROTOBUF_LIBRARY_NAME}) -endif() -if(TARGET libprotoc) - set(_gRPC_PROTOBUF_PROTOC_LIBRARIES libprotoc) -endif() -if(TARGET protoc) - set(_gRPC_PROTOBUF_PROTOC protoc) - set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $) -endif() -# For well-known .proto files distributed with protobuf -set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src") -if(gRPC_INSTALL) - message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"") - set(gRPC_INSTALL FALSE) -endif() - -# ssl.cmake -set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ssl) -if(TARGET ssl) - set(_gRPC_SSL_LIBRARIES ssl) - set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include) -endif() # upb.cmake set(UPB_ROOT_DIR ${GRPC_SOURCE_DIR}/third_party/upb) @@ -97,23 +45,21 @@ set(_gRPC_UPB_INCLUDE_DIR "${UPB_ROOT_DIR}") set(_gRPC_UPB_GRPC_GENERATED_DIR "${GRPC_SOURCE_DIR}/src/core/ext/upb-generated") set(_gRPC_UPB_LIBRARIES upb) +# protobuf.cmake +set(_gRPC_PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIR}) +set(_gRPC_PROTOBUF_LIBRARIES ${Protobuf_LIBRARY}) +set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ${Protobuf_PROTOC_LIBRARY}) +set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) + +# ssl.cmake +set(_gRPC_SSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) +set(_gRPC_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) + # zlib.cmake -set(ZLIB_ROOT_DIR ${GRPC_SOURCE_DIR}/third_party/zlib-ng) -include_directories("${ZLIB_ROOT_DIR}") -# add_subdirectory(${ZLIB_ROOT_DIR} ${ZLIB_ROOT_DIR}) -set(_gRPC_ZLIB_LIBRARIES zlibstatic) -set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}") +set(_gRPC_ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIR}) +set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - -if(_gRPC_PLATFORM_MAC) - set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m pthread) -elseif(UNIX) - set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} rt m pthread) -endif() - add_library(address_sorting ${GRPC_SOURCE_DIR}/third_party/address_sorting/address_sorting.c ${GRPC_SOURCE_DIR}/third_party/address_sorting/address_sorting_posix.c @@ -121,7 +67,6 @@ add_library(address_sorting ) target_include_directories(address_sorting - PUBLIC $ $ PRIVATE ${GRPC_SOURCE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} @@ -133,10 +78,11 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(address_sorting - ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} ) + add_library(gpr ${GRPC_SOURCE_DIR}/src/core/lib/gpr/alloc.cc ${GRPC_SOURCE_DIR}/src/core/lib/gpr/atm.cc @@ -192,8 +138,10 @@ target_include_directories(gpr PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) + target_link_libraries(gpr ${_gRPC_ALLTARGETS_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ) add_library(grpc @@ -576,7 +524,6 @@ add_library(grpc ${GRPC_SOURCE_DIR}/src/core/plugin_registry/grpc_plugin_registry.cc ) -target_compile_options(grpc PUBLIC -fpermissive) target_include_directories(grpc PUBLIC ${GRPC_INCLUDE_DIR} @@ -590,364 +537,20 @@ target_include_directories(grpc PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) + target_link_libraries(grpc - ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_SSL_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_CARES_LIBRARIES} ${_gRPC_ADDRESS_SORTING_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} gpr ) if (_gRPC_PLATFORM_MAC) target_link_libraries(grpc "-framework CoreFoundation") endif() -add_library(grpc_cronet - ${GRPC_SOURCE_DIR}/src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/init.cc - ${GRPC_SOURCE_DIR}/src/core/lib/avl/avl.cc - ${GRPC_SOURCE_DIR}/src/core/lib/backoff/backoff.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/channel_args.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/channel_stack.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/channel_stack_builder.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/channel_trace.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/channelz.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/channelz_registry.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/connected_channel.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/handshaker.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/handshaker_registry.cc - ${GRPC_SOURCE_DIR}/src/core/lib/channel/status_util.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/compression.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/compression_args.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/compression_internal.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/message_compress.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/stream_compression.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/stream_compression_gzip.cc - ${GRPC_SOURCE_DIR}/src/core/lib/compression/stream_compression_identity.cc - ${GRPC_SOURCE_DIR}/src/core/lib/debug/stats.cc - ${GRPC_SOURCE_DIR}/src/core/lib/debug/stats_data.cc - ${GRPC_SOURCE_DIR}/src/core/lib/http/format_request.cc - ${GRPC_SOURCE_DIR}/src/core/lib/http/httpcli.cc - ${GRPC_SOURCE_DIR}/src/core/lib/http/parser.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/buffer_list.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/call_combiner.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/cfstream_handle.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/combiner.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/endpoint.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/endpoint_cfstream.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/endpoint_pair_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/endpoint_pair_uv.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/endpoint_pair_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/error.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/error_cfstream.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/ev_epoll1_linux.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/ev_epollex_linux.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/ev_poll_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/ev_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/ev_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/exec_ctx.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/executor.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/executor/mpmcqueue.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/executor/threadpool.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/fork_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/fork_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/gethostname_fallback.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/gethostname_host_name_max.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/gethostname_sysconf.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/internal_errqueue.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iocp_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr_internal.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr_posix_cfstream.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr_uv.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/iomgr_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/is_epollexclusive_available.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/load_file.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/lockfree_event.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/polling_entity.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset_set.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset_set_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset_set_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset_uv.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/pollset_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/resolve_address.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/resolve_address_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/resolve_address_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/resolve_address_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/resource_quota.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/sockaddr_utils.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_factory_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_mutator.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_utils_common_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_utils_linux.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_utils_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_utils_uv.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_utils_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/socket_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_client.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_client_cfstream.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_client_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_client_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_client_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server_utils_posix_common.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_server_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_uv.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/tcp_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/time_averaged_stats.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/timer.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/timer_custom.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/timer_generic.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/timer_heap.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/timer_manager.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/timer_uv.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/udp_server.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/unix_sockets_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/unix_sockets_posix_noop.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/wakeup_fd_eventfd.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/wakeup_fd_nospecial.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/wakeup_fd_pipe.cc - ${GRPC_SOURCE_DIR}/src/core/lib/iomgr/wakeup_fd_posix.cc - ${GRPC_SOURCE_DIR}/src/core/lib/json/json.cc - ${GRPC_SOURCE_DIR}/src/core/lib/json/json_reader.cc - ${GRPC_SOURCE_DIR}/src/core/lib/json/json_string.cc - ${GRPC_SOURCE_DIR}/src/core/lib/json/json_writer.cc - ${GRPC_SOURCE_DIR}/src/core/lib/slice/b64.cc - ${GRPC_SOURCE_DIR}/src/core/lib/slice/percent_encoding.cc - ${GRPC_SOURCE_DIR}/src/core/lib/slice/slice.cc - ${GRPC_SOURCE_DIR}/src/core/lib/slice/slice_buffer.cc - ${GRPC_SOURCE_DIR}/src/core/lib/slice/slice_intern.cc - ${GRPC_SOURCE_DIR}/src/core/lib/slice/slice_string_helpers.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/api_trace.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/byte_buffer.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/byte_buffer_reader.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/call.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/call_details.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/call_log_batch.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/channel.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/channel_init.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/channel_ping.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/channel_stack_type.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/completion_queue.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/completion_queue_factory.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/event_string.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/lame_client.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/metadata_array.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/server.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/validate_metadata.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/version.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/bdp_estimator.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/byte_stream.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/connectivity_state.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/error_utils.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/metadata.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/metadata_batch.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/pid_controller.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/static_metadata.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/status_conversion.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/status_metadata.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/timeout_encoding.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/transport.cc - ${GRPC_SOURCE_DIR}/src/core/lib/transport/transport_op_string.cc - ${GRPC_SOURCE_DIR}/src/core/lib/uri/uri_parser.cc - ${GRPC_SOURCE_DIR}/src/core/lib/debug/trace.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/cronet/transport/cronet_api_dummy.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/cronet/transport/cronet_transport.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/bin_decoder.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/bin_encoder.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/chttp2_transport.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/context_list.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/flow_control.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/frame_data.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/frame_goaway.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/frame_ping.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/frame_settings.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/frame_window_update.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/hpack_encoder.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/hpack_parser.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/hpack_table.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/http2_settings.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/huffsyms.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/incoming_metadata.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/parsing.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/stream_lists.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/stream_map.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/varint.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/transport/writing.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/alpn/alpn.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/http/client/http_client_filter.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/http/http_filters_plugin.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/http/message_compress/message_compress_filter.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/http/server/http_server_filter.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/backend_metric.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/backup_poller.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/channel_connectivity.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/client_channel.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/client_channel_channelz.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/client_channel_factory.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/client_channel_plugin.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/connector.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/global_subchannel_pool.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/health/health_check_client.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/http_connect_handshaker.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/http_proxy.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/lb_policy.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/lb_policy_registry.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/local_subchannel_pool.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/parse_address.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/proxy_mapper.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/proxy_mapper_registry.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/resolver.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/resolver_registry.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/resolver_result_parsing.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/resolving_lb_policy.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/retry_throttle.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/server_address.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/service_config.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/subchannel.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/client_channel/subchannel_pool_interface.cc - ${GRPC_SOURCE_DIR}/src/core/ext/filters/deadline/deadline_filter.cc - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - ${GRPC_SOURCE_DIR}/third_party/upb/upb/decode.c - ${GRPC_SOURCE_DIR}/third_party/upb/upb/encode.c - ${GRPC_SOURCE_DIR}/third_party/upb/upb/msg.c - ${GRPC_SOURCE_DIR}/third_party/upb/upb/port.c - ${GRPC_SOURCE_DIR}/third_party/upb/upb/table.c - ${GRPC_SOURCE_DIR}/third_party/upb/upb/upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/gogoproto/gogo.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/validate/validate.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/api/annotations.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/api/http.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/any.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/duration.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/empty.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/struct.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/google/rpc/status.upb.c - ${GRPC_SOURCE_DIR}/src/core/lib/http/httpcli_security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/context/security_context.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/alts_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/composite/composite_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/credentials_metadata.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/fake/fake_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/google_default/credentials_generic.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/google_default/google_default_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/iam/iam_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/jwt/json_token.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/jwt/jwt_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/jwt/jwt_verifier.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/local/local_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/plugin/plugin_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/ssl/ssl_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/tls/spiffe_credentials.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/alts/alts_security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/fake/fake_security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/load_system_roots_fallback.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/load_system_roots_linux.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/local/local_security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/ssl_utils.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/ssl_utils_config.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/transport/client_auth_filter.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/transport/secure_endpoint.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/transport/security_handshaker.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/transport/server_auth_filter.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/transport/target_authority_table.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/transport/tsi_error.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/util/json_util.cc - ${GRPC_SOURCE_DIR}/src/core/lib/surface/init_secure.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/crypt/aes_gcm.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/crypt/gsec.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/alts_counter.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/alts_crypter.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/alts_frame_protector.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/frame_protector/frame_handler.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/handshaker/alts_handshaker_client.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/handshaker/alts_shared_resource.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/check_gcp_environment.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc - ${GRPC_SOURCE_DIR}/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/handshaker/alts_tsi_utils.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/alts/handshaker/transport_security_common_api.cc - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c - ${GRPC_SOURCE_DIR}/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c - ${GRPC_SOURCE_DIR}/src/core/tsi/transport_security.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/client/insecure/channel_create.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/client/authority.cc - ${GRPC_SOURCE_DIR}/src/core/ext/transport/chttp2/client/chttp2_connector.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/fake_transport_security.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/local_transport_security.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/ssl/session_cache/ssl_session_cache.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/ssl_transport_security.cc - ${GRPC_SOURCE_DIR}/src/core/tsi/transport_security_grpc.cc -) - -target_include_directories(grpc_cronet - PUBLIC ${GRPC_INCLUDE_DIR} - PRIVATE ${GRPC_SOURCE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} -) -target_link_libraries(grpc_cronet - ${_gRPC_BASELIB_LIBRARIES} - ${_gRPC_SSL_LIBRARIES} - ${_gRPC_ZLIB_LIBRARIES} - ${_gRPC_CARES_LIBRARIES} - ${_gRPC_ADDRESS_SORTING_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr -) -if (_gRPC_PLATFORM_MAC) - target_link_libraries(grpc_cronet "-framework CoreFoundation") -endif() add_library(grpc_unsecure ${GRPC_SOURCE_DIR}/src/core/lib/surface/init.cc @@ -1254,31 +857,33 @@ add_library(grpc_unsecure ${GRPC_SOURCE_DIR}/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc ) - target_include_directories(grpc_unsecure PUBLIC ${GRPC_INCLUDE_DIR} PRIVATE ${GRPC_SOURCE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) + target_link_libraries(grpc_unsecure ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_CARES_LIBRARIES} ${_gRPC_ADDRESS_SORTING_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} gpr ) + if (_gRPC_PLATFORM_MAC) target_link_libraries(grpc_unsecure "-framework CoreFoundation") endif() + add_library(grpc++ ${GRPC_SOURCE_DIR}/src/cpp/client/insecure_credentials.cc ${GRPC_SOURCE_DIR}/src/cpp/client/secure_credentials.cc @@ -1335,8 +940,6 @@ add_library(grpc++ ${GRPC_SOURCE_DIR}/src/cpp/codegen/codegen_init.cc ) -target_compile_options(grpc++ PUBLIC -w) - target_include_directories(grpc++ PUBLIC ${GRPC_INCLUDE_DIR} PRIVATE ${GRPC_SOURCE_DIR} @@ -1348,10 +951,9 @@ target_include_directories(grpc++ PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTO_GENS_DIR} ) + target_link_libraries(grpc++ - ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -1359,6 +961,7 @@ target_link_libraries(grpc++ gpr ) + add_library(grpc++_unsecure ${GRPC_SOURCE_DIR}/src/cpp/client/insecure_credentials.cc ${GRPC_SOURCE_DIR}/src/cpp/common/insecure_create_auth_context.cc @@ -1408,21 +1011,19 @@ add_library(grpc++_unsecure ${GRPC_SOURCE_DIR}/src/cpp/codegen/codegen_init.cc ) -target_compile_options(grpc++_unsecure PUBLIC -w) - target_include_directories(grpc++_unsecure PUBLIC ${GRPC_INCLUDE_DIR} PRIVATE ${GRPC_SOURCE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) + target_link_libraries(grpc++_unsecure ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} @@ -1431,6 +1032,16 @@ target_link_libraries(grpc++_unsecure grpc_unsecure ) + +if (_gRPC_SSL_INCLUDE_DIR AND _gRPC_SSL_LIBRARIES) + add_library(libgrpc ALIAS grpc) + add_library(libgrpc++ ALIAS grpc++) +else() + add_library(libgrpc ALIAS grpc_unsecure) + add_library(libgrpc++ ALIAS grpc++_unsecure) +endif() + + add_library(grpc_plugin_support ${GRPC_SOURCE_DIR}/src/compiler/cpp_generator.cc ) @@ -1440,23 +1051,22 @@ target_include_directories(grpc_plugin_support PUBLIC ${GRPC_INCLUDE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTO_GENS_DIR} ) + target_link_libraries(grpc_plugin_support ${_gRPC_PROTOBUF_PROTOC_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} ) + add_executable(grpc_cpp_plugin ${GRPC_SOURCE_DIR}/src/compiler/cpp_plugin.cc ) @@ -1465,16 +1075,13 @@ target_include_directories(grpc_cpp_plugin PRIVATE ${GRPC_SOURCE_DIR} PUBLIC ${GRPC_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpc_cpp_plugin @@ -1483,4 +1090,3 @@ target_link_libraries(grpc_cpp_plugin ${_gRPC_ALLTARGETS_LIBRARIES} grpc_plugin_support ) - diff --git a/contrib/hyperscan-cmake/CMakeLists.txt b/contrib/hyperscan-cmake/CMakeLists.txt new file mode 100644 index 00000000000..1f30bfccbe8 --- /dev/null +++ b/contrib/hyperscan-cmake/CMakeLists.txt @@ -0,0 +1,250 @@ +option (ENABLE_HYPERSCAN "Enable hyperscan library" ${ENABLE_LIBRARIES}) + +if (NOT HAVE_SSSE3) + set (ENABLE_HYPERSCAN OFF) +endif () + +if (ENABLE_HYPERSCAN) + option (USE_INTERNAL_HYPERSCAN_LIBRARY "Use internal hyperscan library" ${NOT_UNBUNDLED}) + + if (USE_INTERNAL_HYPERSCAN_LIBRARY) + set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/hyperscan) + + set (SRCS + ${LIBRARY_DIR}/src/alloc.c + ${LIBRARY_DIR}/src/compiler/asserts.cpp + ${LIBRARY_DIR}/src/compiler/compiler.cpp + ${LIBRARY_DIR}/src/compiler/error.cpp + ${LIBRARY_DIR}/src/crc32.c + ${LIBRARY_DIR}/src/database.c + ${LIBRARY_DIR}/src/fdr/engine_description.cpp + ${LIBRARY_DIR}/src/fdr/fdr_compile_util.cpp + ${LIBRARY_DIR}/src/fdr/fdr_compile.cpp + ${LIBRARY_DIR}/src/fdr/fdr_confirm_compile.cpp + ${LIBRARY_DIR}/src/fdr/fdr_engine_description.cpp + ${LIBRARY_DIR}/src/fdr/fdr.c + ${LIBRARY_DIR}/src/fdr/flood_compile.cpp + ${LIBRARY_DIR}/src/fdr/teddy_compile.cpp + ${LIBRARY_DIR}/src/fdr/teddy_engine_description.cpp + ${LIBRARY_DIR}/src/fdr/teddy.c + ${LIBRARY_DIR}/src/grey.cpp + ${LIBRARY_DIR}/src/hs_valid_platform.c + ${LIBRARY_DIR}/src/hs_version.c + ${LIBRARY_DIR}/src/hs.cpp + ${LIBRARY_DIR}/src/hwlm/hwlm_build.cpp + ${LIBRARY_DIR}/src/hwlm/hwlm_literal.cpp + ${LIBRARY_DIR}/src/hwlm/hwlm.c + ${LIBRARY_DIR}/src/hwlm/noodle_build.cpp + ${LIBRARY_DIR}/src/hwlm/noodle_engine.c + ${LIBRARY_DIR}/src/nfa/accel_dfa_build_strat.cpp + ${LIBRARY_DIR}/src/nfa/accel.c + ${LIBRARY_DIR}/src/nfa/accelcompile.cpp + ${LIBRARY_DIR}/src/nfa/castle.c + ${LIBRARY_DIR}/src/nfa/castlecompile.cpp + ${LIBRARY_DIR}/src/nfa/dfa_build_strat.cpp + ${LIBRARY_DIR}/src/nfa/dfa_min.cpp + ${LIBRARY_DIR}/src/nfa/gough.c + ${LIBRARY_DIR}/src/nfa/goughcompile_accel.cpp + ${LIBRARY_DIR}/src/nfa/goughcompile_reg.cpp + ${LIBRARY_DIR}/src/nfa/goughcompile.cpp + ${LIBRARY_DIR}/src/nfa/lbr.c + ${LIBRARY_DIR}/src/nfa/limex_64.c + ${LIBRARY_DIR}/src/nfa/limex_accel.c + ${LIBRARY_DIR}/src/nfa/limex_compile.cpp + ${LIBRARY_DIR}/src/nfa/limex_native.c + ${LIBRARY_DIR}/src/nfa/limex_simd128.c + ${LIBRARY_DIR}/src/nfa/limex_simd256.c + ${LIBRARY_DIR}/src/nfa/limex_simd384.c + ${LIBRARY_DIR}/src/nfa/limex_simd512.c + ${LIBRARY_DIR}/src/nfa/mcclellan.c + ${LIBRARY_DIR}/src/nfa/mcclellancompile_util.cpp + ${LIBRARY_DIR}/src/nfa/mcclellancompile.cpp + ${LIBRARY_DIR}/src/nfa/mcsheng_compile.cpp + ${LIBRARY_DIR}/src/nfa/mcsheng_data.c + ${LIBRARY_DIR}/src/nfa/mcsheng.c + ${LIBRARY_DIR}/src/nfa/mpv.c + ${LIBRARY_DIR}/src/nfa/mpvcompile.cpp + ${LIBRARY_DIR}/src/nfa/nfa_api_dispatch.c + ${LIBRARY_DIR}/src/nfa/nfa_build_util.cpp + ${LIBRARY_DIR}/src/nfa/rdfa_graph.cpp + ${LIBRARY_DIR}/src/nfa/rdfa_merge.cpp + ${LIBRARY_DIR}/src/nfa/rdfa.cpp + ${LIBRARY_DIR}/src/nfa/repeat.c + ${LIBRARY_DIR}/src/nfa/repeatcompile.cpp + ${LIBRARY_DIR}/src/nfa/sheng.c + ${LIBRARY_DIR}/src/nfa/shengcompile.cpp + ${LIBRARY_DIR}/src/nfa/shufti.c + ${LIBRARY_DIR}/src/nfa/shufticompile.cpp + ${LIBRARY_DIR}/src/nfa/tamarama.c + ${LIBRARY_DIR}/src/nfa/tamaramacompile.cpp + ${LIBRARY_DIR}/src/nfa/truffle.c + ${LIBRARY_DIR}/src/nfa/trufflecompile.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_anchored_acyclic.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_anchored_dots.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_asserts.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_builder.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_calc_components.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_cyclic_redundancy.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_depth.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_dominators.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_edge_redundancy.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_equivalence.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_execute.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_expr_info.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_extparam.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_fixed_width.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_fuzzy.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_haig.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_holder.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_is_equal.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_lbr.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_limex_accel.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_limex.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_literal_analysis.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_literal_component.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_literal_decorated.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_mcclellan.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_misc_opt.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_netflow.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_prefilter.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_prune.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_puff.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_redundancy.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_region_redundancy.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_region.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_repeat.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_reports.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_restructuring.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_revacc.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_sep.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_small_literal_set.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_som_add_redundancy.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_som_util.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_som.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_split.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_squash.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_stop.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_uncalc_components.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_utf8.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_util.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_vacuous.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_violet.cpp + ${LIBRARY_DIR}/src/nfagraph/ng_width.cpp + ${LIBRARY_DIR}/src/nfagraph/ng.cpp + ${LIBRARY_DIR}/src/parser/AsciiComponentClass.cpp + ${LIBRARY_DIR}/src/parser/buildstate.cpp + ${LIBRARY_DIR}/src/parser/check_refs.cpp + ${LIBRARY_DIR}/src/parser/Component.cpp + ${LIBRARY_DIR}/src/parser/ComponentAlternation.cpp + ${LIBRARY_DIR}/src/parser/ComponentAssertion.cpp + ${LIBRARY_DIR}/src/parser/ComponentAtomicGroup.cpp + ${LIBRARY_DIR}/src/parser/ComponentBackReference.cpp + ${LIBRARY_DIR}/src/parser/ComponentBoundary.cpp + ${LIBRARY_DIR}/src/parser/ComponentByte.cpp + ${LIBRARY_DIR}/src/parser/ComponentClass.cpp + ${LIBRARY_DIR}/src/parser/ComponentCondReference.cpp + ${LIBRARY_DIR}/src/parser/ComponentEmpty.cpp + ${LIBRARY_DIR}/src/parser/ComponentEUS.cpp + ${LIBRARY_DIR}/src/parser/ComponentRepeat.cpp + ${LIBRARY_DIR}/src/parser/ComponentSequence.cpp + ${LIBRARY_DIR}/src/parser/ComponentVisitor.cpp + ${LIBRARY_DIR}/src/parser/ComponentWordBoundary.cpp + ${LIBRARY_DIR}/src/parser/ConstComponentVisitor.cpp + ${LIBRARY_DIR}/src/parser/control_verbs.cpp + ${LIBRARY_DIR}/src/parser/logical_combination.cpp + ${LIBRARY_DIR}/src/parser/parse_error.cpp + ${LIBRARY_DIR}/src/parser/parser_util.cpp + ${LIBRARY_DIR}/src/parser/Parser.cpp + ${LIBRARY_DIR}/src/parser/prefilter.cpp + ${LIBRARY_DIR}/src/parser/shortcut_literal.cpp + ${LIBRARY_DIR}/src/parser/ucp_table.cpp + ${LIBRARY_DIR}/src/parser/unsupported.cpp + ${LIBRARY_DIR}/src/parser/utf8_validate.cpp + ${LIBRARY_DIR}/src/parser/Utf8ComponentClass.cpp + ${LIBRARY_DIR}/src/rose/block.c + ${LIBRARY_DIR}/src/rose/catchup.c + ${LIBRARY_DIR}/src/rose/init.c + ${LIBRARY_DIR}/src/rose/match.c + ${LIBRARY_DIR}/src/rose/program_runtime.c + ${LIBRARY_DIR}/src/rose/rose_build_add_mask.cpp + ${LIBRARY_DIR}/src/rose/rose_build_add.cpp + ${LIBRARY_DIR}/src/rose/rose_build_anchored.cpp + ${LIBRARY_DIR}/src/rose/rose_build_bytecode.cpp + ${LIBRARY_DIR}/src/rose/rose_build_castle.cpp + ${LIBRARY_DIR}/src/rose/rose_build_compile.cpp + ${LIBRARY_DIR}/src/rose/rose_build_convert.cpp + ${LIBRARY_DIR}/src/rose/rose_build_dedupe.cpp + ${LIBRARY_DIR}/src/rose/rose_build_engine_blob.cpp + ${LIBRARY_DIR}/src/rose/rose_build_exclusive.cpp + ${LIBRARY_DIR}/src/rose/rose_build_groups.cpp + ${LIBRARY_DIR}/src/rose/rose_build_infix.cpp + ${LIBRARY_DIR}/src/rose/rose_build_instructions.cpp + ${LIBRARY_DIR}/src/rose/rose_build_lit_accel.cpp + ${LIBRARY_DIR}/src/rose/rose_build_long_lit.cpp + ${LIBRARY_DIR}/src/rose/rose_build_lookaround.cpp + ${LIBRARY_DIR}/src/rose/rose_build_matchers.cpp + ${LIBRARY_DIR}/src/rose/rose_build_merge.cpp + ${LIBRARY_DIR}/src/rose/rose_build_misc.cpp + ${LIBRARY_DIR}/src/rose/rose_build_program.cpp + ${LIBRARY_DIR}/src/rose/rose_build_role_aliasing.cpp + ${LIBRARY_DIR}/src/rose/rose_build_scatter.cpp + ${LIBRARY_DIR}/src/rose/rose_build_width.cpp + ${LIBRARY_DIR}/src/rose/rose_in_util.cpp + ${LIBRARY_DIR}/src/rose/stream.c + ${LIBRARY_DIR}/src/runtime.c + ${LIBRARY_DIR}/src/scratch.c + ${LIBRARY_DIR}/src/smallwrite/smallwrite_build.cpp + ${LIBRARY_DIR}/src/som/slot_manager.cpp + ${LIBRARY_DIR}/src/som/som_runtime.c + ${LIBRARY_DIR}/src/som/som_stream.c + ${LIBRARY_DIR}/src/stream_compress.c + ${LIBRARY_DIR}/src/util/alloc.cpp + ${LIBRARY_DIR}/src/util/charreach.cpp + ${LIBRARY_DIR}/src/util/clique.cpp + ${LIBRARY_DIR}/src/util/compile_context.cpp + ${LIBRARY_DIR}/src/util/compile_error.cpp + ${LIBRARY_DIR}/src/util/cpuid_flags.c + ${LIBRARY_DIR}/src/util/depth.cpp + ${LIBRARY_DIR}/src/util/fatbit_build.cpp + ${LIBRARY_DIR}/src/util/multibit_build.cpp + ${LIBRARY_DIR}/src/util/multibit.c + ${LIBRARY_DIR}/src/util/report_manager.cpp + ${LIBRARY_DIR}/src/util/simd_utils.c + ${LIBRARY_DIR}/src/util/state_compress.c + ${LIBRARY_DIR}/src/util/target_info.cpp + ${LIBRARY_DIR}/src/util/ue2string.cpp + ) + + add_library (hyperscan ${SRCS}) + + target_compile_definitions (hyperscan PUBLIC USE_HYPERSCAN=1) + target_compile_options (hyperscan + PRIVATE -g0 -march=corei7 # library has too much debug information + ) + target_include_directories (hyperscan + PRIVATE + common + ${LIBRARY_DIR}/include + ) + target_include_directories (hyperscan SYSTEM PUBLIC ${LIBRARY_DIR}/src) + if (ARCH_AMD64) + target_include_directories (hyperscan PRIVATE x86_64) + endif () + target_link_libraries (hyperscan PRIVATE boost::headers_only) + else () + find_library (LIBRARY_HYPERSCAN hs) + find_path (INCLUDE_HYPERSCAN NAMES hs.h HINTS /usr/include/hs) # Ubuntu puts headers in this folder + + add_library (hyperscan UNKNOWN IMPORTED GLOBAL) + set_target_properties (hyperscan PROPERTIES IMPORTED_LOCATION ${LIBRARY_HYPERSCAN}) + set_target_properties (hyperscan PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_HYPERSCAN}) + set_property(TARGET hyperscan APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USE_HYPERSCAN=1) + endif () + + message (STATUS "Using hyperscan") +else () + add_library (hyperscan INTERFACE) + target_compile_definitions (hyperscan INTERFACE USE_HYPERSCAN=0) + + message (STATUS "Not using hyperscan") +endif () diff --git a/contrib/hyperscan-cmake/common/hs_version.h b/contrib/hyperscan-cmake/common/hs_version.h new file mode 100644 index 00000000000..f6fa8cb209f --- /dev/null +++ b/contrib/hyperscan-cmake/common/hs_version.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HS_VERSION_H_C6428FAF8E3713 +#define HS_VERSION_H_C6428FAF8E3713 + +/** + * A version string to identify this release of Hyperscan. + */ +#define HS_VERSION_STRING "5.1.1 2000-01-01" + +#define HS_VERSION_32BIT ((5 << 24) | (1 << 16) | (1 << 8) | 0) + +#endif /* HS_VERSION_H_C6428FAF8E3713 */ + diff --git a/contrib/hyperscan-cmake/x86_64/config.h b/contrib/hyperscan-cmake/x86_64/config.h new file mode 100644 index 00000000000..4786e3f4e21 --- /dev/null +++ b/contrib/hyperscan-cmake/x86_64/config.h @@ -0,0 +1,106 @@ +/* used by cmake */ + +#ifndef CONFIG_H_ +#define CONFIG_H_ + +/* "Define if the build is 32 bit" */ +/* #undef ARCH_32_BIT */ + +/* "Define if the build is 64 bit" */ +#define ARCH_64_BIT + +/* "Define if building for IA32" */ +/* #undef ARCH_IA32 */ + +/* "Define if building for EM64T" */ +#define ARCH_X86_64 + +/* internal build, switch on dump support. */ +/* #undef DUMP_SUPPORT */ + +/* Define if building "fat" runtime. */ +/* #undef FAT_RUNTIME */ + +/* Define if building AVX-512 in the fat runtime. */ +/* #undef BUILD_AVX512 */ + +/* Define to 1 if `backtrace' works. */ +#define HAVE_BACKTRACE + +/* C compiler has __builtin_assume_aligned */ +#define HAVE_CC_BUILTIN_ASSUME_ALIGNED + +/* C++ compiler has __builtin_assume_aligned */ +#define HAVE_CXX_BUILTIN_ASSUME_ALIGNED + +/* C++ compiler has x86intrin.h */ +#define HAVE_CXX_X86INTRIN_H + +/* C compiler has x86intrin.h */ +#define HAVE_C_X86INTRIN_H + +/* C++ compiler has intrin.h */ +/* #undef HAVE_CXX_INTRIN_H */ + +/* C compiler has intrin.h */ +/* #undef HAVE_C_INTRIN_H */ + +/* Define to 1 if you have the declaration of `pthread_setaffinity_np', and to + 0 if you don't. */ +/* #undef HAVE_DECL_PTHREAD_SETAFFINITY_NP */ + +/* #undef HAVE_PTHREAD_NP_H */ + +/* Define to 1 if you have the `malloc_info' function. */ +/* #undef HAVE_MALLOC_INFO */ + +/* Define to 1 if you have the `memmem' function. */ +/* #undef HAVE_MEMMEM */ + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP + +/* Define to 1 if `posix_memalign' works. */ +#define HAVE_POSIX_MEMALIGN + +/* Define to 1 if you have the `setrlimit' function. */ +#define HAVE_SETRLIMIT + +/* Define to 1 if you have the `shmget' function. */ +/* #undef HAVE_SHMGET */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK + +/* Define if the sqlite3_open_v2 call is available */ +/* #undef HAVE_SQLITE3_OPEN_V2 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H + +/* Define to 1 if you have the `_aligned_malloc' function. */ +/* #undef HAVE__ALIGNED_MALLOC */ + +/* Define if compiler has __builtin_constant_p */ +#define HAVE__BUILTIN_CONSTANT_P + +/* Optimize, inline critical functions */ +#define HS_OPTIMIZE + +#define HS_VERSION +#define HS_MAJOR_VERSION +#define HS_MINOR_VERSION +#define HS_PATCH_VERSION + +#define BUILD_DATE + +/* define if this is a release build. */ +#define RELEASE_BUILD + +/* define if reverse_graph requires patch for boost 1.62.0 */ +/* #undef BOOST_REVGRAPH_PATCH */ + +#endif /* CONFIG_H_ */ diff --git a/contrib/jemalloc b/contrib/jemalloc index cd2931ad9bb..ea6b3e973b4 160000 --- a/contrib/jemalloc +++ b/contrib/jemalloc @@ -1 +1 @@ -Subproject commit cd2931ad9bbd78208565716ab102e86d858c2fff +Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756 diff --git a/contrib/jemalloc-cmake/CMakeLists.txt b/contrib/jemalloc-cmake/CMakeLists.txt index a92d9443b92..63c5a5e66ea 100644 --- a/contrib/jemalloc-cmake/CMakeLists.txt +++ b/contrib/jemalloc-cmake/CMakeLists.txt @@ -9,6 +9,23 @@ if (ENABLE_JEMALLOC) option (USE_INTERNAL_JEMALLOC "Use internal jemalloc library" ${NOT_UNBUNDLED}) if (USE_INTERNAL_JEMALLOC) + # ThreadPool select job randomly, and there can be some threads that had been + # performed some memory heavy task before and will be inactive for some time, + # but until it will became active again, the memory will not be freed since by + # default each thread has it's own arena, but there should be not more then + # 4*CPU arenas (see opt.nareans description). + # + # By enabling percpu_arena number of arenas limited to number of CPUs and hence + # this problem should go away. + set (JEMALLOC_CONFIG_MALLOC_CONF "percpu_arena:percpu,oversize_threshold:0") + # CACHE variable is empty, to allow changing defaults without necessity + # to purge cache + set (JEMALLOC_CONFIG_MALLOC_CONF_OVERRIDE "" CACHE STRING "Change default configuration string of JEMalloc" ) + if (JEMALLOC_CONFIG_MALLOC_CONF_OVERRIDE) + set (JEMALLOC_CONFIG_MALLOC_CONF "${JEMALLOC_CONFIG_MALLOC_CONF_OVERRIDE}") + endif() + message (STATUS "jemalloc malloc_conf: ${JEMALLOC_CONFIG_MALLOC_CONF}") + set (LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/jemalloc") set (SRCS @@ -44,6 +61,7 @@ if (ENABLE_JEMALLOC) ${LIBRARY_DIR}/src/ticker.c ${LIBRARY_DIR}/src/tsd.c ${LIBRARY_DIR}/src/witness.c + ${LIBRARY_DIR}/src/safety_check.c ) if (OS_DARWIN) list(APPEND SRCS ${LIBRARY_DIR}/src/zone.c) @@ -51,12 +69,20 @@ if (ENABLE_JEMALLOC) add_library(jemalloc ${SRCS}) target_include_directories(jemalloc PRIVATE ${LIBRARY_DIR}/include) - target_include_directories(jemalloc PUBLIC include) + target_include_directories(jemalloc SYSTEM PUBLIC include) + + set(JEMALLOC_INCLUDE) if (ARCH_AMD64) - target_include_directories(jemalloc PUBLIC include_linux_x86_64) + set(JEMALLOC_INCLUDE_PREFIX include_linux_x86_64) elseif (ARCH_ARM) - target_include_directories(jemalloc PUBLIC include_linux_aarch64) + set(JEMALLOC_INCLUDE_PREFIX include_linux_aarch64) endif () + target_include_directories(jemalloc SYSTEM PUBLIC + ${JEMALLOC_INCLUDE_PREFIX}) + configure_file(${JEMALLOC_INCLUDE_PREFIX}/jemalloc/internal/jemalloc_internal_defs.h.in + ${JEMALLOC_INCLUDE_PREFIX}/jemalloc/internal/jemalloc_internal_defs.h) + target_include_directories(jemalloc SYSTEM PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/${JEMALLOC_INCLUDE_PREFIX}/jemalloc/internal) target_compile_definitions(jemalloc PRIVATE -DJEMALLOC_NO_PRIVATE_NAMESPACE) @@ -69,7 +95,9 @@ if (ENABLE_JEMALLOC) endif () endif () - target_compile_options(jemalloc PUBLIC -Wno-redundant-decls) + target_compile_options(jemalloc PRIVATE -Wno-redundant-decls) + # for RTLD_NEXT + target_compile_options(jemalloc PRIVATE -D_GNU_SOURCE) else () find_library(LIBRARY_JEMALLOC jemalloc) find_path(INCLUDE_JEMALLOC jemalloc/jemalloc.h) diff --git a/contrib/jemalloc-cmake/include/jemalloc/jemalloc_defs.h b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_defs.h new file mode 100644 index 00000000000..6a03a231a0e --- /dev/null +++ b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_defs.h @@ -0,0 +1,49 @@ +/* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */ +/* Defined if __attribute__((...)) syntax is supported. */ +#define JEMALLOC_HAVE_ATTR + +/* Defined if alloc_size attribute is supported. */ +#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE + +/* Defined if format_arg(...) attribute is supported. */ +#define JEMALLOC_HAVE_ATTR_FORMAT_ARG + +/* Defined if format(gnu_printf, ...) attribute is supported. */ +#define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF + +/* Defined if format(printf, ...) attribute is supported. */ +#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF + +/* + * Define overrides for non-standard allocator-related functions if they are + * present on the system. + */ +#define JEMALLOC_OVERRIDE_MEMALIGN +#define JEMALLOC_OVERRIDE_VALLOC + +/* + * At least Linux omits the "const" in: + * + * size_t malloc_usable_size(const void *ptr); + * + * Match the operating system's prototype. + */ +#define JEMALLOC_USABLE_SIZE_CONST + +/* + * If defined, specify throw() for the public function prototypes when compiling + * with C++. The only justification for this is to match the prototypes that + * glibc defines. + */ +#define JEMALLOC_USE_CXX_THROW + +#ifdef _MSC_VER +# ifdef _WIN64 +# define LG_SIZEOF_PTR_WIN 3 +# else +# define LG_SIZEOF_PTR_WIN 2 +# endif +#endif + +/* sizeof(void *) == 2^LG_SIZEOF_PTR. */ +#define LG_SIZEOF_PTR 3 diff --git a/contrib/jemalloc-cmake/include/jemalloc/jemalloc_macros.h b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_macros.h new file mode 100644 index 00000000000..34235894285 --- /dev/null +++ b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_macros.h @@ -0,0 +1,129 @@ +#include +#include +#include +#include +#include + +#define JEMALLOC_VERSION "5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756" +#define JEMALLOC_VERSION_MAJOR 5 +#define JEMALLOC_VERSION_MINOR 2 +#define JEMALLOC_VERSION_BUGFIX 1 +#define JEMALLOC_VERSION_NREV 0 +#define JEMALLOC_VERSION_GID "ea6b3e973b477b8061e0076bb257dbd7f3faa756" +#define JEMALLOC_VERSION_GID_IDENT ea6b3e973b477b8061e0076bb257dbd7f3faa756 + +#define MALLOCX_LG_ALIGN(la) ((int)(la)) +#if LG_SIZEOF_PTR == 2 +# define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1)) +#else +# define MALLOCX_ALIGN(a) \ + ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \ + ffs((int)(((size_t)(a))>>32))+31)) +#endif +#define MALLOCX_ZERO ((int)0x40) +/* + * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1 + * encodes MALLOCX_TCACHE_NONE. + */ +#define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8)) +#define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1) +/* + * Bias arena index bits so that 0 encodes "use an automatically chosen arena". + */ +#define MALLOCX_ARENA(a) ((((int)(a))+1) << 20) + +/* + * Use as arena index in "arena..{purge,decay,dss}" and + * "stats.arenas..*" mallctl interfaces to select all arenas. This + * definition is intentionally specified in raw decimal format to support + * cpp-based string concatenation, e.g. + * + * #define STRINGIFY_HELPER(x) #x + * #define STRINGIFY(x) STRINGIFY_HELPER(x) + * + * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL, + * 0); + */ +#define MALLCTL_ARENAS_ALL 4096 +/* + * Use as arena index in "stats.arenas..*" mallctl interfaces to select + * destroyed arenas. + */ +#define MALLCTL_ARENAS_DESTROYED 4097 + +#if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW) +# define JEMALLOC_CXX_THROW throw() +#else +# define JEMALLOC_CXX_THROW +#endif + +#if defined(_MSC_VER) +# define JEMALLOC_ATTR(s) +# define JEMALLOC_ALIGNED(s) __declspec(align(s)) +# define JEMALLOC_ALLOC_SIZE(s) +# define JEMALLOC_ALLOC_SIZE2(s1, s2) +# ifndef JEMALLOC_EXPORT +# ifdef DLLEXPORT +# define JEMALLOC_EXPORT __declspec(dllexport) +# else +# define JEMALLOC_EXPORT __declspec(dllimport) +# endif +# endif +# define JEMALLOC_FORMAT_ARG(i) +# define JEMALLOC_FORMAT_PRINTF(s, i) +# define JEMALLOC_NOINLINE __declspec(noinline) +# ifdef __cplusplus +# define JEMALLOC_NOTHROW __declspec(nothrow) +# else +# define JEMALLOC_NOTHROW +# endif +# define JEMALLOC_SECTION(s) __declspec(allocate(s)) +# define JEMALLOC_RESTRICT_RETURN __declspec(restrict) +# if _MSC_VER >= 1900 && !defined(__EDG__) +# define JEMALLOC_ALLOCATOR __declspec(allocator) +# else +# define JEMALLOC_ALLOCATOR +# endif +#elif defined(JEMALLOC_HAVE_ATTR) +# define JEMALLOC_ATTR(s) __attribute__((s)) +# define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) +# ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE +# define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s)) +# define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2)) +# else +# define JEMALLOC_ALLOC_SIZE(s) +# define JEMALLOC_ALLOC_SIZE2(s1, s2) +# endif +# ifndef JEMALLOC_EXPORT +# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) +# endif +# ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG +# define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3)) +# else +# define JEMALLOC_FORMAT_ARG(i) +# endif +# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF +# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i)) +# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF) +# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i)) +# else +# define JEMALLOC_FORMAT_PRINTF(s, i) +# endif +# define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) +# define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) +# define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) +# define JEMALLOC_RESTRICT_RETURN +# define JEMALLOC_ALLOCATOR +#else +# define JEMALLOC_ATTR(s) +# define JEMALLOC_ALIGNED(s) +# define JEMALLOC_ALLOC_SIZE(s) +# define JEMALLOC_ALLOC_SIZE2(s1, s2) +# define JEMALLOC_EXPORT +# define JEMALLOC_FORMAT_PRINTF(s, i) +# define JEMALLOC_NOINLINE +# define JEMALLOC_NOTHROW +# define JEMALLOC_SECTION(s) +# define JEMALLOC_RESTRICT_RETURN +# define JEMALLOC_ALLOCATOR +#endif diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_protos.h b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_protos.h similarity index 100% rename from contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_protos.h rename to contrib/jemalloc-cmake/include/jemalloc/jemalloc_protos.h diff --git a/contrib/jemalloc-cmake/include/jemalloc/jemalloc_rename.h b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_rename.h index a2ea2dd3533..2e94f7a0cc3 100644 --- a/contrib/jemalloc-cmake/include/jemalloc/jemalloc_rename.h +++ b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_rename.h @@ -17,6 +17,7 @@ # define je_malloc_stats_print malloc_stats_print # define je_malloc_usable_size malloc_usable_size # define je_mallocx mallocx +# define je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 # define je_nallocx nallocx # define je_posix_memalign posix_memalign # define je_rallocx rallocx diff --git a/contrib/jemalloc-cmake/include/jemalloc/jemalloc_typedefs.h b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_typedefs.h new file mode 100644 index 00000000000..5f94f16f937 --- /dev/null +++ b/contrib/jemalloc-cmake/include/jemalloc/jemalloc_typedefs.h @@ -0,0 +1,77 @@ +typedef struct extent_hooks_s extent_hooks_t; + +/* + * void * + * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size, + * size_t alignment, bool *zero, bool *commit, unsigned arena_ind); + */ +typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *, + bool *, unsigned); + +/* + * bool + * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size, + * bool committed, unsigned arena_ind); + */ +typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool, + unsigned); + +/* + * void + * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size, + * bool committed, unsigned arena_ind); + */ +typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool, + unsigned); + +/* + * bool + * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size, + * size_t offset, size_t length, unsigned arena_ind); + */ +typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t, + unsigned); + +/* + * bool + * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size, + * size_t offset, size_t length, unsigned arena_ind); + */ +typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t, + size_t, unsigned); + +/* + * bool + * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size, + * size_t offset, size_t length, unsigned arena_ind); + */ +typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t, + unsigned); + +/* + * bool + * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size, + * size_t size_a, size_t size_b, bool committed, unsigned arena_ind); + */ +typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t, + bool, unsigned); + +/* + * bool + * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a, + * void *addr_b, size_t size_b, bool committed, unsigned arena_ind); + */ +typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t, + bool, unsigned); + +struct extent_hooks_s { + extent_alloc_t *alloc; + extent_dalloc_t *dalloc; + extent_destroy_t *destroy; + extent_commit_t *commit; + extent_decommit_t *decommit; + extent_purge_t *purge_lazy; + extent_purge_t *purge_forced; + extent_split_t *split; + extent_merge_t *merge; +}; diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/README b/contrib/jemalloc-cmake/include_linux_aarch64/README index 2ab582803a2..3cecf7fa36d 100644 --- a/contrib/jemalloc-cmake/include_linux_aarch64/README +++ b/contrib/jemalloc-cmake/include_linux_aarch64/README @@ -5,3 +5,4 @@ Added #define GNU_SOURCE Added JEMALLOC_OVERRIDE___POSIX_MEMALIGN because why not. Removed JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF because it's non standard. Removed JEMALLOC_PURGE_MADVISE_FREE because it's available only from Linux 4.5. +Added JEMALLOC_CONFIG_MALLOC_CONF substitution diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_internal_defs.h b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_internal_defs.h deleted file mode 100644 index 9c46a3a9320..00000000000 --- a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_internal_defs.h +++ /dev/null @@ -1,382 +0,0 @@ -/* include/jemalloc/internal/jemalloc_internal_defs.h. Generated from jemalloc_internal_defs.h.in by configure. */ -#ifndef JEMALLOC_INTERNAL_DEFS_H_ -#define JEMALLOC_INTERNAL_DEFS_H_ - - -#ifndef _GNU_SOURCE - #define _GNU_SOURCE -#endif - -/* - * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all - * public APIs to be prefixed. This makes it possible, with some care, to use - * multiple allocators simultaneously. - */ -/* #undef JEMALLOC_PREFIX */ -/* #undef JEMALLOC_CPREFIX */ - -/* - * Define overrides for non-standard allocator-related functions if they are - * present on the system. - */ -#define JEMALLOC_OVERRIDE___LIBC_CALLOC -#define JEMALLOC_OVERRIDE___LIBC_FREE -#define JEMALLOC_OVERRIDE___LIBC_MALLOC -#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN -#define JEMALLOC_OVERRIDE___LIBC_REALLOC -#define JEMALLOC_OVERRIDE___LIBC_VALLOC -#define JEMALLOC_OVERRIDE___POSIX_MEMALIGN - -/* - * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs. - * For shared libraries, symbol visibility mechanisms prevent these symbols - * from being exported, but for static libraries, naming collisions are a real - * possibility. - */ -#define JEMALLOC_PRIVATE_NAMESPACE je_ - -/* - * Hyper-threaded CPUs may need a special instruction inside spin loops in - * order to yield to another virtual CPU. - */ -#define CPU_SPINWAIT -/* 1 if CPU_SPINWAIT is defined, 0 otherwise. */ -#define HAVE_CPU_SPINWAIT 0 - -/* - * Number of significant bits in virtual addresses. This may be less than the - * total number of bits in a pointer, e.g. on x64, for which the uppermost 16 - * bits are the same as bit 47. - */ -#define LG_VADDR 48 - -/* Defined if C11 atomics are available. */ -#define JEMALLOC_C11_ATOMICS 1 - -/* Defined if GCC __atomic atomics are available. */ -#define JEMALLOC_GCC_ATOMIC_ATOMICS 1 - -/* Defined if GCC __sync atomics are available. */ -#define JEMALLOC_GCC_SYNC_ATOMICS 1 - -/* - * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and - * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the - * functions are defined in libgcc instead of being inlines). - */ -/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */ - -/* - * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and - * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the - * functions are defined in libgcc instead of being inlines). - */ -/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */ - -/* - * Defined if __builtin_clz() and __builtin_clzl() are available. - */ -#define JEMALLOC_HAVE_BUILTIN_CLZ - -/* - * Defined if os_unfair_lock_*() functions are available, as provided by Darwin. - */ -/* #undef JEMALLOC_OS_UNFAIR_LOCK */ - -/* - * Defined if OSSpin*() functions are available, as provided by Darwin, and - * documented in the spinlock(3) manual page. - */ -/* #undef JEMALLOC_OSSPIN */ - -/* Defined if syscall(2) is usable. */ -#define JEMALLOC_USE_SYSCALL - -/* - * Defined if secure_getenv(3) is available. - */ -#define JEMALLOC_HAVE_SECURE_GETENV - -/* - * Defined if issetugid(2) is available. - */ -/* #undef JEMALLOC_HAVE_ISSETUGID */ - -/* Defined if pthread_atfork(3) is available. */ -#define JEMALLOC_HAVE_PTHREAD_ATFORK - -/* Defined if pthread_setname_np(3) is available. */ -#define JEMALLOC_HAVE_PTHREAD_SETNAME_NP - -/* - * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. - */ -#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1 - -/* - * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available. - */ -#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1 - -/* - * Defined if mach_absolute_time() is available. - */ -/* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */ - -/* - * Defined if _malloc_thread_cleanup() exists. At least in the case of - * FreeBSD, pthread_key_create() allocates, which if used during malloc - * bootstrapping will cause recursion into the pthreads library. Therefore, if - * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in - * malloc_tsd. - */ -/* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */ - -/* - * Defined if threaded initialization is known to be safe on this platform. - * Among other things, it must be possible to initialize a mutex without - * triggering allocation in order for threaded allocation to be safe. - */ -#define JEMALLOC_THREADED_INIT - -/* - * Defined if the pthreads implementation defines - * _pthread_mutex_init_calloc_cb(), in which case the function is used in order - * to avoid recursive allocation during mutex initialization. - */ -/* #undef JEMALLOC_MUTEX_INIT_CB */ - -/* Non-empty if the tls_model attribute is supported. */ -#define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) - -/* - * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables - * inline functions. - */ -/* #undef JEMALLOC_DEBUG */ - -/* JEMALLOC_STATS enables statistics calculation. */ -#define JEMALLOC_STATS - -/* JEMALLOC_EXPERIMENTAL_SMALLOCX_API enables experimental smallocx API. */ -/* #undef JEMALLOC_EXPERIMENTAL_SMALLOCX_API */ - -/* JEMALLOC_PROF enables allocation profiling. */ -/* #undef JEMALLOC_PROF */ - -/* Use libunwind for profile backtracing if defined. */ -/* #undef JEMALLOC_PROF_LIBUNWIND */ - -/* Use libgcc for profile backtracing if defined. */ -/* #undef JEMALLOC_PROF_LIBGCC */ - -/* Use gcc intrinsics for profile backtracing if defined. */ -/* #undef JEMALLOC_PROF_GCC */ - -/* - * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage - * segment (DSS). - */ -#define JEMALLOC_DSS - -/* Support memory filling (junk/zero). */ -#define JEMALLOC_FILL - -/* Support utrace(2)-based tracing. */ -/* #undef JEMALLOC_UTRACE */ - -/* Support optional abort() on OOM. */ -/* #undef JEMALLOC_XMALLOC */ - -/* Support lazy locking (avoid locking unless a second thread is launched). */ -/* #undef JEMALLOC_LAZY_LOCK */ - -/* - * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size - * classes). - */ -/* #undef LG_QUANTUM */ - -/* One page is 2^LG_PAGE bytes. */ -#define LG_PAGE 16 - -/* - * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the - * system does not explicitly support huge pages; system calls that require - * explicit huge page support are separately configured. - */ -#define LG_HUGEPAGE 29 - -/* - * If defined, adjacent virtual memory mappings with identical attributes - * automatically coalesce, and they fragment when changes are made to subranges. - * This is the normal order of things for mmap()/munmap(), but on Windows - * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e. - * mappings do *not* coalesce/fragment. - */ -#define JEMALLOC_MAPS_COALESCE - -/* - * If defined, retain memory for later reuse by default rather than using e.g. - * munmap() to unmap freed extents. This is enabled on 64-bit Linux because - * common sequences of mmap()/munmap() calls will cause virtual memory map - * holes. - */ -#define JEMALLOC_RETAIN - -/* TLS is used to map arenas and magazine caches to threads. */ -#define JEMALLOC_TLS - -/* - * Used to mark unreachable code to quiet "end of non-void" compiler warnings. - * Don't use this directly; instead use unreachable() from util.h - */ -#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable - -/* - * ffs*() functions to use for bitmapping. Don't use these directly; instead, - * use ffs_*() from util.h. - */ -#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll -#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl -#define JEMALLOC_INTERNAL_FFS __builtin_ffs - -/* - * If defined, explicitly attempt to more uniformly distribute large allocation - * pointer alignments across all cache indices. - */ -#define JEMALLOC_CACHE_OBLIVIOUS - -/* - * If defined, enable logging facilities. We make this a configure option to - * avoid taking extra branches everywhere. - */ -/* #undef JEMALLOC_LOG */ - -/* - * If defined, use readlinkat() (instead of readlink()) to follow - * /etc/malloc_conf. - */ -/* #undef JEMALLOC_READLINKAT */ - -/* - * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. - */ -/* #undef JEMALLOC_ZONE */ - -/* - * Methods for determining whether the OS overcommits. - * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's - * /proc/sys/vm.overcommit_memory file. - * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl. - */ -/* #undef JEMALLOC_SYSCTL_VM_OVERCOMMIT */ -#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY - -/* Defined if madvise(2) is available. */ -#define JEMALLOC_HAVE_MADVISE - -/* - * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE - * arguments to madvise(2). - */ -#define JEMALLOC_HAVE_MADVISE_HUGE - -/* - * Methods for purging unused pages differ between operating systems. - * - * madvise(..., MADV_FREE) : This marks pages as being unused, such that they - * will be discarded rather than swapped out. - * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is - * defined, this immediately discards pages, - * such that new pages will be demand-zeroed if - * the address region is later touched; - * otherwise this behaves similarly to - * MADV_FREE, though typically with higher - * system overhead. - */ -// #define JEMALLOC_PURGE_MADVISE_FREE -#define JEMALLOC_PURGE_MADVISE_DONTNEED -#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS - -/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */ -/* #undef JEMALLOC_DEFINE_MADVISE_FREE */ - -/* - * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise. - */ -#define JEMALLOC_MADVISE_DONTDUMP - -/* - * Defined if transparent huge pages (THPs) are supported via the - * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled. - */ -/* #undef JEMALLOC_THP */ - -/* Define if operating system has alloca.h header. */ -#define JEMALLOC_HAS_ALLOCA_H 1 - -/* C99 restrict keyword supported. */ -#define JEMALLOC_HAS_RESTRICT 1 - -/* For use by hash code. */ -/* #undef JEMALLOC_BIG_ENDIAN */ - -/* sizeof(int) == 2^LG_SIZEOF_INT. */ -#define LG_SIZEOF_INT 2 - -/* sizeof(long) == 2^LG_SIZEOF_LONG. */ -#define LG_SIZEOF_LONG 3 - -/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */ -#define LG_SIZEOF_LONG_LONG 3 - -/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ -#define LG_SIZEOF_INTMAX_T 3 - -/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */ -#define JEMALLOC_GLIBC_MALLOC_HOOK - -/* glibc memalign hook. */ -#define JEMALLOC_GLIBC_MEMALIGN_HOOK - -/* pthread support */ -#define JEMALLOC_HAVE_PTHREAD - -/* dlsym() support */ -#define JEMALLOC_HAVE_DLSYM - -/* Adaptive mutex support in pthreads. */ -#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP - -/* GNU specific sched_getcpu support */ -#define JEMALLOC_HAVE_SCHED_GETCPU - -/* GNU specific sched_setaffinity support */ -#define JEMALLOC_HAVE_SCHED_SETAFFINITY - -/* - * If defined, all the features necessary for background threads are present. - */ -#define JEMALLOC_BACKGROUND_THREAD 1 - -/* - * If defined, jemalloc symbols are not exported (doesn't work when - * JEMALLOC_PREFIX is not defined). - */ -/* #undef JEMALLOC_EXPORT */ - -/* config.malloc_conf options string. */ -#define JEMALLOC_CONFIG_MALLOC_CONF "" - -/* If defined, jemalloc takes the malloc/free/etc. symbol names. */ -#define JEMALLOC_IS_MALLOC 1 - -/* - * Defined if strerror_r returns char * if _GNU_SOURCE is defined. - */ -#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE - -#endif /* JEMALLOC_INTERNAL_DEFS_H_ */ diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_internal_defs.h.in b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_internal_defs.h.in new file mode 100644 index 00000000000..cbd2740e1f1 --- /dev/null +++ b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_internal_defs.h.in @@ -0,0 +1,367 @@ +/* include/jemalloc/internal/jemalloc_internal_defs.h. Generated from jemalloc_internal_defs.h.in by configure. */ +#ifndef JEMALLOC_INTERNAL_DEFS_H_ +#define JEMALLOC_INTERNAL_DEFS_H_ +/* + * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all + * public APIs to be prefixed. This makes it possible, with some care, to use + * multiple allocators simultaneously. + */ +/* #undef JEMALLOC_PREFIX */ +/* #undef JEMALLOC_CPREFIX */ + +/* + * Define overrides for non-standard allocator-related functions if they are + * present on the system. + */ +#define JEMALLOC_OVERRIDE___LIBC_CALLOC +#define JEMALLOC_OVERRIDE___LIBC_FREE +#define JEMALLOC_OVERRIDE___LIBC_MALLOC +#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN +#define JEMALLOC_OVERRIDE___LIBC_REALLOC +#define JEMALLOC_OVERRIDE___LIBC_VALLOC +/* #undef JEMALLOC_OVERRIDE___POSIX_MEMALIGN */ + +/* + * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs. + * For shared libraries, symbol visibility mechanisms prevent these symbols + * from being exported, but for static libraries, naming collisions are a real + * possibility. + */ +#define JEMALLOC_PRIVATE_NAMESPACE je_ + +/* + * Hyper-threaded CPUs may need a special instruction inside spin loops in + * order to yield to another virtual CPU. + */ +#define CPU_SPINWAIT +/* 1 if CPU_SPINWAIT is defined, 0 otherwise. */ +#define HAVE_CPU_SPINWAIT 9 + +/* + * Number of significant bits in virtual addresses. This may be less than the + * total number of bits in a pointer, e.g. on x64, for which the uppermost 16 + * bits are the same as bit 47. + */ +#define LG_VADDR 48 + +/* Defined if C11 atomics are available. */ +#define JEMALLOC_C11_ATOMICS 1 + +/* Defined if GCC __atomic atomics are available. */ +#define JEMALLOC_GCC_ATOMIC_ATOMICS 1 +/* and the 8-bit variant support. */ +#define JEMALLOC_GCC_U8_ATOMIC_ATOMICS 1 + +/* Defined if GCC __sync atomics are available. */ +#define JEMALLOC_GCC_SYNC_ATOMICS 1 +/* and the 8-bit variant support. */ +#define JEMALLOC_GCC_U8_SYNC_ATOMICS 1 + +/* + * Defined if __builtin_clz() and __builtin_clzl() are available. + */ +#define JEMALLOC_HAVE_BUILTIN_CLZ + +/* + * Defined if os_unfair_lock_*() functions are available, as provided by Darwin. + */ +/* #undef JEMALLOC_OS_UNFAIR_LOCK */ + +/* Defined if syscall(2) is usable. */ +#define JEMALLOC_USE_SYSCALL + +/* + * Defined if secure_getenv(3) is available. + */ +// #define JEMALLOC_HAVE_SECURE_GETENV + +/* + * Defined if issetugid(2) is available. + */ +/* #undef JEMALLOC_HAVE_ISSETUGID */ + +/* Defined if pthread_atfork(3) is available. */ +#define JEMALLOC_HAVE_PTHREAD_ATFORK + +/* Defined if pthread_setname_np(3) is available. */ +#define JEMALLOC_HAVE_PTHREAD_SETNAME_NP + +/* + * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. + */ +#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1 + +/* + * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available. + */ +#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1 + +/* + * Defined if mach_absolute_time() is available. + */ +/* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */ + +/* + * Defined if _malloc_thread_cleanup() exists. At least in the case of + * FreeBSD, pthread_key_create() allocates, which if used during malloc + * bootstrapping will cause recursion into the pthreads library. Therefore, if + * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in + * malloc_tsd. + */ +/* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */ + +/* + * Defined if threaded initialization is known to be safe on this platform. + * Among other things, it must be possible to initialize a mutex without + * triggering allocation in order for threaded allocation to be safe. + */ +#define JEMALLOC_THREADED_INIT + +/* + * Defined if the pthreads implementation defines + * _pthread_mutex_init_calloc_cb(), in which case the function is used in order + * to avoid recursive allocation during mutex initialization. + */ +/* #undef JEMALLOC_MUTEX_INIT_CB */ + +/* Non-empty if the tls_model attribute is supported. */ +#define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) + +/* + * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables + * inline functions. + */ +/* #undef JEMALLOC_DEBUG */ + +/* JEMALLOC_STATS enables statistics calculation. */ +#define JEMALLOC_STATS + +/* JEMALLOC_EXPERIMENTAL_SMALLOCX_API enables experimental smallocx API. */ +/* #undef JEMALLOC_EXPERIMENTAL_SMALLOCX_API */ + +/* JEMALLOC_PROF enables allocation profiling. */ +/* #undef JEMALLOC_PROF */ + +/* Use libunwind for profile backtracing if defined. */ +/* #undef JEMALLOC_PROF_LIBUNWIND */ + +/* Use libgcc for profile backtracing if defined. */ +/* #undef JEMALLOC_PROF_LIBGCC */ + +/* Use gcc intrinsics for profile backtracing if defined. */ +/* #undef JEMALLOC_PROF_GCC */ + +/* + * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage + * segment (DSS). + */ +#define JEMALLOC_DSS + +/* Support memory filling (junk/zero). */ +#define JEMALLOC_FILL + +/* Support utrace(2)-based tracing. */ +/* #undef JEMALLOC_UTRACE */ + +/* Support optional abort() on OOM. */ +/* #undef JEMALLOC_XMALLOC */ + +/* Support lazy locking (avoid locking unless a second thread is launched). */ +/* #undef JEMALLOC_LAZY_LOCK */ + +/* + * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size + * classes). + */ +/* #undef LG_QUANTUM */ + +/* One page is 2^LG_PAGE bytes. */ +#define LG_PAGE 16 + +/* + * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the + * system does not explicitly support huge pages; system calls that require + * explicit huge page support are separately configured. + */ +#define LG_HUGEPAGE 29 + +/* + * If defined, adjacent virtual memory mappings with identical attributes + * automatically coalesce, and they fragment when changes are made to subranges. + * This is the normal order of things for mmap()/munmap(), but on Windows + * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e. + * mappings do *not* coalesce/fragment. + */ +#define JEMALLOC_MAPS_COALESCE + +/* + * If defined, retain memory for later reuse by default rather than using e.g. + * munmap() to unmap freed extents. This is enabled on 64-bit Linux because + * common sequences of mmap()/munmap() calls will cause virtual memory map + * holes. + */ +#define JEMALLOC_RETAIN + +/* TLS is used to map arenas and magazine caches to threads. */ +#define JEMALLOC_TLS + +/* + * Used to mark unreachable code to quiet "end of non-void" compiler warnings. + * Don't use this directly; instead use unreachable() from util.h + */ +#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable + +/* + * ffs*() functions to use for bitmapping. Don't use these directly; instead, + * use ffs_*() from util.h. + */ +#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll +#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl +#define JEMALLOC_INTERNAL_FFS __builtin_ffs + +/* + * popcount*() functions to use for bitmapping. + */ +#define JEMALLOC_INTERNAL_POPCOUNTL __builtin_popcountl +#define JEMALLOC_INTERNAL_POPCOUNT __builtin_popcount + +/* + * If defined, explicitly attempt to more uniformly distribute large allocation + * pointer alignments across all cache indices. + */ +#define JEMALLOC_CACHE_OBLIVIOUS + +/* + * If defined, enable logging facilities. We make this a configure option to + * avoid taking extra branches everywhere. + */ +/* #undef JEMALLOC_LOG */ + +/* + * If defined, use readlinkat() (instead of readlink()) to follow + * /etc/malloc_conf. + */ +/* #undef JEMALLOC_READLINKAT */ + +/* + * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. + */ +/* #undef JEMALLOC_ZONE */ + +/* + * Methods for determining whether the OS overcommits. + * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's + * /proc/sys/vm.overcommit_memory file. + * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl. + */ +/* #undef JEMALLOC_SYSCTL_VM_OVERCOMMIT */ +#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY + +/* Defined if madvise(2) is available. */ +#define JEMALLOC_HAVE_MADVISE + +/* + * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE + * arguments to madvise(2). + */ +#define JEMALLOC_HAVE_MADVISE_HUGE + +/* + * Methods for purging unused pages differ between operating systems. + * + * madvise(..., MADV_FREE) : This marks pages as being unused, such that they + * will be discarded rather than swapped out. + * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is + * defined, this immediately discards pages, + * such that new pages will be demand-zeroed if + * the address region is later touched; + * otherwise this behaves similarly to + * MADV_FREE, though typically with higher + * system overhead. + */ +#define JEMALLOC_PURGE_MADVISE_FREE +#define JEMALLOC_PURGE_MADVISE_DONTNEED +#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS + +/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */ +/* #undef JEMALLOC_DEFINE_MADVISE_FREE */ + +/* + * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise. + */ +#define JEMALLOC_MADVISE_DONTDUMP + +/* + * Defined if transparent huge pages (THPs) are supported via the + * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled. + */ +/* #undef JEMALLOC_THP */ + +/* Define if operating system has alloca.h header. */ +#define JEMALLOC_HAS_ALLOCA_H 1 + +/* C99 restrict keyword supported. */ +#define JEMALLOC_HAS_RESTRICT 1 + +/* For use by hash code. */ +/* #undef JEMALLOC_BIG_ENDIAN */ + +/* sizeof(int) == 2^LG_SIZEOF_INT. */ +#define LG_SIZEOF_INT 2 + +/* sizeof(long) == 2^LG_SIZEOF_LONG. */ +#define LG_SIZEOF_LONG 3 + +/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */ +#define LG_SIZEOF_LONG_LONG 3 + +/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ +#define LG_SIZEOF_INTMAX_T 3 + +/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */ +#define JEMALLOC_GLIBC_MALLOC_HOOK + +/* glibc memalign hook. */ +#define JEMALLOC_GLIBC_MEMALIGN_HOOK + +/* pthread support */ +#define JEMALLOC_HAVE_PTHREAD + +/* dlsym() support */ +#define JEMALLOC_HAVE_DLSYM + +/* Adaptive mutex support in pthreads. */ +#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP + +/* GNU specific sched_getcpu support */ +#define JEMALLOC_HAVE_SCHED_GETCPU + +/* GNU specific sched_setaffinity support */ +#define JEMALLOC_HAVE_SCHED_SETAFFINITY + +/* + * If defined, all the features necessary for background threads are present. + */ +#define JEMALLOC_BACKGROUND_THREAD 1 + +/* + * If defined, jemalloc symbols are not exported (doesn't work when + * JEMALLOC_PREFIX is not defined). + */ +/* #undef JEMALLOC_EXPORT */ + +/* config.malloc_conf options string. */ +#define JEMALLOC_CONFIG_MALLOC_CONF "@JEMALLOC_CONFIG_MALLOC_CONF@" + +/* If defined, jemalloc takes the malloc/free/etc. symbol names. */ +#define JEMALLOC_IS_MALLOC 1 + +/* + * Defined if strerror_r returns char * if _GNU_SOURCE is defined. + */ +#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE + +/* Performs additional safety checks when defined. */ +/* #undef JEMALLOC_OPT_SAFETY_CHECKS */ + +#endif /* JEMALLOC_INTERNAL_DEFS_H_ */ diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_preamble.h b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_preamble.h index c150785fb4a..e5e34925b55 100644 --- a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_preamble.h +++ b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/internal/jemalloc_preamble.h @@ -21,7 +21,7 @@ # include "jemalloc/jemalloc.h" #endif -#if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN)) +#if defined(JEMALLOC_OSATOMIC) #include #endif @@ -161,7 +161,26 @@ static const bool config_log = false #endif ; -#ifdef JEMALLOC_HAVE_SCHED_GETCPU +/* + * Are extra safety checks enabled; things like checking the size of sized + * deallocations, double-frees, etc. + */ +static const bool config_opt_safety_checks = +#ifdef JEMALLOC_OPT_SAFETY_CHECKS + true +#elif defined(JEMALLOC_DEBUG) + /* + * This lets us only guard safety checks by one flag instead of two; fast + * checks can guard solely by config_opt_safety_checks and run in debug mode + * too. + */ + true +#else + false +#endif + ; + +#if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU) /* Currently percpu_arena depends on sched_getcpu. */ #define JEMALLOC_PERCPU_ARENA #endif diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_defs.h b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_defs.h deleted file mode 100644 index d1389237a77..00000000000 --- a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_defs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */ -/* Defined if __attribute__((...)) syntax is supported. */ -#define JEMALLOC_HAVE_ATTR - -/* Defined if alloc_size attribute is supported. */ -#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE - -/* Defined if format(printf, ...) attribute is supported. */ -#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF - -/* - * Define overrides for non-standard allocator-related functions if they are - * present on the system. - */ -#define JEMALLOC_OVERRIDE_MEMALIGN -#define JEMALLOC_OVERRIDE_VALLOC - -/* - * At least Linux omits the "const" in: - * - * size_t malloc_usable_size(const void *ptr); - * - * Match the operating system's prototype. - */ -#define JEMALLOC_USABLE_SIZE_CONST - -/* - * If defined, specify throw() for the public function prototypes when compiling - * with C++. The only justification for this is to match the prototypes that - * glibc defines. - */ -#define JEMALLOC_USE_CXX_THROW - -#ifdef _MSC_VER -# ifdef _WIN64 -# define LG_SIZEOF_PTR_WIN 3 -# else -# define LG_SIZEOF_PTR_WIN 2 -# endif -#endif - -/* sizeof(void *) == 2^LG_SIZEOF_PTR. */ -#define LG_SIZEOF_PTR 3 diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_macros.h b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_macros.h deleted file mode 100644 index 79b13337fbb..00000000000 --- a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_macros.h +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include -#include -#include -#include - -#define JEMALLOC_VERSION "5.1.0-97-gcd2931ad9bbd78208565716ab102e86d858c2fff" -#define JEMALLOC_VERSION_MAJOR 5 -#define JEMALLOC_VERSION_MINOR 1 -#define JEMALLOC_VERSION_BUGFIX 0 -#define JEMALLOC_VERSION_NREV 97 -#define JEMALLOC_VERSION_GID "cd2931ad9bbd78208565716ab102e86d858c2fff" -#define JEMALLOC_VERSION_GID_IDENT cd2931ad9bbd78208565716ab102e86d858c2fff - -#define MALLOCX_LG_ALIGN(la) ((int)(la)) -#if LG_SIZEOF_PTR == 2 -# define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1)) -#else -# define MALLOCX_ALIGN(a) \ - ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \ - ffs((int)(((size_t)(a))>>32))+31)) -#endif -#define MALLOCX_ZERO ((int)0x40) -/* - * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1 - * encodes MALLOCX_TCACHE_NONE. - */ -#define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8)) -#define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1) -/* - * Bias arena index bits so that 0 encodes "use an automatically chosen arena". - */ -#define MALLOCX_ARENA(a) ((((int)(a))+1) << 20) - -/* - * Use as arena index in "arena..{purge,decay,dss}" and - * "stats.arenas..*" mallctl interfaces to select all arenas. This - * definition is intentionally specified in raw decimal format to support - * cpp-based string concatenation, e.g. - * - * #define STRINGIFY_HELPER(x) #x - * #define STRINGIFY(x) STRINGIFY_HELPER(x) - * - * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL, - * 0); - */ -#define MALLCTL_ARENAS_ALL 4096 -/* - * Use as arena index in "stats.arenas..*" mallctl interfaces to select - * destroyed arenas. - */ -#define MALLCTL_ARENAS_DESTROYED 4097 - -#if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW) -# define JEMALLOC_CXX_THROW throw() -#else -# define JEMALLOC_CXX_THROW -#endif - -#if defined(_MSC_VER) -# define JEMALLOC_ATTR(s) -# define JEMALLOC_ALIGNED(s) __declspec(align(s)) -# define JEMALLOC_ALLOC_SIZE(s) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) -# ifndef JEMALLOC_EXPORT -# ifdef DLLEXPORT -# define JEMALLOC_EXPORT __declspec(dllexport) -# else -# define JEMALLOC_EXPORT __declspec(dllimport) -# endif -# endif -# define JEMALLOC_FORMAT_PRINTF(s, i) -# define JEMALLOC_NOINLINE __declspec(noinline) -# ifdef __cplusplus -# define JEMALLOC_NOTHROW __declspec(nothrow) -# else -# define JEMALLOC_NOTHROW -# endif -# define JEMALLOC_SECTION(s) __declspec(allocate(s)) -# define JEMALLOC_RESTRICT_RETURN __declspec(restrict) -# if _MSC_VER >= 1900 && !defined(__EDG__) -# define JEMALLOC_ALLOCATOR __declspec(allocator) -# else -# define JEMALLOC_ALLOCATOR -# endif -#elif defined(JEMALLOC_HAVE_ATTR) -# define JEMALLOC_ATTR(s) __attribute__((s)) -# define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) -# ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE -# define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s)) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2)) -# else -# define JEMALLOC_ALLOC_SIZE(s) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) -# endif -# ifndef JEMALLOC_EXPORT -# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) -# endif -# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF -# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i)) -# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF) -# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i)) -# else -# define JEMALLOC_FORMAT_PRINTF(s, i) -# endif -# define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) -# define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) -# define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) -# define JEMALLOC_RESTRICT_RETURN -# define JEMALLOC_ALLOCATOR -#else -# define JEMALLOC_ATTR(s) -# define JEMALLOC_ALIGNED(s) -# define JEMALLOC_ALLOC_SIZE(s) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) -# define JEMALLOC_EXPORT -# define JEMALLOC_FORMAT_PRINTF(s, i) -# define JEMALLOC_NOINLINE -# define JEMALLOC_NOTHROW -# define JEMALLOC_SECTION(s) -# define JEMALLOC_RESTRICT_RETURN -# define JEMALLOC_ALLOCATOR -#endif diff --git a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_typedefs.h b/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_typedefs.h deleted file mode 100644 index 1a58874306e..00000000000 --- a/contrib/jemalloc-cmake/include_linux_aarch64/jemalloc/jemalloc_typedefs.h +++ /dev/null @@ -1,77 +0,0 @@ -typedef struct extent_hooks_s extent_hooks_t; - -/* - * void * - * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size, - * size_t alignment, bool *zero, bool *commit, unsigned arena_ind); - */ -typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *, - bool *, unsigned); - -/* - * bool - * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size, - * bool committed, unsigned arena_ind); - */ -typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool, - unsigned); - -/* - * void - * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size, - * bool committed, unsigned arena_ind); - */ -typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool, - unsigned); - -/* - * bool - * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t offset, size_t length, unsigned arena_ind); - */ -typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t, - unsigned); - -/* - * bool - * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t offset, size_t length, unsigned arena_ind); - */ -typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t, - size_t, unsigned); - -/* - * bool - * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t offset, size_t length, unsigned arena_ind); - */ -typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t, - unsigned); - -/* - * bool - * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t size_a, size_t size_b, bool committed, unsigned arena_ind); - */ -typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t, - bool, unsigned); - -/* - * bool - * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a, - * void *addr_b, size_t size_b, bool committed, unsigned arena_ind); - */ -typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t, - bool, unsigned); - -struct extent_hooks_s { - extent_alloc_t *alloc; - extent_dalloc_t *dalloc; - extent_destroy_t *destroy; - extent_commit_t *commit; - extent_decommit_t *decommit; - extent_purge_t *purge_lazy; - extent_purge_t *purge_forced; - extent_split_t *split; - extent_merge_t *merge; -}; diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/README b/contrib/jemalloc-cmake/include_linux_x86_64/README index bf7663bda8d..8b93e0d4dcd 100644 --- a/contrib/jemalloc-cmake/include_linux_x86_64/README +++ b/contrib/jemalloc-cmake/include_linux_x86_64/README @@ -5,3 +5,4 @@ Added #define GNU_SOURCE Added JEMALLOC_OVERRIDE___POSIX_MEMALIGN because why not. Removed JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF because it's non standard. Removed JEMALLOC_PURGE_MADVISE_FREE because it's available only from Linux 4.5. +Added JEMALLOC_CONFIG_MALLOC_CONF substitution diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_internal_defs.h b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_internal_defs.h deleted file mode 100644 index 43936e8eba0..00000000000 --- a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_internal_defs.h +++ /dev/null @@ -1,373 +0,0 @@ -/* include/jemalloc/internal/jemalloc_internal_defs.h. Generated from jemalloc_internal_defs.h.in by configure. */ -#ifndef JEMALLOC_INTERNAL_DEFS_H_ -#define JEMALLOC_INTERNAL_DEFS_H_ - -#ifndef _GNU_SOURCE - #define _GNU_SOURCE -#endif - -/* - * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all - * public APIs to be prefixed. This makes it possible, with some care, to use - * multiple allocators simultaneously. - */ -/* #undef JEMALLOC_PREFIX */ -/* #undef JEMALLOC_CPREFIX */ - -/* - * Define overrides for non-standard allocator-related functions if they are - * present on the system. - */ -#define JEMALLOC_OVERRIDE___LIBC_CALLOC -#define JEMALLOC_OVERRIDE___LIBC_FREE -#define JEMALLOC_OVERRIDE___LIBC_MALLOC -#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN -#define JEMALLOC_OVERRIDE___LIBC_REALLOC -#define JEMALLOC_OVERRIDE___LIBC_VALLOC -#define JEMALLOC_OVERRIDE___POSIX_MEMALIGN - -/* - * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs. - * For shared libraries, symbol visibility mechanisms prevent these symbols - * from being exported, but for static libraries, naming collisions are a real - * possibility. - */ -#define JEMALLOC_PRIVATE_NAMESPACE je_ - -/* - * Hyper-threaded CPUs may need a special instruction inside spin loops in - * order to yield to another virtual CPU. - */ -#define CPU_SPINWAIT __asm__ volatile("pause") -/* 1 if CPU_SPINWAIT is defined, 0 otherwise. */ -#define HAVE_CPU_SPINWAIT 1 - -/* - * Number of significant bits in virtual addresses. This may be less than the - * total number of bits in a pointer, e.g. on x64, for which the uppermost 16 - * bits are the same as bit 47. - */ -#define LG_VADDR 48 - -/* Defined if C11 atomics are available. */ -#define JEMALLOC_C11_ATOMICS 1 - -/* Defined if GCC __atomic atomics are available. */ -#define JEMALLOC_GCC_ATOMIC_ATOMICS 1 - -/* Defined if GCC __sync atomics are available. */ -#define JEMALLOC_GCC_SYNC_ATOMICS 1 - -/* - * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and - * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the - * functions are defined in libgcc instead of being inlines). - */ -/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */ - -/* - * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and - * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the - * functions are defined in libgcc instead of being inlines). - */ -/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */ - -/* - * Defined if __builtin_clz() and __builtin_clzl() are available. - */ -#define JEMALLOC_HAVE_BUILTIN_CLZ - -/* - * Defined if os_unfair_lock_*() functions are available, as provided by Darwin. - */ -/* #undef JEMALLOC_OS_UNFAIR_LOCK */ - -/* - * Defined if OSSpin*() functions are available, as provided by Darwin, and - * documented in the spinlock(3) manual page. - */ -/* #undef JEMALLOC_OSSPIN */ - -/* Defined if syscall(2) is usable. */ -#define JEMALLOC_USE_SYSCALL - -/* - * Defined if secure_getenv(3) is available. - */ -// Don't want dependency on newer GLIBC -//#define JEMALLOC_HAVE_SECURE_GETENV - -/* - * Defined if issetugid(2) is available. - */ -/* #undef JEMALLOC_HAVE_ISSETUGID */ - -/* Defined if pthread_atfork(3) is available. */ -#define JEMALLOC_HAVE_PTHREAD_ATFORK - -/* Defined if pthread_setname_np(3) is available. */ -#define JEMALLOC_HAVE_PTHREAD_SETNAME_NP - -/* - * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. - */ -#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1 - -/* - * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available. - */ -#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1 - -/* - * Defined if mach_absolute_time() is available. - */ -/* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */ - -/* - * Defined if _malloc_thread_cleanup() exists. At least in the case of - * FreeBSD, pthread_key_create() allocates, which if used during malloc - * bootstrapping will cause recursion into the pthreads library. Therefore, if - * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in - * malloc_tsd. - */ -/* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */ - -/* - * Defined if threaded initialization is known to be safe on this platform. - * Among other things, it must be possible to initialize a mutex without - * triggering allocation in order for threaded allocation to be safe. - */ -#define JEMALLOC_THREADED_INIT - -/* - * Defined if the pthreads implementation defines - * _pthread_mutex_init_calloc_cb(), in which case the function is used in order - * to avoid recursive allocation during mutex initialization. - */ -/* #undef JEMALLOC_MUTEX_INIT_CB */ - -/* Non-empty if the tls_model attribute is supported. */ -#define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) - -/* - * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables - * inline functions. - */ -/* #undef JEMALLOC_DEBUG */ - -/* JEMALLOC_STATS enables statistics calculation. */ -#define JEMALLOC_STATS - -/* JEMALLOC_PROF enables allocation profiling. */ -/* #undef JEMALLOC_PROF */ - -/* Use libunwind for profile backtracing if defined. */ -/* #undef JEMALLOC_PROF_LIBUNWIND */ - -/* Use libgcc for profile backtracing if defined. */ -/* #undef JEMALLOC_PROF_LIBGCC */ - -/* Use gcc intrinsics for profile backtracing if defined. */ -/* #undef JEMALLOC_PROF_GCC */ - -/* - * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage - * segment (DSS). - */ -#define JEMALLOC_DSS - -/* Support memory filling (junk/zero). */ -#define JEMALLOC_FILL - -/* Support utrace(2)-based tracing. */ -/* #undef JEMALLOC_UTRACE */ - -/* Support optional abort() on OOM. */ -/* #undef JEMALLOC_XMALLOC */ - -/* Support lazy locking (avoid locking unless a second thread is launched). */ -/* #undef JEMALLOC_LAZY_LOCK */ - -/* - * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size - * classes). - */ -/* #undef LG_QUANTUM */ - -/* One page is 2^LG_PAGE bytes. */ -#define LG_PAGE 12 - -/* - * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the - * system does not explicitly support huge pages; system calls that require - * explicit huge page support are separately configured. - */ -#define LG_HUGEPAGE 21 - -/* - * If defined, adjacent virtual memory mappings with identical attributes - * automatically coalesce, and they fragment when changes are made to subranges. - * This is the normal order of things for mmap()/munmap(), but on Windows - * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e. - * mappings do *not* coalesce/fragment. - */ -#define JEMALLOC_MAPS_COALESCE - -/* - * If defined, retain memory for later reuse by default rather than using e.g. - * munmap() to unmap freed extents. This is enabled on 64-bit Linux because - * common sequences of mmap()/munmap() calls will cause virtual memory map - * holes. - */ -#define JEMALLOC_RETAIN - -/* TLS is used to map arenas and magazine caches to threads. */ -#define JEMALLOC_TLS - -/* - * Used to mark unreachable code to quiet "end of non-void" compiler warnings. - * Don't use this directly; instead use unreachable() from util.h - */ -#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable - -/* - * ffs*() functions to use for bitmapping. Don't use these directly; instead, - * use ffs_*() from util.h. - */ -#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll -#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl -#define JEMALLOC_INTERNAL_FFS __builtin_ffs - -/* - * If defined, explicitly attempt to more uniformly distribute large allocation - * pointer alignments across all cache indices. - */ -#define JEMALLOC_CACHE_OBLIVIOUS - -/* - * If defined, enable logging facilities. We make this a configure option to - * avoid taking extra branches everywhere. - */ -/* #undef JEMALLOC_LOG */ - -/* - * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. - */ -/* #undef JEMALLOC_ZONE */ - -/* - * Methods for determining whether the OS overcommits. - * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's - * /proc/sys/vm.overcommit_memory file. - * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl. - */ -/* #undef JEMALLOC_SYSCTL_VM_OVERCOMMIT */ -#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY - -/* Defined if madvise(2) is available. */ -#define JEMALLOC_HAVE_MADVISE - -/* - * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE - * arguments to madvise(2). - */ -#define JEMALLOC_HAVE_MADVISE_HUGE - -/* - * Methods for purging unused pages differ between operating systems. - * - * madvise(..., MADV_FREE) : This marks pages as being unused, such that they - * will be discarded rather than swapped out. - * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is - * defined, this immediately discards pages, - * such that new pages will be demand-zeroed if - * the address region is later touched; - * otherwise this behaves similarly to - * MADV_FREE, though typically with higher - * system overhead. - */ -//#define JEMALLOC_PURGE_MADVISE_FREE -#define JEMALLOC_PURGE_MADVISE_DONTNEED -#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS - -/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */ -/* #undef JEMALLOC_DEFINE_MADVISE_FREE */ - -/* - * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise. - */ -#define JEMALLOC_MADVISE_DONTDUMP - -/* - * Defined if transparent huge pages (THPs) are supported via the - * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled. - */ -/* #undef JEMALLOC_THP */ - -/* Define if operating system has alloca.h header. */ -#define JEMALLOC_HAS_ALLOCA_H 1 - -/* C99 restrict keyword supported. */ -#define JEMALLOC_HAS_RESTRICT 1 - -/* For use by hash code. */ -/* #undef JEMALLOC_BIG_ENDIAN */ - -/* sizeof(int) == 2^LG_SIZEOF_INT. */ -#define LG_SIZEOF_INT 2 - -/* sizeof(long) == 2^LG_SIZEOF_LONG. */ -#define LG_SIZEOF_LONG 3 - -/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */ -#define LG_SIZEOF_LONG_LONG 3 - -/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ -#define LG_SIZEOF_INTMAX_T 3 - -/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */ -#define JEMALLOC_GLIBC_MALLOC_HOOK - -/* glibc memalign hook. */ -#define JEMALLOC_GLIBC_MEMALIGN_HOOK - -/* pthread support */ -#define JEMALLOC_HAVE_PTHREAD - -/* dlsym() support */ -#define JEMALLOC_HAVE_DLSYM - -/* Adaptive mutex support in pthreads. */ -#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP - -/* GNU specific sched_getcpu support */ -#define JEMALLOC_HAVE_SCHED_GETCPU - -/* GNU specific sched_setaffinity support */ -#define JEMALLOC_HAVE_SCHED_SETAFFINITY - -/* - * If defined, all the features necessary for background threads are present. - */ -#define JEMALLOC_BACKGROUND_THREAD 1 - -/* - * If defined, jemalloc symbols are not exported (doesn't work when - * JEMALLOC_PREFIX is not defined). - */ -/* #undef JEMALLOC_EXPORT */ - -/* config.malloc_conf options string. */ -#define JEMALLOC_CONFIG_MALLOC_CONF "" - -/* If defined, jemalloc takes the malloc/free/etc. symbol names. */ -#define JEMALLOC_IS_MALLOC 1 - -/* - * Defined if strerror_r returns char * if _GNU_SOURCE is defined. - */ -#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE - -#endif /* JEMALLOC_INTERNAL_DEFS_H_ */ diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_internal_defs.h.in b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_internal_defs.h.in new file mode 100644 index 00000000000..d5cf0e719ef --- /dev/null +++ b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_internal_defs.h.in @@ -0,0 +1,367 @@ +/* include/jemalloc/internal/jemalloc_internal_defs.h. Generated from jemalloc_internal_defs.h.in by configure. */ +#ifndef JEMALLOC_INTERNAL_DEFS_H_ +#define JEMALLOC_INTERNAL_DEFS_H_ +/* + * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all + * public APIs to be prefixed. This makes it possible, with some care, to use + * multiple allocators simultaneously. + */ +/* #undef JEMALLOC_PREFIX */ +/* #undef JEMALLOC_CPREFIX */ + +/* + * Define overrides for non-standard allocator-related functions if they are + * present on the system. + */ +#define JEMALLOC_OVERRIDE___LIBC_CALLOC +#define JEMALLOC_OVERRIDE___LIBC_FREE +#define JEMALLOC_OVERRIDE___LIBC_MALLOC +#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN +#define JEMALLOC_OVERRIDE___LIBC_REALLOC +#define JEMALLOC_OVERRIDE___LIBC_VALLOC +/* #undef JEMALLOC_OVERRIDE___POSIX_MEMALIGN */ + +/* + * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs. + * For shared libraries, symbol visibility mechanisms prevent these symbols + * from being exported, but for static libraries, naming collisions are a real + * possibility. + */ +#define JEMALLOC_PRIVATE_NAMESPACE je_ + +/* + * Hyper-threaded CPUs may need a special instruction inside spin loops in + * order to yield to another virtual CPU. + */ +#define CPU_SPINWAIT __asm__ volatile("pause") +/* 1 if CPU_SPINWAIT is defined, 0 otherwise. */ +#define HAVE_CPU_SPINWAIT 1 + +/* + * Number of significant bits in virtual addresses. This may be less than the + * total number of bits in a pointer, e.g. on x64, for which the uppermost 16 + * bits are the same as bit 47. + */ +#define LG_VADDR 48 + +/* Defined if C11 atomics are available. */ +#define JEMALLOC_C11_ATOMICS 1 + +/* Defined if GCC __atomic atomics are available. */ +#define JEMALLOC_GCC_ATOMIC_ATOMICS 1 +/* and the 8-bit variant support. */ +#define JEMALLOC_GCC_U8_ATOMIC_ATOMICS 1 + +/* Defined if GCC __sync atomics are available. */ +#define JEMALLOC_GCC_SYNC_ATOMICS 1 +/* and the 8-bit variant support. */ +#define JEMALLOC_GCC_U8_SYNC_ATOMICS 1 + +/* + * Defined if __builtin_clz() and __builtin_clzl() are available. + */ +#define JEMALLOC_HAVE_BUILTIN_CLZ + +/* + * Defined if os_unfair_lock_*() functions are available, as provided by Darwin. + */ +/* #undef JEMALLOC_OS_UNFAIR_LOCK */ + +/* Defined if syscall(2) is usable. */ +#define JEMALLOC_USE_SYSCALL + +/* + * Defined if secure_getenv(3) is available. + */ +// #define JEMALLOC_HAVE_SECURE_GETENV + +/* + * Defined if issetugid(2) is available. + */ +/* #undef JEMALLOC_HAVE_ISSETUGID */ + +/* Defined if pthread_atfork(3) is available. */ +#define JEMALLOC_HAVE_PTHREAD_ATFORK + +/* Defined if pthread_setname_np(3) is available. */ +#define JEMALLOC_HAVE_PTHREAD_SETNAME_NP + +/* + * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. + */ +#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1 + +/* + * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available. + */ +#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1 + +/* + * Defined if mach_absolute_time() is available. + */ +/* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */ + +/* + * Defined if _malloc_thread_cleanup() exists. At least in the case of + * FreeBSD, pthread_key_create() allocates, which if used during malloc + * bootstrapping will cause recursion into the pthreads library. Therefore, if + * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in + * malloc_tsd. + */ +/* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */ + +/* + * Defined if threaded initialization is known to be safe on this platform. + * Among other things, it must be possible to initialize a mutex without + * triggering allocation in order for threaded allocation to be safe. + */ +#define JEMALLOC_THREADED_INIT + +/* + * Defined if the pthreads implementation defines + * _pthread_mutex_init_calloc_cb(), in which case the function is used in order + * to avoid recursive allocation during mutex initialization. + */ +/* #undef JEMALLOC_MUTEX_INIT_CB */ + +/* Non-empty if the tls_model attribute is supported. */ +#define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) + +/* + * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables + * inline functions. + */ +/* #undef JEMALLOC_DEBUG */ + +/* JEMALLOC_STATS enables statistics calculation. */ +#define JEMALLOC_STATS + +/* JEMALLOC_EXPERIMENTAL_SMALLOCX_API enables experimental smallocx API. */ +/* #undef JEMALLOC_EXPERIMENTAL_SMALLOCX_API */ + +/* JEMALLOC_PROF enables allocation profiling. */ +/* #undef JEMALLOC_PROF */ + +/* Use libunwind for profile backtracing if defined. */ +/* #undef JEMALLOC_PROF_LIBUNWIND */ + +/* Use libgcc for profile backtracing if defined. */ +/* #undef JEMALLOC_PROF_LIBGCC */ + +/* Use gcc intrinsics for profile backtracing if defined. */ +/* #undef JEMALLOC_PROF_GCC */ + +/* + * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage + * segment (DSS). + */ +#define JEMALLOC_DSS + +/* Support memory filling (junk/zero). */ +#define JEMALLOC_FILL + +/* Support utrace(2)-based tracing. */ +/* #undef JEMALLOC_UTRACE */ + +/* Support optional abort() on OOM. */ +/* #undef JEMALLOC_XMALLOC */ + +/* Support lazy locking (avoid locking unless a second thread is launched). */ +/* #undef JEMALLOC_LAZY_LOCK */ + +/* + * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size + * classes). + */ +/* #undef LG_QUANTUM */ + +/* One page is 2^LG_PAGE bytes. */ +#define LG_PAGE 12 + +/* + * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the + * system does not explicitly support huge pages; system calls that require + * explicit huge page support are separately configured. + */ +#define LG_HUGEPAGE 21 + +/* + * If defined, adjacent virtual memory mappings with identical attributes + * automatically coalesce, and they fragment when changes are made to subranges. + * This is the normal order of things for mmap()/munmap(), but on Windows + * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e. + * mappings do *not* coalesce/fragment. + */ +#define JEMALLOC_MAPS_COALESCE + +/* + * If defined, retain memory for later reuse by default rather than using e.g. + * munmap() to unmap freed extents. This is enabled on 64-bit Linux because + * common sequences of mmap()/munmap() calls will cause virtual memory map + * holes. + */ +#define JEMALLOC_RETAIN + +/* TLS is used to map arenas and magazine caches to threads. */ +#define JEMALLOC_TLS + +/* + * Used to mark unreachable code to quiet "end of non-void" compiler warnings. + * Don't use this directly; instead use unreachable() from util.h + */ +#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable + +/* + * ffs*() functions to use for bitmapping. Don't use these directly; instead, + * use ffs_*() from util.h. + */ +#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll +#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl +#define JEMALLOC_INTERNAL_FFS __builtin_ffs + +/* + * popcount*() functions to use for bitmapping. + */ +#define JEMALLOC_INTERNAL_POPCOUNTL __builtin_popcountl +#define JEMALLOC_INTERNAL_POPCOUNT __builtin_popcount + +/* + * If defined, explicitly attempt to more uniformly distribute large allocation + * pointer alignments across all cache indices. + */ +#define JEMALLOC_CACHE_OBLIVIOUS + +/* + * If defined, enable logging facilities. We make this a configure option to + * avoid taking extra branches everywhere. + */ +/* #undef JEMALLOC_LOG */ + +/* + * If defined, use readlinkat() (instead of readlink()) to follow + * /etc/malloc_conf. + */ +/* #undef JEMALLOC_READLINKAT */ + +/* + * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. + */ +/* #undef JEMALLOC_ZONE */ + +/* + * Methods for determining whether the OS overcommits. + * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's + * /proc/sys/vm.overcommit_memory file. + * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl. + */ +/* #undef JEMALLOC_SYSCTL_VM_OVERCOMMIT */ +#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY + +/* Defined if madvise(2) is available. */ +#define JEMALLOC_HAVE_MADVISE + +/* + * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE + * arguments to madvise(2). + */ +#define JEMALLOC_HAVE_MADVISE_HUGE + +/* + * Methods for purging unused pages differ between operating systems. + * + * madvise(..., MADV_FREE) : This marks pages as being unused, such that they + * will be discarded rather than swapped out. + * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is + * defined, this immediately discards pages, + * such that new pages will be demand-zeroed if + * the address region is later touched; + * otherwise this behaves similarly to + * MADV_FREE, though typically with higher + * system overhead. + */ +#define JEMALLOC_PURGE_MADVISE_FREE +#define JEMALLOC_PURGE_MADVISE_DONTNEED +#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS + +/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */ +/* #undef JEMALLOC_DEFINE_MADVISE_FREE */ + +/* + * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise. + */ +#define JEMALLOC_MADVISE_DONTDUMP + +/* + * Defined if transparent huge pages (THPs) are supported via the + * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled. + */ +/* #undef JEMALLOC_THP */ + +/* Define if operating system has alloca.h header. */ +#define JEMALLOC_HAS_ALLOCA_H 1 + +/* C99 restrict keyword supported. */ +#define JEMALLOC_HAS_RESTRICT 1 + +/* For use by hash code. */ +/* #undef JEMALLOC_BIG_ENDIAN */ + +/* sizeof(int) == 2^LG_SIZEOF_INT. */ +#define LG_SIZEOF_INT 2 + +/* sizeof(long) == 2^LG_SIZEOF_LONG. */ +#define LG_SIZEOF_LONG 3 + +/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */ +#define LG_SIZEOF_LONG_LONG 3 + +/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ +#define LG_SIZEOF_INTMAX_T 3 + +/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */ +#define JEMALLOC_GLIBC_MALLOC_HOOK + +/* glibc memalign hook. */ +#define JEMALLOC_GLIBC_MEMALIGN_HOOK + +/* pthread support */ +#define JEMALLOC_HAVE_PTHREAD + +/* dlsym() support */ +#define JEMALLOC_HAVE_DLSYM + +/* Adaptive mutex support in pthreads. */ +#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP + +/* GNU specific sched_getcpu support */ +#define JEMALLOC_HAVE_SCHED_GETCPU + +/* GNU specific sched_setaffinity support */ +#define JEMALLOC_HAVE_SCHED_SETAFFINITY + +/* + * If defined, all the features necessary for background threads are present. + */ +#define JEMALLOC_BACKGROUND_THREAD 1 + +/* + * If defined, jemalloc symbols are not exported (doesn't work when + * JEMALLOC_PREFIX is not defined). + */ +/* #undef JEMALLOC_EXPORT */ + +/* config.malloc_conf options string. */ +#define JEMALLOC_CONFIG_MALLOC_CONF "@JEMALLOC_CONFIG_MALLOC_CONF@" + +/* If defined, jemalloc takes the malloc/free/etc. symbol names. */ +#define JEMALLOC_IS_MALLOC 1 + +/* + * Defined if strerror_r returns char * if _GNU_SOURCE is defined. + */ +#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE + +/* Performs additional safety checks when defined. */ +/* #undef JEMALLOC_OPT_SAFETY_CHECKS */ + +#endif /* JEMALLOC_INTERNAL_DEFS_H_ */ diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_preamble.h b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_preamble.h index c150785fb4a..e5e34925b55 100644 --- a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_preamble.h +++ b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/internal/jemalloc_preamble.h @@ -21,7 +21,7 @@ # include "jemalloc/jemalloc.h" #endif -#if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN)) +#if defined(JEMALLOC_OSATOMIC) #include #endif @@ -161,7 +161,26 @@ static const bool config_log = false #endif ; -#ifdef JEMALLOC_HAVE_SCHED_GETCPU +/* + * Are extra safety checks enabled; things like checking the size of sized + * deallocations, double-frees, etc. + */ +static const bool config_opt_safety_checks = +#ifdef JEMALLOC_OPT_SAFETY_CHECKS + true +#elif defined(JEMALLOC_DEBUG) + /* + * This lets us only guard safety checks by one flag instead of two; fast + * checks can guard solely by config_opt_safety_checks and run in debug mode + * too. + */ + true +#else + false +#endif + ; + +#if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU) /* Currently percpu_arena depends on sched_getcpu. */ #define JEMALLOC_PERCPU_ARENA #endif diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_defs.h b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_defs.h deleted file mode 100644 index d1389237a77..00000000000 --- a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_defs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */ -/* Defined if __attribute__((...)) syntax is supported. */ -#define JEMALLOC_HAVE_ATTR - -/* Defined if alloc_size attribute is supported. */ -#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE - -/* Defined if format(printf, ...) attribute is supported. */ -#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF - -/* - * Define overrides for non-standard allocator-related functions if they are - * present on the system. - */ -#define JEMALLOC_OVERRIDE_MEMALIGN -#define JEMALLOC_OVERRIDE_VALLOC - -/* - * At least Linux omits the "const" in: - * - * size_t malloc_usable_size(const void *ptr); - * - * Match the operating system's prototype. - */ -#define JEMALLOC_USABLE_SIZE_CONST - -/* - * If defined, specify throw() for the public function prototypes when compiling - * with C++. The only justification for this is to match the prototypes that - * glibc defines. - */ -#define JEMALLOC_USE_CXX_THROW - -#ifdef _MSC_VER -# ifdef _WIN64 -# define LG_SIZEOF_PTR_WIN 3 -# else -# define LG_SIZEOF_PTR_WIN 2 -# endif -#endif - -/* sizeof(void *) == 2^LG_SIZEOF_PTR. */ -#define LG_SIZEOF_PTR 3 diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_macros.h b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_macros.h deleted file mode 100644 index 7432f1cda53..00000000000 --- a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_macros.h +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include -#include -#include - -#define JEMALLOC_VERSION "5.1.0-56-g41b7372eadee941b9164751b8d4963f915d3ceae" -#define JEMALLOC_VERSION_MAJOR 5 -#define JEMALLOC_VERSION_MINOR 1 -#define JEMALLOC_VERSION_BUGFIX 0 -#define JEMALLOC_VERSION_NREV 56 -#define JEMALLOC_VERSION_GID "41b7372eadee941b9164751b8d4963f915d3ceae" - -#define MALLOCX_LG_ALIGN(la) ((int)(la)) -#if LG_SIZEOF_PTR == 2 -# define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1)) -#else -# define MALLOCX_ALIGN(a) \ - ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \ - ffs((int)(((size_t)(a))>>32))+31)) -#endif -#define MALLOCX_ZERO ((int)0x40) -/* - * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1 - * encodes MALLOCX_TCACHE_NONE. - */ -#define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8)) -#define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1) -/* - * Bias arena index bits so that 0 encodes "use an automatically chosen arena". - */ -#define MALLOCX_ARENA(a) ((((int)(a))+1) << 20) - -/* - * Use as arena index in "arena..{purge,decay,dss}" and - * "stats.arenas..*" mallctl interfaces to select all arenas. This - * definition is intentionally specified in raw decimal format to support - * cpp-based string concatenation, e.g. - * - * #define STRINGIFY_HELPER(x) #x - * #define STRINGIFY(x) STRINGIFY_HELPER(x) - * - * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL, - * 0); - */ -#define MALLCTL_ARENAS_ALL 4096 -/* - * Use as arena index in "stats.arenas..*" mallctl interfaces to select - * destroyed arenas. - */ -#define MALLCTL_ARENAS_DESTROYED 4097 - -#if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW) -# define JEMALLOC_CXX_THROW throw() -#else -# define JEMALLOC_CXX_THROW -#endif - -#if defined(_MSC_VER) -# define JEMALLOC_ATTR(s) -# define JEMALLOC_ALIGNED(s) __declspec(align(s)) -# define JEMALLOC_ALLOC_SIZE(s) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) -# ifndef JEMALLOC_EXPORT -# ifdef DLLEXPORT -# define JEMALLOC_EXPORT __declspec(dllexport) -# else -# define JEMALLOC_EXPORT __declspec(dllimport) -# endif -# endif -# define JEMALLOC_FORMAT_PRINTF(s, i) -# define JEMALLOC_NOINLINE __declspec(noinline) -# ifdef __cplusplus -# define JEMALLOC_NOTHROW __declspec(nothrow) -# else -# define JEMALLOC_NOTHROW -# endif -# define JEMALLOC_SECTION(s) __declspec(allocate(s)) -# define JEMALLOC_RESTRICT_RETURN __declspec(restrict) -# if _MSC_VER >= 1900 && !defined(__EDG__) -# define JEMALLOC_ALLOCATOR __declspec(allocator) -# else -# define JEMALLOC_ALLOCATOR -# endif -#elif defined(JEMALLOC_HAVE_ATTR) -# define JEMALLOC_ATTR(s) __attribute__((s)) -# define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) -# ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE -# define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s)) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2)) -# else -# define JEMALLOC_ALLOC_SIZE(s) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) -# endif -# ifndef JEMALLOC_EXPORT -# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) -# endif -# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF -# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i)) -# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF) -# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i)) -# else -# define JEMALLOC_FORMAT_PRINTF(s, i) -# endif -# define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) -# define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) -# define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) -# define JEMALLOC_RESTRICT_RETURN -# define JEMALLOC_ALLOCATOR -#else -# define JEMALLOC_ATTR(s) -# define JEMALLOC_ALIGNED(s) -# define JEMALLOC_ALLOC_SIZE(s) -# define JEMALLOC_ALLOC_SIZE2(s1, s2) -# define JEMALLOC_EXPORT -# define JEMALLOC_FORMAT_PRINTF(s, i) -# define JEMALLOC_NOINLINE -# define JEMALLOC_NOTHROW -# define JEMALLOC_SECTION(s) -# define JEMALLOC_RESTRICT_RETURN -# define JEMALLOC_ALLOCATOR -#endif diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_protos.h b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_protos.h deleted file mode 100644 index ff025e30fa7..00000000000 --- a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_protos.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The je_ prefix on the following public symbol declarations is an artifact - * of namespace management, and should be omitted in application code unless - * JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h). - */ -extern JEMALLOC_EXPORT const char *je_malloc_conf; -extern JEMALLOC_EXPORT void (*je_malloc_message)(void *cbopaque, - const char *s); - -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_malloc(size_t size) - JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1); -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_calloc(size_t num, size_t size) - JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2); -JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_posix_memalign(void **memptr, - size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1)); -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_aligned_alloc(size_t alignment, - size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) - JEMALLOC_ALLOC_SIZE(2); -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_realloc(void *ptr, size_t size) - JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2); -JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_free(void *ptr) - JEMALLOC_CXX_THROW; - -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_mallocx(size_t size, int flags) - JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1); -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_rallocx(void *ptr, size_t size, - int flags) JEMALLOC_ALLOC_SIZE(2); -JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_xallocx(void *ptr, size_t size, - size_t extra, int flags); -JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_sallocx(const void *ptr, - int flags) JEMALLOC_ATTR(pure); -JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_dallocx(void *ptr, int flags); -JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_sdallocx(void *ptr, size_t size, - int flags); -JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_nallocx(size_t size, int flags) - JEMALLOC_ATTR(pure); - -JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char *name, - void *oldp, size_t *oldlenp, void *newp, size_t newlen); -JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlnametomib(const char *name, - size_t *mibp, size_t *miblenp); -JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlbymib(const size_t *mib, - size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); -JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_malloc_stats_print( - void (*write_cb)(void *, const char *), void *je_cbopaque, - const char *opts); -JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size( - JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW; - -#ifdef JEMALLOC_OVERRIDE_MEMALIGN -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size) - JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc); -#endif - -#ifdef JEMALLOC_OVERRIDE_VALLOC -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - void JEMALLOC_NOTHROW *je_valloc(size_t size) JEMALLOC_CXX_THROW - JEMALLOC_ATTR(malloc); -#endif diff --git a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_typedefs.h b/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_typedefs.h deleted file mode 100644 index 1a58874306e..00000000000 --- a/contrib/jemalloc-cmake/include_linux_x86_64/jemalloc/jemalloc_typedefs.h +++ /dev/null @@ -1,77 +0,0 @@ -typedef struct extent_hooks_s extent_hooks_t; - -/* - * void * - * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size, - * size_t alignment, bool *zero, bool *commit, unsigned arena_ind); - */ -typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *, - bool *, unsigned); - -/* - * bool - * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size, - * bool committed, unsigned arena_ind); - */ -typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool, - unsigned); - -/* - * void - * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size, - * bool committed, unsigned arena_ind); - */ -typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool, - unsigned); - -/* - * bool - * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t offset, size_t length, unsigned arena_ind); - */ -typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t, - unsigned); - -/* - * bool - * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t offset, size_t length, unsigned arena_ind); - */ -typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t, - size_t, unsigned); - -/* - * bool - * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t offset, size_t length, unsigned arena_ind); - */ -typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t, - unsigned); - -/* - * bool - * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size, - * size_t size_a, size_t size_b, bool committed, unsigned arena_ind); - */ -typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t, - bool, unsigned); - -/* - * bool - * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a, - * void *addr_b, size_t size_b, bool committed, unsigned arena_ind); - */ -typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t, - bool, unsigned); - -struct extent_hooks_s { - extent_alloc_t *alloc; - extent_dalloc_t *dalloc; - extent_destroy_t *destroy; - extent_commit_t *commit; - extent_decommit_t *decommit; - extent_purge_t *purge_lazy; - extent_purge_t *purge_forced; - extent_split_t *split; - extent_merge_t *merge; -}; diff --git a/contrib/libcpuid b/contrib/libcpuid new file mode 160000 index 00000000000..8db3b8d2d32 --- /dev/null +++ b/contrib/libcpuid @@ -0,0 +1 @@ +Subproject commit 8db3b8d2d32d22437f063ce692a1b9bb15e42d18 diff --git a/contrib/libcpuid-cmake/CMakeLists.txt b/contrib/libcpuid-cmake/CMakeLists.txt new file mode 100644 index 00000000000..cb28cbd21da --- /dev/null +++ b/contrib/libcpuid-cmake/CMakeLists.txt @@ -0,0 +1,35 @@ +option (ENABLE_CPUID "Enable libcpuid library (only internal)" ${ENABLE_LIBRARIES}) + +if (ARCH_ARM) + set (ENABLE_CPUID 0) +endif () + +if (ENABLE_CPUID) + set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/libcpuid) + + set (SRCS + ${LIBRARY_DIR}/libcpuid/asm-bits.c + ${LIBRARY_DIR}/libcpuid/cpuid_main.c + ${LIBRARY_DIR}/libcpuid/libcpuid_util.c + ${LIBRARY_DIR}/libcpuid/msrdriver.c + ${LIBRARY_DIR}/libcpuid/rdmsr.c + ${LIBRARY_DIR}/libcpuid/rdtsc.c + ${LIBRARY_DIR}/libcpuid/recog_amd.c + ${LIBRARY_DIR}/libcpuid/recog_intel.c + ) + + add_library (cpuid ${SRCS}) + + target_include_directories (cpuid SYSTEM PUBLIC ${LIBRARY_DIR}) + target_compile_definitions (cpuid PUBLIC USE_CPUID=1) + target_compile_definitions (cpuid PRIVATE VERSION="v0.4.1") + if (COMPILER_CLANG) + target_compile_options (cpuid PRIVATE -Wno-reserved-id-macro) + endif () + + message (STATUS "Using cpuid") +else () + add_library (cpuid INTERFACE) + + target_compile_definitions (cpuid INTERFACE USE_CPUID=0) +endif () diff --git a/contrib/libcpuid/CMakeLists.txt b/contrib/libcpuid/CMakeLists.txt deleted file mode 100644 index cd3e7fa06fe..00000000000 --- a/contrib/libcpuid/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -add_library(cpuid -include/libcpuid/asm-bits.c -include/libcpuid/cpuid_main.c -include/libcpuid/libcpuid_util.c -include/libcpuid/rdtsc.c -include/libcpuid/recog_amd.c -include/libcpuid/recog_intel.c - -include/libcpuid/asm-bits.h -include/libcpuid/config.h -include/libcpuid/libcpuid_constants.h -include/libcpuid/libcpuid.h -include/libcpuid/libcpuid_types.h -include/libcpuid/libcpuid_util.h -include/libcpuid/rdtsc.h -include/libcpuid/recog_amd.h -include/libcpuid/recog_intel.h -) - -target_include_directories (cpuid SYSTEM PUBLIC include) diff --git a/contrib/libcpuid/COPYING b/contrib/libcpuid/COPYING deleted file mode 100644 index bf4755c203f..00000000000 --- a/contrib/libcpuid/COPYING +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2008 Veselin Georgiev, -anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/libcpuid/README.txt b/contrib/libcpuid/README.txt deleted file mode 100644 index a6817683f8b..00000000000 --- a/contrib/libcpuid/README.txt +++ /dev/null @@ -1 +0,0 @@ -https://github.com/anrieff/libcpuid.git diff --git a/contrib/libcpuid/include/libcpuid/amd_code_t.h b/contrib/libcpuid/include/libcpuid/amd_code_t.h deleted file mode 100644 index 2472a3d61d5..00000000000 --- a/contrib/libcpuid/include/libcpuid/amd_code_t.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2016 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This file contains a list of internal codes we use in detection. It is - * of no external use and isn't a complete list of AMD products. - */ - CODE2(OPTERON_GENERIC, 1000), - CODE(OPTERON_800), - CODE(ATHLON_XP), - CODE(ATHLON_XP_M), - CODE(ATHLON_XP_M_LV), - CODE(ATHLON), - CODE(ATHLON_MP), - CODE(MOBILE_ATHLON64), - CODE(ATHLON_FX), - CODE(DURON), - CODE(DURON_MP), - CODE(MOBILE_DURON), - CODE(MOBILE_SEMPRON), - CODE(OPTERON_SINGLE), - CODE(OPTERON_DUALCORE), - CODE(OPTERON_800_DUALCORE), - CODE(MOBILE_TURION), - CODE(ATHLON_64), - CODE(ATHLON_64_FX), - CODE(TURION_64), - CODE(TURION_X2), - CODE(SEMPRON), - CODE(M_SEMPRON), - CODE(SEMPRON_DUALCORE), - CODE(PHENOM), - CODE(PHENOM2), - CODE(ATHLON_64_X2), - CODE(ATHLON_64_X3), - CODE(ATHLON_64_X4), - CODE(FUSION_C), - CODE(FUSION_E), - CODE(FUSION_EA), - CODE(FUSION_Z), - CODE(FUSION_A), - diff --git a/contrib/libcpuid/include/libcpuid/asm-bits.c b/contrib/libcpuid/include/libcpuid/asm-bits.c deleted file mode 100644 index b8e32284f57..00000000000 --- a/contrib/libcpuid/include/libcpuid/asm-bits.c +++ /dev/null @@ -1,825 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "libcpuid.h" -#include "asm-bits.h" - -int cpuid_exists_by_eflags(void) -{ -#if defined(PLATFORM_X64) - return 1; /* CPUID is always present on the x86_64 */ -#elif defined(PLATFORM_X86) -# if defined(COMPILER_GCC) - int result; - __asm __volatile( - " pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl\n" - : "=m"(result) - : :"eax", "ecx", "memory"); - return (result != 0); -# elif defined(COMPILER_MICROSOFT) - int result; - __asm { - pushfd - pop eax - mov ecx, eax - xor eax, 0x200000 - push eax - popfd - pushfd - pop eax - xor eax, ecx - mov result, eax - push ecx - popfd - }; - return (result != 0); -# else - return 0; -# endif /* COMPILER_MICROSOFT */ -#else - return 0; -#endif /* PLATFORM_X86 */ -} - -#ifdef INLINE_ASM_SUPPORTED -/* - * with MSVC/AMD64, the exec_cpuid() and cpu_rdtsc() functions - * are implemented in separate .asm files. Otherwise, use inline assembly - */ -void exec_cpuid(uint32_t *regs) -{ -#ifdef COMPILER_GCC -# ifdef PLATFORM_X64 - __asm __volatile( - " mov %0, %%rdi\n" - - " push %%rbx\n" - " push %%rcx\n" - " push %%rdx\n" - - " mov (%%rdi), %%eax\n" - " mov 4(%%rdi), %%ebx\n" - " mov 8(%%rdi), %%ecx\n" - " mov 12(%%rdi), %%edx\n" - - " cpuid\n" - - " movl %%eax, (%%rdi)\n" - " movl %%ebx, 4(%%rdi)\n" - " movl %%ecx, 8(%%rdi)\n" - " movl %%edx, 12(%%rdi)\n" - " pop %%rdx\n" - " pop %%rcx\n" - " pop %%rbx\n" - : - :"m"(regs) - :"memory", "eax", "rdi" - ); -# else - __asm __volatile( - " mov %0, %%edi\n" - - " push %%ebx\n" - " push %%ecx\n" - " push %%edx\n" - - " mov (%%edi), %%eax\n" - " mov 4(%%edi), %%ebx\n" - " mov 8(%%edi), %%ecx\n" - " mov 12(%%edi), %%edx\n" - - " cpuid\n" - - " mov %%eax, (%%edi)\n" - " mov %%ebx, 4(%%edi)\n" - " mov %%ecx, 8(%%edi)\n" - " mov %%edx, 12(%%edi)\n" - " pop %%edx\n" - " pop %%ecx\n" - " pop %%ebx\n" - : - :"m"(regs) - :"memory", "eax", "edi" - ); -# endif /* COMPILER_GCC */ -#else -# ifdef COMPILER_MICROSOFT - __asm { - push ebx - push ecx - push edx - push edi - mov edi, regs - - mov eax, [edi] - mov ebx, [edi+4] - mov ecx, [edi+8] - mov edx, [edi+12] - - cpuid - - mov [edi], eax - mov [edi+4], ebx - mov [edi+8], ecx - mov [edi+12], edx - - pop edi - pop edx - pop ecx - pop ebx - } -# else -# error "Unsupported compiler" -# endif /* COMPILER_MICROSOFT */ -#endif -} -#endif /* INLINE_ASSEMBLY_SUPPORTED */ - -#ifdef INLINE_ASM_SUPPORTED -void cpu_rdtsc(uint64_t* result) -{ - uint32_t low_part, hi_part; -#ifdef COMPILER_GCC - __asm __volatile ( - " rdtsc\n" - " mov %%eax, %0\n" - " mov %%edx, %1\n" - :"=m"(low_part), "=m"(hi_part)::"memory", "eax", "edx" - ); -#else -# ifdef COMPILER_MICROSOFT - __asm { - rdtsc - mov low_part, eax - mov hi_part, edx - }; -# else -# error "Unsupported compiler" -# endif /* COMPILER_MICROSOFT */ -#endif /* COMPILER_GCC */ - *result = (uint64_t)low_part + (((uint64_t) hi_part) << 32); -} -#endif /* INLINE_ASM_SUPPORTED */ - -#ifdef INLINE_ASM_SUPPORTED -void busy_sse_loop(int cycles) -{ -#ifdef COMPILER_GCC -#ifndef __APPLE__ -# define XALIGN ".balign 16\n" -#else -# define XALIGN ".align 4\n" -#endif - __asm __volatile ( - " xorps %%xmm0, %%xmm0\n" - " xorps %%xmm1, %%xmm1\n" - " xorps %%xmm2, %%xmm2\n" - " xorps %%xmm3, %%xmm3\n" - " xorps %%xmm4, %%xmm4\n" - " xorps %%xmm5, %%xmm5\n" - " xorps %%xmm6, %%xmm6\n" - " xorps %%xmm7, %%xmm7\n" - XALIGN - /* ".bsLoop:\n" */ - "1:\n" - // 0: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 1: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 2: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 3: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 4: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 5: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 6: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 7: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 8: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - // 9: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //10: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //11: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //12: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //13: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //14: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //15: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //16: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //17: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //18: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //19: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //20: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //21: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //22: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //23: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //24: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //25: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //26: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //27: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //28: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //29: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //30: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - //31: - " addps %%xmm1, %%xmm0\n" - " addps %%xmm2, %%xmm1\n" - " addps %%xmm3, %%xmm2\n" - " addps %%xmm4, %%xmm3\n" - " addps %%xmm5, %%xmm4\n" - " addps %%xmm6, %%xmm5\n" - " addps %%xmm7, %%xmm6\n" - " addps %%xmm0, %%xmm7\n" - - " dec %%eax\n" - /* "jnz .bsLoop\n" */ - " jnz 1b\n" - ::"a"(cycles) - ); -#else -# ifdef COMPILER_MICROSOFT - __asm { - mov eax, cycles - xorps xmm0, xmm0 - xorps xmm1, xmm1 - xorps xmm2, xmm2 - xorps xmm3, xmm3 - xorps xmm4, xmm4 - xorps xmm5, xmm5 - xorps xmm6, xmm6 - xorps xmm7, xmm7 - //-- - align 16 -bsLoop: - // 0: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 1: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 2: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 3: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 4: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 5: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 6: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 7: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 8: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 9: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 10: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 11: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 12: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 13: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 14: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 15: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 16: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 17: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 18: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 19: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 20: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 21: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 22: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 23: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 24: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 25: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 26: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 27: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 28: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 29: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 30: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - // 31: - addps xmm0, xmm1 - addps xmm1, xmm2 - addps xmm2, xmm3 - addps xmm3, xmm4 - addps xmm4, xmm5 - addps xmm5, xmm6 - addps xmm6, xmm7 - addps xmm7, xmm0 - //---------------------- - dec eax - jnz bsLoop - } -# else -# error "Unsupported compiler" -# endif /* COMPILER_MICROSOFT */ -#endif /* COMPILER_GCC */ -} -#endif /* INLINE_ASSEMBLY_SUPPORTED */ diff --git a/contrib/libcpuid/include/libcpuid/asm-bits.h b/contrib/libcpuid/include/libcpuid/asm-bits.h deleted file mode 100644 index 3a03e11ce8c..00000000000 --- a/contrib/libcpuid/include/libcpuid/asm-bits.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __ASM_BITS_H__ -#define __ASM_BITS_H__ -#include "libcpuid.h" - -/* Determine Compiler: */ -#if defined(_MSC_VER) -# define COMPILER_MICROSOFT -#elif defined(__GNUC__) -# define COMPILER_GCC -#endif - -/* Determine Platform */ -#if defined(__x86_64__) || defined(_M_AMD64) -# define PLATFORM_X64 -#elif defined(__i386__) || defined(_M_IX86) -# define PLATFORM_X86 -#endif - -/* Under Windows/AMD64 with MSVC, inline assembly isn't supported */ -#if (defined(COMPILER_GCC) && defined(PLATFORM_X64)) || defined(PLATFORM_X86) -# define INLINE_ASM_SUPPORTED -#endif - -int cpuid_exists_by_eflags(void); -void exec_cpuid(uint32_t *regs); -void busy_sse_loop(int cycles); - -#endif /* __ASM_BITS_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/config.h b/contrib/libcpuid/include/libcpuid/config.h deleted file mode 100644 index 2326cfeede5..00000000000 --- a/contrib/libcpuid/include/libcpuid/config.h +++ /dev/null @@ -1,2 +0,0 @@ -/* Version number of package */ -#define VERSION "0.4.0" diff --git a/contrib/libcpuid/include/libcpuid/cpuid_main.c b/contrib/libcpuid/include/libcpuid/cpuid_main.c deleted file mode 100644 index 34457e297ca..00000000000 --- a/contrib/libcpuid/include/libcpuid/cpuid_main.c +++ /dev/null @@ -1,771 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "libcpuid.h" -#include "libcpuid_internal.h" -#include "recog_intel.h" -#include "recog_amd.h" -#include "asm-bits.h" -#include "libcpuid_util.h" -//#ifdef HAVE_CONFIG_H // CLICKHOUSE PATCH -#include "config.h" -//#endif // CLICKHOUSE PATCH -#include -#include -#include - -/* Implementation: */ - -_Thread_local int _libcpiud_errno = ERR_OK; - -int set_error(cpu_error_t err) -{ - _libcpiud_errno = (int) err; - return (int) err; -} - -static void raw_data_t_constructor(struct cpu_raw_data_t* raw) -{ - memset(raw, 0, sizeof(struct cpu_raw_data_t)); -} - -static void cpu_id_t_constructor(struct cpu_id_t* id) -{ - memset(id, 0, sizeof(struct cpu_id_t)); - id->l1_data_cache = id->l1_instruction_cache = id->l2_cache = id->l3_cache = id->l4_cache = -1; - id->l1_assoc = id->l2_assoc = id->l3_assoc = id->l4_assoc = -1; - id->l1_cacheline = id->l2_cacheline = id->l3_cacheline = id->l4_cacheline = -1; - id->sse_size = -1; -} - -static int parse_token(const char* expected_token, const char *token, - const char *value, uint32_t array[][4], int limit, int *recognized) -{ - char format[32]; - int veax, vebx, vecx, vedx; - int index; - - if (*recognized) return 1; /* already recognized */ - if (strncmp(token, expected_token, strlen(expected_token))) return 1; /* not what we search for */ - sprintf(format, "%s[%%d]", expected_token); - *recognized = 1; - if (1 == sscanf(token, format, &index) && index >=0 && index < limit) { - if (4 == sscanf(value, "%x%x%x%x", &veax, &vebx, &vecx, &vedx)) { - array[index][0] = veax; - array[index][1] = vebx; - array[index][2] = vecx; - array[index][3] = vedx; - return 1; - } - } - return 0; -} - -/* get_total_cpus() system specific code: uses OS routines to determine total number of CPUs */ -#ifdef __APPLE__ -#include -#include -#include -#include -static int get_total_cpus(void) -{ - kern_return_t kr; - host_basic_info_data_t basic_info; - host_info_t info = (host_info_t)&basic_info; - host_flavor_t flavor = HOST_BASIC_INFO; - mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; - kr = host_info(mach_host_self(), flavor, info, &count); - if (kr != KERN_SUCCESS) return 1; - return basic_info.avail_cpus; -} -#define GET_TOTAL_CPUS_DEFINED -#endif - -#ifdef _WIN32 -#include -static int get_total_cpus(void) -{ - SYSTEM_INFO system_info; - GetSystemInfo(&system_info); - return system_info.dwNumberOfProcessors; -} -#define GET_TOTAL_CPUS_DEFINED -#endif - -#if defined linux || defined __linux__ || defined __sun -#include -#include - -static int get_total_cpus(void) -{ - return sysconf(_SC_NPROCESSORS_ONLN); -} -#define GET_TOTAL_CPUS_DEFINED -#endif - -#if defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __bsdi__ || defined __QNX__ -#include -#include - -static int get_total_cpus(void) -{ - int mib[2] = { CTL_HW, HW_NCPU }; - int ncpus; - size_t len = sizeof(ncpus); - if (sysctl(mib, 2, &ncpus, &len, (void *) 0, 0) != 0) return 1; - return ncpus; -} -#define GET_TOTAL_CPUS_DEFINED -#endif - -#ifndef GET_TOTAL_CPUS_DEFINED -static int get_total_cpus(void) -{ - static int warning_printed = 0; - if (!warning_printed) { - warning_printed = 1; - warnf("Your system is not supported by libcpuid -- don't know how to detect the\n"); - warnf("total number of CPUs on your system. It will be reported as 1.\n"); - printf("Please use cpu_id_t.logical_cpus field instead.\n"); - } - return 1; -} -#endif /* GET_TOTAL_CPUS_DEFINED */ - - -static void load_features_common(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - const struct feature_map_t matchtable_edx1[] = { - { 0, CPU_FEATURE_FPU }, - { 1, CPU_FEATURE_VME }, - { 2, CPU_FEATURE_DE }, - { 3, CPU_FEATURE_PSE }, - { 4, CPU_FEATURE_TSC }, - { 5, CPU_FEATURE_MSR }, - { 6, CPU_FEATURE_PAE }, - { 7, CPU_FEATURE_MCE }, - { 8, CPU_FEATURE_CX8 }, - { 9, CPU_FEATURE_APIC }, - { 11, CPU_FEATURE_SEP }, - { 12, CPU_FEATURE_MTRR }, - { 13, CPU_FEATURE_PGE }, - { 14, CPU_FEATURE_MCA }, - { 15, CPU_FEATURE_CMOV }, - { 16, CPU_FEATURE_PAT }, - { 17, CPU_FEATURE_PSE36 }, - { 19, CPU_FEATURE_CLFLUSH }, - { 23, CPU_FEATURE_MMX }, - { 24, CPU_FEATURE_FXSR }, - { 25, CPU_FEATURE_SSE }, - { 26, CPU_FEATURE_SSE2 }, - { 28, CPU_FEATURE_HT }, - }; - const struct feature_map_t matchtable_ecx1[] = { - { 0, CPU_FEATURE_PNI }, - { 1, CPU_FEATURE_PCLMUL }, - { 3, CPU_FEATURE_MONITOR }, - { 9, CPU_FEATURE_SSSE3 }, - { 12, CPU_FEATURE_FMA3 }, - { 13, CPU_FEATURE_CX16 }, - { 19, CPU_FEATURE_SSE4_1 }, - { 20, CPU_FEATURE_SSE4_2 }, - { 22, CPU_FEATURE_MOVBE }, - { 23, CPU_FEATURE_POPCNT }, - { 25, CPU_FEATURE_AES }, - { 26, CPU_FEATURE_XSAVE }, - { 27, CPU_FEATURE_OSXSAVE }, - { 28, CPU_FEATURE_AVX }, - { 29, CPU_FEATURE_F16C }, - { 30, CPU_FEATURE_RDRAND }, - }; - const struct feature_map_t matchtable_ebx7[] = { - { 3, CPU_FEATURE_BMI1 }, - { 5, CPU_FEATURE_AVX2 }, - { 8, CPU_FEATURE_BMI2 }, - }; - const struct feature_map_t matchtable_edx81[] = { - { 11, CPU_FEATURE_SYSCALL }, - { 27, CPU_FEATURE_RDTSCP }, - { 29, CPU_FEATURE_LM }, - }; - const struct feature_map_t matchtable_ecx81[] = { - { 0, CPU_FEATURE_LAHF_LM }, - }; - const struct feature_map_t matchtable_edx87[] = { - { 8, CPU_FEATURE_CONSTANT_TSC }, - }; - if (raw->basic_cpuid[0][0] >= 1) { - match_features(matchtable_edx1, COUNT_OF(matchtable_edx1), raw->basic_cpuid[1][3], data); - match_features(matchtable_ecx1, COUNT_OF(matchtable_ecx1), raw->basic_cpuid[1][2], data); - } - if (raw->basic_cpuid[0][0] >= 7) { - match_features(matchtable_ebx7, COUNT_OF(matchtable_ebx7), raw->basic_cpuid[7][1], data); - } - if (raw->ext_cpuid[0][0] >= 0x80000001) { - match_features(matchtable_edx81, COUNT_OF(matchtable_edx81), raw->ext_cpuid[1][3], data); - match_features(matchtable_ecx81, COUNT_OF(matchtable_ecx81), raw->ext_cpuid[1][2], data); - } - if (raw->ext_cpuid[0][0] >= 0x80000007) { - match_features(matchtable_edx87, COUNT_OF(matchtable_edx87), raw->ext_cpuid[7][3], data); - } - if (data->flags[CPU_FEATURE_SSE]) { - /* apply guesswork to check if the SSE unit width is 128 bit */ - switch (data->vendor) { - case VENDOR_AMD: - data->sse_size = (data->ext_family >= 16 && data->ext_family != 17) ? 128 : 64; - break; - case VENDOR_INTEL: - data->sse_size = (data->family == 6 && data->ext_model >= 15) ? 128 : 64; - break; - default: - break; - } - /* leave the CPU_FEATURE_128BIT_SSE_AUTH 0; the advanced per-vendor detection routines - * will set it accordingly if they detect the needed bit */ - } -} - -static cpu_vendor_t cpuid_vendor_identify(const uint32_t *raw_vendor, char *vendor_str) -{ - int i; - cpu_vendor_t vendor = VENDOR_UNKNOWN; - const struct { cpu_vendor_t vendor; char match[16]; } - matchtable[NUM_CPU_VENDORS] = { - /* source: http://www.sandpile.org/ia32/cpuid.htm */ - { VENDOR_INTEL , "GenuineIntel" }, - { VENDOR_AMD , "AuthenticAMD" }, - { VENDOR_CYRIX , "CyrixInstead" }, - { VENDOR_NEXGEN , "NexGenDriven" }, - { VENDOR_TRANSMETA , "GenuineTMx86" }, - { VENDOR_UMC , "UMC UMC UMC " }, - { VENDOR_CENTAUR , "CentaurHauls" }, - { VENDOR_RISE , "RiseRiseRise" }, - { VENDOR_SIS , "SiS SiS SiS " }, - { VENDOR_NSC , "Geode by NSC" }, - }; - - memcpy(vendor_str + 0, &raw_vendor[1], 4); - memcpy(vendor_str + 4, &raw_vendor[3], 4); - memcpy(vendor_str + 8, &raw_vendor[2], 4); - vendor_str[12] = 0; - - /* Determine vendor: */ - for (i = 0; i < NUM_CPU_VENDORS; i++) - if (!strcmp(vendor_str, matchtable[i].match)) { - vendor = matchtable[i].vendor; - break; - } - return vendor; -} - -static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - int i, j, basic, xmodel, xfamily, ext; - char brandstr[64] = {0}; - data->vendor = cpuid_vendor_identify(raw->basic_cpuid[0], data->vendor_str); - - if (data->vendor == VENDOR_UNKNOWN) - return set_error(ERR_CPU_UNKN); - basic = raw->basic_cpuid[0][0]; - if (basic >= 1) { - data->family = (raw->basic_cpuid[1][0] >> 8) & 0xf; - data->model = (raw->basic_cpuid[1][0] >> 4) & 0xf; - data->stepping = raw->basic_cpuid[1][0] & 0xf; - xmodel = (raw->basic_cpuid[1][0] >> 16) & 0xf; - xfamily = (raw->basic_cpuid[1][0] >> 20) & 0xff; - if (data->vendor == VENDOR_AMD && data->family < 0xf) - data->ext_family = data->family; - else - data->ext_family = data->family + xfamily; - data->ext_model = data->model + (xmodel << 4); - } - ext = raw->ext_cpuid[0][0] - 0x8000000; - - /* obtain the brand string, if present: */ - if (ext >= 4) { - for (i = 0; i < 3; i++) - for (j = 0; j < 4; j++) - memcpy(brandstr + i * 16 + j * 4, - &raw->ext_cpuid[2 + i][j], 4); - brandstr[48] = 0; - i = 0; - while (brandstr[i] == ' ') i++; - strncpy(data->brand_str, brandstr + i, sizeof(data->brand_str)); - data->brand_str[48] = 0; - } - load_features_common(raw, data); - data->total_logical_cpus = get_total_cpus(); - return set_error(ERR_OK); -} - -static void make_list_from_string(const char* csv, struct cpu_list_t* list) -{ - int i, n, l, last; - l = (int) strlen(csv); - n = 0; - for (i = 0; i < l; i++) if (csv[i] == ',') n++; - n++; - list->num_entries = n; - list->names = (char**) malloc(sizeof(char*) * n); - last = -1; - n = 0; - for (i = 0; i <= l; i++) if (i == l || csv[i] == ',') { - list->names[n] = (char*) malloc(i - last); - memcpy(list->names[n], &csv[last + 1], i - last - 1); - list->names[n][i - last - 1] = '\0'; - n++; - last = i; - } -} - - -/* Interface: */ - -int cpuid_get_total_cpus(void) -{ - return get_total_cpus(); -} - -int cpuid_present(void) -{ - return cpuid_exists_by_eflags(); -} - -void cpu_exec_cpuid(uint32_t eax, uint32_t* regs) -{ - regs[0] = eax; - regs[1] = regs[2] = regs[3] = 0; - exec_cpuid(regs); -} - -void cpu_exec_cpuid_ext(uint32_t* regs) -{ - exec_cpuid(regs); -} - -int cpuid_get_raw_data(struct cpu_raw_data_t* data) -{ - unsigned i; - if (!cpuid_present()) - return set_error(ERR_NO_CPUID); - for (i = 0; i < 32; i++) - cpu_exec_cpuid(i, data->basic_cpuid[i]); - for (i = 0; i < 32; i++) - cpu_exec_cpuid(0x80000000 + i, data->ext_cpuid[i]); - for (i = 0; i < MAX_INTELFN4_LEVEL; i++) { - memset(data->intel_fn4[i], 0, sizeof(data->intel_fn4[i])); - data->intel_fn4[i][0] = 4; - data->intel_fn4[i][2] = i; - cpu_exec_cpuid_ext(data->intel_fn4[i]); - } - for (i = 0; i < MAX_INTELFN11_LEVEL; i++) { - memset(data->intel_fn11[i], 0, sizeof(data->intel_fn11[i])); - data->intel_fn11[i][0] = 11; - data->intel_fn11[i][2] = i; - cpu_exec_cpuid_ext(data->intel_fn11[i]); - } - for (i = 0; i < MAX_INTELFN12H_LEVEL; i++) { - memset(data->intel_fn12h[i], 0, sizeof(data->intel_fn12h[i])); - data->intel_fn12h[i][0] = 0x12; - data->intel_fn12h[i][2] = i; - cpu_exec_cpuid_ext(data->intel_fn12h[i]); - } - for (i = 0; i < MAX_INTELFN14H_LEVEL; i++) { - memset(data->intel_fn14h[i], 0, sizeof(data->intel_fn14h[i])); - data->intel_fn14h[i][0] = 0x14; - data->intel_fn14h[i][2] = i; - cpu_exec_cpuid_ext(data->intel_fn14h[i]); - } - return set_error(ERR_OK); -} - -int cpuid_serialize_raw_data(struct cpu_raw_data_t* data, const char* filename) -{ - int i; - FILE *f; - - if (!strcmp(filename, "")) - f = stdout; - else - f = fopen(filename, "wt"); - if (!f) return set_error(ERR_OPEN); - - fprintf(f, "version=%s\n", VERSION); - for (i = 0; i < MAX_CPUID_LEVEL; i++) - fprintf(f, "basic_cpuid[%d]=%08x %08x %08x %08x\n", i, - data->basic_cpuid[i][0], data->basic_cpuid[i][1], - data->basic_cpuid[i][2], data->basic_cpuid[i][3]); - for (i = 0; i < MAX_EXT_CPUID_LEVEL; i++) - fprintf(f, "ext_cpuid[%d]=%08x %08x %08x %08x\n", i, - data->ext_cpuid[i][0], data->ext_cpuid[i][1], - data->ext_cpuid[i][2], data->ext_cpuid[i][3]); - for (i = 0; i < MAX_INTELFN4_LEVEL; i++) - fprintf(f, "intel_fn4[%d]=%08x %08x %08x %08x\n", i, - data->intel_fn4[i][0], data->intel_fn4[i][1], - data->intel_fn4[i][2], data->intel_fn4[i][3]); - for (i = 0; i < MAX_INTELFN11_LEVEL; i++) - fprintf(f, "intel_fn11[%d]=%08x %08x %08x %08x\n", i, - data->intel_fn11[i][0], data->intel_fn11[i][1], - data->intel_fn11[i][2], data->intel_fn11[i][3]); - for (i = 0; i < MAX_INTELFN12H_LEVEL; i++) - fprintf(f, "intel_fn12h[%d]=%08x %08x %08x %08x\n", i, - data->intel_fn12h[i][0], data->intel_fn12h[i][1], - data->intel_fn12h[i][2], data->intel_fn12h[i][3]); - for (i = 0; i < MAX_INTELFN14H_LEVEL; i++) - fprintf(f, "intel_fn14h[%d]=%08x %08x %08x %08x\n", i, - data->intel_fn14h[i][0], data->intel_fn14h[i][1], - data->intel_fn14h[i][2], data->intel_fn14h[i][3]); - - if (strcmp(filename, "")) - fclose(f); - return set_error(ERR_OK); -} - -int cpuid_deserialize_raw_data(struct cpu_raw_data_t* data, const char* filename) -{ - int i, len; - char line[100]; - char token[100]; - char *value; - int syntax; - int cur_line = 0; - int recognized; - FILE *f; - - raw_data_t_constructor(data); - - if (!strcmp(filename, "")) - f = stdin; - else - f = fopen(filename, "rt"); - if (!f) return set_error(ERR_OPEN); - while (fgets(line, sizeof(line), f)) { - ++cur_line; - len = (int) strlen(line); - if (len < 2) continue; - if (line[len - 1] == '\n') - line[--len] = '\0'; - for (i = 0; i < len && line[i] != '='; i++) - if (i >= len && i < 1 && len - i - 1 <= 0) { - fclose(f); - return set_error(ERR_BADFMT); - } - strncpy(token, line, i); - token[i] = '\0'; - value = &line[i + 1]; - /* try to recognize the line */ - recognized = 0; - if (!strcmp(token, "version") || !strcmp(token, "build_date")) { - recognized = 1; - } - syntax = 1; - syntax = syntax && parse_token("basic_cpuid", token, value, data->basic_cpuid, MAX_CPUID_LEVEL, &recognized); - syntax = syntax && parse_token("ext_cpuid", token, value, data->ext_cpuid, MAX_EXT_CPUID_LEVEL, &recognized); - syntax = syntax && parse_token("intel_fn4", token, value, data->intel_fn4, MAX_INTELFN4_LEVEL, &recognized); - syntax = syntax && parse_token("intel_fn11", token, value, data->intel_fn11, MAX_INTELFN11_LEVEL, &recognized); - syntax = syntax && parse_token("intel_fn12h", token, value, data->intel_fn12h, MAX_INTELFN12H_LEVEL, &recognized); - syntax = syntax && parse_token("intel_fn14h", token, value, data->intel_fn14h, MAX_INTELFN14H_LEVEL, &recognized); - if (!syntax) { - warnf("Error: %s:%d: Syntax error\n", filename, cur_line); - fclose(f); - return set_error(ERR_BADFMT); - } - if (!recognized) { - warnf("Warning: %s:%d not understood!\n", filename, cur_line); - } - } - - if (strcmp(filename, "")) - fclose(f); - return set_error(ERR_OK); -} - -int cpu_ident_internal(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal) -{ - int r; - struct cpu_raw_data_t myraw; - if (!raw) { - if ((r = cpuid_get_raw_data(&myraw)) < 0) - return set_error(r); - raw = &myraw; - } - cpu_id_t_constructor(data); - if ((r = cpuid_basic_identify(raw, data)) < 0) - return set_error(r); - switch (data->vendor) { - case VENDOR_INTEL: - r = cpuid_identify_intel(raw, data, internal); - break; - case VENDOR_AMD: - r = cpuid_identify_amd(raw, data, internal); - break; - default: - break; - } - return set_error(r); -} - -int cpu_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - struct internal_id_info_t throwaway; - return cpu_ident_internal(raw, data, &throwaway); -} - -const char* cpu_feature_str(cpu_feature_t feature) -{ - const struct { cpu_feature_t feature; const char* name; } - matchtable[] = { - { CPU_FEATURE_FPU, "fpu" }, - { CPU_FEATURE_VME, "vme" }, - { CPU_FEATURE_DE, "de" }, - { CPU_FEATURE_PSE, "pse" }, - { CPU_FEATURE_TSC, "tsc" }, - { CPU_FEATURE_MSR, "msr" }, - { CPU_FEATURE_PAE, "pae" }, - { CPU_FEATURE_MCE, "mce" }, - { CPU_FEATURE_CX8, "cx8" }, - { CPU_FEATURE_APIC, "apic" }, - { CPU_FEATURE_MTRR, "mtrr" }, - { CPU_FEATURE_SEP, "sep" }, - { CPU_FEATURE_PGE, "pge" }, - { CPU_FEATURE_MCA, "mca" }, - { CPU_FEATURE_CMOV, "cmov" }, - { CPU_FEATURE_PAT, "pat" }, - { CPU_FEATURE_PSE36, "pse36" }, - { CPU_FEATURE_PN, "pn" }, - { CPU_FEATURE_CLFLUSH, "clflush" }, - { CPU_FEATURE_DTS, "dts" }, - { CPU_FEATURE_ACPI, "acpi" }, - { CPU_FEATURE_MMX, "mmx" }, - { CPU_FEATURE_FXSR, "fxsr" }, - { CPU_FEATURE_SSE, "sse" }, - { CPU_FEATURE_SSE2, "sse2" }, - { CPU_FEATURE_SS, "ss" }, - { CPU_FEATURE_HT, "ht" }, - { CPU_FEATURE_TM, "tm" }, - { CPU_FEATURE_IA64, "ia64" }, - { CPU_FEATURE_PBE, "pbe" }, - { CPU_FEATURE_PNI, "pni" }, - { CPU_FEATURE_PCLMUL, "pclmul" }, - { CPU_FEATURE_DTS64, "dts64" }, - { CPU_FEATURE_MONITOR, "monitor" }, - { CPU_FEATURE_DS_CPL, "ds_cpl" }, - { CPU_FEATURE_VMX, "vmx" }, - { CPU_FEATURE_SMX, "smx" }, - { CPU_FEATURE_EST, "est" }, - { CPU_FEATURE_TM2, "tm2" }, - { CPU_FEATURE_SSSE3, "ssse3" }, - { CPU_FEATURE_CID, "cid" }, - { CPU_FEATURE_CX16, "cx16" }, - { CPU_FEATURE_XTPR, "xtpr" }, - { CPU_FEATURE_PDCM, "pdcm" }, - { CPU_FEATURE_DCA, "dca" }, - { CPU_FEATURE_SSE4_1, "sse4_1" }, - { CPU_FEATURE_SSE4_2, "sse4_2" }, - { CPU_FEATURE_SYSCALL, "syscall" }, - { CPU_FEATURE_XD, "xd" }, - { CPU_FEATURE_X2APIC, "x2apic"}, - { CPU_FEATURE_MOVBE, "movbe" }, - { CPU_FEATURE_POPCNT, "popcnt" }, - { CPU_FEATURE_AES, "aes" }, - { CPU_FEATURE_XSAVE, "xsave" }, - { CPU_FEATURE_OSXSAVE, "osxsave" }, - { CPU_FEATURE_AVX, "avx" }, - { CPU_FEATURE_MMXEXT, "mmxext" }, - { CPU_FEATURE_3DNOW, "3dnow" }, - { CPU_FEATURE_3DNOWEXT, "3dnowext" }, - { CPU_FEATURE_NX, "nx" }, - { CPU_FEATURE_FXSR_OPT, "fxsr_opt" }, - { CPU_FEATURE_RDTSCP, "rdtscp" }, - { CPU_FEATURE_LM, "lm" }, - { CPU_FEATURE_LAHF_LM, "lahf_lm" }, - { CPU_FEATURE_CMP_LEGACY, "cmp_legacy" }, - { CPU_FEATURE_SVM, "svm" }, - { CPU_FEATURE_SSE4A, "sse4a" }, - { CPU_FEATURE_MISALIGNSSE, "misalignsse" }, - { CPU_FEATURE_ABM, "abm" }, - { CPU_FEATURE_3DNOWPREFETCH, "3dnowprefetch" }, - { CPU_FEATURE_OSVW, "osvw" }, - { CPU_FEATURE_IBS, "ibs" }, - { CPU_FEATURE_SSE5, "sse5" }, - { CPU_FEATURE_SKINIT, "skinit" }, - { CPU_FEATURE_WDT, "wdt" }, - { CPU_FEATURE_TS, "ts" }, - { CPU_FEATURE_FID, "fid" }, - { CPU_FEATURE_VID, "vid" }, - { CPU_FEATURE_TTP, "ttp" }, - { CPU_FEATURE_TM_AMD, "tm_amd" }, - { CPU_FEATURE_STC, "stc" }, - { CPU_FEATURE_100MHZSTEPS, "100mhzsteps" }, - { CPU_FEATURE_HWPSTATE, "hwpstate" }, - { CPU_FEATURE_CONSTANT_TSC, "constant_tsc" }, - { CPU_FEATURE_XOP, "xop" }, - { CPU_FEATURE_FMA3, "fma3" }, - { CPU_FEATURE_FMA4, "fma4" }, - { CPU_FEATURE_TBM, "tbm" }, - { CPU_FEATURE_F16C, "f16c" }, - { CPU_FEATURE_RDRAND, "rdrand" }, - { CPU_FEATURE_CPB, "cpb" }, - { CPU_FEATURE_APERFMPERF, "aperfmperf" }, - { CPU_FEATURE_PFI, "pfi" }, - { CPU_FEATURE_PA, "pa" }, - { CPU_FEATURE_AVX2, "avx2" }, - { CPU_FEATURE_BMI1, "bmi1" }, - { CPU_FEATURE_BMI2, "bmi2" }, - { CPU_FEATURE_HLE, "hle" }, - { CPU_FEATURE_RTM, "rtm" }, - { CPU_FEATURE_AVX512F, "avx512f" }, - { CPU_FEATURE_AVX512DQ, "avx512dq" }, - { CPU_FEATURE_AVX512PF, "avx512pf" }, - { CPU_FEATURE_AVX512ER, "avx512er" }, - { CPU_FEATURE_AVX512CD, "avx512cd" }, - { CPU_FEATURE_SHA_NI, "sha_ni" }, - { CPU_FEATURE_AVX512BW, "avx512bw" }, - { CPU_FEATURE_AVX512VL, "avx512vl" }, - { CPU_FEATURE_SGX, "sgx" }, - { CPU_FEATURE_RDSEED, "rdseed" }, - { CPU_FEATURE_ADX, "adx" }, - }; - unsigned i, n = COUNT_OF(matchtable); - if (n != NUM_CPU_FEATURES) { - warnf("Warning: incomplete library, feature matchtable size differs from the actual number of features.\n"); - } - for (i = 0; i < n; i++) - if (matchtable[i].feature == feature) - return matchtable[i].name; - return ""; -} - -const char* cpuid_error(void) -{ - const struct { cpu_error_t error; const char *description; } - matchtable[] = { - { ERR_OK , "No error"}, - { ERR_NO_CPUID , "CPUID instruction is not supported"}, - { ERR_NO_RDTSC , "RDTSC instruction is not supported"}, - { ERR_NO_MEM , "Memory allocation failed"}, - { ERR_OPEN , "File open operation failed"}, - { ERR_BADFMT , "Bad file format"}, - { ERR_NOT_IMP , "Not implemented"}, - { ERR_CPU_UNKN , "Unsupported processor"}, - { ERR_NO_RDMSR , "RDMSR instruction is not supported"}, - { ERR_NO_DRIVER, "RDMSR driver error (generic)"}, - { ERR_NO_PERMS , "No permissions to install RDMSR driver"}, - { ERR_EXTRACT , "Cannot extract RDMSR driver (read only media?)"}, - { ERR_HANDLE , "Bad handle"}, - { ERR_INVMSR , "Invalid MSR"}, - { ERR_INVCNB , "Invalid core number"}, - { ERR_HANDLE_R , "Error on handle read"}, - { ERR_INVRANGE , "Invalid given range"}, - }; - unsigned i; - for (i = 0; i < COUNT_OF(matchtable); i++) - if (_libcpiud_errno == matchtable[i].error) - return matchtable[i].description; - return "Unknown error"; -} - - -const char* cpuid_lib_version(void) -{ - return VERSION; -} - -libcpuid_warn_fn_t cpuid_set_warn_function(libcpuid_warn_fn_t new_fn) -{ - libcpuid_warn_fn_t ret = _warn_fun; - _warn_fun = new_fn; - return ret; -} - -void cpuid_set_verbosiness_level(int level) -{ - _current_verboselevel = level; -} - -cpu_vendor_t cpuid_get_vendor(void) -{ - static cpu_vendor_t vendor = VENDOR_UNKNOWN; - uint32_t raw_vendor[4]; - char vendor_str[VENDOR_STR_MAX]; - - if(vendor == VENDOR_UNKNOWN) { - if (!cpuid_present()) - set_error(ERR_NO_CPUID); - else { - cpu_exec_cpuid(0, raw_vendor); - vendor = cpuid_vendor_identify(raw_vendor, vendor_str); - } - } - return vendor; -} - -void cpuid_get_cpu_list(cpu_vendor_t vendor, struct cpu_list_t* list) -{ - switch (vendor) { - case VENDOR_INTEL: - cpuid_get_list_intel(list); - break; - case VENDOR_AMD: - cpuid_get_list_amd(list); - break; - case VENDOR_CYRIX: - make_list_from_string("Cx486,Cx5x86,6x86,6x86MX,M II,MediaGX,MediaGXi,MediaGXm", list); - break; - case VENDOR_NEXGEN: - make_list_from_string("Nx586", list); - break; - case VENDOR_TRANSMETA: - make_list_from_string("Crusoe,Efficeon", list); - break; - case VENDOR_UMC: - make_list_from_string("UMC x86 CPU", list); - break; - case VENDOR_CENTAUR: - make_list_from_string("VIA C3,VIA C7,VIA Nano", list); - break; - case VENDOR_RISE: - make_list_from_string("Rise mP6", list); - break; - case VENDOR_SIS: - make_list_from_string("SiS mP6", list); - break; - case VENDOR_NSC: - make_list_from_string("Geode GXm,Geode GXLV,Geode GX1,Geode GX2", list); - break; - default: - warnf("Unknown vendor passed to cpuid_get_cpu_list()\n"); - break; - } -} - -void cpuid_free_cpu_list(struct cpu_list_t* list) -{ - int i; - if (list->num_entries <= 0) return; - for (i = 0; i < list->num_entries; i++) - free(list->names[i]); - free(list->names); -} diff --git a/contrib/libcpuid/include/libcpuid/intel_code_t.h b/contrib/libcpuid/include/libcpuid/intel_code_t.h deleted file mode 100644 index c50ec9c5a83..00000000000 --- a/contrib/libcpuid/include/libcpuid/intel_code_t.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This file contains a list of internal codes we use in detection. It is - * of no external use and isn't a complete list of intel products. - */ - CODE2(PENTIUM, 2000), - CODE(MOBILE_PENTIUM), - - CODE(XEON), - CODE(XEON_IRWIN), - CODE(XEONMP), - CODE(XEON_POTOMAC), - CODE(XEON_I7), - CODE(XEON_GAINESTOWN), - CODE(XEON_WESTMERE), - - CODE(MOBILE_PENTIUM_M), - CODE(CELERON), - CODE(MOBILE_CELERON), - CODE(NOT_CELERON), - - - CODE(CORE_SOLO), - CODE(MOBILE_CORE_SOLO), - CODE(CORE_DUO), - CODE(MOBILE_CORE_DUO), - - CODE(WOLFDALE), - CODE(MEROM), - CODE(PENRYN), - CODE(QUAD_CORE), - CODE(DUAL_CORE_HT), - CODE(QUAD_CORE_HT), - CODE(MORE_THAN_QUADCORE), - CODE(PENTIUM_D), - - CODE(ATOM_UNKNOWN), - CODE(ATOM_SILVERTHORNE), - CODE(ATOM_DIAMONDVILLE), - CODE(ATOM_PINEVIEW), - CODE(ATOM_CEDARVIEW), - - CODE(CORE_I3), - CODE(CORE_I5), - CODE(CORE_I7), - CODE(CORE_IVY3), /* 22nm Core-iX */ - CODE(CORE_IVY5), - CODE(CORE_IVY7), - CODE(CORE_HASWELL3), /* 22nm Core-iX, Haswell */ - CODE(CORE_HASWELL5), - CODE(CORE_HASWELL7), - CODE(CORE_BROADWELL3), /* 14nm Core-iX, Broadwell */ - CODE(CORE_BROADWELL5), - CODE(CORE_BROADWELL7), - CODE(CORE_SKYLAKE3), /* 14nm Core-iX, Skylake */ - CODE(CORE_SKYLAKE5), - CODE(CORE_SKYLAKE7), - diff --git a/contrib/libcpuid/include/libcpuid/libcpuid.h b/contrib/libcpuid/include/libcpuid/libcpuid.h deleted file mode 100644 index 866c0e8441d..00000000000 --- a/contrib/libcpuid/include/libcpuid/libcpuid.h +++ /dev/null @@ -1,1129 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __LIBCPUID_H__ -#define __LIBCPUID_H__ -/** - * \file libcpuid.h - * \author Veselin Georgiev - * \date Oct 2008 - * \version 0.4.0 - * - * Version history: - * - * * 0.1.0 (2008-10-15): initial adaptation from wxfractgui sources - * * 0.1.1 (2009-07-06): Added intel_fn11 fields to cpu_raw_data_t to handle - * new processor topology enumeration required on Core i7 - * * 0.1.2 (2009-09-26): Added support for MSR reading through self-extracting - * kernel driver on Win32. - * * 0.1.3 (2010-04-20): Added support for greater more accurate CPU clock - * measurements with cpu_clock_by_ic() - * * 0.2.0 (2011-10-11): Support for AMD Bulldozer CPUs, 128-bit SSE unit size - * checking. A backwards-incompatible change, since the - * sizeof cpu_id_t is now different. - * * 0.2.1 (2012-05-26): Support for Ivy Bridge, and detecting the presence of - * the RdRand instruction. - * * 0.2.2 (2015-11-04): Support for newer processors up to Haswell and Vishera. - * Fix clock detection in cpu_clock_by_ic() for Bulldozer. - * More entries supported in cpu_msrinfo(). - * *BSD and Solaris support (unofficial). - * * 0.3.0 (2016-07-09): Support for Skylake; MSR ops in FreeBSD; INFO_VOLTAGE - * for AMD CPUs. Level 4 cache support for Crystalwell - * (a backwards-incompatible change since the sizeof - * cpu_raw_data_t is now different). - * * 0.4.0 (2016-09-30): Better detection of AMD clock multiplier with msrinfo. - * Support for Intel SGX detection - * (a backwards-incompatible change since the sizeof - * cpu_raw_data_t and cpu_id_t is now different). - */ - -/** @mainpage A simple libcpuid introduction - * - * LibCPUID provides CPU identification and access to the CPUID and RDTSC - * instructions on the x86. - *

- * To execute CPUID, use \ref cpu_exec_cpuid
- * To execute RDTSC, use \ref cpu_rdtsc
- * To fetch the CPUID info needed for CPU identification, use - * \ref cpuid_get_raw_data
- * To make sense of that data (decode, extract features), use \ref cpu_identify
- * To detect the CPU speed, use either \ref cpu_clock, \ref cpu_clock_by_os, - * \ref cpu_tsc_mark + \ref cpu_tsc_unmark + \ref cpu_clock_by_mark, - * \ref cpu_clock_measure or \ref cpu_clock_by_ic. - * Read carefully for pros/cons of each method.
- * - * To read MSRs, use \ref cpu_msr_driver_open to get a handle, and then - * \ref cpu_rdmsr for querying abilities. Some MSR decoding is available on recent - * CPUs, and can be queried through \ref cpu_msrinfo; the various types of queries - * are described in \ref cpu_msrinfo_request_t. - *

- */ - -/** @defgroup libcpuid LibCPUID - @{ */ - -/* Include some integer type specifications: */ -#include "libcpuid_types.h" - -/* Some limits and other constants */ -#include "libcpuid_constants.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief CPU vendor, as guessed from the Vendor String. - */ -typedef enum { - VENDOR_INTEL = 0, /*!< Intel CPU */ - VENDOR_AMD, /*!< AMD CPU */ - VENDOR_CYRIX, /*!< Cyrix CPU */ - VENDOR_NEXGEN, /*!< NexGen CPU */ - VENDOR_TRANSMETA, /*!< Transmeta CPU */ - VENDOR_UMC, /*!< x86 CPU by UMC */ - VENDOR_CENTAUR, /*!< x86 CPU by IDT */ - VENDOR_RISE, /*!< x86 CPU by Rise Technology */ - VENDOR_SIS, /*!< x86 CPU by SiS */ - VENDOR_NSC, /*!< x86 CPU by National Semiconductor */ - - NUM_CPU_VENDORS, /*!< Valid CPU vendor ids: 0..NUM_CPU_VENDORS - 1 */ - VENDOR_UNKNOWN = -1, -} cpu_vendor_t; -#define NUM_CPU_VENDORS NUM_CPU_VENDORS - -/** - * @brief Contains just the raw CPUID data. - * - * This contains only the most basic CPU data, required to do identification - * and feature recognition. Every processor should be identifiable using this - * data only. - */ -struct cpu_raw_data_t { - /** contains results of CPUID for eax = 0, 1, ...*/ - uint32_t basic_cpuid[MAX_CPUID_LEVEL][4]; - - /** contains results of CPUID for eax = 0x80000000, 0x80000001, ...*/ - uint32_t ext_cpuid[MAX_EXT_CPUID_LEVEL][4]; - - /** when the CPU is intel and it supports deterministic cache - information: this contains the results of CPUID for eax = 4 - and ecx = 0, 1, ... */ - uint32_t intel_fn4[MAX_INTELFN4_LEVEL][4]; - - /** when the CPU is intel and it supports leaf 0Bh (Extended Topology - enumeration leaf), this stores the result of CPUID with - eax = 11 and ecx = 0, 1, 2... */ - uint32_t intel_fn11[MAX_INTELFN11_LEVEL][4]; - - /** when the CPU is intel and supports leaf 12h (SGX enumeration leaf), - * this stores the result of CPUID with eax = 0x12 and - * ecx = 0, 1, 2... */ - uint32_t intel_fn12h[MAX_INTELFN12H_LEVEL][4]; - - /** when the CPU is intel and supports leaf 14h (Intel Processor Trace - * capabilities leaf). - * this stores the result of CPUID with eax = 0x12 and - * ecx = 0, 1, 2... */ - uint32_t intel_fn14h[MAX_INTELFN14H_LEVEL][4]; -}; - -/** - * @brief This contains information about SGX features of the processor - * Example usage: - * @code - * ... - * struct cpu_raw_data_t raw; - * struct cpu_id_t id; - * - * if (cpuid_get_raw_data(&raw) == 0 && cpu_identify(&raw, &id) == 0 && id.sgx.present) { - * printf("SGX is present.\n"); - * printf("SGX1 instructions: %s.\n", id.sgx.flags[INTEL_SGX1] ? "present" : "absent"); - * printf("SGX2 instructions: %s.\n", id.sgx.flags[INTEL_SGX2] ? "present" : "absent"); - * printf("Max 32-bit enclave size: 2^%d bytes.\n", id.sgx.max_enclave_32bit); - * printf("Max 64-bit enclave size: 2^%d bytes.\n", id.sgx.max_enclave_64bit); - * for (int i = 0; i < id.sgx.num_epc_sections; i++) { - * struct cpu_epc_t epc = cpuid_get_epc(i, NULL); - * printf("EPC section #%d: address = %x, size = %d bytes.\n", epc.address, epc.size); - * } - * } else { - * printf("SGX is not present.\n"); - * } - * @endcode - */ -struct cpu_sgx_t { - /** Whether SGX is present (boolean) */ - uint32_t present; - - /** Max enclave size in 32-bit mode. This is a power-of-two value: - * if it is "31", then the max enclave size is 2^31 bytes (2 GiB). - */ - uint8_t max_enclave_32bit; - - /** Max enclave size in 64-bit mode. This is a power-of-two value: - * if it is "36", then the max enclave size is 2^36 bytes (64 GiB). - */ - uint8_t max_enclave_64bit; - - /** - * contains SGX feature flags. See the \ref cpu_sgx_feature_t - * "INTEL_SGX*" macros below. - */ - uint8_t flags[SGX_FLAGS_MAX]; - - /** number of Enclave Page Cache (EPC) sections. Info for each - * section is available through the \ref cpuid_get_epc() function - */ - int num_epc_sections; - - /** bit vector of the supported extended features that can be written - * to the MISC region of the SSA (Save State Area) - */ - uint32_t misc_select; - - /** a bit vector of the attributes that can be set to SECS.ATTRIBUTES - * via ECREATE. Corresponds to bits 0-63 (incl.) of SECS.ATTRIBUTES. - */ - uint64_t secs_attributes; - - /** a bit vector of the bits that can be set in the XSAVE feature - * request mask; Corresponds to bits 64-127 of SECS.ATTRIBUTES. - */ - uint64_t secs_xfrm; -}; - -/** - * @brief This contains the recognized CPU features/info - */ -struct cpu_id_t { - /** contains the CPU vendor string, e.g. "GenuineIntel" */ - char vendor_str[VENDOR_STR_MAX]; - - /** contains the brand string, e.g. "Intel(R) Xeon(TM) CPU 2.40GHz" */ - char brand_str[BRAND_STR_MAX]; - - /** contains the recognized CPU vendor */ - cpu_vendor_t vendor; - - /** - * contain CPU flags. Used to test for features. See - * the \ref cpu_feature_t "CPU_FEATURE_*" macros below. - * @see Features - */ - uint8_t flags[CPU_FLAGS_MAX]; - - /** CPU family */ - int32_t family; - - /** CPU model */ - int32_t model; - - /** CPU stepping */ - int32_t stepping; - - /** CPU extended family */ - int32_t ext_family; - - /** CPU extended model */ - int32_t ext_model; - - /** Number of CPU cores on the current processor */ - int32_t num_cores; - - /** - * Number of logical processors on the current processor. - * Could be more than the number of physical cores, - * e.g. when the processor has HyperThreading. - */ - int32_t num_logical_cpus; - - /** - * The total number of logical processors. - * The same value is availabe through \ref cpuid_get_total_cpus. - * - * This is num_logical_cpus * {total physical processors in the system} - * (but only on a real system, under a VM this number may be lower). - * - * If you're writing a multithreaded program and you want to run it on - * all CPUs, this is the number of threads you need. - * - * @note in a VM, this will exactly match the number of CPUs set in - * the VM's configuration. - * - */ - int32_t total_logical_cpus; - - /** - * L1 data cache size in KB. Could be zero, if the CPU lacks cache. - * If the size cannot be determined, it will be -1. - */ - int32_t l1_data_cache; - - /** - * L1 instruction cache size in KB. Could be zero, if the CPU lacks - * cache. If the size cannot be determined, it will be -1. - * @note On some Intel CPUs, whose instruction cache is in fact - * a trace cache, the size will be expressed in K uOps. - */ - int32_t l1_instruction_cache; - - /** - * L2 cache size in KB. Could be zero, if the CPU lacks L2 cache. - * If the size of the cache could not be determined, it will be -1 - */ - int32_t l2_cache; - - /** L3 cache size in KB. Zero on most systems */ - int32_t l3_cache; - - /** L4 cache size in KB. Zero on most systems */ - int32_t l4_cache; - - /** Cache associativity for the L1 data cache. -1 if undetermined */ - int32_t l1_assoc; - - /** Cache associativity for the L2 cache. -1 if undetermined */ - int32_t l2_assoc; - - /** Cache associativity for the L3 cache. -1 if undetermined */ - int32_t l3_assoc; - - /** Cache associativity for the L4 cache. -1 if undetermined */ - int32_t l4_assoc; - - /** Cache-line size for L1 data cache. -1 if undetermined */ - int32_t l1_cacheline; - - /** Cache-line size for L2 cache. -1 if undetermined */ - int32_t l2_cacheline; - - /** Cache-line size for L3 cache. -1 if undetermined */ - int32_t l3_cacheline; - - /** Cache-line size for L4 cache. -1 if undetermined */ - int32_t l4_cacheline; - - /** - * The brief and human-friendly CPU codename, which was recognized.
- * Examples: - * @code - * +--------+--------+-------+-------+-------+---------------------------------------+-----------------------+ - * | Vendor | Family | Model | Step. | Cache | Brand String | cpu_id_t.cpu_codename | - * +--------+--------+-------+-------+-------+---------------------------------------+-----------------------+ - * | AMD | 6 | 8 | 0 | 256 | (not available - will be ignored) | "K6-2" | - * | Intel | 15 | 2 | 5 | 512 | "Intel(R) Xeon(TM) CPU 2.40GHz" | "Xeon (Prestonia)" | - * | Intel | 6 | 15 | 11 | 4096 | "Intel(R) Core(TM)2 Duo CPU E6550..." | "Conroe (Core 2 Duo)" | - * | AMD | 15 | 35 | 2 | 1024 | "Dual Core AMD Opteron(tm) Proces..." | "Opteron (Dual Core)" | - * +--------+--------+-------+-------+-------+---------------------------------------+-----------------------+ - * @endcode - */ - char cpu_codename[64]; - - /** SSE execution unit size (64 or 128; -1 if N/A) */ - int32_t sse_size; - - /** - * contain miscellaneous detection information. Used to test about specifics of - * certain detected features. See \ref cpu_hint_t "CPU_HINT_*" macros below. - * @see Hints - */ - uint8_t detection_hints[CPU_HINTS_MAX]; - - /** contains information about SGX features if the processor, if present */ - struct cpu_sgx_t sgx; -}; - -/** - * @brief CPU feature identifiers - * - * Usage: - * @code - * ... - * struct cpu_raw_data_t raw; - * struct cpu_id_t id; - * if (cpuid_get_raw_data(&raw) == 0 && cpu_identify(&raw, &id) == 0) { - * if (id.flags[CPU_FEATURE_SSE2]) { - * // The CPU has SSE2... - * ... - * } else { - * // no SSE2 - * } - * } else { - * // processor cannot be determined. - * } - * @endcode - */ -typedef enum { - CPU_FEATURE_FPU = 0, /*!< Floating point unit */ - CPU_FEATURE_VME, /*!< Virtual mode extension */ - CPU_FEATURE_DE, /*!< Debugging extension */ - CPU_FEATURE_PSE, /*!< Page size extension */ - CPU_FEATURE_TSC, /*!< Time-stamp counter */ - CPU_FEATURE_MSR, /*!< Model-specific regsisters, RDMSR/WRMSR supported */ - CPU_FEATURE_PAE, /*!< Physical address extension */ - CPU_FEATURE_MCE, /*!< Machine check exception */ - CPU_FEATURE_CX8, /*!< CMPXCHG8B instruction supported */ - CPU_FEATURE_APIC, /*!< APIC support */ - CPU_FEATURE_MTRR, /*!< Memory type range registers */ - CPU_FEATURE_SEP, /*!< SYSENTER / SYSEXIT instructions supported */ - CPU_FEATURE_PGE, /*!< Page global enable */ - CPU_FEATURE_MCA, /*!< Machine check architecture */ - CPU_FEATURE_CMOV, /*!< CMOVxx instructions supported */ - CPU_FEATURE_PAT, /*!< Page attribute table */ - CPU_FEATURE_PSE36, /*!< 36-bit page address extension */ - CPU_FEATURE_PN, /*!< Processor serial # implemented (Intel P3 only) */ - CPU_FEATURE_CLFLUSH, /*!< CLFLUSH instruction supported */ - CPU_FEATURE_DTS, /*!< Debug store supported */ - CPU_FEATURE_ACPI, /*!< ACPI support (power states) */ - CPU_FEATURE_MMX, /*!< MMX instruction set supported */ - CPU_FEATURE_FXSR, /*!< FXSAVE / FXRSTOR supported */ - CPU_FEATURE_SSE, /*!< Streaming-SIMD Extensions (SSE) supported */ - CPU_FEATURE_SSE2, /*!< SSE2 instructions supported */ - CPU_FEATURE_SS, /*!< Self-snoop */ - CPU_FEATURE_HT, /*!< Hyper-threading supported (but might be disabled) */ - CPU_FEATURE_TM, /*!< Thermal monitor */ - CPU_FEATURE_IA64, /*!< IA64 supported (Itanium only) */ - CPU_FEATURE_PBE, /*!< Pending-break enable */ - CPU_FEATURE_PNI, /*!< PNI (SSE3) instructions supported */ - CPU_FEATURE_PCLMUL, /*!< PCLMULQDQ instruction supported */ - CPU_FEATURE_DTS64, /*!< 64-bit Debug store supported */ - CPU_FEATURE_MONITOR, /*!< MONITOR / MWAIT supported */ - CPU_FEATURE_DS_CPL, /*!< CPL Qualified Debug Store */ - CPU_FEATURE_VMX, /*!< Virtualization technology supported */ - CPU_FEATURE_SMX, /*!< Safer mode exceptions */ - CPU_FEATURE_EST, /*!< Enhanced SpeedStep */ - CPU_FEATURE_TM2, /*!< Thermal monitor 2 */ - CPU_FEATURE_SSSE3, /*!< SSSE3 instructionss supported (this is different from SSE3!) */ - CPU_FEATURE_CID, /*!< Context ID supported */ - CPU_FEATURE_CX16, /*!< CMPXCHG16B instruction supported */ - CPU_FEATURE_XTPR, /*!< Send Task Priority Messages disable */ - CPU_FEATURE_PDCM, /*!< Performance capabilities MSR supported */ - CPU_FEATURE_DCA, /*!< Direct cache access supported */ - CPU_FEATURE_SSE4_1, /*!< SSE 4.1 instructions supported */ - CPU_FEATURE_SSE4_2, /*!< SSE 4.2 instructions supported */ - CPU_FEATURE_SYSCALL, /*!< SYSCALL / SYSRET instructions supported */ - CPU_FEATURE_XD, /*!< Execute disable bit supported */ - CPU_FEATURE_MOVBE, /*!< MOVBE instruction supported */ - CPU_FEATURE_POPCNT, /*!< POPCNT instruction supported */ - CPU_FEATURE_AES, /*!< AES* instructions supported */ - CPU_FEATURE_XSAVE, /*!< XSAVE/XRSTOR/etc instructions supported */ - CPU_FEATURE_OSXSAVE, /*!< non-privileged copy of OSXSAVE supported */ - CPU_FEATURE_AVX, /*!< Advanced vector extensions supported */ - CPU_FEATURE_MMXEXT, /*!< AMD MMX-extended instructions supported */ - CPU_FEATURE_3DNOW, /*!< AMD 3DNow! instructions supported */ - CPU_FEATURE_3DNOWEXT, /*!< AMD 3DNow! extended instructions supported */ - CPU_FEATURE_NX, /*!< No-execute bit supported */ - CPU_FEATURE_FXSR_OPT, /*!< FFXSR: FXSAVE and FXRSTOR optimizations */ - CPU_FEATURE_RDTSCP, /*!< RDTSCP instruction supported (AMD-only) */ - CPU_FEATURE_LM, /*!< Long mode (x86_64/EM64T) supported */ - CPU_FEATURE_LAHF_LM, /*!< LAHF/SAHF supported in 64-bit mode */ - CPU_FEATURE_CMP_LEGACY, /*!< core multi-processing legacy mode */ - CPU_FEATURE_SVM, /*!< AMD Secure virtual machine */ - CPU_FEATURE_ABM, /*!< LZCNT instruction support */ - CPU_FEATURE_MISALIGNSSE,/*!< Misaligned SSE supported */ - CPU_FEATURE_SSE4A, /*!< SSE 4a from AMD */ - CPU_FEATURE_3DNOWPREFETCH, /*!< PREFETCH/PREFETCHW support */ - CPU_FEATURE_OSVW, /*!< OS Visible Workaround (AMD) */ - CPU_FEATURE_IBS, /*!< Instruction-based sampling */ - CPU_FEATURE_SSE5, /*!< SSE 5 instructions supported (deprecated, will never be 1) */ - CPU_FEATURE_SKINIT, /*!< SKINIT / STGI supported */ - CPU_FEATURE_WDT, /*!< Watchdog timer support */ - CPU_FEATURE_TS, /*!< Temperature sensor */ - CPU_FEATURE_FID, /*!< Frequency ID control */ - CPU_FEATURE_VID, /*!< Voltage ID control */ - CPU_FEATURE_TTP, /*!< THERMTRIP */ - CPU_FEATURE_TM_AMD, /*!< AMD-specified hardware thermal control */ - CPU_FEATURE_STC, /*!< Software thermal control */ - CPU_FEATURE_100MHZSTEPS,/*!< 100 MHz multiplier control */ - CPU_FEATURE_HWPSTATE, /*!< Hardware P-state control */ - CPU_FEATURE_CONSTANT_TSC, /*!< TSC ticks at constant rate */ - CPU_FEATURE_XOP, /*!< The XOP instruction set (same as the old CPU_FEATURE_SSE5) */ - CPU_FEATURE_FMA3, /*!< The FMA3 instruction set */ - CPU_FEATURE_FMA4, /*!< The FMA4 instruction set */ - CPU_FEATURE_TBM, /*!< Trailing bit manipulation instruction support */ - CPU_FEATURE_F16C, /*!< 16-bit FP convert instruction support */ - CPU_FEATURE_RDRAND, /*!< RdRand instruction */ - CPU_FEATURE_X2APIC, /*!< x2APIC, APIC_BASE.EXTD, MSRs 0000_0800h...0000_0BFFh 64-bit ICR (+030h but not +031h), no DFR (+00Eh), SELF_IPI (+040h) also see standard level 0000_000Bh */ - CPU_FEATURE_CPB, /*!< Core performance boost */ - CPU_FEATURE_APERFMPERF, /*!< MPERF/APERF MSRs support */ - CPU_FEATURE_PFI, /*!< Processor Feedback Interface support */ - CPU_FEATURE_PA, /*!< Processor accumulator */ - CPU_FEATURE_AVX2, /*!< AVX2 instructions */ - CPU_FEATURE_BMI1, /*!< BMI1 instructions */ - CPU_FEATURE_BMI2, /*!< BMI2 instructions */ - CPU_FEATURE_HLE, /*!< Hardware Lock Elision prefixes */ - CPU_FEATURE_RTM, /*!< Restricted Transactional Memory instructions */ - CPU_FEATURE_AVX512F, /*!< AVX-512 Foundation */ - CPU_FEATURE_AVX512DQ, /*!< AVX-512 Double/Quad granular insns */ - CPU_FEATURE_AVX512PF, /*!< AVX-512 Prefetch */ - CPU_FEATURE_AVX512ER, /*!< AVX-512 Exponential/Reciprocal */ - CPU_FEATURE_AVX512CD, /*!< AVX-512 Conflict detection */ - CPU_FEATURE_SHA_NI, /*!< SHA-1/SHA-256 instructions */ - CPU_FEATURE_AVX512BW, /*!< AVX-512 Byte/Word granular insns */ - CPU_FEATURE_AVX512VL, /*!< AVX-512 128/256 vector length extensions */ - CPU_FEATURE_SGX, /*!< SGX extensions. Non-autoritative, check cpu_id_t::sgx::present to verify presence */ - CPU_FEATURE_RDSEED, /*!< RDSEED instruction */ - CPU_FEATURE_ADX, /*!< ADX extensions (arbitrary precision) */ - /* termination: */ - NUM_CPU_FEATURES, -} cpu_feature_t; - -/** - * @brief CPU detection hints identifiers - * - * Usage: similar to the flags usage - */ -typedef enum { - CPU_HINT_SSE_SIZE_AUTH = 0, /*!< SSE unit size is authoritative (not only a Family/Model guesswork, but based on an actual CPUID bit) */ - /* termination */ - NUM_CPU_HINTS, -} cpu_hint_t; - -/** - * @brief SGX features flags - * \see cpu_sgx_t - * - * Usage: - * @code - * ... - * struct cpu_raw_data_t raw; - * struct cpu_id_t id; - * if (cpuid_get_raw_data(&raw) == 0 && cpu_identify(&raw, &id) == 0 && id.sgx.present) { - * if (id.sgx.flags[INTEL_SGX1]) - * // The CPU has SGX1 instructions support... - * ... - * } else { - * // no SGX - * } - * } else { - * // processor cannot be determined. - * } - * @endcode - */ - -typedef enum { - INTEL_SGX1, /*!< SGX1 instructions support */ - INTEL_SGX2, /*!< SGX2 instructions support */ - - /* termination: */ - NUM_SGX_FEATURES, -} cpu_sgx_feature_t; - -/** - * @brief Describes common library error codes - */ -typedef enum { - ERR_OK = 0, /*!< "No error" */ - ERR_NO_CPUID = -1, /*!< "CPUID instruction is not supported" */ - ERR_NO_RDTSC = -2, /*!< "RDTSC instruction is not supported" */ - ERR_NO_MEM = -3, /*!< "Memory allocation failed" */ - ERR_OPEN = -4, /*!< "File open operation failed" */ - ERR_BADFMT = -5, /*!< "Bad file format" */ - ERR_NOT_IMP = -6, /*!< "Not implemented" */ - ERR_CPU_UNKN = -7, /*!< "Unsupported processor" */ - ERR_NO_RDMSR = -8, /*!< "RDMSR instruction is not supported" */ - ERR_NO_DRIVER= -9, /*!< "RDMSR driver error (generic)" */ - ERR_NO_PERMS = -10, /*!< "No permissions to install RDMSR driver" */ - ERR_EXTRACT = -11, /*!< "Cannot extract RDMSR driver (read only media?)" */ - ERR_HANDLE = -12, /*!< "Bad handle" */ - ERR_INVMSR = -13, /*!< "Invalid MSR" */ - ERR_INVCNB = -14, /*!< "Invalid core number" */ - ERR_HANDLE_R = -15, /*!< "Error on handle read" */ - ERR_INVRANGE = -16, /*!< "Invalid given range" */ -} cpu_error_t; - -/** - * @brief Internal structure, used in cpu_tsc_mark, cpu_tsc_unmark and - * cpu_clock_by_mark - */ -struct cpu_mark_t { - uint64_t tsc; /*!< Time-stamp from RDTSC */ - uint64_t sys_clock; /*!< In microsecond resolution */ -}; - -/** - * @brief Returns the total number of logical CPU threads (even if CPUID is not present). - * - * Under VM, this number (and total_logical_cpus, since they are fetched with the same code) - * may be nonsensical, i.e. might not equal NumPhysicalCPUs*NumCoresPerCPU*HyperThreading. - * This is because no matter how many logical threads the host machine has, you may limit them - * in the VM to any number you like. **This** is the number returned by cpuid_get_total_cpus(). - * - * @returns Number of logical CPU threads available. Equals the \ref cpu_id_t::total_logical_cpus. - */ -int cpuid_get_total_cpus(void); - -/** - * @brief Checks if the CPUID instruction is supported - * @retval 1 if CPUID is present - * @retval 0 the CPU doesn't have CPUID. - */ -int cpuid_present(void); - -/** - * @brief Executes the CPUID instruction - * @param eax - the value of the EAX register when executing CPUID - * @param regs - the results will be stored here. regs[0] = EAX, regs[1] = EBX, ... - * @note CPUID will be executed with EAX set to the given value and EBX, ECX, - * EDX set to zero. - */ -void cpu_exec_cpuid(uint32_t eax, uint32_t* regs); - -/** - * @brief Executes the CPUID instruction with the given input registers - * @note This is just a bit more generic version of cpu_exec_cpuid - it allows - * you to control all the registers. - * @param regs - Input/output. Prior to executing CPUID, EAX, EBX, ECX and - * EDX will be set to regs[0], regs[1], regs[2] and regs[3]. - * After CPUID, this array will contain the results. - */ -void cpu_exec_cpuid_ext(uint32_t* regs); - -/** - * @brief Obtains the raw CPUID data from the current CPU - * @param data - a pointer to cpu_raw_data_t structure - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -int cpuid_get_raw_data(struct cpu_raw_data_t* data); - -/** - * @brief Writes the raw CPUID data to a text file - * @param data - a pointer to cpu_raw_data_t structure - * @param filename - the path of the file, where the serialized data should be - * written. If empty, stdout will be used. - * @note This is intended primarily for debugging. On some processor, which is - * not currently supported or not completely recognized by cpu_identify, - * one can still successfully get the raw data and write it to a file. - * libcpuid developers can later import this file and debug the detection - * code as if running on the actual hardware. - * The file is simple text format of "something=value" pairs. Version info - * is also written, but the format is not intended to be neither backward- - * nor forward compatible. - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -int cpuid_serialize_raw_data(struct cpu_raw_data_t* data, const char* filename); - -/** - * @brief Reads raw CPUID data from file - * @param data - a pointer to cpu_raw_data_t structure. The deserialized data will - * be written here. - * @param filename - the path of the file, containing the serialized raw data. - * If empty, stdin will be used. - * @note This function may fail, if the file is created by different version of - * the library. Also, see the notes on cpuid_serialize_raw_data. - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t -*/ -int cpuid_deserialize_raw_data(struct cpu_raw_data_t* data, const char* filename); - -/** - * @brief Identifies the CPU - * @param raw - Input - a pointer to the raw CPUID data, which is obtained - * either by cpuid_get_raw_data or cpuid_deserialize_raw_data. - * Can also be NULL, in which case the functions calls - * cpuid_get_raw_data itself. - * @param data - Output - the decoded CPU features/info is written here. - * @note The function will not fail, even if some of the information - * cannot be obtained. Even when the CPU is new and thus unknown to - * libcpuid, some generic info, such as "AMD K9 family CPU" will be - * written to data.cpu_codename, and most other things, such as the - * CPU flags, cache sizes, etc. should be detected correctly anyway. - * However, the function CAN fail, if the CPU is completely alien to - * libcpuid. - * @note While cpu_identify() and cpuid_get_raw_data() are fast for most - * purposes, running them several thousand times per second can hamper - * performance significantly. Specifically, avoid writing "cpu feature - * checker" wrapping function, which calls cpu_identify and returns the - * value of some flag, if that function is going to be called frequently. - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -int cpu_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data); - -/** - * @brief Returns the short textual representation of a CPU flag - * @param feature - the feature, whose textual representation is wanted. - * @returns a constant string like "fpu", "tsc", "sse2", etc. - * @note the names of the returned flags are compatible with those from - * /proc/cpuinfo in Linux, with the exception of `tm_amd' - */ -const char* cpu_feature_str(cpu_feature_t feature); - -/** - * @brief Returns textual description of the last error - * - * libcpuid stores an `errno'-style error status, whose description - * can be obtained with this function. - * @note This function is not thread-safe - * @see cpu_error_t - */ -const char* cpuid_error(void); - -/** - * @brief Executes RDTSC - * - * The RDTSC (ReaD Time Stamp Counter) instruction gives access to an - * internal 64-bit counter, which usually increments at each clock cycle. - * This can be used for various timing routines, and as a very precise - * clock source. It is set to zero on system startup. Beware that may not - * increment at the same frequency as the CPU. Consecutive calls of RDTSC - * are, however, guaranteed to return monotonically-increasing values. - * - * @param result - a pointer to a 64-bit unsigned integer, where the TSC value - * will be stored - * - * @note If 100% compatibility is a concern, you must first check if the - * RDTSC instruction is present (if it is not, your program will crash - * with "invalid opcode" exception). Only some very old processors (i486, - * early AMD K5 and some Cyrix CPUs) lack that instruction - they should - * have become exceedingly rare these days. To verify RDTSC presence, - * run cpu_identify() and check flags[CPU_FEATURE_TSC]. - * - * @note The monotonically increasing nature of the TSC may be violated - * on SMP systems, if their TSC clocks run at different rate. If the OS - * doesn't account for that, the TSC drift may become arbitrary large. - */ -void cpu_rdtsc(uint64_t* result); - -/** - * @brief Store TSC and timing info - * - * This function stores the current TSC value and current - * time info from a precise OS-specific clock source in the cpu_mark_t - * structure. The sys_clock field contains time with microsecond resolution. - * The values can later be used to measure time intervals, number of clocks, - * FPU frequency, etc. - * @see cpu_rdtsc - * - * @param mark [out] - a pointer to a cpu_mark_t structure - */ -void cpu_tsc_mark(struct cpu_mark_t* mark); - -/** - * @brief Calculate TSC and timing difference - * - * @param mark - input/output: a pointer to a cpu_mark_t sturcture, which has - * already been initialized by cpu_tsc_mark. The difference in - * TSC and time will be written here. - * - * This function calculates the TSC and time difference, by obtaining the - * current TSC and timing values and subtracting the contents of the `mark' - * structure from them. Results are written in the same structure. - * - * Example: - * @code - * ... - * struct cpu_mark_t mark; - * cpu_tsc_mark(&mark); - * foo(); - * cpu_tsc_unmark(&mark); - * printf("Foo finished. Executed in %llu cycles and %llu usecs\n", - * mark.tsc, mark.sys_clock); - * ... - * @endcode - */ -void cpu_tsc_unmark(struct cpu_mark_t* mark); - -/** - * @brief Calculates the CPU clock - * - * @param mark - pointer to a cpu_mark_t structure, which has been initialized - * with cpu_tsc_mark and later `stopped' with cpu_tsc_unmark. - * - * @note For reliable results, the marked time interval should be at least about - * 10 ms. - * - * @returns the CPU clock frequency, in MHz. Due to measurement error, it will - * differ from the true value in a few least-significant bits. Accuracy depends - * on the timing interval - the more, the better. If the timing interval is - * insufficient, the result is -1. Also, see the comment on cpu_clock_measure - * for additional issues and pitfalls in using RDTSC for CPU frequency - * measurements. - */ -int cpu_clock_by_mark(struct cpu_mark_t* mark); - -/** - * @brief Returns the CPU clock, as reported by the OS - * - * This function uses OS-specific functions to obtain the CPU clock. It may - * differ from the true clock for several reasons:

- * - * i) The CPU might be in some power saving state, while the OS reports its - * full-power frequency, or vice-versa.
- * ii) In some cases you can raise or lower the CPU frequency with overclocking - * utilities and the OS will not notice. - * - * @returns the CPU clock frequency in MHz. If the OS is not (yet) supported - * or lacks the necessary reporting machinery, the return value is -1 - */ -int cpu_clock_by_os(void); - -/** - * @brief Measure the CPU clock frequency - * - * @param millis - How much time to waste in the busy-wait cycle. In millisecs. - * Useful values 10 - 1000 - * @param quad_check - Do a more thorough measurement if nonzero - * (see the explanation). - * - * The function performs a busy-wait cycle for the given time and calculates - * the CPU frequency by the difference of the TSC values. The accuracy of the - * calculation depends on the length of the busy-wait cycle: more is better, - * but 100ms should be enough for most purposes. - * - * While this will calculate the CPU frequency correctly in most cases, there are - * several reasons why it might be incorrect:
- * - * i) RDTSC doesn't guarantee it will run at the same clock as the CPU. - * Apparently there aren't CPUs at the moment, but still, there's no - * guarantee.
- * ii) The CPU might be in a low-frequency power saving mode, and the CPU - * might be switched to higher frequency at any time. If this happens - * during the measurement, the result can be anywhere between the - * low and high frequencies. Also, if you're interested in the - * high frequency value only, this function might return the low one - * instead.
- * iii) On SMP systems exhibiting TSC drift (see \ref cpu_rdtsc) - * - * the quad_check option will run four consecutive measurements and - * then return the average of the two most-consistent results. The total - * runtime of the function will still be `millis' - consider using - * a bit more time for the timing interval. - * - * Finally, for benchmarking / CPU intensive applications, the best strategy is - * to use the cpu_tsc_mark() / cpu_tsc_unmark() / cpu_clock_by_mark() method. - * Begin by mark()-ing about one second after application startup (allowing the - * power-saving manager to kick in and rise the frequency during that time), - * then unmark() just before application finishing. The result will most - * acurately represent at what frequency your app was running. - * - * @returns the CPU clock frequency in MHz (within some measurement error - * margin). If RDTSC is not supported, the result is -1. - */ -int cpu_clock_measure(int millis, int quad_check); - -/** - * @brief Measure the CPU clock frequency using instruction-counting - * - * @param millis - how much time to allocate for each run, in milliseconds - * @param runs - how many runs to perform - * - * The function performs a busy-wait cycle using a known number of "heavy" (SSE) - * instructions. These instructions run at (more or less guaranteed) 1 IPC rate, - * so by running a busy loop for a fixed amount of time, and measuring the - * amount of instructions done, the CPU clock is accurately measured. - * - * Of course, this function is still affected by the power-saving schemes, so - * the warnings as of cpu_clock_measure() still apply. However, this function is - * immune to problems with detection, related to the Intel Nehalem's "Turbo" - * mode, where the internal clock is raised, but the RDTSC rate is unaffected. - * - * The function will run for about (millis * runs) milliseconds. - * You can make only a single busy-wait run (runs == 1); however, this can - * be affected by task scheduling (which will break the counting), so allowing - * more than one run is recommended. As run length is not imperative for - * accurate readings (e.g., 50ms is sufficient), you can afford a lot of short - * runs, e.g. 10 runs of 50ms or 20 runs of 25ms. - * - * Recommended values - millis = 50, runs = 4. For more robustness, - * increase the number of runs. - * - * NOTE: on Bulldozer and later CPUs, the busy-wait cycle runs at 1.4 IPC, thus - * the results are skewed. This is corrected internally by dividing the resulting - * value by 1.4. - * However, this only occurs if the thread is executed on a single CMT - * module - if there are other threads competing for resources, the results are - * unpredictable. Make sure you run cpu_clock_by_ic() on a CPU that is free from - * competing threads, or if there are such threads, they shouldn't exceed the - * number of modules. On a Bulldozer X8, that means 4 threads. - * - * @returns the CPU clock frequency in MHz (within some measurement error - * margin). If SSE is not supported, the result is -1. If the input parameters - * are incorrect, or some other internal fault is detected, the result is -2. - */ -int cpu_clock_by_ic(int millis, int runs); - -/** - * @brief Get the CPU clock frequency (all-in-one method) - * - * This is an all-in-one method for getting the CPU clock frequency. - * It tries to use the OS for that. If the OS doesn't have this info, it - * uses cpu_clock_measure with 200ms time interval and quadruple checking. - * - * @returns the CPU clock frequency in MHz. If every possible method fails, - * the result is -1. - */ -int cpu_clock(void); - - -/** - * @brief The return value of cpuid_get_epc(). - * @details - * Describes an EPC (Enclave Page Cache) layout (physical address and size). - * A CPU may have one or more EPC areas, and information about each is - * fetched via \ref cpuid_get_epc. - */ -struct cpu_epc_t { - uint64_t start_addr; - uint64_t length; -}; - -/** - * @brief Fetches information about an EPC (Enclave Page Cache) area. - * @param index - zero-based index, valid range [0..cpu_id_t.egx.num_epc_sections) - * @param raw - a pointer to fetched raw CPUID data. Needed only for testing, - * you can safely pass NULL here (if you pass a real structure, - * it will be used for fetching the leaf 12h data if index < 2; - * otherwise the real CPUID instruction will be used). - * @returns the requested data. If the CPU doesn't support SGX, or if - * index >= cpu_id_t.egx.num_epc_sections, both fields of the returned - * structure will be zeros. - */ -struct cpu_epc_t cpuid_get_epc(int index, const struct cpu_raw_data_t* raw); - -/** - * @brief Returns the libcpuid version - * - * @returns the string representation of the libcpuid version, like "0.1.1" - */ -const char* cpuid_lib_version(void); - -typedef void (*libcpuid_warn_fn_t) (const char *msg); -/** - * @brief Sets the warning print function - * - * In some cases, the internal libcpuid machinery would like to emit useful - * debug warnings. By default, these warnings are written to stderr. However, - * you can set a custom function that will receive those warnings. - * - * @param warn_fun - the warning function you want to set. If NULL, warnings - * are disabled. The function takes const char* argument. - * - * @returns the current warning function. You can use the return value to - * keep the previous warning function and restore it at your discretion. - */ -libcpuid_warn_fn_t cpuid_set_warn_function(libcpuid_warn_fn_t warn_fun); - -/** - * @brief Sets the verbosiness level - * - * When the verbosiness level is above zero, some functions might print - * diagnostic information about what are they doing. The higher the level is, - * the more detail is printed. Level zero is guaranteed to omit all such - * output. The output is written using the same machinery as the warnings, - * @see cpuid_set_warn_function() - * - * @param level the desired verbosiness level. Useful values 0..2 inclusive - */ -void cpuid_set_verbosiness_level(int level); - - -/** - * @brief Obtains the CPU vendor from CPUID from the current CPU - * @note The result is cached. - * @returns VENDOR_UNKNOWN if failed, otherwise the CPU vendor type. - * @see cpu_vendor_t - */ -cpu_vendor_t cpuid_get_vendor(void); - -/** - * @brief a structure that holds a list of processor names - */ -struct cpu_list_t { - /** Number of entries in the list */ - int num_entries; - /** Pointers to names. There will be num_entries of them */ - char **names; -}; - -/** - * @brief Gets a list of all known CPU names from a specific vendor. - * - * This function compiles a list of all known CPU (code)names - * (i.e. the possible values of cpu_id_t::cpu_codename) for the given vendor. - * - * There are about 100 entries for Intel and AMD, and a few for the other - * vendors. The list is written out in approximate chronological introduction - * order of the parts. - * - * @param vendor the vendor to be queried - * @param list [out] the resulting list will be written here. - * NOTE: As the memory is dynamically allocated, be sure to call - * cpuid_free_cpu_list() after you're done with the data - * @see cpu_list_t - */ -void cpuid_get_cpu_list(cpu_vendor_t vendor, struct cpu_list_t* list); - -/** - * @brief Frees a CPU list - * - * This function deletes all the memory associated with a CPU list, as obtained - * by cpuid_get_cpu_list() - * - * @param list - the list to be free()'d. - */ -void cpuid_free_cpu_list(struct cpu_list_t* list); - -struct msr_driver_t; -/** - * @brief Starts/opens a driver, needed to read MSRs (Model Specific Registers) - * - * On systems that support it, this function will create a temporary - * system driver, that has privileges to execute the RDMSR instruction. - * After the driver is created, you can read MSRs by calling \ref cpu_rdmsr - * - * @returns a handle to the driver on success, and NULL on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -struct msr_driver_t* cpu_msr_driver_open(void); - -/** - * @brief Similar to \ref cpu_msr_driver_open, but accept one parameter - * - * This function works on certain operating systems (GNU/Linux, FreeBSD) - * - * @param core_num specify the core number for MSR. - * The first core number is 0. - * The last core number is \ref cpuid_get_total_cpus - 1. - * - * @returns a handle to the driver on success, and NULL on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -struct msr_driver_t* cpu_msr_driver_open_core(unsigned core_num); - -/** - * @brief Reads a Model-Specific Register (MSR) - * - * If the CPU has MSRs (as indicated by the CPU_FEATURE_MSR flag), you can - * read a MSR with the given index by calling this function. - * - * There are several prerequisites you must do before reading MSRs: - * 1) You must ensure the CPU has RDMSR. Check the CPU_FEATURE_MSR flag - * in cpu_id_t::flags - * 2) You must ensure that the CPU implements the specific MSR you intend to - * read. - * 3) You must open a MSR-reader driver. RDMSR is a privileged instruction and - * needs ring-0 access in order to work. This temporary driver is created - * by calling \ref cpu_msr_driver_open - * - * @param handle - a handle to the MSR reader driver, as created by - * cpu_msr_driver_open - * @param msr_index - the numeric ID of the MSR you want to read - * @param result - a pointer to a 64-bit integer, where the MSR value is stored - * - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -int cpu_rdmsr(struct msr_driver_t* handle, uint32_t msr_index, uint64_t* result); - - -typedef enum { - INFO_MPERF, /*!< Maximum performance frequency clock. This - is a counter, which increments as a - proportion of the actual processor speed. */ - INFO_APERF, /*!< Actual performance frequency clock. This - accumulates the core clock counts when the - core is active. */ - INFO_MIN_MULTIPLIER, /*!< Minimum CPU:FSB ratio for this CPU, - multiplied by 100. */ - INFO_CUR_MULTIPLIER, /*!< Current CPU:FSB ratio, multiplied by 100. - e.g., a CPU:FSB value of 18.5 reads as - "1850". */ - INFO_MAX_MULTIPLIER, /*!< Maximum CPU:FSB ratio for this CPU, - multiplied by 100. */ - INFO_TEMPERATURE, /*!< The current core temperature in Celsius. */ - INFO_THROTTLING, /*!< 1 if the current logical processor is - throttling. 0 if it is running normally. */ - INFO_VOLTAGE, /*!< The current core voltage in Volt, - multiplied by 100. */ - INFO_BCLK, /*!< See \ref INFO_BUS_CLOCK. */ - INFO_BUS_CLOCK, /*!< The main bus clock in MHz, - e.g., FSB/QPI/DMI/HT base clock, - multiplied by 100. */ -} cpu_msrinfo_request_t; - -/** - * @brief Similar to \ref cpu_rdmsr, but extract a range of bits - * - * @param handle - a handle to the MSR reader driver, as created by - * cpu_msr_driver_open - * @param msr_index - the numeric ID of the MSR you want to read - * @param highbit - the high bit in range, must be inferior to 64 - * @param lowbit - the low bit in range, must be equal or superior to 0 - * @param result - a pointer to a 64-bit integer, where the MSR value is stored - * - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -int cpu_rdmsr_range(struct msr_driver_t* handle, uint32_t msr_index, uint8_t highbit, - uint8_t lowbit, uint64_t* result); - -/** - * @brief Reads extended CPU information from Model-Specific Registers. - * @param handle - a handle to an open MSR driver, @see cpu_msr_driver_open - * @param which - which info field should be returned. A list of - * available information entities is listed in the - * cpu_msrinfo_request_t enum. - * @retval - if the requested information is available for the current - * processor model, the respective value is returned. - * if no information is available, or the CPU doesn't support - * the query, the special value CPU_INVALID_VALUE is returned - */ -int cpu_msrinfo(struct msr_driver_t* handle, cpu_msrinfo_request_t which); -#define CPU_INVALID_VALUE 0x3fffffff - -/** - * @brief Closes an open MSR driver - * - * This function unloads the MSR driver opened by cpu_msr_driver_open and - * frees any resources associated with it. - * - * @param handle - a handle to the MSR reader driver, as created by - * cpu_msr_driver_open - * - * @returns zero if successful, and some negative number on error. - * The error message can be obtained by calling \ref cpuid_error. - * @see cpu_error_t - */ -int cpu_msr_driver_close(struct msr_driver_t* handle); - -#ifdef __cplusplus -}; /* extern "C" */ -#endif - - -/** @} */ - -#endif /* __LIBCPUID_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/libcpuid_constants.h b/contrib/libcpuid/include/libcpuid/libcpuid_constants.h deleted file mode 100644 index 3ddb6d5e14e..00000000000 --- a/contrib/libcpuid/include/libcpuid/libcpuid_constants.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * @File libcpuid_constants.h - * @Author Veselin Georgiev - * @Brief Some limits and constants for libcpuid - */ - -#ifndef __LIBCPUID_CONSTANTS_H__ -#define __LIBCPUID_CONSTANTS_H__ - -#define VENDOR_STR_MAX 16 -#define BRAND_STR_MAX 64 -#define CPU_FLAGS_MAX 128 -#define MAX_CPUID_LEVEL 32 -#define MAX_EXT_CPUID_LEVEL 32 -#define MAX_INTELFN4_LEVEL 8 -#define MAX_INTELFN11_LEVEL 4 -#define MAX_INTELFN12H_LEVEL 4 -#define MAX_INTELFN14H_LEVEL 4 -#define CPU_HINTS_MAX 16 -#define SGX_FLAGS_MAX 14 - -#endif /* __LIBCPUID_CONSTANTS_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/libcpuid_internal.h b/contrib/libcpuid/include/libcpuid/libcpuid_internal.h deleted file mode 100644 index 95528896219..00000000000 --- a/contrib/libcpuid/include/libcpuid/libcpuid_internal.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2016 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __LIBCPUID_INTERNAL_H__ -#define __LIBCPUID_INTERNAL_H__ -/* - * This file contains internal undocumented declarations and function prototypes - * for the workings of the internal library infrastructure. - */ - -enum _common_codes_t { - NA = 0, - NO_CODE, -}; - -#define CODE(x) x -#define CODE2(x, y) x = y -enum _amd_code_t { - #include "amd_code_t.h" -}; -typedef enum _amd_code_t amd_code_t; - -enum _intel_code_t { - #include "intel_code_t.h" -}; -typedef enum _intel_code_t intel_code_t; -#undef CODE -#undef CODE2 - -struct internal_id_info_t { - union { - amd_code_t amd; - intel_code_t intel; - } code; - int score; // detection (matchtable) score -}; - -int cpu_ident_internal(struct cpu_raw_data_t* raw, struct cpu_id_t* data, - struct internal_id_info_t* internal); - -#endif /* __LIBCPUID_INTERNAL_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/libcpuid_types.h b/contrib/libcpuid/include/libcpuid/libcpuid_types.h deleted file mode 100644 index f1181edf2ee..00000000000 --- a/contrib/libcpuid/include/libcpuid/libcpuid_types.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * @File libcpuid_types.h - * @Author Veselin Georgiev - * @Brief Type specifications for libcpuid. - */ - -#ifndef __LIBCPUID_TYPES_H__ -#define __LIBCPUID_TYPES_H__ - -//#ifdef HAVE_CONFIG_H // CLICKHOUSE PATCH -# include "config.h" -//#endif // CLICKHOUSE PATCH - -#if 1 // CLICKHOUSE PATCH -//#if defined(HAVE_STDINT_H) // CLICKHOUSE PATCH -# include -#else -/* we have to provide our own: */ -# if !defined(HAVE_INT32_T) && !defined(__int32_t_defined) -typedef int int32_t; -# endif - -# if !defined(HAVE_UINT32_T) && !defined(__uint32_t_defined) -typedef unsigned uint32_t; -# endif - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -#if (defined _MSC_VER) && (_MSC_VER <= 1300) - /* MSVC 6.0: no long longs ... */ - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; -#else - /* all other sane compilers: */ - typedef signed long long int64_t; - typedef unsigned long long uint64_t; -#endif - -#endif - -#endif /* __LIBCPUID_TYPES_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/libcpuid_util.c b/contrib/libcpuid/include/libcpuid/libcpuid_util.c deleted file mode 100644 index ea6b1b8dfb4..00000000000 --- a/contrib/libcpuid/include/libcpuid/libcpuid_util.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include "libcpuid.h" -#include "libcpuid_util.h" - -int _current_verboselevel; - -void match_features(const struct feature_map_t* matchtable, int count, uint32_t reg, struct cpu_id_t* data) -{ - int i; - for (i = 0; i < count; i++) - if (reg & (1u << matchtable[i].bit)) - data->flags[matchtable[i].feature] = 1; -} - -static void default_warn(const char *msg) -{ - fprintf(stderr, "%s", msg); -} - -libcpuid_warn_fn_t _warn_fun = default_warn; - -#if defined(_MSC_VER) -# define vsnprintf _vsnprintf -#endif -void warnf(const char* format, ...) -{ - char buff[1024]; - va_list va; - if (!_warn_fun) return; - va_start(va, format); - vsnprintf(buff, sizeof(buff), format, va); - va_end(va); - _warn_fun(buff); -} - -void debugf(int verboselevel, const char* format, ...) -{ - char buff[1024]; - va_list va; - if (verboselevel > _current_verboselevel) return; - va_start(va, format); - vsnprintf(buff, sizeof(buff), format, va); - va_end(va); - _warn_fun(buff); -} - -static int score(const struct match_entry_t* entry, const struct cpu_id_t* data, - int brand_code, int model_code) -{ - int res = 0; - if (entry->family == data->family ) res += 2; - if (entry->model == data->model ) res += 2; - if (entry->stepping == data->stepping ) res += 2; - if (entry->ext_family == data->ext_family) res += 2; - if (entry->ext_model == data->ext_model ) res += 2; - if (entry->ncores == data->num_cores ) res += 2; - if (entry->l2cache == data->l2_cache ) res += 1; - if (entry->l3cache == data->l3_cache ) res += 1; - if (entry->brand_code == brand_code ) res += 2; - if (entry->model_code == model_code ) res += 2; - return res; -} - -int match_cpu_codename(const struct match_entry_t* matchtable, int count, - struct cpu_id_t* data, int brand_code, int model_code) -{ - int bestscore = -1; - int bestindex = 0; - int i, t; - - debugf(3, "Matching cpu f:%d, m:%d, s:%d, xf:%d, xm:%d, ncore:%d, l2:%d, bcode:%d, code:%d\n", - data->family, data->model, data->stepping, data->ext_family, - data->ext_model, data->num_cores, data->l2_cache, brand_code, model_code); - - for (i = 0; i < count; i++) { - t = score(&matchtable[i], data, brand_code, model_code); - debugf(3, "Entry %d, `%s', score %d\n", i, matchtable[i].name, t); - if (t > bestscore) { - debugf(2, "Entry `%s' selected - best score so far (%d)\n", matchtable[i].name, t); - bestscore = t; - bestindex = i; - } - } - strcpy(data->cpu_codename, matchtable[bestindex].name); - return bestscore; -} - -void generic_get_cpu_list(const struct match_entry_t* matchtable, int count, - struct cpu_list_t* list) -{ - int i, j, n, good; - n = 0; - list->names = (char**) malloc(sizeof(char*) * count); - for (i = 0; i < count; i++) { - if (strstr(matchtable[i].name, "Unknown")) continue; - good = 1; - for (j = n - 1; j >= 0; j--) - if (!strcmp(list->names[j], matchtable[i].name)) { - good = 0; - break; - } - if (!good) continue; -#if defined(_MSC_VER) - list->names[n++] = _strdup(matchtable[i].name); -#else - list->names[n++] = strdup(matchtable[i].name); -#endif - } - list->num_entries = n; -} - -static int xmatch_entry(char c, const char* p) -{ - int i, j; - if (c == 0) return -1; - if (c == p[0]) return 1; - if (p[0] == '.') return 1; - if (p[0] == '#' && isdigit(c)) return 1; - if (p[0] == '[') { - j = 1; - while (p[j] && p[j] != ']') j++; - if (!p[j]) return -1; - for (i = 1; i < j; i++) - if (p[i] == c) return j + 1; - } - return -1; -} - -int match_pattern(const char* s, const char* p) -{ - int i, j, dj, k, n, m; - n = (int) strlen(s); - m = (int) strlen(p); - for (i = 0; i < n; i++) { - if (xmatch_entry(s[i], p) != -1) { - j = 0; - k = 0; - while (j < m && ((dj = xmatch_entry(s[i + k], p + j)) != -1)) { - k++; - j += dj; - } - if (j == m) return i + 1; - } - } - return 0; -} - -struct cpu_id_t* get_cached_cpuid(void) -{ - static int initialized = 0; - static struct cpu_id_t id; - if (initialized) return &id; - if (cpu_identify(NULL, &id)) - memset(&id, 0, sizeof(id)); - initialized = 1; - return &id; -} diff --git a/contrib/libcpuid/include/libcpuid/libcpuid_util.h b/contrib/libcpuid/include/libcpuid/libcpuid_util.h deleted file mode 100644 index 22becea26f6..00000000000 --- a/contrib/libcpuid/include/libcpuid/libcpuid_util.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __LIBCPUID_UTIL_H__ -#define __LIBCPUID_UTIL_H__ - -#define COUNT_OF(array) (sizeof(array) / sizeof(array[0])) - -struct feature_map_t { - unsigned bit; - cpu_feature_t feature; -}; - -void match_features(const struct feature_map_t* matchtable, int count, - uint32_t reg, struct cpu_id_t* data); - -struct match_entry_t { - int family, model, stepping, ext_family, ext_model; - int ncores, l2cache, l3cache, brand_code, model_code; - char name[32]; -}; - -// returns the match score: -int match_cpu_codename(const struct match_entry_t* matchtable, int count, - struct cpu_id_t* data, int brand_code, int model_code); - -void warnf(const char* format, ...) -#ifdef __GNUC__ -__attribute__((format(printf, 1, 2))) -#endif -; -void debugf(int verboselevel, const char* format, ...) -#ifdef __GNUC__ -__attribute__((format(printf, 2, 3))) -#endif -; -void generic_get_cpu_list(const struct match_entry_t* matchtable, int count, - struct cpu_list_t* list); - -/* - * Seek for a pattern in `haystack'. - * Pattern may be an fixed string, or contain the special metacharacters - * '.' - match any single character - * '#' - match any digit - * '[] - match any of the given chars (regex-like ranges are not - * supported) - * Return val: 0 if the pattern is not found. Nonzero if it is found (actually, - * x + 1 where x is the index where the match is found). - */ -int match_pattern(const char* haystack, const char* pattern); - -/* - * Gets an initialized cpu_id_t. It is cached, so that internal libcpuid - * machinery doesn't need to issue cpu_identify more than once. - */ -struct cpu_id_t* get_cached_cpuid(void); - -/* - * Sets the current errno - */ -int set_error(cpu_error_t err); - -extern libcpuid_warn_fn_t _warn_fun; -extern int _current_verboselevel; - -#endif /* __LIBCPUID_UTIL_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/msrdriver.c b/contrib/libcpuid/include/libcpuid/msrdriver.c deleted file mode 100644 index 8f9d7ed0ca8..00000000000 --- a/contrib/libcpuid/include/libcpuid/msrdriver.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Copyright 2009 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @File msrdriver.c - * @Brief Contains the binary images of the x86 and x64 MSR drivers for Windows - * @Date 2009-09-29 - * - * The driver is courtesy of Nick 'Bombera' Gabareff, and its source is actually - * available, see the contrib/ dir. - * - * However, for simplicity, here we just include the images of the compiled .SYS - * files. - * They are extracted to the filesystem on demand and loaded in the kernel - * by the cpu_msr_driver_open() function - */ -#ifdef _WIN32 -#include "asm-bits.h" -//begin { -int cc_x86driver_code_size = 4608; -uint8_t cc_x86driver_code[4608] = { - 0x4d,0x5a,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xb8,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x0e,0x1f,0xba,0x0e,0x00,0xb4,0x09,0xcd, - 0x21,0xb8,0x01,0x4c,0xcd,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6f,0x67,0x72,0x61,0x6d, - 0x20,0x63,0x61,0x6e,0x6e,0x6f,0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6e,0x20,0x69,0x6e,0x20, - 0x44,0x4f,0x53,0x20,0x6d,0x6f,0x64,0x65,0x2e,0x0d,0x0d,0x0a,0x24,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x9f,0x99,0x48,0xdf,0xdb,0xf8,0x26,0x8c,0xdb,0xf8,0x26,0x8c,0xdb,0xf8,0x26,0x8c, - 0xdb,0xf8,0x27,0x8c,0xdd,0xf8,0x26,0x8c,0x21,0xdb,0x3f,0x8c,0xd8,0xf8,0x26,0x8c,0xfc,0x3e, - 0x57,0x8c,0xda,0xf8,0x26,0x8c,0xfc,0x3e,0x5a,0x8c,0xda,0xf8,0x26,0x8c,0xfc,0x3e,0x5e,0x8c, - 0xda,0xf8,0x26,0x8c,0x52,0x69,0x63,0x68,0xdb,0xf8,0x26,0x8c,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x50,0x45,0x00,0x00,0x4c,0x01,0x07,0x00,0x12,0x9b,0x9b,0x4a,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0xe0,0x00,0x02,0x21,0x0b,0x01,0x08,0x00,0x00,0x06,0x00,0x00,0x00,0x0a, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00, - 0x00,0x00,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x04,0x00,0x00, - 0xa9,0xd1,0x00,0x00,0x01,0x00,0x00,0x04,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00, - 0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0xc0,0x03, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x20,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2e,0x74, - 0x65,0x78,0x74,0x00,0x00,0x00,0xa3,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00, - 0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00, - 0x00,0x68,0x2e,0x72,0x64,0x61,0x74,0x61,0x00,0x00,0x62,0x00,0x00,0x00,0x00,0x20,0x00,0x00, - 0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x40,0x00,0x00,0x48,0x2e,0x64,0x61,0x74,0x61,0x00,0x00,0x00,0x04,0x00,0x00,0x00, - 0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xc8,0x50,0x41,0x47,0x45,0x30,0x44,0x45,0x46, - 0x8c,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,0x49,0x4e,0x49,0x54, - 0x00,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0a, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0xe2, - 0x2e,0x72,0x73,0x72,0x63,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x04, - 0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x40,0x00,0x00,0x42,0x2e,0x72,0x65,0x6c,0x6f,0x63,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x70, - 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8b,0x4c, - 0x24,0x08,0x83,0x61,0x18,0x00,0x83,0x61,0x1c,0x00,0x32,0xd2,0xff,0x15,0x08,0x20,0x01,0x00, - 0x33,0xc0,0xc2,0x08,0x00,0x56,0x8b,0x74,0x24,0x0c,0x8b,0x46,0x60,0x81,0x78,0x0c,0x0c,0xe0, - 0x22,0x00,0x57,0x75,0x3c,0x83,0x78,0x04,0x08,0x72,0x36,0x83,0x78,0x08,0x04,0x75,0x07,0x8b, - 0x46,0x0c,0x8b,0x08,0xeb,0x05,0xb9,0x9c,0x01,0x00,0x00,0x8b,0x7e,0x0c,0x0f,0x32,0x89,0x07, - 0x89,0x57,0x04,0xc7,0x46,0x1c,0x08,0x00,0x00,0x00,0x33,0xff,0x32,0xd2,0x8b,0xce,0xff,0x15, - 0x08,0x20,0x01,0x00,0x8b,0xc7,0x5f,0x5e,0xc2,0x08,0x00,0x83,0x66,0x1c,0x00,0xbf,0x01,0x00, - 0x00,0xc0,0x89,0x7e,0x18,0xeb,0xe1,0x55,0x8b,0xec,0x51,0x51,0x8b,0x45,0x08,0xff,0x70,0x04, - 0xff,0x15,0x04,0x20,0x01,0x00,0x68,0x3c,0x20,0x01,0x00,0x8d,0x45,0xf8,0x50,0xff,0x15,0x00, - 0x20,0x01,0x00,0x8d,0x45,0xf8,0x50,0xff,0x15,0x14,0x20,0x01,0x00,0xc9,0xc2,0x04,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x50,0x00,0x00,0x74,0x50,0x00,0x00,0x86,0x50,0x00,0x00, - 0x9c,0x50,0x00,0x00,0xb4,0x50,0x00,0x00,0x44,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x00, - 0x44,0x00,0x65,0x00,0x76,0x00,0x69,0x00,0x63,0x00,0x65,0x00,0x5c,0x00,0x54,0x00,0x6d,0x00, - 0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00,0x00,0x00,0x00,0x00,0x5c,0x00,0x44,0x00,0x6f,0x00, - 0x73,0x00,0x44,0x00,0x65,0x00,0x76,0x00,0x69,0x00,0x63,0x00,0x65,0x00,0x73,0x00,0x5c,0x00, - 0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x8b,0xec,0x83, - 0xec,0x14,0x56,0x8b,0x35,0x00,0x20,0x01,0x00,0x57,0x68,0x1c,0x20,0x01,0x00,0x8d,0x45,0xf4, - 0x50,0xff,0xd6,0x8b,0x7d,0x08,0x8d,0x45,0xfc,0x50,0x6a,0x00,0x6a,0x00,0x6a,0x22,0x8d,0x45, - 0xf4,0x50,0x6a,0x04,0x57,0xff,0x15,0x10,0x20,0x01,0x00,0x85,0xc0,0x75,0x4f,0x68,0x3c,0x20, - 0x01,0x00,0x8d,0x45,0xec,0x50,0xff,0xd6,0x8d,0x45,0xf4,0x50,0x8d,0x45,0xec,0x50,0xff,0x15, - 0x0c,0x20,0x01,0x00,0x8b,0xf0,0x85,0xf6,0x74,0x0d,0xff,0x75,0xfc,0xff,0x15,0x04,0x20,0x01, - 0x00,0x8b,0xc6,0xeb,0x23,0x8b,0x45,0xfc,0xa3,0x00,0x30,0x01,0x00,0xb8,0x00,0x10,0x01,0x00, - 0x89,0x47,0x38,0x89,0x47,0x40,0xc7,0x47,0x34,0x75,0x10,0x01,0x00,0xc7,0x47,0x70,0x19,0x10, - 0x01,0x00,0x33,0xc0,0x5f,0x5e,0xc9,0xc2,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc6,0x50, - 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x50,0x00,0x00,0x74,0x50,0x00,0x00,0x86,0x50, - 0x00,0x00,0x9c,0x50,0x00,0x00,0xb4,0x50,0x00,0x00,0x44,0x50,0x00,0x00,0x00,0x00,0x00,0x00, - 0x4b,0x01,0x49,0x6f,0x44,0x65,0x6c,0x65,0x74,0x65,0x53,0x79,0x6d,0x62,0x6f,0x6c,0x69,0x63, - 0x4c,0x69,0x6e,0x6b,0x00,0x00,0x0b,0x04,0x52,0x74,0x6c,0x49,0x6e,0x69,0x74,0x55,0x6e,0x69, - 0x63,0x6f,0x64,0x65,0x53,0x74,0x72,0x69,0x6e,0x67,0x00,0x00,0x49,0x01,0x49,0x6f,0x44,0x65, - 0x6c,0x65,0x74,0x65,0x44,0x65,0x76,0x69,0x63,0x65,0x00,0x00,0xda,0x01,0x49,0x6f,0x66,0x43, - 0x6f,0x6d,0x70,0x6c,0x65,0x74,0x65,0x52,0x65,0x71,0x75,0x65,0x73,0x74,0x00,0x00,0x41,0x01, - 0x49,0x6f,0x43,0x72,0x65,0x61,0x74,0x65,0x53,0x79,0x6d,0x62,0x6f,0x6c,0x69,0x63,0x4c,0x69, - 0x6e,0x6b,0x00,0x00,0x38,0x01,0x49,0x6f,0x43,0x72,0x65,0x61,0x74,0x65,0x44,0x65,0x76,0x69, - 0x63,0x65,0x00,0x00,0x6e,0x74,0x6f,0x73,0x6b,0x72,0x6e,0x6c,0x2e,0x65,0x78,0x65,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x10,0x00,0x00,0x00,0x18,0x00,0x00,0x80, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00, - 0x00,0x00,0x30,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x01,0x00,0x09,0x04,0x00,0x00,0x48,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x5c,0x03, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x5c,0x03,0x34,0x00,0x00,0x00,0x56,0x00,0x53,0x00,0x5f,0x00,0x56,0x00,0x45,0x00,0x52,0x00, - 0x53,0x00,0x49,0x00,0x4f,0x00,0x4e,0x00,0x5f,0x00,0x49,0x00,0x4e,0x00,0x46,0x00,0x4f,0x00, - 0x00,0x00,0x00,0x00,0xbd,0x04,0xef,0xfe,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00, - 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x04,0x00,0x04,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0xba,0x02,0x00,0x00,0x01,0x00,0x53,0x00,0x74,0x00,0x72,0x00,0x69,0x00,0x6e,0x00, - 0x67,0x00,0x46,0x00,0x69,0x00,0x6c,0x00,0x65,0x00,0x49,0x00,0x6e,0x00,0x66,0x00,0x6f,0x00, - 0x00,0x00,0x96,0x02,0x00,0x00,0x01,0x00,0x30,0x00,0x34,0x00,0x30,0x00,0x39,0x00,0x30,0x00, - 0x34,0x00,0x62,0x00,0x30,0x00,0x00,0x00,0x58,0x00,0x20,0x00,0x01,0x00,0x43,0x00,0x6f,0x00, - 0x6d,0x00,0x6d,0x00,0x65,0x00,0x6e,0x00,0x74,0x00,0x73,0x00,0x00,0x00,0x4d,0x00,0x53,0x00, - 0x52,0x00,0x20,0x00,0x72,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x65,0x00,0x72,0x00,0x20,0x00, - 0x33,0x00,0x32,0x00,0x2d,0x00,0x62,0x00,0x69,0x00,0x74,0x00,0x20,0x00,0x6b,0x00,0x65,0x00, - 0x72,0x00,0x6e,0x00,0x65,0x00,0x6c,0x00,0x20,0x00,0x64,0x00,0x72,0x00,0x69,0x00,0x76,0x00, - 0x65,0x00,0x72,0x00,0x00,0x00,0x42,0x00,0x11,0x00,0x01,0x00,0x43,0x00,0x6f,0x00,0x6d,0x00, - 0x70,0x00,0x61,0x00,0x6e,0x00,0x79,0x00,0x4e,0x00,0x61,0x00,0x6d,0x00,0x65,0x00,0x00,0x00, - 0x00,0x00,0x49,0x00,0x72,0x00,0x6f,0x00,0x6e,0x00,0x20,0x00,0x53,0x00,0x74,0x00,0x65,0x00, - 0x65,0x00,0x64,0x00,0x73,0x00,0x20,0x00,0x49,0x00,0x6e,0x00,0x63,0x00,0x2e,0x00,0x00,0x00, - 0x00,0x00,0x60,0x00,0x1c,0x00,0x01,0x00,0x46,0x00,0x69,0x00,0x6c,0x00,0x65,0x00,0x44,0x00, - 0x65,0x00,0x73,0x00,0x63,0x00,0x72,0x00,0x69,0x00,0x70,0x00,0x74,0x00,0x69,0x00,0x6f,0x00, - 0x6e,0x00,0x00,0x00,0x00,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00, - 0x20,0x00,0x33,0x00,0x32,0x00,0x2d,0x00,0x62,0x00,0x69,0x00,0x74,0x00,0x20,0x00,0x4b,0x00, - 0x65,0x00,0x72,0x00,0x6e,0x00,0x65,0x00,0x6c,0x00,0x20,0x00,0x4d,0x00,0x6f,0x00,0x64,0x00, - 0x75,0x00,0x6c,0x00,0x65,0x00,0x00,0x00,0x36,0x00,0x0b,0x00,0x01,0x00,0x46,0x00,0x69,0x00, - 0x6c,0x00,0x65,0x00,0x56,0x00,0x65,0x00,0x72,0x00,0x73,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00, - 0x00,0x00,0x00,0x00,0x31,0x00,0x2c,0x00,0x20,0x00,0x30,0x00,0x2c,0x00,0x20,0x00,0x30,0x00, - 0x2c,0x00,0x20,0x00,0x31,0x00,0x00,0x00,0x00,0x00,0x2e,0x00,0x07,0x00,0x01,0x00,0x49,0x00, - 0x6e,0x00,0x74,0x00,0x65,0x00,0x72,0x00,0x6e,0x00,0x61,0x00,0x6c,0x00,0x4e,0x00,0x61,0x00, - 0x6d,0x00,0x65,0x00,0x00,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00, - 0x00,0x00,0x00,0x00,0x4a,0x00,0x13,0x00,0x01,0x00,0x4c,0x00,0x65,0x00,0x67,0x00,0x61,0x00, - 0x6c,0x00,0x43,0x00,0x6f,0x00,0x70,0x00,0x79,0x00,0x72,0x00,0x69,0x00,0x67,0x00,0x68,0x00, - 0x74,0x00,0x00,0x00,0x4e,0x00,0x69,0x00,0x63,0x00,0x6b,0x00,0x20,0x00,0x47,0x00,0x61,0x00, - 0x62,0x00,0x61,0x00,0x72,0x00,0x65,0x00,0x76,0x00,0x20,0x00,0x27,0x00,0x32,0x00,0x30,0x00, - 0x30,0x00,0x39,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x0b,0x00,0x01,0x00,0x4f,0x00,0x72,0x00, - 0x69,0x00,0x67,0x00,0x69,0x00,0x6e,0x00,0x61,0x00,0x6c,0x00,0x46,0x00,0x69,0x00,0x6c,0x00, - 0x65,0x00,0x6e,0x00,0x61,0x00,0x6d,0x00,0x65,0x00,0x00,0x00,0x54,0x00,0x6d,0x00,0x70,0x00, - 0x52,0x00,0x64,0x00,0x72,0x00,0x2e,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x00,0x00,0x00,0x00, - 0x54,0x00,0x1a,0x00,0x01,0x00,0x50,0x00,0x72,0x00,0x6f,0x00,0x64,0x00,0x75,0x00,0x63,0x00, - 0x74,0x00,0x4e,0x00,0x61,0x00,0x6d,0x00,0x65,0x00,0x00,0x00,0x00,0x00,0x43,0x00,0x6f,0x00, - 0x72,0x00,0x65,0x00,0x20,0x00,0x32,0x00,0x20,0x00,0x54,0x00,0x65,0x00,0x6d,0x00,0x70,0x00, - 0x65,0x00,0x72,0x00,0x61,0x00,0x74,0x00,0x75,0x00,0x72,0x00,0x65,0x00,0x20,0x00,0x52,0x00, - 0x65,0x00,0x61,0x00,0x64,0x00,0x65,0x00,0x72,0x00,0x00,0x00,0x3a,0x00,0x0b,0x00,0x01,0x00, - 0x50,0x00,0x72,0x00,0x6f,0x00,0x64,0x00,0x75,0x00,0x63,0x00,0x74,0x00,0x56,0x00,0x65,0x00, - 0x72,0x00,0x73,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x00,0x00,0x31,0x00,0x2c,0x00,0x20,0x00, - 0x30,0x00,0x2c,0x00,0x20,0x00,0x30,0x00,0x2c,0x00,0x20,0x00,0x31,0x00,0x00,0x00,0x00,0x00, - 0x44,0x00,0x00,0x00,0x01,0x00,0x56,0x00,0x61,0x00,0x72,0x00,0x46,0x00,0x69,0x00,0x6c,0x00, - 0x65,0x00,0x49,0x00,0x6e,0x00,0x66,0x00,0x6f,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x04,0x00, - 0x00,0x00,0x54,0x00,0x72,0x00,0x61,0x00,0x6e,0x00,0x73,0x00,0x6c,0x00,0x61,0x00,0x74,0x00, - 0x69,0x00,0x6f,0x00,0x6e,0x00,0x00,0x00,0x00,0x00,0x09,0x04,0xb0,0x04,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x14,0x00,0x00,0x00, - 0x10,0x30,0x5c,0x30,0x82,0x30,0x87,0x30,0x91,0x30,0x9b,0x30,0x00,0x40,0x00,0x00,0x1c,0x00, - 0x00,0x00,0x09,0x30,0x0f,0x30,0x2f,0x30,0x38,0x30,0x4c,0x30,0x5b,0x30,0x67,0x30,0x6c,0x30, - 0x79,0x30,0x80,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -}; -int cc_x64driver_code_size = 5120; -uint8_t cc_x64driver_code[5120] = { - 0x4d,0x5a,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xb8,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x00,0x00,0x00,0x0e,0x1f,0xba,0x0e,0x00,0xb4,0x09,0xcd, - 0x21,0xb8,0x01,0x4c,0xcd,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6f,0x67,0x72,0x61,0x6d, - 0x20,0x63,0x61,0x6e,0x6e,0x6f,0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6e,0x20,0x69,0x6e,0x20, - 0x44,0x4f,0x53,0x20,0x6d,0x6f,0x64,0x65,0x2e,0x0d,0x0d,0x0a,0x24,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0xb7,0x04,0xa8,0xc2,0xf3,0x65,0xc6,0x91,0xf3,0x65,0xc6,0x91,0xf3,0x65,0xc6,0x91, - 0xf3,0x65,0xc7,0x91,0xf4,0x65,0xc6,0x91,0x85,0xf8,0xbd,0x91,0xf0,0x65,0xc6,0x91,0x85,0xf8, - 0xab,0x91,0xf0,0x65,0xc6,0x91,0x30,0x6a,0x98,0x91,0xf2,0x65,0xc6,0x91,0x85,0xf8,0xbe,0x91, - 0xf2,0x65,0xc6,0x91,0x52,0x69,0x63,0x68,0xf3,0x65,0xc6,0x91,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x64,0x86,0x07,0x00, - 0x41,0xc8,0x6d,0x49,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x22,0x00,0x0b,0x02, - 0x08,0x00,0x00,0x06,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x00, - 0x00,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02, - 0x00,0x00,0x05,0x00,0x02,0x00,0x05,0x00,0x02,0x00,0x05,0x00,0x02,0x00,0x00,0x00,0x00,0x00, - 0x00,0x80,0x00,0x00,0x00,0x04,0x00,0x00,0x79,0x44,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00, - 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x60,0x00,0x00,0x28,0x00,0x00,0x00, - 0x00,0x70,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x40,0x00,0x00,0x48,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x00,0x00, - 0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x2e,0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x26,0x01,0x00,0x00,0x00,0x10, - 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x68,0x2e,0x72,0x64,0x61,0x74,0x61,0x00,0x00,0xf0,0x00, - 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x48,0x2e,0x64,0x61,0x74,0x61,0x00, - 0x00,0x00,0x18,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xc8,0x2e,0x70, - 0x64,0x61,0x74,0x61,0x00,0x00,0x48,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00, - 0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, - 0x00,0x48,0x50,0x41,0x47,0x45,0x30,0x44,0x45,0x46,0x4e,0x01,0x00,0x00,0x00,0x50,0x00,0x00, - 0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x20,0x00,0x00,0x60,0x49,0x4e,0x49,0x54,0x00,0x00,0x00,0x00,0x60,0x01,0x00,0x00, - 0x00,0x60,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0xe2,0x2e,0x72,0x73,0x72,0x63,0x00,0x00,0x00, - 0xc0,0x03,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x42,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x83,0xec,0x28, - 0x33,0xc9,0x48,0x8b,0xc2,0x89,0x4a,0x30,0x48,0x89,0x4a,0x38,0x33,0xd2,0x48,0x8b,0xc8,0xff, - 0x15,0xfd,0x0f,0x00,0x00,0x33,0xc0,0x48,0x83,0xc4,0x28,0xc3,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc, - 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x48,0x83,0xec,0x28,0x48,0x8b,0x82,0xb8,0x00,0x00, - 0x00,0x4c,0x8b,0xca,0x81,0x78,0x18,0x0c,0xe0,0x22,0x00,0x75,0x43,0x83,0x78,0x08,0x08,0x72, - 0x3d,0x83,0x78,0x10,0x04,0x75,0x08,0x48,0x8b,0x42,0x18,0x8b,0x08,0xeb,0x05,0xb9,0x9c,0x01, - 0x00,0x00,0x4c,0x8b,0x42,0x18,0x0f,0x32,0x48,0xc1,0xe2,0x20,0x49,0x8b,0xc9,0x48,0x0b,0xc2, - 0x33,0xd2,0x49,0x89,0x00,0x49,0xc7,0x41,0x38,0x08,0x00,0x00,0x00,0xff,0x15,0x95,0x0f,0x00, - 0x00,0x33,0xc0,0x48,0x83,0xc4,0x28,0xc3,0xc7,0x42,0x30,0x01,0x00,0x00,0xc0,0x48,0xc7,0x42, - 0x38,0x00,0x00,0x00,0x00,0x49,0x8b,0xc9,0x33,0xd2,0xff,0x15,0x74,0x0f,0x00,0x00,0xb8,0x01, - 0x00,0x00,0xc0,0x48,0x83,0xc4,0x28,0xc3,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc, - 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x48,0x83,0xec,0x38,0x48,0x8b,0x49,0x08,0xff,0x15, - 0x32,0x0f,0x00,0x00,0x48,0x8d,0x15,0x1b,0x00,0x00,0x00,0x48,0x8d,0x4c,0x24,0x20,0xff,0x15, - 0x18,0x0f,0x00,0x00,0x48,0x8d,0x4c,0x24,0x20,0xff,0x15,0x05,0x0f,0x00,0x00,0x48,0x83,0xc4, - 0x38,0xc3,0x5c,0x00,0x44,0x00,0x6f,0x00,0x73,0x00,0x44,0x00,0x65,0x00,0x76,0x00,0x69,0x00, - 0x63,0x00,0x65,0x00,0x73,0x00,0x5c,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00, - 0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x60,0x00,0x00, - 0x00,0x00,0x00,0x00,0x16,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x61,0x00,0x00,0x00,0x00, - 0x00,0x00,0x40,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x60,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x41,0xc8,0x6d,0x49,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x49,0x00,0x00,0x00, - 0x5c,0x20,0x00,0x00,0x5c,0x06,0x00,0x00,0x52,0x53,0x44,0x53,0xd9,0x5e,0xab,0x47,0xc4,0xf2, - 0x4f,0x40,0xaa,0xe9,0x90,0x47,0x67,0x30,0xa5,0xfa,0x03,0x00,0x00,0x00,0x44,0x3a,0x5c,0x74, - 0x6d,0x70,0x5c,0x4b,0x65,0x72,0x6e,0x65,0x6c,0x5c,0x6f,0x62,0x6a,0x66,0x72,0x65,0x5f,0x77, - 0x6e,0x65,0x74,0x5f,0x41,0x4d,0x44,0x36,0x34,0x5c,0x61,0x6d,0x64,0x36,0x34,0x5c,0x54,0x6d, - 0x70,0x52,0x64,0x72,0x2e,0x70,0x64,0x62,0x00,0x00,0x00,0x00,0x01,0x04,0x01,0x00,0x04,0x42, - 0x00,0x00,0x01,0x04,0x01,0x00,0x04,0x42,0x00,0x00,0x01,0x04,0x01,0x00,0x04,0x62,0x00,0x00, - 0x21,0x00,0x00,0x00,0x10,0x50,0x00,0x00,0x74,0x50,0x00,0x00,0xe4,0x20,0x00,0x00,0x21,0x08, - 0x02,0x00,0x08,0x74,0x13,0x00,0x10,0x50,0x00,0x00,0x74,0x50,0x00,0x00,0xe4,0x20,0x00,0x00, - 0x01,0x0c,0x03,0x00,0x0c,0x34,0x12,0x00,0x04,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xcd,0x5d,0x20,0xd2,0x66,0xd4,0xff,0xff,0x32,0xa2,0xdf,0x2d,0x99,0x2b,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x32,0x10,0x00,0x00,0xa8,0x20,0x00,0x00,0x40,0x10, - 0x00,0x00,0xbe,0x10,0x00,0x00,0xb0,0x20,0x00,0x00,0xd0,0x10,0x00,0x00,0x00,0x11,0x00,0x00, - 0xb8,0x20,0x00,0x00,0x10,0x50,0x00,0x00,0x74,0x50,0x00,0x00,0xe4,0x20,0x00,0x00,0x74,0x50, - 0x00,0x00,0xe8,0x50,0x00,0x00,0xd0,0x20,0x00,0x00,0xe8,0x50,0x00,0x00,0xf5,0x50,0x00,0x00, - 0xc0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x83,0xec,0x78,0x48,0x89,0x9c,0x24, - 0x90,0x00,0x00,0x00,0x48,0x8b,0xd9,0x48,0x8d,0x15,0x0a,0x01,0x00,0x00,0x48,0x8d,0x4c,0x24, - 0x48,0xff,0x15,0xd7,0xcf,0xff,0xff,0x41,0xb9,0x22,0x00,0x00,0x00,0x4c,0x8d,0x5c,0x24,0x40, - 0x4c,0x89,0x5c,0x24,0x30,0x4c,0x8d,0x44,0x24,0x48,0x41,0x8d,0x51,0xe6,0x48,0x8b,0xcb,0xc6, - 0x44,0x24,0x28,0x00,0xc7,0x44,0x24,0x20,0x00,0x00,0x00,0x00,0xff,0x15,0xc0,0xcf,0xff,0xff, - 0x85,0xc0,0x0f,0x85,0x80,0x00,0x00,0x00,0x48,0x8d,0x15,0x91,0x00,0x00,0x00,0x48,0x8d,0x4c, - 0x24,0x58,0x48,0x89,0xbc,0x24,0x98,0x00,0x00,0x00,0xff,0x15,0x86,0xcf,0xff,0xff,0x48,0x8d, - 0x54,0x24,0x48,0x48,0x8d,0x4c,0x24,0x58,0xff,0x15,0x86,0xcf,0xff,0xff,0x85,0xc0,0x8b,0xf8, - 0x74,0x0f,0x48,0x8b,0x4c,0x24,0x40,0xff,0x15,0x6d,0xcf,0xff,0xff,0x8b,0xc7,0xeb,0x39,0x48, - 0x8b,0x44,0x24,0x40,0x48,0x89,0x05,0x5d,0xe0,0xff,0xff,0x48,0x8d,0x05,0x16,0xc0,0xff,0xff, - 0x48,0x89,0x43,0x68,0x48,0x8d,0x05,0x4b,0xbf,0xff,0xff,0x48,0x89,0x43,0x70,0x48,0x89,0x83, - 0x80,0x00,0x00,0x00,0x48,0x8d,0x05,0x69,0xbf,0xff,0xff,0x48,0x89,0x83,0xe0,0x00,0x00,0x00, - 0x33,0xc0,0x48,0x8b,0xbc,0x24,0x98,0x00,0x00,0x00,0x48,0x8b,0x9c,0x24,0x90,0x00,0x00,0x00, - 0x48,0x83,0xc4,0x78,0xc3,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x5c,0x00, - 0x44,0x00,0x6f,0x00,0x73,0x00,0x44,0x00,0x65,0x00,0x76,0x00,0x69,0x00,0x63,0x00,0x65,0x00, - 0x73,0x00,0x5c,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00,0x00,0x00, - 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x5c,0x00,0x44,0x00,0x65,0x00,0x76,0x00, - 0x69,0x00,0x63,0x00,0x65,0x00,0x5c,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00, - 0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x48,0x8b,0x05,0xf1,0xd0,0xff,0xff,0x49,0xb9,0x32,0xa2,0xdf,0x2d,0x99,0x2b,0x00,0x00,0x48, - 0x85,0xc0,0x74,0x05,0x49,0x3b,0xc1,0x75,0x2f,0x4c,0x8d,0x05,0xd6,0xd0,0xff,0xff,0x48,0xb8, - 0x20,0x03,0x00,0x00,0x80,0xf7,0xff,0xff,0x48,0x8b,0x00,0x49,0x33,0xc0,0x49,0xb8,0xff,0xff, - 0xff,0xff,0xff,0xff,0x00,0x00,0x49,0x23,0xc0,0x49,0x0f,0x44,0xc1,0x48,0x89,0x05,0xae,0xd0, - 0xff,0xff,0x48,0xf7,0xd0,0x48,0x89,0x05,0x9c,0xd0,0xff,0xff,0xe9,0xa7,0xef,0xff,0xff,0xcc, - 0xcc,0xcc,0x98,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x61,0x00,0x00, - 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0x60,0x00,0x00,0x00,0x00,0x00,0x00, - 0xfe,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x61, - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x60,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0x01,0x49,0x6f,0x66,0x43, - 0x6f,0x6d,0x70,0x6c,0x65,0x74,0x65,0x52,0x65,0x71,0x75,0x65,0x73,0x74,0x00,0x00,0x61,0x01, - 0x49,0x6f,0x44,0x65,0x6c,0x65,0x74,0x65,0x53,0x79,0x6d,0x62,0x6f,0x6c,0x69,0x63,0x4c,0x69, - 0x6e,0x6b,0x00,0x00,0x3e,0x04,0x52,0x74,0x6c,0x49,0x6e,0x69,0x74,0x55,0x6e,0x69,0x63,0x6f, - 0x64,0x65,0x53,0x74,0x72,0x69,0x6e,0x67,0x00,0x00,0x5f,0x01,0x49,0x6f,0x44,0x65,0x6c,0x65, - 0x74,0x65,0x44,0x65,0x76,0x69,0x63,0x65,0x00,0x00,0x55,0x01,0x49,0x6f,0x43,0x72,0x65,0x61, - 0x74,0x65,0x53,0x79,0x6d,0x62,0x6f,0x6c,0x69,0x63,0x4c,0x69,0x6e,0x6b,0x00,0x00,0x4c,0x01, - 0x49,0x6f,0x43,0x72,0x65,0x61,0x74,0x65,0x44,0x65,0x76,0x69,0x63,0x65,0x00,0x00,0x6e,0x74, - 0x6f,0x73,0x6b,0x72,0x6e,0x6c,0x2e,0x65,0x78,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x10,0x00,0x00,0x00,0x18,0x00,0x00,0x80,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00, - 0x30,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x00,0x09,0x04,0x00,0x00,0x48,0x00,0x00,0x00,0x60,0x70,0x00,0x00,0x60,0x03,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x03, - 0x34,0x00,0x00,0x00,0x56,0x00,0x53,0x00,0x5f,0x00,0x56,0x00,0x45,0x00,0x52,0x00,0x53,0x00, - 0x49,0x00,0x4f,0x00,0x4e,0x00,0x5f,0x00,0x49,0x00,0x4e,0x00,0x46,0x00,0x4f,0x00,0x00,0x00, - 0x00,0x00,0xbd,0x04,0xef,0xfe,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00, - 0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, - 0x04,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xbe,0x02,0x00,0x00,0x01,0x00,0x53,0x00,0x74,0x00,0x72,0x00,0x69,0x00,0x6e,0x00,0x67,0x00, - 0x46,0x00,0x69,0x00,0x6c,0x00,0x65,0x00,0x49,0x00,0x6e,0x00,0x66,0x00,0x6f,0x00,0x00,0x00, - 0x9a,0x02,0x00,0x00,0x01,0x00,0x30,0x00,0x34,0x00,0x30,0x00,0x39,0x00,0x30,0x00,0x34,0x00, - 0x62,0x00,0x30,0x00,0x00,0x00,0x58,0x00,0x20,0x00,0x01,0x00,0x43,0x00,0x6f,0x00,0x6d,0x00, - 0x6d,0x00,0x65,0x00,0x6e,0x00,0x74,0x00,0x73,0x00,0x00,0x00,0x4d,0x00,0x53,0x00,0x52,0x00, - 0x20,0x00,0x72,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x65,0x00,0x72,0x00,0x20,0x00,0x36,0x00, - 0x34,0x00,0x2d,0x00,0x62,0x00,0x69,0x00,0x74,0x00,0x20,0x00,0x6b,0x00,0x65,0x00,0x72,0x00, - 0x6e,0x00,0x65,0x00,0x6c,0x00,0x20,0x00,0x64,0x00,0x72,0x00,0x69,0x00,0x76,0x00,0x65,0x00, - 0x72,0x00,0x00,0x00,0x42,0x00,0x11,0x00,0x01,0x00,0x43,0x00,0x6f,0x00,0x6d,0x00,0x70,0x00, - 0x61,0x00,0x6e,0x00,0x79,0x00,0x4e,0x00,0x61,0x00,0x6d,0x00,0x65,0x00,0x00,0x00,0x00,0x00, - 0x49,0x00,0x72,0x00,0x6f,0x00,0x6e,0x00,0x20,0x00,0x53,0x00,0x74,0x00,0x65,0x00,0x65,0x00, - 0x64,0x00,0x73,0x00,0x20,0x00,0x49,0x00,0x6e,0x00,0x63,0x00,0x2e,0x00,0x00,0x00,0x00,0x00, - 0x60,0x00,0x1c,0x00,0x01,0x00,0x46,0x00,0x69,0x00,0x6c,0x00,0x65,0x00,0x44,0x00,0x65,0x00, - 0x73,0x00,0x63,0x00,0x72,0x00,0x69,0x00,0x70,0x00,0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00, - 0x00,0x00,0x00,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00,0x20,0x00, - 0x36,0x00,0x34,0x00,0x2d,0x00,0x62,0x00,0x69,0x00,0x74,0x00,0x20,0x00,0x4b,0x00,0x65,0x00, - 0x72,0x00,0x6e,0x00,0x65,0x00,0x6c,0x00,0x20,0x00,0x4d,0x00,0x6f,0x00,0x64,0x00,0x75,0x00, - 0x6c,0x00,0x65,0x00,0x00,0x00,0x36,0x00,0x0b,0x00,0x01,0x00,0x46,0x00,0x69,0x00,0x6c,0x00, - 0x65,0x00,0x56,0x00,0x65,0x00,0x72,0x00,0x73,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x00,0x00, - 0x00,0x00,0x31,0x00,0x2c,0x00,0x20,0x00,0x30,0x00,0x2c,0x00,0x20,0x00,0x30,0x00,0x2c,0x00, - 0x20,0x00,0x31,0x00,0x00,0x00,0x00,0x00,0x2e,0x00,0x07,0x00,0x01,0x00,0x49,0x00,0x6e,0x00, - 0x74,0x00,0x65,0x00,0x72,0x00,0x6e,0x00,0x61,0x00,0x6c,0x00,0x4e,0x00,0x61,0x00,0x6d,0x00, - 0x65,0x00,0x00,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00,0x64,0x00,0x72,0x00,0x00,0x00, - 0x00,0x00,0x4a,0x00,0x13,0x00,0x01,0x00,0x4c,0x00,0x65,0x00,0x67,0x00,0x61,0x00,0x6c,0x00, - 0x43,0x00,0x6f,0x00,0x70,0x00,0x79,0x00,0x72,0x00,0x69,0x00,0x67,0x00,0x68,0x00,0x74,0x00, - 0x00,0x00,0x4e,0x00,0x69,0x00,0x63,0x00,0x6b,0x00,0x20,0x00,0x47,0x00,0x61,0x00,0x62,0x00, - 0x61,0x00,0x72,0x00,0x65,0x00,0x76,0x00,0x20,0x00,0x27,0x00,0x32,0x00,0x30,0x00,0x30,0x00, - 0x39,0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x0d,0x00,0x01,0x00,0x4f,0x00,0x72,0x00,0x69,0x00, - 0x67,0x00,0x69,0x00,0x6e,0x00,0x61,0x00,0x6c,0x00,0x46,0x00,0x69,0x00,0x6c,0x00,0x65,0x00, - 0x6e,0x00,0x61,0x00,0x6d,0x00,0x65,0x00,0x00,0x00,0x54,0x00,0x6d,0x00,0x70,0x00,0x52,0x00, - 0x64,0x00,0x72,0x00,0x36,0x00,0x34,0x00,0x2e,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x00,0x00, - 0x00,0x00,0x54,0x00,0x1a,0x00,0x01,0x00,0x50,0x00,0x72,0x00,0x6f,0x00,0x64,0x00,0x75,0x00, - 0x63,0x00,0x74,0x00,0x4e,0x00,0x61,0x00,0x6d,0x00,0x65,0x00,0x00,0x00,0x00,0x00,0x43,0x00, - 0x6f,0x00,0x72,0x00,0x65,0x00,0x20,0x00,0x32,0x00,0x20,0x00,0x54,0x00,0x65,0x00,0x6d,0x00, - 0x70,0x00,0x65,0x00,0x72,0x00,0x61,0x00,0x74,0x00,0x75,0x00,0x72,0x00,0x65,0x00,0x20,0x00, - 0x52,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x65,0x00,0x72,0x00,0x00,0x00,0x3a,0x00,0x0b,0x00, - 0x01,0x00,0x50,0x00,0x72,0x00,0x6f,0x00,0x64,0x00,0x75,0x00,0x63,0x00,0x74,0x00,0x56,0x00, - 0x65,0x00,0x72,0x00,0x73,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x00,0x00,0x31,0x00,0x2c,0x00, - 0x20,0x00,0x30,0x00,0x2c,0x00,0x20,0x00,0x30,0x00,0x2c,0x00,0x20,0x00,0x31,0x00,0x00,0x00, - 0x00,0x00,0x44,0x00,0x00,0x00,0x01,0x00,0x56,0x00,0x61,0x00,0x72,0x00,0x46,0x00,0x69,0x00, - 0x6c,0x00,0x65,0x00,0x49,0x00,0x6e,0x00,0x66,0x00,0x6f,0x00,0x00,0x00,0x00,0x00,0x24,0x00, - 0x04,0x00,0x00,0x00,0x54,0x00,0x72,0x00,0x61,0x00,0x6e,0x00,0x73,0x00,0x6c,0x00,0x61,0x00, - 0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x00,0x00,0x00,0x00,0x09,0x04,0xb0,0x04,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -}; -//} end -#endif // _WIN32 - -int msrdriver_dummy; // a dummy to avoid a linker warning on OS X. diff --git a/contrib/libcpuid/include/libcpuid/rdmsr.c b/contrib/libcpuid/include/libcpuid/rdmsr.c deleted file mode 100644 index a27e939bba0..00000000000 --- a/contrib/libcpuid/include/libcpuid/rdmsr.c +++ /dev/null @@ -1,922 +0,0 @@ -/* - * Copyright 2009 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#define _XOPEN_SOURCE 500 -#include -#include -#include "libcpuid.h" -#include "asm-bits.h" -#include "libcpuid_util.h" -#include "libcpuid_internal.h" -#include "rdtsc.h" - -#if defined (__linux__) || defined (__gnu_linux__) -/* Assuming linux with /dev/cpu/x/msr: */ -#include -#include -#include -#include -#include -#include -struct msr_driver_t { int fd; }; -static int rdmsr_supported(void); -static int load_driver(char *msr_path) -{ - const int file_exists = !access(msr_path, F_OK); - const int file_readable = !access(msr_path, R_OK); - - if (file_exists && file_readable) - return 1; - else if (file_exists && !file_readable) - return 0; - else if (getuid() != 0) - return 0; - else - return !system("modprobe msr 2> /dev/null"); -} - -struct msr_driver_t* cpu_msr_driver_open(void) -{ - return cpu_msr_driver_open_core(0); -} - -struct msr_driver_t* cpu_msr_driver_open_core(unsigned core_num) -{ - char msr[32]; - struct msr_driver_t* handle; - if (core_num >= cpuid_get_total_cpus()) { - set_error(ERR_INVCNB); - return NULL; - } - if (!rdmsr_supported()) { - set_error(ERR_NO_RDMSR); - return NULL; - } - sprintf(msr, "/dev/cpu/%u/msr", core_num); - if(!load_driver(msr)) { - set_error(ERR_NO_DRIVER); - return NULL; - } - int fd = open(msr, O_RDONLY); - if (fd < 0) { - if (errno == EIO) { - set_error(ERR_NO_RDMSR); - return NULL; - } - set_error(ERR_NO_DRIVER); - return NULL; - } - handle = (struct msr_driver_t*) malloc(sizeof(struct msr_driver_t)); - handle->fd = fd; - return handle; -} - -int cpu_rdmsr(struct msr_driver_t* driver, uint32_t msr_index, uint64_t* result) -{ - ssize_t ret; - - if (!driver || driver->fd < 0) - return set_error(ERR_HANDLE); - ret = pread(driver->fd, result, 8, msr_index); - if (ret != 8) - return set_error(ERR_INVMSR); - return 0; -} - -int cpu_msr_driver_close(struct msr_driver_t* drv) -{ - if (drv && drv->fd >= 0) { - close(drv->fd); - free(drv); - } - return 0; -} - -/* #endif defined (__linux__) || defined (__gnu_linux__) */ - -#elif defined (__FreeBSD__) || defined (__DragonFly__) -/* Assuming FreeBSD with /dev/cpuctlX */ -#include -#include -#include -#include -#include - -struct msr_driver_t { int fd; }; -static int rdmsr_supported(void); -static int load_driver(char *msr_path) -{ - const int file_exists = !access(msr_path, F_OK); - const int file_readable = !access(msr_path, R_OK); - - if (file_exists && file_readable) - return 1; - else if (file_exists && !file_readable) - return 0; - else if (getuid() != 0) - return 0; - else - return !system("kldload -n cpuctl 2> /dev/null"); -} - -struct msr_driver_t* cpu_msr_driver_open(void) -{ - return cpu_msr_driver_open_core(0); -} - -struct msr_driver_t* cpu_msr_driver_open_core(unsigned core_num) -{ - char msr[32]; - struct msr_driver_t* handle; - if (core_num >= cpuid_get_total_cpus()) { - set_error(ERR_INVCNB); - return NULL; - } - if (!rdmsr_supported()) { - set_error(ERR_NO_RDMSR); - return NULL; - } - sprintf(msr, "/dev/cpuctl%u", core_num); - if(!load_driver(msr)) { - set_error(ERR_NO_DRIVER); - return NULL; - } - int fd = open(msr, O_RDONLY); - if (fd < 0) { - if (errno == EIO) { - set_error(ERR_NO_RDMSR); - return NULL; - } - set_error(ERR_NO_DRIVER); - return NULL; - } - handle = (struct msr_driver_t*) malloc(sizeof(struct msr_driver_t)); - handle->fd = fd; - return handle; -} - -int cpu_rdmsr(struct msr_driver_t* driver, uint32_t msr_index, uint64_t* result) -{ - cpuctl_msr_args_t args; - args.msr = msr_index; - - if (!driver || driver->fd < 0) - return set_error(ERR_HANDLE); - - if(ioctl(driver->fd, CPUCTL_RDMSR, &args)) - return set_error(ERR_INVMSR); - - *result = args.data; - return 0; -} - -int cpu_msr_driver_close(struct msr_driver_t* drv) -{ - if (drv && drv->fd >= 0) { - close(drv->fd); - free(drv); - } - return 0; -} - -/* #endif defined (__FreeBSD__) || defined (__DragonFly__) */ - -#elif defined (_WIN32) -#include -#include -#include - -extern uint8_t cc_x86driver_code[]; -extern int cc_x86driver_code_size; -extern uint8_t cc_x64driver_code[]; -extern int cc_x64driver_code_size; - -struct msr_driver_t { - char driver_path[MAX_PATH + 1]; - SC_HANDLE scManager; - volatile SC_HANDLE scDriver; - HANDLE hhDriver; - OVERLAPPED ovl; - int errorcode; -}; - -static int rdmsr_supported(void); -static int extract_driver(struct msr_driver_t* driver); -static int load_driver(struct msr_driver_t* driver); - -struct msr_driver_t* cpu_msr_driver_open(void) -{ - struct msr_driver_t* drv; - int status; - if (!rdmsr_supported()) { - set_error(ERR_NO_RDMSR); - return NULL; - } - - drv = (struct msr_driver_t*) malloc(sizeof(struct msr_driver_t)); - if (!drv) { - set_error(ERR_NO_MEM); - return NULL; - } - memset(drv, 0, sizeof(struct msr_driver_t)); - - if (!extract_driver(drv)) { - free(drv); - set_error(ERR_EXTRACT); - return NULL; - } - - status = load_driver(drv); - if (!DeleteFile(drv->driver_path)) - debugf(1, "Deleting temporary driver file failed.\n"); - if (!status) { - set_error(drv->errorcode ? drv->errorcode : ERR_NO_DRIVER); - free(drv); - return NULL; - } - return drv; -} - -struct msr_driver_t* cpu_msr_driver_open_core(unsigned core_num) -{ - warnf("cpu_msr_driver_open_core(): parameter ignored (function is the same as cpu_msr_driver_open)\n"); - return cpu_msr_driver_open(); -} - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); -static BOOL is_running_x64(void) -{ - BOOL bIsWow64 = FALSE; - - LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(__TEXT("kernel32")), "IsWow64Process"); - if(NULL != fnIsWow64Process) - fnIsWow64Process(GetCurrentProcess(), &bIsWow64); - return bIsWow64; -} - - -static int extract_driver(struct msr_driver_t* driver) -{ - FILE *f; - if (!GetTempPath(sizeof(driver->driver_path), driver->driver_path)) return 0; - strcat(driver->driver_path, "TmpRdr.sys"); - - f = fopen(driver->driver_path, "wb"); - if (!f) return 0; - if (is_running_x64()) - fwrite(cc_x64driver_code, 1, cc_x64driver_code_size, f); - else - fwrite(cc_x86driver_code, 1, cc_x86driver_code_size, f); - fclose(f); - return 1; -} - -static BOOL wait_for_service_state(SC_HANDLE hService, DWORD dwDesiredState, SERVICE_STATUS *lpsrvStatus){ - BOOL fOK = FALSE; - DWORD dwWaitHint; - - if(hService != NULL){ - while(TRUE){ - fOK = QueryServiceStatus(hService, lpsrvStatus); - if(!fOK) - break; - if(lpsrvStatus->dwCurrentState == dwDesiredState) - break; - - dwWaitHint = lpsrvStatus->dwWaitHint / 10; // Poll 1/10 of the wait hint - if (dwWaitHint < 1000) - dwWaitHint = 1000; // At most once per second - if (dwWaitHint > 10000) - dwWaitHint = 10000; // At least every 10 seconds - Sleep(dwWaitHint); - } - } - - return fOK; -} - -static int load_driver(struct msr_driver_t* drv) -{ - LPTSTR lpszInfo = __TEXT("RDMSR Executor Driver"); - USHORT uLen = 0; - SERVICE_STATUS srvStatus = {0}; - BOOL fRunning = FALSE; - DWORD dwLastError; - LPTSTR lpszDriverServiceName = __TEXT("TmpRdr"); - TCHAR lpszDriverName[] = __TEXT("\\\\.\\Global\\TmpRdr"); - - if((LPVOID)(drv->scManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) != NULL) { - drv->scDriver = CreateService(drv->scManager, lpszDriverServiceName, lpszInfo, SERVICE_ALL_ACCESS, - SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, - drv->driver_path, NULL, NULL, NULL, NULL, NULL); - if(drv->scDriver == NULL){ - switch(dwLastError = GetLastError()){ - case ERROR_SERVICE_EXISTS: - case ERROR_SERVICE_MARKED_FOR_DELETE:{ - LPQUERY_SERVICE_CONFIG lpqsc; - DWORD dwBytesNeeded; - - drv->scDriver = OpenService(drv->scManager, lpszDriverServiceName, SERVICE_ALL_ACCESS); - if(drv->scDriver == NULL){ - debugf(1, "Error opening service: %d\n", GetLastError()); - break; - } - - QueryServiceConfig(drv->scDriver, NULL, 0, &dwBytesNeeded); - if((dwLastError = GetLastError()) == ERROR_INSUFFICIENT_BUFFER){ - lpqsc = calloc(1, dwBytesNeeded); - if(!QueryServiceConfig(drv->scDriver, lpqsc, dwBytesNeeded, &dwBytesNeeded)){ - free(lpqsc); - debugf(1, "Error query service config(adjusted buffer): %d\n", GetLastError()); - goto clean_up; - } - else{ - free(lpqsc); - } - } - else{ - debugf(1, "Error query service config: %d\n", dwLastError); - goto clean_up; - } - - break; - } - case ERROR_ACCESS_DENIED: - drv->errorcode = ERR_NO_PERMS; - break; - default: - debugf(1, "Create driver service failed: %d\n", dwLastError); - break; - } - } - if(drv->scDriver != NULL){ - if(StartService(drv->scDriver, 0, NULL)){ - if(!wait_for_service_state(drv->scDriver, SERVICE_RUNNING, &srvStatus)){ - debugf(1, "Driver load failed.\n"); - DeleteService(drv->scDriver); - CloseServiceHandle(drv->scManager); - drv->scDriver = NULL; - goto clean_up; - } else { - fRunning = TRUE; - } - } else{ - if((dwLastError = GetLastError()) == ERROR_SERVICE_ALREADY_RUNNING) - fRunning = TRUE; - else{ - debugf(1, "Driver start failed.\n"); - DeleteService(drv->scDriver); - CloseServiceHandle(drv->scManager); - drv->scDriver = NULL; - goto clean_up; - } - - } - if(fRunning) - debugf(1, "Driver already running.\n"); - else - debugf(1, "Driver loaded.\n"); - CloseServiceHandle(drv->scManager); - drv->hhDriver = CreateFile(lpszDriverName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); - drv->ovl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - return 1; - } - } else { - debugf(1, "Open SCM failed: %d\n", GetLastError()); - } - -clean_up: - if(drv->scManager != NULL){ - CloseServiceHandle(drv->scManager); - drv->scManager = 0; // pointless - } - if(drv->scDriver != NULL){ - if(!DeleteService(drv->scDriver)) - debugf(1, "Delete driver service failed: %d\n", GetLastError()); - CloseServiceHandle(drv->scDriver); - drv->scDriver = 0; - } - - return 0; -} - -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define IOCTL_UNKNOWN_BASE FILE_DEVICE_UNKNOWN -#define IOCTL_PROCVIEW_RDMSR CTL_CODE(IOCTL_UNKNOWN_BASE, 0x0803, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - -int cpu_rdmsr(struct msr_driver_t* driver, uint32_t msr_index, uint64_t* result) -{ - DWORD dwBytesReturned; - __int64 msrdata; - SERVICE_STATUS srvStatus = {0}; - - if (!driver) - return set_error(ERR_HANDLE); - DeviceIoControl(driver->hhDriver, IOCTL_PROCVIEW_RDMSR, &msr_index, sizeof(int), &msrdata, sizeof(__int64), &dwBytesReturned, &driver->ovl); - GetOverlappedResult(driver->hhDriver, &driver->ovl, &dwBytesReturned, TRUE); - *result = msrdata; - return 0; -} - -int cpu_msr_driver_close(struct msr_driver_t* drv) -{ - SERVICE_STATUS srvStatus = {0}; - if (drv == NULL) return 0; - if(drv->scDriver != NULL){ - if (drv->hhDriver) CancelIo(drv->hhDriver); - if(drv->ovl.hEvent != NULL) - CloseHandle(drv->ovl.hEvent); - if (drv->hhDriver) CloseHandle(drv->hhDriver); - drv->hhDriver = NULL; - drv->ovl.hEvent = NULL; - if (ControlService(drv->scDriver, SERVICE_CONTROL_STOP, &srvStatus)){ - if (wait_for_service_state(drv->scDriver, SERVICE_STOPPED, &srvStatus)){ - DeleteService(drv->scDriver); - } - } - } - return 0; -} - -/* endif defined (_WIN32) */ - -#else /* Unsupported OS */ -/* On others OS (i.e., Darwin), we still do not support RDMSR, so supply dummy struct - and functions */ - -#define RDMSR_UNSUPPORTED_OS - -struct msr_driver_t { int dummy; }; -struct msr_driver_t* cpu_msr_driver_open(void) -{ - set_error(ERR_NOT_IMP); - return NULL; -} - -struct msr_driver_t* cpu_msr_driver_open_core(unsigned core_num) -{ - set_error(ERR_NOT_IMP); - return NULL; -} - -int cpu_rdmsr(struct msr_driver_t* driver, uint32_t msr_index, uint64_t* result) -{ - return set_error(ERR_NOT_IMP); -} - -int cpu_msr_driver_close(struct msr_driver_t* driver) -{ - return set_error(ERR_NOT_IMP); -} - -int cpu_rdmsr_range(struct msr_driver_t* handle, uint32_t msr_index, uint8_t highbit, - uint8_t lowbit, uint64_t* result) -{ - return set_error(ERR_NOT_IMP); -} - -int cpu_msrinfo(struct msr_driver_t* driver, cpu_msrinfo_request_t which) -{ - return set_error(ERR_NOT_IMP); -} - -#endif /* Unsupported OS */ - -#ifndef RDMSR_UNSUPPORTED_OS - -/* Useful links for hackers: -- AMD MSRs: - AMD BIOS and Kernel Developer’s Guide (BKDG) - * AMD Family 10h Processors - http://support.amd.com/TechDocs/31116.pdf - * AMD Family 11h Processors - http://support.amd.com/TechDocs/41256.pdf - * AMD Family 12h Processors - http://support.amd.com/TechDocs/41131.pdf - * AMD Family 14h Processors - http://support.amd.com/TechDocs/43170_14h_Mod_00h-0Fh_BKDG.pdf - * AMD Family 15h Processors - http://support.amd.com/TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdf - http://support.amd.com/TechDocs/42300_15h_Mod_10h-1Fh_BKDG.pdf - http://support.amd.com/TechDocs/49125_15h_Models_30h-3Fh_BKDG.pdf - http://support.amd.com/TechDocs/50742_15h_Models_60h-6Fh_BKDG.pdf - http://support.amd.com/TechDocs/49125_15h_Models_30h-3Fh_BKDG.pdf - * AMD Family 16h Processors - http://support.amd.com/TechDocs/48751_16h_bkdg.pdf - http://support.amd.com/TechDocs/52740_16h_Models_30h-3Fh_BKDG.pdf - -- Intel MSRs: - Intel® 64 and IA-32 Architectures Software Developer’s Manual - * Volume 3 (3A, 3B, 3C & 3D): System Programming Guide - http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-system-programming-manual-325384.pdf -*/ - -/* AMD MSRs addresses */ -#define MSR_PSTATE_L 0xC0010061 -#define MSR_PSTATE_S 0xC0010063 -#define MSR_PSTATE_0 0xC0010064 -#define MSR_PSTATE_7 0xC001006B - -/* Intel MSRs addresses */ -#define IA32_MPERF 0xE7 -#define IA32_APERF 0xE8 -#define IA32_PERF_STATUS 0x198 -#define IA32_THERM_STATUS 0x19C -#define MSR_EBL_CR_POWERON 0x2A -#define MSR_TURBO_RATIO_LIMIT 0x1AD -#define MSR_TEMPERATURE_TARGET 0x1A2 -#define MSR_PERF_STATUS 0x198 -#define MSR_PLATFORM_INFO 0xCE - - -static int rdmsr_supported(void) -{ - struct cpu_id_t* id = get_cached_cpuid(); - return id->flags[CPU_FEATURE_MSR]; -} - -static int perfmsr_measure(struct msr_driver_t* handle, int msr) -{ - int err; - uint64_t a, b; - uint64_t x, y; - err = cpu_rdmsr(handle, msr, &x); - if (err) return CPU_INVALID_VALUE; - sys_precise_clock(&a); - busy_loop_delay(10); - cpu_rdmsr(handle, msr, &y); - sys_precise_clock(&b); - if (a >= b || x > y) return CPU_INVALID_VALUE; - return (int) ((y - x) / (b - a)); -} - -static int get_amd_multipliers(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal, - uint32_t pstate, uint64_t *multiplier) -{ - int err; - static int clock = 0; - uint64_t CpuFid, CpuDid, CpuDidLSD; - double divisor; - - if (pstate < MSR_PSTATE_0 || MSR_PSTATE_7 < pstate) - return 1; - - switch (id->ext_family) { - case 0x11: - /* BKDG 11h, page 236 - MSRC001_00[6B:64][8:6] is CpuDid - MSRC001_00[6B:64][5:0] is CpuFid - CPU COF is ((100 MHz * (CpuFid + 08h)) / (2^CpuDid)) */ - err = cpu_rdmsr_range(handle, pstate, 8, 6, &CpuDid); - err += cpu_rdmsr_range(handle, pstate, 5, 0, &CpuFid); - *multiplier = (uint64_t) ((CpuFid + 0x8) / (1ull << CpuDid)); - break; - case 0x12: - /* BKDG 12h, page 469 - MSRC001_00[6B:64][8:4] is CpuFid - MSRC001_00[6B:64][3:0] is CpuDid - CPU COF is (100MHz * (CpuFid + 10h) / (divisor specified by CpuDid)) */ - err = cpu_rdmsr_range(handle, pstate, 8, 4, &CpuFid); - err += cpu_rdmsr_range(handle, pstate, 3, 0, &CpuDid); - if (CpuDid == 0x0) - divisor = 1; - else if (CpuDid == 0x1) - divisor = 1.5; - else if (CpuDid == 0x2) - divisor = 2; - else if (CpuDid == 0x3) - divisor = 3; - else if (CpuDid == 0x4) - divisor = 4; - else if (CpuDid == 0x5) - divisor = 6; - else if (CpuDid == 0x6) - divisor = 8; - else if (CpuDid == 0x7) - divisor = 12; - else if (CpuDid == 0x8) - divisor = 16; - else - divisor = 0; - - if (divisor > 0) - *multiplier = (uint64_t) ((CpuFid + 0x10) / divisor); - else - err++; - break; - case 0x14: - /* BKDG 14h, page 430 - MSRC001_00[6B:64][8:4] is CpuDidMSD - MSRC001_00[6B:64][3:0] is CpuDidLSD - PLL COF is (100 MHz * (D18F3xD4[MainPllOpFreqId] + 10h)) - Divisor is (CpuDidMSD + (CpuDidLSD * 0.25) + 1) - CPU COF is (main PLL frequency specified by D18F3xD4[MainPllOpFreqId]) / (core clock divisor specified by CpuDidMSD and CpuDidLSD) */ - err = cpu_rdmsr_range(handle, pstate, 8, 4, &CpuDid); - err += cpu_rdmsr_range(handle, pstate, 3, 0, &CpuDidLSD); - if (clock == 0) - clock = cpu_clock_measure(100, 1) + 5; // Fake round - *multiplier = (uint64_t) ((clock / 100 + 0x10) / (CpuDid + CpuDidLSD * 0.25 + 1)); - break; - case 0x10: - /* BKDG 10h, page 429 - MSRC001_00[6B:64][8:6] is CpuDid - MSRC001_00[6B:64][5:0] is CpuFid - CPU COF is (100 MHz * (CpuFid + 10h) / (2^CpuDid)) */ - case 0x15: - /* BKDG 15h, page 570/580/635/692 (00h-0Fh/10h-1Fh/30h-3Fh/60h-6Fh) - MSRC001_00[6B:64][8:6] is CpuDid - MSRC001_00[6B:64][5:0] is CpuFid - CoreCOF is (100 * (MSRC001_00[6B:64][CpuFid] + 10h) / (2^MSRC001_00[6B:64][CpuDid])) */ - case 0x16: - /* BKDG 16h, page 549/611 (00h-0Fh/30h-3Fh) - MSRC001_00[6B:64][8:6] is CpuDid - MSRC001_00[6B:64][5:0] is CpuFid - CoreCOF is (100 * (MSRC001_00[6B:64][CpuFid] + 10h) / (2^MSRC001_00[6B:64][CpuDid])) */ - err = cpu_rdmsr_range(handle, pstate, 8, 6, &CpuDid); - err += cpu_rdmsr_range(handle, pstate, 5, 0, &CpuFid); - *multiplier = (uint64_t) ((CpuFid + 0x10) / (1ull << CpuDid)); - break; - default: - err = 1; - break; - } - - return err; -} - -static double get_info_min_multiplier(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal) -{ - int err; - uint64_t reg; - - if(id->vendor == VENDOR_INTEL) { - /* Refer links above - Table 35-12. MSRs in Next Generation Intel Atom Processors Based on the Goldmont Microarchitecture - Table 35-13. MSRs in Processors Based on Intel® Microarchitecture Code Name Nehalem - Table 35-18. MSRs Supported by Intel® Processors based on Intel® microarchitecture code name Sandy Bridge (Contd.) - Table 35-23. Additional MSRs Supported by 3rd Generation Intel® Core™ Processors (based on Intel® microarchitecture code name Ivy Bridge) - Table 35-24. MSRs Supported by Intel® Xeon® Processors E5 v2 Product Family (based on Ivy Bridge-E microarchitecture) - Table 35-27. Additional MSRs Supported by Processors based on the Haswell or Haswell-E microarchitectures - Table 35-34. Additional MSRs Common to Intel® Xeon® Processor D and Intel Xeon Processors E5 v4 Family Based on the Broadwell Microarchitecture - Table 35-40. Selected MSRs Supported by Next Generation Intel® Xeon Phi™ Processors with DisplayFamily_DisplayModel Signature 06_57H - MSR_PLATFORM_INFO[47:40] is Maximum Efficiency Ratio - Maximum Efficiency Ratio is the minimum ratio that the processor can operates */ - err = cpu_rdmsr_range(handle, MSR_PLATFORM_INFO, 47, 40, ®); - if (!err) return (double) reg; - } - else if(id->vendor == VENDOR_AMD) { - /* Refer links above - MSRC001_0061[6:4] is PstateMaxVal - PstateMaxVal is the lowest-performance non-boosted P-state */ - err = cpu_rdmsr_range(handle, MSR_PSTATE_L, 6, 4, ®); - err += get_amd_multipliers(handle, id, internal, MSR_PSTATE_0 + (uint32_t) reg, ®); - if (!err) return (double) reg; - } - - return (double) CPU_INVALID_VALUE / 100; -} - -static double get_info_cur_multiplier(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal) -{ - int err; - uint64_t reg; - - if(id->vendor == VENDOR_INTEL && internal->code.intel == PENTIUM) { - err = cpu_rdmsr(handle, MSR_EBL_CR_POWERON, ®); - if (!err) return (double) ((reg>>22) & 0x1f); - } - else if(id->vendor == VENDOR_INTEL && internal->code.intel != PENTIUM) { - /* Refer links above - Table 35-2. IA-32 Architectural MSRs (Contd.) - IA32_PERF_STATUS[15:0] is Current performance State Value - [7:0] is 0x0, [15:8] looks like current ratio */ - err = cpu_rdmsr_range(handle, IA32_PERF_STATUS, 15, 8, ®); - if (!err) return (double) reg; - } - else if(id->vendor == VENDOR_AMD) { - /* Refer links above - MSRC001_0063[2:0] is CurPstate */ - err = cpu_rdmsr_range(handle, MSR_PSTATE_S, 2, 0, ®); - err += get_amd_multipliers(handle, id, internal, MSR_PSTATE_0 + (uint32_t) reg, ®); - if (!err) return (double) reg; - } - - return (double) CPU_INVALID_VALUE / 100; -} - -static double get_info_max_multiplier(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal) -{ - int err; - uint64_t reg; - - if(id->vendor == VENDOR_INTEL && internal->code.intel == PENTIUM) { - err = cpu_rdmsr(handle, IA32_PERF_STATUS, ®); - if (!err) return (double) ((reg >> 40) & 0x1f); - } - else if(id->vendor == VENDOR_INTEL && internal->code.intel != PENTIUM) { - /* Refer links above - Table 35-10. Specific MSRs Supported by Intel® Atom™ Processor C2000 Series with CPUID Signature 06_4DH - Table 35-12. MSRs in Next Generation Intel Atom Processors Based on the Goldmont Microarchitecture (Contd.) - Table 35-13. MSRs in Processors Based on Intel® Microarchitecture Code Name Nehalem (Contd.) - Table 35-14. Additional MSRs in Intel® Xeon® Processor 5500 and 3400 Series - Table 35-16. Additional MSRs Supported by Intel Processors (Based on Intel® Microarchitecture Code Name Westmere) - Table 35-19. MSRs Supported by 2nd Generation Intel® Core™ Processors (Intel® microarchitecture code name Sandy Bridge) - Table 35-21. Selected MSRs Supported by Intel® Xeon® Processors E5 Family (based on Sandy Bridge microarchitecture) - Table 35-28. MSRs Supported by 4th Generation Intel® Core™ Processors (Haswell microarchitecture) (Contd.) - Table 35-30. Additional MSRs Supported by Intel® Xeon® Processor E5 v3 Family - Table 35-33. Additional MSRs Supported by Intel® Core™ M Processors and 5th Generation Intel® Core™ Processors - Table 35-34. Additional MSRs Common to Intel® Xeon® Processor D and Intel Xeon Processors E5 v4 Family Based on the Broadwell Microarchitecture - Table 35-37. Additional MSRs Supported by 6th Generation Intel® Core™ Processors Based on Skylake Microarchitecture - Table 35-40. Selected MSRs Supported by Next Generation Intel® Xeon Phi™ Processors with DisplayFamily_DisplayModel Signature 06_57H - MSR_TURBO_RATIO_LIMIT[7:0] is Maximum Ratio Limit for 1C */ - err = cpu_rdmsr_range(handle, MSR_TURBO_RATIO_LIMIT, 7, 0, ®); - if (!err) return (double) reg; - } - else if(id->vendor == VENDOR_AMD) { - /* Refer links above - MSRC001_0064 is Pb0 - Pb0 is the highest-performance boosted P-state */ - err = get_amd_multipliers(handle, id, internal, MSR_PSTATE_0, ®); - if (!err) return (double) reg; - } - - return (double) CPU_INVALID_VALUE / 100; -} - -static int get_info_temperature(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal) -{ - int err; - uint64_t DigitalReadout, ReadingValid, TemperatureTarget; - - if(id->vendor == VENDOR_INTEL) { - /* Refer links above - Table 35-2. IA-32 Architectural MSRs - IA32_THERM_STATUS[22:16] is Digital Readout - IA32_THERM_STATUS[31] is Reading Valid - - Table 35-6. MSRs Common to the Silvermont Microarchitecture and Newer Microarchitectures for Intel® Atom - Table 35-13. MSRs in Processors Based on Intel® Microarchitecture Code Name Nehalem (Contd.) - Table 35-18. MSRs Supported by Intel® Processors based on Intel® microarchitecture code name Sandy Bridge (Contd.) - Table 35-24. MSRs Supported by Intel® Xeon® Processors E5 v2 Product Family (based on Ivy Bridge-E microarchitecture) (Contd.) - Table 35-34. Additional MSRs Common to Intel® Xeon® Processor D and Intel Xeon Processors E5 v4 Family Based on the Broadwell Microarchitecture - Table 35-40. Selected MSRs Supported by Next Generation Intel® Xeon Phi™ Processors with DisplayFamily_DisplayModel Signature 06_57H - MSR_TEMPERATURE_TARGET[23:16] is Temperature Target */ - err = cpu_rdmsr_range(handle, IA32_THERM_STATUS, 22, 16, &DigitalReadout); - err += cpu_rdmsr_range(handle, IA32_THERM_STATUS, 31, 31, &ReadingValid); - err += cpu_rdmsr_range(handle, MSR_TEMPERATURE_TARGET, 23, 16, &TemperatureTarget); - if(!err && ReadingValid) return (int) (TemperatureTarget - DigitalReadout); - } - - return CPU_INVALID_VALUE; -} - -static double get_info_voltage(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal) -{ - int err; - uint64_t reg, CpuVid; - - if(id->vendor == VENDOR_INTEL) { - /* Refer links above - Table 35-18. MSRs Supported by Intel® Processors based on Intel® microarchitecture code name Sandy Bridge (Contd.) - MSR_PERF_STATUS[47:32] is Core Voltage - P-state core voltage can be computed by MSR_PERF_STATUS[37:32] * (float) 1/(2^13). */ - err = cpu_rdmsr_range(handle, MSR_PERF_STATUS, 47, 32, ®); - if (!err) return (double) reg / (1 << 13); - } - else if(id->vendor == VENDOR_AMD) { - /* Refer links above - MSRC001_00[6B:64][15:9] is CpuVid - MSRC001_0063[2:0] is P-state Status - 2.4.1.6.3 Serial VID (SVI) Encodings: voltage = 1.550V - 0.0125V * SviVid[6:0] */ - err = cpu_rdmsr_range(handle, MSR_PSTATE_S, 2, 0, ®); - err += cpu_rdmsr_range(handle, MSR_PSTATE_0 + (uint32_t) reg, 15, 9, &CpuVid); - if (!err && MSR_PSTATE_0 + (uint32_t) reg <= MSR_PSTATE_7) return 1.550 - 0.0125 * CpuVid; - } - - return (double) CPU_INVALID_VALUE / 100; -} - -static double get_info_bus_clock(struct msr_driver_t* handle, struct cpu_id_t *id, - struct internal_id_info_t *internal) -{ - int err; - static int clock = 0; - uint64_t reg; - - if(clock == 0) - clock = cpu_clock_measure(100, 1); - - if(id->vendor == VENDOR_INTEL) { - /* Refer links above - Table 35-12. MSRs in Next Generation Intel Atom Processors Based on the Goldmont Microarchitecture - Table 35-13. MSRs in Processors Based on Intel® Microarchitecture Code Name Nehalem - Table 35-18. MSRs Supported by Intel® Processors based on Intel® microarchitecture code name Sandy Bridge (Contd.) - Table 35-23. Additional MSRs Supported by 3rd Generation Intel® Core™ Processors (based on Intel® microarchitecture code name Ivy Bridge) - Table 35-24. MSRs Supported by Intel® Xeon® Processors E5 v2 Product Family (based on Ivy Bridge-E microarchitecture) - Table 35-27. Additional MSRs Supported by Processors based on the Haswell or Haswell-E microarchitectures - Table 35-40. Selected MSRs Supported by Next Generation Intel® Xeon Phi™ Processors with DisplayFamily_DisplayModel Signature 06_57H - MSR_PLATFORM_INFO[15:8] is Maximum Non-Turbo Ratio */ - err = cpu_rdmsr_range(handle, MSR_PLATFORM_INFO, 15, 8, ®); - if (!err) return (double) clock / reg; - } - else if(id->vendor == VENDOR_AMD) { - /* Refer links above - MSRC001_0061[2:0] is CurPstateLimit - CurPstateLimit is the highest-performance non-boosted P-state */ - err = cpu_rdmsr_range(handle, MSR_PSTATE_L, 2, 0, ®); - err += get_amd_multipliers(handle, id, internal, MSR_PSTATE_0 + (uint32_t) reg, ®); - if (!err) return (double) clock / reg; - } - - return (double) CPU_INVALID_VALUE / 100; -} - -int cpu_rdmsr_range(struct msr_driver_t* handle, uint32_t msr_index, uint8_t highbit, - uint8_t lowbit, uint64_t* result) -{ - int err; - const uint8_t bits = highbit - lowbit + 1; - - if(highbit > 63 || lowbit > highbit) - return set_error(ERR_INVRANGE); - - err = cpu_rdmsr(handle, msr_index, result); - - if(!err && bits < 64) { - /* Show only part of register */ - *result >>= lowbit; - *result &= (1ULL << bits) - 1; - } - - return err; -} - -int cpu_msrinfo(struct msr_driver_t* handle, cpu_msrinfo_request_t which) -{ - struct cpu_raw_data_t raw; - static struct cpu_id_t id; - static struct internal_id_info_t internal; - internal.score = -1; - - if (handle == NULL) - return set_error(ERR_HANDLE); - - if (internal.score == -1) { - cpuid_get_raw_data(&raw); - cpu_ident_internal(&raw, &id, &internal); - } - - switch (which) { - case INFO_MPERF: - return perfmsr_measure(handle, IA32_MPERF); - case INFO_APERF: - return perfmsr_measure(handle, IA32_APERF); - case INFO_MIN_MULTIPLIER: - return (int) (get_info_min_multiplier(handle, &id, &internal) * 100); - case INFO_CUR_MULTIPLIER: - return (int) (get_info_cur_multiplier(handle, &id, &internal) * 100); - case INFO_MAX_MULTIPLIER: - return (int) (get_info_max_multiplier(handle, &id, &internal) * 100); - case INFO_TEMPERATURE: - return get_info_temperature(handle, &id, &internal); - case INFO_THROTTLING: - return CPU_INVALID_VALUE; - case INFO_VOLTAGE: - return (int) (get_info_voltage(handle, &id, &internal) * 100); - case INFO_BCLK: - case INFO_BUS_CLOCK: - return (int) (get_info_bus_clock(handle, &id, &internal) * 100); - default: - return CPU_INVALID_VALUE; - } -} - -#endif // RDMSR_UNSUPPORTED_OS diff --git a/contrib/libcpuid/include/libcpuid/rdtsc.c b/contrib/libcpuid/include/libcpuid/rdtsc.c deleted file mode 100644 index df4543946f5..00000000000 --- a/contrib/libcpuid/include/libcpuid/rdtsc.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include "libcpuid.h" -#include "libcpuid_util.h" -#include "asm-bits.h" -#include "rdtsc.h" - -#ifdef _WIN32 -#include -void sys_precise_clock(uint64_t *result) -{ - double c, f; - LARGE_INTEGER freq, counter; - QueryPerformanceCounter(&counter); - QueryPerformanceFrequency(&freq); - c = (double) counter.QuadPart; - f = (double) freq.QuadPart; - *result = (uint64_t) ( c * 1000000.0 / f ); -} -#else -/* assuming Linux, Mac OS or other POSIX */ -#include -void sys_precise_clock(uint64_t *result) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - *result = (uint64_t) tv.tv_sec * (uint64_t) 1000000 + - (uint64_t) tv.tv_usec; -} -#endif /* _WIN32 */ - -/* out = a - b */ -static void mark_t_subtract(struct cpu_mark_t* a, struct cpu_mark_t* b, struct cpu_mark_t *out) -{ - out->tsc = a->tsc - b->tsc; - out->sys_clock = a->sys_clock - b->sys_clock; -} - -void cpu_tsc_mark(struct cpu_mark_t* mark) -{ - cpu_rdtsc(&mark->tsc); - sys_precise_clock(&mark->sys_clock); -} - -void cpu_tsc_unmark(struct cpu_mark_t* mark) -{ - struct cpu_mark_t temp; - cpu_tsc_mark(&temp); - mark_t_subtract(&temp, mark, mark); -} - - -int cpu_clock_by_mark(struct cpu_mark_t* mark) -{ - uint64_t result; - - /* Check if some subtraction resulted in a negative number: */ - if ((mark->tsc >> 63) != 0 || (mark->sys_clock >> 63) != 0) return -1; - - /* Divide-by-zero check: */ - if (mark->sys_clock == 0) return -1; - - /* Check if the result fits in 32bits */ - result = mark->tsc / mark->sys_clock; - if (result > (uint64_t) 0x7fffffff) return -1; - return (int) result; -} - -#ifdef _WIN32 -int cpu_clock_by_os(void) -{ - HKEY key; - DWORD result; - DWORD size = 4; - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_READ, &key) != ERROR_SUCCESS) - return -1; - - if (RegQueryValueEx(key, TEXT("~MHz"), NULL, NULL, (LPBYTE) &result, (LPDWORD) &size) != ERROR_SUCCESS) { - RegCloseKey(key); - return -1; - } - RegCloseKey(key); - - return (int)result; -} -#else -#ifdef __APPLE__ -#include -#include -/* Assuming Mac OS X with hw.cpufrequency sysctl */ -int cpu_clock_by_os(void) -{ - long long result = -1; - size_t size = sizeof(result); - if (sysctlbyname("hw.cpufrequency", &result, &size, NULL, 0)) - return -1; - return (int) (result / (long long) 1000000); -} -#else -/* Assuming Linux with /proc/cpuinfo */ -int cpu_clock_by_os(void) -{ - FILE *f; - char line[1024], *s; - int result; - - f = fopen("/proc/cpuinfo", "rt"); - if (!f) return -1; - - while (fgets(line, sizeof(line), f)) { - if (!strncmp(line, "cpu MHz", 7)) { - s = strchr(line, ':'); - if (s && 1 == sscanf(s, ":%d.", &result)) { - fclose(f); - return result; - } - } - } - fclose(f); - return -1; -} -#endif /* __APPLE__ */ -#endif /* _WIN32 */ - -/* Emulate doing useful CPU intensive work */ -static int busy_loop(int amount) -{ - int i, j, k, s = 0; - static volatile int data[42] = {32, 12, -1, 5, 23, 0 }; - for (i = 0; i < amount; i++) - for (j = 0; j < 65536; j++) - for (k = 0; k < 42; k++) - s += data[k]; - return s; -} - -int busy_loop_delay(int milliseconds) -{ - int cycles = 0, r = 0, first = 1; - uint64_t a, b, c; - sys_precise_clock(&a); - while (1) { - sys_precise_clock(&c); - if ((c - a) / 1000 > milliseconds) return r; - r += busy_loop(cycles); - if (first) { - first = 0; - } else { - if (c - b < 1000) cycles *= 2; - if (c - b > 10000) cycles /= 2; - } - b = c; - } -} - -int cpu_clock_measure(int millis, int quad_check) -{ - struct cpu_mark_t begin[4], end[4], temp, temp2; - int results[4], cycles, n, k, i, j, bi, bj, mdiff, diff, _zero = 0; - uint64_t tl; - - if (millis < 1) return -1; - tl = millis * (uint64_t) 1000; - if (quad_check) - tl /= 4; - n = quad_check ? 4 : 1; - cycles = 1; - for (k = 0; k < n; k++) { - cpu_tsc_mark(&begin[k]); - end[k] = begin[k]; - do { - /* Run busy loop, and fool the compiler that we USE the garbishy - value it calculates */ - _zero |= (1 & busy_loop(cycles)); - cpu_tsc_mark(&temp); - mark_t_subtract(&temp, &end[k], &temp2); - /* If busy loop is too short, increase it */ - if (temp2.sys_clock < tl / 8) - cycles *= 2; - end[k] = temp; - } while (end[k].sys_clock - begin[k].sys_clock < tl); - mark_t_subtract(&end[k], &begin[k], &temp); - results[k] = cpu_clock_by_mark(&temp); - } - if (n == 1) return results[0]; - mdiff = 0x7fffffff; - bi = bj = -1; - for (i = 0; i < 4; i++) { - for (j = i + 1; j < 4; j++) { - diff = results[i] - results[j]; - if (diff < 0) diff = -diff; - if (diff < mdiff) { - mdiff = diff; - bi = i; - bj = j; - } - } - } - if (results[bi] == -1) return -1; - return (results[bi] + results[bj] + _zero) / 2; -} - - -static void adjust_march_ic_multiplier(const struct cpu_id_t* id, int* numerator, int* denom) -{ - /* - * for cpu_clock_by_ic: we need to know how many clocks does a typical ADDPS instruction - * take, when issued in rapid succesion without dependencies. The whole idea of - * cpu_clock_by_ic was that this is easy to determine, at least it was back in 2010. Now - * it's getting progressively more hairy, but here are the current measurements: - * - * 1. For CPUs with 64-bit SSE units, ADDPS issue rate is 0.5 IPC (one insn in 2 clocks) - * 2. For CPUs with 128-bit SSE units, issue rate is exactly 1.0 IPC - * 3. For Bulldozer and later, it is 1.4 IPC (we multiply by 5/7) - * 4. For Skylake and later, it is 1.6 IPC (we multiply by 5/8) - */ - // - if (id->sse_size < 128) { - debugf(1, "SSE execution path is 64-bit\n"); - // on a CPU with half SSE unit length, SSE instructions execute at 0.5 IPC; - // the resulting value must be multiplied by 2: - *numerator = 2; - } else { - debugf(1, "SSE execution path is 128-bit\n"); - } - // - // Bulldozer or later: assume 1.4 IPC - if (id->vendor == VENDOR_AMD && id->ext_family >= 21) { - debugf(1, "cpu_clock_by_ic: Bulldozer (or later) detected, dividing result by 1.4\n"); - *numerator = 5; - *denom = 7; // multiply by 5/7, to divide by 1.4 - } - // - // Skylake or later: assume 1.6 IPC - if (id->vendor == VENDOR_INTEL && id->ext_model >= 94) { - debugf(1, "cpu_clock_by_ic: Skylake (or later) detected, dividing result by 1.6\n"); - *numerator = 5; - *denom = 8; // to divide by 1.6, multiply by 5/8 - } -} - -int cpu_clock_by_ic(int millis, int runs) -{ - int max_value = 0, cur_value, i, ri, cycles_inner, cycles_outer, c; - struct cpu_id_t* id; - uint64_t t0, t1, tl, hz; - int multiplier_numerator = 1, multiplier_denom = 1; - if (millis <= 0 || runs <= 0) return -2; - id = get_cached_cpuid(); - // if there aren't SSE instructions - we can't run the test at all - if (!id || !id->flags[CPU_FEATURE_SSE]) return -1; - // - adjust_march_ic_multiplier(id, &multiplier_numerator, &multiplier_denom); - // - tl = millis * 125; // (*1000 / 8) - cycles_inner = 128; - cycles_outer = 1; - do { - if (cycles_inner < 1000000000) cycles_inner *= 2; - else cycles_outer *= 2; - sys_precise_clock(&t0); - for (i = 0; i < cycles_outer; i++) - busy_sse_loop(cycles_inner); - sys_precise_clock(&t1); - } while (t1 - t0 < tl); - debugf(2, "inner: %d, outer: %d\n", cycles_inner, cycles_outer); - for (ri = 0; ri < runs; ri++) { - sys_precise_clock(&t0); - c = 0; - do { - c++; - for (i = 0; i < cycles_outer; i++) - busy_sse_loop(cycles_inner); - sys_precise_clock(&t1); - } while (t1 - t0 < tl * (uint64_t) 8); - // cpu_Hz = cycles_inner * cycles_outer * 256 / (t1 - t0) * 1000000 - debugf(2, "c = %d, td = %d\n", c, (int) (t1 - t0)); - hz = ((uint64_t) cycles_inner * (uint64_t) 256 + 12) * - (uint64_t) cycles_outer * (uint64_t) multiplier_numerator * (uint64_t) c * (uint64_t) 1000000 - / ((t1 - t0) * (uint64_t) multiplier_denom); - cur_value = (int) (hz / 1000000); - if (cur_value > max_value) max_value = cur_value; - } - return max_value; -} - -int cpu_clock(void) -{ - int result; - result = cpu_clock_by_os(); - if (result <= 0) - result = cpu_clock_measure(200, 1); - return result; -} diff --git a/contrib/libcpuid/include/libcpuid/rdtsc.h b/contrib/libcpuid/include/libcpuid/rdtsc.h deleted file mode 100644 index b4aaf99a570..00000000000 --- a/contrib/libcpuid/include/libcpuid/rdtsc.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2010 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __RDTSC_H__ -#define __RDTSC_H__ - -void sys_precise_clock(uint64_t *result); -int busy_loop_delay(int milliseconds); - - -#endif /* __RDTSC_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/recog_amd.c b/contrib/libcpuid/include/libcpuid/recog_amd.c deleted file mode 100644 index 2e6c8a9ead8..00000000000 --- a/contrib/libcpuid/include/libcpuid/recog_amd.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "libcpuid.h" -#include "libcpuid_util.h" -#include "libcpuid_internal.h" -#include "recog_amd.h" - -const struct amd_code_str { amd_code_t code; char *str; } amd_code_str[] = { - #define CODE(x) { x, #x } - #define CODE2(x, y) CODE(x) - #include "amd_code_t.h" - #undef CODE -}; - -const struct match_entry_t cpudb_amd[] = { - { -1, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown AMD CPU" }, - - /* 486 and the likes */ - { 4, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown AMD 486" }, - { 4, 3, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "AMD 486DX2" }, - { 4, 7, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "AMD 486DX2WB" }, - { 4, 8, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "AMD 486DX4" }, - { 4, 9, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "AMD 486DX4WB" }, - - /* Pentia clones */ - { 5, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown AMD 586" }, - { 5, 0, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K5" }, - { 5, 1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K5" }, - { 5, 2, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K5" }, - { 5, 3, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K5" }, - - /* The K6 */ - { 5, 6, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K6" }, - { 5, 7, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K6" }, - - { 5, 8, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K6-2" }, - { 5, 9, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K6-III" }, - { 5, 10, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown K6" }, - { 5, 11, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown K6" }, - { 5, 12, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown K6" }, - { 5, 13, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "K6-2+" }, - - /* Athlon et al. */ - { 6, 1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Athlon (Slot-A)" }, - { 6, 2, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Athlon (Slot-A)" }, - { 6, 3, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Duron (Spitfire)" }, - { 6, 4, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Athlon (ThunderBird)" }, - - { 6, 6, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Athlon" }, - { 6, 6, -1, -1, -1, 1, -1, -1, ATHLON , 0, "Athlon (Palomino)" }, - { 6, 6, -1, -1, -1, 1, -1, -1, ATHLON_MP , 0, "Athlon MP (Palomino)" }, - { 6, 6, -1, -1, -1, 1, -1, -1, DURON , 0, "Duron (Palomino)" }, - { 6, 6, -1, -1, -1, 1, -1, -1, ATHLON_XP , 0, "Athlon XP" }, - - { 6, 7, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Athlon XP" }, - { 6, 7, -1, -1, -1, 1, -1, -1, DURON , 0, "Duron (Morgan)" }, - - { 6, 8, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Athlon XP" }, - { 6, 8, -1, -1, -1, 1, -1, -1, ATHLON , 0, "Athlon XP (Thoroughbred)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, ATHLON_XP , 0, "Athlon XP (Thoroughbred)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, DURON , 0, "Duron (Applebred)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, SEMPRON , 0, "Sempron (Thoroughbred)" }, - { 6, 8, -1, -1, -1, 1, 128, -1, SEMPRON , 0, "Sempron (Thoroughbred)" }, - { 6, 8, -1, -1, -1, 1, 256, -1, SEMPRON , 0, "Sempron (Thoroughbred)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, ATHLON_MP , 0, "Athlon MP (Thoroughbred)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, ATHLON_XP_M , 0, "Mobile Athlon (T-Bred)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, ATHLON_XP_M_LV , 0, "Mobile Athlon (T-Bred)" }, - - { 6, 10, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Athlon XP (Barton)" }, - { 6, 10, -1, -1, -1, 1, 512, -1, ATHLON_XP , 0, "Athlon XP (Barton)" }, - { 6, 10, -1, -1, -1, 1, 512, -1, SEMPRON , 0, "Sempron (Barton)" }, - { 6, 10, -1, -1, -1, 1, 256, -1, SEMPRON , 0, "Sempron (Thorton)" }, - { 6, 10, -1, -1, -1, 1, 256, -1, ATHLON_XP , 0, "Athlon XP (Thorton)" }, - { 6, 10, -1, -1, -1, 1, -1, -1, ATHLON_MP , 0, "Athlon MP (Barton)" }, - { 6, 10, -1, -1, -1, 1, -1, -1, ATHLON_XP_M , 0, "Mobile Athlon (Barton)" }, - { 6, 10, -1, -1, -1, 1, -1, -1, ATHLON_XP_M_LV , 0, "Mobile Athlon (Barton)" }, - - /* K8 Architecture */ - { 15, -1, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Unknown K8" }, - { 15, -1, -1, 16, -1, 1, -1, -1, NO_CODE , 0, "Unknown K9" }, - - { 15, -1, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Unknown A64" }, - { 15, -1, -1, 15, -1, 1, -1, -1, OPTERON_SINGLE , 0, "Opteron" }, - { 15, -1, -1, 15, -1, 2, -1, -1, OPTERON_DUALCORE , 0, "Opteron (Dual Core)" }, - { 15, 3, -1, 15, -1, 1, -1, -1, OPTERON_SINGLE , 0, "Opteron" }, - { 15, 3, -1, 15, -1, 2, -1, -1, OPTERON_DUALCORE , 0, "Opteron (Dual Core)" }, - { 15, -1, -1, 15, -1, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (512K)" }, - { 15, -1, -1, 15, -1, 1, 1024, -1, ATHLON_64 , 0, "Athlon 64 (1024K)" }, - { 15, -1, -1, 15, -1, 1, -1, -1, ATHLON_FX , 0, "Athlon FX" }, - { 15, -1, -1, 15, -1, 1, -1, -1, ATHLON_64_FX , 0, "Athlon 64 FX" }, - { 15, 3, -1, 15, 35, 2, -1, -1, ATHLON_64_FX , 0, "Athlon 64 FX X2 (Toledo)" }, - { 15, -1, -1, 15, -1, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (512K)" }, - { 15, -1, -1, 15, -1, 2, 1024, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (1024K)" }, - { 15, -1, -1, 15, -1, 1, 512, -1, TURION_64 , 0, "Turion 64 (512K)" }, - { 15, -1, -1, 15, -1, 1, 1024, -1, TURION_64 , 0, "Turion 64 (1024K)" }, - { 15, -1, -1, 15, -1, 2, 512, -1, TURION_X2 , 0, "Turion 64 X2 (512K)" }, - { 15, -1, -1, 15, -1, 2, 1024, -1, TURION_X2 , 0, "Turion 64 X2 (1024K)" }, - { 15, -1, -1, 15, -1, 1, 128, -1, SEMPRON , 0, "A64 Sempron (128K)" }, - { 15, -1, -1, 15, -1, 1, 256, -1, SEMPRON , 0, "A64 Sempron (256K)" }, - { 15, -1, -1, 15, -1, 1, 512, -1, SEMPRON , 0, "A64 Sempron (512K)" }, - { 15, -1, -1, 15, 0x4f, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (Orleans/512K)" }, - { 15, -1, -1, 15, 0x5f, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (Orleans/512K)" }, - { 15, -1, -1, 15, 0x2f, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (Venice/512K)" }, - { 15, -1, -1, 15, 0x2c, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (Venice/512K)" }, - { 15, -1, -1, 15, 0x1f, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (Winchester/512K)" }, - { 15, -1, -1, 15, 0x0c, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (Newcastle/512K)" }, - { 15, -1, -1, 15, 0x27, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (San Diego/512K)" }, - { 15, -1, -1, 15, 0x37, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (San Diego/512K)" }, - { 15, -1, -1, 15, 0x04, 1, 512, -1, ATHLON_64 , 0, "Athlon 64 (ClawHammer/512K)" }, - - { 15, -1, -1, 15, 0x5f, 1, 1024, -1, ATHLON_64 , 0, "Athlon 64 (Orleans/1024K)" }, - { 15, -1, -1, 15, 0x27, 1, 1024, -1, ATHLON_64 , 0, "Athlon 64 (San Diego/1024K)" }, - { 15, -1, -1, 15, 0x04, 1, 1024, -1, ATHLON_64 , 0, "Athlon 64 (ClawHammer/1024K)" }, - - { 15, -1, -1, 15, 0x4b, 2, 256, -1, SEMPRON_DUALCORE , 0, "Athlon 64 X2 (Windsor/256K)" }, - - { 15, -1, -1, 15, 0x23, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Toledo/512K)" }, - { 15, -1, -1, 15, 0x4b, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Windsor/512K)" }, - { 15, -1, -1, 15, 0x43, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Windsor/512K)" }, - { 15, -1, -1, 15, 0x6b, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Brisbane/512K)" }, - { 15, -1, -1, 15, 0x2b, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Manchester/512K)"}, - - { 15, -1, -1, 15, 0x23, 2, 1024, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Toledo/1024K)" }, - { 15, -1, -1, 15, 0x43, 2, 1024, -1, ATHLON_64_X2 , 0, "Athlon 64 X2 (Windsor/1024K)" }, - - { 15, -1, -1, 15, 0x08, 1, 128, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Dublin/128K)"}, - { 15, -1, -1, 15, 0x08, 1, 256, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Dublin/256K)"}, - { 15, -1, -1, 15, 0x0c, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Paris)" }, - { 15, -1, -1, 15, 0x1c, 1, 128, -1, SEMPRON , 0, "Sempron 64 (Palermo/128K)" }, - { 15, -1, -1, 15, 0x1c, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Palermo/256K)" }, - { 15, -1, -1, 15, 0x1c, 1, 128, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Sonora/128K)"}, - { 15, -1, -1, 15, 0x1c, 1, 256, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Sonora/256K)"}, - { 15, -1, -1, 15, 0x2c, 1, 128, -1, SEMPRON , 0, "Sempron 64 (Palermo/128K)" }, - { 15, -1, -1, 15, 0x2c, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Palermo/256K)" }, - { 15, -1, -1, 15, 0x2c, 1, 128, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Albany/128K)"}, - { 15, -1, -1, 15, 0x2c, 1, 256, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Albany/256K)"}, - { 15, -1, -1, 15, 0x2f, 1, 128, -1, SEMPRON , 0, "Sempron 64 (Palermo/128K)" }, - { 15, -1, -1, 15, 0x2f, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Palermo/256K)" }, - { 15, -1, -1, 15, 0x4f, 1, 128, -1, SEMPRON , 0, "Sempron 64 (Manila/128K)" }, - { 15, -1, -1, 15, 0x4f, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Manila/256K)" }, - { 15, -1, -1, 15, 0x5f, 1, 128, -1, SEMPRON , 0, "Sempron 64 (Manila/128K)" }, - { 15, -1, -1, 15, 0x5f, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Manila/256K)" }, - { 15, -1, -1, 15, 0x6b, 2, 256, -1, SEMPRON , 0, "Sempron 64 Dual (Sherman/256K)"}, - { 15, -1, -1, 15, 0x6b, 2, 512, -1, SEMPRON , 0, "Sempron 64 Dual (Sherman/512K)"}, - { 15, -1, -1, 15, 0x7f, 1, 256, -1, SEMPRON , 0, "Sempron 64 (Sparta/256K)" }, - { 15, -1, -1, 15, 0x7f, 1, 512, -1, SEMPRON , 0, "Sempron 64 (Sparta/512K)" }, - { 15, -1, -1, 15, 0x4c, 1, 256, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Keene/256K)"}, - { 15, -1, -1, 15, 0x4c, 1, 512, -1, M_SEMPRON , 0, "Mobile Sempron 64 (Keene/512K)"}, - { 15, -1, -1, 15, -1, 2, -1, -1, SEMPRON_DUALCORE , 0, "Sempron Dual Core" }, - - { 15, -1, -1, 15, 0x24, 1, 512, -1, TURION_64 , 0, "Turion 64 (Lancaster/512K)" }, - { 15, -1, -1, 15, 0x24, 1, 1024, -1, TURION_64 , 0, "Turion 64 (Lancaster/1024K)" }, - { 15, -1, -1, 15, 0x48, 2, 256, -1, TURION_X2 , 0, "Turion X2 (Taylor)" }, - { 15, -1, -1, 15, 0x48, 2, 512, -1, TURION_X2 , 0, "Turion X2 (Trinidad)" }, - { 15, -1, -1, 15, 0x4c, 1, 512, -1, TURION_64 , 0, "Turion 64 (Richmond)" }, - { 15, -1, -1, 15, 0x68, 2, 256, -1, TURION_X2 , 0, "Turion X2 (Tyler/256K)" }, - { 15, -1, -1, 15, 0x68, 2, 512, -1, TURION_X2 , 0, "Turion X2 (Tyler/512K)" }, - { 15, -1, -1, 17, 3, 2, 512, -1, TURION_X2 , 0, "Turion X2 (Griffin/512K)" }, - { 15, -1, -1, 17, 3, 2, 1024, -1, TURION_X2 , 0, "Turion X2 (Griffin/1024K)" }, - - /* K9 Architecture */ - { 15, -1, -1, 16, -1, 1, -1, -1, PHENOM , 0, "Unknown AMD Phenom" }, - { 15, 2, -1, 16, -1, 1, -1, -1, PHENOM , 0, "Phenom" }, - { 15, 2, -1, 16, -1, 3, -1, -1, PHENOM , 0, "Phenom X3 (Toliman)" }, - { 15, 2, -1, 16, -1, 4, -1, -1, PHENOM , 0, "Phenom X4 (Agena)" }, - { 15, 2, -1, 16, -1, 3, 512, -1, PHENOM , 0, "Phenom X3 (Toliman/256K)" }, - { 15, 2, -1, 16, -1, 3, 512, -1, PHENOM , 0, "Phenom X3 (Toliman/512K)" }, - { 15, 2, -1, 16, -1, 4, 128, -1, PHENOM , 0, "Phenom X4 (Agena/128K)" }, - { 15, 2, -1, 16, -1, 4, 256, -1, PHENOM , 0, "Phenom X4 (Agena/256K)" }, - { 15, 2, -1, 16, -1, 4, 512, -1, PHENOM , 0, "Phenom X4 (Agena/512K)" }, - { 15, 2, -1, 16, -1, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon X2 (Kuma)" }, - /* Phenom II derivates: */ - { 15, 4, -1, 16, -1, 4, -1, -1, NO_CODE , 0, "Phenom (Deneb-based)" }, - { 15, 4, -1, 16, -1, 1, 1024, -1, SEMPRON , 0, "Sempron (Sargas)" }, - { 15, 4, -1, 16, -1, 2, 512, -1, PHENOM2 , 0, "Phenom II X2 (Callisto)" }, - { 15, 4, -1, 16, -1, 3, 512, -1, PHENOM2 , 0, "Phenom II X3 (Heka)" }, - { 15, 4, -1, 16, -1, 4, 512, -1, PHENOM2 , 0, "Phenom II X4" }, - { 15, 4, -1, 16, 4, 4, 512, -1, PHENOM2 , 0, "Phenom II X4 (Deneb)" }, - { 15, 5, -1, 16, 5, 4, 512, -1, PHENOM2 , 0, "Phenom II X4 (Deneb)" }, - { 15, 4, -1, 16, 10, 4, 512, -1, PHENOM2 , 0, "Phenom II X4 (Zosma)" }, - { 15, 4, -1, 16, 10, 6, 512, -1, PHENOM2 , 0, "Phenom II X6 (Thuban)" }, - - { 15, 6, -1, 16, 6, 2, 512, -1, ATHLON , 0, "Athlon II (Champlain)" }, - { 15, 6, -1, 16, 6, 2, 512, -1, ATHLON_64_X2 , 0, "Athlon II X2 (Regor)" }, - { 15, 6, -1, 16, 6, 2, 1024, -1, ATHLON_64_X2 , 0, "Athlon II X2 (Regor)" }, - { 15, 5, -1, 16, 5, 3, 512, -1, ATHLON_64_X3 , 0, "Athlon II X3 (Rana)" }, - { 15, 5, -1, 16, 5, 4, 512, -1, ATHLON_64_X4 , 0, "Athlon II X4 (Propus)" }, - - /* 2011 CPUs: K10 architecture: Llano */ - { 15, 1, -1, 18, 1, 2, 512, -1, FUSION_EA , 0, "Llano X2" }, - { 15, 1, -1, 18, 1, 2, 1024, -1, FUSION_EA , 0, "Llano X2" }, - { 15, 1, -1, 18, 1, 3, 1024, -1, FUSION_EA , 0, "Llano X3" }, - { 15, 1, -1, 18, 1, 4, 1024, -1, FUSION_EA , 0, "Llano X4" }, - /* 2011 CPUs: Bobcat architecture: Ontario, Zacate, Desna, Hondo */ - { 15, 2, -1, 20, -1, 1, 512, -1, FUSION_C , 0, "Brazos Ontario" }, - { 15, 2, -1, 20, -1, 2, 512, -1, FUSION_C , 0, "Brazos Ontario (Dual-core)" }, - { 15, 1, -1, 20, -1, 1, 512, -1, FUSION_E , 0, "Brazos Zacate" }, - { 15, 1, -1, 20, -1, 2, 512, -1, FUSION_E , 0, "Brazos Zacate (Dual-core)" }, - { 15, 2, -1, 20, -1, 2, 512, -1, FUSION_Z , 0, "Brazos Desna (Dual-core)" }, - /* 2012 CPUs: Piledriver architecture: Trinity and Richland */ - { 15, 0, -1, 21, 10, 2, 1024, -1, FUSION_A , 0, "Trinity X2" }, - { 15, 0, -1, 21, 16, 2, 1024, -1, FUSION_A , 0, "Trinity X2" }, - { 15, 0, -1, 21, 10, 4, 1024, -1, FUSION_A , 0, "Trinity X4" }, - { 15, 0, -1, 21, 16, 4, 1024, -1, FUSION_A , 0, "Trinity X4" }, - { 15, 3, -1, 21, 13, 2, 1024, -1, FUSION_A , 0, "Richland X2" }, - { 15, 3, -1, 21, 13, 4, 1024, -1, FUSION_A , 0, "Richland X4" }, - /* 2013 CPUs: Jaguar architecture: Kabini and Temash */ - { 15, 0, -1, 22, 0, 2, 1024, -1, FUSION_A , 0, "Kabini X2" }, - { 15, 0, -1, 22, 0, 4, 1024, -1, FUSION_A , 0, "Kabini X4" }, - /* 2014 CPUs: Steamroller architecture: Kaveri */ - { 15, 0, -1, 21, 30, 2, 1024, -1, FUSION_A , 0, "Kaveri X2" }, - { 15, 0, -1, 21, 30, 4, 1024, -1, FUSION_A , 0, "Kaveri X4" }, - /* 2014 CPUs: Puma architecture: Beema and Mullins */ - { 15, 0, -1, 22, 30, 2, 1024, -1, FUSION_E , 0, "Mullins X2" }, - { 15, 0, -1, 22, 30, 4, 1024, -1, FUSION_A , 0, "Mullins X4" }, - /* 2015 CPUs: Excavator architecture: Carrizo */ - { 15, 1, -1, 21, 60, 2, 1024, -1, FUSION_A , 0, "Carrizo X2" }, - { 15, 1, -1, 21, 60, 4, 1024, -1, FUSION_A , 0, "Carrizo X4" }, - /* 2015 CPUs: Steamroller architecture: Godavari */ - //TODO - /* 2016 CPUs: Excavator architecture: Bristol Ridge */ - //TODO - - /* Newer Opterons: */ - { 15, 9, -1, 22, 9, 8, -1, -1, OPTERON_GENERIC , 0, "Magny-Cours Opteron" }, - - /* Bulldozer CPUs: */ - { 15, -1, -1, 21, 0, 4, 2048, -1, NO_CODE , 0, "Bulldozer X2" }, - { 15, -1, -1, 21, 1, 4, 2048, -1, NO_CODE , 0, "Bulldozer X2" }, - { 15, -1, -1, 21, 1, 6, 2048, -1, NO_CODE , 0, "Bulldozer X3" }, - { 15, -1, -1, 21, 1, 8, 2048, -1, NO_CODE , 0, "Bulldozer X4" }, - /* Piledriver CPUs: */ - { 15, -1, -1, 21, 2, 4, 2048, -1, NO_CODE , 0, "Vishera X2" }, - { 15, -1, -1, 21, 2, 6, 2048, -1, NO_CODE , 0, "Vishera X3" }, - { 15, -1, -1, 21, 2, 8, 2048, -1, NO_CODE , 0, "Vishera X4" }, - /* Steamroller CPUs: */ - //TODO - /* Excavator CPUs: */ - //TODO - /* Zen CPUs: */ - //TODO -}; - - -static void load_amd_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - const struct feature_map_t matchtable_edx81[] = { - { 20, CPU_FEATURE_NX }, - { 22, CPU_FEATURE_MMXEXT }, - { 25, CPU_FEATURE_FXSR_OPT }, - { 30, CPU_FEATURE_3DNOWEXT }, - { 31, CPU_FEATURE_3DNOW }, - }; - const struct feature_map_t matchtable_ecx81[] = { - { 1, CPU_FEATURE_CMP_LEGACY }, - { 2, CPU_FEATURE_SVM }, - { 5, CPU_FEATURE_ABM }, - { 6, CPU_FEATURE_SSE4A }, - { 7, CPU_FEATURE_MISALIGNSSE }, - { 8, CPU_FEATURE_3DNOWPREFETCH }, - { 9, CPU_FEATURE_OSVW }, - { 10, CPU_FEATURE_IBS }, - { 11, CPU_FEATURE_XOP }, - { 12, CPU_FEATURE_SKINIT }, - { 13, CPU_FEATURE_WDT }, - { 16, CPU_FEATURE_FMA4 }, - { 21, CPU_FEATURE_TBM }, - }; - const struct feature_map_t matchtable_edx87[] = { - { 0, CPU_FEATURE_TS }, - { 1, CPU_FEATURE_FID }, - { 2, CPU_FEATURE_VID }, - { 3, CPU_FEATURE_TTP }, - { 4, CPU_FEATURE_TM_AMD }, - { 5, CPU_FEATURE_STC }, - { 6, CPU_FEATURE_100MHZSTEPS }, - { 7, CPU_FEATURE_HWPSTATE }, - /* id 8 is handled in common */ - { 9, CPU_FEATURE_CPB }, - { 10, CPU_FEATURE_APERFMPERF }, - { 11, CPU_FEATURE_PFI }, - { 12, CPU_FEATURE_PA }, - }; - if (raw->ext_cpuid[0][0] >= 0x80000001) { - match_features(matchtable_edx81, COUNT_OF(matchtable_edx81), raw->ext_cpuid[1][3], data); - match_features(matchtable_ecx81, COUNT_OF(matchtable_ecx81), raw->ext_cpuid[1][2], data); - } - if (raw->ext_cpuid[0][0] >= 0x80000007) - match_features(matchtable_edx87, COUNT_OF(matchtable_edx87), raw->ext_cpuid[7][3], data); - if (raw->ext_cpuid[0][0] >= 0x8000001a) { - /* We have the extended info about SSE unit size */ - data->detection_hints[CPU_HINT_SSE_SIZE_AUTH] = 1; - data->sse_size = (raw->ext_cpuid[0x1a][0] & 1) ? 128 : 64; - } -} - -static void decode_amd_cache_info(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - int l3_result; - const int assoc_table[16] = { - 0, 1, 2, 0, 4, 0, 8, 0, 16, 0, 32, 48, 64, 96, 128, 255 - }; - unsigned n = raw->ext_cpuid[0][0]; - - if (n >= 0x80000005) { - data->l1_data_cache = (raw->ext_cpuid[5][2] >> 24) & 0xff; - data->l1_assoc = (raw->ext_cpuid[5][2] >> 16) & 0xff; - data->l1_cacheline = (raw->ext_cpuid[5][2]) & 0xff; - data->l1_instruction_cache = (raw->ext_cpuid[5][3] >> 24) & 0xff; - } - if (n >= 0x80000006) { - data->l2_cache = (raw->ext_cpuid[6][2] >> 16) & 0xffff; - data->l2_assoc = assoc_table[(raw->ext_cpuid[6][2] >> 12) & 0xf]; - data->l2_cacheline = (raw->ext_cpuid[6][2]) & 0xff; - - l3_result = (raw->ext_cpuid[6][3] >> 18); - if (l3_result > 0) { - l3_result = 512 * l3_result; /* AMD spec says it's a range, - but we take the lower bound */ - data->l3_cache = l3_result; - data->l3_assoc = assoc_table[(raw->ext_cpuid[6][3] >> 12) & 0xf]; - data->l3_cacheline = (raw->ext_cpuid[6][3]) & 0xff; - } else { - data->l3_cache = 0; - } - } -} - -static void decode_amd_number_of_cores(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - int logical_cpus = -1, num_cores = -1; - - if (raw->basic_cpuid[0][0] >= 1) { - logical_cpus = (raw->basic_cpuid[1][1] >> 16) & 0xff; - if (raw->ext_cpuid[0][0] >= 8) { - num_cores = 1 + (raw->ext_cpuid[8][2] & 0xff); - } - } - if (data->flags[CPU_FEATURE_HT]) { - if (num_cores > 1) { - data->num_cores = num_cores; - data->num_logical_cpus = logical_cpus; - } else { - data->num_cores = 1; - data->num_logical_cpus = (logical_cpus >= 2 ? logical_cpus : 2); - } - } else { - data->num_cores = data->num_logical_cpus = 1; - } -} - -static int amd_has_turion_modelname(const char *bs) -{ - /* We search for something like TL-60. Ahh, I miss regexes...*/ - int i, l, k; - char code[3] = {0}; - const char* codes[] = { "ML", "MT", "MK", "TK", "TL", "RM", "ZM", "" }; - l = (int) strlen(bs); - for (i = 3; i < l - 2; i++) { - if (bs[i] == '-' && - isupper(bs[i-1]) && isupper(bs[i-2]) && !isupper(bs[i-3]) && - isdigit(bs[i+1]) && isdigit(bs[i+2]) && !isdigit(bs[i+3])) - { - code[0] = bs[i-2]; - code[1] = bs[i-1]; - for (k = 0; codes[k][0]; k++) - if (!strcmp(codes[k], code)) return 1; - } - } - return 0; -} - -static amd_code_t decode_amd_codename_part1(const char *bs) -{ - int is_dual = 0, is_quad = 0, is_tri = 0; - if (strstr(bs, "Dual Core") || - strstr(bs, "Dual-Core") || - strstr(bs, " X2 ")) - is_dual = 1; - if (strstr(bs, " X4 ")) is_quad = 1; - if (strstr(bs, " X3 ")) is_tri = 1; - if (strstr(bs, "Opteron")) { - return is_dual ? OPTERON_DUALCORE : OPTERON_SINGLE; - } - if (strstr(bs, "Phenom")) { - if (strstr(bs, "II")) return PHENOM2; - else return PHENOM; - } - if (amd_has_turion_modelname(bs)) { - return is_dual ? TURION_X2 : TURION_64; - } - if (strstr(bs, "Athlon(tm) 64 FX")) return ATHLON_64_FX; - if (strstr(bs, "Athlon(tm) FX")) return ATHLON_FX; - if (strstr(bs, "Athlon(tm) 64") || strstr(bs, "Athlon(tm) II X") || match_pattern(bs, "Athlon(tm) X#")) { - if (is_quad) return ATHLON_64_X4; - if (is_dual) return ATHLON_64_X2; - if (is_tri) return ATHLON_64_X3; - return ATHLON_64; - } - if (strstr(bs, "Turion")) { - return is_dual ? TURION_X2 : TURION_64; - } - - if (strstr(bs, "mobile") || strstr(bs, "Mobile")) { - if (strstr(bs, "Athlon(tm) XP-M (LV)")) return ATHLON_XP_M_LV; - if (strstr(bs, "Athlon(tm) XP")) return ATHLON_XP_M; - if (strstr(bs, "Sempron(tm)")) return M_SEMPRON; - if (strstr(bs, "Athlon")) return MOBILE_ATHLON64; - if (strstr(bs, "Duron")) return MOBILE_DURON; - - } else { - if (strstr(bs, "Athlon(tm) XP")) return ATHLON_XP; - if (strstr(bs, "Athlon(tm) MP")) return ATHLON_MP; - if (strstr(bs, "Sempron(tm)")) return SEMPRON; - if (strstr(bs, "Duron")) return DURON; - if (strstr(bs, "Athlon")) return ATHLON; - } - if (match_pattern(bs, "C-##")) return FUSION_C; - if (match_pattern(bs, "E-###")) return FUSION_E; - if (match_pattern(bs, "Z-##")) return FUSION_Z; - if (match_pattern(bs, "E#-####") || match_pattern(bs, "A#-####")) return FUSION_EA; - - return (amd_code_t) NO_CODE; -} - -static void decode_amd_codename(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal) -{ - amd_code_t code = decode_amd_codename_part1(data->brand_str); - int i = 0; - char* code_str = NULL; - for (i = 0; i < COUNT_OF(amd_code_str); i++) { - if (code == amd_code_str[i].code) { - code_str = amd_code_str[i].str; - break; - } - } - if (code == ATHLON_64_X2 && data->l2_cache < 512) - code = SEMPRON_DUALCORE; - if (code_str) - debugf(2, "Detected AMD brand code: %d (%s)\n", code, code_str); - else - debugf(2, "Detected AMD brand code: %d\n", code); - internal->code.amd = code; - internal->score = match_cpu_codename(cpudb_amd, COUNT_OF(cpudb_amd), data, code, 0); -} - -int cpuid_identify_amd(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal) -{ - load_amd_features(raw, data); - decode_amd_cache_info(raw, data); - decode_amd_number_of_cores(raw, data); - decode_amd_codename(raw, data, internal); - return 0; -} - -void cpuid_get_list_amd(struct cpu_list_t* list) -{ - generic_get_cpu_list(cpudb_amd, COUNT_OF(cpudb_amd), list); -} diff --git a/contrib/libcpuid/include/libcpuid/recog_amd.h b/contrib/libcpuid/include/libcpuid/recog_amd.h deleted file mode 100644 index 34e89598397..00000000000 --- a/contrib/libcpuid/include/libcpuid/recog_amd.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __RECOG_AMD_H__ -#define __RECOG_AMD_H__ - -int cpuid_identify_amd(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal); -void cpuid_get_list_amd(struct cpu_list_t* list); - -#endif /* __RECOG_AMD_H__ */ diff --git a/contrib/libcpuid/include/libcpuid/recog_intel.c b/contrib/libcpuid/include/libcpuid/recog_intel.c deleted file mode 100644 index 2ffc41c8a15..00000000000 --- a/contrib/libcpuid/include/libcpuid/recog_intel.c +++ /dev/null @@ -1,897 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include "libcpuid.h" -#include "libcpuid_util.h" -#include "libcpuid_internal.h" -#include "recog_intel.h" - -const struct intel_bcode_str { intel_code_t code; char *str; } intel_bcode_str[] = { - #define CODE(x) { x, #x } - #define CODE2(x, y) CODE(x) - #include "intel_code_t.h" - #undef CODE -}; - -enum _intel_model_t { - UNKNOWN = -1, - _3000 = 100, - _3100, - _3200, - X3200, - _3300, - X3300, - _5100, - _5200, - _5300, - _5400, - _2xxx, /* Core i[357] 2xxx */ - _3xxx, /* Core i[357] 3xxx */ -}; -typedef enum _intel_model_t intel_model_t; - -const struct match_entry_t cpudb_intel[] = { - { -1, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Intel CPU" }, - - /* i486 */ - { 4, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown i486" }, - { 4, 0, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 DX-25/33" }, - { 4, 1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 DX-50" }, - { 4, 2, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 SX" }, - { 4, 3, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 DX2" }, - { 4, 4, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 SL" }, - { 4, 5, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 SX2" }, - { 4, 7, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 DX2 WriteBack" }, - { 4, 8, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 DX4" }, - { 4, 9, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "i486 DX4 WriteBack" }, - - /* All Pentia: - Pentium 1 */ - { 5, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Pentium" }, - { 5, 0, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium A-Step" }, - { 5, 1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium 1 (0.8u)" }, - { 5, 2, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium 1 (0.35u)" }, - { 5, 3, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium OverDrive" }, - { 5, 4, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium 1 (0.35u)" }, - { 5, 7, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium 1 (0.35u)" }, - { 5, 8, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium MMX (0.25u)" }, - - /* Pentium 2 / 3 / M / Conroe / whatsnext - all P6 based. */ - { 6, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown P6" }, - { 6, 0, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium Pro" }, - { 6, 1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium Pro" }, - { 6, 3, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium II (Klamath)" }, - { 6, 5, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium II (Deschutes)" }, - { 6, 5, -1, -1, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile Pentium II (Tonga)"}, - { 6, 6, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium II (Dixon)" }, - - { 6, 3, -1, -1, -1, 1, -1, -1, XEON , 0, "P-II Xeon (Klamath)" }, - { 6, 5, -1, -1, -1, 1, -1, -1, XEON , 0, "P-II Xeon (Drake)" }, - { 6, 6, -1, -1, -1, 1, -1, -1, XEON , 0, "P-II Xeon (Dixon)" }, - - { 6, 5, -1, -1, -1, 1, -1, -1, CELERON , 0, "P-II Celeron (Covingtons" }, - { 6, 6, -1, -1, -1, 1, -1, -1, CELERON , 0, "P-II Celeron (Mendocino)" }, - - /* -------------------------------------------------- */ - - { 6, 7, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium III (Katmai)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium III (Coppermine)"}, - { 6, 10, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium III (Coppermine)"}, - { 6, 11, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Pentium III (Tualatin)" }, - - { 6, 7, -1, -1, -1, 1, -1, -1, XEON , 0, "P-III Xeon (Tanner)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, XEON , 0, "P-III Xeon (Cascades)" }, - { 6, 10, -1, -1, -1, 1, -1, -1, XEON , 0, "P-III Xeon (Cascades)" }, - { 6, 11, -1, -1, -1, 1, -1, -1, XEON , 0, "P-III Xeon (Tualatin)" }, - - { 6, 7, -1, -1, -1, 1, -1, -1, CELERON , 0, "P-III Celeron (Katmai)" }, - { 6, 8, -1, -1, -1, 1, -1, -1, CELERON , 0, "P-III Celeron (Coppermine)" }, - { 6, 10, -1, -1, -1, 1, -1, -1, CELERON , 0, "P-III Celeron (Coppermine)" }, - { 6, 11, -1, -1, -1, 1, -1, -1, CELERON , 0, "P-III Celeron (Tualatin)" }, - - /* Netburst based (Pentium 4 and later) - classic P4s */ - { 15, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Pentium 4" }, - { 15, -1, -1, 15, -1, 1, -1, -1, CELERON , 0, "Unknown P-4 Celeron" }, - { 15, -1, -1, 15, -1, 1, -1, -1, XEON , 0, "Unknown Xeon" }, - - { 15, 0, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium 4 (Willamette)" }, - { 15, 1, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium 4 (Willamette)" }, - { 15, 2, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium 4 (Northwood)" }, - { 15, 3, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium 4 (Prescott)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium 4 (Prescott)" }, - { 15, 6, -1, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium 4 (Cedar Mill)" }, - { 15, 0, -1, 15, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile P-4 (Willamette)" }, - { 15, 1, -1, 15, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile P-4 (Willamette)" }, - { 15, 2, -1, 15, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile P-4 (Northwood)" }, - { 15, 3, -1, 15, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile P-4 (Prescott)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile P-4 (Prescott)" }, - { 15, 6, -1, 15, -1, 1, -1, -1, MOBILE_PENTIUM , 0, "Mobile P-4 (Cedar Mill)" }, - - /* server CPUs */ - { 15, 0, -1, 15, -1, 1, -1, -1, XEON , 0, "Xeon (Foster)" }, - { 15, 1, -1, 15, -1, 1, -1, -1, XEON , 0, "Xeon (Foster)" }, - { 15, 2, -1, 15, -1, 1, -1, -1, XEON , 0, "Xeon (Prestonia)" }, - { 15, 2, -1, 15, -1, 1, -1, -1, XEONMP , 0, "Xeon (Gallatin)" }, - { 15, 3, -1, 15, -1, 1, -1, -1, XEON , 0, "Xeon (Nocona)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, XEON , 0, "Xeon (Nocona)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, XEON_IRWIN , 0, "Xeon (Irwindale)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, XEONMP , 0, "Xeon (Cranford)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, XEON_POTOMAC , 0, "Xeon (Potomac)" }, - { 15, 6, -1, 15, -1, 1, -1, -1, XEON , 0, "Xeon (Dempsey)" }, - - /* Pentium Ds */ - { 15, 4, 4, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium D (SmithField)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, PENTIUM_D , 0, "Pentium D (SmithField)" }, - { 15, 4, 7, 15, -1, 1, -1, -1, NO_CODE , 0, "Pentium D (SmithField)" }, - { 15, 6, -1, 15, -1, 1, -1, -1, PENTIUM_D , 0, "Pentium D (Presler)" }, - - /* Celeron and Celeron Ds */ - { 15, 1, -1, 15, -1, 1, -1, -1, CELERON , 0, "P-4 Celeron (Willamette)" }, - { 15, 2, -1, 15, -1, 1, -1, -1, CELERON , 0, "P-4 Celeron (Northwood)" }, - { 15, 3, -1, 15, -1, 1, -1, -1, CELERON , 0, "P-4 Celeron D (Prescott)" }, - { 15, 4, -1, 15, -1, 1, -1, -1, CELERON , 0, "P-4 Celeron D (Prescott)" }, - { 15, 6, -1, 15, -1, 1, -1, -1, CELERON , 0, "P-4 Celeron D (Cedar Mill)" }, - - /* -------------------------------------------------- */ - /* Intel Core microarchitecture - P6-based */ - - { 6, 9, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Pentium M" }, - { 6, 9, -1, -1, -1, 1, -1, -1, MOBILE_PENTIUM_M , 0, "Unknown Pentium M" }, - { 6, 9, -1, -1, -1, 1, -1, -1, PENTIUM , 0, "Pentium M (Banias)" }, - { 6, 9, -1, -1, -1, 1, -1, -1, MOBILE_PENTIUM_M , 0, "Pentium M (Banias)" }, - { 6, 9, -1, -1, -1, 1, -1, -1, CELERON , 0, "Celeron M" }, - { 6, 13, -1, -1, -1, 1, -1, -1, PENTIUM , 0, "Pentium M (Dothan)" }, - { 6, 13, -1, -1, -1, 1, -1, -1, MOBILE_PENTIUM_M , 0, "Pentium M (Dothan)" }, - { 6, 13, -1, -1, -1, 1, -1, -1, CELERON , 0, "Celeron M" }, - - { 6, 12, -1, -1, -1, -1, -1, -1, ATOM_UNKNOWN , 0, "Unknown Atom" }, - { 6, 12, -1, -1, -1, -1, -1, -1, ATOM_DIAMONDVILLE , 0, "Atom (Diamondville)" }, - { 6, 12, -1, -1, -1, -1, -1, -1, ATOM_SILVERTHORNE , 0, "Atom (Silverthorne)" }, - { 6, 12, -1, -1, -1, -1, -1, -1, ATOM_CEDARVIEW , 0, "Atom (Cedarview)" }, - { 6, 6, -1, -1, -1, -1, -1, -1, ATOM_CEDARVIEW , 0, "Atom (Cedarview)" }, - { 6, 12, -1, -1, -1, -1, -1, -1, ATOM_PINEVIEW , 0, "Atom (Pineview)" }, - - /* -------------------------------------------------- */ - - { 6, 14, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Yonah" }, - { 6, 14, -1, -1, -1, 1, -1, -1, CORE_SOLO , 0, "Yonah (Core Solo)" }, - { 6, 14, -1, -1, -1, 2, -1, -1, CORE_DUO , 0, "Yonah (Core Duo)" }, - { 6, 14, -1, -1, -1, 1, -1, -1, MOBILE_CORE_SOLO , 0, "Yonah (Core Solo)" }, - { 6, 14, -1, -1, -1, 2, -1, -1, MOBILE_CORE_DUO , 0, "Yonah (Core Duo)" }, - { 6, 14, -1, -1, -1, 1, -1, -1, CORE_SOLO , 0, "Yonah (Core Solo)" }, - - { 6, 15, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Unknown Core 2" }, - { 6, 15, -1, -1, -1, 2, 4096, -1, CORE_DUO , 0, "Conroe (Core 2 Duo)" }, - { 6, 15, -1, -1, -1, 2, 1024, -1, CORE_DUO , 0, "Conroe (Core 2 Duo) 1024K" }, - { 6, 15, -1, -1, -1, 2, 512, -1, CORE_DUO , 0, "Conroe (Core 2 Duo) 512K" }, - { 6, 15, -1, -1, -1, 4, -1, -1, QUAD_CORE , 0, "Kentsfield (Core 2 Quad)" }, - { 6, 15, -1, -1, -1, 4, 4096, -1, QUAD_CORE , 0, "Kentsfield (Core 2 Quad)" }, - { 6, 15, -1, -1, -1, 400, -1, -1, MORE_THAN_QUADCORE, 0, "More than quad-core" }, - { 6, 15, -1, -1, -1, 2, 2048, -1, CORE_DUO , 0, "Allendale (Core 2 Duo)" }, - { 6, 15, -1, -1, -1, 2, -1, -1, MOBILE_CORE_DUO , 0, "Merom (Core 2 Duo)" }, - { 6, 15, -1, -1, -1, 2, 2048, -1, MEROM , 0, "Merom (Core 2 Duo) 2048K" }, - { 6, 15, -1, -1, -1, 2, 4096, -1, MEROM , 0, "Merom (Core 2 Duo) 4096K" }, - - { 6, 15, -1, -1, 15, 1, -1, -1, CELERON , 0, "Conroe-L (Celeron)" }, - { 6, 6, -1, -1, 22, 1, -1, -1, CELERON , 0, "Conroe-L (Celeron)" }, - { 6, 15, -1, -1, 15, 2, -1, -1, CELERON , 0, "Conroe-L (Allendale)" }, - { 6, 6, -1, -1, 22, 2, -1, -1, CELERON , 0, "Conroe-L (Allendale)" }, - - - { 6, 6, -1, -1, 22, 1, -1, -1, NO_CODE , 0, "Unknown Core ?" }, - { 6, 7, -1, -1, 23, 1, -1, -1, NO_CODE , 0, "Unknown Core ?" }, - { 6, 6, -1, -1, 22, 400, -1, -1, MORE_THAN_QUADCORE, 0, "More than quad-core" }, - { 6, 7, -1, -1, 23, 400, -1, -1, MORE_THAN_QUADCORE, 0, "More than quad-core" }, - - { 6, 7, -1, -1, 23, 1, -1, -1, CORE_SOLO , 0, "Unknown Core 45nm" }, - { 6, 7, -1, -1, 23, 1, -1, -1, CORE_DUO , 0, "Unknown Core 45nm" }, - { 6, 7, -1, -1, 23, 2, 1024, -1, WOLFDALE , 0, "Celeron Wolfdale 1M" }, - { 6, 7, -1, -1, 23, 2, 2048, -1, WOLFDALE , 0, "Wolfdale (Core 2 Duo) 2M" }, - { 6, 7, -1, -1, 23, 2, 3072, -1, WOLFDALE , 0, "Wolfdale (Core 2 Duo) 3M" }, - { 6, 7, -1, -1, 23, 2, 6144, -1, WOLFDALE , 0, "Wolfdale (Core 2 Duo) 6M" }, - { 6, 7, -1, -1, 23, 1, -1, -1, MOBILE_CORE_DUO , 0, "Penryn (Core 2 Duo)" }, - { 6, 7, -1, -1, 23, 2, 1024, -1, PENRYN , 0, "Penryn (Core 2 Duo)" }, - { 6, 7, -1, -1, 23, 2, 3072, -1, PENRYN , 0, "Penryn (Core 2 Duo) 3M" }, - { 6, 7, -1, -1, 23, 2, 6144, -1, PENRYN , 0, "Penryn (Core 2 Duo) 6M" }, - { 6, 7, -1, -1, 23, 4, 2048, -1, QUAD_CORE , 0, "Yorkfield (Core 2 Quad) 2M"}, - { 6, 7, -1, -1, 23, 4, 3072, -1, QUAD_CORE , 0, "Yorkfield (Core 2 Quad) 3M"}, - { 6, 7, -1, -1, 23, 4, 6144, -1, QUAD_CORE , 0, "Yorkfield (Core 2 Quad) 6M"}, - - /* Core microarchitecture-based Xeons: */ - { 6, 14, -1, -1, 14, 1, -1, -1, XEON , 0, "Xeon LV" }, - { 6, 15, -1, -1, 15, 2, 4096, -1, XEON , _5100, "Xeon (Woodcrest)" }, - { 6, 15, -1, -1, 15, 2, 2048, -1, XEON , _3000, "Xeon (Conroe/2M)" }, - { 6, 15, -1, -1, 15, 2, 4096, -1, XEON , _3000, "Xeon (Conroe/4M)" }, - { 6, 15, -1, -1, 15, 4, 4096, -1, XEON , X3200, "Xeon (Kentsfield)" }, - { 6, 15, -1, -1, 15, 4, 4096, -1, XEON , _5300, "Xeon (Clovertown)" }, - { 6, 7, -1, -1, 23, 2, 6144, -1, XEON , _3100, "Xeon (Wolfdale)" }, - { 6, 7, -1, -1, 23, 2, 6144, -1, XEON , _5200, "Xeon (Wolfdale DP)" }, - { 6, 7, -1, -1, 23, 4, 6144, -1, XEON , _5400, "Xeon (Harpertown)" }, - { 6, 7, -1, -1, 23, 4, 3072, -1, XEON , X3300, "Xeon (Yorkfield/3M)" }, - { 6, 7, -1, -1, 23, 4, 6144, -1, XEON , X3300, "Xeon (Yorkfield/6M)" }, - - /* Nehalem CPUs (45nm): */ - { 6, 10, -1, -1, 26, 4, -1, -1, XEON_GAINESTOWN , 0, "Gainestown (Xeon)" }, - { 6, 10, -1, -1, 26, 4, -1, 4096, XEON_GAINESTOWN , 0, "Gainestown 4M (Xeon)" }, - { 6, 10, -1, -1, 26, 4, -1, 8192, XEON_GAINESTOWN , 0, "Gainestown 8M (Xeon)" }, - { 6, 10, -1, -1, 26, 4, -1, -1, XEON_I7 , 0, "Bloomfield (Xeon)" }, - { 6, 10, -1, -1, 26, 4, -1, -1, CORE_I7 , 0, "Bloomfield (Core i7)" }, - { 6, 10, -1, -1, 30, 4, -1, -1, CORE_I7 , 0, "Lynnfield (Core i7)" }, - { 6, 5, -1, -1, 37, 4, -1, 8192, CORE_I5 , 0, "Lynnfield (Core i5)" }, - - /* Westmere CPUs (32nm): */ - { 6, 5, -1, -1, 37, 2, -1, -1, NO_CODE , 0, "Unknown Core i3/i5" }, - { 6, 12, -1, -1, 44, -1, -1, -1, XEON_WESTMERE , 0, "Westmere (Xeon)" }, - { 6, 12, -1, -1, 44, -1, -1, 12288, XEON_WESTMERE , 0, "Gulftown (Xeon)" }, - { 6, 12, -1, -1, 44, 4, -1, 12288, CORE_I7 , 0, "Gulftown (Core i7)" }, - { 6, 5, -1, -1, 37, 2, -1, 4096, CORE_I5 , 0, "Clarkdale (Core i5)" }, - { 6, 5, -1, -1, 37, 2, -1, 4096, CORE_I3 , 0, "Clarkdale (Core i3)" }, - { 6, 5, -1, -1, 37, 2, -1, -1, PENTIUM , 0, "Arrandale" }, - { 6, 5, -1, -1, 37, 2, -1, 4096, CORE_I7 , 0, "Arrandale (Core i7)" }, - { 6, 5, -1, -1, 37, 2, -1, 3072, CORE_I5 , 0, "Arrandale (Core i5)" }, - { 6, 5, -1, -1, 37, 2, -1, 3072, CORE_I3 , 0, "Arrandale (Core i3)" }, - - /* Sandy Bridge CPUs (32nm): */ - { 6, 10, -1, -1, 42, -1, -1, -1, NO_CODE , 0, "Unknown Sandy Bridge" }, - { 6, 10, -1, -1, 42, -1, -1, -1, XEON , 0, "Sandy Bridge (Xeon)" }, - { 6, 10, -1, -1, 42, -1, -1, -1, CORE_I7 , 0, "Sandy Bridge (Core i7)" }, - { 6, 10, -1, -1, 42, 4, -1, -1, CORE_I7 , 0, "Sandy Bridge (Core i7)" }, - { 6, 10, -1, -1, 42, 4, -1, -1, CORE_I5 , 0, "Sandy Bridge (Core i5)" }, - { 6, 10, -1, -1, 42, 2, -1, -1, CORE_I3 , 0, "Sandy Bridge (Core i3)" }, - { 6, 10, -1, -1, 42, 2, -1, -1, PENTIUM , 0, "Sandy Bridge (Pentium)" }, - { 6, 10, -1, -1, 42, 1, -1, -1, CELERON , 0, "Sandy Bridge (Celeron)" }, - { 6, 10, -1, -1, 42, 2, -1, -1, CELERON , 0, "Sandy Bridge (Celeron)" }, - { 6, 13, -1, -1, 45, -1, -1, -1, NO_CODE , 0, "Sandy Bridge-E" }, - { 6, 13, -1, -1, 45, -1, -1, -1, XEON , 0, "Sandy Bridge-E (Xeon)" }, - - /* Ivy Bridge CPUs (22nm): */ - { 6, 10, -1, -1, 58, -1, -1, -1, XEON , 0, "Ivy Bridge (Xeon)" }, - { 6, 10, -1, -1, 58, 4, -1, -1, CORE_IVY7 , 0, "Ivy Bridge (Core i7)" }, - { 6, 10, -1, -1, 58, 4, -1, -1, CORE_IVY5 , 0, "Ivy Bridge (Core i5)" }, - { 6, 10, -1, -1, 58, 2, -1, -1, CORE_IVY3 , 0, "Ivy Bridge (Core i3)" }, - { 6, 10, -1, -1, 58, 2, -1, -1, PENTIUM , 0, "Ivy Bridge (Pentium)" }, - { 6, 10, -1, -1, 58, 1, -1, -1, CELERON , 0, "Ivy Bridge (Celeron)" }, - { 6, 10, -1, -1, 58, 2, -1, -1, CELERON , 0, "Ivy Bridge (Celeron)" }, - { 6, 14, -1, -1, 62, -1, -1, -1, NO_CODE , 0, "Ivy Bridge-E" }, - - /* Haswell CPUs (22nm): */ - { 6, 12, -1, -1, 60, -1, -1, -1, XEON , 0, "Haswell (Xeon)" }, - { 6, 12, -1, -1, 60, 4, -1, -1, CORE_HASWELL7 , 0, "Haswell (Core i7)" }, - { 6, 5, -1, -1, 69, 4, -1, -1, CORE_HASWELL7 , 0, "Haswell (Core i7)" }, - { 6, 12, -1, -1, 60, 4, -1, -1, CORE_HASWELL5 , 0, "Haswell (Core i5)" }, - { 6, 5, -1, -1, 69, 4, -1, -1, CORE_HASWELL5 , 0, "Haswell (Core i5)" }, - { 6, 12, -1, -1, 60, 2, -1, -1, CORE_HASWELL3 , 0, "Haswell (Core i3)" }, - { 6, 5, -1, -1, 69, 2, -1, -1, CORE_HASWELL3 , 0, "Haswell (Core i3)" }, - { 6, 12, -1, -1, 60, 2, -1, -1, PENTIUM , 0, "Haswell (Pentium)" }, - { 6, 12, -1, -1, 60, 2, -1, -1, CELERON , 0, "Haswell (Celeron)" }, - { 6, 12, -1, -1, 60, 1, -1, -1, CELERON , 0, "Haswell (Celeron)" }, - { 6, 15, -1, -1, 63, -1, -1, -1, NO_CODE , 0, "Haswell-E" }, - - /* Broadwell CPUs (14nm): */ - { 6, 7, -1, -1, 71, 4, -1, -1, CORE_BROADWELL7 , 0, "Broadwell (Core i7)" }, - { 6, 7, -1, -1, 71, 4, -1, -1, CORE_BROADWELL5 , 0, "Broadwell (Core i5)" }, - { 6, 13, -1, -1, 61, 4, -1, -1, CORE_BROADWELL7 , 0, "Broadwell-U (Core i7)" }, - { 6, 13, -1, -1, 61, 2, -1, -1, CORE_BROADWELL7 , 0, "Broadwell-U (Core i7)" }, - { 6, 13, -1, -1, 61, 2, -1, -1, CORE_BROADWELL5 , 0, "Broadwell-U (Core i5)" }, - { 6, 13, -1, -1, 61, 2, -1, -1, CORE_BROADWELL3 , 0, "Broadwell-U (Core i3)" }, - { 6, 13, -1, -1, 61, 2, -1, -1, PENTIUM , 0, "Broadwell-U (Pentium)" }, - { 6, 13, -1, -1, 61, 2, -1, -1, CELERON , 0, "Broadwell-U (Celeron)" }, - { 6, 13, -1, -1, 61, 2, -1, -1, NA , 0, "Broadwell-U (Core M)" }, - { 6, 15, -1, -1, 79, 2, -1, -1, CORE_BROADWELL3 , 0, "Broadwell-E (Core i3)" }, - { 6, 15, -1, -1, 79, 2, -1, -1, CORE_BROADWELL5 , 0, "Broadwell-E (Core i5)" }, - { 6, 15, -1, -1, 79, 4, -1, -1, CORE_BROADWELL5 , 0, "Broadwell-E (Core i5)" }, - { 6, 15, -1, -1, 79, 2, -1, -1, CORE_BROADWELL7 , 0, "Broadwell-E (Core i7)" }, - { 6, 15, -1, -1, 79, 4, -1, -1, CORE_BROADWELL7 , 0, "Broadwell-E (Core i7)" }, - - /* Skylake CPUs (14nm): */ - { 6, 14, -1, -1, 94, 4, -1, -1, CORE_BROADWELL7 , 0, "Skylake (Core i7)" }, - { 6, 14, -1, -1, 94, 4, -1, -1, CORE_BROADWELL5 , 0, "Skylake (Core i5)" }, - { 6, 14, -1, -1, 94, 4, -1, -1, CORE_BROADWELL3 , 0, "Skylake (Core i3)" }, - { 6, 14, -1, -1, 94, 4, -1, -1, PENTIUM , 0, "Skylake (Pentium)" }, - - /* Itaniums */ - { 7, -1, -1, -1, -1, 1, -1, -1, NO_CODE , 0, "Itanium" }, - { 15, -1, -1, 16, -1, 1, -1, -1, NO_CODE , 0, "Itanium 2" }, - -}; - - -static void load_intel_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - const struct feature_map_t matchtable_edx1[] = { - { 18, CPU_FEATURE_PN }, - { 21, CPU_FEATURE_DTS }, - { 22, CPU_FEATURE_ACPI }, - { 27, CPU_FEATURE_SS }, - { 29, CPU_FEATURE_TM }, - { 30, CPU_FEATURE_IA64 }, - { 31, CPU_FEATURE_PBE }, - }; - const struct feature_map_t matchtable_ecx1[] = { - { 2, CPU_FEATURE_DTS64 }, - { 4, CPU_FEATURE_DS_CPL }, - { 5, CPU_FEATURE_VMX }, - { 6, CPU_FEATURE_SMX }, - { 7, CPU_FEATURE_EST }, - { 8, CPU_FEATURE_TM2 }, - { 10, CPU_FEATURE_CID }, - { 14, CPU_FEATURE_XTPR }, - { 15, CPU_FEATURE_PDCM }, - { 18, CPU_FEATURE_DCA }, - { 21, CPU_FEATURE_X2APIC }, - }; - const struct feature_map_t matchtable_edx81[] = { - { 20, CPU_FEATURE_XD }, - }; - const struct feature_map_t matchtable_ebx7[] = { - { 2, CPU_FEATURE_SGX }, - { 4, CPU_FEATURE_HLE }, - { 11, CPU_FEATURE_RTM }, - { 16, CPU_FEATURE_AVX512F }, - { 17, CPU_FEATURE_AVX512DQ }, - { 18, CPU_FEATURE_RDSEED }, - { 19, CPU_FEATURE_ADX }, - { 26, CPU_FEATURE_AVX512PF }, - { 27, CPU_FEATURE_AVX512ER }, - { 28, CPU_FEATURE_AVX512CD }, - { 29, CPU_FEATURE_SHA_NI }, - { 30, CPU_FEATURE_AVX512BW }, - { 31, CPU_FEATURE_AVX512VL }, - }; - if (raw->basic_cpuid[0][0] >= 1) { - match_features(matchtable_edx1, COUNT_OF(matchtable_edx1), raw->basic_cpuid[1][3], data); - match_features(matchtable_ecx1, COUNT_OF(matchtable_ecx1), raw->basic_cpuid[1][2], data); - } - if (raw->ext_cpuid[0][0] >= 1) { - match_features(matchtable_edx81, COUNT_OF(matchtable_edx81), raw->ext_cpuid[1][3], data); - } - // detect TSX/AVX512: - if (raw->basic_cpuid[0][0] >= 7) { - match_features(matchtable_ebx7, COUNT_OF(matchtable_ebx7), raw->basic_cpuid[7][1], data); - } -} - -enum _cache_type_t { - L1I, - L1D, - L2, - L3, - L4 -}; -typedef enum _cache_type_t cache_type_t; - -static void check_case(uint8_t on, cache_type_t cache, int size, int assoc, int linesize, struct cpu_id_t* data) -{ - if (!on) return; - switch (cache) { - case L1I: - data->l1_instruction_cache = size; - break; - case L1D: - data->l1_data_cache = size; - data->l1_assoc = assoc; - data->l1_cacheline = linesize; - break; - case L2: - data->l2_cache = size; - data->l2_assoc = assoc; - data->l2_cacheline = linesize; - break; - case L3: - data->l3_cache = size; - data->l3_assoc = assoc; - data->l3_cacheline = linesize; - break; - case L4: - data->l4_cache = size; - data->l4_assoc = assoc; - data->l4_cacheline = linesize; - break; - default: - break; - } -} - -static void decode_intel_oldstyle_cache_info(struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - uint8_t f[256] = {0}; - int reg, off; - uint32_t x; - for (reg = 0; reg < 4; reg++) { - x = raw->basic_cpuid[2][reg]; - if (x & 0x80000000) continue; - for (off = 0; off < 4; off++) { - f[x & 0xff] = 1; - x >>= 8; - } - } - - check_case(f[0x06], L1I, 8, 4, 32, data); - check_case(f[0x08], L1I, 16, 4, 32, data); - check_case(f[0x0A], L1D, 8, 2, 32, data); - check_case(f[0x0C], L1D, 16, 4, 32, data); - check_case(f[0x22], L3, 512, 4, 64, data); - check_case(f[0x23], L3, 1024, 8, 64, data); - check_case(f[0x25], L3, 2048, 8, 64, data); - check_case(f[0x29], L3, 4096, 8, 64, data); - check_case(f[0x2C], L1D, 32, 8, 64, data); - check_case(f[0x30], L1I, 32, 8, 64, data); - check_case(f[0x39], L2, 128, 4, 64, data); - check_case(f[0x3A], L2, 192, 6, 64, data); - check_case(f[0x3B], L2, 128, 2, 64, data); - check_case(f[0x3C], L2, 256, 4, 64, data); - check_case(f[0x3D], L2, 384, 6, 64, data); - check_case(f[0x3E], L2, 512, 4, 64, data); - check_case(f[0x41], L2, 128, 4, 32, data); - check_case(f[0x42], L2, 256, 4, 32, data); - check_case(f[0x43], L2, 512, 4, 32, data); - check_case(f[0x44], L2, 1024, 4, 32, data); - check_case(f[0x45], L2, 2048, 4, 32, data); - check_case(f[0x46], L3, 4096, 4, 64, data); - check_case(f[0x47], L3, 8192, 8, 64, data); - check_case(f[0x4A], L3, 6144, 12, 64, data); - check_case(f[0x4B], L3, 8192, 16, 64, data); - check_case(f[0x4C], L3, 12288, 12, 64, data); - check_case(f[0x4D], L3, 16384, 16, 64, data); - check_case(f[0x4E], L2, 6144, 24, 64, data); - check_case(f[0x60], L1D, 16, 8, 64, data); - check_case(f[0x66], L1D, 8, 4, 64, data); - check_case(f[0x67], L1D, 16, 4, 64, data); - check_case(f[0x68], L1D, 32, 4, 64, data); - /* The following four entries are trace cache. Intel does not - * specify a cache-line size, so we use -1 instead - */ - check_case(f[0x70], L1I, 12, 8, -1, data); - check_case(f[0x71], L1I, 16, 8, -1, data); - check_case(f[0x72], L1I, 32, 8, -1, data); - check_case(f[0x73], L1I, 64, 8, -1, data); - - check_case(f[0x78], L2, 1024, 4, 64, data); - check_case(f[0x79], L2, 128, 8, 64, data); - check_case(f[0x7A], L2, 256, 8, 64, data); - check_case(f[0x7B], L2, 512, 8, 64, data); - check_case(f[0x7C], L2, 1024, 8, 64, data); - check_case(f[0x7D], L2, 2048, 8, 64, data); - check_case(f[0x7F], L2, 512, 2, 64, data); - check_case(f[0x82], L2, 256, 8, 32, data); - check_case(f[0x83], L2, 512, 8, 32, data); - check_case(f[0x84], L2, 1024, 8, 32, data); - check_case(f[0x85], L2, 2048, 8, 32, data); - check_case(f[0x86], L2, 512, 4, 64, data); - check_case(f[0x87], L2, 1024, 8, 64, data); - - if (f[0x49]) { - /* This flag is overloaded with two meanings. On Xeon MP - * (family 0xf, model 0x6) this means L3 cache. On all other - * CPUs (notably Conroe et al), this is L2 cache. In both cases - * it means 4MB, 16-way associative, 64-byte line size. - */ - if (data->family == 0xf && data->model == 0x6) { - data->l3_cache = 4096; - data->l3_assoc = 16; - data->l3_cacheline = 64; - } else { - data->l2_cache = 4096; - data->l2_assoc = 16; - data->l2_cacheline = 64; - } - } - if (f[0x40]) { - /* Again, a special flag. It means: - * 1) If no L2 is specified, then CPU is w/o L2 (0 KB) - * 2) If L2 is specified by other flags, then, CPU is w/o L3. - */ - if (data->l2_cache == -1) { - data->l2_cache = 0; - } else { - data->l3_cache = 0; - } - } -} - -static void decode_intel_deterministic_cache_info(struct cpu_raw_data_t* raw, - struct cpu_id_t* data) -{ - int ecx; - int ways, partitions, linesize, sets, size, level, typenumber; - cache_type_t type; - for (ecx = 0; ecx < MAX_INTELFN4_LEVEL; ecx++) { - typenumber = raw->intel_fn4[ecx][0] & 0x1f; - if (typenumber == 0) break; - level = (raw->intel_fn4[ecx][0] >> 5) & 0x7; - if (level == 1 && typenumber == 1) - type = L1D; - else if (level == 1 && typenumber == 2) - type = L1I; - else if (level == 2 && typenumber == 3) - type = L2; - else if (level == 3 && typenumber == 3) - type = L3; - else if (level == 4 && typenumber == 3) - type = L4; - else { - warnf("deterministic_cache: unknown level/typenumber combo (%d/%d), cannot\n", level, typenumber); - warnf("deterministic_cache: recognize cache type\n"); - continue; - } - ways = ((raw->intel_fn4[ecx][1] >> 22) & 0x3ff) + 1; - partitions = ((raw->intel_fn4[ecx][1] >> 12) & 0x3ff) + 1; - linesize = (raw->intel_fn4[ecx][1] & 0xfff) + 1; - sets = raw->intel_fn4[ecx][2] + 1; - size = ways * partitions * linesize * sets / 1024; - check_case(1, type, size, ways, linesize, data); - } -} - -static int decode_intel_extended_topology(struct cpu_raw_data_t* raw, - struct cpu_id_t* data) -{ - int i, level_type, num_smt = -1, num_core = -1; - for (i = 0; i < MAX_INTELFN11_LEVEL; i++) { - level_type = (raw->intel_fn11[i][2] & 0xff00) >> 8; - switch (level_type) { - case 0x01: - num_smt = raw->intel_fn11[i][1] & 0xffff; - break; - case 0x02: - num_core = raw->intel_fn11[i][1] & 0xffff; - break; - default: - break; - } - } - if (num_smt == -1 || num_core == -1) return 0; - data->num_logical_cpus = num_core; - data->num_cores = num_core / num_smt; - // make sure num_cores is at least 1. In VMs, the CPUID instruction - // is rigged and may give nonsensical results, but we should at least - // avoid outputs like data->num_cores == 0. - if (data->num_cores <= 0) data->num_cores = 1; - return 1; -} - -static void decode_intel_number_of_cores(struct cpu_raw_data_t* raw, - struct cpu_id_t* data) -{ - int logical_cpus = -1, num_cores = -1; - - if (raw->basic_cpuid[0][0] >= 11) { - if (decode_intel_extended_topology(raw, data)) return; - } - - if (raw->basic_cpuid[0][0] >= 1) { - logical_cpus = (raw->basic_cpuid[1][1] >> 16) & 0xff; - if (raw->basic_cpuid[0][0] >= 4) { - num_cores = 1 + ((raw->basic_cpuid[4][0] >> 26) & 0x3f); - } - } - if (data->flags[CPU_FEATURE_HT]) { - if (num_cores > 1) { - data->num_cores = num_cores; - data->num_logical_cpus = logical_cpus; - } else { - data->num_cores = 1; - data->num_logical_cpus = (logical_cpus >= 1 ? logical_cpus : 1); - if (data->num_logical_cpus == 1) - data->flags[CPU_FEATURE_HT] = 0; - } - } else { - data->num_cores = data->num_logical_cpus = 1; - } -} - -static intel_code_t get_brand_code(struct cpu_id_t* data) -{ - intel_code_t code = (intel_code_t) NO_CODE; - int i, need_matchtable = 1, core_ix_base = 0; - const char* bs = data->brand_str; - const char* s; - const struct { intel_code_t c; const char *search; } matchtable[] = { - { XEONMP, "Xeon MP" }, - { XEONMP, "Xeon(TM) MP" }, - { XEON, "Xeon" }, - { CELERON, "Celeron" }, - { MOBILE_PENTIUM_M, "Pentium(R) M" }, - { CORE_SOLO, "Pentium(R) Dual CPU" }, - { CORE_SOLO, "Pentium(R) Dual-Core" }, - { PENTIUM_D, "Pentium(R) D" }, - { PENTIUM, "Pentium" }, - { CORE_SOLO, "Genuine Intel(R) CPU" }, - { CORE_SOLO, "Intel(R) Core(TM)" }, - { ATOM_DIAMONDVILLE, "Atom(TM) CPU [N ][23]## " }, - { ATOM_SILVERTHORNE, "Atom(TM) CPU Z" }, - { ATOM_PINEVIEW, "Atom(TM) CPU [ND][45]## " }, - { ATOM_CEDARVIEW, "Atom(TM) CPU [ND]#### " }, - { ATOM_UNKNOWN, "Atom(TM) CPU" }, - }; - - if (strstr(bs, "Mobile")) { - need_matchtable = 0; - if (strstr(bs, "Celeron")) - code = MOBILE_CELERON; - else if (strstr(bs, "Pentium")) - code = MOBILE_PENTIUM; - } - if ((i = match_pattern(bs, "Core(TM) i[357]")) != 0) { - /* Core i3, Core i5 or Core i7 */ - need_matchtable = 0; - - core_ix_base = CORE_I3; - - /* if it has RdRand, then it is at least Ivy Bridge */ - if (data->flags[CPU_FEATURE_RDRAND]) - core_ix_base = CORE_IVY3; - /* if it has FMA, then it is at least Haswell */ - if (data->flags[CPU_FEATURE_FMA3]) - core_ix_base = CORE_HASWELL3; - /* if it has RTM, then it is at least a Broadwell-E or Skylake */ - if (data->flags[CPU_FEATURE_RDSEED]) - core_ix_base = CORE_BROADWELL3; - - switch (bs[i + 9]) { - case '3': code = core_ix_base + 0; break; - case '5': code = core_ix_base + 1; break; - case '7': code = core_ix_base + 2; break; - } - } - if (need_matchtable) { - for (i = 0; i < COUNT_OF(matchtable); i++) - if (match_pattern(bs, matchtable[i].search)) { - code = matchtable[i].c; - break; - } - debugf(2, "intel matchtable result is %d\n", code); - } - if (code == XEON) { - if (match_pattern(bs, "W35##") || match_pattern(bs, "[ELXW]75##")) - code = XEON_I7; - else if (match_pattern(bs, "[ELXW]55##")) - code = XEON_GAINESTOWN; - else if (match_pattern(bs, "[ELXW]56##")) - code = XEON_WESTMERE; - else if (data->l3_cache > 0 && data->family == 16) - /* restrict by family, since later Xeons also have L3 ... */ - code = XEON_IRWIN; - } - if (code == XEONMP && data->l3_cache > 0) - code = XEON_POTOMAC; - if (code == CORE_SOLO) { - s = strstr(bs, "CPU"); - if (s) { - s += 3; - while (*s == ' ') s++; - if (*s == 'T') - code = (data->num_cores == 1) ? MOBILE_CORE_SOLO : MOBILE_CORE_DUO; - } - } - if (code == CORE_SOLO) { - switch (data->num_cores) { - case 1: break; - case 2: - { - code = CORE_DUO; - if (data->num_logical_cpus > 2) - code = DUAL_CORE_HT; - break; - } - case 4: - { - code = QUAD_CORE; - if (data->num_logical_cpus > 4) - code = QUAD_CORE_HT; - break; - } - default: - code = MORE_THAN_QUADCORE; break; - } - } - - if (code == CORE_DUO && data->ext_model >= 23) { - code = WOLFDALE; - } - if (code == PENTIUM_D && data->ext_model >= 23) { - code = WOLFDALE; - } - if (code == MOBILE_CORE_DUO && data->model != 14) { - if (data->ext_model < 23) { - code = MEROM; - } else { - code = PENRYN; - } - } - return code; -} - -static intel_model_t get_model_code(struct cpu_id_t* data) -{ - int i = 0; - int l = (int) strlen(data->brand_str); - const char *bs = data->brand_str; - int mod_flags = 0, model_no = 0, ndigs = 0; - /* If the CPU is a Core ix, then just return the model number generation: */ - if ((i = match_pattern(bs, "Core(TM) i[357]")) != 0) { - i += 11; - if (i + 4 >= l) return UNKNOWN; - if (bs[i] == '2') return _2xxx; - if (bs[i] == '3') return _3xxx; - return UNKNOWN; - } - - /* For Core2-based Xeons: */ - while (i < l - 3) { - if (bs[i] == 'C' && bs[i+1] == 'P' && bs[i+2] == 'U') - break; - i++; - } - if (i >= l - 3) return UNKNOWN; - i += 3; - while (i < l - 4 && bs[i] == ' ') i++; - if (i >= l - 4) return UNKNOWN; - while (i < l - 4 && !isdigit(bs[i])) { - if (bs[i] >= 'A' && bs[i] <= 'Z') - mod_flags |= (1 << (bs[i] - 'A')); - i++; - } - if (i >= l - 4) return UNKNOWN; - while (isdigit(bs[i])) { - ndigs++; - model_no = model_no * 10 + (int) (bs[i] - '0'); - i++; - } - if (ndigs != 4) return UNKNOWN; -#define HAVE(ch, flags) ((flags & (1 << ((int)(ch-'A')))) != 0) - switch (model_no / 100) { - case 30: return _3000; - case 31: return _3100; - case 32: - { - return (HAVE('X', mod_flags)) ? X3200 : _3200; - } - case 33: - { - return (HAVE('X', mod_flags)) ? X3300 : _3300; - } - case 51: return _5100; - case 52: return _5200; - case 53: return _5300; - case 54: return _5400; - default: - return UNKNOWN; - } -#undef HAVE -} - -static void decode_intel_sgx_features(const struct cpu_raw_data_t* raw, struct cpu_id_t* data) -{ - struct cpu_epc_t epc; - int i; - - if (raw->basic_cpuid[0][0] < 0x12) return; // no 12h leaf - if (raw->basic_cpuid[0x12][0] == 0) return; // no sub-leafs available, probably it's disabled by BIOS - - // decode sub-leaf 0: - if (raw->basic_cpuid[0x12][0] & 1) data->sgx.flags[INTEL_SGX1] = 1; - if (raw->basic_cpuid[0x12][0] & 2) data->sgx.flags[INTEL_SGX2] = 1; - if (data->sgx.flags[INTEL_SGX1] || data->sgx.flags[INTEL_SGX2]) - data->sgx.present = 1; - data->sgx.misc_select = raw->basic_cpuid[0x12][1]; - data->sgx.max_enclave_32bit = (raw->basic_cpuid[0x12][3] ) & 0xff; - data->sgx.max_enclave_64bit = (raw->basic_cpuid[0x12][3] >> 8) & 0xff; - - // decode sub-leaf 1: - data->sgx.secs_attributes = raw->intel_fn12h[1][0] | (((uint64_t) raw->intel_fn12h[1][1]) << 32); - data->sgx.secs_xfrm = raw->intel_fn12h[1][2] | (((uint64_t) raw->intel_fn12h[1][3]) << 32); - - // decode higher-order subleafs, whenever present: - data->sgx.num_epc_sections = -1; - for (i = 0; i < 1000000; i++) { - epc = cpuid_get_epc(i, raw); - if (epc.length == 0) { - debugf(2, "SGX: epc section request for %d returned null, no more EPC sections.\n", i); - data->sgx.num_epc_sections = i; - break; - } - } - if (data->sgx.num_epc_sections == -1) { - debugf(1, "SGX: warning: seems to be infinitude of EPC sections.\n"); - data->sgx.num_epc_sections = 1000000; - } -} - -struct cpu_epc_t cpuid_get_epc(int index, const struct cpu_raw_data_t* raw) -{ - uint32_t regs[4]; - struct cpu_epc_t retval = {0, 0}; - if (raw && index < MAX_INTELFN12H_LEVEL - 2) { - // this was queried already, use the data: - memcpy(regs, raw->intel_fn12h[2 + index], sizeof(regs)); - } else { - // query this ourselves: - regs[0] = 0x12; - regs[2] = 2 + index; - regs[1] = regs[3] = 0; - cpu_exec_cpuid_ext(regs); - } - - // decode values: - if ((regs[0] & 0xf) == 0x1) { - retval.start_addr |= (regs[0] & 0xfffff000); // bits [12, 32) -> bits [12, 32) - retval.start_addr |= ((uint64_t) (regs[1] & 0x000fffff)) << 32; // bits [0, 20) -> bits [32, 52) - retval.length |= (regs[2] & 0xfffff000); // bits [12, 32) -> bits [12, 32) - retval.length |= ((uint64_t) (regs[3] & 0x000fffff)) << 32; // bits [0, 20) -> bits [32, 52) - } - return retval; -} - -int cpuid_identify_intel(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal) -{ - intel_code_t brand_code; - intel_model_t model_code; - int i; - char* brand_code_str = NULL; - - load_intel_features(raw, data); - if (raw->basic_cpuid[0][0] >= 4) { - /* Deterministic way is preferred, being more generic */ - decode_intel_deterministic_cache_info(raw, data); - } else if (raw->basic_cpuid[0][0] >= 2) { - decode_intel_oldstyle_cache_info(raw, data); - } - decode_intel_number_of_cores(raw, data); - - brand_code = get_brand_code(data); - model_code = get_model_code(data); - for (i = 0; i < COUNT_OF(intel_bcode_str); i++) { - if (brand_code == intel_bcode_str[i].code) { - brand_code_str = intel_bcode_str[i].str; - break; - } - } - if (brand_code_str) - debugf(2, "Detected Intel brand code: %d (%s)\n", brand_code, brand_code_str); - else - debugf(2, "Detected Intel brand code: %d\n", brand_code); - debugf(2, "Detected Intel model code: %d\n", model_code); - - internal->code.intel = brand_code; - - if (data->flags[CPU_FEATURE_SGX]) { - debugf(2, "SGX seems to be present, decoding...\n"); - // if SGX is indicated by the CPU, verify its presence: - decode_intel_sgx_features(raw, data); - } - - internal->score = match_cpu_codename(cpudb_intel, COUNT_OF(cpudb_intel), data, - brand_code, model_code); - return 0; -} - -void cpuid_get_list_intel(struct cpu_list_t* list) -{ - generic_get_cpu_list(cpudb_intel, COUNT_OF(cpudb_intel), list); -} diff --git a/contrib/libcpuid/include/libcpuid/recog_intel.h b/contrib/libcpuid/include/libcpuid/recog_intel.h deleted file mode 100644 index b99c783bf43..00000000000 --- a/contrib/libcpuid/include/libcpuid/recog_intel.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2008 Veselin Georgiev, - * anrieffNOSPAM @ mgail_DOT.com (convert to gmail) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __RECOG_INTEL_H__ -#define __RECOG_INTEL_H__ - -int cpuid_identify_intel(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal); -void cpuid_get_list_intel(struct cpu_list_t* list); - -#endif /*__RECOG_INTEL_H__*/ diff --git a/contrib/libdivide/CMakeLists.txt b/contrib/libdivide/CMakeLists.txt new file mode 100644 index 00000000000..57e9f254db5 --- /dev/null +++ b/contrib/libdivide/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library (libdivide INTERFACE) +target_include_directories (libdivide SYSTEM BEFORE INTERFACE .) diff --git a/contrib/libhdfs3-cmake/CMakeLists.txt b/contrib/libhdfs3-cmake/CMakeLists.txt index e68f0bacf46..4c71770f5b6 100644 --- a/contrib/libhdfs3-cmake/CMakeLists.txt +++ b/contrib/libhdfs3-cmake/CMakeLists.txt @@ -209,9 +209,8 @@ endif() target_link_libraries(hdfs3 PRIVATE ${LIBXML2_LIBRARY}) # inherit from parent cmake -target_include_directories(hdfs3 PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(hdfs3 PRIVATE ${Protobuf_INCLUDE_DIR}) -target_link_libraries(hdfs3 PRIVATE ${Protobuf_LIBRARY}) +target_link_libraries(hdfs3 PRIVATE ${Protobuf_LIBRARY} boost::headers_only) if(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) target_include_directories(hdfs3 PRIVATE ${OPENSSL_INCLUDE_DIR}) target_link_libraries(hdfs3 PRIVATE ${OPENSSL_LIBRARIES}) diff --git a/contrib/libmetrohash/CMakeLists.txt b/contrib/libmetrohash/CMakeLists.txt index d71a5432715..9304cb3644c 100644 --- a/contrib/libmetrohash/CMakeLists.txt +++ b/contrib/libmetrohash/CMakeLists.txt @@ -1,13 +1,10 @@ -if (HAVE_SSE42) # Not used. Pretty easy to port. - set (SOURCES_SSE42_ONLY src/metrohash128crc.cpp src/metrohash128crc.h) -endif () - -add_library(metrohash - src/metrohash.h - src/testvector.h - +set (SRCS src/metrohash64.cpp src/metrohash128.cpp - ${SOURCES_SSE42_ONLY}) +) +if (HAVE_SSE42) # Not used. Pretty easy to port. + list (APPEND SRCS src/metrohash128crc.cpp) +endif () -target_include_directories(metrohash PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) +add_library(metrohash ${SRCS}) +target_include_directories(metrohash PUBLIC src) diff --git a/contrib/librdkafka b/contrib/librdkafka index 4ffe54b4f59..b0d91bd74ab 160000 --- a/contrib/librdkafka +++ b/contrib/librdkafka @@ -1 +1 @@ -Subproject commit 4ffe54b4f59ee5ae3767f9f25dc14651a3384d62 +Subproject commit b0d91bd74abb5f0e1ee972d326a317ad610f6300 diff --git a/contrib/librdkafka-cmake/CMakeLists.txt b/contrib/librdkafka-cmake/CMakeLists.txt index 0f7b8e349ff..b8dcb0a9340 100644 --- a/contrib/librdkafka-cmake/CMakeLists.txt +++ b/contrib/librdkafka-cmake/CMakeLists.txt @@ -3,20 +3,30 @@ set(RDKAFKA_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/librdkafka/src) set(SRCS ${RDKAFKA_SOURCE_DIR}/crc32c.c ${RDKAFKA_SOURCE_DIR}/rdkafka_zstd.c +# ${RDKAFKA_SOURCE_DIR}/lz4.c +# ${RDKAFKA_SOURCE_DIR}/lz4frame.c +# ${RDKAFKA_SOURCE_DIR}/lz4hc.c +# ${RDKAFKA_SOURCE_DIR}/rdxxhash.c +# ${RDKAFKA_SOURCE_DIR}/regexp.c ${RDKAFKA_SOURCE_DIR}/rdaddr.c ${RDKAFKA_SOURCE_DIR}/rdavl.c ${RDKAFKA_SOURCE_DIR}/rdbuf.c ${RDKAFKA_SOURCE_DIR}/rdcrc32.c ${RDKAFKA_SOURCE_DIR}/rddl.c + ${RDKAFKA_SOURCE_DIR}/rdfnv1a.c ${RDKAFKA_SOURCE_DIR}/rdhdrhistogram.c ${RDKAFKA_SOURCE_DIR}/rdkafka.c + ${RDKAFKA_SOURCE_DIR}/rdkafka_admin.c # looks optional ${RDKAFKA_SOURCE_DIR}/rdkafka_assignor.c + ${RDKAFKA_SOURCE_DIR}/rdkafka_aux.c # looks optional ${RDKAFKA_SOURCE_DIR}/rdkafka_background.c ${RDKAFKA_SOURCE_DIR}/rdkafka_broker.c ${RDKAFKA_SOURCE_DIR}/rdkafka_buf.c ${RDKAFKA_SOURCE_DIR}/rdkafka_cert.c ${RDKAFKA_SOURCE_DIR}/rdkafka_cgrp.c ${RDKAFKA_SOURCE_DIR}/rdkafka_conf.c + ${RDKAFKA_SOURCE_DIR}/rdkafka_coord.c + ${RDKAFKA_SOURCE_DIR}/rdkafka_error.c ${RDKAFKA_SOURCE_DIR}/rdkafka_event.c ${RDKAFKA_SOURCE_DIR}/rdkafka_feature.c ${RDKAFKA_SOURCE_DIR}/rdkafka_idempotence.c @@ -24,6 +34,7 @@ set(SRCS ${RDKAFKA_SOURCE_DIR}/rdkafka_metadata.c ${RDKAFKA_SOURCE_DIR}/rdkafka_metadata_cache.c ${RDKAFKA_SOURCE_DIR}/rdkafka_mock.c + ${RDKAFKA_SOURCE_DIR}/rdkafka_mock_cgrp.c ${RDKAFKA_SOURCE_DIR}/rdkafka_mock_handlers.c ${RDKAFKA_SOURCE_DIR}/rdkafka_msg.c ${RDKAFKA_SOURCE_DIR}/rdkafka_msgset_reader.c @@ -38,9 +49,11 @@ set(SRCS ${RDKAFKA_SOURCE_DIR}/rdkafka_request.c ${RDKAFKA_SOURCE_DIR}/rdkafka_roundrobin_assignor.c ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl.c +# ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_cyrus.c # needed to support Kerberos, requires cyrus-sasl ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_oauthbearer.c ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_plain.c ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_scram.c +# ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_win32.c ${RDKAFKA_SOURCE_DIR}/rdkafka_ssl.c ${RDKAFKA_SOURCE_DIR}/rdkafka_subscription.c ${RDKAFKA_SOURCE_DIR}/rdkafka_timer.c @@ -48,6 +61,7 @@ set(SRCS ${RDKAFKA_SOURCE_DIR}/rdkafka_transport.c ${RDKAFKA_SOURCE_DIR}/rdkafka_interceptor.c ${RDKAFKA_SOURCE_DIR}/rdkafka_header.c + ${RDKAFKA_SOURCE_DIR}/rdkafka_txnmgr.c ${RDKAFKA_SOURCE_DIR}/rdlist.c ${RDKAFKA_SOURCE_DIR}/rdlog.c ${RDKAFKA_SOURCE_DIR}/rdmurmur2.c @@ -68,7 +82,7 @@ target_compile_options(rdkafka PRIVATE -fno-sanitize=undefined) target_include_directories(rdkafka SYSTEM PUBLIC include) target_include_directories(rdkafka SYSTEM PUBLIC ${RDKAFKA_SOURCE_DIR}) # Because weird logic with "include_next" is used. target_include_directories(rdkafka SYSTEM PRIVATE ${ZSTD_INCLUDE_DIR}/common) # Because wrong path to "zstd_errors.h" is used. -target_link_libraries(rdkafka PRIVATE ${ZLIB_LIBRARIES} ${ZSTD_LIBRARY} ${LZ4_LIBRARY} ${LIBGSASL_LIBRARY}) +target_link_libraries(rdkafka PRIVATE lz4 ${ZLIB_LIBRARIES} ${ZSTD_LIBRARY} ${LIBGSASL_LIBRARY}) if(OPENSSL_SSL_LIBRARY AND OPENSSL_CRYPTO_LIBRARY) target_link_libraries(rdkafka PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) endif() diff --git a/contrib/libunwind b/contrib/libunwind index ede00622ff8..27026ef4a9c 160000 --- a/contrib/libunwind +++ b/contrib/libunwind @@ -1 +1 @@ -Subproject commit ede00622ff8ecb1848ed22187eabbfaf8b4e9307 +Subproject commit 27026ef4a9c6c8cc956d1d131c4d794e24096981 diff --git a/contrib/libuv b/contrib/libuv new file mode 160000 index 00000000000..84438304f41 --- /dev/null +++ b/contrib/libuv @@ -0,0 +1 @@ +Subproject commit 84438304f41d8ea6670ee5409f4d6c63ca784f28 diff --git a/contrib/lz4 b/contrib/lz4 index 3d67671559b..f39b79fb029 160000 --- a/contrib/lz4 +++ b/contrib/lz4 @@ -1 +1 @@ -Subproject commit 3d67671559be723b0912bbee2fcd2eb14783a721 +Subproject commit f39b79fb02962a1cd880bbdecb6dffba4f754a11 diff --git a/contrib/lz4-cmake/CMakeLists.txt b/contrib/lz4-cmake/CMakeLists.txt index 25cceaa4574..b8121976213 100644 --- a/contrib/lz4-cmake/CMakeLists.txt +++ b/contrib/lz4-cmake/CMakeLists.txt @@ -1,16 +1,28 @@ -SET(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4/lib) +option (USE_INTERNAL_LZ4_LIBRARY "Use internal lz4 library" ${NOT_UNBUNDLED}) -add_library (lz4 - ${LIBRARY_DIR}/lz4.c - ${LIBRARY_DIR}/lz4hc.c - ${LIBRARY_DIR}/lz4frame.c - ${LIBRARY_DIR}/lz4frame.h - ${LIBRARY_DIR}/xxhash.c - ${LIBRARY_DIR}/xxhash.h +if (USE_INTERNAL_LZ4_LIBRARY) + set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4) - ${LIBRARY_DIR}/lz4.h - ${LIBRARY_DIR}/lz4hc.h) + set (SRCS + ${LIBRARY_DIR}/lib/lz4.c + ${LIBRARY_DIR}/lib/lz4hc.c + ${LIBRARY_DIR}/lib/lz4frame.c + ${LIBRARY_DIR}/lib/xxhash.c + ) -target_compile_definitions(lz4 PUBLIC LZ4_DISABLE_DEPRECATE_WARNINGS=1) + add_library (lz4 ${SRCS}) -target_include_directories(lz4 PUBLIC ${LIBRARY_DIR}) + target_compile_definitions (lz4 PUBLIC LZ4_DISABLE_DEPRECATE_WARNINGS=1 USE_XXHASH=1) + if (SANITIZE STREQUAL "undefined") + target_compile_options (lz4 PRIVATE -fno-sanitize=undefined) + endif () + target_include_directories(lz4 PUBLIC ${LIBRARY_DIR}/lib) +else () + find_library (LIBRARY_LZ4 lz4) + find_path (INCLUDE_LZ4 lz4.h) + + add_library (lz4 UNKNOWN IMPORTED) + set_property (TARGET lz4 PROPERTY IMPORTED_LOCATION ${LIBRARY_LZ4}) + set_property (TARGET lz4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_LZ4}) + set_property (TARGET lz4 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USE_XXHASH=0) +endif () diff --git a/contrib/openldap b/contrib/openldap new file mode 160000 index 00000000000..34b9ba94b30 --- /dev/null +++ b/contrib/openldap @@ -0,0 +1 @@ +Subproject commit 34b9ba94b30319ed6389a4e001d057f7983fe363 diff --git a/contrib/openldap-cmake/CMakeLists.txt b/contrib/openldap-cmake/CMakeLists.txt new file mode 100644 index 00000000000..b0a5f4048ff --- /dev/null +++ b/contrib/openldap-cmake/CMakeLists.txt @@ -0,0 +1,202 @@ +set(OPENLDAP_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/openldap) + +# How these lists were generated? +# I compiled the original OpenLDAP with it's original build system and copied the list of source files from build commands. + +set(_libs_type SHARED) +if(OPENLDAP_USE_STATIC_LIBS) + set(_libs_type STATIC) +endif() + +set(OPENLDAP_VERSION_STRING "2.5.X") + +macro(mkversion _lib_name) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-version.c + COMMAND ${CMAKE_COMMAND} -E env bash -c "${OPENLDAP_SOURCE_DIR}/build/mkversion -v '${OPENLDAP_VERSION_STRING}' liblber.la > ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-version.c" + MAIN_DEPENDENCY ${OPENLDAP_SOURCE_DIR}/build/mkversion + WORKING_DIRECTORY ${OPENLDAP_SOURCE_DIR} + VERBATIM + ) +endmacro() + +string(TOLOWER "${CMAKE_SYSTEM_NAME}" _system_name) +string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _system_processor) + +if( + "${_system_processor}" STREQUAL "amd64" OR + "${_system_processor}" STREQUAL "x64" +) + set(_system_processor "x86_64") +elseif( + "${_system_processor}" STREQUAL "arm64" +) + set (_system_processor "aarch64") +endif() + +set(_extra_build_dir "${CMAKE_CURRENT_SOURCE_DIR}/${_system_name}_${_system_processor}") + +set(_lber_srcs + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/assert.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/decode.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/encode.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/io.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/bprint.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/debug.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/memory.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/options.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/sockbuf.c + ${OPENLDAP_SOURCE_DIR}/libraries/liblber/stdio.c +) + +mkversion(lber) + +add_library(lber ${_libs_type} + ${_lber_srcs} + ${CMAKE_CURRENT_BINARY_DIR}/lber-version.c +) + +target_link_libraries(lber + PRIVATE ${OPENSSL_LIBRARIES} +) + +target_include_directories(lber + PRIVATE ${_extra_build_dir}/include + PRIVATE ${OPENLDAP_SOURCE_DIR}/include + PRIVATE ${OPENLDAP_SOURCE_DIR}/libraries/liblber + PRIVATE ${OPENSSL_INCLUDE_DIR} +) + +target_compile_definitions(lber + PRIVATE LBER_LIBRARY +) + +set(_ldap_srcs + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/bind.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/open.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/result.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/error.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/compare.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/search.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/controls.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/messages.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/references.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/extended.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/cyrus.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/modify.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/add.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/modrdn.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/delete.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/abandon.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/sasl.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/sbind.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/unbind.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/cancel.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/filter.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/free.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/sort.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/passwd.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/whoami.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/vc.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/getdn.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/getentry.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/getattr.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/getvalues.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/addentry.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/request.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/os-ip.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/url.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/pagectrl.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/sortctrl.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/vlvctrl.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/init.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/options.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/print.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/string.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/util-int.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/schema.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/charray.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/os-local.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/dnssrv.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/utf-8.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/utf-8-conv.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/tls2.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/tls_o.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/tls_g.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/turn.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/ppolicy.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/dds.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/txn.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/ldap_sync.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/stctrl.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/assertion.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/deref.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/ldifutil.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/ldif.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/fetch.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/lbase64.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/msctrl.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap/psearchctrl.c +) + +mkversion(ldap) + +add_library(ldap ${_libs_type} + ${_ldap_srcs} + ${CMAKE_CURRENT_BINARY_DIR}/ldap-version.c +) + +target_link_libraries(ldap + PRIVATE lber + PRIVATE ${OPENSSL_LIBRARIES} +) + +target_include_directories(ldap + PRIVATE ${_extra_build_dir}/include + PRIVATE ${OPENLDAP_SOURCE_DIR}/include + PRIVATE ${OPENLDAP_SOURCE_DIR}/libraries/libldap + PRIVATE ${OPENSSL_INCLUDE_DIR} +) + +target_compile_definitions(ldap + PRIVATE LDAP_LIBRARY +) + +set(_ldap_r_specific_srcs + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/threads.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/rdwr.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/tpool.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/rq.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/thr_posix.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/thr_thr.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/thr_nt.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/thr_pth.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/thr_stub.c + ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r/thr_debug.c +) + +mkversion(ldap_r) + +add_library(ldap_r ${_libs_type} + ${_ldap_r_specific_srcs} + ${_ldap_srcs} + ${CMAKE_CURRENT_BINARY_DIR}/ldap_r-version.c +) + +target_link_libraries(ldap_r + PRIVATE lber + PRIVATE ${OPENSSL_LIBRARIES} +) + +target_include_directories(ldap_r + PRIVATE ${_extra_build_dir}/include + PRIVATE ${OPENLDAP_SOURCE_DIR}/include + PRIVATE ${OPENLDAP_SOURCE_DIR}/libraries/libldap_r + PRIVATE ${OPENLDAP_SOURCE_DIR}/libraries/libldap + PRIVATE ${OPENSSL_INCLUDE_DIR} +) + +target_compile_definitions(ldap_r + PRIVATE LDAP_R_COMPILE + PRIVATE LDAP_LIBRARY +) diff --git a/contrib/openldap-cmake/darwin_x86_64/include/lber_types.h b/contrib/openldap-cmake/darwin_x86_64/include/lber_types.h new file mode 100644 index 00000000000..dbd59430527 --- /dev/null +++ b/contrib/openldap-cmake/darwin_x86_64/include/lber_types.h @@ -0,0 +1,63 @@ +/* include/lber_types.h. Generated from lber_types.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LBER types + */ + +#ifndef _LBER_TYPES_H +#define _LBER_TYPES_H + +#include + +LDAP_BEGIN_DECL + +/* LBER boolean, enum, integers (32 bits or larger) */ +#define LBER_INT_T int + +/* LBER tags (32 bits or larger) */ +#define LBER_TAG_T long + +/* LBER socket descriptor */ +#define LBER_SOCKET_T int + +/* LBER lengths (32 bits or larger) */ +#define LBER_LEN_T long + +/* ------------------------------------------------------------ */ + +/* booleans, enumerations, and integers */ +typedef LBER_INT_T ber_int_t; + +/* signed and unsigned versions */ +typedef signed LBER_INT_T ber_sint_t; +typedef unsigned LBER_INT_T ber_uint_t; + +/* tags */ +typedef unsigned LBER_TAG_T ber_tag_t; + +/* "socket" descriptors */ +typedef LBER_SOCKET_T ber_socket_t; + +/* lengths */ +typedef unsigned LBER_LEN_T ber_len_t; + +/* signed lengths */ +typedef signed LBER_LEN_T ber_slen_t; + +LDAP_END_DECL + +#endif /* _LBER_TYPES_H */ diff --git a/contrib/openldap-cmake/darwin_x86_64/include/ldap_config.h b/contrib/openldap-cmake/darwin_x86_64/include/ldap_config.h new file mode 100644 index 00000000000..89f7b40b884 --- /dev/null +++ b/contrib/openldap-cmake/darwin_x86_64/include/ldap_config.h @@ -0,0 +1,74 @@ +/* include/ldap_config.h. Generated from ldap_config.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * This file works in conjunction with OpenLDAP configure system. + * If you do no like the values below, adjust your configure options. + */ + +#ifndef _LDAP_CONFIG_H +#define _LDAP_CONFIG_H + +/* directory separator */ +#ifndef LDAP_DIRSEP +#ifndef _WIN32 +#define LDAP_DIRSEP "/" +#else +#define LDAP_DIRSEP "\\" +#endif +#endif + +/* directory for temporary files */ +#if defined(_WIN32) +# define LDAP_TMPDIR "C:\\." /* we don't have much of a choice */ +#elif defined( _P_tmpdir ) +# define LDAP_TMPDIR _P_tmpdir +#elif defined( P_tmpdir ) +# define LDAP_TMPDIR P_tmpdir +#elif defined( _PATH_TMPDIR ) +# define LDAP_TMPDIR _PATH_TMPDIR +#else +# define LDAP_TMPDIR LDAP_DIRSEP "tmp" +#endif + +/* directories */ +#ifndef LDAP_BINDIR +#define LDAP_BINDIR "/tmp/ldap-prefix/bin" +#endif +#ifndef LDAP_SBINDIR +#define LDAP_SBINDIR "/tmp/ldap-prefix/sbin" +#endif +#ifndef LDAP_DATADIR +#define LDAP_DATADIR "/tmp/ldap-prefix/share/openldap" +#endif +#ifndef LDAP_SYSCONFDIR +#define LDAP_SYSCONFDIR "/tmp/ldap-prefix/etc/openldap" +#endif +#ifndef LDAP_LIBEXECDIR +#define LDAP_LIBEXECDIR "/tmp/ldap-prefix/libexec" +#endif +#ifndef LDAP_MODULEDIR +#define LDAP_MODULEDIR "/tmp/ldap-prefix/libexec/openldap" +#endif +#ifndef LDAP_RUNDIR +#define LDAP_RUNDIR "/tmp/ldap-prefix/var" +#endif +#ifndef LDAP_LOCALEDIR +#define LDAP_LOCALEDIR "" +#endif + + +#endif /* _LDAP_CONFIG_H */ diff --git a/contrib/openldap-cmake/darwin_x86_64/include/ldap_features.h b/contrib/openldap-cmake/darwin_x86_64/include/ldap_features.h new file mode 100644 index 00000000000..f0cc7c3626f --- /dev/null +++ b/contrib/openldap-cmake/darwin_x86_64/include/ldap_features.h @@ -0,0 +1,61 @@ +/* include/ldap_features.h. Generated from ldap_features.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LDAP Features + */ + +#ifndef _LDAP_FEATURES_H +#define _LDAP_FEATURES_H 1 + +/* OpenLDAP API version macros */ +#define LDAP_VENDOR_VERSION 20501 +#define LDAP_VENDOR_VERSION_MAJOR 2 +#define LDAP_VENDOR_VERSION_MINOR 5 +#define LDAP_VENDOR_VERSION_PATCH X + +/* +** WORK IN PROGRESS! +** +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation is not thread-safe. +** +** The -lldap_r implementation is: +** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety) +** but also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is available at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definitions and declarations may be incorrect. +** +*/ + +/* is -lldap_r available or not */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* LDAP v2 Referrals */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +#endif /* LDAP_FEATURES */ diff --git a/contrib/openldap-cmake/darwin_x86_64/include/portable.h b/contrib/openldap-cmake/darwin_x86_64/include/portable.h new file mode 100644 index 00000000000..fdf4e89017e --- /dev/null +++ b/contrib/openldap-cmake/darwin_x86_64/include/portable.h @@ -0,0 +1,1169 @@ +/* include/portable.h. Generated from portable.hin by configure. */ +/* include/portable.hin. Generated from configure.in by autoheader. */ + + +/* begin of portable.h.pre */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* define this if needed to get reentrant functions */ +#ifndef REENTRANT +#define REENTRANT 1 +#endif +#ifndef _REENTRANT +#define _REENTRANT 1 +#endif + +/* define this if needed to get threadsafe functions */ +#ifndef THREADSAFE +#define THREADSAFE 1 +#endif +#ifndef _THREADSAFE +#define _THREADSAFE 1 +#endif +#ifndef THREAD_SAFE +#define THREAD_SAFE 1 +#endif +#ifndef _THREAD_SAFE +#define _THREAD_SAFE 1 +#endif + +#ifndef _SGI_MP_SOURCE +#define _SGI_MP_SOURCE 1 +#endif + +/* end of portable.h.pre */ + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* define to use both and */ +/* #undef BOTH_STRINGS_H */ + +/* define if cross compiling */ +/* #undef CROSS_COMPILING */ + +/* set to the number of arguments ctime_r() expects */ +#define CTIME_R_NARGS 2 + +/* define if toupper() requires islower() */ +/* #undef C_UPPER_LOWER */ + +/* define if sys_errlist is not declared in stdio.h or errno.h */ +/* #undef DECL_SYS_ERRLIST */ + +/* define to enable slapi library */ +/* #undef ENABLE_SLAPI */ + +/* defined to be the EXE extension */ +#define EXEEXT "" + +/* set to the number of arguments gethostbyaddr_r() expects */ +/* #undef GETHOSTBYADDR_R_NARGS */ + +/* set to the number of arguments gethostbyname_r() expects */ +/* #undef GETHOSTBYNAME_R_NARGS */ + +/* Define to 1 if `TIOCGWINSZ' requires . */ +/* #undef GWINSZ_IN_SYS_IOCTL */ + +/* define if you have AIX security lib */ +/* #undef HAVE_AIX_SECURITY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BITS_TYPES_H */ + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `closesocket' function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* define if crypt(3) is available */ +/* #undef HAVE_CRYPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* define if crypt_r() is also available */ +/* #undef HAVE_CRYPT_R */ + +/* Define to 1 if you have the `ctime_r' function. */ +#define HAVE_CTIME_R 1 + +/* define if you have Cyrus SASL */ +/* #undef HAVE_CYRUS_SASL */ + +/* define if your system supports /dev/poll */ +/* #undef HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* define if system uses EBCDIC instead of ASCII */ +/* #undef HAVE_EBCDIC */ + +/* Define to 1 if you have the `endgrent' function. */ +#define HAVE_ENDGRENT 1 + +/* Define to 1 if you have the `endpwent' function. */ +#define HAVE_ENDPWENT 1 + +/* define if your system supports epoll */ +/* #undef HAVE_EPOLL */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* define if you actually have FreeBSD fetch(3) */ +/* #undef HAVE_FETCH */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FILIO_H */ + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getdtablesize' function. */ +#define HAVE_GETDTABLESIZE 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgrgid' function. */ +#define HAVE_GETGRGID 1 + +/* Define to 1 if you have the `gethostbyaddr_r' function. */ +/* #undef HAVE_GETHOSTBYADDR_R */ + +/* Define to 1 if you have the `gethostbyname_r' function. */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getpassphrase' function. */ +/* #undef HAVE_GETPASSPHRASE */ + +/* Define to 1 if you have the `getpeereid' function. */ +#define HAVE_GETPEEREID 1 + +/* Define to 1 if you have the `getpeerucred' function. */ +/* #undef HAVE_GETPEERUCRED */ + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GMP_H */ + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* define if you have GNUtls */ +/* #undef HAVE_GNUTLS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GNUTLS_GNUTLS_H */ + +/* if you have GNU Pth */ +/* #undef HAVE_GNU_PTH */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* define to you inet_aton(3) is available */ +#define HAVE_INET_ATON 1 + +/* Define to 1 if you have the `inet_ntoa_b' function. */ +/* #undef HAVE_INET_NTOA_B */ + +/* Define to 1 if you have the `inet_ntop' function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `ioctl' function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* define if your system supports kqueue */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the `gen' library (-lgen). */ +/* #undef HAVE_LIBGEN */ + +/* Define to 1 if you have the `gmp' library (-lgmp). */ +/* #undef HAVE_LIBGMP */ + +/* Define to 1 if you have the `inet' library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* define if you have libtool -ltdl */ +/* #undef HAVE_LIBLTDL */ + +/* Define to 1 if you have the `net' library (-lnet). */ +/* #undef HAVE_LIBNET */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define to 1 if you have the `V3' library (-lV3). */ +/* #undef HAVE_LIBV3 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* if you have LinuxThreads */ +/* #undef HAVE_LINUX_THREADS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LTDL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +/* #undef HAVE_MEMRCHR */ + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mktemp' function. */ +#define HAVE_MKTEMP 1 + +/* define this if you have mkversion */ +#define HAVE_MKVERSION 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* define if strerror_r returns char* instead of int */ +/* #undef HAVE_NONPOSIX_STRERROR_R */ + +/* if you have NT Event Log */ +/* #undef HAVE_NT_EVENT_LOG */ + +/* if you have NT Service Manager */ +/* #undef HAVE_NT_SERVICE_MANAGER */ + +/* if you have NT Threads */ +/* #undef HAVE_NT_THREADS */ + +/* define if you have OpenSSL */ +#define HAVE_OPENSSL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_BN_H 1 + +/* define if you have OpenSSL with CRL checking capability */ +#define HAVE_OPENSSL_CRL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_CRYPTO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_SSL_H 1 + +/* Define to 1 if you have the `pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PSAP_H */ + +/* define to pthreads API spec revision */ +#define HAVE_PTHREADS 10 + +/* define if you have pthread_detach function */ +#define HAVE_PTHREAD_DETACH 1 + +/* Define to 1 if you have the `pthread_getconcurrency' function. */ +#define HAVE_PTHREAD_GETCONCURRENCY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_kill_other_threads_np' function. */ +/* #undef HAVE_PTHREAD_KILL_OTHER_THREADS_NP */ + +/* define if you have pthread_rwlock_destroy function */ +#define HAVE_PTHREAD_RWLOCK_DESTROY 1 + +/* Define to 1 if you have the `pthread_setconcurrency' function. */ +#define HAVE_PTHREAD_SETCONCURRENCY 1 + +/* Define to 1 if you have the `pthread_yield' function. */ +/* #undef HAVE_PTHREAD_YIELD */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTH_H */ + +/* Define to 1 if the system has the type `ptrdiff_t'. */ +#define HAVE_PTRDIFF_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `read' function. */ +#define HAVE_READ 1 + +/* Define to 1 if you have the `recv' function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the `recvfrom' function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RESOLV_H */ + +/* define if you have res_query() */ +/* #undef HAVE_RES_QUERY */ + +/* define if OpenSSL needs RSAref */ +/* #undef HAVE_RSAREF */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_SASL_H */ + +/* define if your SASL library has sasl_version() */ +/* #undef HAVE_SASL_VERSION */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_yield' function. */ +#define HAVE_SCHED_YIELD 1 + +/* Define to 1 if you have the `send' function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the `sendmsg' function. */ +#define HAVE_SENDMSG 1 + +/* Define to 1 if you have the `sendto' function. */ +#define HAVE_SENDTO 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setpwfile' function. */ +/* #undef HAVE_SETPWFILE */ + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SGTTY_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* Define to 1 if you have the `sigset' function. */ +#define HAVE_SIGSET 1 + +/* define if you have -lslp */ +/* #undef HAVE_SLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SLP_H */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* if you have spawnlp() */ +/* #undef HAVE_SPAWNLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQLEXT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strpbrk' function. */ +#define HAVE_STRPBRK 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strsep' function. */ +#define HAVE_STRSEP 1 + +/* Define to 1 if you have the `strspn' function. */ +#define HAVE_STRSPN 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +#define HAVE_STRTOQ 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the `strtouq' function. */ +#define HAVE_STRTOUQ 1 + +/* Define to 1 if `msg_accrightslen' is a member of `struct msghdr'. */ +/* #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN */ + +/* Define to 1 if `msg_control' is a member of `struct msghdr'. */ +/* #undef HAVE_STRUCT_MSGHDR_MSG_CONTROL */ + +/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_GECOS 1 + +/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_PASSWD 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_fstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE */ + +/* define to 1 if st_fstype is char * */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_CHAR */ + +/* define to 1 if st_fstype is int */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_INT */ + +/* Define to 1 if `st_vfstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_VFSTYPE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYNCH_H */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EPOLL_H */ + +/* define if you actually have sys_errlist in your libs */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FSTYP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PRIVGRP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UCRED_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UUID_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_VMOUNT_H */ + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* define if you have -lwrap */ +/* #undef HAVE_TCPD */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TCPD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* if you have Solaris LWP (thr) package */ +/* #undef HAVE_THR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `thr_getconcurrency' function. */ +/* #undef HAVE_THR_GETCONCURRENCY */ + +/* Define to 1 if you have the `thr_setconcurrency' function. */ +/* #undef HAVE_THR_SETCONCURRENCY */ + +/* Define to 1 if you have the `thr_yield' function. */ +/* #undef HAVE_THR_YIELD */ + +/* define if you have TLS */ +#define HAVE_TLS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* define if you have uuid_generate() */ +/* #undef HAVE_UUID_GENERATE */ + +/* define if you have uuid_to_str() */ +/* #undef HAVE_UUID_TO_STR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UUID_UUID_H */ + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* define if you have winsock */ +/* #undef HAVE_WINSOCK */ + +/* define if you have winsock2 */ +/* #undef HAVE_WINSOCK2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WIREDTIGER_H */ + +/* Define to 1 if you have the `write' function. */ +#define HAVE_WRITE 1 + +/* define if select implicitly yields */ +#define HAVE_YIELDING_SELECT 1 + +/* Define to 1 if you have the `_vsnprintf' function. */ +/* #undef HAVE__VSNPRINTF */ + +/* define to 32-bit or greater integer type */ +#define LBER_INT_T int + +/* define to large integer type */ +#define LBER_LEN_T long + +/* define to socket descriptor type */ +#define LBER_SOCKET_T int + +/* define to large integer type */ +#define LBER_TAG_T long + +/* define to 1 if library is thread safe */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* define to LDAP VENDOR VERSION */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +/* define this to add debugging code */ +/* #undef LDAP_DEBUG */ + +/* define if LDAP libs are dynamic */ +/* #undef LDAP_LIBS_DYNAMIC */ + +/* define to support PF_INET6 */ +#define LDAP_PF_INET6 1 + +/* define to support PF_LOCAL */ +#define LDAP_PF_LOCAL 1 + +/* define this to add SLAPI code */ +/* #undef LDAP_SLAPI */ + +/* define this to add syslog code */ +/* #undef LDAP_SYSLOG */ + +/* Version */ +#define LDAP_VENDOR_VERSION 20501 + +/* Major */ +#define LDAP_VENDOR_VERSION_MAJOR 2 + +/* Minor */ +#define LDAP_VENDOR_VERSION_MINOR 5 + +/* Patch */ +#define LDAP_VENDOR_VERSION_PATCH X + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* define if memcmp is not 8-bit clean or is otherwise broken */ +/* #undef NEED_MEMCMP_REPLACEMENT */ + +/* define if you have (or want) no threads */ +/* #undef NO_THREADS */ + +/* define to use the original debug style */ +/* #undef OLD_DEBUG */ + +/* Package */ +#define OPENLDAP_PACKAGE "OpenLDAP" + +/* Version */ +#define OPENLDAP_VERSION "2.5.X" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* define if sched_yield yields the entire process */ +/* #undef REPLACE_BROKEN_YIELD */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type of arg 1 for `select'. */ +#define SELECT_TYPE_ARG1 int + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#define SELECT_TYPE_ARG234 (fd_set *) + +/* Define to the type of arg 5 for `select'. */ +#define SELECT_TYPE_ARG5 (struct timeval *) + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* define to support per-object ACIs */ +/* #undef SLAPD_ACI_ENABLED */ + +/* define to support LDAP Async Metadirectory backend */ +/* #undef SLAPD_ASYNCMETA */ + +/* define to support cleartext passwords */ +/* #undef SLAPD_CLEARTEXT */ + +/* define to support crypt(3) passwords */ +/* #undef SLAPD_CRYPT */ + +/* define to support DNS SRV backend */ +/* #undef SLAPD_DNSSRV */ + +/* define to support LDAP backend */ +/* #undef SLAPD_LDAP */ + +/* define to support MDB backend */ +/* #undef SLAPD_MDB */ + +/* define to support LDAP Metadirectory backend */ +/* #undef SLAPD_META */ + +/* define to support modules */ +/* #undef SLAPD_MODULES */ + +/* dynamically linked module */ +#define SLAPD_MOD_DYNAMIC 2 + +/* statically linked module */ +#define SLAPD_MOD_STATIC 1 + +/* define to support cn=Monitor backend */ +/* #undef SLAPD_MONITOR */ + +/* define to support NDB backend */ +/* #undef SLAPD_NDB */ + +/* define to support NULL backend */ +/* #undef SLAPD_NULL */ + +/* define for In-Directory Access Logging overlay */ +/* #undef SLAPD_OVER_ACCESSLOG */ + +/* define for Audit Logging overlay */ +/* #undef SLAPD_OVER_AUDITLOG */ + +/* define for Automatic Certificate Authority overlay */ +/* #undef SLAPD_OVER_AUTOCA */ + +/* define for Collect overlay */ +/* #undef SLAPD_OVER_COLLECT */ + +/* define for Attribute Constraint overlay */ +/* #undef SLAPD_OVER_CONSTRAINT */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DDS */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DEREF */ + +/* define for Dynamic Group overlay */ +/* #undef SLAPD_OVER_DYNGROUP */ + +/* define for Dynamic List overlay */ +/* #undef SLAPD_OVER_DYNLIST */ + +/* define for Reverse Group Membership overlay */ +/* #undef SLAPD_OVER_MEMBEROF */ + +/* define for Password Policy overlay */ +/* #undef SLAPD_OVER_PPOLICY */ + +/* define for Proxy Cache overlay */ +/* #undef SLAPD_OVER_PROXYCACHE */ + +/* define for Referential Integrity overlay */ +/* #undef SLAPD_OVER_REFINT */ + +/* define for Return Code overlay */ +/* #undef SLAPD_OVER_RETCODE */ + +/* define for Rewrite/Remap overlay */ +/* #undef SLAPD_OVER_RWM */ + +/* define for Sequential Modify overlay */ +/* #undef SLAPD_OVER_SEQMOD */ + +/* define for ServerSideSort/VLV overlay */ +/* #undef SLAPD_OVER_SSSVLV */ + +/* define for Syncrepl Provider overlay */ +/* #undef SLAPD_OVER_SYNCPROV */ + +/* define for Translucent Proxy overlay */ +/* #undef SLAPD_OVER_TRANSLUCENT */ + +/* define for Attribute Uniqueness overlay */ +/* #undef SLAPD_OVER_UNIQUE */ + +/* define for Value Sorting overlay */ +/* #undef SLAPD_OVER_VALSORT */ + +/* define to support PASSWD backend */ +/* #undef SLAPD_PASSWD */ + +/* define to support PERL backend */ +/* #undef SLAPD_PERL */ + +/* define to support relay backend */ +/* #undef SLAPD_RELAY */ + +/* define to support reverse lookups */ +/* #undef SLAPD_RLOOKUPS */ + +/* define to support SHELL backend */ +/* #undef SLAPD_SHELL */ + +/* define to support SOCK backend */ +/* #undef SLAPD_SOCK */ + +/* define to support SASL passwords */ +/* #undef SLAPD_SPASSWD */ + +/* define to support SQL backend */ +/* #undef SLAPD_SQL */ + +/* define to support WiredTiger backend */ +/* #undef SLAPD_WT */ + +/* define to support run-time loadable ACL */ +/* #undef SLAP_DYNACL */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* set to urandom device */ +#define URANDOM_DEVICE "/dev/urandom" + +/* define to use OpenSSL BIGNUM for MP */ +/* #undef USE_MP_BIGNUM */ + +/* define to use GMP for MP */ +/* #undef USE_MP_GMP */ + +/* define to use 'long' for MP */ +/* #undef USE_MP_LONG */ + +/* define to use 'long long' for MP */ +/* #undef USE_MP_LONG_LONG */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to the type of arg 3 for `accept'. */ +#define ber_socklen_t socklen_t + +/* Define to `char *' if does not define. */ +/* #undef caddr_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `int' if does not define. */ +/* #undef sig_atomic_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +/* define to snprintf routine */ +/* #undef snprintf */ + +/* Define like ber_socklen_t if does not define. */ +/* #undef socklen_t */ + +/* Define to `signed int' if does not define. */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* define as empty if volatile is not supported */ +/* #undef volatile */ + +/* define to snprintf routine */ +/* #undef vsnprintf */ + + +/* begin of portable.h.post */ + +#ifdef _WIN32 +/* don't suck in all of the win32 api */ +# define WIN32_LEAN_AND_MEAN 1 +#endif + +#ifndef LDAP_NEEDS_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define LDAP_NEEDS_PROTOTYPES 1 +#endif + +#ifndef LDAP_REL_ENG +#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL) +#define LDAP_DEVEL +#endif +#if defined(LDAP_DEVEL) && !defined(LDAP_TEST) +#define LDAP_TEST +#endif +#endif + +#ifdef HAVE_STDDEF_H +# include +#endif + +#ifdef HAVE_EBCDIC +/* ASCII/EBCDIC converting replacements for stdio funcs + * vsnprintf and snprintf are used too, but they are already + * checked by the configure script + */ +#define fputs ber_pvt_fputs +#define fgets ber_pvt_fgets +#define printf ber_pvt_printf +#define fprintf ber_pvt_fprintf +#define vfprintf ber_pvt_vfprintf +#define vsprintf ber_pvt_vsprintf +#endif + +#include "ac/fdset.h" + +#include "ldap_cdefs.h" +#include "ldap_features.h" + +#include "ac/assert.h" +#include "ac/localize.h" + +#endif /* _LDAP_PORTABLE_H */ +/* end of portable.h.post */ + diff --git a/contrib/openldap-cmake/freebsd_x86_64/include/lber_types.h b/contrib/openldap-cmake/freebsd_x86_64/include/lber_types.h new file mode 100644 index 00000000000..dbd59430527 --- /dev/null +++ b/contrib/openldap-cmake/freebsd_x86_64/include/lber_types.h @@ -0,0 +1,63 @@ +/* include/lber_types.h. Generated from lber_types.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LBER types + */ + +#ifndef _LBER_TYPES_H +#define _LBER_TYPES_H + +#include + +LDAP_BEGIN_DECL + +/* LBER boolean, enum, integers (32 bits or larger) */ +#define LBER_INT_T int + +/* LBER tags (32 bits or larger) */ +#define LBER_TAG_T long + +/* LBER socket descriptor */ +#define LBER_SOCKET_T int + +/* LBER lengths (32 bits or larger) */ +#define LBER_LEN_T long + +/* ------------------------------------------------------------ */ + +/* booleans, enumerations, and integers */ +typedef LBER_INT_T ber_int_t; + +/* signed and unsigned versions */ +typedef signed LBER_INT_T ber_sint_t; +typedef unsigned LBER_INT_T ber_uint_t; + +/* tags */ +typedef unsigned LBER_TAG_T ber_tag_t; + +/* "socket" descriptors */ +typedef LBER_SOCKET_T ber_socket_t; + +/* lengths */ +typedef unsigned LBER_LEN_T ber_len_t; + +/* signed lengths */ +typedef signed LBER_LEN_T ber_slen_t; + +LDAP_END_DECL + +#endif /* _LBER_TYPES_H */ diff --git a/contrib/openldap-cmake/freebsd_x86_64/include/ldap_config.h b/contrib/openldap-cmake/freebsd_x86_64/include/ldap_config.h new file mode 100644 index 00000000000..89f7b40b884 --- /dev/null +++ b/contrib/openldap-cmake/freebsd_x86_64/include/ldap_config.h @@ -0,0 +1,74 @@ +/* include/ldap_config.h. Generated from ldap_config.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * This file works in conjunction with OpenLDAP configure system. + * If you do no like the values below, adjust your configure options. + */ + +#ifndef _LDAP_CONFIG_H +#define _LDAP_CONFIG_H + +/* directory separator */ +#ifndef LDAP_DIRSEP +#ifndef _WIN32 +#define LDAP_DIRSEP "/" +#else +#define LDAP_DIRSEP "\\" +#endif +#endif + +/* directory for temporary files */ +#if defined(_WIN32) +# define LDAP_TMPDIR "C:\\." /* we don't have much of a choice */ +#elif defined( _P_tmpdir ) +# define LDAP_TMPDIR _P_tmpdir +#elif defined( P_tmpdir ) +# define LDAP_TMPDIR P_tmpdir +#elif defined( _PATH_TMPDIR ) +# define LDAP_TMPDIR _PATH_TMPDIR +#else +# define LDAP_TMPDIR LDAP_DIRSEP "tmp" +#endif + +/* directories */ +#ifndef LDAP_BINDIR +#define LDAP_BINDIR "/tmp/ldap-prefix/bin" +#endif +#ifndef LDAP_SBINDIR +#define LDAP_SBINDIR "/tmp/ldap-prefix/sbin" +#endif +#ifndef LDAP_DATADIR +#define LDAP_DATADIR "/tmp/ldap-prefix/share/openldap" +#endif +#ifndef LDAP_SYSCONFDIR +#define LDAP_SYSCONFDIR "/tmp/ldap-prefix/etc/openldap" +#endif +#ifndef LDAP_LIBEXECDIR +#define LDAP_LIBEXECDIR "/tmp/ldap-prefix/libexec" +#endif +#ifndef LDAP_MODULEDIR +#define LDAP_MODULEDIR "/tmp/ldap-prefix/libexec/openldap" +#endif +#ifndef LDAP_RUNDIR +#define LDAP_RUNDIR "/tmp/ldap-prefix/var" +#endif +#ifndef LDAP_LOCALEDIR +#define LDAP_LOCALEDIR "" +#endif + + +#endif /* _LDAP_CONFIG_H */ diff --git a/contrib/openldap-cmake/freebsd_x86_64/include/ldap_features.h b/contrib/openldap-cmake/freebsd_x86_64/include/ldap_features.h new file mode 100644 index 00000000000..f0cc7c3626f --- /dev/null +++ b/contrib/openldap-cmake/freebsd_x86_64/include/ldap_features.h @@ -0,0 +1,61 @@ +/* include/ldap_features.h. Generated from ldap_features.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LDAP Features + */ + +#ifndef _LDAP_FEATURES_H +#define _LDAP_FEATURES_H 1 + +/* OpenLDAP API version macros */ +#define LDAP_VENDOR_VERSION 20501 +#define LDAP_VENDOR_VERSION_MAJOR 2 +#define LDAP_VENDOR_VERSION_MINOR 5 +#define LDAP_VENDOR_VERSION_PATCH X + +/* +** WORK IN PROGRESS! +** +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation is not thread-safe. +** +** The -lldap_r implementation is: +** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety) +** but also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is available at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definitions and declarations may be incorrect. +** +*/ + +/* is -lldap_r available or not */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* LDAP v2 Referrals */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +#endif /* LDAP_FEATURES */ diff --git a/contrib/openldap-cmake/freebsd_x86_64/include/portable.h b/contrib/openldap-cmake/freebsd_x86_64/include/portable.h new file mode 100644 index 00000000000..10a15fe3ca1 --- /dev/null +++ b/contrib/openldap-cmake/freebsd_x86_64/include/portable.h @@ -0,0 +1,1169 @@ +/* include/portable.h. Generated from portable.hin by configure. */ +/* include/portable.hin. Generated from configure.in by autoheader. */ + + +/* begin of portable.h.pre */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* define this if needed to get reentrant functions */ +#ifndef REENTRANT +#define REENTRANT 1 +#endif +#ifndef _REENTRANT +#define _REENTRANT 1 +#endif + +/* define this if needed to get threadsafe functions */ +#ifndef THREADSAFE +#define THREADSAFE 1 +#endif +#ifndef _THREADSAFE +#define _THREADSAFE 1 +#endif +#ifndef THREAD_SAFE +#define THREAD_SAFE 1 +#endif +#ifndef _THREAD_SAFE +#define _THREAD_SAFE 1 +#endif + +#ifndef _SGI_MP_SOURCE +#define _SGI_MP_SOURCE 1 +#endif + +/* end of portable.h.pre */ + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* define to use both and */ +/* #undef BOTH_STRINGS_H */ + +/* define if cross compiling */ +/* #undef CROSS_COMPILING */ + +/* set to the number of arguments ctime_r() expects */ +#define CTIME_R_NARGS 2 + +/* define if toupper() requires islower() */ +/* #undef C_UPPER_LOWER */ + +/* define if sys_errlist is not declared in stdio.h or errno.h */ +/* #undef DECL_SYS_ERRLIST */ + +/* define to enable slapi library */ +/* #undef ENABLE_SLAPI */ + +/* defined to be the EXE extension */ +#define EXEEXT "" + +/* set to the number of arguments gethostbyaddr_r() expects */ +#define GETHOSTBYADDR_R_NARGS 8 + +/* set to the number of arguments gethostbyname_r() expects */ +#define GETHOSTBYNAME_R_NARGS 6 + +/* Define to 1 if `TIOCGWINSZ' requires . */ +/* #undef GWINSZ_IN_SYS_IOCTL */ + +/* define if you have AIX security lib */ +/* #undef HAVE_AIX_SECURITY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BITS_TYPES_H */ + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `closesocket' function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* define if crypt(3) is available */ +/* #undef HAVE_CRYPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* define if crypt_r() is also available */ +/* #undef HAVE_CRYPT_R */ + +/* Define to 1 if you have the `ctime_r' function. */ +#define HAVE_CTIME_R 1 + +/* define if you have Cyrus SASL */ +/* #undef HAVE_CYRUS_SASL */ + +/* define if your system supports /dev/poll */ +/* #undef HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* define if system uses EBCDIC instead of ASCII */ +/* #undef HAVE_EBCDIC */ + +/* Define to 1 if you have the `endgrent' function. */ +#define HAVE_ENDGRENT 1 + +/* Define to 1 if you have the `endpwent' function. */ +#define HAVE_ENDPWENT 1 + +/* define if your system supports epoll */ +/* #undef HAVE_EPOLL */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* define if you actually have FreeBSD fetch(3) */ +/* #undef HAVE_FETCH */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FILIO_H */ + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getdtablesize' function. */ +#define HAVE_GETDTABLESIZE 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgrgid' function. */ +#define HAVE_GETGRGID 1 + +/* Define to 1 if you have the `gethostbyaddr_r' function. */ +#define HAVE_GETHOSTBYADDR_R 1 + +/* Define to 1 if you have the `gethostbyname_r' function. */ +#define HAVE_GETHOSTBYNAME_R 1 + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getpassphrase' function. */ +/* #undef HAVE_GETPASSPHRASE */ + +/* Define to 1 if you have the `getpeereid' function. */ +#define HAVE_GETPEEREID 1 + +/* Define to 1 if you have the `getpeerucred' function. */ +/* #undef HAVE_GETPEERUCRED */ + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GMP_H */ + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* define if you have GNUtls */ +/* #undef HAVE_GNUTLS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GNUTLS_GNUTLS_H */ + +/* if you have GNU Pth */ +/* #undef HAVE_GNU_PTH */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* define to you inet_aton(3) is available */ +#define HAVE_INET_ATON 1 + +/* Define to 1 if you have the `inet_ntoa_b' function. */ +/* #undef HAVE_INET_NTOA_B */ + +/* Define to 1 if you have the `inet_ntop' function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `ioctl' function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* define if your system supports kqueue */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the `gen' library (-lgen). */ +/* #undef HAVE_LIBGEN */ + +/* Define to 1 if you have the `gmp' library (-lgmp). */ +/* #undef HAVE_LIBGMP */ + +/* Define to 1 if you have the `inet' library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* define if you have libtool -ltdl */ +/* #undef HAVE_LIBLTDL */ + +/* Define to 1 if you have the `net' library (-lnet). */ +/* #undef HAVE_LIBNET */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIBUTIL_H 1 + +/* Define to 1 if you have the `V3' library (-lV3). */ +/* #undef HAVE_LIBV3 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* if you have LinuxThreads */ +/* #undef HAVE_LINUX_THREADS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LTDL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mktemp' function. */ +#define HAVE_MKTEMP 1 + +/* define this if you have mkversion */ +#define HAVE_MKVERSION 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* define if strerror_r returns char* instead of int */ +/* #undef HAVE_NONPOSIX_STRERROR_R */ + +/* if you have NT Event Log */ +/* #undef HAVE_NT_EVENT_LOG */ + +/* if you have NT Service Manager */ +/* #undef HAVE_NT_SERVICE_MANAGER */ + +/* if you have NT Threads */ +/* #undef HAVE_NT_THREADS */ + +/* define if you have OpenSSL */ +#define HAVE_OPENSSL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_BN_H 1 + +/* define if you have OpenSSL with CRL checking capability */ +#define HAVE_OPENSSL_CRL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_CRYPTO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_SSL_H 1 + +/* Define to 1 if you have the `pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PSAP_H */ + +/* define to pthreads API spec revision */ +#define HAVE_PTHREADS 10 + +/* define if you have pthread_detach function */ +#define HAVE_PTHREAD_DETACH 1 + +/* Define to 1 if you have the `pthread_getconcurrency' function. */ +#define HAVE_PTHREAD_GETCONCURRENCY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_kill_other_threads_np' function. */ +/* #undef HAVE_PTHREAD_KILL_OTHER_THREADS_NP */ + +/* define if you have pthread_rwlock_destroy function */ +#define HAVE_PTHREAD_RWLOCK_DESTROY 1 + +/* Define to 1 if you have the `pthread_setconcurrency' function. */ +#define HAVE_PTHREAD_SETCONCURRENCY 1 + +/* Define to 1 if you have the `pthread_yield' function. */ +#define HAVE_PTHREAD_YIELD 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTH_H */ + +/* Define to 1 if the system has the type `ptrdiff_t'. */ +#define HAVE_PTRDIFF_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `read' function. */ +#define HAVE_READ 1 + +/* Define to 1 if you have the `recv' function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the `recvfrom' function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RESOLV_H */ + +/* define if you have res_query() */ +/* #undef HAVE_RES_QUERY */ + +/* define if OpenSSL needs RSAref */ +/* #undef HAVE_RSAREF */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_SASL_H */ + +/* define if your SASL library has sasl_version() */ +/* #undef HAVE_SASL_VERSION */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_yield' function. */ +#define HAVE_SCHED_YIELD 1 + +/* Define to 1 if you have the `send' function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the `sendmsg' function. */ +#define HAVE_SENDMSG 1 + +/* Define to 1 if you have the `sendto' function. */ +#define HAVE_SENDTO 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setpwfile' function. */ +/* #undef HAVE_SETPWFILE */ + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SGTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* Define to 1 if you have the `sigset' function. */ +#define HAVE_SIGSET 1 + +/* define if you have -lslp */ +/* #undef HAVE_SLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SLP_H */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* if you have spawnlp() */ +/* #undef HAVE_SPAWNLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQLEXT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strpbrk' function. */ +#define HAVE_STRPBRK 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strsep' function. */ +#define HAVE_STRSEP 1 + +/* Define to 1 if you have the `strspn' function. */ +#define HAVE_STRSPN 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +#define HAVE_STRTOQ 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the `strtouq' function. */ +#define HAVE_STRTOUQ 1 + +/* Define to 1 if `msg_accrightslen' is a member of `struct msghdr'. */ +/* #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN */ + +/* Define to 1 if `msg_control' is a member of `struct msghdr'. */ +/* #undef HAVE_STRUCT_MSGHDR_MSG_CONTROL */ + +/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_GECOS 1 + +/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_PASSWD 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_fstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE */ + +/* define to 1 if st_fstype is char * */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_CHAR */ + +/* define to 1 if st_fstype is int */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_INT */ + +/* Define to 1 if `st_vfstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_VFSTYPE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYNCH_H */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EPOLL_H */ + +/* define if you actually have sys_errlist in your libs */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FSTYP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PRIVGRP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UCRED_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UUID_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_VMOUNT_H */ + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* define if you have -lwrap */ +/* #undef HAVE_TCPD */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TCPD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* if you have Solaris LWP (thr) package */ +/* #undef HAVE_THR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `thr_getconcurrency' function. */ +/* #undef HAVE_THR_GETCONCURRENCY */ + +/* Define to 1 if you have the `thr_setconcurrency' function. */ +/* #undef HAVE_THR_SETCONCURRENCY */ + +/* Define to 1 if you have the `thr_yield' function. */ +/* #undef HAVE_THR_YIELD */ + +/* define if you have TLS */ +#define HAVE_TLS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* define if you have uuid_generate() */ +/* #undef HAVE_UUID_GENERATE */ + +/* define if you have uuid_to_str() */ +/* #undef HAVE_UUID_TO_STR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UUID_UUID_H */ + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* define if you have winsock */ +/* #undef HAVE_WINSOCK */ + +/* define if you have winsock2 */ +/* #undef HAVE_WINSOCK2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WIREDTIGER_H */ + +/* Define to 1 if you have the `write' function. */ +#define HAVE_WRITE 1 + +/* define if select implicitly yields */ +#define HAVE_YIELDING_SELECT 1 + +/* Define to 1 if you have the `_vsnprintf' function. */ +/* #undef HAVE__VSNPRINTF */ + +/* define to 32-bit or greater integer type */ +#define LBER_INT_T int + +/* define to large integer type */ +#define LBER_LEN_T long + +/* define to socket descriptor type */ +#define LBER_SOCKET_T int + +/* define to large integer type */ +#define LBER_TAG_T long + +/* define to 1 if library is thread safe */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* define to LDAP VENDOR VERSION */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +/* define this to add debugging code */ +/* #undef LDAP_DEBUG */ + +/* define if LDAP libs are dynamic */ +/* #undef LDAP_LIBS_DYNAMIC */ + +/* define to support PF_INET6 */ +#define LDAP_PF_INET6 1 + +/* define to support PF_LOCAL */ +#define LDAP_PF_LOCAL 1 + +/* define this to add SLAPI code */ +/* #undef LDAP_SLAPI */ + +/* define this to add syslog code */ +/* #undef LDAP_SYSLOG */ + +/* Version */ +#define LDAP_VENDOR_VERSION 20501 + +/* Major */ +#define LDAP_VENDOR_VERSION_MAJOR 2 + +/* Minor */ +#define LDAP_VENDOR_VERSION_MINOR 5 + +/* Patch */ +#define LDAP_VENDOR_VERSION_PATCH X + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* define if memcmp is not 8-bit clean or is otherwise broken */ +/* #undef NEED_MEMCMP_REPLACEMENT */ + +/* define if you have (or want) no threads */ +/* #undef NO_THREADS */ + +/* define to use the original debug style */ +/* #undef OLD_DEBUG */ + +/* Package */ +#define OPENLDAP_PACKAGE "OpenLDAP" + +/* Version */ +#define OPENLDAP_VERSION "2.5.X" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* define if sched_yield yields the entire process */ +/* #undef REPLACE_BROKEN_YIELD */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type of arg 1 for `select'. */ +#define SELECT_TYPE_ARG1 int + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#define SELECT_TYPE_ARG234 (fd_set *) + +/* Define to the type of arg 5 for `select'. */ +#define SELECT_TYPE_ARG5 (struct timeval *) + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* define to support per-object ACIs */ +/* #undef SLAPD_ACI_ENABLED */ + +/* define to support LDAP Async Metadirectory backend */ +/* #undef SLAPD_ASYNCMETA */ + +/* define to support cleartext passwords */ +/* #undef SLAPD_CLEARTEXT */ + +/* define to support crypt(3) passwords */ +/* #undef SLAPD_CRYPT */ + +/* define to support DNS SRV backend */ +/* #undef SLAPD_DNSSRV */ + +/* define to support LDAP backend */ +/* #undef SLAPD_LDAP */ + +/* define to support MDB backend */ +/* #undef SLAPD_MDB */ + +/* define to support LDAP Metadirectory backend */ +/* #undef SLAPD_META */ + +/* define to support modules */ +/* #undef SLAPD_MODULES */ + +/* dynamically linked module */ +#define SLAPD_MOD_DYNAMIC 2 + +/* statically linked module */ +#define SLAPD_MOD_STATIC 1 + +/* define to support cn=Monitor backend */ +/* #undef SLAPD_MONITOR */ + +/* define to support NDB backend */ +/* #undef SLAPD_NDB */ + +/* define to support NULL backend */ +/* #undef SLAPD_NULL */ + +/* define for In-Directory Access Logging overlay */ +/* #undef SLAPD_OVER_ACCESSLOG */ + +/* define for Audit Logging overlay */ +/* #undef SLAPD_OVER_AUDITLOG */ + +/* define for Automatic Certificate Authority overlay */ +/* #undef SLAPD_OVER_AUTOCA */ + +/* define for Collect overlay */ +/* #undef SLAPD_OVER_COLLECT */ + +/* define for Attribute Constraint overlay */ +/* #undef SLAPD_OVER_CONSTRAINT */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DDS */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DEREF */ + +/* define for Dynamic Group overlay */ +/* #undef SLAPD_OVER_DYNGROUP */ + +/* define for Dynamic List overlay */ +/* #undef SLAPD_OVER_DYNLIST */ + +/* define for Reverse Group Membership overlay */ +/* #undef SLAPD_OVER_MEMBEROF */ + +/* define for Password Policy overlay */ +/* #undef SLAPD_OVER_PPOLICY */ + +/* define for Proxy Cache overlay */ +/* #undef SLAPD_OVER_PROXYCACHE */ + +/* define for Referential Integrity overlay */ +/* #undef SLAPD_OVER_REFINT */ + +/* define for Return Code overlay */ +/* #undef SLAPD_OVER_RETCODE */ + +/* define for Rewrite/Remap overlay */ +/* #undef SLAPD_OVER_RWM */ + +/* define for Sequential Modify overlay */ +/* #undef SLAPD_OVER_SEQMOD */ + +/* define for ServerSideSort/VLV overlay */ +/* #undef SLAPD_OVER_SSSVLV */ + +/* define for Syncrepl Provider overlay */ +/* #undef SLAPD_OVER_SYNCPROV */ + +/* define for Translucent Proxy overlay */ +/* #undef SLAPD_OVER_TRANSLUCENT */ + +/* define for Attribute Uniqueness overlay */ +/* #undef SLAPD_OVER_UNIQUE */ + +/* define for Value Sorting overlay */ +/* #undef SLAPD_OVER_VALSORT */ + +/* define to support PASSWD backend */ +/* #undef SLAPD_PASSWD */ + +/* define to support PERL backend */ +/* #undef SLAPD_PERL */ + +/* define to support relay backend */ +/* #undef SLAPD_RELAY */ + +/* define to support reverse lookups */ +/* #undef SLAPD_RLOOKUPS */ + +/* define to support SHELL backend */ +/* #undef SLAPD_SHELL */ + +/* define to support SOCK backend */ +/* #undef SLAPD_SOCK */ + +/* define to support SASL passwords */ +/* #undef SLAPD_SPASSWD */ + +/* define to support SQL backend */ +/* #undef SLAPD_SQL */ + +/* define to support WiredTiger backend */ +/* #undef SLAPD_WT */ + +/* define to support run-time loadable ACL */ +/* #undef SLAP_DYNACL */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* set to urandom device */ +#define URANDOM_DEVICE "/dev/urandom" + +/* define to use OpenSSL BIGNUM for MP */ +/* #undef USE_MP_BIGNUM */ + +/* define to use GMP for MP */ +/* #undef USE_MP_GMP */ + +/* define to use 'long' for MP */ +/* #undef USE_MP_LONG */ + +/* define to use 'long long' for MP */ +/* #undef USE_MP_LONG_LONG */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to the type of arg 3 for `accept'. */ +#define ber_socklen_t socklen_t + +/* Define to `char *' if does not define. */ +/* #undef caddr_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `int' if does not define. */ +/* #undef sig_atomic_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +/* define to snprintf routine */ +/* #undef snprintf */ + +/* Define like ber_socklen_t if does not define. */ +/* #undef socklen_t */ + +/* Define to `signed int' if does not define. */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* define as empty if volatile is not supported */ +/* #undef volatile */ + +/* define to snprintf routine */ +/* #undef vsnprintf */ + + +/* begin of portable.h.post */ + +#ifdef _WIN32 +/* don't suck in all of the win32 api */ +# define WIN32_LEAN_AND_MEAN 1 +#endif + +#ifndef LDAP_NEEDS_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define LDAP_NEEDS_PROTOTYPES 1 +#endif + +#ifndef LDAP_REL_ENG +#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL) +#define LDAP_DEVEL +#endif +#if defined(LDAP_DEVEL) && !defined(LDAP_TEST) +#define LDAP_TEST +#endif +#endif + +#ifdef HAVE_STDDEF_H +# include +#endif + +#ifdef HAVE_EBCDIC +/* ASCII/EBCDIC converting replacements for stdio funcs + * vsnprintf and snprintf are used too, but they are already + * checked by the configure script + */ +#define fputs ber_pvt_fputs +#define fgets ber_pvt_fgets +#define printf ber_pvt_printf +#define fprintf ber_pvt_fprintf +#define vfprintf ber_pvt_vfprintf +#define vsprintf ber_pvt_vsprintf +#endif + +#include "ac/fdset.h" + +#include "ldap_cdefs.h" +#include "ldap_features.h" + +#include "ac/assert.h" +#include "ac/localize.h" + +#endif /* _LDAP_PORTABLE_H */ +/* end of portable.h.post */ + diff --git a/contrib/openldap-cmake/linux_aarch64/include/lber_types.h b/contrib/openldap-cmake/linux_aarch64/include/lber_types.h new file mode 100644 index 00000000000..dbd59430527 --- /dev/null +++ b/contrib/openldap-cmake/linux_aarch64/include/lber_types.h @@ -0,0 +1,63 @@ +/* include/lber_types.h. Generated from lber_types.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LBER types + */ + +#ifndef _LBER_TYPES_H +#define _LBER_TYPES_H + +#include + +LDAP_BEGIN_DECL + +/* LBER boolean, enum, integers (32 bits or larger) */ +#define LBER_INT_T int + +/* LBER tags (32 bits or larger) */ +#define LBER_TAG_T long + +/* LBER socket descriptor */ +#define LBER_SOCKET_T int + +/* LBER lengths (32 bits or larger) */ +#define LBER_LEN_T long + +/* ------------------------------------------------------------ */ + +/* booleans, enumerations, and integers */ +typedef LBER_INT_T ber_int_t; + +/* signed and unsigned versions */ +typedef signed LBER_INT_T ber_sint_t; +typedef unsigned LBER_INT_T ber_uint_t; + +/* tags */ +typedef unsigned LBER_TAG_T ber_tag_t; + +/* "socket" descriptors */ +typedef LBER_SOCKET_T ber_socket_t; + +/* lengths */ +typedef unsigned LBER_LEN_T ber_len_t; + +/* signed lengths */ +typedef signed LBER_LEN_T ber_slen_t; + +LDAP_END_DECL + +#endif /* _LBER_TYPES_H */ diff --git a/contrib/openldap-cmake/linux_aarch64/include/ldap_config.h b/contrib/openldap-cmake/linux_aarch64/include/ldap_config.h new file mode 100644 index 00000000000..89f7b40b884 --- /dev/null +++ b/contrib/openldap-cmake/linux_aarch64/include/ldap_config.h @@ -0,0 +1,74 @@ +/* include/ldap_config.h. Generated from ldap_config.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * This file works in conjunction with OpenLDAP configure system. + * If you do no like the values below, adjust your configure options. + */ + +#ifndef _LDAP_CONFIG_H +#define _LDAP_CONFIG_H + +/* directory separator */ +#ifndef LDAP_DIRSEP +#ifndef _WIN32 +#define LDAP_DIRSEP "/" +#else +#define LDAP_DIRSEP "\\" +#endif +#endif + +/* directory for temporary files */ +#if defined(_WIN32) +# define LDAP_TMPDIR "C:\\." /* we don't have much of a choice */ +#elif defined( _P_tmpdir ) +# define LDAP_TMPDIR _P_tmpdir +#elif defined( P_tmpdir ) +# define LDAP_TMPDIR P_tmpdir +#elif defined( _PATH_TMPDIR ) +# define LDAP_TMPDIR _PATH_TMPDIR +#else +# define LDAP_TMPDIR LDAP_DIRSEP "tmp" +#endif + +/* directories */ +#ifndef LDAP_BINDIR +#define LDAP_BINDIR "/tmp/ldap-prefix/bin" +#endif +#ifndef LDAP_SBINDIR +#define LDAP_SBINDIR "/tmp/ldap-prefix/sbin" +#endif +#ifndef LDAP_DATADIR +#define LDAP_DATADIR "/tmp/ldap-prefix/share/openldap" +#endif +#ifndef LDAP_SYSCONFDIR +#define LDAP_SYSCONFDIR "/tmp/ldap-prefix/etc/openldap" +#endif +#ifndef LDAP_LIBEXECDIR +#define LDAP_LIBEXECDIR "/tmp/ldap-prefix/libexec" +#endif +#ifndef LDAP_MODULEDIR +#define LDAP_MODULEDIR "/tmp/ldap-prefix/libexec/openldap" +#endif +#ifndef LDAP_RUNDIR +#define LDAP_RUNDIR "/tmp/ldap-prefix/var" +#endif +#ifndef LDAP_LOCALEDIR +#define LDAP_LOCALEDIR "" +#endif + + +#endif /* _LDAP_CONFIG_H */ diff --git a/contrib/openldap-cmake/linux_aarch64/include/ldap_features.h b/contrib/openldap-cmake/linux_aarch64/include/ldap_features.h new file mode 100644 index 00000000000..f0cc7c3626f --- /dev/null +++ b/contrib/openldap-cmake/linux_aarch64/include/ldap_features.h @@ -0,0 +1,61 @@ +/* include/ldap_features.h. Generated from ldap_features.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LDAP Features + */ + +#ifndef _LDAP_FEATURES_H +#define _LDAP_FEATURES_H 1 + +/* OpenLDAP API version macros */ +#define LDAP_VENDOR_VERSION 20501 +#define LDAP_VENDOR_VERSION_MAJOR 2 +#define LDAP_VENDOR_VERSION_MINOR 5 +#define LDAP_VENDOR_VERSION_PATCH X + +/* +** WORK IN PROGRESS! +** +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation is not thread-safe. +** +** The -lldap_r implementation is: +** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety) +** but also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is available at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definitions and declarations may be incorrect. +** +*/ + +/* is -lldap_r available or not */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* LDAP v2 Referrals */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +#endif /* LDAP_FEATURES */ diff --git a/contrib/openldap-cmake/linux_aarch64/include/portable.h b/contrib/openldap-cmake/linux_aarch64/include/portable.h new file mode 100644 index 00000000000..2924b6713a4 --- /dev/null +++ b/contrib/openldap-cmake/linux_aarch64/include/portable.h @@ -0,0 +1,1169 @@ +/* include/portable.h. Generated from portable.hin by configure. */ +/* include/portable.hin. Generated from configure.in by autoheader. */ + + +/* begin of portable.h.pre */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* define this if needed to get reentrant functions */ +#ifndef REENTRANT +#define REENTRANT 1 +#endif +#ifndef _REENTRANT +#define _REENTRANT 1 +#endif + +/* define this if needed to get threadsafe functions */ +#ifndef THREADSAFE +#define THREADSAFE 1 +#endif +#ifndef _THREADSAFE +#define _THREADSAFE 1 +#endif +#ifndef THREAD_SAFE +#define THREAD_SAFE 1 +#endif +#ifndef _THREAD_SAFE +#define _THREAD_SAFE 1 +#endif + +#ifndef _SGI_MP_SOURCE +#define _SGI_MP_SOURCE 1 +#endif + +/* end of portable.h.pre */ + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* define to use both and */ +/* #undef BOTH_STRINGS_H */ + +/* define if cross compiling */ +/* #undef CROSS_COMPILING */ + +/* set to the number of arguments ctime_r() expects */ +#define CTIME_R_NARGS 2 + +/* define if toupper() requires islower() */ +/* #undef C_UPPER_LOWER */ + +/* define if sys_errlist is not declared in stdio.h or errno.h */ +/* #undef DECL_SYS_ERRLIST */ + +/* define to enable slapi library */ +/* #undef ENABLE_SLAPI */ + +/* defined to be the EXE extension */ +#define EXEEXT "" + +/* set to the number of arguments gethostbyaddr_r() expects */ +#define GETHOSTBYADDR_R_NARGS 8 + +/* set to the number of arguments gethostbyname_r() expects */ +#define GETHOSTBYNAME_R_NARGS 6 + +/* Define to 1 if `TIOCGWINSZ' requires . */ +#define GWINSZ_IN_SYS_IOCTL 1 + +/* define if you have AIX security lib */ +/* #undef HAVE_AIX_SECURITY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_BITS_TYPES_H 1 + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `closesocket' function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* define if crypt(3) is available */ +/* #undef HAVE_CRYPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* define if crypt_r() is also available */ +/* #undef HAVE_CRYPT_R */ + +/* Define to 1 if you have the `ctime_r' function. */ +#define HAVE_CTIME_R 1 + +/* define if you have Cyrus SASL */ +/* #undef HAVE_CYRUS_SASL */ + +/* define if your system supports /dev/poll */ +/* #undef HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* define if system uses EBCDIC instead of ASCII */ +/* #undef HAVE_EBCDIC */ + +/* Define to 1 if you have the `endgrent' function. */ +#define HAVE_ENDGRENT 1 + +/* Define to 1 if you have the `endpwent' function. */ +#define HAVE_ENDPWENT 1 + +/* define if your system supports epoll */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* define if you actually have FreeBSD fetch(3) */ +/* #undef HAVE_FETCH */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FILIO_H */ + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getdtablesize' function. */ +#define HAVE_GETDTABLESIZE 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgrgid' function. */ +#define HAVE_GETGRGID 1 + +/* Define to 1 if you have the `gethostbyaddr_r' function. */ +#define HAVE_GETHOSTBYADDR_R 1 + +/* Define to 1 if you have the `gethostbyname_r' function. */ +#define HAVE_GETHOSTBYNAME_R 1 + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getpassphrase' function. */ +/* #undef HAVE_GETPASSPHRASE */ + +/* Define to 1 if you have the `getpeereid' function. */ +/* #undef HAVE_GETPEEREID */ + +/* Define to 1 if you have the `getpeerucred' function. */ +/* #undef HAVE_GETPEERUCRED */ + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getspnam' function. */ +#define HAVE_GETSPNAM 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GMP_H */ + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* define if you have GNUtls */ +/* #undef HAVE_GNUTLS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GNUTLS_GNUTLS_H */ + +/* if you have GNU Pth */ +/* #undef HAVE_GNU_PTH */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* define to you inet_aton(3) is available */ +#define HAVE_INET_ATON 1 + +/* Define to 1 if you have the `inet_ntoa_b' function. */ +/* #undef HAVE_INET_NTOA_B */ + +/* Define to 1 if you have the `inet_ntop' function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `ioctl' function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* define if your system supports kqueue */ +/* #undef HAVE_KQUEUE */ + +/* Define to 1 if you have the `gen' library (-lgen). */ +/* #undef HAVE_LIBGEN */ + +/* Define to 1 if you have the `gmp' library (-lgmp). */ +/* #undef HAVE_LIBGMP */ + +/* Define to 1 if you have the `inet' library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* define if you have libtool -ltdl */ +/* #undef HAVE_LIBLTDL */ + +/* Define to 1 if you have the `net' library (-lnet). */ +/* #undef HAVE_LIBNET */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define to 1 if you have the `V3' library (-lV3). */ +/* #undef HAVE_LIBV3 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* if you have LinuxThreads */ +/* #undef HAVE_LINUX_THREADS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LTDL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mktemp' function. */ +#define HAVE_MKTEMP 1 + +/* define this if you have mkversion */ +#define HAVE_MKVERSION 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* define if strerror_r returns char* instead of int */ +/* #undef HAVE_NONPOSIX_STRERROR_R */ + +/* if you have NT Event Log */ +/* #undef HAVE_NT_EVENT_LOG */ + +/* if you have NT Service Manager */ +/* #undef HAVE_NT_SERVICE_MANAGER */ + +/* if you have NT Threads */ +/* #undef HAVE_NT_THREADS */ + +/* define if you have OpenSSL */ +#define HAVE_OPENSSL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_BN_H 1 + +/* define if you have OpenSSL with CRL checking capability */ +#define HAVE_OPENSSL_CRL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_CRYPTO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_SSL_H 1 + +/* Define to 1 if you have the `pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PSAP_H */ + +/* define to pthreads API spec revision */ +#define HAVE_PTHREADS 10 + +/* define if you have pthread_detach function */ +#define HAVE_PTHREAD_DETACH 1 + +/* Define to 1 if you have the `pthread_getconcurrency' function. */ +#define HAVE_PTHREAD_GETCONCURRENCY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_kill_other_threads_np' function. */ +/* #undef HAVE_PTHREAD_KILL_OTHER_THREADS_NP */ + +/* define if you have pthread_rwlock_destroy function */ +#define HAVE_PTHREAD_RWLOCK_DESTROY 1 + +/* Define to 1 if you have the `pthread_setconcurrency' function. */ +#define HAVE_PTHREAD_SETCONCURRENCY 1 + +/* Define to 1 if you have the `pthread_yield' function. */ +#define HAVE_PTHREAD_YIELD 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTH_H */ + +/* Define to 1 if the system has the type `ptrdiff_t'. */ +#define HAVE_PTRDIFF_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `read' function. */ +#define HAVE_READ 1 + +/* Define to 1 if you have the `recv' function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the `recvfrom' function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RESOLV_H */ + +/* define if you have res_query() */ +/* #undef HAVE_RES_QUERY */ + +/* define if OpenSSL needs RSAref */ +/* #undef HAVE_RSAREF */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_SASL_H */ + +/* define if your SASL library has sasl_version() */ +/* #undef HAVE_SASL_VERSION */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_yield' function. */ +#define HAVE_SCHED_YIELD 1 + +/* Define to 1 if you have the `send' function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the `sendmsg' function. */ +#define HAVE_SENDMSG 1 + +/* Define to 1 if you have the `sendto' function. */ +#define HAVE_SENDTO 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setpwfile' function. */ +/* #undef HAVE_SETPWFILE */ + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SGTTY_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* Define to 1 if you have the `sigset' function. */ +#define HAVE_SIGSET 1 + +/* define if you have -lslp */ +/* #undef HAVE_SLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SLP_H */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* if you have spawnlp() */ +/* #undef HAVE_SPAWNLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQLEXT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strpbrk' function. */ +#define HAVE_STRPBRK 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strsep' function. */ +#define HAVE_STRSEP 1 + +/* Define to 1 if you have the `strspn' function. */ +#define HAVE_STRSPN 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +#define HAVE_STRTOQ 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the `strtouq' function. */ +#define HAVE_STRTOUQ 1 + +/* Define to 1 if `msg_accrightslen' is a member of `struct msghdr'. */ +/* #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN */ + +/* Define to 1 if `msg_control' is a member of `struct msghdr'. */ +#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1 + +/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_GECOS 1 + +/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_PASSWD 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_fstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE */ + +/* define to 1 if st_fstype is char * */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_CHAR */ + +/* define to 1 if st_fstype is int */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_INT */ + +/* Define to 1 if `st_vfstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_VFSTYPE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYNCH_H */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* define if you actually have sys_errlist in your libs */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EVENT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FILIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FSTYP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PRIVGRP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UCRED_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UUID_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_VMOUNT_H */ + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* define if you have -lwrap */ +/* #undef HAVE_TCPD */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TCPD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* if you have Solaris LWP (thr) package */ +/* #undef HAVE_THR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `thr_getconcurrency' function. */ +/* #undef HAVE_THR_GETCONCURRENCY */ + +/* Define to 1 if you have the `thr_setconcurrency' function. */ +/* #undef HAVE_THR_SETCONCURRENCY */ + +/* Define to 1 if you have the `thr_yield' function. */ +/* #undef HAVE_THR_YIELD */ + +/* define if you have TLS */ +#define HAVE_TLS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* define if you have uuid_generate() */ +/* #undef HAVE_UUID_GENERATE */ + +/* define if you have uuid_to_str() */ +/* #undef HAVE_UUID_TO_STR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UUID_UUID_H */ + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* define if you have winsock */ +/* #undef HAVE_WINSOCK */ + +/* define if you have winsock2 */ +/* #undef HAVE_WINSOCK2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WIREDTIGER_H */ + +/* Define to 1 if you have the `write' function. */ +#define HAVE_WRITE 1 + +/* define if select implicitly yields */ +#define HAVE_YIELDING_SELECT 1 + +/* Define to 1 if you have the `_vsnprintf' function. */ +/* #undef HAVE__VSNPRINTF */ + +/* define to 32-bit or greater integer type */ +#define LBER_INT_T int + +/* define to large integer type */ +#define LBER_LEN_T long + +/* define to socket descriptor type */ +#define LBER_SOCKET_T int + +/* define to large integer type */ +#define LBER_TAG_T long + +/* define to 1 if library is thread safe */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* define to LDAP VENDOR VERSION */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +/* define this to add debugging code */ +/* #undef LDAP_DEBUG */ + +/* define if LDAP libs are dynamic */ +/* #undef LDAP_LIBS_DYNAMIC */ + +/* define to support PF_INET6 */ +#define LDAP_PF_INET6 1 + +/* define to support PF_LOCAL */ +#define LDAP_PF_LOCAL 1 + +/* define this to add SLAPI code */ +/* #undef LDAP_SLAPI */ + +/* define this to add syslog code */ +/* #undef LDAP_SYSLOG */ + +/* Version */ +#define LDAP_VENDOR_VERSION 20501 + +/* Major */ +#define LDAP_VENDOR_VERSION_MAJOR 2 + +/* Minor */ +#define LDAP_VENDOR_VERSION_MINOR 5 + +/* Patch */ +#define LDAP_VENDOR_VERSION_PATCH X + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* define if memcmp is not 8-bit clean or is otherwise broken */ +/* #undef NEED_MEMCMP_REPLACEMENT */ + +/* define if you have (or want) no threads */ +/* #undef NO_THREADS */ + +/* define to use the original debug style */ +/* #undef OLD_DEBUG */ + +/* Package */ +#define OPENLDAP_PACKAGE "OpenLDAP" + +/* Version */ +#define OPENLDAP_VERSION "2.5.X" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* define if sched_yield yields the entire process */ +/* #undef REPLACE_BROKEN_YIELD */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type of arg 1 for `select'. */ +#define SELECT_TYPE_ARG1 int + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#define SELECT_TYPE_ARG234 (fd_set *) + +/* Define to the type of arg 5 for `select'. */ +#define SELECT_TYPE_ARG5 (struct timeval *) + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* define to support per-object ACIs */ +/* #undef SLAPD_ACI_ENABLED */ + +/* define to support LDAP Async Metadirectory backend */ +/* #undef SLAPD_ASYNCMETA */ + +/* define to support cleartext passwords */ +/* #undef SLAPD_CLEARTEXT */ + +/* define to support crypt(3) passwords */ +/* #undef SLAPD_CRYPT */ + +/* define to support DNS SRV backend */ +/* #undef SLAPD_DNSSRV */ + +/* define to support LDAP backend */ +/* #undef SLAPD_LDAP */ + +/* define to support MDB backend */ +/* #undef SLAPD_MDB */ + +/* define to support LDAP Metadirectory backend */ +/* #undef SLAPD_META */ + +/* define to support modules */ +/* #undef SLAPD_MODULES */ + +/* dynamically linked module */ +#define SLAPD_MOD_DYNAMIC 2 + +/* statically linked module */ +#define SLAPD_MOD_STATIC 1 + +/* define to support cn=Monitor backend */ +/* #undef SLAPD_MONITOR */ + +/* define to support NDB backend */ +/* #undef SLAPD_NDB */ + +/* define to support NULL backend */ +/* #undef SLAPD_NULL */ + +/* define for In-Directory Access Logging overlay */ +/* #undef SLAPD_OVER_ACCESSLOG */ + +/* define for Audit Logging overlay */ +/* #undef SLAPD_OVER_AUDITLOG */ + +/* define for Automatic Certificate Authority overlay */ +/* #undef SLAPD_OVER_AUTOCA */ + +/* define for Collect overlay */ +/* #undef SLAPD_OVER_COLLECT */ + +/* define for Attribute Constraint overlay */ +/* #undef SLAPD_OVER_CONSTRAINT */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DDS */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DEREF */ + +/* define for Dynamic Group overlay */ +/* #undef SLAPD_OVER_DYNGROUP */ + +/* define for Dynamic List overlay */ +/* #undef SLAPD_OVER_DYNLIST */ + +/* define for Reverse Group Membership overlay */ +/* #undef SLAPD_OVER_MEMBEROF */ + +/* define for Password Policy overlay */ +/* #undef SLAPD_OVER_PPOLICY */ + +/* define for Proxy Cache overlay */ +/* #undef SLAPD_OVER_PROXYCACHE */ + +/* define for Referential Integrity overlay */ +/* #undef SLAPD_OVER_REFINT */ + +/* define for Return Code overlay */ +/* #undef SLAPD_OVER_RETCODE */ + +/* define for Rewrite/Remap overlay */ +/* #undef SLAPD_OVER_RWM */ + +/* define for Sequential Modify overlay */ +/* #undef SLAPD_OVER_SEQMOD */ + +/* define for ServerSideSort/VLV overlay */ +/* #undef SLAPD_OVER_SSSVLV */ + +/* define for Syncrepl Provider overlay */ +/* #undef SLAPD_OVER_SYNCPROV */ + +/* define for Translucent Proxy overlay */ +/* #undef SLAPD_OVER_TRANSLUCENT */ + +/* define for Attribute Uniqueness overlay */ +/* #undef SLAPD_OVER_UNIQUE */ + +/* define for Value Sorting overlay */ +/* #undef SLAPD_OVER_VALSORT */ + +/* define to support PASSWD backend */ +/* #undef SLAPD_PASSWD */ + +/* define to support PERL backend */ +/* #undef SLAPD_PERL */ + +/* define to support relay backend */ +/* #undef SLAPD_RELAY */ + +/* define to support reverse lookups */ +/* #undef SLAPD_RLOOKUPS */ + +/* define to support SHELL backend */ +/* #undef SLAPD_SHELL */ + +/* define to support SOCK backend */ +/* #undef SLAPD_SOCK */ + +/* define to support SASL passwords */ +/* #undef SLAPD_SPASSWD */ + +/* define to support SQL backend */ +/* #undef SLAPD_SQL */ + +/* define to support WiredTiger backend */ +/* #undef SLAPD_WT */ + +/* define to support run-time loadable ACL */ +/* #undef SLAP_DYNACL */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* set to urandom device */ +#define URANDOM_DEVICE "/dev/urandom" + +/* define to use OpenSSL BIGNUM for MP */ +/* #undef USE_MP_BIGNUM */ + +/* define to use GMP for MP */ +/* #undef USE_MP_GMP */ + +/* define to use 'long' for MP */ +/* #undef USE_MP_LONG */ + +/* define to use 'long long' for MP */ +/* #undef USE_MP_LONG_LONG */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to the type of arg 3 for `accept'. */ +#define ber_socklen_t socklen_t + +/* Define to `char *' if does not define. */ +/* #undef caddr_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `int' if does not define. */ +/* #undef sig_atomic_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +/* define to snprintf routine */ +/* #undef snprintf */ + +/* Define like ber_socklen_t if does not define. */ +/* #undef socklen_t */ + +/* Define to `signed int' if does not define. */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* define as empty if volatile is not supported */ +/* #undef volatile */ + +/* define to snprintf routine */ +/* #undef vsnprintf */ + + +/* begin of portable.h.post */ + +#ifdef _WIN32 +/* don't suck in all of the win32 api */ +# define WIN32_LEAN_AND_MEAN 1 +#endif + +#ifndef LDAP_NEEDS_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define LDAP_NEEDS_PROTOTYPES 1 +#endif + +#ifndef LDAP_REL_ENG +#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL) +#define LDAP_DEVEL +#endif +#if defined(LDAP_DEVEL) && !defined(LDAP_TEST) +#define LDAP_TEST +#endif +#endif + +#ifdef HAVE_STDDEF_H +# include +#endif + +#ifdef HAVE_EBCDIC +/* ASCII/EBCDIC converting replacements for stdio funcs + * vsnprintf and snprintf are used too, but they are already + * checked by the configure script + */ +#define fputs ber_pvt_fputs +#define fgets ber_pvt_fgets +#define printf ber_pvt_printf +#define fprintf ber_pvt_fprintf +#define vfprintf ber_pvt_vfprintf +#define vsprintf ber_pvt_vsprintf +#endif + +#include "ac/fdset.h" + +#include "ldap_cdefs.h" +#include "ldap_features.h" + +#include "ac/assert.h" +#include "ac/localize.h" + +#endif /* _LDAP_PORTABLE_H */ +/* end of portable.h.post */ + diff --git a/contrib/openldap-cmake/linux_x86_64/include/lber_types.h b/contrib/openldap-cmake/linux_x86_64/include/lber_types.h new file mode 100644 index 00000000000..dbd59430527 --- /dev/null +++ b/contrib/openldap-cmake/linux_x86_64/include/lber_types.h @@ -0,0 +1,63 @@ +/* include/lber_types.h. Generated from lber_types.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LBER types + */ + +#ifndef _LBER_TYPES_H +#define _LBER_TYPES_H + +#include + +LDAP_BEGIN_DECL + +/* LBER boolean, enum, integers (32 bits or larger) */ +#define LBER_INT_T int + +/* LBER tags (32 bits or larger) */ +#define LBER_TAG_T long + +/* LBER socket descriptor */ +#define LBER_SOCKET_T int + +/* LBER lengths (32 bits or larger) */ +#define LBER_LEN_T long + +/* ------------------------------------------------------------ */ + +/* booleans, enumerations, and integers */ +typedef LBER_INT_T ber_int_t; + +/* signed and unsigned versions */ +typedef signed LBER_INT_T ber_sint_t; +typedef unsigned LBER_INT_T ber_uint_t; + +/* tags */ +typedef unsigned LBER_TAG_T ber_tag_t; + +/* "socket" descriptors */ +typedef LBER_SOCKET_T ber_socket_t; + +/* lengths */ +typedef unsigned LBER_LEN_T ber_len_t; + +/* signed lengths */ +typedef signed LBER_LEN_T ber_slen_t; + +LDAP_END_DECL + +#endif /* _LBER_TYPES_H */ diff --git a/contrib/openldap-cmake/linux_x86_64/include/ldap_config.h b/contrib/openldap-cmake/linux_x86_64/include/ldap_config.h new file mode 100644 index 00000000000..89f7b40b884 --- /dev/null +++ b/contrib/openldap-cmake/linux_x86_64/include/ldap_config.h @@ -0,0 +1,74 @@ +/* include/ldap_config.h. Generated from ldap_config.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * This file works in conjunction with OpenLDAP configure system. + * If you do no like the values below, adjust your configure options. + */ + +#ifndef _LDAP_CONFIG_H +#define _LDAP_CONFIG_H + +/* directory separator */ +#ifndef LDAP_DIRSEP +#ifndef _WIN32 +#define LDAP_DIRSEP "/" +#else +#define LDAP_DIRSEP "\\" +#endif +#endif + +/* directory for temporary files */ +#if defined(_WIN32) +# define LDAP_TMPDIR "C:\\." /* we don't have much of a choice */ +#elif defined( _P_tmpdir ) +# define LDAP_TMPDIR _P_tmpdir +#elif defined( P_tmpdir ) +# define LDAP_TMPDIR P_tmpdir +#elif defined( _PATH_TMPDIR ) +# define LDAP_TMPDIR _PATH_TMPDIR +#else +# define LDAP_TMPDIR LDAP_DIRSEP "tmp" +#endif + +/* directories */ +#ifndef LDAP_BINDIR +#define LDAP_BINDIR "/tmp/ldap-prefix/bin" +#endif +#ifndef LDAP_SBINDIR +#define LDAP_SBINDIR "/tmp/ldap-prefix/sbin" +#endif +#ifndef LDAP_DATADIR +#define LDAP_DATADIR "/tmp/ldap-prefix/share/openldap" +#endif +#ifndef LDAP_SYSCONFDIR +#define LDAP_SYSCONFDIR "/tmp/ldap-prefix/etc/openldap" +#endif +#ifndef LDAP_LIBEXECDIR +#define LDAP_LIBEXECDIR "/tmp/ldap-prefix/libexec" +#endif +#ifndef LDAP_MODULEDIR +#define LDAP_MODULEDIR "/tmp/ldap-prefix/libexec/openldap" +#endif +#ifndef LDAP_RUNDIR +#define LDAP_RUNDIR "/tmp/ldap-prefix/var" +#endif +#ifndef LDAP_LOCALEDIR +#define LDAP_LOCALEDIR "" +#endif + + +#endif /* _LDAP_CONFIG_H */ diff --git a/contrib/openldap-cmake/linux_x86_64/include/ldap_features.h b/contrib/openldap-cmake/linux_x86_64/include/ldap_features.h new file mode 100644 index 00000000000..f0cc7c3626f --- /dev/null +++ b/contrib/openldap-cmake/linux_x86_64/include/ldap_features.h @@ -0,0 +1,61 @@ +/* include/ldap_features.h. Generated from ldap_features.hin by configure. */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +/* + * LDAP Features + */ + +#ifndef _LDAP_FEATURES_H +#define _LDAP_FEATURES_H 1 + +/* OpenLDAP API version macros */ +#define LDAP_VENDOR_VERSION 20501 +#define LDAP_VENDOR_VERSION_MAJOR 2 +#define LDAP_VENDOR_VERSION_MINOR 5 +#define LDAP_VENDOR_VERSION_PATCH X + +/* +** WORK IN PROGRESS! +** +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation is not thread-safe. +** +** The -lldap_r implementation is: +** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety) +** but also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is available at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definitions and declarations may be incorrect. +** +*/ + +/* is -lldap_r available or not */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* LDAP v2 Referrals */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +#endif /* LDAP_FEATURES */ diff --git a/contrib/openldap-cmake/linux_x86_64/include/portable.h b/contrib/openldap-cmake/linux_x86_64/include/portable.h new file mode 100644 index 00000000000..2924b6713a4 --- /dev/null +++ b/contrib/openldap-cmake/linux_x86_64/include/portable.h @@ -0,0 +1,1169 @@ +/* include/portable.h. Generated from portable.hin by configure. */ +/* include/portable.hin. Generated from configure.in by autoheader. */ + + +/* begin of portable.h.pre */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2020 The OpenLDAP Foundation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* define this if needed to get reentrant functions */ +#ifndef REENTRANT +#define REENTRANT 1 +#endif +#ifndef _REENTRANT +#define _REENTRANT 1 +#endif + +/* define this if needed to get threadsafe functions */ +#ifndef THREADSAFE +#define THREADSAFE 1 +#endif +#ifndef _THREADSAFE +#define _THREADSAFE 1 +#endif +#ifndef THREAD_SAFE +#define THREAD_SAFE 1 +#endif +#ifndef _THREAD_SAFE +#define _THREAD_SAFE 1 +#endif + +#ifndef _SGI_MP_SOURCE +#define _SGI_MP_SOURCE 1 +#endif + +/* end of portable.h.pre */ + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* define to use both and */ +/* #undef BOTH_STRINGS_H */ + +/* define if cross compiling */ +/* #undef CROSS_COMPILING */ + +/* set to the number of arguments ctime_r() expects */ +#define CTIME_R_NARGS 2 + +/* define if toupper() requires islower() */ +/* #undef C_UPPER_LOWER */ + +/* define if sys_errlist is not declared in stdio.h or errno.h */ +/* #undef DECL_SYS_ERRLIST */ + +/* define to enable slapi library */ +/* #undef ENABLE_SLAPI */ + +/* defined to be the EXE extension */ +#define EXEEXT "" + +/* set to the number of arguments gethostbyaddr_r() expects */ +#define GETHOSTBYADDR_R_NARGS 8 + +/* set to the number of arguments gethostbyname_r() expects */ +#define GETHOSTBYNAME_R_NARGS 6 + +/* Define to 1 if `TIOCGWINSZ' requires . */ +#define GWINSZ_IN_SYS_IOCTL 1 + +/* define if you have AIX security lib */ +/* #undef HAVE_AIX_SECURITY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_BITS_TYPES_H 1 + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `closesocket' function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* define if crypt(3) is available */ +/* #undef HAVE_CRYPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* define if crypt_r() is also available */ +/* #undef HAVE_CRYPT_R */ + +/* Define to 1 if you have the `ctime_r' function. */ +#define HAVE_CTIME_R 1 + +/* define if you have Cyrus SASL */ +/* #undef HAVE_CYRUS_SASL */ + +/* define if your system supports /dev/poll */ +/* #undef HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* define if system uses EBCDIC instead of ASCII */ +/* #undef HAVE_EBCDIC */ + +/* Define to 1 if you have the `endgrent' function. */ +#define HAVE_ENDGRENT 1 + +/* Define to 1 if you have the `endpwent' function. */ +#define HAVE_ENDPWENT 1 + +/* define if your system supports epoll */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* define if you actually have FreeBSD fetch(3) */ +/* #undef HAVE_FETCH */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FILIO_H */ + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getdtablesize' function. */ +#define HAVE_GETDTABLESIZE 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgrgid' function. */ +#define HAVE_GETGRGID 1 + +/* Define to 1 if you have the `gethostbyaddr_r' function. */ +#define HAVE_GETHOSTBYADDR_R 1 + +/* Define to 1 if you have the `gethostbyname_r' function. */ +#define HAVE_GETHOSTBYNAME_R 1 + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getpassphrase' function. */ +/* #undef HAVE_GETPASSPHRASE */ + +/* Define to 1 if you have the `getpeereid' function. */ +/* #undef HAVE_GETPEEREID */ + +/* Define to 1 if you have the `getpeerucred' function. */ +/* #undef HAVE_GETPEERUCRED */ + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getspnam' function. */ +#define HAVE_GETSPNAM 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GMP_H */ + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* define if you have GNUtls */ +/* #undef HAVE_GNUTLS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GNUTLS_GNUTLS_H */ + +/* if you have GNU Pth */ +/* #undef HAVE_GNU_PTH */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* define to you inet_aton(3) is available */ +#define HAVE_INET_ATON 1 + +/* Define to 1 if you have the `inet_ntoa_b' function. */ +/* #undef HAVE_INET_NTOA_B */ + +/* Define to 1 if you have the `inet_ntop' function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `ioctl' function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* define if your system supports kqueue */ +/* #undef HAVE_KQUEUE */ + +/* Define to 1 if you have the `gen' library (-lgen). */ +/* #undef HAVE_LIBGEN */ + +/* Define to 1 if you have the `gmp' library (-lgmp). */ +/* #undef HAVE_LIBGMP */ + +/* Define to 1 if you have the `inet' library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* define if you have libtool -ltdl */ +/* #undef HAVE_LIBLTDL */ + +/* Define to 1 if you have the `net' library (-lnet). */ +/* #undef HAVE_LIBNET */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define to 1 if you have the `V3' library (-lV3). */ +/* #undef HAVE_LIBV3 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* if you have LinuxThreads */ +/* #undef HAVE_LINUX_THREADS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LTDL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mktemp' function. */ +#define HAVE_MKTEMP 1 + +/* define this if you have mkversion */ +#define HAVE_MKVERSION 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* define if strerror_r returns char* instead of int */ +/* #undef HAVE_NONPOSIX_STRERROR_R */ + +/* if you have NT Event Log */ +/* #undef HAVE_NT_EVENT_LOG */ + +/* if you have NT Service Manager */ +/* #undef HAVE_NT_SERVICE_MANAGER */ + +/* if you have NT Threads */ +/* #undef HAVE_NT_THREADS */ + +/* define if you have OpenSSL */ +#define HAVE_OPENSSL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_BN_H 1 + +/* define if you have OpenSSL with CRL checking capability */ +#define HAVE_OPENSSL_CRL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_CRYPTO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_SSL_H 1 + +/* Define to 1 if you have the `pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PSAP_H */ + +/* define to pthreads API spec revision */ +#define HAVE_PTHREADS 10 + +/* define if you have pthread_detach function */ +#define HAVE_PTHREAD_DETACH 1 + +/* Define to 1 if you have the `pthread_getconcurrency' function. */ +#define HAVE_PTHREAD_GETCONCURRENCY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_kill_other_threads_np' function. */ +/* #undef HAVE_PTHREAD_KILL_OTHER_THREADS_NP */ + +/* define if you have pthread_rwlock_destroy function */ +#define HAVE_PTHREAD_RWLOCK_DESTROY 1 + +/* Define to 1 if you have the `pthread_setconcurrency' function. */ +#define HAVE_PTHREAD_SETCONCURRENCY 1 + +/* Define to 1 if you have the `pthread_yield' function. */ +#define HAVE_PTHREAD_YIELD 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTH_H */ + +/* Define to 1 if the system has the type `ptrdiff_t'. */ +#define HAVE_PTRDIFF_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `read' function. */ +#define HAVE_READ 1 + +/* Define to 1 if you have the `recv' function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the `recvfrom' function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RESOLV_H */ + +/* define if you have res_query() */ +/* #undef HAVE_RES_QUERY */ + +/* define if OpenSSL needs RSAref */ +/* #undef HAVE_RSAREF */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SASL_SASL_H */ + +/* define if your SASL library has sasl_version() */ +/* #undef HAVE_SASL_VERSION */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_yield' function. */ +#define HAVE_SCHED_YIELD 1 + +/* Define to 1 if you have the `send' function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the `sendmsg' function. */ +#define HAVE_SENDMSG 1 + +/* Define to 1 if you have the `sendto' function. */ +#define HAVE_SENDTO 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setpwfile' function. */ +/* #undef HAVE_SETPWFILE */ + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SGTTY_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* Define to 1 if you have the `sigset' function. */ +#define HAVE_SIGSET 1 + +/* define if you have -lslp */ +/* #undef HAVE_SLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SLP_H */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* if you have spawnlp() */ +/* #undef HAVE_SPAWNLP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQLEXT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SQL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strpbrk' function. */ +#define HAVE_STRPBRK 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strsep' function. */ +#define HAVE_STRSEP 1 + +/* Define to 1 if you have the `strspn' function. */ +#define HAVE_STRSPN 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +#define HAVE_STRTOQ 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the `strtouq' function. */ +#define HAVE_STRTOUQ 1 + +/* Define to 1 if `msg_accrightslen' is a member of `struct msghdr'. */ +/* #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN */ + +/* Define to 1 if `msg_control' is a member of `struct msghdr'. */ +#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1 + +/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_GECOS 1 + +/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_PASSWD 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_fstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE */ + +/* define to 1 if st_fstype is char * */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_CHAR */ + +/* define to 1 if st_fstype is int */ +/* #undef HAVE_STRUCT_STAT_ST_FSTYPE_INT */ + +/* Define to 1 if `st_vfstype' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_VFSTYPE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYNCH_H */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* define if you actually have sys_errlist in your libs */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EVENT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FILIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FSTYP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PRIVGRP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UCRED_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UUID_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_VMOUNT_H */ + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* define if you have -lwrap */ +/* #undef HAVE_TCPD */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TCPD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* if you have Solaris LWP (thr) package */ +/* #undef HAVE_THR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `thr_getconcurrency' function. */ +/* #undef HAVE_THR_GETCONCURRENCY */ + +/* Define to 1 if you have the `thr_setconcurrency' function. */ +/* #undef HAVE_THR_SETCONCURRENCY */ + +/* Define to 1 if you have the `thr_yield' function. */ +/* #undef HAVE_THR_YIELD */ + +/* define if you have TLS */ +#define HAVE_TLS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* define if you have uuid_generate() */ +/* #undef HAVE_UUID_GENERATE */ + +/* define if you have uuid_to_str() */ +/* #undef HAVE_UUID_TO_STR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UUID_UUID_H */ + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* define if you have winsock */ +/* #undef HAVE_WINSOCK */ + +/* define if you have winsock2 */ +/* #undef HAVE_WINSOCK2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WIREDTIGER_H */ + +/* Define to 1 if you have the `write' function. */ +#define HAVE_WRITE 1 + +/* define if select implicitly yields */ +#define HAVE_YIELDING_SELECT 1 + +/* Define to 1 if you have the `_vsnprintf' function. */ +/* #undef HAVE__VSNPRINTF */ + +/* define to 32-bit or greater integer type */ +#define LBER_INT_T int + +/* define to large integer type */ +#define LBER_LEN_T long + +/* define to socket descriptor type */ +#define LBER_SOCKET_T int + +/* define to large integer type */ +#define LBER_TAG_T long + +/* define to 1 if library is thread safe */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 + +/* define to LDAP VENDOR VERSION */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + +/* define this to add debugging code */ +/* #undef LDAP_DEBUG */ + +/* define if LDAP libs are dynamic */ +/* #undef LDAP_LIBS_DYNAMIC */ + +/* define to support PF_INET6 */ +#define LDAP_PF_INET6 1 + +/* define to support PF_LOCAL */ +#define LDAP_PF_LOCAL 1 + +/* define this to add SLAPI code */ +/* #undef LDAP_SLAPI */ + +/* define this to add syslog code */ +/* #undef LDAP_SYSLOG */ + +/* Version */ +#define LDAP_VENDOR_VERSION 20501 + +/* Major */ +#define LDAP_VENDOR_VERSION_MAJOR 2 + +/* Minor */ +#define LDAP_VENDOR_VERSION_MINOR 5 + +/* Patch */ +#define LDAP_VENDOR_VERSION_PATCH X + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* define if memcmp is not 8-bit clean or is otherwise broken */ +/* #undef NEED_MEMCMP_REPLACEMENT */ + +/* define if you have (or want) no threads */ +/* #undef NO_THREADS */ + +/* define to use the original debug style */ +/* #undef OLD_DEBUG */ + +/* Package */ +#define OPENLDAP_PACKAGE "OpenLDAP" + +/* Version */ +#define OPENLDAP_VERSION "2.5.X" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* define if sched_yield yields the entire process */ +/* #undef REPLACE_BROKEN_YIELD */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type of arg 1 for `select'. */ +#define SELECT_TYPE_ARG1 int + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#define SELECT_TYPE_ARG234 (fd_set *) + +/* Define to the type of arg 5 for `select'. */ +#define SELECT_TYPE_ARG5 (struct timeval *) + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* define to support per-object ACIs */ +/* #undef SLAPD_ACI_ENABLED */ + +/* define to support LDAP Async Metadirectory backend */ +/* #undef SLAPD_ASYNCMETA */ + +/* define to support cleartext passwords */ +/* #undef SLAPD_CLEARTEXT */ + +/* define to support crypt(3) passwords */ +/* #undef SLAPD_CRYPT */ + +/* define to support DNS SRV backend */ +/* #undef SLAPD_DNSSRV */ + +/* define to support LDAP backend */ +/* #undef SLAPD_LDAP */ + +/* define to support MDB backend */ +/* #undef SLAPD_MDB */ + +/* define to support LDAP Metadirectory backend */ +/* #undef SLAPD_META */ + +/* define to support modules */ +/* #undef SLAPD_MODULES */ + +/* dynamically linked module */ +#define SLAPD_MOD_DYNAMIC 2 + +/* statically linked module */ +#define SLAPD_MOD_STATIC 1 + +/* define to support cn=Monitor backend */ +/* #undef SLAPD_MONITOR */ + +/* define to support NDB backend */ +/* #undef SLAPD_NDB */ + +/* define to support NULL backend */ +/* #undef SLAPD_NULL */ + +/* define for In-Directory Access Logging overlay */ +/* #undef SLAPD_OVER_ACCESSLOG */ + +/* define for Audit Logging overlay */ +/* #undef SLAPD_OVER_AUDITLOG */ + +/* define for Automatic Certificate Authority overlay */ +/* #undef SLAPD_OVER_AUTOCA */ + +/* define for Collect overlay */ +/* #undef SLAPD_OVER_COLLECT */ + +/* define for Attribute Constraint overlay */ +/* #undef SLAPD_OVER_CONSTRAINT */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DDS */ + +/* define for Dynamic Directory Services overlay */ +/* #undef SLAPD_OVER_DEREF */ + +/* define for Dynamic Group overlay */ +/* #undef SLAPD_OVER_DYNGROUP */ + +/* define for Dynamic List overlay */ +/* #undef SLAPD_OVER_DYNLIST */ + +/* define for Reverse Group Membership overlay */ +/* #undef SLAPD_OVER_MEMBEROF */ + +/* define for Password Policy overlay */ +/* #undef SLAPD_OVER_PPOLICY */ + +/* define for Proxy Cache overlay */ +/* #undef SLAPD_OVER_PROXYCACHE */ + +/* define for Referential Integrity overlay */ +/* #undef SLAPD_OVER_REFINT */ + +/* define for Return Code overlay */ +/* #undef SLAPD_OVER_RETCODE */ + +/* define for Rewrite/Remap overlay */ +/* #undef SLAPD_OVER_RWM */ + +/* define for Sequential Modify overlay */ +/* #undef SLAPD_OVER_SEQMOD */ + +/* define for ServerSideSort/VLV overlay */ +/* #undef SLAPD_OVER_SSSVLV */ + +/* define for Syncrepl Provider overlay */ +/* #undef SLAPD_OVER_SYNCPROV */ + +/* define for Translucent Proxy overlay */ +/* #undef SLAPD_OVER_TRANSLUCENT */ + +/* define for Attribute Uniqueness overlay */ +/* #undef SLAPD_OVER_UNIQUE */ + +/* define for Value Sorting overlay */ +/* #undef SLAPD_OVER_VALSORT */ + +/* define to support PASSWD backend */ +/* #undef SLAPD_PASSWD */ + +/* define to support PERL backend */ +/* #undef SLAPD_PERL */ + +/* define to support relay backend */ +/* #undef SLAPD_RELAY */ + +/* define to support reverse lookups */ +/* #undef SLAPD_RLOOKUPS */ + +/* define to support SHELL backend */ +/* #undef SLAPD_SHELL */ + +/* define to support SOCK backend */ +/* #undef SLAPD_SOCK */ + +/* define to support SASL passwords */ +/* #undef SLAPD_SPASSWD */ + +/* define to support SQL backend */ +/* #undef SLAPD_SQL */ + +/* define to support WiredTiger backend */ +/* #undef SLAPD_WT */ + +/* define to support run-time loadable ACL */ +/* #undef SLAP_DYNACL */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* set to urandom device */ +#define URANDOM_DEVICE "/dev/urandom" + +/* define to use OpenSSL BIGNUM for MP */ +/* #undef USE_MP_BIGNUM */ + +/* define to use GMP for MP */ +/* #undef USE_MP_GMP */ + +/* define to use 'long' for MP */ +/* #undef USE_MP_LONG */ + +/* define to use 'long long' for MP */ +/* #undef USE_MP_LONG_LONG */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to the type of arg 3 for `accept'. */ +#define ber_socklen_t socklen_t + +/* Define to `char *' if does not define. */ +/* #undef caddr_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `int' if does not define. */ +/* #undef sig_atomic_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +/* define to snprintf routine */ +/* #undef snprintf */ + +/* Define like ber_socklen_t if does not define. */ +/* #undef socklen_t */ + +/* Define to `signed int' if does not define. */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* define as empty if volatile is not supported */ +/* #undef volatile */ + +/* define to snprintf routine */ +/* #undef vsnprintf */ + + +/* begin of portable.h.post */ + +#ifdef _WIN32 +/* don't suck in all of the win32 api */ +# define WIN32_LEAN_AND_MEAN 1 +#endif + +#ifndef LDAP_NEEDS_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define LDAP_NEEDS_PROTOTYPES 1 +#endif + +#ifndef LDAP_REL_ENG +#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL) +#define LDAP_DEVEL +#endif +#if defined(LDAP_DEVEL) && !defined(LDAP_TEST) +#define LDAP_TEST +#endif +#endif + +#ifdef HAVE_STDDEF_H +# include +#endif + +#ifdef HAVE_EBCDIC +/* ASCII/EBCDIC converting replacements for stdio funcs + * vsnprintf and snprintf are used too, but they are already + * checked by the configure script + */ +#define fputs ber_pvt_fputs +#define fgets ber_pvt_fgets +#define printf ber_pvt_printf +#define fprintf ber_pvt_fprintf +#define vfprintf ber_pvt_vfprintf +#define vsprintf ber_pvt_vsprintf +#endif + +#include "ac/fdset.h" + +#include "ldap_cdefs.h" +#include "ldap_features.h" + +#include "ac/assert.h" +#include "ac/localize.h" + +#endif /* _LDAP_PORTABLE_H */ +/* end of portable.h.post */ + diff --git a/contrib/poco b/contrib/poco index 7d605a1ae5d..be2ab90ba5d 160000 --- a/contrib/poco +++ b/contrib/poco @@ -1 +1 @@ -Subproject commit 7d605a1ae5d878294f91f68feb62ae51e9a04426 +Subproject commit be2ab90ba5dccd46919a116e3fe4fa77bb85063b diff --git a/contrib/poco-cmake/CMakeLists.txt b/contrib/poco-cmake/CMakeLists.txt new file mode 100644 index 00000000000..59b6c84a1d1 --- /dev/null +++ b/contrib/poco-cmake/CMakeLists.txt @@ -0,0 +1,19 @@ +option (USE_INTERNAL_POCO_LIBRARY "Use internal Poco library" ${NOT_UNBUNDLED}) + +if (USE_INTERNAL_POCO_LIBRARY) + set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/poco) +else () + find_path (ROOT_DIR NAMES Foundation/include/Poco/Poco.h include/Poco/Poco.h) +endif () + +add_subdirectory (Crypto) +add_subdirectory (Data) +add_subdirectory (Data/ODBC) +add_subdirectory (Foundation) +add_subdirectory (JSON) +add_subdirectory (MongoDB) +add_subdirectory (Net) +add_subdirectory (Net/SSL) +add_subdirectory (Redis) +add_subdirectory (Util) +add_subdirectory (XML) diff --git a/contrib/poco-cmake/Crypto/CMakeLists.txt b/contrib/poco-cmake/Crypto/CMakeLists.txt new file mode 100644 index 00000000000..468f1641510 --- /dev/null +++ b/contrib/poco-cmake/Crypto/CMakeLists.txt @@ -0,0 +1,51 @@ +if (ENABLE_SSL) + if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/Crypto/src/Cipher.cpp + ${LIBRARY_DIR}/Crypto/src/CipherFactory.cpp + ${LIBRARY_DIR}/Crypto/src/CipherImpl.cpp + ${LIBRARY_DIR}/Crypto/src/CipherKey.cpp + ${LIBRARY_DIR}/Crypto/src/CipherKeyImpl.cpp + ${LIBRARY_DIR}/Crypto/src/CryptoException.cpp + ${LIBRARY_DIR}/Crypto/src/CryptoStream.cpp + ${LIBRARY_DIR}/Crypto/src/CryptoTransform.cpp + ${LIBRARY_DIR}/Crypto/src/DigestEngine.cpp + ${LIBRARY_DIR}/Crypto/src/ECDSADigestEngine.cpp + ${LIBRARY_DIR}/Crypto/src/ECKey.cpp + ${LIBRARY_DIR}/Crypto/src/ECKeyImpl.cpp + ${LIBRARY_DIR}/Crypto/src/EVPPKey.cpp + ${LIBRARY_DIR}/Crypto/src/KeyPair.cpp + ${LIBRARY_DIR}/Crypto/src/KeyPairImpl.cpp + ${LIBRARY_DIR}/Crypto/src/OpenSSLInitializer.cpp + ${LIBRARY_DIR}/Crypto/src/PKCS12Container.cpp + ${LIBRARY_DIR}/Crypto/src/RSACipherImpl.cpp + ${LIBRARY_DIR}/Crypto/src/RSADigestEngine.cpp + ${LIBRARY_DIR}/Crypto/src/RSAKey.cpp + ${LIBRARY_DIR}/Crypto/src/RSAKeyImpl.cpp + ${LIBRARY_DIR}/Crypto/src/X509Certificate.cpp + ) + + add_library (_poco_crypto ${SRCS}) + add_library (Poco::Crypto ALIAS _poco_crypto) + + target_compile_options (_poco_crypto PRIVATE -Wno-newline-eof) + target_include_directories (_poco_crypto SYSTEM PUBLIC ${LIBRARY_DIR}/Crypto/include) + target_link_libraries (_poco_crypto PUBLIC Poco::Foundation ssl) + else () + add_library (Poco::Crypto UNKNOWN IMPORTED GLOBAL) + + find_library(LIBRARY_POCO_CRYPTO PocoCrypto) + find_path(INCLUDE_POCO_CRYPTO Poco/Crypto/Crypto.h) + set_target_properties (Poco::Crypto PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_CRYPTO}) + set_target_properties (Poco::Crypto PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_CRYPTO}) + + target_link_libraries (Poco::Crypto INTERFACE Poco::Foundation) + endif () + + message (STATUS "Using Poco::Crypto") +else () + add_library (_poco_crypto INTERFACE) + add_library (Poco::Crypto ALIAS _poco_crypto) + + message (STATUS "Not using Poco::Crypto") +endif () diff --git a/contrib/poco-cmake/Data/CMakeLists.txt b/contrib/poco-cmake/Data/CMakeLists.txt new file mode 100644 index 00000000000..1c185df8961 --- /dev/null +++ b/contrib/poco-cmake/Data/CMakeLists.txt @@ -0,0 +1,60 @@ +if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/Data/src/AbstractBinder.cpp + ${LIBRARY_DIR}/Data/src/AbstractBinding.cpp + ${LIBRARY_DIR}/Data/src/AbstractExtraction.cpp + ${LIBRARY_DIR}/Data/src/AbstractExtractor.cpp + ${LIBRARY_DIR}/Data/src/AbstractPreparation.cpp + ${LIBRARY_DIR}/Data/src/AbstractPreparator.cpp + ${LIBRARY_DIR}/Data/src/ArchiveStrategy.cpp + ${LIBRARY_DIR}/Data/src/Bulk.cpp + ${LIBRARY_DIR}/Data/src/Connector.cpp + ${LIBRARY_DIR}/Data/src/DataException.cpp + ${LIBRARY_DIR}/Data/src/Date.cpp + ${LIBRARY_DIR}/Data/src/DynamicLOB.cpp + ${LIBRARY_DIR}/Data/src/Limit.cpp + ${LIBRARY_DIR}/Data/src/MetaColumn.cpp + ${LIBRARY_DIR}/Data/src/PooledSessionHolder.cpp + ${LIBRARY_DIR}/Data/src/PooledSessionImpl.cpp + ${LIBRARY_DIR}/Data/src/Position.cpp + ${LIBRARY_DIR}/Data/src/Range.cpp + ${LIBRARY_DIR}/Data/src/RecordSet.cpp + ${LIBRARY_DIR}/Data/src/Row.cpp + ${LIBRARY_DIR}/Data/src/RowFilter.cpp + ${LIBRARY_DIR}/Data/src/RowFormatter.cpp + ${LIBRARY_DIR}/Data/src/RowIterator.cpp + ${LIBRARY_DIR}/Data/src/Session.cpp + ${LIBRARY_DIR}/Data/src/SessionFactory.cpp + ${LIBRARY_DIR}/Data/src/SessionImpl.cpp + ${LIBRARY_DIR}/Data/src/SessionPool.cpp + ${LIBRARY_DIR}/Data/src/SessionPoolContainer.cpp + ${LIBRARY_DIR}/Data/src/SimpleRowFormatter.cpp + ${LIBRARY_DIR}/Data/src/SQLChannel.cpp + ${LIBRARY_DIR}/Data/src/Statement.cpp + ${LIBRARY_DIR}/Data/src/StatementCreator.cpp + ${LIBRARY_DIR}/Data/src/StatementImpl.cpp + ${LIBRARY_DIR}/Data/src/Time.cpp + ${LIBRARY_DIR}/Data/src/Transaction.cpp + ) + + add_library (_poco_data ${SRCS}) + add_library (Poco::Data ALIAS _poco_data) + + if (COMPILER_GCC) + target_compile_options (_poco_data PRIVATE -Wno-deprecated-copy) + endif () + target_include_directories (_poco_data SYSTEM PUBLIC ${LIBRARY_DIR}/Data/include) + target_link_libraries (_poco_data PUBLIC Poco::Foundation) +else () + # NOTE: don't know why, but the GLOBAL is required here. + add_library (Poco::Data UNKNOWN IMPORTED GLOBAL) + + find_library(LIBRARY_POCO_DATA PocoData) + find_path(INCLUDE_POCO_DATA Poco/Data/Data.h) + set_target_properties (Poco::Data PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_DATA}) + set_target_properties (Poco::Data PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_DATA}) + + target_link_libraries (Poco::Data INTERFACE Poco::Foundation) + + message (STATUS "Using Poco::Data: ${LIBRARY_POCO_DATA} ${INCLUDE_POCO_DATA}") +endif () diff --git a/contrib/poco-cmake/Data/ODBC/CMakeLists.txt b/contrib/poco-cmake/Data/ODBC/CMakeLists.txt new file mode 100644 index 00000000000..a0e4f83a7cc --- /dev/null +++ b/contrib/poco-cmake/Data/ODBC/CMakeLists.txt @@ -0,0 +1,44 @@ +if (ENABLE_ODBC) + if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/Data/ODBC/src/Binder.cpp + ${LIBRARY_DIR}/Data/ODBC/src/ConnectionHandle.cpp + ${LIBRARY_DIR}/Data/ODBC/src/Connector.cpp + ${LIBRARY_DIR}/Data/ODBC/src/EnvironmentHandle.cpp + ${LIBRARY_DIR}/Data/ODBC/src/Extractor.cpp + ${LIBRARY_DIR}/Data/ODBC/src/ODBCException.cpp + ${LIBRARY_DIR}/Data/ODBC/src/ODBCMetaColumn.cpp + ${LIBRARY_DIR}/Data/ODBC/src/ODBCStatementImpl.cpp + ${LIBRARY_DIR}/Data/ODBC/src/Parameter.cpp + ${LIBRARY_DIR}/Data/ODBC/src/Preparator.cpp + ${LIBRARY_DIR}/Data/ODBC/src/SessionImpl.cpp + ${LIBRARY_DIR}/Data/ODBC/src/TypeInfo.cpp + ${LIBRARY_DIR}/Data/ODBC/src/Unicode.cpp + ${LIBRARY_DIR}/Data/ODBC/src/Utility.cpp + ) + + add_library (_poco_data_odbc ${SRCS}) + add_library (Poco::Data::ODBC ALIAS _poco_data_odbc) + + target_compile_options (_poco_data_odbc PRIVATE -Wno-unused-variable) + target_include_directories (_poco_data_odbc SYSTEM PUBLIC ${LIBRARY_DIR}/Data/ODBC/include) + target_link_libraries (_poco_data_odbc PUBLIC Poco::Data unixodbc) + else () + add_library (Poco::Data::ODBC UNKNOWN IMPORTED) + + find_library(LIBRARY_POCO_DATA_ODBC PocoDataODBC) + find_path(INCLUDE_POCO_DATA_ODBC Poco/Data/ODBC/ODBC.h) + set_target_properties (Poco::Data::ODBC PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_DATA_ODBC}) + set_target_properties (Poco::Data::ODBC PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_DATA_ODBC}) + + target_link_libraries (Poco::Data::ODBC INTERFACE Poco::Data) + endif () + + message (STATUS "Using Poco::Data::ODBC") +else () + add_library (_poco_data_odbc INTERFACE) + add_library (Poco::Data::ODBC ALIAS _poco_data_odbc) + target_link_libraries (_poco_data_odbc INTERFACE unixodbc) + + message (STATUS "Not using Poco::Data::ODBC") +endif () diff --git a/contrib/poco-cmake/Foundation/CMakeLists.txt b/contrib/poco-cmake/Foundation/CMakeLists.txt new file mode 100644 index 00000000000..740fe53db1b --- /dev/null +++ b/contrib/poco-cmake/Foundation/CMakeLists.txt @@ -0,0 +1,235 @@ +if (USE_INTERNAL_POCO_LIBRARY) + # Foundation (pcre) + + set (SRCS_PCRE + ${LIBRARY_DIR}/Foundation/src/pcre_config.c + ${LIBRARY_DIR}/Foundation/src/pcre_byte_order.c + ${LIBRARY_DIR}/Foundation/src/pcre_chartables.c + ${LIBRARY_DIR}/Foundation/src/pcre_compile.c + ${LIBRARY_DIR}/Foundation/src/pcre_exec.c + ${LIBRARY_DIR}/Foundation/src/pcre_fullinfo.c + ${LIBRARY_DIR}/Foundation/src/pcre_globals.c + ${LIBRARY_DIR}/Foundation/src/pcre_maketables.c + ${LIBRARY_DIR}/Foundation/src/pcre_newline.c + ${LIBRARY_DIR}/Foundation/src/pcre_ord2utf8.c + ${LIBRARY_DIR}/Foundation/src/pcre_study.c + ${LIBRARY_DIR}/Foundation/src/pcre_tables.c + ${LIBRARY_DIR}/Foundation/src/pcre_dfa_exec.c + ${LIBRARY_DIR}/Foundation/src/pcre_get.c + ${LIBRARY_DIR}/Foundation/src/pcre_jit_compile.c + ${LIBRARY_DIR}/Foundation/src/pcre_refcount.c + ${LIBRARY_DIR}/Foundation/src/pcre_string_utils.c + ${LIBRARY_DIR}/Foundation/src/pcre_version.c + ${LIBRARY_DIR}/Foundation/src/pcre_ucd.c + ${LIBRARY_DIR}/Foundation/src/pcre_valid_utf8.c + ${LIBRARY_DIR}/Foundation/src/pcre_xclass.c + ) + + add_library (_poco_foundation_pcre ${SRCS_PCRE}) + add_library (Poco::Foundation::PCRE ALIAS _poco_foundation_pcre) + + target_compile_options (_poco_foundation_pcre PRIVATE -Wno-sign-compare) + + # Foundation + + set (SRCS + ${LIBRARY_DIR}/Foundation/src/AbstractObserver.cpp + ${LIBRARY_DIR}/Foundation/src/ActiveDispatcher.cpp + ${LIBRARY_DIR}/Foundation/src/ArchiveStrategy.cpp + ${LIBRARY_DIR}/Foundation/src/Ascii.cpp + ${LIBRARY_DIR}/Foundation/src/ASCIIEncoding.cpp + ${LIBRARY_DIR}/Foundation/src/AsyncChannel.cpp + ${LIBRARY_DIR}/Foundation/src/AtomicCounter.cpp + ${LIBRARY_DIR}/Foundation/src/Base32Decoder.cpp + ${LIBRARY_DIR}/Foundation/src/Base32Encoder.cpp + ${LIBRARY_DIR}/Foundation/src/Base64Decoder.cpp + ${LIBRARY_DIR}/Foundation/src/Base64Encoder.cpp + ${LIBRARY_DIR}/Foundation/src/BinaryReader.cpp + ${LIBRARY_DIR}/Foundation/src/BinaryWriter.cpp + ${LIBRARY_DIR}/Foundation/src/Bugcheck.cpp + ${LIBRARY_DIR}/Foundation/src/ByteOrder.cpp + ${LIBRARY_DIR}/Foundation/src/Channel.cpp + ${LIBRARY_DIR}/Foundation/src/Checksum.cpp + ${LIBRARY_DIR}/Foundation/src/Clock.cpp + ${LIBRARY_DIR}/Foundation/src/Condition.cpp + ${LIBRARY_DIR}/Foundation/src/Configurable.cpp + ${LIBRARY_DIR}/Foundation/src/ConsoleChannel.cpp + ${LIBRARY_DIR}/Foundation/src/CountingStream.cpp + ${LIBRARY_DIR}/Foundation/src/DateTime.cpp + ${LIBRARY_DIR}/Foundation/src/DateTimeFormat.cpp + ${LIBRARY_DIR}/Foundation/src/DateTimeFormatter.cpp + ${LIBRARY_DIR}/Foundation/src/DateTimeParser.cpp + ${LIBRARY_DIR}/Foundation/src/Debugger.cpp + ${LIBRARY_DIR}/Foundation/src/DeflatingStream.cpp + ${LIBRARY_DIR}/Foundation/src/DigestEngine.cpp + ${LIBRARY_DIR}/Foundation/src/DigestStream.cpp + ${LIBRARY_DIR}/Foundation/src/DirectoryIterator.cpp + ${LIBRARY_DIR}/Foundation/src/DirectoryIteratorStrategy.cpp + ${LIBRARY_DIR}/Foundation/src/DirectoryWatcher.cpp + ${LIBRARY_DIR}/Foundation/src/Environment.cpp + ${LIBRARY_DIR}/Foundation/src/Error.cpp + ${LIBRARY_DIR}/Foundation/src/ErrorHandler.cpp + ${LIBRARY_DIR}/Foundation/src/Event.cpp + ${LIBRARY_DIR}/Foundation/src/EventArgs.cpp + ${LIBRARY_DIR}/Foundation/src/EventChannel.cpp + ${LIBRARY_DIR}/Foundation/src/Exception.cpp + ${LIBRARY_DIR}/Foundation/src/FIFOBufferStream.cpp + ${LIBRARY_DIR}/Foundation/src/File.cpp + ${LIBRARY_DIR}/Foundation/src/FileChannel.cpp + ${LIBRARY_DIR}/Foundation/src/FileStream.cpp + ${LIBRARY_DIR}/Foundation/src/FileStreamFactory.cpp + ${LIBRARY_DIR}/Foundation/src/Format.cpp + ${LIBRARY_DIR}/Foundation/src/Formatter.cpp + ${LIBRARY_DIR}/Foundation/src/FormattingChannel.cpp + ${LIBRARY_DIR}/Foundation/src/FPEnvironment.cpp + ${LIBRARY_DIR}/Foundation/src/Glob.cpp + ${LIBRARY_DIR}/Foundation/src/Hash.cpp + ${LIBRARY_DIR}/Foundation/src/HashStatistic.cpp + ${LIBRARY_DIR}/Foundation/src/HexBinaryDecoder.cpp + ${LIBRARY_DIR}/Foundation/src/HexBinaryEncoder.cpp + ${LIBRARY_DIR}/Foundation/src/InflatingStream.cpp + ${LIBRARY_DIR}/Foundation/src/JSONString.cpp + ${LIBRARY_DIR}/Foundation/src/Latin1Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/Latin2Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/Latin9Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/LineEndingConverter.cpp + ${LIBRARY_DIR}/Foundation/src/LocalDateTime.cpp + ${LIBRARY_DIR}/Foundation/src/LogFile.cpp + ${LIBRARY_DIR}/Foundation/src/Logger.cpp + ${LIBRARY_DIR}/Foundation/src/LoggingFactory.cpp + ${LIBRARY_DIR}/Foundation/src/LoggingRegistry.cpp + ${LIBRARY_DIR}/Foundation/src/LogStream.cpp + ${LIBRARY_DIR}/Foundation/src/Manifest.cpp + ${LIBRARY_DIR}/Foundation/src/MD4Engine.cpp + ${LIBRARY_DIR}/Foundation/src/MD5Engine.cpp + ${LIBRARY_DIR}/Foundation/src/MemoryPool.cpp + ${LIBRARY_DIR}/Foundation/src/MemoryStream.cpp + ${LIBRARY_DIR}/Foundation/src/Message.cpp + ${LIBRARY_DIR}/Foundation/src/Mutex.cpp + ${LIBRARY_DIR}/Foundation/src/NamedEvent.cpp + ${LIBRARY_DIR}/Foundation/src/NamedMutex.cpp + ${LIBRARY_DIR}/Foundation/src/NestedDiagnosticContext.cpp + ${LIBRARY_DIR}/Foundation/src/Notification.cpp + ${LIBRARY_DIR}/Foundation/src/NotificationCenter.cpp + ${LIBRARY_DIR}/Foundation/src/NotificationQueue.cpp + ${LIBRARY_DIR}/Foundation/src/NullChannel.cpp + ${LIBRARY_DIR}/Foundation/src/NullStream.cpp + ${LIBRARY_DIR}/Foundation/src/NumberFormatter.cpp + ${LIBRARY_DIR}/Foundation/src/NumberParser.cpp + ${LIBRARY_DIR}/Foundation/src/NumericString.cpp + ${LIBRARY_DIR}/Foundation/src/Path.cpp + ${LIBRARY_DIR}/Foundation/src/PatternFormatter.cpp + ${LIBRARY_DIR}/Foundation/src/Pipe.cpp + ${LIBRARY_DIR}/Foundation/src/PipeImpl.cpp + ${LIBRARY_DIR}/Foundation/src/PipeStream.cpp + ${LIBRARY_DIR}/Foundation/src/PriorityNotificationQueue.cpp + ${LIBRARY_DIR}/Foundation/src/Process.cpp + ${LIBRARY_DIR}/Foundation/src/PurgeStrategy.cpp + ${LIBRARY_DIR}/Foundation/src/Random.cpp + ${LIBRARY_DIR}/Foundation/src/RandomStream.cpp + ${LIBRARY_DIR}/Foundation/src/RefCountedObject.cpp + ${LIBRARY_DIR}/Foundation/src/RegularExpression.cpp + ${LIBRARY_DIR}/Foundation/src/RotateStrategy.cpp + ${LIBRARY_DIR}/Foundation/src/Runnable.cpp + ${LIBRARY_DIR}/Foundation/src/RWLock.cpp + ${LIBRARY_DIR}/Foundation/src/Semaphore.cpp + ${LIBRARY_DIR}/Foundation/src/SHA1Engine.cpp + ${LIBRARY_DIR}/Foundation/src/SharedLibrary.cpp + ${LIBRARY_DIR}/Foundation/src/SharedMemory.cpp + ${LIBRARY_DIR}/Foundation/src/SignalHandler.cpp + ${LIBRARY_DIR}/Foundation/src/SimpleFileChannel.cpp + ${LIBRARY_DIR}/Foundation/src/SortedDirectoryIterator.cpp + ${LIBRARY_DIR}/Foundation/src/SplitterChannel.cpp + ${LIBRARY_DIR}/Foundation/src/Stopwatch.cpp + ${LIBRARY_DIR}/Foundation/src/StreamChannel.cpp + ${LIBRARY_DIR}/Foundation/src/StreamConverter.cpp + ${LIBRARY_DIR}/Foundation/src/StreamCopier.cpp + ${LIBRARY_DIR}/Foundation/src/StreamTokenizer.cpp + ${LIBRARY_DIR}/Foundation/src/String.cpp + ${LIBRARY_DIR}/Foundation/src/StringTokenizer.cpp + ${LIBRARY_DIR}/Foundation/src/SynchronizedObject.cpp + ${LIBRARY_DIR}/Foundation/src/SyslogChannel.cpp + ${LIBRARY_DIR}/Foundation/src/Task.cpp + ${LIBRARY_DIR}/Foundation/src/TaskManager.cpp + ${LIBRARY_DIR}/Foundation/src/TaskNotification.cpp + ${LIBRARY_DIR}/Foundation/src/TeeStream.cpp + ${LIBRARY_DIR}/Foundation/src/TemporaryFile.cpp + ${LIBRARY_DIR}/Foundation/src/TextBufferIterator.cpp + ${LIBRARY_DIR}/Foundation/src/TextConverter.cpp + ${LIBRARY_DIR}/Foundation/src/TextEncoding.cpp + ${LIBRARY_DIR}/Foundation/src/TextIterator.cpp + ${LIBRARY_DIR}/Foundation/src/Thread.cpp + ${LIBRARY_DIR}/Foundation/src/ThreadLocal.cpp + ${LIBRARY_DIR}/Foundation/src/ThreadPool.cpp + ${LIBRARY_DIR}/Foundation/src/ThreadTarget.cpp + ${LIBRARY_DIR}/Foundation/src/TimedNotificationQueue.cpp + ${LIBRARY_DIR}/Foundation/src/Timer.cpp + ${LIBRARY_DIR}/Foundation/src/Timespan.cpp + ${LIBRARY_DIR}/Foundation/src/Timestamp.cpp + ${LIBRARY_DIR}/Foundation/src/Timezone.cpp + ${LIBRARY_DIR}/Foundation/src/Token.cpp + ${LIBRARY_DIR}/Foundation/src/Unicode.cpp + ${LIBRARY_DIR}/Foundation/src/UnicodeConverter.cpp + ${LIBRARY_DIR}/Foundation/src/URI.cpp + ${LIBRARY_DIR}/Foundation/src/URIStreamFactory.cpp + ${LIBRARY_DIR}/Foundation/src/URIStreamOpener.cpp + ${LIBRARY_DIR}/Foundation/src/UTF16Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/UTF32Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/UTF8Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/UTF8String.cpp + ${LIBRARY_DIR}/Foundation/src/UUID.cpp + ${LIBRARY_DIR}/Foundation/src/UUIDGenerator.cpp + ${LIBRARY_DIR}/Foundation/src/Var.cpp + ${LIBRARY_DIR}/Foundation/src/VarHolder.cpp + ${LIBRARY_DIR}/Foundation/src/VarIterator.cpp + ${LIBRARY_DIR}/Foundation/src/Void.cpp + ${LIBRARY_DIR}/Foundation/src/Windows1250Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/Windows1251Encoding.cpp + ${LIBRARY_DIR}/Foundation/src/Windows1252Encoding.cpp + ) + + add_library (_poco_foundation ${SRCS}) + add_library (Poco::Foundation ALIAS _poco_foundation) + + if (COMPILER_GCC) + target_compile_options (_poco_foundation + PRIVATE + -Wno-suggest-override + ) + elseif (COMPILER_CLANG) + target_compile_options (_poco_foundation + PRIVATE + -Wno-atomic-implicit-seq-cst + -Wno-deprecated + -Wno-extra-semi-stmt + -Wno-zero-as-null-pointer-constant + -Wno-implicit-int-float-conversion + -Wno-thread-safety-analysis + -Wno-thread-safety-negative + ) + endif () + target_compile_options (_poco_foundation + PRIVATE + -Wno-sign-compare + -Wno-unused-parameter + ) + target_compile_definitions (_poco_foundation + PRIVATE + POCO_UNBUNDLED + POCO_UNBUNDLED_ZLIB + PUBLIC + POCO_ENABLE_CPP11 + POCO_OS_FAMILY_UNIX + ) + target_include_directories (_poco_foundation SYSTEM PUBLIC ${LIBRARY_DIR}/Foundation/include) + target_link_libraries (_poco_foundation PRIVATE Poco::Foundation::PCRE zlib) +else () + add_library (Poco::Foundation UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_FOUNDATION PocoFoundation) + find_path (INCLUDE_POCO_FOUNDATION Poco/Foundation.h) + set_target_properties (Poco::Foundation PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_FOUNDATION}) + set_target_properties (Poco::Foundation PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_FOUNDATION}) + + message (STATUS "Using Poco::Foundation: ${LIBRARY_POCO_FOUNDATION} ${INCLUDE_POCO_FOUNDATION}") +endif () diff --git a/contrib/poco-cmake/JSON/CMakeLists.txt b/contrib/poco-cmake/JSON/CMakeLists.txt new file mode 100644 index 00000000000..89054cf225d --- /dev/null +++ b/contrib/poco-cmake/JSON/CMakeLists.txt @@ -0,0 +1,42 @@ +if (USE_INTERNAL_POCO_LIBRARY) + # Poco::JSON (pdjson) + + set (SRCS_PDJSON + ${LIBRARY_DIR}/JSON/src/pdjson.c + ) + + add_library (_poco_json_pdjson ${SRCS_PDJSON}) + add_library (Poco::JSON::Pdjson ALIAS _poco_json_pdjson) + + # Poco::JSON + + set (SRCS + ${LIBRARY_DIR}/JSON/src/Array.cpp + ${LIBRARY_DIR}/JSON/src/Handler.cpp + ${LIBRARY_DIR}/JSON/src/JSONException.cpp + ${LIBRARY_DIR}/JSON/src/Object.cpp + ${LIBRARY_DIR}/JSON/src/ParseHandler.cpp + ${LIBRARY_DIR}/JSON/src/Parser.cpp + ${LIBRARY_DIR}/JSON/src/ParserImpl.cpp + ${LIBRARY_DIR}/JSON/src/PrintHandler.cpp + ${LIBRARY_DIR}/JSON/src/Query.cpp + ${LIBRARY_DIR}/JSON/src/Stringifier.cpp + ${LIBRARY_DIR}/JSON/src/Template.cpp + ${LIBRARY_DIR}/JSON/src/TemplateCache.cpp + ) + + add_library (_poco_json ${SRCS}) + add_library (Poco::JSON ALIAS _poco_json) + + target_include_directories (_poco_json SYSTEM PUBLIC ${LIBRARY_DIR}/JSON/include) + target_link_libraries (_poco_json PUBLIC Poco::Foundation Poco::JSON::Pdjson) +else () + add_library (Poco::JSON UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_JSON PocoJSON) + find_path (INCLUDE_POCO_JSON Poco/JSON/JSON.h) + set_target_properties (Poco::JSON PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_JSON}) + set_target_properties (Poco::JSON PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_JSON}) + + message (STATUS "Using Poco::JSON: ${LIBRARY_POCO_JSON} ${INCLUDE_POCO_JSON}") +endif () diff --git a/contrib/poco-cmake/MongoDB/CMakeLists.txt b/contrib/poco-cmake/MongoDB/CMakeLists.txt new file mode 100644 index 00000000000..0d79f680a64 --- /dev/null +++ b/contrib/poco-cmake/MongoDB/CMakeLists.txt @@ -0,0 +1,40 @@ +if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/MongoDB/src/Array.cpp + ${LIBRARY_DIR}/MongoDB/src/Binary.cpp + ${LIBRARY_DIR}/MongoDB/src/Connection.cpp + ${LIBRARY_DIR}/MongoDB/src/Cursor.cpp + ${LIBRARY_DIR}/MongoDB/src/Database.cpp + ${LIBRARY_DIR}/MongoDB/src/DeleteRequest.cpp + ${LIBRARY_DIR}/MongoDB/src/Document.cpp + ${LIBRARY_DIR}/MongoDB/src/Element.cpp + ${LIBRARY_DIR}/MongoDB/src/GetMoreRequest.cpp + ${LIBRARY_DIR}/MongoDB/src/InsertRequest.cpp + ${LIBRARY_DIR}/MongoDB/src/JavaScriptCode.cpp + ${LIBRARY_DIR}/MongoDB/src/KillCursorsRequest.cpp + ${LIBRARY_DIR}/MongoDB/src/Message.cpp + ${LIBRARY_DIR}/MongoDB/src/MessageHeader.cpp + ${LIBRARY_DIR}/MongoDB/src/ObjectId.cpp + ${LIBRARY_DIR}/MongoDB/src/QueryRequest.cpp + ${LIBRARY_DIR}/MongoDB/src/RegularExpression.cpp + ${LIBRARY_DIR}/MongoDB/src/ReplicaSet.cpp + ${LIBRARY_DIR}/MongoDB/src/RequestMessage.cpp + ${LIBRARY_DIR}/MongoDB/src/ResponseMessage.cpp + ${LIBRARY_DIR}/MongoDB/src/UpdateRequest.cpp + ) + + add_library (_poco_mongodb ${SRCS}) + add_library (Poco::MongoDB ALIAS _poco_mongodb) + + target_include_directories (_poco_mongodb SYSTEM PUBLIC ${LIBRARY_DIR}/MongoDB/include) + target_link_libraries (_poco_mongodb PUBLIC Poco::Net) +else () + add_library (Poco::MongoDB UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_MONGODB PocoMongoDB) + find_path (INCLUDE_POCO_MONGODB Poco/MongoDB/MongoDB.h) + set_target_properties (Poco::MongoDB PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_MONGODB}) + set_target_properties (Poco::MongoDB PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_MONGODB}) + + message (STATUS "Using Poco::MongoDB: ${LIBRARY_POCO_MONGODB} ${INCLUDE_POCO_MONGODB}") +endif () diff --git a/contrib/poco-cmake/Net/CMakeLists.txt b/contrib/poco-cmake/Net/CMakeLists.txt new file mode 100644 index 00000000000..9bc06e52e05 --- /dev/null +++ b/contrib/poco-cmake/Net/CMakeLists.txt @@ -0,0 +1,139 @@ +if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/Net/src/AbstractHTTPRequestHandler.cpp + ${LIBRARY_DIR}/Net/src/DatagramSocket.cpp + ${LIBRARY_DIR}/Net/src/DatagramSocketImpl.cpp + ${LIBRARY_DIR}/Net/src/DialogSocket.cpp + ${LIBRARY_DIR}/Net/src/DNS.cpp + ${LIBRARY_DIR}/Net/src/FilePartSource.cpp + ${LIBRARY_DIR}/Net/src/FTPClientSession.cpp + ${LIBRARY_DIR}/Net/src/FTPStreamFactory.cpp + ${LIBRARY_DIR}/Net/src/HostEntry.cpp + ${LIBRARY_DIR}/Net/src/HTMLForm.cpp + ${LIBRARY_DIR}/Net/src/HTTPAuthenticationParams.cpp + ${LIBRARY_DIR}/Net/src/HTTPBasicCredentials.cpp + ${LIBRARY_DIR}/Net/src/HTTPBufferAllocator.cpp + ${LIBRARY_DIR}/Net/src/HTTPChunkedStream.cpp + ${LIBRARY_DIR}/Net/src/HTTPClientSession.cpp + ${LIBRARY_DIR}/Net/src/HTTPCookie.cpp + ${LIBRARY_DIR}/Net/src/HTTPCredentials.cpp + ${LIBRARY_DIR}/Net/src/HTTPDigestCredentials.cpp + ${LIBRARY_DIR}/Net/src/HTTPFixedLengthStream.cpp + ${LIBRARY_DIR}/Net/src/HTTPHeaderStream.cpp + ${LIBRARY_DIR}/Net/src/HTTPIOStream.cpp + ${LIBRARY_DIR}/Net/src/HTTPMessage.cpp + ${LIBRARY_DIR}/Net/src/HTTPRequest.cpp + ${LIBRARY_DIR}/Net/src/HTTPRequestHandler.cpp + ${LIBRARY_DIR}/Net/src/HTTPRequestHandlerFactory.cpp + ${LIBRARY_DIR}/Net/src/HTTPResponse.cpp + ${LIBRARY_DIR}/Net/src/HTTPServer.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerConnection.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerConnectionFactory.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerParams.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerRequest.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerRequestImpl.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerResponse.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerResponseImpl.cpp + ${LIBRARY_DIR}/Net/src/HTTPServerSession.cpp + ${LIBRARY_DIR}/Net/src/HTTPSession.cpp + ${LIBRARY_DIR}/Net/src/HTTPSessionFactory.cpp + ${LIBRARY_DIR}/Net/src/HTTPSessionInstantiator.cpp + ${LIBRARY_DIR}/Net/src/HTTPStream.cpp + ${LIBRARY_DIR}/Net/src/HTTPStreamFactory.cpp + ${LIBRARY_DIR}/Net/src/ICMPClient.cpp + ${LIBRARY_DIR}/Net/src/ICMPEventArgs.cpp + ${LIBRARY_DIR}/Net/src/ICMPPacket.cpp + ${LIBRARY_DIR}/Net/src/ICMPPacketImpl.cpp + ${LIBRARY_DIR}/Net/src/ICMPSocket.cpp + ${LIBRARY_DIR}/Net/src/ICMPSocketImpl.cpp + ${LIBRARY_DIR}/Net/src/ICMPv4PacketImpl.cpp + ${LIBRARY_DIR}/Net/src/IPAddress.cpp + ${LIBRARY_DIR}/Net/src/IPAddressImpl.cpp + ${LIBRARY_DIR}/Net/src/MailMessage.cpp + ${LIBRARY_DIR}/Net/src/MailRecipient.cpp + ${LIBRARY_DIR}/Net/src/MailStream.cpp + ${LIBRARY_DIR}/Net/src/MediaType.cpp + ${LIBRARY_DIR}/Net/src/MessageHeader.cpp + ${LIBRARY_DIR}/Net/src/MulticastSocket.cpp + ${LIBRARY_DIR}/Net/src/MultipartReader.cpp + ${LIBRARY_DIR}/Net/src/MultipartWriter.cpp + ${LIBRARY_DIR}/Net/src/NameValueCollection.cpp + ${LIBRARY_DIR}/Net/src/Net.cpp + ${LIBRARY_DIR}/Net/src/NetException.cpp + ${LIBRARY_DIR}/Net/src/NetworkInterface.cpp + ${LIBRARY_DIR}/Net/src/NTPClient.cpp + ${LIBRARY_DIR}/Net/src/NTPEventArgs.cpp + ${LIBRARY_DIR}/Net/src/NTPPacket.cpp + ${LIBRARY_DIR}/Net/src/NullPartHandler.cpp + ${LIBRARY_DIR}/Net/src/OAuth10Credentials.cpp + ${LIBRARY_DIR}/Net/src/OAuth20Credentials.cpp + ${LIBRARY_DIR}/Net/src/PartHandler.cpp + ${LIBRARY_DIR}/Net/src/PartSource.cpp + ${LIBRARY_DIR}/Net/src/PartStore.cpp + ${LIBRARY_DIR}/Net/src/PollSet.cpp + ${LIBRARY_DIR}/Net/src/POP3ClientSession.cpp + ${LIBRARY_DIR}/Net/src/QuotedPrintableDecoder.cpp + ${LIBRARY_DIR}/Net/src/QuotedPrintableEncoder.cpp + ${LIBRARY_DIR}/Net/src/RawSocket.cpp + ${LIBRARY_DIR}/Net/src/RawSocketImpl.cpp + ${LIBRARY_DIR}/Net/src/RemoteSyslogChannel.cpp + ${LIBRARY_DIR}/Net/src/RemoteSyslogListener.cpp + ${LIBRARY_DIR}/Net/src/ServerSocket.cpp + ${LIBRARY_DIR}/Net/src/ServerSocketImpl.cpp + ${LIBRARY_DIR}/Net/src/SMTPChannel.cpp + ${LIBRARY_DIR}/Net/src/SMTPClientSession.cpp + ${LIBRARY_DIR}/Net/src/Socket.cpp + ${LIBRARY_DIR}/Net/src/SocketAddress.cpp + ${LIBRARY_DIR}/Net/src/SocketAddressImpl.cpp + ${LIBRARY_DIR}/Net/src/SocketImpl.cpp + ${LIBRARY_DIR}/Net/src/SocketNotification.cpp + ${LIBRARY_DIR}/Net/src/SocketNotifier.cpp + ${LIBRARY_DIR}/Net/src/SocketReactor.cpp + ${LIBRARY_DIR}/Net/src/SocketStream.cpp + ${LIBRARY_DIR}/Net/src/StreamSocket.cpp + ${LIBRARY_DIR}/Net/src/StreamSocketImpl.cpp + ${LIBRARY_DIR}/Net/src/StringPartSource.cpp + ${LIBRARY_DIR}/Net/src/TCPServer.cpp + ${LIBRARY_DIR}/Net/src/TCPServerConnection.cpp + ${LIBRARY_DIR}/Net/src/TCPServerConnectionFactory.cpp + ${LIBRARY_DIR}/Net/src/TCPServerDispatcher.cpp + ${LIBRARY_DIR}/Net/src/TCPServerParams.cpp + ${LIBRARY_DIR}/Net/src/WebSocket.cpp + ${LIBRARY_DIR}/Net/src/WebSocketImpl.cpp + ) + + add_library (_poco_net ${SRCS}) + add_library (Poco::Net ALIAS _poco_net) + + if (OS_LINUX) + target_compile_definitions (_poco_net PUBLIC POCO_HAVE_FD_EPOLL) + elseif (OS_DARWIN OR OS_FREEBSD) + target_compile_definitions (_poco_net PUBLIC POCO_HAVE_FD_POLL) + endif () + + if (COMPILER_CLANG) + # clang-specific warnings + target_compile_options (_poco_net + PRIVATE + -Wno-atomic-implicit-seq-cst + -Wno-extra-semi-stmt + -Wno-extra-semi + ) + endif () + target_compile_options (_poco_net + PRIVATE + -Wno-deprecated + -Wno-extra-semi + ) + target_include_directories (_poco_net SYSTEM PUBLIC ${LIBRARY_DIR}/Net/include) + target_link_libraries (_poco_net PUBLIC Poco::Foundation) +else () + add_library (Poco::Net UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_NET PocoNet) + find_path (INCLUDE_POCO_NET Poco/Net/Net.h) + set_target_properties (Poco::Net PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_NET}) + set_target_properties (Poco::Net PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_NET}) + + message (STATUS "Using Poco::Net: ${LIBRARY_POCO_NET} ${INCLUDE_POCO_NET}") +endif () diff --git a/contrib/poco-cmake/Net/SSL/CMakeLists.txt b/contrib/poco-cmake/Net/SSL/CMakeLists.txt new file mode 100644 index 00000000000..7cc71f441c7 --- /dev/null +++ b/contrib/poco-cmake/Net/SSL/CMakeLists.txt @@ -0,0 +1,53 @@ +if (ENABLE_SSL) + if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/AcceptCertificateHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/CertificateHandlerFactory.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/ConsoleCertificateHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/Context.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/HTTPSClientSession.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/HTTPSStreamFactory.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/InvalidCertificateHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/KeyConsoleHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/KeyFileHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/PrivateKeyFactory.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/PrivateKeyPassphraseHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/RejectCertificateHandler.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SecureServerSocket.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SecureSMTPClientSession.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SecureSocketImpl.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SecureStreamSocket.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/Session.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SSLException.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/SSLManager.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/Utility.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/VerificationErrorArgs.cpp + ${LIBRARY_DIR}/NetSSL_OpenSSL/src/X509Certificate.cpp + ) + + add_library (_poco_net_ssl ${SRCS}) + add_library (Poco::Net::SSL ALIAS _poco_net_ssl) + + target_include_directories (_poco_net_ssl SYSTEM PUBLIC ${LIBRARY_DIR}/NetSSL_OpenSSL/include) + target_link_libraries (_poco_net_ssl PUBLIC Poco::Crypto Poco::Net Poco::Util) + else () + add_library (Poco::Net::SSL UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_NET_SSL PocoNetSSL) + find_path (INCLUDE_POCO_NET_SSL Poco/Net/NetSSL.h) + set_target_properties (Poco::Net::SSL PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_NET_SSL}) + set_target_properties (Poco::Net::SSL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_NET_SSL}) + + message (STATUS "Using Poco::Net::SSL: ${LIBRARY_POCO_NET_SSL} ${INCLUDE_POCO_NET_SSL}") + endif () +else () + add_library (_poco_net_ssl INTERFACE) + add_library (Poco::Net::SSL ALIAS _poco_net_ssl) + + message (STATUS "Not using Poco::Net::SSL") +endif () diff --git a/contrib/poco-cmake/Redis/CMakeLists.txt b/contrib/poco-cmake/Redis/CMakeLists.txt new file mode 100644 index 00000000000..43d0009101c --- /dev/null +++ b/contrib/poco-cmake/Redis/CMakeLists.txt @@ -0,0 +1,34 @@ +if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/Redis/src/Array.cpp + ${LIBRARY_DIR}/Redis/src/AsyncReader.cpp + ${LIBRARY_DIR}/Redis/src/Client.cpp + ${LIBRARY_DIR}/Redis/src/Command.cpp + ${LIBRARY_DIR}/Redis/src/Error.cpp + ${LIBRARY_DIR}/Redis/src/Exception.cpp + ${LIBRARY_DIR}/Redis/src/RedisEventArgs.cpp + ${LIBRARY_DIR}/Redis/src/RedisStream.cpp + ${LIBRARY_DIR}/Redis/src/Type.cpp + ) + + add_library (_poco_redis ${SRCS}) + add_library (Poco::Redis ALIAS _poco_redis) + + if (COMPILER_GCC) + target_compile_options (_poco_redis PRIVATE -Wno-deprecated-copy) + endif () + target_compile_options (_poco_redis PRIVATE -Wno-shadow) + target_include_directories (_poco_redis SYSTEM PUBLIC ${LIBRARY_DIR}/Redis/include) + target_link_libraries (_poco_redis PUBLIC Poco::Net) +else () + add_library (Poco::Redis UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_REDIS PocoRedis) + find_path (INCLUDE_POCO_REDIS Poco/Redis/Redis.h) + set_target_properties (Poco::Redis PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_REDIS}) + set_target_properties (Poco::Redis PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_REDIS}) + + target_link_libraries (Poco::Redis INTERFACE Poco::Net) + + message (STATUS "Using Poco::Redis: ${LIBRARY_POCO_REDIS} ${INCLUDE_POCO_REDIS}") +endif () diff --git a/contrib/poco-cmake/Util/CMakeLists.txt b/contrib/poco-cmake/Util/CMakeLists.txt new file mode 100644 index 00000000000..f5af3a5793c --- /dev/null +++ b/contrib/poco-cmake/Util/CMakeLists.txt @@ -0,0 +1,46 @@ +if (USE_INTERNAL_POCO_LIBRARY) + set (SRCS + ${LIBRARY_DIR}/Util/src/AbstractConfiguration.cpp + ${LIBRARY_DIR}/Util/src/Application.cpp + ${LIBRARY_DIR}/Util/src/ConfigurationMapper.cpp + ${LIBRARY_DIR}/Util/src/ConfigurationView.cpp + ${LIBRARY_DIR}/Util/src/FilesystemConfiguration.cpp + ${LIBRARY_DIR}/Util/src/HelpFormatter.cpp + ${LIBRARY_DIR}/Util/src/IniFileConfiguration.cpp + ${LIBRARY_DIR}/Util/src/IntValidator.cpp + ${LIBRARY_DIR}/Util/src/JSONConfiguration.cpp + ${LIBRARY_DIR}/Util/src/LayeredConfiguration.cpp + ${LIBRARY_DIR}/Util/src/LoggingConfigurator.cpp + ${LIBRARY_DIR}/Util/src/LoggingSubsystem.cpp + ${LIBRARY_DIR}/Util/src/MapConfiguration.cpp + ${LIBRARY_DIR}/Util/src/Option.cpp + ${LIBRARY_DIR}/Util/src/OptionCallback.cpp + ${LIBRARY_DIR}/Util/src/OptionException.cpp + ${LIBRARY_DIR}/Util/src/OptionProcessor.cpp + ${LIBRARY_DIR}/Util/src/OptionSet.cpp + ${LIBRARY_DIR}/Util/src/PropertyFileConfiguration.cpp + ${LIBRARY_DIR}/Util/src/RegExpValidator.cpp + ${LIBRARY_DIR}/Util/src/ServerApplication.cpp + ${LIBRARY_DIR}/Util/src/Subsystem.cpp + ${LIBRARY_DIR}/Util/src/SystemConfiguration.cpp + ${LIBRARY_DIR}/Util/src/Timer.cpp + ${LIBRARY_DIR}/Util/src/TimerTask.cpp + ${LIBRARY_DIR}/Util/src/Validator.cpp + ${LIBRARY_DIR}/Util/src/XMLConfiguration.cpp + ) + + add_library (_poco_util ${SRCS}) + add_library (Poco::Util ALIAS _poco_util) + + target_include_directories (_poco_util SYSTEM PUBLIC ${LIBRARY_DIR}/Util/include) + target_link_libraries (_poco_util PUBLIC Poco::JSON Poco::XML) +else () + add_library (Poco::Util UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_UTIL PocoUtil) + find_path (INCLUDE_POCO_UTIL Poco/Util/Util.h) + set_target_properties (Poco::Util PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_UTIL}) + set_target_properties (Poco::Util PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_UTIL}) + + message (STATUS "Using Poco::Util: ${LIBRARY_POCO_UTIL} ${INCLUDE_POCO_UTIL}") +endif () diff --git a/contrib/poco-cmake/XML/CMakeLists.txt b/contrib/poco-cmake/XML/CMakeLists.txt new file mode 100644 index 00000000000..448b7e22c7c --- /dev/null +++ b/contrib/poco-cmake/XML/CMakeLists.txt @@ -0,0 +1,110 @@ +if (USE_INTERNAL_POCO_LIBRARY) + # Poco::XML (expat) + + set (SRCS_EXPAT + ${LIBRARY_DIR}/XML/src/xmlrole.c + ${LIBRARY_DIR}/XML/src/xmltok_impl.c + ${LIBRARY_DIR}/XML/src/xmltok_ns.c + ${LIBRARY_DIR}/XML/src/xmltok.c + ) + + add_library (_poco_xml_expat ${SRCS_EXPAT}) + add_library (Poco::XML::Expat ALIAS _poco_xml_expat) + + target_include_directories (_poco_xml_expat PUBLIC ${LIBRARY_DIR}/XML/include) + + # Poco::XML + + set (SRCS + ${LIBRARY_DIR}/XML/src/AbstractContainerNode.cpp + ${LIBRARY_DIR}/XML/src/AbstractNode.cpp + ${LIBRARY_DIR}/XML/src/Attr.cpp + ${LIBRARY_DIR}/XML/src/Attributes.cpp + ${LIBRARY_DIR}/XML/src/AttributesImpl.cpp + ${LIBRARY_DIR}/XML/src/AttrMap.cpp + ${LIBRARY_DIR}/XML/src/CDATASection.cpp + ${LIBRARY_DIR}/XML/src/CharacterData.cpp + ${LIBRARY_DIR}/XML/src/ChildNodesList.cpp + ${LIBRARY_DIR}/XML/src/Comment.cpp + ${LIBRARY_DIR}/XML/src/ContentHandler.cpp + ${LIBRARY_DIR}/XML/src/DeclHandler.cpp + ${LIBRARY_DIR}/XML/src/DefaultHandler.cpp + ${LIBRARY_DIR}/XML/src/Document.cpp + ${LIBRARY_DIR}/XML/src/DocumentEvent.cpp + ${LIBRARY_DIR}/XML/src/DocumentFragment.cpp + ${LIBRARY_DIR}/XML/src/DocumentType.cpp + ${LIBRARY_DIR}/XML/src/DOMBuilder.cpp + ${LIBRARY_DIR}/XML/src/DOMException.cpp + ${LIBRARY_DIR}/XML/src/DOMImplementation.cpp + ${LIBRARY_DIR}/XML/src/DOMObject.cpp + ${LIBRARY_DIR}/XML/src/DOMParser.cpp + ${LIBRARY_DIR}/XML/src/DOMSerializer.cpp + ${LIBRARY_DIR}/XML/src/DOMWriter.cpp + ${LIBRARY_DIR}/XML/src/DTDHandler.cpp + ${LIBRARY_DIR}/XML/src/DTDMap.cpp + ${LIBRARY_DIR}/XML/src/Element.cpp + ${LIBRARY_DIR}/XML/src/ElementsByTagNameList.cpp + ${LIBRARY_DIR}/XML/src/Entity.cpp + ${LIBRARY_DIR}/XML/src/EntityReference.cpp + ${LIBRARY_DIR}/XML/src/EntityResolver.cpp + ${LIBRARY_DIR}/XML/src/EntityResolverImpl.cpp + ${LIBRARY_DIR}/XML/src/ErrorHandler.cpp + ${LIBRARY_DIR}/XML/src/Event.cpp + ${LIBRARY_DIR}/XML/src/EventDispatcher.cpp + ${LIBRARY_DIR}/XML/src/EventException.cpp + ${LIBRARY_DIR}/XML/src/EventListener.cpp + ${LIBRARY_DIR}/XML/src/EventTarget.cpp + ${LIBRARY_DIR}/XML/src/InputSource.cpp + ${LIBRARY_DIR}/XML/src/LexicalHandler.cpp + ${LIBRARY_DIR}/XML/src/Locator.cpp + ${LIBRARY_DIR}/XML/src/LocatorImpl.cpp + ${LIBRARY_DIR}/XML/src/MutationEvent.cpp + ${LIBRARY_DIR}/XML/src/Name.cpp + ${LIBRARY_DIR}/XML/src/NamedNodeMap.cpp + ${LIBRARY_DIR}/XML/src/NamePool.cpp + ${LIBRARY_DIR}/XML/src/NamespaceStrategy.cpp + ${LIBRARY_DIR}/XML/src/NamespaceSupport.cpp + ${LIBRARY_DIR}/XML/src/Node.cpp + ${LIBRARY_DIR}/XML/src/NodeAppender.cpp + ${LIBRARY_DIR}/XML/src/NodeFilter.cpp + ${LIBRARY_DIR}/XML/src/NodeIterator.cpp + ${LIBRARY_DIR}/XML/src/NodeList.cpp + ${LIBRARY_DIR}/XML/src/Notation.cpp + ${LIBRARY_DIR}/XML/src/ParserEngine.cpp + ${LIBRARY_DIR}/XML/src/ProcessingInstruction.cpp + ${LIBRARY_DIR}/XML/src/QName.cpp + ${LIBRARY_DIR}/XML/src/SAXException.cpp + ${LIBRARY_DIR}/XML/src/SAXParser.cpp + ${LIBRARY_DIR}/XML/src/Text.cpp + ${LIBRARY_DIR}/XML/src/TreeWalker.cpp + ${LIBRARY_DIR}/XML/src/ValueTraits.cpp + ${LIBRARY_DIR}/XML/src/WhitespaceFilter.cpp + ${LIBRARY_DIR}/XML/src/XMLException.cpp + ${LIBRARY_DIR}/XML/src/XMLFilter.cpp + ${LIBRARY_DIR}/XML/src/XMLFilterImpl.cpp + ${LIBRARY_DIR}/XML/src/XMLReader.cpp + ${LIBRARY_DIR}/XML/src/XMLStreamParser.cpp + ${LIBRARY_DIR}/XML/src/XMLStreamParserException.cpp + ${LIBRARY_DIR}/XML/src/XMLString.cpp + ${LIBRARY_DIR}/XML/src/XMLWriter.cpp + + # expat + ${LIBRARY_DIR}/XML/src/xmlparse.cpp + ) + + add_library (_poco_xml ${SRCS}) + add_library (Poco::XML ALIAS _poco_xml) + + target_compile_options (_poco_xml PRIVATE -Wno-old-style-cast) + target_include_directories (_poco_xml SYSTEM PUBLIC ${LIBRARY_DIR}/XML/include) + target_link_libraries (_poco_xml PUBLIC Poco::Foundation Poco::XML::Expat) +else () + add_library (Poco::XML UNKNOWN IMPORTED GLOBAL) + + find_library (LIBRARY_POCO_XML PocoXML) + find_path (INCLUDE_POCO_XML Poco/XML/XML.h) + set_target_properties (Poco::XML PROPERTIES IMPORTED_LOCATION ${LIBRARY_POCO_XML}) + set_target_properties (Poco::XML PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_POCO_XML}) + + message (STATUS "Using Poco::XML: ${LIBRARY_POCO_XML} ${INCLUDE_POCO_XML}") +endif () diff --git a/contrib/protobuf-cmake/CMakeLists.txt b/contrib/protobuf-cmake/CMakeLists.txt new file mode 100644 index 00000000000..3cb9053d647 --- /dev/null +++ b/contrib/protobuf-cmake/CMakeLists.txt @@ -0,0 +1,13 @@ +set(protobuf_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/protobuf) +set(protobuf_BINARY_DIR ${ClickHouse_BINARY_DIR}/contrib/protobuf) + +set(protobuf_WITH_ZLIB 0 CACHE INTERNAL "" FORCE) # actually will use zlib, but skip find +set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) + +if (MAKE_STATIC_LIBRARIES) + set(protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) +else () + set(protobuf_BUILD_SHARED_LIBS ON CACHE INTERNAL "" FORCE) +endif () + +add_subdirectory(${protobuf_SOURCE_DIR}/cmake ${protobuf_BINARY_DIR}) diff --git a/contrib/replxx b/contrib/replxx index f1332626639..2d37daaad24 160000 --- a/contrib/replxx +++ b/contrib/replxx @@ -1 +1 @@ -Subproject commit f1332626639d6492eaf170758642da14fbbda7bf +Subproject commit 2d37daaad24be71e76514a36b0a47120be2f9086 diff --git a/contrib/replxx-cmake/CMakeLists.txt b/contrib/replxx-cmake/CMakeLists.txt index cc428d957cf..48d7e8bb36b 100644 --- a/contrib/replxx-cmake/CMakeLists.txt +++ b/contrib/replxx-cmake/CMakeLists.txt @@ -20,14 +20,14 @@ if (ENABLE_REPLXX) ) add_library (replxx ${SRCS}) - target_include_directories(replxx PUBLIC ${LIBRARY_DIR}/include) + target_include_directories(replxx SYSTEM PUBLIC ${LIBRARY_DIR}/include) else () find_library(LIBRARY_REPLXX NAMES replxx replxx-static) find_path(INCLUDE_REPLXX replxx.hxx) add_library(replxx UNKNOWN IMPORTED) set_property(TARGET replxx PROPERTY IMPORTED_LOCATION ${LIBRARY_REPLXX}) - target_include_directories(replxx PUBLIC ${INCLUDE_REPLXX}) + target_include_directories(replxx SYSTEM PUBLIC ${INCLUDE_REPLXX}) set(CMAKE_REQUIRED_LIBRARIES replxx) check_cxx_source_compiles( @@ -45,8 +45,8 @@ if (ENABLE_REPLXX) endif () endif () - if (NOT (COMPILER_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)) - target_compile_options(replxx PUBLIC -Wno-documentation) + if (COMPILER_CLANG) + target_compile_options(replxx PRIVATE -Wno-documentation) endif () target_compile_definitions(replxx PUBLIC USE_REPLXX=1) diff --git a/contrib/unixodbc-cmake/CMakeLists.txt b/contrib/unixodbc-cmake/CMakeLists.txt index 1715747191c..6d1922075a6 100644 --- a/contrib/unixodbc-cmake/CMakeLists.txt +++ b/contrib/unixodbc-cmake/CMakeLists.txt @@ -1,288 +1,318 @@ -set(ODBC_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/unixodbc) -set(ODBC_BINARY_DIR ${ClickHouse_BINARY_DIR}/contrib/unixodbc) +option (ENABLE_ODBC "Enable ODBC library" ${ENABLE_LIBRARIES}) +if (NOT OS_LINUX) + set (ENABLE_ODBC OFF CACHE INTERNAL "") +endif () -set(SRCS -${ODBC_SOURCE_DIR}/libltdl/lt__alloc.c -${ODBC_SOURCE_DIR}/libltdl/lt__strl.c -${ODBC_SOURCE_DIR}/libltdl/ltdl.c -${ODBC_SOURCE_DIR}/libltdl/lt_dlloader.c -${ODBC_SOURCE_DIR}/libltdl/slist.c -${ODBC_SOURCE_DIR}/libltdl/lt_error.c -${ODBC_SOURCE_DIR}/libltdl/loaders/dlopen.c -${ODBC_SOURCE_DIR}/libltdl/loaders/preopen.c -#${ODBC_SOURCE_DIR}/libltdl/lt__dirent.c -#${ODBC_SOURCE_DIR}/libltdl/lt__argz.c -#${ODBC_SOURCE_DIR}/libltdl/loaders/dld_link.c -#${ODBC_SOURCE_DIR}/libltdl/loaders/load_add_on.c -#${ODBC_SOURCE_DIR}/libltdl/loaders/shl_load.c -#${ODBC_SOURCE_DIR}/libltdl/loaders/loadlibrary.c -#${ODBC_SOURCE_DIR}/libltdl/loaders/dyld.c +if (ENABLE_ODBC) + option (USE_INTERNAL_ODBC_LIBRARY "Use internal ODBC library" ${NOT_UNBUNDLED}) -# This file is generated by 'libtool' inside libltdl directory and then removed. -${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/libltdl/libltdlcS.c -) + if (USE_INTERNAL_ODBC_LIBRARY) + set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/unixodbc) -add_library(ltdl ${SRCS}) + # ltdl -target_include_directories(ltdl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/libltdl) -target_include_directories(ltdl PUBLIC ${ODBC_SOURCE_DIR}/libltdl) -target_include_directories(ltdl PUBLIC ${ODBC_SOURCE_DIR}/libltdl/libltdl) + set (SRCS_LTDL + # This file is generated by 'libtool' inside libltdl directory and then removed. + linux_x86_64/libltdl/libltdlcS.c -target_compile_definitions(ltdl PRIVATE -DHAVE_CONFIG_H -DLTDL -DLTDLOPEN=libltdlc) + ${LIBRARY_DIR}/libltdl/lt__alloc.c + ${LIBRARY_DIR}/libltdl/lt__strl.c + ${LIBRARY_DIR}/libltdl/ltdl.c + ${LIBRARY_DIR}/libltdl/lt_dlloader.c + ${LIBRARY_DIR}/libltdl/slist.c + ${LIBRARY_DIR}/libltdl/lt_error.c + ${LIBRARY_DIR}/libltdl/loaders/dlopen.c + ${LIBRARY_DIR}/libltdl/loaders/preopen.c + ) -target_compile_options(ltdl PRIVATE -Wno-constant-logical-operand -Wno-unknown-warning-option -O2) + add_library (ltdl ${SRCS_LTDL}) + target_include_directories(ltdl + PRIVATE + linux_x86_64/libltdl + PUBLIC + ${LIBRARY_DIR}/libltdl + ${LIBRARY_DIR}/libltdl/libltdl + ) + target_compile_definitions(ltdl PRIVATE -DHAVE_CONFIG_H -DLTDL -DLTDLOPEN=libltdlc) + target_compile_options(ltdl PRIVATE -Wno-constant-logical-operand -Wno-unknown-warning-option -O2) -set(SRCS -${ODBC_SOURCE_DIR}/DriverManager/__attribute.c -${ODBC_SOURCE_DIR}/DriverManager/__connection.c -${ODBC_SOURCE_DIR}/DriverManager/__handles.c -${ODBC_SOURCE_DIR}/DriverManager/__info.c -${ODBC_SOURCE_DIR}/DriverManager/__stats.c -${ODBC_SOURCE_DIR}/DriverManager/SQLAllocConnect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLAllocEnv.c -${ODBC_SOURCE_DIR}/DriverManager/SQLAllocHandle.c -${ODBC_SOURCE_DIR}/DriverManager/SQLAllocHandleStd.c -${ODBC_SOURCE_DIR}/DriverManager/SQLAllocStmt.c -${ODBC_SOURCE_DIR}/DriverManager/SQLBindCol.c -${ODBC_SOURCE_DIR}/DriverManager/SQLBindParam.c -${ODBC_SOURCE_DIR}/DriverManager/SQLBindParameter.c -${ODBC_SOURCE_DIR}/DriverManager/SQLBrowseConnect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLBrowseConnectW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLBulkOperations.c -${ODBC_SOURCE_DIR}/DriverManager/SQLCancel.c -${ODBC_SOURCE_DIR}/DriverManager/SQLCancelHandle.c -${ODBC_SOURCE_DIR}/DriverManager/SQLCloseCursor.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColAttribute.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColAttributes.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColAttributesW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColAttributeW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColumnPrivileges.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColumnPrivilegesW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColumns.c -${ODBC_SOURCE_DIR}/DriverManager/SQLColumnsW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLConnect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLConnectW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLCopyDesc.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDataSources.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDataSourcesW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDescribeCol.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDescribeColW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDescribeParam.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDisconnect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDriverConnect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDriverConnectW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDrivers.c -${ODBC_SOURCE_DIR}/DriverManager/SQLDriversW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLEndTran.c -${ODBC_SOURCE_DIR}/DriverManager/SQLError.c -${ODBC_SOURCE_DIR}/DriverManager/SQLErrorW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLExecDirect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLExecDirectW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLExecute.c -${ODBC_SOURCE_DIR}/DriverManager/SQLExtendedFetch.c -${ODBC_SOURCE_DIR}/DriverManager/SQLFetch.c -${ODBC_SOURCE_DIR}/DriverManager/SQLFetchScroll.c -${ODBC_SOURCE_DIR}/DriverManager/SQLForeignKeys.c -${ODBC_SOURCE_DIR}/DriverManager/SQLForeignKeysW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLFreeConnect.c -${ODBC_SOURCE_DIR}/DriverManager/SQLFreeEnv.c -${ODBC_SOURCE_DIR}/DriverManager/SQLFreeHandle.c -${ODBC_SOURCE_DIR}/DriverManager/SQLFreeStmt.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetConnectAttr.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetConnectAttrW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetConnectOption.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetConnectOptionW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetCursorName.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetCursorNameW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetData.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDescField.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDescFieldW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDescRec.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDescRecW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDiagField.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDiagFieldW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDiagRec.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetDiagRecW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetEnvAttr.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetFunctions.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetInfo.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetInfoW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetStmtAttr.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetStmtAttrW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetStmtOption.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetTypeInfo.c -${ODBC_SOURCE_DIR}/DriverManager/SQLGetTypeInfoW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLMoreResults.c -${ODBC_SOURCE_DIR}/DriverManager/SQLNativeSql.c -${ODBC_SOURCE_DIR}/DriverManager/SQLNativeSqlW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLNumParams.c -${ODBC_SOURCE_DIR}/DriverManager/SQLNumResultCols.c -${ODBC_SOURCE_DIR}/DriverManager/SQLParamData.c -${ODBC_SOURCE_DIR}/DriverManager/SQLParamOptions.c -${ODBC_SOURCE_DIR}/DriverManager/SQLPrepare.c -${ODBC_SOURCE_DIR}/DriverManager/SQLPrepareW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLPrimaryKeys.c -${ODBC_SOURCE_DIR}/DriverManager/SQLPrimaryKeysW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLProcedureColumns.c -${ODBC_SOURCE_DIR}/DriverManager/SQLProcedureColumnsW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLProcedures.c -${ODBC_SOURCE_DIR}/DriverManager/SQLProceduresW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLPutData.c -${ODBC_SOURCE_DIR}/DriverManager/SQLRowCount.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetConnectAttr.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetConnectAttrW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetConnectOption.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetConnectOptionW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetCursorName.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetCursorNameW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetDescField.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetDescFieldW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetDescRec.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetEnvAttr.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetParam.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetPos.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetScrollOptions.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetStmtAttr.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetStmtAttrW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetStmtOption.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSetStmtOptionW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSpecialColumns.c -${ODBC_SOURCE_DIR}/DriverManager/SQLSpecialColumnsW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLStatistics.c -${ODBC_SOURCE_DIR}/DriverManager/SQLStatisticsW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLTablePrivileges.c -${ODBC_SOURCE_DIR}/DriverManager/SQLTablePrivilegesW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLTables.c -${ODBC_SOURCE_DIR}/DriverManager/SQLTablesW.c -${ODBC_SOURCE_DIR}/DriverManager/SQLTransact.c + # odbc -${ODBC_SOURCE_DIR}/odbcinst/_logging.c -${ODBC_SOURCE_DIR}/odbcinst/_odbcinst_ConfigModeINI.c -${ODBC_SOURCE_DIR}/odbcinst/ODBCINSTConstructProperties.c -${ODBC_SOURCE_DIR}/odbcinst/ODBCINSTDestructProperties.c -${ODBC_SOURCE_DIR}/odbcinst/_odbcinst_GetEntries.c -${ODBC_SOURCE_DIR}/odbcinst/_odbcinst_GetSections.c -${ODBC_SOURCE_DIR}/odbcinst/ODBCINSTSetProperty.c -${ODBC_SOURCE_DIR}/odbcinst/_odbcinst_SystemINI.c -${ODBC_SOURCE_DIR}/odbcinst/_odbcinst_UserINI.c -${ODBC_SOURCE_DIR}/odbcinst/ODBCINSTValidateProperties.c -${ODBC_SOURCE_DIR}/odbcinst/ODBCINSTValidateProperty.c -${ODBC_SOURCE_DIR}/odbcinst/SQLConfigDataSource.c -${ODBC_SOURCE_DIR}/odbcinst/SQLConfigDriver.c -${ODBC_SOURCE_DIR}/odbcinst/SQLCreateDataSource.c -${ODBC_SOURCE_DIR}/odbcinst/_SQLDriverConnectPrompt.c -${ODBC_SOURCE_DIR}/odbcinst/SQLGetAvailableDrivers.c -${ODBC_SOURCE_DIR}/odbcinst/SQLGetConfigMode.c -${ODBC_SOURCE_DIR}/odbcinst/_SQLGetInstalledDrivers.c -${ODBC_SOURCE_DIR}/odbcinst/SQLGetInstalledDrivers.c -${ODBC_SOURCE_DIR}/odbcinst/SQLGetPrivateProfileString.c -${ODBC_SOURCE_DIR}/odbcinst/SQLGetTranslator.c -${ODBC_SOURCE_DIR}/odbcinst/SQLInstallDriverEx.c -${ODBC_SOURCE_DIR}/odbcinst/SQLInstallDriverManager.c -${ODBC_SOURCE_DIR}/odbcinst/SQLInstallerError.c -${ODBC_SOURCE_DIR}/odbcinst/SQLInstallODBC.c -${ODBC_SOURCE_DIR}/odbcinst/SQLInstallTranslatorEx.c -${ODBC_SOURCE_DIR}/odbcinst/SQLManageDataSources.c -${ODBC_SOURCE_DIR}/odbcinst/SQLPostInstallerError.c -${ODBC_SOURCE_DIR}/odbcinst/SQLReadFileDSN.c -${ODBC_SOURCE_DIR}/odbcinst/SQLRemoveDriver.c -${ODBC_SOURCE_DIR}/odbcinst/SQLRemoveDriverManager.c -${ODBC_SOURCE_DIR}/odbcinst/SQLRemoveDSNFromIni.c -${ODBC_SOURCE_DIR}/odbcinst/SQLRemoveTranslator.c -${ODBC_SOURCE_DIR}/odbcinst/SQLSetConfigMode.c -${ODBC_SOURCE_DIR}/odbcinst/SQLValidDSN.c -${ODBC_SOURCE_DIR}/odbcinst/SQLWriteDSNToIni.c -${ODBC_SOURCE_DIR}/odbcinst/SQLWriteFileDSN.c -${ODBC_SOURCE_DIR}/odbcinst/_SQLWriteInstalledDrivers.c -${ODBC_SOURCE_DIR}/odbcinst/SQLWritePrivateProfileString.c + set (SRCS + ${LIBRARY_DIR}/DriverManager/__attribute.c + ${LIBRARY_DIR}/DriverManager/__connection.c + ${LIBRARY_DIR}/DriverManager/__handles.c + ${LIBRARY_DIR}/DriverManager/__info.c + ${LIBRARY_DIR}/DriverManager/__stats.c + ${LIBRARY_DIR}/DriverManager/SQLAllocConnect.c + ${LIBRARY_DIR}/DriverManager/SQLAllocEnv.c + ${LIBRARY_DIR}/DriverManager/SQLAllocHandle.c + ${LIBRARY_DIR}/DriverManager/SQLAllocHandleStd.c + ${LIBRARY_DIR}/DriverManager/SQLAllocStmt.c + ${LIBRARY_DIR}/DriverManager/SQLBindCol.c + ${LIBRARY_DIR}/DriverManager/SQLBindParam.c + ${LIBRARY_DIR}/DriverManager/SQLBindParameter.c + ${LIBRARY_DIR}/DriverManager/SQLBrowseConnect.c + ${LIBRARY_DIR}/DriverManager/SQLBrowseConnectW.c + ${LIBRARY_DIR}/DriverManager/SQLBulkOperations.c + ${LIBRARY_DIR}/DriverManager/SQLCancel.c + ${LIBRARY_DIR}/DriverManager/SQLCancelHandle.c + ${LIBRARY_DIR}/DriverManager/SQLCloseCursor.c + ${LIBRARY_DIR}/DriverManager/SQLColAttribute.c + ${LIBRARY_DIR}/DriverManager/SQLColAttributes.c + ${LIBRARY_DIR}/DriverManager/SQLColAttributesW.c + ${LIBRARY_DIR}/DriverManager/SQLColAttributeW.c + ${LIBRARY_DIR}/DriverManager/SQLColumnPrivileges.c + ${LIBRARY_DIR}/DriverManager/SQLColumnPrivilegesW.c + ${LIBRARY_DIR}/DriverManager/SQLColumns.c + ${LIBRARY_DIR}/DriverManager/SQLColumnsW.c + ${LIBRARY_DIR}/DriverManager/SQLConnect.c + ${LIBRARY_DIR}/DriverManager/SQLConnectW.c + ${LIBRARY_DIR}/DriverManager/SQLCopyDesc.c + ${LIBRARY_DIR}/DriverManager/SQLDataSources.c + ${LIBRARY_DIR}/DriverManager/SQLDataSourcesW.c + ${LIBRARY_DIR}/DriverManager/SQLDescribeCol.c + ${LIBRARY_DIR}/DriverManager/SQLDescribeColW.c + ${LIBRARY_DIR}/DriverManager/SQLDescribeParam.c + ${LIBRARY_DIR}/DriverManager/SQLDisconnect.c + ${LIBRARY_DIR}/DriverManager/SQLDriverConnect.c + ${LIBRARY_DIR}/DriverManager/SQLDriverConnectW.c + ${LIBRARY_DIR}/DriverManager/SQLDrivers.c + ${LIBRARY_DIR}/DriverManager/SQLDriversW.c + ${LIBRARY_DIR}/DriverManager/SQLEndTran.c + ${LIBRARY_DIR}/DriverManager/SQLError.c + ${LIBRARY_DIR}/DriverManager/SQLErrorW.c + ${LIBRARY_DIR}/DriverManager/SQLExecDirect.c + ${LIBRARY_DIR}/DriverManager/SQLExecDirectW.c + ${LIBRARY_DIR}/DriverManager/SQLExecute.c + ${LIBRARY_DIR}/DriverManager/SQLExtendedFetch.c + ${LIBRARY_DIR}/DriverManager/SQLFetch.c + ${LIBRARY_DIR}/DriverManager/SQLFetchScroll.c + ${LIBRARY_DIR}/DriverManager/SQLForeignKeys.c + ${LIBRARY_DIR}/DriverManager/SQLForeignKeysW.c + ${LIBRARY_DIR}/DriverManager/SQLFreeConnect.c + ${LIBRARY_DIR}/DriverManager/SQLFreeEnv.c + ${LIBRARY_DIR}/DriverManager/SQLFreeHandle.c + ${LIBRARY_DIR}/DriverManager/SQLFreeStmt.c + ${LIBRARY_DIR}/DriverManager/SQLGetConnectAttr.c + ${LIBRARY_DIR}/DriverManager/SQLGetConnectAttrW.c + ${LIBRARY_DIR}/DriverManager/SQLGetConnectOption.c + ${LIBRARY_DIR}/DriverManager/SQLGetConnectOptionW.c + ${LIBRARY_DIR}/DriverManager/SQLGetCursorName.c + ${LIBRARY_DIR}/DriverManager/SQLGetCursorNameW.c + ${LIBRARY_DIR}/DriverManager/SQLGetData.c + ${LIBRARY_DIR}/DriverManager/SQLGetDescField.c + ${LIBRARY_DIR}/DriverManager/SQLGetDescFieldW.c + ${LIBRARY_DIR}/DriverManager/SQLGetDescRec.c + ${LIBRARY_DIR}/DriverManager/SQLGetDescRecW.c + ${LIBRARY_DIR}/DriverManager/SQLGetDiagField.c + ${LIBRARY_DIR}/DriverManager/SQLGetDiagFieldW.c + ${LIBRARY_DIR}/DriverManager/SQLGetDiagRec.c + ${LIBRARY_DIR}/DriverManager/SQLGetDiagRecW.c + ${LIBRARY_DIR}/DriverManager/SQLGetEnvAttr.c + ${LIBRARY_DIR}/DriverManager/SQLGetFunctions.c + ${LIBRARY_DIR}/DriverManager/SQLGetInfo.c + ${LIBRARY_DIR}/DriverManager/SQLGetInfoW.c + ${LIBRARY_DIR}/DriverManager/SQLGetStmtAttr.c + ${LIBRARY_DIR}/DriverManager/SQLGetStmtAttrW.c + ${LIBRARY_DIR}/DriverManager/SQLGetStmtOption.c + ${LIBRARY_DIR}/DriverManager/SQLGetTypeInfo.c + ${LIBRARY_DIR}/DriverManager/SQLGetTypeInfoW.c + ${LIBRARY_DIR}/DriverManager/SQLMoreResults.c + ${LIBRARY_DIR}/DriverManager/SQLNativeSql.c + ${LIBRARY_DIR}/DriverManager/SQLNativeSqlW.c + ${LIBRARY_DIR}/DriverManager/SQLNumParams.c + ${LIBRARY_DIR}/DriverManager/SQLNumResultCols.c + ${LIBRARY_DIR}/DriverManager/SQLParamData.c + ${LIBRARY_DIR}/DriverManager/SQLParamOptions.c + ${LIBRARY_DIR}/DriverManager/SQLPrepare.c + ${LIBRARY_DIR}/DriverManager/SQLPrepareW.c + ${LIBRARY_DIR}/DriverManager/SQLPrimaryKeys.c + ${LIBRARY_DIR}/DriverManager/SQLPrimaryKeysW.c + ${LIBRARY_DIR}/DriverManager/SQLProcedureColumns.c + ${LIBRARY_DIR}/DriverManager/SQLProcedureColumnsW.c + ${LIBRARY_DIR}/DriverManager/SQLProcedures.c + ${LIBRARY_DIR}/DriverManager/SQLProceduresW.c + ${LIBRARY_DIR}/DriverManager/SQLPutData.c + ${LIBRARY_DIR}/DriverManager/SQLRowCount.c + ${LIBRARY_DIR}/DriverManager/SQLSetConnectAttr.c + ${LIBRARY_DIR}/DriverManager/SQLSetConnectAttrW.c + ${LIBRARY_DIR}/DriverManager/SQLSetConnectOption.c + ${LIBRARY_DIR}/DriverManager/SQLSetConnectOptionW.c + ${LIBRARY_DIR}/DriverManager/SQLSetCursorName.c + ${LIBRARY_DIR}/DriverManager/SQLSetCursorNameW.c + ${LIBRARY_DIR}/DriverManager/SQLSetDescField.c + ${LIBRARY_DIR}/DriverManager/SQLSetDescFieldW.c + ${LIBRARY_DIR}/DriverManager/SQLSetDescRec.c + ${LIBRARY_DIR}/DriverManager/SQLSetEnvAttr.c + ${LIBRARY_DIR}/DriverManager/SQLSetParam.c + ${LIBRARY_DIR}/DriverManager/SQLSetPos.c + ${LIBRARY_DIR}/DriverManager/SQLSetScrollOptions.c + ${LIBRARY_DIR}/DriverManager/SQLSetStmtAttr.c + ${LIBRARY_DIR}/DriverManager/SQLSetStmtAttrW.c + ${LIBRARY_DIR}/DriverManager/SQLSetStmtOption.c + ${LIBRARY_DIR}/DriverManager/SQLSetStmtOptionW.c + ${LIBRARY_DIR}/DriverManager/SQLSpecialColumns.c + ${LIBRARY_DIR}/DriverManager/SQLSpecialColumnsW.c + ${LIBRARY_DIR}/DriverManager/SQLStatistics.c + ${LIBRARY_DIR}/DriverManager/SQLStatisticsW.c + ${LIBRARY_DIR}/DriverManager/SQLTablePrivileges.c + ${LIBRARY_DIR}/DriverManager/SQLTablePrivilegesW.c + ${LIBRARY_DIR}/DriverManager/SQLTables.c + ${LIBRARY_DIR}/DriverManager/SQLTablesW.c + ${LIBRARY_DIR}/DriverManager/SQLTransact.c + ${LIBRARY_DIR}/ini/_iniDump.c + ${LIBRARY_DIR}/ini/_iniObjectRead.c + ${LIBRARY_DIR}/ini/_iniPropertyRead.c + ${LIBRARY_DIR}/ini/_iniScanUntilObject.c + ${LIBRARY_DIR}/ini/iniAllTrim.c + ${LIBRARY_DIR}/ini/iniAppend.c + ${LIBRARY_DIR}/ini/iniClose.c + ${LIBRARY_DIR}/ini/iniCommit.c + ${LIBRARY_DIR}/ini/iniCursor.c + ${LIBRARY_DIR}/ini/iniDelete.c + ${LIBRARY_DIR}/ini/iniElement.c + ${LIBRARY_DIR}/ini/iniElementCount.c + ${LIBRARY_DIR}/ini/iniGetBookmark.c + ${LIBRARY_DIR}/ini/iniGotoBookmark.c + ${LIBRARY_DIR}/ini/iniObject.c + ${LIBRARY_DIR}/ini/iniObjectDelete.c + ${LIBRARY_DIR}/ini/iniObjectEOL.c + ${LIBRARY_DIR}/ini/iniObjectFirst.c + ${LIBRARY_DIR}/ini/iniObjectInsert.c + ${LIBRARY_DIR}/ini/iniObjectLast.c + ${LIBRARY_DIR}/ini/iniObjectNext.c + ${LIBRARY_DIR}/ini/iniObjectSeek.c + ${LIBRARY_DIR}/ini/iniObjectSeekSure.c + ${LIBRARY_DIR}/ini/iniObjectUpdate.c + ${LIBRARY_DIR}/ini/iniOpen.c + ${LIBRARY_DIR}/ini/iniProperty.c + ${LIBRARY_DIR}/ini/iniPropertyDelete.c + ${LIBRARY_DIR}/ini/iniPropertyEOL.c + ${LIBRARY_DIR}/ini/iniPropertyFirst.c + ${LIBRARY_DIR}/ini/iniPropertyInsert.c + ${LIBRARY_DIR}/ini/iniPropertyLast.c + ${LIBRARY_DIR}/ini/iniPropertyNext.c + ${LIBRARY_DIR}/ini/iniPropertySeek.c + ${LIBRARY_DIR}/ini/iniPropertySeekSure.c + ${LIBRARY_DIR}/ini/iniPropertyUpdate.c + ${LIBRARY_DIR}/ini/iniPropertyValue.c + ${LIBRARY_DIR}/ini/iniToUpper.c + ${LIBRARY_DIR}/ini/iniValue.c + ${LIBRARY_DIR}/log/_logFreeMsg.c + ${LIBRARY_DIR}/log/logClear.c + ${LIBRARY_DIR}/log/logClose.c + ${LIBRARY_DIR}/log/logOn.c + ${LIBRARY_DIR}/log/logOpen.c + ${LIBRARY_DIR}/log/logPeekMsg.c + ${LIBRARY_DIR}/log/logPopMsg.c + ${LIBRARY_DIR}/log/logPushMsg.c + ${LIBRARY_DIR}/lst/_lstAdjustCurrent.c + ${LIBRARY_DIR}/lst/_lstDump.c + ${LIBRARY_DIR}/lst/_lstFreeItem.c + ${LIBRARY_DIR}/lst/_lstNextValidItem.c + ${LIBRARY_DIR}/lst/_lstPrevValidItem.c + ${LIBRARY_DIR}/lst/_lstVisible.c + ${LIBRARY_DIR}/lst/lstAppend.c + ${LIBRARY_DIR}/lst/lstClose.c + ${LIBRARY_DIR}/lst/lstDelete.c + ${LIBRARY_DIR}/lst/lstEOL.c + ${LIBRARY_DIR}/lst/lstFirst.c + ${LIBRARY_DIR}/lst/lstGet.c + ${LIBRARY_DIR}/lst/lstGetBookMark.c + ${LIBRARY_DIR}/lst/lstGoto.c + ${LIBRARY_DIR}/lst/lstGotoBookMark.c + ${LIBRARY_DIR}/lst/lstInsert.c + ${LIBRARY_DIR}/lst/lstLast.c + ${LIBRARY_DIR}/lst/lstNext.c + ${LIBRARY_DIR}/lst/lstOpen.c + ${LIBRARY_DIR}/lst/lstOpenCursor.c + ${LIBRARY_DIR}/lst/lstPrev.c + ${LIBRARY_DIR}/lst/lstSeek.c + ${LIBRARY_DIR}/lst/lstSeekItem.c + ${LIBRARY_DIR}/lst/lstSet.c + ${LIBRARY_DIR}/lst/lstSetFreeFunc.c + ${LIBRARY_DIR}/odbcinst/_logging.c + ${LIBRARY_DIR}/odbcinst/_odbcinst_ConfigModeINI.c + ${LIBRARY_DIR}/odbcinst/_odbcinst_GetEntries.c + ${LIBRARY_DIR}/odbcinst/_odbcinst_GetSections.c + ${LIBRARY_DIR}/odbcinst/_odbcinst_SystemINI.c + ${LIBRARY_DIR}/odbcinst/_odbcinst_UserINI.c + ${LIBRARY_DIR}/odbcinst/_SQLDriverConnectPrompt.c + ${LIBRARY_DIR}/odbcinst/_SQLGetInstalledDrivers.c + ${LIBRARY_DIR}/odbcinst/_SQLWriteInstalledDrivers.c + ${LIBRARY_DIR}/odbcinst/ODBCINSTConstructProperties.c + ${LIBRARY_DIR}/odbcinst/ODBCINSTDestructProperties.c + ${LIBRARY_DIR}/odbcinst/ODBCINSTSetProperty.c + ${LIBRARY_DIR}/odbcinst/ODBCINSTValidateProperties.c + ${LIBRARY_DIR}/odbcinst/ODBCINSTValidateProperty.c + ${LIBRARY_DIR}/odbcinst/SQLConfigDataSource.c + ${LIBRARY_DIR}/odbcinst/SQLConfigDriver.c + ${LIBRARY_DIR}/odbcinst/SQLCreateDataSource.c + ${LIBRARY_DIR}/odbcinst/SQLGetAvailableDrivers.c + ${LIBRARY_DIR}/odbcinst/SQLGetConfigMode.c + ${LIBRARY_DIR}/odbcinst/SQLGetInstalledDrivers.c + ${LIBRARY_DIR}/odbcinst/SQLGetPrivateProfileString.c + ${LIBRARY_DIR}/odbcinst/SQLGetTranslator.c + ${LIBRARY_DIR}/odbcinst/SQLInstallDriverEx.c + ${LIBRARY_DIR}/odbcinst/SQLInstallDriverManager.c + ${LIBRARY_DIR}/odbcinst/SQLInstallerError.c + ${LIBRARY_DIR}/odbcinst/SQLInstallODBC.c + ${LIBRARY_DIR}/odbcinst/SQLInstallTranslatorEx.c + ${LIBRARY_DIR}/odbcinst/SQLManageDataSources.c + ${LIBRARY_DIR}/odbcinst/SQLPostInstallerError.c + ${LIBRARY_DIR}/odbcinst/SQLReadFileDSN.c + ${LIBRARY_DIR}/odbcinst/SQLRemoveDriver.c + ${LIBRARY_DIR}/odbcinst/SQLRemoveDriverManager.c + ${LIBRARY_DIR}/odbcinst/SQLRemoveDSNFromIni.c + ${LIBRARY_DIR}/odbcinst/SQLRemoveTranslator.c + ${LIBRARY_DIR}/odbcinst/SQLSetConfigMode.c + ${LIBRARY_DIR}/odbcinst/SQLValidDSN.c + ${LIBRARY_DIR}/odbcinst/SQLWriteDSNToIni.c + ${LIBRARY_DIR}/odbcinst/SQLWriteFileDSN.c + ${LIBRARY_DIR}/odbcinst/SQLWritePrivateProfileString.c + ) -${ODBC_SOURCE_DIR}/ini/iniAllTrim.c -${ODBC_SOURCE_DIR}/ini/iniAppend.c -${ODBC_SOURCE_DIR}/ini/iniClose.c -${ODBC_SOURCE_DIR}/ini/iniCommit.c -${ODBC_SOURCE_DIR}/ini/iniCursor.c -${ODBC_SOURCE_DIR}/ini/iniDelete.c -${ODBC_SOURCE_DIR}/ini/_iniDump.c -${ODBC_SOURCE_DIR}/ini/iniElement.c -${ODBC_SOURCE_DIR}/ini/iniElementCount.c -${ODBC_SOURCE_DIR}/ini/iniGetBookmark.c -${ODBC_SOURCE_DIR}/ini/iniGotoBookmark.c -${ODBC_SOURCE_DIR}/ini/iniObject.c -${ODBC_SOURCE_DIR}/ini/iniObjectDelete.c -${ODBC_SOURCE_DIR}/ini/iniObjectEOL.c -${ODBC_SOURCE_DIR}/ini/iniObjectFirst.c -${ODBC_SOURCE_DIR}/ini/iniObjectInsert.c -${ODBC_SOURCE_DIR}/ini/iniObjectLast.c -${ODBC_SOURCE_DIR}/ini/iniObjectNext.c -${ODBC_SOURCE_DIR}/ini/_iniObjectRead.c -${ODBC_SOURCE_DIR}/ini/iniObjectSeek.c -${ODBC_SOURCE_DIR}/ini/iniObjectSeekSure.c -${ODBC_SOURCE_DIR}/ini/iniObjectUpdate.c -${ODBC_SOURCE_DIR}/ini/iniOpen.c -${ODBC_SOURCE_DIR}/ini/iniProperty.c -${ODBC_SOURCE_DIR}/ini/iniPropertyDelete.c -${ODBC_SOURCE_DIR}/ini/iniPropertyEOL.c -${ODBC_SOURCE_DIR}/ini/iniPropertyFirst.c -${ODBC_SOURCE_DIR}/ini/iniPropertyInsert.c -${ODBC_SOURCE_DIR}/ini/iniPropertyLast.c -${ODBC_SOURCE_DIR}/ini/iniPropertyNext.c -${ODBC_SOURCE_DIR}/ini/_iniPropertyRead.c -${ODBC_SOURCE_DIR}/ini/iniPropertySeek.c -${ODBC_SOURCE_DIR}/ini/iniPropertySeekSure.c -${ODBC_SOURCE_DIR}/ini/iniPropertyUpdate.c -${ODBC_SOURCE_DIR}/ini/iniPropertyValue.c -${ODBC_SOURCE_DIR}/ini/_iniScanUntilObject.c -${ODBC_SOURCE_DIR}/ini/iniToUpper.c -${ODBC_SOURCE_DIR}/ini/iniValue.c + add_library (unixodbc ${SRCS}) -${ODBC_SOURCE_DIR}/log/logClear.c -${ODBC_SOURCE_DIR}/log/logClose.c -${ODBC_SOURCE_DIR}/log/_logFreeMsg.c -${ODBC_SOURCE_DIR}/log/logOn.c -${ODBC_SOURCE_DIR}/log/logOpen.c -${ODBC_SOURCE_DIR}/log/logPeekMsg.c -${ODBC_SOURCE_DIR}/log/logPopMsg.c -${ODBC_SOURCE_DIR}/log/logPushMsg.c + target_link_libraries (unixodbc PRIVATE ltdl) -${ODBC_SOURCE_DIR}/lst/_lstAdjustCurrent.c -${ODBC_SOURCE_DIR}/lst/lstAppend.c -${ODBC_SOURCE_DIR}/lst/lstClose.c -${ODBC_SOURCE_DIR}/lst/lstDelete.c -${ODBC_SOURCE_DIR}/lst/_lstDump.c -${ODBC_SOURCE_DIR}/lst/lstEOL.c -${ODBC_SOURCE_DIR}/lst/lstFirst.c -${ODBC_SOURCE_DIR}/lst/_lstFreeItem.c -${ODBC_SOURCE_DIR}/lst/lstGetBookMark.c -${ODBC_SOURCE_DIR}/lst/lstGet.c -${ODBC_SOURCE_DIR}/lst/lstGotoBookMark.c -${ODBC_SOURCE_DIR}/lst/lstGoto.c -${ODBC_SOURCE_DIR}/lst/lstInsert.c -${ODBC_SOURCE_DIR}/lst/lstLast.c -${ODBC_SOURCE_DIR}/lst/lstNext.c -${ODBC_SOURCE_DIR}/lst/_lstNextValidItem.c -${ODBC_SOURCE_DIR}/lst/lstOpen.c -${ODBC_SOURCE_DIR}/lst/lstOpenCursor.c -${ODBC_SOURCE_DIR}/lst/lstPrev.c -${ODBC_SOURCE_DIR}/lst/_lstPrevValidItem.c -${ODBC_SOURCE_DIR}/lst/lstSeek.c -${ODBC_SOURCE_DIR}/lst/lstSeekItem.c -${ODBC_SOURCE_DIR}/lst/lstSet.c -${ODBC_SOURCE_DIR}/lst/lstSetFreeFunc.c -${ODBC_SOURCE_DIR}/lst/_lstVisible.c -) + # SYSTEM_FILE_PATH was changed to /etc -add_library(unixodbc ${SRCS}) + target_include_directories (unixodbc + PRIVATE + linux_x86_64/private + PUBLIC + linux_x86_64 + ${LIBRARY_DIR}/include + ) + target_compile_definitions (unixodbc PRIVATE -DHAVE_CONFIG_H) + target_compile_options (unixodbc + PRIVATE + -Wno-dangling-else + -Wno-parentheses + -Wno-misleading-indentation + -Wno-unknown-warning-option + -Wno-reserved-id-macro + -O2 + ) + else () + add_library (unixodbc UNKNOWN IMPORTED) -target_link_libraries(unixodbc PRIVATE ltdl) + find_library (LIBRARY_ODBC unixodbc) + find_path (INCLUDE_ODBC sql.h) + set_target_properties (unixodbc PROPERTIES IMPORTED_LOCATION ${LIBRARY_ODBC}) + set_target_properties (unixodbc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_ODBC}) + endif () -# SYSTEM_FILE_PATH was changed to /etc + target_compile_definitions (unixodbc PUBLIC USE_ODBC=1) -target_include_directories(unixodbc SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/private) -target_include_directories(unixodbc SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64) -target_include_directories(unixodbc SYSTEM PUBLIC ${ODBC_SOURCE_DIR}/include) + message (STATUS "Using unixodbc") +else () + add_library (unixodbc INTERFACE) + target_compile_definitions (unixodbc INTERFACE USE_ODBC=0) -target_compile_definitions(unixodbc PRIVATE -DHAVE_CONFIG_H) - -target_compile_options(unixodbc PRIVATE -Wno-dangling-else -Wno-parentheses -Wno-misleading-indentation -Wno-unknown-warning-option -O2) + message (STATUS "Not using unixodbc") +endif () diff --git a/contrib/zstd b/contrib/zstd index 255597502c3..10f0e6993f9 160000 --- a/contrib/zstd +++ b/contrib/zstd @@ -1 +1 @@ -Subproject commit 255597502c3a4ef150abc964e376d4202a8c2929 +Subproject commit 10f0e6993f9d2f682da6d04aa2385b7d53cbb4ee diff --git a/contrib/zstd-cmake/CMakeLists.txt b/contrib/zstd-cmake/CMakeLists.txt index 6d8ecce2a44..58a827761ea 100644 --- a/contrib/zstd-cmake/CMakeLists.txt +++ b/contrib/zstd-cmake/CMakeLists.txt @@ -49,7 +49,10 @@ FILE(READ ${LIBRARY_DIR}/zstd.h HEADER_CONTENT) GetLibraryVersion("${HEADER_CONTENT}" LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE) MESSAGE(STATUS "ZSTD VERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}") +# cd contrib/zstd/lib +# find . -name '*.c' | grep -vP 'deprecated|legacy' | sort | sed 's/^\./ ${LIBRARY_DIR}/' SET(Sources + ${LIBRARY_DIR}/common/debug.c ${LIBRARY_DIR}/common/entropy_common.c ${LIBRARY_DIR}/common/error_private.c ${LIBRARY_DIR}/common/fse_decompress.c @@ -58,8 +61,11 @@ SET(Sources ${LIBRARY_DIR}/common/xxhash.c ${LIBRARY_DIR}/common/zstd_common.c ${LIBRARY_DIR}/compress/fse_compress.c + ${LIBRARY_DIR}/compress/hist.c ${LIBRARY_DIR}/compress/huf_compress.c ${LIBRARY_DIR}/compress/zstd_compress.c + ${LIBRARY_DIR}/compress/zstd_compress_literals.c + ${LIBRARY_DIR}/compress/zstd_compress_sequences.c ${LIBRARY_DIR}/compress/zstd_double_fast.c ${LIBRARY_DIR}/compress/zstd_fast.c ${LIBRARY_DIR}/compress/zstd_lazy.c @@ -67,16 +73,21 @@ SET(Sources ${LIBRARY_DIR}/compress/zstdmt_compress.c ${LIBRARY_DIR}/compress/zstd_opt.c ${LIBRARY_DIR}/decompress/huf_decompress.c + ${LIBRARY_DIR}/decompress/zstd_ddict.c + ${LIBRARY_DIR}/decompress/zstd_decompress_block.c ${LIBRARY_DIR}/decompress/zstd_decompress.c - ${LIBRARY_DIR}/deprecated/zbuff_common.c - ${LIBRARY_DIR}/deprecated/zbuff_compress.c - ${LIBRARY_DIR}/deprecated/zbuff_decompress.c ${LIBRARY_DIR}/dictBuilder/cover.c ${LIBRARY_DIR}/dictBuilder/divsufsort.c + ${LIBRARY_DIR}/dictBuilder/fastcover.c ${LIBRARY_DIR}/dictBuilder/zdict.c) +# cd contrib/zstd/lib +# find . -name '*.h' | grep -vP 'deprecated|legacy' | sort | sed 's/^\./ ${LIBRARY_DIR}/' SET(Headers ${LIBRARY_DIR}/common/bitstream.h + ${LIBRARY_DIR}/common/compiler.h + ${LIBRARY_DIR}/common/cpu.h + ${LIBRARY_DIR}/common/debug.h ${LIBRARY_DIR}/common/error_private.h ${LIBRARY_DIR}/common/fse.h ${LIBRARY_DIR}/common/huf.h @@ -86,14 +97,21 @@ SET(Headers ${LIBRARY_DIR}/common/xxhash.h ${LIBRARY_DIR}/common/zstd_errors.h ${LIBRARY_DIR}/common/zstd_internal.h + ${LIBRARY_DIR}/compress/hist.h + ${LIBRARY_DIR}/compress/zstd_compress_internal.h + ${LIBRARY_DIR}/compress/zstd_compress_literals.h + ${LIBRARY_DIR}/compress/zstd_compress_sequences.h + ${LIBRARY_DIR}/compress/zstd_cwksp.h ${LIBRARY_DIR}/compress/zstd_double_fast.h ${LIBRARY_DIR}/compress/zstd_fast.h ${LIBRARY_DIR}/compress/zstd_lazy.h ${LIBRARY_DIR}/compress/zstd_ldm.h ${LIBRARY_DIR}/compress/zstdmt_compress.h ${LIBRARY_DIR}/compress/zstd_opt.h - ${LIBRARY_DIR}/compress/zstd_ldm.h - ${LIBRARY_DIR}/deprecated/zbuff.h + ${LIBRARY_DIR}/decompress/zstd_ddict.h + ${LIBRARY_DIR}/decompress/zstd_decompress_block.h + ${LIBRARY_DIR}/decompress/zstd_decompress_internal.h + ${LIBRARY_DIR}/dictBuilder/cover.h ${LIBRARY_DIR}/dictBuilder/divsufsort.h ${LIBRARY_DIR}/dictBuilder/zdict.h ${LIBRARY_DIR}/zstd.h) @@ -128,3 +146,4 @@ ENDIF (ZSTD_LEGACY_SUPPORT) ADD_LIBRARY(zstd ${Sources} ${Headers}) target_include_directories (zstd PUBLIC ${LIBRARY_DIR}) +target_compile_options(zstd PRIVATE -fno-sanitize=undefined) diff --git a/debian/control b/debian/control index 58efd711d27..3ce12b504c2 100644 --- a/debian/control +++ b/debian/control @@ -28,7 +28,7 @@ Description: Client binary for ClickHouse Package: clickhouse-common-static Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends}, tzdata Suggests: clickhouse-common-static-dbg Replaces: clickhouse-common, clickhouse-server-base Provides: clickhouse-common, clickhouse-server-base diff --git a/debian/rules b/debian/rules index dabebb516cd..7218e196baa 100755 --- a/debian/rules +++ b/debian/rules @@ -24,6 +24,10 @@ DEB_BUILD_OPTIONS+=parallel=$(THREADS_COUNT) ifndef ENABLE_TESTS CMAKE_FLAGS += -DENABLE_TESTS=0 +else +# To export binaries and from deb build we do not strip them. No need to run tests in deb build as we run them in CI + DEB_BUILD_OPTIONS+= nocheck + DEB_BUILD_OPTIONS+= nostrip endif ifndef MAKE_TARGET @@ -88,14 +92,19 @@ override_dh_auto_build: $(MAKE) $(THREADS_COUNT) -C $(BUILDDIR) $(MAKE_TARGET) override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) cd $(BUILDDIR) && ctest $(THREADS_COUNT) -V -E with_server +endif override_dh_clean: rm -rf debian/copyright debian/clickhouse-client.docs debian/clickhouse-common-static.docs - dh_clean -X contrib + dh_clean # -X contrib override_dh_strip: +#https://www.debian.org/doc/debian-policy/ch-source.html#debian-rules-and-deb-build-options +ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS))) dh_strip -pclickhouse-common-static --dbg-package=clickhouse-common-static-dbg +endif override_dh_install: # Making docs diff --git a/docker/builder/Dockerfile b/docker/builder/Dockerfile index f2dc484a438..53a591ca4da 100644 --- a/docker/builder/Dockerfile +++ b/docker/builder/Dockerfile @@ -23,6 +23,7 @@ RUN apt-get update -y \ python-termcolor \ sudo \ tzdata \ + llvm-10 \ clang-10 \ clang-tidy-10 \ lld-10 \ diff --git a/docker/client/Dockerfile b/docker/client/Dockerfile index 978538e73cc..493cdaac543 100644 --- a/docker/client/Dockerfile +++ b/docker/client/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -ARG repository="deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" +ARG repository="deb https://repo.clickhouse.tech/deb/stable/ main/" ARG version=20.5.1.* RUN apt-get update \ @@ -16,7 +16,8 @@ RUN apt-get update \ apt-get install --allow-unauthenticated --yes --no-install-recommends \ clickhouse-client=$version \ clickhouse-common-static=$version \ - locales + locales \ + tzdata \ && rm -rf /var/lib/apt/lists/* /var/cache/debconf \ && apt-get clean diff --git a/docker/images.json b/docker/images.json index 450f5ae3966..7a8b4e57244 100644 --- a/docker/images.json +++ b/docker/images.json @@ -10,6 +10,7 @@ "docker/test/stateful": "yandex/clickhouse-stateful-test", "docker/test/stateful_with_coverage": "yandex/clickhouse-stateful-test-with-coverage", "docker/test/stateless": "yandex/clickhouse-stateless-test", + "docker/test/stateless_pytest": "yandex/clickhouse-stateless-pytest", "docker/test/stateless_with_coverage": "yandex/clickhouse-stateless-test-with-coverage", "docker/test/unit": "yandex/clickhouse-unit-test", "docker/test/stress": "yandex/clickhouse-stress-test", diff --git a/docker/packager/README.md b/docker/packager/README.md index 9c764ec3640..9fbc2d7f8b5 100644 --- a/docker/packager/README.md +++ b/docker/packager/README.md @@ -18,11 +18,11 @@ $ ls -l deb/test_output ``` -Build ClickHouse binary with `clang-9` and `address` sanitizer in `relwithdebuginfo` +Build ClickHouse binary with `clang-10` and `address` sanitizer in `relwithdebuginfo` mode: ``` $ mkdir $HOME/some_clickhouse -$ ./packager --output-dir=$HOME/some_clickhouse --package-type binary --compiler=clang-9 --sanitizer=address +$ ./packager --output-dir=$HOME/some_clickhouse --package-type binary --compiler=clang-10 --sanitizer=address $ ls -l $HOME/some_clickhouse -rwxr-xr-x 1 root root 787061952 clickhouse lrwxrwxrwx 1 root root 10 clickhouse-benchmark -> clickhouse diff --git a/docker/packager/binary/Dockerfile b/docker/packager/binary/Dockerfile index b90f509f7ea..34fb8f0ea30 100644 --- a/docker/packager/binary/Dockerfile +++ b/docker/packager/binary/Dockerfile @@ -26,6 +26,7 @@ RUN apt-get update -y \ curl \ gcc-9 \ g++-9 \ + llvm-10 \ clang-10 \ lld-10 \ clang-tidy-10 \ @@ -40,6 +41,9 @@ RUN apt-get update -y \ ninja-build \ gperf \ git \ + opencl-headers \ + ocl-icd-libopencl1 \ + intel-opencl-icd \ tzdata \ gperf \ cmake \ @@ -71,8 +75,8 @@ RUN wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/M # It contains all required headers and libraries. Note that it's named as "gcc" but actually we are using clang for cross compiling. RUN wget "https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en" -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -# Download toolchain for FreeBSD 12.1 -RUN wget https://clickhouse-datasets.s3.yandex.net/toolchains/toolchains/freebsd-12.1-toolchain.tar.xz +# Download toolchain for FreeBSD 11.3 +RUN wget https://clickhouse-datasets.s3.yandex.net/toolchains/toolchains/freebsd-11.3-toolchain.tar.xz COPY build.sh / CMD ["/bin/bash", "/build.sh"] diff --git a/docker/packager/binary/build.sh b/docker/packager/binary/build.sh index a341bbd9840..4b566ef2158 100755 --- a/docker/packager/binary/build.sh +++ b/docker/packager/binary/build.sh @@ -9,16 +9,16 @@ mkdir -p build/cmake/toolchain/linux-aarch64 tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build/cmake/toolchain/linux-aarch64 --strip-components=1 mkdir -p build/cmake/toolchain/freebsd-x86_64 -tar xJf freebsd-12.1-toolchain.tar.xz -C build/cmake/toolchain/freebsd-x86_64 --strip-components=1 +tar xJf freebsd-11.3-toolchain.tar.xz -C build/cmake/toolchain/freebsd-x86_64 --strip-components=1 mkdir -p build/build_docker cd build/build_docker ccache --show-stats ||: ccache --zero-stats ||: +ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /usr/lib/libOpenCL.so ||: rm -f CMakeCache.txt cmake .. -LA -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSANITIZE=$SANITIZER $CMAKE_FLAGS -ninja -ccache --show-stats ||: +ninja clickhouse-bundle mv ./programs/clickhouse* /output mv ./src/unit_tests_dbms /output find . -name '*.so' -print -exec mv '{}' /output \; @@ -46,3 +46,4 @@ then rm -r /output/* mv "$COMBINED_OUTPUT.tgz" /output fi +ccache --show-stats ||: diff --git a/docker/packager/deb/Dockerfile b/docker/packager/deb/Dockerfile index b8e7b06bf6b..8a67ff24692 100644 --- a/docker/packager/deb/Dockerfile +++ b/docker/packager/deb/Dockerfile @@ -5,6 +5,7 @@ RUN apt-get --allow-unauthenticated update -y && apt-get install --yes wget gnup RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - RUN echo "deb [trusted=yes] http://apt.llvm.org/eoan/ llvm-toolchain-eoan-10 main" >> /etc/apt/sources.list + RUN apt-get --allow-unauthenticated update -y \ && env DEBIAN_FRONTEND=noninteractive \ apt-get --allow-unauthenticated install --yes --no-install-recommends \ @@ -17,12 +18,21 @@ RUN apt-get --allow-unauthenticated update -y \ apt-transport-https \ ca-certificates +# Special dpkg-deb (https://github.com/ClickHouse-Extras/dpkg) version which is able +# to compress files using pigz (https://zlib.net/pigz/) instead of gzip. +# Significantly increase deb packaging speed and compatible with old systems +RUN curl -O https://clickhouse-builds.s3.yandex.net/utils/dpkg-deb +RUN chmod +x dpkg-deb +RUN cp dpkg-deb /usr/bin + + # Libraries from OS are only needed to test the "unbundled" build (that is not used in production). RUN apt-get --allow-unauthenticated update -y \ && env DEBIAN_FRONTEND=noninteractive \ apt-get --allow-unauthenticated install --yes --no-install-recommends \ gcc-9 \ g++-9 \ + llvm-10 \ clang-10 \ lld-10 \ clang-tidy-10 \ @@ -44,6 +54,8 @@ RUN apt-get --allow-unauthenticated update -y \ libboost-system-dev \ libboost-filesystem-dev \ libboost-thread-dev \ + libboost-iostreams-dev \ + libboost-regex-dev \ zlib1g-dev \ liblz4-dev \ libdouble-conversion-dev \ @@ -56,6 +68,9 @@ RUN apt-get --allow-unauthenticated update -y \ libre2-dev \ libjemalloc-dev \ libmsgpack-dev \ + opencl-headers \ + ocl-icd-libopencl1 \ + intel-opencl-icd \ unixodbc-dev \ odbcinst \ tzdata \ @@ -66,14 +81,12 @@ RUN apt-get --allow-unauthenticated update -y \ gdb \ pigz \ moreutils \ - libcctz-dev + libcctz-dev \ + libldap2-dev \ + libsasl2-dev \ + heimdal-multidev \ + libhyperscan-dev -# Special dpkg-deb (https://github.com/ClickHouse-Extras/dpkg) version which is able -# to compress files using pigz (https://zlib.net/pigz/) instead of gzip. -# Significantly increase deb packaging speed and compatible with old systems -RUN curl -O https://clickhouse-builds.s3.yandex.net/utils/dpkg-deb -RUN chmod +x dpkg-deb -RUN cp dpkg-deb /usr/bin # This symlink required by gcc to find lld compiler RUN ln -s /usr/bin/lld-10 /usr/bin/ld.lld diff --git a/docker/packager/deb/build.sh b/docker/packager/deb/build.sh index 6d5144266ae..fbaa0151c6b 100755 --- a/docker/packager/deb/build.sh +++ b/docker/packager/deb/build.sh @@ -10,4 +10,16 @@ mv *.changes /output mv *.buildinfo /output mv /*.rpm /output ||: # if exists mv /*.tgz /output ||: # if exists + +if [ -n "$BINARY_OUTPUT" ] && { [ "$BINARY_OUTPUT" = "programs" ] || [ "$BINARY_OUTPUT" = "tests" ] ;} +then + echo Place $BINARY_OUTPUT to output + mkdir /output/binary ||: # if exists + mv /build/obj-*/programs/clickhouse* /output/binary + if [ "$BINARY_OUTPUT" = "tests" ] + then + mv /build/obj-*/src/unit_tests_dbms /output/binary + fi +fi ccache --show-stats ||: +ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /usr/lib/libOpenCL.so ||: diff --git a/docker/packager/packager b/docker/packager/packager index 71380b92fac..ccb01a4df92 100755 --- a/docker/packager/packager +++ b/docker/packager/packager @@ -54,7 +54,7 @@ def run_docker_image_with_env(image_name, output, env_variables, ch_root, ccache subprocess.check_call(cmd, shell=True) -def parse_env_variables(build_type, compiler, sanitizer, package_type, image_type, cache, distcc_hosts, unbundled, split_binary, clang_tidy, version, author, official, alien_pkgs, with_coverage): +def parse_env_variables(build_type, compiler, sanitizer, package_type, image_type, cache, distcc_hosts, unbundled, split_binary, clang_tidy, version, author, official, alien_pkgs, with_coverage, with_binaries): CLANG_PREFIX = "clang" DARWIN_SUFFIX = "-darwin" ARM_SUFFIX = "-aarch64" @@ -120,6 +120,7 @@ def parse_env_variables(build_type, compiler, sanitizer, package_type, image_typ result.append("CCACHE_BASEDIR=/build") result.append("CCACHE_NOHASHDIR=true") result.append("CCACHE_COMPILERCHECK=content") + result.append("CCACHE_MAXSIZE=15G") # result.append("CCACHE_UMASK=777") if distcc_hosts: @@ -131,9 +132,17 @@ def parse_env_variables(build_type, compiler, sanitizer, package_type, image_typ if alien_pkgs: result.append("ALIEN_PKGS='" + ' '.join(['--' + pkg for pkg in alien_pkgs]) + "'") + if with_binaries == "programs": + result.append('BINARY_OUTPUT=programs') + elif with_binaries == "tests": + result.append('ENABLE_TESTS=1') + result.append('BINARY_OUTPUT=tests') + cmake_flags.append('-DENABLE_TESTS=1') + cmake_flags.append('-DUSE_GTEST=1') + if unbundled: # TODO: fix build with ENABLE_RDKAFKA - cmake_flags.append('-DUNBUNDLED=1 -DENABLE_MYSQL=0 -DENABLE_POCO_ODBC=0 -DENABLE_ODBC=0 -DENABLE_REPLXX=0 -DENABLE_RDKAFKA=0') + cmake_flags.append('-DUNBUNDLED=1 -DENABLE_MYSQL=0 -DENABLE_ODBC=0 -DENABLE_REPLXX=0 -DENABLE_RDKAFKA=0') if split_binary: cmake_flags.append('-DUSE_STATIC_LIBRARIES=0 -DSPLIT_SHARED_LIBRARIES=1 -DCLICKHOUSE_SPLIT_BINARY=1') @@ -162,10 +171,10 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description="ClickHouse building script using prebuilt Docker image") # 'performance' creates a combined .tgz with server and configs to be used for performance test. parser.add_argument("--package-type", choices=['deb', 'binary', 'performance'], required=True) - parser.add_argument("--clickhouse-repo-path", default="../../") + parser.add_argument("--clickhouse-repo-path", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)) parser.add_argument("--output-dir", required=True) parser.add_argument("--build-type", choices=("debug", ""), default="") - parser.add_argument("--compiler", choices=("clang-8", "clang-8-darwin", "clang-9-aarch64", "clang-9-freebsd", "gcc-8", "gcc-9", "clang-9"), default="gcc-8") + parser.add_argument("--compiler", choices=("clang-10-darwin", "clang-10-aarch64", "clang-10-freebsd", "gcc-9", "clang-10"), default="gcc-9") parser.add_argument("--sanitizer", choices=("address", "thread", "memory", "undefined", ""), default="") parser.add_argument("--unbundled", action="store_true") parser.add_argument("--split-binary", action="store_true") @@ -179,6 +188,7 @@ if __name__ == "__main__": parser.add_argument("--official", action="store_true") parser.add_argument("--alien-pkgs", nargs='+', default=[]) parser.add_argument("--with-coverage", action="store_true") + parser.add_argument("--with-binaries", choices=("programs", "tests", ""), default="") args = parser.parse_args() if not os.path.isabs(args.output_dir): @@ -195,6 +205,12 @@ if __name__ == "__main__": if args.alien_pkgs and not image_type == "deb": raise Exception("Can add alien packages only in deb build") + if args.with_binaries != "" and not image_type == "deb": + raise Exception("Can add additional binaries only in deb build") + + if args.with_binaries != "" and image_type == "deb": + logging.info("Should place {} to output".format(args.with_binaries)) + dockerfile = os.path.join(ch_root, "docker/packager", image_type, "Dockerfile") if image_type != "freebsd" and not check_image_exists_locally(image_name) or args.force_build_image: if not pull_image(image_name) or args.force_build_image: @@ -202,6 +218,6 @@ if __name__ == "__main__": env_prepared = parse_env_variables( args.build_type, args.compiler, args.sanitizer, args.package_type, image_type, args.cache, args.distcc_hosts, args.unbundled, args.split_binary, args.clang_tidy, - args.version, args.author, args.official, args.alien_pkgs, args.with_coverage) + args.version, args.author, args.official, args.alien_pkgs, args.with_coverage, args.with_binaries) run_docker_image_with_env(image_name, args.output_dir, env_prepared, ch_root, args.ccache_dir) logging.info("Output placed into {}".format(args.output_dir)) diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile index faa5a593eb2..3a16a1fd158 100644 --- a/docker/server/Dockerfile +++ b/docker/server/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -ARG repository="deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" +ARG repository="deb https://repo.clickhouse.tech/deb/stable/ main/" ARG version=20.5.1.* ARG gosu_ver=1.10 @@ -21,6 +21,7 @@ RUN apt-get update \ locales \ ca-certificates \ wget \ + tzdata \ && rm -rf \ /var/lib/apt/lists/* \ /var/cache/debconf \ diff --git a/docker/server/README.md b/docker/server/README.md index b36bbe40dc7..e8e8d326de7 100644 --- a/docker/server/README.md +++ b/docker/server/README.md @@ -45,6 +45,14 @@ When you use the image with mounting local directories inside you probably would $ docker run --rm -e CLICKHOUSE_UID=0 -e CLICKHOUSE_GID=0 --name clickhouse-server-userns -v "$(pwd)/logs/clickhouse:/var/log/clickhouse-server" -v "$(pwd)/data/clickhouse:/var/lib/clickhouse" yandex/clickhouse-server ``` +### How to create default database and user on starting + +Sometimes you may want to create user (user named `default` is used by default) and database on image starting. You can do it using environment variables `CLICKHOUSE_DB`, `CLICKHOUSE_USER` and `CLICKHOUSE_PASSWORD`: + +``` +$ docker run --rm -e CLICKHOUSE_DB=my_database -e CLICKHOUSE_USER=username -e CLICKHOUSE_PASSWORD=password -p 9000:9000/tcp yandex/clickhouse-server +``` + ## How to extend this image If you would like to do additional initialization in an image derived from this one, add one or more `*.sql`, `*.sql.gz`, or `*.sh` scripts under `/docker-entrypoint-initdb.d`. After the entrypoint calls `initdb` it will run any `*.sql` files, run any executable `*.sh` scripts, and source any non-executable `*.sh` scripts found in that directory to do further initialization before starting the service. diff --git a/docker/server/entrypoint.sh b/docker/server/entrypoint.sh index fbab44de2b7..8fc9c670b06 100644 --- a/docker/server/entrypoint.sh +++ b/docker/server/entrypoint.sh @@ -35,7 +35,10 @@ LOG_DIR="$(dirname $LOG_PATH || true)" ERROR_LOG_PATH="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=logger.errorlog || true)" ERROR_LOG_DIR="$(dirname $ERROR_LOG_PATH || true)" FORMAT_SCHEMA_PATH="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=format_schema_path || true)" + CLICKHOUSE_USER="${CLICKHOUSE_USER:-default}" +CLICKHOUSE_PASSWORD="${CLICKHOUSE_PASSWORD:-}" +CLICKHOUSE_DB="${CLICKHOUSE_DB:-}" for dir in "$DATA_DIR" \ "$ERROR_LOG_DIR" \ @@ -61,15 +64,37 @@ do fi done +# if clickhouse user is defined - create it (user "default" already exists out of box) +if [ -n "$CLICKHOUSE_USER" ] && [ "$CLICKHOUSE_USER" != "default" ] || [ -n "$CLICKHOUSE_PASSWORD" ]; then + echo "$0: create new user '$CLICKHOUSE_USER' instead 'default'" + cat < /etc/clickhouse-server/users.d/default-user.xml + + + + + + + <${CLICKHOUSE_USER}> + default + + ::/0 + + ${CLICKHOUSE_PASSWORD} + default + + + +EOT +fi -if [ -n "$(ls /docker-entrypoint-initdb.d/)" ]; then +if [ -n "$(ls /docker-entrypoint-initdb.d/)" ] || [ -n "$CLICKHOUSE_DB" ]; then $gosu /usr/bin/clickhouse-server --config-file=$CLICKHOUSE_CONFIG & pid="$!" # check if clickhouse is ready to accept connections # will try to send ping clickhouse via http_port (max 12 retries, with 1 sec delay) - if ! wget --spider --quiet --tries=12 --waitretry=1 --retry-connrefused "http://localhost:$HTTP_PORT/ping" ; then + if ! wget --spider --quiet --prefer-family=IPv6 --tries=12 --waitretry=1 --retry-connrefused "http://localhost:$HTTP_PORT/ping" ; then echo >&2 'ClickHouse init process failed.' exit 1 fi @@ -81,6 +106,13 @@ if [ -n "$(ls /docker-entrypoint-initdb.d/)" ]; then clickhouseclient=( clickhouse-client --multiquery -u $CLICKHOUSE_USER $WITH_PASSWORD ) echo + + # create default database, if defined + if [ -n "$CLICKHOUSE_DB" ]; then + echo "$0: create database '$CLICKHOUSE_DB'" + "${clickhouseclient[@]}" -q "CREATE DATABASE IF NOT EXISTS $CLICKHOUSE_DB"; + fi + for f in /docker-entrypoint-initdb.d/*; do case "$f" in *.sh) diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index 1dd756ed7c2..6673d32c2e2 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -ARG repository="deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" +ARG repository="deb https://repo.clickhouse.tech/deb/stable/ main/" ARG version=20.5.1.* RUN apt-get update && \ diff --git a/docker/test/coverage/Dockerfile b/docker/test/coverage/Dockerfile index 00f3c37ff00..9ce480f38d8 100644 --- a/docker/test/coverage/Dockerfile +++ b/docker/test/coverage/Dockerfile @@ -12,14 +12,13 @@ RUN apt-get --allow-unauthenticated update -y \ software-properties-common -RUN echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main" >> /etc/apt/sources.list - RUN apt-get --allow-unauthenticated update -y \ && env DEBIAN_FRONTEND=noninteractive \ apt-get --allow-unauthenticated install --yes --no-install-recommends \ perl \ lcov \ - llvm-9 \ + clang-10 \ + llvm-10 \ tzdata @@ -29,8 +28,8 @@ ENV OUTPUT_DIR=/output ENV IGNORE='.*contrib.*' -CMD mkdir -p /build/obj-x86_64-linux-gnu && cd /build/obj-x86_64-linux-gnu && CC=clang-8 CXX=clang++-8 cmake .. && cd /; \ +CMD mkdir -p /build/obj-x86_64-linux-gnu && cd /build/obj-x86_64-linux-gnu && CC=clang-10 CXX=clang++-10 cmake .. && cd /; \ dpkg -i /package_folder/clickhouse-common-static_*.deb; \ - llvm-profdata-9 merge -sparse ${COVERAGE_DIR}/* -o clickhouse.profdata && \ - llvm-cov-9 export /usr/bin/clickhouse -instr-profile=clickhouse.profdata -j=16 -format=lcov -skip-functions -ignore-filename-regex $IGNORE > output.lcov && \ + llvm-profdata-10 merge -sparse ${COVERAGE_DIR}/* -o clickhouse.profdata && \ + llvm-cov-10 export /usr/bin/clickhouse -instr-profile=clickhouse.profdata -j=16 -format=lcov -skip-functions -ignore-filename-regex $IGNORE > output.lcov && \ genhtml output.lcov --ignore-errors source --output-directory ${OUTPUT_DIR} diff --git a/docker/test/integration/compose/docker_compose_cassandra.yml b/docker/test/integration/compose/docker_compose_cassandra.yml new file mode 100644 index 00000000000..6567a352027 --- /dev/null +++ b/docker/test/integration/compose/docker_compose_cassandra.yml @@ -0,0 +1,7 @@ +version: '2.3' +services: + cassandra1: + image: cassandra + restart: always + ports: + - 9043:9042 diff --git a/docker/test/integration/compose/docker_compose_hdfs.yml b/docker/test/integration/compose/docker_compose_hdfs.yml index 010a6cd37c1..d19aacfc8d4 100644 --- a/docker/test/integration/compose/docker_compose_hdfs.yml +++ b/docker/test/integration/compose/docker_compose_hdfs.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: hdfs1: image: sequenceiq/hadoop-docker:2.7.0 diff --git a/docker/test/integration/compose/docker_compose_kafka.yml b/docker/test/integration/compose/docker_compose_kafka.yml index 16cbec5f333..219d977ffd9 100644 --- a/docker/test/integration/compose/docker_compose_kafka.yml +++ b/docker/test/integration/compose/docker_compose_kafka.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: kafka_zookeeper: diff --git a/docker/test/integration/compose/docker_compose_minio.yml b/docker/test/integration/compose/docker_compose_minio.yml index 41816427794..eefbe4abff5 100644 --- a/docker/test/integration/compose/docker_compose_minio.yml +++ b/docker/test/integration/compose/docker_compose_minio.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: minio1: @@ -16,6 +16,9 @@ services: interval: 30s timeout: 20s retries: 3 + depends_on: + - redirect + - resolver # Redirects all requests to origin Minio. redirect: @@ -27,5 +30,29 @@ services: - SERVER_REDIRECT_CODE=307 - SERVER_ACCESS_LOG=/nginx/access.log +# HTTP proxies for Minio. + proxy1: + image: vimagick/tinyproxy + ports: + - "4081:8888" + + proxy2: + image: vimagick/tinyproxy + ports: + - "4082:8888" + +# Empty container to run proxy resolver. + resolver: + build: + context: ../../../docker/test/integration/ + dockerfile: resolver/Dockerfile + network: host + ports: + - "4083:8080" + tty: true + depends_on: + - proxy1 + - proxy2 + volumes: data1-1: diff --git a/docker/test/integration/compose/docker_compose_mongo.yml b/docker/test/integration/compose/docker_compose_mongo.yml index a593c3e123b..8c54544ed88 100644 --- a/docker/test/integration/compose/docker_compose_mongo.yml +++ b/docker/test/integration/compose/docker_compose_mongo.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: mongo1: image: mongo:3.6 @@ -8,3 +8,4 @@ services: MONGO_INITDB_ROOT_PASSWORD: clickhouse ports: - 27018:27017 + command: --profile=2 --verbose diff --git a/docker/test/integration/compose/docker_compose_mysql.yml b/docker/test/integration/compose/docker_compose_mysql.yml index 30c76ef1981..2e3afce117d 100644 --- a/docker/test/integration/compose/docker_compose_mysql.yml +++ b/docker/test/integration/compose/docker_compose_mysql.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: mysql1: image: mysql:5.7 diff --git a/docker/test/integration/compose/docker_compose_net.yml b/docker/test/integration/compose/docker_compose_net.yml index 4e8cabe5403..eff43681f2e 100644 --- a/docker/test/integration/compose/docker_compose_net.yml +++ b/docker/test/integration/compose/docker_compose_net.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' networks: default: driver: bridge diff --git a/docker/test/integration/compose/docker_compose_postgres.yml b/docker/test/integration/compose/docker_compose_postgres.yml index 0745fe827c0..ffc4d3164b5 100644 --- a/docker/test/integration/compose/docker_compose_postgres.yml +++ b/docker/test/integration/compose/docker_compose_postgres.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: postgres1: image: postgres diff --git a/docker/test/integration/compose/docker_compose_redis.yml b/docker/test/integration/compose/docker_compose_redis.yml index 205409b3a21..2dc79ed5910 100644 --- a/docker/test/integration/compose/docker_compose_redis.yml +++ b/docker/test/integration/compose/docker_compose_redis.yml @@ -1,4 +1,4 @@ -version: '2.2' +version: '2.3' services: redis1: image: redis diff --git a/docker/test/integration/compose/docker_compose_zookeeper.yml b/docker/test/integration/compose/docker_compose_zookeeper.yml index 284e4a855dd..49e285b5515 100644 --- a/docker/test/integration/compose/docker_compose_zookeeper.yml +++ b/docker/test/integration/compose/docker_compose_zookeeper.yml @@ -1,25 +1,47 @@ -version: '2.2' +version: '2.3' services: zoo1: image: zookeeper:3.4.12 restart: always environment: ZOO_TICK_TIME: 500 - ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 - + ZOO_MY_ID: 1 + JVMFLAGS: -Dzookeeper.forceSync=no + volumes: + - type: ${ZK_FS:-tmpfs} + source: ${ZK_DATA1:-} + target: /data + - type: ${ZK_FS:-tmpfs} + source: ${ZK_DATA_LOG1:-} + target: /datalog zoo2: image: zookeeper:3.4.12 restart: always environment: ZOO_TICK_TIME: 500 - ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 - + ZOO_MY_ID: 2 + JVMFLAGS: -Dzookeeper.forceSync=no + volumes: + - type: ${ZK_FS:-tmpfs} + source: ${ZK_DATA2:-} + target: /data + - type: ${ZK_FS:-tmpfs} + source: ${ZK_DATA_LOG2:-} + target: /datalog zoo3: image: zookeeper:3.4.12 restart: always environment: ZOO_TICK_TIME: 500 - ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 + ZOO_MY_ID: 3 + JVMFLAGS: -Dzookeeper.forceSync=no + volumes: + - type: ${ZK_FS:-tmpfs} + source: ${ZK_DATA3:-} + target: /data + - type: ${ZK_FS:-tmpfs} + source: ${ZK_DATA_LOG3:-} + target: /datalog diff --git a/docker/test/integration/resolver/Dockerfile b/docker/test/integration/resolver/Dockerfile new file mode 100644 index 00000000000..37118b7a555 --- /dev/null +++ b/docker/test/integration/resolver/Dockerfile @@ -0,0 +1,4 @@ +# Helper docker container to run python bottle apps + +FROM python:3 +RUN python -m pip install bottle \ No newline at end of file diff --git a/docker/test/integration/runner/Dockerfile b/docker/test/integration/runner/Dockerfile index 648b98fa60d..9c1fe66cf7b 100644 --- a/docker/test/integration/runner/Dockerfile +++ b/docker/test/integration/runner/Dockerfile @@ -22,6 +22,7 @@ RUN apt-get update \ libicu-dev \ bsdutils \ curl \ + python-pika \ liblua5.1-dev \ luajit \ libssl-dev \ @@ -35,7 +36,7 @@ RUN apt-get update \ ENV TZ=Europe/Moscow RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -RUN pip install urllib3==1.23 pytest docker-compose==1.22.0 docker dicttoxml kazoo PyMySQL psycopg2==2.7.5 pymongo tzlocal kafka-python protobuf redis aerospike pytest-timeout minio rpm-confluent-schemaregistry +RUN pip install urllib3==1.23 pytest docker-compose==1.22.0 docker dicttoxml kazoo PyMySQL psycopg2==2.7.5 pymongo tzlocal kafka-python protobuf redis aerospike pytest-timeout minio rpm-confluent-schemaregistry grpcio grpcio-tools cassandra-driver ENV DOCKER_CHANNEL stable ENV DOCKER_VERSION 17.09.1-ce diff --git a/docker/test/performance-comparison/README.md b/docker/test/performance-comparison/README.md new file mode 100644 index 00000000000..b36bbc531c4 --- /dev/null +++ b/docker/test/performance-comparison/README.md @@ -0,0 +1,110 @@ +# [draft] Performance comparison test + +This is an experimental mode that compares performance of old and new server +side by side. Both servers are run, and the query is executed on one then another, +measuring the times. This setup should remove much of the variability present in +the current performance tests, which only run the new version and compare with +the old results recorded some time in the past. + +To interpret the observed results, we build randomization distribution for the +observed difference of median times between old and new server, under the null +hypothesis that the performance distribution is the same (for the details of the +method, see [1]). We consider the observed difference in performance significant, +if it is above 5% and above the 95th percentile of the randomization distribution. +We also consider the test to be unstable, if the observed difference is less than +5%, but the 95th percentile is above 5% -- this means that we are likely to observe +performance differences above 5% more often than in 5% runs, so the test is likely +to have false positives. + +### How to read the report + +Should add inline comments there, because who reads the docs anyway. They must +be collapsible and I am afraid of Javascript, so I'm going to do it later. + +### How to run +Run the entire docker container, specifying PR number (0 for master) +and SHA of the commit to test. The reference revision is determined as a nearest +ancestor testing release tag. It is possible to specify the reference revision and +pull requests (0 for master) manually. + +``` +docker run --network=host --volume=$(pwd)/workspace:/workspace --volume=$(pwd)/output:/output + [-e REF_PR={} -e REF_SHA={}] + -e PR_TO_TEST={} -e SHA_TO_TEST={} + yandex/clickhouse-performance-comparison +``` + +Then see the `report.html` in the `output` directory. + +There are some environment variables that influence what the test does: + * `-e CHCP_RUNS` -- the number of runs; + * `-e CHPC_TEST_GREP` -- the names of the tests (xml files) to run, interpreted + as a grep pattern. + * `-e CHPC_LOCAL_SCRIPT` -- use the comparison scripts from the docker container and not from the tested commit. + +#### Re-genarate report with your tweaks +From the workspace directory (extracted test output archive): +``` +stage=report compare.sh +``` +More stages are available, e.g. restart servers or run the tests. See the code. + +#### Run a single test on the already configured servers +``` +docker/test/performance-comparison/perf.py --host=localhost --port=9000 --runs=1 tests/performance/logical_functions_small.xml +``` + +#### Run all tests on some custom configuration +Start two servers manually on ports `9001` (old) and `9002` (new). Change to a +new directory to be used as workspace for tests, and try something like this: +``` +$ PATH=$PATH:~/ch4/build-gcc9-rel/programs \ + CHPC_TEST_PATH=~/ch3/ch/tests/performance \ + CHPC_TEST_GREP=visit_param \ + stage=run_tests \ + ~/ch3/ch/docker/test/performance-comparison/compare.sh +``` +* `PATH` must contain `clickhouse-local` and `clickhouse-client`. +* `CHPC_TEST_PATH` -- path to performance test cases, e.g. `tests/performance`. +* `CHPC_TEST_GREP` -- a filter for which tests to run, as a grep pattern. +* `stage` -- from which execution stage to start. To run the tests, use + `run_tests` stage. + +The tests will run, and the `report.html` will be generated in the current +directory. + +More complex setup is possible, but inconvenient and requires some scripting. +See `manual-run.sh` for inspiration. + +#### Compare two published releases +Use `compare-releases.sh`. It will download and extract static + dbg + test +packages for both releases, and then call the main comparison script +`compare.sh`, starting from `configure` stage. +``` +compare-releaseses.sh 19.16.19.85 20.4.2.9 +``` + + +#### Statistical considerations +Generating randomization distribution for medians is tricky. Suppose we have N +runs for each version, and then use the combined 2N run results to make a +virtual experiment. In this experiment, we only have N possible values for +median of each version. This becomes very clear if you sort those 2N runs and +imagine where a window of N runs can be -- the N/2 smallest and N/2 largest +values can never be medians. From these N possible values of +medians, you can obtain (N/2)^2 possible values of absolute median difference. +These numbers are +-1, I'm making an off-by-one error somewhere. So, if your +number of runs is small, e.g. 7, you'll only get 16 possible differences, so +even if you make 100k virtual experiments, the randomization distribution will +have only 16 steps, so you'll get weird effects. So you also have to have +enough runs. You can observe it on real data if you add more output to the +query that calculates randomization distribution, e.g., add a number of unique +median values. Looking even more closely, you can see that the exact +values of medians don't matter, and the randomization distribution for +difference of medians devolves into some kind of ranked test. We could probably +skip all these virtual experiments and calculate the resulting distribution +analytically, but I don't know enough math to do it. It would be something +close to Wilcoxon test distribution. + +### References +1\. Box, Hunter, Hunter "Statictics for exprerimenters", p. 78: "A Randomized Design Used in the Comparison of Standard and Modified Fertilizer Mixtures for Tomato Plants." diff --git a/docker/test/performance-comparison/compare-releases.sh b/docker/test/performance-comparison/compare-releases.sh new file mode 100755 index 00000000000..a93a768f36b --- /dev/null +++ b/docker/test/performance-comparison/compare-releases.sh @@ -0,0 +1,82 @@ +#!/bin/bash +set -ex +set -o pipefail +trap "exit" INT TERM +trap 'kill $(jobs -pr) ||:' EXIT + +left_version=${1} +right_version=${2} + +if [ "$left_version" == "" ] || [ "$right_version" == "" ] +then + >&2 echo Usage: $(basename "$0") left_version right_version + exit 1 +fi + +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +repo_dir=${repo_dir:-$(readlink -f "$script_dir/../../..")} + +function download_package() # (version, path) +{ + version="$1" + path="$2" + cd "$path" + wget -nv -nd -nc "https://repo.clickhouse.tech/deb/stable/main/clickhouse-common-static-dbg_${version}_amd64.deb" ||: + wget -nv -nd -nc "https://repo.clickhouse.tech/deb/stable/main/clickhouse-common-static_${version}_amd64.deb" ||: + wget -nv -nd -nc "https://repo.clickhouse.tech/deb/stable/main/clickhouse-test_${version}_all.deb" ||: + mkdir tmp ||: + for x in *.deb; do dpkg-deb -x "$x" tmp ; done + mv tmp/usr/bin/clickhouse ./clickhouse + mkdir .debug + mv tmp/usr/lib/debug/usr/bin/clickhouse .debug/clickhouse + mv tmp/usr/share/clickhouse-test/performance . + ln -s clickhouse clickhouse-local + ln -s clickhouse clickhouse-client + ln -s clickhouse clickhouse-server + rm -rf tmp +} + +function download +{ + rm -r left right db0 ||: + mkdir left right db0 ||: + + "$script_dir/download.sh" ||: & + + download_package "$left_version" left & + download_package "$right_version" right & + + wait + + rm -rf {right,left}/tmp +} + +function configure +{ + # Configs + cp -av "$script_dir/config" right + cp -av "$script_dir/config" left + cp -av "$repo_dir"/programs/server/config* right/config + cp -av "$repo_dir"/programs/server/user* right/config + cp -av "$repo_dir"/programs/server/config* left/config + cp -av "$repo_dir"/programs/server/user* left/config +} + +function run +{ + left/clickhouse-local --query "select * from system.build_options format PrettySpace" | sed 's/ *$//' | fold -w 80 -s > left-commit.txt + right/clickhouse-local --query "select * from system.build_options format PrettySpace" | sed 's/ *$//' | fold -w 80 -s > right-commit.txt + + PATH=right:"$PATH" \ + CHPC_TEST_PATH=right/performance \ + stage=configure \ + "$script_dir/compare.sh" &> >(tee compare.log) +} + +download +configure +run + +rm output.7z +7z a output.7z ./*.{log,tsv,html,txt,rep,svg} {right,left}/{performance,db/preprocessed_configs} + diff --git a/docker/test/performance-comparison/compare.sh b/docker/test/performance-comparison/compare.sh index 21a51613538..a2760907cb3 100755 --- a/docker/test/performance-comparison/compare.sh +++ b/docker/test/performance-comparison/compare.sh @@ -27,7 +27,7 @@ function configure kill -0 $left_pid disown $left_pid set +m - while ! clickhouse-client --port 9001 --query "select 1" ; do kill -0 $left_pid ; echo . ; sleep 1 ; done + while ! clickhouse-client --port 9001 --query "select 1" && kill -0 $left_pid ; do echo . ; sleep 1 ; done echo server for setup started clickhouse-client --port 9001 --query "create database test" ||: @@ -71,9 +71,9 @@ function restart set +m - while ! clickhouse-client --port 9001 --query "select 1" ; do kill -0 $left_pid ; echo . ; sleep 1 ; done + while ! clickhouse-client --port 9001 --query "select 1" && kill -0 $left_pid ; do echo . ; sleep 1 ; done echo left ok - while ! clickhouse-client --port 9002 --query "select 1" ; do kill -0 $right_pid ; echo . ; sleep 1 ; done + while ! clickhouse-client --port 9002 --query "select 1" && kill -0 $right_pid ; do echo . ; sleep 1 ; done echo right ok clickhouse-client --port 9001 --query "select * from system.tables where database != 'system'" @@ -93,53 +93,51 @@ function run_tests # Just check that the script runs at all "$script_dir/perf.py" --help > /dev/null - # When testing commits from master, use the older test files. This allows the - # tests to pass even when we add new functions and tests for them, that are - # not supported in the old revision. - # When testing a PR, use the test files from the PR so that we can test their - # changes. - test_prefix=$([ "$PR_TO_TEST" == "0" ] && echo left || echo right)/performance + # Find the directory with test files. + if [ -v CHPC_TEST_PATH ] + then + # Use the explicitly set path to directory with test files. + test_prefix="$CHPC_TEST_PATH" + elif [ "$PR_TO_TEST" = "0" ] + then + # When testing commits from master, use the older test files. This + # allows the tests to pass even when we add new functions and tests for + # them, that are not supported in the old revision. + test_prefix=left/performance + else + # For PRs, use newer test files so we can test these changes. + test_prefix=right/performance - for x in {test-times,skipped-tests,wall-clock-times,report-thresholds,client-times}.tsv + # If only the perf tests were changed in the PR, we will run only these + # tests. The list of changed tests in changed-test.txt is prepared in + # entrypoint.sh from git diffs, because it has the cloned repo. Used + # to use rsync for that but it was really ugly and not always correct + # (e.g. when the reference SHA is really old and has some other + # differences to the tested SHA, besides the one introduced by the PR). + changed_test_files=$(sed "s/tests\/performance/${test_prefix//\//\\/}/" changed-tests.txt) + fi + + # Determine which tests to run. + if [ -v CHPC_TEST_GREP ] + then + # Run only explicitly specified tests, if any. + test_files=$(ls "$test_prefix" | grep "$CHPC_TEST_GREP" | xargs -I{} -n1 readlink -f "$test_prefix/{}") + elif [ "$changed_test_files" != "" ] + then + # Use test files that changed in the PR. + test_files="$changed_test_files" + else + # The default -- run all tests found in the test dir. + test_files=$(ls "$test_prefix"/*.xml) + fi + + # Delete old report files. + for x in {test-times,wall-clock-times}.tsv do rm -v "$x" ||: touch "$x" done - - # FIXME a quick crutch to bring the run time down for the unstable tests -- - # if some performance tests xmls were changed in a PR, run only these ones. - if [ "$PR_TO_TEST" != "0" ] - then - # changed-test.txt prepared in entrypoint.sh from git diffs, because it - # has the cloned repo. Used to use rsync for that but it was really ugly - # and not always correct (e.g. when the reference SHA is really old and - # has some other differences to the tested SHA, besides the one introduced - # by the PR). - test_files_override=$(sed "s/tests\/performance/${test_prefix//\//\\/}/" changed-tests.txt) - if [ "$test_files_override" != "" ] - then - test_files=$test_files_override - fi - fi - - # Run only explicitly specified tests, if any - if [ -v CHPC_TEST_GREP ] - then - test_files=$(ls "$test_prefix" | grep "$CHPC_TEST_GREP" | xargs -I{} -n1 readlink -f "$test_prefix/{}") - fi - - if [ "$test_files" == "" ] - then - # FIXME remove some broken long tests - for test_name in {IPv4,IPv6,modulo,parse_engine_file,number_formatting_formats,select_format,arithmetic,cryptographic_hashes,logical_functions_{medium,small}} - do - printf "%s\tMarked as broken (see compare.sh)\n" "$test_name">> skipped-tests.tsv - rm "$test_prefix/$test_name.xml" ||: - done - test_files=$(ls "$test_prefix"/*.xml) - fi - # Run the tests. test_name="" for test in $test_files @@ -156,18 +154,6 @@ function run_tests TIMEFORMAT=$(printf "$test_name\t%%3R\t%%3U\t%%3S\n") # the grep is to filter out set -x output and keep only time output { time "$script_dir/perf.py" --host localhost localhost --port 9001 9002 -- "$test" > "$test_name-raw.tsv" 2> "$test_name-err.log" ; } 2>&1 >/dev/null | grep -v ^+ >> "wall-clock-times.tsv" || continue - - # The test completed with zero status, so we treat stderr as warnings - mv "$test_name-err.log" "$test_name-warn.log" - - grep ^query "$test_name-raw.tsv" | cut -f2- > "$test_name-queries.tsv" - sed -n "s/^client-time/$test_name/p" < "$test_name-raw.tsv" >> "client-times.tsv" - sed -n "s/^threshold/$test_name/p" < "$test_name-raw.tsv" >> "report-thresholds.tsv" - skipped=$(grep ^skipped "$test_name-raw.tsv" | cut -f2-) - if [ "$skipped" != "" ] - then - printf "%s\t%s\n" "$test_name" "$skipped">> skipped-tests.tsv - fi done unset TIMEFORMAT @@ -212,12 +198,14 @@ function get_profiles clickhouse-client --port 9001 --query "select * from system.trace_log format TSVWithNamesAndTypes" > left-trace-log.tsv ||: & clickhouse-client --port 9001 --query "select arrayJoin(trace) addr, concat(splitByChar('/', addressToLine(addr))[-1], '#', demangle(addressToSymbol(addr)) ) name from system.trace_log group by addr format TSVWithNamesAndTypes" > left-addresses.tsv ||: & clickhouse-client --port 9001 --query "select * from system.metric_log format TSVWithNamesAndTypes" > left-metric-log.tsv ||: & + clickhouse-client --port 9001 --query "select * from system.asynchronous_metric_log format TSVWithNamesAndTypes" > left-async-metric-log.tsv ||: & clickhouse-client --port 9002 --query "select * from system.query_log where type = 2 format TSVWithNamesAndTypes" > right-query-log.tsv ||: & clickhouse-client --port 9002 --query "select * from system.query_thread_log format TSVWithNamesAndTypes" > right-query-thread-log.tsv ||: & clickhouse-client --port 9002 --query "select * from system.trace_log format TSVWithNamesAndTypes" > right-trace-log.tsv ||: & clickhouse-client --port 9002 --query "select arrayJoin(trace) addr, concat(splitByChar('/', addressToLine(addr))[-1], '#', demangle(addressToSymbol(addr)) ) name from system.trace_log group by addr format TSVWithNamesAndTypes" > right-addresses.tsv ||: & clickhouse-client --port 9002 --query "select * from system.metric_log format TSVWithNamesAndTypes" > right-metric-log.tsv ||: & + clickhouse-client --port 9002 --query "select * from system.asynchronous_metric_log format TSVWithNamesAndTypes" > right-async-metric-log.tsv ||: & wait @@ -227,126 +215,268 @@ function get_profiles clickhouse-client --port 9002 --query "select 1" } +function build_log_column_definitions +{ +# FIXME This loop builds column definitons from TSVWithNamesAndTypes in an +# absolutely atrocious way. This should be done by the file() function itself. +for x in {right,left}-{addresses,{query,query-thread,trace,metric}-log}.tsv +do + paste -d' ' \ + <(sed -n '1{s/\t/\n/g;p;q}' "$x" | sed 's/\(^.*$\)/"\1"/') \ + <(sed -n '2{s/\t/\n/g;p;q}' "$x" ) \ + | tr '\n' ', ' | sed 's/,$//' > "$x.columns" +done +} + # Build and analyze randomization distribution for all queries. function analyze_queries { -rm -v analyze-commands.txt analyze-errors.log all-queries.tsv unstable-queries.tsv ./*-report.tsv ||: +rm -v analyze-commands.txt analyze-errors.log all-queries.tsv unstable-queries.tsv ./*-report.tsv raw-queries.tsv ||: +rm -rf analyze ||: +mkdir analyze analyze/tmp ||: + +build_log_column_definitions + +# Split the raw test output into files suitable for analysis. +IFS=$'\n' +for test_file in $(find . -maxdepth 1 -name "*-raw.tsv" -print) +do + test_name=$(basename "$test_file" "-raw.tsv") + sed -n "s/^query\t/$test_name\t/p" < "$test_file" >> "analyze/query-runs.tsv" + sed -n "s/^client-time/$test_name/p" < "$test_file" >> "analyze/client-times.tsv" + sed -n "s/^report-threshold/$test_name/p" < "$test_file" >> "analyze/report-thresholds.tsv" + sed -n "s/^skipped/$test_name/p" < "$test_file" >> "analyze/skipped-tests.tsv" + sed -n "s/^display-name/$test_name/p" < "$test_file" >> "analyze/query-display-names.tsv" +done +unset IFS + +# for each query run, prepare array of metrics from query log +clickhouse-local --query " +create view query_runs as select * from file('analyze/query-runs.tsv', TSV, + 'test text, query_index int, query_id text, version UInt8, time float'); + +create view left_query_log as select * + from file('left-query-log.tsv', TSVWithNamesAndTypes, + '$(cat "left-query-log.tsv.columns")'); + +create view right_query_log as select * + from file('right-query-log.tsv', TSVWithNamesAndTypes, + '$(cat "right-query-log.tsv.columns")'); + +create table query_metrics engine File(TSV, -- do not add header -- will parse with grep + 'analyze/query-run-metrics.tsv') + as select + test, query_index, 0 run, version, + [ + -- server-reported time + query_duration_ms / toFloat64(1000) + , toFloat64(memory_usage) + -- client-reported time + , query_runs.time + ] metrics + from ( + select query_duration_ms, memory_usage, query_id, 0 version from left_query_log + union all + select query_duration_ms, memory_usage, query_id, 1 version from right_query_log + ) query_logs + right join query_runs + using (query_id, version) + order by test, query_index + ; +" # This is a lateral join in bash... please forgive me. -# We don't have arrayPermute(), so I have to make random permutations with +# We don't have arrayPermute(), so I have to make random permutations with # `order by rand`, and it becomes really slow if I do it for more than one # query. We also don't have lateral joins. So I just put all runs of each # query into a separate file, and then compute randomization distribution # for each file. I do this in parallel using GNU parallel. +query_index=1 IFS=$'\n' -for test_file in $(find . -maxdepth 1 -name "*-queries.tsv" -print) +for prefix in $(cut -f1,2 "analyze/query-run-metrics.tsv" | sort | uniq) do - test_name=$(basename "$test_file" "-queries.tsv") - query_index=1 - for query in $(cut -d' ' -f1 "$test_file" | sort | uniq) - do - query_prefix="$test_name.q$query_index" - query_index=$((query_index + 1)) - grep -F "$query " "$test_file" > "$query_prefix.tmp" - printf "%s\0\n" \ - "clickhouse-local \ - --file \"$query_prefix.tmp\" \ - --structure 'query text, run int, version UInt32, time float' \ - --query \"$(cat "$script_dir/eqmed.sql")\" \ - >> \"$test_name-report.tsv\"" \ - 2>> analyze-errors.log \ - >> analyze-commands.txt - done + file="analyze/tmp/$(echo "$prefix" | sed 's/\t/_/g').tsv" + grep "^$prefix " "analyze/query-run-metrics.tsv" > "$file" & + printf "%s\0\n" \ + "clickhouse-local \ + --file \"$file\" \ + --structure 'test text, query text, run int, version UInt8, metrics Array(float)' \ + --query \"$(cat "$script_dir/eqmed.sql")\" \ + >> \"analyze/query-reports.tsv\"" \ + 2>> analyze/errors.log \ + >> analyze/commands.txt done wait unset IFS -parallel --verbose --null < analyze-commands.txt +parallel --joblog analyze/parallel-log.txt --null < analyze/commands.txt 2>> analyze/errors.log } # Analyze results function report { - rm -r report ||: -mkdir report ||: +mkdir report report/tmp ||: +rm ./*.{rep,svg} test-times.tsv test-dump.tsv unstable.tsv unstable-query-ids.tsv unstable-query-metrics.tsv changed-perf.tsv unstable-tests.tsv unstable-queries.tsv bad-tests.tsv slow-on-client.tsv all-queries.tsv run-errors.tsv ||: -rm ./*.{rep,svg} test-times.tsv test-dump.tsv unstable.tsv unstable-query-ids.tsv unstable-query-metrics.tsv changed-perf.tsv unstable-tests.tsv unstable-queries.tsv bad-tests.tsv slow-on-client.tsv all-queries.tsv ||: +build_log_column_definitions -cat analyze-errors.log >> report/errors.log ||: +cat analyze/errors.log >> report/errors.log ||: cat profile-errors.log >> report/errors.log ||: clickhouse-local --query " +create view query_display_names as select * from + file('analyze/query-display-names.tsv', TSV, + 'test text, query_index int, query_display_name text') + ; + +create table query_metric_stats engine File(TSVWithNamesAndTypes, + 'report/query-metric-stats.tsv') as + select metric_name, left, right, diff, stat_threshold, test, query_index, + query_display_name + from file ('analyze/query-reports.tsv', TSV, 'left Array(float), + right Array(float), diff Array(float), stat_threshold Array(float), + test text, query_index int') reports + left array join ['server_time', 'memory', 'client_time'] as metric_name, + left, right, diff, stat_threshold + left join query_display_names + on reports.test = query_display_names.test + and reports.query_index = query_display_names.query_index + ; + +-- Main statistics for queries -- query time as reported in query log. create table queries engine File(TSVWithNamesAndTypes, 'report/queries.tsv') as select -- FIXME Comparison mode doesn't make sense for queries that complete - -- immediately, so for now we pretend they don't exist. We don't want to - -- remove them altogether because we want to be able to detect regressions, - -- but the right way to do this is not yet clear. + -- immediately (on the same order of time as noise). We compute average + -- run time between old and new version, and if it is below a threshold, + -- we just skip the query. If there is a significant regression, the + -- average will be above threshold, we'll process it normally and will + -- detect the regression. (left + right) / 2 < 0.02 as short, not short and abs(diff) > report_threshold and abs(diff) > stat_threshold as changed_fail, not short and abs(diff) > report_threshold - 0.05 and abs(diff) > stat_threshold as changed_show, - not short and not changed_fail and stat_threshold > report_threshold + 0.05 as unstable_fail, + not short and not changed_fail and stat_threshold > report_threshold + 0.10 as unstable_fail, not short and not changed_show and stat_threshold > report_threshold - 0.05 as unstable_show, left, right, diff, stat_threshold, if(report_threshold > 0, report_threshold, 0.10) as report_threshold, - reports.test, - -- Truncate long queries. - if(length(query) < 300, query, substr(query, 1, 298) || '...') query - from - ( - select *, - replaceAll(_file, '-report.tsv', '') test - from file('*-report.tsv', TSV, 'left float, right float, diff float, stat_threshold float, query text') - ) reports - left join file('report-thresholds.tsv', TSV, 'test text, report_threshold float') thresholds - using test - ; + test, query_index, query_display_name + from query_metric_stats + left join file('analyze/report-thresholds.tsv', TSV, + 'test text, report_threshold float') thresholds + on query_metric_stats.test = thresholds.test + where metric_name = 'server_time' + order by test, query_index, metric_name + ; -- keep the table in old format so that we can analyze new and old data together create table queries_old_format engine File(TSVWithNamesAndTypes, 'queries.rep') - as select short, changed_fail, unstable_fail, left, right, diff, stat_threshold, test, query + as select short, changed_fail, unstable_fail, left, right, diff, + stat_threshold, test, query_display_name query from queries ; -create table changed_perf_tsv engine File(TSV, 'report/changed-perf.tsv') as - select left, right, diff, stat_threshold, changed_fail, test, query from queries where changed_show - order by abs(diff) desc; - -create table unstable_queries_tsv engine File(TSV, 'report/unstable-queries.tsv') as - select left, right, diff, stat_threshold, unstable_fail, test, query from queries where unstable_show - order by stat_threshold desc; - -create table queries_for_flamegraph engine File(TSVWithNamesAndTypes, 'report/queries-for-flamegraph.tsv') as - select query, test from queries where unstable_show or changed_show +-- save all test runs as JSON for the new comparison page +create table all_query_runs_json engine File(JSON, 'report/all-query-runs.json') as + select test, query_index, query_display_name query, + left, right, diff, stat_threshold, report_threshold, + versions_runs[1] runs_left, versions_runs[2] runs_right + from ( + select + test, query_index, + groupArrayInsertAt(runs, version) versions_runs + from ( + select + test, query_index, version, + groupArray(metrics[1]) runs + from file('analyze/query-run-metrics.tsv', TSV, + 'test text, query_index int, run int, version UInt8, metrics Array(float)') + group by test, query_index, version + ) + group by test, query_index + ) runs + left join query_display_names + on runs.test = query_display_names.test + and runs.query_index = query_display_names.query_index + left join file('analyze/report-thresholds.tsv', + TSV, 'test text, report_threshold float') thresholds + on runs.test = thresholds.test + left join query_metric_stats + on runs.test = query_metric_stats.test + and runs.query_index = query_metric_stats.query_index + where + query_metric_stats.metric_name = 'server_time' ; -create table unstable_tests_tsv engine File(TSV, 'report/bad-tests.tsv') as - select test, sum(unstable_fail) u, sum(changed_fail) c, u + c s from queries - group by test having s > 0 order by s desc; +create table changed_perf_tsv engine File(TSV, 'report/changed-perf.tsv') as + select left, right, diff, stat_threshold, changed_fail, test, query_index, query_display_name + from queries where changed_show order by abs(diff) desc; + +create table unstable_queries_tsv engine File(TSV, 'report/unstable-queries.tsv') as + select left, right, diff, stat_threshold, unstable_fail, test, query_index, query_display_name + from queries where unstable_show order by stat_threshold desc; + +create table queries_for_flamegraph engine File(TSVWithNamesAndTypes, + 'report/queries-for-flamegraph.tsv') as + select test, query_index from queries where unstable_show or changed_show + ; + +create table test_time_changes_tsv engine File(TSV, 'report/test-time-changes.tsv') as + select test, queries, average_time_change from ( + select test, count(*) queries, + sum(left) as left, sum(right) as right, + (right - left) / right average_time_change + from queries + group by test + order by abs(average_time_change) desc + ) + ; + +create table unstable_tests_tsv engine File(TSV, 'report/unstable-tests.tsv') as + select test, sum(unstable_show) total_unstable, sum(changed_show) total_changed + from queries + group by test + order by total_unstable + total_changed desc + ; + +create table test_perf_changes_tsv engine File(TSV, 'report/test-perf-changes.tsv') as + select test, + queries, + coalesce(total_unstable, 0) total_unstable, + coalesce(total_changed, 0) total_changed, + total_unstable + total_changed total_bad, + coalesce(toString(floor(average_time_change, 3)), '??') average_time_change_str + from test_time_changes_tsv + full join unstable_tests_tsv + using test + where (abs(average_time_change) > 0.05 and queries > 5) + or (total_bad > 0) + order by total_bad desc, average_time_change desc + settings join_use_nulls = 1 + ; create table query_time engine Memory as select * - from file('client-times.tsv', TSV, 'test text, query text, client float, server float'); + from file('analyze/client-times.tsv', TSV, + 'test text, query_index int, client float, server float'); create table wall_clock engine Memory as select * from file('wall-clock-times.tsv', TSV, 'test text, real float, user float, system float'); create table slow_on_client_tsv engine File(TSV, 'report/slow-on-client.tsv') as - select client, server, floor(client/server, 3) p, query - from query_time where p > 1.02 order by p desc; + select client, server, floor(client/server, 3) p, test, query_display_name + from query_time left join query_display_names using (test, query_index) + where p > 1.02 order by p desc; create table test_time engine Memory as select test, sum(client) total_client_time, maxIf(client, not short) query_max, minIf(client, not short) query_min, - count(*) queries, - sum(short) short_queries - from query_time full join queries - on query_time.query = queries.query + count(*) queries, sum(short) short_queries + from query_time full join queries using (test, query_index) group by test; create table test_times_tsv engine File(TSV, 'report/test-times.tsv') as @@ -357,142 +487,208 @@ create table test_times_tsv engine File(TSV, 'report/test-times.tsv') as floor(query_max, 3), floor(real / queries, 3) avg_real_per_query, floor(query_min, 3) - from test_time full join wall_clock using test + from test_time + -- wall clock times are also measured for skipped tests, so don't + -- do full join + left join wall_clock using test order by avg_real_per_query desc; +-- report for all queries page, only main metric create table all_tests_tsv engine File(TSV, 'report/all-queries.tsv') as select changed_fail, unstable_fail, left, right, diff, floor(left > right ? left / right : right / left, 3), - stat_threshold, test, query - from queries order by test, query; + stat_threshold, test, query_index, query_display_name + from queries order by test, query_index; + +-- new report for all queries with all metrics (no page yet) +create table all_query_metrics_tsv engine File(TSV, 'report/all-query-metrics.tsv') as + select metric_name, left, right, diff, + floor(left > right ? left / right : right / left, 3), + stat_threshold, test, query_index, query_display_name + from query_metric_stats + order by test, query_index; " 2> >(tee -a report/errors.log 1>&2) -for x in {right,left}-{addresses,{query,query-thread,trace,metric}-log}.tsv -do - # FIXME This loop builds column definitons from TSVWithNamesAndTypes in an - # absolutely atrocious way. This should be done by the file() function itself. - paste -d' ' \ - <(sed -n '1{s/\t/\n/g;p;q}' "$x" | sed 's/\(^.*$\)/"\1"/') \ - <(sed -n '2{s/\t/\n/g;p;q}' "$x" ) \ - | tr '\n' ', ' | sed 's/,$//' > "$x.columns" -done +# Prepare source data for metrics and flamegraphs for unstable queries. for version in {right,left} do -clickhouse-local --query " + rm -rf data + clickhouse-local --query " create view queries_for_flamegraph as select * from file('report/queries-for-flamegraph.tsv', TSVWithNamesAndTypes, - 'query text, test text'); + 'test text, query_index int'); + +create view query_runs as + with 0 as left, 1 as right + select * from file('analyze/query-runs.tsv', TSV, + 'test text, query_index int, query_id text, version UInt8, time float') + where version = $version + ; + +create view query_display_names as select * from + file('analyze/query-display-names.tsv', TSV, + 'test text, query_index int, query_display_name text') + ; + +create table unstable_query_runs engine File(TSVWithNamesAndTypes, + 'unstable-query-runs.$version.rep') as + select test, query_index, query_display_name, query_id + from query_runs + join queries_for_flamegraph on + query_runs.test = queries_for_flamegraph.test + and query_runs.query_index = queries_for_flamegraph.query_index + left join query_display_names on + query_runs.test = query_display_names.test + and query_runs.query_index = query_display_names.query_index + ; create view query_log as select * from file('$version-query-log.tsv', TSVWithNamesAndTypes, '$(cat "$version-query-log.tsv.columns")'); +create table unstable_run_metrics engine File(TSVWithNamesAndTypes, + 'unstable-run-metrics.$version.rep') as + select + test, query_index, query_id, + ProfileEvents.Values value, ProfileEvents.Names metric + from query_log array join ProfileEvents + join unstable_query_runs using (query_id) + ; + +create table unstable_run_metrics_2 engine File(TSVWithNamesAndTypes, + 'unstable-run-metrics-2.$version.rep') as + select + test, query_index, query_id, + v, n + from ( + select + test, query_index, query_id, + ['memory_usage', 'read_bytes', 'written_bytes', 'query_duration_ms'] n, + [memory_usage, read_bytes, written_bytes, query_duration_ms] v + from query_log + join unstable_query_runs using (query_id) + ) + array join v, n; + create view trace_log as select * from file('$version-trace-log.tsv', TSVWithNamesAndTypes, '$(cat "$version-trace-log.tsv.columns")'); -create view addresses_src as select * +create view addresses_src as select addr, + -- Some functions change name between builds, e.g. '__clone' or 'clone' or + -- even '__GI__clone@@GLIBC_2.32'. This breaks differential flame graphs, so + -- filter them out here. + [name, 'clone.S (filtered by script)', 'pthread_cond_timedwait (filtered by script)'] + -- this line is a subscript operator of the above array + [1 + multiSearchFirstIndex(name, ['clone.S', 'pthread_cond_timedwait'])] name from file('$version-addresses.tsv', TSVWithNamesAndTypes, '$(cat "$version-addresses.tsv.columns")'); create table addresses_join_$version engine Join(any, left, address) as select addr address, name from addresses_src; -create table unstable_query_runs engine File(TSVWithNamesAndTypes, - 'unstable-query-runs.$version.rep') as - select query, query_id from query_log - where query in (select query from queries_for_flamegraph) - and query_id not like 'prewarm %' - ; - -create table unstable_query_log engine File(Vertical, - 'unstable-query-log.$version.rep') as - select * from query_log - where query_id in (select query_id from unstable_query_runs); - -create table unstable_run_metrics engine File(TSVWithNamesAndTypes, - 'unstable-run-metrics.$version.rep') as - select ProfileEvents.Values value, ProfileEvents.Names metric, query_id, query - from query_log array join ProfileEvents - where query_id in (select query_id from unstable_query_runs) - ; - -create table unstable_run_metrics_2 engine File(TSVWithNamesAndTypes, - 'unstable-run-metrics-2.$version.rep') as - select v, n, query_id, query - from - (select - ['memory_usage', 'read_bytes', 'written_bytes', 'query_duration_ms'] n, - [memory_usage, read_bytes, written_bytes, query_duration_ms] v, - query, - query_id - from query_log - where query_id in (select query_id from unstable_query_runs)) - array join n, v; - create table unstable_run_traces engine File(TSVWithNamesAndTypes, 'unstable-run-traces.$version.rep') as select + test, query_index, query_id, count() value, - joinGet(addresses_join_$version, 'name', arrayJoin(trace)) metric, - unstable_query_runs.query_id, - any(unstable_query_runs.query) query - from unstable_query_runs - join trace_log on trace_log.query_id = unstable_query_runs.query_id - group by unstable_query_runs.query_id, metric + joinGet(addresses_join_$version, 'name', arrayJoin(trace)) + || '(' || toString(trace_type) || ')' metric + from trace_log + join unstable_query_runs using query_id + group by test, query_index, query_id, metric order by count() desc ; create table metric_devation engine File(TSVWithNamesAndTypes, - 'metric-deviation.$version.rep') as - select query, floor((q[3] - q[1])/q[2], 3) d, - quantilesExact(0, 0.5, 1)(value) q, metric - from (select * from unstable_run_metrics - union all select * from unstable_run_traces - union all select * from unstable_run_metrics_2) mm - join queries_for_flamegraph using query - group by query, metric - having d > 0.5 - order by query desc, d desc + 'report/metric-deviation.$version.tsv') as + -- first goes the key used to split the file with grep + select test, query_index, query_display_name, + d, q, metric + from ( + select + test, query_index, + floor((q[3] - q[1])/q[2], 3) d, + quantilesExact(0, 0.5, 1)(value) q, metric + from (select * from unstable_run_metrics + union all select * from unstable_run_traces + union all select * from unstable_run_metrics_2) mm + group by test, query_index, metric + having d > 0.5 and q[3] > 5 + ) metrics + left join query_display_names using (test, query_index) + order by test, query_index, d desc ; -create table stacks engine File(TSV, 'stacks.$version.rep') as +create table stacks engine File(TSV, 'report/stacks.$version.tsv') as select - query, + -- first goes the key used to split the file with grep + test, query_index, trace_type, any(query_display_name), + -- next go the stacks in flamegraph format: 'func1;...;funcN count' arrayStringConcat( - arrayMap(x -> joinGet(addresses_join_$version, 'name', x), + arrayMap( + addr -> joinGet(addresses_join_$version, 'name', addr), arrayReverse(trace) ), ';' ) readable_trace, - count() + count() c from trace_log join unstable_query_runs using query_id - group by query, trace + group by test, query_index, trace_type, trace + order by test, query_index, trace_type, trace ; " 2> >(tee -a report/errors.log 1>&2) # do not run in parallel because they use the same data dir for StorageJoins which leads to weird errors. done wait +# Create per-query flamegraphs IFS=$'\n' for version in {right,left} do - for query in $(cut -d' ' -f1 "stacks.$version.rep" | sort | uniq) + for query in $(cut -d' ' -f1-4 "report/stacks.$version.tsv" | sort | uniq) do - query_file=$(echo "$query" | cut -c-120 | sed 's/[/]/_/g') + query_file=$(echo "$query" | cut -c-120 | sed 's/[/ ]/_/g') + echo "$query_file" >> report/query-files.txt # Build separate .svg flamegraph for each query. - grep -F "$query " "stacks.$version.rep" \ - | cut -d' ' -f 2- \ + # -F is somewhat unsafe because it might match not the beginning of the + # string, but this is unlikely and escaping the query for grep is a pain. + grep -F "$query " "report/stacks.$version.tsv" \ + | cut -f 5- \ | sed 's/\t/ /g' \ - | tee "$query_file.stacks.$version.rep" \ - | ~/fg/flamegraph.pl > "$query_file.$version.svg" & + | tee "report/tmp/$query_file.stacks.$version.tsv" \ + | ~/fg/flamegraph.pl --hash > "$query_file.$version.svg" & + done +done +wait +unset IFS - # Copy metric stats into separate files as well. - grep -F "$query " "metric-deviation.$version.rep" \ - | cut -f2- > "$query_file.$version.metrics.rep" & +# Create differential flamegraphs. +IFS=$'\n' +for query_file in $(cat report/query-files.txt) +do + ~/fg/difffolded.pl "report/tmp/$query_file.stacks.left.tsv" \ + "report/tmp/$query_file.stacks.right.tsv" \ + | tee "report/tmp/$query_file.stacks.diff.tsv" \ + | ~/fg/flamegraph.pl > "$query_file.diff.svg" & +done +unset IFS +wait + +# Create per-query files with metrics. Note that the key is different from flamegraphs. +IFS=$'\n' +for version in {right,left} +do + for query in $(cut -d' ' -f1-3 "report/metric-deviation.$version.tsv" | sort | uniq) + do + query_file=$(echo "$query" | cut -c-120 | sed 's/[/ ]/_/g') + + # Ditto the above comment about -F. + grep -F "$query " "report/metric-deviation.$version.tsv" \ + | cut -f4- > "$query_file.$version.metrics.rep" & done done wait @@ -538,7 +734,7 @@ case "$stage" in # to collect the logs. Prefer not to restart, because addresses might change # and we won't be able to process trace_log data. Start in a subshell, so that # it doesn't interfere with the watchdog through `wait`. - ( time get_profiles || restart || get_profiles ||: ) + ( get_profiles || restart || get_profiles ||: ) # Kill the whole process group, because somehow when the subshell is killed, # the sleep inside remains alive and orphaned. @@ -549,11 +745,10 @@ case "$stage" in echo Servers stopped. ;& "analyze_queries") - # FIXME grep for set_index fails -- argument list too long. time analyze_queries ||: ;& "report") - time report + time report ||: time "$script_dir/report.py" --report=all-queries > all-queries.html 2> >(tee -a report/errors.log 1>&2) ||: time "$script_dir/report.py" > report.html diff --git a/docker/test/performance-comparison/config/config.d/perf-comparison-tweaks-config.xml b/docker/test/performance-comparison/config/config.d/perf-comparison-tweaks-config.xml index e41ab8eb75d..5dcc3c51eca 100644 --- a/docker/test/performance-comparison/config/config.d/perf-comparison-tweaks-config.xml +++ b/docker/test/performance-comparison/config/config.d/perf-comparison-tweaks-config.xml @@ -19,6 +19,5 @@ 1000 - 0 1000000000 diff --git a/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml b/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml index ce1416ac9dc..6e3e3df5d39 100644 --- a/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml +++ b/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml @@ -5,6 +5,7 @@ 0 1 1 + 1 diff --git a/docker/test/performance-comparison/download.sh b/docker/test/performance-comparison/download.sh index dd030e9f39d..8e09fac77f8 100755 --- a/docker/test/performance-comparison/download.sh +++ b/docker/test/performance-comparison/download.sh @@ -46,7 +46,13 @@ function download done mkdir ~/fg ||: - cd ~/fg && wget -nv -nd -c "https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl" && chmod +x ~/fg/flamegraph.pl & + ( + cd ~/fg + wget -nv -nd -c "https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl" + wget -nv -nd -c "https://raw.githubusercontent.com/brendangregg/FlameGraph/master/difffolded.pl" + chmod +x ~/fg/difffolded.pl + chmod +x ~/fg/flamegraph.pl + ) & wait } diff --git a/docker/test/performance-comparison/entrypoint.sh b/docker/test/performance-comparison/entrypoint.sh index 3bb4733370b..fb3c80ba8a1 100755 --- a/docker/test/performance-comparison/entrypoint.sh +++ b/docker/test/performance-comparison/entrypoint.sh @@ -81,8 +81,20 @@ if [ "$REF_PR" == "" ]; then echo Reference PR is not specified ; exit 1 ; fi fi ) | tee right-commit.txt -# Prepare the list of changed tests for use by compare.sh -git -C ch diff --name-only "$SHA_TO_TEST" "$(git -C ch merge-base "$SHA_TO_TEST"~ master)" -- tests/performance | tee changed-tests.txt +if [ "$PR_TO_TEST" != "0" ] +then + # If the PR only changes the tests and nothing else, prepare a list of these + # tests for use by compare.sh. Compare to merge base, because master might be + # far in the future and have unrelated test changes. + base=$(git -C ch merge-base "$SHA_TO_TEST" master) + git -C ch diff --name-only "$base" "$SHA_TO_TEST" | tee changed-tests.txt + if grep -vq '^tests/performance' changed-tests.txt + then + # Have some other changes besides the tests, so truncate the test list, + # meaning, run all tests. + : > changed-tests.txt + fi +fi # Set python output encoding so that we can print queries with Russian letters. export PYTHONIOENCODING=utf-8 @@ -119,5 +131,5 @@ done dmesg -T > dmesg.log -7z a /output/output.7z ./*.{log,tsv,html,txt,rep,svg} {right,left}/{performance,db/preprocessed_configs} ./report +7z a '-x!*/tmp' /output/output.7z ./*.{log,tsv,html,txt,rep,svg,columns} {right,left}/{performance,db/preprocessed_configs,scripts} report analyze benchmark cp compare.log /output diff --git a/docker/test/performance-comparison/eqmed.sql b/docker/test/performance-comparison/eqmed.sql index 4f8482ea74b..f7f8d6ac40d 100644 --- a/docker/test/performance-comparison/eqmed.sql +++ b/docker/test/performance-comparison/eqmed.sql @@ -1,32 +1,37 @@ --- input is table(query text, run UInt32, version int, time float) +-- input is table(test text, query text, run UInt32, version int, metrics Array(float)) select - floor(original_medians_array.time_by_version[1], 4) l, - floor(original_medians_array.time_by_version[2], 4) r, - floor((r - l) / l, 3) diff_percent, - floor(threshold / l, 3) threshold_percent, - query + arrayMap(x -> floor(x, 4), original_medians_array.medians_by_version[1] as l) l_rounded, + arrayMap(x -> floor(x, 4), original_medians_array.medians_by_version[2] as r) r_rounded, + arrayMap(x, y -> floor((y - x) / x, 3), l, r) diff_percent, + arrayMap(x, y -> floor(x / y, 3), threshold, l) threshold_percent, + test, query from ( -- quantiles of randomization distributions - select quantileExact(0.999)(abs(time_by_label[1] - time_by_label[2]) as d) threshold + select quantileExactForEach(0.999)( + arrayMap(x, y -> abs(x - y), metrics_by_label[1], metrics_by_label[2]) as d + ) threshold ---- uncomment to see what the distribution is really like - --, uniqExact(d) u + --, uniqExact(d.1) u --, arraySort(x->x.1, -- arrayZip( - -- (sumMap([d], [1]) as f).1, + -- (sumMap([d.1], [1]) as f).1, -- f.2)) full_histogram from ( - select virtual_run, groupArrayInsertAt(median_time, random_label) time_by_label -- make array 'random label' -> 'median time' + -- make array 'random label' -> '[median metric]' + select virtual_run, groupArrayInsertAt(median_metrics, random_label) metrics_by_label from ( - select medianExact(time) median_time, virtual_run, random_label -- get median times, grouping by random label + -- get [median metric] arrays among virtual runs, grouping by random label + select medianExactForEach(metrics) median_metrics, virtual_run, random_label from ( - select *, toUInt32(rowNumberInAllBlocks() % 2) random_label -- randomly relabel measurements + -- randomly relabel measurements + select *, toUInt32(rowNumberInAllBlocks() % 2) random_label from ( - select time, number virtual_run + select metrics, number virtual_run from -- strip the query away before the join -- it might be several kB long; - (select time, run, version from table) no_query, + (select metrics, run, version from table) no_query, -- duplicate input measurements into many virtual runs numbers(1, 100000) nn -- for each virtual run, randomly reorder measurements @@ -40,19 +45,19 @@ from -- this select aggregates by virtual_run ) rd, ( - select groupArrayInsertAt(median_time, version) time_by_version + select groupArrayInsertAt(median_metrics, version) medians_by_version from ( - select medianExact(time) median_time, version + select medianExactForEach(metrics) median_metrics, version from table group by version ) original_medians ) original_medians_array, ( - select any(query) query from table + select any(test) test, any(query) query from table ) any_query, ( - select throwIf(uniq(query) != 1) from table + select throwIf(uniq((test, query)) != 1) from table ) check_single_query -- this subselect checks that there is only one query in the input table; -- written this way so that it is not optimized away (#10523) ; diff --git a/docker/test/performance-comparison/perf.py b/docker/test/performance-comparison/perf.py index a749b158e83..308d4760b48 100755 --- a/docker/test/performance-comparison/perf.py +++ b/docker/test/performance-comparison/perf.py @@ -11,6 +11,9 @@ import string import time import traceback +def tsv_escape(s): + return s.replace('\\', '\\\\').replace('\t', '\\t').replace('\n', '\\n').replace('\r','') + stage_start_seconds = time.perf_counter() def report_stage_end(stage_name): @@ -29,6 +32,8 @@ parser.add_argument('--runs', type=int, default=int(os.environ.get('CHPC_RUNS', parser.add_argument('--no-long', type=bool, default=True, help='Skip the tests tagged as long.') args = parser.parse_args() +test_name = os.path.splitext(os.path.basename(args.file[0].name))[0] + tree = et.parse(args.file[0]) root = tree.getroot() @@ -95,11 +100,20 @@ for c in connections: report_stage_end('drop1') -# Apply settings +# Apply settings. +# If there are errors, report them and continue -- maybe a new test uses a setting +# that is not in master, but the queries can still run. If we have multiple +# settings and one of them throws an exception, all previous settings for this +# connection will be reset, because the driver reconnects on error (not +# configurable). So the end result is uncertain, but hopefully we'll be able to +# run at least some queries. settings = root.findall('settings/*') for c in connections: for s in settings: - c.execute("set {} = '{}'".format(s.tag, s.text)) + try: + c.execute("set {} = '{}'".format(s.tag, s.text)) + except: + print(traceback.format_exc(), file=sys.stderr) report_stage_end('settings') @@ -110,8 +124,9 @@ for t in tables: try: res = c.execute("select 1 from {} limit 1".format(t)) except: - print('skipped\t' + traceback.format_exception_only(*sys.exc_info()[:2])[-1]) - traceback.print_exc() + exception_message = traceback.format_exception_only(*sys.exc_info()[:2])[-1] + skipped_message = ' '.join(exception_message.split('\n')[:2]) + print(f'skipped\t{tsv_escape(skipped_message)}') sys.exit(0) report_stage_end('preconditions') @@ -133,27 +148,32 @@ for c in connections: report_stage_end('fill') # Run test queries -def tsv_escape(s): - return s.replace('\\', '\\\\').replace('\t', '\\t').replace('\n', '\\n').replace('\r','') - test_query_templates = [q.text for q in root.findall('query')] test_queries = substitute_parameters(test_query_templates) report_stage_end('substitute2') -for i, q in enumerate(test_queries): +for query_index, q in enumerate(test_queries): + query_prefix = f'{test_name}.query{query_index}' + # We have some crazy long queries (about 100kB), so trim them to a sane - # length. + # length. This means we can't use query text as an identifier and have to + # use the test name + the test-wide query index. query_display_name = q if len(query_display_name) > 1000: - query_display_name = f'{query_display_name[:1000]}...({i})' + query_display_name = f'{query_display_name[:1000]}...({query_index})' + + print(f'display-name\t{query_index}\t{tsv_escape(query_display_name)}') # Prewarm: run once on both servers. Helps to bring the data into memory, # precompile the queries, etc. try: for conn_index, c in enumerate(connections): - res = c.execute(q, query_id = f'prewarm {0} {query_display_name}') - print(f'prewarm\t{tsv_escape(query_display_name)}\t{conn_index}\t{c.last_query.elapsed}') + prewarm_id = f'{query_prefix}.prewarm0' + res = c.execute(q, query_id = prewarm_id) + print(f'prewarm\t{query_index}\t{prewarm_id}\t{conn_index}\t{c.last_query.elapsed}') + except KeyboardInterrupt: + raise except: # If prewarm fails for some query -- skip it, and try to test the others. # This might happen if the new test introduces some function that the @@ -170,13 +190,14 @@ for i, q in enumerate(test_queries): start_seconds = time.perf_counter() server_seconds = 0 for run in range(0, args.runs): + run_id = f'{query_prefix}.run{run}' for conn_index, c in enumerate(connections): - res = c.execute(q) - print(f'query\t{tsv_escape(query_display_name)}\t{run}\t{conn_index}\t{c.last_query.elapsed}') + res = c.execute(q, query_id = run_id) + print(f'query\t{query_index}\t{run_id}\t{conn_index}\t{c.last_query.elapsed}') server_seconds += c.last_query.elapsed client_seconds = time.perf_counter() - start_seconds - print(f'client-time\t{tsv_escape(query_display_name)}\t{client_seconds}\t{server_seconds}') + print(f'client-time\t{query_index}\t{client_seconds}\t{server_seconds}') report_stage_end('benchmark') diff --git a/docker/test/performance-comparison/performance_comparison.md b/docker/test/performance-comparison/performance_comparison.md deleted file mode 100644 index e14bb9d024d..00000000000 --- a/docker/test/performance-comparison/performance_comparison.md +++ /dev/null @@ -1,78 +0,0 @@ -# [draft] Performance comparison test - -This is an experimental mode that compares performance of old and new server -side by side. Both servers are run, and the query is executed on one then another, -measuring the times. This setup should remove much of the variability present in -the current performance tests, which only run the new version and compare with -the old results recorded some time in the past. - -To interpret the observed results, we build randomization distribution for the -observed difference of median times between old and new server, under the null -hypothesis that the performance distribution is the same (for the details of the -method, see [1]). We consider the observed difference in performance significant, -if it is above 5% and above the 95th percentile of the randomization distribution. -We also consider the test to be unstable, if the observed difference is less than -5%, but the 95th percentile is above 5% -- this means that we are likely to observe -performance differences above 5% more often than in 5% runs, so the test is likely -to have false positives. - -### How to read the report - -Should add inline comments there, because who reads the docs anyway. They must -be collapsible and I am afraid of Javascript, so I'm going to do it later. - -### How to run -Run the entire docker container, specifying PR number (0 for master) -and SHA of the commit to test. The reference revision is determined as a nearest -ancestor testing release tag. It is possible to specify the reference revision and -pull requests (0 for master) manually. - -``` -docker run --network=host --volume=$(pwd)/workspace:/workspace --volume=$(pwd)/output:/output - [-e REF_PR={} -e REF_SHA={} -e ] - -e PR_TO_TEST={} -e SHA_TO_TEST={} - yandex/clickhouse-performance-comparison -``` - -Then see the `report.html` in the `output` directory. - -There are some environment variables that influence what the test does: - * `-e CHCP_RUNS` -- the number of runs; - * `-e CHPC_TEST_GREP` -- the names of the tests (xml files) to run, interpreted - as a grep pattern. - -#### Re-genarate report with your tweaks -From the workspace directory (extracted test output archive): -``` -stage=report compare.sh -``` -More stages are available, e.g. restart servers or run the tests. See the code. - -#### Run a single test on the already configured servers -``` -docker/test/performance-comparison/perf.py --host=localhost --port=9000 --runs=1 tests/performance/logical_functions_small.xml -``` - -#### Statistical considerations -Generating randomization distribution for medians is tricky. Suppose we have N -runs for each version, and then use the combined 2N run results to make a -virtual experiment. In this experiment, we only have N possible values for -median of each version. This becomes very clear if you sort those 2N runs and -imagine where a window of N runs can be -- the N/2 smallest and N/2 largest -values can never be medians. From these N possible values of -medians, you can obtain (N/2)^2 possible values of absolute median difference. -These numbers are +-1, I'm making an off-by-one error somewhere. So, if your -number of runs is small, e.g. 7, you'll only get 16 possible differences, so -even if you make 100k virtual experiments, the randomization distribution will -have only 16 steps, so you'll get weird effects. So you also have to have -enough runs. You can observe it on real data if you add more output to the -query that calculates randomization distribution, e.g., add a number of unique -median values. Looking even more closely, you can see that the exact -values of medians don't matter, and the randomization distribution for -difference of medians devolves into some kind of ranked test. We could probably -skip all these virtual experiments and calculate the resulting distribution -analytically, but I don't know enough math to do it. It would be something -close to Wilcoxon test distribution. - -### References -1\. Box, Hunter, Hunter "Statictics for exprerimenters", p. 78: "A Randomized Design Used in the Comparison of Standard and Modified Fertilizer Mixtures for Tomato Plants." diff --git a/docker/test/performance-comparison/report.py b/docker/test/performance-comparison/report.py index 2232a64a249..9db37932aea 100755 --- a/docker/test/performance-comparison/report.py +++ b/docker/test/performance-comparison/report.py @@ -22,6 +22,12 @@ slower_queries = 0 unstable_queries = 0 very_unstable_queries = 0 +# max seconds to run one query by itself, not counting preparation +allowed_single_run_time = 2 + +color_bad='#ffb0c0' +color_good='#b0d050' + header_template = """ @@ -40,14 +46,13 @@ header_template = """ }} body {{ font-family: "Yandex Sans Display Web", Arial, sans-serif; background: #EEE; }} -h1 {{ margin-left: 10px; }} th, td {{ border: 0; padding: 5px 10px 5px 10px; text-align: left; vertical-align: top; line-height: 1.5; background-color: #FFF; td {{ white-space: pre; font-family: Monospace, Courier New; }} border: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 8px 25px -5px rgba(0, 0, 0, 0.1); }} a {{ color: #06F; text-decoration: none; }} a:hover, a:active {{ color: #F40; text-decoration: underline; }} table {{ border: 0; }} -.main {{ margin-left: 10%; }} +.main {{ margin: auto; max-width: 95%; }} p.links a {{ padding: 5px; margin: 3px; background: #FFF; line-height: 2; white-space: nowrap; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 8px 25px -5px rgba(0, 0, 0, 0.1); }} .cancela,.cancela:link,.cancela:visited,.cancela:hover,.cancela:focus,.cancela:active{{ @@ -140,13 +145,52 @@ def printSimpleTable(caption, columns, rows): print(tableRow(row)) print(tableEnd()) +def print_tested_commits(): + global report_errors + try: + printSimpleTable('Tested commits', ['Old', 'New'], + [['
{}
'.format(x) for x in + [open('left-commit.txt').read(), + open('right-commit.txt').read()]]]) + except: + # Don't fail if no commit info -- maybe it's a manual run. + report_errors.append( + traceback.format_exception_only( + *sys.exc_info()[:2])[-1]) + pass + +def print_report_errors(): + global report_errors + # Add the errors reported by various steps of comparison script + try: + report_errors += [l.strip() for l in open('report/errors.log')] + except: + report_errors.append( + traceback.format_exception_only( + *sys.exc_info()[:2])[-1]) + pass + + if len(report_errors): + print(tableStart('Errors while building the report')) + print(tableHeader(['Error'])) + for x in report_errors: + print(tableRow([x])) + print(tableEnd()) + if args.report == 'main': print(header_template.format()) - printSimpleTable('Tested commits', ['Old', 'New'], - [['
{}
'.format(x) for x in - [open('left-commit.txt').read(), - open('right-commit.txt').read()]]]) + print_tested_commits() + + run_error_rows = tsvRows('run-errors.tsv') + error_tests += len(run_error_rows) + printSimpleTable('Run errors', ['Test', 'Error'], run_error_rows) + + slow_on_client_rows = tsvRows('report/slow-on-client.tsv') + error_tests += len(slow_on_client_rows) + printSimpleTable('Slow on client', + ['Client time, s', 'Server time, s', 'Ratio', 'Test', 'Query'], + slow_on_client_rows) def print_changes(): rows = tsvRows('report/changed-perf.tsv') @@ -159,11 +203,12 @@ if args.report == 'main': columns = [ 'Old, s', # 0 'New, s', # 1 - 'Relative difference (new - old)/old', # 2 + 'Relative difference (new − old) / old', # 2 'p < 0.001 threshold', # 3 # Failed # 4 'Test', # 5 - 'Query', # 6 + '#', # 6 + 'Query', # 7 ] print(tableHeader(columns)) @@ -174,10 +219,10 @@ if args.report == 'main': if int(row[4]): if float(row[2]) < 0.: faster_queries += 1 - attrs[2] = 'style="background: #adbdff"' + attrs[2] = f'style="background: {color_good}"' else: slower_queries += 1 - attrs[2] = 'style="background: #ffb0a0"' + attrs[2] = f'style="background: {color_bad}"' else: attrs[2] = '' @@ -187,12 +232,6 @@ if args.report == 'main': print_changes() - slow_on_client_rows = tsvRows('report/slow-on-client.tsv') - error_tests += len(slow_on_client_rows) - printSimpleTable('Slow on client', - ['Client time, s', 'Server time, s', 'Ratio', 'Query'], - slow_on_client_rows) - def print_unstable_queries(): global unstable_queries global very_unstable_queries @@ -210,7 +249,8 @@ if args.report == 'main': 'p < 0.001 threshold', #3 # Failed #4 'Test', #5 - 'Query' #6 + '#', #6 + 'Query' #7 ] print(tableStart('Unstable queries')) @@ -221,7 +261,7 @@ if args.report == 'main': for r in unstable_rows: if int(r[4]): very_unstable_queries += 1 - attrs[3] = 'style="background: #ffb0a0"' + attrs[3] = f'style="background: {color_bad}"' else: attrs[3] = '' @@ -231,16 +271,12 @@ if args.report == 'main': print_unstable_queries() - run_error_rows = tsvRows('run-errors.tsv') - error_tests += len(run_error_rows) - printSimpleTable('Run errors', ['Test', 'Error'], run_error_rows) - - skipped_tests_rows = tsvRows('skipped-tests.tsv') + skipped_tests_rows = tsvRows('analyze/skipped-tests.tsv') printSimpleTable('Skipped tests', ['Test', 'Reason'], skipped_tests_rows) - printSimpleTable('Tests with most unstable queries', - ['Test', 'Unstable', 'Changed perf', 'Total not OK'], - tsvRows('report/bad-tests.tsv')) + printSimpleTable('Test performance changes', + ['Test', 'Queries', 'Unstable', 'Changed perf', 'Total not OK', 'Avg relative time diff'], + tsvRows('report/test-perf-changes.tsv')) def print_test_times(): global slow_average_tests @@ -261,20 +297,21 @@ if args.report == 'main': print(tableStart('Test times')) print(tableHeader(columns)) - - runs = 13 # FIXME pass this as an argument + + nominal_runs = 13 # FIXME pass this as an argument + total_runs = (nominal_runs + 1) * 2 # one prewarm run, two servers attrs = ['' for c in columns] for r in rows: - if float(r[6]) > 3 * runs: + if float(r[6]) > 1.5 * total_runs: # FIXME should be 15s max -- investigate parallel_insert slow_average_tests += 1 - attrs[6] = 'style="background: #ffb0a0"' + attrs[6] = f'style="background: {color_bad}"' else: attrs[6] = '' - if float(r[5]) > 4 * runs: + if float(r[5]) > allowed_single_run_time * total_runs: slow_average_tests += 1 - attrs[5] = 'style="background: #ffb0a0"' + attrs[5] = f'style="background: {color_bad}"' else: attrs[5] = '' @@ -284,21 +321,13 @@ if args.report == 'main': print_test_times() - # Add the errors reported by various steps of comparison script - report_errors += [l.strip() for l in open('report/errors.log')] - if len(report_errors): - print(tableStart('Errors while building the report')) - print(tableHeader(['Error'])) - for x in report_errors: - print(tableRow([x])) - print(tableEnd()) - + print_report_errors() print(""" @@ -316,19 +345,21 @@ if args.report == 'main': message_array.append(str(faster_queries) + ' faster') if slower_queries: - status = 'failure' + if slower_queries > 3: + status = 'failure' message_array.append(str(slower_queries) + ' slower') if unstable_queries: message_array.append(str(unstable_queries) + ' unstable') - if very_unstable_queries: - status = 'failure' +# Disabled before fix. +# if very_unstable_queries: +# status = 'failure' error_tests += slow_average_tests if error_tests: status = 'failure' - message_array.append(str(error_tests) + ' errors') + message_array.insert(0, str(error_tests) + ' errors') if message_array: message = ', '.join(message_array) @@ -346,10 +377,7 @@ elif args.report == 'all-queries': print(header_template.format()) - printSimpleTable('Tested commits', ['Old', 'New'], - [['
{}
'.format(x) for x in - [open('left-commit.txt').read(), - open('right-commit.txt').read()]]]) + print_tested_commits() def print_all_queries(): rows = tsvRows('report/all-queries.tsv') @@ -361,11 +389,12 @@ elif args.report == 'all-queries': # Unstable #1 'Old, s', #2 'New, s', #3 - 'Relative difference (new - old)/old', #4 - 'Times speedup/slowdown', #5 + 'Relative difference (new − old) / old', #4 + 'Times speedup / slowdown', #5 'p < 0.001 threshold', #6 'Test', #7 - 'Query', #8 + '#', #8 + 'Query', #9 ] print(tableStart('All query times')) @@ -376,29 +405,38 @@ elif args.report == 'all-queries': attrs[1] = None for r in rows: if int(r[1]): - attrs[6] = 'style="background: #ffb0a0"' + attrs[6] = f'style="background: {color_bad}"' else: attrs[6] = '' if int(r[0]): if float(r[4]) > 0.: - attrs[4] = 'style="background: #ffb0a0"' + attrs[4] = f'style="background: {color_bad}"' else: - attrs[4] = 'style="background: #adbdff"' + attrs[4] = f'style="background: {color_good}"' else: attrs[4] = '' + if (float(r[2]) + float(r[3])) / 2 > allowed_single_run_time: + attrs[2] = f'style="background: {color_bad}"' + attrs[3] = f'style="background: {color_bad}"' + else: + attrs[2] = '' + attrs[3] = '' + print(tableRow(r, attrs)) print(tableEnd()) print_all_queries() + print_report_errors() + print(""" diff --git a/docker/test/pvs/Dockerfile b/docker/test/pvs/Dockerfile index a3639fb1551..6e573b4648f 100644 --- a/docker/test/pvs/Dockerfile +++ b/docker/test/pvs/Dockerfile @@ -20,10 +20,10 @@ RUN apt-get --allow-unauthenticated update -y \ # apt-get --allow-unauthenticated install --yes --no-install-recommends \ # pvs-studio -ENV PKG_VERSION="pvs-studio-7.07.37949.43-amd64.deb" +ENV PKG_VERSION="pvs-studio-7.07.38234.46-amd64.deb" -RUN wget -q http://files.viva64.com/$PKG_VERSION -RUN sudo dpkg -i $PKG_VERSION +RUN wget "http://files.viva64.com/$PKG_VERSION" +RUN sudo dpkg -i "$PKG_VERSION" CMD cd /repo_folder && pvs-studio-analyzer credentials $LICENCE_NAME $LICENCE_KEY -o ./licence.lic \ && cmake . && ninja re2_st && \ diff --git a/docker/test/split_build_smoke_test/run.sh b/docker/test/split_build_smoke_test/run.sh index 63cd5fada5b..eac9848030e 100755 --- a/docker/test/split_build_smoke_test/run.sh +++ b/docker/test/split_build_smoke_test/run.sh @@ -6,11 +6,14 @@ install_and_run_server() { mkdir /unpacked tar -xzf /package_folder/shared_build.tgz -C /unpacked --strip 1 LD_LIBRARY_PATH=/unpacked /unpacked/clickhouse-server --config /unpacked/config/config.xml >/var/log/clickhouse-server/stderr.log 2>&1 & - sleep 5 } run_client() { - LD_LIBRARY_PATH=/unpacked /unpacked/clickhouse-client --query "select 'OK'" 2>/var/log/clickhouse-server/clientstderr.log || echo "FAIL" + for i in {1..100}; do + sleep 1 + LD_LIBRARY_PATH=/unpacked /unpacked/clickhouse-client --query "select 'OK'" 2>/var/log/clickhouse-server/clientstderr.log && break + [[ $i == 100 ]] && echo 'FAIL' + done } install_and_run_server diff --git a/docker/test/stateful/Dockerfile b/docker/test/stateful/Dockerfile index 4795ac0cfc6..3aff49bf5a1 100644 --- a/docker/test/stateful/Dockerfile +++ b/docker/test/stateful/Dockerfile @@ -16,6 +16,10 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \ dpkg -i package_folder/clickhouse-server_*.deb; \ dpkg -i package_folder/clickhouse-client_*.deb; \ dpkg -i package_folder/clickhouse-test_*.deb; \ + mkdir -p /etc/clickhouse-server/dict_examples; \ + ln -s /usr/share/clickhouse-test/config/ints_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/strings_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/decimals_dictionary.xml /etc/clickhouse-server/dict_examples/; \ ln -s /usr/share/clickhouse-test/config/zookeeper.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/listen.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/part_log.xml /etc/clickhouse-server/config.d/; \ @@ -28,6 +32,8 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \ ln -s /usr/share/clickhouse-test/config/decimals_dictionary.xml /etc/clickhouse-server/; \ ln -s /usr/share/clickhouse-test/config/macros.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/lib/llvm-9/bin/llvm-symbolizer /usr/bin/llvm-symbolizer; \ + if [[ -n "$USE_DATABASE_ATOMIC" ]] && [[ "$USE_DATABASE_ATOMIC" -eq 1 ]]; then ln -s /usr/share/clickhouse-test/config/database_atomic_configd.xml /etc/clickhouse-server/config.d/; fi; \ + if [[ -n "$USE_DATABASE_ATOMIC" ]] && [[ "$USE_DATABASE_ATOMIC" -eq 1 ]]; then ln -s /usr/share/clickhouse-test/config/database_atomic_usersd.xml /etc/clickhouse-server/users.d/; fi; \ echo "TSAN_OPTIONS='verbosity=1000 halt_on_error=1 history_size=7'" >> /etc/environment; \ echo "TSAN_SYMBOLIZER_PATH=/usr/lib/llvm-8/bin/llvm-symbolizer" >> /etc/environment; \ echo "UBSAN_OPTIONS='print_stacktrace=1'" >> /etc/environment; \ diff --git a/docker/test/stateful_with_coverage/Dockerfile b/docker/test/stateful_with_coverage/Dockerfile index e5ddf3d3475..839eea5cdc1 100644 --- a/docker/test/stateful_with_coverage/Dockerfile +++ b/docker/test/stateful_with_coverage/Dockerfile @@ -6,9 +6,7 @@ RUN echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 RUN apt-get update -y \ && env DEBIAN_FRONTEND=noninteractive \ apt-get install --yes --no-install-recommends \ - python-requests \ - llvm-8 \ - llvm-9 + python-requests COPY s3downloader /s3downloader COPY run.sh /run.sh diff --git a/docker/test/stateful_with_coverage/run.sh b/docker/test/stateful_with_coverage/run.sh index 1e89350b3c9..b946f5b187d 100755 --- a/docker/test/stateful_with_coverage/run.sh +++ b/docker/test/stateful_with_coverage/run.sh @@ -20,9 +20,9 @@ start_clickhouse () { } wait_llvm_profdata () { - while kill -0 `pgrep llvm-profdata-9`; + while kill -0 `pgrep llvm-profdata-10`; do - echo "Waiting for profdata" `pgrep llvm-profdata-9` "still alive" + echo "Waiting for profdata" `pgrep llvm-profdata-10` "still alive" sleep 3 done } @@ -31,7 +31,7 @@ merge_client_files_in_background () { client_files=`ls /client_*profraw 2>/dev/null` if [ ! -z "$client_files" ] then - llvm-profdata-9 merge -sparse $client_files -o merged_client_`date +%s`.profraw + llvm-profdata-10 merge -sparse $client_files -o merged_client_`date +%s`.profraw rm $client_files fi } @@ -48,6 +48,13 @@ mkdir -p /var/lib/clickhouse mkdir -p /var/log/clickhouse-server chmod 777 -R /var/log/clickhouse-server/ +# Temorary way to keep CI green while moving dictionaries to separate directory +mkdir -p /etc/clickhouse-server/dict_examples +chmod 777 -R /etc/clickhouse-server/dict_examples +ln -s /usr/share/clickhouse-test/config/ints_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/strings_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/decimals_dictionary.xml /etc/clickhouse-server/dict_examples/; + ln -s /usr/share/clickhouse-test/config/zookeeper.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/listen.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/part_log.xml /etc/clickhouse-server/config.d/; \ diff --git a/docker/test/stateless/Dockerfile b/docker/test/stateless/Dockerfile index a4c5ab5a554..41a53f8a3f5 100644 --- a/docker/test/stateless/Dockerfile +++ b/docker/test/stateless/Dockerfile @@ -54,6 +54,10 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \ dpkg -i package_folder/clickhouse-server_*.deb; \ dpkg -i package_folder/clickhouse-client_*.deb; \ dpkg -i package_folder/clickhouse-test_*.deb; \ + mkdir -p /etc/clickhouse-server/dict_examples; \ + ln -s /usr/share/clickhouse-test/config/ints_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/strings_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/decimals_dictionary.xml /etc/clickhouse-server/dict_examples/; \ ln -s /usr/share/clickhouse-test/config/zookeeper.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/listen.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/part_log.xml /etc/clickhouse-server/config.d/; \ @@ -74,7 +78,9 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \ ln -s /usr/share/clickhouse-test/config/server.key /etc/clickhouse-server/; \ ln -s /usr/share/clickhouse-test/config/server.crt /etc/clickhouse-server/; \ ln -s /usr/share/clickhouse-test/config/dhparam.pem /etc/clickhouse-server/; \ - if [ -n $USE_POLYMORPHIC_PARTS ] && [ $USE_POLYMORPHIC_PARTS -eq 1 ]; then ln -s /usr/share/clickhouse-test/config/polymorphic_parts.xml /etc/clickhouse-server/config.d/; fi; \ + if [[ -n "$USE_POLYMORPHIC_PARTS" ]] && [[ "$USE_POLYMORPHIC_PARTS" -eq 1 ]]; then ln -s /usr/share/clickhouse-test/config/polymorphic_parts.xml /etc/clickhouse-server/config.d/; fi; \ + if [[ -n "$USE_DATABASE_ATOMIC" ]] && [[ "$USE_DATABASE_ATOMIC" -eq 1 ]]; then ln -s /usr/share/clickhouse-test/config/database_atomic_configd.xml /etc/clickhouse-server/config.d/; fi; \ + if [[ -n "$USE_DATABASE_ATOMIC" ]] && [[ "$USE_DATABASE_ATOMIC" -eq 1 ]]; then ln -s /usr/share/clickhouse-test/config/database_atomic_usersd.xml /etc/clickhouse-server/users.d/; fi; \ ln -sf /usr/share/clickhouse-test/config/client_config.xml /etc/clickhouse-client/config.xml; \ service zookeeper start; sleep 5; \ service clickhouse-server start && sleep 5 && clickhouse-test --testname --shard --zookeeper $ADDITIONAL_OPTIONS $SKIP_TESTS_OPTION 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee test_output/test_result.txt diff --git a/docker/test/stateless_pytest/Dockerfile b/docker/test/stateless_pytest/Dockerfile new file mode 100644 index 00000000000..b3b954a105e --- /dev/null +++ b/docker/test/stateless_pytest/Dockerfile @@ -0,0 +1,20 @@ +# docker build -t yandex/clickhouse-stateless-pytest . +FROM yandex/clickhouse-deb-builder + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + python-pip \ + python-setuptools + +RUN pip install \ + pytest \ + pytest-html \ + pytest-timeout \ + pytest-xdist + +CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \ + dpkg -i package_folder/clickhouse-common-static-dbg_*.deb; \ + dpkg -i package_folder/clickhouse-server_*.deb; \ + dpkg -i package_folder/clickhouse-client_*.deb; \ + dpkg -i package_folder/clickhouse-test_*.deb; \ + python -m pytest /usr/share/clickhouse-test/queries -n $(nproc) --html=test_output/report.html --self-contained-html diff --git a/docker/test/stateless_with_coverage/Dockerfile b/docker/test/stateless_with_coverage/Dockerfile index f872f87b3f4..ae4ab56e3d8 100644 --- a/docker/test/stateless_with_coverage/Dockerfile +++ b/docker/test/stateless_with_coverage/Dockerfile @@ -4,8 +4,6 @@ FROM yandex/clickhouse-deb-builder ARG odbc_driver_url="https://github.com/ClickHouse/clickhouse-odbc/releases/download/v1.1.4.20200302/clickhouse-odbc-1.1.4-Linux.tar.gz" -RUN echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main" >> /etc/apt/sources.list - RUN apt-get update -y \ && env DEBIAN_FRONTEND=noninteractive \ apt-get install --yes --no-install-recommends \ @@ -31,7 +29,6 @@ RUN apt-get update -y \ brotli \ gdb \ lsof \ - llvm-9 \ unixodbc \ wget \ qemu-user-static diff --git a/docker/test/stateless_with_coverage/run.sh b/docker/test/stateless_with_coverage/run.sh index 238c7567694..185dc95c783 100755 --- a/docker/test/stateless_with_coverage/run.sh +++ b/docker/test/stateless_with_coverage/run.sh @@ -39,6 +39,13 @@ mkdir -p /var/log/clickhouse-server chmod 777 -R /var/lib/clickhouse chmod 777 -R /var/log/clickhouse-server/ +# Temorary way to keep CI green while moving dictionaries to separate directory +mkdir -p /etc/clickhouse-server/dict_examples +chmod 777 -R /etc/clickhouse-server/dict_examples +ln -s /usr/share/clickhouse-test/config/ints_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/strings_dictionary.xml /etc/clickhouse-server/dict_examples/; \ + ln -s /usr/share/clickhouse-test/config/decimals_dictionary.xml /etc/clickhouse-server/dict_examples/; + ln -s /usr/share/clickhouse-test/config/zookeeper.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/listen.xml /etc/clickhouse-server/config.d/; \ ln -s /usr/share/clickhouse-test/config/part_log.xml /etc/clickhouse-server/config.d/; \ diff --git a/docker/test/stress/Dockerfile b/docker/test/stress/Dockerfile index f022411a031..a5aa3bbf004 100644 --- a/docker/test/stress/Dockerfile +++ b/docker/test/stress/Dockerfile @@ -48,4 +48,4 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \ && clickhouse-client --query "RENAME TABLE datasets.hits_v1 TO test.hits" \ && clickhouse-client --query "RENAME TABLE datasets.visits_v1 TO test.visits" \ && clickhouse-client --query "SHOW TABLES FROM test" \ - && ./stress --output-folder test_output + && ./stress --output-folder test_output --skip-func-tests "$SKIP_TESTS_OPTION" diff --git a/docker/test/stress/stress b/docker/test/stress/stress index 8fb351c1395..92dac8bc2d1 100755 --- a/docker/test/stress/stress +++ b/docker/test/stress/stress @@ -14,14 +14,18 @@ def run_perf_test(cmd, xmls_path, output_folder): p = Popen("{} --skip-tags=long --recursive --input-files {}".format(cmd, xmls_path), shell=True, stdout=f, stderr=f) return p -def run_func_test(cmd, output_prefix, num_processes): +def run_func_test(cmd, output_prefix, num_processes, skip_tests_option): output_paths = [os.path.join(output_prefix, "stress_test_run_{}.txt".format(i)) for i in range(num_processes)] f = open(output_paths[0], 'w') - pipes = [Popen("{}".format(cmd), shell=True, stdout=f, stderr=f)] + main_command = "{} {}".format(cmd, skip_tests_option) + logging.info("Run func tests main cmd '%s'", main_command) + pipes = [Popen(main_command, shell=True, stdout=f, stderr=f)] for output_path in output_paths[1:]: time.sleep(0.5) f = open(output_path, 'w') - p = Popen("{} --order=random".format(cmd), shell=True, stdout=f, stderr=f) + full_command = "{} --order=random {}".format(cmd, skip_tests_option) + logging.info("Run func tests '%s'", full_command) + p = Popen(full_command, shell=True, stdout=f, stderr=f) pipes.append(p) return pipes @@ -37,6 +41,7 @@ if __name__ == "__main__": logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') parser = argparse.ArgumentParser(description="ClickHouse script for running stresstest") parser.add_argument("--test-cmd", default='clickhouse-test') + parser.add_argument("--skip-func-tests", default='') parser.add_argument("--client-cmd", default='clickhouse-client') parser.add_argument("--perf-test-cmd", default='clickhouse-performance-test') parser.add_argument("--perf-test-xml-path", default='/usr/share/clickhouse-test/performance/') @@ -49,7 +54,7 @@ if __name__ == "__main__": perf_process = None try: perf_process = run_perf_test(args.perf_test_cmd, args.perf_test_xml_path, args.output_folder) - func_pipes = run_func_test(args.test_cmd, args.output_folder, args.num_parallel) + func_pipes = run_func_test(args.test_cmd, args.output_folder, args.num_parallel, args.skip_func_tests) logging.info("Will wait functests to finish") while True: diff --git a/docker/test/test_runner.sh b/docker/test/test_runner.sh index 76e142e61f9..561117492b0 100755 --- a/docker/test/test_runner.sh +++ b/docker/test/test_runner.sh @@ -12,7 +12,7 @@ readonly CLICKHOUSE_PACKAGES_ARG="${2}" CLICKHOUSE_SERVER_IMAGE="${3}" if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then - readonly CLICKHOUSE_PACKAGES_DIR="$(realpath ${2})" # or --no-rebuild + readonly CLICKHOUSE_PACKAGES_DIR="$(realpath ${2})" # or --no-rebuild fi @@ -26,19 +26,19 @@ fi # TODO: optionally mount most recent clickhouse-test and queries directory from local machine if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then - docker build \ - -f "${CLICKHOUSE_DOCKER_DIR}/test/stateless/clickhouse-statelest-test-runner.Dockerfile" \ - --target clickhouse-test-runner-base \ - -t clickhouse-test-runner-base:preinstall \ - "${CLICKHOUSE_DOCKER_DIR}/test/stateless" + docker build \ + -f "${CLICKHOUSE_DOCKER_DIR}/test/stateless/clickhouse-statelest-test-runner.Dockerfile" \ + --target clickhouse-test-runner-base \ + -t clickhouse-test-runner-base:preinstall \ + "${CLICKHOUSE_DOCKER_DIR}/test/stateless" - docker rm -f clickhouse-test-runner-installing-packages || true - docker run \ - -v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \ - --name clickhouse-test-runner-installing-packages \ - clickhouse-test-runner-base:preinstall - docker commit clickhouse-test-runner-installing-packages clickhouse-statelest-test-runner:local - docker rm -f clickhouse-test-runner-installing-packages || true + docker rm -f clickhouse-test-runner-installing-packages || true + docker run \ + -v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \ + --name clickhouse-test-runner-installing-packages \ + clickhouse-test-runner-base:preinstall + docker commit clickhouse-test-runner-installing-packages clickhouse-statelest-test-runner:local + docker rm -f clickhouse-test-runner-installing-packages || true fi # # Create a bind-volume to the clickhouse-test script file @@ -47,38 +47,38 @@ fi # Build server image (optional) from local packages if [ -z "${CLICKHOUSE_SERVER_IMAGE}" ]; then - CLICKHOUSE_SERVER_IMAGE="yandex/clickhouse-server:local" + CLICKHOUSE_SERVER_IMAGE="yandex/clickhouse-server:local" - if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then - docker build \ - -f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ - --target clickhouse-server-base \ - -t clickhouse-server-base:preinstall \ - "${CLICKHOUSE_DOCKER_DIR}/server" + if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then + docker build \ + -f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ + --target clickhouse-server-base \ + -t clickhouse-server-base:preinstall \ + "${CLICKHOUSE_DOCKER_DIR}/server" - docker rm -f clickhouse_server_base_installing_server || true - docker run -v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \ - --name clickhouse_server_base_installing_server \ - clickhouse-server-base:preinstall - docker commit clickhouse_server_base_installing_server clickhouse-server-base:postinstall + docker rm -f clickhouse_server_base_installing_server || true + docker run -v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \ + --name clickhouse_server_base_installing_server \ + clickhouse-server-base:preinstall + docker commit clickhouse_server_base_installing_server clickhouse-server-base:postinstall - docker build \ - -f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ - --target clickhouse-server \ - -t "${CLICKHOUSE_SERVER_IMAGE}" \ - "${CLICKHOUSE_DOCKER_DIR}/server" - fi + docker build \ + -f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ + --target clickhouse-server \ + -t "${CLICKHOUSE_SERVER_IMAGE}" \ + "${CLICKHOUSE_DOCKER_DIR}/server" + fi fi docker rm -f test-runner || true docker-compose down CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" \ - docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \ - create \ - --build --force-recreate + docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \ + create \ + --build --force-recreate CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" \ - docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \ - run \ - --name test-runner \ - test-runner + docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \ + run \ + --name test-runner \ + test-runner diff --git a/docs/_description_templates/template-system-table.md b/docs/_description_templates/template-system-table.md index 9c05bf4cc5d..137766a34b6 100644 --- a/docs/_description_templates/template-system-table.md +++ b/docs/_description_templates/template-system-table.md @@ -1,10 +1,10 @@ -## system.table\_name {#system-tables_table-name} +## system.table_name {#system-tables_table-name} Description. Columns: -- `column_name` ([data\_type\_name](path/to/data_type.md)) — Description. +- `column_name` ([data_type_name](path/to/data_type.md)) — Description. **Example** diff --git a/docs/_includes/install/rpm.sh b/docs/_includes/install/rpm.sh index b88f52048bf..972d50124c4 100644 --- a/docs/_includes/install/rpm.sh +++ b/docs/_includes/install/rpm.sh @@ -1,8 +1,7 @@ sudo yum install yum-utils sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG -sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 +sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/clickhouse.repo sudo yum install clickhouse-server clickhouse-client sudo /etc/init.d/clickhouse-server start clickhouse-client - diff --git a/docs/en/commercial/cloud.md b/docs/en/commercial/cloud.md index 5255d254100..07d843f724a 100644 --- a/docs/en/commercial/cloud.md +++ b/docs/en/commercial/cloud.md @@ -1,6 +1,6 @@ --- -toc_title: Cloud toc_priority: 1 +toc_title: Cloud --- # ClickHouse Cloud Service Providers {#clickhouse-cloud-service-providers} @@ -12,7 +12,7 @@ toc_priority: 1 [Yandex Managed Service for ClickHouse](https://cloud.yandex.com/services/managed-clickhouse?utm_source=referrals&utm_medium=clickhouseofficialsite&utm_campaign=link3) provides the following key features: -- Fully managed ZooKeeper service for [ClickHouse replication](../engines/table_engines/mergetree_family/replication.md) +- Fully managed ZooKeeper service for [ClickHouse replication](../engines/table-engines/mergetree-family/replication.md) - Multiple storage type choices - Replicas in different availability zones - Encryption and isolation diff --git a/docs/en/commercial/support.md b/docs/en/commercial/support.md index e7b4503a534..37bc54e3e8b 100644 --- a/docs/en/commercial/support.md +++ b/docs/en/commercial/support.md @@ -1,6 +1,6 @@ --- -toc_title: Support toc_priority: 3 +toc_title: Support --- # ClickHouse Commercial Support Service Providers {#clickhouse-commercial-support-service-providers} @@ -10,7 +10,7 @@ toc_priority: 3 ## Altinity {#altinity} -[Service description](https://www.altinity.com/24x7-support) +Altinity has offered enterprise ClickHouse support and services since 2017. Altinity customers range from Fortune 100 enterprises to startups. Visit [www.altinity.com](https://www.altinity.com/) for more information. ## Mafiree {#mafiree} diff --git a/docs/en/development/architecture.md b/docs/en/development/architecture.md index cfd852637fe..71a65bf8cc5 100644 --- a/docs/en/development/architecture.md +++ b/docs/en/development/architecture.md @@ -1,6 +1,6 @@ --- toc_priority: 62 -toc_title: Overview of ClickHouse Architecture +toc_title: Architecture Overview --- # Overview of ClickHouse Architecture {#overview-of-clickhouse-architecture} @@ -120,7 +120,7 @@ There are ordinary functions and aggregate functions. For aggregate functions, s Ordinary functions don’t change the number of rows – they work as if they are processing each row independently. In fact, functions are not called for individual rows, but for `Block`’s of data to implement vectorized query execution. -There are some miscellaneous functions, like [blockSize](../sql_reference/functions/other_functions.md#function-blocksize), [rowNumberInBlock](../sql_reference/functions/other_functions.md#function-rownumberinblock), and [runningAccumulate](../sql_reference/functions/other_functions.md#function-runningaccumulate), that exploit block processing and violate the independence of rows. +There are some miscellaneous functions, like [blockSize](../sql-reference/functions/other-functions.md#function-blocksize), [rowNumberInBlock](../sql-reference/functions/other-functions.md#function-rownumberinblock), and [runningAccumulate](../sql-reference/functions/other-functions.md#function-runningaccumulate), that exploit block processing and violate the independence of rows. ClickHouse has strong typing, so there’s no implicit type conversion. If a function doesn’t support a specific combination of types, it throws an exception. But functions can work (be overloaded) for many different combinations of types. For example, the `plus` function (to implement the `+` operator) works for any combination of numeric types: `UInt8` + `Float32`, `UInt16` + `Int8`, and so on. Also, some variadic functions can accept any number of arguments, such as the `concat` function. diff --git a/docs/en/development/browse-code.md b/docs/en/development/browse-code.md new file mode 100644 index 00000000000..b4f755ca5d2 --- /dev/null +++ b/docs/en/development/browse-code.md @@ -0,0 +1,12 @@ +--- +toc_priority: 71 +toc_title: Source Code +--- + +# Browse ClickHouse Source Code {#browse-clickhouse-source-code} + +You can use **Woboq** online code browser available [here](https://clickhouse.tech/codebrowser/html_report/ClickHouse/src/index.html). It provides code navigation and semantic highlighting, search and indexing. The code snapshot is updated daily. + +Also, you can browse sources on [GitHub](https://github.com/ClickHouse/ClickHouse) as usual. + +If you’re interested what IDE to use, we recommend CLion, QT Creator, VS Code and KDevelop (with caveats). You can use any favourite IDE. Vim and Emacs also count. diff --git a/docs/en/development/browse_code.md b/docs/en/development/browse_code.md deleted file mode 100644 index 3e7b259bb39..00000000000 --- a/docs/en/development/browse_code.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -toc_priority: 63 -toc_title: Browse Source Code ---- - -# Browse ClickHouse Source Code {#browse-clickhouse-source-code} - -You can use **Woboq** online code browser available [here](https://clickhouse.tech/codebrowser/html_report/ClickHouse/src/index.html). It provides code navigation and semantic highlighting, search and indexing. The code snapshot is updated daily. - -Also, you can browse sources on [GitHub](https://github.com/ClickHouse/ClickHouse) as usual. - -If you’re interested what IDE to use, we recommend CLion, QT Creator, VS Code and KDevelop (with caveats). You can use any favourite IDE. Vim and Emacs also count. diff --git a/docs/en/development/build_cross_arm.md b/docs/en/development/build-cross-arm.md similarity index 100% rename from docs/en/development/build_cross_arm.md rename to docs/en/development/build-cross-arm.md diff --git a/docs/en/development/build-cross-osx.md b/docs/en/development/build-cross-osx.md new file mode 100644 index 00000000000..7c49a5609f2 --- /dev/null +++ b/docs/en/development/build-cross-osx.md @@ -0,0 +1,62 @@ +--- +toc_priority: 66 +toc_title: How to Build ClickHouse on Linux for Mac OS X +--- + +# How to Build ClickHouse on Linux for Mac OS X {#how-to-build-clickhouse-on-linux-for-mac-os-x} + +This is for the case when you have Linux machine and want to use it to build `clickhouse` binary that will run on OS X. This is intended for continuous integration checks that run on Linux servers. If you want to build ClickHouse directly on Mac OS X, then proceed with [another instruction](build-osx.md). + +The cross-build for Mac OS X is based on the [Build instructions](build.md), follow them first. + +# Install Clang-8 {#install-clang-8} + +Follow the instructions from https://apt.llvm.org/ for your Ubuntu or Debian setup. +For example the commands for Bionic are like: + +``` bash +sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list +sudo apt-get install clang-8 +``` + +# Install Cross-Compilation Toolset {#install-cross-compilation-toolset} + +Let’s remember the path where we install `cctools` as ${CCTOOLS} + +``` bash +mkdir ${CCTOOLS} + +git clone https://github.com/tpoechtrager/apple-libtapi.git +cd apple-libtapi +INSTALLPREFIX=${CCTOOLS} ./build.sh +./install.sh +cd .. + +git clone https://github.com/tpoechtrager/cctools-port.git +cd cctools-port/cctools +./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin +make install +``` + +Also, we need to download macOS X SDK into the working tree. + +``` bash +cd ClickHouse +wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' +mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 +tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 +``` + +# Build ClickHouse {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-osx +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ + -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ + -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ + -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld +ninja -C build-osx +``` + +The resulting binary will have a Mach-O executable format and can’t be run on Linux. diff --git a/docs/en/development/build-osx.md b/docs/en/development/build-osx.md new file mode 100644 index 00000000000..02da3ba1390 --- /dev/null +++ b/docs/en/development/build-osx.md @@ -0,0 +1,91 @@ +--- +toc_priority: 65 +toc_title: How to Build ClickHouse on Mac OS X +--- + +# How to Build ClickHouse on Mac OS X {#how-to-build-clickhouse-on-mac-os-x} + +Build should work on Mac OS X 10.15 (Catalina). + +## Install Homebrew {#install-homebrew} + +``` bash +$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +## Install Required Compilers, Tools, and Libraries {#install-required-compilers-tools-and-libraries} + +``` bash +$ brew install cmake ninja libtool gettext +``` + +## Checkout ClickHouse Sources {#checkout-clickhouse-sources} + +``` bash +$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git +``` + +or + +``` bash +$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git + +$ cd ClickHouse +``` + +## Build ClickHouse {#build-clickhouse} + +``` bash +$ mkdir build +$ cd build +$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` +$ ninja +$ cd .. +``` + +## Caveats {#caveats} + +If you intend to run clickhouse-server, make sure to increase the system’s maxfiles variable. + +!!! info "Note" + You’ll need to use sudo. + +To do so, create the following file: + +/Library/LaunchDaemons/limit.maxfiles.plist: + +``` xml + + + + + Label + limit.maxfiles + ProgramArguments + + launchctl + limit + maxfiles + 524288 + 524288 + + RunAtLoad + + ServiceIPC + + + +``` + +Execute the following command: + +``` bash +$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist +``` + +Reboot. + +To check if it’s working, you can use `ulimit -n` command. + +[Original article](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/en/development/build.md b/docs/en/development/build.md index b9b22c737ac..842e565b132 100644 --- a/docs/en/development/build.md +++ b/docs/en/development/build.md @@ -5,9 +5,13 @@ toc_title: How to Build ClickHouse on Linux # How to Build ClickHouse for Development {#how-to-build-clickhouse-for-development} -The following tutorial is based on the Ubuntu Linux system. -With appropriate changes, it should also work on any other Linux distribution. -Supported platforms: x86\_64 and AArch64. Support for Power9 is experimental. +The following tutorial is based on the Ubuntu Linux system. With appropriate changes, it should also work on any other Linux distribution. + +Supported platforms: + +- x86\_64 +- AArch64 +- Power9 (experimental) ## Install Git, CMake, Python and Ninja {#install-git-cmake-python-and-ninja} @@ -21,8 +25,18 @@ Or cmake3 instead of cmake on older systems. There are several ways to do this. +### Install from Repository {#install-from-repository} + +On Ubuntu 19.10 or newer: +``` +$ sudo apt-get update +$ sudo apt-get install gcc-9 g++-9 +``` + ### Install from a PPA Package {#install-from-a-ppa-package} +On older Ubuntu: + ``` bash $ sudo apt-get install software-properties-common $ sudo apt-add-repository ppa:ubuntu-toolchain-r/test @@ -32,7 +46,7 @@ $ sudo apt-get install gcc-9 g++-9 ### Install from Sources {#install-from-sources} -Look at [utils/ci/build-gcc-from-sources.sh](https://github.com/ClickHouse/ClickHouse/blob/master/utils/ci/build-gcc-from-sources.sh) +See [utils/ci/build-gcc-from-sources.sh](https://github.com/ClickHouse/ClickHouse/blob/master/utils/ci/build-gcc-from-sources.sh) ## Use GCC 9 for Builds {#use-gcc-9-for-builds} @@ -61,7 +75,6 @@ $ mkdir build $ cd build $ cmake .. $ ninja -$ cd .. ``` To create an executable, run `ninja clickhouse`. diff --git a/docs/en/development/build_cross_osx.md b/docs/en/development/build_cross_osx.md deleted file mode 100644 index bf95bdb42db..00000000000 --- a/docs/en/development/build_cross_osx.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -toc_priority: 66 -toc_title: How to Build ClickHouse on Linux for Mac OS X ---- - -# How to Build ClickHouse on Linux for Mac OS X {#how-to-build-clickhouse-on-linux-for-mac-os-x} - -This is for the case when you have Linux machine and want to use it to build `clickhouse` binary that will run on OS X. This is intended for continuous integration checks that run on Linux servers. If you want to build ClickHouse directly on Mac OS X, then proceed with [another instruction](build_osx.md). - -The cross-build for Mac OS X is based on the [Build instructions](build.md), follow them first. - -# Install Clang-8 {#install-clang-8} - -Follow the instructions from https://apt.llvm.org/ for your Ubuntu or Debian setup. -For example the commands for Bionic are like: - -``` bash -sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list -sudo apt-get install clang-8 -``` - -# Install Cross-Compilation Toolset {#install-cross-compilation-toolset} - -Let’s remember the path where we install `cctools` as ${CCTOOLS} - -``` bash -mkdir ${CCTOOLS} - -git clone https://github.com/tpoechtrager/apple-libtapi.git -cd apple-libtapi -INSTALLPREFIX=${CCTOOLS} ./build.sh -./install.sh -cd .. - -git clone https://github.com/tpoechtrager/cctools-port.git -cd cctools-port/cctools -./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin -make install -``` - -Also, we need to download macOS X SDK into the working tree. - -``` bash -cd ClickHouse -wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' -mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 -tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 -``` - -# Build ClickHouse {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-osx -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ - -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ - -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ - -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld -ninja -C build-osx -``` - -The resulting binary will have a Mach-O executable format and can’t be run on Linux. diff --git a/docs/en/development/build_osx.md b/docs/en/development/build_osx.md deleted file mode 100644 index 281f961fc2d..00000000000 --- a/docs/en/development/build_osx.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -toc_priority: 65 -toc_title: How to Build ClickHouse on Mac OS X ---- - -# How to Build ClickHouse on Mac OS X {#how-to-build-clickhouse-on-mac-os-x} - -Build should work on Mac OS X 10.15 (Catalina) - -## Install Homebrew {#install-homebrew} - -``` bash -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` - -## Install Required Compilers, Tools, and Libraries {#install-required-compilers-tools-and-libraries} - -``` bash -$ brew install cmake ninja libtool gettext -``` - -## Checkout ClickHouse Sources {#checkout-clickhouse-sources} - -``` bash -$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git -``` - -or - -``` bash -$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git - -$ cd ClickHouse -``` - -## Build ClickHouse {#build-clickhouse} - -``` bash -$ mkdir build -$ cd build -$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` -$ ninja -$ cd .. -``` - -## Caveats {#caveats} - -If you intend to run clickhouse-server, make sure to increase the system’s maxfiles variable. - -!!! info "Note" - You’ll need to use sudo. - -To do so, create the following file: - -/Library/LaunchDaemons/limit.maxfiles.plist: - -``` xml - - - - - Label - limit.maxfiles - ProgramArguments - - launchctl - limit - maxfiles - 524288 - 524288 - - RunAtLoad - - ServiceIPC - - - -``` - -Execute the following command: - -``` bash -$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist -``` - -Reboot. - -To check if it’s working, you can use `ulimit -n` command. - -[Original article](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/en/development/developer-instruction.md b/docs/en/development/developer-instruction.md new file mode 100644 index 00000000000..3776c9b513f --- /dev/null +++ b/docs/en/development/developer-instruction.md @@ -0,0 +1,283 @@ +--- +toc_priority: 61 +toc_title: For Beginners +--- + +# The Beginner ClickHouse Developer Instruction + +Building of ClickHouse is supported on Linux, FreeBSD and Mac OS X. + +If you use Windows, you need to create a virtual machine with Ubuntu. To start working with a virtual machine please install VirtualBox. You can download Ubuntu from the website: https://www.ubuntu.com/#download. Please create a virtual machine from the downloaded image (you should reserve at least 4GB of RAM for it). To run a command-line terminal in Ubuntu, please locate a program containing the word “terminal” in its name (gnome-terminal, konsole etc.) or just press Ctrl+Alt+T. + +ClickHouse cannot work or build on a 32-bit system. You should acquire access to a 64-bit system and you can continue reading. + +## Creating a Repository on GitHub {#creating-a-repository-on-github} + +To start working with ClickHouse repository you will need a GitHub account. + +You probably already have one, but if you don’t, please register at https://github.com. In case you do not have SSH keys, you should generate them and then upload them on GitHub. It is required for sending over your patches. It is also possible to use the same SSH keys that you use with any other SSH servers - probably you already have those. + +Create a fork of ClickHouse repository. To do that please click on the “fork” button in the upper right corner at https://github.com/ClickHouse/ClickHouse. It will fork your own copy of ClickHouse/ClickHouse to your account. + +The development process consists of first committing the intended changes into your fork of ClickHouse and then creating a “pull request” for these changes to be accepted into the main repository (ClickHouse/ClickHouse). + +To work with git repositories, please install `git`. + +To do that in Ubuntu you would run in the command line terminal: + + sudo apt update + sudo apt install git + +A brief manual on using Git can be found here: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf. +For a detailed manual on Git see https://git-scm.com/book/en/v2. + +## Cloning a Repository to Your Development Machine {#cloning-a-repository-to-your-development-machine} + +Next, you need to download the source files onto your working machine. This is called “to clone a repository” because it creates a local copy of the repository on your working machine. + +In the command line terminal run: + + git clone --recursive git@github.com:your_github_username/ClickHouse.git + cd ClickHouse + +Note: please, substitute *your\_github\_username* with what is appropriate! + +This command will create a directory `ClickHouse` containing the working copy of the project. + +It is important that the path to the working directory contains no whitespaces as it may lead to problems with running the build system. + +Please note that ClickHouse repository uses `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` flag as in the example above. If the repository has been cloned without submodules, to download them you need to run the following: + + git submodule init + git submodule update + +You can check the status with the command: `git submodule status`. + +If you get the following error message: + + Permission denied (publickey). + fatal: Could not read from remote repository. + + Please make sure you have the correct access rights + and the repository exists. + +It generally means that the SSH keys for connecting to GitHub are missing. These keys are normally located in `~/.ssh`. For SSH keys to be accepted you need to upload them in the settings section of GitHub UI. + +You can also clone the repository via https protocol: + + git clone https://github.com/ClickHouse/ClickHouse.git + +This, however, will not let you send your changes to the server. You can still use it temporarily and add the SSH keys later replacing the remote address of the repository with `git remote` command. + +You can also add original ClickHouse repo’s address to your local repository to pull updates from there: + + git remote add upstream git@github.com:ClickHouse/ClickHouse.git + +After successfully running this command you will be able to pull updates from the main ClickHouse repo by running `git pull upstream master`. + +### Working with Submodules {#working-with-submodules} + +Working with submodules in git could be painful. Next commands will help to manage it: + + # ! each command accepts --recursive + # Update remote URLs for submodules. Barely rare case + git submodule sync + # Add new submodules + git submodule init + # Update existing submodules to the current state + git submodule update + # Two last commands could be merged together + git submodule update --init + +The next commands would help you to reset all submodules to the initial state (!WARNING! - any changes inside will be deleted): + + # Synchronizes submodules' remote URL with .gitmodules + git submodule sync --recursive + # Update the registered submodules with initialize not yet initialized + git submodule update --init --recursive + # Reset all changes done after HEAD + git submodule foreach git reset --hard + # Clean files from .gitignore + git submodule foreach git clean -xfd + # Repeat last 4 commands for all submodule + git submodule foreach git submodule sync --recursive + git submodule foreach git submodule update --init --recursive + git submodule foreach git submodule foreach git reset --hard + git submodule foreach git submodule foreach git clean -xfd + +## Build System {#build-system} + +ClickHouse uses CMake and Ninja for building. + +CMake - a meta-build system that can generate Ninja files (build tasks). +Ninja - a smaller build system with a focus on the speed used to execute those cmake generated tasks. + +To install on Ubuntu, Debian or Mint run `sudo apt install cmake ninja-build`. + +On CentOS, RedHat run `sudo yum install cmake ninja-build`. + +If you use Arch or Gentoo, you probably know it yourself how to install CMake. + +For installing CMake and Ninja on Mac OS X first install Homebrew and then install everything else via brew: + + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install cmake ninja + +Next, check the version of CMake: `cmake --version`. If it is below 3.3, you should install a newer version from the website: https://cmake.org/download/. + +## Optional External Libraries {#optional-external-libraries} + +ClickHouse uses several external libraries for building. All of them do not need to be installed separately as they are built together with ClickHouse from the sources located in the submodules. You can check the list in `contrib`. + +## C++ Compiler {#c-compiler} + +Compilers GCC starting from version 9 and Clang version 8 or above are supported for building ClickHouse. + +Official Yandex builds currently use GCC because it generates machine code of slightly better performance (yielding a difference of up to several percent according to our benchmarks). And Clang is more convenient for development usually. Though, our continuous integration (CI) platform runs checks for about a dozen of build combinations. + +To install GCC on Ubuntu run: `sudo apt install gcc g++` + +Check the version of gcc: `gcc --version`. If it is below 9, then follow the instruction here: https://clickhouse.tech/docs/en/development/build/#install-gcc-9. + +Mac OS X build is supported only for Clang. Just run `brew install llvm` + +If you decide to use Clang, you can also install `libc++` and `lld`, if you know what it is. Using `ccache` is also recommended. + +## The Building Process {#the-building-process} + +Now that you are ready to build ClickHouse we recommend you to create a separate directory `build` inside `ClickHouse` that will contain all of the build artefacts: + + mkdir build + cd build + +You can have several different directories (build\_release, build\_debug, etc.) for different types of build. + +While inside the `build` directory, configure your build by running CMake. Before the first run, you need to define environment variables that specify compiler (version 9 gcc compiler in this example). + +Linux: + + export CC=gcc-9 CXX=g++-9 + cmake .. + +Mac OS X: + + export CC=clang CXX=clang++ + cmake .. + +The `CC` variable specifies the compiler for C (short for C Compiler), and `CXX` variable instructs which C++ compiler is to be used for building. + +For a faster build, you can resort to the `debug` build type - a build with no optimizations. For that supply the following parameter `-D CMAKE_BUILD_TYPE=Debug`: + + cmake -D CMAKE_BUILD_TYPE=Debug .. + +You can change the type of build by running this command in the `build` directory. + +Run ninja to build: + + ninja clickhouse-server clickhouse-client + +Only the required binaries are going to be built in this example. + +If you require to build all the binaries (utilities and tests), you should run ninja with no parameters: + + ninja + +Full build requires about 30GB of free disk space or 15GB to build the main binaries. + +When a large amount of RAM is available on build machine you should limit the number of build tasks run in parallel with `-j` param: + + ninja -j 1 clickhouse-server clickhouse-client + +On machines with 4GB of RAM, it is recommended to specify 1, for 8GB of RAM `-j 2` is recommended. + +If you get the message: `ninja: error: loading 'build.ninja': No such file or directory`, it means that generating a build configuration has failed and you need to inspect the message above. + +Upon the successful start of the building process, you’ll see the build progress - the number of processed tasks and the total number of tasks. + +While building messages about protobuf files in libhdfs2 library like `libprotobuf WARNING` may show up. They affect nothing and are safe to be ignored. + +Upon successful build you get an executable file `ClickHouse//programs/clickhouse`: + + ls -l programs/clickhouse + +## Running the Built Executable of ClickHouse {#running-the-built-executable-of-clickhouse} + +To run the server under the current user you need to navigate to `ClickHouse/programs/server/` (located outside of `build`) and run: + + ../../build/programs/clickhouse server + +In this case, ClickHouse will use config files located in the current directory. You can run `clickhouse server` from any directory specifying the path to a config file as a command-line parameter `--config-file`. + +To connect to ClickHouse with clickhouse-client in another terminal navigate to `ClickHouse/build/programs/` and run `clickhouse client`. + +If you get `Connection refused` message on Mac OS X or FreeBSD, try specifying host address 127.0.0.1: + + clickhouse client --host 127.0.0.1 + +You can replace the production version of ClickHouse binary installed in your system with your custom-built ClickHouse binary. To do that install ClickHouse on your machine following the instructions from the official website. Next, run the following: + + sudo service clickhouse-server stop + sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ + sudo service clickhouse-server start + +Note that `clickhouse-client`, `clickhouse-server` and others are symlinks to the commonly shared `clickhouse` binary. + +You can also run your custom-built ClickHouse binary with the config file from the ClickHouse package installed on your system: + + sudo service clickhouse-server stop + sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml + +## IDE (Integrated Development Environment) {#ide-integrated-development-environment} + +If you do not know which IDE to use, we recommend that you use CLion. CLion is commercial software, but it offers 30 days free trial period. It is also free of charge for students. CLion can be used both on Linux and on Mac OS X. + +KDevelop and QTCreator are other great alternatives of an IDE for developing ClickHouse. KDevelop comes in as a very handy IDE although unstable. If KDevelop crashes after a while upon opening project, you should click “Stop All” button as soon as it has opened the list of project’s files. After doing so KDevelop should be fine to work with. + +As simple code editors, you can use Sublime Text or Visual Studio Code, or Kate (all of which are available on Linux). + +Just in case, it is worth mentioning that CLion creates `build` path on its own, it also on its own selects `debug` for build type, for configuration it uses a version of CMake that is defined in CLion and not the one installed by you, and finally, CLion will use `make` to run build tasks instead of `ninja`. This is normal behaviour, just keep that in mind to avoid confusion. + +## Writing Code {#writing-code} + +The description of ClickHouse architecture can be found here: https://clickhouse.tech/docs/en/development/architecture/ + +The Code Style Guide: https://clickhouse.tech/docs/en/development/style/ + +Writing tests: https://clickhouse.tech/docs/en/development/tests/ + +List of tasks: https://github.com/ClickHouse/ClickHouse/contribute + +## Test Data {#test-data} + +Developing ClickHouse often requires loading realistic datasets. It is particularly important for performance testing. We have a specially prepared set of anonymized data from Yandex.Metrica. It requires additionally some 3GB of free disk space. Note that this data is not required to accomplish most of the development tasks. + + sudo apt install wget xz-utils + + wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz + wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz + + xz -v -d hits_v1.tsv.xz + xz -v -d visits_v1.tsv.xz + + clickhouse-client + + CREATE DATABASE IF NOT EXISTS test + + CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); + + CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); + + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv + +## Creating Pull Request {#creating-pull-request} + +Navigate to your fork repository in GitHub’s UI. If you have been developing in a branch, you need to select that branch. There will be a “Pull request” button located on the screen. In essence, this means “create a request for accepting my changes into the main repository”. + +A pull request can be created even if the work is not completed yet. In this case please put the word “WIP” (work in progress) at the beginning of the title, it can be changed later. This is useful for cooperative reviewing and discussion of changes as well as for running all of the available tests. It is important that you provide a brief description of your changes, it will later be used for generating release changelogs. + +Testing will commence as soon as Yandex employees label your PR with a tag “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. + +The system will prepare ClickHouse binary builds for your pull request individually. To retrieve these builds click the “Details” link next to “ClickHouse build check” entry in the list of checks. There you will find direct links to the built .deb packages of ClickHouse which you can deploy even on your production servers (if you have no fear). + +Most probably some of the builds will fail at first times. This is due to the fact that we check builds both with gcc as well as with clang, with almost all of existing warnings (always with the `-Werror` flag) enabled for clang. On that same page, you can find all of the build logs so that you do not have to build ClickHouse in all of the possible ways. diff --git a/docs/en/development/developer_instruction.md b/docs/en/development/developer_instruction.md deleted file mode 100644 index cd7d6404ec5..00000000000 --- a/docs/en/development/developer_instruction.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -toc_priority: 61 -toc_title: The Beginner ClickHouse Developer Instruction ---- - -Building of ClickHouse is supported on Linux, FreeBSD and Mac OS X. - -# If You Use Windows {#if-you-use-windows} - -If you use Windows, you need to create a virtual machine with Ubuntu. To start working with a virtual machine please install VirtualBox. You can download Ubuntu from the website: https://www.ubuntu.com/\#download. Please create a virtual machine from the downloaded image (you should reserve at least 4GB of RAM for it). To run a command-line terminal in Ubuntu, please locate a program containing the word “terminal” in its name (gnome-terminal, konsole etc.) or just press Ctrl+Alt+T. - -# If You Use a 32-bit System {#if-you-use-a-32-bit-system} - -ClickHouse cannot work or build on a 32-bit system. You should acquire access to a 64-bit system and you can continue reading. - -# Creating a Repository on GitHub {#creating-a-repository-on-github} - -To start working with ClickHouse repository you will need a GitHub account. - -You probably already have one, but if you don’t, please register at https://github.com. In case you do not have SSH keys, you should generate them and then upload them on GitHub. It is required for sending over your patches. It is also possible to use the same SSH keys that you use with any other SSH servers - probably you already have those. - -Create a fork of ClickHouse repository. To do that please click on the “fork” button in the upper right corner at https://github.com/ClickHouse/ClickHouse. It will fork your own copy of ClickHouse/ClickHouse to your account. - -The development process consists of first committing the intended changes into your fork of ClickHouse and then creating a “pull request” for these changes to be accepted into the main repository (ClickHouse/ClickHouse). - -To work with git repositories, please install `git`. - -To do that in Ubuntu you would run in the command line terminal: - - sudo apt update - sudo apt install git - -A brief manual on using Git can be found here: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf. -For a detailed manual on Git see https://git-scm.com/book/en/v2. - -# Cloning a Repository to Your Development Machine {#cloning-a-repository-to-your-development-machine} - -Next, you need to download the source files onto your working machine. This is called “to clone a repository” because it creates a local copy of the repository on your working machine. - -In the command line terminal run: - - git clone --recursive git@github.com:your_github_username/ClickHouse.git - cd ClickHouse - -Note: please, substitute *your\_github\_username* with what is appropriate! - -This command will create a directory `ClickHouse` containing the working copy of the project. - -It is important that the path to the working directory contains no whitespaces as it may lead to problems with running the build system. - -Please note that ClickHouse repository uses `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` flag as in the example above. If the repository has been cloned without submodules, to download them you need to run the following: - - git submodule init - git submodule update - -You can check the status with the command: `git submodule status`. - -If you get the following error message: - - Permission denied (publickey). - fatal: Could not read from remote repository. - - Please make sure you have the correct access rights - and the repository exists. - -It generally means that the SSH keys for connecting to GitHub are missing. These keys are normally located in `~/.ssh`. For SSH keys to be accepted you need to upload them in the settings section of GitHub UI. - -You can also clone the repository via https protocol: - - git clone https://github.com/ClickHouse/ClickHouse.git - -This, however, will not let you send your changes to the server. You can still use it temporarily and add the SSH keys later replacing the remote address of the repository with `git remote` command. - -You can also add original ClickHouse repo’s address to your local repository to pull updates from there: - - git remote add upstream git@github.com:ClickHouse/ClickHouse.git - -After successfully running this command you will be able to pull updates from the main ClickHouse repo by running `git pull upstream master`. - -## Working with Submodules {#working-with-submodules} - -Working with submodules in git could be painful. Next commands will help to manage it: - - # ! each command accepts --recursive - # Update remote URLs for submodules. Barely rare case - git submodule sync - # Add new submodules - git submodule init - # Update existing submodules to the current state - git submodule update - # Two last commands could be merged together - git submodule update --init - -The next commands would help you to reset all submodules to the initial state (!WARNING! - any changes inside will be deleted): - - # Synchronizes submodules' remote URL with .gitmodules - git submodule sync --recursive - # Update the registered submodules with initialize not yet initialized - git submodule update --init --recursive - # Reset all changes done after HEAD - git submodule foreach git reset --hard - # Clean files from .gitignore - git submodule foreach git clean -xfd - # Repeat last 4 commands for all submodule - git submodule foreach git submodule sync --recursive - git submodule foreach git submodule update --init --recursive - git submodule foreach git submodule foreach git reset --hard - git submodule foreach git submodule foreach git clean -xfd - -# Build System {#build-system} - -ClickHouse uses CMake and Ninja for building. - -CMake - a meta-build system that can generate Ninja files (build tasks). -Ninja - a smaller build system with a focus on the speed used to execute those cmake generated tasks. - -To install on Ubuntu, Debian or Mint run `sudo apt install cmake ninja-build`. - -On CentOS, RedHat run `sudo yum install cmake ninja-build`. - -If you use Arch or Gentoo, you probably know it yourself how to install CMake. - -For installing CMake and Ninja on Mac OS X first install Homebrew and then install everything else via brew: - - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew install cmake ninja - -Next, check the version of CMake: `cmake --version`. If it is below 3.3, you should install a newer version from the website: https://cmake.org/download/. - -# Optional External Libraries {#optional-external-libraries} - -ClickHouse uses several external libraries for building. All of them do not need to be installed separately as they are built together with ClickHouse from the sources located in the submodules. You can check the list in `contrib`. - -# C++ Compiler {#c-compiler} - -Compilers GCC starting from version 9 and Clang version 8 or above are supported for building ClickHouse. - -Official Yandex builds currently use GCC because it generates machine code of slightly better performance (yielding a difference of up to several percent according to our benchmarks). And Clang is more convenient for development usually. Though, our continuous integration (CI) platform runs checks for about a dozen of build combinations. - -To install GCC on Ubuntu run: `sudo apt install gcc g++` - -Check the version of gcc: `gcc --version`. If it is below 9, then follow the instruction here: https://clickhouse.tech/docs/en/development/build/\#install-gcc-9. - -Mac OS X build is supported only for Clang. Just run `brew install llvm` - -If you decide to use Clang, you can also install `libc++` and `lld`, if you know what it is. Using `ccache` is also recommended. - -# The Building Process {#the-building-process} - -Now that you are ready to build ClickHouse we recommend you to create a separate directory `build` inside `ClickHouse` that will contain all of the build artefacts: - - mkdir build - cd build - -You can have several different directories (build\_release, build\_debug, etc.) for different types of build. - -While inside the `build` directory, configure your build by running CMake. Before the first run, you need to define environment variables that specify compiler (version 9 gcc compiler in this example). - -Linux: - - export CC=gcc-9 CXX=g++-9 - cmake .. - -Mac OS X: - - export CC=clang CXX=clang++ - cmake .. - -The `CC` variable specifies the compiler for C (short for C Compiler), and `CXX` variable instructs which C++ compiler is to be used for building. - -For a faster build, you can resort to the `debug` build type - a build with no optimizations. For that supply the following parameter `-D CMAKE_BUILD_TYPE=Debug`: - - cmake -D CMAKE_BUILD_TYPE=Debug .. - -You can change the type of build by running this command in the `build` directory. - -Run ninja to build: - - ninja clickhouse-server clickhouse-client - -Only the required binaries are going to be built in this example. - -If you require to build all the binaries (utilities and tests), you should run ninja with no parameters: - - ninja - -Full build requires about 30GB of free disk space or 15GB to build the main binaries. - -When a large amount of RAM is available on build machine you should limit the number of build tasks run in parallel with `-j` param: - - ninja -j 1 clickhouse-server clickhouse-client - -On machines with 4GB of RAM, it is recommended to specify 1, for 8GB of RAM `-j 2` is recommended. - -If you get the message: `ninja: error: loading 'build.ninja': No such file or directory`, it means that generating a build configuration has failed and you need to inspect the message above. - -Upon the successful start of the building process, you’ll see the build progress - the number of processed tasks and the total number of tasks. - -While building messages about protobuf files in libhdfs2 library like `libprotobuf WARNING` may show up. They affect nothing and are safe to be ignored. - -Upon successful build you get an executable file `ClickHouse//programs/clickhouse`: - - ls -l programs/clickhouse - -# Running the Built Executable of ClickHouse {#running-the-built-executable-of-clickhouse} - -To run the server under the current user you need to navigate to `ClickHouse/programs/server/` (located outside of `build`) and run: - - ../../../build/programs/clickhouse server - -In this case, ClickHouse will use config files located in the current directory. You can run `clickhouse server` from any directory specifying the path to a config file as a command-line parameter `--config-file`. - -To connect to ClickHouse with clickhouse-client in another terminal navigate to `ClickHouse/build/programs/` and run `clickhouse client`. - -If you get `Connection refused` message on Mac OS X or FreeBSD, try specifying host address 127.0.0.1: - - clickhouse client --host 127.0.0.1 - -You can replace the production version of ClickHouse binary installed in your system with your custom-built ClickHouse binary. To do that install ClickHouse on your machine following the instructions from the official website. Next, run the following: - - sudo service clickhouse-server stop - sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ - sudo service clickhouse-server start - -Note that `clickhouse-client`, `clickhouse-server` and others are symlinks to the commonly shared `clickhouse` binary. - -You can also run your custom-built ClickHouse binary with the config file from the ClickHouse package installed on your system: - - sudo service clickhouse-server stop - sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml - -# IDE (Integrated Development Environment) {#ide-integrated-development-environment} - -If you do not know which IDE to use, we recommend that you use CLion. CLion is commercial software, but it offers 30 days free trial period. It is also free of charge for students. CLion can be used both on Linux and on Mac OS X. - -KDevelop and QTCreator are other great alternatives of an IDE for developing ClickHouse. KDevelop comes in as a very handy IDE although unstable. If KDevelop crashes after a while upon opening project, you should click “Stop All” button as soon as it has opened the list of project’s files. After doing so KDevelop should be fine to work with. - -As simple code editors, you can use Sublime Text or Visual Studio Code, or Kate (all of which are available on Linux). - -Just in case, it is worth mentioning that CLion creates `build` path on its own, it also on its own selects `debug` for build type, for configuration it uses a version of CMake that is defined in CLion and not the one installed by you, and finally, CLion will use `make` to run build tasks instead of `ninja`. This is normal behaviour, just keep that in mind to avoid confusion. - -# Writing Code {#writing-code} - -The description of ClickHouse architecture can be found here: https://clickhouse.tech/docs/en/development/architecture/ - -The Code Style Guide: https://clickhouse.tech/docs/en/development/style/ - -Writing tests: https://clickhouse.tech/docs/en/development/tests/ - -List of tasks: https://github.com/ClickHouse/ClickHouse/blob/master/testsructions/easy\_tasks\_sorted\_en.md - -# Test Data {#test-data} - -Developing ClickHouse often requires loading realistic datasets. It is particularly important for performance testing. We have a specially prepared set of anonymized data from Yandex.Metrica. It requires additionally some 3GB of free disk space. Note that this data is not required to accomplish most of the development tasks. - - sudo apt install wget xz-utils - - wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz - wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz - - xz -v -d hits_v1.tsv.xz - xz -v -d visits_v1.tsv.xz - - clickhouse-client - - CREATE DATABASE IF NOT EXISTS test - - CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); - - CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); - - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv - -# Creating Pull Request {#creating-pull-request} - -Navigate to your fork repository in GitHub’s UI. If you have been developing in a branch, you need to select that branch. There will be a “Pull request” button located on the screen. In essence, this means “create a request for accepting my changes into the main repository”. - -A pull request can be created even if the work is not completed yet. In this case please put the word “WIP” (work in progress) at the beginning of the title, it can be changed later. This is useful for cooperative reviewing and discussion of changes as well as for running all of the available tests. It is important that you provide a brief description of your changes, it will later be used for generating release changelogs. - -Testing will commence as soon as Yandex employees label your PR with a tag “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. - -The system will prepare ClickHouse binary builds for your pull request individually. To retrieve these builds click the “Details” link next to “ClickHouse build check” entry in the list of checks. There you will find direct links to the built .deb packages of ClickHouse which you can deploy even on your production servers (if you have no fear). - -Most probably some of the builds will fail at first times. This is due to the fact that we check builds both with gcc as well as with clang, with almost all of existing warnings (always with the `-Werror` flag) enabled for clang. On that same page, you can find all of the build logs so that you do not have to build ClickHouse in all of the possible ways. diff --git a/docs/en/development/tests.md b/docs/en/development/tests.md index 45adb221b5b..eefced2e684 100644 --- a/docs/en/development/tests.md +++ b/docs/en/development/tests.md @@ -197,13 +197,24 @@ Debug version of `jemalloc` is used for debug build. ## Fuzzing {#fuzzing} -We use simple fuzz test to generate random SQL queries and to check that the server doesn’t die. Fuzz testing is performed with Address sanitizer. You can find it in `00746_sql_fuzzy.pl`. This test should be run continuously (overnight and longer). +ClickHouse fuzzing is implemented both using [libFuzzer](https://llvm.org/docs/LibFuzzer.html) and random SQL queries. +All the fuzz testing should be performed with sanitizers (Address and Undefined). + +LibFuzzer is used for isolated fuzz testing of library code. Fuzzers are implemented as part of test code and have "\_fuzzer" name postfixes. +Fuzzer example can be found at `src/Parsers/tests/lexer_fuzzer.cpp`. LibFuzzer-specific configs, dictionaries and corpus are stored at `tests/fuzz`. +We encourage you to write fuzz tests for every functionality that handles user input. + +Fuzzers are not built by default. To build fuzzers both `-DENABLE_FUZZING=1` and `-DENABLE_TESTS=1` options should be set. +We recommend to disable Jemalloc while building fuzzers. Configuration used to integrate ClickHouse fuzzing to +Google OSS-Fuzz can be found at `docker/fuzz`. + +We also use simple fuzz test to generate random SQL queries and to check that the server doesn’t die executing them. +You can find it in `00746_sql_fuzzy.pl`. This test should be run continuously (overnight and longer). -As of December 2018, we still don’t use isolated fuzz testing of library code. ## Security Audit {#security-audit} -People from Yandex Cloud department do some basic overview of ClickHouse capabilities from the security standpoint. +People from Yandex Security Team do some basic overview of ClickHouse capabilities from the security standpoint. ## Static Analyzers {#static-analyzers} diff --git a/docs/en/engines/database-engines/index.md b/docs/en/engines/database-engines/index.md new file mode 100644 index 00000000000..87646a34ac2 --- /dev/null +++ b/docs/en/engines/database-engines/index.md @@ -0,0 +1,19 @@ +--- +toc_folder_title: Database Engines +toc_priority: 27 +toc_title: Introduction +--- + +# Database Engines {#database-engines} + +Database engines allow you to work with tables. + +By default, ClickHouse uses its native database engine, which provides configurable [table engines](../../engines/table-engines/index.md) and an [SQL dialect](../../sql-reference/syntax.md). + +You can also use the following database engines: + +- [MySQL](mysql.md) + +- [Lazy](lazy.md) + +[Original article](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/en/engines/database_engines/lazy.md b/docs/en/engines/database-engines/lazy.md similarity index 100% rename from docs/en/engines/database_engines/lazy.md rename to docs/en/engines/database-engines/lazy.md diff --git a/docs/en/engines/database-engines/mysql.md b/docs/en/engines/database-engines/mysql.md new file mode 100644 index 00000000000..6e6b9ae3d0b --- /dev/null +++ b/docs/en/engines/database-engines/mysql.md @@ -0,0 +1,133 @@ +--- +toc_priority: 30 +toc_title: MySQL +--- + +# MySQL {#mysql} + +Allows to connect to databases on a remote MySQL server and perform `INSERT` and `SELECT` queries to exchange data between ClickHouse and MySQL. + +The `MySQL` database engine translate queries to the MySQL server so you can perform operations such as `SHOW TABLES` or `SHOW CREATE TABLE`. + +You cannot perform the following queries: + +- `RENAME` +- `CREATE TABLE` +- `ALTER` + +## Creating a Database {#creating-a-database} + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] +ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') +``` + +**Engine Parameters** + +- `host:port` — MySQL server address. +- `database` — Remote database name. +- `user` — MySQL user. +- `password` — User password. + +## Data Types Support {#data_types-support} + +| MySQL | ClickHouse | +|----------------------------------|--------------------------------------------------------------| +| UNSIGNED TINYINT | [UInt8](../../sql-reference/data-types/int-uint.md) | +| TINYINT | [Int8](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED SMALLINT | [UInt16](../../sql-reference/data-types/int-uint.md) | +| SMALLINT | [Int16](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../sql-reference/data-types/int-uint.md) | +| INT, MEDIUMINT | [Int32](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED BIGINT | [UInt64](../../sql-reference/data-types/int-uint.md) | +| BIGINT | [Int64](../../sql-reference/data-types/int-uint.md) | +| FLOAT | [Float32](../../sql-reference/data-types/float.md) | +| DOUBLE | [Float64](../../sql-reference/data-types/float.md) | +| DATE | [Date](../../sql-reference/data-types/date.md) | +| DATETIME, TIMESTAMP | [DateTime](../../sql-reference/data-types/datetime.md) | +| BINARY | [FixedString](../../sql-reference/data-types/fixedstring.md) | + +All other MySQL data types are converted into [String](../../sql-reference/data-types/string.md). + +[Nullable](../../sql-reference/data-types/nullable.md) is supported. + +## Examples of Use {#examples-of-use} + +Table in MySQL: + +``` text +mysql> USE test; +Database changed + +mysql> CREATE TABLE `mysql_table` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `float` FLOAT NOT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from mysql_table; ++------+-----+ +| int_id | value | ++------+-----+ +| 1 | 2 | ++------+-----+ +1 row in set (0,00 sec) +``` + +Database in ClickHouse, exchanging data with the MySQL server: + +``` sql +CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') +``` + +``` sql +SHOW DATABASES +``` + +``` text +┌─name─────┐ +│ default │ +│ mysql_db │ +│ system │ +└──────────┘ +``` + +``` sql +SHOW TABLES FROM mysql_db +``` + +``` text +┌─name─────────┐ +│ mysql_table │ +└──────────────┘ +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +└────────┴───────┘ +``` + +``` sql +INSERT INTO mysql_db.mysql_table VALUES (3,4) +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +│ 3 │ 4 │ +└────────┴───────┘ +``` + +[Original article](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/en/engines/database_engines/index.md b/docs/en/engines/database_engines/index.md deleted file mode 100644 index ef8202f2249..00000000000 --- a/docs/en/engines/database_engines/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -toc_folder_title: Database Engines -toc_priority: 27 -toc_title: Introduction ---- - -# Database Engines {#database-engines} - -Database engines allow you to work with tables. - -By default, ClickHouse uses its native database engine, which provides configurable [table engines](../../engines/table_engines/index.md) and an [SQL dialect](../../sql_reference/syntax.md). - -You can also use the following database engines: - -- [MySQL](mysql.md) - -- [Lazy](lazy.md) - -[Original article](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/en/engines/database_engines/mysql.md b/docs/en/engines/database_engines/mysql.md deleted file mode 100644 index 467a3aa032d..00000000000 --- a/docs/en/engines/database_engines/mysql.md +++ /dev/null @@ -1,133 +0,0 @@ ---- -toc_priority: 30 -toc_title: MySQL ---- - -# MySQL {#mysql} - -Allows to connect to databases on a remote MySQL server and perform `INSERT` and `SELECT` queries to exchange data between ClickHouse and MySQL. - -The `MySQL` database engine translate queries to the MySQL server so you can perform operations such as `SHOW TABLES` or `SHOW CREATE TABLE`. - -You cannot perform the following queries: - -- `RENAME` -- `CREATE TABLE` -- `ALTER` - -## Creating a Database {#creating-a-database} - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] -ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') -``` - -**Engine Parameters** - -- `host:port` — MySQL server address. -- `database` — Remote database name. -- `user` — MySQL user. -- `password` — User password. - -## Data Types Support {#data_types-support} - -| MySQL | ClickHouse | -|----------------------|--------------------------------------| -| UNSIGNED TINYINT | [UInt8](../../sql_reference/data_types/int_uint.md) | -| TINYINT | [Int8](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED SMALLINT | [UInt16](../../sql_reference/data_types/int_uint.md) | -| SMALLINT | [Int16](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../sql_reference/data_types/int_uint.md) | -| INT, MEDIUMINT | [Int32](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED BIGINT | [UInt64](../../sql_reference/data_types/int_uint.md) | -| BIGINT | [Int64](../../sql_reference/data_types/int_uint.md) | -| FLOAT | [Float32](../../sql_reference/data_types/float.md) | -| DOUBLE | [Float64](../../sql_reference/data_types/float.md) | -| DATE | [Date](../../sql_reference/data_types/date.md) | -| DATETIME, TIMESTAMP | [DateTime](../../sql_reference/data_types/datetime.md) | -| BINARY | [FixedString](../../sql_reference/data_types/fixedstring.md) | - -All other MySQL data types are converted into [String](../../sql_reference/data_types/string.md). - -[Nullable](../../sql_reference/data_types/nullable.md) is supported. - -## Examples Of Use {#examples-of-use} - -Table in MySQL: - -``` text -mysql> USE test; -Database changed - -mysql> CREATE TABLE `mysql_table` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `float` FLOAT NOT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from mysql_table; -+------+-----+ -| int_id | value | -+------+-----+ -| 1 | 2 | -+------+-----+ -1 row in set (0,00 sec) -``` - -Database in ClickHouse, exchanging data with the MySQL server: - -``` sql -CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') -``` - -``` sql -SHOW DATABASES -``` - -``` text -┌─name─────┐ -│ default │ -│ mysql_db │ -│ system │ -└──────────┘ -``` - -``` sql -SHOW TABLES FROM mysql_db -``` - -``` text -┌─name─────────┐ -│ mysql_table │ -└──────────────┘ -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -└────────┴───────┘ -``` - -``` sql -INSERT INTO mysql_db.mysql_table VALUES (3,4) -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -│ 3 │ 4 │ -└────────┴───────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/en/engines/index.md b/docs/en/engines/index.md index c4b0b299858..0ab3b5fe172 100644 --- a/docs/en/engines/index.md +++ b/docs/en/engines/index.md @@ -1,6 +1,8 @@ --- toc_folder_title: Engines toc_priority: 25 +toc_title: hidden +toc_hidden: true --- - +{## [Original article](https://clickhouse.tech/docs/en/engines/) ##} diff --git a/docs/en/engines/table-engines/index.md b/docs/en/engines/table-engines/index.md new file mode 100644 index 00000000000..ee28bfda905 --- /dev/null +++ b/docs/en/engines/table-engines/index.md @@ -0,0 +1,83 @@ +--- +toc_folder_title: Table Engines +toc_priority: 26 +toc_title: Introduction +--- + +# Table Engines {#table_engines} + +The table engine (type of table) determines: + +- How and where data is stored, where to write it to, and where to read it from. +- Which queries are supported, and how. +- Concurrent data access. +- Use of indexes, if present. +- Whether multithreaded request execution is possible. +- Data replication parameters. + +## Engine Families {#engine-families} + +### MergeTree {#mergetree} + +The most universal and functional table engines for high-load tasks. The property shared by these engines is quick data insertion with subsequent background data processing. `MergeTree` family engines support data replication (with [Replicated*](mergetree-family/replication.md#table_engines-replication) versions of engines), partitioning, and other features not supported in other engines. + +Engines in the family: + +- [MergeTree](mergetree-family/mergetree.md#mergetree) +- [ReplacingMergeTree](mergetree-family/replacingmergetree.md#replacingmergetree) +- [SummingMergeTree](mergetree-family/summingmergetree.md#summingmergetree) +- [AggregatingMergeTree](mergetree-family/aggregatingmergetree.md#aggregatingmergetree) +- [CollapsingMergeTree](mergetree-family/collapsingmergetree.md#table_engine-collapsingmergetree) +- [VersionedCollapsingMergeTree](mergetree-family/versionedcollapsingmergetree.md#versionedcollapsingmergetree) +- [GraphiteMergeTree](mergetree-family/graphitemergetree.md#graphitemergetree) + +### Log {#log} + +Lightweight [engines](log-family/index.md) with minimum functionality. They’re the most effective when you need to quickly write many small tables (up to approximately 1 million rows) and read them later as a whole. + +Engines in the family: + +- [TinyLog](log-family/tinylog.md#tinylog) +- [StripeLog](log-family/stripelog.md#stripelog) +- [Log](log-family/log.md#log) + +### Integration Engines {#integration-engines} + +Engines for communicating with other data storage and processing systems. + +Engines in the family: + +- [Kafka](integrations/kafka.md#kafka) +- [MySQL](integrations/mysql.md#mysql) +- [ODBC](integrations/odbc.md#table-engine-odbc) +- [JDBC](integrations/jdbc.md#table-engine-jdbc) +- [HDFS](integrations/hdfs.md#hdfs) + +### Special Engines {#special-engines} + +Engines in the family: + +- [Distributed](special/distributed.md#distributed) +- [MaterializedView](special/materializedview.md#materializedview) +- [Dictionary](special/dictionary.md#dictionary) +- [Merge](special/merge.md#merge) +- [File](special/file.md#file) +- [Null](special/null.md#null) +- [Set](special/set.md#set) +- [Join](special/join.md#join) +- [URL](special/url.md#table_engines-url) +- [View](special/view.md#table_engines-view) +- [Memory](special/memory.md#memory) +- [Buffer](special/buffer.md#buffer) + +## Virtual Columns {#table_engines-virtual_columns} + +Virtual column is an integral table engine attribute that is defined in the engine source code. + +You shouldn’t specify virtual columns in the `CREATE TABLE` query and you can’t see them in `SHOW CREATE TABLE` and `DESCRIBE TABLE` query results. Virtual columns are also read-only, so you can’t insert data into virtual columns. + +To select data from a virtual column, you must specify its name in the `SELECT` query. `SELECT *` doesn’t return values from virtual columns. + +If you create a table with a column that has the same name as one of the table virtual columns, the virtual column becomes inaccessible. We don’t recommend doing this. To help avoid conflicts, virtual column names are usually prefixed with an underscore. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/en/engines/table-engines/integrations/hdfs.md b/docs/en/engines/table-engines/integrations/hdfs.md new file mode 100644 index 00000000000..045b235bb5e --- /dev/null +++ b/docs/en/engines/table-engines/integrations/hdfs.md @@ -0,0 +1,121 @@ +--- +toc_priority: 36 +toc_title: HDFS +--- + +# HDFS {#table_engines-hdfs} + +This engine provides integration with [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) ecosystem by allowing to manage data on [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)via ClickHouse. This engine is similar +to the [File](../special/file.md#table_engines-file) and [URL](../special/url.md#table_engines-url) engines, but provides Hadoop-specific features. + +## Usage {#usage} + +``` sql +ENGINE = HDFS(URI, format) +``` + +The `URI` parameter is the whole file URI in HDFS. +The `format` parameter specifies one of the available file formats. To perform +`SELECT` queries, the format must be supported for input, and to perform +`INSERT` queries – for output. The available formats are listed in the +[Formats](../../../interfaces/formats.md#formats) section. +The path part of `URI` may contain globs. In this case the table would be readonly. + +**Example:** + +**1.** Set up the `hdfs_engine_table` table: + +``` sql +CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') +``` + +**2.** Fill file: + +``` sql +INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) +``` + +**3.** Query the data: + +``` sql +SELECT * FROM hdfs_engine_table LIMIT 2 +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Implementation Details {#implementation-details} + +- Reads and writes can be parallel +- Not supported: + - `ALTER` and `SELECT...SAMPLE` operations. + - Indexes. + - Replication. + +**Globs in path** + +Multiple path components can have globs. For being processed file should exists and matches to the whole path pattern. Listing of files determines during `SELECT` (not at `CREATE` moment). + +- `*` — Substitutes any number of any characters except `/` including empty string. +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +Constructions with `{}` are similar to the [remote](../../../sql-reference/table-functions/remote.md) table function. + +**Example** + +1. Suppose we have several files in TSV format with the following URIs on HDFS: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. There are several ways to make a table consisting of all six files: + + + +``` sql +CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') +``` + +Another way: + +``` sql +CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') +``` + +Table consists of all the files in both directories (all files should satisfy format and schema described in query): + +``` sql +CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') +``` + +!!! warning "Warning" + If the listing of files contains number ranges with leading zeros, use the construction with braces for each digit separately or use `?`. + +**Example** + +Create table with files named `file000`, `file001`, … , `file999`: + +``` sql +CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') +``` + +## Virtual Columns {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**See Also** + +- [Virtual columns](../index.md#table_engines-virtual_columns) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/en/engines/table-engines/integrations/index.md b/docs/en/engines/table-engines/integrations/index.md new file mode 100644 index 00000000000..dd005919ad1 --- /dev/null +++ b/docs/en/engines/table-engines/integrations/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Integrations +toc_priority: 30 +--- + + diff --git a/docs/en/engines/table-engines/integrations/jdbc.md b/docs/en/engines/table-engines/integrations/jdbc.md new file mode 100644 index 00000000000..08ddc19520a --- /dev/null +++ b/docs/en/engines/table-engines/integrations/jdbc.md @@ -0,0 +1,88 @@ +--- +toc_priority: 34 +toc_title: JDBC +--- + +# JDBC {#table-engine-jdbc} + +Allows ClickHouse to connect to external databases via [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). + +To implement the JDBC connection, ClickHouse uses the separate program [clickhouse-jdbc-bridge](https://github.com/alex-krash/clickhouse-jdbc-bridge) that should run as a daemon. + +This engine supports the [Nullable](../../../sql-reference/data-types/nullable.md) data type. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name +( + columns list... +) +ENGINE = JDBC(dbms_uri, external_database, external_table) +``` + +**Engine Parameters** + +- `dbms_uri` — URI of an external DBMS. + + Format: `jdbc:://:/?user=&password=`. + Example for MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. + +- `external_database` — Database in an external DBMS. + +- `external_table` — Name of the table in `external_database`. + +## Usage Example {#usage-example} + +Creating a table in MySQL server by connecting directly with it’s console client: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Creating a table in ClickHouse server and selecting data from it: + +``` sql +CREATE TABLE jdbc_table +( + `int_id` Int32, + `int_nullable` Nullable(Int32), + `float` Float32, + `float_nullable` Nullable(Float32) +) +ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') +``` + +``` sql +SELECT * +FROM jdbc_table +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## See Also {#see-also} + +- [JDBC table function](../../../sql-reference/table-functions/jdbc.md). + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/en/engines/table-engines/integrations/kafka.md b/docs/en/engines/table-engines/integrations/kafka.md new file mode 100644 index 00000000000..97d5333b0ad --- /dev/null +++ b/docs/en/engines/table-engines/integrations/kafka.md @@ -0,0 +1,179 @@ +--- +toc_priority: 32 +toc_title: Kafka +--- + +# Kafka {#kafka} + +This engine works with [Apache Kafka](http://kafka.apache.org/). + +Kafka lets you: + +- Publish or subscribe to data flows. +- Organize fault-tolerant storage. +- Process streams as they become available. + +## Creating a Table {#table_engine-kafka-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = Kafka() +SETTINGS + kafka_broker_list = 'host:port', + kafka_topic_list = 'topic1,topic2,...', + kafka_group_name = 'group_name', + kafka_format = 'data_format'[,] + [kafka_row_delimiter = 'delimiter_symbol',] + [kafka_schema = '',] + [kafka_num_consumers = N,] + [kafka_max_block_size = 0,] + [kafka_skip_broken_messages = N,] + [kafka_commit_every_batch = 0] +``` + +Required parameters: + +- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). +- `kafka_topic_list` – A list of Kafka topics. +- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don’t want messages to be duplicated in the cluster, use the same group name everywhere. +- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` function, such as `JSONEachRow`. For more information, see the [Formats](../../../interfaces/formats.md) section. + +Optional parameters: + +- `kafka_row_delimiter` – Delimiter character, which ends the message. +- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap’n Proto](https://capnproto.org/) requires the path to the schema file and the name of the root `schema.capnp:Message` object. +- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Specify more consumers if the throughput of one consumer is insufficient. The total number of consumers should not exceed the number of partitions in the topic, since only one consumer can be assigned per partition. +- `kafka_max_block_size` - The maximum batch size (in messages) for poll (default: `max_block_size`). +- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. If `kafka_skip_broken_messages = N` then the engine skips *N* Kafka messages that cannot be parsed (a message equals a row of data). +- `kafka_commit_every_batch` - Commit every consumed and handled batch instead of a single commit after writing a whole block (default: `0`). + +Examples: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + SELECT * FROM queue LIMIT 5; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', + kafka_topic_list = 'topic', + kafka_group_name = 'group1', + kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; + + CREATE TABLE queue3 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') + SETTINGS kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; +``` + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects. If possible, switch old projects to the method described above. + +``` sql +Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format + [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) +``` + +
+ +## Description {#description} + +The delivered messages are tracked automatically, so each message in a group is only counted once. If you want to get the data twice, then create a copy of the table with another group name. + +Groups are flexible and synced on the cluster. For instance, if you have 10 topics and 5 copies of a table in a cluster, then each copy gets 2 topics. If the number of copies changes, the topics are redistributed across the copies automatically. Read more about this at http://kafka.apache.org/intro. + +`SELECT` is not particularly useful for reading messages (except for debugging), because each message can be read only once. It is more practical to create real-time threads using materialized views. To do this: + +1. Use the engine to create a Kafka consumer and consider it a data stream. +2. Create a table with the desired structure. +3. Create a materialized view that converts data from the engine and puts it into a previously created table. + +When the `MATERIALIZED VIEW` joins the engine, it starts collecting data in the background. This allows you to continually receive messages from Kafka and convert them to the required format using `SELECT`. +One kafka table can have as many materialized views as you like, they do not read data from the kafka table directly, but receive new records (in blocks), this way you can write to several tables with different detail level (with grouping - aggregation and without). + +Example: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + CREATE TABLE daily ( + day Date, + level String, + total UInt64 + ) ENGINE = SummingMergeTree(day, (day, level), 8192); + + CREATE MATERIALIZED VIEW consumer TO daily + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + FROM queue GROUP BY day, level; + + SELECT level, sum(total) FROM daily GROUP BY level; +``` + +To improve performance, received messages are grouped into blocks the size of [max\_insert\_block\_size](../../../operations/server-configuration-parameters/settings.md#settings-max_insert_block_size). If the block wasn’t formed within [stream\_flush\_interval\_ms](../../../operations/server-configuration-parameters/settings.md) milliseconds, the data will be flushed to the table regardless of the completeness of the block. + +To stop receiving topic data or to change the conversion logic, detach the materialized view: + +``` sql + DETACH TABLE consumer; + ATTACH TABLE consumer; +``` + +If you want to change the target table by using `ALTER`, we recommend disabling the material view to avoid discrepancies between the target table and the data from the view. + +## Configuration {#configuration} + +Similar to GraphiteMergeTree, the Kafka engine supports extended configuration using the ClickHouse config file. There are two configuration keys that you can use: global (`kafka`) and topic-level (`kafka_*`). The global configuration is applied first, and then the topic-level configuration is applied (if it exists). + +``` xml + + + cgrp + smallest + + + + + 250 + 100000 + +``` + +For a list of possible configuration options, see the [librdkafka configuration reference](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Use the underscore (`_`) instead of a dot in the ClickHouse configuration. For example, `check.crcs=true` will be `true`. + +## Virtual Columns {#virtual-columns} + +- `_topic` — Kafka topic. +- `_key` — Key of the message. +- `_offset` — Offset of the message. +- `_timestamp` — Timestamp of the message. +- `_partition` — Partition of Kafka topic. + +**See Also** + +- [Virtual columns](../index.md#table_engines-virtual_columns) +- [background_schedule_pool_size](../../../operations/settings/settings.md#background_schedule_pool_size) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/en/engines/table-engines/integrations/mysql.md b/docs/en/engines/table-engines/integrations/mysql.md new file mode 100644 index 00000000000..c98d492322f --- /dev/null +++ b/docs/en/engines/table-engines/integrations/mysql.md @@ -0,0 +1,103 @@ +--- +toc_priority: 33 +toc_title: MySQL +--- + +# Mysql {#mysql} + +The MySQL engine allows you to perform `SELECT` queries on data that is stored on a remote MySQL server. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... +) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +See a detailed description of the [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) query. + +The table structure can differ from the original MySQL table structure: + +- Column names should be the same as in the original MySQL table, but you can use just some of these columns and in any order. +- Column types may differ from those in the original MySQL table. ClickHouse tries to [cast](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) values to the ClickHouse data types. + +**Engine Parameters** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` queries to `REPLACE INTO`. If `replace_query=1`, the query is substituted. + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expression that is added to the `INSERT` query. + + Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the [MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. + + To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. + +Simple `WHERE` clauses such as `=, !=, >, >=, <, <=` are executed on the MySQL server. + +The rest of the conditions and the `LIMIT` sampling constraint are executed in ClickHouse only after the query to MySQL finishes. + +## Usage Example {#usage-example} + +Table in MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Table in ClickHouse, retrieving data from the MySQL table created above: + +``` sql +CREATE TABLE mysql_table +( + `float_nullable` Nullable(Float32), + `int_id` Int32 +) +ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` sql +SELECT * FROM mysql_table +``` + +``` text +┌─float_nullable─┬─int_id─┐ +│ ᴺᵁᴸᴸ │ 1 │ +└────────────────┴────────┘ +``` + +## See Also {#see-also} + +- [The ‘mysql’ table function](../../../sql-reference/table-functions/mysql.md) +- [Using MySQL as a source of external dictionary](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/en/engines/table-engines/integrations/odbc.md b/docs/en/engines/table-engines/integrations/odbc.md new file mode 100644 index 00000000000..04387760fb4 --- /dev/null +++ b/docs/en/engines/table-engines/integrations/odbc.md @@ -0,0 +1,130 @@ +--- +toc_priority: 35 +toc_title: ODBC +--- + +# ODBC {#table-engine-odbc} + +Allows ClickHouse to connect to external databases via [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +To safely implement ODBC connections, ClickHouse uses a separate program `clickhouse-odbc-bridge`. If the ODBC driver is loaded directly from `clickhouse-server`, driver problems can crash the ClickHouse server. ClickHouse automatically starts `clickhouse-odbc-bridge` when it is required. The ODBC bridge program is installed from the same package as the `clickhouse-server`. + +This engine supports the [Nullable](../../../sql-reference/data-types/nullable.md) data type. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1], + name2 [type2], + ... +) +ENGINE = ODBC(connection_settings, external_database, external_table) +``` + +See a detailed description of the [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) query. + +The table structure can differ from the source table structure: + +- Column names should be the same as in the source table, but you can use just some of these columns and in any order. +- Column types may differ from those in the source table. ClickHouse tries to [cast](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) values to the ClickHouse data types. + +**Engine Parameters** + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` file. +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +## Usage Example {#usage-example} + +**Retrieving data from the local MySQL installation via ODBC** + +This example is checked for Ubuntu Linux 18.04 and MySQL server 5.7. + +Ensure that unixODBC and MySQL Connector are installed. + +By default (if installed from packages), ClickHouse starts as user `clickhouse`. Thus, you need to create and configure this user in the MySQL server. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +Then configure the connection in `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +You can check the connection using the `isql` utility from the unixODBC installation. + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +Table in MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Table in ClickHouse, retrieving data from the MySQL table: + +``` sql +CREATE TABLE odbc_t +( + `int_id` Int32, + `float_nullable` Nullable(Float32) +) +ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') +``` + +``` sql +SELECT * FROM odbc_t +``` + +``` text +┌─int_id─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ +└────────┴────────────────┘ +``` + +## See Also {#see-also} + +- [ODBC external dictionaries](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [ODBC table function](../../../sql-reference/table-functions/odbc.md) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/en/engines/table-engines/log-family/index.md b/docs/en/engines/table-engines/log-family/index.md new file mode 100644 index 00000000000..a5d93c4c7c3 --- /dev/null +++ b/docs/en/engines/table-engines/log-family/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Log Family +toc_priority: 29 +--- + + diff --git a/docs/en/engines/table-engines/log-family/log-family.md b/docs/en/engines/table-engines/log-family/log-family.md new file mode 100644 index 00000000000..af87625393c --- /dev/null +++ b/docs/en/engines/table-engines/log-family/log-family.md @@ -0,0 +1,44 @@ +--- +toc_priority: 31 +toc_title: Introduction +--- + +# Log Engine Family {#log-engine-family} + +These engines were developed for scenarios when you need to quickly write many small tables (up to about 1 million rows) and read them later as a whole. + +Engines of the family: + +- [StripeLog](stripelog.md) +- [Log](log.md) +- [TinyLog](tinylog.md) + +## Common Properties {#common-properties} + +Engines: + +- Store data on a disk. + +- Append data to the end of file when writing. + +- Support locks for concurrent data access. + + During `INSERT` queries, the table is locked, and other queries for reading and writing data both wait for the table to unlock. If there are no data writing queries, any number of data reading queries can be performed concurrently. + +- Do not support [mutation](../../../sql-reference/statements/alter.md#alter-mutations) operations. + +- Do not support indexes. + + This means that `SELECT` queries for ranges of data are not efficient. + +- Do not write data atomically. + + You can get a table with corrupted data if something breaks the write operation, for example, abnormal server shutdown. + +## Differences {#differences} + +The `TinyLog` engine is the simplest in the family and provides the poorest functionality and lowest efficiency. The `TinyLog` engine doesn’t support parallel data reading by several threads. It reads data slower than other engines in the family that support parallel reading and it uses almost as many descriptors as the `Log` engine because it stores each column in a separate file. Use it in simple low-load scenarios. + +The `Log` and `StripeLog` engines support parallel data reading. When reading data, ClickHouse uses multiple threads. Each thread processes a separate data block. The `Log` engine uses a separate file for each column of the table. `StripeLog` stores all the data in one file. As a result, the `StripeLog` engine uses fewer descriptors in the operating system, but the `Log` engine provides higher efficiency when reading data. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/en/engines/table-engines/log-family/log.md b/docs/en/engines/table-engines/log-family/log.md new file mode 100644 index 00000000000..1bc229837a4 --- /dev/null +++ b/docs/en/engines/table-engines/log-family/log.md @@ -0,0 +1,14 @@ +--- +toc_priority: 33 +toc_title: Log +--- + +# Log {#log} + +Engine belongs to the family of log engines. See the common properties of log engines and their differences in the [Log Engine Family](log-family.md) article. + +Log differs from [TinyLog](tinylog.md) in that a small file of “marks” resides with the column files. These marks are written on every data block and contain offsets that indicate where to start reading the file in order to skip the specified number of rows. This makes it possible to read table data in multiple threads. +For concurrent data access, the read operations can be performed simultaneously, while write operations block reads and each other. +The Log engine does not support indexes. Similarly, if writing to a table failed, the table is broken, and reading from it returns an error. The Log engine is appropriate for temporary data, write-once tables, and for testing or demonstration purposes. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/en/engines/table-engines/log-family/stripelog.md b/docs/en/engines/table-engines/log-family/stripelog.md new file mode 100644 index 00000000000..87e8999fb51 --- /dev/null +++ b/docs/en/engines/table-engines/log-family/stripelog.md @@ -0,0 +1,93 @@ +--- +toc_priority: 32 +toc_title: StripeLog +--- + +# Stripelog {#stripelog} + +This engine belongs to the family of log engines. See the common properties of log engines and their differences in the [Log Engine Family](log-family.md) article. + +Use this engine in scenarios when you need to write many tables with a small amount of data (less than 1 million rows). + +## Creating a Table {#table_engines-stripelog-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = StripeLog +``` + +See the detailed description of the [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) query. + +## Writing the Data {#table_engines-stripelog-writing-the-data} + +The `StripeLog` engine stores all the columns in one file. For each `INSERT` query, ClickHouse appends the data block to the end of a table file, writing columns one by one. + +For each table ClickHouse writes the files: + +- `data.bin` — Data file. +- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. + +The `StripeLog` engine does not support the `ALTER UPDATE` and `ALTER DELETE` operations. + +## Reading the Data {#table_engines-stripelog-reading-the-data} + +The file with marks allows ClickHouse to parallelize the reading of data. This means that a `SELECT` query returns rows in an unpredictable order. Use the `ORDER BY` clause to sort rows. + +## Example of Use {#table_engines-stripelog-example-of-use} + +Creating a table: + +``` sql +CREATE TABLE stripe_log_table +( + timestamp DateTime, + message_type String, + message String +) +ENGINE = StripeLog +``` + +Inserting data: + +``` sql +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') +``` + +We used two `INSERT` queries to create two data blocks inside the `data.bin` file. + +ClickHouse uses multiple threads when selecting data. Each thread reads a separate data block and returns resulting rows independently as it finishes. As a result, the order of blocks of rows in the output does not match the order of the same blocks in the input in most cases. For example: + +``` sql +SELECT * FROM stripe_log_table +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +┌───────────timestamp─┬─message_type─┬─message───────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +└─────────────────────┴──────────────┴───────────────────────────┘ +``` + +Sorting the results (ascending order by default): + +``` sql +SELECT * FROM stripe_log_table ORDER BY timestamp +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +``` + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/en/engines/table-engines/log-family/tinylog.md b/docs/en/engines/table-engines/log-family/tinylog.md new file mode 100644 index 00000000000..8dc5a837028 --- /dev/null +++ b/docs/en/engines/table-engines/log-family/tinylog.md @@ -0,0 +1,14 @@ +--- +toc_priority: 34 +toc_title: TinyLog +--- + +# TinyLog {#tinylog} + +The engine belongs to the log engine family. See [Log Engine Family](log-family.md) for common properties of log engines and their differences. + +This table engine is typically used with the write-once method: write data one time, then read it as many times as necessary. For example, you can use `TinyLog`-type tables for intermediary data that is processed in small batches. Note that storing data in a large number of small tables is inefficient. + +Queries are executed in a single stream. In other words, this engine is intended for relatively small tables (up to about 1,000,000 rows). It makes sense to use this table engine if you have many small tables, since it’s simpler than the [Log](log.md) engine (fewer files need to be opened). + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/en/engines/table-engines/mergetree-family/aggregatingmergetree.md b/docs/en/engines/table-engines/mergetree-family/aggregatingmergetree.md new file mode 100644 index 00000000000..7e1c04a17e7 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/aggregatingmergetree.md @@ -0,0 +1,103 @@ +--- +toc_priority: 35 +toc_title: AggregatingMergeTree +--- + +# Aggregatingmergetree {#aggregatingmergetree} + +The engine inherits from [MergeTree](mergetree.md#table_engines-mergetree), altering the logic for data parts merging. ClickHouse replaces all rows with the same primary key (or more accurately, with the same [sorting key](mergetree.md)) with a single row (within a one data part) that stores a combination of states of aggregate functions. + +You can use `AggregatingMergeTree` tables for incremental data aggregation, including for aggregated materialized views. + +The engine processes all columns with the following types: + +- [AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) +- [SimpleAggregateFunction](../../../sql-reference/data-types/simpleaggregatefunction.md) + +It is appropriate to use `AggregatingMergeTree` if it reduces the number of rows by orders. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = AggregatingMergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[TTL expr] +[SETTINGS name=value, ...] +``` + +For a description of request parameters, see [request description](../../../sql-reference/statements/create.md). + +**Query clauses** + +When creating a `AggregatingMergeTree` table the same [clauses](mergetree.md) are required, as when creating a `MergeTree` table. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects and, if possible, switch the old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +All of the parameters have the same meaning as in `MergeTree`. +
+ +## SELECT and INSERT {#select-and-insert} + +To insert data, use [INSERT SELECT](../../../sql-reference/statements/insert-into.md) query with aggregate -State- functions. +When selecting data from `AggregatingMergeTree` table, use `GROUP BY` clause and the same aggregate functions as when inserting data, but using `-Merge` suffix. + +In the results of `SELECT` query, the values of `AggregateFunction` type have implementation-specific binary representation for all of the ClickHouse output formats. If dump data into, for example, `TabSeparated` format with `SELECT` query then this dump can be loaded back using `INSERT` query. + +## Example of an Aggregated Materialized View {#example-of-an-aggregated-materialized-view} + +`AggregatingMergeTree` materialized view that watches the `test.visits` table: + +``` sql +CREATE MATERIALIZED VIEW test.basic +ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) +AS SELECT + CounterID, + StartDate, + sumState(Sign) AS Visits, + uniqState(UserID) AS Users +FROM test.visits +GROUP BY CounterID, StartDate; +``` + +Inserting data into the `test.visits` table. + +``` sql +INSERT INTO test.visits ... +``` + +The data are inserted in both the table and view `test.basic` that will perform the aggregation. + +To get the aggregated data, we need to execute a query such as `SELECT ... GROUP BY ...` from the view `test.basic`: + +``` sql +SELECT + StartDate, + sumMerge(Visits) AS Visits, + uniqMerge(Users) AS Users +FROM test.basic +GROUP BY StartDate +ORDER BY StartDate; +``` + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/en/engines/table-engines/mergetree-family/collapsingmergetree.md b/docs/en/engines/table-engines/mergetree-family/collapsingmergetree.md new file mode 100644 index 00000000000..26e9dfe91c3 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/collapsingmergetree.md @@ -0,0 +1,304 @@ +--- +toc_priority: 36 +toc_title: CollapsingMergeTree +--- + +# CollapsingMergeTree {#table_engine-collapsingmergetree} + +The engine inherits from [MergeTree](mergetree.md) and adds the logic of rows collapsing to data parts merge algorithm. + +`CollapsingMergeTree` asynchronously deletes (collapses) pairs of rows if all of the fields in a sorting key (`ORDER BY`) are equivalent excepting the particular field `Sign` which can have `1` and `-1` values. Rows without a pair are kept. For more details see the [Collapsing](#table_engine-collapsingmergetree-collapsing) section of the document. + +The engine may significantly reduce the volume of storage and increase the efficiency of `SELECT` query as a consequence. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = CollapsingMergeTree(sign) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +For a description of query parameters, see [query description](../../../sql-reference/statements/create.md). + +**CollapsingMergeTree Parameters** + +- `sign` — Name of the column with the type of row: `1` is a “state” row, `-1` is a “cancel” row. + + Column data type — `Int8`. + +**Query clauses** + +When creating a `CollapsingMergeTree` table, the same [query clauses](mergetree.md#table_engine-mergetree-creating-a-table) are required, as when creating a `MergeTree` table. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects and, if possible, switch the old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) +``` + +All of the parameters excepting `sign` have the same meaning as in `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` — “state” row, `-1` — “cancel” row. + + Column Data Type — `Int8`. + +
+ +## Collapsing {#table_engine-collapsingmergetree-collapsing} + +### Data {#data} + +Consider the situation where you need to save continually changing data for some object. It sounds logical to have one row for an object and update it at any change, but update operation is expensive and slow for DBMS because it requires rewriting of the data in the storage. If you need to write data quickly, update not acceptable, but you can write the changes of an object sequentially as follows. + +Use the particular column `Sign`. If `Sign = 1` it means that the row is a state of an object, let’s call it “state” row. If `Sign = -1` it means the cancellation of the state of an object with the same attributes, let’s call it “cancel” row. + +For example, we want to calculate how much pages users checked at some site and how long they were there. At some moment we write the following row with the state of user activity: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +At some moment later we register the change of user activity and write it with the following two rows. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +The first row cancels the previous state of the object (user). It should copy the sorting key fields of the cancelled state excepting `Sign`. + +The second row contains the current state. + +As we need only the last state of user activity, the rows + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +can be deleted collapsing the invalid (old) state of an object. `CollapsingMergeTree` does this while merging of the data parts. + +Why we need 2 rows for each change read in the [Algorithm](#table_engine-collapsingmergetree-collapsing-algorithm) paragraph. + +**Peculiar properties of such approach** + +1. The program that writes the data should remember the state of an object to be able to cancel it. “Cancel” string should contain copies of the sorting key fields of the “state” string and the opposite `Sign`. It increases the initial size of storage but allows to write the data quickly. +2. Long growing arrays in columns reduce the efficiency of the engine due to load for writing. The more straightforward data, the higher the efficiency. +3. The `SELECT` results depend strongly on the consistency of object changes history. Be accurate when preparing data for inserting. You can get unpredictable results in inconsistent data, for example, negative values for non-negative metrics such as session depth. + +### Algorithm {#table_engine-collapsingmergetree-collapsing-algorithm} + +When ClickHouse merges data parts, each group of consecutive rows with the same sorting key (`ORDER BY`) is reduced to not more than two rows, one with `Sign = 1` (“state” row) and another with `Sign = -1` (“cancel” row). In other words, entries collapse. + +For each resulting data part ClickHouse saves: + +1. The first “cancel” and the last “state” rows, if the number of “state” and “cancel” rows matches and the last row is a “state” row. +2. The last “state” row, if there are more “state” rows than “cancel” rows. +3. The first “cancel” row, if there are more “cancel” rows than “state” rows. +4. None of the rows, in all other cases. + +Also when there are at least 2 more “state” rows than “cancel” rows, or at least 2 more “cancel” rows then “state” rows, the merge continues, but ClickHouse treats this situation as a logical error and records it in the server log. This error can occur if the same data were inserted more than once. + +Thus, collapsing should not change the results of calculating statistics. +Changes gradually collapsed so that in the end only the last state of almost every object left. + +The `Sign` is required because the merging algorithm doesn’t guarantee that all of the rows with the same sorting key will be in the same resulting data part and even on the same physical server. ClickHouse process `SELECT` queries with multiple threads, and it can not predict the order of rows in the result. The aggregation is required if there is a need to get completely “collapsed” data from `CollapsingMergeTree` table. + +To finalize collapsing, write a query with `GROUP BY` clause and aggregate functions that account for the sign. For example, to calculate quantity, use `sum(Sign)` instead of `count()`. To calculate the sum of something, use `sum(Sign * x)` instead of `sum(x)`, and so on, and also add `HAVING sum(Sign) > 0`. + +The aggregates `count`, `sum` and `avg` could be calculated this way. The aggregate `uniq` could be calculated if an object has at least one state not collapsed. The aggregates `min` and `max` could not be calculated because `CollapsingMergeTree` does not save the values history of the collapsed states. + +If you need to extract data without aggregation (for example, to check whether rows are present whose newest values match certain conditions), you can use the `FINAL` modifier for the `FROM` clause. This approach is significantly less efficient. + +## Example of Use {#example-of-use} + +Example data: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Creation of the table: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Insertion of the data: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) +``` + +We use two `INSERT` queries to create two different data parts. If we insert the data with one query ClickHouse creates one data part and will not perform any merge ever. + +Getting the data: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +What do we see and where is collapsing? + +With two `INSERT` queries, we created 2 data parts. The `SELECT` query was performed in 2 threads, and we got a random order of rows. Collapsing not occurred because there was no merge of the data parts yet. ClickHouse merges data part in an unknown moment which we can not predict. + +Thus we need aggregation: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration +FROM UAct +GROUP BY UserID +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +If we do not need aggregation and want to force collapsing, we can use `FINAL` modifier for `FROM` clause. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +This way of selecting the data is very inefficient. Don’t use it for big tables. + +## Example of Another Approach {#example-of-another-approach} + +Example data: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ -5 │ -146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +The idea is that merges take into account only key fields. And in the “Cancel” line we can specify negative values that equalize the previous version of the row when summing without using the Sign column. For this approach, it is necessary to change the data type `PageViews`,`Duration` to store negative values of UInt8 -\> Int16. + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews Int16, + Duration Int16, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Let’s test the approach: + +``` sql +insert into UAct values(4324182021466249494, 5, 146, 1); +insert into UAct values(4324182021466249494, -5, -146, -1); +insert into UAct values(4324182021466249494, 6, 185, 1); + +select * from UAct final; // avoid using final in production (just for a test or small tables) +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +``` sql +SELECT + UserID, + sum(PageViews) AS PageViews, + sum(Duration) AS Duration +FROM UAct +GROUP BY UserID +```text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +``` sqk +select count() FROM UAct +``` + +``` text +┌─count()─┐ +│ 3 │ +└─────────┘ +``` + +``` sql +optimize table UAct final; + +select * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/en/engines/table-engines/mergetree-family/custom-partitioning-key.md b/docs/en/engines/table-engines/mergetree-family/custom-partitioning-key.md new file mode 100644 index 00000000000..91ae0dfbc44 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/custom-partitioning-key.md @@ -0,0 +1,125 @@ +--- +toc_priority: 32 +toc_title: Custom Partitioning Key +--- + +# Custom Partitioning Key {#custom-partitioning-key} + +Partitioning is available for the [MergeTree](mergetree.md) family tables (including [replicated](replication.md) tables). [Materialized views](../special/materializedview.md#materializedview) based on MergeTree tables support partitioning, as well. + +A partition is a logical combination of records in a table by a specified criterion. You can set a partition by an arbitrary criterion, such as by month, by day, or by event type. Each partition is stored separately to simplify manipulations of this data. When accessing the data, ClickHouse uses the smallest subset of partitions possible. + +The partition is specified in the `PARTITION BY expr` clause when [creating a table](mergetree.md#table_engine-mergetree-creating-a-table). The partition key can be any expression from the table columns. For example, to specify partitioning by month, use the expression `toYYYYMM(date_column)`: + +``` sql +CREATE TABLE visits +( + VisitDate Date, + Hour UInt8, + ClientID UUID +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(VisitDate) +ORDER BY Hour; +``` + +The partition key can also be a tuple of expressions (similar to the [primary key](mergetree.md#primary-keys-and-indexes-in-queries)). For example: + +``` sql +ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) +PARTITION BY (toMonday(StartDate), EventType) +ORDER BY (CounterID, StartDate, intHash32(UserID)); +``` + +In this example, we set partitioning by the event types that occurred during the current week. + +When inserting new data to a table, this data is stored as a separate part (chunk) sorted by the primary key. In 10-15 minutes after inserting, the parts of the same partition are merged into the entire part. + +!!! info "Info" + A merge only works for data parts that have the same value for the partitioning expression. This means **you shouldn’t make overly granular partitions** (more than about a thousand partitions). Otherwise, the `SELECT` query performs poorly because of an unreasonably large number of files in the file system and open file descriptors. + +Use the [system.parts](../../../operations/system-tables.md#system_tables-parts) table to view the table parts and partitions. For example, let’s assume that we have a `visits` table with partitioning by month. Let’s perform the `SELECT` query for the `system.parts` table: + +``` sql +SELECT + partition, + name, + active +FROM system.parts +WHERE table = 'visits' +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 1 │ +│ 201902 │ 201902_11_11_0 │ 1 │ +└───────────┴────────────────┴────────┘ +``` + +The `partition` column contains the names of the partitions. There are two partitions in this example: `201901` and `201902`. You can use this column value to specify the partition name in [ALTER … PARTITION](#alter_manipulations-with-partitions) queries. + +The `name` column contains the names of the partition data parts. You can use this column to specify the name of the part in the [ALTER ATTACH PART](#alter_attach-partition) query. + +Let’s break down the name of the first part: `201901_1_3_1`: + +- `201901` is the partition name. +- `1` is the minimum number of the data block. +- `3` is the maximum number of the data block. +- `1` is the chunk level (the depth of the merge tree it is formed from). + +!!! info "Info" + The parts of old-type tables have the name: `20190117_20190123_2_2_0` (minimum date - maximum date - minimum block number - maximum block number - level). + +The `active` column shows the status of the part. `1` is active; `0` is inactive. The inactive parts are, for example, source parts remaining after merging to a larger part. The corrupted data parts are also indicated as inactive. + +As you can see in the example, there are several separated parts of the same partition (for example, `201901_1_3_1` and `201901_1_9_2`). This means that these parts are not merged yet. ClickHouse merges the inserted parts of data periodically, approximately 15 minutes after inserting. In addition, you can perform a non-scheduled merge using the [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) query. Example: + +``` sql +OPTIMIZE TABLE visits PARTITION 201902; +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 0 │ +│ 201902 │ 201902_4_11_2 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 0 │ +│ 201902 │ 201902_11_11_0 │ 0 │ +└───────────┴────────────────┴────────┘ +``` + +Inactive parts will be deleted approximately 10 minutes after merging. + +Another way to view a set of parts and partitions is to go into the directory of the table: `/var/lib/clickhouse/data///`. For example: + +``` bash +/var/lib/clickhouse/data/default/visits$ ls -l +total 40 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached +``` + +The folders ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ and so on are the directories of the parts. Each part relates to a corresponding partition and contains data just for a certain month (the table in this example has partitioning by month). + +The `detached` directory contains parts that were detached from the table using the [DETACH](../../../sql-reference/statements/alter.md#alter_detach-partition) query. The corrupted parts are also moved to this directory, instead of being deleted. The server does not use the parts from the `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql-reference/statements/alter.md#alter_attach-partition) query. + +Note that on the operating server, you cannot manually change the set of parts or their data on the file system, since the server will not know about it. For non-replicated tables, you can do this when the server is stopped, but it isn’t recommended. For replicated tables, the set of parts cannot be changed in any case. + +ClickHouse allows you to perform operations with the partitions: delete them, copy from one table to another, or create a backup. See the list of all operations in the section [Manipulations With Partitions and Parts](../../../sql-reference/statements/alter.md#alter_manipulations-with-partitions). + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/en/engines/table-engines/mergetree-family/graphitemergetree.md b/docs/en/engines/table-engines/mergetree-family/graphitemergetree.md new file mode 100644 index 00000000000..db761a01be3 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/graphitemergetree.md @@ -0,0 +1,172 @@ +--- +toc_priority: 38 +toc_title: GraphiteMergeTree +--- + +# GraphiteMergeTree {#graphitemergetree} + +This engine is designed for thinning and aggregating/averaging (rollup) [Graphite](http://graphite.readthedocs.io/en/latest/index.html) data. It may be helpful to developers who want to use ClickHouse as a data store for Graphite. + +You can use any ClickHouse table engine to store the Graphite data if you don’t need rollup, but if you need a rollup use `GraphiteMergeTree`. The engine reduces the volume of storage and increases the efficiency of queries from Graphite. + +The engine inherits properties from [MergeTree](mergetree.md). + +## Creating a Table {#creating-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE = GraphiteMergeTree(config_section) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +See a detailed description of the [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) query. + +A table for the Graphite data should have the following columns for the following data: + +- Metric name (Graphite sensor). Data type: `String`. + +- Time of measuring the metric. Data type: `DateTime`. + +- Value of the metric. Data type: any numeric. + +- Version of the metric. Data type: any numeric. + + ClickHouse saves the rows with the highest version or the last written if versions are the same. Other rows are deleted during the merge of data parts. + +The names of these columns should be set in the rollup configuration. + +**GraphiteMergeTree parameters** + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +**Query clauses** + +When creating a `GraphiteMergeTree` table, the same [clauses](mergetree.md#table_engine-mergetree-creating-a-table) are required, as when creating a `MergeTree` table. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects and, if possible, switch the old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + EventDate Date, + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) +``` + +All of the parameters excepting `config_section` have the same meaning as in `MergeTree`. + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +
+ +## Rollup Configuration {#rollup-configuration} + +The settings for rollup are defined by the [graphite\_rollup](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-graphite) parameter in the server configuration. The name of the parameter could be any. You can create several configurations and use them for different tables. + +Rollup configuration structure: + + required-columns + patterns + +### Required Columns {#required-columns} + +- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. +- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. +- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Default value: `Value`. +- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. + +### Patterns {#patterns} + +Structure of the `patterns` section: + +``` text +pattern + regexp + function +pattern + regexp + age + precision + ... +pattern + regexp + function + age + precision + ... +pattern + ... +default + function + age + precision + ... +``` + +!!! warning "Attention" + Patterns must be strictly ordered: + + 1. Patterns without `function` or `retention`. + 1. Patterns with both `function` and `retention`. + 1. Pattern `default`. + +When processing a row, ClickHouse checks the rules in the `pattern` sections. Each of `pattern` (including `default`) sections can contain `function` parameter for aggregation, `retention` parameters or both. If the metric name matches the `regexp`, the rules from the `pattern` section (or sections) are applied; otherwise, the rules from the `default` section are used. + +Fields for `pattern` and `default` sections: + +- `regexp`– A pattern for the metric name. +- `age` – The minimum age of the data in seconds. +- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). +- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. + +### Configuration Example {#configuration-example} + +``` xml + + Version + + click_cost + any + + 0 + 5 + + + 86400 + 60 + + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/en/engines/table-engines/mergetree-family/index.md b/docs/en/engines/table-engines/mergetree-family/index.md new file mode 100644 index 00000000000..9e989d807da --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: MergeTree Family +toc_priority: 28 +--- + + diff --git a/docs/en/engines/table-engines/mergetree-family/mergetree.md b/docs/en/engines/table-engines/mergetree-family/mergetree.md new file mode 100644 index 00000000000..33d12293172 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/mergetree.md @@ -0,0 +1,663 @@ +--- +toc_priority: 30 +toc_title: MergeTree +--- + +# MergeTree {#table_engines-mergetree} + +The `MergeTree` engine and other engines of this family (`*MergeTree`) are the most robust ClickHouse table engines. + +Engines in the `MergeTree` family are designed for inserting a very large amount of data into a table. The data is quickly written to the table part by part, then rules are applied for merging the parts in the background. This method is much more efficient than continually rewriting the data in storage during insert. + +Main features: + +- Stores data sorted by primary key. + + This allows you to create a small sparse index that helps find data faster. + +- Partitions can be used if the [partitioning key](custom-partitioning-key.md) is specified. + + ClickHouse supports certain operations with partitions that are more effective than general operations on the same data with the same result. ClickHouse also automatically cuts off the partition data where the partitioning key is specified in the query. This also improves query performance. + +- Data replication support. + + The family of `ReplicatedMergeTree` tables provides data replication. For more information, see [Data replication](replication.md). + +- Data sampling support. + + If necessary, you can set the data sampling method in the table. + +!!! info "Info" + The [Merge](../special/merge.md#merge) engine does not belong to the `*MergeTree` family. + +## Creating a Table {#table_engine-mergetree-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... + INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, + INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 +) ENGINE = MergeTree() +ORDER BY expr +[PARTITION BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] +[SETTINGS name=value, ...] +``` + +For a description of parameters, see the [CREATE query description](../../../sql-reference/statements/create.md). + +!!! note "Note" + `INDEX` is an experimental feature, see [Data Skipping Indexes](#table_engine-mergetree-data_skipping-indexes). + +### Query Clauses {#mergetree-query-clauses} + +- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. The `MergeTree` engine does not have parameters. + +- `ORDER BY` — The sorting key. + + A tuple of column names or arbitrary expressions. Example: `ORDER BY (CounterID, EventDate)`. + + ClickHouse uses the sorting key as a primary key if the primary key is not defined obviously by the `PRIMARY KEY` clause. + + Use the `ORDER BY tuple()` syntax, if you don't need sorting. See [Selecting the Primary Key](#selecting-the-primary-key). + +- `PARTITION BY` — The [partitioning key](custom-partitioning-key.md). Optional. + + For partitioning by month, use the `toYYYYMM(date_column)` expression, where `date_column` is a column with a date of the type [Date](../../../sql-reference/data-types/date.md). The partition names here have the `"YYYYMM"` format. + +- `PRIMARY KEY` — The primary key if it [differs from the sorting key](#choosing-a-primary-key-that-differs-from-the-sorting-key). Optional. + + By default the primary key is the same as the sorting key (which is specified by the `ORDER BY` clause). Thus in most cases it is unnecessary to specify a separate `PRIMARY KEY` clause. + +- `SAMPLE BY` — An expression for sampling. Optional. + + If a sampling expression is used, the primary key must contain it. Example: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. + +- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [between disks and volumes](#table_engine-mergetree-multiple-volumes). Optional. + + Expression must have one `Date` or `DateTime` column as a result. Example: + `TTL date + INTERVAL 1 DAY` + + Type of the rule `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` specifies an action to be done with the part if the expression is satisfied (reaches current time): removal of expired rows, moving a part (if expression is satisfied for all rows in a part) to specified disk (`TO DISK 'xxx'`) or to volume (`TO VOLUME 'xxx'`). Default type of the rule is removal (`DELETE`). List of multiple rules can specified, but there should be no more than one `DELETE` rule. + + For more details, see [TTL for columns and tables](#table_engine-mergetree-ttl) + +- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree` (optional): + + - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Data Storage](#mergetree-data-storage). + - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Data Storage](#mergetree-data-storage). + - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` setting. Before version 19.11, there was only the `index_granularity` setting for restricting granule size. The `index_granularity_bytes` setting improves ClickHouse performance when selecting data from tables with big rows (tens and hundreds of megabytes). If you have tables with big rows, you can enable this setting for the tables to improve the efficiency of `SELECT` queries. + - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, then ZooKeeper stores less data. For more information, see the [setting description](../../../operations/server-configuration-parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) in “Server configuration parameters”. + - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` bytes, ClickHouse reads and writes the data to the storage disk using the direct I/O interface (`O_DIRECT` option). If `min_merge_bytes_to_use_direct_io = 0`, then direct I/O is disabled. Default value: `10 * 1024 * 1024 * 1024` bytes. + + - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). + - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don’t turn it off. + - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. + - `storage_policy` — Storage policy. See [Using Multiple Block Devices for Data Storage](#table_engine-mergetree-multiple-volumes). + +**Example of Sections Setting** + +``` sql +ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 +``` + +In the example, we set partitioning by month. + +We also set an expression for sampling as a hash by the user ID. This allows you to pseudorandomize the data in the table for each `CounterID` and `EventDate`. If you define a [SAMPLE](../../../sql-reference/statements/select/sample.md#select-sample-clause) clause when selecting the data, ClickHouse will return an evenly pseudorandom data sample for a subset of users. + +The `index_granularity` setting can be omitted because 8192 is the default value. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects. If possible, switch old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +**MergeTree() Parameters** + +- `date-column` — The name of a column of the [Date](../../../sql-reference/data-types/date.md) type. ClickHouse automatically creates partitions by month based on this column. The partition names are in the `"YYYYMM"` format. +- `sampling_expression` — An expression for sampling. +- `(primary, key)` — Primary key. Type: [Tuple()](../../../sql-reference/data-types/tuple.md) +- `index_granularity` — The granularity of an index. The number of data rows between the “marks” of an index. The value 8192 is appropriate for most tasks. + +**Example** + +``` sql +MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) +``` + +The `MergeTree` engine is configured in the same way as in the example above for the main engine configuration method. +
+ +## Data Storage {#mergetree-data-storage} + +A table consists of data parts sorted by primary key. + +When data is inserted in a table, separate data parts are created and each of them is lexicographically sorted by primary key. For example, if the primary key is `(CounterID, Date)`, the data in the part is sorted by `CounterID`, and within each `CounterID`, it is ordered by `Date`. + +Data belonging to different partitions are separated into different parts. In the background, ClickHouse merges data parts for more efficient storage. Parts belonging to different partitions are not merged. The merge mechanism does not guarantee that all rows with the same primary key will be in the same data part. + +Each data part is logically divided into granules. A granule is the smallest indivisible data set that ClickHouse reads when selecting data. ClickHouse doesn’t split rows or values, so each granule always contains an integer number of rows. The first row of a granule is marked with the value of the primary key for the row. For each data part, ClickHouse creates an index file that stores the marks. For each column, whether it’s in the primary key or not, ClickHouse also stores the same marks. These marks let you find data directly in column files. + +The granule size is restricted by the `index_granularity` and `index_granularity_bytes` settings of the table engine. The number of rows in a granule lays in the `[1, index_granularity]` range, depending on the size of the rows. The size of a granule can exceed `index_granularity_bytes` if the size of a single row is greater than the value of the setting. In this case, the size of the granule equals the size of the row. + +## Primary Keys and Indexes in Queries {#primary-keys-and-indexes-in-queries} + +Take the `(CounterID, Date)` primary key as an example. In this case, the sorting and index can be illustrated as follows: + + Whole data: [---------------------------------------------] + CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] + Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] + Marks: | | | | | | | | | | | + a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 + Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 + +If the data query specifies: + +- `CounterID in ('a', 'h')`, the server reads the data in the ranges of marks `[0, 3)` and `[6, 8)`. +- `CounterID IN ('a', 'h') AND Date = 3`, the server reads the data in the ranges of marks `[1, 3)` and `[7, 8)`. +- `Date = 3`, the server reads the data in the range of marks `[1, 10]`. + +The examples above show that it is always more effective to use an index than a full scan. + +A sparse index allows extra data to be read. When reading a single range of the primary key, up to `index_granularity * 2` extra rows in each data block can be read. + +Sparse indexes allow you to work with a very large number of table rows, because in most cases, such indexes fit in the computer’s RAM. + +ClickHouse does not require a unique primary key. You can insert multiple rows with the same primary key. + +### Selecting the Primary Key {#selecting-the-primary-key} + +The number of columns in the primary key is not explicitly limited. Depending on the data structure, you can include more or fewer columns in the primary key. This may: + +- Improve the performance of an index. + + If the primary key is `(a, b)`, then adding another column `c` will improve the performance if the following conditions are met: + + - There are queries with a condition on column `c`. + - Long data ranges (several times longer than the `index_granularity`) with identical values for `(a, b)` are common. In other words, when adding another column allows you to skip quite long data ranges. + +- Improve data compression. + + ClickHouse sorts data by primary key, so the higher the consistency, the better the compression. + +- Provide additional logic when merging data parts in the [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) and [SummingMergeTree](summingmergetree.md) engines. + + In this case it makes sense to specify the *sorting key* that is different from the primary key. + +A long primary key will negatively affect the insert performance and memory consumption, but extra columns in the primary key do not affect ClickHouse performance during `SELECT` queries. + +You can create a table without a primary key using the `ORDER BY tuple()` syntax. In this case, ClickHouse stores data in the order of inserting. If you want to save data order when inserting data by `INSERT ... SELECT` queries, set [max_insert_threads = 1](../../../operations/settings/settings.md#settings-max-insert-threads). + +To select data in the initial order, use [single-threaded](../../../operations/settings/settings.md#settings-max_threads) `SELECT` queries. + +### Choosing a Primary Key that Differs from the Sorting Key {#choosing-a-primary-key-that-differs-from-the-sorting-key} + +It is possible to specify a primary key (an expression with values that are written in the index file for each mark) that is different from the sorting key (an expression for sorting the rows in data parts). In this case the primary key expression tuple must be a prefix of the sorting key expression tuple. + +This feature is helpful when using the [SummingMergeTree](summingmergetree.md) and +[AggregatingMergeTree](aggregatingmergetree.md) table engines. In a common case when using these engines, the table has two types of columns: *dimensions* and *measures*. Typical queries aggregate values of measure columns with arbitrary `GROUP BY` and filtering by dimensions. Because SummingMergeTree and AggregatingMergeTree aggregate rows with the same value of the sorting key, it is natural to add all dimensions to it. As a result, the key expression consists of a long list of columns and this list must be frequently updated with newly added dimensions. + +In this case it makes sense to leave only a few columns in the primary key that will provide efficient range scans and add the remaining dimension columns to the sorting key tuple. + +[ALTER](../../../sql-reference/statements/alter.md) of the sorting key is a lightweight operation because when a new column is simultaneously added to the table and to the sorting key, existing data parts don’t need to be changed. Since the old sorting key is a prefix of the new sorting key and there is no data in the newly added column, the data is sorted by both the old and new sorting keys at the moment of table modification. + +### Use of Indexes and Partitions in Queries {#use-of-indexes-and-partitions-in-queries} + +For `SELECT` queries, ClickHouse analyzes whether an index can be used. An index can be used if the `WHERE/PREWHERE` clause has an expression (as one of the conjunction elements, or entirely) that represents an equality or inequality comparison operation, or if it has `IN` or `LIKE` with a fixed prefix on columns or expressions that are in the primary key or partitioning key, or on certain partially repetitive functions of these columns, or logical relationships of these expressions. + +Thus, it is possible to quickly run queries on one or many ranges of the primary key. In this example, queries will be fast when run for a specific tracking tag, for a specific tag and date range, for a specific tag and date, for multiple tags with a date range, and so on. + +Let’s look at the engine configured as follows: + + ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 + +In this case, in queries: + +``` sql +SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 +SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) +SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) +``` + +ClickHouse will use the primary key index to trim improper data and the monthly partitioning key to trim partitions that are in improper date ranges. + +The queries above show that the index is used even for complex expressions. Reading from the table is organized so that using the index can’t be slower than a full scan. + +In the example below, the index can’t be used. + +``` sql +SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' +``` + +To check whether ClickHouse can use the index when running a query, use the settings [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) and [force\_primary\_key](../../../operations/settings/settings.md). + +The key for partitioning by month allows reading only those data blocks which contain dates from the proper range. In this case, the data block may contain data for many dates (up to an entire month). Within a block, data is sorted by primary key, which might not contain the date as the first column. Because of this, using a query with only a date condition that does not specify the primary key prefix will cause more data to be read than for a single date. + +### Use of Index for Partially-monotonic Primary Keys {#use-of-index-for-partially-monotonic-primary-keys} + +Consider, for example, the days of the month. They form a [monotonic sequence](https://en.wikipedia.org/wiki/Monotonic_function) for one month, but not monotonic for more extended periods. This is a partially-monotonic sequence. If a user creates the table with partially-monotonic primary key, ClickHouse creates a sparse index as usual. When a user selects data from this kind of table, ClickHouse analyzes the query conditions. If the user wants to get data between two marks of the index and both these marks fall within one month, ClickHouse can use the index in this particular case because it can calculate the distance between the parameters of a query and index marks. + +ClickHouse cannot use an index if the values of the primary key in the query parameter range don’t represent a monotonic sequence. In this case, ClickHouse uses the full scan method. + +ClickHouse uses this logic not only for days of the month sequences, but for any primary key that represents a partially-monotonic sequence. + +### Data Skipping Indexes (experimental) {#table_engine-mergetree-data_skipping-indexes} + +The index declaration is in the columns section of the `CREATE` query. + +``` sql +INDEX index_name expr TYPE type(...) GRANULARITY granularity_value +``` + +For tables from the `*MergeTree` family, data skipping indices can be specified. + +These indices aggregate some information about the specified expression on blocks, which consist of `granularity_value` granules (the size of the granule is specified using the `index_granularity` setting in the table engine). Then these aggregates are used in `SELECT` queries for reducing the amount of data to read from the disk by skipping big blocks of data where the `where` query cannot be satisfied. + +**Example** + +``` sql +CREATE TABLE table_name +( + u64 UInt64, + i32 Int32, + s String, + ... + INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, + INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 +) ENGINE = MergeTree() +... +``` + +Indices from the example can be used by ClickHouse to reduce the amount of data to read from disk in the following queries: + +``` sql +SELECT count() FROM table WHERE s < 'z' +SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 +``` + +#### Available Types of Indices {#available-types-of-indices} + +- `minmax` + + Stores extremes of the specified expression (if the expression is `tuple`, then it stores extremes for each element of `tuple`), uses stored info for skipping blocks of data like the primary key. + +- `set(max_rows)` + + Stores unique values of the specified expression (no more than `max_rows` rows, `max_rows=0` means “no limits”). Uses the values to check if the `WHERE` expression is not satisfiable on a block of data. + +- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Stores a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) that contains all ngrams from a block of data. Works only with strings. Can be used for optimization of `equals`, `like` and `in` expressions. + + - `n` — ngram size, + - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). + - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. + - `random_seed` — The seed for Bloom filter hash functions. + +- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + The same as `ngrambf_v1`, but stores tokens instead of ngrams. Tokens are sequences separated by non-alphanumeric characters. + +- `bloom_filter([false_positive])` — Stores a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) for the specified columns. + + The optional `false_positive` parameter is the probability of receiving a false positive response from the filter. Possible values: (0, 1). Default value: 0.025. + + Supported data types: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. + + The following functions can use it: [equals](../../../sql-reference/functions/comparison-functions.md), [notEquals](../../../sql-reference/functions/comparison-functions.md), [in](../../../sql-reference/functions/in-functions.md), [notIn](../../../sql-reference/functions/in-functions.md), [has](../../../sql-reference/functions/array-functions.md). + + + +``` sql +INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 +INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 +INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 +``` + +#### Functions Support {#functions-support} + +Conditions in the `WHERE` clause contains calls of the functions that operate with columns. If the column is a part of an index, ClickHouse tries to use this index when performing the functions. ClickHouse supports different subsets of functions for using indexes. + +The `set` index can be used with all functions. Function subsets for other indexes are shown in the table below. + +| Function (operator) / Index | primary key | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | +|------------------------------------------------------------------------------------------------------------|-------------|--------|-------------|-------------|---------------| +| [equals (=, ==)](../../../sql-reference/functions/comparison-functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notEquals(!=, \<\>)](../../../sql-reference/functions/comparison-functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [like](../../../sql-reference/functions/string-search-functions.md#function-like) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notLike](../../../sql-reference/functions/string-search-functions.md#function-notlike) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [startsWith](../../../sql-reference/functions/string-functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | +| [endsWith](../../../sql-reference/functions/string-functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | +| [multiSearchAny](../../../sql-reference/functions/string-search-functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | +| [in](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notIn](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [less (\<)](../../../sql-reference/functions/comparison-functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [greater (\>)](../../../sql-reference/functions/comparison-functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [lessOrEquals (\<=)](../../../sql-reference/functions/comparison-functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [greaterOrEquals (\>=)](../../../sql-reference/functions/comparison-functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [empty](../../../sql-reference/functions/array-functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [notEmpty](../../../sql-reference/functions/array-functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | + +Functions with a constant argument that is less than ngram size can’t be used by `ngrambf_v1` for query optimization. + +!!! note "Note" + Bloom filters can have false positive matches, so the `ngrambf_v1`, `tokenbf_v1`, and `bloom_filter` indexes can’t be used for optimizing queries where the result of a function is expected to be false, for example: + +- Can be optimized: + - `s LIKE '%test%'` + - `NOT s NOT LIKE '%test%'` + - `s = 1` + - `NOT s != 1` + - `startsWith(s, 'test')` +- Can’t be optimized: + - `NOT s LIKE '%test%'` + - `s NOT LIKE '%test%'` + - `NOT s = 1` + - `s != 1` + - `NOT startsWith(s, 'test')` + +## Concurrent Data Access {#concurrent-data-access} + +For concurrent table access, we use multi-versioning. In other words, when a table is simultaneously read and updated, data is read from a set of parts that is current at the time of the query. There are no lengthy locks. Inserts do not get in the way of read operations. + +Reading from a table is automatically parallelized. + +## TTL for Columns and Tables {#table_engine-mergetree-ttl} + +Determines the lifetime of values. + +The `TTL` clause can be set for the whole table and for each individual column. Table-level TTL can also specify logic of automatic move of data between disks and volumes. + +Expressions must evaluate to [Date](../../../sql-reference/data-types/date.md) or [DateTime](../../../sql-reference/data-types/datetime.md) data type. + +Example: + +``` sql +TTL time_column +TTL time_column + interval +``` + +To define `interval`, use [time interval](../../../sql-reference/operators/index.md#operators-datetime) operators. + +``` sql +TTL date_time + INTERVAL 1 MONTH +TTL date_time + INTERVAL 15 HOUR +``` + +### Column TTL {#mergetree-column-ttl} + +When the values in the column expire, ClickHouse replaces them with the default values for the column data type. If all the column values in the data part expire, ClickHouse deletes this column from the data part in a filesystem. + +The `TTL` clause can’t be used for key columns. + +Examples: + +Creating a table with TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int TTL d + INTERVAL 1 MONTH, + b Int TTL d + INTERVAL 1 MONTH, + c String +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d; +``` + +Adding TTL to a column of an existing table + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 DAY; +``` + +Altering TTL of the column + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 MONTH; +``` + +### Table TTL {#mergetree-table-ttl} + +Table can have an expression for removal of expired rows, and multiple expressions for automatic move of parts between [disks or volumes](#table_engine-mergetree-multiple-volumes). When rows in the table expire, ClickHouse deletes all corresponding rows. For parts moving feature, all rows of a part must satisfy the movement expression criteria. + +``` sql +TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... +``` + +Type of TTL rule may follow each TTL expression. It affects an action which is to be done once the expression is satisfied (reaches current time): + +- `DELETE` - delete expired rows (default action); +- `TO DISK 'aaa'` - move part to the disk `aaa`; +- `TO VOLUME 'bbb'` - move part to the disk `bbb`. + +Examples: + +Creating a table with TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d +TTL d + INTERVAL 1 MONTH [DELETE], + d + INTERVAL 1 WEEK TO VOLUME 'aaa', + d + INTERVAL 2 WEEK TO DISK 'bbb'; +``` + +Altering TTL of the table + +``` sql +ALTER TABLE example_table + MODIFY TTL d + INTERVAL 1 DAY; +``` + +**Removing Data** + +Data with an expired TTL is removed when ClickHouse merges data parts. + +When ClickHouse see that data is expired, it performs an off-schedule merge. To control the frequency of such merges, you can set `merge_with_ttl_timeout`. If the value is too low, it will perform many off-schedule merges that may consume a lot of resources. + +If you perform the `SELECT` query between merges, you may get expired data. To avoid it, use the [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) query before `SELECT`. + +## Using Multiple Block Devices for Data Storage {#table_engine-mergetree-multiple-volumes} + +### Introduction {#introduction} + +`MergeTree` family table engines can store data on multiple block devices. For example, it can be useful when the data of a certain table are implicitly split into “hot” and “cold”. The most recent data is regularly requested but requires only a small amount of space. On the contrary, the fat-tailed historical data is requested rarely. If several disks are available, the “hot” data may be located on fast disks (for example, NVMe SSDs or in memory), while the “cold” data - on relatively slow ones (for example, HDD). + +Data part is the minimum movable unit for `MergeTree`-engine tables. The data belonging to one part are stored on one disk. Data parts can be moved between disks in the background (according to user settings) as well as by means of the [ALTER](../../../sql-reference/statements/alter.md#alter_move-partition) queries. + +### Terms {#terms} + +- Disk — Block device mounted to the filesystem. +- Default disk — Disk that stores the path specified in the [path](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path) server setting. +- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). +- Storage policy — Set of volumes and the rules for moving data between them. + +The names given to the described entities can be found in the system tables, [system.storage\_policies](../../../operations/system-tables.md#system_tables-storage_policies) and [system.disks](../../../operations/system-tables.md#system_tables-disks). To apply one of the configured storage policies for a table, use the `storage_policy` setting of `MergeTree`-engine family tables. + +### Configuration {#table_engine-mergetree-multiple-volumes_configure} + +Disks, volumes and storage policies should be declared inside the `` tag either in the main file `config.xml` or in a distinct file in the `config.d` directory. + +Configuration structure: + +``` xml + + + + /mnt/fast_ssd/clickhouse/ + + + /mnt/hdd1/clickhouse/ + 10485760 + + + /mnt/hdd2/clickhouse/ + 10485760 + + + ... + + + ... + +``` + +Tags: + +- `` — Disk name. Names must be different for all disks. +- `path` — path under which a server will store data (`data` and `shadow` folders), should be terminated with ‘/’. +- `keep_free_space_bytes` — the amount of free disk space to be reserved. + +The order of the disk definition is not important. + +Storage policies configuration markup: + +``` xml + + ... + + + + + disk_name_from_disks_configuration + 1073741824 + + + + + + + 0.2 + + + + + + + + ... + +``` + +Tags: + +- `policy_name_N` — Policy name. Policy names must be unique. +- `volume_name_N` — Volume name. Volume names must be unique. +- `disk` — a disk within a volume. +- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume’s disks. +- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). + +Cofiguration examples: + +``` xml + + ... + + + + + disk1 + disk2 + + + + + + + + fast_ssd + 1073741824 + + + disk1 + + + 0.2 + + + ... + +``` + +In given example, the `hdd_in_order` policy implements the [round-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) approach. Thus this policy defines only one volume (`single`), the data parts are stored on all its disks in circular order. Such policy can be quite useful if there are several similar disks are mounted to the system, but RAID is not configured. Keep in mind that each individual disk drive is not reliable and you might want to compensate it with replication factor of 3 or more. + +If there are different kinds of disks available in the system, `moving_from_ssd_to_hdd` policy can be used instead. The volume `hot` consists of an SSD disk (`fast_ssd`), and the maximum size of a part that can be stored on this volume is 1GB. All the parts with the size larger than 1GB will be stored directly on the `cold` volume, which contains an HDD disk `disk1`. +Also, once the disk `fast_ssd` gets filled by more than 80%, data will be transferred to the `disk1` by a background process. + +The order of volume enumeration within a storage policy is important. Once a volume is overfilled, data are moved to the next one. The order of disk enumeration is important as well because data are stored on them in turns. + +When creating a table, one can apply one of the configured storage policies to it: + +``` sql +CREATE TABLE table_with_non_default_policy ( + EventDate Date, + OrderID UInt64, + BannerID UInt64, + SearchPhrase String +) ENGINE = MergeTree +ORDER BY (OrderID, BannerID) +PARTITION BY toYYYYMM(EventDate) +SETTINGS storage_policy = 'moving_from_ssd_to_hdd' +``` + +The `default` storage policy implies using only one volume, which consists of only one disk given in ``. Once a table is created, its storage policy cannot be changed. + +The number of threads performing background moves of data parts can be changed by [background_move_pool_size](../../../operations/settings/settings.md#background_move_pool_size) setting. + +### Details {#details} + +In the case of `MergeTree` tables, data is getting to disk in different ways: + +- As a result of an insert (`INSERT` query). +- During background merges and [mutations](../../../sql-reference/statements/alter.md#alter-mutations). +- When downloading from another replica. +- As a result of partition freezing [ALTER TABLE … FREEZE PARTITION](../../../sql-reference/statements/alter.md#alter_freeze-partition). + +In all these cases except for mutations and partition freezing, a part is stored on a volume and a disk according to the given storage policy: + +1. The first volume (in the order of definition) that has enough disk space for storing a part (`unreserved_space > current_part_size`) and allows for storing parts of a given size (`max_data_part_size_bytes > current_part_size`) is chosen. +2. Within this volume, that disk is chosen that follows the one, which was used for storing the previous chunk of data, and that has free space more than the part size (`unreserved_space - keep_free_space_bytes > current_part_size`). + +Under the hood, mutations and partition freezing make use of [hard links](https://en.wikipedia.org/wiki/Hard_link). Hard links between different disks are not supported, therefore in such cases the resulting parts are stored on the same disks as the initial ones. + +In the background, parts are moved between volumes on the basis of the amount of free space (`move_factor` parameter) according to the order the volumes are declared in the configuration file. +Data is never transferred from the last one and into the first one. One may use system tables [system.part\_log](../../../operations/system-tables.md#system_tables-part-log) (field `type = MOVE_PART`) and [system.parts](../../../operations/system-tables.md#system_tables-parts) (fields `path` and `disk`) to monitor background moves. Also, the detailed information can be found in server logs. + +User can force moving a part or a partition from one volume to another using the query [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql-reference/statements/alter.md#alter_move-partition), all the restrictions for background operations are taken into account. The query initiates a move on its own and does not wait for background operations to be completed. User will get an error message if not enough free space is available or if any of the required conditions are not met. + +Moving data does not interfere with data replication. Therefore, different storage policies can be specified for the same table on different replicas. + +After the completion of background merges and mutations, old parts are removed only after a certain amount of time (`old_parts_lifetime`). +During this time, they are not moved to other volumes or disks. Therefore, until the parts are finally removed, they are still taken into account for evaluation of the occupied disk space. + +[Original article](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/en/engines/table-engines/mergetree-family/replacingmergetree.md b/docs/en/engines/table-engines/mergetree-family/replacingmergetree.md new file mode 100644 index 00000000000..6ca8be1912e --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/replacingmergetree.md @@ -0,0 +1,67 @@ +--- +toc_priority: 33 +toc_title: ReplacingMergeTree +--- + +# ReplacingMergeTree {#replacingmergetree} + +The engine differs from [MergeTree](mergetree.md#table_engines-mergetree) in that it removes duplicate entries with the same primary key value (or more accurately, with the same [sorting key](mergetree.md) value). + +Data deduplication occurs only during a merge. Merging occurs in the background at an unknown time, so you can’t plan for it. Some of the data may remain unprocessed. Although you can run an unscheduled merge using the `OPTIMIZE` query, don’t count on using it, because the `OPTIMIZE` query will read and write a large amount of data. + +Thus, `ReplacingMergeTree` is suitable for clearing out duplicate data in the background in order to save space, but it doesn’t guarantee the absence of duplicates. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = ReplacingMergeTree([ver]) +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +For a description of request parameters, see [request description](../../../sql-reference/statements/create.md). + +**ReplacingMergeTree Parameters** + +- `ver` — column with version. Type `UInt*`, `Date` or `DateTime`. Optional parameter. + + When merging, `ReplacingMergeTree` from all the rows with the same primary key leaves only one: + + - Last in the selection, if `ver` not set. + - With the maximum version, if `ver` specified. + +**Query clauses** + +When creating a `ReplacingMergeTree` table the same [clauses](mergetree.md) are required, as when creating a `MergeTree` table. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects and, if possible, switch the old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) +``` + +All of the parameters excepting `ver` have the same meaning as in `MergeTree`. + +- `ver` - column with the version. Optional parameter. For a description, see the text above. + +
+ +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/en/engines/table-engines/mergetree-family/replication.md b/docs/en/engines/table-engines/mergetree-family/replication.md new file mode 100644 index 00000000000..aa4e2e87d95 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/replication.md @@ -0,0 +1,222 @@ +--- +toc_priority: 31 +toc_title: Data Replication +--- + +# Data Replication {#table_engines-replication} + +Replication is only supported for tables in the MergeTree family: + +- ReplicatedMergeTree +- ReplicatedSummingMergeTree +- ReplicatedReplacingMergeTree +- ReplicatedAggregatingMergeTree +- ReplicatedCollapsingMergeTree +- ReplicatedVersionedCollapsingMergeTree +- ReplicatedGraphiteMergeTree + +Replication works at the level of an individual table, not the entire server. A server can store both replicated and non-replicated tables at the same time. + +Replication does not depend on sharding. Each shard has its own independent replication. + +Compressed data for `INSERT` and `ALTER` queries is replicated (for more information, see the documentation for [ALTER](../../../sql-reference/statements/alter.md#query_language_queries_alter)). + +`CREATE`, `DROP`, `ATTACH`, `DETACH` and `RENAME` queries are executed on a single server and are not replicated: + +- The `CREATE TABLE` query creates a new replicatable table on the server where the query is run. If this table already exists on other servers, it adds a new replica. +- The `DROP TABLE` query deletes the replica located on the server where the query is run. +- The `RENAME` query renames the table on one of the replicas. In other words, replicated tables can have different names on different replicas. + +ClickHouse uses [Apache ZooKeeper](https://zookeeper.apache.org) for storing replicas meta information. Use ZooKeeper version 3.4.5 or newer. + +To use replication, set parameters in the [zookeeper](../../../operations/server-configuration-parameters/settings.md#server-settings_zookeeper) server configuration section. + +!!! attention "Attention" + Don’t neglect the security setting. ClickHouse supports the `digest` [ACL scheme](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) of the ZooKeeper security subsystem. + +Example of setting the addresses of the ZooKeeper cluster: + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + + example3 + 2181 + + +``` + +You can specify any existing ZooKeeper cluster and the system will use a directory on it for its own data (the directory is specified when creating a replicatable table). + +If ZooKeeper isn’t set in the config file, you can’t create replicated tables, and any existing replicated tables will be read-only. + +ZooKeeper is not used in `SELECT` queries because replication does not affect the performance of `SELECT` and queries run just as fast as they do for non-replicated tables. When querying distributed replicated tables, ClickHouse behavior is controlled by the settings [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) and [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). + +For each `INSERT` query, approximately ten entries are added to ZooKeeper through several transactions. (To be more precise, this is for each inserted block of data; an INSERT query contains one block or one block per `max_insert_block_size = 1048576` rows.) This leads to slightly longer latencies for `INSERT` compared to non-replicated tables. But if you follow the recommendations to insert data in batches of no more than one `INSERT` per second, it doesn’t create any problems. The entire ClickHouse cluster used for coordinating one ZooKeeper cluster has a total of several hundred `INSERTs` per second. The throughput on data inserts (the number of rows per second) is just as high as for non-replicated data. + +For very large clusters, you can use different ZooKeeper clusters for different shards. However, this hasn’t proven necessary on the Yandex.Metrica cluster (approximately 300 servers). + +Replication is asynchronous and multi-master. `INSERT` queries (as well as `ALTER`) can be sent to any available server. Data is inserted on the server where the query is run, and then it is copied to the other servers. Because it is asynchronous, recently inserted data appears on the other replicas with some latency. If part of the replicas are not available, the data is written when they become available. If a replica is available, the latency is the amount of time it takes to transfer the block of compressed data over the network. The number of threads performing background tasks for replicated tables can be set by [background_schedule_pool_size](../../../operations/settings/settings.md#background_schedule_pool_size) setting. + +By default, an INSERT query waits for confirmation of writing the data from only one replica. If the data was successfully written to only one replica and the server with this replica ceases to exist, the stored data will be lost. To enable getting confirmation of data writes from multiple replicas, use the `insert_quorum` option. + +Each block of data is written atomically. The INSERT query is divided into blocks up to `max_insert_block_size = 1048576` rows. In other words, if the `INSERT` query has less than 1048576 rows, it is made atomically. + +Data blocks are deduplicated. For multiple writes of the same data block (data blocks of the same size containing the same rows in the same order), the block is only written once. The reason for this is in case of network failures when the client application doesn’t know if the data was written to the DB, so the `INSERT` query can simply be repeated. It doesn’t matter which replica INSERTs were sent to with identical data. `INSERTs` are idempotent. Deduplication parameters are controlled by [merge\_tree](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree) server settings. + +During replication, only the source data to insert is transferred over the network. Further data transformation (merging) is coordinated and performed on all the replicas in the same way. This minimizes network usage, which means that replication works well when replicas reside in different datacenters. (Note that duplicating data in different datacenters is the main goal of replication.) + +You can have any number of replicas of the same data. Yandex.Metrica uses double replication in production. Each server uses RAID-5 or RAID-6, and RAID-10 in some cases. This is a relatively reliable and convenient solution. + +The system monitors data synchronicity on replicas and is able to recover after a failure. Failover is automatic (for small differences in data) or semi-automatic (when data differs too much, which may indicate a configuration error). + +## Creating Replicated Tables {#creating-replicated-tables} + +The `Replicated` prefix is added to the table engine name. For example:`ReplicatedMergeTree`. + +**Replicated\*MergeTree parameters** + +- `zoo_path` — The path to the table in ZooKeeper. +- `replica_name` — The replica name in ZooKeeper. +- `other_parameters` — Parameters of an engine which is used for creating the replicated version, for example, version in `ReplacingMergeTree`. + +Example: + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32, + ver UInt16 +) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', ver) +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +``` + +
+ +Example in deprecated syntax + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) +``` + +
+ +As the example shows, these parameters can contain substitutions in curly brackets. The substituted values are taken from the ‘macros’ section of the configuration file. Example: + +``` xml + + 05 + 02 + example05-02-1.yandex.ru + +``` + +The path to the table in ZooKeeper should be unique for each replicated table. Tables on different shards should have different paths. +In this case, the path consists of the following parts: + +`/clickhouse/tables/` is the common prefix. We recommend using exactly this one. + +`{layer}-{shard}` is the shard identifier. In this example it consists of two parts, since the Yandex.Metrica cluster uses bi-level sharding. For most tasks, you can leave just the {shard} substitution, which will be expanded to the shard identifier. + +`table_name` is the name of the node for the table in ZooKeeper. It is a good idea to make it the same as the table name. It is defined explicitly, because in contrast to the table name, it doesn’t change after a RENAME query. +*HINT*: you could add a database name in front of `table_name` as well. E.g. `db_name.table_name` + +The replica name identifies different replicas of the same table. You can use the server name for this, as in the example. The name only needs to be unique within each shard. + +You can define the parameters explicitly instead of using substitutions. This might be convenient for testing and for configuring small clusters. However, you can’t use distributed DDL queries (`ON CLUSTER`) in this case. + +When working with large clusters, we recommend using substitutions because they reduce the probability of error. + +Run the `CREATE TABLE` query on each replica. This query creates a new replicated table, or adds a new replica to an existing one. + +If you add a new replica after the table already contains some data on other replicas, the data will be copied from the other replicas to the new one after running the query. In other words, the new replica syncs itself with the others. + +To delete a replica, run `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. + +## Recovery After Failures {#recovery-after-failures} + +If ZooKeeper is unavailable when a server starts, replicated tables switch to read-only mode. The system periodically attempts to connect to ZooKeeper. + +If ZooKeeper is unavailable during an `INSERT`, or an error occurs when interacting with ZooKeeper, an exception is thrown. + +After connecting to ZooKeeper, the system checks whether the set of data in the local file system matches the expected set of data (ZooKeeper stores this information). If there are minor inconsistencies, the system resolves them by syncing data with the replicas. + +If the system detects broken data parts (with the wrong size of files) or unrecognized parts (parts written to the file system but not recorded in ZooKeeper), it moves them to the `detached` subdirectory (they are not deleted). Any missing parts are copied from the replicas. + +Note that ClickHouse does not perform any destructive actions such as automatically deleting a large amount of data. + +When the server starts (or establishes a new session with ZooKeeper), it only checks the quantity and sizes of all files. If the file sizes match but bytes have been changed somewhere in the middle, this is not detected immediately, but only when attempting to read the data for a `SELECT` query. The query throws an exception about a non-matching checksum or size of a compressed block. In this case, data parts are added to the verification queue and copied from the replicas if necessary. + +If the local set of data differs too much from the expected one, a safety mechanism is triggered. The server enters this in the log and refuses to launch. The reason for this is that this case may indicate a configuration error, such as if a replica on a shard was accidentally configured like a replica on a different shard. However, the thresholds for this mechanism are set fairly low, and this situation might occur during normal failure recovery. In this case, data is restored semi-automatically - by “pushing a button”. + +To start recovery, create the node `/path_to_table/replica_name/flags/force_restore_data` in ZooKeeper with any content, or run the command to restore all replicated tables: + +``` bash +sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data +``` + +Then restart the server. On start, the server deletes these flags and starts recovery. + +## Recovery After Complete Data Loss {#recovery-after-complete-data-loss} + +If all data and metadata disappeared from one of the servers, follow these steps for recovery: + +1. Install ClickHouse on the server. Define substitutions correctly in the config file that contains the shard identifier and replicas, if you use them. +2. If you had unreplicated tables that must be manually duplicated on the servers, copy their data from a replica (in the directory `/var/lib/clickhouse/data/db_name/table_name/`). +3. Copy table definitions located in `/var/lib/clickhouse/metadata/` from a replica. If a shard or replica identifier is defined explicitly in the table definitions, correct it so that it corresponds to this replica. (Alternatively, start the server and make all the `ATTACH TABLE` queries that should have been in the .sql files in `/var/lib/clickhouse/metadata/`.) +4. To start recovery, create the ZooKeeper node `/path_to_table/replica_name/flags/force_restore_data` with any content, or run the command to restore all replicated tables: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` + +Then start the server (restart, if it is already running). Data will be downloaded from replicas. + +An alternative recovery option is to delete information about the lost replica from ZooKeeper (`/path_to_table/replica_name`), then create the replica again as described in “[Creating replicated tables](#creating-replicated-tables)”. + +There is no restriction on network bandwidth during recovery. Keep this in mind if you are restoring many replicas at once. + +## Converting from MergeTree to ReplicatedMergeTree {#converting-from-mergetree-to-replicatedmergetree} + +We use the term `MergeTree` to refer to all table engines in the `MergeTree family`, the same as for `ReplicatedMergeTree`. + +If you had a `MergeTree` table that was manually replicated, you can convert it to a replicated table. You might need to do this if you have already collected a large amount of data in a `MergeTree` table and now you want to enable replication. + +If the data differs on various replicas, first sync it, or delete this data on all the replicas except one. + +Rename the existing MergeTree table, then create a `ReplicatedMergeTree` table with the old name. +Move the data from the old table to the `detached` subdirectory inside the directory with the new table data (`/var/lib/clickhouse/data/db_name/table_name/`). +Then run `ALTER TABLE ATTACH PARTITION` on one of the replicas to add these data parts to the working set. + +## Converting from ReplicatedMergeTree to MergeTree {#converting-from-replicatedmergetree-to-mergetree} + +Create a MergeTree table with a different name. Move all the data from the directory with the `ReplicatedMergeTree` table data to the new table’s data directory. Then delete the `ReplicatedMergeTree` table and restart the server. + +If you want to get rid of a `ReplicatedMergeTree` table without launching the server: + +- Delete the corresponding `.sql` file in the metadata directory (`/var/lib/clickhouse/metadata/`). +- Delete the corresponding path in ZooKeeper (`/path_to_table/replica_name`). + +After this, you can launch the server, create a `MergeTree` table, move the data to its directory, and then restart the server. + +## Recovery When Metadata in the Zookeeper Cluster Is Lost or Damaged {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} + +If the data in ZooKeeper was lost or damaged, you can save data by moving it to an unreplicated table as described above. + +**See also** + +- [background_schedule_pool_size](../../../operations/settings/settings.md#background_schedule_pool_size) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/en/engines/table-engines/mergetree-family/summingmergetree.md b/docs/en/engines/table-engines/mergetree-family/summingmergetree.md new file mode 100644 index 00000000000..53c76044051 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/summingmergetree.md @@ -0,0 +1,139 @@ +--- +toc_priority: 34 +toc_title: SummingMergeTree +--- + +# SummingMergeTree {#summingmergetree} + +The engine inherits from [MergeTree](mergetree.md#table_engines-mergetree). The difference is that when merging data parts for `SummingMergeTree` tables ClickHouse replaces all the rows with the same primary key (or more accurately, with the same [sorting key](mergetree.md)) with one row which contains summarized values for the columns with the numeric data type. If the sorting key is composed in a way that a single key value corresponds to large number of rows, this significantly reduces storage volume and speeds up data selection. + +We recommend to use the engine together with `MergeTree`. Store complete data in `MergeTree` table, and use `SummingMergeTree` for aggregated data storing, for example, when preparing reports. Such an approach will prevent you from losing valuable data due to an incorrectly composed primary key. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = SummingMergeTree([columns]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +For a description of request parameters, see [request description](../../../sql-reference/statements/create.md). + +**Parameters of SummingMergeTree** + +- `columns` - a tuple with the names of columns where values will be summarized. Optional parameter. + The columns must be of a numeric type and must not be in the primary key. + + If `columns` not specified, ClickHouse summarizes the values in all columns with a numeric data type that are not in the primary key. + +**Query clauses** + +When creating a `SummingMergeTree` table the same [clauses](mergetree.md) are required, as when creating a `MergeTree` table. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects and, if possible, switch the old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) +``` + +All of the parameters excepting `columns` have the same meaning as in `MergeTree`. + +- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. + +
+ +## Usage Example {#usage-example} + +Consider the following table: + +``` sql +CREATE TABLE summtt +( + key UInt32, + value UInt32 +) +ENGINE = SummingMergeTree() +ORDER BY key +``` + +Insert data to it: + +``` sql +INSERT INTO summtt Values(1,1),(1,2),(2,1) +``` + +ClickHouse may sum all the rows not completely ([see below](#data-processing)), so we use an aggregate function `sum` and `GROUP BY` clause in the query. + +``` sql +SELECT key, sum(value) FROM summtt GROUP BY key +``` + +``` text +┌─key─┬─sum(value)─┐ +│ 2 │ 1 │ +│ 1 │ 3 │ +└─────┴────────────┘ +``` + +## Data Processing {#data-processing} + +When data are inserted into a table, they are saved as-is. ClickHouse merges the inserted parts of data periodically and this is when rows with the same primary key are summed and replaced with one for each resulting part of data. + +ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) an aggregate function [sum()](../../../sql-reference/aggregate-functions/reference.md#agg_function-sum) and `GROUP BY` clause should be used in a query as described in the example above. + +### Common Rules for Summation {#common-rules-for-summation} + +The values in the columns with the numeric data type are summarized. The set of columns is defined by the parameter `columns`. + +If the values were 0 in all of the columns for summation, the row is deleted. + +If column is not in the primary key and is not summarized, an arbitrary value is selected from the existing ones. + +The values are not summarized for columns in the primary key. + +### The Summation in the Aggregatefunction Columns {#the-summation-in-the-aggregatefunction-columns} + +For columns of [AggregateFunction type](../../../sql-reference/data-types/aggregatefunction.md) ClickHouse behaves as [AggregatingMergeTree](aggregatingmergetree.md) engine aggregating according to the function. + +### Nested Structures {#nested-structures} + +Table can have nested data structures that are processed in a special way. + +If the name of a nested table ends with `Map` and it contains at least two columns that meet the following criteria: + +- the first column is numeric `(*Int*, Date, DateTime)` or a string `(String, FixedString)`, let’s call it `key`, +- the other columns are arithmetic `(*Int*, Float32/64)`, let’s call it `(values...)`, + +then this nested table is interpreted as a mapping of `key => (values...)`, and when merging its rows, the elements of two data sets are merged by `key` with a summation of the corresponding `(values...)`. + +Examples: + +``` text +[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] +[(1, 100)] + [(1, 150)] -> [(1, 250)] +[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] +[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] +``` + +When requesting data, use the [sumMap(key, value)](../../../sql-reference/aggregate-functions/reference.md) function for aggregation of `Map`. + +For nested data structure, you do not need to specify its columns in the tuple of columns for summation. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/en/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md b/docs/en/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md new file mode 100644 index 00000000000..c9e1da3d454 --- /dev/null +++ b/docs/en/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md @@ -0,0 +1,236 @@ +--- +toc_priority: 37 +toc_title: VersionedCollapsingMergeTree +--- + +# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} + +This engine: + +- Allows quick writing of object states that are continually changing. +- Deletes old object states in the background. This significantly reduces the volume of storage. + +See the section [Collapsing](#table_engines_versionedcollapsingmergetree) for details. + +The engine inherits from [MergeTree](mergetree.md#table_engines-mergetree) and adds the logic for collapsing rows to the algorithm for merging data parts. `VersionedCollapsingMergeTree` serves the same purpose as [CollapsingMergeTree](collapsingmergetree.md) but uses a different collapsing algorithm that allows inserting the data in any order with multiple threads. In particular, the `Version` column helps to collapse the rows properly even if they are inserted in the wrong order. In contrast, `CollapsingMergeTree` allows only strictly consecutive insertion. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = VersionedCollapsingMergeTree(sign, version) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +For a description of query parameters, see the [query description](../../../sql-reference/statements/create.md). + +**Engine Parameters** + +``` sql +VersionedCollapsingMergeTree(sign, version) +``` + +- `sign` — Name of the column with the type of row: `1` is a “state” row, `-1` is a “cancel” row. + + The column data type should be `Int8`. + +- `version` — Name of the column with the version of the object state. + + The column data type should be `UInt*`. + +**Query Clauses** + +When creating a `VersionedCollapsingMergeTree` table, the same [clauses](mergetree.md) are required as when creating a `MergeTree` table. + +
+ +Deprecated Method for Creating a Table + +!!! attention "Attention" + Do not use this method in new projects. If possible, switch the old projects to the method described above. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] VersionedCollapsingMergeTree(date-column [, samp#table_engines_versionedcollapsingmergetreeling_expression], (primary, key), index_granularity, sign, version) +``` + +All of the parameters except `sign` and `version` have the same meaning as in `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` is a “state” row, `-1` is a “cancel” row. + + Column Data Type — `Int8`. + +- `version` — Name of the column with the version of the object state. + + The column data type should be `UInt*`. + +
+ +## Collapsing {#table_engines_versionedcollapsingmergetree} + +### Data {#data} + +Consider a situation where you need to save continually changing data for some object. It is reasonable to have one row for an object and update the row whenever there are changes. However, the update operation is expensive and slow for a DBMS because it requires rewriting the data in the storage. Update is not acceptable if you need to write data quickly, but you can write the changes to an object sequentially as follows. + +Use the `Sign` column when writing the row. If `Sign = 1` it means that the row is a state of an object (let’s call it the “state” row). If `Sign = -1` it indicates the cancellation of the state of an object with the same attributes (let’s call it the “cancel” row). Also use the `Version` column, which should identify each state of an object with a separate number. + +For example, we want to calculate how many pages users visited on some site and how long they were there. At some point in time we write the following row with the state of user activity: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +At some point later we register the change of user activity and write it with the following two rows. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +The first row cancels the previous state of the object (user). It should copy all of the fields of the canceled state except `Sign`. + +The second row contains the current state. + +Because we need only the last state of user activity, the rows + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +can be deleted, collapsing the invalid (old) state of the object. `VersionedCollapsingMergeTree` does this while merging the data parts. + +To find out why we need two rows for each change, see [Algorithm](#table_engines-versionedcollapsingmergetree-algorithm). + +**Notes on Usage** + +1. The program that writes the data should remember the state of an object in order to cancel it. The “cancel” string should be a copy of the “state” string with the opposite `Sign`. This increases the initial size of storage but allows to write the data quickly. +2. Long growing arrays in columns reduce the efficiency of the engine due to the load for writing. The more straightforward the data, the better the efficiency. +3. `SELECT` results depend strongly on the consistency of the history of object changes. Be accurate when preparing data for inserting. You can get unpredictable results with inconsistent data, such as negative values for non-negative metrics like session depth. + +### Algorithm {#table_engines-versionedcollapsingmergetree-algorithm} + +When ClickHouse merges data parts, it deletes each pair of rows that have the same primary key and version and different `Sign`. The order of rows does not matter. + +When ClickHouse inserts data, it orders rows by the primary key. If the `Version` column is not in the primary key, ClickHouse adds it to the primary key implicitly as the last field and uses it for ordering. + +## Selecting Data {#selecting-data} + +ClickHouse doesn’t guarantee that all of the rows with the same primary key will be in the same resulting data part or even on the same physical server. This is true both for writing the data and for subsequent merging of the data parts. In addition, ClickHouse processes `SELECT` queries with multiple threads, and it cannot predict the order of rows in the result. This means that aggregation is required if there is a need to get completely “collapsed” data from a `VersionedCollapsingMergeTree` table. + +To finalize collapsing, write a query with a `GROUP BY` clause and aggregate functions that account for the sign. For example, to calculate quantity, use `sum(Sign)` instead of `count()`. To calculate the sum of something, use `sum(Sign * x)` instead of `sum(x)`, and add `HAVING sum(Sign) > 0`. + +The aggregates `count`, `sum` and `avg` can be calculated this way. The aggregate `uniq` can be calculated if an object has at least one non-collapsed state. The aggregates `min` and `max` can’t be calculated because `VersionedCollapsingMergeTree` does not save the history of values of collapsed states. + +If you need to extract the data with “collapsing” but without aggregation (for example, to check whether rows are present whose newest values match certain conditions), you can use the `FINAL` modifier for the `FROM` clause. This approach is inefficient and should not be used with large tables. + +## Example of Use {#example-of-use} + +Example data: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Creating the table: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8, + Version UInt8 +) +ENGINE = VersionedCollapsingMergeTree(Sign, Version) +ORDER BY UserID +``` + +Inserting the data: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) +``` + +We use two `INSERT` queries to create two different data parts. If we insert the data with a single query, ClickHouse creates one data part and will never perform any merge. + +Getting the data: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +What do we see here and where are the collapsed parts? +We created two data parts using two `INSERT` queries. The `SELECT` query was performed in two threads, and the result is a random order of rows. +Collapsing did not occur because the data parts have not been merged yet. ClickHouse merges data parts at an unknown point in time which we cannot predict. + +This is why we need aggregation: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration, + Version +FROM UAct +GROUP BY UserID, Version +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 2 │ +└─────────────────────┴───────────┴──────────┴─────────┘ +``` + +If we don’t need aggregation and want to force collapsing, we can use the `FINAL` modifier for the `FROM` clause. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +This is a very inefficient way to select data. Don’t use it for large tables. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/en/engines/table-engines/special/buffer.md b/docs/en/engines/table-engines/special/buffer.md new file mode 100644 index 00000000000..bf6c08f8f6c --- /dev/null +++ b/docs/en/engines/table-engines/special/buffer.md @@ -0,0 +1,69 @@ +--- +toc_priority: 45 +toc_title: Buffer +--- + +# Buffer Table Engine {#buffer} + +Buffers the data to write in RAM, periodically flushing it to another table. During the read operation, data is read from the buffer and the other table simultaneously. + +``` sql +Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) +``` + +Engine parameters: + +- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. +- `table` – Table to flush data to. +- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` of independent buffers. Recommended value: 16. +- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, and `max_bytes` – Conditions for flushing data from the buffer. + +Data is flushed from the buffer and written to the destination table if all the `min*` conditions or at least one `max*` condition are met. + +- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. +- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. +- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. + +During the write operation, data is inserted to a `num_layers` number of random buffers. Or, if the data part to insert is large enough (greater than `max_rows` or `max_bytes`), it is written directly to the destination table, omitting the buffer. + +The conditions for flushing the data are calculated separately for each of the `num_layers` buffers. For example, if `num_layers = 16` and `max_bytes = 100000000`, the maximum RAM consumption is 1.6 GB. + +Example: + +``` sql +CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) +``` + +Creating a `merge.hits_buffer` table with the same structure as `merge.hits` and using the Buffer engine. When writing to this table, data is buffered in RAM and later written to the ‘merge.hits’ table. 16 buffers are created. The data in each of them is flushed if either 100 seconds have passed, or one million rows have been written, or 100 MB of data have been written; or if simultaneously 10 seconds have passed and 10,000 rows and 10 MB of data have been written. For example, if just one row has been written, after 100 seconds it will be flushed, no matter what. But if many rows have been written, the data will be flushed sooner. + +When the server is stopped, with `DROP TABLE` or `DETACH TABLE`, buffer data is also flushed to the destination table. + +You can set empty strings in single quotation marks for the database and table name. This indicates the absence of a destination table. In this case, when the data flush conditions are reached, the buffer is simply cleared. This may be useful for keeping a window of data in memory. + +When reading from a Buffer table, data is processed both from the buffer and from the destination table (if there is one). +Note that the Buffer tables does not support an index. In other words, data in the buffer is fully scanned, which might be slow for large buffers. (For data in a subordinate table, the index that it supports will be used.) + +If the set of columns in the Buffer table doesn’t match the set of columns in a subordinate table, a subset of columns that exist in both tables is inserted. + +If the types don’t match for one of the columns in the Buffer table and a subordinate table, an error message is entered in the server log and the buffer is cleared. +The same thing happens if the subordinate table doesn’t exist when the buffer is flushed. + +If you need to run ALTER for a subordinate table and the Buffer table, we recommend first deleting the Buffer table, running ALTER for the subordinate table, then creating the Buffer table again. + +If the server is restarted abnormally, the data in the buffer is lost. + +`FINAL` and `SAMPLE` do not work correctly for Buffer tables. These conditions are passed to the destination table, but are not used for processing data in the buffer. If these features are required we recommend only using the Buffer table for writing, while reading from the destination table. + +When adding data to a Buffer, one of the buffers is locked. This causes delays if a read operation is simultaneously being performed from the table. + +Data that is inserted to a Buffer table may end up in the subordinate table in a different order and in different blocks. Because of this, a Buffer table is difficult to use for writing to a CollapsingMergeTree correctly. To avoid problems, you can set `num_layers` to 1. + +If the destination table is replicated, some expected characteristics of replicated tables are lost when writing to a Buffer table. The random changes to the order of rows and sizes of data parts cause data deduplication to quit working, which means it is not possible to have a reliable ‘exactly once’ write to replicated tables. + +Due to these disadvantages, we can only recommend using a Buffer table in rare cases. + +A Buffer table is used when too many INSERTs are received from a large number of servers over a unit of time and data can’t be buffered before insertion, which means the INSERTs can’t run fast enough. + +Note that it doesn’t make sense to insert data one row at a time, even for Buffer tables. This will only produce a speed of a few thousand rows per second, while inserting larger blocks of data can produce over a million rows per second (see the section “Performance”). + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/en/engines/table-engines/special/dictionary.md b/docs/en/engines/table-engines/special/dictionary.md new file mode 100644 index 00000000000..086ad53fab5 --- /dev/null +++ b/docs/en/engines/table-engines/special/dictionary.md @@ -0,0 +1,97 @@ +--- +toc_priority: 35 +toc_title: Dictionary +--- + +# Dictionary Table Engine {#dictionary} + +The `Dictionary` engine displays the [dictionary](../../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) data as a ClickHouse table. + +## Example + +As an example, consider a dictionary of `products` with the following configuration: + +``` xml + + + products + + +
products
+ DSN=some-db-server + + + + 300 + 360 + + + + + + + product_id + + + title + String + + + + + +``` + +Query the dictionary data: + +``` sql +SELECT + name, + type, + key, + attribute.names, + attribute.types, + bytes_allocated, + element_count, + source +FROM system.dictionaries +WHERE name = 'products' +``` + +``` text +┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ +│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ +└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ +``` + +You can use the [dictGet\*](../../../sql-reference/functions/ext-dict-functions.md#ext_dict_functions) function to get the dictionary data in this format. + +This view isn’t helpful when you need to get raw data, or when performing a `JOIN` operation. For these cases, you can use the `Dictionary` engine, which displays the dictionary data in a table. + +Syntax: + +``` sql +CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` +``` + +Usage example: + +``` sql +create table products (product_id UInt64, title String) Engine = Dictionary(products); +``` + + Ok + +Take a look at what’s in the table. + +``` sql +select * from products limit 1; +``` + +``` text +┌────product_id─┬─title───────────┐ +│ 152689 │ Some item │ +└───────────────┴─────────────────┘ +``` + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/en/engines/table-engines/special/distributed.md b/docs/en/engines/table-engines/special/distributed.md new file mode 100644 index 00000000000..11245bbf262 --- /dev/null +++ b/docs/en/engines/table-engines/special/distributed.md @@ -0,0 +1,151 @@ +--- +toc_priority: 33 +toc_title: Distributed +--- + +# Distributed Table Engine {#distributed} + +Tables with Distributed engine do not store any data by their own, but allow distributed query processing on multiple servers. +Reading is automatically parallelized. During a read, the table indexes on remote servers are used, if there are any. + +The Distributed engine accepts parameters: + +- the cluster name in the server's config file + +- the name of a remote database + +- the name of a remote table + +- (optionally) sharding key + +- (optionally) policy name, it will be used to store temporary files for async send + + See also: + + - `insert_distributed_sync` setting + - [MergeTree](../mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) for the examples + +Example: + +``` sql +Distributed(logs, default, hits[, sharding_key[, policy_name]]) +``` + +Data will be read from all servers in the `logs` cluster, from the default.hits table located on every server in the cluster. +Data is not only read but is partially processed on the remote servers (to the extent that this is possible). +For example, for a query with GROUP BY, data will be aggregated on remote servers, and the intermediate states of aggregate functions will be sent to the requestor server. Then data will be further aggregated. + +Instead of the database name, you can use a constant expression that returns a string. For example: currentDatabase(). + +logs – The cluster name in the server's config file. + +Clusters are set like this: + +``` xml + + + + + 1 + + false + + example01-01-1 + 9000 + + + example01-01-2 + 9000 + + + + 2 + false + + example01-02-1 + 9000 + + + example01-02-2 + 1 + 9440 + + + + +``` + +Here a cluster is defined with the name `logs` that consists of two shards, each of which contains two replicas. +Shards refer to the servers that contain different parts of the data (in order to read all the data, you must access all the shards). +Replicas are duplicating servers (in order to read all the data, you can access the data on any one of the replicas). + +Cluster names must not contain dots. + +The parameters `host`, `port`, and optionally `user`, `password`, `secure`, `compression` are specified for each server: +- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. +- `port` – The TCP port for messenger activity (`tcp_port` in the config, usually set to 9000). Do not confuse it with http\_port. +- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Access rights](../../../operations/access-rights.md). +- `password` – The password for connecting to a remote server (not masked). Default value: empty string. +- `secure` - Use ssl for connection, usually you also should define `port` = 9440. Server should listen on `9440` and have correct certificates. +- `compression` - Use data compression. Default value: true. + +When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [load\_balancing](../../../operations/settings/settings.md#settings-load_balancing) setting. +If the connection with the server is not established, there will be an attempt to connect with a short timeout. If the connection failed, the next replica will be selected, and so on for all the replicas. If the connection attempt failed for all the replicas, the attempt will be repeated the same way, several times. +This works in favour of resiliency, but does not provide complete fault tolerance: a remote server might accept the connection, but might not work, or work poorly. + +You can specify just one of the shards (in this case, query processing should be called remote, rather than distributed) or up to any number of shards. In each shard, you can specify from one to any number of replicas. You can specify a different number of replicas for each shard. + +You can specify as many clusters as you wish in the configuration. + +To view your clusters, use the `system.clusters` table. + +The Distributed engine allows working with a cluster like a local server. However, the cluster is inextensible: you must write its configuration in the server config file (even better, for all the cluster's servers). + +The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the `remote` table function instead. See the section [Table functions](../../../sql-reference/table-functions/index.md). + +There are two methods for writing data to a cluster: + +First, you can define which servers to write which data to and perform the write directly on each shard. In other words, perform INSERT in the tables that the distributed table "looks at". This is the most flexible solution as you can use any sharding scheme, which could be non-trivial due to the requirements of the subject area. This is also the most optimal solution since data can be written to different shards completely independently. + +Second, you can perform INSERT in a Distributed table. In this case, the table will distribute the inserted data across the servers itself. In order to write to a Distributed table, it must have a sharding key set (the last parameter). In addition, if there is only one shard, the write operation works without specifying the sharding key, since it doesn't mean anything in this case. + +Each shard can have a weight defined in the config file. By default, the weight is equal to one. Data is distributed across shards in the amount proportional to the shard weight. For example, if there are two shards and the first has a weight of 9 while the second has a weight of 10, the first will be sent 9 / 19 parts of the rows, and the second will be sent 10 / 19. + +Each shard can have the `internal_replication` parameter defined in the config file. + +If this parameter is set to `true`, the write operation selects the first healthy replica and writes data to it. Use this alternative if the Distributed table "looks at" replicated tables. In other words, if the table where data will be written is going to replicate them itself. + +If it is set to `false` (the default), data is written to all replicas. In essence, this means that the Distributed table replicates data itself. This is worse than using replicated tables, because the consistency of replicas is not checked, and over time they will contain slightly different data. + +To select the shard that a row of data is sent to, the sharding expression is analyzed, and its remainder is taken from dividing it by the total weight of the shards. The row is sent to the shard that corresponds to the half-interval of the remainders from `prev_weight` to `prev_weights + weight`, where `prev_weights` is the total weight of the shards with the smallest number, and `weight` is the weight of this shard. For example, if there are two shards, and the first has a weight of 9 while the second has a weight of 10, the row will be sent to the first shard for the remainders from the range \[0, 9), and to the second for the remainders from the range \[9, 19). + +The sharding expression can be any expression from constants and table columns that returns an integer. For example, you can use the expression `rand()` for random distribution of data, or `UserID` for distribution by the remainder from dividing the user's ID (then the data of a single user will reside on a single shard, which simplifies running IN and JOIN by users). If one of the columns is not distributed evenly enough, you can wrap it in a hash function: intHash64(UserID). + +A simple reminder from the division is a limited solution for sharding and isn't always appropriate. It works for medium and large volumes of data (dozens of servers), but not for very large volumes of data (hundreds of servers or more). In the latter case, use the sharding scheme required by the subject area, rather than using entries in Distributed tables. + +SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. + +You should be concerned about the sharding scheme in the following cases: + +- Queries are used that require joining data (IN or JOIN) by a specific key. If data is sharded by this key, you can use local IN or JOIN instead of GLOBAL IN or GLOBAL JOIN, which is much more efficient. +- A large number of servers is used (hundreds or more) with a large number of small queries (queries of individual clients - websites, advertisers, or partners). In order for the small queries to not affect the entire cluster, it makes sense to locate data for a single client on a single shard. Alternatively, as we've done in Yandex.Metrica, you can set up bi-level sharding: divide the entire cluster into "layers", where a layer may consist of multiple shards. Data for a single client is located on a single layer, but shards can be added to a layer as necessary, and data is randomly distributed within them. Distributed tables are created for each layer, and a single shared distributed table is created for global queries. + +Data is written asynchronously. When inserted in the table, the data block is just written to the local file system. The data is sent to the remote servers in the background as soon as possible. The period for sending data is managed by the [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) and [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) settings. The `Distributed` engine sends each file with inserted data separately, but you can enable batch sending of files with the [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) setting. This setting improves cluster performance by better utilizing local server and network resources. You should check whether data is sent successfully by checking the list of files (data waiting to be sent) in the table directory: `/var/lib/clickhouse/data/database/table/`. The number of threads performing background tasks can be set by [background_distributed_schedule_pool_size](../../../operations/settings/settings.md#background_distributed_schedule_pool_size) setting. + +If the server ceased to exist or had a rough restart (for example, after a device failure) after an INSERT to a Distributed table, the inserted data might be lost. If a damaged data part is detected in the table directory, it is transferred to the `broken` subdirectory and no longer used. + +When the `max_parallel_replicas` option is enabled, query processing is parallelized across all replicas within a single shard. For more information, see the section [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). + +## Virtual Columns {#virtual-columns} + +- `_shard_num` — Contains the `shard_num` (from `system.clusters`). Type: [UInt32](../../../sql-reference/data-types/int-uint.md). + +!!! note "Note" + Since [`remote`](../../../sql-reference/table-functions/remote.md)/`cluster` table functions internally create temporary instance of the same Distributed engine, `_shard_num` is available there too. + +**See Also** + +- [Virtual columns](index.md#table_engines-virtual_columns) +- [background_distributed_schedule_pool_size](../../../operations/settings/settings.md#background_distributed_schedule_pool_size) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/en/engines/table-engines/special/external-data.md b/docs/en/engines/table-engines/special/external-data.md new file mode 100644 index 00000000000..a2f6c076196 --- /dev/null +++ b/docs/en/engines/table-engines/special/external-data.md @@ -0,0 +1,66 @@ +--- +toc_priority: 45 +toc_title: External Data +--- + +# External Data for Query Processing {#external-data-for-query-processing} + +ClickHouse allows sending a server the data that is needed for processing a query, together with a `SELECT` query. This data is put in a temporary table (see the section “Temporary tables”) and can be used in the query (for example, in `IN` operators). + +For example, if you have a text file with important user identifiers, you can upload it to the server along with a query that uses filtration by this list. + +If you need to run more than one query with a large volume of external data, don’t use this feature. It is better to upload the data to the DB ahead of time. + +External data can be uploaded using the command-line client (in non-interactive mode), or using the HTTP interface. + +In the command-line client, you can specify a parameters section in the format + +``` bash +--external --file=... [--name=...] [--format=...] [--types=...|--structure=...] +``` + +You may have multiple sections like this, for the number of tables being transmitted. + +**–external** – Marks the beginning of a clause. +**–file** – Path to the file with the table dump, or -, which refers to stdin. +Only a single table can be retrieved from stdin. + +The following parameters are optional: **–name**– Name of the table. If omitted, \_data is used. +**–format** – Data format in the file. If omitted, TabSeparated is used. + +One of the following parameters is required:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … +**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Defines the column names and types. + +The files specified in ‘file’ will be parsed by the format specified in ‘format’, using the data types specified in ‘types’ or ‘structure’. The table will be uploaded to the server and accessible there as a temporary table with the name in ‘name’. + +Examples: + +``` bash +$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 +849897 +$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +When using the HTTP interface, external data is passed in the multipart/form-data format. Each table is transmitted as a separate file. The table name is taken from the file name. The `query_string` is passed the parameters `name_format`, `name_types`, and `name_structure`, where `name` is the name of the table that these parameters correspond to. The meaning of the parameters is the same as when using the command-line client. + +Example: + +``` bash +$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv + +$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +For distributed query processing, the temporary tables are sent to all the remote servers. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/en/engines/table-engines/special/file.md b/docs/en/engines/table-engines/special/file.md new file mode 100644 index 00000000000..afccf0a4552 --- /dev/null +++ b/docs/en/engines/table-engines/special/file.md @@ -0,0 +1,87 @@ +--- +toc_priority: 37 +toc_title: File +--- + +# File Table Engine {#table_engines-file} + +The File table engine keeps the data in a file in one of the supported [file formats](../../../interfaces/formats.md#formats) (`TabSeparated`, `Native`, etc.). + +Usage scenarios: + +- Data export from ClickHouse to file. +- Convert data from one format to another. +- Updating data in ClickHouse via editing a file on a disk. + +## Usage in ClickHouse Server {#usage-in-clickhouse-server} + +``` sql +File(Format) +``` + +The `Format` parameter specifies one of the available file formats. To perform +`SELECT` queries, the format must be supported for input, and to perform +`INSERT` queries – for output. The available formats are listed in the +[Formats](../../../interfaces/formats.md#formats) section. + +ClickHouse does not allow to specify filesystem path for`File`. It will use folder defined by [path](../../../operations/server-configuration-parameters/settings.md) setting in server configuration. + +When creating table using `File(Format)` it creates empty subdirectory in that folder. When data is written to that table, it’s put into `data.Format` file in that subdirectory. + +You may manually create this subfolder and file in server filesystem and then [ATTACH](../../../sql-reference/statements/misc.md) it to table information with matching name, so you can query data from that file. + +!!! warning "Warning" + Be careful with this functionality, because ClickHouse does not keep track of external changes to such files. The result of simultaneous writes via ClickHouse and outside of ClickHouse is undefined. + +## Example + +**1.** Set up the `file_engine_table` table: + +``` sql +CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) +``` + +By default ClickHouse will create folder `/var/lib/clickhouse/data/default/file_engine_table`. + +**2.** Manually create `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` containing: + +``` bash +$ cat data.TabSeparated +one 1 +two 2 +``` + +**3.** Query the data: + +``` sql +SELECT * FROM file_engine_table +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Usage in ClickHouse-local {#usage-in-clickhouse-local} + +In [clickhouse-local](../../../operations/utilities/clickhouse-local.md) File engine accepts file path in addition to `Format`. Default input/output streams can be specified using numeric or human-readable names like `0` or `stdin`, `1` or `stdout`. +**Example:** + +``` bash +$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" +``` + +## Details of Implementation {#details-of-implementation} + +- Multiple `SELECT` queries can be performed concurrently, but `INSERT` queries will wait each other. +- Supported creating new file by `INSERT` query. +- If file exists, `INSERT` would append new values in it. +- Not supported: + - `ALTER` + - `SELECT ... SAMPLE` + - Indices + - Replication + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/en/engines/table-engines/special/generate.md b/docs/en/engines/table-engines/special/generate.md new file mode 100644 index 00000000000..aa12092367c --- /dev/null +++ b/docs/en/engines/table-engines/special/generate.md @@ -0,0 +1,59 @@ +--- +toc_priority: 46 +toc_title: GenerateRandom +--- + +# GenerateRandom Table Engine {#table_engines-generate} + +The GenerateRandom table engine produces random data for given table schema. + +Usage examples: + +- Use in test to populate reproducible large table. +- Generate random input for fuzzing tests. + +## Usage in ClickHouse Server {#usage-in-clickhouse-server} + +``` sql +ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) +``` + +The `max_array_length` and `max_string_length` parameters specify maximum length of all +array columns and strings correspondingly in generated data. + +Generate table engine supports only `SELECT` queries. + +It supports all [DataTypes](../../../sql-reference/data-types/index.md) that can be stored in a table except `LowCardinality` and `AggregateFunction`. + +## Example + +**1.** Set up the `generate_engine_table` table: + +``` sql +CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) +``` + +**2.** Query the data: + +``` sql +SELECT * FROM generate_engine_table LIMIT 3 +``` + +``` text +┌─name─┬──────value─┐ +│ c4xJ │ 1412771199 │ +│ r │ 1791099446 │ +│ 7#$ │ 124312908 │ +└──────┴────────────┘ +``` + +## Details of Implementation {#details-of-implementation} + +- Not supported: + - `ALTER` + - `SELECT ... SAMPLE` + - `INSERT` + - Indices + - Replication + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/en/engines/table-engines/special/index.md b/docs/en/engines/table-engines/special/index.md new file mode 100644 index 00000000000..b1789f34347 --- /dev/null +++ b/docs/en/engines/table-engines/special/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Special +toc_priority: 31 +--- + + diff --git a/docs/en/engines/table-engines/special/join.md b/docs/en/engines/table-engines/special/join.md new file mode 100644 index 00000000000..0f88f0a56e7 --- /dev/null +++ b/docs/en/engines/table-engines/special/join.md @@ -0,0 +1,112 @@ +--- +toc_priority: 40 +toc_title: Join +--- + +# Join Table Engine {#join} + +Optional prepared data structure for usage in [JOIN](../../../sql-reference/statements/select/join.md#select-join) operations. + +!!! note "Note" + This is not an article about the [JOIN clause](../../../sql-reference/statements/select/join.md#select-join) itself. + +## Creating a Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], +) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) +``` + +See the detailed description of the [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) query. + +**Engine Parameters** + +- `join_strictness` – [JOIN strictness](../../../sql-reference/statements/select/join.md#select-join-strictness). +- `join_type` – [JOIN type](../../../sql-reference/statements/select/join.md#select-join-types). +- `k1[, k2, ...]` – Key columns from the `USING` clause that the `JOIN` operation is made with. + +Enter `join_strictness` and `join_type` parameters without quotes, for example, `Join(ANY, LEFT, col1)`. They must match the `JOIN` operation that the table will be used for. If the parameters don’t match, ClickHouse doesn’t throw an exception and may return incorrect data. + +## Table Usage {#table-usage} + +### Example {#example} + +Creating the left-side table: + +``` sql +CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog +``` + +``` sql +INSERT INTO id_val VALUES (1,11)(2,12)(3,13) +``` + +Creating the right-side `Join` table: + +``` sql +CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) +``` + +``` sql +INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) +``` + +Joining the tables: + +``` sql +SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 +``` + +``` text +┌─id─┬─val─┬─id_val_join.val─┐ +│ 1 │ 11 │ 21 │ +│ 2 │ 12 │ ᴺᵁᴸᴸ │ +│ 3 │ 13 │ 23 │ +└────┴─────┴─────────────────┘ +``` + +As an alternative, you can retrieve data from the `Join` table, specifying the join key value: + +``` sql +SELECT joinGet('id_val_join', 'val', toUInt32(1)) +``` + +``` text +┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ +│ 21 │ +└────────────────────────────────────────────┘ +``` + +### Selecting and Inserting Data {#selecting-and-inserting-data} + +You can use `INSERT` queries to add data to the `Join`-engine tables. If the table was created with the `ANY` strictness, data for duplicate keys are ignored. With the `ALL` strictness, all rows are added. + +You cannot perform a `SELECT` query directly from the table. Instead, use one of the following methods: + +- Place the table to the right side in a `JOIN` clause. +- Call the [joinGet](../../../sql-reference/functions/other-functions.md#joinget) function, which lets you extract data from the table the same way as from a dictionary. + +### Limitations and Settings {#join-limitations-and-settings} + +When creating a table, the following settings are applied: + +- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) +- [max\_rows\_in\_join](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) +- [max\_bytes\_in\_join](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) +- [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) +- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) + +The `Join`-engine tables can’t be used in `GLOBAL JOIN` operations. + +The `Join`-engine allows use [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) setting in the `CREATE TABLE` statement. And [SELECT](../../../sql-reference/statements/select/index.md) query allows use `join_use_nulls` too. If you have different `join_use_nulls` settings, you can get an error joining table. It depends on kind of JOIN. When you use [joinGet](../../../sql-reference/functions/other-functions.md#joinget) function, you have to use the same `join_use_nulls` setting in `CRATE TABLE` and `SELECT` statements. + +## Data Storage {#data-storage} + +`Join` table data is always located in the RAM. When inserting rows into a table, ClickHouse writes data blocks to the directory on the disk so that they can be restored when the server restarts. + +If the server restarts incorrectly, the data block on the disk might get lost or damaged. In this case, you may need to manually delete the file with damaged data. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/en/engines/table-engines/special/materializedview.md b/docs/en/engines/table-engines/special/materializedview.md new file mode 100644 index 00000000000..53ebf9641af --- /dev/null +++ b/docs/en/engines/table-engines/special/materializedview.md @@ -0,0 +1,10 @@ +--- +toc_priority: 43 +toc_title: MaterializedView +--- + +# MaterializedView Table Engine {#materializedview} + +Used for implementing materialized views (for more information, see [CREATE TABLE](../../../sql-reference/statements/create.md)). For storing data, it uses a different engine that was specified when creating the view. When reading from a table, it just uses that engine. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/en/engines/table-engines/special/memory.md b/docs/en/engines/table-engines/special/memory.md new file mode 100644 index 00000000000..a6c833ebdba --- /dev/null +++ b/docs/en/engines/table-engines/special/memory.md @@ -0,0 +1,18 @@ +--- +toc_priority: 44 +toc_title: Memory +--- + +# Memory Table Engine {#memory} + +The Memory engine stores data in RAM, in uncompressed form. Data is stored in exactly the same form as it is received when read. In other words, reading from this table is completely free. +Concurrent data access is synchronized. Locks are short: read and write operations don’t block each other. +Indexes are not supported. Reading is parallelized. + +Maximal productivity (over 10 GB/sec) is reached on simple queries, because there is no reading from the disk, decompressing, or deserializing data. (We should note that in many cases, the productivity of the MergeTree engine is almost as high.) +When restarting a server, data disappears from the table and the table becomes empty. +Normally, using this table engine is not justified. However, it can be used for tests, and for tasks where maximum speed is required on a relatively small number of rows (up to approximately 100,000,000). + +The Memory engine is used by the system for temporary tables with external query data (see the section “External data for processing a query”), and for implementing `GLOBAL IN` (see the section “IN operators”). + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/en/engines/table-engines/special/merge.md b/docs/en/engines/table-engines/special/merge.md new file mode 100644 index 00000000000..5dca7f8602d --- /dev/null +++ b/docs/en/engines/table-engines/special/merge.md @@ -0,0 +1,72 @@ +--- +toc_priority: 36 +toc_title: Merge +--- + +# Merge Table Engine {#merge} + +The `Merge` engine (not to be confused with `MergeTree`) does not store data itself, but allows reading from any number of other tables simultaneously. + +Reading is automatically parallelized. Writing to a table is not supported. When reading, the indexes of tables that are actually being read are used, if they exist. + +The `Merge` engine accepts parameters: the database name and a regular expression for tables. + +## Examples + +Example 1: + +``` sql +Merge(hits, '^WatchLog') +``` + +Data will be read from the tables in the `hits` database that have names that match the regular expression ‘`^WatchLog`’. + +Instead of the database name, you can use a constant expression that returns a string. For example, `currentDatabase()`. + +Regular expressions — [re2](https://github.com/google/re2) (supports a subset of PCRE), case-sensitive. +See the notes about escaping symbols in regular expressions in the “match” section. + +When selecting tables to read, the `Merge` table itself will not be selected, even if it matches the regex. This is to avoid loops. +It is possible to create two `Merge` tables that will endlessly try to read each others’ data, but this is not a good idea. + +The typical way to use the `Merge` engine is for working with a large number of `TinyLog` tables as if with a single table. + +Example 2: + +Let’s say you have a old table (WatchLog\_old) and decided to change partitioning without moving data to a new table (WatchLog\_new) and you need to see data from both tables. + +``` sql +CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree(date, (UserId, EventType), 8192); +INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); + +CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; +INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); + +CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); + +SELECT * +FROM WatchLog +``` + +``` text +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-01 │ 1 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-02 │ 2 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +``` + +## Virtual Columns {#virtual-columns} + +- `_table` — Contains the name of the table from which data was read. Type: [String](../../../sql-reference/data-types/string.md). + + You can set the constant conditions on `_table` in the `WHERE/PREWHERE` clause (for example, `WHERE _table='xyz'`). In this case the read operation is performed only for that tables where the condition on `_table` is satisfied, so the `_table` column acts as an index. + +**See Also** + +- [Virtual columns](index.md#table_engines-virtual_columns) + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/en/engines/table-engines/special/null.md b/docs/en/engines/table-engines/special/null.md new file mode 100644 index 00000000000..5f9a2ac679b --- /dev/null +++ b/docs/en/engines/table-engines/special/null.md @@ -0,0 +1,13 @@ +--- +toc_priority: 38 +toc_title: 'Null' +--- + +# Null Table Engine {#null} + +When writing to a `Null` table, data is ignored. When reading from a `Null` table, the response is empty. + +!!! info "Hint" + However, you can create a materialized view on a `Null` table. So the data written to the table will end up affecting the view, but original raw data will still be discarded. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/en/engines/table-engines/special/set.md b/docs/en/engines/table-engines/special/set.md new file mode 100644 index 00000000000..65fd7376532 --- /dev/null +++ b/docs/en/engines/table-engines/special/set.md @@ -0,0 +1,17 @@ +--- +toc_priority: 39 +toc_title: Set +--- + +# Set Table Engine {#set} + +A data set that is always in RAM. It is intended for use on the right side of the `IN` operator (see the section “IN operators”). + +You can use `INSERT` to insert data in the table. New elements will be added to the data set, while duplicates will be ignored. +But you can’t perform `SELECT` from the table. The only way to retrieve data is by using it in the right half of the `IN` operator. + +Data is always located in RAM. For `INSERT`, the blocks of inserted data are also written to the directory of tables on the disk. When starting the server, this data is loaded to RAM. In other words, after restarting, the data remains in place. + +For a rough server restart, the block of data on the disk might be lost or damaged. In the latter case, you may need to manually delete the file with damaged data. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/en/engines/table-engines/special/url.md b/docs/en/engines/table-engines/special/url.md new file mode 100644 index 00000000000..4fa1a50df38 --- /dev/null +++ b/docs/en/engines/table-engines/special/url.md @@ -0,0 +1,81 @@ +--- +toc_priority: 41 +toc_title: URL +--- + +# URL Table Engine {#table_engines-url} + +Queries data to/from a remote HTTP/HTTPS server. This engine is similar to the [File](file.md) engine. + +Syntax: `URL(URL, Format)` + +## Usage {#using-the-engine-in-the-clickhouse-server} + +The `format` must be one that ClickHouse can use in +`SELECT` queries and, if necessary, in `INSERTs`. For the full list of supported formats, see +[Formats](../../../interfaces/formats.md#formats). + +The `URL` must conform to the structure of a Uniform Resource Locator. The specified URL must point to a server +that uses HTTP or HTTPS. This does not require any +additional headers for getting a response from the server. + +`INSERT` and `SELECT` queries are transformed to `POST` and `GET` requests, +respectively. For processing `POST` requests, the remote server must support +[Chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). + +You can limit the maximum number of HTTP GET redirect hops using the [max\_http\_get\_redirects](../../../operations/settings/settings.md#setting-max_http_get_redirects) setting. + +## Example + +**1.** Create a `url_engine_table` table on the server : + +``` sql +CREATE TABLE url_engine_table (word String, value UInt64) +ENGINE=URL('http://127.0.0.1:12345/', CSV) +``` + +**2.** Create a basic HTTP server using the standard Python 3 tools and +start it: + +``` python3 +from http.server import BaseHTTPRequestHandler, HTTPServer + +class CSVHTTPServer(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header('Content-type', 'text/csv') + self.end_headers() + + self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) + +if __name__ == "__main__": + server_address = ('127.0.0.1', 12345) + HTTPServer(server_address, CSVHTTPServer).serve_forever() +``` + +``` bash +$ python3 server.py +``` + +**3.** Request data: + +``` sql +SELECT * FROM url_engine_table +``` + +``` text +┌─word──┬─value─┐ +│ Hello │ 1 │ +│ World │ 2 │ +└───────┴───────┘ +``` + +## Details of Implementation {#details-of-implementation} + +- Reads and writes can be parallel +- Not supported: + - `ALTER` and `SELECT...SAMPLE` operations. + - Indexes. + - Replication. + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/en/engines/table-engines/special/view.md b/docs/en/engines/table-engines/special/view.md new file mode 100644 index 00000000000..c4f95adfa6d --- /dev/null +++ b/docs/en/engines/table-engines/special/view.md @@ -0,0 +1,10 @@ +--- +toc_priority: 42 +toc_title: View +--- + +# View Table Engine {#table_engines-view} + +Used for implementing views (for more information, see the `CREATE VIEW query`). It does not store data, but only stores the specified `SELECT` query. When reading from a table, it runs this query (and deletes all unnecessary columns from the query). + +[Original article](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/en/engines/table_engines/index.md b/docs/en/engines/table_engines/index.md deleted file mode 100644 index 00f53a6f9f0..00000000000 --- a/docs/en/engines/table_engines/index.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -toc_folder_title: Table Engines -toc_priority: 26 -toc_title: Introduction ---- - -# Table Engines {#table_engines} - -The table engine (type of table) determines: - -- How and where data is stored, where to write it to, and where to read it from. -- Which queries are supported, and how. -- Concurrent data access. -- Use of indexes, if present. -- Whether multithreaded request execution is possible. -- Data replication parameters. - -## Engine Families {#engine-families} - -### MergeTree {#mergetree} - -The most universal and functional table engines for high-load tasks. The property shared by these engines is quick data insertion with subsequent background data processing. `MergeTree` family engines support data replication (with [Replicated\*](mergetree_family/replication.md) versions of engines), partitioning, and other features not supported in other engines. - -Engines in the family: - -- [MergeTree](mergetree_family/mergetree.md) -- [ReplacingMergeTree](mergetree_family/replacingmergetree.md) -- [SummingMergeTree](mergetree_family/summingmergetree.md) -- [AggregatingMergeTree](mergetree_family/aggregatingmergetree.md) -- [CollapsingMergeTree](mergetree_family/collapsingmergetree.md) -- [VersionedCollapsingMergeTree](mergetree_family/versionedcollapsingmergetree.md) -- [GraphiteMergeTree](mergetree_family/graphitemergetree.md) - -### Log {#log} - -Lightweight [engines](log_family/index.md) with minimum functionality. They’re the most effective when you need to quickly write many small tables (up to approximately 1 million rows) and read them later as a whole. - -Engines in the family: - -- [TinyLog](log_family/tinylog.md) -- [StripeLog](log_family/stripelog.md) -- [Log](log_family/log.md) - -### Integration Engines {#integration-engines} - -Engines for communicating with other data storage and processing systems. - -Engines in the family: - -- [Kafka](integrations/kafka.md) -- [MySQL](integrations/mysql.md) -- [ODBC](integrations/odbc.md) -- [JDBC](integrations/jdbc.md) -- [HDFS](integrations/hdfs.md) - -### Special Engines {#special-engines} - -Engines in the family: - -- [Distributed](special/distributed.md) -- [MaterializedView](special/materializedview.md) -- [Dictionary](special/dictionary.md) -- [Merge](special/merge.md) -- [File](special/file.md) -- [Null](special/null.md) -- [Set](special/set.md) -- [Join](special/join.md) -- [URL](special/url.md) -- [View](special/view.md) -- [Memory](special/memory.md) -- [Buffer](special/buffer.md) - -## Virtual Columns {#table_engines-virtual-columns} - -Virtual column is an integral table engine attribute that is defined in the engine source code. - -You shouldn’t specify virtual columns in the `CREATE TABLE` query and you can’t see them in `SHOW CREATE TABLE` and `DESCRIBE TABLE` query results. Virtual columns are also read-only, so you can’t insert data into virtual columns. - -To select data from a virtual column, you must specify its name in the `SELECT` query. `SELECT *` doesn’t return values from virtual columns. - -If you create a table with a column that has the same name as one of the table virtual columns, the virtual column becomes inaccessible. We don’t recommend doing this. To help avoid conflicts, virtual column names are usually prefixed with an underscore. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/en/engines/table_engines/integrations/hdfs.md b/docs/en/engines/table_engines/integrations/hdfs.md deleted file mode 100644 index b24313e682a..00000000000 --- a/docs/en/engines/table_engines/integrations/hdfs.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -toc_priority: 36 -toc_title: HDFS ---- - -# HDFS {#table_engines-hdfs} - -This engine provides integration with [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) ecosystem by allowing to manage data on [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)via ClickHouse. This engine is similar -to the [File](../special/file.md) and [URL](../special/url.md) engines, but provides Hadoop-specific features. - -## Usage {#usage} - -``` sql -ENGINE = HDFS(URI, format) -``` - -The `URI` parameter is the whole file URI in HDFS. -The `format` parameter specifies one of the available file formats. To perform -`SELECT` queries, the format must be supported for input, and to perform -`INSERT` queries – for output. The available formats are listed in the -[Formats](../../../interfaces/formats.md#formats) section. -The path part of `URI` may contain globs. In this case the table would be readonly. - -**Example:** - -**1.** Set up the `hdfs_engine_table` table: - -``` sql -CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') -``` - -**2.** Fill file: - -``` sql -INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) -``` - -**3.** Query the data: - -``` sql -SELECT * FROM hdfs_engine_table LIMIT 2 -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Implementation Details {#implementation-details} - -- Reads and writes can be parallel -- Not supported: - - `ALTER` and `SELECT...SAMPLE` operations. - - Indexes. - - Replication. - -**Globs in path** - -Multiple path components can have globs. For being processed file should exists and matches to the whole path pattern. Listing of files determines during `SELECT` (not at `CREATE` moment). - -- `*` — Substitutes any number of any characters except `/` including empty string. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -Constructions with `{}` are similar to the [remote](../../../sql_reference/table_functions/remote.md) table function. - -**Example** - -1. Suppose we have several files in TSV format with the following URIs on HDFS: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. There are several ways to make a table consisting of all six files: - - - -``` sql -CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') -``` - -Another way: - -``` sql -CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') -``` - -Table consists of all the files in both directories (all files should satisfy format and schema described in query): - -``` sql -CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') -``` - -!!! warning "Warning" - If the listing of files contains number ranges with leading zeros, use the construction with braces for each digit separately or use `?`. - -**Example** - -Create table with files named `file000`, `file001`, … , `file999`: - -``` sql -CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') -``` - -## Virtual Columns {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**See Also** - -- [Virtual columns](../index.md#table_engines-virtual_columns) - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/en/engines/table_engines/integrations/index.md b/docs/en/engines/table_engines/integrations/index.md deleted file mode 100644 index 716d00cdd98..00000000000 --- a/docs/en/engines/table_engines/integrations/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Integrations -toc_priority: 30 ---- - diff --git a/docs/en/engines/table_engines/integrations/jdbc.md b/docs/en/engines/table_engines/integrations/jdbc.md deleted file mode 100644 index e3ba45ac06e..00000000000 --- a/docs/en/engines/table_engines/integrations/jdbc.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -toc_priority: 34 -toc_title: JDBC ---- - -# JDBC {#table-engine-jdbc} - -Allows ClickHouse to connect to external databases via [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). - -To implement the JDBC connection, ClickHouse uses the separate program [clickhouse-jdbc-bridge](https://github.com/alex-krash/clickhouse-jdbc-bridge) that should run as a daemon. - -This engine supports the [Nullable](../../../sql_reference/data_types/nullable.md) data type. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name -( - columns list... -) -ENGINE = JDBC(dbms_uri, external_database, external_table) -``` - -**Engine Parameters** - -- `dbms_uri` — URI of an external DBMS. - - Format: `jdbc:://:/?user=&password=`. - Example for MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. - -- `external_database` — Database in an external DBMS. - -- `external_table` — Name of the table in `external_database`. - -## Usage Example {#usage-example} - -Creating a table in MySQL server by connecting directly with it’s console client: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Creating a table in ClickHouse server and selecting data from it: - -``` sql -CREATE TABLE jdbc_table -( - `int_id` Int32, - `int_nullable` Nullable(Int32), - `float` Float32, - `float_nullable` Nullable(Float32) -) -ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') -``` - -``` sql -SELECT * -FROM jdbc_table -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## See Also {#see-also} - -- [JDBC table function](../../../sql_reference/table_functions/jdbc.md). - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/en/engines/table_engines/integrations/kafka.md b/docs/en/engines/table_engines/integrations/kafka.md deleted file mode 100644 index 31a218c85b5..00000000000 --- a/docs/en/engines/table_engines/integrations/kafka.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -toc_priority: 32 -toc_title: Kafka ---- - -# Kafka {#kafka} - -This engine works with [Apache Kafka](http://kafka.apache.org/). - -Kafka lets you: - -- Publish or subscribe to data flows. -- Organize fault-tolerant storage. -- Process streams as they become available. - -## Creating a Table {#table_engine-kafka-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = Kafka() -SETTINGS - kafka_broker_list = 'host:port', - kafka_topic_list = 'topic1,topic2,...', - kafka_group_name = 'group_name', - kafka_format = 'data_format'[,] - [kafka_row_delimiter = 'delimiter_symbol',] - [kafka_schema = '',] - [kafka_num_consumers = N,] - [kafka_skip_broken_messages = N] -``` - -Required parameters: - -- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). -- `kafka_topic_list` – A list of Kafka topics. -- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don’t want messages to be duplicated in the cluster, use the same group name everywhere. -- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` function, such as `JSONEachRow`. For more information, see the [Formats](../../../interfaces/formats.md) section. - -Optional parameters: - -- `kafka_row_delimiter` – Delimiter character, which ends the message. -- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap’n Proto](https://capnproto.org/) requires the path to the schema file and the name of the root `schema.capnp:Message` object. -- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Specify more consumers if the throughput of one consumer is insufficient. The total number of consumers should not exceed the number of partitions in the topic, since only one consumer can be assigned per partition. -- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. If `kafka_skip_broken_messages = N` then the engine skips *N* Kafka messages that cannot be parsed (a message equals a row of data). - -Examples: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - SELECT * FROM queue LIMIT 5; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', - kafka_topic_list = 'topic', - kafka_group_name = 'group1', - kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') - SETTINGS kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; -``` - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects. If possible, switch old projects to the method described above. - -``` sql -Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format - [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) -``` - -
- -## Description {#description} - -The delivered messages are tracked automatically, so each message in a group is only counted once. If you want to get the data twice, then create a copy of the table with another group name. - -Groups are flexible and synced on the cluster. For instance, if you have 10 topics and 5 copies of a table in a cluster, then each copy gets 2 topics. If the number of copies changes, the topics are redistributed across the copies automatically. Read more about this at http://kafka.apache.org/intro. - -`SELECT` is not particularly useful for reading messages (except for debugging), because each message can be read only once. It is more practical to create real-time threads using materialized views. To do this: - -1. Use the engine to create a Kafka consumer and consider it a data stream. -2. Create a table with the desired structure. -3. Create a materialized view that converts data from the engine and puts it into a previously created table. - -When the `MATERIALIZED VIEW` joins the engine, it starts collecting data in the background. This allows you to continually receive messages from Kafka and convert them to the required format using `SELECT`. -One kafka table can have as many materialized views as you like, they do not read data from the kafka table directly, but receive new records (in blocks), this way you can write to several tables with different detail level (with grouping - aggregation and without). - -Example: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - CREATE TABLE daily ( - day Date, - level String, - total UInt64 - ) ENGINE = SummingMergeTree(day, (day, level), 8192); - - CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total - FROM queue GROUP BY day, level; - - SELECT level, sum(total) FROM daily GROUP BY level; -``` - -To improve performance, received messages are grouped into blocks the size of [max\_insert\_block\_size](../../../operations/server_configuration_parameters/settings.md#settings-max_insert_block_size). If the block wasn’t formed within [stream\_flush\_interval\_ms](../../../operations/server_configuration_parameters/settings.md) milliseconds, the data will be flushed to the table regardless of the completeness of the block. - -To stop receiving topic data or to change the conversion logic, detach the materialized view: - -``` sql - DETACH TABLE consumer; - ATTACH TABLE consumer; -``` - -If you want to change the target table by using `ALTER`, we recommend disabling the material view to avoid discrepancies between the target table and the data from the view. - -## Configuration {#configuration} - -Similar to GraphiteMergeTree, the Kafka engine supports extended configuration using the ClickHouse config file. There are two configuration keys that you can use: global (`kafka`) and topic-level (`kafka_*`). The global configuration is applied first, and then the topic-level configuration is applied (if it exists). - -``` xml - - - cgrp - smallest - - - - - 250 - 100000 - -``` - -For a list of possible configuration options, see the [librdkafka configuration reference](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Use the underscore (`_`) instead of a dot in the ClickHouse configuration. For example, `check.crcs=true` will be `true`. - -## Virtual Columns {#virtual-columns} - -- `_topic` — Kafka topic. -- `_key` — Key of the message. -- `_offset` — Offset of the message. -- `_timestamp` — Timestamp of the message. -- `_partition` — Partition of Kafka topic. - -**See Also** - -- [Virtual columns](../index.md#table_engines-virtual_columns) - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/en/engines/table_engines/integrations/mysql.md b/docs/en/engines/table_engines/integrations/mysql.md deleted file mode 100644 index 49410887242..00000000000 --- a/docs/en/engines/table_engines/integrations/mysql.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -toc_priority: 33 -toc_title: MySQL ---- - -# Mysql {#mysql} - -The MySQL engine allows you to perform `SELECT` queries on data that is stored on a remote MySQL server. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... -) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -See a detailed description of the [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) query. - -The table structure can differ from the original MySQL table structure: - -- Column names should be the same as in the original MySQL table, but you can use just some of these columns and in any order. -- Column types may differ from those in the original MySQL table. ClickHouse tries to [cast](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) values to the ClickHouse data types. - -**Engine Parameters** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` queries to `REPLACE INTO`. If `replace_query=1`, the query is substituted. - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expression that is added to the `INSERT` query. - - Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the [MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. - - To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. - -Simple `WHERE` clauses such as `=, !=, >, >=, <, <=` are executed on the MySQL server. - -The rest of the conditions and the `LIMIT` sampling constraint are executed in ClickHouse only after the query to MySQL finishes. - -## Usage Example {#usage-example} - -Table in MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Table in ClickHouse, retrieving data from the MySQL table created above: - -``` sql -CREATE TABLE mysql_table -( - `float_nullable` Nullable(Float32), - `int_id` Int32 -) -ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` sql -SELECT * FROM mysql_table -``` - -``` text -┌─float_nullable─┬─int_id─┐ -│ ᴺᵁᴸᴸ │ 1 │ -└────────────────┴────────┘ -``` - -## See Also {#see-also} - -- [The ‘mysql’ table function](../../../sql_reference/table_functions/mysql.md) -- [Using MySQL as a source of external dictionary](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/en/engines/table_engines/integrations/odbc.md b/docs/en/engines/table_engines/integrations/odbc.md deleted file mode 100644 index a537150313f..00000000000 --- a/docs/en/engines/table_engines/integrations/odbc.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -toc_priority: 35 -toc_title: ODBC ---- - -# ODBC {#table-engine-odbc} - -Allows ClickHouse to connect to external databases via [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -To safely implement ODBC connections, ClickHouse uses a separate program `clickhouse-odbc-bridge`. If the ODBC driver is loaded directly from `clickhouse-server`, driver problems can crash the ClickHouse server. ClickHouse automatically starts `clickhouse-odbc-bridge` when it is required. The ODBC bridge program is installed from the same package as the `clickhouse-server`. - -This engine supports the [Nullable](../../../sql_reference/data_types/nullable.md) data type. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1], - name2 [type2], - ... -) -ENGINE = ODBC(connection_settings, external_database, external_table) -``` - -See a detailed description of the [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) query. - -The table structure can differ from the source table structure: - -- Column names should be the same as in the source table, but you can use just some of these columns and in any order. -- Column types may differ from those in the source table. ClickHouse tries to [cast](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) values to the ClickHouse data types. - -**Engine Parameters** - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` file. -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -## Usage Example {#usage-example} - -**Retrieving data from the local MySQL installation via ODBC** - -This example is checked for Ubuntu Linux 18.04 and MySQL server 5.7. - -Ensure that unixODBC and MySQL Connector are installed. - -By default (if installed from packages), ClickHouse starts as user `clickhouse`. Thus, you need to create and configure this user in the MySQL server. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -Then configure the connection in `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -You can check the connection using the `isql` utility from the unixODBC installation. - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -Table in MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Table in ClickHouse, retrieving data from the MySQL table: - -``` sql -CREATE TABLE odbc_t -( - `int_id` Int32, - `float_nullable` Nullable(Float32) -) -ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') -``` - -``` sql -SELECT * FROM odbc_t -``` - -``` text -┌─int_id─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ -└────────┴────────────────┘ -``` - -## See Also {#see-also} - -- [ODBC external dictionaries](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [ODBC table function](../../../sql_reference/table_functions/odbc.md) - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/en/engines/table_engines/log_family/index.md b/docs/en/engines/table_engines/log_family/index.md deleted file mode 100644 index a64371200a6..00000000000 --- a/docs/en/engines/table_engines/log_family/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Log Family -toc_priority: 29 ---- - diff --git a/docs/en/engines/table_engines/log_family/log.md b/docs/en/engines/table_engines/log_family/log.md deleted file mode 100644 index b34fdd4116e..00000000000 --- a/docs/en/engines/table_engines/log_family/log.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -toc_priority: 33 -toc_title: Log ---- - -# Log {#log} - -Engine belongs to the family of log engines. See the common properties of log engines and their differences in the [Log Engine Family](log_family.md) article. - -Log differs from [TinyLog](tinylog.md) in that a small file of “marks” resides with the column files. These marks are written on every data block and contain offsets that indicate where to start reading the file in order to skip the specified number of rows. This makes it possible to read table data in multiple threads. -For concurrent data access, the read operations can be performed simultaneously, while write operations block reads and each other. -The Log engine does not support indexes. Similarly, if writing to a table failed, the table is broken, and reading from it returns an error. The Log engine is appropriate for temporary data, write-once tables, and for testing or demonstration purposes. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/en/engines/table_engines/log_family/log_family.md b/docs/en/engines/table_engines/log_family/log_family.md deleted file mode 100644 index a238a844002..00000000000 --- a/docs/en/engines/table_engines/log_family/log_family.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -toc_priority: 31 -toc_title: Introduction ---- - -# Log Engine Family {#log-engine-family} - -These engines were developed for scenarios when you need to quickly write many small tables (up to about 1 million rows) and read them later as a whole. - -Engines of the family: - -- [StripeLog](stripelog.md) -- [Log](log.md) -- [TinyLog](tinylog.md) - -## Common Properties {#common-properties} - -Engines: - -- Store data on a disk. - -- Append data to the end of file when writing. - -- Support locks for concurrent data access. - - During `INSERT` queries, the table is locked, and other queries for reading and writing data both wait for the table to unlock. If there are no data writing queries, any number of data reading queries can be performed concurrently. - -- Do not support [mutation](../../../sql_reference/statements/alter.md#alter-mutations) operations. - -- Do not support indexes. - - This means that `SELECT` queries for ranges of data are not efficient. - -- Do not write data atomically. - - You can get a table with corrupted data if something breaks the write operation, for example, abnormal server shutdown. - -## Differences {#differences} - -The `TinyLog` engine is the simplest in the family and provides the poorest functionality and lowest efficiency. The `TinyLog` engine doesn’t support parallel data reading by several threads. It reads data slower than other engines in the family that support parallel reading and it uses almost as many descriptors as the `Log` engine because it stores each column in a separate file. Use it in simple low-load scenarios. - -The `Log` and `StripeLog` engines support parallel data reading. When reading data, ClickHouse uses multiple threads. Each thread processes a separate data block. The `Log` engine uses a separate file for each column of the table. `StripeLog` stores all the data in one file. As a result, the `StripeLog` engine uses fewer descriptors in the operating system, but the `Log` engine provides higher efficiency when reading data. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/en/engines/table_engines/log_family/stripelog.md b/docs/en/engines/table_engines/log_family/stripelog.md deleted file mode 100644 index 1aace26ceeb..00000000000 --- a/docs/en/engines/table_engines/log_family/stripelog.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -toc_priority: 32 -toc_title: StripeLog ---- - -# Stripelog {#stripelog} - -This engine belongs to the family of log engines. See the common properties of log engines and their differences in the [Log Engine Family](log_family.md) article. - -Use this engine in scenarios when you need to write many tables with a small amount of data (less than 1 million rows). - -## Creating a Table {#table_engines-stripelog-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = StripeLog -``` - -See the detailed description of the [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) query. - -## Writing the Data {#table_engines-stripelog-writing-the-data} - -The `StripeLog` engine stores all the columns in one file. For each `INSERT` query, ClickHouse appends the data block to the end of a table file, writing columns one by one. - -For each table ClickHouse writes the files: - -- `data.bin` — Data file. -- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. - -The `StripeLog` engine does not support the `ALTER UPDATE` and `ALTER DELETE` operations. - -## Reading the Data {#table_engines-stripelog-reading-the-data} - -The file with marks allows ClickHouse to parallelize the reading of data. This means that a `SELECT` query returns rows in an unpredictable order. Use the `ORDER BY` clause to sort rows. - -## Example Of Use {#table_engines-stripelog-example-of-use} - -Creating a table: - -``` sql -CREATE TABLE stripe_log_table -( - timestamp DateTime, - message_type String, - message String -) -ENGINE = StripeLog -``` - -Inserting data: - -``` sql -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') -``` - -We used two `INSERT` queries to create two data blocks inside the `data.bin` file. - -ClickHouse uses multiple threads when selecting data. Each thread reads a separate data block and returns resulting rows independently as it finishes. As a result, the order of blocks of rows in the output does not match the order of the same blocks in the input in most cases. For example: - -``` sql -SELECT * FROM stripe_log_table -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -┌───────────timestamp─┬─message_type─┬─message───────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -└─────────────────────┴──────────────┴───────────────────────────┘ -``` - -Sorting the results (ascending order by default): - -``` sql -SELECT * FROM stripe_log_table ORDER BY timestamp -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/en/engines/table_engines/log_family/tinylog.md b/docs/en/engines/table_engines/log_family/tinylog.md deleted file mode 100644 index 7b91becc4d7..00000000000 --- a/docs/en/engines/table_engines/log_family/tinylog.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -toc_priority: 34 -toc_title: TinyLog ---- - -# TinyLog {#tinylog} - -The engine belongs to the log engine family. See [Log Engine Family](log_family.md) for common properties of log engines and their differences. - -This table engine is typically used with the write-once method: write data one time, then read it as many times as necessary. For example, you can use `TinyLog`-type tables for intermediary data that is processed in small batches. Note that storing data in a large number of small tables is inefficient. - -Queries are executed in a single stream. In other words, this engine is intended for relatively small tables (up to about 1,000,000 rows). It makes sense to use this table engine if you have many small tables, since it’s simpler than the [Log](log.md) engine (fewer files need to be opened). - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/en/engines/table_engines/mergetree_family/aggregatingmergetree.md b/docs/en/engines/table_engines/mergetree_family/aggregatingmergetree.md deleted file mode 100644 index 9e310d313b9..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/aggregatingmergetree.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -toc_priority: 35 -toc_title: AggregatingMergeTree ---- - -# Aggregatingmergetree {#aggregatingmergetree} - -The engine inherits from [MergeTree](mergetree.md#table_engines-mergetree), altering the logic for data parts merging. ClickHouse replaces all rows with the same primary key (or more accurately, with the same [sorting key](mergetree.md)) with a single row (within a one data part) that stores a combination of states of aggregate functions. - -You can use `AggregatingMergeTree` tables for incremental data aggregation, including for aggregated materialized views. - -The engine processes all columns with the following types: - -- [AggregateFunction](../../../sql_reference/data_types/aggregatefunction.md) -- [SimpleAggregateFunction](../../../sql_reference/data_types/simpleaggregatefunction.md) - -It is appropriate to use `AggregatingMergeTree` if it reduces the number of rows by orders. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = AggregatingMergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[TTL expr] -[SETTINGS name=value, ...] -``` - -For a description of request parameters, see [request description](../../../sql_reference/statements/create.md). - -**Query clauses** - -When creating a `AggregatingMergeTree` table the same [clauses](mergetree.md) are required, as when creating a `MergeTree` table. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects and, if possible, switch the old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -All of the parameters have the same meaning as in `MergeTree`. -
- -## SELECT and INSERT {#select-and-insert} - -To insert data, use [INSERT SELECT](../../../sql_reference/statements/insert_into.md) query with aggregate -State- functions. -When selecting data from `AggregatingMergeTree` table, use `GROUP BY` clause and the same aggregate functions as when inserting data, but using `-Merge` suffix. - -In the results of `SELECT` query, the values of `AggregateFunction` type have implementation-specific binary representation for all of the ClickHouse output formats. If dump data into, for example, `TabSeparated` format with `SELECT` query then this dump can be loaded back using `INSERT` query. - -## Example Of an Aggregated Materialized View {#example-of-an-aggregated-materialized-view} - -`AggregatingMergeTree` materialized view that watches the `test.visits` table: - -``` sql -CREATE MATERIALIZED VIEW test.basic -ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) -AS SELECT - CounterID, - StartDate, - sumState(Sign) AS Visits, - uniqState(UserID) AS Users -FROM test.visits -GROUP BY CounterID, StartDate; -``` - -Inserting data into the `test.visits` table. - -``` sql -INSERT INTO test.visits ... -``` - -The data are inserted in both the table and view `test.basic` that will perform the aggregation. - -To get the aggregated data, we need to execute a query such as `SELECT ... GROUP BY ...` from the view `test.basic`: - -``` sql -SELECT - StartDate, - sumMerge(Visits) AS Visits, - uniqMerge(Users) AS Users -FROM test.basic -GROUP BY StartDate -ORDER BY StartDate; -``` - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/en/engines/table_engines/mergetree_family/collapsingmergetree.md b/docs/en/engines/table_engines/mergetree_family/collapsingmergetree.md deleted file mode 100644 index 973377c0b58..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/collapsingmergetree.md +++ /dev/null @@ -1,307 +0,0 @@ ---- -toc_priority: 36 -toc_title: CollapsingMergeTree ---- - -# CollapsingMergeTree {#table_engine-collapsingmergetree} - -The engine inherits from [MergeTree](mergetree.md) and adds the logic of rows collapsing to data parts merge algorithm. - -`CollapsingMergeTree` asynchronously deletes (collapses) pairs of rows if all of the fields in a sorting key (`ORDER BY`) are equivalent excepting the particular field `Sign` which can have `1` and `-1` values. Rows without a pair are kept. For more details see the [Collapsing](#table_engine-collapsingmergetree-collapsing) section of the document. - -The engine may significantly reduce the volume of storage and increase the efficiency of `SELECT` query as a consequence. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = CollapsingMergeTree(sign) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -For a description of query parameters, see [query description](../../../sql_reference/statements/create.md). - -**CollapsingMergeTree Parameters** - -- `sign` — Name of the column with the type of row: `1` is a “state” row, `-1` is a “cancel” row. - - Column data type — `Int8`. - -**Query clauses** - -When creating a `CollapsingMergeTree` table, the same [query clauses](mergetree.md#table_engine-mergetree-creating-a-table) are required, as when creating a `MergeTree` table. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects and, if possible, switch the old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) -``` - -All of the parameters excepting `sign` have the same meaning as in `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` — “state” row, `-1` — “cancel” row. - - Column Data Type — `Int8`. - -
- -## Collapsing {#table_engine-collapsingmergetree-collapsing} - -### Data {#data} - -Consider the situation where you need to save continually changing data for some object. It sounds logical to have one row for an object and update it at any change, but update operation is expensive and slow for DBMS because it requires rewriting of the data in the storage. If you need to write data quickly, update not acceptable, but you can write the changes of an object sequentially as follows. - -Use the particular column `Sign`. If `Sign = 1` it means that the row is a state of an object, let’s call it “state” row. If `Sign = -1` it means the cancellation of the state of an object with the same attributes, let’s call it “cancel” row. - -For example, we want to calculate how much pages users checked at some site and how long they were there. At some moment we write the following row with the state of user activity: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -At some moment later we register the change of user activity and write it with the following two rows. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -The first row cancels the previous state of the object (user). It should copy the sorting key fields of the cancelled state excepting `Sign`. - -The second row contains the current state. - -As we need only the last state of user activity, the rows - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -can be deleted collapsing the invalid (old) state of an object. `CollapsingMergeTree` does this while merging of the data parts. - -Why we need 2 rows for each change read in the [Algorithm](#table_engine-collapsingmergetree-collapsing-algorithm) paragraph. - -**Peculiar properties of such approach** - -1. The program that writes the data should remember the state of an object to be able to cancel it. “Cancel” string should contain copies of the sorting key fields of the “state” string and the opposite `Sign`. It increases the initial size of storage but allows to write the data quickly. -2. Long growing arrays in columns reduce the efficiency of the engine due to load for writing. The more straightforward data, the higher the efficiency. -3. The `SELECT` results depend strongly on the consistency of object changes history. Be accurate when preparing data for inserting. You can get unpredictable results in inconsistent data, for example, negative values for non-negative metrics such as session depth. - -### Algorithm {#table_engine-collapsingmergetree-collapsing-algorithm} - -When ClickHouse merges data parts, each group of consecutive rows with the same sorting key (`ORDER BY`) is reduced to not more than two rows, one with `Sign = 1` (“state” row) and another with `Sign = -1` (“cancel” row). In other words, entries collapse. - -For each resulting data part ClickHouse saves: - -1. The first “cancel” and the last “state” rows, if the number of “state” and “cancel” rows matches and the last row is a “state” row. - -2. The last “state” row, if there are more “state” rows than “cancel” rows. - -3. The first “cancel” row, if there are more “cancel” rows than “state” rows. - -4. None of the rows, in all other cases. - -Also when there are at least 2 more “state” rows than “cancel” rows, or at least 2 more “cancel” rows then “state” rows, the merge continues, but ClickHouse treats this situation as a logical error and records it in the server log. This error can occur if the same data were inserted more than once. - -Thus, collapsing should not change the results of calculating statistics. -Changes gradually collapsed so that in the end only the last state of almost every object left. - -The `Sign` is required because the merging algorithm doesn’t guarantee that all of the rows with the same sorting key will be in the same resulting data part and even on the same physical server. ClickHouse process `SELECT` queries with multiple threads, and it can not predict the order of rows in the result. The aggregation is required if there is a need to get completely “collapsed” data from `CollapsingMergeTree` table. - -To finalize collapsing, write a query with `GROUP BY` clause and aggregate functions that account for the sign. For example, to calculate quantity, use `sum(Sign)` instead of `count()`. To calculate the sum of something, use `sum(Sign * x)` instead of `sum(x)`, and so on, and also add `HAVING sum(Sign) > 0`. - -The aggregates `count`, `sum` and `avg` could be calculated this way. The aggregate `uniq` could be calculated if an object has at least one state not collapsed. The aggregates `min` and `max` could not be calculated because `CollapsingMergeTree` does not save the values history of the collapsed states. - -If you need to extract data without aggregation (for example, to check whether rows are present whose newest values match certain conditions), you can use the `FINAL` modifier for the `FROM` clause. This approach is significantly less efficient. - -## Example Of Use {#example-of-use} - -Example data: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Creation of the table: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Insertion of the data: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) -``` - -We use two `INSERT` queries to create two different data parts. If we insert the data with one query ClickHouse creates one data part and will not perform any merge ever. - -Getting the data: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -What do we see and where is collapsing? - -With two `INSERT` queries, we created 2 data parts. The `SELECT` query was performed in 2 threads, and we got a random order of rows. Collapsing not occurred because there was no merge of the data parts yet. ClickHouse merges data part in an unknown moment which we can not predict. - -Thus we need aggregation: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration -FROM UAct -GROUP BY UserID -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -If we do not need aggregation and want to force collapsing, we can use `FINAL` modifier for `FROM` clause. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -This way of selecting the data is very inefficient. Don’t use it for big tables. - -## Example Of Another Approach {#example-of-another-approach} - -Example data: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ -5 │ -146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -The idea is that merges take into account only key fields. And in the “Cancel” line we can specify negative values that equalize the previous version of the row when summing without using the Sign column. For this approach, it is necessary to change the data type `PageViews`,`Duration` to store negative values of UInt8 -\> Int16. - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews Int16, - Duration Int16, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Let’s test the approach: - -``` sql -insert into UAct values(4324182021466249494, 5, 146, 1); -insert into UAct values(4324182021466249494, -5, -146, -1); -insert into UAct values(4324182021466249494, 6, 185, 1); - -select * from UAct final; // avoid using final in production (just for a test or small tables) -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -``` sql -SELECT - UserID, - sum(PageViews) AS PageViews, - sum(Duration) AS Duration -FROM UAct -GROUP BY UserID -```text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -``` sqk -select count() FROM UAct -``` - -``` text -┌─count()─┐ -│ 3 │ -└─────────┘ -``` - -``` sql -optimize table UAct final; - -select * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/en/engines/table_engines/mergetree_family/custom_partitioning_key.md b/docs/en/engines/table_engines/mergetree_family/custom_partitioning_key.md deleted file mode 100644 index 0d5891955a9..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/custom_partitioning_key.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -toc_priority: 32 -toc_title: Custom Partitioning Key ---- - -# Custom Partitioning Key {#custom-partitioning-key} - -Partitioning is available for the [MergeTree](mergetree.md) family tables (including [replicated](replication.md) tables). [Materialized views](../special/materializedview.md) based on MergeTree tables support partitioning, as well. - -A partition is a logical combination of records in a table by a specified criterion. You can set a partition by an arbitrary criterion, such as by month, by day, or by event type. Each partition is stored separately to simplify manipulations of this data. When accessing the data, ClickHouse uses the smallest subset of partitions possible. - -The partition is specified in the `PARTITION BY expr` clause when [creating a table](mergetree.md#table_engine-mergetree-creating-a-table). The partition key can be any expression from the table columns. For example, to specify partitioning by month, use the expression `toYYYYMM(date_column)`: - -``` sql -CREATE TABLE visits -( - VisitDate Date, - Hour UInt8, - ClientID UUID -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(VisitDate) -ORDER BY Hour; -``` - -The partition key can also be a tuple of expressions (similar to the [primary key](mergetree.md#primary-keys-and-indexes-in-queries)). For example: - -``` sql -ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) -PARTITION BY (toMonday(StartDate), EventType) -ORDER BY (CounterID, StartDate, intHash32(UserID)); -``` - -In this example, we set partitioning by the event types that occurred during the current week. - -When inserting new data to a table, this data is stored as a separate part (chunk) sorted by the primary key. In 10-15 minutes after inserting, the parts of the same partition are merged into the entire part. - -!!! info "Info" - A merge only works for data parts that have the same value for the partitioning expression. This means **you shouldn’t make overly granular partitions** (more than about a thousand partitions). Otherwise, the `SELECT` query performs poorly because of an unreasonably large number of files in the file system and open file descriptors. - -Use the [system.parts](../../../operations/system_tables.md#system_tables-parts) table to view the table parts and partitions. For example, let’s assume that we have a `visits` table with partitioning by month. Let’s perform the `SELECT` query for the `system.parts` table: - -``` sql -SELECT - partition, - name, - active -FROM system.parts -WHERE table = 'visits' -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 1 │ -│ 201902 │ 201902_11_11_0 │ 1 │ -└───────────┴────────────────┴────────┘ -``` - -The `partition` column contains the names of the partitions. There are two partitions in this example: `201901` and `201902`. You can use this column value to specify the partition name in [ALTER … PARTITION](#alter_manipulations-with-partitions) queries. - -The `name` column contains the names of the partition data parts. You can use this column to specify the name of the part in the [ALTER ATTACH PART](#alter_attach-partition) query. - -Let’s break down the name of the first part: `201901_1_3_1`: - -- `201901` is the partition name. -- `1` is the minimum number of the data block. -- `3` is the maximum number of the data block. -- `1` is the chunk level (the depth of the merge tree it is formed from). - -!!! info "Info" - The parts of old-type tables have the name: `20190117_20190123_2_2_0` (minimum date - maximum date - minimum block number - maximum block number - level). - -The `active` column shows the status of the part. `1` is active; `0` is inactive. The inactive parts are, for example, source parts remaining after merging to a larger part. The corrupted data parts are also indicated as inactive. - -As you can see in the example, there are several separated parts of the same partition (for example, `201901_1_3_1` and `201901_1_9_2`). This means that these parts are not merged yet. ClickHouse merges the inserted parts of data periodically, approximately 15 minutes after inserting. In addition, you can perform a non-scheduled merge using the [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) query. Example: - -``` sql -OPTIMIZE TABLE visits PARTITION 201902; -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 0 │ -│ 201902 │ 201902_4_11_2 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 0 │ -│ 201902 │ 201902_11_11_0 │ 0 │ -└───────────┴────────────────┴────────┘ -``` - -Inactive parts will be deleted approximately 10 minutes after merging. - -Another way to view a set of parts and partitions is to go into the directory of the table: `/var/lib/clickhouse/data///`. For example: - -``` bash -/var/lib/clickhouse/data/default/visits$ ls -l -total 40 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached -``` - -The folders ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ and so on are the directories of the parts. Each part relates to a corresponding partition and contains data just for a certain month (the table in this example has partitioning by month). - -The `detached` directory contains parts that were detached from the table using the [DETACH](#alter_detach-partition) query. The corrupted parts are also moved to this directory, instead of being deleted. The server does not use the parts from the `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql_reference/statements/alter.md#alter_attach-partition) query. - -Note that on the operating server, you cannot manually change the set of parts or their data on the file system, since the server will not know about it. For non-replicated tables, you can do this when the server is stopped, but it isn’t recommended. For replicated tables, the set of parts cannot be changed in any case. - -ClickHouse allows you to perform operations with the partitions: delete them, copy from one table to another, or create a backup. See the list of all operations in the section [Manipulations With Partitions and Parts](../../../sql_reference/statements/alter.md#alter_manipulations-with-partitions). - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/en/engines/table_engines/mergetree_family/graphitemergetree.md b/docs/en/engines/table_engines/mergetree_family/graphitemergetree.md deleted file mode 100644 index ebfdfe4685a..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/graphitemergetree.md +++ /dev/null @@ -1,172 +0,0 @@ ---- -toc_priority: 38 -toc_title: GraphiteMergeTree ---- - -# GraphiteMergeTree {#graphitemergetree} - -This engine is designed for thinning and aggregating/averaging (rollup) [Graphite](http://graphite.readthedocs.io/en/latest/index.html) data. It may be helpful to developers who want to use ClickHouse as a data store for Graphite. - -You can use any ClickHouse table engine to store the Graphite data if you don’t need rollup, but if you need a rollup use `GraphiteMergeTree`. The engine reduces the volume of storage and increases the efficiency of queries from Graphite. - -The engine inherits properties from [MergeTree](mergetree.md). - -## Creating a Table {#creating-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE = GraphiteMergeTree(config_section) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -See a detailed description of the [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) query. - -A table for the Graphite data should have the following columns for the following data: - -- Metric name (Graphite sensor). Data type: `String`. - -- Time of measuring the metric. Data type: `DateTime`. - -- Value of the metric. Data type: any numeric. - -- Version of the metric. Data type: any numeric. - - ClickHouse saves the rows with the highest version or the last written if versions are the same. Other rows are deleted during the merge of data parts. - -The names of these columns should be set in the rollup configuration. - -**GraphiteMergeTree parameters** - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -**Query clauses** - -When creating a `GraphiteMergeTree` table, the same [clauses](mergetree.md#table_engine-mergetree-creating-a-table) are required, as when creating a `MergeTree` table. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects and, if possible, switch the old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - EventDate Date, - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) -``` - -All of the parameters excepting `config_section` have the same meaning as in `MergeTree`. - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -
- -## Rollup Configuration {#rollup-configuration} - -The settings for rollup are defined by the [graphite\_rollup](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) parameter in the server configuration. The name of the parameter could be any. You can create several configurations and use them for different tables. - -Rollup configuration structure: - - required-columns - patterns - -### Required Columns {#required-columns} - -- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. -- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. -- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Default value: `Value`. -- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. - -### Patterns {#patterns} - -Structure of the `patterns` section: - -``` text -pattern - regexp - function -pattern - regexp - age + precision - ... -pattern - regexp - function - age + precision - ... -pattern - ... -default - function - age + precision - ... -``` - -!!! warning "Attention" - Patterns must be strictly ordered: - - 1. Patterns without `function` or `retention`. - 1. Patterns with both `function` and `retention`. - 1. Pattern `default`. - -When processing a row, ClickHouse checks the rules in the `pattern` sections. Each of `pattern` (including `default`) sections can contain `function` parameter for aggregation, `retention` parameters or both. If the metric name matches the `regexp`, the rules from the `pattern` section (or sections) are applied; otherwise, the rules from the `default` section are used. - -Fields for `pattern` and `default` sections: - -- `regexp`– A pattern for the metric name. -- `age` – The minimum age of the data in seconds. -- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). -- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. - -### Configuration Example {#configuration-example} - -``` xml - - Version - - click_cost - any - - 0 - 5 - - - 86400 - 60 - - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/en/engines/table_engines/mergetree_family/index.md b/docs/en/engines/table_engines/mergetree_family/index.md deleted file mode 100644 index 6a23ef23a8e..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: MergeTree Family -toc_priority: 28 ---- - diff --git a/docs/en/engines/table_engines/mergetree_family/mergetree.md b/docs/en/engines/table_engines/mergetree_family/mergetree.md deleted file mode 100644 index d7b624fa2f7..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/mergetree.md +++ /dev/null @@ -1,652 +0,0 @@ ---- -toc_priority: 30 -toc_title: MergeTree ---- - -# MergeTree {#table_engines-mergetree} - -The `MergeTree` engine and other engines of this family (`*MergeTree`) are the most robust ClickHouse table engines. - -Engines in the `MergeTree` family are designed for inserting a very large amount of data into a table. The data is quickly written to the table part by part, then rules are applied for merging the parts in the background. This method is much more efficient than continually rewriting the data in storage during insert. - -Main features: - -- Stores data sorted by primary key. - - This allows you to create a small sparse index that helps find data faster. - -- Partitions can be used if the [partitioning key](custom_partitioning_key.md) is specified. - - ClickHouse supports certain operations with partitions that are more effective than general operations on the same data with the same result. ClickHouse also automatically cuts off the partition data where the partitioning key is specified in the query. This also improves query performance. - -- Data replication support. - - The family of `ReplicatedMergeTree` tables provides data replication. For more information, see [Data replication](replication.md). - -- Data sampling support. - - If necessary, you can set the data sampling method in the table. - -!!! info "Info" - The [Merge](../special/merge.md) engine does not belong to the `*MergeTree` family. - -## Creating a Table {#table_engine-mergetree-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... - INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, - INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 -) ENGINE = MergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] -[SETTINGS name=value, ...] -``` - -For a description of parameters, see the [CREATE query description](../../../sql_reference/statements/create.md). - -!!! note "Note" - `INDEX` is an experimental feature, see [Data Skipping Indexes](#table_engine-mergetree-data_skipping-indexes). - -### Query Clauses {#mergetree-query-clauses} - -- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. The `MergeTree` engine does not have parameters. - -- `PARTITION BY` — The [partitioning key](custom_partitioning_key.md). - - For partitioning by month, use the `toYYYYMM(date_column)` expression, where `date_column` is a column with a date of the type [Date](../../../sql_reference/data_types/date.md). The partition names here have the `"YYYYMM"` format. - -- `ORDER BY` — The sorting key. - - A tuple of columns or arbitrary expressions. Example: `ORDER BY (CounterID, EventDate)`. - -- `PRIMARY KEY` — The primary key if it [differs from the sorting key](#choosing-a-primary-key-that-differs-from-the-sorting-key). - - By default the primary key is the same as the sorting key (which is specified by the `ORDER BY` clause). Thus in most cases it is unnecessary to specify a separate `PRIMARY KEY` clause. - -- `SAMPLE BY` — An expression for sampling. - - If a sampling expression is used, the primary key must contain it. Example: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. - -- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [between disks and volumes](#table_engine-mergetree-multiple-volumes). - - Expression must have one `Date` or `DateTime` column as a result. Example: - `TTL date + INTERVAL 1 DAY` - - Type of the rule `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` specifies an action to be done with the part if the expression is satisfied (reaches current time): removal of expired rows, moving a part (if expression is satisfied for all rows in a part) to specified disk (`TO DISK 'xxx'`) or to volume (`TO VOLUME 'xxx'`). Default type of the rule is removal (`DELETE`). List of multiple rules can specified, but there should be no more than one `DELETE` rule. - - For more details, see [TTL for columns and tables](#table_engine-mergetree-ttl) - -- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: - - - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Data Storage](#mergetree-data-storage). - - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Data Storage](#mergetree-data-storage). - - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` setting. Before version 19.11, there was only the `index_granularity` setting for restricting granule size. The `index_granularity_bytes` setting improves ClickHouse performance when selecting data from tables with big rows (tens and hundreds of megabytes). If you have tables with big rows, you can enable this setting for the tables to improve the efficiency of `SELECT` queries. - - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, then ZooKeeper stores less data. For more information, see the [setting description](../../../operations/server_configuration_parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) in “Server configuration parameters”. - - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` bytes, ClickHouse reads and writes the data to the storage disk using the direct I/O interface (`O_DIRECT` option). If `min_merge_bytes_to_use_direct_io = 0`, then direct I/O is disabled. Default value: `10 * 1024 * 1024 * 1024` bytes. - - - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). - - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don’t turn it off. - - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. - - `storage_policy` — Storage policy. See [Using Multiple Block Devices for Data Storage](#table_engine-mergetree-multiple-volumes). - -**Example of Sections Setting** - -``` sql -ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 -``` - -In the example, we set partitioning by month. - -We also set an expression for sampling as a hash by the user ID. This allows you to pseudorandomize the data in the table for each `CounterID` and `EventDate`. If you define a [SAMPLE](../../../sql_reference/statements/select.md#select-sample-clause) clause when selecting the data, ClickHouse will return an evenly pseudorandom data sample for a subset of users. - -The `index_granularity` setting can be omitted because 8192 is the default value. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects. If possible, switch old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -**MergeTree() Parameters** - -- `date-column` — The name of a column of the [Date](../../../sql_reference/data_types/date.md) type. ClickHouse automatically creates partitions by month based on this column. The partition names are in the `"YYYYMM"` format. -- `sampling_expression` — An expression for sampling. -- `(primary, key)` — Primary key. Type: [Tuple()](../../../sql_reference/data_types/tuple.md) -- `index_granularity` — The granularity of an index. The number of data rows between the “marks” of an index. The value 8192 is appropriate for most tasks. - -**Example** - -``` sql -MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) -``` - -The `MergeTree` engine is configured in the same way as in the example above for the main engine configuration method. -
- -## Data Storage {#mergetree-data-storage} - -A table consists of data parts sorted by primary key. - -When data is inserted in a table, separate data parts are created and each of them is lexicographically sorted by primary key. For example, if the primary key is `(CounterID, Date)`, the data in the part is sorted by `CounterID`, and within each `CounterID`, it is ordered by `Date`. - -Data belonging to different partitions are separated into different parts. In the background, ClickHouse merges data parts for more efficient storage. Parts belonging to different partitions are not merged. The merge mechanism does not guarantee that all rows with the same primary key will be in the same data part. - -Each data part is logically divided into granules. A granule is the smallest indivisible data set that ClickHouse reads when selecting data. ClickHouse doesn’t split rows or values, so each granule always contains an integer number of rows. The first row of a granule is marked with the value of the primary key for the row. For each data part, ClickHouse creates an index file that stores the marks. For each column, whether it’s in the primary key or not, ClickHouse also stores the same marks. These marks let you find data directly in column files. - -The granule size is restricted by the `index_granularity` and `index_granularity_bytes` settings of the table engine. The number of rows in a granule lays in the `[1, index_granularity]` range, depending on the size of the rows. The size of a granule can exceed `index_granularity_bytes` if the size of a single row is greater than the value of the setting. In this case, the size of the granule equals the size of the row. - -## Primary Keys and Indexes In Queries {#primary-keys-and-indexes-in-queries} - -Take the `(CounterID, Date)` primary key as an example. In this case, the sorting and index can be illustrated as follows: - - Whole data: [---------------------------------------------] - CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] - Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] - Marks: | | | | | | | | | | | - a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 - Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 - -If the data query specifies: - -- `CounterID in ('a', 'h')`, the server reads the data in the ranges of marks `[0, 3)` and `[6, 8)`. -- `CounterID IN ('a', 'h') AND Date = 3`, the server reads the data in the ranges of marks `[1, 3)` and `[7, 8)`. -- `Date = 3`, the server reads the data in the range of marks `[1, 10]`. - -The examples above show that it is always more effective to use an index than a full scan. - -A sparse index allows extra data to be read. When reading a single range of the primary key, up to `index_granularity * 2` extra rows in each data block can be read. - -Sparse indexes allow you to work with a very large number of table rows, because in most cases, such indexes fit in the computer’s RAM. - -ClickHouse does not require a unique primary key. You can insert multiple rows with the same primary key. - -### Selecting the Primary Key {#selecting-the-primary-key} - -The number of columns in the primary key is not explicitly limited. Depending on the data structure, you can include more or fewer columns in the primary key. This may: - -- Improve the performance of an index. - - If the primary key is `(a, b)`, then adding another column `c` will improve the performance if the following conditions are met: - - - There are queries with a condition on column `c`. - - Long data ranges (several times longer than the `index_granularity`) with identical values for `(a, b)` are common. In other words, when adding another column allows you to skip quite long data ranges. - -- Improve data compression. - - ClickHouse sorts data by primary key, so the higher the consistency, the better the compression. - -- Provide additional logic when merging data parts in the [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) and [SummingMergeTree](summingmergetree.md) engines. - - In this case it makes sense to specify the *sorting key* that is different from the primary key. - -A long primary key will negatively affect the insert performance and memory consumption, but extra columns in the primary key do not affect ClickHouse performance during `SELECT` queries. - -### Choosing a Primary Key That Differs From the Sorting Key {#choosing-a-primary-key-that-differs-from-the-sorting-key} - -It is possible to specify a primary key (an expression with values that are written in the index file for each mark) that is different from the sorting key (an expression for sorting the rows in data parts). In this case the primary key expression tuple must be a prefix of the sorting key expression tuple. - -This feature is helpful when using the [SummingMergeTree](summingmergetree.md) and -[AggregatingMergeTree](aggregatingmergetree.md) table engines. In a common case when using these engines, the table has two types of columns: *dimensions* and *measures*. Typical queries aggregate values of measure columns with arbitrary `GROUP BY` and filtering by dimensions. Because SummingMergeTree and AggregatingMergeTree aggregate rows with the same value of the sorting key, it is natural to add all dimensions to it. As a result, the key expression consists of a long list of columns and this list must be frequently updated with newly added dimensions. - -In this case it makes sense to leave only a few columns in the primary key that will provide efficient range scans and add the remaining dimension columns to the sorting key tuple. - -[ALTER](../../../sql_reference/statements/alter.md) of the sorting key is a lightweight operation because when a new column is simultaneously added to the table and to the sorting key, existing data parts don’t need to be changed. Since the old sorting key is a prefix of the new sorting key and there is no data in the newly added column, the data is sorted by both the old and new sorting keys at the moment of table modification. - -### Use Of Indexes and Partitions In Queries {#use-of-indexes-and-partitions-in-queries} - -For `SELECT` queries, ClickHouse analyzes whether an index can be used. An index can be used if the `WHERE/PREWHERE` clause has an expression (as one of the conjunction elements, or entirely) that represents an equality or inequality comparison operation, or if it has `IN` or `LIKE` with a fixed prefix on columns or expressions that are in the primary key or partitioning key, or on certain partially repetitive functions of these columns, or logical relationships of these expressions. - -Thus, it is possible to quickly run queries on one or many ranges of the primary key. In this example, queries will be fast when run for a specific tracking tag, for a specific tag and date range, for a specific tag and date, for multiple tags with a date range, and so on. - -Let’s look at the engine configured as follows: - - ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 - -In this case, in queries: - -``` sql -SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 -SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) -SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) -``` - -ClickHouse will use the primary key index to trim improper data and the monthly partitioning key to trim partitions that are in improper date ranges. - -The queries above show that the index is used even for complex expressions. Reading from the table is organized so that using the index can’t be slower than a full scan. - -In the example below, the index can’t be used. - -``` sql -SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' -``` - -To check whether ClickHouse can use the index when running a query, use the settings [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) and [force\_primary\_key](../../../operations/settings/settings.md). - -The key for partitioning by month allows reading only those data blocks which contain dates from the proper range. In this case, the data block may contain data for many dates (up to an entire month). Within a block, data is sorted by primary key, which might not contain the date as the first column. Because of this, using a query with only a date condition that does not specify the primary key prefix will cause more data to be read than for a single date. - -### Use Of Index For Partially-monotonic Primary Keys {#use-of-index-for-partially-monotonic-primary-keys} - -Consider, for example, the days of the month. They form a [monotonic sequence](https://en.wikipedia.org/wiki/Monotonic_function) for one month, but not monotonic for more extended periods. This is a partially-monotonic sequence. If a user creates the table with partially-monotonic primary key, ClickHouse creates a sparse index as usual. When a user selects data from this kind of table, ClickHouse analyzes the query conditions. If the user wants to get data between two marks of the index and both these marks fall within one month, ClickHouse can use the index in this particular case because it can calculate the distance between the parameters of a query and index marks. - -ClickHouse cannot use an index if the values of the primary key in the query parameter range don’t represent a monotonic sequence. In this case, ClickHouse uses the full scan method. - -ClickHouse uses this logic not only for days of the month sequences, but for any primary key that represents a partially-monotonic sequence. - -### Data Skipping Indexes (experimental) {#table_engine-mergetree-data_skipping-indexes} - -The index declaration is in the columns section of the `CREATE` query. - -``` sql -INDEX index_name expr TYPE type(...) GRANULARITY granularity_value -``` - -For tables from the `*MergeTree` family, data skipping indices can be specified. - -These indices aggregate some information about the specified expression on blocks, which consist of `granularity_value` granules (the size of the granule is specified using the `index_granularity` setting in the table engine). Then these aggregates are used in `SELECT` queries for reducing the amount of data to read from the disk by skipping big blocks of data where the `where` query cannot be satisfied. - -**Example** - -``` sql -CREATE TABLE table_name -( - u64 UInt64, - i32 Int32, - s String, - ... - INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, - INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 -) ENGINE = MergeTree() -... -``` - -Indices from the example can be used by ClickHouse to reduce the amount of data to read from disk in the following queries: - -``` sql -SELECT count() FROM table WHERE s < 'z' -SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 -``` - -#### Available Types Of Indices {#available-types-of-indices} - -- `minmax` - - Stores extremes of the specified expression (if the expression is `tuple`, then it stores extremes for each element of `tuple`), uses stored info for skipping blocks of data like the primary key. - -- `set(max_rows)` - - Stores unique values of the specified expression (no more than `max_rows` rows, `max_rows=0` means “no limits”). Uses the values to check if the `WHERE` expression is not satisfiable on a block of data. - -- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Stores a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) that contains all ngrams from a block of data. Works only with strings. Can be used for optimization of `equals`, `like` and `in` expressions. - - - `n` — ngram size, - - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). - - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. - - `random_seed` — The seed for Bloom filter hash functions. - -- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - The same as `ngrambf_v1`, but stores tokens instead of ngrams. Tokens are sequences separated by non-alphanumeric characters. - -- `bloom_filter([false_positive])` — Stores a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) for the specified columns. - - The optional `false_positive` parameter is the probability of receiving a false positive response from the filter. Possible values: (0, 1). Default value: 0.025. - - Supported data types: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. - - The following functions can use it: [equals](../../../sql_reference/functions/comparison_functions.md), [notEquals](../../../sql_reference/functions/comparison_functions.md), [in](../../../sql_reference/functions/in_functions.md), [notIn](../../../sql_reference/functions/in_functions.md), [has](../../../sql_reference/functions/array_functions.md). - - - -``` sql -INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 -INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 -INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 -``` - -#### Functions Support {#functions-support} - -Conditions in the `WHERE` clause contains calls of the functions that operate with columns. If the column is a part of an index, ClickHouse tries to use this index when performing the functions. ClickHouse supports different subsets of functions for using indexes. - -The `set` index can be used with all functions. Function subsets for other indexes are shown in the table below. - -| Function (operator) / Index | primary key | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | -|------------------------------------------------------------------|---------|------|---------|---------|---------| -| [equals (=, ==)](../../../sql_reference/functions/comparison_functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notEquals(!=, \<\>)](../../../sql_reference/functions/comparison_functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [like](../../../sql_reference/functions/string_search_functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [notLike](../../../sql_reference/functions/string_search_functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [startsWith](../../../sql_reference/functions/string_functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | -| [endsWith](../../../sql_reference/functions/string_functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | -| [multiSearchAny](../../../sql_reference/functions/string_search_functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | -| [in](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notIn](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [less (\<)](../../../sql_reference/functions/comparison_functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [greater (\>)](../../../sql_reference/functions/comparison_functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [lessOrEquals (\<=)](../../../sql_reference/functions/comparison_functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [greaterOrEquals (\>=)](../../../sql_reference/functions/comparison_functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [empty](../../../sql_reference/functions/array_functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [notEmpty](../../../sql_reference/functions/array_functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | - -Functions with a constant argument that is less than ngram size can’t be used by `ngrambf_v1` for query optimization. - -Bloom filters can have false positive matches, so the `ngrambf_v1`, `tokenbf_v1`, and `bloom_filter` indexes can’t be used for optimizing queries where the result of a function is expected to be false, for example: - -- Can be optimized: - - `s LIKE '%test%'` - - `NOT s NOT LIKE '%test%'` - - `s = 1` - - `NOT s != 1` - - `startsWith(s, 'test')` -- Can’t be optimized: - - `NOT s LIKE '%test%'` - - `s NOT LIKE '%test%'` - - `NOT s = 1` - - `s != 1` - - `NOT startsWith(s, 'test')` - -## Concurrent Data Access {#concurrent-data-access} - -For concurrent table access, we use multi-versioning. In other words, when a table is simultaneously read and updated, data is read from a set of parts that is current at the time of the query. There are no lengthy locks. Inserts do not get in the way of read operations. - -Reading from a table is automatically parallelized. - -## TTL For Columns and Tables {#table_engine-mergetree-ttl} - -Determines the lifetime of values. - -The `TTL` clause can be set for the whole table and for each individual column. Table-level TTL can also specify logic of automatic move of data between disks and volumes. - -Expressions must evaluate to [Date](../../../sql_reference/data_types/date.md) or [DateTime](../../../sql_reference/data_types/datetime.md) data type. - -Example: - -``` sql -TTL time_column -TTL time_column + interval -``` - -To define `interval`, use [time interval](../../../sql_reference/operators.md#operators-datetime) operators. - -``` sql -TTL date_time + INTERVAL 1 MONTH -TTL date_time + INTERVAL 15 HOUR -``` - -### Column TTL {#mergetree-column-ttl} - -When the values in the column expire, ClickHouse replaces them with the default values for the column data type. If all the column values in the data part expire, ClickHouse deletes this column from the data part in a filesystem. - -The `TTL` clause can’t be used for key columns. - -Examples: - -Creating a table with TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int TTL d + INTERVAL 1 MONTH, - b Int TTL d + INTERVAL 1 MONTH, - c String -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d; -``` - -Adding TTL to a column of an existing table - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 DAY; -``` - -Altering TTL of the column - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 MONTH; -``` - -### Table TTL {#mergetree-table-ttl} - -Table can have an expression for removal of expired rows, and multiple expressions for automatic move of parts between [disks or volumes](#table_engine-mergetree-multiple-volumes). When rows in the table expire, ClickHouse deletes all corresponding rows. For parts moving feature, all rows of a part must satisfy the movement expression criteria. - -``` sql -TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... -``` - -Type of TTL rule may follow each TTL expression. It affects an action which is to be done once the expression is satisfied (reaches current time): - -- `DELETE` - delete expired rows (default action); -- `TO DISK 'aaa'` - move part to the disk `aaa`; -- `TO VOLUME 'bbb'` - move part to the disk `bbb`. - -Examples: - -Creating a table with TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d -TTL d + INTERVAL 1 MONTH [DELETE], - d + INTERVAL 1 WEEK TO VOLUME 'aaa', - d + INTERVAL 2 WEEK TO DISK 'bbb'; -``` - -Altering TTL of the table - -``` sql -ALTER TABLE example_table - MODIFY TTL d + INTERVAL 1 DAY; -``` - -**Removing Data** - -Data with an expired TTL is removed when ClickHouse merges data parts. - -When ClickHouse see that data is expired, it performs an off-schedule merge. To control the frequency of such merges, you can set [merge\_with\_ttl\_timeout](#mergetree_setting-merge_with_ttl_timeout). If the value is too low, it will perform many off-schedule merges that may consume a lot of resources. - -If you perform the `SELECT` query between merges, you may get expired data. To avoid it, use the [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) query before `SELECT`. - -## Using Multiple Block Devices For Data Storage {#table_engine-mergetree-multiple-volumes} - -### Introduction {#introduction} - -`MergeTree` family table engines can store data on multiple block devices. For example, it can be useful when the data of a certain table are implicitly split into “hot” and “cold”. The most recent data is regularly requested but requires only a small amount of space. On the contrary, the fat-tailed historical data is requested rarely. If several disks are available, the “hot” data may be located on fast disks (for example, NVMe SSDs or in memory), while the “cold” data - on relatively slow ones (for example, HDD). - -Data part is the minimum movable unit for `MergeTree`-engine tables. The data belonging to one part are stored on one disk. Data parts can be moved between disks in the background (according to user settings) as well as by means of the [ALTER](../../../sql_reference/statements/alter.md#alter_move-partition) queries. - -### Terms {#terms} - -- Disk — Block device mounted to the filesystem. -- Default disk — Disk that stores the path specified in the [path](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) server setting. -- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). -- Storage policy — Set of volumes and the rules for moving data between them. - -The names given to the described entities can be found in the system tables, [system.storage\_policies](../../../operations/system_tables.md#system_tables-storage_policies) and [system.disks](../../../operations/system_tables.md#system_tables-disks). To apply one of the configured storage policies for a table, use the `storage_policy` setting of `MergeTree`-engine family tables. - -### Configuration {#table_engine-mergetree-multiple-volumes-configure} - -Disks, volumes and storage policies should be declared inside the `` tag either in the main file `config.xml` or in a distinct file in the `config.d` directory. - -Configuration structure: - -``` xml - - - - /mnt/fast_ssd/clickhouse/ - - - /mnt/hdd1/clickhouse/ - 10485760 - - - /mnt/hdd2/clickhouse/ - 10485760 - - - ... - - - ... - -``` - -Tags: - -- `` — Disk name. Names must be different for all disks. -- `path` — path under which a server will store data (`data` and `shadow` folders), should be terminated with ‘/’. -- `keep_free_space_bytes` — the amount of free disk space to be reserved. - -The order of the disk definition is not important. - -Storage policies configuration markup: - -``` xml - - ... - - - - - disk_name_from_disks_configuration - 1073741824 - - - - - - - 0.2 - - - - - - - - ... - -``` - -Tags: - -- `policy_name_N` — Policy name. Policy names must be unique. -- `volume_name_N` — Volume name. Volume names must be unique. -- `disk` — a disk within a volume. -- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume’s disks. -- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). - -Cofiguration examples: - -``` xml - - ... - - - - - disk1 - disk2 - - - - - - - - fast_ssd - 1073741824 - - - disk1 - - - 0.2 - - - ... - -``` - -In given example, the `hdd_in_order` policy implements the [round-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) approach. Thus this policy defines only one volume (`single`), the data parts are stored on all its disks in circular order. Such policy can be quite useful if there are several similar disks are mounted to the system, but RAID is not configured. Keep in mind that each individual disk drive is not reliable and you might want to compensate it with replication factor of 3 or more. - -If there are different kinds of disks available in the system, `moving_from_ssd_to_hdd` policy can be used instead. The volume `hot` consists of an SSD disk (`fast_ssd`), and the maximum size of a part that can be stored on this volume is 1GB. All the parts with the size larger than 1GB will be stored directly on the `cold` volume, which contains an HDD disk `disk1`. -Also, once the disk `fast_ssd` gets filled by more than 80%, data will be transferred to the `disk1` by a background process. - -The order of volume enumeration within a storage policy is important. Once a volume is overfilled, data are moved to the next one. The order of disk enumeration is important as well because data are stored on them in turns. - -When creating a table, one can apply one of the configured storage policies to it: - -``` sql -CREATE TABLE table_with_non_default_policy ( - EventDate Date, - OrderID UInt64, - BannerID UInt64, - SearchPhrase String -) ENGINE = MergeTree -ORDER BY (OrderID, BannerID) -PARTITION BY toYYYYMM(EventDate) -SETTINGS storage_policy = 'moving_from_ssd_to_hdd' -``` - -The `default` storage policy implies using only one volume, which consists of only one disk given in ``. Once a table is created, its storage policy cannot be changed. - -### Details {#details} - -In the case of `MergeTree` tables, data is getting to disk in different ways: - -- As a result of an insert (`INSERT` query). -- During background merges and [mutations](../../../sql_reference/statements/alter.md#alter-mutations). -- When downloading from another replica. -- As a result of partition freezing [ALTER TABLE … FREEZE PARTITION](../../../sql_reference/statements/alter.md#alter_freeze-partition). - -In all these cases except for mutations and partition freezing, a part is stored on a volume and a disk according to the given storage policy: - -1. The first volume (in the order of definition) that has enough disk space for storing a part (`unreserved_space > current_part_size`) and allows for storing parts of a given size (`max_data_part_size_bytes > current_part_size`) is chosen. -2. Within this volume, that disk is chosen that follows the one, which was used for storing the previous chunk of data, and that has free space more than the part size (`unreserved_space - keep_free_space_bytes > current_part_size`). - -Under the hood, mutations and partition freezing make use of [hard links](https://en.wikipedia.org/wiki/Hard_link). Hard links between different disks are not supported, therefore in such cases the resulting parts are stored on the same disks as the initial ones. - -In the background, parts are moved between volumes on the basis of the amount of free space (`move_factor` parameter) according to the order the volumes are declared in the configuration file. -Data is never transferred from the last one and into the first one. One may use system tables [system.part\_log](../../../operations/system_tables.md#system_tables-part-log) (field `type = MOVE_PART`) and [system.parts](../../../operations/system_tables.md#system_tables-parts) (fields `path` and `disk`) to monitor background moves. Also, the detailed information can be found in server logs. - -User can force moving a part or a partition from one volume to another using the query [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql_reference/statements/alter.md#alter_move-partition), all the restrictions for background operations are taken into account. The query initiates a move on its own and does not wait for background operations to be completed. User will get an error message if not enough free space is available or if any of the required conditions are not met. - -Moving data does not interfere with data replication. Therefore, different storage policies can be specified for the same table on different replicas. - -After the completion of background merges and mutations, old parts are removed only after a certain amount of time (`old_parts_lifetime`). -During this time, they are not moved to other volumes or disks. Therefore, until the parts are finally removed, they are still taken into account for evaluation of the occupied disk space. - -[Original article](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/en/engines/table_engines/mergetree_family/replacingmergetree.md b/docs/en/engines/table_engines/mergetree_family/replacingmergetree.md deleted file mode 100644 index 7fbd4edec68..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/replacingmergetree.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -toc_priority: 33 -toc_title: ReplacingMergeTree ---- - -# ReplacingMergeTree {#replacingmergetree} - -The engine differs from [MergeTree](mergetree.md#table_engines-mergetree) in that it removes duplicate entries with the same primary key value (or more accurately, with the same [sorting key](mergetree.md) value). - -Data deduplication occurs only during a merge. Merging occurs in the background at an unknown time, so you can’t plan for it. Some of the data may remain unprocessed. Although you can run an unscheduled merge using the `OPTIMIZE` query, don’t count on using it, because the `OPTIMIZE` query will read and write a large amount of data. - -Thus, `ReplacingMergeTree` is suitable for clearing out duplicate data in the background in order to save space, but it doesn’t guarantee the absence of duplicates. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = ReplacingMergeTree([ver]) -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -For a description of request parameters, see [request description](../../../sql_reference/statements/create.md). - -**ReplacingMergeTree Parameters** - -- `ver` — column with version. Type `UInt*`, `Date` or `DateTime`. Optional parameter. - - When merging, `ReplacingMergeTree` from all the rows with the same primary key leaves only one: - - - Last in the selection, if `ver` not set. - - With the maximum version, if `ver` specified. - -**Query clauses** - -When creating a `ReplacingMergeTree` table the same [clauses](mergetree.md) are required, as when creating a `MergeTree` table. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects and, if possible, switch the old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) -``` - -All of the parameters excepting `ver` have the same meaning as in `MergeTree`. - -- `ver` - column with the version. Optional parameter. For a description, see the text above. - -
- -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/en/engines/table_engines/mergetree_family/replication.md b/docs/en/engines/table_engines/mergetree_family/replication.md deleted file mode 100644 index 9de68fdb9ed..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/replication.md +++ /dev/null @@ -1,216 +0,0 @@ ---- -toc_priority: 31 -toc_title: Data Replication ---- - -# Data Replication {#table_engines-replication} - -Replication is only supported for tables in the MergeTree family: - -- ReplicatedMergeTree -- ReplicatedSummingMergeTree -- ReplicatedReplacingMergeTree -- ReplicatedAggregatingMergeTree -- ReplicatedCollapsingMergeTree -- ReplicatedVersionedCollapsingMergeTree -- ReplicatedGraphiteMergeTree - -Replication works at the level of an individual table, not the entire server. A server can store both replicated and non-replicated tables at the same time. - -Replication does not depend on sharding. Each shard has its own independent replication. - -Compressed data for `INSERT` and `ALTER` queries is replicated (for more information, see the documentation for [ALTER](../../../sql_reference/statements/alter.md#query_language_queries_alter)). - -`CREATE`, `DROP`, `ATTACH`, `DETACH` and `RENAME` queries are executed on a single server and are not replicated: - -- The `CREATE TABLE` query creates a new replicatable table on the server where the query is run. If this table already exists on other servers, it adds a new replica. -- The `DROP TABLE` query deletes the replica located on the server where the query is run. -- The `RENAME` query renames the table on one of the replicas. In other words, replicated tables can have different names on different replicas. - -ClickHouse uses [Apache ZooKeeper](https://zookeeper.apache.org) for storing replicas meta information. Use ZooKeeper version 3.4.5 or newer. - -To use replication, set parameters in the [zookeeper](../../../operations/server_configuration_parameters/settings.md#server-settings_zookeeper) server configuration section. - -!!! attention "Attention" - Don’t neglect the security setting. ClickHouse supports the `digest` [ACL scheme](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) of the ZooKeeper security subsystem. - -Example of setting the addresses of the ZooKeeper cluster: - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - - example3 - 2181 - - -``` - -You can specify any existing ZooKeeper cluster and the system will use a directory on it for its own data (the directory is specified when creating a replicatable table). - -If ZooKeeper isn’t set in the config file, you can’t create replicated tables, and any existing replicated tables will be read-only. - -ZooKeeper is not used in `SELECT` queries because replication does not affect the performance of `SELECT` and queries run just as fast as they do for non-replicated tables. When querying distributed replicated tables, ClickHouse behavior is controlled by the settings [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) and [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). - -For each `INSERT` query, approximately ten entries are added to ZooKeeper through several transactions. (To be more precise, this is for each inserted block of data; an INSERT query contains one block or one block per `max_insert_block_size = 1048576` rows.) This leads to slightly longer latencies for `INSERT` compared to non-replicated tables. But if you follow the recommendations to insert data in batches of no more than one `INSERT` per second, it doesn’t create any problems. The entire ClickHouse cluster used for coordinating one ZooKeeper cluster has a total of several hundred `INSERTs` per second. The throughput on data inserts (the number of rows per second) is just as high as for non-replicated data. - -For very large clusters, you can use different ZooKeeper clusters for different shards. However, this hasn’t proven necessary on the Yandex.Metrica cluster (approximately 300 servers). - -Replication is asynchronous and multi-master. `INSERT` queries (as well as `ALTER`) can be sent to any available server. Data is inserted on the server where the query is run, and then it is copied to the other servers. Because it is asynchronous, recently inserted data appears on the other replicas with some latency. If part of the replicas are not available, the data is written when they become available. If a replica is available, the latency is the amount of time it takes to transfer the block of compressed data over the network. - -By default, an INSERT query waits for confirmation of writing the data from only one replica. If the data was successfully written to only one replica and the server with this replica ceases to exist, the stored data will be lost. To enable getting confirmation of data writes from multiple replicas, use the `insert_quorum` option. - -Each block of data is written atomically. The INSERT query is divided into blocks up to `max_insert_block_size = 1048576` rows. In other words, if the `INSERT` query has less than 1048576 rows, it is made atomically. - -Data blocks are deduplicated. For multiple writes of the same data block (data blocks of the same size containing the same rows in the same order), the block is only written once. The reason for this is in case of network failures when the client application doesn’t know if the data was written to the DB, so the `INSERT` query can simply be repeated. It doesn’t matter which replica INSERTs were sent to with identical data. `INSERTs` are idempotent. Deduplication parameters are controlled by [merge\_tree](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-merge_tree) server settings. - -During replication, only the source data to insert is transferred over the network. Further data transformation (merging) is coordinated and performed on all the replicas in the same way. This minimizes network usage, which means that replication works well when replicas reside in different datacenters. (Note that duplicating data in different datacenters is the main goal of replication.) - -You can have any number of replicas of the same data. Yandex.Metrica uses double replication in production. Each server uses RAID-5 or RAID-6, and RAID-10 in some cases. This is a relatively reliable and convenient solution. - -The system monitors data synchronicity on replicas and is able to recover after a failure. Failover is automatic (for small differences in data) or semi-automatic (when data differs too much, which may indicate a configuration error). - -## Creating Replicated Tables {#creating-replicated-tables} - -The `Replicated` prefix is added to the table engine name. For example:`ReplicatedMergeTree`. - -**Replicated\*MergeTree parameters** - -- `zoo_path` — The path to the table in ZooKeeper. -- `replica_name` — The replica name in ZooKeeper. - -Example: - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -``` - -
- -Example in deprecated syntax - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) -``` - -
- -As the example shows, these parameters can contain substitutions in curly brackets. The substituted values are taken from the ‘macros’ section of the configuration file. Example: - -``` xml - - 05 - 02 - example05-02-1.yandex.ru - -``` - -The path to the table in ZooKeeper should be unique for each replicated table. Tables on different shards should have different paths. -In this case, the path consists of the following parts: - -`/clickhouse/tables/` is the common prefix. We recommend using exactly this one. - -`{layer}-{shard}` is the shard identifier. In this example it consists of two parts, since the Yandex.Metrica cluster uses bi-level sharding. For most tasks, you can leave just the {shard} substitution, which will be expanded to the shard identifier. - -`table_name` is the name of the node for the table in ZooKeeper. It is a good idea to make it the same as the table name. It is defined explicitly, because in contrast to the table name, it doesn’t change after a RENAME query. -*HINT*: you could add a database name in front of `table_name` as well. E.g. `db_name.table_name` - -The replica name identifies different replicas of the same table. You can use the server name for this, as in the example. The name only needs to be unique within each shard. - -You can define the parameters explicitly instead of using substitutions. This might be convenient for testing and for configuring small clusters. However, you can’t use distributed DDL queries (`ON CLUSTER`) in this case. - -When working with large clusters, we recommend using substitutions because they reduce the probability of error. - -Run the `CREATE TABLE` query on each replica. This query creates a new replicated table, or adds a new replica to an existing one. - -If you add a new replica after the table already contains some data on other replicas, the data will be copied from the other replicas to the new one after running the query. In other words, the new replica syncs itself with the others. - -To delete a replica, run `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. - -## Recovery After Failures {#recovery-after-failures} - -If ZooKeeper is unavailable when a server starts, replicated tables switch to read-only mode. The system periodically attempts to connect to ZooKeeper. - -If ZooKeeper is unavailable during an `INSERT`, or an error occurs when interacting with ZooKeeper, an exception is thrown. - -After connecting to ZooKeeper, the system checks whether the set of data in the local file system matches the expected set of data (ZooKeeper stores this information). If there are minor inconsistencies, the system resolves them by syncing data with the replicas. - -If the system detects broken data parts (with the wrong size of files) or unrecognized parts (parts written to the file system but not recorded in ZooKeeper), it moves them to the `detached` subdirectory (they are not deleted). Any missing parts are copied from the replicas. - -Note that ClickHouse does not perform any destructive actions such as automatically deleting a large amount of data. - -When the server starts (or establishes a new session with ZooKeeper), it only checks the quantity and sizes of all files. If the file sizes match but bytes have been changed somewhere in the middle, this is not detected immediately, but only when attempting to read the data for a `SELECT` query. The query throws an exception about a non-matching checksum or size of a compressed block. In this case, data parts are added to the verification queue and copied from the replicas if necessary. - -If the local set of data differs too much from the expected one, a safety mechanism is triggered. The server enters this in the log and refuses to launch. The reason for this is that this case may indicate a configuration error, such as if a replica on a shard was accidentally configured like a replica on a different shard. However, the thresholds for this mechanism are set fairly low, and this situation might occur during normal failure recovery. In this case, data is restored semi-automatically - by “pushing a button”. - -To start recovery, create the node `/path_to_table/replica_name/flags/force_restore_data` in ZooKeeper with any content, or run the command to restore all replicated tables: - -``` bash -sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data -``` - -Then restart the server. On start, the server deletes these flags and starts recovery. - -## Recovery After Complete Data Loss {#recovery-after-complete-data-loss} - -If all data and metadata disappeared from one of the servers, follow these steps for recovery: - -1. Install ClickHouse on the server. Define substitutions correctly in the config file that contains the shard identifier and replicas, if you use them. -2. If you had unreplicated tables that must be manually duplicated on the servers, copy their data from a replica (in the directory `/var/lib/clickhouse/data/db_name/table_name/`). -3. Copy table definitions located in `/var/lib/clickhouse/metadata/` from a replica. If a shard or replica identifier is defined explicitly in the table definitions, correct it so that it corresponds to this replica. (Alternatively, start the server and make all the `ATTACH TABLE` queries that should have been in the .sql files in `/var/lib/clickhouse/metadata/`.) -4. To start recovery, create the ZooKeeper node `/path_to_table/replica_name/flags/force_restore_data` with any content, or run the command to restore all replicated tables: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` - -Then start the server (restart, if it is already running). Data will be downloaded from replicas. - -An alternative recovery option is to delete information about the lost replica from ZooKeeper (`/path_to_table/replica_name`), then create the replica again as described in “[Creating replicated tables](#creating-replicated-tables)”. - -There is no restriction on network bandwidth during recovery. Keep this in mind if you are restoring many replicas at once. - -## Converting From MergeTree To ReplicatedMergeTree {#converting-from-mergetree-to-replicatedmergetree} - -We use the term `MergeTree` to refer to all table engines in the `MergeTree family`, the same as for `ReplicatedMergeTree`. - -If you had a `MergeTree` table that was manually replicated, you can convert it to a replicated table. You might need to do this if you have already collected a large amount of data in a `MergeTree` table and now you want to enable replication. - -If the data differs on various replicas, first sync it, or delete this data on all the replicas except one. - -Rename the existing MergeTree table, then create a `ReplicatedMergeTree` table with the old name. -Move the data from the old table to the `detached` subdirectory inside the directory with the new table data (`/var/lib/clickhouse/data/db_name/table_name/`). -Then run `ALTER TABLE ATTACH PARTITION` on one of the replicas to add these data parts to the working set. - -## Converting From ReplicatedMergeTree To MergeTree {#converting-from-replicatedmergetree-to-mergetree} - -Create a MergeTree table with a different name. Move all the data from the directory with the `ReplicatedMergeTree` table data to the new table’s data directory. Then delete the `ReplicatedMergeTree` table and restart the server. - -If you want to get rid of a `ReplicatedMergeTree` table without launching the server: - -- Delete the corresponding `.sql` file in the metadata directory (`/var/lib/clickhouse/metadata/`). -- Delete the corresponding path in ZooKeeper (`/path_to_table/replica_name`). - -After this, you can launch the server, create a `MergeTree` table, move the data to its directory, and then restart the server. - -## Recovery When Metadata In The Zookeeper Cluster Is Lost or Damaged {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} - -If the data in ZooKeeper was lost or damaged, you can save data by moving it to an unreplicated table as described above. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/en/engines/table_engines/mergetree_family/summingmergetree.md b/docs/en/engines/table_engines/mergetree_family/summingmergetree.md deleted file mode 100644 index c8f76b60c53..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/summingmergetree.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -toc_priority: 34 -toc_title: SummingMergeTree ---- - -# SummingMergeTree {#summingmergetree} - -The engine inherits from [MergeTree](mergetree.md#table_engines-mergetree). The difference is that when merging data parts for `SummingMergeTree` tables ClickHouse replaces all the rows with the same primary key (or more accurately, with the same [sorting key](mergetree.md)) with one row which contains summarized values for the columns with the numeric data type. If the sorting key is composed in a way that a single key value corresponds to large number of rows, this significantly reduces storage volume and speeds up data selection. - -We recommend to use the engine together with `MergeTree`. Store complete data in `MergeTree` table, and use `SummingMergeTree` for aggregated data storing, for example, when preparing reports. Such an approach will prevent you from losing valuable data due to an incorrectly composed primary key. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = SummingMergeTree([columns]) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -For a description of request parameters, see [request description](../../../sql_reference/statements/create.md). - -**Parameters of SummingMergeTree** - -- `columns` - a tuple with the names of columns where values will be summarized. Optional parameter. - The columns must be of a numeric type and must not be in the primary key. - - If `columns` not specified, ClickHouse summarizes the values in all columns with a numeric data type that are not in the primary key. - -**Query clauses** - -When creating a `SummingMergeTree` table the same [clauses](mergetree.md) are required, as when creating a `MergeTree` table. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects and, if possible, switch the old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) -``` - -All of the parameters excepting `columns` have the same meaning as in `MergeTree`. - -- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. - -
- -## Usage Example {#usage-example} - -Consider the following table: - -``` sql -CREATE TABLE summtt -( - key UInt32, - value UInt32 -) -ENGINE = SummingMergeTree() -ORDER BY key -``` - -Insert data to it: - -``` sql -INSERT INTO summtt Values(1,1),(1,2),(2,1) -``` - -ClickHouse may sum all the rows not completely ([see below](#data-processing)), so we use an aggregate function `sum` and `GROUP BY` clause in the query. - -``` sql -SELECT key, sum(value) FROM summtt GROUP BY key -``` - -``` text -┌─key─┬─sum(value)─┐ -│ 2 │ 1 │ -│ 1 │ 3 │ -└─────┴────────────┘ -``` - -## Data Processing {#data-processing} - -When data are inserted into a table, they are saved as-is. ClickHouse merges the inserted parts of data periodically and this is when rows with the same primary key are summed and replaced with one for each resulting part of data. - -ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) an aggregate function [sum()](../../../sql_reference/aggregate_functions/reference.md#agg_function-sum) and `GROUP BY` clause should be used in a query as described in the example above. - -### Common Rules For Summation {#common-rules-for-summation} - -The values in the columns with the numeric data type are summarized. The set of columns is defined by the parameter `columns`. - -If the values were 0 in all of the columns for summation, the row is deleted. - -If column is not in the primary key and is not summarized, an arbitrary value is selected from the existing ones. - -The values are not summarized for columns in the primary key. - -### The Summation In the Aggregatefunction Columns {#the-summation-in-the-aggregatefunction-columns} - -For columns of [AggregateFunction type](../../../sql_reference/data_types/aggregatefunction.md) ClickHouse behaves as [AggregatingMergeTree](aggregatingmergetree.md) engine aggregating according to the function. - -### Nested Structures {#nested-structures} - -Table can have nested data structures that are processed in a special way. - -If the name of a nested table ends with `Map` and it contains at least two columns that meet the following criteria: - -- the first column is numeric `(*Int*, Date, DateTime)` or a string `(String, FixedString)`, let’s call it `key`, -- the other columns are arithmetic `(*Int*, Float32/64)`, let’s call it `(values...)`, - -then this nested table is interpreted as a mapping of `key => (values...)`, and when merging its rows, the elements of two data sets are merged by `key` with a summation of the corresponding `(values...)`. - -Examples: - -``` text -[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] -[(1, 100)] + [(1, 150)] -> [(1, 250)] -[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] -[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] -``` - -When requesting data, use the [sumMap(key, value)](../../../sql_reference/aggregate_functions/reference.md) function for aggregation of `Map`. - -For nested data structure, you do not need to specify its columns in the tuple of columns for summation. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/en/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md b/docs/en/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md deleted file mode 100644 index f9a95dbd626..00000000000 --- a/docs/en/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md +++ /dev/null @@ -1,236 +0,0 @@ ---- -toc_priority: 37 -toc_title: VersionedCollapsingMergeTree ---- - -# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} - -This engine: - -- Allows quick writing of object states that are continually changing. -- Deletes old object states in the background. This significantly reduces the volume of storage. - -See the section [Collapsing](#table_engines_versionedcollapsingmergetree) for details. - -The engine inherits from [MergeTree](mergetree.md#table_engines-mergetree) and adds the logic for collapsing rows to the algorithm for merging data parts. `VersionedCollapsingMergeTree` serves the same purpose as [CollapsingMergeTree](collapsingmergetree.md) but uses a different collapsing algorithm that allows inserting the data in any order with multiple threads. In particular, the `Version` column helps to collapse the rows properly even if they are inserted in the wrong order. In contrast, `CollapsingMergeTree` allows only strictly consecutive insertion. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = VersionedCollapsingMergeTree(sign, version) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -For a description of query parameters, see the [query description](../../../sql_reference/statements/create.md). - -**Engine Parameters** - -``` sql -VersionedCollapsingMergeTree(sign, version) -``` - -- `sign` — Name of the column with the type of row: `1` is a “state” row, `-1` is a “cancel” row. - - The column data type should be `Int8`. - -- `version` — Name of the column with the version of the object state. - - The column data type should be `UInt*`. - -**Query Clauses** - -When creating a `VersionedCollapsingMergeTree` table, the same [clauses](mergetree.md) are required as when creating a `MergeTree` table. - -
- -Deprecated Method for Creating a Table - -!!! attention "Attention" - Do not use this method in new projects. If possible, switch the old projects to the method described above. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] VersionedCollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign, version) -``` - -All of the parameters except `sign` and `version` have the same meaning as in `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` is a “state” row, `-1` is a “cancel” row. - - Column Data Type — `Int8`. - -- `version` — Name of the column with the version of the object state. - - The column data type should be `UInt*`. - -
- -## Collapsing {#table_engines-versionedcollapsingmergetree} - -### Data {#data} - -Consider a situation where you need to save continually changing data for some object. It is reasonable to have one row for an object and update the row whenever there are changes. However, the update operation is expensive and slow for a DBMS because it requires rewriting the data in the storage. Update is not acceptable if you need to write data quickly, but you can write the changes to an object sequentially as follows. - -Use the `Sign` column when writing the row. If `Sign = 1` it means that the row is a state of an object (let’s call it the “state” row). If `Sign = -1` it indicates the cancellation of the state of an object with the same attributes (let’s call it the “cancel” row). Also use the `Version` column, which should identify each state of an object with a separate number. - -For example, we want to calculate how many pages users visited on some site and how long they were there. At some point in time we write the following row with the state of user activity: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -At some point later we register the change of user activity and write it with the following two rows. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -The first row cancels the previous state of the object (user). It should copy all of the fields of the canceled state except `Sign`. - -The second row contains the current state. - -Because we need only the last state of user activity, the rows - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -can be deleted, collapsing the invalid (old) state of the object. `VersionedCollapsingMergeTree` does this while merging the data parts. - -To find out why we need two rows for each change, see [Algorithm](#table_engines-versionedcollapsingmergetree-algorithm). - -**Notes on Usage** - -1. The program that writes the data should remember the state of an object in order to cancel it. The “cancel” string should be a copy of the “state” string with the opposite `Sign`. This increases the initial size of storage but allows to write the data quickly. -2. Long growing arrays in columns reduce the efficiency of the engine due to the load for writing. The more straightforward the data, the better the efficiency. -3. `SELECT` results depend strongly on the consistency of the history of object changes. Be accurate when preparing data for inserting. You can get unpredictable results with inconsistent data, such as negative values for non-negative metrics like session depth. - -### Algorithm {#table_engines-versionedcollapsingmergetree-algorithm} - -When ClickHouse merges data parts, it deletes each pair of rows that have the same primary key and version and different `Sign`. The order of rows does not matter. - -When ClickHouse inserts data, it orders rows by the primary key. If the `Version` column is not in the primary key, ClickHouse adds it to the primary key implicitly as the last field and uses it for ordering. - -## Selecting Data {#selecting-data} - -ClickHouse doesn’t guarantee that all of the rows with the same primary key will be in the same resulting data part or even on the same physical server. This is true both for writing the data and for subsequent merging of the data parts. In addition, ClickHouse processes `SELECT` queries with multiple threads, and it cannot predict the order of rows in the result. This means that aggregation is required if there is a need to get completely “collapsed” data from a `VersionedCollapsingMergeTree` table. - -To finalize collapsing, write a query with a `GROUP BY` clause and aggregate functions that account for the sign. For example, to calculate quantity, use `sum(Sign)` instead of `count()`. To calculate the sum of something, use `sum(Sign * x)` instead of `sum(x)`, and add `HAVING sum(Sign) > 0`. - -The aggregates `count`, `sum` and `avg` can be calculated this way. The aggregate `uniq` can be calculated if an object has at least one non-collapsed state. The aggregates `min` and `max` can’t be calculated because `VersionedCollapsingMergeTree` does not save the history of values of collapsed states. - -If you need to extract the data with “collapsing” but without aggregation (for example, to check whether rows are present whose newest values match certain conditions), you can use the `FINAL` modifier for the `FROM` clause. This approach is inefficient and should not be used with large tables. - -## Example Of Use {#example-of-use} - -Example data: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Creating the table: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8, - Version UInt8 -) -ENGINE = VersionedCollapsingMergeTree(Sign, Version) -ORDER BY UserID -``` - -Inserting the data: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) -``` - -We use two `INSERT` queries to create two different data parts. If we insert the data with a single query, ClickHouse creates one data part and will never perform any merge. - -Getting the data: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -What do we see here and where are the collapsed parts? -We created two data parts using two `INSERT` queries. The `SELECT` query was performed in two threads, and the result is a random order of rows. -Collapsing did not occur because the data parts have not been merged yet. ClickHouse merges data parts at an unknown point in time which we cannot predict. - -This is why we need aggregation: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration, - Version -FROM UAct -GROUP BY UserID, Version -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 2 │ -└─────────────────────┴───────────┴──────────┴─────────┘ -``` - -If we don’t need aggregation and want to force collapsing, we can use the `FINAL` modifier for the `FROM` clause. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -This is a very inefficient way to select data. Don’t use it for large tables. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/en/engines/table_engines/special/buffer.md b/docs/en/engines/table_engines/special/buffer.md deleted file mode 100644 index 12143044f21..00000000000 --- a/docs/en/engines/table_engines/special/buffer.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -toc_priority: 45 -toc_title: Buffer ---- - -# Buffer {#buffer} - -Buffers the data to write in RAM, periodically flushing it to another table. During the read operation, data is read from the buffer and the other table simultaneously. - -``` sql -Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) -``` - -Engine parameters: - -- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. -- `table` – Table to flush data to. -- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` of independent buffers. Recommended value: 16. -- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, and `max_bytes` – Conditions for flushing data from the buffer. - -Data is flushed from the buffer and written to the destination table if all the `min*` conditions or at least one `max*` condition are met. - -- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. -- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. -- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. - -During the write operation, data is inserted to a `num_layers` number of random buffers. Or, if the data part to insert is large enough (greater than `max_rows` or `max_bytes`), it is written directly to the destination table, omitting the buffer. - -The conditions for flushing the data are calculated separately for each of the `num_layers` buffers. For example, if `num_layers = 16` and `max_bytes = 100000000`, the maximum RAM consumption is 1.6 GB. - -Example: - -``` sql -CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) -``` - -Creating a ‘merge.hits\_buffer’ table with the same structure as ‘merge.hits’ and using the Buffer engine. When writing to this table, data is buffered in RAM and later written to the ‘merge.hits’ table. 16 buffers are created. The data in each of them is flushed if either 100 seconds have passed, or one million rows have been written, or 100 MB of data have been written; or if simultaneously 10 seconds have passed and 10,000 rows and 10 MB of data have been written. For example, if just one row has been written, after 100 seconds it will be flushed, no matter what. But if many rows have been written, the data will be flushed sooner. - -When the server is stopped, with DROP TABLE or DETACH TABLE, buffer data is also flushed to the destination table. - -You can set empty strings in single quotation marks for the database and table name. This indicates the absence of a destination table. In this case, when the data flush conditions are reached, the buffer is simply cleared. This may be useful for keeping a window of data in memory. - -When reading from a Buffer table, data is processed both from the buffer and from the destination table (if there is one). -Note that the Buffer tables does not support an index. In other words, data in the buffer is fully scanned, which might be slow for large buffers. (For data in a subordinate table, the index that it supports will be used.) - -If the set of columns in the Buffer table doesn’t match the set of columns in a subordinate table, a subset of columns that exist in both tables is inserted. - -If the types don’t match for one of the columns in the Buffer table and a subordinate table, an error message is entered in the server log and the buffer is cleared. -The same thing happens if the subordinate table doesn’t exist when the buffer is flushed. - -If you need to run ALTER for a subordinate table and the Buffer table, we recommend first deleting the Buffer table, running ALTER for the subordinate table, then creating the Buffer table again. - -If the server is restarted abnormally, the data in the buffer is lost. - -FINAL and SAMPLE do not work correctly for Buffer tables. These conditions are passed to the destination table, but are not used for processing data in the buffer. If these features are required we recommend only using the Buffer table for writing, while reading from the destination table. - -When adding data to a Buffer, one of the buffers is locked. This causes delays if a read operation is simultaneously being performed from the table. - -Data that is inserted to a Buffer table may end up in the subordinate table in a different order and in different blocks. Because of this, a Buffer table is difficult to use for writing to a CollapsingMergeTree correctly. To avoid problems, you can set ‘num\_layers’ to 1. - -If the destination table is replicated, some expected characteristics of replicated tables are lost when writing to a Buffer table. The random changes to the order of rows and sizes of data parts cause data deduplication to quit working, which means it is not possible to have a reliable ‘exactly once’ write to replicated tables. - -Due to these disadvantages, we can only recommend using a Buffer table in rare cases. - -A Buffer table is used when too many INSERTs are received from a large number of servers over a unit of time and data can’t be buffered before insertion, which means the INSERTs can’t run fast enough. - -Note that it doesn’t make sense to insert data one row at a time, even for Buffer tables. This will only produce a speed of a few thousand rows per second, while inserting larger blocks of data can produce over a million rows per second (see the section “Performance”). - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/en/engines/table_engines/special/dictionary.md b/docs/en/engines/table_engines/special/dictionary.md deleted file mode 100644 index 86b8214c8e5..00000000000 --- a/docs/en/engines/table_engines/special/dictionary.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -toc_priority: 35 -toc_title: Dictionary ---- - -# Dictionary {#dictionary} - -The `Dictionary` engine displays the [dictionary](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) data as a ClickHouse table. - -As an example, consider a dictionary of `products` with the following configuration: - -``` xml - - - products - - -
products
- DSN=some-db-server - - - - 300 - 360 - - - - - - - product_id - - - title - String - - - - - -``` - -Query the dictionary data: - -``` sql -SELECT - name, - type, - key, - attribute.names, - attribute.types, - bytes_allocated, - element_count, - source -FROM system.dictionaries -WHERE name = 'products' -``` - -``` text -┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ -│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ -└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ -``` - -You can use the [dictGet\*](../../../sql_reference/functions/ext_dict_functions.md#ext_dict_functions) function to get the dictionary data in this format. - -This view isn’t helpful when you need to get raw data, or when performing a `JOIN` operation. For these cases, you can use the `Dictionary` engine, which displays the dictionary data in a table. - -Syntax: - -``` sql -CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` -``` - -Usage example: - -``` sql -create table products (product_id UInt64, title String) Engine = Dictionary(products); -``` - - Ok - -Take a look at what’s in the table. - -``` sql -select * from products limit 1; -``` - -``` text -┌────product_id─┬─title───────────┐ -│ 152689 │ Some item │ -└───────────────┴─────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/en/engines/table_engines/special/distributed.md b/docs/en/engines/table_engines/special/distributed.md deleted file mode 100644 index c23aa10efb8..00000000000 --- a/docs/en/engines/table_engines/special/distributed.md +++ /dev/null @@ -1,150 +0,0 @@ ---- -toc_priority: 33 -toc_title: Distributed ---- - -# Distributed {#distributed} - -**Tables with Distributed engine do not store any data by themself**, but allow distributed query processing on multiple servers. -Reading is automatically parallelized. During a read, the table indexes on remote servers are used, if there are any. - -The Distributed engine accepts parameters: - -- the cluster name in the server’s config file - -- the name of a remote database - -- the name of a remote table - -- (optionally) sharding key - -- (optionally) policy name, it will be used to store temporary files for async send - - See also: - - - `insert_distributed_sync` setting - - [MergeTree](../mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) for the examples - -Example: - -``` sql -Distributed(logs, default, hits[, sharding_key[, policy_name]]) -``` - -Data will be read from all servers in the ‘logs’ cluster, from the default.hits table located on every server in the cluster. -Data is not only read but is partially processed on the remote servers (to the extent that this is possible). -For example, for a query with GROUP BY, data will be aggregated on remote servers, and the intermediate states of aggregate functions will be sent to the requestor server. Then data will be further aggregated. - -Instead of the database name, you can use a constant expression that returns a string. For example: currentDatabase(). - -logs – The cluster name in the server’s config file. - -Clusters are set like this: - -``` xml - - - - - 1 - - false - - example01-01-1 - 9000 - - - example01-01-2 - 9000 - - - - 2 - false - - example01-02-1 - 9000 - - - example01-02-2 - 1 - 9440 - - - - -``` - -Here a cluster is defined with the name ‘logs’ that consists of two shards, each of which contains two replicas. -Shards refer to the servers that contain different parts of the data (in order to read all the data, you must access all the shards). -Replicas are duplicating servers (in order to read all the data, you can access the data on any one of the replicas). - -Cluster names must not contain dots. - -The parameters `host`, `port`, and optionally `user`, `password`, `secure`, `compression` are specified for each server: -- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn’t start. If you change the DNS record, restart the server. -- `port` – The TCP port for messenger activity (‘tcp\_port’ in the config, usually set to 9000). Do not confuse it with http\_port. -- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Access rights](../../../operations/access_rights.md). -- `password` – The password for connecting to a remote server (not masked). Default value: empty string. -- `secure` - Use ssl for connection, usually you also should define `port` = 9440. Server should listen on 9440 and have correct certificates. -- `compression` - Use data compression. Default value: true. - -When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [load\_balancing](../../../operations/settings/settings.md#settings-load_balancing) setting. -If the connection with the server is not established, there will be an attempt to connect with a short timeout. If the connection failed, the next replica will be selected, and so on for all the replicas. If the connection attempt failed for all the replicas, the attempt will be repeated the same way, several times. -This works in favour of resiliency, but does not provide complete fault tolerance: a remote server might accept the connection, but might not work, or work poorly. - -You can specify just one of the shards (in this case, query processing should be called remote, rather than distributed) or up to any number of shards. In each shard, you can specify from one to any number of replicas. You can specify a different number of replicas for each shard. - -You can specify as many clusters as you wish in the configuration. - -To view your clusters, use the ‘system.clusters’ table. - -The Distributed engine allows working with a cluster like a local server. However, the cluster is inextensible: you must write its configuration in the server config file (even better, for all the cluster’s servers). - -The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don’t need to create a Distributed table – use the ‘remote’ table function instead. See the section [Table functions](../../../sql_reference/table_functions/index.md). - -There are two methods for writing data to a cluster: - -First, you can define which servers to write which data to and perform the write directly on each shard. In other words, perform INSERT in the tables that the distributed table “looks at”. This is the most flexible solution as you can use any sharding scheme, which could be non-trivial due to the requirements of the subject area. This is also the most optimal solution since data can be written to different shards completely independently. - -Second, you can perform INSERT in a Distributed table. In this case, the table will distribute the inserted data across the servers itself. In order to write to a Distributed table, it must have a sharding key set (the last parameter). In addition, if there is only one shard, the write operation works without specifying the sharding key, since it doesn’t mean anything in this case. - -Each shard can have a weight defined in the config file. By default, the weight is equal to one. Data is distributed across shards in the amount proportional to the shard weight. For example, if there are two shards and the first has a weight of 9 while the second has a weight of 10, the first will be sent 9 / 19 parts of the rows, and the second will be sent 10 / 19. - -Each shard can have the ‘internal\_replication’ parameter defined in the config file. - -If this parameter is set to ‘true’, the write operation selects the first healthy replica and writes data to it. Use this alternative if the Distributed table “looks at” replicated tables. In other words, if the table where data will be written is going to replicate them itself. - -If it is set to ‘false’ (the default), data is written to all replicas. In essence, this means that the Distributed table replicates data itself. This is worse than using replicated tables, because the consistency of replicas is not checked, and over time they will contain slightly different data. - -To select the shard that a row of data is sent to, the sharding expression is analyzed, and its remainder is taken from dividing it by the total weight of the shards. The row is sent to the shard that corresponds to the half-interval of the remainders from ‘prev\_weight’ to ‘prev\_weights + weight’, where ‘prev\_weights’ is the total weight of the shards with the smallest number, and ‘weight’ is the weight of this shard. For example, if there are two shards, and the first has a weight of 9 while the second has a weight of 10, the row will be sent to the first shard for the remainders from the range \[0, 9), and to the second for the remainders from the range \[9, 19). - -The sharding expression can be any expression from constants and table columns that returns an integer. For example, you can use the expression ‘rand()’ for random distribution of data, or ‘UserID’ for distribution by the remainder from dividing the user’s ID (then the data of a single user will reside on a single shard, which simplifies running IN and JOIN by users). If one of the columns is not distributed evenly enough, you can wrap it in a hash function: intHash64(UserID). - -A simple reminder from the division is a limited solution for sharding and isn’t always appropriate. It works for medium and large volumes of data (dozens of servers), but not for very large volumes of data (hundreds of servers or more). In the latter case, use the sharding scheme required by the subject area, rather than using entries in Distributed tables. - -SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don’t have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. - -You should be concerned about the sharding scheme in the following cases: - -- Queries are used that require joining data (IN or JOIN) by a specific key. If data is sharded by this key, you can use local IN or JOIN instead of GLOBAL IN or GLOBAL JOIN, which is much more efficient. -- A large number of servers is used (hundreds or more) with a large number of small queries (queries of individual clients - websites, advertisers, or partners). In order for the small queries to not affect the entire cluster, it makes sense to locate data for a single client on a single shard. Alternatively, as we’ve done in Yandex.Metrica, you can set up bi-level sharding: divide the entire cluster into “layers”, where a layer may consist of multiple shards. Data for a single client is located on a single layer, but shards can be added to a layer as necessary, and data is randomly distributed within them. Distributed tables are created for each layer, and a single shared distributed table is created for global queries. - -Data is written asynchronously. When inserted in the table, the data block is just written to the local file system. The data is sent to the remote servers in the background as soon as possible. The period for sending data is managed by the [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) and [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) settings. The `Distributed` engine sends each file with inserted data separately, but you can enable batch sending of files with the [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) setting. This setting improves cluster performance by better utilizing local server and network resources. You should check whether data is sent successfully by checking the list of files (data waiting to be sent) in the table directory: `/var/lib/clickhouse/data/database/table/`. - -If the server ceased to exist or had a rough restart (for example, after a device failure) after an INSERT to a Distributed table, the inserted data might be lost. If a damaged data part is detected in the table directory, it is transferred to the ‘broken’ subdirectory and no longer used. - -When the max\_parallel\_replicas option is enabled, query processing is parallelized across all replicas within a single shard. For more information, see the section [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). - -## Virtual Columns {#virtual-columns} - -- `_shard_num` — Contains the `shard_num` (from `system.clusters`). Type: [UInt32](../../../sql_reference/data_types/int_uint.md). - -!!! note "Note" - Since [`remote`](../../../sql_reference/table_functions/remote.md)/`cluster` table functions internally create temporary instance of the same Distributed engine, `_shard_num` is available there too. - -**See Also** - -- [Virtual columns](index.md#table_engines-virtual_columns) - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/en/engines/table_engines/special/external_data.md b/docs/en/engines/table_engines/special/external_data.md deleted file mode 100644 index de487aef154..00000000000 --- a/docs/en/engines/table_engines/special/external_data.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -toc_priority: 34 -toc_title: External data ---- - -# External Data for Query Processing {#external-data-for-query-processing} - -ClickHouse allows sending a server the data that is needed for processing a query, together with a SELECT query. This data is put in a temporary table (see the section “Temporary tables”) and can be used in the query (for example, in IN operators). - -For example, if you have a text file with important user identifiers, you can upload it to the server along with a query that uses filtration by this list. - -If you need to run more than one query with a large volume of external data, don’t use this feature. It is better to upload the data to the DB ahead of time. - -External data can be uploaded using the command-line client (in non-interactive mode), or using the HTTP interface. - -In the command-line client, you can specify a parameters section in the format - -``` bash ---external --file=... [--name=...] [--format=...] [--types=...|--structure=...] -``` - -You may have multiple sections like this, for the number of tables being transmitted. - -**–external** – Marks the beginning of a clause. -**–file** – Path to the file with the table dump, or -, which refers to stdin. -Only a single table can be retrieved from stdin. - -The following parameters are optional: **–name**– Name of the table. If omitted, \_data is used. -**–format** – Data format in the file. If omitted, TabSeparated is used. - -One of the following parameters is required:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … -**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Defines the column names and types. - -The files specified in ‘file’ will be parsed by the format specified in ‘format’, using the data types specified in ‘types’ or ‘structure’. The table will be uploaded to the server and accessible there as a temporary table with the name in ‘name’. - -Examples: - -``` bash -$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 -849897 -$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -When using the HTTP interface, external data is passed in the multipart/form-data format. Each table is transmitted as a separate file. The table name is taken from the file name. The ‘query\_string’ is passed the parameters ‘name\_format’, ‘name\_types’, and ‘name\_structure’, where ‘name’ is the name of the table that these parameters correspond to. The meaning of the parameters is the same as when using the command-line client. - -Example: - -``` bash -$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv - -$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -For distributed query processing, the temporary tables are sent to all the remote servers. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/en/engines/table_engines/special/file.md b/docs/en/engines/table_engines/special/file.md deleted file mode 100644 index b9a79ed2e3e..00000000000 --- a/docs/en/engines/table_engines/special/file.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -toc_priority: 37 -toc_title: File ---- - -# File {#table_engines-file} - -The File table engine keeps the data in a file in one of the supported [file -formats](../../../interfaces/formats.md#formats) (TabSeparated, Native, etc.). - -Usage examples: - -- Data export from ClickHouse to file. -- Convert data from one format to another. -- Updating data in ClickHouse via editing a file on a disk. - -## Usage In ClickHouse Server {#usage-in-clickhouse-server} - -``` sql -File(Format) -``` - -The `Format` parameter specifies one of the available file formats. To perform -`SELECT` queries, the format must be supported for input, and to perform -`INSERT` queries – for output. The available formats are listed in the -[Formats](../../../interfaces/formats.md#formats) section. - -ClickHouse does not allow to specify filesystem path for`File`. It will use folder defined by [path](../../../operations/server_configuration_parameters/settings.md) setting in server configuration. - -When creating table using `File(Format)` it creates empty subdirectory in that folder. When data is written to that table, it’s put into `data.Format` file in that subdirectory. - -You may manually create this subfolder and file in server filesystem and then [ATTACH](../../../sql_reference/statements/misc.md) it to table information with matching name, so you can query data from that file. - -!!! warning "Warning" - Be careful with this functionality, because ClickHouse does not keep track of external changes to such files. The result of simultaneous writes via ClickHouse and outside of ClickHouse is undefined. - -**Example:** - -**1.** Set up the `file_engine_table` table: - -``` sql -CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) -``` - -By default ClickHouse will create folder `/var/lib/clickhouse/data/default/file_engine_table`. - -**2.** Manually create `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` containing: - -``` bash -$ cat data.TabSeparated -one 1 -two 2 -``` - -**3.** Query the data: - -``` sql -SELECT * FROM file_engine_table -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Usage In ClickHouse-local {#usage-in-clickhouse-local} - -In [clickhouse-local](../../../operations/utilities/clickhouse-local.md) File engine accepts file path in addition to `Format`. Default input/output streams can be specified using numeric or human-readable names like `0` or `stdin`, `1` or `stdout`. -**Example:** - -``` bash -$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" -``` - -## Details Of Implementation {#details-of-implementation} - -- Multiple `SELECT` queries can be performed concurrently, but `INSERT` queries will wait each other. -- Supported creating new file by `INSERT` query. -- If file exists, `INSERT` would append new values in it. -- Not supported: - - `ALTER` - - `SELECT ... SAMPLE` - - Indices - - Replication - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/en/engines/table_engines/special/generate.md b/docs/en/engines/table_engines/special/generate.md deleted file mode 100644 index 6e592674346..00000000000 --- a/docs/en/engines/table_engines/special/generate.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -toc_priority: 46 -toc_title: GenerateRandom ---- - -# Generaterandom {#table_engines-generate} - -The GenerateRandom table engine produces random data for given table schema. - -Usage examples: - -- Use in test to populate reproducible large table. -- Generate random input for fuzzing tests. - -## Usage In ClickHouse Server {#usage-in-clickhouse-server} - -``` sql -ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) -``` - -The `max_array_length` and `max_string_length` parameters specify maximum length of all -array columns and strings correspondingly in generated data. - -Generate table engine supports only `SELECT` queries. - -It supports all [DataTypes](../../../sql_reference/data_types/index.md) that can be stored in a table except `LowCardinality` and `AggregateFunction`. - -**Example:** - -**1.** Set up the `generate_engine_table` table: - -``` sql -CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) -``` - -**2.** Query the data: - -``` sql -SELECT * FROM generate_engine_table LIMIT 3 -``` - -``` text -┌─name─┬──────value─┐ -│ c4xJ │ 1412771199 │ -│ r │ 1791099446 │ -│ 7#$ │ 124312908 │ -└──────┴────────────┘ -``` - -## Details Of Implementation {#details-of-implementation} - -- Not supported: - - `ALTER` - - `SELECT ... SAMPLE` - - `INSERT` - - Indices - - Replication - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/en/engines/table_engines/special/index.md b/docs/en/engines/table_engines/special/index.md deleted file mode 100644 index 22cebf295c1..00000000000 --- a/docs/en/engines/table_engines/special/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Special -toc_priority: 31 ---- - diff --git a/docs/en/engines/table_engines/special/join.md b/docs/en/engines/table_engines/special/join.md deleted file mode 100644 index 5c41396141d..00000000000 --- a/docs/en/engines/table_engines/special/join.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -toc_priority: 40 -toc_title: Join ---- - -# Join {#join} - -Prepared data structure for using in [JOIN](../../../sql_reference/statements/select.md#select-join) operations. - -## Creating a Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], -) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) -``` - -See the detailed description of the [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) query. - -**Engine Parameters** - -- `join_strictness` – [JOIN strictness](../../../sql_reference/statements/select.md#select-join-strictness). -- `join_type` – [JOIN type](../../../sql_reference/statements/select.md#select-join-types). -- `k1[, k2, ...]` – Key columns from the `USING` clause that the `JOIN` operation is made with. - -Enter `join_strictness` and `join_type` parameters without quotes, for example, `Join(ANY, LEFT, col1)`. They must match the `JOIN` operation that the table will be used for. If the parameters don’t match, ClickHouse doesn’t throw an exception and may return incorrect data. - -## Table Usage {#table-usage} - -### Example {#example} - -Creating the left-side table: - -``` sql -CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog -``` - -``` sql -INSERT INTO id_val VALUES (1,11)(2,12)(3,13) -``` - -Creating the right-side `Join` table: - -``` sql -CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) -``` - -``` sql -INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) -``` - -Joining the tables: - -``` sql -SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 -``` - -``` text -┌─id─┬─val─┬─id_val_join.val─┐ -│ 1 │ 11 │ 21 │ -│ 2 │ 12 │ ᴺᵁᴸᴸ │ -│ 3 │ 13 │ 23 │ -└────┴─────┴─────────────────┘ -``` - -As an alternative, you can retrieve data from the `Join` table, specifying the join key value: - -``` sql -SELECT joinGet('id_val_join', 'val', toUInt32(1)) -``` - -``` text -┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ -│ 21 │ -└────────────────────────────────────────────┘ -``` - -### Selecting and Inserting Data {#selecting-and-inserting-data} - -You can use `INSERT` queries to add data to the `Join`-engine tables. If the table was created with the `ANY` strictness, data for duplicate keys are ignored. With the `ALL` strictness, all rows are added. - -You cannot perform a `SELECT` query directly from the table. Instead, use one of the following methods: - -- Place the table to the right side in a `JOIN` clause. -- Call the [joinGet](../../../sql_reference/functions/other_functions.md#joinget) function, which lets you extract data from the table the same way as from a dictionary. - -### Limitations and Settings {#join-limitations-and-settings} - -When creating a table, the following settings are applied: - -- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) -- [max\_rows\_in\_join](../../../operations/settings/query_complexity.md#settings-max_rows_in_join) -- [max\_bytes\_in\_join](../../../operations/settings/query_complexity.md#settings-max_bytes_in_join) -- [join\_overflow\_mode](../../../operations/settings/query_complexity.md#settings-join_overflow_mode) -- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) - -The `Join`-engine tables can’t be used in `GLOBAL JOIN` operations. - -The `Join`-engine allows use [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) setting in the `CREATE TABLE` statement. And [SELECT](../../../sql_reference/statements/select.md) query allows use `join_use_nulls` too. If you have different `join_use_nulls` settings, you can get an error joining table. It depends on kind of JOIN. When you use [joinGet](../../../sql_reference/functions/other_functions.md#joinget) function, you have to use the same `join_use_nulls` setting in `CRATE TABLE` and `SELECT` statements. - -## Data Storage {#data-storage} - -`Join` table data is always located in the RAM. When inserting rows into a table, ClickHouse writes data blocks to the directory on the disk so that they can be restored when the server restarts. - -If the server restarts incorrectly, the data block on the disk might get lost or damaged. In this case, you may need to manually delete the file with damaged data. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/en/engines/table_engines/special/materializedview.md b/docs/en/engines/table_engines/special/materializedview.md deleted file mode 100644 index 49ad2411f83..00000000000 --- a/docs/en/engines/table_engines/special/materializedview.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -toc_priority: 43 -toc_title: MaterializedView ---- - -# Materializedview {#materializedview} - -Used for implementing materialized views (for more information, see [CREATE TABLE](../../../sql_reference/statements/create.md)). For storing data, it uses a different engine that was specified when creating the view. When reading from a table, it just uses this engine. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/en/engines/table_engines/special/memory.md b/docs/en/engines/table_engines/special/memory.md deleted file mode 100644 index abdb07658d4..00000000000 --- a/docs/en/engines/table_engines/special/memory.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -toc_priority: 44 -toc_title: Memory ---- - -# Memory {#memory} - -The Memory engine stores data in RAM, in uncompressed form. Data is stored in exactly the same form as it is received when read. In other words, reading from this table is completely free. -Concurrent data access is synchronized. Locks are short: read and write operations don’t block each other. -Indexes are not supported. Reading is parallelized. -Maximal productivity (over 10 GB/sec) is reached on simple queries, because there is no reading from the disk, decompressing, or deserializing data. (We should note that in many cases, the productivity of the MergeTree engine is almost as high.) -When restarting a server, data disappears from the table and the table becomes empty. -Normally, using this table engine is not justified. However, it can be used for tests, and for tasks where maximum speed is required on a relatively small number of rows (up to approximately 100,000,000). - -The Memory engine is used by the system for temporary tables with external query data (see the section “External data for processing a query”), and for implementing GLOBAL IN (see the section “IN operators”). - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/en/engines/table_engines/special/merge.md b/docs/en/engines/table_engines/special/merge.md deleted file mode 100644 index 8027266b441..00000000000 --- a/docs/en/engines/table_engines/special/merge.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -toc_priority: 36 -toc_title: Merge ---- - -# Merge {#merge} - -The `Merge` engine (not to be confused with `MergeTree`) does not store data itself, but allows reading from any number of other tables simultaneously. -Reading is automatically parallelized. Writing to a table is not supported. When reading, the indexes of tables that are actually being read are used, if they exist. -The `Merge` engine accepts parameters: the database name and a regular expression for tables. - -Example: - -``` sql -Merge(hits, '^WatchLog') -``` - -Data will be read from the tables in the `hits` database that have names that match the regular expression ‘`^WatchLog`’. - -Instead of the database name, you can use a constant expression that returns a string. For example, `currentDatabase()`. - -Regular expressions — [re2](https://github.com/google/re2) (supports a subset of PCRE), case-sensitive. -See the notes about escaping symbols in regular expressions in the “match” section. - -When selecting tables to read, the `Merge` table itself will not be selected, even if it matches the regex. This is to avoid loops. -It is possible to create two `Merge` tables that will endlessly try to read each others’ data, but this is not a good idea. - -The typical way to use the `Merge` engine is for working with a large number of `TinyLog` tables as if with a single table. - -Example 2: - -Let’s say you have a old table (WatchLog\_old) and decided to change partitioning without moving data to a new table (WatchLog\_new) and you need to see data from both tables. - -``` sql -CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree(date, (UserId, EventType), 8192); -INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); - -CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; -INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); - -CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); - -SELECT * -FROM WatchLog -``` - -``` text -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-01 │ 1 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-02 │ 2 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -``` - -## Virtual Columns {#virtual-columns} - -- `_table` — Contains the name of the table from which data was read. Type: [String](../../../sql_reference/data_types/string.md). - - You can set the constant conditions on `_table` in the `WHERE/PREWHERE` clause (for example, `WHERE _table='xyz'`). In this case the read operation is performed only for that tables where the condition on `_table` is satisfied, so the `_table` column acts as an index. - -**See Also** - -- [Virtual columns](index.md#table_engines-virtual_columns) - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/en/engines/table_engines/special/null.md b/docs/en/engines/table_engines/special/null.md deleted file mode 100644 index 73c5a2b1ea6..00000000000 --- a/docs/en/engines/table_engines/special/null.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -toc_priority: 38 -toc_title: 'Null' ---- - -# Null {#null} - -When writing to a Null table, data is ignored. When reading from a Null table, the response is empty. - -However, you can create a materialized view on a Null table. So the data written to the table will end up in the view. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/en/engines/table_engines/special/set.md b/docs/en/engines/table_engines/special/set.md deleted file mode 100644 index fb0c5952ae4..00000000000 --- a/docs/en/engines/table_engines/special/set.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -toc_priority: 39 -toc_title: Set ---- - -# Set {#set} - -A data set that is always in RAM. It is intended for use on the right side of the IN operator (see the section “IN operators”). - -You can use INSERT to insert data in the table. New elements will be added to the data set, while duplicates will be ignored. -But you can’t perform SELECT from the table. The only way to retrieve data is by using it in the right half of the IN operator. - -Data is always located in RAM. For INSERT, the blocks of inserted data are also written to the directory of tables on the disk. When starting the server, this data is loaded to RAM. In other words, after restarting, the data remains in place. - -For a rough server restart, the block of data on the disk might be lost or damaged. In the latter case, you may need to manually delete the file with damaged data. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/en/engines/table_engines/special/url.md b/docs/en/engines/table_engines/special/url.md deleted file mode 100644 index db679b97c54..00000000000 --- a/docs/en/engines/table_engines/special/url.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -toc_priority: 41 -toc_title: URL ---- - -# URL(URL, Format) {#table_engines-url} - -Manages data on a remote HTTP/HTTPS server. This engine is similar -to the [File](file.md) engine. - -## Using the Engine In the ClickHouse Server {#using-the-engine-in-the-clickhouse-server} - -The `format` must be one that ClickHouse can use in -`SELECT` queries and, if necessary, in `INSERTs`. For the full list of supported formats, see -[Formats](../../../interfaces/formats.md#formats). - -The `URL` must conform to the structure of a Uniform Resource Locator. The specified URL must point to a server -that uses HTTP or HTTPS. This does not require any -additional headers for getting a response from the server. - -`INSERT` and `SELECT` queries are transformed to `POST` and `GET` requests, -respectively. For processing `POST` requests, the remote server must support -[Chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). - -You can limit the maximum number of HTTP GET redirect hops using the [max\_http\_get\_redirects](../../../operations/settings/settings.md#setting-max_http_get_redirects) setting. - -**Example:** - -**1.** Create a `url_engine_table` table on the server : - -``` sql -CREATE TABLE url_engine_table (word String, value UInt64) -ENGINE=URL('http://127.0.0.1:12345/', CSV) -``` - -**2.** Create a basic HTTP server using the standard Python 3 tools and -start it: - -``` python3 -from http.server import BaseHTTPRequestHandler, HTTPServer - -class CSVHTTPServer(BaseHTTPRequestHandler): - def do_GET(self): - self.send_response(200) - self.send_header('Content-type', 'text/csv') - self.end_headers() - - self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) - -if __name__ == "__main__": - server_address = ('127.0.0.1', 12345) - HTTPServer(server_address, CSVHTTPServer).serve_forever() -``` - -``` bash -$ python3 server.py -``` - -**3.** Request data: - -``` sql -SELECT * FROM url_engine_table -``` - -``` text -┌─word──┬─value─┐ -│ Hello │ 1 │ -│ World │ 2 │ -└───────┴───────┘ -``` - -## Details Of Implementation {#details-of-implementation} - -- Reads and writes can be parallel -- Not supported: - - `ALTER` and `SELECT...SAMPLE` operations. - - Indexes. - - Replication. - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/en/engines/table_engines/special/view.md b/docs/en/engines/table_engines/special/view.md deleted file mode 100644 index f5d74795dec..00000000000 --- a/docs/en/engines/table_engines/special/view.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -toc_priority: 42 -toc_title: View ---- - -# View {#table_engines-view} - -Used for implementing views (for more information, see the `CREATE VIEW query`). It does not store data, but only stores the specified `SELECT` query. When reading from a table, it runs this query (and deletes all unnecessary columns from the query). - -[Original article](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/en/faq/general.md b/docs/en/faq/general.md index a382daf3f0e..53cb583e25f 100644 --- a/docs/en/faq/general.md +++ b/docs/en/faq/general.md @@ -27,7 +27,7 @@ NLS_LANG=RUSSIAN_RUSSIA.UTF8 ### Using INTO OUTFILE Clause {#using-into-outfile-clause} -Add an [INTO OUTFILE](../sql_reference/statements/select.md#into-outfile-clause) clause to your query. +Add an [INTO OUTFILE](../sql-reference/statements/select/into-outfile.md#into-outfile-clause) clause to your query. For example: @@ -35,7 +35,7 @@ For example: SELECT * FROM table INTO OUTFILE 'file' ``` -By default, ClickHouse uses the [TabSeparated](../interfaces/formats.md#tabseparated) format for output data. To select the [data format](../interfaces/formats.md), use the [FORMAT clause](../sql_reference/statements/select.md#format-clause). +By default, ClickHouse uses the [TabSeparated](../interfaces/formats.md#tabseparated) format for output data. To select the [data format](../interfaces/formats.md), use the [FORMAT clause](../sql-reference/statements/select/format.md#format-clause). For example: @@ -45,7 +45,7 @@ SELECT * FROM table INTO OUTFILE 'file' FORMAT CSV ### Using a File-Engine Table {#using-a-file-engine-table} -See [File](../engines/table_engines/special/file.md). +See [File](../engines/table-engines/special/file.md). ### Using Command-Line Redirection {#using-command-line-redirection} diff --git a/docs/en/faq/index.md b/docs/en/faq/index.md index 2ee9d51e83b..bdbd59f7880 100644 --- a/docs/en/faq/index.md +++ b/docs/en/faq/index.md @@ -1,6 +1,9 @@ --- toc_folder_title: F.A.Q. toc_priority: 76 +toc_title: hidden +toc_hidden: true --- +{## [Original article](https://clickhouse.tech/docs/en/faq) ##} diff --git a/docs/en/getting_started/example_datasets/amplab_benchmark.md b/docs/en/getting-started/example-datasets/amplab-benchmark.md similarity index 100% rename from docs/en/getting_started/example_datasets/amplab_benchmark.md rename to docs/en/getting-started/example-datasets/amplab-benchmark.md diff --git a/docs/en/getting_started/example_datasets/criteo.md b/docs/en/getting-started/example-datasets/criteo.md similarity index 100% rename from docs/en/getting_started/example_datasets/criteo.md rename to docs/en/getting-started/example-datasets/criteo.md diff --git a/docs/en/getting-started/example-datasets/index.md b/docs/en/getting-started/example-datasets/index.md new file mode 100644 index 00000000000..c81b272d029 --- /dev/null +++ b/docs/en/getting-started/example-datasets/index.md @@ -0,0 +1,20 @@ +--- +toc_folder_title: Example Datasets +toc_priority: 12 +toc_title: Introduction +--- + +# Example Datasets {#example-datasets} + +This section describes how to obtain example datasets and import them into ClickHouse. +For some datasets example queries are also available. + +- [Anonymized Yandex.Metrica Dataset](metrica.md) +- [Star Schema Benchmark](star-schema.md) +- [WikiStat](wikistat.md) +- [Terabyte of Click Logs from Criteo](criteo.md) +- [AMPLab Big Data Benchmark](amplab-benchmark.md) +- [New York Taxi Data](nyc-taxi.md) +- [OnTime](ontime.md) + +[Original article](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/en/getting-started/example-datasets/metrica.md b/docs/en/getting-started/example-datasets/metrica.md new file mode 100644 index 00000000000..4131dca78fe --- /dev/null +++ b/docs/en/getting-started/example-datasets/metrica.md @@ -0,0 +1,68 @@ +--- +toc_priority: 14 +toc_title: Yandex.Metrica Data +--- + +# Anonymized Yandex.Metrica Data {#anonymized-yandex-metrica-data} + +Dataset consists of two tables containing anonymized data about hits (`hits_v1`) and visits (`visits_v1`) of Yandex.Metrica. You can read more about Yandex.Metrica in [ClickHouse history](../../introduction/history.md) section. + +The dataset consists of two tables, either of them can be downloaded as a compressed `tsv.xz` file or as prepared partitions. In addition to that, an extended version of the `hits` table containing 100 million rows is available as TSV at https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_100m_obfuscated_v1.tsv.xz and as prepared partitions at https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz. + +## Obtaining Tables from Prepared Partitions {#obtaining-tables-from-prepared-partitions} + +Download and import hits table: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar +tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Download and import visits: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar +tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Obtaining Tables from Compressed TSV File {#obtaining-tables-from-compressed-tsv-file} + +Download and import hits from compressed TSV file: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Download and import visits from compressed tsv-file: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Example Queries {#example-queries} + +[ClickHouse tutorial](../../getting-started/tutorial.md) is based on Yandex.Metrica dataset and the recommended way to get started with this dataset is to just go through tutorial. + +Additional examples of queries to these tables can be found among [stateful tests](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) of ClickHouse (they are named `test.hists` and `test.visits` there). diff --git a/docs/en/getting-started/example-datasets/nyc-taxi.md b/docs/en/getting-started/example-datasets/nyc-taxi.md new file mode 100644 index 00000000000..4a069e247b3 --- /dev/null +++ b/docs/en/getting-started/example-datasets/nyc-taxi.md @@ -0,0 +1,388 @@ +--- +toc_priority: 16 +toc_title: New York Taxi Data +--- + +# New York Taxi Data {#new-york-taxi-data} + +This dataset can be obtained in two ways: + +- import from raw data +- download of prepared partitions + +## How to Import the Raw Data {#how-to-import-the-raw-data} + +See https://github.com/toddwschneider/nyc-taxi-data and http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html for the description of a dataset and instructions for downloading. + +Downloading will result in about 227 GB of uncompressed data in CSV files. The download takes about an hour over a 1 Gbit connection (parallel downloading from s3.amazonaws.com recovers at least half of a 1 Gbit channel). +Some of the files might not download fully. Check the file sizes and re-download any that seem doubtful. + +Some of the files might contain invalid rows. You can fix them as follows: + +``` bash +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ +mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv +mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv +``` + +Then the data must be pre-processed in PostgreSQL. This will create selections of points in the polygons (to match points on the map with the boroughs of New York City) and combine all the data into a single denormalized flat table by using a JOIN. To do this, you will need to install PostgreSQL with PostGIS support. + +Be careful when running `initialize_database.sh` and manually re-check that all the tables were created correctly. + +It takes about 20-30 minutes to process each month’s worth of data in PostgreSQL, for a total of about 48 hours. + +You can check the number of downloaded rows as follows: + +``` bash +$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" +## Count + 1298979494 +(1 row) + +real 7m9.164s +``` + +(This is slightly more than 1.1 billion rows reported by Mark Litwintschik in a series of blog posts.) + +The data in PostgreSQL uses 370 GB of space. + +Exporting the data from PostgreSQL: + +``` sql +COPY +( + SELECT trips.id, + trips.vendor_id, + trips.pickup_datetime, + trips.dropoff_datetime, + trips.store_and_fwd_flag, + trips.rate_code_id, + trips.pickup_longitude, + trips.pickup_latitude, + trips.dropoff_longitude, + trips.dropoff_latitude, + trips.passenger_count, + trips.trip_distance, + trips.fare_amount, + trips.extra, + trips.mta_tax, + trips.tip_amount, + trips.tolls_amount, + trips.ehail_fee, + trips.improvement_surcharge, + trips.total_amount, + trips.payment_type, + trips.trip_type, + trips.pickup, + trips.dropoff, + + cab_types.type cab_type, + + weather.precipitation_tenths_of_mm rain, + weather.snow_depth_mm, + weather.snowfall_mm, + weather.max_temperature_tenths_degrees_celsius max_temp, + weather.min_temperature_tenths_degrees_celsius min_temp, + weather.average_wind_speed_tenths_of_meters_per_second wind, + + pick_up.gid pickup_nyct2010_gid, + pick_up.ctlabel pickup_ctlabel, + pick_up.borocode pickup_borocode, + pick_up.boroname pickup_boroname, + pick_up.ct2010 pickup_ct2010, + pick_up.boroct2010 pickup_boroct2010, + pick_up.cdeligibil pickup_cdeligibil, + pick_up.ntacode pickup_ntacode, + pick_up.ntaname pickup_ntaname, + pick_up.puma pickup_puma, + + drop_off.gid dropoff_nyct2010_gid, + drop_off.ctlabel dropoff_ctlabel, + drop_off.borocode dropoff_borocode, + drop_off.boroname dropoff_boroname, + drop_off.ct2010 dropoff_ct2010, + drop_off.boroct2010 dropoff_boroct2010, + drop_off.cdeligibil dropoff_cdeligibil, + drop_off.ntacode dropoff_ntacode, + drop_off.ntaname dropoff_ntaname, + drop_off.puma dropoff_puma + FROM trips + LEFT JOIN cab_types + ON trips.cab_type_id = cab_types.id + LEFT JOIN central_park_weather_observations_raw weather + ON weather.date = trips.pickup_datetime::date + LEFT JOIN nyct2010 pick_up + ON pick_up.gid = trips.pickup_nyct2010_gid + LEFT JOIN nyct2010 drop_off + ON drop_off.gid = trips.dropoff_nyct2010_gid +) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; +``` + +The data snapshot is created at a speed of about 50 MB per second. While creating the snapshot, PostgreSQL reads from the disk at a speed of about 28 MB per second. +This takes about 5 hours. The resulting TSV file is 590612904969 bytes. + +Create a temporary table in ClickHouse: + +``` sql +CREATE TABLE trips +( +trip_id UInt32, +vendor_id String, +pickup_datetime DateTime, +dropoff_datetime Nullable(DateTime), +store_and_fwd_flag Nullable(FixedString(1)), +rate_code_id Nullable(UInt8), +pickup_longitude Nullable(Float64), +pickup_latitude Nullable(Float64), +dropoff_longitude Nullable(Float64), +dropoff_latitude Nullable(Float64), +passenger_count Nullable(UInt8), +trip_distance Nullable(Float64), +fare_amount Nullable(Float32), +extra Nullable(Float32), +mta_tax Nullable(Float32), +tip_amount Nullable(Float32), +tolls_amount Nullable(Float32), +ehail_fee Nullable(Float32), +improvement_surcharge Nullable(Float32), +total_amount Nullable(Float32), +payment_type Nullable(String), +trip_type Nullable(UInt8), +pickup Nullable(String), +dropoff Nullable(String), +cab_type Nullable(String), +precipitation Nullable(UInt8), +snow_depth Nullable(UInt8), +snowfall Nullable(UInt8), +max_temperature Nullable(UInt8), +min_temperature Nullable(UInt8), +average_wind_speed Nullable(UInt8), +pickup_nyct2010_gid Nullable(UInt8), +pickup_ctlabel Nullable(String), +pickup_borocode Nullable(UInt8), +pickup_boroname Nullable(String), +pickup_ct2010 Nullable(String), +pickup_boroct2010 Nullable(String), +pickup_cdeligibil Nullable(FixedString(1)), +pickup_ntacode Nullable(String), +pickup_ntaname Nullable(String), +pickup_puma Nullable(String), +dropoff_nyct2010_gid Nullable(UInt8), +dropoff_ctlabel Nullable(String), +dropoff_borocode Nullable(UInt8), +dropoff_boroname Nullable(String), +dropoff_ct2010 Nullable(String), +dropoff_boroct2010 Nullable(String), +dropoff_cdeligibil Nullable(String), +dropoff_ntacode Nullable(String), +dropoff_ntaname Nullable(String), +dropoff_puma Nullable(String) +) ENGINE = Log; +``` + +It is needed for converting fields to more correct data types and, if possible, to eliminate NULLs. + +``` bash +$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv + +real 75m56.214s +``` + +Data is read at a speed of 112-140 Mb/second. +Loading data into a Log type table in one stream took 76 minutes. +The data in this table uses 142 GB. + +(Importing data directly from Postgres is also possible using `COPY ... TO PROGRAM`.) + +Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. + +To start, we’ll create a table on a single server. Later we will make the table distributed. + +Create and populate a summary table: + +``` sql +CREATE TABLE trips_mergetree +ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +AS SELECT + +trip_id, +CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, +toDate(pickup_datetime) AS pickup_date, +ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, +toDate(dropoff_datetime) AS dropoff_date, +ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, +assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, +assumeNotNull(rate_code_id) AS rate_code_id, +assumeNotNull(pickup_longitude) AS pickup_longitude, +assumeNotNull(pickup_latitude) AS pickup_latitude, +assumeNotNull(dropoff_longitude) AS dropoff_longitude, +assumeNotNull(dropoff_latitude) AS dropoff_latitude, +assumeNotNull(passenger_count) AS passenger_count, +assumeNotNull(trip_distance) AS trip_distance, +assumeNotNull(fare_amount) AS fare_amount, +assumeNotNull(extra) AS extra, +assumeNotNull(mta_tax) AS mta_tax, +assumeNotNull(tip_amount) AS tip_amount, +assumeNotNull(tolls_amount) AS tolls_amount, +assumeNotNull(ehail_fee) AS ehail_fee, +assumeNotNull(improvement_surcharge) AS improvement_surcharge, +assumeNotNull(total_amount) AS total_amount, +CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, +assumeNotNull(trip_type) AS trip_type, +ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, +ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, +CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, + +assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, +toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, +assumeNotNull(pickup_borocode) AS pickup_borocode, +CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, +toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, +toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, +CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, +toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, + +CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, + +toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, + +assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, +toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, +assumeNotNull(dropoff_borocode) AS dropoff_borocode, +CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, +toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, +toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, +CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, +toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, + +CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, + +toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma + +FROM trips +``` + +This takes 3030 seconds at a speed of about 428,000 rows per second. +To load it faster, you can create the table with the `Log` engine instead of `MergeTree`. In this case, the download works faster than 200 seconds. + +The table uses 126 GB of disk space. + +``` sql +SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active +``` + +``` text +┌─formatReadableSize(sum(bytes))─┐ +│ 126.18 GiB │ +└────────────────────────────────┘ +``` + +Among other things, you can run the OPTIMIZE query on MergeTree. But it’s not required since everything will be fine without it. + +## Download of Prepared Partitions {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar +$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" +``` + +!!! info "Info" + If you will run the queries described below, you have to use the full table name, `datasets.trips_mergetree`. + +## Results on Single Server {#results-on-single-server} + +Q1: + +``` sql +SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type +``` + +0.490 seconds. + +Q2: + +``` sql +SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count +``` + +1.224 seconds. + +Q3: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year +``` + +2.104 seconds. + +Q4: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) +FROM trips_mergetree +GROUP BY passenger_count, year, distance +ORDER BY year, count(*) DESC +``` + +3.593 seconds. + +The following server was used: + +Two Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz, 16 physical kernels total,128 GiB RAM,8x6 TB HD on hardware RAID-5 + +Execution time is the best of three runs. But starting from the second run, queries read data from the file system cache. No further caching occurs: the data is read out and processed in each run. + +Creating a table on three servers: + +On each server: + +``` sql +CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +``` + +On the source server: + +``` sql +CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) +``` + +The following query redistributes data: + +``` sql +INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree +``` + +This takes 2454 seconds. + +On three servers: + +Q1: 0.212 seconds. +Q2: 0.438 seconds. +Q3: 0.733 seconds. +Q4: 1.241 seconds. + +No surprises here, since the queries are scaled linearly. + +We also have the results from a cluster of 140 servers: + +Q1: 0.028 sec. +Q2: 0.043 sec. +Q3: 0.051 sec. +Q4: 0.072 sec. + +In this case, the query processing time is determined above all by network latency. +We ran queries using a client located in a Yandex datacenter in Finland on a cluster in Russia, which added about 20 ms of latency. + +## Summary {#summary} + +| servers | Q1 | Q2 | Q3 | Q4 | +|---------|-------|-------|-------|-------| +| 1 | 0.490 | 1.224 | 2.104 | 3.593 | +| 3 | 0.212 | 0.438 | 0.733 | 1.241 | +| 140 | 0.028 | 0.043 | 0.051 | 0.072 | + +[Original article](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/en/getting-started/example-datasets/ontime.md b/docs/en/getting-started/example-datasets/ontime.md new file mode 100644 index 00000000000..91b6913e223 --- /dev/null +++ b/docs/en/getting-started/example-datasets/ontime.md @@ -0,0 +1,410 @@ +--- +toc_priority: 15 +toc_title: OnTime +--- + +# OnTime {#ontime} + +This dataset can be obtained in two ways: + +- import from raw data +- download of prepared partitions + +## Import from Raw Data {#import-from-raw-data} + +Downloading data: + +``` bash +for s in `seq 1987 2018` +do +for m in `seq 1 12` +do +wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip +done +done +``` + +(from https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) + +Creating a table: + +``` sql +CREATE TABLE `ontime` ( + `Year` UInt16, + `Quarter` UInt8, + `Month` UInt8, + `DayofMonth` UInt8, + `DayOfWeek` UInt8, + `FlightDate` Date, + `UniqueCarrier` FixedString(7), + `AirlineID` Int32, + `Carrier` FixedString(2), + `TailNum` String, + `FlightNum` String, + `OriginAirportID` Int32, + `OriginAirportSeqID` Int32, + `OriginCityMarketID` Int32, + `Origin` FixedString(5), + `OriginCityName` String, + `OriginState` FixedString(2), + `OriginStateFips` String, + `OriginStateName` String, + `OriginWac` Int32, + `DestAirportID` Int32, + `DestAirportSeqID` Int32, + `DestCityMarketID` Int32, + `Dest` FixedString(5), + `DestCityName` String, + `DestState` FixedString(2), + `DestStateFips` String, + `DestStateName` String, + `DestWac` Int32, + `CRSDepTime` Int32, + `DepTime` Int32, + `DepDelay` Int32, + `DepDelayMinutes` Int32, + `DepDel15` Int32, + `DepartureDelayGroups` String, + `DepTimeBlk` String, + `TaxiOut` Int32, + `WheelsOff` Int32, + `WheelsOn` Int32, + `TaxiIn` Int32, + `CRSArrTime` Int32, + `ArrTime` Int32, + `ArrDelay` Int32, + `ArrDelayMinutes` Int32, + `ArrDel15` Int32, + `ArrivalDelayGroups` Int32, + `ArrTimeBlk` String, + `Cancelled` UInt8, + `CancellationCode` FixedString(1), + `Diverted` UInt8, + `CRSElapsedTime` Int32, + `ActualElapsedTime` Int32, + `AirTime` Int32, + `Flights` Int32, + `Distance` Int32, + `DistanceGroup` UInt8, + `CarrierDelay` Int32, + `WeatherDelay` Int32, + `NASDelay` Int32, + `SecurityDelay` Int32, + `LateAircraftDelay` Int32, + `FirstDepTime` String, + `TotalAddGTime` String, + `LongestAddGTime` String, + `DivAirportLandings` String, + `DivReachedDest` String, + `DivActualElapsedTime` String, + `DivArrDelay` String, + `DivDistance` String, + `Div1Airport` String, + `Div1AirportID` Int32, + `Div1AirportSeqID` Int32, + `Div1WheelsOn` String, + `Div1TotalGTime` String, + `Div1LongestGTime` String, + `Div1WheelsOff` String, + `Div1TailNum` String, + `Div2Airport` String, + `Div2AirportID` Int32, + `Div2AirportSeqID` Int32, + `Div2WheelsOn` String, + `Div2TotalGTime` String, + `Div2LongestGTime` String, + `Div2WheelsOff` String, + `Div2TailNum` String, + `Div3Airport` String, + `Div3AirportID` Int32, + `Div3AirportSeqID` Int32, + `Div3WheelsOn` String, + `Div3TotalGTime` String, + `Div3LongestGTime` String, + `Div3WheelsOff` String, + `Div3TailNum` String, + `Div4Airport` String, + `Div4AirportID` Int32, + `Div4AirportSeqID` Int32, + `Div4WheelsOn` String, + `Div4TotalGTime` String, + `Div4LongestGTime` String, + `Div4WheelsOff` String, + `Div4TailNum` String, + `Div5Airport` String, + `Div5AirportID` Int32, + `Div5AirportSeqID` Int32, + `Div5WheelsOn` String, + `Div5TotalGTime` String, + `Div5LongestGTime` String, + `Div5WheelsOff` String, + `Div5TailNum` String +) ENGINE = MergeTree +PARTITION BY Year +ORDER BY (Carrier, FlightDate) +SETTINGS index_granularity = 8192; +``` + +Loading data: + +``` bash +$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done +``` + +## Download of Prepared Partitions {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar +$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.ontime" +``` + +!!! info "Info" + If you will run the queries described below, you have to use the full table name, `datasets.ontime`. + +## Queries {#queries} + +Q0. + +``` sql +SELECT avg(c1) +FROM +( + SELECT Year, Month, count(*) AS c1 + FROM ontime + GROUP BY Year, Month +); +``` + +Q1. The number of flights per day from the year 2000 to 2008 + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +Q2. The number of flights delayed by more than 10 minutes, grouped by the day of the week, for 2000-2008 + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +Q3. The number of delays by the airport for 2000-2008 + +``` sql +SELECT Origin, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY Origin +ORDER BY c DESC +LIMIT 10; +``` + +Q4. The number of delays by carrier for 2007 + +``` sql +SELECT Carrier, count(*) +FROM ontime +WHERE DepDelay>10 AND Year=2007 +GROUP BY Carrier +ORDER BY count(*) DESC; +``` + +Q5. The percentage of delays by carrier for 2007 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year=2007 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year=2007 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Better version of the same query: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year=2007 +GROUP BY Carrier +ORDER BY c3 DESC +``` + +Q6. The previous request for a broader range of years, 2000-2008 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year>=2000 AND Year<=2008 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year>=2000 AND Year<=2008 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Better version of the same query: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY Carrier +ORDER BY c3 DESC; +``` + +Q7. Percentage of flights delayed for more than 10 minutes, by year + +``` sql +SELECT Year, c1/c2 +FROM +( + select + Year, + count(*)*100 as c1 + from ontime + WHERE DepDelay>10 + GROUP BY Year +) +JOIN +( + select + Year, + count(*) as c2 + from ontime + GROUP BY Year +) USING (Year) +ORDER BY Year; +``` + +Better version of the same query: + +``` sql +SELECT Year, avg(DepDelay>10)*100 +FROM ontime +GROUP BY Year +ORDER BY Year; +``` + +Q8. The most popular destinations by the number of directly connected cities for various year ranges + +``` sql +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +WHERE Year >= 2000 and Year <= 2010 +GROUP BY DestCityName +ORDER BY u DESC LIMIT 10; +``` + +Q9. + +``` sql +SELECT Year, count(*) AS c1 +FROM ontime +GROUP BY Year; +``` + +Q10. + +``` sql +SELECT + min(Year), max(Year), Carrier, count(*) AS cnt, + sum(ArrDelayMinutes>30) AS flights_delayed, + round(sum(ArrDelayMinutes>30)/count(*),2) AS rate +FROM ontime +WHERE + DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') + AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') + AND FlightDate < '2010-01-01' +GROUP by Carrier +HAVING cnt>100000 and max(Year)>1990 +ORDER by rate DESC +LIMIT 1000; +``` + +Bonus: + +``` sql +SELECT avg(cnt) +FROM +( + SELECT Year,Month,count(*) AS cnt + FROM ontime + WHERE DepDel15=1 + GROUP BY Year,Month +); + +SELECT avg(c1) FROM +( + SELECT Year,Month,count(*) AS c1 + FROM ontime + GROUP BY Year,Month +); + +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +GROUP BY DestCityName +ORDER BY u DESC +LIMIT 10; + +SELECT OriginCityName, DestCityName, count() AS c +FROM ontime +GROUP BY OriginCityName, DestCityName +ORDER BY c DESC +LIMIT 10; + +SELECT OriginCityName, count() AS c +FROM ontime +GROUP BY OriginCityName +ORDER BY c DESC +LIMIT 10; +``` + +This performance test was created by Vadim Tkachenko. See: + +- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ +- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ +- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ +- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ +- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ +- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html + +[Original article](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/en/getting_started/example_datasets/star_schema.md b/docs/en/getting-started/example-datasets/star-schema.md similarity index 100% rename from docs/en/getting_started/example_datasets/star_schema.md rename to docs/en/getting-started/example-datasets/star-schema.md diff --git a/docs/en/getting_started/example_datasets/wikistat.md b/docs/en/getting-started/example-datasets/wikistat.md similarity index 100% rename from docs/en/getting_started/example_datasets/wikistat.md rename to docs/en/getting-started/example-datasets/wikistat.md diff --git a/docs/en/getting-started/index.md b/docs/en/getting-started/index.md new file mode 100644 index 00000000000..c84b3c7c9a6 --- /dev/null +++ b/docs/en/getting-started/index.md @@ -0,0 +1,15 @@ +--- +toc_folder_title: Getting Started +toc_hidden: true +toc_priority: 8 +toc_title: hidden +--- + +# Getting Started {#getting-started} + +If you are new to ClickHouse and want to get a hands-on feeling of its performance, first of all, you need to go through the [installation process](install.md). After that you can: + +- [Go through detailed tutorial](tutorial.md) +- [Experiment with example datasets](example-datasets/ontime.md) + +[Original article](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/en/getting-started/install.md b/docs/en/getting-started/install.md new file mode 100644 index 00000000000..7c8ae631e1a --- /dev/null +++ b/docs/en/getting-started/install.md @@ -0,0 +1,180 @@ +--- +toc_priority: 11 +toc_title: Installation +--- + +# Installation {#installation} + +## System Requirements {#system-requirements} + +ClickHouse can run on any Linux, FreeBSD, or Mac OS X with x86\_64, AArch64, or PowerPC64LE CPU architecture. + +Official pre-built binaries are typically compiled for x86\_64 and leverage SSE 4.2 instruction set, so unless otherwise stated usage of CPU that supports it becomes an additional system requirement. Here’s the command to check if current CPU has support for SSE 4.2: + +``` bash +$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" +``` + +To run ClickHouse on processors that do not support SSE 4.2 or have AArch64 or PowerPC64LE architecture, you should [build ClickHouse from sources](#from-sources) with proper configuration adjustments. + +## Available Installation Options {#available-installation-options} + +### From DEB Packages {#install-from-deb-packages} + +It is recommended to use official pre-compiled `deb` packages for Debian or Ubuntu. Run these commands to install packages: + +``` bash +{% include 'install/deb.sh' %} +``` + +If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments). + +You can also download and install packages manually from [here](https://repo.clickhouse.tech/deb/stable/main/). + +#### Packages {#packages} + +- `clickhouse-common-static` — Installs ClickHouse compiled binary files. +- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` and installs the default server configuration. +- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` and other client-related tools. and installs client configuration files. +- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. + +### From RPM Packages {#from-rpm-packages} + +It is recommended to use official pre-compiled `rpm` packages for CentOS, RedHat, and all other rpm-based Linux distributions. + +First, you need to add the official repository: + +``` bash +sudo yum install yum-utils +sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG +sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 +``` + +If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments). `prestable` is sometimes also available. + +Then run these commands to install packages: + +``` bash +sudo yum install clickhouse-server clickhouse-client +``` + +You can also download and install packages manually from [here](https://repo.clickhouse.tech/rpm/stable/x86_64). + +### From Tgz Archives {#from-tgz-archives} + +It is recommended to use official pre-compiled `tgz` archives for all Linux distributions, where installation of `deb` or `rpm` packages is not possible. + +The required version can be downloaded with `curl` or `wget` from repository https://repo.clickhouse.tech/tgz/. +After that downloaded archives should be unpacked and installed with installation scripts. Example for the latest version: + +``` bash +export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz + +tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz +sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz +sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-server-$LATEST_VERSION.tgz +sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh +sudo /etc/init.d/clickhouse-server start + +tar -xzvf clickhouse-client-$LATEST_VERSION.tgz +sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh +``` + +For production environments, it’s recommended to use the latest `stable`-version. You can find its number on GitHub page https://github.com/ClickHouse/ClickHouse/tags with postfix `-stable`. + +### From Docker Image {#from-docker-image} + +To run ClickHouse inside Docker follow the guide on [Docker Hub](https://hub.docker.com/r/yandex/clickhouse-server/). Those images use official `deb` packages inside. + +### From Sources {#from-sources} + +To manually compile ClickHouse, follow the instructions for [Linux](../development/build.md) or [Mac OS X](../development/build-osx.md). + +You can compile packages and install them or use programs without installing packages. Also by building manually you can disable SSE 4.2 requirement or build for AArch64 CPUs. + + Client: programs/clickhouse-client + Server: programs/clickhouse-server + +You’ll need to create a data and metadata folders and `chown` them for the desired user. Their paths can be changed in server config (src/programs/server/config.xml), by default they are: + + /opt/clickhouse/data/default/ + /opt/clickhouse/metadata/default/ + +On Gentoo, you can just use `emerge clickhouse` to install ClickHouse from sources. + +## Launch {#launch} + +To start the server as a daemon, run: + +``` bash +$ sudo service clickhouse-server start +``` + +If you don’t have `service` command, run as + +``` bash +$ sudo /etc/init.d/clickhouse-server start +``` + +See the logs in the `/var/log/clickhouse-server/` directory. + +If the server doesn’t start, check the configurations in the file `/etc/clickhouse-server/config.xml`. + +You can also manually launch the server from the console: + +``` bash +$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml +``` + +In this case, the log will be printed to the console, which is convenient during development. +If the configuration file is in the current directory, you don’t need to specify the `--config-file` parameter. By default, it uses `./config.xml`. + +ClickHouse supports access restriction settings. They are located in the `users.xml` file (next to `config.xml`). +By default, access is allowed from anywhere for the `default` user, without a password. See `user/default/networks`. +For more information, see the section [“Configuration Files”](../operations/configuration-files.md). + +After launching server, you can use the command-line client to connect to it: + +``` bash +$ clickhouse-client +``` + +By default, it connects to `localhost:9000` on behalf of the user `default` without a password. It can also be used to connect to a remote server using `--host` argument. + +The terminal must use UTF-8 encoding. +For more information, see the section [“Command-line client”](../interfaces/cli.md). + +Example: + +``` bash +$ ./clickhouse-client +ClickHouse client version 0.0.18749. +Connecting to localhost:9000. +Connected to ClickHouse server version 0.0.18749. + +:) SELECT 1 + +SELECT 1 + +┌─1─┐ +│ 1 │ +└───┘ + +1 rows in set. Elapsed: 0.003 sec. + +:) +``` + +**Congratulations, the system works!** + +To continue experimenting, you can download one of the test data sets or go through [tutorial](https://clickhouse.tech/tutorial.html). + +[Original article](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/en/getting-started/playground.md b/docs/en/getting-started/playground.md new file mode 100644 index 00000000000..bed1618314b --- /dev/null +++ b/docs/en/getting-started/playground.md @@ -0,0 +1,64 @@ +--- +toc_priority: 14 +toc_title: Playground +--- + +# ClickHouse Playground {#clickhouse-playground} + +[ClickHouse Playground](https://play.clickhouse.tech) allows people to experiment with ClickHouse by running queries instantly, without setting up their server or cluster. +Several example datasets are available in the Playground as well as sample queries that show ClickHouse features. There's also a selection of ClickHouse LTS releases to experiment with. + +ClickHouse Playground gives the experience of m2.small [Managed Service for ClickHouse](https://cloud.yandex.com/services/managed-clickhouse) instance (4 vCPU, 32 GB RAM) hosted in [Yandex.Cloud](https://cloud.yandex.com/). More information about [cloud providers](../commercial/cloud.md). + +You can make queries to playground using any HTTP client, for example [curl](https://curl.haxx.se) or [wget](https://www.gnu.org/software/wget/), or set up a connection using [JDBC](../interfaces/jdbc.md) or [ODBC](../interfaces/odbc.md) drivers. More information about software products that support ClickHouse is available [here](../interfaces/index.md). + +## Credentials + +| Parameter | Value | +|:--------------------|:----------------------------------------| +| HTTPS endpoint | `https://play-api.clickhouse.tech:8443` | +| Native TCP endpoint | `play-api.clickhouse.tech:9440` | +| User | `playground` | +| Password | `clickhouse` | + +There are additional endpoints with specific ClickHouse releases to experiment with their differences (ports and user/password are the same as above): + +* 20.3 LTS: `play-api-v20-3.clickhouse.tech` +* 19.14 LTS: `play-api-v19-14.clickhouse.tech` + +!!! note "Note" + All these endpoints require a secure TLS connection. + +## Limitations + +The queries are executed as a read-only user. It implies some limitations: + +- DDL queries are not allowed +- INSERT queries are not allowed + +The following settings are also enforced: +- [max_result_bytes=10485760](../operations/settings/query_complexity/#max-result-bytes) +- [max_result_rows=2000](../operations/settings/query_complexity/#setting-max_result_rows) +- [result_overflow_mode=break](../operations/settings/query_complexity/#result-overflow-mode) +- [max_execution_time=60000](../operations/settings/query_complexity/#max-execution-time) + +## Examples + +HTTPS endpoint example with `curl`: + +``` bash +curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" +``` + +TCP endpoint example with [CLI](../interfaces/cli.md): +``` bash +clickhouse client --secure -h play-api.clickhouse.tech --port 9440 -u playground --password clickhouse -q "SELECT 'Play ClickHouse!'" +``` + +## Implementation Details + +ClickHouse Playground web interface makes requests via ClickHouse [HTTP API](../interfaces/http.md). +The Playground backend is just a ClickHouse cluster without any additional server-side application. As mentioned above, ClickHouse HTTPS and TCP/TLS endpoints are also publicly available as a part of the Playground, both are proxied through [Cloudflare Spectrum](https://www.cloudflare.com/products/cloudflare-spectrum/) to add extra layer of protection and improved global connectivity. + +!!! warning "Warning" + Exposing ClickHouse server to public internet in any other situation is **strongly not recommended**. Make sure it listens only on private network and is covered by properly configured firewall. diff --git a/docs/en/getting-started/tutorial.md b/docs/en/getting-started/tutorial.md new file mode 100644 index 00000000000..952161bdb0a --- /dev/null +++ b/docs/en/getting-started/tutorial.md @@ -0,0 +1,664 @@ +--- +toc_priority: 12 +toc_title: Tutorial +--- + +# ClickHouse Tutorial {#clickhouse-tutorial} + +## What to Expect from This Tutorial? {#what-to-expect-from-this-tutorial} + +By going through this tutorial, you’ll learn how to set up a simple ClickHouse cluster. It’ll be small, but fault-tolerant and scalable. Then we will use one of the example datasets to fill it with data and execute some demo queries. + +## Single Node Setup {#single-node-setup} + +To postpone the complexities of a distributed environment, we’ll start with deploying ClickHouse on a single server or virtual machine. ClickHouse is usually installed from [deb](install.md#install-from-deb-packages) or [rpm](install.md#from-rpm-packages) packages, but there are [alternatives](install.md#from-docker-image) for the operating systems that do no support them. + +For example, you have chosen `deb` packages and executed: + +``` bash +{% include 'install/deb.sh' %} +``` + +What do we have in the packages that got installed: + +- `clickhouse-client` package contains [clickhouse-client](../interfaces/cli.md) application, interactive ClickHouse console client. +- `clickhouse-common` package contains a ClickHouse executable file. +- `clickhouse-server` package contains configuration files to run ClickHouse as a server. + +Server config files are located in `/etc/clickhouse-server/`. Before going further, please notice the `` element in `config.xml`. Path determines the location for data storage, so it should be located on volume with large disk capacity; the default value is `/var/lib/clickhouse/`. If you want to adjust the configuration, it’s not handy to directly edit `config.xml` file, considering it might get rewritten on future package updates. The recommended way to override the config elements is to create [files in config.d directory](../operations/configuration-files.md) which serve as “patches” to config.xml. + +As you might have noticed, `clickhouse-server` is not launched automatically after package installation. It won’t be automatically restarted after updates, either. The way you start the server depends on your init system, usually, it is: + +``` bash +sudo service clickhouse-server start +``` + +or + +``` bash +sudo /etc/init.d/clickhouse-server start +``` + +The default location for server logs is `/var/log/clickhouse-server/`. The server is ready to handle client connections once it logs the `Ready for connections` message. + +Once the `clickhouse-server` is up and running, we can use `clickhouse-client` to connect to the server and run some test queries like `SELECT "Hello, world!";`. + +
+ +Quick tips for clickhouse-client + +Interactive mode: + +``` bash +clickhouse-client +clickhouse-client --host=... --port=... --user=... --password=... +``` + +Enable multiline queries: + +``` bash +clickhouse-client -m +clickhouse-client --multiline +``` + +Run queries in batch-mode: + +``` bash +clickhouse-client --query='SELECT 1' +echo 'SELECT 1' | clickhouse-client +clickhouse-client <<< 'SELECT 1' +``` + +Insert data from a file in specified format: + +``` bash +clickhouse-client --query='INSERT INTO table VALUES' < data.txt +clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv +``` + +
+ +## Import Sample Dataset {#import-sample-dataset} + +Now it’s time to fill our ClickHouse server with some sample data. In this tutorial, we’ll use the anonymized data of Yandex.Metrica, the first service that runs ClickHouse in production way before it became open-source (more on that in [history section](../introduction/history.md)). There are [multiple ways to import Yandex.Metrica dataset](example-datasets/metrica.md), and for the sake of the tutorial, we’ll go with the most realistic one. + +### Download and Extract Table Data {#download-and-extract-table-data} + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +``` + +The extracted files are about 10GB in size. + +### Create Tables {#create-tables} + +As in most databases management systems, ClickHouse logically groups tables into “databases”. There’s a `default` database, but we’ll create a new one named `tutorial`: + +``` bash +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" +``` + +Syntax for creating tables is way more complicated compared to databases (see [reference](../sql-reference/statements/create.md). In general `CREATE TABLE` statement has to specify three key things: + +1. Name of table to create. +2. Table schema, i.e. list of columns and their [data types](../sql-reference/data-types/index.md). +3. [Table engine](../engines/table-engines/index.md) and its settings, which determines all the details on how queries to this table will be physically executed. + +Yandex.Metrica is a web analytics service, and sample dataset doesn’t cover its full functionality, so there are only two tables to create: + +- `hits` is a table with each action done by all users on all websites covered by the service. +- `visits` is a table that contains pre-built sessions instead of individual actions. + +Let’s see and execute the real create table queries for these tables: + +``` sql +CREATE TABLE tutorial.hits_v1 +( + `WatchID` UInt64, + `JavaEnable` UInt8, + `Title` String, + `GoodEvent` Int16, + `EventTime` DateTime, + `EventDate` Date, + `CounterID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RegionID` UInt32, + `UserID` UInt64, + `CounterClass` Int8, + `OS` UInt8, + `UserAgent` UInt8, + `URL` String, + `Referer` String, + `URLDomain` String, + `RefererDomain` String, + `Refresh` UInt8, + `IsRobot` UInt8, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `FlashMinor2` String, + `NetMajor` UInt8, + `NetMinor` UInt8, + `UserAgentMajor` UInt16, + `UserAgentMinor` FixedString(2), + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `MobilePhone` UInt8, + `MobilePhoneModel` String, + `Params` String, + `IPNetworkID` UInt32, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `IsArtifical` UInt8, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `ClientTimeZone` Int16, + `ClientEventTime` DateTime, + `SilverlightVersion1` UInt8, + `SilverlightVersion2` UInt8, + `SilverlightVersion3` UInt32, + `SilverlightVersion4` UInt16, + `PageCharset` String, + `CodeVersion` UInt32, + `IsLink` UInt8, + `IsDownload` UInt8, + `IsNotBounce` UInt8, + `FUniqID` UInt64, + `HID` UInt32, + `IsOldCounter` UInt8, + `IsEvent` UInt8, + `IsParameter` UInt8, + `DontCountHits` UInt8, + `WithHash` UInt8, + `HitColor` FixedString(1), + `UTCEventTime` DateTime, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `WindowName` Int32, + `OpenerName` Int32, + `HistoryLength` Int16, + `BrowserLanguage` FixedString(2), + `BrowserCountry` FixedString(2), + `SocialNetwork` String, + `SocialAction` String, + `HTTPError` UInt16, + `SendTiming` Int32, + `DNSTiming` Int32, + `ConnectTiming` Int32, + `ResponseStartTiming` Int32, + `ResponseEndTiming` Int32, + `FetchTiming` Int32, + `RedirectTiming` Int32, + `DOMInteractiveTiming` Int32, + `DOMContentLoadedTiming` Int32, + `DOMCompleteTiming` Int32, + `LoadEventStartTiming` Int32, + `LoadEventEndTiming` Int32, + `NSToDOMContentLoadedTiming` Int32, + `FirstPaintTiming` Int32, + `RedirectCount` Int8, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `ParamPrice` Int64, + `ParamOrderID` String, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `GoalsReached` Array(UInt32), + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `RefererHash` UInt64, + `URLHash` UInt64, + `CLID` UInt32, + `YCLID` UInt64, + `ShareService` String, + `ShareURL` String, + `ShareTitle` String, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `IslandID` FixedString(16), + `RequestNum` UInt32, + `RequestTry` UInt8 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +``` sql +CREATE TABLE tutorial.visits_v1 +( + `CounterID` UInt32, + `StartDate` Date, + `Sign` Int8, + `IsNew` UInt8, + `VisitID` UInt64, + `UserID` UInt64, + `StartTime` DateTime, + `Duration` UInt32, + `UTCStartTime` DateTime, + `PageViews` Int32, + `Hits` Int32, + `IsBounce` UInt8, + `Referer` String, + `StartURL` String, + `RefererDomain` String, + `StartURLDomain` String, + `EndURL` String, + `LinkURL` String, + `IsDownload` UInt8, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `PlaceID` Int32, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `IsYandex` UInt8, + `GoalReachesDepth` Int32, + `GoalReachesURL` Int32, + `GoalReachesAny` Int32, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `MobilePhoneModel` String, + `ClientEventTime` DateTime, + `RegionID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `IPNetworkID` UInt32, + `SilverlightVersion3` UInt32, + `CodeVersion` UInt32, + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `UserAgentMajor` UInt16, + `UserAgentMinor` UInt16, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `SilverlightVersion2` UInt8, + `SilverlightVersion4` UInt16, + `FlashVersion3` UInt16, + `FlashVersion4` UInt16, + `ClientTimeZone` Int16, + `OS` UInt8, + `UserAgent` UInt8, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `NetMajor` UInt8, + `NetMinor` UInt8, + `MobilePhone` UInt8, + `SilverlightVersion1` UInt8, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `JavaEnable` UInt8, + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `BrowserLanguage` UInt16, + `BrowserCountry` UInt16, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `Params` Array(String), + `Goals` Nested( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32), + `WatchIDs` Array(UInt64), + `ParamSumPrice` Int64, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `ClickLogID` UInt64, + `ClickEventID` Int32, + `ClickGoodEvent` Int32, + `ClickEventTime` DateTime, + `ClickPriorityID` Int32, + `ClickPhraseID` Int32, + `ClickPageID` Int32, + `ClickPlaceID` Int32, + `ClickTypeID` Int32, + `ClickResourceID` Int32, + `ClickCost` UInt32, + `ClickClientIP` UInt32, + `ClickDomainID` UInt32, + `ClickURL` String, + `ClickAttempt` UInt8, + `ClickOrderID` UInt32, + `ClickBannerID` UInt32, + `ClickMarketCategoryID` UInt32, + `ClickMarketPP` UInt32, + `ClickMarketCategoryName` String, + `ClickMarketPPName` String, + `ClickAWAPSCampaignName` String, + `ClickPageName` String, + `ClickTargetType` UInt16, + `ClickTargetPhraseID` UInt64, + `ClickContextType` UInt8, + `ClickSelectType` Int8, + `ClickOptions` String, + `ClickGroupBannerID` Int32, + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `FirstVisit` DateTime, + `PredLastVisit` Date, + `LastVisit` Date, + `TotalVisits` UInt32, + `TraficSource` Nested( + ID Int8, + SearchEngineID UInt16, + AdvEngineID UInt8, + PlaceID UInt16, + SocialSourceNetworkID UInt8, + Domain String, + SearchPhrase String, + SocialSourcePage String), + `Attendance` FixedString(16), + `CLID` UInt32, + `YCLID` UInt64, + `NormalizedRefererHash` UInt64, + `SearchPhraseHash` UInt64, + `RefererDomainHash` UInt64, + `NormalizedStartURLHash` UInt64, + `StartURLDomainHash` UInt64, + `NormalizedEndURLHash` UInt64, + `TopLevelDomain` UInt64, + `URLScheme` UInt64, + `OpenstatServiceNameHash` UInt64, + `OpenstatCampaignIDHash` UInt64, + `OpenstatAdIDHash` UInt64, + `OpenstatSourceIDHash` UInt64, + `UTMSourceHash` UInt64, + `UTMMediumHash` UInt64, + `UTMCampaignHash` UInt64, + `UTMContentHash` UInt64, + `UTMTermHash` UInt64, + `FromHash` UInt64, + `WebVisorEnabled` UInt8, + `WebVisorActivity` UInt32, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `Market` Nested( + Type UInt8, + GoalID UInt32, + OrderID String, + OrderPrice Int64, + PP UInt32, + DirectPlaceID UInt32, + DirectOrderID UInt32, + DirectBannerID UInt32, + GoodID String, + GoodName String, + GoodQuantity Int32, + GoodPrice Int64), + `IslandID` FixedString(16) +) +ENGINE = CollapsingMergeTree(Sign) +PARTITION BY toYYYYMM(StartDate) +ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +You can execute those queries using the interactive mode of `clickhouse-client` (just launch it in a terminal without specifying a query in advance) or try some [alternative interface](../interfaces/index.md) if you want. + +As we can see, `hits_v1` uses the [basic MergeTree engine](../engines/table-engines/mergetree-family/mergetree.md), while the `visits_v1` uses the [Collapsing](../engines/table-engines/mergetree-family/collapsingmergetree.md) variant. + +### Import Data {#import-data} + +Data import to ClickHouse is done via [INSERT INTO](../sql-reference/statements/insert-into.md) query like in many other SQL databases. However, data is usually provided in one of the [supported serialization formats](../interfaces/formats.md) instead of `VALUES` clause (which is also supported). + +The files we downloaded earlier are in tab-separated format, so here’s how to import them via console client: + +``` bash +clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv +clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv +``` + +ClickHouse has a lot of [settings to tune](../operations/settings/index.md) and one way to specify them in console client is via arguments, as we can see with `--max_insert_block_size`. The easiest way to figure out what settings are available, what do they mean and what the defaults are is to query the `system.settings` table: + +``` sql +SELECT name, value, changed, description +FROM system.settings +WHERE name LIKE '%max_insert_b%' +FORMAT TSV + +max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." +``` + +Optionally you can [OPTIMIZE](../sql-reference/statements/misc.md#misc_operations-optimize) the tables after import. Tables that are configured with an engine from MergeTree-family always do merges of data parts in the background to optimize data storage (or at least check if it makes sense). These queries force the table engine to do storage optimization right now instead of some time later: + +``` bash +clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" +clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" +``` + +These queries start an I/O and CPU intensive operation, so if the table consistently receives new data, it’s better to leave it alone and let merges run in the background. + +Now we can check if the table import was successful: + +``` bash +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" +``` + +## Example Queries {#example-queries} + +``` sql +SELECT + StartURL AS URL, + AVG(Duration) AS AvgDuration +FROM tutorial.visits_v1 +WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' +GROUP BY URL +ORDER BY AvgDuration DESC +LIMIT 10 +``` + +``` sql +SELECT + sum(Sign) AS visits, + sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, + (100. * goal_visits) / visits AS goal_percent +FROM tutorial.visits_v1 +WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') +``` + +## Cluster Deployment {#cluster-deployment} + +ClickHouse cluster is a homogenous cluster. Steps to set up: + +1. Install ClickHouse server on all machines of the cluster +2. Set up cluster configs in configuration files +3. Create local tables on each instance +4. Create a [Distributed table](../engines/table-engines/special/distributed.md) + +[Distributed table](../engines/table-engines/special/distributed.md) is actually a kind of “view” to local tables of ClickHouse cluster. SELECT query from a distributed table executes using resources of all cluster’s shards. You may specify configs for multiple clusters and create multiple distributed tables providing views to different clusters. + +Example config for a cluster with three shards, one replica each: + +``` xml + + + + + example-perftest01j.yandex.ru + 9000 + + + + + example-perftest02j.yandex.ru + 9000 + + + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +For further demonstration, let’s create a new local table with the same `CREATE TABLE` query that we used for `hits_v1`, but different table name: + +``` sql +CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... +``` + +Creating a distributed table providing a view into local tables of the cluster: + +``` sql +CREATE TABLE tutorial.hits_all AS tutorial.hits_local +ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); +``` + +A common practice is to create similar Distributed tables on all machines of the cluster. It allows running distributed queries on any machine of the cluster. Also there’s an alternative option to create temporary distributed table for a given SELECT query using [remote](../sql-reference/table-functions/remote.md) table function. + +Let’s run [INSERT SELECT](../sql-reference/statements/insert-into.md) into the Distributed table to spread the table to multiple servers. + +``` sql +INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; +``` + +!!! warning "Notice" + This approach is not suitable for the sharding of large tables. There’s a separate tool [clickhouse-copier](../operations/utilities/clickhouse-copier.md) that can re-shard arbitrary large tables. + +As you could expect, computationally heavy queries run N times faster if they utilize 3 servers instead of one. + +In this case, we have used a cluster with 3 shards, and each contains a single replica. + +To provide resilience in a production environment, we recommend that each shard should contain 2-3 replicas spread between multiple availability zones or datacenters (or at least racks). Note that ClickHouse supports an unlimited number of replicas. + +Example config for a cluster of one shard containing three replicas: + +``` xml + + ... + + + + example-perftest01j.yandex.ru + 9000 + + + example-perftest02j.yandex.ru + 9000 + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +To enable native replication [ZooKeeper](http://zookeeper.apache.org/) is required. ClickHouse takes care of data consistency on all replicas and runs restore procedure after failure automatically. It’s recommended to deploy the ZooKeeper cluster on separate servers (where no other processes including ClickHouse are running). + +!!! note "Note" + ZooKeeper is not a strict requirement: in some simple cases, you can duplicate the data by writing it into all the replicas from your application code. This approach is **not** recommended, in this case, ClickHouse won’t be able to guarantee data consistency on all replicas. Thus it becomes the responsibility of your application. + +ZooKeeper locations are specified in the configuration file: + +``` xml + + + zoo01.yandex.ru + 2181 + + + zoo02.yandex.ru + 2181 + + + zoo03.yandex.ru + 2181 + + +``` + +Also, we need to set macros for identifying each shard and replica which are used on table creation: + +``` xml + + 01 + 01 + +``` + +If there are no replicas at the moment on replicated table creation, a new first replica is instantiated. If there are already live replicas, the new replica clones data from existing ones. You have an option to create all replicated tables first, and then insert data to it. Another option is to create some replicas and add the others after or during data insertion. + +``` sql +CREATE TABLE tutorial.hits_replica (...) +ENGINE = ReplcatedMergeTree( + '/clickhouse_perftest/tables/{shard}/hits', + '{replica}' +) +... +``` + +Here we use [ReplicatedMergeTree](../engines/table-engines/mergetree-family/replication.md) table engine. In parameters we specify ZooKeeper path containing shard and replica identifiers. + +``` sql +INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; +``` + +Replication operates in multi-master mode. Data can be loaded into any replica, and the system then syncs it with other instances automatically. Replication is asynchronous so at a given moment, not all replicas may contain recently inserted data. At least one replica should be up to allow data ingestion. Others will sync up data and repair consistency once they will become active again. Note that this approach allows for the low possibility of a loss of recently inserted data. + +[Original article](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/en/getting_started/example_datasets/index.md b/docs/en/getting_started/example_datasets/index.md deleted file mode 100644 index a94dff3cef8..00000000000 --- a/docs/en/getting_started/example_datasets/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -toc_folder_title: Example Datasets -toc_priority: 12 -toc_title: Introduction ---- - -# Example Datasets - -This section describes how to obtain example datasets and import them into ClickHouse. -For some datasets example queries are also available. - -* [Anonymized Yandex.Metrica Dataset](metrica.md) -* [Star Schema Benchmark](star_schema.md) -* [WikiStat](wikistat.md) -* [Terabyte of Click Logs from Criteo](criteo.md) -* [AMPLab Big Data Benchmark](amplab_benchmark.md) -* [New York Taxi Data](nyc_taxi.md) -* [OnTime](ontime.md) - -[Original article](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/en/getting_started/example_datasets/metrica.md b/docs/en/getting_started/example_datasets/metrica.md deleted file mode 100644 index 366531fa8e7..00000000000 --- a/docs/en/getting_started/example_datasets/metrica.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -toc_priority: 21 -toc_title: Yandex.Metrica Data ---- - -# Anonymized Yandex.Metrica Data {#anonymized-yandex-metrica-data} - -Dataset consists of two tables containing anonymized data about hits (`hits_v1`) and visits (`visits_v1`) of Yandex.Metrica. You can read more about Yandex.Metrica in [ClickHouse history](../../introduction/history.md) section. - -The dataset consists of two tables, either of them can be downloaded as a compressed `tsv.xz` file or as prepared partitions. In addition to that, an extended version of the `hits` table containing 100 million rows is available as TSV at https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_100m_obfuscated_v1.tsv.xz and as prepared partitions at https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz. - -## Obtaining Tables from Prepared Partitions {#obtaining-tables-from-prepared-partitions} - -Download and import hits table: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar -tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Download and import visits: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar -tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Obtaining Tables from Compressed TSV File {#obtaining-tables-from-compressed-tsv-file} - -Download and import hits from compressed TSV file: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Download and import visits from compressed tsv-file: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Example Queries {#example-queries} - -[ClickHouse tutorial](../../getting_started/tutorial.md) is based on Yandex.Metrica dataset and the recommended way to get started with this dataset is to just go through tutorial. - -Additional examples of queries to these tables can be found among [stateful tests](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) of ClickHouse (they are named `test.hists` and `test.visits` there). diff --git a/docs/en/getting_started/example_datasets/nyc_taxi.md b/docs/en/getting_started/example_datasets/nyc_taxi.md deleted file mode 100644 index 6c7b274e7d4..00000000000 --- a/docs/en/getting_started/example_datasets/nyc_taxi.md +++ /dev/null @@ -1,388 +0,0 @@ ---- -toc_priority: 16 -toc_title: New York Taxi Data ---- - -# New York Taxi Data {#new-york-taxi-data} - -This dataset can be obtained in two ways: - -- import from raw data -- download of prepared partitions - -## How to Import The Raw Data {#how-to-import-the-raw-data} - -See https://github.com/toddwschneider/nyc-taxi-data and http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html for the description of a dataset and instructions for downloading. - -Downloading will result in about 227 GB of uncompressed data in CSV files. The download takes about an hour over a 1 Gbit connection (parallel downloading from s3.amazonaws.com recovers at least half of a 1 Gbit channel). -Some of the files might not download fully. Check the file sizes and re-download any that seem doubtful. - -Some of the files might contain invalid rows. You can fix them as follows: - -``` bash -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ -mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv -mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv -``` - -Then the data must be pre-processed in PostgreSQL. This will create selections of points in the polygons (to match points on the map with the boroughs of New York City) and combine all the data into a single denormalized flat table by using a JOIN. To do this, you will need to install PostgreSQL with PostGIS support. - -Be careful when running `initialize_database.sh` and manually re-check that all the tables were created correctly. - -It takes about 20-30 minutes to process each month’s worth of data in PostgreSQL, for a total of about 48 hours. - -You can check the number of downloaded rows as follows: - -``` bash -$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" -## Count - 1298979494 -(1 row) - -real 7m9.164s -``` - -(This is slightly more than 1.1 billion rows reported by Mark Litwintschik in a series of blog posts.) - -The data in PostgreSQL uses 370 GB of space. - -Exporting the data from PostgreSQL: - -``` sql -COPY -( - SELECT trips.id, - trips.vendor_id, - trips.pickup_datetime, - trips.dropoff_datetime, - trips.store_and_fwd_flag, - trips.rate_code_id, - trips.pickup_longitude, - trips.pickup_latitude, - trips.dropoff_longitude, - trips.dropoff_latitude, - trips.passenger_count, - trips.trip_distance, - trips.fare_amount, - trips.extra, - trips.mta_tax, - trips.tip_amount, - trips.tolls_amount, - trips.ehail_fee, - trips.improvement_surcharge, - trips.total_amount, - trips.payment_type, - trips.trip_type, - trips.pickup, - trips.dropoff, - - cab_types.type cab_type, - - weather.precipitation_tenths_of_mm rain, - weather.snow_depth_mm, - weather.snowfall_mm, - weather.max_temperature_tenths_degrees_celsius max_temp, - weather.min_temperature_tenths_degrees_celsius min_temp, - weather.average_wind_speed_tenths_of_meters_per_second wind, - - pick_up.gid pickup_nyct2010_gid, - pick_up.ctlabel pickup_ctlabel, - pick_up.borocode pickup_borocode, - pick_up.boroname pickup_boroname, - pick_up.ct2010 pickup_ct2010, - pick_up.boroct2010 pickup_boroct2010, - pick_up.cdeligibil pickup_cdeligibil, - pick_up.ntacode pickup_ntacode, - pick_up.ntaname pickup_ntaname, - pick_up.puma pickup_puma, - - drop_off.gid dropoff_nyct2010_gid, - drop_off.ctlabel dropoff_ctlabel, - drop_off.borocode dropoff_borocode, - drop_off.boroname dropoff_boroname, - drop_off.ct2010 dropoff_ct2010, - drop_off.boroct2010 dropoff_boroct2010, - drop_off.cdeligibil dropoff_cdeligibil, - drop_off.ntacode dropoff_ntacode, - drop_off.ntaname dropoff_ntaname, - drop_off.puma dropoff_puma - FROM trips - LEFT JOIN cab_types - ON trips.cab_type_id = cab_types.id - LEFT JOIN central_park_weather_observations_raw weather - ON weather.date = trips.pickup_datetime::date - LEFT JOIN nyct2010 pick_up - ON pick_up.gid = trips.pickup_nyct2010_gid - LEFT JOIN nyct2010 drop_off - ON drop_off.gid = trips.dropoff_nyct2010_gid -) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; -``` - -The data snapshot is created at a speed of about 50 MB per second. While creating the snapshot, PostgreSQL reads from the disk at a speed of about 28 MB per second. -This takes about 5 hours. The resulting TSV file is 590612904969 bytes. - -Create a temporary table in ClickHouse: - -``` sql -CREATE TABLE trips -( -trip_id UInt32, -vendor_id String, -pickup_datetime DateTime, -dropoff_datetime Nullable(DateTime), -store_and_fwd_flag Nullable(FixedString(1)), -rate_code_id Nullable(UInt8), -pickup_longitude Nullable(Float64), -pickup_latitude Nullable(Float64), -dropoff_longitude Nullable(Float64), -dropoff_latitude Nullable(Float64), -passenger_count Nullable(UInt8), -trip_distance Nullable(Float64), -fare_amount Nullable(Float32), -extra Nullable(Float32), -mta_tax Nullable(Float32), -tip_amount Nullable(Float32), -tolls_amount Nullable(Float32), -ehail_fee Nullable(Float32), -improvement_surcharge Nullable(Float32), -total_amount Nullable(Float32), -payment_type Nullable(String), -trip_type Nullable(UInt8), -pickup Nullable(String), -dropoff Nullable(String), -cab_type Nullable(String), -precipitation Nullable(UInt8), -snow_depth Nullable(UInt8), -snowfall Nullable(UInt8), -max_temperature Nullable(UInt8), -min_temperature Nullable(UInt8), -average_wind_speed Nullable(UInt8), -pickup_nyct2010_gid Nullable(UInt8), -pickup_ctlabel Nullable(String), -pickup_borocode Nullable(UInt8), -pickup_boroname Nullable(String), -pickup_ct2010 Nullable(String), -pickup_boroct2010 Nullable(String), -pickup_cdeligibil Nullable(FixedString(1)), -pickup_ntacode Nullable(String), -pickup_ntaname Nullable(String), -pickup_puma Nullable(String), -dropoff_nyct2010_gid Nullable(UInt8), -dropoff_ctlabel Nullable(String), -dropoff_borocode Nullable(UInt8), -dropoff_boroname Nullable(String), -dropoff_ct2010 Nullable(String), -dropoff_boroct2010 Nullable(String), -dropoff_cdeligibil Nullable(String), -dropoff_ntacode Nullable(String), -dropoff_ntaname Nullable(String), -dropoff_puma Nullable(String) -) ENGINE = Log; -``` - -It is needed for converting fields to more correct data types and, if possible, to eliminate NULLs. - -``` bash -$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv - -real 75m56.214s -``` - -Data is read at a speed of 112-140 Mb/second. -Loading data into a Log type table in one stream took 76 minutes. -The data in this table uses 142 GB. - -(Importing data directly from Postgres is also possible using `COPY ... TO PROGRAM`.) - -Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. - -To start, we’ll create a table on a single server. Later we will make the table distributed. - -Create and populate a summary table: - -``` sql -CREATE TABLE trips_mergetree -ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -AS SELECT - -trip_id, -CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, -toDate(pickup_datetime) AS pickup_date, -ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, -toDate(dropoff_datetime) AS dropoff_date, -ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, -assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, -assumeNotNull(rate_code_id) AS rate_code_id, -assumeNotNull(pickup_longitude) AS pickup_longitude, -assumeNotNull(pickup_latitude) AS pickup_latitude, -assumeNotNull(dropoff_longitude) AS dropoff_longitude, -assumeNotNull(dropoff_latitude) AS dropoff_latitude, -assumeNotNull(passenger_count) AS passenger_count, -assumeNotNull(trip_distance) AS trip_distance, -assumeNotNull(fare_amount) AS fare_amount, -assumeNotNull(extra) AS extra, -assumeNotNull(mta_tax) AS mta_tax, -assumeNotNull(tip_amount) AS tip_amount, -assumeNotNull(tolls_amount) AS tolls_amount, -assumeNotNull(ehail_fee) AS ehail_fee, -assumeNotNull(improvement_surcharge) AS improvement_surcharge, -assumeNotNull(total_amount) AS total_amount, -CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, -assumeNotNull(trip_type) AS trip_type, -ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, -ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, -CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, - -assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, -toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, -assumeNotNull(pickup_borocode) AS pickup_borocode, -CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, -toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, -toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, -CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, -toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, - -CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, - -toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, - -assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, -toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, -assumeNotNull(dropoff_borocode) AS dropoff_borocode, -CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, -toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, -toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, -CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, -toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, - -CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, - -toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma - -FROM trips -``` - -This takes 3030 seconds at a speed of about 428,000 rows per second. -To load it faster, you can create the table with the `Log` engine instead of `MergeTree`. In this case, the download works faster than 200 seconds. - -The table uses 126 GB of disk space. - -``` sql -SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active -``` - -``` text -┌─formatReadableSize(sum(bytes))─┐ -│ 126.18 GiB │ -└────────────────────────────────┘ -``` - -Among other things, you can run the OPTIMIZE query on MergeTree. But it’s not required since everything will be fine without it. - -## Download of Prepared Partitions {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar -$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" -``` - -!!! info "Info" - If you will run the queries described below, you have to use the full table name, `datasets.trips_mergetree`. - -## Results on Single Server {#results-on-single-server} - -Q1: - -``` sql -SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type -``` - -0.490 seconds. - -Q2: - -``` sql -SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count -``` - -1.224 seconds. - -Q3: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year -``` - -2.104 seconds. - -Q4: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) -FROM trips_mergetree -GROUP BY passenger_count, year, distance -ORDER BY year, count(*) DESC -``` - -3.593 seconds. - -The following server was used: - -Two Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz, 16 physical kernels total,128 GiB RAM,8x6 TB HD on hardware RAID-5 - -Execution time is the best of three runs. But starting from the second run, queries read data from the file system cache. No further caching occurs: the data is read out and processed in each run. - -Creating a table on three servers: - -On each server: - -``` sql -CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -``` - -On the source server: - -``` sql -CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) -``` - -The following query redistributes data: - -``` sql -INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree -``` - -This takes 2454 seconds. - -On three servers: - -Q1: 0.212 seconds. -Q2: 0.438 seconds. -Q3: 0.733 seconds. -Q4: 1.241 seconds. - -No surprises here, since the queries are scaled linearly. - -We also have the results from a cluster of 140 servers: - -Q1: 0.028 sec. -Q2: 0.043 sec. -Q3: 0.051 sec. -Q4: 0.072 sec. - -In this case, the query processing time is determined above all by network latency. -We ran queries using a client located in a Yandex datacenter in Finland on a cluster in Russia, which added about 20 ms of latency. - -## Summary {#summary} - -| servers | Q1 | Q2 | Q3 | Q4 | -|-------|-----|-----|-----|-----| -| 1 | 0.490 | 1.224 | 2.104 | 3.593 | -| 3 | 0.212 | 0.438 | 0.733 | 1.241 | -| 140 | 0.028 | 0.043 | 0.051 | 0.072 | - -[Original article](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/en/getting_started/example_datasets/ontime.md b/docs/en/getting_started/example_datasets/ontime.md deleted file mode 100644 index 11c9f595eab..00000000000 --- a/docs/en/getting_started/example_datasets/ontime.md +++ /dev/null @@ -1,410 +0,0 @@ ---- -toc_priority: 15 -toc_title: OnTime ---- - -# OnTime {#ontime} - -This dataset can be obtained in two ways: - -- import from raw data -- download of prepared partitions - -## Import From Raw Data {#import-from-raw-data} - -Downloading data: - -``` bash -for s in `seq 1987 2018` -do -for m in `seq 1 12` -do -wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip -done -done -``` - -(from https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) - -Creating a table: - -``` sql -CREATE TABLE `ontime` ( - `Year` UInt16, - `Quarter` UInt8, - `Month` UInt8, - `DayofMonth` UInt8, - `DayOfWeek` UInt8, - `FlightDate` Date, - `UniqueCarrier` FixedString(7), - `AirlineID` Int32, - `Carrier` FixedString(2), - `TailNum` String, - `FlightNum` String, - `OriginAirportID` Int32, - `OriginAirportSeqID` Int32, - `OriginCityMarketID` Int32, - `Origin` FixedString(5), - `OriginCityName` String, - `OriginState` FixedString(2), - `OriginStateFips` String, - `OriginStateName` String, - `OriginWac` Int32, - `DestAirportID` Int32, - `DestAirportSeqID` Int32, - `DestCityMarketID` Int32, - `Dest` FixedString(5), - `DestCityName` String, - `DestState` FixedString(2), - `DestStateFips` String, - `DestStateName` String, - `DestWac` Int32, - `CRSDepTime` Int32, - `DepTime` Int32, - `DepDelay` Int32, - `DepDelayMinutes` Int32, - `DepDel15` Int32, - `DepartureDelayGroups` String, - `DepTimeBlk` String, - `TaxiOut` Int32, - `WheelsOff` Int32, - `WheelsOn` Int32, - `TaxiIn` Int32, - `CRSArrTime` Int32, - `ArrTime` Int32, - `ArrDelay` Int32, - `ArrDelayMinutes` Int32, - `ArrDel15` Int32, - `ArrivalDelayGroups` Int32, - `ArrTimeBlk` String, - `Cancelled` UInt8, - `CancellationCode` FixedString(1), - `Diverted` UInt8, - `CRSElapsedTime` Int32, - `ActualElapsedTime` Int32, - `AirTime` Int32, - `Flights` Int32, - `Distance` Int32, - `DistanceGroup` UInt8, - `CarrierDelay` Int32, - `WeatherDelay` Int32, - `NASDelay` Int32, - `SecurityDelay` Int32, - `LateAircraftDelay` Int32, - `FirstDepTime` String, - `TotalAddGTime` String, - `LongestAddGTime` String, - `DivAirportLandings` String, - `DivReachedDest` String, - `DivActualElapsedTime` String, - `DivArrDelay` String, - `DivDistance` String, - `Div1Airport` String, - `Div1AirportID` Int32, - `Div1AirportSeqID` Int32, - `Div1WheelsOn` String, - `Div1TotalGTime` String, - `Div1LongestGTime` String, - `Div1WheelsOff` String, - `Div1TailNum` String, - `Div2Airport` String, - `Div2AirportID` Int32, - `Div2AirportSeqID` Int32, - `Div2WheelsOn` String, - `Div2TotalGTime` String, - `Div2LongestGTime` String, - `Div2WheelsOff` String, - `Div2TailNum` String, - `Div3Airport` String, - `Div3AirportID` Int32, - `Div3AirportSeqID` Int32, - `Div3WheelsOn` String, - `Div3TotalGTime` String, - `Div3LongestGTime` String, - `Div3WheelsOff` String, - `Div3TailNum` String, - `Div4Airport` String, - `Div4AirportID` Int32, - `Div4AirportSeqID` Int32, - `Div4WheelsOn` String, - `Div4TotalGTime` String, - `Div4LongestGTime` String, - `Div4WheelsOff` String, - `Div4TailNum` String, - `Div5Airport` String, - `Div5AirportID` Int32, - `Div5AirportSeqID` Int32, - `Div5WheelsOn` String, - `Div5TotalGTime` String, - `Div5LongestGTime` String, - `Div5WheelsOff` String, - `Div5TailNum` String -) ENGINE = MergeTree -PARTITION BY Year -ORDER BY (Carrier, FlightDate) -SETTINGS index_granularity = 8192; -``` - -Loading data: - -``` bash -$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done -``` - -## Download of Prepared Partitions {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar -$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.ontime" -``` - -!!! info "Info" - If you will run the queries described below, you have to use the full table name, `datasets.ontime`. - -## Queries {#queries} - -Q0. - -``` sql -SELECT avg(c1) -FROM -( - SELECT Year, Month, count(*) AS c1 - FROM ontime - GROUP BY Year, Month -); -``` - -Q1. The number of flights per day from the year 2000 to 2008 - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -Q2. The number of flights delayed by more than 10 minutes, grouped by the day of the week, for 2000-2008 - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -Q3. The number of delays by the airport for 2000-2008 - -``` sql -SELECT Origin, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY Origin -ORDER BY c DESC -LIMIT 10; -``` - -Q4. The number of delays by carrier for 2007 - -``` sql -SELECT Carrier, count(*) -FROM ontime -WHERE DepDelay>10 AND Year=2007 -GROUP BY Carrier -ORDER BY count(*) DESC; -``` - -Q5. The percentage of delays by carrier for 2007 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year=2007 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year=2007 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Better version of the same query: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year=2007 -GROUP BY Carrier -ORDER BY c3 DESC -``` - -Q6. The previous request for a broader range of years, 2000-2008 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year>=2000 AND Year<=2008 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year>=2000 AND Year<=2008 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Better version of the same query: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY Carrier -ORDER BY c3 DESC; -``` - -Q7. Percentage of flights delayed for more than 10 minutes, by year - -``` sql -SELECT Year, c1/c2 -FROM -( - select - Year, - count(*)*100 as c1 - from ontime - WHERE DepDelay>10 - GROUP BY Year -) -JOIN -( - select - Year, - count(*) as c2 - from ontime - GROUP BY Year -) USING (Year) -ORDER BY Year; -``` - -Better version of the same query: - -``` sql -SELECT Year, avg(DepDelay>10)*100 -FROM ontime -GROUP BY Year -ORDER BY Year; -``` - -Q8. The most popular destinations by the number of directly connected cities for various year ranges - -``` sql -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -WHERE Year >= 2000 and Year <= 2010 -GROUP BY DestCityName -ORDER BY u DESC LIMIT 10; -``` - -Q9. - -``` sql -SELECT Year, count(*) AS c1 -FROM ontime -GROUP BY Year; -``` - -Q10. - -``` sql -SELECT - min(Year), max(Year), Carrier, count(*) AS cnt, - sum(ArrDelayMinutes>30) AS flights_delayed, - round(sum(ArrDelayMinutes>30)/count(*),2) AS rate -FROM ontime -WHERE - DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') - AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') - AND FlightDate < '2010-01-01' -GROUP by Carrier -HAVING cnt>100000 and max(Year)>1990 -ORDER by rate DESC -LIMIT 1000; -``` - -Bonus: - -``` sql -SELECT avg(cnt) -FROM -( - SELECT Year,Month,count(*) AS cnt - FROM ontime - WHERE DepDel15=1 - GROUP BY Year,Month -); - -SELECT avg(c1) FROM -( - SELECT Year,Month,count(*) AS c1 - FROM ontime - GROUP BY Year,Month -); - -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -GROUP BY DestCityName -ORDER BY u DESC -LIMIT 10; - -SELECT OriginCityName, DestCityName, count() AS c -FROM ontime -GROUP BY OriginCityName, DestCityName -ORDER BY c DESC -LIMIT 10; - -SELECT OriginCityName, count() AS c -FROM ontime -GROUP BY OriginCityName -ORDER BY c DESC -LIMIT 10; -``` - -This performance test was created by Vadim Tkachenko. See: - -- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ -- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ -- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ -- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ -- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ -- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html - -[Original article](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/en/getting_started/index.md b/docs/en/getting_started/index.md deleted file mode 100644 index 61eab2f512b..00000000000 --- a/docs/en/getting_started/index.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -toc_folder_title: Getting Started -toc_hidden: true -toc_priority: 8 -toc_title: hidden ---- - -# Getting Started {#getting-started} - -If you are new to ClickHouse and want to get a hands-on feeling of its performance, first of all, you need to go through the [installation process](install.md). After that you can: - -- [Go through detailed tutorial](tutorial.md) -- [Experiment with example datasets](example_datasets/ontime.md) - -[Original article](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/en/getting_started/install.md b/docs/en/getting_started/install.md deleted file mode 100644 index cfef6a62e2e..00000000000 --- a/docs/en/getting_started/install.md +++ /dev/null @@ -1,180 +0,0 @@ ---- -toc_priority: 11 -toc_title: Installation ---- - -# Installation {#installation} - -## System Requirements {#system-requirements} - -ClickHouse can run on any Linux, FreeBSD, or Mac OS X with x86\_64, AArch64, or PowerPC64LE CPU architecture. - -Official pre-built binaries are typically compiled for x86\_64 and leverage SSE 4.2 instruction set, so unless otherwise stated usage of CPU that supports it becomes an additional system requirement. Here’s the command to check if current CPU has support for SSE 4.2: - -``` bash -$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" -``` - -To run ClickHouse on processors that do not support SSE 4.2 or have AArch64 or PowerPC64LE architecture, you should [build ClickHouse from sources](#from-sources) with proper configuration adjustments. - -## Available Installation Options {#available-installation-options} - -### From DEB Packages {#install-from-deb-packages} - -It is recommended to use official pre-compiled `deb` packages for Debian or Ubuntu. Run these commands to install packages: - -``` bash -{% include 'install/deb.sh' %} -``` - -If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments). - -You can also download and install packages manually from [here](https://repo.clickhouse.tech/deb/stable/main/). - -#### Packages {#packages} - -- `clickhouse-common-static` — Installs ClickHouse compiled binary files. -- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` and installs the default server configuration. -- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` and other client-related tools. and installs client configuration files. -- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. - -### From RPM Packages {#from-rpm-packages} - -It is recommended to use official pre-compiled `rpm` packages for CentOS, RedHat, and all other rpm-based Linux distributions. - -First, you need to add the official repository: - -``` bash -sudo yum install yum-utils -sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG -sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 -``` - -If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments). The `prestable` tag is sometimes available too. - -Then run these commands to install packages: - -``` bash -sudo yum install clickhouse-server clickhouse-client -``` - -You can also download and install packages manually from [here](https://repo.clickhouse.tech/rpm/stable/x86_64). - -### From Tgz Archives {#from-tgz-archives} - -It is recommended to use official pre-compiled `tgz` archives for all Linux distributions, where installation of `deb` or `rpm` packages is not possible. - -The required version can be downloaded with `curl` or `wget` from repository https://repo.yandex.ru/clickhouse/tgz/. -After that downloaded archives should be unpacked and installed with installation scripts. Example for the latest version: - -``` bash -export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz - -tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz -sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz -sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-server-$LATEST_VERSION.tgz -sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh -sudo /etc/init.d/clickhouse-server start - -tar -xzvf clickhouse-client-$LATEST_VERSION.tgz -sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh -``` - -For production environments, it’s recommended to use the latest `stable`-version. You can find its number on GitHub page https://github.com/ClickHouse/ClickHouse/tags with postfix `-stable`. - -### From Docker Image {#from-docker-image} - -To run ClickHouse inside Docker follow the guide on [Docker Hub](https://hub.docker.com/r/yandex/clickhouse-server/). Those images use official `deb` packages inside. - -### From Sources {#from-sources} - -To manually compile ClickHouse, follow the instructions for [Linux](../development/build.md) or [Mac OS X](../development/build_osx.md). - -You can compile packages and install them or use programs without installing packages. Also by building manually you can disable SSE 4.2 requirement or build for AArch64 CPUs. - - Client: programs/clickhouse-client - Server: programs/clickhouse-server - -You’ll need to create a data and metadata folders and `chown` them for the desired user. Their paths can be changed in server config (src/programs/server/config.xml), by default they are: - - /opt/clickhouse/data/default/ - /opt/clickhouse/metadata/default/ - -On Gentoo, you can just use `emerge clickhouse` to install ClickHouse from sources. - -## Launch {#launch} - -To start the server as a daemon, run: - -``` bash -$ sudo service clickhouse-server start -``` - -If you don’t have `service` command, run as - -``` bash -$ sudo /etc/init.d/clickhouse-server start -``` - -See the logs in the `/var/log/clickhouse-server/` directory. - -If the server doesn’t start, check the configurations in the file `/etc/clickhouse-server/config.xml`. - -You can also manually launch the server from the console: - -``` bash -$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml -``` - -In this case, the log will be printed to the console, which is convenient during development. -If the configuration file is in the current directory, you don’t need to specify the `--config-file` parameter. By default, it uses `./config.xml`. - -ClickHouse supports access restriction settings. They are located in the `users.xml` file (next to `config.xml`). -By default, access is allowed from anywhere for the `default` user, without a password. See `user/default/networks`. -For more information, see the section [“Configuration Files”](../operations/configuration_files.md). - -After launching server, you can use the command-line client to connect to it: - -``` bash -$ clickhouse-client -``` - -By default, it connects to `localhost:9000` on behalf of the user `default` without a password. It can also be used to connect to a remote server using `--host` argument. - -The terminal must use UTF-8 encoding. -For more information, see the section [“Command-line client”](../interfaces/cli.md). - -Example: - -``` bash -$ ./clickhouse-client -ClickHouse client version 0.0.18749. -Connecting to localhost:9000. -Connected to ClickHouse server version 0.0.18749. - -:) SELECT 1 - -SELECT 1 - -┌─1─┐ -│ 1 │ -└───┘ - -1 rows in set. Elapsed: 0.003 sec. - -:) -``` - -**Congratulations, the system works!** - -To continue experimenting, you can download one of the test data sets or go through [tutorial](https://clickhouse.tech/tutorial.html). - -[Original article](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/en/getting_started/playground.md b/docs/en/getting_started/playground.md deleted file mode 100644 index 353724b6e3e..00000000000 --- a/docs/en/getting_started/playground.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -toc_priority: 14 -toc_title: Playground ---- - -# ClickHouse Playground {#clickhouse-playground} - -[ClickHouse Playground](https://play.clickhouse.tech?file=welcome) allows people to experiment with ClickHouse by running queries instantly, without setting up their server or cluster. -Several example datasets are available in the Playground as well as sample queries that show ClickHouse features. - -The queries are executed as a read-only user. It implies some limitations: - -- DDL queries are not allowed -- INSERT queries are not allowed - -The following settings are also enforced: -- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) -- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) -- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) -- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) - -ClickHouse Playground gives the experience of m2.small -[Managed Service for ClickHouse](https://cloud.yandex.com/services/managed-clickhouse) -instance hosted in [Yandex.Cloud](https://cloud.yandex.com/). -More information about [cloud providers](../commercial/cloud.md). - -ClickHouse Playground web interface makes requests via ClickHouse [HTTP API](../interfaces/http.md). -The Playground backend is just a ClickHouse cluster without any additional server-side application. -ClickHouse HTTPS endpoint is also available as a part of the Playground. - -You can make queries to playground using any HTTP client, for example [curl](https://curl.haxx.se) or [wget](https://www.gnu.org/software/wget/), or set up a connection using [JDBC](../interfaces/jdbc.md) or [ODBC](../interfaces/odbc.md) drivers. -More information about software products that support ClickHouse is available [here](../interfaces/index.md). - -| Parameter | Value | -|:----------|:--------------------------------------| -| Endpoint | https://play-api.clickhouse.tech:8443 | -| User | `playground` | -| Password | `clickhouse` | - -Note that this endpoint requires a secure connection. - -Example: - -``` bash -curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" -``` diff --git a/docs/en/getting_started/tutorial.md b/docs/en/getting_started/tutorial.md deleted file mode 100644 index 74b90aac2fa..00000000000 --- a/docs/en/getting_started/tutorial.md +++ /dev/null @@ -1,663 +0,0 @@ ---- -toc_priority: 12 -toc_title: Tutorial ---- - -# ClickHouse Tutorial {#clickhouse-tutorial} - -## What to Expect from This Tutorial? {#what-to-expect-from-this-tutorial} - -By going through this tutorial, you’ll learn how to set up a simple ClickHouse cluster. It’ll be small, but fault-tolerant and scalable. Then we will use one of the example datasets to fill it with data and execute some demo queries. - -## Single Node Setup {#single-node-setup} - -To postpone the complexities of a distributed environment, we’ll start with deploying ClickHouse on a single server or virtual machine. ClickHouse is usually installed from [deb](install.md#install-from-deb-packages) or [rpm](install.md#from-rpm-packages) packages, but there are [alternatives](install.md#from-docker-image) for the operating systems that do no support them. - -For example, you have chosen `deb` packages and executed: - -``` bash -{% include 'install/deb.sh' %} -``` - -What do we have in the packages that got installed: - -- `clickhouse-client` package contains [clickhouse-client](../interfaces/cli.md) application, interactive ClickHouse console client. -- `clickhouse-common` package contains a ClickHouse executable file. -- `clickhouse-server` package contains configuration files to run ClickHouse as a server. - -Server config files are located in `/etc/clickhouse-server/`. Before going further, please notice the `` element in `config.xml`. Path determines the location for data storage, so it should be located on volume with large disk capacity; the default value is `/var/lib/clickhouse/`. If you want to adjust the configuration, it’s not handy to directly edit `config.xml` file, considering it might get rewritten on future package updates. The recommended way to override the config elements is to create [files in config.d directory](../operations/configuration_files.md) which serve as “patches” to config.xml. - -As you might have noticed, `clickhouse-server` is not launched automatically after package installation. It won’t be automatically restarted after updates, either. The way you start the server depends on your init system, usually, it is: - -``` bash -sudo service clickhouse-server start -``` - -or - -``` bash -sudo /etc/init.d/clickhouse-server start -``` - -The default location for server logs is `/var/log/clickhouse-server/`. The server is ready to handle client connections once it logs the `Ready for connections` message. - -Once the `clickhouse-server` is up and running, we can use `clickhouse-client` to connect to the server and run some test queries like `SELECT "Hello, world!";`. - -
- -Quick tips for clickhouse-client -Interactive mode: - -``` bash -clickhouse-client -clickhouse-client --host=... --port=... --user=... --password=... -``` - -Enable multiline queries: - -``` bash -clickhouse-client -m -clickhouse-client --multiline -``` - -Run queries in batch-mode: - -``` bash -clickhouse-client --query='SELECT 1' -echo 'SELECT 1' | clickhouse-client -clickhouse-client <<< 'SELECT 1' -``` - -Insert data from a file in specified format: - -``` bash -clickhouse-client --query='INSERT INTO table VALUES' < data.txt -clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv -``` - -
- -## Import Sample Dataset {#import-sample-dataset} - -Now it’s time to fill our ClickHouse server with some sample data. In this tutorial, we’ll use the anonymized data of Yandex.Metrica, the first service that runs ClickHouse in production way before it became open-source (more on that in [history section](../introduction/history.md)). There are [multiple ways to import Yandex.Metrica dataset](example_datasets/metrica.md), and for the sake of the tutorial, we’ll go with the most realistic one. - -### Download and Extract Table Data {#download-and-extract-table-data} - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -``` - -The extracted files are about 10GB in size. - -### Create Tables {#create-tables} - -As in most databases management systems, ClickHouse logically groups tables into “databases”. There’s a `default` database, but we’ll create a new one named `tutorial`: - -``` bash -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" -``` - -Syntax for creating tables is way more complicated compared to databases (see [reference](../sql_reference/statements/create.md). In general `CREATE TABLE` statement has to specify three key things: - -1. Name of table to create. -2. Table schema, i.e. list of columns and their [data types](../sql_reference/data_types/index.md). -3. [Table engine](../engines/table_engines/index.md) and its settings, which determines all the details on how queries to this table will be physically executed. - -Yandex.Metrica is a web analytics service, and sample dataset doesn’t cover its full functionality, so there are only two tables to create: - -- `hits` is a table with each action done by all users on all websites covered by the service. -- `visits` is a table that contains pre-built sessions instead of individual actions. - -Let’s see and execute the real create table queries for these tables: - -``` sql -CREATE TABLE tutorial.hits_v1 -( - `WatchID` UInt64, - `JavaEnable` UInt8, - `Title` String, - `GoodEvent` Int16, - `EventTime` DateTime, - `EventDate` Date, - `CounterID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RegionID` UInt32, - `UserID` UInt64, - `CounterClass` Int8, - `OS` UInt8, - `UserAgent` UInt8, - `URL` String, - `Referer` String, - `URLDomain` String, - `RefererDomain` String, - `Refresh` UInt8, - `IsRobot` UInt8, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `FlashMinor2` String, - `NetMajor` UInt8, - `NetMinor` UInt8, - `UserAgentMajor` UInt16, - `UserAgentMinor` FixedString(2), - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `MobilePhone` UInt8, - `MobilePhoneModel` String, - `Params` String, - `IPNetworkID` UInt32, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `IsArtifical` UInt8, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `ClientTimeZone` Int16, - `ClientEventTime` DateTime, - `SilverlightVersion1` UInt8, - `SilverlightVersion2` UInt8, - `SilverlightVersion3` UInt32, - `SilverlightVersion4` UInt16, - `PageCharset` String, - `CodeVersion` UInt32, - `IsLink` UInt8, - `IsDownload` UInt8, - `IsNotBounce` UInt8, - `FUniqID` UInt64, - `HID` UInt32, - `IsOldCounter` UInt8, - `IsEvent` UInt8, - `IsParameter` UInt8, - `DontCountHits` UInt8, - `WithHash` UInt8, - `HitColor` FixedString(1), - `UTCEventTime` DateTime, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `WindowName` Int32, - `OpenerName` Int32, - `HistoryLength` Int16, - `BrowserLanguage` FixedString(2), - `BrowserCountry` FixedString(2), - `SocialNetwork` String, - `SocialAction` String, - `HTTPError` UInt16, - `SendTiming` Int32, - `DNSTiming` Int32, - `ConnectTiming` Int32, - `ResponseStartTiming` Int32, - `ResponseEndTiming` Int32, - `FetchTiming` Int32, - `RedirectTiming` Int32, - `DOMInteractiveTiming` Int32, - `DOMContentLoadedTiming` Int32, - `DOMCompleteTiming` Int32, - `LoadEventStartTiming` Int32, - `LoadEventEndTiming` Int32, - `NSToDOMContentLoadedTiming` Int32, - `FirstPaintTiming` Int32, - `RedirectCount` Int8, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `ParamPrice` Int64, - `ParamOrderID` String, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `GoalsReached` Array(UInt32), - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `RefererHash` UInt64, - `URLHash` UInt64, - `CLID` UInt32, - `YCLID` UInt64, - `ShareService` String, - `ShareURL` String, - `ShareTitle` String, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `IslandID` FixedString(16), - `RequestNum` UInt32, - `RequestTry` UInt8 -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -``` sql -CREATE TABLE tutorial.visits_v1 -( - `CounterID` UInt32, - `StartDate` Date, - `Sign` Int8, - `IsNew` UInt8, - `VisitID` UInt64, - `UserID` UInt64, - `StartTime` DateTime, - `Duration` UInt32, - `UTCStartTime` DateTime, - `PageViews` Int32, - `Hits` Int32, - `IsBounce` UInt8, - `Referer` String, - `StartURL` String, - `RefererDomain` String, - `StartURLDomain` String, - `EndURL` String, - `LinkURL` String, - `IsDownload` UInt8, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `PlaceID` Int32, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `IsYandex` UInt8, - `GoalReachesDepth` Int32, - `GoalReachesURL` Int32, - `GoalReachesAny` Int32, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `MobilePhoneModel` String, - `ClientEventTime` DateTime, - `RegionID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `IPNetworkID` UInt32, - `SilverlightVersion3` UInt32, - `CodeVersion` UInt32, - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `UserAgentMajor` UInt16, - `UserAgentMinor` UInt16, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `SilverlightVersion2` UInt8, - `SilverlightVersion4` UInt16, - `FlashVersion3` UInt16, - `FlashVersion4` UInt16, - `ClientTimeZone` Int16, - `OS` UInt8, - `UserAgent` UInt8, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `NetMajor` UInt8, - `NetMinor` UInt8, - `MobilePhone` UInt8, - `SilverlightVersion1` UInt8, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `JavaEnable` UInt8, - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `BrowserLanguage` UInt16, - `BrowserCountry` UInt16, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `Params` Array(String), - `Goals` Nested( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32), - `WatchIDs` Array(UInt64), - `ParamSumPrice` Int64, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `ClickLogID` UInt64, - `ClickEventID` Int32, - `ClickGoodEvent` Int32, - `ClickEventTime` DateTime, - `ClickPriorityID` Int32, - `ClickPhraseID` Int32, - `ClickPageID` Int32, - `ClickPlaceID` Int32, - `ClickTypeID` Int32, - `ClickResourceID` Int32, - `ClickCost` UInt32, - `ClickClientIP` UInt32, - `ClickDomainID` UInt32, - `ClickURL` String, - `ClickAttempt` UInt8, - `ClickOrderID` UInt32, - `ClickBannerID` UInt32, - `ClickMarketCategoryID` UInt32, - `ClickMarketPP` UInt32, - `ClickMarketCategoryName` String, - `ClickMarketPPName` String, - `ClickAWAPSCampaignName` String, - `ClickPageName` String, - `ClickTargetType` UInt16, - `ClickTargetPhraseID` UInt64, - `ClickContextType` UInt8, - `ClickSelectType` Int8, - `ClickOptions` String, - `ClickGroupBannerID` Int32, - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `FirstVisit` DateTime, - `PredLastVisit` Date, - `LastVisit` Date, - `TotalVisits` UInt32, - `TraficSource` Nested( - ID Int8, - SearchEngineID UInt16, - AdvEngineID UInt8, - PlaceID UInt16, - SocialSourceNetworkID UInt8, - Domain String, - SearchPhrase String, - SocialSourcePage String), - `Attendance` FixedString(16), - `CLID` UInt32, - `YCLID` UInt64, - `NormalizedRefererHash` UInt64, - `SearchPhraseHash` UInt64, - `RefererDomainHash` UInt64, - `NormalizedStartURLHash` UInt64, - `StartURLDomainHash` UInt64, - `NormalizedEndURLHash` UInt64, - `TopLevelDomain` UInt64, - `URLScheme` UInt64, - `OpenstatServiceNameHash` UInt64, - `OpenstatCampaignIDHash` UInt64, - `OpenstatAdIDHash` UInt64, - `OpenstatSourceIDHash` UInt64, - `UTMSourceHash` UInt64, - `UTMMediumHash` UInt64, - `UTMCampaignHash` UInt64, - `UTMContentHash` UInt64, - `UTMTermHash` UInt64, - `FromHash` UInt64, - `WebVisorEnabled` UInt8, - `WebVisorActivity` UInt32, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `Market` Nested( - Type UInt8, - GoalID UInt32, - OrderID String, - OrderPrice Int64, - PP UInt32, - DirectPlaceID UInt32, - DirectOrderID UInt32, - DirectBannerID UInt32, - GoodID String, - GoodName String, - GoodQuantity Int32, - GoodPrice Int64), - `IslandID` FixedString(16) -) -ENGINE = CollapsingMergeTree(Sign) -PARTITION BY toYYYYMM(StartDate) -ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -You can execute those queries using the interactive mode of `clickhouse-client` (just launch it in a terminal without specifying a query in advance) or try some [alternative interface](../interfaces/index.md) if you want. - -As we can see, `hits_v1` uses the [basic MergeTree engine](../engines/table_engines/mergetree_family/mergetree.md), while the `visits_v1` uses the [Collapsing](../engines/table_engines/mergetree_family/collapsingmergetree.md) variant. - -### Import Data {#import-data} - -Data import to ClickHouse is done via [INSERT INTO](../sql_reference/statements/insert_into.md) query like in many other SQL databases. However, data is usually provided in one of the [supported serialization formats](../interfaces/formats.md) instead of `VALUES` clause (which is also supported). - -The files we downloaded earlier are in tab-separated format, so here’s how to import them via console client: - -``` bash -clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv -clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv -``` - -ClickHouse has a lot of [settings to tune](../operations/settings/index.md) and one way to specify them in console client is via arguments, as we can see with `--max_insert_block_size`. The easiest way to figure out what settings are available, what do they mean and what the defaults are is to query the `system.settings` table: - -``` sql -SELECT name, value, changed, description -FROM system.settings -WHERE name LIKE '%max_insert_b%' -FORMAT TSV - -max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." -``` - -Optionally you can [OPTIMIZE](../sql_reference/statements/misc.md#misc_operations-optimize) the tables after import. Tables that are configured with an engine from MergeTree-family always do merges of data parts in the background to optimize data storage (or at least check if it makes sense). These queries force the table engine to do storage optimization right now instead of some time later: - -``` bash -clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" -clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" -``` - -These queries start an I/O and CPU intensive operation, so if the table consistently receives new data, it’s better to leave it alone and let merges run in the background. - -Now we can check if the table import was successful: - -``` bash -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" -``` - -## Example Queries {#example-queries} - -``` sql -SELECT - StartURL AS URL, - AVG(Duration) AS AvgDuration -FROM tutorial.visits_v1 -WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' -GROUP BY URL -ORDER BY AvgDuration DESC -LIMIT 10 -``` - -``` sql -SELECT - sum(Sign) AS visits, - sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, - (100. * goal_visits) / visits AS goal_percent -FROM tutorial.visits_v1 -WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') -``` - -## Cluster Deployment {#cluster-deployment} - -ClickHouse cluster is a homogenous cluster. Steps to set up: - -1. Install ClickHouse server on all machines of the cluster -2. Set up cluster configs in configuration files -3. Create local tables on each instance -4. Create a [Distributed table](../engines/table_engines/special/distributed.md) - -[Distributed table](../engines/table_engines/special/distributed.md) is actually a kind of “view” to local tables of ClickHouse cluster. SELECT query from a distributed table executes using resources of all cluster’s shards. You may specify configs for multiple clusters and create multiple distributed tables providing views to different clusters. - -Example config for a cluster with three shards, one replica each: - -``` xml - - - - - example-perftest01j.yandex.ru - 9000 - - - - - example-perftest02j.yandex.ru - 9000 - - - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -For further demonstration, let’s create a new local table with the same `CREATE TABLE` query that we used for `hits_v1`, but different table name: - -``` sql -CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... -``` - -Creating a distributed table providing a view into local tables of the cluster: - -``` sql -CREATE TABLE tutorial.hits_all AS tutorial.hits_local -ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); -``` - -A common practice is to create similar Distributed tables on all machines of the cluster. It allows running distributed queries on any machine of the cluster. Also there’s an alternative option to create temporary distributed table for a given SELECT query using [remote](../sql_reference/table_functions/remote.md) table function. - -Let’s run [INSERT SELECT](../sql_reference/statements/insert_into.md) into the Distributed table to spread the table to multiple servers. - -``` sql -INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; -``` - -!!! warning "Notice" - This approach is not suitable for the sharding of large tables. There’s a separate tool [clickhouse-copier](../operations/utilities/clickhouse-copier.md) that can re-shard arbitrary large tables. - -As you could expect, computationally heavy queries run N times faster if they utilize 3 servers instead of one. - -In this case, we have used a cluster with 3 shards, and each contains a single replica. - -To provide resilience in a production environment, we recommend that each shard should contain 2-3 replicas spread between multiple availability zones or datacenters (or at least racks). Note that ClickHouse supports an unlimited number of replicas. - -Example config for a cluster of one shard containing three replicas: - -``` xml - - ... - - - - example-perftest01j.yandex.ru - 9000 - - - example-perftest02j.yandex.ru - 9000 - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -To enable native replication [ZooKeeper](http://zookeeper.apache.org/) is required. ClickHouse takes care of data consistency on all replicas and runs restore procedure after failure automatically. It’s recommended to deploy the ZooKeeper cluster on separate servers (where no other processes including ClickHouse are running). - -!!! note "Note" - ZooKeeper is not a strict requirement: in some simple cases, you can duplicate the data by writing it into all the replicas from your application code. This approach is **not** recommended, in this case, ClickHouse won’t be able to guarantee data consistency on all replicas. Thus it becomes the responsibility of your application. - -ZooKeeper locations are specified in the configuration file: - -``` xml - - - zoo01.yandex.ru - 2181 - - - zoo02.yandex.ru - 2181 - - - zoo03.yandex.ru - 2181 - - -``` - -Also, we need to set macros for identifying each shard and replica which are used on table creation: - -``` xml - - 01 - 01 - -``` - -If there are no replicas at the moment on replicated table creation, a new first replica is instantiated. If there are already live replicas, the new replica clones data from existing ones. You have an option to create all replicated tables first, and then insert data to it. Another option is to create some replicas and add the others after or during data insertion. - -``` sql -CREATE TABLE tutorial.hits_replica (...) -ENGINE = ReplcatedMergeTree( - '/clickhouse_perftest/tables/{shard}/hits', - '{replica}' -) -... -``` - -Here we use [ReplicatedMergeTree](../engines/table_engines/mergetree_family/replication.md) table engine. In parameters we specify ZooKeeper path containing shard and replica identifiers. - -``` sql -INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; -``` - -Replication operates in multi-master mode. Data can be loaded into any replica, and the system then syncs it with other instances automatically. Replication is asynchronous so at a given moment, not all replicas may contain recently inserted data. At least one replica should be up to allow data ingestion. Others will sync up data and repair consistency once they will become active again. Note that this approach allows for the low possibility of a loss of recently inserted data. - -[Original article](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/en/guides/apply-catboost-model.md b/docs/en/guides/apply-catboost-model.md new file mode 100644 index 00000000000..835f4dda7fa --- /dev/null +++ b/docs/en/guides/apply-catboost-model.md @@ -0,0 +1,237 @@ +--- +toc_priority: 41 +toc_title: Applying CatBoost Models +--- + +# Applying a Catboost Model in ClickHouse {#applying-catboost-model-in-clickhouse} + +[CatBoost](https://catboost.ai) is a free and open-source gradient boosting library developed at [Yandex](https://yandex.com/company/) for machine learning. + +With this instruction, you will learn to apply pre-trained models in ClickHouse by running model inference from SQL. + +To apply a CatBoost model in ClickHouse: + +1. [Create a Table](#create-table). +2. [Insert the Data to the Table](#insert-data-to-table). +3. [Integrate CatBoost into ClickHouse](#integrate-catboost-into-clickhouse) (Optional step). +4. [Run the Model Inference from SQL](#run-model-inference). + +For more information about training CatBoost models, see [Training and applying models](https://catboost.ai/docs/features/training.html#training). + +## Prerequisites {#prerequisites} + +If you don’t have the [Docker](https://docs.docker.com/install/) yet, install it. + +!!! note "Note" + [Docker](https://www.docker.com) is a software platform that allows you to create containers that isolate a CatBoost and ClickHouse installation from the rest of the system. + +Before applying a CatBoost model: + +**1.** Pull the [Docker image](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) from the registry: + +``` bash +$ docker pull yandex/tutorial-catboost-clickhouse +``` + +This Docker image contains everything you need to run CatBoost and ClickHouse: code, runtime, libraries, environment variables, and configuration files. + +**2.** Make sure the Docker image has been successfully pulled: + +``` bash +$ docker image ls +REPOSITORY TAG IMAGE ID CREATED SIZE +yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB +``` + +**3.** Start a Docker container based on this image: + +``` bash +$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse +``` + +## 1. Create a Table {#create-table} + +To create a ClickHouse table for the training sample: + +**1.** Start ClickHouse console client in the interactive mode: + +``` bash +$ clickhouse client +``` + +!!! note "Note" + The ClickHouse server is already running inside the Docker container. + +**2.** Create the table using the command: + +``` sql +:) CREATE TABLE amazon_train +( + date Date MATERIALIZED today(), + ACTION UInt8, + RESOURCE UInt32, + MGR_ID UInt32, + ROLE_ROLLUP_1 UInt32, + ROLE_ROLLUP_2 UInt32, + ROLE_DEPTNAME UInt32, + ROLE_TITLE UInt32, + ROLE_FAMILY_DESC UInt32, + ROLE_FAMILY UInt32, + ROLE_CODE UInt32 +) +ENGINE = MergeTree ORDER BY date +``` + +**3.** Exit from ClickHouse console client: + +``` sql +:) exit +``` + +## 2. Insert the Data to the Table {#insert-data-to-table} + +To insert the data: + +**1.** Run the following command: + +``` bash +$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv +``` + +**2.** Start ClickHouse console client in the interactive mode: + +``` bash +$ clickhouse client +``` + +**3.** Make sure the data has been uploaded: + +``` sql +:) SELECT count() FROM amazon_train + +SELECT count() +FROM amazon_train + ++-count()-+ +| 65538 | ++-------+ +``` + +## 3. Integrate CatBoost into ClickHouse {#integrate-catboost-into-clickhouse} + +!!! note "Note" + **Optional step.** The Docker image contains everything you need to run CatBoost and ClickHouse. + +To integrate CatBoost into ClickHouse: + +**1.** Build the evaluation library. + +The fastest way to evaluate a CatBoost model is compile `libcatboostmodel.` library. For more information about how to build the library, see [CatBoost documentation](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). + +**2.** Create a new directory anywhere and with any name, for example, `data` and put the created library in it. The Docker image already contains the library `data/libcatboostmodel.so`. + +**3.** Create a new directory for config model anywhere and with any name, for example, `models`. + +**4.** Create a model configuration file with any name, for example, `models/amazon_model.xml`. + +**5.** Describe the model configuration: + +``` xml + + + + catboost + + amazon + + /home/catboost/tutorial/catboost_model.bin + + 0 + + +``` + +**6.** Add the path to CatBoost and the model configuration to the ClickHouse configuration: + +``` xml + +/home/catboost/data/libcatboostmodel.so +/home/catboost/models/*_model.xml +``` + +## 4. Run the Model Inference from SQL {#run-model-inference} + +For test model run the ClickHouse client `$ clickhouse client`. + +Let’s make sure that the model is working: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) > 0 AS prediction, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Note" + Function [modelEvaluate](../sql-reference/functions/other-functions.md#function-modelevaluate) returns tuple with per-class raw predictions for multiclass models. + +Let’s predict the probability: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1 + exp(-prediction)) AS probability, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Note" + More info about [exp()](../sql-reference/functions/math-functions.md) function. + +Let’s calculate LogLoss on the sample: + +``` sql +:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss +FROM +( + SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1. + exp(-prediction)) AS prob, + ACTION AS tg + FROM amazon_train +) +``` + +!!! note "Note" + More info about [avg()](../sql-reference/aggregate-functions/reference.md#agg_function-avg) and [log()](../sql-reference/functions/math-functions.md) functions. + +[Original article](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/en/guides/apply_catboost_model.md b/docs/en/guides/apply_catboost_model.md deleted file mode 100644 index 89942a00359..00000000000 --- a/docs/en/guides/apply_catboost_model.md +++ /dev/null @@ -1,237 +0,0 @@ ---- -toc_priority: 41 -toc_title: Applying CatBoost Models ---- - -# Applying a Catboost Model in ClickHouse {#applying-catboost-model-in-clickhouse} - -[CatBoost](https://catboost.ai) is a free and open-source gradient boosting library developed at [Yandex](https://yandex.com/company/) for machine learning. - -With this instruction, you will learn to apply pre-trained models in ClickHouse by running model inference from SQL. - -To apply a CatBoost model in ClickHouse: - -1. [Create a Table](#create-table). -2. [Insert the Data to the Table](#insert-data-to-table). -3. [Integrate CatBoost into ClickHouse](#integrate-catboost-into-clickhouse) (Optional step). -4. [Run the Model Inference from SQL](#run-model-inference). - -For more information about training CatBoost models, see [Training and applying models](https://catboost.ai/docs/features/training.html#training). - -## Prerequisites {#prerequisites} - -If you don’t have the [Docker](https://docs.docker.com/install/) yet, install it. - -!!! note "Note" - [Docker](https://www.docker.com) is a software platform that allows you to create containers that isolate a CatBoost and ClickHouse installation from the rest of the system. - -Before applying a CatBoost model: - -**1.** Pull the [Docker image](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) from the registry: - -``` bash -$ docker pull yandex/tutorial-catboost-clickhouse -``` - -This Docker image contains everything you need to run CatBoost and ClickHouse: code, runtime, libraries, environment variables, and configuration files. - -**2.** Make sure the Docker image has been successfully pulled: - -``` bash -$ docker image ls -REPOSITORY TAG IMAGE ID CREATED SIZE -yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB -``` - -**3.** Start a Docker container based on this image: - -``` bash -$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse -``` - -## 1. Create a Table {#create-table} - -To create a ClickHouse table for the training sample: - -**1.** Start ClickHouse console client in the interactive mode: - -``` bash -$ clickhouse client -``` - -!!! note "Note" - The ClickHouse server is already running inside the Docker container. - -**2.** Create the table using the command: - -``` sql -:) CREATE TABLE amazon_train -( - date Date MATERIALIZED today(), - ACTION UInt8, - RESOURCE UInt32, - MGR_ID UInt32, - ROLE_ROLLUP_1 UInt32, - ROLE_ROLLUP_2 UInt32, - ROLE_DEPTNAME UInt32, - ROLE_TITLE UInt32, - ROLE_FAMILY_DESC UInt32, - ROLE_FAMILY UInt32, - ROLE_CODE UInt32 -) -ENGINE = MergeTree ORDER BY date -``` - -**3.** Exit from ClickHouse console client: - -``` sql -:) exit -``` - -## 2. Insert the Data to the Table {#insert-data-to-table} - -To insert the data: - -**1.** Run the following command: - -``` bash -$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv -``` - -**2.** Start ClickHouse console client in the interactive mode: - -``` bash -$ clickhouse client -``` - -**3.** Make sure the data has been uploaded: - -``` sql -:) SELECT count() FROM amazon_train - -SELECT count() -FROM amazon_train - -+-count()-+ -| 65538 | -+-------+ -``` - -## 3. Integrate CatBoost into ClickHouse {#integrate-catboost-into-clickhouse} - -!!! note "Note" - **Optional step.** The Docker image contains everything you need to run CatBoost and ClickHouse. - -To integrate CatBoost into ClickHouse: - -**1.** Build the evaluation library. - -The fastest way to evaluate a CatBoost model is compile `libcatboostmodel.` library. For more information about how to build the library, see [CatBoost documentation](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). - -**2.** Create a new directory anywhere and with any name, for example, `data` and put the created library in it. The Docker image already contains the library `data/libcatboostmodel.so`. - -**3.** Create a new directory for config model anywhere and with any name, for example, `models`. - -**4.** Create a model configuration file with any name, for example, `models/amazon_model.xml`. - -**5.** Describe the model configuration: - -``` xml - - - - catboost - - amazon - - /home/catboost/tutorial/catboost_model.bin - - 0 - - -``` - -**6.** Add the path to CatBoost and the model configuration to the ClickHouse configuration: - -``` xml - -/home/catboost/data/libcatboostmodel.so -/home/catboost/models/*_model.xml -``` - -## 4. Run the Model Inference from SQL {#run-model-inference} - -For test model run the ClickHouse client `$ clickhouse client`. - -Let’s make sure that the model is working: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) > 0 AS prediction, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Note" - Function [modelEvaluate](../sql_reference/functions/other_functions.md#function-modelevaluate) returns tuple with per-class raw predictions for multiclass models. - -Let’s predict the probability: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1 + exp(-prediction)) AS probability, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Note" - More info about [exp()](../sql_reference/functions/math_functions.md) function. - -Let’s calculate LogLoss on the sample: - -``` sql -:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss -FROM -( - SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1. + exp(-prediction)) AS prob, - ACTION AS tg - FROM amazon_train -) -``` - -!!! note "Note" - More info about [avg()](../sql_reference/aggregate_functions/reference.md#agg_function-avg) and [log()](../sql_reference/functions/math_functions.md) functions. - -[Original article](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/en/guides/index.md b/docs/en/guides/index.md index e18c5fac223..ea20a606cac 100644 --- a/docs/en/guides/index.md +++ b/docs/en/guides/index.md @@ -8,7 +8,7 @@ toc_title: Overview List of detailed step-by-step instructions that help to solve various tasks using ClickHouse: -- [Tutorial on simple cluster set-up](../getting_started/tutorial.md) -- [Applying a CatBoost model in ClickHouse](apply_catboost_model.md) +- [Tutorial on simple cluster set-up](../getting-started/tutorial.md) +- [Applying a CatBoost model in ClickHouse](apply-catboost-model.md) [Original article](https://clickhouse.tech/docs/en/guides/) diff --git a/docs/en/images/column-oriented.gif b/docs/en/images/column-oriented.gif new file mode 100644 index 00000000000..d5ac7c82848 Binary files /dev/null and b/docs/en/images/column-oriented.gif differ diff --git a/docs/en/images/column_oriented.gif b/docs/en/images/column_oriented.gif deleted file mode 100644 index 15f4b12e697..00000000000 Binary files a/docs/en/images/column_oriented.gif and /dev/null differ diff --git a/docs/en/images/logo.svg b/docs/en/images/logo.svg index 865b96d98c7..b5ab923ff65 100644 --- a/docs/en/images/logo.svg +++ b/docs/en/images/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/docs/en/images/row-oriented.gif b/docs/en/images/row-oriented.gif new file mode 100644 index 00000000000..41395b5693e Binary files /dev/null and b/docs/en/images/row-oriented.gif differ diff --git a/docs/en/images/row_oriented.gif b/docs/en/images/row_oriented.gif deleted file mode 100644 index 53daa20f322..00000000000 Binary files a/docs/en/images/row_oriented.gif and /dev/null differ diff --git a/docs/en/index.md b/docs/en/index.md index 67c4ca4d53b..fb7e1eb67d9 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -3,14 +3,14 @@ toc_priority: 0 toc_title: Overview --- -# What is ClickHouse? {#what-is-clickhouse} +# What Is ClickHouse? {#what-is-clickhouse} ClickHouse is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP). In a “normal” row-oriented DBMS, data is stored in this order: | Row | WatchID | JavaEnable | Title | GoodEvent | EventTime | -|---|---------|--------|------------|-------|-------------| +|-----|-------------|------------|--------------------|-----------|---------------------| | \#0 | 89354350662 | 1 | Investor Relations | 1 | 2016-05-18 05:19:20 | | \#1 | 90329509958 | 0 | Contact us | 1 | 2016-05-18 08:10:20 | | \#2 | 89953706054 | 1 | Mission | 1 | 2016-05-18 07:38:00 | @@ -23,7 +23,7 @@ Examples of a row-oriented DBMS are MySQL, Postgres, and MS SQL Server. In a column-oriented DBMS, data is stored like this: | Row: | \#0 | \#1 | \#2 | \#N | -|---------|-------------|-------------|-------------|---| +|-------------|---------------------|---------------------|---------------------|-----| | WatchID: | 89354350662 | 90329509958 | 89953706054 | … | | JavaEnable: | 1 | 0 | 1 | … | | Title: | Investor Relations | Contact us | Mission | … | @@ -62,11 +62,11 @@ Column-oriented databases are better suited to OLAP scenarios: they are at least **Row-oriented DBMS** -![Row-oriented](images/row_oriented.gif#) +![Row-oriented](images/row-oriented.gif#) **Column-oriented DBMS** -![Column-oriented](images/column_oriented.gif#) +![Column-oriented](images/column-oriented.gif#) See the difference? diff --git a/docs/en/interfaces/cli.md b/docs/en/interfaces/cli.md index 5bad73008a6..07ed3e5c884 100644 --- a/docs/en/interfaces/cli.md +++ b/docs/en/interfaces/cli.md @@ -7,7 +7,7 @@ toc_title: Command-Line Client ClickHouse provides a native command-line client: `clickhouse-client`. The client supports command-line options and configuration files. For more information, see [Configuring](#interfaces_cli_configuration). -[Install](../getting_started/index.md) it from the `clickhouse-client` package and run it with the command `clickhouse-client`. +[Install](../getting-started/index.md) it from the `clickhouse-client` package and run it with the command `clickhouse-client`. ``` bash $ clickhouse-client @@ -87,7 +87,7 @@ Format a query as usual, then place the values that you want to pass from the ap ``` - `name` — Placeholder identifier. In the console client it should be used in app parameters as `--param_ = value`. -- `data type` — [Data type](../sql_reference/data_types/index.md) of the app parameter value. For example, a data structure like `(integer, ('string', integer))` can have the `Tuple(UInt8, Tuple(String, UInt8))` data type (you can also use another [integer](../sql_reference/data_types/int_uint.md) types). +- `data type` — [Data type](../sql-reference/data-types/index.md) of the app parameter value. For example, a data structure like `(integer, ('string', integer))` can have the `Tuple(UInt8, Tuple(String, UInt8))` data type (you can also use another [integer](../sql-reference/data-types/int-uint.md) types). #### Example {#example} diff --git a/docs/en/interfaces/formats.md b/docs/en/interfaces/formats.md index 51985ba89e1..a08f2db7149 100644 --- a/docs/en/interfaces/formats.md +++ b/docs/en/interfaces/formats.md @@ -37,6 +37,8 @@ The supported formats are: | [Avro](#data-format-avro) | ✔ | ✔ | | [AvroConfluent](#data-format-avro-confluent) | ✔ | ✗ | | [Parquet](#data-format-parquet) | ✔ | ✔ | +| [Arrow](#data-format-arrow) | ✔ | ✔ | +| [ArrowStream](#data-format-arrow-stream) | ✔ | ✔ | | [ORC](#data-format-orc) | ✔ | ✗ | | [RowBinary](#rowbinary) | ✔ | ✔ | | [RowBinaryWithNamesAndTypes](#rowbinarywithnamesandtypes) | ✔ | ✔ | @@ -108,9 +110,9 @@ Only a small set of symbols are escaped. You can easily stumble onto a string va Arrays are written as a list of comma-separated values in square brackets. Number items in the array are formatted as normally. `Date` and `DateTime` types are written in single quotes. Strings are written in single quotes with the same escaping rules as above. -[NULL](../sql_reference/syntax.md) is formatted as `\N`. +[NULL](../sql-reference/syntax.md) is formatted as `\N`. -Each element of [Nested](../sql_reference/data_types/nested_data_structures/nested.md) structures is represented as array. +Each element of [Nested](../sql-reference/data-types/nested-data-structures/nested.md) structures is represented as array. For example: @@ -330,7 +332,7 @@ SearchPhrase=curtain designs count()=1064 SearchPhrase=baku count()=1000 ``` -[NULL](../sql_reference/syntax.md) is formatted as `\N`. +[NULL](../sql-reference/syntax.md) is formatted as `\N`. ``` sql SELECT * FROM t_null FORMAT TSKV @@ -462,7 +464,7 @@ If the query contains GROUP BY, rows\_before\_limit\_at\_least is the exact numb This format is only appropriate for outputting a query result, but not for parsing (retrieving data to insert in a table). -ClickHouse supports [NULL](../sql_reference/syntax.md), which is displayed as `null` in the JSON output. +ClickHouse supports [NULL](../sql-reference/syntax.md), which is displayed as `null` in the JSON output. See also the [JSONEachRow](#jsoneachrow) format. @@ -539,7 +541,7 @@ ClickHouse ignores spaces between elements and commas after the objects. You can **Omitted values processing** -ClickHouse substitutes omitted values with the default values for the corresponding [data types](../sql_reference/data_types/index.md). +ClickHouse substitutes omitted values with the default values for the corresponding [data types](../sql-reference/data-types/index.md). If `DEFAULT expr` is specified, ClickHouse uses different substitution rules depending on the [input\_format\_defaults\_for\_omitted\_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields) setting. @@ -584,7 +586,7 @@ Unlike the [JSON](#json) format, there is no substitution of invalid UTF-8 seque ### Usage of Nested Structures {#jsoneachrow-nested} -If you have a table with [Nested](../sql_reference/data_types/nested_data_structures/nested.md) data type columns, you can insert JSON data with the same structure. Enable this feature with the [input\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) setting. +If you have a table with [Nested](../sql-reference/data-types/nested-data-structures/nested.md) data type columns, you can insert JSON data with the same structure. Enable this feature with the [input\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) setting. For example, consider the following table: @@ -658,7 +660,7 @@ Outputs data as Unicode-art tables, also using ANSI-escape sequences for setting A full grid of the table is drawn, and each row occupies two lines in the terminal. Each result block is output as a separate table. This is necessary so that blocks can be output without buffering results (buffering would be necessary in order to pre-calculate the visible width of all the values). -[NULL](../sql_reference/syntax.md) is output as `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) is output as `ᴺᵁᴸᴸ`. Example (shown for the [PrettyCompact](#prettycompact) format): @@ -762,7 +764,7 @@ FixedString is represented simply as a sequence of bytes. Array is represented as a varint length (unsigned [LEB128](https://en.wikipedia.org/wiki/LEB128)), followed by successive elements of the array. -For [NULL](../sql_reference/syntax.md#null-literal) support, an additional byte containing 1 or 0 is added before each [Nullable](../sql_reference/data_types/nullable.md) value. If 1, then the value is `NULL` and this byte is interpreted as a separate value. If 0, the value after the byte is not `NULL`. +For [NULL](../sql-reference/syntax.md#null-literal) support, an additional byte containing 1 or 0 is added before each [Nullable](../sql-reference/data-types/nullable.md) value. If 1, then the value is `NULL` and this byte is interpreted as a separate value. If 0, the value after the byte is not `NULL`. ## RowBinaryWithNamesAndTypes {#rowbinarywithnamesandtypes} @@ -774,7 +776,7 @@ Similar to [RowBinary](#rowbinary), but with added header: ## Values {#data-format-values} -Prints every row in brackets. Rows are separated by commas. There is no comma after the last row. The values inside the brackets are also comma-separated. Numbers are output in a decimal format without quotes. Arrays are output in square brackets. Strings, dates, and dates with times are output in quotes. Escaping rules and parsing are similar to the [TabSeparated](#tabseparated) format. During formatting, extra spaces aren’t inserted, but during parsing, they are allowed and skipped (except for spaces inside array values, which are not allowed). [NULL](../sql_reference/syntax.md) is represented as `NULL`. +Prints every row in brackets. Rows are separated by commas. There is no comma after the last row. The values inside the brackets are also comma-separated. Numbers are output in a decimal format without quotes. Arrays are output in square brackets. Strings, dates, and dates with times are output in quotes. Escaping rules and parsing are similar to the [TabSeparated](#tabseparated) format. During formatting, extra spaces aren’t inserted, but during parsing, they are allowed and skipped (except for spaces inside array values, which are not allowed). [NULL](../sql-reference/syntax.md) is represented as `NULL`. The minimum set of characters that you need to escape when passing data in Values ​​format: single quotes and backslashes. @@ -786,7 +788,7 @@ See also: [input\_format\_values\_interpret\_expressions](../operations/settings Prints each value on a separate line with the column name specified. This format is convenient for printing just one or a few rows if each row consists of a large number of columns. -[NULL](../sql_reference/syntax.md) is output as `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) is output as `ᴺᵁᴸᴸ`. Example: @@ -965,7 +967,7 @@ message MessageType { ``` ClickHouse tries to find a column named `x.y.z` (or `x_y_z` or `X.y_Z` and so on). -Nested messages are suitable to input or output a [nested data structures](../sql_reference/data_types/nested_data_structures/nested.md). +Nested messages are suitable to input or output a [nested data structures](../sql-reference/data-types/nested-data-structures/nested.md). Default values defined in a protobuf schema like this @@ -977,7 +979,7 @@ message MessageType { } ``` -are not applied; the [table defaults](../sql_reference/statements/create.md#create-default-values) are used instead of them. +are not applied; the [table defaults](../sql-reference/statements/create.md#create-default-values) are used instead of them. ClickHouse inputs and outputs protobuf messages in the `length-delimited` format. It means before every message should be written its length as a [varint](https://developers.google.com/protocol-buffers/docs/encoding#varints). @@ -985,31 +987,31 @@ See also [how to read/write length-delimited protobuf messages in popular langua ## Avro {#data-format-avro} -[Apache Avro](http://avro.apache.org/) is a row-oriented data serialization framework developed within Apache’s Hadoop project. +[Apache Avro](https://avro.apache.org/) is a row-oriented data serialization framework developed within Apache’s Hadoop project. -ClickHouse Avro format supports reading and writing [Avro data files](http://avro.apache.org/docs/current/spec.html#Object+Container+Files). +ClickHouse Avro format supports reading and writing [Avro data files](https://avro.apache.org/docs/current/spec.html#Object+Container+Files). ### Data Types Matching {#data_types-matching} -The table below shows supported data types and how they match ClickHouse [data types](../sql_reference/data_types/index.md) in `INSERT` and `SELECT` queries. +The table below shows supported data types and how they match ClickHouse [data types](../sql-reference/data-types/index.md) in `INSERT` and `SELECT` queries. | Avro data type `INSERT` | ClickHouse data type | Avro data type `SELECT` | |---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|------------------------------| -| `boolean`, `int`, `long`, `float`, `double` | [Int(8\|16\|32)](../sql_reference/data_types/int_uint.md), [UInt(8\|16\|32)](../sql_reference/data_types/int_uint.md) | `int` | -| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql_reference/data_types/int_uint.md), [UInt64](../sql_reference/data_types/int_uint.md) | `long` | -| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql_reference/data_types/float.md) | `float` | -| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql_reference/data_types/float.md) | `double` | -| `bytes`, `string`, `fixed`, `enum` | [String](../sql_reference/data_types/string.md) | `bytes` | -| `bytes`, `string`, `fixed` | [FixedString(N)](../sql_reference/data_types/fixedstring.md) | `fixed(N)` | -| `enum` | [Enum(8\|16)](../sql_reference/data_types/enum.md) | `enum` | -| `array(T)` | [Array(T)](../sql_reference/data_types/array.md) | `array(T)` | -| `union(null, T)`, `union(T, null)` | [Nullable(T)](../sql_reference/data_types/date.md) | `union(null, T)` | -| `null` | [Nullable(Nothing)](../sql_reference/data_types/special_data_types/nothing.md) | `null` | -| `int (date)` \* | [Date](../sql_reference/data_types/date.md) | `int (date)` \* | -| `long (timestamp-millis)` \* | [DateTime64(3)](../sql_reference/data_types/datetime.md) | `long (timestamp-millis)` \* | -| `long (timestamp-micros)` \* | [DateTime64(6)](../sql_reference/data_types/datetime.md) | `long (timestamp-micros)` \* | +| `boolean`, `int`, `long`, `float`, `double` | [Int(8\|16\|32)](../sql-reference/data-types/int-uint.md), [UInt(8\|16\|32)](../sql-reference/data-types/int-uint.md) | `int` | +| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql-reference/data-types/int-uint.md), [UInt64](../sql-reference/data-types/int-uint.md) | `long` | +| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql-reference/data-types/float.md) | `float` | +| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql-reference/data-types/float.md) | `double` | +| `bytes`, `string`, `fixed`, `enum` | [String](../sql-reference/data-types/string.md) | `bytes` | +| `bytes`, `string`, `fixed` | [FixedString(N)](../sql-reference/data-types/fixedstring.md) | `fixed(N)` | +| `enum` | [Enum(8\|16)](../sql-reference/data-types/enum.md) | `enum` | +| `array(T)` | [Array(T)](../sql-reference/data-types/array.md) | `array(T)` | +| `union(null, T)`, `union(T, null)` | [Nullable(T)](../sql-reference/data-types/date.md) | `union(null, T)` | +| `null` | [Nullable(Nothing)](../sql-reference/data-types/special-data-types/nothing.md) | `null` | +| `int (date)` \* | [Date](../sql-reference/data-types/date.md) | `int (date)` \* | +| `long (timestamp-millis)` \* | [DateTime64(3)](../sql-reference/data-types/datetime.md) | `long (timestamp-millis)` \* | +| `long (timestamp-micros)` \* | [DateTime64(6)](../sql-reference/data-types/datetime.md) | `long (timestamp-micros)` \* | -\* [Avro logical types](http://avro.apache.org/docs/current/spec.html#Logical+Types) +\* [Avro logical types](https://avro.apache.org/docs/current/spec.html#Logical+Types) Unsupported Avro data types: `record` (non-root), `map` @@ -1028,7 +1030,7 @@ The root schema of input Avro file must be of `record` type. To find the correspondence between table columns and fields of Avro schema ClickHouse compares their names. This comparison is case-sensitive. Unused fields are skipped. -Data types of ClickHouse table columns can differ from the corresponding fields of the Avro data inserted. When inserting data, ClickHouse interprets data types according to the table above and then [casts](../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) the data to corresponding column type. +Data types of ClickHouse table columns can differ from the corresponding fields of the Avro data inserted. When inserting data, ClickHouse interprets data types according to the table above and then [casts](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) the data to corresponding column type. ### Selecting Data {#selecting-data-1} @@ -1070,7 +1072,7 @@ $ kafkacat -b kafka-broker -C -t topic1 -o beginning -f '%s' -c 3 | clickhouse- 3 c ``` -To use `AvroConfluent` with [Kafka](../engines/table_engines/integrations/kafka.md): +To use `AvroConfluent` with [Kafka](../engines/table-engines/integrations/kafka.md): ``` sql CREATE TABLE topic1_stream @@ -1095,29 +1097,29 @@ SELECT * FROM topic1_stream; ## Parquet {#data-format-parquet} -[Apache Parquet](http://parquet.apache.org/) is a columnar storage format widespread in the Hadoop ecosystem. ClickHouse supports read and write operations for this format. +[Apache Parquet](https://parquet.apache.org/) is a columnar storage format widespread in the Hadoop ecosystem. ClickHouse supports read and write operations for this format. ### Data Types Matching {#data_types-matching-2} -The table below shows supported data types and how they match ClickHouse [data types](../sql_reference/data_types/index.md) in `INSERT` and `SELECT` queries. +The table below shows supported data types and how they match ClickHouse [data types](../sql-reference/data-types/index.md) in `INSERT` and `SELECT` queries. | Parquet data type (`INSERT`) | ClickHouse data type | Parquet data type (`SELECT`) | |------------------------------|-----------------------------------------------------------|------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | `UINT8` | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | `INT8` | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | `UINT16` | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | `INT16` | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | `UINT32` | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | `INT32` | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | `UINT64` | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | `INT64` | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | `FLOAT` | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | `DOUBLE` | -| `DATE32` | [Date](../sql_reference/data_types/date.md) | `UINT16` | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | `UINT32` | -| `STRING`, `BINARY` | [String](../sql_reference/data_types/string.md) | `STRING` | -| — | [FixedString](../sql_reference/data_types/fixedstring.md) | `STRING` | -| `DECIMAL` | [Decimal](../sql_reference/data_types/decimal.md) | `DECIMAL` | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | `UINT8` | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | `INT8` | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | `UINT16` | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | `INT16` | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | `UINT32` | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | `INT32` | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | `UINT64` | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | `INT64` | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | `FLOAT` | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | `DOUBLE` | +| `DATE32` | [Date](../sql-reference/data-types/date.md) | `UINT16` | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | `UINT32` | +| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | `STRING` | +| — | [FixedString](../sql-reference/data-types/fixedstring.md) | `STRING` | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | `DECIMAL` | ClickHouse supports configurable precision of `Decimal` type. The `INSERT` query treats the Parquet `DECIMAL` type as the ClickHouse `Decimal128` type. @@ -1139,7 +1141,17 @@ You can select data from a ClickHouse table and save them into some file in the $ clickhouse-client --query="SELECT * FROM {some_table} FORMAT Parquet" > {some_file.pq} ``` -To exchange data with Hadoop, you can use [HDFS table engine](../engines/table_engines/integrations/hdfs.md). +To exchange data with Hadoop, you can use [HDFS table engine](../engines/table-engines/integrations/hdfs.md). + +## Arrow {#data-format-arrow} + +[Apache Arrow](https://arrow.apache.org/) comes with two built-in columnar storage formats. ClickHouse supports read and write operations for these formats. + +`Arrow` is Apache Arrow's "file mode" format. It is designed for in-memory random access. + +## ArrowStream {#data-format-arrow-stream} + +`ArrowStream` is Apache Arrow's "stream mode" format. It is designed for in-memory stream processing. ## ORC {#data-format-orc} @@ -1147,30 +1159,30 @@ To exchange data with Hadoop, you can use [HDFS table engine](../engines/table_e ### Data Types Matching {#data_types-matching-3} -The table below shows supported data types and how they match ClickHouse [data types](../sql_reference/data_types/index.md) in `INSERT` queries. +The table below shows supported data types and how they match ClickHouse [data types](../sql-reference/data-types/index.md) in `INSERT` queries. | ORC data type (`INSERT`) | ClickHouse data type | |--------------------------|-----------------------------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | -| `DATE32` | [Date](../sql_reference/data_types/date.md) | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | -| `STRING`, `BINARY` | [String](../sql_reference/data_types/string.md) | -| `DECIMAL` | [Decimal](../sql_reference/data_types/decimal.md) | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE32` | [Date](../sql-reference/data-types/date.md) | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | +| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | ClickHouse supports configurable precision of the `Decimal` type. The `INSERT` query treats the ORC `DECIMAL` type as the ClickHouse `Decimal128` type. Unsupported ORC data types: `DATE32`, `TIME32`, `FIXED_SIZE_BINARY`, `JSON`, `UUID`, `ENUM`. -The data types of ClickHouse table columns don’t have to match the corresponding ORC data fields. When inserting data, ClickHouse interprets data types according to the table above and then [casts](../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) the data to the data type set for the ClickHouse table column. +The data types of ClickHouse table columns don’t have to match the corresponding ORC data fields. When inserting data, ClickHouse interprets data types according to the table above and then [casts](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) the data to the data type set for the ClickHouse table column. ### Inserting Data {#inserting-data-2} @@ -1180,7 +1192,7 @@ You can insert ORC data from a file into ClickHouse table by the following comma $ cat filename.orc | clickhouse-client --query="INSERT INTO some_table FORMAT ORC" ``` -To exchange data with Hadoop, you can use [HDFS table engine](../engines/table_engines/integrations/hdfs.md). +To exchange data with Hadoop, you can use [HDFS table engine](../engines/table-engines/integrations/hdfs.md). ## Format Schema {#formatschema} @@ -1196,7 +1208,7 @@ can contain an absolute path or a path relative to the current directory on the If you use the client in the [batch mode](../interfaces/cli.md#cli_usage), the path to the schema must be relative due to security reasons. If you input or output data via the [HTTP interface](../interfaces/http.md) the file name specified in the format schema -should be located in the directory specified in [format\_schema\_path](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-format_schema_path) +should be located in the directory specified in [format\_schema\_path](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-format_schema_path) in the server configuration. ## Skipping Errors {#skippingerrors} diff --git a/docs/en/interfaces/http.md b/docs/en/interfaces/http.md index 0e18e00bb0d..98de4a560fb 100644 --- a/docs/en/interfaces/http.md +++ b/docs/en/interfaces/http.md @@ -9,7 +9,7 @@ The HTTP interface lets you use ClickHouse on any platform from any programming By default, clickhouse-server listens for HTTP on port 8123 (this can be changed in the config). -If you make a GET / request without parameters, it returns 200 response code and the string which defined in [http\_server\_default\_response](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-http_server_default_response) default value “Ok.” (with a line feed at the end) +If you make a GET / request without parameters, it returns 200 response code and the string which defined in [http\_server\_default\_response](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-http_server_default_response) default value “Ok.” (with a line feed at the end) ``` bash $ curl 'http://localhost:8123/' @@ -301,13 +301,16 @@ Example: ``` xml - - /metrics - GET - + + /predefined_query + POST,GET + + predefined_query_handler SELECT * FROM system.metrics LIMIT 5 FORMAT Template SETTINGS format_template_resultset = 'prometheus_template_output_format_resultset', format_template_row = 'prometheus_template_output_format_row', format_template_rows_between_delimiter = '\n' - - + + + ... + ... ``` @@ -316,21 +319,23 @@ Example: ``` bash -curl -vvv 'http://localhost:8123/metrics' +$ curl -v 'http://localhost:8123/predefined_query' * Trying ::1... * Connected to localhost (::1) port 8123 (#0) -> GET /metrics HTTP/1.1 +> GET /predefined_query HTTP/1.1 > Host: localhost:8123 > User-Agent: curl/7.47.0 > Accept: */* > < HTTP/1.1 200 OK -< Date: Wed, 27 Nov 2019 08:54:25 GMT +< Date: Tue, 28 Apr 2020 08:52:56 GMT < Connection: Keep-Alive < Content-Type: text/plain; charset=UTF-8 -< X-ClickHouse-Server-Display-Name: i-tl62qd0o +< X-ClickHouse-Server-Display-Name: i-mloy5trc < Transfer-Encoding: chunked -< X-ClickHouse-Query-Id: f39235f6-6ed7-488c-ae07-c7ceafb960f6 +< X-ClickHouse-Query-Id: 96fe0052-01e6-43ce-b12a-6b7370de6e8a +< X-ClickHouse-Format: Template +< X-ClickHouse-Timezone: Asia/Shanghai < Keep-Alive: timeout=3 < X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} < @@ -354,117 +359,62 @@ curl -vvv 'http://localhost:8123/metrics' # TYPE "ReplicatedSend" counter "ReplicatedSend" 0 +* Connection #0 to host localhost left intact + + * Connection #0 to host localhost left intact ``` -As you can see from the example, if `` is configured in the config.xml file, ClickHouse will match the HTTP requests received to the predefined type in ``, then ClickHouse will execute the corresponding predefined query if the match is successful. +As you can see from the example, if `` is configured in the config.xml file and `` can contain many `s`. ClickHouse will match the HTTP requests received to the predefined type in `` and the first matched runs the handler. Then ClickHouse will execute the corresponding predefined query if the match is successful. -Now `` can configure ``, ``, ``, `` and `` . +> Now `` can configure ``, ``, ``,``: +> `` is responsible for matching the method part of the HTTP request. `` fully conforms to the definition of [method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) in the HTTP protocol. It is an optional configuration. If it is not defined in the configuration file, it does not match the method portion of the HTTP request. +> +> `` is responsible for matching the url part of the HTTP request. It is compatible with [RE2](https://github.com/google/re2)’s regular expressions. It is an optional configuration. If it is not defined in the configuration file, it does not match the url portion of the HTTP request. +> +> `` is responsible for matching the header part of the HTTP request. It is compatible with RE2’s regular expressions. It is an optional configuration. If it is not defined in the configuration file, it does not match the header portion of the HTTP request. +> +> `` contains the main processing part. Now `` can configure ``, ``, ``, ``, ``, ``. +> \> `` currently supports three types: **predefined\_query\_handler**, **dynamic\_query\_handler**, **static**. +> \> +> \> `` - use with predefined\_query\_handler type, executes query when the handler is called. +> \> +> \> `` - use with dynamic\_query\_handler type, extracts and executes the value corresponding to the `` value in HTTP request params. +> \> +> \> `` - use with static type, response status code. +> \> +> \> `` - use with static type, response [content-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type). +> \> +> \> `` - use with static type, Response content sent to client, when using the prefix ‘file://’ or ‘config://’, find the content from the file or configuration send to client. -## root\_handler {#root_handler} - -`` returns the specified content for the root path request. The specific return content is configured by `http_server_default_response` in config.xml. if not specified, return **Ok.** - -`http_server_default_response` is not defined and an HTTP request is sent to ClickHouse. The result is as follows: - -``` xml - - - -``` - - $ curl 'http://localhost:8123' - Ok. - -`http_server_default_response` is defined and an HTTP request is sent to ClickHouse. The result is as follows: - -``` xml -
]]>
- - - - -``` - - $ curl 'http://localhost:8123' -
% - -## ping\_handler {#ping_handler} - -`` can be used to probe the health of the current ClickHouse Server. When the ClickHouse HTTP Server is normal, accessing ClickHouse through `` will return **Ok.**. - -Example: - -``` xml - - /ping - -``` - -``` bash -$ curl 'http://localhost:8123/ping' -Ok. -``` - -## replicas\_status\_handler {#replicas_status_handler} - -`` is used to detect the state of the replica node and return **Ok.** if the replica node has no delay. If there is a delay, return the specific delay. The value of `` supports customization. If you do not specify ``, ClickHouse default setting `` is **/replicas\_status**. - -Example: - -``` xml - - /replicas_status - -``` - -No delay case: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -Ok. -``` - -Delayed case: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -db.stats: Absolute delay: 22. Relative delay: 22. -``` +Next are the configuration methods for the different ``. ## predefined\_query\_handler {#predefined_query_handler} -You can configure ``, ``, `` and `` in ``. +`` supports setting Settings and query\_params values. You can configure `` in the type of ``. -`` is responsible for matching the method part of the HTTP request. `` fully conforms to the definition of [method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) in the HTTP protocol. It is an optional configuration. If it is not defined in the configuration file, it does not match the method portion of the HTTP request - -`` is responsible for matching the url part of the HTTP request. It is compatible with [RE2](https://github.com/google/re2)’s regular expressions. It is an optional configuration. If it is not defined in the configuration file, it does not match the url portion of the HTTP request - -`` is responsible for matching the header part of the HTTP request. It is compatible with RE2’s regular expressions. It is an optional configuration. If it is not defined in the configuration file, it does not match the header portion of the HTTP request - -`` value is a predefined query of ``, which is executed by ClickHouse when an HTTP request is matched and the result of the query is returned. It is a must configuration. - -`` supports setting Settings and query\_params values. +`` value is a predefined query of ``, which is executed by ClickHouse when an HTTP request is matched and the result of the query is returned. It is a must configuration. The following example defines the values of `max_threads` and `max_alter_threads` settings, then queries the system table to check whether these settings were set successfully. Example: ``` xml - - + + + [^/]+)(/(?P[^/]+))?]]> GET TEST_HEADER_VALUE [^/]+)(/(?P[^/]+))?]]> - [^/]+)(/(?P[^/]+))?]]> - + + predefined_query_handler SELECT value FROM system.settings WHERE name = {name_1:String} SELECT name, value FROM system.settings WHERE name = {name_2:String} - - - +
+
+
``` ``` bash @@ -473,37 +423,193 @@ $ curl -H 'XXX:TEST_HEADER_VALUE' -H 'PARAMS_XXX:max_threads' 'http://localhost: max_alter_threads 2 ``` -!!! note "Note" - In one ``, one `` only supports one `` of an insert type. +!!! note "caution" + In one `` only supports one `` of an insert type. ## dynamic\_query\_handler {#dynamic_query_handler} -`` than `` increased `` . +In ``, query is written in the form of param of the HTTP request. The difference is that in ``, query is wrote in the configuration file. You can configure `` in ``. -ClickHouse extracts and executes the value corresponding to the `` value in the url of the HTTP request. -ClickHouse default setting `` is `/query` . It is an optional configuration. If there is no definition in the configuration file, the param is not passed in. +ClickHouse extracts and executes the value corresponding to the `` value in the url of the HTTP request. The default value of `` is `/query` . It is an optional configuration. If there is no definition in the configuration file, the param is not passed in. To experiment with this functionality, the example defines the values of max\_threads and max\_alter\_threads and queries whether the Settings were set successfully. -The difference is that in ``, query is wrote in the configuration file. But in ``, query is written in the form of param of the HTTP request. Example: ``` xml - - - - TEST_HEADER_VALUE_DYNAMIC - [^/]+)(/(?P[^/]+))?]]> - + + + + TEST_HEADER_VALUE_DYNAMIC + + dynamic_query_handler query_param - - + +
+
``` ``` bash -$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' -H 'PARAMS_XXX:max_threads' 'http://localhost:8123/?query_param=SELECT%20value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D&max_threads=1&max_alter_threads=2¶m_name_2=max_alter_threads' -1 -2 +$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' 'http://localhost:8123/own?max_threads=1&max_alter_threads=2¶m_name_1=max_threads¶m_name_2=max_alter_threads&query_param=SELECT%20name,value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D' +max_threads 1 +max_alter_threads 2 +``` + +## static {#static} + +`` can return [content\_type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type), [status](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) and response\_content. response\_content can return the specified content + +Example: + +Return a message. + +``` xml + + + GET + xxx + /hi + + static + 402 + text/html; charset=UTF-8 + Say Hi! + + + +``` + +``` bash +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/hi' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /hi HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 402 Payment Required +< Date: Wed, 29 Apr 2020 03:51:26 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +Say Hi!% +``` + +Find the content from the configuration send to client. + +``` xml +
]]>
+ + + + GET + xxx + /get_config_static_handler + + static + config://get_config_static_handler + + + +``` + +``` bash +$ curl -v -H 'XXX:xxx' 'http://localhost:8123/get_config_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_config_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:01:24 GMT +< Connection: Keep-Alive +< Content-Type: text/plain; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +
% +``` + +Find the content from the file send to client. + +``` xml + + + GET + xxx + /get_absolute_path_static_handler + + static + text/html; charset=UTF-8 + file:///absolute_path_file.html + + + + GET + xxx + /get_relative_path_static_handler + + static + text/html; charset=UTF-8 + file://./relative_path_file.html + + + +``` + +``` bash +$ user_files_path='/var/lib/clickhouse/user_files' +$ sudo echo "Relative Path File" > $user_files_path/relative_path_file.html +$ sudo echo "Absolute Path File" > $user_files_path/absolute_path_file.html +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_absolute_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_absolute_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:16 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Absolute Path File +* Connection #0 to host localhost left intact +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_relative_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_relative_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:31 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Relative Path File +* Connection #0 to host localhost left intact ``` [Original article](https://clickhouse.tech/docs/en/interfaces/http_interface/) diff --git a/docs/en/interfaces/index.md b/docs/en/interfaces/index.md index 938f276fe0b..e1b8a639db2 100644 --- a/docs/en/interfaces/index.md +++ b/docs/en/interfaces/index.md @@ -20,7 +20,7 @@ In most cases it is recommended to use appropriate tool or library instead of in There are also a wide range of third-party libraries for working with ClickHouse: -- [Client libraries](third-party/client_libraries.md) +- [Client libraries](third-party/client-libraries.md) - [Integrations](third-party/integrations.md) - [Visual interfaces](third-party/gui.md) diff --git a/docs/en/interfaces/mysql.md b/docs/en/interfaces/mysql.md index 9f9d7f89a87..d4f19630c10 100644 --- a/docs/en/interfaces/mysql.md +++ b/docs/en/interfaces/mysql.md @@ -5,7 +5,7 @@ toc_title: MySQL Interface # MySQL Interface {#mysql-interface} -ClickHouse supports MySQL wire protocol. It can be enabled by [mysql\_port](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-mysql_port) setting in configuration file: +ClickHouse supports MySQL wire protocol. It can be enabled by [mysql\_port](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-mysql_port) setting in configuration file: ``` xml 9004 @@ -35,8 +35,8 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` -For compatibility with all MySQL clients, it is recommended to specify user password with [double SHA1](../operations/settings/settings_users.md#password_double_sha1_hex) in configuration file. -If user password is specified using [SHA256](../operations/settings/settings_users.md#password_sha256_hex), some clients won’t be able to authenticate (mysqljs and old versions of command-line tool mysql). +For compatibility with all MySQL clients, it is recommended to specify user password with [double SHA1](../operations/settings/settings-users.md#password_double_sha1_hex) in configuration file. +If user password is specified using [SHA256](../operations/settings/settings-users.md#password_sha256_hex), some clients won’t be able to authenticate (mysqljs and old versions of command-line tool mysql). Restrictions: diff --git a/docs/en/interfaces/odbc.md b/docs/en/interfaces/odbc.md index 4fd7cd23964..42ae4cf5b53 100644 --- a/docs/en/interfaces/odbc.md +++ b/docs/en/interfaces/odbc.md @@ -5,6 +5,6 @@ toc_title: ODBC Driver # ODBC Driver {#odbc-driver} -- [Official driver](https://github.com/ClickHouse/clickhouse-odbc). +- [Official driver](https://github.com/ClickHouse/clickhouse-odbc) [Original article](https://clickhouse.tech/docs/en/interfaces/odbc/) diff --git a/docs/en/interfaces/third-party/client_libraries.md b/docs/en/interfaces/third-party/client-libraries.md similarity index 100% rename from docs/en/interfaces/third-party/client_libraries.md rename to docs/en/interfaces/third-party/client-libraries.md diff --git a/docs/en/interfaces/third-party/gui.md b/docs/en/interfaces/third-party/gui.md index 9b380a0f92e..2009312a917 100644 --- a/docs/en/interfaces/third-party/gui.md +++ b/docs/en/interfaces/third-party/gui.md @@ -92,7 +92,8 @@ Features: [clickhouse-flamegraph](https://github.com/Slach/clickhouse-flamegraph) is a specialized tool to visualize the `system.trace_log` as [flamegraph](http://www.brendangregg.com/flamegraphs.html). ### clickhouse-plantuml {#clickhouse-plantuml} -[cickhouse-plantuml](https://pypi.org/project/clickhouse-plantuml/) is a script to generate [PlantUML](https://plantuml.com/) diagram of tables' schemes. + +[cickhouse-plantuml](https://pypi.org/project/clickhouse-plantuml/) is a script to generate [PlantUML](https://plantuml.com/) diagram of tables’ schemes. ## Commercial {#commercial} diff --git a/docs/en/interfaces/third-party/index.md b/docs/en/interfaces/third-party/index.md index 16d315d059c..84291a199eb 100644 --- a/docs/en/interfaces/third-party/index.md +++ b/docs/en/interfaces/third-party/index.md @@ -3,3 +3,4 @@ toc_folder_title: Third-Party toc_priority: 24 --- + diff --git a/docs/en/interfaces/third-party/integrations.md b/docs/en/interfaces/third-party/integrations.md index 9f4b0f2fa65..716e774871b 100644 --- a/docs/en/interfaces/third-party/integrations.md +++ b/docs/en/interfaces/third-party/integrations.md @@ -25,6 +25,7 @@ toc_title: Integrations - Message queues - [Kafka](https://kafka.apache.org) - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (uses [Go client](https://github.com/ClickHouse/clickhouse-go/)) + - [stream-loader-clickhouse](https://github.com/adform/stream-loader) - Stream processing - [Flink](https://flink.apache.org) - [flink-clickhouse-sink](https://github.com/ivi-ru/flink-clickhouse-sink) @@ -43,7 +44,7 @@ toc_title: Integrations - [graphouse](https://github.com/yandex/graphouse) - [carbon-clickhouse](https://github.com/lomik/carbon-clickhouse) + - [graphite-clickhouse](https://github.com/lomik/graphite-clickhouse) - - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - optimizes staled partitions in [\*GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md#graphitemergetree) if rules from [rollup configuration](../../engines/table_engines/mergetree_family/graphitemergetree.md#rollup-configuration) could be applied + - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - optimizes staled partitions in [\*GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md#graphitemergetree) if rules from [rollup configuration](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) could be applied - [Grafana](https://grafana.com/) - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) - [Prometheus](https://prometheus.io/) @@ -75,7 +76,7 @@ toc_title: Integrations - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (uses [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - [pandas](https://pandas.pydata.org) - [pandahouse](https://github.com/kszucs/pandahouse) -- PHP +- PHP - [Doctrine](https://www.doctrine-project.org/) - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) - R @@ -83,7 +84,7 @@ toc_title: Integrations - [RClickHouse](https://github.com/IMSMWU/RClickHouse) (uses [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) - Java - [Hadoop](http://hadoop.apache.org) - - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (uses [JDBC](../../sql_reference/table_functions/jdbc.md)) + - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (uses [JDBC](../../sql-reference/table-functions/jdbc.md)) - Scala - [Akka](https://akka.io) - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) diff --git a/docs/en/introduction/adopters.md b/docs/en/introduction/adopters.md index d2fcb112e67..081f963f74f 100644 --- a/docs/en/introduction/adopters.md +++ b/docs/en/introduction/adopters.md @@ -8,78 +8,78 @@ toc_title: Adopters !!! warning "Disclaimer" The following list of companies using ClickHouse and their success stories is assembled from public sources, thus might differ from current reality. We’d appreciate it if you share the story of adopting ClickHouse in your company and [add it to the list](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/introduction/adopters.md), but please make sure you won’t have any NDA issues by doing so. Providing updates with publications from other companies is also useful. -| Company | Industry | Usecase | Cluster Size | (Un)Compressed Data Size\* | Reference | -|-----------------------------------------------------------------------------|---------------------------------|-----------------------|------------------------------------------------------------|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [2gis](https://2gis.ru) | Maps | Monitoring | — | — | [Talk in Russian, July 2019](https://youtu.be/58sPkXfq6nw) | -| [Aloha Browser](https://alohabrowser.com/) | Mobile App | Browser backend | — | — | [Slides in Russian, May 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | -| [Amadeus](https://amadeus.com/) | Travel | Analytics | — | — | [Press Release, April 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | -| [Appsflyer](https://www.appsflyer.com) | Mobile analytics | Main product | — | — | [Talk in Russian, July 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | -| [ArenaData](https://arenadata.tech/) | Data Platform | Main product | — | — | [Slides in Russian, December 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | -| [Badoo](https://badoo.com) | Dating | Timeseries | — | — | [Slides in Russian, December 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | -| [Benocs](https://www.benocs.com/) | Network Telemetry and Analytics | Main Product | — | — | [Slides in English, October 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | -| [Bloomberg](https://www.bloomberg.com/) | Finance, Media | Monitoring | 102 servers | — | [Slides, May 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | -| [Bloxy](https://bloxy.info) | Blockchain | Analytics | — | — | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | -| `Dataliance/UltraPower` | Telecom | Analytics | — | — | [Slides in Chinese, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | -| [CARTO](https://carto.com/) | Business Intelligence | Geo analytics | — | — | [Geospatial processing with ClickHouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | -| [CERN](http://public.web.cern.ch/public/) | Research | Experiment | — | — | [Press release, April 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | -| [Cisco](http://cisco.com/) | Networking | Traffic analysis | — | — | [Lightning talk, October 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | -| [Citadel Securities](https://www.citadelsecurities.com/) | Finance | — | — | — | [Contribution, March 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | -| [Citymobil](https://city-mobil.ru) | Taxi | Analytics | — | — | [Blog Post in Russian, March 2020](https://habr.com/en/company/citymobil/blog/490660/) | -| [ContentSquare](https://contentsquare.com) | Web analytics | Main product | — | — | [Blog post in French, November 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | -| [Cloudflare](https://cloudflare.com) | CDN | Traffic analysis | 36 servers | — | [Blog post, May 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Blog post, March 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | -| [Corunet](https://coru.net/) | Analytics | Main product | — | — | [Slides in English, April 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | -| [CraiditX 氪信](https://www.creditx.com) | Finance AI | Analysis | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | -| [Criteo/Storetail](https://www.criteo.com/) | Retail | Main product | — | — | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | -| [Deutsche Bank](https://db.com) | Finance | BI Analytics | — | — | [Slides in English, October 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | -| [Diva-e](https://www.diva-e.com) | Digital consulting | Main Product | — | — | [Slides in English, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | -| [Exness](https://www.exness.com) | Trading | Metrics, Logging | — | — | [Talk in Russian, May 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | -| [Geniee](https://geniee.co.jp) | Ad network | Main product | — | — | [Blog post in Japanese, July 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | -| [HUYA](https://www.huya.com/) | Video Streaming | Analytics | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | -| [Idealista](https://www.idealista.com) | Real Estate | Analytics | — | — | [Blog Post in English, April 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | -| [Infovista](https://www.infovista.com/) | Networks | Analytics | — | — | [Slides in English, October 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | -| [InnoGames](https://www.innogames.com) | Games | Metrics, Logging | — | — | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | -| [Integros](https://integros.com) | Platform for video services | Analytics | — | — | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Kodiak Data](https://www.kodiakdata.com/) | Clouds | Main product | — | — | [Slides in Engish, April 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | -| [Kontur](https://kontur.ru) | Software Development | Metrics | — | — | [Talk in Russian, November 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | -| [LifeStreet](https://lifestreet.com/) | Ad network | Main product | 75 servers (3 replicas) | 5.27 PiB | [Blog post in Russian, February 2017](https://habr.com/en/post/322620/) | -| [Mail.ru Cloud Solutions](https://mcs.mail.ru/) | Cloud services | Main product | — | — | [Running ClickHouse Instance, in Russian](https://mcs.mail.ru/help/db-create/clickhouse#) | -| [MessageBird](https://www.messagebird.com) | Telecommunications | Statistics | — | — | [Slides in English, November 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | -| [MGID](https://www.mgid.com/) | Ad network | Web-analytics | — | — | [Our experience in implementing analytical DBMS ClickHouse, in Russian](http://gs-studio.com/news-about-it/32777----clickhouse---c) | -| [OneAPM](https://www.oneapm.com/) | Monitorings and Data Analysis | Main product | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | -| [Pragma Innovation](http://www.pragma-innovation.fr/) | Telemetry and Big Data Analysis | Main product | — | — | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | -| [QINGCLOUD](https://www.qingcloud.com/) | Cloud services | Main product | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | -| [Qrator](https://qrator.net) | DDoS protection | Main product | — | — | [Blog Post, March 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | -| [Percent 百分点](https://www.percent.cn/) | Analytics | Main Product | — | — | [Slides in Chinese, June 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | -| [Rambler](https://rambler.ru) | Internet services | Analytics | — | — | [Talk in Russian, April 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | -| [Tencent](https://www.tencent.com) | Messaging | Logging | — | — | [Talk in Chinese, November 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | -| [Traffic Stars](https://trafficstars.com/) | AD network | — | — | — | [Slides in Russian, May 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | -| [S7 Airlines](https://www.s7.ru) | Airlines | Metrics, Logging | — | — | [Talk in Russian, March 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | -| [SEMrush](https://www.semrush.com/) | Marketing | Main product | — | — | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | -| [scireum GmbH](https://www.scireum.de/) | e-Commerce | Main product | — | — | [Talk in German, February 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | -| [Sentry](https://sentry.io/) | Software developer | Backend for product | — | — | [Blog Post in English, May 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | -| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr) | Goverment Social Security | Analytics | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | -| [seo.do](https://seo.do/) | Analytics | Main product | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | -| [Sina](http://english.sina.com/index.html) | News | — | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | -| [SMI2](https://smi2.ru/) | News | Analytics | — | — | [Blog Post in Russian, November 2017](https://habr.com/ru/company/smi2/blog/314558/) | -| [Splunk](https://www.splunk.com/) | Business Analytics | Main product | — | — | [Slides in English, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | -| [Spotify](https://www.spotify.com) | Music | Experimentation | — | — | [Slides, July 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | -| [Tencent](https://www.tencent.com) | Big Data | Data processing | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | -| [Uber](https://www.uber.com) | Taxi | Logging | — | — | [Slides, February 2020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | -| [VKontakte](https://vk.com) | Social Network | Statistics, Logging | — | — | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | -| [Wisebits](https://wisebits.com/) | IT Solutions | Analytics | — | — | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Xiaoxin Tech](http://www.xiaoxintech.cn/) | Education | Common purpose | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | -| [Ximalaya](https://www.ximalaya.com/) | Audio sharing | OLAP | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | -| [Yandex Cloud](https://cloud.yandex.ru/services/managed-clickhouse) | Public Cloud | Main product | — | — | [Talk in Russian, December 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | -| [Yandex DataLens](https://cloud.yandex.ru/services/datalens) | Business Intelligence | Main product | — | — | [Slides in Russian, December 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | -| [Yandex Market](https://market.yandex.ru/) | e-Commerce | Metrics, Logging | — | — | [Talk in Russian, January 2019](https://youtu.be/_l1qP0DyBcA?t=478) | -| [Yandex Metrica](https://metrica.yandex.com) | Web analytics | Main product | 360 servers in one cluster, 1862 servers in one department | 66.41 PiB / 5.68 PiB | [Slides, February 2020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | -| [ЦВТ](https://htc-cs.ru/) | Software Development | Metrics, Logging | — | — | [Blog Post, March 2019, in Russian](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | -| [МКБ](https://mkb.ru/) | Bank | Web-system monitoring | — | — | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | -| [Jinshuju 金数据](https://jinshuju.net) | BI Analytics | Main product | — | — | [Slides in Chinese, October 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | -| [Instana](https://www.instana.com) | APM Platform | Main product | — | — | [Twitter post](https://twitter.com/mieldonkers/status/1248884119158882304) | -| [Wargaming](https://wargaming.com/en/) | Games | | — | — | [Interview](https://habr.com/en/post/496954/) | -| [Crazypanda](https://crazypanda.ru/en/) | Games | | — | — | Live session on ClickHouse meetup | -| [FunCorp](https://fun.co/rp) | Games | | — | — | [Article](https://www.altinity.com/blog/migrating-from-redshift-to-clickhouse) | - +| Company | Industry | Usecase | Cluster Size | (Un)Compressed Data Size\* | Reference | +|---------------------------------------------------------------------|---------------------------------|-----------------------|------------------------------------------------------------|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [2gis](https://2gis.ru){.favicon} | Maps | Monitoring | — | — | [Talk in Russian, July 2019](https://youtu.be/58sPkXfq6nw) | +| [Aloha Browser](https://alohabrowser.com/){.favicon} | Mobile App | Browser backend | — | — | [Slides in Russian, May 2019](https://presentations.clickhouse.tech/meetup22/aloha.pdf) | +| [Amadeus](https://amadeus.com/){.favicon} | Travel | Analytics | — | — | [Press Release, April 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | +| [Appsflyer](https://www.appsflyer.com){.favicon} | Mobile analytics | Main product | — | — | [Talk in Russian, July 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | +| [ArenaData](https://arenadata.tech/){.favicon} | Data Platform | Main product | — | — | [Slides in Russian, December 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | +| [Badoo](https://badoo.com){.favicon} | Dating | Timeseries | — | — | [Slides in Russian, December 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | +| [Benocs](https://www.benocs.com/){.favicon} | Network Telemetry and Analytics | Main Product | — | — | [Slides in English, October 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | +| [Bloomberg](https://www.bloomberg.com/){.favicon} | Finance, Media | Monitoring | 102 servers | — | [Slides, May 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | +| [Bloxy](https://bloxy.info){.favicon} | Blockchain | Analytics | — | — | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | +| [Dataliance for China Telecom](https://www.chinatelecomglobal.com/){.favicon} | Telecom | Analytics | — | — | [Slides in Chinese, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | +| [CARTO](https://carto.com/){.favicon} | Business Intelligence | Geo analytics | — | — | [Geospatial processing with ClickHouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | +| [CERN](http://public.web.cern.ch/public/){.favicon} | Research | Experiment | — | — | [Press release, April 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | +| [Cisco](http://cisco.com/){.favicon} | Networking | Traffic analysis | — | — | [Lightning talk, October 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | +| [Citadel Securities](https://www.citadelsecurities.com/){.favicon} | Finance | — | — | — | [Contribution, March 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | +| [Citymobil](https://city-mobil.ru){.favicon} | Taxi | Analytics | — | — | [Blog Post in Russian, March 2020](https://habr.com/en/company/citymobil/blog/490660/) | +| [ContentSquare](https://contentsquare.com){.favicon} | Web analytics | Main product | — | — | [Blog post in French, November 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | +| [Cloudflare](https://cloudflare.com){.favicon} | CDN | Traffic analysis | 36 servers | — | [Blog post, May 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Blog post, March 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | +| [Corunet](https://coru.net/){.favicon} | Analytics | Main product | — | — | [Slides in English, April 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | +| [CraiditX 氪信](https://www.creditx.com){.favicon} | Finance AI | Analysis | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | +| [Criteo](https://www.criteo.com/){.favicon} | Retail | Main product | — | — | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | +| [Deutsche Bank](https://db.com){.favicon} | Finance | BI Analytics | — | — | [Slides in English, October 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | +| [Diva-e](https://www.diva-e.com){.favicon} | Digital consulting | Main Product | — | — | [Slides in English, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | +| [Exness](https://www.exness.com){.favicon} | Trading | Metrics, Logging | — | — | [Talk in Russian, May 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | +| [Geniee](https://geniee.co.jp){.favicon} | Ad network | Main product | — | — | [Blog post in Japanese, July 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | +| [HUYA](https://www.huya.com/){.favicon} | Video Streaming | Analytics | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | +| [Idealista](https://www.idealista.com){.favicon} | Real Estate | Analytics | — | — | [Blog Post in English, April 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | +| [Infovista](https://www.infovista.com/){.favicon} | Networks | Analytics | — | — | [Slides in English, October 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | +| [InnoGames](https://www.innogames.com){.favicon} | Games | Metrics, Logging | — | — | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | +| [Integros](https://integros.com){.favicon} | Platform for video services | Analytics | — | — | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| [Kodiak Data](https://www.kodiakdata.com/){.favicon} | Clouds | Main product | — | — | [Slides in Engish, April 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | +| [Kontur](https://kontur.ru){.favicon} | Software Development | Metrics | — | — | [Talk in Russian, November 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | +| [Lawrence Berkeley National Laboratory](https://www.lbl.gov){.favicon} | Research | Traffic analysis | 1 server | 11.8 TiB | [Slides in English, April 2019](https://www.smitasin.com/presentations/2019-04-17_DOE-NSM.pdf) | +| [LifeStreet](https://lifestreet.com/){.favicon} | Ad network | Main product | 75 servers (3 replicas) | 5.27 PiB | [Blog post in Russian, February 2017](https://habr.com/en/post/322620/) | +| [Mail.ru Cloud Solutions](https://mcs.mail.ru/){.favicon} | Cloud services | Main product | — | — | [Article in Russian](https://mcs.mail.ru/help/db-create/clickhouse#) | +| [MessageBird](https://www.messagebird.com){.favicon} | Telecommunications | Statistics | — | — | [Slides in English, November 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | +| [MGID](https://www.mgid.com/){.favicon} | Ad network | Web-analytics | — | — | [Blog post in Russian, April 2020](http://gs-studio.com/news-about-it/32777----clickhouse---c) | +| [OneAPM](https://www.oneapm.com/){.favicon} | Monitorings and Data Analysis | Main product | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | +| [Pragma Innovation](http://www.pragma-innovation.fr/){.favicon} | Telemetry and Big Data Analysis | Main product | — | — | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | +| [QINGCLOUD](https://www.qingcloud.com/){.favicon} | Cloud services | Main product | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | +| [Qrator](https://qrator.net){.favicon} | DDoS protection | Main product | — | — | [Blog Post, March 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | +| [Percent 百分点](https://www.percent.cn/){.favicon} | Analytics | Main Product | — | — | [Slides in Chinese, June 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | +| [Rambler](https://rambler.ru){.favicon} | Internet services | Analytics | — | — | [Talk in Russian, April 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | +| [Tencent](https://www.tencent.com){.favicon} | Messaging | Logging | — | — | [Talk in Chinese, November 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | +| [Traffic Stars](https://trafficstars.com/){.favicon} | AD network | — | — | — | [Slides in Russian, May 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | +| [S7 Airlines](https://www.s7.ru){.favicon} | Airlines | Metrics, Logging | — | — | [Talk in Russian, March 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | +| [SEMrush](https://www.semrush.com/){.favicon} | Marketing | Main product | — | — | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | +| [scireum GmbH](https://www.scireum.de/){.favicon} | e-Commerce | Main product | — | — | [Talk in German, February 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | +| [Sentry](https://sentry.io/){.favicon} | Software Development | Main product | — | — | [Blog Post in English, May 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | +| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr){.favicon} | Goverment Social Security | Analytics | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | +| [seo.do](https://seo.do/){.favicon} | Analytics | Main product | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | +| [Sina](http://english.sina.com/index.html){.favicon} | News | — | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | +| [SMI2](https://smi2.ru/){.favicon} | News | Analytics | — | — | [Blog Post in Russian, November 2017](https://habr.com/ru/company/smi2/blog/314558/) | +| [Splunk](https://www.splunk.com/){.favicon} | Business Analytics | Main product | — | — | [Slides in English, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | +| [Spotify](https://www.spotify.com){.favicon} | Music | Experimentation | — | — | [Slides, July 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | +| [Tencent](https://www.tencent.com){.favicon} | Big Data | Data processing | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | +| [Uber](https://www.uber.com){.favicon} | Taxi | Logging | — | — | [Slides, February 2020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | +| [VKontakte](https://vk.com){.favicon} | Social Network | Statistics, Logging | — | — | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | +| [Wisebits](https://wisebits.com/){.favicon} | IT Solutions | Analytics | — | — | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| [Xiaoxin Tech](http://www.xiaoxintech.cn/){.favicon} | Education | Common purpose | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | +| [Ximalaya](https://www.ximalaya.com/){.favicon} | Audio sharing | OLAP | — | — | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | +| [Yandex Cloud](https://cloud.yandex.ru/services/managed-clickhouse){.favicon} | Public Cloud | Main product | — | — | [Talk in Russian, December 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | +| [Yandex DataLens](https://cloud.yandex.ru/services/datalens){.favicon} | Business Intelligence | Main product | — | — | [Slides in Russian, December 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | +| [Yandex Market](https://market.yandex.ru/){.favicon} | e-Commerce | Metrics, Logging | — | — | [Talk in Russian, January 2019](https://youtu.be/_l1qP0DyBcA?t=478) | +| [Yandex Metrica](https://metrica.yandex.com){.favicon} | Web analytics | Main product | 360 servers in one cluster, 1862 servers in one department | 66.41 PiB / 5.68 PiB | [Slides, February 2020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | +| [ЦВТ](https://htc-cs.ru/){.favicon} | Software Development | Metrics, Logging | — | — | [Blog Post, March 2019, in Russian](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | +| [МКБ](https://mkb.ru/){.favicon} | Bank | Web-system monitoring | — | — | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | +| [Jinshuju 金数据](https://jinshuju.net){.favicon} | BI Analytics | Main product | — | — | [Slides in Chinese, October 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | +| [Instana](https://www.instana.com){.favicon} | APM Platform | Main product | — | — | [Twitter post](https://twitter.com/mieldonkers/status/1248884119158882304) | +| [Wargaming](https://wargaming.com/en/){.favicon} | Games | | — | — | [Interview](https://habr.com/en/post/496954/) | +| [Crazypanda](https://crazypanda.ru/en/){.favicon} | Games | | — | — | Live session on ClickHouse meetup | +| [FunCorp](https://fun.co/rp){.favicon} | Games | | — | — | [Article](https://www.altinity.com/blog/migrating-from-redshift-to-clickhouse) | [Original article](https://clickhouse.tech/docs/en/introduction/adopters/) diff --git a/docs/en/introduction/distinctive-features.md b/docs/en/introduction/distinctive-features.md new file mode 100644 index 00000000000..c1c44194a5f --- /dev/null +++ b/docs/en/introduction/distinctive-features.md @@ -0,0 +1,75 @@ +--- +toc_priority: 4 +toc_title: Distinctive Features +--- + +# Distinctive Features of ClickHouse {#distinctive-features-of-clickhouse} + +## True Column-Oriented DBMS {#true-column-oriented-dbms} + +In a true column-oriented DBMS, no extra data is stored with the values. Among other things, this means that constant-length values must be supported, to avoid storing their length “number” next to the values. As an example, a billion UInt8-type values should consume around 1 GB uncompressed, or this strongly affects the CPU use. It is essential to store data compactly (without any “garbage”) even when uncompressed, since the speed of decompression (CPU usage) depends mainly on the volume of uncompressed data. + +It is worth noting because there are systems that can store values of different columns separately, but that can’t effectively process analytical queries due to their optimization for other scenarios. Examples are HBase, BigTable, Cassandra, and HyperTable. In these systems, you would get throughput around a hundred thousand rows per second, but not hundreds of millions of rows per second. + +It’s also worth noting that ClickHouse is a database management system, not a single database. ClickHouse allows creating tables and databases in runtime, loading data, and running queries without reconfiguring and restarting the server. + +## Data Compression {#data-compression} + +Some column-oriented DBMSs (InfiniDB CE and MonetDB) do not use data compression. However, data compression does play a key role in achieving excellent performance. + +## Disk Storage of Data {#disk-storage-of-data} + +Keeping data physically sorted by primary key makes it possible to extract data for its specific values or value ranges with low latency, less than a few dozen milliseconds. Some column-oriented DBMSs (such as SAP HANA and Google PowerDrill) can only work in RAM. This approach encourages the allocation of a larger hardware budget than is necessary for real-time analysis. ClickHouse is designed to work on regular hard drives, which means the cost per GB of data storage is low, but SSD and additional RAM are also fully used if available. + +## Parallel Processing on Multiple Cores {#parallel-processing-on-multiple-cores} + +Large queries are parallelized naturally, taking all the necessary resources available on the current server. + +## Distributed Processing on Multiple Servers {#distributed-processing-on-multiple-servers} + +Almost none of the columnar DBMSs mentioned above have support for distributed query processing. +In ClickHouse, data can reside on different shards. Each shard can be a group of replicas used for fault tolerance. All shards are used to run a query in parallel, transparently for the user. + +## SQL Support {#sql-support} + +ClickHouse supports a declarative query language based on SQL that is identical to the SQL standard in many cases. +Supported queries include GROUP BY, ORDER BY, subqueries in FROM, IN, and JOIN clauses, and scalar subqueries. +Dependent subqueries and window functions are not supported. + +## Vector Engine {#vector-engine} + +Data is not only stored by columns but is processed by vectors (parts of columns), which allows achieving high CPU efficiency. + +## Real-time Data Updates {#real-time-data-updates} + +ClickHouse supports tables with a primary key. To quickly perform queries on the range of the primary key, the data is sorted incrementally using the merge tree. Due to this, data can continually be added to the table. No locks are taken when new data is ingested. + +## Index {#index} + +Having a data physically sorted by primary key makes it possible to extract data for its specific values or value ranges with low latency, less than a few dozen milliseconds. + +## Suitable for Online Queries {#suitable-for-online-queries} + +Low latency means that queries can be processed without delay and without trying to prepare an answer in advance, right at the same moment while the user interface page is loading. In other words, online. + +## Support for Approximated Calculations {#support-for-approximated-calculations} + +ClickHouse provides various ways to trade accuracy for performance: + +1. Aggregate functions for approximated calculation of the number of distinct values, medians, and quantiles. +2. Running a query based on a part (sample) of data and getting an approximated result. In this case, proportionally less data is retrieved from the disk. +3. Running an aggregation for a limited number of random keys, instead of for all keys. Under certain conditions for key distribution in the data, this provides a reasonably accurate result while using fewer resources. + +## Data Replication and Data Integrity Support {#data-replication-and-data-integrity-support} + +ClickHouse uses asynchronous multi-master replication. After being written to any available replica, all the remaining replicas retrieve their copy in the background. The system maintains identical data on different replicas. Recovery after most failures is performed automatically, or semi-automatically in complex cases. + +For more information, see the section [Data replication](../engines/table-engines/mergetree-family/replication.md). + +## Features that Can Be Considered Disadvantages {#clickhouse-features-that-can-be-considered-disadvantages} + +1. No full-fledged transactions. +2. Lack of ability to modify or delete already inserted data with high rate and low latency. There are batch deletes and updates available to clean up or modify data, for example to comply with [GDPR](https://gdpr-info.eu). +3. The sparse index makes ClickHouse not so suitable for point queries retrieving single rows by their keys. + +[Original article](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/en/introduction/distinctive_features.md b/docs/en/introduction/distinctive_features.md deleted file mode 100644 index 1244e80a253..00000000000 --- a/docs/en/introduction/distinctive_features.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -toc_priority: 4 -toc_title: Distinctive Features ---- - -# Distinctive Features of ClickHouse {#distinctive-features-of-clickhouse} - -## True Column-Oriented DBMS {#true-column-oriented-dbms} - -In a true column-oriented DBMS, no extra data is stored with the values. Among other things, this means that constant-length values must be supported, to avoid storing their length “number” next to the values. As an example, a billion UInt8-type values should consume around 1 GB uncompressed, or this strongly affects the CPU use. It is essential to store data compactly (without any “garbage”) even when uncompressed, since the speed of decompression (CPU usage) depends mainly on the volume of uncompressed data. - -It is worth noting because there are systems that can store values of different columns separately, but that can’t effectively process analytical queries due to their optimization for other scenarios. Examples are HBase, BigTable, Cassandra, and HyperTable. In these systems, you would get throughput around a hundred thousand rows per second, but not hundreds of millions of rows per second. - -It’s also worth noting that ClickHouse is a database management system, not a single database. ClickHouse allows creating tables and databases in runtime, loading data, and running queries without reconfiguring and restarting the server. - -## Data Compression {#data-compression} - -Some column-oriented DBMSs (InfiniDB CE and MonetDB) do not use data compression. However, data compression does play a key role in achieving excellent performance. - -## Disk Storage of Data {#disk-storage-of-data} - -Keeping data physically sorted by primary key makes it possible to extract data for its specific values or value ranges with low latency, less than a few dozen milliseconds. Some column-oriented DBMSs (such as SAP HANA and Google PowerDrill) can only work in RAM. This approach encourages the allocation of a larger hardware budget than is necessary for real-time analysis. ClickHouse is designed to work on regular hard drives, which means the cost per GB of data storage is low, but SSD and additional RAM are also fully used if available. - -## Parallel Processing on Multiple Cores {#parallel-processing-on-multiple-cores} - -Large queries are parallelized naturally, taking all the necessary resources available on the current server. - -## Distributed Processing on Multiple Servers {#distributed-processing-on-multiple-servers} - -Almost none of the columnar DBMSs mentioned above have support for distributed query processing. -In ClickHouse, data can reside on different shards. Each shard can be a group of replicas used for fault tolerance. All shards are used to run a query in parallel, transparently for the user. - -## SQL Support {#sql-support} - -ClickHouse supports a declarative query language based on SQL that is identical to the SQL standard in many cases. -Supported queries include GROUP BY, ORDER BY, subqueries in FROM, IN, and JOIN clauses, and scalar subqueries. -Dependent subqueries and window functions are not supported. - -## Vector Engine {#vector-engine} - -Data is not only stored by columns but is processed by vectors (parts of columns), which allows achieving high CPU efficiency. - -## Real-time Data Updates {#real-time-data-updates} - -ClickHouse supports tables with a primary key. To quickly perform queries on the range of the primary key, the data is sorted incrementally using the merge tree. Due to this, data can continually be added to the table. No locks are taken when new data is ingested. - -## Index {#index} - -Having a data physically sorted by primary key makes it possible to extract data for its specific values or value ranges with low latency, less than a few dozen milliseconds. - -## Suitable for Online Queries {#suitable-for-online-queries} - -Low latency means that queries can be processed without delay and without trying to prepare an answer in advance, right at the same moment while the user interface page is loading. In other words, online. - -## Support for Approximated Calculations {#support-for-approximated-calculations} - -ClickHouse provides various ways to trade accuracy for performance: - -1. Aggregate functions for approximated calculation of the number of distinct values, medians, and quantiles. -2. Running a query based on a part (sample) of data and getting an approximated result. In this case, proportionally less data is retrieved from the disk. -3. Running an aggregation for a limited number of random keys, instead of for all keys. Under certain conditions for key distribution in the data, this provides a reasonably accurate result while using fewer resources. - -## Data Replication and Data Integrity Support {#data-replication-and-data-integrity-support} - -ClickHouse uses asynchronous multi-master replication. After being written to any available replica, all the remaining replicas retrieve their copy in the background. The system maintains identical data on different replicas. Recovery after most failures is performed automatically, or semi-automatically in complex cases. - -For more information, see the section [Data replication](../engines/table_engines/mergetree_family/replication.md). - -## Features that Can Be Considered Disadvantages {#clickhouse-features-that-can-be-considered-disadvantages} - -1. No full-fledged transactions. -2. Lack of ability to modify or delete already inserted data with high rate and low latency. There are batch deletes and updates available to clean up or modify data, for example to comply with [GDPR](https://gdpr-info.eu). -3. The sparse index makes ClickHouse not so suitable for point queries retrieving single rows by their keys. - -[Original article](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/en/introduction/performance.md b/docs/en/introduction/performance.md index 73aacc293b1..d2780aedccb 100644 --- a/docs/en/introduction/performance.md +++ b/docs/en/introduction/performance.md @@ -27,4 +27,4 @@ Under the same conditions, ClickHouse can handle several hundred queries per sec We recommend inserting data in packets of at least 1000 rows, or no more than a single request per second. When inserting to a MergeTree table from a tab-separated dump, the insertion speed can be from 50 to 200 MB/s. If the inserted rows are around 1 Kb in size, the speed will be from 50,000 to 200,000 rows per second. If the rows are small, the performance can be higher in rows per second (on Banner System data -`>` 500,000 rows per second; on Graphite data -`>` 1,000,000 rows per second). To improve performance, you can make multiple INSERT queries in parallel, which scales linearly. -[Original article](https://clickhouse.tech/docs/en/introduction/performance/) +{## [Original article](https://clickhouse.tech/docs/en/introduction/performance/) ##} diff --git a/docs/en/operations/access-rights.md b/docs/en/operations/access-rights.md new file mode 100644 index 00000000000..001afd29fcb --- /dev/null +++ b/docs/en/operations/access-rights.md @@ -0,0 +1,147 @@ +--- +toc_priority: 48 +toc_title: Access Control and Account Management +--- + +# Access Control and Account Management {#access-control} + +ClickHouse supports access control management based on [RBAC](https://en.wikipedia.org/wiki/Role-based_access_control) approach. + +ClickHouse access entities: +- [User account](#user-account-management) +- [Role](#role-management) +- [Row Policy](#row-policy-management) +- [Settings Profile](#settings-profiles-management) +- [Quota](#quotas-management) + +You can configure access entities using: + +- SQL-driven workflow. + + You need to [enable](#enabling-access-control) this functionality. + +- Server [configuration files](configuration-files.md) `users.xml` and `config.xml`. + +We recommend using SQL-driven workflow. Both of the configuration methods work simultaneously, so if you use the server configuration files for managing accounts and access rights, you can smoothly switch to SQL-driven workflow. + +!!! note "Warning" + You can't manage the same access entity by both configuration methods simultaneously. + + +## Usage {#access-control-usage} + +By default, the ClickHouse server provides the `default` user account which is not allowed using SQL-driven access control and account management but has all the rights and permissions. The `default` user account is used in any cases when the username is not defined, for example, at login from client or in distributed queries. In distributed query processing a default user account is used, if the configuration of the server or cluster doesn’t specify the [user and password](../engines/table-engines/special/distributed.md) properties. + +If you just started using ClickHouse, consider the following scenario: + +1. [Enable](#enabling-access-control) SQL-driven access control and account management for the `default` user. +2. Log in to the `default` user account and create all the required users. Don't forget to create an administrator account (`GRANT ALL ON *.* WITH GRANT OPTION TO admin_user_account`). +3. [Restrict permissions](settings/permissions-for-queries.md#permissions_for_queries) for the `default` user and disable SQL-driven access control and account management for it. + +### Properties of Current Solution {#access-control-properties} + +- You can grant permissions for databases and tables even if they do not exist. +- If a table was deleted, all the privileges that correspond to this table are not revoked. This means that even if you create a new table with the same name later, all the privileges remain valid. To revoke privileges corresponding to the deleted table, you need to execute, for example, the `REVOKE ALL PRIVILEGES ON db.table FROM ALL` query. +- There are no lifetime settings for privileges. + +## User account {#user-account-management} + +A user account is an access entity that allows to authorize someone in ClickHouse. A user account contains: + +- Identification information. +- [Privileges](../sql-reference/statements/grant.md#grant-privileges) that define a scope of queries the user can execute. +- Hosts allowed to connect to the ClickHouse server. +- Assigned and default roles. +- Settings with their constraints applied by default at user login. +- Assigned settings profiles. + +Privileges can be granted to a user account by the [GRANT](../sql-reference/statements/grant.md) query or by assigning [roles](#role-management). To revoke privileges from a user, ClickHouse provides the [REVOKE](../sql-reference/statements/revoke.md) query. To list privileges for a user, use the [SHOW GRANTS](../sql-reference/statements/show.md#show-grants-statement) statement. + +Management queries: + +- [CREATE USER](../sql-reference/statements/create.md#create-user-statement) +- [ALTER USER](../sql-reference/statements/alter.md#alter-user-statement) +- [DROP USER](../sql-reference/statements/misc.md#drop-user-statement) +- [SHOW CREATE USER](../sql-reference/statements/show.md#show-create-user-statement) + +### Settings Applying {#access-control-settings-applying} + +Settings can be configured differently: for a user account, in its granted roles and in settings profiles. At user login, if a setting is configured for different access entities, the value and constraints of this setting are applied as follows (from higher to lower priority): + +1. User account settings. +2. The settings of default roles of the user account. If a setting is configured in some roles, then order of the setting application is undefined. +3. The settings from settings profiles assigned to a user or to its default roles. If a setting is configured in some profiles, then order of setting application is undefined. +4. Settings applied to all the server by default or from the [default profile](server-configuration-parameters/settings.md#default-profile). + + +## Role {#role-management} + +Role is a container for access entities that can be granted to a user account. + +Role contains: + +- [Privileges](../sql-reference/statements/grant.md#grant-privileges) +- Settings and constraints +- List of assigned roles + +Management queries: + +- [CREATE ROLE](../sql-reference/statements/create.md#create-role-statement) +- [ALTER ROLE](../sql-reference/statements/alter.md#alter-role-statement) +- [DROP ROLE](../sql-reference/statements/misc.md#drop-role-statement) +- [SET ROLE](../sql-reference/statements/misc.md#set-role-statement) +- [SET DEFAULT ROLE](../sql-reference/statements/misc.md#set-default-role-statement) +- [SHOW CREATE ROLE](../sql-reference/statements/show.md#show-create-role-statement) + +Privileges can be granted to a role by the [GRANT](../sql-reference/statements/grant.md) query. To revoke privileges from a role ClickHouse provides the [REVOKE](../sql-reference/statements/revoke.md) query. + +## Row Policy {#row-policy-management} + +Row policy is a filter that defines which of the rows are available to a user or a role. Row policy contains filters for one particular table, as well as a list of roles and/or users which should use this row policy. + +Management queries: + +- [CREATE ROW POLICY](../sql-reference/statements/create.md#create-row-policy-statement) +- [ALTER ROW POLICY](../sql-reference/statements/alter.md#alter-row-policy-statement) +- [DROP ROW POLICY](../sql-reference/statements/misc.md#drop-row-policy-statement) +- [SHOW CREATE ROW POLICY](../sql-reference/statements/show.md#show-create-row-policy-statement) + + +## Settings Profile {#settings-profiles-management} + +Settings profile is a collection of [settings](settings/index.md). Settings profile contains settings and constraints, as well as a list of roles and/or users to which this profile is applied. + +Management queries: + +- [CREATE SETTINGS PROFILE](../sql-reference/statements/create.md#create-settings-profile-statement) +- [ALTER SETTINGS PROFILE](../sql-reference/statements/alter.md#alter-settings-profile-statement) +- [DROP SETTINGS PROFILE](../sql-reference/statements/misc.md#drop-settings-profile-statement) +- [SHOW CREATE SETTINGS PROFILE](../sql-reference/statements/show.md#show-create-settings-profile-statement) + + +## Quota {#quotas-management} + +Quota limits resource usage. See [Quotas](quotas.md). + +Quota contains a set of limits for some durations, as well as a list of roles and/or users which should use this quota. + +Management queries: + +- [CREATE QUOTA](../sql-reference/statements/create.md#create-quota-statement) +- [ALTER QUOTA](../sql-reference/statements/alter.md#alter-quota-statement) +- [DROP QUOTA](../sql-reference/statements/misc.md#drop-quota-statement) +- [SHOW CREATE QUOTA](../sql-reference/statements/show.md#show-create-quota-statement) + + +## Enabling SQL-driven Access Control and Account Management {#enabling-access-control} + +- Setup a directory for configurations storage. + + ClickHouse stores access entity configurations in the folder set in the [access_control_path](server-configuration-parameters/settings.md#access_control_path) server configuration parameter. + +- Enable SQL-driven access control and account management for at least one user account. + + By default, SQL-driven access control and account management is disabled for all users. You need to configure at least one user in the `users.xml` configuration file and set the value of the [access_management](settings/settings-users.md#access_management-user-setting) setting to 1. + + +[Original article](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/en/operations/access_rights.md b/docs/en/operations/access_rights.md deleted file mode 100644 index fcef4995c4b..00000000000 --- a/docs/en/operations/access_rights.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -toc_priority: 48 -toc_title: Access Rights ---- - -# Access Rights {#access-rights} - -Users and access rights are set up in the user config. This is usually `users.xml`. - -Users are recorded in the `users` section. Here is a fragment of the `users.xml` file: - -``` xml - - - - - - - - - - - - default - - - default - - - - - - - web - default - - test - - - test - - - -``` - -You can see a declaration from two users: `default`and`web`. We added the `web` user separately. - -The `default` user is chosen in cases when the username is not passed. The `default` user is also used for distributed query processing, if the configuration of the server or cluster doesn’t specify the `user` and `password` (see the section on the [Distributed](../engines/table_engines/special/distributed.md) engine). - -The user that is used for exchanging information between servers combined in a cluster must not have substantial restrictions or quotas – otherwise, distributed queries will fail. - -The password is specified in clear text (not recommended) or in SHA-256. The hash isn’t salted. In this regard, you should not consider these passwords as providing security against potential malicious attacks. Rather, they are necessary for protection from employees. - -A list of networks is specified that access is allowed from. In this example, the list of networks for both users is loaded from a separate file (`/etc/metrika.xml`) containing the `networks` substitution. Here is a fragment of it: - -``` xml - - ... - - ::/64 - 203.0.113.0/24 - 2001:DB8::/32 - ... - - -``` - -You could define this list of networks directly in `users.xml`, or in a file in the `users.d` directory (for more information, see the section “[Configuration files](configuration_files.md#configuration_files)”). - -The config includes comments explaining how to open access from everywhere. - -For use in production, only specify `ip` elements (IP addresses and their masks), since using `host` and `hoost_regexp` might cause extra latency. - -Next the user settings profile is specified (see the section “[Settings profiles](settings/settings_profiles.md)”. You can specify the default profile, `default'`. The profile can have any name. You can specify the same profile for different users. The most important thing you can write in the settings profile is `readonly=1`, which ensures read-only access. Then specify the quota to be used (see the section “[Quotas](quotas.md#quotas)”). You can specify the default quota: `default`. It is set in the config by default to only count resource usage, without restricting it. The quota can have any name. You can specify the same quota for different users – in this case, resource usage is calculated for each user individually. - -In the optional `` section, you can also specify a list of databases that the user can access. By default, all databases are available to the user. You can specify the `default` database. In this case, the user will receive access to the database by default. - -In the optional `` section, you can also specify a list of dictionaries that the user can access. By default, all dictionaries are available to the user. - -Access to the `system` database is always allowed (since this database is used for processing queries). - -The user can get a list of all databases and tables in them by using `SHOW` queries or system tables, even if access to individual databases isn’t allowed. - -Database access is not related to the [readonly](settings/permissions_for_queries.md#settings_readonly) setting. You can’t grant full access to one database and `readonly` access to another one. - -[Original article](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/en/operations/backup.md b/docs/en/operations/backup.md index 27418dff884..72316284e3b 100644 --- a/docs/en/operations/backup.md +++ b/docs/en/operations/backup.md @@ -5,7 +5,7 @@ toc_title: Data Backup # Data Backup {#data-backup} -While [replication](../engines/table_engines/mergetree_family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [you can’t just drop tables with a MergeTree-like engine containing more than 50 Gb of data](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). However, these safeguards don’t cover all possible cases and can be circumvented. +While [replication](../engines/table-engines/mergetree-family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [you can’t just drop tables with a MergeTree-like engine containing more than 50 Gb of data](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). However, these safeguards don’t cover all possible cases and can be circumvented. In order to effectively mitigate possible human errors, you should carefully prepare a strategy for backing up and restoring your data **in advance**. @@ -20,7 +20,7 @@ Often data that is ingested into ClickHouse is delivered through some sort of pe ## Filesystem Snapshots {#filesystem-snapshots} -Some local filesystems provide snapshot functionality (for example, [ZFS](https://en.wikipedia.org/wiki/ZFS)), but they might not be the best choice for serving live queries. A possible solution is to create additional replicas with this kind of filesystem and exclude them from the [Distributed](../engines/table_engines/special/distributed.md) tables that are used for `SELECT` queries. Snapshots on such replicas will be out of reach of any queries that modify data. As a bonus, these replicas might have special hardware configurations with more disks attached per server, which would be cost-effective. +Some local filesystems provide snapshot functionality (for example, [ZFS](https://en.wikipedia.org/wiki/ZFS)), but they might not be the best choice for serving live queries. A possible solution is to create additional replicas with this kind of filesystem and exclude them from the [Distributed](../engines/table-engines/special/distributed.md) tables that are used for `SELECT` queries. Snapshots on such replicas will be out of reach of any queries that modify data. As a bonus, these replicas might have special hardware configurations with more disks attached per server, which would be cost-effective. ## clickhouse-copier {#clickhouse-copier} @@ -31,8 +31,9 @@ For smaller volumes of data, a simple `INSERT INTO ... SELECT ...` to remote tab ## Manipulations with Parts {#manipulations-with-parts} ClickHouse allows using the `ALTER TABLE ... FREEZE PARTITION ...` query to create a local copy of table partitions. This is implemented using hardlinks to the `/var/lib/clickhouse/shadow/` folder, so it usually does not consume extra disk space for old data. The created copies of files are not handled by ClickHouse server, so you can just leave them there: you will have a simple backup that doesn’t require any additional external system, but it will still be prone to hardware issues. For this reason, it’s better to remotely copy them to another location and then remove the local copies. Distributed filesystems and object stores are still a good options for this, but normal attached file servers with a large enough capacity might work as well (in this case the transfer will occur via the network filesystem or maybe [rsync](https://en.wikipedia.org/wiki/Rsync)). +Data can be restored from backup using the `ALTER TABLE ... ATTACH PARTITION ...` -For more information about queries related to partition manipulations, see the [ALTER documentation](../sql_reference/statements/alter.md#alter_manipulations-with-partitions). +For more information about queries related to partition manipulations, see the [ALTER documentation](../sql-reference/statements/alter.md#alter_manipulations-with-partitions). A third-party tool is available to automate this approach: [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup). diff --git a/docs/en/operations/configuration-files.md b/docs/en/operations/configuration-files.md new file mode 100644 index 00000000000..f574240ea39 --- /dev/null +++ b/docs/en/operations/configuration-files.md @@ -0,0 +1,64 @@ +--- +toc_priority: 50 +toc_title: Configuration Files +--- + +# Configuration Files {#configuration_files} + +ClickHouse supports multi-file configuration management. The main server configuration file is `/etc/clickhouse-server/config.xml`. Other files must be in the `/etc/clickhouse-server/config.d` directory. + +All the configuration files should be in XML format. Also, they should have the same root element, usually ``. + +## Override + +Some settings specified in the main configuration file can be overridden in other configuration files: + +- The `replace` or `remove` attributes can be specified for the elements of these configuration files. +- If neither is specified, it combines the contents of elements recursively, replacing values of duplicate children. +- If `replace` is specified, it replaces the entire element with the specified one. +- If `remove` is specified, it deletes the element. + +## Substitution + +The config can also define "substitutions". If an element has the `incl` attribute, the corresponding substitution from the file will be used as the value. By default, the path to the file with substitutions is `/etc/metrika.xml`. This can be changed in the [include\_from](server-configuration-parameters/settings.md#server_configuration_parameters-include_from) element in the server config. The substitution values are specified in `/yandex/substitution_name` elements in this file. If a substitution specified in `incl` does not exist, it is recorded in the log. To prevent ClickHouse from logging missing substitutions, specify the `optional="true"` attribute (for example, settings for [macros](server-configuration-parameters/settings.md)). + +Substitutions can also be performed from ZooKeeper. To do this, specify the attribute `from_zk = "/path/to/node"`. The element value is replaced with the contents of the node at `/path/to/node` in ZooKeeper. You can also put an entire XML subtree on the ZooKeeper node and it will be fully inserted into the source element. + +## User Settings + +The `config.xml` file can specify a separate config with user settings, profiles, and quotas. The relative path to this config is set in the `users_config` element. By default, it is `users.xml`. If `users_config` is omitted, the user settings, profiles, and quotas are specified directly in `config.xml`. + +Users configuration can be splitted into separate files similar to `config.xml` and `config.d/`. +Directory name is defined as `users_config` setting without `.xml` postfix concatenated with `.d`. +Directory `users.d` is used by default, as `users_config` defaults to `users.xml`. + +## Example + +For example, you can have separate config file for each user like this: + +``` bash +$ cat /etc/clickhouse-server/users.d/alice.xml +``` + +``` xml + + + + analytics + + ::/0 + + ... + analytics + + + +``` + +## Implementation Details + +For each config file, the server also generates `file-preprocessed.xml` files when starting. These files contain all the completed substitutions and overrides, and they are intended for informational use. If ZooKeeper substitutions were used in the config files but ZooKeeper is not available on the server start, the server loads the configuration from the preprocessed file. + +The server tracks changes in config files, as well as files and ZooKeeper nodes that were used when performing substitutions and overrides, and reloads the settings for users and clusters on the fly. This means that you can modify the cluster, users, and their settings without restarting the server. + +[Original article](https://clickhouse.tech/docs/en/operations/configuration-files/) diff --git a/docs/en/operations/configuration_files.md b/docs/en/operations/configuration_files.md deleted file mode 100644 index 2d6a1a163f5..00000000000 --- a/docs/en/operations/configuration_files.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -toc_priority: 50 -toc_title: Configuration Files ---- - -# Configuration Files {#configuration_files} - -ClickHouse supports multi-file configuration management. The main server configuration file is `/etc/clickhouse-server/config.xml`. Other files must be in the `/etc/clickhouse-server/config.d` directory. - -!!! note "Note" - All the configuration files should be in XML format. Also, they should have the same root element, usually ``. - -Some settings specified in the main configuration file can be overridden in other configuration files. The `replace` or `remove` attributes can be specified for the elements of these configuration files. - -If neither is specified, it combines the contents of elements recursively, replacing values of duplicate children. - -If `replace` is specified, it replaces the entire element with the specified one. - -If `remove` is specified, it deletes the element. - -The config can also define “substitutions”. If an element has the `incl` attribute, the corresponding substitution from the file will be used as the value. By default, the path to the file with substitutions is `/etc/metrika.xml`. This can be changed in the [include\_from](server_configuration_parameters/settings.md#server_configuration_parameters-include_from) element in the server config. The substitution values are specified in `/yandex/substitution_name` elements in this file. If a substitution specified in `incl` does not exist, it is recorded in the log. To prevent ClickHouse from logging missing substitutions, specify the `optional="true"` attribute (for example, settings for [macros](server_configuration_parameters/settings.md)). - -Substitutions can also be performed from ZooKeeper. To do this, specify the attribute `from_zk = "/path/to/node"`. The element value is replaced with the contents of the node at `/path/to/node` in ZooKeeper. You can also put an entire XML subtree on the ZooKeeper node and it will be fully inserted into the source element. - -The `config.xml` file can specify a separate config with user settings, profiles, and quotas. The relative path to this config is set in the `users_config` element. By default, it is `users.xml`. If `users_config` is omitted, the user settings, profiles, and quotas are specified directly in `config.xml`. - -Users configuration can be splitted into separate files similar to `config.xml` and `config.d/`. -Directory name is defined as `users_config` setting without `.xml` postfix concatenated with `.d`. -Directory `users.d` is used by default, as `users_config` defaults to `users.xml`. -For example, you can have separate config file for each user like this: - -``` bash -$ cat /etc/clickhouse-server/users.d/alice.xml -``` - -``` xml - - - - analytics - - ::/0 - - ... - analytics - - - -``` - -For each config file, the server also generates `file-preprocessed.xml` files when starting. These files contain all the completed substitutions and overrides, and they are intended for informational use. If ZooKeeper substitutions were used in the config files but ZooKeeper is not available on the server start, the server loads the configuration from the preprocessed file. - -The server tracks changes in config files, as well as files and ZooKeeper nodes that were used when performing substitutions and overrides, and reloads the settings for users and clusters on the fly. This means that you can modify the cluster, users, and their settings without restarting the server. - -[Original article](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/en/operations/index.md b/docs/en/operations/index.md index a23c6f3d16a..7c0518610fb 100644 --- a/docs/en/operations/index.md +++ b/docs/en/operations/index.md @@ -13,14 +13,14 @@ ClickHouse operations manual consists of the following major sections: - [Troubleshooting](troubleshooting.md) - [Usage Recommendations](tips.md) - [Update Procedure](update.md) -- [Access Rights](access_rights.md) +- [Access Rights](access-rights.md) - [Data Backup](backup.md) -- [Configuration Files](configuration_files.md) +- [Configuration Files](configuration-files.md) - [Quotas](quotas.md) -- [System Tables](system_tables.md) -- [Server Configuration Parameters](server_configuration_parameters/index.md) -- [How To Test Your Hardware With ClickHouse](performance_test.md) +- [System Tables](system-tables.md) +- [Server Configuration Parameters](server-configuration-parameters/index.md) +- [How To Test Your Hardware With ClickHouse](performance-test.md) - [Settings](settings/index.md) - [Utilities](utilities/index.md) -[Original article](https://clickhouse.tech/docs/en/operations/) +{## [Original article](https://clickhouse.tech/docs/en/operations/) ##} diff --git a/docs/en/operations/monitoring.md b/docs/en/operations/monitoring.md index dee1255569b..25e29197646 100644 --- a/docs/en/operations/monitoring.md +++ b/docs/en/operations/monitoring.md @@ -26,18 +26,18 @@ It is highly recommended to set up monitoring for: ClickHouse server has embedded instruments for self-state monitoring. -To track server events use server logs. See the [logger](server_configuration_parameters/settings.md#server_configuration_parameters-logger) section of the configuration file. +To track server events use server logs. See the [logger](server-configuration-parameters/settings.md#server_configuration_parameters-logger) section of the configuration file. ClickHouse collects: - Different metrics of how the server uses computational resources. - Common statistics on query processing. -You can find metrics in the [system.metrics](../operations/system_tables.md#system_tables-metrics), [system.events](../operations/system_tables.md#system_tables-events), and [system.asynchronous\_metrics](../operations/system_tables.md#system_tables-asynchronous_metrics) tables. +You can find metrics in the [system.metrics](../operations/system-tables.md#system_tables-metrics), [system.events](../operations/system-tables.md#system_tables-events), and [system.asynchronous\_metrics](../operations/system-tables.md#system_tables-asynchronous_metrics) tables. -You can configure ClickHouse to export metrics to [Graphite](https://github.com/graphite-project). See the [Graphite section](server_configuration_parameters/settings.md#server_configuration_parameters-graphite) in the ClickHouse server configuration file. Before configuring export of metrics, you should set up Graphite by following their official [guide](https://graphite.readthedocs.io/en/latest/install.html). +You can configure ClickHouse to export metrics to [Graphite](https://github.com/graphite-project). See the [Graphite section](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) in the ClickHouse server configuration file. Before configuring export of metrics, you should set up Graphite by following their official [guide](https://graphite.readthedocs.io/en/latest/install.html). -You can configure ClickHouse to export metrics to [Prometheus](https://prometheus.io). See the [Prometheus section](server_configuration_parameters/settings.md#server_configuration_parameters-prometheus) in the ClickHouse server configuration file. Before configuring export of metrics, you should set up Prometheus by following their official [guide](https://prometheus.io/docs/prometheus/latest/installation/). +You can configure ClickHouse to export metrics to [Prometheus](https://prometheus.io). See the [Prometheus section](server-configuration-parameters/settings.md#server_configuration_parameters-prometheus) in the ClickHouse server configuration file. Before configuring export of metrics, you should set up Prometheus by following their official [guide](https://prometheus.io/docs/prometheus/latest/installation/). Additionally, you can monitor server availability through the HTTP API. Send the `HTTP GET` request to `/ping`. If the server is available, it responds with `200 OK`. diff --git a/docs/en/operations/optimizing-performance/index.md b/docs/en/operations/optimizing-performance/index.md new file mode 100644 index 00000000000..6e6cef109c1 --- /dev/null +++ b/docs/en/operations/optimizing-performance/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Optimizing Performance +toc_priority: 52 +--- + + diff --git a/docs/en/operations/optimizing-performance/sampling-query-profiler.md b/docs/en/operations/optimizing-performance/sampling-query-profiler.md new file mode 100644 index 00000000000..3e9365c281a --- /dev/null +++ b/docs/en/operations/optimizing-performance/sampling-query-profiler.md @@ -0,0 +1,62 @@ +--- +toc_priority: 54 +toc_title: Query Profiling +--- + +# Sampling Query Profiler {#sampling-query-profiler} + +ClickHouse runs sampling profiler that allows analyzing query execution. Using profiler you can find source code routines that used the most frequently during query execution. You can trace CPU time and wall-clock time spent including idle time. + +To use profiler: + +- Setup the [trace\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) section of the server configuration. + + This section configures the [trace\_log](../../operations/system-tables.md#system_tables-trace_log) system table containing the results of the profiler functioning. It is configured by default. Remember that data in this table is valid only for a running server. After the server restart, ClickHouse doesn’t clean up the table and all the stored virtual memory address may become invalid. + +- Setup the [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) or [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) settings. Both settings can be used simultaneously. + + These settings allow you to configure profiler timers. As these are the session settings, you can get different sampling frequency for the whole server, individual users or user profiles, for your interactive session, and for each individual query. + +The default sampling frequency is one sample per second and both CPU and real timers are enabled. This frequency allows collecting enough information about ClickHouse cluster. At the same time, working with this frequency, profiler doesn’t affect ClickHouse server’s performance. If you need to profile each individual query try to use higher sampling frequency. + +To analyze the `trace_log` system table: + +- Install the `clickhouse-common-static-dbg` package. See [Install from DEB Packages](../../getting-started/install.md#install-from-deb-packages). + +- Allow introspection functions by the [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) setting. + + For security reasons, introspection functions are disabled by default. + +- Use the `addressToLine`, `addressToSymbol` and `demangle` [introspection functions](../../sql-reference/functions/introspection.md) to get function names and their positions in ClickHouse code. To get a profile for some query, you need to aggregate data from the `trace_log` table. You can aggregate data by individual functions or by the whole stack traces. + +If you need to visualize `trace_log` info, try [flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) and [speedscope](https://github.com/laplab/clickhouse-speedscope). + +## Example {#example} + +In this example we: + +- Filtering `trace_log` data by a query identifier and the current date. + +- Aggregating by stack trace. + +- Using introspection functions, we will get a report of: + + - Names of symbols and corresponding source code functions. + - Source code locations of these functions. + + + +``` sql +SELECT + count(), + arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym +FROM system.trace_log +WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) +GROUP BY trace +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +{% include "examples/sampling_query_profiler_result.txt" %} +``` diff --git a/docs/en/operations/optimizing_performance/index.md b/docs/en/operations/optimizing_performance/index.md deleted file mode 100644 index 4f4cbb66d24..00000000000 --- a/docs/en/operations/optimizing_performance/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Optimizing Performance -toc_priority: 52 ---- - diff --git a/docs/en/operations/optimizing_performance/sampling_query_profiler.md b/docs/en/operations/optimizing_performance/sampling_query_profiler.md deleted file mode 100644 index dbb70c92b2f..00000000000 --- a/docs/en/operations/optimizing_performance/sampling_query_profiler.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -toc_priority: 54 -toc_title: Query Profiling ---- - -# Sampling Query Profiler {#sampling-query-profiler} - -ClickHouse runs sampling profiler that allows analyzing query execution. Using profiler you can find source code routines that used the most frequently during query execution. You can trace CPU time and wall-clock time spent including idle time. - -To use profiler: - -- Setup the [trace\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) section of the server configuration. - - This section configures the [trace\_log](../../operations/system_tables.md#system_tables-trace_log) system table containing the results of the profiler functioning. It is configured by default. Remember that data in this table is valid only for a running server. After the server restart, ClickHouse doesn’t clean up the table and all the stored virtual memory address may become invalid. - -- Setup the [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) or [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) settings. Both settings can be used simultaneously. - - These settings allow you to configure profiler timers. As these are the session settings, you can get different sampling frequency for the whole server, individual users or user profiles, for your interactive session, and for each individual query. - -The default sampling frequency is one sample per second and both CPU and real timers are enabled. This frequency allows collecting enough information about ClickHouse cluster. At the same time, working with this frequency, profiler doesn’t affect ClickHouse server’s performance. If you need to profile each individual query try to use higher sampling frequency. - -To analyze the `trace_log` system table: - -- Install the `clickhouse-common-static-dbg` package. See [Install from DEB Packages](../../getting_started/install.md#install-from-deb-packages). - -- Allow introspection functions by the [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) setting. - - For security reasons, introspection functions are disabled by default. - -- Use the `addressToLine`, `addressToSymbol` and `demangle` [introspection functions](../../sql_reference/functions/introspection.md) to get function names and their positions in ClickHouse code. To get a profile for some query, you need to aggregate data from the `trace_log` table. You can aggregate data by individual functions or by the whole stack traces. - -If you need to visualize `trace_log` info, try [flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) and [speedscope](https://github.com/laplab/clickhouse-speedscope). - -## Example {#example} - -In this example we: - -- Filtering `trace_log` data by a query identifier and the current date. - -- Aggregating by stack trace. - -- Using introspection functions, we will get a report of: - - - Names of symbols and corresponding source code functions. - - Source code locations of these functions. - - - -``` sql -SELECT - count(), - arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym -FROM system.trace_log -WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) -GROUP BY trace -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -{% include "examples/sampling_query_profiler_result.txt" %} -``` diff --git a/docs/en/operations/performance-test.md b/docs/en/operations/performance-test.md new file mode 100644 index 00000000000..a3beccdaab5 --- /dev/null +++ b/docs/en/operations/performance-test.md @@ -0,0 +1,80 @@ +--- +toc_priority: 54 +toc_title: Testing Hardware +--- + +# How to Test Your Hardware with ClickHouse {#how-to-test-your-hardware-with-clickhouse} + +With this instruction you can run basic ClickHouse performance test on any server without installation of ClickHouse packages. + +1. Go to “commits” page: https://github.com/ClickHouse/ClickHouse/commits/master + +2. Click on the first green check mark or red cross with green “ClickHouse Build Check” and click on the “Details” link near “ClickHouse Build Check”. There is no such link in some commits, for example commits with documentation. In this case, choose the nearest commit having this link. + +3. Copy the link to “clickhouse” binary for amd64 or aarch64. + +4. ssh to the server and download it with wget: + + + + # For amd64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse + # For aarch64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse + # Then do: + chmod a+x clickhouse + +5. Download configs: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml + mkdir config.d + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml + +6. Download benchmark files: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh + chmod a+x benchmark-new.sh + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql + +7. Download test data according to the [Yandex.Metrica dataset](../getting-started/example-datasets/metrica.md) instruction (“hits” table containing 100 million rows). + + + + wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz + tar xvf hits_100m_obfuscated_v1.tar.xz -C . + mv hits_100m_obfuscated_v1/* . + +8. Run the server: + + + + ./clickhouse server + +9. Check the data: ssh to the server in another terminal + + + + ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" + 100000000 + +10. Edit the benchmark-new.sh, change `clickhouse-client` to `./clickhouse client` and add `–-max_memory_usage 100000000000` parameter. + + + + mcedit benchmark-new.sh + +11. Run the benchmark: + + + + ./benchmark-new.sh hits_100m_obfuscated + +12. Send the numbers and the info about your hardware configuration to clickhouse-feedback@yandex-team.com + +All the results are published here: https://clickhouse.tech/benchmark/hardware/ diff --git a/docs/en/operations/performance_test.md b/docs/en/operations/performance_test.md deleted file mode 100644 index 9114cbde71a..00000000000 --- a/docs/en/operations/performance_test.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -toc_priority: 54 -toc_title: Testing Hardware ---- - -# How to Test Your Hardware with ClickHouse {#how-to-test-your-hardware-with-clickhouse} - -With this instruction you can run basic ClickHouse performance test on any server without installation of ClickHouse packages. - -1. Go to “commits” page: https://github.com/ClickHouse/ClickHouse/commits/master - -2. Click on the first green check mark or red cross with green “ClickHouse Build Check” and click on the “Details” link near “ClickHouse Build Check”. There is no such link in some commits, for example commits with documentation. In this case, choose the nearest commit having this link. - -3. Copy the link to “clickhouse” binary for amd64 or aarch64. - -4. ssh to the server and download it with wget: - - - - # For amd64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse - # For aarch64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse - # Then do: - chmod a+x clickhouse - -5. Download configs: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml - mkdir config.d - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml - -6. Download benchmark files: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh - chmod a+x benchmark-new.sh - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql - -7. Download test data according to the [Yandex.Metrica dataset](../getting_started/example_datasets/metrica.md) instruction (“hits” table containing 100 million rows). - - - - wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz - tar xvf hits_100m_obfuscated_v1.tar.xz -C . - mv hits_100m_obfuscated_v1/* . - -8. Run the server: - - - - ./clickhouse server - -9. Check the data: ssh to the server in another terminal - - - - ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" - 100000000 - -10. Edit the benchmark-new.sh, change `clickhouse-client` to `./clickhouse client` and add `–-max_memory_usage 100000000000` parameter. - - - - mcedit benchmark-new.sh - -11. Run the benchmark: - - - - ./benchmark-new.sh hits_100m_obfuscated - -12. Send the numbers and the info about your hardware configuration to clickhouse-feedback@yandex-team.com - -All the results are published here: https://clickhouse.tech/benchmark/hardware/ diff --git a/docs/en/operations/requirements.md b/docs/en/operations/requirements.md index ce32a46a3e3..e759849eaaa 100644 --- a/docs/en/operations/requirements.md +++ b/docs/en/operations/requirements.md @@ -22,9 +22,9 @@ The required volume of RAM depends on: - The complexity of queries. - The amount of data that is processed in queries. -To calculate the required volume of RAM, you should estimate the size of temporary data for [GROUP BY](../sql_reference/statements/select.md#select-group-by-clause), [DISTINCT](../sql_reference/statements/select.md#select-distinct), [JOIN](../sql_reference/statements/select.md#select-join) and other operations you use. +To calculate the required volume of RAM, you should estimate the size of temporary data for [GROUP BY](../sql-reference/statements/select/group-by.md#select-group-by-clause), [DISTINCT](../sql-reference/statements/select/distinct.md#select-distinct), [JOIN](../sql-reference/statements/select/join.md#select-join) and other operations you use. -ClickHouse can use external memory for temporary data. See [GROUP BY in External Memory](../sql_reference/statements/select.md#select-group-by-in-external-memory) for details. +ClickHouse can use external memory for temporary data. See [GROUP BY in External Memory](../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory) for details. ## Swap File {#swap-file} @@ -56,4 +56,4 @@ The network bandwidth is critical for processing distributed queries with a larg ClickHouse is developed primarily for the Linux family of operating systems. The recommended Linux distribution is Ubuntu. The `tzdata` package should be installed in the system. -ClickHouse can also work in other operating system families. See details in the [Getting started](../getting_started/index.md) section of the documentation. +ClickHouse can also work in other operating system families. See details in the [Getting started](../getting-started/index.md) section of the documentation. diff --git a/docs/en/operations/server-configuration-parameters/index.md b/docs/en/operations/server-configuration-parameters/index.md new file mode 100644 index 00000000000..0a4d3ac613d --- /dev/null +++ b/docs/en/operations/server-configuration-parameters/index.md @@ -0,0 +1,17 @@ +--- +toc_folder_title: Server Configuration Parameters +toc_priority: 54 +toc_title: Introduction +--- + +# Server Configuration Parameters {#server-settings} + +This section contains descriptions of server settings that cannot be changed at the session or query level. + +These settings are stored in the `config.xml` file on the ClickHouse server. + +Other settings are described in the “[Settings](../settings/index.md#session-settings-intro)” section. + +Before studying the settings, read the [Configuration files](../configuration-files.md#configuration_files) section and note the use of substitutions (the `incl` and `optional` attributes). + +[Original article](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/en/operations/server-configuration-parameters/settings.md b/docs/en/operations/server-configuration-parameters/settings.md new file mode 100644 index 00000000000..b90b432da6c --- /dev/null +++ b/docs/en/operations/server-configuration-parameters/settings.md @@ -0,0 +1,909 @@ +--- +toc_priority: 57 +toc_title: Server Settings +--- + +# Server Settings {#server-settings} + +## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} + +The interval in seconds before reloading built-in dictionaries. + +ClickHouse reloads built-in dictionaries every x seconds. This makes it possible to edit dictionaries “on the fly” without restarting the server. + +Default value: 3600. + +**Example** + +``` xml +3600 +``` + +## compression {#server-settings-compression} + +Data compression settings for [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine tables. + +!!! warning "Warning" + Don’t use it if you have just started using ClickHouse. + +Configuration template: + +``` xml + + + ... + ... + ... + + ... + +``` + +`` fields: + +- `min_part_size` – The minimum size of a data part. +- `min_part_size_ratio` – The ratio of the data part size to the table size. +- `method` – Compression method. Acceptable values: `lz4` or `zstd`. + +You can configure multiple `` sections. + +Actions when conditions are met: + +- If a data part matches a condition set, ClickHouse uses the specified compression method. +- If a data part matches multiple condition sets, ClickHouse uses the first matched condition set. + +If no conditions met for a data part, ClickHouse uses the `lz4` compression. + +**Example** + +``` xml + + + 10000000000 + 0.01 + zstd + + +``` + +## default\_database {#default-database} + +The default database. + +To get a list of databases, use the [SHOW DATABASES](../../sql-reference/statements/show.md#show-databases) query. + +**Example** + +``` xml +default +``` + +## default\_profile {#default-profile} + +Default settings profile. + +Settings profiles are located in the file specified in the parameter `user_config`. + +**Example** + +``` xml +default +``` + +## dictionaries\_config {#server_configuration_parameters-dictionaries_config} + +The path to the config file for external dictionaries. + +Path: + +- Specify the absolute path or the path relative to the server config file. +- The path can contain wildcards \* and ?. + +See also “[External dictionaries](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md)”. + +**Example** + +``` xml +*_dictionary.xml +``` + +## dictionaries\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} + +Lazy loading of dictionaries. + +If `true`, then each dictionary is created on first use. If dictionary creation failed, the function that was using the dictionary throws an exception. + +If `false`, all dictionaries are created when the server starts, and if there is an error, the server shuts down. + +The default is `true`. + +**Example** + +``` xml +true +``` + +## format\_schema\_path {#server_configuration_parameters-format_schema_path} + +The path to the directory with the schemes for the input data, such as schemas for the [CapnProto](../../interfaces/formats.md#capnproto) format. + +**Example** + +``` xml + + format_schemas/ +``` + +## graphite {#server_configuration_parameters-graphite} + +Sending data to [Graphite](https://github.com/graphite-project). + +Settings: + +- host – The Graphite server. +- port – The port on the Graphite server. +- interval – The interval for sending, in seconds. +- timeout – The timeout for sending data, in seconds. +- root\_path – Prefix for keys. +- metrics – Sending data from the [system.metrics](../../operations/system-tables.md#system_tables-metrics) table. +- events – Sending deltas data accumulated for the time period from the [system.events](../../operations/system-tables.md#system_tables-events) table. +- events\_cumulative – Sending cumulative data from the [system.events](../../operations/system-tables.md#system_tables-events) table. +- asynchronous\_metrics – Sending data from the [system.asynchronous\_metrics](../../operations/system-tables.md#system_tables-asynchronous_metrics) table. + +You can configure multiple `` clauses. For instance, you can use this for sending different data at different intervals. + +**Example** + +``` xml + + localhost + 42000 + 0.1 + 60 + one_min + true + true + false + true + +``` + +## graphite\_rollup {#server_configuration_parameters-graphite-rollup} + +Settings for thinning data for Graphite. + +For more details, see [GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md). + +**Example** + +``` xml + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +## http\_port/https\_port {#http-porthttps-port} + +The port for connecting to the server over HTTP(s). + +If `https_port` is specified, [openSSL](#server_configuration_parameters-openssl) must be configured. + +If `http_port` is specified, the OpenSSL configuration is ignored even if it is set. + +**Example** + +``` xml +9999 +``` + +## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} + +The page that is shown by default when you access the ClickHouse HTTP(s) server. +The default value is “Ok.” (with a line feed at the end) + +**Example** + +Opens `https://tabix.io/` when accessing `http://localhost: http_port`. + +``` xml + +
]]> +
+``` + +## include\_from {#server_configuration_parameters-include_from} + +The path to the file with substitutions. + +For more information, see the section “[Configuration files](../configuration-files.md#configuration_files)”. + +**Example** + +``` xml +/etc/metrica.xml +``` + +## interserver\_http\_port {#interserver-http-port} + +Port for exchanging data between ClickHouse servers. + +**Example** + +``` xml +9009 +``` + +## interserver\_http\_host {#interserver-http-host} + +The hostname that can be used by other servers to access this server. + +If omitted, it is defined in the same way as the `hostname-f` command. + +Useful for breaking away from a specific network interface. + +**Example** + +``` xml +example.yandex.ru +``` + +## interserver\_http\_credentials {#server-settings-interserver-http-credentials} + +The username and password used to authenticate during [replication](../../engines/table-engines/mergetree-family/replication.md) with the Replicated\* engines. These credentials are used only for communication between replicas and are unrelated to credentials for ClickHouse clients. The server is checking these credentials for connecting replicas and use the same credentials when connecting to other replicas. So, these credentials should be set the same for all replicas in a cluster. +By default, the authentication is not used. + +This section contains the following parameters: + +- `user` — username. +- `password` — password. + +**Example** + +``` xml + + admin + 222 + +``` + +## keep\_alive\_timeout {#keep-alive-timeout} + +The number of seconds that ClickHouse waits for incoming requests before closing the connection. Defaults to 3 seconds. + +**Example** + +``` xml +3 +``` + +## listen\_host {#server_configuration_parameters-listen_host} + +Restriction on hosts that requests can come from. If you want the server to answer all of them, specify `::`. + +Examples: + +``` xml +::1 +127.0.0.1 +``` + +## logger {#server_configuration_parameters-logger} + +Logging settings. + +Keys: + +- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. +- log – The log file. Contains all the entries according to `level`. +- errorlog – Error log file. +- size – Size of the file. Applies to `log`and`errorlog`. Once the file reaches `size`, ClickHouse archives and renames it, and creates a new log file in its place. +- count – The number of archived log files that ClickHouse stores. + +**Example** + +``` xml + + trace + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 10 + +``` + +Writing to the syslog is also supported. Config example: + +``` xml + + 1 + +
syslog.remote:10514
+ myhost.local + LOG_LOCAL6 + syslog +
+
+``` + +Keys: + +- use\_syslog — Required setting if you want to write to the syslog. +- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. +- hostname — Optional. The name of the host that logs are sent from. +- facility — [The syslog facility keyword](https://en.wikipedia.org/wiki/Syslog#Facility) in uppercase letters with the “LOG\_” prefix: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3`, and so on). + Default value: `LOG_USER` if `address` is specified, `LOG_DAEMON otherwise.` +- format – Message format. Possible values: `bsd` and `syslog.` + +## macros {#macros} + +Parameter substitutions for replicated tables. + +Can be omitted if replicated tables are not used. + +For more information, see the section “[Creating replicated tables](../../engines/table-engines/mergetree-family/replication.md)”. + +**Example** + +``` xml + +``` + +## mark\_cache\_size {#server-mark-cache-size} + +Approximate size (in bytes) of the cache of marks used by table engines of the [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) family. + +The cache is shared for the server and memory is allocated as needed. The cache size must be at least 5368709120. + +**Example** + +``` xml +5368709120 +``` + +## max\_concurrent\_queries {#max-concurrent-queries} + +The maximum number of simultaneously processed requests. + +**Example** + +``` xml +100 +``` + +## max\_connections {#max-connections} + +The maximum number of inbound connections. + +**Example** + +``` xml +4096 +``` + +## max\_open\_files {#max-open-files} + +The maximum number of open files. + +By default: `maximum`. + +We recommend using this option in Mac OS X since the `getrlimit()` function returns an incorrect value. + +**Example** + +``` xml +262144 +``` + +## max\_table\_size\_to\_drop {#max-table-size-to-drop} + +Restriction on deleting tables. + +If the size of a [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) table exceeds `max_table_size_to_drop` (in bytes), you can’t delete it using a DROP query. + +If you still need to delete the table without restarting the ClickHouse server, create the `/flags/force_drop_table` file and run the DROP query. + +Default value: 50 GB. + +The value 0 means that you can delete all tables without any restrictions. + +**Example** + +``` xml +0 +``` + +## merge\_tree {#server_configuration_parameters-merge_tree} + +Fine tuning for tables in the [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). + +For more information, see the MergeTreeSettings.h header file. + +**Example** + +``` xml + + 5 + +``` + +## openSSL {#server_configuration_parameters-openssl} + +SSL client/server configuration. + +Support for SSL is provided by the `libpoco` library. The interface is described in the file [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) + +Keys for server/client settings: + +- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. +- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` contains the certificate. +- caConfig – The path to the file or directory that contains trusted root certificates. +- verificationMode – The method for checking the node’s certificates. Details are in the description of the [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) class. Possible values: `none`, `relaxed`, `strict`, `once`. +- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. +- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| +- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. +- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Acceptable values: `true`, `false`. +- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. This parameter is always recommended since it helps avoid problems both if the server caches the session and if the client requested caching. Default value: `${application.name}`. +- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. +- sessionTimeout – Time for caching the session on the server. +- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. +- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. +- fips – Activates OpenSSL FIPS mode. Supported if the library’s OpenSSL version supports FIPS. +- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. +- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . +- disableProtocols – Protocols that are not allowed to use. +- preferServerCiphers – Preferred server ciphers on the client. + +**Example of settings:** + +``` xml + + + + /etc/clickhouse-server/server.crt + /etc/clickhouse-server/server.key + + /etc/clickhouse-server/dhparam.pem + none + true + true + sslv2,sslv3 + true + + + true + true + sslv2,sslv3 + true + + + + RejectCertificateHandler + + + +``` + +## part\_log {#server_configuration_parameters-part-log} + +Logging events that are associated with [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). For instance, adding or merging data. You can use the log to simulate merge algorithms and compare their characteristics. You can visualize the merge process. + +Queries are logged in the [system.part\_log](../../operations/system-tables.md#system_tables-part-log) table, not in a separate file. You can configure the name of this table in the `table` parameter (see below). + +Use the following parameters to configure logging: + +- `database` – Name of the database. +- `table` – Name of the system table. +- `partition_by` – Sets a [custom partitioning key](../../engines/table-engines/mergetree-family/custom-partitioning-key.md). +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +**Example** + +``` xml + + system + part_log
+ toMonday(event_date) + 7500 +
+``` + +## path {#server_configuration_parameters-path} + +The path to the directory containing data. + +!!! note "Note" + The trailing slash is mandatory. + +**Example** + +``` xml +/var/lib/clickhouse/ +``` + +## prometheus {#server_configuration_parameters-prometheus} + +Exposing metrics data for scraping from [Prometheus](https://prometheus.io). + +Settings: + +- `endpoint` – HTTP endpoint for scraping metrics by prometheus server. Start from ‘/’. +- `port` – Port for `endpoint`. +- `metrics` – Flag that sets to expose metrics from the [system.metrics](../system-tables.md#system_tables-metrics) table. +- `events` – Flag that sets to expose metrics from the [system.events](../system-tables.md#system_tables-events) table. +- `asynchronous_metrics` – Flag that sets to expose current metrics values from the [system.asynchronous\_metrics](../system-tables.md#system_tables-asynchronous_metrics) table. + +**Example** + +``` xml + + /metrics + 8001 + true + true + true + +``` + +## query\_log {#server_configuration_parameters-query-log} + +Setting for logging queries received with the [log\_queries=1](../settings/settings.md) setting. + +Queries are logged in the [system.query\_log](../../operations/system-tables.md#system_tables-query_log) table, not in a separate file. You can change the name of the table in the `table` parameter (see below). + +Use the following parameters to configure logging: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [custom partitioning key](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) for a table. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +If the table doesn’t exist, ClickHouse will create it. If the structure of the query log changed when the ClickHouse server was updated, the table with the old structure is renamed, and a new table is created automatically. + +**Example** + +``` xml + + system + query_log
+ toMonday(event_date) + 7500 +
+``` + +## query\_thread\_log {#server_configuration_parameters-query_thread_log} + +Setting for logging threads of queries received with the [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads) setting. + +Queries are logged in the [system.query\_thread\_log](../../operations/system-tables.md#system_tables-query_thread_log) table, not in a separate file. You can change the name of the table in the `table` parameter (see below). + +Use the following parameters to configure logging: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [custom partitioning key](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) for a system table. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +If the table doesn’t exist, ClickHouse will create it. If the structure of the query thread log changed when the ClickHouse server was updated, the table with the old structure is renamed, and a new table is created automatically. + +**Example** + +``` xml + + system + query_thread_log
+ toMonday(event_date) + 7500 +
+``` + +## trace\_log {#server_configuration_parameters-trace_log} + +Settings for the [trace\_log](../../operations/system-tables.md#system_tables-trace_log) system table operation. + +Parameters: + +- `database` — Database for storing a table. +- `table` — Table name. +- `partition_by` — [Custom partitioning key](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) for a system table. +- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. + +The default server configuration file `config.xml` contains the following settings section: + +``` xml + + system + trace_log
+ toYYYYMM(event_date) + 7500 +
+``` + +## query\_masking\_rules {#query-masking-rules} + +Regexp-based rules, which will be applied to queries as well as all log messages before storing them in server logs, +`system.query_log`, `system.text_log`, `system.processes` table, and in logs sent to the client. That allows preventing +sensitive data leakage from SQL queries (like names, emails, personal +identifiers or credit card numbers) to logs. + +**Example** + +``` xml + + + hide SSN + (^|\D)\d{3}-\d{2}-\d{4}($|\D) + 000-00-0000 + + +``` + +Config fields: +- `name` - name for the rule (optional) +- `regexp` - RE2 compatible regular expression (mandatory) +- `replace` - substitution string for sensitive data (optional, by default - six asterisks) + +The masking rules are applied to the whole query (to prevent leaks of sensitive data from malformed / non-parsable queries). + +`system.events` table have counter `QueryMaskingRulesMatch` which have an overall number of query masking rules matches. + +For distributed queries each server have to be configured separately, otherwise, subqueries passed to other +nodes will be stored without masking. + +## remote\_servers {#server-settings-remote-servers} + +Configuration of clusters used by the [Distributed](../../engines/table-engines/special/distributed.md) table engine and by the `cluster` table function. + +**Example** + +``` xml + +``` + +For the value of the `incl` attribute, see the section “[Configuration files](../configuration-files.md#configuration_files)”. + +**See Also** + +- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) + +## timezone {#server_configuration_parameters-timezone} + +The server’s time zone. + +Specified as an IANA identifier for the UTC timezone or geographic location (for example, Africa/Abidjan). + +The time zone is necessary for conversions between String and DateTime formats when DateTime fields are output to text format (printed on the screen or in a file), and when getting DateTime from a string. Besides, the time zone is used in functions that work with the time and date if they didn’t receive the time zone in the input parameters. + +**Example** + +``` xml +Europe/Moscow +``` + +## tcp\_port {#server_configuration_parameters-tcp_port} + +Port for communicating with clients over the TCP protocol. + +**Example** + +``` xml +9000 +``` + +## tcp_port_secure {#server_configuration_parameters-tcp_port_secure} + +TCP port for secure communication with clients. Use it with [OpenSSL](#server_configuration_parameters-openssl) settings. + +**Possible values** + +Positive integer. + +**Default value** + +``` xml +9440 +``` + +## mysql\_port {#server_configuration_parameters-mysql_port} + +Port for communicating with clients over MySQL protocol. + +**Possible values** + +Positive integer. + +Example + +``` xml +9004 +``` + +## tmp_path {#tmp-path} + +Path to temporary data for processing large queries. + +!!! note "Note" + The trailing slash is mandatory. + +**Example** + +``` xml +/var/lib/clickhouse/tmp/ +``` + +## tmp_policy {#tmp-policy} + +Policy from [storage_configuration](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) to store temporary files. + +If not set, [tmp_path](#tmp-path) is used, otherwise it is ignored. + +!!! note "Note" + - `move_factor` is ignored. + - `keep_free_space_bytes` is ignored. + - `max_data_part_size_bytes` is ignored. + - Уou must have exactly one volume in that policy. + +## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} + +Cache size (in bytes) for uncompressed data used by table engines from the [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). + +There is one shared cache for the server. Memory is allocated on demand. The cache is used if the option [use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) is enabled. + +The uncompressed cache is advantageous for very short queries in individual cases. + +**Example** + +``` xml +8589934592 +``` + +## user\_files\_path {#server_configuration_parameters-user_files_path} + +The directory with user files. Used in the table function [file()](../../sql-reference/table-functions/file.md). + +**Example** + +``` xml +/var/lib/clickhouse/user_files/ +``` + +## users\_config {#users-config} + +Path to the file that contains: + +- User configurations. +- Access rights. +- Settings profiles. +- Quota settings. + +**Example** + +``` xml +users.xml +``` + +## zookeeper {#server-settings_zookeeper} + +Contains settings that allow ClickHouse to interact with a [ZooKeeper](http://zookeeper.apache.org/) cluster. + +ClickHouse uses ZooKeeper for storing metadata of replicas when using replicated tables. If replicated tables are not used, this section of parameters can be omitted. + +This section contains the following parameters: + +- `node` — ZooKeeper endpoint. You can set multiple endpoints. + + For example: + + + +``` xml + + example_host + 2181 + +``` + + The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. + +- `session_timeout` — Maximum timeout for the client session in milliseconds. +- `root` — The [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) that is used as the root for znodes used by the ClickHouse server. Optional. +- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. + +**Example configuration** + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + 30000 + 10000 + + /path/to/zookeeper/node + + user:password + +``` + +**See Also** + +- [Replication](../../engines/table-engines/mergetree-family/replication.md) +- [ZooKeeper Programmer’s Guide](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) + +## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} + +Storage method for data part headers in ZooKeeper. + +This setting only applies to the `MergeTree` family. It can be specified: + +- Globally in the [merge\_tree](#server_configuration_parameters-merge_tree) section of the `config.xml` file. + + ClickHouse uses the setting for all the tables on the server. You can change the setting at any time. Existing tables change their behaviour when the setting changes. + +- For each table. + + When creating a table, specify the corresponding [engine setting](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). The behaviour of an existing table with this setting does not change, even if the global setting changes. + +**Possible values** + +- 0 — Functionality is turned off. +- 1 — Functionality is turned on. + +If `use_minimalistic_part_header_in_zookeeper = 1`, then [replicated](../../engines/table-engines/mergetree-family/replication.md) tables store the headers of the data parts compactly using a single `znode`. If the table contains many columns, this storage method significantly reduces the volume of the data stored in Zookeeper. + +!!! attention "Attention" + After applying `use_minimalistic_part_header_in_zookeeper = 1`, you can’t downgrade the ClickHouse server to a version that doesn’t support this setting. Be careful when upgrading ClickHouse on servers in a cluster. Don’t upgrade all the servers at once. It is safer to test new versions of ClickHouse in a test environment, or on just a few servers of a cluster. + + Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. + +**Default value:** 0. + +## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} + +Disables the internal DNS cache. Recommended for operating ClickHouse in systems +with frequently changing infrastructure such as Kubernetes. + +**Default value:** 0. + +## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} + +The period of updating IP addresses stored in the ClickHouse internal DNS cache (in seconds). +The update is performed asynchronously, in a separate system thread. + +**Default value**: 15. + +**See also** + +- [background_schedule_pool_size](../settings/settings.md#background_schedule_pool_size) + +## access_control_path {#access_control_path} + +Path to a folder where a ClickHouse server stores user and role configurations created by SQL commands. + +Default value: `/var/lib/clickhouse/access/`. + +**See also** + +- [Access Control and Account Management](../access-rights.md#access-control) + +[Original article](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/en/operations/server_configuration_parameters/index.md b/docs/en/operations/server_configuration_parameters/index.md deleted file mode 100644 index 748f4d25345..00000000000 --- a/docs/en/operations/server_configuration_parameters/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -toc_folder_title: Server Configuration Parameters -toc_priority: 54 -toc_title: Introduction ---- - -# Server configuration parameters {#server-settings} - -This section contains descriptions of server settings that cannot be changed at the session or query level. - -These settings are stored in the `config.xml` file on the ClickHouse server. - -Other settings are described in the “[Settings](../settings/index.md#settings)” section. - -Before studying the settings, read the [Configuration files](../configuration_files.md#configuration_files) section and note the use of substitutions (the `incl` and `optional` attributes). - -[Original article](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/en/operations/server_configuration_parameters/settings.md b/docs/en/operations/server_configuration_parameters/settings.md deleted file mode 100644 index 02c00fababf..00000000000 --- a/docs/en/operations/server_configuration_parameters/settings.md +++ /dev/null @@ -1,894 +0,0 @@ ---- -toc_priority: 57 -toc_title: Server Settings ---- - -# Server Settings {#server-settings} - -## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} - -The interval in seconds before reloading built-in dictionaries. - -ClickHouse reloads built-in dictionaries every x seconds. This makes it possible to edit dictionaries “on the fly” without restarting the server. - -Default value: 3600. - -**Example** - -``` xml -3600 -``` - -## compression {#server-settings-compression} - -Data compression settings for [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)-engine tables. - -!!! warning "Warning" - Don’t use it if you have just started using ClickHouse. - -Configuration template: - -``` xml - - - ... - ... - ... - - ... - -``` - -`` fields: - -- `min_part_size` – The minimum size of a data part. -- `min_part_size_ratio` – The ratio of the data part size to the table size. -- `method` – Compression method. Acceptable values: `lz4` or `zstd`. - -You can configure multiple `` sections. - -Actions when conditions are met: - -- If a data part matches a condition set, ClickHouse uses the specified compression method. -- If a data part matches multiple condition sets, ClickHouse uses the first matched condition set. - -If no conditions met for a data part, ClickHouse uses the `lz4` compression. - -**Example** - -``` xml - - - 10000000000 - 0.01 - zstd - - -``` - -## default\_database {#default-database} - -The default database. - -To get a list of databases, use the [SHOW DATABASES](../../sql_reference/statements/show.md#show-databases) query. - -**Example** - -``` xml -default -``` - -## default\_profile {#default-profile} - -Default settings profile. - -Settings profiles are located in the file specified in the parameter `user_config`. - -**Example** - -``` xml -default -``` - -## dictionaries\_config {#server_configuration_parameters-dictionaries_config} - -The path to the config file for external dictionaries. - -Path: - -- Specify the absolute path or the path relative to the server config file. -- The path can contain wildcards \* and ?. - -See also “[External dictionaries](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md)”. - -**Example** - -``` xml -*_dictionary.xml -``` - -## dictionaries\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} - -Lazy loading of dictionaries. - -If `true`, then each dictionary is created on first use. If dictionary creation failed, the function that was using the dictionary throws an exception. - -If `false`, all dictionaries are created when the server starts, and if there is an error, the server shuts down. - -The default is `true`. - -**Example** - -``` xml -true -``` - -## format\_schema\_path {#server_configuration_parameters-format_schema_path} - -The path to the directory with the schemes for the input data, such as schemas for the [CapnProto](../../interfaces/formats.md#capnproto) format. - -**Example** - -``` xml - - format_schemas/ -``` - -## graphite {#server_configuration_parameters-graphite} - -Sending data to [Graphite](https://github.com/graphite-project). - -Settings: - -- host – The Graphite server. -- port – The port on the Graphite server. -- interval – The interval for sending, in seconds. -- timeout – The timeout for sending data, in seconds. -- root\_path – Prefix for keys. -- metrics – Sending data from the [system.metrics](../../operations/system_tables.md#system_tables-metrics) table. -- events – Sending deltas data accumulated for the time period from the [system.events](../../operations/system_tables.md#system_tables-events) table. -- events\_cumulative – Sending cumulative data from the [system.events](../../operations/system_tables.md#system_tables-events) table. -- asynchronous\_metrics – Sending data from the [system.asynchronous\_metrics](../../operations/system_tables.md#system_tables-asynchronous_metrics) table. - -You can configure multiple `` clauses. For instance, you can use this for sending different data at different intervals. - -**Example** - -``` xml - - localhost - 42000 - 0.1 - 60 - one_min - true - true - false - true - -``` - -## graphite\_rollup {#server_configuration_parameters-graphite-rollup} - -Settings for thinning data for Graphite. - -For more details, see [GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md). - -**Example** - -``` xml - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -## http\_port/https\_port {#http-porthttps-port} - -The port for connecting to the server over HTTP(s). - -If `https_port` is specified, [openSSL](#server_configuration_parameters-openssl) must be configured. - -If `http_port` is specified, the OpenSSL configuration is ignored even if it is set. - -**Example** - -``` xml -0000 -``` - -## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} - -The page that is shown by default when you access the ClickHouse HTTP(s) server. -The default value is “Ok.” (with a line feed at the end) - -**Example** - -Opens `https://tabix.io/` when accessing `http://localhost: http_port`. - -``` xml - -
]]> -
-``` - -## include\_from {#server_configuration_parameters-include_from} - -The path to the file with substitutions. - -For more information, see the section “[Configuration files](../configuration_files.md#configuration_files)”. - -**Example** - -``` xml -/etc/metrica.xml -``` - -## interserver\_http\_port {#interserver-http-port} - -Port for exchanging data between ClickHouse servers. - -**Example** - -``` xml -9009 -``` - -## interserver\_http\_host {#interserver-http-host} - -The hostname that can be used by other servers to access this server. - -If omitted, it is defined in the same way as the `hostname-f` command. - -Useful for breaking away from a specific network interface. - -**Example** - -``` xml -example.yandex.ru -``` - -## interserver\_http\_credentials {#server-settings-interserver-http-credentials} - -The username and password used to authenticate during [replication](../../engines/table_engines/mergetree_family/replication.md) with the Replicated\* engines. These credentials are used only for communication between replicas and are unrelated to credentials for ClickHouse clients. The server is checking these credentials for connecting replicas and use the same credentials when connecting to other replicas. So, these credentials should be set the same for all replicas in a cluster. -By default, the authentication is not used. - -This section contains the following parameters: - -- `user` — username. -- `password` — password. - -**Example** - -``` xml - - admin - 222 - -``` - -## keep\_alive\_timeout {#keep-alive-timeout} - -The number of seconds that ClickHouse waits for incoming requests before closing the connection. Defaults to 3 seconds. - -**Example** - -``` xml -3 -``` - -## listen\_host {#server_configuration_parameters-listen_host} - -Restriction on hosts that requests can come from. If you want the server to answer all of them, specify `::`. - -Examples: - -``` xml -::1 -127.0.0.1 -``` - -## logger {#server_configuration_parameters-logger} - -Logging settings. - -Keys: - -- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. -- log – The log file. Contains all the entries according to `level`. -- errorlog – Error log file. -- size – Size of the file. Applies to `log`and`errorlog`. Once the file reaches `size`, ClickHouse archives and renames it, and creates a new log file in its place. -- count – The number of archived log files that ClickHouse stores. - -**Example** - -``` xml - - trace - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 10 - -``` - -Writing to the syslog is also supported. Config example: - -``` xml - - 1 - -
syslog.remote:10514
- myhost.local - LOG_LOCAL6 - syslog -
-
-``` - -Keys: - -- use\_syslog — Required setting if you want to write to the syslog. -- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. -- hostname — Optional. The name of the host that logs are sent from. -- facility — [The syslog facility keyword](https://en.wikipedia.org/wiki/Syslog#Facility) in uppercase letters with the “LOG\_” prefix: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3`, and so on). - Default value: `LOG_USER` if `address` is specified, `LOG_DAEMON otherwise.` -- format – Message format. Possible values: `bsd` and `syslog.` - -## macros {#macros} - -Parameter substitutions for replicated tables. - -Can be omitted if replicated tables are not used. - -For more information, see the section “[Creating replicated tables](../../engines/table_engines/mergetree_family/replication.md)”. - -**Example** - -``` xml - -``` - -## mark\_cache\_size {#server-mark-cache-size} - -Approximate size (in bytes) of the cache of marks used by table engines of the [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) family. - -The cache is shared for the server and memory is allocated as needed. The cache size must be at least 5368709120. - -**Example** - -``` xml -5368709120 -``` - -## max\_concurrent\_queries {#max-concurrent-queries} - -The maximum number of simultaneously processed requests. - -**Example** - -``` xml -100 -``` - -## max\_connections {#max-connections} - -The maximum number of inbound connections. - -**Example** - -``` xml -4096 -``` - -## max\_open\_files {#max-open-files} - -The maximum number of open files. - -By default: `maximum`. - -We recommend using this option in Mac OS X since the `getrlimit()` function returns an incorrect value. - -**Example** - -``` xml -262144 -``` - -## max\_table\_size\_to\_drop {#max-table-size-to-drop} - -Restriction on deleting tables. - -If the size of a [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) table exceeds `max_table_size_to_drop` (in bytes), you can’t delete it using a DROP query. - -If you still need to delete the table without restarting the ClickHouse server, create the `/flags/force_drop_table` file and run the DROP query. - -Default value: 50 GB. - -The value 0 means that you can delete all tables without any restrictions. - -**Example** - -``` xml -0 -``` - -## merge\_tree {#server_configuration_parameters-merge_tree} - -Fine tuning for tables in the [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). - -For more information, see the MergeTreeSettings.h header file. - -**Example** - -``` xml - - 5 - -``` - -## openSSL {#server_configuration_parameters-openssl} - -SSL client/server configuration. - -Support for SSL is provided by the `libpoco` library. The interface is described in the file [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) - -Keys for server/client settings: - -- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. -- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` contains the certificate. -- caConfig – The path to the file or directory that contains trusted root certificates. -- verificationMode – The method for checking the node’s certificates. Details are in the description of the [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) class. Possible values: `none`, `relaxed`, `strict`, `once`. -- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. -- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| -- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. -- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Acceptable values: `true`, `false`. -- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. This parameter is always recommended since it helps avoid problems both if the server caches the session and if the client requested caching. Default value: `${application.name}`. -- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. -- sessionTimeout – Time for caching the session on the server. -- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. -- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. -- fips – Activates OpenSSL FIPS mode. Supported if the library’s OpenSSL version supports FIPS. -- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. -- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . -- disableProtocols – Protocols that are not allowed to use. -- preferServerCiphers – Preferred server ciphers on the client. - -**Example of settings:** - -``` xml - - - - /etc/clickhouse-server/server.crt - /etc/clickhouse-server/server.key - - /etc/clickhouse-server/dhparam.pem - none - true - true - sslv2,sslv3 - true - - - true - true - sslv2,sslv3 - true - - - - RejectCertificateHandler - - - -``` - -## part\_log {#server_configuration_parameters-part-log} - -Logging events that are associated with [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). For instance, adding or merging data. You can use the log to simulate merge algorithms and compare their characteristics. You can visualize the merge process. - -Queries are logged in the [system.part\_log](../../operations/system_tables.md#system_tables-part-log) table, not in a separate file. You can configure the name of this table in the `table` parameter (see below). - -Use the following parameters to configure logging: - -- `database` – Name of the database. -- `table` – Name of the system table. -- `partition_by` – Sets a [custom partitioning key](../../engines/table_engines/mergetree_family/custom_partitioning_key.md). -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -**Example** - -``` xml - - system - part_log
- toMonday(event_date) - 7500 -
-``` - -## path {#server_configuration_parameters-path} - -The path to the directory containing data. - -!!! note "Note" - The trailing slash is mandatory. - -**Example** - -``` xml -/var/lib/clickhouse/ -``` - -## prometheus {#server_configuration_parameters-prometheus} - -Exposing metrics data for scraping from [Prometheus](https://prometheus.io). - -Settings: - -- `endpoint` – HTTP endpoint for scraping metrics by prometheus server. Start from '/'. -- `port` – Port for `endpoint`. -- `metrics` – Flag that sets to expose metrics from the [system.metrics](../system_tables.md#system_tables-metrics) table. -- `events` – Flag that sets to expose metrics from the [system.events](../system_tables.md#system_tables-events) table. -- `asynchronous_metrics` – Flag that sets to expose current metrics values from the [system.asynchronous\_metrics](../system_tables.md#system_tables-asynchronous_metrics) table. - -**Example** - -``` xml - - /metrics - 8001 - true - true - true - -``` - -## query\_log {#server_configuration_parameters-query-log} - -Setting for logging queries received with the [log\_queries=1](../settings/settings.md) setting. - -Queries are logged in the [system.query\_log](../../operations/system_tables.md#system_tables-query_log) table, not in a separate file. You can change the name of the table in the `table` parameter (see below). - -Use the following parameters to configure logging: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [custom partitioning key](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) for a table. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -If the table doesn’t exist, ClickHouse will create it. If the structure of the query log changed when the ClickHouse server was updated, the table with the old structure is renamed, and a new table is created automatically. - -**Example** - -``` xml - - system - query_log
- toMonday(event_date) - 7500 -
-``` - -## query\_thread\_log {#server_configuration_parameters-query-thread-log} - -Setting for logging threads of queries received with the [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads) setting. - -Queries are logged in the [system.query\_thread\_log](../../operations/system_tables.md#system_tables-query-thread-log) table, not in a separate file. You can change the name of the table in the `table` parameter (see below). - -Use the following parameters to configure logging: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [custom partitioning key](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) for a system table. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -If the table doesn’t exist, ClickHouse will create it. If the structure of the query thread log changed when the ClickHouse server was updated, the table with the old structure is renamed, and a new table is created automatically. - -**Example** - -``` xml - - system - query_thread_log
- toMonday(event_date) - 7500 -
-``` - -## trace\_log {#server_configuration_parameters-trace_log} - -Settings for the [trace\_log](../../operations/system_tables.md#system_tables-trace_log) system table operation. - -Parameters: - -- `database` — Database for storing a table. -- `table` — Table name. -- `partition_by` — [Custom partitioning key](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) for a system table. -- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. - -The default server configuration file `config.xml` contains the following settings section: - -``` xml - - system - trace_log
- toYYYYMM(event_date) - 7500 -
-``` - -## query\_masking\_rules {#query-masking-rules} - -Regexp-based rules, which will be applied to queries as well as all log messages before storing them in server logs, -`system.query_log`, `system.text_log`, `system.processes` table, and in logs sent to the client. That allows preventing -sensitive data leakage from SQL queries (like names, emails, personal -identifiers or credit card numbers) to logs. - -**Example** - -``` xml - - - hide SSN - (^|\D)\d{3}-\d{2}-\d{4}($|\D) - 000-00-0000 - - -``` - -Config fields: -- `name` - name for the rule (optional) -- `regexp` - RE2 compatible regular expression (mandatory) -- `replace` - substitution string for sensitive data (optional, by default - six asterisks) - -The masking rules are applied to the whole query (to prevent leaks of sensitive data from malformed / non-parsable queries). - -`system.events` table have counter `QueryMaskingRulesMatch` which have an overall number of query masking rules matches. - -For distributed queries each server have to be configured separately, otherwise, subqueries passed to other -nodes will be stored without masking. - -## remote\_servers {#server-settings-remote-servers} - -Configuration of clusters used by the [Distributed](../../engines/table_engines/special/distributed.md) table engine and by the `cluster` table function. - -**Example** - -``` xml - -``` - -For the value of the `incl` attribute, see the section “[Configuration files](../configuration_files.md#configuration_files)”. - -**See Also** - -- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) - -## timezone {#server_configuration_parameters-timezone} - -The server’s time zone. - -Specified as an IANA identifier for the UTC timezone or geographic location (for example, Africa/Abidjan). - -The time zone is necessary for conversions between String and DateTime formats when DateTime fields are output to text format (printed on the screen or in a file), and when getting DateTime from a string. Besides, the time zone is used in functions that work with the time and date if they didn’t receive the time zone in the input parameters. - -**Example** - -``` xml -Europe/Moscow -``` - -## tcp\_port {#server_configuration_parameters-tcp_port} - -Port for communicating with clients over the TCP protocol. - -**Example** - -``` xml -9000 -``` - -## tcp\_port\_secure {#server_configuration_parameters-tcp_port-secure} - -TCP port for secure communication with clients. Use it with [OpenSSL](#server_configuration_parameters-openssl) settings. - -**Possible values** - -Positive integer. - -**Default value** - -``` xml -9440 -``` - -## mysql\_port {#server_configuration_parameters-mysql_port} - -Port for communicating with clients over MySQL protocol. - -**Possible values** - -Positive integer. - -Example - -``` xml -9004 -``` - -## tmp\_path {#server-settings-tmp_path} - -Path to temporary data for processing large queries. - -!!! note "Note" - The trailing slash is mandatory. - -**Example** - -``` xml -/var/lib/clickhouse/tmp/ -``` - -## tmp\_policy {#server-settings-tmp-policy} - -Policy from [`storage_configuration`](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) to store temporary files. -If not set [`tmp_path`](#server-settings-tmp_path) is used, otherwise it is ignored. - -!!! note "Note" - - `move_factor` is ignored -- `keep_free_space_bytes` is ignored -- `max_data_part_size_bytes` is ignored -- you must have exactly one volume in that policy - -## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} - -Cache size (in bytes) for uncompressed data used by table engines from the [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). - -There is one shared cache for the server. Memory is allocated on demand. The cache is used if the option [use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) is enabled. - -The uncompressed cache is advantageous for very short queries in individual cases. - -**Example** - -``` xml -8589934592 -``` - -## user\_files\_path {#server_configuration_parameters-user_files_path} - -The directory with user files. Used in the table function [file()](../../sql_reference/table_functions/file.md). - -**Example** - -``` xml -/var/lib/clickhouse/user_files/ -``` - -## users\_config {#users-config} - -Path to the file that contains: - -- User configurations. -- Access rights. -- Settings profiles. -- Quota settings. - -**Example** - -``` xml -users.xml -``` - -## zookeeper {#server-settings_zookeeper} - -Contains settings that allow ClickHouse to interact with a [ZooKeeper](http://zookeeper.apache.org/) cluster. - -ClickHouse uses ZooKeeper for storing metadata of replicas when using replicated tables. If replicated tables are not used, this section of parameters can be omitted. - -This section contains the following parameters: - -- `node` — ZooKeeper endpoint. You can set multiple endpoints. - - For example: - - - -``` xml - - example_host - 2181 - -``` - - The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. - -- `session_timeout` — Maximum timeout for the client session in milliseconds. -- `root` — The [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) that is used as the root for znodes used by the ClickHouse server. Optional. -- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. - -**Example configuration** - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - 30000 - 10000 - - /path/to/zookeeper/node - - user:password - -``` - -**See Also** - -- [Replication](../../engines/table_engines/mergetree_family/replication.md) -- [ZooKeeper Programmer’s Guide](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) - -## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} - -Storage method for data part headers in ZooKeeper. - -This setting only applies to the `MergeTree` family. It can be specified: - -- Globally in the [merge\_tree](#server_configuration_parameters-merge_tree) section of the `config.xml` file. - - ClickHouse uses the setting for all the tables on the server. You can change the setting at any time. Existing tables change their behaviour when the setting changes. - -- For each table. - - When creating a table, specify the corresponding [engine setting](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). The behaviour of an existing table with this setting does not change, even if the global setting changes. - -**Possible values** - -- 0 — Functionality is turned off. -- 1 — Functionality is turned on. - -If `use_minimalistic_part_header_in_zookeeper = 1`, then [replicated](../../engines/table_engines/mergetree_family/replication.md) tables store the headers of the data parts compactly using a single `znode`. If the table contains many columns, this storage method significantly reduces the volume of the data stored in Zookeeper. - -!!! attention "Attention" - After applying `use_minimalistic_part_header_in_zookeeper = 1`, you can’t downgrade the ClickHouse server to a version that doesn’t support this setting. Be careful when upgrading ClickHouse on servers in a cluster. Don’t upgrade all the servers at once. It is safer to test new versions of ClickHouse in a test environment, or on just a few servers of a cluster. - - Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. - -**Default value:** 0. - -## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} - -Disables the internal DNS cache. Recommended for operating ClickHouse in systems -with frequently changing infrastructure such as Kubernetes. - -**Default value:** 0. - -## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} - -The period of updating IP addresses stored in the ClickHouse internal DNS cache (in seconds). -The update is performed asynchronously, in a separate system thread. - -**Default value**: 15. - -[Original article](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/en/operations/settings/constraints_on_settings.md b/docs/en/operations/settings/constraints-on-settings.md similarity index 100% rename from docs/en/operations/settings/constraints_on_settings.md rename to docs/en/operations/settings/constraints-on-settings.md diff --git a/docs/en/operations/settings/index.md b/docs/en/operations/settings/index.md index 0f4a11272c6..59394d77b11 100644 --- a/docs/en/operations/settings/index.md +++ b/docs/en/operations/settings/index.md @@ -4,9 +4,10 @@ toc_priority: 55 toc_title: Introduction --- -# Settings {#settings} +# Settings {#session-settings-intro} + +There are multiple ways to make all the settings described in this section of documentation. -There are multiple ways to make all the settings described below. Settings are configured in layers, so each subsequent layer redefines the previous settings. Ways to configure settings, in order of priority: diff --git a/docs/en/operations/settings/permissions-for-queries.md b/docs/en/operations/settings/permissions-for-queries.md new file mode 100644 index 00000000000..1f697989f5d --- /dev/null +++ b/docs/en/operations/settings/permissions-for-queries.md @@ -0,0 +1,59 @@ +--- +toc_priority: 58 +toc_title: Permissions for Queries +--- + +# Permissions for Queries {#permissions_for_queries} + +Queries in ClickHouse can be divided into several types: + +1. Read data queries: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. +2. Write data queries: `INSERT`, `OPTIMIZE`. +3. Change settings query: `SET`, `USE`. +4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) queries: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. +5. `KILL QUERY`. + +The following settings regulate user permissions by the type of query: + +- [readonly](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. +- [allow\_ddl](#settings_allow_ddl) — Restricts permissions for DDL queries. + +`KILL QUERY` can be performed with any settings. + +## readonly {#settings_readonly} + +Restricts permissions for reading data, write data and change settings queries. + +See how the queries are divided into types [above](#permissions_for_queries). + +Possible values: + +- 0 — All queries are allowed. +- 1 — Only read data queries are allowed. +- 2 — Read data and change settings queries are allowed. + +After setting `readonly = 1`, the user can’t change `readonly` and `allow_ddl` settings in the current session. + +When using the `GET` method in the [HTTP interface](../../interfaces/http.md), `readonly = 1` is set automatically. To modify data, use the `POST` method. + +Setting `readonly = 1` prohibit the user from changing all the settings. There is a way to prohibit the user +from changing only specific settings, for details see [constraints on settings](constraints-on-settings.md). + +Default value: 0 + +## allow\_ddl {#settings_allow_ddl} + +Allows or denies [DDL](https://en.wikipedia.org/wiki/Data_definition_language) queries. + +See how the queries are divided into types [above](#permissions_for_queries). + +Possible values: + +- 0 — DDL queries are not allowed. +- 1 — DDL queries are allowed. + +You can’t execute `SET allow_ddl = 1` if `allow_ddl = 0` for the current session. + +Default value: 1 + +[Original article](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/en/operations/settings/permissions_for_queries.md b/docs/en/operations/settings/permissions_for_queries.md deleted file mode 100644 index 4bcc065e3f1..00000000000 --- a/docs/en/operations/settings/permissions_for_queries.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -toc_priority: 58 -toc_title: Permissions for Queries ---- - -# Permissions for Queries {#permissions_for_queries} - -Queries in ClickHouse can be divided into several types: - -1. Read data queries: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. -2. Write data queries: `INSERT`, `OPTIMIZE`. -3. Change settings query: `SET`, `USE`. -4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) queries: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. -5. `KILL QUERY`. - -The following settings regulate user permissions by the type of query: - -- [readonly](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. -- [allow\_ddl](#settings_allow_ddl) — Restricts permissions for DDL queries. - -`KILL QUERY` can be performed with any settings. - -## readonly {#settings_readonly} - -Restricts permissions for reading data, write data and change settings queries. - -See how the queries are divided into types [above](#permissions_for_queries). - -Possible values: - -- 0 — All queries are allowed. -- 1 — Only read data queries are allowed. -- 2 — Read data and change settings queries are allowed. - -After setting `readonly = 1`, the user can’t change `readonly` and `allow_ddl` settings in the current session. - -When using the `GET` method in the [HTTP interface](../../interfaces/http.md), `readonly = 1` is set automatically. To modify data, use the `POST` method. - -Setting `readonly = 1` prohibit the user from changing all the settings. There is a way to prohibit the user -from changing only specific settings, for details see [constraints on settings](constraints_on_settings.md). - -Default value: 0 - -## allow\_ddl {#settings_allow_ddl} - -Allows or denies [DDL](https://en.wikipedia.org/wiki/Data_definition_language) queries. - -See how the queries are divided into types [above](#permissions_for_queries). - -Possible values: - -- 0 — DDL queries are not allowed. -- 1 — DDL queries are allowed. - -You can’t execute `SET allow_ddl = 1` if `allow_ddl = 0` for the current session. - -Default value: 1 - -[Original article](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/en/operations/settings/query-complexity.md b/docs/en/operations/settings/query-complexity.md new file mode 100644 index 00000000000..83b6054d642 --- /dev/null +++ b/docs/en/operations/settings/query-complexity.md @@ -0,0 +1,299 @@ +--- +toc_priority: 59 +toc_title: Restrictions on Query Complexity +--- + +# Restrictions on Query Complexity {#restrictions-on-query-complexity} + +Restrictions on query complexity are part of the settings. +They are used to provide safer execution from the user interface. +Almost all the restrictions only apply to `SELECT`. For distributed query processing, restrictions are applied on each server separately. + +ClickHouse checks the restrictions for data parts, not for each row. It means that you can exceed the value of restriction with the size of the data part. + +Restrictions on the “maximum amount of something” can take the value 0, which means “unrestricted”. +Most restrictions also have an ‘overflow\_mode’ setting, meaning what to do when the limit is exceeded. +It can take one of two values: `throw` or `break`. Restrictions on aggregation (group\_by\_overflow\_mode) also have the value `any`. + +`throw` – Throw an exception (default). + +`break` – Stop executing the query and return the partial result, as if the source data ran out. + +`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don’t add new keys to the set. + +## max\_memory\_usage {#settings_max_memory_usage} + +The maximum amount of RAM to use for running a query on a single server. + +In the default configuration file, the maximum is 10 GB. + +The setting doesn’t consider the volume of available memory or the total volume of memory on the machine. +The restriction applies to a single query within a single server. +You can use `SHOW PROCESSLIST` to see the current memory consumption for each query. +Besides, the peak memory consumption is tracked for each query and written to the log. + +Memory usage is not monitored for the states of certain aggregate functions. + +Memory usage is not fully tracked for states of the aggregate functions `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` from `String` and `Array` arguments. + +Memory consumption is also restricted by the parameters `max_memory_usage_for_user` and `max_memory_usage_for_all_queries`. + +## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} + +The maximum amount of RAM to use for running a user’s queries on a single server. + +Default values are defined in [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). By default, the amount is not restricted (`max_memory_usage_for_user = 0`). + +See also the description of [max\_memory\_usage](#settings_max_memory_usage). + +## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} + +The maximum amount of RAM to use for running all queries on a single server. + +Default values are defined in [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). By default, the amount is not restricted (`max_memory_usage_for_all_queries = 0`). + +See also the description of [max\_memory\_usage](#settings_max_memory_usage). + +## max\_rows\_to\_read {#max-rows-to-read} + +The following restrictions can be checked on each block (instead of on each row). That is, the restrictions can be broken a little. +When running a query in multiple threads, the following restrictions apply to each thread separately. + +A maximum number of rows that can be read from a table when running a query. + +## max\_bytes\_to\_read {#max-bytes-to-read} + +A maximum number of bytes (uncompressed data) that can be read from a table when running a query. + +## read\_overflow\_mode {#read-overflow-mode} + +What to do when the volume of data read exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. + +## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} + +A maximum number of unique keys received from aggregation. This setting lets you limit memory consumption when aggregating. + +## group\_by\_overflow\_mode {#group-by-overflow-mode} + +What to do when the number of unique keys for aggregation exceeds the limit: ‘throw’, ‘break’, or ‘any’. By default, throw. +Using the ‘any’ value lets you run an approximation of GROUP BY. The quality of this approximation depends on the statistical nature of the data. + +## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} + +Enables or disables execution of `GROUP BY` clauses in external memory. See [GROUP BY in external memory](../../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory). + +Possible values: + +- Maximum volume of RAM (in bytes) that can be used by the single [GROUP BY](../../sql-reference/statements/select/group-by.md#select-group-by-clause) operation. +- 0 — `GROUP BY` in external memory disabled. + +Default value: 0. + +## max\_rows\_to\_sort {#max-rows-to-sort} + +A maximum number of rows before sorting. This allows you to limit memory consumption when sorting. + +## max\_bytes\_to\_sort {#max-bytes-to-sort} + +A maximum number of bytes before sorting. + +## sort\_overflow\_mode {#sort-overflow-mode} + +What to do if the number of rows received before sorting exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. + +## max\_result\_rows {#setting-max_result_rows} + +Limit on the number of rows in the result. Also checked for subqueries, and on remote servers when running parts of a distributed query. + +## max\_result\_bytes {#max-result-bytes} + +Limit on the number of bytes in the result. The same as the previous setting. + +## result\_overflow\_mode {#result-overflow-mode} + +What to do if the volume of the result exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. + +Using ‘break’ is similar to using LIMIT. `Break` interrupts execution only at the block level. This means that amount of returned rows is greater than [max\_result\_rows](#setting-max_result_rows), multiple of [max\_block\_size](settings.md#setting-max_block_size) and depends on [max_threads](settings.md#settings-max_threads). + +Example: + +``` sql +SET max_threads = 3, max_block_size = 3333; +SET max_result_rows = 3334, result_overflow_mode = 'break'; + +SELECT * +FROM numbers_mt(100000) +FORMAT Null; +``` + +Result: + +``` text +6666 rows in set. ... +``` + +## max\_execution\_time {#max-execution-time} + +Maximum query execution time in seconds. +At this time, it is not checked for one of the sorting stages, or when merging and finalizing aggregate functions. + +## timeout\_overflow\_mode {#timeout-overflow-mode} + +What to do if the query is run longer than ‘max\_execution\_time’: ‘throw’ or ‘break’. By default, throw. + +## min\_execution\_speed {#min-execution-speed} + +Minimal execution speed in rows per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is lower, an exception is thrown. + +## min\_execution\_speed\_bytes {#min-execution-speed-bytes} + +A minimum number of execution bytes per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is lower, an exception is thrown. + +## max\_execution\_speed {#max-execution-speed} + +A maximum number of execution rows per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is high, the execution speed will be reduced. + +## max\_execution\_speed\_bytes {#max-execution-speed-bytes} + +A maximum number of execution bytes per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is high, the execution speed will be reduced. + +## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} + +Checks that execution speed is not too slow (no less than ‘min\_execution\_speed’), after the specified time in seconds has expired. + +## max\_columns\_to\_read {#max-columns-to-read} + +A maximum number of columns that can be read from a table in a single query. If a query requires reading a greater number of columns, it throws an exception. + +## max\_temporary\_columns {#max-temporary-columns} + +A maximum number of temporary columns that must be kept in RAM at the same time when running a query, including constant columns. If there are more temporary columns than this, it throws an exception. + +## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} + +The same thing as ‘max\_temporary\_columns’, but without counting constant columns. +Note that constant columns are formed fairly often when running a query, but they require approximately zero computing resources. + +## max\_subquery\_depth {#max-subquery-depth} + +Maximum nesting depth of subqueries. If subqueries are deeper, an exception is thrown. By default, 100. + +## max\_pipeline\_depth {#max-pipeline-depth} + +Maximum pipeline depth. Corresponds to the number of transformations that each data block goes through during query processing. Counted within the limits of a single server. If the pipeline depth is greater, an exception is thrown. By default, 1000. + +## max\_ast\_depth {#max-ast-depth} + +Maximum nesting depth of a query syntactic tree. If exceeded, an exception is thrown. +At this time, it isn’t checked during parsing, but only after parsing the query. That is, a syntactic tree that is too deep can be created during parsing, but the query will fail. By default, 1000. + +## max\_ast\_elements {#max-ast-elements} + +A maximum number of elements in a query syntactic tree. If exceeded, an exception is thrown. +In the same way as the previous setting, it is checked only after parsing the query. By default, 50,000. + +## max\_rows\_in\_set {#max-rows-in-set} + +A maximum number of rows for a data set in the IN clause created from a subquery. + +## max\_bytes\_in\_set {#max-bytes-in-set} + +A maximum number of bytes (uncompressed data) used by a set in the IN clause created from a subquery. + +## set\_overflow\_mode {#set-overflow-mode} + +What to do when the amount of data exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. + +## max\_rows\_in\_distinct {#max-rows-in-distinct} + +A maximum number of different rows when using DISTINCT. + +## max\_bytes\_in\_distinct {#max-bytes-in-distinct} + +A maximum number of bytes used by a hash table when using DISTINCT. + +## distinct\_overflow\_mode {#distinct-overflow-mode} + +What to do when the amount of data exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. + +## max\_rows\_to\_transfer {#max-rows-to-transfer} + +A maximum number of rows that can be passed to a remote server or saved in a temporary table when using GLOBAL IN. + +## max\_bytes\_to\_transfer {#max-bytes-to-transfer} + +A maximum number of bytes (uncompressed data) that can be passed to a remote server or saved in a temporary table when using GLOBAL IN. + +## transfer\_overflow\_mode {#transfer-overflow-mode} + +What to do when the amount of data exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. + +## max\_rows\_in\_join {#settings-max_rows_in_join} + +Limits the number of rows in the hash table that is used when joining tables. + +This settings applies to [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) operations and the [Join](../../engines/table-engines/special/join.md) table engine. + +If a query contains multiple joins, ClickHouse checks this setting for every intermediate result. + +ClickHouse can proceed with different actions when the limit is reached. Use the [join\_overflow\_mode](#settings-join_overflow_mode) setting to choose the action. + +Possible values: + +- Positive integer. +- 0 — Unlimited number of rows. + +Default value: 0. + +## max\_bytes\_in\_join {#settings-max_bytes_in_join} + +Limits the size in bytes of the hash table used when joining tables. + +This settings applies to [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) operations and [Join table engine](../../engines/table-engines/special/join.md). + +If the query contains joins, ClickHouse checks this setting for every intermediate result. + +ClickHouse can proceed with different actions when the limit is reached. Use [join\_overflow\_mode](#settings-join_overflow_mode) settings to choose the action. + +Possible values: + +- Positive integer. +- 0 — Memory control is disabled. + +Default value: 0. + +## join\_overflow\_mode {#settings-join_overflow_mode} + +Defines what action ClickHouse performs when any of the following join limits is reached: + +- [max\_bytes\_in\_join](#settings-max_bytes_in_join) +- [max\_rows\_in\_join](#settings-max_rows_in_join) + +Possible values: + +- `THROW` — ClickHouse throws an exception and breaks operation. +- `BREAK` — ClickHouse breaks operation and doesn’t throw an exception. + +Default value: `THROW`. + +**See Also** + +- [JOIN clause](../../sql-reference/statements/select/join.md#select-join) +- [Join table engine](../../engines/table-engines/special/join.md) + +## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} + +Limits the maximum number of partitions in a single inserted block. + +- Positive integer. +- 0 — Unlimited number of partitions. + +Default value: 100. + +**Details** + +When inserting data, ClickHouse calculates the number of partitions in the inserted block. If the number of partitions is more than `max_partitions_per_insert_block`, ClickHouse throws an exception with the following text: + +> “Too many partitions for single INSERT block (more than” + toString(max\_parts) + “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” + +[Original article](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/en/operations/settings/query_complexity.md b/docs/en/operations/settings/query_complexity.md deleted file mode 100644 index 034284d1d0b..00000000000 --- a/docs/en/operations/settings/query_complexity.md +++ /dev/null @@ -1,299 +0,0 @@ ---- -toc_priority: 59 -toc_title: Restrictions on Query Complexity ---- - -# Restrictions On Query Complexity {#restrictions-on-query-complexity} - -Restrictions on query complexity are part of the settings. -They are used to provide safer execution from the user interface. -Almost all the restrictions only apply to `SELECT`. For distributed query processing, restrictions are applied on each server separately. - -ClickHouse checks the restrictions for data parts, not for each row. It means that you can exceed the value of restriction with the size of the data part. - -Restrictions on the “maximum amount of something” can take the value 0, which means “unrestricted”. -Most restrictions also have an ‘overflow\_mode’ setting, meaning what to do when the limit is exceeded. -It can take one of two values: `throw` or `break`. Restrictions on aggregation (group\_by\_overflow\_mode) also have the value `any`. - -`throw` – Throw an exception (default). - -`break` – Stop executing the query and return the partial result, as if the source data ran out. - -`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don’t add new keys to the set. - -## max\_memory\_usage {#settings_max_memory_usage} - -The maximum amount of RAM to use for running a query on a single server. - -In the default configuration file, the maximum is 10 GB. - -The setting doesn’t consider the volume of available memory or the total volume of memory on the machine. -The restriction applies to a single query within a single server. -You can use `SHOW PROCESSLIST` to see the current memory consumption for each query. -Besides, the peak memory consumption is tracked for each query and written to the log. - -Memory usage is not monitored for the states of certain aggregate functions. - -Memory usage is not fully tracked for states of the aggregate functions `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` from `String` and `Array` arguments. - -Memory consumption is also restricted by the parameters `max_memory_usage_for_user` and `max_memory_usage_for_all_queries`. - -## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} - -The maximum amount of RAM to use for running a user’s queries on a single server. - -Default values are defined in [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). By default, the amount is not restricted (`max_memory_usage_for_user = 0`). - -See also the description of [max\_memory\_usage](#settings_max_memory_usage). - -## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} - -The maximum amount of RAM to use for running all queries on a single server. - -Default values are defined in [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). By default, the amount is not restricted (`max_memory_usage_for_all_queries = 0`). - -See also the description of [max\_memory\_usage](#settings_max_memory_usage). - -## max\_rows\_to\_read {#max-rows-to-read} - -The following restrictions can be checked on each block (instead of on each row). That is, the restrictions can be broken a little. -When running a query in multiple threads, the following restrictions apply to each thread separately. - -A maximum number of rows that can be read from a table when running a query. - -## max\_bytes\_to\_read {#max-bytes-to-read} - -A maximum number of bytes (uncompressed data) that can be read from a table when running a query. - -## read\_overflow\_mode {#read-overflow-mode} - -What to do when the volume of data read exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. - -## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} - -A maximum number of unique keys received from aggregation. This setting lets you limit memory consumption when aggregating. - -## group\_by\_overflow\_mode {#group-by-overflow-mode} - -What to do when the number of unique keys for aggregation exceeds the limit: ‘throw’, ‘break’, or ‘any’. By default, throw. -Using the ‘any’ value lets you run an approximation of GROUP BY. The quality of this approximation depends on the statistical nature of the data. - -## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} - -Enables or disables execution of `GROUP BY` clauses in external memory. See [GROUP BY in external memory](../../sql_reference/statements/select.md#select-group-by-in-external-memory). - -Possible values: - -- Maximum volume of RAM (in bytes) that can be used by the single [GROUP BY](../../sql_reference/statements/select.md#select-group-by-clause) operation. -- 0 — `GROUP BY` in external memory disabled. - -Default value: 0. - -## max\_rows\_to\_sort {#max-rows-to-sort} - -A maximum number of rows before sorting. This allows you to limit memory consumption when sorting. - -## max\_bytes\_to\_sort {#max-bytes-to-sort} - -A maximum number of bytes before sorting. - -## sort\_overflow\_mode {#sort-overflow-mode} - -What to do if the number of rows received before sorting exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. - -## max\_result\_rows {#setting-max_result_rows} - -Limit on the number of rows in the result. Also checked for subqueries, and on remote servers when running parts of a distributed query. - -## max\_result\_bytes {#max-result-bytes} - -Limit on the number of bytes in the result. The same as the previous setting. - -## result\_overflow\_mode {#result-overflow-mode} - -What to do if the volume of the result exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. - -Using ‘break’ is similar to using LIMIT. `Break` interrupts execution only at the block level. This means that amount of returned rows is greater than [max\_result\_rows](#setting-max_result_rows), multiple of [max\_block\_size](settings.md#setting-max_block_size) and depends on [max\_threads](settings.md#settings-max_threads). - -Example: - -``` sql -SET max_threads = 3, max_block_size = 3333; -SET max_result_rows = 3334, result_overflow_mode = 'break'; - -SELECT * -FROM numbers_mt(100000) -FORMAT Null; -``` - -Result: - -``` text -6666 rows in set. ... -``` - -## max\_execution\_time {#max-execution-time} - -Maximum query execution time in seconds. -At this time, it is not checked for one of the sorting stages, or when merging and finalizing aggregate functions. - -## timeout\_overflow\_mode {#timeout-overflow-mode} - -What to do if the query is run longer than ‘max\_execution\_time’: ‘throw’ or ‘break’. By default, throw. - -## min\_execution\_speed {#min-execution-speed} - -Minimal execution speed in rows per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is lower, an exception is thrown. - -## min\_execution\_speed\_bytes {#min-execution-speed-bytes} - -A minimum number of execution bytes per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is lower, an exception is thrown. - -## max\_execution\_speed {#max-execution-speed} - -A maximum number of execution rows per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is high, the execution speed will be reduced. - -## max\_execution\_speed\_bytes {#max-execution-speed-bytes} - -A maximum number of execution bytes per second. Checked on every data block when ‘timeout\_before\_checking\_execution\_speed’ expires. If the execution speed is high, the execution speed will be reduced. - -## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} - -Checks that execution speed is not too slow (no less than ‘min\_execution\_speed’), after the specified time in seconds has expired. - -## max\_columns\_to\_read {#max-columns-to-read} - -A maximum number of columns that can be read from a table in a single query. If a query requires reading a greater number of columns, it throws an exception. - -## max\_temporary\_columns {#max-temporary-columns} - -A maximum number of temporary columns that must be kept in RAM at the same time when running a query, including constant columns. If there are more temporary columns than this, it throws an exception. - -## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} - -The same thing as ‘max\_temporary\_columns’, but without counting constant columns. -Note that constant columns are formed fairly often when running a query, but they require approximately zero computing resources. - -## max\_subquery\_depth {#max-subquery-depth} - -Maximum nesting depth of subqueries. If subqueries are deeper, an exception is thrown. By default, 100. - -## max\_pipeline\_depth {#max-pipeline-depth} - -Maximum pipeline depth. Corresponds to the number of transformations that each data block goes through during query processing. Counted within the limits of a single server. If the pipeline depth is greater, an exception is thrown. By default, 1000. - -## max\_ast\_depth {#max-ast-depth} - -Maximum nesting depth of a query syntactic tree. If exceeded, an exception is thrown. -At this time, it isn’t checked during parsing, but only after parsing the query. That is, a syntactic tree that is too deep can be created during parsing, but the query will fail. By default, 1000. - -## max\_ast\_elements {#max-ast-elements} - -A maximum number of elements in a query syntactic tree. If exceeded, an exception is thrown. -In the same way as the previous setting, it is checked only after parsing the query. By default, 50,000. - -## max\_rows\_in\_set {#max-rows-in-set} - -A maximum number of rows for a data set in the IN clause created from a subquery. - -## max\_bytes\_in\_set {#max-bytes-in-set} - -A maximum number of bytes (uncompressed data) used by a set in the IN clause created from a subquery. - -## set\_overflow\_mode {#set-overflow-mode} - -What to do when the amount of data exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. - -## max\_rows\_in\_distinct {#max-rows-in-distinct} - -A maximum number of different rows when using DISTINCT. - -## max\_bytes\_in\_distinct {#max-bytes-in-distinct} - -A maximum number of bytes used by a hash table when using DISTINCT. - -## distinct\_overflow\_mode {#distinct-overflow-mode} - -What to do when the amount of data exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. - -## max\_rows\_to\_transfer {#max-rows-to-transfer} - -A maximum number of rows that can be passed to a remote server or saved in a temporary table when using GLOBAL IN. - -## max\_bytes\_to\_transfer {#max-bytes-to-transfer} - -A maximum number of bytes (uncompressed data) that can be passed to a remote server or saved in a temporary table when using GLOBAL IN. - -## transfer\_overflow\_mode {#transfer-overflow-mode} - -What to do when the amount of data exceeds one of the limits: ‘throw’ or ‘break’. By default, throw. - -## max\_rows\_in\_join {#settings-max_rows_in_join} - -Limits the number of rows in the hash table that is used when joining tables. - -This settings applies to [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) operations and the [Join](../../engines/table_engines/special/join.md) table engine. - -If a query contains multiple joins, ClickHouse checks this setting for every intermediate result. - -ClickHouse can proceed with different actions when the limit is reached. Use the [join\_overflow\_mode](#settings-join_overflow_mode) setting to choose the action. - -Possible values: - -- Positive integer. -- 0 — Unlimited number of rows. - -Default value: 0. - -## max\_bytes\_in\_join {#settings-max_bytes_in_join} - -Limits the size in bytes of the hash table used when joining tables. - -This settings applies to [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) operations and [Join table engine](../../engines/table_engines/special/join.md). - -If the query contains joins, ClickHouse checks this setting for every intermediate result. - -ClickHouse can proceed with different actions when the limit is reached. Use [join\_overflow\_mode](#settings-join_overflow_mode) settings to choose the action. - -Possible values: - -- Positive integer. -- 0 — Memory control is disabled. - -Default value: 0. - -## join\_overflow\_mode {#settings-join_overflow_mode} - -Defines what action ClickHouse performs when any of the following join limits is reached: - -- [max\_bytes\_in\_join](#settings-max_bytes_in_join) -- [max\_rows\_in\_join](#settings-max_rows_in_join) - -Possible values: - -- `THROW` — ClickHouse throws an exception and breaks operation. -- `BREAK` — ClickHouse breaks operation and doesn’t throw an exception. - -Default value: `THROW`. - -**See Also** - -- [JOIN clause](../../sql_reference/statements/select.md#select-join) -- [Join table engine](../../engines/table_engines/special/join.md) - -## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} - -Limits the maximum number of partitions in a single inserted block. - -- Positive integer. -- 0 — Unlimited number of partitions. - -Default value: 100. - -**Details** - -When inserting data, ClickHouse calculates the number of partitions in the inserted block. If the number of partitions is more than `max_partitions_per_insert_block`, ClickHouse throws an exception with the following text: - -> “Too many partitions for single INSERT block (more than” + toString(max\_parts) + “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” - -[Original article](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/en/operations/settings/settings-profiles.md b/docs/en/operations/settings/settings-profiles.md new file mode 100644 index 00000000000..3e5d1a02cbd --- /dev/null +++ b/docs/en/operations/settings/settings-profiles.md @@ -0,0 +1,80 @@ +--- +toc_priority: 61 +toc_title: Settings Profiles +--- + +# Settings Profiles {#settings-profiles} + +A settings profile is a collection of settings grouped under the same name. + +!!! note "Information" + ClickHouse also supports [SQL-driven workflow](../access-rights.md#access-control) for managing settings profiles. We recommend using it. + + +The profile can have any name. You can specify the same profile for different users. The most important thing you can write in the settings profile is `readonly=1`, which ensures read-only access. + +Settings profiles can inherit from each other. To use inheritance, indicate one or multiple `profile` settings before the other settings that are listed in the profile. In case when one setting is defined in different profiles, the latest defined is used. + +To apply all the settings in a profile, set the `profile` setting. + +Example: + +Install the `web` profile. + +``` sql +SET profile = 'web' +``` + +Settings profiles are declared in the user config file. This is usually `users.xml`. + +Example: + +``` xml + + + + + + 8 + + + + + 1000000000 + 100000000000 + + 1000000 + any + + 1000000 + 1000000000 + + 100000 + 100000000 + break + + 600 + 1000000 + 15 + + 25 + 100 + 50 + + 2 + 25 + 50 + 100 + + 1 + + +``` + +The example specifies two profiles: `default` and `web`. + +The `default` profile has a special purpose: it must always be present and is applied when starting the server. In other words, the `default` profile contains default settings. + +The `web` profile is a regular profile that can be set using the `SET` query or using a URL parameter in an HTTP query. + +[Original article](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/en/operations/settings/settings-users.md b/docs/en/operations/settings/settings-users.md new file mode 100644 index 00000000000..3c104202801 --- /dev/null +++ b/docs/en/operations/settings/settings-users.md @@ -0,0 +1,163 @@ +--- +toc_priority: 63 +toc_title: User Settings +--- + +# User Settings {#user-settings} + +The `users` section of the `user.xml` configuration file contains user settings. + +!!! note "Information" + ClickHouse also supports [SQL-driven workflow](../access-rights.md#access-control) for managing users. We recommend using it. + + +Structure of the `users` section: + +``` xml + + + + + + + + 0|1 + + + + + profile_name + + default + + + + + expression + + + + + + +``` + +### user\_name/password {#user-namepassword} + +Password can be specified in plaintext or in SHA256 (hex format). + +- To assign a password in plaintext (**not recommended**), place it in a `password` element. + + For example, `qwerty`. The password can be left blank. + + + +- To assign a password using its SHA256 hash, place it in a `password_sha256_hex` element. + + For example, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. + + Example of how to generate a password from shell: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' + + The first line of the result is the password. The second line is the corresponding SHA256 hash. + + + +- For compatibility with MySQL clients, password can be specified in double SHA1 hash. Place it in `password_double_sha1_hex` element. + + For example, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. + + Example of how to generate a password from shell: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' + + The first line of the result is the password. The second line is the corresponding double SHA1 hash. + +### access_management {#access_management-user-setting} + +This setting enables or disables using of SQL-driven [access control and account management](../access-rights.md#access-control) for the user. + +Possible values: + +- 0 — Disabled. +- 1 — Enabled. + +Default value: 0. + +### user\_name/networks {#user-namenetworks} + +List of networks from which the user can connect to the ClickHouse server. + +Each element of the list can have one of the following forms: + +- `` — IP address or network mask. + + Examples: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. + +- `` — Hostname. + + Example: `example01.host.ru`. + + To check access, a DNS query is performed, and all returned IP addresses are compared to the peer address. + +- `` — Regular expression for hostnames. + + Example, `^example\d\d-\d\d-\d\.host\.ru$` + + To check access, a [DNS PTR query](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) is performed for the peer address and then the specified regexp is applied. Then, another DNS query is performed for the results of the PTR query and all the received addresses are compared to the peer address. We strongly recommend that regexp ends with $. + +All results of DNS requests are cached until the server restarts. + +**Examples** + +To open access for user from any network, specify: + +``` xml +::/0 +``` + +!!! warning "Warning" + It’s insecure to open access from any network unless you have a firewall properly configured or the server is not directly connected to Internet. + +To open access only from localhost, specify: + +``` xml +::1 +127.0.0.1 +``` + +### user\_name/profile {#user-nameprofile} + +You can assign a settings profile for the user. Settings profiles are configured in a separate section of the `users.xml` file. For more information, see [Profiles of Settings](settings-profiles.md). + +### user\_name/quota {#user-namequota} + +Quotas allow you to track or limit resource usage over a period of time. Quotas are configured in the `quotas` +section of the `users.xml` configuration file. + +You can assign a quotas set for the user. For a detailed description of quotas configuration, see [Quotas](../quotas.md#quotas). + +### user\_name/databases {#user-namedatabases} + +In this section, you can you can limit rows that are returned by ClickHouse for `SELECT` queries made by the current user, thus implementing basic row-level security. + +**Example** + +The following configuration forces that user `user1` can only see the rows of `table1` as the result of `SELECT` queries, where the value of the `id` field is 1000. + +``` xml + + + + + id = 1000 + + + + +``` + +The `filter` can be any expression resulting in a [UInt8](../../sql-reference/data-types/int-uint.md)-type value. It usually contains comparisons and logical operators. Rows from `database_name.table1` where filter results to 0 are not returned for this user. The filtering is incompatible with `PREWHERE` operations and disables `WHERE→PREWHERE` optimization. + +[Original article](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/en/operations/settings/settings.md b/docs/en/operations/settings/settings.md index 46cd00cb661..f29866d4980 100644 --- a/docs/en/operations/settings/settings.md +++ b/docs/en/operations/settings/settings.md @@ -1,13 +1,8 @@ ---- -toc_priority: 60 -toc_title: Settings ---- - # Settings {#settings} ## distributed\_product\_mode {#distributed-product-mode} -Changes the behavior of [distributed subqueries](../../sql_reference/statements/select.md). +Changes the behavior of [distributed subqueries](../../sql-reference/operators/in.md). ClickHouse applies this setting when the query contains the product of distributed tables, i.e. when the query for a distributed table contains a non-GLOBAL subquery for the distributed table. @@ -16,7 +11,7 @@ Restrictions: - Only applied for IN and JOIN subqueries. - Only if the FROM section uses a distributed table containing more than one shard. - If the subquery concerns a distributed table containing more than one shard. -- Not used for a table-valued [remote](../../sql_reference/table_functions/remote.md) function. +- Not used for a table-valued [remote](../../sql-reference/table-functions/remote.md) function. Possible values: @@ -51,7 +46,7 @@ If `enable_optimize_predicate_expression = 0`, then the execution time of the se ## fallback\_to\_stale\_replicas\_for\_distributed\_queries {#settings-fallback_to_stale_replicas_for_distributed_queries} -Forces a query to an out-of-date replica if updated data is not available. See [Replication](../../engines/table_engines/mergetree_family/replication.md). +Forces a query to an out-of-date replica if updated data is not available. See [Replication](../../engines/table-engines/mergetree-family/replication.md). ClickHouse selects the most relevant from the outdated replicas of the table. @@ -65,7 +60,7 @@ Disables query execution if the index can’t be used by date. Works with tables in the MergeTree family. -If `force_index_by_date=1`, ClickHouse checks whether the query has a date key condition that can be used for restricting data ranges. If there is no suitable condition, it throws an exception. However, it does not check whether the condition reduces the amount of data to read. For example, the condition `Date != ' 2000-01-01 '` is acceptable even when it matches all the data in the table (i.e., running the query requires a full scan). For more information about ranges of data in MergeTree tables, see [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +If `force_index_by_date=1`, ClickHouse checks whether the query has a date key condition that can be used for restricting data ranges. If there is no suitable condition, it throws an exception. However, it does not check whether the condition reduces the amount of data to read. For example, the condition `Date != ' 2000-01-01 '` is acceptable even when it matches all the data in the table (i.e., running the query requires a full scan). For more information about ranges of data in MergeTree tables, see [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## force\_primary\_key {#force-primary-key} @@ -73,7 +68,7 @@ Disables query execution if indexing by the primary key is not possible. Works with tables in the MergeTree family. -If `force_primary_key=1`, ClickHouse checks to see if the query has a primary key condition that can be used for restricting data ranges. If there is no suitable condition, it throws an exception. However, it does not check whether the condition reduces the amount of data to read. For more information about data ranges in MergeTree tables, see [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +If `force_primary_key=1`, ClickHouse checks to see if the query has a primary key condition that can be used for restricting data ranges. If there is no suitable condition, it throws an exception. However, it does not check whether the condition reduces the amount of data to read. For more information about data ranges in MergeTree tables, see [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## format\_schema {#format-schema} @@ -134,7 +129,7 @@ Default value: 0. ## max\_http\_get\_redirects {#setting-max_http_get_redirects} -Limits the maximum number of HTTP GET redirect hops for [URL](../../engines/table_engines/special/url.md)-engine tables. The setting applies to both types of tables: those created by the [CREATE TABLE](../../sql_reference/statements/create.md#create-table-query) query and by the [url](../../sql_reference/table_functions/url.md) table function. +Limits the maximum number of HTTP GET redirect hops for [URL](../../engines/table-engines/special/url.md)-engine tables. The setting applies to both types of tables: those created by the [CREATE TABLE](../../sql-reference/statements/create.md#create-table-query) query and by the [url](../../sql-reference/table-functions/url.md) table function. Possible values: @@ -170,7 +165,7 @@ If both `input_format_allow_errors_num` and `input_format_allow_errors_ratio` ar ## input\_format\_values\_interpret\_expressions {#settings-input_format_values_interpret_expressions} -Enables or disables the full SQL parser if the fast stream parser can’t parse the data. This setting is used only for the [Values](../../interfaces/formats.md#data-format-values) format at the data insertion. For more information about syntax parsing, see the [Syntax](../../sql_reference/syntax.md) section. +Enables or disables the full SQL parser if the fast stream parser can’t parse the data. This setting is used only for the [Values](../../interfaces/formats.md#data-format-values) format at the data insertion. For more information about syntax parsing, see the [Syntax](../../sql-reference/syntax.md) section. Possible values: @@ -186,7 +181,7 @@ Default value: 1. Example of Use -Insert the [DateTime](../../sql_reference/data_types/datetime.md) type value with the different settings. +Insert the [DateTime](../../sql-reference/data-types/datetime.md) type value with the different settings. ``` sql SET input_format_values_interpret_expressions = 0; @@ -220,7 +215,7 @@ Ok. ## input\_format\_values\_deduce\_templates\_of\_expressions {#settings-input_format_values_deduce_templates_of_expressions} -Enables or disables template deduction for SQL expressions in [Values](../../interfaces/formats.md#data-format-values) format. It allows parsing and interpreting expressions in `Values` much faster if expressions in consecutive rows have the same structure. ClickHouse tries to deduce template of an expression, parse the following rows using this template and evaluate the expression on a batch of successfully parsed rows. +Enables or disables template deduction for SQL expressions in [Values](../../interfaces/formats.md#data-format-values) format. It allows parsing and interpreting expressions in `Values` much faster if expressions in consecutive rows have the same structure. ClickHouse tries to deduce template of an expression, parse the following rows using this template and evaluate the expression on a batch of successfully parsed rows. Possible values: @@ -346,7 +341,7 @@ Default value: 1. Allows choosing a parser of the text representation of date and time. -The setting doesn’t apply to [date and time functions](../../sql_reference/functions/date_time_functions.md). +The setting doesn’t apply to [date and time functions](../../sql-reference/functions/date-time-functions.md). Possible values: @@ -362,12 +357,12 @@ Default value: `'basic'`. See also: -- [DateTime data type.](../../sql_reference/data_types/datetime.md) -- [Functions for working with dates and times.](../../sql_reference/functions/date_time_functions.md) +- [DateTime data type.](../../sql-reference/data-types/datetime.md) +- [Functions for working with dates and times.](../../sql-reference/functions/date-time-functions.md) ## join\_default\_strictness {#settings-join_default_strictness} -Sets default strictness for [JOIN clauses](../../sql_reference/statements/select.md#select-join). +Sets default strictness for [JOIN clauses](../../sql-reference/statements/select/join.md#select-join). Possible values: @@ -383,7 +378,7 @@ Default value: `ALL`. Changes behaviour of join operations with `ANY` strictness. !!! warning "Attention" - This setting applies only for `JOIN` operations with [Join](../../engines/table_engines/special/join.md) engine tables. + This setting applies only for `JOIN` operations with [Join](../../engines/table-engines/special/join.md) engine tables. Possible values: @@ -394,21 +389,104 @@ Default value: 0. See also: -- [JOIN clause](../../sql_reference/statements/select.md#select-join) -- [Join table engine](../../engines/table_engines/special/join.md) +- [JOIN clause](../../sql-reference/statements/select/join.md#select-join) +- [Join table engine](../../engines/table-engines/special/join.md) - [join\_default\_strictness](#settings-join_default_strictness) ## join\_use\_nulls {#join_use_nulls} -Sets the type of [JOIN](../../sql_reference/statements/select.md) behavior. When merging tables, empty cells may appear. ClickHouse fills them differently based on this setting. +Sets the type of [JOIN](../../sql-reference/statements/select/join.md) behavior. When merging tables, empty cells may appear. ClickHouse fills them differently based on this setting. Possible values: - 0 — The empty cells are filled with the default value of the corresponding field type. -- 1 — `JOIN` behaves the same way as in standard SQL. The type of the corresponding field is converted to [Nullable](../../sql_reference/data_types/nullable.md#data_type-nullable), and empty cells are filled with [NULL](../../sql_reference/syntax.md). +- 1 — `JOIN` behaves the same way as in standard SQL. The type of the corresponding field is converted to [Nullable](../../sql-reference/data-types/nullable.md#data_type-nullable), and empty cells are filled with [NULL](../../sql-reference/syntax.md). Default value: 0. +## partial_merge_join_optimizations {#partial_merge_join_optimizations} + +Disables optimizations in partial merge join algorithm for [JOIN](../../sql-reference/statements/select/join.md) queries. + +By default, this setting enables improvements that could lead to wrong results. If you see suspicious results in your queries, disable optimizations by this setting. Optimizations can be different in different versions of the ClickHouse server. + +Possible values: + +- 0 — Optimizations disabled. +- 1 — Optimizations enabled. + +Default value: 1. + +## partial_merge_join_rows_in_right_blocks {#partial_merge_join_rows_in_right_blocks} + +Limits sizes of right-hand join data blocks in partial merge join algorithm for [JOIN](../../sql-reference/statements/select/join.md) queries. + +ClickHouse server: + +1. Splits right-hand join data into blocks with up to the specified number of rows. +2. Indexes each block with their minimum and maximum values +3. Unloads prepared blocks to disk if possible. + +Possible values: + +- Any positive integer. Recommended range of values: [1000, 100000]. + +Default value: 65536. + +## join_on_disk_max_files_to_merge {#join_on_disk_max_files_to_merge} + +Limits the number of files allowed for parallel sorting in MergeJoin operations when they are executed on disk. + +The bigger the value of the setting, the more RAM used and the less disk I/O needed. + +Possible values: + +- Any positive integer, starting from 2. + +Default value: 64. + +## any_join_distinct_right_table_keys {#any_join_distinct_right_table_keys} + +Enables legacy ClickHouse server behavior in `ANY INNER|LEFT JOIN` operations. + +!!! note "Warning" + Use this setting only for the purpose of backward compatibility if your use cases depend on legacy `JOIN` behavior. + +When the legacy behavior enabled: + +- Results of `t1 ANY LEFT JOIN t2` and `t2 ANY RIGHT JOIN t1` operations are not equal because ClickHouse uses the logic with many-to-one left-to-right table keys mapping. +- Results of `ANY INNER JOIN` operations contain all rows from the left table like the `SEMI LEFT JOIN` operations do. + +When the legacy behavior disabled: + +- Results of `t1 ANY LEFT JOIN t2` and `t2 ANY RIGHT JOIN t1` operations are equal because ClickHouse uses the logic which provides one-to-many keys mapping in `ANY RIGHT JOIN` operations. +- Results of `ANY INNER JOIN` operations contain one row per key from both left and right tables. + +Possible values: + +- 0 — Legacy behavior is disabled. +- 1 — Legacy behavior is enabled. + + +Default value: 0. + +See also: + +- [JOIN strictness](../../sql-reference/statements/select/join.md#select-join-strictness) + + +## temporary_files_codec {#temporary_files_codec} + +Sets compression codec for temporary files used in sorting and joining operations on disk. + +Possible values: + +- LZ4 — [LZ4](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm)) compression is applied. +- NONE — No compression is applied. + +Default value: LZ4. + + ## max\_block\_size {#setting-max_block_size} In ClickHouse, data is processed by blocks (sets of column parts). The internal processing cycles for a single block are efficient enough, but there are noticeable expenditures on each block. The `max_block_size` setting is a recommendation for what size of the block (in a count of rows) to load from tables. The block size shouldn’t be too small, so that the expenditures on each block are still noticeable, but not too large so that the query with LIMIT that is completed after the first block is processed quickly. The goal is to avoid consuming too much memory when extracting a large number of columns in multiple threads and to preserve at least some cache locality. @@ -425,7 +503,7 @@ By default: 1,000,000. It only works when reading from MergeTree engines. ## merge\_tree\_min\_rows\_for\_concurrent\_read {#setting-merge-tree-min-rows-for-concurrent-read} -If the number of rows to be read from a file of a [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) table exceeds `merge_tree_min_rows_for_concurrent_read` then ClickHouse tries to perform a concurrent reading from this file on several threads. +If the number of rows to be read from a file of a [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) table exceeds `merge_tree_min_rows_for_concurrent_read` then ClickHouse tries to perform a concurrent reading from this file on several threads. Possible values: @@ -435,7 +513,7 @@ Default value: 163840. ## merge\_tree\_min\_bytes\_for\_concurrent\_read {#setting-merge-tree-min-bytes-for-concurrent-read} -If the number of bytes to read from one file of a [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)-engine table exceeds `merge_tree_min_bytes_for_concurrent_read`, then ClickHouse tries to concurrently read from this file in several threads. +If the number of bytes to read from one file of a [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine table exceeds `merge_tree_min_bytes_for_concurrent_read`, then ClickHouse tries to concurrently read from this file in several threads. Possible value: @@ -477,7 +555,7 @@ Default value: 8. If ClickHouse should read more than `merge_tree_max_rows_to_use_cache` rows in one query, it doesn’t use the cache of uncompressed blocks. -The cache of uncompressed blocks stores data extracted for queries. ClickHouse uses this cache to speed up responses to repeated small queries. This setting protects the cache from trashing by queries that read a large amount of data. The [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks. +The cache of uncompressed blocks stores data extracted for queries. ClickHouse uses this cache to speed up responses to repeated small queries. This setting protects the cache from trashing by queries that read a large amount of data. The [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks. Possible values: @@ -489,7 +567,7 @@ Default value: 128 ✕ 8192. If ClickHouse should read more than `merge_tree_max_bytes_to_use_cache` bytes in one query, it doesn’t use the cache of uncompressed blocks. -The cache of uncompressed blocks stores data extracted for queries. ClickHouse uses this cache to speed up responses to repeated small queries. This setting protects the cache from trashing by queries that read a large amount of data. The [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks. +The cache of uncompressed blocks stores data extracted for queries. ClickHouse uses this cache to speed up responses to repeated small queries. This setting protects the cache from trashing by queries that read a large amount of data. The [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks. Possible value: @@ -514,7 +592,7 @@ Default value: 0. Setting up query logging. -Queries sent to ClickHouse with this setup are logged according to the rules in the [query\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server configuration parameter. +Queries sent to ClickHouse with this setup are logged according to the rules in the [query\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query-log) server configuration parameter. Example: @@ -544,7 +622,7 @@ log_queries_min_type='EXCEPTION_WHILE_PROCESSING' Setting up query threads logging. -Queries’ threads runned by ClickHouse with this setup are logged according to the rules in the [query\_thread\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) server configuration parameter. +Queries’ threads runned by ClickHouse with this setup are logged according to the rules in the [query\_thread\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) server configuration parameter. Example: @@ -564,31 +642,31 @@ Default value: 1,048,576. The default is slightly more than `max_block_size`. The reason for this is because certain table engines (`*MergeTree`) form a data part on the disk for each inserted block, which is a fairly large entity. Similarly, `*MergeTree` tables sort data during insertion and a large enough block size allow sorting more data in RAM. -## min_insert_block_size_rows {#min-insert-block-size-rows} +## min\_insert\_block\_size\_rows {#min-insert-block-size-rows} Sets minimum number of rows in block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones. Possible values: -- Positive integer. -- 0 — Squashing disabled. +- Positive integer. +- 0 — Squashing disabled. Default value: 1048576. -## min_insert_block_size_bytes {#min-insert-block-size-bytes} +## min\_insert\_block\_size\_bytes {#min-insert-block-size-bytes} Sets minimum number of bytes in block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones. Possible values: -- Positive integer. -- 0 — Squashing disabled. +- Positive integer. +- 0 — Squashing disabled. Default value: 268435456. ## max\_replica\_delay\_for\_distributed\_queries {#settings-max_replica_delay_for_distributed_queries} -Disables lagging replicas for distributed queries. See [Replication](../../engines/table_engines/mergetree_family/replication.md). +Disables lagging replicas for distributed queries. See [Replication](../../engines/table-engines/mergetree-family/replication.md). Sets the time in seconds. If a replica lags more than the set value, this replica is not used. @@ -633,7 +711,7 @@ Don’t confuse blocks for compression (a chunk of memory consisting of bytes) w ## min\_compress\_block\_size {#min-compress-block-size} -For [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)" tables. In order to reduce latency when processing queries, a block is compressed when writing the next mark if its size is at least ‘min\_compress\_block\_size’. By default, 65,536. +For [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)" tables. In order to reduce latency when processing queries, a block is compressed when writing the next mark if its size is at least ‘min\_compress\_block\_size’. By default, 65,536. The actual size of the block, if the uncompressed data is less than ‘max\_compress\_block\_size’, is no less than this value and no less than the volume of data for one mark. @@ -711,7 +789,7 @@ For more information, see the section “Extreme values”. ## use\_uncompressed\_cache {#setting-use_uncompressed_cache} Whether to use a cache of uncompressed blocks. Accepts 0 or 1. By default, 0 (disabled). -Using the uncompressed cache (only for tables in the MergeTree family) can significantly reduce latency and increase throughput when working with a large number of short queries. Enable this setting for users who send frequent short requests. Also pay attention to the [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. +Using the uncompressed cache (only for tables in the MergeTree family) can significantly reduce latency and increase throughput when working with a large number of short queries. Enable this setting for users who send frequent short requests. Also pay attention to the [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. For queries that read at least a somewhat large volume of data (one million rows or more), the uncompressed cache is disabled automatically to save space for truly small queries. This means that you can keep the ‘use\_uncompressed\_cache’ setting always set to 1. @@ -877,10 +955,10 @@ ClickHouse generates an exception See also: -- [insert\_quorum\_timeout](#settings-insert_quorum_timeout) -- [select\_sequential\_consistency](#settings-select_sequential_consistency) +- [insert_quorum_timeout](#settings-insert_quorum_timeout) +- [select_sequential_consistency](#settings-select_sequential_consistency) -## insert\_quorum\_timeout {#settings-insert_quorum-timeout} +## insert_quorum_timeout {#settings-insert_quorum_timeout} Write to quorum timeout in seconds. If the timeout has passed and no write has taken place yet, ClickHouse will generate an exception and the client must repeat the query to write the same block to the same or any other replica. @@ -908,8 +986,8 @@ When sequential consistency is enabled, ClickHouse allows the client to execute See also: -- [insert\_quorum](#settings-insert_quorum) -- [insert\_quorum\_timeout](#settings-insert_quorum_timeout) +- [insert_quorum](#settings-insert_quorum) +- [insert_quorum_timeout](#settings-insert_quorum_timeout) ## insert\_deduplicate {#settings-insert-deduplicate} @@ -922,7 +1000,8 @@ Possible values: Default value: 1. -By default, blocks inserted into replicated tables by the `INSERT` statement are deduplicated (see \[Data Replication\] (../engines/table\_engines/mergetree_family/replication.md). +By default, blocks inserted into replicated tables by the `INSERT` statement are deduplicated (see [Data Replication](../../engines/table-engines/mergetree-family/replication.md)). + ## deduplicate\_blocks\_in\_dependent\_materialized\_views {#settings-deduplicate-blocks-in-dependent-materialized-views} @@ -988,15 +1067,15 @@ Default value: 0. ## count\_distinct\_implementation {#settings-count_distinct_implementation} -Specifies which of the `uniq*` functions should be used to perform the [COUNT(DISTINCT …)](../../sql_reference/aggregate_functions/reference.md#agg_function-count) construction. +Specifies which of the `uniq*` functions should be used to perform the [COUNT(DISTINCT …)](../../sql-reference/aggregate-functions/reference.md#agg_function-count) construction. Possible values: -- [uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq) -- [uniqCombined](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined) -- [uniqCombined64](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined64) -- [uniqHLL12](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqhll12) -- [uniqExact](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqexact) +- [uniq](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq) +- [uniqCombined](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined) +- [uniqCombined64](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined64) +- [uniqHLL12](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqhll12) +- [uniqExact](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqexact) Default value: `uniqExact`. @@ -1030,27 +1109,32 @@ Possible values: Default value: 0. -## optimize\_skip\_unused\_shards {#settings-optimize_skip_unused_shards} +## optimize_skip_unused_shards {#optimize-skip-unused-shards} -Enables or disables skipping of unused shards for SELECT queries that have sharding key condition in PREWHERE/WHERE (assumes that the data is distributed by sharding key, otherwise do nothing). - -Default value: 0 - -## force\_optimize\_skip\_unused\_shards {#settings-force_optimize_skip_unused_shards} - -Enables or disables query execution if [`optimize_skip_unused_shards`](#settings-optimize_skip_unused_shards) enabled and skipping of unused shards is not possible. If the skipping is not possible and the setting is enabled exception will be thrown. +Enables or disables skipping of unused shards for [SELECT](../../sql-reference/statements/select/index.md) queries that have sharding key condition in `WHERE/PREWHERE` (assuming that the data is distributed by sharding key, otherwise does nothing). Possible values: -- 0 - Disabled (do not throws) -- 1 - Disable query execution only if the table has sharding key -- 2 - Disable query execution regardless sharding key is defined for the table +- 0 — Disabled. +- 1 — Enabled. + +Default value: 0 + +## force_optimize_skip_unused_shards {#force-optimize-skip-unused-shards} + +Enables or disables query execution if [optimize_skip_unused_shards](#optimize-skip-unused-shards) is enabled and skipping of unused shards is not possible. If the skipping is not possible and the setting is enabled, an exception will be thrown. + +Possible values: + +- 0 — Disabled. ClickHouse doesn't throw an exception. +- 1 — Enabled. Query execution is disabled only if the table has a sharding key. +- 2 — Enabled. Query execution is disabled regardless of whether a sharding key is defined for the table. Default value: 0 ## force\_optimize\_skip\_unused\_shards\_no\_nested {#settings-force_optimize_skip_unused_shards_no_nested} -Reset [`optimize_skip_unused_shards`](#settings-force_optimize_skip_unused_shards) for nested `Distributed` table +Reset [`optimize_skip_unused_shards`](#optimize-skip-unused-shards) for nested `Distributed` table Possible values: @@ -1061,7 +1145,7 @@ Default value: 0. ## optimize\_throw\_if\_noop {#setting-optimize_throw_if_noop} -Enables or disables throwing an exception if an [OPTIMIZE](../../sql_reference/statements/misc.md#misc_operations-optimize) query didn’t perform a merge. +Enables or disables throwing an exception if an [OPTIMIZE](../../sql-reference/statements/misc.md#misc_operations-optimize) query didn’t perform a merge. By default, `OPTIMIZE` returns successfully even if it didn’t do anything. This setting lets you differentiate these situations and get the reason in an exception message. @@ -1081,7 +1165,7 @@ Controls how fast errors in distributed tables are zeroed. If a replica is unava See also: -- [Table engine Distributed](../../engines/table_engines/special/distributed.md) +- [Table engine Distributed](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_cap](#settings-distributed_replica_error_cap) ## distributed\_replica\_error\_cap {#settings-distributed_replica_error_cap} @@ -1093,12 +1177,12 @@ Error count of each replica is capped at this value, preventing a single replica See also: -- [Table engine Distributed](../../engines/table_engines/special/distributed.md) +- [Table engine Distributed](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_half\_life](#settings-distributed_replica_error_half_life) ## distributed\_directory\_monitor\_sleep\_time\_ms {#distributed_directory_monitor_sleep_time_ms} -Base interval for the [Distributed](../../engines/table_engines/special/distributed.md) table engine to send data. The actual interval grows exponentially in the event of errors. +Base interval for the [Distributed](../../engines/table-engines/special/distributed.md) table engine to send data. The actual interval grows exponentially in the event of errors. Possible values: @@ -1108,7 +1192,7 @@ Default value: 100 milliseconds. ## distributed\_directory\_monitor\_max\_sleep\_time\_ms {#distributed_directory_monitor_max_sleep_time_ms} -Maximum interval for the [Distributed](../../engines/table_engines/special/distributed.md) table engine to send data. Limits exponential growth of the interval set in the [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) setting. +Maximum interval for the [Distributed](../../engines/table-engines/special/distributed.md) table engine to send data. Limits exponential growth of the interval set in the [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) setting. Possible values: @@ -1120,7 +1204,7 @@ Default value: 30000 milliseconds (30 seconds). Enables/disables sending of inserted data in batches. -When batch sending is enabled, the [Distributed](../../engines/table_engines/special/distributed.md) table engine tries to send multiple files of inserted data in one operation instead of sending them separately. Batch sending improves cluster performance by better-utilizing server and network resources. +When batch sending is enabled, the [Distributed](../../engines/table-engines/special/distributed.md) table engine tries to send multiple files of inserted data in one operation instead of sending them separately. Batch sending improves cluster performance by better-utilizing server and network resources. Possible values: @@ -1146,7 +1230,7 @@ Default value: 0. ## query\_profiler\_real\_time\_period\_ns {#query_profiler_real_time_period_ns} -Sets the period for a real clock timer of the [query profiler](../../operations/optimizing_performance/sampling_query_profiler.md). Real clock timer counts wall-clock time. +Sets the period for a real clock timer of the [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md). Real clock timer counts wall-clock time. Possible values: @@ -1159,17 +1243,17 @@ Possible values: - 0 for turning off the timer. -Type: [UInt64](../../sql_reference/data_types/int_uint.md). +Type: [UInt64](../../sql-reference/data-types/int-uint.md). Default value: 1000000000 nanoseconds (once a second). See also: -- System table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- System table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## query\_profiler\_cpu\_time\_period\_ns {#query_profiler_cpu_time_period_ns} -Sets the period for a CPU clock timer of the [query profiler](../../operations/optimizing_performance/sampling_query_profiler.md). This timer counts only CPU time. +Sets the period for a CPU clock timer of the [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md). This timer counts only CPU time. Possible values: @@ -1182,17 +1266,17 @@ Possible values: - 0 for turning off the timer. -Type: [UInt64](../../sql_reference/data_types/int_uint.md). +Type: [UInt64](../../sql-reference/data-types/int-uint.md). Default value: 1000000000 nanoseconds. See also: -- System table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- System table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## allow\_introspection\_functions {#settings-allow_introspection_functions} -Enables of disables [introspections functions](../../sql_reference/functions/introspection.md) for query profiling. +Enables of disables [introspections functions](../../sql-reference/functions/introspection.md) for query profiling. Possible values: @@ -1203,8 +1287,8 @@ Default value: 0. **See Also** -- [Sampling Query Profiler](../optimizing_performance/sampling_query_profiler.md) -- System table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- [Sampling Query Profiler](../optimizing-performance/sampling-query-profiler.md) +- System table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## input\_format\_parallel\_parsing {#input-format-parallel-parsing} @@ -1252,4 +1336,114 @@ Type: URL Default value: Empty +## background_pool_size {#background_pool_size} + +Sets the number of threads performing background operations in table engines (for example, merges in [MergeTree engine](../../engines/table-engines/mergetree-family/index.md) tables). This setting is applied from `default` profile at ClickHouse server start and can’t be changed in a user session. By adjusting this setting, you manage CPU and disk load. Smaller pool size utilizes less CPU and disk resources, but background processes advance slower which might eventually impact query performance. + +Before changing it, please also take a look at related [MergeTree settings](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree), such as `number_of_free_entries_in_pool_to_lower_max_size_of_merge` and `number_of_free_entries_in_pool_to_execute_mutation`. + +Possible values: + +- Any positive integer. + +Default value: 16. + +## background_buffer_flush_schedule_pool_size {#background_buffer_flush_schedule_pool_size} + +Sets the number of threads performing background flush in [Buffer](../../engines/table-engines/special/buffer.md)-engine tables. This setting is applied at ClickHouse server start and can't be changed in a user session. + +Possible values: + +- Any positive integer. + +Default value: 16. + +## background_move_pool_size {#background_move_pool_size} + +Sets the number of threads performing background moves of data parts for [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes)-engine tables. This setting is applied at ClickHouse server start and can’t be changed in a user session. + +Possible values: + +- Any positive integer. + +Default value: 8. + +## background_schedule_pool_size {#background_schedule_pool_size} + +Sets the number of threads performing background tasks for [replicated](../../engines/table-engines/mergetree-family/replication.md) tables, [Kafka](../../engines/table-engines/integrations/kafka.md) streaming, [DNS cache updates](../server-configuration-parameters/settings.md#server-settings-dns-cache-update-period). This setting is applied at ClickHouse server start and can’t be changed in a user session. + +Possible values: + +- Any positive integer. + +Default value: 16. + +## background_distributed_schedule_pool_size {#background_distributed_schedule_pool_size} + +Sets the number of threads performing background tasks for [distributed](../../engines/table-engines/special/distributed.md) sends. This setting is applied at ClickHouse server start and can’t be changed in a user session. + +Possible values: + +- Any positive integer. + +Default value: 16. + +## low_cardinality_max_dictionary_size {#low_cardinality_max_dictionary_size} + +Sets a maximum size in rows of a shared global dictionary for the [LowCardinality](../../sql-reference/data-types/lowcardinality.md) data type that can be written to a storage file system. This setting prevents issues with RAM in case of unlimited dictionary growth. All the data that can't be encoded due to maximum dictionary size limitation ClickHouse writes in an ordinary method. + +Possible values: + +- Any positive integer. + +Default value: 8192. + +## low_cardinality_use_single_dictionary_for_part {#low_cardinality_use_single_dictionary_for_part} + +Turns on or turns off using of single dictionary for the data part. + +By default, ClickHouse server monitors the size of dictionaries and if a dictionary overflows then the server starts to write the next one. To prohibit creating several dictionaries set `low_cardinality_use_single_dictionary_for_part = 1`. + +Possible values: + +- 1 — Creating several dictionaries for the data part is prohibited. +- 0 — Creating several dictionaries for the data part is not prohibited. + +Default value: 0. + +## low_cardinality_allow_in_native_format {#low_cardinality_allow_in_native_format} + +Allows or restricts using the [LowCardinality](../../sql-reference/data-types/lowcardinality.md) data type with the [Native](../../interfaces/formats.md#native) format. + +If usage of `LowCardinality` is restricted, ClickHouse server converts `LowCardinality`-columns to ordinary ones for `SELECT` queries, and convert ordinary columns to `LowCardinality`-columns for `INSERT` queries. + +This setting is required mainly for third-party clients which don't support `LowCardinality` data type. + +Possible values: + +- 1 — Usage of `LowCardinality` is not restricted. +- 0 — Usage of `LowCardinality` is restricted. + +Default value: 1. + + +## allow_suspicious_low_cardinality_types {#allow_suspicious_low_cardinality_types} + +Allows or restricts using [LowCardinality](../../sql-reference/data-types/lowcardinality.md) with data types with fixed size of 8 bytes or less: numeric data types and `FixedString(8_bytes_or_less)`. + +For small fixed values using of `LowCardinality` is usually inefficient, because ClickHouse stores a numeric index for each row. As a result: + +- Disk space usage can rise. +- RAM consumption can be higher, depending on a dictionary size. +- Some functions can work slower due to extra coding/encoding operations. + +Merge times in [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine tables can grow due to all the reasons described above. + +Possible values: + +- 1 — Usage of `LowCardinality` is not restricted. +- 0 — Usage of `LowCardinality` is restricted. + +Default value: 0. + [Original article](https://clickhouse.tech/docs/en/operations/settings/settings/) diff --git a/docs/en/operations/settings/settings_profiles.md b/docs/en/operations/settings/settings_profiles.md deleted file mode 100644 index ee7aef922ea..00000000000 --- a/docs/en/operations/settings/settings_profiles.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -toc_priority: 61 -toc_title: Settings Profiles ---- - -# Settings Profiles {#settings-profiles} - -A settings profile is a collection of settings grouped under the same name. Each ClickHouse user has a profile. -To apply all the settings in a profile, set the `profile` setting. - -Example: - -Install the `web` profile. - -``` sql -SET profile = 'web' -``` - -Settings profiles are declared in the user config file. This is usually `users.xml`. - -Example: - -``` xml - - - - - - 8 - - - - - 1000000000 - 100000000000 - - 1000000 - any - - 1000000 - 1000000000 - - 100000 - 100000000 - break - - 600 - 1000000 - 15 - - 25 - 100 - 50 - - 2 - 25 - 50 - 100 - - 1 - - -``` - -The example specifies two profiles: `default` and `web`. The `default` profile has a special purpose: it must always be present and is applied when starting the server. In other words, the `default` profile contains default settings. The `web` profile is a regular profile that can be set using the `SET` query or using a URL parameter in an HTTP query. - -Settings profiles can inherit from each other. To use inheritance, indicate one or multiple `profile` settings before the other settings that are listed in the profile. In case when one setting is defined in different profiles, the latest defined is used. - -[Original article](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/en/operations/settings/settings_users.md b/docs/en/operations/settings/settings_users.md deleted file mode 100644 index 4b398796ea8..00000000000 --- a/docs/en/operations/settings/settings_users.md +++ /dev/null @@ -1,146 +0,0 @@ ---- -toc_priority: 63 -toc_title: User Settings ---- - -# User Settings {#user-settings} - -The `users` section of the `user.xml` configuration file contains user settings. - -Structure of the `users` section: - -``` xml - - - - - - - - - - - profile_name - - default - - - - - expression - - - - - - -``` - -### user\_name/password {#user-namepassword} - -Password can be specified in plaintext or in SHA256 (hex format). - -- To assign a password in plaintext (**not recommended**), place it in a `password` element. - - For example, `qwerty`. The password can be left blank. - - - -- To assign a password using its SHA256 hash, place it in a `password_sha256_hex` element. - - For example, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. - - Example of how to generate a password from shell: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' - - The first line of the result is the password. The second line is the corresponding SHA256 hash. - - - -- For compatibility with MySQL clients, password can be specified in double SHA1 hash. Place it in `password_double_sha1_hex` element. - - For example, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. - - Example of how to generate a password from shell: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' - - The first line of the result is the password. The second line is the corresponding double SHA1 hash. - -### user\_name/networks {#user-namenetworks} - -List of networks from which the user can connect to the ClickHouse server. - -Each element of the list can have one of the following forms: - -- `` — IP address or network mask. - - Examples: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. - -- `` — Hostname. - - Example: `example01.host.ru`. - - To check access, a DNS query is performed, and all returned IP addresses are compared to the peer address. - -- `` — Regular expression for hostnames. - - Example, `^example\d\d-\d\d-\d\.host\.ru$` - - To check access, a [DNS PTR query](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) is performed for the peer address and then the specified regexp is applied. Then, another DNS query is performed for the results of the PTR query and all the received addresses are compared to the peer address. We strongly recommend that regexp ends with $. - -All results of DNS requests are cached until the server restarts. - -**Examples** - -To open access for user from any network, specify: - -``` xml -::/0 -``` - -!!! warning "Warning" - It’s insecure to open access from any network unless you have a firewall properly configured or the server is not directly connected to Internet. - -To open access only from localhost, specify: - -``` xml -::1 -127.0.0.1 -``` - -### user\_name/profile {#user-nameprofile} - -You can assign a settings profile for the user. Settings profiles are configured in a separate section of the `users.xml` file. For more information, see [Profiles of Settings](settings_profiles.md). - -### user\_name/quota {#user-namequota} - -Quotas allow you to track or limit resource usage over a period of time. Quotas are configured in the `quotas` -section of the `users.xml` configuration file. - -You can assign a quotas set for the user. For a detailed description of quotas configuration, see [Quotas](../quotas.md#quotas). - -### user\_name/databases {#user-namedatabases} - -In this section, you can you can limit rows that are returned by ClickHouse for `SELECT` queries made by the current user, thus implementing basic row-level security. - -**Example** - -The following configuration forces that user `user1` can only see the rows of `table1` as the result of `SELECT` queries, where the value of the `id` field is 1000. - -``` xml - - - - - id = 1000 - - - - -``` - -The `filter` can be any expression resulting in a [UInt8](../../sql_reference/data_types/int_uint.md)-type value. It usually contains comparisons and logical operators. Rows from `database_name.table1` where filter results to 0 are not returned for this user. The filtering is incompatible with `PREWHERE` operations and disables `WHERE→PREWHERE` optimization. - -[Original article](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/en/operations/system-tables.md b/docs/en/operations/system-tables.md new file mode 100644 index 00000000000..28f448b632c --- /dev/null +++ b/docs/en/operations/system-tables.md @@ -0,0 +1,1342 @@ +--- +toc_priority: 52 +toc_title: System Tables +--- + +# System Tables {#system-tables} + +## Introduction {#system-tables-introduction} + +System tables provide information about: + +- Server states, processes, and environment. +- Server's internal processes. + +System tables: + +- Located in the `system` database. +- Available only for reading data. +- Can't be dropped or altered, but can be detached. + +Most of system tables store their data in RAM. A ClickHouse server creates such system tables at the start. + +Unlike other system tables, the system tables [metric_log](#system_tables-metric_log), [query_log](#system_tables-query_log), [query_thread_log](#system_tables-query_thread_log), [trace_log](#system_tables-trace_log) are served by [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) table engine and store their data in a storage filesystem. If you remove a table from a filesystem, the ClickHouse server creates the empty one again at the time of the next data writing. If system table schema changed in a new release, then ClickHouse renames the current table and creates a new one. + +By default, table growth is unlimited. To control a size of a table, you can use [TTL](../sql-reference/statements/alter.md#manipulations-with-table-ttl) settings for removing outdated log records. Also you can use the partitioning feature of `MergeTree`-engine tables. + + +### Sources of System Metrics {#system-tables-sources-of-system-metrics} + +For collecting system metrics ClickHouse server uses: + +- `CAP_NET_ADMIN` capability. +- [procfs](https://en.wikipedia.org/wiki/Procfs) (only in Linux). + +**procfs** + +If ClickHouse server doesn't have `CAP_NET_ADMIN` capability, it tries to fall back to `ProcfsMetricsProvider`. `ProcfsMetricsProvider` allows collecting per-query system metrics (for CPU and I/O). + +If procfs is supported and enabled on the system, ClickHouse server collects these metrics: + +- `OSCPUVirtualTimeMicroseconds` +- `OSCPUWaitMicroseconds` +- `OSIOWaitMicroseconds` +- `OSReadChars` +- `OSWriteChars` +- `OSReadBytes` +- `OSWriteBytes` + +## system.asynchronous\_metrics {#system_tables-asynchronous_metrics} + +Contains metrics that are calculated periodically in the background. For example, the amount of RAM in use. + +Columns: + +- `metric` ([String](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Float64](../sql-reference/data-types/float.md)) — Metric value. + +**Example** + +``` sql +SELECT * FROM system.asynchronous_metrics LIMIT 10 +``` + +``` text +┌─metric──────────────────────────────────┬──────value─┐ +│ jemalloc.background_thread.run_interval │ 0 │ +│ jemalloc.background_thread.num_runs │ 0 │ +│ jemalloc.background_thread.num_threads │ 0 │ +│ jemalloc.retained │ 422551552 │ +│ jemalloc.mapped │ 1682989056 │ +│ jemalloc.resident │ 1656446976 │ +│ jemalloc.metadata_thp │ 0 │ +│ jemalloc.metadata │ 10226856 │ +│ UncompressedCacheCells │ 0 │ +│ MarkCacheFiles │ 0 │ +└─────────────────────────────────────────┴────────────┘ +``` + +**See Also** + +- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. +- [system.metrics](#system_tables-metrics) — Contains instantly calculated metrics. +- [system.events](#system_tables-events) — Contains a number of events that have occurred. +- [system.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. + +## system.asynchronous_metric_log {#system-tables-async-log} + +Contains the historical values for `system.asynchronous_log` (see [system.asynchronous_metrics](#system_tables-asynchronous_metrics)) + +## system.clusters {#system-clusters} + +Contains information about clusters available in the config file and the servers in them. + +Columns: + +- `cluster` (String) — The cluster name. +- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. +- `shard_weight` (UInt32) — The relative weight of the shard when writing data. +- `replica_num` (UInt32) — The replica number in the shard, starting from 1. +- `host_name` (String) — The host name, as specified in the config. +- `host_address` (String) — The host IP address obtained from DNS. +- `port` (UInt16) — The port to use for connecting to the server. +- `user` (String) — The name of the user for connecting to the server. +- `errors_count` (UInt32) - number of times this host failed to reach replica. +- `estimated_recovery_time` (UInt32) - seconds left until replica error count is zeroed and it is considered to be back to normal. + +Please note that `errors_count` is updated once per query to the cluster, but `estimated_recovery_time` is recalculated on-demand. So there could be a case of non-zero `errors_count` and zero `estimated_recovery_time`, that next query will zero `errors_count` and try to use replica as if it has no errors. + +**See also** + +- [Table engine Distributed](../engines/table-engines/special/distributed.md) +- [distributed\_replica\_error\_cap setting](settings/settings.md#settings-distributed_replica_error_cap) +- [distributed\_replica\_error\_half\_life setting](settings/settings.md#settings-distributed_replica_error_half_life) + +## system.columns {#system-columns} + +Contains information about columns in all the tables. + +You can use this table to get information similar to the [DESCRIBE TABLE](../sql-reference/statements/misc.md#misc-describe-table) query, but for multiple tables at once. + +The `system.columns` table contains the following columns (the column type is shown in brackets): + +- `database` (String) — Database name. +- `table` (String) — Table name. +- `name` (String) — Column name. +- `type` (String) — Column type. +- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) for the default value, or an empty string if it is not defined. +- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. +- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. +- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. +- `marks_bytes` (UInt64) — The size of marks, in bytes. +- `comment` (String) — Comment on the column, or an empty string if it is not defined. +- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. +- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. +- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. +- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. + +## system.contributors {#system-contributors} + +Contains information about contributors. All constributors in random order. The order is random at query execution time. + +Columns: + +- `name` (String) — Contributor (author) name from git log. + +**Example** + +``` sql +SELECT * FROM system.contributors LIMIT 10 +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +│ Max Vetrov │ +│ LiuYangkuan │ +│ svladykin │ +│ zamulla │ +│ Šimon Podlipský │ +│ BayoNet │ +│ Ilya Khomutov │ +│ Amy Krishnevsky │ +│ Loud_Scream │ +└──────────────────┘ +``` + +To find out yourself in the table, use a query: + +``` sql +SELECT * FROM system.contributors WHERE name='Olga Khvostikova' +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +└──────────────────┘ +``` + +## system.databases {#system-databases} + +This table contains a single String column called ‘name’ – the name of a database. +Each database that the server knows about has a corresponding entry in the table. +This system table is used for implementing the `SHOW DATABASES` query. + +## system.data_type_families {#system_tables-data_type_families} + +Contains information about supported [data types](../sql-reference/data-types/). + +Columns: + +- `name` ([String](../sql-reference/data-types/string.md)) — Data type name. +- `case_insensitive` ([UInt8](../sql-reference/data-types/int-uint.md)) — Property that shows whether you can use a data type name in a query in case insensitive manner or not. For example, `Date` and `date` are both valid. +- `alias_to` ([String](../sql-reference/data-types/string.md)) — Data type name for which `name` is an alias. + +**Example** + +``` sql +SELECT * FROM system.data_type_families WHERE alias_to = 'String' +``` + +``` text +┌─name───────┬─case_insensitive─┬─alias_to─┐ +│ LONGBLOB │ 1 │ String │ +│ LONGTEXT │ 1 │ String │ +│ TINYTEXT │ 1 │ String │ +│ TEXT │ 1 │ String │ +│ VARCHAR │ 1 │ String │ +│ MEDIUMBLOB │ 1 │ String │ +│ BLOB │ 1 │ String │ +│ TINYBLOB │ 1 │ String │ +│ CHAR │ 1 │ String │ +│ MEDIUMTEXT │ 1 │ String │ +└────────────┴──────────────────┴──────────┘ +``` + +**See Also** + +- [Syntax](../sql-reference/syntax.md) — Information about supported syntax. + +## system.detached\_parts {#system_tables-detached_parts} + +Contains information about detached parts of [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) tables. The `reason` column specifies why the part was detached. For user-detached parts, the reason is empty. Such parts can be attached with [ALTER TABLE ATTACH PARTITION\|PART](../sql-reference/statements/alter.md#alter_attach-partition) command. For the description of other columns, see [system.parts](#system_tables-parts). If part name is invalid, values of some columns may be `NULL`. Such parts can be deleted with [ALTER TABLE DROP DETACHED PART](../sql-reference/statements/alter.md#alter_drop-detached). + +## system.dictionaries {#system_tables-dictionaries} + +Contains information about [external dictionaries](../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +Columns: + +- `database` ([String](../sql-reference/data-types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries. +- `name` ([String](../sql-reference/data-types/string.md)) — [Dictionary name](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md). +- `status` ([Enum8](../sql-reference/data-types/enum.md)) — Dictionary status. Possible values: + - `NOT_LOADED` — Dictionary was not loaded because it was not used. + - `LOADED` — Dictionary loaded successfully. + - `FAILED` — Unable to load the dictionary as a result of an error. + - `LOADING` — Dictionary is loading now. + - `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../sql-reference/statements/system.md#query_language-system-reload-dictionary) query, timeout, dictionary config has changed). + - `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now. +- `origin` ([String](../sql-reference/data-types/string.md)) — Path to the configuration file that describes the dictionary. +- `type` ([String](../sql-reference/data-types/string.md)) — Type of a dictionary allocation. [Storing Dictionaries in Memory](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md). +- `key` — [Key type](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-key): Numeric Key ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) or Сomposite key ([String](../sql-reference/data-types/string.md)) — form “(type 1, type 2, …, type n)”. +- `attribute.names` ([Array](../sql-reference/data-types/array.md)([String](../sql-reference/data-types/string.md))) — Array of [attribute names](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) provided by the dictionary. +- `attribute.types` ([Array](../sql-reference/data-types/array.md)([String](../sql-reference/data-types/string.md))) — Corresponding array of [attribute types](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) that are provided by the dictionary. +- `bytes_allocated` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary. +- `query_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot. +- `hit_rate` ([Float64](../sql-reference/data-types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache. +- `element_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of items stored in the dictionary. +- `load_factor` ([Float64](../sql-reference/data-types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). +- `source` ([String](../sql-reference/data-types/string.md)) — Text describing the [data source](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md) for the dictionary. +- `lifetime_min` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Minimum [lifetime](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) of the dictionary in memory, after which ClickHouse tries to reload the dictionary (if `invalidate_query` is set, then only if it has changed). Set in seconds. +- `lifetime_max` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Maximum [lifetime](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) of the dictionary in memory, after which ClickHouse tries to reload the dictionary (if `invalidate_query` is set, then only if it has changed). Set in seconds. +- `loading_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Start time for loading the dictionary. +- `last_successful_update_time` ([DateTime](../sql-reference/data-types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes. +- `loading_duration` ([Float32](../sql-reference/data-types/float.md)) — Duration of a dictionary loading. +- `last_exception` ([String](../sql-reference/data-types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn’t be created. + +**Example** + +Configure the dictionary. + +``` sql +CREATE DICTIONARY dictdb.dict +( + `key` Int64 DEFAULT -1, + `value_default` String DEFAULT 'world', + `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) +LIFETIME(MIN 0 MAX 1) +LAYOUT(FLAT()) +``` + +Make sure that the dictionary is loaded. + +``` sql +SELECT * FROM system.dictionaries +``` + +``` text +┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ +│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ +└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ +``` + +## system.events {#system_tables-events} + +Contains information about the number of events that have occurred in the system. For example, in the table, you can find how many `SELECT` queries were processed since the ClickHouse server started. + +Columns: + +- `event` ([String](../sql-reference/data-types/string.md)) — Event name. +- `value` ([UInt64](../sql-reference/data-types/int-uint.md)) — Number of events occurred. +- `description` ([String](../sql-reference/data-types/string.md)) — Event description. + +**Example** + +``` sql +SELECT * FROM system.events LIMIT 5 +``` + +``` text +┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ +│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ +│ FileOpen │ 73 │ Number of files opened. │ +│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ +│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ +└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**See Also** + +- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [system.metrics](#system_tables-metrics) — Contains instantly calculated metrics. +- [system.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. + +## system.functions {#system-functions} + +Contains information about normal and aggregate functions. + +Columns: + +- `name`(`String`) – The name of the function. +- `is_aggregate`(`UInt8`) — Whether the function is aggregate. + +## system.graphite\_retentions {#system-graphite-retentions} + +Contains information about parameters [graphite\_rollup](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) which are used in tables with [\*GraphiteMergeTree](../engines/table-engines/mergetree-family/graphitemergetree.md) engines. + +Columns: + +- `config_name` (String) - `graphite_rollup` parameter name. +- `regexp` (String) - A pattern for the metric name. +- `function` (String) - The name of the aggregating function. +- `age` (UInt64) - The minimum age of the data in seconds. +- `precision` (UInt64) - How precisely to define the age of the data in seconds. +- `priority` (UInt16) - Pattern priority. +- `is_default` (UInt8) - Whether the pattern is the default. +- `Tables.database` (Array(String)) - Array of names of database tables that use the `config_name` parameter. +- `Tables.table` (Array(String)) - Array of table names that use the `config_name` parameter. + +## system.merges {#system-merges} + +Contains information about merges and part mutations currently in process for tables in the MergeTree family. + +Columns: + +- `database` (String) — The name of the database the table is in. +- `table` (String) — Table name. +- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. +- `progress` (Float64) — The percentage of completed work from 0 to 1. +- `num_parts` (UInt64) — The number of pieces to be merged. +- `result_part_name` (String) — The name of the part that will be formed as the result of merging. +- `is_mutation` (UInt8) - 1 if this process is a part mutation. +- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. +- `total_size_marks` (UInt64) — The total number of marks in the merged parts. +- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. +- `rows_read` (UInt64) — Number of rows read. +- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. +- `rows_written` (UInt64) — Number of rows written. + +## system.metrics {#system_tables-metrics} + +Contains metrics which can be calculated instantly, or have a current value. For example, the number of simultaneously processed queries or the current replica delay. This table is always up to date. + +Columns: + +- `metric` ([String](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Int64](../sql-reference/data-types/int-uint.md)) — Metric value. +- `description` ([String](../sql-reference/data-types/string.md)) — Metric description. + +The list of supported metrics you can find in the [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) source file of ClickHouse. + +**Example** + +``` sql +SELECT * FROM system.metrics LIMIT 10 +``` + +``` text +┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 1 │ Number of executing queries │ +│ Merge │ 0 │ Number of executing background merges │ +│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ +│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ +│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ +│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ +│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ +│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ +│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ +│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ +└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**See Also** + +- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [system.events](#system_tables-events) — Contains a number of events that occurred. +- [system.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. + +## system.metric\_log {#system_tables-metric_log} + +Contains history of metrics values from tables `system.metrics` and `system.events`, periodically flushed to disk. +To turn on metrics history collection on `system.metric_log`, create `/etc/clickhouse-server/config.d/metric_log.xml` with following content: + +``` xml + + + system + metric_log
+ 7500 + 1000 +
+
+``` + +**Example** + +``` sql +SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +event_date: 2020-02-18 +event_time: 2020-02-18 07:15:33 +milliseconds: 554 +ProfileEvent_Query: 0 +ProfileEvent_SelectQuery: 0 +ProfileEvent_InsertQuery: 0 +ProfileEvent_FileOpen: 0 +ProfileEvent_Seek: 0 +ProfileEvent_ReadBufferFromFileDescriptorRead: 1 +ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 +ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 +ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 +ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 +ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 +... +CurrentMetric_Query: 0 +CurrentMetric_Merge: 0 +CurrentMetric_PartMutation: 0 +CurrentMetric_ReplicatedFetch: 0 +CurrentMetric_ReplicatedSend: 0 +CurrentMetric_ReplicatedChecks: 0 +... +``` + +**See also** + +- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [system.events](#system_tables-events) — Contains a number of events that occurred. +- [system.metrics](#system_tables-metrics) — Contains instantly calculated metrics. +- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. + +## system.numbers {#system-numbers} + +This table contains a single UInt64 column named ‘number’ that contains almost all the natural numbers starting from zero. +You can use this table for tests, or if you need to do a brute force search. +Reads from this table are not parallelized. + +## system.numbers\_mt {#system-numbers-mt} + +The same as ‘system.numbers’ but reads are parallelized. The numbers can be returned in any order. +Used for tests. + +## system.one {#system-one} + +This table contains a single row with a single ‘dummy’ UInt8 column containing the value 0. +This table is used if a SELECT query doesn’t specify the FROM clause. +This is similar to the DUAL table found in other DBMSs. + +## system.parts {#system_tables-parts} + +Contains information about parts of [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) tables. + +Each row describes one data part. + +Columns: + +- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql-reference/statements/alter.md#query_language_queries_alter) query. + + Formats: + + - `YYYYMM` for automatic partitioning by month. + - `any_string` when partitioning manually. + +- `name` (`String`) – Name of the data part. + +- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it’s used in a table. Otherwise, it’s deleted. Inactive data parts remain after merging. + +- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` by the index granularity (usually 8192) (this hint doesn’t work for adaptive granularity). + +- `rows` (`UInt64`) – The number of rows. + +- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. + +- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `marks_bytes` (`UInt64`) – The size of the file with marks. + +- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| + +- `remove_time` (`DateTime`) – The time when the data part became inactive. + +- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. + +- `min_date` (`Date`) – The minimum value of the date key in the data part. + +- `max_date` (`Date`) – The maximum value of the date key in the data part. + +- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. + +- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. + +- `partition_id` (`String`) – ID of the partition. + +- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. + +- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. + +- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. + +- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). + +- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. + +- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. + +- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn’t exist. For more details, see [FREEZE PARTITION](../sql-reference/statements/alter.md#alter_freeze-partition) + +- `database` (`String`) – Name of the database. + +- `table` (`String`) – Name of the table. + +- `engine` (`String`) – Name of the table engine without parameters. + +- `path` (`String`) – Absolute path to the folder with data part files. + +- `disk` (`String`) – Name of a disk that stores the data part. + +- `hash_of_all_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) of compressed files. + +- `hash_of_uncompressed_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) of uncompressed files (files with marks, index file etc.). + +- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) of data in the compressed files as if they were uncompressed. + +- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. + +- `marks_size` (`UInt64`) – Alias for `marks_bytes`. + +## system.part\_log {#system_tables-part-log} + +The `system.part_log` table is created only if the [part\_log](server-configuration-parameters/settings.md#server_configuration_parameters-part-log) server setting is specified. + +This table contains information about events that occurred with [data parts](../engines/table-engines/mergetree-family/custom-partitioning-key.md) in the [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) family tables, such as adding or merging data. + +The `system.part_log` table contains the following columns: + +- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: + - `NEW_PART` — Inserting of a new data part. + - `MERGE_PARTS` — Merging of data parts. + - `DOWNLOAD_PART` — Downloading a data part. + - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql-reference/statements/alter.md#alter_detach-partition). + - `MUTATE_PART` — Mutating of a data part. + - `MOVE_PART` — Moving the data part from the one disk to another one. +- `event_date` (Date) — Event date. +- `event_time` (DateTime) — Event time. +- `duration_ms` (UInt64) — Duration. +- `database` (String) — Name of the database the data part is in. +- `table` (String) — Name of the table the data part is in. +- `part_name` (String) — Name of the data part. +- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ value if the partitioning is by `tuple()`. +- `rows` (UInt64) — The number of rows in the data part. +- `size_in_bytes` (UInt64) — Size of the data part in bytes. +- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). +- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. +- `read_rows` (UInt64) — The number of rows was read during the merge. +- `read_bytes` (UInt64) — The number of bytes was read during the merge. +- `error` (UInt16) — The code number of the occurred error. +- `exception` (String) — Text message of the occurred error. + +The `system.part_log` table is created after the first inserting data to the `MergeTree` table. + +## system.processes {#system_tables-processes} + +This system table is used for implementing the `SHOW PROCESSLIST` query. + +Columns: + +- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` user. The field contains the username for a specific query, not for a query that this query initiated. +- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` on the query requestor server. +- `elapsed` (Float64) – The time in seconds since request execution started. +- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. +- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../operations/settings/query-complexity.md#settings_max_memory_usage) setting. +- `query` (String) – The query text. For `INSERT`, it doesn’t include the data to insert. +- `query_id` (String) – Query ID, if defined. + +## system.text\_log {#system-tables-text-log} + +Contains logging entries. Logging level which goes to this table can be limited with `text_log.level` server setting. + +Columns: + +- `event_date` (Date) — Date of the entry. +- `event_time` (DateTime) — Time of the entry. +- `microseconds` (UInt32) — Microseconds of the entry. +- `thread_name` (String) — Name of the thread from which the logging was done. +- `thread_id` (UInt64) — OS thread ID. +- `level` (`Enum8`) — Entry level. Possible values: + - `1` or `'Fatal'`. + - `2` or `'Critical'`. + - `3` or `'Error'`. + - `4` or `'Warning'`. + - `5` or `'Notice'`. + - `6` or `'Information'`. + - `7` or `'Debug'`. + - `8` or `'Trace'`. +- `query_id` (String) — ID of the query. +- `logger_name` (LowCardinality(String)) — Name of the logger (i.e. `DDLWorker`). +- `message` (String) — The message itself. +- `revision` (UInt32) — ClickHouse revision. +- `source_file` (LowCardinality(String)) — Source file from which the logging was done. +- `source_line` (UInt64) — Source line from which the logging was done. + +## system.query_log {#system_tables-query_log} + +Contains information about executed queries, for example, start time, duration of processing, error messages. + +!!! note "Note" + The table doesn’t contain input data for `INSERT` queries. + +You can change settings of queries logging in the [query_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) section of the server configuration. + +You can disable queries logging by setting [log_queries = 0](settings/settings.md#settings-log-queries). We don't recommend to turn off logging because information in this table is important for solving issues. + +The flushing period of data is set in `flush_interval_milliseconds` parameter of the [query_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) server settings section. To force flushing, use the [SYSTEM FLUSH LOGS](../sql-reference/statements/system.md#query_language-system-flush_logs) query. + +ClickHouse doesn't delete data from the table automatically. See [Introduction](#system-tables-introduction) for more details. + +The `system.query_log` table registers two kinds of queries: + +1. Initial queries that were run directly by the client. +2. Child queries that were initiated by other queries (for distributed query execution). For these types of queries, information about the parent queries is shown in the `initial_*` columns. + +Each query creates one or two rows in the `query_log` table, depending on the status (see the `type` column) of the query: + +1. If the query execution was successful, two rows with the `QueryStart` and `QueryFinish` types are created . +2. If an error occurred during query processing, two events with the `QueryStart` and `ExceptionWhileProcessing` types are created . +3. If an error occurred before launching the query, a single event with the `ExceptionBeforeStart` type is created. + +Columns: + +- `type` ([Enum8](../sql-reference/data-types/enum.md)) — Type of an event that occurred when executing the query. Values: + - `'QueryStart' = 1` — Successful start of query execution. + - `'QueryFinish' = 2` — Successful end of query execution. + - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. + - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. +- `event_date` ([Date](../sql-reference/data-types/date.md)) — Query starting date. +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Query starting time. +- `query_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Start time of query execution. +- `query_duration_ms` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Duration of query execution in milliseconds. +- `read_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Total number or rows read from all tables and table functions participated in query. It includes usual subqueries, subqueries for `IN` and `JOIN`. For distributed queries `read_rows` includes the total number of rows read at all replicas. Each replica sends it's `read_rows` value, and the server-initiator of the query summarize all received and local values. The cache volumes doesn't affect this value. +- `read_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Total number or bytes read from all tables and table functions participated in query. It includes usual subqueries, subqueries for `IN` and `JOIN`. For distributed queries `read_bytes` includes the total number of rows read at all replicas. Each replica sends it's `read_bytes` value, and the server-initiator of the query summarize all received and local values. The cache volumes doesn't affect this value. +- `written_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0. +- `written_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` queries, the number of written bytes. For other queries, the column value is 0. +- `result_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of rows in a result of the `SELECT` query, or a number of rows in the `INSERT` query. +- `result_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — RAM volume in bytes used to store a query result. +- `memory_usage` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Memory consumption by the query. +- `query` ([String](../sql-reference/data-types/string.md)) — Query string. +- `exception` ([String](../sql-reference/data-types/string.md)) — Exception message. +- `exception_code` ([Int32](../sql-reference/data-types/int-uint.md)) — Code of an exception. +- `stack_trace` ([String](../sql-reference/data-types/string.md)) — [Stack trace](https://en.wikipedia.org/wiki/Stack_trace). An empty string, if the query was completed successfully. +- `is_initial_query` ([UInt8](../sql-reference/data-types/int-uint.md)) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query as part of distributed query execution. +- `user` ([String](../sql-reference/data-types/string.md)) — Name of the user who initiated the current query. +- `query_id` ([String](../sql-reference/data-types/string.md)) — ID of the query. +- `address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP address that was used to make the query. +- `port` ([UInt16](../sql-reference/data-types/int-uint.md)) — The client port that was used to make the query. +- `initial_user` ([String](../sql-reference/data-types/string.md)) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` ([String](../sql-reference/data-types/string.md)) — ID of the initial query (for distributed query execution). +- `initial_address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP address that the parent query was launched from. +- `initial_port` ([UInt16](../sql-reference/data-types/int-uint.md)) — The client port that was used to make the parent query. +- `interface` ([UInt8](../sql-reference/data-types/int-uint.md)) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` ([String](../sql-reference/data-types/string.md)) — Operating system username who runs [clickhouse-client](../interfaces/cli.md). +- `client_hostname` ([String](../sql-reference/data-types/string.md)) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) or another TCP client is run. +- `client_name` ([String](../sql-reference/data-types/string.md)) — The [clickhouse-client](../interfaces/cli.md) or another TCP client name. +- `client_revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — Revision of the [clickhouse-client](../interfaces/cli.md) or another TCP client. +- `client_version_major` ([UInt32](../sql-reference/data-types/int-uint.md)) — Major version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. +- `client_version_minor` ([UInt32](../sql-reference/data-types/int-uint.md)) — Minor version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. +- `client_version_patch` ([UInt32](../sql-reference/data-types/int-uint.md)) — Patch component of the [clickhouse-client](../interfaces/cli.md) or another TCP client version. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` method was used. + - 2 — `POST` method was used. +- `http_user_agent` ([String](../sql-reference/data-types/string.md)) — The `UserAgent` header passed in the HTTP request. +- `quota_key` ([String](../sql-reference/data-types/string.md)) — The “quota key” specified in the [quotas](quotas.md) setting (see `keyed`). +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ClickHouse revision. +- `thread_numbers` ([Array(UInt32)](../sql-reference/data-types/array.md)) — Number of threads that are participating in query execution. +- `ProfileEvents.Names` ([Array(String)](../sql-reference/data-types/array.md)) — Counters that measure different metrics. The description of them could be found in the table [system.events](#system_tables-events) +- `ProfileEvents.Values` ([Array(UInt64)](../sql-reference/data-types/array.md)) — Values of metrics that are listed in the `ProfileEvents.Names` column. +- `Settings.Names` ([Array(String)](../sql-reference/data-types/array.md)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parameter to 1. +- `Settings.Values` ([Array(String)](../sql-reference/data-types/array.md)) — Values of settings that are listed in the `Settings.Names` column. + +**Example** + +``` sql +SELECT * FROM system.query_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +type: QueryStart +event_date: 2020-05-13 +event_time: 2020-05-13 14:02:28 +query_start_time: 2020-05-13 14:02:28 +query_duration_ms: 0 +read_rows: 0 +read_bytes: 0 +written_rows: 0 +written_bytes: 0 +result_rows: 0 +result_bytes: 0 +memory_usage: 0 +query: SELECT 1 +exception_code: 0 +exception: +stack_trace: +is_initial_query: 1 +user: default +query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +address: ::ffff:127.0.0.1 +port: 57720 +initial_user: default +initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +initial_address: ::ffff:127.0.0.1 +initial_port: 57720 +interface: 1 +os_user: bayonet +client_hostname: clickhouse.ru-central1.internal +client_name: ClickHouse client +client_revision: 54434 +client_version_major: 20 +client_version_minor: 4 +client_version_patch: 1 +http_method: 0 +http_user_agent: +quota_key: +revision: 54434 +thread_ids: [] +ProfileEvents.Names: [] +ProfileEvents.Values: [] +Settings.Names: ['use_uncompressed_cache','load_balancing','log_queries','max_memory_usage'] +Settings.Values: ['0','random','1','10000000000'] + +``` +**See Also** + +- [system.query_thread_log](#system_tables-query_thread_log) — This table contains information about each query execution thread. + +## system.query_thread_log {#system_tables-query_thread_log} + +Contains information about threads which execute queries, for example, thread name, thread start time, duration of query processing. + +To start logging: + +1. Configure parameters in the [query_thread_log](server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) section. +2. Set [log_query_threads](settings/settings.md#settings-log-query-threads) to 1. + +The flushing period of data is set in `flush_interval_milliseconds` parameter of the [query_thread_log](server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) server settings section. To force flushing, use the [SYSTEM FLUSH LOGS](../sql-reference/statements/system.md#query_language-system-flush_logs) query. + +ClickHouse doesn't delete data from the table automatically. See [Introduction](#system-tables-introduction) for more details. + +Columns: + +- `event_date` ([Date](../sql-reference/data-types/date.md)) — The date when the thread has finished execution of the query. +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — The date and time when the thread has finished execution of the query. +- `query_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Start time of query execution. +- `query_duration_ms` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Duration of query execution. +- `read_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of read rows. +- `read_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of read bytes. +- `written_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0. +- `written_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` queries, the number of written bytes. For other queries, the column value is 0. +- `memory_usage` ([Int64](../sql-reference/data-types/int-uint.md)) — The difference between the amount of allocated and freed memory in context of this thread. +- `peak_memory_usage` ([Int64](../sql-reference/data-types/int-uint.md)) — The maximum difference between the amount of allocated and freed memory in context of this thread. +- `thread_name` ([String](../sql-reference/data-types/string.md)) — Name of the thread. +- `thread_number` ([UInt32](../sql-reference/data-types/int-uint.md)) — Internal thread ID. +- `thread_id` ([Int32](../sql-reference/data-types/int-uint.md)) — thread ID. +- `master_thread_id` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — OS initial ID of initial thread. +- `query` ([String](../sql-reference/data-types/string.md)) — Query string. +- `is_initial_query` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` ([String](../sql-reference/data-types/string.md)) — Name of the user who initiated the current query. +- `query_id` ([String](../sql-reference/data-types/string.md)) — ID of the query. +- `address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP address that was used to make the query. +- `port` ([UInt16](../sql-reference/data-types/int-uint.md#uint-ranges)) — The client port that was used to make the query. +- `initial_user` ([String](../sql-reference/data-types/string.md)) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` ([String](../sql-reference/data-types/string.md)) — ID of the initial query (for distributed query execution). +- `initial_address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP address that the parent query was launched from. +- `initial_port` ([UInt16](../sql-reference/data-types/int-uint.md#uint-ranges)) — The client port that was used to make the parent query. +- `interface` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` ([String](../sql-reference/data-types/string.md)) — OS’s username who runs [clickhouse-client](../interfaces/cli.md). +- `client_hostname` ([String](../sql-reference/data-types/string.md)) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) or another TCP client is run. +- `client_name` ([String](../sql-reference/data-types/string.md)) — The [clickhouse-client](../interfaces/cli.md) or another TCP client name. +- `client_revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — Revision of the [clickhouse-client](../interfaces/cli.md) or another TCP client. +- `client_version_major` ([UInt32](../sql-reference/data-types/int-uint.md)) — Major version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. +- `client_version_minor` ([UInt32](../sql-reference/data-types/int-uint.md)) — Minor version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. +- `client_version_patch` ([UInt32](../sql-reference/data-types/int-uint.md)) — Patch component of the [clickhouse-client](../interfaces/cli.md) or another TCP client version. +- `http_method` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` method was used. + - 2 — `POST` method was used. +- `http_user_agent` ([String](../sql-reference/data-types/string.md)) — The `UserAgent` header passed in the HTTP request. +- `quota_key` ([String](../sql-reference/data-types/string.md)) — The “quota key” specified in the [quotas](quotas.md) setting (see `keyed`). +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ClickHouse revision. +- `ProfileEvents.Names` ([Array(String)](../sql-reference/data-types/array.md)) — Counters that measure different metrics for this thread. The description of them could be found in the table [system.events](#system_tables-events). +- `ProfileEvents.Values` ([Array(UInt64)](../sql-reference/data-types/array.md)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` column. + +**Example** + +``` sql + SELECT * FROM system.query_thread_log LIMIT 1 FORMAT Vertical +``` + +``` text +Row 1: +────── +event_date: 2020-05-13 +event_time: 2020-05-13 14:02:28 +query_start_time: 2020-05-13 14:02:28 +query_duration_ms: 0 +read_rows: 1 +read_bytes: 1 +written_rows: 0 +written_bytes: 0 +memory_usage: 0 +peak_memory_usage: 0 +thread_name: QueryPipelineEx +thread_id: 28952 +master_thread_id: 28924 +query: SELECT 1 +is_initial_query: 1 +user: default +query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +address: ::ffff:127.0.0.1 +port: 57720 +initial_user: default +initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +initial_address: ::ffff:127.0.0.1 +initial_port: 57720 +interface: 1 +os_user: bayonet +client_hostname: clickhouse.ru-central1.internal +client_name: ClickHouse client +client_revision: 54434 +client_version_major: 20 +client_version_minor: 4 +client_version_patch: 1 +http_method: 0 +http_user_agent: +quota_key: +revision: 54434 +ProfileEvents.Names: ['ContextLock','RealTimeMicroseconds','UserTimeMicroseconds','OSCPUWaitMicroseconds','OSCPUVirtualTimeMicroseconds'] +ProfileEvents.Values: [1,97,81,5,81] +... +``` + +**See Also** + +- [system.query_log](#system_tables-query_log) — Description of the `query_log` system table which contains common information about queries execution. + +## system.trace\_log {#system_tables-trace_log} + +Contains stack traces collected by the sampling query profiler. + +ClickHouse creates this table when the [trace\_log](server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) server configuration section is set. Also the [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) and [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) settings should be set. + +To analyze logs, use the `addressToLine`, `addressToSymbol` and `demangle` introspection functions. + +Columns: + +- `event_date` ([Date](../sql-reference/data-types/date.md)) — Date of sampling moment. + +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Timestamp of the sampling moment. + +- `timestamp_ns` ([UInt64](../sql-reference/data-types/int-uint.md)) — Timestamp of the sampling moment in nanoseconds. + +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ClickHouse server build revision. + + When connecting to server by `clickhouse-client`, you see the string similar to `Connected to ClickHouse server version 19.18.1 revision 54429.`. This field contains the `revision`, but not the `version` of a server. + +- `timer_type` ([Enum8](../sql-reference/data-types/enum.md)) — Timer type: + + - `Real` represents wall-clock time. + - `CPU` represents CPU time. + +- `thread_number` ([UInt32](../sql-reference/data-types/int-uint.md)) — Thread identifier. + +- `query_id` ([String](../sql-reference/data-types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) system table. + +- `trace` ([Array(UInt64)](../sql-reference/data-types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. + +**Example** + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-15 +event_time: 2019-11-15 15:09:38 +revision: 54428 +timer_type: Real +thread_number: 48 +query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 +trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] +``` + +## system.replicas {#system_tables-replicas} + +Contains information and status for replicated tables residing on the local server. +This table can be used for monitoring. The table contains a row for every Replicated\* table. + +Example: + +``` sql +SELECT * +FROM system.replicas +WHERE table = 'visits' +FORMAT Vertical +``` + +``` text +Row 1: +────── +database: merge +table: visits +engine: ReplicatedCollapsingMergeTree +is_leader: 1 +can_become_leader: 1 +is_readonly: 0 +is_session_expired: 0 +future_parts: 1 +parts_to_check: 0 +zookeeper_path: /clickhouse/tables/01-06/visits +replica_name: example01-06-1.yandex.ru +replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru +columns_version: 9 +queue_size: 1 +inserts_in_queue: 0 +merges_in_queue: 1 +part_mutations_in_queue: 0 +queue_oldest_time: 2020-02-20 08:34:30 +inserts_oldest_time: 0000-00-00 00:00:00 +merges_oldest_time: 2020-02-20 08:34:30 +part_mutations_oldest_time: 0000-00-00 00:00:00 +oldest_part_to_get: +oldest_part_to_merge_to: 20200220_20284_20840_7 +oldest_part_to_mutate_to: +log_max_index: 596273 +log_pointer: 596274 +last_queue_update: 2020-02-20 08:34:32 +absolute_delay: 0 +total_replicas: 2 +active_replicas: 2 +``` + +Columns: + +- `database` (`String`) - Database name +- `table` (`String`) - Table name +- `engine` (`String`) - Table engine name +- `is_leader` (`UInt8`) - Whether the replica is the leader. + Only one replica at a time can be the leader. The leader is responsible for selecting background merges to perform. + Note that writes can be performed to any replica that is available and has a session in ZK, regardless of whether it is a leader. +- `can_become_leader` (`UInt8`) - Whether the replica can be elected as a leader. +- `is_readonly` (`UInt8`) - Whether the replica is in read-only mode. + This mode is turned on if the config doesn’t have sections with ZooKeeper, if an unknown error occurred when reinitializing sessions in ZooKeeper, and during session reinitialization in ZooKeeper. +- `is_session_expired` (`UInt8`) - the session with ZooKeeper has expired. Basically the same as `is_readonly`. +- `future_parts` (`UInt32`) - The number of data parts that will appear as the result of INSERTs or merges that haven’t been done yet. +- `parts_to_check` (`UInt32`) - The number of data parts in the queue for verification. A part is put in the verification queue if there is suspicion that it might be damaged. +- `zookeeper_path` (`String`) - Path to table data in ZooKeeper. +- `replica_name` (`String`) - Replica name in ZooKeeper. Different replicas of the same table have different names. +- `replica_path` (`String`) - Path to replica data in ZooKeeper. The same as concatenating ‘zookeeper\_path/replicas/replica\_path’. +- `columns_version` (`Int32`) - Version number of the table structure. Indicates how many times ALTER was performed. If replicas have different versions, it means some replicas haven’t made all of the ALTERs yet. +- `queue_size` (`UInt32`) - Size of the queue for operations waiting to be performed. Operations include inserting blocks of data, merges, and certain other actions. It usually coincides with `future_parts`. +- `inserts_in_queue` (`UInt32`) - Number of inserts of blocks of data that need to be made. Insertions are usually replicated fairly quickly. If this number is large, it means something is wrong. +- `merges_in_queue` (`UInt32`) - The number of merges waiting to be made. Sometimes merges are lengthy, so this value may be greater than zero for a long time. +- `part_mutations_in_queue` (`UInt32`) - The number of mutations waiting to be made. +- `queue_oldest_time` (`DateTime`) - If `queue_size` greater than 0, shows when the oldest operation was added to the queue. +- `inserts_oldest_time` (`DateTime`) - See `queue_oldest_time` +- `merges_oldest_time` (`DateTime`) - See `queue_oldest_time` +- `part_mutations_oldest_time` (`DateTime`) - See `queue_oldest_time` + +The next 4 columns have a non-zero value only where there is an active session with ZK. + +- `log_max_index` (`UInt64`) - Maximum entry number in the log of general activity. +- `log_pointer` (`UInt64`) - Maximum entry number in the log of general activity that the replica copied to its execution queue, plus one. If `log_pointer` is much smaller than `log_max_index`, something is wrong. +- `last_queue_update` (`DateTime`) - When the queue was updated last time. +- `absolute_delay` (`UInt64`) - How big lag in seconds the current replica has. +- `total_replicas` (`UInt8`) - The total number of known replicas of this table. +- `active_replicas` (`UInt8`) - The number of replicas of this table that have a session in ZooKeeper (i.e., the number of functioning replicas). + +If you request all the columns, the table may work a bit slowly, since several reads from ZooKeeper are made for each row. +If you don’t request the last 4 columns (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), the table works quickly. + +For example, you can check that everything is working correctly like this: + +``` sql +SELECT + database, + table, + is_leader, + is_readonly, + is_session_expired, + future_parts, + parts_to_check, + columns_version, + queue_size, + inserts_in_queue, + merges_in_queue, + log_max_index, + log_pointer, + total_replicas, + active_replicas +FROM system.replicas +WHERE + is_readonly + OR is_session_expired + OR future_parts > 20 + OR parts_to_check > 10 + OR queue_size > 20 + OR inserts_in_queue > 10 + OR log_max_index - log_pointer > 10 + OR total_replicas < 2 + OR active_replicas < total_replicas +``` + +If this query doesn’t return anything, it means that everything is fine. + +## system.settings {#system-tables-system-settings} + +Contains information about session settings for current user. + +Columns: + +- `name` ([String](../sql-reference/data-types/string.md)) — Setting name. +- `value` ([String](../sql-reference/data-types/string.md)) — Setting value. +- `changed` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether a setting is changed from its default value. +- `description` ([String](../sql-reference/data-types/string.md)) — Short setting description. +- `min` ([Nullable](../sql-reference/data-types/nullable.md)([String](../sql-reference/data-types/string.md))) — Minimum value of the setting, if any is set via [constraints](settings/constraints-on-settings.md#constraints-on-settings). If the setting has no minimum value, contains [NULL](../sql-reference/syntax.md#null-literal). +- `max` ([Nullable](../sql-reference/data-types/nullable.md)([String](../sql-reference/data-types/string.md))) — Maximum value of the setting, if any is set via [constraints](settings/constraints-on-settings.md#constraints-on-settings). If the setting has no maximum value, contains [NULL](../sql-reference/syntax.md#null-literal). +- `readonly` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether the current user can change the setting: + - `0` — Current user can change the setting. + - `1` — Current user can’t change the setting. + +**Example** + +The following example shows how to get information about settings which name contains `min_i`. + +``` sql +SELECT * +FROM system.settings +WHERE name LIKE '%min_i%' +``` + +``` text +┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ +│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ +``` + +Using of `WHERE changed` can be useful, for example, when you want to check: + +- Whether settings in configuration files are loaded correctly and are in use. +- Settings that changed in the current session. + + + +``` sql +SELECT * FROM system.settings WHERE changed AND name='load_balancing' +``` + +**See also** + +- [Settings](settings/index.md#session-settings-intro) +- [Permissions for Queries](settings/permissions-for-queries.md#settings_readonly) +- [Constraints on Settings](settings/constraints-on-settings.md) + +## system.table\_engines {#system.table_engines} + +``` text +┌─name───────────────────┬─value───────┐ +│ max_threads │ 8 │ +│ use_uncompressed_cache │ 0 │ +│ load_balancing │ random │ +│ max_memory_usage │ 10000000000 │ +└────────────────────────┴─────────────┘ +``` + +## system.merge\_tree\_settings {#system-merge_tree_settings} + +Contains information about settings for `MergeTree` tables. + +Columns: + +- `name` (String) — Setting name. +- `value` (String) — Setting value. +- `description` (String) — Setting description. +- `type` (String) — Setting type (implementation specific string value). +- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. + +## system.table\_engines {#system-table-engines} + +Contains description of table engines supported by server and their feature support information. + +This table contains the following columns (the column type is shown in brackets): + +- `name` (String) — The name of table engine. +- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` clause. +- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [skipping indices](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes). +- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). +- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` and `SAMPLE_BY`. +- `supports_replication` (UInt8) — Flag that indicates if table engine supports [data replication](../engines/table-engines/mergetree-family/replication.md). +- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. + +Example: + +``` sql +SELECT * +FROM system.table_engines +WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') +``` + +``` text +┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ +│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ +│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ +│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ +└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ +``` + +**See also** + +- MergeTree family [query clauses](../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) +- Kafka [settings](../engines/table-engines/integrations/kafka.md#table_engine-kafka-creating-a-table) +- Join [settings](../engines/table-engines/special/join.md#join-limitations-and-settings) + +## system.tables {#system-tables} + +Contains metadata of each table that the server knows about. Detached tables are not shown in `system.tables`. + +This table contains the following columns (the column type is shown in brackets): + +- `database` (String) — The name of the database the table is in. + +- `name` (String) — Table name. + +- `engine` (String) — Table engine name (without parameters). + +- `is_temporary` (UInt8) - Flag that indicates whether the table is temporary. + +- `data_path` (String) - Path to the table data in the file system. + +- `metadata_path` (String) - Path to the table metadata in the file system. + +- `metadata_modification_time` (DateTime) - Time of latest modification of the table metadata. + +- `dependencies_database` (Array(String)) - Database dependencies. + +- `dependencies_table` (Array(String)) - Table dependencies ([MaterializedView](../engines/table-engines/special/materializedview.md) tables based on the current table). + +- `create_table_query` (String) - The query that was used to create the table. + +- `engine_full` (String) - Parameters of the table engine. + +- `partition_key` (String) - The partition key expression specified in the table. + +- `sorting_key` (String) - The sorting key expression specified in the table. + +- `primary_key` (String) - The primary key expression specified in the table. + +- `sampling_key` (String) - The sampling key expression specified in the table. + +- `storage_policy` (String) - The storage policy: + + - [MergeTree](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) + - [Distributed](../engines/table-engines/special/distributed.md#distributed) + +- `total_rows` (Nullable(UInt64)) - Total number of rows, if it is possible to quickly determine exact number of rows in the table, otherwise `Null` (including underying `Buffer` table). + +- `total_bytes` (Nullable(UInt64)) - Total number of bytes, if it is possible to quickly determine exact number of bytes for the table on storage, otherwise `Null` (**does not** includes any underlying storage). + + - If the table stores data on disk, returns used space on disk (i.e. compressed). + - If the table stores data in memory, returns approximated number of used bytes in memory. + +The `system.tables` table is used in `SHOW TABLES` query implementation. + +## system.zookeeper {#system-zookeeper} + +The table does not exist if ZooKeeper is not configured. Allows reading data from the ZooKeeper cluster defined in the config. +The query must have a ‘path’ equality condition in the WHERE clause. This is the path in ZooKeeper for the children that you want to get data for. + +The query `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` outputs data for all children on the `/clickhouse` node. +To output data for all root nodes, write path = ‘/’. +If the path specified in ‘path’ doesn’t exist, an exception will be thrown. + +Columns: + +- `name` (String) — The name of the node. +- `path` (String) — The path to the node. +- `value` (String) — Node value. +- `dataLength` (Int32) — Size of the value. +- `numChildren` (Int32) — Number of descendants. +- `czxid` (Int64) — ID of the transaction that created the node. +- `mzxid` (Int64) — ID of the transaction that last changed the node. +- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. +- `ctime` (DateTime) — Time of node creation. +- `mtime` (DateTime) — Time of the last modification of the node. +- `version` (Int32) — Node version: the number of times the node was changed. +- `cversion` (Int32) — Number of added or removed descendants. +- `aversion` (Int32) — Number of changes to the ACL. +- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. + +Example: + +``` sql +SELECT * +FROM system.zookeeper +WHERE path = '/clickhouse/tables/01-08/visits/replicas' +FORMAT Vertical +``` + +``` text +Row 1: +────── +name: example01-08-1.yandex.ru +value: +czxid: 932998691229 +mzxid: 932998691229 +ctime: 2015-03-27 16:49:51 +mtime: 2015-03-27 16:49:51 +version: 0 +cversion: 47 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021031383 +path: /clickhouse/tables/01-08/visits/replicas + +Row 2: +────── +name: example01-08-2.yandex.ru +value: +czxid: 933002738135 +mzxid: 933002738135 +ctime: 2015-03-27 16:57:01 +mtime: 2015-03-27 16:57:01 +version: 0 +cversion: 37 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021252247 +path: /clickhouse/tables/01-08/visits/replicas +``` + +## system.mutations {#system_tables-mutations} + +The table contains information about [mutations](../sql-reference/statements/alter.md#alter-mutations) of MergeTree tables and their progress. Each mutation command is represented by a single row. The table has the following columns: + +**database**, **table** - The name of the database and table to which the mutation was applied. + +**mutation\_id** - The ID of the mutation. For replicated tables these IDs correspond to znode names in the `/mutations/` directory in ZooKeeper. For unreplicated tables the IDs correspond to file names in the data directory of the table. + +**command** - The mutation command string (the part of the query after `ALTER TABLE [db.]table`). + +**create\_time** - When this mutation command was submitted for execution. + +**block\_numbers.partition\_id**, **block\_numbers.number** - A nested column. For mutations of replicated tables, it contains one record for each partition: the partition ID and the block number that was acquired by the mutation (in each partition, only parts that contain blocks with numbers less than the block number acquired by the mutation in that partition will be mutated). In non-replicated tables, block numbers in all partitions form a single sequence. This means that for mutations of non-replicated tables, the column will contain one record with a single block number acquired by the mutation. + +**parts\_to\_do** - The number of data parts that need to be mutated for the mutation to finish. + +**is\_done** - Is the mutation done? Note that even if `parts_to_do = 0` it is possible that a mutation of a replicated table is not done yet because of a long-running INSERT that will create a new data part that will need to be mutated. + +If there were problems with mutating some parts, the following columns contain additional information: + +**latest\_failed\_part** - The name of the most recent part that could not be mutated. + +**latest\_fail\_time** - The time of the most recent part mutation failure. + +**latest\_fail\_reason** - The exception message that caused the most recent part mutation failure. + +## system.disks {#system_tables-disks} + +Contains information about disks defined in the [server configuration](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Columns: + +- `name` ([String](../sql-reference/data-types/string.md)) — Name of a disk in the server configuration. +- `path` ([String](../sql-reference/data-types/string.md)) — Path to the mount point in the file system. +- `free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Free space on disk in bytes. +- `total_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Disk volume in bytes. +- `keep_free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` parameter of disk configuration. + +## system.storage\_policies {#system_tables-storage_policies} + +Contains information about storage policies and volumes defined in the [server configuration](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Columns: + +- `policy_name` ([String](../sql-reference/data-types/string.md)) — Name of the storage policy. +- `volume_name` ([String](../sql-reference/data-types/string.md)) — Volume name defined in the storage policy. +- `volume_priority` ([UInt64](../sql-reference/data-types/int-uint.md)) — Volume order number in the configuration. +- `disks` ([Array(String)](../sql-reference/data-types/array.md)) — Disk names, defined in the storage policy. +- `max_data_part_size` ([UInt64](../sql-reference/data-types/int-uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). +- `move_factor` ([Float64](../sql-reference/data-types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. + +If the storage policy contains more then one volume, then information for each volume is stored in the individual row of the table. + +[Original article](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/en/operations/system_tables.md b/docs/en/operations/system_tables.md deleted file mode 100644 index 22e688c59cd..00000000000 --- a/docs/en/operations/system_tables.md +++ /dev/null @@ -1,1167 +0,0 @@ ---- -toc_priority: 52 -toc_title: System Tables ---- - -# System Tables {#system-tables} - -System tables are used for implementing part of the system’s functionality, and for providing access to information about how the system is working. -You can’t delete a system table (but you can perform DETACH). -System tables don’t have files with data on the disk or files with metadata. The server creates all the system tables when it starts. -System tables are read-only. -They are located in the ‘system’ database. - -## system.asynchronous\_metrics {#system_tables-asynchronous_metrics} - -Contains metrics that are calculated periodically in the background. For example, the amount of RAM in use. - -Columns: - -- `metric` ([String](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Float64](../sql_reference/data_types/float.md)) — Metric value. - -**Example** - -``` sql -SELECT * FROM system.asynchronous_metrics LIMIT 10 -``` - -``` text -┌─metric──────────────────────────────────┬──────value─┐ -│ jemalloc.background_thread.run_interval │ 0 │ -│ jemalloc.background_thread.num_runs │ 0 │ -│ jemalloc.background_thread.num_threads │ 0 │ -│ jemalloc.retained │ 422551552 │ -│ jemalloc.mapped │ 1682989056 │ -│ jemalloc.resident │ 1656446976 │ -│ jemalloc.metadata_thp │ 0 │ -│ jemalloc.metadata │ 10226856 │ -│ UncompressedCacheCells │ 0 │ -│ MarkCacheFiles │ 0 │ -└─────────────────────────────────────────┴────────────┘ -``` - -**See Also** - -- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. -- [system.metrics](#system_tables-metrics) — Contains instantly calculated metrics. -- [system.events](#system_tables-events) — Contains a number of events that have occurred. -- [system.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. - -## system.clusters {#system-clusters} - -Contains information about clusters available in the config file and the servers in them. - -Columns: - -- `cluster` (String) — The cluster name. -- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. -- `shard_weight` (UInt32) — The relative weight of the shard when writing data. -- `replica_num` (UInt32) — The replica number in the shard, starting from 1. -- `host_name` (String) — The host name, as specified in the config. -- `host_address` (String) — The host IP address obtained from DNS. -- `port` (UInt16) — The port to use for connecting to the server. -- `user` (String) — The name of the user for connecting to the server. -- `errors_count` (UInt32) - number of times this host failed to reach replica. -- `estimated_recovery_time` (UInt32) - seconds left until replica error count is zeroed and it is considered to be back to normal. - -Please note that `errors_count` is updated once per query to the cluster, but `estimated_recovery_time` is recalculated on-demand. So there could be a case of non-zero `errors_count` and zero `estimated_recovery_time`, that next query will zero `errors_count` and try to use replica as if it has no errors. - -**See also** - -- [Table engine Distributed](../engines/table_engines/special/distributed.md) -- [distributed\_replica\_error\_cap setting](settings/settings.md#settings-distributed_replica_error_cap) -- [distributed\_replica\_error\_half\_life setting](settings/settings.md#settings-distributed_replica_error_half_life) - -## system.columns {#system-columns} - -Contains information about columns in all the tables. - -You can use this table to get information similar to the [DESCRIBE TABLE](../sql_reference/statements/misc.md#misc-describe-table) query, but for multiple tables at once. - -The `system.columns` table contains the following columns (the column type is shown in brackets): - -- `database` (String) — Database name. -- `table` (String) — Table name. -- `name` (String) — Column name. -- `type` (String) — Column type. -- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) for the default value, or an empty string if it is not defined. -- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. -- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. -- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. -- `marks_bytes` (UInt64) — The size of marks, in bytes. -- `comment` (String) — Comment on the column, or an empty string if it is not defined. -- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. -- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. -- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. -- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. - -## system.contributors {#system-contributors} - -Contains information about contributors. All constributors in random order. The order is random at query execution time. - -Columns: - -- `name` (String) — Contributor (author) name from git log. - -**Example** - -``` sql -SELECT * FROM system.contributors LIMIT 10 -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -│ Max Vetrov │ -│ LiuYangkuan │ -│ svladykin │ -│ zamulla │ -│ Šimon Podlipský │ -│ BayoNet │ -│ Ilya Khomutov │ -│ Amy Krishnevsky │ -│ Loud_Scream │ -└──────────────────┘ -``` - -To find out yourself in the table, use a query: - -``` sql -SELECT * FROM system.contributors WHERE name='Olga Khvostikova' -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -└──────────────────┘ -``` - -## system.databases {#system-databases} - -This table contains a single String column called ‘name’ – the name of a database. -Each database that the server knows about has a corresponding entry in the table. -This system table is used for implementing the `SHOW DATABASES` query. - -## system.detached\_parts {#system_tables-detached_parts} - -Contains information about detached parts of [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) tables. The `reason` column specifies why the part was detached. For user-detached parts, the reason is empty. Such parts can be attached with [ALTER TABLE ATTACH PARTITION\|PART](../sql_reference/statements/alter.md#alter_attach-partition) command. For the description of other columns, see [system.parts](#system_tables-parts). If part name is invalid, values of some columns may be `NULL`. Such parts can be deleted with [ALTER TABLE DROP DETACHED PART](../sql_reference/statements/alter.md#alter_drop-detached). - -## system.dictionaries {#system_tables-dictionaries} - -Contains information about [external dictionaries](../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -Columns: - -- `database` ([String](../sql_reference/data_types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries. -- `name` ([String](../sql_reference/data_types/string.md)) — [Dictionary name](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md). -- `status` ([Enum8](../sql_reference/data_types/enum.md)) — Dictionary status. Possible values: - - `NOT_LOADED` — Dictionary was not loaded because it was not used. - - `LOADED` — Dictionary loaded successfully. - - `FAILED` — Unable to load the dictionary as a result of an error. - - `LOADING` — Dictionary is loading now. - - `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../sql_reference/statements/system.md#query_language-system-reload-dictionary) query, timeout, dictionary config has changed). - - `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now. -- `origin` ([String](../sql_reference/data_types/string.md)) — Path to the configuration file that describes the dictionary. -- `type` ([String](../sql_reference/data_types/string.md)) — Type of a dictionary allocation. [Storing Dictionaries in Memory](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md). -- `key` — [Key type](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-key): Numeric Key ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) or Сomposite key ([String](../sql_reference/data_types/string.md)) — form "(type 1, type 2, ..., type n)". -- `attribute.names` ([Array](../sql_reference/data_types/array.md)([String](../sql_reference/data_types/string.md))) — Array of [attribute names](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes) provided by the dictionary. -- `attribute.types` ([Array](../sql_reference/data_types/array.md)([String](../sql_reference/data_types/string.md))) — Corresponding array of [attribute types](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes) that are provided by the dictionary. -- `bytes_allocated` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary. -- `query_count` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot. -- `hit_rate` ([Float64](../sql_reference/data_types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache. -- `element_count` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Number of items stored in the dictionary. -- `load_factor` ([Float64](../sql_reference/data_types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). -- `source` ([String](../sql_reference/data_types/string.md)) — Text describing the [data source](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md) for the dictionary. -- `lifetime_min` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Minimum [lifetime](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md) of the dictionary in memory, after which ClickHouse tries to reload the dictionary (if `invalidate_query` is set, then only if it has changed). Set in seconds. -- `lifetime_max` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Maximum [lifetime](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md) of the dictionary in memory, after which ClickHouse tries to reload the dictionary (if `invalidate_query` is set, then only if it has changed). Set in seconds. -- `loading_start_time` ([DateTime](../sql_reference/data_types/datetime.md)) — Start time for loading the dictionary. -- `last_successful_update_time` ([DateTime](../sql_reference/data_types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes. -- `loading_duration` ([Float32](../sql_reference/data_types/float.md)) — Duration of a dictionary loading. -- `last_exception` ([String](../sql_reference/data_types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. - - -**Example** - -Configure the dictionary. - -```sql -CREATE DICTIONARY dictdb.dict -( - `key` Int64 DEFAULT -1, - `value_default` String DEFAULT 'world', - `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' -) -PRIMARY KEY key -SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) -LIFETIME(MIN 0 MAX 1) -LAYOUT(FLAT()) -``` - -Make sure that the dictionary is loaded. - -```sql -SELECT * FROM system.dictionaries -``` - -```text -┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ -│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ -└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ -``` - -## system.events {#system_tables-events} - -Contains information about the number of events that have occurred in the system. For example, in the table, you can find how many `SELECT` queries were processed since the ClickHouse server started. - -Columns: - -- `event` ([String](../sql_reference/data_types/string.md)) — Event name. -- `value` ([UInt64](../sql_reference/data_types/int_uint.md)) — Number of events occurred. -- `description` ([String](../sql_reference/data_types/string.md)) — Event description. - -**Example** - -``` sql -SELECT * FROM system.events LIMIT 5 -``` - -``` text -┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ -│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ -│ FileOpen │ 73 │ Number of files opened. │ -│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ -│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ -└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**See Also** - -- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [system.metrics](#system_tables-metrics) — Contains instantly calculated metrics. -- [system.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. - -## system.functions {#system-functions} - -Contains information about normal and aggregate functions. - -Columns: - -- `name`(`String`) – The name of the function. -- `is_aggregate`(`UInt8`) — Whether the function is aggregate. - -## system.graphite\_retentions {#system-graphite-retentions} - -Contains information about parameters [graphite\_rollup](server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) which are used in tables with [\*GraphiteMergeTree](../engines/table_engines/mergetree_family/graphitemergetree.md) engines. - -Columns: - -- `config_name` (String) - `graphite_rollup` parameter name. -- `regexp` (String) - A pattern for the metric name. -- `function` (String) - The name of the aggregating function. -- `age` (UInt64) - The minimum age of the data in seconds. -- `precision` (UInt64) - How precisely to define the age of the data in seconds. -- `priority` (UInt16) - Pattern priority. -- `is_default` (UInt8) - Whether the pattern is the default. -- `Tables.database` (Array(String)) - Array of names of database tables that use the `config_name` parameter. -- `Tables.table` (Array(String)) - Array of table names that use the `config_name` parameter. - -## system.merges {#system-merges} - -Contains information about merges and part mutations currently in process for tables in the MergeTree family. - -Columns: - -- `database` (String) — The name of the database the table is in. -- `table` (String) — Table name. -- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. -- `progress` (Float64) — The percentage of completed work from 0 to 1. -- `num_parts` (UInt64) — The number of pieces to be merged. -- `result_part_name` (String) — The name of the part that will be formed as the result of merging. -- `is_mutation` (UInt8) - 1 if this process is a part mutation. -- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. -- `total_size_marks` (UInt64) — The total number of marks in the merged parts. -- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. -- `rows_read` (UInt64) — Number of rows read. -- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. -- `rows_written` (UInt64) — Number of rows written. - -## system.metrics {#system_tables-metrics} - -Contains metrics which can be calculated instantly, or have a current value. For example, the number of simultaneously processed queries or the current replica delay. This table is always up to date. - -Columns: - -- `metric` ([String](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Int64](../sql_reference/data_types/int_uint.md)) — Metric value. -- `description` ([String](../sql_reference/data_types/string.md)) — Metric description. - -The list of supported metrics you can find in the [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) source file of ClickHouse. - -**Example** - -``` sql -SELECT * FROM system.metrics LIMIT 10 -``` - -``` text -┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 1 │ Number of executing queries │ -│ Merge │ 0 │ Number of executing background merges │ -│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ -│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ -│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ -│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ -│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ -│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ -│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ -│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ -└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**See Also** - -- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [system.events](#system_tables-events) — Contains a number of events that occurred. -- [system.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. - -## system.metric\_log {#system_tables-metric_log} - -Contains history of metrics values from tables `system.metrics` and `system.events`, periodically flushed to disk. -To turn on metrics history collection on `system.metric_log`, create `/etc/clickhouse-server/config.d/metric_log.xml` with following content: - -``` xml - - - system - metric_log
- 7500 - 1000 -
-
-``` - -**Example** - -``` sql -SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; -``` - -``` text -Row 1: -────── -event_date: 2020-02-18 -event_time: 2020-02-18 07:15:33 -milliseconds: 554 -ProfileEvent_Query: 0 -ProfileEvent_SelectQuery: 0 -ProfileEvent_InsertQuery: 0 -ProfileEvent_FileOpen: 0 -ProfileEvent_Seek: 0 -ProfileEvent_ReadBufferFromFileDescriptorRead: 1 -ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 -ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 -ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 -ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 -ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 -... -CurrentMetric_Query: 0 -CurrentMetric_Merge: 0 -CurrentMetric_PartMutation: 0 -CurrentMetric_ReplicatedFetch: 0 -CurrentMetric_ReplicatedSend: 0 -CurrentMetric_ReplicatedChecks: 0 -... -``` - -**See also** - -- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [system.events](#system_tables-events) — Contains a number of events that occurred. -- [system.metrics](#system_tables-metrics) — Contains instantly calculated metrics. -- [Monitoring](monitoring.md) — Base concepts of ClickHouse monitoring. - -## system.numbers {#system-numbers} - -This table contains a single UInt64 column named ‘number’ that contains almost all the natural numbers starting from zero. -You can use this table for tests, or if you need to do a brute force search. -Reads from this table are not parallelized. - -## system.numbers\_mt {#system-numbers-mt} - -The same as ‘system.numbers’ but reads are parallelized. The numbers can be returned in any order. -Used for tests. - -## system.one {#system-one} - -This table contains a single row with a single ‘dummy’ UInt8 column containing the value 0. -This table is used if a SELECT query doesn’t specify the FROM clause. -This is similar to the DUAL table found in other DBMSs. - -## system.parts {#system_tables-parts} - -Contains information about parts of [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) tables. - -Each row describes one data part. - -Columns: - -- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql_reference/statements/alter.md#query_language_queries_alter) query. - - Formats: - - - `YYYYMM` for automatic partitioning by month. - - `any_string` when partitioning manually. - -- `name` (`String`) – Name of the data part. - -- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it’s used in a table. Otherwise, it’s deleted. Inactive data parts remain after merging. - -- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` by the index granularity (usually 8192) (this hint doesn’t work for adaptive granularity). - -- `rows` (`UInt64`) – The number of rows. - -- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. - -- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `marks_bytes` (`UInt64`) – The size of the file with marks. - -- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| - -- `remove_time` (`DateTime`) – The time when the data part became inactive. - -- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. - -- `min_date` (`Date`) – The minimum value of the date key in the data part. - -- `max_date` (`Date`) – The maximum value of the date key in the data part. - -- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. - -- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. - -- `partition_id` (`String`) – ID of the partition. - -- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. - -- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. - -- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. - -- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). - -- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. - -- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. - -- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn’t exist. For more details, see [FREEZE PARTITION](../sql_reference/statements/alter.md#alter_freeze-partition) - -- `database` (`String`) – Name of the database. - -- `table` (`String`) – Name of the table. - -- `engine` (`String`) – Name of the table engine without parameters. - -- `path` (`String`) – Absolute path to the folder with data part files. - -- `disk` (`String`) – Name of a disk that stores the data part. - -- `hash_of_all_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) of compressed files. - -- `hash_of_uncompressed_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) of uncompressed files (files with marks, index file etc.). - -- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) of data in the compressed files as if they were uncompressed. - -- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. - -- `marks_size` (`UInt64`) – Alias for `marks_bytes`. - -## system.part\_log {#system_tables-part-log} - -The `system.part_log` table is created only if the [part\_log](server_configuration_parameters/settings.md#server_configuration_parameters-part-log) server setting is specified. - -This table contains information about events that occurred with [data parts](../engines/table_engines/mergetree_family/custom_partitioning_key.md) in the [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) family tables, such as adding or merging data. - -The `system.part_log` table contains the following columns: - -- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: - - `NEW_PART` — Inserting of a new data part. - - `MERGE_PARTS` — Merging of data parts. - - `DOWNLOAD_PART` — Downloading a data part. - - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql_reference/statements/alter.md#alter_detach-partition). - - `MUTATE_PART` — Mutating of a data part. - - `MOVE_PART` — Moving the data part from the one disk to another one. -- `event_date` (Date) — Event date. -- `event_time` (DateTime) — Event time. -- `duration_ms` (UInt64) — Duration. -- `database` (String) — Name of the database the data part is in. -- `table` (String) — Name of the table the data part is in. -- `part_name` (String) — Name of the data part. -- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ value if the partitioning is by `tuple()`. -- `rows` (UInt64) — The number of rows in the data part. -- `size_in_bytes` (UInt64) — Size of the data part in bytes. -- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). -- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. -- `read_rows` (UInt64) — The number of rows was read during the merge. -- `read_bytes` (UInt64) — The number of bytes was read during the merge. -- `error` (UInt16) — The code number of the occurred error. -- `exception` (String) — Text message of the occurred error. - -The `system.part_log` table is created after the first inserting data to the `MergeTree` table. - -## system.processes {#system_tables-processes} - -This system table is used for implementing the `SHOW PROCESSLIST` query. - -Columns: - -- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` user. The field contains the username for a specific query, not for a query that this query initiated. -- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` on the query requestor server. -- `elapsed` (Float64) – The time in seconds since request execution started. -- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. -- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../operations/settings/query_complexity.md#settings_max_memory_usage) setting. -- `query` (String) – The query text. For `INSERT`, it doesn’t include the data to insert. -- `query_id` (String) – Query ID, if defined. - -## system.text\_log {#system-tables-text-log} - -Contains logging entries. Logging level which goes to this table can be limited with `text_log.level` server setting. - -Columns: - -- `event_date` (`Date`) - Date of the entry. -- `event_time` (`DateTime`) - Time of the entry. -- `microseconds` (`UInt32`) - Microseconds of the entry. -- `thread_name` (String) — Name of the thread from which the logging was done. -- `thread_id` (UInt64) — OS thread ID. -- `level` (`Enum8`) - Entry level. - - `'Fatal' = 1` - - `'Critical' = 2` - - `'Error' = 3` - - `'Warning' = 4` - - `'Notice' = 5` - - `'Information' = 6` - - `'Debug' = 7` - - `'Trace' = 8` -- `query_id` (`String`) - ID of the query. -- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) -- `message` (`String`) - The message itself. -- `revision` (`UInt32`) - ClickHouse revision. -- `source_file` (`LowCardinality(String)`) - Source file from which the logging was done. -- `source_line` (`UInt64`) - Source line from which the logging was done. - -## system.query\_log {#system_tables-query_log} - -Contains information about execution of queries. For each query, you can see processing start time, duration of processing, error messages and other information. - -!!! note "Note" - The table doesn’t contain input data for `INSERT` queries. - -ClickHouse creates this table only if the [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server parameter is specified. This parameter sets the logging rules, such as the logging interval or the name of the table the queries will be logged in. - -To enable query logging, set the [log\_queries](settings/settings.md#settings-log-queries) parameter to 1. For details, see the [Settings](settings/settings.md) section. - -The `system.query_log` table registers two kinds of queries: - -1. Initial queries that were run directly by the client. -2. Child queries that were initiated by other queries (for distributed query execution). For these types of queries, information about the parent queries is shown in the `initial_*` columns. - -Columns: - -- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: - - `'QueryStart' = 1` — Successful start of query execution. - - `'QueryFinish' = 2` — Successful end of query execution. - - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. - - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. -- `event_date` (Date) — Query starting date. -- `event_time` (DateTime) — Query starting time. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0. -- `written_bytes` (UInt64) — For `INSERT` queries, the number of written bytes. For other queries, the column value is 0. -- `result_rows` (UInt64) — Number of rows in the result. -- `result_bytes` (UInt64) — Number of bytes in the result. -- `memory_usage` (UInt64) — Memory consumption by the query. -- `query` (String) — Query string. -- `exception` (String) — Exception message. -- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS’s username who runs [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) or another TCP client is run. -- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) or another TCP client name. -- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) or another TCP client version. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` method was used. - - 2 — `POST` method was used. -- `http_user_agent` (String) — The `UserAgent` header passed in the HTTP request. -- `quota_key` (String) — The “quota key” specified in the [quotas](quotas.md) setting (see `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [system.events](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` column. -- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parameter to 1. -- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` column. - -Each query creates one or two rows in the `query_log` table, depending on the status of the query: - -1. If the query execution is successful, two events with types 1 and 2 are created (see the `type` column). -2. If an error occurred during query processing, two events with types 1 and 4 are created. -3. If an error occurred before launching the query, a single event with type 3 is created. - -By default, logs are added to the table at intervals of 7.5 seconds. You can set this interval in the [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server setting (see the `flush_interval_milliseconds` parameter). To flush the logs forcibly from the memory buffer into the table, use the `SYSTEM FLUSH LOGS` query. - -When the table is deleted manually, it will be automatically created on the fly. Note that all the previous logs will be deleted. - -!!! note "Note" - The storage period for logs is unlimited. Logs aren’t automatically deleted from the table. You need to organize the removal of outdated logs yourself. - -You can specify an arbitrary partitioning key for the `system.query_log` table in the [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server setting (see the `partition_by` parameter). - -## system.query\_thread\_log {#system_tables-query-thread-log} - -The table contains information about each query execution thread. - -ClickHouse creates this table only if the [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) server parameter is specified. This parameter sets the logging rules, such as the logging interval or the name of the table the queries will be logged in. - -To enable query logging, set the [log\_query\_threads](settings/settings.md#settings-log-query-threads) parameter to 1. For details, see the [Settings](settings/settings.md) section. - -Columns: - -- `event_date` (Date) — the date when the thread has finished execution of the query. -- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0. -- `written_bytes` (UInt64) — For `INSERT` queries, the number of written bytes. For other queries, the column value is 0. -- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. -- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. -- `thread_name` (String) — Name of the thread. -- `thread_number` (UInt32) — Internal thread ID. -- `os_thread_id` (Int32) — OS thread ID. -- `master_thread_id` (UInt64) — OS initial ID of initial thread. -- `query` (String) — Query string. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS’s username who runs [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) or another TCP client is run. -- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) or another TCP client name. -- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) or another TCP client version. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` method was used. - - 2 — `POST` method was used. -- `http_user_agent` (String) — The `UserAgent` header passed in the HTTP request. -- `quota_key` (String) — The “quota key” specified in the [quotas](quotas.md) setting (see `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [system.events](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` column. - -By default, logs are added to the table at intervals of 7.5 seconds. You can set this interval in the [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) server setting (see the `flush_interval_milliseconds` parameter). To flush the logs forcibly from the memory buffer into the table, use the `SYSTEM FLUSH LOGS` query. - -When the table is deleted manually, it will be automatically created on the fly. Note that all the previous logs will be deleted. - -!!! note "Note" - The storage period for logs is unlimited. Logs aren’t automatically deleted from the table. You need to organize the removal of outdated logs yourself. - -You can specify an arbitrary partitioning key for the `system.query_thread_log` table in the [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) server setting (see the `partition_by` parameter). - -## system.trace_log {#system_tables-trace_log} - -Contains stack traces collected by the sampling query profiler. - -ClickHouse creates this table when the [trace\_log](server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) server configuration section is set. Also the [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) and [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) settings should be set. - -To analyze logs, use the `addressToLine`, `addressToSymbol` and `demangle` introspection functions. - -Columns: - -- `event_date` ([Date](../sql_reference/data_types/date.md)) — Date of sampling moment. - -- `event_time` ([DateTime](../sql_reference/data_types/datetime.md)) — Timestamp of the sampling moment. - -- `timestamp_ns` ([UInt64](../sql_reference/data_types/int_uint.md)) — Timestamp of the sampling moment in nanoseconds. - -- `revision` ([UInt32](../sql_reference/data_types/int_uint.md)) — ClickHouse server build revision. - - When connecting to server by `clickhouse-client`, you see the string similar to `Connected to ClickHouse server version 19.18.1 revision 54429.`. This field contains the `revision`, but not the `version` of a server. - -- `timer_type` ([Enum8](../sql_reference/data_types/enum.md)) — Timer type: - - - `Real` represents wall-clock time. - - `CPU` represents CPU time. - -- `thread_number` ([UInt32](../sql_reference/data_types/int_uint.md)) — Thread identifier. - -- `query_id` ([String](../sql_reference/data_types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) system table. - -- `trace` ([Array(UInt64)](../sql_reference/data_types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. - -**Example** - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-15 -event_time: 2019-11-15 15:09:38 -revision: 54428 -timer_type: Real -thread_number: 48 -query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 -trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] -``` - -## system.replicas {#system_tables-replicas} - -Contains information and status for replicated tables residing on the local server. -This table can be used for monitoring. The table contains a row for every Replicated\* table. - -Example: - -``` sql -SELECT * -FROM system.replicas -WHERE table = 'visits' -FORMAT Vertical -``` - -``` text -Row 1: -────── -database: merge -table: visits -engine: ReplicatedCollapsingMergeTree -is_leader: 1 -can_become_leader: 1 -is_readonly: 0 -is_session_expired: 0 -future_parts: 1 -parts_to_check: 0 -zookeeper_path: /clickhouse/tables/01-06/visits -replica_name: example01-06-1.yandex.ru -replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru -columns_version: 9 -queue_size: 1 -inserts_in_queue: 0 -merges_in_queue: 1 -part_mutations_in_queue: 0 -queue_oldest_time: 2020-02-20 08:34:30 -inserts_oldest_time: 0000-00-00 00:00:00 -merges_oldest_time: 2020-02-20 08:34:30 -part_mutations_oldest_time: 0000-00-00 00:00:00 -oldest_part_to_get: -oldest_part_to_merge_to: 20200220_20284_20840_7 -oldest_part_to_mutate_to: -log_max_index: 596273 -log_pointer: 596274 -last_queue_update: 2020-02-20 08:34:32 -absolute_delay: 0 -total_replicas: 2 -active_replicas: 2 -``` - -Columns: - -- `database` (`String`) - Database name -- `table` (`String`) - Table name -- `engine` (`String`) - Table engine name -- `is_leader` (`UInt8`) - Whether the replica is the leader. - Only one replica at a time can be the leader. The leader is responsible for selecting background merges to perform. - Note that writes can be performed to any replica that is available and has a session in ZK, regardless of whether it is a leader. -- `can_become_leader` (`UInt8`) - Whether the replica can be elected as a leader. -- `is_readonly` (`UInt8`) - Whether the replica is in read-only mode. - This mode is turned on if the config doesn’t have sections with ZooKeeper, if an unknown error occurred when reinitializing sessions in ZooKeeper, and during session reinitialization in ZooKeeper. -- `is_session_expired` (`UInt8`) - the session with ZooKeeper has expired. Basically the same as `is_readonly`. -- `future_parts` (`UInt32`) - The number of data parts that will appear as the result of INSERTs or merges that haven’t been done yet. -- `parts_to_check` (`UInt32`) - The number of data parts in the queue for verification. A part is put in the verification queue if there is suspicion that it might be damaged. -- `zookeeper_path` (`String`) - Path to table data in ZooKeeper. -- `replica_name` (`String`) - Replica name in ZooKeeper. Different replicas of the same table have different names. -- `replica_path` (`String`) - Path to replica data in ZooKeeper. The same as concatenating ‘zookeeper\_path/replicas/replica\_path’. -- `columns_version` (`Int32`) - Version number of the table structure. Indicates how many times ALTER was performed. If replicas have different versions, it means some replicas haven’t made all of the ALTERs yet. -- `queue_size` (`UInt32`) - Size of the queue for operations waiting to be performed. Operations include inserting blocks of data, merges, and certain other actions. It usually coincides with `future_parts`. -- `inserts_in_queue` (`UInt32`) - Number of inserts of blocks of data that need to be made. Insertions are usually replicated fairly quickly. If this number is large, it means something is wrong. -- `merges_in_queue` (`UInt32`) - The number of merges waiting to be made. Sometimes merges are lengthy, so this value may be greater than zero for a long time. -- `part_mutations_in_queue` (`UInt32`) - The number of mutations waiting to be made. -- `queue_oldest_time` (`DateTime`) - If `queue_size` greater than 0, shows when the oldest operation was added to the queue. -- `inserts_oldest_time` (`DateTime`) - See `queue_oldest_time` -- `merges_oldest_time` (`DateTime`) - See `queue_oldest_time` -- `part_mutations_oldest_time` (`DateTime`) - See `queue_oldest_time` - -The next 4 columns have a non-zero value only where there is an active session with ZK. - -- `log_max_index` (`UInt64`) - Maximum entry number in the log of general activity. -- `log_pointer` (`UInt64`) - Maximum entry number in the log of general activity that the replica copied to its execution queue, plus one. If `log_pointer` is much smaller than `log_max_index`, something is wrong. -- `last_queue_update` (`DateTime`) - When the queue was updated last time. -- `absolute_delay` (`UInt64`) - How big lag in seconds the current replica has. -- `total_replicas` (`UInt8`) - The total number of known replicas of this table. -- `active_replicas` (`UInt8`) - The number of replicas of this table that have a session in ZooKeeper (i.e., the number of functioning replicas). - -If you request all the columns, the table may work a bit slowly, since several reads from ZooKeeper are made for each row. -If you don’t request the last 4 columns (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), the table works quickly. - -For example, you can check that everything is working correctly like this: - -``` sql -SELECT - database, - table, - is_leader, - is_readonly, - is_session_expired, - future_parts, - parts_to_check, - columns_version, - queue_size, - inserts_in_queue, - merges_in_queue, - log_max_index, - log_pointer, - total_replicas, - active_replicas -FROM system.replicas -WHERE - is_readonly - OR is_session_expired - OR future_parts > 20 - OR parts_to_check > 10 - OR queue_size > 20 - OR inserts_in_queue > 10 - OR log_max_index - log_pointer > 10 - OR total_replicas < 2 - OR active_replicas < total_replicas -``` - -If this query doesn’t return anything, it means that everything is fine. - -## system.settings {#system-tables-system-settings} - -Contains information about session settings for current user. - -Columns: - -- `name` ([String](../sql_reference/data_types/string.md)) — Setting name. -- `value` ([String](../sql_reference/data_types/string.md)) — Setting value. -- `changed` ([UInt8](../sql_reference/data_types/int_uint.md#uint-ranges)) — Shows whether a setting is changed from its default value. -- `description` ([String](../sql_reference/data_types/string.md)) — Short setting description. -- `min` ([Nullable](../sql_reference/data_types/nullable.md)([String](../sql_reference/data_types/string.md))) — Minimum value of the setting, if any is set via [constraints](settings/constraints_on_settings.md#constraints-on-settings). If the setting has no minimum value, contains [NULL](../sql_reference/syntax.md#null-literal). -- `max` ([Nullable](../sql_reference/data_types/nullable.md)([String](../sql_reference/data_types/string.md))) — Maximum value of the setting, if any is set via [constraints](settings/constraints_on_settings.md#constraints-on-settings). If the setting has no maximum value, contains [NULL](../sql_reference/syntax.md#null-literal). -- `readonly` ([UInt8](../sql_reference/data_types/int_uint.md#uint-ranges)) — Shows whether the current user can change the setting: - - `0` — Current user can change the setting. - - `1` — Current user can’t change the setting. - -**Example** - -The following example shows how to get information about settings which name contains `min_i`. - -``` sql -SELECT * -FROM system.settings -WHERE name LIKE '%min_i%' -``` - -``` text -┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ -│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ -``` - -Using of `WHERE changed` can be useful, for example, when you want to check: - -- Whether settings in configuration files are loaded correctly and are in use. -- Settings that changed in the current session. - - - -``` sql -SELECT * FROM system.settings WHERE changed AND name='load_balancing' -``` - -**See also** - -- [Settings](settings/index.md#settings) -- [Permissions for Queries](settings/permissions_for_queries.md#settings_readonly) -- [Constraints on Settings](settings/constraints_on_settings.md) - -## system.table\_engines {#system.table_engines} - -``` text -┌─name───────────────────┬─value───────┐ -│ max_threads │ 8 │ -│ use_uncompressed_cache │ 0 │ -│ load_balancing │ random │ -│ max_memory_usage │ 10000000000 │ -└────────────────────────┴─────────────┘ -``` - -## system.merge\_tree\_settings {#system-merge_tree_settings} - -Contains information about settings for `MergeTree` tables. - -Columns: - -- `name` (String) — Setting name. -- `value` (String) — Setting value. -- `description` (String) — Setting description. -- `type` (String) — Setting type (implementation specific string value). -- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. - -## system.table\_engines {#system-table-engines} - -Contains description of table engines supported by server and their feature support information. - -This table contains the following columns (the column type is shown in brackets): - -- `name` (String) — The name of table engine. -- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` clause. -- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [skipping indices](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-data_skipping-indexes). -- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). -- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` and `SAMPLE_BY`. -- `supports_replication` (UInt8) — Flag that indicates if table engine supports [data replication](../engines/table_engines/mergetree_family/replication.md). -- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. - -Example: - -``` sql -SELECT * -FROM system.table_engines -WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') -``` - -``` text -┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ -│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ -│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ -│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ -└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ -``` - -**See also** - -- MergeTree family [query clauses](../engines/table_engines/mergetree_family/mergetree.md#mergetree-query-clauses) -- Kafka [settings](../engines/table_engines/integrations/kafka.md#table_engine-kafka-creating-a-table) -- Join [settings](../engines/table_engines/special/join.md#join-limitations-and-settings) - -## system.tables {#system-tables} - -Contains metadata of each table that the server knows about. Detached tables are not shown in `system.tables`. - -This table contains the following columns (the column type is shown in brackets): - -- `database` (String) — The name of the database the table is in. - -- `name` (String) — Table name. - -- `engine` (String) — Table engine name (without parameters). - -- `is_temporary` (UInt8) - Flag that indicates whether the table is temporary. - -- `data_path` (String) - Path to the table data in the file system. - -- `metadata_path` (String) - Path to the table metadata in the file system. - -- `metadata_modification_time` (DateTime) - Time of latest modification of the table metadata. - -- `dependencies_database` (Array(String)) - Database dependencies. - -- `dependencies_table` (Array(String)) - Table dependencies ([MaterializedView](../engines/table_engines/special/materializedview.md) tables based on the current table). - -- `create_table_query` (String) - The query that was used to create the table. - -- `engine_full` (String) - Parameters of the table engine. - -- `partition_key` (String) - The partition key expression specified in the table. - -- `sorting_key` (String) - The sorting key expression specified in the table. - -- `primary_key` (String) - The primary key expression specified in the table. - -- `sampling_key` (String) - The sampling key expression specified in the table. - -- `storage_policy` (String) - The storage policy: - - - [MergeTree](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) - - [Distributed](../engines/table_engines/special/distributed.md#distributed) - -- `total_rows` (Nullable(UInt64)) - Total number of rows, if it is possible to quickly determine exact number of rows in the table, otherwise `Null` (including underying `Buffer` table). - -- `total_bytes` (Nullable(UInt64)) - Total number of bytes, if it is possible to quickly determine exact number of bytes for the table on storage, otherwise `Null` (**does not** includes any underlying storage). - - - If the table stores data on disk, returns used space on disk (i.e. compressed). - - If the table stores data in memory, returns approximated number of used bytes in memory. - -The `system.tables` table is used in `SHOW TABLES` query implementation. - -## system.zookeeper {#system-zookeeper} - -The table does not exist if ZooKeeper is not configured. Allows reading data from the ZooKeeper cluster defined in the config. -The query must have a ‘path’ equality condition in the WHERE clause. This is the path in ZooKeeper for the children that you want to get data for. - -The query `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` outputs data for all children on the `/clickhouse` node. -To output data for all root nodes, write path = ‘/’. -If the path specified in ‘path’ doesn’t exist, an exception will be thrown. - -Columns: - -- `name` (String) — The name of the node. -- `path` (String) — The path to the node. -- `value` (String) — Node value. -- `dataLength` (Int32) — Size of the value. -- `numChildren` (Int32) — Number of descendants. -- `czxid` (Int64) — ID of the transaction that created the node. -- `mzxid` (Int64) — ID of the transaction that last changed the node. -- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. -- `ctime` (DateTime) — Time of node creation. -- `mtime` (DateTime) — Time of the last modification of the node. -- `version` (Int32) — Node version: the number of times the node was changed. -- `cversion` (Int32) — Number of added or removed descendants. -- `aversion` (Int32) — Number of changes to the ACL. -- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. - -Example: - -``` sql -SELECT * -FROM system.zookeeper -WHERE path = '/clickhouse/tables/01-08/visits/replicas' -FORMAT Vertical -``` - -``` text -Row 1: -────── -name: example01-08-1.yandex.ru -value: -czxid: 932998691229 -mzxid: 932998691229 -ctime: 2015-03-27 16:49:51 -mtime: 2015-03-27 16:49:51 -version: 0 -cversion: 47 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021031383 -path: /clickhouse/tables/01-08/visits/replicas - -Row 2: -────── -name: example01-08-2.yandex.ru -value: -czxid: 933002738135 -mzxid: 933002738135 -ctime: 2015-03-27 16:57:01 -mtime: 2015-03-27 16:57:01 -version: 0 -cversion: 37 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021252247 -path: /clickhouse/tables/01-08/visits/replicas -``` - -## system.mutations {#system_tables-mutations} - -The table contains information about [mutations](../sql_reference/statements/alter.md#alter-mutations) of MergeTree tables and their progress. Each mutation command is represented by a single row. The table has the following columns: - -**database**, **table** - The name of the database and table to which the mutation was applied. - -**mutation\_id** - The ID of the mutation. For replicated tables these IDs correspond to znode names in the `/mutations/` directory in ZooKeeper. For unreplicated tables the IDs correspond to file names in the data directory of the table. - -**command** - The mutation command string (the part of the query after `ALTER TABLE [db.]table`). - -**create\_time** - When this mutation command was submitted for execution. - -**block\_numbers.partition\_id**, **block\_numbers.number** - A nested column. For mutations of replicated tables, it contains one record for each partition: the partition ID and the block number that was acquired by the mutation (in each partition, only parts that contain blocks with numbers less than the block number acquired by the mutation in that partition will be mutated). In non-replicated tables, block numbers in all partitions form a single sequence. This means that for mutations of non-replicated tables, the column will contain one record with a single block number acquired by the mutation. - -**parts\_to\_do** - The number of data parts that need to be mutated for the mutation to finish. - -**is\_done** - Is the mutation done? Note that even if `parts_to_do = 0` it is possible that a mutation of a replicated table is not done yet because of a long-running INSERT that will create a new data part that will need to be mutated. - -If there were problems with mutating some parts, the following columns contain additional information: - -**latest\_failed\_part** - The name of the most recent part that could not be mutated. - -**latest\_fail\_time** - The time of the most recent part mutation failure. - -**latest\_fail\_reason** - The exception message that caused the most recent part mutation failure. - -## system.disks {#system_tables-disks} - -Contains information about disks defined in the [server configuration](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Columns: - -- `name` ([String](../sql_reference/data_types/string.md)) — Name of a disk in the server configuration. -- `path` ([String](../sql_reference/data_types/string.md)) — Path to the mount point in the file system. -- `free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Free space on disk in bytes. -- `total_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Disk volume in bytes. -- `keep_free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` parameter of disk configuration. - -## system.storage\_policies {#system_tables-storage_policies} - -Contains information about storage policies and volumes defined in the [server configuration](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Columns: - -- `policy_name` ([String](../sql_reference/data_types/string.md)) — Name of the storage policy. -- `volume_name` ([String](../sql_reference/data_types/string.md)) — Volume name defined in the storage policy. -- `volume_priority` ([UInt64](../sql_reference/data_types/int_uint.md)) — Volume order number in the configuration. -- `disks` ([Array(String)](../sql_reference/data_types/array.md)) — Disk names, defined in the storage policy. -- `max_data_part_size` ([UInt64](../sql_reference/data_types/int_uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). -- `move_factor` ([Float64](../sql_reference/data_types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. - -If the storage policy contains more then one volume, then information for each volume is stored in the individual row of the table. - -[Original article](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/en/operations/troubleshooting.md b/docs/en/operations/troubleshooting.md index b6afedfca7e..1a33aa3f689 100644 --- a/docs/en/operations/troubleshooting.md +++ b/docs/en/operations/troubleshooting.md @@ -15,7 +15,7 @@ toc_title: Troubleshooting ### You Cannot Get Deb Packages from ClickHouse Repository with Apt-get {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} - Check firewall settings. -- If you cannot access the repository for any reason, download packages as described in the [Getting started](../getting_started/index.md) article and install them manually using the `sudo dpkg -i ` command. You will also need the `tzdata` package. +- If you cannot access the repository for any reason, download packages as described in the [Getting started](../getting-started/index.md) article and install them manually using the `sudo dpkg -i ` command. You will also need the `tzdata` package. ## Connecting to the Server {#troubleshooting-accepts-no-connections} @@ -103,7 +103,7 @@ Check: - Endpoint settings. - Check [listen\_host](server_configuration_parameters/settings.md#server_configuration_parameters-listen_host) and [tcp\_port](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port) settings. + Check [listen\_host](server-configuration-parameters/settings.md#server_configuration_parameters-listen_host) and [tcp\_port](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port) settings. ClickHouse server accepts localhost connections only by default. @@ -115,8 +115,8 @@ Check: Check: - - The [tcp\_port\_secure](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) setting. - - Settings for [SSL sertificates](server_configuration_parameters/settings.md#server_configuration_parameters-openssl). + - The [tcp\_port\_secure](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) setting. + - Settings for [SSL certificates](server-configuration-parameters/settings.md#server_configuration_parameters-openssl). Use proper parameters while connecting. For example, use the `port_secure` parameter with `clickhouse_client`. diff --git a/docs/en/operations/utilities/clickhouse-benchmark.md b/docs/en/operations/utilities/clickhouse-benchmark.md index 8435e37b4b5..ab67ca197dd 100644 --- a/docs/en/operations/utilities/clickhouse-benchmark.md +++ b/docs/en/operations/utilities/clickhouse-benchmark.md @@ -97,7 +97,7 @@ In the report you can find: - Percentiles of queries execution time. -## Comparison mode {#clickhouse-benchmark-comparison-mode} +## Comparison Mode {#clickhouse-benchmark-comparison-mode} `clickhouse-benchmark` can compare performances for two running ClickHouse servers. diff --git a/docs/en/operations/utilities/clickhouse-copier.md b/docs/en/operations/utilities/clickhouse-copier.md index d519940b8d9..d450f5753e4 100644 --- a/docs/en/operations/utilities/clickhouse-copier.md +++ b/docs/en/operations/utilities/clickhouse-copier.md @@ -24,12 +24,12 @@ After starting, `clickhouse-copier`: To reduce network traffic, we recommend running `clickhouse-copier` on the same server where the source data is located. -## Running clickhouse-copier {#running-clickhouse-copier} +## Running Clickhouse-copier {#running-clickhouse-copier} The utility should be run manually: ``` bash -$ clickhouse-copier copier --daemon --config zookeeper.xml --task-path /task/path --base-dir /path/to/dir +$ clickhouse-copier --daemon --config zookeeper.xml --task-path /task/path --base-dir /path/to/dir ``` Parameters: @@ -41,7 +41,7 @@ Parameters: - `task-upload-force` — Force upload `task-file` even if node already exists. - `base-dir` — The path to logs and auxiliary files. When it starts, `clickhouse-copier` creates `clickhouse-copier_YYYYMMHHSS_` subdirectories in `$base-dir`. If this parameter is omitted, the directories are created in the directory where `clickhouse-copier` was launched. -## Format of zookeeper.xml {#format-of-zookeeper-xml} +## Format of Zookeeper.xml {#format-of-zookeeper-xml} ``` xml @@ -60,7 +60,7 @@ Parameters: ``` -## Configuration of copying tasks {#configuration-of-copying-tasks} +## Configuration of Copying Tasks {#configuration-of-copying-tasks} ``` xml diff --git a/docs/en/operations/utilities/clickhouse-local.md b/docs/en/operations/utilities/clickhouse-local.md index 38f28b432a3..8aa0560f5d1 100644 --- a/docs/en/operations/utilities/clickhouse-local.md +++ b/docs/en/operations/utilities/clickhouse-local.md @@ -7,7 +7,7 @@ toc_title: clickhouse-local The `clickhouse-local` program enables you to perform fast processing on local files, without having to deploy and configure the ClickHouse server. -Accepts data that represent tables and queries them using [ClickHouse SQL dialect](../../sql_reference/index.md). +Accepts data that represent tables and queries them using [ClickHouse SQL dialect](../../sql-reference/index.md). `clickhouse-local` uses the same core as ClickHouse server, so it supports most of the features and the same set of formats and table engines. diff --git a/docs/en/sql-reference/aggregate-functions/combinators.md b/docs/en/sql-reference/aggregate-functions/combinators.md new file mode 100644 index 00000000000..8573d55a33c --- /dev/null +++ b/docs/en/sql-reference/aggregate-functions/combinators.md @@ -0,0 +1,244 @@ +--- +toc_priority: 37 +toc_title: Combinators +--- + +# Aggregate Function Combinators {#aggregate_functions_combinators} + +The name of an aggregate function can have a suffix appended to it. This changes the way the aggregate function works. + +## -If {#agg-functions-combinator-if} + +The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). + +Examples: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` and so on. + +With conditional aggregate functions, you can calculate aggregates for several conditions at once, without using subqueries and `JOIN`s. For example, in Yandex.Metrica, conditional aggregate functions are used to implement the segment comparison functionality. + +## -Array {#agg-functions-combinator-array} + +The -Array suffix can be appended to any aggregate function. In this case, the aggregate function takes arguments of the ‘Array(T)’ type (arrays) instead of ‘T’ type arguments. If the aggregate function accepts multiple arguments, this must be arrays of equal lengths. When processing arrays, the aggregate function works like the original aggregate function across all array elements. + +Example 1: `sumArray(arr)` - Totals all the elements of all ‘arr’ arrays. In this example, it could have been written more simply: `sum(arraySum(arr))`. + +Example 2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ arrays. This could be done an easier way: `uniq(arrayJoin(arr))`, but it’s not always possible to add ‘arrayJoin’ to a query. + +-If and -Array can be combined. However, ‘Array’ must come first, then ‘If’. Examples: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. Due to this order, the ‘cond’ argument won’t be an array. + +## -State {#agg-functions-combinator-state} + +If you apply this combinator, the aggregate function doesn’t return the resulting value (such as the number of unique values for the [uniq](reference.md#agg_function-uniq) function), but an intermediate state of the aggregation (for `uniq`, this is the hash table for calculating the number of unique values). This is an `AggregateFunction(...)` that can be used for further processing or stored in a table to finish aggregating later. + +To work with these states, use: + +- [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) table engine. +- [finalizeAggregation](../../sql-reference/functions/other-functions.md#function-finalizeaggregation) function. +- [runningAccumulate](../../sql-reference/functions/other-functions.md#function-runningaccumulate) function. +- [-Merge](#aggregate_functions_combinators-merge) combinator. +- [-MergeState](#aggregate_functions_combinators-mergestate) combinator. + +## -Merge {#aggregate_functions_combinators-merge} + +If you apply this combinator, the aggregate function takes the intermediate aggregation state as an argument, combines the states to finish aggregation, and returns the resulting value. + +## -MergeState {#aggregate_functions_combinators-mergestate} + +Merges the intermediate aggregation states in the same way as the -Merge combinator. However, it doesn’t return the resulting value, but an intermediate aggregation state, similar to the -State combinator. + +## -ForEach {#agg-functions-combinator-foreach} + +Converts an aggregate function for tables into an aggregate function for arrays that aggregates the corresponding array items and returns an array of results. For example, `sumForEach` for the arrays `[1, 2]`, `[3, 4, 5]`and`[6, 7]`returns the result `[10, 13, 5]` after adding together the corresponding array items. + +## -OrDefault {#agg-functions-combinator-ordefault} + +Changes behavior of an aggregate function. + +If an aggregate function doesn't have input values, with this combinator it returns the default value for its return data type. Applies to the aggregate functions that can take empty input data. + +`-OrDefault` can be used with other combinators. + +**Syntax** + +``` sql +OrDefault(x) +``` + +**Parameters** + +- `x` — Aggregate function parameters. + +**Returned values** + +Returns the default value of an aggregate function’s return type if there is nothing to aggregate. + +Type depends on the aggregate function used. + +**Example** + +Query: + +``` sql +SELECT avg(number), avgOrDefault(number) FROM numbers(0) +``` + +Result: + +``` text +┌─avg(number)─┬─avgOrDefault(number)─┐ +│ nan │ 0 │ +└─────────────┴──────────────────────┘ +``` + +Also `-OrDefault` can be used with another combinators. It is useful when the aggregate function does not accept the empty input. + +Query: + +``` sql +SELECT avgOrDefaultIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Result: + +``` text +┌─avgOrDefaultIf(x, greater(x, 10))─┐ +│ 0.00 │ +└───────────────────────────────────┘ +``` + + +## -OrNull {#agg-functions-combinator-ornull} + +Changes behavior of an aggregate function. + +This combinator converts a result of an aggregate function to the [Nullable](../data-types/nullable.md) data type. If the aggregate function does not have values to calculate it returns [NULL](../syntax.md#null-literal). + +`-OrNull` can be used with other combinators. + +**Syntax** + +``` sql +OrNull(x) +``` + +**Parameters** + +- `x` — Aggregate function parameters. + +**Returned values** + +- The result of the aggregate function, converted to the `Nullable` data type. +- `NULL`, if there is nothing to aggregate. + +Type: `Nullable(aggregate function return type)`. + +**Example** + +Add `-orNull` to the end of aggregate function. + +Query: + +``` sql +SELECT sumOrNull(number), toTypeName(sumOrNull(number)) FROM numbers(10) WHERE number > 10 +``` + +Result: + +``` text +┌─sumOrNull(number)─┬─toTypeName(sumOrNull(number))─┐ +│ ᴺᵁᴸᴸ │ Nullable(UInt64) │ +└───────────────────┴───────────────────────────────┘ +``` + +Also `-OrNull` can be used with another combinators. It is useful when the aggregate function does not accept the empty input. + +Query: + +``` sql +SELECT avgOrNullIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Result: + +``` text +┌─avgOrNullIf(x, greater(x, 10))─┐ +│ ᴺᵁᴸᴸ │ +└────────────────────────────────┘ +``` + +## -Resample {#agg-functions-combinator-resample} + +Lets you divide data into groups, and then separately aggregates the data in those groups. Groups are created by splitting the values from one column into intervals. + +``` sql +Resample(start, end, step)(, resampling_key) +``` + +**Parameters** + +- `start` — Starting value of the whole required interval for `resampling_key` values. +- `stop` — Ending value of the whole required interval for `resampling_key` values. The whole interval doesn’t include the `stop` value `[start, stop)`. +- `step` — Step for separating the whole interval into subintervals. The `aggFunction` is executed over each of those subintervals independently. +- `resampling_key` — Column whose values are used for separating data into intervals. +- `aggFunction_params` — `aggFunction` parameters. + +**Returned values** + +- Array of `aggFunction` results for each subinterval. + +**Example** + +Consider the `people` table with the following data: + +``` text +┌─name───┬─age─┬─wage─┐ +│ John │ 16 │ 10 │ +│ Alice │ 30 │ 15 │ +│ Mary │ 35 │ 8 │ +│ Evelyn │ 48 │ 11.5 │ +│ David │ 62 │ 9.9 │ +│ Brian │ 60 │ 16 │ +└────────┴─────┴──────┘ +``` + +Let’s get the names of the people whose age lies in the intervals of `[30,60)` and `[60,75)`. Since we use integer representation for age, we get ages in the `[30, 59]` and `[60,74]` intervals. + +To aggregate names in an array, we use the [groupArray](reference.md#agg_function-grouparray) aggregate function. It takes one argument. In our case, it’s the `name` column. The `groupArrayResample` function should use the `age` column to aggregate names by age. To define the required intervals, we pass the `30, 75, 30` arguments into the `groupArrayResample` function. + +``` sql +SELECT groupArrayResample(30, 75, 30)(name, age) FROM people +``` + +``` text +┌─groupArrayResample(30, 75, 30)(name, age)─────┐ +│ [['Alice','Mary','Evelyn'],['David','Brian']] │ +└───────────────────────────────────────────────┘ +``` + +Consider the results. + +`Jonh` is out of the sample because he’s too young. Other people are distributed according to the specified age intervals. + +Now let’s count the total number of people and their average wage in the specified age intervals. + +``` sql +SELECT + countResample(30, 75, 30)(name, age) AS amount, + avgResample(30, 75, 30)(wage, age) AS avg_wage +FROM people +``` + +``` text +┌─amount─┬─avg_wage──────────────────┐ +│ [3,2] │ [11.5,12.949999809265137] │ +└────────┴───────────────────────────┘ +``` + +[Original article](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/en/sql-reference/aggregate-functions/index.md b/docs/en/sql-reference/aggregate-functions/index.md new file mode 100644 index 00000000000..aa1045b123c --- /dev/null +++ b/docs/en/sql-reference/aggregate-functions/index.md @@ -0,0 +1,60 @@ +--- +toc_folder_title: Aggregate Functions +toc_priority: 33 +toc_title: Introduction +--- + +# Aggregate Functions {#aggregate-functions} + +Aggregate functions work in the [normal](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) way as expected by database experts. + +ClickHouse also supports: + +- [Parametric aggregate functions](parametric-functions.md#aggregate_functions_parametric), which accept other parameters in addition to columns. +- [Combinators](combinators.md#aggregate_functions_combinators), which change the behavior of aggregate functions. + +## NULL Processing {#null-processing} + +During aggregation, all `NULL`s are skipped. + +**Examples:** + +Consider this table: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +Let’s say you need to total the values in the `y` column: + +``` sql +SELECT sum(y) FROM t_null_big +``` + + ┌─sum(y)─┐ + │ 7 │ + └────────┘ + +The `sum` function interprets `NULL` as `0`. In particular, this means that if the function receives input of a selection where all the values are `NULL`, then the result will be `0`, not `NULL`. + +Now you can use the `groupArray` function to create an array from the `y` column: + +``` sql +SELECT groupArray(y) FROM t_null_big +``` + +``` text +┌─groupArray(y)─┐ +│ [2,2,3] │ +└───────────────┘ +``` + +`groupArray` does not include `NULL` in the resulting array. + +[Original article](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/en/sql-reference/aggregate-functions/parametric-functions.md b/docs/en/sql-reference/aggregate-functions/parametric-functions.md new file mode 100644 index 00000000000..a7908c1e740 --- /dev/null +++ b/docs/en/sql-reference/aggregate-functions/parametric-functions.md @@ -0,0 +1,497 @@ +--- +toc_priority: 38 +toc_title: Parametric +--- + +# Parametric Aggregate Functions {#aggregate_functions_parametric} + +Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. + +## histogram {#histogram} + +Calculates an adaptive histogram. It doesn’t guarantee precise results. + +``` sql +histogram(number_of_bins)(values) +``` + +The functions uses [A Streaming Parallel Decision Tree Algorithm](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). The borders of histogram bins are adjusted as new data enters a function. In common case, the widths of bins are not equal. + +**Parameters** + +`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. +`values` — [Expression](../syntax.md#syntax-expressions) resulting in input values. + +**Returned values** + +- [Array](../../sql-reference/data-types/array.md) of [Tuples](../../sql-reference/data-types/tuple.md) of the following format: + + ``` + [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] + ``` + + - `lower` — Lower bound of the bin. + - `upper` — Upper bound of the bin. + - `height` — Calculated height of the bin. + +**Example** + +``` sql +SELECT histogram(5)(number + 1) +FROM ( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ +│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +You can visualize a histogram with the [bar](../../sql-reference/functions/other-functions.md#function-bar) function, for example: + +``` sql +WITH histogram(5)(rand() % 100) AS hist +SELECT + arrayJoin(hist).3 AS height, + bar(height, 0, 6, 5) AS bar +FROM +( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─height─┬─bar───┐ +│ 2.125 │ █▋ │ +│ 3.25 │ ██▌ │ +│ 5.625 │ ████▏ │ +│ 5.625 │ ████▏ │ +│ 3.375 │ ██▌ │ +└────────┴───────┘ +``` + +In this case, you should remember that you don’t know the histogram bin borders. + +## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} + +Checks whether the sequence contains an event chain that matches the pattern. + +``` sql +sequenceMatch(pattern)(timestamp, cond1, cond2, ...) +``` + +!!! warning "Warning" + Events that occur at the same second may lay in the sequence in an undefined order affecting the result. + +**Parameters** + +- `pattern` — Pattern string. See [Pattern syntax](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported [UInt](../../sql-reference/data-types/int-uint.md) data types. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. + +**Returned values** + +- 1, if the pattern is matched. +- 0, if the pattern isn’t matched. + +Type: `UInt8`. + + +**Pattern syntax** + +- `(?N)` — Matches the condition argument at position `N`. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. + +- `.*` — Matches any number of events. You don’t need conditional arguments to match this element of the pattern. + +- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=` operators. + +**Examples** + +Consider data in the `t` table: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +└──────┴────────┘ +``` + +Perform the query: + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 1 │ +└───────────────────────────────────────────────────────────────────────┘ +``` + +The function found the event chain where number 2 follows number 1. It skipped number 3 between them, because the number is not described as an event. If we want to take this number into account when searching for the event chain given in the example, we should make a condition for it. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ +│ 0 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +In this case, the function couldn’t find the event chain matching the pattern, because the event for number 3 occured between 1 and 2. If in the same case we checked the condition for number 4, the sequence would match the pattern. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ +│ 1 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**See Also** + +- [sequenceCount](#function-sequencecount) + +## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} + +Counts the number of event chains that matched the pattern. The function searches event chains that don’t overlap. It starts to search for the next chain after the current chain is matched. + +!!! warning "Warning" + Events that occur at the same second may lay in the sequence in an undefined order affecting the result. + +``` sql +sequenceCount(pattern)(timestamp, cond1, cond2, ...) +``` + +**Parameters** + +- `pattern` — Pattern string. See [Pattern syntax](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported [UInt](../../sql-reference/data-types/int-uint.md) data types. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. + +**Returned values** + +- Number of non-overlapping event chains that are matched. + +Type: `UInt64`. + +**Example** + +Consider data in the `t` table: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +│ 4 │ 1 │ +│ 5 │ 3 │ +│ 6 │ 2 │ +└──────┴────────┘ +``` + +Count how many times the number 2 occurs after the number 1 with any amount of other numbers between them: + +``` sql +SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 2 │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +**See Also** + +- [sequenceMatch](#function-sequencematch) + +## windowFunnel {#windowfunnel} + +Searches for event chains in a sliding time window and calculates the maximum number of events that occurred from the chain. + +The function works according to the algorithm: + +- The function searches for data that triggers the first condition in the chain and sets the event counter to 1. This is the moment when the sliding window starts. + +- If events from the chain occur sequentially within the window, the counter is incremented. If the sequence of events is disrupted, the counter isn’t incremented. + +- If the data has multiple event chains at varying points of completion, the function will only output the size of the longest chain. + +**Syntax** + +``` sql +windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) +``` + +**Parameters** + +- `window` — Length of the sliding window in seconds. +- `mode` - It is an optional argument. + - `'strict'` - When the `'strict'` is set, the windowFunnel() applies conditions only for the unique values. +- `timestamp` — Name of the column containing the timestamp. Data types supported: [Date](../../sql-reference/data-types/date.md), [DateTime](../../sql-reference/data-types/datetime.md#data_type-datetime) and other unsigned integer types (note that even though timestamp supports the `UInt64` type, it’s value can’t exceed the Int64 maximum, which is 2^63 - 1). +- `cond` — Conditions or data describing the chain of events. [UInt8](../../sql-reference/data-types/int-uint.md). + +**Returned value** + +The maximum number of consecutive triggered conditions from the chain within the sliding time window. +All the chains in the selection are analyzed. + +Type: `Integer`. + +**Example** + +Determine if a set period of time is enough for the user to select a phone and purchase it twice in the online store. + +Set the following chain of events: + +1. The user logged in to their account on the store (`eventID = 1003`). +2. The user searches for a phone (`eventID = 1007, product = 'phone'`). +3. The user placed an order (`eventID = 1009`). +4. The user made the order again (`eventID = 1010`). + +Input table: + +``` text +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +``` + +Find out how far the user `user_id` could get through the chain in a period in January-February of 2019. + +Query: + +``` sql +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level + FROM trend + WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC +``` + +Result: + +``` text +┌─level─┬─c─┐ +│ 4 │ 1 │ +└───────┴───┘ +``` + +## retention {#retention} + +The function takes as arguments a set of conditions from 1 to 32 arguments of type `UInt8` that indicate whether a certain condition was met for the event. +Any condition can be specified as an argument (as in [WHERE](../../sql-reference/statements/select/where.md#select-where)). + +The conditions, except the first, apply in pairs: the result of the second will be true if the first and second are true, of the third if the first and third are true, etc. + +**Syntax** + +``` sql +retention(cond1, cond2, ..., cond32); +``` + +**Parameters** + +- `cond` — an expression that returns a `UInt8` result (1 or 0). + +**Returned value** + +The array of 1 or 0. + +- 1 — condition was met for the event. +- 0 — condition wasn’t met for the event. + +Type: `UInt8`. + +**Example** + +Let’s consider an example of calculating the `retention` function to determine site traffic. + +**1.** Сreate a table to illustrate an example. + +``` sql +CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; + +INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); +INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); +INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); +``` + +Input table: + +Query: + +``` sql +SELECT * FROM retention_test +``` + +Result: + +``` text +┌───────date─┬─uid─┐ +│ 2020-01-01 │ 0 │ +│ 2020-01-01 │ 1 │ +│ 2020-01-01 │ 2 │ +│ 2020-01-01 │ 3 │ +│ 2020-01-01 │ 4 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-02 │ 0 │ +│ 2020-01-02 │ 1 │ +│ 2020-01-02 │ 2 │ +│ 2020-01-02 │ 3 │ +│ 2020-01-02 │ 4 │ +│ 2020-01-02 │ 5 │ +│ 2020-01-02 │ 6 │ +│ 2020-01-02 │ 7 │ +│ 2020-01-02 │ 8 │ +│ 2020-01-02 │ 9 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-03 │ 0 │ +│ 2020-01-03 │ 1 │ +│ 2020-01-03 │ 2 │ +│ 2020-01-03 │ 3 │ +│ 2020-01-03 │ 4 │ +│ 2020-01-03 │ 5 │ +│ 2020-01-03 │ 6 │ +│ 2020-01-03 │ 7 │ +│ 2020-01-03 │ 8 │ +│ 2020-01-03 │ 9 │ +│ 2020-01-03 │ 10 │ +│ 2020-01-03 │ 11 │ +│ 2020-01-03 │ 12 │ +│ 2020-01-03 │ 13 │ +│ 2020-01-03 │ 14 │ +└────────────┴─────┘ +``` + +**2.** Group users by unique ID `uid` using the `retention` function. + +Query: + +``` sql +SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r +FROM retention_test +WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') +GROUP BY uid +ORDER BY uid ASC +``` + +Result: + +``` text +┌─uid─┬─r───────┐ +│ 0 │ [1,1,1] │ +│ 1 │ [1,1,1] │ +│ 2 │ [1,1,1] │ +│ 3 │ [1,1,1] │ +│ 4 │ [1,1,1] │ +│ 5 │ [0,0,0] │ +│ 6 │ [0,0,0] │ +│ 7 │ [0,0,0] │ +│ 8 │ [0,0,0] │ +│ 9 │ [0,0,0] │ +│ 10 │ [0,0,0] │ +│ 11 │ [0,0,0] │ +│ 12 │ [0,0,0] │ +│ 13 │ [0,0,0] │ +│ 14 │ [0,0,0] │ +└─────┴─────────┘ +``` + +**3.** Calculate the total number of site visits per day. + +Query: + +``` sql +SELECT + sum(r[1]) AS r1, + sum(r[2]) AS r2, + sum(r[3]) AS r3 +FROM +( + SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r + FROM retention_test + WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') + GROUP BY uid +) +``` + +Result: + +``` text +┌─r1─┬─r2─┬─r3─┐ +│ 5 │ 5 │ 5 │ +└────┴────┴────┘ +``` + +Where: + +- `r1`- the number of unique visitors who visited the site during 2020-01-01 (the `cond1` condition). +- `r2`- the number of unique visitors who visited the site during a specific time period between 2020-01-01 and 2020-01-02 (`cond1` and `cond2` conditions). +- `r3`- the number of unique visitors who visited the site during a specific time period between 2020-01-01 and 2020-01-03 (`cond1` and `cond3` conditions). + +## uniqUpTo(N)(x) {#uniquptonx} + +Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. + +Recommended for use with small Ns, up to 10. The maximum value of N is 100. + +For the state of an aggregate function, it uses the amount of memory equal to 1 + N \* the size of one value of bytes. +For strings, it stores a non-cryptographic hash of 8 bytes. That is, the calculation is approximated for strings. + +The function also works for several arguments. + +It works as fast as possible, except for cases when a large N value is used and the number of unique values is slightly less than N. + +Usage example: + +``` text +Problem: Generate a report that shows only keywords that produced at least 5 unique users. +Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 +``` + +[Original article](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) + +## sumMapFiltered(keys\_to\_keep)(keys, values) {#summapfilteredkeys-to-keepkeys-values} + +Same behavior as [sumMap](reference.md#agg_functions-summap) except that an array of keys is passed as a parameter. This can be especially useful when working with a high cardinality of keys. diff --git a/docs/en/sql-reference/aggregate-functions/reference.md b/docs/en/sql-reference/aggregate-functions/reference.md new file mode 100644 index 00000000000..baba1ce904e --- /dev/null +++ b/docs/en/sql-reference/aggregate-functions/reference.md @@ -0,0 +1,1975 @@ +--- +toc_priority: 36 +toc_title: Reference +--- + +# Aggregate Function Reference {#aggregate-functions-reference} + +## count {#agg_function-count} + +Counts the number of rows or not-NULL values. + +ClickHouse supports the following syntaxes for `count`: +- `count(expr)` or `COUNT(DISTINCT expr)`. +- `count()` or `COUNT(*)`. The `count()` syntax is ClickHouse-specific. + +**Parameters** + +The function can take: + +- Zero parameters. +- One [expression](../syntax.md#syntax-expressions). + +**Returned value** + +- If the function is called without parameters it counts the number of rows. +- If the [expression](../syntax.md#syntax-expressions) is passed, then the function counts how many times this expression returned not null. If the expression returns a [Nullable](../../sql-reference/data-types/nullable.md)-type value, then the result of `count` stays not `Nullable`. The function returns 0 if the expression returned `NULL` for all the rows. + +In both cases the type of the returned value is [UInt64](../../sql-reference/data-types/int-uint.md). + +**Details** + +ClickHouse supports the `COUNT(DISTINCT ...)` syntax. The behavior of this construction depends on the [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation) setting. It defines which of the [uniq\*](#agg_function-uniq) functions is used to perform the operation. The default is the [uniqExact](#agg_function-uniqexact) function. + +The `SELECT count() FROM table` query is not optimized, because the number of entries in the table is not stored separately. It chooses a small column from the table and counts the number of values in it. + +**Examples** + +Example 1: + +``` sql +SELECT count() FROM t +``` + +``` text +┌─count()─┐ +│ 5 │ +└─────────┘ +``` + +Example 2: + +``` sql +SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' +``` + +``` text +┌─name──────────────────────────┬─value─────┐ +│ count_distinct_implementation │ uniqExact │ +└───────────────────────────────┴───────────┘ +``` + +``` sql +SELECT count(DISTINCT num) FROM t +``` + +``` text +┌─uniqExact(num)─┐ +│ 3 │ +└────────────────┘ +``` + +This example shows that `count(DISTINCT num)` is performed by the `uniqExact` function according to the `count_distinct_implementation` setting value. + +## any(x) {#agg_function-any} + +Selects the first encountered value. +The query can be executed in any order and even in a different order each time, so the result of this function is indeterminate. +To get a determinate result, you can use the ‘min’ or ‘max’ function instead of ‘any’. + +In some cases, you can rely on the order of execution. This applies to cases when SELECT comes from a subquery that uses ORDER BY. + +When a `SELECT` query has the `GROUP BY` clause or at least one aggregate function, ClickHouse (in contrast to MySQL) requires that all expressions in the `SELECT`, `HAVING`, and `ORDER BY` clauses be calculated from keys or from aggregate functions. In other words, each column selected from the table must be used either in keys or inside aggregate functions. To get behavior like in MySQL, you can put the other columns in the `any` aggregate function. + +## anyHeavy(x) {#anyheavyx} + +Selects a frequently occurring value using the [heavy hitters](http://www.cs.umd.edu/~samir/498/karp.pdf) algorithm. If there is a value that occurs more than in half the cases in each of the query’s execution threads, this value is returned. Normally, the result is nondeterministic. + +``` sql +anyHeavy(column) +``` + +**Arguments** + +- `column` – The column name. + +**Example** + +Take the [OnTime](../../getting-started/example-datasets/ontime.md) data set and select any frequently occurring value in the `AirlineID` column. + +``` sql +SELECT anyHeavy(AirlineID) AS res +FROM ontime +``` + +``` text +┌───res─┐ +│ 19690 │ +└───────┘ +``` + +## anyLast(x) {#anylastx} + +Selects the last value encountered. +The result is just as indeterminate as for the `any` function. + +## groupBitAnd {#groupbitand} + +Applies bitwise `AND` for series of numbers. + +``` sql +groupBitAnd(expr) +``` + +**Parameters** + +`expr` – An expression that results in `UInt*` type. + +**Return value** + +Value of the `UInt*` type. + +**Example** + +Test data: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Query: + +``` sql +SELECT groupBitAnd(num) FROM t +``` + +Where `num` is the column with the test data. + +Result: + +``` text +binary decimal +00000100 = 4 +``` + +## groupBitOr {#groupbitor} + +Applies bitwise `OR` for series of numbers. + +``` sql +groupBitOr(expr) +``` + +**Parameters** + +`expr` – An expression that results in `UInt*` type. + +**Return value** + +Value of the `UInt*` type. + +**Example** + +Test data: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Query: + +``` sql +SELECT groupBitOr(num) FROM t +``` + +Where `num` is the column with the test data. + +Result: + +``` text +binary decimal +01111101 = 125 +``` + +## groupBitXor {#groupbitxor} + +Applies bitwise `XOR` for series of numbers. + +``` sql +groupBitXor(expr) +``` + +**Parameters** + +`expr` – An expression that results in `UInt*` type. + +**Return value** + +Value of the `UInt*` type. + +**Example** + +Test data: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Query: + +``` sql +SELECT groupBitXor(num) FROM t +``` + +Where `num` is the column with the test data. + +Result: + +``` text +binary decimal +01101000 = 104 +``` + +## groupBitmap {#groupbitmap} + +Bitmap or Aggregate calculations from a unsigned integer column, return cardinality of type UInt64, if add suffix -State, then return [bitmap object](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmap(expr) +``` + +**Parameters** + +`expr` – An expression that results in `UInt*` type. + +**Return value** + +Value of the `UInt64` type. + +**Example** + +Test data: + +``` text +UserID +1 +1 +2 +3 +``` + +Query: + +``` sql +SELECT groupBitmap(UserID) as num FROM t +``` + +Result: + +``` text +num +3 +``` + +## min(x) {#agg_function-min} + +Calculates the minimum. + +## max(x) {#agg_function-max} + +Calculates the maximum. + +## argMin(arg, val) {#agg-function-argmin} + +Calculates the ‘arg’ value for a minimal ‘val’ value. If there are several different values of ‘arg’ for minimal values of ‘val’, the first of these values encountered is output. + +**Example:** + +``` text +┌─user─────┬─salary─┐ +│ director │ 5000 │ +│ manager │ 3000 │ +│ worker │ 1000 │ +└──────────┴────────┘ +``` + +``` sql +SELECT argMin(user, salary) FROM salary +``` + +``` text +┌─argMin(user, salary)─┐ +│ worker │ +└──────────────────────┘ +``` + +## argMax(arg, val) {#agg-function-argmax} + +Calculates the ‘arg’ value for a maximum ‘val’ value. If there are several different values of ‘arg’ for maximum values of ‘val’, the first of these values encountered is output. + +## sum(x) {#agg_function-sum} + +Calculates the sum. +Only works for numbers. + +## sumWithOverflow(x) {#sumwithoverflowx} + +Computes the sum of the numbers, using the same data type for the result as for the input parameters. If the sum exceeds the maximum value for this data type, the function returns an error. + +Only works for numbers. + +## sumMap(key, value), sumMap(Tuple(key, value)) {#agg_functions-summap} + +Totals the ‘value’ array according to the keys specified in the ‘key’ array. +Passing tuple of keys and values arrays is synonymical to passing two arrays of keys and values. +The number of elements in ‘key’ and ‘value’ must be the same for each row that is totaled. +Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. + +Example: + +``` sql +CREATE TABLE sum_map( + date Date, + timeslot DateTime, + statusMap Nested( + status UInt16, + requests UInt64 + ), + statusMapTuple Tuple(Array(Int32), Array(Int32)) +) ENGINE = Log; +INSERT INTO sum_map VALUES + ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10], ([1, 2, 3], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10], ([3, 4, 5], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10], ([4, 5, 6], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10])); + +SELECT + timeslot, + sumMap(statusMap.status, statusMap.requests), + sumMap(statusMapTuple) +FROM sum_map +GROUP BY timeslot +``` + +``` text +┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┬─sumMap(statusMapTuple)─────────┐ +│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ ([1,2,3,4,5],[10,10,20,10,10]) │ +│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ ([4,5,6,7,8],[10,10,20,10,10]) │ +└─────────────────────┴──────────────────────────────────────────────┴────────────────────────────────┘ +``` + +## skewPop {#skewpop} + +Computes the [skewness](https://en.wikipedia.org/wiki/Skewness) of a sequence. + +``` sql +skewPop(expr) +``` + +**Parameters** + +`expr` — [Expression](../syntax.md#syntax-expressions) returning a number. + +**Returned value** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Example** + +``` sql +SELECT skewPop(value) FROM series_with_value_column +``` + +## skewSamp {#skewsamp} + +Computes the [sample skewness](https://en.wikipedia.org/wiki/Skewness) of a sequence. + +It represents an unbiased estimate of the skewness of a random variable if passed values form its sample. + +``` sql +skewSamp(expr) +``` + +**Parameters** + +`expr` — [Expression](../syntax.md#syntax-expressions) returning a number. + +**Returned value** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). If `n <= 1` (`n` is the size of the sample), then the function returns `nan`. + +**Example** + +``` sql +SELECT skewSamp(value) FROM series_with_value_column +``` + +## kurtPop {#kurtpop} + +Computes the [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of a sequence. + +``` sql +kurtPop(expr) +``` + +**Parameters** + +`expr` — [Expression](../syntax.md#syntax-expressions) returning a number. + +**Returned value** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Example** + +``` sql +SELECT kurtPop(value) FROM series_with_value_column +``` + +## kurtSamp {#kurtsamp} + +Computes the [sample kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of a sequence. + +It represents an unbiased estimate of the kurtosis of a random variable if passed values form its sample. + +``` sql +kurtSamp(expr) +``` + +**Parameters** + +`expr` — [Expression](../syntax.md#syntax-expressions) returning a number. + +**Returned value** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). If `n <= 1` (`n` is a size of the sample), then the function returns `nan`. + +**Example** + +``` sql +SELECT kurtSamp(value) FROM series_with_value_column +``` + +## timeSeriesGroupSum(uid, timestamp, value) {#agg-function-timeseriesgroupsum} + +`timeSeriesGroupSum` can aggregate different time series that sample timestamp not alignment. +It will use linear interpolation between two sample timestamp and then sum time-series together. + +- `uid` is the time series unique id, `UInt64`. +- `timestamp` is Int64 type in order to support millisecond or microsecond. +- `value` is the metric. + +The function returns array of tuples with `(timestamp, aggregated_value)` pairs. + +Before using this function make sure `timestamp` is in ascending order. + +Example: + +``` text +┌─uid─┬─timestamp─┬─value─┐ +│ 1 │ 2 │ 0.2 │ +│ 1 │ 7 │ 0.7 │ +│ 1 │ 12 │ 1.2 │ +│ 1 │ 17 │ 1.7 │ +│ 1 │ 25 │ 2.5 │ +│ 2 │ 3 │ 0.6 │ +│ 2 │ 8 │ 1.6 │ +│ 2 │ 12 │ 2.4 │ +│ 2 │ 18 │ 3.6 │ +│ 2 │ 24 │ 4.8 │ +└─────┴───────────┴───────┘ +``` + +``` sql +CREATE TABLE time_series( + uid UInt64, + timestamp Int64, + value Float64 +) ENGINE = Memory; +INSERT INTO time_series VALUES + (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), + (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); + +SELECT timeSeriesGroupSum(uid, timestamp, value) +FROM ( + SELECT * FROM time_series order by timestamp ASC +); +``` + +And the result will be: + +``` text +[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] +``` + +## timeSeriesGroupRateSum(uid, ts, val) {#agg-function-timeseriesgroupratesum} + +Similarly to `timeSeriesGroupSum`, `timeSeriesGroupRateSum` calculates the rate of time-series and then sum rates together. +Also, timestamp should be in ascend order before use this function. + +Applying this function to the data from the `timeSeriesGroupSum` example, you get the following result: + +``` text +[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] +``` + +## avg(x) {#agg_function-avg} + +Calculates the average. +Only works for numbers. +The result is always Float64. + +## avgWeighted {#avgweighted} + +Calculates the [weighted arithmetic mean](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean). + +**Syntax** + +``` sql +avgWeighted(x, weight) +``` + +**Parameters** + +- `x` — Values. [Integer](../data-types/int-uint.md) or [floating-point](../data-types/float.md). +- `weight` — Weights of the values. [Integer](../data-types/int-uint.md) or [floating-point](../data-types/float.md). + +Type of `x` and `weight` must be the same. + +**Returned value** + +- Weighted mean. +- `NaN`. If all the weights are equal to 0. + +Type: [Float64](../data-types/float.md). + +**Example** + +Query: + +``` sql +SELECT avgWeighted(x, w) +FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) +``` + +Result: + +``` text +┌─avgWeighted(x, weight)─┐ +│ 8 │ +└────────────────────────┘ +``` + +## uniq {#agg_function-uniq} + +Calculates the approximate number of different values of the argument. + +``` sql +uniq(x[, ...]) +``` + +**Parameters** + +The function takes a variable number of parameters. Parameters can be `Tuple`, `Array`, `Date`, `DateTime`, `String`, or numeric types. + +**Returned value** + +- A [UInt64](../../sql-reference/data-types/int-uint.md)-type number. + +**Implementation details** + +Function: + +- Calculates a hash for all parameters in the aggregate, then uses it in calculations. + +- Uses an adaptive sampling algorithm. For the calculation state, the function uses a sample of element hash values up to 65536. + + This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. + +- Provides the result deterministically (it doesn’t depend on the query processing order). + +We recommend using this function in almost all scenarios. + +**See Also** + +- [uniqCombined](#agg_function-uniqcombined) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined {#agg_function-uniqcombined} + +Calculates the approximate number of different argument values. + +``` sql +uniqCombined(HLL_precision)(x[, ...]) +``` + +The `uniqCombined` function is a good choice for calculating the number of different values. + +**Parameters** + +The function takes a variable number of parameters. Parameters can be `Tuple`, `Array`, `Date`, `DateTime`, `String`, or numeric types. + +`HLL_precision` is the base-2 logarithm of the number of cells in [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). Optional, you can use the function as `uniqCombined(x[, ...])`. The default value for `HLL_precision` is 17, which is effectively 96 KiB of space (2^17 cells, 6 bits each). + +**Returned value** + +- A number [UInt64](../../sql-reference/data-types/int-uint.md)-type number. + +**Implementation details** + +Function: + +- Calculates a hash (64-bit hash for `String` and 32-bit otherwise) for all parameters in the aggregate, then uses it in calculations. + +- Uses a combination of three algorithms: array, hash table, and HyperLogLog with an error correction table. + + For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. + +- Provides the result deterministically (it doesn’t depend on the query processing order). + +!!! note "Note" + Since it uses 32-bit hash for non-`String` type, the result will have very high error for cardinalities significantly larger than `UINT_MAX` (error will raise quickly after a few tens of billions of distinct values), hence in this case you should use [uniqCombined64](#agg_function-uniqcombined64) + +Compared to the [uniq](#agg_function-uniq) function, the `uniqCombined`: + +- Consumes several times less memory. +- Calculates with several times higher accuracy. +- Usually has slightly lower performance. In some scenarios, `uniqCombined` can perform better than `uniq`, for example, with distributed queries that transmit a large number of aggregation states over the network. + +**See Also** + +- [uniq](#agg_function-uniq) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined64 {#agg_function-uniqcombined64} + +Same as [uniqCombined](#agg_function-uniqcombined), but uses 64-bit hash for all data types. + +## uniqHLL12 {#agg_function-uniqhll12} + +Calculates the approximate number of different argument values, using the [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) algorithm. + +``` sql +uniqHLL12(x[, ...]) +``` + +**Parameters** + +The function takes a variable number of parameters. Parameters can be `Tuple`, `Array`, `Date`, `DateTime`, `String`, or numeric types. + +**Returned value** + +- A [UInt64](../../sql-reference/data-types/int-uint.md)-type number. + +**Implementation details** + +Function: + +- Calculates a hash for all parameters in the aggregate, then uses it in calculations. + +- Uses the HyperLogLog algorithm to approximate the number of different argument values. + + 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). + +- Provides the determinate result (it doesn’t depend on the query processing order). + +We don’t recommend using this function. In most cases, use the [uniq](#agg_function-uniq) or [uniqCombined](#agg_function-uniqcombined) function. + +**See Also** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqExact](#agg_function-uniqexact) + +## uniqExact {#agg_function-uniqexact} + +Calculates the exact number of different argument values. + +``` sql +uniqExact(x[, ...]) +``` + +Use the `uniqExact` function if you absolutely need an exact result. Otherwise use the [uniq](#agg_function-uniq) function. + +The `uniqExact` function uses more memory than `uniq`, because the size of the state has unbounded growth as the number of different values increases. + +**Parameters** + +The function takes a variable number of parameters. Parameters can be `Tuple`, `Array`, `Date`, `DateTime`, `String`, or numeric types. + +**See Also** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqHLL12](#agg_function-uniqhll12) + +## groupArray(x), groupArray(max\_size)(x) {#agg_function-grouparray} + +Creates an array of argument values. +Values can be added to the array in any (indeterminate) order. + +The second version (with the `max_size` parameter) limits the size of the resulting array to `max_size` elements. +For example, `groupArray (1) (x)` is equivalent to `[any (x)]`. + +In some cases, you can still rely on the order of execution. This applies to cases when `SELECT` comes from a subquery that uses `ORDER BY`. + +## groupArrayInsertAt {#grouparrayinsertat} + +Inserts a value into the array at the specified position. + +**Syntax** + +```sql +groupArrayInsertAt(default_x, size)(x, pos); +``` + +If in one query several values are inserted into the same position, the function behaves in the following ways: + +- If a query is executed in a single thread, the first one of the inserted values is used. +- If a query is executed in multiple threads, the resulting value is an undetermined one of the inserted values. + +**Parameters** + +- `x` — Value to be inserted. [Expression](../syntax.md#syntax-expressions) resulting in one of the [supported data types](../../sql-reference/data-types/index.md). +- `pos` — Position at which the specified element `x` is to be inserted. Index numbering in the array starts from zero. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). +- `default_x`— Default value for substituting in empty positions. Optional parameter. [Expression](../syntax.md#syntax-expressions) resulting in the data type configured for the `x` parameter. If `default_x` is not defined, the [default values](../../sql-reference/statements/create.md#create-default-values) are used. +- `size`— Length of the resulting array. Optional parameter. When using this parameter, the default value `default_x` must be specified. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). + +**Returned value** + +- Array with inserted values. + +Type: [Array](../../sql-reference/data-types/array.md#data-type-array). + +**Example** + +Query: + +```sql +SELECT groupArrayInsertAt(toString(number), number * 2) FROM numbers(5); +``` + +Result: + +```text +┌─groupArrayInsertAt(toString(number), multiply(number, 2))─┐ +│ ['0','','1','','2','','3','','4'] │ +└───────────────────────────────────────────────────────────┘ +``` + +Query: + +```sql +SELECT groupArrayInsertAt('-')(toString(number), number * 2) FROM numbers(5); +``` + +Result: + +```text +┌─groupArrayInsertAt('-')(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2','-','3','-','4'] │ +└────────────────────────────────────────────────────────────────┘ +``` + +Query: + +```sql +SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); +``` + +Result: + +```text +┌─groupArrayInsertAt('-', 5)(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2'] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +Multi-threaded insertion of elements into one position. + +Query: + +```sql +SELECT groupArrayInsertAt(number, 0) FROM numbers_mt(10) SETTINGS max_block_size = 1; +``` + +As a result of this query you get random integer in the `[0,9]` range. For example: + +```text +┌─groupArrayInsertAt(number, 0)─┐ +│ [7] │ +└───────────────────────────────┘ +``` + +## groupArrayMovingSum {#agg_function-grouparraymovingsum} + +Calculates the moving sum of input values. + +``` sql +groupArrayMovingSum(numbers_for_summing) +groupArrayMovingSum(window_size)(numbers_for_summing) +``` + +The function can take the window size as a parameter. If left unspecified, the function takes the window size equal to the number of rows in the column. + +**Parameters** + +- `numbers_for_summing` — [Expression](../syntax.md#syntax-expressions) resulting in a numeric data type value. +- `window_size` — Size of the calculation window. + +**Returned values** + +- Array of the same size and type as the input data. + +**Example** + +The sample table: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +The queries: + +``` sql +SELECT + groupArrayMovingSum(int) AS I, + groupArrayMovingSum(float) AS F, + groupArrayMovingSum(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingSum(2)(int) AS I, + groupArrayMovingSum(2)(float) AS F, + groupArrayMovingSum(2)(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +## groupArrayMovingAvg {#agg_function-grouparraymovingavg} + +Calculates the moving average of input values. + +``` sql +groupArrayMovingAvg(numbers_for_summing) +groupArrayMovingAvg(window_size)(numbers_for_summing) +``` + +The function can take the window size as a parameter. If left unspecified, the function takes the window size equal to the number of rows in the column. + +**Parameters** + +- `numbers_for_summing` — [Expression](../syntax.md#syntax-expressions) resulting in a numeric data type value. +- `window_size` — Size of the calculation window. + +**Returned values** + +- Array of the same size and type as the input data. + +The function uses [rounding towards zero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). It truncates the decimal places insignificant for the resulting data type. + +**Example** + +The sample table `b`: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +The queries: + +``` sql +SELECT + groupArrayMovingAvg(int) AS I, + groupArrayMovingAvg(float) AS F, + groupArrayMovingAvg(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ +│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ +└───────────┴─────────────────────────────────────┴───────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingAvg(2)(int) AS I, + groupArrayMovingAvg(2)(float) AS F, + groupArrayMovingAvg(2)(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ +│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ +└───────────┴──────────────────────────────────┴───────────────────────┘ +``` + +## groupUniqArray(x), groupUniqArray(max\_size)(x) {#groupuniqarrayx-groupuniqarraymax-sizex} + +Creates an array from different argument values. Memory consumption is the same as for the `uniqExact` function. + +The second version (with the `max_size` parameter) limits the size of the resulting array to `max_size` elements. +For example, `groupUniqArray(1)(x)` is equivalent to `[any(x)]`. + +## quantile {#quantile} + +Computes an approximate [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence. + +This function applies [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) with a reservoir size up to 8192 and a random number generator for sampling. The result is non-deterministic. To get an exact quantile, use the [quantileExact](#quantileexact) function. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantile(level)(expr) +``` + +Alias: `median`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [data types](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). + +**Returned value** + +- Approximate quantile of the specified level. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) for numeric data type input. +- [Date](../../sql-reference/data-types/date.md) if input values have the `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) if input values have the `DateTime` type. + +**Example** + +Input table: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Query: + +``` sql +SELECT quantile(val) FROM t +``` + +Result: + +``` text +┌─quantile(val)─┐ +│ 1.5 │ +└───────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileDeterministic {#quantiledeterministic} + +Computes an approximate [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence. + +This function applies [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) with a reservoir size up to 8192 and deterministic algorithm of sampling. The result is deterministic. To get an exact quantile, use the [quantileExact](#quantileexact) function. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileDeterministic(level)(expr, determinator) +``` + +Alias: `medianDeterministic`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [data types](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). +- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. + +**Returned value** + +- Approximate quantile of the specified level. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) for numeric data type input. +- [Date](../../sql-reference/data-types/date.md) if input values have the `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) if input values have the `DateTime` type. + +**Example** + +Input table: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Query: + +``` sql +SELECT quantileDeterministic(val, 1) FROM t +``` + +Result: + +``` text +┌─quantileDeterministic(val, 1)─┐ +│ 1.5 │ +└───────────────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileExact {#quantileexact} + +Exactly computes the [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` memory, where `n` is a number of values that were passed. However, for a small number of values, the function is very effective. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileExact(level)(expr) +``` + +Alias: `medianExact`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [data types](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). + +**Returned value** + +- Quantile of the specified level. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) for numeric data type input. +- [Date](../../sql-reference/data-types/date.md) if input values have the `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) if input values have the `DateTime` type. + +**Example** + +Query: + +``` sql +SELECT quantileExact(number) FROM numbers(10) +``` + +Result: + +``` text +┌─quantileExact(number)─┐ +│ 5 │ +└───────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileExactWeighted {#quantileexactweighted} + +Exactly computes the [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence, taking into account the weight of each element. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [quantileExact](#quantileexact). You can use this function instead of `quantileExact` and specify the weight 1. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileExactWeighted(level)(expr, weight) +``` + +Alias: `medianExactWeighted`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [data types](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. + +**Returned value** + +- Quantile of the specified level. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) for numeric data type input. +- [Date](../../sql-reference/data-types/date.md) if input values have the `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) if input values have the `DateTime` type. + +**Example** + +Input table: + +``` text +┌─n─┬─val─┐ +│ 0 │ 3 │ +│ 1 │ 2 │ +│ 2 │ 1 │ +│ 5 │ 4 │ +└───┴─────┘ +``` + +Query: + +``` sql +SELECT quantileExactWeighted(n, val) FROM t +``` + +Result: + +``` text +┌─quantileExactWeighted(n, val)─┐ +│ 1 │ +└───────────────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTiming {#quantiletiming} + +With the determined precision computes the [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence. + +The result is deterministic (it doesn’t depend on the query processing order). The function is optimized for working with sequences which describe distributions like loading web pages times or backend response times. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileTiming(level)(expr) +``` + +Alias: `medianTiming`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). + +- `expr` — [Expression](../syntax.md#syntax-expressions) over a column values returning a [Float\*](../../sql-reference/data-types/float.md)-type number. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +**Accuracy** + +The calculation is accurate if: + +- Total number of values doesn’t exceed 5670. +- Total number of values exceeds 5670, but the page loading time is less than 1024ms. + +Otherwise, the result of the calculation is rounded to the nearest multiple of 16 ms. + +!!! note "Note" + For calculating page loading time quantiles, this function is more effective and accurate than [quantile](#quantile). + +**Returned value** + +- Quantile of the specified level. + +Type: `Float32`. + +!!! note "Note" + If no values are passed to the function (when using `quantileTimingIf`), [NaN](../../sql-reference/data-types/float.md#data_type-float-nan-inf) is returned. The purpose of this is to differentiate these cases from cases that result in zero. See [ORDER BY clause](../statements/select/order-by.md#select-order-by) for notes on sorting `NaN` values. + +**Example** + +Input table: + +``` text +┌─response_time─┐ +│ 72 │ +│ 112 │ +│ 126 │ +│ 145 │ +│ 104 │ +│ 242 │ +│ 313 │ +│ 168 │ +│ 108 │ +└───────────────┘ +``` + +Query: + +``` sql +SELECT quantileTiming(response_time) FROM t +``` + +Result: + +``` text +┌─quantileTiming(response_time)─┐ +│ 126 │ +└───────────────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTimingWeighted {#quantiletimingweighted} + +With the determined precision computes the [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence according to the weight of each sequence member. + +The result is deterministic (it doesn’t depend on the query processing order). The function is optimized for working with sequences which describe distributions like loading web pages times or backend response times. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileTimingWeighted(level)(expr, weight) +``` + +Alias: `medianTimingWeighted`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). + +- `expr` — [Expression](../syntax.md#syntax-expressions) over a column values returning a [Float\*](../../sql-reference/data-types/float.md)-type number. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Accuracy** + +The calculation is accurate if: + +- Total number of values doesn’t exceed 5670. +- Total number of values exceeds 5670, but the page loading time is less than 1024ms. + +Otherwise, the result of the calculation is rounded to the nearest multiple of 16 ms. + +!!! note "Note" + For calculating page loading time quantiles, this function is more effective and accurate than [quantile](#quantile). + +**Returned value** + +- Quantile of the specified level. + +Type: `Float32`. + +!!! note "Note" + If no values are passed to the function (when using `quantileTimingIf`), [NaN](../../sql-reference/data-types/float.md#data_type-float-nan-inf) is returned. The purpose of this is to differentiate these cases from cases that result in zero. See [ORDER BY clause](../statements/select/order-by.md#select-order-by) for notes on sorting `NaN` values. + +**Example** + +Input table: + +``` text +┌─response_time─┬─weight─┐ +│ 68 │ 1 │ +│ 104 │ 2 │ +│ 112 │ 3 │ +│ 126 │ 2 │ +│ 138 │ 1 │ +│ 162 │ 1 │ +└───────────────┴────────┘ +``` + +Query: + +``` sql +SELECT quantileTimingWeighted(response_time, weight) FROM t +``` + +Result: + +``` text +┌─quantileTimingWeighted(response_time, weight)─┐ +│ 112 │ +└───────────────────────────────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTDigest {#quantiletdigest} + +Computes an approximate [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence using the [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algorithm. + +The maximum error is 1%. Memory consumption is `log(n)`, where `n` is a number of values. The result depends on the order of running the query, and is nondeterministic. + +The performance of the function is lower than performance of [quantile](#quantile) or [quantileTiming](#quantiletiming). In terms of the ratio of State size to precision, this function is much better than `quantile`. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileTDigest(level)(expr) +``` + +Alias: `medianTDigest`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [data types](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). + +**Returned value** + +- Approximate quantile of the specified level. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) for numeric data type input. +- [Date](../../sql-reference/data-types/date.md) if input values have the `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) if input values have the `DateTime` type. + +**Example** + +Query: + +``` sql +SELECT quantileTDigest(number) FROM numbers(10) +``` + +Result: + +``` text +┌─quantileTDigest(number)─┐ +│ 4.5 │ +└─────────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTDigestWeighted {#quantiletdigestweighted} + +Computes an approximate [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence using the [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algorithm. The function takes into account the weight of each sequence member. The maximum error is 1%. Memory consumption is `log(n)`, where `n` is a number of values. + +The performance of the function is lower than performance of [quantile](#quantile) or [quantileTiming](#quantiletiming). In terms of the ratio of State size to precision, this function is much better than `quantile`. + +The result depends on the order of running the query, and is nondeterministic. + +When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the [quantiles](#quantiles) function. + +**Syntax** + +``` sql +quantileTDigest(level)(expr) +``` + +Alias: `medianTDigest`. + +**Parameters** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates [median](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [data types](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Returned value** + +- Approximate quantile of the specified level. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) for numeric data type input. +- [Date](../../sql-reference/data-types/date.md) if input values have the `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) if input values have the `DateTime` type. + +**Example** + +Query: + +``` sql +SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) +``` + +Result: + +``` text +┌─quantileTDigestWeighted(number, 1)─┐ +│ 4.5 │ +└────────────────────────────────────┘ +``` + +**See Also** + +- [median](#median) +- [quantiles](#quantiles) + +## median {#median} + +The `median*` functions are the aliases for the corresponding `quantile*` functions. They calculate median of a numeric data sample. + +Functions: + +- `median` — Alias for [quantile](#quantile). +- `medianDeterministic` — Alias for [quantileDeterministic](#quantiledeterministic). +- `medianExact` — Alias for [quantileExact](#quantileexact). +- `medianExactWeighted` — Alias for [quantileExactWeighted](#quantileexactweighted). +- `medianTiming` — Alias for [quantileTiming](#quantiletiming). +- `medianTimingWeighted` — Alias for [quantileTimingWeighted](#quantiletimingweighted). +- `medianTDigest` — Alias for [quantileTDigest](#quantiletdigest). +- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](#quantiletdigestweighted). + +**Example** + +Input table: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Query: + +``` sql +SELECT medianDeterministic(val, 1) FROM t +``` + +Result: + +``` text +┌─medianDeterministic(val, 1)─┐ +│ 1.5 │ +└─────────────────────────────┘ +``` + +## quantiles(level1, level2, …)(x) {#quantiles} + +All the quantile functions also have corresponding quantiles functions: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. These functions calculate all the quantiles of the listed levels in one pass, and return an array of the resulting values. + +## varSamp(x) {#varsampx} + +Calculates the amount `Σ((x - x̅)^2) / (n - 1)`, where `n` is the sample size and `x̅`is the average value of `x`. + +It represents an unbiased estimate of the variance of a random variable if passed values form its sample. + +Returns `Float64`. When `n <= 1`, returns `+∞`. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `varSampStable` function. It works slower but provides a lower computational error. + +## varPop(x) {#varpopx} + +Calculates the amount `Σ((x - x̅)^2) / n`, where `n` is the sample size and `x̅`is the average value of `x`. + +In other words, dispersion for a set of values. Returns `Float64`. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `varPopStable` function. It works slower but provides a lower computational error. + +## stddevSamp(x) {#stddevsampx} + +The result is equal to the square root of `varSamp(x)`. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `stddevSampStable` function. It works slower but provides a lower computational error. + +## stddevPop(x) {#stddevpopx} + +The result is equal to the square root of `varPop(x)`. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `stddevPopStable` function. It works slower but provides a lower computational error. + +## topK(N)(x) {#topknx} + +Returns an array of the approximately most frequent values in the specified column. The resulting array is sorted in descending order of approximate frequency of values (not by the values themselves). + +Implements the [Filtered Space-Saving](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) algorithm for analyzing TopK, based on the reduce-and-combine algorithm from [Parallel Space Saving](https://arxiv.org/pdf/1401.0702.pdf). + +``` sql +topK(N)(column) +``` + +This function doesn’t provide a guaranteed result. In certain situations, errors might occur and it might return frequent values that aren’t the most frequent values. + +We recommend using the `N < 10` value; performance is reduced with large `N` values. Maximum value of `N = 65536`. + +**Parameters** + +- ‘N’ is the number of elements to return. + +If the parameter is omitted, default value 10 is used. + +**Arguments** + +- ’ x ’ – The value to calculate frequency. + +**Example** + +Take the [OnTime](../../getting-started/example-datasets/ontime.md) data set and select the three most frequently occurring values in the `AirlineID` column. + +``` sql +SELECT topK(3)(AirlineID) AS res +FROM ontime +``` + +``` text +┌─res─────────────────┐ +│ [19393,19790,19805] │ +└─────────────────────┘ +``` + +## topKWeighted {#topkweighted} + +Similar to `topK` but takes one additional argument of integer type - `weight`. Every value is accounted `weight` times for frequency calculation. + +**Syntax** + +``` sql +topKWeighted(N)(x, weight) +``` + +**Parameters** + +- `N` — The number of elements to return. + +**Arguments** + +- `x` – The value. +- `weight` — The weight. [UInt8](../../sql-reference/data-types/int-uint.md). + +**Returned value** + +Returns an array of the values with maximum approximate sum of weights. + +**Example** + +Query: + +``` sql +SELECT topKWeighted(10)(number, number) FROM numbers(1000) +``` + +Result: + +``` text +┌─topKWeighted(10)(number, number)──────────┐ +│ [999,998,997,996,995,994,993,992,991,990] │ +└───────────────────────────────────────────┘ +``` + +## covarSamp(x, y) {#covarsampx-y} + +Calculates the value of `Σ((x - x̅)(y - y̅)) / (n - 1)`. + +Returns Float64. When `n <= 1`, returns +∞. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `covarSampStable` function. It works slower but provides a lower computational error. + +## covarPop(x, y) {#covarpopx-y} + +Calculates the value of `Σ((x - x̅)(y - y̅)) / n`. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `covarPopStable` function. It works slower but provides a lower computational error. + +## corr(x, y) {#corrx-y} + +Calculates the Pearson correlation coefficient: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. + +!!! note "Note" + This function uses a numerically unstable algorithm. If you need [numerical stability](https://en.wikipedia.org/wiki/Numerical_stability) in calculations, use the `corrStable` function. It works slower but provides a lower computational error. + +## categoricalInformationValue {#categoricalinformationvalue} + +Calculates the value of `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` for each category. + +``` sql +categoricalInformationValue(category1, category2, ..., tag) +``` + +The result indicates how a discrete (categorical) feature `[category1, category2, ...]` contribute to a learning model which predicting the value of `tag`. + +## simpleLinearRegression {#simplelinearregression} + +Performs simple (unidimensional) linear regression. + +``` sql +simpleLinearRegression(x, y) +``` + +Parameters: + +- `x` — Column with dependent variable values. +- `y` — Column with explanatory variable values. + +Returned values: + +Constants `(a, b)` of the resulting line `y = a*x + b`. + +**Examples** + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ +│ (1,0) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ +│ (1,3) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## stochasticLinearRegression {#agg_functions-stochasticlinearregression} + +This function implements stochastic linear regression. It supports custom parameters for learning rate, L2 regularization coefficient, mini-batch size and has few methods for updating weights ([Adam](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (used by default), [simple SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [Momentum](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). + +### Parameters {#agg_functions-stochasticlinearregression-parameters} + +There are 4 customizable parameters. They are passed to the function sequentially, but there is no need to pass all four - default values will be used, however good model required some parameter tuning. + +``` text +stochasticLinearRegression(1.0, 1.0, 10, 'SGD') +``` + +1. `learning rate` is the coefficient on step length, when gradient descent step is performed. Too big learning rate may cause infinite weights of the model. Default is `0.00001`. +2. `l2 regularization coefficient` which may help to prevent overfitting. Default is `0.1`. +3. `mini-batch size` sets the number of elements, which gradients will be computed and summed to perform one step of gradient descent. Pure stochastic descent uses one element, however having small batches(about 10 elements) make gradient steps more stable. Default is `15`. +4. `method for updating weights`, they are: `Adam` (by default), `SGD`, `Momentum`, `Nesterov`. `Momentum` and `Nesterov` require little bit more computations and memory, however they happen to be useful in terms of speed of convergance and stability of stochastic gradient methods. + +### Usage {#agg_functions-stochasticlinearregression-usage} + +`stochasticLinearRegression` is used in two steps: fitting the model and predicting on new data. In order to fit the model and save its state for later usage we use `-State` combinator, which basically saves the state (model weights, etc). +To predict we use function [evalMLMethod](../functions/machine-learning-functions.md#machine_learning_methods-evalmlmethod), which takes a state as an argument as well as features to predict on. + + + +**1.** Fitting + +Such query may be used. + +``` sql +CREATE TABLE IF NOT EXISTS train_data +( + param1 Float64, + param2 Float64, + target Float64 +) ENGINE = Memory; + +CREATE TABLE your_model ENGINE = Memory AS SELECT +stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) +AS state FROM train_data; +``` + +Here we also need to insert data into `train_data` table. The number of parameters is not fixed, it depends only on number of arguments, passed into `linearRegressionState`. They all must be numeric values. +Note that the column with target value(which we would like to learn to predict) is inserted as the first argument. + +**2.** Predicting + +After saving a state into the table, we may use it multiple times for prediction, or even merge with other states and create new even better models. + +``` sql +WITH (SELECT state FROM your_model) AS model SELECT +evalMLMethod(model, param1, param2) FROM test_data +``` + +The query will return a column of predicted values. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. + +`test_data` is a table like `train_data` but may not contain target value. + +### Notes {#agg_functions-stochasticlinearregression-notes} + +1. To merge two models user may create such query: + `sql SELECT state1 + state2 FROM your_models` + where `your_models` table contains both models. This query will return new `AggregateFunctionState` object. + +2. User may fetch weights of the created model for its own purposes without saving the model if no `-State` combinator is used. + `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` + Such query will fit the model and return its weights - first are weights, which correspond to the parameters of the model, the last one is bias. So in the example above the query will return a column with 3 values. + +**See Also** + +- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) +- [Difference between linear and logistic regressions](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} + +This function implements stochastic logistic regression. It can be used for binary classification problem, supports the same custom parameters as stochasticLinearRegression and works the same way. + +### Parameters {#agg_functions-stochasticlogisticregression-parameters} + +Parameters are exactly the same as in stochasticLinearRegression: +`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. +For more information see [parameters](#agg_functions-stochasticlinearregression-parameters). + +``` text +stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') +``` + +**1.** Fitting + + + + See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. + + Predicted labels have to be in \[-1, 1\]. + +**2.** Predicting + + + + Using saved state we can predict probability of object having label `1`. + + ``` sql + WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) FROM test_data + ``` + + The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. + + We can also set a bound of probability, which assigns elements to different labels. + + ``` sql + SELECT ans < 1.1 AND ans > 0.5 FROM + (WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) AS ans FROM test_data) + ``` + + Then the result will be labels. + + `test_data` is a table like `train_data` but may not contain target value. + +**See Also** + +- [stochasticLinearRegression](#agg_functions-stochasticlinearregression) +- [Difference between linear and logistic regressions.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## groupBitmapAnd {#groupbitmapand} + +Calculations the AND of a bitmap column, return cardinality of type UInt64, if add suffix -State, then return [bitmap object](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapAnd(expr) +``` + +**Parameters** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` type. + +**Return value** + +Value of the `UInt64` type. + +**Example** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapAnd(z)─┐ +│ 3 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ +│ [6,8,10] │ +└──────────────────────────────────────────────────┘ +``` + +## groupBitmapOr {#groupbitmapor} + +Calculations the OR of a bitmap column, return cardinality of type UInt64, if add suffix -State, then return [bitmap object](../../sql-reference/functions/bitmap-functions.md). This is equivalent to `groupBitmapMerge`. + +``` sql +groupBitmapOr(expr) +``` + +**Parameters** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` type. + +**Return value** + +Value of the `UInt64` type. + +**Example** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapOr(z)─┐ +│ 15 │ +└──────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ +│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ +└─────────────────────────────────────────────────┘ +``` + +## groupBitmapXor {#groupbitmapxor} + +Calculations the XOR of a bitmap column, return cardinality of type UInt64, if add suffix -State, then return [bitmap object](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapOr(expr) +``` + +**Parameters** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` type. + +**Return value** + +Value of the `UInt64` type. + +**Example** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapXor(z)─┐ +│ 10 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ +│ [1,3,5,6,8,10,11,13,14,15] │ +└──────────────────────────────────────────────────┘ +``` + +[Original article](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/en/sql-reference/ansi.md b/docs/en/sql-reference/ansi.md new file mode 100644 index 00000000000..805741ba9d5 --- /dev/null +++ b/docs/en/sql-reference/ansi.md @@ -0,0 +1,178 @@ +--- +toc_priority: 40 +toc_title: ANSI Compatibility +--- + +# ANSI SQL Compatibility of ClickHouse SQL Dialect {#ansi-sql-compatibility-of-clickhouse-sql-dialect} + +!!! note "Note" + This article relies on Table 38, “Feature taxonomy and definition for mandatory features”, Annex F of ISO/IEC CD 9075-2:2013. + +## Differences in Behaviour {#differences-in-behaviour} + +The following table lists cases when query feature works in ClickHouse, but behaves not as specified in ANSI SQL. + +| Feature ID | Feature Name | Difference | +|------------|-----------------------------|-----------------------------------------------------------------------------------------------------------| +| E011 | Numeric data types | Numeric literal with period is interpreted as approximate (`Float64`) instead of exact (`Decimal`) | +| E051-05 | Select items can be renamed | Item renames have a wider visibility scope than just the SELECT result | +| E141-01 | NOT NULL constraints | `NOT NULL` is implied for table columns by default | +| E011-04 | Arithmetic operators | ClickHouse overflows instead of checked arithmetic and changes the result data type based on custom rules | + +## Feature Status {#feature-status} + +| Feature ID | Feature Name | Status | Comment | +|------------|--------------------------------------------------------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **E011** | **Numeric data types** | **Partial**{.text-warning} | | +| E011-01 | INTEGER and SMALLINT data types | Yes{.text-success} | | +| E011-02 | REAL, DOUBLE PRECISION and FLOAT data types data types | Partial{.text-warning} | `FLOAT()`, `REAL` and `DOUBLE PRECISION` are not supported | +| E011-03 | DECIMAL and NUMERIC data types | Partial{.text-warning} | Only `DECIMAL(p,s)` is supported, not `NUMERIC` | +| E011-04 | Arithmetic operators | Yes{.text-success} | | +| E011-05 | Numeric comparison | Yes{.text-success} | | +| E011-06 | Implicit casting among the numeric data types | No{.text-danger} | ANSI SQL allows arbitrary implicit cast between numeric types, while ClickHouse relies on functions having multiple overloads instead of implicit cast | +| **E021** | **Character string types** | **Partial**{.text-warning} | | +| E021-01 | CHARACTER data type | No{.text-danger} | | +| E021-02 | CHARACTER VARYING data type | No{.text-danger} | `String` behaves similarly, but without length limit in parentheses | +| E021-03 | Character literals | Partial{.text-warning} | No automatic concatenation of consecutive literals and character set support | +| E021-04 | CHARACTER\_LENGTH function | Partial{.text-warning} | No `USING` clause | +| E021-05 | OCTET\_LENGTH function | No{.text-danger} | `LENGTH` behaves similarly | +| E021-06 | SUBSTRING | Partial{.text-warning} | No support for `SIMILAR` and `ESCAPE` clauses, no `SUBSTRING_REGEX` variant | +| E021-07 | Character concatenation | Partial{.text-warning} | No `COLLATE` clause | +| E021-08 | UPPER and LOWER functions | Yes{.text-success} | | +| E021-09 | TRIM function | Yes{.text-success} | | +| E021-10 | Implicit casting among the fixed-length and variable-length character string types | No{.text-danger} | ANSI SQL allows arbitrary implicit cast between string types, while ClickHouse relies on functions having multiple overloads instead of implicit cast | +| E021-11 | POSITION function | Partial{.text-warning} | No support for `IN` and `USING` clauses, no `POSITION_REGEX` variant | +| E021-12 | Character comparison | Yes{.text-success} | | +| **E031** | **Identifiers** | **Partial**{.text-warning} | | +| E031-01 | Delimited identifiers | Partial{.text-warning} | Unicode literal support is limited | +| E031-02 | Lower case identifiers | Yes{.text-success} | | +| E031-03 | Trailing underscore | Yes{.text-success} | | +| **E051** | **Basic query specification** | **Partial**{.text-warning} | | +| E051-01 | SELECT DISTINCT | Yes{.text-success} | | +| E051-02 | GROUP BY clause | Yes{.text-success} | | +| E051-04 | GROUP BY can contain columns not in `` | Yes{.text-success} | | -| E051-05 | Select items can be renamed | Yes{.text-success} | | -| E051-06 | HAVING clause | Yes{.text-success} | | -| E051-07 | Qualified \* in select list | Yes{.text-success} | | -| E051-08 | Correlation name in the FROM clause | Yes{.text-success} | | -| E051-09 | Rename columns in the FROM clause | No{.text-danger} | | -| **E061** | **Basic predicates and search conditions** | **Partial**{.text-warning} | | -| E061-01 | Comparison predicate | Yes{.text-success} | | -| E061-02 | BETWEEN predicate | Partial{.text-warning} | No `SYMMETRIC` and `ASYMMETRIC` clause | -| E061-03 | IN predicate with list of values | Yes{.text-success} | | -| E061-04 | LIKE predicate | Yes{.text-success} | | -| E061-05 | LIKE predicate: ESCAPE clause | No{.text-danger} | | -| E061-06 | NULL predicate | Yes{.text-success} | | -| E061-07 | Quantified comparison predicate | No{.text-danger} | | -| E061-08 | EXISTS predicate | No{.text-danger} | | -| E061-09 | Subqueries in comparison predicate | Yes{.text-success} | | -| E061-11 | Subqueries in IN predicate | Yes{.text-success} | | -| E061-12 | Subqueries in quantified comparison predicate | No{.text-danger} | | -| E061-13 | Correlated subqueries | No{.text-danger} | | -| E061-14 | Search condition | Yes{.text-success} | | -| **E071** | **Basic query expressions** | **Partial**{.text-warning} | | -| E071-01 | UNION DISTINCT table operator | No{.text-danger} | | -| E071-02 | UNION ALL table operator | Yes{.text-success} | | -| E071-03 | EXCEPT DISTINCT table operator | No{.text-danger} | | -| E071-05 | Columns combined via table operators need not have exactly the same data type | Yes{.text-success} | | -| E071-06 | Table operators in subqueries | Yes{.text-success} | | -| **E081** | **Basic privileges** | **Partial**{.text-warning} | Work in progress | -| **E091** | **Set functions** | **Yes**{.text-success} | | -| E091-01 | AVG | Yes{.text-success} | | -| E091-02 | COUNT | Yes{.text-success} | | -| E091-03 | MAX | Yes{.text-success} | | -| E091-04 | MIN | Yes{.text-success} | | -| E091-05 | SUM | Yes{.text-success} | | -| E091-06 | ALL quantifier | No{.text-danger} | | -| E091-07 | DISTINCT quantifier | Partial{.text-warning} | Not all aggregate functions supported | -| **E101** | **Basic data manipulation** | **Partial**{.text-warning} | | -| E101-01 | INSERT statement | Yes{.text-success} | Note: primary key in ClickHouse does not imply the `UNIQUE` constraint | -| E101-03 | Searched UPDATE statement | No{.text-danger} | There’s an `ALTER UPDATE` statement for batch data modification | -| E101-04 | Searched DELETE statement | No{.text-danger} | There’s an `ALTER DELETE` statement for batch data removal | -| **E111** | **Single row SELECT statement** | **No**{.text-danger} | | -| **E121** | **Basic cursor support** | **No**{.text-danger} | | -| E121-01 | DECLARE CURSOR | No{.text-danger} | | -| E121-02 | ORDER BY columns need not be in select list | No{.text-danger} | | -| E121-03 | Value expressions in ORDER BY clause | No{.text-danger} | | -| E121-04 | OPEN statement | No{.text-danger} | | -| E121-06 | Positioned UPDATE statement | No{.text-danger} | | -| E121-07 | Positioned DELETE statement | No{.text-danger} | | -| E121-08 | CLOSE statement | No{.text-danger} | | -| E121-10 | FETCH statement: implicit NEXT | No{.text-danger} | | -| E121-17 | WITH HOLD cursors | No{.text-danger} | | -| **E131** | **Null value support (nulls in lieu of values)** | **Partial**{.text-warning} | Some restrictions apply | -| **E141** | **Basic integrity constraints** | **Partial**{.text-warning} | | -| E141-01 | NOT NULL constraints | Yes{.text-success} | Note: `NOT NULL` is implied for table columns by default | -| E141-02 | UNIQUE constraint of NOT NULL columns | No{.text-danger} | | -| E141-03 | PRIMARY KEY constraints | No{.text-danger} | | -| E141-04 | Basic FOREIGN KEY constraint with the NO ACTION default for both referential delete action and referential update action | No{.text-danger} | | -| E141-06 | CHECK constraint | Yes{.text-success} | | -| E141-07 | Column defaults | Yes{.text-success} | | -| E141-08 | NOT NULL inferred on PRIMARY KEY | Yes{.text-success} | | -| E141-10 | Names in a foreign key can be specified in any order | No{.text-danger} | | -| **E151** | **Transaction support** | **No**{.text-danger} | | -| E151-01 | COMMIT statement | No{.text-danger} | | -| E151-02 | ROLLBACK statement | No{.text-danger} | | -| **E152** | **Basic SET TRANSACTION statement** | **No**{.text-danger} | | -| E152-01 | SET TRANSACTION statement: ISOLATION LEVEL SERIALIZABLE clause | No{.text-danger} | | -| E152-02 | SET TRANSACTION statement: READ ONLY and READ WRITE clauses | No{.text-danger} | | -| **E153** | **Updatable queries with subqueries** | **No**{.text-danger} | | -| **E161** | **SQL comments using leading double minus** | **Yes**{.text-success} | | -| **E171** | **SQLSTATE support** | **No**{.text-danger} | | -| **E182** | **Host language binding** | **No**{.text-danger} | | -| **F031** | **Basic schema manipulation** | **Partial**{.text-warning} | | -| F031-01 | CREATE TABLE statement to create persistent base tables | Partial{.text-warning} | No `SYSTEM VERSIONING`, `ON COMMIT`, `GLOBAL`, `LOCAL`, `PRESERVE`, `DELETE`, `REF IS`, `WITH OPTIONS`, `UNDER`, `LIKE`, `PERIOD FOR` clauses and no support for user resolved data types | -| F031-02 | CREATE VIEW statement | Partial{.text-warning} | No `RECURSIVE`, `CHECK`, `UNDER`, `WITH OPTIONS` clauses and no support for user resolved data types | -| F031-03 | GRANT statement | Yes{.text-success} | | -| F031-04 | ALTER TABLE statement: ADD COLUMN clause | Partial{.text-warning} | No support for `GENERATED` clause and system time period | -| F031-13 | DROP TABLE statement: RESTRICT clause | No{.text-danger} | | -| F031-16 | DROP VIEW statement: RESTRICT clause | No{.text-danger} | | -| F031-19 | REVOKE statement: RESTRICT clause | No{.text-danger} | | -| **F041** | **Basic joined table** | **Partial**{.text-warning} | | -| F041-01 | Inner join (but not necessarily the INNER keyword) | Yes{.text-success} | | -| F041-02 | INNER keyword | Yes{.text-success} | | -| F041-03 | LEFT OUTER JOIN | Yes{.text-success} | | -| F041-04 | RIGHT OUTER JOIN | Yes{.text-success} | | -| F041-05 | Outer joins can be nested | Yes{.text-success} | | -| F041-07 | The inner table in a left or right outer join can also be used in an inner join | Yes{.text-success} | | -| F041-08 | All comparison operators are supported (rather than just =) | No{.text-danger} | | -| **F051** | **Basic date and time** | **Partial**{.text-warning} | | -| F051-01 | DATE data type (including support of DATE literal) | Partial{.text-warning} | No literal | -| F051-02 | TIME data type (including support of TIME literal) with fractional seconds precision of at least 0 | No{.text-danger} | | -| F051-03 | TIMESTAMP data type (including support of TIMESTAMP literal) with fractional seconds precision of at least 0 and 6 | No{.text-danger} | `DateTime64` time provides similar functionality | -| F051-04 | Comparison predicate on DATE, TIME, and TIMESTAMP data types | Partial{.text-warning} | Only one data type available | -| F051-05 | Explicit CAST between datetime types and character string types | Yes{.text-success} | | -| F051-06 | CURRENT\_DATE | No{.text-danger} | `today()` is similar | -| F051-07 | LOCALTIME | No{.text-danger} | `now()` is similar | -| F051-08 | LOCALTIMESTAMP | No{.text-danger} | | -| **F081** | **UNION and EXCEPT in views** | **Partial**{.text-warning} | | -| **F131** | **Grouped operations** | **Partial**{.text-warning} | | -| F131-01 | WHERE, GROUP BY, and HAVING clauses supported in queries with grouped views | Yes{.text-success} | | -| F131-02 | Multiple tables supported in queries with grouped views | Yes{.text-success} | | -| F131-03 | Set functions supported in queries with grouped views | Yes{.text-success} | | -| F131-04 | Subqueries with GROUP BY and HAVING clauses and grouped views | Yes{.text-success} | | -| F131-05 | Single row SELECT with GROUP BY and HAVING clauses and grouped views | No{.text-danger} | | -| **F181** | **Multiple module support** | **No**{.text-danger} | | -| **F201** | **CAST function** | **Yes**{.text-success} | | -| **F221** | **Explicit defaults** | **No**{.text-danger} | | -| **F261** | **CASE expression** | **Yes**{.text-success} | | -| F261-01 | Simple CASE | Yes{.text-success} | | -| F261-02 | Searched CASE | Yes{.text-success} | | -| F261-03 | NULLIF | Yes{.text-success} | | -| F261-04 | COALESCE | Yes{.text-success} | | -| **F311** | **Schema definition statement** | **Partial**{.text-warning} | | -| F311-01 | CREATE SCHEMA | No{.text-danger} | | -| F311-02 | CREATE TABLE for persistent base tables | Yes{.text-success} | | -| F311-03 | CREATE VIEW | Yes{.text-success} | | -| F311-04 | CREATE VIEW: WITH CHECK OPTION | No{.text-danger} | | -| F311-05 | GRANT statement | Yes{.text-success} | | -| **F471** | **Scalar subquery values** | **Yes**{.text-success} | | -| **F481** | **Expanded NULL predicate** | **Yes**{.text-success} | | -| **F812** | **Basic flagging** | **No**{.text-danger} | | -| **T321** | **Basic SQL-invoked routines** | **No**{.text-danger} | | -| T321-01 | User-defined functions with no overloading | No{.text-danger} | | -| T321-02 | User-defined stored procedures with no overloading | No{.text-danger} | | -| T321-03 | Function invocation | No{.text-danger} | | -| T321-04 | CALL statement | No{.text-danger} | | -| T321-05 | RETURN statement | No{.text-danger} | | -| **T631** | **IN predicate with one list element** | **Yes**{.text-success} | | diff --git a/docs/en/sql_reference/data_types/aggregatefunction.md b/docs/en/sql_reference/data_types/aggregatefunction.md deleted file mode 100644 index 57935557ba9..00000000000 --- a/docs/en/sql_reference/data_types/aggregatefunction.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -toc_priority: 52 -toc_title: AggregateFunction(name, types_of_arguments...) ---- - -# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} - -Aggregate functions can have an implementation-defined intermediate state that can be serialized to an AggregateFunction(...) data type and stored in a table, usually, by means of [a materialized view](../../sql_reference/statements/select.md#create-view). The common way to produce an aggregate function state is by calling the aggregate function with the `-State` suffix. To get the final result of aggregation in the future, you must use the same aggregate function with the `-Merge`suffix. - -`AggregateFunction` — parametric data type. - -**Parameters** - -- Name of the aggregate function. - - If the function is parametric, specify its parameters too. - -- Types of the aggregate function arguments. - -**Example** - -``` sql -CREATE TABLE t -( - column1 AggregateFunction(uniq, UInt64), - column2 AggregateFunction(anyIf, String, UInt8), - column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) -) ENGINE = ... -``` - -[uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq), anyIf ([any](../../sql_reference/aggregate_functions/reference.md#agg_function-any)+[If](../../sql_reference/aggregate_functions/combinators.md#agg-functions-combinator-if)) and [quantiles](../../sql_reference/aggregate_functions/reference.md) are the aggregate functions supported in ClickHouse. - -## Usage {#usage} - -### Data Insertion {#data-insertion} - -To insert data, use `INSERT SELECT` with aggregate `-State`- functions. - -**Function examples** - -``` sql -uniqState(UserID) -quantilesState(0.5, 0.9)(SendTiming) -``` - -In contrast to the corresponding functions `uniq` and `quantiles`, `-State`- functions return the state, instead of the final value. In other words, they return a value of `AggregateFunction` type. - -In the results of `SELECT` query, the values of `AggregateFunction` type have implementation-specific binary representation for all of the ClickHouse output formats. If dump data into, for example, `TabSeparated` format with `SELECT` query, then this dump can be loaded back using `INSERT` query. - -### Data Selection {#data-selection} - -When selecting data from `AggregatingMergeTree` table, use `GROUP BY` clause and the same aggregate functions as when inserting data, but using `-Merge`suffix. - -An aggregate function with `-Merge` suffix takes a set of states, combines them, and returns the result of complete data aggregation. - -For example, the following two queries return the same result: - -``` sql -SELECT uniq(UserID) FROM table - -SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) -``` - -## Usage Example {#usage-example} - -See [AggregatingMergeTree](../../engines/table_engines/mergetree_family/aggregatingmergetree.md) engine description. - -[Original article](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/en/sql_reference/data_types/array.md b/docs/en/sql_reference/data_types/array.md deleted file mode 100644 index 58b1d25df04..00000000000 --- a/docs/en/sql_reference/data_types/array.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -toc_priority: 51 -toc_title: Array(T) ---- - -# Array(t) {#data-type-array} - -An array of `T`-type items. `T` can be any data type, including an array. - -## Creating an Array {#creating-an-array} - -You can use a function to create an array: - -``` sql -array(T) -``` - -You can also use square brackets. - -``` sql -[] -``` - -Example of creating an array: - -``` sql -SELECT array(1, 2) AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName(array(1, 2))─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴─────────────────────────┘ -``` - -``` sql -SELECT [1, 2] AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName([1, 2])─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴────────────────────┘ -``` - -## Working With Data Types {#working-with-data-types} - -When creating an array on the fly, ClickHouse automatically defines the argument type as the narrowest data type that can store all the listed arguments. If there are any [Nullable](nullable.md#data_type-nullable) or literal [NULL](../../sql_reference/syntax.md#null-literal) values, the type of an array element also becomes [Nullable](nullable.md). - -If ClickHouse couldn’t determine the data type, it generates an exception. For instance, this happens when trying to create an array with strings and numbers simultaneously (`SELECT array(1, 'a')`). - -Examples of automatic data type detection: - -``` sql -SELECT array(1, 2, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ -│ [1,2,NULL] │ Array(Nullable(UInt8)) │ -└────────────┴───────────────────────────────┘ -``` - -If you try to create an array of incompatible data types, ClickHouse throws an exception: - -``` sql -SELECT array(1, 'a') -``` - -``` text -Received exception from server (version 1.1.54388): -Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. -``` - -[Original article](https://clickhouse.tech/docs/en/data_types/array/) diff --git a/docs/en/sql_reference/data_types/datetime.md b/docs/en/sql_reference/data_types/datetime.md deleted file mode 100644 index ee108dfe078..00000000000 --- a/docs/en/sql_reference/data_types/datetime.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -toc_priority: 48 -toc_title: DateTime ---- - -# Datetime {#data_type-datetime} - -Allows to store an instant in time, that can be expressed as a calendar date and a time of a day. - -Syntax: - -``` sql -DateTime([timezone]) -``` - -Supported range of values: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. - -Resolution: 1 second. - -## Usage Remarks {#usage-remarks} - -The point in time is saved as a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time), regardless of the time zone or daylight saving time. Additionally, the `DateTime` type can store time zone that is the same for the entire column, that affects how the values of the `DateTime` type values are displayed in text format and how the values specified as strings are parsed (‘2020-01-01 05:00:01’). The time zone is not stored in the rows of the table (or in resultset), but is stored in the column metadata. -A list of supported time zones can be found in the [IANA Time Zone Database](https://www.iana.org/time-zones). -The `tzdata` package, containing [IANA Time Zone Database](https://www.iana.org/time-zones), should be installed in the system. Use the `timedatectl list-timezones` command to list timezones known by a local system. - -You can explicitly set a time zone for `DateTime`-type columns when creating a table. If the time zone isn’t set, ClickHouse uses the value of the [timezone](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) parameter in the server settings or the operating system settings at the moment of the ClickHouse server start. - -The [clickhouse-client](../../interfaces/cli.md) applies the server time zone by default if a time zone isn’t explicitly set when initializing the data type. To use the client time zone, run `clickhouse-client` with the `--use_client_time_zone` parameter. - -ClickHouse outputs values in `YYYY-MM-DD hh:mm:ss` text format by default. You can change the output with the [formatDateTime](../../sql_reference/functions/date_time_functions.md#formatdatetime) function. - -When inserting data into ClickHouse, you can use different formats of date and time strings, depending on the value of the [date\_time\_input\_format](../../operations/settings/settings.md#settings-date_time_input_format) setting. - -## Examples {#examples} - -**1.** Creating a table with a `DateTime`-type column and inserting data into it: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime('Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog; -``` - -``` sql -INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); -``` - -``` sql -SELECT * FROM dt; -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -- When inserting datetime as an integer, it is treated as Unix Timestamp (UTC). `1546300800` represents `'2019-01-01 00:00:00'` UTC. However, as `timestamp` column has `Europe/Moscow` (UTC+3) timezone specified, when outputting as string the value will be shown as `'2019-01-01 03:00:00'` -- When inserting string value as datetime, it is treated as being in column timezone. `'2019-01-01 00:00:00'` will be treated as being in `Europe/Moscow` timezone and saved as `1546290000`. - -**2.** Filtering on `DateTime` values - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -`DateTime` column values can be filtered using a string value in `WHERE` predicate. It will be converted to `DateTime` automatically: - -``` sql -SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -└─────────────────────┴──────────┘ -``` - -**3.** Getting a time zone for a `DateTime`-type column: - -``` sql -SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────column─┬─x─────────────────────────┐ -│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ -└─────────────────────┴───────────────────────────┘ -``` - -**4.** Timezone conversion - -``` sql -SELECT -toDateTime(timestamp, 'Europe/London') as lon_time, -toDateTime(timestamp, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────lon_time──┬────────────mos_time─┐ -│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ -│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ -└─────────────────────┴─────────────────────┘ -``` - -## See Also {#see-also} - -- [Type conversion functions](../../sql_reference/functions/type_conversion_functions.md) -- [Functions for working with dates and times](../../sql_reference/functions/date_time_functions.md) -- [Functions for working with arrays](../../sql_reference/functions/array_functions.md) -- [The `date_time_input_format` setting](../../operations/settings/settings.md#settings-date_time_input_format) -- [The `timezone` server configuration parameter](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [Operators for working with dates and times](../../sql_reference/operators.md#operators-datetime) -- [The `Date` data type](date.md) - -[Original article](https://clickhouse.tech/docs/en/data_types/datetime/) diff --git a/docs/en/sql_reference/data_types/datetime64.md b/docs/en/sql_reference/data_types/datetime64.md deleted file mode 100644 index f946c7aff6b..00000000000 --- a/docs/en/sql_reference/data_types/datetime64.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -toc_priority: 49 -toc_title: DateTime64 ---- - -# Datetime64 {#data_type-datetime64} - -Allows to store an instant in time, that can be expressed as a calendar date and a time of a day, with defined sub-second precision - -Tick size (precision): 10-precision seconds - -Syntax: - -``` sql -DateTime64(precision, [timezone]) -``` - -Internally, stores data as a number of ‘ticks’ since epoch start (1970-01-01 00:00:00 UTC) as Int64. The tick resolution is determined by the precision parameter. Additionally, the `DateTime64` type can store time zone that is the same for the entire column, that affects how the values of the `DateTime64` type values are displayed in text format and how the values specified as strings are parsed (‘2020-01-01 05:00:01.000’). The time zone is not stored in the rows of the table (or in resultset), but is stored in the column metadata. See details in [DateTime](datetime.md). - -## Examples {#examples} - -**1.** Creating a table with `DateTime64`-type column and inserting data into it: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime64(3, 'Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog -``` - -``` sql -INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) -``` - -``` sql -SELECT * FROM dt -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00.000 │ 1 │ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -- When inserting datetime as an integer, it is treated as an appropriately scaled Unix Timestamp (UTC). `1546300800000` (with precision 3) represents `'2019-01-01 00:00:00'` UTC. However, as `timestamp` column has `Europe/Moscow` (UTC+3) timezone specified, when outputting as a string the value will be shown as `'2019-01-01 03:00:00'` -- When inserting string value as datetime, it is treated as being in column timezone. `'2019-01-01 00:00:00'` will be treated as being in `Europe/Moscow` timezone and stored as `1546290000000`. - -**2.** Filtering on `DateTime64` values - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -Unlike `DateTime`, `DateTime64` values are not converted from `String` automatically - -**3.** Getting a time zone for a `DateTime64`-type value: - -``` sql -SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────────column─┬─x──────────────────────────────┐ -│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ -└─────────────────────────┴────────────────────────────────┘ -``` - -**4.** Timezone conversion - -``` sql -SELECT -toDateTime64(timestamp, 3, 'Europe/London') as lon_time, -toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────────lon_time──┬────────────────mos_time─┐ -│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ -│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ -└─────────────────────────┴─────────────────────────┘ -``` - -## See Also {#see-also} - -- [Type conversion functions](../../sql_reference/functions/type_conversion_functions.md) -- [Functions for working with dates and times](../../sql_reference/functions/date_time_functions.md) -- [Functions for working with arrays](../../sql_reference/functions/array_functions.md) -- [The `date_time_input_format` setting](../../operations/settings/settings.md#settings-date_time_input_format) -- [The `timezone` server configuration parameter](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [Operators for working with dates and times](../../sql_reference/operators.md#operators-datetime) -- [`Date` data type](date.md) -- [`DateTime` data type](datetime.md) diff --git a/docs/en/sql_reference/data_types/decimal.md b/docs/en/sql_reference/data_types/decimal.md deleted file mode 100644 index c689cf60310..00000000000 --- a/docs/en/sql_reference/data_types/decimal.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -toc_priority: 42 -toc_title: Decimal ---- - -# Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} - -Signed fixed-point numbers that keep precision during add, subtract and multiply operations. For division least significant digits are discarded (not rounded). - -## Parameters {#parameters} - -- P - precision. Valid range: \[ 1 : 38 \]. Determines how many decimal digits number can have (including fraction). -- S - scale. Valid range: \[ 0 : P \]. Determines how many decimal digits fraction can have. - -Depending on P parameter value Decimal(P, S) is a synonym for: -- P from \[ 1 : 9 \] - for Decimal32(S) -- P from \[ 10 : 18 \] - for Decimal64(S) -- P from \[ 19 : 38 \] - for Decimal128(S) - -## Decimal value ranges {#decimal-value-ranges} - -- Decimal32(S) - ( -1 \* 10^(9 - S), 1 \* 10^(9 - S) ) -- Decimal64(S) - ( -1 \* 10^(18 - S), 1 \* 10^(18 - S) ) -- Decimal128(S) - ( -1 \* 10^(38 - S), 1 \* 10^(38 - S) ) - -For example, Decimal32(4) can contain numbers from -99999.9999 to 99999.9999 with 0.0001 step. - -## Internal representation {#internal-representation} - -Internally data is represented as normal signed integers with respective bit width. Real value ranges that can be stored in memory are a bit larger than specified above, which are checked only on conversion from a string. - -Because modern CPU’s do not support 128-bit integers natively, operations on Decimal128 are emulated. Because of this Decimal128 works significantly slower than Decimal32/Decimal64. - -## Operations and result type {#operations-and-result-type} - -Binary operations on Decimal result in wider result type (with any order of arguments). - -- Decimal64(S1) Decimal32(S2) -\> Decimal64(S) -- Decimal128(S1) Decimal32(S2) -\> Decimal128(S) -- Decimal128(S1) Decimal64(S2) -\> Decimal128(S) - -Rules for scale: - -- add, subtract: S = max(S1, S2). -- multuply: S = S1 + S2. -- divide: S = S1. - -For similar operations between Decimal and integers, the result is Decimal of the same size as an argument. - -Operations between Decimal and Float32/Float64 are not defined. If you need them, you can explicitly cast one of argument using toDecimal32, toDecimal64, toDecimal128 or toFloat32, toFloat64 builtins. Keep in mind that the result will lose precision and type conversion is a computationally expensive operation. - -Some functions on Decimal return result as Float64 (for example, var or stddev). Intermediate calculations might still be performed in Decimal, which might lead to different results between Float64 and Decimal inputs with the same values. - -## Overflow checks {#overflow-checks} - -During calculations on Decimal, integer overflows might happen. Excessive digits in a fraction are discarded (not rounded). Excessive digits in integer part will lead to an exception. - -``` sql -SELECT toDecimal32(2, 4) AS x, x / 3 -``` - -``` text -┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ -│ 2.0000 │ 0.6666 │ -└────────┴──────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, x * x -``` - -``` text -DB::Exception: Scale is out of bounds. -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -DB::Exception: Decimal math overflow. -``` - -Overflow checks lead to operations slowdown. If it is known that overflows are not possible, it makes sense to disable checks using `decimal_check_overflow` setting. When checks are disabled and overflow happens, the result will be incorrect: - -``` sql -SET decimal_check_overflow = 0; -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ -│ 4.20000000 │ -17.74967296 │ -└────────────┴──────────────────────────────────┘ -``` - -Overflow checks happen not only on arithmetic operations but also on value comparison: - -``` sql -SELECT toDecimal32(1, 8) < 100 -``` - -``` text -DB::Exception: Can't compare. -``` - -[Original article](https://clickhouse.tech/docs/en/data_types/decimal/) diff --git a/docs/en/sql_reference/data_types/domains/index.md b/docs/en/sql_reference/data_types/domains/index.md deleted file mode 100644 index d4496cf8d5b..00000000000 --- a/docs/en/sql_reference/data_types/domains/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Domains -toc_priority: 56 ---- - diff --git a/docs/en/sql_reference/data_types/enum.md b/docs/en/sql_reference/data_types/enum.md deleted file mode 100644 index e31bbed3426..00000000000 --- a/docs/en/sql_reference/data_types/enum.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -toc_priority: 50 -toc_title: Enum ---- - -# Enum {#enum} - -Enumerated type consisting of named values. - -Named values must be declared as `'string' = integer` pairs. ClickHouse stores only numbers, but supports operations with the values through their names. - -ClickHouse supports: - -- 8-bit `Enum`. It can contain up to 256 values enumerated in the `[-128, 127]` range. -- 16-bit `Enum`. It can contain up to 65536 values enumerated in the `[-32768, 32767]` range. - -ClickHouse automatically chooses the type of `Enum` when data is inserted. You can also use `Enum8` or `Enum16` types to be sure in the size of storage. - -## Usage Examples {#usage-examples} - -Here we create a table with an `Enum8('hello' = 1, 'world' = 2)` type column: - -``` sql -CREATE TABLE t_enum -( - x Enum('hello' = 1, 'world' = 2) -) -ENGINE = TinyLog -``` - -Column `x` can only store values that are listed in the type definition: `'hello'` or `'world'`. If you try to save any other value, ClickHouse will raise an exception. 8-bit size for this `Enum` is chosen automatically. - -``` sql -INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') -``` - -``` text -Ok. -``` - -``` sql -INSERT INTO t_enum values('a') -``` - -``` text -Exception on client: -Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) -``` - -When you query data from the table, ClickHouse outputs the string values from `Enum`. - -``` sql -SELECT * FROM t_enum -``` - -``` text -┌─x─────┐ -│ hello │ -│ world │ -│ hello │ -└───────┘ -``` - -If you need to see the numeric equivalents of the rows, you must cast the `Enum` value to integer type. - -``` sql -SELECT CAST(x, 'Int8') FROM t_enum -``` - -``` text -┌─CAST(x, 'Int8')─┐ -│ 1 │ -│ 2 │ -│ 1 │ -└─────────────────┘ -``` - -To create an Enum value in a query, you also need to use `CAST`. - -``` sql -SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) -``` - -``` text -┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ -│ Enum8('a' = 1, 'b' = 2) │ -└─────────────────────────────────────────────────────┘ -``` - -## General Rules and Usage {#general-rules-and-usage} - -Each of the values is assigned a number in the range `-128 ... 127` for `Enum8` or in the range `-32768 ... 32767` for `Enum16`. All the strings and numbers must be different. An empty string is allowed. If this type is specified (in a table definition), numbers can be in an arbitrary order. However, the order does not matter. - -Neither the string nor the numeric value in an `Enum` can be [NULL](../../sql_reference/syntax.md). - -An `Enum` can be contained in [Nullable](nullable.md) type. So if you create a table using the query - -``` sql -CREATE TABLE t_enum_nullable -( - x Nullable( Enum8('hello' = 1, 'world' = 2) ) -) -ENGINE = TinyLog -``` - -it can store not only `'hello'` and `'world'`, but `NULL`, as well. - -``` sql -INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) -``` - -In RAM, an `Enum` column is stored in the same way as `Int8` or `Int16` of the corresponding numerical values. - -When reading in text form, ClickHouse parses the value as a string and searches for the corresponding string from the set of Enum values. If it is not found, an exception is thrown. When reading in text format, the string is read and the corresponding numeric value is looked up. An exception will be thrown if it is not found. -When writing in text form, it writes the value as the corresponding string. If column data contains garbage (numbers that are not from the valid set), an exception is thrown. When reading and writing in binary form, it works the same way as for Int8 and Int16 data types. -The implicit default value is the value with the lowest number. - -During `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` and so on, Enums behave the same way as the corresponding numbers. For example, ORDER BY sorts them numerically. Equality and comparison operators work the same way on Enums as they do on the underlying numeric values. - -Enum values cannot be compared with numbers. Enums can be compared to a constant string. If the string compared to is not a valid value for the Enum, an exception will be thrown. The IN operator is supported with the Enum on the left-hand side and a set of strings on the right-hand side. The strings are the values of the corresponding Enum. - -Most numeric and string operations are not defined for Enum values, e.g. adding a number to an Enum or concatenating a string to an Enum. -However, the Enum has a natural `toString` function that returns its string value. - -Enum values are also convertible to numeric types using the `toT` function, where T is a numeric type. When T corresponds to the enum’s underlying numeric type, this conversion is zero-cost. -The Enum type can be changed without cost using ALTER, if only the set of values is changed. It is possible to both add and remove members of the Enum using ALTER (removing is safe only if the removed value has never been used in the table). As a safeguard, changing the numeric value of a previously defined Enum member will throw an exception. - -Using ALTER, it is possible to change an Enum8 to an Enum16 or vice versa, just like changing an Int8 to Int16. - -[Original article](https://clickhouse.tech/docs/en/data_types/enum/) diff --git a/docs/en/sql_reference/data_types/fixedstring.md b/docs/en/sql_reference/data_types/fixedstring.md deleted file mode 100644 index 4c8ea65b278..00000000000 --- a/docs/en/sql_reference/data_types/fixedstring.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -toc_priority: 45 -toc_title: FixedString(N) ---- - -# Fixedstring {#fixedstring} - -A fixed-length string of `N` bytes (neither characters nor code points). - -To declare a column of `FixedString` type, use the following syntax: - -``` sql - FixedString(N) -``` - -Where `N` is a natural number. - -The `FixedString` type is efficient when data has the length of precisely `N` bytes. In all other cases, it is likely to reduce efficiency. - -Examples of the values that can be efficiently stored in `FixedString`-typed columns: - -- The binary representation of IP addresses (`FixedString(16)` for IPv6). -- Language codes (ru\_RU, en\_US … ). -- Currency codes (USD, RUB … ). -- Binary representation of hashes (`FixedString(16)` for MD5, `FixedString(32)` for SHA256). - -To store UUID values, use the [UUID](uuid.md) data type. - -When inserting the data, ClickHouse: - -- Complements a string with null bytes if the string contains fewer than `N` bytes. -- Throws the `Too large value for FixedString(N)` exception if the string contains more than `N` bytes. - -When selecting the data, ClickHouse does not remove the null bytes at the end of the string. If you use the `WHERE` clause, you should add null bytes manually to match the `FixedString` value. The following example illustrates how to use the `WHERE` clause with `FixedString`. - -Let’s consider the following table with the single `FixedString(2)` column: - -``` text -┌─name──┐ -│ b │ -└───────┘ -``` - -The query `SELECT * FROM FixedStringTable WHERE a = 'b'` does not return any data as a result. We should complement the filter pattern with null bytes. - -``` sql -SELECT * FROM FixedStringTable -WHERE a = 'b\0' -``` - -``` text -┌─a─┐ -│ b │ -└───┘ -``` - -This behaviour differs from MySQL for the `CHAR` type (where strings are padded with spaces, and the spaces are removed for output). - -Note that the length of the `FixedString(N)` value is constant. The [length](../../sql_reference/functions/array_functions.md#array_functions-length) function returns `N` even if the `FixedString(N)` value is filled only with null bytes, but the [empty](../../sql_reference/functions/string_functions.md#empty) function returns `1` in this case. - -[Original article](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/en/sql_reference/data_types/float.md b/docs/en/sql_reference/data_types/float.md deleted file mode 100644 index 646161d34fd..00000000000 --- a/docs/en/sql_reference/data_types/float.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -toc_priority: 41 -toc_title: Float32, Float64 ---- - -# Float32, Float64 {#float32-float64} - -[Floating point numbers](https://en.wikipedia.org/wiki/IEEE_754). - -Types are equivalent to types of C: - -- `Float32` - `float` -- `Float64` - `double` - -We recommend that you store data in integer form whenever possible. For example, convert fixed precision numbers to integer values, such as monetary amounts or page load times in milliseconds. - -## Using Floating-point Numbers {#using-floating-point-numbers} - -- Computations with floating-point numbers might produce a rounding error. - - - -``` sql -SELECT 1 - 0.9 -``` - -``` text -┌───────minus(1, 0.9)─┐ -│ 0.09999999999999998 │ -└─────────────────────┘ -``` - -- The result of the calculation depends on the calculation method (the processor type and architecture of the computer system). -- Floating-point calculations might result in numbers such as infinity (`Inf`) and “not-a-number” (`NaN`). This should be taken into account when processing the results of calculations. -- When parsing floating-point numbers from text, the result might not be the nearest machine-representable number. - -## NaN and Inf {#data_type-float-nan-inf} - -In contrast to standard SQL, ClickHouse supports the following categories of floating-point numbers: - -- `Inf` – Infinity. - - - -``` sql -SELECT 0.5 / 0 -``` - -``` text -┌─divide(0.5, 0)─┐ -│ inf │ -└────────────────┘ -``` - -- `-Inf` – Negative infinity. - - - -``` sql -SELECT -0.5 / 0 -``` - -``` text -┌─divide(-0.5, 0)─┐ -│ -inf │ -└─────────────────┘ -``` - -- `NaN` – Not a number. - - - -``` sql -SELECT 0 / 0 -``` - -``` text -┌─divide(0, 0)─┐ -│ nan │ -└──────────────┘ -``` - - See the rules for `NaN` sorting in the section [ORDER BY clause](../sql_reference/statements/select.md). - -[Original article](https://clickhouse.tech/docs/en/data_types/float/) diff --git a/docs/en/sql_reference/data_types/index.md b/docs/en/sql_reference/data_types/index.md deleted file mode 100644 index da507b81acd..00000000000 --- a/docs/en/sql_reference/data_types/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -toc_folder_title: Data Types -toc_priority: 37 -toc_title: Introduction ---- - -# Data Types {#data_types} - -ClickHouse can store various kinds of data in table cells. - -This section describes the supported data types and special considerations for using and/or implementing them if any. - -[Original article](https://clickhouse.tech/docs/en/data_types/) diff --git a/docs/en/sql_reference/data_types/nested_data_structures/nested.md b/docs/en/sql_reference/data_types/nested_data_structures/nested.md deleted file mode 100644 index 4c95f1fd2fc..00000000000 --- a/docs/en/sql_reference/data_types/nested_data_structures/nested.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -toc_priority: 57 -toc_title: Nested(Name1 Type1, Name2 Type2, ...) ---- - -# Nested(name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} - -A nested data structure is like a table inside a cell. The parameters of a nested data structure – the column names and types – are specified the same way as in a [CREATE TABLE](../../../sql_reference/statements/create.md) query. Each table row can correspond to any number of rows in a nested data structure. - -Example: - -``` sql -CREATE TABLE test.visits -( - CounterID UInt32, - StartDate Date, - Sign Int8, - IsNew UInt8, - VisitID UInt64, - UserID UInt64, - ... - Goals Nested - ( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32 - ), - ... -) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) -``` - -This example declares the `Goals` nested data structure, which contains data about conversions (goals reached). Each row in the ‘visits’ table can correspond to zero or any number of conversions. - -Only a single nesting level is supported. Columns of nested structures containing arrays are equivalent to multidimensional arrays, so they have limited support (there is no support for storing these columns in tables with the MergeTree engine). - -In most cases, when working with a nested data structure, its columns are specified with column names separated by a dot. These columns make up an array of matching types. All the column arrays of a single nested data structure have the same length. - -Example: - -``` sql -SELECT - Goals.ID, - Goals.EventTime -FROM test.visits -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ -│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ -│ [1073752] │ ['2014-03-17 00:28:25'] │ -│ [1073752] │ ['2014-03-17 10:46:20'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ -│ [] │ [] │ -│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ -│ [] │ [] │ -│ [] │ [] │ -│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ -└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -It is easiest to think of a nested data structure as a set of multiple column arrays of the same length. - -The only place where a SELECT query can specify the name of an entire nested data structure instead of individual columns is the ARRAY JOIN clause. For more information, see “ARRAY JOIN clause”. Example: - -``` sql -SELECT - Goal.ID, - Goal.EventTime -FROM test.visits -ARRAY JOIN Goals AS Goal -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goal.ID─┬──────Goal.EventTime─┐ -│ 1073752 │ 2014-03-17 16:38:10 │ -│ 591325 │ 2014-03-17 16:38:48 │ -│ 591325 │ 2014-03-17 16:42:27 │ -│ 1073752 │ 2014-03-17 00:28:25 │ -│ 1073752 │ 2014-03-17 10:46:20 │ -│ 1073752 │ 2014-03-17 13:59:20 │ -│ 591325 │ 2014-03-17 22:17:55 │ -│ 591325 │ 2014-03-17 22:18:07 │ -│ 591325 │ 2014-03-17 22:18:51 │ -│ 1073752 │ 2014-03-17 11:37:06 │ -└─────────┴─────────────────────┘ -``` - -You can’t perform SELECT for an entire nested data structure. You can only explicitly list individual columns that are part of it. - -For an INSERT query, you should pass all the component column arrays of a nested data structure separately (as if they were individual column arrays). During insertion, the system checks that they have the same length. - -For a DESCRIBE query, the columns in a nested data structure are listed separately in the same way. - -The ALTER query for elements in a nested data structure has limitations. - -[Original article](https://clickhouse.tech/docs/en/data_types/nested_data_structures/nested/) diff --git a/docs/en/sql_reference/data_types/nullable.md b/docs/en/sql_reference/data_types/nullable.md deleted file mode 100644 index 7fd68592c4a..00000000000 --- a/docs/en/sql_reference/data_types/nullable.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -toc_priority: 54 -toc_title: Nullable ---- - -# Nullable(typename) {#data_type-nullable} - -Allows to store special marker ([NULL](../../sql_reference/syntax.md)) that denotes “missing value” alongside normal values allowed by `TypeName`. For example, a `Nullable(Int8)` type column can store `Int8` type values, and the rows that don’t have a value will store `NULL`. - -For a `TypeName`, you can’t use composite data types [Array](array.md) and [Tuple](tuple.md). Composite data types can contain `Nullable` type values, such as `Array(Nullable(Int8))`. - -A `Nullable` type field can’t be included in table indexes. - -`NULL` is the default value for any `Nullable` type, unless specified otherwise in the ClickHouse server configuration. - -## Storage Features {#storage-features} - -To store `Nullable` type values in a table column, ClickHouse uses a separate file with `NULL` masks in addition to normal file with values. Entries in masks file allow ClickHouse to distinguish between `NULL` and a default value of corresponding data type for each table row. Because of an additional file, `Nullable` column consumes additional storage space compared to a similar normal one. - -!!! info "Note" - Using `Nullable` almost always negatively affects performance, keep this in mind when designing your databases. - -## Usage Example {#usage-example} - -``` sql -CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog -``` - -``` sql -INSERT INTO t_null VALUES (1, NULL), (2, 3) -``` - -``` sql -SELECT x + y FROM t_null -``` - -``` text -┌─plus(x, y)─┐ -│ ᴺᵁᴸᴸ │ -│ 5 │ -└────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/en/sql_reference/data_types/simpleaggregatefunction.md b/docs/en/sql_reference/data_types/simpleaggregatefunction.md deleted file mode 100644 index 81036aec4c8..00000000000 --- a/docs/en/sql_reference/data_types/simpleaggregatefunction.md +++ /dev/null @@ -1,34 +0,0 @@ -# SimpleAggregateFunction(name, types\_of\_arguments…) {#data-type-simpleaggregatefunction} - -`SimpleAggregateFunction` data type stores current value of the aggregate function, and does not store its full state as [`AggregateFunction`](aggregatefunction.md) does. This optimization can be applied to functions for which the following property holds: the result of applying a function `f` to a row set `S1 UNION ALL S2` can be obtained by applying `f` to parts of the row set separately, and then again applying `f` to the results: `f(S1 UNION ALL S2) = f(f(S1) UNION ALL f(S2))`. This property guarantees that partial aggregation results are enough to compute the combined one, so we don't have to store and process any extra data. - -The following aggregate functions are supported: - -- [`any`](../../sql_reference/aggregate_functions/reference.md#agg_function-any) -- [`anyLast`](../../sql_reference/aggregate_functions/reference.md#anylastx) -- [`min`](../../sql_reference/aggregate_functions/reference.md#agg_function-min) -- [`max`](../../sql_reference/aggregate_functions/reference.md#agg_function-max) -- [`sum`](../../sql_reference/aggregate_functions/reference.md#agg_function-sum) -- [`groupBitAnd`](../../sql_reference/aggregate_functions/reference.md#groupbitand) -- [`groupBitOr`](../../sql_reference/aggregate_functions/reference.md#groupbitor) -- [`groupBitXor`](../../sql_reference/aggregate_functions/reference.md#groupbitxor) - - -Values of the `SimpleAggregateFunction(func, Type)` look and stored the same way as `Type`, so you do not need to apply functions with `-Merge`/`-State` suffixes. `SimpleAggregateFunction` has better performance than `AggregateFunction` with same aggregation function. - -**Parameters** - -- Name of the aggregate function. -- Types of the aggregate function arguments. - -**Example** - -``` sql -CREATE TABLE t -( - column1 SimpleAggregateFunction(sum, UInt64), - column2 SimpleAggregateFunction(any, String) -) ENGINE = ... -``` - -[Original article](https://clickhouse.tech/docs/en/data_types/simpleaggregatefunction/) diff --git a/docs/en/sql_reference/data_types/special_data_types/interval.md b/docs/en/sql_reference/data_types/special_data_types/interval.md deleted file mode 100644 index 8b71e1301a6..00000000000 --- a/docs/en/sql_reference/data_types/special_data_types/interval.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -toc_priority: 61 -toc_title: Interval ---- - -# Interval {#data-type-interval} - -The family of data types representing time and date intervals. The resulting types of the [INTERVAL](../../../sql_reference/operators.md#operator-interval) operator. - -!!! warning "Warning" - `Interval` data type values can’t be stored in tables. - -Structure: - -- Time interval as an unsigned integer value. -- Type of an interval. - -Supported interval types: - -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -For each interval type, there is a separate data type. For example, the `DAY` interval corresponds to the `IntervalDay` data type: - -``` sql -SELECT toTypeName(INTERVAL 4 DAY) -``` - -``` text -┌─toTypeName(toIntervalDay(4))─┐ -│ IntervalDay │ -└──────────────────────────────┘ -``` - -## Usage Remarks {#data-type-interval-usage-remarks} - -You can use `Interval`-type values in arithmetical operations with [Date](../../../sql_reference/data_types/date.md) and [DateTime](../../../sql_reference/data_types/datetime.md)-type values. For example, you can add 4 days to the current time: - -``` sql -SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY -``` - -``` text -┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ -│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ -└─────────────────────┴───────────────────────────────┘ -``` - -Intervals with different types can’t be combined. You can’t use intervals like `4 DAY 1 HOUR`. Specify intervals in units that are smaller or equal to the smallest unit of the interval, for example, the interval `1 day and an hour` interval can be expressed as `25 HOUR` or `90000 SECOND`. - -You can’t perform arithmetical operations with `Interval`-type values, but you can add intervals of different types consequently to values in `Date` or `DateTime` data types. For example: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -The following query causes an exception: - -``` sql -select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) -``` - -``` text -Received exception from server (version 19.14.1): -Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. -``` - -## See Also {#see-also} - -- [INTERVAL](../../../sql_reference/operators.md#operator-interval) operator -- [toInterval](../../../sql_reference/functions/type_conversion_functions.md#function-tointerval) type convertion functions diff --git a/docs/en/sql_reference/data_types/special_data_types/nothing.md b/docs/en/sql_reference/data_types/special_data_types/nothing.md deleted file mode 100644 index 054f7e2c5a8..00000000000 --- a/docs/en/sql_reference/data_types/special_data_types/nothing.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -toc_priority: 60 -toc_title: Nothing ---- - -# Nothing {#nothing} - -The only purpose of this data type is to represent cases where a value is not expected. So you can’t create a `Nothing` type value. - -For example, literal [NULL](../../../sql_reference/syntax.md#null-literal) has type of `Nullable(Nothing)`. See more about [Nullable](../../../sql_reference/data_types/nullable.md). - -The `Nothing` type can also used to denote empty arrays: - -``` sql -SELECT toTypeName(array()) -``` - -``` text -┌─toTypeName(array())─┐ -│ Array(Nothing) │ -└─────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/data_types/special_data_types/nothing/) diff --git a/docs/en/sql_reference/data_types/special_data_types/set.md b/docs/en/sql_reference/data_types/special_data_types/set.md deleted file mode 100644 index 05ca97910b6..00000000000 --- a/docs/en/sql_reference/data_types/special_data_types/set.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -toc_priority: 59 -toc_title: Set ---- - -# Set {#set} - -Used for the right half of an [IN](../../statements/select.md#select-in-operators) expression. - -[Original article](https://clickhouse.tech/docs/en/data_types/special_data_types/set/) diff --git a/docs/en/sql_reference/data_types/tuple.md b/docs/en/sql_reference/data_types/tuple.md deleted file mode 100644 index 4e73f85df63..00000000000 --- a/docs/en/sql_reference/data_types/tuple.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -toc_priority: 53 -toc_title: Tuple(T1, T2, ...) ---- - -# Tuple(t1, T2, …) {#tuplet1-t2} - -A tuple of elements, each having an individual [type](index.md#data_types). - -Tuples are used for temporary column grouping. Columns can be grouped when an IN expression is used in a query, and for specifying certain formal parameters of lambda functions. For more information, see the sections [IN operators](../../sql_reference/statements/select.md) and [Higher order functions](../../sql_reference/functions/higher_order_functions.md). - -Tuples can be the result of a query. In this case, for text formats other than JSON, values are comma-separated in brackets. In JSON formats, tuples are output as arrays (in square brackets). - -## Creating a Tuple {#creating-a-tuple} - -You can use a function to create a tuple: - -``` sql -tuple(T1, T2, ...) -``` - -Example of creating a tuple: - -``` sql -SELECT tuple(1,'a') AS x, toTypeName(x) -``` - -``` text -┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ -│ (1,'a') │ Tuple(UInt8, String) │ -└─────────┴───────────────────────────┘ -``` - -## Working With Data Types {#working-with-data-types} - -When creating a tuple on the fly, ClickHouse automatically detects the type of each argument as the minimum of the types which can store the argument value. If the argument is [NULL](../../sql_reference/syntax.md#null-literal), the type of the tuple element is [Nullable](nullable.md). - -Example of automatic data type detection: - -``` sql -SELECT tuple(1, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ -│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ -└──────────┴─────────────────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/data_types/tuple/) diff --git a/docs/en/sql_reference/data_types/uuid.md b/docs/en/sql_reference/data_types/uuid.md deleted file mode 100644 index 140f86ac464..00000000000 --- a/docs/en/sql_reference/data_types/uuid.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -toc_priority: 46 -toc_title: UUID ---- - -# UUID {#uuid-data-type} - -A universally unique identifier (UUID) is a 16-byte number used to identify records. For detailed information about the UUID, see [Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier). - -The example of UUID type value is represented below: - -``` text -61f0c404-5cb3-11e7-907b-a6006ad3dba0 -``` - -If you do not specify the UUID column value when inserting a new record, the UUID value is filled with zero: - -``` text -00000000-0000-0000-0000-000000000000 -``` - -## How To Generate {#how-to-generate} - -To generate the UUID value, ClickHouse provides the [generateUUIDv4](../../sql_reference/functions/uuid_functions.md) function. - -## Usage Example {#usage-example} - -**Example 1** - -This example demonstrates creating a table with the UUID type column and inserting a value into the table. - -``` sql -CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog -``` - -``` sql -INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -└──────────────────────────────────────┴───────────┘ -``` - -**Example 2** - -In this example, the UUID column value is not specified when inserting a new record. - -``` sql -INSERT INTO t_uuid (y) VALUES ('Example 2') -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ -└──────────────────────────────────────┴───────────┘ -``` - -## Restrictions {#restrictions} - -The UUID data type only supports functions which [String](string.md) data type also supports (for example, [min](../../sql_reference/aggregate_functions/reference.md#agg_function-min), [max](../../sql_reference/aggregate_functions/reference.md#agg_function-max), and [count](../../sql_reference/aggregate_functions/reference.md#agg_function-count)). - -The UUID data type is not supported by arithmetic operations (for example, [abs](../../sql_reference/functions/arithmetic_functions.md#arithm_func-abs)) or aggregate functions, such as [sum](../../sql_reference/aggregate_functions/reference.md#agg_function-sum) and [avg](../../sql_reference/aggregate_functions/reference.md#agg_function-avg). - -[Original article](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts.md deleted file mode 100644 index 446946e927e..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -toc_priority: 39 -toc_title: General Description ---- - -# External Dictionaries {#dicts-external-dicts} - -You can add your own dictionaries from various data sources. The data source for a dictionary can be a local text or executable file, an HTTP(s) resource, or another DBMS. For more information, see “[Sources for external dictionaries](external_dicts_dict_sources.md)”. - -ClickHouse: - -- Fully or partially stores dictionaries in RAM. -- Periodically updates dictionaries and dynamically loads missing values. In other words, dictionaries can be loaded dynamically. -- Allows to create external dictionaries with xml files or [DDL queries](../../statements/create.md#create-dictionary-query). - -The configuration of external dictionaries can be located in one or more xml-files. The path to the configuration is specified in the [dictionaries\_config](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_config) parameter. - -Dictionaries can be loaded at server startup or at first use, depending on the [dictionaries\_lazy\_load](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) setting. - -The dictionary configuration file has the following format: - -``` xml - - An optional element with any content. Ignored by the ClickHouse server. - - - /etc/metrika.xml - - - - - - - - -``` - -You can [configure](external_dicts_dict.md) any number of dictionaries in the same file. - -[DDL queries for dictionaries](../../statements/create.md#create-dictionary-query) doesn’t require any additional records in server configuration. They allow to work with dictionaries as first-class entities, like tables or views. - -!!! attention "Attention" - You can convert values for a small dictionary by describing it in a `SELECT` query (see the [transform](../../../sql_reference/functions/other_functions.md) function). This functionality is not related to external dictionaries. - -## See Also {#ext-dicts-see-also} - -- [Configuring an External Dictionary](external_dicts_dict.md) -- [Storing Dictionaries in Memory](external_dicts_dict_layout.md) -- [Dictionary Updates](external_dicts_dict_lifetime.md) -- [Sources of External Dictionaries](external_dicts_dict_sources.md) -- [Dictionary Key and Fields](external_dicts_dict_structure.md) -- [Functions for Working with External Dictionaries](../../../sql_reference/functions/ext_dict_functions.md) - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md deleted file mode 100644 index 16e9a4ada39..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -toc_priority: 40 -toc_title: Configuring an External Dictionary ---- - -# Configuring an External Dictionary {#dicts-external-dicts-dict} - -If dictionary is configured using xml file, than dictionary configuration has the following structure: - -``` xml - - dict_name - - - - - - - - - - - - - - - - - -``` - -Corresponding [DDL-query](../../statements/create.md#create-dictionary-query) has the following structure: - -``` sql -CREATE DICTIONARY dict_name -( - ... -- attributes -) -PRIMARY KEY ... -- complex or single key configuration -SOURCE(...) -- Source configuration -LAYOUT(...) -- Memory layout configuration -LIFETIME(...) -- Lifetime of dictionary in memory -``` - -- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. -- [source](external_dicts_dict_sources.md) — Source of the dictionary. -- [layout](external_dicts_dict_layout.md) — Dictionary layout in memory. -- [structure](external_dicts_dict_structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. -- [lifetime](external_dicts_dict_lifetime.md) — Frequency of dictionary updates. - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md deleted file mode 100644 index b56245539cb..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -toc_priority: 45 -toc_title: Hierarchical dictionaries ---- - -# Hierarchical Dictionaries {#hierarchical-dictionaries} - -ClickHouse supports hierarchical dictionaries with a [numeric key](external_dicts_dict_structure.md#ext_dict-numeric-key). - -Look at the following hierarchical structure: - -``` text -0 (Common parent) -│ -├── 1 (Russia) -│ │ -│ └── 2 (Moscow) -│ │ -│ └── 3 (Center) -│ -└── 4 (Great Britain) - │ - └── 5 (London) -``` - -This hierarchy can be expressed as the following dictionary table. - -| region\_id | parent\_region | region\_name | -|--------|----------|---------| -| 1 | 0 | Russia | -| 2 | 1 | Moscow | -| 3 | 2 | Center | -| 4 | 0 | Great Britain | -| 5 | 4 | London | - -This table contains a column `parent_region` that contains the key of the nearest parent for the element. - -ClickHouse supports the [hierarchical](external_dicts_dict_structure.md#hierarchical-dict-attr) property for [external dictionary](index.md) attributes. This property allows you to configure the hierarchical dictionary similar to described above. - -The [dictGetHierarchy](../../../sql_reference/functions/ext_dict_functions.md#dictgethierarchy) function allows you to get the parent chain of an element. - -For our example, the structure of dictionary can be the following: - -``` xml - - - - region_id - - - - parent_region - UInt64 - 0 - true - - - - region_name - String - - - - - -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md deleted file mode 100644 index 663cde42f9b..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md +++ /dev/null @@ -1,371 +0,0 @@ ---- -toc_priority: 41 -toc_title: Storing Dictionaries in Memory ---- - -# Storing Dictionaries In Memory {#dicts-external-dicts-dict-layout} - -There are a variety of ways to store dictionaries in memory. - -We recommend [flat](#flat), [hashed](#dicts-external_dicts_dict_layout-hashed) and [complex\_key\_hashed](#complex-key-hashed). which provide optimal processing speed. - -Caching is not recommended because of potentially poor performance and difficulties in selecting optimal parameters. Read more in the section “[cache](#cache)”. - -There are several ways to improve dictionary performance: - -- Call the function for working with the dictionary after `GROUP BY`. -- Mark attributes to extract as injective. An attribute is called injective if different attribute values correspond to different keys. So when `GROUP BY` uses a function that fetches an attribute value by the key, this function is automatically taken out of `GROUP BY`. - -ClickHouse generates an exception for errors with dictionaries. Examples of errors: - -- The dictionary being accessed could not be loaded. -- Error querying a `cached` dictionary. - -You can view the list of external dictionaries and their statuses in the `system.dictionaries` table. - -The configuration looks like this: - -``` xml - - - ... - - - - - - ... - - -``` - -Corresponding [DDL-query](../../statements/create.md#create-dictionary-query): - -``` sql -CREATE DICTIONARY (...) -... -LAYOUT(LAYOUT_TYPE(param value)) -- layout settings -... -``` - -## Ways To Store Dictionaries In Memory {#ways-to-store-dictionaries-in-memory} - -- [flat](#flat) -- [hashed](#dicts-external_dicts_dict_layout-hashed) -- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) -- [cache](#cache) -- [range\_hashed](#range-hashed) -- [complex\_key\_hashed](#complex-key-hashed) -- [complex\_key\_cache](#complex-key-cache) -- [ip\_trie](#ip-trie) - -### flat {#flat} - -The dictionary is completely stored in memory in the form of flat arrays. How much memory does the dictionary use? The amount is proportional to the size of the largest key (in space used). - -The dictionary key has the `UInt64` type and the value is limited to 500,000. If a larger key is discovered when creating the dictionary, ClickHouse throws an exception and does not create the dictionary. - -All types of sources are supported. When updating, data (from a file or from a table) is read in its entirety. - -This method provides the best performance among all available methods of storing the dictionary. - -Configuration example: - -``` xml - - - -``` - -or - -``` sql -LAYOUT(FLAT()) -``` - -### hashed {#dicts-external_dicts_dict_layout-hashed} - -The dictionary is completely stored in memory in the form of a hash table. The dictionary can contain any number of elements with any identifiers In practice, the number of keys can reach tens of millions of items. - -All types of sources are supported. When updating, data (from a file or from a table) is read in its entirety. - -Configuration example: - -``` xml - - - -``` - -or - -``` sql -LAYOUT(HASHED()) -``` - -### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} - -Similar to `hashed`, but uses less memory in favor more CPU usage. - -Configuration example: - -``` xml - - - -``` - -``` sql -LAYOUT(SPARSE_HASHED()) -``` - -### complex\_key\_hashed {#complex-key-hashed} - -This type of storage is for use with composite [keys](external_dicts_dict_structure.md). Similar to `hashed`. - -Configuration example: - -``` xml - - - -``` - -``` sql -LAYOUT(COMPLEX_KEY_HASHED()) -``` - -### range\_hashed {#range-hashed} - -The dictionary is stored in memory in the form of a hash table with an ordered array of ranges and their corresponding values. - -This storage method works the same way as hashed and allows using date/time (arbitrary numeric type) ranges in addition to the key. - -Example: The table contains discounts for each advertiser in the format: - -``` text -+---------|-------------|-------------|------+ -| advertiser id | discount start date | discount end date | amount | -+===============+=====================+===================+========+ -| 123 | 2015-01-01 | 2015-01-15 | 0.15 | -+---------|-------------|-------------|------+ -| 123 | 2015-01-16 | 2015-01-31 | 0.25 | -+---------|-------------|-------------|------+ -| 456 | 2015-01-01 | 2015-01-15 | 0.05 | -+---------|-------------|-------------|------+ -``` - -To use a sample for date ranges, define the `range_min` and `range_max` elements in the [structure](external_dicts_dict_structure.md). These elements must contain elements `name` and`type` (if `type` is not specified, the default type will be used - Date). `type` can be any numeric type (Date / DateTime / UInt64 / Int32 / others). - -Example: - -``` xml - - - Id - - - first - Date - - - last - Date - - ... -``` - -or - -``` sql -CREATE DICTIONARY somedict ( - id UInt64, - first Date, - last Date -) -PRIMARY KEY id -LAYOUT(RANGE_HASHED()) -RANGE(MIN first MAX last) -``` - -To work with these dictionaries, you need to pass an additional argument to the `dictGetT` function, for which a range is selected: - -``` sql -dictGetT('dict_name', 'attr_name', id, date) -``` - -This function returns the value for the specified `id`s and the date range that includes the passed date. - -Details of the algorithm: - -- If the `id` is not found or a range is not found for the `id`, it returns the default value for the dictionary. -- If there are overlapping ranges, you can use any. -- If the range delimiter is `NULL` or an invalid date (such as 1900-01-01 or 2039-01-01), the range is left open. The range can be open on both sides. - -Configuration example: - -``` xml - - - - ... - - - - - - - - Abcdef - - - StartTimeStamp - UInt64 - - - EndTimeStamp - UInt64 - - - XXXType - String - - - - - - -``` - -or - -``` sql -CREATE DICTIONARY somedict( - Abcdef UInt64, - StartTimeStamp UInt64, - EndTimeStamp UInt64, - XXXType String DEFAULT '' -) -PRIMARY KEY Abcdef -RANGE(MIN StartTimeStamp MAX EndTimeStamp) -``` - -### cache {#cache} - -The dictionary is stored in a cache that has a fixed number of cells. These cells contain frequently used elements. - -When searching for a dictionary, the cache is searched first. For each block of data, all keys that are not found in the cache or are outdated are requested from the source using `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. The received data is then written to the cache. - -For cache dictionaries, the expiration [lifetime](external_dicts_dict_lifetime.md) of data in the cache can be set. If more time than `lifetime` has passed since loading the data in a cell, the cell’s value is not used, and it is re-requested the next time it needs to be used. -This is the least effective of all the ways to store dictionaries. The speed of the cache depends strongly on correct settings and the usage scenario. A cache type dictionary performs well only when the hit rates are high enough (recommended 99% and higher). You can view the average hit rate in the `system.dictionaries` table. - -To improve cache performance, use a subquery with `LIMIT`, and call the function with the dictionary externally. - -Supported [sources](external_dicts_dict_sources.md): MySQL, ClickHouse, executable, HTTP. - -Example of settings: - -``` xml - - - - 1000000000 - - -``` - -or - -``` sql -LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) -``` - -Set a large enough cache size. You need to experiment to select the number of cells: - -1. Set some value. -2. Run queries until the cache is completely full. -3. Assess memory consumption using the `system.dictionaries` table. -4. Increase or decrease the number of cells until the required memory consumption is reached. - -!!! warning "Warning" - Do not use ClickHouse as a source, because it is slow to process queries with random reads. - -### complex\_key\_cache {#complex-key-cache} - -This type of storage is for use with composite [keys](external_dicts_dict_structure.md). Similar to `cache`. - -### ip\_trie {#ip-trie} - -This type of storage is for mapping network prefixes (IP addresses) to metadata such as ASN. - -Example: The table contains network prefixes and their corresponding AS number and country code: - -``` text - +-----------|-----|------+ - | prefix | asn | cca2 | - +=================+=======+========+ - | 202.79.32.0/20 | 17501 | NP | - +-----------|-----|------+ - | 2620:0:870::/48 | 3856 | US | - +-----------|-----|------+ - | 2a02:6b8:1::/48 | 13238 | RU | - +-----------|-----|------+ - | 2001:db8::/32 | 65536 | ZZ | - +-----------|-----|------+ -``` - -When using this type of layout, the structure must have a composite key. - -Example: - -``` xml - - - - prefix - String - - - - asn - UInt32 - - - - cca2 - String - ?? - - ... -``` - -or - -``` sql -CREATE DICTIONARY somedict ( - prefix String, - asn UInt32, - cca2 String DEFAULT '??' -) -PRIMARY KEY prefix -``` - -The key must have only one String type attribute that contains an allowed IP prefix. Other types are not supported yet. - -For queries, you must use the same functions (`dictGetT` with a tuple) as for dictionaries with composite keys: - -``` sql -dictGetT('dict_name', 'attr_name', tuple(ip)) -``` - -The function takes either `UInt32` for IPv4, or `FixedString(16)` for IPv6: - -``` sql -dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) -``` - -Other types are not supported yet. The function returns the attribute for the prefix that corresponds to this IP address. If there are overlapping prefixes, the most specific one is returned. - -Data is stored in a `trie`. It must completely fit into RAM. - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md deleted file mode 100644 index 97d5b6e4474..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -toc_priority: 42 -toc_title: Dictionary Updates ---- - -# Dictionary Updates {#dictionary-updates} - -ClickHouse periodically updates the dictionaries. The update interval for fully downloaded dictionaries and the invalidation interval for cached dictionaries are defined in the `` tag in seconds. - -Dictionary updates (other than loading for first use) do not block queries. During updates, the old version of a dictionary is used. If an error occurs during an update, the error is written to the server log, and queries continue using the old version of dictionaries. - -Example of settings: - -``` xml - - ... - 300 - ... - -``` - -``` sql -CREATE DICTIONARY (...) -... -LIFETIME(300) -... -``` - -Setting `0` (`LIFETIME(0)`) prevents dictionaries from updating. - -You can set a time interval for upgrades, and ClickHouse will choose a uniformly random time within this range. This is necessary in order to distribute the load on the dictionary source when upgrading on a large number of servers. - -Example of settings: - -``` xml - - ... - - 300 - 360 - - ... - -``` - -or - -``` sql -LIFETIME(MIN 300 MAX 360) -``` - -If `0` and `0`, ClickHouse does not reload the dictionary by timeout. -In this case, ClickHouse can reload the dictionary earlier if the dictionary configuration file was changed or the `SYSTEM RELOAD DICTIONARY` command was executed. - -When upgrading the dictionaries, the ClickHouse server applies different logic depending on the type of [source](external_dicts_dict_sources.md): - -When upgrading the dictionaries, the ClickHouse server applies different logic depending on the type of [source](external_dicts_dict_sources.md): - -- For a text file, it checks the time of modification. If the time differs from the previously recorded time, the dictionary is updated. -- For MyISAM tables, the time of modification is checked using a `SHOW TABLE STATUS` query. -- Dictionaries from other sources are updated every time by default. - -For MySQL (InnoDB), ODBC and ClickHouse sources, you can set up a query that will update the dictionaries only if they really changed, rather than each time. To do this, follow these steps: - -- The dictionary table must have a field that always changes when the source data is updated. -- The settings of the source must specify a query that retrieves the changing field. The ClickHouse server interprets the query result as a row, and if this row has changed relative to its previous state, the dictionary is updated. Specify the query in the `` field in the settings for the [source](external_dicts_dict_sources.md). - -Example of settings: - -``` xml - - ... - - ... - SELECT update_time FROM dictionary_source where id = 1 - - ... - -``` - -or - -``` sql -... -SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) -... -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md deleted file mode 100644 index a5c40226f85..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md +++ /dev/null @@ -1,627 +0,0 @@ ---- -toc_priority: 43 -toc_title: Sources of External Dictionaries ---- - -# Sources Of External Dictionaries {#dicts-external-dicts-dict-sources} - -An external dictionary can be connected from many different sources. - -If dictionary is configured using xml-file, the configuration looks like this: - -``` xml - - - ... - - - - - - ... - - ... - -``` - -In case of [DDL-query](../../statements/create.md#create-dictionary-query), equal configuration will looks like: - -``` sql -CREATE DICTIONARY dict_name (...) -... -SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration -... -``` - -The source is configured in the `source` section. - -For source types [Local file](#dicts-external_dicts_dict_sources-local_file), [Executable file](#dicts-external_dicts_dict_sources-executable), [HTTP(s)](#dicts-external_dicts_dict_sources-http), [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) -optional settings are available: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - - 0 - - -``` -or -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -SETTINGS(format_csv_allow_single_quotes = 0) -``` - - -Types of sources (`source_type`): - -- [Local file](#dicts-external_dicts_dict_sources-local_file) -- [Executable file](#dicts-external_dicts_dict_sources-executable) -- [HTTP(s)](#dicts-external_dicts_dict_sources-http) -- DBMS - - [ODBC](#dicts-external_dicts_dict_sources-odbc) - - [MySQL](#dicts-external_dicts_dict_sources-mysql) - - [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) - - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) - - [Redis](#dicts-external_dicts_dict_sources-redis) - -## Local File {#dicts-external_dicts_dict_sources-local_file} - -Example of settings: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - -``` - -or - -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -Setting fields: - -- `path` – The absolute path to the file. -- `format` – The file format. All the formats described in “[Formats](../../../interfaces/formats.md#formats)” are supported. - -## Executable File {#dicts-external_dicts_dict_sources-executable} - -Working with executable files depends on [how the dictionary is stored in memory](external_dicts_dict_layout.md). If the dictionary is stored using `cache` and `complex_key_cache`, ClickHouse requests the necessary keys by sending a request to the executable file’s STDIN. Otherwise, ClickHouse starts executable file and treats its output as dictionary data. - -Example of settings: - -``` xml - - - cat /opt/dictionaries/os.tsv - TabSeparated - - -``` - -or - -``` sql -SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -Setting fields: - -- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). -- `format` – The file format. All the formats described in “[Formats](../../../interfaces/formats.md#formats)” are supported. - -## Http(s) {#dicts-external_dicts_dict_sources-http} - -Working with an HTTP(s) server depends on [how the dictionary is stored in memory](external_dicts_dict_layout.md). If the dictionary is stored using `cache` and `complex_key_cache`, ClickHouse requests the necessary keys by sending a request via the `POST` method. - -Example of settings: - -``` xml - - - http://[::1]/os.tsv - TabSeparated - - user - password - - -
- API-KEY - key -
-
-
- -``` - -or - -``` sql -SOURCE(HTTP( - url 'http://[::1]/os.tsv' - format 'TabSeparated' - credentials(user 'user' password 'password') - headers(header(name 'API-KEY' value 'key')) -)) -``` - -In order for ClickHouse to access an HTTPS resource, you must [configure openSSL](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-openssl) in the server configuration. - -Setting fields: - -- `url` – The source URL. -- `format` – The file format. All the formats described in “[Formats](../../../interfaces/formats.md#formats)” are supported. -- `credentials` – Basic HTTP authentication. Optional parameter. - - `user` – Username required for the authentication. - - `password` – Password required for the authentication. -- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. - - `header` – Single HTTP header entry. - - `name` – Identifiant name used for the header send on the request. - - `value` – Value set for a specific identifiant name. - -## ODBC {#dicts-external_dicts_dict_sources-odbc} - -You can use this method to connect any database that has an ODBC driver. - -Example of settings: - -``` xml - - - DatabaseName - ShemaName.TableName
- DSN=some_parameters - SQL_QUERY -
- -``` - -or - -``` sql -SOURCE(ODBC( - db 'DatabaseName' - table 'SchemaName.TableName' - connection_string 'DSN=some_parameters' - invalidate_query 'SQL_QUERY' -)) -``` - -Setting fields: - -- `db` – Name of the database. Omit it if the database name is set in the `` parameters. -- `table` – Name of the table and schema if exists. -- `connection_string` – Connection string. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [Updating dictionaries](external_dicts_dict_lifetime.md). - -ClickHouse receives quoting symbols from ODBC-driver and quote all settings in queries to driver, so it’s necessary to set table name accordingly to table name case in database. - -If you have a problems with encodings when using Oracle, see the corresponding [FAQ](../../../faq/general.md#oracle-odbc-encodings) article. - -### Known Vulnerability Of the ODBC Dictionary Functionality {#known-vulnerability-of-the-odbc-dictionary-functionality} - -!!! attention "Attention" - When connecting to the database through the ODBC driver connection parameter `Servername` can be substituted. In this case values of `USERNAME` and `PASSWORD` from `odbc.ini` are sent to the remote server and can be compromised. - -**Example of insecure use** - -Let’s configure unixODBC for PostgreSQL. Content of `/etc/odbc.ini`: - -``` text -[gregtest] -Driver = /usr/lib/psqlodbca.so -Servername = localhost -PORT = 5432 -DATABASE = test_db -#OPTION = 3 -USERNAME = test -PASSWORD = test -``` - -If you then make a query such as - -``` sql -SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); -``` - -ODBC driver will send values of `USERNAME` and `PASSWORD` from `odbc.ini` to `some-server.com`. - -### Example Of Connecting Postgresql {#example-of-connecting-postgresql} - -Ubuntu OS. - -Installing unixODBC and the ODBC driver for PostgreSQL: - -``` bash -$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql -``` - -Configuring `/etc/odbc.ini` (or `~/.odbc.ini`): - -``` text - [DEFAULT] - Driver = myconnection - - [myconnection] - Description = PostgreSQL connection to my_db - Driver = PostgreSQL Unicode - Database = my_db - Servername = 127.0.0.1 - UserName = username - Password = password - Port = 5432 - Protocol = 9.3 - ReadOnly = No - RowVersioning = No - ShowSystemTables = No - ConnSettings = -``` - -The dictionary configuration in ClickHouse: - -``` xml - - - table_name - - - - - DSN=myconnection - postgresql_table
-
- - - 300 - 360 - - - - - - - id - - - some_column - UInt64 - 0 - - -
-
-``` - -or - -``` sql -CREATE DICTIONARY table_name ( - id UInt64, - some_column UInt64 DEFAULT 0 -) -PRIMARY KEY id -SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) -LAYOUT(HASHED()) -LIFETIME(MIN 300 MAX 360) -``` - -You may need to edit `odbc.ini` to specify the full path to the library with the driver `DRIVER=/usr/local/lib/psqlodbcw.so`. - -### Example Of Connecting MS SQL Server {#example-of-connecting-ms-sql-server} - -Ubuntu OS. - -Installing the driver: : - -``` bash -$ sudo apt-get install tdsodbc freetds-bin sqsh -``` - -Configuring the driver: - -``` bash - $ cat /etc/freetds/freetds.conf - ... - - [MSSQL] - host = 192.168.56.101 - port = 1433 - tds version = 7.0 - client charset = UTF-8 - - $ cat /etc/odbcinst.ini - ... - - [FreeTDS] - Description = FreeTDS - Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so - Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so - FileUsage = 1 - UsageCount = 5 - - $ cat ~/.odbc.ini - ... - - [MSSQL] - Description = FreeTDS - Driver = FreeTDS - Servername = MSSQL - Database = test - UID = test - PWD = test - Port = 1433 -``` - -Configuring the dictionary in ClickHouse: - -``` xml - - - test - - - dict
- DSN=MSSQL;UID=test;PWD=test -
- - - - 300 - 360 - - - - - - - - - k - - - s - String - - - -
-
-``` - -or - -``` sql -CREATE DICTIONARY test ( - k UInt64, - s String DEFAULT '' -) -PRIMARY KEY k -SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) -LAYOUT(FLAT()) -LIFETIME(MIN 300 MAX 360) -``` - -## DBMS {#dbms} - -### Mysql {#dicts-external_dicts_dict_sources-mysql} - -Example of settings: - -``` xml - - - 3306 - clickhouse - qwerty - - example01-1 - 1 - - - example01-2 - 1 - - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -or - -``` sql -SOURCE(MYSQL( - port 3306 - user 'clickhouse' - password 'qwerty' - replica(host 'example01-1' priority 1) - replica(host 'example01-2' priority 1) - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -Setting fields: - -- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). - -- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `replica` – Section of replica configurations. There can be multiple sections. - - - `replica/host` – The MySQL host. - - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. - -- `db` – Name of the database. - -- `table` – Name of the table. - -- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` clause in MySQL, for example, `id > 10 AND id < 20`. Optional parameter. - -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [Updating dictionaries](external_dicts_dict_lifetime.md). - -MySQL can be connected on a local host via sockets. To do this, set `host` and `socket`. - -Example of settings: - -``` xml - - - localhost - /path/to/socket/file.sock - clickhouse - qwerty - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -or - -``` sql -SOURCE(MYSQL( - host 'localhost' - socket '/path/to/socket/file.sock' - user 'clickhouse' - password 'qwerty' - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -### ClickHouse {#dicts-external_dicts_dict_sources-clickhouse} - -Example of settings: - -``` xml - - - example01-01-1 - 9000 - default - - default - ids
- id=10 -
- -``` - -or - -``` sql -SOURCE(CLICKHOUSE( - host 'example01-01-1' - port 9000 - user 'default' - password '' - db 'default' - table 'ids' - where 'id=10' -)) -``` - -Setting fields: - -- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [Distributed](../../../engines/table_engines/special/distributed.md) table and enter it in subsequent configurations. -- `port` – The port on the ClickHouse server. -- `user` – Name of the ClickHouse user. -- `password` – Password of the ClickHouse user. -- `db` – Name of the database. -- `table` – Name of the table. -- `where` – The selection criteria. May be omitted. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [Updating dictionaries](external_dicts_dict_lifetime.md). - -### Mongodb {#dicts-external_dicts_dict_sources-mongodb} - -Example of settings: - -``` xml - - - localhost - 27017 - - - test - dictionary_source - - -``` - -or - -``` sql -SOURCE(MONGO( - host 'localhost' - port 27017 - user '' - password '' - db 'test' - collection 'dictionary_source' -)) -``` - -Setting fields: - -- `host` – The MongoDB host. -- `port` – The port on the MongoDB server. -- `user` – Name of the MongoDB user. -- `password` – Password of the MongoDB user. -- `db` – Name of the database. -- `collection` – Name of the collection. - -### Redis {#dicts-external_dicts_dict_sources-redis} - -Example of settings: - -``` xml - - - localhost - 6379 - simple - 0 - - -``` - -or - -``` sql -SOURCE(REDIS( - host 'localhost' - port 6379 - storage_type 'simple' - db_index 0 -)) -``` - -Setting fields: - -- `host` – The Redis host. -- `port` – The port on the Redis server. -- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` is for simple sources and for hashed single key sources, `hash_map` is for hashed sources with two keys. Ranged sources and cache sources with complex key are unsupported. May be omitted, default value is `simple`. -- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md b/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md deleted file mode 100644 index 460320e6fa3..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -toc_priority: 44 -toc_title: Dictionary Key and Fields ---- - -# Dictionary Key and Fields {#dictionary-key-and-fields} - -The `` clause describes the dictionary key and fields available for queries. - -XML description: - -``` xml - - - - Id - - - - - - - ... - - - -``` - -Attributes are described in the elements: - -- `` — [Key column](external_dicts_dict_structure.md#ext_dict_structure-key). -- `` — [Data column](external_dicts_dict_structure.md#ext_dict_structure-attributes). There can be a multiple number of attributes. - -DDL query: - -``` sql -CREATE DICTIONARY dict_name ( - Id UInt64, - -- attributes -) -PRIMARY KEY Id -... -``` - -Attributes are described in the query body: - -- `PRIMARY KEY` — [Key column](external_dicts_dict_structure.md#ext_dict_structure-key) -- `AttrName AttrType` — [Data column](external_dicts_dict_structure.md#ext_dict_structure-attributes). There can be a multiple number of attributes. - -## Key {#ext_dict_structure-key} - -ClickHouse supports the following types of keys: - -- Numeric key. `UInt64`. Defined in the `` tag or using `PRIMARY KEY` keyword. -- Composite key. Set of values of different types. Defined in the tag `` or `PRIMARY KEY` keyword. - -An xml structure can contain either `` or ``. DDL-query must contain single `PRIMARY KEY`. - -!!! warning "Warning" - You must not describe key as an attribute. - -### Numeric Key {#ext_dict-numeric-key} - -Type: `UInt64`. - -Configuration example: - -``` xml - - Id - -``` - -Configuration fields: - -- `name` – The name of the column with keys. - -For DDL-query: - -``` sql -CREATE DICTIONARY ( - Id UInt64, - ... -) -PRIMARY KEY Id -... -``` - -- `PRIMARY KEY` – The name of the column with keys. - -### Composite Key {#composite-key} - -The key can be a `tuple` from any types of fields. The [layout](external_dicts_dict_layout.md) in this case must be `complex_key_hashed` or `complex_key_cache`. - -!!! tip "Tip" - A composite key can consist of a single element. This makes it possible to use a string as the key, for instance. - -The key structure is set in the element ``. Key fields are specified in the same format as the dictionary [attributes](external_dicts_dict_structure.md). Example: - -``` xml - - - - field1 - String - - - field2 - UInt32 - - ... - -... -``` - -or - -``` sql -CREATE DICTIONARY ( - field1 String, - field2 String - ... -) -PRIMARY KEY field1, field2 -... -``` - -For a query to the `dictGet*` function, a tuple is passed as the key. Example: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. - -## Attributes {#ext_dict_structure-attributes} - -Configuration example: - -``` xml - - ... - - Name - ClickHouseDataType - - rand64() - true - true - true - - -``` - -or - -``` sql -CREATE DICTIONARY somename ( - Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID -) -``` - -Configuration fields: - -| Tag | Description | Required | -|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------| -| `name` | Column name. | Yes | -| `type` | ClickHouse data type.
ClickHouse tries to cast value from dictionary to the specified data type. For example, for MySQL, the field might be `TEXT`, `VARCHAR`, or `BLOB` in the MySQL source table, but it can be uploaded as `String` in ClickHouse.
[Nullable](../../../sql_reference/data_types/nullable.md) is not supported. | Yes | -| `null_value` | Default value for a non-existing element.
In the example, it is an empty string. You cannot use `NULL` in this field. | Yes | -| `expression` | [Expression](../../syntax.md#syntax-expressions) that ClickHouse executes on the value.
The expression can be a column name in the remote SQL database. Thus, you can use it to create an alias for the remote column.

Default value: no expression. | No | -| `hierarchical` | If `true`, the attribute contains the value of a parent key for the current key. See [Hierarchical Dictionaries](external_dicts_dict_hierarchical.md).

Default value: `false`. | No | -| `injective` | Flag that shows whether the `id -> attribute` image is [injective](https://en.wikipedia.org/wiki/Injective_function).
If `true`, ClickHouse can automatically place after the `GROUP BY` clause the requests to dictionaries with injection. Usually it significantly reduces the amount of such requests.

Default value: `false`. | No | -| `is_object_id` | Flag that shows whether the query is executed for a MongoDB document by `ObjectID`.

Default value: `false`. | No | - -## See Also {#see-also} - -- [Functions for working with external dictionaries](../../../sql_reference/functions/ext_dict_functions.md). - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/en/sql_reference/dictionaries/external_dictionaries/index.md b/docs/en/sql_reference/dictionaries/external_dictionaries/index.md deleted file mode 100644 index 9af8b4f2f12..00000000000 --- a/docs/en/sql_reference/dictionaries/external_dictionaries/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: External Dictionaries -toc_priority: 37 ---- - diff --git a/docs/en/sql_reference/dictionaries/index.md b/docs/en/sql_reference/dictionaries/index.md deleted file mode 100644 index 9806b27ed9b..00000000000 --- a/docs/en/sql_reference/dictionaries/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -toc_folder_title: Dictionaries -toc_priority: 35 -toc_title: Introduction ---- - -# Dictionaries {#dictionaries} - -A dictionary is a mapping (`key -> attributes`) that is convenient for various types of reference lists. - -ClickHouse supports special functions for working with dictionaries that can be used in queries. It is easier and more efficient to use dictionaries with functions than a `JOIN` with reference tables. - -[NULL](../syntax.md#null) values can’t be stored in a dictionary. - -ClickHouse supports: - -- [Built-in dictionaries](internal_dicts.md#internal_dicts) with a specific [set of functions](../../sql_reference/functions/ym_dict_functions.md). -- [Plug-in (external) dictionaries](external_dictionaries/external_dicts.md) with a [net of functions](../../sql_reference/functions/ext_dict_functions.md). - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/en/sql_reference/dictionaries/internal_dicts.md b/docs/en/sql_reference/dictionaries/internal_dicts.md deleted file mode 100644 index 327206c9672..00000000000 --- a/docs/en/sql_reference/dictionaries/internal_dicts.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -toc_priority: 39 -toc_title: Internal Dictionaries ---- - -# Internal dictionaries {#internal_dicts} - -ClickHouse contains a built-in feature for working with a geobase. - -This allows you to: - -- Use a region’s ID to get its name in the desired language. -- Use a region’s ID to get the ID of a city, area, federal district, country, or continent. -- Check whether a region is part of another region. -- Get a chain of parent regions. - -All the functions support “translocality,” the ability to simultaneously use different perspectives on region ownership. For more information, see the section “Functions for working with Yandex.Metrica dictionaries”. - -The internal dictionaries are disabled in the default package. -To enable them, uncomment the parameters `path_to_regions_hierarchy_file` and `path_to_regions_names_files` in the server configuration file. - -The geobase is loaded from text files. - -Place the `regions_hierarchy*.txt` files into the `path_to_regions_hierarchy_file` directory. This configuration parameter must contain the path to the `regions_hierarchy.txt` file (the default regional hierarchy), and the other files (`regions_hierarchy_ua.txt`) must be located in the same directory. - -Put the `regions_names_*.txt` files in the `path_to_regions_names_files` directory. - -You can also create these files yourself. The file format is as follows: - -`regions_hierarchy*.txt`: TabSeparated (no header), columns: - -- region ID (`UInt32`) -- parent region ID (`UInt32`) -- region type (`UInt8`): 1 - continent, 3 - country, 4 - federal district, 5 - region, 6 - city; other types don’t have values -- population (`UInt32`) — optional column - -`regions_names_*.txt`: TabSeparated (no header), columns: - -- region ID (`UInt32`) -- region name (`String`) — Can’t contain tabs or line feeds, even escaped ones. - -A flat array is used for storing in RAM. For this reason, IDs shouldn’t be more than a million. - -Dictionaries can be updated without restarting the server. However, the set of available dictionaries is not updated. -For updates, the file modification times are checked. If a file has changed, the dictionary is updated. -The interval to check for changes is configured in the `builtin_dictionaries_reload_interval` parameter. -Dictionary updates (other than loading at first use) do not block queries. During updates, queries use the old versions of dictionaries. If an error occurs during an update, the error is written to the server log, and queries continue using the old version of dictionaries. - -We recommend periodically updating the dictionaries with the geobase. During an update, generate new files and write them to a separate location. When everything is ready, rename them to the files used by the server. - -There are also functions for working with OS identifiers and Yandex.Metrica search engines, but they shouldn’t be used. - -[Original article](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/en/sql_reference/functions/arithmetic_functions.md b/docs/en/sql_reference/functions/arithmetic_functions.md deleted file mode 100644 index 36cb6e9ada9..00000000000 --- a/docs/en/sql_reference/functions/arithmetic_functions.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -toc_priority: 35 -toc_title: Arithmetic ---- - -# Arithmetic functions {#arithmetic-functions} - -For all arithmetic functions, the result type is calculated as the smallest number type that the result fits in, if there is such a type. The minimum is taken simultaneously based on the number of bits, whether it is signed, and whether it floats. If there are not enough bits, the highest bit type is taken. - -Example: - -``` sql -SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) -``` - -``` text -┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ -│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ -└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ -``` - -Arithmetic functions work for any pair of types from UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, or Float64. - -Overflow is produced the same way as in C++. - -## plus(a, b), a + b operator {#plusa-b-a-b-operator} - -Calculates the sum of the numbers. -You can also add integer numbers with a date or date and time. In the case of a date, adding an integer means adding the corresponding number of days. For a date with time, it means adding the corresponding number of seconds. - -## minus(a, b), a - b operator {#minusa-b-a-b-operator} - -Calculates the difference. The result is always signed. - -You can also calculate integer numbers from a date or date with time. The idea is the same – see above for ‘plus’. - -## multiply(a, b), a \* b operator {#multiplya-b-a-b-operator} - -Calculates the product of the numbers. - -## divide(a, b), a / b operator {#dividea-b-a-b-operator} - -Calculates the quotient of the numbers. The result type is always a floating-point type. -It is not integer division. For integer division, use the ‘intDiv’ function. -When dividing by zero you get ‘inf’, ‘-inf’, or ‘nan’. - -## intDiv(a, b) {#intdiva-b} - -Calculates the quotient of the numbers. Divides into integers, rounding down (by the absolute value). -An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one. - -## intDivOrZero(a, b) {#intdivorzeroa-b} - -Differs from ‘intDiv’ in that it returns zero when dividing by zero or when dividing a minimal negative number by minus one. - -## modulo(a, b), a % b operator {#moduloa-b-a-b-operator} - -Calculates the remainder after division. -If arguments are floating-point numbers, they are pre-converted to integers by dropping the decimal portion. -The remainder is taken in the same sense as in C++. Truncated division is used for negative numbers. -An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one. - -## moduloOrZero(a, b) {#moduloorzeroa-b} - -Differs from ‘modulo’ in that it returns zero when the divisor is zero. - -## negate(a), -a operator {#negatea-a-operator} - -Calculates a number with the reverse sign. The result is always signed. - -## abs(a) {#arithm_func-abs} - -Calculates the absolute value of the number (a). That is, if a \< 0, it returns -a. For unsigned types it doesn’t do anything. For signed integer types, it returns an unsigned number. - -## gcd(a, b) {#gcda-b} - -Returns the greatest common divisor of the numbers. -An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one. - -## lcm(a, b) {#lcma-b} - -Returns the least common multiple of the numbers. -An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/en/sql_reference/functions/array_functions.md b/docs/en/sql_reference/functions/array_functions.md deleted file mode 100644 index 77a955fa18b..00000000000 --- a/docs/en/sql_reference/functions/array_functions.md +++ /dev/null @@ -1,1058 +0,0 @@ ---- -toc_priority: 46 -toc_title: Working with Arrays ---- - -# Functions for working with arrays {#functions-for-working-with-arrays} - -## empty {#function-empty} - -Returns 1 for an empty array, or 0 for a non-empty array. -The result type is UInt8. -The function also works for strings. - -## notEmpty {#function-notempty} - -Returns 0 for an empty array, or 1 for a non-empty array. -The result type is UInt8. -The function also works for strings. - -## length {#array_functions-length} - -Returns the number of items in the array. -The result type is UInt64. -The function also works for strings. - -## emptyArrayUInt8, emptyArrayUInt16, emptyArrayUInt32, emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} - -## emptyArrayInt8, emptyArrayInt16, emptyArrayInt32, emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} - -## emptyArrayFloat32, emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} - -## emptyArrayDate, emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} - -## emptyArrayString {#emptyarraystring} - -Accepts zero arguments and returns an empty array of the appropriate type. - -## emptyArrayToSingle {#emptyarraytosingle} - -Accepts an empty array and returns a one-element array that is equal to the default value. - -## range(end), range(start, end \[, step\]) {#rangeend-rangestart-end-step} - -Returns an array of numbers from start to end-1 by step. -If the argument `start` is not specified, defaults to 0. -If the argument `step` is not specified, defaults to 1. -It behaviors almost like pythonic `range`. But the difference is that all the arguments type must be `UInt` numbers. -Just in case, an exception is thrown if arrays with a total length of more than 100,000,000 elements are created in a data block. - -## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} - -Creates an array from the function arguments. -The arguments must be constants and have types that have the smallest common type. At least one argument must be passed, because otherwise it isn’t clear which type of array to create. That is, you can’t use this function to create an empty array (to do that, use the ‘emptyArray\*’ function described above). -Returns an ‘Array(T)’ type result, where ‘T’ is the smallest common type out of the passed arguments. - -## arrayConcat {#arrayconcat} - -Combines arrays passed as arguments. - -``` sql -arrayConcat(arrays) -``` - -**Parameters** - -- `arrays` – Arbitrary number of arguments of [Array](../../sql_reference/data_types/array.md) type. - **Example** - - - -``` sql -SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,3,4,5,6] │ -└───────────────┘ -``` - -## arrayElement(arr, n), operator arr\[n\] {#arrayelementarr-n-operator-arrn} - -Get the element with the index `n` from the array `arr`. `n` must be any integer type. -Indexes in an array begin from one. -Negative indexes are supported. In this case, it selects the corresponding element numbered from the end. For example, `arr[-1]` is the last item in the array. - -If the index falls outside of the bounds of an array, it returns some default value (0 for numbers, an empty string for strings, etc.), except for the case with a non-constant array and a constant index 0 (in this case there will be an error `Array indices are 1-based`). - -## has(arr, elem) {#hasarr-elem} - -Checks whether the ‘arr’ array has the ‘elem’ element. -Returns 0 if the the element is not in the array, or 1 if it is. - -`NULL` is processed as a value. - -``` sql -SELECT has([1, 2, NULL], NULL) -``` - -``` text -┌─has([1, 2, NULL], NULL)─┐ -│ 1 │ -└─────────────────────────┘ -``` - -## hasAll {#hasall} - -Checks whether one array is a subset of another. - -``` sql -hasAll(set, subset) -``` - -**Parameters** - -- `set` – Array of any type with a set of elements. -- `subset` – Array of any type with elements that should be tested to be a subset of `set`. - -**Return values** - -- `1`, if `set` contains all of the elements from `subset`. -- `0`, otherwise. - -**Peculiar properties** - -- An empty array is a subset of any array. -- `Null` processed as a value. -- Order of values in both of arrays doesn’t matter. - -**Examples** - -`SELECT hasAll([], [])` returns 1. - -`SELECT hasAll([1, Null], [Null])` returns 1. - -`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` returns 1. - -`SELECT hasAll(['a', 'b'], ['a'])` returns 1. - -`SELECT hasAll([1], ['a'])` returns 0. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` returns 0. - -## hasAny {#hasany} - -Checks whether two arrays have intersection by some elements. - -``` sql -hasAny(array1, array2) -``` - -**Parameters** - -- `array1` – Array of any type with a set of elements. -- `array2` – Array of any type with a set of elements. - -**Return values** - -- `1`, if `array1` and `array2` have one similar element at least. -- `0`, otherwise. - -**Peculiar properties** - -- `Null` processed as a value. -- Order of values in both of arrays doesn’t matter. - -**Examples** - -`SELECT hasAny([1], [])` returns `0`. - -`SELECT hasAny([Null], [Null, 1])` returns `1`. - -`SELECT hasAny([-128, 1., 512], [1])` returns `1`. - -`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` returns `0`. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` returns `1`. - -## indexOf(arr, x) {#indexofarr-x} - -Returns the index of the first ‘x’ element (starting from 1) if it is in the array, or 0 if it is not. - -Example: - -``` sql -SELECT indexOf([1, 3, NULL, NULL], NULL) -``` - -``` text - -┌─indexOf([1, 3, NULL, NULL], NULL)─┐ -│ 3 │ -└───────────────────────────────────┘ -``` - -Elements set to `NULL` are handled as normal values. - -## countEqual(arr, x) {#countequalarr-x} - -Returns the number of elements in the array equal to x. Equivalent to arrayCount (elem -\> elem = x, arr). - -`NULL` elements are handled as separate values. - -Example: - -``` sql -SELECT countEqual([1, 2, NULL, NULL], NULL) -``` - -``` text -┌─countEqual([1, 2, NULL, NULL], NULL)─┐ -│ 2 │ -└──────────────────────────────────────┘ -``` - -## arrayEnumerate(arr) {#array_functions-arrayenumerate} - -Returns the array \[1, 2, 3, …, length (arr) \] - -This function is normally used with ARRAY JOIN. It allows counting something just once for each array after applying ARRAY JOIN. Example: - -``` sql -SELECT - count() AS Reaches, - countIf(num = 1) AS Hits -FROM test.hits -ARRAY JOIN - GoalsReached, - arrayEnumerate(GoalsReached) AS num -WHERE CounterID = 160656 -LIMIT 10 -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -In this example, Reaches is the number of conversions (the strings received after applying ARRAY JOIN), and Hits is the number of pageviews (strings before ARRAY JOIN). In this particular case, you can get the same result in an easier way: - -``` sql -SELECT - sum(length(GoalsReached)) AS Reaches, - count() AS Hits -FROM test.hits -WHERE (CounterID = 160656) AND notEmpty(GoalsReached) -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -This function can also be used in higher-order functions. For example, you can use it to get array indexes for elements that match a condition. - -## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} - -Returns an array the same size as the source array, indicating for each element what its position is among elements with the same value. -For example: arrayEnumerateUniq(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. - -This function is useful when using ARRAY JOIN and aggregation of array elements. -Example: - -``` sql -SELECT - Goals.ID AS GoalID, - sum(Sign) AS Reaches, - sumIf(Sign, num = 1) AS Visits -FROM test.visits -ARRAY JOIN - Goals, - arrayEnumerateUniq(Goals.ID) AS num -WHERE CounterID = 160656 -GROUP BY GoalID -ORDER BY Reaches DESC -LIMIT 10 -``` - -``` text -┌──GoalID─┬─Reaches─┬─Visits─┐ -│ 53225 │ 3214 │ 1097 │ -│ 2825062 │ 3188 │ 1097 │ -│ 56600 │ 2803 │ 488 │ -│ 1989037 │ 2401 │ 365 │ -│ 2830064 │ 2396 │ 910 │ -│ 1113562 │ 2372 │ 373 │ -│ 3270895 │ 2262 │ 812 │ -│ 1084657 │ 2262 │ 345 │ -│ 56599 │ 2260 │ 799 │ -│ 3271094 │ 2256 │ 812 │ -└─────────┴─────────┴────────┘ -``` - -In this example, each goal ID has a calculation of the number of conversions (each element in the Goals nested data structure is a goal that was reached, which we refer to as a conversion) and the number of sessions. Without ARRAY JOIN, we would have counted the number of sessions as sum(Sign). But in this particular case, the rows were multiplied by the nested Goals structure, so in order to count each session one time after this, we apply a condition to the value of the arrayEnumerateUniq(Goals.ID) function. - -The arrayEnumerateUniq function can take multiple arrays of the same size as arguments. In this case, uniqueness is considered for tuples of elements in the same positions in all the arrays. - -``` sql -SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,1,1,2,1] │ -└───────────────┘ -``` - -This is necessary when using ARRAY JOIN with a nested data structure and further aggregation across multiple elements in this structure. - -## arrayPopBack {#arraypopback} - -Removes the last item from the array. - -``` sql -arrayPopBack(array) -``` - -**Parameters** - -- `array` – Array. - -**Example** - -``` sql -SELECT arrayPopBack([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## arrayPopFront {#arraypopfront} - -Removes the first item from the array. - -``` sql -arrayPopFront(array) -``` - -**Parameters** - -- `array` – Array. - -**Example** - -``` sql -SELECT arrayPopFront([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [2,3] │ -└───────┘ -``` - -## arrayPushBack {#arraypushback} - -Adds one item to the end of the array. - -``` sql -arrayPushBack(array, single_value) -``` - -**Parameters** - -- `array` – Array. -- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` type for the data type of the array. For more information about the types of data in ClickHouse, see “[Data types](../../sql_reference/data_types/index.md#data_types)”. Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`. - -**Example** - -``` sql -SELECT arrayPushBack(['a'], 'b') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## arrayPushFront {#arraypushfront} - -Adds one element to the beginning of the array. - -``` sql -arrayPushFront(array, single_value) -``` - -**Parameters** - -- `array` – Array. -- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` type for the data type of the array. For more information about the types of data in ClickHouse, see “[Data types](../../sql_reference/data_types/index.md#data_types)”. Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`. - -**Example** - -``` sql -SELECT arrayPushFront(['b'], 'a') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## arrayResize {#arrayresize} - -Changes the length of the array. - -``` sql -arrayResize(array, size[, extender]) -``` - -**Parameters:** - -- `array` — Array. -- `size` — Required length of the array. - - If `size` is less than the original size of the array, the array is truncated from the right. -- If `size` is larger than the initial size of the array, the array is extended to the right with `extender` values or default values for the data type of the array items. -- `extender` — Value for extending an array. Can be `NULL`. - -**Returned value:** - -An array of length `size`. - -**Examples of calls** - -``` sql -SELECT arrayResize([1], 3) -``` - -``` text -┌─arrayResize([1], 3)─┐ -│ [1,0,0] │ -└─────────────────────┘ -``` - -``` sql -SELECT arrayResize([1], 3, NULL) -``` - -``` text -┌─arrayResize([1], 3, NULL)─┐ -│ [1,NULL,NULL] │ -└───────────────────────────┘ -``` - -## arraySlice {#arrayslice} - -Returns a slice of the array. - -``` sql -arraySlice(array, offset[, length]) -``` - -**Parameters** - -- `array` – Array of data. -- `offset` – Indent from the edge of the array. A positive value indicates an offset on the left, and a negative value is an indent on the right. Numbering of the array items begins with 1. -- `length` - The length of the required slice. If you specify a negative value, the function returns an open slice `[offset, array_length - length)`. If you omit the value, the function returns the slice `[offset, the_end_of_array]`. - -**Example** - -``` sql -SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res -``` - -``` text -┌─res────────┐ -│ [2,NULL,4] │ -└────────────┘ -``` - -Array elements set to `NULL` are handled as normal values. - -## arraySort(\[func,\] arr, …) {#array_functions-sort} - -Sorts the elements of the `arr` array in ascending order. If the `func` function is specified, sorting order is determined by the result of the `func` function applied to the elements of the array. If `func` accepts multiple arguments, the `arraySort` function is passed several arrays that the arguments of `func` will correspond to. Detailed examples are shown at the end of `arraySort` description. - -Example of integer values sorting: - -``` sql -SELECT arraySort([1, 3, 3, 0]); -``` - -``` text -┌─arraySort([1, 3, 3, 0])─┐ -│ [0,1,3,3] │ -└─────────────────────────┘ -``` - -Example of string values sorting: - -``` sql -SELECT arraySort(['hello', 'world', '!']); -``` - -``` text -┌─arraySort(['hello', 'world', '!'])─┐ -│ ['!','hello','world'] │ -└────────────────────────────────────┘ -``` - -Consider the following sorting order for the `NULL`, `NaN` and `Inf` values: - -``` sql -SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); -``` - -``` text -┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ -│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────────────────────────┘ -``` - -- `-Inf` values are first in the array. -- `NULL` values are last in the array. -- `NaN` values are right before `NULL`. -- `Inf` values are right before `NaN`. - -Note that `arraySort` is a [higher-order function](higher_order_functions.md). You can pass a lambda function to it as the first argument. In this case, sorting order is determined by the result of the lambda function applied to the elements of the array. - -Let’s consider the following example: - -``` sql -SELECT arraySort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,2,1] │ -└─────────┘ -``` - -For each element of the source array, the lambda function returns the sorting key, that is, \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Since the `arraySort` function sorts the keys in ascending order, the result is \[3, 2, 1\]. Thus, the `(x) –> -x` lambda function sets the [descending order](#array_functions-reverse-sort) in a sorting. - -The lambda function can accept multiple arguments. In this case, you need to pass the `arraySort` function several arrays of identical length that the arguments of lambda function will correspond to. The resulting array will consist of elements from the first input array; elements from the next input array(s) specify the sorting keys. For example: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -Here, the elements that are passed in the second array (\[2, 1\]) define a sorting key for the corresponding element from the source array (\[‘hello’, ‘world’\]), that is, \[‘hello’ –\> 2, ‘world’ –\> 1\]. Since the lambda function doesn’t use `x`, actual values of the source array don’t affect the order in the result. So, ‘hello’ will be the second element in the result, and ‘world’ will be the first. - -Other examples are shown below. - -``` sql -SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -``` sql -SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -!!! note "Note" - To improve sorting efficiency, the [Schwartzian transform](https://en.wikipedia.org/wiki/Schwartzian_transform) is used. - -## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} - -Sorts the elements of the `arr` array in descending order. If the `func` function is specified, `arr` is sorted according to the result of the `func` function applied to the elements of the array, and then the sorted array is reversed. If `func` accepts multiple arguments, the `arrayReverseSort` function is passed several arrays that the arguments of `func` will correspond to. Detailed examples are shown at the end of `arrayReverseSort` description. - -Example of integer values sorting: - -``` sql -SELECT arrayReverseSort([1, 3, 3, 0]); -``` - -``` text -┌─arrayReverseSort([1, 3, 3, 0])─┐ -│ [3,3,1,0] │ -└────────────────────────────────┘ -``` - -Example of string values sorting: - -``` sql -SELECT arrayReverseSort(['hello', 'world', '!']); -``` - -``` text -┌─arrayReverseSort(['hello', 'world', '!'])─┐ -│ ['world','hello','!'] │ -└───────────────────────────────────────────┘ -``` - -Consider the following sorting order for the `NULL`, `NaN` and `Inf` values: - -``` sql -SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; -``` - -``` text -┌─res───────────────────────────────────┐ -│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────┘ -``` - -- `Inf` values are first in the array. -- `NULL` values are last in the array. -- `NaN` values are right before `NULL`. -- `-Inf` values are right before `NaN`. - -Note that the `arrayReverseSort` is a [higher-order function](higher_order_functions.md). You can pass a lambda function to it as the first argument. Example is shown below. - -``` sql -SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [1,2,3] │ -└─────────┘ -``` - -The array is sorted in the following way: - -1. At first, the source array (\[1, 2, 3\]) is sorted according to the result of the lambda function applied to the elements of the array. The result is an array \[3, 2, 1\]. -2. Array that is obtained on the previous step, is reversed. So, the final result is \[1, 2, 3\]. - -The lambda function can accept multiple arguments. In this case, you need to pass the `arrayReverseSort` function several arrays of identical length that the arguments of lambda function will correspond to. The resulting array will consist of elements from the first input array; elements from the next input array(s) specify the sorting keys. For example: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -In this example, the array is sorted in the following way: - -1. At first, the source array (\[‘hello’, ‘world’\]) is sorted according to the result of the lambda function applied to the elements of the arrays. The elements that are passed in the second array (\[2, 1\]), define the sorting keys for corresponding elements from the source array. The result is an array \[‘world’, ‘hello’\]. -2. Array that was sorted on the previous step, is reversed. So, the final result is \[‘hello’, ‘world’\]. - -Other examples are shown below. - -``` sql -SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; -``` - -``` text -┌─res─────┐ -│ [5,3,4] │ -└─────────┘ -``` - -``` sql -SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; -``` - -``` text -┌─res─────┐ -│ [4,3,5] │ -└─────────┘ -``` - -## arrayUniq(arr, …) {#arrayuniqarr} - -If one argument is passed, it counts the number of different elements in the array. -If multiple arguments are passed, it counts the number of different tuples of elements at corresponding positions in multiple arrays. - -If you want to get a list of unique items in an array, you can use arrayReduce(‘groupUniqArray’, arr). - -## arrayJoin(arr) {#array-functions-join} - -A special function. See the section [“ArrayJoin function”](array_join.md#functions_arrayjoin). - -## arrayDifference {#arraydifference} - -Calculates the difference between adjacent array elements. Returns an array where the first element will be 0, the second is the difference between `a[1] - a[0]`, etc. The type of elements in the resulting array is determined by the type inference rules for subtraction (e.g. `UInt8` - `UInt8` = `Int16`). - -**Syntax** - -``` sql -arrayDifference(array) -``` - -**Parameters** - -- `array` – [Array](https://clickhouse.yandex/docs/en/data_types/array/). - -**Returned values** - -Returns an array of differences between adjacent elements. - -Type: [UInt\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#uint-ranges), [Int\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#int-ranges), [Float\*](https://clickhouse.yandex/docs/en/data_types/float/). - -**Example** - -Query: - -``` sql -SELECT arrayDifference([1, 2, 3, 4]) -``` - -Result: - -``` text -┌─arrayDifference([1, 2, 3, 4])─┐ -│ [0,1,1,1] │ -└───────────────────────────────┘ -``` - -Example of the overflow due to result type Int64: - -Query: - -``` sql -SELECT arrayDifference([0, 10000000000000000000]) -``` - -Result: - -``` text -┌─arrayDifference([0, 10000000000000000000])─┐ -│ [0,-8446744073709551616] │ -└────────────────────────────────────────────┘ -``` - -## arrayDistinct {#arraydistinct} - -Takes an array, returns an array containing the distinct elements only. - -**Syntax** - -``` sql -arrayDistinct(array) -``` - -**Parameters** - -- `array` – [Array](https://clickhouse.yandex/docs/en/data_types/array/). - -**Returned values** - -Returns an array containing the distinct elements. - -**Example** - -Query: - -``` sql -SELECT arrayDistinct([1, 2, 2, 3, 1]) -``` - -Result: - -``` text -┌─arrayDistinct([1, 2, 2, 3, 1])─┐ -│ [1,2,3] │ -└────────────────────────────────┘ -``` - -## arrayEnumerateDense(arr) {#array_functions-arrayenumeratedense} - -Returns an array of the same size as the source array, indicating where each element first appears in the source array. - -Example: - -``` sql -SELECT arrayEnumerateDense([10, 20, 10, 30]) -``` - -``` text -┌─arrayEnumerateDense([10, 20, 10, 30])─┐ -│ [1,2,1,3] │ -└───────────────────────────────────────┘ -``` - -## arrayIntersect(arr) {#array-functions-arrayintersect} - -Takes multiple arrays, returns an array with elements that are present in all source arrays. Elements order in the resulting array is the same as in the first array. - -Example: - -``` sql -SELECT - arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, - arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect -``` - -``` text -┌─no_intersect─┬─intersect─┐ -│ [] │ [1] │ -└──────────────┴───────────┘ -``` - -## arrayReduce {#arrayreduce} - -Applies an aggregate function to array elements and returns its result. The name of the aggregation function is passed as a string in single quotes `'max'`, `'sum'`. When using parametric aggregate functions, the parameter is indicated after the function name in parentheses `'uniqUpTo(6)'`. - -**Syntax** - -```sql -arrayReduce(agg_func, arr1, arr2, ..., arrN) -``` - -**Parameters** - -* `agg_func` — The name of an aggregate function which should be a constant [string](../../sql_reference/data_types/string.md). -* `arr` — Any number of [array](../../sql_reference/data_types/array.md) type columns as the parameters of the aggregation function. - -**Returned value** - -**Example** - -```sql -SELECT arrayReduce('max', [1, 2, 3]) -``` - -```text -┌─arrayReduce('max', [1, 2, 3])─┐ -│ 3 │ -└───────────────────────────────┘ -``` - -If an aggregate function takes multiple arguments, then this function must be applied to multiple arrays of the same size. - -```sql -SELECT arrayReduce('maxIf', [3, 5], [1, 0]) -``` - -```text -┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ -│ 3 │ -└──────────────────────────────────────┘ -``` - -Example with a parametric aggregate function: - -```sql -SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -``` - -```text -┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ -│ 4 │ -└─────────────────────────────────────────────────────────────┘ -``` - -## arrayReduceInRanges {#arrayreduceinranges} - -Applies an aggregate function to array elements in given ranges and returns an array containing the result corresponding to each range. The function will return the same result as multiple `arrayReduce(agg_func, arraySlice(arr1, index, length), ...)`. - -**Syntax** - -```sql -arrayReduceInRanges(agg_func, ranges, arr1, arr2, ..., arrN) -``` - -**Parameters** - -* `agg_func` — The name of an aggregate function which should be a constant [string](../../sql_reference/data_types/string.md). -* `ranges` — The ranges to aggretate which should be an [array](../../sql_reference/data_types/array.md) of [tuples](../../sql_reference/data_types/tuple.md) which containing the index and the length of each range. -* `arr` — Any number of [array](../../sql_reference/data_types/array.md) type columns as the parameters of the aggregation function. - -**Returned value** - -**Example** - -```sql -SELECT arrayReduceInRanges( - 'sum', - [(1, 5), (2, 3), (3, 4), (4, 4)], - [1000000, 200000, 30000, 4000, 500, 60, 7] -) AS res -``` - -```text -┌─res─────────────────────────┐ -│ [1234500,234000,34560,4567] │ -└─────────────────────────────┘ -``` - -## arrayReverse(arr) {#arrayreverse} - -Returns an array of the same size as the original array containing the elements in reverse order. - -Example: - -``` sql -SELECT arrayReverse([1, 2, 3]) -``` - -``` text -┌─arrayReverse([1, 2, 3])─┐ -│ [3,2,1] │ -└─────────────────────────┘ -``` - -## reverse(arr) {#array-functions-reverse} - -Synonym for [“arrayReverse”](#array_functions-arrayreverse) - -## arrayFlatten {#arrayflatten} - -Converts an array of arrays to a flat array. - -Function: - -- Applies to any depth of nested arrays. -- Does not change arrays that are already flat. - -The flattened array contains all the elements from all source arrays. - -**Syntax** - -``` sql -flatten(array_of_arrays) -``` - -Alias: `flatten`. - -**Parameters** - -- `array_of_arrays` — [Array](../../sql_reference/data_types/array.md) of arrays. For example, `[[1,2,3], [4,5]]`. - -**Examples** - -``` sql -SELECT flatten([[[1]], [[2], [3]]]) -``` - -``` text -┌─flatten(array(array([1]), array([2], [3])))─┐ -│ [1,2,3] │ -└─────────────────────────────────────────────┘ -``` - -## arrayCompact {#arraycompact} - -Removes consecutive duplicate elements from an array. The order of result values is determined by the order in the source array. - -**Syntax** - -``` sql -arrayCompact(arr) -``` - -**Parameters** - -`arr` — The [array](../../sql_reference/data_types/array.md) to inspect. - -**Returned value** - -The array without duplicate. - -Type: `Array`. - -**Example** - -Query: - -``` sql -SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) -``` - -Result: - -``` text -┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ -│ [1,nan,nan,2,3] │ -└────────────────────────────────────────────┘ -``` - -## arrayZip {#arrayzip} - -Combines multiple arrays into a single array. The resulting array contains the corresponding elements of the source arrays grouped into tuples in the listed order of arguments. - -**Syntax** - -``` sql -arrayZip(arr1, arr2, ..., arrN) -``` - -**Parameters** - -- `arrN` — [Array](../data_types/array.md). - -The function can take any number of arrays of different types. All the input arrays must be of equal size. - -**Returned value** - -- Array with elements from the source arrays grouped into [tuples](../data_types/tuple.md). Data types in the tuple are the same as types of the input arrays and in the same order as arrays are passed. - -Type: [Array](../data_types/array.md). - -**Example** - -Query: - -``` sql -SELECT arrayZip(['a', 'b', 'c'], [5, 2, 1]) -``` - -Result: - -``` text -┌─arrayZip(['a', 'b', 'c'], [5, 2, 1])─┐ -│ [('a',5),('b',2),('c',1)] │ -└──────────────────────────────────────┘ -``` - - -## arrayAUC {#arrayauc} -Calculate AUC (Area Under the Curve, which is a concept in machine learning, see more details: https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve). - -**Syntax** -```sql -arrayAUC(arr_scores, arr_labels) -``` - -**Parameters** -- `arr_scores` — scores prediction model gives. -- `arr_labels` — labels of samples, usually 1 for positive sample and 0 for negtive sample. - -**Returned value** -Returns AUC value with type Float64. - -**Example** -Query: -```sql -select arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]) -``` - -Result: - -```text -┌─arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1])─┐ -│ 0.75 │ -└────────────────────────────────────────---──┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/en/sql_reference/functions/bit_functions.md b/docs/en/sql_reference/functions/bit_functions.md deleted file mode 100644 index dbed3ac2230..00000000000 --- a/docs/en/sql_reference/functions/bit_functions.md +++ /dev/null @@ -1,252 +0,0 @@ ---- -toc_priority: 48 -toc_title: Bit ---- - -# Bit functions {#bit-functions} - -Bit functions work for any pair of types from UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, or Float64. - -The result type is an integer with bits equal to the maximum bits of its arguments. If at least one of the arguments is signed, the result is a signed number. If an argument is a floating-point number, it is cast to Int64. - -## bitAnd(a, b) {#bitanda-b} - -## bitOr(a, b) {#bitora-b} - -## bitXor(a, b) {#bitxora-b} - -## bitNot(a) {#bitnota} - -## bitShiftLeft(a, b) {#bitshiftlefta-b} - -## bitShiftRight(a, b) {#bitshiftrighta-b} - -## bitRotateLeft(a, b) {#bitrotatelefta-b} - -## bitRotateRight(a, b) {#bitrotaterighta-b} - -## bitTest {#bittest} - -Takes any integer and converts it into [binary form](https://en.wikipedia.org/wiki/Binary_number), returns the value of a bit at specified position. The countdown starts from 0 from the right to the left. - -**Syntax** - -``` sql -SELECT bitTest(number, index) -``` - -**Parameters** - -- `number` – integer number. -- `index` – position of bit. - -**Returned values** - -Returns a value of bit at specified position. - -Type: `UInt8`. - -**Example** - -For example, the number 43 in base-2 (binary) numeral system is 101011. - -Query: - -``` sql -SELECT bitTest(43, 1) -``` - -Result: - -``` text -┌─bitTest(43, 1)─┐ -│ 1 │ -└────────────────┘ -``` - -Another example: - -Query: - -``` sql -SELECT bitTest(43, 2) -``` - -Result: - -``` text -┌─bitTest(43, 2)─┐ -│ 0 │ -└────────────────┘ -``` - -## bitTestAll {#bittestall} - -Returns result of [logical conjuction](https://en.wikipedia.org/wiki/Logical_conjunction) (AND operator) of all bits at given positions. The countdown starts from 0 from the right to the left. - -The conjuction for bitwise operations: - -0 AND 0 = 0 - -0 AND 1 = 0 - -1 AND 0 = 0 - -1 AND 1 = 1 - -**Syntax** - -``` sql -SELECT bitTestAll(number, index1, index2, index3, index4, ...) -``` - -**Parameters** - -- `number` – integer number. -- `index1`, `index2`, `index3`, `index4` – positions of bit. For example, for set of positions (`index1`, `index2`, `index3`, `index4`) is true if and only if all of its positions are true (`index1` ⋀ `index2`, ⋀ `index3` ⋀ `index4`). - -**Returned values** - -Returns result of logical conjuction. - -Type: `UInt8`. - -**Example** - -For example, the number 43 in base-2 (binary) numeral system is 101011. - -Query: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5) -``` - -Result: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5)─┐ -│ 1 │ -└────────────────────────────┘ -``` - -Another example: - -Query: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5, 2) -``` - -Result: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ -│ 0 │ -└───────────────────────────────┘ -``` - -## bitTestAny {#bittestany} - -Returns result of [logical disjunction](https://en.wikipedia.org/wiki/Logical_disjunction) (OR operator) of all bits at given positions. The countdown starts from 0 from the right to the left. - -The disjunction for bitwise operations: - -0 OR 0 = 0 - -0 OR 1 = 1 - -1 OR 0 = 1 - -1 OR 1 = 1 - -**Syntax** - -``` sql -SELECT bitTestAny(number, index1, index2, index3, index4, ...) -``` - -**Parameters** - -- `number` – integer number. -- `index1`, `index2`, `index3`, `index4` – positions of bit. - -**Returned values** - -Returns result of logical disjuction. - -Type: `UInt8`. - -**Example** - -For example, the number 43 in base-2 (binary) numeral system is 101011. - -Query: - -``` sql -SELECT bitTestAny(43, 0, 2) -``` - -Result: - -``` text -┌─bitTestAny(43, 0, 2)─┐ -│ 1 │ -└──────────────────────┘ -``` - -Another example: - -Query: - -``` sql -SELECT bitTestAny(43, 4, 2) -``` - -Result: - -``` text -┌─bitTestAny(43, 4, 2)─┐ -│ 0 │ -└──────────────────────┘ -``` -## bitCount {#bitcount} - -Calculates the number of bits set to one in the binary representation of a number. - -**Syntax** - -```sql -bitCount(x) -``` - -**Parameters** - -- `x` — [Integer](../../sql_reference/data_types/int_uint.md) or [floating-point](../../sql_reference/data_types/float.md) number. The function uses the value representation in memory. It allows supporting floating-point numbers. - -**Returned value** - -- Number of bits set to one in the input number. - -The function doesn't convert input value to a larger type ([sign extension](https://en.wikipedia.org/wiki/Sign_extension)). So, for example, `bitCount(toUInt8(-1)) = 8`. - -Type: `UInt8`. - -**Example** - -Take for example the number 333. Its binary representation: 0000000101001101. - -Query: - -```sql -SELECT bitCount(333) -``` - -Result: - -```text -┌─bitCount(333)─┐ -│ 5 │ -└───────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/en/sql_reference/functions/bitmap_functions.md b/docs/en/sql_reference/functions/bitmap_functions.md deleted file mode 100644 index 8e47fa24034..00000000000 --- a/docs/en/sql_reference/functions/bitmap_functions.md +++ /dev/null @@ -1,494 +0,0 @@ ---- -toc_priority: 49 -toc_title: Bitmap ---- - -# Bitmap functions {#bitmap-functions} - -Bitmap functions work for two bitmaps Object value calculation, it is to return new bitmap or cardinality while using formula calculation, such as and, or, xor, and not, etc. - -There are 2 kinds of construction methods for Bitmap Object. One is to be constructed by aggregation function groupBitmap with -State, the other is to be constructed by Array Object. It is also to convert Bitmap Object to Array Object. - -RoaringBitmap is wrapped into a data structure while actual storage of Bitmap objects. When the cardinality is less than or equal to 32, it uses Set objet. When the cardinality is greater than 32, it uses RoaringBitmap object. That is why storage of low cardinality set is faster. - -For more information on RoaringBitmap, see: [CRoaring](https://github.com/RoaringBitmap/CRoaring). - -## bitmapBuild {#bitmap_functions-bitmapbuild} - -Build a bitmap from unsigned integer array. - -``` sql -bitmapBuild(array) -``` - -**Parameters** - -- `array` – unsigned integer array. - -**Example** - -``` sql -SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) -``` - -``` text -┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ -│  │ AggregateFunction(groupBitmap, UInt8) │ -└─────┴──────────────────────────────────────────────┘ -``` - -## bitmapToArray {#bitmaptoarray} - -Convert bitmap to integer array. - -``` sql -bitmapToArray(bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## bitmapSubsetInRange {#bitmap-functions-bitmapsubsetinrange} - -Return subset in specified range (not include the range\_end). - -``` sql -bitmapSubsetInRange(bitmap, range_start, range_end) -``` - -**Parameters** - -- `bitmap` – [Bitmap object](#bitmap_functions-bitmapbuild). -- `range_start` – range start point. Type: [UInt32](../../sql_reference/data_types/int_uint.md). -- `range_end` – range end point(excluded). Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**Example** - -``` sql -SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -``` text -┌─res───────────────┐ -│ [30,31,32,33,100] │ -└───────────────────┘ -``` - -## bitmapSubsetLimit {#bitmapsubsetlimit} - -Creates a subset of bitmap with n elements taken between `range_start` and `cardinality_limit`. - -**Syntax** - -``` sql -bitmapSubsetLimit(bitmap, range_start, cardinality_limit) -``` - -**Parameters** - -- `bitmap` – [Bitmap object](#bitmap_functions-bitmapbuild). -- `range_start` – The subset starting point. Type: [UInt32](../../sql_reference/data_types/int_uint.md). -- `cardinality_limit` – The subset cardinality upper limit. Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**Returned value** - -The subset. - -Type: `Bitmap object`. - -**Example** - -Query: - -``` sql -SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -Result: - -``` text -┌─res───────────────────────┐ -│ [30,31,32,33,100,200,500] │ -└───────────────────────────┘ -``` - -## bitmapContains {#bitmap_functions-bitmapcontains} - -Checks whether the bitmap contains an element. - -``` sql -bitmapContains(haystack, needle) -``` - -**Parameters** - -- `haystack` – [Bitmap object](#bitmap_functions-bitmapbuild), where the function searches. -- `needle` – Value that the function searches. Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- 0 — If `haystack` doesn’t contain `needle`. -- 1 — If `haystack` contains `needle`. - -Type: `UInt8`. - -**Example** - -``` sql -SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAny {#bitmaphasany} - -Checks whether two bitmaps have intersection by some elements. - -``` sql -bitmapHasAny(bitmap1, bitmap2) -``` - -If you are sure that `bitmap2` contains strictly one element, consider using the [bitmapContains](#bitmap_functions-bitmapcontains) function. It works more efficiently. - -**Parameters** - -- `bitmap*` – bitmap object. - -**Return values** - -- `1`, if `bitmap1` and `bitmap2` have one similar element at least. -- `0`, otherwise. - -**Example** - -``` sql -SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAll {#bitmaphasall} - -Analogous to `hasAll(array, array)` returns 1 if the first bitmap contains all the elements of the second one, 0 otherwise. -If the second argument is an empty bitmap then returns 1. - -``` sql -bitmapHasAll(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 0 │ -└─────┘ -``` - -## bitmapCardinality {#bitmapcardinality} - -Retrun bitmap cardinality of type UInt64. - -``` sql -bitmapCardinality(bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## bitmapMin {#bitmapmin} - -Retrun the smallest value of type UInt64 in the set, UINT32\_MAX if the set is empty. - - bitmapMin(bitmap) - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 1 │ - └─────┘ - -## bitmapMax {#bitmapmax} - -Retrun the greatest value of type UInt64 in the set, 0 if the set is empty. - - bitmapMax(bitmap) - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 5 │ - └─────┘ - -## bitmapTransform {#bitmaptransform} - -Transform an array of values in a bitmap to another array of values, the result is a new bitmap. - - bitmapTransform(bitmap, from_array, to_array) - -**Parameters** - -- `bitmap` – bitmap object. -- `from_array` – UInt32 array. For idx in range \[0, from\_array.size()), if bitmap contains from\_array\[idx\], then replace it with to\_array\[idx\]. Note that the result depends on array ordering if there are common elements between from\_array and to\_array. -- `to_array` – UInt32 array, its size shall be the same to from\_array. - -**Example** - -``` sql -SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res -``` - - ┌─res───────────────────┐ - │ [1,3,4,6,7,8,9,10,20] │ - └───────────────────────┘ - -## bitmapAnd {#bitmapand} - -Two bitmap and calculation, the result is a new bitmap. - -``` sql -bitmapAnd(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─┐ -│ [3] │ -└─────┘ -``` - -## bitmapOr {#bitmapor} - -Two bitmap or calculation, the result is a new bitmap. - -``` sql -bitmapOr(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## bitmapXor {#bitmapxor} - -Two bitmap xor calculation, the result is a new bitmap. - -``` sql -bitmapXor(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,4,5] │ -└───────────┘ -``` - -## bitmapAndnot {#bitmapandnot} - -Two bitmap andnot calculation, the result is a new bitmap. - -``` sql -bitmapAndnot(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## bitmapAndCardinality {#bitmapandcardinality} - -Two bitmap and calculation, return cardinality of type UInt64. - -``` sql -bitmapAndCardinality(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapOrCardinality {#bitmaporcardinality} - -Two bitmap or calculation, return cardinality of type UInt64. - -``` sql -bitmapOrCardinality(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## bitmapXorCardinality {#bitmapxorcardinality} - -Two bitmap xor calculation, return cardinality of type UInt64. - -``` sql -bitmapXorCardinality(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 4 │ -└─────┘ -``` - -## bitmapAndnotCardinality {#bitmapandnotcardinality} - -Two bitmap andnot calculation, return cardinality of type UInt64. - -``` sql -bitmapAndnotCardinality(bitmap,bitmap) -``` - -**Parameters** - -- `bitmap` – bitmap object. - -**Example** - -``` sql -SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 2 │ -└─────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/en/sql_reference/functions/comparison_functions.md b/docs/en/sql_reference/functions/comparison_functions.md deleted file mode 100644 index 368ac447dd1..00000000000 --- a/docs/en/sql_reference/functions/comparison_functions.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -toc_priority: 36 -toc_title: Comparison ---- - -# Comparison functions {#comparison-functions} - -Comparison functions always return 0 or 1 (Uint8). - -The following types can be compared: - -- numbers -- strings and fixed strings -- dates -- dates with times - -within each group, but not between different groups. - -For example, you can’t compare a date with a string. You have to use a function to convert the string to a date, or vice versa. - -Strings are compared by bytes. A shorter string is smaller than all strings that start with it and that contain at least one more character. - -## equals, a = b and a == b operator {#function-equals} - -## notEquals, a ! operator= b and a <> b {#function-notequals} - -## less, < operator {#function-less} - -## greater, > operator {#function-greater} - -## lessOrEquals, <= operator {#function-lessorequals} - -## greaterOrEquals, >= operator {#function-greaterorequals} - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/en/sql_reference/functions/conditional_functions.md b/docs/en/sql_reference/functions/conditional_functions.md deleted file mode 100644 index 0f9f0b78ce4..00000000000 --- a/docs/en/sql_reference/functions/conditional_functions.md +++ /dev/null @@ -1,205 +0,0 @@ ---- -toc_priority: 43 -toc_title: 'Conditional ' ---- - -# Conditional functions {#conditional-functions} - -## if {#if} - -Controls conditional branching. Unlike most systems, ClickHouse always evaluate both expressions `then` and `else`. - -**Syntax** - -``` sql -SELECT if(cond, then, else) -``` - -If the condition `cond` evaluates to a non-zero value, returns the result of the expression `then`, and the result of the expression `else`, if present, is skipped. If the `cond` is zero or `NULL`, then the result of the `then` expression is skipped and the result of the `else` expression, if present, is returned. - -**Parameters** - -- `cond` – The condition for evaluation that can be zero or not. The type is UInt8, Nullable(UInt8) or NULL. -- `then` - The expression to return if condition is met. -- `else` - The expression to return if condition is not met. - -**Returned values** - -The function executes `then` and `else` expressions and returns its result, depending on whether the condition `cond` ended up being zero or not. - -**Example** - -Query: - -``` sql -SELECT if(1, plus(2, 2), plus(2, 6)) -``` - -Result: - -``` text -┌─plus(2, 2)─┐ -│ 4 │ -└────────────┘ -``` - -Query: - -``` sql -SELECT if(0, plus(2, 2), plus(2, 6)) -``` - -Result: - -``` text -┌─plus(2, 6)─┐ -│ 8 │ -└────────────┘ -``` - -- `then` and `else` must have the lowest common type. - -**Example:** - -Take this `LEFT_RIGHT` table: - -``` sql -SELECT * -FROM LEFT_RIGHT - -┌─left─┬─right─┐ -│ ᴺᵁᴸᴸ │ 4 │ -│ 1 │ 3 │ -│ 2 │ 2 │ -│ 3 │ 1 │ -│ 4 │ ᴺᵁᴸᴸ │ -└──────┴───────┘ -``` - -The following query compares `left` and `right` values: - -``` sql -SELECT - left, - right, - if(left < right, 'left is smaller than right', 'right is greater or equal than left') AS is_smaller -FROM LEFT_RIGHT -WHERE isNotNull(left) AND isNotNull(right) - -┌─left─┬─right─┬─is_smaller──────────────────────────┐ -│ 1 │ 3 │ left is smaller than right │ -│ 2 │ 2 │ right is greater or equal than left │ -│ 3 │ 1 │ right is greater or equal than left │ -└──────┴───────┴─────────────────────────────────────┘ -``` - -Note: `NULL` values are not used in this example, check [NULL values in conditionals](#null-values-in-conditionals) section. - -## Ternary Operator {#ternary-operator} - -It works same as `if` function. - -Syntax: `cond ? then : else` - -Returns `then` if the `cond` evaluates to be true (greater than zero), otherwise returns `else`. - -- `cond` must be of type of `UInt8`, and `then` and `else` must have the lowest common type. - -- `then` and `else` can be `NULL` - -**See also** - -- [ifNotFinite](other_functions.md#ifnotfinite). - -## multiIf {#multiif} - -Allows you to write the [CASE](../operators.md#operator_case) operator more compactly in the query. - -Syntax: `multiIf(cond_1, then_1, cond_2, then_2, ..., else)` - -**Parameters:** - -- `cond_N` — The condition for the function to return `then_N`. -- `then_N` — The result of the function when executed. -- `else` — The result of the function if none of the conditions is met. - -The function accepts `2N+1` parameters. - -**Returned values** - -The function returns one of the values `then_N` or `else`, depending on the conditions `cond_N`. - -**Example** - -Again using `LEFT_RIGHT` table. - -``` sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─result──────────┐ -│ ᴺᵁᴸᴸ │ 4 │ Null value │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ left is greater │ -│ 4 │ ᴺᵁᴸᴸ │ Null value │ -└──────┴───────┴─────────────────┘ -``` - -## Using conditional results directly {#using-conditional-results-directly} - -Conditionals always result to `0`, `1` or `NULL`. So you can use conditional results directly like this: - -``` sql -SELECT left < right AS is_small -FROM LEFT_RIGHT - -┌─is_small─┐ -│ ᴺᵁᴸᴸ │ -│ 1 │ -│ 0 │ -│ 0 │ -│ ᴺᵁᴸᴸ │ -└──────────┘ -``` - -## NULL values in conditionals {#null-values-in-conditionals} - -When `NULL` values are involved in conditionals, the result will also be `NULL`. - -``` sql -SELECT - NULL < 1, - 2 < NULL, - NULL < NULL, - NULL = NULL - -┌─less(NULL, 1)─┬─less(2, NULL)─┬─less(NULL, NULL)─┬─equals(NULL, NULL)─┐ -│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└───────────────┴───────────────┴──────────────────┴────────────────────┘ -``` - -So you should construct your queries carefully if the types are `Nullable`. - -The following example demonstrates this by failing to add equals condition to `multiIf`. - -``` sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'right is smaller', 'Both equal') AS faulty_result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─faulty_result────┐ -│ ᴺᵁᴸᴸ │ 4 │ Both equal │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ right is smaller │ -│ 4 │ ᴺᵁᴸᴸ │ Both equal │ -└──────┴───────┴──────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/en/sql_reference/functions/date_time_functions.md b/docs/en/sql_reference/functions/date_time_functions.md deleted file mode 100644 index 3c477665bb7..00000000000 --- a/docs/en/sql_reference/functions/date_time_functions.md +++ /dev/null @@ -1,448 +0,0 @@ ---- -toc_priority: 39 -toc_title: Working with Dates and Times ---- - -# Functions for working with dates and times {#functions-for-working-with-dates-and-times} - -Support for time zones - -All functions for working with the date and time that have a logical use for the time zone can accept a second optional time zone argument. Example: Asia/Yekaterinburg. In this case, they use the specified time zone instead of the local (default) one. - -``` sql -SELECT - toDateTime('2016-06-15 23:00:00') AS time, - toDate(time) AS date_local, - toDate(time, 'Asia/Yekaterinburg') AS date_yekat, - toString(time, 'US/Samoa') AS time_samoa -``` - -``` text -┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ -└─────────────────────┴────────────┴────────────┴─────────────────────┘ -``` - -Only time zones that differ from UTC by a whole number of hours are supported. - -## toTimeZone {#totimezone} - -Convert time or date and time to the specified time zone. - -## toYear {#toyear} - -Converts a date or date with time to a UInt16 number containing the year number (AD). - -## toQuarter {#toquarter} - -Converts a date or date with time to a UInt8 number containing the quarter number. - -## toMonth {#tomonth} - -Converts a date or date with time to a UInt8 number containing the month number (1-12). - -## toDayOfYear {#todayofyear} - -Converts a date or date with time to a UInt16 number containing the number of the day of the year (1-366). - -## toDayOfMonth {#todayofmonth} - -Converts a date or date with time to a UInt8 number containing the number of the day of the month (1-31). - -## toDayOfWeek {#todayofweek} - -Converts a date or date with time to a UInt8 number containing the number of the day of the week (Monday is 1, and Sunday is 7). - -## toHour {#tohour} - -Converts a date with time to a UInt8 number containing the number of the hour in 24-hour time (0-23). -This function assumes that if clocks are moved ahead, it is by one hour and occurs at 2 a.m., and if clocks are moved back, it is by one hour and occurs at 3 a.m. (which is not always true – even in Moscow the clocks were twice changed at a different time). - -## toMinute {#tominute} - -Converts a date with time to a UInt8 number containing the number of the minute of the hour (0-59). - -## toSecond {#tosecond} - -Converts a date with time to a UInt8 number containing the number of the second in the minute (0-59). -Leap seconds are not accounted for. - -## toUnixTimestamp {#to-unix-timestamp} - -For DateTime argument: converts value to its internal numeric representation (Unix Timestamp). -For String argument: parse datetime from string according to the timezone (optional second argument, server timezone is used by default) and returns the corresponding unix timestamp. -For Date argument: the behaviour is unspecified. - -**Syntax** - -``` sql -toUnixTimestamp(datetime) -toUnixTimestamp(str, [timezone]) -``` - -**Returned value** - -- Returns the unix timestamp. - -Type: `UInt32`. - -**Example** - -Query: - -``` sql -SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp -``` - -Result: - -``` text -┌─unix_timestamp─┐ -│ 1509836867 │ -└────────────────┘ -``` - -## toStartOfYear {#tostartofyear} - -Rounds down a date or date with time to the first day of the year. -Returns the date. - -## toStartOfISOYear {#tostartofisoyear} - -Rounds down a date or date with time to the first day of ISO year. -Returns the date. - -## toStartOfQuarter {#tostartofquarter} - -Rounds down a date or date with time to the first day of the quarter. -The first day of the quarter is either 1 January, 1 April, 1 July, or 1 October. -Returns the date. - -## toStartOfMonth {#tostartofmonth} - -Rounds down a date or date with time to the first day of the month. -Returns the date. - -!!! attention "Attention" - The behavior of parsing incorrect dates is implementation specific. ClickHouse may return zero date, throw an exception or do “natural” overflow. - -## toMonday {#tomonday} - -Rounds down a date or date with time to the nearest Monday. -Returns the date. - -## toStartOfWeek(t\[,mode\]) {#tostartofweektmode} - -Rounds down a date or date with time to the nearest Sunday or Monday by mode. -Returns the date. -The mode argument works exactly like the mode argument to toWeek(). For the single-argument syntax, a mode value of 0 is used. - -## toStartOfDay {#tostartofday} - -Rounds down a date with time to the start of the day. - -## toStartOfHour {#tostartofhour} - -Rounds down a date with time to the start of the hour. - -## toStartOfMinute {#tostartofminute} - -Rounds down a date with time to the start of the minute. - -## toStartOfFiveMinute {#tostartoffiveminute} - -Rounds down a date with time to the start of the five-minute interval. - -## toStartOfTenMinutes {#tostartoftenminutes} - -Rounds down a date with time to the start of the ten-minute interval. - -## toStartOfFifteenMinutes {#tostartoffifteenminutes} - -Rounds down the date with time to the start of the fifteen-minute interval. - -## toStartOfInterval(time\_or\_data, INTERVAL x unit \[, time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} - -This is a generalization of other functions named `toStartOf*`. For example, -`toStartOfInterval(t, INTERVAL 1 year)` returns the same as `toStartOfYear(t)`, -`toStartOfInterval(t, INTERVAL 1 month)` returns the same as `toStartOfMonth(t)`, -`toStartOfInterval(t, INTERVAL 1 day)` returns the same as `toStartOfDay(t)`, -`toStartOfInterval(t, INTERVAL 15 minute)` returns the same as `toStartOfFifteenMinutes(t)` etc. - -## toTime {#totime} - -Converts a date with time to a certain fixed date, while preserving the time. - -## toRelativeYearNum {#torelativeyearnum} - -Converts a date with time or date to the number of the year, starting from a certain fixed point in the past. - -## toRelativeQuarterNum {#torelativequarternum} - -Converts a date with time or date to the number of the quarter, starting from a certain fixed point in the past. - -## toRelativeMonthNum {#torelativemonthnum} - -Converts a date with time or date to the number of the month, starting from a certain fixed point in the past. - -## toRelativeWeekNum {#torelativeweeknum} - -Converts a date with time or date to the number of the week, starting from a certain fixed point in the past. - -## toRelativeDayNum {#torelativedaynum} - -Converts a date with time or date to the number of the day, starting from a certain fixed point in the past. - -## toRelativeHourNum {#torelativehournum} - -Converts a date with time or date to the number of the hour, starting from a certain fixed point in the past. - -## toRelativeMinuteNum {#torelativeminutenum} - -Converts a date with time or date to the number of the minute, starting from a certain fixed point in the past. - -## toRelativeSecondNum {#torelativesecondnum} - -Converts a date with time or date to the number of the second, starting from a certain fixed point in the past. - -## toISOYear {#toisoyear} - -Converts a date or date with time to a UInt16 number containing the ISO Year number. - -## toISOWeek {#toisoweek} - -Converts a date or date with time to a UInt8 number containing the ISO Week number. - -## toWeek(date\[,mode\]) {#toweekdatemode} - -This function returns the week number for date or datetime. The two-argument form of toWeek() enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the default mode is 0. -`toISOWeek()`is a compatibility function that is equivalent to `toWeek(date,3)`. -The following table describes how the mode argument works. - -| Mode | First day of week | Range | Week 1 is the first week … | -|----|-------------|-----|-------------------| -| 0 | Sunday | 0-53 | with a Sunday in this year | -| 1 | Monday | 0-53 | with 4 or more days this year | -| 2 | Sunday | 1-53 | with a Sunday in this year | -| 3 | Monday | 1-53 | with 4 or more days this year | -| 4 | Sunday | 0-53 | with 4 or more days this year | -| 5 | Monday | 0-53 | with a Monday in this year | -| 6 | Sunday | 1-53 | with 4 or more days this year | -| 7 | Monday | 1-53 | with a Monday in this year | -| 8 | Sunday | 1-53 | contains January 1 | -| 9 | Monday | 1-53 | contains January 1 | - -For mode values with a meaning of “with 4 or more days this year,” weeks are numbered according to ISO 8601:1988: - -- If the week containing January 1 has 4 or more days in the new year, it is week 1. - -- Otherwise, it is the last week of the previous year, and the next week is week 1. - -For mode values with a meaning of “contains January 1”, the week contains January 1 is week 1. It doesn’t matter how many days in the new year the week contained, even if it contained only one day. - -``` sql -toWeek(date, [, mode][, Timezone]) -``` - -**Parameters** - -- `date` – Date or DateTime. -- `mode` – Optional parameter, Range of values is \[0,9\], default is 0. -- `Timezone` – Optional parameter, it behaves like any other conversion function. - -**Example** - -``` sql -SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9; -``` - -``` text -┌───────date─┬─week0─┬─week1─┬─week9─┐ -│ 2016-12-27 │ 52 │ 52 │ 1 │ -└────────────┴───────┴───────┴───────┘ -``` - -## toYearWeek(date\[,mode\]) {#toyearweekdatemode} - -Returns year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year. - -The mode argument works exactly like the mode argument to toWeek(). For the single-argument syntax, a mode value of 0 is used. - -`toISOYear()`is a compatibility function that is equivalent to `intDiv(toYearWeek(date,3),100)`. - -**Example** - -``` sql -SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9; -``` - -``` text -┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┐ -│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ -└────────────┴───────────┴───────────┴───────────┘ -``` - -## now {#now} - -Accepts zero arguments and returns the current time at one of the moments of request execution. -This function returns a constant, even if the request took a long time to complete. - -## today {#today} - -Accepts zero arguments and returns the current date at one of the moments of request execution. -The same as ‘toDate(now())’. - -## yesterday {#yesterday} - -Accepts zero arguments and returns yesterday’s date at one of the moments of request execution. -The same as ‘today() - 1’. - -## timeSlot {#timeslot} - -Rounds the time to the half hour. -This function is specific to Yandex.Metrica, since half an hour is the minimum amount of time for breaking a session into two sessions if a tracking tag shows a single user’s consecutive pageviews that differ in time by strictly more than this amount. This means that tuples (the tag ID, user ID, and time slot) can be used to search for pageviews that are included in the corresponding session. - -## toYYYYMM {#toyyyymm} - -Converts a date or date with time to a UInt32 number containing the year and month number (YYYY \* 100 + MM). - -## toYYYYMMDD {#toyyyymmdd} - -Converts a date or date with time to a UInt32 number containing the year and month number (YYYY \* 10000 + MM \* 100 + DD). - -## toYYYYMMDDhhmmss {#toyyyymmddhhmmss} - -Converts a date or date with time to a UInt64 number containing the year and month number (YYYY \* 10000000000 + MM \* 100000000 + DD \* 1000000 + hh \* 10000 + mm \* 100 + ss). - -## addYears, addMonths, addWeeks, addDays, addHours, addMinutes, addSeconds, addQuarters {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} - -Function adds a Date/DateTime interval to a Date/DateTime and then return the Date/DateTime. For example: - -``` sql -WITH - toDate('2018-01-01') AS date, - toDateTime('2018-01-01 00:00:00') AS date_time -SELECT - addYears(date, 1) AS add_years_with_date, - addYears(date_time, 1) AS add_years_with_date_time -``` - -``` text -┌─add_years_with_date─┬─add_years_with_date_time─┐ -│ 2019-01-01 │ 2019-01-01 00:00:00 │ -└─────────────────────┴──────────────────────────┘ -``` - -## subtractYears, subtractMonths, subtractWeeks, subtractDays, subtractHours, subtractMinutes, subtractSeconds, subtractQuarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} - -Function subtract a Date/DateTime interval to a Date/DateTime and then return the Date/DateTime. For example: - -``` sql -WITH - toDate('2019-01-01') AS date, - toDateTime('2019-01-01 00:00:00') AS date_time -SELECT - subtractYears(date, 1) AS subtract_years_with_date, - subtractYears(date_time, 1) AS subtract_years_with_date_time -``` - -``` text -┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ -│ 2018-01-01 │ 2018-01-01 00:00:00 │ -└──────────────────────────┴───────────────────────────────┘ -``` - -## dateDiff {#datediff} - -Returns the difference between two Date or DateTime values. - -**Syntax** - -``` sql -dateDiff('unit', startdate, enddate, [timezone]) -``` - -**Parameters** - -- `unit` — Time unit, in which the returned value is expressed. [String](../syntax.md#syntax-string-literal). - - Supported values: - - | unit | - | ---- | - |second | - |minute | - |hour | - |day | - |week | - |month | - |quarter | - |year | - -- `startdate` — The first time value to compare. [Date](../../sql_reference/data_types/date.md) or [DateTime](../../sql_reference/data_types/datetime.md). - -- `enddate` — The second time value to compare. [Date](../../sql_reference/data_types/date.md) or [DateTime](../../sql_reference/data_types/datetime.md). - -- `timezone` — Optional parameter. If specified, it is applied to both `startdate` and `enddate`. If not specified, timezones of `startdate` and `enddate` are used. If they are not the same, the result is unspecified. - -**Returned value** - -Difference between `startdate` and `enddate` expressed in `unit`. - -Type: `int`. - -**Example** - -Query: - -``` sql -SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); -``` - -Result: - -``` text -┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ -│ 25 │ -└────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## timeSlots(StartTime, Duration,\[, Size\]) {#timeslotsstarttime-duration-size} - -For a time interval starting at ‘StartTime’ and continuing for ‘Duration’ seconds, it returns an array of moments in time, consisting of points from this interval rounded down to the ‘Size’ in seconds. ‘Size’ is an optional parameter: a constant UInt32, set to 1800 by default. -For example, `timeSlots(toDateTime('2012-01-01 12:20:00'), 600) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. -This is necessary for searching for pageviews in the corresponding session. - -## formatDateTime(Time, Format\[, Timezone\]) {#formatdatetime} - -Function formats a Time according given Format string. N.B.: Format is a constant expression, e.g. you can not have multiple formats for single result column. - -Supported modifiers for Format: -(“Example” column shows formatting result for time `2018-01-02 22:33:44`) - -| Modifier | Description | Example | -|------|-----------------------------------|--------| -| %C | year divided by 100 and truncated to integer (00-99) | 20 | -| %d | day of the month, zero-padded (01-31) | 02 | -| %D | Short MM/DD/YY date, equivalent to %m/%d/%y | 01/02/18 | -| %e | day of the month, space-padded ( 1-31) | 2 | -| %F | short YYYY-MM-DD date, equivalent to %Y-%m-%d | 2018-01-02 | -| %H | hour in 24h format (00-23) | 22 | -| %I | hour in 12h format (01-12) | 10 | -| %j | day of the year (001-366) | 002 | -| %m | month as a decimal number (01-12) | 01 | -| %M | minute (00-59) | 33 | -| %n | new-line character (‘’) | | -| %p | AM or PM designation | PM | -| %R | 24-hour HH:MM time, equivalent to %H:%M | 22:33 | -| %S | second (00-59) | 44 | -| %t | horizontal-tab character (’) | | -| %T | ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S | 22:33:44 | -| %u | ISO 8601 weekday as number with Monday as 1 (1-7) | 2 | -| %V | ISO 8601 week number (01-53) | 01 | -| %w | weekday as a decimal number with Sunday as 0 (0-6) | 2 | -| %y | Year, last two digits (00-99) | 18 | -| %Y | Year | 2018 | -| %% | a % sign | % | - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/en/sql_reference/functions/encoding_functions.md b/docs/en/sql_reference/functions/encoding_functions.md deleted file mode 100644 index 4802b2786c2..00000000000 --- a/docs/en/sql_reference/functions/encoding_functions.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -toc_priority: 52 -toc_title: Encoding ---- - -# Encoding functions {#encoding-functions} - -## char {#char} - -Returns the string with the length as the number of passed arguments and each byte has the value of corresponding argument. Accepts multiple arguments of numeric types. If the value of argument is out of range of UInt8 data type, it is converted to UInt8 with possible rounding and overflow. - -**Syntax** - -``` sql -char(number_1, [number_2, ..., number_n]); -``` - -**Parameters** - -- `number_1, number_2, ..., number_n` — Numerical arguments interpreted as integers. Types: [Int](../../sql_reference/data_types/int_uint.md), [Float](../../sql_reference/data_types/float.md). - -**Returned value** - -- a string of given bytes. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello -``` - -Result: - -``` text -┌─hello─┐ -│ hello │ -└───────┘ -``` - -You can construct a string of arbitrary encoding by passing the corresponding bytes. Here is example for UTF-8: - -Query: - -``` sql -SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; -``` - -Result: - -``` text -┌─hello──┐ -│ привет │ -└────────┘ -``` - -Query: - -``` sql -SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; -``` - -Result: - -``` text -┌─hello─┐ -│ 你好 │ -└───────┘ -``` - -## hex {#hex} - -Returns a string containing the argument’s hexadecimal representation. - -**Syntax** - -``` sql -hex(arg) -``` - -The function is using uppercase letters `A-F` and not using any prefixes (like `0x`) or suffixes (like `h`). - -For integer arguments, it prints hex digits (“nibbles”) from the most significant to least significant (big endian or “human readable” order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints both digits of every byte even if leading digit is zero. - -Example: - -**Example** - -Query: - -``` sql -SELECT hex(1); -``` - -Result: - -``` text -01 -``` - -Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). - -For `String` and `FixedString`, all bytes are simply encoded as two hexadecimal numbers. Zero bytes are not omitted. - -Values of floating point and Decimal types are encoded as their representation in memory. As we support little endian architecture, they are encoded in little endian. Zero leading/trailing bytes are not omitted. - -**Parameters** - -- `arg` — A value to convert to hexadecimal. Types: [String](../../sql_reference/data_types/string.md), [UInt](../../sql_reference/data_types/int_uint.md), [Float](../../sql_reference/data_types/float.md), [Decimal](../../sql_reference/data_types/decimal.md), [Date](../../sql_reference/data_types/date.md) or [DateTime](../../sql_reference/data_types/datetime.md). - -**Returned value** - -- A string with the hexadecimal representation of the argument. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); -``` - -Result: - -``` text -┌─hex_presentation─┐ -│ 00007041 │ -│ 00008041 │ -└──────────────────┘ -``` - -Query: - -``` sql -SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); -``` - -Result: - -``` text -┌─hex_presentation─┐ -│ 0000000000002E40 │ -│ 0000000000003040 │ -└──────────────────┘ -``` - -## unhex(str) {#unhexstr} - -Accepts a string containing any number of hexadecimal digits, and returns a string containing the corresponding bytes. Supports both uppercase and lowercase letters A-F. The number of hexadecimal digits does not have to be even. If it is odd, the last digit is interpreted as the least significant half of the 00-0F byte. If the argument string contains anything other than hexadecimal digits, some implementation-defined result is returned (an exception isn’t thrown). -If you want to convert the result to a number, you can use the ‘reverse’ and ‘reinterpretAsType’ functions. - -## UUIDStringToNum(str) {#uuidstringtonumstr} - -Accepts a string containing 36 characters in the format `123e4567-e89b-12d3-a456-426655440000`, and returns it as a set of bytes in a FixedString(16). - -## UUIDNumToString(str) {#uuidnumtostringstr} - -Accepts a FixedString(16) value. Returns a string containing 36 characters in text format. - -## bitmaskToList(num) {#bitmasktolistnum} - -Accepts an integer. Returns a string containing the list of powers of two that total the source number when summed. They are comma-separated without spaces in text format, in ascending order. - -## bitmaskToArray(num) {#bitmasktoarraynum} - -Accepts an integer. Returns an array of UInt64 numbers containing the list of powers of two that total the source number when summed. Numbers in the array are in ascending order. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/en/sql_reference/functions/ext_dict_functions.md b/docs/en/sql_reference/functions/ext_dict_functions.md deleted file mode 100644 index fa3b0519c37..00000000000 --- a/docs/en/sql_reference/functions/ext_dict_functions.md +++ /dev/null @@ -1,203 +0,0 @@ ---- -toc_priority: 58 -toc_title: Working with External Dictionaries ---- - -# Functions For Working With External Dictionaries {#ext_dict_functions} - -For information on connecting and configuring external dictionaries, see [External dictionaries](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -## dictGet {#dictget} - -Retrieves a value from an external dictionary. - -``` sql -dictGet('dict_name', 'attr_name', id_expr) -dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**Parameters** - -- `dict_name` — Name of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `attr_name` — Name of the column of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [Expression](../syntax.md#syntax-expressions) returning a [UInt64](../../sql_reference/data_types/int_uint.md) or [Tuple](../../sql_reference/data_types/tuple.md)-type value depending on the dictionary configuration. -- `default_value_expr` — Value returned if the dictionary doesn’t contain a row with the `id_expr` key. [Expression](../syntax.md#syntax-expressions) returning the value in the data type configured for the `attr_name` attribute. - -**Returned value** - -- If ClickHouse parses the attribute successfully in the [attribute’s data type](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes), functions return the value of the dictionary attribute that corresponds to `id_expr`. - -- If there is no the key, corresponding to `id_expr`, in the dictionary, then: - - - `dictGet` returns the content of the `` element specified for the attribute in the dictionary configuration. - - `dictGetOrDefault` returns the value passed as the `default_value_expr` parameter. - -ClickHouse throws an exception if it cannot parse the value of the attribute or the value doesn’t match the attribute data type. - -**Example** - -Create a text file `ext-dict-text.csv` containing the following: - -``` text -1,1 -2,2 -``` - -The first column is `id`, the second column is `c1`. - -Configure the external dictionary: - -``` xml - - - ext-dict-test - - - /path-to/ext-dict-test.csv - CSV - - - - - - - - id - - - c1 - UInt32 - - - - 0 - - -``` - -Perform the query: - -``` sql -SELECT - dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, - toTypeName(val) AS type -FROM system.numbers -LIMIT 3 -``` - -``` text -┌─val─┬─type───┐ -│ 1 │ UInt32 │ -│ 2 │ UInt32 │ -│ 20 │ UInt32 │ -└─────┴────────┘ -``` - -**See Also** - -- [External Dictionaries](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) - -## dictHas {#dicthas} - -Checks whether a key is present in a dictionary. - -``` sql -dictHas('dict_name', id_expr) -``` - -**Parameters** - -- `dict_name` — Name of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [Expression](../syntax.md#syntax-expressions) returning a [UInt64](../../sql_reference/data_types/int_uint.md)-type value. - -**Returned value** - -- 0, if there is no key. -- 1, if there is a key. - -Type: `UInt8`. - -## dictGetHierarchy {#dictgethierarchy} - -Creates an array, containing all the parents of a key in the [hierarchical dictionary](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md). - -**Syntax** - -``` sql -dictGetHierarchy('dict_name', key) -``` - -**Parameters** - -- `dict_name` — Name of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `key` — Key value. [Expression](../syntax.md#syntax-expressions) returning a [UInt64](../../sql_reference/data_types/int_uint.md)-type value. - -**Returned value** - -- Parents for the key. - -Type: [Array(UInt64)](../../sql_reference/data_types/array.md). - -## dictIsIn {#dictisin} - -Checks the ancestor of a key through the whole hierarchical chain in the dictionary. - -``` sql -dictIsIn('dict_name', child_id_expr, ancestor_id_expr) -``` - -**Parameters** - -- `dict_name` — Name of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `child_id_expr` — Key to be checked. [Expression](../syntax.md#syntax-expressions) returning a [UInt64](../../sql_reference/data_types/int_uint.md)-type value. -- `ancestor_id_expr` — Alleged ancestor of the `child_id_expr` key. [Expression](../syntax.md#syntax-expressions) returning a [UInt64](../../sql_reference/data_types/int_uint.md)-type value. - -**Returned value** - -- 0, if `child_id_expr` is not a child of `ancestor_id_expr`. -- 1, if `child_id_expr` is a child of `ancestor_id_expr` or if `child_id_expr` is an `ancestor_id_expr`. - -Type: `UInt8`. - -## Other Functions {#ext_dict_functions-other} - -ClickHouse supports specialized functions that convert dictionary attribute values to a specific data type regardless of the dictionary configuration. - -Functions: - -- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` -- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` -- `dictGetFloat32`, `dictGetFloat64` -- `dictGetDate` -- `dictGetDateTime` -- `dictGetUUID` -- `dictGetString` - -All these functions have the `OrDefault` modification. For example, `dictGetDateOrDefault`. - -Syntax: - -``` sql -dictGet[Type]('dict_name', 'attr_name', id_expr) -dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**Parameters** - -- `dict_name` — Name of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `attr_name` — Name of the column of the dictionary. [String literal](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [Expression](../syntax.md#syntax-expressions) returning a [UInt64](../../sql_reference/data_types/int_uint.md)-type value. -- `default_value_expr` — Value which is returned if the dictionary doesn’t contain a row with the `id_expr` key. [Expression](../syntax.md#syntax-expressions) returning a value in the data type configured for the `attr_name` attribute. - -**Returned value** - -- If ClickHouse parses the attribute successfully in the [attribute’s data type](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes), functions return the value of the dictionary attribute that corresponds to `id_expr`. - -- If there is no requested `id_expr` in the dictionary then: - - - `dictGet[Type]` returns the content of the `` element specified for the attribute in the dictionary configuration. - - `dictGet[Type]OrDefault` returns the value passed as the `default_value_expr` parameter. - -ClickHouse throws an exception if it cannot parse the value of the attribute or the value doesn’t match the attribute data type. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/en/sql_reference/functions/functions_for_nulls.md b/docs/en/sql_reference/functions/functions_for_nulls.md deleted file mode 100644 index 4ea67d1e0b5..00000000000 --- a/docs/en/sql_reference/functions/functions_for_nulls.md +++ /dev/null @@ -1,310 +0,0 @@ ---- -toc_priority: 63 -toc_title: Working with Nullable arguments ---- - -# Functions for working with Nullable aggregates {#functions-for-working-with-nullable-aggregates} - -## isNull {#isnull} - -Checks whether the argument is [NULL](../syntax.md#null). - -``` sql -isNull(x) -``` - -**Parameters** - -- `x` — A value with a non-compound data type. - -**Returned value** - -- `1` if `x` is `NULL`. -- `0` if `x` is not `NULL`. - -**Example** - -Input table - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Query - -``` sql -SELECT x FROM t_null WHERE isNull(y) -``` - -``` text -┌─x─┐ -│ 1 │ -└───┘ -``` - -## isNotNull {#isnotnull} - -Checks whether the argument is [NULL](../syntax.md#null). - -``` sql -isNotNull(x) -``` - -**Parameters:** - -- `x` — A value with a non-compound data type. - -**Returned value** - -- `0` if `x` is `NULL`. -- `1` if `x` is not `NULL`. - -**Example** - -Input table - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Query - -``` sql -SELECT x FROM t_null WHERE isNotNull(y) -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## coalesce {#coalesce} - -Checks from left to right whether `NULL` arguments were passed and returns the first non-`NULL` argument. - -``` sql -coalesce(x,...) -``` - -**Parameters:** - -- Any number of parameters of a non-compound type. All parameters must be compatible by data type. - -**Returned values** - -- The first non-`NULL` argument. -- `NULL`, if all arguments are `NULL`. - -**Example** - -Consider a list of contacts that may specify multiple ways to contact a customer. - -``` text -┌─name─────┬─mail─┬─phone─────┬──icq─┐ -│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ -│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└──────────┴──────┴───────────┴──────┘ -``` - -The `mail` and `phone` fields are of type String, but the `icq` field is `UInt32`, so it needs to be converted to `String`. - -Get the first available contact method for the customer from the contact list: - -``` sql -SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook -``` - -``` text -┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ -│ client 1 │ 123-45-67 │ -│ client 2 │ ᴺᵁᴸᴸ │ -└──────────┴──────────────────────────────────────────────────────┘ -``` - -## ifNull {#ifnull} - -Returns an alternative value if the main argument is `NULL`. - -``` sql -ifNull(x,alt) -``` - -**Parameters:** - -- `x` — The value to check for `NULL`. -- `alt` — The value that the function returns if `x` is `NULL`. - -**Returned values** - -- The value `x`, if `x` is not `NULL`. -- The value `alt`, if `x` is `NULL`. - -**Example** - -``` sql -SELECT ifNull('a', 'b') -``` - -``` text -┌─ifNull('a', 'b')─┐ -│ a │ -└──────────────────┘ -``` - -``` sql -SELECT ifNull(NULL, 'b') -``` - -``` text -┌─ifNull(NULL, 'b')─┐ -│ b │ -└───────────────────┘ -``` - -## nullIf {#nullif} - -Returns `NULL` if the arguments are equal. - -``` sql -nullIf(x, y) -``` - -**Parameters:** - -`x`, `y` — Values for comparison. They must be compatible types, or ClickHouse will generate an exception. - -**Returned values** - -- `NULL`, if the arguments are equal. -- The `x` value, if the arguments are not equal. - -**Example** - -``` sql -SELECT nullIf(1, 1) -``` - -``` text -┌─nullIf(1, 1)─┐ -│ ᴺᵁᴸᴸ │ -└──────────────┘ -``` - -``` sql -SELECT nullIf(1, 2) -``` - -``` text -┌─nullIf(1, 2)─┐ -│ 1 │ -└──────────────┘ -``` - -## assumeNotNull {#assumenotnull} - -Results in a value of type [Nullable](../../sql_reference/data_types/nullable.md) for a non- `Nullable`, if the value is not `NULL`. - -``` sql -assumeNotNull(x) -``` - -**Parameters:** - -- `x` — The original value. - -**Returned values** - -- The original value from the non-`Nullable` type, if it is not `NULL`. -- The default value for the non-`Nullable` type if the original value was `NULL`. - -**Example** - -Consider the `t_null` table. - -``` sql -SHOW CREATE TABLE t_null -``` - -``` text -┌─statement─────────────────────────────────────────────────────────────────┐ -│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ -└───────────────────────────────────────────────────────────────────────────┘ -``` - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Apply the `assumeNotNull` function to the `y` column. - -``` sql -SELECT assumeNotNull(y) FROM t_null -``` - -``` text -┌─assumeNotNull(y)─┐ -│ 0 │ -│ 3 │ -└──────────────────┘ -``` - -``` sql -SELECT toTypeName(assumeNotNull(y)) FROM t_null -``` - -``` text -┌─toTypeName(assumeNotNull(y))─┐ -│ Int8 │ -│ Int8 │ -└──────────────────────────────┘ -``` - -## toNullable {#tonullable} - -Converts the argument type to `Nullable`. - -``` sql -toNullable(x) -``` - -**Parameters:** - -- `x` — The value of any non-compound type. - -**Returned value** - -- The input value with a `Nullable` type. - -**Example** - -``` sql -SELECT toTypeName(10) -``` - -``` text -┌─toTypeName(10)─┐ -│ UInt8 │ -└────────────────┘ -``` - -``` sql -SELECT toTypeName(toNullable(10)) -``` - -``` text -┌─toTypeName(toNullable(10))─┐ -│ Nullable(UInt8) │ -└────────────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/en/sql_reference/functions/geo.md b/docs/en/sql_reference/functions/geo.md deleted file mode 100644 index 7303821d162..00000000000 --- a/docs/en/sql_reference/functions/geo.md +++ /dev/null @@ -1,508 +0,0 @@ ---- -toc_priority: 62 -toc_title: Working with geographical coordinates ---- - -# Functions for Working with Geographical Coordinates {#functions-for-working-with-geographical-coordinates} - -## greatCircleDistance {#greatcircledistance} - -Calculate the distance between two points on the Earth’s surface using [the great-circle formula](https://en.wikipedia.org/wiki/Great-circle_distance). - -``` sql -greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) -``` - -**Input parameters** - -- `lon1Deg` — Longitude of the first point in degrees. Range: `[-180°, 180°]`. -- `lat1Deg` — Latitude of the first point in degrees. Range: `[-90°, 90°]`. -- `lon2Deg` — Longitude of the second point in degrees. Range: `[-180°, 180°]`. -- `lat2Deg` — Latitude of the second point in degrees. Range: `[-90°, 90°]`. - -Positive values correspond to North latitude and East longitude, and negative values correspond to South latitude and West longitude. - -**Returned value** - -The distance between two points on the Earth’s surface, in meters. - -Generates an exception when the input parameter values fall outside of the range. - -**Example** - -``` sql -SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) -``` - -``` text -┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ -│ 14132374.194975413 │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## pointInEllipses {#pointinellipses} - -Checks whether the point belongs to at least one of the ellipses. -Coordinates are geometric in the Cartesian coordinate system. - -``` sql -pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) -``` - -**Input parameters** - -- `x, y` — Coordinates of a point on the plane. -- `xᵢ, yᵢ` — Coordinates of the center of the `i`-th ellipsis. -- `aᵢ, bᵢ` — Axes of the `i`-th ellipsis in units of x, y coordinates. - -The input parameters must be `2+4⋅n`, where `n` is the number of ellipses. - -**Returned values** - -`1` if the point is inside at least one of the ellipses; `0`if it is not. - -**Example** - -``` sql -SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) -``` - -``` text -┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ -│ 1 │ -└─────────────────────────────────────────────────┘ -``` - -## pointInPolygon {#pointinpolygon} - -Checks whether the point belongs to the polygon on the plane. - -``` sql -pointInPolygon((x, y), [(a, b), (c, d) ...], ...) -``` - -**Input values** - -- `(x, y)` — Coordinates of a point on the plane. Data type — [Tuple](../../sql_reference/data_types/tuple.md) — A tuple of two numbers. -- `[(a, b), (c, d) ...]` — Polygon vertices. Data type — [Array](../../sql_reference/data_types/array.md). Each vertex is represented by a pair of coordinates `(a, b)`. Vertices should be specified in a clockwise or counterclockwise order. The minimum number of vertices is 3. The polygon must be constant. -- The function also supports polygons with holes (cut out sections). In this case, add polygons that define the cut out sections using additional arguments of the function. The function does not support non-simply-connected polygons. - -**Returned values** - -`1` if the point is inside the polygon, `0` if it is not. -If the point is on the polygon boundary, the function may return either 0 or 1. - -**Example** - -``` sql -SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## geohashEncode {#geohashencode} - -Encodes latitude and longitude as a geohash-string, please see (http://geohash.org/, https://en.wikipedia.org/wiki/Geohash). - -``` sql -geohashEncode(longitude, latitude, [precision]) -``` - -**Input values** - -- longitude - longitude part of the coordinate you want to encode. Floating in range`[-180°, 180°]` -- latitude - latitude part of the coordinate you want to encode. Floating in range `[-90°, 90°]` -- precision - Optional, length of the resulting encoded string, defaults to `12`. Integer in range `[1, 12]`. Any value less than `1` or greater than `12` is silently converted to `12`. - -**Returned values** - -- alphanumeric `String` of encoded coordinate (modified version of the base32-encoding alphabet is used). - -**Example** - -``` sql -SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res -``` - -``` text -┌─res──────────┐ -│ ezs42d000000 │ -└──────────────┘ -``` - -## geohashDecode {#geohashdecode} - -Decodes any geohash-encoded string into longitude and latitude. - -**Input values** - -- encoded string - geohash-encoded string. - -**Returned values** - -- (longitude, latitude) - 2-tuple of `Float64` values of longitude and latitude. - -**Example** - -``` sql -SELECT geohashDecode('ezs42') AS res -``` - -``` text -┌─res─────────────────────────────┐ -│ (-5.60302734375,42.60498046875) │ -└─────────────────────────────────┘ -``` - -## geoToH3 {#geotoh3} - -Returns [H3](https://uber.github.io/h3/#/documentation/overview/introduction) point index `(lon, lat)` with specified resolution. - -[H3](https://uber.github.io/h3/#/documentation/overview/introduction) is a geographical indexing system where Earth’s surface divided into even hexagonal tiles. This system is hierarchical, i. e. each hexagon on the top level can be splitted into seven even but smaller ones and so on. - -This index is used primarily for bucketing locations and other geospatial manipulations. - -**Syntax** - -``` sql -geoToH3(lon, lat, resolution) -``` - -**Parameters** - -- `lon` — Longitude. Type: [Float64](../../sql_reference/data_types/float.md). -- `lat` — Latitude. Type: [Float64](../../sql_reference/data_types/float.md). -- `resolution` — Index resolution. Range: `[0, 15]`. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Hexagon index number. -- 0 in case of error. - -Type: `UInt64`. - -**Example** - -Query: - -``` sql -SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index -``` - -Result: - -``` text -┌────────────h3Index─┐ -│ 644325524701193974 │ -└────────────────────┘ -``` - -## geohashesInBox {#geohashesinbox} - -Returns an array of geohash-encoded strings of given precision that fall inside and intersect boundaries of given box, basically a 2D grid flattened into array. - -**Input values** - -- longitude\_min - min longitude, floating value in range `[-180°, 180°]` -- latitude\_min - min latitude, floating value in range `[-90°, 90°]` -- longitude\_max - max longitude, floating value in range `[-180°, 180°]` -- latitude\_max - max latitude, floating value in range `[-90°, 90°]` -- precision - geohash precision, `UInt8` in range `[1, 12]` - -Please note that all coordinate parameters should be of the same type: either `Float32` or `Float64`. - -**Returned values** - -- array of precision-long strings of geohash-boxes covering provided area, you should not rely on order of items. -- \[\] - empty array if *min* values of *latitude* and *longitude* aren’t less than corresponding *max* values. - -Please note that function will throw an exception if resulting array is over 10’000’000 items long. - -**Example** - -``` sql -SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos -``` - -``` text -┌─thasos──────────────────────────────────────┐ -│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ -└─────────────────────────────────────────────┘ -``` - -## h3GetBaseCell {#h3getbasecell} - -Returns the base cell number of the index. - -**Syntax** - -``` sql -h3GetBaseCell(index) -``` - -**Parameters** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Hexagon base cell number. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT h3GetBaseCell(612916788725809151) as basecell -``` - -Result: - -``` text -┌─basecell─┐ -│ 12 │ -└──────────┘ -``` - -## h3HexAreaM2 {#h3hexaream2} - -Average hexagon area in square meters at the given resolution. - -**Syntax** - -``` sql -h3HexAreaM2(resolution) -``` - -**Parameters** - -- `resolution` — Index resolution. Range: `[0, 15]`. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Area in m². Type: [Float64](../../sql_reference/data_types/float.md). - -**Example** - -Query: - -``` sql -SELECT h3HexAreaM2(13) as area -``` - -Result: - -``` text -┌─area─┐ -│ 43.9 │ -└──────┘ -``` - -## h3IndexesAreNeighbors {#h3indexesareneighbors} - -Returns whether or not the provided H3Indexes are neighbors. - -**Syntax** - -``` sql -h3IndexesAreNeighbors(index1, index2) -``` - -**Parameters** - -- `index1` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `index2` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Returns `1` if the indexes are neighbors, `0` otherwise. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT h3IndexesAreNeighbors(617420388351344639, 617420388352655359) AS n -``` - -Result: - -``` text -┌─n─┐ -│ 1 │ -└───┘ -``` - -## h3ToChildren {#h3tochildren} - -Returns an array with the child indexes of the given index. - -**Syntax** - -``` sql -h3ToChildren(index, resolution) -``` - -**Parameters** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `resolution` — Index resolution. Range: `[0, 15]`. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Array with the child H3 indexes. Array of type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT h3ToChildren(599405990164561919, 6) AS children -``` - -Result: - -``` text -┌─children───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ [603909588852408319,603909588986626047,603909589120843775,603909589255061503,603909589389279231,603909589523496959,603909589657714687] │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## h3ToParent {#h3toparent} - -Returns the parent (coarser) index containing the given index. - -**Syntax** - -``` sql -h3ToParent(index, resolution) -``` - -**Parameters** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `resolution` — Index resolution. Range: `[0, 15]`. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Parent H3 index. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT h3ToParent(599405990164561919, 3) as parent -``` - -Result: - -``` text -┌─────────────parent─┐ -│ 590398848891879423 │ -└────────────────────┘ -``` - -## h3ToString {#h3tostring} - -Converts the H3Index representation of the index to the string representation. - -``` sql -h3ToString(index) -``` - -**Parameters** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- String representation of the H3 index. Type: [String](../../sql_reference/data_types/string.md). - -**Example** - -Query: - -``` sql -SELECT h3ToString(617420388352917503) as h3_string -``` - -Result: - -``` text -┌─h3_string───────┐ -│ 89184926cdbffff │ -└─────────────────┘ -``` - -## stringToH3 {#stringtoh3} - -Converts the string representation to H3Index (UInt64) representation. - -``` sql -stringToH3(index_str) -``` - -**Parameters** - -- `index_str` — String representation of the H3 index. Type: [String](../../sql_reference/data_types/string.md). - -**Returned values** - -- Hexagon index number. Returns 0 on error. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT stringToH3('89184926cc3ffff') as index -``` - -Result: - -``` text -┌──────────────index─┐ -│ 617420388351344639 │ -└────────────────────┘ -``` - -## h3GetResolution {#h3getresolution} - -Returns the resolution of the index. - -**Syntax** - -``` sql -h3GetResolution(index) -``` - -**Parameters** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Returned values** - -- Index resolution. Range: `[0, 15]`. Type: [UInt8](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT h3GetResolution(617420388352917503) as res -``` - -Result: - -``` text -┌─res─┐ -│ 9 │ -└─────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/en/sql_reference/functions/hash_functions.md b/docs/en/sql_reference/functions/hash_functions.md deleted file mode 100644 index 772c3c92d27..00000000000 --- a/docs/en/sql_reference/functions/hash_functions.md +++ /dev/null @@ -1,483 +0,0 @@ ---- -toc_priority: 50 -toc_title: Hash ---- - -# Hash functions {#hash-functions} - -Hash functions can be used for the deterministic pseudo-random shuffling of elements. - -## halfMD5 {#hash-functions-halfmd5} - -[Interprets](../../sql_reference/functions/type_conversion_functions.md#type_conversion_functions-reinterpretAsString) all the input parameters as strings and calculates the [MD5](https://en.wikipedia.org/wiki/MD5) hash value for each of them. Then combines hashes, takes the first 8 bytes of the hash of the resulting string, and interprets them as `UInt64` in big-endian byte order. - -``` sql -halfMD5(par1, ...) -``` - -The function is relatively slow (5 million short strings per second per processor core). -Consider using the [sipHash64](#hash_functions-siphash64) function instead. - -**Parameters** - -The function takes a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -A [UInt64](../../sql_reference/data_types/int_uint.md) data type hash value. - -**Example** - -``` sql -SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type -``` - -``` text -┌────────halfMD5hash─┬─type───┐ -│ 186182704141653334 │ UInt64 │ -└────────────────────┴────────┘ -``` - -## MD5 {#hash_functions-md5} - -Calculates the MD5 from a string and returns the resulting set of bytes as FixedString(16). -If you don’t need MD5 in particular, but you need a decent cryptographic 128-bit hash, use the ‘sipHash128’ function instead. -If you want to get the same result as output by the md5sum utility, use lower(hex(MD5(s))). - -## sipHash64 {#hash_functions-siphash64} - -Produces a 64-bit [SipHash](https://131002.net/siphash/) hash value. - -``` sql -sipHash64(par1,...) -``` - -This is a cryptographic hash function. It works at least three times faster than the [MD5](#hash_functions-md5) function. - -Function [interprets](../../sql_reference/functions/type_conversion_functions.md#type_conversion_functions-reinterpretAsString) all the input parameters as strings and calculates the hash value for each of them. Then combines hashes by the following algorithm: - -1. After hashing all the input parameters, the function gets the array of hashes. -2. Function takes the first and the second elements and calculates a hash for the array of them. -3. Then the function takes the hash value, calculated at the previous step, and the third element of the initial hash array, and calculates a hash for the array of them. -4. The previous step is repeated for all the remaining elements of the initial hash array. - -**Parameters** - -The function takes a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -A [UInt64](../../sql_reference/data_types/int_uint.md) data type hash value. - -**Example** - -``` sql -SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type -``` - -``` text -┌──────────────SipHash─┬─type───┐ -│ 13726873534472839665 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## sipHash128 {#hash_functions-siphash128} - -Calculates SipHash from a string. -Accepts a String-type argument. Returns FixedString(16). -Differs from sipHash64 in that the final xor-folding state is only done up to 128 bits. - -## cityHash64 {#cityhash64} - -Produces a 64-bit [CityHash](https://github.com/google/cityhash) hash value. - -``` sql -cityHash64(par1,...) -``` - -This is a fast non-cryptographic hash function. It uses the CityHash algorithm for string parameters and implementation-specific fast non-cryptographic hash function for parameters with other data types. The function uses the CityHash combinator to get the final results. - -**Parameters** - -The function takes a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -A [UInt64](../../sql_reference/data_types/int_uint.md) data type hash value. - -**Examples** - -Call example: - -``` sql -SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type -``` - -``` text -┌─────────────CityHash─┬─type───┐ -│ 12072650598913549138 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -The following example shows how to compute the checksum of the entire table with accuracy up to the row order: - -``` sql -SELECT groupBitXor(cityHash64(*)) FROM table -``` - -## intHash32 {#inthash32} - -Calculates a 32-bit hash code from any type of integer. -This is a relatively fast non-cryptographic hash function of average quality for numbers. - -## intHash64 {#inthash64} - -Calculates a 64-bit hash code from any type of integer. -It works faster than intHash32. Average quality. - -## SHA1 {#sha1} - -## SHA224 {#sha224} - -## SHA256 {#sha256} - -Calculates SHA-1, SHA-224, or SHA-256 from a string and returns the resulting set of bytes as FixedString(20), FixedString(28), or FixedString(32). -The function works fairly slowly (SHA-1 processes about 5 million short strings per second per processor core, while SHA-224 and SHA-256 process about 2.2 million). -We recommend using this function only in cases when you need a specific hash function and you can’t select it. -Even in these cases, we recommend applying the function offline and pre-calculating values when inserting them into the table, instead of applying it in SELECTS. - -## URLHash(url\[, N\]) {#urlhashurl-n} - -A fast, decent-quality non-cryptographic hash function for a string obtained from a URL using some type of normalization. -`URLHash(s)` – Calculates a hash from a string without one of the trailing symbols `/`,`?` or `#` at the end, if present. -`URLHash(s, N)` – Calculates a hash from a string up to the N level in the URL hierarchy, without one of the trailing symbols `/`,`?` or `#` at the end, if present. -Levels are the same as in URLHierarchy. This function is specific to Yandex.Metrica. - -## farmHash64 {#farmhash64} - -Produces a 64-bit [FarmHash](https://github.com/google/farmhash) hash value. - -``` sql -farmHash64(par1, ...) -``` - -The function uses the `Hash64` method from all [available methods](https://github.com/google/farmhash/blob/master/src/farmhash.h). - -**Parameters** - -The function takes a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -A [UInt64](../../sql_reference/data_types/int_uint.md) data type hash value. - -**Example** - -``` sql -SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type -``` - -``` text -┌─────────────FarmHash─┬─type───┐ -│ 17790458267262532859 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## javaHash {#hash_functions-javahash} - -Calculates [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) from a string. This hash function is neither fast nor having a good quality. The only reason to use it is when this algorithm is already used in another system and you have to calculate exactly the same result. - -**Syntax** - -``` sql -SELECT javaHash(''); -``` - -**Returned value** - -A `Int32` data type hash value. - -**Example** - -Query: - -``` sql -SELECT javaHash('Hello, world!'); -``` - -Result: - -``` text -┌─javaHash('Hello, world!')─┐ -│ -1880044555 │ -└───────────────────────────┘ -``` - -## javaHashUTF16LE {#javahashutf16le} - -Calculates [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) from a string, assuming it contains bytes representing a string in UTF-16LE encoding. - -**Syntax** - -``` sql -javaHashUTF16LE(stringUtf16le) -``` - -**Parameters** - -- `stringUtf16le` — a string in UTF-16LE encoding. - -**Returned value** - -A `Int32` data type hash value. - -**Example** - -Correct query with UTF-16LE encoded string. - -Query: - -``` sql -SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) -``` - -Result: - -``` text -┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ -│ 3556498 │ -└──────────────────────────────────────────────────────────────┘ -``` - -## hiveHash {#hash-functions-hivehash} - -Calculates `HiveHash` from a string. - -``` sql -SELECT hiveHash(''); -``` - -This is just [JavaHash](#hash_functions-javahash) with zeroed out sign bit. This function is used in [Apache Hive](https://en.wikipedia.org/wiki/Apache_Hive) for versions before 3.0. This hash function is neither fast nor having a good quality. The only reason to use it is when this algorithm is already used in another system and you have to calculate exactly the same result. - -**Returned value** - -A `Int32` data type hash value. - -Type: `hiveHash`. - -**Example** - -Query: - -``` sql -SELECT hiveHash('Hello, world!'); -``` - -Result: - -``` text -┌─hiveHash('Hello, world!')─┐ -│ 267439093 │ -└───────────────────────────┘ -``` - -## metroHash64 {#metrohash64} - -Produces a 64-bit [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/) hash value. - -``` sql -metroHash64(par1, ...) -``` - -**Parameters** - -The function takes a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -A [UInt64](../../sql_reference/data_types/int_uint.md) data type hash value. - -**Example** - -``` sql -SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type -``` - -``` text -┌────────────MetroHash─┬─type───┐ -│ 14235658766382344533 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## jumpConsistentHash {#jumpconsistenthash} - -Calculates JumpConsistentHash form a UInt64. -Accepts two arguments: a UInt64-type key and the number of buckets. Returns Int32. -For more information, see the link: [JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) - -## murmurHash2\_32, murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} - -Produces a [MurmurHash2](https://github.com/aappleby/smhasher) hash value. - -``` sql -murmurHash2_32(par1, ...) -murmurHash2_64(par1, ...) -``` - -**Parameters** - -Both functions take a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -- The `murmurHash2_32` function returns hash value having the [UInt32](../../sql_reference/data_types/int_uint.md) data type. -- The `murmurHash2_64` function returns hash value having the [UInt64](../../sql_reference/data_types/int_uint.md) data type. - -**Example** - -``` sql -SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type -``` - -``` text -┌──────────MurmurHash2─┬─type───┐ -│ 11832096901709403633 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## gccMurmurHash {#gccmurmurhash} - -Calculates a 64-bit [MurmurHash2](https://github.com/aappleby/smhasher) hash value using the same hash seed as [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191). It is portable between CLang and GCC builds. - -**Syntax** - -```sql -gccMurmurHash(par1, ...); -``` - -**Parameters** - -- `par1, ...` — A variable number of parameters that can be any of the [supported data types](../../sql_reference/data_types/index.md#data_types). - -**Returned value** - -- Calculated hash value. - -Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -```sql -SELECT - gccMurmurHash(1, 2, 3) AS res1, - gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 -``` - -Result: - -``` text -┌─────────────────res1─┬────────────────res2─┐ -│ 12384823029245979431 │ 1188926775431157506 │ -└──────────────────────┴─────────────────────┘ -``` - -## murmurHash3\_32, murmurHash3\_64 {#murmurhash3-32-murmurhash3-64} - -Produces a [MurmurHash3](https://github.com/aappleby/smhasher) hash value. - -``` sql -murmurHash3_32(par1, ...) -murmurHash3_64(par1, ...) -``` - -**Parameters** - -Both functions take a variable number of input parameters. Parameters can be any of the [supported data types](../../sql_reference/data_types/index.md). - -**Returned Value** - -- The `murmurHash3_32` function returns a [UInt32](../../sql_reference/data_types/int_uint.md) data type hash value. -- The `murmurHash3_64` function returns a [UInt64](../../sql_reference/data_types/int_uint.md) data type hash value. - -**Example** - -``` sql -SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3─┬─type───┐ -│ 2152717 │ UInt32 │ -└─────────────┴────────┘ -``` - -## murmurHash3\_128 {#murmurhash3-128} - -Produces a 128-bit [MurmurHash3](https://github.com/aappleby/smhasher) hash value. - -``` sql -murmurHash3_128( expr ) -``` - -**Parameters** - -- `expr` — [Expressions](../syntax.md#syntax-expressions) returning a [String](../../sql_reference/data_types/string.md)-type value. - -**Returned Value** - -A [FixedString(16)](../../sql_reference/data_types/fixedstring.md) data type hash value. - -**Example** - -``` sql -SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3──────┬─type────────────┐ -│ 6�1�4"S5KT�~~q │ FixedString(16) │ -└──────────────────┴─────────────────┘ -``` - -## xxHash32, xxHash64 {#hash-functions-xxhash32} - -Calculates `xxHash` from a string. It is proposed in two flavors, 32 and 64 bits. - -``` sql -SELECT xxHash32(''); - -OR - -SELECT xxHash64(''); -``` - -**Returned value** - -A `Uint32` or `Uint64` data type hash value. - -Type: `xxHash`. - -**Example** - -Query: - -``` sql -SELECT xxHash32('Hello, world!'); -``` - -Result: - -``` text -┌─xxHash32('Hello, world!')─┐ -│ 834093149 │ -└───────────────────────────┘ -``` - -**See Also** - -- [xxHash](http://cyan4973.github.io/xxHash/). - - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/en/sql_reference/functions/higher_order_functions.md b/docs/en/sql_reference/functions/higher_order_functions.md deleted file mode 100644 index 99d2d8ea885..00000000000 --- a/docs/en/sql_reference/functions/higher_order_functions.md +++ /dev/null @@ -1,262 +0,0 @@ ---- -toc_priority: 57 -toc_title: Higher-Order ---- - -# Higher-order functions {#higher-order-functions} - -## `->` operator, lambda(params, expr) function {#operator-lambdaparams-expr-function} - -Allows describing a lambda function for passing to a higher-order function. The left side of the arrow has a formal parameter, which is any ID, or multiple formal parameters – any IDs in a tuple. The right side of the arrow has an expression that can use these formal parameters, as well as any table columns. - -Examples: `x -> 2 * x, str -> str != Referer.` - -Higher-order functions can only accept lambda functions as their functional argument. - -A lambda function that accepts multiple arguments can be passed to a higher-order function. In this case, the higher-order function is passed several arrays of identical length that these arguments will correspond to. - -For some functions, such as [arrayCount](#higher_order_functions-array-count) or [arraySum](#higher_order_functions-array-count), the first argument (the lambda function) can be omitted. In this case, identical mapping is assumed. - -A lambda function can’t be omitted for the following functions: - -- [arrayMap](#higher_order_functions-array-map) -- [arrayFilter](#higher_order_functions-array-filter) -- [arrayFill](#higher_order_functions-array-fill) -- [arrayReverseFill](#higher_order_functions-array-reverse-fill) -- [arraySplit](#higher_order_functions-array-split) -- [arrayReverseSplit](#higher_order_functions-array-reverse-split) -- [arrayFirst](#higher_order_functions-array-first) -- [arrayFirstIndex](#higher_order_functions-array-first-index) - -### arrayMap(func, arr1, …) {#higher_order_functions-array-map} - -Returns an array obtained from the original application of the `func` function to each element in the `arr` array. - -Examples: - -``` sql -SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,4,5] │ -└─────────┘ -``` - -The following example shows how to create a tuple of elements from different arrays: - -``` sql -SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res -``` - -``` text -┌─res─────────────────┐ -│ [(1,4),(2,5),(3,6)] │ -└─────────────────────┘ -``` - -Note that the first argument (lambda function) can’t be omitted in the `arrayMap` function. - -### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} - -Returns an array containing only the elements in `arr1` for which `func` returns something other than 0. - -Examples: - -``` sql -SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res -``` - -``` text -┌─res───────────┐ -│ ['abc World'] │ -└───────────────┘ -``` - -``` sql -SELECT - arrayFilter( - (i, x) -> x LIKE '%World%', - arrayEnumerate(arr), - ['Hello', 'abc World'] AS arr) - AS res -``` - -``` text -┌─res─┐ -│ [2] │ -└─────┘ -``` - -Note that the first argument (lambda function) can’t be omitted in the `arrayFilter` function. - -### arrayFill(func, arr1, …) {#higher_order_functions-array-fill} - -Scan through `arr1` from the first element to the last element and replace `arr1[i]` by `arr1[i - 1]` if `func` returns 0. The first element of `arr1` will not be replaced. - -Examples: - -``` sql -SELECT arrayFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res -``` - -``` text -┌─res──────────────────────────────┐ -│ [1,1,3,11,12,12,12,5,6,14,14,14] │ -└──────────────────────────────────┘ -``` - -Note that the first argument (lambda function) can’t be omitted in the `arrayFill` function. - -### arrayReverseFill(func, arr1, …) {#higher_order_functions-array-reverse-fill} - -Scan through `arr1` from the last element to the first element and replace `arr1[i]` by `arr1[i + 1]` if `func` returns 0. The last element of `arr1` will not be replaced. - -Examples: - -``` sql -SELECT arrayReverseFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res -``` - -``` text -┌─res────────────────────────────────┐ -│ [1,3,3,11,12,5,5,5,6,14,NULL,NULL] │ -└────────────────────────────────────┘ -``` - -Note that the first argument (lambda function) can’t be omitted in the `arrayReverseFill` function. - -### arraySplit(func, arr1, …) {#higher_order_functions-array-split} - -Split `arr1` into multiple arrays. When `func` returns something other than 0, the array will be split on the left hand side of the element. The array will not be split before the first element. - -Examples: - -``` sql -SELECT arraySplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res -``` - -``` text -┌─res─────────────┐ -│ [[1,2,3],[4,5]] │ -└─────────────────┘ -``` - -Note that the first argument (lambda function) can’t be omitted in the `arraySplit` function. - -### arrayReverseSplit(func, arr1, …) {#higher_order_functions-array-reverse-split} - -Split `arr1` into multiple arrays. When `func` returns something other than 0, the array will be split on the right hand side of the element. The array will not be split after the last element. - -Examples: - -``` sql -SELECT arrayReverseSplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res -``` - -``` text -┌─res───────────────┐ -│ [[1],[2,3,4],[5]] │ -└───────────────────┘ -``` - -Note that the first argument (lambda function) can’t be omitted in the `arraySplit` function. - -### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} - -Returns the number of elements in the arr array for which func returns something other than 0. If ‘func’ is not specified, it returns the number of non-zero elements in the array. - -### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} - -Returns 1 if there is at least one element in ‘arr’ for which ‘func’ returns something other than 0. Otherwise, it returns 0. - -### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} - -Returns 1 if ‘func’ returns something other than 0 for all the elements in ‘arr’. Otherwise, it returns 0. - -### arraySum(\[func,\] arr1, …) {#higher-order-functions-array-sum} - -Returns the sum of the ‘func’ values. If the function is omitted, it just returns the sum of the array elements. - -### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} - -Returns the first element in the ‘arr1’ array for which ‘func’ returns something other than 0. - -Note that the first argument (lambda function) can’t be omitted in the `arrayFirst` function. - -### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} - -Returns the index of the first element in the ‘arr1’ array for which ‘func’ returns something other than 0. - -Note that the first argument (lambda function) can’t be omitted in the `arrayFirstIndex` function. - -### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} - -Returns an array of partial sums of elements in the source array (a running sum). If the `func` function is specified, then the values of the array elements are converted by this function before summing. - -Example: - -``` sql -SELECT arrayCumSum([1, 1, 1, 1]) AS res -``` - -``` text -┌─res──────────┐ -│ [1, 2, 3, 4] │ -└──────────────┘ -``` - -### arrayCumSumNonNegative(arr) {#arraycumsumnonnegativearr} - -Same as `arrayCumSum`, returns an array of partial sums of elements in the source array (a running sum). Different `arrayCumSum`, when then returned value contains a value less than zero, the value is replace with zero and the subsequent calculation is performed with zero parameters. For example: - -``` sql -SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,0,1] │ -└───────────┘ -``` - -### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} - -Returns an array as result of sorting the elements of `arr1` in ascending order. If the `func` function is specified, sorting order is determined by the result of the function `func` applied to the elements of array (arrays) - -The [Schwartzian transform](https://en.wikipedia.org/wiki/Schwartzian_transform) is used to improve sorting efficiency. - -Example: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -For more information about the `arraySort` method, see the [Functions for Working With Arrays](array_functions.md#array_functions-sort) section. - -### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} - -Returns an array as result of sorting the elements of `arr1` in descending order. If the `func` function is specified, sorting order is determined by the result of the function `func` applied to the elements of array (arrays). - -Example: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -For more information about the `arrayReverseSort` method, see the [Functions for Working With Arrays](array_functions.md#array_functions-reverse-sort) section. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/en/sql_reference/functions/in_functions.md b/docs/en/sql_reference/functions/in_functions.md deleted file mode 100644 index b8ff809b276..00000000000 --- a/docs/en/sql_reference/functions/in_functions.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -toc_priority: 60 -toc_title: Implementing the IN Operator ---- - -# Functions For Implementing the IN Operator {#functions-for-implementing-the-in-operator} - -## in, notIn, globalIn, globalNotIn {#in-functions} - -See the section [IN operators](../statements/select.md#select-in-operators). - -## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} - -A function that allows grouping multiple columns. -For columns with the types T1, T2, …, it returns a Tuple(T1, T2, …) type tuple containing these columns. There is no cost to execute the function. -Tuples are normally used as intermediate values for an argument of IN operators, or for creating a list of formal parameters of lambda functions. Tuples can’t be written to a table. - -## tupleElement(tuple, n), operator x.N {#tupleelementtuple-n-operator-x-n} - -A function that allows getting a column from a tuple. -‘N’ is the column index, starting from 1. N must be a constant. ‘N’ must be a constant. ‘N’ must be a strict postive integer no greater than the size of the tuple. -There is no cost to execute the function. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/en/sql_reference/functions/index.md b/docs/en/sql_reference/functions/index.md deleted file mode 100644 index a69c1ec1848..00000000000 --- a/docs/en/sql_reference/functions/index.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -toc_folder_title: Functions -toc_priority: 32 -toc_title: Introduction ---- - -# Functions {#functions} - -There are at least\* two types of functions - regular functions (they are just called “functions”) and aggregate functions. These are completely different concepts. Regular functions work as if they are applied to each row separately (for each row, the result of the function doesn’t depend on the other rows). Aggregate functions accumulate a set of values from various rows (i.e. they depend on the entire set of rows). - -In this section we discuss regular functions. For aggregate functions, see the section “Aggregate functions”. - -\* - There is a third type of function that the ‘arrayJoin’ function belongs to; table functions can also be mentioned separately.\* - -## Strong typing {#strong-typing} - -In contrast to standard SQL, ClickHouse has strong typing. In other words, it doesn’t make implicit conversions between types. Each function works for a specific set of types. This means that sometimes you need to use type conversion functions. - -## Common subexpression elimination {#common-subexpression-elimination} - -All expressions in a query that have the same AST (the same record or same result of syntactic parsing) are considered to have identical values. Such expressions are concatenated and executed once. Identical subqueries are also eliminated this way. - -## Types of results {#types-of-results} - -All functions return a single return as the result (not several values, and not zero values). The type of result is usually defined only by the types of arguments, not by the values. Exceptions are the tupleElement function (the a.N operator), and the toFixedString function. - -## Constants {#constants} - -For simplicity, certain functions can only work with constants for some arguments. For example, the right argument of the LIKE operator must be a constant. -Almost all functions return a constant for constant arguments. The exception is functions that generate random numbers. -The ‘now’ function returns different values for queries that were run at different times, but the result is considered a constant, since constancy is only important within a single query. -A constant expression is also considered a constant (for example, the right half of the LIKE operator can be constructed from multiple constants). - -Functions can be implemented in different ways for constant and non-constant arguments (different code is executed). But the results for a constant and for a true column containing only the same value should match each other. - -## NULL processing {#null-processing} - -Functions have the following behaviors: - -- If at least one of the arguments of the function is `NULL`, the function result is also `NULL`. -- Special behavior that is specified individually in the description of each function. In the ClickHouse source code, these functions have `UseDefaultImplementationForNulls=false`. - -## Constancy {#constancy} - -Functions can’t change the values of their arguments – any changes are returned as the result. Thus, the result of calculating separate functions does not depend on the order in which the functions are written in the query. - -## Error handling {#error-handling} - -Some functions might throw an exception if the data is invalid. In this case, the query is canceled and an error text is returned to the client. For distributed processing, when an exception occurs on one of the servers, the other servers also attempt to abort the query. - -## Evaluation of argument expressions {#evaluation-of-argument-expressions} - -In almost all programming languages, one of the arguments might not be evaluated for certain operators. This is usually the operators `&&`, `||`, and `?:`. -But in ClickHouse, arguments of functions (operators) are always evaluated. This is because entire parts of columns are evaluated at once, instead of calculating each row separately. - -## Performing functions for distributed query processing {#performing-functions-for-distributed-query-processing} - -For distributed query processing, as many stages of query processing as possible are performed on remote servers, and the rest of the stages (merging intermediate results and everything after that) are performed on the requestor server. - -This means that functions can be performed on different servers. -For example, in the query `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` - -- if a `distributed_table` has at least two shards, the functions ‘g’ and ‘h’ are performed on remote servers, and the function ‘f’ is performed on the requestor server. -- if a `distributed_table` has only one shard, all the ‘f’, ‘g’, and ‘h’ functions are performed on this shard’s server. - -The result of a function usually doesn’t depend on which server it is performed on. However, sometimes this is important. -For example, functions that work with dictionaries use the dictionary that exists on the server they are running on. -Another example is the `hostName` function, which returns the name of the server it is running on in order to make `GROUP BY` by servers in a `SELECT` query. - -If a function in a query is performed on the requestor server, but you need to perform it on remote servers, you can wrap it in an ‘any’ aggregate function or add it to a key in `GROUP BY`. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/en/sql_reference/functions/introspection.md b/docs/en/sql_reference/functions/introspection.md deleted file mode 100644 index ae237fa8e11..00000000000 --- a/docs/en/sql_reference/functions/introspection.md +++ /dev/null @@ -1,308 +0,0 @@ ---- -toc_priority: 65 -toc_title: Introspection ---- - -# Introspection Functions {#introspection-functions} - -You can use functions described in this chapter to introspect [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) and [DWARF](https://en.wikipedia.org/wiki/DWARF) for query profiling. - -!!! warning "Warning" - These functions are slow and may impose security considerations. - -For proper operation of introspection functions: - -- Install the `clickhouse-common-static-dbg` package. - -- Set the [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) setting to 1. - - For security reasons introspection functions are disabled by default. - -ClickHouse saves profiler reports to the [trace\_log](../../operations/system_tables.md#system_tables-trace_log) system table. Make sure the table and profiler are configured properly. - -## addressToLine {#addresstoline} - -Converts virtual memory address inside ClickHouse server process to the filename and the line number in ClickHouse source code. - -If you use official ClickHouse packages, you need to install the `clickhouse-common-static-dbg` package. - -**Syntax** - -``` sql -addressToLine(address_of_binary_instruction) -``` - -**Parameters** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**Returned value** - -- Source code filename and the line number in this file delimited by colon. - - For example, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, where `199` is a line number. - -- Name of a binary, if the function couldn’t find the debug information. - -- Empty string, if the address is not valid. - -Type: [String](../../sql_reference/data_types/string.md). - -**Example** - -Enabling introspection functions: - -``` sql -SET allow_introspection_functions=1 -``` - -Selecting the first string from the `trace_log` system table: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-19 -event_time: 2019-11-19 18:57:23 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 421b6855-1858-45a5-8f37-f383409d6d72 -trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] -``` - -The `trace` field contains the stack trace at the moment of sampling. - -Getting the source code filename and the line number for a single address: - -``` sql -SELECT addressToLine(94784076370703) \G -``` - -``` text -Row 1: -────── -addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -``` - -Applying the function to the whole stack trace: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines -FROM system.trace_log -LIMIT 1 -\G -``` - -The [arrayMap](higher_order_functions.md#higher_order_functions-array-map) function allows to process each individual element of the `trace` array by the `addressToLine` function. The result of this processing you see in the `trace_source_code_lines` column of output. - -``` text -Row 1: -────── -trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so -/usr/lib/debug/usr/bin/clickhouse -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 -/usr/include/c++/9/bits/atomic_base.h:551 -/usr/lib/debug/usr/bin/clickhouse -/lib/x86_64-linux-gnu/libpthread-2.27.so -/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -``` - -## addressToSymbol {#addresstosymbol} - -Converts virtual memory address inside ClickHouse server process to the symbol from ClickHouse object files. - -**Syntax** - -``` sql -addressToSymbol(address_of_binary_instruction) -``` - -**Parameters** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**Returned value** - -- Symbol from ClickHouse object files. -- Empty string, if the address is not valid. - -Type: [String](../../sql_reference/data_types/string.md). - -**Example** - -Enabling introspection functions: - -``` sql -SET allow_introspection_functions=1 -``` - -Selecting the first string from the `trace_log` system table: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -The `trace` field contains the stack trace at the moment of sampling. - -Getting a symbol for a single address: - -``` sql -SELECT addressToSymbol(94138803686098) \G -``` - -``` text -Row 1: -────── -addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -``` - -Applying the function to the whole stack trace: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols -FROM system.trace_log -LIMIT 1 -\G -``` - -The [arrayMap](higher_order_functions.md#higher_order_functions-array-map) function allows to process each individual element of the `trace` array by the `addressToSymbols` function. The result of this processing you see in the `trace_symbols` column of output. - -``` text -Row 1: -────── -trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE -_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb -_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb -_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE -_ZN2DB27AggregatingBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB28AsynchronousBlockInputStream9calculateEv -_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data -_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E -_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv -_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E -execute_native_thread_routine -start_thread -clone -``` - -## demangle {#demangle} - -Converts a symbol that you can get using the [addressToSymbol](#addresstosymbol) function to the C++ function name. - -**Syntax** - -``` sql -demangle(symbol) -``` - -**Parameters** - -- `symbol` ([String](../../sql_reference/data_types/string.md)) — Symbol from an object file. - -**Returned value** - -- Name of the C++ function. -- Empty string if a symbol is not valid. - -Type: [String](../../sql_reference/data_types/string.md). - -**Example** - -Enabling introspection functions: - -``` sql -SET allow_introspection_functions=1 -``` - -Selecting the first string from the `trace_log` system table: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -The `trace` field contains the stack trace at the moment of sampling. - -Getting a function name for a single address: - -``` sql -SELECT demangle(addressToSymbol(94138803686098)) \G -``` - -``` text -Row 1: -────── -demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -``` - -Applying the function to the whole stack trace: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions -FROM system.trace_log -LIMIT 1 -\G -``` - -The [arrayMap](higher_order_functions.md#higher_order_functions-array-map) function allows to process each individual element of the `trace` array by the `demangle` function. The result of this processing you see in the `trace_functions` column of output. - -``` text -Row 1: -────── -trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const -DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) -DB::AggregatingBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::AsynchronousBlockInputStream::calculate() -std::_Function_handler::_M_invoke(std::_Any_data const&) -ThreadPoolImpl::worker(std::_List_iterator) -ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const -ThreadPoolImpl::worker(std::_List_iterator) -execute_native_thread_routine -start_thread -clone -``` diff --git a/docs/en/sql_reference/functions/ip_address_functions.md b/docs/en/sql_reference/functions/ip_address_functions.md deleted file mode 100644 index e412197d9ac..00000000000 --- a/docs/en/sql_reference/functions/ip_address_functions.md +++ /dev/null @@ -1,246 +0,0 @@ ---- -toc_priority: 55 -toc_title: Working with IP Addresses ---- - -# Functions for working with IP addresses {#functions-for-working-with-ip-addresses} - -## IPv4NumToString(num) {#ipv4numtostringnum} - -Takes a UInt32 number. Interprets it as an IPv4 address in big endian. Returns a string containing the corresponding IPv4 address in the format A.B.C.d (dot-separated numbers in decimal form). - -## IPv4StringToNum(s) {#ipv4stringtonums} - -The reverse function of IPv4NumToString. If the IPv4 address has an invalid format, it returns 0. - -## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} - -Similar to IPv4NumToString, but using xxx instead of the last octet. - -Example: - -``` sql -SELECT - IPv4NumToStringClassC(ClientIP) AS k, - count() AS c -FROM test.hits -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─k──────────────┬─────c─┐ -│ 83.149.9.xxx │ 26238 │ -│ 217.118.81.xxx │ 26074 │ -│ 213.87.129.xxx │ 25481 │ -│ 83.149.8.xxx │ 24984 │ -│ 217.118.83.xxx │ 22797 │ -│ 78.25.120.xxx │ 22354 │ -│ 213.87.131.xxx │ 21285 │ -│ 78.25.121.xxx │ 20887 │ -│ 188.162.65.xxx │ 19694 │ -│ 83.149.48.xxx │ 17406 │ -└────────────────┴───────┘ -``` - -Since using ‘xxx’ is highly unusual, this may be changed in the future. We recommend that you don’t rely on the exact format of this fragment. - -### IPv6NumToString(x) {#ipv6numtostringx} - -Accepts a FixedString(16) value containing the IPv6 address in binary format. Returns a string containing this address in text format. -IPv6-mapped IPv4 addresses are output in the format ::ffff:111.222.33.44. Examples: - -``` sql -SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr -``` - -``` text -┌─addr─────────┐ -│ 2a02:6b8::11 │ -└──────────────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ -│ 2a02:2168:aaa:bbbb::2 │ 24695 │ -│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ -│ 2a02:6b8:0:fff::ff │ 16389 │ -│ 2a01:4f8:111:6666::2 │ 16016 │ -│ 2a02:2168:888:222::1 │ 15896 │ -│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ -│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ -│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ -│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ -│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ -└─────────────────────────────────────────┴───────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)─┬──────c─┐ -│ ::ffff:94.26.111.111 │ 747440 │ -│ ::ffff:37.143.222.4 │ 529483 │ -│ ::ffff:5.166.111.99 │ 317707 │ -│ ::ffff:46.38.11.77 │ 263086 │ -│ ::ffff:79.105.111.111 │ 186611 │ -│ ::ffff:93.92.111.88 │ 176773 │ -│ ::ffff:84.53.111.33 │ 158709 │ -│ ::ffff:217.118.11.22 │ 154004 │ -│ ::ffff:217.118.11.33 │ 148449 │ -│ ::ffff:217.118.11.44 │ 148243 │ -└────────────────────────────┴────────┘ -``` - -## IPv6StringToNum(s) {#ipv6stringtonums} - -The reverse function of IPv6NumToString. If the IPv6 address has an invalid format, it returns a string of null bytes. -HEX can be uppercase or lowercase. - -## IPv4ToIPv6(x) {#ipv4toipv6x} - -Takes a `UInt32` number. Interprets it as an IPv4 address in [big endian](https://en.wikipedia.org/wiki/Endianness). Returns a `FixedString(16)` value containing the IPv6 address in binary format. Examples: - -``` sql -SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr -``` - -``` text -┌─addr───────────────┐ -│ ::ffff:192.168.0.1 │ -└────────────────────┘ -``` - -## cutIPv6(x, bytesToCutForIPv6, bytesToCutForIPv4) {#cutipv6x-bytestocutforipv6-bytestocutforipv4} - -Accepts a FixedString(16) value containing the IPv6 address in binary format. Returns a string containing the address of the specified number of bytes removed in text format. For example: - -``` sql -WITH - IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, - IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 -SELECT - cutIPv6(ipv6, 2, 0), - cutIPv6(ipv4, 0, 2) -``` - -``` text -┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ -│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ -└─────────────────────────────────────┴─────────────────────┘ -``` - -## IPv4CIDRToRange(ipv4, cidr), {#ipv4cidrtorangeipv4-cidr} - -Accepts an IPv4 and an UInt8 value containing the [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing). Return a tuple with two IPv4 containing the lower range and the higher range of the subnet. - -``` sql -SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) -``` - -``` text -┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ -│ ('192.168.0.0','192.168.255.255') │ -└────────────────────────────────────────────┘ -``` - -## IPv6CIDRToRange(ipv6, cidr), {#ipv6cidrtorangeipv6-cidr} - -Accepts an IPv6 and an UInt8 value containing the CIDR. Return a tuple with two IPv6 containing the lower range and the higher range of the subnet. - -``` sql -SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); -``` - -``` text -┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ -│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ -└────────────────────────────────────────────────────────────────────────┘ -``` - -## toIPv4(string) {#toipv4string} - -An alias to `IPv4StringToNum()` that takes a string form of IPv4 address and returns value of [IPv4](../../sql_reference/data_types/domains/ipv4.md) type, which is binary equal to value returned by `IPv4StringToNum()`. - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - toTypeName(IPv4StringToNum(IPv4_string)), - toTypeName(toIPv4(IPv4_string)) -``` - -``` text -┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ -│ UInt32 │ IPv4 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - hex(IPv4StringToNum(IPv4_string)), - hex(toIPv4(IPv4_string)) -``` - -``` text -┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ -│ ABE1822D │ ABE1822D │ -└───────────────────────────────────┴──────────────────────────┘ -``` - -## toIPv6(string) {#toipv6string} - -An alias to `IPv6StringToNum()` that takes a string form of IPv6 address and returns value of [IPv6](../../sql_reference/data_types/domains/ipv6.md) type, which is binary equal to value returned by `IPv6StringToNum()`. - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - toTypeName(IPv6StringToNum(IPv6_string)), - toTypeName(toIPv6(IPv6_string)) -``` - -``` text -┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ -│ FixedString(16) │ IPv6 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - hex(IPv6StringToNum(IPv6_string)), - hex(toIPv6(IPv6_string)) -``` - -``` text -┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ -│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ -└───────────────────────────────────┴──────────────────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/en/sql_reference/functions/json_functions.md b/docs/en/sql_reference/functions/json_functions.md deleted file mode 100644 index ca1690130e6..00000000000 --- a/docs/en/sql_reference/functions/json_functions.md +++ /dev/null @@ -1,239 +0,0 @@ ---- -toc_priority: 56 -toc_title: Working with JSON. ---- - -# Functions for working with JSON {#functions-for-working-with-json} - -In Yandex.Metrica, JSON is transmitted by users as session parameters. There are some special functions for working with this JSON. (Although in most of the cases, the JSONs are additionally pre-processed, and the resulting values are put in separate columns in their processed format.) All these functions are based on strong assumptions about what the JSON can be, but they try to do as little as possible to get the job done. - -The following assumptions are made: - -1. The field name (function argument) must be a constant. -2. The field name is somehow canonically encoded in JSON. For example: `visitParamHas('{"abc":"def"}', 'abc') = 1`, but `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -3. Fields are searched for on any nesting level, indiscriminately. If there are multiple matching fields, the first occurrence is used. -4. The JSON doesn’t have space characters outside of string literals. - -## visitParamHas(params, name) {#visitparamhasparams-name} - -Checks whether there is a field with the ‘name’ name. - -## visitParamExtractUInt(params, name) {#visitparamextractuintparams-name} - -Parses UInt64 from the value of the field named ‘name’. If this is a string field, it tries to parse a number from the beginning of the string. If the field doesn’t exist, or it exists but doesn’t contain a number, it returns 0. - -## visitParamExtractInt(params, name) {#visitparamextractintparams-name} - -The same as for Int64. - -## visitParamExtractFloat(params, name) {#visitparamextractfloatparams-name} - -The same as for Float64. - -## visitParamExtractBool(params, name) {#visitparamextractboolparams-name} - -Parses a true/false value. The result is UInt8. - -## visitParamExtractRaw(params, name) {#visitparamextractrawparams-name} - -Returns the value of a field, including separators. - -Examples: - -``` sql -visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' -visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' -``` - -## visitParamExtractString(params, name) {#visitparamextractstringparams-name} - -Parses the string in double quotes. The value is unescaped. If unescaping failed, it returns an empty string. - -Examples: - -``` sql -visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' -visitParamExtractString('{"abc":"hello}', 'abc') = '' -``` - -There is currently no support for code points in the format `\uXXXX\uYYYY` that are not from the basic multilingual plane (they are converted to CESU-8 instead of UTF-8). - -The following functions are based on [simdjson](https://github.com/lemire/simdjson) designed for more complex JSON parsing requirements. The assumption 2 mentioned above still applies. - -## isValidJSON(json) {#isvalidjsonjson} - -Checks that passed string is a valid json. - -Examples: - -``` sql -SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 -SELECT isValidJSON('not a json') = 0 -``` - -## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} - -If the value exists in the JSON document, `1` will be returned. - -If the value does not exist, `0` will be returned. - -Examples: - -``` sql -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 -``` - -`indices_or_keys` is a list of zero or more arguments each of them can be either string or integer. - -- String = access object member by key. -- Positive integer = access the n-th member/key from the beginning. -- Negative integer = access the n-th member/key from the end. - -Minimum index of the element is 1. Thus the element 0 doesn’t exist. - -You may use integers to access both JSON arrays and JSON objects. - -So, for example: - -``` sql -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' -``` - -## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} - -Return the length of a JSON array or a JSON object. - -If the value does not exist or has a wrong type, `0` will be returned. - -Examples: - -``` sql -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 -``` - -## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} - -Return the type of a JSON value. - -If the value does not exist, `Null` will be returned. - -Examples: - -``` sql -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' -``` - -## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} - -## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} - -## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} - -## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} - -Parses a JSON and extract a value. These functions are similar to `visitParam` functions. - -If the value does not exist or has a wrong type, `0` will be returned. - -Examples: - -``` sql -SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 -SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 -SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 -``` - -## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} - -Parses a JSON and extract a string. This function is similar to `visitParamExtractString` functions. - -If the value does not exist or has a wrong type, an empty string will be returned. - -The value is unescaped. If unescaping failed, it returns an empty string. - -Examples: - -``` sql -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' -SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' -SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' -``` - -## JSONExtract(json\[, indices\_or\_keys…\], return\_type) {#jsonextractjson-indices-or-keys-return-type} - -Parses a JSON and extract a value of the given ClickHouse data type. - -This is a generalization of the previous `JSONExtract` functions. -This means -`JSONExtract(..., 'String')` returns exactly the same as `JSONExtractString()`, -`JSONExtract(..., 'Float64')` returns exactly the same as `JSONExtractFloat()`. - -Examples: - -``` sql -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL -SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 -SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' -SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' -``` - -## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} - -Parses key-value pairs from a JSON where the values are of the given ClickHouse data type. - -Example: - -``` sql -SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)] -``` - -## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} - -Returns a part of JSON as unparsed string. - -If the part does not exist or has a wrong type, an empty string will be returned. - -Example: - -``` sql -SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' -``` - -## JSONExtractArrayRaw(json\[, indices\_or\_keys…\]) {#jsonextractarrayrawjson-indices-or-keys} - -Returns an array with elements of JSON array, each represented as unparsed string. - -If the part does not exist or isn’t array, an empty array will be returned. - -Example: - -``` sql -SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) - -## JSONExtractKeysAndValuesRaw(json\[, indices\_or\_keys…\]) {#jsonextractkeysandvaluesrawjson-indices-or-keys} - -Parses key-value pairs from a JSON and returns an array of such pairs, each value represented as unparsed string. - -Example: - -``` sql -SELECT JSONExtractKeysAndValuesRaw('{"a": "hello", "b": [-100, 200.0, 300]}') = [('a','"hello"'),('b','[-100,200,300]')] -``` diff --git a/docs/en/sql_reference/functions/logical_functions.md b/docs/en/sql_reference/functions/logical_functions.md deleted file mode 100644 index c1aa30775c3..00000000000 --- a/docs/en/sql_reference/functions/logical_functions.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -toc_priority: 37 -toc_title: Logical ---- - -# Logical functions {#logical-functions} - -Logical functions accept any numeric types, but return a UInt8 number equal to 0 or 1. - -Zero as an argument is considered “false,” while any non-zero value is considered “true”. - -## and, AND operator {#and-and-operator} - -## or, OR operator {#or-or-operator} - -## not, NOT operator {#not-not-operator} - -## xor {#xor} - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/en/sql_reference/functions/machine_learning_functions.md b/docs/en/sql_reference/functions/machine_learning_functions.md deleted file mode 100644 index 4ff4e592e7b..00000000000 --- a/docs/en/sql_reference/functions/machine_learning_functions.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -toc_priority: 64 -toc_title: Machine Learning Functions ---- - -# Machine Learning Functions {#machine-learning-functions} - -## evalMLMethod (prediction) {#machine_learning_methods-evalmlmethod} - -Prediction using fitted regression models uses `evalMLMethod` function. See link in `linearRegression`. - -### Stochastic Linear Regression {#stochastic-linear-regression} - -The [stochasticLinearRegression](../../sql_reference/aggregate_functions/reference.md#agg_functions-stochasticlinearregression) aggregate function implements stochastic gradient descent method using linear model and MSE loss function. Uses `evalMLMethod` to predict on new data. - -### Stochastic Logistic Regression {#stochastic-logistic-regression} - -The [stochasticLogisticRegression](../../sql_reference/aggregate_functions/reference.md#agg_functions-stochasticlogisticregression) aggregate function implements stochastic gradient descent method for binary classification problem. Uses `evalMLMethod` to predict on new data. diff --git a/docs/en/sql_reference/functions/math_functions.md b/docs/en/sql_reference/functions/math_functions.md deleted file mode 100644 index 3f0f8623840..00000000000 --- a/docs/en/sql_reference/functions/math_functions.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -toc_priority: 44 -toc_title: Mathematical ---- - -# Mathematical functions {#mathematical-functions} - -All the functions return a Float64 number. The accuracy of the result is close to the maximum precision possible, but the result might not coincide with the machine representable number nearest to the corresponding real number. - -## e() {#e} - -Returns a Float64 number that is close to the number e. - -## pi() {#pi} - -Returns a Float64 number that is close to the number π. - -## exp(x) {#expx} - -Accepts a numeric argument and returns a Float64 number close to the exponent of the argument. - -## log(x), ln(x) {#logx-lnx} - -Accepts a numeric argument and returns a Float64 number close to the natural logarithm of the argument. - -## exp2(x) {#exp2x} - -Accepts a numeric argument and returns a Float64 number close to 2 to the power of x. - -## log2(x) {#log2x} - -Accepts a numeric argument and returns a Float64 number close to the binary logarithm of the argument. - -## exp10(x) {#exp10x} - -Accepts a numeric argument and returns a Float64 number close to 10 to the power of x. - -## log10(x) {#log10x} - -Accepts a numeric argument and returns a Float64 number close to the decimal logarithm of the argument. - -## sqrt(x) {#sqrtx} - -Accepts a numeric argument and returns a Float64 number close to the square root of the argument. - -## cbrt(x) {#cbrtx} - -Accepts a numeric argument and returns a Float64 number close to the cubic root of the argument. - -## erf(x) {#erfx} - -If ‘x’ is non-negative, then erf(x / σ√2) is the probability that a random variable having a normal distribution with standard deviation ‘σ’ takes the value that is separated from the expected value by more than ‘x’. - -Example (three sigma rule): - -``` sql -SELECT erf(3 / sqrt(2)) -``` - -``` text -┌─erf(divide(3, sqrt(2)))─┐ -│ 0.9973002039367398 │ -└─────────────────────────┘ -``` - -## erfc(x) {#erfcx} - -Accepts a numeric argument and returns a Float64 number close to 1 - erf(x), but without loss of precision for large ‘x’ values. - -## lgamma(x) {#lgammax} - -The logarithm of the gamma function. - -## tgamma(x) {#tgammax} - -Gamma function. - -## sin(x) {#sinx} - -The sine. - -## cos(x) {#cosx} - -The cosine. - -## tan(x) {#tanx} - -The tangent. - -## asin(x) {#asinx} - -The arc sine. - -## acos(x) {#acosx} - -The arc cosine. - -## atan(x) {#atanx} - -The arc tangent. - -## pow(x, y), power(x, y) {#powx-y-powerx-y} - -Takes two numeric arguments x and y. Returns a Float64 number close to x to the power of y. - -## intExp2 {#intexp2} - -Accepts a numeric argument and returns a UInt64 number close to 2 to the power of x. - -## intExp10 {#intexp10} - -Accepts a numeric argument and returns a UInt64 number close to 10 to the power of x. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/en/sql_reference/functions/other_functions.md b/docs/en/sql_reference/functions/other_functions.md deleted file mode 100644 index 843897c21b2..00000000000 --- a/docs/en/sql_reference/functions/other_functions.md +++ /dev/null @@ -1,1077 +0,0 @@ ---- -toc_priority: 66 -toc_title: Other ---- - -# Other functions {#other-functions} - -## hostName() {#hostname} - -Returns a string with the name of the host that this function was performed on. For distributed processing, this is the name of the remote server host, if the function is performed on a remote server. - -## FQDN {#fqdn} - -Returns the fully qualified domain name. - -**Syntax** - -``` sql -fqdn(); -``` - -This function is case-insensitive. - -**Returned value** - -- String with the fully qualified domain name. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT FQDN(); -``` - -Result: - -``` text -┌─FQDN()──────────────────────────┐ -│ clickhouse.ru-central1.internal │ -└─────────────────────────────────┘ -``` - -## basename {#basename} - -Extracts the trailing part of a string after the last slash or backslash. This function if often used to extract the filename from a path. - -``` sql -basename( expr ) -``` - -**Parameters** - -- `expr` — Expression resulting in a [String](../../sql_reference/data_types/string.md) type value. All the backslashes must be escaped in the resulting value. - -**Returned Value** - -A string that contains: - -- The trailing part of a string after the last slash or backslash. - - If the input string contains a path ending with slash or backslash, for example, `/` or `c:\`, the function returns an empty string. - -- The original string if there are no slashes or backslashes. - -**Example** - -``` sql -SELECT 'some/long/path/to/file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some\\long\\path\\to\\file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some-file-name' AS a, basename(a) -``` - -``` text -┌─a──────────────┬─basename('some-file-name')─┐ -│ some-file-name │ some-file-name │ -└────────────────┴────────────────────────────┘ -``` - -## visibleWidth(x) {#visiblewidthx} - -Calculates the approximate width when outputting values to the console in text format (tab-separated). -This function is used by the system for implementing Pretty formats. - -`NULL` is represented as a string corresponding to `NULL` in `Pretty` formats. - -``` sql -SELECT visibleWidth(NULL) -``` - -``` text -┌─visibleWidth(NULL)─┐ -│ 4 │ -└────────────────────┘ -``` - -## toTypeName(x) {#totypenamex} - -Returns a string containing the type name of the passed argument. - -If `NULL` is passed to the function as input, then it returns the `Nullable(Nothing)` type, which corresponds to an internal `NULL` representation in ClickHouse. - -## blockSize() {#function-blocksize} - -Gets the size of the block. -In ClickHouse, queries are always run on blocks (sets of column parts). This function allows getting the size of the block that you called it for. - -## materialize(x) {#materializex} - -Turns a constant into a full column containing just one value. -In ClickHouse, full columns and constants are represented differently in memory. Functions work differently for constant arguments and normal arguments (different code is executed), although the result is almost always the same. This function is for debugging this behavior. - -## ignore(…) {#ignore} - -Accepts any arguments, including `NULL`. Always returns 0. -However, the argument is still evaluated. This can be used for benchmarks. - -## sleep(seconds) {#sleepseconds} - -Sleeps ‘seconds’ seconds on each data block. You can specify an integer or a floating-point number. - -## sleepEachRow(seconds) {#sleepeachrowseconds} - -Sleeps ‘seconds’ seconds on each row. You can specify an integer or a floating-point number. - -## currentDatabase() {#currentdatabase} - -Returns the name of the current database. -You can use this function in table engine parameters in a CREATE TABLE query where you need to specify the database. - -## currentUser() {#other-function-currentuser} - -Returns the login of current user. Login of user, that initiated query, will be returned in case distibuted query. - -``` sql -SELECT currentUser(); -``` - -Alias: `user()`, `USER()`. - -**Returned values** - -- Login of current user. -- Login of user that initiated query in case of disributed query. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT currentUser(); -``` - -Result: - -``` text -┌─currentUser()─┐ -│ default │ -└───────────────┘ -``` - -## isFinite(x) {#isfinitex} - -Accepts Float32 and Float64 and returns UInt8 equal to 1 if the argument is not infinite and not a NaN, otherwise 0. - -## isInfinite(x) {#isinfinitex} - -Accepts Float32 and Float64 and returns UInt8 equal to 1 if the argument is infinite, otherwise 0. Note that 0 is returned for a NaN. - -## ifNotFinite {#ifnotfinite} - -Checks whether floating point value is finite. - -**Syntax** - - ifNotFinite(x,y) - -**Parameters** - -- `x` — Value to be checked for infinity. Type: [Float\*](../../sql_reference/data_types/float.md). -- `y` — Fallback value. Type: [Float\*](../../sql_reference/data_types/float.md). - -**Returned value** - -- `x` if `x` is finite. -- `y` if `x` is not finite. - -**Example** - -Query: - - SELECT 1/0 as infimum, ifNotFinite(infimum,42) - -Result: - - ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ - │ inf │ 42 │ - └─────────┴───────────────────────────────┘ - -You can get similar result by using [ternary operator](conditional_functions.md#ternary-operator): `isFinite(x) ? x : y`. - -## isNaN(x) {#isnanx} - -Accepts Float32 and Float64 and returns UInt8 equal to 1 if the argument is a NaN, otherwise 0. - -## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} - -Accepts constant strings: database name, table name, and column name. Returns a UInt8 constant expression equal to 1 if there is a column, otherwise 0. If the hostname parameter is set, the test will run on a remote server. -The function throws an exception if the table does not exist. -For elements in a nested data structure, the function checks for the existence of a column. For the nested data structure itself, the function returns 0. - -## bar {#function-bar} - -Allows building a unicode-art diagram. - -`bar(x, min, max, width)` draws a band with a width proportional to `(x - min)` and equal to `width` characters when `x = max`. - -Parameters: - -- `x` — Size to display. -- `min, max` — Integer constants. The value must fit in `Int64`. -- `width` — Constant, positive integer, can be fractional. - -The band is drawn with accuracy to one eighth of a symbol. - -Example: - -``` sql -SELECT - toHour(EventTime) AS h, - count() AS c, - bar(c, 0, 600000, 20) AS bar -FROM test.hits -GROUP BY h -ORDER BY h ASC -``` - -``` text -┌──h─┬──────c─┬─bar────────────────┐ -│ 0 │ 292907 │ █████████▋ │ -│ 1 │ 180563 │ ██████ │ -│ 2 │ 114861 │ ███▋ │ -│ 3 │ 85069 │ ██▋ │ -│ 4 │ 68543 │ ██▎ │ -│ 5 │ 78116 │ ██▌ │ -│ 6 │ 113474 │ ███▋ │ -│ 7 │ 170678 │ █████▋ │ -│ 8 │ 278380 │ █████████▎ │ -│ 9 │ 391053 │ █████████████ │ -│ 10 │ 457681 │ ███████████████▎ │ -│ 11 │ 493667 │ ████████████████▍ │ -│ 12 │ 509641 │ ████████████████▊ │ -│ 13 │ 522947 │ █████████████████▍ │ -│ 14 │ 539954 │ █████████████████▊ │ -│ 15 │ 528460 │ █████████████████▌ │ -│ 16 │ 539201 │ █████████████████▊ │ -│ 17 │ 523539 │ █████████████████▍ │ -│ 18 │ 506467 │ ████████████████▊ │ -│ 19 │ 520915 │ █████████████████▎ │ -│ 20 │ 521665 │ █████████████████▍ │ -│ 21 │ 542078 │ ██████████████████ │ -│ 22 │ 493642 │ ████████████████▍ │ -│ 23 │ 400397 │ █████████████▎ │ -└────┴────────┴────────────────────┘ -``` - -## transform {#transform} - -Transforms a value according to the explicitly defined mapping of some elements to other ones. -There are two variations of this function: - -### transform(x, array\_from, array\_to, default) {#transformx-array-from-array-to-default} - -`x` – What to transform. - -`array_from` – Constant array of values for converting. - -`array_to` – Constant array of values to convert the values in ‘from’ to. - -`default` – Which value to use if ‘x’ is not equal to any of the values in ‘from’. - -`array_from` and `array_to` – Arrays of the same size. - -Types: - -`transform(T, Array(T), Array(U), U) -> U` - -`T` and `U` can be numeric, string, or Date or DateTime types. -Where the same letter is indicated (T or U), for numeric types these might not be matching types, but types that have a common type. -For example, the first argument can have the Int64 type, while the second has the Array(UInt16) type. - -If the ‘x’ value is equal to one of the elements in the ‘array\_from’ array, it returns the existing element (that is numbered the same) from the ‘array\_to’ array. Otherwise, it returns ‘default’. If there are multiple matching elements in ‘array\_from’, it returns one of the matches. - -Example: - -``` sql -SELECT - transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, - count() AS c -FROM test.hits -WHERE SearchEngineID != 0 -GROUP BY title -ORDER BY c DESC -``` - -``` text -┌─title─────┬──────c─┐ -│ Yandex │ 498635 │ -│ Google │ 229872 │ -│ Other │ 104472 │ -└───────────┴────────┘ -``` - -### transform(x, array\_from, array\_to) {#transformx-array-from-array-to} - -Differs from the first variation in that the ‘default’ argument is omitted. -If the ‘x’ value is equal to one of the elements in the ‘array\_from’ array, it returns the matching element (that is numbered the same) from the ‘array\_to’ array. Otherwise, it returns ‘x’. - -Types: - -`transform(T, Array(T), Array(T)) -> T` - -Example: - -``` sql -SELECT - transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, - count() AS c -FROM test.hits -GROUP BY domain(Referer) -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -┌─s──────────────┬───────c─┐ -│ │ 2906259 │ -│ www.yandex │ 867767 │ -│ ███████.ru │ 313599 │ -│ mail.yandex.ru │ 107147 │ -│ ██████.ru │ 100355 │ -│ █████████.ru │ 65040 │ -│ news.yandex.ru │ 64515 │ -│ ██████.net │ 59141 │ -│ example.com │ 57316 │ -└────────────────┴─────────┘ -``` - -## formatReadableSize(x) {#formatreadablesizex} - -Accepts the size (number of bytes). Returns a rounded size with a suffix (KiB, MiB, etc.) as a string. - -Example: - -``` sql -SELECT - arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, - formatReadableSize(filesize_bytes) AS filesize -``` - -``` text -┌─filesize_bytes─┬─filesize───┐ -│ 1 │ 1.00 B │ -│ 1024 │ 1.00 KiB │ -│ 1048576 │ 1.00 MiB │ -│ 192851925 │ 183.92 MiB │ -└────────────────┴────────────┘ -``` - -## least(a, b) {#leasta-b} - -Returns the smallest value from a and b. - -## greatest(a, b) {#greatesta-b} - -Returns the largest value of a and b. - -## uptime() {#uptime} - -Returns the server’s uptime in seconds. - -## version() {#version} - -Returns the version of the server as a string. - -## timezone() {#timezone} - -Returns the timezone of the server. - -## blockNumber {#blocknumber} - -Returns the sequence number of the data block where the row is located. - -## rowNumberInBlock {#function-rownumberinblock} - -Returns the ordinal number of the row in the data block. Different data blocks are always recalculated. - -## rowNumberInAllBlocks() {#rownumberinallblocks} - -Returns the ordinal number of the row in the data block. This function only considers the affected data blocks. - -## neighbor {#neighbor} - -The window function that provides access to a row at a specified offset which comes before or after the current row of a given column. - -**Syntax** - -``` sql -neighbor(column, offset[, default_value]) -``` - -The result of the function depends on the affected data blocks and the order of data in the block. -If you make a subquery with ORDER BY and call the function from outside the subquery, you can get the expected result. - -**Parameters** - -- `column` — A column name or scalar expression. -- `offset` — The number of rows forwards or backwards from the current row of `column`. [Int64](../../sql_reference/data_types/int_uint.md). -- `default_value` — Optional. The value to be returned if offset goes beyond the scope of the block. Type of data blocks affected. - -**Returned values** - -- Value for `column` in `offset` distance from current row if `offset` value is not outside block bounds. -- Default value for `column` if `offset` value is outside block bounds. If `default_value` is given, then it will be used. - -Type: type of data blocks affected or default value type. - -**Example** - -Query: - -``` sql -SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; -``` - -Result: - -``` text -┌─number─┬─neighbor(number, 2)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 0 │ -│ 9 │ 0 │ -└────────┴─────────────────────┘ -``` - -Query: - -``` sql -SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; -``` - -Result: - -``` text -┌─number─┬─neighbor(number, 2, 999)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 999 │ -│ 9 │ 999 │ -└────────┴──────────────────────────┘ -``` - -This function can be used to compute year-over-year metric value: - -Query: - -``` sql -WITH toDate('2018-01-01') AS start_date -SELECT - toStartOfMonth(start_date + (number * 32)) AS month, - toInt32(month) % 100 AS money, - neighbor(money, -12) AS prev_year, - round(prev_year / money, 2) AS year_over_year -FROM numbers(16) -``` - -Result: - -``` text -┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ -│ 2018-01-01 │ 32 │ 0 │ 0 │ -│ 2018-02-01 │ 63 │ 0 │ 0 │ -│ 2018-03-01 │ 91 │ 0 │ 0 │ -│ 2018-04-01 │ 22 │ 0 │ 0 │ -│ 2018-05-01 │ 52 │ 0 │ 0 │ -│ 2018-06-01 │ 83 │ 0 │ 0 │ -│ 2018-07-01 │ 13 │ 0 │ 0 │ -│ 2018-08-01 │ 44 │ 0 │ 0 │ -│ 2018-09-01 │ 75 │ 0 │ 0 │ -│ 2018-10-01 │ 5 │ 0 │ 0 │ -│ 2018-11-01 │ 36 │ 0 │ 0 │ -│ 2018-12-01 │ 66 │ 0 │ 0 │ -│ 2019-01-01 │ 97 │ 32 │ 0.33 │ -│ 2019-02-01 │ 28 │ 63 │ 2.25 │ -│ 2019-03-01 │ 56 │ 91 │ 1.62 │ -│ 2019-04-01 │ 87 │ 22 │ 0.25 │ -└────────────┴───────┴───────────┴────────────────┘ -``` - -## runningDifference(x) {#other_functions-runningdifference} - -Calculates the difference between successive row values ​​in the data block. -Returns 0 for the first row and the difference from the previous row for each subsequent row. - -The result of the function depends on the affected data blocks and the order of data in the block. -If you make a subquery with ORDER BY and call the function from outside the subquery, you can get the expected result. - -Example: - -``` sql -SELECT - EventID, - EventTime, - runningDifference(EventTime) AS delta -FROM -( - SELECT - EventID, - EventTime - FROM events - WHERE EventDate = '2016-11-24' - ORDER BY EventTime ASC - LIMIT 5 -) -``` - -``` text -┌─EventID─┬───────────EventTime─┬─delta─┐ -│ 1106 │ 2016-11-24 00:00:04 │ 0 │ -│ 1107 │ 2016-11-24 00:00:05 │ 1 │ -│ 1108 │ 2016-11-24 00:00:05 │ 0 │ -│ 1109 │ 2016-11-24 00:00:09 │ 4 │ -│ 1110 │ 2016-11-24 00:00:10 │ 1 │ -└─────────┴─────────────────────┴───────┘ -``` - -Please note - block size affects the result. With each new block, the `runningDifference` state is reset. - -``` sql -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -┌─number─┬─diff─┐ -│ 65536 │ 0 │ -└────────┴──────┘ -``` - -``` sql -set max_block_size=100000 -- default value is 65536! - -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -``` - -## runningDifferenceStartingWithFirstValue {#runningdifferencestartingwithfirstvalue} - -Same as for [runningDifference](./other_functions.md#other_functions-runningdifference), the difference is the value of the first row, returned the value of the first row, and each subsequent row returns the difference from the previous row. - -## MACNumToString(num) {#macnumtostringnum} - -Accepts a UInt64 number. Interprets it as a MAC address in big endian. Returns a string containing the corresponding MAC address in the format AA:BB:CC:DD:EE:FF (colon-separated numbers in hexadecimal form). - -## MACStringToNum(s) {#macstringtonums} - -The inverse function of MACNumToString. If the MAC address has an invalid format, it returns 0. - -## MACStringToOUI(s) {#macstringtoouis} - -Accepts a MAC address in the format AA:BB:CC:DD:EE:FF (colon-separated numbers in hexadecimal form). Returns the first three octets as a UInt64 number. If the MAC address has an invalid format, it returns 0. - -## getSizeOfEnumType {#getsizeofenumtype} - -Returns the number of fields in [Enum](../../sql_reference/data_types/enum.md). - -``` sql -getSizeOfEnumType(value) -``` - -**Parameters:** - -- `value` — Value of type `Enum`. - -**Returned values** - -- The number of fields with `Enum` input values. -- An exception is thrown if the type is not `Enum`. - -**Example** - -``` sql -SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## blockSerializedSize {#blockserializedsize} - -Returns size on disk (without taking into account compression). - -``` sql -blockSerializedSize(value[, value[, ...]]) -``` - -**Parameters:** - -- `value` — Any value. - -**Returned values** - -- The number of bytes that will be written to disk for block of values (without compression). - -**Example** - -``` sql -SELECT blockSerializedSize(maxState(1)) as x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## toColumnTypeName {#tocolumntypename} - -Returns the name of the class that represents the data type of the column in RAM. - -``` sql -toColumnTypeName(value) -``` - -**Parameters:** - -- `value` — Any type of value. - -**Returned values** - -- A string with the name of the class that is used for representing the `value` data type in RAM. - -**Example of the difference between`toTypeName ' and ' toColumnTypeName`** - -``` sql -SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime │ -└─────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ Const(UInt32) │ -└───────────────────────────────────────────────────────────┘ -``` - -The example shows that the `DateTime` data type is stored in memory as `Const(UInt32)`. - -## dumpColumnStructure {#dumpcolumnstructure} - -Outputs a detailed description of data structures in RAM - -``` sql -dumpColumnStructure(value) -``` - -**Parameters:** - -- `value` — Any type of value. - -**Returned values** - -- A string describing the structure that is used for representing the `value` data type in RAM. - -**Example** - -``` sql -SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) -``` - -``` text -┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime, Const(size = 1, UInt32(size = 1)) │ -└──────────────────────────────────────────────────────────────┘ -``` - -## defaultValueOfArgumentType {#defaultvalueofargumenttype} - -Outputs the default value for the data type. - -Does not include default values for custom columns set by the user. - -``` sql -defaultValueOfArgumentType(expression) -``` - -**Parameters:** - -- `expression` — Arbitrary type of value or an expression that results in a value of an arbitrary type. - -**Returned values** - -- `0` for numbers. -- Empty string for strings. -- `ᴺᵁᴸᴸ` for [Nullable](../../sql_reference/data_types/nullable.md). - -**Example** - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ -│ 0 │ -└─────────────────────────────────────────────┘ -``` - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ -│ ᴺᵁᴸᴸ │ -└───────────────────────────────────────────────────────┘ -``` - -## replicate {#other-functions-replicate} - -Creates an array with a single value. - -Used for internal implementation of [arrayJoin](array_join.md#functions_arrayjoin). - -``` sql -SELECT replicate(x, arr); -``` - -**Parameters:** - -- `arr` — Original array. ClickHouse creates a new array of the same length as the original and fills it with the value `x`. -- `x` — The value that the resulting array will be filled with. - -**Returned value** - -An array filled with the value `x`. - -Type: `Array`. - -**Example** - -Query: - -``` sql -SELECT replicate(1, ['a', 'b', 'c']) -``` - -Result: - -``` text -┌─replicate(1, ['a', 'b', 'c'])─┐ -│ [1,1,1] │ -└───────────────────────────────┘ -``` - -## filesystemAvailable {#filesystemavailable} - -Returns amount of remaining space on the filesystem where the files of the databases located. It is always smaller than total free space ([filesystemFree](#filesystemfree)) because some space is reserved for OS. - -**Syntax** - -``` sql -filesystemAvailable() -``` - -**Returned value** - -- The amount of remaining space available in bytes. - -Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; -``` - -Result: - -``` text -┌─Available space─┬─Type───┐ -│ 30.75 GiB │ UInt64 │ -└─────────────────┴────────┘ -``` - -## filesystemFree {#filesystemfree} - -Returns total amount of the free space on the filesystem where the files of the databases located. See also `filesystemAvailable` - -**Syntax** - -``` sql -filesystemFree() -``` - -**Returned value** - -- Amount of free space in bytes. - -Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; -``` - -Result: - -``` text -┌─Free space─┬─Type───┐ -│ 32.39 GiB │ UInt64 │ -└────────────┴────────┘ -``` - -## filesystemCapacity {#filesystemcapacity} - -Returns the capacity of the filesystem in bytes. For evaluation, the [path](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) to the data directory must be configured. - -**Syntax** - -``` sql -filesystemCapacity() -``` - -**Returned value** - -- Capacity information of the filesystem in bytes. - -Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Example** - -Query: - -``` sql -SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" -``` - -Result: - -``` text -┌─Capacity──┬─Type───┐ -│ 39.32 GiB │ UInt64 │ -└───────────┴────────┘ -``` - -## finalizeAggregation {#function-finalizeaggregation} - -Takes state of aggregate function. Returns result of aggregation (finalized state). - -## runningAccumulate {#function-runningaccumulate} - -Takes the states of the aggregate function and returns a column with values, are the result of the accumulation of these states for a set of block lines, from the first to the current line. -For example, takes state of aggregate function (example runningAccumulate(uniqState(UserID))), and for each row of block, return result of aggregate function on merge of states of all previous rows and current row. -So, result of function depends on partition of data to blocks and on order of data in block. - -## joinGet {#joinget} - -The function lets you extract data from the table the same way as from a [dictionary](../../sql_reference/dictionaries/index.md). - -Gets data from [Join](../../engines/table_engines/special/join.md#creating-a-table) tables using the specified join key. - -Only supports tables created with the `ENGINE = Join(ANY, LEFT, )` statement. - -**Syntax** - -``` sql -joinGet(join_storage_table_name, `value_column`, join_keys) -``` - -**Parameters** - -- `join_storage_table_name` — an [identifier](../syntax.md#syntax-identifiers) indicates where search is performed. The identifier is searched in the default database (see parameter `default_database` in the config file). To override the default database, use the `USE db_name` or specify the database and the table through the separator `db_name.db_table`, see the example. -- `value_column` — name of the column of the table that contains required data. -- `join_keys` — list of keys. - -**Returned value** - -Returns list of values corresponded to list of keys. - -If certain doesn’t exist in source table then `0` or `null` will be returned based on [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls) setting. - -More info about `join_use_nulls` in [Join operation](../../engines/table_engines/special/join.md). - -**Example** - -Input table: - -``` sql -CREATE DATABASE db_test -CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 -INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) -``` - -``` text -┌─id─┬─val─┐ -│ 4 │ 13 │ -│ 2 │ 12 │ -│ 1 │ 11 │ -└────┴─────┘ -``` - -Query: - -``` sql -SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 -``` - -Result: - -``` text -┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ -│ 0 │ -│ 11 │ -│ 12 │ -│ 0 │ -└──────────────────────────────────────────────────┘ -``` - -## modelEvaluate(model\_name, …) {#function-modelevaluate} - -Evaluate external model. -Accepts a model name and model arguments. Returns Float64. - -## throwIf(x\[, custom\_message\]) {#throwifx-custom-message} - -Throw an exception if the argument is non zero. -custom\_message - is an optional parameter: a constant string, provides an error message - -``` sql -SELECT throwIf(number = 3, 'Too many') FROM numbers(10); -``` - -``` text -↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): -Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. -``` - -## identity {#identity} - -Returns the same value that was used as its argument. Used for debugging and testing, allows to cancel using index, and get the query performance of a full scan. When query is analyzed for possible use of index, the analyzer doesn’t look inside `identity` functions. - -**Syntax** - -``` sql -identity(x) -``` - -**Example** - -Query: - -``` sql -SELECT identity(42) -``` - -Result: - -``` text -┌─identity(42)─┐ -│ 42 │ -└──────────────┘ -``` - -## randomPrintableASCII {#randomascii} - -Generates a string with a random set of [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) printable characters. - -**Syntax** - -``` sql -randomPrintableASCII(length) -``` - -**Parameters** - -- `length` — Resulting string length. Positive integer. - - If you pass `length < 0`, behavior of the function is undefined. - -**Returned value** - -- String with a random set of [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) printable characters. - -Type: [String](../../sql_reference/data_types/string.md) - -**Example** - -``` sql -SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 -``` - -``` text -┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ -│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ -│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ -│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ -└────────┴────────────────────────────────┴──────────────────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/en/sql_reference/functions/random_functions.md b/docs/en/sql_reference/functions/random_functions.md deleted file mode 100644 index 7990d3b6cc7..00000000000 --- a/docs/en/sql_reference/functions/random_functions.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -toc_priority: 51 -toc_title: Generating Pseudo-Random Numbers ---- - -# Functions for generating pseudo-random numbers {#functions-for-generating-pseudo-random-numbers} - -Non-cryptographic generators of pseudo-random numbers are used. - -All the functions accept zero arguments or one argument. -If an argument is passed, it can be any type, and its value is not used for anything. -The only purpose of this argument is to prevent common subexpression elimination, so that two different instances of the same function return different columns with different random numbers. - -## rand {#rand} - -Returns a pseudo-random UInt32 number, evenly distributed among all UInt32-type numbers. -Uses a linear congruential generator. - -## rand64 {#rand64} - -Returns a pseudo-random UInt64 number, evenly distributed among all UInt64-type numbers. -Uses a linear congruential generator. - -## randConstant {#randconstant} - -Returns a pseudo-random UInt32 number, The value is one for different blocks. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/en/sql_reference/functions/rounding_functions.md b/docs/en/sql_reference/functions/rounding_functions.md deleted file mode 100644 index ce3c592acc6..00000000000 --- a/docs/en/sql_reference/functions/rounding_functions.md +++ /dev/null @@ -1,188 +0,0 @@ ---- -toc_priority: 45 -toc_title: Rounding ---- - -# Rounding functions {#rounding-functions} - -## floor(x\[, N\]) {#floorx-n} - -Returns the largest round number that is less than or equal to `x`. A round number is a multiple of 1/10N, or the nearest number of the appropriate data type if 1 / 10N isn’t exact. -‘N’ is an integer constant, optional parameter. By default it is zero, which means to round to an integer. -‘N’ may be negative. - -Examples: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` - -`x` is any numeric type. The result is a number of the same type. -For integer arguments, it makes sense to round with a negative `N` value (for non-negative `N`, the function doesn’t do anything). -If rounding causes overflow (for example, floor(-128, -1)), an implementation-specific result is returned. - -## ceil(x\[, N\]), ceiling(x\[, N\]) {#ceilx-n-ceilingx-n} - -Returns the smallest round number that is greater than or equal to `x`. In every other way, it is the same as the `floor` function (see above). - -## trunc(x\[, N\]), truncate(x\[, N\]) {#truncx-n-truncatex-n} - -Returns the round number with largest absolute value that has an absolute value less than or equal to `x`‘s. In every other way, it is the same as the ’floor’ function (see above). - -## round(x\[, N\]) {#rounding_functions-round} - -Rounds a value to a specified number of decimal places. - -The function returns the nearest number of the specified order. In case when given number has equal distance to surrounding numbers, the function uses banker’s rounding for float number types and rounds away from zero for the other number types. - -``` sql -round(expression [, decimal_places]) -``` - -**Parameters:** - -- `expression` — A number to be rounded. Can be any [expression](../syntax.md#syntax-expressions) returning the numeric [data type](../../sql_reference/data_types/index.md#data_types). -- `decimal-places` — An integer value. - - If `decimal-places > 0` then the function rounds the value to the right of the decimal point. - - If `decimal-places < 0` then the function rounds the value to the left of the decimal point. - - If `decimal-places = 0` then the function rounds the value to integer. In this case the argument can be omitted. - -**Returned value:** - -The rounded number of the same type as the input number. - -### Examples {#examples} - -**Example of use** - -``` sql -SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 -``` - -``` text -┌───x─┬─round(divide(number, 2))─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -└─────┴──────────────────────────┘ -``` - -**Examples of rounding** - -Rounding to the nearest number. - -``` text -round(3.2, 0) = 3 -round(4.1267, 2) = 4.13 -round(22,-1) = 20 -round(467,-2) = 500 -round(-467,-2) = -500 -``` - -Banker’s rounding. - -``` text -round(3.5) = 4 -round(4.5) = 4 -round(3.55, 1) = 3.6 -round(3.65, 1) = 3.6 -``` - -**See Also** - -- [roundBankers](#roundbankers) - -## roundBankers {#roundbankers} - -Rounds a number to a specified decimal position. - -- If the rounding number is halfway between two numbers, the function uses banker’s rounding. - - Banker's rounding is a method of rounding fractional numbers. When the rounding number is halfway between two numbers, it's rounded to the nearest even digit at the specified decimal position. For example: 3.5 rounds up to 4, 2.5 rounds down to 2. - - It's the default rounding method for floating point numbers defined in [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). The [round](#rounding_functions-round) function performs the same rounding for floating point numbers. The `roundBankers` function also rounds integers the same way, for example, `roundBankers(45, -1) = 40`. - -- In other cases, the function rounds numbers to the nearest integer. - -Using banker’s rounding, you can reduce the effect that rounding numbers has on the results of summing or subtracting these numbers. - -For example, sum numbers 1.5, 2.5, 3.5, 4.5 with different rounding: - -- No rounding: 1.5 + 2.5 + 3.5 + 4.5 = 12. -- Banker’s rounding: 2 + 2 + 4 + 4 = 12. -- Rounding to the nearest integer: 2 + 3 + 4 + 5 = 14. - -**Syntax** - -``` sql -roundBankers(expression [, decimal_places]) -``` - -**Parameters** - -- `expression` — A number to be rounded. Can be any [expression](../syntax.md#syntax-expressions) returning the numeric [data type](../../sql_reference/data_types/index.md#data_types). -- `decimal-places` — Decimal places. An integer number. - - `decimal-places > 0` — The function rounds the number to the given position right of the decimal point. Example: `roundBankers(3.55, 1) = 3.6`. - - `decimal-places < 0` — The function rounds the number to the given position left of the decimal point. Example: `roundBankers(24.55, -1) = 20`. - - `decimal-places = 0` — The function rounds the number to an integer. In this case the argument can be omitted. Example: `roundBankers(2.5) = 2`. - -**Returned value** - -A value rounded by the banker’s rounding method. - -### Examples {#examples-1} - -**Example of use** - -Query: - -``` sql - SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 -``` - -Result: - -``` text -┌───x─┬─b─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -│ 1.5 │ 2 │ -│ 2 │ 2 │ -│ 2.5 │ 2 │ -│ 3 │ 3 │ -│ 3.5 │ 4 │ -│ 4 │ 4 │ -│ 4.5 │ 4 │ -└─────┴───┘ -``` - -**Examples of Banker’s rounding** - -``` text -roundBankers(0.4) = 0 -roundBankers(-3.5) = -4 -roundBankers(4.5) = 4 -roundBankers(3.55, 1) = 3.6 -roundBankers(3.65, 1) = 3.6 -roundBankers(10.35, 1) = 10.4 -roundBankers(10.755, 2) = 11,76 -``` - -**See Also** - -- [round](#rounding_functions-round) - -## roundToExp2(num) {#roundtoexp2num} - -Accepts a number. If the number is less than one, it returns 0. Otherwise, it rounds the number down to the nearest (whole non-negative) degree of two. - -## roundDuration(num) {#rounddurationnum} - -Accepts a number. If the number is less than one, it returns 0. Otherwise, it rounds the number down to numbers from the set: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. This function is specific to Yandex.Metrica and used for implementing the report on session length. - -## roundAge(num) {#roundagenum} - -Accepts a number. If the number is less than 18, it returns 0. Otherwise, it rounds the number down to a number from the set: 18, 25, 35, 45, 55. This function is specific to Yandex.Metrica and used for implementing the report on user age. - -## roundDown(num, arr) {#rounddownnum-arr} - -Accepts a number and rounds it down to an element in the specified array. If the value is less than the lowest bound, the lowest bound is returned. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/en/sql_reference/functions/splitting_merging_functions.md b/docs/en/sql_reference/functions/splitting_merging_functions.md deleted file mode 100644 index 9e455440293..00000000000 --- a/docs/en/sql_reference/functions/splitting_merging_functions.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -toc_priority: 47 -toc_title: Splitting and Merging Strings and Arrays ---- - -# Functions for splitting and merging strings and arrays {#functions-for-splitting-and-merging-strings-and-arrays} - -## splitByChar(separator, s) {#splitbycharseparator-s} - -Splits a string into substrings separated by a specified character. It uses a constant string `separator` which consisting of exactly one character. -Returns an array of selected substrings. Empty substrings may be selected if the separator occurs at the beginning or end of the string, or if there are multiple consecutive separators. - -**Syntax** - -```sql -splitByChar(, ) -``` - -**Parameters** - -- `separator` — The separator which should contain exactly one character. [String](../../sql_reference/data_types/string.md). -- `s` — The string to split. [String](../../sql_reference/data_types/string.md). - -**Returned value(s)** - -Returns an array of selected substrings. Empty substrings may be selected when: - -* A separator occurs at the beginning or end of the string; -* There are multiple consecutive separators; -* The original string `s` is empty. - -Type: [Array](../../sql_reference/data_types/array.md) of [String](../../sql_reference/data_types/string.md). - -**Example** - -``` sql -SELECT splitByChar(',', '1,2,3,abcde') -``` - -``` text -┌─splitByChar(',', '1,2,3,abcde')─┐ -│ ['1','2','3','abcde'] │ -└─────────────────────────────────┘ -``` - -## splitByString(separator, s) {#splitbystringseparator-s} - -Splits a string into substrings separated by a string. It uses a constant string `separator` of multiple characters as the separator. If the string `separator` is empty, it will split the string `s` into an array of single characters. - -**Syntax** - -```sql -splitByString(, ) -``` - -**Parameters** - -- `separator` — The separator. [String](../../sql_reference/data_types/string.md). -- `s` — The string to split. [String](../../sql_reference/data_types/string.md). - -**Returned value(s)** - -Returns an array of selected substrings. Empty substrings may be selected when: - -Type: [Array](../../sql_reference/data_types/array.md) of [String](../../sql_reference/data_types/string.md). - -* A non-empty separator occurs at the beginning or end of the string; -* There are multiple consecutive non-empty separators; -* The original string `s` is empty while the separator is not empty. - -**Example** - -``` sql -SELECT splitByString(', ', '1, 2 3, 4,5, abcde') -``` - -``` text -┌─splitByString(', ', '1, 2 3, 4,5, abcde')─┐ -│ ['1','2 3','4,5','abcde'] │ -└───────────────────────────────────────────┘ -``` - -``` sql -SELECT splitByString('', 'abcde') -``` - -``` text -┌─splitByString('', 'abcde')─┐ -│ ['a','b','c','d','e'] │ -└────────────────────────────┘ -``` - -## arrayStringConcat(arr\[, separator\]) {#arraystringconcatarr-separator} - -Concatenates the strings listed in the array with the separator.’separator’ is an optional parameter: a constant string, set to an empty string by default. -Returns the string. - -## alphaTokens(s) {#alphatokenss} - -Selects substrings of consecutive bytes from the ranges a-z and A-Z.Returns an array of substrings. - -**Example** - -``` sql -SELECT alphaTokens('abca1abc') -``` - -``` text -┌─alphaTokens('abca1abc')─┐ -│ ['abca','abc'] │ -└─────────────────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/en/sql_reference/functions/string_functions.md b/docs/en/sql_reference/functions/string_functions.md deleted file mode 100644 index 5619f036d52..00000000000 --- a/docs/en/sql_reference/functions/string_functions.md +++ /dev/null @@ -1,487 +0,0 @@ ---- -toc_priority: 40 -toc_title: Working with strings ---- - -# Functions for working with strings {#functions-for-working-with-strings} - -## empty {#empty} - -Returns 1 for an empty string or 0 for a non-empty string. -The result type is UInt8. -A string is considered non-empty if it contains at least one byte, even if this is a space or a null byte. -The function also works for arrays. - -## notEmpty {#notempty} - -Returns 0 for an empty string or 1 for a non-empty string. -The result type is UInt8. -The function also works for arrays. - -## length {#length} - -Returns the length of a string in bytes (not in characters, and not in code points). -The result type is UInt64. -The function also works for arrays. - -## lengthUTF8 {#lengthutf8} - -Returns the length of a string in Unicode code points (not in characters), assuming that the string contains a set of bytes that make up UTF-8 encoded text. If this assumption is not met, it returns some result (it doesn’t throw an exception). -The result type is UInt64. - -## char\_length, CHAR\_LENGTH {#char-length} - -Returns the length of a string in Unicode code points (not in characters), assuming that the string contains a set of bytes that make up UTF-8 encoded text. If this assumption is not met, it returns some result (it doesn’t throw an exception). -The result type is UInt64. - -## character\_length, CHARACTER\_LENGTH {#character-length} - -Returns the length of a string in Unicode code points (not in characters), assuming that the string contains a set of bytes that make up UTF-8 encoded text. If this assumption is not met, it returns some result (it doesn’t throw an exception). -The result type is UInt64. - -## lower, lcase {#lower} - -Converts ASCII Latin symbols in a string to lowercase. - -## upper, ucase {#upper} - -Converts ASCII Latin symbols in a string to uppercase. - -## lowerUTF8 {#lowerutf8} - -Converts a string to lowercase, assuming the string contains a set of bytes that make up a UTF-8 encoded text. -It doesn’t detect the language. So for Turkish the result might not be exactly correct. -If the length of the UTF-8 byte sequence is different for upper and lower case of a code point, the result may be incorrect for this code point. -If the string contains a set of bytes that is not UTF-8, then the behavior is undefined. - -## upperUTF8 {#upperutf8} - -Converts a string to uppercase, assuming the string contains a set of bytes that make up a UTF-8 encoded text. -It doesn’t detect the language. So for Turkish the result might not be exactly correct. -If the length of the UTF-8 byte sequence is different for upper and lower case of a code point, the result may be incorrect for this code point. -If the string contains a set of bytes that is not UTF-8, then the behavior is undefined. - -## isValidUTF8 {#isvalidutf8} - -Returns 1, if the set of bytes is valid UTF-8 encoded, otherwise 0. - -## toValidUTF8 {#tovalidutf8} - -Replaces invalid UTF-8 characters by the `�` (U+FFFD) character. All running in a row invalid characters are collapsed into the one replacement character. - -``` sql -toValidUTF8( input_string ) -``` - -Parameters: - -- input\_string — Any set of bytes represented as the [String](../../sql_reference/data_types/string.md) data type object. - -Returned value: Valid UTF-8 string. - -**Example** - -``` sql -SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') -``` - -``` text -┌─toValidUTF8('a����b')─┐ -│ a�b │ -└───────────────────────┘ -``` - -## repeat {#repeat} - -Repeats a string as many times as specified and concatenates the replicated values as a single string. - -**Syntax** - -``` sql -repeat(s, n) -``` - -**Parameters** - -- `s` — The string to repeat. [String](../../sql_reference/data_types/string.md). -- `n` — The number of times to repeat the string. [UInt](../../sql_reference/data_types/int_uint.md). - -**Returned value** - -The single string, which contains the string `s` repeated `n` times. If `n` \< 1, the function returns empty string. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT repeat('abc', 10) -``` - -Result: - -``` text -┌─repeat('abc', 10)──────────────┐ -│ abcabcabcabcabcabcabcabcabcabc │ -└────────────────────────────────┘ -``` - -## reverse {#reverse} - -Reverses the string (as a sequence of bytes). - -## reverseUTF8 {#reverseutf8} - -Reverses a sequence of Unicode code points, assuming that the string contains a set of bytes representing a UTF-8 text. Otherwise, it does something else (it doesn’t throw an exception). - -## format(pattern, s0, s1, …) {#format} - -Formatting constant pattern with the string listed in the arguments. `pattern` is a simplified Python format pattern. Format string contains “replacement fields” surrounded by curly braces `{}`. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. If you need to include a brace character in the literal text, it can be escaped by doubling: `{{ '{{' }}` and `{{ '}}' }}`. Field names can be numbers (starting from zero) or empty (then they are treated as consequence numbers). - -``` sql -SELECT format('{1} {0} {1}', 'World', 'Hello') -``` - -``` text -┌─format('{1} {0} {1}', 'World', 'Hello')─┐ -│ Hello World Hello │ -└─────────────────────────────────────────┘ -``` - -``` sql -SELECT format('{} {}', 'Hello', 'World') -``` - -``` text -┌─format('{} {}', 'Hello', 'World')─┐ -│ Hello World │ -└───────────────────────────────────┘ -``` - -## concat {#concat} - -Concatenates the strings listed in the arguments, without a separator. - -**Syntax** - -``` sql -concat(s1, s2, ...) -``` - -**Parameters** - -Values of type String or FixedString. - -**Returned values** - -Returns the String that results from concatenating the arguments. - -If any of argument values is `NULL`, `concat` returns `NULL`. - -**Example** - -Query: - -``` sql -SELECT concat('Hello, ', 'World!') -``` - -Result: - -``` text -┌─concat('Hello, ', 'World!')─┐ -│ Hello, World! │ -└─────────────────────────────┘ -``` - -## concatAssumeInjective {#concatassumeinjective} - -Same as [concat](#concat), the difference is that you need to ensure that `concat(s1, s2, ...) → sn` is injective, it will be used for optimization of GROUP BY. - -The function is named “injective” if it always returns different result for different values of arguments. In other words: different arguments never yield identical result. - -**Syntax** - -``` sql -concatAssumeInjective(s1, s2, ...) -``` - -**Parameters** - -Values of type String or FixedString. - -**Returned values** - -Returns the String that results from concatenating the arguments. - -If any of argument values is `NULL`, `concatAssumeInjective` returns `NULL`. - -**Example** - -Input table: - -``` sql -CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog; -INSERT INTO key_val VALUES ('Hello, ','World',1), ('Hello, ','World',2), ('Hello, ','World!',3), ('Hello',', World!',2); -SELECT * from key_val; -``` - -``` text -┌─key1────┬─key2─────┬─value─┐ -│ Hello, │ World │ 1 │ -│ Hello, │ World │ 2 │ -│ Hello, │ World! │ 3 │ -│ Hello │ , World! │ 2 │ -└─────────┴──────────┴───────┘ -``` - -Query: - -``` sql -SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY concatAssumeInjective(key1, key2) -``` - -Result: - -``` text -┌─concat(key1, key2)─┬─sum(value)─┐ -│ Hello, World! │ 3 │ -│ Hello, World! │ 2 │ -│ Hello, World │ 3 │ -└────────────────────┴────────────┘ -``` - -## substring(s, offset, length), mid(s, offset, length), substr(s, offset, length) {#substring} - -Returns a substring starting with the byte from the ‘offset’ index that is ‘length’ bytes long. Character indexing starts from one (as in standard SQL). The ‘offset’ and ‘length’ arguments must be constants. - -## substringUTF8(s, offset, length) {#substringutf8} - -The same as ‘substring’, but for Unicode code points. Works under the assumption that the string contains a set of bytes representing a UTF-8 encoded text. If this assumption is not met, it returns some result (it doesn’t throw an exception). - -## appendTrailingCharIfAbsent(s, c) {#appendtrailingcharifabsent} - -If the ‘s’ string is non-empty and does not contain the ‘c’ character at the end, it appends the ‘c’ character to the end. - -## convertCharset(s, from, to) {#convertcharset} - -Returns the string ‘s’ that was converted from the encoding in ‘from’ to the encoding in ‘to’. - -## base64Encode(s) {#base64encode} - -Encodes ‘s’ string into base64 - -## base64Decode(s) {#base64decode} - -Decode base64-encoded string ‘s’ into original string. In case of failure raises an exception. - -## tryBase64Decode(s) {#trybase64decode} - -Similar to base64Decode, but in case of error an empty string would be returned. - -## endsWith(s, suffix) {#endswith} - -Returns whether to end with the specified suffix. Returns 1 if the string ends with the specified suffix, otherwise it returns 0. - -## startsWith(str, prefix) {#startswith} - -Returns 1 whether string starts with the specified prefix, otherwise it returns 0. - -``` sql -SELECT startsWith('Spider-Man', 'Spi'); -``` - -**Returned values** - -- 1, if the string starts with the specified prefix. -- 0, if the string doesn’t start with the specified prefix. - -**Example** - -Query: - -``` sql -SELECT startsWith('Hello, world!', 'He'); -``` - -Result: - -``` text -┌─startsWith('Hello, world!', 'He')─┐ -│ 1 │ -└───────────────────────────────────┘ -``` - -## trim {#trim} - -Removes all specified characters from the start or end of a string. -By default removes all consecutive occurrences of common whitespace (ASCII character 32) from both ends of a string. - -**Syntax** - -``` sql -trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) -``` - -**Parameters** - -- `trim_character` — specified characters for trim. [String](../../sql_reference/data_types/string.md). -- `input_string` — string for trim. [String](../../sql_reference/data_types/string.md). - -**Returned value** - -A string without leading and (or) trailing specified characters. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT trim(BOTH ' ()' FROM '( Hello, world! )') -``` - -Result: - -``` text -┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ -│ Hello, world! │ -└───────────────────────────────────────────────┘ -``` - -## trimLeft {#trimleft} - -Removes all consecutive occurrences of common whitespace (ASCII character 32) from the beginning of a string. It doesn’t remove other kinds of whitespace characters (tab, no-break space, etc.). - -**Syntax** - -``` sql -trimLeft(input_string) -``` - -Alias: `ltrim(input_string)`. - -**Parameters** - -- `input_string` — string to trim. [String](../../sql_reference/data_types/string.md). - -**Returned value** - -A string without leading common whitespaces. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT trimLeft(' Hello, world! ') -``` - -Result: - -``` text -┌─trimLeft(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## trimRight {#trimright} - -Removes all consecutive occurrences of common whitespace (ASCII character 32) from the end of a string. It doesn’t remove other kinds of whitespace characters (tab, no-break space, etc.). - -**Syntax** - -``` sql -trimRight(input_string) -``` - -Alias: `rtrim(input_string)`. - -**Parameters** - -- `input_string` — string to trim. [String](../../sql_reference/data_types/string.md). - -**Returned value** - -A string without trailing common whitespaces. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT trimRight(' Hello, world! ') -``` - -Result: - -``` text -┌─trimRight(' Hello, world! ')─┐ -│ Hello, world! │ -└──────────────────────────────────────┘ -``` - -## trimBoth {#trimboth} - -Removes all consecutive occurrences of common whitespace (ASCII character 32) from both ends of a string. It doesn’t remove other kinds of whitespace characters (tab, no-break space, etc.). - -**Syntax** - -``` sql -trimBoth(input_string) -``` - -Alias: `trim(input_string)`. - -**Parameters** - -- `input_string` — string to trim. [String](../../sql_reference/data_types/string.md). - -**Returned value** - -A string without leading and trailing common whitespaces. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT trimBoth(' Hello, world! ') -``` - -Result: - -``` text -┌─trimBoth(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## CRC32(s) {#crc32} - -Returns the CRC32 checksum of a string, using CRC-32-IEEE 802.3 polynomial and initial value `0xffffffff` (zlib implementation). - -The result type is UInt32. - -## CRC32IEEE(s) {#crc32ieee} - -Returns the CRC32 checksum of a string, using CRC-32-IEEE 802.3 polynomial. - -The result type is UInt32. - -## CRC64(s) {#crc64} - -Returns the CRC64 checksum of a string, using CRC-64-ECMA polynomial. - -The result type is UInt64. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/en/sql_reference/functions/string_replace_functions.md b/docs/en/sql_reference/functions/string_replace_functions.md deleted file mode 100644 index 1238937d7c0..00000000000 --- a/docs/en/sql_reference/functions/string_replace_functions.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -toc_priority: 42 -toc_title: For Replacing in Strings ---- - -# Functions for searching and replacing in strings {#functions-for-searching-and-replacing-in-strings} - -## replaceOne(haystack, pattern, replacement) {#replaceonehaystack-pattern-replacement} - -Replaces the first occurrence, if it exists, of the ‘pattern’ substring in ‘haystack’ with the ‘replacement’ substring. -Hereafter, ‘pattern’ and ‘replacement’ must be constants. - -## replaceAll(haystack, pattern, replacement), replace(haystack, pattern, replacement) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} - -Replaces all occurrences of the ‘pattern’ substring in ‘haystack’ with the ‘replacement’ substring. - -## replaceRegexpOne(haystack, pattern, replacement) {#replaceregexponehaystack-pattern-replacement} - -Replacement using the ‘pattern’ regular expression. A re2 regular expression. -Replaces only the first occurrence, if it exists. -A pattern can be specified as ‘replacement’. This pattern can include substitutions `\0-\9`. -The substitution `\0` includes the entire regular expression. Substitutions `\1-\9` correspond to the subpattern numbers.To use the `\` character in a template, escape it using `\`. -Also keep in mind that a string literal requires an extra escape. - -Example 1. Converting the date to American format: - -``` sql -SELECT DISTINCT - EventDate, - replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res -FROM test.hits -LIMIT 7 -FORMAT TabSeparated -``` - -``` text -2014-03-17 03/17/2014 -2014-03-18 03/18/2014 -2014-03-19 03/19/2014 -2014-03-20 03/20/2014 -2014-03-21 03/21/2014 -2014-03-22 03/22/2014 -2014-03-23 03/23/2014 -``` - -Example 2. Copying a string ten times: - -``` sql -SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res -``` - -``` text -┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## replaceRegexpAll(haystack, pattern, replacement) {#replaceregexpallhaystack-pattern-replacement} - -This does the same thing, but replaces all the occurrences. Example: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res -``` - -``` text -┌─res────────────────────────┐ -│ HHeelllloo,, WWoorrlldd!! │ -└────────────────────────────┘ -``` - -As an exception, if a regular expression worked on an empty substring, the replacement is not made more than once. -Example: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res -``` - -``` text -┌─res─────────────────┐ -│ here: Hello, World! │ -└─────────────────────┘ -``` - -## regexpQuoteMeta(s) {#regexpquotemetas} - -The function adds a backslash before some predefined characters in the string. -Predefined characters: ‘0’, ‘\\’, ‘\|’, ‘(’, ‘)’, ‘^’, ‘$’, ‘.’, ‘\[’, ’\]’, ‘?’, ’\*‘,’+‘,’{‘,’:‘,’-’. -This implementation slightly differs from re2::RE2::QuoteMeta. It escapes zero byte as \\0 instead of 00 and it escapes only required characters. -For more information, see the link: [RE2](https://github.com/google/re2/blob/master/re2/re2.cc#L473) - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/en/sql_reference/functions/string_search_functions.md b/docs/en/sql_reference/functions/string_search_functions.md deleted file mode 100644 index 180830c0842..00000000000 --- a/docs/en/sql_reference/functions/string_search_functions.md +++ /dev/null @@ -1,377 +0,0 @@ ---- -toc_priority: 41 -toc_title: For Searching Strings ---- - -# Functions for Searching Strings {#functions-for-searching-strings} - -The search is case-sensitive by default in all these functions. There are separate variants for case insensitive search. - -## position(haystack, needle), locate(haystack, needle) {#position} - -Returns the position (in bytes) of the found substring in the string, starting from 1. - -Works under the assumption that the string contains a set of bytes representing a single-byte encoded text. If this assumption is not met and a character can’t be represented using a single byte, the function doesn’t throw an exception and returns some unexpected result. If character can be represented using two bytes, it will use two bytes and so on. - -For a case-insensitive search, use the function [positionCaseInsensitive](#positioncaseinsensitive). - -**Syntax** - -``` sql -position(haystack, needle) -``` - -Alias: `locate(haystack, needle)`. - -**Parameters** - -- `haystack` — string, in which substring will to be searched. [String](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [String](../syntax.md#syntax-string-literal). - -**Returned values** - -- Starting position in bytes (counting from 1), if substring was found. -- 0, if the substring was not found. - -Type: `Integer`. - -**Examples** - -The phrase “Hello, world!” contains a set of bytes representing a single-byte encoded text. The function returns some expected result: - -Query: - -``` sql -SELECT position('Hello, world!', '!') -``` - -Result: - -``` text -┌─position('Hello, world!', '!')─┐ -│ 13 │ -└────────────────────────────────┘ -``` - -The same phrase in Russian contains characters which can’t be represented using a single byte. The function returns some unexpected result (use [positionUTF8](#positionutf8) function for multi-byte encoded text): - -Query: - -``` sql -SELECT position('Привет, мир!', '!') -``` - -Result: - -``` text -┌─position('Привет, мир!', '!')─┐ -│ 21 │ -└───────────────────────────────┘ -``` - -## positionCaseInsensitive {#positioncaseinsensitive} - -The same as [position](#position) returns the position (in bytes) of the found substring in the string, starting from 1. Use the function for a case-insensitive search. - -Works under the assumption that the string contains a set of bytes representing a single-byte encoded text. If this assumption is not met and a character can’t be represented using a single byte, the function doesn’t throw an exception and returns some unexpected result. If character can be represented using two bytes, it will use two bytes and so on. - -**Syntax** - -``` sql -positionCaseInsensitive(haystack, needle) -``` - -**Parameters** - -- `haystack` — string, in which substring will to be searched. [String](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [String](../syntax.md#syntax-string-literal). - -**Returned values** - -- Starting position in bytes (counting from 1), if substring was found. -- 0, if the substring was not found. - -Type: `Integer`. - -**Example** - -Query: - -``` sql -SELECT positionCaseInsensitive('Hello, world!', 'hello') -``` - -Result: - -``` text -┌─positionCaseInsensitive('Hello, world!', 'hello')─┐ -│ 1 │ -└───────────────────────────────────────────────────┘ -``` - -## positionUTF8 {#positionutf8} - -Returns the position (in Unicode points) of the found substring in the string, starting from 1. - -Works under the assumption that the string contains a set of bytes representing a UTF-8 encoded text. If this assumption is not met, the function doesn’t throw an exception and returns some unexpected result. If character can be represented using two Unicode points, it will use two and so on. - -For a case-insensitive search, use the function [positionCaseInsensitiveUTF8](#positioncaseinsensitiveutf8). - -**Syntax** - -``` sql -positionUTF8(haystack, needle) -``` - -**Parameters** - -- `haystack` — string, in which substring will to be searched. [String](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [String](../syntax.md#syntax-string-literal). - -**Returned values** - -- Starting position in Unicode points (counting from 1), if substring was found. -- 0, if the substring was not found. - -Type: `Integer`. - -**Examples** - -The phrase “Hello, world!” in Russian contains a set of Unicode points representing a single-point encoded text. The function returns some expected result: - -Query: - -``` sql -SELECT positionUTF8('Привет, мир!', '!') -``` - -Result: - -``` text -┌─positionUTF8('Привет, мир!', '!')─┐ -│ 12 │ -└───────────────────────────────────┘ -``` - -The phrase “Salut, étudiante!”, where character `é` can be represented using a one point (`U+00E9`) or two points (`U+0065U+0301`) the function can be returned some unexpected result: - -Query for the letter `é`, which is represented one Unicode point `U+00E9`: - -``` sql -SELECT positionUTF8('Salut, étudiante!', '!') -``` - -Result: - -``` text -┌─positionUTF8('Salut, étudiante!', '!')─┐ -│ 17 │ -└────────────────────────────────────────┘ -``` - -Query for the letter `é`, which is represented two Unicode points `U+0065U+0301`: - -``` sql -SELECT positionUTF8('Salut, étudiante!', '!') -``` - -Result: - -``` text -┌─positionUTF8('Salut, étudiante!', '!')─┐ -│ 18 │ -└────────────────────────────────────────┘ -``` - -## positionCaseInsensitiveUTF8 {#positioncaseinsensitiveutf8} - -The same as [positionUTF8](#positionutf8), but is case-insensitive. Returns the position (in Unicode points) of the found substring in the string, starting from 1. - -Works under the assumption that the string contains a set of bytes representing a UTF-8 encoded text. If this assumption is not met, the function doesn’t throw an exception and returns some unexpected result. If character can be represented using two Unicode points, it will use two and so on. - -**Syntax** - -``` sql -positionCaseInsensitiveUTF8(haystack, needle) -``` - -**Parameters** - -- `haystack` — string, in which substring will to be searched. [String](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [String](../syntax.md#syntax-string-literal). - -**Returned value** - -- Starting position in Unicode points (counting from 1), if substring was found. -- 0, if the substring was not found. - -Type: `Integer`. - -**Example** - -Query: - -``` sql -SELECT positionCaseInsensitiveUTF8('Привет, мир!', 'Мир') -``` - -Result: - -``` text -┌─positionCaseInsensitiveUTF8('Привет, мир!', 'Мир')─┐ -│ 9 │ -└────────────────────────────────────────────────────┘ -``` - -## multiSearchAllPositions {#multisearchallpositions} - -The same as [position](string_search_functions.md#position) but returns `Array` of positions (in bytes) of the found corresponding substrings in the string. Positions are indexed starting from 1. - -The search is performed on sequences of bytes without respect to string encoding and collation. - -- For case-insensitive ASCII search, use the function `multiSearchAllPositionsCaseInsensitive`. -- For search in UTF-8, use the function [multiSearchAllPositionsUTF8](#multiSearchAllPositionsUTF8). -- For case-insensitive UTF-8 search, use the function multiSearchAllPositionsCaseInsensitiveUTF8. - -**Syntax** - -``` sql -multiSearchAllPositions(haystack, [needle1, needle2, ..., needlen]) -``` - -**Parameters** - -- `haystack` — string, in which substring will to be searched. [String](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [String](../syntax.md#syntax-string-literal). - -**Returned values** - -- Array of starting positions in bytes (counting from 1), if the corresponding substring was found and 0 if not found. - -**Example** - -Query: - -``` sql -SELECT multiSearchAllPositions('Hello, World!', ['hello', '!', 'world']) -``` - -Result: - -``` text -┌─multiSearchAllPositions('Hello, World!', ['hello', '!', 'world'])─┐ -│ [0,13,0] │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## multiSearchAllPositionsUTF8 {#multiSearchAllPositionsUTF8} - -See `multiSearchAllPositions`. - -## multiSearchFirstPosition(haystack, \[needle1, needle2, …, needlen\]) {#multisearchfirstposition} - -The same as `position` but returns the leftmost offset of the string `haystack` that is matched to some of the needles. - -For a case-insensitive search or/and in UTF-8 format use functions `multiSearchFirstPositionCaseInsensitive, multiSearchFirstPositionUTF8, multiSearchFirstPositionCaseInsensitiveUTF8`. - -## multiSearchFirstIndex(haystack, \[needle1, needle2, …, needlen\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} - -Returns the index `i` (starting from 1) of the leftmost found needlei in the string `haystack` and 0 otherwise. - -For a case-insensitive search or/and in UTF-8 format use functions `multiSearchFirstIndexCaseInsensitive, multiSearchFirstIndexUTF8, multiSearchFirstIndexCaseInsensitiveUTF8`. - -## multiSearchAny(haystack, \[needle1, needle2, …, needlen\]) {#function-multisearchany} - -Returns 1, if at least one string needlei matches the string `haystack` and 0 otherwise. - -For a case-insensitive search or/and in UTF-8 format use functions `multiSearchAnyCaseInsensitive, multiSearchAnyUTF8, multiSearchAnyCaseInsensitiveUTF8`. - -!!! note "Note" - In all `multiSearch*` functions the number of needles should be less than 28 because of implementation specification. - -## match(haystack, pattern) {#matchhaystack-pattern} - -Checks whether the string matches the `pattern` regular expression. A `re2` regular expression. The [syntax](https://github.com/google/re2/wiki/Syntax) of the `re2` regular expressions is more limited than the syntax of the Perl regular expressions. - -Returns 0 if it doesn’t match, or 1 if it matches. - -Note that the backslash symbol (`\`) is used for escaping in the regular expression. The same symbol is used for escaping in string literals. So in order to escape the symbol in a regular expression, you must write two backslashes (\\) in a string literal. - -The regular expression works with the string as if it is a set of bytes. The regular expression can’t contain null bytes. -For patterns to search for substrings in a string, it is better to use LIKE or ‘position’, since they work much faster. - -## multiMatchAny(haystack, \[pattern1, pattern2, …, patternn\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} - -The same as `match`, but returns 0 if none of the regular expressions are matched and 1 if any of the patterns matches. It uses [hyperscan](https://github.com/intel/hyperscan) library. For patterns to search substrings in a string, it is better to use `multiSearchAny` since it works much faster. - -!!! note "Note" - The length of any of the `haystack` string must be less than 232 bytes otherwise the exception is thrown. This restriction takes place because of hyperscan API. - -## multiMatchAnyIndex(haystack, \[pattern1, pattern2, …, patternn\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} - -The same as `multiMatchAny`, but returns any index that matches the haystack. - -## multiMatchAllIndices(haystack, \[pattern1, pattern2, …, patternn\]) {#multimatchallindiceshaystack-pattern1-pattern2-patternn} - -The same as `multiMatchAny`, but returns the array of all indicies that match the haystack in any order. - -## multiFuzzyMatchAny(haystack, distance, \[pattern1, pattern2, …, patternn\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} - -The same as `multiMatchAny`, but returns 1 if any pattern matches the haystack within a constant [edit distance](https://en.wikipedia.org/wiki/Edit_distance). This function is also in an experimental mode and can be extremely slow. For more information see [hyperscan documentation](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching). - -## multiFuzzyMatchAnyIndex(haystack, distance, \[pattern1, pattern2, …, patternn\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} - -The same as `multiFuzzyMatchAny`, but returns any index that matches the haystack within a constant edit distance. - -## multiFuzzyMatchAllIndices(haystack, distance, \[pattern1, pattern2, …, patternn\]) {#multifuzzymatchallindiceshaystack-distance-pattern1-pattern2-patternn} - -The same as `multiFuzzyMatchAny`, but returns the array of all indices in any order that match the haystack within a constant edit distance. - -!!! note "Note" - `multiFuzzyMatch*` functions do not support UTF-8 regular expressions, and such expressions are treated as bytes because of hyperscan restriction. - -!!! note "Note" - To turn off all functions that use hyperscan, use setting `SET allow_hyperscan = 0;`. - -## extract(haystack, pattern) {#extracthaystack-pattern} - -Extracts a fragment of a string using a regular expression. If ‘haystack’ doesn’t match the ‘pattern’ regex, an empty string is returned. If the regex doesn’t contain subpatterns, it takes the fragment that matches the entire regex. Otherwise, it takes the fragment that matches the first subpattern. - -## extractAll(haystack, pattern) {#extractallhaystack-pattern} - -Extracts all the fragments of a string using a regular expression. If ‘haystack’ doesn’t match the ‘pattern’ regex, an empty string is returned. Returns an array of strings consisting of all matches to the regex. In general, the behavior is the same as the ‘extract’ function (it takes the first subpattern, or the entire expression if there isn’t a subpattern). - -## like(haystack, pattern), haystack LIKE pattern operator {#function-like} - -Checks whether a string matches a simple regular expression. -The regular expression can contain the metasymbols `%` and `_`. - -`%` indicates any quantity of any bytes (including zero characters). - -`_` indicates any one byte. - -Use the backslash (`\`) for escaping metasymbols. See the note on escaping in the description of the ‘match’ function. - -For regular expressions like `%needle%`, the code is more optimal and works as fast as the `position` function. -For other regular expressions, the code is the same as for the ‘match’ function. - -## notLike(haystack, pattern), haystack NOT LIKE pattern operator {#function-notlike} - -The same thing as ‘like’, but negative. - -## ngramDistance(haystack, needle) {#ngramdistancehaystack-needle} - -Calculates the 4-gram distance between `haystack` and `needle`: counts the symmetric difference between two multisets of 4-grams and normalizes it by the sum of their cardinalities. Returns float number from 0 to 1 – the closer to zero, the more strings are similar to each other. If the constant `needle` or `haystack` is more than 32Kb, throws an exception. If some of the non-constant `haystack` or `needle` strings are more than 32Kb, the distance is always one. - -For case-insensitive search or/and in UTF-8 format use functions `ngramDistanceCaseInsensitive, ngramDistanceUTF8, ngramDistanceCaseInsensitiveUTF8`. - -## ngramSearch(haystack, needle) {#ngramsearchhaystack-needle} - -Same as `ngramDistance` but calculates the non-symmetric difference between `needle` and `haystack` – the number of n-grams from needle minus the common number of n-grams normalized by the number of `needle` n-grams. The closer to one, the more likely `needle` is in the `haystack`. Can be useful for fuzzy string search. - -For case-insensitive search or/and in UTF-8 format use functions `ngramSearchCaseInsensitive, ngramSearchUTF8, ngramSearchCaseInsensitiveUTF8`. - -!!! note "Note" - For UTF-8 case we use 3-gram distance. All these are not perfectly fair n-gram distances. We use 2-byte hashes to hash n-grams and then calculate the (non-)symmetric difference between these hash tables – collisions may occur. With UTF-8 case-insensitive format we do not use fair `tolower` function – we zero the 5-th bit (starting from zero) of each codepoint byte and first bit of zeroth byte if bytes more than one – this works for Latin and mostly for all Cyrillic letters. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/en/sql_reference/functions/type_conversion_functions.md b/docs/en/sql_reference/functions/type_conversion_functions.md deleted file mode 100644 index a61e1e692d8..00000000000 --- a/docs/en/sql_reference/functions/type_conversion_functions.md +++ /dev/null @@ -1,534 +0,0 @@ ---- -toc_priority: 38 -toc_title: Type Conversion ---- - -# Type Conversion Functions {#type-conversion-functions} - -## Common Issues of Numeric Conversions {#numeric-conversion-issues} - -When you convert a value from one to another data type, you should remember that in common case, it is an unsafe operation that can lead to a data loss. A data loss can occur if you try to fit value from a larger data type to a smaller data type, or if you convert values between different data types. - -ClickHouse has the [same behavior as C++ programs](https://en.cppreference.com/w/cpp/language/implicit_conversion). - -## toInt(8\|16\|32\|64) {#toint8163264} - -Converts an input value to the [Int](../../sql_reference/data_types/int_uint.md) data type. This function family includes: - -- `toInt8(expr)` — Results in the `Int8` data type. -- `toInt16(expr)` — Results in the `Int16` data type. -- `toInt32(expr)` — Results in the `Int32` data type. -- `toInt64(expr)` — Results in the `Int64` data type. - -**Parameters** - -- `expr` — [Expression](../syntax.md#syntax-expressions) returning a number or a string with the decimal representation of a number. Binary, octal, and hexadecimal representations of numbers are not supported. Leading zeroes are stripped. - -**Returned value** - -Integer value in the `Int8`, `Int16`, `Int32`, or `Int64` data type. - -Functions use [rounding towards zero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero), meaning they truncate fractional digits of numbers. - -The behavior of functions for the [NaN and Inf](../../sql_reference/data_types/float.md#data_type-float-nan-inf) arguments is undefined. Remember about [numeric convertions issues](#numeric-conversion-issues), when using the functions. - -**Example** - -``` sql -SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) -``` - -``` text -┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ -│ -9223372036854775808 │ 32 │ 16 │ 8 │ -└──────────────────────┴─────────────┴───────────────┴─────────────┘ -``` - -## toInt(8\|16\|32\|64)OrZero {#toint8163264orzero} - -It takes an argument of type String and tries to parse it into Int (8 \| 16 \| 32 \| 64). If failed, returns 0. - -**Example** - -``` sql -select toInt64OrZero('123123'), toInt8OrZero('123qwe123') -``` - -``` text -┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ -│ 123123 │ 0 │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toInt(8\|16\|32\|64)OrNull {#toint8163264ornull} - -It takes an argument of type String and tries to parse it into Int (8 \| 16 \| 32 \| 64). If failed, returns NULL. - -**Example** - -``` sql -select toInt64OrNull('123123'), toInt8OrNull('123qwe123') -``` - -``` text -┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ -│ 123123 │ ᴺᵁᴸᴸ │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toUInt(8\|16\|32\|64) {#touint8163264} - -Converts an input value to the [UInt](../../sql_reference/data_types/int_uint.md) data type. This function family includes: - -- `toUInt8(expr)` — Results in the `UInt8` data type. -- `toUInt16(expr)` — Results in the `UInt16` data type. -- `toUInt32(expr)` — Results in the `UInt32` data type. -- `toUInt64(expr)` — Results in the `UInt64` data type. - -**Parameters** - -- `expr` — [Expression](../syntax.md#syntax-expressions) returning a number or a string with the decimal representation of a number. Binary, octal, and hexadecimal representations of numbers are not supported. Leading zeroes are stripped. - -**Returned value** - -Integer value in the `UInt8`, `UInt16`, `UInt32`, or `UInt64` data type. - -Functions use [rounding towards zero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero), meaning they truncate fractional digits of numbers. - -The behavior of functions for negative agruments and for the [NaN and Inf](../../sql_reference/data_types/float.md#data_type-float-nan-inf) arguments is undefined. If you pass a string with a negative number, for example `'-32'`, ClickHouse raises an exception. Remember about [numeric convertions issues](#numeric-conversion-issues), when using the functions. - -**Example** - -``` sql -SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) -``` - -``` text -┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ -│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ -└─────────────────────┴───────────────┴────────────────┴──────────────┘ -``` - -## toUInt(8\|16\|32\|64)OrZero {#touint8163264orzero} - -## toUInt(8\|16\|32\|64)OrNull {#touint8163264ornull} - -## toFloat(32\|64) {#tofloat3264} - -## toFloat(32\|64)OrZero {#tofloat3264orzero} - -## toFloat(32\|64)OrNull {#tofloat3264ornull} - -## toDate {#todate} - -## toDateOrZero {#todateorzero} - -## toDateOrNull {#todateornull} - -## toDateTime {#todatetime} - -## toDateTimeOrZero {#todatetimeorzero} - -## toDateTimeOrNull {#todatetimeornull} - -## toDecimal(32\|64\|128) {#todecimal3264128} - -Converts `value` to the [Decimal](../../sql_reference/data_types/decimal.md) data type with precision of `S`. The `value` can be a number or a string. The `S` (scale) parameter specifies the number of decimal places. - -- `toDecimal32(value, S)` -- `toDecimal64(value, S)` -- `toDecimal128(value, S)` - -## toDecimal(32\|64\|128)OrNull {#todecimal3264128ornull} - -Converts an input string to a [Nullable(Decimal(P,S))](../../sql_reference/data_types/decimal.md) data type value. This family of functions include: - -- `toDecimal32OrNull(expr, S)` — Results in `Nullable(Decimal32(S))` data type. -- `toDecimal64OrNull(expr, S)` — Results in `Nullable(Decimal64(S))` data type. -- `toDecimal128OrNull(expr, S)` — Results in `Nullable(Decimal128(S))` data type. - -These functions should be used instead of `toDecimal*()` functions, if you prefer to get a `NULL` value instead of an exception in the event of an input value parsing error. - -**Parameters** - -- `expr` — [Expression](../syntax.md#syntax-expressions), returns a value in the [String](../../sql_reference/data_types/string.md) data type. ClickHouse expects the textual representation of the decimal number. For example, `'1.111'`. -- `S` — Scale, the number of decimal places in the resulting value. - -**Returned value** - -A value in the `Nullable(Decimal(P,S))` data type. The value contains: - -- Number with `S` decimal places, if ClickHouse interprets the input string as a number. -- `NULL`, if ClickHouse can’t interpret the input string as a number or if the input number contains more than `S` decimal places. - -**Examples** - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ -│ -1.11100 │ Nullable(Decimal(9, 5)) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ -│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toDecimal(32\|64\|128)OrZero {#todecimal3264128orzero} - -Converts an input value to the [Decimal(P,S)](../../sql_reference/data_types/decimal.md) data type. This family of functions include: - -- `toDecimal32OrZero( expr, S)` — Results in `Decimal32(S)` data type. -- `toDecimal64OrZero( expr, S)` — Results in `Decimal64(S)` data type. -- `toDecimal128OrZero( expr, S)` — Results in `Decimal128(S)` data type. - -These functions should be used instead of `toDecimal*()` functions, if you prefer to get a `0` value instead of an exception in the event of an input value parsing error. - -**Parameters** - -- `expr` — [Expression](../syntax.md#syntax-expressions), returns a value in the [String](../../sql_reference/data_types/string.md) data type. ClickHouse expects the textual representation of the decimal number. For example, `'1.111'`. -- `S` — Scale, the number of decimal places in the resulting value. - -**Returned value** - -A value in the `Nullable(Decimal(P,S))` data type. The value contains: - -- Number with `S` decimal places, if ClickHouse interprets the input string as a number. -- 0 with `S` decimal places, if ClickHouse can’t interpret the input string as a number or if the input number contains more than `S` decimal places. - -**Example** - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ -│ -1.11100 │ Decimal(9, 5) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ -│ 0.00 │ Decimal(9, 2) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toString {#tostring} - -Functions for converting between numbers, strings (but not fixed strings), dates, and dates with times. -All these functions accept one argument. - -When converting to or from a string, the value is formatted or parsed using the same rules as for the TabSeparated format (and almost all other text formats). If the string can’t be parsed, an exception is thrown and the request is canceled. - -When converting dates to numbers or vice versa, the date corresponds to the number of days since the beginning of the Unix epoch. -When converting dates with times to numbers or vice versa, the date with time corresponds to the number of seconds since the beginning of the Unix epoch. - -The date and date-with-time formats for the toDate/toDateTime functions are defined as follows: - -``` text -YYYY-MM-DD -YYYY-MM-DD hh:mm:ss -``` - -As an exception, if converting from UInt32, Int32, UInt64, or Int64 numeric types to Date, and if the number is greater than or equal to 65536, the number is interpreted as a Unix timestamp (and not as the number of days) and is rounded to the date. This allows support for the common occurrence of writing ‘toDate(unix\_timestamp)’, which otherwise would be an error and would require writing the more cumbersome ‘toDate(toDateTime(unix\_timestamp))’. - -Conversion between a date and date with time is performed the natural way: by adding a null time or dropping the time. - -Conversion between numeric types uses the same rules as assignments between different numeric types in C++. - -Additionally, the toString function of the DateTime argument can take a second String argument containing the name of the time zone. Example: `Asia/Yekaterinburg` In this case, the time is formatted according to the specified time zone. - -``` sql -SELECT - now() AS now_local, - toString(now(), 'Asia/Yekaterinburg') AS now_yekat -``` - -``` text -┌───────────now_local─┬─now_yekat───────────┐ -│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ -└─────────────────────┴─────────────────────┘ -``` - -Also see the `toUnixTimestamp` function. - -## toFixedString(s, N) {#tofixedstrings-n} - -Converts a String type argument to a FixedString(N) type (a string with fixed length N). N must be a constant. -If the string has fewer bytes than N, it is passed with null bytes to the right. If the string has more bytes than N, an exception is thrown. - -## toStringCutToZero(s) {#tostringcuttozeros} - -Accepts a String or FixedString argument. Returns the String with the content truncated at the first zero byte found. - -Example: - -``` sql -SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s─────────────┬─s_cut─┐ -│ foo\0\0\0\0\0 │ foo │ -└───────────────┴───────┘ -``` - -``` sql -SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s──────────┬─s_cut─┐ -│ foo\0bar\0 │ foo │ -└────────────┴───────┘ -``` - -## reinterpretAsUInt(8\|16\|32\|64) {#reinterpretasuint8163264} - -## reinterpretAsInt(8\|16\|32\|64) {#reinterpretasint8163264} - -## reinterpretAsFloat(32\|64) {#reinterpretasfloat3264} - -## reinterpretAsDate {#reinterpretasdate} - -## reinterpretAsDateTime {#reinterpretasdatetime} - -These functions accept a string and interpret the bytes placed at the beginning of the string as a number in host order (little endian). If the string isn’t long enough, the functions work as if the string is padded with the necessary number of null bytes. If the string is longer than needed, the extra bytes are ignored. A date is interpreted as the number of days since the beginning of the Unix Epoch, and a date with time is interpreted as the number of seconds since the beginning of the Unix Epoch. - -## reinterpretAsString {#type_conversion_functions-reinterpretAsString} - -This function accepts a number or date or date with time, and returns a string containing bytes representing the corresponding value in host order (little endian). Null bytes are dropped from the end. For example, a UInt32 type value of 255 is a string that is one byte long. - -## reinterpretAsFixedString {#reinterpretasfixedstring} - -This function accepts a number or date or date with time, and returns a FixedString containing bytes representing the corresponding value in host order (little endian). Null bytes are dropped from the end. For example, a UInt32 type value of 255 is a FixedString that is one byte long. - -## CAST(x, t) {#type_conversion_function-cast} - -Converts ‘x’ to the ‘t’ data type. The syntax CAST(x AS t) is also supported. - -Example: - -``` sql -SELECT - '2016-06-15 23:00:00' AS timestamp, - CAST(timestamp AS DateTime) AS datetime, - CAST(timestamp AS Date) AS date, - CAST(timestamp, 'String') AS string, - CAST(timestamp, 'FixedString(22)') AS fixed_string -``` - -``` text -┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ -└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ -``` - -Conversion to FixedString(N) only works for arguments of type String or FixedString(N). - -Type conversion to [Nullable](../../sql_reference/data_types/nullable.md) and back is supported. Example: - -``` sql -SELECT toTypeName(x) FROM t_null -``` - -``` text -┌─toTypeName(x)─┐ -│ Int8 │ -│ Int8 │ -└───────────────┘ -``` - -``` sql -SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null -``` - -``` text -┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ -│ Nullable(UInt16) │ -│ Nullable(UInt16) │ -└─────────────────────────────────────────┘ -``` - -## toInterval(Year\|Quarter\|Month\|Week\|Day\|Hour\|Minute\|Second) {#function-tointerval} - -Converts a Number type argument to an [Interval](../../sql_reference/data_types/special_data_types/interval.md) data type. - -**Syntax** - -``` sql -toIntervalSecond(number) -toIntervalMinute(number) -toIntervalHour(number) -toIntervalDay(number) -toIntervalWeek(number) -toIntervalMonth(number) -toIntervalQuarter(number) -toIntervalYear(number) -``` - -**Parameters** - -- `number` — Duration of interval. Positive integer number. - -**Returned values** - -- The value in `Interval` data type. - -**Example** - -``` sql -WITH - toDate('2019-01-01') AS date, - INTERVAL 1 WEEK AS interval_week, - toIntervalWeek(1) AS interval_to_week -SELECT - date + interval_week, - date + interval_to_week -``` - -``` text -┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ -│ 2019-01-08 │ 2019-01-08 │ -└───────────────────────────┴──────────────────────────────┘ -``` - -## parseDateTimeBestEffort {#parsedatetimebesteffort} - -Converts a date and time in the [String](../../sql_reference/data_types/string.md) representation to [DateTime](../../sql_reference/data_types/datetime.md#data_type-datetime) data type. - -The function parses [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55), ClickHouse's and some other date and time formats. - - -**Syntax** - -```sql -parseDateTimeBestEffort(time_string [, time_zone]); -``` - -**Parameters** - -- `time_string` — String containing a date and time to convert. [String](../../sql_reference/data_types/string.md). -- `time_zone` — Time zone. The function parses `time_string` according to the time zone. [String](../../sql_reference/data_types/string.md). - - -**Supported non-standard formats** - -- A string containing 9..10 digit [unix timestamp](https://en.wikipedia.org/wiki/Unix_time). -- A string with a date and a time component: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`, etc. -- A string with a date, but no time component: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` etc. -- A string with a day and time: `DD`, `DD hh`, `DD hh:mm`. In this case `YYYY-MM` are substituted as `2000-01`. -- A string that includes the date and time along with time zone offset information: `YYYY-MM-DD hh:mm:ss ±h:mm`, etc. For example, `2020-12-12 17:36:00 -5:00`. - -For all of the formats with separator the function parses months names expressed by their full name or by the first three letters of a month name. Examples: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. - -**Returned value** - -- `time_string` converted to the `DateTime` data type. - -**Examples** - -Query: - -```sql -SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') -AS parseDateTimeBestEffort; -``` - -Result: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2020-12-12 12:12:57 │ -└─────────────────────────┘ -``` - -Query: - -```sql -SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') -AS parseDateTimeBestEffort -``` - -Result: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2018-08-18 10:22:16 │ -└─────────────────────────┘ -``` - -Query: - -```sql -SELECT parseDateTimeBestEffort('1284101485') -AS parseDateTimeBestEffort -``` - -Result: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2015-07-07 12:04:41 │ -└─────────────────────────┘ -``` - -Query: - -```sql -SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') -AS parseDateTimeBestEffort -``` - -Result: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2018-12-12 10:12:12 │ -└─────────────────────────┘ -``` - -Query: - -```sql -SELECT parseDateTimeBestEffort('10 20:19') -``` - -Result: - -```text -┌─parseDateTimeBestEffort('10 20:19')─┐ -│ 2000-01-10 20:19:00 │ -└─────────────────────────────────────┘ -``` - -**See Also** - -- [ISO 8601 announcement by @xkcd](https://xkcd.com/1179/) -- [RFC 1123](https://tools.ietf.org/html/rfc1123) -- [toDate](#todate) -- [toDateTime](#todatetime) - -## parseDateTimeBestEffortOrNull {#parsedatetimebesteffortornull} - -Same as for [parseDateTimeBestEffort](#parsedatetimebesteffort) except that it returns null when it encounters a date format that cannot be processed. - -## parseDateTimeBestEffortOrZero {#parsedatetimebesteffortorzero} - -Same as for [parseDateTimeBestEffort](#parsedatetimebesteffort) except that it returns zero date or zero date time when it encounters a date format that cannot be processed. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/en/sql_reference/functions/url_functions.md b/docs/en/sql_reference/functions/url_functions.md deleted file mode 100644 index 205fb4bc068..00000000000 --- a/docs/en/sql_reference/functions/url_functions.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -toc_priority: 54 -toc_title: Working with URLs ---- - -# Functions for working with URLs {#functions-for-working-with-urls} - -All these functions don’t follow the RFC. They are maximally simplified for improved performance. - -## Functions that Extract Parts of a URL {#functions-that-extract-parts-of-a-url} - -If the relevant part isn’t present in a URL, an empty string is returned. - -### protocol {#protocol} - -Extracts the protocol from a URL. - -Examples of typical returned values: http, https, ftp, mailto, tel, magnet… - -### domain {#domain} - -Extracts the hostname from a URL. - -``` sql -domain(url) -``` - -**Parameters** - -- `url` — URL. Type: [String](../../sql_reference/data_types/string.md). - -The URL can be specified with or without a scheme. Examples: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -For these examples, the `domain` function returns the following results: - -``` text -some.svn-hosting.com -some.svn-hosting.com -yandex.com -``` - -**Returned values** - -- Host name. If ClickHouse can parse the input string as a URL. -- Empty string. If ClickHouse can’t parse the input string as a URL. - -Type: `String`. - -**Example** - -``` sql -SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ -│ some.svn-hosting.com │ -└────────────────────────────────────────────────────────┘ -``` - -### domainWithoutWWW {#domainwithoutwww} - -Returns the domain and removes no more than one ‘www.’ from the beginning of it, if present. - -### topLevelDomain {#topleveldomain} - -Extracts the the top-level domain from a URL. - -``` sql -topLevelDomain(url) -``` - -**Parameters** - -- `url` — URL. Type: [String](../../sql_reference/data_types/string.md). - -The URL can be specified with or without a scheme. Examples: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -**Returned values** - -- Domain name. If ClickHouse can parse the input string as a URL. -- Empty string. If ClickHouse cannot parse the input string as a URL. - -Type: `String`. - -**Example** - -``` sql -SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ -│ com │ -└────────────────────────────────────────────────────────────────────┘ -``` - -### firstSignificantSubdomain {#firstsignificantsubdomain} - -Returns the “first significant subdomain”. This is a non-standard concept specific to Yandex.Metrica. The first significant subdomain is a second-level domain if it is ‘com’, ‘net’, ‘org’, or ‘co’. Otherwise, it is a third-level domain. For example, `firstSignificantSubdomain (‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’`. The list of “insignificant” second-level domains and other implementation details may change in the future. - -### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} - -Returns the part of the domain that includes top-level subdomains up to the “first significant subdomain” (see the explanation above). - -For example, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. - -### path {#path} - -Returns the path. Example: `/top/news.html` The path does not include the query string. - -### pathFull {#pathfull} - -The same as above, but including query string and fragment. Example: /top/news.html?page=2\#comments - -### queryString {#querystring} - -Returns the query string. Example: page=1&lr=213. query-string does not include the initial question mark, as well as \# and everything after \#. - -### fragment {#fragment} - -Returns the fragment identifier. fragment does not include the initial hash symbol. - -### queryStringAndFragment {#querystringandfragment} - -Returns the query string and fragment identifier. Example: page=1\#29390. - -### extractURLParameter(URL, name) {#extracturlparameterurl-name} - -Returns the value of the ‘name’ parameter in the URL, if present. Otherwise, an empty string. If there are many parameters with this name, it returns the first occurrence. This function works under the assumption that the parameter name is encoded in the URL exactly the same way as in the passed argument. - -### extractURLParameters(URL) {#extracturlparametersurl} - -Returns an array of name=value strings corresponding to the URL parameters. The values are not decoded in any way. - -### extractURLParameterNames(URL) {#extracturlparameternamesurl} - -Returns an array of name strings corresponding to the names of URL parameters. The values are not decoded in any way. - -### URLHierarchy(URL) {#urlhierarchyurl} - -Returns an array containing the URL, truncated at the end by the symbols /,? in the path and query-string. Consecutive separator characters are counted as one. The cut is made in the position after all the consecutive separator characters. - -### URLPathHierarchy(URL) {#urlpathhierarchyurl} - -The same as above, but without the protocol and host in the result. The / element (root) is not included. Example: the function is used to implement tree reports the URL in Yandex. Metric. - -``` text -URLPathHierarchy('https://example.com/browse/CONV-6788') = -[ - '/browse/', - '/browse/CONV-6788' -] -``` - -### decodeURLComponent(URL) {#decodeurlcomponenturl} - -Returns the decoded URL. -Example: - -``` sql -SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; -``` - -``` text -┌─DecodedURL─────────────────────────────┐ -│ http://127.0.0.1:8123/?query=SELECT 1; │ -└────────────────────────────────────────┘ -``` - -## Functions that remove part of a URL. {#functions-that-remove-part-of-a-url} - -If the URL doesn’t have anything similar, the URL remains unchanged. - -### cutWWW {#cutwww} - -Removes no more than one ‘www.’ from the beginning of the URL’s domain, if present. - -### cutQueryString {#cutquerystring} - -Removes query string. The question mark is also removed. - -### cutFragment {#cutfragment} - -Removes the fragment identifier. The number sign is also removed. - -### cutQueryStringAndFragment {#cutquerystringandfragment} - -Removes the query string and fragment identifier. The question mark and number sign are also removed. - -### cutURLParameter(URL, name) {#cuturlparameterurl-name} - -Removes the ‘name’ URL parameter, if present. This function works under the assumption that the parameter name is encoded in the URL exactly the same way as in the passed argument. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/en/sql_reference/functions/uuid_functions.md b/docs/en/sql_reference/functions/uuid_functions.md deleted file mode 100644 index 9cda8f44b13..00000000000 --- a/docs/en/sql_reference/functions/uuid_functions.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -toc_priority: 53 -toc_title: Working with UUID ---- - -# Functions for working with UUID {#functions-for-working-with-uuid} - -The functions for working with UUID are listed below. - -## generateUUIDv4 {#uuid-function-generate} - -Generates the [UUID](../../sql_reference/data_types/uuid.md) of [version 4](https://tools.ietf.org/html/rfc4122#section-4.4). - -``` sql -generateUUIDv4() -``` - -**Returned value** - -The UUID type value. - -**Usage example** - -This example demonstrates creating a table with the UUID type column and inserting a value into the table. - -``` sql -CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog - -INSERT INTO t_uuid SELECT generateUUIDv4() - -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┐ -│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ -└──────────────────────────────────────┘ -``` - -## toUUID (x) {#touuid-x} - -Converts String type value to UUID type. - -``` sql -toUUID(String) -``` - -**Returned value** - -The UUID type value. - -**Usage example** - -``` sql -SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid -``` - -``` text -┌─────────────────────────────────uuid─┐ -│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ -└──────────────────────────────────────┘ -``` - -## UUIDStringToNum {#uuidstringtonum} - -Accepts a string containing 36 characters in the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, and returns it as a set of bytes in a [FixedString(16)](../../sql_reference/data_types/fixedstring.md). - -``` sql -UUIDStringToNum(String) -``` - -**Returned value** - -FixedString(16) - -**Usage examples** - -``` sql -SELECT - '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, - UUIDStringToNum(uuid) AS bytes -``` - -``` text - -┌─uuid─────────────────────────────────┬─bytes────────────┐ -│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ -└──────────────────────────────────────┴──────────────────┘ -``` - -## UUIDNumToString {#uuidnumtostring} - -Accepts a [FixedString(16)](../../sql_reference/data_types/fixedstring.md) value, and returns a string containing 36 characters in text format. - -``` sql -UUIDNumToString(FixedString(16)) -``` - -**Returned value** - -String. - -**Usage example** - -``` sql -SELECT - 'a/<@];!~p{jTj={)' AS bytes, - UUIDNumToString(toFixedString(bytes, 16)) AS uuid -``` - -``` text -┌─bytes────────────┬─uuid─────────────────────────────────┐ -│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ -└──────────────────┴──────────────────────────────────────┘ -``` - -## See also {#see-also} - -- [dictGetUUID](ext_dict_functions.md#ext_dict_functions-other) - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/en/sql_reference/functions/ym_dict_functions.md b/docs/en/sql_reference/functions/ym_dict_functions.md deleted file mode 100644 index e36d460689b..00000000000 --- a/docs/en/sql_reference/functions/ym_dict_functions.md +++ /dev/null @@ -1,155 +0,0 @@ ---- -toc_priority: 59 -toc_title: Working with Yandex.Metrica Dictionaries ---- - -# Functions for working with Yandex.Metrica dictionaries {#functions-for-working-with-yandex-metrica-dictionaries} - -In order for the functions below to work, the server config must specify the paths and addresses for getting all the Yandex.Metrica dictionaries. The dictionaries are loaded at the first call of any of these functions. If the reference lists can’t be loaded, an exception is thrown. - -For information about creating reference lists, see the section “Dictionaries”. - -## Multiple geobases {#multiple-geobases} - -ClickHouse supports working with multiple alternative geobases (regional hierarchies) simultaneously, in order to support various perspectives on which countries certain regions belong to. - -The ‘clickhouse-server’ config specifies the file with the regional hierarchy::`/opt/geo/regions_hierarchy.txt` - -Besides this file, it also searches for files nearby that have the \_ symbol and any suffix appended to the name (before the file extension). -For example, it will also find the file `/opt/geo/regions_hierarchy_ua.txt`, if present. - -`ua` is called the dictionary key. For a dictionary without a suffix, the key is an empty string. - -All the dictionaries are re-loaded in runtime (once every certain number of seconds, as defined in the builtin\_dictionaries\_reload\_interval config parameter, or once an hour by default). However, the list of available dictionaries is defined one time, when the server starts. - -All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. -Example: - -``` sql -regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt -regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt -regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt -``` - -### regionToCity(id\[, geobase\]) {#regiontocityid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. - -### regionToArea(id\[, geobase\]) {#regiontoareaid-geobase} - -Converts a region to an area (type 5 in the geobase). In every other way, this function is the same as ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ -│ │ -│ Moscow and Moscow region │ -│ St. Petersburg and Leningrad region │ -│ Belgorod region │ -│ Ivanovsk region │ -│ Kaluga region │ -│ Kostroma region │ -│ Kursk region │ -│ Lipetsk region │ -│ Orlov region │ -│ Ryazan region │ -│ Smolensk region │ -│ Tambov region │ -│ Tver region │ -│ Tula region │ -└──────────────────────────────────────────────────────┘ -``` - -### regionToDistrict(id\[, geobase\]) {#regiontodistrictid-geobase} - -Converts a region to a federal district (type 4 in the geobase). In every other way, this function is the same as ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ -│ │ -│ Central federal district │ -│ Northwest federal district │ -│ South federal district │ -│ North Caucases federal district │ -│ Privolga federal district │ -│ Ural federal district │ -│ Siberian federal district │ -│ Far East federal district │ -│ Scotland │ -│ Faroe Islands │ -│ Flemish region │ -│ Brussels capital region │ -│ Wallonia │ -│ Federation of Bosnia and Herzegovina │ -└──────────────────────────────────────────────────────────┘ -``` - -### regionToCountry(id\[, geobase\]) {#regiontocountryid-geobase} - -Converts a region to a country. In every other way, this function is the same as ‘regionToCity’. -Example: `regionToCountry(toUInt32(213)) = 225` converts Moscow (213) to Russia (225). - -### regionToContinent(id\[, geobase\]) {#regiontocontinentid-geobase} - -Converts a region to a continent. In every other way, this function is the same as ‘regionToCity’. -Example: `regionToContinent(toUInt32(213)) = 10001` converts Moscow (213) to Eurasia (10001). - -### regionToTopContinent (#regiontotopcontinent) - -Finds the highest continent in the hierarchy for the region. - -**Syntax** - -```sql -regionToTopContinent(id[, geobase]); -``` - -**Parameters** - -- `id` — Region ID from the Yandex geobase. [UInt32](../../sql_reference/data_types/int_uint.md). -- `geobase` — Dictionary key. See [Multiple Geobases](#multiple-geobases). [String](../../sql_reference/data_types/string.md). Optional. - - -**Returned value** - -- Identifier of the top level continent (the latter when you climb the hierarchy of regions). -- 0, if there is none. - -Type: `UInt32`. - - -### regionToPopulation(id\[, geobase\]) {#regiontopopulationid-geobase} - -Gets the population for a region. -The population can be recorded in files with the geobase. See the section “External dictionaries”. -If the population is not recorded for the region, it returns 0. -In the Yandex geobase, the population might be recorded for child regions, but not for parent regions. - -### regionIn(lhs, rhs\[, geobase\]) {#regioninlhs-rhs-geobase} - -Checks whether a ‘lhs’ region belongs to a ‘rhs’ region. Returns a UInt8 number equal to 1 if it belongs, or 0 if it doesn’t belong. -The relationship is reflexive – any region also belongs to itself. - -### regionHierarchy(id\[, geobase\]) {#regionhierarchyid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. -Example: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. - -### regionToName(id\[, lang\]) {#regiontonameid-lang} - -Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn’t exist, an empty string is returned. - -`ua` and `uk` both mean Ukrainian. - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/en/sql_reference/index.md b/docs/en/sql_reference/index.md deleted file mode 100644 index ae0f81336be..00000000000 --- a/docs/en/sql_reference/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -toc_folder_title: SQL Reference -toc_hidden: true -toc_priority: 28 -toc_title: hidden ---- - -# SQL Reference {#sql-reference} - -- [SELECT](statements/select.md) -- [INSERT INTO](statements/insert_into.md) -- [CREATE](statements/create.md) -- [ALTER](statements/alter.md#query_language_queries_alter) -- [Other types of queries](statements/misc.md) - -[Original article](https://clickhouse.tech/docs/en/query_language/) diff --git a/docs/en/sql_reference/operators.md b/docs/en/sql_reference/operators.md deleted file mode 100644 index 8ae9e460d87..00000000000 --- a/docs/en/sql_reference/operators.md +++ /dev/null @@ -1,275 +0,0 @@ ---- -toc_priority: 37 -toc_title: Operators ---- - -# Operators {#operators} - -ClickHouse transforms operators to their corresponding functions at the query parsing stage according to their priority, precedence, and associativity. - -## Access Operators {#access-operators} - -`a[N]` – Access to an element of an array. The `arrayElement(a, N)` function. - -`a.N` – Access to a tuple element. The `tupleElement(a, N)` function. - -## Numeric Negation Operator {#numeric-negation-operator} - -`-a` – The `negate (a)` function. - -## Multiplication and Division Operators {#multiplication-and-division-operators} - -`a * b` – The `multiply (a, b)` function. - -`a / b` – The `divide(a, b)` function. - -`a % b` – The `modulo(a, b)` function. - -## Addition and Subtraction Operators {#addition-and-subtraction-operators} - -`a + b` – The `plus(a, b)` function. - -`a - b` – The `minus(a, b)` function. - -## Comparison Operators {#comparison-operators} - -`a = b` – The `equals(a, b)` function. - -`a == b` – The `equals(a, b)` function. - -`a != b` – The `notEquals(a, b)` function. - -`a <> b` – The `notEquals(a, b)` function. - -`a <= b` – The `lessOrEquals(a, b)` function. - -`a >= b` – The `greaterOrEquals(a, b)` function. - -`a < b` – The `less(a, b)` function. - -`a > b` – The `greater(a, b)` function. - -`a LIKE s` – The `like(a, b)` function. - -`a NOT LIKE s` – The `notLike(a, b)` function. - -`a BETWEEN b AND c` – The same as `a >= b AND a <= c`. - -`a NOT BETWEEN b AND c` – The same as `a < b OR a > c`. - -## Operators for Working with Data Sets {#operators-for-working-with-data-sets} - -*See [IN operators](statements/select.md#select-in-operators).* - -`a IN ...` – The `in(a, b)` function. - -`a NOT IN ...` – The `notIn(a, b)` function. - -`a GLOBAL IN ...` – The `globalIn(a, b)` function. - -`a GLOBAL NOT IN ...` – The `globalNotIn(a, b)` function. - -## Operators for Working with Dates and Times {#operators-datetime} - -### EXTRACT {#operator-extract} - -``` sql -EXTRACT(part FROM date); -``` - -Extract parts from a given date. For example, you can retrieve a month from a given date, or a second from a time. - -The `part` parameter specifies which part of the date to retrieve. The following values are available: - -- `DAY` — The day of the month. Possible values: 1–31. -- `MONTH` — The number of a month. Possible values: 1–12. -- `YEAR` — The year. -- `SECOND` — The second. Possible values: 0–59. -- `MINUTE` — The minute. Possible values: 0–59. -- `HOUR` — The hour. Possible values: 0–23. - -The `part` parameter is case-insensitive. - -The `date` parameter specifies the date or the time to process. Either [Date](../sql_reference/data_types/date.md) or [DateTime](../sql_reference/data_types/datetime.md) type is supported. - -Examples: - -``` sql -SELECT EXTRACT(DAY FROM toDate('2017-06-15')); -SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); -SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); -``` - -In the following example we create a table and insert into it a value with the `DateTime` type. - -``` sql -CREATE TABLE test.Orders -( - OrderId UInt64, - OrderName String, - OrderDate DateTime -) -ENGINE = Log; -``` - -``` sql -INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); -``` - -``` sql -SELECT - toYear(OrderDate) AS OrderYear, - toMonth(OrderDate) AS OrderMonth, - toDayOfMonth(OrderDate) AS OrderDay, - toHour(OrderDate) AS OrderHour, - toMinute(OrderDate) AS OrderMinute, - toSecond(OrderDate) AS OrderSecond -FROM test.Orders; -``` - -``` text -┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ -│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ -└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ -``` - -You can see more examples in [tests](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). - -### INTERVAL {#operator-interval} - -Creates an [Interval](../sql_reference/data_types/special_data_types/interval.md)-type value that should be used in arithmetical operations with [Date](../sql_reference/data_types/date.md) and [DateTime](../sql_reference/data_types/datetime.md)-type values. - -Types of intervals: -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -!!! warning "Warning" - Intervals with different types can’t be combined. You can’t use expressions like `INTERVAL 4 DAY 1 HOUR`. Specify intervals in units that are smaller or equal to the smallest unit of the interval, for example, `INTERVAL 25 HOUR`. You can use consecutive operations, like in the example below. - -Example: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -**See Also** - -- [Interval](../sql_reference/data_types/special_data_types/interval.md) data type -- [toInterval](../sql_reference/functions/type_conversion_functions.md#function-tointerval) type convertion functions - -## Logical Negation Operator {#logical-negation-operator} - -`NOT a` – The `not(a)` function. - -## Logical AND Operator {#logical-and-operator} - -`a AND b` – The`and(a, b)` function. - -## Logical OR Operator {#logical-or-operator} - -`a OR b` – The `or(a, b)` function. - -## Conditional Operator {#conditional-operator} - -`a ? b : c` – The `if(a, b, c)` function. - -Note: - -The conditional operator calculates the values of b and c, then checks whether condition a is met, and then returns the corresponding value. If `b` or `C` is an [arrayJoin()](../sql_reference/functions/array_join.md#functions_arrayjoin) function, each row will be replicated regardless of the “a” condition. - -## Conditional Expression {#operator_case} - -``` sql -CASE [x] - WHEN a THEN b - [WHEN ... THEN ...] - [ELSE c] -END -``` - -If `x` is specified, then `transform(x, [a, ...], [b, ...], c)` function is used. Otherwise – `multiIf(a, b, ..., c)`. - -If there is no `ELSE c` clause in the expression, the default value is `NULL`. - -The `transform` function does not work with `NULL`. - -## Concatenation Operator {#concatenation-operator} - -`s1 || s2` – The `concat(s1, s2) function.` - -## Lambda Creation Operator {#lambda-creation-operator} - -`x -> expr` – The `lambda(x, expr) function.` - -The following operators do not have a priority since they are brackets: - -## Array Creation Operator {#array-creation-operator} - -`[x1, ...]` – The `array(x1, ...) function.` - -## Tuple Creation Operator {#tuple-creation-operator} - -`(x1, x2, ...)` – The `tuple(x2, x2, ...) function.` - -## Associativity {#associativity} - -All binary operators have left associativity. For example, `1 + 2 + 3` is transformed to `plus(plus(1, 2), 3)`. -Sometimes this doesn’t work the way you expect. For example, `SELECT 4 > 2 > 3` will result in 0. - -For efficiency, the `and` and `or` functions accept any number of arguments. The corresponding chains of `AND` and `OR` operators are transformed into a single call of these functions. - -## Checking for `NULL` {#checking-for-null} - -ClickHouse supports the `IS NULL` and `IS NOT NULL` operators. - -### IS NULL {#operator-is-null} - -- For [Nullable](../sql_reference/data_types/nullable.md) type values, the `IS NULL` operator returns: - - `1`, if the value is `NULL`. - - `0` otherwise. -- For other values, the `IS NULL` operator always returns `0`. - - - -``` sql -SELECT x+100 FROM t_null WHERE y IS NULL -``` - -``` text -┌─plus(x, 100)─┐ -│ 101 │ -└──────────────┘ -``` - -### IS NOT NULL {#is-not-null} - -- For [Nullable](../sql_reference/data_types/nullable.md) type values, the `IS NOT NULL` operator returns: - - `0`, if the value is `NULL`. - - `1` otherwise. -- For other values, the `IS NOT NULL` operator always returns `1`. - - - -``` sql -SELECT * FROM t_null WHERE y IS NOT NULL -``` - -``` text -┌─x─┬─y─┐ -│ 2 │ 3 │ -└───┴───┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/en/sql_reference/statements/alter.md b/docs/en/sql_reference/statements/alter.md deleted file mode 100644 index aa04ae65514..00000000000 --- a/docs/en/sql_reference/statements/alter.md +++ /dev/null @@ -1,502 +0,0 @@ ---- -toc_priority: 36 -toc_title: ALTER ---- - -## ALTER {#query_language_queries_alter} - -The `ALTER` query is only supported for `*MergeTree` tables, as well as `Merge`and`Distributed`. The query has several variations. - -### Column Manipulations {#column-manipulations} - -Changing the table structure. - -``` sql -ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... -``` - -In the query, specify a list of one or more comma-separated actions. -Each action is an operation on a column. - -The following actions are supported: - -- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. -- [DROP COLUMN](#alter_drop-column) — Deletes the column. -- [CLEAR COLUMN](#alter_clear-column) — Resets column values. -- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. -- [MODIFY COLUMN](#alter_modify-column) — Changes column’s type, default expression and TTL. - -These actions are described in detail below. - -#### ADD COLUMN {#alter_add-column} - -``` sql -ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] -``` - -Adds a new column to the table with the specified `name`, `type`, [`codec`](create.md#codecs) and `default_expr` (see the section [Default expressions](create.md#create-default-values)). - -If the `IF NOT EXISTS` clause is included, the query won’t return an error if the column already exists. If you specify `AFTER name_after` (the name of another column), the column is added after the specified one in the list of table columns. Otherwise, the column is added to the end of the table. Note that there is no way to add a column to the beginning of a table. For a chain of actions, `name_after` can be the name of a column that is added in one of the previous actions. - -Adding a column just changes the table structure, without performing any actions with data. The data doesn’t appear on the disk after `ALTER`. If the data is missing for a column when reading from the table, it is filled in with default values (by performing the default expression if there is one, or using zeros or empty strings). The column appears on the disk after merging data parts (see [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)). - -This approach allows us to complete the `ALTER` query instantly, without increasing the volume of old data. - -Example: - -``` sql -ALTER TABLE visits ADD COLUMN browser String AFTER user_id -``` - -#### DROP COLUMN {#alter_drop-column} - -``` sql -DROP COLUMN [IF EXISTS] name -``` - -Deletes the column with the name `name`. If the `IF EXISTS` clause is specified, the query won’t return an error if the column doesn’t exist. - -Deletes data from the file system. Since this deletes entire files, the query is completed almost instantly. - -Example: - -``` sql -ALTER TABLE visits DROP COLUMN browser -``` - -#### CLEAR COLUMN {#alter_clear-column} - -``` sql -CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name -``` - -Resets all data in a column for a specified partition. Read more about setting the partition name in the section [How to specify the partition expression](#alter-how-to-specify-part-expr). - -If the `IF EXISTS` clause is specified, the query won’t return an error if the column doesn’t exist. - -Example: - -``` sql -ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() -``` - -#### COMMENT COLUMN {#alter_comment-column} - -``` sql -COMMENT COLUMN [IF EXISTS] name 'comment' -``` - -Adds a comment to the column. If the `IF EXISTS` clause is specified, the query won’t return an error if the column doesn’t exist. - -Each column can have one comment. If a comment already exists for the column, a new comment overwrites the previous comment. - -Comments are stored in the `comment_expression` column returned by the [DESCRIBE TABLE](misc.md#misc-describe-table) query. - -Example: - -``` sql -ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' -``` - -#### MODIFY COLUMN {#alter_modify-column} - -``` sql -MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] -``` - -This query changes the `name` column properties: - -- Type - -- Default expression - -- TTL - - For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). - -If the `IF EXISTS` clause is specified, the query won’t return an error if the column doesn’t exist. - -When changing the type, values are converted as if the [toType](../../sql_reference/functions/type_conversion_functions.md) functions were applied to them. If only the default expression is changed, the query doesn’t do anything complex, and is completed almost instantly. - -Example: - -``` sql -ALTER TABLE visits MODIFY COLUMN browser Array(String) -``` - -Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. - -There are several processing stages: - -- Preparing temporary (new) files with modified data. -- Renaming old files. -- Renaming the temporary (new) files to the old names. -- Deleting the old files. - -Only the first stage takes time. If there is a failure at this stage, the data is not changed. -If there is a failure during one of the successive stages, data can be restored manually. The exception is if the old files were deleted from the file system but the data for the new files did not get written to the disk and was lost. - -The `ALTER` query for changing columns is replicated. The instructions are saved in ZooKeeper, then each replica applies them. All `ALTER` queries are run in the same order. The query waits for the appropriate actions to be completed on the other replicas. However, a query to change columns in a replicated table can be interrupted, and all actions will be performed asynchronously. - -#### ALTER Query Limitations {#alter-query-limitations} - -The `ALTER` query lets you create and delete separate elements (columns) in nested data structures, but not whole nested data structures. To add a nested data structure, you can add columns with a name like `name.nested_name` and the type `Array(T)`. A nested data structure is equivalent to multiple array columns with a name that has the same prefix before the dot. - -There is no support for deleting columns in the primary key or the sampling key (columns that are used in the `ENGINE` expression). Changing the type for columns that are included in the primary key is only possible if this change does not cause the data to be modified (for example, you are allowed to add values to an Enum or to change a type from `DateTime` to `UInt32`). - -If the `ALTER` query is not sufficient to make the table changes you need, you can create a new table, copy the data to it using the [INSERT SELECT](insert_into.md#insert_query_insert-select) query, then switch the tables using the [RENAME](misc.md#misc_operations-rename) query and delete the old table. You can use the [clickhouse-copier](../../operations/utilities/clickhouse-copier.md) as an alternative to the `INSERT SELECT` query. - -The `ALTER` query blocks all reads and writes for the table. In other words, if a long `SELECT` is running at the time of the `ALTER` query, the `ALTER` query will wait for it to complete. At the same time, all new queries to the same table will wait while this `ALTER` is running. - -For tables that don’t store data themselves (such as `Merge` and `Distributed`), `ALTER` just changes the table structure, and does not change the structure of subordinate tables. For example, when running ALTER for a `Distributed` table, you will also need to run `ALTER` for the tables on all remote servers. - -### Manipulations With Key Expressions {#manipulations-with-key-expressions} - -The following command is supported: - -``` sql -MODIFY ORDER BY new_expression -``` - -It only works for tables in the [`MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) family (including -[replicated](../../engines/table_engines/mergetree_family/replication.md) tables). The command changes the -[sorting key](../../engines/table_engines/mergetree_family/mergetree.md) of the table -to `new_expression` (an expression or a tuple of expressions). Primary key remains the same. - -The command is lightweight in a sense that it only changes metadata. To keep the property that data part -rows are ordered by the sorting key expression you cannot add expressions containing existing columns -to the sorting key (only columns added by the `ADD COLUMN` command in the same `ALTER` query). - -### Manipulations With Data Skipping Indices {#manipulations-with-data-skipping-indices} - -It only works for tables in the [`*MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) family (including -[replicated](../../engines/table_engines/mergetree_family/replication.md) tables). The following operations -are available: - -- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` - Adds index description to tables metadata. - -- `ALTER TABLE [db].name DROP INDEX name` - Removes index description from tables metadata and deletes index files from disk. - -These commands are lightweight in a sense that they only change metadata or remove files. -Also, they are replicated (syncing indices metadata through ZooKeeper). - -### Manipulations With Constraints {#manipulations-with-constraints} - -See more on [constraints](create.md#constraints) - -Constraints could be added or deleted using following syntax: - -``` sql -ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; -ALTER TABLE [db].name DROP CONSTRAINT constraint_name; -``` - -Queries will add or remove metadata about constraints from table so they are processed immediately. - -Constraint check *will not be executed* on existing data if it was added. - -All changes on replicated tables are broadcasting to ZooKeeper so will be applied on other replicas. - -### Manipulations With Partitions and Parts {#alter_manipulations-with-partitions} - -The following operations with [partitions](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) are available: - -- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` directory and forget it. -- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. -- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` directory to the table. -- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. -- [REPLACE PARTITION](#alter_replace-partition) - Copies the data partition from one table to another and replaces. -- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition) (\#alter\_move\_to\_table-partition) - Move the data partition from one table to another. -- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) - Resets the value of a specified column in a partition. -- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) - Resets the specified secondary index in a partition. -- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. -- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. -- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. - - - -#### DETACH PARTITION {\#alter\_detach-partition} {#detach-partition-alter-detach-partition} - -``` sql -ALTER TABLE table_name DETACH PARTITION partition_expr -``` - -Moves all data for the specified partition to the `detached` directory. The server forgets about the detached data partition as if it does not exist. The server will not know about this data until you make the [ATTACH](#alter_attach-partition) query. - -Example: - -``` sql -ALTER TABLE visits DETACH PARTITION 201901 -``` - -Read about setting the partition expression in a section [How to specify the partition expression](#alter-how-to-specify-part-expr). - -After the query is executed, you can do whatever you want with the data in the `detached` directory — delete it from the file system, or just leave it. - -This query is replicated – it moves the data to the `detached` directory on all replicas. Note that you can execute this query only on a leader replica. To find out if a replica is a leader, perform the `SELECT` query to the [system.replicas](../../operations/system_tables.md#system_tables-replicas) table. Alternatively, it is easier to make a `DETACH` query on all replicas - all the replicas throw an exception, except the leader replica. - -#### DROP PARTITION {#alter_drop-partition} - -``` sql -ALTER TABLE table_name DROP PARTITION partition_expr -``` - -Deletes the specified partition from the table. This query tags the partition as inactive and deletes data completely, approximately in 10 minutes. - -Read about setting the partition expression in a section [How to specify the partition expression](#alter-how-to-specify-part-expr). - -The query is replicated – it deletes data on all replicas. - -#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} - -``` sql -ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr -``` - -Removes the specified part or all parts of the specified partition from `detached`. -Read more about setting the partition expression in a section [How to specify the partition expression](#alter-how-to-specify-part-expr). - -#### ATTACH PARTITION\|PART {#alter_attach-partition} - -``` sql -ALTER TABLE table_name ATTACH PARTITION|PART partition_expr -``` - -Adds data to the table from the `detached` directory. It is possible to add data for an entire partition or for a separate part. Examples: - -``` sql -ALTER TABLE visits ATTACH PARTITION 201901; -ALTER TABLE visits ATTACH PART 201901_2_2_0; -``` - -Read more about setting the partition expression in a section [How to specify the partition expression](#alter-how-to-specify-part-expr). - -This query is replicated. The replica-initiator checks whether there is data in the `detached` directory. If data exists, the query checks its integrity. If everything is correct, the query adds the data to the table. All other replicas download the data from the replica-initiator. - -So you can put data to the `detached` directory on one replica, and use the `ALTER ... ATTACH` query to add it to the table on all replicas. - -#### ATTACH PARTITION FROM {#alter_attach-partition-from} - -``` sql -ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 -``` - -This query copies the data partition from the `table1` to `table2` adds data to exsisting in the `table2`. Note that data won’t be deleted from `table1`. - -For the query to run successfully, the following conditions must be met: - -- Both tables must have the same structure. -- Both tables must have the same partition key. - -#### REPLACE PARTITION {#alter_replace-partition} - -``` sql -ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 -``` - -This query copies the data partition from the `table1` to `table2` and replaces existing partition in the `table2`. Note that data won’t be deleted from `table1`. - -For the query to run successfully, the following conditions must be met: - -- Both tables must have the same structure. -- Both tables must have the same partition key. - -#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} - -``` sql -ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest -``` - -This query move the data partition from the `table_source` to `table_dest` with deleting the data from `table_source`. - -For the query to run successfully, the following conditions must be met: - -- Both tables must have the same structure. -- Both tables must have the same partition key. -- Both tables must be the same engine family. (replicated or non-replicated) -- Both tables must have the same storage policy. - -#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} - -``` sql -ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr -``` - -Resets all values in the specified column in a partition. If the `DEFAULT` clause was determined when creating a table, this query sets the column value to a specified default value. - -Example: - -``` sql -ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 -``` - -#### FREEZE PARTITION {#alter_freeze-partition} - -``` sql -ALTER TABLE table_name FREEZE [PARTITION partition_expr] -``` - -This query creates a local backup of a specified partition. If the `PARTITION` clause is omitted, the query creates the backup of all partitions at once. - -!!! note "Note" - The entire backup process is performed without stopping the server. - -Note that for old-styled tables you can specify the prefix of the partition name (for example, ‘2019’) - then the query creates the backup for all the corresponding partitions. Read about setting the partition expression in a section [How to specify the partition expression](#alter-how-to-specify-part-expr). - -At the time of execution, for a data snapshot, the query creates hardlinks to a table data. Hardlinks are placed in the directory `/var/lib/clickhouse/shadow/N/...`, where: - -- `/var/lib/clickhouse/` is the working ClickHouse directory specified in the config. -- `N` is the incremental number of the backup. - -!!! note "Note" - If you use [a set of disks for data storage in a table](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes), the `shadow/N` directory appears on every disk, storing data parts that matched by the `PARTITION` expression. - -The same structure of directories is created inside the backup as inside `/var/lib/clickhouse/`. The query performs ‘chmod’ for all files, forbidding writing into them. - -After creating the backup, you can copy the data from `/var/lib/clickhouse/shadow/` to the remote server and then delete it from the local server. Note that the `ALTER t FREEZE PARTITION` query is not replicated. It creates a local backup only on the local server. - -The query creates backup almost instantly (but first it waits for the current queries to the corresponding table to finish running). - -`ALTER TABLE t FREEZE PARTITION` copies only the data, not table metadata. To make a backup of table metadata, copy the file `/var/lib/clickhouse/metadata/database/table.sql` - -To restore data from a backup, do the following: - -1. Create the table if it does not exist. To view the query, use the .sql file (replace `ATTACH` in it with `CREATE`). -2. Copy the data from the `data/database/table/` directory inside the backup to the `/var/lib/clickhouse/data/database/table/detached/` directory. -3. Run `ALTER TABLE t ATTACH PARTITION` queries to add the data to a table. - -Restoring from a backup doesn’t require stopping the server. - -For more information about backups and restoring data, see the [Data Backup](../../operations/backup.md) section. - -#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} - -``` sql -ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr -``` - -The query works similar to `CLEAR COLUMN`, but it resets an index instead of a column data. - -#### FETCH PARTITION {#alter_fetch-partition} - -``` sql -ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' -``` - -Downloads a partition from another server. This query only works for the replicated tables. - -The query does the following: - -1. Downloads the partition from the specified shard. In ‘path-in-zookeeper’ you must specify a path to the shard in ZooKeeper. -2. Then the query puts the downloaded data to the `detached` directory of the `table_name` table. Use the [ATTACH PARTITION\|PART](#alter_attach-partition) query to add the data to the table. - -For example: - -``` sql -ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; -ALTER TABLE users ATTACH PARTITION 201902; -``` - -Note that: - -- The `ALTER ... FETCH PARTITION` query isn’t replicated. It places the partition to the `detached` directory only on the local server. -- The `ALTER TABLE ... ATTACH` query is replicated. It adds the data to all replicas. The data is added to one of the replicas from the `detached` directory, and to the others - from neighboring replicas. - -Before downloading, the system checks if the partition exists and the table structure matches. The most appropriate replica is selected automatically from the healthy replicas. - -Although the query is called `ALTER TABLE`, it does not change the table structure and does not immediately change the data available in the table. - -#### MOVE PARTITION\|PART {#alter_move-partition} - -Moves partitions or data parts to another volume or disk for `MergeTree`-engine tables. See [Using Multiple Block Devices for Data Storage](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes). - -``` sql -ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' -``` - -The `ALTER TABLE t MOVE` query: - -- Not replicated, because different replicas can have different storage policies. -- Returns an error if the specified disk or volume is not configured. Query also returns an error if conditions of data moving, that specified in the storage policy, can’t be applied. -- Can return an error in the case, when data to be moved is already moved by a background process, concurrent `ALTER TABLE t MOVE` query or as a result of background data merging. A user shouldn’t perform any additional actions in this case. - -Example: - -``` sql -ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' -ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' -``` - -#### How To Set Partition Expression {#alter-how-to-specify-part-expr} - -You can specify the partition expression in `ALTER ... PARTITION` queries in different ways: - -- As a value from the `partition` column of the `system.parts` table. For example, `ALTER TABLE visits DETACH PARTITION 201901`. -- As the expression from the table column. Constants and constant expressions are supported. For example, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. -- Using the partition ID. Partition ID is a string identifier of the partition (human-readable, if possible) that is used as the names of partitions in the file system and in ZooKeeper. The partition ID must be specified in the `PARTITION ID` clause, in a single quotes. For example, `ALTER TABLE visits DETACH PARTITION ID '201901'`. -- In the [ALTER ATTACH PART](#alter_attach-partition) and [DROP DETACHED PART](#alter_drop-detached) query, to specify the name of a part, use string literal with a value from the `name` column of the [system.detached\_parts](../../operations/system_tables.md#system_tables-detached_parts) table. For example, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. - -Usage of quotes when specifying the partition depends on the type of partition expression. For example, for the `String` type, you have to specify its name in quotes (`'`). For the `Date` and `Int*` types no quotes are needed. - -For old-style tables, you can specify the partition either as a number `201901` or a string `'201901'`. The syntax for the new-style tables is stricter with types (similar to the parser for the VALUES input format). - -All the rules above are also true for the [OPTIMIZE](misc.md#misc_operations-optimize) query. If you need to specify the only partition when optimizing a non-partitioned table, set the expression `PARTITION tuple()`. For example: - -``` sql -OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; -``` - -The examples of `ALTER ... PARTITION` queries are demonstrated in the tests [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) and [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). - -### Manipulations With Table TTL {#manipulations-with-table-ttl} - -You can change [table TTL](../../engines/table_engines/mergetree_family/mergetree.md#mergetree-table-ttl) with a request of the following form: - -``` sql -ALTER TABLE table-name MODIFY TTL ttl-expression -``` - -### Synchronicity Of ALTER Queries {#synchronicity-of-alter-queries} - -For non-replicatable tables, all `ALTER` queries are performed synchronously. For replicatable tables, the query just adds instructions for the appropriate actions to `ZooKeeper`, and the actions themselves are performed as soon as possible. However, the query can wait for these actions to be completed on all the replicas. - -For `ALTER ... ATTACH|DETACH|DROP` queries, you can use the `replication_alter_partitions_sync` setting to set up waiting. -Possible values: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. - -### Mutations {#alter-mutations} - -Mutations are an ALTER query variant that allows changing or deleting rows in a table. In contrast to standard `UPDATE` and `DELETE` queries that are intended for point data changes, mutations are intended for heavy operations that change a lot of rows in a table. Supported for the `MergeTree` family of table engines including the engines with replication support. - -Existing tables are ready for mutations as-is (no conversion necessary), but after the first mutation is applied to a table, its metadata format becomes incompatible with previous server versions and falling back to a previous version becomes impossible. - -Currently available commands: - -``` sql -ALTER TABLE [db.]table DELETE WHERE filter_expr -``` - -The `filter_expr` must be of type `UInt8`. The query deletes rows in the table for which this expression takes a non-zero value. - -``` sql -ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr -``` - -The `filter_expr` must be of type `UInt8`. This query updates values of specified columns to the values of corresponding expressions in rows for which the `filter_expr` takes a non-zero value. Values are casted to the column type using the `CAST` operator. Updating columns that are used in the calculation of the primary or the partition key is not supported. - -``` sql -ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name -``` - -The query rebuilds the secondary index `name` in the partition `partition_name`. - -One query can contain several commands separated by commas. - -For \*MergeTree tables mutations execute by rewriting whole data parts. There is no atomicity - parts are substituted for mutated parts as soon as they are ready and a `SELECT` query that started executing during a mutation will see data from parts that have already been mutated along with data from parts that have not been mutated yet. - -Mutations are totally ordered by their creation order and are applied to each part in that order. Mutations are also partially ordered with INSERTs - data that was inserted into the table before the mutation was submitted will be mutated and data that was inserted after that will not be mutated. Note that mutations do not block INSERTs in any way. - -A mutation query returns immediately after the mutation entry is added (in case of replicated tables to ZooKeeper, for nonreplicated tables - to the filesystem). The mutation itself executes asynchronously using the system profile settings. To track the progress of mutations you can use the [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) table. A mutation that was successfully submitted will continue to execute even if ClickHouse servers are restarted. There is no way to roll back the mutation once it is submitted, but if the mutation is stuck for some reason it can be cancelled with the [`KILL MUTATION`](misc.md#kill-mutation) query. - -Entries for finished mutations are not deleted right away (the number of preserved entries is determined by the `finished_mutations_to_keep` storage engine parameter). Older mutation entries are deleted. - -[Original article](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/en/sql_reference/statements/create.md b/docs/en/sql_reference/statements/create.md deleted file mode 100644 index 430bcacbc34..00000000000 --- a/docs/en/sql_reference/statements/create.md +++ /dev/null @@ -1,301 +0,0 @@ ---- -toc_priority: 35 -toc_title: CREATE ---- - -# CREATE Queries {#create-queries} - -## CREATE DATABASE {#query-language-create-database} - -Creates database. - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] -``` - -### Clauses {#clauses} - -- `IF NOT EXISTS` - If the `db_name` database already exists, then ClickHouse doesn't create a new database and: - - Doesn't throw an exception if clause is specified. - - Throws an exception if clause isn't specified. - -- `ON CLUSTER` - ClickHouse creates the `db_name` database on all the servers of a specified cluster. - -- `ENGINE` - - [MySQL](../../engines/database_engines/mysql.md) - Allows you to retrieve data from the remote MySQL server. - By default, ClickHouse uses its own [database engine](../../engines/database_engines/index.md). - -## CREATE TABLE {#create-table-query} - -The `CREATE TABLE` query can have several forms. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], - ... -) ENGINE = engine -``` - -Creates a table named ‘name’ in the ‘db’ database or the current database if ‘db’ is not set, with the structure specified in brackets and the ‘engine’ engine. -The structure of the table is a list of column descriptions. If indexes are supported by the engine, they are indicated as parameters for the table engine. - -A column description is `name type` in the simplest case. Example: `RegionID UInt32`. -Expressions can also be defined for default values (see below). - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] -``` - -Creates a table with the same structure as another table. You can specify a different engine for the table. If the engine is not specified, the same engine will be used as for the `db2.name2` table. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() -``` - -Creates a table with the structure and data returned by a [table function](../table_functions/index.md). - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... -``` - -Creates a table with a structure like the result of the `SELECT` query, with the ‘engine’ engine, and fills it with data from SELECT. - -In all cases, if `IF NOT EXISTS` is specified, the query won’t return an error if the table already exists. In this case, the query won’t do anything. - -There can be other clauses after the `ENGINE` clause in the query. See detailed documentation on how to create tables in the descriptions of [table engines](../../engines/table_engines/index.md#table_engines). - -### Default Values {#create-default-values} - -The column description can specify an expression for a default value, in one of the following ways:`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. -Example: `URLDomain String DEFAULT domain(URL)`. - -If an expression for the default value is not defined, the default values will be set to zeros for numbers, empty strings for strings, empty arrays for arrays, and `0000-00-00` for dates or `0000-00-00 00:00:00` for dates with time. NULLs are not supported. - -If the default expression is defined, the column type is optional. If there isn’t an explicitly defined type, the default expression type is used. Example: `EventDate DEFAULT toDate(EventTime)` – the ‘Date’ type will be used for the ‘EventDate’ column. - -If the data type and default expression are defined explicitly, this expression will be cast to the specified type using type casting functions. Example: `Hits UInt32 DEFAULT 0` means the same thing as `Hits UInt32 DEFAULT toUInt32(0)`. - -Default expressions may be defined as an arbitrary expression from table constants and columns. When creating and changing the table structure, it checks that expressions don’t contain loops. For INSERT, it checks that expressions are resolvable – that all columns they can be calculated from have been passed. - -`DEFAULT expr` - -Normal default value. If the INSERT query doesn’t specify the corresponding column, it will be filled in by computing the corresponding expression. - -`MATERIALIZED expr` - -Materialized expression. Such a column can’t be specified for INSERT, because it is always calculated. -For an INSERT without a list of columns, these columns are not considered. -In addition, this column is not substituted when using an asterisk in a SELECT query. This is to preserve the invariant that the dump obtained using `SELECT *` can be inserted back into the table using INSERT without specifying the list of columns. - -`ALIAS expr` - -Synonym. Such a column isn’t stored in the table at all. -Its values can’t be inserted in a table, and it is not substituted when using an asterisk in a SELECT query. -It can be used in SELECTs if the alias is expanded during query parsing. - -When using the ALTER query to add new columns, old data for these columns is not written. Instead, when reading old data that does not have values for the new columns, expressions are computed on the fly by default. However, if running the expressions requires different columns that are not indicated in the query, these columns will additionally be read, but only for the blocks of data that need it. - -If you add a new column to a table but later change its default expression, the values used for old data will change (for data where values were not stored on the disk). Note that when running background merges, data for columns that are missing in one of the merging parts is written to the merged part. - -It is not possible to set default values for elements in nested data structures. - -### Constraints {#constraints} - -Along with columns descriptions constraints could be defined: - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - ... - CONSTRAINT constraint_name_1 CHECK boolean_expr_1, - ... -) ENGINE = engine -``` - -`boolean_expr_1` could by any boolean expression. If constraints are defined for the table, each of them will be checked for every row in `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. - -Adding large amount of constraints can negatively affect performance of big `INSERT` queries. - -### TTL Expression {#ttl-expression} - -Defines storage time for values. Can be specified only for MergeTree-family tables. For the detailed description, see [TTL for columns and tables](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). - -### Column Compression Codecs {#codecs} - -By default, ClickHouse applies the `lz4` compression method. For `MergeTree`-engine family you can change the default compression method in the [compression](../../operations/server_configuration_parameters/settings.md#server-settings-compression) section of a server configuration. You can also define the compression method for each individual column in the `CREATE TABLE` query. - -``` sql -CREATE TABLE codec_example -( - dt Date CODEC(ZSTD), - ts DateTime CODEC(LZ4HC), - float_value Float32 CODEC(NONE), - double_value Float64 CODEC(LZ4HC(9)) - value Float32 CODEC(Delta, ZSTD) -) -ENGINE = -... -``` - -If a codec is specified, the default codec doesn’t apply. Codecs can be combined in a pipeline, for example, `CODEC(Delta, ZSTD)`. To select the best codec combination for you project, pass benchmarks similar to described in the Altinity [New Encodings to Improve ClickHouse Efficiency](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) article. - -!!! warning "Warning" - You can’t decompress ClickHouse database files with external utilities like `lz4`. Instead, use the special [clickhouse-compressor](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) utility. - -Compression is supported for the following table engines: - -- [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) family. Supports column compression codecs and selecting the default compression method by [compression](../../operations/server_configuration_parameters/settings.md#server-settings-compression) settings. -- [Log](../../engines/table_engines/log_family/log_family.md) family. Uses the `lz4` compression method by default and supports column compression codecs. -- [Set](../../engines/table_engines/special/set.md). Only supported the default compression. -- [Join](../../engines/table_engines/special/join.md). Only supported the default compression. - -ClickHouse supports common purpose codecs and specialized codecs. - -#### Specialized Codecs {#create-query-specialized-codecs} - -These codecs are designed to make compression more effective by using specific features of data. Some of these codecs don’t compress data themself. Instead, they prepare the data for a common purpose codec, which compresses it better than without this preparation. - -Specialized codecs: - -- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` are used for storing delta values, so `delta_bytes` is the maximum size of raw values. Possible `delta_bytes` values: 1, 2, 4, 8. The default value for `delta_bytes` is `sizeof(type)` if equal to 1, 2, 4, or 8. In all other cases, it’s 1. -- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` and `DateTime`). At each step of its algorithm, codec takes a block of 64 values, puts them into 64x64 bit matrix, transposes it, crops the unused bits of values and returns the rest as a sequence. Unused bits are the bits, that don’t differ between maximum and minimum values in the whole data part for which the compression is used. - -`DoubleDelta` and `Gorilla` codecs are used in Gorilla TSDB as the components of its compressing algorithm. Gorilla approach is effective in scenarios when there is a sequence of slowly changing values with their timestamps. Timestamps are effectively compressed by the `DoubleDelta` codec, and values are effectively compressed by the `Gorilla` codec. For example, to get an effectively stored table, you can create it in the following configuration: - -``` sql -CREATE TABLE codec_example -( - timestamp DateTime CODEC(DoubleDelta), - slow_values Float32 CODEC(Gorilla) -) -ENGINE = MergeTree() -``` - -#### General Purpose Codecs {#create-query-general-purpose-codecs} - -Codecs: - -- `NONE` — No compression. -- `LZ4` — Lossless [data compression algorithm](https://github.com/lz4/lz4) used by default. Applies LZ4 fast compression. -- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` applies the default level. Possible levels: \[1, 12\]. Recommended level range: \[4, 9\]. -- `ZSTD[(level)]` — [ZSTD compression algorithm](https://en.wikipedia.org/wiki/Zstandard) with configurable `level`. Possible levels: \[1, 22\]. Default value: 1. - -High compression levels are useful for asymmetric scenarios, like compress once, decompress repeatedly. Higher levels mean better compression and higher CPU usage. - -## Temporary Tables {#temporary-tables} - -ClickHouse supports temporary tables which have the following characteristics: - -- Temporary tables disappear when the session ends, including if the connection is lost. -- A temporary table uses the Memory engine only. -- The DB can’t be specified for a temporary table. It is created outside of databases. -- Impossible to create a temporary table with distributed DDL query on all cluster servers (by using `ON CLUSTER`): this table exists only in the current session. -- If a temporary table has the same name as another one and a query specifies the table name without specifying the DB, the temporary table will be used. -- For distributed query processing, temporary tables used in a query are passed to remote servers. - -To create a temporary table, use the following syntax: - -``` sql -CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) -``` - -In most cases, temporary tables are not created manually, but when using external data for a query, or for distributed `(GLOBAL) IN`. For more information, see the appropriate sections - -It’s possible to use tables with [ENGINE = Memory](../../engines/table_engines/special/memory.md) instead of temporary tables. - -## Distributed DDL Queries (ON CLUSTER Clause) {#distributed-ddl-queries-on-cluster-clause} - -The `CREATE`, `DROP`, `ALTER`, and `RENAME` queries support distributed execution on a cluster. -For example, the following query creates the `all_hits` `Distributed` table on each host in `cluster`: - -``` sql -CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) -``` - -In order to run these queries correctly, each host must have the same cluster definition (to simplify syncing configs, you can use substitutions from ZooKeeper). They must also connect to the ZooKeeper servers. -The local version of the query will eventually be implemented on each host in the cluster, even if some hosts are currently not available. The order for executing queries within a single host is guaranteed. - -## CREATE VIEW {#create-view} - -``` sql -CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... -``` - -Creates a view. There are two types of views: normal and MATERIALIZED. - -Normal views don’t store any data, but just perform a read from another table. In other words, a normal view is nothing more than a saved query. When reading from a view, this saved query is used as a subquery in the FROM clause. - -As an example, assume you’ve created a view: - -``` sql -CREATE VIEW view AS SELECT ... -``` - -and written a query: - -``` sql -SELECT a, b, c FROM view -``` - -This query is fully equivalent to using the subquery: - -``` sql -SELECT a, b, c FROM (SELECT ...) -``` - -Materialized views store data transformed by the corresponding SELECT query. - -When creating a materialized view without `TO [db].[table]`, you must specify ENGINE – the table engine for storing data. - -When creating a materialized view with `TO [db].[table]`, you must not use `POPULATE`. - -A materialized view is arranged as follows: when inserting data to the table specified in SELECT, part of the inserted data is converted by this SELECT query, and the result is inserted in the view. - -If you specify POPULATE, the existing table data is inserted in the view when creating it, as if making a `CREATE TABLE ... AS SELECT ...` . Otherwise, the query contains only the data inserted in the table after creating the view. We don’t recommend using POPULATE, since data inserted in the table during the view creation will not be inserted in it. - -A `SELECT` query can contain `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Note that the corresponding conversions are performed independently on each block of inserted data. For example, if `GROUP BY` is set, data is aggregated during insertion, but only within a single packet of inserted data. The data won’t be further aggregated. The exception is when using an ENGINE that independently performs data aggregation, such as `SummingMergeTree`. - -The execution of `ALTER` queries on materialized views has not been fully developed, so they might be inconvenient. If the materialized view uses the construction `TO [db.]name`, you can `DETACH` the view, run `ALTER` for the target table, and then `ATTACH` the previously detached (`DETACH`) view. - -Views look the same as normal tables. For example, they are listed in the result of the `SHOW TABLES` query. - -There isn’t a separate query for deleting views. To delete a view, use `DROP TABLE`. - -## CREATE DICTIONARY {#create-dictionary-query} - -``` sql -CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] -( - key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - attr1 type2 [DEFAULT|EXPRESSION expr3], - attr2 type2 [DEFAULT|EXPRESSION expr4] -) -PRIMARY KEY key1, key2 -SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) -LAYOUT(LAYOUT_NAME([param_name param_value])) -LIFETIME([MIN val1] MAX val2) -``` - -Creates [external dictionary](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) with given [structure](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md), [source](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md), [layout](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md) and [lifetime](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md). - -External dictionary structure consists of attributes. Dictionary attributes are specified similarly to table columns. The only required attribute property is its type, all other properties may have default values. - -Depending on dictionary [layout](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md) one or more attributes can be specified as dictionary keys. - -For more information, see [External Dictionaries](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) section. - -[Original article](https://clickhouse.tech/docs/en/query_language/create/) diff --git a/docs/en/sql_reference/statements/index.md b/docs/en/sql_reference/statements/index.md deleted file mode 100644 index 507d858c14a..00000000000 --- a/docs/en/sql_reference/statements/index.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -toc_folder_title: Statements -toc_priority: 31 ---- diff --git a/docs/en/sql_reference/statements/insert_into.md b/docs/en/sql_reference/statements/insert_into.md deleted file mode 100644 index 0f26a37e2b9..00000000000 --- a/docs/en/sql_reference/statements/insert_into.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -toc_priority: 34 -toc_title: INSERT INTO ---- - -## INSERT {#insert} - -Adding data. - -Basic query format: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... -``` - -The query can specify a list of columns to insert `[(c1, c2, c3)]`. In this case, the rest of the columns are filled with: - -- The values calculated from the `DEFAULT` expressions specified in the table definition. -- Zeros and empty strings, if `DEFAULT` expressions are not defined. - -If [strict\_insert\_defaults=1](../../operations/settings/settings.md), columns that do not have `DEFAULT` defined must be listed in the query. - -Data can be passed to the INSERT in any [format](../../interfaces/formats.md#formats) supported by ClickHouse. The format must be specified explicitly in the query: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set -``` - -For example, the following query format is identical to the basic version of INSERT … VALUES: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... -``` - -ClickHouse removes all spaces and one line feed (if there is one) before the data. When forming a query, we recommend putting the data on a new line after the query operators (this is important if the data begins with spaces). - -Example: - -``` sql -INSERT INTO t FORMAT TabSeparated -11 Hello, world! -22 Qwerty -``` - -You can insert data separately from the query by using the command-line client or the HTTP interface. For more information, see the section “[Interfaces](../../interfaces/index.md#interfaces)”. - -### Constraints {#constraints} - -If table has [constraints](create.md#constraints), their expressions will be checked for each row of inserted data. If any of those constraints is not satisfied — server will raise an exception containing constraint name and expression, the query will be stopped. - -### Inserting The Results Of `SELECT` {#insert_query_insert-select} - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... -``` - -Columns are mapped according to their position in the SELECT clause. However, their names in the SELECT expression and the table for INSERT may differ. If necessary, type casting is performed. - -None of the data formats except Values allow setting values to expressions such as `now()`, `1 + 2`, and so on. The Values format allows limited use of expressions, but this is not recommended, because in this case inefficient code is used for their execution. - -Other queries for modifying data parts are not supported: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. -However, you can delete old data using `ALTER TABLE ... DROP PARTITION`. - -`FORMAT` clause must be specified in the end of query if `SELECT` clause contains table function [input()](../table_functions/input.md). - -### Performance Considerations {#performance-considerations} - -`INSERT` sorts the input data by primary key and splits them into partitions by a partition key. If you insert data into several partitions at once, it can significantly reduce the performance of the `INSERT` query. To avoid this: - -- Add data in fairly large batches, such as 100,000 rows at a time. -- Group data by a partition key before uploading it to ClickHouse. - -Performance will not decrease if: - -- Data is added in real time. -- You upload data that is usually sorted by time. - -[Original article](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/en/sql_reference/statements/misc.md b/docs/en/sql_reference/statements/misc.md deleted file mode 100644 index be2c07e86b8..00000000000 --- a/docs/en/sql_reference/statements/misc.md +++ /dev/null @@ -1,250 +0,0 @@ ---- -toc_priority: 39 -toc_title: Other ---- - -# Miscellaneous Queries {#miscellaneous-queries} - -## ATTACH {#attach} - -This query is exactly the same as `CREATE`, but - -- Instead of the word `CREATE` it uses the word `ATTACH`. -- The query does not create data on the disk, but assumes that data is already in the appropriate places, and just adds information about the table to the server. - After executing an ATTACH query, the server will know about the existence of the table. - -If the table was previously detached (`DETACH`), meaning that its structure is known, you can use shorthand without defining the structure. - -``` sql -ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] -``` - -This query is used when starting the server. The server stores table metadata as files with `ATTACH` queries, which it simply runs at launch (with the exception of system tables, which are explicitly created on the server). - -## CHECK TABLE {#check-table} - -Checks if the data in the table is corrupted. - -``` sql -CHECK TABLE [db.]name -``` - -The `CHECK TABLE` query compares actual file sizes with the expected values which are stored on the server. If the file sizes do not match the stored values, it means the data is corrupted. This can be caused, for example, by a system crash during query execution. - -The query response contains the `result` column with a single row. The row has a value of -[Boolean](../../sql_reference/data_types/boolean.md) type: - -- 0 - The data in the table is corrupted. -- 1 - The data maintains integrity. - -The `CHECK TABLE` query supports the following table engines: - -- [Log](../../engines/table_engines/log_family/log.md) -- [TinyLog](../../engines/table_engines/log_family/tinylog.md) -- [StripeLog](../../engines/table_engines/log_family/stripelog.md) -- [MergeTree family](../../engines/table_engines/mergetree_family/mergetree.md) - -Performed over the tables with another table engines causes an exception. - -Engines from the `*Log` family don’t provide automatic data recovery on failure. Use the `CHECK TABLE` query to track data loss in a timely manner. - -For `MergeTree` family engines, the `CHECK TABLE` query shows a check status for every individual data part of a table on the local server. - -**If the data is corrupted** - -If the table is corrupted, you can copy the non-corrupted data to another table. To do this: - -1. Create a new table with the same structure as damaged table. To do this execute the query `CREATE TABLE AS `. -2. Set the [max\_threads](../../operations/settings/settings.md#settings-max_threads) value to 1 to process the next query in a single thread. To do this run the query `SET max_threads = 1`. -3. Execute the query `INSERT INTO SELECT * FROM `. This request copies the non-corrupted data from the damaged table to another table. Only the data before the corrupted part will be copied. -4. Restart the `clickhouse-client` to reset the `max_threads` value. - -## DESCRIBE TABLE {#misc-describe-table} - -``` sql -DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -Returns the following `String` type columns: - -- `name` — Column name. -- `type`— Column type. -- `default_type` — Clause that is used in [default expression](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` or `ALIAS`). Column contains an empty string, if the default expression isn’t specified. -- `default_expression` — Value specified in the `DEFAULT` clause. -- `comment_expression` — Comment text. - -Nested data structures are output in “expanded” format. Each column is shown separately, with the name after a dot. - -## DETACH {#detach} - -Deletes information about the ‘name’ table from the server. The server stops knowing about the table’s existence. - -``` sql -DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -This does not delete the table’s data or metadata. On the next server launch, the server will read the metadata and find out about the table again. -Similarly, a “detached” table can be re-attached using the `ATTACH` query (with the exception of system tables, which do not have metadata stored for them). - -There is no `DETACH DATABASE` query. - -## DROP {#drop} - -This query has two types: `DROP DATABASE` and `DROP TABLE`. - -``` sql -DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] -``` - -Deletes all tables inside the ‘db’ database, then deletes the ‘db’ database itself. -If `IF EXISTS` is specified, it doesn’t return an error if the database doesn’t exist. - -``` sql -DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -Deletes the table. -If `IF EXISTS` is specified, it doesn’t return an error if the table doesn’t exist or the database doesn’t exist. - - DROP DICTIONARY [IF EXISTS] [db.]name - -Delets the dictionary. -If `IF EXISTS` is specified, it doesn’t return an error if the table doesn’t exist or the database doesn’t exist. - -## EXISTS {#exists} - -``` sql -EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] -``` - -Returns a single `UInt8`-type column, which contains the single value `0` if the table or database doesn’t exist, or `1` if the table exists in the specified database. - -## KILL QUERY {#kill-query} - -``` sql -KILL QUERY [ON CLUSTER cluster] - WHERE - [SYNC|ASYNC|TEST] - [FORMAT format] -``` - -Attempts to forcibly terminate the currently running queries. -The queries to terminate are selected from the system.processes table using the criteria defined in the `WHERE` clause of the `KILL` query. - -Examples: - -``` sql --- Forcibly terminates all queries with the specified query_id: -KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - --- Synchronously terminates all queries run by 'username': -KILL QUERY WHERE user='username' SYNC -``` - -Read-only users can only stop their own queries. - -By default, the asynchronous version of queries is used (`ASYNC`), which doesn’t wait for confirmation that queries have stopped. - -The synchronous version (`SYNC`) waits for all queries to stop and displays information about each process as it stops. -The response contains the `kill_status` column, which can take the following values: - -1. ‘finished’ – The query was terminated successfully. -2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. -3. The other values ​​explain why the query can’t be stopped. - -A test query (`TEST`) only checks the user’s rights and displays a list of queries to stop. - -## KILL MUTATION {#kill-mutation} - -``` sql -KILL MUTATION [ON CLUSTER cluster] - WHERE - [TEST] - [FORMAT format] -``` - -Tries to cancel and remove [mutations](alter.md#alter-mutations) that are currently executing. Mutations to cancel are selected from the [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) table using the filter specified by the `WHERE` clause of the `KILL` query. - -A test query (`TEST`) only checks the user’s rights and displays a list of queries to stop. - -Examples: - -``` sql --- Cancel and remove all mutations of the single table: -KILL MUTATION WHERE database = 'default' AND table = 'table' - --- Cancel the specific mutation: -KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' -``` - -The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). - -Changes already made by the mutation are not rolled back. - -## OPTIMIZE {#misc_operations-optimize} - -``` sql -OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] -``` - -This query tries to initialize an unscheduled merge of data parts for tables with a table engine from the [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) family. - -The `OPTMIZE` query is also supported for the [MaterializedView](../../engines/table_engines/special/materializedview.md) and the [Buffer](../../engines/table_engines/special/buffer.md) engines. Other table engines aren’t supported. - -When `OPTIMIZE` is used with the [ReplicatedMergeTree](../../engines/table_engines/mergetree_family/replication.md) family of table engines, ClickHouse creates a task for merging and waits for execution on all nodes (if the `replication_alter_partitions_sync` setting is enabled). - -- If `OPTIMIZE` doesn’t perform a merge for any reason, it doesn’t notify the client. To enable notifications, use the [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop) setting. -- If you specify a `PARTITION`, only the specified partition is optimized. [How to set partition expression](alter.md#alter-how-to-specify-part-expr). -- If you specify `FINAL`, optimization is performed even when all the data is already in one part. -- If you specify `DEDUPLICATE`, then completely identical rows will be deduplicated (all columns are compared), it makes sense only for the MergeTree engine. - -!!! warning "Warning" - `OPTIMIZE` can’t fix the “Too many parts” error. - -## RENAME {#misc_operations-rename} - -Renames one or more tables. - -``` sql -RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] -``` - -All tables are renamed under global locking. Renaming tables is a light operation. If you indicated another database after TO, the table will be moved to this database. However, the directories with databases must reside in the same file system (otherwise, an error is returned). - -## SET {#query-set} - -``` sql -SET param = value -``` - -Assigns `value` to the `param` [setting](../../operations/settings/index.md) for the current session. You cannot change [server settings](../../operations/server_configuration_parameters/index.md) this way. - -You can also set all the values from the specified settings profile in a single query. - -``` sql -SET profile = 'profile-name-from-the-settings-file' -``` - -For more information, see [Settings](../../operations/settings/settings.md). - -## TRUNCATE {#truncate} - -``` sql -TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -Removes all data from a table. When the clause `IF EXISTS` is omitted, the query returns an error if the table does not exist. - -The `TRUNCATE` query is not supported for [View](../../engines/table_engines/special/view.md), [File](../../engines/table_engines/special/file.md), [URL](../../engines/table_engines/special/url.md) and [Null](../../engines/table_engines/special/null.md) table engines. - -## USE {#use} - -``` sql -USE db -``` - -Lets you set the current database for the session. -The current database is used for searching for tables if the database is not explicitly defined in the query with a dot before the table name. -This query can’t be made when using the HTTP protocol, since there is no concept of a session. - -[Original article](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/en/sql_reference/statements/select.md b/docs/en/sql_reference/statements/select.md deleted file mode 100644 index 9232011a8e2..00000000000 --- a/docs/en/sql_reference/statements/select.md +++ /dev/null @@ -1,1378 +0,0 @@ ---- -toc_priority: 33 -toc_title: SELECT ---- - -# SELECT Queries Syntax {#select-queries-syntax} - -`SELECT` performs data retrieval. - -``` sql -[WITH expr_list|(subquery)] -SELECT [DISTINCT] expr_list -[FROM [db.]table | (subquery) | table_function] [FINAL] -[SAMPLE sample_coeff] -[ARRAY JOIN ...] -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list -[PREWHERE expr] -[WHERE expr] -[GROUP BY expr_list] [WITH TOTALS] -[HAVING expr] -[ORDER BY expr_list] -[LIMIT [offset_value, ]n BY columns] -[LIMIT [n, ]m] -[UNION ALL ...] -[INTO OUTFILE filename] -[FORMAT format] -``` - -All the clauses are optional, except for the required list of expressions immediately after SELECT. -The clauses below are described in almost the same order as in the query execution conveyor. - -If the query omits the `DISTINCT`, `GROUP BY` and `ORDER BY` clauses and the `IN` and `JOIN` subqueries, the query will be completely stream processed, using O(1) amount of RAM. -Otherwise, the query might consume a lot of RAM if the appropriate restrictions are not specified: `max_memory_usage`, `max_rows_to_group_by`, `max_rows_to_sort`, `max_rows_in_distinct`, `max_bytes_in_distinct`, `max_rows_in_set`, `max_bytes_in_set`, `max_rows_in_join`, `max_bytes_in_join`, `max_bytes_before_external_sort`, `max_bytes_before_external_group_by`. For more information, see the section “Settings”. It is possible to use external sorting (saving temporary tables to a disk) and external aggregation. `The system does not have "merge join"`. - -### WITH Clause {#with-clause} - -This section provides support for Common Table Expressions ([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL)), with some limitations: -1. Recursive queries are not supported -2. When subquery is used inside WITH section, it’s result should be scalar with exactly one row -3. Expression’s results are not available in subqueries -Results of WITH clause expressions can be used inside SELECT clause. - -Example 1: Using constant expression as “variable” - -``` sql -WITH '2019-08-01 15:23:00' as ts_upper_bound -SELECT * -FROM hits -WHERE - EventDate = toDate(ts_upper_bound) AND - EventTime <= ts_upper_bound -``` - -Example 2: Evicting sum(bytes) expression result from SELECT clause column list - -``` sql -WITH sum(bytes) as s -SELECT - formatReadableSize(s), - table -FROM system.parts -GROUP BY table -ORDER BY s -``` - -Example 3: Using results of scalar subquery - -``` sql -/* this example would return TOP 10 of most huge tables */ -WITH - ( - SELECT sum(bytes) - FROM system.parts - WHERE active - ) AS total_disk_usage -SELECT - (sum(bytes) / total_disk_usage) * 100 AS table_disk_usage, - table -FROM system.parts -GROUP BY table -ORDER BY table_disk_usage DESC -LIMIT 10 -``` - -Example 4: Re-using expression in subquery -As a workaround for current limitation for expression usage in subqueries, you may duplicate it. - -``` sql -WITH ['hello'] AS hello -SELECT - hello, - * -FROM -( - WITH ['hello'] AS hello - SELECT hello -) -``` - -``` text -┌─hello─────┬─hello─────┐ -│ ['hello'] │ ['hello'] │ -└───────────┴───────────┘ -``` - -### FROM Clause {#select-from} - -If the FROM clause is omitted, data will be read from the `system.one` table. -The `system.one` table contains exactly one row (this table fulfills the same purpose as the DUAL table found in other DBMSs). - -The `FROM` clause specifies the source to read data from: - -- Table -- Subquery -- [Table function](../table_functions/index.md) - -`ARRAY JOIN` and the regular `JOIN` may also be included (see below). - -Instead of a table, the `SELECT` subquery may be specified in parenthesis. -In contrast to standard SQL, a synonym does not need to be specified after a subquery. - -To execute a query, all the columns listed in the query are extracted from the appropriate table. Any columns not needed for the external query are thrown out of the subqueries. -If a query does not list any columns (for example, `SELECT count() FROM t`), some column is extracted from the table anyway (the smallest one is preferred), in order to calculate the number of rows. - -#### FINAL Modifier {#select-from-final} - -Applicable when selecting data from tables from the [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)-engine family other than `GraphiteMergeTree`. When `FINAL` is specified, ClickHouse fully merges the data before returning the result and thus performs all data transformations that happen during merges for the given table engine. - -Also supported for: -- [Replicated](../../engines/table_engines/mergetree_family/replication.md) versions of `MergeTree` engines. -- [View](../../engines/table_engines/special/view.md), [Buffer](../../engines/table_engines/special/buffer.md), [Distributed](../../engines/table_engines/special/distributed.md), and [MaterializedView](../../engines/table_engines/special/materializedview.md) engines that operate over other engines, provided they were created over `MergeTree`-engine tables. - -Queries that use `FINAL` are executed not as fast as similar queries that don’t, because: - -- Query is executed in a single thread and data is merged during query execution. -- Queries with `FINAL` read primary key columns in addition to the columns specified in the query. - -In most cases, avoid using `FINAL`. - -### SAMPLE Clause {#select-sample-clause} - -The `SAMPLE` clause allows for approximated query processing. - -When data sampling is enabled, the query is not performed on all the data, but only on a certain fraction of data (sample). For example, if you need to calculate statistics for all the visits, it is enough to execute the query on the 1/10 fraction of all the visits and then multiply the result by 10. - -Approximated query processing can be useful in the following cases: - -- When you have strict timing requirements (like \<100ms) but you can’t justify the cost of additional hardware resources to meet them. -- When your raw data is not accurate, so approximation doesn’t noticeably degrade the quality. -- Business requirements target approximate results (for cost-effectiveness, or in order to market exact results to premium users). - -!!! note "Note" - You can only use sampling with the tables in the [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) family, and only if the sampling expression was specified during table creation (see [MergeTree engine](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table)). - -The features of data sampling are listed below: - -- Data sampling is a deterministic mechanism. The result of the same `SELECT .. SAMPLE` query is always the same. -- Sampling works consistently for different tables. For tables with a single sampling key, a sample with the same coefficient always selects the same subset of possible data. For example, a sample of user IDs takes rows with the same subset of all the possible user IDs from different tables. This means that you can use the sample in subqueries in the [IN](#select-in-operators) clause. Also, you can join samples using the [JOIN](#select-join) clause. -- Sampling allows reading less data from a disk. Note that you must specify the sampling key correctly. For more information, see [Creating a MergeTree Table](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). - -For the `SAMPLE` clause the following syntax is supported: - -| SAMPLE Clause Syntax | Description | -|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| -| `SAMPLE k` | Here `k` is the number from 0 to 1.
The query is executed on `k` fraction of data. For example, `SAMPLE 0.1` runs the query on 10% of data. [Read more](#select-sample-k) | -| `SAMPLE n` | Here `n` is a sufficiently large integer.
The query is executed on a sample of at least `n` rows (but not significantly more than this). For example, `SAMPLE 10000000` runs the query on a minimum of 10,000,000 rows. [Read more](#select-sample-n) | -| `SAMPLE k OFFSET m` | Here `k` and `m` are the numbers from 0 to 1.
The query is executed on a sample of `k` fraction of the data. The data used for the sample is offset by `m` fraction. [Read more](#select-sample-offset) | - -#### SAMPLE K {#select-sample-k} - -Here `k` is the number from 0 to 1 (both fractional and decimal notations are supported). For example, `SAMPLE 1/2` or `SAMPLE 0.5`. - -In a `SAMPLE k` clause, the sample is taken from the `k` fraction of data. The example is shown below: - -``` sql -SELECT - Title, - count() * 10 AS PageViews -FROM hits_distributed -SAMPLE 0.1 -WHERE - CounterID = 34 -GROUP BY Title -ORDER BY PageViews DESC LIMIT 1000 -``` - -In this example, the query is executed on a sample from 0.1 (10%) of data. Values of aggregate functions are not corrected automatically, so to get an approximate result, the value `count()` is manually multiplied by 10. - -#### SAMPLE N {#select-sample-n} - -Here `n` is a sufficiently large integer. For example, `SAMPLE 10000000`. - -In this case, the query is executed on a sample of at least `n` rows (but not significantly more than this). For example, `SAMPLE 10000000` runs the query on a minimum of 10,000,000 rows. - -Since the minimum unit for data reading is one granule (its size is set by the `index_granularity` setting), it makes sense to set a sample that is much larger than the size of the granule. - -When using the `SAMPLE n` clause, you don’t know which relative percent of data was processed. So you don’t know the coefficient the aggregate functions should be multiplied by. Use the `_sample_factor` virtual column to get the approximate result. - -The `_sample_factor` column contains relative coefficients that are calculated dynamically. This column is created automatically when you [create](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table) a table with the specified sampling key. The usage examples of the `_sample_factor` column are shown below. - -Let’s consider the table `visits`, which contains the statistics about site visits. The first example shows how to calculate the number of page views: - -``` sql -SELECT sum(PageViews * _sample_factor) -FROM visits -SAMPLE 10000000 -``` - -The next example shows how to calculate the total number of visits: - -``` sql -SELECT sum(_sample_factor) -FROM visits -SAMPLE 10000000 -``` - -The example below shows how to calculate the average session duration. Note that you don’t need to use the relative coefficient to calculate the average values. - -``` sql -SELECT avg(Duration) -FROM visits -SAMPLE 10000000 -``` - -#### SAMPLE K OFFSET M {#select-sample-offset} - -Here `k` and `m` are numbers from 0 to 1. Examples are shown below. - -**Example 1** - -``` sql -SAMPLE 1/10 -``` - -In this example, the sample is 1/10th of all data: - -`[++------------]` - -**Example 2** - -``` sql -SAMPLE 1/10 OFFSET 1/2 -``` - -Here, a sample of 10% is taken from the second half of the data. - -`[------++------]` - -### ARRAY JOIN Clause {#select-array-join-clause} - -Allows executing `JOIN` with an array or nested data structure. The intent is similar to the [arrayJoin](../functions/array_join.md#functions_arrayjoin) function, but its functionality is broader. - -``` sql -SELECT -FROM -[LEFT] ARRAY JOIN -[WHERE|PREWHERE ] -... -``` - -You can specify only a single `ARRAY JOIN` clause in a query. - -The query execution order is optimized when running `ARRAY JOIN`. Although `ARRAY JOIN` must always be specified before the `WHERE/PREWHERE` clause, it can be performed either before `WHERE/PREWHERE` (if the result is needed in this clause), or after completing it (to reduce the volume of calculations). The processing order is controlled by the query optimizer. - -Supported types of `ARRAY JOIN` are listed below: - -- `ARRAY JOIN` - In this case, empty arrays are not included in the result of `JOIN`. -- `LEFT ARRAY JOIN` - The result of `JOIN` contains rows with empty arrays. The value for an empty array is set to the default value for the array element type (usually 0, empty string or NULL). - -The examples below demonstrate the usage of the `ARRAY JOIN` and `LEFT ARRAY JOIN` clauses. Let’s create a table with an [Array](../../sql_reference/data_types/array.md) type column and insert values into it: - -``` sql -CREATE TABLE arrays_test -( - s String, - arr Array(UInt8) -) ENGINE = Memory; - -INSERT INTO arrays_test -VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []); -``` - -``` text -┌─s───────────┬─arr─────┐ -│ Hello │ [1,2] │ -│ World │ [3,4,5] │ -│ Goodbye │ [] │ -└─────────────┴─────────┘ -``` - -The example below uses the `ARRAY JOIN` clause: - -``` sql -SELECT s, arr -FROM arrays_test -ARRAY JOIN arr; -``` - -``` text -┌─s─────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -└───────┴─────┘ -``` - -The next example uses the `LEFT ARRAY JOIN` clause: - -``` sql -SELECT s, arr -FROM arrays_test -LEFT ARRAY JOIN arr; -``` - -``` text -┌─s───────────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -│ Goodbye │ 0 │ -└─────────────┴─────┘ -``` - -#### Using Aliases {#using-aliases} - -An alias can be specified for an array in the `ARRAY JOIN` clause. In this case, an array item can be accessed by this alias, but the array itself is accessed by the original name. Example: - -``` sql -SELECT s, arr, a -FROM arrays_test -ARRAY JOIN arr AS a; -``` - -``` text -┌─s─────┬─arr─────┬─a─┐ -│ Hello │ [1,2] │ 1 │ -│ Hello │ [1,2] │ 2 │ -│ World │ [3,4,5] │ 3 │ -│ World │ [3,4,5] │ 4 │ -│ World │ [3,4,5] │ 5 │ -└───────┴─────────┴───┘ -``` - -Using aliases, you can perform `ARRAY JOIN` with an external array. For example: - -``` sql -SELECT s, arr_external -FROM arrays_test -ARRAY JOIN [1, 2, 3] AS arr_external; -``` - -``` text -┌─s───────────┬─arr_external─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ Hello │ 3 │ -│ World │ 1 │ -│ World │ 2 │ -│ World │ 3 │ -│ Goodbye │ 1 │ -│ Goodbye │ 2 │ -│ Goodbye │ 3 │ -└─────────────┴──────────────┘ -``` - -Multiple arrays can be comma-separated in the `ARRAY JOIN` clause. In this case, `JOIN` is performed with them simultaneously (the direct sum, not the cartesian product). Note that all the arrays must have the same size. Example: - -``` sql -SELECT s, arr, a, num, mapped -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ -│ Hello │ [1,2] │ 1 │ 1 │ 2 │ -│ Hello │ [1,2] │ 2 │ 2 │ 3 │ -│ World │ [3,4,5] │ 3 │ 1 │ 4 │ -│ World │ [3,4,5] │ 4 │ 2 │ 5 │ -│ World │ [3,4,5] │ 5 │ 3 │ 6 │ -└───────┴─────────┴───┴─────┴────────┘ -``` - -The example below uses the [arrayEnumerate](../../sql_reference/functions/array_functions.md#array_functions-arrayenumerate) function: - -``` sql -SELECT s, arr, a, num, arrayEnumerate(arr) -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ -│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ -│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ -│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ -│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ -│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ -└───────┴─────────┴───┴─────┴─────────────────────┘ -``` - -#### ARRAY JOIN With Nested Data Structure {#array-join-with-nested-data-structure} - -`ARRAY`JOIN\`\` also works with [nested data structures](../../sql_reference/data_types/nested_data_structures/nested.md). Example: - -``` sql -CREATE TABLE nested_test -( - s String, - nest Nested( - x UInt8, - y UInt32) -) ENGINE = Memory; - -INSERT INTO nested_test -VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []); -``` - -``` text -┌─s───────┬─nest.x──┬─nest.y─────┐ -│ Hello │ [1,2] │ [10,20] │ -│ World │ [3,4,5] │ [30,40,50] │ -│ Goodbye │ [] │ [] │ -└─────────┴─────────┴────────────┘ -``` - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -When specifying names of nested data structures in `ARRAY JOIN`, the meaning is the same as `ARRAY JOIN` with all the array elements that it consists of. Examples are listed below: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`, `nest.y`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -This variation also makes sense: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─────┐ -│ Hello │ 1 │ [10,20] │ -│ Hello │ 2 │ [10,20] │ -│ World │ 3 │ [30,40,50] │ -│ World │ 4 │ [30,40,50] │ -│ World │ 5 │ [30,40,50] │ -└───────┴────────┴────────────┘ -``` - -An alias may be used for a nested data structure, in order to select either the `JOIN` result or the source array. Example: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest AS n; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ -└───────┴─────┴─────┴─────────┴────────────┘ -``` - -Example of using the [arrayEnumerate](../../sql_reference/functions/array_functions.md#array_functions-arrayenumerate) function: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num -FROM nested_test -ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ -└───────┴─────┴─────┴─────────┴────────────┴─────┘ -``` - -### JOIN Clause {#select-join} - -Joins the data in the normal [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) sense. - -!!! info "Note" - Not related to [ARRAY JOIN](#select-array-join-clause). - -``` sql -SELECT -FROM -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN -(ON )|(USING ) ... -``` - -The table names can be specified instead of `` and ``. This is equivalent to the `SELECT * FROM table` subquery, except in a special case when the table has the [Join](../../engines/table_engines/special/join.md) engine – an array prepared for joining. - -#### Supported Types Of `JOIN` {#select-join-types} - -- `INNER JOIN` (or `JOIN`) -- `LEFT JOIN` (or `LEFT OUTER JOIN`) -- `RIGHT JOIN` (or `RIGHT OUTER JOIN`) -- `FULL JOIN` (or `FULL OUTER JOIN`) -- `CROSS JOIN` (or `,` ) - -See the standard [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) description. - -#### Multiple JOIN {#multiple-join} - -Performing queries, ClickHouse rewrites multi-table joins into the sequence of two-table joins. For example, if there are four tables for join ClickHouse joins the first and the second, then joins the result with the third table, and at the last step, it joins the fourth one. - -If a query contains the `WHERE` clause, ClickHouse tries to pushdown filters from this clause through the intermediate join. If it cannot apply the filter to each intermediate join, ClickHouse applies the filters after all joins are completed. - -We recommend the `JOIN ON` or `JOIN USING` syntax for creating queries. For example: - -``` sql -SELECT * FROM t1 JOIN t2 ON t1.a = t2.a JOIN t3 ON t1.a = t3.a -``` - -You can use comma-separated lists of tables in the `FROM` clause. For example: - -``` sql -SELECT * FROM t1, t2, t3 WHERE t1.a = t2.a AND t1.a = t3.a -``` - -Don’t mix these syntaxes. - -ClickHouse doesn’t directly support syntax with commas, so we don’t recommend using them. The algorithm tries to rewrite the query in terms of `CROSS JOIN` and `INNER JOIN` clauses and then proceeds to query processing. When rewriting the query, ClickHouse tries to optimize performance and memory consumption. By default, ClickHouse treats commas as an `INNER JOIN` clause and converts `INNER JOIN` to `CROSS JOIN` when the algorithm cannot guarantee that `INNER JOIN` returns the required data. - -#### Strictness {#select-join-strictness} - -- `ALL` — If the right table has several matching rows, ClickHouse creates a [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) from matching rows. This is the standard `JOIN` behavior in SQL. -- `ANY` — If the right table has several matching rows, only the first one found is joined. If the right table has only one matching row, the results of queries with `ANY` and `ALL` keywords are the same. -- `ASOF` — For joining sequences with a non-exact match. `ASOF JOIN` usage is described below. - -**ASOF JOIN Usage** - -`ASOF JOIN` is useful when you need to join records that have no exact match. - -Tables for `ASOF JOIN` must have an ordered sequence column. This column cannot be alone in a table, and should be one of the data types: `UInt32`, `UInt64`, `Float32`, `Float64`, `Date`, and `DateTime`. - -Syntax `ASOF JOIN ... ON`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF LEFT JOIN table_2 -ON equi_cond AND closest_match_cond -``` - -You can use any number of equality conditions and exactly one closest match condition. For example, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`. - -Conditions supported for the closest match: `>`, `>=`, `<`, `<=`. - -Syntax `ASOF JOIN ... USING`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF JOIN table_2 -USING (equi_column1, ... equi_columnN, asof_column) -``` - -`ASOF JOIN` uses `equi_columnX` for joining on equality and `asof_column` for joining on the closest match with the `table_1.asof_column >= table_2.asof_column` condition. The `asof_column` column always the last one in the `USING` clause. - -For example, consider the following tables: - - table_1 table_2 - event | ev_time | user_id event | ev_time | user_id - ----------|---------|---------- ----------|---------|---------- - ... ... - event_1_1 | 12:00 | 42 event_2_1 | 11:59 | 42 - ... event_2_2 | 12:30 | 42 - event_1_2 | 13:00 | 42 event_2_3 | 13:00 | 42 - ... ... - - -`ASOF JOIN` can take the timestamp of a user event from `table_1` and find an event in `table_2` where the timestamp is closest to the timestamp of the event from `table_1` corresponding to the closest match condition. Equal timestamp values are the closest if available. Here, the `user_id` column can be used for joining on equality and the `ev_time` column can be used for joining on the closest match. In our example, `event_1_1` can be joined with `event_2_1` and `event_1_2` can be joined with `event_2_3`, but `event_2_2` can’t be joined. - -!!! note "Note" - `ASOF` join is **not** supported in the [Join](../../engines/table_engines/special/join.md) table engine. - -To set the default strictness value, use the session configuration parameter [join\_default\_strictness](../../operations/settings/settings.md#settings-join_default_strictness). - -#### GLOBAL JOIN {#global-join} - -When using a normal `JOIN`, the query is sent to remote servers. Subqueries are run on each of them in order to make the right table, and the join is performed with this table. In other words, the right table is formed on each server separately. - -When using `GLOBAL ... JOIN`, first the requestor server runs a subquery to calculate the right table. This temporary table is passed to each remote server, and queries are run on them using the temporary data that was transmitted. - -Be careful when using `GLOBAL`. For more information, see the section [Distributed subqueries](#select-distributed-subqueries). - -#### Usage Recommendations {#usage-recommendations} - -When running a `JOIN`, there is no optimization of the order of execution in relation to other stages of the query. The join (a search in the right table) is run before filtering in `WHERE` and before aggregation. In order to explicitly set the processing order, we recommend running a `JOIN` subquery with a subquery. - -Example: - -``` sql -SELECT - CounterID, - hits, - visits -FROM -( - SELECT - CounterID, - count() AS hits - FROM test.hits - GROUP BY CounterID -) ANY LEFT JOIN -( - SELECT - CounterID, - sum(Sign) AS visits - FROM test.visits - GROUP BY CounterID -) USING CounterID -ORDER BY hits DESC -LIMIT 10 -``` - -``` text -┌─CounterID─┬───hits─┬─visits─┐ -│ 1143050 │ 523264 │ 13665 │ -│ 731962 │ 475698 │ 102716 │ -│ 722545 │ 337212 │ 108187 │ -│ 722889 │ 252197 │ 10547 │ -│ 2237260 │ 196036 │ 9522 │ -│ 23057320 │ 147211 │ 7689 │ -│ 722818 │ 90109 │ 17847 │ -│ 48221 │ 85379 │ 4652 │ -│ 19762435 │ 77807 │ 7026 │ -│ 722884 │ 77492 │ 11056 │ -└───────────┴────────┴────────┘ -``` - -Subqueries don’t allow you to set names or use them for referencing a column from a specific subquery. -The columns specified in `USING` must have the same names in both subqueries, and the other columns must be named differently. You can use aliases to change the names of columns in subqueries (the example uses the aliases `hits` and `visits`). - -The `USING` clause specifies one or more columns to join, which establishes the equality of these columns. The list of columns is set without brackets. More complex join conditions are not supported. - -The right table (the subquery result) resides in RAM. If there isn’t enough memory, you can’t run a `JOIN`. - -Each time a query is run with the same `JOIN`, the subquery is run again because the result is not cached. To avoid this, use the special [Join](../../engines/table_engines/special/join.md) table engine, which is a prepared array for joining that is always in RAM. - -In some cases, it is more efficient to use `IN` instead of `JOIN`. -Among the various types of `JOIN`, the most efficient is `ANY LEFT JOIN`, then `ANY INNER JOIN`. The least efficient are `ALL LEFT JOIN` and `ALL INNER JOIN`. - -If you need a `JOIN` for joining with dimension tables (these are relatively small tables that contain dimension properties, such as names for advertising campaigns), a `JOIN` might not be very convenient due to the fact that the right table is re-accessed for every query. For such cases, there is an “external dictionaries” feature that you should use instead of `JOIN`. For more information, see the section [External dictionaries](../dictionaries/external_dictionaries/external_dicts.md). - -**Memory Limitations** - -ClickHouse uses the [hash join](https://en.wikipedia.org/wiki/Hash_join) algorithm. ClickHouse takes the `` and creates a hash table for it in RAM. If you need to restrict join operation memory consumption use the following settings: - -- [max\_rows\_in\_join](../../operations/settings/query_complexity.md#settings-max_rows_in_join) — Limits number of rows in the hash table. -- [max\_bytes\_in\_join](../../operations/settings/query_complexity.md#settings-max_bytes_in_join) — Limits size of the hash table. - -When any of these limits is reached, ClickHouse acts as the [join\_overflow\_mode](../../operations/settings/query_complexity.md#settings-join_overflow_mode) setting instructs. - -#### Processing of Empty or NULL Cells {#processing-of-empty-or-null-cells} - -While joining tables, the empty cells may appear. The setting [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls) define how ClickHouse fills these cells. - -If the `JOIN` keys are [Nullable](../data_types/nullable.md) fields, the rows where at least one of the keys has the value [NULL](../syntax.md#null-literal) are not joined. - -#### Syntax Limitations {#syntax-limitations} - -For multiple `JOIN` clauses in a single `SELECT` query: - -- Taking all the columns via `*` is available only if tables are joined, not subqueries. -- The `PREWHERE` clause is not available. - -For `ON`, `WHERE`, and `GROUP BY` clauses: - -- Arbitrary expressions cannot be used in `ON`, `WHERE`, and `GROUP BY` clauses, but you can define an expression in a `SELECT` clause and then use it in these clauses via an alias. - -### WHERE Clause {#select-where} - -If there is a WHERE clause, it must contain an expression with the UInt8 type. This is usually an expression with comparison and logical operators. -This expression will be used for filtering data before all other transformations. - -If indexes are supported by the database table engine, the expression is evaluated on the ability to use indexes. - -### PREWHERE Clause {#prewhere-clause} - -This clause has the same meaning as the WHERE clause. The difference is in which data is read from the table. -When using PREWHERE, first only the columns necessary for executing PREWHERE are read. Then the other columns are read that are needed for running the query, but only those blocks where the PREWHERE expression is true. - -It makes sense to use PREWHERE if there are filtration conditions that are used by a minority of the columns in the query, but that provide strong data filtration. This reduces the volume of data to read. - -For example, it is useful to write PREWHERE for queries that extract a large number of columns, but that only have filtration for a few columns. - -PREWHERE is only supported by tables from the `*MergeTree` family. - -A query may simultaneously specify PREWHERE and WHERE. In this case, PREWHERE precedes WHERE. - -If the ‘optimize\_move\_to\_prewhere’ setting is set to 1 and PREWHERE is omitted, the system uses heuristics to automatically move parts of expressions from WHERE to PREWHERE. - -### GROUP BY Clause {#select-group-by-clause} - -This is one of the most important parts of a column-oriented DBMS. - -If there is a GROUP BY clause, it must contain a list of expressions. Each expression will be referred to here as a “key”. -All the expressions in the SELECT, HAVING, and ORDER BY clauses must be calculated from keys or from aggregate functions. In other words, each column selected from the table must be used either in keys or inside aggregate functions. - -If a query contains only table columns inside aggregate functions, the GROUP BY clause can be omitted, and aggregation by an empty set of keys is assumed. - -Example: - -``` sql -SELECT - count(), - median(FetchTiming > 60 ? 60 : FetchTiming), - count() - sum(Refresh) -FROM hits -``` - -However, in contrast to standard SQL, if the table doesn’t have any rows (either there aren’t any at all, or there aren’t any after using WHERE to filter), an empty result is returned, and not the result from one of the rows containing the initial values of aggregate functions. - -As opposed to MySQL (and conforming to standard SQL), you can’t get some value of some column that is not in a key or aggregate function (except constant expressions). To work around this, you can use the ‘any’ aggregate function (get the first encountered value) or ‘min/max’. - -Example: - -``` sql -SELECT - domainWithoutWWW(URL) AS domain, - count(), - any(Title) AS title -- getting the first occurred page header for each domain. -FROM hits -GROUP BY domain -``` - -For every different key value encountered, GROUP BY calculates a set of aggregate function values. - -GROUP BY is not supported for array columns. - -A constant can’t be specified as arguments for aggregate functions. Example: sum(1). Instead of this, you can get rid of the constant. Example: `count()`. - -#### NULL processing {#null-processing} - -For grouping, ClickHouse interprets [NULL](../syntax.md) as a value, and `NULL=NULL`. - -Here’s an example to show what this means. - -Assume you have this table: - -``` text -┌─x─┬────y─┐ -│ 1 │ 2 │ -│ 2 │ ᴺᵁᴸᴸ │ -│ 3 │ 2 │ -│ 3 │ 3 │ -│ 3 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -The query `SELECT sum(x), y FROM t_null_big GROUP BY y` results in: - -``` text -┌─sum(x)─┬────y─┐ -│ 4 │ 2 │ -│ 3 │ 3 │ -│ 5 │ ᴺᵁᴸᴸ │ -└────────┴──────┘ -``` - -You can see that `GROUP BY` for `y = NULL` summed up `x`, as if `NULL` is this value. - -If you pass several keys to `GROUP BY`, the result will give you all the combinations of the selection, as if `NULL` were a specific value. - -#### WITH TOTALS Modifier {#with-totals-modifier} - -If the WITH TOTALS modifier is specified, another row will be calculated. This row will have key columns containing default values (zeros or empty lines), and columns of aggregate functions with the values calculated across all the rows (the “total” values). - -This extra row is output in JSON\*, TabSeparated\*, and Pretty\* formats, separately from the other rows. In the other formats, this row is not output. - -In JSON\* formats, this row is output as a separate ‘totals’ field. In TabSeparated\* formats, the row comes after the main result, preceded by an empty row (after the other data). In Pretty\* formats, the row is output as a separate table after the main result. - -`WITH TOTALS` can be run in different ways when HAVING is present. The behavior depends on the ‘totals\_mode’ setting. -By default, `totals_mode = 'before_having'`. In this case, ‘totals’ is calculated across all rows, including the ones that don’t pass through HAVING and ‘max\_rows\_to\_group\_by’. - -The other alternatives include only the rows that pass through HAVING in ‘totals’, and behave differently with the setting `max_rows_to_group_by` and `group_by_overflow_mode = 'any'`. - -`after_having_exclusive` – Don’t include rows that didn’t pass through `max_rows_to_group_by`. In other words, ‘totals’ will have less than or the same number of rows as it would if `max_rows_to_group_by` were omitted. - -`after_having_inclusive` – Include all the rows that didn’t pass through ‘max\_rows\_to\_group\_by’ in ‘totals’. In other words, ‘totals’ will have more than or the same number of rows as it would if `max_rows_to_group_by` were omitted. - -`after_having_auto` – Count the number of rows that passed through HAVING. If it is more than a certain amount (by default, 50%), include all the rows that didn’t pass through ‘max\_rows\_to\_group\_by’ in ‘totals’. Otherwise, do not include them. - -`totals_auto_threshold` – By default, 0.5. The coefficient for `after_having_auto`. - -If `max_rows_to_group_by` and `group_by_overflow_mode = 'any'` are not used, all variations of `after_having` are the same, and you can use any of them (for example, `after_having_auto`). - -You can use WITH TOTALS in subqueries, including subqueries in the JOIN clause (in this case, the respective total values are combined). - -#### GROUP BY in External Memory {#select-group-by-in-external-memory} - -You can enable dumping temporary data to the disk to restrict memory usage during `GROUP BY`. -The [max\_bytes\_before\_external\_group\_by](../../operations/settings/settings.md#settings-max_bytes_before_external_group_by) setting determines the threshold RAM consumption for dumping `GROUP BY` temporary data to the file system. If set to 0 (the default), it is disabled. - -When using `max_bytes_before_external_group_by`, we recommend that you set `max_memory_usage` about twice as high. This is necessary because there are two stages to aggregation: reading the date and forming intermediate data (1) and merging the intermediate data (2). Dumping data to the file system can only occur during stage 1. If the temporary data wasn’t dumped, then stage 2 might require up to the same amount of memory as in stage 1. - -For example, if [max\_memory\_usage](../../operations/settings/settings.md#settings_max_memory_usage) was set to 10000000000 and you want to use external aggregation, it makes sense to set `max_bytes_before_external_group_by` to 10000000000, and max\_memory\_usage to 20000000000. When external aggregation is triggered (if there was at least one dump of temporary data), maximum consumption of RAM is only slightly more than `max_bytes_before_external_group_by`. - -With distributed query processing, external aggregation is performed on remote servers. In order for the requester server to use only a small amount of RAM, set `distributed_aggregation_memory_efficient` to 1. - -When merging data flushed to the disk, as well as when merging results from remote servers when the `distributed_aggregation_memory_efficient` setting is enabled, consumes up to `1/256 * the_number_of_threads` from the total amount of RAM. - -When external aggregation is enabled, if there was less than `max_bytes_before_external_group_by` of data (i.e. data was not flushed), the query runs just as fast as without external aggregation. If any temporary data was flushed, the run time will be several times longer (approximately three times). - -If you have an `ORDER BY` with a `LIMIT` after `GROUP BY`, then the amount of used RAM depends on the amount of data in `LIMIT`, not in the whole table. But if the `ORDER BY` doesn’t have `LIMIT`, don’t forget to enable external sorting (`max_bytes_before_external_sort`). - -### LIMIT BY Clause {#limit-by-clause} - -A query with the `LIMIT n BY expressions` clause selects the first `n` rows for each distinct value of `expressions`. The key for `LIMIT BY` can contain any number of [expressions](../syntax.md#syntax-expressions). - -ClickHouse supports the following syntax: - -- `LIMIT [offset_value, ]n BY expressions` -- `LIMIT n OFFSET offset_value BY expressions` - -During query processing, ClickHouse selects data ordered by sorting key. The sorting key is set explicitly using an [ORDER BY](#select-order-by) clause or implicitly as a property of the table engine. Then ClickHouse applies `LIMIT n BY expressions` and returns the first `n` rows for each distinct combination of `expressions`. If `OFFSET` is specified, then for each data block that belongs to a distinct combination of `expressions`, ClickHouse skips `offset_value` number of rows from the beginning of the block and returns a maximum of `n` rows as a result. If `offset_value` is bigger than the number of rows in the data block, ClickHouse returns zero rows from the block. - -`LIMIT BY` is not related to `LIMIT`. They can both be used in the same query. - -**Examples** - -Sample table: - -``` sql -CREATE TABLE limit_by(id Int, val Int) ENGINE = Memory; -INSERT INTO limit_by values(1, 10), (1, 11), (1, 12), (2, 20), (2, 21); -``` - -Queries: - -``` sql -SELECT * FROM limit_by ORDER BY id, val LIMIT 2 BY id -``` - -``` text -┌─id─┬─val─┐ -│ 1 │ 10 │ -│ 1 │ 11 │ -│ 2 │ 20 │ -│ 2 │ 21 │ -└────┴─────┘ -``` - -``` sql -SELECT * FROM limit_by ORDER BY id, val LIMIT 1, 2 BY id -``` - -``` text -┌─id─┬─val─┐ -│ 1 │ 11 │ -│ 1 │ 12 │ -│ 2 │ 21 │ -└────┴─────┘ -``` - -The `SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` query returns the same result. - -The following query returns the top 5 referrers for each `domain, device_type` pair with a maximum of 100 rows in total (`LIMIT n BY + LIMIT`). - -``` sql -SELECT - domainWithoutWWW(URL) AS domain, - domainWithoutWWW(REFERRER_URL) AS referrer, - device_type, - count() cnt -FROM hits -GROUP BY domain, referrer, device_type -ORDER BY cnt DESC -LIMIT 5 BY domain, device_type -LIMIT 100 -``` - -### HAVING Clause {#having-clause} - -Allows filtering the result received after GROUP BY, similar to the WHERE clause. -WHERE and HAVING differ in that WHERE is performed before aggregation (GROUP BY), while HAVING is performed after it. -If aggregation is not performed, HAVING can’t be used. - -### ORDER BY Clause {#select-order-by} - -The ORDER BY clause contains a list of expressions, which can each be assigned DESC or ASC (the sorting direction). If the direction is not specified, ASC is assumed. ASC is sorted in ascending order, and DESC in descending order. The sorting direction applies to a single expression, not to the entire list. Example: `ORDER BY Visits DESC, SearchPhrase` - -For sorting by String values, you can specify collation (comparison). Example: `ORDER BY SearchPhrase COLLATE 'tr'` - for sorting by keyword in ascending order, using the Turkish alphabet, case insensitive, assuming that strings are UTF-8 encoded. COLLATE can be specified or not for each expression in ORDER BY independently. If ASC or DESC is specified, COLLATE is specified after it. When using COLLATE, sorting is always case-insensitive. - -We only recommend using COLLATE for final sorting of a small number of rows, since sorting with COLLATE is less efficient than normal sorting by bytes. - -Rows that have identical values for the list of sorting expressions are output in an arbitrary order, which can also be nondeterministic (different each time). -If the ORDER BY clause is omitted, the order of the rows is also undefined, and may be nondeterministic as well. - -`NaN` and `NULL` sorting order: - -- With the modifier `NULLS FIRST` — First `NULL`, then `NaN`, then other values. -- With the modifier `NULLS LAST` — First the values, then `NaN`, then `NULL`. -- Default — The same as with the `NULLS LAST` modifier. - -Example: - -For the table - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 2 │ -│ 1 │ nan │ -│ 2 │ 2 │ -│ 3 │ 4 │ -│ 5 │ 6 │ -│ 6 │ nan │ -│ 7 │ ᴺᵁᴸᴸ │ -│ 6 │ 7 │ -│ 8 │ 9 │ -└───┴──────┘ -``` - -Run the query `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` to get: - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 7 │ ᴺᵁᴸᴸ │ -│ 1 │ nan │ -│ 6 │ nan │ -│ 2 │ 2 │ -│ 2 │ 2 │ -│ 3 │ 4 │ -│ 5 │ 6 │ -│ 6 │ 7 │ -│ 8 │ 9 │ -└───┴──────┘ -``` - -When floating point numbers are sorted, NaNs are separate from the other values. Regardless of the sorting order, NaNs come at the end. In other words, for ascending sorting they are placed as if they are larger than all the other numbers, while for descending sorting they are placed as if they are smaller than the rest. - -Less RAM is used if a small enough LIMIT is specified in addition to ORDER BY. Otherwise, the amount of memory spent is proportional to the volume of data for sorting. For distributed query processing, if GROUP BY is omitted, sorting is partially done on remote servers, and the results are merged on the requestor server. This means that for distributed sorting, the volume of data to sort can be greater than the amount of memory on a single server. - -If there is not enough RAM, it is possible to perform sorting in external memory (creating temporary files on a disk). Use the setting `max_bytes_before_external_sort` for this purpose. If it is set to 0 (the default), external sorting is disabled. If it is enabled, when the volume of data to sort reaches the specified number of bytes, the collected data is sorted and dumped into a temporary file. After all data is read, all the sorted files are merged and the results are output. Files are written to the /var/lib/clickhouse/tmp/ directory in the config (by default, but you can use the ‘tmp\_path’ parameter to change this setting). - -Running a query may use more memory than ‘max\_bytes\_before\_external\_sort’. For this reason, this setting must have a value significantly smaller than ‘max\_memory\_usage’. As an example, if your server has 128 GB of RAM and you need to run a single query, set ‘max\_memory\_usage’ to 100 GB, and ‘max\_bytes\_before\_external\_sort’ to 80 GB. - -External sorting works much less effectively than sorting in RAM. - -### SELECT Clause {#select-select} - -[Expressions](../syntax.md#syntax-expressions) specified in the `SELECT` clause are calculated after all the operations in the clauses described above are finished. These expressions work as if they apply to separate rows in the result. If expressions in the `SELECT` clause contain aggregate functions, then ClickHouse processes aggregate functions and expressions used as their arguments during the [GROUP BY](#select-group-by-clause) aggregation. - -If you want to include all columns in the result, use the asterisk (`*`) symbol. For example, `SELECT * FROM ...`. - -To match some columns in the result with a [re2](https://en.wikipedia.org/wiki/RE2_(software)) regular expression, you can use the `COLUMNS` expression. - -``` sql -COLUMNS('regexp') -``` - -For example, consider the table: - -``` sql -CREATE TABLE default.col_names (aa Int8, ab Int8, bc Int8) ENGINE = TinyLog -``` - -The following query selects data from all the columns containing the `a` symbol in their name. - -``` sql -SELECT COLUMNS('a') FROM col_names -``` - -``` text -┌─aa─┬─ab─┐ -│ 1 │ 1 │ -└────┴────┘ -``` - -The selected columns are returned not in the alphabetical order. - -You can use multiple `COLUMNS` expressions in a query and apply functions to them. - -For example: - -``` sql -SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names -``` - -``` text -┌─aa─┬─ab─┬─bc─┬─toTypeName(bc)─┐ -│ 1 │ 1 │ 1 │ Int8 │ -└────┴────┴────┴────────────────┘ -``` - -Each column returned by the `COLUMNS` expression is passed to the function as a separate argument. Also you can pass other arguments to the function if it supports them. Be careful when using functions. If a function doesn’t support the number of arguments you have passed to it, ClickHouse throws an exception. - -For example: - -``` sql -SELECT COLUMNS('a') + COLUMNS('c') FROM col_names -``` - -``` text -Received exception from server (version 19.14.1): -Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of arguments for function plus doesn't match: passed 3, should be 2. -``` - -In this example, `COLUMNS('a')` returns two columns: `aa` and `ab`. `COLUMNS('c')` returns the `bc` column. The `+` operator can’t apply to 3 arguments, so ClickHouse throws an exception with the relevant message. - -Columns that matched the `COLUMNS` expression can have different data types. If `COLUMNS` doesn’t match any columns and is the only expression in `SELECT`, ClickHouse throws an exception. - -### DISTINCT Clause {#select-distinct} - -If DISTINCT is specified, only a single row will remain out of all the sets of fully matching rows in the result. -The result will be the same as if GROUP BY were specified across all the fields specified in SELECT without aggregate functions. But there are several differences from GROUP BY: - -- DISTINCT can be applied together with GROUP BY. -- When ORDER BY is omitted and LIMIT is defined, the query stops running immediately after the required number of different rows has been read. -- Data blocks are output as they are processed, without waiting for the entire query to finish running. - -DISTINCT is not supported if SELECT has at least one array column. - -`DISTINCT` works with [NULL](../syntax.md) as if `NULL` were a specific value, and `NULL=NULL`. In other words, in the `DISTINCT` results, different combinations with `NULL` only occur once. - -ClickHouse supports using the `DISTINCT` and `ORDER BY` clauses for different columns in one query. The `DISTINCT` clause is executed before the `ORDER BY` clause. - -Example table: - -``` text -┌─a─┬─b─┐ -│ 2 │ 1 │ -│ 1 │ 2 │ -│ 3 │ 3 │ -│ 2 │ 4 │ -└───┴───┘ -``` - -When selecting data with the `SELECT DISTINCT a FROM t1 ORDER BY b ASC` query, we get the following result: - -``` text -┌─a─┐ -│ 2 │ -│ 1 │ -│ 3 │ -└───┘ -``` - -If we change the sorting direction `SELECT DISTINCT a FROM t1 ORDER BY b DESC`, we get the following result: - -``` text -┌─a─┐ -│ 3 │ -│ 1 │ -│ 2 │ -└───┘ -``` - -Row `2, 4` was cut before sorting. - -Take this implementation specificity into account when programming queries. - -### LIMIT Clause {#limit-clause} - -`LIMIT m` allows you to select the first `m` rows from the result. - -`LIMIT n, m` allows you to select the first `m` rows from the result after skipping the first `n` rows. The `LIMIT m OFFSET n` syntax is also supported. - -`n` and `m` must be non-negative integers. - -If there isn’t an `ORDER BY` clause that explicitly sorts results, the result may be arbitrary and nondeterministic. - -### UNION ALL Clause {#union-all-clause} - -You can use UNION ALL to combine any number of queries. Example: - -``` sql -SELECT CounterID, 1 AS table, toInt64(count()) AS c - FROM test.hits - GROUP BY CounterID - -UNION ALL - -SELECT CounterID, 2 AS table, sum(Sign) AS c - FROM test.visits - GROUP BY CounterID - HAVING c > 0 -``` - -Only UNION ALL is supported. The regular UNION (UNION DISTINCT) is not supported. If you need UNION DISTINCT, you can write SELECT DISTINCT from a subquery containing UNION ALL. - -Queries that are parts of UNION ALL can be run simultaneously, and their results can be mixed together. - -The structure of results (the number and type of columns) must match for the queries. But the column names can differ. In this case, the column names for the final result will be taken from the first query. Type casting is performed for unions. For example, if two queries being combined have the same field with non-`Nullable` and `Nullable` types from a compatible type, the resulting `UNION ALL` has a `Nullable` type field. - -Queries that are parts of UNION ALL can’t be enclosed in brackets. ORDER BY and LIMIT are applied to separate queries, not to the final result. If you need to apply a conversion to the final result, you can put all the queries with UNION ALL in a subquery in the FROM clause. - -### INTO OUTFILE Clause {#into-outfile-clause} - -Add the `INTO OUTFILE filename` clause (where filename is a string literal) to redirect query output to the specified file. -In contrast to MySQL, the file is created on the client side. The query will fail if a file with the same filename already exists. -This functionality is available in the command-line client and clickhouse-local (a query sent via HTTP interface will fail). - -The default output format is TabSeparated (the same as in the command-line client batch mode). - -### FORMAT Clause {#format-clause} - -Specify ‘FORMAT format’ to get data in any specified format. -You can use this for convenience, or for creating dumps. -For more information, see the section “Formats”. -If the FORMAT clause is omitted, the default format is used, which depends on both the settings and the interface used for accessing the DB. For the HTTP interface and the command-line client in batch mode, the default format is TabSeparated. For the command-line client in interactive mode, the default format is PrettyCompact (it has attractive and compact tables). - -When using the command-line client, data is passed to the client in an internal efficient format. The client independently interprets the FORMAT clause of the query and formats the data itself (thus relieving the network and the server from the load). - -### IN Operators {#select-in-operators} - -The `IN`, `NOT IN`, `GLOBAL IN`, and `GLOBAL NOT IN` operators are covered separately, since their functionality is quite rich. - -The left side of the operator is either a single column or a tuple. - -Examples: - -``` sql -SELECT UserID IN (123, 456) FROM ... -SELECT (CounterID, UserID) IN ((34, 123), (101500, 456)) FROM ... -``` - -If the left side is a single column that is in the index, and the right side is a set of constants, the system uses the index for processing the query. - -Don’t list too many values explicitly (i.e. millions). If a data set is large, put it in a temporary table (for example, see the section “External data for query processing”), then use a subquery. - -The right side of the operator can be a set of constant expressions, a set of tuples with constant expressions (shown in the examples above), or the name of a database table or SELECT subquery in brackets. - -If the right side of the operator is the name of a table (for example, `UserID IN users`), this is equivalent to the subquery `UserID IN (SELECT * FROM users)`. Use this when working with external data that is sent along with the query. For example, the query can be sent together with a set of user IDs loaded to the ‘users’ temporary table, which should be filtered. - -If the right side of the operator is a table name that has the Set engine (a prepared data set that is always in RAM), the data set will not be created over again for each query. - -The subquery may specify more than one column for filtering tuples. -Example: - -``` sql -SELECT (CounterID, UserID) IN (SELECT CounterID, UserID FROM ...) FROM ... -``` - -The columns to the left and right of the IN operator should have the same type. - -The IN operator and subquery may occur in any part of the query, including in aggregate functions and lambda functions. -Example: - -``` sql -SELECT - EventDate, - avg(UserID IN - ( - SELECT UserID - FROM test.hits - WHERE EventDate = toDate('2014-03-17') - )) AS ratio -FROM test.hits -GROUP BY EventDate -ORDER BY EventDate ASC -``` - -``` text -┌──EventDate─┬────ratio─┐ -│ 2014-03-17 │ 1 │ -│ 2014-03-18 │ 0.807696 │ -│ 2014-03-19 │ 0.755406 │ -│ 2014-03-20 │ 0.723218 │ -│ 2014-03-21 │ 0.697021 │ -│ 2014-03-22 │ 0.647851 │ -│ 2014-03-23 │ 0.648416 │ -└────────────┴──────────┘ -``` - -For each day after March 17th, count the percentage of pageviews made by users who visited the site on March 17th. -A subquery in the IN clause is always run just one time on a single server. There are no dependent subqueries. - -#### NULL processing {#null-processing-1} - -During request processing, the IN operator assumes that the result of an operation with [NULL](../syntax.md) is always equal to `0`, regardless of whether `NULL` is on the right or left side of the operator. `NULL` values are not included in any dataset, do not correspond to each other and cannot be compared. - -Here is an example with the `t_null` table: - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Running the query `SELECT x FROM t_null WHERE y IN (NULL,3)` gives you the following result: - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -You can see that the row in which `y = NULL` is thrown out of the query results. This is because ClickHouse can’t decide whether `NULL` is included in the `(NULL,3)` set, returns `0` as the result of the operation, and `SELECT` excludes this row from the final output. - -``` sql -SELECT y IN (NULL, 3) -FROM t_null -``` - -``` text -┌─in(y, tuple(NULL, 3))─┐ -│ 0 │ -│ 1 │ -└───────────────────────┘ -``` - -#### Distributed Subqueries {#select-distributed-subqueries} - -There are two options for IN-s with subqueries (similar to JOINs): normal `IN` / `JOIN` and `GLOBAL IN` / `GLOBAL JOIN`. They differ in how they are run for distributed query processing. - -!!! attention "Attention" - Remember that the algorithms described below may work differently depending on the [settings](../../operations/settings/settings.md) `distributed_product_mode` setting. - -When using the regular IN, the query is sent to remote servers, and each of them runs the subqueries in the `IN` or `JOIN` clause. - -When using `GLOBAL IN` / `GLOBAL JOINs`, first all the subqueries are run for `GLOBAL IN` / `GLOBAL JOINs`, and the results are collected in temporary tables. Then the temporary tables are sent to each remote server, where the queries are run using this temporary data. - -For a non-distributed query, use the regular `IN` / `JOIN`. - -Be careful when using subqueries in the `IN` / `JOIN` clauses for distributed query processing. - -Let’s look at some examples. Assume that each server in the cluster has a normal **local\_table**. Each server also has a **distributed\_table** table with the **Distributed** type, which looks at all the servers in the cluster. - -For a query to the **distributed\_table**, the query will be sent to all the remote servers and run on them using the **local\_table**. - -For example, the query - -``` sql -SELECT uniq(UserID) FROM distributed_table -``` - -will be sent to all remote servers as - -``` sql -SELECT uniq(UserID) FROM local_table -``` - -and run on each of them in parallel, until it reaches the stage where intermediate results can be combined. Then the intermediate results will be returned to the requestor server and merged on it, and the final result will be sent to the client. - -Now let’s examine a query with IN: - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) -``` - -- Calculation of the intersection of audiences of two sites. - -This query will be sent to all remote servers as - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) -``` - -In other words, the data set in the IN clause will be collected on each server independently, only across the data that is stored locally on each of the servers. - -This will work correctly and optimally if you are prepared for this case and have spread data across the cluster servers such that the data for a single UserID resides entirely on a single server. In this case, all the necessary data will be available locally on each server. Otherwise, the result will be inaccurate. We refer to this variation of the query as “local IN”. - -To correct how the query works when data is spread randomly across the cluster servers, you could specify **distributed\_table** inside a subquery. The query would look like this: - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -This query will be sent to all remote servers as - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -The subquery will begin running on each remote server. Since the subquery uses a distributed table, the subquery that is on each remote server will be resent to every remote server as - -``` sql -SELECT UserID FROM local_table WHERE CounterID = 34 -``` - -For example, if you have a cluster of 100 servers, executing the entire query will require 10,000 elementary requests, which is generally considered unacceptable. - -In such cases, you should always use GLOBAL IN instead of IN. Let’s look at how it works for the query - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID GLOBAL IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -The requestor server will run the subquery - -``` sql -SELECT UserID FROM distributed_table WHERE CounterID = 34 -``` - -and the result will be put in a temporary table in RAM. Then the request will be sent to each remote server as - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID GLOBAL IN _data1 -``` - -and the temporary table `_data1` will be sent to every remote server with the query (the name of the temporary table is implementation-defined). - -This is more optimal than using the normal IN. However, keep the following points in mind: - -1. When creating a temporary table, data is not made unique. To reduce the volume of data transmitted over the network, specify DISTINCT in the subquery. (You don’t need to do this for a normal IN.) -2. The temporary table will be sent to all the remote servers. Transmission does not account for network topology. For example, if 10 remote servers reside in a datacenter that is very remote in relation to the requestor server, the data will be sent 10 times over the channel to the remote datacenter. Try to avoid large data sets when using GLOBAL IN. -3. When transmitting data to remote servers, restrictions on network bandwidth are not configurable. You might overload the network. -4. Try to distribute data across servers so that you don’t need to use GLOBAL IN on a regular basis. -5. If you need to use GLOBAL IN often, plan the location of the ClickHouse cluster so that a single group of replicas resides in no more than one data center with a fast network between them, so that a query can be processed entirely within a single data center. - -It also makes sense to specify a local table in the `GLOBAL IN` clause, in case this local table is only available on the requestor server and you want to use data from it on remote servers. - -### Extreme Values {#extreme-values} - -In addition to results, you can also get minimum and maximum values for the results columns. To do this, set the **extremes** setting to 1. Minimums and maximums are calculated for numeric types, dates, and dates with times. For other columns, the default values are output. - -An extra two rows are calculated – the minimums and maximums, respectively. These extra two rows are output in `JSON*`, `TabSeparated*`, and `Pretty*` [formats](../../interfaces/formats.md), separate from the other rows. They are not output for other formats. - -In `JSON*` formats, the extreme values are output in a separate ‘extremes’ field. In `TabSeparated*` formats, the row comes after the main result, and after ‘totals’ if present. It is preceded by an empty row (after the other data). In `Pretty*` formats, the row is output as a separate table after the main result, and after `totals` if present. - -Extreme values are calculated for rows before `LIMIT`, but after `LIMIT BY`. However, when using `LIMIT offset, size`, the rows before `offset` are included in `extremes`. In stream requests, the result may also include a small number of rows that passed through `LIMIT`. - -### Notes {#notes} - -The `GROUP BY` and `ORDER BY` clauses do not support positional arguments. This contradicts MySQL, but conforms to standard SQL. -For example, `GROUP BY 1, 2` will be interpreted as grouping by constants (i.e. aggregation of all rows into one). - -You can use synonyms (`AS` aliases) in any part of a query. - -You can put an asterisk in any part of a query instead of an expression. When the query is analyzed, the asterisk is expanded to a list of all table columns (excluding the `MATERIALIZED` and `ALIAS` columns). There are only a few cases when using an asterisk is justified: - -- When creating a table dump. -- For tables containing just a few columns, such as system tables. -- For getting information about what columns are in a table. In this case, set `LIMIT 1`. But it is better to use the `DESC TABLE` query. -- When there is strong filtration on a small number of columns using `PREWHERE`. -- In subqueries (since columns that aren’t needed for the external query are excluded from subqueries). - -In all other cases, we don’t recommend using the asterisk, since it only gives you the drawbacks of a columnar DBMS instead of the advantages. In other words using the asterisk is not recommended. - -[Original article](https://clickhouse.tech/docs/en/query_language/select/) diff --git a/docs/en/sql_reference/statements/show.md b/docs/en/sql_reference/statements/show.md deleted file mode 100644 index 89572fc7118..00000000000 --- a/docs/en/sql_reference/statements/show.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -toc_priority: 38 -toc_title: SHOW ---- - -# SHOW Queries {#show-queries} - -## SHOW CREATE TABLE {#show-create-table} - -``` sql -SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -Returns a single `String`-type ‘statement’ column, which contains a single value – the `CREATE` query used for creating the specified object. - -## SHOW DATABASES {#show-databases} - -``` sql -SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] -``` - -Prints a list of all databases. -This query is identical to `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. - -## SHOW PROCESSLIST {#show-processlist} - -``` sql -SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] -``` - -Outputs the content of the [system.processes](../../operations/system_tables.md#system_tables-processes) table, that contains a list of queries that is being processed at the moment, excepting `SHOW PROCESSLIST` queries. - -The `SELECT * FROM system.processes` query returns data about all the current queries. - -Tip (execute in the console): - -``` bash -$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" -``` - -## SHOW TABLES {#show-tables} - -Displays a list of tables. - -``` sql -SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -If the `FROM` clause is not specified, the query returns the list of tables from the current database. - -You can get the same results as the `SHOW TABLES` query in the following way: - -``` sql -SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**Example** - -The following query selects the first two rows from the list of tables in the `system` database, whose names contain `co`. - -``` sql -SHOW TABLES FROM system LIKE '%co%' LIMIT 2 -``` - -``` text -┌─name───────────────────────────┐ -│ aggregate_function_combinators │ -│ collations │ -└────────────────────────────────┘ -``` - -## SHOW DICTIONARIES {#show-dictionaries} - -Displays a list of [external dictionaries](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -``` sql -SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -If the `FROM` clause is not specified, the query returns the list of dictionaries from the current database. - -You can get the same results as the `SHOW DICTIONARIES` query in the following way: - -``` sql -SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**Example** - -The following query selects the first two rows from the list of tables in the `system` database, whose names contain `reg`. - -``` sql -SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 -``` - -``` text -┌─name─────────┐ -│ regions │ -│ region_names │ -└──────────────┘ -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/en/sql_reference/statements/system.md b/docs/en/sql_reference/statements/system.md deleted file mode 100644 index ebd945f850e..00000000000 --- a/docs/en/sql_reference/statements/system.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -toc_priority: 37 -toc_title: SYSTEM ---- - -# SYSTEM Queries {#query-language-system} - -- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) -- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) -- [DROP DNS CACHE](#query_language-system-drop-dns-cache) -- [DROP MARK CACHE](#query_language-system-drop-mark-cache) -- [FLUSH LOGS](#query_language-system-flush_logs) -- [RELOAD CONFIG](#query_language-system-reload-config) -- [SHUTDOWN](#query_language-system-shutdown) -- [KILL](#query_language-system-kill) -- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) -- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) -- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) -- [STOP MERGES](#query_language-system-stop-merges) -- [START MERGES](#query_language-system-start-merges) - -## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} - -Reloads all dictionaries that have been successfully loaded before. -By default, dictionaries are loaded lazily (see [dictionaries\_lazy\_load](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load)), so instead of being loaded automatically at startup, they are initialized on first access through dictGet function or SELECT from tables with ENGINE = Dictionary. The `SYSTEM RELOAD DICTIONARIES` query reloads such dictionaries (LOADED). -Always returns `Ok.` regardless of the result of the dictionary update. - -## RELOAD DICTIONARY Dictionary\_name {#query_language-system-reload-dictionary} - -Completely reloads a dictionary `dictionary_name`, regardless of the state of the dictionary (LOADED / NOT\_LOADED / FAILED). -Always returns `Ok.` regardless of the result of updating the dictionary. -The status of the dictionary can be checked by querying the `system.dictionaries` table. - -``` sql -SELECT name, status FROM system.dictionaries; -``` - -## DROP DNS CACHE {#query_language-system-drop-dns-cache} - -Resets ClickHouse’s internal DNS cache. Sometimes (for old ClickHouse versions) it is necessary to use this command when changing the infrastructure (changing the IP address of another ClickHouse server or the server used by dictionaries). - -For more convenient (automatic) cache management, see disable\_internal\_dns\_cache, dns\_cache\_update\_period parameters. - -## DROP MARK CACHE {#query_language-system-drop-mark-cache} - -Resets the mark cache. Used in development of ClickHouse and performance tests. - -## FLUSH LOGS {#query_language-system-flush_logs} - -Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. - -## RELOAD CONFIG {#query_language-system-reload-config} - -Reloads ClickHouse configuration. Used when configuration is stored in ZooKeeeper. - -## SHUTDOWN {#query_language-system-shutdown} - -Normally shuts down ClickHouse (like `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) - -## KILL {#query_language-system-kill} - -Aborts ClickHouse process (like `kill -9 {$ pid_clickhouse-server}`) - -## Managing Distributed Tables {#query-language-system-distributed} - -ClickHouse can manage [distributed](../../engines/table_engines/special/distributed.md) tables. When a user inserts data into these tables, ClickHouse first creates a queue of the data that should be sent to cluster nodes, then asynchronously sends it. You can manage queue processing with the [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed), and [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) queries. You can also synchronously insert distributed data with the `insert_distributed_sync` setting. - -### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} - -Disables background data distribution when inserting data into distributed tables. - -``` sql -SYSTEM STOP DISTRIBUTED SENDS [db.] -``` - -### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} - -Forces ClickHouse to send data to cluster nodes synchronously. If any nodes are unavailable, ClickHouse throws an exception and stops query execution. You can retry the query until it succeeds, which will happen when all nodes are back online. - -``` sql -SYSTEM FLUSH DISTRIBUTED [db.] -``` - -### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} - -Enables background data distribution when inserting data into distributed tables. - -``` sql -SYSTEM START DISTRIBUTED SENDS [db.] -``` - -### STOP MERGES {#query_language-system-stop-merges} - -Provides possibility to stop background merges for tables in the MergeTree family: - -``` sql -SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] -``` - -!!! note "Note" - `DETACH / ATTACH` table will start background merges for the table even in case when merges have been stopped for all MergeTree tables before. - -### START MERGES {#query_language-system-start-merges} - -Provides possibility to start background merges for tables in the MergeTree family: - -``` sql -SYSTEM START MERGES [[db.]merge_tree_family_table_name] -``` - -[Original article](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/en/sql_reference/syntax.md b/docs/en/sql_reference/syntax.md deleted file mode 100644 index 10e8c421f6d..00000000000 --- a/docs/en/sql_reference/syntax.md +++ /dev/null @@ -1,185 +0,0 @@ ---- -toc_priority: 31 -toc_title: Syntax ---- - -# Syntax {#syntax} - -There are two types of parsers in the system: the full SQL parser (a recursive descent parser), and the data format parser (a fast stream parser). -In all cases except the `INSERT` query, only the full SQL parser is used. -The `INSERT` query uses both parsers: - -``` sql -INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') -``` - -The `INSERT INTO t VALUES` fragment is parsed by the full parser, and the data `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` is parsed by the fast stream parser. You can also turn on the full parser for the data by using the [input\_format\_values\_interpret\_expressions](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) setting. When `input_format_values_interpret_expressions = 1`, ClickHouse first tries to parse values with the fast stream parser. If it fails, ClickHouse tries to use the full parser for the data, treating it like an SQL [expression](#syntax-expressions). - -Data can have any format. When a query is received, the server calculates no more than [max\_query\_size](../operations/settings/settings.md#settings-max_query_size) bytes of the request in RAM (by default, 1 MB), and the rest is stream parsed. -It allows for avoiding issues with large `INSERT` queries. - -When using the `Values` format in an `INSERT` query, it may seem that data is parsed the same as expressions in a `SELECT` query, but this is not true. The `Values` format is much more limited. - -The rest of this article covers the full parser. For more information about format parsers, see the [Formats](../interfaces/formats.md) section. - -## Spaces {#spaces} - -There may be any number of space symbols between syntactical constructions (including the beginning and end of a query). Space symbols include the space, tab, line feed, CR, and form feed. - -## Comments {#comments} - -ClickHouse supports either SQL-style and C-style comments. -SQL-style comments start with `--` and continue to the end of the line, a space after `--` can be omitted. -C-style are from `/*` to `*/`and can be multiline, spaces are not required either. - -## Keywords {#syntax-keywords} - -Keywords are case-insensitive when they correspond to: - -- SQL standard. For example, `SELECT`, `select` and `SeLeCt` are all valid. -- Implementation in some popular DBMS (MySQL or Postgres). For example, `DateTime` is the same as `datetime`. - -Whether data type name is case-sensitive can be checked in the `system.data_type_families` table. - -In contrast to standard SQL, all other keywords (including functions names) are **case-sensitive**. - -Keywords are not reserved; they are treated as such only in the corresponding context. If you use [identifiers](#syntax-identifiers) with the same name as the keywords, enclose them into double-quotes or backticks. For example, the query `SELECT "FROM" FROM table_name` is valid if the table `table_name` has column with the name `"FROM"`. - -## Identifiers {#syntax-identifiers} - -Identifiers are: - -- Cluster, database, table, partition, and column names. -- Functions. -- Data types. -- [Expression aliases](#syntax-expression_aliases). - -Identifiers can be quoted or non-quoted. The latter is preferred. - -Non-quoted identifiers must match the regex `^[a-zA-Z_][0-9a-zA-Z_]*$` and can not be equal to [keywords](#syntax-keywords). Examples: `x, _1, X_y__Z123_.` - -If you want to use identifiers the same as keywords or you want to use other symbols in identifiers, quote it using double quotes or backticks, for example, `"id"`, `` `id` ``. - -## Literals {#literals} - -There are numeric, string, compound, and `NULL` literals. - -### Numeric {#numeric} - -Numeric literal tries to be parsed: - -- First, as a 64-bit signed number, using the [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul) function. -- If unsuccessful, as a 64-bit unsigned number, using the [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) function. -- If unsuccessful, as a floating-point number using the [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) function. -- Otherwise, it returns an error. - -Literal value has the smallest type that the value fits in. -For example, 1 is parsed as `UInt8`, but 256 is parsed as `UInt16`. For more information, see [Data types](../sql_reference/data_types/index.md). - -Examples: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. - -### String {#syntax-string-literal} - -Only string literals in single quotes are supported. The enclosed characters can be backslash-escaped. The following escape sequences have a corresponding special value: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. In all other cases, escape sequences in the format `\c`, where `c` is any character, are converted to `c`. It means that you can use the sequences `\'`and`\\`. The value will have the [String](../sql_reference/data_types/string.md) type. - -In string literals, you need to escape at least `'` and `\`. Single quotes can be escaped with the single quote, literals `'It\'s'` and `'It''s'` are equal. - -### Compound {#compound} - -Arrays are constructed with square brackets `[1, 2, 3]`. Nuples are constructed with round brackets `(1, 'Hello, world!', 2)`. -Technically these are not literals, but expressions with the array creation operator and the tuple creation operator, respectively. -An array must consist of at least one item, and a tuple must have at least two items. -There's a separate case when tuples appear in the `IN` clause of a `SELECT` query. Query results can include tuples, but tuples can’t be saved to a database (except of tables with [Memory](../engines/table_engines/special/memory.md) engine). - -### NULL {#null-literal} - -Indicates that the value is missing. - -In order to store `NULL` in a table field, it must be of the [Nullable](../sql_reference/data_types/nullable.md) type. - -Depending on the data format (input or output), `NULL` may have a different representation. For more information, see the documentation for [data formats](../interfaces/formats.md#formats). - -There are many nuances to processing `NULL`. For example, if at least one of the arguments of a comparison operation is `NULL`, the result of this operation is also `NULL`. The same is true for multiplication, addition, and other operations. For more information, read the documentation for each operation. - -In queries, you can check `NULL` using the [IS NULL](operators.md#operator-is-null) and [IS NOT NULL](operators.md) operators and the related functions `isNull` and `isNotNull`. - -## Functions {#functions} - -Function calls are written like an identifier with a list of arguments (possibly empty) in round brackets. In contrast to standard SQL, the brackets are required, even for an empty argument list. Example: `now()`. -There are regular and aggregate functions (see the section “Aggregate functions”). Some aggregate functions can contain two lists of arguments in brackets. Example: `quantile (0.9) (x)`. These aggregate functions are called “parametric” functions, and the arguments in the first list are called “parameters”. The syntax of aggregate functions without parameters is the same as for regular functions. - -## Operators {#operators} - -Operators are converted to their corresponding functions during query parsing, taking their priority and associativity into account. -For example, the expression `1 + 2 * 3 + 4` is transformed to `plus(plus(1, multiply(2, 3)), 4)`. - -## Data Types and Database Table Engines {#data_types-and-database-table-engines} - -Data types and table engines in the `CREATE` query are written the same way as identifiers or functions. In other words, they may or may not contain an argument list in brackets. For more information, see the sections “Data types,” “Table engines,” and “CREATE”. - -## Expression Aliases {#syntax-expression_aliases} - -An alias is a user-defined name for expression in a query. - -``` sql -expr AS alias -``` - -- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` clause without using the `AS` keyword. - - For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. - - In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. - -- `expr` — Any expression supported by ClickHouse. - - For example, `SELECT column_name * 2 AS double FROM some_table`. - -- `alias` — Name for `expr`. Aliases should comply with the [identifiers](#syntax-identifiers) syntax. - - For example, `SELECT "table t".column_name FROM table_name AS "table t"`. - -### Notes on Usage {#notes-on-usage} - -Aliases are global for a query or subquery, and you can define an alias in any part of a query for any expression. For example, `SELECT (1 AS n) + 2, n`. - -Aliases are not visible in subqueries and between subqueries. For example, while executing the query `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouse generates the exception `Unknown identifier: num`. - -If an alias is defined for the result columns in the `SELECT` clause of a subquery, these columns are visible in the outer query. For example, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. - -Be careful with aliases that are the same as column or table names. Let’s consider the following example: - -``` sql -CREATE TABLE t -( - a Int, - b Int -) -ENGINE = TinyLog() -``` - -``` sql -SELECT - argMax(a, b), - sum(b) AS b -FROM t -``` - -``` text -Received exception from server (version 18.14.17): -Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. -``` - -In this example, we declared table `t` with column `b`. Then, when selecting data, we defined the `sum(b) AS b` alias. As aliases are global, ClickHouse substituted the literal `b` in the expression `argMax(a, b)` with the expression `sum(b)`. This substitution caused the exception. - -## Asterisk {#asterisk} - -In a `SELECT` query, an asterisk can replace the expression. For more information, see the section “SELECT”. - -## Expressions {#syntax-expressions} - -An expression is a function, identifier, literal, application of an operator, expression in brackets, subquery, or asterisk. It can also contain an alias. -A list of expressions is one or more expressions separated by commas. -Functions and operators, in turn, can have expressions as arguments. - -[Original article](https://clickhouse.tech/docs/en/sql_reference/syntax/) diff --git a/docs/en/sql_reference/table_functions/file.md b/docs/en/sql_reference/table_functions/file.md deleted file mode 100644 index 6ae7eb034f9..00000000000 --- a/docs/en/sql_reference/table_functions/file.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -toc_priority: 37 -toc_title: file ---- - -# file {#file} - -Creates a table from a file. This table function is similar to [url](url.md) and [hdfs](hdfs.md) ones. - -``` sql -file(path, format, structure) -``` - -**Input parameters** - -- `path` — The relative path to the file from [user\_files\_path](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-user_files_path). Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` and `{N..M}` where `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [format](../../interfaces/formats.md#formats) of the file. -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**Returned value** - -A table with the specified structure for reading or writing data in the specified file. - -**Example** - -Setting `user_files_path` and the contents of the file `test.csv`: - -``` bash -$ grep user_files_path /etc/clickhouse-server/config.xml - /var/lib/clickhouse/user_files/ - -$ cat /var/lib/clickhouse/user_files/test.csv - 1,2,3 - 3,2,1 - 78,43,45 -``` - -Table from`test.csv` and selection of the first two rows from it: - -``` sql -SELECT * -FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -``` sql --- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file -SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 -``` - -**Globs in path** - -Multiple path components can have globs. For being processed file should exists and matches to the whole path pattern (not only suffix or prefix). - -- `*` — Substitutes any number of any characters except `/` including empty string. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -Constructions with `{}` are similar to the [remote table function](../../sql_reference/table_functions/remote.md)). - -**Example** - -1. Suppose we have several files with the following relative paths: - -- ‘some\_dir/some\_file\_1’ -- ‘some\_dir/some\_file\_2’ -- ‘some\_dir/some\_file\_3’ -- ‘another\_dir/some\_file\_1’ -- ‘another\_dir/some\_file\_2’ -- ‘another\_dir/some\_file\_3’ - -1. Query the amount of rows in these files: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. Query the amount of rows in all files of these two directories: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "Warning" - If your listing of files contains number ranges with leading zeros, use the construction with braces for each digit separately or use `?`. - -**Example** - -Query the data from files named `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## Virtual Columns {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**See Also** - -- [Virtual columns](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[Original article](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/en/sql_reference/table_functions/hdfs.md b/docs/en/sql_reference/table_functions/hdfs.md deleted file mode 100644 index 730bd96758f..00000000000 --- a/docs/en/sql_reference/table_functions/hdfs.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -toc_priority: 45 -toc_title: hdfs ---- - -# hdfs {#hdfs} - -Creates a table from files in HDFS. This table function is similar to [url](url.md) and [file](file.md) ones. - -``` sql -hdfs(URI, format, structure) -``` - -**Input parameters** - -- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` and `{N..M}` where `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [format](../../interfaces/formats.md#formats) of the file. -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**Returned value** - -A table with the specified structure for reading or writing data in the specified file. - -**Example** - -Table from `hdfs://hdfs1:9000/test` and selection of the first two rows from it: - -``` sql -SELECT * -FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -**Globs in path** - -Multiple path components can have globs. For being processed file should exists and matches to the whole path pattern (not only suffix or prefix). - -- `*` — Substitutes any number of any characters except `/` including empty string. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -Constructions with `{}` are similar to the [remote table function](../../sql_reference/table_functions/remote.md)). - -**Example** - -1. Suppose that we have several files with following URIs on HDFS: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. Query the amount of rows in these files: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. Query the amount of rows in all files of these two directories: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "Warning" - If your listing of files contains number ranges with leading zeros, use the construction with braces for each digit separately or use `?`. - -**Example** - -Query the data from files named `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## Virtual Columns {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**See Also** - -- [Virtual columns](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[Original article](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/en/sql_reference/table_functions/index.md b/docs/en/sql_reference/table_functions/index.md deleted file mode 100644 index 18a17ce2f6f..00000000000 --- a/docs/en/sql_reference/table_functions/index.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -toc_folder_title: Table Functions -toc_priority: 34 -toc_title: Introduction ---- - -# Table Functions {#table-functions} - -Table functions are methods for constructing tables. - -You can use table functions in: - -- [FROM](../statements/select.md#select-from) clause of the `SELECT` query. - - The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. - -- [CREATE TABLE AS \](../statements/create.md#create-table-query) query. - - It's one of the methods of creating a table. - -!!! warning "Warning" - You can’t use table functions if the [allow\_ddl](../../operations/settings/permissions_for_queries.md#settings_allow_ddl) setting is disabled. - -| Function | Description | -|---------------|----------------------------------------------------------------------------------| -| [file](file.md) | Creates a [File](../../engines/table_engines/special/file.md)-engine table. | -| [merge](merge.md) | Creates a [Merge](../../engines/table_engines/special/merge.md)-engine table. | -| [numbers](numbers.md) | Creates a table with a single column filled with integer numbers. | -| [remote](remote.md) | Allows you to access remote servers without creating a [Distributed](../../engines/table_engines/special/distributed.md)-engine table. | -| [url](url.md) | Creates a [Url](../../engines/table_engines/special/url.md)-engine table. | -| [mysql](mysql.md) | Creates a [MySQL](../../engines/table_engines/integrations/mysql.md)-engine table. | -| [jdbc](jdbc.md) | Creates a [JDBC](../../engines/table_engines/integrations/jdbc.md)-engine table. | -| [odbc](odbc.md) | Creates a [ODBC](../../engines/table_engines/integrations/odbc.md)-engine table. | -| [hdfs](hdfs.md) | Creates a [HDFS](../../engines/table_engines/integrations/hdfs.md)-engine table. | - -[Original article](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/en/sql_reference/table_functions/mysql.md b/docs/en/sql_reference/table_functions/mysql.md deleted file mode 100644 index b4029c945d3..00000000000 --- a/docs/en/sql_reference/table_functions/mysql.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -toc_priority: 42 -toc_title: mysql ---- - -# mysql {#mysql} - -Allows `SELECT` queries to be performed on data that is stored on a remote MySQL server. - -``` sql -mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -**Parameters** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` queries to `REPLACE INTO`. If `replace_query=1`, the query is replaced. - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expression that is added to the `INSERT` query. - - Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. - - To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. - -Simple `WHERE` clauses such as `=, !=, >, >=, <, <=` are currently executed on the MySQL server. - -The rest of the conditions and the `LIMIT` sampling constraint are executed in ClickHouse only after the query to MySQL finishes. - -**Returned Value** - -A table object with the same columns as the original MySQL table. - -## Usage Example {#usage-example} - -Table in MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Selecting data from ClickHouse: - -``` sql -SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## See Also {#see-also} - -- [The ‘MySQL’ table engine](../../engines/table_engines/integrations/mysql.md) -- [Using MySQL as a source of external dictionary](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[Original article](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/en/sql_reference/table_functions/odbc.md b/docs/en/sql_reference/table_functions/odbc.md deleted file mode 100644 index f14e7808f79..00000000000 --- a/docs/en/sql_reference/table_functions/odbc.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -toc_priority: 44 -toc_title: odbc ---- - -# odbc {#table-functions-odbc} - -Returns table that is connected via [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -``` sql -odbc(connection_settings, external_database, external_table) -``` - -Parameters: - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` file. -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -To safely implement ODBC connections, ClickHouse uses a separate program `clickhouse-odbc-bridge`. If the ODBC driver is loaded directly from `clickhouse-server`, driver problems can crash the ClickHouse server. ClickHouse automatically starts `clickhouse-odbc-bridge` when it is required. The ODBC bridge program is installed from the same package as the `clickhouse-server`. - -The fields with the `NULL` values from the external table are converted into the default values for the base data type. For example, if a remote MySQL table field has the `INT NULL` type it is converted to 0 (the default value for ClickHouse `Int32` data type). - -## Usage example {#usage-example} - -**Getting data from the local MySQL installation via ODBC** - -This example is checked for Ubuntu Linux 18.04 and MySQL server 5.7. - -Ensure that unixODBC and MySQL Connector are installed. - -By default (if installed from packages), ClickHouse starts as user `clickhouse`. Thus you need to create and configure this user in the MySQL server. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -Then configure the connection in `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -You can check the connection using the `isql` utility from the unixODBC installation. - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -Table in MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Retrieving data from the MySQL table in ClickHouse: - -``` sql -SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ 0 │ 2 │ 0 │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## See Also {#see-also} - -- [ODBC external dictionaries](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [ODBC table engine](../../engines/table_engines/integrations/odbc.md). - -[Original article](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/en/sql_reference/table_functions/remote.md b/docs/en/sql_reference/table_functions/remote.md deleted file mode 100644 index 62ead0674b5..00000000000 --- a/docs/en/sql_reference/table_functions/remote.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -toc_priority: 40 -toc_title: remote ---- - -# remote, remoteSecure {#remote-remotesecure} - -Allows you to access remote servers without creating a `Distributed` table. - -Signatures: - -``` sql -remote('addresses_expr', db, table[, 'user'[, 'password']]) -remote('addresses_expr', db.table[, 'user'[, 'password']]) -``` - -`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port`, or just `host`. The host can be specified as the server name, or as the IPv4 or IPv6 address. An IPv6 address is specified in square brackets. The port is the TCP port on the remote server. If the port is omitted, it uses `tcp_port` from the server’s config file (by default, 9000). - -!!! important "Important" - The port is required for an IPv6 address. - -Examples: - -``` text -example01-01-1 -example01-01-1:9000 -localhost -127.0.0.1 -[::]:9000 -[2a02:6b8:0:1111::11]:9000 -``` - -Multiple addresses can be comma-separated. In this case, ClickHouse will use distributed processing, so it will send the query to all specified addresses (like to shards with different data). - -Example: - -``` text -example01-01-1,example01-02-1 -``` - -Part of the expression can be specified in curly brackets. The previous example can be written as follows: - -``` text -example01-0{1,2}-1 -``` - -Curly brackets can contain a range of numbers separated by two dots (non-negative integers). In this case, the range is expanded to a set of values that generate shard addresses. If the first number starts with zero, the values are formed with the same zero alignment. The previous example can be written as follows: - -``` text -example01-{01..02}-1 -``` - -If you have multiple pairs of curly brackets, it generates the direct product of the corresponding sets. - -Addresses and parts of addresses in curly brackets can be separated by the pipe symbol (\|). In this case, the corresponding sets of addresses are interpreted as replicas, and the query will be sent to the first healthy replica. However, the replicas are iterated in the order currently set in the [load\_balancing](../../operations/settings/settings.md) setting. - -Example: - -``` text -example01-{01..02}-{1|2} -``` - -This example specifies two shards that each have two replicas. - -The number of addresses generated is limited by a constant. Right now this is 1000 addresses. - -Using the `remote` table function is less optimal than creating a `Distributed` table, because in this case, the server connection is re-established for every request. In addition, if host names are set, the names are resolved, and errors are not counted when working with various replicas. When processing a large number of queries, always create the `Distributed` table ahead of time, and don’t use the `remote` table function. - -The `remote` table function can be useful in the following cases: - -- Accessing a specific server for data comparison, debugging, and testing. -- Queries between various ClickHouse clusters for research purposes. -- Infrequent distributed requests that are made manually. -- Distributed requests where the set of servers is re-defined each time. - -If the user is not specified, `default` is used. -If the password is not specified, an empty password is used. - -`remoteSecure` - same as `remote` but with secured connection. Default port — [tcp\_port\_secure](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) from config or 9440. - -[Original article](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/en/whats-new/changelog/2017.md b/docs/en/whats-new/changelog/2017.md new file mode 100644 index 00000000000..d819324b07a --- /dev/null +++ b/docs/en/whats-new/changelog/2017.md @@ -0,0 +1,266 @@ +--- +toc_priority: 79 +toc_title: '2017' +--- + +### ClickHouse Release 1.1.54327, 2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} + +This release contains bug fixes for the previous release 1.1.54318: + +- Fixed bug with possible race condition in replication that could lead to data loss. This issue affects versions 1.1.54310 and 1.1.54318. If you use one of these versions with Replicated tables, the update is strongly recommended. This issue shows in logs in Warning messages like `Part ... from own log doesn't exist.` The issue is relevant even if you don’t see these messages in logs. + +### ClickHouse Release 1.1.54318, 2017-11-30 {#clickhouse-release-1-1-54318-2017-11-30} + +This release contains bug fixes for the previous release 1.1.54310: + +- Fixed incorrect row deletions during merges in the SummingMergeTree engine +- Fixed a memory leak in unreplicated MergeTree engines +- Fixed performance degradation with frequent inserts in MergeTree engines +- Fixed an issue that was causing the replication queue to stop running +- Fixed rotation and archiving of server logs + +### ClickHouse Release 1.1.54310, 2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} + +#### New Features: {#new-features} + +- Custom partitioning key for the MergeTree family of table engines. +- [Kafka](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) table engine. +- Added support for loading [CatBoost](https://catboost.yandex/) models and applying them to data stored in ClickHouse. +- Added support for time zones with non-integer offsets from UTC. +- Added support for arithmetic operations with time intervals. +- The range of values for the Date and DateTime types is extended to the year 2105. +- Added the `CREATE MATERIALIZED VIEW x TO y` query (specifies an existing table for storing the data of a materialized view). +- Added the `ATTACH TABLE` query without arguments. +- The processing logic for Nested columns with names ending in -Map in a SummingMergeTree table was extracted to the sumMap aggregate function. You can now specify such columns explicitly. +- Max size of the IP trie dictionary is increased to 128M entries. +- Added the getSizeOfEnumType function. +- Added the sumWithOverflow aggregate function. +- Added support for the Cap’n Proto input format. +- You can now customize compression level when using the zstd algorithm. + +#### Backward Incompatible Changes: {#backward-incompatible-changes} + +- Creation of temporary tables with an engine other than Memory is not allowed. +- Explicit creation of tables with the View or MaterializedView engine is not allowed. +- During table creation, a new check verifies that the sampling key expression is included in the primary key. + +#### Bug Fixes: {#bug-fixes} + +- Fixed hangups when synchronously inserting into a Distributed table. +- Fixed nonatomic adding and removing of parts in Replicated tables. +- Data inserted into a materialized view is not subjected to unnecessary deduplication. +- Executing a query to a Distributed table for which the local replica is lagging and remote replicas are unavailable does not result in an error anymore. +- Users don’t need access permissions to the `default` database to create temporary tables anymore. +- Fixed crashing when specifying the Array type without arguments. +- Fixed hangups when the disk volume containing server logs is full. +- Fixed an overflow in the toRelativeWeekNum function for the first week of the Unix epoch. + +#### Build Improvements: {#build-improvements} + +- Several third-party libraries (notably Poco) were updated and converted to git submodules. + +### ClickHouse Release 1.1.54304, 2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} + +#### New Features: {#new-features-1} + +- TLS support in the native protocol (to enable, set `tcp_ssl_port` in `config.xml` ). + +#### Bug Fixes: {#bug-fixes-1} + +- `ALTER` for replicated tables now tries to start running as soon as possible. +- Fixed crashing when reading data with the setting `preferred_block_size_bytes=0.` +- Fixed crashes of `clickhouse-client` when pressing `Page Down` +- Correct interpretation of certain complex queries with `GLOBAL IN` and `UNION ALL` +- `FREEZE PARTITION` always works atomically now. +- Empty POST requests now return a response with code 411. +- Fixed interpretation errors for expressions like `CAST(1 AS Nullable(UInt8)).` +- Fixed an error when reading `Array(Nullable(String))` columns from `MergeTree` tables. +- Fixed crashing when parsing queries like `SELECT dummy AS dummy, dummy AS b` +- Users are updated correctly with invalid `users.xml` +- Correct handling when an executable dictionary returns a non-zero response code. + +### ClickHouse Release 1.1.54292, 2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} + +#### New Features: {#new-features-2} + +- Added the `pointInPolygon` function for working with coordinates on a coordinate plane. +- Added the `sumMap` aggregate function for calculating the sum of arrays, similar to `SummingMergeTree`. +- Added the `trunc` function. Improved performance of the rounding functions (`round`, `floor`, `ceil`, `roundToExp2`) and corrected the logic of how they work. Changed the logic of the `roundToExp2` function for fractions and negative numbers. +- The ClickHouse executable file is now less dependent on the libc version. The same ClickHouse executable file can run on a wide variety of Linux systems. There is still a dependency when using compiled queries (with the setting `compile = 1` , which is not used by default). +- Reduced the time needed for dynamic compilation of queries. + +#### Bug Fixes: {#bug-fixes-2} + +- Fixed an error that sometimes produced `part ... intersects previous part` messages and weakened replica consistency. +- Fixed an error that caused the server to lock up if ZooKeeper was unavailable during shutdown. +- Removed excessive logging when restoring replicas. +- Fixed an error in the UNION ALL implementation. +- Fixed an error in the concat function that occurred if the first column in a block has the Array type. +- Progress is now displayed correctly in the system.merges table. + +### ClickHouse Release 1.1.54289, 2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} + +#### New Features: {#new-features-3} + +- `SYSTEM` queries for server administration: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. +- Added functions for working with arrays: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. +- Added `root` and `identity` parameters for the ZooKeeper configuration. This allows you to isolate individual users on the same ZooKeeper cluster. +- Added aggregate functions `groupBitAnd`, `groupBitOr`, and `groupBitXor` (for compatibility, they are also available under the names `BIT_AND`, `BIT_OR`, and `BIT_XOR`). +- External dictionaries can be loaded from MySQL by specifying a socket in the filesystem. +- External dictionaries can be loaded from MySQL over SSL (`ssl_cert`, `ssl_key`, `ssl_ca` parameters). +- Added the `max_network_bandwidth_for_user` setting to restrict the overall bandwidth use for queries per user. +- Support for `DROP TABLE` for temporary tables. +- Support for reading `DateTime` values in Unix timestamp format from the `CSV` and `JSONEachRow` formats. +- Lagging replicas in distributed queries are now excluded by default (the default threshold is 5 minutes). +- FIFO locking is used during ALTER: an ALTER query isn’t blocked indefinitely for continuously running queries. +- Option to set `umask` in the config file. +- Improved performance for queries with `DISTINCT` . + +#### Bug Fixes: {#bug-fixes-3} + +- Improved the process for deleting old nodes in ZooKeeper. Previously, old nodes sometimes didn’t get deleted if there were very frequent inserts, which caused the server to be slow to shut down, among other things. +- Fixed randomization when choosing hosts for the connection to ZooKeeper. +- Fixed the exclusion of lagging replicas in distributed queries if the replica is localhost. +- Fixed an error where a data part in a `ReplicatedMergeTree` table could be broken after running `ALTER MODIFY` on an element in a `Nested` structure. +- Fixed an error that could cause SELECT queries to “hang”. +- Improvements to distributed DDL queries. +- Fixed the query `CREATE TABLE ... AS `. +- Resolved the deadlock in the `ALTER ... CLEAR COLUMN IN PARTITION` query for `Buffer` tables. +- Fixed the invalid default value for `Enum` s (0 instead of the minimum) when using the `JSONEachRow` and `TSKV` formats. +- Resolved the appearance of zombie processes when using a dictionary with an `executable` source. +- Fixed segfault for the HEAD query. + +#### Improved Workflow for Developing and Assembling ClickHouse: {#improved-workflow-for-developing-and-assembling-clickhouse} + +- You can use `pbuilder` to build ClickHouse. +- You can use `libc++` instead of `libstdc++` for builds on Linux. +- Added instructions for using static code analysis tools: `Coverage`, `clang-tidy`, `cppcheck`. + +#### Please Note When Upgrading: {#please-note-when-upgrading} + +- There is now a higher default value for the MergeTree setting `max_bytes_to_merge_at_max_space_in_pool` (the maximum total size of data parts to merge, in bytes): it has increased from 100 GiB to 150 GiB. This might result in large merges running after the server upgrade, which could cause an increased load on the disk subsystem. If the free space available on the server is less than twice the total amount of the merges that are running, this will cause all other merges to stop running, including merges of small data parts. As a result, INSERT queries will fail with the message “Merges are processing significantly slower than inserts.” Use the `SELECT * FROM system.merges` query to monitor the situation. You can also check the `DiskSpaceReservedForMerge` metric in the `system.metrics` table, or in Graphite. You don’t need to do anything to fix this, since the issue will resolve itself once the large merges finish. If you find this unacceptable, you can restore the previous value for the `max_bytes_to_merge_at_max_space_in_pool` setting. To do this, go to the `` section in config.xml, set ``` ``107374182400 ``` and restart the server. + +### ClickHouse Release 1.1.54284, 2017-08-29 {#clickhouse-release-1-1-54284-2017-08-29} + +- This is a bugfix release for the previous 1.1.54282 release. It fixes leaks in the parts directory in ZooKeeper. + +### ClickHouse Release 1.1.54282, 2017-08-23 {#clickhouse-release-1-1-54282-2017-08-23} + +This release contains bug fixes for the previous release 1.1.54276: + +- Fixed `DB::Exception: Assertion violation: !_path.empty()` when inserting into a Distributed table. +- Fixed parsing when inserting in RowBinary format if input data starts with’;’. +- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). + +### ClickHouse Release 1.1.54276, 2017-08-16 {#clickhouse-release-1-1-54276-2017-08-16} + +#### New Features: {#new-features-4} + +- Added an optional WITH section for a SELECT query. Example query: `WITH 1+1 AS a SELECT a, a*a` +- INSERT can be performed synchronously in a Distributed table: OK is returned only after all the data is saved on all the shards. This is activated by the setting insert\_distributed\_sync=1. +- Added the UUID data type for working with 16-byte identifiers. +- Added aliases of CHAR, FLOAT and other types for compatibility with the Tableau. +- Added the functions toYYYYMM, toYYYYMMDD, and toYYYYMMDDhhmmss for converting time into numbers. +- You can use IP addresses (together with the hostname) to identify servers for clustered DDL queries. +- Added support for non-constant arguments and negative offsets in the function `substring(str, pos, len).` +- Added the max\_size parameter for the `groupArray(max_size)(column)` aggregate function, and optimized its performance. + +#### Main Changes: {#main-changes} + +- Security improvements: all server files are created with 0640 permissions (can be changed via `` config parameter). +- Improved error messages for queries with invalid syntax. +- Significantly reduced memory consumption and improved performance when merging large sections of MergeTree data. +- Significantly increased the performance of data merges for the ReplacingMergeTree engine. +- Improved performance for asynchronous inserts from a Distributed table by combining multiple source inserts. To enable this functionality, use the setting distributed\_directory\_monitor\_batch\_inserts=1. + +#### Backward Incompatible Changes: {#backward-incompatible-changes-1} + +- Changed the binary format of aggregate states of `groupArray(array_column)` functions for arrays. + +#### Complete List of Changes: {#complete-list-of-changes} + +- Added the `output_format_json_quote_denormals` setting, which enables outputting nan and inf values in JSON format. +- Optimized stream allocation when reading from a Distributed table. +- Settings can be configured in readonly mode if the value doesn’t change. +- Added the ability to retrieve non-integer granules of the MergeTree engine in order to meet restrictions on the block size specified in the preferred\_block\_size\_bytes setting. The purpose is to reduce the consumption of RAM and increase cache locality when processing queries from tables with large columns. +- Efficient use of indexes that contain expressions like `toStartOfHour(x)` for conditions like `toStartOfHour(x) op сonstexpr.` +- Added new settings for MergeTree engines (the merge\_tree section in config.xml): + - replicated\_deduplication\_window\_seconds sets the number of seconds allowed for deduplicating inserts in Replicated tables. + - cleanup\_delay\_period sets how often to start cleanup to remove outdated data. + - replicated\_can\_become\_leader can prevent a replica from becoming the leader (and assigning merges). +- Accelerated cleanup to remove outdated data from ZooKeeper. +- Multiple improvements and fixes for clustered DDL queries. Of particular interest is the new setting distributed\_ddl\_task\_timeout, which limits the time to wait for a response from the servers in the cluster. If a ddl request has not been performed on all hosts, a response will contain a timeout error and a request will be executed in an async mode. +- Improved display of stack traces in the server logs. +- Added the “none” value for the compression method. +- You can use multiple dictionaries\_config sections in config.xml. +- It is possible to connect to MySQL through a socket in the file system. +- The system.parts table has a new column with information about the size of marks, in bytes. + +#### Bug Fixes: {#bug-fixes-4} + +- Distributed tables using a Merge table now work correctly for a SELECT query with a condition on the `_table` field. +- Fixed a rare race condition in ReplicatedMergeTree when checking data parts. +- Fixed possible freezing on “leader election” when starting a server. +- The max\_replica\_delay\_for\_distributed\_queries setting was ignored when using a local replica of the data source. This has been fixed. +- Fixed incorrect behavior of `ALTER TABLE CLEAR COLUMN IN PARTITION` when attempting to clean a non-existing column. +- Fixed an exception in the multiIf function when using empty arrays or strings. +- Fixed excessive memory allocations when deserializing Native format. +- Fixed incorrect auto-update of Trie dictionaries. +- Fixed an exception when running queries with a GROUP BY clause from a Merge table when using SAMPLE. +- Fixed a crash of GROUP BY when using distributed\_aggregation\_memory\_efficient=1. +- Now you can specify the database.table in the right side of IN and JOIN. +- Too many threads were used for parallel aggregation. This has been fixed. +- Fixed how the “if” function works with FixedString arguments. +- SELECT worked incorrectly from a Distributed table for shards with a weight of 0. This has been fixed. +- Running `CREATE VIEW IF EXISTS no longer causes crashes.` +- Fixed incorrect behavior when input\_format\_skip\_unknown\_fields=1 is set and there are negative numbers. +- Fixed an infinite loop in the `dictGetHierarchy()` function if there is some invalid data in the dictionary. +- Fixed `Syntax error: unexpected (...)` errors when running distributed queries with subqueries in an IN or JOIN clause and Merge tables. +- Fixed an incorrect interpretation of a SELECT query from Dictionary tables. +- Fixed the “Cannot mremap” error when using arrays in IN and JOIN clauses with more than 2 billion elements. +- Fixed the failover for dictionaries with MySQL as the source. + +#### Improved Workflow for Developing and Assembling ClickHouse: {#improved-workflow-for-developing-and-assembling-clickhouse-1} + +- Builds can be assembled in Arcadia. +- You can use gcc 7 to compile ClickHouse. +- Parallel builds using ccache+distcc are faster now. + +### ClickHouse Release 1.1.54245, 2017-07-04 {#clickhouse-release-1-1-54245-2017-07-04} + +#### New Features: {#new-features-5} + +- Distributed DDL (for example, `CREATE TABLE ON CLUSTER`) +- The replicated query `ALTER TABLE CLEAR COLUMN IN PARTITION.` +- The engine for Dictionary tables (access to dictionary data in the form of a table). +- Dictionary database engine (this type of database automatically has Dictionary tables available for all the connected external dictionaries). +- You can check for updates to the dictionary by sending a request to the source. +- Qualified column names +- Quoting identifiers using double quotation marks. +- Sessions in the HTTP interface. +- The OPTIMIZE query for a Replicated table can can run not only on the leader. + +#### Backward Incompatible Changes: {#backward-incompatible-changes-2} + +- Removed SET GLOBAL. + +#### Minor Changes: {#minor-changes} + +- Now after an alert is triggered, the log prints the full stack trace. +- Relaxed the verification of the number of damaged/extra data parts at startup (there were too many false positives). + +#### Bug Fixes: {#bug-fixes-5} + +- Fixed a bad connection “sticking” when inserting into a Distributed table. +- GLOBAL IN now works for a query from a Merge table that looks at a Distributed table. +- The incorrect number of cores was detected on a Google Compute Engine virtual machine. This has been fixed. +- Changes in how an executable source of cached external dictionaries works. +- Fixed the comparison of strings containing null characters. +- Fixed the comparison of Float32 primary key fields with constants. +- Previously, an incorrect estimate of the size of a field could lead to overly large allocations. +- Fixed a crash when querying a Nullable column added to a table using ALTER. +- Fixed a crash when sorting by a Nullable column, if the number of rows is less than LIMIT. +- Fixed an ORDER BY subquery consisting of only constant values. +- Previously, a Replicated table could remain in the invalid state after a failed DROP TABLE. +- Aliases for scalar subqueries with empty results are no longer lost. +- Now a query that used compilation does not fail with an error if the .so file gets damaged. diff --git a/docs/en/whats-new/changelog/2018.md b/docs/en/whats-new/changelog/2018.md new file mode 100644 index 00000000000..38e1932707f --- /dev/null +++ b/docs/en/whats-new/changelog/2018.md @@ -0,0 +1,1061 @@ +--- +toc_priority: 78 +toc_title: '2018' +--- + +## ClickHouse Release 18.16 {#clickhouse-release-18-16} + +### ClickHouse Release 18.16.1, 2018-12-21 {#clickhouse-release-18-16-1-2018-12-21} + +#### Bug Fixes: {#bug-fixes} + +- Fixed an error that led to problems with updating dictionaries with the ODBC source. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- JIT compilation of aggregate functions now works with LowCardinality columns. [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) + +#### Improvements: {#improvements} + +- Added the `low_cardinality_allow_in_native_format` setting (enabled by default). When disabled, LowCardinality columns will be converted to ordinary columns for SELECT queries and ordinary columns will be expected for INSERT queries. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) + +#### Build Improvements: {#build-improvements} + +- Fixes for builds on macOS and ARM. + +### ClickHouse Release 18.16.0, 2018-12-14 {#clickhouse-release-18-16-0-2018-12-14} + +#### New Features: {#new-features} + +- `DEFAULT` expressions are evaluated for missing fields when loading data in semi-structured input formats (`JSONEachRow`, `TSKV`). The feature is enabled with the `insert_sample_with_metadata` setting. [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) +- The `ALTER TABLE` query now has the `MODIFY ORDER BY` action for changing the sorting key when adding or removing a table column. This is useful for tables in the `MergeTree` family that perform additional tasks when merging based on this sorting key, such as `SummingMergeTree`, `AggregatingMergeTree`, and so on. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) +- For tables in the `MergeTree` family, now you can specify a different sorting key (`ORDER BY`) and index (`PRIMARY KEY`). The sorting key can be longer than the index. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) +- Added the `hdfs` table function and the `HDFS` table engine for importing and exporting data to HDFS. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) +- Added functions for working with base64: `base64Encode`, `base64Decode`, `tryBase64Decode`. [Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3350) +- Now you can use a parameter to configure the precision of the `uniqCombined` aggregate function (select the number of HyperLogLog cells). [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) +- Added the `system.contributors` table that contains the names of everyone who made commits in ClickHouse. [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) +- Added the ability to omit the partition for the `ALTER TABLE ... FREEZE` query in order to back up all partitions at once. [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) +- Added `dictGet` and `dictGetOrDefault` functions that don’t require specifying the type of return value. The type is determined automatically from the dictionary description. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3564) +- Now you can specify comments for a column in the table description and change it using `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) +- Reading is supported for `Join` type tables with simple keys. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3728) +- Now you can specify the options `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join`, and `join_overflow_mode` when creating a `Join` type table. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3728) +- Added the `joinGet` function that allows you to use a `Join` type table like a dictionary. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3728) +- Added the `partition_key`, `sorting_key`, `primary_key`, and `sampling_key` columns to the `system.tables` table in order to provide information about table keys. [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- Added the `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key`, and `is_in_sampling_key` columns to the `system.columns` table. [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- Added the `min_time` and `max_time` columns to the `system.parts` table. These columns are populated when the partitioning key is an expression consisting of `DateTime` columns. [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) + +#### Bug Fixes: {#bug-fixes-1} + +- Fixes and performance improvements for the `LowCardinality` data type. `GROUP BY` using `LowCardinality(Nullable(...))`. Getting the values of `extremes`. Processing high-order functions. `LEFT ARRAY JOIN`. Distributed `GROUP BY`. Functions that return `Array`. Execution of `ORDER BY`. Writing to `Distributed` tables (nicelulu). Backward compatibility for `INSERT` queries from old clients that implement the `Native` protocol. Support for `LowCardinality` for `JOIN`. Improved performance when working in a single stream. [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) +- Fixed how the `select_sequential_consistency` option works. Previously, when this setting was enabled, an incomplete result was sometimes returned after beginning to write to a new partition. [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) +- Databases are correctly specified when executing DDL `ON CLUSTER` queries and `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- Databases are correctly specified for subqueries inside a VIEW. [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) +- Fixed a bug in `PREWHERE` with `FINAL` for `VersionedCollapsingMergeTree`. [7167bfd7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) +- Now you can use `KILL QUERY` to cancel queries that have not started yet because they are waiting for the table to be locked. [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) +- Corrected date and time calculations if the clocks were moved back at midnight (this happens in Iran, and happened in Moscow from 1981 to 1983). Previously, this led to the time being reset a day earlier than necessary, and also caused incorrect formatting of the date and time in text format. [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) +- Fixed bugs in some cases of `VIEW` and subqueries that omit the database. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3521) +- Fixed a race condition when simultaneously reading from a `MATERIALIZED VIEW` and deleting a `MATERIALIZED VIEW` due to not locking the internal `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) +- Fixed the error `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) +- Fixed query processing when the `compile_expressions` option is enabled (it’s enabled by default). Nondeterministic constant expressions like the `now` function are no longer unfolded. [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) +- Fixed a crash when specifying a non-constant scale argument in `toDecimal32/64/128` functions. +- Fixed an error when trying to insert an array with `NULL` elements in the `Values` format into a column of type `Array` without `Nullable` (if `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) +- Fixed continuous error logging in `DDLWorker` if ZooKeeper is not available. [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) +- Fixed the return type for `quantile*` functions from `Date` and `DateTime` types of arguments. [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) +- Fixed the `WITH` clause if it specifies a simple alias without expressions. [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) +- Fixed processing of queries with named sub-queries and qualified column names when `enable_optimize_predicate_expression` is enabled. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3588) +- Fixed the error `Attempt to attach to nullptr thread group` when working with materialized views. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) +- Fixed a crash when passing certain incorrect arguments to the `arrayReverse` function. [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- Fixed the buffer overflow in the `extractURLParameter` function. Improved performance. Added correct processing of strings containing zero bytes. [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) +- Fixed buffer overflow in the `lowerUTF8` and `upperUTF8` functions. Removed the ability to execute these functions over `FixedString` type arguments. [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) +- Fixed a rare race condition when deleting `MergeTree` tables. [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) +- Fixed a race condition when reading from `Buffer` tables and simultaneously performing `ALTER` or `DROP` on the target tables. [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) +- Fixed a segfault if the `max_temporary_non_const_columns` limit was exceeded. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### Improvements: {#improvements-1} + +- The server does not write the processed configuration files to the `/etc/clickhouse-server/` directory. Instead, it saves them in the `preprocessed_configs` directory inside `path`. This means that the `/etc/clickhouse-server/` directory doesn’t have write access for the `clickhouse` user, which improves security. [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) +- The `min_merge_bytes_to_use_direct_io` option is set to 10 GiB by default. A merge that forms large parts of tables from the MergeTree family will be performed in `O_DIRECT` mode, which prevents excessive page cache eviction. [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) +- Accelerated server start when there is a very large number of tables. [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) +- Added a connection pool and HTTP `Keep-Alive` for connections between replicas. [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) +- If the query syntax is invalid, the `400 Bad Request` code is returned in the `HTTP` interface (500 was returned previously). [31bc680a](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) +- The `join_default_strictness` option is set to `ALL` by default for compatibility. [120e2cbe](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) +- Removed logging to `stderr` from the `re2` library for invalid or complex regular expressions. [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) +- Added for the `Kafka` table engine: checks for subscriptions before beginning to read from Kafka; the kafka\_max\_block\_size setting for the table. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) +- The `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32`, and `murmurHash3_64` functions now work for any number of arguments and for arguments in the form of tuples. [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) +- The `arrayReverse` function now works with any types of arrays. [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- Added an optional parameter: the slot size for the `timeSlots` function. [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/3724) +- For `FULL` and `RIGHT JOIN`, the `max_block_size` setting is used for a stream of non-joined data from the right table. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3699) +- Added the `--secure` command line parameter in `clickhouse-benchmark` and `clickhouse-performance-test` to enable TLS. [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) +- Type conversion when the structure of a `Buffer` type table does not match the structure of the destination table. [Vitaly Baranov](https://github.com/ClickHouse/ClickHouse/pull/3603) +- Added the `tcp_keep_alive_timeout` option to enable keep-alive packets after inactivity for the specified time interval. [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) +- Removed unnecessary quoting of values for the partition key in the `system.parts` table if it consists of a single column. [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) +- The modulo function works for `Date` and `DateTime` data types. [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) +- Added synonyms for the `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR`, and `MID` functions. [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) Some function names are case-insensitive for compatibility with the SQL standard. Added syntactic sugar `SUBSTRING(expr FROM start FOR length)` for compatibility with SQL. [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) +- Added the ability to `mlock` memory pages corresponding to `clickhouse-server` executable code to prevent it from being forced out of memory. This feature is disabled by default. [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) +- Improved performance when reading from `O_DIRECT` (with the `min_bytes_to_use_direct_io` option enabled). [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) +- Improved performance of the `dictGet...OrDefault` function for a constant key argument and a non-constant default argument. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3563) +- The `firstSignificantSubdomain` function now processes the domains `gov`, `mil`, and `edu`. [Igor Hatarist](https://github.com/ClickHouse/ClickHouse/pull/3601) Improved performance. [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) +- Ability to specify custom environment variables for starting `clickhouse-server` using the `SYS-V init.d` script by defining `CLICKHOUSE_PROGRAM_ENV` in `/etc/default/clickhouse`. + [Pavlo Bashynskyi](https://github.com/ClickHouse/ClickHouse/pull/3612) +- Correct return code for the clickhouse-server init script. [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) +- The `system.metrics` table now has the `VersionInteger` metric, and `system.build_options` has the added line `VERSION_INTEGER`, which contains the numeric form of the ClickHouse version, such as `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) +- Removed the ability to compare the `Date` type with a number to avoid potential errors like `date = 2018-12-17`, where quotes around the date are omitted by mistake. [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) +- Fixed the behavior of stateful functions like `rowNumberInAllBlocks`. They previously output a result that was one number larger due to starting during query analysis. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3729) +- If the `force_restore_data` file can’t be deleted, an error message is displayed. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3794) + +#### Build Improvements: {#build-improvements-1} + +- Updated the `jemalloc` library, which fixes a potential memory leak. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3557) +- Profiling with `jemalloc` is enabled by default in order to debug builds. [2cc82f5c](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) +- Added the ability to run integration tests when only `Docker` is installed on the system. [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) +- Added the fuzz expression test in SELECT queries. [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) +- Added a stress test for commits, which performs functional tests in parallel and in random order to detect more race conditions. [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) +- Improved the method for starting clickhouse-server in a Docker image. [Elghazal Ahmed](https://github.com/ClickHouse/ClickHouse/pull/3663) +- For a Docker image, added support for initializing databases using files in the `/docker-entrypoint-initdb.d` directory. [Konstantin Lebedev](https://github.com/ClickHouse/ClickHouse/pull/3695) +- Fixes for builds on ARM. [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) + +#### Backward Incompatible Changes: {#backward-incompatible-changes} + +- Removed the ability to compare the `Date` type with a number. Instead of `toDate('2018-12-18') = 17883`, you must use explicit type conversion `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) + +## ClickHouse Release 18.14 {#clickhouse-release-18-14} + +### ClickHouse Release 18.14.19, 2018-12-19 {#clickhouse-release-18-14-19-2018-12-19} + +#### Bug Fixes: {#bug-fixes-2} + +- Fixed an error that led to problems with updating dictionaries with the ODBC source. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- Databases are correctly specified when executing DDL `ON CLUSTER` queries. [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- Fixed a segfault if the `max_temporary_non_const_columns` limit was exceeded. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### Build Improvements: {#build-improvements-2} + +- Fixes for builds on ARM. + +### ClickHouse Release 18.14.18, 2018-12-04 {#clickhouse-release-18-14-18-2018-12-04} + +#### Bug Fixes: {#bug-fixes-3} + +- Fixed error in `dictGet...` function for dictionaries of type `range`, if one of the arguments is constant and other is not. [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) +- Fixed error that caused messages `netlink: '...': attribute type 1 has an invalid length` to be printed in Linux kernel log, that was happening only on fresh enough versions of Linux kernel. [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) +- Fixed segfault in function `empty` for argument of `FixedString` type. [Daniel, Dao Quang Minh](https://github.com/ClickHouse/ClickHouse/pull/3703) +- Fixed excessive memory allocation when using large value of `max_query_size` setting (a memory chunk of `max_query_size` bytes was preallocated at once). [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) + +#### Build Changes: {#build-changes} + +- Fixed build with LLVM/Clang libraries of version 7 from the OS packages (these libraries are used for runtime query compilation). [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### ClickHouse Release 18.14.17, 2018-11-30 {#clickhouse-release-18-14-17-2018-11-30} + +#### Bug Fixes: {#bug-fixes-4} + +- Fixed cases when the ODBC bridge process did not terminate with the main server process. [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) +- Fixed synchronous insertion into the `Distributed` table with a columns list that differs from the column list of the remote table. [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) +- Fixed a rare race condition that can lead to a crash when dropping a MergeTree table. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- Fixed a query deadlock in case when query thread creation fails with the `Resource temporarily unavailable` error. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- Fixed parsing of the `ENGINE` clause when the `CREATE AS table` syntax was used and the `ENGINE` clause was specified before the `AS table` (the error resulted in ignoring the specified engine). [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) + +### ClickHouse Release 18.14.15, 2018-11-21 {#clickhouse-release-18-14-15-2018-11-21} + +#### Bug Fixes: {#bug-fixes-5} + +- The size of memory chunk was overestimated while deserializing the column of type `Array(String)` that leads to “Memory limit exceeded” errors. The issue appeared in version 18.12.13. [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) + +### ClickHouse Release 18.14.14, 2018-11-20 {#clickhouse-release-18-14-14-2018-11-20} + +#### Bug Fixes: {#bug-fixes-6} + +- Fixed `ON CLUSTER` queries when cluster configured as secure (flag ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) + +#### Build Changes: {#build-changes-1} + +- Fixed problems (llvm-7 from system, macos) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### ClickHouse Release 18.14.13, 2018-11-08 {#clickhouse-release-18-14-13-2018-11-08} + +#### Bug Fixes: {#bug-fixes-7} + +- Fixed the `Block structure mismatch in MergingSorted stream` error. [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) +- Fixed `ON CLUSTER` queries in case when secure connections were turned on in the cluster config (the `` flag). [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) +- Fixed an error in queries that used `SAMPLE`, `PREWHERE` and alias columns. [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) +- Fixed a rare `unknown compression method` error when the `min_bytes_to_use_direct_io` setting was enabled. [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) + +#### Performance Improvements: {#performance-improvements} + +- Fixed performance regression of queries with `GROUP BY` of columns of UInt16 or Date type when executing on AMD EPYC processors. [Igor Lapko](https://github.com/ClickHouse/ClickHouse/pull/3512) +- Fixed performance regression of queries that process long strings. [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) + +#### Build Improvements: {#build-improvements-3} + +- Improvements for simplifying the Arcadia build. [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) + +### ClickHouse Release 18.14.12, 2018-11-02 {#clickhouse-release-18-14-12-2018-11-02} + +#### Bug Fixes: {#bug-fixes-8} + +- Fixed a crash on joining two unnamed subqueries. [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) +- Fixed generating incorrect queries (with an empty `WHERE` clause) when querying external databases. [hotid](https://github.com/ClickHouse/ClickHouse/pull/3477) +- Fixed using an incorrect timeout value in ODBC dictionaries. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) + +### ClickHouse Release 18.14.11, 2018-10-29 {#clickhouse-release-18-14-11-2018-10-29} + +#### Bug Fixes: {#bug-fixes-9} + +- Fixed the error `Block structure mismatch in UNION stream: different number of columns` in LIMIT queries. [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) +- Fixed errors when merging data in tables containing arrays inside Nested structures. [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) +- Fixed incorrect query results if the `merge_tree_uniform_read_distribution` setting is disabled (it is enabled by default). [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) +- Fixed an error on inserts to a Distributed table in Native format. [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) + +### ClickHouse Release 18.14.10, 2018-10-23 {#clickhouse-release-18-14-10-2018-10-23} + +- The `compile_expressions` setting (JIT compilation of expressions) is disabled by default. [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) +- The `enable_optimize_predicate_expression` setting is disabled by default. + +### ClickHouse Release 18.14.9, 2018-10-16 {#clickhouse-release-18-14-9-2018-10-16} + +#### New Features: {#new-features-1} + +- The `WITH CUBE` modifier for `GROUP BY` (the alternative syntax `GROUP BY CUBE(...)` is also available). [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) +- Added the `formatDateTime` function. [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2770) +- Added the `JDBC` table engine and `jdbc` table function (requires installing clickhouse-jdbc-bridge). [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) +- Added functions for working with the ISO week number: `toISOWeek`, `toISOYear`, `toStartOfISOYear`, and `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) +- Now you can use `Nullable` columns for `MySQL` and `ODBC` tables. [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- Nested data structures can be read as nested objects in `JSONEachRow` format. Added the `input_format_import_nested_json` setting. [Veloman Yunkan](https://github.com/ClickHouse/ClickHouse/pull/3144) +- Parallel processing is available for many `MATERIALIZED VIEW`s when inserting data. See the `parallel_view_processing` setting. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) +- Added the `SYSTEM FLUSH LOGS` query (forced log flushes to system tables such as `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) +- Now you can use pre-defined `database` and `table` macros when declaring `Replicated` tables. [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) +- Added the ability to read `Decimal` type values in engineering notation (indicating powers of ten). [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) + +#### Experimental Features: {#experimental-features} + +- Optimization of the GROUP BY clause for `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) +- Optimized calculation of expressions for `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) + +#### Improvements: {#improvements-2} + +- Significantly reduced memory consumption for queries with `ORDER BY` and `LIMIT`. See the `max_bytes_before_remerge_sort` setting. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- In the absence of `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` is assumed. [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) +- Qualified asterisks work correctly in queries with `JOIN`. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3202) +- The `ODBC` table engine correctly chooses the method for quoting identifiers in the SQL dialect of a remote database. [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) +- The `compile_expressions` setting (JIT compilation of expressions) is enabled by default. +- Fixed behavior for simultaneous DROP DATABASE/TABLE IF EXISTS and CREATE DATABASE/TABLE IF NOT EXISTS. Previously, a `CREATE DATABASE ... IF NOT EXISTS` query could return the error message “File … already exists”, and the `CREATE TABLE ... IF NOT EXISTS` and `DROP TABLE IF EXISTS` queries could return `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) +- LIKE and IN expressions with a constant right half are passed to the remote server when querying from MySQL or ODBC tables. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- Comparisons with constant expressions in a WHERE clause are passed to the remote server when querying from MySQL and ODBC tables. Previously, only comparisons with constants were passed. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- Correct calculation of row width in the terminal for `Pretty` formats, including strings with hieroglyphs. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3257). +- `ON CLUSTER` can be specified for `ALTER UPDATE` queries. +- Improved performance for reading data in `JSONEachRow` format. [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) +- Added synonyms for the `LENGTH` and `CHARACTER_LENGTH` functions for compatibility. The `CONCAT` function is no longer case-sensitive. [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) +- Added the `TIMESTAMP` synonym for the `DateTime` type. [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) +- There is always space reserved for query\_id in the server logs, even if the log line is not related to a query. This makes it easier to parse server text logs with third-party tools. +- Memory consumption by a query is logged when it exceeds the next level of an integer number of gigabytes. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- Added compatibility mode for the case when the client library that uses the Native protocol sends fewer columns by mistake than the server expects for the INSERT query. This scenario was possible when using the clickhouse-cpp library. Previously, this scenario caused the server to crash. [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) +- In a user-defined WHERE expression in `clickhouse-copier`, you can now use a `partition_key` alias (for additional filtering by source table partition). This is useful if the partitioning scheme changes during copying, but only changes slightly. [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) +- The workflow of the `Kafka` engine has been moved to a background thread pool in order to automatically reduce the speed of data reading at high loads. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- Support for reading `Tuple` and `Nested` values of structures like `struct` in the `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) +- The list of top-level domains for the `firstSignificantSubdomain` function now includes the domain `biz`. [decaseal](https://github.com/ClickHouse/ClickHouse/pull/3219) +- In the configuration of external dictionaries, `null_value` is interpreted as the value of the default data type. [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) +- Support for the `intDiv` and `intDivOrZero` functions for `Decimal`. [b48402e8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) +- Support for the `Date`, `DateTime`, `UUID`, and `Decimal` types as a key for the `sumMap` aggregate function. [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) +- Support for the `Decimal` data type in external dictionaries. [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) +- Support for the `Decimal` data type in `SummingMergeTree` tables. [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) +- Added specializations for `UUID` in `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) +- Reduced the number of `open` and `close` system calls when reading from a `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) +- A `TRUNCATE TABLE` query can be executed on any replica (the query is passed to the leader replica). [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/3375) + +#### Bug Fixes: {#bug-fixes-10} + +- Fixed an issue with `Dictionary` tables for `range_hashed` dictionaries. This error occurred in version 18.12.17. [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) +- Fixed an error when loading `range_hashed` dictionaries (the message `Unsupported type Nullable (...)`). This error occurred in version 18.12.17. [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- Fixed errors in the `pointInPolygon` function due to the accumulation of inaccurate calculations for polygons with a large number of vertices located close to each other. [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) +- If after merging data parts, the checksum for the resulting part differs from the result of the same merge in another replica, the result of the merge is deleted and the data part is downloaded from the other replica (this is the correct behavior). But after downloading the data part, it couldn’t be added to the working set because of an error that the part already exists (because the data part was deleted with some delay after the merge). This led to cyclical attempts to download the same data. [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) +- Fixed incorrect calculation of total memory consumption by queries (because of incorrect calculation, the `max_memory_usage_for_all_queries` setting worked incorrectly and the `MemoryTracking` metric had an incorrect value). This error occurred in version 18.12.13. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) +- Fixed the functionality of `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` This error occurred in version 18.12.13. [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) +- Fixed unnecessary preparation of data structures for `JOIN`s on the server that initiates the query if the `JOIN` is only performed on remote servers. [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) +- Fixed bugs in the `Kafka` engine: deadlocks after exceptions when starting to read data, and locks upon completion [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- For `Kafka` tables, the optional `schema` parameter was not passed (the schema of the `Cap'n'Proto` format). [Vojtech Splichal](https://github.com/ClickHouse/ClickHouse/pull/3150) +- If the ensemble of ZooKeeper servers has servers that accept the connection but then immediately close it instead of responding to the handshake, ClickHouse chooses to connect another server. Previously, this produced the error `Cannot read all data. Bytes read: 0. Bytes expected: 4.` and the server couldn’t start. [8218cf3a](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) +- If the ensemble of ZooKeeper servers contains servers for which the DNS query returns an error, these servers are ignored. [17b8e209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) +- Fixed type conversion between `Date` and `DateTime` when inserting data in the `VALUES` format (if `input_format_values_interpret_expressions = 1`). Previously, the conversion was performed between the numerical value of the number of days in Unix Epoch time and the Unix timestamp, which led to unexpected results. [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) +- Corrected type conversion between `Decimal` and integer numbers. [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) +- Fixed errors in the `enable_optimize_predicate_expression` setting. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3231) +- Fixed a parsing error in CSV format with floating-point numbers if a non-default CSV separator is used, such as `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) +- Fixed the `arrayCumSumNonNegative` function (it does not accumulate negative values if the accumulator is less than zero). [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/3163) +- Fixed how `Merge` tables work on top of `Distributed` tables when using `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) +- Bug fixes in the `ALTER UPDATE` query. +- Fixed bugs in the `odbc` table function that appeared in version 18.12. [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) +- Fixed the operation of aggregate functions with `StateArray` combinators. [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) +- Fixed a crash when dividing a `Decimal` value by zero. [69dd6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) +- Fixed output of types for operations using `Decimal` and integer arguments. [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) +- Fixed the segfault during `GROUP BY` on `Decimal128`. [3359ba06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) +- The `log_query_threads` setting (logging information about each thread of query execution) now takes effect only if the `log_queries` option (logging information about queries) is set to 1. Since the `log_query_threads` option is enabled by default, information about threads was previously logged even if query logging was disabled. [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) +- Fixed an error in the distributed operation of the quantiles aggregate function (the error message `Not found column quantile...`). [292a8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) +- Fixed the compatibility problem when working on a cluster of version 18.12.17 servers and older servers at the same time. For distributed queries with GROUP BY keys of both fixed and non-fixed length, if there was a large amount of data to aggregate, the returned data was not always fully aggregated (two different rows contained the same aggregation keys). [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) +- Fixed handling of substitutions in `clickhouse-performance-test`, if the query contains only part of the substitutions declared in the test. [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) +- Fixed an error when using `FINAL` with `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- Fixed an error when using `PREWHERE` over columns that were added during `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- Added a check for the absence of `arrayJoin` for `DEFAULT` and `MATERIALIZED` expressions. Previously, `arrayJoin` led to an error when inserting data. [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) +- Added a check for the absence of `arrayJoin` in a `PREWHERE` clause. Previously, this led to messages like `Size ... doesn't match` or `Unknown compression method` when executing queries. [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) +- Fixed segfault that could occur in rare cases after optimization that replaced AND chains from equality evaluations with the corresponding IN expression. [liuyimin-bytedance](https://github.com/ClickHouse/ClickHouse/pull/3339) +- Minor corrections to `clickhouse-benchmark`: previously, client information was not sent to the server; now the number of queries executed is calculated more accurately when shutting down and for limiting the number of iterations. [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) + +#### Backward Incompatible Changes: {#backward-incompatible-changes-1} + +- Removed the `allow_experimental_decimal_type` option. The `Decimal` data type is available for default use. [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) + +## ClickHouse Release 18.12 {#clickhouse-release-18-12} + +### ClickHouse Release 18.12.17, 2018-09-16 {#clickhouse-release-18-12-17-2018-09-16} + +#### New Features: {#new-features-2} + +- `invalidate_query` (the ability to specify a query to check whether an external dictionary needs to be updated) is implemented for the `clickhouse` source. [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) +- Added the ability to use `UInt*`, `Int*`, and `DateTime` data types (along with the `Date` type) as a `range_hashed` external dictionary key that defines the boundaries of ranges. Now `NULL` can be used to designate an open range. [Vasily Nemkov](https://github.com/ClickHouse/ClickHouse/pull/3123) +- The `Decimal` type now supports `var*` and `stddev*` aggregate functions. [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- The `Decimal` type now supports mathematical functions (`exp`, `sin` and so on.) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- The `system.part_log` table now has the `partition_id` column. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### Bug Fixes: {#bug-fixes-11} + +- `Merge` now works correctly on `Distributed` tables. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3159) +- Fixed incompatibility (unnecessary dependency on the `glibc` version) that made it impossible to run ClickHouse on `Ubuntu Precise` and older versions. The incompatibility arose in version 18.12.13. [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) +- Fixed errors in the `enable_optimize_predicate_expression` setting. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3107) +- Fixed a minor issue with backwards compatibility that appeared when working with a cluster of replicas on versions earlier than 18.12.13 and simultaneously creating a new replica of a table on a server with a newer version (shown in the message `Can not clone replica, because the ... updated to new ClickHouse version`, which is logical, but shouldn’t happen). [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) + +#### Backward Incompatible Changes: {#backward-incompatible-changes-2} + +- The `enable_optimize_predicate_expression` option is enabled by default (which is rather optimistic). If query analysis errors occur that are related to searching for the column names, set `enable_optimize_predicate_expression` to 0. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3107) + +### ClickHouse Release 18.12.14, 2018-09-13 {#clickhouse-release-18-12-14-2018-09-13} + +#### New Features: {#new-features-3} + +- Added support for `ALTER UPDATE` queries. [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) +- Added the `allow_ddl` option, which restricts the user’s access to DDL queries. [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) +- Added the `min_merge_bytes_to_use_direct_io` option for `MergeTree` engines, which allows you to set a threshold for the total size of the merge (when above the threshold, data part files will be handled using O\_DIRECT). [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) +- The `system.merges` system table now contains the `partition_id` column. [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) + +#### Improvements {#improvements-3} + +- If a data part remains unchanged during mutation, it isn’t downloaded by replicas. [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) +- Autocomplete is available for names of settings when working with `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) + +#### Bug Fixes: {#bug-fixes-12} + +- Added a check for the sizes of arrays that are elements of `Nested` type fields when inserting. [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) +- Fixed an error updating external dictionaries with the `ODBC` source and `hashed` storage. This error occurred in version 18.12.13. +- Fixed a crash when creating a temporary table from a query with an `IN` condition. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3098) +- Fixed an error in aggregate functions for arrays that can have `NULL` elements. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3097) + +### ClickHouse Release 18.12.13, 2018-09-10 {#clickhouse-release-18-12-13-2018-09-10} + +#### New Features: {#new-features-4} + +- Added the `DECIMAL(digits, scale)` data type (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). To enable it, use the setting `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) +- New `WITH ROLLUP` modifier for `GROUP BY` (alternative syntax: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) +- In queries with JOIN, the star character expands to a list of columns in all tables, in compliance with the SQL standard. You can restore the old behavior by setting `asterisk_left_columns_only` to 1 on the user configuration level. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2787) +- Added support for JOIN with table functions. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2907) +- Autocomplete by pressing Tab in clickhouse-client. [Sergey Shcherbin](https://github.com/ClickHouse/ClickHouse/pull/2447) +- Ctrl+C in clickhouse-client clears a query that was entered. [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) +- Added the `join_default_strictness` setting (values: `"`, `'any'`, `'all'`). This allows you to not specify `ANY` or `ALL` for `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) +- Each line of the server log related to query processing shows the query ID. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- Now you can get query execution logs in clickhouse-client (use the `send_logs_level` setting). With distributed query processing, logs are cascaded from all the servers. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- The `system.query_log` and `system.processes` (`SHOW PROCESSLIST`) tables now have information about all changed settings when you run a query (the nested structure of the `Settings` data). Added the `log_query_settings` setting. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- The `system.query_log` and `system.processes` tables now show information about the number of threads that are participating in query execution (see the `thread_numbers` column). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- Added `ProfileEvents` counters that measure the time spent on reading and writing over the network and reading and writing to disk, the number of network errors, and the time spent waiting when network bandwidth is limited. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- Added `ProfileEvents`counters that contain the system metrics from rusage (you can use them to get information about CPU usage in userspace and the kernel, page faults, and context switches), as well as taskstats metrics (use these to obtain information about I/O wait time, CPU wait time, and the amount of data read and recorded, both with and without page cache). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- The `ProfileEvents` counters are applied globally and for each query, as well as for each query execution thread, which allows you to profile resource consumption by query in detail. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- Added the `system.query_thread_log` table, which contains information about each query execution thread. Added the `log_query_threads` setting. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- The `system.metrics` and `system.events` tables now have built-in documentation. [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) +- Added the `arrayEnumerateDense` function. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2975) +- Added the `arrayCumSumNonNegative` and `arrayDifference` functions. [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/2942) +- Added the `retention` aggregate function. [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2887) +- Now you can add (merge) states of aggregate functions by using the plus operator, and multiply the states of aggregate functions by a nonnegative constant. [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) +- Tables in the MergeTree family now have the virtual column `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### Experimental Features: {#experimental-features-1} + +- Added the `LowCardinality(T)` data type. This data type automatically creates a local dictionary of values and allows data processing without unpacking the dictionary. [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) +- Added a cache of JIT-compiled functions and a counter for the number of uses before compiling. To JIT compile expressions, enable the `compile_expressions` setting. [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) + +#### Improvements: {#improvements-4} + +- Fixed the problem with unlimited accumulation of the replication log when there are abandoned replicas. Added an effective recovery mode for replicas with a long lag. +- Improved performance of `GROUP BY` with multiple aggregation fields when one of them is string and the others are fixed length. +- Improved performance when using `PREWHERE` and with implicit transfer of expressions in `PREWHERE`. +- Improved parsing performance for text formats (`CSV`, `TSV`). [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) +- Improved performance of reading strings and arrays in binary formats. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2955) +- Increased performance and reduced memory consumption for queries to `system.tables` and `system.columns` when there is a very large number of tables on a single server. [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) +- Fixed a performance problem in the case of a large stream of queries that result in an error (the `_dl_addr` function is visible in `perf top`, but the server isn’t using much CPU). [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) +- Conditions are cast into the View (when `enable_optimize_predicate_expression` is enabled). [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2907) +- Improvements to the functionality for the `UUID` data type. [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) +- The `UUID` data type is supported in The-Alchemist dictionaries. [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) +- The `visitParamExtractRaw` function works correctly with nested structures. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2974) +- When the `input_format_skip_unknown_fields` setting is enabled, object fields in `JSONEachRow` format are skipped correctly. [BlahGeek](https://github.com/ClickHouse/ClickHouse/pull/2958) +- For a `CASE` expression with conditions, you can now omit `ELSE`, which is equivalent to `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) +- The operation timeout can now be configured when working with ZooKeeper. [urykhy](https://github.com/ClickHouse/ClickHouse/pull/2971) +- You can specify an offset for `LIMIT n, m` as `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- You can use the `SELECT TOP n` syntax as an alternative for `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- Increased the size of the queue to write to system tables, so the `SystemLog parameter queue is full` error doesn’t happen as often. +- The `windowFunnel` aggregate function now supports events that meet multiple conditions. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2801) +- Duplicate columns can be used in a `USING` clause for `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) +- `Pretty` formats now have a limit on column alignment by width. Use the `output_format_pretty_max_column_pad_width` setting. If a value is wider, it will still be displayed in its entirety, but the other cells in the table will not be too wide. [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) +- The `odbc` table function now allows you to specify the database/schema name. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2885) +- Added the ability to use a username specified in the `clickhouse-client` config file. [Vladimir Kozbin](https://github.com/ClickHouse/ClickHouse/pull/2909) +- The `ZooKeeperExceptions` counter has been split into three counters: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions`, and `ZooKeeperOtherExceptions`. +- `ALTER DELETE` queries work for materialized views. +- Added randomization when running the cleanup thread periodically for `ReplicatedMergeTree` tables in order to avoid periodic load spikes when there are a very large number of `ReplicatedMergeTree` tables. +- Support for `ATTACH TABLE ... ON CLUSTER` queries. [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) + +#### Bug Fixes: {#bug-fixes-13} + +- Fixed an issue with `Dictionary` tables (throws the `Size of offsets doesn't match size of column` or `Unknown compression method` exception). This bug appeared in version 18.10.3. [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) +- Fixed a bug when merging `CollapsingMergeTree` tables if one of the data parts is empty (these parts are formed during merge or `ALTER DELETE` if all data was deleted), and the `vertical` algorithm was used for the merge. [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) +- Fixed a race condition during `DROP` or `TRUNCATE` for `Memory` tables with a simultaneous `SELECT`, which could lead to server crashes. This bug appeared in version 1.1.54388. [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) +- Fixed the possibility of data loss when inserting in `Replicated` tables if the `Session is expired` error is returned (data loss can be detected by the `ReplicatedDataLoss` metric). This error occurred in version 1.1.54378. [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) +- Fixed a segfault during `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) +- Fixed the error searching column names when the `WHERE` expression consists entirely of a qualified column name, such as `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) +- Fixed the “Not found column” error that occurred when executing distributed queries if a single column consisting of an IN expression with a subquery is requested from a remote server. [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) +- Fixed the `Block structure mismatch in UNION stream: different number of columns` error that occurred for distributed queries if one of the shards is local and the other is not, and optimization of the move to `PREWHERE` is triggered. [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) +- Fixed the `pointInPolygon` function for certain cases of non-convex polygons. [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) +- Fixed the incorrect result when comparing `nan` with integers. [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) +- Fixed an error in the `zlib-ng` library that could lead to segfault in rare cases. [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) +- Fixed a memory leak when inserting into a table with `AggregateFunction` columns, if the state of the aggregate function is not simple (allocates memory separately), and if a single insertion request results in multiple small blocks. [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) +- Fixed a race condition when creating and deleting the same `Buffer` or `MergeTree` table simultaneously. +- Fixed the possibility of a segfault when comparing tuples made up of certain non-trivial types, such as tuples. [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) +- Fixed the possibility of a segfault when running certain `ON CLUSTER` queries. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2960) +- Fixed an error in the `arrayDistinct` function for `Nullable` array elements. [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) +- The `enable_optimize_predicate_expression` option now correctly supports cases with `SELECT *`. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2929) +- Fixed the segfault when re-initializing the ZooKeeper session. [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) +- Fixed potential blocking when working with ZooKeeper. +- Fixed incorrect code for adding nested data structures in a `SummingMergeTree`. +- When allocating memory for states of aggregate functions, alignment is correctly taken into account, which makes it possible to use operations that require alignment when implementing states of aggregate functions. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) + +#### Security Fix: {#security-fix} + +- Safe use of ODBC data sources. Interaction with ODBC drivers uses a separate `clickhouse-odbc-bridge` process. Errors in third-party ODBC drivers no longer cause problems with server stability or vulnerabilities. [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) +- Fixed incorrect validation of the file path in the `catBoostPool` table function. [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) +- The contents of system tables (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas`, and `replication_queue`) are filtered according to the user’s configured access to databases (`allow_databases`). [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2856) + +#### Backward Incompatible Changes: {#backward-incompatible-changes-3} + +- In queries with JOIN, the star character expands to a list of columns in all tables, in compliance with the SQL standard. You can restore the old behavior by setting `asterisk_left_columns_only` to 1 on the user configuration level. + +#### Build Changes: {#build-changes-2} + +- Most integration tests can now be run by commit. +- Code style checks can also be run by commit. +- The `memcpy` implementation is chosen correctly when building on CentOS7/Fedora. [Etienne Champetier](https://github.com/ClickHouse/ClickHouse/pull/2912) +- When using clang to build, some warnings from `-Weverything` have been added, in addition to the regular `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) +- Debugging the build uses the `jemalloc` debug option. +- The interface of the library for interacting with ZooKeeper is declared abstract. [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) + +## ClickHouse Release 18.10 {#clickhouse-release-18-10} + +### ClickHouse Release 18.10.3, 2018-08-13 {#clickhouse-release-18-10-3-2018-08-13} + +#### New Features: {#new-features-5} + +- HTTPS can be used for replication. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) +- Added the functions `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64`, and `murmurHash3_128` in addition to the existing `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) +- Support for Nullable types in the ClickHouse ODBC driver (`ODBCDriver2` output format). [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) +- Support for `UUID` in the key columns. + +#### Improvements: {#improvements-5} + +- Clusters can be removed without restarting the server when they are deleted from the config files. [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) +- External dictionaries can be removed without restarting the server when they are removed from config files. [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) +- Added `SETTINGS` support for the `Kafka` table engine. [Alexander Marshalov](https://github.com/ClickHouse/ClickHouse/pull/2781) +- Improvements for the `UUID` data type (not yet complete). [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) +- Support for empty parts after merges in the `SummingMergeTree`, `CollapsingMergeTree` and `VersionedCollapsingMergeTree` engines. [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) +- Old records of completed mutations are deleted (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) +- Added the `system.merge_tree_settings` table. [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/2841) +- The `system.tables` table now has dependency columns: `dependencies_database` and `dependencies_table`. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2851) +- Added the `max_partition_size_to_drop` config option. [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) +- Added the `output_format_json_escape_forward_slashes` option. [Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2812) +- Added the `max_fetch_partition_retries_count` setting. [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) +- Added the `prefer_localhost_replica` setting for disabling the preference for a local replica and going to a local replica without inter-process interaction. [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) +- The `quantileExact` aggregate function returns `nan` in the case of aggregation on an empty `Float32` or `Float64` set. [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2855) + +#### Bug Fixes: {#bug-fixes-14} + +- Removed unnecessary escaping of the connection string parameters for ODBC, which made it impossible to establish a connection. This error occurred in version 18.6.0. +- Fixed the logic for processing `REPLACE PARTITION` commands in the replication queue. If there are two `REPLACE` commands for the same partition, the incorrect logic could cause one of them to remain in the replication queue and not be executed. [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) +- Fixed a merge bug when all data parts were empty (parts that were formed from a merge or from `ALTER DELETE` if all data was deleted). This bug appeared in version 18.1.0. [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) +- Fixed an error for concurrent `Set` or `Join`. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2823) +- Fixed the `Block structure mismatch in UNION stream: different number of columns` error that occurred for `UNION ALL` queries inside a sub-query if one of the `SELECT` queries contains duplicate column names. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2094) +- Fixed a memory leak if an exception occurred when connecting to a MySQL server. +- Fixed incorrect clickhouse-client response code in case of a query error. +- Fixed incorrect behavior of materialized views containing DISTINCT. [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) + +#### Backward Incompatible Changes {#backward-incompatible-changes-4} + +- Removed support for CHECK TABLE queries for Distributed tables. + +#### Build Changes: {#build-changes-3} + +- The allocator has been replaced: `jemalloc` is now used instead of `tcmalloc`. In some scenarios, this increases speed up to 20%. However, there are queries that have slowed by up to 20%. Memory consumption has been reduced by approximately 10% in some scenarios, with improved stability. With highly competitive loads, CPU usage in userspace and in system shows just a slight increase. [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) +- Use of libressl from a submodule. [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) +- Use of unixodbc from a submodule. [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) +- Use of mariadb-connector-c from a submodule. [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) +- Added functional test files to the repository that depend on the availability of test data (for the time being, without the test data itself). + +## ClickHouse Release 18.6 {#clickhouse-release-18-6} + +### ClickHouse Release 18.6.0, 2018-08-02 {#clickhouse-release-18-6-0-2018-08-02} + +#### New Features: {#new-features-6} + +- Added support for ON expressions for the JOIN ON syntax: + `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` + The expression must be a chain of equalities joined by the AND operator. Each side of the equality can be an arbitrary expression over the columns of one of the tables. The use of fully qualified column names is supported (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`) for the right table. [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) +- HTTPS can be enabled for replication. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) + +#### Improvements: {#improvements-6} + +- The server passes the patch component of its version to the client. Data about the patch version component is in `system.processes` and `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) + +## ClickHouse Release 18.5 {#clickhouse-release-18-5} + +### ClickHouse Release 18.5.1, 2018-07-31 {#clickhouse-release-18-5-1-2018-07-31} + +#### New Features: {#new-features-7} + +- Added the hash function `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). + +#### Improvements: {#improvements-7} + +- Now you can use the `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) attribute to set values in config files from environment variables. +- Added case-insensitive versions of the `coalesce`, `ifNull`, and `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). + +#### Bug Fixes: {#bug-fixes-15} + +- Fixed a possible bug when starting a replica [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). + +## ClickHouse Release 18.4 {#clickhouse-release-18-4} + +### ClickHouse Release 18.4.0, 2018-07-28 {#clickhouse-release-18-4-0-2018-07-28} + +#### New Features: {#new-features-8} + +- Added system tables: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). +- Added the ability to use a table function instead of a table as an argument of a `remote` or `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). +- Support for `HTTP Basic` authentication in the replication protocol [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). +- The `has` function now allows searching for a numeric value in an array of `Enum` values [Maxim Khrisanfov](https://github.com/ClickHouse/ClickHouse/pull/2699). +- Support for adding arbitrary message separators when reading from `Kafka` [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2701). + +#### Improvements: {#improvements-8} + +- The `ALTER TABLE t DELETE WHERE` query does not rewrite data parts that were not affected by the WHERE condition [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). +- The `use_minimalistic_checksums_in_zookeeper` option for `ReplicatedMergeTree` tables is enabled by default. This setting was added in version 1.1.54378, 2018-04-16. Versions that are older than 1.1.54378 can no longer be installed. +- Support for running `KILL` and `OPTIMIZE` queries that specify `ON CLUSTER` [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2689). + +#### Bug Fixes: {#bug-fixes-16} + +- Fixed the error `Column ... is not under an aggregate function and not in GROUP BY` for aggregation with an IN expression. This bug appeared in version 18.1.0. ([bbdd780b](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) +- Fixed a bug in the `windowFunnel aggregate function` [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2735). +- Fixed a bug in the `anyHeavy` aggregate function ([a2101df2](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) +- Fixed server crash when using the `countArray()` aggregate function. + +#### Backward Incompatible Changes: {#backward-incompatible-changes-5} + +- Parameters for `Kafka` engine was changed from `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` to `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. If your tables use `kafka_schema` or `kafka_num_consumers` parameters, you have to manually edit the metadata files `path/metadata/database/table.sql` and add `kafka_row_delimiter` parameter with `''` value. + +## ClickHouse Release 18.1 {#clickhouse-release-18-1} + +### ClickHouse Release 18.1.0, 2018-07-23 {#clickhouse-release-18-1-0-2018-07-23} + +#### New Features: {#new-features-9} + +- Support for the `ALTER TABLE t DELETE WHERE` query for non-replicated MergeTree tables ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). +- Support for arbitrary types for the `uniq*` family of aggregate functions ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). +- Support for arbitrary types in comparison operators ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). +- The `users.xml` file allows setting a subnet mask in the format `10.0.0.1/255.255.255.0`. This is necessary for using masks for IPv6 networks with zeros in the middle ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). +- Added the `arrayDistinct` function ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). +- The SummingMergeTree engine can now work with AggregateFunction type columns ([Constantin S. Pan](https://github.com/ClickHouse/ClickHouse/pull/2566)). + +#### Improvements: {#improvements-9} + +- Changed the numbering scheme for release versions. Now the first part contains the year of release (A.D., Moscow timezone, minus 2000), the second part contains the number for major changes (increases for most releases), and the third part is the patch version. Releases are still backward compatible, unless otherwise stated in the changelog. +- Faster conversions of floating-point numbers to a string ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2664)). +- If some rows were skipped during an insert due to parsing errors (this is possible with the `input_allow_errors_num` and `input_allow_errors_ratio` settings enabled), the number of skipped rows is now written to the server log ([Leonardo Cecchi](https://github.com/ClickHouse/ClickHouse/pull/2669)). + +#### Bug Fixes: {#bug-fixes-17} + +- Fixed the TRUNCATE command for temporary tables ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2624)). +- Fixed a rare deadlock in the ZooKeeper client library that occurred when there was a network error while reading the response ([c315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). +- Fixed an error during a CAST to Nullable types ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). +- Fixed the incorrect result of the `maxIntersection()` function when the boundaries of intervals coincided ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2657)). +- Fixed incorrect transformation of the OR expression chain in a function argument ([chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). +- Fixed performance degradation for queries containing `IN (subquery)` expressions inside another subquery ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). +- Fixed incompatibility between servers with different versions in distributed queries that use a `CAST` function that isn’t in uppercase letters ([fe8c4d6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). +- Added missing quoting of identifiers for queries to an external DBMS ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). + +#### Backward Incompatible Changes: {#backward-incompatible-changes-6} + +- Converting a string containing the number zero to DateTime does not work. Example: `SELECT toDateTime('0')`. This is also the reason that `DateTime DEFAULT '0'` does not work in tables, as well as `0` in dictionaries. Solution: replace `0` with `0000-00-00 00:00:00`. + +## ClickHouse Release 1.1 {#clickhouse-release-1-1} + +### ClickHouse Release 1.1.54394, 2018-07-12 {#clickhouse-release-1-1-54394-2018-07-12} + +#### New Features: {#new-features-10} + +- Added the `histogram` aggregate function ([Mikhail Surin](https://github.com/ClickHouse/ClickHouse/pull/2521)). +- Now `OPTIMIZE TABLE ... FINAL` can be used without specifying partitions for `ReplicatedMergeTree` ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2600)). + +#### Bug Fixes: {#bug-fixes-18} + +- Fixed a problem with a very small timeout for sockets (one second) for reading and writing when sending and downloading replicated data, which made it impossible to download larger parts if there is a load on the network or disk (it resulted in cyclical attempts to download parts). This error occurred in version 1.1.54388. +- Fixed issues when using chroot in ZooKeeper if you inserted duplicate data blocks in the table. +- The `has` function now works correctly for an array with Nullable elements ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). +- The `system.tables` table now works correctly when used in distributed queries. The `metadata_modification_time` and `engine_full` columns are now non-virtual. Fixed an error that occurred if only these columns were queried from the table. +- Fixed how an empty `TinyLog` table works after inserting an empty data block ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). +- The `system.zookeeper` table works if the value of the node in ZooKeeper is NULL. + +### ClickHouse Release 1.1.54390, 2018-07-06 {#clickhouse-release-1-1-54390-2018-07-06} + +#### New Features: {#new-features-11} + +- Queries can be sent in `multipart/form-data` format (in the `query` field), which is useful if external data is also sent for query processing ([Olga Hvostikova](https://github.com/ClickHouse/ClickHouse/pull/2490)). +- Added the ability to enable or disable processing single or double quotes when reading data in CSV format. You can configure this in the `format_csv_allow_single_quotes` and `format_csv_allow_double_quotes` settings ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2574)). +- Now `OPTIMIZE TABLE ... FINAL` can be used without specifying the partition for non-replicated variants of `MergeTree` ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2599)). + +#### Improvements: {#improvements-10} + +- Improved performance, reduced memory consumption, and correct memory consumption tracking with use of the IN operator when a table index could be used ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). +- Removed redundant checking of checksums when adding a data part. This is important when there are a large number of replicas, because in these cases the total number of checks was equal to N^2. +- Added support for `Array(Tuple(...))` arguments for the `arrayEnumerateUniq` function ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). +- Added `Nullable` support for the `runningDifference` function ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). +- Improved query analysis performance when there is a very large number of expressions ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). +- Faster selection of data parts for merging in `ReplicatedMergeTree` tables. Faster recovery of the ZooKeeper session ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). +- The `format_version.txt` file for `MergeTree` tables is re-created if it is missing, which makes sense if ClickHouse is launched after copying the directory structure without files ([Ciprian Hacman](https://github.com/ClickHouse/ClickHouse/pull/2593)). + +#### Bug Fixes: {#bug-fixes-19} + +- Fixed a bug when working with ZooKeeper that could make it impossible to recover the session and readonly states of tables before restarting the server. +- Fixed a bug when working with ZooKeeper that could result in old nodes not being deleted if the session is interrupted. +- Fixed an error in the `quantileTDigest` function for Float arguments (this bug was introduced in version 1.1.54388) ([Mikhail Surin](https://github.com/ClickHouse/ClickHouse/pull/2553)). +- Fixed a bug in the index for MergeTree tables if the primary key column is located inside the function for converting types between signed and unsigned integers of the same size ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). +- Fixed segfault if `macros` are used but they aren’t in the config file ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). +- Fixed switching to the default database when reconnecting the client ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). +- Fixed a bug that occurred when the `use_index_for_in_with_subqueries` setting was disabled. + +#### Security Fix: {#security-fix-1} + +- Sending files is no longer possible when connected to MySQL (`LOAD DATA LOCAL INFILE`). + +### ClickHouse Release 1.1.54388, 2018-06-28 {#clickhouse-release-1-1-54388-2018-06-28} + +#### New Features: {#new-features-12} + +- Support for the `ALTER TABLE t DELETE WHERE` query for replicated tables. Added the `system.mutations` table to track progress of this type of queries. +- Support for the `ALTER TABLE t [REPLACE|ATTACH] PARTITION` query for \*MergeTree tables. +- Support for the `TRUNCATE TABLE` query ([Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2260)) +- Several new `SYSTEM` queries for replicated tables (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). +- Added the ability to write to a table with the MySQL engine and the corresponding table function ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2294)). +- Added the `url()` table function and the `URL` table engine ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). +- Added the `windowFunnel` aggregate function ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2352)). +- New `startsWith` and `endsWith` functions for strings ([Vadim Plakhtinsky](https://github.com/ClickHouse/ClickHouse/pull/2429)). +- The `numbers()` table function now allows you to specify the offset ([Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2535)). +- The password to `clickhouse-client` can be entered interactively. +- Server logs can now be sent to syslog ([Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2459)). +- Support for logging in dictionaries with a shared library source ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). +- Support for custom CSV delimiters ([Ivan Zhukov](https://github.com/ClickHouse/ClickHouse/pull/2263)) +- Added the `date_time_input_format` setting. If you switch this setting to `'best_effort'`, DateTime values will be read in a wide range of formats. +- Added the `clickhouse-obfuscator` utility for data obfuscation. Usage example: publishing data used in performance tests. + +#### Experimental Features: {#experimental-features-2} + +- Added the ability to calculate `and` arguments only where they are needed ([Anastasia Tsarkova](https://github.com/ClickHouse/ClickHouse/pull/2272)) +- JIT compilation to native code is now available for some expressions ([pyos](https://github.com/ClickHouse/ClickHouse/pull/2277)). + +#### Bug Fixes: {#bug-fixes-20} + +- Duplicates no longer appear for a query with `DISTINCT` and `ORDER BY`. +- Queries with `ARRAY JOIN` and `arrayFilter` no longer return an incorrect result. +- Fixed an error when reading an array column from a Nested structure ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). +- Fixed an error when analyzing queries with a HAVING clause like `HAVING tuple IN (...)`. +- Fixed an error when analyzing queries with recursive aliases. +- Fixed an error when reading from ReplacingMergeTree with a condition in PREWHERE that filters all rows ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). +- User profile settings were not applied when using sessions in the HTTP interface. +- Fixed how settings are applied from the command line parameters in clickhouse-local. +- The ZooKeeper client library now uses the session timeout received from the server. +- Fixed a bug in the ZooKeeper client library when the client waited for the server response longer than the timeout. +- Fixed pruning of parts for queries with conditions on partition key columns ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). +- Merges are now possible after `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). +- Type mapping in the ODBC table function has been fixed ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2268)). +- Type comparisons have been fixed for `DateTime` with and without the time zone ([Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2400)). +- Fixed syntactic parsing and formatting of the `CAST` operator. +- Fixed insertion into a materialized view for the Distributed table engine ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). +- Fixed a race condition when writing data from the `Kafka` engine to materialized views ([Yangkuan Liu](https://github.com/ClickHouse/ClickHouse/pull/2448)). +- Fixed SSRF in the remote() table function. +- Fixed exit behavior of `clickhouse-client` in multiline mode ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). + +#### Improvements: {#improvements-11} + +- Background tasks in replicated tables are now performed in a thread pool instead of in separate threads ([Silviu Caragea](https://github.com/ClickHouse/ClickHouse/pull/1722)). +- Improved LZ4 compression performance. +- Faster analysis for queries with a large number of JOINs and sub-queries. +- The DNS cache is now updated automatically when there are too many network errors. +- Table inserts no longer occur if the insert into one of the materialized views is not possible because it has too many parts. +- Corrected the discrepancy in the event counters `Query`, `SelectQuery`, and `InsertQuery`. +- Expressions like `tuple IN (SELECT tuple)` are allowed if the tuple types match. +- A server with replicated tables can start even if you haven’t configured ZooKeeper. +- When calculating the number of available CPU cores, limits on cgroups are now taken into account ([Atri Sharma](https://github.com/ClickHouse/ClickHouse/pull/2325)). +- Added chown for config directories in the systemd config file ([Mikhail Shiryaev](https://github.com/ClickHouse/ClickHouse/pull/2421)). + +#### Build Changes: {#build-changes-4} + +- The gcc8 compiler can be used for builds. +- Added the ability to build llvm from submodule. +- The version of the librdkafka library has been updated to v0.11.4. +- Added the ability to use the system libcpuid library. The library version has been updated to 0.4.0. +- Fixed the build using the vectorclass library ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). +- Cmake now generates files for ninja by default (like when using `-G Ninja`). +- Added the ability to use the libtinfo library instead of libtermcap ([Georgy Kondratiev](https://github.com/ClickHouse/ClickHouse/pull/2519)). +- Fixed a header file conflict in Fedora Rawhide ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). + +#### Backward Incompatible Changes: {#backward-incompatible-changes-7} + +- Removed escaping in `Vertical` and `Pretty*` formats and deleted the `VerticalRaw` format. +- If servers with version 1.1.54388 (or newer) and servers with an older version are used simultaneously in a distributed query and the query has the `cast(x, 'Type')` expression without the `AS` keyword and doesn’t have the word `cast` in uppercase, an exception will be thrown with a message like `Not found column cast(0, 'UInt8') in block`. Solution: Update the server on the entire cluster. + +### ClickHouse Release 1.1.54385, 2018-06-01 {#clickhouse-release-1-1-54385-2018-06-01} + +#### Bug Fixes: {#bug-fixes-21} + +- Fixed an error that in some cases caused ZooKeeper operations to block. + +### ClickHouse Release 1.1.54383, 2018-05-22 {#clickhouse-release-1-1-54383-2018-05-22} + +#### Bug Fixes: {#bug-fixes-22} + +- Fixed a slowdown of replication queue if a table has many replicas. + +### ClickHouse Release 1.1.54381, 2018-05-14 {#clickhouse-release-1-1-54381-2018-05-14} + +#### Bug Fixes: {#bug-fixes-23} + +- Fixed a nodes leak in ZooKeeper when ClickHouse loses connection to ZooKeeper server. + +### ClickHouse Release 1.1.54380, 2018-04-21 {#clickhouse-release-1-1-54380-2018-04-21} + +#### New Features: {#new-features-13} + +- Added the table function `file(path, format, structure)`. An example reading bytes from `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. + +#### Improvements: {#improvements-12} + +- Subqueries can be wrapped in `()` brackets to enhance query readability. For example: `(SELECT 1) UNION ALL (SELECT 1)`. +- Simple `SELECT` queries from the `system.processes` table are not included in the `max_concurrent_queries` limit. + +#### Bug Fixes: {#bug-fixes-24} + +- Fixed incorrect behavior of the `IN` operator when select from `MATERIALIZED VIEW`. +- Fixed incorrect filtering by partition index in expressions like `partition_key_column IN (...)`. +- Fixed inability to execute `OPTIMIZE` query on non-leader replica if `REANAME` was performed on the table. +- Fixed the authorization error when executing `OPTIMIZE` or `ALTER` queries on a non-leader replica. +- Fixed freezing of `KILL QUERY`. +- Fixed an error in ZooKeeper client library which led to loss of watches, freezing of distributed DDL queue, and slowdowns in the replication queue if a non-empty `chroot` prefix is used in the ZooKeeper configuration. + +#### Backward Incompatible Changes: {#backward-incompatible-changes-8} + +- Removed support for expressions like `(a, b) IN (SELECT (a, b))` (you can use the equivalent expression `(a, b) IN (SELECT a, b)`). In previous releases, these expressions led to undetermined `WHERE` filtering or caused errors. + +### ClickHouse Release 1.1.54378, 2018-04-16 {#clickhouse-release-1-1-54378-2018-04-16} + +#### New Features: {#new-features-14} + +- Logging level can be changed without restarting the server. +- Added the `SHOW CREATE DATABASE` query. +- The `query_id` can be passed to `clickhouse-client` (elBroom). +- New setting: `max_network_bandwidth_for_all_users`. +- Added support for `ALTER TABLE ... PARTITION ...` for `MATERIALIZED VIEW`. +- Added information about the size of data parts in uncompressed form in the system table. +- Server-to-server encryption support for distributed tables (`1` in the replica config in ``). +- Configuration of the table level for the `ReplicatedMergeTree` family in order to minimize the amount of data stored in Zookeeper: : `use_minimalistic_checksums_in_zookeeper = 1` +- Configuration of the `clickhouse-client` prompt. By default, server names are now output to the prompt. The server’s display name can be changed. It’s also sent in the `X-ClickHouse-Display-Name` HTTP header (Kirill Shvakov). +- Multiple comma-separated `topics` can be specified for the `Kafka` engine (Tobias Adamson) +- When a query is stopped by `KILL QUERY` or `replace_running_query`, the client receives the `Query was canceled` exception instead of an incomplete result. + +#### Improvements: {#improvements-13} + +- `ALTER TABLE ... DROP/DETACH PARTITION` queries are run at the front of the replication queue. +- `SELECT ... FINAL` and `OPTIMIZE ... FINAL` can be used even when the table has a single data part. +- A `query_log` table is recreated on the fly if it was deleted manually (Kirill Shvakov). +- The `lengthUTF8` function runs faster (zhang2014). +- Improved performance of synchronous inserts in `Distributed` tables (`insert_distributed_sync = 1`) when there is a very large number of shards. +- The server accepts the `send_timeout` and `receive_timeout` settings from the client and applies them when connecting to the client (they are applied in reverse order: the server socket’s `send_timeout` is set to the `receive_timeout` value received from the client, and vice versa). +- More robust crash recovery for asynchronous insertion into `Distributed` tables. +- The return type of the `countEqual` function changed from `UInt32` to `UInt64` (谢磊). + +#### Bug Fixes: {#bug-fixes-25} + +- Fixed an error with `IN` when the left side of the expression is `Nullable`. +- Correct results are now returned when using tuples with `IN` when some of the tuple components are in the table index. +- The `max_execution_time` limit now works correctly with distributed queries. +- Fixed errors when calculating the size of composite columns in the `system.columns` table. +- Fixed an error when creating a temporary table `CREATE TEMPORARY TABLE IF NOT EXISTS.` +- Fixed errors in `StorageKafka` (\#\#2075) +- Fixed server crashes from invalid arguments of certain aggregate functions. +- Fixed the error that prevented the `DETACH DATABASE` query from stopping background tasks for `ReplicatedMergeTree` tables. +- `Too many parts` state is less likely to happen when inserting into aggregated materialized views (\#\#2084). +- Corrected recursive handling of substitutions in the config if a substitution must be followed by another substitution on the same level. +- Corrected the syntax in the metadata file when creating a `VIEW` that uses a query with `UNION ALL`. +- `SummingMergeTree` now works correctly for summation of nested data structures with a composite key. +- Fixed the possibility of a race condition when choosing the leader for `ReplicatedMergeTree` tables. + +#### Build Changes: {#build-changes-5} + +- The build supports `ninja` instead of `make` and uses `ninja` by default for building releases. +- Renamed packages: `clickhouse-server-base` in `clickhouse-common-static`; `clickhouse-server-common` in `clickhouse-server`; `clickhouse-common-dbg` in `clickhouse-common-static-dbg`. To install, use `clickhouse-server clickhouse-client`. Packages with the old names will still load in the repositories for backward compatibility. + +#### Backward Incompatible Changes: {#backward-incompatible-changes-9} + +- Removed the special interpretation of an IN expression if an array is specified on the left side. Previously, the expression `arr IN (set)` was interpreted as “at least one `arr` element belongs to the `set`”. To get the same behavior in the new version, write `arrayExists(x -> x IN (set), arr)`. +- Disabled the incorrect use of the socket option `SO_REUSEPORT`, which was incorrectly enabled by default in the Poco library. Note that on Linux there is no longer any reason to simultaneously specify the addresses `::` and `0.0.0.0` for listen – use just `::`, which allows listening to the connection both over IPv4 and IPv6 (with the default kernel config settings). You can also revert to the behavior from previous versions by specifying `1` in the config. + +### ClickHouse Release 1.1.54370, 2018-03-16 {#clickhouse-release-1-1-54370-2018-03-16} + +#### New Features: {#new-features-15} + +- Added the `system.macros` table and auto updating of macros when the config file is changed. +- Added the `SYSTEM RELOAD CONFIG` query. +- Added the `maxIntersections(left_col, right_col)` aggregate function, which returns the maximum number of simultaneously intersecting intervals `[left; right]`. The `maxIntersectionsPosition(left, right)` function returns the beginning of the “maximum” interval. ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2012)). + +#### Improvements: {#improvements-14} + +- When inserting data in a `Replicated` table, fewer requests are made to `ZooKeeper` (and most of the user-level errors have disappeared from the `ZooKeeper` log). +- Added the ability to create aliases for data sets. Example: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. + +#### Bug Fixes: {#bug-fixes-26} + +- Fixed the `Illegal PREWHERE` error when reading from Merge tables for `Distributed`tables. +- Added fixes that allow you to start clickhouse-server in IPv4-only Docker containers. +- Fixed a race condition when reading from system `system.parts_columns tables.` +- Removed double buffering during a synchronous insert to a `Distributed` table, which could have caused the connection to timeout. +- Fixed a bug that caused excessively long waits for an unavailable replica before beginning a `SELECT` query. +- Fixed incorrect dates in the `system.parts` table. +- Fixed a bug that made it impossible to insert data in a `Replicated` table if `chroot` was non-empty in the configuration of the `ZooKeeper` cluster. +- Fixed the vertical merging algorithm for an empty `ORDER BY` table. +- Restored the ability to use dictionaries in queries to remote tables, even if these dictionaries are not present on the requestor server. This functionality was lost in release 1.1.54362. +- Restored the behavior for queries like `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` when the right side of the `IN` should use a remote `default.table` instead of a local one. This behavior was broken in version 1.1.54358. +- Removed extraneous error-level logging of `Not found column ... in block`. + +### ClickHouse Release 1.1.54362, 2018-03-11 {#clickhouse-release-1-1-54362-2018-03-11} + +#### New Features: {#new-features-16} + +- Aggregation without `GROUP BY` for an empty set (such as `SELECT count(*) FROM table WHERE 0`) now returns a result with one row with null values for aggregate functions, in compliance with the SQL standard. To restore the old behavior (return an empty result), set `empty_result_for_aggregation_by_empty_set` to 1. +- Added type conversion for `UNION ALL`. Different alias names are allowed in `SELECT` positions in `UNION ALL`, in compliance with the SQL standard. +- Arbitrary expressions are supported in `LIMIT BY` clauses. Previously, it was only possible to use columns resulting from `SELECT`. +- An index of `MergeTree` tables is used when `IN` is applied to a tuple of expressions from the columns of the primary key. Example: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` (Anastasiya Tsarkova). +- Added the `clickhouse-copier` tool for copying between clusters and resharding data (beta). +- Added consistent hashing functions: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. They can be used as a sharding key in order to reduce the amount of network traffic during subsequent reshardings. +- Added functions: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. +- Added the `arrayCumSum` function (Javi Santana). +- Added the `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero`, and `parseDateTimeBestEffortOrNull` functions to read the DateTime from a string containing text in a wide variety of possible formats. +- Data can be partially reloaded from external dictionaries during updating (load just the records in which the value of the specified field greater than in the previous download) (Arsen Hakobyan). +- Added the `cluster` table function. Example: `cluster(cluster_name, db, table)`. The `remote` table function can accept the cluster name as the first argument, if it is specified as an identifier. +- The `remote` and `cluster` table functions can be used in `INSERT` queries. +- Added the `create_table_query` and `engine_full` virtual columns to the `system.tables`table . The `metadata_modification_time` column is virtual. +- Added the `data_path` and `metadata_path` columns to `system.tables`and`system.databases` tables, and added the `path` column to the `system.parts` and `system.parts_columns` tables. +- Added additional information about merges in the `system.part_log` table. +- An arbitrary partitioning key can be used for the `system.query_log` table (Kirill Shvakov). +- The `SHOW TABLES` query now also shows temporary tables. Added temporary tables and the `is_temporary` column to `system.tables` (zhang2014). +- Added `DROP TEMPORARY TABLE` and `EXISTS TEMPORARY TABLE` queries (zhang2014). +- Support for `SHOW CREATE TABLE` for temporary tables (zhang2014). +- Added the `system_profile` configuration parameter for the settings used by internal processes. +- Support for loading `object_id` as an attribute in `MongoDB` dictionaries (Pavel Litvinenko). +- Reading `null` as the default value when loading data for an external dictionary with the `MongoDB` source (Pavel Litvinenko). +- Reading `DateTime` values in the `Values` format from a Unix timestamp without single quotes. +- Failover is supported in `remote` table functions for cases when some of the replicas are missing the requested table. +- Configuration settings can be overridden in the command line when you run `clickhouse-server`. Example: `clickhouse-server -- --logger.level=information`. +- Implemented the `empty` function from a `FixedString` argument: the function returns 1 if the string consists entirely of null bytes (zhang2014). +- Added the `listen_try`configuration parameter for listening to at least one of the listen addresses without quitting, if some of the addresses can’t be listened to (useful for systems with disabled support for IPv4 or IPv6). +- Added the `VersionedCollapsingMergeTree` table engine. +- Support for rows and arbitrary numeric types for the `library` dictionary source. +- `MergeTree` tables can be used without a primary key (you need to specify `ORDER BY tuple()`). +- A `Nullable` type can be `CAST` to a non-`Nullable` type if the argument is not `NULL`. +- `RENAME TABLE` can be performed for `VIEW`. +- Added the `throwIf` function. +- Added the `odbc_default_field_size` option, which allows you to extend the maximum size of the value loaded from an ODBC source (by default, it is 1024). +- The `system.processes` table and `SHOW PROCESSLIST` now have the `is_cancelled` and `peak_memory_usage` columns. + +#### Improvements: {#improvements-15} + +- Limits and quotas on the result are no longer applied to intermediate data for `INSERT SELECT` queries or for `SELECT` subqueries. +- Fewer false triggers of `force_restore_data` when checking the status of `Replicated` tables when the server starts. +- Added the `allow_distributed_ddl` option. +- Nondeterministic functions are not allowed in expressions for `MergeTree` table keys. +- Files with substitutions from `config.d` directories are loaded in alphabetical order. +- Improved performance of the `arrayElement` function in the case of a constant multidimensional array with an empty array as one of the elements. Example: `[[1], []][x]`. +- The server starts faster now when using configuration files with very large substitutions (for instance, very large lists of IP networks). +- When running a query, table valued functions run once. Previously, `remote` and `mysql` table valued functions performed the same query twice to retrieve the table structure from a remote server. +- The `MkDocs` documentation generator is used. +- When you try to delete a table column that `DEFAULT`/`MATERIALIZED` expressions of other columns depend on, an exception is thrown (zhang2014). +- Added the ability to parse an empty line in text formats as the number 0 for `Float` data types. This feature was previously available but was lost in release 1.1.54342. +- `Enum` values can be used in `min`, `max`, `sum` and some other functions. In these cases, it uses the corresponding numeric values. This feature was previously available but was lost in the release 1.1.54337. +- Added `max_expanded_ast_elements` to restrict the size of the AST after recursively expanding aliases. + +#### Bug Fixes: {#bug-fixes-27} + +- Fixed cases when unnecessary columns were removed from subqueries in error, or not removed from subqueries containing `UNION ALL`. +- Fixed a bug in merges for `ReplacingMergeTree` tables. +- Fixed synchronous insertions in `Distributed` tables (`insert_distributed_sync = 1`). +- Fixed segfault for certain uses of `FULL` and `RIGHT JOIN` with duplicate columns in subqueries. +- Fixed segfault for certain uses of `replace_running_query` and `KILL QUERY`. +- Fixed the order of the `source` and `last_exception` columns in the `system.dictionaries` table. +- Fixed a bug when the `DROP DATABASE` query did not delete the file with metadata. +- Fixed the `DROP DATABASE` query for `Dictionary` databases. +- Fixed the low precision of `uniqHLL12` and `uniqCombined` functions for cardinalities greater than 100 million items (Alex Bocharov). +- Fixed the calculation of implicit default values when necessary to simultaneously calculate default explicit expressions in `INSERT` queries (zhang2014). +- Fixed a rare case when a query to a `MergeTree` table couldn’t finish (chenxing-xc). +- Fixed a crash that occurred when running a `CHECK` query for `Distributed` tables if all shards are local (chenxing.xc). +- Fixed a slight performance regression with functions that use regular expressions. +- Fixed a performance regression when creating multidimensional arrays from complex expressions. +- Fixed a bug that could cause an extra `FORMAT` section to appear in an `.sql` file with metadata. +- Fixed a bug that caused the `max_table_size_to_drop` limit to apply when trying to delete a `MATERIALIZED VIEW` looking at an explicitly specified table. +- Fixed incompatibility with old clients (old clients were sometimes sent data with the `DateTime('timezone')` type, which they do not understand). +- Fixed a bug when reading `Nested` column elements of structures that were added using `ALTER` but that are empty for the old partitions, when the conditions for these columns moved to `PREWHERE`. +- Fixed a bug when filtering tables by virtual `_table` columns in queries to `Merge` tables. +- Fixed a bug when using `ALIAS` columns in `Distributed` tables. +- Fixed a bug that made dynamic compilation impossible for queries with aggregate functions from the `quantile` family. +- Fixed a race condition in the query execution pipeline that occurred in very rare cases when using `Merge` tables with a large number of tables, and when using `GLOBAL` subqueries. +- Fixed a crash when passing arrays of different sizes to an `arrayReduce` function when using aggregate functions from multiple arguments. +- Prohibited the use of queries with `UNION ALL` in a `MATERIALIZED VIEW`. +- Fixed an error during initialization of the `part_log` system table when the server starts (by default, `part_log` is disabled). + +#### Backward Incompatible Changes: {#backward-incompatible-changes-10} + +- Removed the `distributed_ddl_allow_replicated_alter` option. This behavior is enabled by default. +- Removed the `strict_insert_defaults` setting. If you were using this functionality, write to `clickhouse-feedback@yandex-team.com`. +- Removed the `UnsortedMergeTree` engine. + +### ClickHouse Release 1.1.54343, 2018-02-05 {#clickhouse-release-1-1-54343-2018-02-05} + +- Added macros support for defining cluster names in distributed DDL queries and constructors of Distributed tables: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. +- Now queries like `SELECT ... FROM table WHERE expr IN (subquery)` are processed using the `table` index. +- Improved processing of duplicates when inserting to Replicated tables, so they no longer slow down execution of the replication queue. + +### ClickHouse Release 1.1.54342, 2018-01-22 {#clickhouse-release-1-1-54342-2018-01-22} + +This release contains bug fixes for the previous release 1.1.54337: + +- Fixed a regression in 1.1.54337: if the default user has readonly access, then the server refuses to start up with the message `Cannot create database in readonly mode`. +- Fixed a regression in 1.1.54337: on systems with systemd, logs are always written to syslog regardless of the configuration; the watchdog script still uses init.d. +- Fixed a regression in 1.1.54337: wrong default configuration in the Docker image. +- Fixed nondeterministic behavior of GraphiteMergeTree (you can see it in log messages `Data after merge is not byte-identical to the data on another replicas`). +- Fixed a bug that may lead to inconsistent merges after OPTIMIZE query to Replicated tables (you may see it in log messages `Part ... intersects the previous part`). +- Buffer tables now work correctly when MATERIALIZED columns are present in the destination table (by zhang2014). +- Fixed a bug in implementation of NULL. + +### ClickHouse Release 1.1.54337, 2018-01-18 {#clickhouse-release-1-1-54337-2018-01-18} + +#### New Features: {#new-features-17} + +- Added support for storage of multi-dimensional arrays and tuples (`Tuple` data type) in tables. +- Support for table functions for `DESCRIBE` and `INSERT` queries. Added support for subqueries in `DESCRIBE`. Examples: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. Support for `INSERT INTO TABLE` in addition to `INSERT INTO`. +- Improved support for time zones. The `DateTime` data type can be annotated with the timezone that is used for parsing and formatting in text formats. Example: `DateTime('Europe/Moscow')`. When timezones are specified in functions for `DateTime` arguments, the return type will track the timezone, and the value will be displayed as expected. +- Added the functions `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. The `toRelativeHour`/`Minute`/`Second` functions can take a value of type `Date` as an argument. The `now` function name is case-sensitive. +- Added the `toStartOfFifteenMinutes` function (Kirill Shvakov). +- Added the `clickhouse format` tool for formatting queries. +- Added the `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` format. Schema files can be located only in the specified directory. +- Added support for config substitutions (`incl` and `conf.d`) for configuration of external dictionaries and models (Pavel Yakunin). +- Added a column with documentation for the `system.settings` table (Kirill Shvakov). +- Added the `system.parts_columns` table with information about column sizes in each data part of `MergeTree` tables. +- Added the `system.models` table with information about loaded `CatBoost` machine learning models. +- Added the `mysql` and `odbc` table function and corresponding `MySQL` and `ODBC` table engines for accessing remote databases. This functionality is in the beta stage. +- Added the possibility to pass an argument of type `AggregateFunction` for the `groupArray` aggregate function (so you can create an array of states of some aggregate function). +- Removed restrictions on various combinations of aggregate function combinators. For example, you can use `avgForEachIf` as well as `avgIfForEach` aggregate functions, which have different behaviors. +- The `-ForEach` aggregate function combinator is extended for the case of aggregate functions of multiple arguments. +- Added support for aggregate functions of `Nullable` arguments even for cases when the function returns a non-`Nullable` result (added with the contribution of Silviu Caragea). Example: `groupArray`, `groupUniqArray`, `topK`. +- Added the `max_client_network_bandwidth` for `clickhouse-client` (Kirill Shvakov). +- Users with the `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). +- Added support for using multiple consumers with the `Kafka` engine. Extended configuration options for `Kafka` (Marek Vavruša). +- Added the `intExp3` and `intExp4` functions. +- Added the `sumKahan` aggregate function. +- Added the to \* Number\* OrNull functions, where \* Number\* is a numeric type. +- Added support for `WITH` clauses for an `INSERT SELECT` query (author: zhang2014). +- Added settings: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. In particular, these settings are used for downloading data parts for replication. Changing these settings allows for faster failover if the network is overloaded. +- Added support for `ALTER` for tables of type `Null` (Anastasiya Tsarkova). +- The `reinterpretAsString` function is extended for all data types that are stored contiguously in memory. +- Added the `--silent` option for the `clickhouse-local` tool. It suppresses printing query execution info in stderr. +- Added support for reading values of type `Date` from text in a format where the month and/or day of the month is specified using a single digit instead of two digits (Amos Bird). + +#### Performance Optimizations: {#performance-optimizations} + +- Improved performance of aggregate functions `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` from string arguments. +- Improved performance of the functions `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. +- Improved performance of parsing and formatting `Date` and `DateTime` type values in text format. +- Improved performance and precision of parsing floating point numbers. +- Lowered memory usage for `JOIN` in the case when the left and right parts have columns with identical names that are not contained in `USING` . +- Improved performance of aggregate functions `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` by reducing computational stability. The old functions are available under the names `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. + +#### Bug Fixes: {#bug-fixes-28} + +- Fixed data deduplication after running a `DROP` or `DETACH PARTITION` query. In the previous version, dropping a partition and inserting the same data again was not working because inserted blocks were considered duplicates. +- Fixed a bug that could lead to incorrect interpretation of the `WHERE` clause for `CREATE MATERIALIZED VIEW` queries with `POPULATE` . +- Fixed a bug in using the `root_path` parameter in the `zookeeper_servers` configuration. +- Fixed unexpected results of passing the `Date` argument to `toStartOfDay` . +- Fixed the `addMonths` and `subtractMonths` functions and the arithmetic for `INTERVAL n MONTH` in cases when the result has the previous year. +- Added missing support for the `UUID` data type for `DISTINCT` , `JOIN` , and `uniq` aggregate functions and external dictionaries (Evgeniy Ivanov). Support for `UUID` is still incomplete. +- Fixed `SummingMergeTree` behavior in cases when the rows summed to zero. +- Various fixes for the `Kafka` engine (Marek Vavruša). +- Fixed incorrect behavior of the `Join` table engine (Amos Bird). +- Fixed incorrect allocator behavior under FreeBSD and OS X. +- The `extractAll` function now supports empty matches. +- Fixed an error that blocked usage of `libressl` instead of `openssl` . +- Fixed the `CREATE TABLE AS SELECT` query from temporary tables. +- Fixed non-atomicity of updating the replication queue. This could lead to replicas being out of sync until the server restarts. +- Fixed possible overflow in `gcd` , `lcm` and `modulo` (`%` operator) (Maks Skorokhod). +- `-preprocessed` files are now created after changing `umask` (`umask` can be changed in the config). +- Fixed a bug in the background check of parts (`MergeTreePartChecker` ) when using a custom partition key. +- Fixed parsing of tuples (values of the `Tuple` data type) in text formats. +- Improved error messages about incompatible types passed to `multiIf` , `array` and some other functions. +- Redesigned support for `Nullable` types. Fixed bugs that may lead to a server crash. Fixed almost all other bugs related to `NULL` support: incorrect type conversions in INSERT SELECT, insufficient support for Nullable in HAVING and PREWHERE, `join_use_nulls` mode, Nullable types as arguments of `OR` operator, etc. +- Fixed various bugs related to internal semantics of data types. Examples: unnecessary summing of `Enum` type fields in `SummingMergeTree` ; alignment of `Enum` types in `Pretty` formats, etc. +- Stricter checks for allowed combinations of composite columns. +- Fixed the overflow when specifying a very large parameter for the `FixedString` data type. +- Fixed a bug in the `topK` aggregate function in a generic case. +- Added the missing check for equality of array sizes in arguments of n-ary variants of aggregate functions with an `-Array` combinator. +- Fixed a bug in `--pager` for `clickhouse-client` (author: ks1322). +- Fixed the precision of the `exp10` function. +- Fixed the behavior of the `visitParamExtract` function for better compliance with documentation. +- Fixed the crash when incorrect data types are specified. +- Fixed the behavior of `DISTINCT` in the case when all columns are constants. +- Fixed query formatting in the case of using the `tupleElement` function with a complex constant expression as the tuple element index. +- Fixed a bug in `Dictionary` tables for `range_hashed` dictionaries. +- Fixed a bug that leads to excessive rows in the result of `FULL` and `RIGHT JOIN` (Amos Bird). +- Fixed a server crash when creating and removing temporary files in `config.d` directories during config reload. +- Fixed the `SYSTEM DROP DNS CACHE` query: the cache was flushed but addresses of cluster nodes were not updated. +- Fixed the behavior of `MATERIALIZED VIEW` after executing `DETACH TABLE` for the table under the view (Marek Vavruša). + +#### Build Improvements: {#build-improvements-4} + +- The `pbuilder` tool is used for builds. The build process is almost completely independent of the build host environment. +- A single build is used for different OS versions. Packages and binaries have been made compatible with a wide range of Linux systems. +- Added the `clickhouse-test` package. It can be used to run functional tests. +- The source tarball can now be published to the repository. It can be used to reproduce the build without using GitHub. +- Added limited integration with Travis CI. Due to limits on build time in Travis, only the debug build is tested and a limited subset of tests are run. +- Added support for `Cap'n'Proto` in the default build. +- Changed the format of documentation sources from `Restricted Text` to `Markdown`. +- Added support for `systemd` (Vladimir Smirnov). It is disabled by default due to incompatibility with some OS images and can be enabled manually. +- For dynamic code generation, `clang` and `lld` are embedded into the `clickhouse` binary. They can also be invoked as `clickhouse clang` and `clickhouse lld` . +- Removed usage of GNU extensions from the code. Enabled the `-Wextra` option. When building with `clang` the default is `libc++` instead of `libstdc++`. +- Extracted `clickhouse_parsers` and `clickhouse_common_io` libraries to speed up builds of various tools. + +#### Backward Incompatible Changes: {#backward-incompatible-changes-11} + +- The format for marks in `Log` type tables that contain `Nullable` columns was changed in a backward incompatible way. If you have these tables, you should convert them to the `TinyLog` type before starting up the new server version. To do this, replace `ENGINE = Log` with `ENGINE = TinyLog` in the corresponding `.sql` file in the `metadata` directory. If your table doesn’t have `Nullable` columns or if the type of your table is not `Log`, then you don’t need to do anything. +- Removed the `experimental_allow_extended_storage_definition_syntax` setting. Now this feature is enabled by default. +- The `runningIncome` function was renamed to `runningDifferenceStartingWithFirstvalue` to avoid confusion. +- Removed the `FROM ARRAY JOIN arr` syntax when ARRAY JOIN is specified directly after FROM with no table (Amos Bird). +- Removed the `BlockTabSeparated` format that was used solely for demonstration purposes. +- Changed the state format for aggregate functions `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. If you have stored states of these aggregate functions in tables (using the `AggregateFunction` data type or materialized views with corresponding states), please write to clickhouse-feedback@yandex-team.com. +- In previous server versions there was an undocumented feature: if an aggregate function depends on parameters, you can still specify it without parameters in the AggregateFunction data type. Example: `AggregateFunction(quantiles, UInt64)` instead of `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. This feature was lost. Although it was undocumented, we plan to support it again in future releases. +- Enum data types cannot be used in min/max aggregate functions. This ability will be returned in the next release. + +#### Please Note When Upgrading: {#please-note-when-upgrading} + +- When doing a rolling update on a cluster, at the point when some of the replicas are running the old version of ClickHouse and some are running the new version, replication is temporarily stopped and the message `unknown parameter 'shard'` appears in the log. Replication will continue after all replicas of the cluster are updated. +- If different versions of ClickHouse are running on the cluster servers, it is possible that distributed queries using the following functions will have incorrect results: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. You should update all cluster nodes. + +## [Changelog for 2017](./2017.md#clickhouse-release-1-1-54327-2017-12-21) {#changelog-for-2017} diff --git a/docs/en/whats-new/changelog/2019.md b/docs/en/whats-new/changelog/2019.md new file mode 100644 index 00000000000..d5a984905b7 --- /dev/null +++ b/docs/en/whats-new/changelog/2019.md @@ -0,0 +1,2072 @@ +--- +toc_priority: 77 +toc_title: '2019' +--- + +## ClickHouse Release 19.17 {#clickhouse-release-v19-17} + +### ClickHouse Release 19.17.6.36, 2019-12-27 {#clickhouse-release-v19-17-6-36-2019-12-27} + +#### Bug Fix {#bug-fix} + +- Fixed potential buffer overflow in decompress. Malicious user can pass fabricated compressed data that could cause read after buffer. This issue was found by Eldar Zaitov from Yandex information security team. [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed possible server crash (`std::terminate`) when the server cannot send or write data in JSON or XML format with values of String data type (that require UTF-8 validation) or when compressing result data with Brotli algorithm or in some other rare cases. [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed dictionaries with source from a clickhouse `VIEW`, now reading such dictionaries doesn’t cause the error `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed checking if a client host is allowed by host\_regexp specified in users.xml. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([Vitaly Baranov](https://github.com/vitlibar)) +- `RENAME TABLE` for a distributed table now renames the folder containing inserted data before sending to shards. This fixes an issue with successive renames `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) +- `range_hashed` external dictionaries created by DDL queries now allow ranges of arbitrary numeric types. [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([alesapin](https://github.com/alesapin)) +- Fixed `INSERT INTO table SELECT ... FROM mysql(...)` table function. [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) +- Fixed segfault in `INSERT INTO TABLE FUNCTION file()` while inserting into a file which doesn’t exist. Now in this case file would be created and then insert would be processed. [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) +- Fixed bitmapAnd error when intersecting an aggregated bitmap and a scalar bitmap. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([Yue Huang](https://github.com/moon03432)) +- Fixed segfault when `EXISTS` query was used without `TABLE` or `DICTIONARY` qualifier, just like `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed return type for functions `rand` and `randConstant` in case of nullable argument. Now functions always return `UInt32` and never `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed `DROP DICTIONARY IF EXISTS db.dict`, now it doesn’t throw exception if `db` doesn’t exist. [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([Vitaly Baranov](https://github.com/vitlibar)) +- If a table wasn’t completely dropped because of server crash, the server will try to restore and load it [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) +- Fixed a trivial count query for a distributed table if there are more than two shard local table. [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) +- Fixed bug that lead to a data race in DB::BlockStreamProfileInfo::calculateRowsBeforeLimit() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([Alexander Kazakov](https://github.com/Akazz)) +- Fixed `ALTER table MOVE part` executed immediately after merging the specified part, which could cause moving a part which the specified part merged into. Now it correctly moves the specified part. [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Expressions for dictionaries can be specified as strings now. This is useful for calculation of attributes while extracting data from non-ClickHouse sources because it allows to use non-ClickHouse syntax for those expressions. [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([alesapin](https://github.com/alesapin)) +- Fixed a very rare race in `clickhouse-copier` because of an overflow in ZXid. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([Ding Xiang Fei](https://github.com/dingxiangfei2009)) +- Fixed the bug when after the query failed (due to “Too many simultaneous queries” for example) it would not read external tables info, and the + next request would interpret this info as the beginning of the next query causing an error like `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) +- Avoid null dereference after “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) +- Restore support of all ICU locales, add the ability to apply collations for constant expressions and add language name to system.collations table. [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([alesapin](https://github.com/alesapin)) +- Number of streams for read from `StorageFile` and `StorageHDFS` is now limited, to avoid exceeding the memory limit. [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([alesapin](https://github.com/alesapin)) +- Fixed `CHECK TABLE` query for `*MergeTree` tables without key. [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([alesapin](https://github.com/alesapin)) +- Removed the mutation number from a part name in case there were no mutations. This removing improved the compatibility with older versions. [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([alesapin](https://github.com/alesapin)) +- Fixed the bug that mutations are skipped for some attached parts due to their data\_version are larger than the table mutation version. [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([Zhichang Yu](https://github.com/yuzhichang)) +- Allow starting the server with redundant copies of parts after moving them to another device. [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fixed the error “Sizes of columns doesn’t match” that might appear when using aggregate function columns. [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) +- Now an exception will be thrown in case of using WITH TIES alongside LIMIT BY. And now it’s possible to use TOP with LIMIT BY. [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +- Fix dictionary reload if it has `invalidate_query`, which stopped updates and some exception on previous update tries. [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([alesapin](https://github.com/alesapin)) + +### ClickHouse Release 19.17.4.11, 2019-11-22 {#clickhouse-release-v19-17-4-11-2019-11-22} + +#### Backward Incompatible Change {#backward-incompatible-change} + +- Using column instead of AST to store scalar subquery results for better performance. Setting `enable_scalar_subquery_optimization` was added in 19.17 and it was enabled by default. It leads to errors like [this](https://github.com/ClickHouse/ClickHouse/issues/7851) during upgrade to 19.17.2 or 19.17.3 from previous versions. This setting was disabled by default in 19.17.4, to make possible upgrading from 19.16 and older versions without errors. [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([Amos Bird](https://github.com/amosbird)) + +#### New Feature {#new-feature} + +- Add the ability to create dictionaries with DDL queries. [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([alesapin](https://github.com/alesapin)) +- Make `bloom_filter` type of index supporting `LowCardinality` and `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Add function `isValidJSON` to check that passed string is a valid json. [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([Vdimir](https://github.com/Vdimir)) +- Implement `arrayCompact` function [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([Memo](https://github.com/Joeywzr)) +- Created function `hex` for Decimal numbers. It works like `hex(reinterpretAsString())`, but doesn’t delete last zero bytes. [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([Mikhail Korotov](https://github.com/millb)) +- Add `arrayFill` and `arrayReverseFill` functions, which replace elements by other elements in front/back of them in the array. [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([hcz](https://github.com/hczhcz)) +- Add `CRC32IEEE()`/`CRC64()` support [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([Azat Khuzhin](https://github.com/azat)) +- Implement `char` function similar to one in [mysql](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([sundyli](https://github.com/sundy-li)) +- Add `bitmapTransform` function. It transforms an array of values in a bitmap to another array of values, the result is a new bitmap [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([Zhichang Yu](https://github.com/yuzhichang)) +- Implemented `javaHashUTF16LE()` function [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([achimbab](https://github.com/achimbab)) +- Add `_shard_num` virtual column for the Distributed engine [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([Azat Khuzhin](https://github.com/azat)) + +#### Experimental Feature {#experimental-feature} + +- Support for processors (new query execution pipeline) in `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +#### Bug Fix {#bug-fix-1} + +- Fix incorrect float parsing in `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) +- Fix rare deadlock which can happen when trace\_log is enabled. [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([filimonov](https://github.com/filimonov)) +- Prevent message duplication when producing Kafka table has any MVs selecting from it [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([Ivan](https://github.com/abyss7)) +- Support for `Array(LowCardinality(Nullable(String)))` in `IN`. Resolves [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([achimbab](https://github.com/achimbab)) +- Add handling of `SQL_TINYINT` and `SQL_BIGINT`, and fix handling of `SQL_FLOAT` data source types in ODBC Bridge. [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) +- Fix aggregation (`avg` and quantiles) over empty decimal columns [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([Andrey Konyaev](https://github.com/akonyaev90)) +- Fix `INSERT` into Distributed with `MATERIALIZED` columns [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) +- Make `MOVE PARTITION` work if some parts of partition are already on destination disk or volume [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fixed bug with hardlinks failing to be created during mutations in `ReplicatedMergeTree` in multi-disk configurations. [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fixed a bug with a mutation on a MergeTree when whole part remains unchanged and best space is being found on another disk [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fixed bug with `keep_free_space_ratio` not being read from disks configuration [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fix bug with table contains only `Tuple` columns or columns with complex paths. Fixes [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([alesapin](https://github.com/alesapin)) +- Do not account memory for Buffer engine in max\_memory\_usage limit [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([Azat Khuzhin](https://github.com/azat)) +- Fix final mark usage in `MergeTree` tables ordered by `tuple()`. In rare cases it could lead to `Can't adjust last granule` error while select. [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([Anton Popov](https://github.com/CurtizJ)) +- Fix bug in mutations that have predicate with actions that require context (for example functions for json), which may lead to crashes or strange exceptions. [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([alesapin](https://github.com/alesapin)) +- Fix mismatch of database and table names escaping in `data/` and `shadow/` directories [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([Alexander Burmak](https://github.com/Alex-Burmak)) +- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. Fix crash in this case. [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix `Not found column in block` when joining on expression with RIGHT or FULL JOIN. [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([Artem Zuikov](https://github.com/4ertus2)) +- One more attempt to fix infinite loop in `PrettySpace` format [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([Olga Khvostikova](https://github.com/stavrolia)) +- Fix bug in `concat` function when all arguments were `FixedString` of the same size. [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([alesapin](https://github.com/alesapin)) +- Fixed exception in case of using 1 argument while defining S3, URL and HDFS storages. [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fix scope of the InterpreterSelectQuery for views with query [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([Azat Khuzhin](https://github.com/azat)) + +#### Improvement {#improvement} + +- `Nullable` columns recognized and NULL-values handled correctly by ODBC-bridge [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([Vasily Nemkov](https://github.com/Enmk)) +- Write current batch for distributed send atomically [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([Azat Khuzhin](https://github.com/azat)) +- Throw an exception if we cannot detect table for column name in query. [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([Artem Zuikov](https://github.com/4ertus2)) +- Add `merge_max_block_size` setting to `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([Artem Zuikov](https://github.com/4ertus2)) +- Queries with `HAVING` and without `GROUP BY` assume group by constant. So, `SELECT 1 HAVING 1` now returns a result. [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([Amos Bird](https://github.com/amosbird)) +- Support parsing `(X,)` as tuple similar to python. [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([Amos Bird](https://github.com/amosbird)) +- Make `range` function behaviors almost like pythonic one. [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([sundyli](https://github.com/sundy-li)) +- Add `constraints` columns to table `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([Vitaly Baranov](https://github.com/vitlibar)) +- Better Null format for tcp handler, so that it’s possible to use `select ignore() from table format Null` for perf measure via clickhouse-client [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([Amos Bird](https://github.com/amosbird)) +- Queries like `CREATE TABLE ... AS (SELECT (1, 2))` are parsed correctly [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([hcz](https://github.com/hczhcz)) + +#### Performance Improvement {#performance-improvement} + +- The performance of aggregation over short string keys is improved. [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([Alexander Kuzmenkov](https://github.com/akuzm), [Amos Bird](https://github.com/amosbird)) +- Run another pass of syntax/expression analysis to get potential optimizations after constant predicates are folded. [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([Amos Bird](https://github.com/amosbird)) +- Use storage meta info to evaluate trivial `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([Amos Bird](https://github.com/amosbird), [alexey-milovidov](https://github.com/alexey-milovidov)) +- Vectorize processing `arrayReduce` similar to Aggregator `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([Amos Bird](https://github.com/amosbird)) +- Minor improvements in performance of `Kafka` consumption [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([Ivan](https://github.com/abyss7)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement} + +- Add support for cross-compiling to the CPU architecture AARCH64. Refactor packager script. [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([Ivan](https://github.com/abyss7)) +- Unpack darwin-x86\_64 and linux-aarch64 toolchains into mounted Docker volume when building packages [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([Ivan](https://github.com/abyss7)) +- Update Docker Image for Binary Packager [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([Ivan](https://github.com/abyss7)) +- Fixed compile errors on MacOS Catalina [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([Ernest Poletaev](https://github.com/ernestp)) +- Some refactoring in query analysis logic: split complex class into several simple ones. [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix build without submodules [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([proller](https://github.com/proller)) +- Better `add_globs` in CMake files [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([Amos Bird](https://github.com/amosbird)) +- Remove hardcoded paths in `unwind` target [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([Konstantin Podshumok](https://github.com/podshumok)) +- Allow to use mysql format without ssl [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([proller](https://github.com/proller)) + +#### Other {#other} + +- Added ANTLR4 grammar for ClickHouse SQL dialect [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +## ClickHouse Release 19.16 {#clickhouse-release-v19-16} + +#### ClickHouse Release 19.16.14.65, 2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} + +- Fixed up a bug in batched calculations of ternary logical OPs on multiple arguments (more than 10). [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([Alexander Kazakov](https://github.com/Akazz)) This bugfix was backported to version 19.16 by a special request from Altinity. + +#### ClickHouse Release 19.16.14.65, 2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} + +- Fix distributed subqueries incompatibility with older CH versions. Fixes [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) + [(tabplubix)](https://github.com/tavplubix) +- When executing `CREATE` query, fold constant expressions in storage engine arguments. Replace empty database name with current database. Fixes [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). Also fix check for local address in `ClickHouseDictionarySource`. + [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) +- Now background merges in `*MergeTree` table engines family preserve storage policy volume order more accurately. + [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Prevent losing data in `Kafka` in rare cases when exception happens after reading suffix but before commit. Fixes [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). Related: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) + [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(filimonov)](https://github.com/filimonov) +- Fix bug leading to server termination when trying to use / drop `Kafka` table created with wrong parameters. Fixes [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). Incorporates [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). + [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(filimonov)](https://github.com/filimonov) +- Allow using `MaterializedView` with subqueries above `Kafka` tables. + [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([filimonov](https://github.com/filimonov)) + +#### New Feature {#new-feature-1} + +- Add `deduplicate_blocks_in_dependent_materialized_views` option to control the behaviour of idempotent inserts into tables with materialized views. This new feature was added to the bugfix release by a special request from Altinity. + [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) + +### ClickHouse Release 19.16.2.2, 2019-10-30 {#clickhouse-release-v19-16-2-2-2019-10-30} + +#### Backward Incompatible Change {#backward-incompatible-change-1} + +- Add missing arity validation for count/counIf. + [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) + [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([Vdimir](https://github.com/Vdimir)) +- Remove legacy `asterisk_left_columns_only` setting (it was disabled by default). + [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([Artem + Zuikov](https://github.com/4ertus2)) +- Format strings for Template data format are now specified in files. + [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([tavplubix](https://github.com/tavplubix)) + +#### New Feature {#new-feature-2} + +- Introduce uniqCombined64() to calculate cardinality greater than UINT\_MAX. + [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), + [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([Azat + Khuzhin](https://github.com/azat)) +- Support Bloom filter indexes on Array columns. + [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) + ([achimbab](https://github.com/achimbab)) +- Add a function `getMacro(name)` that returns String with the value of corresponding `` + from server configuration. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) + ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Set two configuration options for a dictionary based on an HTTP source: `credentials` and + `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([Guillaume + Tassery](https://github.com/YiuRULE)) +- Add a new ProfileEvent `Merge` that counts the number of launched background merges. + [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([Mikhail + Korotov](https://github.com/millb)) +- Add fullHostName function that returns a fully qualified domain name. + [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) + [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([sundyli](https://github.com/sundy-li)) +- Add function `arraySplit` and `arrayReverseSplit` which split an array by “cut off” + conditions. They are useful in time sequence handling. + [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([hcz](https://github.com/hczhcz)) +- Add new functions that return the Array of all matched indices in multiMatch family of functions. + [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([Danila + Kutenin](https://github.com/danlark1)) +- Add a new database engine `Lazy` that is optimized for storing a large number of small -Log + tables. [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([Nikita + Vasilev](https://github.com/nikvas0)) +- Add aggregate functions groupBitmapAnd, -Or, -Xor for bitmap columns. [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([Zhichang + Yu](https://github.com/yuzhichang)) +- Add aggregate function combinators -OrNull and -OrDefault, which return null + or default values when there is nothing to aggregate. + [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) + ([hcz](https://github.com/hczhcz)) +- Introduce CustomSeparated data format that supports custom escaping and + delimiter rules. [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([tavplubix](https://github.com/tavplubix)) +- Support Redis as source of external dictionary. [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([comunodi](https://github.com/comunodi), [Anton + Popov](https://github.com/CurtizJ)) + +#### Bug Fix {#bug-fix-2} + +- Fix wrong query result if it has `WHERE IN (SELECT ...)` section and `optimize_read_in_order` is + used. [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([Anton + Popov](https://github.com/CurtizJ)) +- Disabled MariaDB authentication plugin, which depends on files outside of project. + [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([Yuriy + Baranov](https://github.com/yurriy)) +- Fix exception `Cannot convert column ... because it is constant but values of constants are different in source and result` which could rarely happen when functions `now()`, `today()`, + `yesterday()`, `randConstant()` are used. + [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([Nikolai + Kochetov](https://github.com/KochetovNicolai)) +- Fixed issue of using HTTP keep alive timeout instead of TCP keep alive timeout. + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([Vasily + Nemkov](https://github.com/Enmk)) +- Fixed a segmentation fault in groupBitmapOr (issue [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). + [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([Zhichang + Yu](https://github.com/yuzhichang)) +- For materialized views the commit for Kafka is called after all data were written. + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([Ivan](https://github.com/abyss7)) +- Fixed wrong `duration_ms` value in `system.part_log` table. It was ten times off. + [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([Vladimir + Chebotarev](https://github.com/excitoon)) +- A quick fix to resolve crash in LIVE VIEW table and re-enabling all LIVE VIEW tests. + [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) + ([vzakaznikov](https://github.com/vzakaznikov)) +- Serialize NULL values correctly in min/max indexes of MergeTree parts. + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander + Kuzmenkov](https://github.com/akuzm)) +- Don’t put virtual columns to .sql metadata when table is created as `CREATE TABLE AS`. + [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([Ivan](https://github.com/abyss7)) +- Fix segmentation fault in `ATTACH PART` query. + [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) + ([alesapin](https://github.com/alesapin)) +- Fix wrong result for some queries given by the optimization of empty IN subqueries and empty + INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([Nikolai + Kochetov](https://github.com/KochetovNicolai)) +- Fixing AddressSanitizer error in the LIVE VIEW getHeader() method. + [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) + ([vzakaznikov](https://github.com/vzakaznikov)) + +#### Improvement {#improvement-1} + +- Add a message in case of queue\_wait\_max\_ms wait takes place. + [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([Azat + Khuzhin](https://github.com/azat)) +- Made setting `s3_min_upload_part_size` table-level. + [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([Vladimir + Chebotarev](https://github.com/excitoon)) +- Check TTL in StorageFactory. [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) + ([sundyli](https://github.com/sundy-li)) +- Squash left-hand blocks in partial merge join (optimization). + [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([Artem + Zuikov](https://github.com/4ertus2)) +- Do not allow non-deterministic functions in mutations of Replicated table engines, because this + can introduce inconsistencies between replicas. + [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([Alexander + Kazakov](https://github.com/Akazz)) +- Disable memory tracker while converting exception stack trace to string. It can prevent the loss + of error messages of type `Memory limit exceeded` on server, which caused the `Attempt to read after eof` exception on client. [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) + ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Miscellaneous format improvements. Resolves + [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), + [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), + [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), + [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) + [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) + ([tavplubix](https://github.com/tavplubix)) +- ClickHouse ignores values on the right side of IN operator that are not convertible to the left + side type. Make it work properly for compound types – Array and Tuple. + [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([Alexander + Kuzmenkov](https://github.com/akuzm)) +- Support missing inequalities for ASOF JOIN. It’s possible to join less-or-equal variant and strict + greater and less variants for ASOF column in ON syntax. + [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([Artem + Zuikov](https://github.com/4ertus2)) +- Optimize partial merge join. [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) + ([Artem Zuikov](https://github.com/4ertus2)) +- Do not use more than 98K of memory in uniqCombined functions. + [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), + [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([Azat + Khuzhin](https://github.com/azat)) +- Flush parts of right-hand joining table on disk in PartialMergeJoin (if there is not enough + memory). Load data back when needed. [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) + ([Artem Zuikov](https://github.com/4ertus2)) + +#### Performance Improvement {#performance-improvement-1} + +- Speed up joinGet with const arguments by avoiding data duplication. + [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([Amos + Bird](https://github.com/amosbird)) +- Return early if the subquery is empty. + [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) +- Optimize parsing of SQL expression in Values. + [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) + ([tavplubix](https://github.com/tavplubix)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-1} + +- Disable some contribs for cross-compilation to Mac OS. + [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([Ivan](https://github.com/abyss7)) +- Add missing linking with PocoXML for clickhouse\_common\_io. + [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([Azat + Khuzhin](https://github.com/azat)) +- Accept multiple test filter arguments in clickhouse-test. + [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([Alexander + Kuzmenkov](https://github.com/akuzm)) +- Enable musl and jemalloc for ARM. [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) + ([Amos Bird](https://github.com/amosbird)) +- Added `--client-option` parameter to `clickhouse-test` to pass additional parameters to client. + [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([Nikolai + Kochetov](https://github.com/KochetovNicolai)) +- Preserve existing configs on rpm package upgrade. + [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) + ([filimonov](https://github.com/filimonov)) +- Fix errors detected by PVS. [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([Artem + Zuikov](https://github.com/4ertus2)) +- Fix build for Darwin. [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) + ([Ivan](https://github.com/abyss7)) +- glibc 2.29 compatibility. [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([Amos + Bird](https://github.com/amosbird)) +- Make sure dh\_clean does not touch potential source files. + [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([Amos + Bird](https://github.com/amosbird)) +- Attempt to avoid conflict when updating from altinity rpm - it has config file packaged separately + in clickhouse-server-common. [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) + ([filimonov](https://github.com/filimonov)) +- Optimize some header files for faster rebuilds. + [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), + [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([Alexander + Kuzmenkov](https://github.com/akuzm)) +- Add performance tests for Date and DateTime. [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([Vasily + Nemkov](https://github.com/Enmk)) +- Fix some tests that contained non-deterministic mutations. + [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([Alexander + Kazakov](https://github.com/Akazz)) +- Add build with MemorySanitizer to CI. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) + ([Alexander Kuzmenkov](https://github.com/akuzm)) +- Avoid use of uninitialized values in MetricsTransmitter. + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat + Khuzhin](https://github.com/azat)) +- Fix some issues in Fields found by MemorySanitizer. + [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), + [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([Alexander + Kuzmenkov](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) + ([Amos Bird](https://github.com/amosbird)) +- Fix undefined behavior in murmurhash32. [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([Amos + Bird](https://github.com/amosbird)) +- Fix undefined behavior in StoragesInfoStream. [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) + ([tavplubix](https://github.com/tavplubix)) +- Fixed constant expressions folding for external database engines (MySQL, ODBC, JDBC). In previous + versions it wasn’t working for multiple constant expressions and was not working at all for Date, + DateTime and UUID. This fixes [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) + ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixing ThreadSanitizer data race error in the LIVE VIEW when accessing no\_users\_thread variable. + [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) + ([vzakaznikov](https://github.com/vzakaznikov)) +- Get rid of malloc symbols in libcommon + [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), + [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([Amos + Bird](https://github.com/amosbird)) +- Add global flag ENABLE\_LIBRARIES for disabling all libraries. + [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) + ([proller](https://github.com/proller)) + +#### Code Cleanup {#code-cleanup} + +- Generalize configuration repository to prepare for DDL for Dictionaries. [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) + ([alesapin](https://github.com/alesapin)) +- Parser for dictionaries DDL without any semantic. + [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) + ([alesapin](https://github.com/alesapin)) +- Split ParserCreateQuery into different smaller parsers. + [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) + ([alesapin](https://github.com/alesapin)) +- Small refactoring and renaming near external dictionaries. + [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) + ([alesapin](https://github.com/alesapin)) +- Refactor some code to prepare for role-based access control. [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([Vitaly + Baranov](https://github.com/vitlibar)) +- Some improvements in DatabaseOrdinary code. + [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([Nikita + Vasilev](https://github.com/nikvas0)) +- Do not use iterators in find() and emplace() methods of hash tables. + [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([Alexander + Kuzmenkov](https://github.com/akuzm)) +- Fix getMultipleValuesFromConfig in case when parameter root is not empty. [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) + ([Mikhail Korotov](https://github.com/millb)) +- Remove some copy-paste (TemporaryFile and TemporaryFileStream) + [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([Artem + Zuikov](https://github.com/4ertus2)) +- Improved code readability a little bit (`MergeTreeData::getActiveContainingPart`). + [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([Vladimir + Chebotarev](https://github.com/excitoon)) +- Wait for all scheduled jobs, which are using local objects, if `ThreadPool::schedule(...)` throws + an exception. Rename `ThreadPool::schedule(...)` to `ThreadPool::scheduleOrThrowOnError(...)` and + fix comments to make obvious that it may throw. + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) + ([tavplubix](https://github.com/tavplubix)) + +## ClickHouse Release 19.15 {#clickhouse-release-19-15} + +### ClickHouse Release 19.15.4.10, 2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} + +#### Bug Fix {#bug-fix-3} + +- Added handling of SQL\_TINYINT and SQL\_BIGINT, and fix handling of SQL\_FLOAT data source types in ODBC Bridge. + [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) +- Allowed to have some parts on destination disk or volume in MOVE PARTITION. + [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fixed NULL-values in nullable columns through ODBC-bridge. + [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([Vasily Nemkov](https://github.com/Enmk)) +- Fixed INSERT into Distributed non local node with MATERIALIZED columns. + [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) +- Fixed function getMultipleValuesFromConfig. + [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([Mikhail Korotov](https://github.com/millb)) +- Fixed issue of using HTTP keep alive timeout instead of TCP keep alive timeout. + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([Vasily Nemkov](https://github.com/Enmk)) +- Wait for all jobs to finish on exception (fixes rare segfaults). + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([tavplubix](https://github.com/tavplubix)) +- Don’t push to MVs when inserting into Kafka table. + [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([Ivan](https://github.com/abyss7)) +- Disable memory tracker for exception stack. + [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed bad code in transforming query for external database. + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Avoid use of uninitialized values in MetricsTransmitter. + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat Khuzhin](https://github.com/azat)) +- Added example config with macros for tests ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.15.3.6, 2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} + +#### Bug Fix {#bug-fix-4} + +- Fixed bad\_variant in hashed dictionary. + ([alesapin](https://github.com/alesapin)) +- Fixed up bug with segmentation fault in ATTACH PART query. + ([alesapin](https://github.com/alesapin)) +- Fixed time calculation in `MergeTreeData`. + ([Vladimir Chebotarev](https://github.com/excitoon)) +- Commit to Kafka explicitly after the writing is finalized. + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([Ivan](https://github.com/abyss7)) +- Serialize NULL values correctly in min/max indexes of MergeTree parts. + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander Kuzmenkov](https://github.com/akuzm)) + +### ClickHouse Release 19.15.2.2, 2019-10-01 {#clickhouse-release-19-15-2-2-2019-10-01} + +#### New Feature {#new-feature-3} + +- Tiered storage: support to use multiple storage volumes for tables with MergeTree engine. It’s possible to store fresh data on SSD and automatically move old data to HDD. ([example](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([Igr](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([alesapin](https://github.com/alesapin)) +- Add table function `input` for reading incoming data in `INSERT SELECT` query. [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([palasonic1](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([Anton Popov](https://github.com/CurtizJ)) +- Add a `sparse_hashed` dictionary layout, that is functionally equivalent to the `hashed` layout, but is more memory efficient. It uses about twice as less memory at the cost of slower value retrieval. [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([Azat Khuzhin](https://github.com/azat)) +- Implement ability to define list of users for access to dictionaries. Only current connected database using. [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Add `LIMIT` option to `SHOW` query. [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([Philipp Malkovsky](https://github.com/malkfilipp)) +- Add `bitmapSubsetLimit(bitmap, range_start, limit)` function, that returns subset of the smallest `limit` values in set that is no smaller than `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([Zhichang Yu](https://github.com/yuzhichang)) +- Add `bitmapMin` and `bitmapMax` functions. [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([Zhichang Yu](https://github.com/yuzhichang)) +- Add function `repeat` related to [issue-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([flynn](https://github.com/ucasFL)) + +#### Experimental Feature {#experimental-feature-1} + +- Implement (in memory) Merge Join variant that does not change current pipeline. Result is partially sorted by merge key. Set `partial_merge_join = 1` to use this feature. The Merge Join is still in development. [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([Artem Zuikov](https://github.com/4ertus2)) +- Add `S3` engine and table function. It is still in development (no authentication support yet). [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([Vladimir Chebotarev](https://github.com/excitoon)) + +#### Improvement {#improvement-2} + +- Every message read from Kafka is inserted atomically. This resolves almost all known issues with Kafka engine. [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([Ivan](https://github.com/abyss7)) +- Improvements for failover of Distributed queries. Shorten recovery time, also it is now configurable and can be seen in `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([Vasily Nemkov](https://github.com/Enmk)) +- Support numeric values for Enums directly in `IN` section. \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([dimarub2000](https://github.com/dimarub2000)) +- Support (optional, disabled by default) redirects on URL storage. [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([maqroll](https://github.com/maqroll)) +- Add information message when client with an older version connects to a server. [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([Philipp Malkovsky](https://github.com/malkfilipp)) +- Remove maximum backoff sleep time limit for sending data in Distributed tables [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([Azat Khuzhin](https://github.com/azat)) +- Add ability to send profile events (counters) with cumulative values to graphite. It can be enabled under `` in server `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([Azat Khuzhin](https://github.com/azat)) +- Add automatically cast type `T` to `LowCardinality(T)` while inserting data in column of type `LowCardinality(T)` in Native format via HTTP. [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Add ability to use function `hex` without using `reinterpretAsString` for `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([Mikhail Korotov](https://github.com/millb)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-2} + +- Add gdb-index to clickhouse binary with debug info. It will speed up startup time of `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([alesapin](https://github.com/alesapin)) +- Speed up deb packaging with patched dpkg-deb which uses `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([alesapin](https://github.com/alesapin)) +- Set `enable_fuzzing = 1` to enable libfuzzer instrumentation of all the project code. [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([kyprizel](https://github.com/kyprizel)) +- Add split build smoke test in CI. [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([alesapin](https://github.com/alesapin)) +- Add build with MemorySanitizer to CI. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([Alexander Kuzmenkov](https://github.com/akuzm)) +- Replace `libsparsehash` with `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([Azat Khuzhin](https://github.com/azat)) + +#### Bug Fix {#bug-fix-5} + +- Fixed performance degradation of index analysis on complex keys on large tables. This fixes \#6924. [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix logical error causing segfaults when selecting from Kafka empty topic. [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([Ivan](https://github.com/abyss7)) +- Fix too early MySQL connection close in `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- Returned support for very old Linux kernels (fix [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix possible data loss in `insert select` query in case of empty block in input stream. \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix for function `АrrayEnumerateUniqRanked` with empty arrays in params [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) +- Fix complex queries with array joins and global subqueries. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([Ivan](https://github.com/abyss7)) +- Fix `Unknown identifier` error in ORDER BY and GROUP BY with multiple JOINs [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed `MSan` warning while executing function with `LowCardinality` argument. [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +#### Backward Incompatible Change {#backward-incompatible-change-2} + +- Changed serialization format of bitmap\* aggregate function states to improve performance. Serialized states of bitmap\* from previous versions cannot be read. [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([Zhichang Yu](https://github.com/yuzhichang)) + +## ClickHouse Release 19.14 {#clickhouse-release-19-14} + +### ClickHouse Release 19.14.7.15, 2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} + +#### Bug Fix {#bug-fix-6} + +- This release also contains all bug fixes from 19.11.12.69. +- Fixed compatibility for distributed queries between 19.14 and earlier versions. This fixes [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.14.6.12, 2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} + +#### Bug Fix {#bug-fix-7} + +- Fix for function `АrrayEnumerateUniqRanked` with empty arrays in params. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) +- Fixed subquery name in queries with `ARRAY JOIN` and `GLOBAL IN subquery` with alias. Use subquery alias for external table name if it is specified. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([Ivan](https://github.com/abyss7)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-3} + +- Fix [flapping](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) test `00715_fetch_merged_or_mutated_part_zookeeper` by rewriting it to a shell scripts because it needs to wait for mutations to apply. [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([Alexander Kazakov](https://github.com/Akazz)) +- Fixed UBSan and MemSan failure in function `groupUniqArray` with emtpy array argument. It was caused by placing of empty `PaddedPODArray` into hash table zero cell because constructor for zero cell value was not called. [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([Amos Bird](https://github.com/amosbird)) + +### ClickHouse Release 19.14.3.3, 2019-09-10 {#clickhouse-release-19-14-3-3-2019-09-10} + +#### New Feature {#new-feature-4} + +- `WITH FILL` modifier for `ORDER BY`. (continuation of [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([Anton Popov](https://github.com/CurtizJ)) +- `WITH TIES` modifier for `LIMIT`. (continuation of [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([Anton Popov](https://github.com/CurtizJ)) +- Parse unquoted `NULL` literal as NULL (if setting `format_csv_unquoted_null_literal_as_null=1`). Initialize null fields with default values if data type of this field is not nullable (if setting `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([tavplubix](https://github.com/tavplubix)) +- Support for wildcards in paths of table functions `file` and `hdfs`. If the path contains wildcards, the table will be readonly. Example of usage: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` and `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([Olga Khvostikova](https://github.com/stavrolia)) +- New `system.metric_log` table which stores values of `system.events` and `system.metrics` with specified time interval. [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Allow to write ClickHouse text logs to `system.text_log` table. [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Show private symbols in stack traces (this is done via parsing symbol tables of ELF files). Added information about file and line number in stack traces if debug info is present. Speedup symbol name lookup with indexing symbols present in program. Added new SQL functions for introspection: `demangle` and `addressToLine`. Renamed function `symbolizeAddress` to `addressToSymbol` for consistency. Function `addressToSymbol` will return mangled name for performance reasons and you have to apply `demangle`. Added setting `allow_introspection_functions` which is turned off by default. [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Table function `values` (the name is case-insensitive). It allows to read from `VALUES` list proposed in [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). Example: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) +- Added an ability to alter storage settings. Syntax: `ALTER TABLE MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([alesapin](https://github.com/alesapin)) +- Support for removing of detached parts. Syntax: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([tavplubix](https://github.com/tavplubix)) +- Table constraints. Allows to add constraint to table definition which will be checked at insert. [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([Gleb Novikov](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Suppport for cascaded materialized views. [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([Amos Bird](https://github.com/amosbird)) +- Turn on query profiler by default to sample every query execution thread once a second. [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Input format `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([akonyaev90](https://github.com/akonyaev90)) +- Added two new functions: `sigmoid` and `tanh` (that are useful for machine learning applications). [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Function `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` to check if given token is in haystack. Token is a maximal length substring between two non alphanumeric ASCII characters (or boundaries of haystack). Token must be a constant string. Supported by tokenbf\_v1 index specialization. [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([Vasily Nemkov](https://github.com/Enmk)) +- New function `neighbor(value, offset[, default_value])`. Allows to reach prev/next value within column in a block of data. [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([Alex Krash](https://github.com/alex-krash)) [6685365ab8c5b74f9650492c88a012596eb1b0c6](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341e2e4587a18065c2da1ca888c73389f48ce36c](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [Alexey Milovidov](https://github.com/alexey-milovidov) +- Created a function `currentUser()`, returning login of authorized user. Added alias `user()` for compatibility with MySQL. [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([Alex Krash](https://github.com/alex-krash)) +- New aggregate functions `quantilesExactInclusive` and `quantilesExactExclusive` which were proposed in [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([dimarub2000](https://github.com/dimarub2000)) +- Function `bitmapRange(bitmap, range_begin, range_end)` which returns new set with specified range (not include the `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([Zhichang Yu](https://github.com/yuzhichang)) +- Function `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` which creates array of precision-long strings of geohash-boxes covering provided area. [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([Vasily Nemkov](https://github.com/Enmk)) +- Implement support for INSERT query with `Kafka` tables. [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([Ivan](https://github.com/abyss7)) +- Added support for `_partition` and `_timestamp` virtual columns to Kafka engine. [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([Ivan](https://github.com/abyss7)) +- Possibility to remove sensitive data from `query_log`, server logs, process list with regexp-based rules. [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([filimonov](https://github.com/filimonov)) + +#### Experimental Feature {#experimental-feature-2} + +- Input and output data format `Template`. It allows to specify custom format string for input and output. [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([tavplubix](https://github.com/tavplubix)) +- Implementation of `LIVE VIEW` tables that were originally proposed in [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898), prepared in [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925), and then updated in [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). See [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) for detailed description. [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([vzakaznikov](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([vzakaznikov](https://github.com/vzakaznikov)) Note that `LIVE VIEW` feature may be removed in next versions. + +#### Bug Fix {#bug-fix-8} + +- This release also contains all bug fixes from 19.13 and 19.11. +- Fix segmentation fault when the table has skip indices and vertical merge happens. [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([alesapin](https://github.com/alesapin)) +- Fix per-column TTL with non-trivial column defaults. Previously in case of force TTL merge with `OPTIMIZE ... FINAL` query, expired values was replaced by type defaults instead of user-specified column defaults. [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([Anton Popov](https://github.com/CurtizJ)) +- Fix Kafka messages duplication problem on normal server restart. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([Ivan](https://github.com/abyss7)) +- Fixed infinite loop when reading Kafka messages. Do not pause/resume consumer on subscription at all - otherwise it may get paused indefinitely in some scenarios. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([Ivan](https://github.com/abyss7)) +- Fix `Key expression contains comparison between inconvertible types` exception in `bitmapContains` function. [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([dimarub2000](https://github.com/dimarub2000)) +- Fix segfault with enabled `optimize_skip_unused_shards` and missing sharding key. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([Anton Popov](https://github.com/CurtizJ)) +- Fixed wrong code in mutations that may lead to memory corruption. Fixed segfault with read of address `0x14c0` that may happed due to concurrent `DROP TABLE` and `SELECT` from `system.parts` or `system.parts_columns`. Fixed race condition in preparation of mutation queries. Fixed deadlock caused by `OPTIMIZE` of Replicated tables and concurrent modification operations like ALTERs. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Removed extra verbose logging in MySQL interface [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Return the ability to parse boolean settings from ‘true’ and ‘false’ in the configuration file. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([alesapin](https://github.com/alesapin)) +- Fix crash in `quantile` and `median` function over `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed possible incomplete result returned by `SELECT` query with `WHERE` condition on primary key contained conversion to Float type. It was caused by incorrect checking of monotonicity in `toFloat` function. [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) +- Check `max_expanded_ast_elements` setting for mutations. Clear mutations after `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([Winter Zhang](https://github.com/zhang2014)) +- Fix JOIN results for key columns when used with `join_use_nulls`. Attach Nulls instead of columns defaults. [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix for skip indices with vertical merge and alter. Fix for `Bad size of marks file` exception. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([alesapin](https://github.com/alesapin)) +- Fix rare crash in `ALTER MODIFY COLUMN` and vertical merge when one of merged/altered parts is empty (0 rows) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([alesapin](https://github.com/alesapin)) +- Fixed bug in conversion of `LowCardinality` types in `AggregateFunctionFactory`. This fixes [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix wrong behavior and possible segfaults in `topK` and `topKWeighted` aggregated functions. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([Anton Popov](https://github.com/CurtizJ)) +- Fixed unsafe code around `getIdentifier` function. [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed bug in MySQL wire protocol (is used while connecting to ClickHouse form MySQL client). Caused by heap buffer overflow in `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([Yuriy Baranov](https://github.com/yurriy)) +- Fixed memory leak in `bitmapSubsetInRange` function. [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([Zhichang Yu](https://github.com/yuzhichang)) +- Fix rare bug when mutation executed after granularity change. [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([alesapin](https://github.com/alesapin)) +- Allow protobuf message with all fields by default. [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([Vitaly Baranov](https://github.com/vitlibar)) +- Resolve a bug with `nullIf` function when we send a `NULL` argument on the second argument. [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Fix rare bug with wrong memory allocation/deallocation in complex key cache dictionaries with string fields which leads to infinite memory consumption (looks like memory leak). Bug reproduces when string size was a power of two starting from eight (8, 16, 32, etc). [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([alesapin](https://github.com/alesapin)) +- Fixed Gorilla encoding on small sequences which caused exception `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Vasily Nemkov](https://github.com/Enmk)) +- Allow to use not nullable types in JOINs with `join_use_nulls` enabled. [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([Artem Zuikov](https://github.com/4ertus2)) +- Disable `Poco::AbstractConfiguration` substitutions in query in `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Avoid deadlock in `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Using `arrayReduce` for constant arguments may lead to segfault. [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix inconsistent parts which can appear if replica was restored after `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- Fixed hang in `JSONExtractRaw` function. [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix bug with incorrect skip indices serialization and aggregation with adaptive granularity. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([alesapin](https://github.com/alesapin)) +- Fix `WITH ROLLUP` and `WITH CUBE` modifiers of `GROUP BY` with two-level aggregation. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([Anton Popov](https://github.com/CurtizJ)) +- Fix bug with writing secondary indices marks with adaptive granularity. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alesapin](https://github.com/alesapin)) +- Fix initialization order while server startup. Since `StorageMergeTree::background_task_handle` is initialized in `startup()` the `MergeTreeBlockOutputStream::write()` may try to use it before initialization. Just check if it is initialized. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([Ivan](https://github.com/abyss7)) +- Clearing the data buffer from the previous read operation that was completed with an error. [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([Nikolay](https://github.com/bopohaa)) +- Fix bug with enabling adaptive granularity when creating a new replica for Replicated\*MergeTree table. [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([alesapin](https://github.com/alesapin)) +- Fixed possible crash during server startup in case of exception happened in `libunwind` during exception at access to uninitialized `ThreadStatus` structure. [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +- Fix crash in `yandexConsistentHash` function. Found by fuzz test. [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed the possibility of hanging queries when server is overloaded and global thread pool becomes near full. This have higher chance to happen on clusters with large number of shards (hundreds), because distributed queries allocate a thread per connection to each shard. For example, this issue may reproduce if a cluster of 330 shards is processing 30 concurrent distributed queries. This issue affects all versions starting from 19.2. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed logic of `arrayEnumerateUniqRanked` function. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix segfault when decoding symbol table. [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([Amos Bird](https://github.com/amosbird)) +- Fixed irrelevant exception in cast of `LowCardinality(Nullable)` to not-Nullable column in case if it doesn’t contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Removed extra quoting of description in `system.settings` table. [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Avoid possible deadlock in `TRUNCATE` of Replicated table. [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix reading in order of sorting key. [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([Anton Popov](https://github.com/CurtizJ)) +- Fix `ALTER TABLE ... UPDATE` query for tables with `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) +- Fix bug opened by [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (since 19.4.0). Reproduces in queries to Distributed tables over MergeTree tables when we doesn’t query any columns (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([alesapin](https://github.com/alesapin)) +- Fixed overflow in integer division of signed type to unsigned type. The behaviour was exactly as in C or C++ language (integer promotion rules) that may be surprising. Please note that the overflow is still possible when dividing large signed number to large unsigned number or vice-versa (but that case is less usual). The issue existed in all server versions. [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Limit maximum sleep time for throttling when `max_execution_speed` or `max_execution_speed_bytes` is set. Fixed false errors like `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed issues about using `MATERIALIZED` columns and aliases in `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([Amos Bird](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix `FormatFactory` behaviour for input streams which are not implemented as processor. [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed typo. [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([Alex Ryndin](https://github.com/alexryndin)) +- Typo in the error message ( is -\> are ). [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([Denis Zhuravlev](https://github.com/den-crane)) +- Fixed error while parsing of columns list from string if type contained a comma (this issue was relevant for `File`, `URL`, `HDFS` storages) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) + +#### Security Fix {#security-fix} + +- This release also contains all bug security fixes from 19.13 and 19.11. +- Fixed the possibility of a fabricated query to cause server crash due to stack overflow in SQL parser. Fixed the possibility of stack overflow in Merge and Distributed tables, materialized views and conditions for row-level security that involve subqueries. [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Improvement {#improvement-3} + +- Correct implementation of ternary logic for `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([Alexander Kazakov](https://github.com/Akazz)) +- Now values and rows with expired TTL will be removed after `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` query. Added queries `SYSTEM STOP/START TTL MERGES` to disallow/allow assign merges with TTL and filter expired values in all merges. [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([Anton Popov](https://github.com/CurtizJ)) +- Possibility to change the location of ClickHouse history file for client using `CLICKHOUSE_HISTORY_FILE` env. [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([filimonov](https://github.com/filimonov)) +- Remove `dry_run` flag from `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Support `ASOF JOIN` with `ON` section. [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([Artem Zuikov](https://github.com/4ertus2)) +- Better support of skip indexes for mutations and replication. Support for `MATERIALIZE/CLEAR INDEX ... IN PARTITION` query. `UPDATE x = x` recalculates all indices that use column `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([Nikita Vasilev](https://github.com/nikvas0)) +- Allow to `ATTACH` live views (for example, at the server startup) regardless to `allow_experimental_live_view` setting. [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- For stack traces gathered by query profiler, do not include stack frames generated by the query profiler itself. [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Now table functions `values`, `file`, `url`, `hdfs` have support for ALIAS columns. [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Throw an exception if `config.d` file doesn’t have the corresponding root element as the config file. [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) +- Print extra info in exception message for `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([tavplubix](https://github.com/tavplubix)) +- When determining shards of a `Distributed` table to be covered by a read query (for `optimize_skip_unused_shards` = 1) ClickHouse now checks conditions from both `prewhere` and `where` clauses of select statement. [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([Alexander Kazakov](https://github.com/Akazz)) +- Enabled `SIMDJSON` for machines without AVX2 but with SSE 4.2 and PCLMUL instruction set. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- ClickHouse can work on filesystems without `O_DIRECT` support (such as ZFS and BtrFS) without additional tuning. [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Support push down predicate for final subquery. [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([TCeason](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Better `JOIN ON` keys extraction [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([Artem Zuikov](https://github.com/4ertus2)) +- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Optimize selecting of smallest column for `SELECT count()` query. [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([Amos Bird](https://github.com/amosbird)) +- Added `strict` parameter in `windowFunnel()`. When the `strict` is set, the `windowFunnel()` applies conditions only for the unique values. [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([achimbab](https://github.com/achimbab)) +- Safer interface of `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([avasiliev](https://github.com/avasiliev)) +- Options line size when executing with `--help` option now corresponds with terminal size. [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([dimarub2000](https://github.com/dimarub2000)) +- Disable “read in order” optimization for aggregation without keys. [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([Anton Popov](https://github.com/CurtizJ)) +- HTTP status code for `INCORRECT_DATA` and `TYPE_MISMATCH` error codes was changed from default `500 Internal Server Error` to `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([Alexander Rodin](https://github.com/a-rodin)) +- Move Join object from `ExpressionAction` into `AnalyzedJoin`. `ExpressionAnalyzer` and `ExpressionAction` do not know about `Join` class anymore. Its logic is hidden by `AnalyzedJoin` iface. [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed possible deadlock of distributed queries when one of shards is localhost but the query is sent via network connection. [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Changed semantic of multiple tables `RENAME` to avoid possible deadlocks. [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Rewritten MySQL compatibility server to prevent loading full packet payload in memory. Decreased memory consumption for each connection to approximately `2 * DBMS_DEFAULT_BUFFER_SIZE` (read/write buffers). [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([Yuriy Baranov](https://github.com/yurriy)) +- Move AST alias interpreting logic out of parser that doesn’t have to know anything about query semantics. [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([Artem Zuikov](https://github.com/4ertus2)) +- Slightly more safe parsing of `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `clickhouse-copier`: Allow use `where_condition` from config with `partition_key` alias in query for checking partition existence (Earlier it was used only in reading data queries). [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([proller](https://github.com/proller)) +- Added optional message argument in `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([Vdimir](https://github.com/Vdimir)) +- Server exception got while sending insertion data is now being processed in client as well. [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([dimarub2000](https://github.com/dimarub2000)) +- Added a metric `DistributedFilesToInsert` that shows the total number of files in filesystem that are selected to send to remote servers by Distributed tables. The number is summed across all shards. [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Move most of JOINs prepare logic from `ExpressionAction/ExpressionAnalyzer` to `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix TSan [warning](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([Vasily Nemkov](https://github.com/Enmk)) +- Better information messages about lack of Linux capabilities. Logging fatal errors with “fatal” level, that will make it easier to find in `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- When enable dumping temporary data to the disk to restrict memory usage during `GROUP BY`, `ORDER BY`, it didn’t check the free disk space. The fix add a new setting `min_free_disk_space`, when the free disk space it smaller then the threshold, the query will stop and throw `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([Weiqing Xu](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Removed recursive rwlock by thread. It makes no sense, because threads are reused between queries. `SELECT` query may acquire a lock in one thread, hold a lock from another thread and exit from first thread. In the same time, first thread can be reused by `DROP` query. This will lead to false “Attempt to acquire exclusive lock recursively” messages. [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Split `ExpressionAnalyzer.appendJoin()`. Prepare a place in `ExpressionAnalyzer` for `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([Artem Zuikov](https://github.com/4ertus2)) +- Added `mysql_native_password` authentication plugin to MySQL compatibility server. [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([Yuriy Baranov](https://github.com/yurriy)) +- Less number of `clock_gettime` calls; fixed ABI compatibility between debug/release in `Allocator` (insignificant issue). [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Move `collectUsedColumns` from `ExpressionAnalyzer` to `SyntaxAnalyzer`. `SyntaxAnalyzer` makes `required_source_columns` itself now. [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([Artem Zuikov](https://github.com/4ertus2)) +- Add setting `joined_subquery_requires_alias` to require aliases for subselects and table functions in `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([Artem Zuikov](https://github.com/4ertus2)) +- Extract `GetAggregatesVisitor` class from `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([Artem Zuikov](https://github.com/4ertus2)) +- `system.query_log`: change data type of `type` column to `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +- Static linking of `sha256_password` authentication plugin. [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([Yuriy Baranov](https://github.com/yurriy)) +- Avoid extra dependency for the setting `compile` to work. In previous versions, the user may get error like `cannot open crti.o`, `unable to find library -lc` etc. [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- More validation of the input that may come from malicious replica. [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Now `clickhouse-obfuscator` file is available in `clickhouse-client` package. In previous versions it was available as `clickhouse obfuscator` (with whitespace). [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([dimarub2000](https://github.com/dimarub2000)) +- Fixed deadlock when we have at least two queries that read at least two tables in different order and another query that performs DDL operation on one of tables. Fixed another very rare deadlock. [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added `os_thread_ids` column to `system.processes` and `system.query_log` for better debugging possibilities. [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- A workaround for PHP mysqlnd extension bugs which occur when `sha256_password` is used as a default authentication plugin (described in [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([Yuriy Baranov](https://github.com/yurriy)) +- Remove unneeded place with changed nullability columns. [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([Artem Zuikov](https://github.com/4ertus2)) +- Set default value of `queue_max_wait_ms` to zero, because current value (five seconds) makes no sense. There are rare circumstances when this settings has any use. Added settings `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` and `connection_pool_max_wait_ms` for disambiguation. [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Extract `SelectQueryExpressionAnalyzer` from `ExpressionAnalyzer`. Keep the last one for non-select queries. [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([Artem Zuikov](https://github.com/4ertus2)) +- Removed duplicating input and output formats. [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Allow user to override `poll_interval` and `idle_connection_timeout` settings on connection. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `MergeTree` now has an additional option `ttl_only_drop_parts` (disabled by default) to avoid partial pruning of parts, so that they dropped completely when all the rows in a part are expired. [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([Sergi Vladykin](https://github.com/svladykin)) +- Type checks for set index functions. Throw exception if function got a wrong type. This fixes fuzz test with UBSan. [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([Nikita Vasilev](https://github.com/nikvas0)) + +#### Performance Improvement {#performance-improvement-2} + +- Optimize queries with `ORDER BY expressions` clause, where `expressions` have coinciding prefix with sorting key in `MergeTree` tables. This optimization is controlled by `optimize_read_in_order` setting. [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([Anton Popov](https://github.com/CurtizJ)) +- Allow to use multiple threads during parts loading and removal. [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Implemented batch variant of updating aggregate function states. It may lead to performance benefits. [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Using `FastOps` library for functions `exp`, `log`, `sigmoid`, `tanh`. FastOps is a fast vector math library from Michael Parakhin (Yandex CTO). Improved performance of `exp` and `log` functions more than 6 times. The functions `exp` and `log` from `Float32` argument will return `Float32` (in previous versions they always return `Float64`). Now `exp(nan)` may return `inf`. The result of `exp` and `log` functions may be not the nearest machine representable number to the true answer. [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([alexey-milovidov](https://github.com/alexey-milovidov)) Using Danila Kutenin variant to make fastops working [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Disable consecutive key optimization for `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([akuzm](https://github.com/akuzm)) +- Improved performance of `simdjson` library by getting rid of dynamic allocation in `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([Vitaly Baranov](https://github.com/vitlibar)) +- Pre-fault pages when allocating memory with `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([akuzm](https://github.com/akuzm)) +- Fix performance bug in `Decimal` comparison. [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-4} + +- Remove Compiler (runtime template instantiation) because we’ve win over it’s performance. [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added performance test to show degradation of performance in gcc-9 in more isolated way. [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added table function `numbers_mt`, which is multithreaded version of `numbers`. Updated performance tests with hash functions. [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Comparison mode in `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([dimarub2000](https://github.com/dimarub2000)) +- Best effort for printing stack traces. Also added `SIGPROF` as a debugging signal to print stack trace of a running thread. [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Every function in its own file, part 10. [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Remove doubled const `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([filimonov](https://github.com/filimonov)) +- Formatting changes for `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([akuzm](https://github.com/akuzm)) +- Better subquery for join creation in `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([Artem Zuikov](https://github.com/4ertus2)) +- Remove a redundant condition (found by PVS Studio). [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([akuzm](https://github.com/akuzm)) +- Separate the hash table interface for `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([akuzm](https://github.com/akuzm)) +- Refactoring of settings. [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([alesapin](https://github.com/alesapin)) +- Add comments for `set` index functions. [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([Nikita Vasilev](https://github.com/nikvas0)) +- Increase OOM score in debug version on Linux. [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([akuzm](https://github.com/akuzm)) +- HDFS HA now work in debug build. [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([Weiqing Xu](https://github.com/weiqxu)) +- Added a test to `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add test for multiple materialized views for Kafka table. [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([Ivan](https://github.com/abyss7)) +- Make a better build scheme. [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([Ivan](https://github.com/abyss7)) +- Fixed `test_external_dictionaries` integration in case it was executed under non root user. [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- The bug reproduces when total size of written packets exceeds `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([Yuriy Baranov](https://github.com/yurriy)) +- Added a test for `RENAME` table race condition [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Avoid data race on Settings in `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add integration test for handling errors by a cache dictionary. [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([Vitaly Baranov](https://github.com/vitlibar)) +- Disable parsing of ELF object files on Mac OS, because it makes no sense. [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Attempt to make changelog generator better. [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Adding `-Wshadow` switch to the GCC. [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) +- Removed obsolete code for `mimalloc` support. [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `zlib-ng` determines x86 capabilities and saves this info to global variables. This is done in defalteInit call, which may be made by different threads simultaneously. To avoid multithreaded writes, do it on library startup. [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([akuzm](https://github.com/akuzm)) +- Regression test for a bug which in join which was fixed in [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([Bakhtiyor Ruziev](https://github.com/theruziev)) +- Fixed MSan report. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix flapping TTL test. [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([Anton Popov](https://github.com/CurtizJ)) +- Fixed false data race in `MergeTreeDataPart::is_frozen` field. [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed timeouts in fuzz test. In previous version, it managed to find false hangup in query `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added debug checks to `static_cast` of columns. [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Support for Oracle Linux in official RPM packages. [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Changed json perftests from `once` to `loop` type. [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- `odbc-bridge.cpp` defines `main()` so it should not be included in `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([Orivej Desh](https://github.com/orivej)) +- Test for crash in `FULL|RIGHT JOIN` with nulls in right table’s keys. [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([Artem Zuikov](https://github.com/4ertus2)) +- Added a test for the limit on expansion of aliases just in case. [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Switched from `boost::filesystem` to `std::filesystem` where appropriate. [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added RPM packages to website. [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add a test for fixed `Unknown identifier` exception in `IN` section. [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([Artem Zuikov](https://github.com/4ertus2)) +- Simplify `shared_ptr_helper` because people facing difficulties understanding it. [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added performance tests for fixed Gorilla and DoubleDelta codec. [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([Vasily Nemkov](https://github.com/Enmk)) +- Split the integration test `test_dictionaries` into 4 separate tests. [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix PVS-Studio warning in `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Allow to use `library` dictionary source with ASan. [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added option to generate changelog from a list of PRs. [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Lock the `TinyLog` storage when reading. [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([akuzm](https://github.com/akuzm)) +- Check for broken symlinks in CI. [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Increase timeout for “stack overflow” test because it may take a long time in debug build. [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added a check for double whitespaces. [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix `new/delete` memory tracking when build with sanitizers. Tracking is not clear. It only prevents memory limit exceptions in tests. [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([Artem Zuikov](https://github.com/4ertus2)) +- Enable back the check of undefined symbols while linking. [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([Ivan](https://github.com/abyss7)) +- Avoid rebuilding `hyperscan` every day. [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed UBSan report in `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Don’t allow to use query profiler with sanitizers because it is not compatible. [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add test for reloading a dictionary after fail by timer. [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix inconsistency in `PipelineExecutor::prepareProcessor` argument type. [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Added a test for bad URIs. [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added more checks to `CAST` function. This should get more information about segmentation fault in fuzzy test. [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Added `gcc-9` support to `docker/builder` container that builds image locally. [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([Gleb Novikov](https://github.com/NanoBjorn)) +- Test for primary key with `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([dimarub2000](https://github.com/dimarub2000)) +- Fixed tests affected by slow stack traces printing. [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add a test case for crash in `groupUniqArray` fixed in [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([akuzm](https://github.com/akuzm)) +- Fixed indices mutations tests. [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([Nikita Vasilev](https://github.com/nikvas0)) +- In performance test, do not read query log for queries we didn’t run. [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([akuzm](https://github.com/akuzm)) +- Materialized view now could be created with any low cardinality types regardless to the setting about suspicious low cardinality types. [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([Olga Khvostikova](https://github.com/stavrolia)) +- Updated tests for `send_logs_level` setting. [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix build under gcc-8.2. [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([Max Akhmedov](https://github.com/zlobober)) +- Fix build with internal libc++. [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([Ivan](https://github.com/abyss7)) +- Fix shared build with `rdkafka` library [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([Ivan](https://github.com/abyss7)) +- Fixes for Mac OS build (incomplete). [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([alex-zaitsev](https://github.com/alex-zaitsev)) +- Fix “splitted” build. [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Other build fixes: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([Amos Bird](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([vxider](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([Ivan](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([proller](https://github.com/proller)) + +#### Backward Incompatible Change {#backward-incompatible-change-3} + +- Removed rarely used table function `catBoostPool` and storage `CatBoostPool`. If you have used this table function, please write email to `clickhouse-feedback@yandex-team.com`. Note that CatBoost integration remains and will be supported. [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Disable `ANY RIGHT JOIN` and `ANY FULL JOIN` by default. Set `any_join_distinct_right_table_keys` setting to enable them. [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([Artem Zuikov](https://github.com/4ertus2)) + +## ClickHouse Release 19.13 {#clickhouse-release-19-13} + +### ClickHouse Release 19.13.6.51, 2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} + +#### Bug Fix {#bug-fix-9} + +- This release also contains all bug fixes from 19.11.12.69. + +### ClickHouse Release 19.13.5.44, 2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} + +#### Bug Fix {#bug-fix-10} + +- This release also contains all bug fixes from 19.14.6.12. +- Fixed possible inconsistent state of table while executing `DROP` query for replicated table while zookeeper is not accessible. [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +- Fix for data race in StorageMerge [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix bug introduced in query profiler which leads to endless recv from socket. [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([alesapin](https://github.com/alesapin)) +- Fix excessive CPU usage while executing `JSONExtractRaw` function over a boolean value. [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fixes the regression while pushing to materialized view. [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([Ivan](https://github.com/abyss7)) +- Table function `url` had the vulnerability allowed the attacker to inject arbitrary HTTP headers in the request. This issue was found by [Nikita Tikhomirov](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix useless `AST` check in Set index. [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([Nikita Vasilev](https://github.com/nikvas0)) +- Fixed parsing of `AggregateFunction` values embedded in query. [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([Zhichang Yu](https://github.com/yuzhichang)) +- Fixed wrong behaviour of `trim` functions family. [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.13.4.32, 2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} + +#### Bug Fix {#bug-fix-11} + +- This release also contains all bug security fixes from 19.11.9.52 and 19.11.10.54. +- Fixed data race in `system.parts` table and `ALTER` query. [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed mismatched header in streams happened in case of reading from empty distributed table with sample and prewhere. [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([Lixiang Qian](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed crash when using `IN` clause with a subquery with a tuple. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- Fix case with same column names in `GLOBAL JOIN ON` section. [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix crash when casting types to `Decimal` that do not support it. Throw exception instead. [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed crash in `extractAll()` function. [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([Artem Zuikov](https://github.com/4ertus2)) +- Query transformation for `MySQL`, `ODBC`, `JDBC` table functions now works properly for `SELECT WHERE` queries with multiple `AND` expressions. [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([dimarub2000](https://github.com/dimarub2000)) +- Added previous declaration checks for MySQL 8 integration. [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([Rafael David Tinoco](https://github.com/rafaeldtinoco)) + +#### Security Fix {#security-fix-1} + +- Fix two vulnerabilities in codecs in decompression phase (malicious user can fabricate compressed data that will lead to buffer overflow in decompression). [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([Artem Zuikov](https://github.com/4ertus2)) + +### ClickHouse Release 19.13.3.26, 2019-08-22 {#clickhouse-release-19-13-3-26-2019-08-22} + +#### Bug Fix {#bug-fix-12} + +- Fix `ALTER TABLE ... UPDATE` query for tables with `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) +- Fix NPE when using IN clause with a subquery with a tuple. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- Fixed an issue that if a stale replica becomes alive, it may still have data parts that were removed by DROP PARTITION. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- Fixed issue with parsing CSV [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) +- Fixed data race in system.parts table and ALTER query. This fixes [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed wrong code in mutations that may lead to memory corruption. Fixed segfault with read of address `0x14c0` that may happed due to concurrent `DROP TABLE` and `SELECT` from `system.parts` or `system.parts_columns`. Fixed race condition in preparation of mutation queries. Fixed deadlock caused by `OPTIMIZE` of Replicated tables and concurrent modification operations like ALTERs. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed possible data loss after `ALTER DELETE` query on table with skipping index. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([Nikita Vasilev](https://github.com/nikvas0)) + +#### Security Fix {#security-fix-2} + +- If the attacker has write access to ZooKeeper and is able to run custom server available from the network where ClickHouse run, it can create custom-built malicious server that will act as ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. Found by Eldar Zaitov, information security team at Yandex. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.13.2.19, 2019-08-14 {#clickhouse-release-19-13-2-19-2019-08-14} + +#### New Feature {#new-feature-5} + +- Sampling profiler on query level. [Example](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) +- Allow to specify a list of columns with `COLUMNS('regexp')` expression that works like a more sophisticated variant of `*` asterisk. [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([mfridental](https://github.com/mfridental)), ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `CREATE TABLE AS table_function()` is now possible [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([dimarub2000](https://github.com/dimarub2000)) +- Adam optimizer for stochastic gradient descent is used by default in `stochasticLinearRegression()` and `stochasticLogisticRegression()` aggregate functions, because it shows good quality without almost any tuning. [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([Quid37](https://github.com/Quid37)) +- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([Andy Yang](https://github.com/andyyzh)) +- `RENAME` queries now work with all storages. [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([Ivan](https://github.com/abyss7)) +- Now client receive logs from server with any desired level by setting `send_logs_level` regardless to the log level specified in server settings. [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) + +#### Backward Incompatible Change {#backward-incompatible-change-4} + +- The setting `input_format_defaults_for_omitted_fields` is enabled by default. Inserts in Distributed tables need this setting to be the same on cluster (you need to set it before rolling update). It enables calculation of complex default expressions for omitted fields in `JSONEachRow` and `CSV*` formats. It should be the expected behavior but may lead to negligible performance difference. [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([Artem Zuikov](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) + +#### Experimental Features {#experimental-features} + +- New query processing pipeline. Use `experimental_use_processors=1` option to enable it. Use for your own trouble. [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +#### Bug Fix {#bug-fix-13} + +- Kafka integration has been fixed in this version. +- Fixed `DoubleDelta` encoding of `Int64` for large `DoubleDelta` values, improved `DoubleDelta` encoding for random data for `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([Vasily Nemkov](https://github.com/Enmk)) +- Fixed overestimation of `max_rows_to_read` if the setting `merge_tree_uniform_read_distribution` is set to 0. [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Improvement {#improvement-4} + +- Throws an exception if `config.d` file doesn’t have the corresponding root element as the config file [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) + +#### Performance Improvement {#performance-improvement-3} + +- Optimize `count()`. Now it uses the smallest column (if possible). [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([Amos Bird](https://github.com/amosbird)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-5} + +- Report memory usage in performance tests. [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([akuzm](https://github.com/akuzm)) +- Fix build with external `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([Ivan](https://github.com/abyss7)) +- Fix shared build with `rdkafka` library [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([Ivan](https://github.com/abyss7)) + +## ClickHouse Release 19.11 {#clickhouse-release-19-11} + +### ClickHouse Release 19.11.13.74, 2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} + +#### Bug Fix {#bug-fix-14} + +- Fixed rare crash in `ALTER MODIFY COLUMN` and vertical merge when one of merged/altered parts is empty (0 rows). [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([alesapin](https://github.com/alesapin)) +- Manual update of `SIMDJSON`. This fixes possible flooding of stderr files with bogus json diagnostic messages. [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([Alexander Kazakov](https://github.com/Akazz)) +- Fixed bug with `mrk` file extension for mutations ([alesapin](https://github.com/alesapin)) + +### ClickHouse Release 19.11.12.69, 2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} + +#### Bug Fix {#bug-fix-15} + +- Fixed performance degradation of index analysis on complex keys on large tables. This fixes [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Avoid rare SIGSEGV while sending data in tables with Distributed engine (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([Azat Khuzhin](https://github.com/azat)) +- Fix `Unknown identifier` with multiple joins. This fixes [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) + +### ClickHouse Release 19.11.11.57, 2019-09-13 {#clickhouse-release-19-11-11-57-2019-09-13} + +- Fix logical error causing segfaults when selecting from Kafka empty topic. [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([Ivan](https://github.com/abyss7)) +- Fix for function `АrrayEnumerateUniqRanked` with empty arrays in params. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) + +### ClickHouse Release 19.11.10.54, 2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} + +#### Bug Fix {#bug-fix-16} + +- Do store offsets for Kafka messages manually to be able to commit them all at once for all partitions. Fixes potential duplication in “one consumer - many partitions” scenario. [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([Ivan](https://github.com/abyss7)) + +### ClickHouse Release 19.11.9.52, 2019-09-6 {#clickhouse-release-19-11-9-52-2019-09-6} + +- Improve error handling in cache dictionaries. [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fixed bug in function `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([proller](https://github.com/proller)) +- Fix `JSONExtract` function while extracting a `Tuple` from JSON. [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fixed possible data loss after `ALTER DELETE` query on table with skipping index. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([Nikita Vasilev](https://github.com/nikvas0)) +- Fixed performance test. [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Parquet: Fix reading boolean columns. [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed wrong behaviour of `nullIf` function for constant arguments. [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([Guillaume Tassery](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix Kafka messages duplication problem on normal server restart. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([Ivan](https://github.com/abyss7)) +- Fixed an issue when long `ALTER UPDATE` or `ALTER DELETE` may prevent regular merges to run. Prevent mutations from executing if there is no enough free threads available. [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([tavplubix](https://github.com/tavplubix)) +- Fixed error with processing “timezone” in server configuration file. [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix kafka tests. [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([Ivan](https://github.com/abyss7)) + +#### Security Fix {#security-fix-3} + +- If the attacker has write access to ZooKeeper and is able to run custom server available from the network where ClickHouse runs, it can create custom-built malicious server that will act as ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. Found by Eldar Zaitov, information security team at Yandex. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.11.8.46, 2019-08-22 {#clickhouse-release-19-11-8-46-2019-08-22} + +#### Bug Fix {#bug-fix-17} + +- Fix `ALTER TABLE ... UPDATE` query for tables with `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) +- Fix NPE when using IN clause with a subquery with a tuple. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- Fixed an issue that if a stale replica becomes alive, it may still have data parts that were removed by DROP PARTITION. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- Fixed issue with parsing CSV [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) +- Fixed data race in system.parts table and ALTER query. This fixes [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed wrong code in mutations that may lead to memory corruption. Fixed segfault with read of address `0x14c0` that may happed due to concurrent `DROP TABLE` and `SELECT` from `system.parts` or `system.parts_columns`. Fixed race condition in preparation of mutation queries. Fixed deadlock caused by `OPTIMIZE` of Replicated tables and concurrent modification operations like ALTERs. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.11.7.40, 2019-08-14 {#clickhouse-release-19-11-7-40-2019-08-14} + +#### Bug Fix {#bug-fix-18} + +- Kafka integration has been fixed in this version. +- Fix segfault when using `arrayReduce` for constant arguments. [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed `toFloat()` monotonicity. [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) +- Fix segfault with enabled `optimize_skip_unused_shards` and missing sharding key. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([CurtizJ](https://github.com/CurtizJ)) +- Fixed logic of `arrayEnumerateUniqRanked` function. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Removed extra verbose logging from MySQL handler. [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix wrong behavior and possible segfaults in `topK` and `topKWeighted` aggregated functions. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([CurtizJ](https://github.com/CurtizJ)) +- Do not expose virtual columns in `system.columns` table. This is required for backward compatibility. [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix bug with memory allocation for string fields in complex key cache dictionary. [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([alesapin](https://github.com/alesapin)) +- Fix bug with enabling adaptive granularity when creating new replica for `Replicated*MergeTree` table. [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([alesapin](https://github.com/alesapin)) +- Fix infinite loop when reading Kafka messages. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([abyss7](https://github.com/abyss7)) +- Fixed the possibility of a fabricated query to cause server crash due to stack overflow in SQL parser and possibility of stack overflow in `Merge` and `Distributed` tables [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed Gorilla encoding error on small sequences. [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Enmk](https://github.com/Enmk)) + +#### Improvement {#improvement-5} + +- Allow user to override `poll_interval` and `idle_connection_timeout` settings on connection. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.11.5.28, 2019-08-05 {#clickhouse-release-19-11-5-28-2019-08-05} + +#### Bug Fix {#bug-fix-19} + +- Fixed the possibility of hanging queries when server is overloaded. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix FPE in yandexConsistentHash function. This fixes [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed bug in conversion of `LowCardinality` types in `AggregateFunctionFactory`. This fixes [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix parsing of `bool` settings from `true` and `false` strings in configuration files. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([alesapin](https://github.com/alesapin)) +- Fix rare bug with incompatible stream headers in queries to `Distributed` table over `MergeTree` table when part of `WHERE` moves to `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([alesapin](https://github.com/alesapin)) +- Fixed overflow in integer division of signed type to unsigned type. This fixes [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Backward Incompatible Change {#backward-incompatible-change-5} + +- `Kafka` still broken. + +### ClickHouse Release 19.11.4.24, 2019-08-01 {#clickhouse-release-19-11-4-24-2019-08-01} + +#### Bug Fix {#bug-fix-20} + +- Fix bug with writing secondary indices marks with adaptive granularity. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alesapin](https://github.com/alesapin)) +- Fix `WITH ROLLUP` and `WITH CUBE` modifiers of `GROUP BY` with two-level aggregation. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([Anton Popov](https://github.com/CurtizJ)) +- Fixed hang in `JSONExtractRaw` function. Fixed [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix segfault in ExternalLoader::reloadOutdated(). [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fixed the case when server may close listening sockets but not shutdown and continue serving remaining queries. You may end up with two running clickhouse-server processes. Sometimes, the server may return an error `bad_function_call` for remaining queries. [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed useless and incorrect condition on update field for initial loading of external dictionaries via ODBC, MySQL, ClickHouse and HTTP. This fixes [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed irrelevant exception in cast of `LowCardinality(Nullable)` to not-Nullable column in case if it doesn’t contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix non-deterministic result of “uniq” aggregate function in extreme rare cases. The bug was present in all ClickHouse versions. [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Segfault when we set a little bit too high CIDR on the function `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Fixed small memory leak when server throw many exceptions from many different contexts. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix the situation when consumer got paused before subscription and not resumed afterwards. [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([Ivan](https://github.com/abyss7)) Note that Kafka is broken in this version. +- Clearing the Kafka data buffer from the previous read operation that was completed with an error [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([Nikolay](https://github.com/bopohaa)) Note that Kafka is broken in this version. +- Since `StorageMergeTree::background_task_handle` is initialized in `startup()` the `MergeTreeBlockOutputStream::write()` may try to use it before initialization. Just check if it is initialized. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([Ivan](https://github.com/abyss7)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-6} + +- Added official `rpm` packages. [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([proller](https://github.com/proller)) ([alesapin](https://github.com/alesapin)) +- Add an ability to build `.rpm` and `.tgz` packages with `packager` script. [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([alesapin](https://github.com/alesapin)) +- Fixes for “Arcadia” build system. [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([proller](https://github.com/proller)) + +#### Backward Incompatible Change {#backward-incompatible-change-6} + +- `Kafka` is broken in this version. + +### ClickHouse Release 19.11.3.11, 2019-07-18 {#clickhouse-release-19-11-3-11-2019-07-18} + +#### New Feature {#new-feature-6} + +- Added support for prepared statements. [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([Alexander](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `DoubleDelta` and `Gorilla` column codecs [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([Vasily Nemkov](https://github.com/Enmk)) +- Added `os_thread_priority` setting that allows to control the “nice” value of query processing threads that is used by OS to adjust dynamic scheduling priority. It requires `CAP_SYS_NICE` capabilities to work. This implements [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Implement `_topic`, `_offset`, `_key` columns for Kafka engine [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([Ivan](https://github.com/abyss7)) Note that Kafka is broken in this version. +- Add aggregate function combinator `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([hcz](https://github.com/hczhcz)) +- Aggregate functions `groupArrayMovingSum(win_size)(x)` and `groupArrayMovingAvg(win_size)(x)`, which calculate moving sum/avg with or without window-size limitation. [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([inv2004](https://github.com/inv2004)) +- Add synonim `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([hcz](https://github.com/hczhcz)) +- Intergate H3 function `geoToH3` from Uber. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen Ivan](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Bug Fix {#bug-fix-21} + +- Implement DNS cache with asynchronous update. Separate thread resolves all hosts and updates DNS cache with period (setting `dns_cache_update_period`). It should help, when ip of hosts changes frequently. [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([Anton Popov](https://github.com/CurtizJ)) +- Fix segfault in `Delta` codec which affects columns with values less than 32 bits size. The bug led to random memory corruption. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([alesapin](https://github.com/alesapin)) +- Fix segfault in TTL merge with non-physical columns in block. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([Anton Popov](https://github.com/CurtizJ)) +- Fix rare bug in checking of part with `LowCardinality` column. Previously `checkDataPart` always fails for part with `LowCardinality` column. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([alesapin](https://github.com/alesapin)) +- Avoid hanging connections when server thread pool is full. It is important for connections from `remote` table function or connections to a shard without replicas when there is long connection timeout. This fixes [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Support for constant arguments to `evalMLModel` function. This fixes [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed the issue when ClickHouse determines default time zone as `UCT` instead of `UTC`. This fixes [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed buffer underflow in `visitParamExtractRaw`. This fixes [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Now distributed `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` queries will be executed directly on leader replica. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([alesapin](https://github.com/alesapin)) +- Fix `coalesce` for `ColumnConst` with `ColumnNullable` + related changes. [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix the `ReadBufferFromKafkaConsumer` so that it keeps reading new messages after `commit()` even if it was stalled before [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([Ivan](https://github.com/abyss7)) +- Fix `FULL` and `RIGHT` JOIN results when joining on `Nullable` keys in right table. [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([Artem Zuikov](https://github.com/4ertus2)) +- Possible fix of infinite sleeping of low-priority queries. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix race condition, which cause that some queries may not appear in query\_log after `SYSTEM FLUSH LOGS` query. [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([Anton Popov](https://github.com/CurtizJ)) +- Fixed `heap-use-after-free` ASan warning in ClusterCopier caused by watch which try to use already removed copier object. [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed wrong `StringRef` pointer returned by some implementations of `IColumn::deserializeAndInsertFromArena`. This bug affected only unit-tests. [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Prevent source and intermediate array join columns of masking same name columns. [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix insert and select query to MySQL engine with MySQL style identifier quoting. [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([Winter Zhang](https://github.com/zhang2014)) +- Now `CHECK TABLE` query can work with MergeTree engine family. It returns check status and message if any for each part (or file in case of simplier engines). Also, fix bug in fetch of a broken part. [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([alesapin](https://github.com/alesapin)) +- Fix SPLIT\_SHARED\_LIBRARIES runtime [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([Danila Kutenin](https://github.com/danlark1)) +- Fixed time zone initialization when `/etc/localtime` is a relative symlink like `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- clickhouse-copier: Fix use-after free on shutdown [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([proller](https://github.com/proller)) +- Updated `simdjson`. Fixed the issue that some invalid JSONs with zero bytes successfully parse. [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix shutdown of SystemLogs [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([Anton Popov](https://github.com/CurtizJ)) +- Fix hanging when condition in invalidate\_query depends on a dictionary. [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([Vitaly Baranov](https://github.com/vitlibar)) + +#### Improvement {#improvement-6} + +- Allow unresolvable addresses in cluster configuration. They will be considered unavailable and tried to resolve at every connection attempt. This is especially useful for Kubernetes. This fixes [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Close idle TCP connections (with one hour timeout by default). This is especially important for large clusters with multiple distributed tables on every server, because every server can possibly keep a connection pool to every other server, and after peak query concurrency, connections will stall. This fixes [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Better quality of `topK` function. Changed the SavingSpace set behavior to remove the last element if the new element have a bigger weight. [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([Guillaume Tassery](https://github.com/YiuRULE)) +- URL functions to work with domains now can work for incomplete URLs without scheme [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([alesapin](https://github.com/alesapin)) +- Checksums added to the `system.parts_columns` table. [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) +- Added `Enum` data type as a synonim for `Enum8` or `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([dimarub2000](https://github.com/dimarub2000)) +- Full bit transpose variant for `T64` codec. Could lead to better compression with `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([Artem Zuikov](https://github.com/4ertus2)) +- Condition on `startsWith` function now can uses primary key. This fixes [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) and [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([dimarub2000](https://github.com/dimarub2000)) +- Allow to use `clickhouse-copier` with cross-replication cluster topology by permitting empty database name. [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([nvartolomei](https://github.com/nvartolomei)) +- Use `UTC` as default timezone on a system without `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` was printed and server or client refused to start. [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Returned back support for floating point argument in function `quantileTiming` for backward compatibility. [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Show which table is missing column in error messages. [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([Ivan](https://github.com/abyss7)) +- Disallow run query with same query\_id by various users [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([proller](https://github.com/proller)) +- More robust code for sending metrics to Graphite. It will work even during long multiple `RENAME TABLE` operation. [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- More informative error messages will be displayed when ThreadPool cannot schedule a task for execution. This fixes [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Inverting ngramSearch to be more intuitive [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([Danila Kutenin](https://github.com/danlark1)) +- Add user parsing in HDFS engine builder [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([akonyaev90](https://github.com/akonyaev90)) +- Update default value of `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([Artem Konovalov](https://github.com/izebit)) +- Added a notion of obsolete settings. The obsolete setting `allow_experimental_low_cardinality_type` can be used with no effect. [0f15c01c6802f7ce1a1494c12c846be8c98944cd](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [Alexey Milovidov](https://github.com/alexey-milovidov) + +#### Performance Improvement {#performance-improvement-4} + +- Increase number of streams to SELECT from Merge table for more uniform distribution of threads. Added setting `max_streams_multiplier_for_merge_tables`. This fixes [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-7} + +- Add a backward compatibility test for client-server interaction with different versions of clickhouse. [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([alesapin](https://github.com/alesapin)) +- Test coverage information in every commit and pull request. [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([alesapin](https://github.com/alesapin)) +- Cooperate with address sanitizer to support our custom allocators (`Arena` and `ArenaWithFreeLists`) for better debugging of “use-after-free” errors. [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([akuzm](https://github.com/akuzm)) +- Switch to [LLVM libunwind implementation](https://github.com/llvm-mirror/libunwind) for C++ exception handling and for stack traces printing [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([Nikita Lapkov](https://github.com/laplab)) +- Add two more warnings from -Weverything [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Allow to build ClickHouse with Memory Sanitizer. [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed ubsan report about `bitTest` function in fuzz test. [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Docker: added possibility to init a ClickHouse instance which requires authentication. [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([Korviakov Andrey](https://github.com/shurshun)) +- Update librdkafka to version 1.1.0 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([Ivan](https://github.com/abyss7)) +- Add global timeout for integration tests and disable some of them in tests code. [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([alesapin](https://github.com/alesapin)) +- Fix some ThreadSanitizer failures. [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([akuzm](https://github.com/akuzm)) +- The `--no-undefined` option forces the linker to check all external names for existence while linking. It’s very useful to track real dependencies between libraries in the split build mode. [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([Ivan](https://github.com/abyss7)) +- Added performance test for [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed compatibility with gcc-7. [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added support for gcc-9. This fixes [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed error when libunwind can be linked incorrectly. [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed a few warnings found by PVS-Studio. [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added initial support for `clang-tidy` static analyzer. [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Convert BSD/Linux endian macros( ‘be64toh’ and ‘htobe64’) to the Mac OS X equivalents [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([Fu Chen](https://github.com/fredchenbj)) +- Improved integration tests guide. [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Fixing build at macosx + gcc9 [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([filimonov](https://github.com/filimonov)) +- Fix a hard-to-spot typo: aggreAGte -\> aggregate. [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([akuzm](https://github.com/akuzm)) +- Fix freebsd build [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([proller](https://github.com/proller)) +- Add link to experimental YouTube channel to website [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([Ivan Blinkov](https://github.com/blinkov)) +- CMake: add option for coverage flags: WITH\_COVERAGE [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([proller](https://github.com/proller)) +- Fix initial size of some inline PODArray’s. [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([akuzm](https://github.com/akuzm)) +- clickhouse-server.postinst: fix os detection for centos 6 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([proller](https://github.com/proller)) +- Added Arch linux package generation. [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([Vladimir Chebotarev](https://github.com/excitoon)) +- Split Common/config.h by libs (dbms) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([proller](https://github.com/proller)) +- Fixes for “Arcadia” build platform [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([proller](https://github.com/proller)) +- Fixes for unconventional build (gcc9, no submodules) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([proller](https://github.com/proller)) +- Require explicit type in unalignedStore because it was proven to be bug-prone [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([akuzm](https://github.com/akuzm)) +- Fixes MacOS build [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([filimonov](https://github.com/filimonov)) +- Performance test concerning the new JIT feature with bigger dataset, as requested here [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Run stateful tests in stress test [12693e568722f11e19859742f56428455501fd2a](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([alesapin](https://github.com/alesapin)) + +#### Backward Incompatible Change {#backward-incompatible-change-7} + +- `Kafka` is broken in this version. +- Enable `adaptive_index_granularity` = 10MB by default for new `MergeTree` tables. If you created new MergeTree tables on version 19.11+, downgrade to versions prior to 19.6 will be impossible. [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([alesapin](https://github.com/alesapin)) +- Removed obsolete undocumented embedded dictionaries that were used by Yandex.Metrica. The functions `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` are no longer available. If you are using these functions, write email to clickhouse-feedback@yandex-team.com. Note: at the last moment we decided to keep these functions for a while. [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +## ClickHouse Release 19.10 {#clickhouse-release-19-10} + +### ClickHouse Release 19.10.1.5, 2019-07-12 {#clickhouse-release-19-10-1-5-2019-07-12} + +#### New Feature {#new-feature-7} + +- Add new column codec: `T64`. Made for (U)IntX/EnumX/Data(Time)/DecimalX columns. It should be good for columns with constant or small range values. Codec itself allows enlarge or shrink data type without re-compression. [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([Artem Zuikov](https://github.com/4ertus2)) +- Add database engine `MySQL` that allow to view all the tables in remote MySQL server [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([Winter Zhang](https://github.com/zhang2014)) +- `bitmapContains` implementation. It’s 2x faster than `bitmapHasAny` if the second bitmap contains one element. [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([Zhichang Yu](https://github.com/yuzhichang)) +- Support for `crc32` function (with behaviour exactly as in MySQL or PHP). Do not use it if you need a hash function. [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen Ivan](https://github.com/BHYCHIK)) +- Implemented `SYSTEM START/STOP DISTRIBUTED SENDS` queries to control asynchronous inserts into `Distributed` tables. [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([Winter Zhang](https://github.com/zhang2014)) + +#### Bug Fix {#bug-fix-22} + +- Ignore query execution limits and max parts size for merge limits while executing mutations. [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([Anton Popov](https://github.com/CurtizJ)) +- Fix bug which may lead to deduplication of normal blocks (extremely rare) and insertion of duplicate blocks (more often). [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([alesapin](https://github.com/alesapin)) +- Fix of function `arrayEnumerateUniqRanked` for arguments with empty arrays [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([proller](https://github.com/proller)) +- Don’t subscribe to Kafka topics without intent to poll any messages. [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([Ivan](https://github.com/abyss7)) +- Make setting `join_use_nulls` get no effect for types that cannot be inside Nullable [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([Olga Khvostikova](https://github.com/stavrolia)) +- Fixed `Incorrect size of index granularity` errors [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([coraxster](https://github.com/coraxster)) +- Fix Float to Decimal convert overflow [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([coraxster](https://github.com/coraxster)) +- Flush buffer when `WriteBufferFromHDFS`’s destructor is called. This fixes writing into `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([Xindong Peng](https://github.com/eejoin)) + +#### Improvement {#improvement-7} + +- Treat empty cells in `CSV` as default values when the setting `input_format_defaults_for_omitted_fields` is enabled. [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) +- Non-blocking loading of external dictionaries. [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([Vitaly Baranov](https://github.com/vitlibar)) +- Network timeouts can be dynamically changed for already established connections according to the settings. [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([Konstantin Podshumok](https://github.com/podshumok)) +- Using “public\_suffix\_list” for functions `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. It’s using a perfect hash table generated by `gperf` with a list generated from the file: https://publicsuffix.org/list/public\_suffix\_list.dat. (for example, now we recognize the domain `ac.uk` as non-significant). [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Adopted `IPv6` data type in system tables; unified client info columns in `system.processes` and `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Using sessions for connections with MySQL compatibility protocol. \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([Yuriy Baranov](https://github.com/yurriy)) +- Support more `ALTER` queries `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([sundyli](https://github.com/sundy-li)) +- Support `` section in `clickhouse-local` config file. [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([proller](https://github.com/proller)) +- Allow run query with `remote` table function in `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([proller](https://github.com/proller)) + +#### Performance Improvement {#performance-improvement-5} + +- Add the possibility to write the final mark at the end of MergeTree columns. It allows to avoid useless reads for keys that are out of table data range. It is enabled only if adaptive index granularity is in use. [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([alesapin](https://github.com/alesapin)) +- Improved performance of MergeTree tables on very slow filesystems by reducing number of `stat` syscalls. [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed performance degradation in reading from MergeTree tables that was introduced in version 19.6. Fixes \#5631. [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-8} + +- Implemented `TestKeeper` as an implementation of ZooKeeper interface used for testing [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([alexey-milovidov](https://github.com/alexey-milovidov)) ([levushkin aleksej](https://github.com/alexey-milovidov)) +- From now on `.sql` tests can be run isolated by server, in parallel, with random database. It allows to run them faster, add new tests with custom server configurations, and be sure that different tests doesn’t affect each other. [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([Ivan](https://github.com/abyss7)) +- Remove `` and `` from performance tests [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([Olga Khvostikova](https://github.com/stavrolia)) +- Fixed “select\_format” performance test for `Pretty` formats [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +## ClickHouse Release 19.9 {#clickhouse-release-19-9} + +### ClickHouse Release 19.9.3.31, 2019-07-05 {#clickhouse-release-19-9-3-31-2019-07-05} + +#### Bug Fix {#bug-fix-23} + +- Fix segfault in Delta codec which affects columns with values less than 32 bits size. The bug led to random memory corruption. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([alesapin](https://github.com/alesapin)) +- Fix rare bug in checking of part with LowCardinality column. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([alesapin](https://github.com/alesapin)) +- Fix segfault in TTL merge with non-physical columns in block. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([Anton Popov](https://github.com/CurtizJ)) +- Fix potential infinite sleeping of low-priority queries. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix how ClickHouse determines default time zone as UCT instead of UTC. [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix bug about executing distributed DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER queries on follower replica before leader replica. Now they will be executed directly on leader replica. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([alesapin](https://github.com/alesapin)) +- Fix race condition, which cause that some queries may not appear in query\_log instantly after SYSTEM FLUSH LOGS query. [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([Anton Popov](https://github.com/CurtizJ)) +- Added missing support for constant arguments to `evalMLModel` function. [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.9.2.4, 2019-06-24 {#clickhouse-release-19-9-2-4-2019-06-24} + +#### New Feature {#new-feature-8} + +- Print information about frozen parts in `system.parts` table. [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([proller](https://github.com/proller)) +- Ask client password on clickhouse-client start on tty if not set in arguments [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([proller](https://github.com/proller)) +- Implement `dictGet` and `dictGetOrDefault` functions for Decimal types. [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Improvement {#improvement-8} + +- Debian init: Add service stop timeout [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([proller](https://github.com/proller)) +- Add setting forbidden by default to create table with suspicious types for LowCardinality [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([Olga Khvostikova](https://github.com/stavrolia)) +- Regression functions return model weights when not used as State in function `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([Quid37](https://github.com/Quid37)) +- Rename and improve regression methods. [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([Quid37](https://github.com/Quid37)) +- Clearer interfaces of string searchers. [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([Danila Kutenin](https://github.com/danlark1)) + +#### Bug Fix {#bug-fix-24} + +- Fix potential data loss in Kafka [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([Ivan](https://github.com/abyss7)) +- Fix potential infinite loop in `PrettySpace` format when called with zero columns [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([Olga Khvostikova](https://github.com/stavrolia)) +- Fixed UInt32 overflow bug in linear models. Allow eval ML model for non-const model argument. [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- `ALTER TABLE ... DROP INDEX IF EXISTS ...` should not raise an exception if provided index does not exist [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([Gleb Novikov](https://github.com/NanoBjorn)) +- Fix segfault with `bitmapHasAny` in scalar subquery [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) +- Fixed error when replication connection pool doesn’t retry to resolve host, even when DNS cache was dropped. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([alesapin](https://github.com/alesapin)) +- Fixed `ALTER ... MODIFY TTL` on ReplicatedMergeTree. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([Anton Popov](https://github.com/CurtizJ)) +- Fix INSERT into Distributed table with MATERIALIZED column [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) +- Fix bad alloc when truncate Join storage [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([TCeason](https://github.com/TCeason)) +- In recent versions of package tzdata some of files are symlinks now. The current mechanism for detecting default timezone gets broken and gives wrong names for some timezones. Now at least we force the timezone name to the contents of TZ if provided. [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([Ivan](https://github.com/abyss7)) +- Fix some extremely rare cases with MultiVolnitsky searcher when the constant needles in sum are at least 16KB long. The algorithm missed or overwrote the previous results which can lead to the incorrect result of `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([Danila Kutenin](https://github.com/danlark1)) +- Fix the issue when settings for ExternalData requests couldn’t use ClickHouse settings. Also, for now, settings `date_time_input_format` and `low_cardinality_allow_in_native_format` cannot be used because of the ambiguity of names (in external data it can be interpreted as table format and in the query it can be a setting). [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila Kutenin](https://github.com/danlark1)) +- Fix bug when parts were removed only from FS without dropping them from Zookeeper. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([alesapin](https://github.com/alesapin)) +- Remove debug logging from MySQL protocol [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Skip ZNONODE during DDL query processing [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) +- Fix mix `UNION ALL` result column type. There were cases with inconsistent data and column types of resulting columns. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) +- Throw an exception on wrong integers in `dictGetT` functions instead of crash. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix wrong element\_count and load\_factor for hashed dictionary in `system.dictionaries` table. [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-9} + +- Fixed build without `Brotli` HTTP compression support (`ENABLE_BROTLI=OFF` cmake variable). [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([Anton Yuzhaninov](https://github.com/citrin)) +- Include roaring.h as roaring/roaring.h [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([Orivej Desh](https://github.com/orivej)) +- Fix gcc9 warnings in hyperscan (\#line directive is evil!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([Danila Kutenin](https://github.com/danlark1)) +- Fix all warnings when compiling with gcc-9. Fix some contrib issues. Fix gcc9 ICE and submit it to bugzilla. [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([Danila Kutenin](https://github.com/danlark1)) +- Fixed linking with lld [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Remove unused specializations in dictionaries [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([Artem Zuikov](https://github.com/4ertus2)) +- Improvement performance tests for formatting and parsing tables for different types of files [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([Olga Khvostikova](https://github.com/stavrolia)) +- Fixes for parallel test run [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([proller](https://github.com/proller)) +- Docker: use configs from clickhouse-test [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([proller](https://github.com/proller)) +- Fix compile for FreeBSD [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([proller](https://github.com/proller)) +- Upgrade boost to 1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([proller](https://github.com/proller)) +- Fix build clickhouse as submodule [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([proller](https://github.com/proller)) +- Improve JSONExtract performance tests [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([Vitaly Baranov](https://github.com/vitlibar)) + +## ClickHouse Release 19.8 {#clickhouse-release-19-8} + +### ClickHouse Release 19.8.3.8, 2019-06-11 {#clickhouse-release-19-8-3-8-2019-06-11} + +#### New Features {#new-features} + +- Added functions to work with JSON [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([hcz](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([Vitaly Baranov](https://github.com/vitlibar)) +- Add a function basename, with a similar behaviour to a basename function, which exists in a lot of languages (`os.path.basename` in python, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Added `LIMIT n, m BY` or `LIMIT m OFFSET n BY` syntax to set offset of n for LIMIT BY clause. [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([Anton Popov](https://github.com/CurtizJ)) +- Added new data type `SimpleAggregateFunction`, which allows to have columns with light aggregation in an `AggregatingMergeTree`. This can only be used with simple functions like `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([Boris Granveaud](https://github.com/bgranvea)) +- Added support for non-constant arguments in function `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([Danila Kutenin](https://github.com/danlark1)) +- Added functions `skewPop`, `skewSamp`, `kurtPop` and `kurtSamp` to compute for sequence skewness, sample skewness, kurtosis and sample kurtosis respectively. [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([hcz](https://github.com/hczhcz)) +- Support rename operation for `MaterializeView` storage. [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Added server which allows connecting to ClickHouse using MySQL client. [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([Yuriy Baranov](https://github.com/yurriy)) +- Add `toDecimal*OrZero` and `toDecimal*OrNull` functions. [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([Artem Zuikov](https://github.com/4ertus2)) +- Support Decimal types in functions: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted`, medianExactWeighted. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) +- Added `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([Danila Kutenin](https://github.com/danlark1)) +- Added `format` function. Formatting constant pattern (simplified Python format pattern) with the strings listed in the arguments. [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([Danila Kutenin](https://github.com/danlark1)) +- Added `system.detached_parts` table containing information about detached parts of `MergeTree` tables. [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([akuzm](https://github.com/akuzm)) +- Added `ngramSearch` function to calculate the non-symmetric difference between needle and haystack. [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([Danila Kutenin](https://github.com/danlark1)) +- Implementation of basic machine learning methods (stochastic linear regression and logistic regression) using aggregate functions interface. Has different strategies for updating model weights (simple gradient descent, momentum method, Nesterov method). Also supports mini-batches of custom size. [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([Quid37](https://github.com/Quid37)) +- Implementation of `geohashEncode` and `geohashDecode` functions. [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([Vasily Nemkov](https://github.com/Enmk)) +- Added aggregate function `timeSeriesGroupSum`, which can aggregate different time series that sample timestamp not alignment. It will use linear interpolation between two sample timestamp and then sum time-series together. Added aggregate function `timeSeriesGroupRateSum`, which calculates the rate of time-series and then sum rates together. [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([Yangkuan Liu](https://github.com/LiuYangkuan)) +- Added functions `IPv4CIDRtoIPv4Range` and `IPv6CIDRtoIPv6Range` to calculate the lower and higher bounds for an IP in the subnet using a CIDR. [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([Guillaume Tassery](https://github.com/YiuRULE)) +- Add a X-ClickHouse-Summary header when we send a query using HTTP with enabled setting `send_progress_in_http_headers`. Return the usual information of X-ClickHouse-Progress, with additional information like how many rows and bytes were inserted in the query. [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([Guillaume Tassery](https://github.com/YiuRULE)) + +#### Improvements {#improvements} + +- Added `max_parts_in_total` setting for MergeTree family of tables (default: 100 000) that prevents unsafe specification of partition key \#5166. [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `clickhouse-obfuscator`: derive seed for individual columns by combining initial seed with column name, not column position. This is intended to transform datasets with multiple related tables, so that tables will remain JOINable after transformation. [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added functions `JSONExtractRaw`, `JSONExtractKeyAndValues`. Renamed functions `jsonExtract` to `JSONExtract`. When something goes wrong these functions return the correspondent values, not `NULL`. Modified function `JSONExtract`, now it gets the return type from its last parameter and doesn’t inject nullables. Implemented fallback to RapidJSON in case AVX2 instructions are not available. Simdjson library updated to a new version. [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([Vitaly Baranov](https://github.com/vitlibar)) +- Now `if` and `multiIf` functions don’t rely on the condition’s `Nullable`, but rely on the branches for sql compatibility. [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([Jian Wu](https://github.com/janplus)) +- `In` predicate now generates `Null` result from `Null` input like the `Equal` function. [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([Jian Wu](https://github.com/janplus)) +- Check the time limit every (flush\_interval / poll\_timeout) number of rows from Kafka. This allows to break the reading from Kafka consumer more frequently and to check the time limits for the top-level streams [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([Ivan](https://github.com/abyss7)) +- Link rdkafka with bundled SASL. It should allow to use SASL SCRAM authentication [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([Ivan](https://github.com/abyss7)) +- Batched version of RowRefList for ALL JOINS. [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([Artem Zuikov](https://github.com/4ertus2)) +- clickhouse-server: more informative listen error messages. [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([proller](https://github.com/proller)) +- Support dictionaries in clickhouse-copier for functions in `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([proller](https://github.com/proller)) +- Add new setting `kafka_commit_every_batch` to regulate Kafka committing policy. + It allows to set commit mode: after every batch of messages is handled, or after the whole block is written to the storage. It’s a trade-off between losing some messages or reading them twice in some extreme situations. [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([Ivan](https://github.com/abyss7)) +- Make `windowFunnel` support other Unsigned Integer Types. [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([sundyli](https://github.com/sundy-li)) +- Allow to shadow virtual column `_table` in Merge engine. [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([Ivan](https://github.com/abyss7)) +- Make `sequenceMatch` aggregate functions support other unsigned Integer types [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([sundyli](https://github.com/sundy-li)) +- Better error messages if checksum mismatch is most likely caused by hardware failures. [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Check that underlying tables support sampling for `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([Ivan](https://github.com/abyss7)) +- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- Improvements of MySQL Wire Protocol. Changed name of format to MySQLWire. Using RAII for calling RSA\_free. Disabling SSL if context cannot be created. [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([Yuriy Baranov](https://github.com/yurriy)) +- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([proller](https://github.com/proller)) +- Respect query settings in asynchronous INSERTs into Distributed tables. [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([TCeason](https://github.com/TCeason)) +- Renamed functions `leastSqr` to `simpleLinearRegression`, `LinearRegression` to `linearRegression`, `LogisticRegression` to `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +#### Performance Improvements {#performance-improvements} + +- Parallelize processing of parts of non-replicated MergeTree tables in ALTER MODIFY query. [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([Ivan Kush](https://github.com/IvanKush)) +- Optimizations in regular expressions extraction. [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([Danila Kutenin](https://github.com/danlark1)) +- Do not add right join key column to join result if it’s used only in join on section. [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([Artem Zuikov](https://github.com/4ertus2)) +- Freeze the Kafka buffer after first empty response. It avoids multiple invokations of `ReadBuffer::next()` for empty result in some row-parsing streams. [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([Ivan](https://github.com/abyss7)) +- `concat` function optimization for multiple arguments. [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([Danila Kutenin](https://github.com/danlark1)) +- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([Artem Zuikov](https://github.com/4ertus2)) +- Upgrade our LZ4 implementation with reference one to have faster decompression. [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([Danila Kutenin](https://github.com/danlark1)) +- Implemented MSD radix sort (based on kxsort), and partial sorting. [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([Evgenii Pravda](https://github.com/kvinty)) + +#### Bug Fixes {#bug-fixes} + +- Fix push require columns with join [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([Winter Zhang](https://github.com/zhang2014)) +- Fixed bug, when ClickHouse is run by systemd, the command `sudo service clickhouse-server forcerestart` was not working as expected. [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([proller](https://github.com/proller)) +- Fix http error codes in DataPartsExchange (interserver http server on 9009 port always returned code 200, even on errors). [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([proller](https://github.com/proller)) +- Fix SimpleAggregateFunction for String longer than MAX\_SMALL\_STRING\_SIZE [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([Azat Khuzhin](https://github.com/azat)) +- Fix error for `Decimal` to `Nullable(Decimal)` conversion in IN. Support other Decimal to Decimal conversions (including different scales). [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed FPU clobbering in simdjson library that lead to wrong calculation of `uniqHLL` and `uniqCombined` aggregate function and math functions such as `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed handling mixed const/nonconst cases in JSON functions. [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix `retention` function. Now all conditions that satisfy in a row of data are added to the data state. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) +- Fix result type for `quantileExact` with Decimals. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Documentation {#documentation} + +- Translate documentation for `CollapsingMergeTree` to chinese. [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) +- Translate some documentation about table engines to chinese. + [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) + [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) + ([never lee](https://github.com/neverlee)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements} + +- Fix some sanitizer reports that show probable use-after-free.[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([Ivan](https://github.com/abyss7)) +- Move performance tests out of separate directories for convenience. [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix incorrect performance tests. [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([alesapin](https://github.com/alesapin)) +- Added a tool to calculate checksums caused by bit flips to debug hardware issues. [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Make runner script more usable. [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([filimonov](https://github.com/filimonov)) +- Add small instruction how to write performance tests. [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([alesapin](https://github.com/alesapin)) +- Add ability to make substitutions in create, fill and drop query in performance tests [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([Olga Khvostikova](https://github.com/stavrolia)) + +## ClickHouse Release 19.7 {#clickhouse-release-19-7} + +### ClickHouse Release 19.7.5.29, 2019-07-05 {#clickhouse-release-19-7-5-29-2019-07-05} + +#### Bug Fix {#bug-fix-25} + +- Fix performance regression in some queries with JOIN. [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([Winter Zhang](https://github.com/zhang2014)) + +### ClickHouse Release 19.7.5.27, 2019-06-09 {#clickhouse-release-19-7-5-27-2019-06-09} + +#### New Features {#new-features-1} + +- Added bitmap related functions `bitmapHasAny` and `bitmapHasAll` analogous to `hasAny` and `hasAll` functions for arrays. [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([Sergi Vladykin](https://github.com/svladykin)) + +#### Bug Fixes {#bug-fixes-1} + +- Fix segfault on `minmax` INDEX with Null value. [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([Nikita Vasilev](https://github.com/nikvas0)) +- Mark all input columns in LIMIT BY as required output. It fixes ‘Not found column’ error in some distributed queries. [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([Constantin S. Pan](https://github.com/kvap)) +- Fix “Column ‘0’ already exists” error in `SELECT .. PREWHERE` on column with DEFAULT [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([proller](https://github.com/proller)) +- Fix `ALTER MODIFY TTL` query on `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([Anton Popov](https://github.com/CurtizJ)) +- Don’t crash the server when Kafka consumers have failed to start. [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([Ivan](https://github.com/abyss7)) +- Fixed bitmap functions produce wrong result. [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([Andy Yang](https://github.com/andyyzh)) +- Fix element\_count for hashed dictionary (do not include duplicates) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) +- Use contents of environment variable TZ as the name for timezone. It helps to correctly detect default timezone in some cases.[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([Ivan](https://github.com/abyss7)) +- Do not try to convert integers in `dictGetT` functions, because it doesn’t work correctly. Throw an exception instead. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix settings in ExternalData HTTP request. [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila + Kutenin](https://github.com/danlark1)) +- Fix bug when parts were removed only from FS without dropping them from Zookeeper. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([alesapin](https://github.com/alesapin)) +- Fix segmentation fault in `bitmapHasAny` function. [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) +- Fixed error when replication connection pool doesn’t retry to resolve host, even when DNS cache was dropped. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([alesapin](https://github.com/alesapin)) +- Fixed `DROP INDEX IF EXISTS` query. Now `ALTER TABLE ... DROP INDEX IF EXISTS ...` query doesn’t raise an exception if provided index does not exist. [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([Gleb Novikov](https://github.com/NanoBjorn)) +- Fix union all supertype column. There were cases with inconsistent data and column types of resulting columns. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) +- Skip ZNONODE during DDL query processing. Before if another node removes the znode in task queue, the one that + did not process it, but already get list of children, will terminate the DDLWorker thread. [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) +- Fix INSERT into Distributed() table with MATERIALIZED column. [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) + +### ClickHouse Release 19.7.3.9, 2019-05-30 {#clickhouse-release-19-7-3-9-2019-05-30} + +#### New Features {#new-features-2} + +- Allow to limit the range of a setting that can be specified by user. + These constraints can be set up in user settings profile. + [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([Vitaly + Baranov](https://github.com/vitlibar)) +- Add a second version of the function `groupUniqArray` with an optional + `max_size` parameter that limits the size of the resulting array. This + behavior is similar to `groupArray(max_size)(x)` function. + [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([Guillaume + Tassery](https://github.com/YiuRULE)) +- For TSVWithNames/CSVWithNames input file formats, column order can now be + determined from file header. This is controlled by + `input_format_with_names_use_header` parameter. + [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) + ([Alexander](https://github.com/Akazz)) + +#### Bug Fixes {#bug-fixes-2} + +- Crash with uncompressed\_cache + JOIN during merge (\#5197) + [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([Danila + Kutenin](https://github.com/danlark1)) +- Segmentation fault on a clickhouse-client query to system tables. \#5066 + [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) + ([Ivan](https://github.com/abyss7)) +- Data loss on heavy load via KafkaEngine (\#4736) + [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) + ([Ivan](https://github.com/abyss7)) +- Fixed very rare data race condition that could happen when executing a query with UNION ALL involving at least two SELECTs from system.columns, system.tables, system.parts, system.parts\_tables or tables of Merge family and performing ALTER of columns of the related tables concurrently. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Performance Improvements {#performance-improvements-1} + +- Use radix sort for sorting by single numeric column in `ORDER BY` without + `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), + [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) + ([Evgenii Pravda](https://github.com/kvinty), + [alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Documentation {#documentation-1} + +- Translate documentation for some table engines to Chinese. + [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), + [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), + [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) + ([张风啸](https://github.com/AlexZFX)), + [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([never + lee](https://github.com/neverlee)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-1} + +- Print UTF-8 characters properly in `clickhouse-test`. + [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) + ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add command line parameter for clickhouse-client to always load suggestion + data. [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) + ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Resolve some of PVS-Studio warnings. + [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) + ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Update LZ4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([Danila + Kutenin](https://github.com/danlark1)) +- Add gperf to build requirements for upcoming pull request \#5030. + [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) + ([proller](https://github.com/proller)) + +## ClickHouse Release 19.6 {#clickhouse-release-19-6} + +### ClickHouse Release 19.6.3.18, 2019-06-13 {#clickhouse-release-19-6-3-18-2019-06-13} + +#### Bug Fixes {#bug-fixes-3} + +- Fixed IN condition pushdown for queries from table functions `mysql` and `odbc` and corresponding table engines. This fixes \#3540 and \#2384. [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix deadlock in Zookeeper. [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([github1youlc](https://github.com/github1youlc)) +- Allow quoted decimals in CSV. [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([Artem Zuikov](https://github.com/4ertus2) +- Disallow conversion from float Inf/NaN into Decimals (throw exception). [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix data race in rename query. [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([Winter Zhang](https://github.com/zhang2014)) +- Temporarily disable LFAlloc. Usage of LFAlloc might lead to a lot of MAP\_FAILED in allocating UncompressedCache and in a result to crashes of queries at high loaded servers. [cfdba93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([Danila Kutenin](https://github.com/danlark1)) + +### ClickHouse Release 19.6.2.11, 2019-05-13 {#clickhouse-release-19-6-2-11-2019-05-13} + +#### New Features {#new-features-3} + +- TTL expressions for columns and tables. [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([Anton Popov](https://github.com/CurtizJ)) +- Added support for `brotli` compression for HTTP responses (Accept-Encoding: br) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([Mikhail](https://github.com/fandyushin)) +- Added new function `isValidUTF8` for checking whether a set of bytes is correctly utf-8 encoded. [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([Danila Kutenin](https://github.com/danlark1)) +- Add new load balancing policy `first_or_random` which sends queries to the first specified host and if it’s inaccessible send queries to random hosts of shard. Useful for cross-replication topology setups. [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([nvartolomei](https://github.com/nvartolomei)) + +#### Experimental Features {#experimental-features-1} + +- Add setting `index_granularity_bytes` (adaptive index granularity) for MergeTree\* tables family. [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([alesapin](https://github.com/alesapin)) + +#### Improvements {#improvements-1} + +- Added support for non-constant and negative size and length arguments for function `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Disable push-down to right table in left join, left table in right join, and both tables in full join. This fixes wrong JOIN results in some cases. [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([Ivan](https://github.com/abyss7)) +- `clickhouse-copier`: auto upload task configuration from `--task-file` option [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([proller](https://github.com/proller)) +- Added typos handler for storage factory and table functions factory. [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([Danila Kutenin](https://github.com/danlark1)) +- Support asterisks and qualified asterisks for multiple joins without subqueries [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([Artem Zuikov](https://github.com/4ertus2)) +- Make missing column error message more user friendly. [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Performance Improvements {#performance-improvements-2} + +- Significant speedup of ASOF JOIN [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([Martijn Bakker](https://github.com/Gladdy)) + +#### Backward Incompatible Changes {#backward-incompatible-changes} + +- HTTP header `Query-Id` was renamed to `X-ClickHouse-Query-Id` for consistency. [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([Mikhail](https://github.com/fandyushin)) + +#### Bug Fixes {#bug-fixes-4} + +- Fixed potential null pointer dereference in `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([proller](https://github.com/proller)) +- Fixed error on query with JOIN + ARRAY JOIN [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed hanging on start of the server when a dictionary depends on another dictionary via a database with engine=Dictionary. [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([Vitaly Baranov](https://github.com/vitlibar)) +- Partially fix distributed\_product\_mode = local. It’s possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There’s not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix potentially wrong result for `SELECT DISTINCT` with `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed very rare data race condition that could happen when executing a query with UNION ALL involving at least two SELECTs from system.columns, system.tables, system.parts, system.parts\_tables or tables of Merge family and performing ALTER of columns of the related tables concurrently. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-2} + +- Fixed test failures when running clickhouse-server on different host [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([Vasily Nemkov](https://github.com/Enmk)) +- clickhouse-test: Disable color control sequences in non tty environment. [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([alesapin](https://github.com/alesapin)) +- clickhouse-test: Allow use any test database (remove `test.` qualification where it possible) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([proller](https://github.com/proller)) +- Fix ubsan errors [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([Vitaly Baranov](https://github.com/vitlibar)) +- Yandex LFAlloc was added to ClickHouse to allocate MarkCache and UncompressedCache data in different ways to catch segfaults more reliable [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([Danila Kutenin](https://github.com/danlark1)) +- Python util to help with backports and changelogs. [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([Ivan](https://github.com/abyss7)) + +## ClickHouse Release 19.5 {#clickhouse-release-19-5} + +### ClickHouse Release 19.5.4.22, 2019-05-13 {#clickhouse-release-19-5-4-22-2019-05-13} + +#### Bug Fixes {#bug-fixes-5} + +- Fixed possible crash in bitmap\* functions [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([Andy Yang](https://github.com/andyyzh)) +- Fixed very rare data race condition that could happen when executing a query with UNION ALL involving at least two SELECTs from system.columns, system.tables, system.parts, system.parts\_tables or tables of Merge family and performing ALTER of columns of the related tables concurrently. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed error `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. This error happened if LowCardinality column was the part of primary key. \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Modification of retention function: If a row satisfies both the first and NTH condition, only the first satisfied condition is added to the data state. Now all conditions that satisfy in a row of data are added to the data state. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) + +### ClickHouse Release 19.5.3.8, 2019-04-18 {#clickhouse-release-19-5-3-8-2019-04-18} + +#### Bug Fixes {#bug-fixes-6} + +- Fixed type of setting `max_partitions_per_insert_block` from boolean to UInt64. [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([Mohammad Hossein Sekhavat](https://github.com/mhsekhavat)) + +### ClickHouse Release 19.5.2.6, 2019-04-15 {#clickhouse-release-19-5-2-6-2019-04-15} + +#### New Features {#new-features-4} + +- [Hyperscan](https://github.com/intel/hyperscan) multiple regular expression matching was added (functions `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([Danila Kutenin](https://github.com/danlark1)) +- `multiSearchFirstPosition` function was added. [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) +- Implement the predefined expression filter per row for tables. [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([Ivan](https://github.com/abyss7)) +- A new type of data skipping indices based on bloom filters (can be used for `equal`, `in` and `like` functions). [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([Nikita Vasilev](https://github.com/nikvas0)) +- Added `ASOF JOIN` which allows to run queries that join to the most recent value known. [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([Martijn Bakker](https://github.com/Gladdy), [Artem Zuikov](https://github.com/4ertus2)) +- Rewrite multiple `COMMA JOIN` to `CROSS JOIN`. Then rewrite them to `INNER JOIN` if possible. [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Improvement {#improvement-9} + +- `topK` and `topKWeighted` now supports custom `loadFactor` (fixes issue [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([Kirill Danshin](https://github.com/kirillDanshin)) +- Allow to use `parallel_replicas_count > 1` even for tables without sampling (the setting is simply ignored for them). In previous versions it was lead to exception. [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([Alexey Elymanov](https://github.com/digitalist)) +- Support for `CREATE OR REPLACE VIEW`. Allow to create a view or set a new definition in a single statement. [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([Boris Granveaud](https://github.com/bgranvea)) +- `Buffer` table engine now supports `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([Yangkuan Liu](https://github.com/LiuYangkuan)) +- Add ability to start replicated table without metadata in zookeeper in `readonly` mode. [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([alesapin](https://github.com/alesapin)) +- Fixed flicker of progress bar in clickhouse-client. The issue was most noticeable when using `FORMAT Null` with streaming queries. [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Allow to disable functions with `hyperscan` library on per user basis to limit potentially excessive and uncontrolled resource usage. [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add version number logging in all errors. [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([proller](https://github.com/proller)) +- Added restriction to the `multiMatch` functions which requires string size to fit into `unsigned int`. Also added the number of arguments limit to the `multiSearch` functions. [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([Danila Kutenin](https://github.com/danlark1)) +- Improved usage of scratch space and error handling in Hyperscan. [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([Danila Kutenin](https://github.com/danlark1)) +- Fill `system.graphite_detentions` from a table config of `*GraphiteMergeTree` engine tables. [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- Rename `trigramDistance` function to `ngramDistance` and add more functions with `CaseInsensitive` and `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([Danila Kutenin](https://github.com/danlark1)) +- Improved data skipping indices calculation. [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([Nikita Vasilev](https://github.com/nikvas0)) +- Keep ordinary, `DEFAULT`, `MATERIALIZED` and `ALIAS` columns in a single list (fixes issue [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) + +#### Bug Fix {#bug-fix-26} + +- Avoid `std::terminate` in case of memory allocation failure. Now `std::bad_alloc` exception is thrown as expected. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixes capnproto reading from buffer. Sometimes files wasn’t loaded successfully by HTTP. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([Vladislav](https://github.com/smirnov-vs)) +- Fix error `Unknown log entry type: 0` after `OPTIMIZE TABLE FINAL` query. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([Amos Bird](https://github.com/amosbird)) +- Wrong arguments to `hasAny` or `hasAll` functions may lead to segfault. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Deadlock may happen while executing `DROP DATABASE dictionary` query. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix undefined behavior in `median` and `quantile` functions. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +- Fix compression level detection when `network_compression_method` in lowercase. Broken in v19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) +- Fixed ignorance of `UTC` setting (fixes issue [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) +- Fix `histogram` function behaviour with `Distributed` tables. [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) +- Fixed tsan report `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed TSan report on shutdown due to race condition in system logs usage. Fixed potential use-after-free on shutdown when part\_log is enabled. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix recheck parts in `ReplicatedMergeTreeAlterThread` in case of error. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Arithmetic operations on intermediate aggregate function states were not working for constant arguments (such as subquery results). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Always backquote column names in metadata. Otherwise it’s impossible to create a table with column named `index` (server won’t restart due to malformed `ATTACH` query in metadata). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix crash in `ALTER ... MODIFY ORDER BY` on `Distributed` table. [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) +- Fix segfault in `JOIN ON` with enabled `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([Winter Zhang](https://github.com/zhang2014)) +- Fix bug with adding an extraneous row after consuming a protobuf message from Kafka. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix crash of `JOIN` on not-nullable vs nullable column. Fix `NULLs` in right keys in `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) +- Fixed race condition in `SELECT` from `system.tables` if the table is renamed or altered concurrently. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed data race when fetching data part that is already obsolete. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed rare data race that can happen during `RENAME` table of MergeTree family. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed segmentation fault in function `arrayIntersect`. Segmentation fault could happen if function was called with mixed constant and ordinary arguments. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang Qian](https://github.com/fancyqlx)) +- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix crash in `FULL/RIGHT JOIN` when we joining on nullable vs not nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix `No message received` exception while fetching parts between replicas. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([alesapin](https://github.com/alesapin)) +- Fixed `arrayIntersect` function wrong result in case of several repeated values in single array. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix a race condition during concurrent `ALTER COLUMN` queries that could lead to a server crash (fixes issue [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fix incorrect result in `FULL/RIGHT JOIN` with const column. [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix duplicates in `GLOBAL JOIN` with asterisk. [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix parameter deduction in `ALTER MODIFY` of column `CODEC` when column type is not specified. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([alesapin](https://github.com/alesapin)) +- Functions `cutQueryStringAndFragment()` and `queryStringAndFragment()` now works correctly when `URL` contains a fragment and no query. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix rare bug when setting `min_bytes_to_use_direct_io` is greater than zero, which occures when thread have to seek backward in column file. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([alesapin](https://github.com/alesapin)) +- Fix wrong argument types for aggregate functions with `LowCardinality` arguments (fixes issue [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix wrong name qualification in `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix function `toISOWeek` result for year 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix `DROP`, `TRUNCATE` and `OPTIMIZE` queries duplication, when executed on `ON CLUSTER` for `ReplicatedMergeTree*` tables family. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([alesapin](https://github.com/alesapin)) + +#### Backward Incompatible Change {#backward-incompatible-change-8} + +- Rename setting `insert_sample_with_metadata` to setting `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([Artem Zuikov](https://github.com/4ertus2)) +- Added setting `max_partitions_per_insert_block` (with value 100 by default). If inserted block contains larger number of partitions, an exception is thrown. Set it to 0 if you want to remove the limit (not recommended). [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Multi-search functions were renamed (`multiPosition` to `multiSearchAllPositions`, `multiSearch` to `multiSearchAny`, `firstMatch` to `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) + +#### Performance Improvement {#performance-improvement-6} + +- Optimize Volnitsky searcher by inlining, giving about 5-10% search improvement for queries with many needles or many similar bigrams. [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([Danila Kutenin](https://github.com/danlark1)) +- Fix performance issue when setting `use_uncompressed_cache` is greater than zero, which appeared when all read data contained in cache. [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([alesapin](https://github.com/alesapin)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-10} + +- Hardening debug build: more granular memory mappings and ASLR; add memory protection for mark cache and index. This allows to find more memory stomping bugs in case when ASan and MSan cannot do it. [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add support for cmake variables `ENABLE_PROTOBUF`, `ENABLE_PARQUET` and `ENABLE_BROTLI` which allows to enable/disable the above features (same as we can do for librdkafka, mysql, etc). [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([Silviu Caragea](https://github.com/silviucpp)) +- Add ability to print process list and stacktraces of all threads if some queries are hung after test run. [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([alesapin](https://github.com/alesapin)) +- Add retries on `Connection loss` error in `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([alesapin](https://github.com/alesapin)) +- Add freebsd build with vagrant and build with thread sanitizer to packager script. [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([alesapin](https://github.com/alesapin)) +- Now user asked for password for user `'default'` during installation. [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([proller](https://github.com/proller)) +- Suppress warning in `rdkafka` library. [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Allow ability to build without ssl. [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([proller](https://github.com/proller)) +- Add a way to launch clickhouse-server image from a custom user. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- Upgrade contrib boost to 1.69. [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([proller](https://github.com/proller)) +- Disable usage of `mremap` when compiled with Thread Sanitizer. Surprisingly enough, TSan does not intercept `mremap` (though it does intercept `mmap`, `munmap`) that leads to false positives. Fixed TSan report in stateful tests. [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add test checking using format schema via HTTP interface. [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([Vitaly Baranov](https://github.com/vitlibar)) + +## ClickHouse Release 19.4 {#clickhouse-release-19-4} + +### ClickHouse Release 19.4.4.33, 2019-04-17 {#clickhouse-release-19-4-4-33-2019-04-17} + +#### Bug Fixes {#bug-fixes-7} + +- Avoid `std::terminate` in case of memory allocation failure. Now `std::bad_alloc` exception is thrown as expected. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixes capnproto reading from buffer. Sometimes files wasn’t loaded successfully by HTTP. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([Vladislav](https://github.com/smirnov-vs)) +- Fix error `Unknown log entry type: 0` after `OPTIMIZE TABLE FINAL` query. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([Amos Bird](https://github.com/amosbird)) +- Wrong arguments to `hasAny` or `hasAll` functions may lead to segfault. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Deadlock may happen while executing `DROP DATABASE dictionary` query. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix undefined behavior in `median` and `quantile` functions. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +- Fix compression level detection when `network_compression_method` in lowercase. Broken in v19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) +- Fixed ignorance of `UTC` setting (fixes issue [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) +- Fix `histogram` function behaviour with `Distributed` tables. [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) +- Fixed tsan report `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed TSan report on shutdown due to race condition in system logs usage. Fixed potential use-after-free on shutdown when part\_log is enabled. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix recheck parts in `ReplicatedMergeTreeAlterThread` in case of error. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Arithmetic operations on intermediate aggregate function states were not working for constant arguments (such as subquery results). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Always backquote column names in metadata. Otherwise it’s impossible to create a table with column named `index` (server won’t restart due to malformed `ATTACH` query in metadata). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix crash in `ALTER ... MODIFY ORDER BY` on `Distributed` table. [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) +- Fix segfault in `JOIN ON` with enabled `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([Winter Zhang](https://github.com/zhang2014)) +- Fix bug with adding an extraneous row after consuming a protobuf message from Kafka. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) +- Fixed race condition in `SELECT` from `system.tables` if the table is renamed or altered concurrently. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed data race when fetching data part that is already obsolete. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed rare data race that can happen during `RENAME` table of MergeTree family. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed segmentation fault in function `arrayIntersect`. Segmentation fault could happen if function was called with mixed constant and ordinary arguments. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang Qian](https://github.com/fancyqlx)) +- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix `No message received` exception while fetching parts between replicas. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([alesapin](https://github.com/alesapin)) +- Fixed `arrayIntersect` function wrong result in case of several repeated values in single array. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix a race condition during concurrent `ALTER COLUMN` queries that could lead to a server crash (fixes issue [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fix parameter deduction in `ALTER MODIFY` of column `CODEC` when column type is not specified. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([alesapin](https://github.com/alesapin)) +- Functions `cutQueryStringAndFragment()` and `queryStringAndFragment()` now works correctly when `URL` contains a fragment and no query. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([Vitaly Baranov](https://github.com/vitlibar)) +- Fix rare bug when setting `min_bytes_to_use_direct_io` is greater than zero, which occures when thread have to seek backward in column file. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([alesapin](https://github.com/alesapin)) +- Fix wrong argument types for aggregate functions with `LowCardinality` arguments (fixes issue [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fix function `toISOWeek` result for year 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix `DROP`, `TRUNCATE` and `OPTIMIZE` queries duplication, when executed on `ON CLUSTER` for `ReplicatedMergeTree*` tables family. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([alesapin](https://github.com/alesapin)) + +#### Improvements {#improvements-2} + +- Keep ordinary, `DEFAULT`, `MATERIALIZED` and `ALIAS` columns in a single list (fixes issue [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) + +### ClickHouse Release 19.4.3.11, 2019-04-02 {#clickhouse-release-19-4-3-11-2019-04-02} + +#### Bug Fixes {#bug-fixes-8} + +- Fix crash in `FULL/RIGHT JOIN` when we joining on nullable vs not nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-11} + +- Add a way to launch clickhouse-server image from a custom user. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### ClickHouse Release 19.4.2.7, 2019-03-30 {#clickhouse-release-19-4-2-7-2019-03-30} + +#### Bug Fixes {#bug-fixes-9} + +- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +### ClickHouse Release 19.4.1.3, 2019-03-19 {#clickhouse-release-19-4-1-3-2019-03-19} + +#### Bug Fixes {#bug-fixes-10} + +- Fixed remote queries which contain both `LIMIT BY` and `LIMIT`. Previously, if `LIMIT BY` and `LIMIT` were used for remote query, `LIMIT` could happen before `LIMIT BY`, which led to too filtered result. [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([Constantin S. Pan](https://github.com/kvap)) + +### ClickHouse Release 19.4.0.49, 2019-03-09 {#clickhouse-release-19-4-0-49-2019-03-09} + +#### New Features {#new-features-5} + +- Added full support for `Protobuf` format (input and output, nested data structures). [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([Vitaly Baranov](https://github.com/vitlibar)) +- Added bitmap functions with Roaring Bitmaps. [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([Andy Yang](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([Vitaly Baranov](https://github.com/vitlibar)) +- Parquet format support. [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([proller](https://github.com/proller)) +- N-gram distance was added for fuzzy string comparison. It is similar to q-gram metrics in R language. [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([Danila Kutenin](https://github.com/danlark1)) +- Combine rules for graphite rollup from dedicated aggregation and retention patterns. [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- Added `max_execution_speed` and `max_execution_speed_bytes` to limit resource usage. Added `min_execution_speed_bytes` setting to complement the `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([Winter Zhang](https://github.com/zhang2014)) +- Implemented function `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([alexey-milovidov](https://github.com/alexey-milovidov), [kzon](https://github.com/kzon)) +- Added functions `arrayEnumerateDenseRanked` and `arrayEnumerateUniqRanked` (it’s like `arrayEnumerateUniq` but allows to fine tune array depth to look inside multidimensional arrays). [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([proller](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Bug Fixes {#bug-fixes-11} + +- This release also contains all bug fixes from 19.3 and 19.1. +- Fixed bug in data skipping indices: order of granules after INSERT was incorrect. [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([Nikita Vasilev](https://github.com/nikvas0)) +- Fixed `set` index for `Nullable` and `LowCardinality` columns. Before it, `set` index with `Nullable` or `LowCardinality` column led to error `Data type must be deserialized with multiple streams` while selecting. [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Correctly set update\_time on full `executable` dictionary update. [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([Tema Novikov](https://github.com/temoon)) +- Fix broken progress bar in 19.3. [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([filimonov](https://github.com/filimonov)) +- Fixed inconsistent values of MemoryTracker when memory region was shrinked, in certain cases. [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed undefined behaviour in ThreadPool. [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed a very rare crash with the message `mutex lock failed: Invalid argument` that could happen when a MergeTree table was dropped concurrently with a SELECT. [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([Alex Zatelepin](https://github.com/ztlpn)) +- ODBC driver compatibility with `LowCardinality` data type. [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([proller](https://github.com/proller)) +- FreeBSD: Fixup for `AIOcontextPool: Found io_event with unknown id 0` error. [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([urgordeadbeef](https://github.com/urgordeadbeef)) +- `system.part_log` table was created regardless to configuration. [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix undefined behaviour in `dictIsIn` function for cache dictionaries. [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([alesapin](https://github.com/alesapin)) +- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([Alex Zatelepin](https://github.com/ztlpn)) +- Disable compile\_expressions by default until we get own `llvm` contrib and can test it with `clang` and `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([alesapin](https://github.com/alesapin)) +- Prevent `std::terminate` when `invalidate_query` for `clickhouse` external dictionary source has returned wrong resultset (empty or more than one row or more than one column). Fixed issue when the `invalidate_query` was performed every five seconds regardless to the `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Avoid deadlock when the `invalidate_query` for a dictionary with `clickhouse` source was involving `system.dictionaries` table or `Dictionaries` database (rare case). [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixes for CROSS JOIN with empty WHERE. [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed segfault in function “replicate” when constant argument is passed. [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix lambda function with predicate optimizer. [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([Winter Zhang](https://github.com/zhang2014)) +- Multiple JOINs multiple fixes. [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Improvements {#improvements-3} + +- Support aliases in JOIN ON section for right table columns. [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([Artem Zuikov](https://github.com/4ertus2)) +- Result of multiple JOINs need correct result names to be used in subselects. Replace flat aliases with source names in result. [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([Artem Zuikov](https://github.com/4ertus2)) +- Improve push-down logic for joined statements. [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([Ivan](https://github.com/abyss7)) + +#### Performance Improvements {#performance-improvements-3} + +- Improved heuristics of “move to PREWHERE” optimization. [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Use proper lookup tables that uses HashTable’s API for 8-bit and 16-bit keys. [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([Amos Bird](https://github.com/amosbird)) +- Improved performance of string comparison. [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Cleanup distributed DDL queue in a separate thread so that it doesn’t slow down the main loop that processes distributed DDL tasks. [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([Alex Zatelepin](https://github.com/ztlpn)) +- When `min_bytes_to_use_direct_io` is set to 1, not every file was opened with O\_DIRECT mode because the data size to read was sometimes underestimated by the size of one compressed block. [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-12} + +- Added support for clang-9 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix wrong `__asm__` instructions (again) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([Konstantin Podshumok](https://github.com/podshumok)) +- Add ability to specify settings for `clickhouse-performance-test` from command line. [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([alesapin](https://github.com/alesapin)) +- Add dictionaries tests to integration tests. [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([alesapin](https://github.com/alesapin)) +- Added queries from the benchmark on the website to automated performance tests. [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `xxhash.h` does not exist in external lz4 because it is an implementation detail and its symbols are namespaced with `XXH_NAMESPACE` macro. When lz4 is external, xxHash has to be external too, and the dependents have to link to it. [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([Orivej Desh](https://github.com/orivej)) +- Fixed a case when `quantileTiming` aggregate function can be called with negative or floating point argument (this fixes fuzz test with undefined behaviour sanitizer). [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Spelling error correction. [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) +- Fix compilation on Mac. [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([Vitaly Baranov](https://github.com/vitlibar)) +- Build fixes for FreeBSD and various unusual build configurations. [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([proller](https://github.com/proller)) + +## ClickHouse Release 19.3 {#clickhouse-release-19-3} + +### ClickHouse Release 19.3.9.1, 2019-04-02 {#clickhouse-release-19-3-9-1-2019-04-02} + +#### Bug Fixes {#bug-fixes-12} + +- Fix crash in `FULL/RIGHT JOIN` when we joining on nullable vs not nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) +- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) +- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) + +#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-13} + +- Add a way to launch clickhouse-server image from a custom user [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### ClickHouse Release 19.3.7, 2019-03-12 {#clickhouse-release-19-3-7-2019-03-12} + +#### Bug Fixes {#bug-fixes-13} + +- Fixed error in \#3920. This error manifests itself as random cache corruption (messages `Unknown codec family code`, `Cannot seek through file`) and segfaults. This bug first appeared in version 19.1 and is present in versions up to 19.1.10 and 19.3.6. [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.3.6, 2019-03-02 {#clickhouse-release-19-3-6-2019-03-02} + +#### Bug Fixes {#bug-fixes-14} + +- When there are more than 1000 threads in a thread pool, `std::terminate` may happen on thread exit. [Azat Khuzhin](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Now it’s possible to create `ReplicatedMergeTree*` tables with comments on columns without defaults and tables with columns codecs without comments and defaults. Also fix comparison of codecs. [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([alesapin](https://github.com/alesapin)) +- Fixed crash on JOIN with array or tuple. [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed crash in clickhouse-copier with the message `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed hangup on server shutdown if distributed DDLs were used. [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([Alex Zatelepin](https://github.com/ztlpn)) +- Incorrect column numbers were printed in error message about text format parsing for columns with number greater than 10. [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-3} + +- Fixed build with AVX enabled. [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Enable extended accounting and IO accounting based on good known version instead of kernel under which it is compiled. [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([nvartolomei](https://github.com/nvartolomei)) +- Allow to skip setting of core\_dump.size\_limit, warning instead of throw if limit set fail. [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([proller](https://github.com/proller)) +- Removed the `inline` tags of `void readBinary(...)` in `Field.cpp`. Also merged redundant `namespace DB` blocks. [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([hcz](https://github.com/hczhcz)) + +### ClickHouse Release 19.3.5, 2019-02-21 {#clickhouse-release-19-3-5-2019-02-21} + +#### Bug Fixes {#bug-fixes-15} + +- Fixed bug with large http insert queries processing. [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([alesapin](https://github.com/alesapin)) +- Fixed backward incompatibility with old versions due to wrong implementation of `send_logs_level` setting. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed backward incompatibility of table function `remote` introduced with column comments. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.3.4, 2019-02-16 {#clickhouse-release-19-3-4-2019-02-16} + +#### Improvements {#improvements-4} + +- Table index size is not accounted for memory limits when doing `ATTACH TABLE` query. Avoided the possibility that a table cannot be attached after being detached. [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Slightly raised up the limit on max string and array size received from ZooKeeper. It allows to continue to work with increased size of `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` on ZooKeeper. [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Allow to repair abandoned replica even if it already has huge number of nodes in its queue. [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Add one required argument to `SET` index (max stored rows number). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([Nikita Vasilev](https://github.com/nikvas0)) + +#### Bug Fixes {#bug-fixes-16} + +- Fixed `WITH ROLLUP` result for group by single `LowCardinality` key. [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Fixed bug in the set index (dropping a granule if it contains more than `max_rows` rows). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([Nikita Vasilev](https://github.com/nikvas0)) +- A lot of FreeBSD build fixes. [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([proller](https://github.com/proller)) +- Fixed aliases substitution in queries with subquery containing same alias (issue [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-4} + +- Add ability to run `clickhouse-server` for stateless tests in docker image. [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([Vasily Nemkov](https://github.com/Enmk)) + +### ClickHouse Release 19.3.3, 2019-02-13 {#clickhouse-release-19-3-3-2019-02-13} + +#### New Features {#new-features-6} + +- Added the `KILL MUTATION` statement that allows removing mutations that are for some reasons stuck. Added `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` fields to the `system.mutations` table for easier troubleshooting. [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([Alex Zatelepin](https://github.com/ztlpn)) +- Added aggregate function `entropy` which computes Shannon entropy. [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) +- Added ability to send queries `INSERT INTO tbl VALUES (....` to server without splitting on `query` and `data` parts. [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([alesapin](https://github.com/alesapin)) +- Generic implementation of `arrayWithConstant` function was added. [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Implemented `NOT BETWEEN` comparison operator. [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([Dmitry Naumov](https://github.com/nezed)) +- Implement `sumMapFiltered` in order to be able to limit the number of keys for which values will be summed by `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- Added support of `Nullable` types in `mysql` table function. [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) +- Support for arbitrary constant expressions in `LIMIT` clause. [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) +- Added `topKWeighted` aggregate function that takes additional argument with (unsigned integer) weight. [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([Andrew Golman](https://github.com/andrewgolman)) +- `StorageJoin` now supports `join_any_take_last_row` setting that allows overwriting existing values of the same key. [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([Amos Bird](https://github.com/amosbird) +- Added function `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([Vitaly Baranov](https://github.com/vitlibar)) +- Added `RowBinaryWithNamesAndTypes` format. [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([Oleg V. Kozlyuk](https://github.com/DarkWanderer)) +- Added `IPv4` and `IPv6` data types. More effective implementations of `IPv*` functions. [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([Vasily Nemkov](https://github.com/Enmk)) +- Added function `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([Vitaly Baranov](https://github.com/vitlibar)) +- Added `Protobuf` output format. [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([Vitaly Baranov](https://github.com/vitlibar)) +- Added brotli support for HTTP interface for data import (INSERTs). [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([Mikhail](https://github.com/fandyushin)) +- Added hints while user make typo in function name or type in command line client. [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([Danila Kutenin](https://github.com/danlark1)) +- Added `Query-Id` to Server’s HTTP Response header. [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([Mikhail](https://github.com/fandyushin)) + +#### Experimental Features {#experimental-features-2} + +- Added `minmax` and `set` data skipping indices for MergeTree table engines family. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) +- Added conversion of `CROSS JOIN` to `INNER JOIN` if possible. [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Bug Fixes {#bug-fixes-17} + +- Fixed `Not found column` for duplicate columns in `JOIN ON` section. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) +- Make `START REPLICATED SENDS` command start replicated sends. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) +- Fixed aggregate functions execution with `Array(LowCardinality)` arguments. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Fixed wrong behaviour when doing `INSERT ... SELECT ... FROM file(...)` query and file has `CSVWithNames` or `TSVWIthNames` format and the first data row is missing. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed crash on dictionary reload if dictionary not available. This bug was appeared in 19.1.6. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) +- Fixed `ALL JOIN` with duplicates in right table. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed segmentation fault with `use_uncompressed_cache=1` and exception with wrong uncompressed size. This bug was appeared in 19.1.6. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([alesapin](https://github.com/alesapin)) +- Fixed `compile_expressions` bug with comparison of big (more than int16) dates. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([alesapin](https://github.com/alesapin)) +- Fixed infinite loop when selecting from table function `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Temporarily disable predicate optimization for `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([Winter Zhang](https://github.com/zhang2014)) +- Fixed `Illegal instruction` error when using base64 functions on old CPUs. This error has been reproduced only when ClickHouse was compiled with gcc-8. [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed `No message received` error when interacting with PostgreSQL ODBC Driver through TLS connection. Also fixes segfault when using MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed incorrect result when `Date` and `DateTime` arguments are used in branches of conditional operator (function `if`). Added generic case for function `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- ClickHouse dictionaries now load within `clickhouse` process. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed deadlock when `SELECT` from a table with `File` engine was retried after `No such file or directory` error. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed race condition when selecting from `system.tables` may give `table doesn't exist` error. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `clickhouse-client` can segfault on exit while loading data for command line suggestions if it was run in interactive mode. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed a bug when the execution of mutations containing `IN` operators was producing incorrect results. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fixed error: if there is a database with `Dictionary` engine, all dictionaries forced to load at server startup, and if there is a dictionary with ClickHouse source from localhost, the dictionary cannot load. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed error when system logs are tried to create again at server shutdown. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Correctly return the right type and properly handle locks in `joinGet` function. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([Amos Bird](https://github.com/amosbird)) +- Added `sumMapWithOverflow` function. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- Fixed segfault with `allow_experimental_multiple_joins_emulation`. [52de2c](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed bug with incorrect `Date` and `DateTime` comparison. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) +- Fixed fuzz test under undefined behavior sanitizer: added parameter type check for `quantile*Weighted` family of functions. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed rare race condition when removing of old data parts can fail with `File not found` error. [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix install package with missing /etc/clickhouse-server/config.xml. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-5} + +- Debian package: correct /etc/clickhouse-server/preprocessed link according to config. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) +- Various build fixes for FreeBSD. [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([proller](https://github.com/proller)) +- Added ability to create, fill and drop tables in perftest. [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([alesapin](https://github.com/alesapin)) +- Added a script to check for duplicate includes. [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added ability to run queries by index in performance test. [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([alesapin](https://github.com/alesapin)) +- Package with debug symbols is suggested to be installed. [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Refactoring of performance-test. Better logging and signals handling. [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([alesapin](https://github.com/alesapin)) +- Added docs to anonymized Yandex.Metrika datasets. [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([alesapin](https://github.com/alesapin)) +- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([Alex Zatelepin](https://github.com/ztlpn)) +- Added docs about two datasets in s3. [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([alesapin](https://github.com/alesapin)) +- Added script which creates changelog from pull requests description. [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([KochetovNicolai](https://github.com/KochetovNicolai)) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Added puppet module for ClickHouse. [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([Maxim Fedotov](https://github.com/MaxFedotov)) +- Added docs for a group of undocumented functions. [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([Winter Zhang](https://github.com/zhang2014)) +- ARM build fixes. [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([proller](https://github.com/proller)) ([proller](https://github.com/proller)) +- Dictionary tests now able to run from `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([proller](https://github.com/proller)) +- Now `/etc/ssl` is used as default directory with SSL certificates. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added checking SSE and AVX instruction at start. [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([Igr](https://github.com/igron99)) +- Init script will wait server until start. [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([proller](https://github.com/proller)) + +#### Backward Incompatible Changes {#backward-incompatible-changes-1} + +- Removed `allow_experimental_low_cardinality_type` setting. `LowCardinality` data types are production ready. [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Reduce mark cache size and uncompressed cache size accordingly to available memory amount. [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([Lopatin Konstantin](https://github.com/k-lopatin) +- Added keyword `INDEX` in `CREATE TABLE` query. A column with name `index` must be quoted with backticks or double quotes: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) +- `sumMap` now promote result type instead of overflow. The old `sumMap` behavior can be obtained by using `sumMapWithOverflow` function. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) + +#### Performance Improvements {#performance-improvements-4} + +- `std::sort` replaced by `pdqsort` for queries without `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([Evgenii Pravda](https://github.com/kvinty)) +- Now server reuse threads from global thread pool. This affects performance in some corner cases. [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Improvements {#improvements-5} + +- Implemented AIO support for FreeBSD. [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([urgordeadbeef](https://github.com/urgordeadbeef)) +- `SELECT * FROM a JOIN b USING a, b` now return `a` and `b` columns only from the left table. [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([Artem Zuikov](https://github.com/4ertus2)) +- Allow `-C` option of client to work as `-c` option. [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([syominsergey](https://github.com/syominsergey)) +- Now option `--password` used without value requires password from stdin. [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([BSD\_Conqueror](https://github.com/bsd-conqueror)) +- Added highlighting of unescaped metacharacters in string literals that contain `LIKE` expressions or regexps. [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added cancelling of HTTP read only queries if client socket goes away. [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([nvartolomei](https://github.com/nvartolomei)) +- Now server reports progress to keep client connections alive. [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([Ivan](https://github.com/abyss7)) +- Slightly better message with reason for OPTIMIZE query with `optimize_throw_if_noop` setting enabled. [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added support of `--version` option for clickhouse server. [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([Lopatin Konstantin](https://github.com/k-lopatin)) +- Added `--help/-h` option to `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([Yuriy Baranov](https://github.com/yurriy)) +- Added support for scalar subqueries with aggregate function state result. [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) +- Improved server shutdown time and ALTERs waiting time. [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added info about the replicated\_can\_become\_leader setting to system.replicas and add logging if the replica won’t try to become leader. [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([Alex Zatelepin](https://github.com/ztlpn)) + +## ClickHouse Release 19.1 {#clickhouse-release-19-1} + +### ClickHouse Release 19.1.14, 2019-03-14 {#clickhouse-release-19-1-14-2019-03-14} + +- Fixed error `Column ... queried more than once` that may happen if the setting `asterisk_left_columns_only` is set to 1 in case of using `GLOBAL JOIN` with `SELECT *` (rare case). The issue does not exist in 19.3 and newer. [6bac7d8d](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([Artem Zuikov](https://github.com/4ertus2)) + +### ClickHouse Release 19.1.13, 2019-03-12 {#clickhouse-release-19-1-13-2019-03-12} + +This release contains exactly the same set of patches as 19.3.7. + +### ClickHouse Release 19.1.10, 2019-03-03 {#clickhouse-release-19-1-10-2019-03-03} + +This release contains exactly the same set of patches as 19.3.6. + +## ClickHouse Release 19.1 {#clickhouse-release-19-1-1} + +### ClickHouse Release 19.1.9, 2019-02-21 {#clickhouse-release-19-1-9-2019-02-21} + +#### Bug Fixes {#bug-fixes-18} + +- Fixed backward incompatibility with old versions due to wrong implementation of `send_logs_level` setting. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed backward incompatibility of table function `remote` introduced with column comments. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.1.8, 2019-02-16 {#clickhouse-release-19-1-8-2019-02-16} + +#### Bug Fixes {#bug-fixes-19} + +- Fix install package with missing /etc/clickhouse-server/config.xml. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) + +## ClickHouse Release 19.1 {#clickhouse-release-19-1-2} + +### ClickHouse Release 19.1.7, 2019-02-15 {#clickhouse-release-19-1-7-2019-02-15} + +#### Bug Fixes {#bug-fixes-20} + +- Correctly return the right type and properly handle locks in `joinGet` function. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([Amos Bird](https://github.com/amosbird)) +- Fixed error when system logs are tried to create again at server shutdown. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed error: if there is a database with `Dictionary` engine, all dictionaries forced to load at server startup, and if there is a dictionary with ClickHouse source from localhost, the dictionary cannot load. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed a bug when the execution of mutations containing `IN` operators was producing incorrect results. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) +- `clickhouse-client` can segfault on exit while loading data for command line suggestions if it was run in interactive mode. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed race condition when selecting from `system.tables` may give `table doesn't exist` error. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed deadlock when `SELECT` from a table with `File` engine was retried after `No such file or directory` error. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed an issue: local ClickHouse dictionaries are loaded via TCP, but should load within process. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed `No message received` error when interacting with PostgreSQL ODBC Driver through TLS connection. Also fixes segfault when using MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Temporarily disable predicate optimization for `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([Winter Zhang](https://github.com/zhang2014)) +- Fixed infinite loop when selecting from table function `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed `compile_expressions` bug with comparison of big (more than int16) dates. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([alesapin](https://github.com/alesapin)) +- Fixed segmentation fault with `uncompressed_cache=1` and exception with wrong uncompressed size. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([alesapin](https://github.com/alesapin)) +- Fixed `ALL JOIN` with duplicates in right table. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) +- Fixed wrong behaviour when doing `INSERT ... SELECT ... FROM file(...)` query and file has `CSVWithNames` or `TSVWIthNames` format and the first data row is missing. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed aggregate functions execution with `Array(LowCardinality)` arguments. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Debian package: correct /etc/clickhouse-server/preprocessed link according to config. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) +- Fixed fuzz test under undefined behavior sanitizer: added parameter type check for `quantile*Weighted` family of functions. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Make `START REPLICATED SENDS` command start replicated sends. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) +- Fixed `Not found column` for duplicate columns in JOIN ON section. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) +- Now `/etc/ssl` is used as default directory with SSL certificates. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed crash on dictionary reload if dictionary not available. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) +- Fixed bug with incorrect `Date` and `DateTime` comparison. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) +- Fixed incorrect result when `Date` and `DateTime` arguments are used in branches of conditional operator (function `if`). Added generic case for function `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +### ClickHouse Release 19.1.6, 2019-01-24 {#clickhouse-release-19-1-6-2019-01-24} + +#### New Features {#new-features-7} + +- Custom per column compression codecs for tables. [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([alesapin](https://github.com/alesapin), [Winter Zhang](https://github.com/zhang2014), [Anatoly](https://github.com/Sindbag)) +- Added compression codec `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([alesapin](https://github.com/alesapin)) +- Allow to `ALTER` compression codecs. [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([alesapin](https://github.com/alesapin)) +- Added functions `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` for SQL standard compatibility. [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([Ivan Blinkov](https://github.com/blinkov)) +- Support for write in `HDFS` tables and `hdfs` table function. [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([alesapin](https://github.com/alesapin)) +- Added functions to search for multiple constant strings from big haystack: `multiPosition`, `multiSearch` ,`firstMatch` also with `-UTF8`, `-CaseInsensitive`, and `-CaseInsensitiveUTF8` variants. [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([Danila Kutenin](https://github.com/danlark1)) +- Pruning of unused shards if `SELECT` query filters by sharding key (setting `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([Gleb Kanterov](https://github.com/kanterov), [Ivan](https://github.com/abyss7)) +- Allow `Kafka` engine to ignore some number of parsing errors per block. [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([Ivan](https://github.com/abyss7)) +- Added support for `CatBoost` multiclass models evaluation. Function `modelEvaluate` returns tuple with per-class raw predictions for multiclass models. `libcatboostmodel.so` should be built with [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Added functions `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([Boris Granveaud](https://github.com/bgranvea)) +- Added hashing functions `xxHash64` and `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([filimonov](https://github.com/filimonov)) +- Added `gccMurmurHash` hashing function (GCC flavoured Murmur hash) which uses the same hash seed as [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([sundyli](https://github.com/sundy-li)) +- Added hashing functions `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([shangshujie365](https://github.com/shangshujie365)) +- Added table function `remoteSecure`. Function works as `remote`, but uses secure connection. [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([proller](https://github.com/proller)) + +#### Experimental Features {#experimental-features-3} + +- Added multiple JOINs emulation (`allow_experimental_multiple_joins_emulation` setting). [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([Artem Zuikov](https://github.com/4ertus2)) + +#### Bug Fixes {#bug-fixes-21} + +- Make `compiled_expression_cache_size` setting limited by default to lower memory consumption. [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([alesapin](https://github.com/alesapin)) +- Fix a bug that led to hangups in threads that perform ALTERs of Replicated tables and in the thread that updates configuration from ZooKeeper. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fixed a race condition when executing a distributed ALTER task. The race condition led to more than one replica trying to execute the task and all replicas except one failing with a ZooKeeper error. [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fix a bug when `from_zk` config elements weren’t refreshed after a request to ZooKeeper timed out. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fix bug with wrong prefix for IPv4 subnet masks. [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([alesapin](https://github.com/alesapin)) +- Fixed crash (`std::terminate`) in rare cases when a new thread cannot be created due to exhausted resources. [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix bug when in `remote` table function execution when wrong restrictions were used for in `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([alesapin](https://github.com/alesapin)) +- Fix a leak of netlink sockets. They were placed in a pool where they were never deleted and new sockets were created at the start of a new thread when all current sockets were in use. [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([Alex Zatelepin](https://github.com/ztlpn)) +- Fix bug with closing `/proc/self/fd` directory earlier than all fds were read from `/proc` after forking `odbc-bridge` subprocess. [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([alesapin](https://github.com/alesapin)) +- Fixed String to UInt monotonic conversion in case of usage String in primary key. [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([Winter Zhang](https://github.com/zhang2014)) +- Fixed error in calculation of integer conversion function monotonicity. [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed segfault in `arrayEnumerateUniq`, `arrayEnumerateDense` functions in case of some invalid arguments. [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fix UB in StorageMerge. [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([Amos Bird](https://github.com/amosbird)) +- Fixed segfault in functions `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed error: functions `round`, `floor`, `trunc`, `ceil` may return bogus result when executed on integer argument and large negative scale. [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed a bug induced by ‘kill query sync’ which leads to a core dump. [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([muVulDeePecker](https://github.com/fancyqlx)) +- Fix bug with long delay after empty replication queue. [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([alesapin](https://github.com/alesapin)) +- Fixed excessive memory usage in case of inserting into table with `LowCardinality` primary key. [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Fixed `LowCardinality` serialization for `Native` format in case of empty arrays. [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Fixed incorrect result while using distinct by single LowCardinality numeric column. [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Fixed specialized aggregation with LowCardinality key (in case when `compile` setting is enabled). [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Fix user and password forwarding for replicated tables queries. [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([alesapin](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) +- Fixed very rare race condition that can happen when listing tables in Dictionary database while reloading dictionaries. [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed incorrect result when HAVING was used with ROLLUP or CUBE. [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([Sam Chou](https://github.com/reflection)) +- Fixed column aliases for query with `JOIN ON` syntax and distributed tables. [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([Winter Zhang](https://github.com/zhang2014)) +- Fixed error in internal implementation of `quantileTDigest` (found by Artem Vakhrushev). This error never happens in ClickHouse and was relevant only for those who use ClickHouse codebase as a library directly. [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Improvements {#improvements-6} + +- Support for `IF NOT EXISTS` in `ALTER TABLE ADD COLUMN` statements along with `IF EXISTS` in `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([Boris Granveaud](https://github.com/bgranvea)) +- Function `parseDateTimeBestEffort`: support for formats `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` and similar. [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- `CapnProtoInputStream` now support jagged structures. [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) +- Usability improvement: added a check that server process is started from the data directory’s owner. Do not allow to start server from root if the data belongs to non-root user. [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([sergey-v-galtsev](https://github.com/sergey-v-galtsev)) +- Better logic of checking required columns during analysis of queries with JOINs. [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([Artem Zuikov](https://github.com/4ertus2)) +- Decreased the number of connections in case of large number of Distributed tables in a single server. [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([Winter Zhang](https://github.com/zhang2014)) +- Supported totals row for `WITH TOTALS` query for ODBC driver. [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([Maksim Koritckiy](https://github.com/nightweb)) +- Allowed to use `Enum`s as integers inside if function. [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([Ivan](https://github.com/abyss7)) +- Added `low_cardinality_allow_in_native_format` setting. If disabled, do not use `LowCadrinality` type in `Native` format. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Removed some redundant objects from compiled expressions cache to lower memory usage. [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([alesapin](https://github.com/alesapin)) +- Add check that `SET send_logs_level = 'value'` query accept appropriate value. [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([Sabyanin Maxim](https://github.com/s-mx)) +- Fixed data type check in type conversion functions. [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([Winter Zhang](https://github.com/zhang2014)) + +#### Performance Improvements {#performance-improvements-5} + +- Add a MergeTree setting `use_minimalistic_part_header_in_zookeeper`. If enabled, Replicated tables will store compact part metadata in a single part znode. This can dramatically reduce ZooKeeper snapshot size (especially if the tables have a lot of columns). Note that after enabling this setting you will not be able to downgrade to a version that doesn’t support it. [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([Alex Zatelepin](https://github.com/ztlpn)) +- Add an DFA-based implementation for functions `sequenceMatch` and `sequenceCount` in case pattern doesn’t contain time. [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- Performance improvement for integer numbers serialization. [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([Amos Bird](https://github.com/amosbird)) +- Zero left padding PODArray so that -1 element is always valid and zeroed. It’s used for branchless calculation of offsets. [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([Amos Bird](https://github.com/amosbird)) +- Reverted `jemalloc` version which lead to performance degradation. [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([alexey-milovidov](https://github.com/alexey-milovidov)) + +#### Backward Incompatible Changes {#backward-incompatible-changes-2} + +- Removed undocumented feature `ALTER MODIFY PRIMARY KEY` because it was superseded by the `ALTER MODIFY ORDER BY` command. [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([Alex Zatelepin](https://github.com/ztlpn)) +- Removed function `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Forbid using scalar subqueries with result of type `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([Ivan](https://github.com/abyss7)) + +#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-6} + +- Added support for PowerPC (`ppc64le`) build. [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([Danila Kutenin](https://github.com/danlark1)) +- Stateful functional tests are run on public available dataset. [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed error when the server cannot start with the `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` message within Docker or systemd-nspawn. [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Updated `rdkafka` library to v1.0.0-RC5. Used cppkafka instead of raw C interface. [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([Ivan](https://github.com/abyss7)) +- Updated `mariadb-client` library. Fixed one of issues found by UBSan. [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Some fixes for UBSan builds. [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added per-commit runs of tests with UBSan build. +- Added per-commit runs of PVS-Studio static analyzer. +- Fixed bugs found by PVS-Studio. [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed glibc compatibility issues. [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Move Docker images to 18.10 and add compatibility file for glibc \>= 2.28 [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([alesapin](https://github.com/alesapin)) +- Add env variable if user don’t want to chown directories in server Docker image. [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([alesapin](https://github.com/alesapin)) +- Enabled most of the warnings from `-Weverything` in clang. Enabled `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Added a few more warnings that are available only in clang 8. [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Link to `libLLVM` rather than to individual LLVM libs when using shared linking. [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([Orivej Desh](https://github.com/orivej)) +- Added sanitizer variables for test images. [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([alesapin](https://github.com/alesapin)) +- `clickhouse-server` debian package will recommend `libcap2-bin` package to use `setcap` tool for setting capabilities. This is optional. [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Improved compilation time, fixed includes. [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([proller](https://github.com/proller)) +- Added performance tests for hash functions. [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([filimonov](https://github.com/filimonov)) +- Fixed cyclic library dependences. [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([proller](https://github.com/proller)) +- Improved compilation with low available memory. [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([proller](https://github.com/proller)) +- Added test script to reproduce performance degradation in `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([alexey-milovidov](https://github.com/alexey-milovidov)) +- Fixed misspells in comments and string literals under `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([maiha](https://github.com/maiha)) +- Fixed typos in comments. [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([Evgenii Pravda](https://github.com/kvinty)) + +## [Changelog for 2018](./2018.md#clickhouse-release-18-16) {#changelog-for-2018} diff --git a/docs/en/whats-new/changelog/index.md b/docs/en/whats-new/changelog/index.md new file mode 100644 index 00000000000..c13441a8bd5 --- /dev/null +++ b/docs/en/whats-new/changelog/index.md @@ -0,0 +1,7 @@ +--- +toc_folder_title: Changelog +toc_priority: 74 +toc_title: '2020' +--- + +{% include "content/changelog.md" %} diff --git a/docs/en/whats_new/index.md b/docs/en/whats-new/index.md similarity index 100% rename from docs/en/whats_new/index.md rename to docs/en/whats-new/index.md diff --git a/docs/en/whats-new/roadmap.md b/docs/en/whats-new/roadmap.md new file mode 100644 index 00000000000..c2ebc5260e6 --- /dev/null +++ b/docs/en/whats-new/roadmap.md @@ -0,0 +1,16 @@ +--- +toc_priority: 74 +toc_title: Roadmap +--- + +# Roadmap {#roadmap} + +## Q2 2020 {#q2-2020} + +- Integration with external authentication services + +## Q3 2020 {#q3-2020} + +- Resource pools for more precise distribution of cluster capacity between users + +{## [Original article](https://clickhouse.tech/docs/en/roadmap/) ##} diff --git a/docs/en/whats_new/security_changelog.md b/docs/en/whats-new/security-changelog.md similarity index 100% rename from docs/en/whats_new/security_changelog.md rename to docs/en/whats-new/security-changelog.md diff --git a/docs/en/whats_new/changelog/2017.md b/docs/en/whats_new/changelog/2017.md deleted file mode 100644 index df632d72d83..00000000000 --- a/docs/en/whats_new/changelog/2017.md +++ /dev/null @@ -1,266 +0,0 @@ ---- -toc_priority: 79 -toc_title: '2017' ---- - -### ClickHouse release 1.1.54327, 2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} - -This release contains bug fixes for the previous release 1.1.54318: - -- Fixed bug with possible race condition in replication that could lead to data loss. This issue affects versions 1.1.54310 and 1.1.54318. If you use one of these versions with Replicated tables, the update is strongly recommended. This issue shows in logs in Warning messages like `Part ... from own log doesn't exist.` The issue is relevant even if you don’t see these messages in logs. - -### ClickHouse release 1.1.54318, 2017-11-30 {#clickhouse-release-1-1-54318-2017-11-30} - -This release contains bug fixes for the previous release 1.1.54310: - -- Fixed incorrect row deletions during merges in the SummingMergeTree engine -- Fixed a memory leak in unreplicated MergeTree engines -- Fixed performance degradation with frequent inserts in MergeTree engines -- Fixed an issue that was causing the replication queue to stop running -- Fixed rotation and archiving of server logs - -### ClickHouse release 1.1.54310, 2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} - -#### New features: {#new-features} - -- Custom partitioning key for the MergeTree family of table engines. -- [Kafka](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) table engine. -- Added support for loading [CatBoost](https://catboost.yandex/) models and applying them to data stored in ClickHouse. -- Added support for time zones with non-integer offsets from UTC. -- Added support for arithmetic operations with time intervals. -- The range of values for the Date and DateTime types is extended to the year 2105. -- Added the `CREATE MATERIALIZED VIEW x TO y` query (specifies an existing table for storing the data of a materialized view). -- Added the `ATTACH TABLE` query without arguments. -- The processing logic for Nested columns with names ending in -Map in a SummingMergeTree table was extracted to the sumMap aggregate function. You can now specify such columns explicitly. -- Max size of the IP trie dictionary is increased to 128M entries. -- Added the getSizeOfEnumType function. -- Added the sumWithOverflow aggregate function. -- Added support for the Cap’n Proto input format. -- You can now customize compression level when using the zstd algorithm. - -#### Backward incompatible changes: {#backward-incompatible-changes} - -- Creation of temporary tables with an engine other than Memory is not allowed. -- Explicit creation of tables with the View or MaterializedView engine is not allowed. -- During table creation, a new check verifies that the sampling key expression is included in the primary key. - -#### Bug fixes: {#bug-fixes} - -- Fixed hangups when synchronously inserting into a Distributed table. -- Fixed nonatomic adding and removing of parts in Replicated tables. -- Data inserted into a materialized view is not subjected to unnecessary deduplication. -- Executing a query to a Distributed table for which the local replica is lagging and remote replicas are unavailable does not result in an error anymore. -- Users don’t need access permissions to the `default` database to create temporary tables anymore. -- Fixed crashing when specifying the Array type without arguments. -- Fixed hangups when the disk volume containing server logs is full. -- Fixed an overflow in the toRelativeWeekNum function for the first week of the Unix epoch. - -#### Build improvements: {#build-improvements} - -- Several third-party libraries (notably Poco) were updated and converted to git submodules. - -### ClickHouse release 1.1.54304, 2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} - -#### New features: {#new-features-1} - -- TLS support in the native protocol (to enable, set `tcp_ssl_port` in `config.xml` ). - -#### Bug fixes: {#bug-fixes-1} - -- `ALTER` for replicated tables now tries to start running as soon as possible. -- Fixed crashing when reading data with the setting `preferred_block_size_bytes=0.` -- Fixed crashes of `clickhouse-client` when pressing `Page Down` -- Correct interpretation of certain complex queries with `GLOBAL IN` and `UNION ALL` -- `FREEZE PARTITION` always works atomically now. -- Empty POST requests now return a response with code 411. -- Fixed interpretation errors for expressions like `CAST(1 AS Nullable(UInt8)).` -- Fixed an error when reading `Array(Nullable(String))` columns from `MergeTree` tables. -- Fixed crashing when parsing queries like `SELECT dummy AS dummy, dummy AS b` -- Users are updated correctly with invalid `users.xml` -- Correct handling when an executable dictionary returns a non-zero response code. - -### ClickHouse release 1.1.54292, 2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} - -#### New features: {#new-features-2} - -- Added the `pointInPolygon` function for working with coordinates on a coordinate plane. -- Added the `sumMap` aggregate function for calculating the sum of arrays, similar to `SummingMergeTree`. -- Added the `trunc` function. Improved performance of the rounding functions (`round`, `floor`, `ceil`, `roundToExp2`) and corrected the logic of how they work. Changed the logic of the `roundToExp2` function for fractions and negative numbers. -- The ClickHouse executable file is now less dependent on the libc version. The same ClickHouse executable file can run on a wide variety of Linux systems. There is still a dependency when using compiled queries (with the setting `compile = 1` , which is not used by default). -- Reduced the time needed for dynamic compilation of queries. - -#### Bug fixes: {#bug-fixes-2} - -- Fixed an error that sometimes produced `part ... intersects previous part` messages and weakened replica consistency. -- Fixed an error that caused the server to lock up if ZooKeeper was unavailable during shutdown. -- Removed excessive logging when restoring replicas. -- Fixed an error in the UNION ALL implementation. -- Fixed an error in the concat function that occurred if the first column in a block has the Array type. -- Progress is now displayed correctly in the system.merges table. - -### ClickHouse release 1.1.54289, 2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} - -#### New features: {#new-features-3} - -- `SYSTEM` queries for server administration: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. -- Added functions for working with arrays: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. -- Added `root` and `identity` parameters for the ZooKeeper configuration. This allows you to isolate individual users on the same ZooKeeper cluster. -- Added aggregate functions `groupBitAnd`, `groupBitOr`, and `groupBitXor` (for compatibility, they are also available under the names `BIT_AND`, `BIT_OR`, and `BIT_XOR`). -- External dictionaries can be loaded from MySQL by specifying a socket in the filesystem. -- External dictionaries can be loaded from MySQL over SSL (`ssl_cert`, `ssl_key`, `ssl_ca` parameters). -- Added the `max_network_bandwidth_for_user` setting to restrict the overall bandwidth use for queries per user. -- Support for `DROP TABLE` for temporary tables. -- Support for reading `DateTime` values in Unix timestamp format from the `CSV` and `JSONEachRow` formats. -- Lagging replicas in distributed queries are now excluded by default (the default threshold is 5 minutes). -- FIFO locking is used during ALTER: an ALTER query isn’t blocked indefinitely for continuously running queries. -- Option to set `umask` in the config file. -- Improved performance for queries with `DISTINCT` . - -#### Bug fixes: {#bug-fixes-3} - -- Improved the process for deleting old nodes in ZooKeeper. Previously, old nodes sometimes didn’t get deleted if there were very frequent inserts, which caused the server to be slow to shut down, among other things. -- Fixed randomization when choosing hosts for the connection to ZooKeeper. -- Fixed the exclusion of lagging replicas in distributed queries if the replica is localhost. -- Fixed an error where a data part in a `ReplicatedMergeTree` table could be broken after running `ALTER MODIFY` on an element in a `Nested` structure. -- Fixed an error that could cause SELECT queries to “hang”. -- Improvements to distributed DDL queries. -- Fixed the query `CREATE TABLE ... AS `. -- Resolved the deadlock in the `ALTER ... CLEAR COLUMN IN PARTITION` query for `Buffer` tables. -- Fixed the invalid default value for `Enum` s (0 instead of the minimum) when using the `JSONEachRow` and `TSKV` formats. -- Resolved the appearance of zombie processes when using a dictionary with an `executable` source. -- Fixed segfault for the HEAD query. - -#### Improved workflow for developing and assembling ClickHouse: {#improved-workflow-for-developing-and-assembling-clickhouse} - -- You can use `pbuilder` to build ClickHouse. -- You can use `libc++` instead of `libstdc++` for builds on Linux. -- Added instructions for using static code analysis tools: `Coverage`, `clang-tidy`, `cppcheck`. - -#### Please note when upgrading: {#please-note-when-upgrading} - -- There is now a higher default value for the MergeTree setting `max_bytes_to_merge_at_max_space_in_pool` (the maximum total size of data parts to merge, in bytes): it has increased from 100 GiB to 150 GiB. This might result in large merges running after the server upgrade, which could cause an increased load on the disk subsystem. If the free space available on the server is less than twice the total amount of the merges that are running, this will cause all other merges to stop running, including merges of small data parts. As a result, INSERT queries will fail with the message “Merges are processing significantly slower than inserts.” Use the `SELECT * FROM system.merges` query to monitor the situation. You can also check the `DiskSpaceReservedForMerge` metric in the `system.metrics` table, or in Graphite. You don’t need to do anything to fix this, since the issue will resolve itself once the large merges finish. If you find this unacceptable, you can restore the previous value for the `max_bytes_to_merge_at_max_space_in_pool` setting. To do this, go to the section in config.xml, set ``` ``107374182400 ``` and restart the server. - -### ClickHouse release 1.1.54284, 2017-08-29 {#clickhouse-release-1-1-54284-2017-08-29} - -- This is a bugfix release for the previous 1.1.54282 release. It fixes leaks in the parts directory in ZooKeeper. - -### ClickHouse release 1.1.54282, 2017-08-23 {#clickhouse-release-1-1-54282-2017-08-23} - -This release contains bug fixes for the previous release 1.1.54276: - -- Fixed `DB::Exception: Assertion violation: !_path.empty()` when inserting into a Distributed table. -- Fixed parsing when inserting in RowBinary format if input data starts with’;’. -- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). - -### ClickHouse Release 1.1.54276, 2017-08-16 {#clickhouse-release-1-1-54276-2017-08-16} - -#### New features: {#new-features-4} - -- Added an optional WITH section for a SELECT query. Example query: `WITH 1+1 AS a SELECT a, a*a` -- INSERT can be performed synchronously in a Distributed table: OK is returned only after all the data is saved on all the shards. This is activated by the setting insert\_distributed\_sync=1. -- Added the UUID data type for working with 16-byte identifiers. -- Added aliases of CHAR, FLOAT and other types for compatibility with the Tableau. -- Added the functions toYYYYMM, toYYYYMMDD, and toYYYYMMDDhhmmss for converting time into numbers. -- You can use IP addresses (together with the hostname) to identify servers for clustered DDL queries. -- Added support for non-constant arguments and negative offsets in the function `substring(str, pos, len).` -- Added the max\_size parameter for the `groupArray(max_size)(column)` aggregate function, and optimized its performance. - -#### Main changes: {#main-changes} - -- Security improvements: all server files are created with 0640 permissions (can be changed via config parameter). -- Improved error messages for queries with invalid syntax. -- Significantly reduced memory consumption and improved performance when merging large sections of MergeTree data. -- Significantly increased the performance of data merges for the ReplacingMergeTree engine. -- Improved performance for asynchronous inserts from a Distributed table by combining multiple source inserts. To enable this functionality, use the setting distributed\_directory\_monitor\_batch\_inserts=1. - -#### Backward incompatible changes: {#backward-incompatible-changes-1} - -- Changed the binary format of aggregate states of `groupArray(array_column)` functions for arrays. - -#### Complete list of changes: {#complete-list-of-changes} - -- Added the `output_format_json_quote_denormals` setting, which enables outputting nan and inf values in JSON format. -- Optimized stream allocation when reading from a Distributed table. -- Settings can be configured in readonly mode if the value doesn’t change. -- Added the ability to retrieve non-integer granules of the MergeTree engine in order to meet restrictions on the block size specified in the preferred\_block\_size\_bytes setting. The purpose is to reduce the consumption of RAM and increase cache locality when processing queries from tables with large columns. -- Efficient use of indexes that contain expressions like `toStartOfHour(x)` for conditions like `toStartOfHour(x) op сonstexpr.` -- Added new settings for MergeTree engines (the merge\_tree section in config.xml): - - replicated\_deduplication\_window\_seconds sets the number of seconds allowed for deduplicating inserts in Replicated tables. - - cleanup\_delay\_period sets how often to start cleanup to remove outdated data. - - replicated\_can\_become\_leader can prevent a replica from becoming the leader (and assigning merges). -- Accelerated cleanup to remove outdated data from ZooKeeper. -- Multiple improvements and fixes for clustered DDL queries. Of particular interest is the new setting distributed\_ddl\_task\_timeout, which limits the time to wait for a response from the servers in the cluster. If a ddl request has not been performed on all hosts, a response will contain a timeout error and a request will be executed in an async mode. -- Improved display of stack traces in the server logs. -- Added the “none” value for the compression method. -- You can use multiple dictionaries\_config sections in config.xml. -- It is possible to connect to MySQL through a socket in the file system. -- The system.parts table has a new column with information about the size of marks, in bytes. - -#### Bug fixes: {#bug-fixes-4} - -- Distributed tables using a Merge table now work correctly for a SELECT query with a condition on the `_table` field. -- Fixed a rare race condition in ReplicatedMergeTree when checking data parts. -- Fixed possible freezing on “leader election” when starting a server. -- The max\_replica\_delay\_for\_distributed\_queries setting was ignored when using a local replica of the data source. This has been fixed. -- Fixed incorrect behavior of `ALTER TABLE CLEAR COLUMN IN PARTITION` when attempting to clean a non-existing column. -- Fixed an exception in the multiIf function when using empty arrays or strings. -- Fixed excessive memory allocations when deserializing Native format. -- Fixed incorrect auto-update of Trie dictionaries. -- Fixed an exception when running queries with a GROUP BY clause from a Merge table when using SAMPLE. -- Fixed a crash of GROUP BY when using distributed\_aggregation\_memory\_efficient=1. -- Now you can specify the database.table in the right side of IN and JOIN. -- Too many threads were used for parallel aggregation. This has been fixed. -- Fixed how the “if” function works with FixedString arguments. -- SELECT worked incorrectly from a Distributed table for shards with a weight of 0. This has been fixed. -- Running `CREATE VIEW IF EXISTS no longer causes crashes.` -- Fixed incorrect behavior when input\_format\_skip\_unknown\_fields=1 is set and there are negative numbers. -- Fixed an infinite loop in the `dictGetHierarchy()` function if there is some invalid data in the dictionary. -- Fixed `Syntax error: unexpected (...)` errors when running distributed queries with subqueries in an IN or JOIN clause and Merge tables. -- Fixed an incorrect interpretation of a SELECT query from Dictionary tables. -- Fixed the “Cannot mremap” error when using arrays in IN and JOIN clauses with more than 2 billion elements. -- Fixed the failover for dictionaries with MySQL as the source. - -#### Improved workflow for developing and assembling ClickHouse: {#improved-workflow-for-developing-and-assembling-clickhouse-1} - -- Builds can be assembled in Arcadia. -- You can use gcc 7 to compile ClickHouse. -- Parallel builds using ccache+distcc are faster now. - -### ClickHouse release 1.1.54245, 2017-07-04 {#clickhouse-release-1-1-54245-2017-07-04} - -#### New features: {#new-features-5} - -- Distributed DDL (for example, `CREATE TABLE ON CLUSTER`) -- The replicated query `ALTER TABLE CLEAR COLUMN IN PARTITION.` -- The engine for Dictionary tables (access to dictionary data in the form of a table). -- Dictionary database engine (this type of database automatically has Dictionary tables available for all the connected external dictionaries). -- You can check for updates to the dictionary by sending a request to the source. -- Qualified column names -- Quoting identifiers using double quotation marks. -- Sessions in the HTTP interface. -- The OPTIMIZE query for a Replicated table can can run not only on the leader. - -#### Backward incompatible changes: {#backward-incompatible-changes-2} - -- Removed SET GLOBAL. - -#### Minor changes: {#minor-changes} - -- Now after an alert is triggered, the log prints the full stack trace. -- Relaxed the verification of the number of damaged/extra data parts at startup (there were too many false positives). - -#### Bug fixes: {#bug-fixes-5} - -- Fixed a bad connection “sticking” when inserting into a Distributed table. -- GLOBAL IN now works for a query from a Merge table that looks at a Distributed table. -- The incorrect number of cores was detected on a Google Compute Engine virtual machine. This has been fixed. -- Changes in how an executable source of cached external dictionaries works. -- Fixed the comparison of strings containing null characters. -- Fixed the comparison of Float32 primary key fields with constants. -- Previously, an incorrect estimate of the size of a field could lead to overly large allocations. -- Fixed a crash when querying a Nullable column added to a table using ALTER. -- Fixed a crash when sorting by a Nullable column, if the number of rows is less than LIMIT. -- Fixed an ORDER BY subquery consisting of only constant values. -- Previously, a Replicated table could remain in the invalid state after a failed DROP TABLE. -- Aliases for scalar subqueries with empty results are no longer lost. -- Now a query that used compilation does not fail with an error if the .so file gets damaged. diff --git a/docs/en/whats_new/changelog/2018.md b/docs/en/whats_new/changelog/2018.md deleted file mode 100644 index 346c8d6b639..00000000000 --- a/docs/en/whats_new/changelog/2018.md +++ /dev/null @@ -1,1061 +0,0 @@ ---- -toc_priority: 78 -toc_title: '2018' ---- - -## ClickHouse release 18.16 {#clickhouse-release-18-16} - -### ClickHouse release 18.16.1, 2018-12-21 {#clickhouse-release-18-16-1-2018-12-21} - -#### Bug fixes: {#bug-fixes} - -- Fixed an error that led to problems with updating dictionaries with the ODBC source. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- JIT compilation of aggregate functions now works with LowCardinality columns. [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) - -#### Improvements: {#improvements} - -- Added the `low_cardinality_allow_in_native_format` setting (enabled by default). When disabled, LowCardinality columns will be converted to ordinary columns for SELECT queries and ordinary columns will be expected for INSERT queries. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) - -#### Build improvements: {#build-improvements} - -- Fixes for builds on macOS and ARM. - -### ClickHouse release 18.16.0, 2018-12-14 {#clickhouse-release-18-16-0-2018-12-14} - -#### New features: {#new-features} - -- `DEFAULT` expressions are evaluated for missing fields when loading data in semi-structured input formats (`JSONEachRow`, `TSKV`). The feature is enabled with the `insert_sample_with_metadata` setting. [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) -- The `ALTER TABLE` query now has the `MODIFY ORDER BY` action for changing the sorting key when adding or removing a table column. This is useful for tables in the `MergeTree` family that perform additional tasks when merging based on this sorting key, such as `SummingMergeTree`, `AggregatingMergeTree`, and so on. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) -- For tables in the `MergeTree` family, now you can specify a different sorting key (`ORDER BY`) and index (`PRIMARY KEY`). The sorting key can be longer than the index. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) -- Added the `hdfs` table function and the `HDFS` table engine for importing and exporting data to HDFS. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) -- Added functions for working with base64: `base64Encode`, `base64Decode`, `tryBase64Decode`. [Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3350) -- Now you can use a parameter to configure the precision of the `uniqCombined` aggregate function (select the number of HyperLogLog cells). [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) -- Added the `system.contributors` table that contains the names of everyone who made commits in ClickHouse. [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) -- Added the ability to omit the partition for the `ALTER TABLE ... FREEZE` query in order to back up all partitions at once. [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) -- Added `dictGet` and `dictGetOrDefault` functions that don’t require specifying the type of return value. The type is determined automatically from the dictionary description. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3564) -- Now you can specify comments for a column in the table description and change it using `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) -- Reading is supported for `Join` type tables with simple keys. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3728) -- Now you can specify the options `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join`, and `join_overflow_mode` when creating a `Join` type table. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3728) -- Added the `joinGet` function that allows you to use a `Join` type table like a dictionary. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3728) -- Added the `partition_key`, `sorting_key`, `primary_key`, and `sampling_key` columns to the `system.tables` table in order to provide information about table keys. [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- Added the `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key`, and `is_in_sampling_key` columns to the `system.columns` table. [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- Added the `min_time` and `max_time` columns to the `system.parts` table. These columns are populated when the partitioning key is an expression consisting of `DateTime` columns. [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) - -#### Bug fixes: {#bug-fixes-1} - -- Fixes and performance improvements for the `LowCardinality` data type. `GROUP BY` using `LowCardinality(Nullable(...))`. Getting the values of `extremes`. Processing high-order functions. `LEFT ARRAY JOIN`. Distributed `GROUP BY`. Functions that return `Array`. Execution of `ORDER BY`. Writing to `Distributed` tables (nicelulu). Backward compatibility for `INSERT` queries from old clients that implement the `Native` protocol. Support for `LowCardinality` for `JOIN`. Improved performance when working in a single stream. [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) -- Fixed how the `select_sequential_consistency` option works. Previously, when this setting was enabled, an incomplete result was sometimes returned after beginning to write to a new partition. [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) -- Databases are correctly specified when executing DDL `ON CLUSTER` queries and `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- Databases are correctly specified for subqueries inside a VIEW. [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) -- Fixed a bug in `PREWHERE` with `FINAL` for `VersionedCollapsingMergeTree`. [7167bfd7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) -- Now you can use `KILL QUERY` to cancel queries that have not started yet because they are waiting for the table to be locked. [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) -- Corrected date and time calculations if the clocks were moved back at midnight (this happens in Iran, and happened in Moscow from 1981 to 1983). Previously, this led to the time being reset a day earlier than necessary, and also caused incorrect formatting of the date and time in text format. [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) -- Fixed bugs in some cases of `VIEW` and subqueries that omit the database. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3521) -- Fixed a race condition when simultaneously reading from a `MATERIALIZED VIEW` and deleting a `MATERIALIZED VIEW` due to not locking the internal `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) -- Fixed the error `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) -- Fixed query processing when the `compile_expressions` option is enabled (it’s enabled by default). Nondeterministic constant expressions like the `now` function are no longer unfolded. [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) -- Fixed a crash when specifying a non-constant scale argument in `toDecimal32/64/128` functions. -- Fixed an error when trying to insert an array with `NULL` elements in the `Values` format into a column of type `Array` without `Nullable` (if `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) -- Fixed continuous error logging in `DDLWorker` if ZooKeeper is not available. [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) -- Fixed the return type for `quantile*` functions from `Date` and `DateTime` types of arguments. [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) -- Fixed the `WITH` clause if it specifies a simple alias without expressions. [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) -- Fixed processing of queries with named sub-queries and qualified column names when `enable_optimize_predicate_expression` is enabled. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3588) -- Fixed the error `Attempt to attach to nullptr thread group` when working with materialized views. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) -- Fixed a crash when passing certain incorrect arguments to the `arrayReverse` function. [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- Fixed the buffer overflow in the `extractURLParameter` function. Improved performance. Added correct processing of strings containing zero bytes. [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) -- Fixed buffer overflow in the `lowerUTF8` and `upperUTF8` functions. Removed the ability to execute these functions over `FixedString` type arguments. [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) -- Fixed a rare race condition when deleting `MergeTree` tables. [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) -- Fixed a race condition when reading from `Buffer` tables and simultaneously performing `ALTER` or `DROP` on the target tables. [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) -- Fixed a segfault if the `max_temporary_non_const_columns` limit was exceeded. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### Improvements: {#improvements-1} - -- The server does not write the processed configuration files to the `/etc/clickhouse-server/` directory. Instead, it saves them in the `preprocessed_configs` directory inside `path`. This means that the `/etc/clickhouse-server/` directory doesn’t have write access for the `clickhouse` user, which improves security. [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) -- The `min_merge_bytes_to_use_direct_io` option is set to 10 GiB by default. A merge that forms large parts of tables from the MergeTree family will be performed in `O_DIRECT` mode, which prevents excessive page cache eviction. [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) -- Accelerated server start when there is a very large number of tables. [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) -- Added a connection pool and HTTP `Keep-Alive` for connections between replicas. [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) -- If the query syntax is invalid, the `400 Bad Request` code is returned in the `HTTP` interface (500 was returned previously). [31bc680a](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) -- The `join_default_strictness` option is set to `ALL` by default for compatibility. [120e2cbe](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) -- Removed logging to `stderr` from the `re2` library for invalid or complex regular expressions. [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) -- Added for the `Kafka` table engine: checks for subscriptions before beginning to read from Kafka; the kafka\_max\_block\_size setting for the table. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) -- The `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32`, and `murmurHash3_64` functions now work for any number of arguments and for arguments in the form of tuples. [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) -- The `arrayReverse` function now works with any types of arrays. [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- Added an optional parameter: the slot size for the `timeSlots` function. [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/3724) -- For `FULL` and `RIGHT JOIN`, the `max_block_size` setting is used for a stream of non-joined data from the right table. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3699) -- Added the `--secure` command line parameter in `clickhouse-benchmark` and `clickhouse-performance-test` to enable TLS. [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) -- Type conversion when the structure of a `Buffer` type table does not match the structure of the destination table. [Vitaly Baranov](https://github.com/ClickHouse/ClickHouse/pull/3603) -- Added the `tcp_keep_alive_timeout` option to enable keep-alive packets after inactivity for the specified time interval. [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) -- Removed unnecessary quoting of values for the partition key in the `system.parts` table if it consists of a single column. [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) -- The modulo function works for `Date` and `DateTime` data types. [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) -- Added synonyms for the `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR`, and `MID` functions. [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) Some function names are case-insensitive for compatibility with the SQL standard. Added syntactic sugar `SUBSTRING(expr FROM start FOR length)` for compatibility with SQL. [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) -- Added the ability to `mlock` memory pages corresponding to `clickhouse-server` executable code to prevent it from being forced out of memory. This feature is disabled by default. [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) -- Improved performance when reading from `O_DIRECT` (with the `min_bytes_to_use_direct_io` option enabled). [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) -- Improved performance of the `dictGet...OrDefault` function for a constant key argument and a non-constant default argument. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3563) -- The `firstSignificantSubdomain` function now processes the domains `gov`, `mil`, and `edu`. [Igor Hatarist](https://github.com/ClickHouse/ClickHouse/pull/3601) Improved performance. [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) -- Ability to specify custom environment variables for starting `clickhouse-server` using the `SYS-V init.d` script by defining `CLICKHOUSE_PROGRAM_ENV` in `/etc/default/clickhouse`. - [Pavlo Bashynskyi](https://github.com/ClickHouse/ClickHouse/pull/3612) -- Correct return code for the clickhouse-server init script. [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) -- The `system.metrics` table now has the `VersionInteger` metric, and `system.build_options` has the added line `VERSION_INTEGER`, which contains the numeric form of the ClickHouse version, such as `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) -- Removed the ability to compare the `Date` type with a number to avoid potential errors like `date = 2018-12-17`, where quotes around the date are omitted by mistake. [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) -- Fixed the behavior of stateful functions like `rowNumberInAllBlocks`. They previously output a result that was one number larger due to starting during query analysis. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3729) -- If the `force_restore_data` file can’t be deleted, an error message is displayed. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3794) - -#### Build improvements: {#build-improvements-1} - -- Updated the `jemalloc` library, which fixes a potential memory leak. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3557) -- Profiling with `jemalloc` is enabled by default in order to debug builds. [2cc82f5c](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) -- Added the ability to run integration tests when only `Docker` is installed on the system. [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) -- Added the fuzz expression test in SELECT queries. [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) -- Added a stress test for commits, which performs functional tests in parallel and in random order to detect more race conditions. [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) -- Improved the method for starting clickhouse-server in a Docker image. [Elghazal Ahmed](https://github.com/ClickHouse/ClickHouse/pull/3663) -- For a Docker image, added support for initializing databases using files in the `/docker-entrypoint-initdb.d` directory. [Konstantin Lebedev](https://github.com/ClickHouse/ClickHouse/pull/3695) -- Fixes for builds on ARM. [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) - -#### Backward incompatible changes: {#backward-incompatible-changes} - -- Removed the ability to compare the `Date` type with a number. Instead of `toDate('2018-12-18') = 17883`, you must use explicit type conversion `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) - -## ClickHouse release 18.14 {#clickhouse-release-18-14} - -### ClickHouse release 18.14.19, 2018-12-19 {#clickhouse-release-18-14-19-2018-12-19} - -#### Bug fixes: {#bug-fixes-2} - -- Fixed an error that led to problems with updating dictionaries with the ODBC source. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- Databases are correctly specified when executing DDL `ON CLUSTER` queries. [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- Fixed a segfault if the `max_temporary_non_const_columns` limit was exceeded. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### Build improvements: {#build-improvements-2} - -- Fixes for builds on ARM. - -### ClickHouse release 18.14.18, 2018-12-04 {#clickhouse-release-18-14-18-2018-12-04} - -#### Bug fixes: {#bug-fixes-3} - -- Fixed error in `dictGet...` function for dictionaries of type `range`, if one of the arguments is constant and other is not. [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) -- Fixed error that caused messages `netlink: '...': attribute type 1 has an invalid length` to be printed in Linux kernel log, that was happening only on fresh enough versions of Linux kernel. [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) -- Fixed segfault in function `empty` for argument of `FixedString` type. [Daniel, Dao Quang Minh](https://github.com/ClickHouse/ClickHouse/pull/3703) -- Fixed excessive memory allocation when using large value of `max_query_size` setting (a memory chunk of `max_query_size` bytes was preallocated at once). [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) - -#### Build changes: {#build-changes} - -- Fixed build with LLVM/Clang libraries of version 7 from the OS packages (these libraries are used for runtime query compilation). [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### ClickHouse release 18.14.17, 2018-11-30 {#clickhouse-release-18-14-17-2018-11-30} - -#### Bug fixes: {#bug-fixes-4} - -- Fixed cases when the ODBC bridge process did not terminate with the main server process. [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) -- Fixed synchronous insertion into the `Distributed` table with a columns list that differs from the column list of the remote table. [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) -- Fixed a rare race condition that can lead to a crash when dropping a MergeTree table. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- Fixed a query deadlock in case when query thread creation fails with the `Resource temporarily unavailable` error. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- Fixed parsing of the `ENGINE` clause when the `CREATE AS table` syntax was used and the `ENGINE` clause was specified before the `AS table` (the error resulted in ignoring the specified engine). [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) - -### ClickHouse release 18.14.15, 2018-11-21 {#clickhouse-release-18-14-15-2018-11-21} - -#### Bug fixes: {#bug-fixes-5} - -- The size of memory chunk was overestimated while deserializing the column of type `Array(String)` that leads to “Memory limit exceeded” errors. The issue appeared in version 18.12.13. [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) - -### ClickHouse release 18.14.14, 2018-11-20 {#clickhouse-release-18-14-14-2018-11-20} - -#### Bug fixes: {#bug-fixes-6} - -- Fixed `ON CLUSTER` queries when cluster configured as secure (flag ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) - -#### Build changes: {#build-changes-1} - -- Fixed problems (llvm-7 from system, macos) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### ClickHouse release 18.14.13, 2018-11-08 {#clickhouse-release-18-14-13-2018-11-08} - -#### Bug fixes: {#bug-fixes-7} - -- Fixed the `Block structure mismatch in MergingSorted stream` error. [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) -- Fixed `ON CLUSTER` queries in case when secure connections were turned on in the cluster config (the `` flag). [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) -- Fixed an error in queries that used `SAMPLE`, `PREWHERE` and alias columns. [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) -- Fixed a rare `unknown compression method` error when the `min_bytes_to_use_direct_io` setting was enabled. [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) - -#### Performance improvements: {#performance-improvements} - -- Fixed performance regression of queries with `GROUP BY` of columns of UInt16 or Date type when executing on AMD EPYC processors. [Igor Lapko](https://github.com/ClickHouse/ClickHouse/pull/3512) -- Fixed performance regression of queries that process long strings. [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) - -#### Build improvements: {#build-improvements-3} - -- Improvements for simplifying the Arcadia build. [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) - -### ClickHouse release 18.14.12, 2018-11-02 {#clickhouse-release-18-14-12-2018-11-02} - -#### Bug fixes: {#bug-fixes-8} - -- Fixed a crash on joining two unnamed subqueries. [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) -- Fixed generating incorrect queries (with an empty `WHERE` clause) when querying external databases. [hotid](https://github.com/ClickHouse/ClickHouse/pull/3477) -- Fixed using an incorrect timeout value in ODBC dictionaries. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) - -### ClickHouse release 18.14.11, 2018-10-29 {#clickhouse-release-18-14-11-2018-10-29} - -#### Bug fixes: {#bug-fixes-9} - -- Fixed the error `Block structure mismatch in UNION stream: different number of columns` in LIMIT queries. [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) -- Fixed errors when merging data in tables containing arrays inside Nested structures. [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) -- Fixed incorrect query results if the `merge_tree_uniform_read_distribution` setting is disabled (it is enabled by default). [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) -- Fixed an error on inserts to a Distributed table in Native format. [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) - -### ClickHouse release 18.14.10, 2018-10-23 {#clickhouse-release-18-14-10-2018-10-23} - -- The `compile_expressions` setting (JIT compilation of expressions) is disabled by default. [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) -- The `enable_optimize_predicate_expression` setting is disabled by default. - -### ClickHouse release 18.14.9, 2018-10-16 {#clickhouse-release-18-14-9-2018-10-16} - -#### New features: {#new-features-1} - -- The `WITH CUBE` modifier for `GROUP BY` (the alternative syntax `GROUP BY CUBE(...)` is also available). [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) -- Added the `formatDateTime` function. [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2770) -- Added the `JDBC` table engine and `jdbc` table function (requires installing clickhouse-jdbc-bridge). [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) -- Added functions for working with the ISO week number: `toISOWeek`, `toISOYear`, `toStartOfISOYear`, and `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) -- Now you can use `Nullable` columns for `MySQL` and `ODBC` tables. [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- Nested data structures can be read as nested objects in `JSONEachRow` format. Added the `input_format_import_nested_json` setting. [Veloman Yunkan](https://github.com/ClickHouse/ClickHouse/pull/3144) -- Parallel processing is available for many `MATERIALIZED VIEW`s when inserting data. See the `parallel_view_processing` setting. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) -- Added the `SYSTEM FLUSH LOGS` query (forced log flushes to system tables such as `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) -- Now you can use pre-defined `database` and `table` macros when declaring `Replicated` tables. [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) -- Added the ability to read `Decimal` type values in engineering notation (indicating powers of ten). [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) - -#### Experimental features: {#experimental-features} - -- Optimization of the GROUP BY clause for `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) -- Optimized calculation of expressions for `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) - -#### Improvements: {#improvements-2} - -- Significantly reduced memory consumption for queries with `ORDER BY` and `LIMIT`. See the `max_bytes_before_remerge_sort` setting. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- In the absence of `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` is assumed. [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) -- Qualified asterisks work correctly in queries with `JOIN`. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3202) -- The `ODBC` table engine correctly chooses the method for quoting identifiers in the SQL dialect of a remote database. [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) -- The `compile_expressions` setting (JIT compilation of expressions) is enabled by default. -- Fixed behavior for simultaneous DROP DATABASE/TABLE IF EXISTS and CREATE DATABASE/TABLE IF NOT EXISTS. Previously, a `CREATE DATABASE ... IF NOT EXISTS` query could return the error message “File … already exists”, and the `CREATE TABLE ... IF NOT EXISTS` and `DROP TABLE IF EXISTS` queries could return `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) -- LIKE and IN expressions with a constant right half are passed to the remote server when querying from MySQL or ODBC tables. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- Comparisons with constant expressions in a WHERE clause are passed to the remote server when querying from MySQL and ODBC tables. Previously, only comparisons with constants were passed. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- Correct calculation of row width in the terminal for `Pretty` formats, including strings with hieroglyphs. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/3257). -- `ON CLUSTER` can be specified for `ALTER UPDATE` queries. -- Improved performance for reading data in `JSONEachRow` format. [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) -- Added synonyms for the `LENGTH` and `CHARACTER_LENGTH` functions for compatibility. The `CONCAT` function is no longer case-sensitive. [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) -- Added the `TIMESTAMP` synonym for the `DateTime` type. [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) -- There is always space reserved for query\_id in the server logs, even if the log line is not related to a query. This makes it easier to parse server text logs with third-party tools. -- Memory consumption by a query is logged when it exceeds the next level of an integer number of gigabytes. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- Added compatibility mode for the case when the client library that uses the Native protocol sends fewer columns by mistake than the server expects for the INSERT query. This scenario was possible when using the clickhouse-cpp library. Previously, this scenario caused the server to crash. [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) -- In a user-defined WHERE expression in `clickhouse-copier`, you can now use a `partition_key` alias (for additional filtering by source table partition). This is useful if the partitioning scheme changes during copying, but only changes slightly. [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) -- The workflow of the `Kafka` engine has been moved to a background thread pool in order to automatically reduce the speed of data reading at high loads. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- Support for reading `Tuple` and `Nested` values of structures like `struct` in the `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) -- The list of top-level domains for the `firstSignificantSubdomain` function now includes the domain `biz`. [decaseal](https://github.com/ClickHouse/ClickHouse/pull/3219) -- In the configuration of external dictionaries, `null_value` is interpreted as the value of the default data type. [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) -- Support for the `intDiv` and `intDivOrZero` functions for `Decimal`. [b48402e8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) -- Support for the `Date`, `DateTime`, `UUID`, and `Decimal` types as a key for the `sumMap` aggregate function. [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) -- Support for the `Decimal` data type in external dictionaries. [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) -- Support for the `Decimal` data type in `SummingMergeTree` tables. [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) -- Added specializations for `UUID` in `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) -- Reduced the number of `open` and `close` system calls when reading from a `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) -- A `TRUNCATE TABLE` query can be executed on any replica (the query is passed to the leader replica). [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/3375) - -#### Bug fixes: {#bug-fixes-10} - -- Fixed an issue with `Dictionary` tables for `range_hashed` dictionaries. This error occurred in version 18.12.17. [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) -- Fixed an error when loading `range_hashed` dictionaries (the message `Unsupported type Nullable (...)`). This error occurred in version 18.12.17. [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- Fixed errors in the `pointInPolygon` function due to the accumulation of inaccurate calculations for polygons with a large number of vertices located close to each other. [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) -- If after merging data parts, the checksum for the resulting part differs from the result of the same merge in another replica, the result of the merge is deleted and the data part is downloaded from the other replica (this is the correct behavior). But after downloading the data part, it couldn’t be added to the working set because of an error that the part already exists (because the data part was deleted with some delay after the merge). This led to cyclical attempts to download the same data. [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) -- Fixed incorrect calculation of total memory consumption by queries (because of incorrect calculation, the `max_memory_usage_for_all_queries` setting worked incorrectly and the `MemoryTracking` metric had an incorrect value). This error occurred in version 18.12.13. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) -- Fixed the functionality of `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` This error occurred in version 18.12.13. [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) -- Fixed unnecessary preparation of data structures for `JOIN`s on the server that initiates the query if the `JOIN` is only performed on remote servers. [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) -- Fixed bugs in the `Kafka` engine: deadlocks after exceptions when starting to read data, and locks upon completion [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- For `Kafka` tables, the optional `schema` parameter was not passed (the schema of the `Cap'n'Proto` format). [Vojtech Splichal](https://github.com/ClickHouse/ClickHouse/pull/3150) -- If the ensemble of ZooKeeper servers has servers that accept the connection but then immediately close it instead of responding to the handshake, ClickHouse chooses to connect another server. Previously, this produced the error `Cannot read all data. Bytes read: 0. Bytes expected: 4.` and the server couldn’t start. [8218cf3a](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) -- If the ensemble of ZooKeeper servers contains servers for which the DNS query returns an error, these servers are ignored. [17b8e209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) -- Fixed type conversion between `Date` and `DateTime` when inserting data in the `VALUES` format (if `input_format_values_interpret_expressions = 1`). Previously, the conversion was performed between the numerical value of the number of days in Unix Epoch time and the Unix timestamp, which led to unexpected results. [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) -- Corrected type conversion between `Decimal` and integer numbers. [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) -- Fixed errors in the `enable_optimize_predicate_expression` setting. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3231) -- Fixed a parsing error in CSV format with floating-point numbers if a non-default CSV separator is used, such as `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) -- Fixed the `arrayCumSumNonNegative` function (it does not accumulate negative values if the accumulator is less than zero). [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/3163) -- Fixed how `Merge` tables work on top of `Distributed` tables when using `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) -- Bug fixes in the `ALTER UPDATE` query. -- Fixed bugs in the `odbc` table function that appeared in version 18.12. [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) -- Fixed the operation of aggregate functions with `StateArray` combinators. [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) -- Fixed a crash when dividing a `Decimal` value by zero. [69dd6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) -- Fixed output of types for operations using `Decimal` and integer arguments. [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) -- Fixed the segfault during `GROUP BY` on `Decimal128`. [3359ba06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) -- The `log_query_threads` setting (logging information about each thread of query execution) now takes effect only if the `log_queries` option (logging information about queries) is set to 1. Since the `log_query_threads` option is enabled by default, information about threads was previously logged even if query logging was disabled. [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) -- Fixed an error in the distributed operation of the quantiles aggregate function (the error message `Not found column quantile...`). [292a8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) -- Fixed the compatibility problem when working on a cluster of version 18.12.17 servers and older servers at the same time. For distributed queries with GROUP BY keys of both fixed and non-fixed length, if there was a large amount of data to aggregate, the returned data was not always fully aggregated (two different rows contained the same aggregation keys). [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) -- Fixed handling of substitutions in `clickhouse-performance-test`, if the query contains only part of the substitutions declared in the test. [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) -- Fixed an error when using `FINAL` with `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- Fixed an error when using `PREWHERE` over columns that were added during `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- Added a check for the absence of `arrayJoin` for `DEFAULT` and `MATERIALIZED` expressions. Previously, `arrayJoin` led to an error when inserting data. [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) -- Added a check for the absence of `arrayJoin` in a `PREWHERE` clause. Previously, this led to messages like `Size ... doesn't match` or `Unknown compression method` when executing queries. [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) -- Fixed segfault that could occur in rare cases after optimization that replaced AND chains from equality evaluations with the corresponding IN expression. [liuyimin-bytedance](https://github.com/ClickHouse/ClickHouse/pull/3339) -- Minor corrections to `clickhouse-benchmark`: previously, client information was not sent to the server; now the number of queries executed is calculated more accurately when shutting down and for limiting the number of iterations. [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) - -#### Backward incompatible changes: {#backward-incompatible-changes-1} - -- Removed the `allow_experimental_decimal_type` option. The `Decimal` data type is available for default use. [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) - -## ClickHouse release 18.12 {#clickhouse-release-18-12} - -### ClickHouse release 18.12.17, 2018-09-16 {#clickhouse-release-18-12-17-2018-09-16} - -#### New features: {#new-features-2} - -- `invalidate_query` (the ability to specify a query to check whether an external dictionary needs to be updated) is implemented for the `clickhouse` source. [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) -- Added the ability to use `UInt*`, `Int*`, and `DateTime` data types (along with the `Date` type) as a `range_hashed` external dictionary key that defines the boundaries of ranges. Now `NULL` can be used to designate an open range. [Vasily Nemkov](https://github.com/ClickHouse/ClickHouse/pull/3123) -- The `Decimal` type now supports `var*` and `stddev*` aggregate functions. [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- The `Decimal` type now supports mathematical functions (`exp`, `sin` and so on.) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- The `system.part_log` table now has the `partition_id` column. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### Bug fixes: {#bug-fixes-11} - -- `Merge` now works correctly on `Distributed` tables. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3159) -- Fixed incompatibility (unnecessary dependency on the `glibc` version) that made it impossible to run ClickHouse on `Ubuntu Precise` and older versions. The incompatibility arose in version 18.12.13. [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) -- Fixed errors in the `enable_optimize_predicate_expression` setting. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3107) -- Fixed a minor issue with backwards compatibility that appeared when working with a cluster of replicas on versions earlier than 18.12.13 and simultaneously creating a new replica of a table on a server with a newer version (shown in the message `Can not clone replica, because the ... updated to new ClickHouse version`, which is logical, but shouldn’t happen). [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) - -#### Backward incompatible changes: {#backward-incompatible-changes-2} - -- The `enable_optimize_predicate_expression` option is enabled by default (which is rather optimistic). If query analysis errors occur that are related to searching for the column names, set `enable_optimize_predicate_expression` to 0. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3107) - -### ClickHouse release 18.12.14, 2018-09-13 {#clickhouse-release-18-12-14-2018-09-13} - -#### New features: {#new-features-3} - -- Added support for `ALTER UPDATE` queries. [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) -- Added the `allow_ddl` option, which restricts the user’s access to DDL queries. [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) -- Added the `min_merge_bytes_to_use_direct_io` option for `MergeTree` engines, which allows you to set a threshold for the total size of the merge (when above the threshold, data part files will be handled using O\_DIRECT). [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) -- The `system.merges` system table now contains the `partition_id` column. [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) - -#### Improvements {#improvements-3} - -- If a data part remains unchanged during mutation, it isn’t downloaded by replicas. [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) -- Autocomplete is available for names of settings when working with `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) - -#### Bug fixes: {#bug-fixes-12} - -- Added a check for the sizes of arrays that are elements of `Nested` type fields when inserting. [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) -- Fixed an error updating external dictionaries with the `ODBC` source and `hashed` storage. This error occurred in version 18.12.13. -- Fixed a crash when creating a temporary table from a query with an `IN` condition. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3098) -- Fixed an error in aggregate functions for arrays that can have `NULL` elements. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/3097) - -### ClickHouse release 18.12.13, 2018-09-10 {#clickhouse-release-18-12-13-2018-09-10} - -#### New features: {#new-features-4} - -- Added the `DECIMAL(digits, scale)` data type (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). To enable it, use the setting `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) -- New `WITH ROLLUP` modifier for `GROUP BY` (alternative syntax: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) -- In queries with JOIN, the star character expands to a list of columns in all tables, in compliance with the SQL standard. You can restore the old behavior by setting `asterisk_left_columns_only` to 1 on the user configuration level. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2787) -- Added support for JOIN with table functions. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2907) -- Autocomplete by pressing Tab in clickhouse-client. [Sergey Shcherbin](https://github.com/ClickHouse/ClickHouse/pull/2447) -- Ctrl+C in clickhouse-client clears a query that was entered. [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) -- Added the `join_default_strictness` setting (values: `"`, `'any'`, `'all'`). This allows you to not specify `ANY` or `ALL` for `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) -- Each line of the server log related to query processing shows the query ID. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- Now you can get query execution logs in clickhouse-client (use the `send_logs_level` setting). With distributed query processing, logs are cascaded from all the servers. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- The `system.query_log` and `system.processes` (`SHOW PROCESSLIST`) tables now have information about all changed settings when you run a query (the nested structure of the `Settings` data). Added the `log_query_settings` setting. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- The `system.query_log` and `system.processes` tables now show information about the number of threads that are participating in query execution (see the `thread_numbers` column). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- Added `ProfileEvents` counters that measure the time spent on reading and writing over the network and reading and writing to disk, the number of network errors, and the time spent waiting when network bandwidth is limited. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- Added `ProfileEvents`counters that contain the system metrics from rusage (you can use them to get information about CPU usage in userspace and the kernel, page faults, and context switches), as well as taskstats metrics (use these to obtain information about I/O wait time, CPU wait time, and the amount of data read and recorded, both with and without page cache). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- The `ProfileEvents` counters are applied globally and for each query, as well as for each query execution thread, which allows you to profile resource consumption by query in detail. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- Added the `system.query_thread_log` table, which contains information about each query execution thread. Added the `log_query_threads` setting. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- The `system.metrics` and `system.events` tables now have built-in documentation. [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) -- Added the `arrayEnumerateDense` function. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2975) -- Added the `arrayCumSumNonNegative` and `arrayDifference` functions. [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/2942) -- Added the `retention` aggregate function. [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2887) -- Now you can add (merge) states of aggregate functions by using the plus operator, and multiply the states of aggregate functions by a nonnegative constant. [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) -- Tables in the MergeTree family now have the virtual column `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### Experimental features: {#experimental-features-1} - -- Added the `LowCardinality(T)` data type. This data type automatically creates a local dictionary of values and allows data processing without unpacking the dictionary. [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) -- Added a cache of JIT-compiled functions and a counter for the number of uses before compiling. To JIT compile expressions, enable the `compile_expressions` setting. [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) - -#### Improvements: {#improvements-4} - -- Fixed the problem with unlimited accumulation of the replication log when there are abandoned replicas. Added an effective recovery mode for replicas with a long lag. -- Improved performance of `GROUP BY` with multiple aggregation fields when one of them is string and the others are fixed length. -- Improved performance when using `PREWHERE` and with implicit transfer of expressions in `PREWHERE`. -- Improved parsing performance for text formats (`CSV`, `TSV`). [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) -- Improved performance of reading strings and arrays in binary formats. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2955) -- Increased performance and reduced memory consumption for queries to `system.tables` and `system.columns` when there is a very large number of tables on a single server. [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) -- Fixed a performance problem in the case of a large stream of queries that result in an error (the `_dl_addr` function is visible in `perf top`, but the server isn’t using much CPU). [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) -- Conditions are cast into the View (when `enable_optimize_predicate_expression` is enabled). [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2907) -- Improvements to the functionality for the `UUID` data type. [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) -- The `UUID` data type is supported in The-Alchemist dictionaries. [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) -- The `visitParamExtractRaw` function works correctly with nested structures. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2974) -- When the `input_format_skip_unknown_fields` setting is enabled, object fields in `JSONEachRow` format are skipped correctly. [BlahGeek](https://github.com/ClickHouse/ClickHouse/pull/2958) -- For a `CASE` expression with conditions, you can now omit `ELSE`, which is equivalent to `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) -- The operation timeout can now be configured when working with ZooKeeper. [urykhy](https://github.com/ClickHouse/ClickHouse/pull/2971) -- You can specify an offset for `LIMIT n, m` as `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- You can use the `SELECT TOP n` syntax as an alternative for `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- Increased the size of the queue to write to system tables, so the `SystemLog parameter queue is full` error doesn’t happen as often. -- The `windowFunnel` aggregate function now supports events that meet multiple conditions. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2801) -- Duplicate columns can be used in a `USING` clause for `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) -- `Pretty` formats now have a limit on column alignment by width. Use the `output_format_pretty_max_column_pad_width` setting. If a value is wider, it will still be displayed in its entirety, but the other cells in the table will not be too wide. [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) -- The `odbc` table function now allows you to specify the database/schema name. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2885) -- Added the ability to use a username specified in the `clickhouse-client` config file. [Vladimir Kozbin](https://github.com/ClickHouse/ClickHouse/pull/2909) -- The `ZooKeeperExceptions` counter has been split into three counters: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions`, and `ZooKeeperOtherExceptions`. -- `ALTER DELETE` queries work for materialized views. -- Added randomization when running the cleanup thread periodically for `ReplicatedMergeTree` tables in order to avoid periodic load spikes when there are a very large number of `ReplicatedMergeTree` tables. -- Support for `ATTACH TABLE ... ON CLUSTER` queries. [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) - -#### Bug fixes: {#bug-fixes-13} - -- Fixed an issue with `Dictionary` tables (throws the `Size of offsets doesn't match size of column` or `Unknown compression method` exception). This bug appeared in version 18.10.3. [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) -- Fixed a bug when merging `CollapsingMergeTree` tables if one of the data parts is empty (these parts are formed during merge or `ALTER DELETE` if all data was deleted), and the `vertical` algorithm was used for the merge. [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) -- Fixed a race condition during `DROP` or `TRUNCATE` for `Memory` tables with a simultaneous `SELECT`, which could lead to server crashes. This bug appeared in version 1.1.54388. [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) -- Fixed the possibility of data loss when inserting in `Replicated` tables if the `Session is expired` error is returned (data loss can be detected by the `ReplicatedDataLoss` metric). This error occurred in version 1.1.54378. [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) -- Fixed a segfault during `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) -- Fixed the error searching column names when the `WHERE` expression consists entirely of a qualified column name, such as `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) -- Fixed the “Not found column” error that occurred when executing distributed queries if a single column consisting of an IN expression with a subquery is requested from a remote server. [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) -- Fixed the `Block structure mismatch in UNION stream: different number of columns` error that occurred for distributed queries if one of the shards is local and the other is not, and optimization of the move to `PREWHERE` is triggered. [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) -- Fixed the `pointInPolygon` function for certain cases of non-convex polygons. [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) -- Fixed the incorrect result when comparing `nan` with integers. [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) -- Fixed an error in the `zlib-ng` library that could lead to segfault in rare cases. [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) -- Fixed a memory leak when inserting into a table with `AggregateFunction` columns, if the state of the aggregate function is not simple (allocates memory separately), and if a single insertion request results in multiple small blocks. [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) -- Fixed a race condition when creating and deleting the same `Buffer` or `MergeTree` table simultaneously. -- Fixed the possibility of a segfault when comparing tuples made up of certain non-trivial types, such as tuples. [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) -- Fixed the possibility of a segfault when running certain `ON CLUSTER` queries. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2960) -- Fixed an error in the `arrayDistinct` function for `Nullable` array elements. [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) -- The `enable_optimize_predicate_expression` option now correctly supports cases with `SELECT *`. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2929) -- Fixed the segfault when re-initializing the ZooKeeper session. [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) -- Fixed potential blocking when working with ZooKeeper. -- Fixed incorrect code for adding nested data structures in a `SummingMergeTree`. -- When allocating memory for states of aggregate functions, alignment is correctly taken into account, which makes it possible to use operations that require alignment when implementing states of aggregate functions. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) - -#### Security fix: {#security-fix} - -- Safe use of ODBC data sources. Interaction with ODBC drivers uses a separate `clickhouse-odbc-bridge` process. Errors in third-party ODBC drivers no longer cause problems with server stability or vulnerabilities. [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) -- Fixed incorrect validation of the file path in the `catBoostPool` table function. [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) -- The contents of system tables (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas`, and `replication_queue`) are filtered according to the user’s configured access to databases (`allow_databases`). [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2856) - -#### Backward incompatible changes: {#backward-incompatible-changes-3} - -- In queries with JOIN, the star character expands to a list of columns in all tables, in compliance with the SQL standard. You can restore the old behavior by setting `asterisk_left_columns_only` to 1 on the user configuration level. - -#### Build changes: {#build-changes-2} - -- Most integration tests can now be run by commit. -- Code style checks can also be run by commit. -- The `memcpy` implementation is chosen correctly when building on CentOS7/Fedora. [Etienne Champetier](https://github.com/ClickHouse/ClickHouse/pull/2912) -- When using clang to build, some warnings from `-Weverything` have been added, in addition to the regular `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) -- Debugging the build uses the `jemalloc` debug option. -- The interface of the library for interacting with ZooKeeper is declared abstract. [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) - -## ClickHouse release 18.10 {#clickhouse-release-18-10} - -### ClickHouse release 18.10.3, 2018-08-13 {#clickhouse-release-18-10-3-2018-08-13} - -#### New features: {#new-features-5} - -- HTTPS can be used for replication. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) -- Added the functions `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64`, and `murmurHash3_128` in addition to the existing `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) -- Support for Nullable types in the ClickHouse ODBC driver (`ODBCDriver2` output format). [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) -- Support for `UUID` in the key columns. - -#### Improvements: {#improvements-5} - -- Clusters can be removed without restarting the server when they are deleted from the config files. [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) -- External dictionaries can be removed without restarting the server when they are removed from config files. [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) -- Added `SETTINGS` support for the `Kafka` table engine. [Alexander Marshalov](https://github.com/ClickHouse/ClickHouse/pull/2781) -- Improvements for the `UUID` data type (not yet complete). [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) -- Support for empty parts after merges in the `SummingMergeTree`, `CollapsingMergeTree` and `VersionedCollapsingMergeTree` engines. [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) -- Old records of completed mutations are deleted (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) -- Added the `system.merge_tree_settings` table. [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/2841) -- The `system.tables` table now has dependency columns: `dependencies_database` and `dependencies_table`. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2851) -- Added the `max_partition_size_to_drop` config option. [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) -- Added the `output_format_json_escape_forward_slashes` option. [Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2812) -- Added the `max_fetch_partition_retries_count` setting. [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) -- Added the `prefer_localhost_replica` setting for disabling the preference for a local replica and going to a local replica without inter-process interaction. [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) -- The `quantileExact` aggregate function returns `nan` in the case of aggregation on an empty `Float32` or `Float64` set. [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2855) - -#### Bug fixes: {#bug-fixes-14} - -- Removed unnecessary escaping of the connection string parameters for ODBC, which made it impossible to establish a connection. This error occurred in version 18.6.0. -- Fixed the logic for processing `REPLACE PARTITION` commands in the replication queue. If there are two `REPLACE` commands for the same partition, the incorrect logic could cause one of them to remain in the replication queue and not be executed. [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) -- Fixed a merge bug when all data parts were empty (parts that were formed from a merge or from `ALTER DELETE` if all data was deleted). This bug appeared in version 18.1.0. [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) -- Fixed an error for concurrent `Set` or `Join`. [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2823) -- Fixed the `Block structure mismatch in UNION stream: different number of columns` error that occurred for `UNION ALL` queries inside a sub-query if one of the `SELECT` queries contains duplicate column names. [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2094) -- Fixed a memory leak if an exception occurred when connecting to a MySQL server. -- Fixed incorrect clickhouse-client response code in case of a query error. -- Fixed incorrect behavior of materialized views containing DISTINCT. [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) - -#### Backward incompatible changes {#backward-incompatible-changes-4} - -- Removed support for CHECK TABLE queries for Distributed tables. - -#### Build changes: {#build-changes-3} - -- The allocator has been replaced: `jemalloc` is now used instead of `tcmalloc`. In some scenarios, this increases speed up to 20%. However, there are queries that have slowed by up to 20%. Memory consumption has been reduced by approximately 10% in some scenarios, with improved stability. With highly competitive loads, CPU usage in userspace and in system shows just a slight increase. [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) -- Use of libressl from a submodule. [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) -- Use of unixodbc from a submodule. [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) -- Use of mariadb-connector-c from a submodule. [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) -- Added functional test files to the repository that depend on the availability of test data (for the time being, without the test data itself). - -## ClickHouse release 18.6 {#clickhouse-release-18-6} - -### ClickHouse release 18.6.0, 2018-08-02 {#clickhouse-release-18-6-0-2018-08-02} - -#### New features: {#new-features-6} - -- Added support for ON expressions for the JOIN ON syntax: - `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` - The expression must be a chain of equalities joined by the AND operator. Each side of the equality can be an arbitrary expression over the columns of one of the tables. The use of fully qualified column names is supported (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`) for the right table. [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) -- HTTPS can be enabled for replication. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) - -#### Improvements: {#improvements-6} - -- The server passes the patch component of its version to the client. Data about the patch version component is in `system.processes` and `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) - -## ClickHouse release 18.5 {#clickhouse-release-18-5} - -### ClickHouse release 18.5.1, 2018-07-31 {#clickhouse-release-18-5-1-2018-07-31} - -#### New features: {#new-features-7} - -- Added the hash function `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). - -#### Improvements: {#improvements-7} - -- Now you can use the `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) attribute to set values in config files from environment variables. -- Added case-insensitive versions of the `coalesce`, `ifNull`, and `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). - -#### Bug fixes: {#bug-fixes-15} - -- Fixed a possible bug when starting a replica [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). - -## ClickHouse release 18.4 {#clickhouse-release-18-4} - -### ClickHouse release 18.4.0, 2018-07-28 {#clickhouse-release-18-4-0-2018-07-28} - -#### New features: {#new-features-8} - -- Added system tables: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). -- Added the ability to use a table function instead of a table as an argument of a `remote` or `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). -- Support for `HTTP Basic` authentication in the replication protocol [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). -- The `has` function now allows searching for a numeric value in an array of `Enum` values [Maxim Khrisanfov](https://github.com/ClickHouse/ClickHouse/pull/2699). -- Support for adding arbitrary message separators when reading from `Kafka` [Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2701). - -#### Improvements: {#improvements-8} - -- The `ALTER TABLE t DELETE WHERE` query does not rewrite data parts that were not affected by the WHERE condition [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). -- The `use_minimalistic_checksums_in_zookeeper` option for `ReplicatedMergeTree` tables is enabled by default. This setting was added in version 1.1.54378, 2018-04-16. Versions that are older than 1.1.54378 can no longer be installed. -- Support for running `KILL` and `OPTIMIZE` queries that specify `ON CLUSTER` [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2689). - -#### Bug fixes: {#bug-fixes-16} - -- Fixed the error `Column ... is not under an aggregate function and not in GROUP BY` for aggregation with an IN expression. This bug appeared in version 18.1.0. ([bbdd780b](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) -- Fixed a bug in the `windowFunnel aggregate function` [Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2735). -- Fixed a bug in the `anyHeavy` aggregate function ([a2101df2](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) -- Fixed server crash when using the `countArray()` aggregate function. - -#### Backward incompatible changes: {#backward-incompatible-changes-5} - -- Parameters for `Kafka` engine was changed from `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` to `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. If your tables use `kafka_schema` or `kafka_num_consumers` parameters, you have to manually edit the metadata files `path/metadata/database/table.sql` and add `kafka_row_delimiter` parameter with `''` value. - -## ClickHouse release 18.1 {#clickhouse-release-18-1} - -### ClickHouse release 18.1.0, 2018-07-23 {#clickhouse-release-18-1-0-2018-07-23} - -#### New features: {#new-features-9} - -- Support for the `ALTER TABLE t DELETE WHERE` query for non-replicated MergeTree tables ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). -- Support for arbitrary types for the `uniq*` family of aggregate functions ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). -- Support for arbitrary types in comparison operators ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). -- The `users.xml` file allows setting a subnet mask in the format `10.0.0.1/255.255.255.0`. This is necessary for using masks for IPv6 networks with zeros in the middle ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). -- Added the `arrayDistinct` function ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). -- The SummingMergeTree engine can now work with AggregateFunction type columns ([Constantin S. Pan](https://github.com/ClickHouse/ClickHouse/pull/2566)). - -#### Improvements: {#improvements-9} - -- Changed the numbering scheme for release versions. Now the first part contains the year of release (A.D., Moscow timezone, minus 2000), the second part contains the number for major changes (increases for most releases), and the third part is the patch version. Releases are still backward compatible, unless otherwise stated in the changelog. -- Faster conversions of floating-point numbers to a string ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2664)). -- If some rows were skipped during an insert due to parsing errors (this is possible with the `input_allow_errors_num` and `input_allow_errors_ratio` settings enabled), the number of skipped rows is now written to the server log ([Leonardo Cecchi](https://github.com/ClickHouse/ClickHouse/pull/2669)). - -#### Bug fixes: {#bug-fixes-17} - -- Fixed the TRUNCATE command for temporary tables ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2624)). -- Fixed a rare deadlock in the ZooKeeper client library that occurred when there was a network error while reading the response ([c315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). -- Fixed an error during a CAST to Nullable types ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). -- Fixed the incorrect result of the `maxIntersection()` function when the boundaries of intervals coincided ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2657)). -- Fixed incorrect transformation of the OR expression chain in a function argument ([chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). -- Fixed performance degradation for queries containing `IN (subquery)` expressions inside another subquery ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). -- Fixed incompatibility between servers with different versions in distributed queries that use a `CAST` function that isn’t in uppercase letters ([fe8c4d6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). -- Added missing quoting of identifiers for queries to an external DBMS ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). - -#### Backward incompatible changes: {#backward-incompatible-changes-6} - -- Converting a string containing the number zero to DateTime does not work. Example: `SELECT toDateTime('0')`. This is also the reason that `DateTime DEFAULT '0'` does not work in tables, as well as `0` in dictionaries. Solution: replace `0` with `0000-00-00 00:00:00`. - -## ClickHouse release 1.1 {#clickhouse-release-1-1} - -### ClickHouse release 1.1.54394, 2018-07-12 {#clickhouse-release-1-1-54394-2018-07-12} - -#### New features: {#new-features-10} - -- Added the `histogram` aggregate function ([Mikhail Surin](https://github.com/ClickHouse/ClickHouse/pull/2521)). -- Now `OPTIMIZE TABLE ... FINAL` can be used without specifying partitions for `ReplicatedMergeTree` ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2600)). - -#### Bug fixes: {#bug-fixes-18} - -- Fixed a problem with a very small timeout for sockets (one second) for reading and writing when sending and downloading replicated data, which made it impossible to download larger parts if there is a load on the network or disk (it resulted in cyclical attempts to download parts). This error occurred in version 1.1.54388. -- Fixed issues when using chroot in ZooKeeper if you inserted duplicate data blocks in the table. -- The `has` function now works correctly for an array with Nullable elements ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). -- The `system.tables` table now works correctly when used in distributed queries. The `metadata_modification_time` and `engine_full` columns are now non-virtual. Fixed an error that occurred if only these columns were queried from the table. -- Fixed how an empty `TinyLog` table works after inserting an empty data block ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). -- The `system.zookeeper` table works if the value of the node in ZooKeeper is NULL. - -### ClickHouse release 1.1.54390, 2018-07-06 {#clickhouse-release-1-1-54390-2018-07-06} - -#### New features: {#new-features-11} - -- Queries can be sent in `multipart/form-data` format (in the `query` field), which is useful if external data is also sent for query processing ([Olga Hvostikova](https://github.com/ClickHouse/ClickHouse/pull/2490)). -- Added the ability to enable or disable processing single or double quotes when reading data in CSV format. You can configure this in the `format_csv_allow_single_quotes` and `format_csv_allow_double_quotes` settings ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2574)). -- Now `OPTIMIZE TABLE ... FINAL` can be used without specifying the partition for non-replicated variants of `MergeTree` ([Amos Bird](https://github.com/ClickHouse/ClickHouse/pull/2599)). - -#### Improvements: {#improvements-10} - -- Improved performance, reduced memory consumption, and correct memory consumption tracking with use of the IN operator when a table index could be used ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). -- Removed redundant checking of checksums when adding a data part. This is important when there are a large number of replicas, because in these cases the total number of checks was equal to N^2. -- Added support for `Array(Tuple(...))` arguments for the `arrayEnumerateUniq` function ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). -- Added `Nullable` support for the `runningDifference` function ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). -- Improved query analysis performance when there is a very large number of expressions ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). -- Faster selection of data parts for merging in `ReplicatedMergeTree` tables. Faster recovery of the ZooKeeper session ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). -- The `format_version.txt` file for `MergeTree` tables is re-created if it is missing, which makes sense if ClickHouse is launched after copying the directory structure without files ([Ciprian Hacman](https://github.com/ClickHouse/ClickHouse/pull/2593)). - -#### Bug fixes: {#bug-fixes-19} - -- Fixed a bug when working with ZooKeeper that could make it impossible to recover the session and readonly states of tables before restarting the server. -- Fixed a bug when working with ZooKeeper that could result in old nodes not being deleted if the session is interrupted. -- Fixed an error in the `quantileTDigest` function for Float arguments (this bug was introduced in version 1.1.54388) ([Mikhail Surin](https://github.com/ClickHouse/ClickHouse/pull/2553)). -- Fixed a bug in the index for MergeTree tables if the primary key column is located inside the function for converting types between signed and unsigned integers of the same size ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). -- Fixed segfault if `macros` are used but they aren’t in the config file ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). -- Fixed switching to the default database when reconnecting the client ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). -- Fixed a bug that occurred when the `use_index_for_in_with_subqueries` setting was disabled. - -#### Security fix: {#security-fix-1} - -- Sending files is no longer possible when connected to MySQL (`LOAD DATA LOCAL INFILE`). - -### ClickHouse release 1.1.54388, 2018-06-28 {#clickhouse-release-1-1-54388-2018-06-28} - -#### New features: {#new-features-12} - -- Support for the `ALTER TABLE t DELETE WHERE` query for replicated tables. Added the `system.mutations` table to track progress of this type of queries. -- Support for the `ALTER TABLE t [REPLACE|ATTACH] PARTITION` query for \*MergeTree tables. -- Support for the `TRUNCATE TABLE` query ([Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2260)) -- Several new `SYSTEM` queries for replicated tables (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). -- Added the ability to write to a table with the MySQL engine and the corresponding table function ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2294)). -- Added the `url()` table function and the `URL` table engine ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). -- Added the `windowFunnel` aggregate function ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2352)). -- New `startsWith` and `endsWith` functions for strings ([Vadim Plakhtinsky](https://github.com/ClickHouse/ClickHouse/pull/2429)). -- The `numbers()` table function now allows you to specify the offset ([Winter Zhang](https://github.com/ClickHouse/ClickHouse/pull/2535)). -- The password to `clickhouse-client` can be entered interactively. -- Server logs can now be sent to syslog ([Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2459)). -- Support for logging in dictionaries with a shared library source ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). -- Support for custom CSV delimiters ([Ivan Zhukov](https://github.com/ClickHouse/ClickHouse/pull/2263)) -- Added the `date_time_input_format` setting. If you switch this setting to `'best_effort'`, DateTime values will be read in a wide range of formats. -- Added the `clickhouse-obfuscator` utility for data obfuscation. Usage example: publishing data used in performance tests. - -#### Experimental features: {#experimental-features-2} - -- Added the ability to calculate `and` arguments only where they are needed ([Anastasia Tsarkova](https://github.com/ClickHouse/ClickHouse/pull/2272)) -- JIT compilation to native code is now available for some expressions ([pyos](https://github.com/ClickHouse/ClickHouse/pull/2277)). - -#### Bug fixes: {#bug-fixes-20} - -- Duplicates no longer appear for a query with `DISTINCT` and `ORDER BY`. -- Queries with `ARRAY JOIN` and `arrayFilter` no longer return an incorrect result. -- Fixed an error when reading an array column from a Nested structure ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). -- Fixed an error when analyzing queries with a HAVING clause like `HAVING tuple IN (...)`. -- Fixed an error when analyzing queries with recursive aliases. -- Fixed an error when reading from ReplacingMergeTree with a condition in PREWHERE that filters all rows ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). -- User profile settings were not applied when using sessions in the HTTP interface. -- Fixed how settings are applied from the command line parameters in clickhouse-local. -- The ZooKeeper client library now uses the session timeout received from the server. -- Fixed a bug in the ZooKeeper client library when the client waited for the server response longer than the timeout. -- Fixed pruning of parts for queries with conditions on partition key columns ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). -- Merges are now possible after `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). -- Type mapping in the ODBC table function has been fixed ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2268)). -- Type comparisons have been fixed for `DateTime` with and without the time zone ([Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2400)). -- Fixed syntactic parsing and formatting of the `CAST` operator. -- Fixed insertion into a materialized view for the Distributed table engine ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). -- Fixed a race condition when writing data from the `Kafka` engine to materialized views ([Yangkuan Liu](https://github.com/ClickHouse/ClickHouse/pull/2448)). -- Fixed SSRF in the remote() table function. -- Fixed exit behavior of `clickhouse-client` in multiline mode ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). - -#### Improvements: {#improvements-11} - -- Background tasks in replicated tables are now performed in a thread pool instead of in separate threads ([Silviu Caragea](https://github.com/ClickHouse/ClickHouse/pull/1722)). -- Improved LZ4 compression performance. -- Faster analysis for queries with a large number of JOINs and sub-queries. -- The DNS cache is now updated automatically when there are too many network errors. -- Table inserts no longer occur if the insert into one of the materialized views is not possible because it has too many parts. -- Corrected the discrepancy in the event counters `Query`, `SelectQuery`, and `InsertQuery`. -- Expressions like `tuple IN (SELECT tuple)` are allowed if the tuple types match. -- A server with replicated tables can start even if you haven’t configured ZooKeeper. -- When calculating the number of available CPU cores, limits on cgroups are now taken into account ([Atri Sharma](https://github.com/ClickHouse/ClickHouse/pull/2325)). -- Added chown for config directories in the systemd config file ([Mikhail Shiryaev](https://github.com/ClickHouse/ClickHouse/pull/2421)). - -#### Build changes: {#build-changes-4} - -- The gcc8 compiler can be used for builds. -- Added the ability to build llvm from submodule. -- The version of the librdkafka library has been updated to v0.11.4. -- Added the ability to use the system libcpuid library. The library version has been updated to 0.4.0. -- Fixed the build using the vectorclass library ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). -- Cmake now generates files for ninja by default (like when using `-G Ninja`). -- Added the ability to use the libtinfo library instead of libtermcap ([Georgy Kondratiev](https://github.com/ClickHouse/ClickHouse/pull/2519)). -- Fixed a header file conflict in Fedora Rawhide ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). - -#### Backward incompatible changes: {#backward-incompatible-changes-7} - -- Removed escaping in `Vertical` and `Pretty*` formats and deleted the `VerticalRaw` format. -- If servers with version 1.1.54388 (or newer) and servers with an older version are used simultaneously in a distributed query and the query has the `cast(x, 'Type')` expression without the `AS` keyword and doesn’t have the word `cast` in uppercase, an exception will be thrown with a message like `Not found column cast(0, 'UInt8') in block`. Solution: Update the server on the entire cluster. - -### ClickHouse release 1.1.54385, 2018-06-01 {#clickhouse-release-1-1-54385-2018-06-01} - -#### Bug fixes: {#bug-fixes-21} - -- Fixed an error that in some cases caused ZooKeeper operations to block. - -### ClickHouse release 1.1.54383, 2018-05-22 {#clickhouse-release-1-1-54383-2018-05-22} - -#### Bug fixes: {#bug-fixes-22} - -- Fixed a slowdown of replication queue if a table has many replicas. - -### ClickHouse release 1.1.54381, 2018-05-14 {#clickhouse-release-1-1-54381-2018-05-14} - -#### Bug fixes: {#bug-fixes-23} - -- Fixed a nodes leak in ZooKeeper when ClickHouse loses connection to ZooKeeper server. - -### ClickHouse release 1.1.54380, 2018-04-21 {#clickhouse-release-1-1-54380-2018-04-21} - -#### New features: {#new-features-13} - -- Added the table function `file(path, format, structure)`. An example reading bytes from `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. - -#### Improvements: {#improvements-12} - -- Subqueries can be wrapped in `()` brackets to enhance query readability. For example: `(SELECT 1) UNION ALL (SELECT 1)`. -- Simple `SELECT` queries from the `system.processes` table are not included in the `max_concurrent_queries` limit. - -#### Bug fixes: {#bug-fixes-24} - -- Fixed incorrect behavior of the `IN` operator when select from `MATERIALIZED VIEW`. -- Fixed incorrect filtering by partition index in expressions like `partition_key_column IN (...)`. -- Fixed inability to execute `OPTIMIZE` query on non-leader replica if `REANAME` was performed on the table. -- Fixed the authorization error when executing `OPTIMIZE` or `ALTER` queries on a non-leader replica. -- Fixed freezing of `KILL QUERY`. -- Fixed an error in ZooKeeper client library which led to loss of watches, freezing of distributed DDL queue, and slowdowns in the replication queue if a non-empty `chroot` prefix is used in the ZooKeeper configuration. - -#### Backward incompatible changes: {#backward-incompatible-changes-8} - -- Removed support for expressions like `(a, b) IN (SELECT (a, b))` (you can use the equivalent expression `(a, b) IN (SELECT a, b)`). In previous releases, these expressions led to undetermined `WHERE` filtering or caused errors. - -### ClickHouse release 1.1.54378, 2018-04-16 {#clickhouse-release-1-1-54378-2018-04-16} - -#### New features: {#new-features-14} - -- Logging level can be changed without restarting the server. -- Added the `SHOW CREATE DATABASE` query. -- The `query_id` can be passed to `clickhouse-client` (elBroom). -- New setting: `max_network_bandwidth_for_all_users`. -- Added support for `ALTER TABLE ... PARTITION ...` for `MATERIALIZED VIEW`. -- Added information about the size of data parts in uncompressed form in the system table. -- Server-to-server encryption support for distributed tables (`1` in the replica config in ``). -- Configuration of the table level for the `ReplicatedMergeTree` family in order to minimize the amount of data stored in Zookeeper: : `use_minimalistic_checksums_in_zookeeper = 1` -- Configuration of the `clickhouse-client` prompt. By default, server names are now output to the prompt. The server’s display name can be changed. It’s also sent in the `X-ClickHouse-Display-Name` HTTP header (Kirill Shvakov). -- Multiple comma-separated `topics` can be specified for the `Kafka` engine (Tobias Adamson) -- When a query is stopped by `KILL QUERY` or `replace_running_query`, the client receives the `Query was canceled` exception instead of an incomplete result. - -#### Improvements: {#improvements-13} - -- `ALTER TABLE ... DROP/DETACH PARTITION` queries are run at the front of the replication queue. -- `SELECT ... FINAL` and `OPTIMIZE ... FINAL` can be used even when the table has a single data part. -- A `query_log` table is recreated on the fly if it was deleted manually (Kirill Shvakov). -- The `lengthUTF8` function runs faster (zhang2014). -- Improved performance of synchronous inserts in `Distributed` tables (`insert_distributed_sync = 1`) when there is a very large number of shards. -- The server accepts the `send_timeout` and `receive_timeout` settings from the client and applies them when connecting to the client (they are applied in reverse order: the server socket’s `send_timeout` is set to the `receive_timeout` value received from the client, and vice versa). -- More robust crash recovery for asynchronous insertion into `Distributed` tables. -- The return type of the `countEqual` function changed from `UInt32` to `UInt64` (谢磊). - -#### Bug fixes: {#bug-fixes-25} - -- Fixed an error with `IN` when the left side of the expression is `Nullable`. -- Correct results are now returned when using tuples with `IN` when some of the tuple components are in the table index. -- The `max_execution_time` limit now works correctly with distributed queries. -- Fixed errors when calculating the size of composite columns in the `system.columns` table. -- Fixed an error when creating a temporary table `CREATE TEMPORARY TABLE IF NOT EXISTS.` -- Fixed errors in `StorageKafka` (\#\#2075) -- Fixed server crashes from invalid arguments of certain aggregate functions. -- Fixed the error that prevented the `DETACH DATABASE` query from stopping background tasks for `ReplicatedMergeTree` tables. -- `Too many parts` state is less likely to happen when inserting into aggregated materialized views (\#\#2084). -- Corrected recursive handling of substitutions in the config if a substitution must be followed by another substitution on the same level. -- Corrected the syntax in the metadata file when creating a `VIEW` that uses a query with `UNION ALL`. -- `SummingMergeTree` now works correctly for summation of nested data structures with a composite key. -- Fixed the possibility of a race condition when choosing the leader for `ReplicatedMergeTree` tables. - -#### Build changes: {#build-changes-5} - -- The build supports `ninja` instead of `make` and uses `ninja` by default for building releases. -- Renamed packages: `clickhouse-server-base` in `clickhouse-common-static`; `clickhouse-server-common` in `clickhouse-server`; `clickhouse-common-dbg` in `clickhouse-common-static-dbg`. To install, use `clickhouse-server clickhouse-client`. Packages with the old names will still load in the repositories for backward compatibility. - -#### Backward incompatible changes: {#backward-incompatible-changes-9} - -- Removed the special interpretation of an IN expression if an array is specified on the left side. Previously, the expression `arr IN (set)` was interpreted as “at least one `arr` element belongs to the `set`”. To get the same behavior in the new version, write `arrayExists(x -> x IN (set), arr)`. -- Disabled the incorrect use of the socket option `SO_REUSEPORT`, which was incorrectly enabled by default in the Poco library. Note that on Linux there is no longer any reason to simultaneously specify the addresses `::` and `0.0.0.0` for listen – use just `::`, which allows listening to the connection both over IPv4 and IPv6 (with the default kernel config settings). You can also revert to the behavior from previous versions by specifying `1` in the config. - -### ClickHouse release 1.1.54370, 2018-03-16 {#clickhouse-release-1-1-54370-2018-03-16} - -#### New features: {#new-features-15} - -- Added the `system.macros` table and auto updating of macros when the config file is changed. -- Added the `SYSTEM RELOAD CONFIG` query. -- Added the `maxIntersections(left_col, right_col)` aggregate function, which returns the maximum number of simultaneously intersecting intervals `[left; right]`. The `maxIntersectionsPosition(left, right)` function returns the beginning of the “maximum” interval. ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2012)). - -#### Improvements: {#improvements-14} - -- When inserting data in a `Replicated` table, fewer requests are made to `ZooKeeper` (and most of the user-level errors have disappeared from the `ZooKeeper` log). -- Added the ability to create aliases for data sets. Example: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. - -#### Bug fixes: {#bug-fixes-26} - -- Fixed the `Illegal PREWHERE` error when reading from Merge tables for `Distributed`tables. -- Added fixes that allow you to start clickhouse-server in IPv4-only Docker containers. -- Fixed a race condition when reading from system `system.parts_columns tables.` -- Removed double buffering during a synchronous insert to a `Distributed` table, which could have caused the connection to timeout. -- Fixed a bug that caused excessively long waits for an unavailable replica before beginning a `SELECT` query. -- Fixed incorrect dates in the `system.parts` table. -- Fixed a bug that made it impossible to insert data in a `Replicated` table if `chroot` was non-empty in the configuration of the `ZooKeeper` cluster. -- Fixed the vertical merging algorithm for an empty `ORDER BY` table. -- Restored the ability to use dictionaries in queries to remote tables, even if these dictionaries are not present on the requestor server. This functionality was lost in release 1.1.54362. -- Restored the behavior for queries like `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` when the right side of the `IN` should use a remote `default.table` instead of a local one. This behavior was broken in version 1.1.54358. -- Removed extraneous error-level logging of `Not found column ... in block`. - -### ClickHouse Release 1.1.54362, 2018-03-11 {#clickhouse-release-1-1-54362-2018-03-11} - -#### New features: {#new-features-16} - -- Aggregation without `GROUP BY` for an empty set (such as `SELECT count(*) FROM table WHERE 0`) now returns a result with one row with null values for aggregate functions, in compliance with the SQL standard. To restore the old behavior (return an empty result), set `empty_result_for_aggregation_by_empty_set` to 1. -- Added type conversion for `UNION ALL`. Different alias names are allowed in `SELECT` positions in `UNION ALL`, in compliance with the SQL standard. -- Arbitrary expressions are supported in `LIMIT BY` clauses. Previously, it was only possible to use columns resulting from `SELECT`. -- An index of `MergeTree` tables is used when `IN` is applied to a tuple of expressions from the columns of the primary key. Example: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` (Anastasiya Tsarkova). -- Added the `clickhouse-copier` tool for copying between clusters and resharding data (beta). -- Added consistent hashing functions: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. They can be used as a sharding key in order to reduce the amount of network traffic during subsequent reshardings. -- Added functions: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. -- Added the `arrayCumSum` function (Javi Santana). -- Added the `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero`, and `parseDateTimeBestEffortOrNull` functions to read the DateTime from a string containing text in a wide variety of possible formats. -- Data can be partially reloaded from external dictionaries during updating (load just the records in which the value of the specified field greater than in the previous download) (Arsen Hakobyan). -- Added the `cluster` table function. Example: `cluster(cluster_name, db, table)`. The `remote` table function can accept the cluster name as the first argument, if it is specified as an identifier. -- The `remote` and `cluster` table functions can be used in `INSERT` queries. -- Added the `create_table_query` and `engine_full` virtual columns to the `system.tables`table . The `metadata_modification_time` column is virtual. -- Added the `data_path` and `metadata_path` columns to `system.tables`and`system.databases` tables, and added the `path` column to the `system.parts` and `system.parts_columns` tables. -- Added additional information about merges in the `system.part_log` table. -- An arbitrary partitioning key can be used for the `system.query_log` table (Kirill Shvakov). -- The `SHOW TABLES` query now also shows temporary tables. Added temporary tables and the `is_temporary` column to `system.tables` (zhang2014). -- Added `DROP TEMPORARY TABLE` and `EXISTS TEMPORARY TABLE` queries (zhang2014). -- Support for `SHOW CREATE TABLE` for temporary tables (zhang2014). -- Added the `system_profile` configuration parameter for the settings used by internal processes. -- Support for loading `object_id` as an attribute in `MongoDB` dictionaries (Pavel Litvinenko). -- Reading `null` as the default value when loading data for an external dictionary with the `MongoDB` source (Pavel Litvinenko). -- Reading `DateTime` values in the `Values` format from a Unix timestamp without single quotes. -- Failover is supported in `remote` table functions for cases when some of the replicas are missing the requested table. -- Configuration settings can be overridden in the command line when you run `clickhouse-server`. Example: `clickhouse-server -- --logger.level=information`. -- Implemented the `empty` function from a `FixedString` argument: the function returns 1 if the string consists entirely of null bytes (zhang2014). -- Added the `listen_try`configuration parameter for listening to at least one of the listen addresses without quitting, if some of the addresses can’t be listened to (useful for systems with disabled support for IPv4 or IPv6). -- Added the `VersionedCollapsingMergeTree` table engine. -- Support for rows and arbitrary numeric types for the `library` dictionary source. -- `MergeTree` tables can be used without a primary key (you need to specify `ORDER BY tuple()`). -- A `Nullable` type can be `CAST` to a non-`Nullable` type if the argument is not `NULL`. -- `RENAME TABLE` can be performed for `VIEW`. -- Added the `throwIf` function. -- Added the `odbc_default_field_size` option, which allows you to extend the maximum size of the value loaded from an ODBC source (by default, it is 1024). -- The `system.processes` table and `SHOW PROCESSLIST` now have the `is_cancelled` and `peak_memory_usage` columns. - -#### Improvements: {#improvements-15} - -- Limits and quotas on the result are no longer applied to intermediate data for `INSERT SELECT` queries or for `SELECT` subqueries. -- Fewer false triggers of `force_restore_data` when checking the status of `Replicated` tables when the server starts. -- Added the `allow_distributed_ddl` option. -- Nondeterministic functions are not allowed in expressions for `MergeTree` table keys. -- Files with substitutions from `config.d` directories are loaded in alphabetical order. -- Improved performance of the `arrayElement` function in the case of a constant multidimensional array with an empty array as one of the elements. Example: `[[1], []][x]`. -- The server starts faster now when using configuration files with very large substitutions (for instance, very large lists of IP networks). -- When running a query, table valued functions run once. Previously, `remote` and `mysql` table valued functions performed the same query twice to retrieve the table structure from a remote server. -- The `MkDocs` documentation generator is used. -- When you try to delete a table column that `DEFAULT`/`MATERIALIZED` expressions of other columns depend on, an exception is thrown (zhang2014). -- Added the ability to parse an empty line in text formats as the number 0 for `Float` data types. This feature was previously available but was lost in release 1.1.54342. -- `Enum` values can be used in `min`, `max`, `sum` and some other functions. In these cases, it uses the corresponding numeric values. This feature was previously available but was lost in the release 1.1.54337. -- Added `max_expanded_ast_elements` to restrict the size of the AST after recursively expanding aliases. - -#### Bug fixes: {#bug-fixes-27} - -- Fixed cases when unnecessary columns were removed from subqueries in error, or not removed from subqueries containing `UNION ALL`. -- Fixed a bug in merges for `ReplacingMergeTree` tables. -- Fixed synchronous insertions in `Distributed` tables (`insert_distributed_sync = 1`). -- Fixed segfault for certain uses of `FULL` and `RIGHT JOIN` with duplicate columns in subqueries. -- Fixed segfault for certain uses of `replace_running_query` and `KILL QUERY`. -- Fixed the order of the `source` and `last_exception` columns in the `system.dictionaries` table. -- Fixed a bug when the `DROP DATABASE` query did not delete the file with metadata. -- Fixed the `DROP DATABASE` query for `Dictionary` databases. -- Fixed the low precision of `uniqHLL12` and `uniqCombined` functions for cardinalities greater than 100 million items (Alex Bocharov). -- Fixed the calculation of implicit default values when necessary to simultaneously calculate default explicit expressions in `INSERT` queries (zhang2014). -- Fixed a rare case when a query to a `MergeTree` table couldn’t finish (chenxing-xc). -- Fixed a crash that occurred when running a `CHECK` query for `Distributed` tables if all shards are local (chenxing.xc). -- Fixed a slight performance regression with functions that use regular expressions. -- Fixed a performance regression when creating multidimensional arrays from complex expressions. -- Fixed a bug that could cause an extra `FORMAT` section to appear in an `.sql` file with metadata. -- Fixed a bug that caused the `max_table_size_to_drop` limit to apply when trying to delete a `MATERIALIZED VIEW` looking at an explicitly specified table. -- Fixed incompatibility with old clients (old clients were sometimes sent data with the `DateTime('timezone')` type, which they do not understand). -- Fixed a bug when reading `Nested` column elements of structures that were added using `ALTER` but that are empty for the old partitions, when the conditions for these columns moved to `PREWHERE`. -- Fixed a bug when filtering tables by virtual `_table` columns in queries to `Merge` tables. -- Fixed a bug when using `ALIAS` columns in `Distributed` tables. -- Fixed a bug that made dynamic compilation impossible for queries with aggregate functions from the `quantile` family. -- Fixed a race condition in the query execution pipeline that occurred in very rare cases when using `Merge` tables with a large number of tables, and when using `GLOBAL` subqueries. -- Fixed a crash when passing arrays of different sizes to an `arrayReduce` function when using aggregate functions from multiple arguments. -- Prohibited the use of queries with `UNION ALL` in a `MATERIALIZED VIEW`. -- Fixed an error during initialization of the `part_log` system table when the server starts (by default, `part_log` is disabled). - -#### Backward incompatible changes: {#backward-incompatible-changes-10} - -- Removed the `distributed_ddl_allow_replicated_alter` option. This behavior is enabled by default. -- Removed the `strict_insert_defaults` setting. If you were using this functionality, write to `clickhouse-feedback@yandex-team.com`. -- Removed the `UnsortedMergeTree` engine. - -### ClickHouse Release 1.1.54343, 2018-02-05 {#clickhouse-release-1-1-54343-2018-02-05} - -- Added macros support for defining cluster names in distributed DDL queries and constructors of Distributed tables: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. -- Now queries like `SELECT ... FROM table WHERE expr IN (subquery)` are processed using the `table` index. -- Improved processing of duplicates when inserting to Replicated tables, so they no longer slow down execution of the replication queue. - -### ClickHouse Release 1.1.54342, 2018-01-22 {#clickhouse-release-1-1-54342-2018-01-22} - -This release contains bug fixes for the previous release 1.1.54337: - -- Fixed a regression in 1.1.54337: if the default user has readonly access, then the server refuses to start up with the message `Cannot create database in readonly mode`. -- Fixed a regression in 1.1.54337: on systems with systemd, logs are always written to syslog regardless of the configuration; the watchdog script still uses init.d. -- Fixed a regression in 1.1.54337: wrong default configuration in the Docker image. -- Fixed nondeterministic behavior of GraphiteMergeTree (you can see it in log messages `Data after merge is not byte-identical to the data on another replicas`). -- Fixed a bug that may lead to inconsistent merges after OPTIMIZE query to Replicated tables (you may see it in log messages `Part ... intersects the previous part`). -- Buffer tables now work correctly when MATERIALIZED columns are present in the destination table (by zhang2014). -- Fixed a bug in implementation of NULL. - -### ClickHouse Release 1.1.54337, 2018-01-18 {#clickhouse-release-1-1-54337-2018-01-18} - -#### New features: {#new-features-17} - -- Added support for storage of multi-dimensional arrays and tuples (`Tuple` data type) in tables. -- Support for table functions for `DESCRIBE` and `INSERT` queries. Added support for subqueries in `DESCRIBE`. Examples: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. Support for `INSERT INTO TABLE` in addition to `INSERT INTO`. -- Improved support for time zones. The `DateTime` data type can be annotated with the timezone that is used for parsing and formatting in text formats. Example: `DateTime('Europe/Moscow')`. When timezones are specified in functions for `DateTime` arguments, the return type will track the timezone, and the value will be displayed as expected. -- Added the functions `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. The `toRelativeHour`/`Minute`/`Second` functions can take a value of type `Date` as an argument. The `now` function name is case-sensitive. -- Added the `toStartOfFifteenMinutes` function (Kirill Shvakov). -- Added the `clickhouse format` tool for formatting queries. -- Added the `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` format. Schema files can be located only in the specified directory. -- Added support for config substitutions (`incl` and `conf.d`) for configuration of external dictionaries and models (Pavel Yakunin). -- Added a column with documentation for the `system.settings` table (Kirill Shvakov). -- Added the `system.parts_columns` table with information about column sizes in each data part of `MergeTree` tables. -- Added the `system.models` table with information about loaded `CatBoost` machine learning models. -- Added the `mysql` and `odbc` table function and corresponding `MySQL` and `ODBC` table engines for accessing remote databases. This functionality is in the beta stage. -- Added the possibility to pass an argument of type `AggregateFunction` for the `groupArray` aggregate function (so you can create an array of states of some aggregate function). -- Removed restrictions on various combinations of aggregate function combinators. For example, you can use `avgForEachIf` as well as `avgIfForEach` aggregate functions, which have different behaviors. -- The `-ForEach` aggregate function combinator is extended for the case of aggregate functions of multiple arguments. -- Added support for aggregate functions of `Nullable` arguments even for cases when the function returns a non-`Nullable` result (added with the contribution of Silviu Caragea). Example: `groupArray`, `groupUniqArray`, `topK`. -- Added the `max_client_network_bandwidth` for `clickhouse-client` (Kirill Shvakov). -- Users with the `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). -- Added support for using multiple consumers with the `Kafka` engine. Extended configuration options for `Kafka` (Marek Vavruša). -- Added the `intExp3` and `intExp4` functions. -- Added the `sumKahan` aggregate function. -- Added the to \* Number\* OrNull functions, where \* Number\* is a numeric type. -- Added support for `WITH` clauses for an `INSERT SELECT` query (author: zhang2014). -- Added settings: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. In particular, these settings are used for downloading data parts for replication. Changing these settings allows for faster failover if the network is overloaded. -- Added support for `ALTER` for tables of type `Null` (Anastasiya Tsarkova). -- The `reinterpretAsString` function is extended for all data types that are stored contiguously in memory. -- Added the `--silent` option for the `clickhouse-local` tool. It suppresses printing query execution info in stderr. -- Added support for reading values of type `Date` from text in a format where the month and/or day of the month is specified using a single digit instead of two digits (Amos Bird). - -#### Performance optimizations: {#performance-optimizations} - -- Improved performance of aggregate functions `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` from string arguments. -- Improved performance of the functions `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. -- Improved performance of parsing and formatting `Date` and `DateTime` type values in text format. -- Improved performance and precision of parsing floating point numbers. -- Lowered memory usage for `JOIN` in the case when the left and right parts have columns with identical names that are not contained in `USING` . -- Improved performance of aggregate functions `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` by reducing computational stability. The old functions are available under the names `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. - -#### Bug fixes: {#bug-fixes-28} - -- Fixed data deduplication after running a `DROP` or `DETACH PARTITION` query. In the previous version, dropping a partition and inserting the same data again was not working because inserted blocks were considered duplicates. -- Fixed a bug that could lead to incorrect interpretation of the `WHERE` clause for `CREATE MATERIALIZED VIEW` queries with `POPULATE` . -- Fixed a bug in using the `root_path` parameter in the `zookeeper_servers` configuration. -- Fixed unexpected results of passing the `Date` argument to `toStartOfDay` . -- Fixed the `addMonths` and `subtractMonths` functions and the arithmetic for `INTERVAL n MONTH` in cases when the result has the previous year. -- Added missing support for the `UUID` data type for `DISTINCT` , `JOIN` , and `uniq` aggregate functions and external dictionaries (Evgeniy Ivanov). Support for `UUID` is still incomplete. -- Fixed `SummingMergeTree` behavior in cases when the rows summed to zero. -- Various fixes for the `Kafka` engine (Marek Vavruša). -- Fixed incorrect behavior of the `Join` table engine (Amos Bird). -- Fixed incorrect allocator behavior under FreeBSD and OS X. -- The `extractAll` function now supports empty matches. -- Fixed an error that blocked usage of `libressl` instead of `openssl` . -- Fixed the `CREATE TABLE AS SELECT` query from temporary tables. -- Fixed non-atomicity of updating the replication queue. This could lead to replicas being out of sync until the server restarts. -- Fixed possible overflow in `gcd` , `lcm` and `modulo` (`%` operator) (Maks Skorokhod). -- `-preprocessed` files are now created after changing `umask` (`umask` can be changed in the config). -- Fixed a bug in the background check of parts (`MergeTreePartChecker` ) when using a custom partition key. -- Fixed parsing of tuples (values of the `Tuple` data type) in text formats. -- Improved error messages about incompatible types passed to `multiIf` , `array` and some other functions. -- Redesigned support for `Nullable` types. Fixed bugs that may lead to a server crash. Fixed almost all other bugs related to `NULL` support: incorrect type conversions in INSERT SELECT, insufficient support for Nullable in HAVING and PREWHERE, `join_use_nulls` mode, Nullable types as arguments of `OR` operator, etc. -- Fixed various bugs related to internal semantics of data types. Examples: unnecessary summing of `Enum` type fields in `SummingMergeTree` ; alignment of `Enum` types in `Pretty` formats, etc. -- Stricter checks for allowed combinations of composite columns. -- Fixed the overflow when specifying a very large parameter for the `FixedString` data type. -- Fixed a bug in the `topK` aggregate function in a generic case. -- Added the missing check for equality of array sizes in arguments of n-ary variants of aggregate functions with an `-Array` combinator. -- Fixed a bug in `--pager` for `clickhouse-client` (author: ks1322). -- Fixed the precision of the `exp10` function. -- Fixed the behavior of the `visitParamExtract` function for better compliance with documentation. -- Fixed the crash when incorrect data types are specified. -- Fixed the behavior of `DISTINCT` in the case when all columns are constants. -- Fixed query formatting in the case of using the `tupleElement` function with a complex constant expression as the tuple element index. -- Fixed a bug in `Dictionary` tables for `range_hashed` dictionaries. -- Fixed a bug that leads to excessive rows in the result of `FULL` and `RIGHT JOIN` (Amos Bird). -- Fixed a server crash when creating and removing temporary files in `config.d` directories during config reload. -- Fixed the `SYSTEM DROP DNS CACHE` query: the cache was flushed but addresses of cluster nodes were not updated. -- Fixed the behavior of `MATERIALIZED VIEW` after executing `DETACH TABLE` for the table under the view (Marek Vavruša). - -#### Build improvements: {#build-improvements-4} - -- The `pbuilder` tool is used for builds. The build process is almost completely independent of the build host environment. -- A single build is used for different OS versions. Packages and binaries have been made compatible with a wide range of Linux systems. -- Added the `clickhouse-test` package. It can be used to run functional tests. -- The source tarball can now be published to the repository. It can be used to reproduce the build without using GitHub. -- Added limited integration with Travis CI. Due to limits on build time in Travis, only the debug build is tested and a limited subset of tests are run. -- Added support for `Cap'n'Proto` in the default build. -- Changed the format of documentation sources from `Restricted Text` to `Markdown`. -- Added support for `systemd` (Vladimir Smirnov). It is disabled by default due to incompatibility with some OS images and can be enabled manually. -- For dynamic code generation, `clang` and `lld` are embedded into the `clickhouse` binary. They can also be invoked as `clickhouse clang` and `clickhouse lld` . -- Removed usage of GNU extensions from the code. Enabled the `-Wextra` option. When building with `clang` the default is `libc++` instead of `libstdc++`. -- Extracted `clickhouse_parsers` and `clickhouse_common_io` libraries to speed up builds of various tools. - -#### Backward incompatible changes: {#backward-incompatible-changes-11} - -- The format for marks in `Log` type tables that contain `Nullable` columns was changed in a backward incompatible way. If you have these tables, you should convert them to the `TinyLog` type before starting up the new server version. To do this, replace `ENGINE = Log` with `ENGINE = TinyLog` in the corresponding `.sql` file in the `metadata` directory. If your table doesn’t have `Nullable` columns or if the type of your table is not `Log`, then you don’t need to do anything. -- Removed the `experimental_allow_extended_storage_definition_syntax` setting. Now this feature is enabled by default. -- The `runningIncome` function was renamed to `runningDifferenceStartingWithFirstvalue` to avoid confusion. -- Removed the `FROM ARRAY JOIN arr` syntax when ARRAY JOIN is specified directly after FROM with no table (Amos Bird). -- Removed the `BlockTabSeparated` format that was used solely for demonstration purposes. -- Changed the state format for aggregate functions `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. If you have stored states of these aggregate functions in tables (using the `AggregateFunction` data type or materialized views with corresponding states), please write to clickhouse-feedback@yandex-team.com. -- In previous server versions there was an undocumented feature: if an aggregate function depends on parameters, you can still specify it without parameters in the AggregateFunction data type. Example: `AggregateFunction(quantiles, UInt64)` instead of `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. This feature was lost. Although it was undocumented, we plan to support it again in future releases. -- Enum data types cannot be used in min/max aggregate functions. This ability will be returned in the next release. - -#### Please note when upgrading: {#please-note-when-upgrading} - -- When doing a rolling update on a cluster, at the point when some of the replicas are running the old version of ClickHouse and some are running the new version, replication is temporarily stopped and the message `unknown parameter 'shard'` appears in the log. Replication will continue after all replicas of the cluster are updated. -- If different versions of ClickHouse are running on the cluster servers, it is possible that distributed queries using the following functions will have incorrect results: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. You should update all cluster nodes. - -## [Changelog for 2017](./2017.md) diff --git a/docs/en/whats_new/changelog/2019.md b/docs/en/whats_new/changelog/2019.md deleted file mode 100644 index b510c68ba87..00000000000 --- a/docs/en/whats_new/changelog/2019.md +++ /dev/null @@ -1,2072 +0,0 @@ ---- -toc_priority: 77 -toc_title: '2019' ---- - -## ClickHouse release v19.17 {#clickhouse-release-v19-17} - -### ClickHouse release v19.17.6.36, 2019-12-27 {#clickhouse-release-v19-17-6-36-2019-12-27} - -#### Bug Fix {#bug-fix} - -- Fixed potential buffer overflow in decompress. Malicious user can pass fabricated compressed data that could cause read after buffer. This issue was found by Eldar Zaitov from Yandex information security team. [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed possible server crash (`std::terminate`) when the server cannot send or write data in JSON or XML format with values of String data type (that require UTF-8 validation) or when compressing result data with Brotli algorithm or in some other rare cases. [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed dictionaries with source from a clickhouse `VIEW`, now reading such dictionaries doesn’t cause the error `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed checking if a client host is allowed by host\_regexp specified in users.xml. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([Vitaly Baranov](https://github.com/vitlibar)) -- `RENAME TABLE` for a distributed table now renames the folder containing inserted data before sending to shards. This fixes an issue with successive renames `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) -- `range_hashed` external dictionaries created by DDL queries now allow ranges of arbitrary numeric types. [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([alesapin](https://github.com/alesapin)) -- Fixed `INSERT INTO table SELECT ... FROM mysql(...)` table function. [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) -- Fixed segfault in `INSERT INTO TABLE FUNCTION file()` while inserting into a file which doesn’t exist. Now in this case file would be created and then insert would be processed. [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) -- Fixed bitmapAnd error when intersecting an aggregated bitmap and a scalar bitmap. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([Yue Huang](https://github.com/moon03432)) -- Fixed segfault when `EXISTS` query was used without `TABLE` or `DICTIONARY` qualifier, just like `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed return type for functions `rand` and `randConstant` in case of nullable argument. Now functions always return `UInt32` and never `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed `DROP DICTIONARY IF EXISTS db.dict`, now it doesn’t throw exception if `db` doesn’t exist. [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([Vitaly Baranov](https://github.com/vitlibar)) -- If a table wasn’t completely dropped because of server crash, the server will try to restore and load it [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) -- Fixed a trivial count query for a distributed table if there are more than two shard local table. [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- Fixed bug that lead to a data race in DB::BlockStreamProfileInfo::calculateRowsBeforeLimit() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([Alexander Kazakov](https://github.com/Akazz)) -- Fixed `ALTER table MOVE part` executed immediately after merging the specified part, which could cause moving a part which the specified part merged into. Now it correctly moves the specified part. [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Expressions for dictionaries can be specified as strings now. This is useful for calculation of attributes while extracting data from non-ClickHouse sources because it allows to use non-ClickHouse syntax for those expressions. [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([alesapin](https://github.com/alesapin)) -- Fixed a very rare race in `clickhouse-copier` because of an overflow in ZXid. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([Ding Xiang Fei](https://github.com/dingxiangfei2009)) -- Fixed the bug when after the query failed (due to “Too many simultaneous queries” for example) it would not read external tables info, and the - next request would interpret this info as the beginning of the next query causing an error like `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) -- Avoid null dereference after “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) -- Restore support of all ICU locales, add the ability to apply collations for constant expressions and add language name to system.collations table. [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([alesapin](https://github.com/alesapin)) -- Number of streams for read from `StorageFile` and `StorageHDFS` is now limited, to avoid exceeding the memory limit. [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([alesapin](https://github.com/alesapin)) -- Fixed `CHECK TABLE` query for `*MergeTree` tables without key. [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([alesapin](https://github.com/alesapin)) -- Removed the mutation number from a part name in case there were no mutations. This removing improved the compatibility with older versions. [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([alesapin](https://github.com/alesapin)) -- Fixed the bug that mutations are skipped for some attached parts due to their data\_version are larger than the table mutation version. [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([Zhichang Yu](https://github.com/yuzhichang)) -- Allow starting the server with redundant copies of parts after moving them to another device. [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fixed the error “Sizes of columns doesn’t match” that might appear when using aggregate function columns. [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) -- Now an exception will be thrown in case of using WITH TIES alongside LIMIT BY. And now it’s possible to use TOP with LIMIT BY. [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- Fix dictionary reload if it has `invalidate_query`, which stopped updates and some exception on previous update tries. [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([alesapin](https://github.com/alesapin)) - -### ClickHouse release v19.17.4.11, 2019-11-22 {#clickhouse-release-v19-17-4-11-2019-11-22} - -#### Backward Incompatible Change {#backward-incompatible-change} - -- Using column instead of AST to store scalar subquery results for better performance. Setting `enable_scalar_subquery_optimization` was added in 19.17 and it was enabled by default. It leads to errors like [this](https://github.com/ClickHouse/ClickHouse/issues/7851) during upgrade to 19.17.2 or 19.17.3 from previous versions. This setting was disabled by default in 19.17.4, to make possible upgrading from 19.16 and older versions without errors. [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([Amos Bird](https://github.com/amosbird)) - -#### New Feature {#new-feature} - -- Add the ability to create dictionaries with DDL queries. [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([alesapin](https://github.com/alesapin)) -- Make `bloom_filter` type of index supporting `LowCardinality` and `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Add function `isValidJSON` to check that passed string is a valid json. [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([Vdimir](https://github.com/Vdimir)) -- Implement `arrayCompact` function [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([Memo](https://github.com/Joeywzr)) -- Created function `hex` for Decimal numbers. It works like `hex(reinterpretAsString())`, but doesn’t delete last zero bytes. [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([Mikhail Korotov](https://github.com/millb)) -- Add `arrayFill` and `arrayReverseFill` functions, which replace elements by other elements in front/back of them in the array. [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([hcz](https://github.com/hczhcz)) -- Add `CRC32IEEE()`/`CRC64()` support [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([Azat Khuzhin](https://github.com/azat)) -- Implement `char` function similar to one in [mysql](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([sundyli](https://github.com/sundy-li)) -- Add `bitmapTransform` function. It transforms an array of values in a bitmap to another array of values, the result is a new bitmap [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([Zhichang Yu](https://github.com/yuzhichang)) -- Implemented `javaHashUTF16LE()` function [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([achimbab](https://github.com/achimbab)) -- Add `_shard_num` virtual column for the Distributed engine [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([Azat Khuzhin](https://github.com/azat)) - -#### Experimental Feature {#experimental-feature} - -- Support for processors (new query execution pipeline) in `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### Bug Fix {#bug-fix-1} - -- Fix incorrect float parsing in `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) -- Fix rare deadlock which can happen when trace\_log is enabled. [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([filimonov](https://github.com/filimonov)) -- Prevent message duplication when producing Kafka table has any MVs selecting from it [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([Ivan](https://github.com/abyss7)) -- Support for `Array(LowCardinality(Nullable(String)))` in `IN`. Resolves [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([achimbab](https://github.com/achimbab)) -- Add handling of `SQL_TINYINT` and `SQL_BIGINT`, and fix handling of `SQL_FLOAT` data source types in ODBC Bridge. [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) -- Fix aggregation (`avg` and quantiles) over empty decimal columns [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([Andrey Konyaev](https://github.com/akonyaev90)) -- Fix `INSERT` into Distributed with `MATERIALIZED` columns [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) -- Make `MOVE PARTITION` work if some parts of partition are already on destination disk or volume [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fixed bug with hardlinks failing to be created during mutations in `ReplicatedMergeTree` in multi-disk configurations. [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fixed a bug with a mutation on a MergeTree when whole part remains unchanged and best space is being found on another disk [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fixed bug with `keep_free_space_ratio` not being read from disks configuration [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fix bug with table contains only `Tuple` columns or columns with complex paths. Fixes [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([alesapin](https://github.com/alesapin)) -- Do not account memory for Buffer engine in max\_memory\_usage limit [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([Azat Khuzhin](https://github.com/azat)) -- Fix final mark usage in `MergeTree` tables ordered by `tuple()`. In rare cases it could lead to `Can't adjust last granule` error while select. [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([Anton Popov](https://github.com/CurtizJ)) -- Fix bug in mutations that have predicate with actions that require context (for example functions for json), which may lead to crashes or strange exceptions. [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([alesapin](https://github.com/alesapin)) -- Fix mismatch of database and table names escaping in `data/` and `shadow/` directories [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([Alexander Burmak](https://github.com/Alex-Burmak)) -- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. Fix crash in this case. [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix `Not found column in block` when joining on expression with RIGHT or FULL JOIN. [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([Artem Zuikov](https://github.com/4ertus2)) -- One more attempt to fix infinite loop in `PrettySpace` format [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([Olga Khvostikova](https://github.com/stavrolia)) -- Fix bug in `concat` function when all arguments were `FixedString` of the same size. [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([alesapin](https://github.com/alesapin)) -- Fixed exception in case of using 1 argument while defining S3, URL and HDFS storages. [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fix scope of the InterpreterSelectQuery for views with query [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([Azat Khuzhin](https://github.com/azat)) - -#### Improvement {#improvement} - -- `Nullable` columns recognized and NULL-values handled correctly by ODBC-bridge [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([Vasily Nemkov](https://github.com/Enmk)) -- Write current batch for distributed send atomically [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([Azat Khuzhin](https://github.com/azat)) -- Throw an exception if we cannot detect table for column name in query. [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([Artem Zuikov](https://github.com/4ertus2)) -- Add `merge_max_block_size` setting to `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([Artem Zuikov](https://github.com/4ertus2)) -- Queries with `HAVING` and without `GROUP BY` assume group by constant. So, `SELECT 1 HAVING 1` now returns a result. [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([Amos Bird](https://github.com/amosbird)) -- Support parsing `(X,)` as tuple similar to python. [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([Amos Bird](https://github.com/amosbird)) -- Make `range` function behaviors almost like pythonic one. [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([sundyli](https://github.com/sundy-li)) -- Add `constraints` columns to table `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([Vitaly Baranov](https://github.com/vitlibar)) -- Better Null format for tcp handler, so that it’s possible to use `select ignore() from table format Null` for perf measure via clickhouse-client [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([Amos Bird](https://github.com/amosbird)) -- Queries like `CREATE TABLE ... AS (SELECT (1, 2))` are parsed correctly [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([hcz](https://github.com/hczhcz)) - -#### Performance Improvement {#performance-improvement} - -- The performance of aggregation over short string keys is improved. [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([Alexander Kuzmenkov](https://github.com/akuzm), [Amos Bird](https://github.com/amosbird)) -- Run another pass of syntax/expression analysis to get potential optimizations after constant predicates are folded. [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([Amos Bird](https://github.com/amosbird)) -- Use storage meta info to evaluate trivial `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([Amos Bird](https://github.com/amosbird), [alexey-milovidov](https://github.com/alexey-milovidov)) -- Vectorize processing `arrayReduce` similar to Aggregator `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([Amos Bird](https://github.com/amosbird)) -- Minor improvements in performance of `Kafka` consumption [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([Ivan](https://github.com/abyss7)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement} - -- Add support for cross-compiling to the CPU architecture AARCH64. Refactor packager script. [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([Ivan](https://github.com/abyss7)) -- Unpack darwin-x86\_64 and linux-aarch64 toolchains into mounted Docker volume when building packages [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([Ivan](https://github.com/abyss7)) -- Update Docker Image for Binary Packager [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([Ivan](https://github.com/abyss7)) -- Fixed compile errors on MacOS Catalina [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([Ernest Poletaev](https://github.com/ernestp)) -- Some refactoring in query analysis logic: split complex class into several simple ones. [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix build without submodules [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([proller](https://github.com/proller)) -- Better `add_globs` in CMake files [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([Amos Bird](https://github.com/amosbird)) -- Remove hardcoded paths in `unwind` target [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([Konstantin Podshumok](https://github.com/podshumok)) -- Allow to use mysql format without ssl [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([proller](https://github.com/proller)) - -#### Other {#other} - -- Added ANTLR4 grammar for ClickHouse SQL dialect [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## ClickHouse release v19.16 {#clickhouse-release-v19-16} - -#### ClickHouse release v19.16.14.65, 2020-03-25 - -* Fixed up a bug in batched calculations of ternary logical OPs on multiple arguments (more than 10). [#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([Alexander Kazakov](https://github.com/Akazz)) This bugfix was backported to version 19.16 by a special request from Altinity. - -#### ClickHouse release v19.16.14.65, 2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} - -- Fix distributed subqueries incompatibility with older CH versions. Fixes [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) - [(tabplubix)](https://github.com/tavplubix) -- When executing `CREATE` query, fold constant expressions in storage engine arguments. Replace empty database name with current database. Fixes [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). Also fix check for local address in `ClickHouseDictionarySource`. - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) -- Now background merges in `*MergeTree` table engines family preserve storage policy volume order more accurately. - [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Prevent losing data in `Kafka` in rare cases when exception happens after reading suffix but before commit. Fixes [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). Related: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(filimonov)](https://github.com/filimonov) -- Fix bug leading to server termination when trying to use / drop `Kafka` table created with wrong parameters. Fixes [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). Incorporates [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(filimonov)](https://github.com/filimonov) -- Allow using `MaterializedView` with subqueries above `Kafka` tables. - [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([filimonov](https://github.com/filimonov)) - -#### New Feature {#new-feature-1} - -- Add `deduplicate_blocks_in_dependent_materialized_views` option to control the behaviour of idempotent inserts into tables with materialized views. This new feature was added to the bugfix release by a special request from Altinity. - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) - -### ClickHouse release v19.16.2.2, 2019-10-30 {#clickhouse-release-v19-16-2-2-2019-10-30} - -#### Backward Incompatible Change {#backward-incompatible-change-1} - -- Add missing arity validation for count/counIf. - [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) - [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([Vdimir](https://github.com/Vdimir)) -- Remove legacy `asterisk_left_columns_only` setting (it was disabled by default). - [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([Artem - Zuikov](https://github.com/4ertus2)) -- Format strings for Template data format are now specified in files. - [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([tavplubix](https://github.com/tavplubix)) - -#### New Feature {#new-feature-2} - -- Introduce uniqCombined64() to calculate cardinality greater than UINT\_MAX. - [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), - [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([Azat - Khuzhin](https://github.com/azat)) -- Support Bloom filter indexes on Array columns. - [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) - ([achimbab](https://github.com/achimbab)) -- Add a function `getMacro(name)` that returns String with the value of corresponding `` - from server configuration. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Set two configuration options for a dictionary based on an HTTP source: `credentials` and - `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([Guillaume - Tassery](https://github.com/YiuRULE)) -- Add a new ProfileEvent `Merge` that counts the number of launched background merges. - [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([Mikhail - Korotov](https://github.com/millb)) -- Add fullHostName function that returns a fully qualified domain name. - [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) - [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([sundyli](https://github.com/sundy-li)) -- Add function `arraySplit` and `arrayReverseSplit` which split an array by “cut off” - conditions. They are useful in time sequence handling. - [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([hcz](https://github.com/hczhcz)) -- Add new functions that return the Array of all matched indices in multiMatch family of functions. - [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([Danila - Kutenin](https://github.com/danlark1)) -- Add a new database engine `Lazy` that is optimized for storing a large number of small -Log - tables. [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([Nikita - Vasilev](https://github.com/nikvas0)) -- Add aggregate functions groupBitmapAnd, -Or, -Xor for bitmap columns. [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([Zhichang - Yu](https://github.com/yuzhichang)) -- Add aggregate function combinators -OrNull and -OrDefault, which return null - or default values when there is nothing to aggregate. - [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) - ([hcz](https://github.com/hczhcz)) -- Introduce CustomSeparated data format that supports custom escaping and - delimiter rules. [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([tavplubix](https://github.com/tavplubix)) -- Support Redis as source of external dictionary. [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([comunodi](https://github.com/comunodi), [Anton - Popov](https://github.com/CurtizJ)) - -#### Bug Fix {#bug-fix-2} - -- Fix wrong query result if it has `WHERE IN (SELECT ...)` section and `optimize_read_in_order` is - used. [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([Anton - Popov](https://github.com/CurtizJ)) -- Disabled MariaDB authentication plugin, which depends on files outside of project. - [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([Yuriy - Baranov](https://github.com/yurriy)) -- Fix exception `Cannot convert column ... because it is constant but values of constants are different in source and result` which could rarely happen when functions `now()`, `today()`, - `yesterday()`, `randConstant()` are used. - [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([Nikolai - Kochetov](https://github.com/KochetovNicolai)) -- Fixed issue of using HTTP keep alive timeout instead of TCP keep alive timeout. - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([Vasily - Nemkov](https://github.com/Enmk)) -- Fixed a segmentation fault in groupBitmapOr (issue [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). - [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([Zhichang - Yu](https://github.com/yuzhichang)) -- For materialized views the commit for Kafka is called after all data were written. - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([Ivan](https://github.com/abyss7)) -- Fixed wrong `duration_ms` value in `system.part_log` table. It was ten times off. - [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([Vladimir - Chebotarev](https://github.com/excitoon)) -- A quick fix to resolve crash in LIVE VIEW table and re-enabling all LIVE VIEW tests. - [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) - ([vzakaznikov](https://github.com/vzakaznikov)) -- Serialize NULL values correctly in min/max indexes of MergeTree parts. - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- Don’t put virtual columns to .sql metadata when table is created as `CREATE TABLE AS`. - [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([Ivan](https://github.com/abyss7)) -- Fix segmentation fault in `ATTACH PART` query. - [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) - ([alesapin](https://github.com/alesapin)) -- Fix wrong result for some queries given by the optimization of empty IN subqueries and empty - INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([Nikolai - Kochetov](https://github.com/KochetovNicolai)) -- Fixing AddressSanitizer error in the LIVE VIEW getHeader() method. - [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) - ([vzakaznikov](https://github.com/vzakaznikov)) - -#### Improvement {#improvement-1} - -- Add a message in case of queue\_wait\_max\_ms wait takes place. - [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([Azat - Khuzhin](https://github.com/azat)) -- Made setting `s3_min_upload_part_size` table-level. - [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([Vladimir - Chebotarev](https://github.com/excitoon)) -- Check TTL in StorageFactory. [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) - ([sundyli](https://github.com/sundy-li)) -- Squash left-hand blocks in partial merge join (optimization). - [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([Artem - Zuikov](https://github.com/4ertus2)) -- Do not allow non-deterministic functions in mutations of Replicated table engines, because this - can introduce inconsistencies between replicas. - [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([Alexander - Kazakov](https://github.com/Akazz)) -- Disable memory tracker while converting exception stack trace to string. It can prevent the loss - of error messages of type `Memory limit exceeded` on server, which caused the `Attempt to read after eof` exception on client. [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) - ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Miscellaneous format improvements. Resolves - [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), - [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), - [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), - [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) - [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) - ([tavplubix](https://github.com/tavplubix)) -- ClickHouse ignores values on the right side of IN operator that are not convertible to the left - side type. Make it work properly for compound types – Array and Tuple. - [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- Support missing inequalities for ASOF JOIN. It’s possible to join less-or-equal variant and strict - greater and less variants for ASOF column in ON syntax. - [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([Artem - Zuikov](https://github.com/4ertus2)) -- Optimize partial merge join. [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) - ([Artem Zuikov](https://github.com/4ertus2)) -- Do not use more than 98K of memory in uniqCombined functions. - [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), - [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([Azat - Khuzhin](https://github.com/azat)) -- Flush parts of right-hand joining table on disk in PartialMergeJoin (if there is not enough - memory). Load data back when needed. [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) - ([Artem Zuikov](https://github.com/4ertus2)) - -#### Performance Improvement {#performance-improvement-1} - -- Speed up joinGet with const arguments by avoiding data duplication. - [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([Amos - Bird](https://github.com/amosbird)) -- Return early if the subquery is empty. - [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) -- Optimize parsing of SQL expression in Values. - [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) - ([tavplubix](https://github.com/tavplubix)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-1} - -- Disable some contribs for cross-compilation to Mac OS. - [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([Ivan](https://github.com/abyss7)) -- Add missing linking with PocoXML for clickhouse\_common\_io. - [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([Azat - Khuzhin](https://github.com/azat)) -- Accept multiple test filter arguments in clickhouse-test. - [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- Enable musl and jemalloc for ARM. [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) - ([Amos Bird](https://github.com/amosbird)) -- Added `--client-option` parameter to `clickhouse-test` to pass additional parameters to client. - [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([Nikolai - Kochetov](https://github.com/KochetovNicolai)) -- Preserve existing configs on rpm package upgrade. - [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) - ([filimonov](https://github.com/filimonov)) -- Fix errors detected by PVS. [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([Artem - Zuikov](https://github.com/4ertus2)) -- Fix build for Darwin. [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) - ([Ivan](https://github.com/abyss7)) -- glibc 2.29 compatibility. [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([Amos - Bird](https://github.com/amosbird)) -- Make sure dh\_clean does not touch potential source files. - [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([Amos - Bird](https://github.com/amosbird)) -- Attempt to avoid conflict when updating from altinity rpm - it has config file packaged separately - in clickhouse-server-common. [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) - ([filimonov](https://github.com/filimonov)) -- Optimize some header files for faster rebuilds. - [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), - [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- Add performance tests for Date and DateTime. [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([Vasily - Nemkov](https://github.com/Enmk)) -- Fix some tests that contained non-deterministic mutations. - [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([Alexander - Kazakov](https://github.com/Akazz)) -- Add build with MemorySanitizer to CI. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) - ([Alexander Kuzmenkov](https://github.com/akuzm)) -- Avoid use of uninitialized values in MetricsTransmitter. - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat - Khuzhin](https://github.com/azat)) -- Fix some issues in Fields found by MemorySanitizer. - [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), - [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([Alexander - Kuzmenkov](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) - ([Amos Bird](https://github.com/amosbird)) -- Fix undefined behavior in murmurhash32. [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([Amos - Bird](https://github.com/amosbird)) -- Fix undefined behavior in StoragesInfoStream. [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) - ([tavplubix](https://github.com/tavplubix)) -- Fixed constant expressions folding for external database engines (MySQL, ODBC, JDBC). In previous - versions it wasn’t working for multiple constant expressions and was not working at all for Date, - DateTime and UUID. This fixes [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixing ThreadSanitizer data race error in the LIVE VIEW when accessing no\_users\_thread variable. - [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) - ([vzakaznikov](https://github.com/vzakaznikov)) -- Get rid of malloc symbols in libcommon - [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), - [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([Amos - Bird](https://github.com/amosbird)) -- Add global flag ENABLE\_LIBRARIES for disabling all libraries. - [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) - ([proller](https://github.com/proller)) - -#### Code cleanup {#code-cleanup} - -- Generalize configuration repository to prepare for DDL for Dictionaries. [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) - ([alesapin](https://github.com/alesapin)) -- Parser for dictionaries DDL without any semantic. - [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) - ([alesapin](https://github.com/alesapin)) -- Split ParserCreateQuery into different smaller parsers. - [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) - ([alesapin](https://github.com/alesapin)) -- Small refactoring and renaming near external dictionaries. - [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) - ([alesapin](https://github.com/alesapin)) -- Refactor some code to prepare for role-based access control. [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([Vitaly - Baranov](https://github.com/vitlibar)) -- Some improvements in DatabaseOrdinary code. - [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([Nikita - Vasilev](https://github.com/nikvas0)) -- Do not use iterators in find() and emplace() methods of hash tables. - [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- Fix getMultipleValuesFromConfig in case when parameter root is not empty. [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) - ([Mikhail Korotov](https://github.com/millb)) -- Remove some copy-paste (TemporaryFile and TemporaryFileStream) - [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([Artem - Zuikov](https://github.com/4ertus2)) -- Improved code readability a little bit (`MergeTreeData::getActiveContainingPart`). - [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([Vladimir - Chebotarev](https://github.com/excitoon)) -- Wait for all scheduled jobs, which are using local objects, if `ThreadPool::schedule(...)` throws - an exception. Rename `ThreadPool::schedule(...)` to `ThreadPool::scheduleOrThrowOnError(...)` and - fix comments to make obvious that it may throw. - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) - ([tavplubix](https://github.com/tavplubix)) - -## ClickHouse release 19.15 {#clickhouse-release-19-15} - -### ClickHouse release 19.15.4.10, 2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} - -#### Bug Fix {#bug-fix-3} - -- Added handling of SQL\_TINYINT and SQL\_BIGINT, and fix handling of SQL\_FLOAT data source types in ODBC Bridge. - [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) -- Allowed to have some parts on destination disk or volume in MOVE PARTITION. - [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fixed NULL-values in nullable columns through ODBC-bridge. - [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([Vasily Nemkov](https://github.com/Enmk)) -- Fixed INSERT into Distributed non local node with MATERIALIZED columns. - [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) -- Fixed function getMultipleValuesFromConfig. - [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([Mikhail Korotov](https://github.com/millb)) -- Fixed issue of using HTTP keep alive timeout instead of TCP keep alive timeout. - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([Vasily Nemkov](https://github.com/Enmk)) -- Wait for all jobs to finish on exception (fixes rare segfaults). - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([tavplubix](https://github.com/tavplubix)) -- Don’t push to MVs when inserting into Kafka table. - [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([Ivan](https://github.com/abyss7)) -- Disable memory tracker for exception stack. - [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed bad code in transforming query for external database. - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Avoid use of uninitialized values in MetricsTransmitter. - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat Khuzhin](https://github.com/azat)) -- Added example config with macros for tests ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.15.3.6, 2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} - -#### Bug Fix {#bug-fix-4} - -- Fixed bad\_variant in hashed dictionary. - ([alesapin](https://github.com/alesapin)) -- Fixed up bug with segmentation fault in ATTACH PART query. - ([alesapin](https://github.com/alesapin)) -- Fixed time calculation in `MergeTreeData`. - ([Vladimir Chebotarev](https://github.com/excitoon)) -- Commit to Kafka explicitly after the writing is finalized. - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([Ivan](https://github.com/abyss7)) -- Serialize NULL values correctly in min/max indexes of MergeTree parts. - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -### ClickHouse release 19.15.2.2, 2019-10-01 {#clickhouse-release-19-15-2-2-2019-10-01} - -#### New Feature {#new-feature-3} - -- Tiered storage: support to use multiple storage volumes for tables with MergeTree engine. It’s possible to store fresh data on SSD and automatically move old data to HDD. ([example](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([Igr](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([alesapin](https://github.com/alesapin)) -- Add table function `input` for reading incoming data in `INSERT SELECT` query. [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([palasonic1](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([Anton Popov](https://github.com/CurtizJ)) -- Add a `sparse_hashed` dictionary layout, that is functionally equivalent to the `hashed` layout, but is more memory efficient. It uses about twice as less memory at the cost of slower value retrieval. [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([Azat Khuzhin](https://github.com/azat)) -- Implement ability to define list of users for access to dictionaries. Only current connected database using. [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Add `LIMIT` option to `SHOW` query. [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([Philipp Malkovsky](https://github.com/malkfilipp)) -- Add `bitmapSubsetLimit(bitmap, range_start, limit)` function, that returns subset of the smallest `limit` values in set that is no smaller than `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([Zhichang Yu](https://github.com/yuzhichang)) -- Add `bitmapMin` and `bitmapMax` functions. [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([Zhichang Yu](https://github.com/yuzhichang)) -- Add function `repeat` related to [issue-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([flynn](https://github.com/ucasFL)) - -#### Experimental Feature {#experimental-feature-1} - -- Implement (in memory) Merge Join variant that does not change current pipeline. Result is partially sorted by merge key. Set `partial_merge_join = 1` to use this feature. The Merge Join is still in development. [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([Artem Zuikov](https://github.com/4ertus2)) -- Add `S3` engine and table function. It is still in development (no authentication support yet). [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([Vladimir Chebotarev](https://github.com/excitoon)) - -#### Improvement {#improvement-2} - -- Every message read from Kafka is inserted atomically. This resolves almost all known issues with Kafka engine. [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([Ivan](https://github.com/abyss7)) -- Improvements for failover of Distributed queries. Shorten recovery time, also it is now configurable and can be seen in `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([Vasily Nemkov](https://github.com/Enmk)) -- Support numeric values for Enums directly in `IN` section. \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([dimarub2000](https://github.com/dimarub2000)) -- Support (optional, disabled by default) redirects on URL storage. [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([maqroll](https://github.com/maqroll)) -- Add information message when client with an older version connects to a server. [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([Philipp Malkovsky](https://github.com/malkfilipp)) -- Remove maximum backoff sleep time limit for sending data in Distributed tables [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([Azat Khuzhin](https://github.com/azat)) -- Add ability to send profile events (counters) with cumulative values to graphite. It can be enabled under `` in server `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([Azat Khuzhin](https://github.com/azat)) -- Add automatically cast type `T` to `LowCardinality(T)` while inserting data in column of type `LowCardinality(T)` in Native format via HTTP. [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Add ability to use function `hex` without using `reinterpretAsString` for `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([Mikhail Korotov](https://github.com/millb)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-2} - -- Add gdb-index to clickhouse binary with debug info. It will speed up startup time of `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([alesapin](https://github.com/alesapin)) -- Speed up deb packaging with patched dpkg-deb which uses `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([alesapin](https://github.com/alesapin)) -- Set `enable_fuzzing = 1` to enable libfuzzer instrumentation of all the project code. [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([kyprizel](https://github.com/kyprizel)) -- Add split build smoke test in CI. [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([alesapin](https://github.com/alesapin)) -- Add build with MemorySanitizer to CI. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- Replace `libsparsehash` with `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([Azat Khuzhin](https://github.com/azat)) - -#### Bug Fix {#bug-fix-5} - -- Fixed performance degradation of index analysis on complex keys on large tables. This fixes \#6924. [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix logical error causing segfaults when selecting from Kafka empty topic. [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([Ivan](https://github.com/abyss7)) -- Fix too early MySQL connection close in `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- Returned support for very old Linux kernels (fix [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix possible data loss in `insert select` query in case of empty block in input stream. \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix for function `АrrayEnumerateUniqRanked` with empty arrays in params [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) -- Fix complex queries with array joins and global subqueries. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([Ivan](https://github.com/abyss7)) -- Fix `Unknown identifier` error in ORDER BY and GROUP BY with multiple JOINs [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed `MSan` warning while executing function with `LowCardinality` argument. [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### Backward Incompatible Change {#backward-incompatible-change-2} - -- Changed serialization format of bitmap\* aggregate function states to improve performance. Serialized states of bitmap\* from previous versions cannot be read. [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([Zhichang Yu](https://github.com/yuzhichang)) - -## ClickHouse release 19.14 {#clickhouse-release-19-14} - -### ClickHouse release 19.14.7.15, 2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} - -#### Bug Fix {#bug-fix-6} - -- This release also contains all bug fixes from 19.11.12.69. -- Fixed compatibility for distributed queries between 19.14 and earlier versions. This fixes [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.14.6.12, 2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} - -#### Bug Fix {#bug-fix-7} - -- Fix for function `АrrayEnumerateUniqRanked` with empty arrays in params. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) -- Fixed subquery name in queries with `ARRAY JOIN` and `GLOBAL IN subquery` with alias. Use subquery alias for external table name if it is specified. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([Ivan](https://github.com/abyss7)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-3} - -- Fix [flapping](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) test `00715_fetch_merged_or_mutated_part_zookeeper` by rewriting it to a shell scripts because it needs to wait for mutations to apply. [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([Alexander Kazakov](https://github.com/Akazz)) -- Fixed UBSan and MemSan failure in function `groupUniqArray` with emtpy array argument. It was caused by placing of empty `PaddedPODArray` into hash table zero cell because constructor for zero cell value was not called. [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([Amos Bird](https://github.com/amosbird)) - -### ClickHouse release 19.14.3.3, 2019-09-10 {#clickhouse-release-19-14-3-3-2019-09-10} - -#### New Feature {#new-feature-4} - -- `WITH FILL` modifier for `ORDER BY`. (continuation of [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([Anton Popov](https://github.com/CurtizJ)) -- `WITH TIES` modifier for `LIMIT`. (continuation of [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([Anton Popov](https://github.com/CurtizJ)) -- Parse unquoted `NULL` literal as NULL (if setting `format_csv_unquoted_null_literal_as_null=1`). Initialize null fields with default values if data type of this field is not nullable (if setting `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([tavplubix](https://github.com/tavplubix)) -- Support for wildcards in paths of table functions `file` and `hdfs`. If the path contains wildcards, the table will be readonly. Example of usage: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` and `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([Olga Khvostikova](https://github.com/stavrolia)) -- New `system.metric_log` table which stores values of `system.events` and `system.metrics` with specified time interval. [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Allow to write ClickHouse text logs to `system.text_log` table. [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Show private symbols in stack traces (this is done via parsing symbol tables of ELF files). Added information about file and line number in stack traces if debug info is present. Speedup symbol name lookup with indexing symbols present in program. Added new SQL functions for introspection: `demangle` and `addressToLine`. Renamed function `symbolizeAddress` to `addressToSymbol` for consistency. Function `addressToSymbol` will return mangled name for performance reasons and you have to apply `demangle`. Added setting `allow_introspection_functions` which is turned off by default. [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Table function `values` (the name is case-insensitive). It allows to read from `VALUES` list proposed in [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). Example: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) -- Added an ability to alter storage settings. Syntax: `ALTER TABLE
MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([alesapin](https://github.com/alesapin)) -- Support for removing of detached parts. Syntax: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([tavplubix](https://github.com/tavplubix)) -- Table constraints. Allows to add constraint to table definition which will be checked at insert. [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([Gleb Novikov](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Suppport for cascaded materialized views. [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([Amos Bird](https://github.com/amosbird)) -- Turn on query profiler by default to sample every query execution thread once a second. [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Input format `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([akonyaev90](https://github.com/akonyaev90)) -- Added two new functions: `sigmoid` and `tanh` (that are useful for machine learning applications). [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Function `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` to check if given token is in haystack. Token is a maximal length substring between two non alphanumeric ASCII characters (or boundaries of haystack). Token must be a constant string. Supported by tokenbf\_v1 index specialization. [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([Vasily Nemkov](https://github.com/Enmk)) -- New function `neighbor(value, offset[, default_value])`. Allows to reach prev/next value within column in a block of data. [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([Alex Krash](https://github.com/alex-krash)) [6685365ab8c5b74f9650492c88a012596eb1b0c6](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341e2e4587a18065c2da1ca888c73389f48ce36c](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [Alexey Milovidov](https://github.com/alexey-milovidov) -- Created a function `currentUser()`, returning login of authorized user. Added alias `user()` for compatibility with MySQL. [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([Alex Krash](https://github.com/alex-krash)) -- New aggregate functions `quantilesExactInclusive` and `quantilesExactExclusive` which were proposed in [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([dimarub2000](https://github.com/dimarub2000)) -- Function `bitmapRange(bitmap, range_begin, range_end)` which returns new set with specified range (not include the `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([Zhichang Yu](https://github.com/yuzhichang)) -- Function `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` which creates array of precision-long strings of geohash-boxes covering provided area. [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([Vasily Nemkov](https://github.com/Enmk)) -- Implement support for INSERT query with `Kafka` tables. [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([Ivan](https://github.com/abyss7)) -- Added support for `_partition` and `_timestamp` virtual columns to Kafka engine. [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([Ivan](https://github.com/abyss7)) -- Possibility to remove sensitive data from `query_log`, server logs, process list with regexp-based rules. [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([filimonov](https://github.com/filimonov)) - -#### Experimental Feature {#experimental-feature-2} - -- Input and output data format `Template`. It allows to specify custom format string for input and output. [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([tavplubix](https://github.com/tavplubix)) -- Implementation of `LIVE VIEW` tables that were originally proposed in [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898), prepared in [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925), and then updated in [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). See [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) for detailed description. [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([vzakaznikov](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([vzakaznikov](https://github.com/vzakaznikov)) Note that `LIVE VIEW` feature may be removed in next versions. - -#### Bug Fix {#bug-fix-8} - -- This release also contains all bug fixes from 19.13 and 19.11. -- Fix segmentation fault when the table has skip indices and vertical merge happens. [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([alesapin](https://github.com/alesapin)) -- Fix per-column TTL with non-trivial column defaults. Previously in case of force TTL merge with `OPTIMIZE ... FINAL` query, expired values was replaced by type defaults instead of user-specified column defaults. [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([Anton Popov](https://github.com/CurtizJ)) -- Fix Kafka messages duplication problem on normal server restart. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([Ivan](https://github.com/abyss7)) -- Fixed infinite loop when reading Kafka messages. Do not pause/resume consumer on subscription at all - otherwise it may get paused indefinitely in some scenarios. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([Ivan](https://github.com/abyss7)) -- Fix `Key expression contains comparison between inconvertible types` exception in `bitmapContains` function. [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([dimarub2000](https://github.com/dimarub2000)) -- Fix segfault with enabled `optimize_skip_unused_shards` and missing sharding key. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([Anton Popov](https://github.com/CurtizJ)) -- Fixed wrong code in mutations that may lead to memory corruption. Fixed segfault with read of address `0x14c0` that may happed due to concurrent `DROP TABLE` and `SELECT` from `system.parts` or `system.parts_columns`. Fixed race condition in preparation of mutation queries. Fixed deadlock caused by `OPTIMIZE` of Replicated tables and concurrent modification operations like ALTERs. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Removed extra verbose logging in MySQL interface [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Return the ability to parse boolean settings from ‘true’ and ‘false’ in the configuration file. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([alesapin](https://github.com/alesapin)) -- Fix crash in `quantile` and `median` function over `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed possible incomplete result returned by `SELECT` query with `WHERE` condition on primary key contained conversion to Float type. It was caused by incorrect checking of monotonicity in `toFloat` function. [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) -- Check `max_expanded_ast_elements` setting for mutations. Clear mutations after `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([Winter Zhang](https://github.com/zhang2014)) -- Fix JOIN results for key columns when used with `join_use_nulls`. Attach Nulls instead of columns defaults. [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix for skip indices with vertical merge and alter. Fix for `Bad size of marks file` exception. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([alesapin](https://github.com/alesapin)) -- Fix rare crash in `ALTER MODIFY COLUMN` and vertical merge when one of merged/altered parts is empty (0 rows) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([alesapin](https://github.com/alesapin)) -- Fixed bug in conversion of `LowCardinality` types in `AggregateFunctionFactory`. This fixes [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix wrong behavior and possible segfaults in `topK` and `topKWeighted` aggregated functions. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([Anton Popov](https://github.com/CurtizJ)) -- Fixed unsafe code around `getIdentifier` function. [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed bug in MySQL wire protocol (is used while connecting to ClickHouse form MySQL client). Caused by heap buffer overflow in `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([Yuriy Baranov](https://github.com/yurriy)) -- Fixed memory leak in `bitmapSubsetInRange` function. [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([Zhichang Yu](https://github.com/yuzhichang)) -- Fix rare bug when mutation executed after granularity change. [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([alesapin](https://github.com/alesapin)) -- Allow protobuf message with all fields by default. [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([Vitaly Baranov](https://github.com/vitlibar)) -- Resolve a bug with `nullIf` function when we send a `NULL` argument on the second argument. [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Fix rare bug with wrong memory allocation/deallocation in complex key cache dictionaries with string fields which leads to infinite memory consumption (looks like memory leak). Bug reproduces when string size was a power of two starting from eight (8, 16, 32, etc). [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([alesapin](https://github.com/alesapin)) -- Fixed Gorilla encoding on small sequences which caused exception `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Vasily Nemkov](https://github.com/Enmk)) -- Allow to use not nullable types in JOINs with `join_use_nulls` enabled. [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([Artem Zuikov](https://github.com/4ertus2)) -- Disable `Poco::AbstractConfiguration` substitutions in query in `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Avoid deadlock in `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Using `arrayReduce` for constant arguments may lead to segfault. [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix inconsistent parts which can appear if replica was restored after `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- Fixed hang in `JSONExtractRaw` function. [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix bug with incorrect skip indices serialization and aggregation with adaptive granularity. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([alesapin](https://github.com/alesapin)) -- Fix `WITH ROLLUP` and `WITH CUBE` modifiers of `GROUP BY` with two-level aggregation. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([Anton Popov](https://github.com/CurtizJ)) -- Fix bug with writing secondary indices marks with adaptive granularity. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alesapin](https://github.com/alesapin)) -- Fix initialization order while server startup. Since `StorageMergeTree::background_task_handle` is initialized in `startup()` the `MergeTreeBlockOutputStream::write()` may try to use it before initialization. Just check if it is initialized. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([Ivan](https://github.com/abyss7)) -- Clearing the data buffer from the previous read operation that was completed with an error. [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([Nikolay](https://github.com/bopohaa)) -- Fix bug with enabling adaptive granularity when creating a new replica for Replicated\*MergeTree table. [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([alesapin](https://github.com/alesapin)) -- Fixed possible crash during server startup in case of exception happened in `libunwind` during exception at access to uninitialized `ThreadStatus` structure. [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- Fix crash in `yandexConsistentHash` function. Found by fuzz test. [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed the possibility of hanging queries when server is overloaded and global thread pool becomes near full. This have higher chance to happen on clusters with large number of shards (hundreds), because distributed queries allocate a thread per connection to each shard. For example, this issue may reproduce if a cluster of 330 shards is processing 30 concurrent distributed queries. This issue affects all versions starting from 19.2. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed logic of `arrayEnumerateUniqRanked` function. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix segfault when decoding symbol table. [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([Amos Bird](https://github.com/amosbird)) -- Fixed irrelevant exception in cast of `LowCardinality(Nullable)` to not-Nullable column in case if it doesn’t contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Removed extra quoting of description in `system.settings` table. [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Avoid possible deadlock in `TRUNCATE` of Replicated table. [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix reading in order of sorting key. [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([Anton Popov](https://github.com/CurtizJ)) -- Fix `ALTER TABLE ... UPDATE` query for tables with `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) -- Fix bug opened by [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (since 19.4.0). Reproduces in queries to Distributed tables over MergeTree tables when we doesn’t query any columns (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([alesapin](https://github.com/alesapin)) -- Fixed overflow in integer division of signed type to unsigned type. The behaviour was exactly as in C or C++ language (integer promotion rules) that may be surprising. Please note that the overflow is still possible when dividing large signed number to large unsigned number or vice-versa (but that case is less usual). The issue existed in all server versions. [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Limit maximum sleep time for throttling when `max_execution_speed` or `max_execution_speed_bytes` is set. Fixed false errors like `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed issues about using `MATERIALIZED` columns and aliases in `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([Amos Bird](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix `FormatFactory` behaviour for input streams which are not implemented as processor. [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed typo. [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([Alex Ryndin](https://github.com/alexryndin)) -- Typo in the error message ( is -\> are ). [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([Denis Zhuravlev](https://github.com/den-crane)) -- Fixed error while parsing of columns list from string if type contained a comma (this issue was relevant for `File`, `URL`, `HDFS` storages) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) - -#### Security Fix {#security-fix} - -- This release also contains all bug security fixes from 19.13 and 19.11. -- Fixed the possibility of a fabricated query to cause server crash due to stack overflow in SQL parser. Fixed the possibility of stack overflow in Merge and Distributed tables, materialized views and conditions for row-level security that involve subqueries. [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Improvement {#improvement-3} - -- Correct implementation of ternary logic for `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([Alexander Kazakov](https://github.com/Akazz)) -- Now values and rows with expired TTL will be removed after `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` query. Added queries `SYSTEM STOP/START TTL MERGES` to disallow/allow assign merges with TTL and filter expired values in all merges. [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([Anton Popov](https://github.com/CurtizJ)) -- Possibility to change the location of ClickHouse history file for client using `CLICKHOUSE_HISTORY_FILE` env. [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([filimonov](https://github.com/filimonov)) -- Remove `dry_run` flag from `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Support `ASOF JOIN` with `ON` section. [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([Artem Zuikov](https://github.com/4ertus2)) -- Better support of skip indexes for mutations and replication. Support for `MATERIALIZE/CLEAR INDEX ... IN PARTITION` query. `UPDATE x = x` recalculates all indices that use column `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([Nikita Vasilev](https://github.com/nikvas0)) -- Allow to `ATTACH` live views (for example, at the server startup) regardless to `allow_experimental_live_view` setting. [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- For stack traces gathered by query profiler, do not include stack frames generated by the query profiler itself. [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Now table functions `values`, `file`, `url`, `hdfs` have support for ALIAS columns. [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Throw an exception if `config.d` file doesn’t have the corresponding root element as the config file. [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) -- Print extra info in exception message for `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([tavplubix](https://github.com/tavplubix)) -- When determining shards of a `Distributed` table to be covered by a read query (for `optimize_skip_unused_shards` = 1) ClickHouse now checks conditions from both `prewhere` and `where` clauses of select statement. [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([Alexander Kazakov](https://github.com/Akazz)) -- Enabled `SIMDJSON` for machines without AVX2 but with SSE 4.2 and PCLMUL instruction set. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ClickHouse can work on filesystems without `O_DIRECT` support (such as ZFS and BtrFS) without additional tuning. [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Support push down predicate for final subquery. [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([TCeason](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Better `JOIN ON` keys extraction [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([Artem Zuikov](https://github.com/4ertus2)) -- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Optimize selecting of smallest column for `SELECT count()` query. [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([Amos Bird](https://github.com/amosbird)) -- Added `strict` parameter in `windowFunnel()`. When the `strict` is set, the `windowFunnel()` applies conditions only for the unique values. [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([achimbab](https://github.com/achimbab)) -- Safer interface of `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([avasiliev](https://github.com/avasiliev)) -- Options line size when executing with `--help` option now corresponds with terminal size. [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([dimarub2000](https://github.com/dimarub2000)) -- Disable “read in order” optimization for aggregation without keys. [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([Anton Popov](https://github.com/CurtizJ)) -- HTTP status code for `INCORRECT_DATA` and `TYPE_MISMATCH` error codes was changed from default `500 Internal Server Error` to `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([Alexander Rodin](https://github.com/a-rodin)) -- Move Join object from `ExpressionAction` into `AnalyzedJoin`. `ExpressionAnalyzer` and `ExpressionAction` do not know about `Join` class anymore. Its logic is hidden by `AnalyzedJoin` iface. [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed possible deadlock of distributed queries when one of shards is localhost but the query is sent via network connection. [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Changed semantic of multiple tables `RENAME` to avoid possible deadlocks. [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Rewritten MySQL compatibility server to prevent loading full packet payload in memory. Decreased memory consumption for each connection to approximately `2 * DBMS_DEFAULT_BUFFER_SIZE` (read/write buffers). [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([Yuriy Baranov](https://github.com/yurriy)) -- Move AST alias interpreting logic out of parser that doesn’t have to know anything about query semantics. [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([Artem Zuikov](https://github.com/4ertus2)) -- Slightly more safe parsing of `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `clickhouse-copier`: Allow use `where_condition` from config with `partition_key` alias in query for checking partition existence (Earlier it was used only in reading data queries). [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([proller](https://github.com/proller)) -- Added optional message argument in `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([Vdimir](https://github.com/Vdimir)) -- Server exception got while sending insertion data is now being processed in client as well. [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([dimarub2000](https://github.com/dimarub2000)) -- Added a metric `DistributedFilesToInsert` that shows the total number of files in filesystem that are selected to send to remote servers by Distributed tables. The number is summed across all shards. [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Move most of JOINs prepare logic from `ExpressionAction/ExpressionAnalyzer` to `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix TSan [warning](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([Vasily Nemkov](https://github.com/Enmk)) -- Better information messages about lack of Linux capabilities. Logging fatal errors with “fatal” level, that will make it easier to find in `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- When enable dumping temporary data to the disk to restrict memory usage during `GROUP BY`, `ORDER BY`, it didn’t check the free disk space. The fix add a new setting `min_free_disk_space`, when the free disk space it smaller then the threshold, the query will stop and throw `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([Weiqing Xu](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Removed recursive rwlock by thread. It makes no sense, because threads are reused between queries. `SELECT` query may acquire a lock in one thread, hold a lock from another thread and exit from first thread. In the same time, first thread can be reused by `DROP` query. This will lead to false “Attempt to acquire exclusive lock recursively” messages. [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Split `ExpressionAnalyzer.appendJoin()`. Prepare a place in `ExpressionAnalyzer` for `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([Artem Zuikov](https://github.com/4ertus2)) -- Added `mysql_native_password` authentication plugin to MySQL compatibility server. [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([Yuriy Baranov](https://github.com/yurriy)) -- Less number of `clock_gettime` calls; fixed ABI compatibility between debug/release in `Allocator` (insignificant issue). [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Move `collectUsedColumns` from `ExpressionAnalyzer` to `SyntaxAnalyzer`. `SyntaxAnalyzer` makes `required_source_columns` itself now. [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([Artem Zuikov](https://github.com/4ertus2)) -- Add setting `joined_subquery_requires_alias` to require aliases for subselects and table functions in `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([Artem Zuikov](https://github.com/4ertus2)) -- Extract `GetAggregatesVisitor` class from `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([Artem Zuikov](https://github.com/4ertus2)) -- `system.query_log`: change data type of `type` column to `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- Static linking of `sha256_password` authentication plugin. [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([Yuriy Baranov](https://github.com/yurriy)) -- Avoid extra dependency for the setting `compile` to work. In previous versions, the user may get error like `cannot open crti.o`, `unable to find library -lc` etc. [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- More validation of the input that may come from malicious replica. [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Now `clickhouse-obfuscator` file is available in `clickhouse-client` package. In previous versions it was available as `clickhouse obfuscator` (with whitespace). [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([dimarub2000](https://github.com/dimarub2000)) -- Fixed deadlock when we have at least two queries that read at least two tables in different order and another query that performs DDL operation on one of tables. Fixed another very rare deadlock. [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added `os_thread_ids` column to `system.processes` and `system.query_log` for better debugging possibilities. [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- A workaround for PHP mysqlnd extension bugs which occur when `sha256_password` is used as a default authentication plugin (described in [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([Yuriy Baranov](https://github.com/yurriy)) -- Remove unneeded place with changed nullability columns. [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([Artem Zuikov](https://github.com/4ertus2)) -- Set default value of `queue_max_wait_ms` to zero, because current value (five seconds) makes no sense. There are rare circumstances when this settings has any use. Added settings `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` and `connection_pool_max_wait_ms` for disambiguation. [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Extract `SelectQueryExpressionAnalyzer` from `ExpressionAnalyzer`. Keep the last one for non-select queries. [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([Artem Zuikov](https://github.com/4ertus2)) -- Removed duplicating input and output formats. [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Allow user to override `poll_interval` and `idle_connection_timeout` settings on connection. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `MergeTree` now has an additional option `ttl_only_drop_parts` (disabled by default) to avoid partial pruning of parts, so that they dropped completely when all the rows in a part are expired. [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([Sergi Vladykin](https://github.com/svladykin)) -- Type checks for set index functions. Throw exception if function got a wrong type. This fixes fuzz test with UBSan. [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([Nikita Vasilev](https://github.com/nikvas0)) - -#### Performance Improvement {#performance-improvement-2} - -- Optimize queries with `ORDER BY expressions` clause, where `expressions` have coinciding prefix with sorting key in `MergeTree` tables. This optimization is controlled by `optimize_read_in_order` setting. [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([Anton Popov](https://github.com/CurtizJ)) -- Allow to use multiple threads during parts loading and removal. [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Implemented batch variant of updating aggregate function states. It may lead to performance benefits. [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Using `FastOps` library for functions `exp`, `log`, `sigmoid`, `tanh`. FastOps is a fast vector math library from Michael Parakhin (Yandex CTO). Improved performance of `exp` and `log` functions more than 6 times. The functions `exp` and `log` from `Float32` argument will return `Float32` (in previous versions they always return `Float64`). Now `exp(nan)` may return `inf`. The result of `exp` and `log` functions may be not the nearest machine representable number to the true answer. [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([alexey-milovidov](https://github.com/alexey-milovidov)) Using Danila Kutenin variant to make fastops working [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Disable consecutive key optimization for `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([akuzm](https://github.com/akuzm)) -- Improved performance of `simdjson` library by getting rid of dynamic allocation in `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([Vitaly Baranov](https://github.com/vitlibar)) -- Pre-fault pages when allocating memory with `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([akuzm](https://github.com/akuzm)) -- Fix performance bug in `Decimal` comparison. [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-4} - -- Remove Compiler (runtime template instantiation) because we’ve win over it’s performance. [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added performance test to show degradation of performance in gcc-9 in more isolated way. [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added table function `numbers_mt`, which is multithreaded version of `numbers`. Updated performance tests with hash functions. [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Comparison mode in `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([dimarub2000](https://github.com/dimarub2000)) -- Best effort for printing stack traces. Also added `SIGPROF` as a debugging signal to print stack trace of a running thread. [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Every function in its own file, part 10. [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Remove doubled const `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([filimonov](https://github.com/filimonov)) -- Formatting changes for `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([akuzm](https://github.com/akuzm)) -- Better subquery for join creation in `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([Artem Zuikov](https://github.com/4ertus2)) -- Remove a redundant condition (found by PVS Studio). [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([akuzm](https://github.com/akuzm)) -- Separate the hash table interface for `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([akuzm](https://github.com/akuzm)) -- Refactoring of settings. [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([alesapin](https://github.com/alesapin)) -- Add comments for `set` index functions. [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([Nikita Vasilev](https://github.com/nikvas0)) -- Increase OOM score in debug version on Linux. [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([akuzm](https://github.com/akuzm)) -- HDFS HA now work in debug build. [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([Weiqing Xu](https://github.com/weiqxu)) -- Added a test to `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add test for multiple materialized views for Kafka table. [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([Ivan](https://github.com/abyss7)) -- Make a better build scheme. [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([Ivan](https://github.com/abyss7)) -- Fixed `test_external_dictionaries` integration in case it was executed under non root user. [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- The bug reproduces when total size of written packets exceeds `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([Yuriy Baranov](https://github.com/yurriy)) -- Added a test for `RENAME` table race condition [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Avoid data race on Settings in `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add integration test for handling errors by a cache dictionary. [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([Vitaly Baranov](https://github.com/vitlibar)) -- Disable parsing of ELF object files on Mac OS, because it makes no sense. [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Attempt to make changelog generator better. [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Adding `-Wshadow` switch to the GCC. [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- Removed obsolete code for `mimalloc` support. [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `zlib-ng` determines x86 capabilities and saves this info to global variables. This is done in defalteInit call, which may be made by different threads simultaneously. To avoid multithreaded writes, do it on library startup. [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([akuzm](https://github.com/akuzm)) -- Regression test for a bug which in join which was fixed in [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([Bakhtiyor Ruziev](https://github.com/theruziev)) -- Fixed MSan report. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix flapping TTL test. [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([Anton Popov](https://github.com/CurtizJ)) -- Fixed false data race in `MergeTreeDataPart::is_frozen` field. [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed timeouts in fuzz test. In previous version, it managed to find false hangup in query `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added debug checks to `static_cast` of columns. [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Support for Oracle Linux in official RPM packages. [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Changed json perftests from `once` to `loop` type. [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- `odbc-bridge.cpp` defines `main()` so it should not be included in `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([Orivej Desh](https://github.com/orivej)) -- Test for crash in `FULL|RIGHT JOIN` with nulls in right table’s keys. [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([Artem Zuikov](https://github.com/4ertus2)) -- Added a test for the limit on expansion of aliases just in case. [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Switched from `boost::filesystem` to `std::filesystem` where appropriate. [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added RPM packages to website. [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add a test for fixed `Unknown identifier` exception in `IN` section. [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([Artem Zuikov](https://github.com/4ertus2)) -- Simplify `shared_ptr_helper` because people facing difficulties understanding it. [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added performance tests for fixed Gorilla and DoubleDelta codec. [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([Vasily Nemkov](https://github.com/Enmk)) -- Split the integration test `test_dictionaries` into 4 separate tests. [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix PVS-Studio warning in `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Allow to use `library` dictionary source with ASan. [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added option to generate changelog from a list of PRs. [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Lock the `TinyLog` storage when reading. [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([akuzm](https://github.com/akuzm)) -- Check for broken symlinks in CI. [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Increase timeout for “stack overflow” test because it may take a long time in debug build. [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added a check for double whitespaces. [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix `new/delete` memory tracking when build with sanitizers. Tracking is not clear. It only prevents memory limit exceptions in tests. [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([Artem Zuikov](https://github.com/4ertus2)) -- Enable back the check of undefined symbols while linking. [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([Ivan](https://github.com/abyss7)) -- Avoid rebuilding `hyperscan` every day. [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed UBSan report in `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Don’t allow to use query profiler with sanitizers because it is not compatible. [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add test for reloading a dictionary after fail by timer. [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix inconsistency in `PipelineExecutor::prepareProcessor` argument type. [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Added a test for bad URIs. [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added more checks to `CAST` function. This should get more information about segmentation fault in fuzzy test. [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Added `gcc-9` support to `docker/builder` container that builds image locally. [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([Gleb Novikov](https://github.com/NanoBjorn)) -- Test for primary key with `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([dimarub2000](https://github.com/dimarub2000)) -- Fixed tests affected by slow stack traces printing. [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add a test case for crash in `groupUniqArray` fixed in [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([akuzm](https://github.com/akuzm)) -- Fixed indices mutations tests. [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([Nikita Vasilev](https://github.com/nikvas0)) -- In performance test, do not read query log for queries we didn’t run. [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([akuzm](https://github.com/akuzm)) -- Materialized view now could be created with any low cardinality types regardless to the setting about suspicious low cardinality types. [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([Olga Khvostikova](https://github.com/stavrolia)) -- Updated tests for `send_logs_level` setting. [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix build under gcc-8.2. [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([Max Akhmedov](https://github.com/zlobober)) -- Fix build with internal libc++. [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([Ivan](https://github.com/abyss7)) -- Fix shared build with `rdkafka` library [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([Ivan](https://github.com/abyss7)) -- Fixes for Mac OS build (incomplete). [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([alex-zaitsev](https://github.com/alex-zaitsev)) -- Fix “splitted” build. [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Other build fixes: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([Amos Bird](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([vxider](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([Ivan](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([proller](https://github.com/proller)) - -#### Backward Incompatible Change {#backward-incompatible-change-3} - -- Removed rarely used table function `catBoostPool` and storage `CatBoostPool`. If you have used this table function, please write email to `clickhouse-feedback@yandex-team.com`. Note that CatBoost integration remains and will be supported. [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Disable `ANY RIGHT JOIN` and `ANY FULL JOIN` by default. Set `any_join_distinct_right_table_keys` setting to enable them. [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([Artem Zuikov](https://github.com/4ertus2)) - -## ClickHouse release 19.13 {#clickhouse-release-19-13} - -### ClickHouse release 19.13.6.51, 2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} - -#### Bug Fix {#bug-fix-9} - -- This release also contains all bug fixes from 19.11.12.69. - -### ClickHouse release 19.13.5.44, 2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} - -#### Bug Fix {#bug-fix-10} - -- This release also contains all bug fixes from 19.14.6.12. -- Fixed possible inconsistent state of table while executing `DROP` query for replicated table while zookeeper is not accessible. [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- Fix for data race in StorageMerge [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix bug introduced in query profiler which leads to endless recv from socket. [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([alesapin](https://github.com/alesapin)) -- Fix excessive CPU usage while executing `JSONExtractRaw` function over a boolean value. [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fixes the regression while pushing to materialized view. [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([Ivan](https://github.com/abyss7)) -- Table function `url` had the vulnerability allowed the attacker to inject arbitrary HTTP headers in the request. This issue was found by [Nikita Tikhomirov](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix useless `AST` check in Set index. [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([Nikita Vasilev](https://github.com/nikvas0)) -- Fixed parsing of `AggregateFunction` values embedded in query. [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([Zhichang Yu](https://github.com/yuzhichang)) -- Fixed wrong behaviour of `trim` functions family. [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.13.4.32, 2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} - -#### Bug Fix {#bug-fix-11} - -- This release also contains all bug security fixes from 19.11.9.52 and 19.11.10.54. -- Fixed data race in `system.parts` table and `ALTER` query. [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed mismatched header in streams happened in case of reading from empty distributed table with sample and prewhere. [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([Lixiang Qian](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed crash when using `IN` clause with a subquery with a tuple. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- Fix case with same column names in `GLOBAL JOIN ON` section. [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix crash when casting types to `Decimal` that do not support it. Throw exception instead. [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed crash in `extractAll()` function. [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([Artem Zuikov](https://github.com/4ertus2)) -- Query transformation for `MySQL`, `ODBC`, `JDBC` table functions now works properly for `SELECT WHERE` queries with multiple `AND` expressions. [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([dimarub2000](https://github.com/dimarub2000)) -- Added previous declaration checks for MySQL 8 integration. [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([Rafael David Tinoco](https://github.com/rafaeldtinoco)) - -#### Security Fix {#security-fix-1} - -- Fix two vulnerabilities in codecs in decompression phase (malicious user can fabricate compressed data that will lead to buffer overflow in decompression). [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([Artem Zuikov](https://github.com/4ertus2)) - -### ClickHouse release 19.13.3.26, 2019-08-22 {#clickhouse-release-19-13-3-26-2019-08-22} - -#### Bug Fix {#bug-fix-12} - -- Fix `ALTER TABLE ... UPDATE` query for tables with `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) -- Fix NPE when using IN clause with a subquery with a tuple. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- Fixed an issue that if a stale replica becomes alive, it may still have data parts that were removed by DROP PARTITION. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- Fixed issue with parsing CSV [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) -- Fixed data race in system.parts table and ALTER query. This fixes [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed wrong code in mutations that may lead to memory corruption. Fixed segfault with read of address `0x14c0` that may happed due to concurrent `DROP TABLE` and `SELECT` from `system.parts` or `system.parts_columns`. Fixed race condition in preparation of mutation queries. Fixed deadlock caused by `OPTIMIZE` of Replicated tables and concurrent modification operations like ALTERs. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed possible data loss after `ALTER DELETE` query on table with skipping index. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([Nikita Vasilev](https://github.com/nikvas0)) - -#### Security Fix {#security-fix-2} - -- If the attacker has write access to ZooKeeper and is able to run custom server available from the network where ClickHouse run, it can create custom-built malicious server that will act as ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. Found by Eldar Zaitov, information security team at Yandex. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.13.2.19, 2019-08-14 {#clickhouse-release-19-13-2-19-2019-08-14} - -#### New Feature {#new-feature-5} - -- Sampling profiler on query level. [Example](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) -- Allow to specify a list of columns with `COLUMNS('regexp')` expression that works like a more sophisticated variant of `*` asterisk. [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([mfridental](https://github.com/mfridental)), ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `CREATE TABLE AS table_function()` is now possible [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([dimarub2000](https://github.com/dimarub2000)) -- Adam optimizer for stochastic gradient descent is used by default in `stochasticLinearRegression()` and `stochasticLogisticRegression()` aggregate functions, because it shows good quality without almost any tuning. [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([Quid37](https://github.com/Quid37)) -- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([Andy Yang](https://github.com/andyyzh)) -- `RENAME` queries now work with all storages. [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([Ivan](https://github.com/abyss7)) -- Now client receive logs from server with any desired level by setting `send_logs_level` regardless to the log level specified in server settings. [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) - -#### Backward Incompatible Change {#backward-incompatible-change-4} - -- The setting `input_format_defaults_for_omitted_fields` is enabled by default. Inserts in Distributed tables need this setting to be the same on cluster (you need to set it before rolling update). It enables calculation of complex default expressions for omitted fields in `JSONEachRow` and `CSV*` formats. It should be the expected behavior but may lead to negligible performance difference. [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([Artem Zuikov](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) - -#### Experimental features {#experimental-features} - -- New query processing pipeline. Use `experimental_use_processors=1` option to enable it. Use for your own trouble. [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### Bug Fix {#bug-fix-13} - -- Kafka integration has been fixed in this version. -- Fixed `DoubleDelta` encoding of `Int64` for large `DoubleDelta` values, improved `DoubleDelta` encoding for random data for `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([Vasily Nemkov](https://github.com/Enmk)) -- Fixed overestimation of `max_rows_to_read` if the setting `merge_tree_uniform_read_distribution` is set to 0. [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Improvement {#improvement-4} - -- Throws an exception if `config.d` file doesn’t have the corresponding root element as the config file [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) - -#### Performance Improvement {#performance-improvement-3} - -- Optimize `count()`. Now it uses the smallest column (if possible). [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([Amos Bird](https://github.com/amosbird)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-5} - -- Report memory usage in performance tests. [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([akuzm](https://github.com/akuzm)) -- Fix build with external `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([Ivan](https://github.com/abyss7)) -- Fix shared build with `rdkafka` library [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([Ivan](https://github.com/abyss7)) - -## ClickHouse release 19.11 {#clickhouse-release-19-11} - -### ClickHouse release 19.11.13.74, 2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} - -#### Bug Fix {#bug-fix-14} - -- Fixed rare crash in `ALTER MODIFY COLUMN` and vertical merge when one of merged/altered parts is empty (0 rows). [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([alesapin](https://github.com/alesapin)) -- Manual update of `SIMDJSON`. This fixes possible flooding of stderr files with bogus json diagnostic messages. [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([Alexander Kazakov](https://github.com/Akazz)) -- Fixed bug with `mrk` file extension for mutations ([alesapin](https://github.com/alesapin)) - -### ClickHouse release 19.11.12.69, 2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} - -#### Bug Fix {#bug-fix-15} - -- Fixed performance degradation of index analysis on complex keys on large tables. This fixes [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Avoid rare SIGSEGV while sending data in tables with Distributed engine (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([Azat Khuzhin](https://github.com/azat)) -- Fix `Unknown identifier` with multiple joins. This fixes [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) - -### ClickHouse release 19.11.11.57, 2019-09-13 {#clickhouse-release-19-11-11-57-2019-09-13} - -- Fix logical error causing segfaults when selecting from Kafka empty topic. [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([Ivan](https://github.com/abyss7)) -- Fix for function `АrrayEnumerateUniqRanked` with empty arrays in params. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) - -### ClickHouse release 19.11.10.54, 2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} - -#### Bug Fix {#bug-fix-16} - -- Do store offsets for Kafka messages manually to be able to commit them all at once for all partitions. Fixes potential duplication in “one consumer - many partitions” scenario. [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([Ivan](https://github.com/abyss7)) - -### ClickHouse release 19.11.9.52, 2019-09-6 {#clickhouse-release-19-11-9-52-2019-09-6} - -- Improve error handling in cache dictionaries. [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fixed bug in function `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([proller](https://github.com/proller)) -- Fix `JSONExtract` function while extracting a `Tuple` from JSON. [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fixed possible data loss after `ALTER DELETE` query on table with skipping index. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([Nikita Vasilev](https://github.com/nikvas0)) -- Fixed performance test. [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Parquet: Fix reading boolean columns. [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed wrong behaviour of `nullIf` function for constant arguments. [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([Guillaume Tassery](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix Kafka messages duplication problem on normal server restart. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([Ivan](https://github.com/abyss7)) -- Fixed an issue when long `ALTER UPDATE` or `ALTER DELETE` may prevent regular merges to run. Prevent mutations from executing if there is no enough free threads available. [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([tavplubix](https://github.com/tavplubix)) -- Fixed error with processing “timezone” in server configuration file. [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix kafka tests. [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([Ivan](https://github.com/abyss7)) - -#### Security Fix {#security-fix-3} - -- If the attacker has write access to ZooKeeper and is able to run custom server available from the network where ClickHouse runs, it can create custom-built malicious server that will act as ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. Found by Eldar Zaitov, information security team at Yandex. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.11.8.46, 2019-08-22 {#clickhouse-release-19-11-8-46-2019-08-22} - -#### Bug Fix {#bug-fix-17} - -- Fix `ALTER TABLE ... UPDATE` query for tables with `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) -- Fix NPE when using IN clause with a subquery with a tuple. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- Fixed an issue that if a stale replica becomes alive, it may still have data parts that were removed by DROP PARTITION. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- Fixed issue with parsing CSV [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) -- Fixed data race in system.parts table and ALTER query. This fixes [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed wrong code in mutations that may lead to memory corruption. Fixed segfault with read of address `0x14c0` that may happed due to concurrent `DROP TABLE` and `SELECT` from `system.parts` or `system.parts_columns`. Fixed race condition in preparation of mutation queries. Fixed deadlock caused by `OPTIMIZE` of Replicated tables and concurrent modification operations like ALTERs. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.11.7.40, 2019-08-14 {#clickhouse-release-19-11-7-40-2019-08-14} - -#### Bug fix {#bug-fix-18} - -- Kafka integration has been fixed in this version. -- Fix segfault when using `arrayReduce` for constant arguments. [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed `toFloat()` monotonicity. [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) -- Fix segfault with enabled `optimize_skip_unused_shards` and missing sharding key. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([CurtizJ](https://github.com/CurtizJ)) -- Fixed logic of `arrayEnumerateUniqRanked` function. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Removed extra verbose logging from MySQL handler. [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix wrong behavior and possible segfaults in `topK` and `topKWeighted` aggregated functions. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([CurtizJ](https://github.com/CurtizJ)) -- Do not expose virtual columns in `system.columns` table. This is required for backward compatibility. [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix bug with memory allocation for string fields in complex key cache dictionary. [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([alesapin](https://github.com/alesapin)) -- Fix bug with enabling adaptive granularity when creating new replica for `Replicated*MergeTree` table. [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([alesapin](https://github.com/alesapin)) -- Fix infinite loop when reading Kafka messages. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([abyss7](https://github.com/abyss7)) -- Fixed the possibility of a fabricated query to cause server crash due to stack overflow in SQL parser and possibility of stack overflow in `Merge` and `Distributed` tables [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed Gorilla encoding error on small sequences. [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Enmk](https://github.com/Enmk)) - -#### Improvement {#improvement-5} - -- Allow user to override `poll_interval` and `idle_connection_timeout` settings on connection. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.11.5.28, 2019-08-05 {#clickhouse-release-19-11-5-28-2019-08-05} - -#### Bug fix {#bug-fix-19} - -- Fixed the possibility of hanging queries when server is overloaded. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix FPE in yandexConsistentHash function. This fixes [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed bug in conversion of `LowCardinality` types in `AggregateFunctionFactory`. This fixes [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix parsing of `bool` settings from `true` and `false` strings in configuration files. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([alesapin](https://github.com/alesapin)) -- Fix rare bug with incompatible stream headers in queries to `Distributed` table over `MergeTree` table when part of `WHERE` moves to `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([alesapin](https://github.com/alesapin)) -- Fixed overflow in integer division of signed type to unsigned type. This fixes [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Backward Incompatible Change {#backward-incompatible-change-5} - -- `Kafka` still broken. - -### ClickHouse release 19.11.4.24, 2019-08-01 {#clickhouse-release-19-11-4-24-2019-08-01} - -#### Bug Fix {#bug-fix-20} - -- Fix bug with writing secondary indices marks with adaptive granularity. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alesapin](https://github.com/alesapin)) -- Fix `WITH ROLLUP` and `WITH CUBE` modifiers of `GROUP BY` with two-level aggregation. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([Anton Popov](https://github.com/CurtizJ)) -- Fixed hang in `JSONExtractRaw` function. Fixed [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix segfault in ExternalLoader::reloadOutdated(). [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fixed the case when server may close listening sockets but not shutdown and continue serving remaining queries. You may end up with two running clickhouse-server processes. Sometimes, the server may return an error `bad_function_call` for remaining queries. [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed useless and incorrect condition on update field for initial loading of external dictionaries via ODBC, MySQL, ClickHouse and HTTP. This fixes [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed irrelevant exception in cast of `LowCardinality(Nullable)` to not-Nullable column in case if it doesn’t contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix non-deterministic result of “uniq” aggregate function in extreme rare cases. The bug was present in all ClickHouse versions. [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Segfault when we set a little bit too high CIDR on the function `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Fixed small memory leak when server throw many exceptions from many different contexts. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix the situation when consumer got paused before subscription and not resumed afterwards. [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([Ivan](https://github.com/abyss7)) Note that Kafka is broken in this version. -- Clearing the Kafka data buffer from the previous read operation that was completed with an error [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([Nikolay](https://github.com/bopohaa)) Note that Kafka is broken in this version. -- Since `StorageMergeTree::background_task_handle` is initialized in `startup()` the `MergeTreeBlockOutputStream::write()` may try to use it before initialization. Just check if it is initialized. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([Ivan](https://github.com/abyss7)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-6} - -- Added official `rpm` packages. [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([proller](https://github.com/proller)) ([alesapin](https://github.com/alesapin)) -- Add an ability to build `.rpm` and `.tgz` packages with `packager` script. [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([alesapin](https://github.com/alesapin)) -- Fixes for “Arcadia” build system. [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([proller](https://github.com/proller)) - -#### Backward Incompatible Change {#backward-incompatible-change-6} - -- `Kafka` is broken in this version. - -### ClickHouse release 19.11.3.11, 2019-07-18 {#clickhouse-release-19-11-3-11-2019-07-18} - -#### New Feature {#new-feature-6} - -- Added support for prepared statements. [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([Alexander](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `DoubleDelta` and `Gorilla` column codecs [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([Vasily Nemkov](https://github.com/Enmk)) -- Added `os_thread_priority` setting that allows to control the “nice” value of query processing threads that is used by OS to adjust dynamic scheduling priority. It requires `CAP_SYS_NICE` capabilities to work. This implements [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Implement `_topic`, `_offset`, `_key` columns for Kafka engine [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([Ivan](https://github.com/abyss7)) Note that Kafka is broken in this version. -- Add aggregate function combinator `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([hcz](https://github.com/hczhcz)) -- Aggregate functions `groupArrayMovingSum(win_size)(x)` and `groupArrayMovingAvg(win_size)(x)`, which calculate moving sum/avg with or without window-size limitation. [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([inv2004](https://github.com/inv2004)) -- Add synonim `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([hcz](https://github.com/hczhcz)) -- Intergate H3 function `geoToH3` from Uber. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen Ivan](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Bug Fix {#bug-fix-21} - -- Implement DNS cache with asynchronous update. Separate thread resolves all hosts and updates DNS cache with period (setting `dns_cache_update_period`). It should help, when ip of hosts changes frequently. [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([Anton Popov](https://github.com/CurtizJ)) -- Fix segfault in `Delta` codec which affects columns with values less than 32 bits size. The bug led to random memory corruption. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([alesapin](https://github.com/alesapin)) -- Fix segfault in TTL merge with non-physical columns in block. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([Anton Popov](https://github.com/CurtizJ)) -- Fix rare bug in checking of part with `LowCardinality` column. Previously `checkDataPart` always fails for part with `LowCardinality` column. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([alesapin](https://github.com/alesapin)) -- Avoid hanging connections when server thread pool is full. It is important for connections from `remote` table function or connections to a shard without replicas when there is long connection timeout. This fixes [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Support for constant arguments to `evalMLModel` function. This fixes [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed the issue when ClickHouse determines default time zone as `UCT` instead of `UTC`. This fixes [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed buffer underflow in `visitParamExtractRaw`. This fixes [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Now distributed `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` queries will be executed directly on leader replica. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([alesapin](https://github.com/alesapin)) -- Fix `coalesce` for `ColumnConst` with `ColumnNullable` + related changes. [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix the `ReadBufferFromKafkaConsumer` so that it keeps reading new messages after `commit()` even if it was stalled before [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([Ivan](https://github.com/abyss7)) -- Fix `FULL` and `RIGHT` JOIN results when joining on `Nullable` keys in right table. [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([Artem Zuikov](https://github.com/4ertus2)) -- Possible fix of infinite sleeping of low-priority queries. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix race condition, which cause that some queries may not appear in query\_log after `SYSTEM FLUSH LOGS` query. [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([Anton Popov](https://github.com/CurtizJ)) -- Fixed `heap-use-after-free` ASan warning in ClusterCopier caused by watch which try to use already removed copier object. [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed wrong `StringRef` pointer returned by some implementations of `IColumn::deserializeAndInsertFromArena`. This bug affected only unit-tests. [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Prevent source and intermediate array join columns of masking same name columns. [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix insert and select query to MySQL engine with MySQL style identifier quoting. [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([Winter Zhang](https://github.com/zhang2014)) -- Now `CHECK TABLE` query can work with MergeTree engine family. It returns check status and message if any for each part (or file in case of simplier engines). Also, fix bug in fetch of a broken part. [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([alesapin](https://github.com/alesapin)) -- Fix SPLIT\_SHARED\_LIBRARIES runtime [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([Danila Kutenin](https://github.com/danlark1)) -- Fixed time zone initialization when `/etc/localtime` is a relative symlink like `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- clickhouse-copier: Fix use-after free on shutdown [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([proller](https://github.com/proller)) -- Updated `simdjson`. Fixed the issue that some invalid JSONs with zero bytes successfully parse. [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix shutdown of SystemLogs [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([Anton Popov](https://github.com/CurtizJ)) -- Fix hanging when condition in invalidate\_query depends on a dictionary. [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([Vitaly Baranov](https://github.com/vitlibar)) - -#### Improvement {#improvement-6} - -- Allow unresolvable addresses in cluster configuration. They will be considered unavailable and tried to resolve at every connection attempt. This is especially useful for Kubernetes. This fixes [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Close idle TCP connections (with one hour timeout by default). This is especially important for large clusters with multiple distributed tables on every server, because every server can possibly keep a connection pool to every other server, and after peak query concurrency, connections will stall. This fixes [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Better quality of `topK` function. Changed the SavingSpace set behavior to remove the last element if the new element have a bigger weight. [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([Guillaume Tassery](https://github.com/YiuRULE)) -- URL functions to work with domains now can work for incomplete URLs without scheme [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([alesapin](https://github.com/alesapin)) -- Checksums added to the `system.parts_columns` table. [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- Added `Enum` data type as a synonim for `Enum8` or `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([dimarub2000](https://github.com/dimarub2000)) -- Full bit transpose variant for `T64` codec. Could lead to better compression with `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([Artem Zuikov](https://github.com/4ertus2)) -- Condition on `startsWith` function now can uses primary key. This fixes [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) and [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([dimarub2000](https://github.com/dimarub2000)) -- Allow to use `clickhouse-copier` with cross-replication cluster topology by permitting empty database name. [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([nvartolomei](https://github.com/nvartolomei)) -- Use `UTC` as default timezone on a system without `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` was printed and server or client refused to start. [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Returned back support for floating point argument in function `quantileTiming` for backward compatibility. [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Show which table is missing column in error messages. [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([Ivan](https://github.com/abyss7)) -- Disallow run query with same query\_id by various users [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([proller](https://github.com/proller)) -- More robust code for sending metrics to Graphite. It will work even during long multiple `RENAME TABLE` operation. [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- More informative error messages will be displayed when ThreadPool cannot schedule a task for execution. This fixes [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Inverting ngramSearch to be more intuitive [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([Danila Kutenin](https://github.com/danlark1)) -- Add user parsing in HDFS engine builder [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([akonyaev90](https://github.com/akonyaev90)) -- Update default value of `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([Artem Konovalov](https://github.com/izebit)) -- Added a notion of obsolete settings. The obsolete setting `allow_experimental_low_cardinality_type` can be used with no effect. [0f15c01c6802f7ce1a1494c12c846be8c98944cd](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [Alexey Milovidov](https://github.com/alexey-milovidov) - -#### Performance Improvement {#performance-improvement-4} - -- Increase number of streams to SELECT from Merge table for more uniform distribution of threads. Added setting `max_streams_multiplier_for_merge_tables`. This fixes [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-7} - -- Add a backward compatibility test for client-server interaction with different versions of clickhouse. [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([alesapin](https://github.com/alesapin)) -- Test coverage information in every commit and pull request. [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([alesapin](https://github.com/alesapin)) -- Cooperate with address sanitizer to support our custom allocators (`Arena` and `ArenaWithFreeLists`) for better debugging of “use-after-free” errors. [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([akuzm](https://github.com/akuzm)) -- Switch to [LLVM libunwind implementation](https://github.com/llvm-mirror/libunwind) for C++ exception handling and for stack traces printing [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([Nikita Lapkov](https://github.com/laplab)) -- Add two more warnings from -Weverything [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Allow to build ClickHouse with Memory Sanitizer. [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed ubsan report about `bitTest` function in fuzz test. [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Docker: added possibility to init a ClickHouse instance which requires authentication. [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([Korviakov Andrey](https://github.com/shurshun)) -- Update librdkafka to version 1.1.0 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([Ivan](https://github.com/abyss7)) -- Add global timeout for integration tests and disable some of them in tests code. [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([alesapin](https://github.com/alesapin)) -- Fix some ThreadSanitizer failures. [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([akuzm](https://github.com/akuzm)) -- The `--no-undefined` option forces the linker to check all external names for existence while linking. It’s very useful to track real dependencies between libraries in the split build mode. [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([Ivan](https://github.com/abyss7)) -- Added performance test for [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed compatibility with gcc-7. [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added support for gcc-9. This fixes [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed error when libunwind can be linked incorrectly. [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed a few warnings found by PVS-Studio. [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added initial support for `clang-tidy` static analyzer. [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Convert BSD/Linux endian macros( ‘be64toh’ and ‘htobe64’) to the Mac OS X equivalents [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([Fu Chen](https://github.com/fredchenbj)) -- Improved integration tests guide. [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Fixing build at macosx + gcc9 [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([filimonov](https://github.com/filimonov)) -- Fix a hard-to-spot typo: aggreAGte -\> aggregate. [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([akuzm](https://github.com/akuzm)) -- Fix freebsd build [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([proller](https://github.com/proller)) -- Add link to experimental YouTube channel to website [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([Ivan Blinkov](https://github.com/blinkov)) -- CMake: add option for coverage flags: WITH\_COVERAGE [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([proller](https://github.com/proller)) -- Fix initial size of some inline PODArray’s. [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([akuzm](https://github.com/akuzm)) -- clickhouse-server.postinst: fix os detection for centos 6 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([proller](https://github.com/proller)) -- Added Arch linux package generation. [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Split Common/config.h by libs (dbms) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([proller](https://github.com/proller)) -- Fixes for “Arcadia” build platform [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([proller](https://github.com/proller)) -- Fixes for unconventional build (gcc9, no submodules) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([proller](https://github.com/proller)) -- Require explicit type in unalignedStore because it was proven to be bug-prone [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([akuzm](https://github.com/akuzm)) -- Fixes MacOS build [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([filimonov](https://github.com/filimonov)) -- Performance test concerning the new JIT feature with bigger dataset, as requested here [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Run stateful tests in stress test [12693e568722f11e19859742f56428455501fd2a](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([alesapin](https://github.com/alesapin)) - -#### Backward Incompatible Change {#backward-incompatible-change-7} - -- `Kafka` is broken in this version. -- Enable `adaptive_index_granularity` = 10MB by default for new `MergeTree` tables. If you created new MergeTree tables on version 19.11+, downgrade to versions prior to 19.6 will be impossible. [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([alesapin](https://github.com/alesapin)) -- Removed obsolete undocumented embedded dictionaries that were used by Yandex.Metrica. The functions `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` are no longer available. If you are using these functions, write email to clickhouse-feedback@yandex-team.com. Note: at the last moment we decided to keep these functions for a while. [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## ClickHouse release 19.10 {#clickhouse-release-19-10} - -### ClickHouse release 19.10.1.5, 2019-07-12 {#clickhouse-release-19-10-1-5-2019-07-12} - -#### New Feature {#new-feature-7} - -- Add new column codec: `T64`. Made for (U)IntX/EnumX/Data(Time)/DecimalX columns. It should be good for columns with constant or small range values. Codec itself allows enlarge or shrink data type without re-compression. [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([Artem Zuikov](https://github.com/4ertus2)) -- Add database engine `MySQL` that allow to view all the tables in remote MySQL server [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([Winter Zhang](https://github.com/zhang2014)) -- `bitmapContains` implementation. It’s 2x faster than `bitmapHasAny` if the second bitmap contains one element. [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([Zhichang Yu](https://github.com/yuzhichang)) -- Support for `crc32` function (with behaviour exactly as in MySQL or PHP). Do not use it if you need a hash function. [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen Ivan](https://github.com/BHYCHIK)) -- Implemented `SYSTEM START/STOP DISTRIBUTED SENDS` queries to control asynchronous inserts into `Distributed` tables. [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([Winter Zhang](https://github.com/zhang2014)) - -#### Bug Fix {#bug-fix-22} - -- Ignore query execution limits and max parts size for merge limits while executing mutations. [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([Anton Popov](https://github.com/CurtizJ)) -- Fix bug which may lead to deduplication of normal blocks (extremely rare) and insertion of duplicate blocks (more often). [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([alesapin](https://github.com/alesapin)) -- Fix of function `arrayEnumerateUniqRanked` for arguments with empty arrays [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([proller](https://github.com/proller)) -- Don’t subscribe to Kafka topics without intent to poll any messages. [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([Ivan](https://github.com/abyss7)) -- Make setting `join_use_nulls` get no effect for types that cannot be inside Nullable [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([Olga Khvostikova](https://github.com/stavrolia)) -- Fixed `Incorrect size of index granularity` errors [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([coraxster](https://github.com/coraxster)) -- Fix Float to Decimal convert overflow [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([coraxster](https://github.com/coraxster)) -- Flush buffer when `WriteBufferFromHDFS`’s destructor is called. This fixes writing into `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([Xindong Peng](https://github.com/eejoin)) - -#### Improvement {#improvement-7} - -- Treat empty cells in `CSV` as default values when the setting `input_format_defaults_for_omitted_fields` is enabled. [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) -- Non-blocking loading of external dictionaries. [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([Vitaly Baranov](https://github.com/vitlibar)) -- Network timeouts can be dynamically changed for already established connections according to the settings. [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([Konstantin Podshumok](https://github.com/podshumok)) -- Using “public\_suffix\_list” for functions `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. It’s using a perfect hash table generated by `gperf` with a list generated from the file: https://publicsuffix.org/list/public\_suffix\_list.dat. (for example, now we recognize the domain `ac.uk` as non-significant). [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Adopted `IPv6` data type in system tables; unified client info columns in `system.processes` and `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Using sessions for connections with MySQL compatibility protocol. \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([Yuriy Baranov](https://github.com/yurriy)) -- Support more `ALTER` queries `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([sundyli](https://github.com/sundy-li)) -- Support `` section in `clickhouse-local` config file. [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([proller](https://github.com/proller)) -- Allow run query with `remote` table function in `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([proller](https://github.com/proller)) - -#### Performance Improvement {#performance-improvement-5} - -- Add the possibility to write the final mark at the end of MergeTree columns. It allows to avoid useless reads for keys that are out of table data range. It is enabled only if adaptive index granularity is in use. [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([alesapin](https://github.com/alesapin)) -- Improved performance of MergeTree tables on very slow filesystems by reducing number of `stat` syscalls. [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed performance degradation in reading from MergeTree tables that was introduced in version 19.6. Fixes \#5631. [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-8} - -- Implemented `TestKeeper` as an implementation of ZooKeeper interface used for testing [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([alexey-milovidov](https://github.com/alexey-milovidov)) ([levushkin aleksej](https://github.com/alexey-milovidov)) -- From now on `.sql` tests can be run isolated by server, in parallel, with random database. It allows to run them faster, add new tests with custom server configurations, and be sure that different tests doesn’t affect each other. [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([Ivan](https://github.com/abyss7)) -- Remove `` and `` from performance tests [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([Olga Khvostikova](https://github.com/stavrolia)) -- Fixed “select\_format” performance test for `Pretty` formats [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## ClickHouse release 19.9 {#clickhouse-release-19-9} - -### ClickHouse release 19.9.3.31, 2019-07-05 {#clickhouse-release-19-9-3-31-2019-07-05} - -#### Bug Fix {#bug-fix-23} - -- Fix segfault in Delta codec which affects columns with values less than 32 bits size. The bug led to random memory corruption. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([alesapin](https://github.com/alesapin)) -- Fix rare bug in checking of part with LowCardinality column. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([alesapin](https://github.com/alesapin)) -- Fix segfault in TTL merge with non-physical columns in block. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([Anton Popov](https://github.com/CurtizJ)) -- Fix potential infinite sleeping of low-priority queries. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix how ClickHouse determines default time zone as UCT instead of UTC. [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix bug about executing distributed DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER queries on follower replica before leader replica. Now they will be executed directly on leader replica. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([alesapin](https://github.com/alesapin)) -- Fix race condition, which cause that some queries may not appear in query\_log instantly after SYSTEM FLUSH LOGS query. [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([Anton Popov](https://github.com/CurtizJ)) -- Added missing support for constant arguments to `evalMLModel` function. [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.9.2.4, 2019-06-24 {#clickhouse-release-19-9-2-4-2019-06-24} - -#### New Feature {#new-feature-8} - -- Print information about frozen parts in `system.parts` table. [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([proller](https://github.com/proller)) -- Ask client password on clickhouse-client start on tty if not set in arguments [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([proller](https://github.com/proller)) -- Implement `dictGet` and `dictGetOrDefault` functions for Decimal types. [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Improvement {#improvement-8} - -- Debian init: Add service stop timeout [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([proller](https://github.com/proller)) -- Add setting forbidden by default to create table with suspicious types for LowCardinality [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([Olga Khvostikova](https://github.com/stavrolia)) -- Regression functions return model weights when not used as State in function `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([Quid37](https://github.com/Quid37)) -- Rename and improve regression methods. [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([Quid37](https://github.com/Quid37)) -- Clearer interfaces of string searchers. [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([Danila Kutenin](https://github.com/danlark1)) - -#### Bug Fix {#bug-fix-24} - -- Fix potential data loss in Kafka [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([Ivan](https://github.com/abyss7)) -- Fix potential infinite loop in `PrettySpace` format when called with zero columns [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([Olga Khvostikova](https://github.com/stavrolia)) -- Fixed UInt32 overflow bug in linear models. Allow eval ML model for non-const model argument. [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- `ALTER TABLE ... DROP INDEX IF EXISTS ...` should not raise an exception if provided index does not exist [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([Gleb Novikov](https://github.com/NanoBjorn)) -- Fix segfault with `bitmapHasAny` in scalar subquery [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) -- Fixed error when replication connection pool doesn’t retry to resolve host, even when DNS cache was dropped. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([alesapin](https://github.com/alesapin)) -- Fixed `ALTER ... MODIFY TTL` on ReplicatedMergeTree. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([Anton Popov](https://github.com/CurtizJ)) -- Fix INSERT into Distributed table with MATERIALIZED column [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) -- Fix bad alloc when truncate Join storage [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([TCeason](https://github.com/TCeason)) -- In recent versions of package tzdata some of files are symlinks now. The current mechanism for detecting default timezone gets broken and gives wrong names for some timezones. Now at least we force the timezone name to the contents of TZ if provided. [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([Ivan](https://github.com/abyss7)) -- Fix some extremely rare cases with MultiVolnitsky searcher when the constant needles in sum are at least 16KB long. The algorithm missed or overwrote the previous results which can lead to the incorrect result of `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([Danila Kutenin](https://github.com/danlark1)) -- Fix the issue when settings for ExternalData requests couldn’t use ClickHouse settings. Also, for now, settings `date_time_input_format` and `low_cardinality_allow_in_native_format` cannot be used because of the ambiguity of names (in external data it can be interpreted as table format and in the query it can be a setting). [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila Kutenin](https://github.com/danlark1)) -- Fix bug when parts were removed only from FS without dropping them from Zookeeper. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([alesapin](https://github.com/alesapin)) -- Remove debug logging from MySQL protocol [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Skip ZNONODE during DDL query processing [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) -- Fix mix `UNION ALL` result column type. There were cases with inconsistent data and column types of resulting columns. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) -- Throw an exception on wrong integers in `dictGetT` functions instead of crash. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix wrong element\_count and load\_factor for hashed dictionary in `system.dictionaries` table. [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-9} - -- Fixed build without `Brotli` HTTP compression support (`ENABLE_BROTLI=OFF` cmake variable). [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([Anton Yuzhaninov](https://github.com/citrin)) -- Include roaring.h as roaring/roaring.h [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([Orivej Desh](https://github.com/orivej)) -- Fix gcc9 warnings in hyperscan (\#line directive is evil!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([Danila Kutenin](https://github.com/danlark1)) -- Fix all warnings when compiling with gcc-9. Fix some contrib issues. Fix gcc9 ICE and submit it to bugzilla. [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([Danila Kutenin](https://github.com/danlark1)) -- Fixed linking with lld [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Remove unused specializations in dictionaries [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([Artem Zuikov](https://github.com/4ertus2)) -- Improvement performance tests for formatting and parsing tables for different types of files [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([Olga Khvostikova](https://github.com/stavrolia)) -- Fixes for parallel test run [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([proller](https://github.com/proller)) -- Docker: use configs from clickhouse-test [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([proller](https://github.com/proller)) -- Fix compile for FreeBSD [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([proller](https://github.com/proller)) -- Upgrade boost to 1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([proller](https://github.com/proller)) -- Fix build clickhouse as submodule [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([proller](https://github.com/proller)) -- Improve JSONExtract performance tests [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([Vitaly Baranov](https://github.com/vitlibar)) - -## ClickHouse release 19.8 {#clickhouse-release-19-8} - -### ClickHouse release 19.8.3.8, 2019-06-11 {#clickhouse-release-19-8-3-8-2019-06-11} - -#### New Features {#new-features} - -- Added functions to work with JSON [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([hcz](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([Vitaly Baranov](https://github.com/vitlibar)) -- Add a function basename, with a similar behaviour to a basename function, which exists in a lot of languages (`os.path.basename` in python, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Added `LIMIT n, m BY` or `LIMIT m OFFSET n BY` syntax to set offset of n for LIMIT BY clause. [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([Anton Popov](https://github.com/CurtizJ)) -- Added new data type `SimpleAggregateFunction`, which allows to have columns with light aggregation in an `AggregatingMergeTree`. This can only be used with simple functions like `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([Boris Granveaud](https://github.com/bgranvea)) -- Added support for non-constant arguments in function `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([Danila Kutenin](https://github.com/danlark1)) -- Added functions `skewPop`, `skewSamp`, `kurtPop` and `kurtSamp` to compute for sequence skewness, sample skewness, kurtosis and sample kurtosis respectively. [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([hcz](https://github.com/hczhcz)) -- Support rename operation for `MaterializeView` storage. [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Added server which allows connecting to ClickHouse using MySQL client. [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([Yuriy Baranov](https://github.com/yurriy)) -- Add `toDecimal*OrZero` and `toDecimal*OrNull` functions. [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([Artem Zuikov](https://github.com/4ertus2)) -- Support Decimal types in functions: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted`, medianExactWeighted. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) -- Added `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([Danila Kutenin](https://github.com/danlark1)) -- Added `format` function. Formatting constant pattern (simplified Python format pattern) with the strings listed in the arguments. [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([Danila Kutenin](https://github.com/danlark1)) -- Added `system.detached_parts` table containing information about detached parts of `MergeTree` tables. [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([akuzm](https://github.com/akuzm)) -- Added `ngramSearch` function to calculate the non-symmetric difference between needle and haystack. [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([Danila Kutenin](https://github.com/danlark1)) -- Implementation of basic machine learning methods (stochastic linear regression and logistic regression) using aggregate functions interface. Has different strategies for updating model weights (simple gradient descent, momentum method, Nesterov method). Also supports mini-batches of custom size. [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([Quid37](https://github.com/Quid37)) -- Implementation of `geohashEncode` and `geohashDecode` functions. [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([Vasily Nemkov](https://github.com/Enmk)) -- Added aggregate function `timeSeriesGroupSum`, which can aggregate different time series that sample timestamp not alignment. It will use linear interpolation between two sample timestamp and then sum time-series together. Added aggregate function `timeSeriesGroupRateSum`, which calculates the rate of time-series and then sum rates together. [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([Yangkuan Liu](https://github.com/LiuYangkuan)) -- Added functions `IPv4CIDRtoIPv4Range` and `IPv6CIDRtoIPv6Range` to calculate the lower and higher bounds for an IP in the subnet using a CIDR. [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([Guillaume Tassery](https://github.com/YiuRULE)) -- Add a X-ClickHouse-Summary header when we send a query using HTTP with enabled setting `send_progress_in_http_headers`. Return the usual information of X-ClickHouse-Progress, with additional information like how many rows and bytes were inserted in the query. [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([Guillaume Tassery](https://github.com/YiuRULE)) - -#### Improvements {#improvements} - -- Added `max_parts_in_total` setting for MergeTree family of tables (default: 100 000) that prevents unsafe specification of partition key \#5166. [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `clickhouse-obfuscator`: derive seed for individual columns by combining initial seed with column name, not column position. This is intended to transform datasets with multiple related tables, so that tables will remain JOINable after transformation. [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added functions `JSONExtractRaw`, `JSONExtractKeyAndValues`. Renamed functions `jsonExtract` to `JSONExtract`. When something goes wrong these functions return the correspondent values, not `NULL`. Modified function `JSONExtract`, now it gets the return type from its last parameter and doesn’t inject nullables. Implemented fallback to RapidJSON in case AVX2 instructions are not available. Simdjson library updated to a new version. [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([Vitaly Baranov](https://github.com/vitlibar)) -- Now `if` and `multiIf` functions don’t rely on the condition’s `Nullable`, but rely on the branches for sql compatibility. [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([Jian Wu](https://github.com/janplus)) -- `In` predicate now generates `Null` result from `Null` input like the `Equal` function. [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([Jian Wu](https://github.com/janplus)) -- Check the time limit every (flush\_interval / poll\_timeout) number of rows from Kafka. This allows to break the reading from Kafka consumer more frequently and to check the time limits for the top-level streams [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([Ivan](https://github.com/abyss7)) -- Link rdkafka with bundled SASL. It should allow to use SASL SCRAM authentication [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([Ivan](https://github.com/abyss7)) -- Batched version of RowRefList for ALL JOINS. [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([Artem Zuikov](https://github.com/4ertus2)) -- clickhouse-server: more informative listen error messages. [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([proller](https://github.com/proller)) -- Support dictionaries in clickhouse-copier for functions in `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([proller](https://github.com/proller)) -- Add new setting `kafka_commit_every_batch` to regulate Kafka committing policy. - It allows to set commit mode: after every batch of messages is handled, or after the whole block is written to the storage. It’s a trade-off between losing some messages or reading them twice in some extreme situations. [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([Ivan](https://github.com/abyss7)) -- Make `windowFunnel` support other Unsigned Integer Types. [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([sundyli](https://github.com/sundy-li)) -- Allow to shadow virtual column `_table` in Merge engine. [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([Ivan](https://github.com/abyss7)) -- Make `sequenceMatch` aggregate functions support other unsigned Integer types [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([sundyli](https://github.com/sundy-li)) -- Better error messages if checksum mismatch is most likely caused by hardware failures. [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Check that underlying tables support sampling for `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([Ivan](https://github.com/abyss7)) -- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- Improvements of MySQL Wire Protocol. Changed name of format to MySQLWire. Using RAII for calling RSA\_free. Disabling SSL if context cannot be created. [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([Yuriy Baranov](https://github.com/yurriy)) -- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([proller](https://github.com/proller)) -- Respect query settings in asynchronous INSERTs into Distributed tables. [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([TCeason](https://github.com/TCeason)) -- Renamed functions `leastSqr` to `simpleLinearRegression`, `LinearRegression` to `linearRegression`, `LogisticRegression` to `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### Performance Improvements {#performance-improvements} - -- Parallelize processing of parts of non-replicated MergeTree tables in ALTER MODIFY query. [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([Ivan Kush](https://github.com/IvanKush)) -- Optimizations in regular expressions extraction. [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([Danila Kutenin](https://github.com/danlark1)) -- Do not add right join key column to join result if it’s used only in join on section. [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([Artem Zuikov](https://github.com/4ertus2)) -- Freeze the Kafka buffer after first empty response. It avoids multiple invokations of `ReadBuffer::next()` for empty result in some row-parsing streams. [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([Ivan](https://github.com/abyss7)) -- `concat` function optimization for multiple arguments. [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([Danila Kutenin](https://github.com/danlark1)) -- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([Artem Zuikov](https://github.com/4ertus2)) -- Upgrade our LZ4 implementation with reference one to have faster decompression. [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([Danila Kutenin](https://github.com/danlark1)) -- Implemented MSD radix sort (based on kxsort), and partial sorting. [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([Evgenii Pravda](https://github.com/kvinty)) - -#### Bug Fixes {#bug-fixes} - -- Fix push require columns with join [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([Winter Zhang](https://github.com/zhang2014)) -- Fixed bug, when ClickHouse is run by systemd, the command `sudo service clickhouse-server forcerestart` was not working as expected. [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([proller](https://github.com/proller)) -- Fix http error codes in DataPartsExchange (interserver http server on 9009 port always returned code 200, even on errors). [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([proller](https://github.com/proller)) -- Fix SimpleAggregateFunction for String longer than MAX\_SMALL\_STRING\_SIZE [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([Azat Khuzhin](https://github.com/azat)) -- Fix error for `Decimal` to `Nullable(Decimal)` conversion in IN. Support other Decimal to Decimal conversions (including different scales). [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed FPU clobbering in simdjson library that lead to wrong calculation of `uniqHLL` and `uniqCombined` aggregate function and math functions such as `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed handling mixed const/nonconst cases in JSON functions. [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix `retention` function. Now all conditions that satisfy in a row of data are added to the data state. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) -- Fix result type for `quantileExact` with Decimals. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Documentation {#documentation} - -- Translate documentation for `CollapsingMergeTree` to chinese. [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) -- Translate some documentation about table engines to chinese. - [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) - [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) - ([never lee](https://github.com/neverlee)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements} - -- Fix some sanitizer reports that show probable use-after-free.[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([Ivan](https://github.com/abyss7)) -- Move performance tests out of separate directories for convenience. [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix incorrect performance tests. [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([alesapin](https://github.com/alesapin)) -- Added a tool to calculate checksums caused by bit flips to debug hardware issues. [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Make runner script more usable. [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([filimonov](https://github.com/filimonov)) -- Add small instruction how to write performance tests. [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([alesapin](https://github.com/alesapin)) -- Add ability to make substitutions in create, fill and drop query in performance tests [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([Olga Khvostikova](https://github.com/stavrolia)) - -## ClickHouse release 19.7 {#clickhouse-release-19-7} - -### ClickHouse release 19.7.5.29, 2019-07-05 {#clickhouse-release-19-7-5-29-2019-07-05} - -#### Bug Fix {#bug-fix-25} - -- Fix performance regression in some queries with JOIN. [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([Winter Zhang](https://github.com/zhang2014)) - -### ClickHouse release 19.7.5.27, 2019-06-09 {#clickhouse-release-19-7-5-27-2019-06-09} - -#### New features {#new-features-1} - -- Added bitmap related functions `bitmapHasAny` and `bitmapHasAll` analogous to `hasAny` and `hasAll` functions for arrays. [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([Sergi Vladykin](https://github.com/svladykin)) - -#### Bug Fixes {#bug-fixes-1} - -- Fix segfault on `minmax` INDEX with Null value. [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([Nikita Vasilev](https://github.com/nikvas0)) -- Mark all input columns in LIMIT BY as required output. It fixes ‘Not found column’ error in some distributed queries. [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([Constantin S. Pan](https://github.com/kvap)) -- Fix “Column ‘0’ already exists” error in `SELECT .. PREWHERE` on column with DEFAULT [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([proller](https://github.com/proller)) -- Fix `ALTER MODIFY TTL` query on `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([Anton Popov](https://github.com/CurtizJ)) -- Don’t crash the server when Kafka consumers have failed to start. [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([Ivan](https://github.com/abyss7)) -- Fixed bitmap functions produce wrong result. [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([Andy Yang](https://github.com/andyyzh)) -- Fix element\_count for hashed dictionary (do not include duplicates) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) -- Use contents of environment variable TZ as the name for timezone. It helps to correctly detect default timezone in some cases.[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([Ivan](https://github.com/abyss7)) -- Do not try to convert integers in `dictGetT` functions, because it doesn’t work correctly. Throw an exception instead. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix settings in ExternalData HTTP request. [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila - Kutenin](https://github.com/danlark1)) -- Fix bug when parts were removed only from FS without dropping them from Zookeeper. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([alesapin](https://github.com/alesapin)) -- Fix segmentation fault in `bitmapHasAny` function. [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) -- Fixed error when replication connection pool doesn’t retry to resolve host, even when DNS cache was dropped. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([alesapin](https://github.com/alesapin)) -- Fixed `DROP INDEX IF EXISTS` query. Now `ALTER TABLE ... DROP INDEX IF EXISTS ...` query doesn’t raise an exception if provided index does not exist. [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([Gleb Novikov](https://github.com/NanoBjorn)) -- Fix union all supertype column. There were cases with inconsistent data and column types of resulting columns. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) -- Skip ZNONODE during DDL query processing. Before if another node removes the znode in task queue, the one that - did not process it, but already get list of children, will terminate the DDLWorker thread. [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) -- Fix INSERT into Distributed() table with MATERIALIZED column. [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) - -### ClickHouse release 19.7.3.9, 2019-05-30 {#clickhouse-release-19-7-3-9-2019-05-30} - -#### New Features {#new-features-2} - -- Allow to limit the range of a setting that can be specified by user. - These constraints can be set up in user settings profile. - [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([Vitaly - Baranov](https://github.com/vitlibar)) -- Add a second version of the function `groupUniqArray` with an optional - `max_size` parameter that limits the size of the resulting array. This - behavior is similar to `groupArray(max_size)(x)` function. - [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([Guillaume - Tassery](https://github.com/YiuRULE)) -- For TSVWithNames/CSVWithNames input file formats, column order can now be - determined from file header. This is controlled by - `input_format_with_names_use_header` parameter. - [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) - ([Alexander](https://github.com/Akazz)) - -#### Bug Fixes {#bug-fixes-2} - -- Crash with uncompressed\_cache + JOIN during merge (\#5197) - [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([Danila - Kutenin](https://github.com/danlark1)) -- Segmentation fault on a clickhouse-client query to system tables. \#5066 - [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) - ([Ivan](https://github.com/abyss7)) -- Data loss on heavy load via KafkaEngine (\#4736) - [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) - ([Ivan](https://github.com/abyss7)) -- Fixed very rare data race condition that could happen when executing a query with UNION ALL involving at least two SELECTs from system.columns, system.tables, system.parts, system.parts\_tables or tables of Merge family and performing ALTER of columns of the related tables concurrently. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Performance Improvements {#performance-improvements-1} - -- Use radix sort for sorting by single numeric column in `ORDER BY` without - `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), - [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) - ([Evgenii Pravda](https://github.com/kvinty), - [alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Documentation {#documentation-1} - -- Translate documentation for some table engines to Chinese. - [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), - [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), - [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) - ([张风啸](https://github.com/AlexZFX)), - [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([never - lee](https://github.com/neverlee)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-1} - -- Print UTF-8 characters properly in `clickhouse-test`. - [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add command line parameter for clickhouse-client to always load suggestion - data. [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Resolve some of PVS-Studio warnings. - [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Update LZ4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([Danila - Kutenin](https://github.com/danlark1)) -- Add gperf to build requirements for upcoming pull request \#5030. - [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) - ([proller](https://github.com/proller)) - -## ClickHouse release 19.6 {#clickhouse-release-19-6} - -### ClickHouse release 19.6.3.18, 2019-06-13 {#clickhouse-release-19-6-3-18-2019-06-13} - -#### Bug Fixes {#bug-fixes-3} - -- Fixed IN condition pushdown for queries from table functions `mysql` and `odbc` and corresponding table engines. This fixes \#3540 and \#2384. [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix deadlock in Zookeeper. [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([github1youlc](https://github.com/github1youlc)) -- Allow quoted decimals in CSV. [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([Artem Zuikov](https://github.com/4ertus2) -- Disallow conversion from float Inf/NaN into Decimals (throw exception). [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix data race in rename query. [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([Winter Zhang](https://github.com/zhang2014)) -- Temporarily disable LFAlloc. Usage of LFAlloc might lead to a lot of MAP\_FAILED in allocating UncompressedCache and in a result to crashes of queries at high loaded servers. [cfdba93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([Danila Kutenin](https://github.com/danlark1)) - -### ClickHouse release 19.6.2.11, 2019-05-13 {#clickhouse-release-19-6-2-11-2019-05-13} - -#### New Features {#new-features-3} - -- TTL expressions for columns and tables. [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([Anton Popov](https://github.com/CurtizJ)) -- Added support for `brotli` compression for HTTP responses (Accept-Encoding: br) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([Mikhail](https://github.com/fandyushin)) -- Added new function `isValidUTF8` for checking whether a set of bytes is correctly utf-8 encoded. [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([Danila Kutenin](https://github.com/danlark1)) -- Add new load balancing policy `first_or_random` which sends queries to the first specified host and if it’s inaccessible send queries to random hosts of shard. Useful for cross-replication topology setups. [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([nvartolomei](https://github.com/nvartolomei)) - -#### Experimental Features {#experimental-features-1} - -- Add setting `index_granularity_bytes` (adaptive index granularity) for MergeTree\* tables family. [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([alesapin](https://github.com/alesapin)) - -#### Improvements {#improvements-1} - -- Added support for non-constant and negative size and length arguments for function `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Disable push-down to right table in left join, left table in right join, and both tables in full join. This fixes wrong JOIN results in some cases. [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([Ivan](https://github.com/abyss7)) -- `clickhouse-copier`: auto upload task configuration from `--task-file` option [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([proller](https://github.com/proller)) -- Added typos handler for storage factory and table functions factory. [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([Danila Kutenin](https://github.com/danlark1)) -- Support asterisks and qualified asterisks for multiple joins without subqueries [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([Artem Zuikov](https://github.com/4ertus2)) -- Make missing column error message more user friendly. [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Performance Improvements {#performance-improvements-2} - -- Significant speedup of ASOF JOIN [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([Martijn Bakker](https://github.com/Gladdy)) - -#### Backward Incompatible Changes {#backward-incompatible-changes} - -- HTTP header `Query-Id` was renamed to `X-ClickHouse-Query-Id` for consistency. [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([Mikhail](https://github.com/fandyushin)) - -#### Bug Fixes {#bug-fixes-4} - -- Fixed potential null pointer dereference in `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([proller](https://github.com/proller)) -- Fixed error on query with JOIN + ARRAY JOIN [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed hanging on start of the server when a dictionary depends on another dictionary via a database with engine=Dictionary. [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([Vitaly Baranov](https://github.com/vitlibar)) -- Partially fix distributed\_product\_mode = local. It’s possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There’s not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix potentially wrong result for `SELECT DISTINCT` with `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed very rare data race condition that could happen when executing a query with UNION ALL involving at least two SELECTs from system.columns, system.tables, system.parts, system.parts\_tables or tables of Merge family and performing ALTER of columns of the related tables concurrently. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-2} - -- Fixed test failures when running clickhouse-server on different host [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([Vasily Nemkov](https://github.com/Enmk)) -- clickhouse-test: Disable color control sequences in non tty environment. [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([alesapin](https://github.com/alesapin)) -- clickhouse-test: Allow use any test database (remove `test.` qualification where it possible) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([proller](https://github.com/proller)) -- Fix ubsan errors [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([Vitaly Baranov](https://github.com/vitlibar)) -- Yandex LFAlloc was added to ClickHouse to allocate MarkCache and UncompressedCache data in different ways to catch segfaults more reliable [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([Danila Kutenin](https://github.com/danlark1)) -- Python util to help with backports and changelogs. [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([Ivan](https://github.com/abyss7)) - -## ClickHouse release 19.5 {#clickhouse-release-19-5} - -### ClickHouse release 19.5.4.22, 2019-05-13 {#clickhouse-release-19-5-4-22-2019-05-13} - -#### Bug fixes {#bug-fixes-5} - -- Fixed possible crash in bitmap\* functions [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([Andy Yang](https://github.com/andyyzh)) -- Fixed very rare data race condition that could happen when executing a query with UNION ALL involving at least two SELECTs from system.columns, system.tables, system.parts, system.parts\_tables or tables of Merge family and performing ALTER of columns of the related tables concurrently. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed error `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. This error happened if LowCardinality column was the part of primary key. \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Modification of retention function: If a row satisfies both the first and NTH condition, only the first satisfied condition is added to the data state. Now all conditions that satisfy in a row of data are added to the data state. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) - -### ClickHouse release 19.5.3.8, 2019-04-18 {#clickhouse-release-19-5-3-8-2019-04-18} - -#### Bug fixes {#bug-fixes-6} - -- Fixed type of setting `max_partitions_per_insert_block` from boolean to UInt64. [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([Mohammad Hossein Sekhavat](https://github.com/mhsekhavat)) - -### ClickHouse release 19.5.2.6, 2019-04-15 {#clickhouse-release-19-5-2-6-2019-04-15} - -#### New Features {#new-features-4} - -- [Hyperscan](https://github.com/intel/hyperscan) multiple regular expression matching was added (functions `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([Danila Kutenin](https://github.com/danlark1)) -- `multiSearchFirstPosition` function was added. [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) -- Implement the predefined expression filter per row for tables. [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([Ivan](https://github.com/abyss7)) -- A new type of data skipping indices based on bloom filters (can be used for `equal`, `in` and `like` functions). [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([Nikita Vasilev](https://github.com/nikvas0)) -- Added `ASOF JOIN` which allows to run queries that join to the most recent value known. [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([Martijn Bakker](https://github.com/Gladdy), [Artem Zuikov](https://github.com/4ertus2)) -- Rewrite multiple `COMMA JOIN` to `CROSS JOIN`. Then rewrite them to `INNER JOIN` if possible. [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Improvement {#improvement-9} - -- `topK` and `topKWeighted` now supports custom `loadFactor` (fixes issue [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([Kirill Danshin](https://github.com/kirillDanshin)) -- Allow to use `parallel_replicas_count > 1` even for tables without sampling (the setting is simply ignored for them). In previous versions it was lead to exception. [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([Alexey Elymanov](https://github.com/digitalist)) -- Support for `CREATE OR REPLACE VIEW`. Allow to create a view or set a new definition in a single statement. [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([Boris Granveaud](https://github.com/bgranvea)) -- `Buffer` table engine now supports `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([Yangkuan Liu](https://github.com/LiuYangkuan)) -- Add ability to start replicated table without metadata in zookeeper in `readonly` mode. [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([alesapin](https://github.com/alesapin)) -- Fixed flicker of progress bar in clickhouse-client. The issue was most noticeable when using `FORMAT Null` with streaming queries. [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Allow to disable functions with `hyperscan` library on per user basis to limit potentially excessive and uncontrolled resource usage. [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add version number logging in all errors. [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([proller](https://github.com/proller)) -- Added restriction to the `multiMatch` functions which requires string size to fit into `unsigned int`. Also added the number of arguments limit to the `multiSearch` functions. [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([Danila Kutenin](https://github.com/danlark1)) -- Improved usage of scratch space and error handling in Hyperscan. [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([Danila Kutenin](https://github.com/danlark1)) -- Fill `system.graphite_detentions` from a table config of `*GraphiteMergeTree` engine tables. [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- Rename `trigramDistance` function to `ngramDistance` and add more functions with `CaseInsensitive` and `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([Danila Kutenin](https://github.com/danlark1)) -- Improved data skipping indices calculation. [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([Nikita Vasilev](https://github.com/nikvas0)) -- Keep ordinary, `DEFAULT`, `MATERIALIZED` and `ALIAS` columns in a single list (fixes issue [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) - -#### Bug Fix {#bug-fix-26} - -- Avoid `std::terminate` in case of memory allocation failure. Now `std::bad_alloc` exception is thrown as expected. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixes capnproto reading from buffer. Sometimes files wasn’t loaded successfully by HTTP. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([Vladislav](https://github.com/smirnov-vs)) -- Fix error `Unknown log entry type: 0` after `OPTIMIZE TABLE FINAL` query. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([Amos Bird](https://github.com/amosbird)) -- Wrong arguments to `hasAny` or `hasAll` functions may lead to segfault. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Deadlock may happen while executing `DROP DATABASE dictionary` query. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix undefined behavior in `median` and `quantile` functions. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) -- Fix compression level detection when `network_compression_method` in lowercase. Broken in v19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) -- Fixed ignorance of `UTC` setting (fixes issue [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) -- Fix `histogram` function behaviour with `Distributed` tables. [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) -- Fixed tsan report `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed TSan report on shutdown due to race condition in system logs usage. Fixed potential use-after-free on shutdown when part\_log is enabled. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix recheck parts in `ReplicatedMergeTreeAlterThread` in case of error. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Arithmetic operations on intermediate aggregate function states were not working for constant arguments (such as subquery results). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Always backquote column names in metadata. Otherwise it’s impossible to create a table with column named `index` (server won’t restart due to malformed `ATTACH` query in metadata). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix crash in `ALTER ... MODIFY ORDER BY` on `Distributed` table. [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) -- Fix segfault in `JOIN ON` with enabled `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([Winter Zhang](https://github.com/zhang2014)) -- Fix bug with adding an extraneous row after consuming a protobuf message from Kafka. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix crash of `JOIN` on not-nullable vs nullable column. Fix `NULLs` in right keys in `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- Fixed race condition in `SELECT` from `system.tables` if the table is renamed or altered concurrently. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed data race when fetching data part that is already obsolete. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed rare data race that can happen during `RENAME` table of MergeTree family. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed segmentation fault in function `arrayIntersect`. Segmentation fault could happen if function was called with mixed constant and ordinary arguments. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang Qian](https://github.com/fancyqlx)) -- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix crash in `FULL/RIGHT JOIN` when we joining on nullable vs not nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix `No message received` exception while fetching parts between replicas. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([alesapin](https://github.com/alesapin)) -- Fixed `arrayIntersect` function wrong result in case of several repeated values in single array. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix a race condition during concurrent `ALTER COLUMN` queries that could lead to a server crash (fixes issue [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fix incorrect result in `FULL/RIGHT JOIN` with const column. [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix duplicates in `GLOBAL JOIN` with asterisk. [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix parameter deduction in `ALTER MODIFY` of column `CODEC` when column type is not specified. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([alesapin](https://github.com/alesapin)) -- Functions `cutQueryStringAndFragment()` and `queryStringAndFragment()` now works correctly when `URL` contains a fragment and no query. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix rare bug when setting `min_bytes_to_use_direct_io` is greater than zero, which occures when thread have to seek backward in column file. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([alesapin](https://github.com/alesapin)) -- Fix wrong argument types for aggregate functions with `LowCardinality` arguments (fixes issue [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix wrong name qualification in `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix function `toISOWeek` result for year 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix `DROP`, `TRUNCATE` and `OPTIMIZE` queries duplication, when executed on `ON CLUSTER` for `ReplicatedMergeTree*` tables family. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([alesapin](https://github.com/alesapin)) - -#### Backward Incompatible Change {#backward-incompatible-change-8} - -- Rename setting `insert_sample_with_metadata` to setting `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([Artem Zuikov](https://github.com/4ertus2)) -- Added setting `max_partitions_per_insert_block` (with value 100 by default). If inserted block contains larger number of partitions, an exception is thrown. Set it to 0 if you want to remove the limit (not recommended). [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Multi-search functions were renamed (`multiPosition` to `multiSearchAllPositions`, `multiSearch` to `multiSearchAny`, `firstMatch` to `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) - -#### Performance Improvement {#performance-improvement-6} - -- Optimize Volnitsky searcher by inlining, giving about 5-10% search improvement for queries with many needles or many similar bigrams. [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([Danila Kutenin](https://github.com/danlark1)) -- Fix performance issue when setting `use_uncompressed_cache` is greater than zero, which appeared when all read data contained in cache. [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([alesapin](https://github.com/alesapin)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-10} - -- Hardening debug build: more granular memory mappings and ASLR; add memory protection for mark cache and index. This allows to find more memory stomping bugs in case when ASan and MSan cannot do it. [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add support for cmake variables `ENABLE_PROTOBUF`, `ENABLE_PARQUET` and `ENABLE_BROTLI` which allows to enable/disable the above features (same as we can do for librdkafka, mysql, etc). [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([Silviu Caragea](https://github.com/silviucpp)) -- Add ability to print process list and stacktraces of all threads if some queries are hung after test run. [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([alesapin](https://github.com/alesapin)) -- Add retries on `Connection loss` error in `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([alesapin](https://github.com/alesapin)) -- Add freebsd build with vagrant and build with thread sanitizer to packager script. [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([alesapin](https://github.com/alesapin)) -- Now user asked for password for user `'default'` during installation. [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([proller](https://github.com/proller)) -- Suppress warning in `rdkafka` library. [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Allow ability to build without ssl. [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([proller](https://github.com/proller)) -- Add a way to launch clickhouse-server image from a custom user. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- Upgrade contrib boost to 1.69. [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([proller](https://github.com/proller)) -- Disable usage of `mremap` when compiled with Thread Sanitizer. Surprisingly enough, TSan does not intercept `mremap` (though it does intercept `mmap`, `munmap`) that leads to false positives. Fixed TSan report in stateful tests. [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add test checking using format schema via HTTP interface. [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([Vitaly Baranov](https://github.com/vitlibar)) - -## ClickHouse release 19.4 {#clickhouse-release-19-4} - -### ClickHouse release 19.4.4.33, 2019-04-17 {#clickhouse-release-19-4-4-33-2019-04-17} - -#### Bug Fixes {#bug-fixes-7} - -- Avoid `std::terminate` in case of memory allocation failure. Now `std::bad_alloc` exception is thrown as expected. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixes capnproto reading from buffer. Sometimes files wasn’t loaded successfully by HTTP. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([Vladislav](https://github.com/smirnov-vs)) -- Fix error `Unknown log entry type: 0` after `OPTIMIZE TABLE FINAL` query. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([Amos Bird](https://github.com/amosbird)) -- Wrong arguments to `hasAny` or `hasAll` functions may lead to segfault. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Deadlock may happen while executing `DROP DATABASE dictionary` query. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix undefined behavior in `median` and `quantile` functions. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) -- Fix compression level detection when `network_compression_method` in lowercase. Broken in v19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) -- Fixed ignorance of `UTC` setting (fixes issue [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) -- Fix `histogram` function behaviour with `Distributed` tables. [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) -- Fixed tsan report `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed TSan report on shutdown due to race condition in system logs usage. Fixed potential use-after-free on shutdown when part\_log is enabled. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix recheck parts in `ReplicatedMergeTreeAlterThread` in case of error. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Arithmetic operations on intermediate aggregate function states were not working for constant arguments (such as subquery results). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Always backquote column names in metadata. Otherwise it’s impossible to create a table with column named `index` (server won’t restart due to malformed `ATTACH` query in metadata). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix crash in `ALTER ... MODIFY ORDER BY` on `Distributed` table. [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) -- Fix segfault in `JOIN ON` with enabled `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([Winter Zhang](https://github.com/zhang2014)) -- Fix bug with adding an extraneous row after consuming a protobuf message from Kafka. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- Fixed race condition in `SELECT` from `system.tables` if the table is renamed or altered concurrently. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed data race when fetching data part that is already obsolete. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed rare data race that can happen during `RENAME` table of MergeTree family. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed segmentation fault in function `arrayIntersect`. Segmentation fault could happen if function was called with mixed constant and ordinary arguments. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang Qian](https://github.com/fancyqlx)) -- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix `No message received` exception while fetching parts between replicas. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([alesapin](https://github.com/alesapin)) -- Fixed `arrayIntersect` function wrong result in case of several repeated values in single array. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix a race condition during concurrent `ALTER COLUMN` queries that could lead to a server crash (fixes issue [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fix parameter deduction in `ALTER MODIFY` of column `CODEC` when column type is not specified. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([alesapin](https://github.com/alesapin)) -- Functions `cutQueryStringAndFragment()` and `queryStringAndFragment()` now works correctly when `URL` contains a fragment and no query. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([Vitaly Baranov](https://github.com/vitlibar)) -- Fix rare bug when setting `min_bytes_to_use_direct_io` is greater than zero, which occures when thread have to seek backward in column file. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([alesapin](https://github.com/alesapin)) -- Fix wrong argument types for aggregate functions with `LowCardinality` arguments (fixes issue [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fix function `toISOWeek` result for year 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix `DROP`, `TRUNCATE` and `OPTIMIZE` queries duplication, when executed on `ON CLUSTER` for `ReplicatedMergeTree*` tables family. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([alesapin](https://github.com/alesapin)) - -#### Improvements {#improvements-2} - -- Keep ordinary, `DEFAULT`, `MATERIALIZED` and `ALIAS` columns in a single list (fixes issue [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) - -### ClickHouse release 19.4.3.11, 2019-04-02 {#clickhouse-release-19-4-3-11-2019-04-02} - -#### Bug Fixes {#bug-fixes-8} - -- Fix crash in `FULL/RIGHT JOIN` when we joining on nullable vs not nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-11} - -- Add a way to launch clickhouse-server image from a custom user. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### ClickHouse release 19.4.2.7, 2019-03-30 {#clickhouse-release-19-4-2-7-2019-03-30} - -#### Bug Fixes {#bug-fixes-9} - -- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -### ClickHouse release 19.4.1.3, 2019-03-19 {#clickhouse-release-19-4-1-3-2019-03-19} - -#### Bug Fixes {#bug-fixes-10} - -- Fixed remote queries which contain both `LIMIT BY` and `LIMIT`. Previously, if `LIMIT BY` and `LIMIT` were used for remote query, `LIMIT` could happen before `LIMIT BY`, which led to too filtered result. [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([Constantin S. Pan](https://github.com/kvap)) - -### ClickHouse release 19.4.0.49, 2019-03-09 {#clickhouse-release-19-4-0-49-2019-03-09} - -#### New Features {#new-features-5} - -- Added full support for `Protobuf` format (input and output, nested data structures). [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([Vitaly Baranov](https://github.com/vitlibar)) -- Added bitmap functions with Roaring Bitmaps. [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([Andy Yang](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([Vitaly Baranov](https://github.com/vitlibar)) -- Parquet format support. [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([proller](https://github.com/proller)) -- N-gram distance was added for fuzzy string comparison. It is similar to q-gram metrics in R language. [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([Danila Kutenin](https://github.com/danlark1)) -- Combine rules for graphite rollup from dedicated aggregation and retention patterns. [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- Added `max_execution_speed` and `max_execution_speed_bytes` to limit resource usage. Added `min_execution_speed_bytes` setting to complement the `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([Winter Zhang](https://github.com/zhang2014)) -- Implemented function `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([alexey-milovidov](https://github.com/alexey-milovidov), [kzon](https://github.com/kzon)) -- Added functions `arrayEnumerateDenseRanked` and `arrayEnumerateUniqRanked` (it’s like `arrayEnumerateUniq` but allows to fine tune array depth to look inside multidimensional arrays). [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([proller](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Bug Fixes {#bug-fixes-11} - -- This release also contains all bug fixes from 19.3 and 19.1. -- Fixed bug in data skipping indices: order of granules after INSERT was incorrect. [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([Nikita Vasilev](https://github.com/nikvas0)) -- Fixed `set` index for `Nullable` and `LowCardinality` columns. Before it, `set` index with `Nullable` or `LowCardinality` column led to error `Data type must be deserialized with multiple streams` while selecting. [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Correctly set update\_time on full `executable` dictionary update. [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([Tema Novikov](https://github.com/temoon)) -- Fix broken progress bar in 19.3. [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([filimonov](https://github.com/filimonov)) -- Fixed inconsistent values of MemoryTracker when memory region was shrinked, in certain cases. [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed undefined behaviour in ThreadPool. [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed a very rare crash with the message `mutex lock failed: Invalid argument` that could happen when a MergeTree table was dropped concurrently with a SELECT. [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([Alex Zatelepin](https://github.com/ztlpn)) -- ODBC driver compatibility with `LowCardinality` data type. [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([proller](https://github.com/proller)) -- FreeBSD: Fixup for `AIOcontextPool: Found io_event with unknown id 0` error. [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([urgordeadbeef](https://github.com/urgordeadbeef)) -- `system.part_log` table was created regardless to configuration. [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix undefined behaviour in `dictIsIn` function for cache dictionaries. [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([alesapin](https://github.com/alesapin)) -- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([Alex Zatelepin](https://github.com/ztlpn)) -- Disable compile\_expressions by default until we get own `llvm` contrib and can test it with `clang` and `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([alesapin](https://github.com/alesapin)) -- Prevent `std::terminate` when `invalidate_query` for `clickhouse` external dictionary source has returned wrong resultset (empty or more than one row or more than one column). Fixed issue when the `invalidate_query` was performed every five seconds regardless to the `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Avoid deadlock when the `invalidate_query` for a dictionary with `clickhouse` source was involving `system.dictionaries` table or `Dictionaries` database (rare case). [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixes for CROSS JOIN with empty WHERE. [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed segfault in function “replicate” when constant argument is passed. [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix lambda function with predicate optimizer. [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([Winter Zhang](https://github.com/zhang2014)) -- Multiple JOINs multiple fixes. [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Improvements {#improvements-3} - -- Support aliases in JOIN ON section for right table columns. [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([Artem Zuikov](https://github.com/4ertus2)) -- Result of multiple JOINs need correct result names to be used in subselects. Replace flat aliases with source names in result. [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([Artem Zuikov](https://github.com/4ertus2)) -- Improve push-down logic for joined statements. [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([Ivan](https://github.com/abyss7)) - -#### Performance Improvements {#performance-improvements-3} - -- Improved heuristics of “move to PREWHERE” optimization. [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Use proper lookup tables that uses HashTable’s API for 8-bit and 16-bit keys. [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([Amos Bird](https://github.com/amosbird)) -- Improved performance of string comparison. [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Cleanup distributed DDL queue in a separate thread so that it doesn’t slow down the main loop that processes distributed DDL tasks. [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([Alex Zatelepin](https://github.com/ztlpn)) -- When `min_bytes_to_use_direct_io` is set to 1, not every file was opened with O\_DIRECT mode because the data size to read was sometimes underestimated by the size of one compressed block. [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-12} - -- Added support for clang-9 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix wrong `__asm__` instructions (again) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([Konstantin Podshumok](https://github.com/podshumok)) -- Add ability to specify settings for `clickhouse-performance-test` from command line. [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([alesapin](https://github.com/alesapin)) -- Add dictionaries tests to integration tests. [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([alesapin](https://github.com/alesapin)) -- Added queries from the benchmark on the website to automated performance tests. [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `xxhash.h` does not exist in external lz4 because it is an implementation detail and its symbols are namespaced with `XXH_NAMESPACE` macro. When lz4 is external, xxHash has to be external too, and the dependents have to link to it. [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([Orivej Desh](https://github.com/orivej)) -- Fixed a case when `quantileTiming` aggregate function can be called with negative or floating point argument (this fixes fuzz test with undefined behaviour sanitizer). [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Spelling error correction. [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) -- Fix compilation on Mac. [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([Vitaly Baranov](https://github.com/vitlibar)) -- Build fixes for FreeBSD and various unusual build configurations. [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([proller](https://github.com/proller)) - -## ClickHouse release 19.3 {#clickhouse-release-19-3} - -### ClickHouse release 19.3.9.1, 2019-04-02 {#clickhouse-release-19-3-9-1-2019-04-02} - -#### Bug Fixes {#bug-fixes-12} - -- Fix crash in `FULL/RIGHT JOIN` when we joining on nullable vs not nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- Fix segmentation fault in `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- Fixed reading from `Array(LowCardinality)` column in rare case when column contained a long sequence of empty arrays. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-13} - -- Add a way to launch clickhouse-server image from a custom user [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### ClickHouse release 19.3.7, 2019-03-12 {#clickhouse-release-19-3-7-2019-03-12} - -#### Bug fixes {#bug-fixes-13} - -- Fixed error in \#3920. This error manifests itself as random cache corruption (messages `Unknown codec family code`, `Cannot seek through file`) and segfaults. This bug first appeared in version 19.1 and is present in versions up to 19.1.10 and 19.3.6. [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.3.6, 2019-03-02 {#clickhouse-release-19-3-6-2019-03-02} - -#### Bug fixes {#bug-fixes-14} - -- When there are more than 1000 threads in a thread pool, `std::terminate` may happen on thread exit. [Azat Khuzhin](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Now it’s possible to create `ReplicatedMergeTree*` tables with comments on columns without defaults and tables with columns codecs without comments and defaults. Also fix comparison of codecs. [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([alesapin](https://github.com/alesapin)) -- Fixed crash on JOIN with array or tuple. [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed crash in clickhouse-copier with the message `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed hangup on server shutdown if distributed DDLs were used. [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([Alex Zatelepin](https://github.com/ztlpn)) -- Incorrect column numbers were printed in error message about text format parsing for columns with number greater than 10. [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-3} - -- Fixed build with AVX enabled. [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Enable extended accounting and IO accounting based on good known version instead of kernel under which it is compiled. [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([nvartolomei](https://github.com/nvartolomei)) -- Allow to skip setting of core\_dump.size\_limit, warning instead of throw if limit set fail. [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([proller](https://github.com/proller)) -- Removed the `inline` tags of `void readBinary(...)` in `Field.cpp`. Also merged redundant `namespace DB` blocks. [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([hcz](https://github.com/hczhcz)) - -### ClickHouse release 19.3.5, 2019-02-21 {#clickhouse-release-19-3-5-2019-02-21} - -#### Bug fixes {#bug-fixes-15} - -- Fixed bug with large http insert queries processing. [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([alesapin](https://github.com/alesapin)) -- Fixed backward incompatibility with old versions due to wrong implementation of `send_logs_level` setting. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed backward incompatibility of table function `remote` introduced with column comments. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.3.4, 2019-02-16 {#clickhouse-release-19-3-4-2019-02-16} - -#### Improvements {#improvements-4} - -- Table index size is not accounted for memory limits when doing `ATTACH TABLE` query. Avoided the possibility that a table cannot be attached after being detached. [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Slightly raised up the limit on max string and array size received from ZooKeeper. It allows to continue to work with increased size of `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` on ZooKeeper. [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Allow to repair abandoned replica even if it already has huge number of nodes in its queue. [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Add one required argument to `SET` index (max stored rows number). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([Nikita Vasilev](https://github.com/nikvas0)) - -#### Bug Fixes {#bug-fixes-16} - -- Fixed `WITH ROLLUP` result for group by single `LowCardinality` key. [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Fixed bug in the set index (dropping a granule if it contains more than `max_rows` rows). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([Nikita Vasilev](https://github.com/nikvas0)) -- A lot of FreeBSD build fixes. [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([proller](https://github.com/proller)) -- Fixed aliases substitution in queries with subquery containing same alias (issue [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-4} - -- Add ability to run `clickhouse-server` for stateless tests in docker image. [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([Vasily Nemkov](https://github.com/Enmk)) - -### ClickHouse release 19.3.3, 2019-02-13 {#clickhouse-release-19-3-3-2019-02-13} - -#### New Features {#new-features-6} - -- Added the `KILL MUTATION` statement that allows removing mutations that are for some reasons stuck. Added `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` fields to the `system.mutations` table for easier troubleshooting. [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([Alex Zatelepin](https://github.com/ztlpn)) -- Added aggregate function `entropy` which computes Shannon entropy. [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) -- Added ability to send queries `INSERT INTO tbl VALUES (....` to server without splitting on `query` and `data` parts. [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([alesapin](https://github.com/alesapin)) -- Generic implementation of `arrayWithConstant` function was added. [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Implemented `NOT BETWEEN` comparison operator. [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([Dmitry Naumov](https://github.com/nezed)) -- Implement `sumMapFiltered` in order to be able to limit the number of keys for which values will be summed by `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- Added support of `Nullable` types in `mysql` table function. [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) -- Support for arbitrary constant expressions in `LIMIT` clause. [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) -- Added `topKWeighted` aggregate function that takes additional argument with (unsigned integer) weight. [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([Andrew Golman](https://github.com/andrewgolman)) -- `StorageJoin` now supports `join_any_take_last_row` setting that allows overwriting existing values of the same key. [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([Amos Bird](https://github.com/amosbird) -- Added function `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([Vitaly Baranov](https://github.com/vitlibar)) -- Added `RowBinaryWithNamesAndTypes` format. [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([Oleg V. Kozlyuk](https://github.com/DarkWanderer)) -- Added `IPv4` and `IPv6` data types. More effective implementations of `IPv*` functions. [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([Vasily Nemkov](https://github.com/Enmk)) -- Added function `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([Vitaly Baranov](https://github.com/vitlibar)) -- Added `Protobuf` output format. [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([Vitaly Baranov](https://github.com/vitlibar)) -- Added brotli support for HTTP interface for data import (INSERTs). [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([Mikhail](https://github.com/fandyushin)) -- Added hints while user make typo in function name or type in command line client. [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([Danila Kutenin](https://github.com/danlark1)) -- Added `Query-Id` to Server’s HTTP Response header. [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([Mikhail](https://github.com/fandyushin)) - -#### Experimental features {#experimental-features-2} - -- Added `minmax` and `set` data skipping indices for MergeTree table engines family. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) -- Added conversion of `CROSS JOIN` to `INNER JOIN` if possible. [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Bug Fixes {#bug-fixes-17} - -- Fixed `Not found column` for duplicate columns in `JOIN ON` section. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) -- Make `START REPLICATED SENDS` command start replicated sends. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) -- Fixed aggregate functions execution with `Array(LowCardinality)` arguments. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Fixed wrong behaviour when doing `INSERT ... SELECT ... FROM file(...)` query and file has `CSVWithNames` or `TSVWIthNames` format and the first data row is missing. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed crash on dictionary reload if dictionary not available. This bug was appeared in 19.1.6. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) -- Fixed `ALL JOIN` with duplicates in right table. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed segmentation fault with `use_uncompressed_cache=1` and exception with wrong uncompressed size. This bug was appeared in 19.1.6. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([alesapin](https://github.com/alesapin)) -- Fixed `compile_expressions` bug with comparison of big (more than int16) dates. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([alesapin](https://github.com/alesapin)) -- Fixed infinite loop when selecting from table function `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Temporarily disable predicate optimization for `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([Winter Zhang](https://github.com/zhang2014)) -- Fixed `Illegal instruction` error when using base64 functions on old CPUs. This error has been reproduced only when ClickHouse was compiled with gcc-8. [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed `No message received` error when interacting with PostgreSQL ODBC Driver through TLS connection. Also fixes segfault when using MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed incorrect result when `Date` and `DateTime` arguments are used in branches of conditional operator (function `if`). Added generic case for function `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ClickHouse dictionaries now load within `clickhouse` process. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed deadlock when `SELECT` from a table with `File` engine was retried after `No such file or directory` error. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed race condition when selecting from `system.tables` may give `table doesn't exist` error. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `clickhouse-client` can segfault on exit while loading data for command line suggestions if it was run in interactive mode. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed a bug when the execution of mutations containing `IN` operators was producing incorrect results. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fixed error: if there is a database with `Dictionary` engine, all dictionaries forced to load at server startup, and if there is a dictionary with ClickHouse source from localhost, the dictionary cannot load. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed error when system logs are tried to create again at server shutdown. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Correctly return the right type and properly handle locks in `joinGet` function. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([Amos Bird](https://github.com/amosbird)) -- Added `sumMapWithOverflow` function. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- Fixed segfault with `allow_experimental_multiple_joins_emulation`. [52de2c](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed bug with incorrect `Date` and `DateTime` comparison. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) -- Fixed fuzz test under undefined behavior sanitizer: added parameter type check for `quantile*Weighted` family of functions. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed rare race condition when removing of old data parts can fail with `File not found` error. [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix install package with missing /etc/clickhouse-server/config.xml. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-5} - -- Debian package: correct /etc/clickhouse-server/preprocessed link according to config. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) -- Various build fixes for FreeBSD. [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([proller](https://github.com/proller)) -- Added ability to create, fill and drop tables in perftest. [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([alesapin](https://github.com/alesapin)) -- Added a script to check for duplicate includes. [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added ability to run queries by index in performance test. [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([alesapin](https://github.com/alesapin)) -- Package with debug symbols is suggested to be installed. [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Refactoring of performance-test. Better logging and signals handling. [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([alesapin](https://github.com/alesapin)) -- Added docs to anonymized Yandex.Metrika datasets. [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([alesapin](https://github.com/alesapin)) -- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([Alex Zatelepin](https://github.com/ztlpn)) -- Added docs about two datasets in s3. [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([alesapin](https://github.com/alesapin)) -- Added script which creates changelog from pull requests description. [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([KochetovNicolai](https://github.com/KochetovNicolai)) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Added puppet module for ClickHouse. [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([Maxim Fedotov](https://github.com/MaxFedotov)) -- Added docs for a group of undocumented functions. [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([Winter Zhang](https://github.com/zhang2014)) -- ARM build fixes. [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([proller](https://github.com/proller)) ([proller](https://github.com/proller)) -- Dictionary tests now able to run from `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([proller](https://github.com/proller)) -- Now `/etc/ssl` is used as default directory with SSL certificates. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added checking SSE and AVX instruction at start. [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([Igr](https://github.com/igron99)) -- Init script will wait server until start. [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([proller](https://github.com/proller)) - -#### Backward Incompatible Changes {#backward-incompatible-changes-1} - -- Removed `allow_experimental_low_cardinality_type` setting. `LowCardinality` data types are production ready. [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Reduce mark cache size and uncompressed cache size accordingly to available memory amount. [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([Lopatin Konstantin](https://github.com/k-lopatin) -- Added keyword `INDEX` in `CREATE TABLE` query. A column with name `index` must be quoted with backticks or double quotes: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) -- `sumMap` now promote result type instead of overflow. The old `sumMap` behavior can be obtained by using `sumMapWithOverflow` function. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) - -#### Performance Improvements {#performance-improvements-4} - -- `std::sort` replaced by `pdqsort` for queries without `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([Evgenii Pravda](https://github.com/kvinty)) -- Now server reuse threads from global thread pool. This affects performance in some corner cases. [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Improvements {#improvements-5} - -- Implemented AIO support for FreeBSD. [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([urgordeadbeef](https://github.com/urgordeadbeef)) -- `SELECT * FROM a JOIN b USING a, b` now return `a` and `b` columns only from the left table. [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([Artem Zuikov](https://github.com/4ertus2)) -- Allow `-C` option of client to work as `-c` option. [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([syominsergey](https://github.com/syominsergey)) -- Now option `--password` used without value requires password from stdin. [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([BSD\_Conqueror](https://github.com/bsd-conqueror)) -- Added highlighting of unescaped metacharacters in string literals that contain `LIKE` expressions or regexps. [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added cancelling of HTTP read only queries if client socket goes away. [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([nvartolomei](https://github.com/nvartolomei)) -- Now server reports progress to keep client connections alive. [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([Ivan](https://github.com/abyss7)) -- Slightly better message with reason for OPTIMIZE query with `optimize_throw_if_noop` setting enabled. [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added support of `--version` option for clickhouse server. [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([Lopatin Konstantin](https://github.com/k-lopatin)) -- Added `--help/-h` option to `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([Yuriy Baranov](https://github.com/yurriy)) -- Added support for scalar subqueries with aggregate function state result. [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Improved server shutdown time and ALTERs waiting time. [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added info about the replicated\_can\_become\_leader setting to system.replicas and add logging if the replica won’t try to become leader. [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([Alex Zatelepin](https://github.com/ztlpn)) - -## ClickHouse release 19.1 {#clickhouse-release-19-1} - -### ClickHouse release 19.1.14, 2019-03-14 {#clickhouse-release-19-1-14-2019-03-14} - -- Fixed error `Column ... queried more than once` that may happen if the setting `asterisk_left_columns_only` is set to 1 in case of using `GLOBAL JOIN` with `SELECT *` (rare case). The issue does not exist in 19.3 and newer. [6bac7d8d](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([Artem Zuikov](https://github.com/4ertus2)) - -### ClickHouse release 19.1.13, 2019-03-12 {#clickhouse-release-19-1-13-2019-03-12} - -This release contains exactly the same set of patches as 19.3.7. - -### ClickHouse release 19.1.10, 2019-03-03 {#clickhouse-release-19-1-10-2019-03-03} - -This release contains exactly the same set of patches as 19.3.6. - -## ClickHouse release 19.1 {#clickhouse-release-19-1-1} - -### ClickHouse release 19.1.9, 2019-02-21 {#clickhouse-release-19-1-9-2019-02-21} - -#### Bug fixes {#bug-fixes-18} - -- Fixed backward incompatibility with old versions due to wrong implementation of `send_logs_level` setting. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed backward incompatibility of table function `remote` introduced with column comments. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.1.8, 2019-02-16 {#clickhouse-release-19-1-8-2019-02-16} - -#### Bug Fixes {#bug-fixes-19} - -- Fix install package with missing /etc/clickhouse-server/config.xml. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) - -## ClickHouse release 19.1 {#clickhouse-release-19-1-2} - -### ClickHouse release 19.1.7, 2019-02-15 {#clickhouse-release-19-1-7-2019-02-15} - -#### Bug Fixes {#bug-fixes-20} - -- Correctly return the right type and properly handle locks in `joinGet` function. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([Amos Bird](https://github.com/amosbird)) -- Fixed error when system logs are tried to create again at server shutdown. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed error: if there is a database with `Dictionary` engine, all dictionaries forced to load at server startup, and if there is a dictionary with ClickHouse source from localhost, the dictionary cannot load. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed a bug when the execution of mutations containing `IN` operators was producing incorrect results. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) -- `clickhouse-client` can segfault on exit while loading data for command line suggestions if it was run in interactive mode. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed race condition when selecting from `system.tables` may give `table doesn't exist` error. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed deadlock when `SELECT` from a table with `File` engine was retried after `No such file or directory` error. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed an issue: local ClickHouse dictionaries are loaded via TCP, but should load within process. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed `No message received` error when interacting with PostgreSQL ODBC Driver through TLS connection. Also fixes segfault when using MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Temporarily disable predicate optimization for `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([Winter Zhang](https://github.com/zhang2014)) -- Fixed infinite loop when selecting from table function `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed `compile_expressions` bug with comparison of big (more than int16) dates. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([alesapin](https://github.com/alesapin)) -- Fixed segmentation fault with `uncompressed_cache=1` and exception with wrong uncompressed size. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([alesapin](https://github.com/alesapin)) -- Fixed `ALL JOIN` with duplicates in right table. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) -- Fixed wrong behaviour when doing `INSERT ... SELECT ... FROM file(...)` query and file has `CSVWithNames` or `TSVWIthNames` format and the first data row is missing. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed aggregate functions execution with `Array(LowCardinality)` arguments. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Debian package: correct /etc/clickhouse-server/preprocessed link according to config. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) -- Fixed fuzz test under undefined behavior sanitizer: added parameter type check for `quantile*Weighted` family of functions. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Make `START REPLICATED SENDS` command start replicated sends. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) -- Fixed `Not found column` for duplicate columns in JOIN ON section. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) -- Now `/etc/ssl` is used as default directory with SSL certificates. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed crash on dictionary reload if dictionary not available. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) -- Fixed bug with incorrect `Date` and `DateTime` comparison. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) -- Fixed incorrect result when `Date` and `DateTime` arguments are used in branches of conditional operator (function `if`). Added generic case for function `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouse release 19.1.6, 2019-01-24 {#clickhouse-release-19-1-6-2019-01-24} - -#### New Features {#new-features-7} - -- Custom per column compression codecs for tables. [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([alesapin](https://github.com/alesapin), [Winter Zhang](https://github.com/zhang2014), [Anatoly](https://github.com/Sindbag)) -- Added compression codec `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([alesapin](https://github.com/alesapin)) -- Allow to `ALTER` compression codecs. [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([alesapin](https://github.com/alesapin)) -- Added functions `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` for SQL standard compatibility. [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([Ivan Blinkov](https://github.com/blinkov)) -- Support for write in `HDFS` tables and `hdfs` table function. [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([alesapin](https://github.com/alesapin)) -- Added functions to search for multiple constant strings from big haystack: `multiPosition`, `multiSearch` ,`firstMatch` also with `-UTF8`, `-CaseInsensitive`, and `-CaseInsensitiveUTF8` variants. [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([Danila Kutenin](https://github.com/danlark1)) -- Pruning of unused shards if `SELECT` query filters by sharding key (setting `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([Gleb Kanterov](https://github.com/kanterov), [Ivan](https://github.com/abyss7)) -- Allow `Kafka` engine to ignore some number of parsing errors per block. [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([Ivan](https://github.com/abyss7)) -- Added support for `CatBoost` multiclass models evaluation. Function `modelEvaluate` returns tuple with per-class raw predictions for multiclass models. `libcatboostmodel.so` should be built with [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Added functions `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([Boris Granveaud](https://github.com/bgranvea)) -- Added hashing functions `xxHash64` and `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([filimonov](https://github.com/filimonov)) -- Added `gccMurmurHash` hashing function (GCC flavoured Murmur hash) which uses the same hash seed as [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([sundyli](https://github.com/sundy-li)) -- Added hashing functions `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([shangshujie365](https://github.com/shangshujie365)) -- Added table function `remoteSecure`. Function works as `remote`, but uses secure connection. [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([proller](https://github.com/proller)) - -#### Experimental features {#experimental-features-3} - -- Added multiple JOINs emulation (`allow_experimental_multiple_joins_emulation` setting). [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([Artem Zuikov](https://github.com/4ertus2)) - -#### Bug Fixes {#bug-fixes-21} - -- Make `compiled_expression_cache_size` setting limited by default to lower memory consumption. [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([alesapin](https://github.com/alesapin)) -- Fix a bug that led to hangups in threads that perform ALTERs of Replicated tables and in the thread that updates configuration from ZooKeeper. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fixed a race condition when executing a distributed ALTER task. The race condition led to more than one replica trying to execute the task and all replicas except one failing with a ZooKeeper error. [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fix a bug when `from_zk` config elements weren’t refreshed after a request to ZooKeeper timed out. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fix bug with wrong prefix for IPv4 subnet masks. [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([alesapin](https://github.com/alesapin)) -- Fixed crash (`std::terminate`) in rare cases when a new thread cannot be created due to exhausted resources. [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix bug when in `remote` table function execution when wrong restrictions were used for in `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([alesapin](https://github.com/alesapin)) -- Fix a leak of netlink sockets. They were placed in a pool where they were never deleted and new sockets were created at the start of a new thread when all current sockets were in use. [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([Alex Zatelepin](https://github.com/ztlpn)) -- Fix bug with closing `/proc/self/fd` directory earlier than all fds were read from `/proc` after forking `odbc-bridge` subprocess. [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([alesapin](https://github.com/alesapin)) -- Fixed String to UInt monotonic conversion in case of usage String in primary key. [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([Winter Zhang](https://github.com/zhang2014)) -- Fixed error in calculation of integer conversion function monotonicity. [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed segfault in `arrayEnumerateUniq`, `arrayEnumerateDense` functions in case of some invalid arguments. [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fix UB in StorageMerge. [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([Amos Bird](https://github.com/amosbird)) -- Fixed segfault in functions `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed error: functions `round`, `floor`, `trunc`, `ceil` may return bogus result when executed on integer argument and large negative scale. [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed a bug induced by ‘kill query sync’ which leads to a core dump. [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([muVulDeePecker](https://github.com/fancyqlx)) -- Fix bug with long delay after empty replication queue. [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([alesapin](https://github.com/alesapin)) -- Fixed excessive memory usage in case of inserting into table with `LowCardinality` primary key. [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Fixed `LowCardinality` serialization for `Native` format in case of empty arrays. [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Fixed incorrect result while using distinct by single LowCardinality numeric column. [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Fixed specialized aggregation with LowCardinality key (in case when `compile` setting is enabled). [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Fix user and password forwarding for replicated tables queries. [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([alesapin](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) -- Fixed very rare race condition that can happen when listing tables in Dictionary database while reloading dictionaries. [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed incorrect result when HAVING was used with ROLLUP or CUBE. [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([Sam Chou](https://github.com/reflection)) -- Fixed column aliases for query with `JOIN ON` syntax and distributed tables. [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([Winter Zhang](https://github.com/zhang2014)) -- Fixed error in internal implementation of `quantileTDigest` (found by Artem Vakhrushev). This error never happens in ClickHouse and was relevant only for those who use ClickHouse codebase as a library directly. [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Improvements {#improvements-6} - -- Support for `IF NOT EXISTS` in `ALTER TABLE ADD COLUMN` statements along with `IF EXISTS` in `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([Boris Granveaud](https://github.com/bgranvea)) -- Function `parseDateTimeBestEffort`: support for formats `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` and similar. [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `CapnProtoInputStream` now support jagged structures. [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) -- Usability improvement: added a check that server process is started from the data directory’s owner. Do not allow to start server from root if the data belongs to non-root user. [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([sergey-v-galtsev](https://github.com/sergey-v-galtsev)) -- Better logic of checking required columns during analysis of queries with JOINs. [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([Artem Zuikov](https://github.com/4ertus2)) -- Decreased the number of connections in case of large number of Distributed tables in a single server. [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([Winter Zhang](https://github.com/zhang2014)) -- Supported totals row for `WITH TOTALS` query for ODBC driver. [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([Maksim Koritckiy](https://github.com/nightweb)) -- Allowed to use `Enum`s as integers inside if function. [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([Ivan](https://github.com/abyss7)) -- Added `low_cardinality_allow_in_native_format` setting. If disabled, do not use `LowCadrinality` type in `Native` format. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Removed some redundant objects from compiled expressions cache to lower memory usage. [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([alesapin](https://github.com/alesapin)) -- Add check that `SET send_logs_level = 'value'` query accept appropriate value. [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([Sabyanin Maxim](https://github.com/s-mx)) -- Fixed data type check in type conversion functions. [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([Winter Zhang](https://github.com/zhang2014)) - -#### Performance Improvements {#performance-improvements-5} - -- Add a MergeTree setting `use_minimalistic_part_header_in_zookeeper`. If enabled, Replicated tables will store compact part metadata in a single part znode. This can dramatically reduce ZooKeeper snapshot size (especially if the tables have a lot of columns). Note that after enabling this setting you will not be able to downgrade to a version that doesn’t support it. [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([Alex Zatelepin](https://github.com/ztlpn)) -- Add an DFA-based implementation for functions `sequenceMatch` and `sequenceCount` in case pattern doesn’t contain time. [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- Performance improvement for integer numbers serialization. [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([Amos Bird](https://github.com/amosbird)) -- Zero left padding PODArray so that -1 element is always valid and zeroed. It’s used for branchless calculation of offsets. [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([Amos Bird](https://github.com/amosbird)) -- Reverted `jemalloc` version which lead to performance degradation. [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Backward Incompatible Changes {#backward-incompatible-changes-2} - -- Removed undocumented feature `ALTER MODIFY PRIMARY KEY` because it was superseded by the `ALTER MODIFY ORDER BY` command. [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([Alex Zatelepin](https://github.com/ztlpn)) -- Removed function `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Forbid using scalar subqueries with result of type `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([Ivan](https://github.com/abyss7)) - -#### Build/Testing/Packaging Improvements {#buildtestingpackaging-improvements-6} - -- Added support for PowerPC (`ppc64le`) build. [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([Danila Kutenin](https://github.com/danlark1)) -- Stateful functional tests are run on public available dataset. [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed error when the server cannot start with the `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` message within Docker or systemd-nspawn. [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Updated `rdkafka` library to v1.0.0-RC5. Used cppkafka instead of raw C interface. [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([Ivan](https://github.com/abyss7)) -- Updated `mariadb-client` library. Fixed one of issues found by UBSan. [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Some fixes for UBSan builds. [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added per-commit runs of tests with UBSan build. -- Added per-commit runs of PVS-Studio static analyzer. -- Fixed bugs found by PVS-Studio. [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed glibc compatibility issues. [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Move Docker images to 18.10 and add compatibility file for glibc \>= 2.28 [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([alesapin](https://github.com/alesapin)) -- Add env variable if user don’t want to chown directories in server Docker image. [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([alesapin](https://github.com/alesapin)) -- Enabled most of the warnings from `-Weverything` in clang. Enabled `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Added a few more warnings that are available only in clang 8. [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Link to `libLLVM` rather than to individual LLVM libs when using shared linking. [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([Orivej Desh](https://github.com/orivej)) -- Added sanitizer variables for test images. [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([alesapin](https://github.com/alesapin)) -- `clickhouse-server` debian package will recommend `libcap2-bin` package to use `setcap` tool for setting capabilities. This is optional. [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Improved compilation time, fixed includes. [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([proller](https://github.com/proller)) -- Added performance tests for hash functions. [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([filimonov](https://github.com/filimonov)) -- Fixed cyclic library dependences. [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([proller](https://github.com/proller)) -- Improved compilation with low available memory. [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([proller](https://github.com/proller)) -- Added test script to reproduce performance degradation in `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Fixed misspells in comments and string literals under `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([maiha](https://github.com/maiha)) -- Fixed typos in comments. [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([Evgenii Pravda](https://github.com/kvinty)) - -## [Changelog for 2018](./2018.md) diff --git a/docs/en/whats_new/changelog/index.md b/docs/en/whats_new/changelog/index.md deleted file mode 100644 index 93d5f7ce960..00000000000 --- a/docs/en/whats_new/changelog/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -toc_folder_title: Changelog -toc_priority: 74 -toc_title: '2020' ---- - -{% include 'content/changelog.md' %} diff --git a/docs/en/whats_new/roadmap.md b/docs/en/whats_new/roadmap.md deleted file mode 100644 index e50d663fcb0..00000000000 --- a/docs/en/whats_new/roadmap.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -toc_priority: 74 -toc_title: Roadmap ---- - -# Roadmap {#roadmap} - -## Q1 2020 {#q1-2020} - -- Role-based access control - -## Q2 2020 {#q2-2020} - -- Integration with external authentication services -- Resource pools for more precise distribution of cluster capacity between users - -{## [Original article](https://clickhouse.tech/docs/en/roadmap/) ##} diff --git a/docs/es/commercial/cloud.md b/docs/es/commercial/cloud.md index d8d21359f84..bc593a82ad7 100644 --- a/docs/es/commercial/cloud.md +++ b/docs/es/commercial/cloud.md @@ -1,6 +1,8 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 1 +toc_title: Nube --- # Proveedores de servicios en la nube de ClickHouse {#clickhouse-cloud-service-providers} @@ -12,7 +14,7 @@ machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa [Servicio administrado de Yandex para ClickHouse](https://cloud.yandex.com/services/managed-clickhouse?utm_source=referrals&utm_medium=clickhouseofficialsite&utm_campaign=link3) proporciona las siguientes características clave: -- Servicio ZooKeeper totalmente gestionado para [Replicación de ClickHouse](../engines/table_engines/mergetree_family/replication.md) +- Servicio ZooKeeper totalmente gestionado para [Replicación de ClickHouse](../engines/table-engines/mergetree-family/replication.md) - Múltiples opciones de tipo de almacenamiento - Réplicas en diferentes zonas de disponibilidad - Cifrado y aislamiento diff --git a/docs/es/commercial/index.md b/docs/es/commercial/index.md index 80bb81700f5..b367631ae1c 100644 --- a/docs/es/commercial/index.md +++ b/docs/es/commercial/index.md @@ -1,8 +1,9 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Commercial +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Comercial toc_priority: 70 +toc_title: Comercial --- diff --git a/docs/es/commercial/support.md b/docs/es/commercial/support.md deleted file mode 120000 index 1eb20ccf36a..00000000000 --- a/docs/es/commercial/support.md +++ /dev/null @@ -1 +0,0 @@ -../../en/commercial/support.md \ No newline at end of file diff --git a/docs/es/commercial/support.md b/docs/es/commercial/support.md new file mode 100644 index 00000000000..a817d90dcb5 --- /dev/null +++ b/docs/es/commercial/support.md @@ -0,0 +1,23 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 3 +toc_title: Apoyo +--- + +# Proveedores de servicios de soporte comercial ClickHouse {#clickhouse-commercial-support-service-providers} + +!!! info "INFO" + Si ha lanzado un servicio de soporte comercial ClickHouse, no dude en [abrir una solicitud de extracción](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/commercial/support.md) añadiéndolo a la siguiente lista. + +## Altinidad {#altinity} + +Altinity ha ofrecido soporte y servicios empresariales ClickHouse desde 2017. Los clientes de Altinity van desde empresas Fortune 100 hasta startups. Visitar [Más información](https://www.altinity.com/) para más información. + +## Mafiree {#mafiree} + +[Descripción del servicio](http://mafiree.com/clickhouse-analytics-services.php) + +## MinervaDB {#minervadb} + +[Descripción del servicio](https://minervadb.com/index.php/clickhouse-consulting-and-support-by-minervadb/) diff --git a/docs/es/development/architecture.md b/docs/es/development/architecture.md index c38dfeee9ae..90f028541f3 100644 --- a/docs/es/development/architecture.md +++ b/docs/es/development/architecture.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 62 toc_title: "Descripci\xF3n general de la arquitectura ClickHouse" --- @@ -122,7 +122,7 @@ Hay funciones ordinarias y funciones agregadas. Para las funciones agregadas, co Ordinary functions don't change the number of rows – they work as if they are processing each row independently. In fact, functions are not called for individual rows, but for `Block`de datos para implementar la ejecución de consultas vectorizadas. -Hay algunas funciones diversas, como [BlockSize](../sql_reference/functions/other_functions.md#function-blocksize), [rowNumberInBlock](../sql_reference/functions/other_functions.md#function-rownumberinblock), y [runningAccumulate](../sql_reference/functions/other_functions.md#function-runningaccumulate), que explotan el procesamiento de bloques y violan la independencia de las filas. +Hay algunas funciones diversas, como [BlockSize](../sql-reference/functions/other-functions.md#function-blocksize), [rowNumberInBlock](../sql-reference/functions/other-functions.md#function-rownumberinblock), y [runningAccumulate](../sql-reference/functions/other-functions.md#function-runningaccumulate), que explotan el procesamiento de bloques y violan la independencia de las filas. ClickHouse tiene una tipificación fuerte, por lo que no hay conversión de tipo implícita. Si una función no admite una combinación específica de tipos, produce una excepción. Pero las funciones pueden funcionar (estar sobrecargadas) para muchas combinaciones diferentes de tipos. Por ejemplo, el `plus` función (para implementar el `+` operador) funciona para cualquier combinación de tipos numéricos: `UInt8` + `Float32`, `UInt16` + `Int8` y así sucesivamente. Además, algunas funciones variadas pueden aceptar cualquier número de argumentos, como el `concat` función. diff --git a/docs/es/development/browse-code.md b/docs/es/development/browse-code.md new file mode 100644 index 00000000000..ca031ad03f3 --- /dev/null +++ b/docs/es/development/browse-code.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "Buscar c\xF3digo fuente" +--- + +# Examinar el código fuente de ClickHouse {#browse-clickhouse-source-code} + +Usted puede utilizar **Woboq** navegador de código en línea disponible [aqui](https://clickhouse.tech/codebrowser/html_report/ClickHouse/src/index.html). Proporciona navegación de código y resaltado semántico, búsqueda e indexación. La instantánea de código se actualiza diariamente. + +Además, puede navegar por las fuentes en [GitHub](https://github.com/ClickHouse/ClickHouse) como de costumbre. + +Si está interesado en qué IDE usar, recomendamos CLion, QT Creator, VS Code y KDevelop (con advertencias). Puedes usar cualquier IDE favorito. Vim y Emacs también cuentan. diff --git a/docs/es/development/browse_code.md b/docs/es/development/browse_code.md deleted file mode 100644 index 393577e8dca..00000000000 --- a/docs/es/development/browse_code.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 63 -toc_title: "Examinar el c\xF3digo fuente de ClickHouse" ---- - -# Examinar el código fuente de ClickHouse {#browse-clickhouse-source-code} - -Usted puede utilizar **Woboq** navegador de código en línea disponible [aqui](https://clickhouse.tech/codebrowser/html_report///ClickHouse/src/index.html). Proporciona navegación de código y resaltado semántico, búsqueda e indexación. La instantánea de código se actualiza diariamente. - -Además, puede navegar por las fuentes en [GitHub](https://github.com/ClickHouse/ClickHouse) como de costumbre. - -Si está interesado en qué IDE usar, recomendamos CLion, QT Creator, VS Code y KDevelop (con advertencias). Puedes usar cualquier IDE favorito. Vim y Emacs también cuentan. diff --git a/docs/es/development/build-cross-arm.md b/docs/es/development/build-cross-arm.md new file mode 100644 index 00000000000..2758e9a0e94 --- /dev/null +++ b/docs/es/development/build-cross-arm.md @@ -0,0 +1,43 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 67 +toc_title: "C\xF3mo construir ClickHouse en Linux para AARCH64 (ARM64)" +--- + +# Cómo construir ClickHouse en Linux para la arquitectura AARCH64 (ARM64) {#how-to-build-clickhouse-on-linux-for-aarch64-arm64-architecture} + +Esto es para el caso cuando tiene una máquina Linux y desea usarla para compilar `clickhouse` binario que se ejecutará en otra máquina Linux con arquitectura de CPU AARCH64. Esto está destinado a las comprobaciones de integración continua que se ejecutan en servidores Linux. + +La compilación cruzada para AARCH64 se basa en el [Instrucciones de construcción](build.md), seguirlos primero. + +# Instalar Clang-8 {#install-clang-8} + +Siga las instrucciones de https://apt.llvm.org/ para la configuración de Ubuntu o Debian. +Por ejemplo, en Ubuntu Bionic puede usar los siguientes comandos: + +``` bash +echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee /etc/apt/sources.list.d/llvm.list +sudo apt-get update +sudo apt-get install clang-8 +``` + +# Instalar conjunto de herramientas de compilación cruzada {#install-cross-compilation-toolset} + +``` bash +cd ClickHouse +mkdir -p build-aarch64/cmake/toolchain/linux-aarch64 +wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en' -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz +tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build-aarch64/cmake/toolchain/linux-aarch64 --strip-components=1 +``` + +# Construir ClickHouse {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-arm64 +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake +ninja -C build-arm64 +``` + +El binario resultante se ejecutará solo en Linux con la arquitectura de CPU AARCH64. diff --git a/docs/es/development/build-cross-osx.md b/docs/es/development/build-cross-osx.md new file mode 100644 index 00000000000..35cf01a8ce3 --- /dev/null +++ b/docs/es/development/build-cross-osx.md @@ -0,0 +1,64 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 66 +toc_title: "C\xF3mo construir ClickHouse en Linux para Mac OS X" +--- + +# Cómo construir ClickHouse en Linux para Mac OS X {#how-to-build-clickhouse-on-linux-for-mac-os-x} + +Esto es para el caso cuando tiene una máquina Linux y desea usarla para compilar `clickhouse` Esto está destinado a las comprobaciones de integración continuas que se ejecutan en servidores Linux. Si desea crear ClickHouse directamente en Mac OS X, continúe con [otra instrucción](build-osx.md). + +La compilación cruzada para Mac OS X se basa en el [Instrucciones de construcción](build.md), seguirlos primero. + +# Instalar Clang-8 {#install-clang-8} + +Siga las instrucciones de https://apt.llvm.org/ para la configuración de Ubuntu o Debian. +Por ejemplo, los comandos para Bionic son como: + +``` bash +sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list +sudo apt-get install clang-8 +``` + +# Instalar conjunto de herramientas de compilación cruzada {#install-cross-compilation-toolset} + +Recordemos la ruta donde instalamos `cctools` como ${CCTOOLS} + +``` bash +mkdir ${CCTOOLS} + +git clone https://github.com/tpoechtrager/apple-libtapi.git +cd apple-libtapi +INSTALLPREFIX=${CCTOOLS} ./build.sh +./install.sh +cd .. + +git clone https://github.com/tpoechtrager/cctools-port.git +cd cctools-port/cctools +./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin +make install +``` + +Además, necesitamos descargar macOS X SDK en el árbol de trabajo. + +``` bash +cd ClickHouse +wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' +mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 +tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 +``` + +# Construir ClickHouse {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-osx +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ + -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ + -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ + -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld +ninja -C build-osx +``` + +El binario resultante tendrá un formato ejecutable Mach-O y no se puede ejecutar en Linux. diff --git a/docs/es/development/build-osx.md b/docs/es/development/build-osx.md new file mode 100644 index 00000000000..39eba389798 --- /dev/null +++ b/docs/es/development/build-osx.md @@ -0,0 +1,93 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 65 +toc_title: "C\xF3mo crear ClickHouse en Mac OS X" +--- + +# Cómo crear ClickHouse en Mac OS X {#how-to-build-clickhouse-on-mac-os-x} + +Build debería funcionar en Mac OS X 10.15 (Catalina) + +## Instalar Homebrew {#install-homebrew} + +``` bash +$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +## Instalar compiladores, herramientas y bibliotecas necesarios {#install-required-compilers-tools-and-libraries} + +``` bash +$ brew install cmake ninja libtool gettext +``` + +## Fuentes de ClickHouse de pago {#checkout-clickhouse-sources} + +``` bash +$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git +``` + +o + +``` bash +$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git + +$ cd ClickHouse +``` + +## Construir ClickHouse {#build-clickhouse} + +``` bash +$ mkdir build +$ cd build +$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` +$ ninja +$ cd .. +``` + +## Advertencia {#caveats} + +Si tiene la intención de ejecutar clickhouse-server, asegúrese de aumentar la variable maxfiles del sistema. + +!!! info "Nota" + Tendrás que usar sudo. + +Para ello, cree el siguiente archivo: + +/Library/LaunchDaemons/limit.maxfiles.lista: + +``` xml + + + + + Label + limit.maxfiles + ProgramArguments + + launchctl + limit + maxfiles + 524288 + 524288 + + RunAtLoad + + ServiceIPC + + + +``` + +Ejecute el siguiente comando: + +``` bash +$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist +``` + +Reiniciar. + +Para verificar si está funcionando, puede usar `ulimit -n` comando. + +[Artículo Original](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/es/development/build.md b/docs/es/development/build.md index e7737dfaa8d..861ceb53e51 100644 --- a/docs/es/development/build.md +++ b/docs/es/development/build.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 64 toc_title: "C\xF3mo crear ClickHouse en Linux" --- diff --git a/docs/es/development/build_cross_arm.md b/docs/es/development/build_cross_arm.md deleted file mode 100644 index ac325f3718c..00000000000 --- a/docs/es/development/build_cross_arm.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 67 -toc_title: "C\xF3mo construir ClickHouse en Linux para AARCH64 (ARM64)" ---- - -# Cómo construir ClickHouse en Linux para la arquitectura AARCH64 (ARM64 {#how-to-build-clickhouse-on-linux-for-aarch64-arm64-architecture} - -Esto es para el caso cuando tiene una máquina Linux y desea usarla para compilar `clickhouse` binario que se ejecutará en otra máquina Linux con arquitectura de CPU AARCH64. Esto está destinado a las comprobaciones de integración continua que se ejecutan en servidores Linux. - -La compilación cruzada para AARCH64 se basa en el [Instrucciones de construcción](build.md), seguirlos primero. - -# Instalar Clang-8 {#install-clang-8} - -Siga las instrucciones de https://apt.llvm.org/ para la configuración de Ubuntu o Debian. -Por ejemplo, en Ubuntu Bionic puede usar los siguientes comandos: - -``` bash -echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee /etc/apt/sources.list.d/llvm.list -sudo apt-get update -sudo apt-get install clang-8 -``` - -# Instalar conjunto de herramientas de compilación cruzada {#install-cross-compilation-toolset} - -``` bash -cd ClickHouse -mkdir -p build-aarch64/cmake/toolchain/linux-aarch64 -wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en' -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build-aarch64/cmake/toolchain/linux-aarch64 --strip-components=1 -``` - -# Construir ClickHouse {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-arm64 -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake -ninja -C build-arm64 -``` - -El binario resultante se ejecutará solo en Linux con la arquitectura de CPU AARCH64. diff --git a/docs/es/development/build_cross_osx.md b/docs/es/development/build_cross_osx.md deleted file mode 100644 index b3679c2c794..00000000000 --- a/docs/es/development/build_cross_osx.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 66 -toc_title: "C\xF3mo construir ClickHouse en Linux para Mac OS X" ---- - -# Cómo construir ClickHouse en Linux para Mac OS X {#how-to-build-clickhouse-on-linux-for-mac-os-x} - -Esto es para el caso cuando tiene una máquina Linux y desea usarla para compilar `clickhouse` Esto está destinado a las comprobaciones de integración continuas que se ejecutan en servidores Linux. Si desea crear ClickHouse directamente en Mac OS X, continúe con [otra instrucción](build_osx.md). - -La compilación cruzada para Mac OS X se basa en el [Instrucciones de construcción](build.md), seguirlos primero. - -# Instalar Clang-8 {#install-clang-8} - -Siga las instrucciones de https://apt.llvm.org/ para la configuración de Ubuntu o Debian. -Por ejemplo, los comandos para Bionic son como: - -``` bash -sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list -sudo apt-get install clang-8 -``` - -# Instalar conjunto de herramientas de compilación cruzada {#install-cross-compilation-toolset} - -Recordemos la ruta donde instalamos `cctools` como ${CCTOOLS} - -``` bash -mkdir ${CCTOOLS} - -git clone https://github.com/tpoechtrager/apple-libtapi.git -cd apple-libtapi -INSTALLPREFIX=${CCTOOLS} ./build.sh -./install.sh -cd .. - -git clone https://github.com/tpoechtrager/cctools-port.git -cd cctools-port/cctools -./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin -make install -``` - -Además, necesitamos descargar macOS X SDK en el árbol de trabajo. - -``` bash -cd ClickHouse -wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' -mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 -tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 -``` - -# Construir ClickHouse {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-osx -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ - -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ - -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ - -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld -ninja -C build-osx -``` - -El binario resultante tendrá un formato ejecutable Mach-O y no se puede ejecutar en Linux. diff --git a/docs/es/development/build_osx.md b/docs/es/development/build_osx.md deleted file mode 100644 index 1af1bbd0fac..00000000000 --- a/docs/es/development/build_osx.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 65 -toc_title: "C\xF3mo crear ClickHouse en Mac OS X" ---- - -# Cómo crear ClickHouse en Mac OS X {#how-to-build-clickhouse-on-mac-os-x} - -Build debería funcionar en Mac OS X 10.15 (Catalina) - -## Instalar Homebrew {#install-homebrew} - -``` bash -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` - -## Instalar compiladores, herramientas y bibliotecas necesarios {#install-required-compilers-tools-and-libraries} - -``` bash -$ brew install cmake ninja libtool gettext -``` - -## Fuentes de ClickHouse de pago {#checkout-clickhouse-sources} - -``` bash -$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git -``` - -o - -``` bash -$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git - -$ cd ClickHouse -``` - -## Construir ClickHouse {#build-clickhouse} - -``` bash -$ mkdir build -$ cd build -$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` -$ ninja -$ cd .. -``` - -## Advertencia {#caveats} - -Si tiene la intención de ejecutar clickhouse-server, asegúrese de aumentar la variable maxfiles del sistema. - -!!! info "Nota" - Tendrás que usar sudo. - -Para ello, cree el siguiente archivo: - -/Library/LaunchDaemons/limit.maxfiles.lista: - -``` xml - - - - - Label - limit.maxfiles - ProgramArguments - - launchctl - limit - maxfiles - 524288 - 524288 - - RunAtLoad - - ServiceIPC - - - -``` - -Ejecute el siguiente comando: - -``` bash -$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist -``` - -Reiniciar. - -Para verificar si está funcionando, puede usar `ulimit -n` comando. - -[Artículo Original](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/es/development/contrib.md b/docs/es/development/contrib.md index 387dbee9120..a510c9e80a5 100644 --- a/docs/es/development/contrib.md +++ b/docs/es/development/contrib.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 70 toc_title: Bibliotecas de terceros utilizadas --- diff --git a/docs/es/development/developer-instruction.md b/docs/es/development/developer-instruction.md new file mode 100644 index 00000000000..8f21e851b89 --- /dev/null +++ b/docs/es/development/developer-instruction.md @@ -0,0 +1,287 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "La instrucci\xF3n para desarrolladores de ClickHouse para principiantes" +--- + +La construcción de ClickHouse es compatible con Linux, FreeBSD y Mac OS X. + +# Si utiliza Windows {#if-you-use-windows} + +Si usa Windows, necesita crear una máquina virtual con Ubuntu. Para comenzar a trabajar con una máquina virtual, instale VirtualBox. Puede descargar Ubuntu desde el sitio web: https://www.ubuntu.com/\#download. Por favor, cree una máquina virtual a partir de la imagen descargada (debe reservar al menos 4 GB de RAM para ello). Para ejecutar un terminal de línea de comandos en Ubuntu, busque un programa que contenga la palabra “terminal” en su nombre (gnome-terminal, konsole etc.) o simplemente presione Ctrl + Alt + T. + +# Si utiliza un sistema de 32 bits {#if-you-use-a-32-bit-system} + +ClickHouse no puede funcionar ni construir en un sistema de 32 bits. Debe adquirir acceso a un sistema de 64 bits y puede continuar leyendo. + +# Creación de un repositorio en GitHub {#creating-a-repository-on-github} + +Para comenzar a trabajar con el repositorio de ClickHouse, necesitará una cuenta de GitHub. + +Probablemente ya tenga uno, pero si no lo hace, regístrese en https://github.com . En caso de que no tenga claves SSH, debe generarlas y luego cargarlas en GitHub. Es necesario para enviar a través de sus parches. También es posible usar las mismas claves SSH que usa con cualquier otro servidor SSH, probablemente ya las tenga. + +Cree una bifurcación del repositorio ClickHouse. Para hacerlo por favor haga clic en el “fork” botón en la esquina superior derecha en https://github.com/ClickHouse/ClickHouse . Se bifurcará su propia copia de ClickHouse/ClickHouse a su cuenta. + +El proceso de desarrollo consiste en comprometer primero los cambios previstos en su bifurcación de ClickHouse y luego crear un “pull request” para que estos cambios sean aceptados en el repositorio principal (ClickHouse / ClickHouse). + +Para trabajar con repositorios git, instale `git`. + +Para hacer eso en Ubuntu, ejecutaría en la terminal de línea de comandos: + + sudo apt update + sudo apt install git + +Puede encontrar un breve manual sobre el uso de Git aquí: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf . +Para obtener un manual detallado sobre Git, consulte https://git-scm.com/book/en/v2 . + +# Clonación de un repositorio en su máquina de desarrollo {#cloning-a-repository-to-your-development-machine} + +A continuación, debe descargar los archivos fuente en su máquina de trabajo. Esto se llama “to clone a repository” porque crea una copia local del repositorio en su máquina de trabajo. + +En el terminal de línea de comandos, ejecute: + + git clone --recursive git@github.com:your_github_username/ClickHouse.git + cd ClickHouse + +Nota: por favor, sustituye *your\_github\_username* con lo que es apropiado! + +Este comando creará un directorio `ClickHouse` que contiene la copia de trabajo del proyecto. + +Es importante que la ruta al directorio de trabajo no contenga espacios en blanco, ya que puede ocasionar problemas con la ejecución del sistema de compilación. + +Tenga en cuenta que el repositorio ClickHouse utiliza `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` como en el ejemplo anterior. Si el repositorio se ha clonado sin submódulos, para descargarlos debe ejecutar lo siguiente: + + git submodule init + git submodule update + +Puede verificar el estado con el comando: `git submodule status`. + +Si recibe el siguiente mensaje de error: + + Permission denied (publickey). + fatal: Could not read from remote repository. + + Please make sure you have the correct access rights + and the repository exists. + +Por lo general, significa que faltan las claves SSH para conectarse a GitHub. Estas teclas se encuentran normalmente en `~/.ssh`. Para que las claves SSH sean aceptadas, debe cargarlas en la sección de configuración de la interfaz de usuario de GitHub. + +También puede clonar el repositorio a través del protocolo https: + + git clone https://github.com/ClickHouse/ClickHouse.git + +Sin embargo, esto no le permitirá enviar los cambios al servidor. Aún puede usarlo temporalmente y agregar las claves SSH más tarde reemplazando la dirección remota del repositorio con `git remote` comando. + +También puede agregar la dirección original del repositorio de ClickHouse a su repositorio local para extraer actualizaciones desde allí: + + git remote add upstream git@github.com:ClickHouse/ClickHouse.git + +Después de ejecutar con éxito este comando, podrá extraer actualizaciones del repositorio principal de ClickHouse ejecutando `git pull upstream master`. + +## Trabajar con submódulos {#working-with-submodules} + +Trabajar con submódulos en git podría ser doloroso. Los siguientes comandos ayudarán a administrarlo: + + # ! each command accepts --recursive + # Update remote URLs for submodules. Barely rare case + git submodule sync + # Add new submodules + git submodule init + # Update existing submodules to the current state + git submodule update + # Two last commands could be merged together + git submodule update --init + +Los siguientes comandos le ayudarían a restablecer todos los submódulos al estado inicial (!¡ADVERTENCIA! - cualquier cambio en el interior será eliminado): + + # Synchronizes submodules' remote URL with .gitmodules + git submodule sync --recursive + # Update the registered submodules with initialize not yet initialized + git submodule update --init --recursive + # Reset all changes done after HEAD + git submodule foreach git reset --hard + # Clean files from .gitignore + git submodule foreach git clean -xfd + # Repeat last 4 commands for all submodule + git submodule foreach git submodule sync --recursive + git submodule foreach git submodule update --init --recursive + git submodule foreach git submodule foreach git reset --hard + git submodule foreach git submodule foreach git clean -xfd + +# Sistema de construcción {#build-system} + +ClickHouse utiliza CMake y Ninja para la construcción. + +CMake - un sistema de meta-construcción que puede generar archivos Ninja (tareas de construcción). +Ninja: un sistema de compilación más pequeño con un enfoque en la velocidad utilizada para ejecutar esas tareas generadas por cmake. + +Para instalar en Ubuntu, Debian o Mint run `sudo apt install cmake ninja-build`. + +En CentOS, RedHat se ejecuta `sudo yum install cmake ninja-build`. + +Si usa Arch o Gentoo, probablemente lo sepa usted mismo cómo instalar CMake. + +Para instalar CMake y Ninja en Mac OS X, primero instale Homebrew y luego instale todo lo demás a través de brew: + + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install cmake ninja + +A continuación, verifique la versión de CMake: `cmake --version`. Si está por debajo de 3.3, debe instalar una versión más reciente desde el sitio web: https://cmake.org/download/. + +# Bibliotecas externas opcionales {#optional-external-libraries} + +ClickHouse utiliza varias bibliotecas externas para la construcción. Todos ellos no necesitan ser instalados por separado, ya que se construyen junto con ClickHouse a partir de las fuentes ubicadas en los submódulos. Puede consultar la lista en `contrib`. + +# Compilador de C ++ {#c-compiler} + +Los compiladores GCC a partir de la versión 9 y Clang versión 8 o superior son compatibles para construir ClickHouse. + +Las compilaciones oficiales de Yandex actualmente usan GCC porque genera código de máquina de un rendimiento ligeramente mejor (con una diferencia de hasta varios por ciento según nuestros puntos de referencia). Y Clang es más conveniente para el desarrollo generalmente. Sin embargo, nuestra plataforma de integración continua (CI) ejecuta verificaciones de aproximadamente una docena de combinaciones de compilación. + +Para instalar GCC en Ubuntu, ejecute: `sudo apt install gcc g++` + +Compruebe la versión de gcc: `gcc --version`. Si está por debajo de 9, siga las instrucciones aquí: https://clickhouse.tech/docs/es/development/build/#install-gcc-9. + +La compilación de Mac OS X solo es compatible con Clang. Sólo tiene que ejecutar `brew install llvm` + +Si decide utilizar Clang, también puede instalar `libc++` y `lld` si usted sabe lo que es. Utilizar `ccache` también se recomienda. + +# El proceso de construcción {#the-building-process} + +Ahora que está listo para construir ClickHouse, le recomendamos que cree un directorio separado `build` dentro `ClickHouse` que contendrá todos los de la generación de artefactos: + + mkdir build + cd build + +Puede tener varios directorios diferentes (build\_release, build\_debug, etc.) para diferentes tipos de construcción. + +Mientras que dentro de la `build` directorio, configure su compilación ejecutando CMake. Antes de la primera ejecución, debe definir variables de entorno que especifiquen el compilador (compilador gcc versión 9 en este ejemplo). + +Linux: + + export CC=gcc-9 CXX=g++-9 + cmake .. + +Mac OS X: + + export CC=clang CXX=clang++ + cmake .. + +El `CC` variable especifica el compilador para C (abreviatura de C Compiler), y `CXX` variable indica qué compilador de C ++ se usará para compilar. + +Para una construcción más rápida, puede recurrir al `debug` tipo de compilación: una compilación sin optimizaciones. Para ese suministro el siguiente parámetro `-D CMAKE_BUILD_TYPE=Debug`: + + cmake -D CMAKE_BUILD_TYPE=Debug .. + +Puede cambiar el tipo de compilación ejecutando este comando en el `build` directorio. + +Ejecutar ninja para construir: + + ninja clickhouse-server clickhouse-client + +Solo los binarios requeridos se van a construir en este ejemplo. + +Si necesita construir todos los binarios (utilidades y pruebas), debe ejecutar ninja sin parámetros: + + ninja + +La compilación completa requiere aproximadamente 30 GB de espacio libre en disco o 15 GB para construir los binarios principales. + +Cuando hay una gran cantidad de RAM disponible en la máquina de compilación, debe limitar el número de tareas de compilación que se ejecutan en paralelo con `-j` parámetro: + + ninja -j 1 clickhouse-server clickhouse-client + +En máquinas con 4GB de RAM, se recomienda especificar 1, para 8GB de RAM `-j 2` se recomienda. + +Si recibe el mensaje: `ninja: error: loading 'build.ninja': No such file or directory`, significa que la generación de una configuración de compilación ha fallado y necesita inspeccionar el mensaje anterior. + +Cuando se inicie correctamente el proceso de construcción, verá el progreso de la compilación: el número de tareas procesadas y el número total de tareas. + +Al crear mensajes sobre archivos protobuf en la biblioteca libhdfs2, como `libprotobuf WARNING` puede aparecer. Afectan a nada y son seguros para ser ignorado. + +Tras la compilación exitosa, obtienes un archivo ejecutable `ClickHouse//programs/clickhouse`: + + ls -l programs/clickhouse + +# Ejecución del ejecutable construido de ClickHouse {#running-the-built-executable-of-clickhouse} + +Para ejecutar el servidor bajo el usuario actual, debe navegar hasta `ClickHouse/programs/server/` (situado fuera de `build`) y ejecutar: + + ../../build/programs/clickhouse server + +En este caso, ClickHouse usará archivos de configuración ubicados en el directorio actual. Puede ejecutar `clickhouse server` desde cualquier directorio que especifique la ruta a un archivo de configuración como un parámetro de línea de comandos `--config-file`. + +Para conectarse a ClickHouse con clickhouse-client en otro terminal, vaya a `ClickHouse/build/programs/` y ejecutar `clickhouse client`. + +Si usted consigue `Connection refused` mensaje en Mac OS X o FreeBSD, intente especificar la dirección de host 127.0.0.1: + + clickhouse client --host 127.0.0.1 + +Puede reemplazar la versión de producción del binario ClickHouse instalado en su sistema con su binario ClickHouse personalizado. Para ello, instale ClickHouse en su máquina siguiendo las instrucciones del sitio web oficial. A continuación, ejecute lo siguiente: + + sudo service clickhouse-server stop + sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ + sudo service clickhouse-server start + +Tenga en cuenta que `clickhouse-client`, `clickhouse-server` y otros son enlaces simbólicos a los comúnmente compartidos `clickhouse` binario. + +También puede ejecutar su binario ClickHouse personalizado con el archivo de configuración del paquete ClickHouse instalado en su sistema: + + sudo service clickhouse-server stop + sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml + +# IDE (entorno de desarrollo integrado) {#ide-integrated-development-environment} + +Si no sabe qué IDE usar, le recomendamos que use CLion. CLion es un software comercial, pero ofrece un período de prueba gratuito de 30 días. También es gratuito para los estudiantes. CLion se puede usar tanto en Linux como en Mac OS X. + +KDevelop y QTCreator son otras excelentes alternativas de un IDE para desarrollar ClickHouse. KDevelop viene como un IDE muy útil aunque inestable. Si KDevelop se bloquea después de un tiempo al abrir el proyecto, debe hacer clic “Stop All” botón tan pronto como se ha abierto la lista de archivos del proyecto. Después de hacerlo, KDevelop debería estar bien para trabajar. + +Como editores de código simples, puede usar Sublime Text o Visual Studio Code, o Kate (todos los cuales están disponibles en Linux). + +Por si acaso, vale la pena mencionar que CLion crea `build` por sí mismo, también por sí mismo selecciona `debug` para el tipo de compilación, para la configuración usa una versión de CMake que está definida en CLion y no la instalada por usted, y finalmente, CLion usará `make` para ejecutar tareas de compilación en lugar de `ninja`. Este es un comportamiento normal, solo tenlo en cuenta para evitar confusiones. + +# Código de escritura {#writing-code} + +La descripción de la arquitectura ClickHouse se puede encontrar aquí: https://clickhouse.tech/docs/es/desarrollo/arquitectura/ + +La Guía de estilo de código: https://clickhouse.tech/docs/en/development/style/ + +Pruebas de escritura: https://clickhouse.tech/docs/en/development/tests/ + +Lista de tareas: https://github.com/ClickHouse/ClickHouse/contribute + +# Datos de prueba {#test-data} + +El desarrollo de ClickHouse a menudo requiere cargar conjuntos de datos realistas. Es particularmente importante para las pruebas de rendimiento. Tenemos un conjunto especialmente preparado de datos anónimos de Yandex.Métrica. Se requiere, además, unos 3 GB de espacio libre en disco. Tenga en cuenta que estos datos no son necesarios para realizar la mayoría de las tareas de desarrollo. + + sudo apt install wget xz-utils + + wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz + wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz + + xz -v -d hits_v1.tsv.xz + xz -v -d visits_v1.tsv.xz + + clickhouse-client + + CREATE DATABASE IF NOT EXISTS test + + CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); + + CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); + + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv + +# Creación de solicitud de extracción {#creating-pull-request} + +Navega a tu repositorio de fork en la interfaz de usuario de GitHub. Si ha estado desarrollando en una sucursal, debe seleccionar esa sucursal. Habrá un “Pull request” botón situado en la pantalla. En esencia, esto significa “create a request for accepting my changes into the main repository”. + +Se puede crear una solicitud de extracción incluso si el trabajo aún no se ha completado. En este caso, por favor ponga la palabra “WIP” (trabajo en curso) al comienzo del título, se puede cambiar más tarde. Esto es útil para la revisión cooperativa y la discusión de los cambios, así como para ejecutar todas las pruebas disponibles. Es importante que proporcione una breve descripción de sus cambios, que más tarde se utilizará para generar registros de cambios de lanzamiento. + +Las pruebas comenzarán tan pronto como los empleados de Yandex etiqueten su PR con una etiqueta “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. + +El sistema preparará compilaciones binarias ClickHouse para su solicitud de extracción individualmente. Para recuperar estas compilaciones, haga clic en “Details” junto al link “ClickHouse build check” en la lista de cheques. Allí encontrará enlaces directos a la construcción.deb paquetes de ClickHouse que puede implementar incluso en sus servidores de producción (si no tiene miedo). + +Lo más probable es que algunas de las compilaciones fallen las primeras veces. Esto se debe al hecho de que verificamos las compilaciones tanto con gcc como con clang, con casi todas las advertencias existentes (siempre con el `-Werror` bandera) habilitado para sonido. En esa misma página, puede encontrar todos los registros de compilación para que no tenga que compilar ClickHouse de todas las formas posibles. diff --git a/docs/es/development/developer_instruction.md b/docs/es/development/developer_instruction.md deleted file mode 100644 index a9572ae0eef..00000000000 --- a/docs/es/development/developer_instruction.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 61 -toc_title: "La instrucci\xF3n para desarrolladores de ClickHouse para principiantes" ---- - -La construcción de ClickHouse es compatible con Linux, FreeBSD y Mac OS X. - -# Si utiliza Windows {#if-you-use-windows} - -Si usa Windows, necesita crear una máquina virtual con Ubuntu. Para comenzar a trabajar con una máquina virtual, instale VirtualBox. Puede descargar Ubuntu desde el sitio web: https://www.ubuntu.com/\#download. Por favor, cree una máquina virtual a partir de la imagen descargada (debe reservar al menos 4 GB de RAM para ello). Para ejecutar un terminal de línea de comandos en Ubuntu, busque un programa que contenga la palabra “terminal” en su nombre (gnome-terminal, konsole etc.) o simplemente presione Ctrl + Alt + T. - -# Si utiliza un sistema de 32 bits {#if-you-use-a-32-bit-system} - -ClickHouse no puede funcionar ni construir en un sistema de 32 bits. Debe adquirir acceso a un sistema de 64 bits y puede continuar leyendo. - -# Crear un repositorio en GitHub {#creating-a-repository-on-github} - -Para comenzar a trabajar con el repositorio de ClickHouse, necesitará una cuenta de GitHub. - -Probablemente ya tenga uno, pero si no lo hace, regístrese en https://github.com . En caso de que no tenga claves SSH, debe generarlas y luego cargarlas en GitHub. Es necesario para enviar a través de sus parches. También es posible usar las mismas claves SSH que usa con cualquier otro servidor SSH, probablemente ya las tenga. - -Cree una bifurcación del repositorio ClickHouse. Para hacerlo por favor haga clic en el “fork” botón en la esquina superior derecha en https://github.com/ClickHouse/ClickHouse . Se bifurcará su propia copia de ClickHouse/ClickHouse a su cuenta. - -El proceso de desarrollo consiste en comprometer primero los cambios previstos en su bifurcación de ClickHouse y luego crear un “pull request” para que estos cambios sean aceptados en el repositorio principal (ClickHouse / ClickHouse). - -Para trabajar con repositorios git, instale `git`. - -Para hacer eso en Ubuntu, ejecutaría en la terminal de línea de comandos: - - sudo apt update - sudo apt install git - -Puede encontrar un breve manual sobre el uso de Git aquí: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf . -Para obtener un manual detallado sobre Git, consulte https://git-scm.com/book/en/v2 . - -# Clonación de un repositorio en su máquina de desarrollo {#cloning-a-repository-to-your-development-machine} - -A continuación, debe descargar los archivos fuente en su máquina de trabajo. Esto se llama “to clone a repository” porque crea una copia local del repositorio en su máquina de trabajo. - -En el terminal de línea de comandos, ejecute: - - git clone --recursive git@guthub.com:your_github_username/ClickHouse.git - cd ClickHouse - -Nota: por favor, sustituye *your\_github\_username* con lo que es apropiado! - -Este comando creará un directorio `ClickHouse` que contiene la copia de trabajo del proyecto. - -Es importante que la ruta al directorio de trabajo no contenga espacios en blanco, ya que puede ocasionar problemas con la ejecución del sistema de compilación. - -Tenga en cuenta que el repositorio ClickHouse utiliza `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` como en el ejemplo anterior. Si el repositorio se ha clonado sin submódulos, para descargarlos debe ejecutar lo siguiente: - - git submodule init - git submodule update - -Puede verificar el estado con el comando: `git submodule status`. - -Si recibe el siguiente mensaje de error: - - Permission denied (publickey). - fatal: Could not read from remote repository. - - Please make sure you have the correct access rights - and the repository exists. - -Por lo general, significa que faltan las claves SSH para conectarse a GitHub. Estas teclas se encuentran normalmente en `~/.ssh`. Para que las claves SSH sean aceptadas, debe cargarlas en la sección de configuración de la interfaz de usuario de GitHub. - -También puede clonar el repositorio a través del protocolo https: - - git clone https://github.com/ClickHouse/ClickHouse.git - -Sin embargo, esto no le permitirá enviar los cambios al servidor. Aún puede usarlo temporalmente y agregar las claves SSH más tarde reemplazando la dirección remota del repositorio con `git remote` comando. - -También puede agregar la dirección original del repositorio de ClickHouse a su repositorio local para extraer actualizaciones desde allí: - - git remote add upstream git@github.com:ClickHouse/ClickHouse.git - -Después de ejecutar con éxito este comando, podrá extraer actualizaciones del repositorio principal de ClickHouse ejecutando `git pull upstream master`. - -## Trabajar con submódulos {#working-with-submodules} - -Trabajar con submódulos en git podría ser doloroso. Los siguientes comandos ayudarán a administrarlo: - - # ! each command accepts --recursive - # Update remote URLs for submodules. Barely rare case - git submodule sync - # Add new submodules - git submodule init - # Update existing submodules to the current state - git submodule update - # Two last commands could be merged together - git submodule update --init - -Los siguientes comandos le ayudarían a restablecer todos los submódulos al estado inicial (!¡ADVERTENCIA! - cualquier cambio en el interior será eliminado): - - # Synchronizes submodules' remote URL with .gitmodules - git submodule sync --recursive - # Update the registered submodules with initialize not yet initialized - git submodule update --init --recursive - # Reset all changes done after HEAD - git submodule foreach git reset --hard - # Clean files from .gitignore - git submodule foreach git clean -xfd - # Repeat last 4 commands for all submodule - git submodule foreach git submodule sync --recursive - git submodule foreach git submodule update --init --recursive - git submodule foreach git submodule foreach git reset --hard - git submodule foreach git submodule foreach git clean -xfd - -# Sistema de construcción {#build-system} - -ClickHouse utiliza CMake y Ninja para la construcción. - -CMake - un sistema de meta-construcción que puede generar archivos Ninja (tareas de construcción). -Ninja: un sistema de compilación más pequeño con un enfoque en la velocidad utilizada para ejecutar esas tareas generadas por cmake. - -Para instalar en Ubuntu, Debian o Mint run `sudo apt install cmake ninja-build`. - -En CentOS, RedHat se ejecuta `sudo yum install cmake ninja-build`. - -Si usa Arch o Gentoo, probablemente lo sepa usted mismo cómo instalar CMake. - -Para instalar CMake y Ninja en Mac OS X, primero instale Homebrew y luego instale todo lo demás a través de brew: - - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew install cmake ninja - -A continuación, verifique la versión de CMake: `cmake --version`. Si está por debajo de 3.3, debe instalar una versión más reciente desde el sitio web: https://cmake.org/download/. - -# Bibliotecas externas opcionales {#optional-external-libraries} - -ClickHouse utiliza varias bibliotecas externas para la construcción. Todos ellos no necesitan ser instalados por separado, ya que se construyen junto con ClickHouse a partir de las fuentes ubicadas en los submódulos. Puede consultar la lista en `contrib`. - -# Compilador de C ++ {#c-compiler} - -Los compiladores GCC a partir de la versión 9 y Clang versión 8 o superior son compatibles para construir ClickHouse. - -Las compilaciones oficiales de Yandex actualmente usan GCC porque genera código de máquina de un rendimiento ligeramente mejor (con una diferencia de hasta varios por ciento según nuestros puntos de referencia). Y Clang es más conveniente para el desarrollo generalmente. Sin embargo, nuestra plataforma de integración continua (CI) ejecuta verificaciones de aproximadamente una docena de combinaciones de compilación. - -Para instalar GCC en Ubuntu, ejecute: `sudo apt install gcc g++` - -Compruebe la versión de gcc: `gcc --version`. Si está por debajo de 9, siga las instrucciones aquí: https://clickhouse .tech/docs/en/development/build/\#install-gcc-9. - -La compilación de Mac OS X solo es compatible con Clang. Sólo tiene que ejecutar `brew install llvm` - -Si decide utilizar Clang, también puede instalar `libc++` y `lld` si usted sabe lo que es. Utilizar `ccache` también se recomienda. - -# El proceso de construcción {#the-building-process} - -Ahora que está listo para construir ClickHouse, le recomendamos que cree un directorio separado `build` dentro `ClickHouse` que contendrá todos los de la generación de artefactos: - - mkdir build - cd build - -Puede tener varios directorios diferentes (build\_release, build\_debug, etc.) para diferentes tipos de construcción. - -Mientras que dentro de la `build` directorio, configure su compilación ejecutando CMake. Antes de la primera ejecución, debe definir variables de entorno que especifiquen el compilador (compilador gcc versión 9 en este ejemplo). - -Linux: - - export CC=gcc-9 CXX=g++-9 - cmake .. - -Mac OS X: - - export CC=clang CXX=clang++ - cmake .. - -El `CC` variable especifica el compilador para C (abreviatura de C Compiler), y `CXX` variable indica qué compilador de C ++ se usará para compilar. - -Para una construcción más rápida, puede recurrir al `debug` tipo de compilación: una compilación sin optimizaciones. Para ese suministro el siguiente parámetro `-D CMAKE_BUILD_TYPE=Debug`: - - cmake -D CMAKE_BUILD_TYPE=Debug .. - -Puede cambiar el tipo de compilación ejecutando este comando en el `build` directorio. - -Ejecutar ninja para construir: - - ninja clickhouse-server clickhouse-client - -Solo los binarios requeridos se van a construir en este ejemplo. - -Si necesita construir todos los binarios (utilidades y pruebas), debe ejecutar ninja sin parámetros: - - ninja - -La compilación completa requiere aproximadamente 30 GB de espacio libre en disco o 15 GB para construir los binarios principales. - -Cuando hay una gran cantidad de RAM disponible en la máquina de compilación, debe limitar el número de tareas de compilación que se ejecutan en paralelo con `-j` parámetro: - - ninja -j 1 clickhouse-server clickhouse-client - -En máquinas con 4GB de RAM, se recomienda especificar 1, para 8GB de RAM `-j 2` se recomienda. - -Si recibe el mensaje: `ninja: error: loading 'build.ninja': No such file or directory`, significa que la generación de una configuración de compilación ha fallado y necesita inspeccionar el mensaje anterior. - -Cuando se inicie correctamente el proceso de construcción, verá el progreso de la compilación: el número de tareas procesadas y el número total de tareas. - -Al crear mensajes sobre archivos protobuf en la biblioteca libhdfs2, como `libprotobuf WARNING` puede aparecer. Afectan a nada y son seguros para ser ignorado. - -Tras la compilación exitosa, obtienes un archivo ejecutable `ClickHouse//programs/clickhouse`: - - ls -l programs/clickhouse - -# Ejecutando el ejecutable construido de ClickHouse {#running-the-built-executable-of-clickhouse} - -Para ejecutar el servidor bajo el usuario actual, debe navegar hasta `ClickHouse/programs/server/` (situado fuera de `build`) y ejecutar: - - ../../../build/programs/clickhouse server - -En este caso, ClickHouse usará archivos de configuración ubicados en el directorio actual. Puede ejecutar `clickhouse server` desde cualquier directorio que especifique la ruta a un archivo de configuración como un parámetro de línea de comandos `--config-file`. - -Para conectarse a ClickHouse con clickhouse-client en otro terminal, vaya a `ClickHouse/build/programs/` y ejecutar `clickhouse client`. - -Si usted consigue `Connection refused` mensaje en Mac OS X o FreeBSD, intente especificar la dirección de host 127.0.0.1: - - clickhouse client --host 127.0.0.1 - -Puede reemplazar la versión de producción del binario ClickHouse instalado en su sistema con su binario ClickHouse personalizado. Para ello, instale ClickHouse en su máquina siguiendo las instrucciones del sitio web oficial. A continuación, ejecute lo siguiente: - - sudo service clickhouse-server stop - sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ - sudo service clickhouse-server start - -Tenga en cuenta que `clickhouse-client`, `clickhouse-server` y otros son enlaces simbólicos a los comúnmente compartidos `clickhouse` binario. - -También puede ejecutar su binario ClickHouse personalizado con el archivo de configuración del paquete ClickHouse instalado en su sistema: - - sudo service clickhouse-server stop - sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml - -# IDE (entorno de desarrollo integrado) {#ide-integrated-development-environment} - -Si no sabe qué IDE usar, le recomendamos que use CLion. CLion es un software comercial, pero ofrece un período de prueba gratuito de 30 días. También es gratuito para los estudiantes. CLion se puede usar tanto en Linux como en Mac OS X. - -KDevelop y QTCreator son otras excelentes alternativas de un IDE para desarrollar ClickHouse. KDevelop viene como un IDE muy útil aunque inestable. Si KDevelop se bloquea después de un tiempo al abrir el proyecto, debe hacer clic “Stop All” botón tan pronto como se ha abierto la lista de archivos del proyecto. Después de hacerlo, KDevelop debería estar bien para trabajar. - -Como editores de código simples, puede usar Sublime Text o Visual Studio Code, o Kate (todos los cuales están disponibles en Linux). - -Por si acaso, vale la pena mencionar que CLion crea `build` por sí mismo, también por sí mismo selecciona `debug` para el tipo de compilación, para la configuración usa una versión de CMake que está definida en CLion y no la instalada por usted, y finalmente, CLion usará `make` para ejecutar tareas de compilación en lugar de `ninja`. Este es un comportamiento normal, solo tenlo en cuenta para evitar confusiones. - -# Código de escritura {#writing-code} - -La descripción de la arquitectura ClickHouse se puede encontrar aquí: https://clickhouse.tech/docs/es/desarrollo/arquitectura/ - -La Guía de estilo de código: https://clickhouse.tech/docs/en/development/style/ - -Pruebas de escritura: https://clickhouse.tech/docs/en/development/tests/ - -Lista de tareas: https://github.com/ClickHouse/ClickHouse/blob/master/testsructions/easy\_tasks\_sorted\_en.md - -# Datos de prueba {#test-data} - -El desarrollo de ClickHouse a menudo requiere cargar conjuntos de datos realistas. Es particularmente importante para las pruebas de rendimiento. Tenemos un conjunto especialmente preparado de datos anónimos de Yandex.Métrica. Se requiere, además, unos 3 GB de espacio libre en disco. Tenga en cuenta que estos datos no son necesarios para realizar la mayoría de las tareas de desarrollo. - - sudo apt install wget xz-utils - - wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz - wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz - - xz -v -d hits_v1.tsv.xz - xz -v -d visits_v1.tsv.xz - - clickhouse-client - - CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); - - CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); - - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv - -# Creación de solicitud de extracción {#creating-pull-request} - -Navega a tu repositorio de fork en la interfaz de usuario de GitHub. Si ha estado desarrollando en una sucursal, debe seleccionar esa sucursal. Habrá un “Pull request” botón situado en la pantalla. En esencia, esto significa “create a request for accepting my changes into the main repository”. - -Se puede crear una solicitud de extracción incluso si el trabajo aún no se ha completado. En este caso, por favor ponga la palabra “WIP” (trabajo en curso) al comienzo del título, se puede cambiar más tarde. Esto es útil para la revisión cooperativa y la discusión de los cambios, así como para ejecutar todas las pruebas disponibles. Es importante que proporcione una breve descripción de sus cambios, que más tarde se utilizará para generar registros de cambios de lanzamiento. - -Las pruebas comenzarán tan pronto como los empleados de Yandex etiqueten su PR con una etiqueta “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. - -El sistema preparará compilaciones binarias ClickHouse para su solicitud de extracción individualmente. Para recuperar estas compilaciones, haga clic en “Details” junto al link “ClickHouse build check” en la lista de cheques. Allí encontrará enlaces directos a la construcción.deb paquetes de ClickHouse que puede implementar incluso en sus servidores de producción (si no tiene miedo). - -Lo más probable es que algunas de las compilaciones fallen las primeras veces. Esto se debe al hecho de que verificamos las compilaciones tanto con gcc como con clang, con casi todas las advertencias existentes (siempre con el `-Werror` bandera) habilitado para sonido. En esa misma página, puede encontrar todos los registros de compilación para que no tenga que compilar ClickHouse de todas las formas posibles. diff --git a/docs/es/development/index.md b/docs/es/development/index.md index 815a633071e..6f96f9b3f02 100644 --- a/docs/es/development/index.md +++ b/docs/es/development/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Development +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Desarrollo toc_hidden: true toc_priority: 58 toc_title: oculto diff --git a/docs/es/development/style.md b/docs/es/development/style.md index 77815c0204d..7bf3dfc02d6 100644 --- a/docs/es/development/style.md +++ b/docs/es/development/style.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 68 toc_title: "C\xF3mo escribir c\xF3digo C ++" --- diff --git a/docs/es/development/tests.md b/docs/es/development/tests.md index 12afbb68f2e..0d2931c97fa 100644 --- a/docs/es/development/tests.md +++ b/docs/es/development/tests.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 69 toc_title: "C\xF3mo ejecutar pruebas de ClickHouse" --- @@ -34,7 +34,7 @@ significado. `long` es para pruebas que duran un poco más de un segundo. Usted deshabilitar estos grupos de pruebas utilizando `--no-zookeeper`, `--no-shard` y `--no-long` opciones, respectivamente. -## Bugs conocidos {#known-bugs} +## Bugs Conocidos {#known-bugs} Si conocemos algunos errores que se pueden reproducir fácilmente mediante pruebas funcionales, colocamos pruebas funcionales preparadas en `tests/queries/bugs` directorio. Estas pruebas se moverán a `tests/queries/0_stateless` cuando se corrigen errores. @@ -56,17 +56,17 @@ No es necesariamente tener pruebas unitarias si el código ya está cubierto por Las pruebas de rendimiento permiten medir y comparar el rendimiento de alguna parte aislada de ClickHouse en consultas sintéticas. Las pruebas se encuentran en `tests/performance`. Cada prueba está representada por `.xml` archivo con la descripción del caso de prueba. Las pruebas se ejecutan con `clickhouse performance-test` herramienta (que está incrustada en `clickhouse` binario). Ver `--help` para la invocación. -Cada prueba ejecuta una o múltiples consultas (posiblemente con combinaciones de parámetros) en un bucle con algunas condiciones para stop (como “maximum execution speed is not changing in three seconds”) y medir algunas métricas sobre el rendimiento de las consultas (como “maximum execution speed”). Algunas pruebas pueden contener condiciones previas en el conjunto de datos de pruebas precargado. +Cada prueba ejecuta una o varias consultas (posiblemente con combinaciones de parámetros) en un bucle con algunas condiciones para detener (como “maximum execution speed is not changing in three seconds”) y medir algunas métricas sobre el rendimiento de las consultas (como “maximum execution speed”). Algunas pruebas pueden contener condiciones previas en el conjunto de datos de pruebas precargado. Si desea mejorar el rendimiento de ClickHouse en algún escenario, y si se pueden observar mejoras en consultas simples, se recomienda encarecidamente escribir una prueba de rendimiento. Siempre tiene sentido usar `perf top` u otras herramientas de perf durante sus pruebas. ## Herramientas de prueba y secuencias de comandos {#test-tools-and-scripts} -Algunos programas en `tests` directorio no son pruebas preparadas, pero son herramientas de prueba. Por ejemplo, para `Lexer` hay una herramienta `dbms/Parsers/tests/lexer` que solo hacen la tokenización de stdin y escriben el resultado coloreado en stdout. Puede usar este tipo de herramientas como ejemplos de código y para exploración y pruebas manuales. +Algunos programas en `tests` directorio no son pruebas preparadas, pero son herramientas de prueba. Por ejemplo, para `Lexer` hay una herramienta `src/Parsers/tests/lexer` que solo hacen la tokenización de stdin y escriben el resultado coloreado en stdout. Puede usar este tipo de herramientas como ejemplos de código y para exploración y pruebas manuales. También puede colocar un par de archivos `.sh` y `.reference` junto con la herramienta para ejecutarlo en alguna entrada predefinida, entonces el resultado del script se puede comparar con `.reference` file. Este tipo de pruebas no están automatizadas. -## Miscellanous Pruebas {#miscellanous-tests} +## Pruebas diversas {#miscellaneous-tests} Hay pruebas para diccionarios externos ubicados en `tests/external_dictionaries` y para modelos aprendidos a máquina en `tests/external_models`. Estas pruebas no se actualizan y deben transferirse a pruebas de integración. @@ -165,7 +165,7 @@ Por ejemplo, construir con paquetes del sistema es una mala práctica, porque no Aunque no podemos ejecutar todas las pruebas en todas las variantes de compilaciones, queremos verificar al menos que varias variantes de compilación no estén rotas. Para este propósito utilizamos pruebas de construcción. -## Pruebas de compatibilidad de protocolos {#testing-for-protocol-compatibility} +## Pruebas de Compatibilidad de protocolos {#testing-for-protocol-compatibility} Cuando ampliamos el protocolo de red ClickHouse, probamos manualmente que el antiguo clickhouse-client funciona con el nuevo clickhouse-server y el nuevo clickhouse-client funciona con el antiguo clickhouse-server (simplemente ejecutando binarios de los paquetes correspondientes). @@ -199,13 +199,23 @@ Versión de depuración de `jemalloc` se utiliza para la compilación de depurac ## Fuzzing {#fuzzing} -Usamos una prueba de fuzz simple para generar consultas SQL aleatorias y verificar que el servidor no muera. Las pruebas de pelusa se realizan con el desinfectante Address. Lo puedes encontrar en `00746_sql_fuzzy.pl`. Esta prueba debe ejecutarse de forma continua (de la noche a la mañana y más). +ClickHouse fuzzing se implementa tanto usando [LibFuzzer](https://llvm.org/docs/LibFuzzer.html) y consultas SQL aleatorias. +Todas las pruebas de fuzz deben realizarse con desinfectantes (Dirección y Undefined). -A partir de diciembre de 2018, todavía no usamos pruebas de fuzz aisladas del código de la biblioteca. +LibFuzzer se usa para pruebas de fuzz aisladas del código de la biblioteca. Fuzzers se implementan como parte del código de prueba y tienen “\_fuzzer” nombre postfixes. +El ejemplo de Fuzzer se puede encontrar en `src/Parsers/tests/lexer_fuzzer.cpp`. Las configuraciones, diccionarios y corpus específicos de LibFuzzer se almacenan en `tests/fuzz`. +Le recomendamos que escriba pruebas fuzz para cada funcionalidad que maneje la entrada del usuario. + +Fuzzers no se construyen de forma predeterminada. Para construir fuzzers ambos `-DENABLE_FUZZING=1` y `-DENABLE_TESTS=1` se deben establecer opciones. +Recomendamos deshabilitar Jemalloc mientras se construyen fuzzers. Configuración utilizada para integrar +Google OSS-Fuzz se puede encontrar en `docker/fuzz`. + +También usamos una prueba de fuzz simple para generar consultas SQL aleatorias y verificar que el servidor no muera al ejecutarlas. +Lo puedes encontrar en `00746_sql_fuzzy.pl`. Esta prueba debe ejecutarse de forma continua (de la noche a la mañana y más). ## Auditoría de seguridad {#security-audit} -La gente del departamento de Yandex Cloud hace una visión general básica de las capacidades de ClickHouse desde el punto de vista de la seguridad. +La gente de Yandex Security Team hace una visión general básica de las capacidades de ClickHouse desde el punto de vista de la seguridad. ## Analizadores estáticos {#static-analyzers} @@ -249,4 +259,3 @@ No usamos Travis CI debido al límite de tiempo y potencia computacional. No usamos Jenkins. Se usó antes y ahora estamos felices de no estar usando Jenkins. [Artículo Original](https://clickhouse.tech/docs/en/development/tests/) -pruebas/) diff --git a/docs/es/engines/database-engines/index.md b/docs/es/engines/database-engines/index.md new file mode 100644 index 00000000000..8784b9bd02b --- /dev/null +++ b/docs/es/engines/database-engines/index.md @@ -0,0 +1,21 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Motores de base de datos +toc_priority: 27 +toc_title: "Implantaci\xF3n" +--- + +# Motores de base de datos {#database-engines} + +Los motores de bases de datos le permiten trabajar con tablas. + +De forma predeterminada, ClickHouse utiliza su motor de base de datos nativa, que proporciona [motores de mesa](../../engines/table-engines/index.md) y una [Dialecto SQL](../../sql-reference/syntax.md). + +También puede utilizar los siguientes motores de base de datos: + +- [MySQL](mysql.md) + +- [Perezoso](lazy.md) + +[Artículo Original](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/es/engines/database-engines/lazy.md b/docs/es/engines/database-engines/lazy.md new file mode 100644 index 00000000000..0988c4cb395 --- /dev/null +++ b/docs/es/engines/database-engines/lazy.md @@ -0,0 +1,18 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: Perezoso +--- + +# Perezoso {#lazy} + +Mantiene las tablas en RAM solamente `expiration_time_in_seconds` segundos después del último acceso. Solo se puede usar con tablas \*Log. + +Está optimizado para almacenar muchas tablas pequeñas \* Log, para las cuales hay un largo intervalo de tiempo entre los accesos. + +## Creación de una base de datos {#creating-a-database} + + CREATE DATABASE testlazy ENGINE = Lazy(expiration_time_in_seconds); + +[Artículo Original](https://clickhouse.tech/docs/en/database_engines/lazy/) diff --git a/docs/es/engines/database-engines/mysql.md b/docs/es/engines/database-engines/mysql.md new file mode 100644 index 00000000000..5f1dec97f35 --- /dev/null +++ b/docs/es/engines/database-engines/mysql.md @@ -0,0 +1,135 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 30 +toc_title: MySQL +--- + +# MySQL {#mysql} + +Permite conectarse a bases de datos en un servidor MySQL remoto y realizar `INSERT` y `SELECT` consultas para intercambiar datos entre ClickHouse y MySQL. + +El `MySQL` motor de base de datos traducir consultas al servidor MySQL para que pueda realizar operaciones tales como `SHOW TABLES` o `SHOW CREATE TABLE`. + +No puede realizar las siguientes consultas: + +- `RENAME` +- `CREATE TABLE` +- `ALTER` + +## Creación de una base de datos {#creating-a-database} + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] +ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') +``` + +**Parámetros del motor** + +- `host:port` — MySQL server address. +- `database` — Remote database name. +- `user` — MySQL user. +- `password` — User password. + +## Soporte de tipos de datos {#data_types-support} + +| MySQL | Haga clic en Casa | +|----------------------------------|--------------------------------------------------------------| +| UNSIGNED TINYINT | [UInt8](../../sql-reference/data-types/int-uint.md) | +| TINYINT | [Int8](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED SMALLINT | [UInt16](../../sql-reference/data-types/int-uint.md) | +| SMALLINT | [Int16](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../sql-reference/data-types/int-uint.md) | +| INT, MEDIUMINT | [Int32](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED BIGINT | [UInt64](../../sql-reference/data-types/int-uint.md) | +| BIGINT | [Int64](../../sql-reference/data-types/int-uint.md) | +| FLOAT | [Float32](../../sql-reference/data-types/float.md) | +| DOUBLE | [Float64](../../sql-reference/data-types/float.md) | +| DATE | [Fecha](../../sql-reference/data-types/date.md) | +| DATETIME, TIMESTAMP | [FechaHora](../../sql-reference/data-types/datetime.md) | +| BINARY | [Cadena fija](../../sql-reference/data-types/fixedstring.md) | + +Todos los demás tipos de datos MySQL se convierten en [Cadena](../../sql-reference/data-types/string.md). + +[NULL](../../sql-reference/data-types/nullable.md) se admite. + +## Ejemplos de uso {#examples-of-use} + +Tabla en MySQL: + +``` text +mysql> USE test; +Database changed + +mysql> CREATE TABLE `mysql_table` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `float` FLOAT NOT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from mysql_table; ++------+-----+ +| int_id | value | ++------+-----+ +| 1 | 2 | ++------+-----+ +1 row in set (0,00 sec) +``` + +Base de datos en ClickHouse, intercambiando datos con el servidor MySQL: + +``` sql +CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') +``` + +``` sql +SHOW DATABASES +``` + +``` text +┌─name─────┐ +│ default │ +│ mysql_db │ +│ system │ +└──────────┘ +``` + +``` sql +SHOW TABLES FROM mysql_db +``` + +``` text +┌─name─────────┐ +│ mysql_table │ +└──────────────┘ +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +└────────┴───────┘ +``` + +``` sql +INSERT INTO mysql_db.mysql_table VALUES (3,4) +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +│ 3 │ 4 │ +└────────┴───────┘ +``` + +[Artículo Original](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/es/engines/database_engines/index.md b/docs/es/engines/database_engines/index.md deleted file mode 100644 index 6a06a9d6952..00000000000 --- a/docs/es/engines/database_engines/index.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Database Engines -toc_priority: 27 -toc_title: "Implantaci\xF3n" ---- - -# Motores de base de datos {#database-engines} - -Los motores de bases de datos le permiten trabajar con tablas. - -De forma predeterminada, ClickHouse utiliza su motor de base de datos nativa, que proporciona [motores de mesa](../../engines/table_engines/index.md) y una [Dialecto SQL](../../sql_reference/syntax.md). - -También puede utilizar los siguientes motores de base de datos: - -- [MySQL](mysql.md) - -- [Perezoso](lazy.md) - -[Artículo Original](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/es/engines/database_engines/lazy.md b/docs/es/engines/database_engines/lazy.md deleted file mode 100644 index 602a83df606..00000000000 --- a/docs/es/engines/database_engines/lazy.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 31 -toc_title: Perezoso ---- - -# Perezoso {#lazy} - -Mantiene las tablas en RAM solamente `expiration_time_in_seconds` segundos después del último acceso. Solo se puede usar con tablas \*Log. - -Está optimizado para almacenar muchas tablas pequeñas \* Log, para las cuales hay un largo intervalo de tiempo entre los accesos. - -## Creación de una base de datos {#creating-a-database} - - CREATE DATABASE testlazy ENGINE = Lazy(expiration_time_in_seconds); - -[Artículo Original](https://clickhouse.tech/docs/en/database_engines/lazy/) diff --git a/docs/es/engines/database_engines/mysql.md b/docs/es/engines/database_engines/mysql.md deleted file mode 100644 index 18e1752e4da..00000000000 --- a/docs/es/engines/database_engines/mysql.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 30 -toc_title: MySQL ---- - -# Mysql {#mysql} - -Permite conectarse a bases de datos en un servidor MySQL remoto y realizar `INSERT` y `SELECT` consultas para intercambiar datos entre ClickHouse y MySQL. - -El `MySQL` motor de base de datos traducir consultas al servidor MySQL para que pueda realizar operaciones tales como `SHOW TABLES` o `SHOW CREATE TABLE`. - -No puede realizar las siguientes consultas: - -- `RENAME` -- `CREATE TABLE` -- `ALTER` - -## Creación de una base de datos {#creating-a-database} - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] -ENGINE = MySQL('host:port', 'database', 'user', 'password') -``` - -**Parámetros del motor** - -- `host:port` — MySQL server address. -- `database` — Remote database name. -- `user` — MySQL user. -- `password` — User password. - -## Soporte de tipos de datos {#data_types-support} - -| MySQL | Haga clic en Casa | -|----------------------------------|--------------------------------------------------------------| -| UNSIGNED TINYINT | [UInt8](../../sql_reference/data_types/int_uint.md) | -| TINYINT | [Int8](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED SMALLINT | [UInt16](../../sql_reference/data_types/int_uint.md) | -| SMALLINT | [Int16](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../sql_reference/data_types/int_uint.md) | -| INT, MEDIUMINT | [Int32](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED BIGINT | [UInt64](../../sql_reference/data_types/int_uint.md) | -| BIGINT | [Int64](../../sql_reference/data_types/int_uint.md) | -| FLOAT | [Float32](../../sql_reference/data_types/float.md) | -| DOUBLE | [Float64](../../sql_reference/data_types/float.md) | -| DATE | [Fecha](../../sql_reference/data_types/date.md) | -| DATETIME, TIMESTAMP | [FechaHora](../../sql_reference/data_types/datetime.md) | -| BINARY | [Cadena fija](../../sql_reference/data_types/fixedstring.md) | - -Todos los demás tipos de datos MySQL se convierten en [Cadena](../../sql_reference/data_types/string.md). - -[NULL](../../sql_reference/data_types/nullable.md) se admite. - -## Ejemplos de uso {#examples-of-use} - -Tabla en MySQL: - -``` text -mysql> USE test; -Database changed - -mysql> CREATE TABLE `mysql_table` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `float` FLOAT NOT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from mysql_table; -+------+-----+ -| int_id | value | -+------+-----+ -| 1 | 2 | -+------+-----+ -1 row in set (0,00 sec) -``` - -Base de datos en ClickHouse, intercambiando datos con el servidor MySQL: - -``` sql -CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') -``` - -``` sql -SHOW DATABASES -``` - -``` text -┌─name─────┐ -│ default │ -│ mysql_db │ -│ system │ -└──────────┘ -``` - -``` sql -SHOW TABLES FROM mysql_db -``` - -``` text -┌─name─────────┐ -│ mysql_table │ -└──────────────┘ -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -└────────┴───────┘ -``` - -``` sql -INSERT INTO mysql_db.mysql_table VALUES (3,4) -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -│ 3 │ 4 │ -└────────┴───────┘ -``` - -[Artículo Original](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/es/engines/index.md b/docs/es/engines/index.md index c2a7f33b49f..03e4426dd8d 100644 --- a/docs/es/engines/index.md +++ b/docs/es/engines/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Engines +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Motor toc_priority: 25 --- diff --git a/docs/es/engines/table-engines/index.md b/docs/es/engines/table-engines/index.md new file mode 100644 index 00000000000..cbc7cc5aaa8 --- /dev/null +++ b/docs/es/engines/table-engines/index.md @@ -0,0 +1,85 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Motores de mesa +toc_priority: 26 +toc_title: "Implantaci\xF3n" +--- + +# Motores de mesa {#table_engines} + +El motor de tabla (tipo de tabla) determina: + +- Cómo y dónde se almacenan los datos, dónde escribirlos y dónde leerlos. +- Qué consultas son compatibles y cómo. +- Acceso a datos simultáneos. +- Uso de índices, si está presente. +- Si es posible la ejecución de solicitudes multiproceso. +- Parámetros de replicación de datos. + +## Familias de motores {#engine-families} + +### Método de codificación de datos: {#mergetree} + +Los motores de mesa más universales y funcionales para tareas de alta carga. La propiedad compartida por estos motores es la inserción rápida de datos con el posterior procesamiento de datos en segundo plano. `MergeTree` Los motores familiares admiten la replicación de datos (con [Replicado\*](mergetree-family/replication.md#table_engines-replication) versiones de motores), particionamiento y otras características no admitidas en otros motores. + +Motores en la familia: + +- [Método de codificación de datos:](mergetree-family/mergetree.md#mergetree) +- [ReplacingMergeTree](mergetree-family/replacingmergetree.md#replacingmergetree) +- [SummingMergeTree](mergetree-family/summingmergetree.md#summingmergetree) +- [AgregaciónMergeTree](mergetree-family/aggregatingmergetree.md#aggregatingmergetree) +- [ColapsarMergeTree](mergetree-family/collapsingmergetree.md#table_engine-collapsingmergetree) +- [VersionedCollapsingMergeTree](mergetree-family/versionedcollapsingmergetree.md#versionedcollapsingmergetree) +- [GraphiteMergeTree](mergetree-family/graphitemergetree.md#graphitemergetree) + +### Registro {#log} + +Ligero [motor](log-family/index.md) con funcionalidad mínima. Son los más efectivos cuando necesita escribir rápidamente muchas tablas pequeñas (hasta aproximadamente 1 millón de filas) y leerlas más tarde como un todo. + +Motores en la familia: + +- [TinyLog](log-family/tinylog.md#tinylog) +- [StripeLog](log-family/stripelog.md#stripelog) +- [Registro](log-family/log.md#log) + +### Motores de integración {#integration-engines} + +Motores para comunicarse con otros sistemas de almacenamiento y procesamiento de datos. + +Motores en la familia: + +- [Kafka](integrations/kafka.md#kafka) +- [MySQL](integrations/mysql.md#mysql) +- [ODBC](integrations/odbc.md#table-engine-odbc) +- [JDBC](integrations/jdbc.md#table-engine-jdbc) +- [HDFS](integrations/hdfs.md#hdfs) + +### Motores especiales {#special-engines} + +Motores en la familia: + +- [Distribuido](special/distributed.md#distributed) +- [Método de codificación de datos:](special/materializedview.md#materializedview) +- [Diccionario](special/dictionary.md#dictionary) +- \[Fusión\](special/merge.md\#merge +- [File](special/file.md#file) +- [Nulo](special/null.md#null) +- [Establecer](special/set.md#set) +- [Unir](special/join.md#join) +- [URL](special/url.md#table_engines-url) +- [Vista](special/view.md#table_engines-view) +- [Memoria](special/memory.md#memory) +- [Búfer](special/buffer.md#buffer) + +## Virtual Columnas {#table_engines-virtual_columns} + +La columna virtual es un atributo de motor de tabla integral que se define en el código fuente del motor. + +No debe especificar columnas virtuales en el `CREATE TABLE` consulta y no puedes verlos en `SHOW CREATE TABLE` y `DESCRIBE TABLE` resultados de la consulta. Las columnas virtuales también son de solo lectura, por lo que no puede insertar datos en columnas virtuales. + +Para seleccionar datos de una columna virtual, debe especificar su nombre en el `SELECT` consulta. `SELECT *` no devuelve valores de columnas virtuales. + +Si crea una tabla con una columna que tiene el mismo nombre que una de las columnas virtuales de la tabla, la columna virtual se vuelve inaccesible. No recomendamos hacer esto. Para ayudar a evitar conflictos, los nombres de columna virtual suelen tener el prefijo de un guión bajo. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/es/engines/table-engines/integrations/hdfs.md b/docs/es/engines/table-engines/integrations/hdfs.md new file mode 100644 index 00000000000..500d6e91d90 --- /dev/null +++ b/docs/es/engines/table-engines/integrations/hdfs.md @@ -0,0 +1,123 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: HDFS +--- + +# HDFS {#table_engines-hdfs} + +Este motor proporciona integración con [Acerca de nosotros](https://en.wikipedia.org/wiki/Apache_Hadoop) permitiendo gestionar datos sobre [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)a través de ClickHouse. Este motor es similar +a la [File](../special/file.md#table_engines-file) y [URL](../special/url.md#table_engines-url) motores, pero proporciona características específicas de Hadoop. + +## Uso {#usage} + +``` sql +ENGINE = HDFS(URI, format) +``` + +El `URI` El parámetro es el URI del archivo completo en HDFS. +El `format` parámetro especifica uno de los formatos de archivo disponibles. Realizar +`SELECT` consultas, el formato debe ser compatible para la entrada, y para realizar +`INSERT` queries – for output. The available formats are listed in the +[Formato](../../../interfaces/formats.md#formats) apartado. +La parte de la ruta de `URI` puede contener globs. En este caso, la tabla sería de solo lectura. + +**Ejemplo:** + +**1.** Configurar el `hdfs_engine_table` tabla: + +``` sql +CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') +``` + +**2.** Llenar archivo: + +``` sql +INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) +``` + +**3.** Consultar los datos: + +``` sql +SELECT * FROM hdfs_engine_table LIMIT 2 +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Detalles de implementación {#implementation-details} + +- Las lecturas y escrituras pueden ser paralelas +- No soportado: + - `ALTER` y `SELECT...SAMPLE` operación. + - Índices. + - Replicación. + +**Globs en el camino** + +Múltiples componentes de ruta de acceso pueden tener globs. Para ser procesado, el archivo debe existir y coincidir con todo el patrón de ruta. Listado de archivos determina durante `SELECT` (no en `CREATE` momento). + +- `*` — Substitutes any number of any characters except `/` incluyendo cadena vacía. +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +Construcciones con `{}` son similares a la [remoto](../../../sql-reference/table-functions/remote.md) función de la tabla. + +**Ejemplo** + +1. Supongamos que tenemos varios archivos en formato TSV con los siguientes URI en HDFS: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. Hay varias maneras de hacer una tabla que consta de los seis archivos: + + + +``` sql +CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') +``` + +Otra forma: + +``` sql +CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') +``` + +La tabla consta de todos los archivos en ambos directorios (todos los archivos deben satisfacer el formato y el esquema descritos en la consulta): + +``` sql +CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') +``` + +!!! warning "Advertencia" + Si la lista de archivos contiene rangos de números con ceros a la izquierda, use la construcción con llaves para cada dígito por separado o use `?`. + +**Ejemplo** + +Crear tabla con archivos llamados `file000`, `file001`, … , `file999`: + +``` sql +CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') +``` + +## Virtual Columnas {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**Ver también** + +- [Virtual columnas](../index.md#table_engines-virtual_columns) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/es/engines/table-engines/integrations/index.md b/docs/es/engines/table-engines/integrations/index.md new file mode 100644 index 00000000000..e57aaf88744 --- /dev/null +++ b/docs/es/engines/table-engines/integrations/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Integraci\xF3n" +toc_priority: 30 +--- + + diff --git a/docs/es/engines/table-engines/integrations/jdbc.md b/docs/es/engines/table-engines/integrations/jdbc.md new file mode 100644 index 00000000000..fd3450cef7c --- /dev/null +++ b/docs/es/engines/table-engines/integrations/jdbc.md @@ -0,0 +1,90 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: JDBC +--- + +# JDBC {#table-engine-jdbc} + +Permite que ClickHouse se conecte a bases de datos externas a través de [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). + +Para implementar la conexión JDBC, ClickHouse utiliza el programa independiente [Sistema abierto.](https://github.com/alex-krash/clickhouse-jdbc-bridge) que debería ejecutarse como un demonio. + +Este motor soporta el [NULL](../../../sql-reference/data-types/nullable.md) tipo de datos. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name +( + columns list... +) +ENGINE = JDBC(dbms_uri, external_database, external_table) +``` + +**Parámetros del motor** + +- `dbms_uri` — URI of an external DBMS. + + Formato: `jdbc:://:/?user=&password=`. + Ejemplo para MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. + +- `external_database` — Database in an external DBMS. + +- `external_table` — Name of the table in `external_database`. + +## Ejemplo de uso {#usage-example} + +Crear una tabla en el servidor MySQL conectándose directamente con su cliente de consola: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Creación de una tabla en el servidor ClickHouse y selección de datos de ella: + +``` sql +CREATE TABLE jdbc_table +( + `int_id` Int32, + `int_nullable` Nullable(Int32), + `float` Float32, + `float_nullable` Nullable(Float32) +) +ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') +``` + +``` sql +SELECT * +FROM jdbc_table +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## Ver también {#see-also} + +- [Función de la tabla de JDBC](../../../sql-reference/table-functions/jdbc.md). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/es/engines/table-engines/integrations/kafka.md b/docs/es/engines/table-engines/integrations/kafka.md new file mode 100644 index 00000000000..508ac72b8e7 --- /dev/null +++ b/docs/es/engines/table-engines/integrations/kafka.md @@ -0,0 +1,180 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: Kafka +--- + +# Kafka {#kafka} + +Este motor funciona con [Acerca de nosotros](http://kafka.apache.org/). + +Kafka te permite: + +- Publicar o suscribirse a flujos de datos. +- Organice el almacenamiento tolerante a fallos. +- Secuencias de proceso a medida que estén disponibles. + +## Creación de una tabla {#table_engine-kafka-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = Kafka() +SETTINGS + kafka_broker_list = 'host:port', + kafka_topic_list = 'topic1,topic2,...', + kafka_group_name = 'group_name', + kafka_format = 'data_format'[,] + [kafka_row_delimiter = 'delimiter_symbol',] + [kafka_schema = '',] + [kafka_num_consumers = N,] + [kafka_max_block_size = 0,] + [kafka_skip_broken_messages = N,] + [kafka_commit_every_batch = 0] +``` + +Parámetros requeridos: + +- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). +- `kafka_topic_list` – A list of Kafka topics. +- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don't want messages to be duplicated in the cluster, use the same group name everywhere. +- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` función, tal como `JSONEachRow`. Para obtener más información, consulte [Formato](../../../interfaces/formats.md) apartado. + +Parámetros opcionales: + +- `kafka_row_delimiter` – Delimiter character, which ends the message. +- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap'n Proto](https://capnproto.org/) requiere la ruta de acceso al archivo de esquema y el nombre de la raíz `schema.capnp:Message` objeto. +- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Especifique más consumidores si el rendimiento de un consumidor es insuficiente. El número total de consumidores no debe exceder el número de particiones en el tema, ya que solo se puede asignar un consumidor por partición. +- `kafka_max_block_size` - El tamaño máximo de lote (en mensajes) para la encuesta (predeterminado: `max_block_size`). +- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. Si `kafka_skip_broken_messages = N` entonces el motor salta *N* Mensajes de Kafka que no se pueden analizar (un mensaje es igual a una fila de datos). +- `kafka_commit_every_batch` - Confirmar cada lote consumido y manejado en lugar de una única confirmación después de escribir un bloque completo (predeterminado: `0`). + +Ejemplos: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + SELECT * FROM queue LIMIT 5; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', + kafka_topic_list = 'topic', + kafka_group_name = 'group1', + kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') + SETTINGS kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; +``` + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No utilice este método en nuevos proyectos. Si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format + [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) +``` + +
+ +## Descripci {#description} + +Los mensajes entregados se realizan un seguimiento automático, por lo que cada mensaje de un grupo solo se cuenta una vez. Si desea obtener los datos dos veces, cree una copia de la tabla con otro nombre de grupo. + +Los grupos son flexibles y se sincronizan en el clúster. Por ejemplo, si tiene 10 temas y 5 copias de una tabla en un clúster, cada copia obtiene 2 temas. Si el número de copias cambia, los temas se redistribuyen automáticamente entre las copias. Lea más sobre esto en http://kafka.apache.org/intro . + +`SELECT` no es particularmente útil para leer mensajes (excepto para la depuración), ya que cada mensaje se puede leer solo una vez. Es más práctico crear subprocesos en tiempo real utilizando vistas materializadas. Para hacer esto: + +1. Use el motor para crear un consumidor de Kafka y considérelo como un flujo de datos. +2. Crea una tabla con la estructura deseada. +3. Cree una vista materializada que convierta los datos del motor y los coloque en una tabla creada previamente. + +Cuando el `MATERIALIZED VIEW` se une al motor, comienza a recopilar datos en segundo plano. Esto le permite recibir continuamente mensajes de Kafka y convertirlos al formato requerido usando `SELECT`. +Una tabla kafka puede tener tantas vistas materializadas como desee, no leen datos de la tabla kafka directamente, sino que reciben nuevos registros (en bloques), de esta manera puede escribir en varias tablas con diferentes niveles de detalle (con agrupación - agregación y sin). + +Ejemplo: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + CREATE TABLE daily ( + day Date, + level String, + total UInt64 + ) ENGINE = SummingMergeTree(day, (day, level), 8192); + + CREATE MATERIALIZED VIEW consumer TO daily + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + FROM queue GROUP BY day, level; + + SELECT level, sum(total) FROM daily GROUP BY level; +``` + +Para mejorar el rendimiento, los mensajes recibidos se agrupan en bloques del tamaño de [Max\_insert\_block\_size](../../../operations/server-configuration-parameters/settings.md#settings-max_insert_block_size). Si el bloque no se formó dentro de [Nombre de la red inalámbrica (SSID):](../../../operations/server-configuration-parameters/settings.md) milisegundos, los datos se vaciarán a la tabla independientemente de la integridad del bloque. + +Para detener la recepción de datos de tema o cambiar la lógica de conversión, desconecte la vista materializada: + +``` sql + DETACH TABLE consumer; + ATTACH TABLE consumer; +``` + +Si desea cambiar la tabla de destino utilizando `ALTER`, recomendamos deshabilitar la vista de material para evitar discrepancias entre la tabla de destino y los datos de la vista. + +## Configuración {#configuration} + +Similar a GraphiteMergeTree, el motor Kafka admite una configuración extendida utilizando el archivo de configuración ClickHouse. Hay dos claves de configuración que puede usar: global (`kafka`) y a nivel de tema (`kafka_*`). La configuración global se aplica primero y, a continuación, se aplica la configuración de nivel de tema (si existe). + +``` xml + + + cgrp + smallest + + + + + 250 + 100000 + +``` + +Para obtener una lista de posibles opciones de configuración, consulte [referencia de configuración librdkafka](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Usa el guión bajo (`_`) en lugar de un punto en la configuración de ClickHouse. Por ejemplo, `check.crcs=true` será `true`. + +## Virtual Columnas {#virtual-columns} + +- `_topic` — Kafka topic. +- `_key` — Key of the message. +- `_offset` — Offset of the message. +- `_timestamp` — Timestamp of the message. +- `_partition` — Partition of Kafka topic. + +**Ver también** + +- [Virtual columnas](../index.md#table_engines-virtual_columns) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/es/engines/table-engines/integrations/mysql.md b/docs/es/engines/table-engines/integrations/mysql.md new file mode 100644 index 00000000000..52799117255 --- /dev/null +++ b/docs/es/engines/table-engines/integrations/mysql.md @@ -0,0 +1,105 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: MySQL +--- + +# Mysql {#mysql} + +El motor MySQL le permite realizar `SELECT` consultas sobre datos almacenados en un servidor MySQL remoto. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... +) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +Vea una descripción detallada del [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) consulta. + +La estructura de la tabla puede diferir de la estructura de la tabla MySQL original: + +- Los nombres de columna deben ser los mismos que en la tabla MySQL original, pero puede usar solo algunas de estas columnas y en cualquier orden. +- Los tipos de columna pueden diferir de los de la tabla MySQL original. ClickHouse intenta [elenco](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) valores a los tipos de datos ClickHouse. + +**Parámetros del motor** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` consultas a `REPLACE INTO`. Si `replace_query=1`, la consulta se sustituye. + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expresión que se añade a la `INSERT` consulta. + + Ejemplo: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, donde `on_duplicate_clause` ser `UPDATE c2 = c2 + 1`. Ver el [Documentación de MySQL](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) para encontrar qué `on_duplicate_clause` se puede utilizar con el `ON DUPLICATE KEY` clausula. + + Especificar `on_duplicate_clause` tienes que pasar `0` a la `replace_query` parámetro. Si pasa simultáneamente `replace_query = 1` y `on_duplicate_clause`, ClickHouse genera una excepción. + +Simple `WHERE` cláusulas tales como `=, !=, >, >=, <, <=` se ejecutan en el servidor MySQL. + +El resto de las condiciones y el `LIMIT` La restricción de muestreo se ejecuta en ClickHouse solo después de que finalice la consulta a MySQL. + +## Ejemplo de uso {#usage-example} + +Tabla en MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Tabla en ClickHouse, recuperando datos de la tabla MySQL creada anteriormente: + +``` sql +CREATE TABLE mysql_table +( + `float_nullable` Nullable(Float32), + `int_id` Int32 +) +ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` sql +SELECT * FROM mysql_table +``` + +``` text +┌─float_nullable─┬─int_id─┐ +│ ᴺᵁᴸᴸ │ 1 │ +└────────────────┴────────┘ +``` + +## Ver también {#see-also} + +- [El ‘mysql’ función de la tabla](../../../sql-reference/table-functions/mysql.md) +- [Uso de MySQL como fuente de diccionario externo](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/es/engines/table-engines/integrations/odbc.md b/docs/es/engines/table-engines/integrations/odbc.md new file mode 100644 index 00000000000..75c79484d61 --- /dev/null +++ b/docs/es/engines/table-engines/integrations/odbc.md @@ -0,0 +1,132 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: ODBC +--- + +# ODBC {#table-engine-odbc} + +Permite que ClickHouse se conecte a bases de datos externas a través de [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +Para implementar con seguridad conexiones ODBC, ClickHouse usa un programa separado `clickhouse-odbc-bridge`. Si el controlador ODBC se carga directamente desde `clickhouse-server`, problemas de controlador pueden bloquear el servidor ClickHouse. ClickHouse se inicia automáticamente `clickhouse-odbc-bridge` cuando se requiere. El programa de puente ODBC se instala desde el mismo paquete que el `clickhouse-server`. + +Este motor soporta el [NULL](../../../sql-reference/data-types/nullable.md) tipo de datos. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1], + name2 [type2], + ... +) +ENGINE = ODBC(connection_settings, external_database, external_table) +``` + +Vea una descripción detallada del [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) consulta. + +La estructura de la tabla puede diferir de la estructura de la tabla de origen: + +- Los nombres de columna deben ser los mismos que en la tabla de origen, pero puede usar solo algunas de estas columnas y en cualquier orden. +- Los tipos de columna pueden diferir de los de la tabla de origen. ClickHouse intenta [elenco](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) valores a los tipos de datos ClickHouse. + +**Parámetros del motor** + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` file. +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +## Ejemplo de uso {#usage-example} + +**Recuperación de datos de la instalación local de MySQL a través de ODBC** + +Este ejemplo se comprueba para Ubuntu Linux 18.04 y el servidor MySQL 5.7. + +Asegúrese de que unixODBC y MySQL Connector están instalados. + +De forma predeterminada (si se instala desde paquetes), ClickHouse comienza como usuario `clickhouse`. Por lo tanto, debe crear y configurar este usuario en el servidor MySQL. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +A continuación, configure la conexión en `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +Puede verificar la conexión usando el `isql` utilidad desde la instalación de unixODBC. + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +Tabla en MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Tabla en ClickHouse, recuperando datos de la tabla MySQL: + +``` sql +CREATE TABLE odbc_t +( + `int_id` Int32, + `float_nullable` Nullable(Float32) +) +ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') +``` + +``` sql +SELECT * FROM odbc_t +``` + +``` text +┌─int_id─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ +└────────┴────────────────┘ +``` + +## Ver también {#see-also} + +- [Diccionarios externos ODBC](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [Tabla ODBC función](../../../sql-reference/table-functions/odbc.md) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/es/engines/table-engines/log-family/index.md b/docs/es/engines/table-engines/log-family/index.md new file mode 100644 index 00000000000..42fd671a063 --- /dev/null +++ b/docs/es/engines/table-engines/log-family/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Familia de registro +toc_priority: 29 +--- + + diff --git a/docs/es/engines/table-engines/log-family/log-family.md b/docs/es/engines/table-engines/log-family/log-family.md new file mode 100644 index 00000000000..ee264f88d79 --- /dev/null +++ b/docs/es/engines/table-engines/log-family/log-family.md @@ -0,0 +1,46 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "Implantaci\xF3n" +--- + +# Familia del motor de registro {#log-engine-family} + +Estos motores fueron desarrollados para escenarios en los que necesita escribir rápidamente muchas tablas pequeñas (hasta aproximadamente 1 millón de filas) y leerlas más tarde en su conjunto. + +Motores de la familia: + +- [StripeLog](stripelog.md) +- [Registro](log.md) +- [TinyLog](tinylog.md) + +## Propiedades comunes {#common-properties} + +Motor: + +- Almacenar datos en un disco. + +- Agregue datos al final del archivo al escribir. + +- Bloqueos de soporte para el acceso a datos simultáneos. + + Durante `INSERT` consultas, la tabla está bloqueada y otras consultas para leer y escribir datos esperan a que la tabla se desbloquee. Si no hay consultas de escritura de datos, se puede realizar cualquier número de consultas de lectura de datos simultáneamente. + +- No apoyo [mutación](../../../sql-reference/statements/alter.md#alter-mutations) operación. + +- No admite índices. + + Esto significa que `SELECT` las consultas para rangos de datos no son eficientes. + +- No escriba datos atómicamente. + + Puede obtener una tabla con datos dañados si algo rompe la operación de escritura, por ejemplo, un cierre anormal del servidor. + +## Diferencia {#differences} + +El `TinyLog` es el más simple de la familia y proporciona la funcionalidad más pobre y la eficiencia más baja. El `TinyLog` el motor no admite la lectura de datos paralelos por varios hilos. Lee datos más lentamente que otros motores de la familia que admiten lectura paralela y utiliza casi tantos descriptores como los `Log` motor porque almacena cada columna en un archivo separado. Úselo en escenarios simples de baja carga. + +El `Log` y `StripeLog` Los motores admiten lectura de datos paralela. Al leer datos, ClickHouse usa múltiples hilos. Cada subproceso procesa un bloque de datos separado. El `Log` utiliza un archivo separado para cada columna de la tabla. `StripeLog` almacena todos los datos en un archivo. Como resultado, el `StripeLog` el motor utiliza menos descriptores en el sistema operativo, pero el `Log` proporciona una mayor eficiencia al leer datos. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/es/engines/table-engines/log-family/log.md b/docs/es/engines/table-engines/log-family/log.md new file mode 100644 index 00000000000..e9ce17214eb --- /dev/null +++ b/docs/es/engines/table-engines/log-family/log.md @@ -0,0 +1,16 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: Registro +--- + +# Registro {#log} + +El motor pertenece a la familia de motores de registro. Consulte las propiedades comunes de los motores de registro y sus diferencias en [Familia del motor de registro](log-family.md) artículo. + +El registro difiere de [TinyLog](tinylog.md) en que un pequeño archivo de “marks” reside con los archivos de columna. Estas marcas se escriben en cada bloque de datos y contienen compensaciones que indican dónde comenzar a leer el archivo para omitir el número especificado de filas. Esto hace posible leer datos de tabla en múltiples hilos. +Para el acceso a datos simultáneos, las operaciones de lectura se pueden realizar simultáneamente, mientras que las operaciones de escritura bloquean las lecturas entre sí. +El motor de registro no admite índices. Del mismo modo, si la escritura en una tabla falla, la tabla se rompe y la lectura de ella devuelve un error. El motor de registro es adecuado para datos temporales, tablas de escritura única y para fines de prueba o demostración. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/es/engines/table-engines/log-family/stripelog.md b/docs/es/engines/table-engines/log-family/stripelog.md new file mode 100644 index 00000000000..59a981a2fa6 --- /dev/null +++ b/docs/es/engines/table-engines/log-family/stripelog.md @@ -0,0 +1,95 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: StripeLog +--- + +# Lista de Stripelog {#stripelog} + +Este motor pertenece a la familia de motores de registro. Consulte las propiedades comunes de los motores de registro y sus diferencias en [Familia del motor de registro](log-family.md) artículo. + +Utilice este motor en escenarios en los que necesite escribir muchas tablas con una pequeña cantidad de datos (menos de 1 millón de filas). + +## Creación de una tabla {#table_engines-stripelog-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = StripeLog +``` + +Vea la descripción detallada del [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) consulta. + +## Escribir los datos {#table_engines-stripelog-writing-the-data} + +El `StripeLog` el motor almacena todas las columnas en un archivo. Para cada `INSERT` consulta, ClickHouse agrega el bloque de datos al final de un archivo de tabla, escribiendo columnas una por una. + +Para cada tabla, ClickHouse escribe los archivos: + +- `data.bin` — Data file. +- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. + +El `StripeLog` el motor no soporta el `ALTER UPDATE` y `ALTER DELETE` operación. + +## Lectura de los datos {#table_engines-stripelog-reading-the-data} + +El archivo con marcas permite ClickHouse paralelizar la lectura de datos. Esto significa que un `SELECT` query devuelve filas en un orden impredecible. Utilice el `ORDER BY` cláusula para ordenar filas. + +## Ejemplo de uso {#table_engines-stripelog-example-of-use} + +Creación de una tabla: + +``` sql +CREATE TABLE stripe_log_table +( + timestamp DateTime, + message_type String, + message String +) +ENGINE = StripeLog +``` + +Insertar datos: + +``` sql +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') +``` + +Se utilizaron dos `INSERT` consultas para crear dos bloques de datos dentro del `data.bin` file. + +ClickHouse usa múltiples subprocesos al seleccionar datos. Cada subproceso lee un bloque de datos separado y devuelve las filas resultantes de forma independiente a medida que termina. Como resultado, el orden de los bloques de filas en la salida no coincide con el orden de los mismos bloques en la entrada en la mayoría de los casos. Por ejemplo: + +``` sql +SELECT * FROM stripe_log_table +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +┌───────────timestamp─┬─message_type─┬─message───────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +└─────────────────────┴──────────────┴───────────────────────────┘ +``` + +Ordenación de los resultados (orden ascendente por defecto): + +``` sql +SELECT * FROM stripe_log_table ORDER BY timestamp +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +``` + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/es/engines/table-engines/log-family/tinylog.md b/docs/es/engines/table-engines/log-family/tinylog.md new file mode 100644 index 00000000000..1aa392fb831 --- /dev/null +++ b/docs/es/engines/table-engines/log-family/tinylog.md @@ -0,0 +1,16 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: TinyLog +--- + +# TinyLog {#tinylog} + +El motor pertenece a la familia de motores de registro. Ver [Familia del motor de registro](log-family.md) para las propiedades comunes de los motores de registro y sus diferencias. + +Este motor de tablas se usa normalmente con el método write-once: escribir datos una vez, luego leerlos tantas veces como sea necesario. Por ejemplo, puede usar `TinyLog`-type tablas para datos intermedios que se procesan en pequeños lotes. Tenga en cuenta que el almacenamiento de datos en un gran número de tablas pequeñas es ineficiente. + +Las consultas se ejecutan en una sola secuencia. En otras palabras, este motor está diseñado para tablas relativamente pequeñas (hasta aproximadamente 1,000,000 filas). Tiene sentido usar este motor de tablas si tiene muchas tablas pequeñas, ya que es más simple que el [Registro](log.md) motor (menos archivos necesitan ser abiertos). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/es/engines/table-engines/mergetree-family/aggregatingmergetree.md b/docs/es/engines/table-engines/mergetree-family/aggregatingmergetree.md new file mode 100644 index 00000000000..2aedfbd2317 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/aggregatingmergetree.md @@ -0,0 +1,105 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: "Agregaci\xF3nMergeTree" +--- + +# Aggregatingmergetree {#aggregatingmergetree} + +El motor hereda de [Método de codificación de datos:](mergetree.md#table_engines-mergetree), alterando la lógica para la fusión de partes de datos. ClickHouse reemplaza todas las filas con la misma clave principal (o más exactamente, con la misma [clave de clasificación](mergetree.md)) con una sola fila (dentro de una parte de datos) que almacena una combinación de estados de funciones agregadas. + +Usted puede utilizar `AggregatingMergeTree` tablas para la agregación de datos incrementales, incluidas las vistas materializadas agregadas. + +El motor procesa todas las columnas con los siguientes tipos: + +- [AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) +- [SimpleAggregateFunction](../../../sql-reference/data-types/simpleaggregatefunction.md) + +Es apropiado usar `AggregatingMergeTree` si reduce el número de filas por pedidos. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = AggregatingMergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[TTL expr] +[SETTINGS name=value, ...] +``` + +Para obtener una descripción de los parámetros de solicitud, consulte [descripción de la solicitud](../../../sql-reference/statements/create.md). + +**Cláusulas de consulta** + +Al crear un `AggregatingMergeTree` mesa de la misma [clausula](mergetree.md) se requieren, como al crear un `MergeTree` tabla. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +Todos los parámetros tienen el mismo significado que en `MergeTree`. +
+ +## SELECCIONAR e INSERTAR {#select-and-insert} + +Para insertar datos, utilice [INSERT SELECT](../../../sql-reference/statements/insert-into.md) consulta con funciones agregadas -State-. +Al seleccionar datos de `AggregatingMergeTree` mesa, uso `GROUP BY` cláusula y las mismas funciones agregadas que al insertar datos, pero usando `-Merge` sufijo. + +En los resultados de `SELECT` consulta, los valores de `AggregateFunction` tipo tiene representación binaria específica de la implementación para todos los formatos de salida de ClickHouse. Si volcar datos en, por ejemplo, `TabSeparated` formato con `SELECT` consulta entonces este volcado se puede cargar de nuevo usando `INSERT` consulta. + +## Ejemplo de una vista materializada agregada {#example-of-an-aggregated-materialized-view} + +`AggregatingMergeTree` vista materializada que mira el `test.visits` tabla: + +``` sql +CREATE MATERIALIZED VIEW test.basic +ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) +AS SELECT + CounterID, + StartDate, + sumState(Sign) AS Visits, + uniqState(UserID) AS Users +FROM test.visits +GROUP BY CounterID, StartDate; +``` + +Insertar datos en el `test.visits` tabla. + +``` sql +INSERT INTO test.visits ... +``` + +Los datos se insertan tanto en la tabla como en la vista `test.basic` que realizará la agregación. + +Para obtener los datos agregados, necesitamos ejecutar una consulta como `SELECT ... GROUP BY ...` de la vista `test.basic`: + +``` sql +SELECT + StartDate, + sumMerge(Visits) AS Visits, + uniqMerge(Users) AS Users +FROM test.basic +GROUP BY StartDate +ORDER BY StartDate; +``` + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/es/engines/table-engines/mergetree-family/collapsingmergetree.md b/docs/es/engines/table-engines/mergetree-family/collapsingmergetree.md new file mode 100644 index 00000000000..027d5c2adf7 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/collapsingmergetree.md @@ -0,0 +1,306 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: ColapsarMergeTree +--- + +# ColapsarMergeTree {#table_engine-collapsingmergetree} + +El motor hereda de [Método de codificación de datos:](mergetree.md) y agrega la lógica de las filas que colapsan al algoritmo de fusión de partes de datos. + +`CollapsingMergeTree` elimina de forma asincrónica (colapsa) pares de filas si todos los campos de una clave de ordenación (`ORDER BY`) son equivalentes excepto el campo particular `Sign` que puede tener `1` y `-1` valor. Las filas sin un par se mantienen. Para más detalles, consulte el [Derrumbar](#table_engine-collapsingmergetree-collapsing) sección del documento. + +El motor puede reducir significativamente el volumen de almacenamiento y aumentar la eficiencia de `SELECT` consulta como consecuencia. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = CollapsingMergeTree(sign) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Para obtener una descripción de los parámetros de consulta, consulte [descripción de la consulta](../../../sql-reference/statements/create.md). + +**CollapsingMergeTree Parámetros** + +- `sign` — Name of the column with the type of row: `1` es una “state” fila, `-1` es una “cancel” fila. + + Column data type — `Int8`. + +**Cláusulas de consulta** + +Al crear un `CollapsingMergeTree` mesa, la misma [cláusulas de consulta](mergetree.md#table_engine-mergetree-creating-a-table) se requieren, como al crear un `MergeTree` tabla. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) +``` + +Todos los parámetros excepto `sign` el mismo significado que en `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` — “state” fila, `-1` — “cancel” fila. + + Column Data Type — `Int8`. + +
+ +## Derrumbar {#table_engine-collapsingmergetree-collapsing} + +### Datos {#data} + +Considere la situación en la que necesita guardar datos que cambian continuamente para algún objeto. Parece lógico tener una fila para un objeto y actualizarla en cualquier cambio, pero la operación de actualización es costosa y lenta para DBMS porque requiere la reescritura de los datos en el almacenamiento. Si necesita escribir datos rápidamente, la actualización no es aceptable, pero puede escribir los cambios de un objeto secuencialmente de la siguiente manera. + +Utilice la columna en particular `Sign`. Si `Sign = 1` significa que la fila es un estado de un objeto, llamémoslo “state” fila. Si `Sign = -1` significa la cancelación del estado de un objeto con los mismos atributos, llamémoslo “cancel” fila. + +Por ejemplo, queremos calcular cuántas páginas revisaron los usuarios en algún sitio y cuánto tiempo estuvieron allí. En algún momento escribimos la siguiente fila con el estado de la actividad del usuario: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +En algún momento después registramos el cambio de actividad del usuario y lo escribimos con las siguientes dos filas. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +La primera fila cancela el estado anterior del objeto (usuario). Debe copiar los campos clave de ordenación del estado cancelado exceptuando `Sign`. + +La segunda fila contiene el estado actual. + +Como solo necesitamos el último estado de actividad del usuario, las filas + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +se puede eliminar colapsando el estado no válido (antiguo) de un objeto. `CollapsingMergeTree` hace esto mientras se fusionan las partes de datos. + +Por qué necesitamos 2 filas para cada cambio leído en el [Algoritmo](#table_engine-collapsingmergetree-collapsing-algorithm) apartado. + +**Propiedades peculiares de tal enfoque** + +1. El programa que escribe los datos debe recordar el estado de un objeto para poder cancelarlo. “Cancel” debe contener copias de los campos de clave de ordenación “state” y lo opuesto `Sign`. Aumenta el tamaño inicial de almacenamiento, pero permite escribir los datos rápidamente. +2. Las matrices de largo crecimiento en columnas reducen la eficiencia del motor debido a la carga para escribir. Los datos más sencillos, mayor será la eficiencia. +3. El `SELECT` Los resultados dependen en gran medida de la consistencia del historial de cambios de objetos. Sea preciso al preparar los datos para insertarlos. Puede obtener resultados impredecibles en datos incoherentes, por ejemplo, valores negativos para métricas no negativas, como la profundidad de la sesión. + +### Algoritmo {#table_engine-collapsingmergetree-collapsing-algorithm} + +Cuando ClickHouse combina partes de datos, cada grupo de filas consecutivas tiene la misma clave de ordenación (`ORDER BY`) se reduce a no más de dos filas, una con `Sign = 1` (“state” fila) y otro con `Sign = -1` (“cancel” fila). En otras palabras, las entradas colapsan. + +Para cada parte de datos resultante, ClickHouse guarda: + +1. El primero “cancel” y el último “state” si el número de “state” y “cancel” y la última fila es una “state” fila. +2. El último “state” fila, si hay más “state” filas que “cancel” filas. +3. El primero “cancel” fila, si hay más “cancel” filas que “state” filas. +4. Ninguna de las filas, en todos los demás casos. + +También cuando hay al menos 2 más “state” filas que “cancel” filas, o al menos 2 más “cancel” filas entonces “state” fila, la fusión continúa, pero ClickHouse trata esta situación como un error lógico y la registra en el registro del servidor. Este error puede producirse si se insertan los mismos datos más de una vez. + +Por lo tanto, el colapso no debe cambiar los resultados del cálculo de las estadísticas. +Los cambios colapsaron gradualmente para que al final solo quedara el último estado de casi todos los objetos. + +El `Sign` se requiere porque el algoritmo de fusión no garantiza que todas las filas con la misma clave de clasificación estén en la misma parte de datos resultante e incluso en el mismo servidor físico. Proceso de ClickHouse `SELECT` consultas con múltiples hilos, y no puede predecir el orden de las filas en el resultado. La agregación es necesaria si hay una necesidad de obtener completamente “collapsed” datos de `CollapsingMergeTree` tabla. + +Para finalizar el colapso, escriba una consulta con `GROUP BY` cláusula y funciones agregadas que representan el signo. Por ejemplo, para calcular la cantidad, use `sum(Sign)` en lugar de `count()`. Para calcular la suma de algo, use `sum(Sign * x)` en lugar de `sum(x)` y así sucesivamente, y también añadir `HAVING sum(Sign) > 0`. + +Los agregados `count`, `sum` y `avg` podría calcularse de esta manera. El agregado `uniq` podría calcularse si un objeto tiene al menos un estado no colapsado. Los agregados `min` y `max` no se pudo calcular porque `CollapsingMergeTree` no guarda el historial de valores de los estados colapsados. + +Si necesita extraer datos sin agregación (por ejemplo, para comprobar si hay filas presentes cuyos valores más recientes coinciden con ciertas condiciones), puede utilizar el `FINAL` modificador para el `FROM` clausula. Este enfoque es significativamente menos eficiente. + +## Ejemplo de uso {#example-of-use} + +Datos de ejemplo: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Creación de la tabla: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Inserción de los datos: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) +``` + +Usamos dos `INSERT` consultas para crear dos partes de datos diferentes. Si insertamos los datos con una consulta, ClickHouse crea una parte de datos y nunca realizará ninguna fusión. + +Obtener los datos: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +¿Qué vemos y dónde está colapsando? + +Con dos `INSERT` consultas, hemos creado 2 partes de datos. El `SELECT` la consulta se realizó en 2 hilos, y obtuvimos un orden aleatorio de filas. No se ha producido un colapso porque todavía no se había fusionado las partes de datos. ClickHouse fusiona parte de datos en un momento desconocido que no podemos predecir. + +Por lo tanto, necesitamos agregación: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration +FROM UAct +GROUP BY UserID +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +Si no necesitamos agregación y queremos forzar el colapso, podemos usar `FINAL` modificador para `FROM` clausula. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Esta forma de seleccionar los datos es muy ineficiente. No lo use para mesas grandes. + +## Ejemplo de otro enfoque {#example-of-another-approach} + +Datos de ejemplo: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ -5 │ -146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +La idea es que las fusiones tengan en cuenta solo los campos clave. Y en el “Cancel” línea podemos especificar valores negativos que igualan la versión anterior de la fila al sumar sin usar la columna Sign. Para este enfoque, es necesario cambiar el tipo de datos `PageViews`,`Duration` para almacenar valores negativos de UInt8 -\> Int16. + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews Int16, + Duration Int16, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Vamos a probar el enfoque: + +``` sql +insert into UAct values(4324182021466249494, 5, 146, 1); +insert into UAct values(4324182021466249494, -5, -146, -1); +insert into UAct values(4324182021466249494, 6, 185, 1); + +select * from UAct final; // avoid using final in production (just for a test or small tables) +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +``` sql +SELECT + UserID, + sum(PageViews) AS PageViews, + sum(Duration) AS Duration +FROM UAct +GROUP BY UserID +```text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +``` sqk +select count() FROM UAct +``` + +``` text +┌─count()─┐ +│ 3 │ +└─────────┘ +``` + +``` sql +optimize table UAct final; + +select * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/es/engines/table-engines/mergetree-family/custom-partitioning-key.md b/docs/es/engines/table-engines/mergetree-family/custom-partitioning-key.md new file mode 100644 index 00000000000..49829ee864f --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/custom-partitioning-key.md @@ -0,0 +1,127 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: "Clave de partici\xF3n personalizada" +--- + +# Clave de partición personalizada {#custom-partitioning-key} + +La partición está disponible para el [Método de codificación de datos:](mergetree.md) mesas familiares (incluyendo [repetición](replication.md) tabla). [Vistas materializadas](../special/materializedview.md#materializedview) basado en tablas MergeTree soporte de particionamiento, también. + +Una partición es una combinación lógica de registros en una tabla por un criterio especificado. Puede establecer una partición por un criterio arbitrario, como por mes, por día o por tipo de evento. Cada partición se almacena por separado para simplificar las manipulaciones de estos datos. Al acceder a los datos, ClickHouse utiliza el subconjunto más pequeño de particiones posible. + +La partición se especifica en el `PARTITION BY expr` cláusula cuando [creando una tabla](mergetree.md#table_engine-mergetree-creating-a-table). La clave de partición puede ser cualquier expresión de las columnas de la tabla. Por ejemplo, para especificar la partición por mes, utilice la expresión `toYYYYMM(date_column)`: + +``` sql +CREATE TABLE visits +( + VisitDate Date, + Hour UInt8, + ClientID UUID +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(VisitDate) +ORDER BY Hour; +``` + +La clave de partición también puede ser una tupla de expresiones (similar a la [clave primaria](mergetree.md#primary-keys-and-indexes-in-queries)). Por ejemplo: + +``` sql +ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) +PARTITION BY (toMonday(StartDate), EventType) +ORDER BY (CounterID, StartDate, intHash32(UserID)); +``` + +En este ejemplo, establecemos la partición por los tipos de eventos que se produjeron durante la semana actual. + +Al insertar datos nuevos en una tabla, estos datos se almacenan como una parte separada (porción) ordenada por la clave principal. En 10-15 minutos después de insertar, las partes de la misma partición se fusionan en toda la parte. + +!!! info "INFO" + Una combinación solo funciona para partes de datos que tienen el mismo valor para la expresión de partición. Esto significa **no deberías hacer particiones demasiado granulares** (más de un millar de particiones). De lo contrario, el `SELECT` consulta funciona mal debido a un número excesivamente grande de archivos en el sistema de archivos y descriptores de archivos abiertos. + +Utilice el [sistema.parte](../../../operations/system-tables.md#system_tables-parts) tabla para ver las partes y particiones de la tabla. Por ejemplo, supongamos que tenemos un `visits` tabla con partición por mes. Vamos a realizar el `SELECT` consulta para el `system.parts` tabla: + +``` sql +SELECT + partition, + name, + active +FROM system.parts +WHERE table = 'visits' +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 1 │ +│ 201902 │ 201902_11_11_0 │ 1 │ +└───────────┴────────────────┴────────┘ +``` + +El `partition` columna contiene los nombres de las particiones. Hay dos particiones en este ejemplo: `201901` y `201902`. Puede utilizar este valor de columna para especificar el nombre de partición en [ALTER … PARTITION](#alter_manipulations-with-partitions) consulta. + +El `name` columna contiene los nombres de las partes de datos de partición. Puede utilizar esta columna para especificar el nombre de la pieza [ALTER ATTACH PART](#alter_attach-partition) consulta. + +Vamos a desglosar el nombre de la primera parte: `201901_1_3_1`: + +- `201901` es el nombre de la partición. +- `1` es el número mínimo del bloque de datos. +- `3` es el número máximo del bloque de datos. +- `1` es el nivel de fragmento (la profundidad del árbol de fusión del que se forma). + +!!! info "INFO" + Las partes de las tablas de tipo antiguo tienen el nombre: `20190117_20190123_2_2_0` (fecha mínima - fecha máxima - número de bloque mínimo - número de bloque máximo - nivel). + +El `active` columna muestra el estado de la pieza. `1` está activo; `0` está inactivo. Las partes inactivas son, por ejemplo, las partes de origen que quedan después de fusionarse con una parte más grande. Las partes de datos dañadas también se indican como inactivas. + +Como puede ver en el ejemplo, hay varias partes separadas de la misma partición (por ejemplo, `201901_1_3_1` y `201901_1_9_2`). Esto significa que estas partes aún no están fusionadas. ClickHouse combina las partes insertadas de datos periódicamente, aproximadamente 15 minutos después de la inserción. Además, puede realizar una fusión no programada utilizando el [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) consulta. Ejemplo: + +``` sql +OPTIMIZE TABLE visits PARTITION 201902; +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 0 │ +│ 201902 │ 201902_4_11_2 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 0 │ +│ 201902 │ 201902_11_11_0 │ 0 │ +└───────────┴────────────────┴────────┘ +``` + +Las partes inactivas se eliminarán aproximadamente 10 minutos después de la fusión. + +Otra forma de ver un conjunto de partes y particiones es ir al directorio de la tabla: `/var/lib/clickhouse/data//
/`. Por ejemplo: + +``` bash +/var/lib/clickhouse/data/default/visits$ ls -l +total 40 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached +``` + +Carpeta ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ y así sucesivamente son los directorios de las partes. Cada parte se relaciona con una partición correspondiente y contiene datos solo para un mes determinado (la tabla de este ejemplo tiene particiones por mes). + +El `detached` el directorio contiene partes que se separaron de la tabla utilizando el [DETACH](../../../sql-reference/statements/alter.md#alter_detach-partition) consulta. Las partes dañadas también se mueven a este directorio, en lugar de eliminarse. El servidor no utiliza las piezas del `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql-reference/statements/alter.md#alter_attach-partition) consulta. + +Tenga en cuenta que en el servidor operativo, no puede cambiar manualmente el conjunto de piezas o sus datos en el sistema de archivos, ya que el servidor no lo sabrá. Para tablas no replicadas, puede hacer esto cuando se detiene el servidor, pero no se recomienda. Para tablas replicadas, el conjunto de piezas no se puede cambiar en ningún caso. + +ClickHouse le permite realizar operaciones con las particiones: eliminarlas, copiar de una tabla a otra o crear una copia de seguridad. Consulte la lista de todas las operaciones en la sección [Manipulaciones con particiones y piezas](../../../sql-reference/statements/alter.md#alter_manipulations-with-partitions). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/es/engines/table-engines/mergetree-family/graphitemergetree.md b/docs/es/engines/table-engines/mergetree-family/graphitemergetree.md new file mode 100644 index 00000000000..66438fc4bf9 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/graphitemergetree.md @@ -0,0 +1,174 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: GraphiteMergeTree +--- + +# GraphiteMergeTree {#graphitemergetree} + +Este motor está diseñado para el adelgazamiento y la agregación / promedio (rollup) [Grafito](http://graphite.readthedocs.io/en/latest/index.html) datos. Puede ser útil para los desarrolladores que desean usar ClickHouse como almacén de datos para Graphite. + +Puede usar cualquier motor de tabla ClickHouse para almacenar los datos de Graphite si no necesita un paquete acumulativo, pero si necesita un paquete acumulativo, use `GraphiteMergeTree`. El motor reduce el volumen de almacenamiento y aumenta la eficiencia de las consultas de Graphite. + +El motor hereda propiedades de [Método de codificación de datos:](mergetree.md). + +## Creación de una tabla {#creating-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE = GraphiteMergeTree(config_section) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Vea una descripción detallada del [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) consulta. + +Una tabla para los datos de grafito debe tener las siguientes columnas para los siguientes datos: + +- Nombre métrico (sensor de grafito). Tipo de datos: `String`. + +- Tiempo de medición de la métrica. Tipo de datos: `DateTime`. + +- Valor de la métrica. Tipo de datos: cualquier numérico. + +- Versión de la métrica. Tipo de datos: cualquier numérico. + + ClickHouse guarda las filas con la versión más alta o la última escrita si las versiones son las mismas. Otras filas se eliminan durante la fusión de partes de datos. + +Los nombres de estas columnas deben establecerse en la configuración acumulativa. + +**GraphiteMergeTree parámetros** + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +**Cláusulas de consulta** + +Al crear un `GraphiteMergeTree` mesa, la misma [clausula](mergetree.md#table_engine-mergetree-creating-a-table) se requieren, como al crear un `MergeTree` tabla. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + EventDate Date, + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) +``` + +Todos los parámetros excepto `config_section` el mismo significado que en `MergeTree`. + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +
+ +## Configuración acumulativa {#rollup-configuration} + +La configuración del paquete acumulativo está definida por [graphite\_rollup](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-graphite) parámetro en la configuración del servidor. El nombre del parámetro podría ser cualquiera. Puede crear varias configuraciones y usarlas para diferentes tablas. + +Estructura de configuración Rollup: + + required-columns + patterns + +### Columnas requeridas {#required-columns} + +- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. +- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. +- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Valor predeterminado: `Value`. +- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. + +### Patrón {#patterns} + +Estructura del `patterns` apartado: + +``` text +pattern + regexp + function +pattern + regexp + age + precision + ... +pattern + regexp + function + age + precision + ... +pattern + ... +default + function + age + precision + ... +``` + +!!! warning "Atención" + Los patrones deben ser estrictamente ordenados: + + 1. Patterns without `function` or `retention`. + 1. Patterns with both `function` and `retention`. + 1. Pattern `default`. + +Al procesar una fila, ClickHouse comprueba las reglas en el `pattern` apartado. Cada uno de `pattern` (incluir `default` secciones pueden contener `function` parámetro para la agregación, `retention` parámetros o ambos. Si el nombre de la métrica coincide con `regexp`, las reglas de la `pattern` sección (o secciones); de lo contrario, las reglas de la `default` sección se utilizan. + +Campos para `pattern` y `default` apartado: + +- `regexp`– A pattern for the metric name. +- `age` – The minimum age of the data in seconds. +- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). +- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. + +### Ejemplo de configuración {#configuration-example} + +``` xml + + Version + + click_cost + any + + 0 + 5 + + + 86400 + 60 + + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/es/engines/table-engines/mergetree-family/index.md b/docs/es/engines/table-engines/mergetree-family/index.md new file mode 100644 index 00000000000..359d58b2ff1 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Familia MergeTree +toc_priority: 28 +--- + + diff --git a/docs/es/engines/table-engines/mergetree-family/mergetree.md b/docs/es/engines/table-engines/mergetree-family/mergetree.md new file mode 100644 index 00000000000..9f7dc5a63f8 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/mergetree.md @@ -0,0 +1,654 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 30 +toc_title: "M\xE9todo de codificaci\xF3n de datos:" +--- + +# Método de codificación de datos: {#table_engines-mergetree} + +El `MergeTree` motor y otros motores de esta familia (`*MergeTree`) son los motores de mesa ClickHouse más robustos. + +Motores en el `MergeTree` familia están diseñados para insertar una gran cantidad de datos en una tabla. Los datos se escriben rápidamente en la tabla parte por parte, luego se aplican reglas para fusionar las partes en segundo plano. Este método es mucho más eficiente que reescribir continuamente los datos en almacenamiento durante la inserción. + +Principales características: + +- Almacena datos ordenados por clave principal. + + Esto le permite crear un pequeño índice disperso que ayuda a encontrar datos más rápido. + +- Las particiones se pueden utilizar si [clave de partición](custom-partitioning-key.md) se especifica. + + ClickHouse admite ciertas operaciones con particiones que son más efectivas que las operaciones generales en los mismos datos con el mismo resultado. ClickHouse también corta automáticamente los datos de partición donde se especifica la clave de partición en la consulta. Esto también mejora el rendimiento de las consultas. + +- Soporte de replicación de datos. + + La familia de `ReplicatedMergeTree` proporciona la replicación de datos. Para obtener más información, consulte [Replicación de datos](replication.md). + +- Soporte de muestreo de datos. + + Si es necesario, puede establecer el método de muestreo de datos en la tabla. + +!!! info "INFO" + El [Fusionar](../special/merge.md#merge) el motor no pertenece al `*MergeTree` familia. + +## Creación de una tabla {#table_engine-mergetree-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... + INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, + INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 +) ENGINE = MergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] +[SETTINGS name=value, ...] +``` + +Para obtener una descripción de los parámetros, consulte [Descripción de la consulta CREATE](../../../sql-reference/statements/create.md). + +!!! note "Nota" + `INDEX` es una característica experimental, ver [Índices de saltos de datos](#table_engine-mergetree-data_skipping-indexes). + +### Cláusulas de consulta {#mergetree-query-clauses} + +- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. El `MergeTree` el motor no tiene parámetros. + +- `PARTITION BY` — The [clave de partición](custom-partitioning-key.md). + + Para particionar por mes, utilice el `toYYYYMM(date_column)` expresión, donde `date_column` es una columna con una fecha del tipo [Fecha](../../../sql-reference/data-types/date.md). Los nombres de partición aquí tienen el `"YYYYMM"` formato. + +- `ORDER BY` — The sorting key. + + Una tupla de columnas o expresiones arbitrarias. Ejemplo: `ORDER BY (CounterID, EventDate)`. + +- `PRIMARY KEY` — The primary key if it [difiere de la clave de clasificación](#choosing-a-primary-key-that-differs-from-the-sorting-key). + + De forma predeterminada, la clave principal es la misma que la clave de ordenación (que se especifica `ORDER BY` clausula). Por lo tanto, en la mayoría de los casos no es necesario especificar un `PRIMARY KEY` clausula. + +- `SAMPLE BY` — An expression for sampling. + + Si se utiliza una expresión de muestreo, la clave principal debe contenerla. Ejemplo: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. + +- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [entre discos y volúmenes](#table_engine-mergetree-multiple-volumes). + + La expresión debe tener una `Date` o `DateTime` columna como resultado. Ejemplo: + `TTL date + INTERVAL 1 DAY` + + Tipo de regla `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` especifica una acción que debe realizarse con la pieza si la expresión está satisfecha (alcanza la hora actual): eliminación de filas caducadas, mover una pieza (si la expresión está satisfecha para todas las filas de una pieza) al disco especificado (`TO DISK 'xxx'`) o al volumen (`TO VOLUME 'xxx'`). El tipo predeterminado de la regla es la eliminación (`DELETE`). Se puede especificar una lista de varias reglas, pero no debe haber más de una `DELETE` regla. + + Para obtener más información, consulte [TTL para columnas y tablas](#table_engine-mergetree-ttl) + +- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: + + - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Almacenamiento de datos](#mergetree-data-storage). + - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Almacenamiento de datos](#mergetree-data-storage). + - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` configuración. Antes de la versión 19.11, sólo existía el `index_granularity` ajuste para restringir el tamaño del gránulo. El `index_granularity_bytes` mejora el rendimiento de ClickHouse al seleccionar datos de tablas con filas grandes (decenas y cientos de megabytes). Si tiene tablas con filas grandes, puede habilitar esta configuración para que las tablas mejoren la eficiencia de `SELECT` consulta. + - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, entonces ZooKeeper almacena menos datos. Para obtener más información, consulte [descripción del ajuste](../../../operations/server-configuration-parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) en “Server configuration parameters”. + - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` bytes, ClickHouse lee y escribe los datos en el disco de almacenamiento utilizando la interfaz de E / S directa (`O_DIRECT` opcion). Si `min_merge_bytes_to_use_direct_io = 0`, entonces la E/S directa está deshabilitada. Valor predeterminado: `10 * 1024 * 1024 * 1024` byte. + + - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). + - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don't turn it off. + - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. + - `storage_policy` — Storage policy. See [Uso de varios dispositivos de bloque para el almacenamiento de datos](#table_engine-mergetree-multiple-volumes). + +**Ejemplo de configuración de secciones** + +``` sql +ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 +``` + +En el ejemplo, configuramos la partición por mes. + +También establecemos una expresión para el muestreo como un hash por el ID de usuario. Esto le permite pseudoaleatorizar los datos en la tabla para cada `CounterID` y `EventDate`. Si define un [SAMPLE](../../../sql-reference/statements/select/sample.md#select-sample-clause) cláusula al seleccionar los datos, ClickHouse devolverá una muestra de datos pseudoaleatoria uniforme para un subconjunto de usuarios. + +El `index_granularity` se puede omitir porque 8192 es el valor predeterminado. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No utilice este método en nuevos proyectos. Si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +**Parámetros MergeTree()** + +- `date-column` — The name of a column of the [Fecha](../../../sql-reference/data-types/date.md) tipo. ClickHouse crea automáticamente particiones por mes en función de esta columna. Los nombres de partición están en el `"YYYYMM"` formato. +- `sampling_expression` — An expression for sampling. +- `(primary, key)` — Primary key. Type: [Tupla()](../../../sql-reference/data-types/tuple.md) +- `index_granularity` — The granularity of an index. The number of data rows between the “marks” de un índice. El valor 8192 es apropiado para la mayoría de las tareas. + +**Ejemplo** + +``` sql +MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) +``` + +El `MergeTree` engine se configura de la misma manera que en el ejemplo anterior para el método de configuración del motor principal. +
+ +## Almacenamiento de datos {#mergetree-data-storage} + +Una tabla consta de partes de datos ordenadas por clave principal. + +Cuando se insertan datos en una tabla, se crean partes de datos separadas y cada una de ellas se ordena lexicográficamente por clave principal. Por ejemplo, si la clave principal es `(CounterID, Date)`, los datos en la parte se ordenan por `CounterID`, y dentro de cada `CounterID` es ordenado por `Date`. + +Los datos que pertenecen a diferentes particiones se separan en diferentes partes. En el fondo, ClickHouse combina partes de datos para un almacenamiento más eficiente. Las piezas que pertenecen a particiones diferentes no se fusionan. El mecanismo de combinación no garantiza que todas las filas con la misma clave principal estén en la misma parte de datos. + +Cada parte de datos se divide lógicamente en gránulos. Un gránulo es el conjunto de datos indivisibles más pequeño que ClickHouse lee al seleccionar datos. ClickHouse no divide filas o valores, por lo que cada gránulo siempre contiene un número entero de filas. La primera fila de un gránulo está marcada con el valor de la clave principal de la fila. Para cada parte de datos, ClickHouse crea un archivo de índice que almacena las marcas. Para cada columna, ya sea en la clave principal o no, ClickHouse también almacena las mismas marcas. Estas marcas le permiten encontrar datos directamente en archivos de columnas. + +El tamaño del gránulo es restringido por `index_granularity` y `index_granularity_bytes` configuración del motor de tabla. El número de filas en un gránulo se encuentra en el `[1, index_granularity]` rango, dependiendo del tamaño de las filas. El tamaño de un gránulo puede exceder `index_granularity_bytes` si el tamaño de una sola fila es mayor que el valor de la configuración. En este caso, el tamaño del gránulo es igual al tamaño de la fila. + +## Claves e índices principales en consultas {#primary-keys-and-indexes-in-queries} + +Tome el `(CounterID, Date)` clave primaria como ejemplo. En este caso, la clasificación y el índice se pueden ilustrar de la siguiente manera: + + Whole data: [---------------------------------------------] + CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] + Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] + Marks: | | | | | | | | | | | + a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 + Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 + +Si la consulta de datos especifica: + +- `CounterID in ('a', 'h')`, el servidor lee los datos en los rangos de marcas `[0, 3)` y `[6, 8)`. +- `CounterID IN ('a', 'h') AND Date = 3`, el servidor lee los datos en los rangos de marcas `[1, 3)` y `[7, 8)`. +- `Date = 3`, el servidor lee los datos en el rango de marcas `[1, 10]`. + +Los ejemplos anteriores muestran que siempre es más efectivo usar un índice que un análisis completo. + +Un índice disperso permite leer datos adicionales. Al leer un único rango de la clave primaria, hasta `index_granularity * 2` se pueden leer filas adicionales en cada bloque de datos. + +Los índices dispersos le permiten trabajar con una gran cantidad de filas de tabla, porque en la mayoría de los casos, dichos índices caben en la RAM de la computadora. + +ClickHouse no requiere una clave principal única. Puede insertar varias filas con la misma clave principal. + +### Selección de la clave principal {#selecting-the-primary-key} + +El número de columnas en la clave principal no está explícitamente limitado. Dependiendo de la estructura de datos, puede incluir más o menos columnas en la clave principal. Esto puede: + +- Mejorar el rendimiento de un índice. + + Si la clave principal es `(a, b)`, a continuación, añadir otra columna `c` mejorará el rendimiento si se cumplen las siguientes condiciones: + + - Hay consultas con una condición en la columna `c`. + - Rangos de datos largos (varias veces más `index_granularity`) con valores idénticos para `(a, b)` son comunes. En otras palabras, al agregar otra columna le permite omitir rangos de datos bastante largos. + +- Mejorar la compresión de datos. + + ClickHouse ordena los datos por clave principal, por lo que cuanto mayor sea la consistencia, mejor será la compresión. + +- Proporcione una lógica adicional al fusionar partes de datos en el [ColapsarMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) y [SummingMergeTree](summingmergetree.md) motor. + + En este caso tiene sentido especificar el *clave de clasificación* que es diferente de la clave principal. + +Una clave principal larga afectará negativamente al rendimiento de la inserción y al consumo de memoria, pero las columnas adicionales de la clave principal no afectarán al rendimiento de ClickHouse durante `SELECT` consulta. + +### Elegir una clave principal que difiere de la clave de ordenación {#choosing-a-primary-key-that-differs-from-the-sorting-key} + +Es posible especificar una clave principal (una expresión con valores que se escriben en el archivo de índice para cada marca) que es diferente de la clave de ordenación (una expresión para ordenar las filas en partes de datos). En este caso, la tupla de expresión de clave primaria debe ser un prefijo de la tupla de expresión de clave de ordenación. + +Esta característica es útil cuando se [SummingMergeTree](summingmergetree.md) y +[AgregaciónMergeTree](aggregatingmergetree.md) motores de mesa. En un caso común cuando se utilizan estos motores, la tabla tiene dos tipos de columnas: *cota* y *medida*. Las consultas típicas agregan valores de columnas de medida con `GROUP BY` y filtrado por dimensiones. Debido a que SummingMergeTree y AggregatingMergeTree agregan filas con el mismo valor de la clave de ordenación, es natural agregarle todas las dimensiones. Como resultado, la expresión de clave consta de una larga lista de columnas y esta lista debe actualizarse con frecuencia con las dimensiones recién agregadas. + +En este caso, tiene sentido dejar solo unas pocas columnas en la clave principal que proporcionarán análisis de rango eficientes y agregarán las columnas de dimensión restantes a la tupla de clave de clasificación. + +[ALTER](../../../sql-reference/statements/alter.md) de la clave de ordenación es una operación ligera porque cuando se agrega una nueva columna simultáneamente a la tabla y a la clave de ordenación, las partes de datos existentes no necesitan ser cambiadas. Dado que la clave de ordenación anterior es un prefijo de la nueva clave de ordenación y no hay datos en la columna recién agregada, los datos se ordenan tanto por las claves de ordenación antiguas como por las nuevas en el momento de la modificación de la tabla. + +### Uso de índices y particiones en consultas {#use-of-indexes-and-partitions-in-queries} + +Para `SELECT` consultas, ClickHouse analiza si se puede usar un índice. Se puede usar un índice si el `WHERE/PREWHERE` clause tiene una expresión (como uno de los elementos de conjunción, o enteramente) que representa una operación de comparación de igualdad o desigualdad, o si tiene `IN` o `LIKE` con un prefijo fijo en columnas o expresiones que están en la clave principal o clave de partición, o en ciertas funciones parcialmente repetitivas de estas columnas, o relaciones lógicas de estas expresiones. + +Por lo tanto, es posible ejecutar rápidamente consultas en uno o varios rangos de la clave principal. En este ejemplo, las consultas serán rápidas cuando se ejecuten para una etiqueta de seguimiento específica, para una etiqueta y un intervalo de fechas específicos, para una etiqueta y una fecha específicas, para varias etiquetas con un intervalo de fechas, etc. + +Veamos el motor configurado de la siguiente manera: + + ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 + +En este caso, en consultas: + +``` sql +SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 +SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) +SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) +``` + +ClickHouse utilizará el índice de clave principal para recortar datos incorrectos y la clave de partición mensual para recortar particiones que están en intervalos de fechas incorrectos. + +Las consultas anteriores muestran que el índice se usa incluso para expresiones complejas. La lectura de la tabla está organizada de modo que el uso del índice no puede ser más lento que un escaneo completo. + +En el siguiente ejemplo, el índice no se puede usar. + +``` sql +SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' +``` + +Para comprobar si ClickHouse puede usar el índice al ejecutar una consulta, use la configuración [Fecha de nacimiento](../../../operations/settings/settings.md#settings-force_index_by_date) y [force\_primary\_key](../../../operations/settings/settings.md). + +La clave para particionar por mes permite leer solo aquellos bloques de datos que contienen fechas del rango adecuado. En este caso, el bloque de datos puede contener datos para muchas fechas (hasta un mes). Dentro de un bloque, los datos se ordenan por clave principal, que puede no contener la fecha como la primera columna. Debido a esto, el uso de una consulta con solo una condición de fecha que no especifica el prefijo de clave principal hará que se lean más datos que para una sola fecha. + +### Uso del índice para claves primarias parcialmente monótonas {#use-of-index-for-partially-monotonic-primary-keys} + +Considere, por ejemplo, los días del mes. Ellos forman un [monótona secuencia](https://en.wikipedia.org/wiki/Monotonic_function) durante un mes, pero no monótono durante períodos más prolongados. Esta es una secuencia parcialmente monotónica. Si un usuario crea la tabla con clave primaria parcialmente monótona, ClickHouse crea un índice disperso como de costumbre. Cuando un usuario selecciona datos de este tipo de tabla, ClickHouse analiza las condiciones de consulta. Si el usuario desea obtener datos entre dos marcas del índice y ambas marcas caen dentro de un mes, ClickHouse puede usar el índice en este caso particular porque puede calcular la distancia entre los parámetros de una consulta y las marcas de índice. + +ClickHouse no puede usar un índice si los valores de la clave principal en el rango de parámetros de consulta no representan una secuencia monotónica. En este caso, ClickHouse utiliza el método de análisis completo. + +ClickHouse usa esta lógica no solo para secuencias de días del mes, sino para cualquier clave principal que represente una secuencia parcialmente monotónica. + +### Índices de saltos de datos (experimental) {#table_engine-mergetree-data_skipping-indexes} + +La declaración de índice se encuentra en la sección de columnas del `CREATE` consulta. + +``` sql +INDEX index_name expr TYPE type(...) GRANULARITY granularity_value +``` + +Para tablas de la `*MergeTree` familia, se pueden especificar índices de omisión de datos. + +Estos índices agregan cierta información sobre la expresión especificada en bloques, que consisten en `granularity_value` gránulos (el tamaño del gránulo se especifica utilizando el `index_granularity` ajuste en el motor de la tabla). Entonces estos agregados se usan en `SELECT` consultas para reducir la cantidad de datos a leer desde el disco omitiendo grandes bloques de datos donde el `where` consulta no puede ser satisfecha. + +**Ejemplo** + +``` sql +CREATE TABLE table_name +( + u64 UInt64, + i32 Int32, + s String, + ... + INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, + INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 +) ENGINE = MergeTree() +... +``` + +ClickHouse puede utilizar los índices del ejemplo para reducir la cantidad de datos que se leen desde el disco en las siguientes consultas: + +``` sql +SELECT count() FROM table WHERE s < 'z' +SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 +``` + +#### Tipos de índices disponibles {#available-types-of-indices} + +- `minmax` + + Almacena los extremos de la expresión especificada (si la expresión `tuple`, entonces almacena extremos para cada elemento de `tuple`), utiliza información almacenada para omitir bloques de datos como la clave principal. + +- `set(max_rows)` + + Almacena valores únicos de la expresión especificada (no más de `max_rows` filas, `max_rows=0` medio “no limits”). Utiliza los valores para comprobar si `WHERE` expresión no es satisfactorio en un bloque de datos. + +- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Tiendas a [Filtro de floración](https://en.wikipedia.org/wiki/Bloom_filter) que contiene todos los ngrams de un bloque de datos. Funciona solo con cadenas. Puede ser utilizado para la optimización de `equals`, `like` y `in` expresiones. + + - `n` — ngram size, + - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). + - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. + - `random_seed` — The seed for Bloom filter hash functions. + +- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Lo mismo que `ngrambf_v1`, pero almacena tokens en lugar de ngrams. Los tokens son secuencias separadas por caracteres no alfanuméricos. + +- `bloom_filter([false_positive])` — Stores a [Filtro de floración](https://en.wikipedia.org/wiki/Bloom_filter) para las columnas especificadas. + + Opcional `false_positive` parámetro es la probabilidad de recibir una respuesta falsa positiva del filtro. Valores posibles: (0, 1). Valor predeterminado: 0.025. + + Tipos de datos admitidos: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. + + Las siguientes funciones pueden usarlo: [igual](../../../sql-reference/functions/comparison-functions.md), [notEquals](../../../sql-reference/functions/comparison-functions.md), [en](../../../sql-reference/functions/in-functions.md), [noEn](../../../sql-reference/functions/in-functions.md), [tener](../../../sql-reference/functions/array-functions.md). + + + +``` sql +INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 +INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 +INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 +``` + +#### Funciones de apoyo {#functions-support} + +Condiciones en el `WHERE` cláusula contiene llamadas de las funciones que operan con columnas. Si la columna forma parte de un índice, ClickHouse intenta usar este índice al realizar las funciones. ClickHouse admite diferentes subconjuntos de funciones para usar índices. + +El `set` index se puede utilizar con todas las funciones. Subconjuntos de funciones para otros índices se muestran en la siguiente tabla. + +| Función (operador) / Índice | clave primaria | minmax | Descripción | Sistema abierto. | bloom\_filter | +|----------------------------------------------------------------------------------------------------------|----------------|--------|-------------|------------------|---------------| +| [igual (=, ==)](../../../sql-reference/functions/comparison-functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notEquals(!=, \<\>)](../../../sql-reference/functions/comparison-functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [como](../../../sql-reference/functions/string-search-functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [No como](../../../sql-reference/functions/string-search-functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [Comienza con](../../../sql-reference/functions/string-functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | +| [Finaliza con](../../../sql-reference/functions/string-functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | +| [multiSearchAny](../../../sql-reference/functions/string-search-functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | +| [en](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [noEn](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [menos (\<)](../../../sql-reference/functions/comparison-functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [mayor (\>)](../../../sql-reference/functions/comparison-functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [menosOrEquals (\<=)](../../../sql-reference/functions/comparison-functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [mayorOrEquals (\>=)](../../../sql-reference/functions/comparison-functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [vaciar](../../../sql-reference/functions/array-functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [notEmpty](../../../sql-reference/functions/array-functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | + +Las funciones con un argumento constante que es menor que el tamaño de ngram no pueden ser utilizadas por `ngrambf_v1` para la optimización de consultas. + +Los filtros Bloom pueden tener coincidencias falsas positivas, por lo que `ngrambf_v1`, `tokenbf_v1`, y `bloom_filter` los índices no se pueden usar para optimizar consultas donde se espera que el resultado de una función sea falso, por ejemplo: + +- Puede ser optimizado: + - `s LIKE '%test%'` + - `NOT s NOT LIKE '%test%'` + - `s = 1` + - `NOT s != 1` + - `startsWith(s, 'test')` +- No se puede optimizar: + - `NOT s LIKE '%test%'` + - `s NOT LIKE '%test%'` + - `NOT s = 1` + - `s != 1` + - `NOT startsWith(s, 'test')` + +## Acceso a datos simultáneos {#concurrent-data-access} + +Para el acceso simultáneo a tablas, usamos versiones múltiples. En otras palabras, cuando una tabla se lee y actualiza simultáneamente, los datos se leen de un conjunto de partes que está actualizado en el momento de la consulta. No hay cerraduras largas. Las inserciones no se interponen en el camino de las operaciones de lectura. + +La lectura de una tabla se paralela automáticamente. + +## TTL para columnas y tablas {#table_engine-mergetree-ttl} + +Determina la duración de los valores. + +El `TTL` se puede establecer para toda la tabla y para cada columna individual. TTL de nivel de tabla también puede especificar la lógica de movimiento automático de datos entre discos y volúmenes. + +Las expresiones deben evaluar [Fecha](../../../sql-reference/data-types/date.md) o [FechaHora](../../../sql-reference/data-types/datetime.md) tipo de datos. + +Ejemplo: + +``` sql +TTL time_column +TTL time_column + interval +``` + +Definir `interval`, utilizar [intervalo de tiempo](../../../sql-reference/operators/index.md#operators-datetime) operador. + +``` sql +TTL date_time + INTERVAL 1 MONTH +TTL date_time + INTERVAL 15 HOUR +``` + +### Columna TTL {#mergetree-column-ttl} + +Cuando los valores de la columna caducan, ClickHouse los reemplaza con los valores predeterminados para el tipo de datos de columna. Si todos los valores de columna en la parte de datos caducan, ClickHouse elimina esta columna de la parte de datos en un sistema de archivos. + +El `TTL` cláusula no se puede utilizar para columnas clave. + +Ejemplos: + +Creación de una tabla con TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int TTL d + INTERVAL 1 MONTH, + b Int TTL d + INTERVAL 1 MONTH, + c String +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d; +``` + +Adición de TTL a una columna de una tabla existente + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 DAY; +``` + +Modificación de TTL de la columna + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 MONTH; +``` + +### Tabla TTL {#mergetree-table-ttl} + +La tabla puede tener una expresión para la eliminación de filas caducadas y varias expresiones para el movimiento automático de partes entre [discos o volúmenes](#table_engine-mergetree-multiple-volumes). Cuando las filas de la tabla caducan, ClickHouse elimina todas las filas correspondientes. Para la entidad de movimiento de piezas, todas las filas de una pieza deben cumplir los criterios de expresión de movimiento. + +``` sql +TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... +``` + +El tipo de regla TTL puede seguir cada expresión TTL. Afecta a una acción que debe realizarse una vez que se satisface la expresión (alcanza la hora actual): + +- `DELETE` - Eliminar filas caducadas (acción predeterminada); +- `TO DISK 'aaa'` - mover parte al disco `aaa`; +- `TO VOLUME 'bbb'` - mover parte al disco `bbb`. + +Ejemplos: + +Creación de una tabla con TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d +TTL d + INTERVAL 1 MONTH [DELETE], + d + INTERVAL 1 WEEK TO VOLUME 'aaa', + d + INTERVAL 2 WEEK TO DISK 'bbb'; +``` + +Modificación de TTL de la tabla + +``` sql +ALTER TABLE example_table + MODIFY TTL d + INTERVAL 1 DAY; +``` + +**Eliminación de datos** + +Los datos con un TTL caducado se eliminan cuando ClickHouse fusiona partes de datos. + +Cuando ClickHouse ve que los datos han caducado, realiza una combinación fuera de programación. Para controlar la frecuencia de tales fusiones, puede establecer `merge_with_ttl_timeout`. Si el valor es demasiado bajo, realizará muchas fusiones fuera de horario que pueden consumir muchos recursos. + +Si realiza el `SELECT` consulta entre fusiones, puede obtener datos caducados. Para evitarlo, use el [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) consulta antes `SELECT`. + +## Uso de varios dispositivos de bloque para el almacenamiento de datos {#table_engine-mergetree-multiple-volumes} + +### Implantación {#introduction} + +`MergeTree` Los motores de tablas familiares pueden almacenar datos en múltiples dispositivos de bloque. Por ejemplo, puede ser útil cuando los datos de una determinada tabla se dividen implícitamente en “hot” y “cold”. Los datos más recientes se solicitan regularmente, pero solo requieren una pequeña cantidad de espacio. Por el contrario, los datos históricos de cola gorda se solicitan raramente. Si hay varios discos disponibles, el “hot” los datos pueden estar ubicados en discos rápidos (por ejemplo, SSD NVMe o en memoria), mientras que “cold” datos - en los relativamente lentos (por ejemplo, HDD). + +La parte de datos es la unidad móvil mínima para `MergeTree`-mesas de motor. Los datos que pertenecen a una parte se almacenan en un disco. Las partes de datos se pueden mover entre discos en segundo plano (según la configuración del usuario) así como por medio de la [ALTER](../../../sql-reference/statements/alter.md#alter_move-partition) consulta. + +### Plazo {#terms} + +- Disk — Block device mounted to the filesystem. +- Default disk — Disk that stores the path specified in the [camino](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path) configuración del servidor. +- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). +- Storage policy — Set of volumes and the rules for moving data between them. + +Los nombres dados a las entidades descritas se pueden encontrar en las tablas del sistema, [sistema.almacenamiento\_policies](../../../operations/system-tables.md#system_tables-storage_policies) y [sistema.disco](../../../operations/system-tables.md#system_tables-disks). Para aplicar una de las directivas de almacenamiento configuradas para una tabla, `storage_policy` establecimiento de `MergeTree`-mesas de la familia del motor. + +### Configuración {#table_engine-mergetree-multiple-volumes_configure} + +Los discos, los volúmenes y las políticas de almacenamiento deben declararse `` etiqueta ya sea en el archivo principal `config.xml` o en un archivo distinto en el `config.d` directorio. + +Estructura de configuración: + +``` xml + + + + /mnt/fast_ssd/clickhouse/ + + + /mnt/hdd1/clickhouse/ + 10485760 + + + /mnt/hdd2/clickhouse/ + 10485760 + + + ... + + + ... + +``` + +Tags: + +- `` — Disk name. Names must be different for all disks. +- `path` — path under which a server will store data (`data` y `shadow` carpetas), debe terminarse con ‘/’. +- `keep_free_space_bytes` — the amount of free disk space to be reserved. + +El orden de la definición del disco no es importante. + +Marcado de configuración de directivas de almacenamiento: + +``` xml + + ... + + + + + disk_name_from_disks_configuration + 1073741824 + + + + + + + 0.2 + + + + + + + + ... + +``` + +Tags: + +- `policy_name_N` — Policy name. Policy names must be unique. +- `volume_name_N` — Volume name. Volume names must be unique. +- `disk` — a disk within a volume. +- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume's disks. +- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). + +Cofiguration ejemplos: + +``` xml + + ... + + + + + disk1 + disk2 + + + + + + + + fast_ssd + 1073741824 + + + disk1 + + + 0.2 + + + ... + +``` + +En un ejemplo dado, el `hdd_in_order` la política implementa el [Ronda-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) enfoque. Por lo tanto, esta política define solo un volumen (`single`), las partes de datos se almacenan en todos sus discos en orden circular. Dicha política puede ser bastante útil si hay varios discos similares montados en el sistema, pero RAID no está configurado. Tenga en cuenta que cada unidad de disco individual no es confiable y es posible que desee compensarlo con un factor de replicación de 3 o más. + +Si hay diferentes tipos de discos disponibles en el sistema, `moving_from_ssd_to_hdd` política se puede utilizar en su lugar. Volumen `hot` consta de un disco SSD (`fast_ssd`), y el tamaño máximo de una pieza que se puede almacenar en este volumen es de 1 GB. Todas las piezas con el tamaño más grande que 1GB serán almacenadas directamente en `cold` volumen, que contiene un disco duro `disk1`. +Además, una vez que el disco `fast_ssd` se llena en más del 80%, los datos se transferirán al `disk1` por un proceso en segundo plano. + +El orden de enumeración de volúmenes dentro de una directiva de almacenamiento es importante. Una vez que un volumen está sobrellenado, los datos se mueven al siguiente. El orden de la enumeración del disco también es importante porque los datos se almacenan en ellos por turnos. + +Al crear una tabla, se puede aplicarle una de las directivas de almacenamiento configuradas: + +``` sql +CREATE TABLE table_with_non_default_policy ( + EventDate Date, + OrderID UInt64, + BannerID UInt64, + SearchPhrase String +) ENGINE = MergeTree +ORDER BY (OrderID, BannerID) +PARTITION BY toYYYYMM(EventDate) +SETTINGS storage_policy = 'moving_from_ssd_to_hdd' +``` + +El `default` política de almacenamiento implica el uso de un solo volumen, que consiste en un solo disco dado en ``. Una vez que se crea una tabla, no se puede cambiar su política de almacenamiento. + +### Detalles {#details} + +En el caso de `MergeTree` tablas, los datos están llegando al disco de diferentes maneras: + +- Como resultado de un inserto (`INSERT` consulta). +- Durante las fusiones de fondo y [mutación](../../../sql-reference/statements/alter.md#alter-mutations). +- Al descargar desde otra réplica. +- Como resultado de la congelación de particiones [ALTER TABLE … FREEZE PARTITION](../../../sql-reference/statements/alter.md#alter_freeze-partition). + +En todos estos casos, excepto las mutaciones y la congelación de particiones, una pieza se almacena en un volumen y un disco de acuerdo con la política de almacenamiento dada: + +1. El primer volumen (en el orden de definición) que tiene suficiente espacio en disco para almacenar una pieza (`unreserved_space > current_part_size`) y permite almacenar partes de un tamaño determinado (`max_data_part_size_bytes > current_part_size`) se elige. +2. Dentro de este volumen, se elige ese disco que sigue al que se utilizó para almacenar el fragmento de datos anterior y que tiene espacio libre más que el tamaño de la pieza (`unreserved_space - keep_free_space_bytes > current_part_size`). + +Bajo el capó, las mutaciones y la congelación de particiones hacen uso de [enlaces duros](https://en.wikipedia.org/wiki/Hard_link). Los enlaces duros entre diferentes discos no son compatibles, por lo tanto, en tales casos las partes resultantes se almacenan en los mismos discos que los iniciales. + +En el fondo, las partes se mueven entre volúmenes en función de la cantidad de espacio libre (`move_factor` parámetro) según el orden en que se declaran los volúmenes en el archivo de configuración. +Los datos nunca se transfieren desde el último y al primero. Uno puede usar tablas del sistema [sistema.part\_log](../../../operations/system-tables.md#system_tables-part-log) (campo `type = MOVE_PART`) y [sistema.parte](../../../operations/system-tables.md#system_tables-parts) (campo `path` y `disk`) para monitorear movimientos de fondo. Además, la información detallada se puede encontrar en los registros del servidor. + +El usuario puede forzar el movimiento de una pieza o una partición de un volumen a otro mediante la consulta [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql-reference/statements/alter.md#alter_move-partition), todas las restricciones para las operaciones en segundo plano se tienen en cuenta. La consulta inicia un movimiento por sí misma y no espera a que se completen las operaciones en segundo plano. El usuario recibirá un mensaje de error si no hay suficiente espacio libre disponible o si no se cumple alguna de las condiciones requeridas. + +Mover datos no interfiere con la replicación de datos. Por lo tanto, se pueden especificar diferentes directivas de almacenamiento para la misma tabla en diferentes réplicas. + +Después de la finalización de las fusiones y mutaciones de fondo, las partes viejas se eliminan solo después de un cierto período de tiempo (`old_parts_lifetime`). +Durante este tiempo, no se mueven a otros volúmenes o discos. Por lo tanto, hasta que las partes finalmente se eliminen, aún se tienen en cuenta para la evaluación del espacio en disco ocupado. + +[Artículo Original](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/es/engines/table-engines/mergetree-family/replacingmergetree.md b/docs/es/engines/table-engines/mergetree-family/replacingmergetree.md new file mode 100644 index 00000000000..a1e95c5b5f4 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/replacingmergetree.md @@ -0,0 +1,69 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: ReplacingMergeTree +--- + +# ReplacingMergeTree {#replacingmergetree} + +El motor difiere de [Método de codificación de datos:](mergetree.md#table_engines-mergetree) en que elimina las entradas duplicadas con el mismo valor de clave principal (o más exactamente, con el mismo [clave de clasificación](mergetree.md) valor). + +La desduplicación de datos solo se produce durante una fusión. La fusión ocurre en segundo plano en un momento desconocido, por lo que no puede planificarla. Algunos de los datos pueden permanecer sin procesar. Aunque puede ejecutar una fusión no programada utilizando el `OPTIMIZE` consulta, no cuente con usarlo, porque el `OPTIMIZE` consulta leerá y escribirá una gran cantidad de datos. + +Así, `ReplacingMergeTree` es adecuado para borrar datos duplicados en segundo plano para ahorrar espacio, pero no garantiza la ausencia de duplicados. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = ReplacingMergeTree([ver]) +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Para obtener una descripción de los parámetros de solicitud, consulte [descripción de la solicitud](../../../sql-reference/statements/create.md). + +**ReplacingMergeTree Parámetros** + +- `ver` — column with version. Type `UInt*`, `Date` o `DateTime`. Parámetro opcional. + + Al fusionar, `ReplacingMergeTree` de todas las filas con la misma clave primaria deja solo una: + + - Último en la selección, si `ver` no establecido. + - Con la versión máxima, si `ver` indicado. + +**Cláusulas de consulta** + +Al crear un `ReplacingMergeTree` mesa de la misma [clausula](mergetree.md) se requieren, como al crear un `MergeTree` tabla. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) +``` + +Todos los parámetros excepto `ver` el mismo significado que en `MergeTree`. + +- `ver` - columna con la versión. Parámetro opcional. Para una descripción, vea el texto anterior. + +
+ +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/es/engines/table-engines/mergetree-family/replication.md b/docs/es/engines/table-engines/mergetree-family/replication.md new file mode 100644 index 00000000000..52b4029fd82 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/replication.md @@ -0,0 +1,218 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "Replicaci\xF3n de datos" +--- + +# Replicación de datos {#table_engines-replication} + +La replicación solo se admite para tablas de la familia MergeTree: + +- ReplicatedMergeTree +- ReplicatedSummingMergeTree +- ReplicatedReplacingMergeTree +- ReplicatedAggregatingMergeTree +- ReplicatedCollapsingMergeTree +- ReplicatedVersionedCollapsingMergetree +- ReplicatedGraphiteMergeTree + +La replicación funciona a nivel de una tabla individual, no de todo el servidor. Un servidor puede almacenar tablas replicadas y no replicadas al mismo tiempo. + +La replicación no depende de la fragmentación. Cada fragmento tiene su propia replicación independiente. + +Datos comprimidos para `INSERT` y `ALTER` se replica (para obtener más información, consulte la documentación para [ALTER](../../../sql-reference/statements/alter.md#query_language_queries_alter)). + +`CREATE`, `DROP`, `ATTACH`, `DETACH` y `RENAME` las consultas se ejecutan en un único servidor y no se replican: + +- El `CREATE TABLE` query crea una nueva tabla replicable en el servidor donde se ejecuta la consulta. Si esta tabla ya existe en otros servidores, agrega una nueva réplica. +- El `DROP TABLE` query elimina la réplica ubicada en el servidor donde se ejecuta la consulta. +- El `RENAME` query cambia el nombre de la tabla en una de las réplicas. En otras palabras, las tablas replicadas pueden tener diferentes nombres en diferentes réplicas. + +Uso de ClickHouse [Apache ZooKeeper](https://zookeeper.apache.org) para almacenar metainformación de réplicas. Utilice ZooKeeper versión 3.4.5 o posterior. + +Para utilizar la replicación, establezca los parámetros [Zookeeper](../../../operations/server-configuration-parameters/settings.md#server-settings_zookeeper) sección de configuración del servidor. + +!!! attention "Atención" + No descuides la configuración de seguridad. ClickHouse soporta el `digest` [Esquema de ACL](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) del subsistema de seguridad ZooKeeper. + +Ejemplo de configuración de las direcciones del clúster ZooKeeper: + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + + example3 + 2181 + + +``` + +Puede especificar cualquier clúster ZooKeeper existente y el sistema utilizará un directorio en él para sus propios datos (el directorio se especifica al crear una tabla replicable). + +Si ZooKeeper no está establecido en el archivo de configuración, no puede crear tablas replicadas y las tablas replicadas existentes serán de solo lectura. + +ZooKeeper no se utiliza en `SELECT` consultas porque la replicación no afecta al rendimiento de `SELECT` y las consultas se ejecutan tan rápido como lo hacen para las tablas no replicadas. Al consultar tablas replicadas distribuidas, el comportamiento de ClickHouse se controla mediante la configuración [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) y [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). + +Para cada `INSERT` consulta, aproximadamente diez entradas se agregan a ZooKeeper a través de varias transacciones. (Para ser más precisos, esto es para cada bloque de datos insertado; una consulta INSERT contiene un bloque o un bloque por `max_insert_block_size = 1048576` filas.) Esto conduce a latencias ligeramente más largas para `INSERT` en comparación con las tablas no replicadas. Pero si sigue las recomendaciones para insertar datos en lotes de no más de uno `INSERT` por segundo, no crea ningún problema. Todo el clúster ClickHouse utilizado para coordinar un clúster ZooKeeper tiene un total de varios cientos `INSERTs` por segundo. El rendimiento en las inserciones de datos (el número de filas por segundo) es tan alto como para los datos no replicados. + +Para clústeres muy grandes, puede usar diferentes clústeres de ZooKeeper para diferentes fragmentos. Sin embargo, esto no ha demostrado ser necesario en el Yandex.Clúster Metrica (aproximadamente 300 servidores). + +La replicación es asíncrona y multi-master. `INSERT` consultas (así como `ALTER`) se puede enviar a cualquier servidor disponible. Los datos se insertan en el servidor donde se ejecuta la consulta y, a continuación, se copian a los demás servidores. Debido a que es asincrónico, los datos insertados recientemente aparecen en las otras réplicas con cierta latencia. Si parte de las réplicas no está disponible, los datos se escriben cuando estén disponibles. Si hay una réplica disponible, la latencia es la cantidad de tiempo que tarda en transferir el bloque de datos comprimidos a través de la red. + +De forma predeterminada, una consulta INSERT espera la confirmación de la escritura de los datos de una sola réplica. Si los datos fue correctamente escrito a sólo una réplica y el servidor con esta réplica deja de existir, los datos almacenados se perderán. Para habilitar la confirmación de las escrituras de datos de varias réplicas, utilice `insert_quorum` opcion. + +Cada bloque de datos se escribe atómicamente. La consulta INSERT se divide en bloques hasta `max_insert_block_size = 1048576` filas. En otras palabras, si el `INSERT` consulta tiene menos de 1048576 filas, se hace atómicamente. + +Los bloques de datos se deduplican. Para varias escrituras del mismo bloque de datos (bloques de datos del mismo tamaño que contienen las mismas filas en el mismo orden), el bloque solo se escribe una vez. La razón de esto es en caso de fallas de red cuando la aplicación cliente no sabe si los datos se escribieron en la base de datos, por lo que `INSERT` consulta simplemente se puede repetir. No importa a qué réplica se enviaron los INSERT con datos idénticos. `INSERTs` son idempotentes. Los parámetros de desduplicación son controlados por [merge\_tree](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree) configuración del servidor. + +Durante la replicación, sólo los datos de origen que se van a insertar se transfieren a través de la red. La transformación de datos adicional (fusión) se coordina y se realiza en todas las réplicas de la misma manera. Esto minimiza el uso de la red, lo que significa que la replicación funciona bien cuando las réplicas residen en centros de datos diferentes. (Tenga en cuenta que la duplicación de datos en diferentes centros de datos es el objetivo principal de la replicación.) + +Puede tener cualquier número de réplicas de los mismos datos. El Yandex.Metrica utiliza doble replicación en producción. Cada servidor utiliza RAID-5 o RAID-6, y RAID-10 en algunos casos. Esta es una solución relativamente confiable y conveniente. + +El sistema supervisa la sincronicidad de los datos en las réplicas y puede recuperarse después de un fallo. La conmutación por error es automática (para pequeñas diferencias en los datos) o semiautomática (cuando los datos difieren demasiado, lo que puede indicar un error de configuración). + +## Creación de tablas replicadas {#creating-replicated-tables} + +El `Replicated` prefijo se agrega al nombre del motor de tabla. Por ejemplo:`ReplicatedMergeTree`. + +**Replicated\*MergeTree parámetros** + +- `zoo_path` — The path to the table in ZooKeeper. +- `replica_name` — The replica name in ZooKeeper. + +Ejemplo: + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +``` + +
+ +Ejemplo en sintaxis obsoleta + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) +``` + +
+ +Como muestra el ejemplo, estos parámetros pueden contener sustituciones entre llaves. Los valores sustituidos se toman de la ‘macros’ sección del archivo de configuración. Ejemplo: + +``` xml + + 05 + 02 + example05-02-1.yandex.ru + +``` + +La ruta de acceso a la tabla en ZooKeeper debe ser única para cada tabla replicada. Las tablas en diferentes fragmentos deben tener rutas diferentes. +En este caso, la ruta consta de las siguientes partes: + +`/clickhouse/tables/` es el prefijo común. Recomendamos usar exactamente este. + +`{layer}-{shard}` es el identificador de fragmento. En este ejemplo consta de dos partes, ya que el Yandex.Metrica clúster utiliza sharding de dos niveles. Para la mayoría de las tareas, puede dejar solo la sustitución {shard}, que se expandirá al identificador de fragmento. + +`table_name` es el nombre del nodo de la tabla en ZooKeeper. Es una buena idea hacerlo igual que el nombre de la tabla. Se define explícitamente, porque a diferencia del nombre de la tabla, no cambia después de una consulta RENAME. +*HINT*: podría agregar un nombre de base de datos delante de `table_name` También. Nivel de Cifrado WEP `db_name.table_name` + +El nombre de réplica identifica diferentes réplicas de la misma tabla. Puede usar el nombre del servidor para esto, como en el ejemplo. El nombre solo tiene que ser único dentro de cada fragmento. + +Puede definir los parámetros explícitamente en lugar de utilizar sustituciones. Esto podría ser conveniente para probar y para configurar clústeres pequeños. Sin embargo, no puede usar consultas DDL distribuidas (`ON CLUSTER` en este caso. + +Cuando se trabaja con clústeres grandes, se recomienda utilizar sustituciones porque reducen la probabilidad de error. + +Ejecute el `CREATE TABLE` consulta en cada réplica. Esta consulta crea una nueva tabla replicada o agrega una nueva réplica a una existente. + +Si agrega una nueva réplica después de que la tabla ya contenga algunos datos en otras réplicas, los datos se copiarán de las otras réplicas a la nueva después de ejecutar la consulta. En otras palabras, la nueva réplica se sincroniza con las demás. + +Para eliminar una réplica, ejecute `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. + +## Recuperación después de fallos {#recovery-after-failures} + +Si ZooKeeper no está disponible cuando se inicia un servidor, las tablas replicadas cambian al modo de solo lectura. El sistema intenta conectarse periódicamente a ZooKeeper. + +Si ZooKeeper no está disponible durante un `INSERT`, o se produce un error al interactuar con ZooKeeper, se produce una excepción. + +Después de conectarse a ZooKeeper, el sistema comprueba si el conjunto de datos en el sistema de archivos local coincide con el conjunto de datos esperado (ZooKeeper almacena esta información). Si hay incoherencias menores, el sistema las resuelve sincronizando datos con las réplicas. + +Si el sistema detecta partes de datos rotas (con un tamaño incorrecto de archivos) o partes no reconocidas (partes escritas en el sistema de archivos pero no grabadas en ZooKeeper), las mueve al `detached` subdirectorio (no se eliminan). Las piezas que faltan se copian de las réplicas. + +Tenga en cuenta que ClickHouse no realiza ninguna acción destructiva, como eliminar automáticamente una gran cantidad de datos. + +Cuando el servidor se inicia (o establece una nueva sesión con ZooKeeper), solo verifica la cantidad y el tamaño de todos los archivos. Si los tamaños de los archivos coinciden pero los bytes se han cambiado en algún punto intermedio, esto no se detecta inmediatamente, sino solo cuando se intenta leer los datos `SELECT` consulta. La consulta produce una excepción sobre una suma de comprobación no coincidente o el tamaño de un bloque comprimido. En este caso, las partes de datos se agregan a la cola de verificación y se copian de las réplicas si es necesario. + +Si el conjunto local de datos difiere demasiado del esperado, se activa un mecanismo de seguridad. El servidor ingresa esto en el registro y se niega a iniciarse. La razón de esto es que este caso puede indicar un error de configuración, como si una réplica en un fragmento se configurara accidentalmente como una réplica en un fragmento diferente. Sin embargo, los umbrales para este mecanismo se establecen bastante bajos, y esta situación puede ocurrir durante la recuperación de falla normal. En este caso, los datos se restauran semiautomáticamente, mediante “pushing a button”. + +Para iniciar la recuperación, cree el nodo `/path_to_table/replica_name/flags/force_restore_data` en ZooKeeper con cualquier contenido, o ejecute el comando para restaurar todas las tablas replicadas: + +``` bash +sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data +``` + +A continuación, reinicie el servidor. Al iniciar, el servidor elimina estos indicadores e inicia la recuperación. + +## Recuperación después de la pérdida completa de datos {#recovery-after-complete-data-loss} + +Si todos los datos y metadatos desaparecieron de uno de los servidores, siga estos pasos para la recuperación: + +1. Instale ClickHouse en el servidor. Defina correctamente las sustituciones en el archivo de configuración que contiene el identificador de fragmento y las réplicas, si las usa. +2. Si tenía tablas no duplicadas que deben duplicarse manualmente en los servidores, copie sus datos desde una réplica (en el directorio `/var/lib/clickhouse/data/db_name/table_name/`). +3. Copiar definiciones de tablas ubicadas en `/var/lib/clickhouse/metadata/` de una réplica. Si un identificador de fragmento o réplica se define explícitamente en las definiciones de tabla, corríjalo para que corresponda a esta réplica. (Como alternativa, inicie el servidor y `ATTACH TABLE` consultas que deberían haber estado en el .sql archivos en `/var/lib/clickhouse/metadata/`.) +4. Para iniciar la recuperación, cree el nodo ZooKeeper `/path_to_table/replica_name/flags/force_restore_data` con cualquier contenido o ejecute el comando para restaurar todas las tablas replicadas: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` + +Luego inicie el servidor (reinicie, si ya se está ejecutando). Los datos se descargarán de las réplicas. + +Una opción de recuperación alternativa es eliminar información sobre la réplica perdida de ZooKeeper (`/path_to_table/replica_name`), luego vuelva a crear la réplica como se describe en “[Creación de tablas replicadas](#creating-replicated-tables)”. + +No hay restricción en el ancho de banda de la red durante la recuperación. Tenga esto en cuenta si está restaurando muchas réplicas a la vez. + +## La conversión de MergeTree a ReplicatedMergeTree {#converting-from-mergetree-to-replicatedmergetree} + +Usamos el término `MergeTree` para referirse a todos los motores de mesa en el `MergeTree family`, lo mismo que para `ReplicatedMergeTree`. + +Si usted tenía un `MergeTree` tabla replicada manualmente, puede convertirla en una tabla replicada. Es posible que tenga que hacer esto si ya ha recopilado una gran cantidad de datos `MergeTree` y ahora desea habilitar la replicación. + +Si los datos difieren en varias réplicas, primero sincronícelos o elimínelos en todas las réplicas, excepto en una. + +Cambie el nombre de la tabla MergeTree existente y, a continuación, cree un `ReplicatedMergeTree` mesa con el antiguo nombre. +Mueva los datos de la tabla antigua a la `detached` subdirectorio dentro del directorio con los nuevos datos de la tabla (`/var/lib/clickhouse/data/db_name/table_name/`). +Luego ejecuta `ALTER TABLE ATTACH PARTITION` en una de las réplicas para agregar estas partes de datos al conjunto de trabajo. + +## La conversión de ReplicatedMergeTree a MergeTree {#converting-from-replicatedmergetree-to-mergetree} + +Cree una tabla MergeTree con un nombre diferente. Mueva todos los datos del directorio con el `ReplicatedMergeTree` datos de la tabla al directorio de datos de la nueva tabla. A continuación, elimine el `ReplicatedMergeTree` y reinicie el servidor. + +Si desea deshacerse de un `ReplicatedMergeTree` sin iniciar el servidor: + +- Eliminar el correspondiente `.sql` archivo en el directorio de metadatos (`/var/lib/clickhouse/metadata/`). +- Eliminar la ruta correspondiente en ZooKeeper (`/path_to_table/replica_name`). + +Después de esto, puede iniciar el servidor, crear un `MergeTree` tabla, mueva los datos a su directorio y, a continuación, reinicie el servidor. + +## Recuperación cuando se pierden o se dañan los metadatos del clúster Zookeeper {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} + +Si los datos de ZooKeeper se perdieron o se dañaron, puede guardar los datos moviéndolos a una tabla no duplicada como se describió anteriormente. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/es/engines/table-engines/mergetree-family/summingmergetree.md b/docs/es/engines/table-engines/mergetree-family/summingmergetree.md new file mode 100644 index 00000000000..3ae9a1515c0 --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/summingmergetree.md @@ -0,0 +1,141 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: SummingMergeTree +--- + +# SummingMergeTree {#summingmergetree} + +El motor hereda de [Método de codificación de datos:](mergetree.md#table_engines-mergetree). La diferencia es que al fusionar partes de datos para `SummingMergeTree` ClickHouse reemplaza todas las filas con la misma clave primaria (o más exactamente, con la misma [clave de clasificación](mergetree.md)) con una fila que contiene valores resumidos para las columnas con el tipo de datos numérico. Si la clave de ordenación está compuesta de manera que un solo valor de clave corresponde a un gran número de filas, esto reduce significativamente el volumen de almacenamiento y acelera la selección de datos. + +Recomendamos usar el motor junto con `MergeTree`. Almacenar datos completos en `MergeTree` mesa, y el uso `SummingMergeTree` para el almacenamiento de datos agregados, por ejemplo, al preparar informes. Tal enfoque evitará que pierda datos valiosos debido a una clave primaria compuesta incorrectamente. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = SummingMergeTree([columns]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Para obtener una descripción de los parámetros de solicitud, consulte [descripción de la solicitud](../../../sql-reference/statements/create.md). + +**Parámetros de SummingMergeTree** + +- `columns` - una tupla con los nombres de las columnas donde se resumirán los valores. Parámetro opcional. + Las columnas deben ser de tipo numérico y no deben estar en la clave principal. + + Si `columns` no especificado, ClickHouse resume los valores de todas las columnas con un tipo de datos numérico que no están en la clave principal. + +**Cláusulas de consulta** + +Al crear un `SummingMergeTree` mesa de la misma [clausula](mergetree.md) se requieren, como al crear un `MergeTree` tabla. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) +``` + +Todos los parámetros excepto `columns` el mismo significado que en `MergeTree`. + +- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. + +
+ +## Ejemplo de uso {#usage-example} + +Considere la siguiente tabla: + +``` sql +CREATE TABLE summtt +( + key UInt32, + value UInt32 +) +ENGINE = SummingMergeTree() +ORDER BY key +``` + +Insertar datos: + +``` sql +INSERT INTO summtt Values(1,1),(1,2),(2,1) +``` + +ClickHouse puede sumar todas las filas no completamente ([ver abajo](#data-processing)), entonces usamos una función agregada `sum` y `GROUP BY` cláusula en la consulta. + +``` sql +SELECT key, sum(value) FROM summtt GROUP BY key +``` + +``` text +┌─key─┬─sum(value)─┐ +│ 2 │ 1 │ +│ 1 │ 3 │ +└─────┴────────────┘ +``` + +## Procesamiento de datos {#data-processing} + +Cuando los datos se insertan en una tabla, se guardan tal cual. ClickHouse combina las partes insertadas de los datos periódicamente y esto es cuando las filas con la misma clave principal se suman y se reemplazan con una para cada parte resultante de los datos. + +ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) una función agregada [resumir()](../../../sql-reference/aggregate-functions/reference.md#agg_function-sum) y `GROUP BY` cláusula se debe utilizar en una consulta como se describe en el ejemplo anterior. + +### Reglas comunes para la suma {#common-rules-for-summation} + +Se resumen los valores de las columnas con el tipo de datos numérico. El conjunto de columnas está definido por el parámetro `columns`. + +Si los valores eran 0 en todas las columnas para la suma, se elimina la fila. + +Si la columna no está en la clave principal y no se resume, se selecciona un valor arbitrario entre los existentes. + +Los valores no se resumen para las columnas de la clave principal. + +### La suma en las columnas de función agregada {#the-summation-in-the-aggregatefunction-columns} + +Para columnas de [Tipo AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) ClickHouse se comporta como [AgregaciónMergeTree](aggregatingmergetree.md) agregación del motor según la función. + +### Estructuras anidadas {#nested-structures} + +La tabla puede tener estructuras de datos anidadas que se procesan de una manera especial. + +Si el nombre de una tabla anidada termina con `Map` y contiene al menos dos columnas que cumplen los siguientes criterios: + +- la primera columna es numérica `(*Int*, Date, DateTime)` o una cadena `(String, FixedString)`, vamos a llamarlo `key`, +- las otras columnas son aritméticas `(*Int*, Float32/64)`, vamos a llamarlo `(values...)`, + +entonces esta tabla anidada se interpreta como una asignación de `key => (values...)`, y al fusionar sus filas, los elementos de dos conjuntos de datos se fusionan por `key` con una suma de los correspondientes `(values...)`. + +Ejemplos: + +``` text +[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] +[(1, 100)] + [(1, 150)] -> [(1, 250)] +[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] +[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] +``` + +Al solicitar datos, utilice el [sumMap(clave, valor)](../../../sql-reference/aggregate-functions/reference.md) función para la agregación de `Map`. + +Para la estructura de datos anidados, no necesita especificar sus columnas en la tupla de columnas para la suma. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/es/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md b/docs/es/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md new file mode 100644 index 00000000000..d69bfe9440e --- /dev/null +++ b/docs/es/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md @@ -0,0 +1,238 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: VersionedCollapsingMergeTree +--- + +# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} + +Este motor: + +- Permite la escritura rápida de estados de objetos que cambian continuamente. +- Elimina los estados de objetos antiguos en segundo plano. Esto reduce significativamente el volumen de almacenamiento. + +Vea la sección [Derrumbar](#table_engines_versionedcollapsingmergetree) para más detalles. + +El motor hereda de [Método de codificación de datos:](mergetree.md#table_engines-mergetree) y agrega la lógica para colapsar filas al algoritmo para fusionar partes de datos. `VersionedCollapsingMergeTree` tiene el mismo propósito que [ColapsarMergeTree](collapsingmergetree.md) pero usa un algoritmo de colapso diferente que permite insertar los datos en cualquier orden con múltiples hilos. En particular, el `Version` columna ayuda a contraer las filas correctamente, incluso si se insertan en el orden incorrecto. En contraste, `CollapsingMergeTree` sólo permite la inserción estrictamente consecutiva. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = VersionedCollapsingMergeTree(sign, version) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Para obtener una descripción de los parámetros de consulta, consulte [descripción de la consulta](../../../sql-reference/statements/create.md). + +**Parámetros del motor** + +``` sql +VersionedCollapsingMergeTree(sign, version) +``` + +- `sign` — Name of the column with the type of row: `1` es una “state” fila, `-1` es una “cancel” fila. + + El tipo de datos de columna debe ser `Int8`. + +- `version` — Name of the column with the version of the object state. + + El tipo de datos de columna debe ser `UInt*`. + +**Cláusulas de consulta** + +Al crear un `VersionedCollapsingMergeTree` mesa, la misma [clausula](mergetree.md) se requieren como al crear un `MergeTree` tabla. + +
+ +Método obsoleto para crear una tabla + +!!! attention "Atención" + No utilice este método en nuevos proyectos. Si es posible, cambie los proyectos antiguos al método descrito anteriormente. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] VersionedCollapsingMergeTree(date-column [, samp#table_engines_versionedcollapsingmergetreeling_expression], (primary, key), index_granularity, sign, version) +``` + +Todos los parámetros excepto `sign` y `version` el mismo significado que en `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` es una “state” fila, `-1` es una “cancel” fila. + + Column Data Type — `Int8`. + +- `version` — Name of the column with the version of the object state. + + El tipo de datos de columna debe ser `UInt*`. + +
+ +## Derrumbar {#table_engines_versionedcollapsingmergetree} + +### Datos {#data} + +Considere una situación en la que necesite guardar datos que cambien continuamente para algún objeto. Es razonable tener una fila para un objeto y actualizar la fila siempre que haya cambios. Sin embargo, la operación de actualización es costosa y lenta para un DBMS porque requiere volver a escribir los datos en el almacenamiento. La actualización no es aceptable si necesita escribir datos rápidamente, pero puede escribir los cambios en un objeto secuencialmente de la siguiente manera. + +Utilice el `Sign` columna al escribir la fila. Si `Sign = 1` significa que la fila es un estado de un objeto (llamémoslo el “state” fila). Si `Sign = -1` indica la cancelación del estado de un objeto con los mismos atributos (llamémoslo el “cancel” fila). También use el `Version` columna, que debe identificar cada estado de un objeto con un número separado. + +Por ejemplo, queremos calcular cuántas páginas visitaron los usuarios en algún sitio y cuánto tiempo estuvieron allí. En algún momento escribimos la siguiente fila con el estado de la actividad del usuario: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +En algún momento después registramos el cambio de actividad del usuario y lo escribimos con las siguientes dos filas. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +La primera fila cancela el estado anterior del objeto (usuario). Debe copiar todos los campos del estado cancelado excepto `Sign`. + +La segunda fila contiene el estado actual. + +Debido a que solo necesitamos el último estado de actividad del usuario, las filas + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +se puede eliminar, colapsando el estado no válido (antiguo) del objeto. `VersionedCollapsingMergeTree` hace esto mientras fusiona las partes de datos. + +Para averiguar por qué necesitamos dos filas para cada cambio, vea [Algoritmo](#table_engines-versionedcollapsingmergetree-algorithm). + +**Notas sobre el uso** + +1. El programa que escribe los datos debe recordar el estado de un objeto para cancelarlo. El “cancel” cadena debe ser una copia de la “state” con lo opuesto `Sign`. Esto aumenta el tamaño inicial de almacenamiento, pero permite escribir los datos rápidamente. +2. Las matrices de largo crecimiento en columnas reducen la eficiencia del motor debido a la carga para escribir. Cuanto más sencillos sean los datos, mejor será la eficiencia. +3. `SELECT` Los resultados dependen en gran medida de la coherencia del historial de cambios de objetos. Sea preciso al preparar los datos para insertarlos. Puede obtener resultados impredecibles con datos incoherentes, como valores negativos para métricas no negativas, como la profundidad de la sesión. + +### Algoritmo {#table_engines-versionedcollapsingmergetree-algorithm} + +Cuando ClickHouse combina partes de datos, elimina cada par de filas que tienen la misma clave principal y versión y diferentes `Sign`. El orden de las filas no importa. + +Cuando ClickHouse inserta datos, ordena filas por la clave principal. Si el `Version` la columna no está en la clave principal, ClickHouse la agrega a la clave principal implícitamente como el último campo y la usa para ordenar. + +## Selección de datos {#selecting-data} + +ClickHouse no garantiza que todas las filas con la misma clave principal estén en la misma parte de datos resultante o incluso en el mismo servidor físico. Esto es cierto tanto para escribir los datos como para la posterior fusión de las partes de datos. Además, ClickHouse procesa `SELECT` consultas con múltiples subprocesos, y no puede predecir el orden de las filas en el resultado. Esto significa que la agregación es necesaria si hay una necesidad de obtener completamente “collapsed” datos de un `VersionedCollapsingMergeTree` tabla. + +Para finalizar el colapso, escriba una consulta con un `GROUP BY` cláusula y funciones agregadas que representan el signo. Por ejemplo, para calcular la cantidad, use `sum(Sign)` en lugar de `count()`. Para calcular la suma de algo, use `sum(Sign * x)` en lugar de `sum(x)` y agregar `HAVING sum(Sign) > 0`. + +Los agregados `count`, `sum` y `avg` se puede calcular de esta manera. El agregado `uniq` se puede calcular si un objeto tiene al menos un estado no colapsado. Los agregados `min` y `max` no se puede calcular porque `VersionedCollapsingMergeTree` no guarda el historial de valores de estados colapsados. + +Si necesita extraer los datos con “collapsing” pero sin agregación (por ejemplo, para verificar si hay filas presentes cuyos valores más nuevos coinciden con ciertas condiciones), puede usar el `FINAL` modificador para el `FROM` clausula. Este enfoque es ineficiente y no debe usarse con tablas grandes. + +## Ejemplo de uso {#example-of-use} + +Datos de ejemplo: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Creación de la tabla: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8, + Version UInt8 +) +ENGINE = VersionedCollapsingMergeTree(Sign, Version) +ORDER BY UserID +``` + +Insertar los datos: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) +``` + +Usamos dos `INSERT` consultas para crear dos partes de datos diferentes. Si insertamos los datos con una sola consulta, ClickHouse crea una parte de datos y nunca realizará ninguna fusión. + +Obtener los datos: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +¿Qué vemos aquí y dónde están las partes colapsadas? +Creamos dos partes de datos usando dos `INSERT` consulta. El `SELECT` la consulta se realizó en dos subprocesos, y el resultado es un orden aleatorio de filas. +No se produjo el colapso porque las partes de datos aún no se han fusionado. ClickHouse fusiona partes de datos en un punto desconocido en el tiempo que no podemos predecir. + +Es por eso que necesitamos agregación: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration, + Version +FROM UAct +GROUP BY UserID, Version +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 2 │ +└─────────────────────┴───────────┴──────────┴─────────┘ +``` + +Si no necesitamos agregación y queremos forzar el colapso, podemos usar el `FINAL` modificador para el `FROM` clausula. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Esta es una forma muy ineficiente de seleccionar datos. No lo use para mesas grandes. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/es/engines/table-engines/special/buffer.md b/docs/es/engines/table-engines/special/buffer.md new file mode 100644 index 00000000000..3c8a20beaf3 --- /dev/null +++ b/docs/es/engines/table-engines/special/buffer.md @@ -0,0 +1,71 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "B\xFAfer" +--- + +# Búfer {#buffer} + +Almacena los datos para escribir en la memoria RAM, enjuagándolos periódicamente a otra tabla. Durante la operación de lectura, los datos se leen desde el búfer y la otra tabla simultáneamente. + +``` sql +Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) +``` + +Parámetros del motor: + +- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. +- `table` – Table to flush data to. +- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` de búferes independientes. Valor recomendado: 16. +- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, y `max_bytes` – Conditions for flushing data from the buffer. + +Los datos se vacían del búfer y se escriben en la tabla de destino si `min*` condiciones o al menos una `max*` condición se cumplen. + +- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. +- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. +- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. + +Durante la operación de escritura, los datos se insertan en un `num_layers` número de búferes aleatorios. O bien, si la parte de datos para insertar es lo suficientemente grande (mayor que `max_rows` o `max_bytes`), se escribe directamente en la tabla de destino, omitiendo el búfer. + +Las condiciones para el lavado de los datos se calculan por separado para cada uno de los `num_layers` búfer. Por ejemplo, si `num_layers = 16` y `max_bytes = 100000000`, el consumo máximo de RAM es de 1.6 GB. + +Ejemplo: + +``` sql +CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) +``` + +Creación de un ‘merge.hits\_buffer’ mesa con la misma estructura que ‘merge.hits’ y usando el motor Buffer. Al escribir en esta tabla, los datos se almacenan en la memoria RAM y ‘merge.hits’ tabla. Se crean 16 búferes. Los datos de cada uno de ellos se vacían si han pasado 100 segundos o se han escrito un millón de filas o se han escrito 100 MB de datos; o si simultáneamente han pasado 10 segundos y se han escrito 10.000 filas y 10 MB de datos. Por ejemplo, si solo se ha escrito una fila, después de 100 segundos se vaciará, pase lo que pase. Pero si se han escrito muchas filas, los datos se vaciarán antes. + +Cuando se detiene el servidor, con DROP TABLE o DETACH TABLE, los datos del búfer también se vacían a la tabla de destino. + +Puede establecer cadenas vacías entre comillas simples para la base de datos y el nombre de la tabla. Esto indica la ausencia de una tabla de destino. En este caso, cuando se alcanzan las condiciones de descarga de datos, el búfer simplemente se borra. Esto puede ser útil para mantener una ventana de datos en la memoria. + +Al leer desde una tabla de búfer, los datos se procesan tanto desde el búfer como desde la tabla de destino (si hay uno). +Tenga en cuenta que las tablas Buffer no admiten un índice. En otras palabras, los datos del búfer se analizan por completo, lo que puede ser lento para los búferes grandes. (Para los datos de una tabla subordinada, se utilizará el índice que admite.) + +Si el conjunto de columnas de la tabla Buffer no coincide con el conjunto de columnas de una tabla subordinada, se inserta un subconjunto de columnas que existen en ambas tablas. + +Si los tipos no coinciden con una de las columnas de la tabla Búfer y una tabla subordinada, se escribe un mensaje de error en el registro del servidor y se borra el búfer. +Lo mismo sucede si la tabla subordinada no existe cuando se vacía el búfer. + +Si necesita ejecutar ALTER para una tabla subordinada y la tabla de búfer, se recomienda eliminar primero la tabla de búfer, ejecutar ALTER para la tabla subordinada y, a continuación, crear la tabla de búfer de nuevo. + +Si el servidor se reinicia de forma anormal, se pierden los datos del búfer. + +FINAL y SAMPLE no funcionan correctamente para las tablas Buffer. Estas condiciones se pasan a la tabla de destino, pero no se utilizan para procesar datos en el búfer. Si se requieren estas características, recomendamos usar solo la tabla Buffer para escribir, mientras lee desde la tabla de destino. + +Al agregar datos a un búfer, uno de los búferes está bloqueado. Esto provoca retrasos si se realiza una operación de lectura simultáneamente desde la tabla. + +Los datos que se insertan en una tabla de búfer pueden terminar en la tabla subordinada en un orden diferente y en bloques diferentes. Debido a esto, una tabla Buffer es difícil de usar para escribir en un CollapsingMergeTree correctamente. Para evitar problemas, puede establecer ‘num\_layers’ a 1. + +Si se replica la tabla de destino, se pierden algunas características esperadas de las tablas replicadas al escribir en una tabla de búfer. Los cambios aleatorios en el orden de las filas y los tamaños de las partes de datos hacen que la desduplicación de datos deje de funcionar, lo que significa que no es posible tener un ‘exactly once’ escribir en tablas replicadas. + +Debido a estas desventajas, solo podemos recomendar el uso de una tabla Buffer en casos raros. + +Una tabla de búfer se usa cuando se reciben demasiados INSERT de un gran número de servidores durante una unidad de tiempo y los datos no se pueden almacenar en búfer antes de la inserción, lo que significa que los INSERT no pueden ejecutarse lo suficientemente rápido. + +Tenga en cuenta que no tiene sentido insertar datos una fila a la vez, incluso para las tablas de búfer. Esto solo producirá una velocidad de unos pocos miles de filas por segundo, mientras que la inserción de bloques de datos más grandes puede producir más de un millón de filas por segundo (consulte la sección “Performance”). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/es/engines/table-engines/special/dictionary.md b/docs/es/engines/table-engines/special/dictionary.md new file mode 100644 index 00000000000..6d9136a6a23 --- /dev/null +++ b/docs/es/engines/table-engines/special/dictionary.md @@ -0,0 +1,97 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: Diccionario +--- + +# Diccionario {#dictionary} + +El `Dictionary` el motor muestra el [diccionario](../../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) datos como una tabla ClickHouse. + +Como ejemplo, considere un diccionario de `products` con la siguiente configuración: + +``` xml + + + products + + +
products
+ DSN=some-db-server + + + + 300 + 360 + + + + + + + product_id + + + title + String + + + + + +``` + +Consultar los datos del diccionario: + +``` sql +SELECT + name, + type, + key, + attribute.names, + attribute.types, + bytes_allocated, + element_count, + source +FROM system.dictionaries +WHERE name = 'products' +``` + +``` text +┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ +│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ +└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ +``` + +Puede usar el [dictGet\*](../../../sql-reference/functions/ext-dict-functions.md#ext_dict_functions) función para obtener los datos del diccionario en este formato. + +Esta vista no es útil cuando necesita obtener datos sin procesar o cuando `JOIN` operación. Para estos casos, puede usar el `Dictionary` motor, que muestra los datos del diccionario en una tabla. + +Sintaxis: + +``` sql +CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` +``` + +Ejemplo de uso: + +``` sql +create table products (product_id UInt64, title String) Engine = Dictionary(products); +``` + + Ok + +Echa un vistazo a lo que hay en la mesa. + +``` sql +select * from products limit 1; +``` + +``` text +┌────product_id─┬─title───────────┐ +│ 152689 │ Some item │ +└───────────────┴─────────────────┘ +``` + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/es/engines/table-engines/special/distributed.md b/docs/es/engines/table-engines/special/distributed.md new file mode 100644 index 00000000000..df773c7aec4 --- /dev/null +++ b/docs/es/engines/table-engines/special/distributed.md @@ -0,0 +1,152 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: Distribuido +--- + +# Distribuido {#distributed} + +**Las tablas con motor distribuido no almacenan ningún dato por sí mismas**, pero permite el procesamiento de consultas distribuidas en varios servidores. +La lectura se paralela automáticamente. Durante una lectura, se utilizan los índices de tabla en servidores remotos, si los hay. + +El motor distribuido acepta parámetros: + +- el nombre del clúster en el archivo de configuración del servidor + +- el nombre de una base de datos remota + +- el nombre de una tabla remota + +- (opcionalmente) clave de fragmentación + +- nombre de política (opcionalmente), se usará para almacenar archivos temporales para el envío asíncrono + + Ver también: + + - `insert_distributed_sync` configuración + - [Método de codificación de datos:](../mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) para los ejemplos + +Ejemplo: + +``` sql +Distributed(logs, default, hits[, sharding_key[, policy_name]]) +``` + +Los datos se leerán desde todos los servidores ‘logs’ clúster, desde el valor predeterminado.tabla de éxitos ubicada en cada servidor del clúster. +Los datos no solo se leen sino que se procesan parcialmente en los servidores remotos (en la medida en que esto sea posible). +Por ejemplo, para una consulta con GROUP BY, los datos se agregarán en servidores remotos y los estados intermedios de las funciones agregadas se enviarán al servidor solicitante. Luego, los datos se agregarán más. + +En lugar del nombre de la base de datos, puede usar una expresión constante que devuelva una cadena. Por ejemplo: currentDatabase(). + +logs – The cluster name in the server's config file. + +Los clústeres se establecen así: + +``` xml + + + + + 1 + + false + + example01-01-1 + 9000 + + + example01-01-2 + 9000 + + + + 2 + false + + example01-02-1 + 9000 + + + example01-02-2 + 1 + 9440 + + + + +``` + +Aquí se define un clúster con el nombre ‘logs’ que consta de dos fragmentos, cada uno de los cuales contiene dos réplicas. +Los fragmentos se refieren a los servidores que contienen diferentes partes de los datos (para leer todos los datos, debe acceder a todos los fragmentos). +Las réplicas están duplicando servidores (para leer todos los datos, puede acceder a los datos en cualquiera de las réplicas). + +Los nombres de clúster no deben contener puntos. + +Los parámetros `host`, `port`, y opcionalmente `user`, `password`, `secure`, `compression` se especifican para cada servidor: +- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. +- `port` – The TCP port for messenger activity (‘tcp\_port’ en la configuración, generalmente establecido en 9000). No lo confundas con http\_port. +- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Derechos de acceso](../../../operations/access-rights.md). +- `password` – The password for connecting to a remote server (not masked). Default value: empty string. +- `secure` - Use ssl para la conexión, por lo general también debe definir `port` = 9440. El servidor debe escuchar en `9440` y tener certificados correctos. +- `compression` - Utilice la compresión de datos. Valor predeterminado: true. + +When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [load\_balancing](../../../operations/settings/settings.md#settings-load_balancing) configuración. +Si no se establece la conexión con el servidor, habrá un intento de conectarse con un breve tiempo de espera. Si la conexión falla, se seleccionará la siguiente réplica, y así sucesivamente para todas las réplicas. Si el intento de conexión falló para todas las réplicas, el intento se repetirá de la misma manera, varias veces. +Esto funciona a favor de la resiliencia, pero no proporciona una tolerancia completa a errores: un servidor remoto podría aceptar la conexión, pero podría no funcionar o funcionar mal. + +Puede especificar solo uno de los fragmentos (en este caso, el procesamiento de consultas debe denominarse remoto, en lugar de distribuido) o hasta cualquier número de fragmentos. En cada fragmento, puede especificar entre una y cualquier número de réplicas. Puede especificar un número diferente de réplicas para cada fragmento. + +Puede especificar tantos clústeres como desee en la configuración. + +Para ver los clústeres, utilice el ‘system.clusters’ tabla. + +El motor distribuido permite trabajar con un clúster como un servidor local. Sin embargo, el clúster es inextensible: debe escribir su configuración en el archivo de configuración del servidor (mejor aún, para todos los servidores del clúster). + +The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the ‘remote’ función de tabla en su lugar. Vea la sección [Funciones de tabla](../../../sql-reference/table-functions/index.md). + +Hay dos métodos para escribir datos en un clúster: + +Primero, puede definir a qué servidores escribir en qué datos y realizar la escritura directamente en cada fragmento. En otras palabras, realice INSERT en las tablas que la tabla distribuida “looks at”. Esta es la solución más flexible, ya que puede usar cualquier esquema de fragmentación, que podría ser no trivial debido a los requisitos del área temática. Esta es también la solución más óptima ya que los datos se pueden escribir en diferentes fragmentos de forma completamente independiente. + +En segundo lugar, puede realizar INSERT en una tabla distribuida. En este caso, la tabla distribuirá los datos insertados a través de los propios servidores. Para escribir en una tabla distribuida, debe tener un conjunto de claves de fragmentación (el último parámetro). Además, si solo hay un fragmento, la operación de escritura funciona sin especificar la clave de fragmentación, ya que no significa nada en este caso. + +Cada fragmento puede tener un peso definido en el archivo de configuración. Por defecto, el peso es igual a uno. Los datos se distribuyen entre fragmentos en la cantidad proporcional al peso del fragmento. Por ejemplo, si hay dos fragmentos y el primero tiene un peso de 9 mientras que el segundo tiene un peso de 10, el primero se enviará 9 / 19 partes de las filas, y el segundo se enviará 10 / 19. + +Cada fragmento puede tener el ‘internal\_replication’ parámetro definido en el archivo de configuración. + +Si este parámetro se establece en ‘true’, la operación de escritura selecciona la primera réplica en buen estado y escribe datos en ella. Utilice esta alternativa si la tabla Distribuida “looks at” tablas replicadas. En otras palabras, si la tabla donde se escribirán los datos los replicará por sí misma. + +Si se establece en ‘false’ (el valor predeterminado), los datos se escriben en todas las réplicas. En esencia, esto significa que la tabla distribuida replica los datos en sí. Esto es peor que usar tablas replicadas, porque no se verifica la consistencia de las réplicas y, con el tiempo, contendrán datos ligeramente diferentes. + +Para seleccionar el fragmento al que se envía una fila de datos, se analiza la expresión de fragmentación y su resto se toma de dividirlo por el peso total de los fragmentos. La fila se envía al fragmento que corresponde al medio intervalo de los restos de ‘prev\_weight’ a ‘prev\_weights + weight’, donde ‘prev\_weights’ es el peso total de los fragmentos con el número más pequeño, y ‘weight’ es el peso de este fragmento. Por ejemplo, si hay dos fragmentos, y el primero tiene un peso de 9 mientras que el segundo tiene un peso de 10, la fila se enviará al primer fragmento para los restos del rango \[0, 9), y al segundo para los restos del rango \[9, 19). + +La expresión de fragmentación puede ser cualquier expresión de constantes y columnas de tabla que devuelva un entero. Por ejemplo, puede usar la expresión ‘rand()’ para la distribución aleatoria de datos, o ‘UserID’ para la distribución por el resto de dividir la ID del usuario (entonces los datos de un solo usuario residirán en un solo fragmento, lo que simplifica la ejecución de IN y JOIN por los usuarios). Si una de las columnas no se distribuye lo suficientemente uniformemente, puede envolverla en una función hash: intHash64(UserID) . + +Un simple recordatorio de la división es una solución limitada para sharding y no siempre es apropiado. Funciona para volúmenes medianos y grandes de datos (docenas de servidores), pero no para volúmenes muy grandes de datos (cientos de servidores o más). En este último caso, use el esquema de fragmentación requerido por el área asunto, en lugar de usar entradas en Tablas distribuidas. + +SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. + +Debería preocuparse por el esquema de fragmentación en los siguientes casos: + +- Se utilizan consultas que requieren unir datos (IN o JOIN) mediante una clave específica. Si esta clave fragmenta datos, puede usar IN local o JOIN en lugar de GLOBAL IN o GLOBAL JOIN, que es mucho más eficiente. +- Se usa una gran cantidad de servidores (cientos o más) con una gran cantidad de consultas pequeñas (consultas de clientes individuales: sitios web, anunciantes o socios). Para que las pequeñas consultas no afecten a todo el clúster, tiene sentido ubicar datos para un solo cliente en un solo fragmento. Alternativamente, como lo hemos hecho en Yandex.Metrica, puede configurar sharding de dos niveles: divida todo el clúster en “layers”, donde una capa puede consistir en varios fragmentos. Los datos de un único cliente se encuentran en una sola capa, pero los fragmentos se pueden agregar a una capa según sea necesario y los datos se distribuyen aleatoriamente dentro de ellos. Las tablas distribuidas se crean para cada capa y se crea una única tabla distribuida compartida para consultas globales. + +Los datos se escriben de forma asíncrona. Cuando se inserta en la tabla, el bloque de datos se acaba de escribir en el sistema de archivos local. Los datos se envían a los servidores remotos en segundo plano tan pronto como sea posible. El período de envío de datos está gestionado por el [Distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) y [Distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) configuración. El `Distributed` el motor envía cada archivo con datos insertados por separado, pero puede habilitar el envío por lotes de archivos [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) configuración. Esta configuración mejora el rendimiento del clúster al utilizar mejor los recursos de red y servidor local. Debe comprobar si los datos se envían correctamente comprobando la lista de archivos (datos en espera de ser enviados) en el directorio de la tabla: `/var/lib/clickhouse/data/database/table/`. + +Si el servidor dejó de existir o tuvo un reinicio aproximado (por ejemplo, después de un error de dispositivo) después de un INSERT en una tabla distribuida, es posible que se pierdan los datos insertados. Si se detecta un elemento de datos dañado en el directorio de la tabla, se transfiere al ‘broken’ subdirectorio y ya no se utiliza. + +Cuando la opción max\_parallel\_replicas está habilitada, el procesamiento de consultas se paralela en todas las réplicas dentro de un solo fragmento. Para obtener más información, consulte la sección [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). + +## Virtual Columnas {#virtual-columns} + +- `_shard_num` — Contains the `shard_num` (de `system.clusters`). Tipo: [UInt32](../../../sql-reference/data-types/int-uint.md). + +!!! note "Nota" + Ya [`remote`](../../../sql-reference/table-functions/remote.md)/`cluster` funciones de tabla crean internamente instancia temporal del mismo motor distribuido, `_shard_num` está disponible allí también. + +**Ver también** + +- [Virtual columnas](index.md#table_engines-virtual_columns) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/es/engines/table-engines/special/external-data.md b/docs/es/engines/table-engines/special/external-data.md new file mode 100644 index 00000000000..ce64b375ba2 --- /dev/null +++ b/docs/es/engines/table-engines/special/external-data.md @@ -0,0 +1,68 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: Datos externos +--- + +# Datos externos para el procesamiento de consultas {#external-data-for-query-processing} + +ClickHouse permite enviar a un servidor los datos necesarios para procesar una consulta, junto con una consulta SELECT. Estos datos se colocan en una tabla temporal (consulte la sección “Temporary tables”) y se puede utilizar en la consulta (por ejemplo, en operadores IN). + +Por ejemplo, si tiene un archivo de texto con identificadores de usuario importantes, puede cargarlo en el servidor junto con una consulta que utilice la filtración de esta lista. + +Si necesita ejecutar más de una consulta con un gran volumen de datos externos, no utilice esta función. Es mejor cargar los datos a la base de datos con anticipación. + +Los datos externos se pueden cargar mediante el cliente de línea de comandos (en modo no interactivo) o mediante la interfaz HTTP. + +En el cliente de línea de comandos, puede especificar una sección de parámetros en el formato + +``` bash +--external --file=... [--name=...] [--format=...] [--types=...|--structure=...] +``` + +Puede tener varias secciones como esta, para el número de tablas que se transmiten. + +**–external** – Marks the beginning of a clause. +**–file** – Path to the file with the table dump, or -, which refers to stdin. +Solo se puede recuperar una sola tabla de stdin. + +Los siguientes parámetros son opcionales: **–name**– Name of the table. If omitted, \_data is used. +**–format** – Data format in the file. If omitted, TabSeparated is used. + +Se requiere uno de los siguientes parámetros:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … +**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Define los nombres y tipos de columna. + +Los archivos especificados en ‘file’ se analizará mediante el formato especificado en ‘format’ utilizando los tipos de datos especificados en ‘types’ o ‘structure’. La mesa será cargado en el servidor y accesibles, como una tabla temporal con el nombre de ‘name’. + +Ejemplos: + +``` bash +$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 +849897 +$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +Cuando se utiliza la interfaz HTTP, los datos externos se pasan en el formato multipart/form-data. Cada tabla se transmite como un archivo separado. El nombre de la tabla se toma del nombre del archivo. El ‘query\_string’ se pasa los parámetros ‘name\_format’, ‘name\_types’, y ‘name\_structure’, donde ‘name’ es el nombre de la tabla a la que corresponden estos parámetros. El significado de los parámetros es el mismo que cuando se usa el cliente de línea de comandos. + +Ejemplo: + +``` bash +$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv + +$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +Para el procesamiento de consultas distribuidas, las tablas temporales se envían a todos los servidores remotos. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/es/engines/table-engines/special/file.md b/docs/es/engines/table-engines/special/file.md new file mode 100644 index 00000000000..fb739506a22 --- /dev/null +++ b/docs/es/engines/table-engines/special/file.md @@ -0,0 +1,90 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: File +--- + +# File {#table_engines-file} + +El motor de tabla de archivos mantiene los datos en un archivo en uno de los [file +formato](../../../interfaces/formats.md#formats) (TabSeparated, Native, etc.). + +Ejemplos de uso: + +- Exportación de datos de ClickHouse a archivo. +- Convertir datos de un formato a otro. +- Actualización de datos en ClickHouse mediante la edición de un archivo en un disco. + +## Uso en el servidor ClickHouse {#usage-in-clickhouse-server} + +``` sql +File(Format) +``` + +El `Format` parámetro especifica uno de los formatos de archivo disponibles. Realizar +`SELECT` consultas, el formato debe ser compatible para la entrada, y para realizar +`INSERT` queries – for output. The available formats are listed in the +[Formato](../../../interfaces/formats.md#formats) apartado. + +ClickHouse no permite especificar la ruta del sistema de archivos para`File`. Utilizará la carpeta definida por [camino](../../../operations/server-configuration-parameters/settings.md) configuración en la configuración del servidor. + +Al crear una tabla usando `File(Format)` crea un subdirectorio vacío en esa carpeta. Cuando los datos se escriben en esa tabla, se colocan en `data.Format` en ese subdirectorio. + +Puede crear manualmente esta subcarpeta y archivo en el sistema de archivos del servidor y luego [ATTACH](../../../sql-reference/statements/misc.md) para mostrar información con el nombre coincidente, para que pueda consultar datos desde ese archivo. + +!!! warning "Advertencia" + Tenga cuidado con esta funcionalidad, ya que ClickHouse no realiza un seguimiento de los cambios externos en dichos archivos. El resultado de las escrituras simultáneas a través de ClickHouse y fuera de ClickHouse no está definido. + +**Ejemplo:** + +**1.** Configurar el `file_engine_table` tabla: + +``` sql +CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) +``` + +Por defecto, ClickHouse creará una carpeta `/var/lib/clickhouse/data/default/file_engine_table`. + +**2.** Crear manualmente `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` contener: + +``` bash +$ cat data.TabSeparated +one 1 +two 2 +``` + +**3.** Consultar los datos: + +``` sql +SELECT * FROM file_engine_table +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Uso en ClickHouse-local {#usage-in-clickhouse-local} + +En [Sistema abierto.](../../../operations/utilities/clickhouse-local.md#clickhouse-local) El motor de archivos acepta la ruta del archivo además de `Format`. Los flujos de entrada / salida predeterminados se pueden especificar utilizando nombres numéricos o legibles por humanos como `0` o `stdin`, `1` o `stdout`. +**Ejemplo:** + +``` bash +$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" +``` + +## Detalles de la implementación {#details-of-implementation} + +- Multiple `SELECT` las consultas se pueden realizar simultáneamente, pero `INSERT` las consultas se esperarán entre sí. +- Apoyado la creación de nuevos archivos por `INSERT` consulta. +- Si el archivo existe, `INSERT` añadiría nuevos valores en él. +- No soportado: + - `ALTER` + - `SELECT ... SAMPLE` + - Indice + - Replicación + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/es/engines/table-engines/special/generate.md b/docs/es/engines/table-engines/special/generate.md new file mode 100644 index 00000000000..67e664284b4 --- /dev/null +++ b/docs/es/engines/table-engines/special/generate.md @@ -0,0 +1,61 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: GenerateRandom +--- + +# Generaterandom {#table_engines-generate} + +El motor de tabla GenerateRandom produce datos aleatorios para el esquema de tabla determinado. + +Ejemplos de uso: + +- Se usa en la prueba para poblar una tabla grande reproducible. +- Generar entrada aleatoria para pruebas de fuzzing. + +## Uso en el servidor ClickHouse {#usage-in-clickhouse-server} + +``` sql +ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) +``` + +El `max_array_length` y `max_string_length` parámetros especifican la longitud máxima de todos +columnas y cadenas de matriz correspondientemente en los datos generados. + +Generar motor de tabla sólo admite `SELECT` consulta. + +Es compatible con todos [Tipos de datos](../../../sql-reference/data-types/index.md) que se pueden almacenar en una tabla excepto `LowCardinality` y `AggregateFunction`. + +**Ejemplo:** + +**1.** Configurar el `generate_engine_table` tabla: + +``` sql +CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) +``` + +**2.** Consultar los datos: + +``` sql +SELECT * FROM generate_engine_table LIMIT 3 +``` + +``` text +┌─name─┬──────value─┐ +│ c4xJ │ 1412771199 │ +│ r │ 1791099446 │ +│ 7#$ │ 124312908 │ +└──────┴────────────┘ +``` + +## Detalles de la implementación {#details-of-implementation} + +- No soportado: + - `ALTER` + - `SELECT ... SAMPLE` + - `INSERT` + - Indice + - Replicación + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/es/engines/table-engines/special/index.md b/docs/es/engines/table-engines/special/index.md new file mode 100644 index 00000000000..9927a1f61d9 --- /dev/null +++ b/docs/es/engines/table-engines/special/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Especial +toc_priority: 31 +--- + + diff --git a/docs/es/engines/table-engines/special/join.md b/docs/es/engines/table-engines/special/join.md new file mode 100644 index 00000000000..bb8b0e513d9 --- /dev/null +++ b/docs/es/engines/table-engines/special/join.md @@ -0,0 +1,111 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: Unir +--- + +# Unir {#join} + +Estructura de datos preparada para usar en [JOIN](../../../sql-reference/statements/select/join.md#select-join) operación. + +## Creación de una tabla {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], +) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) +``` + +Vea la descripción detallada del [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) consulta. + +**Parámetros del motor** + +- `join_strictness` – [ÚNETE a la rigurosidad](../../../sql-reference/statements/select/join.md#select-join-strictness). +- `join_type` – [Tipo de unión](../../../sql-reference/statements/select/join.md#select-join-types). +- `k1[, k2, ...]` – Key columns from the `USING` cláusula que el `JOIN` operación se hace con. + +Entrar `join_strictness` y `join_type` parámetros sin comillas, por ejemplo, `Join(ANY, LEFT, col1)`. Deben coincidir con el `JOIN` operación para la que se utilizará la tabla. Si los parámetros no coinciden, ClickHouse no lanza una excepción y puede devolver datos incorrectos. + +## Uso de la tabla {#table-usage} + +### Ejemplo {#example} + +Creación de la tabla del lado izquierdo: + +``` sql +CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog +``` + +``` sql +INSERT INTO id_val VALUES (1,11)(2,12)(3,13) +``` + +Creando el lado derecho `Join` tabla: + +``` sql +CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) +``` + +``` sql +INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) +``` + +Unirse a las tablas: + +``` sql +SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 +``` + +``` text +┌─id─┬─val─┬─id_val_join.val─┐ +│ 1 │ 11 │ 21 │ +│ 2 │ 12 │ ᴺᵁᴸᴸ │ +│ 3 │ 13 │ 23 │ +└────┴─────┴─────────────────┘ +``` + +Como alternativa, puede recuperar datos del `Join` tabla, especificando el valor de la clave de unión: + +``` sql +SELECT joinGet('id_val_join', 'val', toUInt32(1)) +``` + +``` text +┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ +│ 21 │ +└────────────────────────────────────────────┘ +``` + +### Selección e inserción de datos {#selecting-and-inserting-data} + +Usted puede utilizar `INSERT` consultas para agregar datos al `Join`-mesas de motor. Si la tabla se creó con el `ANY` estricta, se ignoran los datos de las claves duplicadas. Con el `ALL` estricta, se agregan todas las filas. + +No se puede realizar una `SELECT` consulta directamente desde la tabla. En su lugar, use uno de los siguientes métodos: + +- Coloque la mesa hacia el lado derecho en un `JOIN` clausula. +- Llame al [joinGet](../../../sql-reference/functions/other-functions.md#joinget) función, que le permite extraer datos de la tabla de la misma manera que de un diccionario. + +### Limitaciones y ajustes {#join-limitations-and-settings} + +Al crear una tabla, se aplican los siguientes valores: + +- [Sistema abierto.](../../../operations/settings/settings.md#join_use_nulls) +- [Método de codificación de datos:](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) +- [Método de codificación de datos:](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) +- [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) +- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) + +El `Join`-las tablas del motor no se pueden usar en `GLOBAL JOIN` operación. + +El `Join`-motor permite el uso [Sistema abierto.](../../../operations/settings/settings.md#join_use_nulls) ajuste en el `CREATE TABLE` instrucción. Y [SELECT](../../../sql-reference/statements/select/index.md) consulta permite el uso `join_use_nulls` demasiado. Si tienes diferentes `join_use_nulls` configuración, puede obtener un error al unirse a la tabla. Depende del tipo de JOIN. Cuando se utiliza [joinGet](../../../sql-reference/functions/other-functions.md#joinget) función, usted tiene que utilizar el mismo `join_use_nulls` ajuste en `CRATE TABLE` y `SELECT` instrucción. + +## Almacenamiento de datos {#data-storage} + +`Join` datos de la tabla siempre se encuentra en la memoria RAM. Al insertar filas en una tabla, ClickHouse escribe bloques de datos en el directorio del disco para que puedan restaurarse cuando se reinicie el servidor. + +Si el servidor se reinicia incorrectamente, el bloque de datos en el disco puede perderse o dañarse. En este caso, es posible que deba eliminar manualmente el archivo con datos dañados. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/es/engines/table-engines/special/materializedview.md b/docs/es/engines/table-engines/special/materializedview.md new file mode 100644 index 00000000000..8b130ab141e --- /dev/null +++ b/docs/es/engines/table-engines/special/materializedview.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "M\xE9todo de codificaci\xF3n de datos:" +--- + +# Método de codificación de datos: {#materializedview} + +Se utiliza para implementar vistas materializadas (para obtener más información, consulte [CREATE TABLE](../../../sql-reference/statements/create.md)). Para almacenar datos, utiliza un motor diferente que se especificó al crear la vista. Al leer desde una tabla, solo usa este motor. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/es/engines/table-engines/special/memory.md b/docs/es/engines/table-engines/special/memory.md new file mode 100644 index 00000000000..3d4f8ddff54 --- /dev/null +++ b/docs/es/engines/table-engines/special/memory.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: Memoria +--- + +# Memoria {#memory} + +El motor de memoria almacena datos en RAM, en forma sin comprimir. Los datos se almacenan exactamente en la misma forma en que se reciben cuando se leen. En otras palabras, la lectura de esta tabla es completamente gratuita. +El acceso a los datos simultáneos está sincronizado. Los bloqueos son cortos: las operaciones de lectura y escritura no se bloquean entre sí. +Los índices no son compatibles. La lectura está paralelizada. +La productividad máxima (más de 10 GB/s) se alcanza en consultas simples, porque no hay lectura del disco, descomprimir o deserializar datos. (Cabe señalar que, en muchos casos, la productividad del motor MergeTree es casi tan alta.) +Al reiniciar un servidor, los datos desaparecen de la tabla y la tabla queda vacía. +Normalmente, el uso de este motor de tabla no está justificado. Sin embargo, se puede usar para pruebas y para tareas donde se requiere la velocidad máxima en un número relativamente pequeño de filas (hasta aproximadamente 100,000,000). + +El sistema utiliza el motor de memoria para tablas temporales con datos de consulta externos (consulte la sección “External data for processing a query”), y para la implementación de GLOBAL IN (véase la sección “IN operators”). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/es/engines/table-engines/special/merge.md b/docs/es/engines/table-engines/special/merge.md new file mode 100644 index 00000000000..0c19fd7e2b0 --- /dev/null +++ b/docs/es/engines/table-engines/special/merge.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: Fusionar +--- + +# Fusionar {#merge} + +El `Merge` motor (no debe confundirse con `MergeTree`) no almacena datos en sí, pero permite leer de cualquier número de otras tablas simultáneamente. +La lectura se paralela automáticamente. No se admite la escritura en una tabla. Al leer, se usan los índices de las tablas que realmente se están leyendo, si existen. +El `Merge` engine acepta parámetros: el nombre de la base de datos y una expresión regular para las tablas. + +Ejemplo: + +``` sql +Merge(hits, '^WatchLog') +``` + +Los datos se leerán de las tablas en el `hits` base de datos que tienen nombres que coinciden con la expresión regular ‘`^WatchLog`’. + +En lugar del nombre de la base de datos, puede usar una expresión constante que devuelva una cadena. Por ejemplo, `currentDatabase()`. + +Regular expressions — [Re2](https://github.com/google/re2) (soporta un subconjunto de PCRE), sensible a mayúsculas y minúsculas. +Vea las notas sobre los símbolos de escape en expresiones regulares en el “match” apartado. + +Al seleccionar tablas para leer, el `Merge` no se seleccionará la tabla en sí, incluso si coincide con la expresión regular. Esto es para evitar bucles. +Es posible crear dos `Merge` tablas que intentarán interminablemente leer los datos de los demás, pero esta no es una buena idea. + +La forma típica de usar el `Merge` para trabajar con un gran número de `TinyLog` tablas como si con una sola tabla. + +Ejemplo 2: + +Digamos que tiene una tabla antigua (WatchLog\_old) y decidió cambiar la partición sin mover datos a una nueva tabla (WatchLog\_new) y necesita ver datos de ambas tablas. + +``` sql +CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree(date, (UserId, EventType), 8192); +INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); + +CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; +INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); + +CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); + +SELECT * +FROM WatchLog +``` + +``` text +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-01 │ 1 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-02 │ 2 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +``` + +## Virtual Columnas {#virtual-columns} + +- `_table` — Contains the name of the table from which data was read. Type: [Cadena](../../../sql-reference/data-types/string.md). + + Puede establecer las condiciones constantes en `_table` en el `WHERE/PREWHERE` cláusula (por ejemplo, `WHERE _table='xyz'`). En este caso, la operación de lectura se realiza sólo para las tablas donde la condición en `_table` está satisfecho, por lo que el `_table` columna actúa como un índice. + +**Ver también** + +- [Virtual columnas](index.md#table_engines-virtual_columns) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/es/engines/table-engines/special/null.md b/docs/es/engines/table-engines/special/null.md new file mode 100644 index 00000000000..cc05e7839c9 --- /dev/null +++ b/docs/es/engines/table-engines/special/null.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: Nulo +--- + +# Nulo {#null} + +Al escribir en una tabla Null, los datos se ignoran. Al leer desde una tabla Null, la respuesta está vacía. + +Sin embargo, puede crear una vista materializada en una tabla Null. Entonces los datos escritos en la tabla terminarán en la vista. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/es/engines/table-engines/special/set.md b/docs/es/engines/table-engines/special/set.md new file mode 100644 index 00000000000..4ff23202443 --- /dev/null +++ b/docs/es/engines/table-engines/special/set.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: Establecer +--- + +# Establecer {#set} + +Un conjunto de datos que siempre está en la memoria RAM. Está diseñado para su uso en el lado derecho del operador IN (consulte la sección “IN operators”). + +Puede usar INSERT para insertar datos en la tabla. Se agregarán nuevos elementos al conjunto de datos, mientras que los duplicados se ignorarán. +Pero no puede realizar SELECT desde la tabla. La única forma de recuperar datos es usándolos en la mitad derecha del operador IN. + +Los datos siempre se encuentran en la memoria RAM. Para INSERT, los bloques de datos insertados también se escriben en el directorio de tablas en el disco. Al iniciar el servidor, estos datos se cargan en la RAM. En otras palabras, después de reiniciar, los datos permanecen en su lugar. + +Para un reinicio aproximado del servidor, el bloque de datos en el disco puede perderse o dañarse. En este último caso, es posible que deba eliminar manualmente el archivo con datos dañados. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/es/engines/table-engines/special/url.md b/docs/es/engines/table-engines/special/url.md new file mode 100644 index 00000000000..654b8e99a4e --- /dev/null +++ b/docs/es/engines/table-engines/special/url.md @@ -0,0 +1,82 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: URL +--- + +# URL(URL, Formato) {#table_engines-url} + +Administra datos en un servidor HTTP/HTTPS remoto. Este motor es similar +a la [File](file.md) motor. + +## Uso del motor en el servidor ClickHouse {#using-the-engine-in-the-clickhouse-server} + +El `format` debe ser uno que ClickHouse pueda usar en +`SELECT` consultas y, si es necesario, en `INSERTs`. Para obtener la lista completa de formatos admitidos, consulte +[Formato](../../../interfaces/formats.md#formats). + +El `URL` debe ajustarse a la estructura de un localizador uniforme de recursos. La dirección URL especificada debe apuntar a un servidor +que utiliza HTTP o HTTPS. Esto no requiere ningún +encabezados adicionales para obtener una respuesta del servidor. + +`INSERT` y `SELECT` las consultas se transforman en `POST` y `GET` peticiones, +respectivamente. Para el procesamiento `POST` solicitudes, el servidor remoto debe admitir +[Codificación de transferencia fragmentada](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). + +Puede limitar el número máximo de saltos de redirección HTTP GET utilizando el [Nombre de la red inalámbrica (SSID):](../../../operations/settings/settings.md#setting-max_http_get_redirects) configuración. + +**Ejemplo:** + +**1.** Crear un `url_engine_table` tabla en el servidor : + +``` sql +CREATE TABLE url_engine_table (word String, value UInt64) +ENGINE=URL('http://127.0.0.1:12345/', CSV) +``` + +**2.** Cree un servidor HTTP básico utilizando las herramientas estándar de Python 3 y +comenzarlo: + +``` python3 +from http.server import BaseHTTPRequestHandler, HTTPServer + +class CSVHTTPServer(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header('Content-type', 'text/csv') + self.end_headers() + + self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) + +if __name__ == "__main__": + server_address = ('127.0.0.1', 12345) + HTTPServer(server_address, CSVHTTPServer).serve_forever() +``` + +``` bash +$ python3 server.py +``` + +**3.** Solicitar datos: + +``` sql +SELECT * FROM url_engine_table +``` + +``` text +┌─word──┬─value─┐ +│ Hello │ 1 │ +│ World │ 2 │ +└───────┴───────┘ +``` + +## Detalles de la implementación {#details-of-implementation} + +- Las lecturas y escrituras pueden ser paralelas +- No soportado: + - `ALTER` y `SELECT...SAMPLE` operación. + - Índices. + - Replicación. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/es/engines/table-engines/special/view.md b/docs/es/engines/table-engines/special/view.md new file mode 100644 index 00000000000..dbb496bcca4 --- /dev/null +++ b/docs/es/engines/table-engines/special/view.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: Vista +--- + +# Vista {#table_engines-view} + +Se utiliza para implementar vistas (para obtener más información, consulte `CREATE VIEW query`). No almacena datos, pero solo almacena los datos especificados `SELECT` consulta. Al leer desde una tabla, ejecuta esta consulta (y elimina todas las columnas innecesarias de la consulta). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/es/engines/table_engines/index.md b/docs/es/engines/table_engines/index.md deleted file mode 100644 index 46d769316ba..00000000000 --- a/docs/es/engines/table_engines/index.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Table Engines -toc_priority: 26 -toc_title: "Implantaci\xF3n" ---- - -# Motores de mesa {#table_engines} - -El motor de tabla (tipo de tabla) determina: - -- Cómo y dónde se almacenan los datos, dónde escribirlos y dónde leerlos. -- Qué consultas son compatibles y cómo. -- Acceso a datos simultáneos. -- Uso de índices, si está presente. -- Si es posible la ejecución de solicitudes multiproceso. -- Parámetros de replicación de datos. - -## Familias de motores {#engine-families} - -### Mergetree {#mergetree} - -Los motores de mesa más universales y funcionales para tareas de alta carga. La propiedad compartida por estos motores es la inserción rápida de datos con el posterior procesamiento de datos en segundo plano. `MergeTree` Los motores familiares admiten la replicación de datos (con [Replicado\*](mergetree_family/replication.md) versiones de motores), particionamiento y otras características no admitidas en otros motores. - -Motores en la familia: - -- [Método de codificación de datos:](mergetree_family/mergetree.md) -- [ReplacingMergeTree](mergetree_family/replacingmergetree.md) -- [SummingMergeTree](mergetree_family/summingmergetree.md) -- [AgregaciónMergeTree](mergetree_family/aggregatingmergetree.md) -- [ColapsarMergeTree](mergetree_family/collapsingmergetree.md) -- [VersionedCollapsingMergeTree](mergetree_family/versionedcollapsingmergetree.md) -- [GraphiteMergeTree](mergetree_family/graphitemergetree.md) - -### Registro {#log} - -Ligero [motor](log_family/index.md) con funcionalidad mínima. Son los más efectivos cuando necesita escribir rápidamente muchas tablas pequeñas (hasta aproximadamente 1 millón de filas) y leerlas más tarde como un todo. - -Motores en la familia: - -- [TinyLog](log_family/tinylog.md) -- [StripeLog](log_family/stripelog.md) -- [Registro](log_family/log.md) - -### Motores de integración {#integration-engines} - -Motores para comunicarse con otros sistemas de almacenamiento y procesamiento de datos. - -Motores en la familia: - -- [Kafka](integrations/kafka.md) -- [MySQL](integrations/mysql.md) -- [ODBC](integrations/odbc.md) -- [JDBC](integrations/jdbc.md) -- [HDFS](integrations/hdfs.md) - -### Motores especiales {#special-engines} - -Motores en la familia: - -- [Distribuido](special/distributed.md) -- [Método de codificación de datos:](special/materializedview.md) -- [Diccionario](special/dictionary.md) -- [Fusionar](special/merge.md) -- [File](special/file.md) -- [Nulo](special/null.md) -- [Establecer](special/set.md) -- [Unir](special/join.md) -- [URL](special/url.md) -- [Vista](special/view.md) -- [Memoria](special/memory.md) -- [Búfer](special/buffer.md) - -## Virtual Columnas {#table_engines-virtual-columns} - -La columna virtual es un atributo de motor de tabla integral que se define en el código fuente del motor. - -No debe especificar columnas virtuales en el `CREATE TABLE` consulta y no puedes verlos en `SHOW CREATE TABLE` y `DESCRIBE TABLE` resultados de la consulta. Las columnas virtuales también son de solo lectura, por lo que no puede insertar datos en columnas virtuales. - -Para seleccionar datos de una columna virtual, debe especificar su nombre en el `SELECT` consulta. `SELECT *` no devuelve valores de columnas virtuales. - -Si crea una tabla con una columna que tiene el mismo nombre que una de las columnas virtuales de la tabla, la columna virtual se vuelve inaccesible. No recomendamos hacer esto. Para ayudar a evitar conflictos, los nombres de columna virtual suelen tener el prefijo de un guión bajo. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/es/engines/table_engines/integrations/hdfs.md b/docs/es/engines/table_engines/integrations/hdfs.md deleted file mode 100644 index eb41cdbc91b..00000000000 --- a/docs/es/engines/table_engines/integrations/hdfs.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 36 -toc_title: HDFS ---- - -# HDFS {#table_engines-hdfs} - -Este motor proporciona integración con [Acerca de nosotros](https://en.wikipedia.org/wiki/Apache_Hadoop) permitiendo gestionar datos sobre [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)a través de ClickHouse. Este motor es similar -a la [File](../special/file.md) y [URL](../special/url.md) motores, pero proporciona características específicas de Hadoop. - -## Uso {#usage} - -``` sql -ENGINE = HDFS(URI, format) -``` - -El `URI` El parámetro es el URI del archivo completo en HDFS. -El `format` parámetro especifica uno de los formatos de archivo disponibles. Realizar -`SELECT` consultas, el formato debe ser compatible para la entrada, y para realizar -`INSERT` queries – for output. The available formats are listed in the -[Formato](../../../interfaces/formats.md#formats) apartado. -La parte de la ruta de `URI` puede contener globs. En este caso, la tabla sería de solo lectura. - -**Ejemplo:** - -**1.** Configurar el `hdfs_engine_table` tabla: - -``` sql -CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') -``` - -**2.** Llenar archivo: - -``` sql -INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) -``` - -**3.** Consultar los datos: - -``` sql -SELECT * FROM hdfs_engine_table LIMIT 2 -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Detalles de implementación {#implementation-details} - -- Las lecturas y escrituras pueden ser paralelas -- No soportado: - - `ALTER` y `SELECT...SAMPLE` operación. - - Índices. - - Replicación. - -**Globs en el camino** - -Múltiples componentes de ruta de acceso pueden tener globs. Para ser procesado, el archivo debe existir y coincidir con todo el patrón de ruta. Listado de archivos determina durante `SELECT` (no en `CREATE` momento). - -- `*` — Substitutes any number of any characters except `/` incluyendo cadena vacía. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -Construcciones con `{}` son similares a la [remoto](../../../sql_reference/table_functions/remote.md) función de la tabla. - -**Ejemplo** - -1. Supongamos que tenemos varios archivos en formato TSV con los siguientes URI en HDFS: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. Hay varias maneras de hacer una tabla que consta de los seis archivos: - - - -``` sql -CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') -``` - -Otra forma: - -``` sql -CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') -``` - -La tabla consta de todos los archivos en ambos directorios (todos los archivos deben satisfacer el formato y el esquema descritos en la consulta): - -``` sql -CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') -``` - -!!! warning "Advertencia" - Si la lista de archivos contiene rangos de números con ceros a la izquierda, use la construcción con llaves para cada dígito por separado o use `?`. - -**Ejemplo** - -Crear tabla con archivos llamados `file000`, `file001`, … , `file999`: - -``` sql -CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') -``` - -## Virtual Columnas {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**Ver también** - -- [Virtual columnas](../index.md#table_engines-virtual_columns) - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/es/engines/table_engines/integrations/index.md b/docs/es/engines/table_engines/integrations/index.md deleted file mode 100644 index 4145d8b3d7e..00000000000 --- a/docs/es/engines/table_engines/integrations/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Integrations -toc_priority: 30 ---- - - diff --git a/docs/es/engines/table_engines/integrations/jdbc.md b/docs/es/engines/table_engines/integrations/jdbc.md deleted file mode 100644 index ad37b26f357..00000000000 --- a/docs/es/engines/table_engines/integrations/jdbc.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 34 -toc_title: JDBC ---- - -# JDBC {#table-engine-jdbc} - -Permite que ClickHouse se conecte a bases de datos externas a través de [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). - -Para implementar la conexión JDBC, ClickHouse utiliza el programa independiente [Sistema abierto.](https://github.com/alex-krash/clickhouse-jdbc-bridge) que debería ejecutarse como un demonio. - -Este motor soporta el [NULL](../../../sql_reference/data_types/nullable.md) tipo de datos. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name -( - columns list... -) -ENGINE = JDBC(dbms_uri, external_database, external_table) -``` - -**Parámetros del motor** - -- `dbms_uri` — URI of an external DBMS. - - Formato: `jdbc:://:/?user=&password=`. - Ejemplo para MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. - -- `external_database` — Database in an external DBMS. - -- `external_table` — Name of the table in `external_database`. - -## Ejemplo de uso {#usage-example} - -Crear una tabla en el servidor MySQL conectándose directamente con su cliente de consola: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Creación de una tabla en el servidor ClickHouse y selección de datos de ella: - -``` sql -CREATE TABLE jdbc_table -( - `int_id` Int32, - `int_nullable` Nullable(Int32), - `float` Float32, - `float_nullable` Nullable(Float32) -) -ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') -``` - -``` sql -SELECT * -FROM jdbc_table -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## Ver también {#see-also} - -- [Función de la tabla de JDBC](../../../sql_reference/table_functions/jdbc.md). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/es/engines/table_engines/integrations/kafka.md b/docs/es/engines/table_engines/integrations/kafka.md deleted file mode 100644 index daedc790806..00000000000 --- a/docs/es/engines/table_engines/integrations/kafka.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 32 -toc_title: Kafka ---- - -# Kafka {#kafka} - -Este motor funciona con [Acerca de nosotros](http://kafka.apache.org/). - -Kafka te permite: - -- Publicar o suscribirse a flujos de datos. -- Organice el almacenamiento tolerante a fallos. -- Secuencias de proceso a medida que estén disponibles. - -## Creación de una tabla {#table_engine-kafka-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = Kafka() -SETTINGS - kafka_broker_list = 'host:port', - kafka_topic_list = 'topic1,topic2,...', - kafka_group_name = 'group_name', - kafka_format = 'data_format'[,] - [kafka_row_delimiter = 'delimiter_symbol',] - [kafka_schema = '',] - [kafka_num_consumers = N,] - [kafka_skip_broken_messages = N] -``` - -Parámetros requeridos: - -- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). -- `kafka_topic_list` – A list of Kafka topics. -- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don't want messages to be duplicated in the cluster, use the same group name everywhere. -- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` función, tal como `JSONEachRow`. Para obtener más información, consulte [Formato](../../../interfaces/formats.md) apartado. - -Parámetros opcionales: - -- `kafka_row_delimiter` – Delimiter character, which ends the message. -- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap'n Proto](https://capnproto.org/) requiere la ruta de acceso al archivo de esquema y el nombre de la raíz `schema.capnp:Message` objeto. -- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Especifique más consumidores si el rendimiento de un consumidor es insuficiente. El número total de consumidores no debe exceder el número de particiones en el tema, ya que solo se puede asignar un consumidor por partición. -- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. Si `kafka_skip_broken_messages = N` entonces el motor salta *N* Mensajes de Kafka que no se pueden analizar (un mensaje es igual a una fila de datos). - -Ejemplos: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - SELECT * FROM queue LIMIT 5; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', - kafka_topic_list = 'topic', - kafka_group_name = 'group1', - kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') - SETTINGS kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; -``` - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No utilice este método en nuevos proyectos. Si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format - [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) -``` - -
- -## Descripci {#description} - -Los mensajes entregados se realizan un seguimiento automático, por lo que cada mensaje de un grupo solo se cuenta una vez. Si desea obtener los datos dos veces, cree una copia de la tabla con otro nombre de grupo. - -Los grupos son flexibles y se sincronizan en el clúster. Por ejemplo, si tiene 10 temas y 5 copias de una tabla en un clúster, cada copia obtiene 2 temas. Si el número de copias cambia, los temas se redistribuyen automáticamente entre las copias. Lea más sobre esto en http://kafka.apache.org/intro . - -`SELECT` no es particularmente útil para leer mensajes (excepto para la depuración), ya que cada mensaje se puede leer solo una vez. Es más práctico crear subprocesos en tiempo real utilizando vistas materializadas. Para hacer esto: - -1. Use el motor para crear un consumidor de Kafka y considérelo como un flujo de datos. -2. Crea una tabla con la estructura deseada. -3. Cree una vista materializada que convierta los datos del motor y los coloque en una tabla creada previamente. - -Cuando el `MATERIALIZED VIEW` se une al motor, comienza a recopilar datos en segundo plano. Esto le permite recibir continuamente mensajes de Kafka y convertirlos al formato requerido usando `SELECT`. -Una tabla kafka puede tener tantas vistas materializadas como desee, no leen datos de la tabla kafka directamente, sino que reciben nuevos registros (en bloques), de esta manera puede escribir en varias tablas con diferentes niveles de detalle (con agrupación - agregación y sin). - -Ejemplo: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - CREATE TABLE daily ( - day Date, - level String, - total UInt64 - ) ENGINE = SummingMergeTree(day, (day, level), 8192); - - CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total - FROM queue GROUP BY day, level; - - SELECT level, sum(total) FROM daily GROUP BY level; -``` - -Para mejorar el rendimiento, los mensajes recibidos se agrupan en bloques del tamaño de [Max\_insert\_block\_size](../../../operations/server_configuration_parameters/settings.md#settings-max_insert_block_size). Si el bloque no se formó dentro de [Nombre de la red inalámbrica (SSID):](../../../operations/server_configuration_parameters/settings.md) milisegundos, los datos se vaciarán a la tabla independientemente de la integridad del bloque. - -Para detener la recepción de datos de tema o cambiar la lógica de conversión, desconecte la vista materializada: - -``` sql - DETACH TABLE consumer; - ATTACH TABLE consumer; -``` - -Si desea cambiar la tabla de destino utilizando `ALTER`, recomendamos deshabilitar la vista de material para evitar discrepancias entre la tabla de destino y los datos de la vista. - -## Configuración {#configuration} - -Similar a GraphiteMergeTree, el motor Kafka admite una configuración extendida utilizando el archivo de configuración ClickHouse. Hay dos claves de configuración que puede usar: global (`kafka`) y a nivel de tema (`kafka_*`). La configuración global se aplica primero y, a continuación, se aplica la configuración de nivel de tema (si existe). - -``` xml - - - cgrp - smallest - - - - - 250 - 100000 - -``` - -Para obtener una lista de posibles opciones de configuración, consulte [referencia de configuración librdkafka](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Usa el guión bajo (`_`) en lugar de un punto en la configuración de ClickHouse. Por ejemplo, `check.crcs=true` será `true`. - -## Virtual Columnas {#virtual-columns} - -- `_topic` — Kafka topic. -- `_key` — Key of the message. -- `_offset` — Offset of the message. -- `_timestamp` — Timestamp of the message. -- `_partition` — Partition of Kafka topic. - -**Ver también** - -- [Virtual columnas](../index.md#table_engines-virtual_columns) - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/es/engines/table_engines/integrations/mysql.md b/docs/es/engines/table_engines/integrations/mysql.md deleted file mode 100644 index 6d78036fbdc..00000000000 --- a/docs/es/engines/table_engines/integrations/mysql.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 33 -toc_title: MySQL ---- - -# Mysql {#mysql} - -El motor MySQL le permite realizar `SELECT` consultas sobre datos almacenados en un servidor MySQL remoto. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... -) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -Vea una descripción detallada del [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) consulta. - -La estructura de la tabla puede diferir de la estructura de la tabla MySQL original: - -- Los nombres de columna deben ser los mismos que en la tabla MySQL original, pero puede usar solo algunas de estas columnas y en cualquier orden. -- Los tipos de columna pueden diferir de los de la tabla MySQL original. ClickHouse intenta [elenco](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) valores a los tipos de datos ClickHouse. - -**Parámetros del motor** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` consultas a `REPLACE INTO`. Si `replace_query=1`, la consulta se sustituye. - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expresión que se añade a la `INSERT` consulta. - - Ejemplo: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, donde `on_duplicate_clause` ser `UPDATE c2 = c2 + 1`. Ver el [Documentación de MySQL](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) para encontrar qué `on_duplicate_clause` se puede utilizar con el `ON DUPLICATE KEY` clausula. - - Especificar `on_duplicate_clause` tienes que pasar `0` a la `replace_query` parámetro. Si pasa simultáneamente `replace_query = 1` y `on_duplicate_clause`, ClickHouse genera una excepción. - -Simple `WHERE` cláusulas tales como `=, !=, >, >=, <, <=` se ejecutan en el servidor MySQL. - -El resto de las condiciones y el `LIMIT` La restricción de muestreo se ejecuta en ClickHouse solo después de que finalice la consulta a MySQL. - -## Ejemplo de uso {#usage-example} - -Tabla en MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Tabla en ClickHouse, recuperando datos de la tabla MySQL creada anteriormente: - -``` sql -CREATE TABLE mysql_table -( - `float_nullable` Nullable(Float32), - `int_id` Int32 -) -ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` sql -SELECT * FROM mysql_table -``` - -``` text -┌─float_nullable─┬─int_id─┐ -│ ᴺᵁᴸᴸ │ 1 │ -└────────────────┴────────┘ -``` - -## Ver también {#see-also} - -- [El ‘mysql’ función de la tabla](../../../sql_reference/table_functions/mysql.md) -- [Uso de MySQL como fuente de diccionario externo](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/es/engines/table_engines/integrations/odbc.md b/docs/es/engines/table_engines/integrations/odbc.md deleted file mode 100644 index 4b26cca9146..00000000000 --- a/docs/es/engines/table_engines/integrations/odbc.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 35 -toc_title: ODBC ---- - -# ODBC {#table-engine-odbc} - -Permite que ClickHouse se conecte a bases de datos externas a través de [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -Para implementar con seguridad conexiones ODBC, ClickHouse usa un programa separado `clickhouse-odbc-bridge`. Si el controlador ODBC se carga directamente desde `clickhouse-server`, problemas de controlador pueden bloquear el servidor ClickHouse. ClickHouse se inicia automáticamente `clickhouse-odbc-bridge` cuando se requiere. El programa de puente ODBC se instala desde el mismo paquete que el `clickhouse-server`. - -Este motor soporta el [NULL](../../../sql_reference/data_types/nullable.md) tipo de datos. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1], - name2 [type2], - ... -) -ENGINE = ODBC(connection_settings, external_database, external_table) -``` - -Vea una descripción detallada del [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) consulta. - -La estructura de la tabla puede diferir de la estructura de la tabla de origen: - -- Los nombres de columna deben ser los mismos que en la tabla de origen, pero puede usar solo algunas de estas columnas y en cualquier orden. -- Los tipos de columna pueden diferir de los de la tabla de origen. ClickHouse intenta [elenco](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) valores a los tipos de datos ClickHouse. - -**Parámetros del motor** - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` file. -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -## Ejemplo de uso {#usage-example} - -**Recuperación de datos de la instalación local de MySQL a través de ODBC** - -Este ejemplo se comprueba para Ubuntu Linux 18.04 y el servidor MySQL 5.7. - -Asegúrese de que unixODBC y MySQL Connector están instalados. - -De forma predeterminada (si se instala desde paquetes), ClickHouse comienza como usuario `clickhouse`. Por lo tanto, debe crear y configurar este usuario en el servidor MySQL. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -A continuación, configure la conexión en `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -Puede verificar la conexión usando el `isql` utilidad desde la instalación de unixODBC. - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -Tabla en MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Tabla en ClickHouse, recuperando datos de la tabla MySQL: - -``` sql -CREATE TABLE odbc_t -( - `int_id` Int32, - `float_nullable` Nullable(Float32) -) -ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') -``` - -``` sql -SELECT * FROM odbc_t -``` - -``` text -┌─int_id─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ -└────────┴────────────────┘ -``` - -## Ver también {#see-also} - -- [Diccionarios externos ODBC](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [Tabla ODBC función](../../../sql_reference/table_functions/odbc.md) - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/es/engines/table_engines/log_family/index.md b/docs/es/engines/table_engines/log_family/index.md deleted file mode 100644 index 53f85f95043..00000000000 --- a/docs/es/engines/table_engines/log_family/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Log Family -toc_priority: 29 ---- - - diff --git a/docs/es/engines/table_engines/log_family/log.md b/docs/es/engines/table_engines/log_family/log.md deleted file mode 100644 index 60fafda1fb8..00000000000 --- a/docs/es/engines/table_engines/log_family/log.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 33 -toc_title: Registro ---- - -# Registro {#log} - -El motor pertenece a la familia de motores de registro. Consulte las propiedades comunes de los motores de registro y sus diferencias en [Familia del motor de registro](log_family.md) artículo. - -El registro difiere de [TinyLog](tinylog.md) en que un pequeño archivo de “marks” reside con los archivos de columna. Estas marcas se escriben en cada bloque de datos y contienen compensaciones que indican dónde comenzar a leer el archivo para omitir el número especificado de filas. Esto hace posible leer datos de tabla en múltiples hilos. -Para el acceso a datos simultáneos, las operaciones de lectura se pueden realizar simultáneamente, mientras que las operaciones de escritura bloquean las lecturas entre sí. -El motor de registro no admite índices. Del mismo modo, si la escritura en una tabla falla, la tabla se rompe y la lectura de ella devuelve un error. El motor de registro es adecuado para datos temporales, tablas de escritura única y para fines de prueba o demostración. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/es/engines/table_engines/log_family/log_family.md b/docs/es/engines/table_engines/log_family/log_family.md deleted file mode 100644 index f55002b3c0d..00000000000 --- a/docs/es/engines/table_engines/log_family/log_family.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 31 -toc_title: "Implantaci\xF3n" ---- - -# Familia del motor de registro {#log-engine-family} - -Estos motores fueron desarrollados para escenarios en los que necesita escribir rápidamente muchas tablas pequeñas (hasta aproximadamente 1 millón de filas) y leerlas más tarde en su conjunto. - -Motores de la familia: - -- [StripeLog](stripelog.md) -- [Registro](log.md) -- [TinyLog](tinylog.md) - -## Propiedades comunes {#common-properties} - -Motor: - -- Almacenar datos en un disco. - -- Agregue datos al final del archivo al escribir. - -- Bloqueos de soporte para el acceso a datos simultáneos. - - Durante `INSERT` consultas, la tabla está bloqueada y otras consultas para leer y escribir datos esperan a que la tabla se desbloquee. Si no hay consultas de escritura de datos, se puede realizar cualquier número de consultas de lectura de datos simultáneamente. - -- No apoyo [mutación](../../../sql_reference/statements/alter.md#alter-mutations) operación. - -- No admite índices. - - Esto significa que `SELECT` las consultas para rangos de datos no son eficientes. - -- No escriba datos atómicamente. - - Puede obtener una tabla con datos dañados si algo rompe la operación de escritura, por ejemplo, un cierre anormal del servidor. - -## Diferencia {#differences} - -El `TinyLog` es el más simple de la familia y proporciona la funcionalidad más pobre y la eficiencia más baja. El `TinyLog` el motor no admite la lectura de datos paralelos por varios hilos. Lee datos más lentamente que otros motores de la familia que admiten lectura paralela y utiliza casi tantos descriptores como los `Log` motor porque almacena cada columna en un archivo separado. Úselo en escenarios simples de baja carga. - -El `Log` y `StripeLog` Los motores admiten lectura de datos paralela. Al leer datos, ClickHouse usa múltiples hilos. Cada subproceso procesa un bloque de datos separado. El `Log` utiliza un archivo separado para cada columna de la tabla. `StripeLog` almacena todos los datos en un archivo. Como resultado, el `StripeLog` el motor utiliza menos descriptores en el sistema operativo, pero el `Log` proporciona una mayor eficiencia al leer datos. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/es/engines/table_engines/log_family/stripelog.md b/docs/es/engines/table_engines/log_family/stripelog.md deleted file mode 100644 index 7e0d84837aa..00000000000 --- a/docs/es/engines/table_engines/log_family/stripelog.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 32 -toc_title: StripeLog ---- - -# Lista de Stripelog {#stripelog} - -Este motor pertenece a la familia de motores de registro. Consulte las propiedades comunes de los motores de registro y sus diferencias en [Familia del motor de registro](log_family.md) artículo. - -Utilice este motor en escenarios en los que necesite escribir muchas tablas con una pequeña cantidad de datos (menos de 1 millón de filas). - -## Creación de una tabla {#table_engines-stripelog-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = StripeLog -``` - -Vea la descripción detallada del [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) consulta. - -## Escribir los datos {#table_engines-stripelog-writing-the-data} - -El `StripeLog` el motor almacena todas las columnas en un archivo. Para cada `INSERT` consulta, ClickHouse agrega el bloque de datos al final de un archivo de tabla, escribiendo columnas una por una. - -Para cada tabla, ClickHouse escribe los archivos: - -- `data.bin` — Data file. -- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. - -El `StripeLog` el motor no soporta el `ALTER UPDATE` y `ALTER DELETE` operación. - -## Lectura de los datos {#table_engines-stripelog-reading-the-data} - -El archivo con marcas permite ClickHouse paralelizar la lectura de datos. Esto significa que un `SELECT` query devuelve filas en un orden impredecible. Utilice el `ORDER BY` cláusula para ordenar filas. - -## Ejemplo de uso {#table_engines-stripelog-example-of-use} - -Creación de una tabla: - -``` sql -CREATE TABLE stripe_log_table -( - timestamp DateTime, - message_type String, - message String -) -ENGINE = StripeLog -``` - -Insertar datos: - -``` sql -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') -``` - -Se utilizaron dos `INSERT` consultas para crear dos bloques de datos dentro del `data.bin` file. - -ClickHouse usa múltiples subprocesos al seleccionar datos. Cada subproceso lee un bloque de datos separado y devuelve las filas resultantes de forma independiente a medida que termina. Como resultado, el orden de los bloques de filas en la salida no coincide con el orden de los mismos bloques en la entrada en la mayoría de los casos. Por ejemplo: - -``` sql -SELECT * FROM stripe_log_table -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -┌───────────timestamp─┬─message_type─┬─message───────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -└─────────────────────┴──────────────┴───────────────────────────┘ -``` - -Ordenación de los resultados (orden ascendente por defecto): - -``` sql -SELECT * FROM stripe_log_table ORDER BY timestamp -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -``` - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/es/engines/table_engines/log_family/tinylog.md b/docs/es/engines/table_engines/log_family/tinylog.md deleted file mode 100644 index a082d47e272..00000000000 --- a/docs/es/engines/table_engines/log_family/tinylog.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 34 -toc_title: TinyLog ---- - -# TinyLog {#tinylog} - -El motor pertenece a la familia de motores de registro. Ver [Familia del motor de registro](log_family.md) para las propiedades comunes de los motores de registro y sus diferencias. - -Este motor de tablas se usa normalmente con el método write-once: escribir datos una vez, luego leerlos tantas veces como sea necesario. Por ejemplo, puede usar `TinyLog`-type tablas para datos intermedios que se procesan en pequeños lotes. Tenga en cuenta que el almacenamiento de datos en un gran número de tablas pequeñas es ineficiente. - -Las consultas se ejecutan en una sola secuencia. En otras palabras, este motor está diseñado para tablas relativamente pequeñas (hasta aproximadamente 1,000,000 filas). Tiene sentido usar este motor de tablas si tiene muchas tablas pequeñas, ya que es más simple que el [Registro](log.md) motor (menos archivos necesitan ser abiertos). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/es/engines/table_engines/mergetree_family/aggregatingmergetree.md b/docs/es/engines/table_engines/mergetree_family/aggregatingmergetree.md deleted file mode 100644 index 5316c0d5752..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/aggregatingmergetree.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 35 -toc_title: "Agregaci\xF3nMergeTree" ---- - -# Aggregatingmergetree {#aggregatingmergetree} - -El motor hereda de [Método de codificación de datos:](mergetree.md#table_engines-mergetree), alterando la lógica para la fusión de partes de datos. ClickHouse reemplaza todas las filas con la misma clave principal (o más exactamente, con la misma [clave de clasificación](mergetree.md)) con una sola fila (dentro de una parte de datos) que almacena una combinación de estados de funciones agregadas. - -Usted puede utilizar `AggregatingMergeTree` tablas para la agregación de datos incrementales, incluidas las vistas materializadas agregadas. - -El motor procesa todas las columnas con [AggregateFunction](../../../sql_reference/data_types/aggregatefunction.md) tipo. - -Es apropiado usar `AggregatingMergeTree` si reduce el número de filas por pedidos. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = AggregatingMergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[TTL expr] -[SETTINGS name=value, ...] -``` - -Para obtener una descripción de los parámetros de solicitud, consulte [descripción de la solicitud](../../../sql_reference/statements/create.md). - -**Cláusulas de consulta** - -Al crear un `AggregatingMergeTree` mesa de la misma [clausula](mergetree.md) se requieren, como al crear un `MergeTree` tabla. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -Todos los parámetros tienen el mismo significado que en `MergeTree`. -
- -## SELECCIONAR e INSERTAR {#select-and-insert} - -Para insertar datos, utilice [INSERT SELECT](../../../sql_reference/statements/insert_into.md) consulta con funciones agregadas -State-. -Al seleccionar datos de `AggregatingMergeTree` mesa, uso `GROUP BY` cláusula y las mismas funciones agregadas que al insertar datos, pero usando `-Merge` sufijo. - -En los resultados de `SELECT` consulta, los valores de `AggregateFunction` tipo tiene representación binaria específica de la implementación para todos los formatos de salida de ClickHouse. Si volcar datos en, por ejemplo, `TabSeparated` formato con `SELECT` consulta entonces este volcado se puede cargar de nuevo usando `INSERT` consulta. - -## Ejemplo de una vista materializada agregada {#example-of-an-aggregated-materialized-view} - -`AggregatingMergeTree` vista materializada que mira el `test.visits` tabla: - -``` sql -CREATE MATERIALIZED VIEW test.basic -ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) -AS SELECT - CounterID, - StartDate, - sumState(Sign) AS Visits, - uniqState(UserID) AS Users -FROM test.visits -GROUP BY CounterID, StartDate; -``` - -Insertar datos en el `test.visits` tabla. - -``` sql -INSERT INTO test.visits ... -``` - -Los datos se insertan tanto en la tabla como en la vista `test.basic` que realizará la agregación. - -Para obtener los datos agregados, necesitamos ejecutar una consulta como `SELECT ... GROUP BY ...` de la vista `test.basic`: - -``` sql -SELECT - StartDate, - sumMerge(Visits) AS Visits, - uniqMerge(Users) AS Users -FROM test.basic -GROUP BY StartDate -ORDER BY StartDate; -``` - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/es/engines/table_engines/mergetree_family/collapsingmergetree.md b/docs/es/engines/table_engines/mergetree_family/collapsingmergetree.md deleted file mode 100644 index 7c9b87cc814..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/collapsingmergetree.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 36 -toc_title: ColapsarMergeTree ---- - -# Colapsarmergetree {#table_engine-collapsingmergetree} - -El motor hereda de [Método de codificación de datos:](mergetree.md) y agrega la lógica de las filas que colapsan al algoritmo de fusión de partes de datos. - -`CollapsingMergeTree` elimina de forma asincrónica (colapsa) pares de filas si todos los campos de una clave de ordenación (`ORDER BY`) son equivalentes excepto el campo particular `Sign` que puede tener `1` y `-1` valor. Las filas sin un par se mantienen. Para más detalles, consulte el [Derrumbar](#table_engine-collapsingmergetree-collapsing) sección del documento. - -El motor puede reducir significativamente el volumen de almacenamiento y aumentar la eficiencia de `SELECT` consulta como consecuencia. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = CollapsingMergeTree(sign) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Para obtener una descripción de los parámetros de consulta, consulte [descripción de la consulta](../../../sql_reference/statements/create.md). - -**CollapsingMergeTree Parámetros** - -- `sign` — Name of the column with the type of row: `1` es una “state” fila, `-1` es una “cancel” fila. - - Column data type — `Int8`. - -**Cláusulas de consulta** - -Al crear un `CollapsingMergeTree` mesa, la misma [cláusulas de consulta](mergetree.md#table_engine-mergetree-creating-a-table) se requieren, como al crear un `MergeTree` tabla. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) -``` - -Todos los parámetros excepto `sign` el mismo significado que en `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` — “state” fila, `-1` — “cancel” fila. - - Column Data Type — `Int8`. - -
- -## Derrumbar {#table_engine-collapsingmergetree-collapsing} - -### Datos {#data} - -Considere la situación en la que necesita guardar datos que cambian continuamente para algún objeto. Parece lógico tener una fila para un objeto y actualizarla en cualquier cambio, pero la operación de actualización es costosa y lenta para DBMS porque requiere la reescritura de los datos en el almacenamiento. Si necesita escribir datos rápidamente, la actualización no es aceptable, pero puede escribir los cambios de un objeto secuencialmente de la siguiente manera. - -Utilice la columna en particular `Sign`. Si `Sign = 1` significa que la fila es un estado de un objeto, llamémoslo “state” fila. Si `Sign = -1` significa la cancelación del estado de un objeto con los mismos atributos, llamémoslo “cancel” fila. - -Por ejemplo, queremos calcular cuántas páginas revisaron los usuarios en algún sitio y cuánto tiempo estuvieron allí. En algún momento escribimos la siguiente fila con el estado de la actividad del usuario: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -En algún momento después registramos el cambio de actividad del usuario y lo escribimos con las siguientes dos filas. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -La primera fila cancela el estado anterior del objeto (usuario). Debe copiar los campos clave de ordenación del estado cancelado exceptuando `Sign`. - -La segunda fila contiene el estado actual. - -Como solo necesitamos el último estado de actividad del usuario, las filas - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -se puede eliminar colapsando el estado no válido (antiguo) de un objeto. `CollapsingMergeTree` hace esto mientras se fusionan las partes de datos. - -Por qué necesitamos 2 filas para cada cambio leído en el [Algoritmo](#table_engine-collapsingmergetree-collapsing-algorithm) apartado. - -**Propiedades peculiares de tal enfoque** - -1. El programa que escribe los datos debe recordar el estado de un objeto para poder cancelarlo. “Cancel” debe contener copias de los campos de clave de ordenación “state” y lo opuesto `Sign`. Aumenta el tamaño inicial de almacenamiento, pero permite escribir los datos rápidamente. -2. Las matrices de largo crecimiento en columnas reducen la eficiencia del motor debido a la carga para escribir. Los datos más sencillos, mayor será la eficiencia. -3. El `SELECT` Los resultados dependen en gran medida de la consistencia del historial de cambios de objetos. Sea preciso al preparar los datos para insertarlos. Puede obtener resultados impredecibles en datos incoherentes, por ejemplo, valores negativos para métricas no negativas, como la profundidad de la sesión. - -### Algoritmo {#table_engine-collapsingmergetree-collapsing-algorithm} - -Cuando ClickHouse combina partes de datos, cada grupo de filas consecutivas tiene la misma clave de ordenación (`ORDER BY`) se reduce a no más de dos filas, una con `Sign = 1` (“state” fila) y otro con `Sign = -1` (“cancel” fila). En otras palabras, las entradas colapsan. - -Para cada parte de datos resultante, ClickHouse guarda: - -1. El primero “cancel” y el último “state” si el número de “state” y “cancel” y la última fila es una “state” fila. - -2. El último “state” fila, si hay más “state” filas que “cancel” filas. - -3. El primero “cancel” fila, si hay más “cancel” filas que “state” filas. - -4. Ninguna de las filas, en todos los demás casos. - -También cuando hay al menos 2 más “state” filas que “cancel” filas, o al menos 2 más “cancel” filas entonces “state” fila, la fusión continúa, pero ClickHouse trata esta situación como un error lógico y la registra en el registro del servidor. Este error puede producirse si se insertan los mismos datos más de una vez. - -Por lo tanto, el colapso no debe cambiar los resultados del cálculo de las estadísticas. -Los cambios colapsaron gradualmente para que al final solo quedara el último estado de casi todos los objetos. - -El `Sign` se requiere porque el algoritmo de fusión no garantiza que todas las filas con la misma clave de clasificación estén en la misma parte de datos resultante e incluso en el mismo servidor físico. Proceso de ClickHouse `SELECT` consultas con múltiples hilos, y no puede predecir el orden de las filas en el resultado. La agregación es necesaria si hay una necesidad de obtener completamente “collapsed” datos de `CollapsingMergeTree` tabla. - -Para finalizar el colapso, escriba una consulta con `GROUP BY` cláusula y funciones agregadas que representan el signo. Por ejemplo, para calcular la cantidad, use `sum(Sign)` en lugar de `count()`. Para calcular la suma de algo, use `sum(Sign * x)` en lugar de `sum(x)` y así sucesivamente, y también añadir `HAVING sum(Sign) > 0`. - -Los agregados `count`, `sum` y `avg` podría calcularse de esta manera. El agregado `uniq` podría calcularse si un objeto tiene al menos un estado no colapsado. Los agregados `min` y `max` no se pudo calcular porque `CollapsingMergeTree` no guarda el historial de valores de los estados colapsados. - -Si necesita extraer datos sin agregación (por ejemplo, para comprobar si hay filas presentes cuyos valores más recientes coinciden con ciertas condiciones), puede utilizar el `FINAL` modificador para el `FROM` clausula. Este enfoque es significativamente menos eficiente. - -## Ejemplo de uso {#example-of-use} - -Datos de ejemplo: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Creación de la tabla: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Inserción de los datos: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) -``` - -Usamos dos `INSERT` consultas para crear dos partes de datos diferentes. Si insertamos los datos con una consulta, ClickHouse crea una parte de datos y nunca realizará ninguna fusión. - -Obtener los datos: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -¿qué vemos y dónde está colapsando? - -Con dos `INSERT` consultas, hemos creado 2 partes de datos. El `SELECT` la consulta se realizó en 2 hilos, y obtuvimos un orden aleatorio de filas. No se ha producido un colapso porque todavía no se había fusionado las partes de datos. ClickHouse fusiona parte de datos en un momento desconocido que no podemos predecir. - -Por lo tanto, necesitamos agregación: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration -FROM UAct -GROUP BY UserID -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -Si no necesitamos agregación y queremos forzar el colapso, podemos usar `FINAL` modificador para `FROM` clausula. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Esta forma de seleccionar los datos es muy ineficiente. No lo use para mesas grandes. - -## Ejemplo de otro enfoque {#example-of-another-approach} - -Datos de ejemplo: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ -5 │ -146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -La idea es que las fusiones tengan en cuenta solo los campos clave. Y en el “Cancel” línea podemos especificar valores negativos que igualan la versión anterior de la fila al sumar sin usar la columna Sign. Para este enfoque, es necesario cambiar el tipo de datos `PageViews`,`Duration` para almacenar valores negativos de UInt8 -\> Int16. - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews Int16, - Duration Int16, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Vamos a probar el enfoque: - -``` sql -insert into UAct values(4324182021466249494, 5, 146, 1); -insert into UAct values(4324182021466249494, -5, -146, -1); -insert into UAct values(4324182021466249494, 6, 185, 1); - -select * from UAct final; // avoid using final in production (just for a test or small tables) -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -``` sql -SELECT - UserID, - sum(PageViews) AS PageViews, - sum(Duration) AS Duration -FROM UAct -GROUP BY UserID -```text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -``` sqk -select count() FROM UAct -``` - -``` text -┌─count()─┐ -│ 3 │ -└─────────┘ -``` - -``` sql -optimize table UAct final; - -select * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/es/engines/table_engines/mergetree_family/custom_partitioning_key.md b/docs/es/engines/table_engines/mergetree_family/custom_partitioning_key.md deleted file mode 100644 index e97e26545b9..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/custom_partitioning_key.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 32 -toc_title: "Clave de partici\xF3n personalizada" ---- - -# Clave de partición personalizada {#custom-partitioning-key} - -La partición está disponible para el [Método de codificación de datos:](mergetree.md) mesas familiares (incluyendo [repetición](replication.md) tabla). [Vistas materializadas](../special/materializedview.md) basado en tablas MergeTree soporte de particionamiento, también. - -Una partición es una combinación lógica de registros en una tabla por un criterio especificado. Puede establecer una partición por un criterio arbitrario, como por mes, por día o por tipo de evento. Cada partición se almacena por separado para simplificar las manipulaciones de estos datos. Al acceder a los datos, ClickHouse utiliza el subconjunto más pequeño de particiones posible. - -La partición se especifica en el `PARTITION BY expr` cláusula cuando [creando una tabla](mergetree.md#table_engine-mergetree-creating-a-table). La clave de partición puede ser cualquier expresión de las columnas de la tabla. Por ejemplo, para especificar la partición por mes, utilice la expresión `toYYYYMM(date_column)`: - -``` sql -CREATE TABLE visits -( - VisitDate Date, - Hour UInt8, - ClientID UUID -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(VisitDate) -ORDER BY Hour; -``` - -La clave de partición también puede ser una tupla de expresiones (similar a la [clave primaria](mergetree.md#primary-keys-and-indexes-in-queries)). Por ejemplo: - -``` sql -ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) -PARTITION BY (toMonday(StartDate), EventType) -ORDER BY (CounterID, StartDate, intHash32(UserID)); -``` - -En este ejemplo, establecemos la partición por los tipos de eventos que se produjeron durante la semana actual. - -Al insertar datos nuevos en una tabla, estos datos se almacenan como una parte separada (porción) ordenada por la clave principal. En 10-15 minutos después de insertar, las partes de la misma partición se fusionan en toda la parte. - -!!! info "INFO" - Una combinación solo funciona para partes de datos que tienen el mismo valor para la expresión de partición. Esto significa **no deberías hacer particiones demasiado granulares** (más de un millar de particiones). De lo contrario, el `SELECT` consulta funciona mal debido a un número excesivamente grande de archivos en el sistema de archivos y descriptores de archivos abiertos. - -Utilice el [sistema.parte](../../../operations/system_tables.md#system_tables-parts) tabla para ver las partes y particiones de la tabla. Por ejemplo, supongamos que tenemos un `visits` tabla con partición por mes. Vamos a realizar el `SELECT` consulta para el `system.parts` tabla: - -``` sql -SELECT - partition, - name, - active -FROM system.parts -WHERE table = 'visits' -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 1 │ -│ 201902 │ 201902_11_11_0 │ 1 │ -└───────────┴────────────────┴────────┘ -``` - -El `partition` columna contiene los nombres de las particiones. Hay dos particiones en este ejemplo: `201901` y `201902`. Puede utilizar este valor de columna para especificar el nombre de partición en [ALTER … PARTITION](#alter_manipulations-with-partitions) consulta. - -El `name` columna contiene los nombres de las partes de datos de partición. Puede utilizar esta columna para especificar el nombre de la pieza [ALTER ATTACH PART](#alter_attach-partition) consulta. - -Vamos a desglosar el nombre de la primera parte: `201901_1_3_1`: - -- `201901` es el nombre de la partición. -- `1` es el número mínimo del bloque de datos. -- `3` es el número máximo del bloque de datos. -- `1` es el nivel de fragmento (la profundidad del árbol de fusión del que se forma). - -!!! info "INFO" - Las partes de las tablas de tipo antiguo tienen el nombre: `20190117_20190123_2_2_0` (fecha mínima - fecha máxima - número de bloque mínimo - número de bloque máximo - nivel). - -El `active` columna muestra el estado de la pieza. `1` está activo; `0` está inactivo. Las partes inactivas son, por ejemplo, las partes de origen que quedan después de fusionarse con una parte más grande. Las partes de datos dañadas también se indican como inactivas. - -Como puede ver en el ejemplo, hay varias partes separadas de la misma partición (por ejemplo, `201901_1_3_1` y `201901_1_9_2`). Esto significa que estas partes aún no están fusionadas. ClickHouse combina las partes insertadas de datos periódicamente, aproximadamente 15 minutos después de la inserción. Además, puede realizar una fusión no programada utilizando el [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) consulta. Ejemplo: - -``` sql -OPTIMIZE TABLE visits PARTITION 201902; -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 0 │ -│ 201902 │ 201902_4_11_2 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 0 │ -│ 201902 │ 201902_11_11_0 │ 0 │ -└───────────┴────────────────┴────────┘ -``` - -Las partes inactivas se eliminarán aproximadamente 10 minutos después de la fusión. - -Otra forma de ver un conjunto de partes y particiones es ir al directorio de la tabla: `/var/lib/clickhouse/data///`. Por ejemplo: - -``` bash -/var/lib/clickhouse/data/default/visits$ ls -l -total 40 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached -``` - -Carpeta ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ y así sucesivamente son los directorios de las partes. Cada parte se relaciona con una partición correspondiente y contiene datos solo para un mes determinado (la tabla de este ejemplo tiene particiones por mes). - -El `detached` el directorio contiene partes que se separaron de la tabla utilizando el [DETACH](#alter_detach-partition) consulta. Las partes dañadas también se mueven a este directorio, en lugar de eliminarse. El servidor no utiliza las piezas del `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql_reference/statements/alter.md#alter_attach-partition) consulta. - -Tenga en cuenta que en el servidor operativo, no puede cambiar manualmente el conjunto de piezas o sus datos en el sistema de archivos, ya que el servidor no lo sabrá. Para tablas no replicadas, puede hacer esto cuando se detiene el servidor, pero no se recomienda. Para tablas replicadas, el conjunto de piezas no se puede cambiar en ningún caso. - -ClickHouse le permite realizar operaciones con las particiones: eliminarlas, copiar de una tabla a otra o crear una copia de seguridad. Consulte la lista de todas las operaciones en la sección [Manipulaciones con particiones y piezas](../../../sql_reference/statements/alter.md#alter_manipulations-with-partitions). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/es/engines/table_engines/mergetree_family/graphitemergetree.md b/docs/es/engines/table_engines/mergetree_family/graphitemergetree.md deleted file mode 100644 index f326b594d6a..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/graphitemergetree.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 38 -toc_title: GraphiteMergeTree ---- - -# Graphitemergetree {#graphitemergetree} - -Este motor está diseñado para el adelgazamiento y la agregación / promedio (rollup) [Grafito](http://graphite.readthedocs.io/en/latest/index.html) datos. Puede ser útil para los desarrolladores que desean usar ClickHouse como almacén de datos para Graphite. - -Puede usar cualquier motor de tabla ClickHouse para almacenar los datos de Graphite si no necesita un paquete acumulativo, pero si necesita un paquete acumulativo, use `GraphiteMergeTree`. El motor reduce el volumen de almacenamiento y aumenta la eficiencia de las consultas de Graphite. - -El motor hereda propiedades de [Método de codificación de datos:](mergetree.md). - -## Creación de una tabla {#creating-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE = GraphiteMergeTree(config_section) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Vea una descripción detallada del [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) consulta. - -Una tabla para los datos de grafito debe tener las siguientes columnas para los siguientes datos: - -- Nombre métrico (sensor de grafito). Tipo de datos: `String`. - -- Tiempo de medición de la métrica. Tipo de datos: `DateTime`. - -- Valor de la métrica. Tipo de datos: cualquier numérico. - -- Versión de la métrica. Tipo de datos: cualquier numérico. - - ClickHouse guarda las filas con la versión más alta o la última escrita si las versiones son las mismas. Otras filas se eliminan durante la fusión de partes de datos. - -Los nombres de estas columnas deben establecerse en la configuración acumulativa. - -**GraphiteMergeTree parámetros** - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -**Cláusulas de consulta** - -Al crear un `GraphiteMergeTree` mesa, la misma [clausula](mergetree.md#table_engine-mergetree-creating-a-table) se requieren, como al crear un `MergeTree` tabla. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - EventDate Date, - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) -``` - -Todos los parámetros excepto `config_section` el mismo significado que en `MergeTree`. - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -
- -## Configuración acumulativa {#rollup-configuration} - -La configuración del paquete acumulativo está definida por [graphite\_rollup](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) parámetro en la configuración del servidor. El nombre del parámetro podría ser cualquiera. Puede crear varias configuraciones y usarlas para diferentes tablas. - -Estructura de configuración Rollup: - - required-columns - patterns - -### Columnas requeridas {#required-columns} - -- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. -- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. -- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Valor predeterminado: `Value`. -- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. - -### Patrón {#patterns} - -Estructura del `patterns` apartado: - -``` text -pattern - regexp - function -pattern - regexp - age + precision - ... -pattern - regexp - function - age + precision - ... -pattern - ... -default - function - age + precision - ... -``` - -!!! warning "Atención" - Los patrones deben ser estrictamente ordenados: - - 1. Patterns without `function` or `retention`. - 1. Patterns with both `function` and `retention`. - 1. Pattern `default`. - -Al procesar una fila, ClickHouse comprueba las reglas en el `pattern` apartado. Cada uno de `pattern` (incluir `default` secciones pueden contener `function` parámetro para la agregación, `retention` parámetros o ambos. Si el nombre de la métrica coincide con `regexp`, las reglas de la `pattern` sección (o secciones); de lo contrario, las reglas de la `default` sección se utilizan. - -Campos para `pattern` y `default` apartado: - -- `regexp`– A pattern for the metric name. -- `age` – The minimum age of the data in seconds. -- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). -- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. - -### Ejemplo de configuración {#configuration-example} - -``` xml - - Version - - click_cost - any - - 0 - 5 - - - 86400 - 60 - - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/es/engines/table_engines/mergetree_family/index.md b/docs/es/engines/table_engines/mergetree_family/index.md deleted file mode 100644 index 339e1dd8eb3..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: MergeTree Family -toc_priority: 28 ---- - - diff --git a/docs/es/engines/table_engines/mergetree_family/mergetree.md b/docs/es/engines/table_engines/mergetree_family/mergetree.md deleted file mode 100644 index c7261eec0cc..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/mergetree.md +++ /dev/null @@ -1,654 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 30 -toc_title: "M\xE9todo de codificaci\xF3n de datos:" ---- - -# Mergetree {#table_engines-mergetree} - -El `MergeTree` motor y otros motores de esta familia (`*MergeTree`) son los motores de mesa ClickHouse más robustos. - -Motores en el `MergeTree` familia están diseñados para insertar una gran cantidad de datos en una tabla. Los datos se escriben rápidamente en la tabla parte por parte, luego se aplican reglas para fusionar las partes en segundo plano. Este método es mucho más eficiente que reescribir continuamente los datos en almacenamiento durante la inserción. - -Principales características: - -- Almacena datos ordenados por clave principal. - - Esto le permite crear un pequeño índice disperso que ayuda a encontrar datos más rápido. - -- Las particiones se pueden utilizar si [clave de partición](custom_partitioning_key.md) se especifica. - - ClickHouse admite ciertas operaciones con particiones que son más efectivas que las operaciones generales en los mismos datos con el mismo resultado. ClickHouse también corta automáticamente los datos de partición donde se especifica la clave de partición en la consulta. Esto también mejora el rendimiento de las consultas. - -- Soporte de replicación de datos. - - La familia de `ReplicatedMergeTree` proporciona la replicación de datos. Para obtener más información, consulte [Replicación de datos](replication.md). - -- Soporte de muestreo de datos. - - Si es necesario, puede establecer el método de muestreo de datos en la tabla. - -!!! info "INFO" - El [Fusionar](../special/merge.md) el motor no pertenece al `*MergeTree` familia. - -## Creación de una tabla {#table_engine-mergetree-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... - INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, - INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 -) ENGINE = MergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] -[SETTINGS name=value, ...] -``` - -Para obtener una descripción de los parámetros, consulte [Descripción de la consulta CREATE](../../../sql_reference/statements/create.md). - -!!! note "Nota" - `INDEX` es una característica experimental, ver [Índices de saltos de datos](#table_engine-mergetree-data_skipping-indexes). - -### Cláusulas de consulta {#mergetree-query-clauses} - -- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. El `MergeTree` el motor no tiene parámetros. - -- `PARTITION BY` — The [clave de partición](custom_partitioning_key.md). - - Para particionar por mes, utilice el `toYYYYMM(date_column)` expresión, donde `date_column` es una columna con una fecha del tipo [Fecha](../../../sql_reference/data_types/date.md). Los nombres de partición aquí tienen el `"YYYYMM"` formato. - -- `ORDER BY` — The sorting key. - - Una tupla de columnas o expresiones arbitrarias. Ejemplo: `ORDER BY (CounterID, EventDate)`. - -- `PRIMARY KEY` — The primary key if it [difiere de la clave de clasificación](#choosing-a-primary-key-that-differs-from-the-sorting-key). - - De forma predeterminada, la clave principal es la misma que la clave de ordenación (que se especifica `ORDER BY` clausula). Por lo tanto, en la mayoría de los casos no es necesario especificar un `PRIMARY KEY` clausula. - -- `SAMPLE BY` — An expression for sampling. - - Si se utiliza una expresión de muestreo, la clave principal debe contenerla. Ejemplo: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. - -- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [entre discos y volúmenes](#table_engine-mergetree-multiple-volumes). - - La expresión debe tener una `Date` o `DateTime` columna como resultado. Ejemplo: - `TTL date + INTERVAL 1 DAY` - - Tipo de regla `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` especifica una acción que debe realizarse con la pieza si la expresión está satisfecha (alcanza la hora actual): eliminación de filas caducadas, mover una pieza (si la expresión está satisfecha para todas las filas de una pieza) al disco especificado (`TO DISK 'xxx'`) o al volumen (`TO VOLUME 'xxx'`). El tipo predeterminado de la regla es la eliminación (`DELETE`). Se puede especificar una lista de varias reglas, pero no debe haber más de una `DELETE` regla. - - Para obtener más información, consulte [TTL para columnas y tablas](#table_engine-mergetree-ttl) - -- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: - - - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Almacenamiento de datos](#mergetree-data-storage). - - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Almacenamiento de datos](#mergetree-data-storage). - - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` configuración. Antes de la versión 19.11, sólo existía el `index_granularity` ajuste para restringir el tamaño del gránulo. El `index_granularity_bytes` mejora el rendimiento de ClickHouse al seleccionar datos de tablas con filas grandes (decenas y cientos de megabytes). Si tiene tablas con filas grandes, puede habilitar esta configuración para que las tablas mejoren la eficiencia de `SELECT` consulta. - - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, entonces ZooKeeper almacena menos datos. Para obtener más información, consulte [descripción del ajuste](../../../operations/server_configuration_parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) en “Server configuration parameters”. - - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` bytes, ClickHouse lee y escribe los datos en el disco de almacenamiento utilizando la interfaz de E / S directa (`O_DIRECT` opcion). Si `min_merge_bytes_to_use_direct_io = 0`, entonces la E/S directa está deshabilitada. Valor predeterminado: `10 * 1024 * 1024 * 1024` byte. - - - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). - - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don't turn it off. - - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. - - `storage_policy` — Storage policy. See [Uso de varios dispositivos de bloque para el almacenamiento de datos](#table_engine-mergetree-multiple-volumes). - -**Ejemplo de configuración de secciones** - -``` sql -ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 -``` - -En el ejemplo, configuramos la partición por mes. - -También establecemos una expresión para el muestreo como un hash por el ID de usuario. Esto le permite pseudoaleatorizar los datos en la tabla para cada `CounterID` y `EventDate`. Si define un [SAMPLE](../../../sql_reference/statements/select.md#select-sample-clause) cláusula al seleccionar los datos, ClickHouse devolverá una muestra de datos pseudoaleatoria uniforme para un subconjunto de usuarios. - -El `index_granularity` se puede omitir porque 8192 es el valor predeterminado. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No utilice este método en nuevos proyectos. Si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -**Parámetros MergeTree()** - -- `date-column` — The name of a column of the [Fecha](../../../sql_reference/data_types/date.md) tipo. ClickHouse crea automáticamente particiones por mes en función de esta columna. Los nombres de partición están en el `"YYYYMM"` formato. -- `sampling_expression` — An expression for sampling. -- `(primary, key)` — Primary key. Type: [Tupla()](../../../sql_reference/data_types/tuple.md) -- `index_granularity` — The granularity of an index. The number of data rows between the “marks” de un índice. El valor 8192 es apropiado para la mayoría de las tareas. - -**Ejemplo** - -``` sql -MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) -``` - -El `MergeTree` engine se configura de la misma manera que en el ejemplo anterior para el método de configuración del motor principal. -
- -## Almacenamiento de datos {#mergetree-data-storage} - -Una tabla consta de partes de datos ordenadas por clave principal. - -Cuando se insertan datos en una tabla, se crean partes de datos separadas y cada una de ellas se ordena lexicográficamente por clave principal. Por ejemplo, si la clave principal es `(CounterID, Date)`, los datos en la parte se ordenan por `CounterID`, y dentro de cada `CounterID` es ordenado por `Date`. - -Los datos que pertenecen a diferentes particiones se separan en diferentes partes. En el fondo, ClickHouse combina partes de datos para un almacenamiento más eficiente. Las piezas que pertenecen a particiones diferentes no se fusionan. El mecanismo de combinación no garantiza que todas las filas con la misma clave principal estén en la misma parte de datos. - -Cada parte de datos se divide lógicamente en gránulos. Un gránulo es el conjunto de datos indivisibles más pequeño que ClickHouse lee al seleccionar datos. ClickHouse no divide filas o valores, por lo que cada gránulo siempre contiene un número entero de filas. La primera fila de un gránulo está marcada con el valor de la clave principal de la fila. Para cada parte de datos, ClickHouse crea un archivo de índice que almacena las marcas. Para cada columna, ya sea en la clave principal o no, ClickHouse también almacena las mismas marcas. Estas marcas le permiten encontrar datos directamente en archivos de columnas. - -El tamaño del gránulo es restringido por `index_granularity` y `index_granularity_bytes` configuración del motor de tabla. El número de filas en un gránulo se encuentra en el `[1, index_granularity]` rango, dependiendo del tamaño de las filas. El tamaño de un gránulo puede exceder `index_granularity_bytes` si el tamaño de una sola fila es mayor que el valor de la configuración. En este caso, el tamaño del gránulo es igual al tamaño de la fila. - -## Claves e índices principales en consultas {#primary-keys-and-indexes-in-queries} - -Tome el `(CounterID, Date)` clave primaria como ejemplo. En este caso, la clasificación y el índice se pueden ilustrar de la siguiente manera: - - Whole data: [---------------------------------------------] - CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] - Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] - Marks: | | | | | | | | | | | - a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 - Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 - -Si la consulta de datos especifica: - -- `CounterID in ('a', 'h')`, el servidor lee los datos en los rangos de marcas `[0, 3)` y `[6, 8)`. -- `CounterID IN ('a', 'h') AND Date = 3`, el servidor lee los datos en los rangos de marcas `[1, 3)` y `[7, 8)`. -- `Date = 3`, el servidor lee los datos en el rango de marcas `[1, 10]`. - -Los ejemplos anteriores muestran que siempre es más efectivo usar un índice que un análisis completo. - -Un índice disperso permite leer datos adicionales. Al leer un único rango de la clave primaria, hasta `index_granularity * 2` se pueden leer filas adicionales en cada bloque de datos. - -Los índices dispersos le permiten trabajar con una gran cantidad de filas de tabla, porque en la mayoría de los casos, dichos índices caben en la RAM de la computadora. - -ClickHouse no requiere una clave principal única. Puede insertar varias filas con la misma clave principal. - -### Selección de la clave principal {#selecting-the-primary-key} - -El número de columnas en la clave principal no está explícitamente limitado. Dependiendo de la estructura de datos, puede incluir más o menos columnas en la clave principal. Esto puede: - -- Mejorar el rendimiento de un índice. - - Si la clave principal es `(a, b)`, a continuación, añadir otra columna `c` mejorará el rendimiento si se cumplen las siguientes condiciones: - - - Hay consultas con una condición en la columna `c`. - - Rangos de datos largos (varias veces más `index_granularity`) con valores idénticos para `(a, b)` son comunes. En otras palabras, al agregar otra columna le permite omitir rangos de datos bastante largos. - -- Mejorar la compresión de datos. - - ClickHouse ordena los datos por clave principal, por lo que cuanto mayor sea la consistencia, mejor será la compresión. - -- Proporcione una lógica adicional al fusionar partes de datos en el [ColapsarMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) y [SummingMergeTree](summingmergetree.md) motor. - - En este caso tiene sentido especificar el *clave de clasificación* que es diferente de la clave principal. - -Una clave principal larga afectará negativamente al rendimiento de la inserción y al consumo de memoria, pero las columnas adicionales de la clave principal no afectarán al rendimiento de ClickHouse durante `SELECT` consulta. - -### Elegir una clave principal que difiere de la clave de ordenación {#choosing-a-primary-key-that-differs-from-the-sorting-key} - -Es posible especificar una clave principal (una expresión con valores que se escriben en el archivo de índice para cada marca) que es diferente de la clave de ordenación (una expresión para ordenar las filas en partes de datos). En este caso, la tupla de expresión de clave primaria debe ser un prefijo de la tupla de expresión de clave de ordenación. - -Esta característica es útil cuando se [SummingMergeTree](summingmergetree.md) y -[AgregaciónMergeTree](aggregatingmergetree.md) motores de mesa. En un caso común cuando se utilizan estos motores, la tabla tiene dos tipos de columnas: *cota* y *medida*. Las consultas típicas agregan valores de columnas de medida con `GROUP BY` y filtrado por dimensiones. Debido a que SummingMergeTree y AggregatingMergeTree agregan filas con el mismo valor de la clave de ordenación, es natural agregarle todas las dimensiones. Como resultado, la expresión de clave consta de una larga lista de columnas y esta lista debe actualizarse con frecuencia con las dimensiones recién agregadas. - -En este caso, tiene sentido dejar solo unas pocas columnas en la clave principal que proporcionarán análisis de rango eficientes y agregarán las columnas de dimensión restantes a la tupla de clave de clasificación. - -[ALTER](../../../sql_reference/statements/alter.md) de la clave de ordenación es una operación ligera porque cuando se agrega una nueva columna simultáneamente a la tabla y a la clave de ordenación, las partes de datos existentes no necesitan ser cambiadas. Dado que la clave de ordenación anterior es un prefijo de la nueva clave de ordenación y no hay datos en la columna recién agregada, los datos se ordenan tanto por las claves de ordenación antiguas como por las nuevas en el momento de la modificación de la tabla. - -### Uso de índices y particiones en consultas {#use-of-indexes-and-partitions-in-queries} - -Para `SELECT` consultas, ClickHouse analiza si se puede usar un índice. Se puede usar un índice si el `WHERE/PREWHERE` clause tiene una expresión (como uno de los elementos de conjunción, o enteramente) que representa una operación de comparación de igualdad o desigualdad, o si tiene `IN` o `LIKE` con un prefijo fijo en columnas o expresiones que están en la clave principal o clave de partición, o en ciertas funciones parcialmente repetitivas de estas columnas, o relaciones lógicas de estas expresiones. - -Por lo tanto, es posible ejecutar rápidamente consultas en uno o varios rangos de la clave principal. En este ejemplo, las consultas serán rápidas cuando se ejecuten para una etiqueta de seguimiento específica, para una etiqueta y un intervalo de fechas específicos, para una etiqueta y una fecha específicas, para varias etiquetas con un intervalo de fechas, etc. - -Veamos el motor configurado de la siguiente manera: - - ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 - -En este caso, en consultas: - -``` sql -SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 -SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) -SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) -``` - -ClickHouse utilizará el índice de clave principal para recortar datos incorrectos y la clave de partición mensual para recortar particiones que están en intervalos de fechas incorrectos. - -Las consultas anteriores muestran que el índice se usa incluso para expresiones complejas. La lectura de la tabla está organizada de modo que el uso del índice no puede ser más lento que un escaneo completo. - -En el siguiente ejemplo, el índice no se puede usar. - -``` sql -SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' -``` - -Para comprobar si ClickHouse puede usar el índice al ejecutar una consulta, use la configuración [Fecha de nacimiento](../../../operations/settings/settings.md#settings-force_index_by_date) y [force\_primary\_key](../../../operations/settings/settings.md). - -La clave para particionar por mes permite leer solo aquellos bloques de datos que contienen fechas del rango adecuado. En este caso, el bloque de datos puede contener datos para muchas fechas (hasta un mes). Dentro de un bloque, los datos se ordenan por clave principal, que puede no contener la fecha como la primera columna. Debido a esto, el uso de una consulta con solo una condición de fecha que no especifica el prefijo de clave principal hará que se lean más datos que para una sola fecha. - -### Uso del índice para claves primarias parcialmente monotónicas {#use-of-index-for-partially-monotonic-primary-keys} - -Considere, por ejemplo, los días del mes. Ellos forman un [monótona secuencia](https://en.wikipedia.org/wiki/Monotonic_function) durante un mes, pero no monótono durante períodos más prolongados. Esta es una secuencia parcialmente monotónica. Si un usuario crea la tabla con clave primaria parcialmente monótona, ClickHouse crea un índice disperso como de costumbre. Cuando un usuario selecciona datos de este tipo de tabla, ClickHouse analiza las condiciones de consulta. Si el usuario desea obtener datos entre dos marcas del índice y ambas marcas caen dentro de un mes, ClickHouse puede usar el índice en este caso particular porque puede calcular la distancia entre los parámetros de una consulta y las marcas de índice. - -ClickHouse no puede usar un índice si los valores de la clave principal en el rango de parámetros de consulta no representan una secuencia monotónica. En este caso, ClickHouse utiliza el método de análisis completo. - -ClickHouse usa esta lógica no solo para secuencias de días del mes, sino para cualquier clave principal que represente una secuencia parcialmente monotónica. - -### Índices de saltos de datos (experimental) {#table_engine-mergetree-data_skipping-indexes} - -La declaración de índice se encuentra en la sección de columnas del `CREATE` consulta. - -``` sql -INDEX index_name expr TYPE type(...) GRANULARITY granularity_value -``` - -Para tablas de la `*MergeTree` familia, se pueden especificar índices de omisión de datos. - -Estos índices agregan cierta información sobre la expresión especificada en bloques, que consisten en `granularity_value` gránulos (el tamaño del gránulo se especifica utilizando el `index_granularity` ajuste en el motor de la tabla). Entonces estos agregados se usan en `SELECT` consultas para reducir la cantidad de datos a leer desde el disco omitiendo grandes bloques de datos donde el `where` consulta no puede ser satisfecha. - -**Ejemplo** - -``` sql -CREATE TABLE table_name -( - u64 UInt64, - i32 Int32, - s String, - ... - INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, - INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 -) ENGINE = MergeTree() -... -``` - -ClickHouse puede utilizar los índices del ejemplo para reducir la cantidad de datos que se leen desde el disco en las siguientes consultas: - -``` sql -SELECT count() FROM table WHERE s < 'z' -SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 -``` - -#### Tipos de índices disponibles {#available-types-of-indices} - -- `minmax` - - Almacena los extremos de la expresión especificada (si la expresión `tuple`, entonces almacena extremos para cada elemento de `tuple`), utiliza información almacenada para omitir bloques de datos como la clave principal. - -- `set(max_rows)` - - Almacena valores únicos de la expresión especificada (no más de `max_rows` filas, `max_rows=0` medio “no limits”). Utiliza los valores para comprobar si `WHERE` expresión no es satisfactorio en un bloque de datos. - -- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Tiendas a [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) que contiene todos los ngrams de un bloque de datos. Funciona solo con cadenas. Puede ser utilizado para la optimización de `equals`, `like` y `in` expresiones. - - - `n` — ngram size, - - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). - - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. - - `random_seed` — The seed for Bloom filter hash functions. - -- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Lo mismo que `ngrambf_v1`, pero almacena tokens en lugar de ngrams. Los tokens son secuencias separadas por caracteres no alfanuméricos. - -- `bloom_filter([false_positive])` — Stores a [Filtro de floración](https://en.wikipedia.org/wiki/Bloom_filter) para las columnas especificadas. - - Opcional `false_positive` parámetro es la probabilidad de recibir una respuesta falsa positiva del filtro. Valores posibles: (0, 1). Valor predeterminado: 0.025. - - Tipos de datos admitidos: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. - - Las siguientes funciones pueden usarlo: [igual](../../../sql_reference/functions/comparison_functions.md), [notEquals](../../../sql_reference/functions/comparison_functions.md), [en](../../../sql_reference/functions/in_functions.md), [noEn](../../../sql_reference/functions/in_functions.md), [tener](../../../sql_reference/functions/array_functions.md). - - - -``` sql -INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 -INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 -INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 -``` - -#### Funciones de apoyo {#functions-support} - -Condiciones en el `WHERE` cláusula contiene llamadas de las funciones que operan con columnas. Si la columna forma parte de un índice, ClickHouse intenta usar este índice al realizar las funciones. ClickHouse admite diferentes subconjuntos de funciones para usar índices. - -El `set` index se puede utilizar con todas las funciones. Subconjuntos de funciones para otros índices se muestran en la siguiente tabla. - -| Función (operador) / Índice | clave primaria | minmax | Descripción | Sistema abierto. | bloom\_filter | -|----------------------------------------------------------------------------------------------------------|----------------|--------|-------------|------------------|---------------| -| [igual (=, ==)](../../../sql_reference/functions/comparison_functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notEquals(!=, \<\>)](../../../sql_reference/functions/comparison_functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [como](../../../sql_reference/functions/string_search_functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [No como](../../../sql_reference/functions/string_search_functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [Comienza con](../../../sql_reference/functions/string_functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | -| [Finaliza con](../../../sql_reference/functions/string_functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | -| [multiSearchAny](../../../sql_reference/functions/string_search_functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | -| [en](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [noEn](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [menos (\<)](../../../sql_reference/functions/comparison_functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [mayor (\>)](../../../sql_reference/functions/comparison_functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [menosOrEquals (\<=)](../../../sql_reference/functions/comparison_functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [mayorOrEquals (\>=)](../../../sql_reference/functions/comparison_functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [vaciar](../../../sql_reference/functions/array_functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [notEmpty](../../../sql_reference/functions/array_functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | - -Las funciones con un argumento constante que es menor que el tamaño de ngram no pueden ser utilizadas por `ngrambf_v1` para la optimización de consultas. - -Los filtros Bloom pueden tener coincidencias falsas positivas, por lo que `ngrambf_v1`, `tokenbf_v1`, y `bloom_filter` los índices no se pueden usar para optimizar consultas donde se espera que el resultado de una función sea falso, por ejemplo: - -- Puede ser optimizado: - - `s LIKE '%test%'` - - `NOT s NOT LIKE '%test%'` - - `s = 1` - - `NOT s != 1` - - `startsWith(s, 'test')` -- No se puede optimizar: - - `NOT s LIKE '%test%'` - - `s NOT LIKE '%test%'` - - `NOT s = 1` - - `s != 1` - - `NOT startsWith(s, 'test')` - -## Acceso a datos simultáneos {#concurrent-data-access} - -Para el acceso simultáneo a tablas, usamos versiones múltiples. En otras palabras, cuando una tabla se lee y actualiza simultáneamente, los datos se leen de un conjunto de partes que está actualizado en el momento de la consulta. No hay cerraduras largas. Las inserciones no se interponen en el camino de las operaciones de lectura. - -La lectura de una tabla se paralela automáticamente. - -## TTL para columnas y tablas {#table_engine-mergetree-ttl} - -Determina la duración de los valores. - -El `TTL` se puede establecer para toda la tabla y para cada columna individual. TTL de nivel de tabla también puede especificar la lógica de movimiento automático de datos entre discos y volúmenes. - -Las expresiones deben evaluar [Fecha](../../../sql_reference/data_types/date.md) o [FechaHora](../../../sql_reference/data_types/datetime.md) tipo de datos. - -Ejemplo: - -``` sql -TTL time_column -TTL time_column + interval -``` - -Definir `interval`, utilizar [intervalo de tiempo](../../../sql_reference/operators.md#operators-datetime) operador. - -``` sql -TTL date_time + INTERVAL 1 MONTH -TTL date_time + INTERVAL 15 HOUR -``` - -### Columna TTL {#mergetree-column-ttl} - -Cuando los valores de la columna caducan, ClickHouse los reemplaza con los valores predeterminados para el tipo de datos de columna. Si todos los valores de columna en la parte de datos caducan, ClickHouse elimina esta columna de la parte de datos en un sistema de archivos. - -El `TTL` cláusula no se puede utilizar para columnas clave. - -Ejemplos: - -Creación de una tabla con TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int TTL d + INTERVAL 1 MONTH, - b Int TTL d + INTERVAL 1 MONTH, - c String -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d; -``` - -Adición de TTL a una columna de una tabla existente - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 DAY; -``` - -Modificación de TTL de la columna - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 MONTH; -``` - -### Tabla TTL {#mergetree-table-ttl} - -La tabla puede tener una expresión para la eliminación de filas caducadas y varias expresiones para el movimiento automático de partes entre [discos o volúmenes](#table_engine-mergetree-multiple-volumes). Cuando las filas de la tabla caducan, ClickHouse elimina todas las filas correspondientes. Para la entidad de movimiento de piezas, todas las filas de una pieza deben cumplir los criterios de expresión de movimiento. - -``` sql -TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... -``` - -El tipo de regla TTL puede seguir cada expresión TTL. Afecta a una acción que debe realizarse una vez que se satisface la expresión (alcanza la hora actual): - -- `DELETE` - Eliminar filas caducadas (acción predeterminada); -- `TO DISK 'aaa'` - mover parte al disco `aaa`; -- `TO VOLUME 'bbb'` - mover parte al disco `bbb`. - -Ejemplos: - -Creación de una tabla con TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d -TTL d + INTERVAL 1 MONTH [DELETE], - d + INTERVAL 1 WEEK TO VOLUME 'aaa', - d + INTERVAL 2 WEEK TO DISK 'bbb'; -``` - -Modificación de TTL de la tabla - -``` sql -ALTER TABLE example_table - MODIFY TTL d + INTERVAL 1 DAY; -``` - -**Eliminación de datos** - -Los datos con un TTL caducado se eliminan cuando ClickHouse fusiona partes de datos. - -Cuando ClickHouse ve que los datos han caducado, realiza una combinación fuera de programación. Para controlar la frecuencia de tales fusiones, puede establecer [Método de codificación de datos:](#mergetree_setting-merge_with_ttl_timeout). Si el valor es demasiado bajo, realizará muchas fusiones fuera de horario que pueden consumir muchos recursos. - -Si realiza el `SELECT` consulta entre fusiones, puede obtener datos caducados. Para evitarlo, use el [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) consulta antes `SELECT`. - -## Uso de múltiples dispositivos de bloque para el almacenamiento de datos {#table_engine-mergetree-multiple-volumes} - -### Implantación {#introduction} - -`MergeTree` Los motores de tablas familiares pueden almacenar datos en múltiples dispositivos de bloque. Por ejemplo, puede ser útil cuando los datos de una determinada tabla se dividen implícitamente en “hot” y “cold”. Los datos más recientes se solicitan regularmente, pero solo requieren una pequeña cantidad de espacio. Por el contrario, los datos históricos de cola gorda se solicitan raramente. Si hay varios discos disponibles, el “hot” los datos pueden estar ubicados en discos rápidos (por ejemplo, SSD NVMe o en memoria), mientras que “cold” datos - en los relativamente lentos (por ejemplo, HDD). - -La parte de datos es la unidad móvil mínima para `MergeTree`-mesas de motor. Los datos que pertenecen a una parte se almacenan en un disco. Las partes de datos se pueden mover entre discos en segundo plano (según la configuración del usuario) así como por medio de la [ALTER](../../../sql_reference/statements/alter.md#alter_move-partition) consulta. - -### Plazo {#terms} - -- Disk — Block device mounted to the filesystem. -- Default disk — Disk that stores the path specified in the [camino](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) configuración del servidor. -- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). -- Storage policy — Set of volumes and the rules for moving data between them. - -Los nombres dados a las entidades descritas se pueden encontrar en las tablas del sistema, [sistema.almacenamiento\_policies](../../../operations/system_tables.md#system_tables-storage_policies) y [sistema.disco](../../../operations/system_tables.md#system_tables-disks). Para aplicar una de las directivas de almacenamiento configuradas para una tabla, `storage_policy` establecimiento de `MergeTree`-motor de la familia de las tablas. - -### Configuración {#table_engine-mergetree-multiple-volumes-configure} - -Discos, volúmenes y políticas de almacenamiento deben ser declaradas dentro de la `` etiqueta ya sea en el archivo principal `config.xml` o en un archivo distinto en el `config.d` directorio. - -Configuración de la estructura: - -``` xml - - - - /mnt/fast_ssd/clickhouse/ - - - /mnt/hdd1/clickhouse/ - 10485760 - - - /mnt/hdd2/clickhouse/ - 10485760 - - - ... - - - ... - -``` - -Tags: - -- `` — Disk name. Names must be different for all disks. -- `path` — path under which a server will store data (`data` y `shadow` carpetas), debe terminarse con ‘/’. -- `keep_free_space_bytes` — the amount of free disk space to be reserved. - -El orden de la definición del disco no es importante. - -Marcado de configuración de directivas de almacenamiento: - -``` xml - - ... - - - - - disk_name_from_disks_configuration - 1073741824 - - - - - - - 0.2 - - - - - - - - ... - -``` - -Tags: - -- `policy_name_N` — Policy name. Policy names must be unique. -- `volume_name_N` — Volume name. Volume names must be unique. -- `disk` — a disk within a volume. -- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume's disks. -- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). - -Cofiguration ejemplos: - -``` xml - - ... - - - - - disk1 - disk2 - - - - - - - - fast_ssd - 1073741824 - - - disk1 - - - 0.2 - - - ... - -``` - -En un ejemplo dado, el `hdd_in_order` implementa la política de [Ronda-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) enfoque. Por lo tanto esta política define un sólo volumen (`single`), las partes de datos se almacenan en todos sus discos en orden circular. Dicha política puede ser bastante útil si hay varios discos similares montados en el sistema, pero RAID no está configurado. Tenga en cuenta que cada unidad de disco individual no es confiable y es posible que desee compensarlo con un factor de replicación de 3 o más. - -Si hay diferentes tipos de discos disponibles en el sistema, `moving_from_ssd_to_hdd` la política puede ser utilizado en su lugar. Volumen `hot` consta de un disco SSD (`fast_ssd`), y el tamaño máximo de una parte que puede ser almacenado en este volumen es de 1GB. Todas las piezas con el tamaño de más de 1GB se almacenan directamente en el `cold` volumen, que contiene un disco duro `disk1`. -Además, una vez que el disco `fast_ssd` se llena en más del 80%, los datos se transferirán al `disk1` por un proceso en segundo plano. - -El orden de enumeración de volúmenes dentro de una directiva de almacenamiento es importante. Una vez que un volumen está sobrellenado, los datos se mueven al siguiente. El orden de la enumeración del disco también es importante porque los datos se almacenan en ellos por turnos. - -Al crear una tabla, se puede aplicarle una de las directivas de almacenamiento configuradas: - -``` sql -CREATE TABLE table_with_non_default_policy ( - EventDate Date, - OrderID UInt64, - BannerID UInt64, - SearchPhrase String -) ENGINE = MergeTree -ORDER BY (OrderID, BannerID) -PARTITION BY toYYYYMM(EventDate) -SETTINGS storage_policy = 'moving_from_ssd_to_hdd' -``` - -El `default` política de almacenamiento implica el uso de un solo volumen, que consiste en un solo disco dado en ``. Una vez que se crea una tabla, no se puede cambiar su política de almacenamiento. - -### Detalles {#details} - -En el caso de `MergeTree` tablas, los datos están llegando al disco de diferentes maneras: - -- Como resultado de un inserto (`INSERT` consulta). -- Durante las fusiones de fondo y [mutación](../../../sql_reference/statements/alter.md#alter-mutations). -- Al descargar desde otra réplica. -- Como resultado de la congelación de particiones [ALTER TABLE … FREEZE PARTITION](../../../sql_reference/statements/alter.md#alter_freeze-partition). - -En todos estos casos, excepto las mutaciones y la congelación de particiones, una pieza se almacena en un volumen y un disco de acuerdo con la política de almacenamiento dada: - -1. El primer volumen (en el orden de definición) que tiene suficiente espacio en disco para almacenar una pieza (`unreserved_space > current_part_size`) y permite almacenar partes de un tamaño determinado (`max_data_part_size_bytes > current_part_size`) se elige. -2. Dentro de este volumen, se elige ese disco que sigue al que se utilizó para almacenar el fragmento de datos anterior y que tiene espacio libre más que el tamaño de la pieza (`unreserved_space - keep_free_space_bytes > current_part_size`). - -Bajo el capó, las mutaciones y la congelación de particiones hacen uso de [enlaces duros](https://en.wikipedia.org/wiki/Hard_link). Los enlaces duros entre diferentes discos no son compatibles, por lo tanto, en tales casos las partes resultantes se almacenan en los mismos discos que los iniciales. - -En el fondo, las partes se mueven entre volúmenes en función de la cantidad de espacio libre (`move_factor` parámetro) según el orden en que se declaran los volúmenes en el archivo de configuración. -Los datos nunca se transfieren desde el último y al primero. Uno puede usar tablas del sistema [sistema.part\_log](../../../operations/system_tables.md#system_tables-part-log) (campo `type = MOVE_PART`) y [sistema.parte](../../../operations/system_tables.md#system_tables-parts) (campo `path` y `disk`) para monitorear el fondo se mueve. Además, la información detallada se puede encontrar en los registros del servidor. - -El usuario puede forzar el movimiento de una pieza o una partición de un volumen a otro mediante la consulta [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql_reference/statements/alter.md#alter_move-partition), todas las restricciones para las operaciones en segundo plano se tienen en cuenta. La consulta inicia un movimiento por sí misma y no espera a que se completen las operaciones en segundo plano. El usuario recibirá un mensaje de error si no hay suficiente espacio libre disponible o si no se cumple alguna de las condiciones requeridas. - -Mover datos no interfiere con la replicación de datos. Por lo tanto, se pueden especificar diferentes directivas de almacenamiento para la misma tabla en diferentes réplicas. - -Después de la finalización de las fusiones y mutaciones de fondo, las partes viejas se eliminan solo después de un cierto período de tiempo (`old_parts_lifetime`). -Durante este tiempo, no se mueven a otros volúmenes o discos. Por lo tanto, hasta que finalmente se retira, se tomará en cuenta para la evaluación de los ocupados de espacio en disco. - -[Artículo Original](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/es/engines/table_engines/mergetree_family/replacingmergetree.md b/docs/es/engines/table_engines/mergetree_family/replacingmergetree.md deleted file mode 100644 index 09aa311d9c6..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/replacingmergetree.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 33 -toc_title: ReplacingMergeTree ---- - -# Replacingmergetree {#replacingmergetree} - -El motor difiere de [Método de codificación de datos:](mergetree.md#table_engines-mergetree) en que elimina las entradas duplicadas con el mismo valor de clave principal (o más exactamente, con el mismo [clave de clasificación](mergetree.md) valor). - -La desduplicación de datos solo se produce durante una fusión. La fusión ocurre en segundo plano en un momento desconocido, por lo que no puede planificarla. Algunos de los datos pueden permanecer sin procesar. Aunque puede ejecutar una fusión no programada utilizando el `OPTIMIZE` consulta, no cuente con usarlo, porque el `OPTIMIZE` consulta leerá y escribirá una gran cantidad de datos. - -Así, `ReplacingMergeTree` es adecuado para borrar datos duplicados en segundo plano para ahorrar espacio, pero no garantiza la ausencia de duplicados. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = ReplacingMergeTree([ver]) -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Para obtener una descripción de los parámetros de solicitud, consulte [descripción de la solicitud](../../../sql_reference/statements/create.md). - -**ReplacingMergeTree Parámetros** - -- `ver` — column with version. Type `UInt*`, `Date` o `DateTime`. Parámetro opcional. - - Al fusionar, `ReplacingMergeTree` de todas las filas con la misma clave primaria deja solo una: - - - Último en la selección, si `ver` no establecido. - - Con la versión máxima, si `ver` indicado. - -**Cláusulas de consulta** - -Al crear un `ReplacingMergeTree` mesa de la misma [clausula](mergetree.md) se requieren, como al crear un `MergeTree` tabla. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) -``` - -Todos los parámetros excepto `ver` el mismo significado que en `MergeTree`. - -- `ver` - columna con la versión. Parámetro opcional. Para una descripción, vea el texto anterior. - -
- -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/es/engines/table_engines/mergetree_family/replication.md b/docs/es/engines/table_engines/mergetree_family/replication.md deleted file mode 100644 index c84014225d0..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/replication.md +++ /dev/null @@ -1,218 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 31 -toc_title: "Replicaci\xF3n de datos" ---- - -# Replicación de datos {#table_engines-replication} - -La replicación solo se admite para tablas de la familia MergeTree: - -- ReplicatedMergeTree -- ReplicatedSummingMergeTree -- ReplicatedReplacingMergeTree -- ReplicatedAggregatingMergeTree -- ReplicatedCollapsingMergeTree -- ReplicatedVersionedCollapsingMergetree -- ReplicatedGraphiteMergeTree - -La replicación funciona a nivel de una tabla individual, no de todo el servidor. Un servidor puede almacenar tablas replicadas y no replicadas al mismo tiempo. - -La replicación no depende de la fragmentación. Cada fragmento tiene su propia replicación independiente. - -Datos comprimidos para `INSERT` y `ALTER` se replica (para obtener más información, consulte la documentación para [ALTER](../../../sql_reference/statements/alter.md#query_language_queries_alter)). - -`CREATE`, `DROP`, `ATTACH`, `DETACH` y `RENAME` las consultas se ejecutan en un único servidor y no se replican: - -- El `CREATE TABLE` query crea una nueva tabla replicable en el servidor donde se ejecuta la consulta. Si esta tabla ya existe en otros servidores, agrega una nueva réplica. -- El `DROP TABLE` query elimina la réplica ubicada en el servidor donde se ejecuta la consulta. -- El `RENAME` query cambia el nombre de la tabla en una de las réplicas. En otras palabras, las tablas replicadas pueden tener diferentes nombres en diferentes réplicas. - -Uso de ClickHouse [Apache ZooKeeper](https://zookeeper.apache.org) para almacenar metainformación de réplicas. Utilice ZooKeeper versión 3.4.5 o posterior. - -Para utilizar la replicación, establezca los parámetros [Zookeeper](../../../operations/server_configuration_parameters/settings.md#server-settings_zookeeper) sección de configuración del servidor. - -!!! attention "Atención" - No descuides la configuración de seguridad. ClickHouse soporta el `digest` [Esquema de ACL](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) del subsistema de seguridad ZooKeeper. - -Ejemplo de configuración de las direcciones del clúster ZooKeeper: - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - - example3 - 2181 - - -``` - -Puede especificar cualquier clúster ZooKeeper existente y el sistema utilizará un directorio en él para sus propios datos (el directorio se especifica al crear una tabla replicable). - -Si ZooKeeper no está establecido en el archivo de configuración, no puede crear tablas replicadas y las tablas replicadas existentes serán de solo lectura. - -ZooKeeper no se utiliza en `SELECT` consultas porque la replicación no afecta al rendimiento de `SELECT` y las consultas se ejecutan tan rápido como lo hacen para las tablas no replicadas. Al consultar tablas replicadas distribuidas, el comportamiento de ClickHouse se controla mediante la configuración [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) y [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). - -Para cada `INSERT` consulta, aproximadamente diez entradas se agregan a ZooKeeper a través de varias transacciones. (Para ser más precisos, esto es para cada bloque de datos insertado; una consulta INSERT contiene un bloque o un bloque por `max_insert_block_size = 1048576` filas.) Esto conduce a latencias ligeramente más largas para `INSERT` en comparación con las tablas no replicadas. Pero si sigue las recomendaciones para insertar datos en lotes de no más de uno `INSERT` por segundo, no crea ningún problema. Todo el clúster ClickHouse utilizado para coordinar un clúster ZooKeeper tiene un total de varios cientos `INSERTs` por segundo. El rendimiento en las inserciones de datos (el número de filas por segundo) es tan alto como para los datos no replicados. - -Para clústeres muy grandes, puede usar diferentes clústeres de ZooKeeper para diferentes fragmentos. Sin embargo, esto no ha demostrado ser necesario en el Yandex.Clúster Metrica (aproximadamente 300 servidores). - -La replicación es asíncrona y multi-master. `INSERT` consultas (así como `ALTER`) se puede enviar a cualquier servidor disponible. Los datos se insertan en el servidor donde se ejecuta la consulta y, a continuación, se copian a los demás servidores. Debido a que es asincrónico, los datos insertados recientemente aparecen en las otras réplicas con cierta latencia. Si parte de las réplicas no está disponible, los datos se escriben cuando estén disponibles. Si hay una réplica disponible, la latencia es la cantidad de tiempo que tarda en transferir el bloque de datos comprimidos a través de la red. - -De forma predeterminada, una consulta INSERT espera la confirmación de la escritura de los datos de una sola réplica. Si los datos fue correctamente escrito a sólo una réplica y el servidor con esta réplica deja de existir, los datos almacenados se perderán. Para habilitar la confirmación de las escrituras de datos de varias réplicas, utilice `insert_quorum` opcion. - -Cada bloque de datos se escribe atómicamente. La consulta INSERT se divide en bloques hasta `max_insert_block_size = 1048576` filas. En otras palabras, si el `INSERT` consulta tiene menos de 1048576 filas, se hace atómicamente. - -Los bloques de datos se deduplican. Para varias escrituras del mismo bloque de datos (bloques de datos del mismo tamaño que contienen las mismas filas en el mismo orden), el bloque solo se escribe una vez. La razón de esto es en caso de fallas de red cuando la aplicación cliente no sabe si los datos se escribieron en la base de datos, por lo que `INSERT` consulta simplemente se puede repetir. No importa a qué réplica se enviaron los INSERT con datos idénticos. `INSERTs` son idempotentes. Los parámetros de desduplicación son controlados por [merge\_tree](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-merge_tree) configuración del servidor. - -Durante la replicación, sólo los datos de origen que se van a insertar se transfieren a través de la red. La transformación de datos adicional (fusión) se coordina y se realiza en todas las réplicas de la misma manera. Esto minimiza el uso de la red, lo que significa que la replicación funciona bien cuando las réplicas residen en centros de datos diferentes. (Tenga en cuenta que la duplicación de datos en diferentes centros de datos es el objetivo principal de la replicación.) - -Puede tener cualquier número de réplicas de los mismos datos. El Yandex.Metrica utiliza doble replicación en producción. Cada servidor utiliza RAID-5 o RAID-6, y RAID-10 en algunos casos. Esta es una solución relativamente confiable y conveniente. - -El sistema supervisa la sincronicidad de los datos en las réplicas y puede recuperarse después de un fallo. La conmutación por error es automática (para pequeñas diferencias en los datos) o semiautomática (cuando los datos difieren demasiado, lo que puede indicar un error de configuración). - -## Creación de tablas replicadas {#creating-replicated-tables} - -El `Replicated` prefijo se agrega al nombre del motor de tabla. Por ejemplo:`ReplicatedMergeTree`. - -**Replicated\*MergeTree parámetros** - -- `zoo_path` — The path to the table in ZooKeeper. -- `replica_name` — The replica name in ZooKeeper. - -Ejemplo: - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -``` - -
- -Ejemplo en sintaxis obsoleta - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) -``` - -
- -Como muestra el ejemplo, estos parámetros pueden contener sustituciones entre llaves. Los valores sustituidos se toman de la ‘macros’ sección del archivo de configuración. Ejemplo: - -``` xml - - 05 - 02 - example05-02-1.yandex.ru - -``` - -La ruta de acceso a la tabla en ZooKeeper debe ser única para cada tabla replicada. Las tablas en diferentes fragmentos deben tener rutas diferentes. -En este caso, la ruta consta de las siguientes partes: - -`/clickhouse/tables/` es el prefijo común. Recomendamos usar exactamente este. - -`{layer}-{shard}` es el identificador de fragmento. En este ejemplo consta de dos partes, ya que el Yandex.Metrica clúster utiliza sharding de dos niveles. Para la mayoría de las tareas, puede dejar solo la sustitución {shard}, que se expandirá al identificador de fragmento. - -`table_name` es el nombre del nodo de la tabla en ZooKeeper. Es una buena idea hacerlo igual que el nombre de la tabla. Se define explícitamente, porque a diferencia del nombre de la tabla, no cambia después de una consulta RENAME. -*HINT*: podría agregar un nombre de base de datos delante de `table_name` También. Nivel de Cifrado WEP `db_name.table_name` - -El nombre de réplica identifica diferentes réplicas de la misma tabla. Puede usar el nombre del servidor para esto, como en el ejemplo. El nombre solo tiene que ser único dentro de cada fragmento. - -Puede definir los parámetros explícitamente en lugar de utilizar sustituciones. Esto podría ser conveniente para probar y para configurar clústeres pequeños. Sin embargo, no puede usar consultas DDL distribuidas (`ON CLUSTER` en este caso. - -Cuando se trabaja con clústeres grandes, se recomienda utilizar sustituciones porque reducen la probabilidad de error. - -Ejecute el `CREATE TABLE` consulta en cada réplica. Esta consulta crea una nueva tabla replicada o agrega una nueva réplica a una existente. - -Si agrega una nueva réplica después de que la tabla ya contenga algunos datos en otras réplicas, los datos se copiarán de las otras réplicas a la nueva después de ejecutar la consulta. En otras palabras, la nueva réplica se sincroniza con las demás. - -Para eliminar una réplica, ejecute `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. - -## Recuperación después de fallos {#recovery-after-failures} - -Si ZooKeeper no está disponible cuando se inicia un servidor, las tablas replicadas cambian al modo de solo lectura. El sistema intenta conectarse periódicamente a ZooKeeper. - -Si ZooKeeper no está disponible durante un `INSERT`, o se produce un error al interactuar con ZooKeeper, se produce una excepción. - -Después de conectarse a ZooKeeper, el sistema comprueba si el conjunto de datos en el sistema de archivos local coincide con el conjunto de datos esperado (ZooKeeper almacena esta información). Si hay incoherencias menores, el sistema las resuelve sincronizando datos con las réplicas. - -Si el sistema detecta partes de datos rotas (con un tamaño incorrecto de archivos) o partes no reconocidas (partes escritas en el sistema de archivos pero no grabadas en ZooKeeper), las mueve al `detached` subdirectorio (no se eliminan). Las piezas que faltan se copian de las réplicas. - -Tenga en cuenta que ClickHouse no realiza ninguna acción destructiva, como eliminar automáticamente una gran cantidad de datos. - -Cuando el servidor se inicia (o establece una nueva sesión con ZooKeeper), solo verifica la cantidad y el tamaño de todos los archivos. Si los tamaños de los archivos coinciden pero los bytes se han cambiado en algún punto intermedio, esto no se detecta inmediatamente, sino solo cuando se intenta leer los datos `SELECT` consulta. La consulta produce una excepción sobre una suma de comprobación no coincidente o el tamaño de un bloque comprimido. En este caso, las partes de datos se agregan a la cola de verificación y se copian de las réplicas si es necesario. - -Si el conjunto local de datos difiere demasiado del esperado, se activa un mecanismo de seguridad. El servidor ingresa esto en el registro y se niega a iniciarse. La razón de esto es que este caso puede indicar un error de configuración, como si una réplica en un fragmento se configurara accidentalmente como una réplica en un fragmento diferente. Sin embargo, los umbrales para este mecanismo se establecen bastante bajos, y esta situación puede ocurrir durante la recuperación de falla normal. En este caso, los datos se restauran semiautomáticamente, mediante “pushing a button”. - -Para iniciar la recuperación, cree el nodo `/path_to_table/replica_name/flags/force_restore_data` en ZooKeeper con cualquier contenido, o ejecute el comando para restaurar todas las tablas replicadas: - -``` bash -sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data -``` - -A continuación, reinicie el servidor. Al iniciar, el servidor elimina estos indicadores e inicia la recuperación. - -## Recuperación después de la pérdida completa de datos {#recovery-after-complete-data-loss} - -Si todos los datos y metadatos desaparecieron de uno de los servidores, siga estos pasos para la recuperación: - -1. Instale ClickHouse en el servidor. Defina correctamente las sustituciones en el archivo de configuración que contiene el identificador de fragmento y las réplicas, si las usa. -2. Si tenía tablas no duplicadas que deben duplicarse manualmente en los servidores, copie sus datos desde una réplica (en el directorio `/var/lib/clickhouse/data/db_name/table_name/`). -3. Copiar definiciones de tablas ubicadas en `/var/lib/clickhouse/metadata/` de una réplica. Si un identificador de fragmento o réplica se define explícitamente en las definiciones de tabla, corríjalo para que corresponda a esta réplica. (Como alternativa, inicie el servidor y `ATTACH TABLE` consultas que deberían haber estado en el .sql archivos en `/var/lib/clickhouse/metadata/`.) -4. Para iniciar la recuperación, cree el nodo ZooKeeper `/path_to_table/replica_name/flags/force_restore_data` con cualquier contenido o ejecute el comando para restaurar todas las tablas replicadas: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` - -Luego inicie el servidor (reinicie, si ya se está ejecutando). Los datos se descargarán de las réplicas. - -Una opción de recuperación alternativa es eliminar información sobre la réplica perdida de ZooKeeper (`/path_to_table/replica_name`), luego vuelva a crear la réplica como se describe en “[Creación de tablas replicadas](#creating-replicated-tables)”. - -No hay restricción en el ancho de banda de la red durante la recuperación. Tenga esto en cuenta si está restaurando muchas réplicas a la vez. - -## La Conversión De Mergetree A Replicatedmergetree {#converting-from-mergetree-to-replicatedmergetree} - -Usamos el término `MergeTree` para referirse a todos los motores de mesa en el `MergeTree family`, lo mismo que para `ReplicatedMergeTree`. - -Si usted tenía un `MergeTree` tabla replicada manualmente, puede convertirla en una tabla replicada. Es posible que tenga que hacer esto si ya ha recopilado una gran cantidad de datos `MergeTree` y ahora desea habilitar la replicación. - -Si los datos difieren en varias réplicas, primero sincronícelos o elimínelos en todas las réplicas, excepto en una. - -Cambie el nombre de la tabla MergeTree existente y, a continuación, cree un `ReplicatedMergeTree` mesa con el antiguo nombre. -Mueva los datos de la tabla antigua a la `detached` subdirectorio dentro del directorio con los nuevos datos de la tabla (`/var/lib/clickhouse/data/db_name/table_name/`). -Luego ejecuta `ALTER TABLE ATTACH PARTITION` en una de las réplicas para agregar estas partes de datos al conjunto de trabajo. - -## La Conversión De Replicatedmergetree A Mergetree {#converting-from-replicatedmergetree-to-mergetree} - -Cree una tabla MergeTree con un nombre diferente. Mueva todos los datos del directorio con el `ReplicatedMergeTree` datos de la tabla al directorio de datos de la nueva tabla. A continuación, elimine el `ReplicatedMergeTree` y reinicie el servidor. - -Si desea deshacerse de un `ReplicatedMergeTree` sin iniciar el servidor: - -- Eliminar el correspondiente `.sql` archivo en el directorio de metadatos (`/var/lib/clickhouse/metadata/`). -- Eliminar la ruta correspondiente en ZooKeeper (`/path_to_table/replica_name`). - -Después de esto, puede iniciar el servidor, crear un `MergeTree` tabla, mueva los datos a su directorio y, a continuación, reinicie el servidor. - -## Recuperación cuando los metadatos en el clúster de Zookeeper se pierden o se dañan {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} - -Si los datos de ZooKeeper se perdieron o se dañaron, puede guardar los datos moviéndolos a una tabla no duplicada como se describió anteriormente. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/es/engines/table_engines/mergetree_family/summingmergetree.md b/docs/es/engines/table_engines/mergetree_family/summingmergetree.md deleted file mode 100644 index 1e3241938f3..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/summingmergetree.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 34 -toc_title: SummingMergeTree ---- - -# Summingmergetree {#summingmergetree} - -El motor hereda de [Método de codificación de datos:](mergetree.md#table_engines-mergetree). La diferencia es que al fusionar partes de datos para `SummingMergeTree` ClickHouse reemplaza todas las filas con la misma clave primaria (o más exactamente, con la misma [clave de clasificación](mergetree.md)) con una fila que contiene valores resumidos para las columnas con el tipo de datos numérico. Si la clave de ordenación está compuesta de manera que un solo valor de clave corresponde a un gran número de filas, esto reduce significativamente el volumen de almacenamiento y acelera la selección de datos. - -Recomendamos usar el motor junto con `MergeTree`. Almacenar datos completos en `MergeTree` mesa, y el uso `SummingMergeTree` para el almacenamiento de datos agregados, por ejemplo, al preparar informes. Tal enfoque evitará que pierda datos valiosos debido a una clave primaria compuesta incorrectamente. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = SummingMergeTree([columns]) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Para obtener una descripción de los parámetros de solicitud, consulte [descripción de la solicitud](../../../sql_reference/statements/create.md). - -**Parámetros de SummingMergeTree** - -- `columns` - una tupla con los nombres de las columnas donde se resumirán los valores. Parámetro opcional. - Las columnas deben ser de tipo numérico y no deben estar en la clave principal. - - Si `columns` no especificado, ClickHouse resume los valores de todas las columnas con un tipo de datos numérico que no están en la clave principal. - -**Cláusulas de consulta** - -Al crear un `SummingMergeTree` mesa de la misma [clausula](mergetree.md) se requieren, como al crear un `MergeTree` tabla. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No use este método en proyectos nuevos y, si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) -``` - -Todos los parámetros excepto `columns` el mismo significado que en `MergeTree`. - -- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. - -
- -## Ejemplo de uso {#usage-example} - -Considere la siguiente tabla: - -``` sql -CREATE TABLE summtt -( - key UInt32, - value UInt32 -) -ENGINE = SummingMergeTree() -ORDER BY key -``` - -Insertar datos: - -``` sql -INSERT INTO summtt Values(1,1),(1,2),(2,1) -``` - -ClickHouse puede sumar todas las filas no completamente ([ver abajo](#data-processing)), entonces usamos una función agregada `sum` y `GROUP BY` cláusula en la consulta. - -``` sql -SELECT key, sum(value) FROM summtt GROUP BY key -``` - -``` text -┌─key─┬─sum(value)─┐ -│ 2 │ 1 │ -│ 1 │ 3 │ -└─────┴────────────┘ -``` - -## Procesamiento de datos {#data-processing} - -Cuando los datos se insertan en una tabla, se guardan tal cual. Clickhouse fusiona las partes insertadas de datos periódicamente y esto es cuando las filas con la misma clave principal se suman y se reemplazan con una para cada parte resultante de los datos. - -ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) una función agregada [resumir()](../../../sql_reference/aggregate_functions/reference.md#agg_function-sum) y `GROUP BY` cláusula se debe utilizar en una consulta como se describe en el ejemplo anterior. - -### Reglas comunes para la suma {#common-rules-for-summation} - -Se resumen los valores de las columnas con el tipo de datos numérico. El conjunto de columnas está definido por el parámetro `columns`. - -Si los valores eran 0 en todas las columnas para la suma, se elimina la fila. - -Si la columna no está en la clave principal y no se resume, se selecciona un valor arbitrario entre los existentes. - -Los valores no se resumen para las columnas de la clave principal. - -### La suma en las columnas de función agregada {#the-summation-in-the-aggregatefunction-columns} - -Para columnas de [Tipo AggregateFunction](../../../sql_reference/data_types/aggregatefunction.md) ClickHouse se comporta como [AgregaciónMergeTree](aggregatingmergetree.md) agregación del motor según la función. - -### Estructuras anidadas {#nested-structures} - -La tabla puede tener estructuras de datos anidadas que se procesan de una manera especial. - -Si el nombre de una tabla anidada termina con `Map` y contiene al menos dos columnas que cumplen los siguientes criterios: - -- la primera columna es numérica `(*Int*, Date, DateTime)` o una cadena `(String, FixedString)`, vamos a llamarlo `key`, -- las otras columnas son aritméticas `(*Int*, Float32/64)`, vamos a llamarlo `(values...)`, - -entonces esta tabla anidada se interpreta como una asignación de `key => (values...)`, y al fusionar sus filas, los elementos de dos conjuntos de datos se fusionan por `key` con una suma de los correspondientes `(values...)`. - -Ejemplos: - -``` text -[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] -[(1, 100)] + [(1, 150)] -> [(1, 250)] -[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] -[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] -``` - -Al solicitar datos, utilice el [sumMap(clave, valor)](../../../sql_reference/aggregate_functions/reference.md) función para la agregación de `Map`. - -Para la estructura de datos anidados, no necesita especificar sus columnas en la tupla de columnas para la suma. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/es/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md b/docs/es/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md deleted file mode 100644 index e21ccc842f3..00000000000 --- a/docs/es/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 37 -toc_title: VersionedCollapsingMergeTree ---- - -# Versionedcollapsingmergetree {#versionedcollapsingmergetree} - -Este motor: - -- Permite la escritura rápida de estados de objetos que cambian continuamente. -- Elimina los estados de objetos antiguos en segundo plano. Esto reduce significativamente el volumen de almacenamiento. - -Vea la sección [Derrumbar](#table_engines_versionedcollapsingmergetree) para más detalles. - -El motor hereda de [Método de codificación de datos:](mergetree.md#table_engines-mergetree) y agrega la lógica para colapsar filas al algoritmo para fusionar partes de datos. `VersionedCollapsingMergeTree` tiene el mismo propósito que [ColapsarMergeTree](collapsingmergetree.md) pero usa un algoritmo de colapso diferente que permite insertar los datos en cualquier orden con múltiples hilos. En particular, el `Version` columna ayuda a contraer las filas correctamente, incluso si se insertan en el orden incorrecto. En contraste, `CollapsingMergeTree` sólo permite la inserción estrictamente consecutiva. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = VersionedCollapsingMergeTree(sign, version) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Para obtener una descripción de los parámetros de consulta, consulte [descripción de la consulta](../../../sql_reference/statements/create.md). - -**Parámetros del motor** - -``` sql -VersionedCollapsingMergeTree(sign, version) -``` - -- `sign` — Name of the column with the type of row: `1` es una “state” fila, `-1` es una “cancel” fila. - - El tipo de datos de columna debe ser `Int8`. - -- `version` — Name of the column with the version of the object state. - - El tipo de datos de columna debe ser `UInt*`. - -**Cláusulas de consulta** - -Al crear un `VersionedCollapsingMergeTree` mesa, la misma [clausula](mergetree.md) se requieren como al crear un `MergeTree` tabla. - -
- -Método obsoleto para crear una tabla - -!!! attention "Atención" - No utilice este método en nuevos proyectos. Si es posible, cambie los proyectos antiguos al método descrito anteriormente. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] VersionedCollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign, version) -``` - -Todos los parámetros excepto `sign` y `version` el mismo significado que en `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` es una “state” fila, `-1` es una “cancel” fila. - - Column Data Type — `Int8`. - -- `version` — Name of the column with the version of the object state. - - El tipo de datos de columna debe ser `UInt*`. - -
- -## Derrumbar {#table_engines-versionedcollapsingmergetree} - -### Datos {#data} - -Considere una situación en la que necesite guardar datos que cambien continuamente para algún objeto. Es razonable tener una fila para un objeto y actualizar la fila siempre que haya cambios. Sin embargo, la operación de actualización es costosa y lenta para un DBMS porque requiere volver a escribir los datos en el almacenamiento. La actualización no es aceptable si necesita escribir datos rápidamente, pero puede escribir los cambios en un objeto secuencialmente de la siguiente manera. - -Utilice el `Sign` columna al escribir la fila. Si `Sign = 1` significa que la fila es un estado de un objeto (llamémoslo el “state” fila). Si `Sign = -1` indica la cancelación del estado de un objeto con los mismos atributos (llamémoslo el “cancel” fila). También use el `Version` columna, que debe identificar cada estado de un objeto con un número separado. - -Por ejemplo, queremos calcular cuántas páginas visitaron los usuarios en algún sitio y cuánto tiempo estuvieron allí. En algún momento escribimos la siguiente fila con el estado de la actividad del usuario: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -En algún momento después registramos el cambio de actividad del usuario y lo escribimos con las siguientes dos filas. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -La primera fila cancela el estado anterior del objeto (usuario). Debe copiar todos los campos del estado cancelado excepto `Sign`. - -La segunda fila contiene el estado actual. - -Debido a que solo necesitamos el último estado de actividad del usuario, las filas - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -se puede eliminar, colapsando el estado no válido (antiguo) del objeto. `VersionedCollapsingMergeTree` hace esto mientras fusiona las partes de datos. - -Para averiguar por qué necesitamos dos filas para cada cambio, vea [Algoritmo](#table_engines-versionedcollapsingmergetree-algorithm). - -**Notas sobre el uso** - -1. El programa que escribe los datos debe recordar el estado de un objeto para cancelarlo. El “cancel” cadena debe ser una copia de la “state” con lo opuesto `Sign`. Esto aumenta el tamaño inicial de almacenamiento, pero permite escribir los datos rápidamente. -2. Las matrices de largo crecimiento en columnas reducen la eficiencia del motor debido a la carga para escribir. Cuanto más sencillos sean los datos, mejor será la eficiencia. -3. `SELECT` Los resultados dependen en gran medida de la coherencia del historial de cambios de objetos. Sea preciso al preparar los datos para insertarlos. Puede obtener resultados impredecibles con datos incoherentes, como valores negativos para métricas no negativas, como la profundidad de la sesión. - -### Algoritmo {#table_engines-versionedcollapsingmergetree-algorithm} - -Cuando ClickHouse combina partes de datos, elimina cada par de filas que tienen la misma clave principal y versión y diferentes `Sign`. El orden de las filas no importa. - -Cuando ClickHouse inserta datos, ordena filas por la clave principal. Si el `Version` la columna no está en la clave principal, ClickHouse la agrega a la clave principal implícitamente como el último campo y la usa para ordenar. - -## Selección de datos {#selecting-data} - -ClickHouse no garantiza que todas las filas con la misma clave principal estén en la misma parte de datos resultante o incluso en el mismo servidor físico. Esto es cierto tanto para escribir los datos como para la posterior fusión de las partes de datos. Además, ClickHouse procesa `SELECT` consultas con múltiples subprocesos, y no puede predecir el orden de las filas en el resultado. Esto significa que la agregación es necesaria si hay una necesidad de obtener completamente “collapsed” datos de un `VersionedCollapsingMergeTree` tabla. - -Para finalizar el colapso, escriba una consulta con un `GROUP BY` cláusula y funciones agregadas que representan el signo. Por ejemplo, para calcular la cantidad, use `sum(Sign)` en lugar de `count()`. Para calcular la suma de algo, use `sum(Sign * x)` en lugar de `sum(x)` y agregar `HAVING sum(Sign) > 0`. - -Los agregados `count`, `sum` y `avg` se puede calcular de esta manera. El agregado `uniq` se puede calcular si un objeto tiene al menos un estado no colapsado. Los agregados `min` y `max` no se puede calcular porque `VersionedCollapsingMergeTree` no guarda el historial de valores de estados colapsados. - -Si necesita extraer los datos con “collapsing” pero sin agregación (por ejemplo, para verificar si hay filas presentes cuyos valores más nuevos coinciden con ciertas condiciones), puede usar el `FINAL` modificador para el `FROM` clausula. Este enfoque es ineficiente y no debe usarse con tablas grandes. - -## Ejemplo de uso {#example-of-use} - -Datos de ejemplo: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Creación de la tabla: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8, - Version UInt8 -) -ENGINE = VersionedCollapsingMergeTree(Sign, Version) -ORDER BY UserID -``` - -Insertar los datos: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) -``` - -Usamos dos `INSERT` consultas para crear dos partes de datos diferentes. Si insertamos los datos con una sola consulta, ClickHouse crea una parte de datos y nunca realizará ninguna fusión. - -Obtener los datos: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -¿qué vemos aquí y dónde están las partes colapsadas? -Creamos dos partes de datos usando dos `INSERT` consulta. El `SELECT` la consulta se realizó en dos subprocesos, y el resultado es un orden aleatorio de filas. -No se produjo el colapso porque las partes de datos aún no se han fusionado. ClickHouse fusiona partes de datos en un punto desconocido en el tiempo que no podemos predecir. - -Es por eso que necesitamos agregación: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration, - Version -FROM UAct -GROUP BY UserID, Version -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 2 │ -└─────────────────────┴───────────┴──────────┴─────────┘ -``` - -Si no necesitamos agregación y queremos forzar el colapso, podemos usar el `FINAL` modificador para el `FROM` clausula. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Esta es una forma muy ineficiente de seleccionar datos. No lo use para mesas grandes. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/es/engines/table_engines/special/buffer.md b/docs/es/engines/table_engines/special/buffer.md deleted file mode 100644 index 0a869d556b8..00000000000 --- a/docs/es/engines/table_engines/special/buffer.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 45 -toc_title: "B\xFAfer" ---- - -# Búfer {#buffer} - -Almacena los datos para escribir en la memoria RAM, enjuagándolos periódicamente a otra tabla. Durante la operación de lectura, los datos se leen desde el búfer y la otra tabla simultáneamente. - -``` sql -Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) -``` - -Parámetros del motor: - -- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. -- `table` – Table to flush data to. -- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` de búferes independientes. Valor recomendado: 16. -- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, y `max_bytes` – Conditions for flushing data from the buffer. - -Los datos se vacían del búfer y se escriben en la tabla de destino si `min*` condiciones o al menos una `max*` condición se cumplen. - -- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. -- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. -- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. - -Durante la operación de escritura, los datos se insertan en un `num_layers` número de búferes aleatorios. O bien, si la parte de datos para insertar es lo suficientemente grande (mayor que `max_rows` o `max_bytes`), se escribe directamente en la tabla de destino, omitiendo el búfer. - -Las condiciones para el lavado de los datos se calculan por separado para cada uno de los `num_layers` búfer. Por ejemplo, si `num_layers = 16` y `max_bytes = 100000000`, el consumo máximo de RAM es de 1.6 GB. - -Ejemplo: - -``` sql -CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) -``` - -Creación de un ‘merge.hits\_buffer’ mesa con la misma estructura que ‘merge.hits’ y usando el motor Buffer. Al escribir en esta tabla, los datos se almacenan en la memoria RAM y ‘merge.hits’ tabla. Se crean 16 búferes. Los datos de cada uno de ellos se vacían si han pasado 100 segundos o se han escrito un millón de filas o se han escrito 100 MB de datos; o si simultáneamente han pasado 10 segundos y se han escrito 10.000 filas y 10 MB de datos. Por ejemplo, si solo se ha escrito una fila, después de 100 segundos se vaciará, pase lo que pase. Pero si se han escrito muchas filas, los datos se vaciarán antes. - -Cuando se detiene el servidor, con DROP TABLE o DETACH TABLE, los datos del búfer también se vacían a la tabla de destino. - -Puede establecer cadenas vacías entre comillas simples para la base de datos y el nombre de la tabla. Esto indica la ausencia de una tabla de destino. En este caso, cuando se alcanzan las condiciones de descarga de datos, el búfer simplemente se borra. Esto puede ser útil para mantener una ventana de datos en la memoria. - -Al leer desde una tabla de búfer, los datos se procesan tanto desde el búfer como desde la tabla de destino (si hay uno). -Tenga en cuenta que las tablas Buffer no admiten un índice. En otras palabras, los datos del búfer se analizan por completo, lo que puede ser lento para los búferes grandes. (Para los datos de una tabla subordinada, se utilizará el índice que admite.) - -Si el conjunto de columnas de la tabla Buffer no coincide con el conjunto de columnas de una tabla subordinada, se inserta un subconjunto de columnas que existen en ambas tablas. - -Si los tipos no coinciden con una de las columnas de la tabla Búfer y una tabla subordinada, se escribe un mensaje de error en el registro del servidor y se borra el búfer. -Lo mismo sucede si la tabla subordinada no existe cuando se vacía el búfer. - -Si necesita ejecutar ALTER para una tabla subordinada y la tabla de búfer, se recomienda eliminar primero la tabla de búfer, ejecutar ALTER para la tabla subordinada y, a continuación, crear la tabla de búfer de nuevo. - -Si el servidor se reinicia de forma anormal, se pierden los datos del búfer. - -FINAL y SAMPLE no funcionan correctamente para las tablas Buffer. Estas condiciones se pasan a la tabla de destino, pero no se utilizan para procesar datos en el búfer. Si se requieren estas características, recomendamos usar solo la tabla Buffer para escribir, mientras lee desde la tabla de destino. - -Al agregar datos a un búfer, uno de los búferes está bloqueado. Esto provoca retrasos si se realiza una operación de lectura simultáneamente desde la tabla. - -Los datos que se insertan en una tabla de búfer pueden terminar en la tabla subordinada en un orden diferente y en bloques diferentes. Debido a esto, una tabla Buffer es difícil de usar para escribir en un CollapsingMergeTree correctamente. Para evitar problemas, puede establecer ‘num\_layers’ a 1. - -Si se replica la tabla de destino, se pierden algunas características esperadas de las tablas replicadas al escribir en una tabla de búfer. Los cambios aleatorios en el orden de las filas y los tamaños de las partes de datos hacen que la desduplicación de datos deje de funcionar, lo que significa que no es posible tener un ‘exactly once’ escribir en tablas replicadas. - -Debido a estas desventajas, solo podemos recomendar el uso de una tabla Buffer en casos raros. - -Una tabla de búfer se usa cuando se reciben demasiados INSERT de un gran número de servidores durante una unidad de tiempo y los datos no se pueden almacenar en búfer antes de la inserción, lo que significa que los INSERT no pueden ejecutarse lo suficientemente rápido. - -Tenga en cuenta que no tiene sentido insertar datos una fila a la vez, incluso para las tablas de búfer. Esto solo producirá una velocidad de unos pocos miles de filas por segundo, mientras que la inserción de bloques de datos más grandes puede producir más de un millón de filas por segundo (consulte la sección “Performance”). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/es/engines/table_engines/special/dictionary.md b/docs/es/engines/table_engines/special/dictionary.md deleted file mode 100644 index 13e091be699..00000000000 --- a/docs/es/engines/table_engines/special/dictionary.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 35 -toc_title: Diccionario ---- - -# Diccionario {#dictionary} - -El `Dictionary` el motor muestra el [diccionario](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) datos como una tabla ClickHouse. - -Como ejemplo, considere un diccionario de `products` con la siguiente configuración: - -``` xml - - - products - - -
products
- DSN=some-db-server - - - - 300 - 360 - - - - - - - product_id - - - title - String - - - - - -``` - -Consultar los datos del diccionario: - -``` sql -SELECT - name, - type, - key, - attribute.names, - attribute.types, - bytes_allocated, - element_count, - source -FROM system.dictionaries -WHERE name = 'products' -``` - -``` text -┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ -│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ -└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ -``` - -Puede usar el [dictGet\*](../../../sql_reference/functions/ext_dict_functions.md#ext_dict_functions) función para obtener los datos del diccionario en este formato. - -Esta vista no es útil cuando necesita obtener datos sin procesar o cuando `JOIN` operación. Para estos casos, puede usar el `Dictionary` motor, que muestra los datos del diccionario en una tabla. - -Sintaxis: - -``` sql -CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` -``` - -Ejemplo de uso: - -``` sql -create table products (product_id UInt64, title String) Engine = Dictionary(products); -``` - - Ok - -Echa un vistazo a lo que hay en la mesa. - -``` sql -select * from products limit 1; -``` - -``` text -┌────product_id─┬─title───────────┐ -│ 152689 │ Some item │ -└───────────────┴─────────────────┘ -``` - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/es/engines/table_engines/special/distributed.md b/docs/es/engines/table_engines/special/distributed.md deleted file mode 100644 index ae3ee5991d8..00000000000 --- a/docs/es/engines/table_engines/special/distributed.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 33 -toc_title: Distribuido ---- - -# Distribuido {#distributed} - -**Las tablas con motor distribuido no almacenan ningún dato por sí mismas**, pero permite el procesamiento de consultas distribuidas en varios servidores. -La lectura se paralela automáticamente. Durante una lectura, se utilizan los índices de tabla en servidores remotos, si los hay. - -El motor distribuido acepta parámetros: - -- el nombre del clúster en el archivo de configuración del servidor - -- el nombre de una base de datos remota - -- el nombre de una tabla remota - -- (opcionalmente) clave de fragmentación - -- nombre de política (opcionalmente), se usará para almacenar archivos temporales para el envío asíncrono - - Ver también: - - - `insert_distributed_sync` configuración - - [Método de codificación de datos:](../mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) para los ejemplos - -Ejemplo: - -``` sql -Distributed(logs, default, hits[, sharding_key[, policy_name]]) -``` - -Los datos se leerán desde todos los servidores ‘logs’ clúster, desde el valor predeterminado.tabla de éxitos ubicada en cada servidor del clúster. -Los datos no solo se leen sino que se procesan parcialmente en los servidores remotos (en la medida en que esto sea posible). -Por ejemplo, para una consulta con GROUP BY, los datos se agregarán en servidores remotos y los estados intermedios de las funciones agregadas se enviarán al servidor solicitante. Luego, los datos se agregarán más. - -En lugar del nombre de la base de datos, puede usar una expresión constante que devuelva una cadena. Por ejemplo: currentDatabase(). - -logs – The cluster name in the server's config file. - -Los clústeres se establecen así: - -``` xml - - - - - 1 - - false - - example01-01-1 - 9000 - - - example01-01-2 - 9000 - - - - 2 - false - - example01-02-1 - 9000 - - - example01-02-2 - 1 - 9440 - - - - -``` - -Aquí se define un clúster con el nombre ‘logs’ que consta de dos fragmentos, cada uno de los cuales contiene dos réplicas. -Los fragmentos se refieren a los servidores que contienen diferentes partes de los datos (para leer todos los datos, debe acceder a todos los fragmentos). -Las réplicas están duplicando servidores (para leer todos los datos, puede acceder a los datos en cualquiera de las réplicas). - -Los nombres de clúster no deben contener puntos. - -Los parámetros `host`, `port`, y opcionalmente `user`, `password`, `secure`, `compression` se especifican para cada servidor: -- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. -- `port` – The TCP port for messenger activity (‘tcp\_port’ en la configuración, generalmente establecido en 9000). No lo confundas con http\_port. -- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Derechos de acceso](../../../operations/access_rights.md). -- `password` – The password for connecting to a remote server (not masked). Default value: empty string. -- `secure` - Use ssl para la conexión, por lo general también debe definir `port` = 9440. El servidor debe escuchar en 9440 y tener certificados correctos. -- `compression` - Utilice la compresión de datos. Valor predeterminado: true. - -When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [load\_balancing](../../../operations/settings/settings.md#settings-load_balancing) configuración. -Si no se establece la conexión con el servidor, habrá un intento de conectarse con un breve tiempo de espera. Si la conexión falla, se seleccionará la siguiente réplica, y así sucesivamente para todas las réplicas. Si el intento de conexión falló para todas las réplicas, el intento se repetirá de la misma manera, varias veces. -Esto funciona a favor de la resiliencia, pero no proporciona una tolerancia completa a errores: un servidor remoto podría aceptar la conexión, pero podría no funcionar o funcionar mal. - -Puede especificar solo uno de los fragmentos (en este caso, el procesamiento de consultas debe denominarse remoto, en lugar de distribuido) o hasta cualquier número de fragmentos. En cada fragmento, puede especificar entre una y cualquier número de réplicas. Puede especificar un número diferente de réplicas para cada fragmento. - -Puede especificar tantos clústeres como desee en la configuración. - -Para ver los clústeres, utilice el ‘system.clusters’ tabla. - -El motor distribuido permite trabajar con un clúster como un servidor local. Sin embargo, el clúster es inextensible: debe escribir su configuración en el archivo de configuración del servidor (mejor aún, para todos los servidores del clúster). - -The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the ‘remote’ función de tabla en su lugar. Vea la sección [Funciones de tabla](../../../sql_reference/table_functions/index.md). - -Hay dos métodos para escribir datos en un clúster: - -Primero, puede definir a qué servidores escribir en qué datos y realizar la escritura directamente en cada fragmento. En otras palabras, realice INSERT en las tablas que la tabla distribuida “looks at”. Esta es la solución más flexible, ya que puede usar cualquier esquema de fragmentación, que podría ser no trivial debido a los requisitos del área temática. Esta es también la solución más óptima ya que los datos se pueden escribir en diferentes fragmentos de forma completamente independiente. - -En segundo lugar, puede realizar INSERT en una tabla distribuida. En este caso, la tabla distribuirá los datos insertados a través de los propios servidores. Para escribir en una tabla distribuida, debe tener un conjunto de claves de fragmentación (el último parámetro). Además, si solo hay un fragmento, la operación de escritura funciona sin especificar la clave de fragmentación, ya que no significa nada en este caso. - -Cada fragmento puede tener un peso definido en el archivo de configuración. Por defecto, el peso es igual a uno. Los datos se distribuyen entre fragmentos en la cantidad proporcional al peso del fragmento. Por ejemplo, si hay dos fragmentos y el primero tiene un peso de 9 mientras que el segundo tiene un peso de 10, el primero se enviará 9 / 19 partes de las filas, y el segundo se enviará 10 / 19. - -Cada fragmento puede tener el ‘internal\_replication’ parámetro definido en el archivo de configuración. - -Si este parámetro se establece en ‘true’, la operación de escritura selecciona la primera réplica en buen estado y escribe datos en ella. Utilice esta alternativa si la tabla Distribuida “looks at” tablas replicadas. En otras palabras, si la tabla donde se escribirán los datos los replicará por sí misma. - -Si se establece en ‘false’ (el valor predeterminado), los datos se escriben en todas las réplicas. En esencia, esto significa que la tabla distribuida replica los datos en sí. Esto es peor que usar tablas replicadas, porque no se verifica la consistencia de las réplicas y, con el tiempo, contendrán datos ligeramente diferentes. - -Para seleccionar el fragmento al que se envía una fila de datos, se analiza la expresión de fragmentación y su resto se toma de dividirlo por el peso total de los fragmentos. La fila se envía al fragmento que corresponde al medio intervalo de los restos de ‘prev\_weight’ a ‘prev\_weights + weight’, donde ‘prev\_weights’ es el peso total de los fragmentos con el número más pequeño, y ‘weight’ es el peso de este fragmento. Por ejemplo, si hay dos fragmentos, y el primero tiene un peso de 9 mientras que el segundo tiene un peso de 10, la fila se enviará al primer fragmento para los restos del rango \[0, 9), y al segundo para los restos del rango \[9, 19). - -La expresión de fragmentación puede ser cualquier expresión de constantes y columnas de tabla que devuelva un entero. Por ejemplo, puede usar la expresión ‘rand()’ para la distribución aleatoria de datos, o ‘UserID’ para la distribución por el resto de dividir la ID del usuario (entonces los datos de un solo usuario residirán en un solo fragmento, lo que simplifica la ejecución de IN y JOIN por los usuarios). Si una de las columnas no se distribuye lo suficientemente uniformemente, puede envolverla en una función hash: intHash64(UserID) . - -Un simple recordatorio de la división es una solución limitada para sharding y no siempre es apropiado. Funciona para volúmenes medianos y grandes de datos (docenas de servidores), pero no para volúmenes muy grandes de datos (cientos de servidores o más). En este último caso, use el esquema de fragmentación requerido por el área asunto, en lugar de usar entradas en Tablas distribuidas. - -SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. - -Debería preocuparse por el esquema de fragmentación en los siguientes casos: - -- Se utilizan consultas que requieren unir datos (IN o JOIN) mediante una clave específica. Si esta clave fragmenta datos, puede usar IN local o JOIN en lugar de GLOBAL IN o GLOBAL JOIN, que es mucho más eficiente. -- Se usa una gran cantidad de servidores (cientos o más) con una gran cantidad de consultas pequeñas (consultas de clientes individuales: sitios web, anunciantes o socios). Para que las pequeñas consultas no afecten a todo el clúster, tiene sentido ubicar datos para un solo cliente en un solo fragmento. Alternativamente, como lo hemos hecho en Yandex.Metrica, puede configurar sharding de dos niveles: divida todo el clúster en “layers”, donde una capa puede consistir en varios fragmentos. Los datos de un único cliente se encuentran en una sola capa, pero los fragmentos se pueden agregar a una capa según sea necesario y los datos se distribuyen aleatoriamente dentro de ellos. Las tablas distribuidas se crean para cada capa y se crea una única tabla distribuida compartida para consultas globales. - -Los datos se escriben de forma asíncrona. Cuando se inserta en la tabla, el bloque de datos se acaba de escribir en el sistema de archivos local. Los datos se envían a los servidores remotos en segundo plano tan pronto como sea posible. El período de envío de datos está gestionado por el [Distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) y [Distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) configuración. El `Distributed` el motor envía cada archivo con datos insertados por separado, pero puede habilitar el envío por lotes de archivos [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) configuración. Esta configuración mejora el rendimiento del clúster al utilizar mejor los recursos de red y servidor local. Debe comprobar si los datos se envían correctamente comprobando la lista de archivos (datos en espera de ser enviados) en el directorio de la tabla: `/var/lib/clickhouse/data/database/table/`. - -Si el servidor dejó de existir o tuvo un reinicio aproximado (por ejemplo, después de un error de dispositivo) después de un INSERT en una tabla distribuida, es posible que se pierdan los datos insertados. Si se detecta un elemento de datos dañado en el directorio de la tabla, se transfiere al ‘broken’ subdirectorio y ya no se utiliza. - -Cuando la opción max\_parallel\_replicas está habilitada, el procesamiento de consultas se paralela en todas las réplicas dentro de un solo fragmento. Para obtener más información, consulte la sección [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). - -## Virtual Columnas {#virtual-columns} - -- `_shard_num` — Contains the `shard_num` (de `system.clusters`). Tipo: [UInt32](../../../sql_reference/data_types/int_uint.md). - -!!! note "Nota" - Ya [`remote`](../../../sql_reference/table_functions/remote.md)/`cluster` funciones de tabla crean internamente instancia temporal del mismo motor distribuido, `_shard_num` está disponible allí también. - -**Ver también** - -- [Virtual columnas](index.md#table_engines-virtual_columns) - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/es/engines/table_engines/special/external_data.md b/docs/es/engines/table_engines/special/external_data.md deleted file mode 100644 index ad15cf4e7d4..00000000000 --- a/docs/es/engines/table_engines/special/external_data.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 34 -toc_title: Datos externos ---- - -# Datos externos para el procesamiento de consultas {#external-data-for-query-processing} - -ClickHouse permite enviar a un servidor los datos necesarios para procesar una consulta, junto con una consulta SELECT. Estos datos se colocan en una tabla temporal (consulte la sección “Temporary tables”) y se puede utilizar en la consulta (por ejemplo, en operadores IN). - -Por ejemplo, si tiene un archivo de texto con identificadores de usuario importantes, puede cargarlo en el servidor junto con una consulta que utilice la filtración de esta lista. - -Si necesita ejecutar más de una consulta con un gran volumen de datos externos, no utilice esta función. Es mejor cargar los datos a la base de datos con anticipación. - -Los datos externos se pueden cargar mediante el cliente de línea de comandos (en modo no interactivo) o mediante la interfaz HTTP. - -En el cliente de línea de comandos, puede especificar una sección de parámetros en el formato - -``` bash ---external --file=... [--name=...] [--format=...] [--types=...|--structure=...] -``` - -Puede tener varias secciones como esta, para el número de tablas que se transmiten. - -**–external** – Marks the beginning of a clause. -**–file** – Path to the file with the table dump, or -, which refers to stdin. -Solo se puede recuperar una sola tabla de stdin. - -Los siguientes parámetros son opcionales: **–name**– Name of the table. If omitted, \_data is used. -**–format** – Data format in the file. If omitted, TabSeparated is used. - -Se requiere uno de los siguientes parámetros:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … -**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Define los nombres y tipos de columna. - -Los archivos especificados en ‘file’ se analizará mediante el formato especificado en ‘format’ utilizando los tipos de datos especificados en ‘types’ o ‘structure’. La mesa será cargado en el servidor y accesibles, como una tabla temporal con el nombre de ‘name’. - -Ejemplos: - -``` bash -$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 -849897 -$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -Cuando se utiliza la interfaz HTTP, los datos externos se pasan en el formato multipart/form-data. Cada tabla se transmite como un archivo separado. El nombre de la tabla se toma del nombre del archivo. El ‘query\_string’ se pasa los parámetros ‘name\_format’, ‘name\_types’, y ‘name\_structure’, donde ‘name’ es el nombre de la tabla a la que corresponden estos parámetros. El significado de los parámetros es el mismo que cuando se usa el cliente de línea de comandos. - -Ejemplo: - -``` bash -$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv - -$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -Para el procesamiento de consultas distribuidas, las tablas temporales se envían a todos los servidores remotos. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/es/engines/table_engines/special/file.md b/docs/es/engines/table_engines/special/file.md deleted file mode 100644 index 460e5ae40f5..00000000000 --- a/docs/es/engines/table_engines/special/file.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 37 -toc_title: File ---- - -# File {#table_engines-file} - -El motor de tabla de archivos mantiene los datos en un archivo en uno de los [file -formato](../../../interfaces/formats.md#formats) (TabSeparated, Native, etc.). - -Ejemplos de uso: - -- Exportación de datos de ClickHouse a archivo. -- Convertir datos de un formato a otro. -- Actualización de datos en ClickHouse mediante la edición de un archivo en un disco. - -## Uso en el servidor de Clickhouse {#usage-in-clickhouse-server} - -``` sql -File(Format) -``` - -El `Format` parámetro especifica uno de los formatos de archivo disponibles. Realizar -`SELECT` consultas, el formato debe ser compatible para la entrada, y para realizar -`INSERT` queries – for output. The available formats are listed in the -[Formato](../../../interfaces/formats.md#formats) apartado. - -ClickHouse no permite especificar la ruta del sistema de archivos para`File`. Utilizará la carpeta definida por [camino](../../../operations/server_configuration_parameters/settings.md) configuración en la configuración del servidor. - -Al crear una tabla usando `File(Format)` crea un subdirectorio vacío en esa carpeta. Cuando los datos se escriben en esa tabla, se colocan en `data.Format` en ese subdirectorio. - -Puede crear manualmente esta subcarpeta y archivo en el sistema de archivos del servidor y luego [ATTACH](../../../sql_reference/statements/misc.md) para mostrar información con el nombre coincidente, para que pueda consultar datos desde ese archivo. - -!!! warning "Advertencia" - Tenga cuidado con esta funcionalidad, ya que ClickHouse no realiza un seguimiento de los cambios externos en dichos archivos. El resultado de las escrituras simultáneas a través de ClickHouse y fuera de ClickHouse no está definido. - -**Ejemplo:** - -**1.** Configurar el `file_engine_table` tabla: - -``` sql -CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) -``` - -Por defecto, ClickHouse creará una carpeta `/var/lib/clickhouse/data/default/file_engine_table`. - -**2.** Crear manualmente `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` contener: - -``` bash -$ cat data.TabSeparated -one 1 -two 2 -``` - -**3.** Consultar los datos: - -``` sql -SELECT * FROM file_engine_table -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Uso en Clickhouse-local {#usage-in-clickhouse-local} - -En [Sistema abierto.](../../../operations/utilities/clickhouse-local.md) El motor de archivos acepta la ruta del archivo además de `Format`. Los flujos de entrada / salida predeterminados se pueden especificar utilizando nombres numéricos o legibles por humanos como `0` o `stdin`, `1` o `stdout`. -**Ejemplo:** - -``` bash -$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" -``` - -## Detalles de la implementación {#details-of-implementation} - -- Multiple `SELECT` las consultas se pueden realizar simultáneamente, pero `INSERT` las consultas se esperarán entre sí. -- Apoyado la creación de nuevos archivos por `INSERT` consulta. -- Si el archivo existe, `INSERT` añadiría nuevos valores en él. -- No soportado: - - `ALTER` - - `SELECT ... SAMPLE` - - Indice - - Replicación - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/es/engines/table_engines/special/generate.md b/docs/es/engines/table_engines/special/generate.md deleted file mode 100644 index 662eada5f86..00000000000 --- a/docs/es/engines/table_engines/special/generate.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 46 -toc_title: GenerateRandom ---- - -# Generaterandom {#table_engines-generate} - -El motor de tabla GenerateRandom produce datos aleatorios para el esquema de tabla determinado. - -Ejemplos de uso: - -- Se usa en la prueba para poblar una tabla grande reproducible. -- Generar entrada aleatoria para pruebas de fuzzing. - -## Uso en el servidor de Clickhouse {#usage-in-clickhouse-server} - -``` sql -ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) -``` - -El `max_array_length` y `max_string_length` parámetros especifican la longitud máxima de todos -columnas y cadenas de matriz correspondientemente en los datos generados. - -Generar motor de tabla sólo admite `SELECT` consulta. - -Es compatible con todos [Tipos de datos](../../../sql_reference/data_types/index.md) que se pueden almacenar en una tabla excepto `LowCardinality` y `AggregateFunction`. - -**Ejemplo:** - -**1.** Configurar el `generate_engine_table` tabla: - -``` sql -CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) -``` - -**2.** Consultar los datos: - -``` sql -SELECT * FROM generate_engine_table LIMIT 3 -``` - -``` text -┌─name─┬──────value─┐ -│ c4xJ │ 1412771199 │ -│ r │ 1791099446 │ -│ 7#$ │ 124312908 │ -└──────┴────────────┘ -``` - -## Detalles de la implementación {#details-of-implementation} - -- No soportado: - - `ALTER` - - `SELECT ... SAMPLE` - - `INSERT` - - Indice - - Replicación - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/es/engines/table_engines/special/index.md b/docs/es/engines/table_engines/special/index.md deleted file mode 100644 index 9770e3fb6c5..00000000000 --- a/docs/es/engines/table_engines/special/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Special -toc_priority: 31 ---- - - diff --git a/docs/es/engines/table_engines/special/join.md b/docs/es/engines/table_engines/special/join.md deleted file mode 100644 index 031305fc8ef..00000000000 --- a/docs/es/engines/table_engines/special/join.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 40 -toc_title: Unir ---- - -# Unir {#join} - -Estructura de datos preparada para usar en [JOIN](../../../sql_reference/statements/select.md#select-join) operación. - -## Creación de una tabla {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], -) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) -``` - -Vea la descripción detallada del [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) consulta. - -**Parámetros del motor** - -- `join_strictness` – [ÚNETE a la rigurosidad](../../../sql_reference/statements/select.md#select-join-strictness). -- `join_type` – [Tipo de unión](../../../sql_reference/statements/select.md#select-join-types). -- `k1[, k2, ...]` – Key columns from the `USING` cláusula que el `JOIN` operación se hace con. - -Entrar `join_strictness` y `join_type` parámetros sin comillas, por ejemplo, `Join(ANY, LEFT, col1)`. Deben coincidir con el `JOIN` operación para la que se utilizará la tabla. Si los parámetros no coinciden, ClickHouse no lanza una excepción y puede devolver datos incorrectos. - -## Uso de la tabla {#table-usage} - -### Ejemplo {#example} - -Creación de la tabla del lado izquierdo: - -``` sql -CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog -``` - -``` sql -INSERT INTO id_val VALUES (1,11)(2,12)(3,13) -``` - -Creando el lado derecho `Join` tabla: - -``` sql -CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) -``` - -``` sql -INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) -``` - -Unirse a las tablas: - -``` sql -SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 -``` - -``` text -┌─id─┬─val─┬─id_val_join.val─┐ -│ 1 │ 11 │ 21 │ -│ 2 │ 12 │ ᴺᵁᴸᴸ │ -│ 3 │ 13 │ 23 │ -└────┴─────┴─────────────────┘ -``` - -Como alternativa, puede recuperar datos del `Join` tabla, especificando el valor de la clave de unión: - -``` sql -SELECT joinGet('id_val_join', 'val', toUInt32(1)) -``` - -``` text -┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ -│ 21 │ -└────────────────────────────────────────────┘ -``` - -### Selección e inserción de datos {#selecting-and-inserting-data} - -Usted puede utilizar `INSERT` consultas para agregar datos al `Join`-mesas de motor. Si la tabla se creó con el `ANY` estricta, se ignoran los datos de las claves duplicadas. Con el `ALL` estricta, se agregan todas las filas. - -No se puede realizar una `SELECT` consulta directamente desde la tabla. En su lugar, use uno de los siguientes métodos: - -- Coloque la mesa hacia el lado derecho en un `JOIN` clausula. -- Llame al [joinGet](../../../sql_reference/functions/other_functions.md#joinget) función, que le permite extraer datos de la tabla de la misma manera que de un diccionario. - -### Limitaciones y ajustes {#join-limitations-and-settings} - -Al crear una tabla, se aplican los siguientes valores: - -- [Sistema abierto.](../../../operations/settings/settings.md#join_use_nulls) -- [Método de codificación de datos:](../../../operations/settings/query_complexity.md#settings-max_rows_in_join) -- [Método de codificación de datos:](../../../operations/settings/query_complexity.md#settings-max_bytes_in_join) -- [join\_overflow\_mode](../../../operations/settings/query_complexity.md#settings-join_overflow_mode) -- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) - -El `Join`-las tablas del motor no se pueden usar en `GLOBAL JOIN` operación. - -El `Join`-motor permite el uso [Sistema abierto.](../../../operations/settings/settings.md#join_use_nulls) ajuste en el `CREATE TABLE` instrucción. Y [SELECT](../../../sql_reference/statements/select.md) consulta permite el uso `join_use_nulls` demasiado. Si tienes diferentes `join_use_nulls` configuración, puede obtener un error al unirse a la tabla. Depende del tipo de JOIN. Cuando se utiliza [joinGet](../../../sql_reference/functions/other_functions.md#joinget) función, usted tiene que utilizar el mismo `join_use_nulls` ajuste en `CRATE TABLE` y `SELECT` instrucción. - -## Almacenamiento de datos {#data-storage} - -`Join` datos de la tabla siempre se encuentra en la memoria RAM. Al insertar filas en una tabla, ClickHouse escribe bloques de datos en el directorio del disco para que puedan restaurarse cuando se reinicie el servidor. - -Si el servidor se reinicia incorrectamente, el bloque de datos en el disco puede perderse o dañarse. En este caso, es posible que deba eliminar manualmente el archivo con datos dañados. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/es/engines/table_engines/special/materializedview.md b/docs/es/engines/table_engines/special/materializedview.md deleted file mode 100644 index 4960ce2cd80..00000000000 --- a/docs/es/engines/table_engines/special/materializedview.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 43 -toc_title: "M\xE9todo de codificaci\xF3n de datos:" ---- - -# Método de codificación de datos: {#materializedview} - -Se utiliza para implementar vistas materializadas (para obtener más información, consulte [CREATE TABLE](../../../sql_reference/statements/create.md)). Para almacenar datos, utiliza un motor diferente que se especificó al crear la vista. Al leer desde una tabla, solo usa este motor. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/es/engines/table_engines/special/memory.md b/docs/es/engines/table_engines/special/memory.md deleted file mode 100644 index f7a2f81ff94..00000000000 --- a/docs/es/engines/table_engines/special/memory.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 44 -toc_title: Memoria ---- - -# Memoria {#memory} - -El motor de memoria almacena datos en RAM, en forma sin comprimir. Los datos se almacenan exactamente en la misma forma en que se reciben cuando se leen. En otras palabras, la lectura de esta tabla es completamente gratuita. -El acceso a los datos simultáneos está sincronizado. Los bloqueos son cortos: las operaciones de lectura y escritura no se bloquean entre sí. -Los índices no son compatibles. La lectura está paralelizada. -La productividad máxima (más de 10 GB/s) se alcanza en consultas simples, porque no hay lectura del disco, descomprimir o deserializar datos. (Cabe señalar que, en muchos casos, la productividad del motor MergeTree es casi tan alta.) -Al reiniciar un servidor, los datos desaparecen de la tabla y la tabla queda vacía. -Normalmente, el uso de este motor de tabla no está justificado. Sin embargo, se puede usar para pruebas y para tareas donde se requiere la velocidad máxima en un número relativamente pequeño de filas (hasta aproximadamente 100,000,000). - -El sistema utiliza el motor de memoria para tablas temporales con datos de consulta externos (consulte la sección “External data for processing a query”), y para la implementación de GLOBAL IN (véase la sección “IN operators”). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/es/engines/table_engines/special/merge.md b/docs/es/engines/table_engines/special/merge.md deleted file mode 100644 index 15b67d2f721..00000000000 --- a/docs/es/engines/table_engines/special/merge.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 36 -toc_title: Fusionar ---- - -# Fusionar {#merge} - -El `Merge` motor (no debe confundirse con `MergeTree`) no almacena datos en sí, pero permite leer de cualquier número de otras tablas simultáneamente. -La lectura se paralela automáticamente. No se admite la escritura en una tabla. Al leer, se usan los índices de las tablas que realmente se están leyendo, si existen. -El `Merge` engine acepta parámetros: el nombre de la base de datos y una expresión regular para las tablas. - -Ejemplo: - -``` sql -Merge(hits, '^WatchLog') -``` - -Los datos se leerán de las tablas en el `hits` base de datos que tienen nombres que coinciden con la expresión regular ‘`^WatchLog`’. - -En lugar del nombre de la base de datos, puede usar una expresión constante que devuelva una cadena. Por ejemplo, `currentDatabase()`. - -Regular expressions — [Re2](https://github.com/google/re2) (soporta un subconjunto de PCRE), sensible a mayúsculas y minúsculas. -Vea las notas sobre los símbolos de escape en expresiones regulares en el “match” apartado. - -Al seleccionar tablas para leer, el `Merge` no se seleccionará la tabla en sí, incluso si coincide con la expresión regular. Esto es para evitar bucles. -Es posible crear dos `Merge` tablas que intentarán interminablemente leer los datos de los demás, pero esta no es una buena idea. - -La forma típica de usar el `Merge` para trabajar con un gran número de `TinyLog` tablas como si con una sola tabla. - -Ejemplo 2: - -Digamos que tiene una tabla antigua (WatchLog\_old) y decidió cambiar la partición sin mover datos a una nueva tabla (WatchLog\_new) y necesita ver datos de ambas tablas. - -``` sql -CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree(date, (UserId, EventType), 8192); -INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); - -CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; -INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); - -CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); - -SELECT * -FROM WatchLog -``` - -``` text -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-01 │ 1 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-02 │ 2 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -``` - -## Virtual Columnas {#virtual-columns} - -- `_table` — Contains the name of the table from which data was read. Type: [Cadena](../../../sql_reference/data_types/string.md). - - Puede establecer las condiciones constantes en `_table` en el `WHERE/PREWHERE` cláusula (por ejemplo, `WHERE _table='xyz'`). En este caso, la operación de lectura se realiza sólo para las tablas donde la condición en `_table` está satisfecho, por lo que el `_table` columna actúa como un índice. - -**Ver también** - -- [Virtual columnas](index.md#table_engines-virtual_columns) - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/es/engines/table_engines/special/null.md b/docs/es/engines/table_engines/special/null.md deleted file mode 100644 index 53abadefb31..00000000000 --- a/docs/es/engines/table_engines/special/null.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 38 -toc_title: Nulo ---- - -# Nulo {#null} - -Al escribir en una tabla Null, los datos se ignoran. Al leer desde una tabla Null, la respuesta está vacía. - -Sin embargo, puede crear una vista materializada en una tabla Null. Entonces los datos escritos en la tabla terminarán en la vista. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/es/engines/table_engines/special/set.md b/docs/es/engines/table_engines/special/set.md deleted file mode 100644 index 4afc3fad85d..00000000000 --- a/docs/es/engines/table_engines/special/set.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 39 -toc_title: Establecer ---- - -# Establecer {#set} - -Un conjunto de datos que siempre está en la memoria RAM. Está diseñado para su uso en el lado derecho del operador IN (consulte la sección “IN operators”). - -Puede usar INSERT para insertar datos en la tabla. Se agregarán nuevos elementos al conjunto de datos, mientras que los duplicados se ignorarán. -Pero no puede realizar SELECT desde la tabla. La única forma de recuperar datos es usándolos en la mitad derecha del operador IN. - -Los datos siempre se encuentran en la memoria RAM. Para INSERT, los bloques de datos insertados también se escriben en el directorio de tablas en el disco. Al iniciar el servidor, estos datos se cargan en la RAM. En otras palabras, después de reiniciar, los datos permanecen en su lugar. - -Para un reinicio aproximado del servidor, el bloque de datos en el disco puede perderse o dañarse. En este último caso, es posible que deba eliminar manualmente el archivo con datos dañados. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/es/engines/table_engines/special/url.md b/docs/es/engines/table_engines/special/url.md deleted file mode 100644 index 37c796b15b8..00000000000 --- a/docs/es/engines/table_engines/special/url.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 41 -toc_title: URL ---- - -# URL(URL, Formato) {#table_engines-url} - -Administra datos en un servidor HTTP/HTTPS remoto. Este motor es similar -a la [File](file.md) motor. - -## Uso del motor en el servidor de Clickhouse {#using-the-engine-in-the-clickhouse-server} - -El `format` debe ser uno que ClickHouse pueda usar en -`SELECT` consultas y, si es necesario, en `INSERTs`. Para obtener la lista completa de formatos admitidos, consulte -[Formato](../../../interfaces/formats.md#formats). - -El `URL` debe ajustarse a la estructura de un localizador uniforme de recursos. La dirección URL especificada debe apuntar a un servidor -que utiliza HTTP o HTTPS. Esto no requiere ningún -encabezados adicionales para obtener una respuesta del servidor. - -`INSERT` y `SELECT` las consultas se transforman en `POST` y `GET` peticiones, -respectivamente. Para el procesamiento `POST` solicitudes, el servidor remoto debe admitir -[Codificación de transferencia fragmentada](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). - -Puede limitar el número máximo de saltos de redirección HTTP GET utilizando el [Nombre de la red inalámbrica (SSID):](../../../operations/settings/settings.md#setting-max_http_get_redirects) configuración. - -**Ejemplo:** - -**1.** Crear un `url_engine_table` tabla en el servidor : - -``` sql -CREATE TABLE url_engine_table (word String, value UInt64) -ENGINE=URL('http://127.0.0.1:12345/', CSV) -``` - -**2.** Cree un servidor HTTP básico utilizando las herramientas estándar de Python 3 y -comenzarlo: - -``` python3 -from http.server import BaseHTTPRequestHandler, HTTPServer - -class CSVHTTPServer(BaseHTTPRequestHandler): - def do_GET(self): - self.send_response(200) - self.send_header('Content-type', 'text/csv') - self.end_headers() - - self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) - -if __name__ == "__main__": - server_address = ('127.0.0.1', 12345) - HTTPServer(server_address, CSVHTTPServer).serve_forever() -``` - -``` bash -$ python3 server.py -``` - -**3.** Solicitar datos: - -``` sql -SELECT * FROM url_engine_table -``` - -``` text -┌─word──┬─value─┐ -│ Hello │ 1 │ -│ World │ 2 │ -└───────┴───────┘ -``` - -## Detalles de la implementación {#details-of-implementation} - -- Las lecturas y escrituras pueden ser paralelas -- No soportado: - - `ALTER` y `SELECT...SAMPLE` operación. - - Índices. - - Replicación. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/es/engines/table_engines/special/view.md b/docs/es/engines/table_engines/special/view.md deleted file mode 100644 index 3dae42d1b06..00000000000 --- a/docs/es/engines/table_engines/special/view.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 42 -toc_title: Vista ---- - -# Vista {#table_engines-view} - -Se utiliza para implementar vistas (para obtener más información, consulte `CREATE VIEW query`). No almacena datos, pero solo almacena los datos especificados `SELECT` consulta. Al leer desde una tabla, ejecuta esta consulta (y elimina todas las columnas innecesarias de la consulta). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/es/faq/general.md b/docs/es/faq/general.md index 09c5a476af8..dc6ba5b5915 100644 --- a/docs/es/faq/general.md +++ b/docs/es/faq/general.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 78 toc_title: Preguntas generales --- # Preguntas generales {#general-questions} -## ¿por qué no usar algo como mapreduce? {#why-not-use-something-like-mapreduce} +## ¿Por qué no usar algo como MapReduce? {#why-not-use-something-like-mapreduce} Podemos referirnos a sistemas como MapReduce como sistemas informáticos distribuidos en los que la operación de reducción se basa en la clasificación distribuida. La solución de código abierto más común en esta clase es [Acerca de nosotros](http://hadoop.apache.org). Yandex utiliza su solución interna, YT. @@ -15,7 +15,7 @@ Estos sistemas no son apropiados para consultas en línea debido a su alta laten La mayoría de las implementaciones de MapReduce le permiten ejecutar código arbitrario en un clúster. Pero un lenguaje de consulta declarativo es más adecuado para OLAP para ejecutar experimentos rápidamente. Por ejemplo, Hadoop tiene Hive y Pig. También considere Cloudera Impala o Shark (obsoleto) para Spark, así como Spark SQL, Presto y Apache Drill. El rendimiento cuando se ejecutan tales tareas es muy subóptimo en comparación con los sistemas especializados, pero la latencia relativamente alta hace que sea poco realista utilizar estos sistemas como back-end para una interfaz web. -## ¿qué sucede si tengo un problema con las codificaciones al usar oracle a través de odbc? {#oracle-odbc-encodings} +## ¿Qué sucede si tengo un problema con las codificaciones al usar Oracle a través de ODBC? {#oracle-odbc-encodings} Si utiliza Oracle a través del controlador ODBC como fuente de diccionarios externos, debe establecer el valor `NLS_LANG` variable de entorno en `/etc/default/clickhouse`. Para obtener más información, consulte [Oracle NLS\_LANG Preguntas frecuentes](https://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html). @@ -29,7 +29,7 @@ NLS_LANG=RUSSIAN_RUSSIA.UTF8 ### Uso de la cláusula INTO OUTFILE {#using-into-outfile-clause} -Añadir un [INTO OUTFILE](../query_language/select/#into-outfile-clause) cláusula a su consulta. +Añadir un [INTO OUTFILE](../sql-reference/statements/select/into-outfile.md#into-outfile-clause) cláusula a su consulta. Por ejemplo: @@ -37,7 +37,7 @@ Por ejemplo: SELECT * FROM table INTO OUTFILE 'file' ``` -De forma predeterminada, ClickHouse usa el [TabSeparated](../interfaces/formats.md#tabseparated) formato de datos de salida. Para seleccionar el [formato de datos](../interfaces/formats.md), utilizar el [Cláusula FORMAT](../query_language/select/#format-clause). +De forma predeterminada, ClickHouse usa el [TabSeparated](../interfaces/formats.md#tabseparated) formato de datos de salida. Para seleccionar el [formato de datos](../interfaces/formats.md), utilizar el [Cláusula FORMAT](../sql-reference/statements/select/format.md#format-clause). Por ejemplo: @@ -47,7 +47,7 @@ SELECT * FROM table INTO OUTFILE 'file' FORMAT CSV ### Uso de una tabla de motor de archivo {#using-a-file-engine-table} -Ver [File](../engines/table_engines/special/file.md). +Ver [File](../engines/table-engines/special/file.md). ### Uso de la redirección de línea de comandos {#using-command-line-redirection} diff --git a/docs/es/faq/index.md b/docs/es/faq/index.md index 05863c71f9a..a44dbb31e89 100644 --- a/docs/es/faq/index.md +++ b/docs/es/faq/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: F.A.Q. toc_priority: 76 --- diff --git a/docs/es/getting-started/example-datasets/amplab-benchmark.md b/docs/es/getting-started/example-datasets/amplab-benchmark.md new file mode 100644 index 00000000000..c8fa77953cb --- /dev/null +++ b/docs/es/getting-started/example-datasets/amplab-benchmark.md @@ -0,0 +1,129 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 17 +toc_title: Referencia de Big Data de AMPLab +--- + +# Referencia de Big Data de AMPLab {#amplab-big-data-benchmark} + +Ver https://amplab.cs.berkeley.edu/benchmark/ + +Regístrese para obtener una cuenta gratuita en https://aws.amazon.com. Requiere una tarjeta de crédito, correo electrónico y número de teléfono. Obtenga una nueva clave de acceso en https://console.aws.amazon.com/iam/home?nc2=h\_m\_sc\#security\_credential + +Ejecute lo siguiente en la consola: + +``` bash +$ sudo apt-get install s3cmd +$ mkdir tiny; cd tiny; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/tiny/ . +$ cd .. +$ mkdir 1node; cd 1node; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/1node/ . +$ cd .. +$ mkdir 5nodes; cd 5nodes; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . +$ cd .. +``` + +Ejecute las siguientes consultas de ClickHouse: + +``` sql +CREATE TABLE rankings_tiny +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_tiny +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); + +CREATE TABLE rankings_1node +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_1node +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); + +CREATE TABLE rankings_5nodes_on_single +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_5nodes_on_single +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); +``` + +Volver a la consola: + +``` bash +$ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done +$ for i in tiny/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_tiny FORMAT CSV"; done +$ for i in 1node/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_1node FORMAT CSV"; done +$ for i in 1node/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_1node FORMAT CSV"; done +$ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_5nodes_on_single FORMAT CSV"; done +$ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done +``` + +Consultas para obtener muestras de datos: + +``` sql +SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 + +SELECT substring(sourceIP, 1, 8), sum(adRevenue) FROM uservisits_1node GROUP BY substring(sourceIP, 1, 8) + +SELECT + sourceIP, + sum(adRevenue) AS totalRevenue, + avg(pageRank) AS pageRank +FROM rankings_1node ALL INNER JOIN +( + SELECT + sourceIP, + destinationURL AS pageURL, + adRevenue + FROM uservisits_1node + WHERE (visitDate > '1980-01-01') AND (visitDate < '1980-04-01') +) USING pageURL +GROUP BY sourceIP +ORDER BY totalRevenue DESC +LIMIT 1 +``` + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/amplab_benchmark/) diff --git a/docs/es/getting-started/example-datasets/criteo.md b/docs/es/getting-started/example-datasets/criteo.md new file mode 100644 index 00000000000..79203b0276d --- /dev/null +++ b/docs/es/getting-started/example-datasets/criteo.md @@ -0,0 +1,81 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 19 +toc_title: Registros de clics de Terabyte de Criteo +--- + +# Terabyte de registros de clics de Criteo {#terabyte-of-click-logs-from-criteo} + +Descargue los datos de http://labs.criteo.com/downloads/download-terabyte-click-logs/ + +Cree una tabla para importar el registro: + +``` sql +CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log +``` + +Descargar los datos: + +``` bash +$ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done +``` + +Crear una tabla para los datos convertidos: + +``` sql +CREATE TABLE criteo +( + date Date, + clicked UInt8, + int1 Int32, + int2 Int32, + int3 Int32, + int4 Int32, + int5 Int32, + int6 Int32, + int7 Int32, + int8 Int32, + int9 Int32, + int10 Int32, + int11 Int32, + int12 Int32, + int13 Int32, + icat1 UInt32, + icat2 UInt32, + icat3 UInt32, + icat4 UInt32, + icat5 UInt32, + icat6 UInt32, + icat7 UInt32, + icat8 UInt32, + icat9 UInt32, + icat10 UInt32, + icat11 UInt32, + icat12 UInt32, + icat13 UInt32, + icat14 UInt32, + icat15 UInt32, + icat16 UInt32, + icat17 UInt32, + icat18 UInt32, + icat19 UInt32, + icat20 UInt32, + icat21 UInt32, + icat22 UInt32, + icat23 UInt32, + icat24 UInt32, + icat25 UInt32, + icat26 UInt32 +) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192) +``` + +Transforme los datos del registro sin procesar y colóquelos en la segunda tabla: + +``` sql +INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log; + +DROP TABLE criteo_log; +``` + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/criteo/) diff --git a/docs/es/getting-started/example-datasets/index.md b/docs/es/getting-started/example-datasets/index.md new file mode 100644 index 00000000000..28e06987af1 --- /dev/null +++ b/docs/es/getting-started/example-datasets/index.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Datos De Ejemplo +toc_priority: 12 +toc_title: "Implantaci\xF3n" +--- + +# Datos De Ejemplo {#example-datasets} + +En esta sección se describe cómo obtener conjuntos de datos de ejemplo e importarlos a ClickHouse. +Para algunos conjuntos de datos también están disponibles consultas de ejemplo. + +- [Yandex anonimizado.Conjunto de datos de Metrica](metrica.md) +- [Estrella Schema Benchmark](star-schema.md) +- [Nombre de la red inalámbrica (SSID):](wikistat.md) +- [Terabyte de registros de clics de Criteo](criteo.md) +- [Referencia de Big Data de AMPLab](amplab-benchmark.md) +- [Datos de taxis de Nueva York](nyc-taxi.md) +- [A tiempo](ontime.md) + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/es/getting-started/example-datasets/metrica.md b/docs/es/getting-started/example-datasets/metrica.md new file mode 100644 index 00000000000..e1c6a2a361e --- /dev/null +++ b/docs/es/getting-started/example-datasets/metrica.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 14 +toc_title: El Yandex.Metrica Datos +--- + +# Yandex anonimizado.Metrica Datos {#anonymized-yandex-metrica-data} + +El conjunto de datos consta de dos tablas que contienen datos anónimos sobre los hits (`hits_v1`) y visitas (`visits_v1`) el Yandex.Métrica. Puedes leer más sobre Yandex.Metrica en [Historial de ClickHouse](../../introduction/history.md) apartado. + +El conjunto de datos consta de dos tablas, cualquiera de ellas se puede descargar como `tsv.xz` o como particiones preparadas. Además, una versión extendida de la `hits` La tabla que contiene 100 millones de filas está disponible como TSV en https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits\_100m\_obfuscated\_v1.tsv.xz y como particiones preparadas en https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits\_100m\_obfuscated\_v1.tar.xz. + +## Obtención de tablas a partir de particiones preparadas {#obtaining-tables-from-prepared-partitions} + +Descargar e importar tabla de hits: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar +tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Descargar e importar visitas: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar +tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Obtención de tablas a partir de un archivo TSV comprimido {#obtaining-tables-from-compressed-tsv-file} + +Descargar e importar hits desde un archivo TSV comprimido: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Descargue e importe visitas desde un archivo tsv comprimido: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Consultas de ejemplo {#example-queries} + +[Tutorial de ClickHouse](../../getting-started/tutorial.md) se basa en Yandex.El conjunto de datos de Metrica y la forma recomendada de comenzar con este conjunto de datos es simplemente pasar por el tutorial. + +Se pueden encontrar ejemplos adicionales de consultas a estas tablas entre [pruebas estatales](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) de ClickHouse (se nombran `test.hists` y `test.visits` alli). diff --git a/docs/es/getting-started/example-datasets/nyc-taxi.md b/docs/es/getting-started/example-datasets/nyc-taxi.md new file mode 100644 index 00000000000..e7dfe0898fe --- /dev/null +++ b/docs/es/getting-started/example-datasets/nyc-taxi.md @@ -0,0 +1,390 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 16 +toc_title: Datos de taxis de Nueva York +--- + +# Datos de taxis de Nueva York {#new-york-taxi-data} + +Este conjunto de datos se puede obtener de dos maneras: + +- importación de datos sin procesar +- descarga de particiones preparadas + +## Cómo importar los datos sin procesar {#how-to-import-the-raw-data} + +Consulte https://github.com/toddwschneider/nyc-taxi-data y http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html para obtener la descripción de un conjunto de datos e instrucciones para descargar. + +La descarga dará como resultado aproximadamente 227 GB de datos sin comprimir en archivos CSV. La descarga tarda aproximadamente una hora en una conexión de 1 Gbit (la descarga paralela de s3.amazonaws.com recupera al menos la mitad de un canal de 1 Gbit). +Es posible que algunos de los archivos no se descarguen por completo. Verifique los tamaños de archivo y vuelva a descargar cualquiera que parezca dudoso. + +Algunos de los archivos pueden contener filas no válidas. Puede arreglarlos de la siguiente manera: + +``` bash +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ +mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv +mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv +``` + +Entonces los datos deben ser preprocesados en PostgreSQL. Esto creará selecciones de puntos en los polígonos (para hacer coincidir los puntos en el mapa con los distritos de la ciudad de Nueva York) y combinará todos los datos en una única tabla plana desnormalizada mediante el uso de una unión. Para hacer esto, deberá instalar PostgreSQL con soporte PostGIS. + +Tenga cuidado al correr `initialize_database.sh` y volver a verificar manualmente que todas las tablas se crearon correctamente. + +Se tarda entre 20 y 30 minutos en procesar los datos de cada mes en PostgreSQL, por un total de aproximadamente 48 horas. + +Puede comprobar el número de filas descargadas de la siguiente manera: + +``` bash +$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" +## Count + 1298979494 +(1 row) + +real 7m9.164s +``` + +(Esto es un poco más de 1.1 mil millones de filas reportadas por Mark Litwintschik en una serie de publicaciones de blog.) + +Los datos en PostgreSQL utilizan 370 GB de espacio. + +Exportación de los datos de PostgreSQL: + +``` sql +COPY +( + SELECT trips.id, + trips.vendor_id, + trips.pickup_datetime, + trips.dropoff_datetime, + trips.store_and_fwd_flag, + trips.rate_code_id, + trips.pickup_longitude, + trips.pickup_latitude, + trips.dropoff_longitude, + trips.dropoff_latitude, + trips.passenger_count, + trips.trip_distance, + trips.fare_amount, + trips.extra, + trips.mta_tax, + trips.tip_amount, + trips.tolls_amount, + trips.ehail_fee, + trips.improvement_surcharge, + trips.total_amount, + trips.payment_type, + trips.trip_type, + trips.pickup, + trips.dropoff, + + cab_types.type cab_type, + + weather.precipitation_tenths_of_mm rain, + weather.snow_depth_mm, + weather.snowfall_mm, + weather.max_temperature_tenths_degrees_celsius max_temp, + weather.min_temperature_tenths_degrees_celsius min_temp, + weather.average_wind_speed_tenths_of_meters_per_second wind, + + pick_up.gid pickup_nyct2010_gid, + pick_up.ctlabel pickup_ctlabel, + pick_up.borocode pickup_borocode, + pick_up.boroname pickup_boroname, + pick_up.ct2010 pickup_ct2010, + pick_up.boroct2010 pickup_boroct2010, + pick_up.cdeligibil pickup_cdeligibil, + pick_up.ntacode pickup_ntacode, + pick_up.ntaname pickup_ntaname, + pick_up.puma pickup_puma, + + drop_off.gid dropoff_nyct2010_gid, + drop_off.ctlabel dropoff_ctlabel, + drop_off.borocode dropoff_borocode, + drop_off.boroname dropoff_boroname, + drop_off.ct2010 dropoff_ct2010, + drop_off.boroct2010 dropoff_boroct2010, + drop_off.cdeligibil dropoff_cdeligibil, + drop_off.ntacode dropoff_ntacode, + drop_off.ntaname dropoff_ntaname, + drop_off.puma dropoff_puma + FROM trips + LEFT JOIN cab_types + ON trips.cab_type_id = cab_types.id + LEFT JOIN central_park_weather_observations_raw weather + ON weather.date = trips.pickup_datetime::date + LEFT JOIN nyct2010 pick_up + ON pick_up.gid = trips.pickup_nyct2010_gid + LEFT JOIN nyct2010 drop_off + ON drop_off.gid = trips.dropoff_nyct2010_gid +) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; +``` + +La instantánea de datos se crea a una velocidad de aproximadamente 50 MB por segundo. Al crear la instantánea, PostgreSQL lee desde el disco a una velocidad de aproximadamente 28 MB por segundo. +Esto toma alrededor de 5 horas. El archivo TSV resultante es 590612904969 bytes. + +Crear una tabla temporal en ClickHouse: + +``` sql +CREATE TABLE trips +( +trip_id UInt32, +vendor_id String, +pickup_datetime DateTime, +dropoff_datetime Nullable(DateTime), +store_and_fwd_flag Nullable(FixedString(1)), +rate_code_id Nullable(UInt8), +pickup_longitude Nullable(Float64), +pickup_latitude Nullable(Float64), +dropoff_longitude Nullable(Float64), +dropoff_latitude Nullable(Float64), +passenger_count Nullable(UInt8), +trip_distance Nullable(Float64), +fare_amount Nullable(Float32), +extra Nullable(Float32), +mta_tax Nullable(Float32), +tip_amount Nullable(Float32), +tolls_amount Nullable(Float32), +ehail_fee Nullable(Float32), +improvement_surcharge Nullable(Float32), +total_amount Nullable(Float32), +payment_type Nullable(String), +trip_type Nullable(UInt8), +pickup Nullable(String), +dropoff Nullable(String), +cab_type Nullable(String), +precipitation Nullable(UInt8), +snow_depth Nullable(UInt8), +snowfall Nullable(UInt8), +max_temperature Nullable(UInt8), +min_temperature Nullable(UInt8), +average_wind_speed Nullable(UInt8), +pickup_nyct2010_gid Nullable(UInt8), +pickup_ctlabel Nullable(String), +pickup_borocode Nullable(UInt8), +pickup_boroname Nullable(String), +pickup_ct2010 Nullable(String), +pickup_boroct2010 Nullable(String), +pickup_cdeligibil Nullable(FixedString(1)), +pickup_ntacode Nullable(String), +pickup_ntaname Nullable(String), +pickup_puma Nullable(String), +dropoff_nyct2010_gid Nullable(UInt8), +dropoff_ctlabel Nullable(String), +dropoff_borocode Nullable(UInt8), +dropoff_boroname Nullable(String), +dropoff_ct2010 Nullable(String), +dropoff_boroct2010 Nullable(String), +dropoff_cdeligibil Nullable(String), +dropoff_ntacode Nullable(String), +dropoff_ntaname Nullable(String), +dropoff_puma Nullable(String) +) ENGINE = Log; +``` + +Es necesario para convertir campos a tipos de datos más correctos y, si es posible, para eliminar NULL. + +``` bash +$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv + +real 75m56.214s +``` + +Los datos se leen a una velocidad de 112-140 Mb / segundo. +La carga de datos en una tabla de tipos de registro en una secuencia tardó 76 minutos. +Los datos de esta tabla utilizan 142 GB. + +(Importar datos directamente desde Postgres también es posible usando `COPY ... TO PROGRAM`.) + +Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. + +Para empezar, crearemos una tabla en un único servidor. Posteriormente haremos la mesa distribuida. + +Crear y rellenar una tabla de resumen: + +``` sql +CREATE TABLE trips_mergetree +ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +AS SELECT + +trip_id, +CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, +toDate(pickup_datetime) AS pickup_date, +ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, +toDate(dropoff_datetime) AS dropoff_date, +ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, +assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, +assumeNotNull(rate_code_id) AS rate_code_id, +assumeNotNull(pickup_longitude) AS pickup_longitude, +assumeNotNull(pickup_latitude) AS pickup_latitude, +assumeNotNull(dropoff_longitude) AS dropoff_longitude, +assumeNotNull(dropoff_latitude) AS dropoff_latitude, +assumeNotNull(passenger_count) AS passenger_count, +assumeNotNull(trip_distance) AS trip_distance, +assumeNotNull(fare_amount) AS fare_amount, +assumeNotNull(extra) AS extra, +assumeNotNull(mta_tax) AS mta_tax, +assumeNotNull(tip_amount) AS tip_amount, +assumeNotNull(tolls_amount) AS tolls_amount, +assumeNotNull(ehail_fee) AS ehail_fee, +assumeNotNull(improvement_surcharge) AS improvement_surcharge, +assumeNotNull(total_amount) AS total_amount, +CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, +assumeNotNull(trip_type) AS trip_type, +ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, +ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, +CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, + +assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, +toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, +assumeNotNull(pickup_borocode) AS pickup_borocode, +CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, +toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, +toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, +CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, +toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, + +CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, + +toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, + +assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, +toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, +assumeNotNull(dropoff_borocode) AS dropoff_borocode, +CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, +toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, +toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, +CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, +toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, + +CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, + +toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma + +FROM trips +``` + +Esto toma 3030 segundos a una velocidad de aproximadamente 428,000 filas por segundo. +Para cargarlo más rápido, puede crear la tabla con el `Log` motor en lugar de `MergeTree`. En este caso, la descarga funciona más rápido que 200 segundos. + +La tabla utiliza 126 GB de espacio en disco. + +``` sql +SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active +``` + +``` text +┌─formatReadableSize(sum(bytes))─┐ +│ 126.18 GiB │ +└────────────────────────────────┘ +``` + +Entre otras cosas, puede ejecutar la consulta OPTIMIZE en MergeTree. Pero no es necesario ya que todo estará bien sin él. + +## Descarga de Prepared Partitions {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar +$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" +``` + +!!! info "INFO" + Si va a ejecutar las consultas que se describen a continuación, debe usar el nombre completo de la tabla, `datasets.trips_mergetree`. + +## Resultados en un solo servidor {#results-on-single-server} + +Q1: + +``` sql +SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type +``` + +0.490 segundos. + +Q2: + +``` sql +SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count +``` + +1.224 segundos. + +Q3: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year +``` + +2.104 segundos. + +Q4: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) +FROM trips_mergetree +GROUP BY passenger_count, year, distance +ORDER BY year, count(*) DESC +``` + +3.593 segundos. + +Se utilizó el siguiente servidor: + +Dos CPU Intel (R) Xeon (R) E5-2650 v2 @ 2.60GHz, 16 núcleos físicos en total, 128 GiB RAM, 8x6 TB HD en hardware RAID-5 + +El tiempo de ejecución es el mejor de tres carreras. Pero a partir de la segunda ejecución, las consultas leen datos de la memoria caché del sistema de archivos. No se produce más almacenamiento en caché: los datos se leen y procesan en cada ejecución. + +Creación de una tabla en tres servidores: + +En cada servidor: + +``` sql +CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +``` + +En el servidor de origen: + +``` sql +CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) +``` + +La siguiente consulta redistribuye los datos: + +``` sql +INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree +``` + +Esto tarda 2454 segundos. + +En tres servidores: + +Q1: 0.212 segundos. +Q2: 0.438 segundos. +Q3: 0.733 segundos. +Q4: 1.241 segundos. + +No hay sorpresas aquí, ya que las consultas se escalan linealmente. + +También tenemos los resultados de un clúster de 140 servidores: + +Q1: 0,028 seg. +Q2: 0,043 seg. +Q3: 0,051 seg. +Q4: 0,072 seg. + +En este caso, el tiempo de procesamiento de la consulta está determinado sobre todo por la latencia de la red. +Ejecutamos consultas utilizando un cliente ubicado en un centro de datos de Yandex en Finlandia en un clúster en Rusia, que agregó aproximadamente 20 ms de latencia. + +## Resumen {#summary} + +| servidor | Q1 | Q2 | Q3 | Q4 | +|----------|-------|-------|-------|-------| +| 1 | 0.490 | 1.224 | 2.104 | 3.593 | +| 3 | 0.212 | 0.438 | 0.733 | 1.241 | +| 140 | 0.028 | 0.043 | 0.051 | 0.072 | + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/es/getting-started/example-datasets/ontime.md b/docs/es/getting-started/example-datasets/ontime.md new file mode 100644 index 00000000000..b0662ef8b53 --- /dev/null +++ b/docs/es/getting-started/example-datasets/ontime.md @@ -0,0 +1,412 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 15 +toc_title: A tiempo +--- + +# A tiempo {#ontime} + +Este conjunto de datos se puede obtener de dos maneras: + +- importación de datos sin procesar +- descarga de particiones preparadas + +## Importar desde datos sin procesar {#import-from-raw-data} + +Descarga de datos: + +``` bash +for s in `seq 1987 2018` +do +for m in `seq 1 12` +do +wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip +done +done +``` + +(a partir de https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) + +Creación de una tabla: + +``` sql +CREATE TABLE `ontime` ( + `Year` UInt16, + `Quarter` UInt8, + `Month` UInt8, + `DayofMonth` UInt8, + `DayOfWeek` UInt8, + `FlightDate` Date, + `UniqueCarrier` FixedString(7), + `AirlineID` Int32, + `Carrier` FixedString(2), + `TailNum` String, + `FlightNum` String, + `OriginAirportID` Int32, + `OriginAirportSeqID` Int32, + `OriginCityMarketID` Int32, + `Origin` FixedString(5), + `OriginCityName` String, + `OriginState` FixedString(2), + `OriginStateFips` String, + `OriginStateName` String, + `OriginWac` Int32, + `DestAirportID` Int32, + `DestAirportSeqID` Int32, + `DestCityMarketID` Int32, + `Dest` FixedString(5), + `DestCityName` String, + `DestState` FixedString(2), + `DestStateFips` String, + `DestStateName` String, + `DestWac` Int32, + `CRSDepTime` Int32, + `DepTime` Int32, + `DepDelay` Int32, + `DepDelayMinutes` Int32, + `DepDel15` Int32, + `DepartureDelayGroups` String, + `DepTimeBlk` String, + `TaxiOut` Int32, + `WheelsOff` Int32, + `WheelsOn` Int32, + `TaxiIn` Int32, + `CRSArrTime` Int32, + `ArrTime` Int32, + `ArrDelay` Int32, + `ArrDelayMinutes` Int32, + `ArrDel15` Int32, + `ArrivalDelayGroups` Int32, + `ArrTimeBlk` String, + `Cancelled` UInt8, + `CancellationCode` FixedString(1), + `Diverted` UInt8, + `CRSElapsedTime` Int32, + `ActualElapsedTime` Int32, + `AirTime` Int32, + `Flights` Int32, + `Distance` Int32, + `DistanceGroup` UInt8, + `CarrierDelay` Int32, + `WeatherDelay` Int32, + `NASDelay` Int32, + `SecurityDelay` Int32, + `LateAircraftDelay` Int32, + `FirstDepTime` String, + `TotalAddGTime` String, + `LongestAddGTime` String, + `DivAirportLandings` String, + `DivReachedDest` String, + `DivActualElapsedTime` String, + `DivArrDelay` String, + `DivDistance` String, + `Div1Airport` String, + `Div1AirportID` Int32, + `Div1AirportSeqID` Int32, + `Div1WheelsOn` String, + `Div1TotalGTime` String, + `Div1LongestGTime` String, + `Div1WheelsOff` String, + `Div1TailNum` String, + `Div2Airport` String, + `Div2AirportID` Int32, + `Div2AirportSeqID` Int32, + `Div2WheelsOn` String, + `Div2TotalGTime` String, + `Div2LongestGTime` String, + `Div2WheelsOff` String, + `Div2TailNum` String, + `Div3Airport` String, + `Div3AirportID` Int32, + `Div3AirportSeqID` Int32, + `Div3WheelsOn` String, + `Div3TotalGTime` String, + `Div3LongestGTime` String, + `Div3WheelsOff` String, + `Div3TailNum` String, + `Div4Airport` String, + `Div4AirportID` Int32, + `Div4AirportSeqID` Int32, + `Div4WheelsOn` String, + `Div4TotalGTime` String, + `Div4LongestGTime` String, + `Div4WheelsOff` String, + `Div4TailNum` String, + `Div5Airport` String, + `Div5AirportID` Int32, + `Div5AirportSeqID` Int32, + `Div5WheelsOn` String, + `Div5TotalGTime` String, + `Div5LongestGTime` String, + `Div5WheelsOff` String, + `Div5TailNum` String +) ENGINE = MergeTree +PARTITION BY Year +ORDER BY (Carrier, FlightDate) +SETTINGS index_granularity = 8192; +``` + +Carga de datos: + +``` bash +$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done +``` + +## Descarga de Prepared Partitions {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar +$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.ontime" +``` + +!!! info "INFO" + Si va a ejecutar las consultas que se describen a continuación, debe usar el nombre completo de la tabla, `datasets.ontime`. + +## Consulta {#queries} + +Q0. + +``` sql +SELECT avg(c1) +FROM +( + SELECT Year, Month, count(*) AS c1 + FROM ontime + GROUP BY Year, Month +); +``` + +Q1. El número de vuelos por día desde el año 2000 hasta 2008 + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +Preguntas frecuentes El número de vuelos retrasados por más de 10 minutos, agrupados por el día de la semana, para 2000-2008 + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +Q3. El número de retrasos por parte del aeropuerto para 2000-2008 + +``` sql +SELECT Origin, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY Origin +ORDER BY c DESC +LIMIT 10; +``` + +Preguntas más frecuentes Número de retrasos por transportista para 2007 + +``` sql +SELECT Carrier, count(*) +FROM ontime +WHERE DepDelay>10 AND Year=2007 +GROUP BY Carrier +ORDER BY count(*) DESC; +``` + +Q5. El porcentaje de retrasos por transportista para 2007 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year=2007 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year=2007 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Mejor versión de la misma consulta: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year=2007 +GROUP BY Carrier +ORDER BY c3 DESC +``` + +¿Por qué? La solicitud anterior de una gama más amplia de años, 2000-2008 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year>=2000 AND Year<=2008 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year>=2000 AND Year<=2008 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Mejor versión de la misma consulta: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY Carrier +ORDER BY c3 DESC; +``` + +Preguntas frecuentes Porcentaje de vuelos retrasados por más de 10 minutos, por año + +``` sql +SELECT Year, c1/c2 +FROM +( + select + Year, + count(*)*100 as c1 + from ontime + WHERE DepDelay>10 + GROUP BY Year +) +JOIN +( + select + Year, + count(*) as c2 + from ontime + GROUP BY Year +) USING (Year) +ORDER BY Year; +``` + +Mejor versión de la misma consulta: + +``` sql +SELECT Year, avg(DepDelay>10)*100 +FROM ontime +GROUP BY Year +ORDER BY Year; +``` + +¿Por qué? Los destinos más populares por el número de ciudades conectadas directamente para varios rangos de año + +``` sql +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +WHERE Year >= 2000 and Year <= 2010 +GROUP BY DestCityName +ORDER BY u DESC LIMIT 10; +``` + +Q9. + +``` sql +SELECT Year, count(*) AS c1 +FROM ontime +GROUP BY Year; +``` + +Q10. + +``` sql +SELECT + min(Year), max(Year), Carrier, count(*) AS cnt, + sum(ArrDelayMinutes>30) AS flights_delayed, + round(sum(ArrDelayMinutes>30)/count(*),2) AS rate +FROM ontime +WHERE + DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') + AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') + AND FlightDate < '2010-01-01' +GROUP by Carrier +HAVING cnt>100000 and max(Year)>1990 +ORDER by rate DESC +LIMIT 1000; +``` + +Bono: + +``` sql +SELECT avg(cnt) +FROM +( + SELECT Year,Month,count(*) AS cnt + FROM ontime + WHERE DepDel15=1 + GROUP BY Year,Month +); + +SELECT avg(c1) FROM +( + SELECT Year,Month,count(*) AS c1 + FROM ontime + GROUP BY Year,Month +); + +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +GROUP BY DestCityName +ORDER BY u DESC +LIMIT 10; + +SELECT OriginCityName, DestCityName, count() AS c +FROM ontime +GROUP BY OriginCityName, DestCityName +ORDER BY c DESC +LIMIT 10; + +SELECT OriginCityName, count() AS c +FROM ontime +GROUP BY OriginCityName +ORDER BY c DESC +LIMIT 10; +``` + +Esta prueba de rendimiento fue creada por Vadim Tkachenko. Ver: + +- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ +- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ +- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ +- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ +- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ +- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/es/getting-started/example-datasets/star-schema.md b/docs/es/getting-started/example-datasets/star-schema.md new file mode 100644 index 00000000000..43f878eb205 --- /dev/null +++ b/docs/es/getting-started/example-datasets/star-schema.md @@ -0,0 +1,370 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 20 +toc_title: Estrella Schema Benchmark +--- + +# Estrella Schema Benchmark {#star-schema-benchmark} + +Compilación de dbgen: + +``` bash +$ git clone git@github.com:vadimtk/ssb-dbgen.git +$ cd ssb-dbgen +$ make +``` + +Generación de datos: + +!!! warning "Atención" + Con `-s 100` dbgen genera 600 millones de filas (67 GB), mientras que `-s 1000` genera 6 mil millones de filas (lo que lleva mucho tiempo) + +``` bash +$ ./dbgen -s 1000 -T c +$ ./dbgen -s 1000 -T l +$ ./dbgen -s 1000 -T p +$ ./dbgen -s 1000 -T s +$ ./dbgen -s 1000 -T d +``` + +Creación de tablas en ClickHouse: + +``` sql +CREATE TABLE customer +( + C_CUSTKEY UInt32, + C_NAME String, + C_ADDRESS String, + C_CITY LowCardinality(String), + C_NATION LowCardinality(String), + C_REGION LowCardinality(String), + C_PHONE String, + C_MKTSEGMENT LowCardinality(String) +) +ENGINE = MergeTree ORDER BY (C_CUSTKEY); + +CREATE TABLE lineorder +( + LO_ORDERKEY UInt32, + LO_LINENUMBER UInt8, + LO_CUSTKEY UInt32, + LO_PARTKEY UInt32, + LO_SUPPKEY UInt32, + LO_ORDERDATE Date, + LO_ORDERPRIORITY LowCardinality(String), + LO_SHIPPRIORITY UInt8, + LO_QUANTITY UInt8, + LO_EXTENDEDPRICE UInt32, + LO_ORDTOTALPRICE UInt32, + LO_DISCOUNT UInt8, + LO_REVENUE UInt32, + LO_SUPPLYCOST UInt32, + LO_TAX UInt8, + LO_COMMITDATE Date, + LO_SHIPMODE LowCardinality(String) +) +ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY); + +CREATE TABLE part +( + P_PARTKEY UInt32, + P_NAME String, + P_MFGR LowCardinality(String), + P_CATEGORY LowCardinality(String), + P_BRAND LowCardinality(String), + P_COLOR LowCardinality(String), + P_TYPE LowCardinality(String), + P_SIZE UInt8, + P_CONTAINER LowCardinality(String) +) +ENGINE = MergeTree ORDER BY P_PARTKEY; + +CREATE TABLE supplier +( + S_SUPPKEY UInt32, + S_NAME String, + S_ADDRESS String, + S_CITY LowCardinality(String), + S_NATION LowCardinality(String), + S_REGION LowCardinality(String), + S_PHONE String +) +ENGINE = MergeTree ORDER BY S_SUPPKEY; +``` + +Insertar datos: + +``` bash +$ clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl +$ clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl +$ clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl +$ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl +``` + +Conversión “star schema” a desnormalizado “flat schema”: + +``` sql +SET max_memory_usage = 20000000000; + +CREATE TABLE lineorder_flat +ENGINE = MergeTree +PARTITION BY toYear(LO_ORDERDATE) +ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS +SELECT + l.LO_ORDERKEY AS LO_ORDERKEY, + l.LO_LINENUMBER AS LO_LINENUMBER, + l.LO_CUSTKEY AS LO_CUSTKEY, + l.LO_PARTKEY AS LO_PARTKEY, + l.LO_SUPPKEY AS LO_SUPPKEY, + l.LO_ORDERDATE AS LO_ORDERDATE, + l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY, + l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY, + l.LO_QUANTITY AS LO_QUANTITY, + l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE, + l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE, + l.LO_DISCOUNT AS LO_DISCOUNT, + l.LO_REVENUE AS LO_REVENUE, + l.LO_SUPPLYCOST AS LO_SUPPLYCOST, + l.LO_TAX AS LO_TAX, + l.LO_COMMITDATE AS LO_COMMITDATE, + l.LO_SHIPMODE AS LO_SHIPMODE, + c.C_NAME AS C_NAME, + c.C_ADDRESS AS C_ADDRESS, + c.C_CITY AS C_CITY, + c.C_NATION AS C_NATION, + c.C_REGION AS C_REGION, + c.C_PHONE AS C_PHONE, + c.C_MKTSEGMENT AS C_MKTSEGMENT, + s.S_NAME AS S_NAME, + s.S_ADDRESS AS S_ADDRESS, + s.S_CITY AS S_CITY, + s.S_NATION AS S_NATION, + s.S_REGION AS S_REGION, + s.S_PHONE AS S_PHONE, + p.P_NAME AS P_NAME, + p.P_MFGR AS P_MFGR, + p.P_CATEGORY AS P_CATEGORY, + p.P_BRAND AS P_BRAND, + p.P_COLOR AS P_COLOR, + p.P_TYPE AS P_TYPE, + p.P_SIZE AS P_SIZE, + p.P_CONTAINER AS P_CONTAINER +FROM lineorder AS l +INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY +INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY +INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; +``` + +Las consultas: + +Q1.1 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toYear(LO_ORDERDATE) = 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25; +``` + +Q1.2 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toYYYYMM(LO_ORDERDATE) = 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35; +``` + +Q1.3 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toISOWeek(LO_ORDERDATE) = 6 AND toYear(LO_ORDERDATE) = 1994 + AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35; +``` + +Q2.1 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q2.2 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_BRAND >= 'MFGR#2221' AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q2.3 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q3.1 + +``` sql +SELECT + C_NATION, + S_NATION, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year >= 1992 AND year <= 1997 +GROUP BY + C_NATION, + S_NATION, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.2 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE C_NATION = 'UNITED STATES' AND S_NATION = 'UNITED STATES' AND year >= 1992 AND year <= 1997 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.3 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND year >= 1992 AND year <= 1997 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.4 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND toYYYYMM(LO_ORDERDATE) = 199712 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q4.1 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + C_NATION, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') +GROUP BY + year, + C_NATION +ORDER BY + year ASC, + C_NATION ASC; +``` + +Q4.2 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + S_NATION, + P_CATEGORY, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year = 1997 OR year = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') +GROUP BY + year, + S_NATION, + P_CATEGORY +ORDER BY + year ASC, + S_NATION ASC, + P_CATEGORY ASC; +``` + +Q4.3 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + S_CITY, + P_BRAND, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE S_NATION = 'UNITED STATES' AND (year = 1997 OR year = 1998) AND P_CATEGORY = 'MFGR#14' +GROUP BY + year, + S_CITY, + P_BRAND +ORDER BY + year ASC, + S_CITY ASC, + P_BRAND ASC; +``` + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/star_schema/) diff --git a/docs/es/getting-started/example-datasets/wikistat.md b/docs/es/getting-started/example-datasets/wikistat.md new file mode 100644 index 00000000000..49d7263cdec --- /dev/null +++ b/docs/es/getting-started/example-datasets/wikistat.md @@ -0,0 +1,35 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 18 +toc_title: "Nombre de la red inal\xE1mbrica (SSID):" +--- + +# Nombre de la red inalámbrica (SSID): {#wikistat} + +Ver: http://dumps.wikimedia.org/other/pagecounts-raw/ + +Creación de una tabla: + +``` sql +CREATE TABLE wikistat +( + date Date, + time DateTime, + project String, + subproject String, + path String, + hits UInt64, + size UInt64 +) ENGINE = MergeTree(date, (path, time), 8192); +``` + +Carga de datos: + +``` bash +$ for i in {2007..2016}; do for j in {01..12}; do echo $i-$j >&2; curl -sSL "http://dumps.wikimedia.org/other/pagecounts-raw/$i/$i-$j/" | grep -oE 'pagecounts-[0-9]+-[0-9]+\.gz'; done; done | sort | uniq | tee links.txt +$ cat links.txt | while read link; do wget http://dumps.wikimedia.org/other/pagecounts-raw/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1/')/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1-\2/')/$link; done +$ ls -1 /opt/wikistat/ | grep gz | while read i; do echo $i; gzip -cd /opt/wikistat/$i | ./wikistat-loader --time="$(echo -n $i | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})\.gz/\1-\2-\3 \4-00-00/')" | clickhouse-client --query="INSERT INTO wikistat FORMAT TabSeparated"; done +``` + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/wikistat/) diff --git a/docs/es/getting-started/index.md b/docs/es/getting-started/index.md new file mode 100644 index 00000000000..681c2017ac1 --- /dev/null +++ b/docs/es/getting-started/index.md @@ -0,0 +1,17 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Primeros pasos +toc_hidden: true +toc_priority: 8 +toc_title: oculto +--- + +# Primeros pasos {#getting-started} + +Si eres nuevo en ClickHouse y quieres tener una sensación práctica de su rendimiento, antes que nada, debes pasar por el [proceso de instalación](install.md). Después de eso puedes: + +- [Ir a través de tutorial detallado](tutorial.md) +- [Experimente con conjuntos de datos de ejemplo](example-datasets/ontime.md) + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/es/getting-started/install.md b/docs/es/getting-started/install.md new file mode 100644 index 00000000000..89b5735f192 --- /dev/null +++ b/docs/es/getting-started/install.md @@ -0,0 +1,182 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 11 +toc_title: "Instalaci\xF3n" +--- + +# Instalación {#installation} + +## Requisitos del sistema {#system-requirements} + +ClickHouse puede ejecutarse en cualquier Linux, FreeBSD o Mac OS X con arquitectura de CPU x86\_64, AArch64 o PowerPC64LE. + +Los binarios oficiales preconstruidos generalmente se compilan para x86\_64 y aprovechan el conjunto de instrucciones SSE 4.2, por lo que, a menos que se indique lo contrario, el uso de la CPU que lo admite se convierte en un requisito adicional del sistema. Aquí está el comando para verificar si la CPU actual tiene soporte para SSE 4.2: + +``` bash +$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" +``` + +Para ejecutar ClickHouse en procesadores que no admiten SSE 4.2 o tienen arquitectura AArch64 o PowerPC64LE, debe [construir ClickHouse a partir de fuentes](#from-sources) con los ajustes de configuración adecuados. + +## Opciones de instalación disponibles {#available-installation-options} + +### De paquetes DEB {#install-from-deb-packages} + +Se recomienda utilizar pre-compilado oficial `deb` Paquetes para Debian o Ubuntu. Ejecute estos comandos para instalar paquetes: + +``` bash +{% include 'install/deb.sh' %} +``` + +Si desea utilizar la versión más reciente, reemplace `stable` con `testing` (esto se recomienda para sus entornos de prueba). + +También puede descargar e instalar paquetes manualmente desde [aqui](https://repo.clickhouse.tech/deb/stable/main/). + +#### Paquete {#packages} + +- `clickhouse-common-static` — Installs ClickHouse compiled binary files. +- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` e instala la configuración predeterminada del servidor. +- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` y otras herramientas relacionadas con el cliente. e instala los archivos de configuración del cliente. +- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. + +### De paquetes RPM {#from-rpm-packages} + +Se recomienda utilizar pre-compilado oficial `rpm` También puede utilizar los paquetes para CentOS, RedHat y todas las demás distribuciones de Linux basadas en rpm. + +Primero, necesitas agregar el repositorio oficial: + +``` bash +sudo yum install yum-utils +sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG +sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 +``` + +Si desea utilizar la versión más reciente, reemplace `stable` con `testing` (esto se recomienda para sus entornos de prueba). El `prestable` etiqueta a veces está disponible también. + +A continuación, ejecute estos comandos para instalar paquetes: + +``` bash +sudo yum install clickhouse-server clickhouse-client +``` + +También puede descargar e instalar paquetes manualmente desde [aqui](https://repo.clickhouse.tech/rpm/stable/x86_64). + +### De archivos Tgz {#from-tgz-archives} + +Se recomienda utilizar pre-compilado oficial `tgz` para todas las distribuciones de Linux, donde la instalación de `deb` o `rpm` paquetes no es posible. + +La versión requerida se puede descargar con `curl` o `wget` desde el repositorio https://repo.clickhouse.tech/tgz/. +Después de eso, los archivos descargados deben desempaquetarse e instalarse con scripts de instalación. Ejemplo para la última versión: + +``` bash +export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz + +tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz +sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz +sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-server-$LATEST_VERSION.tgz +sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh +sudo /etc/init.d/clickhouse-server start + +tar -xzvf clickhouse-client-$LATEST_VERSION.tgz +sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh +``` + +Para los entornos de producción, se recomienda utilizar las últimas `stable`-versión. Puede encontrar su número en la página de GitHub https://github.com/ClickHouse/ClickHouse/tags con postfix `-stable`. + +### Desde Docker Image {#from-docker-image} + +Para ejecutar ClickHouse dentro de Docker, siga la guía en [Eje de acoplador](https://hub.docker.com/r/yandex/clickhouse-server/). Esas imágenes usan oficial `deb` paquetes dentro. + +### De fuentes {#from-sources} + +Para compilar manualmente ClickHouse, siga las instrucciones para [Linux](../development/build.md) o [Mac OS X](../development/build-osx.md). + +Puede compilar paquetes e instalarlos o usar programas sin instalar paquetes. Además, al construir manualmente, puede deshabilitar el requisito de SSE 4.2 o compilar para CPU AArch64. + + Client: programs/clickhouse-client + Server: programs/clickhouse-server + +Tendrá que crear carpetas de datos y metadatos y `chown` para el usuario deseado. Sus rutas se pueden cambiar en la configuración del servidor (src/programs/server/config.xml), por defecto son: + + /opt/clickhouse/data/default/ + /opt/clickhouse/metadata/default/ + +En Gentoo, puedes usar `emerge clickhouse` para instalar ClickHouse desde fuentes. + +## Lanzar {#launch} + +Para iniciar el servidor como demonio, ejecute: + +``` bash +$ sudo service clickhouse-server start +``` + +Si no tienes `service` comando ejecutar como + +``` bash +$ sudo /etc/init.d/clickhouse-server start +``` + +Vea los registros en el `/var/log/clickhouse-server/` directorio. + +Si el servidor no se inicia, compruebe las configuraciones en el archivo `/etc/clickhouse-server/config.xml`. + +También puede iniciar manualmente el servidor desde la consola: + +``` bash +$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml +``` + +En este caso, el registro se imprimirá en la consola, lo cual es conveniente durante el desarrollo. +Si el archivo de configuración está en el directorio actual, no es necesario `--config-file` parámetro. De forma predeterminada, utiliza `./config.xml`. + +ClickHouse admite la configuración de restricción de acceso. Están ubicados en el `users.xml` archivo (junto a `config.xml`). +De forma predeterminada, se permite el acceso desde cualquier lugar `default` usuario, sin una contraseña. Ver `user/default/networks`. +Para obtener más información, consulte la sección [“Configuration Files”](../operations/configuration-files.md). + +Después de iniciar el servidor, puede usar el cliente de línea de comandos para conectarse a él: + +``` bash +$ clickhouse-client +``` + +Por defecto, se conecta a `localhost:9000` en nombre del usuario `default` sin una contraseña. También se puede usar para conectarse a un servidor remoto usando `--host` argumento. + +El terminal debe usar codificación UTF-8. +Para obtener más información, consulte la sección [“Command-line client”](../interfaces/cli.md). + +Ejemplo: + +``` bash +$ ./clickhouse-client +ClickHouse client version 0.0.18749. +Connecting to localhost:9000. +Connected to ClickHouse server version 0.0.18749. + +:) SELECT 1 + +SELECT 1 + +┌─1─┐ +│ 1 │ +└───┘ + +1 rows in set. Elapsed: 0.003 sec. + +:) +``` + +**Felicidades, el sistema funciona!** + +Para continuar experimentando, puede descargar uno de los conjuntos de datos de prueba o pasar por [tutorial](https://clickhouse.tech/tutorial.html). + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/es/getting-started/playground.md b/docs/es/getting-started/playground.md new file mode 100644 index 00000000000..1ab7246e2d4 --- /dev/null +++ b/docs/es/getting-started/playground.md @@ -0,0 +1,48 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 14 +toc_title: Infantil +--- + +# Zona de juegos ClickHouse {#clickhouse-playground} + +[Zona de juegos ClickHouse](https://play.clickhouse.tech?file=welcome) permite a las personas experimentar con ClickHouse ejecutando consultas al instante, sin configurar su servidor o clúster. +Varios conjuntos de datos de ejemplo están disponibles en Playground, así como consultas de ejemplo que muestran las características de ClickHouse. + +Las consultas se ejecutan como un usuario de sólo lectura. Implica algunas limitaciones: + +- No se permiten consultas DDL +- Las consultas INSERT no están permitidas + +También se aplican los siguientes valores: +- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) +- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) +- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) +- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) + +ClickHouse Playground da la experiencia de m2.pequeño +[Servicio administrado para ClickHouse](https://cloud.yandex.com/services/managed-clickhouse) +instancia alojada en [El Yandex.Nube](https://cloud.yandex.com/). +Más información sobre [proveedores de la nube](../commercial/cloud.md). + +La interfaz web de ClickHouse Playground realiza solicitudes a través de ClickHouse [HTTP API](../interfaces/http.md). +El backend Playground es solo un clúster ClickHouse sin ninguna aplicación adicional del lado del servidor. +El punto final HTTPS de ClickHouse también está disponible como parte de Playground. + +Puede realizar consultas al patio de recreo utilizando cualquier cliente HTTP, por ejemplo [rizo](https://curl.haxx.se) o [wget](https://www.gnu.org/software/wget/), o configurar una conexión usando [JDBC](../interfaces/jdbc.md) o [ODBC](../interfaces/odbc.md) controlador. +Más información sobre los productos de software compatibles con ClickHouse está disponible [aqui](../interfaces/index.md). + +| Parámetro | Valor | +|:------------|:----------------------------------------------| +| Punto final | https://play-api.casa de clic.tecnología:8443 | +| Usuario | `playground` | +| Contraseña | `clickhouse` | + +Tenga en cuenta que este extremo requiere una conexión segura. + +Ejemplo: + +``` bash +curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" +``` diff --git a/docs/es/getting-started/tutorial.md b/docs/es/getting-started/tutorial.md new file mode 100644 index 00000000000..ccc07e50468 --- /dev/null +++ b/docs/es/getting-started/tutorial.md @@ -0,0 +1,666 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 12 +toc_title: Tutorial +--- + +# Tutorial de ClickHouse {#clickhouse-tutorial} + +## Qué Esperar de Este Tutorial? {#what-to-expect-from-this-tutorial} + +Al pasar por este tutorial, aprenderá cómo configurar un clúster de ClickHouse simple. Será pequeño, pero tolerante a fallos y escalable. Luego usaremos uno de los conjuntos de datos de ejemplo para llenarlo con datos y ejecutar algunas consultas de demostración. + +## Configuración de nodo único {#single-node-setup} + +Para posponer las complejidades de un entorno distribuido, comenzaremos con la implementación de ClickHouse en un único servidor o máquina virtual. ClickHouse generalmente se instala desde [deb](install.md#install-from-deb-packages) o [RPM](install.md#from-rpm-packages) paquetes, pero hay [alternativa](install.md#from-docker-image) para los sistemas operativos que no los admiten. + +Por ejemplo, ha elegido `deb` paquetes y ejecutado: + +``` bash +{% include 'install/deb.sh' %} +``` + +¿Qué tenemos en los paquetes que tengo instalados: + +- `clickhouse-client` el paquete contiene [Casa de clics-cliente](../interfaces/cli.md) aplicación, cliente interactivo de la consola ClickHouse. +- `clickhouse-common` El paquete contiene un archivo ejecutable ClickHouse. +- `clickhouse-server` El paquete contiene archivos de configuración para ejecutar ClickHouse como servidor. + +Los archivos de configuración del servidor se encuentran en `/etc/clickhouse-server/`. Antes de ir más lejos, tenga en cuenta el `` elemento en `config.xml`. La ruta determina la ubicación para el almacenamiento de datos, por lo que debe ubicarse en un volumen con gran capacidad de disco; el valor predeterminado es `/var/lib/clickhouse/`. Si desea ajustar la configuración, no es útil editar directamente `config.xml` archivo, teniendo en cuenta que podría ser reescrito en futuras actualizaciones de paquetes. La forma recomendada de anular los elementos de configuración es crear [archivos en config.directorio d](../operations/configuration-files.md) que sirven como “patches” de configuración.XML. + +Como habrás notado, `clickhouse-server` no se inicia automáticamente después de la instalación del paquete. Tampoco se reiniciará automáticamente después de las actualizaciones. La forma en que inicia el servidor depende de su sistema de inicio, por lo general, es: + +``` bash +sudo service clickhouse-server start +``` + +o + +``` bash +sudo /etc/init.d/clickhouse-server start +``` + +La ubicación predeterminada para los registros del servidor es `/var/log/clickhouse-server/`. El servidor está listo para manejar las conexiones de cliente una vez que registra el `Ready for connections` mensaje. + +Una vez que el `clickhouse-server` está en funcionamiento, podemos usar `clickhouse-client` para conectarse al servidor y ejecutar algunas consultas de prueba como `SELECT "Hello, world!";`. + +
+ +Consejos rápidos para clickhouse-cliente + +Modo interactivo: + +``` bash +clickhouse-client +clickhouse-client --host=... --port=... --user=... --password=... +``` + +Habilitar consultas multilínea: + +``` bash +clickhouse-client -m +clickhouse-client --multiline +``` + +Ejecutar consultas en modo por lotes: + +``` bash +clickhouse-client --query='SELECT 1' +echo 'SELECT 1' | clickhouse-client +clickhouse-client <<< 'SELECT 1' +``` + +Insertar datos de un archivo en el formato especificado: + +``` bash +clickhouse-client --query='INSERT INTO table VALUES' < data.txt +clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv +``` + +
+ +## Importar conjunto de datos de muestra {#import-sample-dataset} + +Ahora es el momento de llenar nuestro servidor ClickHouse con algunos datos de muestra. En este tutorial, usaremos los datos anónimos de Yandex.Metrica, el primer servicio que ejecuta ClickHouse en forma de producción antes de que se convirtiera en código abierto (más sobre eso en [sección de historia](../introduction/history.md)). Hay [múltiples formas de importar Yandex.Conjunto de datos de Metrica](example-datasets/metrica.md), y por el bien del tutorial, iremos con el más realista. + +### Descargar y extraer datos de tabla {#download-and-extract-table-data} + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +``` + +Los archivos extraídos tienen un tamaño de aproximadamente 10 GB. + +### Crear tablas {#create-tables} + +Como en la mayoría de los sistemas de gestión de bases de datos, ClickHouse agrupa lógicamente las tablas en “databases”. Hay un `default` base de datos, pero crearemos una nueva llamada `tutorial`: + +``` bash +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" +``` + +La sintaxis para crear tablas es mucho más complicada en comparación con las bases de datos (ver [referencia](../sql-reference/statements/create.md). En general `CREATE TABLE` declaración tiene que especificar tres cosas clave: + +1. Nombre de la tabla que se va a crear. +2. Table schema, i.e. list of columns and their [tipos de datos](../sql-reference/data-types/index.md). +3. [Motor de tabla](../engines/table-engines/index.md) y su configuración, que determina todos los detalles sobre cómo se ejecutarán físicamente las consultas a esta tabla. + +El Yandex.Metrica es un servicio de análisis web, y el conjunto de datos de muestra no cubre toda su funcionalidad, por lo que solo hay dos tablas para crear: + +- `hits` es una tabla con cada acción realizada por todos los usuarios en todos los sitios web cubiertos por el servicio. +- `visits` es una tabla que contiene sesiones precompiladas en lugar de acciones individuales. + +Veamos y ejecutemos las consultas de tabla de creación real para estas tablas: + +``` sql +CREATE TABLE tutorial.hits_v1 +( + `WatchID` UInt64, + `JavaEnable` UInt8, + `Title` String, + `GoodEvent` Int16, + `EventTime` DateTime, + `EventDate` Date, + `CounterID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RegionID` UInt32, + `UserID` UInt64, + `CounterClass` Int8, + `OS` UInt8, + `UserAgent` UInt8, + `URL` String, + `Referer` String, + `URLDomain` String, + `RefererDomain` String, + `Refresh` UInt8, + `IsRobot` UInt8, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `FlashMinor2` String, + `NetMajor` UInt8, + `NetMinor` UInt8, + `UserAgentMajor` UInt16, + `UserAgentMinor` FixedString(2), + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `MobilePhone` UInt8, + `MobilePhoneModel` String, + `Params` String, + `IPNetworkID` UInt32, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `IsArtifical` UInt8, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `ClientTimeZone` Int16, + `ClientEventTime` DateTime, + `SilverlightVersion1` UInt8, + `SilverlightVersion2` UInt8, + `SilverlightVersion3` UInt32, + `SilverlightVersion4` UInt16, + `PageCharset` String, + `CodeVersion` UInt32, + `IsLink` UInt8, + `IsDownload` UInt8, + `IsNotBounce` UInt8, + `FUniqID` UInt64, + `HID` UInt32, + `IsOldCounter` UInt8, + `IsEvent` UInt8, + `IsParameter` UInt8, + `DontCountHits` UInt8, + `WithHash` UInt8, + `HitColor` FixedString(1), + `UTCEventTime` DateTime, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `WindowName` Int32, + `OpenerName` Int32, + `HistoryLength` Int16, + `BrowserLanguage` FixedString(2), + `BrowserCountry` FixedString(2), + `SocialNetwork` String, + `SocialAction` String, + `HTTPError` UInt16, + `SendTiming` Int32, + `DNSTiming` Int32, + `ConnectTiming` Int32, + `ResponseStartTiming` Int32, + `ResponseEndTiming` Int32, + `FetchTiming` Int32, + `RedirectTiming` Int32, + `DOMInteractiveTiming` Int32, + `DOMContentLoadedTiming` Int32, + `DOMCompleteTiming` Int32, + `LoadEventStartTiming` Int32, + `LoadEventEndTiming` Int32, + `NSToDOMContentLoadedTiming` Int32, + `FirstPaintTiming` Int32, + `RedirectCount` Int8, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `ParamPrice` Int64, + `ParamOrderID` String, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `GoalsReached` Array(UInt32), + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `RefererHash` UInt64, + `URLHash` UInt64, + `CLID` UInt32, + `YCLID` UInt64, + `ShareService` String, + `ShareURL` String, + `ShareTitle` String, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `IslandID` FixedString(16), + `RequestNum` UInt32, + `RequestTry` UInt8 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +``` sql +CREATE TABLE tutorial.visits_v1 +( + `CounterID` UInt32, + `StartDate` Date, + `Sign` Int8, + `IsNew` UInt8, + `VisitID` UInt64, + `UserID` UInt64, + `StartTime` DateTime, + `Duration` UInt32, + `UTCStartTime` DateTime, + `PageViews` Int32, + `Hits` Int32, + `IsBounce` UInt8, + `Referer` String, + `StartURL` String, + `RefererDomain` String, + `StartURLDomain` String, + `EndURL` String, + `LinkURL` String, + `IsDownload` UInt8, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `PlaceID` Int32, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `IsYandex` UInt8, + `GoalReachesDepth` Int32, + `GoalReachesURL` Int32, + `GoalReachesAny` Int32, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `MobilePhoneModel` String, + `ClientEventTime` DateTime, + `RegionID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `IPNetworkID` UInt32, + `SilverlightVersion3` UInt32, + `CodeVersion` UInt32, + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `UserAgentMajor` UInt16, + `UserAgentMinor` UInt16, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `SilverlightVersion2` UInt8, + `SilverlightVersion4` UInt16, + `FlashVersion3` UInt16, + `FlashVersion4` UInt16, + `ClientTimeZone` Int16, + `OS` UInt8, + `UserAgent` UInt8, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `NetMajor` UInt8, + `NetMinor` UInt8, + `MobilePhone` UInt8, + `SilverlightVersion1` UInt8, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `JavaEnable` UInt8, + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `BrowserLanguage` UInt16, + `BrowserCountry` UInt16, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `Params` Array(String), + `Goals` Nested( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32), + `WatchIDs` Array(UInt64), + `ParamSumPrice` Int64, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `ClickLogID` UInt64, + `ClickEventID` Int32, + `ClickGoodEvent` Int32, + `ClickEventTime` DateTime, + `ClickPriorityID` Int32, + `ClickPhraseID` Int32, + `ClickPageID` Int32, + `ClickPlaceID` Int32, + `ClickTypeID` Int32, + `ClickResourceID` Int32, + `ClickCost` UInt32, + `ClickClientIP` UInt32, + `ClickDomainID` UInt32, + `ClickURL` String, + `ClickAttempt` UInt8, + `ClickOrderID` UInt32, + `ClickBannerID` UInt32, + `ClickMarketCategoryID` UInt32, + `ClickMarketPP` UInt32, + `ClickMarketCategoryName` String, + `ClickMarketPPName` String, + `ClickAWAPSCampaignName` String, + `ClickPageName` String, + `ClickTargetType` UInt16, + `ClickTargetPhraseID` UInt64, + `ClickContextType` UInt8, + `ClickSelectType` Int8, + `ClickOptions` String, + `ClickGroupBannerID` Int32, + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `FirstVisit` DateTime, + `PredLastVisit` Date, + `LastVisit` Date, + `TotalVisits` UInt32, + `TraficSource` Nested( + ID Int8, + SearchEngineID UInt16, + AdvEngineID UInt8, + PlaceID UInt16, + SocialSourceNetworkID UInt8, + Domain String, + SearchPhrase String, + SocialSourcePage String), + `Attendance` FixedString(16), + `CLID` UInt32, + `YCLID` UInt64, + `NormalizedRefererHash` UInt64, + `SearchPhraseHash` UInt64, + `RefererDomainHash` UInt64, + `NormalizedStartURLHash` UInt64, + `StartURLDomainHash` UInt64, + `NormalizedEndURLHash` UInt64, + `TopLevelDomain` UInt64, + `URLScheme` UInt64, + `OpenstatServiceNameHash` UInt64, + `OpenstatCampaignIDHash` UInt64, + `OpenstatAdIDHash` UInt64, + `OpenstatSourceIDHash` UInt64, + `UTMSourceHash` UInt64, + `UTMMediumHash` UInt64, + `UTMCampaignHash` UInt64, + `UTMContentHash` UInt64, + `UTMTermHash` UInt64, + `FromHash` UInt64, + `WebVisorEnabled` UInt8, + `WebVisorActivity` UInt32, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `Market` Nested( + Type UInt8, + GoalID UInt32, + OrderID String, + OrderPrice Int64, + PP UInt32, + DirectPlaceID UInt32, + DirectOrderID UInt32, + DirectBannerID UInt32, + GoodID String, + GoodName String, + GoodQuantity Int32, + GoodPrice Int64), + `IslandID` FixedString(16) +) +ENGINE = CollapsingMergeTree(Sign) +PARTITION BY toYYYYMM(StartDate) +ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +Puede ejecutar esas consultas utilizando el modo interactivo de `clickhouse-client` (simplemente ejecútelo en un terminal sin especificar una consulta por adelantado) o pruebe algunos [interfaz alternativa](../interfaces/index.md) Si quieres. + +Como podemos ver, `hits_v1` utiliza el [motor básico MergeTree](../engines/table-engines/mergetree-family/mergetree.md), mientras que el `visits_v1` utiliza el [Derrumbar](../engines/table-engines/mergetree-family/collapsingmergetree.md) variante. + +### Importar datos {#import-data} + +La importación de datos a ClickHouse se realiza a través de [INSERT INTO](../sql-reference/statements/insert-into.md) consulta como en muchas otras bases de datos SQL. Sin embargo, los datos generalmente se proporcionan en uno de los [Formatos de serialización compatibles](../interfaces/formats.md) en lugar de `VALUES` cláusula (que también es compatible). + +Los archivos que descargamos anteriormente están en formato separado por tabuladores, así que aquí le mostramos cómo importarlos a través del cliente de la consola: + +``` bash +clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv +clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv +``` + +ClickHouse tiene un montón de [ajustes para sintonizar](../operations/settings/index.md) y una forma de especificarlos en el cliente de la consola es a través de argumentos, como podemos ver con `--max_insert_block_size`. La forma más fácil de averiguar qué configuraciones están disponibles, qué significan y cuáles son los valores predeterminados es consultar el `system.settings` tabla: + +``` sql +SELECT name, value, changed, description +FROM system.settings +WHERE name LIKE '%max_insert_b%' +FORMAT TSV + +max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." +``` + +Opcionalmente se puede [OPTIMIZE](../sql-reference/statements/misc.md#misc_operations-optimize) las tablas después de la importación. Las tablas que están configuradas con un motor de la familia MergeTree siempre fusionan partes de datos en segundo plano para optimizar el almacenamiento de datos (o al menos verificar si tiene sentido). Estas consultas obligan al motor de tablas a realizar la optimización del almacenamiento en este momento en lugar de algún tiempo después: + +``` bash +clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" +clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" +``` + +Estas consultas inician una operación intensiva de E / S y CPU, por lo que si la tabla recibe datos nuevos de manera consistente, es mejor dejarlos solos y dejar que las fusiones se ejecuten en segundo plano. + +Ahora podemos comprobar si la importación de la tabla fue exitosa: + +``` bash +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" +``` + +## Consultas de ejemplo {#example-queries} + +``` sql +SELECT + StartURL AS URL, + AVG(Duration) AS AvgDuration +FROM tutorial.visits_v1 +WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' +GROUP BY URL +ORDER BY AvgDuration DESC +LIMIT 10 +``` + +``` sql +SELECT + sum(Sign) AS visits, + sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, + (100. * goal_visits) / visits AS goal_percent +FROM tutorial.visits_v1 +WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') +``` + +## Implementación de clúster {#cluster-deployment} + +El clúster ClickHouse es un clúster homogéneo. Pasos para configurar: + +1. Instale el servidor ClickHouse en todas las máquinas del clúster +2. Configurar configuraciones de clúster en archivos de configuración +3. Crear tablas locales en cada instancia +4. Crear un [Tabla distribuida](../engines/table-engines/special/distributed.md) + +[Tabla distribuida](../engines/table-engines/special/distributed.md) es en realidad una especie de “view” a las tablas locales del clúster ClickHouse. La consulta SELECT de una tabla distribuida se ejecuta utilizando recursos de todos los fragmentos del clúster. Puede especificar configuraciones para varios clústeres y crear varias tablas distribuidas que proporcionen vistas a diferentes clústeres. + +Ejemplo de configuración para un clúster con tres fragmentos, una réplica cada uno: + +``` xml + + + + + example-perftest01j.yandex.ru + 9000 + + + + + example-perftest02j.yandex.ru + 9000 + + + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +Para más demostraciones, vamos a crear una nueva tabla local con la misma `CREATE TABLE` consulta que utilizamos para `hits_v1`, pero nombre de tabla diferente: + +``` sql +CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... +``` + +Creación de una tabla distribuida que proporcione una vista en las tablas locales del clúster: + +``` sql +CREATE TABLE tutorial.hits_all AS tutorial.hits_local +ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); +``` + +Una práctica común es crear tablas distribuidas similares en todas las máquinas del clúster. Permite ejecutar consultas distribuidas en cualquier máquina del clúster. También hay una opción alternativa para crear una tabla distribuida temporal para una consulta SELECT determinada usando [remoto](../sql-reference/table-functions/remote.md) función de la tabla. + +Vamos a correr [INSERT SELECT](../sql-reference/statements/insert-into.md) en la tabla Distributed para extender la tabla a varios servidores. + +``` sql +INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; +``` + +!!! warning "Aviso" + Este enfoque no es adecuado para la fragmentación de tablas grandes. Hay una herramienta separada [Método de codificación de datos:](../operations/utilities/clickhouse-copier.md) que puede volver a fragmentar tablas grandes arbitrarias. + +Como era de esperar, las consultas computacionalmente pesadas se ejecutan N veces más rápido si utilizan 3 servidores en lugar de uno. + +En este caso, hemos utilizado un clúster con 3 fragmentos, y cada uno contiene una sola réplica. + +Para proporcionar resiliencia en un entorno de producción, se recomienda que cada fragmento contenga 2-3 réplicas distribuidas entre varias zonas de disponibilidad o centros de datos (o al menos racks). Tenga en cuenta que ClickHouse admite un número ilimitado de réplicas. + +Ejemplo de configuración para un clúster de un fragmento que contiene tres réplicas: + +``` xml + + ... + + + + example-perftest01j.yandex.ru + 9000 + + + example-perftest02j.yandex.ru + 9000 + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +Para habilitar la replicación nativa [ZooKeeper](http://zookeeper.apache.org/) se requiere. ClickHouse se encarga de la coherencia de los datos en todas las réplicas y ejecuta el procedimiento de restauración después de la falla automáticamente. Se recomienda implementar el clúster ZooKeeper en servidores independientes (donde no se están ejecutando otros procesos, incluido ClickHouse). + +!!! note "Nota" + ZooKeeper no es un requisito estricto: en algunos casos simples, puede duplicar los datos escribiéndolos en todas las réplicas de su código de aplicación. Este enfoque es **ni** recomendado, en este caso, ClickHouse no podrá garantizar la coherencia de los datos en todas las réplicas. Por lo tanto, se convierte en responsabilidad de su aplicación. + +Las ubicaciones de ZooKeeper se especifican en el archivo de configuración: + +``` xml + + + zoo01.yandex.ru + 2181 + + + zoo02.yandex.ru + 2181 + + + zoo03.yandex.ru + 2181 + + +``` + +Además, necesitamos establecer macros para identificar cada fragmento y réplica que se utilizan en la creación de tablas: + +``` xml + + 01 + 01 + +``` + +Si no hay réplicas en este momento en la creación de la tabla replicada, se crea una instancia de una nueva primera réplica. Si ya hay réplicas activas, la nueva réplica clona los datos de las existentes. Tiene la opción de crear primero todas las tablas replicadas y, a continuación, insertar datos en ella. Otra opción es crear algunas réplicas y agregar las otras después o durante la inserción de datos. + +``` sql +CREATE TABLE tutorial.hits_replica (...) +ENGINE = ReplcatedMergeTree( + '/clickhouse_perftest/tables/{shard}/hits', + '{replica}' +) +... +``` + +Aquí usamos [ReplicatedMergeTree](../engines/table-engines/mergetree-family/replication.md) motor de mesa. En los parámetros, especificamos la ruta ZooKeeper que contiene identificadores de fragmentos y réplicas. + +``` sql +INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; +``` + +La replicación funciona en modo multi-master. Los datos se pueden cargar en cualquier réplica y el sistema los sincroniza automáticamente con otras instancias. La replicación es asíncrona, por lo que en un momento dado, no todas las réplicas pueden contener datos insertados recientemente. Al menos una réplica debe estar disponible para permitir la ingestión de datos. Otros sincronizarán los datos y repararán la coherencia una vez que vuelvan a activarse. Tenga en cuenta que este enfoque permite la baja posibilidad de una pérdida de datos recientemente insertados. + +[Artículo Original](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/es/getting_started/example_datasets/amplab_benchmark.md b/docs/es/getting_started/example_datasets/amplab_benchmark.md deleted file mode 100644 index 79c2c6aea23..00000000000 --- a/docs/es/getting_started/example_datasets/amplab_benchmark.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 17 -toc_title: Referencia de Big Data de AMPLab ---- - -# Referencia de Big Data de AMPLab {#amplab-big-data-benchmark} - -Ver https://amplab.cs.berkeley.edu/benchmark/ - -Regístrese para obtener una cuenta gratuita en https://aws.amazon.com. Requiere una tarjeta de crédito, correo electrónico y número de teléfono. Obtenga una nueva clave de acceso en https://console.aws.amazon.com/iam/home?nc2=h\_m\_sc\#security\_credential - -Ejecute lo siguiente en la consola: - -``` bash -$ sudo apt-get install s3cmd -$ mkdir tiny; cd tiny; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/tiny/ . -$ cd .. -$ mkdir 1node; cd 1node; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/1node/ . -$ cd .. -$ mkdir 5nodes; cd 5nodes; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . -$ cd .. -``` - -Ejecute las siguientes consultas de ClickHouse: - -``` sql -CREATE TABLE rankings_tiny -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_tiny -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); - -CREATE TABLE rankings_1node -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_1node -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); - -CREATE TABLE rankings_5nodes_on_single -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_5nodes_on_single -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); -``` - -Volver a la consola: - -``` bash -$ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done -$ for i in tiny/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_tiny FORMAT CSV"; done -$ for i in 1node/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_1node FORMAT CSV"; done -$ for i in 1node/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_1node FORMAT CSV"; done -$ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_5nodes_on_single FORMAT CSV"; done -$ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done -``` - -Consultas para obtener muestras de datos: - -``` sql -SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 - -SELECT substring(sourceIP, 1, 8), sum(adRevenue) FROM uservisits_1node GROUP BY substring(sourceIP, 1, 8) - -SELECT - sourceIP, - sum(adRevenue) AS totalRevenue, - avg(pageRank) AS pageRank -FROM rankings_1node ALL INNER JOIN -( - SELECT - sourceIP, - destinationURL AS pageURL, - adRevenue - FROM uservisits_1node - WHERE (visitDate > '1980-01-01') AND (visitDate < '1980-04-01') -) USING pageURL -GROUP BY sourceIP -ORDER BY totalRevenue DESC -LIMIT 1 -``` - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/amplab_benchmark/) diff --git a/docs/es/getting_started/example_datasets/criteo.md b/docs/es/getting_started/example_datasets/criteo.md deleted file mode 100644 index c501599bcc0..00000000000 --- a/docs/es/getting_started/example_datasets/criteo.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 19 -toc_title: Registros de clics de Terabyte de Criteo ---- - -# Terabyte de registros de clics de Criteo {#terabyte-of-click-logs-from-criteo} - -Descargue los datos de http://labs.criteo.com/downloads/download-terabyte-click-logs/ - -Cree una tabla para importar el registro: - -``` sql -CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log -``` - -Descargar los datos: - -``` bash -$ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done -``` - -Crear una tabla para los datos convertidos: - -``` sql -CREATE TABLE criteo -( - date Date, - clicked UInt8, - int1 Int32, - int2 Int32, - int3 Int32, - int4 Int32, - int5 Int32, - int6 Int32, - int7 Int32, - int8 Int32, - int9 Int32, - int10 Int32, - int11 Int32, - int12 Int32, - int13 Int32, - icat1 UInt32, - icat2 UInt32, - icat3 UInt32, - icat4 UInt32, - icat5 UInt32, - icat6 UInt32, - icat7 UInt32, - icat8 UInt32, - icat9 UInt32, - icat10 UInt32, - icat11 UInt32, - icat12 UInt32, - icat13 UInt32, - icat14 UInt32, - icat15 UInt32, - icat16 UInt32, - icat17 UInt32, - icat18 UInt32, - icat19 UInt32, - icat20 UInt32, - icat21 UInt32, - icat22 UInt32, - icat23 UInt32, - icat24 UInt32, - icat25 UInt32, - icat26 UInt32 -) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192) -``` - -Transforme los datos del registro sin procesar y colóquelos en la segunda tabla: - -``` sql -INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log; - -DROP TABLE criteo_log; -``` - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/criteo/) diff --git a/docs/es/getting_started/example_datasets/index.md b/docs/es/getting_started/example_datasets/index.md deleted file mode 100644 index 7234cbbff39..00000000000 --- a/docs/es/getting_started/example_datasets/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Example Datasets -toc_priority: 12 -toc_title: "Implantaci\xF3n" ---- - -# Datos De Ejemplo {#example-datasets} - -En esta sección se describe cómo obtener conjuntos de datos de ejemplo e importarlos a ClickHouse. -Para algunos conjuntos de datos también están disponibles consultas de ejemplo. - -- [Yandex anonimizado.Conjunto de datos de Metrica](metrica.md) -- [Estrella Schema Benchmark](star_schema.md) -- [Nombre de la red inalámbrica (SSID):](wikistat.md) -- [Terabyte de registros de clics de Criteo](criteo.md) -- [Referencia de Big Data de AMPLab](amplab_benchmark.md) -- [Datos de taxis de Nueva York](nyc_taxi.md) -- [A tiempo](ontime.md) - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/es/getting_started/example_datasets/metrica.md b/docs/es/getting_started/example_datasets/metrica.md deleted file mode 100644 index de0e8f41489..00000000000 --- a/docs/es/getting_started/example_datasets/metrica.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 21 -toc_title: El Yandex.Metrica Datos ---- - -# Yandex anonimizado.Metrica Datos {#anonymized-yandex-metrica-data} - -El conjunto de datos consta de dos tablas que contienen datos anónimos sobre los hits (`hits_v1`) y visitas (`visits_v1`) el Yandex.Métrica. Puedes leer más sobre Yandex.Metrica en [Historial de ClickHouse](../../introduction/history.md) apartado. - -El conjunto de datos consta de dos tablas, cualquiera de ellas se puede descargar como `tsv.xz` o como particiones preparadas. Además, una versión extendida de la `hits` La tabla que contiene 100 millones de filas está disponible como TSV en https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits\_100m\_obfuscated\_v1.tsv.xz y como particiones preparadas en https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits\_100m\_obfuscated\_v1.tar.xz. - -## Obtención de tablas a partir de particiones preparadas {#obtaining-tables-from-prepared-partitions} - -Descargar e importar tabla de hits: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar -tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Descargar e importar visitas: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar -tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Obtención de tablas a partir de un archivo TSV comprimido {#obtaining-tables-from-compressed-tsv-file} - -Descargar e importar hits desde un archivo TSV comprimido: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Descargue e importe visitas desde un archivo tsv comprimido: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Consultas de ejemplo {#example-queries} - -[Tutorial de ClickHouse](../../getting_started/tutorial.md) se basa en Yandex.El conjunto de datos de Metrica y la forma recomendada de comenzar con este conjunto de datos es simplemente pasar por el tutorial. - -Se pueden encontrar ejemplos adicionales de consultas a estas tablas entre [pruebas estatales](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) de ClickHouse (se nombran `test.hists` y `test.visits` alli). diff --git a/docs/es/getting_started/example_datasets/nyc_taxi.md b/docs/es/getting_started/example_datasets/nyc_taxi.md deleted file mode 100644 index 47d54519da6..00000000000 --- a/docs/es/getting_started/example_datasets/nyc_taxi.md +++ /dev/null @@ -1,390 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 16 -toc_title: Datos de taxis de Nueva York ---- - -# Datos de taxis de Nueva York {#new-york-taxi-data} - -Este conjunto de datos se puede obtener de dos maneras: - -- importación de datos sin procesar -- descarga de particiones preparadas - -## Cómo importar los datos sin procesar {#how-to-import-the-raw-data} - -Consulte https://github.com/toddwschneider/nyc-taxi-data y http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html para obtener la descripción de un conjunto de datos e instrucciones para descargar. - -La descarga dará como resultado aproximadamente 227 GB de datos sin comprimir en archivos CSV. La descarga tarda aproximadamente una hora en una conexión de 1 Gbit (la descarga paralela de s3.amazonaws.com recupera al menos la mitad de un canal de 1 Gbit). -Es posible que algunos de los archivos no se descarguen por completo. Verifique los tamaños de archivo y vuelva a descargar cualquiera que parezca dudoso. - -Algunos de los archivos pueden contener filas no válidas. Puede arreglarlos de la siguiente manera: - -``` bash -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ -mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv -mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv -``` - -Entonces los datos deben ser preprocesados en PostgreSQL. Esto creará selecciones de puntos en los polígonos (para hacer coincidir los puntos en el mapa con los distritos de la ciudad de Nueva York) y combinará todos los datos en una única tabla plana desnormalizada mediante el uso de una unión. Para hacer esto, deberá instalar PostgreSQL con soporte PostGIS. - -Tenga cuidado al correr `initialize_database.sh` y volver a verificar manualmente que todas las tablas se crearon correctamente. - -Se tarda entre 20 y 30 minutos en procesar los datos de cada mes en PostgreSQL, por un total de aproximadamente 48 horas. - -Puede comprobar el número de filas descargadas de la siguiente manera: - -``` bash -$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" -## Count - 1298979494 -(1 row) - -real 7m9.164s -``` - -(Esto es un poco más de 1.1 mil millones de filas reportadas por Mark Litwintschik en una serie de publicaciones de blog.) - -Los datos en PostgreSQL utilizan 370 GB de espacio. - -Exportación de los datos de PostgreSQL: - -``` sql -COPY -( - SELECT trips.id, - trips.vendor_id, - trips.pickup_datetime, - trips.dropoff_datetime, - trips.store_and_fwd_flag, - trips.rate_code_id, - trips.pickup_longitude, - trips.pickup_latitude, - trips.dropoff_longitude, - trips.dropoff_latitude, - trips.passenger_count, - trips.trip_distance, - trips.fare_amount, - trips.extra, - trips.mta_tax, - trips.tip_amount, - trips.tolls_amount, - trips.ehail_fee, - trips.improvement_surcharge, - trips.total_amount, - trips.payment_type, - trips.trip_type, - trips.pickup, - trips.dropoff, - - cab_types.type cab_type, - - weather.precipitation_tenths_of_mm rain, - weather.snow_depth_mm, - weather.snowfall_mm, - weather.max_temperature_tenths_degrees_celsius max_temp, - weather.min_temperature_tenths_degrees_celsius min_temp, - weather.average_wind_speed_tenths_of_meters_per_second wind, - - pick_up.gid pickup_nyct2010_gid, - pick_up.ctlabel pickup_ctlabel, - pick_up.borocode pickup_borocode, - pick_up.boroname pickup_boroname, - pick_up.ct2010 pickup_ct2010, - pick_up.boroct2010 pickup_boroct2010, - pick_up.cdeligibil pickup_cdeligibil, - pick_up.ntacode pickup_ntacode, - pick_up.ntaname pickup_ntaname, - pick_up.puma pickup_puma, - - drop_off.gid dropoff_nyct2010_gid, - drop_off.ctlabel dropoff_ctlabel, - drop_off.borocode dropoff_borocode, - drop_off.boroname dropoff_boroname, - drop_off.ct2010 dropoff_ct2010, - drop_off.boroct2010 dropoff_boroct2010, - drop_off.cdeligibil dropoff_cdeligibil, - drop_off.ntacode dropoff_ntacode, - drop_off.ntaname dropoff_ntaname, - drop_off.puma dropoff_puma - FROM trips - LEFT JOIN cab_types - ON trips.cab_type_id = cab_types.id - LEFT JOIN central_park_weather_observations_raw weather - ON weather.date = trips.pickup_datetime::date - LEFT JOIN nyct2010 pick_up - ON pick_up.gid = trips.pickup_nyct2010_gid - LEFT JOIN nyct2010 drop_off - ON drop_off.gid = trips.dropoff_nyct2010_gid -) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; -``` - -La instantánea de datos se crea a una velocidad de aproximadamente 50 MB por segundo. Al crear la instantánea, PostgreSQL lee desde el disco a una velocidad de aproximadamente 28 MB por segundo. -Esto toma alrededor de 5 horas. El archivo TSV resultante es 590612904969 bytes. - -Crear una tabla temporal en ClickHouse: - -``` sql -CREATE TABLE trips -( -trip_id UInt32, -vendor_id String, -pickup_datetime DateTime, -dropoff_datetime Nullable(DateTime), -store_and_fwd_flag Nullable(FixedString(1)), -rate_code_id Nullable(UInt8), -pickup_longitude Nullable(Float64), -pickup_latitude Nullable(Float64), -dropoff_longitude Nullable(Float64), -dropoff_latitude Nullable(Float64), -passenger_count Nullable(UInt8), -trip_distance Nullable(Float64), -fare_amount Nullable(Float32), -extra Nullable(Float32), -mta_tax Nullable(Float32), -tip_amount Nullable(Float32), -tolls_amount Nullable(Float32), -ehail_fee Nullable(Float32), -improvement_surcharge Nullable(Float32), -total_amount Nullable(Float32), -payment_type Nullable(String), -trip_type Nullable(UInt8), -pickup Nullable(String), -dropoff Nullable(String), -cab_type Nullable(String), -precipitation Nullable(UInt8), -snow_depth Nullable(UInt8), -snowfall Nullable(UInt8), -max_temperature Nullable(UInt8), -min_temperature Nullable(UInt8), -average_wind_speed Nullable(UInt8), -pickup_nyct2010_gid Nullable(UInt8), -pickup_ctlabel Nullable(String), -pickup_borocode Nullable(UInt8), -pickup_boroname Nullable(String), -pickup_ct2010 Nullable(String), -pickup_boroct2010 Nullable(String), -pickup_cdeligibil Nullable(FixedString(1)), -pickup_ntacode Nullable(String), -pickup_ntaname Nullable(String), -pickup_puma Nullable(String), -dropoff_nyct2010_gid Nullable(UInt8), -dropoff_ctlabel Nullable(String), -dropoff_borocode Nullable(UInt8), -dropoff_boroname Nullable(String), -dropoff_ct2010 Nullable(String), -dropoff_boroct2010 Nullable(String), -dropoff_cdeligibil Nullable(String), -dropoff_ntacode Nullable(String), -dropoff_ntaname Nullable(String), -dropoff_puma Nullable(String) -) ENGINE = Log; -``` - -Es necesario para convertir campos a tipos de datos más correctos y, si es posible, para eliminar NULL. - -``` bash -$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv - -real 75m56.214s -``` - -Los datos se leen a una velocidad de 112-140 Mb / segundo. -La carga de datos en una tabla de tipos de registro en una secuencia tardó 76 minutos. -Los datos de esta tabla utilizan 142 GB. - -(Importar datos directamente desde Postgres también es posible usando `COPY ... TO PROGRAM`.) - -Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. - -Para empezar, crearemos una tabla en un único servidor. Posteriormente haremos la mesa distribuida. - -Crear y rellenar una tabla de resumen: - -``` sql -CREATE TABLE trips_mergetree -ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -AS SELECT - -trip_id, -CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, -toDate(pickup_datetime) AS pickup_date, -ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, -toDate(dropoff_datetime) AS dropoff_date, -ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, -assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, -assumeNotNull(rate_code_id) AS rate_code_id, -assumeNotNull(pickup_longitude) AS pickup_longitude, -assumeNotNull(pickup_latitude) AS pickup_latitude, -assumeNotNull(dropoff_longitude) AS dropoff_longitude, -assumeNotNull(dropoff_latitude) AS dropoff_latitude, -assumeNotNull(passenger_count) AS passenger_count, -assumeNotNull(trip_distance) AS trip_distance, -assumeNotNull(fare_amount) AS fare_amount, -assumeNotNull(extra) AS extra, -assumeNotNull(mta_tax) AS mta_tax, -assumeNotNull(tip_amount) AS tip_amount, -assumeNotNull(tolls_amount) AS tolls_amount, -assumeNotNull(ehail_fee) AS ehail_fee, -assumeNotNull(improvement_surcharge) AS improvement_surcharge, -assumeNotNull(total_amount) AS total_amount, -CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, -assumeNotNull(trip_type) AS trip_type, -ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, -ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, -CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, - -assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, -toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, -assumeNotNull(pickup_borocode) AS pickup_borocode, -CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, -toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, -toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, -CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, -toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, - -CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, - -toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, - -assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, -toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, -assumeNotNull(dropoff_borocode) AS dropoff_borocode, -CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, -toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, -toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, -CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, -toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, - -CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, - -toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma - -FROM trips -``` - -Esto toma 3030 segundos a una velocidad de aproximadamente 428,000 filas por segundo. -Para cargarlo más rápido, puede crear la tabla con el `Log` motor en lugar de `MergeTree`. En este caso, la descarga funciona más rápido que 200 segundos. - -La tabla utiliza 126 GB de espacio en disco. - -``` sql -SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active -``` - -``` text -┌─formatReadableSize(sum(bytes))─┐ -│ 126.18 GiB │ -└────────────────────────────────┘ -``` - -Entre otras cosas, puede ejecutar la consulta OPTIMIZE en MergeTree. Pero no es necesario ya que todo estará bien sin él. - -## Descarga de Prepared Partitions {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar -$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" -``` - -!!! info "INFO" - Si va a ejecutar las consultas que se describen a continuación, debe usar el nombre completo de la tabla, `datasets.trips_mergetree`. - -## Resultados en un solo servidor {#results-on-single-server} - -Q1: - -``` sql -SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type -``` - -0.490 segundos. - -Q2: - -``` sql -SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count -``` - -1.224 segundos. - -Q3: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year -``` - -2.104 segundos. - -Q4: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) -FROM trips_mergetree -GROUP BY passenger_count, year, distance -ORDER BY year, count(*) DESC -``` - -3.593 segundos. - -Se utilizó el siguiente servidor: - -Dos CPU Intel (R) Xeon (R) E5-2650 v2 @ 2.60GHz, 16 núcleos físicos en total, 128 GiB RAM, 8x6 TB HD en hardware RAID-5 - -El tiempo de ejecución es el mejor de tres carreras. Pero a partir de la segunda ejecución, las consultas leen datos de la memoria caché del sistema de archivos. No se produce más almacenamiento en caché: los datos se leen y procesan en cada ejecución. - -Creación de una tabla en tres servidores: - -En cada servidor: - -``` sql -CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -``` - -En el servidor de origen: - -``` sql -CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) -``` - -La siguiente consulta redistribuye los datos: - -``` sql -INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree -``` - -Esto tarda 2454 segundos. - -En tres servidores: - -Q1: 0.212 segundos. -Q2: 0.438 segundos. -Q3: 0.733 segundos. -Q4: 1.241 segundos. - -No hay sorpresas aquí, ya que las consultas se escalan linealmente. - -También tenemos los resultados de un clúster de 140 servidores: - -Q1: 0,028 seg. -Q2: 0,043 seg. -Q3: 0,051 seg. -Q4: 0,072 seg. - -En este caso, el tiempo de procesamiento de la consulta está determinado sobre todo por la latencia de la red. -Ejecutamos consultas utilizando un cliente ubicado en un centro de datos de Yandex en Finlandia en un clúster en Rusia, que agregó aproximadamente 20 ms de latencia. - -## Resumen {#summary} - -| servidor | Q1 | Q2 | Q3 | Q4 | -|----------|-------|-------|-------|-------| -| 1 | 0.490 | 1.224 | 2.104 | 3.593 | -| 3 | 0.212 | 0.438 | 0.733 | 1.241 | -| 140 | 0.028 | 0.043 | 0.051 | 0.072 | - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/es/getting_started/example_datasets/ontime.md b/docs/es/getting_started/example_datasets/ontime.md deleted file mode 100644 index b471d784138..00000000000 --- a/docs/es/getting_started/example_datasets/ontime.md +++ /dev/null @@ -1,412 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 15 -toc_title: A tiempo ---- - -# A tiempo {#ontime} - -Este conjunto de datos se puede obtener de dos maneras: - -- importación de datos sin procesar -- descarga de particiones preparadas - -## Importar desde datos sin procesar {#import-from-raw-data} - -Descarga de datos: - -``` bash -for s in `seq 1987 2018` -do -for m in `seq 1 12` -do -wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip -done -done -``` - -(a partir de https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) - -Creación de una tabla: - -``` sql -CREATE TABLE `ontime` ( - `Year` UInt16, - `Quarter` UInt8, - `Month` UInt8, - `DayofMonth` UInt8, - `DayOfWeek` UInt8, - `FlightDate` Date, - `UniqueCarrier` FixedString(7), - `AirlineID` Int32, - `Carrier` FixedString(2), - `TailNum` String, - `FlightNum` String, - `OriginAirportID` Int32, - `OriginAirportSeqID` Int32, - `OriginCityMarketID` Int32, - `Origin` FixedString(5), - `OriginCityName` String, - `OriginState` FixedString(2), - `OriginStateFips` String, - `OriginStateName` String, - `OriginWac` Int32, - `DestAirportID` Int32, - `DestAirportSeqID` Int32, - `DestCityMarketID` Int32, - `Dest` FixedString(5), - `DestCityName` String, - `DestState` FixedString(2), - `DestStateFips` String, - `DestStateName` String, - `DestWac` Int32, - `CRSDepTime` Int32, - `DepTime` Int32, - `DepDelay` Int32, - `DepDelayMinutes` Int32, - `DepDel15` Int32, - `DepartureDelayGroups` String, - `DepTimeBlk` String, - `TaxiOut` Int32, - `WheelsOff` Int32, - `WheelsOn` Int32, - `TaxiIn` Int32, - `CRSArrTime` Int32, - `ArrTime` Int32, - `ArrDelay` Int32, - `ArrDelayMinutes` Int32, - `ArrDel15` Int32, - `ArrivalDelayGroups` Int32, - `ArrTimeBlk` String, - `Cancelled` UInt8, - `CancellationCode` FixedString(1), - `Diverted` UInt8, - `CRSElapsedTime` Int32, - `ActualElapsedTime` Int32, - `AirTime` Int32, - `Flights` Int32, - `Distance` Int32, - `DistanceGroup` UInt8, - `CarrierDelay` Int32, - `WeatherDelay` Int32, - `NASDelay` Int32, - `SecurityDelay` Int32, - `LateAircraftDelay` Int32, - `FirstDepTime` String, - `TotalAddGTime` String, - `LongestAddGTime` String, - `DivAirportLandings` String, - `DivReachedDest` String, - `DivActualElapsedTime` String, - `DivArrDelay` String, - `DivDistance` String, - `Div1Airport` String, - `Div1AirportID` Int32, - `Div1AirportSeqID` Int32, - `Div1WheelsOn` String, - `Div1TotalGTime` String, - `Div1LongestGTime` String, - `Div1WheelsOff` String, - `Div1TailNum` String, - `Div2Airport` String, - `Div2AirportID` Int32, - `Div2AirportSeqID` Int32, - `Div2WheelsOn` String, - `Div2TotalGTime` String, - `Div2LongestGTime` String, - `Div2WheelsOff` String, - `Div2TailNum` String, - `Div3Airport` String, - `Div3AirportID` Int32, - `Div3AirportSeqID` Int32, - `Div3WheelsOn` String, - `Div3TotalGTime` String, - `Div3LongestGTime` String, - `Div3WheelsOff` String, - `Div3TailNum` String, - `Div4Airport` String, - `Div4AirportID` Int32, - `Div4AirportSeqID` Int32, - `Div4WheelsOn` String, - `Div4TotalGTime` String, - `Div4LongestGTime` String, - `Div4WheelsOff` String, - `Div4TailNum` String, - `Div5Airport` String, - `Div5AirportID` Int32, - `Div5AirportSeqID` Int32, - `Div5WheelsOn` String, - `Div5TotalGTime` String, - `Div5LongestGTime` String, - `Div5WheelsOff` String, - `Div5TailNum` String -) ENGINE = MergeTree -PARTITION BY Year -ORDER BY (Carrier, FlightDate) -SETTINGS index_granularity = 8192; -``` - -Carga de datos: - -``` bash -$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done -``` - -## Descarga de Prepared Partitions {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar -$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.ontime" -``` - -!!! info "INFO" - Si va a ejecutar las consultas que se describen a continuación, debe usar el nombre completo de la tabla, `datasets.ontime`. - -## Consulta {#queries} - -Q0. - -``` sql -SELECT avg(c1) -FROM -( - SELECT Year, Month, count(*) AS c1 - FROM ontime - GROUP BY Year, Month -); -``` - -Q1. El número de vuelos por día desde el año 2000 hasta 2008 - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -Preguntas frecuentes El número de vuelos retrasados por más de 10 minutos, agrupados por el día de la semana, para 2000-2008 - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -Q3. El número de retrasos por parte del aeropuerto para 2000-2008 - -``` sql -SELECT Origin, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY Origin -ORDER BY c DESC -LIMIT 10; -``` - -Preguntas más frecuentes Número de retrasos por transportista para 2007 - -``` sql -SELECT Carrier, count(*) -FROM ontime -WHERE DepDelay>10 AND Year=2007 -GROUP BY Carrier -ORDER BY count(*) DESC; -``` - -Q5. El porcentaje de retrasos por transportista para 2007 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year=2007 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year=2007 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Mejor versión de la misma consulta: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year=2007 -GROUP BY Carrier -ORDER BY c3 DESC -``` - -¿por qué? la solicitud anterior de una gama más amplia de años, 2000-2008 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year>=2000 AND Year<=2008 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year>=2000 AND Year<=2008 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Mejor versión de la misma consulta: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY Carrier -ORDER BY c3 DESC; -``` - -Preguntas frecuentes Porcentaje de vuelos retrasados por más de 10 minutos, por año - -``` sql -SELECT Year, c1/c2 -FROM -( - select - Year, - count(*)*100 as c1 - from ontime - WHERE DepDelay>10 - GROUP BY Year -) -JOIN -( - select - Year, - count(*) as c2 - from ontime - GROUP BY Year -) USING (Year) -ORDER BY Year; -``` - -Mejor versión de la misma consulta: - -``` sql -SELECT Year, avg(DepDelay>10)*100 -FROM ontime -GROUP BY Year -ORDER BY Year; -``` - -¿por qué? los destinos más populares por el número de ciudades conectadas directamente para varios rangos de año - -``` sql -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -WHERE Year >= 2000 and Year <= 2010 -GROUP BY DestCityName -ORDER BY u DESC LIMIT 10; -``` - -Q9. - -``` sql -SELECT Year, count(*) AS c1 -FROM ontime -GROUP BY Year; -``` - -Q10. - -``` sql -SELECT - min(Year), max(Year), Carrier, count(*) AS cnt, - sum(ArrDelayMinutes>30) AS flights_delayed, - round(sum(ArrDelayMinutes>30)/count(*),2) AS rate -FROM ontime -WHERE - DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') - AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') - AND FlightDate < '2010-01-01' -GROUP by Carrier -HAVING cnt>100000 and max(Year)>1990 -ORDER by rate DESC -LIMIT 1000; -``` - -Bono: - -``` sql -SELECT avg(cnt) -FROM -( - SELECT Year,Month,count(*) AS cnt - FROM ontime - WHERE DepDel15=1 - GROUP BY Year,Month -); - -SELECT avg(c1) FROM -( - SELECT Year,Month,count(*) AS c1 - FROM ontime - GROUP BY Year,Month -); - -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -GROUP BY DestCityName -ORDER BY u DESC -LIMIT 10; - -SELECT OriginCityName, DestCityName, count() AS c -FROM ontime -GROUP BY OriginCityName, DestCityName -ORDER BY c DESC -LIMIT 10; - -SELECT OriginCityName, count() AS c -FROM ontime -GROUP BY OriginCityName -ORDER BY c DESC -LIMIT 10; -``` - -Esta prueba de rendimiento fue creada por Vadim Tkachenko. Ver: - -- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ -- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ -- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ -- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ -- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ -- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/es/getting_started/example_datasets/star_schema.md b/docs/es/getting_started/example_datasets/star_schema.md deleted file mode 100644 index ebc18b94fd6..00000000000 --- a/docs/es/getting_started/example_datasets/star_schema.md +++ /dev/null @@ -1,370 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 20 -toc_title: Estrella Schema Benchmark ---- - -# Estrella Schema Benchmark {#star-schema-benchmark} - -Compilación de dbgen: - -``` bash -$ git clone git@github.com:vadimtk/ssb-dbgen.git -$ cd ssb-dbgen -$ make -``` - -Generación de datos: - -!!! warning "Atención" - Con `-s 100` dbgen genera 600 millones de filas (67 GB), mientras que `-s 1000` genera 6 mil millones de filas (lo que lleva mucho tiempo) - -``` bash -$ ./dbgen -s 1000 -T c -$ ./dbgen -s 1000 -T l -$ ./dbgen -s 1000 -T p -$ ./dbgen -s 1000 -T s -$ ./dbgen -s 1000 -T d -``` - -Creación de tablas en ClickHouse: - -``` sql -CREATE TABLE customer -( - C_CUSTKEY UInt32, - C_NAME String, - C_ADDRESS String, - C_CITY LowCardinality(String), - C_NATION LowCardinality(String), - C_REGION LowCardinality(String), - C_PHONE String, - C_MKTSEGMENT LowCardinality(String) -) -ENGINE = MergeTree ORDER BY (C_CUSTKEY); - -CREATE TABLE lineorder -( - LO_ORDERKEY UInt32, - LO_LINENUMBER UInt8, - LO_CUSTKEY UInt32, - LO_PARTKEY UInt32, - LO_SUPPKEY UInt32, - LO_ORDERDATE Date, - LO_ORDERPRIORITY LowCardinality(String), - LO_SHIPPRIORITY UInt8, - LO_QUANTITY UInt8, - LO_EXTENDEDPRICE UInt32, - LO_ORDTOTALPRICE UInt32, - LO_DISCOUNT UInt8, - LO_REVENUE UInt32, - LO_SUPPLYCOST UInt32, - LO_TAX UInt8, - LO_COMMITDATE Date, - LO_SHIPMODE LowCardinality(String) -) -ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY); - -CREATE TABLE part -( - P_PARTKEY UInt32, - P_NAME String, - P_MFGR LowCardinality(String), - P_CATEGORY LowCardinality(String), - P_BRAND LowCardinality(String), - P_COLOR LowCardinality(String), - P_TYPE LowCardinality(String), - P_SIZE UInt8, - P_CONTAINER LowCardinality(String) -) -ENGINE = MergeTree ORDER BY P_PARTKEY; - -CREATE TABLE supplier -( - S_SUPPKEY UInt32, - S_NAME String, - S_ADDRESS String, - S_CITY LowCardinality(String), - S_NATION LowCardinality(String), - S_REGION LowCardinality(String), - S_PHONE String -) -ENGINE = MergeTree ORDER BY S_SUPPKEY; -``` - -Insertar datos: - -``` bash -$ clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl -$ clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl -$ clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl -$ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl -``` - -Conversión “star schema” a desnormalizado “flat schema”: - -``` sql -SET max_memory_usage = 20000000000; - -CREATE TABLE lineorder_flat -ENGINE = MergeTree -PARTITION BY toYear(LO_ORDERDATE) -ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS -SELECT - l.LO_ORDERKEY AS LO_ORDERKEY, - l.LO_LINENUMBER AS LO_LINENUMBER, - l.LO_CUSTKEY AS LO_CUSTKEY, - l.LO_PARTKEY AS LO_PARTKEY, - l.LO_SUPPKEY AS LO_SUPPKEY, - l.LO_ORDERDATE AS LO_ORDERDATE, - l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY, - l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY, - l.LO_QUANTITY AS LO_QUANTITY, - l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE, - l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE, - l.LO_DISCOUNT AS LO_DISCOUNT, - l.LO_REVENUE AS LO_REVENUE, - l.LO_SUPPLYCOST AS LO_SUPPLYCOST, - l.LO_TAX AS LO_TAX, - l.LO_COMMITDATE AS LO_COMMITDATE, - l.LO_SHIPMODE AS LO_SHIPMODE, - c.C_NAME AS C_NAME, - c.C_ADDRESS AS C_ADDRESS, - c.C_CITY AS C_CITY, - c.C_NATION AS C_NATION, - c.C_REGION AS C_REGION, - c.C_PHONE AS C_PHONE, - c.C_MKTSEGMENT AS C_MKTSEGMENT, - s.S_NAME AS S_NAME, - s.S_ADDRESS AS S_ADDRESS, - s.S_CITY AS S_CITY, - s.S_NATION AS S_NATION, - s.S_REGION AS S_REGION, - s.S_PHONE AS S_PHONE, - p.P_NAME AS P_NAME, - p.P_MFGR AS P_MFGR, - p.P_CATEGORY AS P_CATEGORY, - p.P_BRAND AS P_BRAND, - p.P_COLOR AS P_COLOR, - p.P_TYPE AS P_TYPE, - p.P_SIZE AS P_SIZE, - p.P_CONTAINER AS P_CONTAINER -FROM lineorder AS l -INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY -INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY -INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; -``` - -Las consultas: - -Q1.1 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toYear(LO_ORDERDATE) = 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25; -``` - -Q1.2 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toYYYYMM(LO_ORDERDATE) = 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35; -``` - -Q1.3 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toISOWeek(LO_ORDERDATE) = 6 AND toYear(LO_ORDERDATE) = 1994 - AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35; -``` - -Q2.1 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q2.2 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_BRAND >= 'MFGR#2221' AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q2.3 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q3.1 - -``` sql -SELECT - C_NATION, - S_NATION, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year >= 1992 AND year <= 1997 -GROUP BY - C_NATION, - S_NATION, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.2 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE C_NATION = 'UNITED STATES' AND S_NATION = 'UNITED STATES' AND year >= 1992 AND year <= 1997 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.3 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND year >= 1992 AND year <= 1997 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.4 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND toYYYYMM(LO_ORDERDATE) = 199712 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q4.1 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - C_NATION, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') -GROUP BY - year, - C_NATION -ORDER BY - year ASC, - C_NATION ASC; -``` - -Q4.2 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - S_NATION, - P_CATEGORY, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year = 1997 OR year = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') -GROUP BY - year, - S_NATION, - P_CATEGORY -ORDER BY - year ASC, - S_NATION ASC, - P_CATEGORY ASC; -``` - -Q4.3 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - S_CITY, - P_BRAND, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE S_NATION = 'UNITED STATES' AND (year = 1997 OR year = 1998) AND P_CATEGORY = 'MFGR#14' -GROUP BY - year, - S_CITY, - P_BRAND -ORDER BY - year ASC, - S_CITY ASC, - P_BRAND ASC; -``` - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/star_schema/) diff --git a/docs/es/getting_started/example_datasets/wikistat.md b/docs/es/getting_started/example_datasets/wikistat.md deleted file mode 100644 index 064656320f6..00000000000 --- a/docs/es/getting_started/example_datasets/wikistat.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 18 -toc_title: "Nombre de la red inal\xE1mbrica (SSID):" ---- - -# Nombre de la red inalámbrica (SSID): {#wikistat} - -Ver: http://dumps.wikimedia.org/other/pagecounts-raw/ - -Creación de una tabla: - -``` sql -CREATE TABLE wikistat -( - date Date, - time DateTime, - project String, - subproject String, - path String, - hits UInt64, - size UInt64 -) ENGINE = MergeTree(date, (path, time), 8192); -``` - -Carga de datos: - -``` bash -$ for i in {2007..2016}; do for j in {01..12}; do echo $i-$j >&2; curl -sSL "http://dumps.wikimedia.org/other/pagecounts-raw/$i/$i-$j/" | grep -oE 'pagecounts-[0-9]+-[0-9]+\.gz'; done; done | sort | uniq | tee links.txt -$ cat links.txt | while read link; do wget http://dumps.wikimedia.org/other/pagecounts-raw/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1/')/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1-\2/')/$link; done -$ ls -1 /opt/wikistat/ | grep gz | while read i; do echo $i; gzip -cd /opt/wikistat/$i | ./wikistat-loader --time="$(echo -n $i | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})\.gz/\1-\2-\3 \4-00-00/')" | clickhouse-client --query="INSERT INTO wikistat FORMAT TabSeparated"; done -``` - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/wikistat/) diff --git a/docs/es/getting_started/index.md b/docs/es/getting_started/index.md deleted file mode 100644 index c1d7973a39c..00000000000 --- a/docs/es/getting_started/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Getting Started -toc_hidden: true -toc_priority: 8 -toc_title: oculto ---- - -# Primeros pasos {#getting-started} - -Si eres nuevo en ClickHouse y quieres tener una sensación práctica de su rendimiento, antes que nada, debes pasar por el [proceso de instalación](install.md). Después de eso puedes: - -- [Ir a través de tutorial detallado](tutorial.md) -- [Experimente con conjuntos de datos de ejemplo](example_datasets/ontime.md) - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/es/getting_started/install.md b/docs/es/getting_started/install.md deleted file mode 100644 index 71e8eec3192..00000000000 --- a/docs/es/getting_started/install.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 11 -toc_title: "Instalaci\xF3n" ---- - -# Instalación {#installation} - -## Requisitos del sistema {#system-requirements} - -ClickHouse puede ejecutarse en cualquier Linux, FreeBSD o Mac OS X con arquitectura de CPU x86\_64, AArch64 o PowerPC64LE. - -Los binarios oficiales preconstruidos generalmente se compilan para x86\_64 y aprovechan el conjunto de instrucciones SSE 4.2, por lo que, a menos que se indique lo contrario, el uso de la CPU que lo admite se convierte en un requisito adicional del sistema. Aquí está el comando para verificar si la CPU actual tiene soporte para SSE 4.2: - -``` bash -$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" -``` - -Para ejecutar ClickHouse en procesadores que no admiten SSE 4.2 o tienen arquitectura AArch64 o PowerPC64LE, debe [construir ClickHouse a partir de fuentes](#from-sources) con los ajustes de configuración adecuados. - -## Opciones de instalación disponibles {#available-installation-options} - -### De paquetes DEB {#install-from-deb-packages} - -Se recomienda utilizar pre-compilado oficial `deb` Paquetes para Debian o Ubuntu. Ejecute estos comandos para instalar paquetes: - -``` bash -{% include 'install/deb.sh' %} -``` - -Si desea utilizar la versión más reciente, reemplace `stable` con `testing` (esto se recomienda para sus entornos de prueba). - -También puede descargar e instalar paquetes manualmente desde aquí: https://repo.clickhouse.tech/deb/stable/main/. - -#### Paquete {#packages} - -- `clickhouse-common-static` — Installs ClickHouse compiled binary files. -- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` e instala la configuración predeterminada del servidor. -- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` y otras herramientas relacionadas con el cliente. e instala los archivos de configuración del cliente. -- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. - -### De paquetes RPM {#from-rpm-packages} - -Se recomienda utilizar pre-compilado oficial `rpm` También puede utilizar los paquetes para CentOS, RedHat y todas las demás distribuciones de Linux basadas en rpm. - -Primero, necesitas agregar el repositorio oficial: - -``` bash -sudo yum install yum-utils -sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG -sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 -``` - -Si desea utilizar la versión más reciente, reemplace `stable` con `testing` (esto se recomienda para sus entornos de prueba). El `prestable` etiqueta a veces está disponible también. - -A continuación, ejecute estos comandos para instalar paquetes: - -``` bash -sudo yum install clickhouse-server clickhouse-client -``` - -También puede descargar e instalar paquetes manualmente desde aquí: https://repo.casa de clic.tecnología / rpm / estable / x86\_64. - -### De archivos tgz {#from-tgz-archives} - -Se recomienda utilizar pre-compilado oficial `tgz` para todas las distribuciones de Linux, donde la instalación de `deb` o `rpm` paquetes no es posible. - -La versión requerida se puede descargar con `curl` o `wget` desde el repositorio https://repo.yandex.ru/clickhouse/tgz/. -Después de eso, los archivos descargados deben desempaquetarse e instalarse con scripts de instalación. Ejemplo para la última versión: - -``` bash -export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz - -tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz -sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz -sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-server-$LATEST_VERSION.tgz -sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh -sudo /etc/init.d/clickhouse-server start - -tar -xzvf clickhouse-client-$LATEST_VERSION.tgz -sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh -``` - -Para los entornos de producción, se recomienda utilizar las últimas `stable`-versión. Puede encontrar su número en la página de GitHub https://github.com/ClickHouse/ClickHouse/tags con postfix `-stable`. - -### Desde Docker Image {#from-docker-image} - -Para ejecutar ClickHouse dentro de Docker, siga la guía en [Eje de acoplador](https://hub.docker.com/r/yandex/clickhouse-server/). Esas imágenes usan oficial `deb` paquetes dentro. - -### De fuentes {#from-sources} - -Para compilar manualmente ClickHouse, siga las instrucciones para [Linux](../development/build.md) o [Mac OS X](../development/build_osx.md). - -Puede compilar paquetes e instalarlos o usar programas sin instalar paquetes. Además, al construir manualmente, puede deshabilitar el requisito de SSE 4.2 o compilar para CPU AArch64. - - Client: programs/clickhouse-client - Server: programs/clickhouse-server - -Tendrá que crear carpetas de datos y metadatos y `chown` para el usuario deseado. Sus rutas se pueden cambiar en la configuración del servidor (src/programs/server/config.xml), por defecto son: - - /opt/clickhouse/data/default/ - /opt/clickhouse/metadata/default/ - -En Gentoo, puedes usar `emerge clickhouse` para instalar ClickHouse desde fuentes. - -## Lanzar {#launch} - -Para iniciar el servidor como demonio, ejecute: - -``` bash -$ sudo service clickhouse-server start -``` - -Si no tienes `service` comando ejecutar como - -``` bash -$ sudo /etc/init.d/clickhouse-server start -``` - -Vea los registros en el `/var/log/clickhouse-server/` directorio. - -Si el servidor no se inicia, compruebe las configuraciones en el archivo `/etc/clickhouse-server/config.xml`. - -También puede iniciar manualmente el servidor desde la consola: - -``` bash -$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml -``` - -En este caso, el registro se imprimirá en la consola, lo cual es conveniente durante el desarrollo. -Si el archivo de configuración está en el directorio actual, no es necesario `--config-file` parámetro. De forma predeterminada, utiliza `./config.xml`. - -ClickHouse admite la configuración de restricción de acceso. Están ubicados en el `users.xml` archivo (junto a `config.xml`). -De forma predeterminada, se permite el acceso desde cualquier lugar `default` usuario, sin una contraseña. Ver `user/default/networks`. -Para obtener más información, consulte la sección [“Configuration Files”](../operations/configuration_files.md). - -Después de iniciar el servidor, puede usar el cliente de línea de comandos para conectarse a él: - -``` bash -$ clickhouse-client -``` - -Por defecto, se conecta a `localhost:9000` en nombre del usuario `default` sin una contraseña. También se puede usar para conectarse a un servidor remoto usando `--host` argumento. - -El terminal debe usar codificación UTF-8. -Para obtener más información, consulte la sección [“Command-line client”](../interfaces/cli.md). - -Ejemplo: - -``` bash -$ ./clickhouse-client -ClickHouse client version 0.0.18749. -Connecting to localhost:9000. -Connected to ClickHouse server version 0.0.18749. - -:) SELECT 1 - -SELECT 1 - -┌─1─┐ -│ 1 │ -└───┘ - -1 rows in set. Elapsed: 0.003 sec. - -:) -``` - -**Felicidades, el sistema funciona!** - -Para continuar experimentando, puede descargar uno de los conjuntos de datos de prueba o pasar por [tutorial](https://clickhouse.tech/tutorial.html). - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/es/getting_started/playground.md b/docs/es/getting_started/playground.md deleted file mode 100644 index 1314ca679b5..00000000000 --- a/docs/es/getting_started/playground.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 14 -toc_title: Infantil ---- - -# Zona de juegos ClickHouse {#clickhouse-playground} - -[Zona de juegos ClickHouse](https://play.clickhouse.tech?file=welcome) permite a las personas experimentar con ClickHouse ejecutando consultas al instante, sin configurar su servidor o clúster. -Varios conjuntos de datos de ejemplo están disponibles en Playground, así como consultas de ejemplo que muestran las características de ClickHouse. - -Las consultas se ejecutan como un usuario de sólo lectura. Implica algunas limitaciones: - -- No se permiten consultas DDL -- Las consultas INSERT no están permitidas - -También se aplican los siguientes valores: -- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) -- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) -- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) -- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) - -ClickHouse Playground da la experiencia de m2.pequeño -[Servicio administrado para ClickHouse](https://cloud.yandex.com/services/managed-clickhouse) -instancia alojada en [El Yandex.Nube](https://cloud.yandex.com/). -Más información sobre [proveedores de la nube](../commercial/cloud.md). - -La interfaz web de ClickHouse Playground realiza solicitudes a través de ClickHouse [HTTP API](../interfaces/http.md). -El backend Playground es solo un clúster ClickHouse sin ninguna aplicación adicional del lado del servidor. -El punto final HTTPS de ClickHouse también está disponible como parte de Playground. - -Puede realizar consultas al patio de recreo utilizando cualquier cliente HTTP, por ejemplo [rizo](https://curl.haxx.se) o [wget](https://www.gnu.org/software/wget/), o configurar una conexión usando [JDBC](../interfaces/jdbc.md) o [ODBC](../interfaces/odbc.md) controlador. -Más información sobre los productos de software compatibles con ClickHouse está disponible [aqui](../interfaces/index.md). - -| Parámetro | Valor | -|:------------|:----------------------------------------------| -| Punto final | https://play-api.casa de clic.tecnología:8443 | -| Usuario | `playground` | -| Contraseña | `clickhouse` | - -Tenga en cuenta que este extremo requiere una conexión segura. - -Ejemplo: - -``` bash -curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" -``` diff --git a/docs/es/getting_started/tutorial.md b/docs/es/getting_started/tutorial.md deleted file mode 100644 index 1767b75f2e0..00000000000 --- a/docs/es/getting_started/tutorial.md +++ /dev/null @@ -1,665 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 12 -toc_title: Tutorial ---- - -# Tutorial de ClickHouse {#clickhouse-tutorial} - -## Qué Esperar de Este Tutorial? {#what-to-expect-from-this-tutorial} - -Al pasar por este tutorial, aprenderá cómo configurar un clúster de ClickHouse simple. Será pequeño, pero tolerante a fallos y escalable. Luego usaremos uno de los conjuntos de datos de ejemplo para llenarlo con datos y ejecutar algunas consultas de demostración. - -## Configuración de nodo único {#single-node-setup} - -Para posponer las complejidades de un entorno distribuido, comenzaremos con la implementación de ClickHouse en un único servidor o máquina virtual. ClickHouse generalmente se instala desde [deb](install.md#install-from-deb-packages) o [RPM](install.md#from-rpm-packages) paquetes, pero hay [alternativa](install.md#from-docker-image) para los sistemas operativos que no los admiten. - -Por ejemplo, ha elegido `deb` paquetes y ejecutado: - -``` bash -{% include 'install/deb.sh' %} -``` - -¿qué tenemos en los paquetes que tengo instalados: - -- `clickhouse-client` el paquete contiene [Casa de clics-cliente](../interfaces/cli.md) aplicación, cliente interactivo de la consola ClickHouse. -- `clickhouse-common` El paquete contiene un archivo ejecutable ClickHouse. -- `clickhouse-server` El paquete contiene archivos de configuración para ejecutar ClickHouse como servidor. - -Los archivos de configuración del servidor se encuentran en `/etc/clickhouse-server/`. Antes de ir más lejos, tenga en cuenta el `` elemento en `config.xml`. La ruta determina la ubicación para el almacenamiento de datos, por lo que debe ubicarse en un volumen con gran capacidad de disco; el valor predeterminado es `/var/lib/clickhouse/`. Si desea ajustar la configuración, no es útil editar directamente `config.xml` archivo, teniendo en cuenta que podría ser reescrito en futuras actualizaciones de paquetes. La forma recomendada de anular los elementos de configuración es crear [archivos en config.directorio d](../operations/configuration_files.md) que sirven como “patches” de configuración.XML. - -Como habrás notado, `clickhouse-server` no se inicia automáticamente después de la instalación del paquete. Tampoco se reiniciará automáticamente después de las actualizaciones. La forma en que inicia el servidor depende de su sistema de inicio, por lo general, es: - -``` bash -sudo service clickhouse-server start -``` - -o - -``` bash -sudo /etc/init.d/clickhouse-server start -``` - -La ubicación predeterminada para los registros del servidor es `/var/log/clickhouse-server/`. El servidor está listo para manejar las conexiones de cliente una vez que registra el `Ready for connections` mensaje. - -Una vez que el `clickhouse-server` está en funcionamiento, podemos usar `clickhouse-client` para conectarse al servidor y ejecutar algunas consultas de prueba como `SELECT "Hello, world!";`. - -
- -Consejos rápidos para clickhouse-cliente -Modo interactivo: - -``` bash -clickhouse-client -clickhouse-client --host=... --port=... --user=... --password=... -``` - -Habilitar consultas multilínea: - -``` bash -clickhouse-client -m -clickhouse-client --multiline -``` - -Ejecutar consultas en modo por lotes: - -``` bash -clickhouse-client --query='SELECT 1' -echo 'SELECT 1' | clickhouse-client -clickhouse-client <<< 'SELECT 1' -``` - -Insertar datos de un archivo en el formato especificado: - -``` bash -clickhouse-client --query='INSERT INTO table VALUES' < data.txt -clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv -``` - -
- -## Importar conjunto de datos de muestra {#import-sample-dataset} - -Ahora es el momento de llenar nuestro servidor ClickHouse con algunos datos de muestra. En este tutorial, usaremos los datos anónimos de Yandex.Metrica, el primer servicio que ejecuta ClickHouse en forma de producción antes de que se convirtiera en código abierto (más sobre eso en [sección de historia](../introduction/history.md)). Hay [múltiples formas de importar Yandex.Conjunto de datos de Metrica](example_datasets/metrica.md), y por el bien del tutorial, iremos con el más realista. - -### Descargar y extraer datos de tabla {#download-and-extract-table-data} - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -``` - -Los archivos extraídos tienen un tamaño de aproximadamente 10 GB. - -### Crear tablas {#create-tables} - -Como en la mayoría de los sistemas de gestión de bases de datos, ClickHouse agrupa lógicamente las tablas en “databases”. Hay un `default` base de datos, pero crearemos una nueva llamada `tutorial`: - -``` bash -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" -``` - -La sintaxis para crear tablas es mucho más complicada en comparación con las bases de datos (ver [referencia](../sql_reference/statements/create.md). En general `CREATE TABLE` declaración tiene que especificar tres cosas clave: - -1. Nombre de la tabla que se va a crear. -2. Table schema, i.e. list of columns and their [tipos de datos](../sql_reference/data_types/index.md). -3. [Motor de tabla](../engines/table_engines/index.md) y su configuración, que determina todos los detalles sobre cómo se ejecutarán físicamente las consultas a esta tabla. - -El Yandex.Metrica es un servicio de análisis web, y el conjunto de datos de muestra no cubre toda su funcionalidad, por lo que solo hay dos tablas para crear: - -- `hits` es una tabla con cada acción realizada por todos los usuarios en todos los sitios web cubiertos por el servicio. -- `visits` es una tabla que contiene sesiones precompiladas en lugar de acciones individuales. - -Veamos y ejecutemos las consultas de tabla de creación real para estas tablas: - -``` sql -CREATE TABLE tutorial.hits_v1 -( - `WatchID` UInt64, - `JavaEnable` UInt8, - `Title` String, - `GoodEvent` Int16, - `EventTime` DateTime, - `EventDate` Date, - `CounterID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RegionID` UInt32, - `UserID` UInt64, - `CounterClass` Int8, - `OS` UInt8, - `UserAgent` UInt8, - `URL` String, - `Referer` String, - `URLDomain` String, - `RefererDomain` String, - `Refresh` UInt8, - `IsRobot` UInt8, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `FlashMinor2` String, - `NetMajor` UInt8, - `NetMinor` UInt8, - `UserAgentMajor` UInt16, - `UserAgentMinor` FixedString(2), - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `MobilePhone` UInt8, - `MobilePhoneModel` String, - `Params` String, - `IPNetworkID` UInt32, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `IsArtifical` UInt8, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `ClientTimeZone` Int16, - `ClientEventTime` DateTime, - `SilverlightVersion1` UInt8, - `SilverlightVersion2` UInt8, - `SilverlightVersion3` UInt32, - `SilverlightVersion4` UInt16, - `PageCharset` String, - `CodeVersion` UInt32, - `IsLink` UInt8, - `IsDownload` UInt8, - `IsNotBounce` UInt8, - `FUniqID` UInt64, - `HID` UInt32, - `IsOldCounter` UInt8, - `IsEvent` UInt8, - `IsParameter` UInt8, - `DontCountHits` UInt8, - `WithHash` UInt8, - `HitColor` FixedString(1), - `UTCEventTime` DateTime, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `WindowName` Int32, - `OpenerName` Int32, - `HistoryLength` Int16, - `BrowserLanguage` FixedString(2), - `BrowserCountry` FixedString(2), - `SocialNetwork` String, - `SocialAction` String, - `HTTPError` UInt16, - `SendTiming` Int32, - `DNSTiming` Int32, - `ConnectTiming` Int32, - `ResponseStartTiming` Int32, - `ResponseEndTiming` Int32, - `FetchTiming` Int32, - `RedirectTiming` Int32, - `DOMInteractiveTiming` Int32, - `DOMContentLoadedTiming` Int32, - `DOMCompleteTiming` Int32, - `LoadEventStartTiming` Int32, - `LoadEventEndTiming` Int32, - `NSToDOMContentLoadedTiming` Int32, - `FirstPaintTiming` Int32, - `RedirectCount` Int8, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `ParamPrice` Int64, - `ParamOrderID` String, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `GoalsReached` Array(UInt32), - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `RefererHash` UInt64, - `URLHash` UInt64, - `CLID` UInt32, - `YCLID` UInt64, - `ShareService` String, - `ShareURL` String, - `ShareTitle` String, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `IslandID` FixedString(16), - `RequestNum` UInt32, - `RequestTry` UInt8 -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -``` sql -CREATE TABLE tutorial.visits_v1 -( - `CounterID` UInt32, - `StartDate` Date, - `Sign` Int8, - `IsNew` UInt8, - `VisitID` UInt64, - `UserID` UInt64, - `StartTime` DateTime, - `Duration` UInt32, - `UTCStartTime` DateTime, - `PageViews` Int32, - `Hits` Int32, - `IsBounce` UInt8, - `Referer` String, - `StartURL` String, - `RefererDomain` String, - `StartURLDomain` String, - `EndURL` String, - `LinkURL` String, - `IsDownload` UInt8, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `PlaceID` Int32, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `IsYandex` UInt8, - `GoalReachesDepth` Int32, - `GoalReachesURL` Int32, - `GoalReachesAny` Int32, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `MobilePhoneModel` String, - `ClientEventTime` DateTime, - `RegionID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `IPNetworkID` UInt32, - `SilverlightVersion3` UInt32, - `CodeVersion` UInt32, - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `UserAgentMajor` UInt16, - `UserAgentMinor` UInt16, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `SilverlightVersion2` UInt8, - `SilverlightVersion4` UInt16, - `FlashVersion3` UInt16, - `FlashVersion4` UInt16, - `ClientTimeZone` Int16, - `OS` UInt8, - `UserAgent` UInt8, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `NetMajor` UInt8, - `NetMinor` UInt8, - `MobilePhone` UInt8, - `SilverlightVersion1` UInt8, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `JavaEnable` UInt8, - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `BrowserLanguage` UInt16, - `BrowserCountry` UInt16, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `Params` Array(String), - `Goals` Nested( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32), - `WatchIDs` Array(UInt64), - `ParamSumPrice` Int64, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `ClickLogID` UInt64, - `ClickEventID` Int32, - `ClickGoodEvent` Int32, - `ClickEventTime` DateTime, - `ClickPriorityID` Int32, - `ClickPhraseID` Int32, - `ClickPageID` Int32, - `ClickPlaceID` Int32, - `ClickTypeID` Int32, - `ClickResourceID` Int32, - `ClickCost` UInt32, - `ClickClientIP` UInt32, - `ClickDomainID` UInt32, - `ClickURL` String, - `ClickAttempt` UInt8, - `ClickOrderID` UInt32, - `ClickBannerID` UInt32, - `ClickMarketCategoryID` UInt32, - `ClickMarketPP` UInt32, - `ClickMarketCategoryName` String, - `ClickMarketPPName` String, - `ClickAWAPSCampaignName` String, - `ClickPageName` String, - `ClickTargetType` UInt16, - `ClickTargetPhraseID` UInt64, - `ClickContextType` UInt8, - `ClickSelectType` Int8, - `ClickOptions` String, - `ClickGroupBannerID` Int32, - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `FirstVisit` DateTime, - `PredLastVisit` Date, - `LastVisit` Date, - `TotalVisits` UInt32, - `TraficSource` Nested( - ID Int8, - SearchEngineID UInt16, - AdvEngineID UInt8, - PlaceID UInt16, - SocialSourceNetworkID UInt8, - Domain String, - SearchPhrase String, - SocialSourcePage String), - `Attendance` FixedString(16), - `CLID` UInt32, - `YCLID` UInt64, - `NormalizedRefererHash` UInt64, - `SearchPhraseHash` UInt64, - `RefererDomainHash` UInt64, - `NormalizedStartURLHash` UInt64, - `StartURLDomainHash` UInt64, - `NormalizedEndURLHash` UInt64, - `TopLevelDomain` UInt64, - `URLScheme` UInt64, - `OpenstatServiceNameHash` UInt64, - `OpenstatCampaignIDHash` UInt64, - `OpenstatAdIDHash` UInt64, - `OpenstatSourceIDHash` UInt64, - `UTMSourceHash` UInt64, - `UTMMediumHash` UInt64, - `UTMCampaignHash` UInt64, - `UTMContentHash` UInt64, - `UTMTermHash` UInt64, - `FromHash` UInt64, - `WebVisorEnabled` UInt8, - `WebVisorActivity` UInt32, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `Market` Nested( - Type UInt8, - GoalID UInt32, - OrderID String, - OrderPrice Int64, - PP UInt32, - DirectPlaceID UInt32, - DirectOrderID UInt32, - DirectBannerID UInt32, - GoodID String, - GoodName String, - GoodQuantity Int32, - GoodPrice Int64), - `IslandID` FixedString(16) -) -ENGINE = CollapsingMergeTree(Sign) -PARTITION BY toYYYYMM(StartDate) -ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -Puede ejecutar esas consultas utilizando el modo interactivo de `clickhouse-client` (simplemente ejecútelo en un terminal sin especificar una consulta por adelantado) o pruebe algunos [interfaz alternativa](../interfaces/index.md) Si quieres. - -Como podemos ver, `hits_v1` utiliza el [motor básico MergeTree](../engines/table_engines/mergetree_family/mergetree.md), mientras que el `visits_v1` utiliza el [Derrumbar](../engines/table_engines/mergetree_family/collapsingmergetree.md) variante. - -### Importar datos {#import-data} - -La importación de datos a ClickHouse se realiza a través de [INSERT INTO](../sql_reference/statements/insert_into.md) consulta como en muchas otras bases de datos SQL. Sin embargo, los datos generalmente se proporcionan en uno de los [Formatos de serialización compatibles](../interfaces/formats.md) en lugar de `VALUES` cláusula (que también es compatible). - -Los archivos que descargamos anteriormente están en formato separado por tabuladores, así que aquí le mostramos cómo importarlos a través del cliente de la consola: - -``` bash -clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv -clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv -``` - -ClickHouse tiene un montón de [ajustes para sintonizar](../operations/settings/index.md) y una forma de especificarlos en el cliente de la consola es a través de argumentos, como podemos ver con `--max_insert_block_size`. La forma más fácil de averiguar qué configuraciones están disponibles, qué significan y cuáles son los valores predeterminados es consultar el `system.settings` tabla: - -``` sql -SELECT name, value, changed, description -FROM system.settings -WHERE name LIKE '%max_insert_b%' -FORMAT TSV - -max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." -``` - -Opcionalmente se puede [OPTIMIZE](../query_language/misc/#misc_operations-optimize) las tablas después de la importación. Las tablas que están configuradas con un motor de la familia MergeTree siempre fusionan partes de datos en segundo plano para optimizar el almacenamiento de datos (o al menos verificar si tiene sentido). Estas consultas obligan al motor de tablas a realizar la optimización del almacenamiento en este momento en lugar de algún tiempo después: - -``` bash -clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" -clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" -``` - -Estas consultas inician una operación intensiva de E / S y CPU, por lo que si la tabla recibe datos nuevos de manera consistente, es mejor dejarlos solos y dejar que las fusiones se ejecuten en segundo plano. - -Ahora podemos comprobar si la importación de la tabla fue exitosa: - -``` bash -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" -``` - -## Consultas de ejemplo {#example-queries} - -``` sql -SELECT - StartURL AS URL, - AVG(Duration) AS AvgDuration -FROM tutorial.visits_v1 -WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' -GROUP BY URL -ORDER BY AvgDuration DESC -LIMIT 10 -``` - -``` sql -SELECT - sum(Sign) AS visits, - sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, - (100. * goal_visits) / visits AS goal_percent -FROM tutorial.visits_v1 -WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') -``` - -## Implementación de clúster {#cluster-deployment} - -El clúster ClickHouse es un clúster homogéneo. Pasos para configurar: - -1. Instale el servidor ClickHouse en todas las máquinas del clúster -2. Configurar configuraciones de clúster en archivos de configuración -3. Crear tablas locales en cada instancia -4. Crear un [Tabla distribuida](../engines/table_engines/special/distributed.md) - -[Tabla distribuida](../engines/table_engines/special/distributed.md) es en realidad una especie de “view” a las tablas locales del clúster ClickHouse. La consulta SELECT de una tabla distribuida se ejecuta utilizando recursos de todos los fragmentos del clúster. Puede especificar configuraciones para varios clústeres y crear varias tablas distribuidas que proporcionen vistas a diferentes clústeres. - -Ejemplo de configuración para un clúster con tres fragmentos, una réplica cada uno: - -``` xml - - - - - example-perftest01j.yandex.ru - 9000 - - - - - example-perftest02j.yandex.ru - 9000 - - - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -Para más demostraciones, vamos a crear una nueva tabla local con la misma `CREATE TABLE` consulta que utilizamos para `hits_v1`, pero nombre de tabla diferente: - -``` sql -CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... -``` - -Creación de una tabla distribuida que proporcione una vista en las tablas locales del clúster: - -``` sql -CREATE TABLE tutorial.hits_all AS tutorial.hits_local -ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); -``` - -Una práctica común es crear tablas distribuidas similares en todas las máquinas del clúster. Permite ejecutar consultas distribuidas en cualquier máquina del clúster. También hay una opción alternativa para crear una tabla distribuida temporal para una consulta SELECT determinada usando [remoto](../sql_reference/table_functions/remote.md) función de la tabla. - -Vamos a correr [INSERT SELECT](../sql_reference/statements/insert_into.md) en la tabla Distributed para extender la tabla a varios servidores. - -``` sql -INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; -``` - -!!! warning "Aviso" - Este enfoque no es adecuado para la fragmentación de tablas grandes. Hay una herramienta separada [Método de codificación de datos:](../operations/utilities/clickhouse-copier.md) que puede volver a fragmentar tablas grandes arbitrarias. - -Como era de esperar, las consultas computacionalmente pesadas se ejecutan N veces más rápido si utilizan 3 servidores en lugar de uno. - -En este caso, hemos utilizado un clúster con 3 fragmentos, y cada uno contiene una sola réplica. - -Para proporcionar resiliencia en un entorno de producción, se recomienda que cada fragmento contenga 2-3 réplicas distribuidas entre varias zonas de disponibilidad o centros de datos (o al menos racks). Tenga en cuenta que ClickHouse admite un número ilimitado de réplicas. - -Ejemplo de configuración para un clúster de un fragmento que contiene tres réplicas: - -``` xml - - ... - - - - example-perftest01j.yandex.ru - 9000 - - - example-perftest02j.yandex.ru - 9000 - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -Para habilitar la replicación nativa [ZooKeeper](http://zookeeper.apache.org/) se requiere. ClickHouse se encarga de la coherencia de los datos en todas las réplicas y ejecuta el procedimiento de restauración después de la falla automáticamente. Se recomienda implementar el clúster ZooKeeper en servidores independientes (donde no se están ejecutando otros procesos, incluido ClickHouse). - -!!! note "Nota" - ZooKeeper no es un requisito estricto: en algunos casos simples, puede duplicar los datos escribiéndolos en todas las réplicas de su código de aplicación. Este enfoque es **ni** recomendado, en este caso, ClickHouse no podrá garantizar la coherencia de los datos en todas las réplicas. Por lo tanto, se convierte en responsabilidad de su aplicación. - -Las ubicaciones de ZooKeeper se especifican en el archivo de configuración: - -``` xml - - - zoo01.yandex.ru - 2181 - - - zoo02.yandex.ru - 2181 - - - zoo03.yandex.ru - 2181 - - -``` - -Además, necesitamos establecer macros para identificar cada fragmento y réplica que se utilizan en la creación de tablas: - -``` xml - - 01 - 01 - -``` - -Si no hay réplicas en este momento en la creación de la tabla replicada, se crea una instancia de una nueva primera réplica. Si ya hay réplicas activas, la nueva réplica clona los datos de las existentes. Tiene la opción de crear primero todas las tablas replicadas y, a continuación, insertar datos en ella. Otra opción es crear algunas réplicas y agregar las otras después o durante la inserción de datos. - -``` sql -CREATE TABLE tutorial.hits_replica (...) -ENGINE = ReplcatedMergeTree( - '/clickhouse_perftest/tables/{shard}/hits', - '{replica}' -) -... -``` - -Aquí usamos [ReplicatedMergeTree](../engines/table_engines/mergetree_family/replication.md) motor de mesa. En los parámetros, especificamos la ruta ZooKeeper que contiene identificadores de fragmentos y réplicas. - -``` sql -INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; -``` - -La replicación funciona en modo multi-master. Los datos se pueden cargar en cualquier réplica y el sistema los sincroniza automáticamente con otras instancias. La replicación es asíncrona, por lo que en un momento dado, no todas las réplicas pueden contener datos insertados recientemente. Al menos una réplica debe estar disponible para permitir la ingestión de datos. Otros sincronizarán los datos y repararán la coherencia una vez que vuelvan a activarse. Tenga en cuenta que este enfoque permite la baja posibilidad de una pérdida de datos recientemente insertados. - -[Artículo Original](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/es/guides/apply-catboost-model.md b/docs/es/guides/apply-catboost-model.md new file mode 100644 index 00000000000..b1fe50f3276 --- /dev/null +++ b/docs/es/guides/apply-catboost-model.md @@ -0,0 +1,239 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "Aplicaci\xF3n de modelos CatBoost" +--- + +# Aplicación de un modelo Catboost en ClickHouse {#applying-catboost-model-in-clickhouse} + +[CatBoost](https://catboost.ai) es una biblioteca de impulso de gradiente libre y de código abierto desarrollada en [Yandex](https://yandex.com/company/) para el aprendizaje automático. + +Con esta instrucción, aprenderá a aplicar modelos preentrenados en ClickHouse ejecutando la inferencia de modelos desde SQL. + +Para aplicar un modelo CatBoost en ClickHouse: + +1. [Crear una tabla](#create-table). +2. [Insertar los datos en la tabla](#insert-data-to-table). +3. [Integrar CatBoost en ClickHouse](#integrate-catboost-into-clickhouse) (Paso opcional). +4. [Ejecute la inferencia del modelo desde SQL](#run-model-inference). + +Para obtener más información sobre la formación de modelos CatBoost, consulte [Entrenamiento y aplicación de modelos](https://catboost.ai/docs/features/training.html#training). + +## Requisito {#prerequisites} + +Si no tienes el [Acoplador](https://docs.docker.com/install/) sin embargo, instalarlo. + +!!! note "Nota" + [Acoplador](https://www.docker.com) es una plataforma de software que le permite crear contenedores que aíslan una instalación de CatBoost y ClickHouse del resto del sistema. + +Antes de aplicar un modelo CatBoost: + +**1.** Tire de la [Imagen de acoplador](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) del registro: + +``` bash +$ docker pull yandex/tutorial-catboost-clickhouse +``` + +Esta imagen de Docker contiene todo lo que necesita para ejecutar CatBoost y ClickHouse: código, tiempo de ejecución, bibliotecas, variables de entorno y archivos de configuración. + +**2.** Asegúrese de que la imagen de Docker se haya extraído correctamente: + +``` bash +$ docker image ls +REPOSITORY TAG IMAGE ID CREATED SIZE +yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB +``` + +**3.** Inicie un contenedor Docker basado en esta imagen: + +``` bash +$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse +``` + +## 1. Crear una tabla {#create-table} + +Para crear una tabla ClickHouse para el ejemplo de capacitación: + +**1.** Inicie el cliente de consola ClickHouse en el modo interactivo: + +``` bash +$ clickhouse client +``` + +!!! note "Nota" + El servidor ClickHouse ya se está ejecutando dentro del contenedor Docker. + +**2.** Cree la tabla usando el comando: + +``` sql +:) CREATE TABLE amazon_train +( + date Date MATERIALIZED today(), + ACTION UInt8, + RESOURCE UInt32, + MGR_ID UInt32, + ROLE_ROLLUP_1 UInt32, + ROLE_ROLLUP_2 UInt32, + ROLE_DEPTNAME UInt32, + ROLE_TITLE UInt32, + ROLE_FAMILY_DESC UInt32, + ROLE_FAMILY UInt32, + ROLE_CODE UInt32 +) +ENGINE = MergeTree ORDER BY date +``` + +**3.** Salir del cliente de la consola ClickHouse: + +``` sql +:) exit +``` + +## 2. Insertar los datos en la tabla {#insert-data-to-table} + +Para insertar los datos: + +**1.** Ejecute el siguiente comando: + +``` bash +$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv +``` + +**2.** Inicie el cliente de consola ClickHouse en el modo interactivo: + +``` bash +$ clickhouse client +``` + +**3.** Asegúrese de que los datos se hayan cargado: + +``` sql +:) SELECT count() FROM amazon_train + +SELECT count() +FROM amazon_train + ++-count()-+ +| 65538 | ++-------+ +``` + +## 3. Integrar CatBoost en ClickHouse {#integrate-catboost-into-clickhouse} + +!!! note "Nota" + **Paso opcional.** La imagen de Docker contiene todo lo que necesita para ejecutar CatBoost y ClickHouse. + +Para integrar CatBoost en ClickHouse: + +**1.** Construir la biblioteca de evaluación. + +La forma más rápida de evaluar un modelo CatBoost es compilar `libcatboostmodel.` biblioteca. Para obtener más información acerca de cómo construir la biblioteca, vea [Documentación de CatBoost](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). + +**2.** Cree un nuevo directorio en cualquier lugar y con cualquier nombre, por ejemplo, `data` y poner la biblioteca creada en ella. La imagen de Docker ya contiene la biblioteca `data/libcatboostmodel.so`. + +**3.** Cree un nuevo directorio para el modelo de configuración en cualquier lugar y con cualquier nombre, por ejemplo, `models`. + +**4.** Cree un archivo de configuración de modelo con cualquier nombre, por ejemplo, `models/amazon_model.xml`. + +**5.** Describir la configuración del modelo: + +``` xml + + + + catboost + + amazon + + /home/catboost/tutorial/catboost_model.bin + + 0 + + +``` + +**6.** Agregue la ruta de acceso a CatBoost y la configuración del modelo a la configuración de ClickHouse: + +``` xml + +/home/catboost/data/libcatboostmodel.so +/home/catboost/models/*_model.xml +``` + +## 4. Ejecute la inferencia del modelo desde SQL {#run-model-inference} + +Para el modelo de prueba, ejecute el cliente ClickHouse `$ clickhouse client`. + +Asegurémonos de que el modelo esté funcionando: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) > 0 AS prediction, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Nota" + Función [modelEvaluar](../sql-reference/functions/other-functions.md#function-modelevaluate) devuelve tupla con predicciones sin procesar por clase para modelos multiclase. + +Vamos a predecir la probabilidad: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1 + exp(-prediction)) AS probability, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Nota" + Más información sobre [exp()](../sql-reference/functions/math-functions.md) función. + +Vamos a calcular LogLoss en la muestra: + +``` sql +:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss +FROM +( + SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1. + exp(-prediction)) AS prob, + ACTION AS tg + FROM amazon_train +) +``` + +!!! note "Nota" + Más información sobre [avg()](../sql-reference/aggregate-functions/reference.md#agg_function-avg) y [registro()](../sql-reference/functions/math-functions.md) función. + +[Artículo Original](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/es/guides/apply_catboost_model.md b/docs/es/guides/apply_catboost_model.md deleted file mode 100644 index 416ad448da5..00000000000 --- a/docs/es/guides/apply_catboost_model.md +++ /dev/null @@ -1,239 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 41 -toc_title: "Aplicaci\xF3n de modelos CatBoost" ---- - -# Aplicación de un modelo Catboost en ClickHouse {#applying-catboost-model-in-clickhouse} - -[CatBoost](https://catboost.ai) es una biblioteca de impulso de gradiente libre y de código abierto desarrollada en [Yandex](https://yandex.com/company/) para el aprendizaje automático. - -Con esta instrucción, aprenderá a aplicar modelos preentrenados en ClickHouse ejecutando la inferencia de modelos desde SQL. - -Para aplicar un modelo CatBoost en ClickHouse: - -1. [Crear una tabla](#create-table). -2. [Insertar los datos en la tabla](#insert-data-to-table). -3. [Integrar CatBoost en ClickHouse](#integrate-catboost-into-clickhouse) (Paso opcional). -4. [Ejecute la inferencia del modelo desde SQL](#run-model-inference). - -Para obtener más información sobre la formación de modelos CatBoost, consulte [Entrenamiento y aplicación de modelos](https://catboost.ai/docs/features/training.html#training). - -## Requisito {#prerequisites} - -Si no tienes el [Acoplador](https://docs.docker.com/install/) sin embargo, instalarlo. - -!!! note "Nota" - [Acoplador](https://www.docker.com) es una plataforma de software que le permite crear contenedores que aíslan una instalación de CatBoost y ClickHouse del resto del sistema. - -Antes de aplicar un modelo CatBoost: - -**1.** Tire de la [Imagen de acoplador](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) del registro: - -``` bash -$ docker pull yandex/tutorial-catboost-clickhouse -``` - -Esta imagen de Docker contiene todo lo que necesita para ejecutar CatBoost y ClickHouse: código, tiempo de ejecución, bibliotecas, variables de entorno y archivos de configuración. - -**2.** Asegúrese de que la imagen de Docker se haya extraído correctamente: - -``` bash -$ docker image ls -REPOSITORY TAG IMAGE ID CREATED SIZE -yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB -``` - -**3.** Inicie un contenedor Docker basado en esta imagen: - -``` bash -$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse -``` - -## 1. Crear una tabla {#create-table} - -Para crear una tabla ClickHouse para el ejemplo de capacitación: - -**1.** Inicie el cliente de consola ClickHouse en el modo interactivo: - -``` bash -$ clickhouse client -``` - -!!! note "Nota" - El servidor ClickHouse ya se está ejecutando dentro del contenedor Docker. - -**2.** Cree la tabla usando el comando: - -``` sql -:) CREATE TABLE amazon_train -( - date Date MATERIALIZED today(), - ACTION UInt8, - RESOURCE UInt32, - MGR_ID UInt32, - ROLE_ROLLUP_1 UInt32, - ROLE_ROLLUP_2 UInt32, - ROLE_DEPTNAME UInt32, - ROLE_TITLE UInt32, - ROLE_FAMILY_DESC UInt32, - ROLE_FAMILY UInt32, - ROLE_CODE UInt32 -) -ENGINE = MergeTree ORDER BY date -``` - -**3.** Salir del cliente de la consola ClickHouse: - -``` sql -:) exit -``` - -## 2. Insertar los datos en la tabla {#insert-data-to-table} - -Para insertar los datos: - -**1.** Ejecute el siguiente comando: - -``` bash -$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv -``` - -**2.** Inicie el cliente de consola ClickHouse en el modo interactivo: - -``` bash -$ clickhouse client -``` - -**3.** Asegúrese de que los datos se hayan cargado: - -``` sql -:) SELECT count() FROM amazon_train - -SELECT count() -FROM amazon_train - -+-count()-+ -| 65538 | -+-------+ -``` - -## 3. Integrar CatBoost en ClickHouse {#integrate-catboost-into-clickhouse} - -!!! note "Nota" - **Paso opcional.** La imagen de Docker contiene todo lo que necesita para ejecutar CatBoost y ClickHouse. - -Para integrar CatBoost en ClickHouse: - -**1.** Construir la biblioteca de evaluación. - -La forma más rápida de evaluar un modelo CatBoost es compilar `libcatboostmodel.` biblioteca. Para obtener más información acerca de cómo construir la biblioteca, vea [Documentación de CatBoost](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). - -**2.** Cree un nuevo directorio en cualquier lugar y con cualquier nombre, por ejemplo, `data` y poner la biblioteca creada en ella. La imagen de Docker ya contiene la biblioteca `data/libcatboostmodel.so`. - -**3.** Cree un nuevo directorio para el modelo de configuración en cualquier lugar y con cualquier nombre, por ejemplo, `models`. - -**4.** Cree un archivo de configuración de modelo con cualquier nombre, por ejemplo, `models/amazon_model.xml`. - -**5.** Describir la configuración del modelo: - -``` xml - - - - catboost - - amazon - - /home/catboost/tutorial/catboost_model.bin - - 0 - - -``` - -**6.** Agregue la ruta de acceso a CatBoost y la configuración del modelo a la configuración de ClickHouse: - -``` xml - -/home/catboost/data/libcatboostmodel.so -/home/catboost/models/*_model.xml -``` - -## 4. Ejecute la inferencia del modelo desde SQL {#run-model-inference} - -Para el modelo de prueba, ejecute el cliente ClickHouse `$ clickhouse client`. - -Asegurémonos de que el modelo esté funcionando: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) > 0 AS prediction, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Nota" - Función [modelEvaluar](../sql_reference/functions/other_functions.md#function-modelevaluate) devuelve tupla con predicciones sin procesar por clase para modelos multiclase. - -Vamos a predecir la probabilidad: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1 + exp(-prediction)) AS probability, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Nota" - Más información sobre [exp()](../sql_reference/functions/math_functions.md) función. - -Vamos a calcular LogLoss en la muestra: - -``` sql -:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss -FROM -( - SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1. + exp(-prediction)) AS prob, - ACTION AS tg - FROM amazon_train -) -``` - -!!! note "Nota" - Más información sobre [avg()](../sql_reference/aggregate_functions/reference.md#agg_function-avg) y [registro()](../sql_reference/functions/math_functions.md) función. - -[Artículo Original](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/es/guides/index.md b/docs/es/guides/index.md index 2b410f6db01..c8332ac7846 100644 --- a/docs/es/guides/index.md +++ b/docs/es/guides/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Guides +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Guiar toc_priority: 38 toc_title: "Descripci\xF3n" --- @@ -10,7 +10,7 @@ toc_title: "Descripci\xF3n" Lista de instrucciones detalladas paso a paso que ayudan a resolver varias tareas usando ClickHouse: -- [Tutorial sobre la configuración simple del clúster](../getting_started/tutorial.md) -- [Aplicación de un modelo CatBoost en ClickHouse](apply_catboost_model.md) +- [Tutorial sobre la configuración simple del clúster](../getting-started/tutorial.md) +- [Aplicación de un modelo CatBoost en ClickHouse](apply-catboost-model.md) [Artículo Original](https://clickhouse.tech/docs/en/guides/) diff --git a/docs/es/images/column-oriented.gif b/docs/es/images/column-oriented.gif new file mode 100644 index 00000000000..d5ac7c82848 Binary files /dev/null and b/docs/es/images/column-oriented.gif differ diff --git a/docs/es/images/column_oriented.gif b/docs/es/images/column_oriented.gif deleted file mode 100644 index 15f4b12e697..00000000000 Binary files a/docs/es/images/column_oriented.gif and /dev/null differ diff --git a/docs/es/images/logo.svg b/docs/es/images/logo.svg index 865b96d98c7..b5ab923ff65 100644 --- a/docs/es/images/logo.svg +++ b/docs/es/images/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/docs/es/images/row-oriented.gif b/docs/es/images/row-oriented.gif new file mode 100644 index 00000000000..41395b5693e Binary files /dev/null and b/docs/es/images/row-oriented.gif differ diff --git a/docs/es/images/row_oriented.gif b/docs/es/images/row_oriented.gif deleted file mode 100644 index 53daa20f322..00000000000 Binary files a/docs/es/images/row_oriented.gif and /dev/null differ diff --git a/docs/es/index.md b/docs/es/index.md index 1348ef7013d..9a2918ff7c8 100644 --- a/docs/es/index.md +++ b/docs/es/index.md @@ -1,11 +1,11 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 3 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 0 toc_title: "Descripci\xF3n" --- -# ¿qué es clickhouse? {#what-is-clickhouse} +# ¿Qué es ClickHouse? {#what-is-clickhouse} ClickHouse es un sistema de gestión de bases de datos orientado a columnas (DBMS) para el procesamiento analítico en línea de consultas (OLAP). @@ -64,11 +64,11 @@ Las bases de datos orientadas a columnas son más adecuadas para los escenarios **DBMS orientado a filas** -![Row-oriented](images/row_oriented.gif#) +![Row-oriented](images/row-oriented.gif#) **DBMS orientado a columnas** -![Column-oriented](images/column_oriented.gif#) +![Column-oriented](images/column-oriented.gif#) Ver la diferencia? diff --git a/docs/es/interfaces/cli.md b/docs/es/interfaces/cli.md index 058985194e1..1e4852be53f 100644 --- a/docs/es/interfaces/cli.md +++ b/docs/es/interfaces/cli.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 17 toc_title: "Cliente de l\xEDnea de comandos" --- @@ -9,7 +9,7 @@ toc_title: "Cliente de l\xEDnea de comandos" ClickHouse proporciona un cliente de línea de comandos nativo: `clickhouse-client`. El cliente admite opciones de línea de comandos y archivos de configuración. Para obtener más información, consulte [Configuración](#interfaces_cli_configuration). -[Instalar](../getting_started/index.md) desde el `clickhouse-client` paquete y ejecútelo con el comando `clickhouse-client`. +[Instalar](../getting-started/index.md) desde el `clickhouse-client` paquete y ejecútelo con el comando `clickhouse-client`. ``` bash $ clickhouse-client @@ -89,7 +89,7 @@ Formatee una consulta como de costumbre, luego coloque los valores que desea pas ``` - `name` — Placeholder identifier. In the console client it should be used in app parameters as `--param_ = value`. -- `data type` — [Tipo de datos](../sql_reference/data_types/index.md) del valor del parámetro de la aplicación. Por ejemplo, una estructura de datos como `(integer, ('string', integer))` puede tener el `Tuple(UInt8, Tuple(String, UInt8))` tipo de datos (también puede usar otro [entero](../sql_reference/data_types/int_uint.md) tipo). +- `data type` — [Tipo de datos](../sql-reference/data-types/index.md) del valor del parámetro de la aplicación. Por ejemplo, una estructura de datos como `(integer, ('string', integer))` puede tener el `Tuple(UInt8, Tuple(String, UInt8))` tipo de datos (también puede usar otro [entero](../sql-reference/data-types/int-uint.md) tipo). #### Ejemplo {#example} diff --git a/docs/es/interfaces/cpp.md b/docs/es/interfaces/cpp.md index c854513568a..bc5dc3dbc24 100644 --- a/docs/es/interfaces/cpp.md +++ b/docs/es/interfaces/cpp.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 24 toc_title: Biblioteca de clientes de C++ --- diff --git a/docs/es/interfaces/formats.md b/docs/es/interfaces/formats.md index fcb700a8968..f84c78d6e0b 100644 --- a/docs/es/interfaces/formats.md +++ b/docs/es/interfaces/formats.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 21 toc_title: Formatos de entrada y salida --- @@ -110,9 +110,9 @@ Solo se escapa un pequeño conjunto de símbolos. Puede tropezar fácilmente con Las matrices se escriben como una lista de valores separados por comas entre corchetes. Los elementos numéricos de la matriz tienen el formato normal. `Date` y `DateTime` están escritos entre comillas simples. Las cadenas se escriben entre comillas simples con las mismas reglas de escape que las anteriores. -[NULL](../sql_reference/syntax.md) se formatea como `\N`. +[NULL](../sql-reference/syntax.md) se formatea como `\N`. -Cada elemento de [Anidar](../sql_reference/data_types/nested_data_structures/nested.md) estructuras se representa como una matriz. +Cada elemento de [Anidar](../sql-reference/data-types/nested-data-structures/nested.md) estructuras se representa como una matriz. Por ejemplo: @@ -317,7 +317,7 @@ format_template_resultset = '/some/path/resultset.format', format_template_row = ## TSKV {#tskv} -Similar a TabSeparated, pero las salidas de un valor en nombre=valor de formato. Los nombres se escapó de la misma manera como en TabSeparated formato, y el símbolo = es también escapó. +Similar a TabSeparated , pero genera un valor en formato name=value . Los nombres se escapan de la misma manera que en el formato TabSeparated, y el símbolo = también se escapa. ``` text SearchPhrase= count()=8267016 @@ -332,7 +332,7 @@ SearchPhrase=curtain designs count()=1064 SearchPhrase=baku count()=1000 ``` -[NULL](../sql_reference/syntax.md) se formatea como `\N`. +[NULL](../sql-reference/syntax.md) se formatea como `\N`. ``` sql SELECT * FROM t_null FORMAT TSKV @@ -464,7 +464,7 @@ Si la consulta contiene GROUP BY, rows\_before\_limit\_at\_least es el número e Este formato solo es apropiado para generar un resultado de consulta, pero no para analizar (recuperar datos para insertar en una tabla). -Soporta ClickHouse [NULL](../sql_reference/syntax.md), que se muestra como `null` en la salida JSON. +Soporta ClickHouse [NULL](../sql-reference/syntax.md), que se muestra como `null` en la salida JSON. Ver también el [JSONEachRow](#jsoneachrow) formato. @@ -541,7 +541,7 @@ ClickHouse ignora los espacios entre los elementos y las comas después de los o **Procesamiento de valores omitidos** -ClickHouse sustituye los valores omitidos por los valores predeterminados para el [tipos de datos](../sql_reference/data_types/index.md). +ClickHouse sustituye los valores omitidos por los valores predeterminados para el [tipos de datos](../sql-reference/data-types/index.md). Si `DEFAULT expr` se especifica, ClickHouse utiliza diferentes reglas de sustitución dependiendo de la [Entrada\_format\_defaults\_for\_omitted\_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields) configuración. @@ -586,7 +586,7 @@ A diferencia de la [JSON](#json) formato, no hay sustitución de secuencias UTF- ### Uso de estructuras anidadas {#jsoneachrow-nested} -Si tienes una mesa con [Anidar](../sql_reference/data_types/nested_data_structures/nested.md) columnas de tipo de datos, puede insertar datos JSON con la misma estructura. Habilite esta función con el [Entrada\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) configuración. +Si tienes una mesa con [Anidar](../sql-reference/data-types/nested-data-structures/nested.md) columnas de tipo de datos, puede insertar datos JSON con la misma estructura. Habilite esta función con el [Entrada\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) configuración. Por ejemplo, considere la siguiente tabla: @@ -660,7 +660,7 @@ Salidas de datos como tablas de arte Unicode, también utilizando secuencias de Se dibuja una cuadrícula completa de la tabla, y cada fila ocupa dos líneas en la terminal. Cada bloque de resultados se muestra como una tabla separada. Esto es necesario para que los bloques se puedan generar sin resultados de almacenamiento en búfer (el almacenamiento en búfer sería necesario para calcular previamente el ancho visible de todos los valores). -[NULL](../sql_reference/syntax.md) se emite como `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) se emite como `ᴺᵁᴸᴸ`. Ejemplo (mostrado para el [PrettyCompact](#prettycompact) formato): @@ -747,7 +747,7 @@ Lo mismo que el ajuste anterior. Lo mismo que el ajuste anterior. -## Bienvenido a WordPress. {#prettyspace} +## Bienvenido a WordPress {#prettyspace} Difiere de [PrettyCompact](#prettycompact) en ese espacio en blanco (caracteres de espacio) se usa en lugar de la cuadrícula. @@ -764,7 +764,7 @@ FixedString se representa simplemente como una secuencia de bytes. La matriz se representa como una longitud varint (sin signo [LEB128](https://en.wikipedia.org/wiki/LEB128)), seguido de elementos sucesivos de la matriz. -Para [NULL](../sql_reference/syntax.md#null-literal) soporte, se añade un byte adicional que contiene 1 o 0 antes de cada [NULL](../sql_reference/data_types/nullable.md) valor. Si 1, entonces el valor es `NULL` y este byte se interpreta como un valor separado. Si es 0, el valor después del byte no es `NULL`. +Para [NULL](../sql-reference/syntax.md#null-literal) soporte, se añade un byte adicional que contiene 1 o 0 antes de cada [NULL](../sql-reference/data-types/nullable.md) valor. Si 1, entonces el valor es `NULL` y este byte se interpreta como un valor separado. Si es 0, el valor después del byte no es `NULL`. ## RowBinaryWithNamesAndTypes {#rowbinarywithnamesandtypes} @@ -776,7 +776,7 @@ Similar a [RowBinary](#rowbinary), pero con encabezado añadido: ## Valor {#data-format-values} -Imprime cada fila entre paréntesis. Las filas están separadas por comas. No hay coma después de la última fila. Los valores dentro de los corchetes también están separados por comas. Los números se emiten en formato decimal sin comillas. Las matrices se emiten entre corchetes. Las cadenas, fechas y fechas con horas se generan entre comillas. Las reglas de escape y el análisis son similares a las [TabSeparated](#tabseparated) formato. Durante el formateo, los espacios adicionales no se insertan, pero durante el análisis, se permiten y omiten (excepto los espacios dentro de los valores de la matriz, que no están permitidos). [NULL](../sql_reference/syntax.md) se representa como `NULL`. +Imprime cada fila entre paréntesis. Las filas están separadas por comas. No hay coma después de la última fila. Los valores dentro de los corchetes también están separados por comas. Los números se emiten en formato decimal sin comillas. Las matrices se emiten entre corchetes. Las cadenas, fechas y fechas con horas se generan entre comillas. Las reglas de escape y el análisis son similares a las [TabSeparated](#tabseparated) formato. Durante el formateo, los espacios adicionales no se insertan, pero durante el análisis, se permiten y omiten (excepto los espacios dentro de los valores de la matriz, que no están permitidos). [NULL](../sql-reference/syntax.md) se representa como `NULL`. The minimum set of characters that you need to escape when passing data in Values ​​format: single quotes and backslashes. @@ -786,9 +786,9 @@ Ver también: [input\_format\_values\_interpret\_expressions](../operations/sett ## Vertical {#vertical} -Imprime cada valor en una línea independiente con el nombre de la columna especificada. Este formato es conveniente para imprimir solo una o varias filas si cada fila consta de un gran número de columnas. +Imprime cada valor en una línea independiente con el nombre de columna especificado. Este formato es conveniente para imprimir solo una o varias filas si cada fila consta de un gran número de columnas. -[NULL](../sql_reference/syntax.md) se emite como `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) se emite como `ᴺᵁᴸᴸ`. Ejemplo: @@ -967,7 +967,7 @@ message MessageType { ``` ClickHouse intenta encontrar una columna llamada `x.y.z` (o `x_y_z` o `X.y_Z` y así sucesivamente). -Los mensajes anidados son adecuados para [estructuras de datos anidados](../sql_reference/data_types/nested_data_structures/nested.md). +Los mensajes anidados son adecuados para [estructuras de datos anidados](../sql-reference/data-types/nested-data-structures/nested.md). Valores predeterminados definidos en un esquema protobuf como este @@ -979,7 +979,7 @@ message MessageType { } ``` -no se aplican; el [valores predeterminados de la tabla](../sql_reference/statements/create.md#create-default-values) se utilizan en lugar de ellos. +no se aplican; el [valores predeterminados de la tabla](../sql-reference/statements/create.md#create-default-values) se utilizan en lugar de ellos. ClickHouse entra y emite mensajes protobuf en el `length-delimited` formato. Significa que antes de cada mensaje debe escribirse su longitud como un [varint](https://developers.google.com/protocol-buffers/docs/encoding#varints). @@ -993,23 +993,23 @@ El formato ClickHouse Avro admite lectura y escritura [Archivos de datos Avro](h ### Coincidencia de tipos de datos {#data_types-matching} -La siguiente tabla muestra los tipos de datos admitidos y cómo coinciden con ClickHouse [tipos de datos](../sql_reference/data_types/index.md) en `INSERT` y `SELECT` consulta. +La siguiente tabla muestra los tipos de datos admitidos y cómo coinciden con ClickHouse [tipos de datos](../sql-reference/data-types/index.md) en `INSERT` y `SELECT` consulta. | Tipo de datos Avro `INSERT` | Tipo de datos ClickHouse | Tipo de datos Avro `SELECT` | |---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|------------------------------| -| `boolean`, `int`, `long`, `float`, `double` | [¿cómo funciona?)](../sql_reference/data_types/int_uint.md), [UInt(8\|16\|32)](../sql_reference/data_types/int_uint.md) | `int` | -| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql_reference/data_types/int_uint.md), [UInt64](../sql_reference/data_types/int_uint.md) | `long` | -| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql_reference/data_types/float.md) | `float` | -| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql_reference/data_types/float.md) | `double` | -| `bytes`, `string`, `fixed`, `enum` | [Cadena](../sql_reference/data_types/string.md) | `bytes` | -| `bytes`, `string`, `fixed` | [Cadena fija (N)](../sql_reference/data_types/fixedstring.md) | `fixed(N)` | -| `enum` | [Enum (8\|16)](../sql_reference/data_types/enum.md) | `enum` | -| `array(T)` | [Matriz (T)](../sql_reference/data_types/array.md) | `array(T)` | -| `union(null, T)`, `union(T, null)` | [Nivel de Cifrado WEP)](../sql_reference/data_types/date.md) | `union(null, T)` | -| `null` | [Nullable (nada)](../sql_reference/data_types/special_data_types/nothing.md) | `null` | -| `int (date)` \* | [Fecha](../sql_reference/data_types/date.md) | `int (date)` \* | -| `long (timestamp-millis)` \* | [¿qué puedes encontrar en neodigit)](../sql_reference/data_types/datetime.md) | `long (timestamp-millis)` \* | -| `long (timestamp-micros)` \* | [Cómo hacer esto?)](../sql_reference/data_types/datetime.md) | `long (timestamp-micros)` \* | +| `boolean`, `int`, `long`, `float`, `double` | [¿Cómo funciona?)](../sql-reference/data-types/int-uint.md), [UInt(8\|16\|32)](../sql-reference/data-types/int-uint.md) | `int` | +| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql-reference/data-types/int-uint.md), [UInt64](../sql-reference/data-types/int-uint.md) | `long` | +| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql-reference/data-types/float.md) | `float` | +| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql-reference/data-types/float.md) | `double` | +| `bytes`, `string`, `fixed`, `enum` | [Cadena](../sql-reference/data-types/string.md) | `bytes` | +| `bytes`, `string`, `fixed` | [Cadena fija (N)](../sql-reference/data-types/fixedstring.md) | `fixed(N)` | +| `enum` | [Enum (8\|16)](../sql-reference/data-types/enum.md) | `enum` | +| `array(T)` | [Matriz (T)](../sql-reference/data-types/array.md) | `array(T)` | +| `union(null, T)`, `union(T, null)` | [Nivel de Cifrado WEP)](../sql-reference/data-types/date.md) | `union(null, T)` | +| `null` | [Nullable (nada)](../sql-reference/data-types/special-data-types/nothing.md) | `null` | +| `int (date)` \* | [Fecha](../sql-reference/data-types/date.md) | `int (date)` \* | +| `long (timestamp-millis)` \* | [¿Qué puedes encontrar en Neodigit)](../sql-reference/data-types/datetime.md) | `long (timestamp-millis)` \* | +| `long (timestamp-micros)` \* | [Cómo hacer esto?)](../sql-reference/data-types/datetime.md) | `long (timestamp-micros)` \* | \* [Tipos lógicos Avro](http://avro.apache.org/docs/current/spec.html#Logical+Types) @@ -1030,7 +1030,7 @@ El esquema raíz del archivo Avro de entrada debe ser de `record` tipo. Para encontrar la correspondencia entre las columnas de la tabla y los campos de Avro esquema ClickHouse compara sus nombres. Esta comparación distingue entre mayúsculas y minúsculas. Los campos no utilizados se omiten. -Los tipos de datos de las columnas de tabla ClickHouse pueden diferir de los campos correspondientes de los datos de Avro insertados. Al insertar datos, ClickHouse interpreta los tipos de datos de acuerdo con la tabla anterior y luego [elenco](../query_language/functions/type_conversion_functions/#type_conversion_function-cast) los datos al tipo de columna correspondiente. +Los tipos de datos de las columnas de tabla ClickHouse pueden diferir de los campos correspondientes de los datos de Avro insertados. Al insertar datos, ClickHouse interpreta los tipos de datos de acuerdo con la tabla anterior y luego [elenco](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) los datos al tipo de columna correspondiente. ### Selección de datos {#selecting-data-1} @@ -1063,7 +1063,7 @@ Lo mismo que [Avro](#data-format-avro) ### Uso {#usage} -Para verificar rápidamente la resolución del esquema, puede usar [Método de codificación de datos:](https://github.com/edenhill/kafkacat) con [Sistema abierto.](../operations/utilities/clickhouse-local.md): +Para verificar rápidamente la resolución del esquema, puede usar [Método de codificación de datos:](https://github.com/edenhill/kafkacat) con [Sistema abierto.](../operations/utilities/clickhouse-local.md#clickhouse-local): ``` bash $ kafkacat -b kafka-broker -C -t topic1 -o beginning -f '%s' -c 3 | clickhouse-local --input-format AvroConfluent --format_avro_schema_registry_url 'http://schema-registry' -S "field1 Int64, field2 String" -q 'select * from table' @@ -1072,7 +1072,7 @@ $ kafkacat -b kafka-broker -C -t topic1 -o beginning -f '%s' -c 3 | clickhouse- 3 c ``` -Utilizar `AvroConfluent` con [Kafka](../engines/table_engines/integrations/kafka.md): +Utilizar `AvroConfluent` con [Kafka](../engines/table-engines/integrations/kafka.md): ``` sql CREATE TABLE topic1_stream @@ -1101,25 +1101,25 @@ SELECT * FROM topic1_stream; ### Coincidencia de tipos de datos {#data_types-matching-2} -La siguiente tabla muestra los tipos de datos admitidos y cómo coinciden con ClickHouse [tipos de datos](../sql_reference/data_types/index.md) en `INSERT` y `SELECT` consulta. +La siguiente tabla muestra los tipos de datos admitidos y cómo coinciden con ClickHouse [tipos de datos](../sql-reference/data-types/index.md) en `INSERT` y `SELECT` consulta. | Tipo de datos de parquet (`INSERT`) | Tipo de datos ClickHouse | Tipo de datos de parquet (`SELECT`) | |-------------------------------------|-----------------------------------------------------------|-------------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | `UINT8` | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | `INT8` | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | `UINT16` | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | `INT16` | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | `UINT32` | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | `INT32` | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | `UINT64` | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | `INT64` | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | `FLOAT` | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | `DOUBLE` | -| `DATE32` | [Fecha](../sql_reference/data_types/date.md) | `UINT16` | -| `DATE64`, `TIMESTAMP` | [FechaHora](../sql_reference/data_types/datetime.md) | `UINT32` | -| `STRING`, `BINARY` | [Cadena](../sql_reference/data_types/string.md) | `STRING` | -| — | [Cadena fija](../sql_reference/data_types/fixedstring.md) | `STRING` | -| `DECIMAL` | [Decimal](../sql_reference/data_types/decimal.md) | `DECIMAL` | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | `UINT8` | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | `INT8` | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | `UINT16` | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | `INT16` | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | `UINT32` | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | `INT32` | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | `UINT64` | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | `INT64` | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | `FLOAT` | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | `DOUBLE` | +| `DATE32` | [Fecha](../sql-reference/data-types/date.md) | `UINT16` | +| `DATE64`, `TIMESTAMP` | [FechaHora](../sql-reference/data-types/datetime.md) | `UINT32` | +| `STRING`, `BINARY` | [Cadena](../sql-reference/data-types/string.md) | `STRING` | +| — | [Cadena fija](../sql-reference/data-types/fixedstring.md) | `STRING` | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | `DECIMAL` | ClickHouse admite una precisión configurable de `Decimal` tipo. El `INSERT` consulta trata el Parquet `DECIMAL` tipo como el ClickHouse `Decimal128` tipo. @@ -1141,7 +1141,7 @@ Puede seleccionar datos de una tabla ClickHouse y guardarlos en algún archivo e $ clickhouse-client --query="SELECT * FROM {some_table} FORMAT Parquet" > {some_file.pq} ``` -Para intercambiar datos con Hadoop, puede usar [Motor de mesa HDFS](../engines/table_engines/integrations/hdfs.md). +Para intercambiar datos con Hadoop, puede usar [Motor de mesa HDFS](../engines/table-engines/integrations/hdfs.md). ## ORC {#data-format-orc} @@ -1149,30 +1149,30 @@ Para intercambiar datos con Hadoop, puede usar [Motor de mesa HDFS](../engines/t ### Coincidencia de tipos de datos {#data_types-matching-3} -La siguiente tabla muestra los tipos de datos admitidos y cómo coinciden con ClickHouse [tipos de datos](../sql_reference/data_types/index.md) en `INSERT` consulta. +La siguiente tabla muestra los tipos de datos admitidos y cómo coinciden con ClickHouse [tipos de datos](../sql-reference/data-types/index.md) en `INSERT` consulta. | Tipo de datos ORC (`INSERT`) | Tipo de datos ClickHouse | |------------------------------|------------------------------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | -| `DATE32` | [Fecha](../sql_reference/data_types/date.md) | -| `DATE64`, `TIMESTAMP` | [FechaHora](../sql_reference/data_types/datetime.md) | -| `STRING`, `BINARY` | [Cadena](../sql_reference/data_types/string.md) | -| `DECIMAL` | [Decimal](../sql_reference/data_types/decimal.md) | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE32` | [Fecha](../sql-reference/data-types/date.md) | +| `DATE64`, `TIMESTAMP` | [FechaHora](../sql-reference/data-types/datetime.md) | +| `STRING`, `BINARY` | [Cadena](../sql-reference/data-types/string.md) | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | ClickHouse soporta la precisión configurable de la `Decimal` tipo. El `INSERT` consulta trata el ORC `DECIMAL` tipo como el ClickHouse `Decimal128` tipo. Tipos de datos ORC no admitidos: `DATE32`, `TIME32`, `FIXED_SIZE_BINARY`, `JSON`, `UUID`, `ENUM`. -Los tipos de datos de las columnas de tabla ClickHouse no tienen que coincidir con los campos de datos ORC correspondientes. Al insertar datos, ClickHouse interpreta los tipos de datos de acuerdo con la tabla anterior y luego [elenco](../query_language/functions/type_conversion_functions/#type_conversion_function-cast) los datos al tipo de datos establecido para la columna de tabla ClickHouse. +Los tipos de datos de las columnas de tabla ClickHouse no tienen que coincidir con los campos de datos ORC correspondientes. Al insertar datos, ClickHouse interpreta los tipos de datos de acuerdo con la tabla anterior y luego [elenco](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) los datos al tipo de datos establecido para la columna de tabla ClickHouse. ### Insertar datos {#inserting-data-2} @@ -1182,7 +1182,7 @@ Puede insertar datos ORC de un archivo en la tabla ClickHouse mediante el siguie $ cat filename.orc | clickhouse-client --query="INSERT INTO some_table FORMAT ORC" ``` -Para intercambiar datos con Hadoop, puede usar [Motor de mesa HDFS](../engines/table_engines/integrations/hdfs.md). +Para intercambiar datos con Hadoop, puede usar [Motor de mesa HDFS](../engines/table-engines/integrations/hdfs.md). ## Esquema de formato {#formatschema} @@ -1194,11 +1194,11 @@ Si el archivo tiene la extensión estándar para el formato (por ejemplo, `.prot se puede omitir y en este caso, el esquema de formato se ve así `schemafile:MessageType`. Si introduce o emite datos a través del [cliente](../interfaces/cli.md) en el [modo interactivo](../interfaces/cli.md#cli_usage), el nombre de archivo especificado en el esquema de formato -puede contener una ruta de acceso absoluta o una ruta relativa al directorio actual en el cliente. +puede contener una ruta absoluta o una ruta relativa al directorio actual en el cliente. Si utiliza el cliente en el [modo por lotes](../interfaces/cli.md#cli_usage), la ruta de acceso al esquema debe ser relativa por razones de seguridad. Si introduce o emite datos a través del [Interfaz HTTP](../interfaces/http.md) el nombre de archivo especificado en el esquema de formato -debe estar ubicado en el directorio especificado en [format\_schema\_path](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-format_schema_path) +debe estar ubicado en el directorio especificado en [format\_schema\_path](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-format_schema_path) en la configuración del servidor. ## Salto de errores {#skippingerrors} diff --git a/docs/es/interfaces/http.md b/docs/es/interfaces/http.md index a2d32d30acc..abc5cf63188 100644 --- a/docs/es/interfaces/http.md +++ b/docs/es/interfaces/http.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 19 toc_title: Interfaz HTTP --- @@ -11,7 +11,7 @@ La interfaz HTTP le permite usar ClickHouse en cualquier plataforma desde cualqu De forma predeterminada, clickhouse-server escucha HTTP en el puerto 8123 (esto se puede cambiar en la configuración). -Si realiza una solicitud GET / sin parámetros, devuelve 200 códigos de respuesta y la cadena que definió en [http\_server\_default\_response](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-http_server_default_response) valor predeterminado “Ok.” (con un avance de línea al final) +Si realiza una solicitud GET / sin parámetros, devuelve 200 códigos de respuesta y la cadena que definió en [http\_server\_default\_response](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-http_server_default_response) valor predeterminado “Ok.” (con un avance de línea al final) ``` bash $ curl 'http://localhost:8123/' @@ -303,13 +303,16 @@ Ejemplo: ``` xml - - /metrics - GET - + + /predefined_query + POST,GET + + predefined_query_handler SELECT * FROM system.metrics LIMIT 5 FORMAT Template SETTINGS format_template_resultset = 'prometheus_template_output_format_resultset', format_template_row = 'prometheus_template_output_format_row', format_template_rows_between_delimiter = '\n' - - + + + ... + ... ``` @@ -318,21 +321,23 @@ Ejemplo: ``` bash -curl -vvv 'http://localhost:8123/metrics' +$ curl -v 'http://localhost:8123/predefined_query' * Trying ::1... * Connected to localhost (::1) port 8123 (#0) -> GET /metrics HTTP/1.1 +> GET /predefined_query HTTP/1.1 > Host: localhost:8123 > User-Agent: curl/7.47.0 > Accept: */* > < HTTP/1.1 200 OK -< Date: Wed, 27 Nov 2019 08:54:25 GMT +< Date: Tue, 28 Apr 2020 08:52:56 GMT < Connection: Keep-Alive < Content-Type: text/plain; charset=UTF-8 -< X-ClickHouse-Server-Display-Name: i-tl62qd0o +< X-ClickHouse-Server-Display-Name: i-mloy5trc < Transfer-Encoding: chunked -< X-ClickHouse-Query-Id: f39235f6-6ed7-488c-ae07-c7ceafb960f6 +< X-ClickHouse-Query-Id: 96fe0052-01e6-43ce-b12a-6b7370de6e8a +< X-ClickHouse-Format: Template +< X-ClickHouse-Timezone: Asia/Shanghai < Keep-Alive: timeout=3 < X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} < @@ -356,117 +361,62 @@ curl -vvv 'http://localhost:8123/metrics' # TYPE "ReplicatedSend" counter "ReplicatedSend" 0 +* Connection #0 to host localhost left intact + + * Connection #0 to host localhost left intact ``` -Como puede ver en el ejemplo, si `` está configurado en la configuración.archivo xml, ClickHouse coincidirá con las solicitudes HTTP recibidas con el tipo predefinido en ``, entonces ClickHouse ejecutará la consulta predefinida correspondiente si la coincidencia es exitosa. +Como puede ver en el ejemplo, si `` está configurado en la configuración.archivo xml y `` puede contener muchos `s`. ClickHouse coincidirá con las solicitudes HTTP recibidas con el tipo predefinido en `` y el primer emparejado ejecuta el controlador. Luego, ClickHouse ejecutará la consulta predefinida correspondiente si la coincidencia es exitosa. -Ahora `` puede configurar ``, ``, ``, `` y `` . +> Ahora `` puede configurar ``, ``, ``,``: +> `` es responsable de hacer coincidir la parte del método de la solicitud HTTP. `` se ajusta plenamente a la definición de [método](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) en el protocolo HTTP. Es una configuración opcional. Si no está definido en el archivo de configuración, no coincide con la parte del método de la solicitud HTTP. +> +> `` es responsable de hacer coincidir la parte url de la solicitud HTTP. Es compatible con [RE2](https://github.com/google/re2)expresiones regulares. Es una configuración opcional. Si no está definido en el archivo de configuración, no coincide con la parte url de la solicitud HTTP. +> +> `` es responsable de hacer coincidir la parte del encabezado de la solicitud HTTP. Es compatible con las expresiones regulares de RE2. Es una configuración opcional. Si no está definido en el archivo de configuración, no coincide con la parte de encabezado de la solicitud HTTP. +> +> `` contiene la parte de procesamiento principal. Ahora `` puede configurar ``, ``, ``, ``, ``, ``. +> \> `` Actualmente soporta tres tipos: **Dirección de correo electrónico**, **Nombre de la red inalámbrica (SSID):**, **estática**. +> \> +> \> `` - utilizar con el tipo predefined\_query\_handler, ejecuta la consulta cuando se llama al controlador. +> \> +> \> `` - utilizar con el tipo dynamic\_query\_handler, extrae y ejecuta el valor correspondiente al `` valor en parámetros de solicitud HTTP. +> \> +> \> `` - uso con tipo estático, código de estado de respuesta. +> \> +> \> `` - uso con tipo estático, respuesta [tipo de contenido](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type). +> \> +> \> `` - uso con tipo estático, contenido de respuesta enviado al cliente, cuando se usa el prefijo ‘file://’ o ‘config://’, encontrar el contenido del archivo o configuración enviar al cliente. -## root\_handler {#root_handler} - -`` devuelve el contenido especificado para la solicitud de ruta de acceso raíz. El contenido devuelto específico se configura mediante `http_server_default_response` en la configuración.XML. si no se especifica, devolver **Ok.** - -`http_server_default_response` no está definido y se envía una solicitud HTTP a ClickHouse. El resultado es el siguiente: - -``` xml - - - -``` - - $ curl 'http://localhost:8123' - Ok. - -`http_server_default_response` se define y se envía una solicitud HTTP a ClickHouse. El resultado es el siguiente: - -``` xml -
]]>
- - - - -``` - - $ curl 'http://localhost:8123' -
% - -## Método de codificación de datos: {#ping_handler} - -`` se puede utilizar para sondear el estado del servidor ClickHouse actual. Cuando el servidor HTTP ClickHouse es normal, acceder a ClickHouse a través de `` volverá **Ok.**. - -Ejemplo: - -``` xml - - /ping - -``` - -``` bash -$ curl 'http://localhost:8123/ping' -Ok. -``` - -## Sistema abierto. {#replicas_status_handler} - -`` se utiliza para detectar el estado de la réplica y el nodo de retorno **Ok.** si el nodo de réplica no tiene retraso. Si hay un retraso, devuelva el retraso específico. El valor de `` admite personalización. Si no especifica ``, Configuración predeterminada de ClickHouse `` ser **/replicas\_status**. - -Ejemplo: - -``` xml - - /replicas_status - -``` - -Ningún caso del retraso: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -Ok. -``` - -Caso retrasado: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -db.stats: Absolute delay: 22. Relative delay: 22. -``` +A continuación están los métodos de configuración para los diferentes ``. ## Dirección de correo electrónico {#predefined_query_handler} -Puede configurar ``, ``, `` y `` en ``. +`` admite la configuración de valores Settings y query\_params. Puede configurar `` en el tipo de ``. -`` es responsable de hacer coincidir la parte del método de la solicitud HTTP. `` se ajusta plenamente a la definición de [método](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) en el protocolo HTTP. Es una configuración opcional. Si no está definido en el archivo de configuración, no coincide con la parte del método de la solicitud HTTP - -`` es responsable de hacer coincidir la parte url de la solicitud HTTP. Es compatible con [RE2](https://github.com/google/re2)expresiones regulares. Es una configuración opcional. Si no está definido en el archivo de configuración, no coincide con la parte url de la solicitud HTTP - -`` es responsable de hacer coincidir la parte del encabezado de la solicitud HTTP. Es compatible con las expresiones regulares de RE2. Es una configuración opcional. Si no está definido en el archivo de configuración, no coincide con la parte de encabezado de la solicitud HTTP - -`` valor es una consulta predefinida de ``, que es ejecutado por ClickHouse cuando se hace coincidir una solicitud HTTP y se devuelve el resultado de la consulta. Es una configuración imprescindible. - -`` admite la configuración de valores Settings y query\_params. +`` valor es una consulta predefinida de ``, que es ejecutado por ClickHouse cuando se hace coincidir una solicitud HTTP y se devuelve el resultado de la consulta. Es una configuración imprescindible. En el ejemplo siguiente se definen los valores de `max_threads` y `max_alter_threads` configuración, a continuación, consulta la tabla del sistema para comprobar si estos ajustes se han establecido correctamente. Ejemplo: ``` xml - - + + + [^/]+)(/(?P[^/]+))?]]> GET TEST_HEADER_VALUE [^/]+)(/(?P[^/]+))?]]> - [^/]+)(/(?P[^/]+))?]]> - + + predefined_query_handler SELECT value FROM system.settings WHERE name = {name_1:String} SELECT name, value FROM system.settings WHERE name = {name_2:String} - - - +
+
+
``` ``` bash @@ -475,37 +425,193 @@ $ curl -H 'XXX:TEST_HEADER_VALUE' -H 'PARAMS_XXX:max_threads' 'http://localhost: max_alter_threads 2 ``` -!!! note "Nota" - En uno ``, una `` sólo es compatible con uno `` de un tipo de plaquita. +!!! note "precaución" + En uno `` sólo es compatible con uno `` de un tipo de plaquita. ## Nombre de la red inalámbrica (SSID): {#dynamic_query_handler} -`` que `` aumentar `` . +En ``, consulta se escribe en forma de param de la solicitud HTTP. La diferencia es que en ``, consulta se escribe en el archivo de configuración. Puede configurar `` en ``. -ClickHouse extrae y ejecuta el valor correspondiente al `` valor en la url de la petición HTTP. -Configuración predeterminada de ClickHouse `` ser `/query` . Es una configuración opcional. Si no hay una definición en el archivo de configuración, el parámetro no se pasa. +ClickHouse extrae y ejecuta el valor correspondiente al `` valor en la url de la solicitud HTTP. El valor predeterminado de `` ser `/query` . Es una configuración opcional. Si no hay una definición en el archivo de configuración, el parámetro no se pasa. Para experimentar con esta funcionalidad, el ejemplo define los valores de max\_threads y max\_alter\_threads y consulta si la configuración se estableció correctamente. -La diferencia es que en ``, consulta se escribe en el archivo de configuración. Pero en ``, consulta se escribe en forma de param de la solicitud HTTP. Ejemplo: ``` xml - - - - TEST_HEADER_VALUE_DYNAMIC - [^/]+)(/(?P[^/]+))?]]> - + + + + TEST_HEADER_VALUE_DYNAMIC + + dynamic_query_handler query_param - - + +
+
``` ``` bash -$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' -H 'PARAMS_XXX:max_threads' 'http://localhost:8123/?query_param=SELECT%20value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D&max_threads=1&max_alter_threads=2¶m_name_2=max_alter_threads' -1 -2 +$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' 'http://localhost:8123/own?max_threads=1&max_alter_threads=2¶m_name_1=max_threads¶m_name_2=max_alter_threads&query_param=SELECT%20name,value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D' +max_threads 1 +max_alter_threads 2 +``` + +## estática {#static} + +`` puede volver [Content\_type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type), [estatus](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) y response\_content. response\_content puede devolver el contenido especificado + +Ejemplo: + +Devuelve un mensaje. + +``` xml + + + GET + xxx + /hi + + static + 402 + text/html; charset=UTF-8 + Say Hi! + + + +``` + +``` bash +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/hi' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /hi HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 402 Payment Required +< Date: Wed, 29 Apr 2020 03:51:26 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +Say Hi!% +``` + +Busque el contenido de la configuración enviada al cliente. + +``` xml +
]]>
+ + + + GET + xxx + /get_config_static_handler + + static + config://get_config_static_handler + + + +``` + +``` bash +$ curl -v -H 'XXX:xxx' 'http://localhost:8123/get_config_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_config_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:01:24 GMT +< Connection: Keep-Alive +< Content-Type: text/plain; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +
% +``` + +Encuentra el contenido del archivo enviado al cliente. + +``` xml + + + GET + xxx + /get_absolute_path_static_handler + + static + text/html; charset=UTF-8 + file:///absolute_path_file.html + + + + GET + xxx + /get_relative_path_static_handler + + static + text/html; charset=UTF-8 + file://./relative_path_file.html + + + +``` + +``` bash +$ user_files_path='/var/lib/clickhouse/user_files' +$ sudo echo "Relative Path File" > $user_files_path/relative_path_file.html +$ sudo echo "Absolute Path File" > $user_files_path/absolute_path_file.html +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_absolute_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_absolute_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:16 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Absolute Path File +* Connection #0 to host localhost left intact +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_relative_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_relative_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:31 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Relative Path File +* Connection #0 to host localhost left intact ``` [Artículo Original](https://clickhouse.tech/docs/en/interfaces/http_interface/) diff --git a/docs/es/interfaces/index.md b/docs/es/interfaces/index.md index 8a15889ab81..3632c8a9e29 100644 --- a/docs/es/interfaces/index.md +++ b/docs/es/interfaces/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Interfaces +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Interfaz toc_priority: 14 toc_title: "Implantaci\xF3n" --- @@ -22,7 +22,7 @@ En la mayoría de los casos, se recomienda utilizar la herramienta o biblioteca También hay una amplia gama de bibliotecas de terceros para trabajar con ClickHouse: -- [Bibliotecas de clientes](third-party/client_libraries.md) +- [Bibliotecas de clientes](third-party/client-libraries.md) - [Integración](third-party/integrations.md) - [Interfaces visuales](third-party/gui.md) diff --git a/docs/es/interfaces/jdbc.md b/docs/es/interfaces/jdbc.md index fd3f26c946a..7303dec8960 100644 --- a/docs/es/interfaces/jdbc.md +++ b/docs/es/interfaces/jdbc.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 22 toc_title: Controlador JDBC --- diff --git a/docs/es/interfaces/mysql.md b/docs/es/interfaces/mysql.md index bd4545b46f8..796bfbcf1a4 100644 --- a/docs/es/interfaces/mysql.md +++ b/docs/es/interfaces/mysql.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 20 toc_title: Interfaz MySQL --- -# Interfaz de MySQL {#mysql-interface} +# Interfaz MySQL {#mysql-interface} -ClickHouse soporta el protocolo de cable MySQL. Puede ser habilitado por [mysql\_port](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-mysql_port) configuración en el archivo de configuración: +ClickHouse soporta el protocolo de cable MySQL. Puede ser habilitado por [mysql\_port](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-mysql_port) configuración en el archivo de configuración: ``` xml 9004 @@ -37,8 +37,8 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` -Para la compatibilidad con todos los clientes MySQL, se recomienda especificar la contraseña de usuario con [doble SHA1](../operations/settings/settings_users.md#password_double_sha1_hex) en el archivo de configuración. -Si la contraseña de usuario se especifica usando [SHA256](../operations/settings/settings_users.md#password_sha256_hex), algunos clientes no podrán autenticarse (mysqljs y versiones antiguas de la herramienta de línea de comandos mysql). +Para la compatibilidad con todos los clientes MySQL, se recomienda especificar la contraseña de usuario con [doble SHA1](../operations/settings/settings-users.md#password_double_sha1_hex) en el archivo de configuración. +Si la contraseña de usuario se especifica usando [SHA256](../operations/settings/settings-users.md#password_sha256_hex), algunos clientes no podrán autenticarse (mysqljs y versiones antiguas de la herramienta de línea de comandos mysql). Restricción: diff --git a/docs/es/interfaces/odbc.md b/docs/es/interfaces/odbc.md index 9d1a755122b..6ccb979c7f7 100644 --- a/docs/es/interfaces/odbc.md +++ b/docs/es/interfaces/odbc.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 23 toc_title: Conductor ODBC --- diff --git a/docs/es/interfaces/tcp.md b/docs/es/interfaces/tcp.md index fb304f739da..47df0d12829 100644 --- a/docs/es/interfaces/tcp.md +++ b/docs/es/interfaces/tcp.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 18 toc_title: Interfaz nativa (TCP) --- diff --git a/docs/es/interfaces/third-party/client-libraries.md b/docs/es/interfaces/third-party/client-libraries.md new file mode 100644 index 00000000000..44186ec9135 --- /dev/null +++ b/docs/es/interfaces/third-party/client-libraries.md @@ -0,0 +1,58 @@ +--- +toc_priority: 26 +toc_title: Client Libraries +--- + +# Client Libraries from Third-party Developers {#client-libraries-from-third-party-developers} + +!!! warning "Disclaimer" + Yandex does **not** maintain the libraries listed below and haven’t done any extensive testing to ensure their quality. + +- Python + - [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) + - [clickhouse-driver](https://github.com/mymarilyn/clickhouse-driver) + - [clickhouse-client](https://github.com/yurial/clickhouse-client) + - [aiochclient](https://github.com/maximdanilchenko/aiochclient) +- PHP + - [smi2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) + - [8bitov/clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) + - [bozerkins/clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) + - [simpod/clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) + - [seva-code/php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) + - [SeasClick C++ client](https://github.com/SeasX/SeasClick) +- Go + - [clickhouse](https://github.com/kshvakov/clickhouse/) + - [go-clickhouse](https://github.com/roistat/go-clickhouse) + - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) + - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) +- NodeJs + - [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) + - [node-clickhouse](https://github.com/apla/node-clickhouse) +- Perl + - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) + - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) + - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) +- Ruby + - [ClickHouse (Ruby)](https://github.com/shlima/click_house) + - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) +- R + - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) + - [RClickHouse](https://github.com/IMSMWU/RClickHouse) +- Java + - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) + - [clickhouse-client](https://github.com/Ecwid/clickhouse-client) +- Scala + - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) +- Kotlin + - [AORM](https://github.com/TanVD/AORM) +- C\# + - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) + - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) + - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) +- Elixir + - [clickhousex](https://github.com/appodeal/clickhousex/) + - [pillar](https://github.com/sofakingworld/pillar) +- Nim + - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) + +[Original article](https://clickhouse.tech/docs/en/interfaces/third-party/client_libraries/) diff --git a/docs/es/interfaces/third-party/client_libraries.md b/docs/es/interfaces/third-party/client_libraries.md deleted file mode 100644 index 31e9afcac91..00000000000 --- a/docs/es/interfaces/third-party/client_libraries.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 26 -toc_title: Bibliotecas de clientes ---- - -# Bibliotecas de clientes de desarrolladores de terceros {#client-libraries-from-third-party-developers} - -!!! warning "Descargo" - Yandex hace **ni** mantenga las bibliotecas enumeradas a continuación y no haya realizado ninguna prueba extensa para garantizar su calidad. - -- Película - - [InformaciónSistema abierto.](https://github.com/Infinidat/infi.clickhouse_orm) - - [Casa de clics-conductor](https://github.com/mymarilyn/clickhouse-driver) - - [Casa de clics-cliente](https://github.com/yurial/clickhouse-client) - - [Aiochclient](https://github.com/maximdanilchenko/aiochclient) -- PHP - - [Método de codificación de datos:](https://packagist.org/packages/smi2/phpClickHouse) - - [Sistema abierto.](https://packagist.org/packages/8bitov/clickhouse-php-client) - - [Sistema abierto.](https://packagist.org/packages/bozerkins/clickhouse-client) - - [Sistema abierto.](https://packagist.org/packages/simpod/clickhouse-client) - - [Seva-code/php-click-house-cliente](https://packagist.org/packages/seva-code/php-click-house-client) - - [Cliente de SeasClick C++](https://github.com/SeasX/SeasClick) -- Ve - - [Casa de clics](https://github.com/kshvakov/clickhouse/) - - [Sistema abierto.](https://github.com/roistat/go-clickhouse) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/mailru/go-clickhouse) - - [Golang-clickhouse](https://github.com/leprosus/golang-clickhouse) -- NodeJs - - [Casa de clic (NodeJs)](https://github.com/TimonKK/clickhouse) - - [Inicio](https://github.com/apla/node-clickhouse) -- Perl - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/elcamlost/perl-DBD-ClickHouse) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://metacpan.org/release/HTTP-ClickHouse) - - [Cualquier evento-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) -- Rubí - - [Haga clic en Casa (Ruby)](https://github.com/shlima/click_house) - - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) -- R - - [Sistema abierto.](https://github.com/hannesmuehleisen/clickhouse-r) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/IMSMWU/RClickhouse) -- Java - - [Casa de clic-cliente-java](https://github.com/VirtusAI/clickhouse-client-java) - - [Casa de clics-cliente](https://github.com/Ecwid/clickhouse-client) -- Ciudad - - [Sistema abierto.](https://github.com/crobox/clickhouse-scala-client) -- Bienvenido - - [AORM](https://github.com/TanVD/AORM) -- C\# - - [Sistema abierto.Ado](https://github.com/killwort/ClickHouse-Net) - - [Sistema abierto.Cliente](https://github.com/DarkWanderer/ClickHouse.Client) - - [Sistema abierto.](https://github.com/ilyabreev/ClickHouse.Net) -- Elixir - - [clickhousex](https://github.com/appodeal/clickhousex/) -- Nim - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/leonardoce/nim-clickhouse) - -[Artículo Original](https://clickhouse.tech/docs/en/interfaces/third-party/client_libraries/) diff --git a/docs/es/interfaces/third-party/gui.md b/docs/es/interfaces/third-party/gui.md index 9ad60291016..754c0f68c69 100644 --- a/docs/es/interfaces/third-party/gui.md +++ b/docs/es/interfaces/third-party/gui.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 28 toc_title: Interfaces Visuales --- @@ -23,7 +23,7 @@ Función: [Documentación de Tabix](https://tabix.io/doc/). -### Sistema abierto. {#houseops} +### Sistema abierto {#houseops} [Sistema abierto.](https://github.com/HouseOps/HouseOps) Es una interfaz de usuario / IDE para OSX, Linux y Windows. @@ -78,7 +78,7 @@ Función: - Vista previa de datos de tabla. - Búsqueda de texto completo. -### Sistema abierto. {#clickhouse-cli} +### Sistema abierto {#clickhouse-cli} [Sistema abierto.](https://github.com/hatarist/clickhouse-cli) es un cliente de línea de comandos alternativo para ClickHouse, escrito en Python 3. @@ -89,10 +89,14 @@ Función: - Soporte de buscapersonas para la salida de datos. - Comandos similares a PostgreSQL personalizados. -### Sistema abierto. {#clickhouse-flamegraph} +### Sistema abierto {#clickhouse-flamegraph} [Sistema abierto.](https://github.com/Slach/clickhouse-flamegraph) es una herramienta especializada para visualizar el `system.trace_log` como [Flamegraph](http://www.brendangregg.com/flamegraphs.html). +### Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica {#clickhouse-plantuml} + +[Método de codificación de datos:](https://pypi.org/project/clickhouse-plantuml/) es un script para generar [PlantUML](https://plantuml.com/) diagrama de esquemas de tablas. + ## Comercial {#commercial} ### DataGrip {#datagrip} diff --git a/docs/es/interfaces/third-party/index.md b/docs/es/interfaces/third-party/index.md index 821867a3ca7..adf50b05cdf 100644 --- a/docs/es/interfaces/third-party/index.md +++ b/docs/es/interfaces/third-party/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Third-Party +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: tercero toc_priority: 24 --- diff --git a/docs/es/interfaces/third-party/integrations.md b/docs/es/interfaces/third-party/integrations.md index d706278a280..716e774871b 100644 --- a/docs/es/interfaces/third-party/integrations.md +++ b/docs/es/interfaces/third-party/integrations.md @@ -1,102 +1,101 @@ --- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa toc_priority: 27 -toc_title: "Integraci\xF3n" +toc_title: Integrations --- -# Bibliotecas de integración de desarrolladores externos {#integration-libraries-from-third-party-developers} +# Integration Libraries from Third-party Developers {#integration-libraries-from-third-party-developers} -!!! warning "Descargo" - Yandex hace **ni** mantenga las herramientas y bibliotecas que se enumeran a continuación y no haya realizado ninguna prueba extensa para garantizar su calidad. +!!! warning "Disclaimer" + Yandex does **not** maintain the tools and libraries listed below and haven’t done any extensive testing to ensure their quality. -## Productos de infraestructura {#infrastructure-products} +## Infrastructure Products {#infrastructure-products} -- Sistemas de gestión de bases de datos relacionales +- Relational database management systems - [MySQL](https://www.mysql.com) - - [Nombre de la red inalámbrica (SSID):](https://github.com/sysown/proxysql/wiki/ClickHouse-Support) - - [Casa de clic-mysql-lector de datos](https://github.com/Altinity/clickhouse-mysql-data-reader) - - [Horgh-replicador](https://github.com/larsnovikov/horgh-replicator) + - [ProxySQL](https://github.com/sysown/proxysql/wiki/ClickHouse-Support) + - [clickhouse-mysql-data-reader](https://github.com/Altinity/clickhouse-mysql-data-reader) + - [horgh-replicator](https://github.com/larsnovikov/horgh-replicator) - [PostgreSQL](https://www.postgresql.org) - - [Haga clickhousedb\_fdw](https://github.com/Percona-Lab/clickhousedb_fdw) - - [InformaciónSistema abierto.](https://github.com/Infinidat/infi.clickhouse_fdw) (utilizar [InformaciónSistema abierto.](https://github.com/Infinidat/infi.clickhouse_orm)) - - [Descripción](https://github.com/mkabilov/pg2ch) - - [Sistema abierto.](https://github.com/adjust/clickhouse_fdw) + - [clickhousedb\_fdw](https://github.com/Percona-Lab/clickhousedb_fdw) + - [infi.clickhouse\_fdw](https://github.com/Infinidat/infi.clickhouse_fdw) (uses [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm)) + - [pg2ch](https://github.com/mkabilov/pg2ch) + - [clickhouse\_fdw](https://github.com/adjust/clickhouse_fdw) - [MSSQL](https://en.wikipedia.org/wiki/Microsoft_SQL_Server) - - [Método de codificación de datos:](https://github.com/zlzforever/ClickHouseMigrator) -- Colas de mensajes + - [ClickHouseMigrator](https://github.com/zlzforever/ClickHouseMigrator) +- Message queues - [Kafka](https://kafka.apache.org) - - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (usos [Go client](https://github.com/ClickHouse/clickhouse-go/)) -- Procesamiento de flujo + - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (uses [Go client](https://github.com/ClickHouse/clickhouse-go/)) + - [stream-loader-clickhouse](https://github.com/adform/stream-loader) +- Stream processing - [Flink](https://flink.apache.org) - [flink-clickhouse-sink](https://github.com/ivi-ru/flink-clickhouse-sink) -- Almacenamiento de objetos +- Object storages - [S3](https://en.wikipedia.org/wiki/Amazon_S3) - - [Haga clic en el botón de copia de seguridad](https://github.com/AlexAkulov/clickhouse-backup) -- Orquestación de contenedores + - [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup) +- Container orchestration - [Kubernetes](https://kubernetes.io) - - [Operador de clickhouse](https://github.com/Altinity/clickhouse-operator) -- Gestión de configuración - - [marioneta](https://puppet.com) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://forge.puppet.com/innogames/clickhouse) - - [Sistema abierto.](https://forge.puppet.com/mfedotov/clickhouse) -- Monitoreo - - [Grafito](https://graphiteapp.org) + - [clickhouse-operator](https://github.com/Altinity/clickhouse-operator) +- Configuration management + - [puppet](https://puppet.com) + - [innogames/clickhouse](https://forge.puppet.com/innogames/clickhouse) + - [mfedotov/clickhouse](https://forge.puppet.com/mfedotov/clickhouse) +- Monitoring + - [Graphite](https://graphiteapp.org) - [graphouse](https://github.com/yandex/graphouse) - - [de carbono-clickhouse](https://github.com/lomik/carbon-clickhouse) + - - [Sistema abierto.](https://github.com/lomik/graphite-clickhouse) - - [Grafito-ch-optimizador](https://github.com/innogames/graphite-ch-optimizer) - optimiza las particiones [\*GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md#graphitemergetree) reglas de [Configuración de rollup](../../engines/table_engines/mergetree_family/graphitemergetree.md#rollup-configuration) podría ser aplicado + - [carbon-clickhouse](https://github.com/lomik/carbon-clickhouse) + + - [graphite-clickhouse](https://github.com/lomik/graphite-clickhouse) + - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - optimizes staled partitions in [\*GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md#graphitemergetree) if rules from [rollup configuration](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) could be applied - [Grafana](https://grafana.com/) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/Vertamedia/clickhouse-grafana) - - [Prometeo](https://prometheus.io/) - - [Sistema abierto.](https://github.com/f1yegor/clickhouse_exporter) - - [Bienvenido](https://github.com/Percona-Lab/PromHouse) - - [Sistema abierto.](https://github.com/hot-wifi/clickhouse_exporter) (utilizar [Ir cliente](https://github.com/kshvakov/clickhouse/)) + - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) + - [Prometheus](https://prometheus.io/) + - [clickhouse\_exporter](https://github.com/f1yegor/clickhouse_exporter) + - [PromHouse](https://github.com/Percona-Lab/PromHouse) + - [clickhouse\_exporter](https://github.com/hot-wifi/clickhouse_exporter) (uses [Go client](https://github.com/kshvakov/clickhouse/)) - [Nagios](https://www.nagios.org/) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/exogroup/check_clickhouse/) - - [Inicio](https://github.com/innogames/igmonplugins/blob/master/src/check_clickhouse.py) + - [check\_clickhouse](https://github.com/exogroup/check_clickhouse/) + - [check\_clickhouse.py](https://github.com/innogames/igmonplugins/blob/master/src/check_clickhouse.py) - [Zabbix](https://www.zabbix.com) - - [Sistema abierto.](https://github.com/Altinity/clickhouse-zabbix-template) + - [clickhouse-zabbix-template](https://github.com/Altinity/clickhouse-zabbix-template) - [Sematext](https://sematext.com/) - - [integración clickhouse](https://github.com/sematext/sematext-agent-integrations/tree/master/clickhouse) -- Tala + - [clickhouse integration](https://github.com/sematext/sematext-agent-integrations/tree/master/clickhouse) +- Logging - [rsyslog](https://www.rsyslog.com/) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://www.rsyslog.com/doc/master/configuration/modules/omclickhouse.html) + - [omclickhouse](https://www.rsyslog.com/doc/master/configuration/modules/omclickhouse.html) - [fluentd](https://www.fluentd.org) - - [casa de campo](https://github.com/flant/loghouse) (para [Kubernetes](https://kubernetes.io)) - - [Información](https://www.sematext.com/logagent) - - [Sistema de tabiquería interior y exterior](https://sematext.com/docs/logagent/output-plugin-clickhouse/) + - [loghouse](https://github.com/flant/loghouse) (for [Kubernetes](https://kubernetes.io)) + - [logagent](https://www.sematext.com/logagent) + - [logagent output-plugin-clickhouse](https://sematext.com/docs/logagent/output-plugin-clickhouse/) - Geo - [MaxMind](https://dev.maxmind.com/geoip/) - - [Para que usted pueda encontrar](https://github.com/AlexeyKupershtokh/clickhouse-maxmind-geoip) + - [clickhouse-maxmind-geoip](https://github.com/AlexeyKupershtokh/clickhouse-maxmind-geoip) -## Programación de ecosistemas de lenguaje {#programming-language-ecosystems} +## Programming Language Ecosystems {#programming-language-ecosystems} -- Película +- Python - [SQLAlchemy](https://www.sqlalchemy.org) - - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (utilizar [InformaciónSistema abierto.](https://github.com/Infinidat/infi.clickhouse_orm)) + - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (uses [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - [pandas](https://pandas.pydata.org) - - [Pandahouse](https://github.com/kszucs/pandahouse) -- PHP + - [pandahouse](https://github.com/kszucs/pandahouse) +- PHP - [Doctrine](https://www.doctrine-project.org/) - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) - R - - [Dplyr](https://db.rstudio.com/dplyr/) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/IMSMWU/RClickhouse) (utilizar [Bienvenidos](https://github.com/artpaul/clickhouse-cpp)) + - [dplyr](https://db.rstudio.com/dplyr/) + - [RClickHouse](https://github.com/IMSMWU/RClickHouse) (uses [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) - Java - [Hadoop](http://hadoop.apache.org) - - [Sistema abierto.](https://github.com/jaykelin/clickhouse-hdfs-loader) (utilizar [JDBC](../../sql_reference/table_functions/jdbc.md)) -- Ciudad + - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (uses [JDBC](../../sql-reference/table-functions/jdbc.md)) +- Scala - [Akka](https://akka.io) - - [Sistema abierto.](https://github.com/crobox/clickhouse-scala-client) + - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) - C\# - [ADO.NET](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview) - - [Sistema abierto.Ado](https://github.com/killwort/ClickHouse-Net) - - [Sistema abierto.Cliente](https://github.com/DarkWanderer/ClickHouse.Client) - - [Sistema abierto.](https://github.com/ilyabreev/ClickHouse.Net) - - [Bienvenidos al Portal de Licitación Electrónica de Licitación Electrónica](https://github.com/ilyabreev/ClickHouse.Net.Migrations) + - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) + - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) + - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) + - [ClickHouse.Net.Migrations](https://github.com/ilyabreev/ClickHouse.Net.Migrations) - Elixir - [Ecto](https://github.com/elixir-ecto/ecto) - - [Método de codificación de datos:](https://github.com/appodeal/clickhouse_ecto) + - [clickhouse\_ecto](https://github.com/appodeal/clickhouse_ecto) -[Artículo Original](https://clickhouse.tech/docs/en/interfaces/third-party/integrations/) +[Original article](https://clickhouse.tech/docs/en/interfaces/third-party/integrations/) diff --git a/docs/es/interfaces/third-party/proxy.md b/docs/es/interfaces/third-party/proxy.md index 6c83d97a747..e1aabf8fce4 100644 --- a/docs/es/interfaces/third-party/proxy.md +++ b/docs/es/interfaces/third-party/proxy.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 29 toc_title: Proxy --- @@ -19,7 +19,7 @@ Función: Implementado en Go. -## Bienvenido a WordPress. {#kittenhouse} +## Bienvenido a WordPress {#kittenhouse} [Bienvenido a WordPress.](https://github.com/VKCOM/kittenhouse) está diseñado para ser un proxy local entre ClickHouse y el servidor de aplicaciones en caso de que sea imposible o inconveniente almacenar los datos INSERT en el lado de su aplicación. diff --git a/docs/es/introduction/adopters.md b/docs/es/introduction/adopters.md index 822946a421b..e41e8005cc7 100644 --- a/docs/es/introduction/adopters.md +++ b/docs/es/introduction/adopters.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 8 toc_title: Adoptante --- @@ -10,73 +10,77 @@ toc_title: Adoptante !!! warning "Descargo" La siguiente lista de empresas que utilizan ClickHouse y sus historias de éxito se recopila a partir de fuentes públicas, por lo que podría diferir de la realidad actual. Le agradeceríamos que compartiera la historia de adoptar ClickHouse en su empresa y [agregarlo a la lista](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/introduction/adopters.md), pero por favor asegúrese de que usted no tendrá ningunos problemas de NDA haciendo así. Proporcionar actualizaciones con publicaciones de otras compañías también es útil. -| Empresa | Industria | Usecase | Tamaño de clúster | (Un)Tamaño de datos comprimidos\* | Referencia | -|--------------------------------------------------------------------------------------------|------------------------------------|-----------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [2gis](https://2gis.ru) | Asignar | Monitoreo | — | — | [Charla en ruso, julio 2019](https://youtu.be/58sPkXfq6nw) | -| [Navegador Aloha](https://alohabrowser.com/) | Aplicación móvil | Backend del navegador | — | — | [Diapositivas en ruso, mayo 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | -| [Amadeus](https://amadeus.com/) | Viaje | Analítica | — | — | [Comunicado de prensa, abril de 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | -| [Appsflyer](https://www.appsflyer.com) | Análisis móvil | Producto principal | — | — | [Charla en ruso, julio 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | -| [ArenaData](https://arenadata.tech/) | Plataforma de datos | Producto principal | — | — | [Diapositivas en ruso, diciembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | -| [Badoo](https://badoo.com) | Citas | Serie de tiempo | — | — | [Diapositivas en ruso, diciembre 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | -| [Benocs](https://www.benocs.com/) | Telemetría y análisis de red | Producto principal | — | — | [Diapositivas en español, octubre de 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | -| [Bloomberg](https://www.bloomberg.com/) | Finanzas, Medios | Monitoreo | 102 servidores | — | [Diapositivas, Mayo 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | -| [Bloxy](https://bloxy.info) | Blockchain | Analítica | — | — | [Diapositivas en ruso, agosto 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | -| `Dataliance/UltraPower` | Telecomunicaciones | Analítica | — | — | [Diapositivas en chino, enero 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | -| [CARTO](https://carto.com/) | Inteligencia de negocios | Análisis geográfico | — | — | [Procesamiento geoespacial con Clickhouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | -| [CERN](http://public.web.cern.ch/public/) | Investigación | Experimento | — | — | [Comunicado de prensa, abril de 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | -| [Cisco](http://cisco.com/) | Red | Análisis de tráfico | — | — | [Charla relámpago, octubre 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | -| [Valores de la ciudadela](https://www.citadelsecurities.com/) | Financiación | — | — | — | [Contribución, marzo 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | -| [Más información](https://city-mobil.ru) | Taxi | Analítica | — | — | [Blog Post en ruso, marzo 2020](https://habr.com/en/company/citymobil/blog/490660/) | -| [ContentSquare](https://contentsquare.com) | Análisis web | Producto principal | — | — | [Publicación de blog en francés, noviembre 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | -| [Cloudflare](https://cloudflare.com) | CDN | Análisis de tráfico | 36 servidores | — | [Mensaje del blog, Mayo 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Mensaje del blog, marzo 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | -| [Corunet](https://coru.net/) | Analítica | Producto principal | — | — | [Diapositivas en español, Abril 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | -| [CraiditX 氪信](https://creditx.com) | Finanzas AI | Análisis | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | -| [Criteo/Storetail](https://www.criteo.com/) | Menor | Producto principal | — | — | [Diapositivas en español, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | -| [Banco de Deutsche](https://db.com) | Financiación | BI Analytics | — | — | [Diapositivas en español, octubre 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | -| [Diva-e](https://www.diva-e.com) | Consultoría digital | Producto principal | — | — | [Diapositivas en español, septiembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | -| [Exness](https://www.exness.com) | Comercio | Métricas, Registro | — | — | [Charla en ruso, mayo 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | -| [Sistema abierto.](https://geniee.co.jp) | Red Ad | Producto principal | — | — | [Publicación de blog en japonés, julio 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | -| [HUYA](https://www.huya.com/) | Video Streaming | Analítica | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | -| [Idealista](https://www.idealista.com) | Inmobiliario | Analítica | — | — | [Blog Post en Inglés, Abril 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | -| [Infovista](https://www.infovista.com/) | Red | Analítica | — | — | [Diapositivas en español, octubre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | -| [InnoGames](https://www.innogames.com) | Juego | Métricas, Registro | — | — | [Diapositivas en ruso, septiembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | -| [Integros](https://integros.com) | Plataforma para servicios de video | Analítica | — | — | [Diapositivas en ruso, mayo 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Datos de Kodiak](https://www.kodiakdata.com/) | Nube | Producto principal | — | — | [Diapositivas en Engish, Abril 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | -| [Kontur](https://kontur.ru) | Desarrollo de software | Métricas | — | — | [Charla en ruso, noviembre 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | -| [Sistema abierto.](https://lifestreet.com/) | Red Ad | Producto principal | 75 servidores (3 réplicas) | 5.27 PiB | [Publicación de blog en ruso, febrero 2017](https://habr.com/en/post/322620/) | -| [Soluciones en la nube de Mail.ru](https://mcs.mail.ru/) | Servicios en la nube | Producto principal | — | — | [Ejecución de ClickHouse Instance, en ruso](https://mcs.mail.ru/help/db-create/clickhouse#) | -| [Mensaje de pájaro](https://www.messagebird.com) | Telecomunicaciones | Estadísticas | — | — | [Diapositivas en español, noviembre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | -| [MGID](https://www.mgid.com/) | Red Ad | Analítica Web | — | — | [Nuestra experiencia en la implementación analítica DBMS ClickHouse, en ruso](http://gs-studio.com/news-about-it/32777----clickhouse---c) | -| [UnoAPM](https://www.oneapm.com/) | Supervisión y análisis de datos | Producto principal | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | -| [Pragma Innovación](http://www.pragma-innovation.fr/) | Telemetría y Análisis de Big Data | Producto principal | — | — | [Diapositivas en español, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | -| [QINGCLOUD](https://www.qingcloud.com/) | Servicios en la nube | Producto principal | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | -| [Qrator](https://qrator.net) | Protección DDoS | Producto principal | — | — | [Blog Post, marzo 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | -| [Tecnología de la información del PORCIMIENTO de Pekín Co., Ltd.](https://www.percent.cn/) | Analítica | Producto principal | — | — | [Diapositivas en chino, junio 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | -| [Rambler](https://rambler.ru) | Servicios de Internet | Analítica | — | — | [Charla en ruso, abril 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | -| [Tencent](https://www.tencent.com) | Mensajería | Tala | — | — | [Charla en chino, noviembre 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | -| [Estrellas de tráfico](https://trafficstars.com/) | Red AD | — | — | — | [Diapositivas en ruso, mayo 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | -| [S7 Aerolíneas](https://www.s7.ru) | Aérea | Métricas, Registro | — | — | [Charla en ruso, marzo 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | -| [SEMrush](https://www.semrush.com/) | Marketing | Producto principal | — | — | [Diapositivas en ruso, agosto 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | -| [Inicio](https://www.scireum.de/) | Comercio electrónico | Producto principal | — | — | [Charla en alemán, febrero de 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | -| [Centinela](https://sentry.io/) | Desarrollador de software | Backend para el producto | — | — | [Publicación de blog en inglés, mayo 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | -| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr) | Gobierno Seguridad Social | Analítica | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | -| [el seo.¿](https://seo.do/) | Analítica | Producto principal | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | -| [Sina](http://english.sina.com/index.html) | Noticia | — | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | -| [SMI2](https://smi2.ru/) | Noticia | Analítica | — | — | [Blog Post en ruso, noviembre 2017](https://habr.com/ru/company/smi2/blog/314558/) | -| [Salto](https://www.splunk.com/) | Análisis de negocios | Producto principal | — | — | [Diapositivas en español, enero 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | -| [Spotify](https://www.spotify.com) | Sica | Experimentación | — | — | [Diapositivas, julio 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | -| [Tencent](https://www.tencent.com) | Grandes Datos | Procesamiento de datos | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | -| [Más información](https://www.uber.com) | Taxi | Tala | — | — | [Diapositivas, febrero de 2020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | -| [VKontakte](https://vk.com) | Red social | Estadísticas, Registro | — | — | [Diapositivas en ruso, agosto 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | -| [Método de codificación de datos:](https://wisebits.com/) | Soluciones de TI | Analítica | — | — | [Diapositivas en ruso, mayo 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Tecnología de Xiaoxin.](https://www.xiaoheiban.cn/) | Educación | Propósito común | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | -| [Ximalaya](https://www.ximalaya.com/) | Compartir audio | OLAP | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | -| [Nube de Yandex](https://cloud.yandex.ru/services/managed-clickhouse) | Nube pública | Producto principal | — | — | [Charla en ruso, diciembre 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | -| [Yandex DataLens](https://cloud.yandex.ru/services/datalens) | Inteligencia de negocios | Producto principal | — | — | [Diapositivas en ruso, diciembre 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | -| [Mercado de Yandex](https://market.yandex.ru/) | Comercio electrónico | Métricas, Registro | — | — | [Charla en ruso, enero 2019](https://youtu.be/_l1qP0DyBcA?t=478) | -| [Yandex Metrica](https://metrica.yandex.com) | Análisis web | Producto principal | 360 servidores en un clúster, 1862 servidores en un departamento | 66.41 PiB / 5.68 PiB | [Diapositivas, febrero de 2020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | -| [ЦВТ](https://htc-cs.ru/) | Desarrollo de software | Métricas, Registro | — | — | [Blog Post, marzo 2019, en ruso](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | -| [МКБ](https://mkb.ru/) | Banco | Supervisión del sistema web | — | — | [Diapositivas en ruso, septiembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | -| [金数据](https://jinshuju.net) | BI Analytics | Producto principal | — | — | [Diapositivas en chino, octubre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | +| Empresa | Industria | Usecase | Tamaño de clúster | (Un)Tamaño de datos comprimidos\* | Referencia | +|-------------------------------------------------------------------------------------------------|------------------------------------|-----------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 2gis | Asignar | Monitoreo | — | — | [Charla en ruso, julio 2019](https://youtu.be/58sPkXfq6nw) | +| Aloha Browser | Aplicación móvil | Backend del navegador | — | — | [Diapositivas en ruso, mayo 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | +| Amadeus | Viaje | Analítica | — | — | [Comunicado de prensa, abril de 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | +| Appsflyer | Análisis móvil | Producto principal | — | — | [Charla en ruso, julio 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | +| ArenaData | Plataforma de datos | Producto principal | — | — | [Diapositivas en ruso, diciembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | +| Badoo | Citas | Serie de tiempo | — | — | [Diapositivas en ruso, diciembre 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | +| Benocs | Telemetría y análisis de red | Producto principal | — | — | [Diapositivas en español, octubre de 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | +| Bloomberg | Finanzas, Medios | Monitoreo | 102 servidores | — | [Diapositivas, Mayo 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | +| Bloxy | Blockchain | Analítica | — | — | [Diapositivas en ruso, agosto 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | +| Dataliance para China Telecom | Telecomunicaciones | Analítica | — | — | [Diapositivas en chino, enero 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | +| CARTO | Inteligencia de negocios | Análisis geográfico | — | — | [Procesamiento geoespacial con ClickHouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | +| CERN | Investigación | Experimento | — | — | [Comunicado de prensa, abril de 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | +| Cisco | Red | Análisis de tráfico | — | — | [Charla relámpago, octubre 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | +| Citadel Securities | Financiación | — | — | — | [Contribución, marzo 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | +| Más información | Taxi | Analítica | — | — | [Blog Post en ruso, marzo 2020](https://habr.com/en/company/citymobil/blog/490660/) | +| ContentSquare | Análisis web | Producto principal | — | — | [Publicación de blog en francés, noviembre 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | +| Cloudflare | CDN | Análisis de tráfico | 36 servidores | — | [Mensaje del blog, Mayo 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Mensaje del blog, marzo 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | +| Corunet | Analítica | Producto principal | — | — | [Diapositivas en español, Abril 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | +| CraiditX 氪信 | Finanzas AI | Análisis | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | +| Criteo | Menor | Producto principal | — | — | [Diapositivas en español, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | +| Deutsche Bank | Financiación | BI Analytics | — | — | [Diapositivas en español, octubre 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | +| Diva-e | Consultoría digital | Producto principal | — | — | [Diapositivas en español, septiembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | +| Exness | Comercio | Métricas, Registro | — | — | [Charla en ruso, mayo 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | +| Sistema abierto. | Red Ad | Producto principal | — | — | [Publicación de blog en japonés, julio 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | +| HUYA | Video Streaming | Analítica | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | +| Idealista | Inmobiliario | Analítica | — | — | [Blog Post en Inglés, Abril 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | +| Infovista | Red | Analítica | — | — | [Diapositivas en español, octubre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | +| InnoGames | Juego | Métricas, Registro | — | — | [Diapositivas en ruso, septiembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | +| Integros | Plataforma para servicios de video | Analítica | — | — | [Diapositivas en ruso, mayo 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| Datos de Kodiak | Nube | Producto principal | — | — | [Diapositivas en Engish, Abril 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | +| Kontur | Desarrollo de software | Métricas | — | — | [Charla en ruso, noviembre 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | +| Sistema abierto. | Red Ad | Producto principal | 75 servidores (3 réplicas) | 5.27 PiB | [Publicación de blog en ruso, febrero 2017](https://habr.com/en/post/322620/) | +| Soluciones en la nube de Mail.ru | Servicios en la nube | Producto principal | — | — | [Artículo en ruso](https://mcs.mail.ru/help/db-create/clickhouse#) | +| Mensaje de pájaro | Telecomunicaciones | Estadísticas | — | — | [Diapositivas en español, noviembre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | +| MGID | Red Ad | Analítica Web | — | — | [Publicación de blog en ruso, abril 2020](http://gs-studio.com/news-about-it/32777----clickhouse---c) | +| UnoAPM | Supervisión y análisis de datos | Producto principal | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | +| Pragma Innovation | Telemetría y Análisis de Big Data | Producto principal | — | — | [Diapositivas en español, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | +| QINGCLOUD | Servicios en la nube | Producto principal | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | +| Qrator | Protección DDoS | Producto principal | — | — | [Blog Post, marzo 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | +| Percent 百分点 | Analítica | Producto principal | — | — | [Diapositivas en chino, junio 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | +| Rambler | Servicios de Internet | Analítica | — | — | [Charla en ruso, abril 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | +| Tencent | Mensajería | Tala | — | — | [Charla en chino, noviembre 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | +| Traffic Stars | Red AD | — | — | — | [Diapositivas en ruso, mayo 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | +| S7 Airlines | Aérea | Métricas, Registro | — | — | [Charla en ruso, marzo 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | +| SEMrush | Marketing | Producto principal | — | — | [Diapositivas en ruso, agosto 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | +| scireum GmbH | Comercio electrónico | Producto principal | — | — | [Charla en alemán, febrero de 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | +| Centinela | Desarrollador de software | Backend para el producto | — | — | [Publicación de blog en inglés, mayo 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | +| SGK | Gobierno Seguridad Social | Analítica | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | +| el seo.¿ | Analítica | Producto principal | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | +| Sina | Noticia | — | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | +| SMI2 | Noticia | Analítica | — | — | [Blog Post en ruso, noviembre 2017](https://habr.com/ru/company/smi2/blog/314558/) | +| Salto | Análisis de negocios | Producto principal | — | — | [Diapositivas en español, enero 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | +| Spotify | Sica | Experimentación | — | — | [Diapositivas, julio 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | +| Tencent | Grandes Datos | Procesamiento de datos | — | — | [Diapositivas en chino, octubre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | +| Más información | Taxi | Tala | — | — | [Diapositivas, febrero de 2020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | +| VKontakte | Red social | Estadísticas, Registro | — | — | [Diapositivas en ruso, agosto 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | +| Método de codificación de datos: | Soluciones de TI | Analítica | — | — | [Diapositivas en ruso, mayo 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| Xiaoxin Tech | Educación | Propósito común | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | +| Ximalaya | Compartir audio | OLAP | — | — | [Diapositivas en español, noviembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | +| Yandex Cloud | Nube pública | Producto principal | — | — | [Charla en ruso, diciembre 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | +| Yandex DataLens | Inteligencia de negocios | Producto principal | — | — | [Diapositivas en ruso, diciembre 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | +| Yandex Market | Comercio electrónico | Métricas, Registro | — | — | [Charla en ruso, enero 2019](https://youtu.be/_l1qP0DyBcA?t=478) | +| Yandex Metrica | Análisis web | Producto principal | 360 servidores en un clúster, 1862 servidores en un departamento | 66.41 PiB / 5.68 PiB | [Diapositivas, febrero de 2020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | +| ЦВТ | Desarrollo de software | Métricas, Registro | — | — | [Blog Post, marzo 2019, en ruso](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | +| МКБ | Banco | Supervisión del sistema web | — | — | [Diapositivas en ruso, septiembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | +| Jinshuju 金数据 | BI Analytics | Producto principal | — | — | [Diapositivas en chino, octubre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | +| Instana | Plataforma APM | Producto principal | — | — | [Publicación de Twitter](https://twitter.com/mieldonkers/status/1248884119158882304) | +| Wargaming | Juego | | — | — | [Entrevista](https://habr.com/en/post/496954/) | +| Crazypanda | Juego | | — | — | Sesión en vivo en ClickHouse meetup | +| FunCorp | Juego | | — | — | [Artículo](https://www.altinity.com/blog/migrating-from-redshift-to-clickhouse) | [Artículo Original](https://clickhouse.tech/docs/en/introduction/adopters/) diff --git a/docs/es/introduction/distinctive-features.md b/docs/es/introduction/distinctive-features.md new file mode 100644 index 00000000000..154b12a65e9 --- /dev/null +++ b/docs/es/introduction/distinctive-features.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 4 +toc_title: "Caracter\xEDsticas distintivas" +--- + +# Características distintivas de ClickHouse {#distinctive-features-of-clickhouse} + +## DBMS orientado a columnas verdaderas {#true-column-oriented-dbms} + +En un verdadero DBMS orientado a columnas, no se almacenan datos adicionales con los valores. Entre otras cosas, esto significa que los valores de longitud constante deben ser compatibles, para evitar almacenar su longitud “number” al lado de los valores. Como ejemplo, mil millones de valores de tipo UInt8 deberían consumir alrededor de 1 GB sin comprimir, o esto afecta fuertemente el uso de la CPU. Es esencial almacenar los datos de forma compacta (sin “garbage”) incluso sin comprimir, ya que la velocidad de descompresión (uso de CPU) depende principalmente del volumen de datos sin comprimir. + +Vale la pena señalar porque hay sistemas que pueden almacenar valores de diferentes columnas por separado, pero que no pueden procesar efectivamente las consultas analíticas debido a su optimización para otros escenarios. Los ejemplos son HBase, BigTable, Cassandra e HyperTable. En estos sistemas, obtendría un rendimiento de alrededor de cien mil filas por segundo, pero no cientos de millones de filas por segundo. + +También vale la pena señalar que ClickHouse es un sistema de administración de bases de datos, no una sola base de datos. ClickHouse permite crear tablas y bases de datos en tiempo de ejecución, cargar datos y ejecutar consultas sin volver a configurar y reiniciar el servidor. + +## Compresión de datos {#data-compression} + +Algunos DBMS orientados a columnas (InfiniDB CE y MonetDB) no utilizan la compresión de datos. Sin embargo, la compresión de datos juega un papel clave para lograr un rendimiento excelente. + +## Almacenamiento en disco de datos {#disk-storage-of-data} + +Mantener los datos físicamente ordenados por clave principal permite extraer datos para sus valores específicos o rangos de valores con baja latencia, menos de unas pocas docenas de milisegundos. Algunos DBMS orientados a columnas (como SAP HANA y Google PowerDrill) solo pueden funcionar en RAM. Este enfoque fomenta la asignación de un presupuesto de hardware más grande que el necesario para el análisis en tiempo real. ClickHouse está diseñado para funcionar en discos duros normales, lo que significa que el costo por GB de almacenamiento de datos es bajo, pero SSD y RAM adicional también se utilizan completamente si están disponibles. + +## Procesamiento paralelo en varios núcleos {#parallel-processing-on-multiple-cores} + +Las consultas grandes se paralelizan naturalmente, tomando todos los recursos necesarios disponibles en el servidor actual. + +## Procesamiento distribuido en varios servidores {#distributed-processing-on-multiple-servers} + +Casi ninguno de los DBMS columnar mencionados anteriormente tiene soporte para el procesamiento de consultas distribuidas. +En ClickHouse, los datos pueden residir en diferentes fragmentos. Cada fragmento puede ser un grupo de réplicas utilizadas para la tolerancia a errores. Todos los fragmentos se utilizan para ejecutar una consulta en paralelo, de forma transparente para el usuario. + +## Soporte SQL {#sql-support} + +ClickHouse admite un lenguaje de consulta declarativo basado en SQL que es idéntico al estándar SQL en muchos casos. +Las consultas admitidas incluyen GROUP BY, ORDER BY, subconsultas en cláusulas FROM, IN y JOIN y subconsultas escalares. +No se admiten subconsultas y funciones de ventana dependientes. + +## Motor del vector {#vector-engine} + +Los datos no solo se almacenan mediante columnas, sino que se procesan mediante vectores (partes de columnas), lo que permite lograr una alta eficiencia de CPU. + +## Actualizaciones de datos en tiempo real {#real-time-data-updates} + +ClickHouse admite tablas con una clave principal. Para realizar consultas rápidamente en el rango de la clave principal, los datos se ordenan de forma incremental utilizando el árbol de combinación. Debido a esto, los datos se pueden agregar continuamente a la tabla. No se toman bloqueos cuando se ingieren nuevos datos. + +## Indice {#index} + +Tener un dato ordenado físicamente por clave principal permite extraer datos para sus valores específicos o rangos de valores con baja latencia, menos de unas pocas docenas de milisegundos. + +## Adecuado para consultas en línea {#suitable-for-online-queries} + +La baja latencia significa que las consultas se pueden procesar sin demora y sin intentar preparar una respuesta por adelantado, justo en el mismo momento mientras se carga la página de la interfaz de usuario. En otras palabras, en línea. + +## Soporte para cálculos aproximados {#support-for-approximated-calculations} + +ClickHouse proporciona varias formas de intercambiar precisión por rendimiento: + +1. Funciones agregadas para el cálculo aproximado del número de valores distintos, medianas y cuantiles. +2. Ejecutar una consulta basada en una parte (muestra) de datos y obtener un resultado aproximado. En este caso, se recuperan proporcionalmente menos datos del disco. +3. Ejecutar una agregación para un número limitado de claves aleatorias, en lugar de para todas las claves. Bajo ciertas condiciones para la distribución de claves en los datos, esto proporciona un resultado razonablemente preciso mientras se utilizan menos recursos. + +## Replicación de datos e integridad de datos {#data-replication-and-data-integrity-support} + +ClickHouse utiliza la replicación multi-maestro asincrónica. Después de escribir en cualquier réplica disponible, todas las réplicas restantes recuperan su copia en segundo plano. El sistema mantiene datos idénticos en diferentes réplicas. La recuperación después de la mayoría de las fallas se realiza automáticamente, o semiautomáticamente en casos complejos. + +Para obtener más información, consulte la sección [Replicación de datos](../engines/table-engines/mergetree-family/replication.md). + +## Características que pueden considerarse desventajas {#clickhouse-features-that-can-be-considered-disadvantages} + +1. No hay transacciones completas. +2. Falta de capacidad para modificar o eliminar datos ya insertados con alta tasa y baja latencia. Hay eliminaciones y actualizaciones por lotes disponibles para limpiar o modificar datos, por ejemplo, para cumplir con [GDPR](https://gdpr-info.eu). +3. El índice disperso hace que ClickHouse no sea tan adecuado para consultas de puntos que recuperan filas individuales por sus claves. + +[Artículo Original](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/es/introduction/distinctive_features.md b/docs/es/introduction/distinctive_features.md deleted file mode 100644 index 82b757341be..00000000000 --- a/docs/es/introduction/distinctive_features.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 4 -toc_title: "Caracter\xEDsticas distintivas" ---- - -# Características distintivas de ClickHouse {#distinctive-features-of-clickhouse} - -## DBMS orientado a columnas verdaderas {#true-column-oriented-dbms} - -En un verdadero DBMS orientado a columnas, no se almacenan datos adicionales con los valores. Entre otras cosas, esto significa que los valores de longitud constante deben ser compatibles, para evitar almacenar su longitud “number” al lado de los valores. Como ejemplo, mil millones de valores de tipo UInt8 deberían consumir alrededor de 1 GB sin comprimir, o esto afecta fuertemente el uso de la CPU. Es esencial almacenar los datos de forma compacta (sin “garbage”) incluso sin comprimir, ya que la velocidad de descompresión (uso de CPU) depende principalmente del volumen de datos sin comprimir. - -Vale la pena señalar porque hay sistemas que pueden almacenar valores de diferentes columnas por separado, pero que no pueden procesar efectivamente las consultas analíticas debido a su optimización para otros escenarios. Los ejemplos son HBase, BigTable, Cassandra e HyperTable. En estos sistemas, obtendría un rendimiento de alrededor de cien mil filas por segundo, pero no cientos de millones de filas por segundo. - -También vale la pena señalar que ClickHouse es un sistema de administración de bases de datos, no una sola base de datos. ClickHouse permite crear tablas y bases de datos en tiempo de ejecución, cargar datos y ejecutar consultas sin volver a configurar y reiniciar el servidor. - -## Compresión de datos {#data-compression} - -Algunos DBMS orientados a columnas (InfiniDB CE y MonetDB) no utilizan la compresión de datos. Sin embargo, la compresión de datos juega un papel clave para lograr un rendimiento excelente. - -## Almacenamiento en disco de datos {#disk-storage-of-data} - -Mantener los datos físicamente ordenados por clave principal permite extraer datos para sus valores específicos o rangos de valores con baja latencia, menos de unas pocas docenas de milisegundos. Algunos DBMS orientados a columnas (como SAP HANA y Google PowerDrill) solo pueden funcionar en RAM. Este enfoque fomenta la asignación de un presupuesto de hardware más grande que el necesario para el análisis en tiempo real. ClickHouse está diseñado para funcionar en discos duros normales, lo que significa que el costo por GB de almacenamiento de datos es bajo, pero SSD y RAM adicional también se utilizan completamente si están disponibles. - -## Procesamiento paralelo en varios núcleos {#parallel-processing-on-multiple-cores} - -Las consultas grandes se paralelizan naturalmente, tomando todos los recursos necesarios disponibles en el servidor actual. - -## Procesamiento distribuido en varios servidores {#distributed-processing-on-multiple-servers} - -Casi ninguno de los DBMS columnar mencionados anteriormente tiene soporte para el procesamiento de consultas distribuidas. -En ClickHouse, los datos pueden residir en diferentes fragmentos. Cada fragmento puede ser un grupo de réplicas utilizadas para la tolerancia a errores. Todos los fragmentos se utilizan para ejecutar una consulta en paralelo, de forma transparente para el usuario. - -## Soporte SQL {#sql-support} - -ClickHouse admite un lenguaje de consulta declarativo basado en SQL que es idéntico al estándar SQL en muchos casos. -Las consultas admitidas incluyen GROUP BY, ORDER BY, subconsultas en cláusulas FROM, IN y JOIN y subconsultas escalares. -No se admiten subconsultas y funciones de ventana dependientes. - -## Motor del vector {#vector-engine} - -Los datos no solo se almacenan mediante columnas, sino que se procesan mediante vectores (partes de columnas), lo que permite lograr una alta eficiencia de CPU. - -## Actualizaciones de datos en tiempo real {#real-time-data-updates} - -ClickHouse admite tablas con una clave principal. Para realizar consultas rápidamente en el rango de la clave principal, los datos se ordenan de forma incremental utilizando el árbol de combinación. Debido a esto, los datos se pueden agregar continuamente a la tabla. No se toman bloqueos cuando se ingieren nuevos datos. - -## Indice {#index} - -Tener un dato ordenado físicamente por clave principal permite extraer datos para sus valores específicos o rangos de valores con baja latencia, menos de unas pocas docenas de milisegundos. - -## Adecuado para consultas en línea {#suitable-for-online-queries} - -La baja latencia significa que las consultas se pueden procesar sin demora y sin intentar preparar una respuesta por adelantado, justo en el mismo momento mientras se carga la página de la interfaz de usuario. En otras palabras, en línea. - -## Soporte para cálculos aproximados {#support-for-approximated-calculations} - -ClickHouse proporciona varias formas de intercambiar precisión por rendimiento: - -1. Funciones agregadas para el cálculo aproximado del número de valores distintos, medianas y cuantiles. -2. Ejecutar una consulta basada en una parte (muestra) de datos y obtener un resultado aproximado. En este caso, se recuperan proporcionalmente menos datos del disco. -3. Ejecutar una agregación para un número limitado de claves aleatorias, en lugar de para todas las claves. Bajo ciertas condiciones para la distribución de claves en los datos, esto proporciona un resultado razonablemente preciso mientras se utilizan menos recursos. - -## Replicación de datos y soporte de integridad de datos {#data-replication-and-data-integrity-support} - -ClickHouse utiliza la replicación multi-maestro asincrónica. Después de escribir en cualquier réplica disponible, todas las réplicas restantes recuperan su copia en segundo plano. El sistema mantiene datos idénticos en diferentes réplicas. La recuperación después de la mayoría de las fallas se realiza automáticamente, o semiautomáticamente en casos complejos. - -Para obtener más información, consulte la sección [Replicación de datos](../engines/table_engines/mergetree_family/replication.md). - -## Características que pueden considerarse desventajas {#clickhouse-features-that-can-be-considered-disadvantages} - -1. No hay transacciones completas. -2. Falta de capacidad para modificar o eliminar datos ya insertados con alta tasa y baja latencia. Hay eliminaciones y actualizaciones por lotes disponibles para limpiar o modificar datos, por ejemplo, para cumplir con [GDPR](https://gdpr-info.eu). -3. El índice disperso hace que ClickHouse no sea tan adecuado para consultas de puntos que recuperan filas individuales por sus claves. - -[Artículo Original](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/es/introduction/history.md b/docs/es/introduction/history.md index d4a6b826822..7311fa01959 100644 --- a/docs/es/introduction/history.md +++ b/docs/es/introduction/history.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 7 toc_title: Historia --- diff --git a/docs/es/introduction/index.md b/docs/es/introduction/index.md index 4488eeed6fc..7026dc800e4 100644 --- a/docs/es/introduction/index.md +++ b/docs/es/introduction/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Introduction +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Implantaci\xF3n" toc_priority: 1 --- diff --git a/docs/es/introduction/performance.md b/docs/es/introduction/performance.md index ad992dd13d6..01640439128 100644 --- a/docs/es/introduction/performance.md +++ b/docs/es/introduction/performance.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 6 toc_title: Rendimiento --- diff --git a/docs/es/operations/access-rights.md b/docs/es/operations/access-rights.md new file mode 100644 index 00000000000..5f00dc901d8 --- /dev/null +++ b/docs/es/operations/access-rights.md @@ -0,0 +1,143 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: "Control de acceso y gesti\xF3n de cuentas" +--- + +# Control de acceso y gestión de cuentas {#access-control} + +ClickHouse admite la administración de control de acceso basada en [RBAC](https://en.wikipedia.org/wiki/Role-based_access_control) enfoque. + +Entidades de acceso de ClickHouse: +- [Cuenta de usuario](#user-account-management) +- [Rol](#role-management) +- [Política de fila](#row-policy-management) +- [Perfil de configuración](#settings-profiles-management) +- [Cuota](#quotas-management) + +Puede configurar entidades de acceso utilizando: + +- Flujo de trabajo controlado por SQL. + + Es necesario [permitir](#enabling-access-control) esta funcionalidad. + +- Servidor [archivos de configuración](configuration-files.md) `users.xml` y `config.xml`. + +Se recomienda utilizar el flujo de trabajo controlado por SQL. Ambos métodos de configuración funcionan simultáneamente, por lo que si utiliza los archivos de configuración del servidor para administrar cuentas y derechos de acceso, puede pasar suavemente al flujo de trabajo controlado por SQL. + +!!! note "Advertencia" + No puede administrar la misma entidad de acceso mediante ambos métodos de configuración simultáneamente. + +## Uso {#access-control-usage} + +De forma predeterminada, el servidor ClickHouse proporciona la cuenta de usuario `default` que no está permitido usar control de acceso controlado por SQL y administración de cuentas, pero tiene todos los derechos y permisos. El `default` cuenta de usuario se utiliza en cualquier caso cuando el nombre de usuario no está definido, por ejemplo, al iniciar sesión desde el cliente o en consultas distribuidas. En el procesamiento de consultas distribuidas se utiliza una cuenta de usuario predeterminada, si la configuración del servidor o clúster no [usuario y contraseña](../engines/table-engines/special/distributed.md) propiedad. + +Si acaba de comenzar a usar ClickHouse, puede usar el siguiente escenario: + +1. [Permitir](#enabling-access-control) Control de acceso basado en SQL y gestión de cuentas `default` usuario. +2. Inicie sesión bajo el `default` cuenta de usuario y crear todos los usuarios. No olvides crear una cuenta de administrador (`GRANT ALL ON *.* WITH GRANT OPTION TO admin_user_account`). +3. [Restringir permisos](settings/permissions-for-queries.md#permissions_for_queries) para el `default` usuario y deshabilitar el control de acceso impulsado por SQL y la administración de cuentas para ello. + +### Propiedades de la solución actual {#access-control-properties} + +- Puede conceder permisos para bases de datos y tablas incluso si no existen. +- Si se eliminó una tabla, no se revocarán todos los privilegios que corresponden a esta tabla. Por lo tanto, si se crea una nueva tabla más tarde con el mismo nombre, todos los privilegios vuelven a ser reales. Para revocar los privilegios correspondientes a la tabla eliminada, debe realizar, por ejemplo, el `REVOKE ALL PRIVILEGES ON db.table FROM ALL` consulta. +- No hay ninguna configuración de por vida para los privilegios. + +## Cuenta de usuario {#user-account-management} + +Una cuenta de usuario es una entidad de acceso que permite autorizar a alguien en ClickHouse. Una cuenta de usuario contiene: + +- Información de identificación. +- [Privilegio](../sql-reference/statements/grant.md#grant-privileges) que definen un ámbito de consultas que el usuario puede realizar. +- Hosts desde los que se permite la conexión al servidor ClickHouse. +- Roles otorgados y predeterminados. +- Configuración con sus restricciones que se aplican de forma predeterminada en el inicio de sesión del usuario. +- Perfiles de configuración asignados. + +Los privilegios a una cuenta de usuario pueden ser otorgados por el [GRANT](../sql-reference/statements/grant.md) consulta o asignando [rol](#role-management). Para revocar privilegios de un usuario, ClickHouse proporciona el [REVOKE](../sql-reference/statements/revoke.md) consulta. Para listar los privilegios de un usuario, utilice - [SHOW GRANTS](../sql-reference/statements/show.md#show-grants-statement) instrucción. + +Consultas de gestión: + +- [CREATE USER](../sql-reference/statements/create.md#create-user-statement) +- [ALTER USER](../sql-reference/statements/alter.md#alter-user-statement) +- [DROP USER](../sql-reference/statements/misc.md#drop-user-statement) +- [SHOW CREATE USER](../sql-reference/statements/show.md#show-create-user-statement) + +### Ajustes Aplicación {#access-control-settings-applying} + +Los ajustes se pueden establecer de diferentes maneras: para una cuenta de usuario, en sus roles y perfiles de configuración concedidos. En un inicio de sesión de usuario, si se establece una configuración en diferentes entidades de acceso, el valor y las restricciones de esta configuración se aplican mediante las siguientes prioridades (de mayor a menor): + +1. Configuración de la cuenta de usuario. +2. La configuración de los roles predeterminados de la cuenta de usuario. Si se establece una configuración en algunos roles, el orden de la configuración que se aplica no está definido. +3. La configuración de los perfiles de configuración asignados a un usuario o a sus roles predeterminados. Si se establece una configuración en algunos perfiles, el orden de aplicación de la configuración no está definido. +4. Ajustes aplicados a todo el servidor de forma predeterminada o desde el [perfil predeterminado](server-configuration-parameters/settings.md#default-profile). + +## Rol {#role-management} + +Role es un contenedor para las entidades de acceso que se pueden conceder a una cuenta de usuario. + +El rol contiene: + +- [Privilegio](../sql-reference/statements/grant.md#grant-privileges) +- Configuración y restricciones +- Lista de funciones concedidas + +Consultas de gestión: + +- [CREATE ROLE](../sql-reference/statements/create.md#create-role-statement) +- [ALTER ROLE](../sql-reference/statements/alter.md#alter-role-statement) +- [DROP ROLE](../sql-reference/statements/misc.md#drop-role-statement) +- [SET ROLE](../sql-reference/statements/misc.md#set-role-statement) +- [SET DEFAULT ROLE](../sql-reference/statements/misc.md#set-default-role-statement) +- [SHOW CREATE ROLE](../sql-reference/statements/show.md#show-create-role-statement) + +Los privilegios a un rol pueden ser otorgados por el [GRANT](../sql-reference/statements/grant.md) consulta. Para revocar privilegios de un rol, ClickHouse proporciona el [REVOKE](../sql-reference/statements/revoke.md) consulta. + +## Política de fila {#row-policy-management} + +La directiva de filas es un filtro que define qué filas está disponible para un usuario o para un rol. La directiva de filas contiene filtros para una tabla específica y una lista de roles y/o usuarios que deben usar esta directiva de filas. + +Consultas de gestión: + +- [CREATE ROW POLICY](../sql-reference/statements/create.md#create-row-policy-statement) +- [ALTER ROW POLICY](../sql-reference/statements/alter.md#alter-row-policy-statement) +- [DROP ROW POLICY](../sql-reference/statements/misc.md#drop-row-policy-statement) +- [SHOW CREATE ROW POLICY](../sql-reference/statements/show.md#show-create-row-policy-statement) + +## Perfil de configuración {#settings-profiles-management} + +El perfil de configuración es una colección de [configuración](settings/index.md). El perfil de configuración contiene configuraciones y restricciones, y una lista de roles y/o usuarios a los que se aplica esta cuota. + +Consultas de gestión: + +- [CREATE SETTINGS PROFILE](../sql-reference/statements/create.md#create-settings-profile-statement) +- [ALTER SETTINGS PROFILE](../sql-reference/statements/alter.md#alter-settings-profile-statement) +- [DROP SETTINGS PROFILE](../sql-reference/statements/misc.md#drop-settings-profile-statement) +- [SHOW CREATE SETTINGS PROFILE](../sql-reference/statements/show.md#show-create-settings-profile-statement) + +## Cuota {#quotas-management} + +La cuota limita el uso de recursos. Ver [Cuota](quotas.md). + +La cuota contiene un conjunto de límites para algunas duraciones y una lista de roles y / o usuarios que deben usar esta cuota. + +Consultas de gestión: + +- [CREATE QUOTA](../sql-reference/statements/create.md#create-quota-statement) +- [ALTER QUOTA](../sql-reference/statements/alter.md#alter-quota-statement) +- [DROP QUOTA](../sql-reference/statements/misc.md#drop-quota-statement) +- [SHOW CREATE QUOTA](../sql-reference/statements/show.md#show-create-quota-statement) + +## Habilitación del control de acceso basado en SQL y la administración de cuentas {#enabling-access-control} + +- Configure un directorio para el almacenamiento de configuraciones. + + ClickHouse almacena las configuraciones de entidades de acceso en la carpeta [access\_control\_path](server-configuration-parameters/settings.md#access_control_path) parámetro de configuración del servidor. + +- Habilite el control de acceso controlado por SQL y la administración de cuentas para al menos una cuenta de usuario. + + De forma predeterminada, el control de acceso controlado por SQL y la administración de cuentas se activan para todos los usuarios. Debe configurar al menos un usuario en el `users.xml` archivo de configuración y asigne 1 al [access\_management](settings/settings-users.md#access_management-user-setting) configuración. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/es/operations/access_rights.md b/docs/es/operations/access_rights.md deleted file mode 100644 index 2d909fdc750..00000000000 --- a/docs/es/operations/access_rights.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 48 -toc_title: Derechos de acceso ---- - -# Derechos de acceso {#access-rights} - -Los usuarios y los derechos de acceso se configuran en la configuración del usuario. Esto suele ser `users.xml`. - -Los usuarios se registran en el `users` apartado. Aquí hay un fragmento de la `users.xml` file: - -``` xml - - - - - - - - - - - - default - - - default - - - - - - - web - default - - test - - - test - - - -``` - -Puede ver una declaración de dos usuarios: `default`y`web`. Hemos añadido el `web` usuario por separado. - -El `default` usuario se elige en los casos en que no se pasa el nombre de usuario. El `default` usuario también se utiliza para el procesamiento de consultas distribuidas, si la configuración del servidor o clúster no `user` y `password` (véase la sección sobre el [Distribuido](../engines/table_engines/special/distributed.md) motor). - -The user that is used for exchanging information between servers combined in a cluster must not have substantial restrictions or quotas – otherwise, distributed queries will fail. - -La contraseña se especifica en texto sin cifrar (no recomendado) o en SHA-256. El hash no está salado. En este sentido, no debe considerar estas contraseñas como proporcionar seguridad contra posibles ataques maliciosos. Más bien, son necesarios para la protección de los empleados. - -Se especifica una lista de redes desde las que se permite el acceso. En este ejemplo, la lista de redes para ambos usuarios se carga desde un archivo independiente (`/etc/metrika.xml`) que contiene el `networks` sustitución. Aquí hay un fragmento de eso: - -``` xml - - ... - - ::/64 - 203.0.113.0/24 - 2001:DB8::/32 - ... - - -``` - -Puede definir esta lista de redes directamente en `users.xml` o en un archivo en el `users.d` (para obtener más información, consulte la sección “[Archivos de configuración](configuration_files.md#configuration_files)”). - -La configuración incluye comentarios que explican cómo abrir el acceso desde todas partes. - -Para su uso en producción, sólo especifique `ip` elementos (direcciones IP y sus máscaras), ya que usan `host` y `hoost_regexp` podría causar latencia adicional. - -A continuación se especifica el perfil de configuración de usuario (consulte la sección “[Perfiles de configuración](settings/settings_profiles.md)”. Puede especificar el perfil predeterminado, `default'`. El perfil puede tener cualquier nombre. Puede especificar el mismo perfil para diferentes usuarios. Lo más importante que puede escribir en el perfil de configuración es `readonly=1`, que asegura el acceso de sólo lectura. A continuación, especifique la cuota que se utilizará (consulte la sección “[Cuota](quotas.md#quotas)”). Puede especificar la cuota predeterminada: `default`. It is set in the config by default to only count resource usage, without restricting it. The quota can have any name. You can specify the same quota for different users – in this case, resource usage is calculated for each user individually. - -En el opcional `` sección, también puede especificar una lista de bases de datos a las que el usuario puede acceder. De forma predeterminada, todas las bases de datos están disponibles para el usuario. Puede especificar el `default` base. En este caso, el usuario recibirá acceso a la base de datos de forma predeterminada. - -En el opcional `` sección, también puede especificar una lista de diccionarios a los que el usuario puede acceder. De forma predeterminada, todos los diccionarios están disponibles para el usuario. - -Acceso a la `system` base de datos siempre está permitida (ya que esta base de datos se utiliza para procesar consultas). - -El usuario puede obtener una lista de todas las bases de datos y tablas en ellos mediante el uso de `SHOW` consultas o tablas del sistema, incluso si no se permite el acceso a bases de datos individuales. - -El acceso a la base de datos no está [sólo lectura](settings/permissions_for_queries.md#settings_readonly) configuración. No puede conceder acceso completo a una base de datos y `readonly` acceso a otro. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/es/operations/backup.md b/docs/es/operations/backup.md index b3e7aba307d..f1e5b3d3e09 100644 --- a/docs/es/operations/backup.md +++ b/docs/es/operations/backup.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 49 toc_title: Copia de seguridad de datos --- # Copia de seguridad de datos {#data-backup} -Mientras [replicación](../engines/table_engines/mergetree_family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [no puede simplemente eliminar tablas con un motor similar a MergeTree que contenga más de 50 Gb de datos](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Sin embargo, estas garantías no cubren todos los casos posibles y pueden eludirse. +Mientras [replicación](../engines/table-engines/mergetree-family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [no puede simplemente eliminar tablas con un motor similar a MergeTree que contenga más de 50 Gb de datos](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Sin embargo, estas garantías no cubren todos los casos posibles y pueden eludirse. Para mitigar eficazmente los posibles errores humanos, debe preparar cuidadosamente una estrategia para realizar copias de seguridad y restaurar sus datos **previamente**. @@ -22,7 +22,7 @@ A menudo, los datos que se ingieren en ClickHouse se entregan a través de algú ## Instantáneas del sistema de archivos {#filesystem-snapshots} -Algunos sistemas de archivos locales proporcionan funcionalidad de instantánea (por ejemplo, [ZFS](https://en.wikipedia.org/wiki/ZFS)), pero podrían no ser la mejor opción para servir consultas en vivo. Una posible solución es crear réplicas adicionales con este tipo de sistema de archivos y excluirlas del [Distribuido](../engines/table_engines/special/distributed.md) tablas que se utilizan para `SELECT` consulta. Las instantáneas en tales réplicas estarán fuera del alcance de cualquier consulta que modifique los datos. Como beneficio adicional, estas réplicas podrían tener configuraciones de hardware especiales con más discos conectados por servidor, lo que sería rentable. +Algunos sistemas de archivos locales proporcionan funcionalidad de instantánea (por ejemplo, [ZFS](https://en.wikipedia.org/wiki/ZFS)), pero podrían no ser la mejor opción para servir consultas en vivo. Una posible solución es crear réplicas adicionales con este tipo de sistema de archivos y excluirlas del [Distribuido](../engines/table-engines/special/distributed.md) tablas que se utilizan para `SELECT` consulta. Las instantáneas en tales réplicas estarán fuera del alcance de cualquier consulta que modifique los datos. Como beneficio adicional, estas réplicas podrían tener configuraciones de hardware especiales con más discos conectados por servidor, lo que sería rentable. ## Método de codificación de datos: {#clickhouse-copier} @@ -34,7 +34,7 @@ Para volúmenes de datos más pequeños, un simple `INSERT INTO ... SELECT ...` ClickHouse permite usar el `ALTER TABLE ... FREEZE PARTITION ...` consulta para crear una copia local de particiones de tabla. Esto se implementa utilizando enlaces duros al `/var/lib/clickhouse/shadow/` carpeta, por lo que generalmente no consume espacio adicional en disco para datos antiguos. Las copias creadas de archivos no son manejadas por el servidor ClickHouse, por lo que puede dejarlas allí: tendrá una copia de seguridad simple que no requiere ningún sistema externo adicional, pero seguirá siendo propenso a problemas de hardware. Por esta razón, es mejor copiarlos de forma remota en otra ubicación y luego eliminar las copias locales. Los sistemas de archivos distribuidos y los almacenes de objetos siguen siendo una buena opción para esto, pero los servidores de archivos conectados normales con una capacidad lo suficientemente grande podrían funcionar también (en este caso, la transferencia ocurrirá a través del sistema de archivos de red o tal vez [rsync](https://en.wikipedia.org/wiki/Rsync)). -Para obtener más información sobre las consultas relacionadas con las manipulaciones de particiones, consulte [Documentación de ALTER](../sql_reference/statements/alter.md#alter_manipulations-with-partitions). +Para obtener más información sobre las consultas relacionadas con las manipulaciones de particiones, consulte [Documentación de ALTER](../sql-reference/statements/alter.md#alter_manipulations-with-partitions). Una herramienta de terceros está disponible para automatizar este enfoque: [Haga clic en el botón de copia de seguridad](https://github.com/AlexAkulov/clickhouse-backup). diff --git a/docs/es/operations/configuration-files.md b/docs/es/operations/configuration-files.md new file mode 100644 index 00000000000..578d7b3f9ff --- /dev/null +++ b/docs/es/operations/configuration-files.md @@ -0,0 +1,57 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: "Archivos de configuraci\xF3n" +--- + +# Archivos de configuración {#configuration_files} + +ClickHouse admite la administración de configuración de varios archivos. El archivo de configuración del servidor principal es `/etc/clickhouse-server/config.xml`. Otros archivos deben estar en el `/etc/clickhouse-server/config.d` directorio. + +!!! note "Nota" + Todos los archivos de configuración deben estar en formato XML. Además, deben tener el mismo elemento raíz, generalmente ``. + +Algunos valores especificados en el archivo de configuración principal se pueden anular en otros archivos de configuración. El `replace` o `remove` se pueden especificar atributos para los elementos de estos archivos de configuración. + +Si no se especifica ninguno, combina el contenido de los elementos de forma recursiva, reemplazando los valores de los elementos secundarios duplicados. + +Si `replace` se especifica, reemplaza todo el elemento por el especificado. + +Si `remove` se especifica, elimina el elemento. + +La configuración también puede definir “substitutions”. Si un elemento tiene el `incl` atributo, la sustitución correspondiente del archivo se utilizará como el valor. De forma predeterminada, la ruta al archivo con sustituciones es `/etc/metrika.xml`. Esto se puede cambiar en el [include\_from](server-configuration-parameters/settings.md#server_configuration_parameters-include_from) elemento en la configuración del servidor. Los valores de sustitución se especifican en `/yandex/substitution_name` elementos en este archivo. Si una sustitución especificada en `incl` no existe, se registra en el registro. Para evitar que ClickHouse registre las sustituciones que faltan, especifique `optional="true"` atributo (por ejemplo, ajustes para [macro](server-configuration-parameters/settings.md)). + +Las sustituciones también se pueden realizar desde ZooKeeper. Para hacer esto, especifique el atributo `from_zk = "/path/to/node"`. El valor del elemento se sustituye por el contenido del nodo en `/path/to/node` en ZooKeeper. También puede colocar un subárbol XML completo en el nodo ZooKeeper y se insertará completamente en el elemento de origen. + +El `config.xml` file puede especificar una configuración separada con configuraciones de usuario, perfiles y cuotas. La ruta relativa a esta configuración se establece en el `users_config` elemento. Por defecto, es `users.xml`. Si `users_config` se omite, la configuración de usuario, los perfiles y las cuotas se especifican directamente en `config.xml`. + +La configuración de los usuarios se puede dividir en archivos separados similares a `config.xml` y `config.d/`. +El nombre del directorio se define como `users_config` sin `.xml` postfix concatenado con `.d`. +Directorio `users.d` se utiliza por defecto, como `users_config` por defecto `users.xml`. +Por ejemplo, puede tener un archivo de configuración separado para cada usuario como este: + +``` bash +$ cat /etc/clickhouse-server/users.d/alice.xml +``` + +``` xml + + + + analytics + + ::/0 + + ... + analytics + + + +``` + +Para cada archivo de configuración, el servidor también genera `file-preprocessed.xml` archivos al iniciar. Estos archivos contienen todas las sustituciones y anulaciones completadas, y están destinados para uso informativo. Si se utilizaron sustituciones de ZooKeeper en los archivos de configuración pero ZooKeeper no está disponible en el inicio del servidor, el servidor carga la configuración desde el archivo preprocesado. + +El servidor realiza un seguimiento de los cambios en los archivos de configuración, así como archivos y nodos ZooKeeper que se utilizaron al realizar sustituciones y anulaciones, y vuelve a cargar la configuración de los usuarios y clústeres sobre la marcha. Esto significa que puede modificar el clúster, los usuarios y su configuración sin reiniciar el servidor. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/es/operations/configuration_files.md b/docs/es/operations/configuration_files.md deleted file mode 100644 index 657fd61eb96..00000000000 --- a/docs/es/operations/configuration_files.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 50 -toc_title: "Archivos de configuraci\xF3n" ---- - -# Archivos de configuración {#configuration_files} - -ClickHouse admite la administración de configuración de varios archivos. El archivo de configuración del servidor principal es `/etc/clickhouse-server/config.xml`. Otros archivos deben estar en el `/etc/clickhouse-server/config.d` directorio. - -!!! note "Nota" - Todos los archivos de configuración deben estar en formato XML. Además, deben tener el mismo elemento raíz, generalmente ``. - -Algunos valores especificados en el archivo de configuración principal se pueden anular en otros archivos de configuración. El `replace` o `remove` los atributos pueden ser especificada para los elementos de estos archivos de configuración. - -Si no se especifica ninguno, combina el contenido de los elementos de forma recursiva, reemplazando los valores de los elementos secundarios duplicados. - -Si `replace` se especifica, reemplaza todo el elemento por el especificado. - -Si `remove` se especifica, elimina el elemento. - -La configuración también puede definir “substitutions”. Si un elemento tiene el `incl` atributo, la sustitución correspondiente del archivo se utilizará como el valor. De forma predeterminada, la ruta al archivo con sustituciones es `/etc/metrika.xml`. Esto se puede cambiar en el [include\_from](server_configuration_parameters/settings.md#server_configuration_parameters-include_from) elemento en la configuración del servidor. Los valores de sustitución se especifican en `/yandex/substitution_name` elementos en este archivo. Si una sustitución especificada en `incl` no existe, se registra en el registro. Para evitar que ClickHouse registre las sustituciones que faltan, especifique `optional="true"` atributo (por ejemplo, ajustes para [macro](server_configuration_parameters/settings.md)). - -Las sustituciones pueden también ser realizada a partir de Cuidador. Para ello, especifique el atributo `from_zk = "/path/to/node"`. El valor del elemento se sustituye por el contenido del nodo en `/path/to/node` en ZooKeeper. También puede colocar un subárbol XML completo en el nodo ZooKeeper y se insertará completamente en el elemento de origen. - -El `config.xml` file puede especificar una configuración separada con configuraciones de usuario, perfiles y cuotas. La ruta relativa a esta configuración se establece en el `users_config` elemento. Por defecto, es `users.xml`. Si `users_config` se omite, la configuración de usuario, los perfiles y las cuotas se especifican directamente en `config.xml`. - -Configuración de usuarios puede ser dividido en archivos separados similar a `config.xml` y `config.d/`. -El nombre del directorio se define como `users_config` sin `.xml` postfix concatenado con `.d`. -Directorio `users.d` se utiliza por defecto, como `users_config` por defecto `users.xml`. -Por ejemplo, puede tener un archivo de configuración separado para cada usuario como este: - -``` bash -$ cat /etc/clickhouse-server/users.d/alice.xml -``` - -``` xml - - - - analytics - - ::/0 - - ... - analytics - - - -``` - -Para cada archivo de configuración, el servidor también genera `file-preprocessed.xml` archivos al iniciar. Estos archivos contienen todas las sustituciones y anulaciones completadas, y están destinados para uso informativo. Si se utilizaron sustituciones de ZooKeeper en los archivos de configuración pero ZooKeeper no está disponible en el inicio del servidor, el servidor carga la configuración desde el archivo preprocesado. - -El servidor realiza un seguimiento de los cambios en los archivos de configuración, así como archivos y nodos ZooKeeper que se utilizaron al realizar sustituciones y anulaciones, y vuelve a cargar la configuración de los usuarios y clústeres sobre la marcha. Esto significa que puede modificar el clúster, los usuarios y su configuración sin reiniciar el servidor. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/es/operations/index.md b/docs/es/operations/index.md index 98bd68c4d0b..9a928fa0f01 100644 --- a/docs/es/operations/index.md +++ b/docs/es/operations/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Operations +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Operaci\xF3n" toc_priority: 41 toc_title: "Implantaci\xF3n" --- @@ -15,14 +15,14 @@ El manual de operaciones de ClickHouse consta de las siguientes secciones princi - [Solución de problemas](troubleshooting.md) - [Recomendaciones de uso](tips.md) - [Procedimiento de actualización](update.md) -- [Derechos de acceso](access_rights.md) +- [Derechos de acceso](access-rights.md) - [Copia de seguridad de datos](backup.md) -- [Archivos de configuración](configuration_files.md) +- [Archivos de configuración](configuration-files.md) - [Cuota](quotas.md) -- [Tablas del sistema](system_tables.md) -- [Parámetros de configuración del servidor](server_configuration_parameters/index.md) -- [Cómo probar su hardware con ClickHouse](performance_test.md) +- [Tablas del sistema](system-tables.md) +- [Parámetros de configuración del servidor](server-configuration-parameters/index.md) +- [Cómo probar su hardware con ClickHouse](performance-test.md) - [Configuración](settings/index.md) - [Utilidad](utilities/index.md) -[Artículo Original](https://clickhouse.tech/docs/en/operations/) +{## [Artículo Original](https://clickhouse.tech/docs/en/operations/) ##} diff --git a/docs/es/operations/monitoring.md b/docs/es/operations/monitoring.md index eb8ddf816d9..173d23aa041 100644 --- a/docs/es/operations/monitoring.md +++ b/docs/es/operations/monitoring.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 45 toc_title: Monitoreo --- @@ -24,20 +24,22 @@ Se recomienda encarecidamente configurar la supervisión para: - Utilización del sistema de almacenamiento, RAM y red. -## Métricas del servidor de Clickhouse {#clickhouse-server-metrics} +## Métricas del servidor ClickHouse {#clickhouse-server-metrics} El servidor ClickHouse tiene instrumentos integrados para el monitoreo de estado propio. -Para realizar un seguimiento de los eventos del servidor, use los registros del servidor. Ver el [registrador](server_configuration_parameters/settings.md#server_configuration_parameters-logger) sección del archivo de configuración. +Para realizar un seguimiento de los eventos del servidor, use los registros del servidor. Ver el [registrador](server-configuration-parameters/settings.md#server_configuration_parameters-logger) sección del archivo de configuración. ClickHouse recoge: - Diferentes métricas de cómo el servidor utiliza recursos computacionales. -- Común de la estadística en el procesamiento de la consulta. +- Estadísticas comunes sobre el procesamiento de consultas. -Puede encontrar métricas en el [sistema.métricas](../operations/system_tables.md#system_tables-metrics), [sistema.evento](../operations/system_tables.md#system_tables-events), y [sistema.asynchronous\_metrics](../operations/system_tables.md#system_tables-asynchronous_metrics) tabla. +Puede encontrar métricas en el [sistema.métricas](../operations/system-tables.md#system_tables-metrics), [sistema.evento](../operations/system-tables.md#system_tables-events), y [sistema.asynchronous\_metrics](../operations/system-tables.md#system_tables-asynchronous_metrics) tabla. -Puede configurar ClickHouse para exportar métricas a [Grafito](https://github.com/graphite-project). Ver el [Sección de grafito](server_configuration_parameters/settings.md#server_configuration_parameters-graphite) en el archivo de configuración del servidor ClickHouse. Antes de configurar la exportación de métricas, debe configurar Graphite siguiendo sus [guiar](https://graphite.readthedocs.io/en/latest/install.html). +Puede configurar ClickHouse para exportar métricas a [Grafito](https://github.com/graphite-project). Ver el [Sección de grafito](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) en el archivo de configuración del servidor ClickHouse. Antes de configurar la exportación de métricas, debe configurar Graphite siguiendo sus [guiar](https://graphite.readthedocs.io/en/latest/install.html). + +Puede configurar ClickHouse para exportar métricas a [Prometeo](https://prometheus.io). Ver el [Sección Prometheus](server-configuration-parameters/settings.md#server_configuration_parameters-prometheus) en el archivo de configuración del servidor ClickHouse. Antes de configurar la exportación de métricas, debe configurar Prometheus siguiendo su oficial [guiar](https://prometheus.io/docs/prometheus/latest/installation/). Además, puede supervisar la disponibilidad del servidor a través de la API HTTP. Enviar el `HTTP GET` solicitud de `/ping`. Si el servidor está disponible, responde con `200 OK`. diff --git a/docs/es/operations/optimizing-performance/index.md b/docs/es/operations/optimizing-performance/index.md new file mode 100644 index 00000000000..d2796c6e0d3 --- /dev/null +++ b/docs/es/operations/optimizing-performance/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Optimizaci\xF3n del rendimiento" +toc_priority: 52 +--- + + diff --git a/docs/es/operations/optimizing-performance/sampling-query-profiler.md b/docs/es/operations/optimizing-performance/sampling-query-profiler.md new file mode 100644 index 00000000000..00ea86b6e8c --- /dev/null +++ b/docs/es/operations/optimizing-performance/sampling-query-profiler.md @@ -0,0 +1,64 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Generaci\xF3n de perfiles de consultas" +--- + +# Analizador de consultas de muestreo {#sampling-query-profiler} + +ClickHouse ejecuta el generador de perfiles de muestreo que permite analizar la ejecución de consultas. Utilizando el generador de perfiles puede encontrar rutinas de código fuente que se utilizan con más frecuencia durante la ejecución de la consulta. Puede rastrear el tiempo de CPU y el tiempo de reloj de pared invertido, incluido el tiempo de inactividad. + +Para usar el generador de perfiles: + +- Configurar el [trace\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) sección de la configuración del servidor. + + Esta sección configura la [trace\_log](../../operations/system-tables.md#system_tables-trace_log) tabla del sistema que contiene los resultados del funcionamiento del generador de perfiles. Está configurado de forma predeterminada. Recuerde que los datos de esta tabla solo son válidos para un servidor en ejecución. Después de reiniciar el servidor, ClickHouse no limpia la tabla y toda la dirección de memoria virtual almacenada puede dejar de ser válida. + +- Configurar el [Los resultados de la prueba](../settings/settings.md#query_profiler_cpu_time_period_ns) o [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) configuración. Ambos ajustes se pueden utilizar simultáneamente. + + Estas opciones le permiten configurar temporizadores del generador de perfiles. Como estos son los ajustes de sesión, puede obtener diferentes frecuencias de muestreo para todo el servidor, usuarios individuales o perfiles de usuario, para su sesión interactiva y para cada consulta individual. + +La frecuencia de muestreo predeterminada es una muestra por segundo y tanto la CPU como los temporizadores reales están habilitados. Esta frecuencia permite recopilar suficiente información sobre el clúster ClickHouse. Al mismo tiempo, al trabajar con esta frecuencia, el generador de perfiles no afecta el rendimiento del servidor ClickHouse. Si necesita perfilar cada consulta individual, intente usar una mayor frecuencia de muestreo. + +Para analizar el `trace_log` tabla del sistema: + +- Instale el `clickhouse-common-static-dbg` paquete. Ver [Instalar desde paquetes DEB](../../getting-started/install.md#install-from-deb-packages). + +- Permitir funciones de introspección [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) configuración. + + Por razones de seguridad, las funciones de introspección están deshabilitadas de forma predeterminada. + +- Utilice el `addressToLine`, `addressToSymbol` y `demangle` [funciones de la introspección](../../sql-reference/functions/introspection.md) para obtener nombres de funciones y sus posiciones en el código ClickHouse. Para obtener un perfil para alguna consulta, debe agregar datos del `trace_log` tabla. Puede agregar datos por funciones individuales o por los seguimientos de pila completos. + +Si necesita visualizar `trace_log` información, intente [Flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) y [Nivel de Cifrado WEP](https://github.com/laplab/clickhouse-speedscope). + +## Ejemplo {#example} + +En este ejemplo nos: + +- Filtrado `trace_log` datos por un identificador de consulta y la fecha actual. + +- Agregando por seguimiento de pila. + +- Usando funciones de introspección, obtendremos un informe de: + + - Nombres de símbolos y funciones de código fuente correspondientes. + - Ubicaciones del código fuente de estas funciones. + + + +``` sql +SELECT + count(), + arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym +FROM system.trace_log +WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) +GROUP BY trace +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +{% include "examples/sampling_query_profiler_result.txt" %} +``` diff --git a/docs/es/operations/optimizing_performance/index.md b/docs/es/operations/optimizing_performance/index.md deleted file mode 100644 index 126096db767..00000000000 --- a/docs/es/operations/optimizing_performance/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Optimizing Performance -toc_priority: 52 ---- - - diff --git a/docs/es/operations/optimizing_performance/sampling_query_profiler.md b/docs/es/operations/optimizing_performance/sampling_query_profiler.md deleted file mode 100644 index 2bd7429b312..00000000000 --- a/docs/es/operations/optimizing_performance/sampling_query_profiler.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 54 -toc_title: "Generaci\xF3n de perfiles de consultas" ---- - -# Analizador de consultas de muestreo {#sampling-query-profiler} - -ClickHouse ejecuta el generador de perfiles de muestreo que permite analizar la ejecución de consultas. Utilizando el generador de perfiles puede encontrar rutinas de código fuente que se utilizan con más frecuencia durante la ejecución de la consulta. Puede rastrear el tiempo de CPU y el tiempo de reloj de pared invertido, incluido el tiempo de inactividad. - -Para usar el generador de perfiles: - -- Configurar el [trace\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) sección de la configuración del servidor. - - Esta sección configura la [trace\_log](../../operations/system_tables.md#system_tables-trace_log) tabla del sistema que contiene los resultados del funcionamiento del generador de perfiles. Está configurado de forma predeterminada. Recuerde que los datos de esta tabla solo son válidos para un servidor en ejecución. Después de reiniciar el servidor, ClickHouse no limpia la tabla y toda la dirección de memoria virtual almacenada puede dejar de ser válida. - -- Configurar el [Los resultados de la prueba](../settings/settings.md#query_profiler_cpu_time_period_ns) o [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) configuración. Ambos ajustes se pueden utilizar simultáneamente. - - Estas opciones le permiten configurar temporizadores del generador de perfiles. Como estos son los ajustes de sesión, puede obtener diferentes frecuencias de muestreo para todo el servidor, usuarios individuales o perfiles de usuario, para su sesión interactiva y para cada consulta individual. - -La frecuencia de muestreo predeterminada es una muestra por segundo y tanto la CPU como los temporizadores reales están habilitados. Esta frecuencia permite recopilar suficiente información sobre el clúster ClickHouse. Al mismo tiempo, al trabajar con esta frecuencia, el generador de perfiles no afecta el rendimiento del servidor ClickHouse. Si necesita perfilar cada consulta individual, intente usar una mayor frecuencia de muestreo. - -Para analizar el `trace_log` tabla del sistema: - -- Instale el `clickhouse-common-static-dbg` paquete. Ver [Instalar desde paquetes DEB](../../getting_started/install.md#install-from-deb-packages). - -- Permitir funciones de introspección [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) configuración. - - Por razones de seguridad, las funciones de introspección están deshabilitadas de forma predeterminada. - -- Utilice el `addressToLine`, `addressToSymbol` y `demangle` [funciones de la introspección](../../sql_reference/functions/introspection.md) para obtener nombres de funciones y sus posiciones en el código ClickHouse. Para obtener un perfil para alguna consulta, debe agregar datos del `trace_log` tabla. Puede agregar datos por funciones individuales o por los seguimientos de pila completos. - -Si necesita visualizar `trace_log` información, intente [Flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) y [Nivel de Cifrado WEP](https://github.com/laplab/clickhouse-speedscope). - -## Ejemplo {#example} - -En este ejemplo nos: - -- Filtrado `trace_log` datos por un identificador de consulta y la fecha actual. - -- Agregando por seguimiento de pila. - -- Usando funciones de introspección, obtendremos un informe de: - - - Nombres de símbolos y funciones de código fuente correspondientes. - - Ubicaciones del código fuente de estas funciones. - - - -``` sql -SELECT - count(), - arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym -FROM system.trace_log -WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) -GROUP BY trace -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -{% include "examples/sampling_query_profiler_result.txt" %} -``` diff --git a/docs/es/operations/performance-test.md b/docs/es/operations/performance-test.md new file mode 100644 index 00000000000..d0beb7bd2b4 --- /dev/null +++ b/docs/es/operations/performance-test.md @@ -0,0 +1,82 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: Prueba de hardware +--- + +# Cómo probar su hardware con ClickHouse {#how-to-test-your-hardware-with-clickhouse} + +Con esta instrucción, puede ejecutar una prueba de rendimiento básica de ClickHouse en cualquier servidor sin instalar paquetes de ClickHouse. + +1. Ir a “commits” página: https://github.com/ClickHouse/ClickHouse/commits/master + +2. Haga clic en la primera marca de verificación verde o cruz roja con verde “ClickHouse Build Check” y haga clic en el “Details” enlace cerca “ClickHouse Build Check”. No existe tal enlace en algunas confirmaciones, por ejemplo, confirmaciones con documentación. En este caso, elija la confirmación más cercana que tenga este enlace. + +3. Copie el enlace a “clickhouse” binario para amd64 o aarch64. + +4. ssh al servidor y descargarlo con wget: + + + + # For amd64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse + # For aarch64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse + # Then do: + chmod a+x clickhouse + +1. Descargar configs: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml + mkdir config.d + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml + +1. Descargar archivos de referencia: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh + chmod a+x benchmark-new.sh + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql + +1. Descargue los datos de prueba de acuerdo con el [El Yandex.Conjunto de datos de Metrica](../getting-started/example-datasets/metrica.md) instrucción (“hits” tabla que contiene 100 millones de filas). + + + + wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz + tar xvf hits_100m_obfuscated_v1.tar.xz -C . + mv hits_100m_obfuscated_v1/* . + +1. Ejecute el servidor: + + + + ./clickhouse server + +1. Verifique los datos: ssh al servidor en otro terminal + + + + ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" + 100000000 + +1. Edite el benchmark-new.sh, cambie `clickhouse-client` a `./clickhouse client` y añadir `–-max_memory_usage 100000000000` parámetro. + + + + mcedit benchmark-new.sh + +1. Ejecute el punto de referencia: + + + + ./benchmark-new.sh hits_100m_obfuscated + +1. Envíe los números y la información sobre la configuración de su hardware a clickhouse-feedback@yandex-team.com + +Todos los resultados se publican aquí: https://clickhouse.tecnología/punto de referencia/hardware/ diff --git a/docs/es/operations/performance_test.md b/docs/es/operations/performance_test.md deleted file mode 100644 index 3d982870c36..00000000000 --- a/docs/es/operations/performance_test.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 54 -toc_title: Prueba de hardware ---- - -# Cómo probar su hardware con ClickHouse {#how-to-test-your-hardware-with-clickhouse} - -Con esta instrucción, puede ejecutar una prueba de rendimiento básica de ClickHouse en cualquier servidor sin instalar paquetes de ClickHouse. - -1. Ir a “commits” página: https://github.com/ClickHouse/ClickHouse/commits/master - -2. Haga clic en la primera marca de verificación verde o cruz roja con verde “ClickHouse Build Check” y haga clic en el “Details” enlace cerca “ClickHouse Build Check”. - -3. Copie el enlace a “clickhouse” binario para amd64 o aarch64. - -4. ssh al servidor y descargarlo con wget: - - - - # For amd64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse - # For aarch64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse - # Then do: - chmod a+x clickhouse - -1. Descargar configs: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml - mkdir config.d - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml - -1. Descargar archivos de referencia: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh - chmod a+x benchmark-new.sh - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql - -1. Descargue los datos de prueba de acuerdo con el [El Yandex.Conjunto de datos de Metrica](../getting_started/example_datasets/metrica.md) instrucción (“hits” tabla que contiene 100 millones de filas). - - - - wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz - tar xvf hits_100m_obfuscated_v1.tar.xz -C . - mv hits_100m_obfuscated_v1/* . - -1. Ejecute el servidor: - - - - ./clickhouse server - -1. Verifique los datos: ssh al servidor en otro terminal - - - - ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" - 100000000 - -1. Edite el benchmark-new.sh, cambie “clickhouse-client” a “./clickhouse client” y añadir “–max\_memory\_usage 100000000000” parámetro. - - - - mcedit benchmark-new.sh - -1. Ejecute el punto de referencia: - - - - ./benchmark-new.sh hits_100m_obfuscated - -1. Envíe los números y la información sobre la configuración de su hardware a clickhouse-feedback@yandex-team.com - -Todos los resultados se publican aquí: https://clickhouse.tecnología/benchmark\_hardware.HTML diff --git a/docs/es/operations/quotas.md b/docs/es/operations/quotas.md index af6d09a54ce..9d84ce21339 100644 --- a/docs/es/operations/quotas.md +++ b/docs/es/operations/quotas.md @@ -1,14 +1,14 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 51 toc_title: Cuota --- # Cuota {#quotas} -Las cuotas le permiten limitar el uso de recursos durante un período de tiempo, o simplemente realizar un seguimiento del uso de recursos. -Las cuotas se configuran en la configuración del usuario. Esto suele ser ‘users.xml’. +Las cuotas le permiten limitar el uso de recursos durante un período de tiempo o realizar un seguimiento del uso de recursos. +Las cuotas se configuran en la configuración del usuario, que generalmente ‘users.xml’. El sistema también tiene una característica para limitar la complejidad de una sola consulta. Vea la sección “Restrictions on query complexity”). @@ -39,7 +39,7 @@ Veamos la sección del ‘users.xml’ fichero que define las cuotas. ``` -De forma predeterminada, la cuota sólo pistas de consumo de recursos por cada hora, sin limitación de uso. +De forma predeterminada, la cuota realiza un seguimiento del consumo de recursos para cada hora, sin limitar el uso. El consumo de recursos calculado para cada intervalo se envía al registro del servidor después de cada solicitud. ``` xml @@ -68,7 +68,7 @@ El consumo de recursos calculado para cada intervalo se envía al registro del s ``` -Para el ‘statbox’ Las restricciones se establecen por cada hora y por cada 24 horas (86.400 segundos). El intervalo de tiempo se cuenta a partir de un momento fijo definido por la implementación en el tiempo. En otras palabras, el intervalo de 24 horas no necesariamente comienza a medianoche. +Para el ‘statbox’ Las restricciones se establecen por cada hora y por cada 24 horas (86.400 segundos). El intervalo de tiempo se cuenta, a partir de un momento fijo definido por la implementación en el tiempo. En otras palabras, el intervalo de 24 horas no necesariamente comienza a medianoche. Cuando finaliza el intervalo, se borran todos los valores recopilados. Para la siguiente hora, el cálculo de la cuota comienza de nuevo. @@ -78,15 +78,15 @@ Estas son las cantidades que se pueden restringir: `errors` – The number of queries that threw an exception. -`result_rows` – The total number of rows given as the result. +`result_rows` – The total number of rows given as a result. -`read_rows` – The total number of source rows read from tables for running the query, on all remote servers. +`read_rows` – The total number of source rows read from tables for running the query on all remote servers. `execution_time` – The total query execution time, in seconds (wall time). Si se excede el límite durante al menos un intervalo de tiempo, se lanza una excepción con un texto sobre qué restricción se excedió, para qué intervalo y cuándo comienza el nuevo intervalo (cuando se pueden enviar consultas nuevamente). -Las cuotas pueden usar el “quota key” característica con el fin de informar sobre los recursos para múltiples claves de forma independiente. Aquí hay un ejemplo de esto: +Las cuotas pueden usar el “quota key” característica para informar sobre los recursos para múltiples claves de forma independiente. Aquí hay un ejemplo de esto: ``` xml @@ -97,7 +97,7 @@ Las cuotas pueden usar el “quota key” característica con el fin de informar so the quota will be counted separately for each username. Using keys makes sense only if quota_key is transmitted by the program, not by a user. - You can also write so the IP address is used as the quota key. + You can also write , so the IP address is used as the quota key. (But keep in mind that users can change the IPv6 address fairly easily.) --> diff --git a/docs/es/operations/requirements.md b/docs/es/operations/requirements.md index 3611cc9475d..29ed7a655a7 100644 --- a/docs/es/operations/requirements.md +++ b/docs/es/operations/requirements.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 44 toc_title: Requisito --- @@ -13,7 +13,7 @@ Para la instalación desde paquetes deb precompilados, utilice una CPU con arqui ClickHouse implementa el procesamiento de datos paralelo y utiliza todos los recursos de hardware disponibles. Al elegir un procesador, tenga en cuenta que ClickHouse funciona de manera más eficiente en configuraciones con un gran número de núcleos pero con una velocidad de reloj más baja que en configuraciones con menos núcleos y una velocidad de reloj más alta. Por ejemplo, 16 núcleos con 2600 MHz es preferible a 8 núcleos con 3600 MHz. -Uso de **Impulso de Turbo** y **hiper-threading** tecnologías se recomienda. Mejora significativamente el rendimiento con una carga típica. +Se recomienda usar **Impulso de Turbo** y **hiper-threading** tecnología. Mejora significativamente el rendimiento con una carga de trabajo típica. ## RAM {#ram} @@ -24,9 +24,9 @@ El volumen requerido de RAM depende de: - La complejidad de las consultas. - La cantidad de datos que se procesan en las consultas. -Para calcular el volumen requerido de RAM, debe estimar el tamaño de los datos temporales para [GROUP BY](../sql_reference/statements/select.md#select-group-by-clause), [DISTINCT](../sql_reference/statements/select.md#select-distinct), [JOIN](../sql_reference/statements/select.md#select-join) y otras operaciones que utilice. +Para calcular el volumen requerido de RAM, debe estimar el tamaño de los datos temporales para [GROUP BY](../sql-reference/statements/select/group-by.md#select-group-by-clause), [DISTINCT](../sql-reference/statements/select/distinct.md#select-distinct), [JOIN](../sql-reference/statements/select/join.md#select-join) y otras operaciones que utilice. -ClickHouse puede usar memoria externa para datos temporales. Ver [GROUP BY en memoria externa](../sql_reference/statements/select.md#select-group-by-in-external-memory) para más detalles. +ClickHouse puede usar memoria externa para datos temporales. Ver [GROUP BY en memoria externa](../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory) para más detalles. ## Archivo de intercambio {#swap-file} @@ -56,6 +56,6 @@ El ancho de banda de la red es fundamental para procesar consultas distribuidas ## Software {#software} -ClickHouse está desarrollado para la familia de sistemas operativos Linux. La distribución de Linux recomendada es Ubuntu. El `tzdata` paquete debe ser instalado en el sistema. +ClickHouse está desarrollado principalmente para la familia de sistemas operativos Linux. La distribución de Linux recomendada es Ubuntu. El `tzdata` paquete debe ser instalado en el sistema. -ClickHouse también puede funcionar en otras familias de sistemas operativos. Ver detalles en el [Primeros pasos](../getting_started/index.md) sección de la documentación. +ClickHouse también puede funcionar en otras familias de sistemas operativos. Ver detalles en el [Primeros pasos](../getting-started/index.md) sección de la documentación. diff --git a/docs/es/operations/server-configuration-parameters/index.md b/docs/es/operations/server-configuration-parameters/index.md new file mode 100644 index 00000000000..e1e2e777b94 --- /dev/null +++ b/docs/es/operations/server-configuration-parameters/index.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Par\xE1metros de configuraci\xF3n del servidor" +toc_priority: 54 +toc_title: "Implantaci\xF3n" +--- + +# Parámetros de configuración del servidor {#server-settings} + +Esta sección contiene descripciones de la configuración del servidor que no se puede cambiar en el nivel de sesión o consulta. + +Estos ajustes se almacenan en el `config.xml` archivo en el servidor ClickHouse. + +Otros ajustes se describen en el “[Configuración](../settings/index.md#session-settings-intro)” apartado. + +Antes de estudiar la configuración, lea el [Archivos de configuración](../configuration-files.md#configuration_files) sección y tomar nota del uso de sustituciones (el `incl` y `optional` atributo). + +[Artículo Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/es/operations/server-configuration-parameters/settings.md b/docs/es/operations/server-configuration-parameters/settings.md new file mode 100644 index 00000000000..29f726ee635 --- /dev/null +++ b/docs/es/operations/server-configuration-parameters/settings.md @@ -0,0 +1,906 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "Configuraci\xF3n del servidor" +--- + +# Configuración del servidor {#server-settings} + +## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} + +El intervalo en segundos antes de volver a cargar los diccionarios integrados. + +ClickHouse recarga los diccionarios incorporados cada x segundos. Esto hace posible editar diccionarios “on the fly” sin reiniciar el servidor. + +Valor predeterminado: 3600. + +**Ejemplo** + +``` xml +3600 +``` + +## compresión {#server-settings-compression} + +Ajustes de compresión de datos para [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md)-mesas de motor. + +!!! warning "Advertencia" + No lo use si acaba de comenzar a usar ClickHouse. + +Plantilla de configuración: + +``` xml + + + ... + ... + ... + + ... + +``` + +`` campo: + +- `min_part_size` – The minimum size of a data part. +- `min_part_size_ratio` – The ratio of the data part size to the table size. +- `method` – Compression method. Acceptable values: `lz4` o `zstd`. + +Puede configurar múltiples `` apartado. + +Acciones cuando se cumplen las condiciones: + +- Si un elemento de datos coincide con un conjunto de condiciones, ClickHouse utiliza el método de compresión especificado. +- Si un elemento de datos coincide con varios conjuntos de condiciones, ClickHouse utiliza el primer conjunto de condiciones coincidente. + +Si no se cumplen condiciones para un elemento de datos, ClickHouse utiliza el `lz4` compresión. + +**Ejemplo** + +``` xml + + + 10000000000 + 0.01 + zstd + + +``` + +## default\_database {#default-database} + +La base de datos predeterminada. + +Para obtener una lista de bases de datos, [SHOW DATABASES](../../sql-reference/statements/show.md#show-databases) consulta. + +**Ejemplo** + +``` xml +default +``` + +## default\_profile {#default-profile} + +Perfil de configuración predeterminado. + +Los perfiles de configuración se encuentran en el archivo especificado en el parámetro `user_config`. + +**Ejemplo** + +``` xml +default +``` + +## Diccionarios\_config {#server_configuration_parameters-dictionaries_config} + +La ruta de acceso al archivo de configuración para diccionarios externos. + +Camino: + +- Especifique la ruta absoluta o la ruta relativa al archivo de configuración del servidor. +- La ruta puede contener comodines \* y ?. + +Ver también “[Diccionarios externos](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md)”. + +**Ejemplo** + +``` xml +*_dictionary.xml +``` + +## Diccionarios\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} + +La carga perezosa de los diccionarios. + +Si `true`, entonces cada diccionario es creado en el primer uso. Si se produce un error en la creación del diccionario, la función que estaba utilizando el diccionario produce una excepción. + +Si `false`, todos los diccionarios se crean cuando se inicia el servidor, y si hay un error, el servidor se apaga. + +El valor predeterminado es `true`. + +**Ejemplo** + +``` xml +true +``` + +## format\_schema\_path {#server_configuration_parameters-format_schema_path} + +La ruta de acceso al directorio con los esquemas para los datos de entrada, como los esquemas [CapnProto](../../interfaces/formats.md#capnproto) formato. + +**Ejemplo** + +``` xml + + format_schemas/ +``` + +## grafito {#server_configuration_parameters-graphite} + +Envío de datos a [Grafito](https://github.com/graphite-project). + +Configuración: + +- host – The Graphite server. +- port – The port on the Graphite server. +- interval – The interval for sending, in seconds. +- timeout – The timeout for sending data, in seconds. +- root\_path – Prefix for keys. +- metrics – Sending data from the [sistema.métricas](../../operations/system-tables.md#system_tables-metrics) tabla. +- events – Sending deltas data accumulated for the time period from the [sistema.evento](../../operations/system-tables.md#system_tables-events) tabla. +- events\_cumulative – Sending cumulative data from the [sistema.evento](../../operations/system-tables.md#system_tables-events) tabla. +- asynchronous\_metrics – Sending data from the [sistema.asynchronous\_metrics](../../operations/system-tables.md#system_tables-asynchronous_metrics) tabla. + +Puede configurar múltiples `` clausula. Por ejemplo, puede usar esto para enviar datos diferentes a intervalos diferentes. + +**Ejemplo** + +``` xml + + localhost + 42000 + 0.1 + 60 + one_min + true + true + false + true + +``` + +## graphite\_rollup {#server_configuration_parameters-graphite-rollup} + +Ajustes para reducir los datos de grafito. + +Para obtener más información, consulte [GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md). + +**Ejemplo** + +``` xml + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +## http\_port/https\_port {#http-porthttps-port} + +El puerto para conectarse al servidor a través de HTTP(s). + +Si `https_port` se especifica, [openSSL](#server_configuration_parameters-openssl) debe ser configurado. + +Si `http_port` se especifica, la configuración de OpenSSL se ignora incluso si está establecida. + +**Ejemplo** + +``` xml +9999 +``` + +## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} + +La página que se muestra de forma predeterminada al acceder al servidor HTTP de ClickHouse. +El valor predeterminado es “Ok.” (con un avance de línea al final) + +**Ejemplo** + +Abrir `https://tabix.io/` al acceder `http://localhost: http_port`. + +``` xml + +
]]> +
+``` + +## include\_from {#server_configuration_parameters-include_from} + +La ruta al archivo con sustituciones. + +Para obtener más información, consulte la sección “[Archivos de configuración](../configuration-files.md#configuration_files)”. + +**Ejemplo** + +``` xml +/etc/metrica.xml +``` + +## Interesante {#interserver-http-port} + +Puerto para el intercambio de datos entre servidores ClickHouse. + +**Ejemplo** + +``` xml +9009 +``` + +## Sistema abierto {#interserver-http-host} + +El nombre de host que pueden utilizar otros servidores para acceder a este servidor. + +Si se omite, se define de la misma manera que el `hostname-f` comando. + +Útil para separarse de una interfaz de red específica. + +**Ejemplo** + +``` xml +example.yandex.ru +``` + +## interserver\_http\_credentials {#server-settings-interserver-http-credentials} + +El nombre de usuario y la contraseña utilizados para [replicación](../../engines/table-engines/mergetree-family/replication.md) con los motores Replicated\*. Estas credenciales sólo se utilizan para la comunicación entre réplicas y no están relacionadas con las credenciales de los clientes de ClickHouse. El servidor está comprobando estas credenciales para conectar réplicas y utiliza las mismas credenciales cuando se conecta a otras réplicas. Por lo tanto, estas credenciales deben establecerse igual para todas las réplicas de un clúster. +De forma predeterminada, la autenticación no se utiliza. + +Esta sección contiene los siguientes parámetros: + +- `user` — username. +- `password` — password. + +**Ejemplo** + +``` xml + + admin + 222 + +``` + +## keep\_alive\_timeout {#keep-alive-timeout} + +El número de segundos que ClickHouse espera las solicitudes entrantes antes de cerrar la conexión. El valor predeterminado es de 3 segundos. + +**Ejemplo** + +``` xml +3 +``` + +## listen\_host {#server_configuration_parameters-listen_host} + +Restricción en hosts de los que pueden provenir las solicitudes. Si desea que el servidor responda a todos ellos, especifique `::`. + +Ejemplos: + +``` xml +::1 +127.0.0.1 +``` + +## registrador {#server_configuration_parameters-logger} + +Configuración de registro. + +Claves: + +- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. +- log – The log file. Contains all the entries according to `level`. +- errorlog – Error log file. +- size – Size of the file. Applies to `log`y`errorlog`. Una vez que el archivo alcanza `size`, ClickHouse archiva y cambia el nombre, y crea un nuevo archivo de registro en su lugar. +- count – The number of archived log files that ClickHouse stores. + +**Ejemplo** + +``` xml + + trace + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 10 + +``` + +También se admite la escritura en el syslog. Config ejemplo: + +``` xml + + 1 + +
syslog.remote:10514
+ myhost.local + LOG_LOCAL6 + syslog +
+
+``` + +Claves: + +- use\_syslog — Required setting if you want to write to the syslog. +- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. +- hostname — Optional. The name of the host that logs are sent from. +- facility — [La palabra clave syslog facility](https://en.wikipedia.org/wiki/Syslog#Facility) en letras mayúsculas con el “LOG\_” prefijo: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` y así sucesivamente). + Valor predeterminado: `LOG_USER` si `address` se especifica, `LOG_DAEMON otherwise.` +- format – Message format. Possible values: `bsd` y `syslog.` + +## macro {#macros} + +Sustituciones de parámetros para tablas replicadas. + +Se puede omitir si no se utilizan tablas replicadas. + +Para obtener más información, consulte la sección “[Creación de tablas replicadas](../../engines/table-engines/mergetree-family/replication.md)”. + +**Ejemplo** + +``` xml + +``` + +## Método de codificación de datos: {#server-mark-cache-size} + +Tamaño aproximado (en bytes) de la memoria caché de marcas utilizadas por los motores de [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md) familia. + +La memoria caché se comparte para el servidor y la memoria se asigna según sea necesario. El tamaño de la memoria caché debe ser al menos 5368709120. + +**Ejemplo** + +``` xml +5368709120 +``` + +## max\_concurrent\_queries {#max-concurrent-queries} + +El número máximo de solicitudes procesadas simultáneamente. + +**Ejemplo** + +``` xml +100 +``` + +## max\_connections {#max-connections} + +El número máximo de conexiones entrantes. + +**Ejemplo** + +``` xml +4096 +``` + +## max\_open\_files {#max-open-files} + +El número máximo de archivos abiertos. + +Predeterminada: `maximum`. + +Recomendamos usar esta opción en Mac OS X desde el `getrlimit()` función devuelve un valor incorrecto. + +**Ejemplo** + +``` xml +262144 +``` + +## max\_table\_size\_to\_drop {#max-table-size-to-drop} + +Restricción en la eliminación de tablas. + +Si el tamaño de un [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md) mesa excede `max_table_size_to_drop` (en bytes), no puede eliminarlo usando una consulta DROP. + +Si aún necesita eliminar la tabla sin reiniciar el servidor ClickHouse, cree el `/flags/force_drop_table` y ejecute la consulta DROP. + +Valor predeterminado: 50 GB. + +El valor 0 significa que puede eliminar todas las tablas sin restricciones. + +**Ejemplo** + +``` xml +0 +``` + +## merge\_tree {#server_configuration_parameters-merge_tree} + +Ajuste fino para tablas en el [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md). + +Para obtener más información, vea MergeTreeSettings.h archivo de encabezado. + +**Ejemplo** + +``` xml + + 5 + +``` + +## openSSL {#server_configuration_parameters-openssl} + +Configuración cliente/servidor SSL. + +El soporte para SSL es proporcionado por el `libpoco` biblioteca. La interfaz se describe en el archivo [Nombre de la red inalámbrica (SSID):h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) + +Claves para la configuración del servidor/cliente: + +- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. +- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` contiene el certificado. +- caConfig – The path to the file or directory that contains trusted root certificates. +- verificationMode – The method for checking the node's certificates. Details are in the description of the [Contexto](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) clase. Valores posibles: `none`, `relaxed`, `strict`, `once`. +- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. +- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| +- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. +- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Valores aceptables: `true`, `false`. +- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. Este parámetro siempre se recomienda ya que ayuda a evitar problemas tanto si el servidor almacena en caché la sesión como si el cliente solicita el almacenamiento en caché. Valor predeterminado: `${application.name}`. +- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. +- sessionTimeout – Time for caching the session on the server. +- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. +- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. +- fips – Activates OpenSSL FIPS mode. Supported if the library's OpenSSL version supports FIPS. +- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. +- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . +- disableProtocols – Protocols that are not allowed to use. +- preferServerCiphers – Preferred server ciphers on the client. + +**Ejemplo de configuración:** + +``` xml + + + + /etc/clickhouse-server/server.crt + /etc/clickhouse-server/server.key + + /etc/clickhouse-server/dhparam.pem + none + true + true + sslv2,sslv3 + true + + + true + true + sslv2,sslv3 + true + + + + RejectCertificateHandler + + + +``` + +## part\_log {#server_configuration_parameters-part-log} + +Registro de eventos asociados con [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md). Por ejemplo, agregar o fusionar datos. Puede utilizar el registro para simular algoritmos de combinación y comparar sus características. Puede visualizar el proceso de fusión. + +Las consultas se registran en el [sistema.part\_log](../../operations/system-tables.md#system_tables-part-log) tabla, no en un archivo separado. Puede configurar el nombre de esta tabla en el `table` parámetro (ver más abajo). + +Utilice los siguientes parámetros para configurar el registro: + +- `database` – Name of the database. +- `table` – Name of the system table. +- `partition_by` – Sets a [clave de partición personalizada](../../engines/table-engines/mergetree-family/custom-partitioning-key.md). +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +**Ejemplo** + +``` xml + + system + part_log
+ toMonday(event_date) + 7500 +
+``` + +## camino {#server_configuration_parameters-path} + +La ruta de acceso al directorio que contiene los datos. + +!!! note "Nota" + La barra diagonal es obligatoria. + +**Ejemplo** + +``` xml +/var/lib/clickhouse/ +``` + +## prometeo {#server_configuration_parameters-prometheus} + +Exponer datos de métricas para raspar desde [Prometeo](https://prometheus.io). + +Configuración: + +- `endpoint` – HTTP endpoint for scraping metrics by prometheus server. Start from ‘/’. +- `port` – Port for `endpoint`. +- `metrics` – Flag that sets to expose metrics from the [sistema.métricas](../system-tables.md#system_tables-metrics) tabla. +- `events` – Flag that sets to expose metrics from the [sistema.evento](../system-tables.md#system_tables-events) tabla. +- `asynchronous_metrics` – Flag that sets to expose current metrics values from the [sistema.asynchronous\_metrics](../system-tables.md#system_tables-asynchronous_metrics) tabla. + +**Ejemplo** + +``` xml + + /metrics + 8001 + true + true + true + +``` + +## query\_log {#server_configuration_parameters-query-log} + +Configuración de las consultas de registro recibidas con [log\_queries=1](../settings/settings.md) configuración. + +Las consultas se registran en el [sistema.query\_log](../../operations/system-tables.md#system_tables-query_log) tabla, no en un archivo separado. Puede cambiar el nombre de la tabla en el `table` parámetro (ver más abajo). + +Utilice los siguientes parámetros para configurar el registro: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [clave de partición personalizada](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) para una mesa. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +Si la tabla no existe, ClickHouse la creará. Si la estructura del registro de consultas cambió cuando se actualizó el servidor ClickHouse, se cambia el nombre de la tabla con la estructura anterior y se crea una nueva tabla automáticamente. + +**Ejemplo** + +``` xml + + system + query_log
+ toMonday(event_date) + 7500 +
+``` + +## Sistema abierto {#server_configuration_parameters-query-thread-log} + +Configuración de subprocesos de registro de consultas recibidas con [Log\_query\_threads = 1](../settings/settings.md#settings-log-query-threads) configuración. + +Las consultas se registran en el [sistema.Sistema abierto.](../../operations/system-tables.md#system_tables-query-thread-log) tabla, no en un archivo separado. Puede cambiar el nombre de la tabla en el `table` parámetro (ver más abajo). + +Utilice los siguientes parámetros para configurar el registro: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [clave de partición personalizada](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) para una tabla del sistema. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +Si la tabla no existe, ClickHouse la creará. Si la estructura del registro de subprocesos de consulta cambió cuando se actualizó el servidor ClickHouse, se cambia el nombre de la tabla con la estructura anterior y se crea una nueva tabla automáticamente. + +**Ejemplo** + +``` xml + + system + query_thread_log
+ toMonday(event_date) + 7500 +
+``` + +## trace\_log {#server_configuration_parameters-trace_log} + +Ajustes para el [trace\_log](../../operations/system-tables.md#system_tables-trace_log) operación de la tabla del sistema. + +Parámetros: + +- `database` — Database for storing a table. +- `table` — Table name. +- `partition_by` — [Clave de partición personalizada](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) para una tabla del sistema. +- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. + +El archivo de configuración del servidor predeterminado `config.xml` contiene la siguiente sección de configuración: + +``` xml + + system + trace_log
+ toYYYYMM(event_date) + 7500 +
+``` + +## query\_masking\_rules {#query-masking-rules} + +Reglas basadas en Regexp, que se aplicarán a las consultas, así como a todos los mensajes de registro antes de almacenarlos en los registros del servidor, +`system.query_log`, `system.text_log`, `system.processes` tabla, y en los registros enviados al cliente. Eso permite prevenir +fuga de datos sensible de consultas SQL (como nombres, correos electrónicos, +identificadores o números de tarjetas de crédito) a los registros. + +**Ejemplo** + +``` xml + + + hide SSN + (^|\D)\d{3}-\d{2}-\d{4}($|\D) + 000-00-0000 + + +``` + +Campos de configuración: +- `name` - nombre de la regla (opcional) +- `regexp` - Expresión regular compatible con RE2 (obligatoria) +- `replace` - cadena de sustitución para datos confidenciales (opcional, por defecto - seis asteriscos) + +Las reglas de enmascaramiento se aplican a toda la consulta (para evitar fugas de datos confidenciales de consultas mal formadas / no analizables). + +`system.events` la tabla tiene contador `QueryMaskingRulesMatch` que tienen un número total de coincidencias de reglas de enmascaramiento de consultas. + +Para consultas distribuidas, cada servidor debe configurarse por separado; de lo contrario, las subconsultas pasan a otros +los nodos se almacenarán sin enmascarar. + +## remote\_servers {#server-settings-remote-servers} + +Configuración de los clústeres utilizados por [Distribuido](../../engines/table-engines/special/distributed.md) motor de mesa y por el `cluster` función de la tabla. + +**Ejemplo** + +``` xml + +``` + +Para el valor de la `incl` atributo, consulte la sección “[Archivos de configuración](../configuration-files.md#configuration_files)”. + +**Ver también** + +- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) + +## Zona horaria {#server_configuration_parameters-timezone} + +La zona horaria del servidor. + +Especificado como un identificador de la IANA para la zona horaria UTC o la ubicación geográfica (por ejemplo, África/Abidjan). + +La zona horaria es necesaria para las conversiones entre los formatos String y DateTime cuando los campos DateTime se envían al formato de texto (impreso en la pantalla o en un archivo) y cuando se obtiene DateTime de una cadena. Además, la zona horaria se usa en funciones que funcionan con la hora y la fecha si no recibieron la zona horaria en los parámetros de entrada. + +**Ejemplo** + +``` xml +Europe/Moscow +``` + +## Tcp\_port {#server_configuration_parameters-tcp_port} + +Puerto para comunicarse con clientes a través del protocolo TCP. + +**Ejemplo** + +``` xml +9000 +``` + +## Tcp\_port\_secure {#server_configuration_parameters-tcp_port_secure} + +Puerto TCP para una comunicación segura con los clientes. Úselo con [OpenSSL](#server_configuration_parameters-openssl) configuración. + +**Valores posibles** + +Entero positivo. + +**Valor predeterminado** + +``` xml +9440 +``` + +## mysql\_port {#server_configuration_parameters-mysql_port} + +Puerto para comunicarse con clientes a través del protocolo MySQL. + +**Valores posibles** + +Entero positivo. + +Ejemplo + +``` xml +9004 +``` + +## tmp\_path {#server-settings-tmp_path} + +Ruta de acceso a datos temporales para procesar consultas grandes. + +!!! note "Nota" + La barra diagonal es obligatoria. + +**Ejemplo** + +``` xml +/var/lib/clickhouse/tmp/ +``` + +## tmp\_policy {#server-settings-tmp-policy} + +Política de [`storage_configuration`](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) para almacenar archivos temporales. +Si no se establece [`tmp_path`](#server-settings-tmp_path) se utiliza, de lo contrario se ignora. + +!!! note "Nota" + - `move_factor` se ignora +- `keep_free_space_bytes` se ignora +- `max_data_part_size_bytes` se ignora +- debe tener exactamente un volumen en esa política + +## Uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} + +Tamaño de la memoria caché (en bytes) para los datos sin comprimir utilizados por los motores de [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md). + +Hay una caché compartida para el servidor. La memoria se asigna a pedido. La caché se usa si la opción [Use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) está habilitado. + +La caché sin comprimir es ventajosa para consultas muy cortas en casos individuales. + +**Ejemplo** + +``` xml +8589934592 +``` + +## user\_files\_path {#server_configuration_parameters-user_files_path} + +El directorio con archivos de usuario. Utilizado en la función de tabla [file()](../../sql-reference/table-functions/file.md). + +**Ejemplo** + +``` xml +/var/lib/clickhouse/user_files/ +``` + +## users\_config {#users-config} + +Ruta de acceso al archivo que contiene: + +- Configuraciones de usuario. +- Derechos de acceso. +- Perfiles de configuración. +- Configuración de cuota. + +**Ejemplo** + +``` xml +users.xml +``` + +## Zookeeper {#server-settings_zookeeper} + +Contiene la configuración que permite a ClickHouse interactuar con [ZooKeeper](http://zookeeper.apache.org/) Cluster. + +ClickHouse utiliza ZooKeeper para almacenar metadatos de réplicas cuando se utilizan tablas replicadas. Si no se utilizan tablas replicadas, se puede omitir esta sección de parámetros. + +Esta sección contiene los siguientes parámetros: + +- `node` — ZooKeeper endpoint. You can set multiple endpoints. + + Por ejemplo: + + + +``` xml + + example_host + 2181 + +``` + + The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. + +- `session_timeout` — Maximum timeout for the client session in milliseconds. +- `root` — The [Znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) que se utiliza como la raíz de los znodes utilizados por el servidor ClickHouse. Opcional. +- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. + +**Ejemplo de configuración** + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + 30000 + 10000 + + /path/to/zookeeper/node + + user:password + +``` + +**Ver también** + +- [Replicación](../../engines/table-engines/mergetree-family/replication.md) +- [Guía del programador ZooKeeper](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) + +## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} + +Método de almacenamiento para encabezados de parte de datos en ZooKeeper. + +Esta configuración sólo se aplica a `MergeTree` familia. Se puede especificar: + +- A nivel mundial en el [merge\_tree](#server_configuration_parameters-merge_tree) sección de la `config.xml` file. + + ClickHouse utiliza la configuración para todas las tablas del servidor. Puede cambiar la configuración en cualquier momento. Las tablas existentes cambian su comportamiento cuando cambia la configuración. + +- Para cada tabla. + + Al crear una tabla, especifique la correspondiente [ajuste del motor](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). El comportamiento de una tabla existente con esta configuración no cambia, incluso si la configuración global cambia. + +**Valores posibles** + +- 0 — Functionality is turned off. +- 1 — Functionality is turned on. + +Si `use_minimalistic_part_header_in_zookeeper = 1`, entonces [repetición](../../engines/table-engines/mergetree-family/replication.md) las tablas almacenan los encabezados de las partes de datos de forma compacta `znode`. Si la tabla contiene muchas columnas, este método de almacenamiento reduce significativamente el volumen de los datos almacenados en Zookeeper. + +!!! attention "Atención" + Después de aplicar `use_minimalistic_part_header_in_zookeeper = 1`, no puede degradar el servidor ClickHouse a una versión que no admite esta configuración. Tenga cuidado al actualizar ClickHouse en servidores de un clúster. No actualice todos los servidores a la vez. Es más seguro probar nuevas versiones de ClickHouse en un entorno de prueba o solo en unos pocos servidores de un clúster. + + Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. + +**Valor predeterminado:** 0. + +## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} + +Deshabilita la memoria caché DNS interna. Recomendado para operar ClickHouse en sistemas +con infraestructura que cambia frecuentemente como Kubernetes. + +**Valor predeterminado:** 0. + +## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} + +El período de actualización de las direcciones IP almacenadas en la caché DNS interna de ClickHouse (en segundos). +La actualización se realiza de forma asíncrona, en un subproceso del sistema separado. + +**Valor predeterminado**: 15. + +## access\_control\_path {#access_control_path} + +Ruta de acceso a una carpeta donde un servidor ClickHouse almacena configuraciones de usuario y rol creadas por comandos SQL. + +Valor predeterminado: `/var/lib/clickhouse/access/`. + +**Ver también** + +- [Control de acceso y gestión de cuentas](../access-rights.md#access-control) + +[Artículo Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/es/operations/server_configuration_parameters/index.md b/docs/es/operations/server_configuration_parameters/index.md deleted file mode 100644 index 5a323fec41f..00000000000 --- a/docs/es/operations/server_configuration_parameters/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Server Configuration Parameters -toc_priority: 54 -toc_title: "Implantaci\xF3n" ---- - -# Parámetros de configuración del servidor {#server-settings} - -Esta sección contiene descripciones de la configuración del servidor que no se puede cambiar en el nivel de sesión o consulta. - -Estos ajustes se almacenan en el `config.xml` archivo en el servidor ClickHouse. - -Otros ajustes se describen en el “[Configuración](../settings/index.md#settings)” apartado. - -Antes de estudiar la configuración, lea el [Archivos de configuración](../configuration_files.md#configuration_files) sección y tomar nota del uso de sustituciones (el `incl` y `optional` atributo). - -[Artículo Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/es/operations/server_configuration_parameters/settings.md b/docs/es/operations/server_configuration_parameters/settings.md deleted file mode 100644 index 3ec541c3acd..00000000000 --- a/docs/es/operations/server_configuration_parameters/settings.md +++ /dev/null @@ -1,872 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 57 -toc_title: "Configuraci\xF3n del servidor" ---- - -# Configuración del servidor {#server-settings} - -## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} - -El intervalo en segundos antes de volver a cargar los diccionarios integrados. - -ClickHouse recarga los diccionarios incorporados cada x segundos. Esto hace posible editar diccionarios “on the fly” sin reiniciar el servidor. - -Valor predeterminado: 3600. - -**Ejemplo** - -``` xml -3600 -``` - -## compresión {#server-settings-compression} - -Ajustes de compresión de datos para [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md)-mesas de motor. - -!!! warning "Advertencia" - No lo use si acaba de comenzar a usar ClickHouse. - -Plantilla de configuración: - -``` xml - - - ... - ... - ... - - ... - -``` - -`` campo: - -- `min_part_size` – The minimum size of a data part. -- `min_part_size_ratio` – The ratio of the data part size to the table size. -- `method` – Compression method. Acceptable values: `lz4` o `zstd`. - -Puede configurar múltiples `` apartado. - -Acciones cuando se cumplen las condiciones: - -- Si un elemento de datos coincide con un conjunto de condiciones, ClickHouse utiliza el método de compresión especificado. -- Si un elemento de datos coincide con varios conjuntos de condiciones, ClickHouse utiliza el primer conjunto de condiciones coincidente. - -Si no se cumplen condiciones para un elemento de datos, ClickHouse utiliza el `lz4` compresión. - -**Ejemplo** - -``` xml - - - 10000000000 - 0.01 - zstd - - -``` - -## default\_database {#default-database} - -La base de datos predeterminada. - -Para obtener una lista de bases de datos, [SHOW DATABASES](../../sql_reference/statements/show.md#show-databases) consulta. - -**Ejemplo** - -``` xml -default -``` - -## default\_profile {#default-profile} - -Perfil de configuración predeterminado. - -Los perfiles de configuración se encuentran en el archivo especificado en el parámetro `user_config`. - -**Ejemplo** - -``` xml -default -``` - -## Diccionarios\_config {#server_configuration_parameters-dictionaries_config} - -La ruta de acceso al archivo de configuración para diccionarios externos. - -Camino: - -- Especifique la ruta absoluta o la ruta relativa al archivo de configuración del servidor. -- La ruta puede contener comodines \* y ?. - -Ver también “[Diccionarios externos](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md)”. - -**Ejemplo** - -``` xml -*_dictionary.xml -``` - -## Diccionarios\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} - -La carga perezosa de los diccionarios. - -Si `true`, entonces cada diccionario es creado en el primer uso. Si se produce un error en la creación del diccionario, la función que estaba utilizando el diccionario produce una excepción. - -Si `false`, todos los diccionarios se crean cuando se inicia el servidor, y si hay un error, el servidor se apaga. - -El valor predeterminado es `true`. - -**Ejemplo** - -``` xml -true -``` - -## format\_schema\_path {#server_configuration_parameters-format_schema_path} - -La ruta de acceso al directorio con los esquemas para los datos de entrada, como los esquemas [CapnProto](../../interfaces/formats.md#capnproto) formato. - -**Ejemplo** - -``` xml - - format_schemas/ -``` - -## grafito {#server_configuration_parameters-graphite} - -Envío de datos a [Grafito](https://github.com/graphite-project). - -Configuración: - -- host – The Graphite server. -- port – The port on the Graphite server. -- interval – The interval for sending, in seconds. -- timeout – The timeout for sending data, in seconds. -- root\_path – Prefix for keys. -- metrics – Sending data from the [sistema.métricas](../../operations/system_tables.md#system_tables-metrics) tabla. -- events – Sending deltas data accumulated for the time period from the [sistema.evento](../../operations/system_tables.md#system_tables-events) tabla. -- events\_cumulative – Sending cumulative data from the [sistema.evento](../../operations/system_tables.md#system_tables-events) tabla. -- asynchronous\_metrics – Sending data from the [sistema.asynchronous\_metrics](../../operations/system_tables.md#system_tables-asynchronous_metrics) tabla. - -Puede configurar múltiples `` clausula. Por ejemplo, puede usar esto para enviar datos diferentes a intervalos diferentes. - -**Ejemplo** - -``` xml - - localhost - 42000 - 0.1 - 60 - one_min - true - true - false - true - -``` - -## graphite\_rollup {#server_configuration_parameters-graphite-rollup} - -Ajustes para reducir los datos de grafito. - -Para obtener más información, consulte [GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md). - -**Ejemplo** - -``` xml - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -## http\_port/https\_port {#http-porthttps-port} - -El puerto para conectarse al servidor a través de HTTP(s). - -Si `https_port` se especifica, [openSSL](#server_configuration_parameters-openssl) debe ser configurado. - -Si `http_port` se especifica, la configuración de OpenSSL se ignora incluso si está establecida. - -**Ejemplo** - -``` xml -0000 -``` - -## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} - -La página que se muestra de forma predeterminada al acceder al servidor HTTP de ClickHouse. -El valor predeterminado es “Ok.” (con un avance de línea al final) - -**Ejemplo** - -Abrir `https://tabix.io/` al acceder `http://localhost: http_port`. - -``` xml - -
]]> -
-``` - -## include\_from {#server_configuration_parameters-include_from} - -La ruta al archivo con sustituciones. - -Para obtener más información, consulte la sección “[Archivos de configuración](../configuration_files.md#configuration_files)”. - -**Ejemplo** - -``` xml -/etc/metrica.xml -``` - -## Interesante {#interserver-http-port} - -Puerto para el intercambio de datos entre servidores ClickHouse. - -**Ejemplo** - -``` xml -9009 -``` - -## Sistema abierto. {#interserver-http-host} - -El nombre de host que pueden utilizar otros servidores para acceder a este servidor. - -Si se omite, se define de la misma manera que el `hostname-f` comando. - -Útil para separarse de una interfaz de red específica. - -**Ejemplo** - -``` xml -example.yandex.ru -``` - -## interserver\_http\_credentials {#server-settings-interserver-http-credentials} - -El nombre de usuario y la contraseña utilizados para [replicación](../../engines/table_engines/mergetree_family/replication.md) con los motores Replicated\*. Estas credenciales sólo se utilizan para la comunicación entre réplicas y no están relacionadas con las credenciales de los clientes de ClickHouse. El servidor está comprobando estas credenciales para conectar réplicas y utiliza las mismas credenciales cuando se conecta a otras réplicas. Por lo tanto, estas credenciales deben establecerse igual para todas las réplicas de un clúster. -De forma predeterminada, la autenticación no se utiliza. - -Esta sección contiene los siguientes parámetros: - -- `user` — username. -- `password` — password. - -**Ejemplo** - -``` xml - - admin - 222 - -``` - -## keep\_alive\_timeout {#keep-alive-timeout} - -El número de segundos que ClickHouse espera las solicitudes entrantes antes de cerrar la conexión. El valor predeterminado es de 3 segundos. - -**Ejemplo** - -``` xml -3 -``` - -## listen\_host {#server_configuration_parameters-listen_host} - -Restricción en hosts de los que pueden provenir las solicitudes. Si desea que el servidor responda a todos ellos, especifique `::`. - -Ejemplos: - -``` xml -::1 -127.0.0.1 -``` - -## registrador {#server_configuration_parameters-logger} - -Configuración de registro. - -Claves: - -- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. -- log – The log file. Contains all the entries according to `level`. -- errorlog – Error log file. -- size – Size of the file. Applies to `log`y`errorlog`. Una vez que el archivo alcanza `size`, ClickHouse archiva y cambia el nombre, y crea un nuevo archivo de registro en su lugar. -- count – The number of archived log files that ClickHouse stores. - -**Ejemplo** - -``` xml - - trace - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 10 - -``` - -También se admite la escritura en el syslog. Config ejemplo: - -``` xml - - 1 - -
syslog.remote:10514
- myhost.local - LOG_LOCAL6 - syslog -
-
-``` - -Claves: - -- use\_syslog — Required setting if you want to write to the syslog. -- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. -- hostname — Optional. The name of the host that logs are sent from. -- facility — [La palabra clave syslog facility](https://en.wikipedia.org/wiki/Syslog#Facility) en letras mayúsculas con el “LOG\_” prefijo: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` y así sucesivamente). - Valor predeterminado: `LOG_USER` si `address` se especifica, `LOG_DAEMON otherwise.` -- format – Message format. Possible values: `bsd` y `syslog.` - -## macro {#macros} - -Sustituciones de parámetros para tablas replicadas. - -Se puede omitir si no se utilizan tablas replicadas. - -Para obtener más información, consulte la sección “[Creación de tablas replicadas](../../engines/table_engines/mergetree_family/replication.md)”. - -**Ejemplo** - -``` xml - -``` - -## Método de codificación de datos: {#server-mark-cache-size} - -Tamaño aproximado (en bytes) de la memoria caché de marcas utilizadas por los motores de [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md) familia. - -La memoria caché se comparte para el servidor y la memoria se asigna según sea necesario. El tamaño de la memoria caché debe ser al menos 5368709120. - -**Ejemplo** - -``` xml -5368709120 -``` - -## max\_concurrent\_queries {#max-concurrent-queries} - -El número máximo de solicitudes procesadas simultáneamente. - -**Ejemplo** - -``` xml -100 -``` - -## max\_connections {#max-connections} - -El número máximo de conexiones entrantes. - -**Ejemplo** - -``` xml -4096 -``` - -## max\_open\_files {#max-open-files} - -El número máximo de archivos abiertos. - -Predeterminada: `maximum`. - -Recomendamos el uso de esta opción en Mac OS X desde la `getrlimit()` la función devuelve un valor incorrecto. - -**Ejemplo** - -``` xml -262144 -``` - -## max\_table\_size\_to\_drop {#max-table-size-to-drop} - -Restricción en la eliminación de tablas. - -Si el tamaño de un [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md) tabla supera `max_table_size_to_drop` (en bytes), no puede eliminarlo usando una consulta DROP. - -Si aún necesita eliminar la tabla sin reiniciar el servidor ClickHouse, cree el `/flags/force_drop_table` y ejecute la consulta DROP. - -Valor predeterminado: 50 GB. - -El valor 0 significa que puede eliminar todas las tablas sin restricciones. - -**Ejemplo** - -``` xml -0 -``` - -## merge\_tree {#server_configuration_parameters-merge_tree} - -Ajuste fino para tablas en el [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md). - -Para obtener más información, vea MergeTreeSettings.h archivo de encabezado. - -**Ejemplo** - -``` xml - - 5 - -``` - -## openSSL {#server_configuration_parameters-openssl} - -Configuración cliente/servidor SSL. - -El soporte para SSL es proporcionado por el `libpoco` biblioteca. La interfaz se describe en el archivo [Nombre de la red inalámbrica (SSID):h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) - -Claves para la configuración del servidor/cliente: - -- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. -- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` contiene el certificado. -- caConfig – The path to the file or directory that contains trusted root certificates. -- verificationMode – The method for checking the node's certificates. Details are in the description of the [Contexto](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) clase. Valores posibles: `none`, `relaxed`, `strict`, `once`. -- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. -- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| -- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. -- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Valores aceptables: `true`, `false`. -- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. Este parámetro siempre se recomienda ya que ayuda a evitar problemas tanto si el servidor almacena en caché la sesión como si el cliente solicita el almacenamiento en caché. Valor predeterminado: `${application.name}`. -- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. -- sessionTimeout – Time for caching the session on the server. -- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. -- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. -- fips – Activates OpenSSL FIPS mode. Supported if the library's OpenSSL version supports FIPS. -- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. -- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . -- disableProtocols – Protocols that are not allowed to use. -- preferServerCiphers – Preferred server ciphers on the client. - -**Ejemplo de configuración:** - -``` xml - - - - /etc/clickhouse-server/server.crt - /etc/clickhouse-server/server.key - - /etc/clickhouse-server/dhparam.pem - none - true - true - sslv2,sslv3 - true - - - true - true - sslv2,sslv3 - true - - - - RejectCertificateHandler - - - -``` - -## part\_log {#server_configuration_parameters-part-log} - -Registro de eventos asociados con [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md). Por ejemplo, agregar o fusionar datos. Puede utilizar el registro para simular algoritmos de combinación y comparar sus características. Puede visualizar el proceso de fusión. - -Las consultas se registran en el [sistema.part\_log](../../operations/system_tables.md#system_tables-part-log) tabla, no en un archivo separado. Puede configurar el nombre de esta tabla en el `table` parámetro (ver más abajo). - -Utilice los siguientes parámetros para configurar el registro: - -- `database` – Name of the database. -- `table` – Name of the system table. -- `partition_by` – Sets a [clave de partición personalizada](../../engines/table_engines/mergetree_family/custom_partitioning_key.md). -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -**Ejemplo** - -``` xml - - system - part_log
- toMonday(event_date) - 7500 -
-``` - -## camino {#server_configuration_parameters-path} - -La ruta de acceso al directorio que contiene los datos. - -!!! note "Nota" - La barra diagonal es obligatoria. - -**Ejemplo** - -``` xml -/var/lib/clickhouse/ -``` - -## query\_log {#server_configuration_parameters-query-log} - -Configuración de las consultas de registro recibidas con [log\_queries=1](../settings/settings.md) configuración. - -Las consultas se registran en el [sistema.query\_log](../../operations/system_tables.md#system_tables-query_log) tabla, no en un archivo separado. Puede cambiar el nombre de la tabla en el `table` parámetro (ver más abajo). - -Utilice los siguientes parámetros para configurar el inicio de sesión: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [clave de partición personalizada](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) para una mesa. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -Si la tabla no existe, ClickHouse la creará. Si la estructura del registro de consultas cambió cuando se actualizó el servidor ClickHouse, se cambia el nombre de la tabla con la estructura anterior y se crea una nueva tabla automáticamente. - -**Ejemplo** - -``` xml - - system - query_log
- toMonday(event_date) - 7500 -
-``` - -## Sistema abierto. {#server_configuration_parameters-query-thread-log} - -Configuración de subprocesos de registro de consultas recibidas con [Log\_query\_threads = 1](../settings/settings.md#settings-log-query-threads) configuración. - -Las consultas se registran en el [sistema.Sistema abierto.](../../operations/system_tables.md#system_tables-query-thread-log) tabla, no en un archivo separado. Puede cambiar el nombre de la tabla en el `table` parámetro (ver más abajo). - -Utilice los siguientes parámetros para configurar el inicio de sesión: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [clave de partición personalizada](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) para una tabla del sistema. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -Si la tabla no existe, ClickHouse la creará. Si la estructura del registro de subprocesos de consulta cambió cuando se actualizó el servidor ClickHouse, se cambia el nombre de la tabla con la estructura anterior y se crea una nueva tabla automáticamente. - -**Ejemplo** - -``` xml - - system - query_thread_log
- toMonday(event_date) - 7500 -
-``` - -## trace\_log {#server_configuration_parameters-trace_log} - -La configuración para el [trace\_log](../../operations/system_tables.md#system_tables-trace_log) operación de la tabla del sistema. - -Parámetros: - -- `database` — Database for storing a table. -- `table` — Table name. -- `partition_by` — [Clave de partición personalizada](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) para una tabla del sistema. -- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. - -El archivo de configuración del servidor predeterminado `config.xml` contiene la siguiente sección de configuración: - -``` xml - - system - trace_log
- toYYYYMM(event_date) - 7500 -
-``` - -## query\_masking\_rules {#query-masking-rules} - -Reglas basadas en Regexp, que se aplicarán a las consultas, así como a todos los mensajes de registro antes de almacenarlos en los registros del servidor, -`system.query_log`, `system.text_log`, `system.processes` tabla, y en los registros enviados al cliente. Eso permite prevenir -fuga de datos sensible de consultas SQL (como nombres, correos electrónicos, -identificadores o números de tarjetas de crédito) a los registros. - -**Ejemplo** - -``` xml - - - hide SSN - (^|\D)\d{3}-\d{2}-\d{4}($|\D) - 000-00-0000 - - -``` - -Campos de configuración: -- `name` - nombre de la regla (opcional) -- `regexp` - Expresión regular compatible con RE2 (obligatoria) -- `replace` - cadena de sustitución para datos confidenciales (opcional, por defecto - seis asteriscos) - -Las reglas de enmascaramiento se aplican a toda la consulta (para evitar fugas de datos confidenciales de consultas mal formadas / no analizables). - -`system.events` la tabla tiene contador `QueryMaskingRulesMatch` que tienen un número total de coincidencias de reglas de enmascaramiento de consultas. - -Para consultas distribuidas, cada servidor debe configurarse por separado; de lo contrario, las subconsultas pasan a otros -los nodos se almacenarán sin enmascarar. - -## remote\_servers {#server-settings-remote-servers} - -Configuración de los clústeres utilizados por [Distribuido](../../engines/table_engines/special/distributed.md) motor de mesa y por el `cluster` función de la tabla. - -**Ejemplo** - -``` xml - -``` - -Para el valor de la `incl` atributo, consulte la sección “[Archivos de configuración](../configuration_files.md#configuration_files)”. - -**Ver también** - -- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) - -## Zona horaria {#server_configuration_parameters-timezone} - -La zona horaria del servidor. - -Especificado como un identificador de la IANA para la zona horaria UTC o la ubicación geográfica (por ejemplo, África/Abidjan). - -La zona horaria es necesaria para las conversiones entre los formatos String y DateTime cuando los campos DateTime se envían al formato de texto (impreso en la pantalla o en un archivo) y cuando se obtiene DateTime de una cadena. Además, la zona horaria se usa en funciones que funcionan con la hora y la fecha si no recibieron la zona horaria en los parámetros de entrada. - -**Ejemplo** - -``` xml -Europe/Moscow -``` - -## Tcp\_port {#server_configuration_parameters-tcp_port} - -Puerto para comunicarse con clientes a través del protocolo TCP. - -**Ejemplo** - -``` xml -9000 -``` - -## Tcp\_port\_secure {#server_configuration_parameters-tcp_port-secure} - -Puerto TCP para una comunicación segura con los clientes. Úselo con [OpenSSL](#server_configuration_parameters-openssl) configuración. - -**Valores posibles** - -Entero positivo. - -**Valor predeterminado** - -``` xml -9440 -``` - -## mysql\_port {#server_configuration_parameters-mysql_port} - -Puerto para comunicarse con clientes a través del protocolo MySQL. - -**Valores posibles** - -Entero positivo. - -Ejemplo - -``` xml -9004 -``` - -## tmp\_path {#server-settings-tmp_path} - -Ruta de acceso a datos temporales para procesar consultas grandes. - -!!! note "Nota" - La barra diagonal es obligatoria. - -**Ejemplo** - -``` xml -/var/lib/clickhouse/tmp/ -``` - -## tmp\_policy {#server-settings-tmp-policy} - -Política de [`storage_configuration`](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) para almacenar archivos temporales. -Si no se establece [`tmp_path`](#server-settings-tmp_path) se utiliza, de lo contrario se ignora. - -!!! note "Nota" - - `move_factor` se ignora -- `keep_free_space_bytes` se ignora -- `max_data_part_size_bytes` se ignora -- debe tener exactamente un volumen en esa política - -## Uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} - -Tamaño de la memoria caché (en bytes) para los datos sin comprimir utilizados por los motores de [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md). - -Hay una caché compartida para el servidor. La memoria se asigna a pedido. La caché se usa si la opción [Use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) está habilitado. - -La caché sin comprimir es ventajosa para consultas muy cortas en casos individuales. - -**Ejemplo** - -``` xml -8589934592 -``` - -## user\_files\_path {#server_configuration_parameters-user_files_path} - -El directorio con archivos de usuario. Utilizado en la función de tabla [file()](../../sql_reference/table_functions/file.md). - -**Ejemplo** - -``` xml -/var/lib/clickhouse/user_files/ -``` - -## users\_config {#users-config} - -Ruta de acceso al archivo que contiene: - -- Configuraciones de usuario. -- Derechos de acceso. -- Perfiles de configuración. -- Configuración de cuota. - -**Ejemplo** - -``` xml -users.xml -``` - -## Zookeeper {#server-settings_zookeeper} - -Contiene la configuración que permite a ClickHouse interactuar con [ZooKeeper](http://zookeeper.apache.org/) Cluster. - -ClickHouse utiliza ZooKeeper para almacenar metadatos de réplicas cuando se utilizan tablas replicadas. Si no se utilizan tablas replicadas, se puede omitir esta sección de parámetros. - -Esta sección contiene los siguientes parámetros: - -- `node` — ZooKeeper endpoint. You can set multiple endpoints. - - Por ejemplo: - - - -``` xml - - example_host - 2181 - -``` - - The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. - -- `session_timeout` — Maximum timeout for the client session in milliseconds. -- `root` — The [Znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) que se utiliza como la raíz de los znodes utilizados por el servidor ClickHouse. Opcional. -- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. - -**Ejemplo de configuración** - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - 30000 - 10000 - - /path/to/zookeeper/node - - user:password - -``` - -**Ver también** - -- [Replicación](../../engines/table_engines/mergetree_family/replication.md) -- [Guía del programador ZooKeeper](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) - -## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} - -Método de almacenamiento para encabezados de parte de datos en ZooKeeper. - -Esta configuración sólo se aplica a `MergeTree` familia. Se puede especificar: - -- A nivel mundial en el [merge\_tree](#server_configuration_parameters-merge_tree) sección de la `config.xml` file. - - ClickHouse utiliza la configuración para todas las tablas del servidor. Puede cambiar la configuración en cualquier momento. Las tablas existentes cambian su comportamiento cuando cambia la configuración. - -- Para cada tabla. - - Al crear una tabla, especifique la correspondiente [ajuste del motor](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). El comportamiento de una tabla existente con esta configuración no cambia, incluso si la configuración global cambia. - -**Valores posibles** - -- 0 — Functionality is turned off. -- 1 — Functionality is turned on. - -Si `use_minimalistic_part_header_in_zookeeper = 1`, entonces [repetición](../../engines/table_engines/mergetree_family/replication.md) las tablas almacenan los encabezados de las partes de datos de forma compacta `znode`. Si la tabla contiene muchas columnas, este método de almacenamiento reduce significativamente el volumen de los datos almacenados en Zookeeper. - -!!! attention "Atención" - Después de aplicar `use_minimalistic_part_header_in_zookeeper = 1`, no puede degradar el servidor ClickHouse a una versión que no admite esta configuración. Tenga cuidado al actualizar ClickHouse en servidores de un clúster. No actualice todos los servidores a la vez. Es más seguro probar nuevas versiones de ClickHouse en un entorno de prueba o solo en unos pocos servidores de un clúster. - - Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. - -**Valor predeterminado:** 0. - -## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} - -Deshabilita la memoria caché DNS interna. Recomendado para operar ClickHouse en sistemas -con infraestructura que cambia frecuentemente como Kubernetes. - -**Valor predeterminado:** 0. - -## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} - -El período de actualización de las direcciones IP almacenadas en la caché DNS interna de ClickHouse (en segundos). -La actualización se realiza de forma asíncrona, en un subproceso del sistema separado. - -**Valor predeterminado**: 15. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/es/operations/settings/constraints-on-settings.md b/docs/es/operations/settings/constraints-on-settings.md new file mode 100644 index 00000000000..fe385f6ddbb --- /dev/null +++ b/docs/es/operations/settings/constraints-on-settings.md @@ -0,0 +1,75 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 62 +toc_title: "Restricciones en la configuraci\xF3n" +--- + +# Restricciones en la configuración {#constraints-on-settings} + +Las restricciones en los ajustes se pueden definir en el `profiles` sección de la `user.xml` el archivo de configuración y prohíba a los usuarios cambiar algunos de los ajustes `SET` consulta. +Las restricciones se definen como las siguientes: + +``` xml + + + + + lower_boundary + + + upper_boundary + + + lower_boundary + upper_boundary + + + + + + + +``` + +Si el usuario intenta violar las restricciones, se lanza una excepción y la configuración no se cambia. +Se admiten tres tipos de restricciones: `min`, `max`, `readonly`. El `min` y `max` Las restricciones especifican los límites superior e inferior para una configuración numérica y se pueden usar en combinación. El `readonly` constraint especifica que el usuario no puede cambiar la configuración correspondiente en absoluto. + +**Ejemplo:** Dejar `users.xml` incluye líneas: + +``` xml + + + 10000000000 + 0 + ... + + + 5000000000 + 20000000000 + + + + + + + +``` + +Las siguientes consultas arrojan excepciones: + +``` sql +SET max_memory_usage=20000000001; +SET max_memory_usage=4999999999; +SET force_index_by_date=1; +``` + +``` text +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. +Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. +``` + +**Nota:** el `default` perfil tiene un manejo especial: todas las restricciones definidas para el `default` profile se convierten en las restricciones predeterminadas, por lo que restringen a todos los usuarios hasta que se anulan explícitamente para estos usuarios. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/constraints_on_settings/) diff --git a/docs/es/operations/settings/constraints_on_settings.md b/docs/es/operations/settings/constraints_on_settings.md deleted file mode 100644 index 498ce115ec5..00000000000 --- a/docs/es/operations/settings/constraints_on_settings.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 62 -toc_title: "Restricciones en la configuraci\xF3n" ---- - -# Restricciones en la configuración {#constraints-on-settings} - -Las restricciones en los ajustes se pueden definir en el `profiles` sección de la `user.xml` el archivo de configuración y prohíba a los usuarios cambiar algunos de los ajustes `SET` consulta. -Las restricciones se definen como las siguientes: - -``` xml - - - - - lower_boundary - - - upper_boundary - - - lower_boundary - upper_boundary - - - - - - - -``` - -Si el usuario intenta violar las restricciones, se lanza una excepción y la configuración no se cambia. -Se admiten tres tipos de restricciones: `min`, `max`, `readonly`. El `min` y `max` Las restricciones especifican los límites superior e inferior para una configuración numérica y se pueden usar en combinación. El `readonly` constraint especifica que el usuario no puede cambiar la configuración correspondiente en absoluto. - -**Ejemplo:** Dejar `users.xml` incluye líneas: - -``` xml - - - 10000000000 - 0 - ... - - - 5000000000 - 20000000000 - - - - - - - -``` - -Las siguientes consultas arrojan excepciones: - -``` sql -SET max_memory_usage=20000000001; -SET max_memory_usage=4999999999; -SET force_index_by_date=1; -``` - -``` text -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. -Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. -``` - -**Nota:** el `default` perfil tiene un manejo especial: todas las restricciones definidas para el `default` profile se convierten en las restricciones predeterminadas, por lo que restringen a todos los usuarios hasta que se anulan explícitamente para estos usuarios. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/constraints_on_settings/) diff --git a/docs/es/operations/settings/index.md b/docs/es/operations/settings/index.md index 7f135801098..37aab0a7e1b 100644 --- a/docs/es/operations/settings/index.md +++ b/docs/es/operations/settings/index.md @@ -1,14 +1,15 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Settings +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Configuraci\xF3n" toc_priority: 55 toc_title: "Implantaci\xF3n" --- -# Configuración {#settings} +# Configuración {#session-settings-intro} + +Hay varias maneras de realizar todos los ajustes descritos en esta sección de documentación. -Hay varias formas de realizar todos los ajustes que se describen a continuación. Los ajustes se configuran en capas, por lo que cada capa subsiguiente redefine los ajustes anteriores. Formas de configurar los ajustes, por orden de prioridad: diff --git a/docs/es/operations/settings/permissions-for-queries.md b/docs/es/operations/settings/permissions-for-queries.md new file mode 100644 index 00000000000..f9f669b876e --- /dev/null +++ b/docs/es/operations/settings/permissions-for-queries.md @@ -0,0 +1,61 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: Permisos para consultas +--- + +# Permisos para consultas {#permissions_for_queries} + +Las consultas en ClickHouse se pueden dividir en varios tipos: + +1. Leer consultas de datos: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. +2. Escribir consultas de datos: `INSERT`, `OPTIMIZE`. +3. Cambiar la consulta de configuración: `SET`, `USE`. +4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) consulta: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. +5. `KILL QUERY`. + +La siguiente configuración regula los permisos de usuario según el tipo de consulta: + +- [sólo lectura](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. +- [Método de codificación de datos:](#settings_allow_ddl) — Restricts permissions for DDL queries. + +`KILL QUERY` se puede realizar con cualquier configuración. + +## sólo lectura {#settings_readonly} + +Restringe los permisos para leer datos, escribir datos y cambiar las consultas de configuración. + +Vea cómo las consultas se dividen en tipos [arriba](#permissions_for_queries). + +Valores posibles: + +- 0 — All queries are allowed. +- 1 — Only read data queries are allowed. +- 2 — Read data and change settings queries are allowed. + +Después de configurar `readonly = 1` el usuario no puede cambiar `readonly` y `allow_ddl` configuración en la sesión actual. + +Cuando se utiliza el `GET` método en el [Interfaz HTTP](../../interfaces/http.md), `readonly = 1` se establece automáticamente. Para modificar los datos, `POST` método. + +Configuración `readonly = 1` prohibir al usuario cambiar todas las configuraciones. Hay una manera de prohibir al usuario +de cambiar sólo ajustes específicos, para más detalles ver [restricciones en la configuración](constraints-on-settings.md). + +Valor predeterminado: 0 + +## Método de codificación de datos: {#settings_allow_ddl} + +Permite o niega [DDL](https://en.wikipedia.org/wiki/Data_definition_language) consulta. + +Vea cómo las consultas se dividen en tipos [arriba](#permissions_for_queries). + +Valores posibles: + +- 0 — DDL queries are not allowed. +- 1 — DDL queries are allowed. + +No se puede ejecutar `SET allow_ddl = 1` si `allow_ddl = 0` para la sesión actual. + +Valor predeterminado: 1 + +[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/es/operations/settings/permissions_for_queries.md b/docs/es/operations/settings/permissions_for_queries.md deleted file mode 100644 index 8bb684bbe66..00000000000 --- a/docs/es/operations/settings/permissions_for_queries.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 58 -toc_title: Permisos para consultas ---- - -# Permisos para consultas {#permissions_for_queries} - -Las consultas en ClickHouse se pueden dividir en varios tipos: - -1. Leer consultas de datos: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. -2. Escribir consultas de datos: `INSERT`, `OPTIMIZE`. -3. Cambiar la consulta de configuración: `SET`, `USE`. -4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) consulta: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. -5. `KILL QUERY`. - -La siguiente configuración regula los permisos de usuario según el tipo de consulta: - -- [sólo lectura](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. -- [Método de codificación de datos:](#settings_allow_ddl) — Restricts permissions for DDL queries. - -`KILL QUERY` se puede realizar con cualquier configuración. - -## sólo lectura {#settings_readonly} - -Restringe los permisos para leer datos, escribir datos y cambiar las consultas de configuración. - -Vea cómo las consultas se dividen en tipos [arriba](#permissions_for_queries). - -Valores posibles: - -- 0 — All queries are allowed. -- 1 — Only read data queries are allowed. -- 2 — Read data and change settings queries are allowed. - -Después de configurar `readonly = 1` el usuario no puede cambiar `readonly` y `allow_ddl` configuración en la sesión actual. - -Cuando se utiliza el `GET` método en el [Interfaz HTTP](../../interfaces/http.md), `readonly = 1` se establece automáticamente. Para modificar los datos, `POST` método. - -Configuración `readonly = 1` prohibir al usuario cambiar todas las configuraciones. Hay una manera de prohibir al usuario -de cambiar sólo ajustes específicos, para más detalles ver [restricciones en la configuración](constraints_on_settings.md). - -Valor predeterminado: 0 - -## Método de codificación de datos: {#settings_allow_ddl} - -Permite o niega [DDL](https://en.wikipedia.org/wiki/Data_definition_language) consulta. - -Vea cómo las consultas se dividen en tipos [arriba](#permissions_for_queries). - -Valores posibles: - -- 0 — DDL queries are not allowed. -- 1 — DDL queries are allowed. - -No se puede ejecutar `SET allow_ddl = 1` si `allow_ddl = 0` para la sesión actual. - -Valor predeterminado: 1 - -[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/es/operations/settings/query-complexity.md b/docs/es/operations/settings/query-complexity.md new file mode 100644 index 00000000000..218952dff1f --- /dev/null +++ b/docs/es/operations/settings/query-complexity.md @@ -0,0 +1,301 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: Restricciones en la complejidad de consultas +--- + +# Restricciones en la complejidad de consultas {#restrictions-on-query-complexity} + +Las restricciones en la complejidad de la consulta forman parte de la configuración. +Se utilizan para proporcionar una ejecución más segura desde la interfaz de usuario. +Casi todas las restricciones solo se aplican a `SELECT`. Para el procesamiento de consultas distribuidas, las restricciones se aplican en cada servidor por separado. + +ClickHouse comprueba las restricciones para las partes de datos, no para cada fila. Significa que puede exceder el valor de restricción con el tamaño de la parte de datos. + +Restricciones en el “maximum amount of something” puede tomar el valor 0, lo que significa “unrestricted”. +La mayoría de las restricciones también tienen un ‘overflow\_mode’ establecer, lo que significa qué hacer cuando se excede el límite. +Puede tomar uno de dos valores: `throw` o `break`. Las restricciones en la agregación (group\_by\_overflow\_mode) también tienen el valor `any`. + +`throw` – Throw an exception (default). + +`break` – Stop executing the query and return the partial result, as if the source data ran out. + +`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don't add new keys to the set. + +## Método de codificación de datos: {#settings_max_memory_usage} + +La cantidad máxima de RAM que se utiliza para ejecutar una consulta en un único servidor. + +En el archivo de configuración predeterminado, el máximo es de 10 GB. + +La configuración no tiene en cuenta el volumen de memoria disponible ni el volumen total de memoria en la máquina. +La restricción se aplica a una sola consulta dentro de un único servidor. +Usted puede utilizar `SHOW PROCESSLIST` para ver el consumo de memoria actual para cada consulta. +Además, el consumo máximo de memoria se rastrea para cada consulta y se escribe en el registro. + +El uso de memoria no se supervisa para los estados de ciertas funciones agregadas. + +El uso de memoria no se realiza un seguimiento completo de los estados de las funciones agregadas `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` de `String` y `Array` argumento. + +El consumo de memoria también está restringido por los parámetros `max_memory_usage_for_user` y `max_memory_usage_for_all_queries`. + +## Max\_memory\_usage\_for\_user {#max-memory-usage-for-user} + +La cantidad máxima de RAM que se utilizará para ejecutar las consultas de un usuario en un único servidor. + +Los valores predeterminados se definen en [Configuración.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). De forma predeterminada, el importe no está restringido (`max_memory_usage_for_user = 0`). + +Ver también la descripción de [Método de codificación de datos:](#settings_max_memory_usage). + +## Todos los derechos reservados {#max-memory-usage-for-all-queries} + +La cantidad máxima de RAM que se utilizará para ejecutar todas las consultas en un único servidor. + +Los valores predeterminados se definen en [Configuración.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). De forma predeterminada, el importe no está restringido (`max_memory_usage_for_all_queries = 0`). + +Ver también la descripción de [Método de codificación de datos:](#settings_max_memory_usage). + +## ¿Qué puedes encontrar en Neodigit {#max-rows-to-read} + +Las siguientes restricciones se pueden verificar en cada bloque (en lugar de en cada fila). Es decir, las restricciones se pueden romper un poco. +Al ejecutar una consulta en varios subprocesos, las siguientes restricciones se aplican a cada subproceso por separado. + +Un número máximo de filas que se pueden leer de una tabla al ejecutar una consulta. + +## ¿Qué puedes encontrar en Neodigit {#max-bytes-to-read} + +Un número máximo de bytes (datos sin comprimir) que se pueden leer de una tabla al ejecutar una consulta. + +## Método de codificación de datos: {#read-overflow-mode} + +Qué hacer cuando el volumen de datos leídos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. + +## Método de codificación de datos: {#settings-max-rows-to-group-by} + +Un número máximo de claves únicas recibidas de la agregación. Esta configuración le permite limitar el consumo de memoria al agregar. + +## Grupo\_by\_overflow\_mode {#group-by-overflow-mode} + +Qué hacer cuando el número de claves únicas para la agregación excede el límite: ‘throw’, ‘break’, o ‘any’. Por defecto, throw. +Uso de la ‘any’ valor le permite ejecutar una aproximación de GROUP BY. La calidad de esta aproximación depende de la naturaleza estadística de los datos. + +## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} + +Habilita o deshabilita la ejecución de `GROUP BY` en la memoria externa. Ver [GROUP BY en memoria externa](../../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory). + +Valores posibles: + +- Volumen máximo de RAM (en bytes) que puede ser utilizado por el único [GROUP BY](../../sql-reference/statements/select/group-by.md#select-group-by-clause) operación. +- 0 — `GROUP BY` en la memoria externa deshabilitada. + +Valor predeterminado: 0. + +## Método de codificación de datos: {#max-rows-to-sort} + +Un número máximo de filas antes de ordenar. Esto le permite limitar el consumo de memoria al ordenar. + +## Método de codificación de datos: {#max-bytes-to-sort} + +Un número máximo de bytes antes de ordenar. + +## sort\_overflow\_mode {#sort-overflow-mode} + +Qué hacer si el número de filas recibidas antes de ordenar excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. + +## max\_result\_rows {#setting-max_result_rows} + +Límite en el número de filas en el resultado. También se comprueba si hay subconsultas y en servidores remotos cuando se ejecutan partes de una consulta distribuida. + +## max\_result\_bytes {#max-result-bytes} + +Límite en el número de bytes en el resultado. Lo mismo que el ajuste anterior. + +## result\_overflow\_mode {#result-overflow-mode} + +Qué hacer si el volumen del resultado excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. + +Utilizar ‘break’ es similar a usar LIMIT. `Break` interrumpe la ejecución sólo en el nivel de bloque. Esto significa que la cantidad de filas devueltas es mayor que [max\_result\_rows](#setting-max_result_rows), múltiplo de [max\_block\_size](settings.md#setting-max_block_size) y depende de [max\_threads](settings.md#settings-max_threads). + +Ejemplo: + +``` sql +SET max_threads = 3, max_block_size = 3333; +SET max_result_rows = 3334, result_overflow_mode = 'break'; + +SELECT * +FROM numbers_mt(100000) +FORMAT Null; +``` + +Resultado: + +``` text +6666 rows in set. ... +``` + +## max\_execution\_time {#max-execution-time} + +Tiempo máximo de ejecución de la consulta en segundos. +En este momento, no se comprueba una de las etapas de clasificación, o al fusionar y finalizar funciones agregadas. + +## timeout\_overflow\_mode {#timeout-overflow-mode} + +Qué hacer si la consulta se ejecuta más de ‘max\_execution\_time’: ‘throw’ o ‘break’. Por defecto, throw. + +## Método de codificación de datos: {#min-execution-speed} + +Velocidad de ejecución mínima en filas por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es menor, se produce una excepción. + +## Todos los derechos reservados {#min-execution-speed-bytes} + +Un número mínimo de bytes de ejecución por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es menor, se produce una excepción. + +## Max\_execution\_speed {#max-execution-speed} + +Un número máximo de filas de ejecución por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es alta, la velocidad de ejecución se reducirá. + +## Max\_execution\_speed\_bytes {#max-execution-speed-bytes} + +Un número máximo de bytes de ejecución por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es alta, la velocidad de ejecución se reducirá. + +## Tiempo de espera antes de comprobar\_ejecución\_velocidad {#timeout-before-checking-execution-speed} + +Comprueba que la velocidad de ejecución no sea demasiado lenta (no menos de ‘min\_execution\_speed’), después de que el tiempo especificado en segundos haya expirado. + +## Max\_columns\_to\_read {#max-columns-to-read} + +Un número máximo de columnas que se pueden leer de una tabla en una sola consulta. Si una consulta requiere leer un mayor número de columnas, produce una excepción. + +## max\_temporary\_columns {#max-temporary-columns} + +Un número máximo de columnas temporales que se deben mantener en la memoria RAM al mismo tiempo cuando se ejecuta una consulta, incluidas las columnas constantes. Si hay más columnas temporales que esto, arroja una excepción. + +## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} + +Lo mismo que ‘max\_temporary\_columns’, pero sin contar columnas constantes. +Tenga en cuenta que las columnas constantes se forman con bastante frecuencia cuando se ejecuta una consulta, pero requieren aproximadamente cero recursos informáticos. + +## max\_subquery\_depth {#max-subquery-depth} + +Profundidad máxima de anidamiento de subconsultas. Si las subconsultas son más profundas, se produce una excepción. De forma predeterminada, 100. + +## max\_pipeline\_depth {#max-pipeline-depth} + +Profundidad máxima de la tubería. Corresponde al número de transformaciones que realiza cada bloque de datos durante el procesamiento de consultas. Contado dentro de los límites de un único servidor. Si la profundidad de la canalización es mayor, se produce una excepción. Por defecto, 1000. + +## max\_ast\_depth {#max-ast-depth} + +Profundidad máxima de anidamiento de un árbol sintáctico de consulta. Si se supera, se produce una excepción. +En este momento, no se verifica durante el análisis, sino solo después de analizar la consulta. Es decir, se puede crear un árbol sintáctico demasiado profundo durante el análisis, pero la consulta fallará. Por defecto, 1000. + +## max\_ast\_elements {#max-ast-elements} + +Un número máximo de elementos en un árbol sintáctico de consulta. Si se supera, se produce una excepción. +De la misma manera que la configuración anterior, se verifica solo después de analizar la consulta. De forma predeterminada, 50.000. + +## Método de codificación de datos: {#max-rows-in-set} + +Un número máximo de filas para un conjunto de datos en la cláusula IN creada a partir de una subconsulta. + +## Método de codificación de datos: {#max-bytes-in-set} + +Número máximo de bytes (datos sin comprimir) utilizados por un conjunto en la cláusula IN creada a partir de una subconsulta. + +## set\_overflow\_mode {#set-overflow-mode} + +Qué hacer cuando la cantidad de datos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. + +## Método de codificación de datos: {#max-rows-in-distinct} + +Un número máximo de filas diferentes al usar DISTINCT. + +## Método de codificación de datos: {#max-bytes-in-distinct} + +Un número máximo de bytes utilizados por una tabla hash cuando se utiliza DISTINCT. + +## distinct\_overflow\_mode {#distinct-overflow-mode} + +Qué hacer cuando la cantidad de datos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. + +## max\_rows\_to\_transfer {#max-rows-to-transfer} + +Un número máximo de filas que se pueden pasar a un servidor remoto o guardar en una tabla temporal cuando se utiliza GLOBAL IN. + +## max\_bytes\_to\_transfer {#max-bytes-to-transfer} + +Un número máximo de bytes (datos sin comprimir) que se pueden pasar a un servidor remoto o guardar en una tabla temporal cuando se utiliza GLOBAL IN. + +## transfer\_overflow\_mode {#transfer-overflow-mode} + +Qué hacer cuando la cantidad de datos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. + +## Método de codificación de datos: {#settings-max_rows_in_join} + +Limita el número de filas de la tabla hash que se utiliza al unir tablas. + +Esta configuración se aplica a [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) operaciones y la [Unir](../../engines/table-engines/special/join.md) motor de mesa. + +Si una consulta contiene varias combinaciones, ClickHouse comprueba esta configuración para cada resultado intermedio. + +ClickHouse puede proceder con diferentes acciones cuando se alcanza el límite. Utilice el [join\_overflow\_mode](#settings-join_overflow_mode) configuración para elegir la acción. + +Valores posibles: + +- Entero positivo. +- 0 — Unlimited number of rows. + +Valor predeterminado: 0. + +## Método de codificación de datos: {#settings-max_bytes_in_join} + +Limita el tamaño en bytes de la tabla hash utilizada al unir tablas. + +Esta configuración se aplica a [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) operaciones y [Unirse al motor de tabla](../../engines/table-engines/special/join.md). + +Si la consulta contiene combinaciones, ClickHouse comprueba esta configuración para cada resultado intermedio. + +ClickHouse puede proceder con diferentes acciones cuando se alcanza el límite. Utilizar [join\_overflow\_mode](#settings-join_overflow_mode) para elegir la acción. + +Valores posibles: + +- Entero positivo. +- 0 — Memory control is disabled. + +Valor predeterminado: 0. + +## join\_overflow\_mode {#settings-join_overflow_mode} + +Define qué acción realiza ClickHouse cuando se alcanza cualquiera de los siguientes límites de combinación: + +- [Método de codificación de datos:](#settings-max_bytes_in_join) +- [Método de codificación de datos:](#settings-max_rows_in_join) + +Valores posibles: + +- `THROW` — ClickHouse throws an exception and breaks operation. +- `BREAK` — ClickHouse breaks operation and doesn't throw an exception. + +Valor predeterminado: `THROW`. + +**Ver también** + +- [Cláusula JOIN](../../sql-reference/statements/select/join.md#select-join) +- [Unirse al motor de tabla](../../engines/table-engines/special/join.md) + +## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} + +Limita el número máximo de particiones en un único bloque insertado. + +- Entero positivo. +- 0 — Unlimited number of partitions. + +Valor predeterminado: 100. + +**Detalles** + +Al insertar datos, ClickHouse calcula el número de particiones en el bloque insertado. Si el número de particiones es mayor que `max_partitions_per_insert_block`, ClickHouse lanza una excepción con el siguiente texto: + +> “Too many partitions for single INSERT block (more than” ¿Cómo puedo hacerlo? “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” + +[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/es/operations/settings/query_complexity.md b/docs/es/operations/settings/query_complexity.md deleted file mode 100644 index 243ce5a0297..00000000000 --- a/docs/es/operations/settings/query_complexity.md +++ /dev/null @@ -1,301 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 59 -toc_title: Restricciones en la complejidad de consultas ---- - -# Restricciones en la complejidad de consultas {#restrictions-on-query-complexity} - -Las restricciones en la complejidad de la consulta forman parte de la configuración. -Se utilizan para proporcionar una ejecución más segura desde la interfaz de usuario. -Casi todas las restricciones solo se aplican a `SELECT`. Para el procesamiento de consultas distribuidas, las restricciones se aplican en cada servidor por separado. - -ClickHouse comprueba las restricciones para las partes de datos, no para cada fila. Significa que puede exceder el valor de restricción con el tamaño de la parte de datos. - -Restricciones en el “maximum amount of something” puede tomar el valor 0, lo que significa “unrestricted”. -La mayoría de las restricciones también tienen un ‘overflow\_mode’ establecer, lo que significa qué hacer cuando se excede el límite. -Puede tomar uno de dos valores: `throw` o `break`. Las restricciones en la agregación (group\_by\_overflow\_mode) también tienen el valor `any`. - -`throw` – Throw an exception (default). - -`break` – Stop executing the query and return the partial result, as if the source data ran out. - -`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don't add new keys to the set. - -## Método de codificación de datos: {#settings_max_memory_usage} - -La cantidad máxima de RAM que se utiliza para ejecutar una consulta en un único servidor. - -En el archivo de configuración predeterminado, el máximo es de 10 GB. - -La configuración no tiene en cuenta el volumen de memoria disponible ni el volumen total de memoria en la máquina. -La restricción se aplica a una sola consulta dentro de un único servidor. -Usted puede utilizar `SHOW PROCESSLIST` para ver el consumo de memoria actual para cada consulta. -Además, el consumo máximo de memoria se rastrea para cada consulta y se escribe en el registro. - -El uso de memoria no se supervisa para los estados de ciertas funciones agregadas. - -El uso de memoria no se realiza un seguimiento completo de los estados de las funciones agregadas `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` de `String` y `Array` argumento. - -El consumo de memoria también está restringido por los parámetros `max_memory_usage_for_user` y `max_memory_usage_for_all_queries`. - -## Max\_memory\_usage\_for\_user {#max-memory-usage-for-user} - -La cantidad máxima de RAM que se utilizará para ejecutar las consultas de un usuario en un único servidor. - -Los valores predeterminados se definen en [Configuración.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). De forma predeterminada, el importe no está restringido (`max_memory_usage_for_user = 0`). - -Ver también la descripción de [Método de codificación de datos:](#settings_max_memory_usage). - -## Todos los derechos reservados. {#max-memory-usage-for-all-queries} - -La cantidad máxima de RAM que se utilizará para ejecutar todas las consultas en un único servidor. - -Los valores predeterminados se definen en [Configuración.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). De forma predeterminada, el importe no está restringido (`max_memory_usage_for_all_queries = 0`). - -Ver también la descripción de [Método de codificación de datos:](#settings_max_memory_usage). - -## ¿Qué puedes encontrar en Neodigit {#max-rows-to-read} - -Las siguientes restricciones se pueden verificar en cada bloque (en lugar de en cada fila). Es decir, las restricciones se pueden romper un poco. -Al ejecutar una consulta en varios subprocesos, las siguientes restricciones se aplican a cada subproceso por separado. - -Un número máximo de filas que se pueden leer de una tabla al ejecutar una consulta. - -## ¿Qué puedes encontrar en Neodigit {#max-bytes-to-read} - -Un número máximo de bytes (datos sin comprimir) que se pueden leer de una tabla al ejecutar una consulta. - -## Método de codificación de datos: {#read-overflow-mode} - -Qué hacer cuando el volumen de datos leídos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. - -## Método de codificación de datos: {#settings-max-rows-to-group-by} - -Un número máximo de claves únicas recibidas de la agregación. Esta configuración le permite limitar el consumo de memoria al agregar. - -## Grupo\_by\_overflow\_mode {#group-by-overflow-mode} - -Qué hacer cuando el número de claves únicas para la agregación excede el límite: ‘throw’, ‘break’, o ‘any’. Por defecto, throw. -Uso de la ‘any’ valor le permite ejecutar una aproximación de GROUP BY. La calidad de esta aproximación depende de la naturaleza estadística de los datos. - -## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} - -Habilita o deshabilita la ejecución de `GROUP BY` en la memoria externa. Ver [GROUP BY en memoria externa](../../sql_reference/statements/select.md#select-group-by-in-external-memory). - -Valores posibles: - -- Volumen máximo de RAM (en bytes) que puede ser utilizado por el único [GROUP BY](../../sql_reference/statements/select.md#select-group-by-clause) operación. -- 0 — `GROUP BY` en la memoria externa deshabilitada. - -Valor predeterminado: 0. - -## Método de codificación de datos: {#max-rows-to-sort} - -Un número máximo de filas antes de ordenar. Esto le permite limitar el consumo de memoria al ordenar. - -## Método de codificación de datos: {#max-bytes-to-sort} - -Un número máximo de bytes antes de ordenar. - -## sort\_overflow\_mode {#sort-overflow-mode} - -Qué hacer si el número de filas recibidas antes de ordenar excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. - -## max\_result\_rows {#setting-max_result_rows} - -Límite en el número de filas en el resultado. También se comprueba si hay subconsultas y en servidores remotos cuando se ejecutan partes de una consulta distribuida. - -## max\_result\_bytes {#max-result-bytes} - -Límite en el número de bytes en el resultado. Lo mismo que el ajuste anterior. - -## result\_overflow\_mode {#result-overflow-mode} - -Qué hacer si el volumen del resultado excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. - -Utilizar ‘break’ es similar a usar LIMIT. `Break` interrumpe la ejecución sólo en el nivel de bloque. Esto significa que la cantidad de filas devueltas es mayor que [max\_result\_rows](#setting-max_result_rows), múltiplo de [max\_block\_size](settings.md#setting-max_block_size) y depende de [max\_threads](settings.md#settings-max_threads). - -Ejemplo: - -``` sql -SET max_threads = 3, max_block_size = 3333; -SET max_result_rows = 3334, result_overflow_mode = 'break'; - -SELECT * -FROM numbers_mt(100000) -FORMAT Null; -``` - -Resultado: - -``` text -6666 rows in set. ... -``` - -## max\_execution\_time {#max-execution-time} - -Tiempo máximo de ejecución de la consulta en segundos. -En este momento, no se comprueba una de las etapas de clasificación, o al fusionar y finalizar funciones agregadas. - -## timeout\_overflow\_mode {#timeout-overflow-mode} - -Qué hacer si la consulta se ejecuta más de ‘max\_execution\_time’: ‘throw’ o ‘break’. Por defecto, throw. - -## Método de codificación de datos: {#min-execution-speed} - -Velocidad de ejecución mínima en filas por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es menor, se produce una excepción. - -## Todos los derechos reservados. {#min-execution-speed-bytes} - -Un número mínimo de bytes de ejecución por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es menor, se produce una excepción. - -## Max\_execution\_speed {#max-execution-speed} - -Un número máximo de filas de ejecución por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es alta, la velocidad de ejecución se reducirá. - -## Max\_execution\_speed\_bytes {#max-execution-speed-bytes} - -Un número máximo de bytes de ejecución por segundo. Comprobado en cada bloque de datos cuando ‘timeout\_before\_checking\_execution\_speed’ expirar. Si la velocidad de ejecución es alta, la velocidad de ejecución se reducirá. - -## Tiempo de espera antes de comprobar\_ejecución\_velocidad {#timeout-before-checking-execution-speed} - -Comprueba que la velocidad de ejecución no sea demasiado lenta (no menos de ‘min\_execution\_speed’), después de que el tiempo especificado en segundos haya expirado. - -## Max\_columns\_to\_read {#max-columns-to-read} - -Un número máximo de columnas que se pueden leer de una tabla en una sola consulta. Si una consulta requiere leer un mayor número de columnas, produce una excepción. - -## max\_temporary\_columns {#max-temporary-columns} - -Un número máximo de columnas temporales que se deben mantener en la memoria RAM al mismo tiempo cuando se ejecuta una consulta, incluidas las columnas constantes. Si hay más columnas temporales que esto, arroja una excepción. - -## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} - -Lo mismo que ‘max\_temporary\_columns’, pero sin contar columnas constantes. -Tenga en cuenta que las columnas constantes se forman con bastante frecuencia cuando se ejecuta una consulta, pero requieren aproximadamente cero recursos informáticos. - -## max\_subquery\_depth {#max-subquery-depth} - -Profundidad máxima de anidamiento de subconsultas. Si las subconsultas son más profundas, se produce una excepción. De forma predeterminada, 100. - -## max\_pipeline\_depth {#max-pipeline-depth} - -Profundidad máxima de la tubería. Corresponde al número de transformaciones que realiza cada bloque de datos durante el procesamiento de consultas. Contado dentro de los límites de un único servidor. Si la profundidad de la canalización es mayor, se produce una excepción. Por defecto, 1000. - -## max\_ast\_depth {#max-ast-depth} - -Profundidad máxima de anidamiento de un árbol sintáctico de consulta. Si se supera, se produce una excepción. -En este momento, no se verifica durante el análisis, sino solo después de analizar la consulta. Es decir, se puede crear un árbol sintáctico demasiado profundo durante el análisis, pero la consulta fallará. Por defecto, 1000. - -## max\_ast\_elements {#max-ast-elements} - -Un número máximo de elementos en un árbol sintáctico de consulta. Si se supera, se produce una excepción. -De la misma manera que la configuración anterior, se verifica solo después de analizar la consulta. De forma predeterminada, 50.000. - -## Método de codificación de datos: {#max-rows-in-set} - -Un número máximo de filas para un conjunto de datos en la cláusula IN creada a partir de una subconsulta. - -## Método de codificación de datos: {#max-bytes-in-set} - -Número máximo de bytes (datos sin comprimir) utilizados por un conjunto en la cláusula IN creada a partir de una subconsulta. - -## set\_overflow\_mode {#set-overflow-mode} - -Qué hacer cuando la cantidad de datos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. - -## Método de codificación de datos: {#max-rows-in-distinct} - -Un número máximo de filas diferentes al usar DISTINCT. - -## Método de codificación de datos: {#max-bytes-in-distinct} - -Un número máximo de bytes utilizados por una tabla hash cuando se utiliza DISTINCT. - -## distinct\_overflow\_mode {#distinct-overflow-mode} - -Qué hacer cuando la cantidad de datos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. - -## max\_rows\_to\_transfer {#max-rows-to-transfer} - -Un número máximo de filas que se pueden pasar a un servidor remoto o guardar en una tabla temporal cuando se utiliza GLOBAL IN. - -## max\_bytes\_to\_transfer {#max-bytes-to-transfer} - -Un número máximo de bytes (datos sin comprimir) que se pueden pasar a un servidor remoto o guardar en una tabla temporal cuando se utiliza GLOBAL IN. - -## transfer\_overflow\_mode {#transfer-overflow-mode} - -Qué hacer cuando la cantidad de datos excede uno de los límites: ‘throw’ o ‘break’. Por defecto, throw. - -## Método de codificación de datos: {#settings-max_rows_in_join} - -Limita el número de filas de la tabla hash que se utiliza al unir tablas. - -Esta configuración se aplica a [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) operaciones y la [Unir](../../engines/table_engines/special/join.md) motor de mesa. - -Si una consulta contiene varias combinaciones, ClickHouse comprueba esta configuración para cada resultado intermedio. - -ClickHouse puede proceder con diferentes acciones cuando se alcanza el límite. Utilice el [join\_overflow\_mode](#settings-join_overflow_mode) configuración para elegir la acción. - -Valores posibles: - -- Entero positivo. -- 0 — Unlimited number of rows. - -Valor predeterminado: 0. - -## Método de codificación de datos: {#settings-max_bytes_in_join} - -Limita el tamaño en bytes de la tabla hash utilizada al unir tablas. - -Esta configuración se aplica a [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) operaciones y [Unirse al motor de tabla](../../engines/table_engines/special/join.md). - -Si la consulta contiene combinaciones, ClickHouse comprueba esta configuración para cada resultado intermedio. - -ClickHouse puede proceder con diferentes acciones cuando se alcanza el límite. Utilizar [join\_overflow\_mode](#settings-join_overflow_mode) para elegir la acción. - -Valores posibles: - -- Entero positivo. -- 0 — Memory control is disabled. - -Valor predeterminado: 0. - -## join\_overflow\_mode {#settings-join_overflow_mode} - -Define qué acción realiza ClickHouse cuando se alcanza cualquiera de los siguientes límites de combinación: - -- [Método de codificación de datos:](#settings-max_bytes_in_join) -- [Método de codificación de datos:](#settings-max_rows_in_join) - -Valores posibles: - -- `THROW` — ClickHouse throws an exception and breaks operation. -- `BREAK` — ClickHouse breaks operation and doesn't throw an exception. - -Valor predeterminado: `THROW`. - -**Ver también** - -- [Cláusula JOIN](../../sql_reference/statements/select.md#select-join) -- [Unirse al motor de tabla](../../engines/table_engines/special/join.md) - -## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} - -Limita el número máximo de particiones en un único bloque insertado. - -- Entero positivo. -- 0 — Unlimited number of partitions. - -Valor predeterminado: 100. - -**Detalles** - -Al insertar datos, ClickHouse calcula el número de particiones en el bloque insertado. Si el número de particiones es mayor que `max_partitions_per_insert_block`, ClickHouse lanza una excepción con el siguiente texto: - -> “Too many partitions for single INSERT block (more than” ¿Cómo puedo hacerlo? “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” - -[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/es/operations/settings/settings-profiles.md b/docs/es/operations/settings/settings-profiles.md new file mode 100644 index 00000000000..3d96a2c8fba --- /dev/null +++ b/docs/es/operations/settings/settings-profiles.md @@ -0,0 +1,81 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "Perfiles de configuraci\xF3n" +--- + +# Perfiles de configuración {#settings-profiles} + +Un perfil de configuración es una colección de configuraciones agrupadas con el mismo nombre. + +!!! note "Información" + ClickHouse también es compatible [Flujo de trabajo controlado por SQL](../access-rights.md#access-control) para administrar perfiles de configuración. Recomendamos usarlo. + +Un perfil puede tener cualquier nombre. El perfil puede tener cualquier nombre. Puede especificar el mismo perfil para diferentes usuarios. Lo más importante que puede escribir en el perfil de configuración es `readonly=1`, que asegura el acceso de sólo lectura. + +Los perfiles de configuración pueden heredar unos de otros. Para usar la herencia, indique una o varias `profile` configuraciones antes de las demás configuraciones que se enumeran en el perfil. En caso de que se defina una configuración en diferentes perfiles, se utiliza la última definida. + +Para aplicar todos los ajustes de un perfil, establezca el `profile` configuración. + +Ejemplo: + +Instale el `web` perfil. + +``` sql +SET profile = 'web' +``` + +Los perfiles de configuración se declaran en el archivo de configuración del usuario. Esto suele ser `users.xml`. + +Ejemplo: + +``` xml + + + + + + 8 + + + + + 1000000000 + 100000000000 + + 1000000 + any + + 1000000 + 1000000000 + + 100000 + 100000000 + break + + 600 + 1000000 + 15 + + 25 + 100 + 50 + + 2 + 25 + 50 + 100 + + 1 + + +``` + +El ejemplo especifica dos perfiles: `default` y `web`. + +El `default` tiene un propósito especial: siempre debe estar presente y se aplica al iniciar el servidor. En otras palabras, el `default` perfil contiene la configuración predeterminada. + +El `web` profile es un perfil regular que se puede establecer utilizando el `SET` consulta o utilizando un parámetro URL en una consulta HTTP. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/es/operations/settings/settings-users.md b/docs/es/operations/settings/settings-users.md new file mode 100644 index 00000000000..2f767c959ae --- /dev/null +++ b/docs/es/operations/settings/settings-users.md @@ -0,0 +1,164 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "Configuraci\xF3n del usuario" +--- + +# Configuración del usuario {#user-settings} + +El `users` sección de la `user.xml` el archivo de configuración contiene la configuración del usuario. + +!!! note "Información" + ClickHouse también es compatible [Flujo de trabajo controlado por SQL](../access-rights.md#access-control) para la gestión de usuarios. Recomendamos usarlo. + +Estructura del `users` apartado: + +``` xml + + + + + + + + 0|1 + + + + + profile_name + + default + + + + + expression + + + + + + +``` + +### user\_name/contraseña {#user-namepassword} + +La contraseña se puede especificar en texto sin formato o en SHA256 (formato hexagonal). + +- Para asignar una contraseña en texto sin formato (**no se recomienda**), colóquelo en un `password` elemento. + + Por ejemplo, `qwerty`. La contraseña se puede dejar en blanco. + + + +- Para asignar una contraseña utilizando su hash SHA256, colóquela en un `password_sha256_hex` elemento. + + Por ejemplo, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. + + Ejemplo de cómo generar una contraseña desde el shell: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' + + La primera línea del resultado es la contraseña. La segunda línea es el hash SHA256 correspondiente. + + + +- Para la compatibilidad con los clientes MySQL, la contraseña se puede especificar en doble hash SHA1. Colóquelo en `password_double_sha1_hex` elemento. + + Por ejemplo, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. + + Ejemplo de cómo generar una contraseña desde el shell: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' + + La primera línea del resultado es la contraseña. La segunda línea es el hash SHA1 doble correspondiente. + +### access\_management {#access_management-user-setting} + +Esta configuración habilita deshabilita el uso de [control de acceso y gestión de cuentas](../access-rights.md#access-control) para el usuario. + +Valores posibles: + +- 0 — Disabled. +- 1 — Enabled. + +Valor predeterminado: 0. + +### user\_name/redes {#user-namenetworks} + +Lista de redes desde las que el usuario puede conectarse al servidor ClickHouse. + +Cada elemento de la lista puede tener una de las siguientes formas: + +- `` — IP address or network mask. + + Ejemplos: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. + +- `` — Hostname. + + Ejemplo: `example01.host.ru`. + + Para comprobar el acceso, se realiza una consulta DNS y todas las direcciones IP devueltas se comparan con la dirección del mismo nivel. + +- `` — Regular expression for hostnames. + + Ejemplo, `^example\d\d-\d\d-\d\.host\.ru$` + + Para comprobar el acceso, un [Consulta de DNS PTR](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) se realiza para la dirección del mismo nivel y luego se aplica la expresión regular especificada. A continuación, se realiza otra consulta DNS para los resultados de la consulta PTR y todas las direcciones recibidas se comparan con la dirección del mismo nivel. Recomendamos encarecidamente que regexp termine con $ . + +Todos los resultados de las solicitudes DNS se almacenan en caché hasta que el servidor se reinicia. + +**Ejemplos** + +Para abrir el acceso del usuario desde cualquier red, especifique: + +``` xml +::/0 +``` + +!!! warning "Advertencia" + No es seguro abrir el acceso desde cualquier red a menos que tenga un firewall configurado correctamente o el servidor no esté conectado directamente a Internet. + +Para abrir el acceso solo desde localhost, especifique: + +``` xml +::1 +127.0.0.1 +``` + +### user\_name/perfil {#user-nameprofile} + +Puede asignar un perfil de configuración para el usuario. Los perfiles de configuración se configuran en una sección separada del `users.xml` file. Para obtener más información, consulte [Perfiles de configuración](settings-profiles.md). + +### user\_name/cuota {#user-namequota} + +Las cuotas le permiten realizar un seguimiento o limitar el uso de recursos durante un período de tiempo. Las cuotas se configuran en el `quotas` +sección de la `users.xml` archivo de configuración. + +Puede asignar un conjunto de cuotas para el usuario. Para obtener una descripción detallada de la configuración de las cuotas, consulte [Cuota](../quotas.md#quotas). + +### nombre\_usuario/bases de datos {#user-namedatabases} + +En esta sección, puede limitar las filas devueltas por ClickHouse para `SELECT` consultas realizadas por el usuario actual, implementando así la seguridad básica a nivel de fila. + +**Ejemplo** + +La siguiente configuración obliga a que el usuario `user1` sólo puede ver las filas de `table1` como resultado de `SELECT` consultas, donde el valor de la `id` campo es 1000. + +``` xml + + + + + id = 1000 + + + + +``` + +El `filter` puede ser cualquier expresión que resulte en un [UInt8](../../sql-reference/data-types/int-uint.md)-tipo de valor. Por lo general, contiene comparaciones y operadores lógicos. Filas de `database_name.table1` donde los resultados del filtro a 0 no se devuelven para este usuario. El filtrado es incompatible con `PREWHERE` operaciones y desactiva `WHERE→PREWHERE` optimización. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/es/operations/settings/settings.md b/docs/es/operations/settings/settings.md index dd92922aec2..1989bb71036 100644 --- a/docs/es/operations/settings/settings.md +++ b/docs/es/operations/settings/settings.md @@ -1,15 +1,13 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 60 -toc_title: "Configuraci\xF3n" +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd --- # Configuración {#settings} ## distributed\_product\_mode {#distributed-product-mode} -Cambia el comportamiento de [subconsultas distribuidas](../../sql_reference/statements/select.md). +Cambia el comportamiento de [subconsultas distribuidas](../../sql-reference/operators/in.md). ClickHouse applies this setting when the query contains the product of distributed tables, i.e. when the query for a distributed table contains a non-GLOBAL subquery for the distributed table. @@ -18,7 +16,7 @@ Restricción: - Solo se aplica para las subconsultas IN y JOIN. - Solo si la sección FROM utiliza una tabla distribuida que contiene más de un fragmento. - Si la subconsulta se refiere a una tabla distribuida que contiene más de un fragmento. -- No se usa para un valor de tabla [remoto](../../sql_reference/table_functions/remote.md) función. +- No se usa para un valor de tabla [remoto](../../sql-reference/table-functions/remote.md) función. Valores posibles: @@ -53,7 +51,7 @@ Si `enable_optimize_predicate_expression = 0`, entonces el tiempo de ejecución ## fallback\_to\_stale\_replicas\_for\_distributed\_queries {#settings-fallback_to_stale_replicas_for_distributed_queries} -Fuerza una consulta a una réplica obsoleta si los datos actualizados no están disponibles. Ver [Replicación](../../engines/table_engines/mergetree_family/replication.md). +Fuerza una consulta a una réplica obsoleta si los datos actualizados no están disponibles. Ver [Replicación](../../engines/table-engines/mergetree-family/replication.md). ClickHouse selecciona la más relevante de las réplicas obsoletas de la tabla. @@ -67,7 +65,7 @@ Deshabilita la ejecución de consultas si el índice no se puede usar por fecha. Funciona con tablas de la familia MergeTree. -Si `force_index_by_date=1`, ClickHouse comprueba si la consulta tiene una condición de clave de fecha que se puede usar para restringir intervalos de datos. Si no hay una condición adecuada, arroja una excepción. Sin embargo, no comprueba si la condición reduce la cantidad de datos a leer. Por ejemplo, la condición `Date != ' 2000-01-01 '` es aceptable incluso cuando coincide con todos los datos de la tabla (es decir, ejecutar la consulta requiere un escaneo completo). Para obtener más información acerca de los intervalos de datos en las tablas MergeTree, vea [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md). +Si `force_index_by_date=1`, ClickHouse comprueba si la consulta tiene una condición de clave de fecha que se puede usar para restringir intervalos de datos. Si no hay una condición adecuada, arroja una excepción. Sin embargo, no comprueba si la condición reduce la cantidad de datos a leer. Por ejemplo, la condición `Date != ' 2000-01-01 '` es aceptable incluso cuando coincide con todos los datos de la tabla (es decir, ejecutar la consulta requiere un escaneo completo). Para obtener más información acerca de los intervalos de datos en las tablas MergeTree, vea [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md). ## force\_primary\_key {#force-primary-key} @@ -75,7 +73,7 @@ Deshabilita la ejecución de consultas si no es posible la indexación mediante Funciona con tablas de la familia MergeTree. -Si `force_primary_key=1`, ClickHouse comprueba si la consulta tiene una condición de clave principal que se puede usar para restringir rangos de datos. Si no hay una condición adecuada, arroja una excepción. Sin embargo, no comprueba si la condición reduce la cantidad de datos a leer. Para obtener más información acerca de los intervalos de datos en las tablas MergeTree, consulte [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md). +Si `force_primary_key=1`, ClickHouse comprueba si la consulta tiene una condición de clave principal que se puede usar para restringir rangos de datos. Si no hay una condición adecuada, arroja una excepción. Sin embargo, no comprueba si la condición reduce la cantidad de datos a leer. Para obtener más información acerca de los intervalos de datos en las tablas MergeTree, consulte [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md). ## Formato\_esquema {#format-schema} @@ -136,7 +134,7 @@ Valor predeterminado: 0. ## Nombre de la red inalámbrica (SSID): {#setting-max_http_get_redirects} -Limita el número máximo de saltos de redirección HTTP GET para [URL](../../engines/table_engines/special/url.md)-mesas de motor. La configuración se aplica a ambos tipos de tablas: las creadas por [CREATE TABLE](../../query_language/create/#create-table-query) consulta y por el [URL](../../sql_reference/table_functions/url.md) función de la tabla. +Limita el número máximo de saltos de redirección HTTP GET para [URL](../../engines/table-engines/special/url.md)-mesas de motor. La configuración se aplica a ambos tipos de tablas: las creadas por [CREATE TABLE](../../sql-reference/statements/create.md#create-table-query) consulta y por el [URL](../../sql-reference/table-functions/url.md) función de la tabla. Valores posibles: @@ -172,7 +170,7 @@ Si ambos `input_format_allow_errors_num` y `input_format_allow_errors_ratio` se ## input\_format\_values\_interpret\_expressions {#settings-input_format_values_interpret_expressions} -Habilita o deshabilita el analizador SQL completo si el analizador de secuencias rápidas no puede analizar los datos. Esta configuración sólo se utiliza para [Valor](../../interfaces/formats.md#data-format-values) formato en la inserción de datos. Para obtener más información sobre el análisis de sintaxis, consulte [Sintaxis](../../sql_reference/syntax.md) apartado. +Habilita o deshabilita el analizador SQL completo si el analizador de secuencias rápidas no puede analizar los datos. Esta configuración sólo se utiliza para [Valor](../../interfaces/formats.md#data-format-values) formato en la inserción de datos. Para obtener más información sobre el análisis de sintaxis, consulte [Sintaxis](../../sql-reference/syntax.md) apartado. Valores posibles: @@ -188,7 +186,7 @@ Valor predeterminado: 1. Ejemplo de uso -Inserte el [FechaHora](../../sql_reference/data_types/datetime.md) valor de tipo con los diferentes ajustes. +Inserte el [FechaHora](../../sql-reference/data-types/datetime.md) valor de tipo con los diferentes ajustes. ``` sql SET input_format_values_interpret_expressions = 0; @@ -222,17 +220,24 @@ Ok. ## input\_format\_values\_deduce\_templates\_of\_expressions {#settings-input_format_values_deduce_templates_of_expressions} -Habilita o deshabilita la deducción de plantilla para expresiones SQL en [Valor](../../interfaces/formats.md#data-format-values) formato. Permite analizar e interpretar expresiones en `Values` mucho más rápido si las expresiones en filas consecutivas tienen la misma estructura. ClickHouse intentará deducir la plantilla de una expresión, analizar las siguientes filas utilizando esta plantilla y evaluar la expresión en un lote de filas analizadas correctamente. Para la siguiente consulta: +Habilita o deshabilita la deducción de plantilla para expresiones SQL en [Valor](../../interfaces/formats.md#data-format-values) formato. Permite analizar e interpretar expresiones en `Values` mucho más rápido si las expresiones en filas consecutivas tienen la misma estructura. ClickHouse intenta deducir la plantilla de una expresión, analizar las siguientes filas utilizando esta plantilla y evaluar la expresión en un lote de filas analizadas correctamente. + +Valores posibles: + +- 0 — Disabled. +- 1 — Enabled. + +Valor predeterminado: 1. + +Para la siguiente consulta: ``` sql INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), (upper('Values')), ... ``` -- si `input_format_values_interpret_expressions=1` y `format_values_deduce_templates_of_expressions=0` Las expresiones se interpretarán por separado para cada fila (esto es muy lento para un gran número de filas) -- si `input_format_values_interpret_expressions=0` y `format_values_deduce_templates_of_expressions=1` Las expresiones en la primera, segunda y tercera filas se analizarán usando la plantilla `lower(String)` e interpretados juntos, la expresión es la cuarta fila se analizará con otra plantilla (`upper(String)`) -- si `input_format_values_interpret_expressions=1` y `format_values_deduce_templates_of_expressions=1` - lo mismo que en el caso anterior, pero también permite la alternativa a la interpretación de expresiones por separado si no es posible deducir la plantilla. - -Habilitado de forma predeterminada. +- Si `input_format_values_interpret_expressions=1` y `format_values_deduce_templates_of_expressions=0`, las expresiones se interpretan por separado para cada fila (esto es muy lento para un gran número de filas). +- Si `input_format_values_interpret_expressions=0` y `format_values_deduce_templates_of_expressions=1`, las expresiones en la primera, segunda y tercera filas se analizan usando la plantilla `lower(String)` e interpretados juntos, la expresión en la cuarta fila se analiza con otra plantilla (`upper(String)`). +- Si `input_format_values_interpret_expressions=1` y `format_values_deduce_templates_of_expressions=1`, lo mismo que en el caso anterior, pero también permite la alternativa a la interpretación de expresiones por separado si no es posible deducir la plantilla. ## Entrada\_format\_values\_accurate\_types\_of\_literals {#settings-input-format-values-accurate-types-of-literals} @@ -244,9 +249,17 @@ Esta configuración sólo se utiliza cuando `input_format_values_deduce_template (..., abs(-1), ...), -- Int64 literal ``` -Cuando esta configuración está habilitada, ClickHouse comprobará el tipo real de literal y utilizará una plantilla de expresión del tipo correspondiente. En algunos casos, puede ralentizar significativamente la evaluación de expresiones en `Values`. -When disabled, ClickHouse may use more general type for some literals (e.g. `Float64` o `Int64` en lugar de `UInt64` para `42`), pero puede causar problemas de desbordamiento y precisión. -Habilitado de forma predeterminada. +Valores posibles: + +- 0 — Disabled. + + In this case, ClickHouse may use a more general type for some literals (e.g., `Float64` o `Int64` en lugar de `UInt64` para `42`), pero puede causar problemas de desbordamiento y precisión. + +- 1 — Enabled. + + En este caso, ClickHouse comprueba el tipo real de literal y utiliza una plantilla de expresión del tipo correspondiente. En algunos casos, puede ralentizar significativamente la evaluación de expresiones en `Values`. + +Valor predeterminado: 1. ## Entrada\_format\_defaults\_for\_omitted\_fields {#session_settings-input_format_defaults_for_omitted_fields} @@ -274,7 +287,7 @@ Habilita o deshabilita el uso de valores predeterminados si los datos de entrada ## input\_format\_skip\_unknown\_fields {#settings-input-format-skip-unknown-fields} -Habilita o deshabilita saltarse la inserción de datos adicionales. +Habilita o deshabilita omitir la inserción de datos adicionales. Al escribir datos, ClickHouse produce una excepción si los datos de entrada contienen columnas que no existen en la tabla de destino. Si la omisión está habilitada, ClickHouse no inserta datos adicionales y no lanza una excepción. @@ -296,7 +309,7 @@ Valor predeterminado: 0. Habilita o deshabilita la inserción de datos JSON con objetos anidados. -Formatos compatibles: +Formatos soportados: - [JSONEachRow](../../interfaces/formats.md#jsoneachrow) @@ -311,7 +324,7 @@ Ver también: - [Uso de estructuras anidadas](../../interfaces/formats.md#jsoneachrow-nested) con el `JSONEachRow` formato. -## input\_format\_with\_names\_use\_header {#settings-input-format-with-names-use-header} +## Entrada\_format\_with\_names\_use\_header {#settings-input-format-with-names-use-header} Habilita o deshabilita la comprobación del orden de las columnas al insertar datos. @@ -333,7 +346,7 @@ Valor predeterminado: 1. Permite elegir un analizador de la representación de texto de fecha y hora. -La configuración no se aplica a [Funciones de fecha y hora](../../sql_reference/functions/date_time_functions.md). +La configuración no se aplica a [Funciones de fecha y hora](../../sql-reference/functions/date-time-functions.md). Valores posibles: @@ -349,12 +362,12 @@ Valor predeterminado: `'basic'`. Ver también: -- [Tipo de datos DateTime.](../../sql_reference/data_types/datetime.md) -- [Funciones para trabajar con fechas y horas.](../../sql_reference/functions/date_time_functions.md) +- [Tipo de datos DateTime.](../../sql-reference/data-types/datetime.md) +- [Funciones para trabajar con fechas y horas.](../../sql-reference/functions/date-time-functions.md) ## Por favor, introduzca su dirección de correo electrónico {#settings-join_default_strictness} -Establece el rigor predeterminado para [Cláusulas JOIN](../../sql_reference/statements/select.md#select-join). +Establece el rigor predeterminado para [Cláusulas JOIN](../../sql-reference/statements/select/join.md#select-join). Valores posibles: @@ -370,7 +383,7 @@ Valor predeterminado: `ALL`. Cambia el comportamiento de las operaciones de unión con `ANY` rigor. !!! warning "Atención" - Esta configuración sólo se aplica a `JOIN` operaciones con [Unir](../../engines/table_engines/special/join.md) mesas de motores. + Esta configuración sólo se aplica a `JOIN` operaciones con [Unir](../../engines/table-engines/special/join.md) mesas de motores. Valores posibles: @@ -381,18 +394,18 @@ Valor predeterminado: 0. Ver también: -- [Cláusula JOIN](../../sql_reference/statements/select.md#select-join) -- [Unirse al motor de tabla](../../engines/table_engines/special/join.md) +- [Cláusula JOIN](../../sql-reference/statements/select/join.md#select-join) +- [Unirse al motor de tabla](../../engines/table-engines/special/join.md) - [Por favor, introduzca su dirección de correo electrónico](#settings-join_default_strictness) -## Sistema abierto. {#join_use_nulls} +## Sistema abierto {#join_use_nulls} -Establece el tipo de [JOIN](../../sql_reference/statements/select.md) comportamiento. Al fusionar tablas, pueden aparecer celdas vacías. ClickHouse los rellena de manera diferente según esta configuración. +Establece el tipo de [JOIN](../../sql-reference/statements/select/join.md) comportamiento. Al fusionar tablas, pueden aparecer celdas vacías. ClickHouse los rellena de manera diferente según esta configuración. Valores posibles: - 0 — The empty cells are filled with the default value of the corresponding field type. -- 1 — `JOIN` se comporta de la misma manera que en SQL estándar. El tipo del campo correspondiente se convierte en [NULL](../../sql_reference/data_types/nullable.md#data_type-nullable), y las celdas vacías se llenan con [NULL](../../sql_reference/syntax.md). +- 1 — `JOIN` se comporta de la misma manera que en SQL estándar. El tipo del campo correspondiente se convierte en [NULL](../../sql-reference/data-types/nullable.md#data_type-nullable), y las celdas vacías se llenan con [NULL](../../sql-reference/syntax.md). Valor predeterminado: 0. @@ -412,7 +425,7 @@ Por defecto: 1,000,000. Solo funciona cuando se lee desde los motores MergeTree. ## merge\_tree\_min\_rows\_for\_concurrent\_read {#setting-merge-tree-min-rows-for-concurrent-read} -Si el número de filas que se leerán de un fichero [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md) tabla supera `merge_tree_min_rows_for_concurrent_read` luego ClickHouse intenta realizar una lectura simultánea de este archivo en varios hilos. +Si el número de filas que se leerán de un fichero [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md) mesa excede `merge_tree_min_rows_for_concurrent_read` luego ClickHouse intenta realizar una lectura simultánea de este archivo en varios hilos. Valores posibles: @@ -422,7 +435,7 @@ Valor predeterminado: 163840. ## merge\_tree\_min\_bytes\_for\_concurrent\_read {#setting-merge-tree-min-bytes-for-concurrent-read} -Si el número de bytes a leer de un archivo de un [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md)-La tabla del motor excede `merge_tree_min_bytes_for_concurrent_read`, entonces ClickHouse intenta leer simultáneamente este archivo en varios subprocesos. +Si el número de bytes a leer de un archivo de un [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md)-La tabla del motor excede `merge_tree_min_bytes_for_concurrent_read`, entonces ClickHouse intenta leer simultáneamente este archivo en varios subprocesos. Valor posible: @@ -464,7 +477,7 @@ Valor predeterminado: 8. Si ClickHouse debería leer más de `merge_tree_max_rows_to_use_cache` en una consulta, no usa la memoria caché de bloques sin comprimir. -La memoria caché de bloques sin comprimir almacena datos extraídos para consultas. ClickHouse utiliza esta memoria caché para acelerar las respuestas a pequeñas consultas repetidas. Esta configuración protege la memoria caché del deterioro de las consultas que leen una gran cantidad de datos. El [Uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) configuración del servidor define el tamaño de la memoria caché de bloques sin comprimir. +La memoria caché de bloques sin comprimir almacena datos extraídos para consultas. ClickHouse utiliza esta memoria caché para acelerar las respuestas a pequeñas consultas repetidas. Esta configuración protege la memoria caché del deterioro de las consultas que leen una gran cantidad de datos. El [Uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuración del servidor define el tamaño de la memoria caché de bloques sin comprimir. Valores posibles: @@ -476,7 +489,7 @@ Default value: 128 ✕ 8192. Si ClickHouse debería leer más de `merge_tree_max_bytes_to_use_cache` bytes en una consulta, no usa el caché de bloques sin comprimir. -La memoria caché de bloques sin comprimir almacena datos extraídos para consultas. ClickHouse utiliza esta memoria caché para acelerar las respuestas a pequeñas consultas repetidas. Esta configuración protege la memoria caché del deterioro de las consultas que leen una gran cantidad de datos. El [Uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) configuración del servidor define el tamaño de la memoria caché de bloques sin comprimir. +La memoria caché de bloques sin comprimir almacena datos extraídos para consultas. ClickHouse utiliza esta memoria caché para acelerar las respuestas a pequeñas consultas repetidas. Esta configuración protege la memoria caché del deterioro de las consultas que leen una gran cantidad de datos. El [Uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuración del servidor define el tamaño de la memoria caché de bloques sin comprimir. Valor posible: @@ -484,7 +497,7 @@ Valor posible: Valor predeterminado: 2013265920. -## Todos los derechos reservados. {#settings-min-bytes-to-use-direct-io} +## Todos los derechos reservados {#settings-min-bytes-to-use-direct-io} El volumen de datos mínimo necesario para utilizar el acceso directo de E/S al disco de almacenamiento. @@ -501,7 +514,7 @@ Valor predeterminado: 0. Configuración del registro de consultas. -Las consultas enviadas a ClickHouse con esta configuración se registran de acuerdo con las reglas [query\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-log) parámetro de configuración del servidor. +Las consultas enviadas a ClickHouse con esta configuración se registran de acuerdo con las reglas [query\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query-log) parámetro de configuración del servidor. Ejemplo: @@ -509,11 +522,29 @@ Ejemplo: log_queries=1 ``` +## Nombre de la red inalámbrica (SSID): {#settings-log-queries-min-type} + +`query_log` tipo mínimo para iniciar sesión. + +Valores posibles: +- `QUERY_START` (`=1`) +- `QUERY_FINISH` (`=2`) +- `EXCEPTION_BEFORE_START` (`=3`) +- `EXCEPTION_WHILE_PROCESSING` (`=4`) + +Valor predeterminado: `QUERY_START`. + +Se puede usar para limitar a qué entiries va `query_log`, digamos que eres interesante solo en errores, entonces puedes usar `EXCEPTION_WHILE_PROCESSING`: + +``` text +log_queries_min_type='EXCEPTION_WHILE_PROCESSING' +``` + ## Log\_query\_threads {#settings-log-query-threads} Configuración del registro de subprocesos de consulta. -Los subprocesos de consultas ejecutados por ClickHouse con esta configuración se registran de acuerdo con las reglas en el [Sistema abierto.](../server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) parámetro de configuración del servidor. +Los subprocesos de consultas ejecutados por ClickHouse con esta configuración se registran de acuerdo con las reglas en el [Sistema abierto.](../server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) parámetro de configuración del servidor. Ejemplo: @@ -533,9 +564,31 @@ Valor predeterminado: 1.048.576. El valor predeterminado es ligeramente más que `max_block_size`. La razón de esto se debe a que ciertos motores de mesa (`*MergeTree`) formar una parte de datos en el disco para cada bloque insertado, que es una entidad bastante grande. Similar, `*MergeTree` las tablas ordenan los datos durante la inserción y un tamaño de bloque lo suficientemente grande permiten clasificar más datos en la RAM. +## Nombre de la red inalámbrica (SSID): {#min-insert-block-size-rows} + +Establece el número mínimo de filas en el bloque que se pueden insertar en una tabla `INSERT` consulta. Los bloques de menor tamaño se aplastan en otros más grandes. + +Valores posibles: + +- Entero positivo. +- 0 — Squashing disabled. + +Valor predeterminado: 1048576. + +## Todos los derechos reservados {#min-insert-block-size-bytes} + +Establece el número mínimo de bytes en el bloque que se pueden insertar en una tabla `INSERT` consulta. Los bloques de menor tamaño se aplastan en otros más grandes. + +Valores posibles: + +- Entero positivo. +- 0 — Squashing disabled. + +Valor predeterminado: 268435456. + ## max\_replica\_delay\_for\_distributed\_queries {#settings-max_replica_delay_for_distributed_queries} -Deshabilita las réplicas rezagadas para consultas distribuidas. Ver [Replicación](../../engines/table_engines/mergetree_family/replication.md). +Deshabilita las réplicas rezagadas para consultas distribuidas. Ver [Replicación](../../engines/table-engines/mergetree-family/replication.md). Establece el tiempo en segundos. Si una réplica tiene un retraso superior al valor establecido, no se utiliza esta réplica. @@ -580,7 +633,7 @@ No confunda bloques para la compresión (un fragmento de memoria que consta de b ## Descripción del producto {#min-compress-block-size} -Para [Método de codificación de datos:](../../engines/table_engines/mergetree_family/mergetree.md)" tabla. Para reducir la latencia al procesar consultas, un bloque se comprime al escribir la siguiente marca si su tamaño es al menos ‘min\_compress\_block\_size’. De forma predeterminada, 65.536. +Para [Método de codificación de datos:](../../engines/table-engines/mergetree-family/mergetree.md)" tabla. Para reducir la latencia al procesar consultas, un bloque se comprime al escribir la siguiente marca si su tamaño es al menos ‘min\_compress\_block\_size’. De forma predeterminada, 65.536. El tamaño real del bloque, si los datos sin comprimir son menores que ‘max\_compress\_block\_size’, no es menor que este valor y no menor que el volumen de datos para una marca. @@ -658,7 +711,7 @@ Para obtener más información, consulte la sección “Extreme values”. ## Use\_uncompressed\_cache {#setting-use_uncompressed_cache} Si se debe usar una memoria caché de bloques sin comprimir. Acepta 0 o 1. De forma predeterminada, 0 (deshabilitado). -El uso de la memoria caché sin comprimir (solo para tablas de la familia MergeTree) puede reducir significativamente la latencia y aumentar el rendimiento cuando se trabaja con un gran número de consultas cortas. Habilite esta configuración para los usuarios que envían solicitudes cortas frecuentes. También preste atención al [Uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. +El uso de la memoria caché sin comprimir (solo para tablas de la familia MergeTree) puede reducir significativamente la latencia y aumentar el rendimiento cuando se trabaja con un gran número de consultas cortas. Habilite esta configuración para los usuarios que envían solicitudes cortas frecuentes. También preste atención al [Uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. Para consultas que leen al menos un volumen algo grande de datos (un millón de filas o más), la memoria caché sin comprimir se desactiva automáticamente para ahorrar espacio para consultas realmente pequeñas. Esto significa que puede mantener el ‘use\_uncompressed\_cache’ ajuste siempre establecido en 1. @@ -773,7 +826,7 @@ Si se compiló esta parte de la canalización, la consulta puede ejecutarse más ## min\_count\_to\_compile {#min-count-to-compile} -¿cuántas veces usar potencialmente un fragmento de código compilado antes de ejecutar la compilación? por defecto, 3. +¿Cuántas veces usar potencialmente un fragmento de código compilado antes de ejecutar la compilación? Por defecto, 3. For testing, the value can be set to 0: compilation runs synchronously and the query waits for the end of the compilation process before continuing execution. For all other cases, use values ​​starting with 1. Compilation normally takes about 5-10 seconds. Si el valor es 1 o más, la compilación se produce de forma asíncrona en un subproceso independiente. El resultado se utilizará tan pronto como esté listo, incluidas las consultas que se están ejecutando actualmente. @@ -827,7 +880,7 @@ Ver también: - [insert\_quorum\_timeout](#settings-insert_quorum_timeout) - [select\_sequential\_consistency](#settings-select_sequential_consistency) -## insert\_quorum\_timeout {#settings-insert_quorum-timeout} +## insert\_quorum\_timeout {#settings-insert_quorum_timeout} Escribir en tiempo de espera de quórum en segundos. Si el tiempo de espera ha pasado y aún no se ha realizado ninguna escritura, ClickHouse generará una excepción y el cliente debe repetir la consulta para escribir el mismo bloque en la misma réplica o en cualquier otra réplica. @@ -869,7 +922,7 @@ Valores posibles: Valor predeterminado: 1. -De forma predeterminada, los bloques insertados en tablas replicadas `INSERT` (consulte \[Replicación de datos\] (../engines/table\_engines/mergetree\_family/replication.md). +De forma predeterminada, los bloques insertados en tablas replicadas `INSERT` declaración se deduplican (ver [Replicación de datos](../../engines/table-engines/mergetree-family/replication.md)). ## deduplicate\_blocks\_in\_dependent\_materialized\_views {#settings-deduplicate-blocks-in-dependent-materialized-views} @@ -911,7 +964,7 @@ Valores posibles: Valor predeterminado: 0. -## Todos los derechos reservados. {#settings-max-network-bandwidth-for-user} +## Todos los derechos reservados {#settings-max-network-bandwidth-for-user} Limita la velocidad del intercambio de datos a través de la red en bytes por segundo. Esta configuración se aplica a todas las consultas que se ejecutan simultáneamente realizadas por un único usuario. @@ -922,7 +975,7 @@ Valores posibles: Valor predeterminado: 0. -## Todos los derechos reservados. {#settings-max-network-bandwidth-for-all-users} +## Todos los derechos reservados {#settings-max-network-bandwidth-for-all-users} Limita la velocidad a la que se intercambian datos a través de la red en bytes por segundo. Esta configuración se aplica a todas las consultas que se ejecutan simultáneamente en el servidor. @@ -935,15 +988,15 @@ Valor predeterminado: 0. ## count\_distinct\_implementation {#settings-count_distinct_implementation} -Especifica cuál de las `uniq*` se deben utilizar para realizar el [COUNT(DISTINCT …)](../../sql_reference/aggregate_functions/reference.md#agg_function-count) construcción. +Especifica cuál de las `uniq*` se deben utilizar para realizar el [COUNT(DISTINCT …)](../../sql-reference/aggregate-functions/reference.md#agg_function-count) construcción. Valores posibles: -- [uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq) -- [uniqCombined](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined) -- [UniqCombined64](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined64) -- [uniqHLL12](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqhll12) -- [uniqExact](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqexact) +- [uniq](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq) +- [uniqCombined](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined) +- [UniqCombined64](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined64) +- [uniqHLL12](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqhll12) +- [uniqExact](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqexact) Valor predeterminado: `uniqExact`. @@ -1008,7 +1061,7 @@ Valor predeterminado: 0. ## Optize\_throw\_if\_noop {#setting-optimize_throw_if_noop} -Habilita o deshabilita el lanzamiento de una excepción [OPTIMIZE](../../sql_reference/statements/misc.md#misc_operations-optimize) la consulta no realizó una fusión. +Habilita o deshabilita el lanzamiento de una excepción [OPTIMIZE](../../sql-reference/statements/misc.md#misc_operations-optimize) la consulta no realizó una fusión. Predeterminada, `OPTIMIZE` devuelve con éxito incluso si no hizo nada. Esta configuración le permite diferenciar estas situaciones y obtener el motivo en un mensaje de excepción. @@ -1028,7 +1081,7 @@ Controla la rapidez con la que se ponen a cero los errores en las tablas distrib Ver también: -- [Motor de tabla distribuido](../../engines/table_engines/special/distributed.md) +- [Motor de tabla distribuido](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_cap](#settings-distributed_replica_error_cap) ## distributed\_replica\_error\_cap {#settings-distributed_replica_error_cap} @@ -1040,12 +1093,12 @@ El recuento de errores de cada réplica está limitado a este valor, lo que impi Ver también: -- [Motor de tabla distribuido](../../engines/table_engines/special/distributed.md) +- [Motor de tabla distribuido](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_half\_life](#settings-distributed_replica_error_half_life) ## Distributed\_directory\_monitor\_sleep\_time\_ms {#distributed_directory_monitor_sleep_time_ms} -Intervalo base para el [Distribuido](../../engines/table_engines/special/distributed.md) motor de tabla para enviar datos. El intervalo real crece exponencialmente en caso de errores. +Intervalo base para el [Distribuido](../../engines/table-engines/special/distributed.md) motor de tabla para enviar datos. El intervalo real crece exponencialmente en caso de errores. Valores posibles: @@ -1055,7 +1108,7 @@ Valor predeterminado: 100 milisegundos. ## Distributed\_directory\_monitor\_max\_sleep\_time\_ms {#distributed_directory_monitor_max_sleep_time_ms} -Intervalo máximo para el [Distribuido](../../engines/table_engines/special/distributed.md) motor de tabla para enviar datos. Limita el crecimiento exponencial del intervalo establecido en el [Distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) configuración. +Intervalo máximo para el [Distribuido](../../engines/table-engines/special/distributed.md) motor de tabla para enviar datos. Limita el crecimiento exponencial del intervalo establecido en el [Distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) configuración. Valores posibles: @@ -1067,7 +1120,7 @@ Valor predeterminado: 30000 milisegundos (30 segundos). Habilita/deshabilita el envío de datos insertados en lotes. -Cuando el envío por lotes está habilitado, el [Distribuido](../../engines/table_engines/special/distributed.md) El motor de tabla intenta enviar varios archivos de datos insertados en una operación en lugar de enviarlos por separado. El envío por lotes mejora el rendimiento del clúster al utilizar mejor los recursos del servidor y de la red. +Cuando el envío por lotes está habilitado, el [Distribuido](../../engines/table-engines/special/distributed.md) El motor de tabla intenta enviar varios archivos de datos insertados en una operación en lugar de enviarlos por separado. El envío por lotes mejora el rendimiento del clúster al utilizar mejor los recursos del servidor y de la red. Valores posibles: @@ -1093,7 +1146,7 @@ Valor predeterminado: 0. ## query\_profiler\_real\_time\_period\_ns {#query_profiler_real_time_period_ns} -Establece el período para un temporizador de reloj real del [perfilador de consultas](../../operations/optimizing_performance/sampling_query_profiler.md). El temporizador de reloj real cuenta el tiempo del reloj de pared. +Establece el período para un temporizador de reloj real del [perfilador de consultas](../../operations/optimizing-performance/sampling-query-profiler.md). El temporizador de reloj real cuenta el tiempo del reloj de pared. Valores posibles: @@ -1106,17 +1159,17 @@ Valores posibles: - 0 para apagar el temporizador. -Tipo: [UInt64](../../sql_reference/data_types/int_uint.md). +Tipo: [UInt64](../../sql-reference/data-types/int-uint.md). Valor predeterminado: 1000000000 nanosegundos (una vez por segundo). Ver también: -- Tabla del sistema [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- Tabla del sistema [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## Los resultados de la prueba {#query_profiler_cpu_time_period_ns} -Establece el período para un temporizador de reloj de CPU [perfilador de consultas](../../operations/optimizing_performance/sampling_query_profiler.md). Este temporizador solo cuenta el tiempo de CPU. +Establece el período para un temporizador de reloj de CPU [perfilador de consultas](../../operations/optimizing-performance/sampling-query-profiler.md). Este temporizador solo cuenta el tiempo de CPU. Valores posibles: @@ -1129,17 +1182,17 @@ Valores posibles: - 0 para apagar el temporizador. -Tipo: [UInt64](../../sql_reference/data_types/int_uint.md). +Tipo: [UInt64](../../sql-reference/data-types/int-uint.md). Valor predeterminado: 1000000000 nanosegundos. Ver también: -- Tabla del sistema [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- Tabla del sistema [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## allow\_introspection\_functions {#settings-allow_introspection_functions} -Habilita deshabilita [funciones de introspecciones](../../sql_reference/functions/introspection.md) para la creación de perfiles de consultas. +Habilita deshabilita [funciones de introspecciones](../../sql-reference/functions/introspection.md) para la creación de perfiles de consultas. Valores posibles: @@ -1150,8 +1203,8 @@ Valor predeterminado: 0. **Ver también** -- [Analizador de consultas de muestreo](../optimizing_performance/sampling_query_profiler.md) -- Tabla del sistema [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- [Analizador de consultas de muestreo](../optimizing-performance/sampling-query-profiler.md) +- Tabla del sistema [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## input\_format\_parallel\_parsing {#input-format-parallel-parsing} @@ -1167,7 +1220,7 @@ Habilitar el análisis paralelo de los formatos de datos para preservar el orden El tamaño mínimo de fragmento en bytes, que cada subproceso analizará en paralelo. -## Sistema abierto. {#settings-output_format_avro_codec} +## Sistema abierto {#settings-output_format_avro_codec} Establece el códec de compresión utilizado para el archivo Avro de salida. @@ -1181,7 +1234,7 @@ Valores posibles: Valor predeterminado: `snappy` (si está disponible) o `deflate`. -## Sistema abierto. {#settings-output_format_avro_sync_interval} +## Sistema abierto {#settings-output_format_avro_sync_interval} Establece el tamaño mínimo de datos (en bytes) entre los marcadores de sincronización para el archivo Avro de salida. @@ -1191,7 +1244,7 @@ Valores posibles: 32 (32 bytes) - 1073741824 (1 GiB) Valor predeterminado: 32768 (32 KiB) -## Todos los derechos reservados. {#settings-format_avro_schema_registry_url} +## Todos los derechos reservados {#settings-format_avro_schema_registry_url} Establece la URL del Registro de esquemas confluentes para usar con [AvroConfluent](../../interfaces/formats.md#data-format-avro-confluent) formato @@ -1199,4 +1252,14 @@ Tipo: URL Valor predeterminado: Vacío +## background\_pool\_size {#background_pool_size} + +Establece el número de subprocesos que realizan operaciones en segundo plano en motores de tabla (por ejemplo, fusiona [Motor MergeTree](../../engines/table-engines/mergetree-family/index.md) tabla). Esta configuración se aplica al inicio del servidor ClickHouse y no se puede cambiar en una sesión de usuario. Al ajustar esta configuración, puede administrar la carga de la CPU y el disco. Un tamaño de grupo más pequeño utiliza menos recursos de CPU y disco, pero los procesos en segundo plano avanzan más lentamente, lo que eventualmente podría afectar el rendimiento de la consulta. + +Valores posibles: + +- Cualquier entero positivo. + +Valor predeterminado: 16. + [Artículo Original](https://clickhouse.tech/docs/en/operations/settings/settings/) diff --git a/docs/es/operations/settings/settings_profiles.md b/docs/es/operations/settings/settings_profiles.md deleted file mode 100644 index 21a73d6f9e1..00000000000 --- a/docs/es/operations/settings/settings_profiles.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 61 -toc_title: "Perfiles de configuraci\xF3n" ---- - -# Perfiles de configuración {#settings-profiles} - -Un perfil de configuración es una colección de configuraciones agrupadas con el mismo nombre. Cada usuario de ClickHouse tiene un perfil. -Para aplicar todos los ajustes de un perfil, establezca el `profile` configuración. - -Ejemplo: - -Instale el `web` perfil. - -``` sql -SET profile = 'web' -``` - -Los perfiles de configuración se declaran en el archivo de configuración del usuario. Esto suele ser `users.xml`. - -Ejemplo: - -``` xml - - - - - - 8 - - - - - 1000000000 - 100000000000 - - 1000000 - any - - 1000000 - 1000000000 - - 100000 - 100000000 - break - - 600 - 1000000 - 15 - - 25 - 100 - 50 - - 2 - 25 - 50 - 100 - - 1 - - -``` - -El ejemplo especifica dos perfiles: `default` y `web`. El `default` tiene un propósito especial: siempre debe estar presente y se aplica al iniciar el servidor. En otras palabras, el `default` perfil contiene la configuración predeterminada. El `web` profile es un perfil regular que se puede establecer utilizando el `SET` consulta o utilizando un parámetro URL en una consulta HTTP. - -Los perfiles de configuración pueden heredar unos de otros. Para usar la herencia, indique una o varias `profile` configuraciones antes de las demás configuraciones que se enumeran en el perfil. En caso de que se defina una configuración en diferentes perfiles, se utiliza la última definida. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/es/operations/settings/settings_users.md b/docs/es/operations/settings/settings_users.md deleted file mode 100644 index ec03b34ff50..00000000000 --- a/docs/es/operations/settings/settings_users.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 63 -toc_title: "Configuraci\xF3n del usuario" ---- - -# Configuración del usuario {#user-settings} - -El `users` sección de la `user.xml` el archivo de configuración contiene la configuración del usuario. - -Estructura del `users` apartado: - -``` xml - - - - - - - - - - - profile_name - - default - - - - - expression - - - - - - -``` - -### user\_name/contraseña {#user-namepassword} - -La contraseña se puede especificar en texto sin formato o en SHA256 (formato hexagonal). - -- Para asignar una contraseña en texto sin formato (**no se recomienda**), colóquelo en un `password` elemento. - - Por ejemplo, `qwerty`. La contraseña se puede dejar en blanco. - - - -- Para asignar una contraseña utilizando su hash SHA256, colóquela en un `password_sha256_hex` elemento. - - Por ejemplo, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. - - Ejemplo de cómo generar una contraseña desde el shell: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' - - La primera línea del resultado es la contraseña. La segunda línea es el hash SHA256 correspondiente. - - - -- Para la compatibilidad con los clientes MySQL, la contraseña se puede especificar en doble hash SHA1. Colóquelo en `password_double_sha1_hex` elemento. - - Por ejemplo, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. - - Ejemplo de cómo generar una contraseña desde el shell: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' - - La primera línea del resultado es la contraseña. La segunda línea es el hash SHA1 doble correspondiente. - -### user\_name/redes {#user-namenetworks} - -Lista de redes desde las que el usuario puede conectarse al servidor ClickHouse. - -Cada elemento de la lista puede tener una de las siguientes formas: - -- `` — IP address or network mask. - - Ejemplos: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. - -- `` — Hostname. - - Ejemplo: `example01.host.ru`. - - Para comprobar el acceso, se realiza una consulta DNS y todas las direcciones IP devueltas se comparan con la dirección del mismo nivel. - -- `` — Regular expression for hostnames. - - Ejemplo, `^example\d\d-\d\d-\d\.host\.ru$` - - Para comprobar el acceso, un [Consulta de DNS PTR](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) se realiza para la dirección del mismo nivel y luego se aplica la expresión regular especificada. A continuación, se realiza otra consulta DNS para los resultados de la consulta PTR y todas las direcciones recibidas se comparan con la dirección del mismo nivel. Recomendamos encarecidamente que regexp termine con $ . - -Todos los resultados de las solicitudes DNS se almacenan en caché hasta que el servidor se reinicia. - -**Ejemplos** - -Para abrir el acceso del usuario desde cualquier red, especifique: - -``` xml -::/0 -``` - -!!! warning "Advertencia" - No es seguro abrir el acceso desde cualquier red a menos que tenga un firewall configurado correctamente o el servidor no esté conectado directamente a Internet. - -Para abrir el acceso solo desde localhost, especifique: - -``` xml -::1 -127.0.0.1 -``` - -### user\_name/perfil {#user-nameprofile} - -Puede asignar un perfil de configuración para el usuario. Los perfiles de configuración se configuran en una sección separada del `users.xml` file. Para obtener más información, consulte [Perfiles de configuración](settings_profiles.md). - -### user\_name/cuota {#user-namequota} - -Las cuotas le permiten realizar un seguimiento o limitar el uso de recursos durante un período de tiempo. Las cuotas se configuran en el `quotas` -sección de la `users.xml` archivo de configuración. - -Puede asignar un conjunto de cuotas para el usuario. Para obtener una descripción detallada de la configuración de las cuotas, consulte [Cuota](../quotas.md#quotas). - -### nombre\_usuario/bases de datos {#user-namedatabases} - -En esta sección, puede limitar las filas devueltas por ClickHouse para `SELECT` consultas realizadas por el usuario actual, implementando así la seguridad básica a nivel de fila. - -**Ejemplo** - -La siguiente configuración obliga a que el usuario `user1` sólo puede ver las filas de `table1` como resultado de `SELECT` consultas, donde el valor de la `id` campo es 1000. - -``` xml - - - - - id = 1000 - - - - -``` - -El `filter` puede ser cualquier expresión que resulte en un [UInt8](../../sql_reference/data_types/int_uint.md)-tipo de valor. Por lo general, contiene comparaciones y operadores lógicos. Filas de `database_name.table1` donde los resultados del filtro a 0 no se devuelven para este usuario. El filtrado es incompatible con `PREWHERE` operaciones y desactiva `WHERE→PREWHERE` optimización. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/es/operations/system-tables.md b/docs/es/operations/system-tables.md new file mode 100644 index 00000000000..6b3ddf06bd9 --- /dev/null +++ b/docs/es/operations/system-tables.md @@ -0,0 +1,1168 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: Tablas del sistema +--- + +# Tablas del sistema {#system-tables} + +Las tablas del sistema se utilizan para implementar parte de la funcionalidad del sistema y para proporcionar acceso a información sobre cómo funciona el sistema. +No puede eliminar una tabla del sistema (pero puede realizar DETACH). +Las tablas del sistema no tienen archivos con datos en el disco o archivos con metadatos. El servidor crea todas las tablas del sistema cuando se inicia. +Las tablas del sistema son de solo lectura. +Están ubicados en el ‘system’ base. + +## sistema.asynchronous\_metrics {#system_tables-asynchronous_metrics} + +Contiene métricas que se calculan periódicamente en segundo plano. Por ejemplo, la cantidad de RAM en uso. + +Columna: + +- `metric` ([Cadena](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Float64](../sql-reference/data-types/float.md)) — Metric value. + +**Ejemplo** + +``` sql +SELECT * FROM system.asynchronous_metrics LIMIT 10 +``` + +``` text +┌─metric──────────────────────────────────┬──────value─┐ +│ jemalloc.background_thread.run_interval │ 0 │ +│ jemalloc.background_thread.num_runs │ 0 │ +│ jemalloc.background_thread.num_threads │ 0 │ +│ jemalloc.retained │ 422551552 │ +│ jemalloc.mapped │ 1682989056 │ +│ jemalloc.resident │ 1656446976 │ +│ jemalloc.metadata_thp │ 0 │ +│ jemalloc.metadata │ 10226856 │ +│ UncompressedCacheCells │ 0 │ +│ MarkCacheFiles │ 0 │ +└─────────────────────────────────────────┴────────────┘ +``` + +**Ver también** + +- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. +- [sistema.métricas](#system_tables-metrics) — Contains instantly calculated metrics. +- [sistema.evento](#system_tables-events) — Contains a number of events that have occurred. +- [sistema.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. + +## sistema.Cluster {#system-clusters} + +Contiene información sobre los clústeres disponibles en el archivo de configuración y los servidores que contienen. + +Columna: + +- `cluster` (String) — The cluster name. +- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. +- `shard_weight` (UInt32) — The relative weight of the shard when writing data. +- `replica_num` (UInt32) — The replica number in the shard, starting from 1. +- `host_name` (String) — The host name, as specified in the config. +- `host_address` (String) — The host IP address obtained from DNS. +- `port` (UInt16) — The port to use for connecting to the server. +- `user` (String) — The name of the user for connecting to the server. +- `errors_count` (UInt32): número de veces que este host no pudo alcanzar la réplica. +- `estimated_recovery_time` (UInt32): quedan segundos hasta que el recuento de errores de réplica se ponga a cero y se considere que vuelve a la normalidad. + +Tenga en cuenta que `errors_count` se actualiza una vez por consulta al clúster, pero `estimated_recovery_time` se vuelve a calcular bajo demanda. Entonces podría haber un caso distinto de cero `errors_count` y cero `estimated_recovery_time`, esa próxima consulta será cero `errors_count` e intente usar la réplica como si no tuviera errores. + +**Ver también** + +- [Motor de tabla distribuido](../engines/table-engines/special/distributed.md) +- [distributed\_replica\_error\_cap configuración](settings/settings.md#settings-distributed_replica_error_cap) +- [distributed\_replica\_error\_half\_life configuración](settings/settings.md#settings-distributed_replica_error_half_life) + +## sistema.columna {#system-columns} + +Contiene información sobre las columnas de todas las tablas. + +Puede utilizar esta tabla para obtener información similar a la [DESCRIBE TABLE](../sql-reference/statements/misc.md#misc-describe-table) consulta, pero para varias tablas a la vez. + +El `system.columns` tabla contiene las siguientes columnas (el tipo de columna se muestra entre corchetes): + +- `database` (String) — Database name. +- `table` (String) — Table name. +- `name` (String) — Column name. +- `type` (String) — Column type. +- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) para el valor predeterminado, o una cadena vacía si no está definida. +- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. +- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. +- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. +- `marks_bytes` (UInt64) — The size of marks, in bytes. +- `comment` (String) — Comment on the column, or an empty string if it is not defined. +- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. +- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. +- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. +- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. + +## sistema.colaborador {#system-contributors} + +Contiene información sobre los colaboradores. Todos los constributores en orden aleatorio. El orden es aleatorio en el momento de la ejecución de la consulta. + +Columna: + +- `name` (String) — Contributor (author) name from git log. + +**Ejemplo** + +``` sql +SELECT * FROM system.contributors LIMIT 10 +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +│ Max Vetrov │ +│ LiuYangkuan │ +│ svladykin │ +│ zamulla │ +│ Šimon Podlipský │ +│ BayoNet │ +│ Ilya Khomutov │ +│ Amy Krishnevsky │ +│ Loud_Scream │ +└──────────────────┘ +``` + +Para descubrirlo en la tabla, use una consulta: + +``` sql +SELECT * FROM system.contributors WHERE name='Olga Khvostikova' +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +└──────────────────┘ +``` + +## sistema.base {#system-databases} + +Esta tabla contiene una sola columna String llamada ‘name’ – the name of a database. +Cada base de datos que el servidor conoce tiene una entrada correspondiente en la tabla. +Esta tabla del sistema se utiliza para implementar el `SHOW DATABASES` consulta. + +## sistema.detached\_parts {#system_tables-detached_parts} + +Contiene información sobre piezas separadas de [Método de codificación de datos:](../engines/table-engines/mergetree-family/mergetree.md) tabla. El `reason` columna especifica por qué se separó la pieza. Para las piezas separadas por el usuario, el motivo está vacío. Tales partes se pueden unir con [ALTER TABLE ATTACH PARTITION\|PART](../sql-reference/statements/alter.md#alter_attach-partition) comando. Para obtener la descripción de otras columnas, consulte [sistema.parte](#system_tables-parts). Si el nombre de la pieza no es válido, los valores de algunas columnas pueden ser `NULL`. Tales partes se pueden eliminar con [ALTER TABLE DROP DETACHED PART](../sql-reference/statements/alter.md#alter_drop-detached). + +## sistema.diccionario {#system_tables-dictionaries} + +Contiene información sobre [diccionarios externos](../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +Columna: + +- `database` ([Cadena](../sql-reference/data-types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries. +- `name` ([Cadena](../sql-reference/data-types/string.md)) — [Nombre del diccionario](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md). +- `status` ([Enum8](../sql-reference/data-types/enum.md)) — Dictionary status. Possible values: + - `NOT_LOADED` — Dictionary was not loaded because it was not used. + - `LOADED` — Dictionary loaded successfully. + - `FAILED` — Unable to load the dictionary as a result of an error. + - `LOADING` — Dictionary is loading now. + - `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../sql-reference/statements/system.md#query_language-system-reload-dictionary) consulta, tiempo de espera, configuración del diccionario ha cambiado). + - `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now. +- `origin` ([Cadena](../sql-reference/data-types/string.md)) — Path to the configuration file that describes the dictionary. +- `type` ([Cadena](../sql-reference/data-types/string.md)) — Type of a dictionary allocation. [Almacenamiento de diccionarios en la memoria](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md). +- `key` — [Tipo de llave](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-key): Clave numérica ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) or Сomposite key ([Cadena](../sql-reference/data-types/string.md)) — form “(type 1, type 2, …, type n)”. +- `attribute.names` ([Matriz](../sql-reference/data-types/array.md)([Cadena](../sql-reference/data-types/string.md))) — Array of [nombres de atributos](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) proporcionada por el diccionario. +- `attribute.types` ([Matriz](../sql-reference/data-types/array.md)([Cadena](../sql-reference/data-types/string.md))) — Corresponding array of [tipos de atributos](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) que son proporcionados por el diccionario. +- `bytes_allocated` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary. +- `query_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot. +- `hit_rate` ([Float64](../sql-reference/data-types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache. +- `element_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of items stored in the dictionary. +- `load_factor` ([Float64](../sql-reference/data-types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). +- `source` ([Cadena](../sql-reference/data-types/string.md)) — Text describing the [fuente de datos](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md) para el diccionario. +- `lifetime_min` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Minimum [vida](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) del diccionario en la memoria, después de lo cual ClickHouse intenta volver a cargar el diccionario (si `invalidate_query` está configurado, entonces solo si ha cambiado). Establecer en segundos. +- `lifetime_max` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Maximum [vida](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) del diccionario en la memoria, después de lo cual ClickHouse intenta volver a cargar el diccionario (si `invalidate_query` está configurado, entonces solo si ha cambiado). Establecer en segundos. +- `loading_start_time` ([FechaHora](../sql-reference/data-types/datetime.md)) — Start time for loading the dictionary. +- `last_successful_update_time` ([FechaHora](../sql-reference/data-types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes. +- `loading_duration` ([Float32](../sql-reference/data-types/float.md)) — Duration of a dictionary loading. +- `last_exception` ([Cadena](../sql-reference/data-types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. + +**Ejemplo** + +Configurar el diccionario. + +``` sql +CREATE DICTIONARY dictdb.dict +( + `key` Int64 DEFAULT -1, + `value_default` String DEFAULT 'world', + `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) +LIFETIME(MIN 0 MAX 1) +LAYOUT(FLAT()) +``` + +Asegúrese de que el diccionario esté cargado. + +``` sql +SELECT * FROM system.dictionaries +``` + +``` text +┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ +│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ +└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ +``` + +## sistema.evento {#system_tables-events} + +Contiene información sobre el número de eventos que se han producido en el sistema. Por ejemplo, en la tabla, puede encontrar cuántos `SELECT` las consultas se procesaron desde que se inició el servidor ClickHouse. + +Columna: + +- `event` ([Cadena](../sql-reference/data-types/string.md)) — Event name. +- `value` ([UInt64](../sql-reference/data-types/int-uint.md)) — Number of events occurred. +- `description` ([Cadena](../sql-reference/data-types/string.md)) — Event description. + +**Ejemplo** + +``` sql +SELECT * FROM system.events LIMIT 5 +``` + +``` text +┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ +│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ +│ FileOpen │ 73 │ Number of files opened. │ +│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ +│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ +└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Ver también** + +- [sistema.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [sistema.métricas](#system_tables-metrics) — Contains instantly calculated metrics. +- [sistema.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. + +## sistema.función {#system-functions} + +Contiene información sobre funciones normales y agregadas. + +Columna: + +- `name`(`String`) – The name of the function. +- `is_aggregate`(`UInt8`) — Whether the function is aggregate. + +## sistema.graphite\_retentions {#system-graphite-retentions} + +Contiene información sobre los parámetros [graphite\_rollup](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) que se utilizan en tablas con [\*GraphiteMergeTree](../engines/table-engines/mergetree-family/graphitemergetree.md) motor. + +Columna: + +- `config_name` (Cadena) - `graphite_rollup` nombre del parámetro. +- `regexp` (Cadena) - Un patrón para el nombre de la métrica. +- `function` (String) - El nombre de la función de agregación. +- `age` (UInt64) - La edad mínima de los datos en segundos. +- `precision` (UInt64) - Cómo definir con precisión la edad de los datos en segundos. +- `priority` (UInt16) - Prioridad de patrón. +- `is_default` (UInt8) - Si el patrón es el predeterminado. +- `Tables.database` (Array(String)) - Matriz de nombres de tablas de base de datos que utilizan `config_name` parámetro. +- `Tables.table` (Array(String)) - Matriz de nombres de tablas que utilizan `config_name` parámetro. + +## sistema.fusionar {#system-merges} + +Contiene información sobre fusiones y mutaciones de piezas actualmente en proceso para tablas de la familia MergeTree. + +Columna: + +- `database` (String) — The name of the database the table is in. +- `table` (String) — Table name. +- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. +- `progress` (Float64) — The percentage of completed work from 0 to 1. +- `num_parts` (UInt64) — The number of pieces to be merged. +- `result_part_name` (String) — The name of the part that will be formed as the result of merging. +- `is_mutation` (UInt8) - 1 si este proceso es una mutación parte. +- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. +- `total_size_marks` (UInt64) — The total number of marks in the merged parts. +- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. +- `rows_read` (UInt64) — Number of rows read. +- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. +- `rows_written` (UInt64) — Number of rows written. + +## sistema.métricas {#system_tables-metrics} + +Contiene métricas que pueden calcularse instantáneamente o tener un valor actual. Por ejemplo, el número de consultas procesadas simultáneamente o el retraso de réplica actual. Esta tabla está siempre actualizada. + +Columna: + +- `metric` ([Cadena](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Int64](../sql-reference/data-types/int-uint.md)) — Metric value. +- `description` ([Cadena](../sql-reference/data-types/string.md)) — Metric description. + +La lista de métricas admitidas que puede encontrar en el [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) archivo fuente de ClickHouse. + +**Ejemplo** + +``` sql +SELECT * FROM system.metrics LIMIT 10 +``` + +``` text +┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 1 │ Number of executing queries │ +│ Merge │ 0 │ Number of executing background merges │ +│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ +│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ +│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ +│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ +│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ +│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ +│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ +│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ +└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Ver también** + +- [sistema.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [sistema.evento](#system_tables-events) — Contains a number of events that occurred. +- [sistema.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. + +## sistema.metric\_log {#system_tables-metric_log} + +Contiene el historial de valores de métricas de tablas `system.metrics` y `system.events`, periódicamente enjuagado al disco. +Para activar la recopilación de historial de métricas en `system.metric_log`, crear `/etc/clickhouse-server/config.d/metric_log.xml` con el siguiente contenido: + +``` xml + + + system + metric_log
+ 7500 + 1000 +
+
+``` + +**Ejemplo** + +``` sql +SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +event_date: 2020-02-18 +event_time: 2020-02-18 07:15:33 +milliseconds: 554 +ProfileEvent_Query: 0 +ProfileEvent_SelectQuery: 0 +ProfileEvent_InsertQuery: 0 +ProfileEvent_FileOpen: 0 +ProfileEvent_Seek: 0 +ProfileEvent_ReadBufferFromFileDescriptorRead: 1 +ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 +ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 +ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 +ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 +ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 +... +CurrentMetric_Query: 0 +CurrentMetric_Merge: 0 +CurrentMetric_PartMutation: 0 +CurrentMetric_ReplicatedFetch: 0 +CurrentMetric_ReplicatedSend: 0 +CurrentMetric_ReplicatedChecks: 0 +... +``` + +**Ver también** + +- [sistema.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [sistema.evento](#system_tables-events) — Contains a number of events that occurred. +- [sistema.métricas](#system_tables-metrics) — Contains instantly calculated metrics. +- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. + +## sistema.numero {#system-numbers} + +Esta tabla contiene una única columna UInt64 llamada ‘number’ que contiene casi todos los números naturales a partir de cero. +Puede usar esta tabla para pruebas, o si necesita hacer una búsqueda de fuerza bruta. +Las lecturas de esta tabla no están paralelizadas. + +## sistema.Números\_mt {#system-numbers-mt} + +Lo mismo que ‘system.numbers’ pero las lecturas están paralelizadas. Los números se pueden devolver en cualquier orden. +Se utiliza para pruebas. + +## sistema.una {#system-one} + +Esta tabla contiene una sola fila con una ‘dummy’ Columna UInt8 que contiene el valor 0. +Esta tabla se utiliza si una consulta SELECT no especifica la cláusula FROM. +Esto es similar a la tabla DUAL que se encuentra en otros DBMS. + +## sistema.parte {#system_tables-parts} + +Contiene información sobre partes de [Método de codificación de datos:](../engines/table-engines/mergetree-family/mergetree.md) tabla. + +Cada fila describe una parte de datos. + +Columna: + +- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql-reference/statements/alter.md#query_language_queries_alter) consulta. + + Formato: + + - `YYYYMM` para la partición automática por mes. + - `any_string` al particionar manualmente. + +- `name` (`String`) – Name of the data part. + +- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging. + +- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` por la granularidad del índice (generalmente 8192) (esta sugerencia no funciona para la granularidad adaptativa). + +- `rows` (`UInt64`) – The number of rows. + +- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. + +- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `marks_bytes` (`UInt64`) – The size of the file with marks. + +- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| + +- `remove_time` (`DateTime`) – The time when the data part became inactive. + +- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. + +- `min_date` (`Date`) – The minimum value of the date key in the data part. + +- `max_date` (`Date`) – The maximum value of the date key in the data part. + +- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. + +- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. + +- `partition_id` (`String`) – ID of the partition. + +- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. + +- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. + +- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. + +- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). + +- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. + +- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. + +- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../sql-reference/statements/alter.md#alter_freeze-partition) + +- `database` (`String`) – Name of the database. + +- `table` (`String`) – Name of the table. + +- `engine` (`String`) – Name of the table engine without parameters. + +- `path` (`String`) – Absolute path to the folder with data part files. + +- `disk` (`String`) – Name of a disk that stores the data part. + +- `hash_of_all_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) de archivos comprimidos. + +- `hash_of_uncompressed_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) de archivos sin comprimir (archivos con marcas, archivo de índice, etc.). + +- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) de datos en los archivos comprimidos como si estuvieran descomprimidos. + +- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. + +- `marks_size` (`UInt64`) – Alias for `marks_bytes`. + +## sistema.part\_log {#system_tables-part-log} + +El `system.part_log` se crea sólo si el [part\_log](server-configuration-parameters/settings.md#server_configuration_parameters-part-log) se especifica la configuración del servidor. + +Esta tabla contiene información sobre eventos que ocurrieron con [partes de datos](../engines/table-engines/mergetree-family/custom-partitioning-key.md) en el [Método de codificación de datos:](../engines/table-engines/mergetree-family/mergetree.md) tablas familiares, como agregar o fusionar datos. + +El `system.part_log` contiene las siguientes columnas: + +- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: + - `NEW_PART` — Inserting of a new data part. + - `MERGE_PARTS` — Merging of data parts. + - `DOWNLOAD_PART` — Downloading a data part. + - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql-reference/statements/alter.md#alter_detach-partition). + - `MUTATE_PART` — Mutating of a data part. + - `MOVE_PART` — Moving the data part from the one disk to another one. +- `event_date` (Date) — Event date. +- `event_time` (DateTime) — Event time. +- `duration_ms` (UInt64) — Duration. +- `database` (String) — Name of the database the data part is in. +- `table` (String) — Name of the table the data part is in. +- `part_name` (String) — Name of the data part. +- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ valor si la partición es por `tuple()`. +- `rows` (UInt64) — The number of rows in the data part. +- `size_in_bytes` (UInt64) — Size of the data part in bytes. +- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). +- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. +- `read_rows` (UInt64) — The number of rows was read during the merge. +- `read_bytes` (UInt64) — The number of bytes was read during the merge. +- `error` (UInt16) — The code number of the occurred error. +- `exception` (String) — Text message of the occurred error. + +El `system.part_log` se crea después de la primera inserción de datos `MergeTree` tabla. + +## sistema.procesa {#system_tables-processes} + +Esta tabla del sistema se utiliza para implementar el `SHOW PROCESSLIST` consulta. + +Columna: + +- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` usuario. El campo contiene el nombre de usuario para una consulta específica, no para una consulta que esta consulta inició. +- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` en el servidor de solicitud de consulta. +- `elapsed` (Float64) – The time in seconds since request execution started. +- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. +- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [Método de codificación de datos:](../operations/settings/query-complexity.md#settings_max_memory_usage) configuración. +- `query` (String) – The query text. For `INSERT`, no incluye los datos para insertar. +- `query_id` (String) – Query ID, if defined. + +## sistema.text\_log {#system-tables-text-log} + +Contiene entradas de registro. El nivel de registro que va a esta tabla se puede limitar con `text_log.level` configuración del servidor. + +Columna: + +- `event_date` (`Date`) - Fecha de la entrada. +- `event_time` (`DateTime`) - Hora de la entrada. +- `microseconds` (`UInt32`) - Microsegundos de la entrada. +- `thread_name` (String) — Name of the thread from which the logging was done. +- `thread_id` (UInt64) — OS thread ID. +- `level` (`Enum8`) - Nivel de entrada. + - `'Fatal' = 1` + - `'Critical' = 2` + - `'Error' = 3` + - `'Warning' = 4` + - `'Notice' = 5` + - `'Information' = 6` + - `'Debug' = 7` + - `'Trace' = 8` +- `query_id` (`String`) - ID de la consulta. +- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) +- `message` (`String`) - El mensaje en sí. +- `revision` (`UInt32`) - Revisión de ClickHouse. +- `source_file` (`LowCardinality(String)`) - Archivo de origen desde el que se realizó el registro. +- `source_line` (`UInt64`) - Línea de origen desde la que se realizó el registro. + +## sistema.query\_log {#system_tables-query_log} + +Contiene información sobre la ejecución de consultas. Para cada consulta, puede ver la hora de inicio del procesamiento, la duración del procesamiento, los mensajes de error y otra información. + +!!! note "Nota" + La tabla no contiene datos de entrada para `INSERT` consulta. + +ClickHouse crea esta tabla sólo si el [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) se especifica el parámetro server. Este parámetro establece las reglas de registro, como el intervalo de registro o el nombre de la tabla en la que se registrarán las consultas. + +Para habilitar el registro de consultas, [Log\_queries](settings/settings.md#settings-log-queries) parámetro a 1. Para obtener más información, consulte el [Configuración](settings/settings.md) apartado. + +El `system.query_log` tabla registra dos tipos de consultas: + +1. Consultas iniciales ejecutadas directamente por el cliente. +2. Consultas secundarias iniciadas por otras consultas (para la ejecución de consultas distribuidas). Para estos tipos de consultas, la información sobre las consultas principales se muestra en el `initial_*` columna. + +Columna: + +- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: + - `'QueryStart' = 1` — Successful start of query execution. + - `'QueryFinish' = 2` — Successful end of query execution. + - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. + - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. +- `event_date` (Date) — Query starting date. +- `event_time` (DateTime) — Query starting time. +- `query_start_time` (DateTime) — Start time of query execution. +- `query_duration_ms` (UInt64) — Duration of query execution. +- `read_rows` (UInt64) — Number of read rows. +- `read_bytes` (UInt64) — Number of read bytes. +- `written_rows` (UInt64) — For `INSERT` consultas, el número de filas escritas. Para otras consultas, el valor de la columna es 0. +- `written_bytes` (UInt64) — For `INSERT` consultas, el número de bytes escritos. Para otras consultas, el valor de la columna es 0. +- `result_rows` (UInt64) — Number of rows in the result. +- `result_bytes` (UInt64) — Number of bytes in the result. +- `memory_usage` (UInt64) — Memory consumption by the query. +- `query` (String) — Query string. +- `exception` (String) — Exception message. +- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. +- `is_initial_query` (UInt8) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` (String) — Name of the user who initiated the current query. +- `query_id` (String) — ID of the query. +- `address` (IPv6) — IP address that was used to make the query. +- `port` (UInt16) — The client port that was used to make the query. +- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` (String) — ID of the initial query (for distributed query execution). +- `initial_address` (IPv6) — IP address that the parent query was launched from. +- `initial_port` (UInt16) — The client port that was used to make the parent query. +- `interface` (UInt8) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` (String) — OS's username who runs [Casa de clics-cliente](../interfaces/cli.md). +- `client_hostname` (String) — Hostname of the client machine where the [Casa de clics-cliente](../interfaces/cli.md) o se ejecuta otro cliente TCP. +- `client_name` (String) — The [Casa de clics-cliente](../interfaces/cli.md) o otro nombre de cliente TCP. +- `client_revision` (UInt32) — Revision of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. +- `client_version_major` (UInt32) — Major version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. +- `client_version_minor` (UInt32) — Minor version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. +- `client_version_patch` (UInt32) — Patch component of the [Casa de clics-cliente](../interfaces/cli.md) o otra versión de cliente TCP. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` se utilizó el método. + - 2 — `POST` se utilizó el método. +- `http_user_agent` (String) — The `UserAgent` encabezado pasado en la solicitud HTTP. +- `quota_key` (String) — The “quota key” especificado en el [cuota](quotas.md) ajuste (ver `keyed`). +- `revision` (UInt32) — ClickHouse revision. +- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. +- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [sistema.evento](#system_tables-events) +- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` columna. +- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parámetro a 1. +- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` columna. + +Cada consulta crea una o dos filas en el `query_log` tabla, dependiendo del estado de la consulta: + +1. Si la ejecución de la consulta se realiza correctamente, se crean dos eventos con los tipos 1 y 2 (consulte `type` columna). +2. Si se produjo un error durante el procesamiento de la consulta, se crean dos eventos con los tipos 1 y 4. +3. Si se produjo un error antes de iniciar la consulta, se crea un solo evento con el tipo 3. + +De forma predeterminada, los registros se agregan a la tabla a intervalos de 7,5 segundos. Puede establecer este intervalo en el [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) configuración del servidor (consulte el `flush_interval_milliseconds` parámetro). Para vaciar los registros a la fuerza desde el búfer de memoria a la tabla, utilice `SYSTEM FLUSH LOGS` consulta. + +Cuando la tabla se elimina manualmente, se creará automáticamente sobre la marcha. Tenga en cuenta que se eliminarán todos los registros anteriores. + +!!! note "Nota" + El período de almacenamiento para los registros es ilimitado. Los registros no se eliminan automáticamente de la tabla. Debe organizar la eliminación de registros obsoletos usted mismo. + +Puede especificar una clave de partición arbitraria `system.query_log` mesa en el [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) configuración del servidor (consulte el `partition_by` parámetro). + +## sistema.Sistema abierto {#system_tables-query-thread-log} + +La tabla contiene información sobre cada subproceso de ejecución de consultas. + +ClickHouse crea esta tabla sólo si el [Sistema abierto.](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) se especifica el parámetro server. Este parámetro establece las reglas de registro, como el intervalo de registro o el nombre de la tabla en la que se registrarán las consultas. + +Para habilitar el registro de consultas, [Log\_query\_threads](settings/settings.md#settings-log-query-threads) parámetro a 1. Para obtener más información, consulte el [Configuración](settings/settings.md) apartado. + +Columna: + +- `event_date` (Date) — the date when the thread has finished execution of the query. +- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. +- `query_start_time` (DateTime) — Start time of query execution. +- `query_duration_ms` (UInt64) — Duration of query execution. +- `read_rows` (UInt64) — Number of read rows. +- `read_bytes` (UInt64) — Number of read bytes. +- `written_rows` (UInt64) — For `INSERT` consultas, el número de filas escritas. Para otras consultas, el valor de la columna es 0. +- `written_bytes` (UInt64) — For `INSERT` consultas, el número de bytes escritos. Para otras consultas, el valor de la columna es 0. +- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. +- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. +- `thread_name` (String) — Name of the thread. +- `thread_number` (UInt32) — Internal thread ID. +- `os_thread_id` (Int32) — OS thread ID. +- `master_thread_id` (UInt64) — OS initial ID of initial thread. +- `query` (String) — Query string. +- `is_initial_query` (UInt8) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` (String) — Name of the user who initiated the current query. +- `query_id` (String) — ID of the query. +- `address` (IPv6) — IP address that was used to make the query. +- `port` (UInt16) — The client port that was used to make the query. +- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` (String) — ID of the initial query (for distributed query execution). +- `initial_address` (IPv6) — IP address that the parent query was launched from. +- `initial_port` (UInt16) — The client port that was used to make the parent query. +- `interface` (UInt8) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` (String) — OS's username who runs [Casa de clics-cliente](../interfaces/cli.md). +- `client_hostname` (String) — Hostname of the client machine where the [Casa de clics-cliente](../interfaces/cli.md) o se ejecuta otro cliente TCP. +- `client_name` (String) — The [Casa de clics-cliente](../interfaces/cli.md) o otro nombre de cliente TCP. +- `client_revision` (UInt32) — Revision of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. +- `client_version_major` (UInt32) — Major version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. +- `client_version_minor` (UInt32) — Minor version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. +- `client_version_patch` (UInt32) — Patch component of the [Casa de clics-cliente](../interfaces/cli.md) o otra versión de cliente TCP. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` se utilizó el método. + - 2 — `POST` se utilizó el método. +- `http_user_agent` (String) — The `UserAgent` encabezado pasado en la solicitud HTTP. +- `quota_key` (String) — The “quota key” especificado en el [cuota](quotas.md) ajuste (ver `keyed`). +- `revision` (UInt32) — ClickHouse revision. +- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [sistema.evento](#system_tables-events) +- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` columna. + +De forma predeterminada, los registros se agregan a la tabla a intervalos de 7,5 segundos. Puede establecer este intervalo en el [Sistema abierto.](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) configuración del servidor (consulte el `flush_interval_milliseconds` parámetro). Para vaciar los registros a la fuerza desde el búfer de memoria a la tabla, utilice `SYSTEM FLUSH LOGS` consulta. + +Cuando la tabla se elimina manualmente, se creará automáticamente sobre la marcha. Tenga en cuenta que se eliminarán todos los registros anteriores. + +!!! note "Nota" + El período de almacenamiento para los registros es ilimitado. Los registros no se eliminan automáticamente de la tabla. Debe organizar la eliminación de registros obsoletos usted mismo. + +Puede especificar una clave de partición arbitraria `system.query_thread_log` mesa en el [Sistema abierto.](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) configuración del servidor (consulte el `partition_by` parámetro). + +## sistema.trace\_log {#system_tables-trace_log} + +Contiene seguimientos de pila recopilados por el generador de perfiles de consultas de muestreo. + +ClickHouse crea esta tabla cuando el [trace\_log](server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) se establece la sección de configuración del servidor. También el [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) y [Los resultados de la prueba](settings/settings.md#query_profiler_cpu_time_period_ns) los ajustes deben establecerse. + +Para analizar los registros, utilice el `addressToLine`, `addressToSymbol` y `demangle` funciones de inspección. + +Columna: + +- `event_date` ([Fecha](../sql-reference/data-types/date.md)) — Date of sampling moment. + +- `event_time` ([FechaHora](../sql-reference/data-types/datetime.md)) — Timestamp of the sampling moment. + +- `timestamp_ns` ([UInt64](../sql-reference/data-types/int-uint.md)) — Timestamp of the sampling moment in nanoseconds. + +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ClickHouse server build revision. + + Cuando se conecta al servidor por `clickhouse-client`, ves la cadena similar a `Connected to ClickHouse server version 19.18.1 revision 54429.`. Este campo contiene el `revision`, pero no el `version` de un servidor. + +- `timer_type` ([Enum8](../sql-reference/data-types/enum.md)) — Timer type: + + - `Real` representa el tiempo del reloj de pared. + - `CPU` representa el tiempo de CPU. + +- `thread_number` ([UInt32](../sql-reference/data-types/int-uint.md)) — Thread identifier. + +- `query_id` ([Cadena](../sql-reference/data-types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) tabla del sistema. + +- `trace` ([Matriz (UInt64)](../sql-reference/data-types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. + +**Ejemplo** + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-15 +event_time: 2019-11-15 15:09:38 +revision: 54428 +timer_type: Real +thread_number: 48 +query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 +trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] +``` + +## sistema.Replica {#system_tables-replicas} + +Contiene información y estado de las tablas replicadas que residen en el servidor local. +Esta tabla se puede utilizar para el monitoreo. La tabla contiene una fila para cada tabla Replicated\*. + +Ejemplo: + +``` sql +SELECT * +FROM system.replicas +WHERE table = 'visits' +FORMAT Vertical +``` + +``` text +Row 1: +────── +database: merge +table: visits +engine: ReplicatedCollapsingMergeTree +is_leader: 1 +can_become_leader: 1 +is_readonly: 0 +is_session_expired: 0 +future_parts: 1 +parts_to_check: 0 +zookeeper_path: /clickhouse/tables/01-06/visits +replica_name: example01-06-1.yandex.ru +replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru +columns_version: 9 +queue_size: 1 +inserts_in_queue: 0 +merges_in_queue: 1 +part_mutations_in_queue: 0 +queue_oldest_time: 2020-02-20 08:34:30 +inserts_oldest_time: 0000-00-00 00:00:00 +merges_oldest_time: 2020-02-20 08:34:30 +part_mutations_oldest_time: 0000-00-00 00:00:00 +oldest_part_to_get: +oldest_part_to_merge_to: 20200220_20284_20840_7 +oldest_part_to_mutate_to: +log_max_index: 596273 +log_pointer: 596274 +last_queue_update: 2020-02-20 08:34:32 +absolute_delay: 0 +total_replicas: 2 +active_replicas: 2 +``` + +Columna: + +- `database` (`String`) - Nombre de la base de datos +- `table` (`String`) - Nombre de la tabla +- `engine` (`String`) - Nombre del motor de tabla +- `is_leader` (`UInt8`) - Si la réplica es la líder. + Sólo una réplica a la vez puede ser el líder. El líder es responsable de seleccionar las fusiones de fondo para realizar. + Tenga en cuenta que las escrituras se pueden realizar en cualquier réplica que esté disponible y tenga una sesión en ZK, independientemente de si es un líder. +- `can_become_leader` (`UInt8`) - Si la réplica puede ser elegida como líder. +- `is_readonly` (`UInt8`) - Si la réplica está en modo de sólo lectura. + Este modo se activa si la configuración no tiene secciones con ZooKeeper, si se produce un error desconocido al reinicializar sesiones en ZooKeeper y durante la reinicialización de sesiones en ZooKeeper. +- `is_session_expired` (`UInt8`) - la sesión con ZooKeeper ha expirado. Básicamente lo mismo que `is_readonly`. +- `future_parts` (`UInt32`) - El número de partes de datos que aparecerán como resultado de INSERTs o fusiones que aún no se han realizado. +- `parts_to_check` (`UInt32`) - El número de partes de datos en la cola para la verificación. Una pieza se coloca en la cola de verificación si existe la sospecha de que podría estar dañada. +- `zookeeper_path` (`String`) - Ruta de acceso a los datos de la tabla en ZooKeeper. +- `replica_name` (`String`) - Nombre de réplica en ZooKeeper. Diferentes réplicas de la misma tabla tienen diferentes nombres. +- `replica_path` (`String`) - Ruta de acceso a los datos de réplica en ZooKeeper. Lo mismo que concatenar ‘zookeeper\_path/replicas/replica\_path’. +- `columns_version` (`Int32`) - Número de versión de la estructura de la tabla. Indica cuántas veces se realizó ALTER. Si las réplicas tienen versiones diferentes, significa que algunas réplicas aún no han hecho todas las ALTER. +- `queue_size` (`UInt32`) - Tamaño de la cola para las operaciones en espera de ser realizadas. Las operaciones incluyen insertar bloques de datos, fusiones y otras acciones. Por lo general, coincide con `future_parts`. +- `inserts_in_queue` (`UInt32`) - Número de inserciones de bloques de datos que deben realizarse. Las inserciones generalmente se replican con bastante rapidez. Si este número es grande, significa que algo anda mal. +- `merges_in_queue` (`UInt32`) - El número de fusiones en espera de hacerse. A veces las fusiones son largas, por lo que este valor puede ser mayor que cero durante mucho tiempo. +- `part_mutations_in_queue` (`UInt32`) - El número de mutaciones a la espera de hacerse. +- `queue_oldest_time` (`DateTime`) - Si `queue_size` mayor que 0, muestra cuándo se agregó la operación más antigua a la cola. +- `inserts_oldest_time` (`DateTime`) - Ver `queue_oldest_time` +- `merges_oldest_time` (`DateTime`) - Ver `queue_oldest_time` +- `part_mutations_oldest_time` (`DateTime`) - Ver `queue_oldest_time` + +Las siguientes 4 columnas tienen un valor distinto de cero solo cuando hay una sesión activa con ZK. + +- `log_max_index` (`UInt64`) - Número máximo de inscripción en el registro de actividad general. +- `log_pointer` (`UInt64`) - Número máximo de entrada en el registro de actividad general que la réplica copió en su cola de ejecución, más uno. Si `log_pointer` es mucho más pequeño que `log_max_index`, algo está mal. +- `last_queue_update` (`DateTime`) - Cuando la cola se actualizó la última vez. +- `absolute_delay` (`UInt64`) - ¿Qué tan grande retraso en segundos tiene la réplica actual. +- `total_replicas` (`UInt8`) - El número total de réplicas conocidas de esta tabla. +- `active_replicas` (`UInt8`) - El número de réplicas de esta tabla que tienen una sesión en ZooKeeper (es decir, el número de réplicas en funcionamiento). + +Si solicita todas las columnas, la tabla puede funcionar un poco lentamente, ya que se realizan varias lecturas de ZooKeeper para cada fila. +Si no solicita las últimas 4 columnas (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), la tabla funciona rápidamente. + +Por ejemplo, puede verificar que todo funcione correctamente de esta manera: + +``` sql +SELECT + database, + table, + is_leader, + is_readonly, + is_session_expired, + future_parts, + parts_to_check, + columns_version, + queue_size, + inserts_in_queue, + merges_in_queue, + log_max_index, + log_pointer, + total_replicas, + active_replicas +FROM system.replicas +WHERE + is_readonly + OR is_session_expired + OR future_parts > 20 + OR parts_to_check > 10 + OR queue_size > 20 + OR inserts_in_queue > 10 + OR log_max_index - log_pointer > 10 + OR total_replicas < 2 + OR active_replicas < total_replicas +``` + +Si esta consulta no devuelve nada, significa que todo está bien. + +## sistema.configuración {#system-tables-system-settings} + +Contiene información sobre la configuración de sesión para el usuario actual. + +Columna: + +- `name` ([Cadena](../sql-reference/data-types/string.md)) — Setting name. +- `value` ([Cadena](../sql-reference/data-types/string.md)) — Setting value. +- `changed` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether a setting is changed from its default value. +- `description` ([Cadena](../sql-reference/data-types/string.md)) — Short setting description. +- `min` ([NULL](../sql-reference/data-types/nullable.md)([Cadena](../sql-reference/data-types/string.md))) — Minimum value of the setting, if any is set via [limitación](settings/constraints-on-settings.md#constraints-on-settings). Si la configuración no tiene ningún valor mínimo, contiene [NULL](../sql-reference/syntax.md#null-literal). +- `max` ([NULL](../sql-reference/data-types/nullable.md)([Cadena](../sql-reference/data-types/string.md))) — Maximum value of the setting, if any is set via [limitación](settings/constraints-on-settings.md#constraints-on-settings). Si la configuración no tiene ningún valor máximo, contiene [NULL](../sql-reference/syntax.md#null-literal). +- `readonly` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether the current user can change the setting: + - `0` — Current user can change the setting. + - `1` — Current user can't change the setting. + +**Ejemplo** + +En el ejemplo siguiente se muestra cómo obtener información sobre la configuración cuyo nombre contiene `min_i`. + +``` sql +SELECT * +FROM system.settings +WHERE name LIKE '%min_i%' +``` + +``` text +┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ +│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ +``` + +Uso de `WHERE changed` puede ser útil, por ejemplo, cuando se desea comprobar: + +- Si los ajustes de los archivos de configuración se cargan correctamente y están en uso. +- Configuración que cambió en la sesión actual. + + + +``` sql +SELECT * FROM system.settings WHERE changed AND name='load_balancing' +``` + +**Ver también** + +- [Configuración](settings/index.md#session-settings-intro) +- [Permisos para consultas](settings/permissions-for-queries.md#settings_readonly) +- [Restricciones en la configuración](settings/constraints-on-settings.md) + +## sistema.table\_engines {#system.table_engines} + +``` text +┌─name───────────────────┬─value───────┐ +│ max_threads │ 8 │ +│ use_uncompressed_cache │ 0 │ +│ load_balancing │ random │ +│ max_memory_usage │ 10000000000 │ +└────────────────────────┴─────────────┘ +``` + +## sistema.merge\_tree\_settings {#system-merge_tree_settings} + +Contiene información sobre la configuración `MergeTree` tabla. + +Columna: + +- `name` (String) — Setting name. +- `value` (String) — Setting value. +- `description` (String) — Setting description. +- `type` (String) — Setting type (implementation specific string value). +- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. + +## sistema.table\_engines {#system-table-engines} + +Contiene la descripción de los motores de tablas admitidos por el servidor y su información de soporte de características. + +Esta tabla contiene las siguientes columnas (el tipo de columna se muestra entre corchetes): + +- `name` (String) — The name of table engine. +- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` clausula. +- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [Índices de saltos](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes). +- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). +- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` y `SAMPLE_BY`. +- `supports_replication` (UInt8) — Flag that indicates if table engine supports [Replicación de datos](../engines/table-engines/mergetree-family/replication.md). +- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. + +Ejemplo: + +``` sql +SELECT * +FROM system.table_engines +WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') +``` + +``` text +┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ +│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ +│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ +│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ +└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ +``` + +**Ver también** + +- Familia MergeTree [cláusulas de consulta](../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) +- Kafka [configuración](../engines/table-engines/integrations/kafka.md#table_engine-kafka-creating-a-table) +- Unir [configuración](../engines/table-engines/special/join.md#join-limitations-and-settings) + +## sistema.tabla {#system-tables} + +Contiene metadatos de cada tabla que el servidor conoce. Las tablas separadas no se muestran en `system.tables`. + +Esta tabla contiene las siguientes columnas (el tipo de columna se muestra entre corchetes): + +- `database` (String) — The name of the database the table is in. + +- `name` (String) — Table name. + +- `engine` (String) — Table engine name (without parameters). + +- `is_temporary` (UInt8): marca que indica si la tabla es temporal. + +- `data_path` (String) - Ruta de acceso a los datos de la tabla en el sistema de archivos. + +- `metadata_path` (String) - Ruta de acceso a los metadatos de la tabla en el sistema de archivos. + +- `metadata_modification_time` (DateTime) - Hora de la última modificación de los metadatos de la tabla. + +- `dependencies_database` (Array(String)) - Dependencias de base de datos. + +- `dependencies_table` (Array(String)) - Dependencias de tabla ([Método de codificación de datos:](../engines/table-engines/special/materializedview.md) tablas basadas en la tabla actual). + +- `create_table_query` (String) - La consulta que se utilizó para crear la tabla. + +- `engine_full` (String) - Parámetros del motor de tabla. + +- `partition_key` (String) - La expresión de clave de partición especificada en la tabla. + +- `sorting_key` (String) - La expresión de clave de ordenación especificada en la tabla. + +- `primary_key` (String) - La expresión de clave principal especificada en la tabla. + +- `sampling_key` (String) - La expresión de clave de muestreo especificada en la tabla. + +- `storage_policy` (String) - La política de almacenamiento: + + - [Método de codificación de datos:](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) + - [Distribuido](../engines/table-engines/special/distributed.md#distributed) + +- `total_rows` (Nullable(UInt64)) - Número total de filas, si es posible determinar rápidamente el número exacto de filas en la tabla, de lo contrario `Null` (incluyendo underying `Buffer` tabla). + +- `total_bytes` (Nullable(UInt64)) - Número total de bytes, si es posible determinar rápidamente el número exacto de bytes para la tabla en el almacenamiento, de lo contrario `Null` (**no** incluye cualquier almacenamiento subyacente). + + - If the table stores data on disk, returns used space on disk (i.e. compressed). + - Si la tabla almacena datos en la memoria, devuelve el número aproximado de bytes utilizados en la memoria. + +El `system.tables` se utiliza en `SHOW TABLES` implementación de consultas. + +## sistema.Zookeeper {#system-zookeeper} + +La tabla no existe si ZooKeeper no está configurado. Permite leer datos del clúster ZooKeeper definido en la configuración. +La consulta debe tener un ‘path’ condición de igualdad en la cláusula WHERE. Este es el camino en ZooKeeper para los niños para los que desea obtener datos. + +Consulta `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` salidas de datos para todos los niños en el `/clickhouse` nodo. +Para generar datos para todos los nodos raíz, escriba path = ‘/’. +Si la ruta especificada en ‘path’ no existe, se lanzará una excepción. + +Columna: + +- `name` (String) — The name of the node. +- `path` (String) — The path to the node. +- `value` (String) — Node value. +- `dataLength` (Int32) — Size of the value. +- `numChildren` (Int32) — Number of descendants. +- `czxid` (Int64) — ID of the transaction that created the node. +- `mzxid` (Int64) — ID of the transaction that last changed the node. +- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. +- `ctime` (DateTime) — Time of node creation. +- `mtime` (DateTime) — Time of the last modification of the node. +- `version` (Int32) — Node version: the number of times the node was changed. +- `cversion` (Int32) — Number of added or removed descendants. +- `aversion` (Int32) — Number of changes to the ACL. +- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. + +Ejemplo: + +``` sql +SELECT * +FROM system.zookeeper +WHERE path = '/clickhouse/tables/01-08/visits/replicas' +FORMAT Vertical +``` + +``` text +Row 1: +────── +name: example01-08-1.yandex.ru +value: +czxid: 932998691229 +mzxid: 932998691229 +ctime: 2015-03-27 16:49:51 +mtime: 2015-03-27 16:49:51 +version: 0 +cversion: 47 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021031383 +path: /clickhouse/tables/01-08/visits/replicas + +Row 2: +────── +name: example01-08-2.yandex.ru +value: +czxid: 933002738135 +mzxid: 933002738135 +ctime: 2015-03-27 16:57:01 +mtime: 2015-03-27 16:57:01 +version: 0 +cversion: 37 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021252247 +path: /clickhouse/tables/01-08/visits/replicas +``` + +## sistema.mutación {#system_tables-mutations} + +La tabla contiene información sobre [mutación](../sql-reference/statements/alter.md#alter-mutations) de las tablas MergeTree y su progreso. Cada comando de mutación está representado por una sola fila. La tabla tiene las siguientes columnas: + +**base**, **tabla** - El nombre de la base de datos y la tabla a la que se aplicó la mutación. + +**mutation\_id** - La identificación de la mutación. Para las tablas replicadas, estos identificadores corresponden a los nombres de znode `/mutations/` directorio en ZooKeeper. Para las tablas no duplicadas, los ID corresponden a los nombres de archivo en el directorio de datos de la tabla. + +**comando** - La cadena de comandos de mutación (la parte de la consulta después de `ALTER TABLE [db.]table`). + +**create\_time** - Cuando este comando de mutación fue enviado para su ejecución. + +**block\_numbers.partition\_id**, **block\_numbers.numero** - Una columna anidada. Para las mutaciones de tablas replicadas, contiene un registro para cada partición: el ID de partición y el número de bloque que fue adquirido por la mutación (en cada partición, solo se mutarán las partes que contienen bloques con números menores que el número de bloque adquirido por la mutación en esa partición). En tablas no replicadas, los números de bloque en todas las particiones forman una sola secuencia. Esto significa que para las mutaciones de tablas no replicadas, la columna contendrá un registro con un solo número de bloque adquirido por la mutación. + +**partes\_a\_do** - El número de partes de datos que deben mutarse para que finalice la mutación. + +**is\_done** - Es la mutación hecho? Tenga en cuenta que incluso si `parts_to_do = 0` es posible que aún no se haya realizado una mutación de una tabla replicada debido a un INSERT de larga ejecución que creará una nueva parte de datos que deberá mutarse. + +Si hubo problemas con la mutación de algunas partes, las siguientes columnas contienen información adicional: + +**Método de codificación de datos:** - El nombre de la parte más reciente que no se pudo mutar. + +**Método de codificación de datos:** - El momento del fracaso de la mutación de la parte más reciente. + +**Método de codificación de datos:** - El mensaje de excepción que causó el error de mutación de parte más reciente. + +## sistema.disco {#system_tables-disks} + +Contiene información sobre los discos definidos en el [configuración del servidor](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Columna: + +- `name` ([Cadena](../sql-reference/data-types/string.md)) — Name of a disk in the server configuration. +- `path` ([Cadena](../sql-reference/data-types/string.md)) — Path to the mount point in the file system. +- `free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Free space on disk in bytes. +- `total_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Disk volume in bytes. +- `keep_free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` parámetro de configuración del disco. + +## sistema.almacenamiento\_policies {#system_tables-storage_policies} + +Contiene información sobre las directivas de almacenamiento y los volúmenes [configuración del servidor](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Columna: + +- `policy_name` ([Cadena](../sql-reference/data-types/string.md)) — Name of the storage policy. +- `volume_name` ([Cadena](../sql-reference/data-types/string.md)) — Volume name defined in the storage policy. +- `volume_priority` ([UInt64](../sql-reference/data-types/int-uint.md)) — Volume order number in the configuration. +- `disks` ([Array(Cadena)](../sql-reference/data-types/array.md)) — Disk names, defined in the storage policy. +- `max_data_part_size` ([UInt64](../sql-reference/data-types/int-uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). +- `move_factor` ([Float64](../sql-reference/data-types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. + +Si la directiva de almacenamiento contiene más de un volumen, la información de cada volumen se almacena en la fila individual de la tabla. + +[Artículo Original](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/es/operations/system_tables.md b/docs/es/operations/system_tables.md deleted file mode 100644 index 590ff99bc13..00000000000 --- a/docs/es/operations/system_tables.md +++ /dev/null @@ -1,1097 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_priority: 52 -toc_title: Tablas del sistema ---- - -# Tablas del sistema {#system-tables} - -Las tablas del sistema se utilizan para implementar parte de la funcionalidad del sistema y para proporcionar acceso a información sobre cómo funciona el sistema. -No puede eliminar una tabla del sistema (pero puede realizar DETACH). -Las tablas del sistema no tienen archivos con datos en el disco o archivos con metadatos. El servidor crea todas las tablas del sistema cuando se inicia. -Las tablas del sistema son de solo lectura. -Están ubicados en el ‘system’ base. - -## sistema.asynchronous\_metrics {#system_tables-asynchronous_metrics} - -Contiene métricas que se calculan periódicamente en segundo plano. Por ejemplo, la cantidad de RAM en uso. - -Columna: - -- `metric` ([Cadena](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Float64](../sql_reference/data_types/float.md)) — Metric value. - -**Ejemplo** - -``` sql -SELECT * FROM system.asynchronous_metrics LIMIT 10 -``` - -``` text -┌─metric──────────────────────────────────┬──────value─┐ -│ jemalloc.background_thread.run_interval │ 0 │ -│ jemalloc.background_thread.num_runs │ 0 │ -│ jemalloc.background_thread.num_threads │ 0 │ -│ jemalloc.retained │ 422551552 │ -│ jemalloc.mapped │ 1682989056 │ -│ jemalloc.resident │ 1656446976 │ -│ jemalloc.metadata_thp │ 0 │ -│ jemalloc.metadata │ 10226856 │ -│ UncompressedCacheCells │ 0 │ -│ MarkCacheFiles │ 0 │ -└─────────────────────────────────────────┴────────────┘ -``` - -**Ver también** - -- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. -- [sistema.métricas](#system_tables-metrics) — Contains instantly calculated metrics. -- [sistema.evento](#system_tables-events) — Contains a number of events that have occurred. -- [sistema.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. - -## sistema.Cluster {#system-clusters} - -Contiene información sobre los clústeres disponibles en el archivo de configuración y los servidores que contienen. - -Columna: - -- `cluster` (String) — The cluster name. -- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. -- `shard_weight` (UInt32) — The relative weight of the shard when writing data. -- `replica_num` (UInt32) — The replica number in the shard, starting from 1. -- `host_name` (String) — The host name, as specified in the config. -- `host_address` (String) — The host IP address obtained from DNS. -- `port` (UInt16) — The port to use for connecting to the server. -- `user` (String) — The name of the user for connecting to the server. -- `errors_count` (UInt32): número de veces que este host no pudo alcanzar la réplica. -- `estimated_recovery_time` (UInt32): quedan segundos hasta que el recuento de errores de réplica se ponga a cero y se considere que vuelve a la normalidad. - -Tenga en cuenta que `errors_count` se actualiza una vez por consulta al clúster, pero `estimated_recovery_time` se vuelve a calcular bajo demanda. Entonces podría haber un caso distinto de cero `errors_count` y cero `estimated_recovery_time`, esa próxima consulta será cero `errors_count` e intente usar la réplica como si no tuviera errores. - -**Ver también** - -- [Motor de tabla distribuido](../engines/table_engines/special/distributed.md) -- [distributed\_replica\_error\_cap configuración](settings/settings.md#settings-distributed_replica_error_cap) -- [distributed\_replica\_error\_half\_life configuración](settings/settings.md#settings-distributed_replica_error_half_life) - -## sistema.columna {#system-columns} - -Contiene información sobre las columnas de todas las tablas. - -Puede utilizar esta tabla para obtener información similar a la [DESCRIBE TABLE](../sql_reference/statements/misc.md#misc-describe-table) consulta, pero para varias tablas a la vez. - -El `system.columns` tabla contiene las siguientes columnas (el tipo de columna se muestra entre corchetes): - -- `database` (String) — Database name. -- `table` (String) — Table name. -- `name` (String) — Column name. -- `type` (String) — Column type. -- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) para el valor predeterminado, o una cadena vacía si no está definida. -- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. -- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. -- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. -- `marks_bytes` (UInt64) — The size of marks, in bytes. -- `comment` (String) — Comment on the column, or an empty string if it is not defined. -- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. -- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. -- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. -- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. - -## sistema.colaborador {#system-contributors} - -Contiene información sobre los colaboradores. Todos los constributores en orden aleatorio. El orden es aleatorio en el momento de la ejecución de la consulta. - -Columna: - -- `name` (String) — Contributor (author) name from git log. - -**Ejemplo** - -``` sql -SELECT * FROM system.contributors LIMIT 10 -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -│ Max Vetrov │ -│ LiuYangkuan │ -│ svladykin │ -│ zamulla │ -│ Šimon Podlipský │ -│ BayoNet │ -│ Ilya Khomutov │ -│ Amy Krishnevsky │ -│ Loud_Scream │ -└──────────────────┘ -``` - -Para descubrirlo en la tabla, use una consulta: - -``` sql -SELECT * FROM system.contributors WHERE name='Olga Khvostikova' -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -└──────────────────┘ -``` - -## sistema.base {#system-databases} - -Esta tabla contiene una sola columna String llamada ‘name’ – the name of a database. -Cada base de datos que el servidor conoce tiene una entrada correspondiente en la tabla. -Esta tabla del sistema se utiliza para implementar el `SHOW DATABASES` consulta. - -## sistema.detached\_parts {#system_tables-detached_parts} - -Contiene información sobre piezas separadas de [Método de codificación de datos:](../engines/table_engines/mergetree_family/mergetree.md) tabla. El `reason` columna especifica por qué se separó la pieza. Para las piezas separadas por el usuario, el motivo está vacío. Tales partes se pueden unir con [ALTER TABLE ATTACH PARTITION\|PART](../query_language/query_language/alter/#alter_attach-partition) comando. Para obtener la descripción de otras columnas, consulte [sistema.parte](#system_tables-parts). Si el nombre de la pieza no es válido, los valores de algunas columnas pueden ser `NULL`. Tales partes se pueden eliminar con [ALTER TABLE DROP DETACHED PART](../query_language/query_language/alter/#alter_drop-detached). - -## sistema.diccionario {#system-dictionaries} - -Contiene información sobre diccionarios externos. - -Columna: - -- `name` (String) — Dictionary name. -- `type` (String) — Dictionary type: Flat, Hashed, Cache. -- `origin` (String) — Path to the configuration file that describes the dictionary. -- `attribute.names` (Array(String)) — Array of attribute names provided by the dictionary. -- `attribute.types` (Array(String)) — Corresponding array of attribute types that are provided by the dictionary. -- `has_hierarchy` (UInt8) — Whether the dictionary is hierarchical. -- `bytes_allocated` (UInt64) — The amount of RAM the dictionary uses. -- `hit_rate` (Float64) — For cache dictionaries, the percentage of uses for which the value was in the cache. -- `element_count` (UInt64) — The number of items stored in the dictionary. -- `load_factor` (Float64) — The percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). -- `creation_time` (DateTime) — The time when the dictionary was created or last successfully reloaded. -- `last_exception` (String) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. -- `source` (String) — Text describing the data source for the dictionary. - -Tenga en cuenta que la cantidad de memoria utilizada por el diccionario no es proporcional a la cantidad de elementos almacenados en él. Por lo tanto, para los diccionarios planos y en caché, todas las celdas de memoria se asignan previamente, independientemente de qué tan lleno esté realmente el diccionario. - -## sistema.evento {#system_tables-events} - -Contiene información sobre el número de eventos que se han producido en el sistema. Por ejemplo, en la tabla, puede encontrar cuántos `SELECT` las consultas se procesaron desde que se inició el servidor ClickHouse. - -Columna: - -- `event` ([Cadena](../sql_reference/data_types/string.md)) — Event name. -- `value` ([UInt64](../sql_reference/data_types/int_uint.md)) — Number of events occurred. -- `description` ([Cadena](../sql_reference/data_types/string.md)) — Event description. - -**Ejemplo** - -``` sql -SELECT * FROM system.events LIMIT 5 -``` - -``` text -┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ -│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ -│ FileOpen │ 73 │ Number of files opened. │ -│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ -│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ -└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Ver también** - -- [sistema.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [sistema.métricas](#system_tables-metrics) — Contains instantly calculated metrics. -- [sistema.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. - -## sistema.función {#system-functions} - -Contiene información sobre funciones normales y agregadas. - -Columna: - -- `name`(`String`) – The name of the function. -- `is_aggregate`(`UInt8`) — Whether the function is aggregate. - -## sistema.graphite\_retentions {#system-graphite-retentions} - -Contiene información sobre los parámetros [graphite\_rollup](server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) que se utilizan en tablas con [\*GraphiteMergeTree](../engines/table_engines/mergetree_family/graphitemergetree.md) motor. - -Columna: - -- `config_name` (Cadena) - `graphite_rollup` nombre del parámetro. -- `regexp` (Cadena) - Un patrón para el nombre de la métrica. -- `function` (String) - El nombre de la función de agregación. -- `age` (UInt64) - La edad mínima de los datos en segundos. -- `precision` (UInt64) - Cómo definir con precisión la edad de los datos en segundos. -- `priority` (UInt16) - Prioridad de patrón. -- `is_default` (UInt8) - Si el patrón es el predeterminado. -- `Tables.database` (Array(String)) - Matriz de nombres de tablas de base de datos que utilizan `config_name` parámetro. -- `Tables.table` (Array(String)) - Matriz de nombres de tablas que utilizan `config_name` parámetro. - -## sistema.fusionar {#system-merges} - -Contiene información sobre fusiones y mutaciones de piezas actualmente en proceso para tablas de la familia MergeTree. - -Columna: - -- `database` (String) — The name of the database the table is in. -- `table` (String) — Table name. -- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. -- `progress` (Float64) — The percentage of completed work from 0 to 1. -- `num_parts` (UInt64) — The number of pieces to be merged. -- `result_part_name` (String) — The name of the part that will be formed as the result of merging. -- `is_mutation` (UInt8) - 1 si este proceso es una mutación parte. -- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. -- `total_size_marks` (UInt64) — The total number of marks in the merged parts. -- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. -- `rows_read` (UInt64) — Number of rows read. -- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. -- `rows_written` (UInt64) — Number of rows written. - -## sistema.métricas {#system_tables-metrics} - -Contiene métricas que pueden calcularse instantáneamente o tener un valor actual. Por ejemplo, el número de consultas procesadas simultáneamente o el retraso de réplica actual. Esta tabla está siempre actualizada. - -Columna: - -- `metric` ([Cadena](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Int64](../sql_reference/data_types/int_uint.md)) — Metric value. -- `description` ([Cadena](../sql_reference/data_types/string.md)) — Metric description. - -La lista de métricas admitidas que puede encontrar en el [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) archivo fuente de ClickHouse. - -**Ejemplo** - -``` sql -SELECT * FROM system.metrics LIMIT 10 -``` - -``` text -┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 1 │ Number of executing queries │ -│ Merge │ 0 │ Number of executing background merges │ -│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ -│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ -│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ -│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ -│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ -│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ -│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ -│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ -└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Ver también** - -- [sistema.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [sistema.evento](#system_tables-events) — Contains a number of events that occurred. -- [sistema.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. - -## sistema.metric\_log {#system_tables-metric_log} - -Contiene el historial de valores de métricas de tablas `system.metrics` y `system.events`, periódicamente enjuagado al disco. -Para activar la recopilación de historial de métricas en `system.metric_log`, crear `/etc/clickhouse-server/config.d/metric_log.xml` con el siguiente contenido: - -``` xml - - - system - metric_log
- 7500 - 1000 -
-
-``` - -**Ejemplo** - -``` sql -SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; -``` - -``` text -Row 1: -────── -event_date: 2020-02-18 -event_time: 2020-02-18 07:15:33 -milliseconds: 554 -ProfileEvent_Query: 0 -ProfileEvent_SelectQuery: 0 -ProfileEvent_InsertQuery: 0 -ProfileEvent_FileOpen: 0 -ProfileEvent_Seek: 0 -ProfileEvent_ReadBufferFromFileDescriptorRead: 1 -ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 -ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 -ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 -ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 -ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 -... -CurrentMetric_Query: 0 -CurrentMetric_Merge: 0 -CurrentMetric_PartMutation: 0 -CurrentMetric_ReplicatedFetch: 0 -CurrentMetric_ReplicatedSend: 0 -CurrentMetric_ReplicatedChecks: 0 -... -``` - -**Ver también** - -- [sistema.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [sistema.evento](#system_tables-events) — Contains a number of events that occurred. -- [sistema.métricas](#system_tables-metrics) — Contains instantly calculated metrics. -- [Monitoreo](monitoring.md) — Base concepts of ClickHouse monitoring. - -## sistema.numero {#system-numbers} - -Esta tabla contiene una única columna UInt64 llamada ‘number’ que contiene casi todos los números naturales a partir de cero. -Puede usar esta tabla para pruebas, o si necesita hacer una búsqueda de fuerza bruta. -Las lecturas de esta tabla no están paralelizadas. - -## sistema.Números\_mt {#system-numbers-mt} - -Lo mismo que ‘system.numbers’ pero las lecturas están paralelizadas. Los números se pueden devolver en cualquier orden. -Se utiliza para pruebas. - -## sistema.una {#system-one} - -Esta tabla contiene una sola fila con una ‘dummy’ Columna UInt8 que contiene el valor 0. -Esta tabla se utiliza si una consulta SELECT no especifica la cláusula FROM. -Esto es similar a la tabla DUAL que se encuentra en otros DBMS. - -## sistema.parte {#system_tables-parts} - -Contiene información sobre partes de [Método de codificación de datos:](../engines/table_engines/mergetree_family/mergetree.md) tabla. - -Cada fila describe una parte de los datos. - -Columna: - -- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql_reference/statements/alter.md#query_language_queries_alter) consulta. - - Formato: - - - `YYYYMM` para la partición automática por mes. - - `any_string` al particionar manualmente. - -- `name` (`String`) – Name of the data part. - -- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging. - -- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` por la granularidad del índice (generalmente 8192) (esta sugerencia no funciona para la granularidad adaptativa). - -- `rows` (`UInt64`) – The number of rows. - -- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. - -- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `marks_bytes` (`UInt64`) – The size of the file with marks. - -- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| - -- `remove_time` (`DateTime`) – The time when the data part became inactive. - -- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. - -- `min_date` (`Date`) – The minimum value of the date key in the data part. - -- `max_date` (`Date`) – The maximum value of the date key in the data part. - -- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. - -- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. - -- `partition_id` (`String`) – ID of the partition. - -- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. - -- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. - -- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. - -- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). - -- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. - -- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. - -- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../sql_reference/statements/alter.md#alter_freeze-partition) - -- `database` (`String`) – Name of the database. - -- `table` (`String`) – Name of the table. - -- `engine` (`String`) – Name of the table engine without parameters. - -- `path` (`String`) – Absolute path to the folder with data part files. - -- `disk` (`String`) – Name of a disk that stores the data part. - -- `hash_of_all_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) de archivos comprimidos. - -- `hash_of_uncompressed_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) de archivos sin comprimir (archivos con marcas, archivo de índice, etc.). - -- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) de datos en los archivos comprimidos como si estuvieran descomprimidos. - -- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. - -- `marks_size` (`UInt64`) – Alias for `marks_bytes`. - -## sistema.part\_log {#system_tables-part-log} - -El `system.part_log` se crea sólo si el [part\_log](server_configuration_parameters/settings.md#server_configuration_parameters-part-log) se especifica la configuración del servidor. - -Esta tabla contiene información sobre eventos que ocurrieron con [partes de datos](../engines/table_engines/mergetree_family/custom_partitioning_key.md) en el [Método de codificación de datos:](../engines/table_engines/mergetree_family/mergetree.md) tablas familiares, como agregar o fusionar datos. - -El `system.part_log` contiene las siguientes columnas: - -- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: - - `NEW_PART` — Inserting of a new data part. - - `MERGE_PARTS` — Merging of data parts. - - `DOWNLOAD_PART` — Downloading a data part. - - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql_reference/statements/alter.md#alter_detach-partition). - - `MUTATE_PART` — Mutating of a data part. - - `MOVE_PART` — Moving the data part from the one disk to another one. -- `event_date` (Date) — Event date. -- `event_time` (DateTime) — Event time. -- `duration_ms` (UInt64) — Duration. -- `database` (String) — Name of the database the data part is in. -- `table` (String) — Name of the table the data part is in. -- `part_name` (String) — Name of the data part. -- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ valor si la partición es por `tuple()`. -- `rows` (UInt64) — The number of rows in the data part. -- `size_in_bytes` (UInt64) — Size of the data part in bytes. -- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). -- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. -- `read_rows` (UInt64) — The number of rows was read during the merge. -- `read_bytes` (UInt64) — The number of bytes was read during the merge. -- `error` (UInt16) — The code number of the occurred error. -- `exception` (String) — Text message of the occurred error. - -El `system.part_log` se crea después de la primera inserción de datos `MergeTree` tabla. - -## sistema.procesa {#system_tables-processes} - -Esta tabla del sistema se utiliza para implementar el `SHOW PROCESSLIST` consulta. - -Columna: - -- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` usuario. El campo contiene el nombre de usuario para una consulta específica, no para una consulta que esta consulta inició. -- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` en el servidor de solicitud de consulta. -- `elapsed` (Float64) – The time in seconds since request execution started. -- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. -- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [Método de codificación de datos:](../operations/settings/query_complexity.md#settings_max_memory_usage) configuración. -- `query` (String) – The query text. For `INSERT`, no incluye los datos para insertar. -- `query_id` (String) – Query ID, if defined. - -## sistema.text\_log {#system-tables-text-log} - -Contiene entradas de registro. El nivel de registro que va a esta tabla se puede limitar con `text_log.level` configuración del servidor. - -Columna: - -- `event_date` (`Date`) - Fecha de la entrada. -- `event_time` (`DateTime`) - Tiempo de la entrada. -- `microseconds` (`UInt32`) - Microsegundos de la entrada. -- `thread_name` (String) — Name of the thread from which the logging was done. -- `thread_id` (UInt64) — OS thread ID. -- `level` (`Enum8`) - Nivel de entrada. - - `'Fatal' = 1` - - `'Critical' = 2` - - `'Error' = 3` - - `'Warning' = 4` - - `'Notice' = 5` - - `'Information' = 6` - - `'Debug' = 7` - - `'Trace' = 8` -- `query_id` (`String`) - ID de la consulta. -- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) -- `message` (`String`) - El mensaje en sí. -- `revision` (`UInt32`) - Revisión de ClickHouse. -- `source_file` (`LowCardinality(String)`) - Archivo de origen desde el que se realizó el registro. -- `source_line` (`UInt64`) - Línea de origen desde la que se realizó el registro. - -## sistema.query\_log {#system_tables-query_log} - -Contiene información sobre la ejecución de consultas. Para cada consulta, puede ver la hora de inicio del procesamiento, la duración del procesamiento, los mensajes de error y otra información. - -!!! note "Nota" - La tabla no contiene datos de entrada para `INSERT` consulta. - -ClickHouse crea esta tabla sólo si el [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) se especifica el parámetro server. Este parámetro establece las reglas de registro, como el intervalo de registro o el nombre de la tabla en la que se registrarán las consultas. - -Para habilitar el registro de consultas, [Log\_queries](settings/settings.md#settings-log-queries) parámetro a 1. Para obtener más información, consulte el [Configuración](settings/settings.md) apartado. - -El `system.query_log` tabla registra dos tipos de consultas: - -1. Consultas iniciales ejecutadas directamente por el cliente. -2. Niño consultas que fueron iniciados por otras consultas (distribuida de la ejecución de la consulta). Para estos tipos de consultas, la información sobre el padre de las consultas se muestra en la `initial_*` columna. - -Columna: - -- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: - - `'QueryStart' = 1` — Successful start of query execution. - - `'QueryFinish' = 2` — Successful end of query execution. - - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. - - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. -- `event_date` (Date) — Query starting date. -- `event_time` (DateTime) — Query starting time. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` consultas, el número de filas escritas. Para otras consultas, el valor de la columna es 0. -- `written_bytes` (UInt64) — For `INSERT` consultas, el número de bytes escritos. Para otras consultas, el valor de la columna es 0. -- `result_rows` (UInt64) — Number of rows in the result. -- `result_bytes` (UInt64) — Number of bytes in the result. -- `memory_usage` (UInt64) — Memory consumption by the query. -- `query` (String) — Query string. -- `exception` (String) — Exception message. -- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS's username who runs [Casa de clics-cliente](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [Casa de clics-cliente](../interfaces/cli.md) o se ejecuta otro cliente TCP. -- `client_name` (String) — The [Casa de clics-cliente](../interfaces/cli.md) o otro nombre de cliente TCP. -- `client_revision` (UInt32) — Revision of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. -- `client_version_major` (UInt32) — Major version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. -- `client_version_minor` (UInt32) — Minor version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. -- `client_version_patch` (UInt32) — Patch component of the [Casa de clics-cliente](../interfaces/cli.md) o otra versión de cliente TCP. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` se utilizó el método. - - 2 — `POST` se utilizó el método. -- `http_user_agent` (String) — The `UserAgent` encabezado pasado en la solicitud HTTP. -- `quota_key` (String) — The “quota key” especificado en el [cuota](quotas.md) ajuste (ver `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [sistema.evento](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` columna. -- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parámetro a 1. -- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` columna. - -Cada consulta crea una o dos filas en el `query_log` tabla, dependiendo del estado de la consulta: - -1. Si la ejecución de la consulta se realiza correctamente, se crean dos eventos con los tipos 1 y 2 (consulte `type` columna). -2. Si se produjo un error durante el procesamiento de la consulta, se crean dos eventos con los tipos 1 y 4. -3. Si se produjo un error antes de iniciar la consulta, se crea un solo evento con el tipo 3. - -De forma predeterminada, los registros se agregan a la tabla a intervalos de 7,5 segundos. Puede establecer este intervalo en el [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) configuración del servidor (consulte el `flush_interval_milliseconds` parámetro). Para vaciar los registros a la fuerza desde el búfer de memoria a la tabla, utilice `SYSTEM FLUSH LOGS` consulta. - -Cuando la tabla se elimina manualmente, se creará automáticamente sobre la marcha. Tenga en cuenta que se eliminarán todos los registros anteriores. - -!!! note "Nota" - El período de almacenamiento para los registros es ilimitado. Los registros no se eliminan automáticamente de la tabla. Debe organizar la eliminación de registros obsoletos usted mismo. - -Puede especificar una clave de partición arbitraria `system.query_log` mesa en el [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) configuración del servidor (consulte el `partition_by` parámetro). - -## sistema.Sistema abierto. {#system_tables-query-thread-log} - -La tabla contiene información sobre cada subproceso de ejecución de consultas. - -ClickHouse crea esta tabla sólo si el [Sistema abierto.](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) se especifica el parámetro server. Este parámetro establece las reglas de registro, como el intervalo de registro o el nombre de la tabla en la que se registrarán las consultas. - -Para habilitar el registro de consultas, [Log\_query\_threads](settings/settings.md#settings-log-query-threads) parámetro a 1. Para obtener más información, consulte el [Configuración](settings/settings.md) apartado. - -Columna: - -- `event_date` (Date) — the date when the thread has finished execution of the query. -- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` consultas, el número de filas escritas. Para otras consultas, el valor de la columna es 0. -- `written_bytes` (UInt64) — For `INSERT` consultas, el número de bytes escritos. Para otras consultas, el valor de la columna es 0. -- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. -- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. -- `thread_name` (String) — Name of the thread. -- `thread_number` (UInt32) — Internal thread ID. -- `os_thread_id` (Int32) — OS thread ID. -- `master_thread_id` (UInt64) — OS initial ID of initial thread. -- `query` (String) — Query string. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS's username who runs [Casa de clics-cliente](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [Casa de clics-cliente](../interfaces/cli.md) o se ejecuta otro cliente TCP. -- `client_name` (String) — The [Casa de clics-cliente](../interfaces/cli.md) o otro nombre de cliente TCP. -- `client_revision` (UInt32) — Revision of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. -- `client_version_major` (UInt32) — Major version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. -- `client_version_minor` (UInt32) — Minor version of the [Casa de clics-cliente](../interfaces/cli.md) o otro cliente TCP. -- `client_version_patch` (UInt32) — Patch component of the [Casa de clics-cliente](../interfaces/cli.md) o otra versión de cliente TCP. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` se utilizó el método. - - 2 — `POST` se utilizó el método. -- `http_user_agent` (String) — The `UserAgent` encabezado pasado en la solicitud HTTP. -- `quota_key` (String) — The “quota key” especificado en el [cuota](quotas.md) ajuste (ver `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [sistema.evento](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` columna. - -De forma predeterminada, los registros se agregan a la tabla a intervalos de 7,5 segundos. Puede establecer este intervalo en el [Sistema abierto.](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) configuración del servidor (consulte el `flush_interval_milliseconds` parámetro). Para vaciar los registros a la fuerza desde el búfer de memoria a la tabla, utilice `SYSTEM FLUSH LOGS` consulta. - -Cuando la tabla se elimina manualmente, se creará automáticamente sobre la marcha. Tenga en cuenta que se eliminarán todos los registros anteriores. - -!!! note "Nota" - El período de almacenamiento para los registros es ilimitado. Los registros no se eliminan automáticamente de la tabla. Debe organizar la eliminación de registros obsoletos usted mismo. - -Puede especificar una clave de partición arbitraria `system.query_thread_log` mesa en el [Sistema abierto.](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) configuración del servidor (consulte el `partition_by` parámetro). - -## sistema.trace\_log {#system_tables-trace_log} - -Contiene seguimientos de pila recopilados por el generador de perfiles de consultas de muestreo. - -ClickHouse crea esta tabla cuando el [trace\_log](server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) se establece la sección de configuración del servidor. También el [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) y [Los resultados de la prueba](settings/settings.md#query_profiler_cpu_time_period_ns) los ajustes deben establecerse. - -Para analizar los registros, utilice el `addressToLine`, `addressToSymbol` y `demangle` funciones de inspección. - -Columna: - -- `event_date`([Fecha](../sql_reference/data_types/date.md)) — Date of sampling moment. - -- `event_time`([FechaHora](../sql_reference/data_types/datetime.md)) — Timestamp of sampling moment. - -- `revision`([UInt32](../sql_reference/data_types/int_uint.md)) — ClickHouse server build revision. - - Cuando se conecta al servidor por `clickhouse-client`, ves la cadena similar a `Connected to ClickHouse server version 19.18.1 revision 54429.`. Este campo contiene el `revision`, pero no el `version` de un servidor. - -- `timer_type`([Enum8](../sql_reference/data_types/enum.md)) — Timer type: - - - `Real` representa el tiempo del reloj de pared. - - `CPU` representa el tiempo de CPU. - -- `thread_number`([UInt32](../sql_reference/data_types/int_uint.md)) — Thread identifier. - -- `query_id`([Cadena](../sql_reference/data_types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) tabla del sistema. - -- `trace`([Matriz (UInt64)](../sql_reference/data_types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. - -**Ejemplo** - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-15 -event_time: 2019-11-15 15:09:38 -revision: 54428 -timer_type: Real -thread_number: 48 -query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 -trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] -``` - -## sistema.Replica {#system_tables-replicas} - -Contiene información y estado de las tablas replicadas que residen en el servidor local. -Esta tabla se puede utilizar para el monitoreo. La tabla contiene una fila para cada tabla Replicated\*. - -Ejemplo: - -``` sql -SELECT * -FROM system.replicas -WHERE table = 'visits' -FORMAT Vertical -``` - -``` text -Row 1: -────── -database: merge -table: visits -engine: ReplicatedCollapsingMergeTree -is_leader: 1 -can_become_leader: 1 -is_readonly: 0 -is_session_expired: 0 -future_parts: 1 -parts_to_check: 0 -zookeeper_path: /clickhouse/tables/01-06/visits -replica_name: example01-06-1.yandex.ru -replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru -columns_version: 9 -queue_size: 1 -inserts_in_queue: 0 -merges_in_queue: 1 -part_mutations_in_queue: 0 -queue_oldest_time: 2020-02-20 08:34:30 -inserts_oldest_time: 0000-00-00 00:00:00 -merges_oldest_time: 2020-02-20 08:34:30 -part_mutations_oldest_time: 0000-00-00 00:00:00 -oldest_part_to_get: -oldest_part_to_merge_to: 20200220_20284_20840_7 -oldest_part_to_mutate_to: -log_max_index: 596273 -log_pointer: 596274 -last_queue_update: 2020-02-20 08:34:32 -absolute_delay: 0 -total_replicas: 2 -active_replicas: 2 -``` - -Columna: - -- `database` (`String`) - Nombre de la base de datos -- `table` (`String`) - Nombre de la tabla -- `engine` (`String`) - Nombre del motor de tabla -- `is_leader` (`UInt8`) - Si la réplica es la líder. - Sólo una réplica a la vez puede ser el líder. El líder es responsable de seleccionar las fusiones de fondo para realizar. - Tenga en cuenta que las escrituras se pueden realizar en cualquier réplica que esté disponible y tenga una sesión en ZK, independientemente de si es un líder. -- `can_become_leader` (`UInt8`) - Si la réplica puede ser elegida como líder. -- `is_readonly` (`UInt8`) - Si la réplica está en modo de sólo lectura. - Este modo se activa si la configuración no tiene secciones con ZooKeeper, si se produce un error desconocido al reinicializar sesiones en ZooKeeper y durante la reinicialización de sesiones en ZooKeeper. -- `is_session_expired` (`UInt8`) - la sesión con ZooKeeper ha expirado. Básicamente lo mismo que `is_readonly`. -- `future_parts` (`UInt32`) - El número de partes de datos que aparecerán como resultado de INSERTs o fusiones que aún no se han realizado. -- `parts_to_check` (`UInt32`) - El número de partes de datos en la cola para la verificación. Una pieza se coloca en la cola de verificación si existe la sospecha de que podría estar dañada. -- `zookeeper_path` (`String`) - Ruta de acceso a los datos de la tabla en ZooKeeper. -- `replica_name` (`String`) - Nombre de réplica en ZooKeeper. Diferentes réplicas de la misma tabla tienen diferentes nombres. -- `replica_path` (`String`) - Ruta de acceso a los datos de réplica en ZooKeeper. Lo mismo que concatenar ‘zookeeper\_path/replicas/replica\_path’. -- `columns_version` (`Int32`) - Número de versión de la estructura de la tabla. Indica cuántas veces se realizó ALTER. Si las réplicas tienen versiones diferentes, significa que algunas réplicas aún no han hecho todas las ALTER. -- `queue_size` (`UInt32`) - Tamaño de la cola para las operaciones en espera de ser realizadas. Las operaciones incluyen insertar bloques de datos, fusiones y otras acciones. Por lo general, coincide con `future_parts`. -- `inserts_in_queue` (`UInt32`) - Número de inserciones de bloques de datos que deben realizarse. Las inserciones generalmente se replican con bastante rapidez. Si este número es grande, significa que algo anda mal. -- `merges_in_queue` (`UInt32`) - El número de fusiones en espera de hacerse. A veces las fusiones son largas, por lo que este valor puede ser mayor que cero durante mucho tiempo. -- `part_mutations_in_queue` (`UInt32`) - El número de mutaciones a la espera de hacerse. -- `queue_oldest_time` (`DateTime`) - Si `queue_size` mayor que 0, muestra cuándo se agregó la operación más antigua a la cola. -- `inserts_oldest_time` (`DateTime`) - Ver `queue_oldest_time` -- `merges_oldest_time` (`DateTime`) - Ver `queue_oldest_time` -- `part_mutations_oldest_time` (`DateTime`) - Ver `queue_oldest_time` - -Las siguientes 4 columnas tienen un valor distinto de cero solo cuando hay una sesión activa con ZK. - -- `log_max_index` (`UInt64`) - Número máximo de inscripción en el registro de actividad general. -- `log_pointer` (`UInt64`) - Número máximo de entrada en el registro de actividad general que la réplica copió en su cola de ejecución, más uno. Si `log_pointer` es mucho más pequeño que `log_max_index`, algo está mal. -- `last_queue_update` (`DateTime`) - Cuando la cola se actualizó la última vez. -- `absolute_delay` (`UInt64`) - ¿Qué tan grande retraso en segundos tiene la réplica actual. -- `total_replicas` (`UInt8`) - El número total de réplicas conocidas de esta tabla. -- `active_replicas` (`UInt8`) - El número de réplicas de esta tabla que tienen una sesión en ZooKeeper (es decir, el número de réplicas en funcionamiento). - -Si solicita todas las columnas, la tabla puede funcionar un poco lentamente, ya que se realizan varias lecturas de ZooKeeper para cada fila. -Si no solicita las últimas 4 columnas (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), la tabla funciona rápidamente. - -Por ejemplo, puede verificar que todo funcione correctamente de esta manera: - -``` sql -SELECT - database, - table, - is_leader, - is_readonly, - is_session_expired, - future_parts, - parts_to_check, - columns_version, - queue_size, - inserts_in_queue, - merges_in_queue, - log_max_index, - log_pointer, - total_replicas, - active_replicas -FROM system.replicas -WHERE - is_readonly - OR is_session_expired - OR future_parts > 20 - OR parts_to_check > 10 - OR queue_size > 20 - OR inserts_in_queue > 10 - OR log_max_index - log_pointer > 10 - OR total_replicas < 2 - OR active_replicas < total_replicas -``` - -Si esta consulta no devuelve nada, significa que todo está bien. - -## sistema.configuración {#system-settings} - -Contiene información sobre la configuración actualmente en uso. -Es decir, se usa para ejecutar la consulta que está utilizando para leer del sistema.tabla de configuración. - -Columna: - -- `name` (String) — Setting name. -- `value` (String) — Setting value. -- `description` (String) — Setting description. -- `type` (String) — Setting type (implementation specific string value). -- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. -- `min` (Nullable(String)) — Get minimum allowed value (if any is set via [limitación](settings/constraints_on_settings.md#constraints-on-settings)). -- `max` (Nullable(String)) — Get maximum allowed value (if any is set via [limitación](settings/constraints_on_settings.md#constraints-on-settings)). -- `readonly` (UInt8) — Can user change this setting (for more info, look into [limitación](settings/constraints_on_settings.md#constraints-on-settings)). - -Ejemplo: - -``` sql -SELECT name, value -FROM system.settings -WHERE changed -``` - -``` text -┌─name───────────────────┬─value───────┐ -│ max_threads │ 8 │ -│ use_uncompressed_cache │ 0 │ -│ load_balancing │ random │ -│ max_memory_usage │ 10000000000 │ -└────────────────────────┴─────────────┘ -``` - -## sistema.merge\_tree\_settings {#system-merge_tree_settings} - -Contiene información sobre la configuración `MergeTree` tabla. - -Columna: - -- `name` (String) — Setting name. -- `value` (String) — Setting value. -- `description` (String) — Setting description. -- `type` (String) — Setting type (implementation specific string value). -- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. - -## sistema.table\_engines {#system-table-engines} - -Contiene la descripción de los motores de tablas admitidos por el servidor y su información de soporte de características. - -Esta tabla contiene las siguientes columnas (el tipo de columna se muestra entre corchetes): - -- `name` (String) — The name of table engine. -- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` clausula. -- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [Índices de saltos](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-data_skipping-indexes). -- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). -- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` y `SAMPLE_BY`. -- `supports_replication` (UInt8) — Flag that indicates if table engine supports [Replicación de datos](../engines/table_engines/mergetree_family/replication.md). -- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. - -Ejemplo: - -``` sql -SELECT * -FROM system.table_engines -WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') -``` - -``` text -┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ -│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ -│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ -│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ -└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ -``` - -**Ver también** - -- Familia MergeTree [cláusulas de consulta](../engines/table_engines/mergetree_family/mergetree.md#mergetree-query-clauses) -- Kafka [configuración](../engines/table_engines/integrations/kafka.md#table_engine-kafka-creating-a-table) -- Unir [configuración](../engines/table_engines/special/join.md#join-limitations-and-settings) - -## sistema.tabla {#system-tables} - -Contiene metadatos de cada tabla que el servidor conoce. Las tablas separadas no se muestran en `system.tables`. - -Esta tabla contiene las siguientes columnas (el tipo de columna se muestra entre corchetes): - -- `database` (String) — The name of the database the table is in. - -- `name` (String) — Table name. - -- `engine` (String) — Table engine name (without parameters). - -- `is_temporary` (UInt8): marca que indica si la tabla es temporal. - -- `data_path` (String) - Ruta de acceso a los datos de la tabla en el sistema de archivos. - -- `metadata_path` (String) - Ruta de acceso a los metadatos de la tabla en el sistema de archivos. - -- `metadata_modification_time` (DateTime) - Hora de la última modificación de los metadatos de la tabla. - -- `dependencies_database` (Array(String)) - Dependencias de base de datos. - -- `dependencies_table` (Array(String)) - Dependencias de tabla ([Método de codificación de datos:](../engines/table_engines/special/materializedview.md) tablas basadas en la tabla actual). - -- `create_table_query` (String) - La consulta que se utilizó para crear la tabla. - -- `engine_full` (String) - Parámetros del motor de tabla. - -- `partition_key` (String) - La expresión de clave de partición especificada en la tabla. - -- `sorting_key` (Cadena) - La clave de clasificación de la expresión especificada en la tabla. - -- `primary_key` (String) - La expresión de clave principal especificada en la tabla. - -- `sampling_key` (String) - La expresión de clave de muestreo especificada en la tabla. - -- `storage_policy` (String) - La política de almacenamiento: - - - [Método de codificación de datos:](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) - - [Distribuido](../engines/table_engines/special/distributed.md#distributed) - -- `total_rows` (Nullable(UInt64)) - Número total de filas, si es posible determinar rápidamente el número exacto de filas en la tabla, de lo contrario `Null` (incluyendo underying `Buffer` tabla). - -- `total_bytes` (Nullable(UInt64)) - Número total de bytes, si es posible determinar rápidamente el número exacto de bytes para la tabla en el almacenamiento, de lo contrario `Null` (**no** incluye cualquier almacenamiento subyacente). - - - If the table stores data on disk, returns used space on disk (i.e. compressed). - - Si la tabla almacena datos en la memoria, devuelve el número aproximado de bytes utilizados en la memoria. - -El `system.tables` se utiliza la tabla en `SHOW TABLES` implementación de consultas. - -## sistema.Zookeeper {#system-zookeeper} - -La tabla no existe si ZooKeeper no está configurado. Permite leer datos del clúster ZooKeeper definido en la configuración. -La consulta debe tener un ‘path’ condición de igualdad en la cláusula WHERE. Este es el camino en ZooKeeper para los niños para los que desea obtener datos. - -Consulta `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` salidas de datos para todos los niños en el `/clickhouse` nodo. -Para generar datos para todos los nodos raíz, escriba path = ‘/’. -Si la ruta especificada en ‘path’ no existe, se lanzará una excepción. - -Columna: - -- `name` (String) — The name of the node. -- `path` (String) — The path to the node. -- `value` (String) — Node value. -- `dataLength` (Int32) — Size of the value. -- `numChildren` (Int32) — Number of descendants. -- `czxid` (Int64) — ID of the transaction that created the node. -- `mzxid` (Int64) — ID of the transaction that last changed the node. -- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. -- `ctime` (DateTime) — Time of node creation. -- `mtime` (DateTime) — Time of the last modification of the node. -- `version` (Int32) — Node version: the number of times the node was changed. -- `cversion` (Int32) — Number of added or removed descendants. -- `aversion` (Int32) — Number of changes to the ACL. -- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. - -Ejemplo: - -``` sql -SELECT * -FROM system.zookeeper -WHERE path = '/clickhouse/tables/01-08/visits/replicas' -FORMAT Vertical -``` - -``` text -Row 1: -────── -name: example01-08-1.yandex.ru -value: -czxid: 932998691229 -mzxid: 932998691229 -ctime: 2015-03-27 16:49:51 -mtime: 2015-03-27 16:49:51 -version: 0 -cversion: 47 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021031383 -path: /clickhouse/tables/01-08/visits/replicas - -Row 2: -────── -name: example01-08-2.yandex.ru -value: -czxid: 933002738135 -mzxid: 933002738135 -ctime: 2015-03-27 16:57:01 -mtime: 2015-03-27 16:57:01 -version: 0 -cversion: 37 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021252247 -path: /clickhouse/tables/01-08/visits/replicas -``` - -## sistema.mutación {#system_tables-mutations} - -La tabla contiene información sobre [mutación](../sql_reference/statements/alter.md#alter-mutations) de las tablas MergeTree y su progreso. Cada comando de mutación está representado por una sola fila. La tabla tiene las siguientes columnas: - -**base**, **tabla** - El nombre de la base de datos y la tabla a la que se aplicó la mutación. - -**mutation\_id** - La identificación de la mutación. Para las tablas replicadas, estos identificadores corresponden a los nombres de znode `/mutations/` directorio en ZooKeeper. Para las tablas no duplicadas, los ID corresponden a los nombres de archivo en el directorio de datos de la tabla. - -**comando** - La cadena de comandos de mutación (la parte de la consulta después de `ALTER TABLE [db.]table`). - -**create\_time** - Cuando este comando de mutación fue enviado para su ejecución. - -**block\_numbers.partition\_id**, **block\_numbers.numero** - Una columna anidada. Para las mutaciones de tablas replicadas, contiene un registro para cada partición: el ID de partición y el número de bloque que fue adquirido por la mutación (en cada partición, solo se mutarán las partes que contienen bloques con números menores que el número de bloque adquirido por la mutación en esa partición). En tablas no replicadas, los números de bloque en todas las particiones forman una sola secuencia. Esto significa que para las mutaciones de tablas no replicadas, la columna contendrá un registro con un solo número de bloque adquirido por la mutación. - -**partes\_a\_do** - El número de partes de datos que deben mutarse para que finalice la mutación. - -**is\_done** - Es la mutación hecho? Tenga en cuenta que incluso si `parts_to_do = 0` es posible que aún no se haya realizado una mutación de una tabla replicada debido a un INSERT de larga ejecución que creará una nueva parte de datos que deberá mutarse. - -Si hubo problemas con la mutación de algunas partes, las siguientes columnas contienen información adicional: - -**Método de codificación de datos:** - El nombre de la parte más reciente que no se pudo mutar. - -**Método de codificación de datos:** - El momento del fracaso de la mutación de la parte más reciente. - -**Método de codificación de datos:** - El mensaje de excepción que causó el error de mutación de parte más reciente. - -## sistema.disco {#system_tables-disks} - -Contiene información sobre los discos definidos en el [configuración del servidor](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Columna: - -- `name` ([Cadena](../sql_reference/data_types/string.md)) — Name of a disk in the server configuration. -- `path` ([Cadena](../sql_reference/data_types/string.md)) — Path to the mount point in the file system. -- `free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Free space on disk in bytes. -- `total_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Disk volume in bytes. -- `keep_free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` parámetro de configuración del disco. - -## sistema.almacenamiento\_policies {#system_tables-storage_policies} - -Contiene información sobre las directivas de almacenamiento y los volúmenes [configuración del servidor](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Columna: - -- `policy_name` ([Cadena](../sql_reference/data_types/string.md)) — Name of the storage policy. -- `volume_name` ([Cadena](../sql_reference/data_types/string.md)) — Volume name defined in the storage policy. -- `volume_priority` ([UInt64](../sql_reference/data_types/int_uint.md)) — Volume order number in the configuration. -- `disks` ([Array(Cadena)](../sql_reference/data_types/array.md)) — Disk names, defined in the storage policy. -- `max_data_part_size` ([UInt64](../sql_reference/data_types/int_uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). -- `move_factor` ([Float64](../sql_reference/data_types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. - -Si la directiva de almacenamiento contiene más de un volumen, la información de cada volumen se almacena en la fila individual de la tabla. - -[Artículo Original](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/es/operations/tips.md b/docs/es/operations/tips.md index 19f34f834fc..4d3e76c7d62 100644 --- a/docs/es/operations/tips.md +++ b/docs/es/operations/tips.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 58 toc_title: Recomendaciones de uso --- @@ -46,7 +46,7 @@ Las páginas enormes permanentes tampoco necesitan ser asignadas. ## Subsistema de almacenamiento {#storage-subsystem} Si su presupuesto le permite usar SSD, use SSD. -Si no, utilice el disco duro. Discos Duros SATA de 7200 RPM va a hacer. +Si no, use HDD. Los discos duros SATA 7200 RPM servirán. Dar preferencia a una gran cantidad de servidores con discos duros locales sobre un número menor de servidores con estantes de discos conectados. Pero para almacenar archivos con consultas raras, los estantes funcionarán. @@ -105,7 +105,7 @@ Si desea dividir un clúster ZooKeeper existente en dos, la forma correcta es au No ejecute ZooKeeper en los mismos servidores que ClickHouse. Porque ZooKeeper es muy sensible a la latencia y ClickHouse puede utilizar todos los recursos del sistema disponibles. -Con la configuración predeterminada, Cuidador es una bomba de tiempo: +Con la configuración predeterminada, ZooKeeper es una bomba de tiempo: > El servidor ZooKeeper no eliminará archivos de instantáneas y registros antiguos cuando utilice la configuración predeterminada (consulte autopurge), y esto es responsabilidad del operador. diff --git a/docs/es/operations/troubleshooting.md b/docs/es/operations/troubleshooting.md index 70467a0cca4..04b00e4a5cd 100644 --- a/docs/es/operations/troubleshooting.md +++ b/docs/es/operations/troubleshooting.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 46 toc_title: "Soluci\xF3n de problemas" --- @@ -14,10 +14,10 @@ toc_title: "Soluci\xF3n de problemas" ## Instalación {#troubleshooting-installation-errors} -### No puede obtener paquetes Deb del repositorio de Clickhouse con Apt-get {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} +### No puede obtener paquetes Deb del repositorio ClickHouse con Apt-get {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} - Compruebe la configuración del firewall. -- Si no puede acceder al repositorio por cualquier motivo, descargue los paquetes como se describe en el [Primeros pasos](../getting_started/index.md) artículo e instálelos manualmente usando el `sudo dpkg -i ` comando. También necesitará el `tzdata` paquete. +- Si no puede acceder al repositorio por cualquier motivo, descargue los paquetes como se describe en el [Primeros pasos](../getting-started/index.md) artículo e instálelos manualmente usando el `sudo dpkg -i ` comando. También necesitará el `tzdata` paquete. ## Conexión al servidor {#troubleshooting-accepts-no-connections} @@ -105,7 +105,7 @@ Comprobar: - Configuración del punto final. - Comprobar [listen\_host](server_configuration_parameters/settings.md#server_configuration_parameters-listen_host) y [Tcp\_port](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port) configuración. + Comprobar [listen\_host](server-configuration-parameters/settings.md#server_configuration_parameters-listen_host) y [Tcp\_port](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port) configuración. El servidor ClickHouse acepta conexiones localhost solo de forma predeterminada. @@ -117,8 +117,8 @@ Comprobar: Comprobar: - - El [Tcp\_port\_secure](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) configuración. - - Ajustes para [Sertificados SSL](server_configuration_parameters/settings.md#server_configuration_parameters-openssl). + - El [Tcp\_port\_secure](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) configuración. + - Ajustes para [Sertificados SSL](server-configuration-parameters/settings.md#server_configuration_parameters-openssl). Utilice los parámetros adecuados mientras se conecta. Por ejemplo, utilice el `port_secure` parámetro con `clickhouse_client`. diff --git a/docs/es/operations/update.md b/docs/es/operations/update.md index b391af9adc3..11d15381d72 100644 --- a/docs/es/operations/update.md +++ b/docs/es/operations/update.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 47 toc_title: "Actualizaci\xF3n de ClickHouse" --- diff --git a/docs/es/operations/utilities/clickhouse-benchmark.md b/docs/es/operations/utilities/clickhouse-benchmark.md index e1b59ac2255..9bcafa40dfe 100644 --- a/docs/es/operations/utilities/clickhouse-benchmark.md +++ b/docs/es/operations/utilities/clickhouse-benchmark.md @@ -1,11 +1,11 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 61 toc_title: Sistema abierto. --- -# Sistema abierto. {#clickhouse-benchmark} +# Sistema abierto {#clickhouse-benchmark} Se conecta a un servidor ClickHouse y envía repetidamente las consultas especificadas. @@ -38,7 +38,7 @@ clickhouse-benchmark [keys] < queries_file - `-c N`, `--concurrency=N` — Number of queries that `clickhouse-benchmark` se envía simultáneamente. Valor predeterminado: 1. - `-d N`, `--delay=N` — Interval in seconds between intermediate reports (set 0 to disable reports). Default value: 1. -- `-h WORD`, `--host=WORD` — Server host. Default value: `localhost`. Para el [modo de comparación](#clickhouse-benchmark-comparison-mode) se pueden utilizar varios `-h` claves. +- `-h WORD`, `--host=WORD` — Server host. Default value: `localhost`. Para el [modo de comparación](#clickhouse-benchmark-comparison-mode) puedes usar múltiples `-h` claves. - `-p N`, `--port=N` — Server port. Default value: 9000. For the [modo de comparación](#clickhouse-benchmark-comparison-mode) puedes usar múltiples `-p` claves. - `-i N`, `--iterations=N` — Total number of queries. Default value: 0. - `-r`, `--randomize` — Random order of queries execution if there is more then one input query. @@ -91,7 +91,7 @@ En el informe puedes encontrar: - Punto final del servidor ClickHouse. - Número de consultas procesadas. - - QPS: QPS: ¿cuántas consultas servidor realizó por segundo durante un período de tiempo especificado en el `--delay` argumento. + - QPS: QPS: ¿Cuántas consultas realizó el servidor por segundo durante un período `--delay` argumento. - RPS: ¿Cuántas filas lee el servidor por segundo durante un período `--delay` argumento. - MiB/s: ¿Cuántos mebibytes servidor leído por segundo durante un período especificado en el `--delay` argumento. - resultado RPS: ¿Cuántas filas colocadas por el servidor al resultado de una consulta por segundo durante un período `--delay` argumento. diff --git a/docs/es/operations/utilities/clickhouse-copier.md b/docs/es/operations/utilities/clickhouse-copier.md index 917c4d41939..5717ffaa737 100644 --- a/docs/es/operations/utilities/clickhouse-copier.md +++ b/docs/es/operations/utilities/clickhouse-copier.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 59 toc_title: "M\xE9todo de codificaci\xF3n de datos:" --- @@ -26,7 +26,7 @@ Después de comenzar, `clickhouse-copier`: Para reducir el tráfico de red, recomendamos ejecutar `clickhouse-copier` en el mismo servidor donde se encuentran los datos de origen. -## Ejecución de clickhouse-copiadora {#running-clickhouse-copier} +## Ejecución de Clickhouse-copiadora {#running-clickhouse-copier} La utilidad debe ejecutarse manualmente: @@ -43,7 +43,7 @@ Parámetros: - `task-upload-force` — Force upload `task-file` incluso si el nodo ya existe. - `base-dir` — The path to logs and auxiliary files. When it starts, `clickhouse-copier` crear `clickhouse-copier_YYYYMMHHSS_` subdirectorios en `$base-dir`. Si se omite este parámetro, los directorios se crean en el directorio donde `clickhouse-copier` se puso en marcha. -## Formato de zookeeper.XML {#format-of-zookeeper-xml} +## Formato de Zookeeper.XML {#format-of-zookeeper-xml} ``` xml diff --git a/docs/es/operations/utilities/clickhouse-local.md b/docs/es/operations/utilities/clickhouse-local.md index d96eda80048..e122f668f53 100644 --- a/docs/es/operations/utilities/clickhouse-local.md +++ b/docs/es/operations/utilities/clickhouse-local.md @@ -1,15 +1,15 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 60 -toc_title: Sistema abierto +toc_title: clickhouse-local --- -# Sistema abierto. {#clickhouse-local} +# clickhouse-local {#clickhouse-local} El `clickhouse-local` El programa le permite realizar un procesamiento rápido en archivos locales, sin tener que implementar y configurar el servidor ClickHouse. -Acepta datos que representan tablas y las consulta usando [Nombre de la red inalámbrica (SSID):](../../sql_reference/index.md). +Acepta datos que representan tablas y las consulta usando [Nombre de la red inalámbrica (SSID):](../../sql-reference/index.md). `clickhouse-local` utiliza el mismo núcleo que el servidor ClickHouse, por lo que es compatible con la mayoría de las características y el mismo conjunto de formatos y motores de tabla. diff --git a/docs/es/operations/utilities/index.md b/docs/es/operations/utilities/index.md index 221b043986a..a69397a326c 100644 --- a/docs/es/operations/utilities/index.md +++ b/docs/es/operations/utilities/index.md @@ -1,14 +1,14 @@ --- machine_translated: true -machine_translated_rev: 3e185d24c9fe772c7cf03d5475247fb829a21dfa -toc_folder_title: Utilities +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Utilidad toc_priority: 56 toc_title: "Descripci\xF3n" --- # Utilidad ClickHouse {#clickhouse-utility} -- [Sistema abierto.](clickhouse-local.md) — Allows running SQL queries on data without stopping the ClickHouse server, similar to how `awk` hace esto. +- [Sistema abierto.](clickhouse-local.md#clickhouse-local) — Allows running SQL queries on data without stopping the ClickHouse server, similar to how `awk` hace esto. - [Método de codificación de datos:](clickhouse-copier.md) — Copies (and reshards) data from one cluster to another cluster. - [Sistema abierto.](clickhouse-benchmark.md) — Loads server with the custom queries and settings. diff --git a/docs/es/roadmap.md b/docs/es/roadmap.md index 11934c67422..60db1c608df 100644 --- a/docs/es/roadmap.md +++ b/docs/es/roadmap.md @@ -2,7 +2,7 @@ machine_translated: true --- -# Hoja de ruta {#roadmap} +# Hoja De Ruta {#roadmap} ## Q1 2020 {#q1-2020} diff --git a/docs/es/sql-reference/aggregate-functions/combinators.md b/docs/es/sql-reference/aggregate-functions/combinators.md new file mode 100644 index 00000000000..c9fdcb9478f --- /dev/null +++ b/docs/es/sql-reference/aggregate-functions/combinators.md @@ -0,0 +1,245 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: Combinadores +--- + +# Combinadores de funciones agregadas {#aggregate_functions_combinators} + +El nombre de una función agregada puede tener un sufijo anexado. Esto cambia la forma en que funciona la función de agregado. + +## -Si {#agg-functions-combinator-if} + +The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). + +Ejemplos: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` y así sucesivamente. + +Con las funciones de agregado condicional, puede calcular agregados para varias condiciones a la vez, sin utilizar subconsultas y `JOIN`Por ejemplo, en Yandex.Metrica, las funciones de agregado condicional se utilizan para implementar la funcionalidad de comparación de segmentos. + +## -Matriz {#agg-functions-combinator-array} + +El sufijo -Array se puede agregar a cualquier función agregada. En este caso, la función de agregado toma argumentos del ‘Array(T)’ tipo (arrays) en lugar de ‘T’ argumentos de tipo. Si la función de agregado acepta varios argumentos, deben ser matrices de igual longitud. Al procesar matrices, la función de agregado funciona como la función de agregado original en todos los elementos de la matriz. + +Ejemplo 1: `sumArray(arr)` - Totales de todos los elementos de todos ‘arr’ matriz. En este ejemplo, podría haber sido escrito más simplemente: `sum(arraySum(arr))`. + +Ejemplo 2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ matriz. Esto podría hacerse de una manera más fácil: `uniq(arrayJoin(arr))`, pero no siempre es posible agregar ‘arrayJoin’ a una consulta. + +-If y -Array se pueden combinar. Obstante, ‘Array’ debe venir primero, entonces ‘If’. Ejemplos: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. Debido a este pedido, el ‘cond’ argumento no será una matriz. + +## -Estado {#agg-functions-combinator-state} + +Si aplica este combinador, la función de agregado no devuelve el valor resultante (como el número de valores únicos para el [uniq](reference.md#agg_function-uniq) función), pero un estado intermedio de la agregación (para `uniq`, esta es la tabla hash para calcular el número de valores únicos). Este es un `AggregateFunction(...)` que puede ser utilizado para su posterior procesamiento o almacenado en una tabla para terminar de agregar más tarde. + +Para trabajar con estos estados, use: + +- [AgregaciónMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) motor de mesa. +- [finalizeAggregation](../../sql-reference/functions/other-functions.md#function-finalizeaggregation) función. +- [runningAccumulate](../../sql-reference/functions/other-functions.md#function-runningaccumulate) función. +- [-Fusionar](#aggregate_functions_combinators-merge) combinador. +- [-MergeState](#aggregate_functions_combinators-mergestate) combinador. + +## -Fusionar {#aggregate_functions_combinators-merge} + +Si aplica este combinador, la función de agregado toma el estado de agregación intermedio como argumento, combina los estados para finalizar la agregación y devuelve el valor resultante. + +## -MergeState {#aggregate_functions_combinators-mergestate} + +Combina los estados de agregación intermedios de la misma manera que el combinador -Merge. Sin embargo, no devuelve el valor resultante, sino un estado de agregación intermedio, similar al combinador -State. + +## -ForEach {#agg-functions-combinator-foreach} + +Convierte una función de agregado para tablas en una función de agregado para matrices que agrega los elementos de matriz correspondientes y devuelve una matriz de resultados. Por ejemplo, `sumForEach` para las matrices `[1, 2]`, `[3, 4, 5]`y`[6, 7]`devuelve el resultado `[10, 13, 5]` después de agregar los elementos de la matriz correspondientes. + +## -OPor defecto {#agg-functions-combinator-ordefault} + +Cambia el comportamiento de una función agregada. + +Si una función agregada no tiene valores de entrada, con este combinador devuelve el valor predeterminado para su tipo de datos de retorno. Se aplica a las funciones agregadas que pueden tomar datos de entrada vacíos. + +`-OrDefault` se puede utilizar con otros combinadores. + +**Sintaxis** + +``` sql +OrDefault(x) +``` + +**Parámetros** + +- `x` — Aggregate function parameters. + +**Valores devueltos** + +Devuelve el valor predeterminado del tipo devuelto de una función de agregado si no hay nada que agregar. + +El tipo depende de la función de agregado utilizada. + +**Ejemplo** + +Consulta: + +``` sql +SELECT avg(number), avgOrDefault(number) FROM numbers(0) +``` + +Resultado: + +``` text +┌─avg(number)─┬─avgOrDefault(number)─┐ +│ nan │ 0 │ +└─────────────┴──────────────────────┘ +``` + +También `-OrDefault` se puede utilizar con otros combinadores. Es útil cuando la función de agregado no acepta la entrada vacía. + +Consulta: + +``` sql +SELECT avgOrDefaultIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Resultado: + +``` text +┌─avgOrDefaultIf(x, greater(x, 10))─┐ +│ 0.00 │ +└───────────────────────────────────┘ +``` + +## -OrNull {#agg-functions-combinator-ornull} + +Cambia el comportamiento de una función agregada. + +Este combinador convierte un resultado de una función agregada en [NULL](../data-types/nullable.md) tipo de datos. Si la función de agregado no tiene valores para calcular devuelve [NULL](../syntax.md#null-literal). + +`-OrNull` se puede utilizar con otros combinadores. + +**Sintaxis** + +``` sql +OrNull(x) +``` + +**Parámetros** + +- `x` — Aggregate function parameters. + +**Valores devueltos** + +- El resultado de la función de agregado, convertida a la `Nullable` tipo de datos. +- `NULL`, si no hay nada que agregar. + +Tipo: `Nullable(aggregate function return type)`. + +**Ejemplo** + +Añadir `-orNull` hasta el final de la función agregada. + +Consulta: + +``` sql +SELECT sumOrNull(number), toTypeName(sumOrNull(number)) FROM numbers(10) WHERE number > 10 +``` + +Resultado: + +``` text +┌─sumOrNull(number)─┬─toTypeName(sumOrNull(number))─┐ +│ ᴺᵁᴸᴸ │ Nullable(UInt64) │ +└───────────────────┴───────────────────────────────┘ +``` + +También `-OrNull` se puede utilizar con otros combinadores. Es útil cuando la función de agregado no acepta la entrada vacía. + +Consulta: + +``` sql +SELECT avgOrNullIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Resultado: + +``` text +┌─avgOrNullIf(x, greater(x, 10))─┐ +│ ᴺᵁᴸᴸ │ +└────────────────────────────────┘ +``` + +## -Remuestrear {#agg-functions-combinator-resample} + +Permite dividir los datos en grupos y, a continuación, agregar por separado los datos de esos grupos. Los grupos se crean dividiendo los valores de una columna en intervalos. + +``` sql +Resample(start, end, step)(, resampling_key) +``` + +**Parámetros** + +- `start` — Starting value of the whole required interval for `resampling_key` valor. +- `stop` — Ending value of the whole required interval for `resampling_key` valor. Todo el intervalo no incluye el `stop` valor `[start, stop)`. +- `step` — Step for separating the whole interval into subintervals. The `aggFunction` se ejecuta sobre cada uno de esos subintervalos de forma independiente. +- `resampling_key` — Column whose values are used for separating data into intervals. +- `aggFunction_params` — `aggFunction` parámetros. + +**Valores devueltos** + +- Matriz de `aggFunction` resultados para cada subintervalo. + +**Ejemplo** + +Considere el `people` con los siguientes datos: + +``` text +┌─name───┬─age─┬─wage─┐ +│ John │ 16 │ 10 │ +│ Alice │ 30 │ 15 │ +│ Mary │ 35 │ 8 │ +│ Evelyn │ 48 │ 11.5 │ +│ David │ 62 │ 9.9 │ +│ Brian │ 60 │ 16 │ +└────────┴─────┴──────┘ +``` + +Obtengamos los nombres de las personas cuya edad se encuentra en los intervalos de `[30,60)` y `[60,75)`. Como usamos la representación entera para la edad, obtenemos edades en el `[30, 59]` y `[60,74]` intervalo. + +Para agregar nombres en una matriz, usamos el [Método de codificación de datos:](reference.md#agg_function-grouparray) función de agregado. Se necesita un argumento. En nuestro caso, es el `name` columna. El `groupArrayResample` función debe utilizar el `age` columna para agregar nombres por edad. Para definir los intervalos requeridos, pasamos el `30, 75, 30` discusiones sobre el `groupArrayResample` función. + +``` sql +SELECT groupArrayResample(30, 75, 30)(name, age) FROM people +``` + +``` text +┌─groupArrayResample(30, 75, 30)(name, age)─────┐ +│ [['Alice','Mary','Evelyn'],['David','Brian']] │ +└───────────────────────────────────────────────┘ +``` + +Considera los resultados. + +`Jonh` est? fuera de la muestra porque es demasiado joven. Otras personas se distribuyen de acuerdo con los intervalos de edad especificados. + +Ahora vamos a contar el número total de personas y su salario promedio en los intervalos de edad especificados. + +``` sql +SELECT + countResample(30, 75, 30)(name, age) AS amount, + avgResample(30, 75, 30)(wage, age) AS avg_wage +FROM people +``` + +``` text +┌─amount─┬─avg_wage──────────────────┐ +│ [3,2] │ [11.5,12.949999809265137] │ +└────────┴───────────────────────────┘ +``` + +[Artículo Original](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/es/sql-reference/aggregate-functions/index.md b/docs/es/sql-reference/aggregate-functions/index.md new file mode 100644 index 00000000000..7c7d58d5f94 --- /dev/null +++ b/docs/es/sql-reference/aggregate-functions/index.md @@ -0,0 +1,62 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Funciones agregadas +toc_priority: 33 +toc_title: "Implantaci\xF3n" +--- + +# Funciones agregadas {#aggregate-functions} + +Las funciones agregadas funcionan en el [normal](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) forma esperada por los expertos en bases de datos. + +ClickHouse también es compatible: + +- [Funciones agregadas paramétricas](parametric-functions.md#aggregate_functions_parametric) que aceptan otros parámetros además de las columnas. +- [Combinadores](combinators.md#aggregate_functions_combinators), que cambian el comportamiento de las funciones agregadas. + +## Procesamiento NULL {#null-processing} + +Durante la agregación, todos `NULL`s se omiten. + +**Ejemplos:** + +Considere esta tabla: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +Digamos que necesita sumar los valores en el `y` columna: + +``` sql +SELECT sum(y) FROM t_null_big +``` + + ┌─sum(y)─┐ + │ 7 │ + └────────┘ + +El `sum` función interpreta `NULL` como `0`. En particular, esto significa que si la función recibe la entrada de una selección donde todos los valores son `NULL`, entonces el resultado será `0`, ni `NULL`. + +Ahora puedes usar el `groupArray` función para crear una matriz a partir de la `y` columna: + +``` sql +SELECT groupArray(y) FROM t_null_big +``` + +``` text +┌─groupArray(y)─┐ +│ [2,2,3] │ +└───────────────┘ +``` + +`groupArray` no incluye `NULL` en la matriz resultante. + +[Artículo Original](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/es/sql-reference/aggregate-functions/parametric-functions.md b/docs/es/sql-reference/aggregate-functions/parametric-functions.md new file mode 100644 index 00000000000..9aac66ae47e --- /dev/null +++ b/docs/es/sql-reference/aggregate-functions/parametric-functions.md @@ -0,0 +1,499 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "Param\xE9trico" +--- + +# Funciones agregadas paramétricas {#aggregate_functions_parametric} + +Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. + +## histograma {#histogram} + +Calcula un histograma adaptativo. No garantiza resultados precisos. + +``` sql +histogram(number_of_bins)(values) +``` + +Las funciones utiliza [Un algoritmo de árbol de decisión paralelo de transmisión](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). Los bordes de los contenedores de histograma se ajustan a medida que los nuevos datos entran en una función. En caso común, los anchos de los contenedores no son iguales. + +**Parámetros** + +`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. +`values` — [Expresion](../syntax.md#syntax-expressions) resultando en valores de entrada. + +**Valores devueltos** + +- [Matriz](../../sql-reference/data-types/array.md) de [Tuples](../../sql-reference/data-types/tuple.md) del siguiente formato: + + ``` + [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] + ``` + + - `lower` — Lower bound of the bin. + - `upper` — Upper bound of the bin. + - `height` — Calculated height of the bin. + +**Ejemplo** + +``` sql +SELECT histogram(5)(number + 1) +FROM ( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ +│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +Puede visualizar un histograma con el [Bar](../../sql-reference/functions/other-functions.md#function-bar) función, por ejemplo: + +``` sql +WITH histogram(5)(rand() % 100) AS hist +SELECT + arrayJoin(hist).3 AS height, + bar(height, 0, 6, 5) AS bar +FROM +( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─height─┬─bar───┐ +│ 2.125 │ █▋ │ +│ 3.25 │ ██▌ │ +│ 5.625 │ ████▏ │ +│ 5.625 │ ████▏ │ +│ 3.375 │ ██▌ │ +└────────┴───────┘ +``` + +En este caso, debe recordar que no conoce los bordes del contenedor del histograma. + +## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} + +Comprueba si la secuencia contiene una cadena de eventos que coincida con el patrón. + +``` sql +sequenceMatch(pattern)(timestamp, cond1, cond2, ...) +``` + +!!! warning "Advertencia" + Los eventos que ocurren en el mismo segundo pueden estar en la secuencia en un orden indefinido que afecta el resultado. + +**Parámetros** + +- `pattern` — Pattern string. See [Sintaxis de patrón](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` y `DateTime`. También puede utilizar cualquiera de los [UInt](../../sql-reference/data-types/int-uint.md) tipos de datos. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. Puede pasar hasta 32 argumentos de condición. La función sólo tiene en cuenta los eventos descritos en estas condiciones. Si la secuencia contiene datos que no se describen en una condición, la función los omite. + +**Valores devueltos** + +- 1, si el patrón coincide. +- 0, si el patrón no coincide. + +Tipo: `UInt8`. + + +**Sintaxis de patrón** + +- `(?N)` — Matches the condition argument at position `N`. Las condiciones están numeradas en el `[1, 32]` gama. Por ejemplo, `(?1)` coincide con el argumento pasado al `cond1` parámetro. + +- `.*` — Matches any number of events. You don't need conditional arguments to match this element of the pattern. + +- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` coincide con los eventos que ocurren a más de 1800 segundos el uno del otro. Un número arbitrario de cualquier evento puede estar entre estos eventos. Puede usar el `>=`, `>`, `<`, `<=` operador. + +**Ejemplos** + +Considere los datos en el `t` tabla: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +└──────┴────────┘ +``` + +Realizar la consulta: + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 1 │ +└───────────────────────────────────────────────────────────────────────┘ +``` + +La función encontró la cadena de eventos donde el número 2 sigue al número 1. Se saltó el número 3 entre ellos, porque el número no se describe como un evento. Si queremos tener en cuenta este número al buscar la cadena de eventos dada en el ejemplo, debemos establecer una condición para ello. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ +│ 0 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +En este caso, la función no pudo encontrar la cadena de eventos que coincida con el patrón, porque el evento para el número 3 ocurrió entre 1 y 2. Si en el mismo caso comprobamos la condición para el número 4, la secuencia coincidiría con el patrón. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ +│ 1 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Ver también** + +- [sequenceCount](#function-sequencecount) + +## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} + +Cuenta el número de cadenas de eventos que coinciden con el patrón. La función busca cadenas de eventos que no se superponen. Comienza a buscar la siguiente cadena después de que se haga coincidir la cadena actual. + +!!! warning "Advertencia" + Los eventos que ocurren en el mismo segundo pueden estar en la secuencia en un orden indefinido que afecta el resultado. + +``` sql +sequenceCount(pattern)(timestamp, cond1, cond2, ...) +``` + +**Parámetros** + +- `pattern` — Pattern string. See [Sintaxis de patrón](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` y `DateTime`. También puede utilizar cualquiera de los [UInt](../../sql-reference/data-types/int-uint.md) tipos de datos. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. Puede pasar hasta 32 argumentos de condición. La función sólo tiene en cuenta los eventos descritos en estas condiciones. Si la secuencia contiene datos que no se describen en una condición, la función los omite. + +**Valores devueltos** + +- Número de cadenas de eventos no superpuestas que coinciden. + +Tipo: `UInt64`. + +**Ejemplo** + +Considere los datos en el `t` tabla: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +│ 4 │ 1 │ +│ 5 │ 3 │ +│ 6 │ 2 │ +└──────┴────────┘ +``` + +Cuente cuántas veces ocurre el número 2 después del número 1 con cualquier cantidad de otros números entre ellos: + +``` sql +SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 2 │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +**Ver también** + +- [sequenceMatch](#function-sequencematch) + +## ventanaEmbudo {#windowfunnel} + +Busca cadenas de eventos en una ventana de tiempo deslizante y calcula el número máximo de eventos que ocurrieron desde la cadena. + +La función funciona de acuerdo con el algoritmo: + +- La función busca datos que desencadenan la primera condición en la cadena y establece el contador de eventos en 1. Este es el momento en que comienza la ventana deslizante. + +- Si los eventos de la cadena ocurren secuencialmente dentro de la ventana, el contador se incrementa. Si se interrumpe la secuencia de eventos, el contador no se incrementa. + +- Si los datos tienen varias cadenas de eventos en diferentes puntos de finalización, la función solo generará el tamaño de la cadena más larga. + +**Sintaxis** + +``` sql +windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) +``` + +**Parámetros** + +- `window` — Length of the sliding window in seconds. +- `mode` - Es un argumento opcional. + - `'strict'` - Cuando el `'strict'` se establece, windowFunnel() aplica condiciones solo para los valores únicos. +- `timestamp` — Name of the column containing the timestamp. Data types supported: [Fecha](../../sql-reference/data-types/date.md), [FechaHora](../../sql-reference/data-types/datetime.md#data_type-datetime) y otros tipos de enteros sin signo (tenga en cuenta que aunque timestamp admite el `UInt64` tipo, su valor no puede exceder el máximo de Int64, que es 2 ^ 63 - 1). +- `cond` — Conditions or data describing the chain of events. [UInt8](../../sql-reference/data-types/int-uint.md). + +**Valor devuelto** + +El número máximo de condiciones desencadenadas consecutivas de la cadena dentro de la ventana de tiempo deslizante. +Se analizan todas las cadenas en la selección. + +Tipo: `Integer`. + +**Ejemplo** + +Determine si un período de tiempo establecido es suficiente para que el usuario seleccione un teléfono y lo compre dos veces en la tienda en línea. + +Establezca la siguiente cadena de eventos: + +1. El usuario inició sesión en su cuenta en la tienda (`eventID = 1003`). +2. El usuario busca un teléfono (`eventID = 1007, product = 'phone'`). +3. El usuario realizó un pedido (`eventID = 1009`). +4. El usuario volvió a realizar el pedido (`eventID = 1010`). + +Tabla de entrada: + +``` text +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +``` + +Averigüe hasta qué punto el usuario `user_id` podría atravesar la cadena en un período de enero a febrero de 2019. + +Consulta: + +``` sql +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level + FROM trend + WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC +``` + +Resultado: + +``` text +┌─level─┬─c─┐ +│ 4 │ 1 │ +└───────┴───┘ +``` + +## retención {#retention} + +La función toma como argumentos un conjunto de condiciones de 1 a 32 argumentos de tipo `UInt8` que indican si se cumplió una determinada condición para el evento. +Cualquier condición se puede especificar como un argumento (como en [WHERE](../../sql-reference/statements/select/where.md#select-where)). + +Las condiciones, excepto la primera, se aplican en pares: el resultado del segundo será verdadero si el primero y el segundo son verdaderos, del tercero si el primero y el fird son verdaderos, etc. + +**Sintaxis** + +``` sql +retention(cond1, cond2, ..., cond32); +``` + +**Parámetros** + +- `cond` — an expression that returns a `UInt8` resultado (1 o 0). + +**Valor devuelto** + +La matriz de 1 o 0. + +- 1 — condition was met for the event. +- 0 — condition wasn't met for the event. + +Tipo: `UInt8`. + +**Ejemplo** + +Consideremos un ejemplo de cálculo del `retention` función para determinar el tráfico del sitio. + +**1.** Сreate a table to illustrate an example. + +``` sql +CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; + +INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); +INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); +INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); +``` + +Tabla de entrada: + +Consulta: + +``` sql +SELECT * FROM retention_test +``` + +Resultado: + +``` text +┌───────date─┬─uid─┐ +│ 2020-01-01 │ 0 │ +│ 2020-01-01 │ 1 │ +│ 2020-01-01 │ 2 │ +│ 2020-01-01 │ 3 │ +│ 2020-01-01 │ 4 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-02 │ 0 │ +│ 2020-01-02 │ 1 │ +│ 2020-01-02 │ 2 │ +│ 2020-01-02 │ 3 │ +│ 2020-01-02 │ 4 │ +│ 2020-01-02 │ 5 │ +│ 2020-01-02 │ 6 │ +│ 2020-01-02 │ 7 │ +│ 2020-01-02 │ 8 │ +│ 2020-01-02 │ 9 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-03 │ 0 │ +│ 2020-01-03 │ 1 │ +│ 2020-01-03 │ 2 │ +│ 2020-01-03 │ 3 │ +│ 2020-01-03 │ 4 │ +│ 2020-01-03 │ 5 │ +│ 2020-01-03 │ 6 │ +│ 2020-01-03 │ 7 │ +│ 2020-01-03 │ 8 │ +│ 2020-01-03 │ 9 │ +│ 2020-01-03 │ 10 │ +│ 2020-01-03 │ 11 │ +│ 2020-01-03 │ 12 │ +│ 2020-01-03 │ 13 │ +│ 2020-01-03 │ 14 │ +└────────────┴─────┘ +``` + +**2.** Agrupar usuarios por ID único `uid` utilizando el `retention` función. + +Consulta: + +``` sql +SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r +FROM retention_test +WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') +GROUP BY uid +ORDER BY uid ASC +``` + +Resultado: + +``` text +┌─uid─┬─r───────┐ +│ 0 │ [1,1,1] │ +│ 1 │ [1,1,1] │ +│ 2 │ [1,1,1] │ +│ 3 │ [1,1,1] │ +│ 4 │ [1,1,1] │ +│ 5 │ [0,0,0] │ +│ 6 │ [0,0,0] │ +│ 7 │ [0,0,0] │ +│ 8 │ [0,0,0] │ +│ 9 │ [0,0,0] │ +│ 10 │ [0,0,0] │ +│ 11 │ [0,0,0] │ +│ 12 │ [0,0,0] │ +│ 13 │ [0,0,0] │ +│ 14 │ [0,0,0] │ +└─────┴─────────┘ +``` + +**3.** Calcule el número total de visitas al sitio por día. + +Consulta: + +``` sql +SELECT + sum(r[1]) AS r1, + sum(r[2]) AS r2, + sum(r[3]) AS r3 +FROM +( + SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r + FROM retention_test + WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') + GROUP BY uid +) +``` + +Resultado: + +``` text +┌─r1─┬─r2─┬─r3─┐ +│ 5 │ 5 │ 5 │ +└────┴────┴────┘ +``` + +Donde: + +- `r1`- el número de visitantes únicos que visitaron el sitio durante 2020-01-01 (la `cond1` condición). +- `r2`- el número de visitantes únicos que visitaron el sitio durante un período de tiempo específico entre 2020-01-01 y 2020-01-02 (`cond1` y `cond2` condición). +- `r3`- el número de visitantes únicos que visitaron el sitio durante un período de tiempo específico entre 2020-01-01 y 2020-01-03 (`cond1` y `cond3` condición). + +## UniqUpTo(N)(x) {#uniquptonx} + +Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. + +Recomendado para usar con Ns pequeños, hasta 10. El valor máximo de N es 100. + +Para el estado de una función agregada, utiliza la cantidad de memoria igual a 1 + N \* el tamaño de un valor de bytes. +Para las cadenas, almacena un hash no criptográfico de 8 bytes. Es decir, el cálculo se aproxima a las cadenas. + +La función también funciona para varios argumentos. + +Funciona lo más rápido posible, excepto en los casos en que se usa un valor N grande y el número de valores únicos es ligeramente menor que N. + +Ejemplo de uso: + +``` text +Problem: Generate a report that shows only keywords that produced at least 5 unique users. +Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 +``` + +[Artículo Original](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) + +## sumMapFiltered(keys\_to\_keep)(claves, valores) {#summapfilteredkeys-to-keepkeys-values} + +El mismo comportamiento que [sumMap](reference.md#agg_functions-summap) excepto que una matriz de claves se pasa como un parámetro. Esto puede ser especialmente útil cuando se trabaja con una alta cardinalidad de claves. diff --git a/docs/es/sql-reference/aggregate-functions/reference.md b/docs/es/sql-reference/aggregate-functions/reference.md new file mode 100644 index 00000000000..b7722ecd221 --- /dev/null +++ b/docs/es/sql-reference/aggregate-functions/reference.md @@ -0,0 +1,1977 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: Referencia +--- + +# Referencia de función agregada {#aggregate-functions-reference} + +## contar {#agg_function-count} + +Cuenta el número de filas o valores no NULL. + +ClickHouse admite las siguientes sintaxis para `count`: +- `count(expr)` o `COUNT(DISTINCT expr)`. +- `count()` o `COUNT(*)`. El `count()` la sintaxis es específica de ClickHouse. + +**Parámetros** + +La función puede tomar: + +- Cero parámetros. +- Una [expresion](../syntax.md#syntax-expressions). + +**Valor devuelto** + +- Si se llama a la función sin parámetros, cuenta el número de filas. +- Si el [expresion](../syntax.md#syntax-expressions) se pasa, entonces la función cuenta cuántas veces esta expresión devuelve no nula. Si la expresión devuelve un [NULL](../../sql-reference/data-types/nullable.md)-type valor, entonces el resultado de `count` no se queda `Nullable`. La función devuelve 0 si la expresión devuelta `NULL` para todas las filas. + +En ambos casos el tipo del valor devuelto es [UInt64](../../sql-reference/data-types/int-uint.md). + +**Detalles** + +ClickHouse soporta el `COUNT(DISTINCT ...)` sintaxis. El comportamiento de esta construcción depende del [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation) configuración. Define cuál de las [uniq\*](#agg_function-uniq) se utiliza para realizar la operación. El valor predeterminado es el [uniqExact](#agg_function-uniqexact) función. + +El `SELECT count() FROM table` consulta no está optimizado, porque el número de entradas en la tabla no se almacena por separado. Elige una pequeña columna de la tabla y cuenta el número de valores en ella. + +**Ejemplos** + +Ejemplo 1: + +``` sql +SELECT count() FROM t +``` + +``` text +┌─count()─┐ +│ 5 │ +└─────────┘ +``` + +Ejemplo 2: + +``` sql +SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' +``` + +``` text +┌─name──────────────────────────┬─value─────┐ +│ count_distinct_implementation │ uniqExact │ +└───────────────────────────────┴───────────┘ +``` + +``` sql +SELECT count(DISTINCT num) FROM t +``` + +``` text +┌─uniqExact(num)─┐ +│ 3 │ +└────────────────┘ +``` + +Este ejemplo muestra que `count(DISTINCT num)` se realiza por el `uniqExact` función según el `count_distinct_implementation` valor de ajuste. + +## cualquiera (x) {#agg_function-any} + +Selecciona el primer valor encontrado. +La consulta se puede ejecutar en cualquier orden e incluso en un orden diferente cada vez, por lo que el resultado de esta función es indeterminado. +Para obtener un resultado determinado, puede usar el ‘min’ o ‘max’ función en lugar de ‘any’. + +En algunos casos, puede confiar en el orden de ejecución. Esto se aplica a los casos en que SELECT proviene de una subconsulta que usa ORDER BY. + +Cuando un `SELECT` consulta tiene el `GROUP BY` cláusula o al menos una función agregada, ClickHouse (en contraste con MySQL) requiere que todas las expresiones `SELECT`, `HAVING`, y `ORDER BY` las cláusulas pueden calcularse a partir de claves o de funciones agregadas. En otras palabras, cada columna seleccionada de la tabla debe usarse en claves o dentro de funciones agregadas. Para obtener un comportamiento como en MySQL, puede colocar las otras columnas en el `any` función de agregado. + +## Cualquier pesado (x) {#anyheavyx} + +Selecciona un valor que ocurre con frecuencia [pesos pesados](http://www.cs.umd.edu/~samir/498/karp.pdf) algoritmo. Si hay un valor que se produce más de la mitad de los casos en cada uno de los subprocesos de ejecución de la consulta, se devuelve este valor. Normalmente, el resultado es no determinista. + +``` sql +anyHeavy(column) +``` + +**Argumento** + +- `column` – The column name. + +**Ejemplo** + +Tome el [A tiempo](../../getting-started/example-datasets/ontime.md) conjunto de datos y seleccione cualquier valor que ocurra con frecuencia `AirlineID` columna. + +``` sql +SELECT anyHeavy(AirlineID) AS res +FROM ontime +``` + +``` text +┌───res─┐ +│ 19690 │ +└───────┘ +``` + +## Cualquier último (x) {#anylastx} + +Selecciona el último valor encontrado. +El resultado es tan indeterminado como para el `any` función. + +## Método de codificación de datos: {#groupbitand} + +Se aplica bit a bit `AND` para la serie de números. + +``` sql +groupBitAnd(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `UInt*` tipo. + +**Valor de retorno** + +Valor de la `UInt*` tipo. + +**Ejemplo** + +Datos de prueba: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Consulta: + +``` sql +SELECT groupBitAnd(num) FROM t +``` + +Donde `num` es la columna con los datos de prueba. + +Resultado: + +``` text +binary decimal +00000100 = 4 +``` + +## GrupoBitO {#groupbitor} + +Se aplica bit a bit `OR` para la serie de números. + +``` sql +groupBitOr(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `UInt*` tipo. + +**Valor de retorno** + +Valor de la `UInt*` tipo. + +**Ejemplo** + +Datos de prueba: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Consulta: + +``` sql +SELECT groupBitOr(num) FROM t +``` + +Donde `num` es la columna con los datos de prueba. + +Resultado: + +``` text +binary decimal +01111101 = 125 +``` + +## GrupoBitXor {#groupbitxor} + +Se aplica bit a bit `XOR` para la serie de números. + +``` sql +groupBitXor(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `UInt*` tipo. + +**Valor de retorno** + +Valor de la `UInt*` tipo. + +**Ejemplo** + +Datos de prueba: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Consulta: + +``` sql +SELECT groupBitXor(num) FROM t +``` + +Donde `num` es la columna con los datos de prueba. + +Resultado: + +``` text +binary decimal +01101000 = 104 +``` + +## Método de codificación de datos: {#groupbitmap} + +Mapa de bits o cálculos agregados de una columna entera sin signo, devuelve cardinalidad de tipo UInt64, si agrega el sufijo -State, luego devuelve [objeto de mapa de bits](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmap(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `UInt*` tipo. + +**Valor de retorno** + +Valor de la `UInt64` tipo. + +**Ejemplo** + +Datos de prueba: + +``` text +UserID +1 +1 +2 +3 +``` + +Consulta: + +``` sql +SELECT groupBitmap(UserID) as num FROM t +``` + +Resultado: + +``` text +num +3 +``` + +## Mínimo (x) {#agg_function-min} + +Calcula el mínimo. + +## máximo (x) {#agg_function-max} + +Calcula el máximo. + +## ¿Cómo puedo hacerlo?) {#agg-function-argmin} + +Calcula el ‘arg’ para un valor mínimo ‘val’ valor. Si hay varios valores diferentes de ‘arg’ para valores mínimos de ‘val’, el primero de estos valores encontrados es la salida. + +**Ejemplo:** + +``` text +┌─user─────┬─salary─┐ +│ director │ 5000 │ +│ manager │ 3000 │ +│ worker │ 1000 │ +└──────────┴────────┘ +``` + +``` sql +SELECT argMin(user, salary) FROM salary +``` + +``` text +┌─argMin(user, salary)─┐ +│ worker │ +└──────────────────────┘ +``` + +## Descripción) {#agg-function-argmax} + +Calcula el ‘arg’ para un valor máximo ‘val’ valor. Si hay varios valores diferentes de ‘arg’ para valores máximos de ‘val’, el primero de estos valores encontrados es la salida. + +## suma (x) {#agg_function-sum} + +Calcula la suma. +Solo funciona para números. + +## ¿Cómo puedo obtener más información?) {#sumwithoverflowx} + +Calcula la suma de los números, utilizando el mismo tipo de datos para el resultado que para los parámetros de entrada. Si la suma supera el valor máximo para este tipo de datos, la función devuelve un error. + +Solo funciona para números. + +## Por ejemplo, el valor es el siguiente:)) {#agg_functions-summap} + +Totals el ‘value’ matriz de acuerdo con las claves especificadas en el ‘key’ matriz. +Pasar una tupla de matrices de claves y valores es sinónimo de pasar dos matrices de claves y valores. +El número de elementos en ‘key’ y ‘value’ debe ser el mismo para cada fila que se sume. +Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. + +Ejemplo: + +``` sql +CREATE TABLE sum_map( + date Date, + timeslot DateTime, + statusMap Nested( + status UInt16, + requests UInt64 + ), + statusMapTuple Tuple(Array(Int32), Array(Int32)) +) ENGINE = Log; +INSERT INTO sum_map VALUES + ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10], ([1, 2, 3], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10], ([3, 4, 5], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10], ([4, 5, 6], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10])); + +SELECT + timeslot, + sumMap(statusMap.status, statusMap.requests), + sumMap(statusMapTuple) +FROM sum_map +GROUP BY timeslot +``` + +``` text +┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┬─sumMap(statusMapTuple)─────────┐ +│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ ([1,2,3,4,5],[10,10,20,10,10]) │ +│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ ([4,5,6,7,8],[10,10,20,10,10]) │ +└─────────────────────┴──────────────────────────────────────────────┴────────────────────────────────┘ +``` + +## SkewPop {#skewpop} + +Calcula el [la asimetría](https://en.wikipedia.org/wiki/Skewness) de una secuencia. + +``` sql +skewPop(expr) +``` + +**Parámetros** + +`expr` — [Expresion](../syntax.md#syntax-expressions) devolviendo un número. + +**Valor devuelto** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Ejemplo** + +``` sql +SELECT skewPop(value) FROM series_with_value_column +``` + +## Sistema abierto {#skewsamp} + +Calcula el [asimetría de la muestra](https://en.wikipedia.org/wiki/Skewness) de una secuencia. + +Representa una estimación imparcial de la asimetría de una variable aleatoria si los valores pasados forman su muestra. + +``` sql +skewSamp(expr) +``` + +**Parámetros** + +`expr` — [Expresion](../syntax.md#syntax-expressions) devolviendo un número. + +**Valor devuelto** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). Si `n <= 1` (`n` es el tamaño de la muestra), luego la función devuelve `nan`. + +**Ejemplo** + +``` sql +SELECT skewSamp(value) FROM series_with_value_column +``` + +## KurtPop {#kurtpop} + +Calcula el [curtosis](https://en.wikipedia.org/wiki/Kurtosis) de una secuencia. + +``` sql +kurtPop(expr) +``` + +**Parámetros** + +`expr` — [Expresion](../syntax.md#syntax-expressions) devolviendo un número. + +**Valor devuelto** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Ejemplo** + +``` sql +SELECT kurtPop(value) FROM series_with_value_column +``` + +## KurtSamp {#kurtsamp} + +Calcula el [curtosis muestra](https://en.wikipedia.org/wiki/Kurtosis) de una secuencia. + +Representa una estimación imparcial de la curtosis de una variable aleatoria si los valores pasados forman su muestra. + +``` sql +kurtSamp(expr) +``` + +**Parámetros** + +`expr` — [Expresion](../syntax.md#syntax-expressions) devolviendo un número. + +**Valor devuelto** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). Si `n <= 1` (`n` es un tamaño de la muestra), luego la función devuelve `nan`. + +**Ejemplo** + +``` sql +SELECT kurtSamp(value) FROM series_with_value_column +``` + +## Para obtener más información, consulta nuestra Política de privacidad y nuestras Condiciones de uso) {#agg-function-timeseriesgroupsum} + +`timeSeriesGroupSum` puede agregar diferentes series de tiempo que muestran la marca de tiempo no la alineación. +Utilizará la interpolación lineal entre dos marcas de tiempo de muestra y luego sumará series temporales juntas. + +- `uid` es la identificación única de la serie temporal, `UInt64`. +- `timestamp` es el tipo Int64 para admitir milisegundos o microsegundos. +- `value` es la métrica. + +La función devuelve una matriz de tuplas con `(timestamp, aggregated_value)` par. + +Antes de utilizar esta función, asegúrese de `timestamp` está en orden ascendente. + +Ejemplo: + +``` text +┌─uid─┬─timestamp─┬─value─┐ +│ 1 │ 2 │ 0.2 │ +│ 1 │ 7 │ 0.7 │ +│ 1 │ 12 │ 1.2 │ +│ 1 │ 17 │ 1.7 │ +│ 1 │ 25 │ 2.5 │ +│ 2 │ 3 │ 0.6 │ +│ 2 │ 8 │ 1.6 │ +│ 2 │ 12 │ 2.4 │ +│ 2 │ 18 │ 3.6 │ +│ 2 │ 24 │ 4.8 │ +└─────┴───────────┴───────┘ +``` + +``` sql +CREATE TABLE time_series( + uid UInt64, + timestamp Int64, + value Float64 +) ENGINE = Memory; +INSERT INTO time_series VALUES + (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), + (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); + +SELECT timeSeriesGroupSum(uid, timestamp, value) +FROM ( + SELECT * FROM time_series order by timestamp ASC +); +``` + +Y el resultado será: + +``` text +[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] +``` + +## También puede utilizar el siguiente ejemplo:) {#agg-function-timeseriesgroupratesum} + +De manera similar a `timeSeriesGroupSum`, `timeSeriesGroupRateSum` calcula la tasa de series temporales y luego suma las tasas juntas. +Además, la marca de tiempo debe estar en orden ascendente antes de usar esta función. + +Aplicando esta función a los datos del `timeSeriesGroupSum` ejemplo, se obtiene el siguiente resultado: + +``` text +[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] +``` + +## Acerca de) {#agg_function-avg} + +Calcula el promedio. +Solo funciona para números. +El resultado es siempre Float64. + +## avgPonderado {#avgweighted} + +Calcula el [media aritmética ponderada](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean). + +**Sintaxis** + +``` sql +avgWeighted(x, weight) +``` + +**Parámetros** + +- `x` — Values. [Entero](../data-types/int-uint.md) o [punto flotante](../data-types/float.md). +- `weight` — Weights of the values. [Entero](../data-types/int-uint.md) o [punto flotante](../data-types/float.md). + +Tipo de `x` y `weight` debe ser el mismo. + +**Valor devuelto** + +- Media ponderada. +- `NaN`. Si todos los pesos son iguales a 0. + +Tipo: [Float64](../data-types/float.md). + +**Ejemplo** + +Consulta: + +``` sql +SELECT avgWeighted(x, w) +FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) +``` + +Resultado: + +``` text +┌─avgWeighted(x, weight)─┐ +│ 8 │ +└────────────────────────┘ +``` + +## uniq {#agg_function-uniq} + +Calcula el número aproximado de diferentes valores del argumento. + +``` sql +uniq(x[, ...]) +``` + +**Parámetros** + +La función toma un número variable de parámetros. Los parámetros pueden ser `Tuple`, `Array`, `Date`, `DateTime`, `String`, o tipos numéricos. + +**Valor devuelto** + +- A [UInt64](../../sql-reference/data-types/int-uint.md)-tipo número. + +**Detalles de implementación** + +Función: + +- Calcula un hash para todos los parámetros en el agregado, luego lo usa en los cálculos. + +- Utiliza un algoritmo de muestreo adaptativo. Para el estado de cálculo, la función utiliza una muestra de valores hash de elemento de hasta 65536. + + This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. + +- Proporciona el resultado de forma determinista (no depende del orden de procesamiento de la consulta). + +Recomendamos usar esta función en casi todos los escenarios. + +**Ver también** + +- [uniqCombined](#agg_function-uniqcombined) +- [UniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined {#agg_function-uniqcombined} + +Calcula el número aproximado de diferentes valores de argumento. + +``` sql +uniqCombined(HLL_precision)(x[, ...]) +``` + +El `uniqCombined` es una buena opción para calcular el número de valores diferentes. + +**Parámetros** + +La función toma un número variable de parámetros. Los parámetros pueden ser `Tuple`, `Array`, `Date`, `DateTime`, `String`, o tipos numéricos. + +`HLL_precision` es el logaritmo base-2 del número de células en [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). Opcional, puede utilizar la función como `uniqCombined(x[, ...])`. El valor predeterminado para `HLL_precision` es 17, que es efectivamente 96 KiB de espacio (2 ^ 17 celdas, 6 bits cada una). + +**Valor devuelto** + +- Numero [UInt64](../../sql-reference/data-types/int-uint.md)-tipo número. + +**Detalles de implementación** + +Función: + +- Calcula un hash (hash de 64 bits para `String` y 32 bits de lo contrario) para todos los parámetros en el agregado, luego lo usa en los cálculos. + +- Utiliza una combinación de tres algoritmos: matriz, tabla hash e HyperLogLog con una tabla de corrección de errores. + + For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. + +- Proporciona el resultado de forma determinista (no depende del orden de procesamiento de la consulta). + +!!! note "Nota" + Dado que usa hash de 32 bits para no-`String` tipo, el resultado tendrá un error muy alto para cardinalidades significativamente mayores que `UINT_MAX` (el error aumentará rápidamente después de unas pocas decenas de miles de millones de valores distintos), por lo tanto, en este caso debe usar [UniqCombined64](#agg_function-uniqcombined64) + +En comparación con el [uniq](#agg_function-uniq) función, el `uniqCombined`: + +- Consume varias veces menos memoria. +- Calcula con una precisión varias veces mayor. +- Por lo general, tiene un rendimiento ligeramente menor. En algunos escenarios, `uniqCombined` puede funcionar mejor que `uniq`, por ejemplo, con consultas distribuidas que transmiten un gran número de estados de agregación a través de la red. + +**Ver también** + +- [uniq](#agg_function-uniq) +- [UniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## UniqCombined64 {#agg_function-uniqcombined64} + +Lo mismo que [uniqCombined](#agg_function-uniqcombined), pero utiliza hash de 64 bits para todos los tipos de datos. + +## uniqHLL12 {#agg_function-uniqhll12} + +Calcula el número aproximado de diferentes valores de argumento [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) algoritmo. + +``` sql +uniqHLL12(x[, ...]) +``` + +**Parámetros** + +La función toma un número variable de parámetros. Los parámetros pueden ser `Tuple`, `Array`, `Date`, `DateTime`, `String`, o tipos numéricos. + +**Valor devuelto** + +- A [UInt64](../../sql-reference/data-types/int-uint.md)-tipo número. + +**Detalles de implementación** + +Función: + +- Calcula un hash para todos los parámetros en el agregado, luego lo usa en los cálculos. + +- Utiliza el algoritmo HyperLogLog para aproximar el número de valores de argumento diferentes. + + 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). + +- Proporciona el resultado determinado (no depende del orden de procesamiento de la consulta). + +No recomendamos usar esta función. En la mayoría de los casos, use el [uniq](#agg_function-uniq) o [uniqCombined](#agg_function-uniqcombined) función. + +**Ver también** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqExact](#agg_function-uniqexact) + +## uniqExact {#agg_function-uniqexact} + +Calcula el número exacto de diferentes valores de argumento. + +``` sql +uniqExact(x[, ...]) +``` + +Utilice el `uniqExact` función si necesita absolutamente un resultado exacto. De lo contrario, use el [uniq](#agg_function-uniq) función. + +El `uniqExact` función utiliza más memoria que `uniq`, porque el tamaño del estado tiene un crecimiento ilimitado a medida que aumenta el número de valores diferentes. + +**Parámetros** + +La función toma un número variable de parámetros. Los parámetros pueden ser `Tuple`, `Array`, `Date`, `DateTime`, `String`, o tipos numéricos. + +**Ver también** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqHLL12](#agg_function-uniqhll12) + +## ¿Cómo puedo hacerlo?) {#agg_function-grouparray} + +Crea una matriz de valores de argumento. +Los valores se pueden agregar a la matriz en cualquier orden (indeterminado). + +La segunda versión (con el `max_size` parámetro) limita el tamaño de la matriz resultante a `max_size` elemento. +Por ejemplo, `groupArray (1) (x)` es equivalente a `[any (x)]`. + +En algunos casos, aún puede confiar en el orden de ejecución. Esto se aplica a los casos en que `SELECT` procede de una subconsulta que utiliza `ORDER BY`. + +## GrupoArrayInsertAt {#grouparrayinsertat} + +Inserta un valor en la matriz en la posición especificada. + +**Sintaxis** + +``` sql +groupArrayInsertAt(default_x, size)(x, pos); +``` + +Si en una consulta se insertan varios valores en la misma posición, la función se comporta de las siguientes maneras: + +- Si se ejecuta una consulta en un solo subproceso, se utiliza el primero de los valores insertados. +- Si una consulta se ejecuta en varios subprocesos, el valor resultante es uno indeterminado de los valores insertados. + +**Parámetros** + +- `x` — Value to be inserted. [Expresion](../syntax.md#syntax-expressions) lo que resulta en uno de los [tipos de datos compatibles](../../sql-reference/data-types/index.md). +- `pos` — Position at which the specified element `x` se va a insertar. La numeración de índices en la matriz comienza desde cero. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). +- `default_x`— Default value for substituting in empty positions. Optional parameter. [Expresion](../syntax.md#syntax-expressions) dando como resultado el tipo de datos configurado para `x` parámetro. Si `default_x` no está definido, el [valores predeterminados](../../sql-reference/statements/create.md#create-default-values) se utilizan. +- `size`— Length of the resulting array. Optional parameter. When using this parameter, the default value `default_x` debe ser especificado. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). + +**Valor devuelto** + +- Matriz con valores insertados. + +Tipo: [Matriz](../../sql-reference/data-types/array.md#data-type-array). + +**Ejemplo** + +Consulta: + +``` sql +SELECT groupArrayInsertAt(toString(number), number * 2) FROM numbers(5); +``` + +Resultado: + +``` text +┌─groupArrayInsertAt(toString(number), multiply(number, 2))─┐ +│ ['0','','1','','2','','3','','4'] │ +└───────────────────────────────────────────────────────────┘ +``` + +Consulta: + +``` sql +SELECT groupArrayInsertAt('-')(toString(number), number * 2) FROM numbers(5); +``` + +Resultado: + +``` text +┌─groupArrayInsertAt('-')(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2','-','3','-','4'] │ +└────────────────────────────────────────────────────────────────┘ +``` + +Consulta: + +``` sql +SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); +``` + +Resultado: + +``` text +┌─groupArrayInsertAt('-', 5)(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2'] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +Inserción multihilo de elementos en una posición. + +Consulta: + +``` sql +SELECT groupArrayInsertAt(number, 0) FROM numbers_mt(10) SETTINGS max_block_size = 1; +``` + +Como resultado de esta consulta, obtiene un entero aleatorio en el `[0,9]` gama. Por ejemplo: + +``` text +┌─groupArrayInsertAt(number, 0)─┐ +│ [7] │ +└───────────────────────────────┘ +``` + +## groupArrayMovingSum {#agg_function-grouparraymovingsum} + +Calcula la suma móvil de los valores de entrada. + +``` sql +groupArrayMovingSum(numbers_for_summing) +groupArrayMovingSum(window_size)(numbers_for_summing) +``` + +La función puede tomar el tamaño de la ventana como un parámetro. Si no se especifica, la función toma el tamaño de ventana igual al número de filas de la columna. + +**Parámetros** + +- `numbers_for_summing` — [Expresion](../syntax.md#syntax-expressions) dando como resultado un valor de tipo de datos numérico. +- `window_size` — Size of the calculation window. + +**Valores devueltos** + +- Matriz del mismo tamaño y tipo que los datos de entrada. + +**Ejemplo** + +La tabla de ejemplo: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Consulta: + +``` sql +SELECT + groupArrayMovingSum(int) AS I, + groupArrayMovingSum(float) AS F, + groupArrayMovingSum(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingSum(2)(int) AS I, + groupArrayMovingSum(2)(float) AS F, + groupArrayMovingSum(2)(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +## Método de codificación de datos: {#agg_function-grouparraymovingavg} + +Calcula la media móvil de los valores de entrada. + +``` sql +groupArrayMovingAvg(numbers_for_summing) +groupArrayMovingAvg(window_size)(numbers_for_summing) +``` + +La función puede tomar el tamaño de la ventana como un parámetro. Si no se especifica, la función toma el tamaño de ventana igual al número de filas de la columna. + +**Parámetros** + +- `numbers_for_summing` — [Expresion](../syntax.md#syntax-expressions) dando como resultado un valor de tipo de datos numérico. +- `window_size` — Size of the calculation window. + +**Valores devueltos** + +- Matriz del mismo tamaño y tipo que los datos de entrada. + +La función utiliza [redondeando hacia cero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). Trunca los decimales insignificantes para el tipo de datos resultante. + +**Ejemplo** + +La tabla de ejemplo `b`: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Consulta: + +``` sql +SELECT + groupArrayMovingAvg(int) AS I, + groupArrayMovingAvg(float) AS F, + groupArrayMovingAvg(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ +│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ +└───────────┴─────────────────────────────────────┴───────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingAvg(2)(int) AS I, + groupArrayMovingAvg(2)(float) AS F, + groupArrayMovingAvg(2)(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ +│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ +└───────────┴──────────────────────────────────┴───────────────────────┘ +``` + +## ¿Cómo puedo obtener más información?) {#groupuniqarrayx-groupuniqarraymax-sizex} + +Crea una matriz a partir de diferentes valores de argumento. El consumo de memoria es el mismo que para el `uniqExact` función. + +La segunda versión (con el `max_size` parámetro) limita el tamaño de la matriz resultante a `max_size` elemento. +Por ejemplo, `groupUniqArray(1)(x)` es equivalente a `[any(x)]`. + +## cuantil {#quantile} + +Calcula un aproximado [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos. + +Esta función se aplica [muestreo de embalses](https://en.wikipedia.org/wiki/Reservoir_sampling) con un tamaño de depósito de hasta 8192 y un generador de números aleatorios para el muestreo. El resultado es no determinista. Para obtener un cuantil exacto, use el [quantileExact](#quantileexact) función. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantile(level)(expr) +``` + +Apodo: `median`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [tipos de datos](../../sql-reference/data-types/index.md#data_types), [Fecha](../../sql-reference/data-types/date.md) o [FechaHora](../../sql-reference/data-types/datetime.md). + +**Valor devuelto** + +- Cuantil aproximado del nivel especificado. + +Tipo: + +- [Float64](../../sql-reference/data-types/float.md) para la entrada de tipo de datos numéricos. +- [Fecha](../../sql-reference/data-types/date.md) si los valores de entrada tienen `Date` tipo. +- [FechaHora](../../sql-reference/data-types/datetime.md) si los valores de entrada tienen `DateTime` tipo. + +**Ejemplo** + +Tabla de entrada: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Consulta: + +``` sql +SELECT quantile(val) FROM t +``` + +Resultado: + +``` text +┌─quantile(val)─┐ +│ 1.5 │ +└───────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileDeterminista {#quantiledeterministic} + +Calcula un aproximado [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos. + +Esta función se aplica [muestreo de embalses](https://en.wikipedia.org/wiki/Reservoir_sampling) con un tamaño de depósito de hasta 8192 y algoritmo determinista de muestreo. El resultado es determinista. Para obtener un cuantil exacto, use el [quantileExact](#quantileexact) función. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileDeterministic(level)(expr, determinator) +``` + +Apodo: `medianDeterministic`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [tipos de datos](../../sql-reference/data-types/index.md#data_types), [Fecha](../../sql-reference/data-types/date.md) o [FechaHora](../../sql-reference/data-types/datetime.md). +- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. + +**Valor devuelto** + +- Cuantil aproximado del nivel especificado. + +Tipo: + +- [Float64](../../sql-reference/data-types/float.md) para la entrada de tipo de datos numéricos. +- [Fecha](../../sql-reference/data-types/date.md) si los valores de entrada tienen `Date` tipo. +- [FechaHora](../../sql-reference/data-types/datetime.md) si los valores de entrada tienen `DateTime` tipo. + +**Ejemplo** + +Tabla de entrada: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Consulta: + +``` sql +SELECT quantileDeterministic(val, 1) FROM t +``` + +Resultado: + +``` text +┌─quantileDeterministic(val, 1)─┐ +│ 1.5 │ +└───────────────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileExact {#quantileexact} + +Calcula exactamente el [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` memoria, donde `n` es un número de valores que se pasaron. Sin embargo, para un pequeño número de valores, la función es muy efectiva. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileExact(level)(expr) +``` + +Apodo: `medianExact`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [tipos de datos](../../sql-reference/data-types/index.md#data_types), [Fecha](../../sql-reference/data-types/date.md) o [FechaHora](../../sql-reference/data-types/datetime.md). + +**Valor devuelto** + +- Cuantil del nivel especificado. + +Tipo: + +- [Float64](../../sql-reference/data-types/float.md) para la entrada de tipo de datos numéricos. +- [Fecha](../../sql-reference/data-types/date.md) si los valores de entrada tienen `Date` tipo. +- [FechaHora](../../sql-reference/data-types/datetime.md) si los valores de entrada tienen `DateTime` tipo. + +**Ejemplo** + +Consulta: + +``` sql +SELECT quantileExact(number) FROM numbers(10) +``` + +Resultado: + +``` text +┌─quantileExact(number)─┐ +│ 5 │ +└───────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileExactWeighted {#quantileexactweighted} + +Calcula exactamente el [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos, teniendo en cuenta el peso de cada elemento. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [quantileExact](#quantileexact). Puede usar esta función en lugar de `quantileExact` y especifique el peso 1. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileExactWeighted(level)(expr, weight) +``` + +Apodo: `medianExactWeighted`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [tipos de datos](../../sql-reference/data-types/index.md#data_types), [Fecha](../../sql-reference/data-types/date.md) o [FechaHora](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. + +**Valor devuelto** + +- Cuantil del nivel especificado. + +Tipo: + +- [Float64](../../sql-reference/data-types/float.md) para la entrada de tipo de datos numéricos. +- [Fecha](../../sql-reference/data-types/date.md) si los valores de entrada tienen `Date` tipo. +- [FechaHora](../../sql-reference/data-types/datetime.md) si los valores de entrada tienen `DateTime` tipo. + +**Ejemplo** + +Tabla de entrada: + +``` text +┌─n─┬─val─┐ +│ 0 │ 3 │ +│ 1 │ 2 │ +│ 2 │ 1 │ +│ 5 │ 4 │ +└───┴─────┘ +``` + +Consulta: + +``` sql +SELECT quantileExactWeighted(n, val) FROM t +``` + +Resultado: + +``` text +┌─quantileExactWeighted(n, val)─┐ +│ 1 │ +└───────────────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileTiming {#quantiletiming} + +Con la precisión determinada calcula el [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos. + +El resultado es determinista (no depende del orden de procesamiento de la consulta). La función está optimizada para trabajar con secuencias que describen distribuciones como tiempos de carga de páginas web o tiempos de respuesta de back-end. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileTiming(level)(expr) +``` + +Apodo: `medianTiming`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). + +- `expr` — [Expresion](../syntax.md#syntax-expressions) sobre una columna valores que devuelven un [Flotante\*](../../sql-reference/data-types/float.md)-tipo número. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +**Exactitud** + +El cálculo es preciso si: + +- El número total de valores no supera los 5670. +- El número total de valores supera los 5670, pero el tiempo de carga de la página es inferior a 1024 ms. + +De lo contrario, el resultado del cálculo se redondea al múltiplo más cercano de 16 ms. + +!!! note "Nota" + Para calcular los cuantiles de tiempo de carga de la página, esta función es más efectiva y precisa que [cuantil](#quantile). + +**Valor devuelto** + +- Cuantil del nivel especificado. + +Tipo: `Float32`. + +!!! note "Nota" + Si no se pasan valores a la función (cuando se `quantileTimingIf`), [NaN](../../sql-reference/data-types/float.md#data_type-float-nan-inf) se devuelve. El propósito de esto es diferenciar estos casos de los casos que resultan en cero. Ver [ORDER BY cláusula](../statements/select/order-by.md#select-order-by) para notas sobre la clasificación `NaN` valor. + +**Ejemplo** + +Tabla de entrada: + +``` text +┌─response_time─┐ +│ 72 │ +│ 112 │ +│ 126 │ +│ 145 │ +│ 104 │ +│ 242 │ +│ 313 │ +│ 168 │ +│ 108 │ +└───────────────┘ +``` + +Consulta: + +``` sql +SELECT quantileTiming(response_time) FROM t +``` + +Resultado: + +``` text +┌─quantileTiming(response_time)─┐ +│ 126 │ +└───────────────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileTimingWeighted {#quantiletimingweighted} + +Con la precisión determinada calcula el [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos según el peso de cada miembro de secuencia. + +El resultado es determinista (no depende del orden de procesamiento de la consulta). La función está optimizada para trabajar con secuencias que describen distribuciones como tiempos de carga de páginas web o tiempos de respuesta de back-end. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileTimingWeighted(level)(expr, weight) +``` + +Apodo: `medianTimingWeighted`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). + +- `expr` — [Expresion](../syntax.md#syntax-expressions) sobre una columna valores que devuelven un [Flotante\*](../../sql-reference/data-types/float.md)-tipo número. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Exactitud** + +El cálculo es preciso si: + +- El número total de valores no supera los 5670. +- El número total de valores supera los 5670, pero el tiempo de carga de la página es inferior a 1024 ms. + +De lo contrario, el resultado del cálculo se redondea al múltiplo más cercano de 16 ms. + +!!! note "Nota" + Para calcular los cuantiles de tiempo de carga de la página, esta función es más efectiva y precisa que [cuantil](#quantile). + +**Valor devuelto** + +- Cuantil del nivel especificado. + +Tipo: `Float32`. + +!!! note "Nota" + Si no se pasan valores a la función (cuando se `quantileTimingIf`), [NaN](../../sql-reference/data-types/float.md#data_type-float-nan-inf) se devuelve. El propósito de esto es diferenciar estos casos de los casos que resultan en cero. Ver [ORDER BY cláusula](../statements/select/order-by.md#select-order-by) para notas sobre la clasificación `NaN` valor. + +**Ejemplo** + +Tabla de entrada: + +``` text +┌─response_time─┬─weight─┐ +│ 68 │ 1 │ +│ 104 │ 2 │ +│ 112 │ 3 │ +│ 126 │ 2 │ +│ 138 │ 1 │ +│ 162 │ 1 │ +└───────────────┴────────┘ +``` + +Consulta: + +``` sql +SELECT quantileTimingWeighted(response_time, weight) FROM t +``` + +Resultado: + +``` text +┌─quantileTimingWeighted(response_time, weight)─┐ +│ 112 │ +└───────────────────────────────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileTDigest {#quantiletdigest} + +Calcula un aproximado [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos usando el [T-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algoritmo. + +El error máximo es 1%. El consumo de memoria es `log(n)`, donde `n` es un número de valores. El resultado depende del orden de ejecución de la consulta y no es determinista. + +El rendimiento de la función es menor que el rendimiento de [cuantil](#quantile) o [quantileTiming](#quantiletiming). En términos de la relación entre el tamaño del estado y la precisión, esta función es mucho mejor que `quantile`. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileTDigest(level)(expr) +``` + +Apodo: `medianTDigest`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [tipos de datos](../../sql-reference/data-types/index.md#data_types), [Fecha](../../sql-reference/data-types/date.md) o [FechaHora](../../sql-reference/data-types/datetime.md). + +**Valor devuelto** + +- Cuantil aproximado del nivel especificado. + +Tipo: + +- [Float64](../../sql-reference/data-types/float.md) para la entrada de tipo de datos numéricos. +- [Fecha](../../sql-reference/data-types/date.md) si los valores de entrada tienen `Date` tipo. +- [FechaHora](../../sql-reference/data-types/datetime.md) si los valores de entrada tienen `DateTime` tipo. + +**Ejemplo** + +Consulta: + +``` sql +SELECT quantileTDigest(number) FROM numbers(10) +``` + +Resultado: + +``` text +┌─quantileTDigest(number)─┐ +│ 4.5 │ +└─────────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## quantileTDigestWeighted {#quantiletdigestweighted} + +Calcula un aproximado [cuantil](https://en.wikipedia.org/wiki/Quantile) de una secuencia de datos numéricos usando el [T-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algoritmo. La función tiene en cuenta el peso de cada miembro de secuencia. El error máximo es 1%. El consumo de memoria es `log(n)`, donde `n` es un número de valores. + +El rendimiento de la función es menor que el rendimiento de [cuantil](#quantile) o [quantileTiming](#quantiletiming). En términos de la relación entre el tamaño del estado y la precisión, esta función es mucho mejor que `quantile`. + +El resultado depende del orden de ejecución de la consulta y no es determinista. + +Cuando se utilizan múltiples `quantile*` funciones con diferentes niveles en una consulta, los estados internos no se combinan (es decir, la consulta funciona de manera menos eficiente de lo que podría). En este caso, use el [cantiles](#quantiles) función. + +**Sintaxis** + +``` sql +quantileTDigest(level)(expr) +``` + +Apodo: `medianTDigest`. + +**Parámetros** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` valor en el rango de `[0.01, 0.99]`. Valor predeterminado: 0.5. En `level=0.5` la función calcula [mediana](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [tipos de datos](../../sql-reference/data-types/index.md#data_types), [Fecha](../../sql-reference/data-types/date.md) o [FechaHora](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Valor devuelto** + +- Cuantil aproximado del nivel especificado. + +Tipo: + +- [Float64](../../sql-reference/data-types/float.md) para la entrada de tipo de datos numéricos. +- [Fecha](../../sql-reference/data-types/date.md) si los valores de entrada tienen `Date` tipo. +- [FechaHora](../../sql-reference/data-types/datetime.md) si los valores de entrada tienen `DateTime` tipo. + +**Ejemplo** + +Consulta: + +``` sql +SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) +``` + +Resultado: + +``` text +┌─quantileTDigestWeighted(number, 1)─┐ +│ 4.5 │ +└────────────────────────────────────┘ +``` + +**Ver también** + +- [mediana](#median) +- [cantiles](#quantiles) + +## mediana {#median} + +El `median*` funciones son los alias para el `quantile*` función. Calculan la mediana de una muestra de datos numéricos. + +Función: + +- `median` — Alias for [cuantil](#quantile). +- `medianDeterministic` — Alias for [quantileDeterminista](#quantiledeterministic). +- `medianExact` — Alias for [quantileExact](#quantileexact). +- `medianExactWeighted` — Alias for [quantileExactWeighted](#quantileexactweighted). +- `medianTiming` — Alias for [quantileTiming](#quantiletiming). +- `medianTimingWeighted` — Alias for [quantileTimingWeighted](#quantiletimingweighted). +- `medianTDigest` — Alias for [quantileTDigest](#quantiletdigest). +- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](#quantiletdigestweighted). + +**Ejemplo** + +Tabla de entrada: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Consulta: + +``` sql +SELECT medianDeterministic(val, 1) FROM t +``` + +Resultado: + +``` text +┌─medianDeterministic(val, 1)─┐ +│ 1.5 │ +└─────────────────────────────┘ +``` + +## quantiles(level1, level2, …)(x) {#quantiles} + +Todas las funciones de cuantiles también tienen funciones de cuantiles correspondientes: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. Estas funciones calculan todos los cuantiles de los niveles enumerados en una sola pasada y devuelven una matriz de los valores resultantes. + +## Acerca de Nosotros) {#varsampx} + +Calcula la cantidad `Σ((x - x̅)^2) / (n - 1)`, donde `n` es el tamaño de la muestra y `x̅`es el valor promedio de `x`. + +Representa una estimación imparcial de la varianza de una variable aleatoria si los valores pasados forman su muestra. + +Devoluciones `Float64`. Cuando `n <= 1`, devoluciones `+∞`. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `varSampStable` función. Funciona más lento, pero proporciona un menor error computacional. + +## Nombre de la red inalámbrica (SSID):) {#varpopx} + +Calcula la cantidad `Σ((x - x̅)^2) / n`, donde `n` es el tamaño de la muestra y `x̅`es el valor promedio de `x`. + +En otras palabras, dispersión para un conjunto de valores. Devoluciones `Float64`. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `varPopStable` función. Funciona más lento, pero proporciona un menor error computacional. + +## Soporte técnico) {#stddevsampx} + +El resultado es igual a la raíz cuadrada de `varSamp(x)`. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `stddevSampStable` función. Funciona más lento, pero proporciona un menor error computacional. + +## stddevPop(x) {#stddevpopx} + +El resultado es igual a la raíz cuadrada de `varPop(x)`. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `stddevPopStable` función. Funciona más lento, pero proporciona un menor error computacional. + +## topK(N)(x) {#topknx} + +Devuelve una matriz de los valores aproximadamente más frecuentes de la columna especificada. La matriz resultante se ordena en orden descendente de frecuencia aproximada de valores (no por los valores mismos). + +Implementa el [Ahorro de espacio filtrado](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) algoritmo para analizar TopK, basado en el algoritmo de reducción y combinación de [Ahorro de espacio paralelo](https://arxiv.org/pdf/1401.0702.pdf). + +``` sql +topK(N)(column) +``` + +Esta función no proporciona un resultado garantizado. En ciertas situaciones, pueden producirse errores y pueden devolver valores frecuentes que no son los valores más frecuentes. + +Recomendamos usar el `N < 10` valor; el rendimiento se reduce con grandes `N` valor. Valor máximo de `N = 65536`. + +**Parámetros** + +- ‘N’ es el número de elementos a devolver. + +Si se omite el parámetro, se utiliza el valor predeterminado 10. + +**Argumento** + +- ' x ' – The value to calculate frequency. + +**Ejemplo** + +Tome el [A tiempo](../../getting-started/example-datasets/ontime.md) conjunto de datos y seleccione los tres valores más frecuentes `AirlineID` columna. + +``` sql +SELECT topK(3)(AirlineID) AS res +FROM ontime +``` + +``` text +┌─res─────────────────┐ +│ [19393,19790,19805] │ +└─────────────────────┘ +``` + +## topKPeso {#topkweighted} + +Similar a `topK` pero toma un argumento adicional de tipo entero - `weight`. Cada valor se contabiliza `weight` veces para el cálculo de la frecuencia. + +**Sintaxis** + +``` sql +topKWeighted(N)(x, weight) +``` + +**Parámetros** + +- `N` — The number of elements to return. + +**Argumento** + +- `x` – The value. +- `weight` — The weight. [UInt8](../../sql-reference/data-types/int-uint.md). + +**Valor devuelto** + +Devuelve una matriz de los valores con la suma aproximada máxima de pesos. + +**Ejemplo** + +Consulta: + +``` sql +SELECT topKWeighted(10)(number, number) FROM numbers(1000) +``` + +Resultado: + +``` text +┌─topKWeighted(10)(number, number)──────────┐ +│ [999,998,997,996,995,994,993,992,991,990] │ +└───────────────────────────────────────────┘ +``` + +## covarSamp(x, y) {#covarsampx-y} + +Calcula el valor de `Σ((x - x̅)(y - y̅)) / (n - 1)`. + +Devuelve Float64. Cuando `n <= 1`, returns +∞. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `covarSampStable` función. Funciona más lento, pero proporciona un menor error computacional. + +## covarPop(x, y) {#covarpopx-y} + +Calcula el valor de `Σ((x - x̅)(y - y̅)) / n`. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `covarPopStable` función. Funciona más lento pero proporciona un menor error computacional. + +## corr(x, y) {#corrx-y} + +Calcula el coeficiente de correlación de Pearson: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. + +!!! note "Nota" + Esta función utiliza un algoritmo numéricamente inestable. Si necesita [estabilidad numérica](https://en.wikipedia.org/wiki/Numerical_stability) en los cálculos, utilice el `corrStable` función. Funciona más lento, pero proporciona un menor error computacional. + +## categoricalInformationValue {#categoricalinformationvalue} + +Calcula el valor de `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` para cada categoría. + +``` sql +categoricalInformationValue(category1, category2, ..., tag) +``` + +El resultado indica cómo una característica discreta (categórica `[category1, category2, ...]` contribuir a un modelo de aprendizaje que predice el valor de `tag`. + +## SimpleLinearRegression {#simplelinearregression} + +Realiza una regresión lineal simple (unidimensional). + +``` sql +simpleLinearRegression(x, y) +``` + +Parámetros: + +- `x` — Column with dependent variable values. +- `y` — Column with explanatory variable values. + +Valores devueltos: + +Constante `(a, b)` de la línea resultante `y = a*x + b`. + +**Ejemplos** + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ +│ (1,0) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ +│ (1,3) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## stochasticLinearRegression {#agg_functions-stochasticlinearregression} + +Esta función implementa la regresión lineal estocástica. Admite parámetros personalizados para la tasa de aprendizaje, el coeficiente de regularización L2, el tamaño de mini lote y tiene pocos métodos para actualizar los pesos ([Adán](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (utilizado por defecto), [SGD simple](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [Impulso](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). + +### Parámetros {#agg_functions-stochasticlinearregression-parameters} + +Hay 4 parámetros personalizables. Se pasan a la función secuencialmente, pero no es necesario pasar los cuatro; se usarán valores predeterminados, sin embargo, un buen modelo requirió algún ajuste de parámetros. + +``` text +stochasticLinearRegression(1.0, 1.0, 10, 'SGD') +``` + +1. `learning rate` es el coeficiente en la longitud del paso, cuando se realiza el paso de descenso de gradiente. Una tasa de aprendizaje demasiado grande puede causar pesos infinitos del modelo. El valor predeterminado es `0.00001`. +2. `l2 regularization coefficient` que puede ayudar a prevenir el sobreajuste. El valor predeterminado es `0.1`. +3. `mini-batch size` establece el número de elementos, cuyos gradientes se calcularán y sumarán para realizar un paso de descenso de gradiente. El descenso estocástico puro usa un elemento, sin embargo, tener lotes pequeños (aproximadamente 10 elementos) hace que los pasos de gradiente sean más estables. El valor predeterminado es `15`. +4. `method for updating weights`, son: `Adam` (predeterminada), `SGD`, `Momentum`, `Nesterov`. `Momentum` y `Nesterov` requieren un poco más de cálculos y memoria, sin embargo, resultan útiles en términos de velocidad de convergencia y estabilidad de los métodos de gradiente estocásticos. + +### Uso {#agg_functions-stochasticlinearregression-usage} + +`stochasticLinearRegression` se utiliza en dos pasos: ajustar el modelo y predecir nuevos datos. Para ajustar el modelo y guardar su estado para su uso posterior, utilizamos `-State` combinador, que básicamente guarda el estado (pesos del modelo, etc.). +Para predecir usamos la función [evalMLMethod](../functions/machine-learning-functions.md#machine_learning_methods-evalmlmethod), que toma un estado como argumento, así como características para predecir. + + + +**1.** Accesorio + +Dicha consulta puede ser utilizada. + +``` sql +CREATE TABLE IF NOT EXISTS train_data +( + param1 Float64, + param2 Float64, + target Float64 +) ENGINE = Memory; + +CREATE TABLE your_model ENGINE = Memory AS SELECT +stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) +AS state FROM train_data; +``` + +Aquí también tenemos que insertar datos en `train_data` tabla. El número de parámetros no es fijo, depende solo del número de argumentos, pasados a `linearRegressionState`. Todos deben ser valores numéricos. +Tenga en cuenta que la columna con valor objetivo (que nos gustaría aprender a predecir) se inserta como primer argumento. + +**2.** Predecir + +Después de guardar un estado en la tabla, podemos usarlo varias veces para la predicción, o incluso fusionarlo con otros estados y crear nuevos modelos aún mejores. + +``` sql +WITH (SELECT state FROM your_model) AS model SELECT +evalMLMethod(model, param1, param2) FROM test_data +``` + +La consulta devolverá una columna de valores predichos. Tenga en cuenta que el primer argumento de `evalMLMethod` ser `AggregateFunctionState` objeto, siguiente son columnas de características. + +`test_data` es una mesa como `train_data` pero puede no contener el valor objetivo. + +### Nota {#agg_functions-stochasticlinearregression-notes} + +1. Para fusionar dos modelos, el usuario puede crear dicha consulta: + `sql SELECT state1 + state2 FROM your_models` + donde `your_models` la tabla contiene ambos modelos. Esta consulta devolverá un nuevo `AggregateFunctionState` objeto. + +2. El usuario puede obtener pesos del modelo creado para sus propios fines sin guardar el modelo si no `-State` combinador se utiliza. + `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` + Dicha consulta se ajustará al modelo y devolverá sus pesos: primero son los pesos, que corresponden a los parámetros del modelo, el último es el sesgo. Entonces, en el ejemplo anterior, la consulta devolverá una columna con 3 valores. + +**Ver también** + +- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) +- [Diferencia entre regresiones lineales y logísticas](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} + +Esta función implementa la regresión logística estocástica. Se puede usar para problemas de clasificación binaria, admite los mismos parámetros personalizados que stochasticLinearRegression y funciona de la misma manera. + +### Parámetros {#agg_functions-stochasticlogisticregression-parameters} + +Los parámetros son exactamente los mismos que en stochasticLinearRegression: +`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. +Para obtener más información, consulte [parámetros](#agg_functions-stochasticlinearregression-parameters). + +``` text +stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') +``` + +1. Accesorio + + + + See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. + + Predicted labels have to be in \[-1, 1\]. + +1. Predecir + + + + Using saved state we can predict probability of object having label `1`. + + ``` sql + WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) FROM test_data + ``` + + The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. + + We can also set a bound of probability, which assigns elements to different labels. + + ``` sql + SELECT ans < 1.1 AND ans > 0.5 FROM + (WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) AS ans FROM test_data) + ``` + + Then the result will be labels. + + `test_data` is a table like `train_data` but may not contain target value. + +**Ver también** + +- [stochasticLinearRegression](#agg_functions-stochasticlinearregression) +- [Diferencia entre regresiones lineales y logísticas.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## Método de codificación de datos: {#groupbitmapand} + +Calcula el AND de una columna de mapa de bits, devuelve la cardinalidad del tipo UInt64, si agrega el sufijo -State, luego devuelve [objeto de mapa de bits](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapAnd(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` tipo. + +**Valor de retorno** + +Valor de la `UInt64` tipo. + +**Ejemplo** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapAnd(z)─┐ +│ 3 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ +│ [6,8,10] │ +└──────────────────────────────────────────────────┘ +``` + +## Método de codificación de datos: {#groupbitmapor} + +Calcula el OR de una columna de mapa de bits, devuelve la cardinalidad del tipo UInt64, si agrega el sufijo -State, luego devuelve [objeto de mapa de bits](../../sql-reference/functions/bitmap-functions.md). Esto es equivalente a `groupBitmapMerge`. + +``` sql +groupBitmapOr(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` tipo. + +**Valor de retorno** + +Valor de la `UInt64` tipo. + +**Ejemplo** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapOr(z)─┐ +│ 15 │ +└──────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ +│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ +└─────────────────────────────────────────────────┘ +``` + +## Método de codificación de datos: {#groupbitmapxor} + +Calcula el XOR de una columna de mapa de bits, devuelve la cardinalidad del tipo UInt64, si agrega el sufijo -State, luego devuelve [objeto de mapa de bits](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapOr(expr) +``` + +**Parámetros** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` tipo. + +**Valor de retorno** + +Valor de la `UInt64` tipo. + +**Ejemplo** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapXor(z)─┐ +│ 10 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ +│ [1,3,5,6,8,10,11,13,14,15] │ +└──────────────────────────────────────────────────┘ +``` + +[Artículo Original](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/es/sql-reference/ansi.md b/docs/es/sql-reference/ansi.md new file mode 100644 index 00000000000..3bf06d4419b --- /dev/null +++ b/docs/es/sql-reference/ansi.md @@ -0,0 +1,180 @@ +--- +machine_translated: true +machine_translated_rev: ad252bbb4f7e2899c448eb42ecc39ff195c8faa1 +toc_priority: 40 +toc_title: Compatibilidad con ANSI +--- + +# Compatibilidad de SQL ANSI de ClickHouse SQL Dialect {#ansi-sql-compatibility-of-clickhouse-sql-dialect} + +!!! note "Nota" + Este artículo se basa en la Tabla 38, “Feature taxonomy and definition for mandatory features”, Annex F of ISO/IEC CD 9075-2:2013. + +## Diferencias en el comportamiento {#differences-in-behaviour} + +En la tabla siguiente se enumeran los casos en que la característica de consulta funciona en ClickHouse, pero no se comporta como se especifica en ANSI SQL. + +| Feature ID | Nombre de la función | Diferencia | +|------------|----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| +| E011 | Tipos de datos numéricos | El literal numérico con punto se interpreta como aproximado (`Float64`) en lugar de exacta (`Decimal`) | +| E051-05 | Los elementos seleccionados pueden ser renombrados | Los cambios de nombre de los elementos tienen un alcance de visibilidad más amplio que solo el resultado SELECT | +| E141-01 | Restricciones NOT NULL | `NOT NULL` está implícito para las columnas de tabla de forma predeterminada | +| E011-04 | Operadores aritméticos | ClickHouse se desborda en lugar de la aritmética comprobada y cambia el tipo de datos de resultado en función de las reglas personalizadas | + +## Estado de la función {#feature-status} + +| Feature ID | Nombre de la función | Estatus | Comentario | +|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **E011** | **Tipos de datos numéricos** | **Parcial**{.text-warning} | | +| E011-01 | Tipos de datos INTEGER y SMALLINT | Sí{.text-success} | | +| E011-02 | REAL, DOUBLE PRECISION y FLOAT tipos de datos tipos de datos | Parcial{.text-warning} | `FLOAT()`, `REAL` y `DOUBLE PRECISION` no son compatibles | +| E011-03 | Tipos de datos DECIMAL y NUMERIC | Parcial{.text-warning} | Solo `DECIMAL(p,s)` es compatible, no `NUMERIC` | +| E011-04 | Operadores aritméticos | Sí{.text-success} | | +| E011-05 | Comparación numérica | Sí{.text-success} | | +| E011-06 | Conversión implícita entre los tipos de datos numéricos | No{.text-danger} | ANSI SQL permite la conversión implícita arbitraria entre tipos numéricos, mientras que ClickHouse se basa en funciones que tienen múltiples sobrecargas en lugar de conversión implícita | +| **E021** | **Tipos de cadena de caracteres** | **Parcial**{.text-warning} | | +| E021-01 | Tipo de datos CHARACTER | No{.text-danger} | | +| E021-02 | Tipo de datos CHARACTER VARYING | No{.text-danger} | `String` se comporta de manera similar, pero sin límite de longitud entre paréntesis | +| E021-03 | Literales de caracteres | Parcial{.text-warning} | Sin concatenación automática de literales consecutivos y compatibilidad con el conjunto de caracteres | +| E021-04 | Función CHARACTER\_LENGTH | Parcial{.text-warning} | No `USING` clausula | +| E021-05 | Función OCTET\_LENGTH | No{.text-danger} | `LENGTH` se comporta de manera similar | +| E021-06 | SUBSTRING | Parcial{.text-warning} | No hay soporte para `SIMILAR` y `ESCAPE` cláusulas, no `SUBSTRING_REGEX` variante | +| E021-07 | Concatenación de caracteres | Parcial{.text-warning} | No `COLLATE` clausula | +| E021-08 | Funciones SUPERIOR e INFERIOR | Sí{.text-success} | | +| E021-09 | Función TRIM | Sí{.text-success} | | +| E021-10 | Conversión implícita entre los tipos de cadena de caracteres de longitud fija y longitud variable | No{.text-danger} | ANSI SQL permite la conversión implícita arbitraria entre tipos de cadena, mientras que ClickHouse se basa en funciones que tienen múltiples sobrecargas en lugar de conversión implícita | +| E021-11 | Función POSITION | Parcial{.text-warning} | No hay soporte para `IN` y `USING` cláusulas, no `POSITION_REGEX` variante | +| E021-12 | Comparación de caracteres | Sí{.text-success} | | +| **E031** | **Identificador** | **Parcial**{.text-warning} | | +| E031-01 | Identificadores delimitados | Parcial{.text-warning} | El soporte literal Unicode es limitado | +| E031-02 | Identificadores de minúsculas | Sí{.text-success} | | +| E031-03 | Trailing subrayado | Sí{.text-success} | | +| **E051** | **Especificación básica de la consulta** | **Parcial**{.text-warning} | | +| E051-01 | SELECT DISTINCT | Sí{.text-success} | | +| E051-02 | Cláusula GROUP BY | Sí{.text-success} | | +| E051-04 | GROUP BY puede contener columnas que no estén en `` | بله{.text-success} | | +| E051-05 | انتخاب موارد را می توان تغییر نام داد | بله{.text-success} | | +| E051-06 | داشتن بند | بله{.text-success} | | +| E051-07 | واجد شرایط \* در انتخاب لیست | بله{.text-success} | | +| E051-08 | نام همبستگی در بند | بله{.text-success} | | +| E051-09 | تغییر نام ستون ها در بند | نه{.text-danger} | | +| **E061** | **مخمصه عمومی و شرایط جستجو** | **نسبی**{.text-warning} | | +| E061-01 | پیش فرض مقایسه | بله{.text-success} | | +| E061-02 | بین پیش فرض | نسبی{.text-warning} | نه `SYMMETRIC` و `ASYMMETRIC` بند | +| E061-03 | در گزاره با لیستی از ارزش ها | بله{.text-success} | | +| E061-04 | مثل گزاره | بله{.text-success} | | +| E061-05 | مانند گزاره: فرار بند | نه{.text-danger} | | +| E061-06 | پیش فرض پوچ | بله{.text-success} | | +| E061-07 | گزاره مقایسه کمی | نه{.text-danger} | | +| E061-08 | پیش فرض وجود دارد | نه{.text-danger} | | +| E061-09 | Subqueries در مقایسه گزاره | بله{.text-success} | | +| E061-11 | در حال بارگذاری | بله{.text-success} | | +| E061-12 | زیرمجموعه ها در پیش بینی مقایسه اندازه گیری شده | نه{.text-danger} | | +| E061-13 | ارتباط subqueries | نه{.text-danger} | | +| E061-14 | وضعیت جستجو | بله{.text-success} | | +| **E071** | **عبارتهای پرسوجو پایه** | **نسبی**{.text-warning} | | +| E071-01 | اتحادیه اپراتور جدول مجزا | نه{.text-danger} | | +| E071-02 | اتحادیه تمام اپراتور جدول | بله{.text-success} | | +| E071-03 | به جز اپراتور جدول مجزا | نه{.text-danger} | | +| E071-05 | ستون ترکیب از طریق اپراتورهای جدول نیاز دقیقا همان نوع داده ندارد | بله{.text-success} | | +| E071-06 | اپراتورهای جدول در زیرمجموعه | بله{.text-success} | | +| **E081** | **امتیازات پایه** | **نسبی**{.text-warning} | کار در حال پیشرفت | +| **E091** | **تنظیم توابع** | **بله**{.text-success} | | +| E091-01 | AVG | بله{.text-success} | | +| E091-02 | COUNT | بله{.text-success} | | +| E091-03 | MAX | بله{.text-success} | | +| E091-04 | MIN | بله{.text-success} | | +| E091-05 | SUM | بله{.text-success} | | +| E091-06 | همه کمی | نه{.text-danger} | | +| E091-07 | کمی متمایز | نسبی{.text-warning} | همه توابع مجموع پشتیبانی | +| **E101** | **دستکاری داده های پایه** | **نسبی**{.text-warning} | | +| E101-01 | درج بیانیه | بله{.text-success} | توجه داشته باشید: کلید اصلی در خانه کلیک می کند به این معنی نیست `UNIQUE` محدودیت | +| E101-03 | بیانیه به روز رسانی جستجو | نه{.text-danger} | یک `ALTER UPDATE` بیانیه ای برای اصلاح داده های دسته ای | +| E101-04 | جستجو حذف بیانیه | نه{.text-danger} | یک `ALTER DELETE` بیانیه ای برای حذف داده های دسته ای | +| **E111** | **تک ردیف انتخاب بیانیه** | **نه**{.text-danger} | | +| **E121** | **پشتیبانی عمومی مکان نما** | **نه**{.text-danger} | | +| E121-01 | DECLARE CURSOR | نه{.text-danger} | | +| E121-02 | سفارش ستون ها در لیست انتخاب نمی شود | نه{.text-danger} | | +| E121-03 | عبارات ارزش به ترتیب توسط بند | نه{.text-danger} | | +| E121-04 | بیانیه باز | نه{.text-danger} | | +| E121-06 | بیانیه به روز رسانی موقعیت | نه{.text-danger} | | +| E121-07 | موقعیت حذف بیانیه | نه{.text-danger} | | +| E121-08 | بستن بیانیه | نه{.text-danger} | | +| E121-10 | واکشی بیانیه: ضمنی بعدی | نه{.text-danger} | | +| E121-17 | با نشانگر نگه دارید | نه{.text-danger} | | +| **E131** | **پشتیبانی ارزش صفر (صفر به جای ارزش)** | **نسبی**{.text-warning} | برخی از محدودیت ها اعمال می شود | +| **E141** | **محدودیت یکپارچگی عمومی** | **نسبی**{.text-warning} | | +| E141-01 | محدودیت NOT NULL | بله{.text-success} | یادداشت: `NOT NULL` برای ستون های جدول به طور پیش فرض ضمنی | +| E141-02 | محدودیت منحصر به فرد از ستون تهی نیست | نه{.text-danger} | | +| E141-03 | محدودیت های کلیدی اولیه | نه{.text-danger} | | +| E141-04 | محدودیت کلید خارجی عمومی با هیچ پیش فرض اقدام برای هر دو عمل حذف ارجاعی و عمل به روز رسانی ارجاعی | نه{.text-danger} | | +| E141-06 | بررسی محدودیت | بله{.text-success} | | +| E141-07 | پیشفرض ستون | بله{.text-success} | | +| E141-08 | تهی نیست استنباط در کلید اولیه | بله{.text-success} | | +| E141-10 | نام در یک کلید خارجی را می توان در هر سفارش مشخص شده است | نه{.text-danger} | | +| **E151** | **پشتیبانی تراکنش** | **نه**{.text-danger} | | +| E151-01 | بیانیه متعهد | نه{.text-danger} | | +| E151-02 | بیانیه عقبگرد | نه{.text-danger} | | +| **E152** | **بیانیه معامله عمومی مجموعه** | **نه**{.text-danger} | | +| E152-01 | مجموعه بیانیه معامله: جداسازی سطح SERIALIZABLE بند | نه{.text-danger} | | +| E152-02 | تنظیم بیانیه معامله: فقط خواندن و خواندن نوشتن جملات | نه{.text-danger} | | +| **E153** | **نمایش داده شد بهروز با زیرمجموعه** | **نه**{.text-danger} | | +| **E161** | **گذاشتن نظرات با استفاده از منجر منهای دو** | **بله**{.text-success} | | +| **E171** | **SQLSTATE پشتیبانی** | **نه**{.text-danger} | | +| **E182** | **اتصال زبان میزبان** | **نه**{.text-danger} | | +| **F031** | **دستکاری طرح اولیه** | **نسبی**{.text-warning} | | +| F031-01 | ایجاد بیانیه جدول برای ایجاد جداول پایه مداوم | نسبی{.text-warning} | نه `SYSTEM VERSIONING`, `ON COMMIT`, `GLOBAL`, `LOCAL`, `PRESERVE`, `DELETE`, `REF IS`, `WITH OPTIONS`, `UNDER`, `LIKE`, `PERIOD FOR` بند و هیچ پشتیبانی برای کاربر حل و فصل انواع داده ها | +| F031-02 | ایجاد نمایش بیانیه | نسبی{.text-warning} | نه `RECURSIVE`, `CHECK`, `UNDER`, `WITH OPTIONS` بند و هیچ پشتیبانی برای کاربر حل و فصل انواع داده ها | +| F031-03 | بیانیه گرانت | بله{.text-success} | | +| F031-04 | تغییر بیانیه جدول: اضافه کردن بند ستون | نسبی{.text-warning} | هیچ پشتیبانی برای `GENERATED` بند و مدت زمان سیستم | +| F031-13 | بیانیه جدول قطره: محدود کردن بند | نه{.text-danger} | | +| F031-16 | قطره مشاهده بیانیه: محدود بند | نه{.text-danger} | | +| F031-19 | لغو بیانیه: محدود کردن بند | نه{.text-danger} | | +| **F041** | **جدول پیوست عمومی** | **نسبی**{.text-warning} | | +| F041-01 | عضویت داخلی (اما نه لزوما کلمه کلیدی درونی) | بله{.text-success} | | +| F041-02 | کلیدواژه داخلی | بله{.text-success} | | +| F041-03 | LEFT OUTER JOIN | بله{.text-success} | | +| F041-04 | RIGHT OUTER JOIN | بله{.text-success} | | +| F041-05 | بیرونی می پیوندد می توان تو در تو | بله{.text-success} | | +| F041-07 | جدول درونی در بیرونی چپ یا راست عضویت نیز می تواند مورد استفاده قرار گیرد در عضویت درونی | بله{.text-success} | | +| F041-08 | همه اپراتورهای مقایسه پشتیبانی می شوند (و نه فقط =) | نه{.text-danger} | | +| **F051** | **تاریخ پایه و زمان** | **نسبی**{.text-warning} | | +| F051-01 | تاریخ نوع داده (از جمله پشتیبانی از تاریخ تحت اللفظی) | نسبی{.text-warning} | بدون تحت اللفظی | +| F051-02 | نوع داده زمان (از جمله پشتیبانی از زمان تحت اللفظی) با دقت ثانیه کسری حداقل 0 | نه{.text-danger} | | +| F051-03 | نوع داده برچسب زمان (از جمله پشتیبانی از تحت اللفظی برچسب زمان) با دقت ثانیه کسری از حداقل 0 و 6 | نه{.text-danger} | `DateTime64` زمان فراهم می کند قابلیت های مشابه | +| F051-04 | مقایسه گزاره در تاریخ, زمان, و انواع داده های برچسب زمان | نسبی{.text-warning} | فقط یک نوع داده موجود است | +| F051-05 | بازیگران صریح و روشن بین انواع تاریخ ساعت و انواع رشته شخصیت | بله{.text-success} | | +| F051-06 | CURRENT\_DATE | نه{.text-danger} | `today()` مشابه است | +| F051-07 | LOCALTIME | نه{.text-danger} | `now()` مشابه است | +| F051-08 | LOCALTIMESTAMP | نه{.text-danger} | | +| **F081** | **اتحادیه و به جز در دیدگاه** | **نسبی**{.text-warning} | | +| **F131** | **عملیات گروه بندی شده** | **نسبی**{.text-warning} | | +| F131-01 | جایی که, گروه های, و داشتن بند در نمایش داده شد با نمایش گروه بندی پشتیبانی | بله{.text-success} | | +| F131-02 | جداول چندگانه در نمایش داده شد با نمایش گروه بندی پشتیبانی می شود | بله{.text-success} | | +| F131-03 | تنظیم توابع پشتیبانی شده در نمایش داده شد با نمایش گروه بندی می شوند | بله{.text-success} | | +| F131-04 | Subqueries با گروه و داشتن بند و گروه بندی views | بله{.text-success} | | +| F131-05 | تک ردیف با گروه و داشتن بند و دیدگاه های گروه بندی شده را انتخاب کنید | نه{.text-danger} | | +| **F181** | **پشتیبانی از ماژول های متعدد** | **نه**{.text-danger} | | +| **F201** | **تابع بازیگران** | **بله**{.text-success} | | +| **F221** | **پیش فرض های صریح** | **نه**{.text-danger} | | +| **F261** | **عبارت مورد** | **بله**{.text-success} | | +| F261-01 | مورد ساده | بله{.text-success} | | +| F261-02 | مورد جستجو | بله{.text-success} | | +| F261-03 | NULLIF | بله{.text-success} | | +| F261-04 | COALESCE | بله{.text-success} | | +| **F311** | **بیانیه تعریف طرح** | **نسبی**{.text-warning} | | +| F311-01 | CREATE SCHEMA | نه{.text-danger} | | +| F311-02 | ایجاد جدول برای جداول پایه مداوم | بله{.text-success} | | +| F311-03 | CREATE VIEW | بله{.text-success} | | +| F311-04 | CREATE VIEW: WITH CHECK OPTION | نه{.text-danger} | | +| F311-05 | بیانیه گرانت | بله{.text-success} | | +| **F471** | **مقادیر زیر مقیاس** | **بله**{.text-success} | | +| **F481** | **پیش فرض صفر گسترش یافته است** | **بله**{.text-success} | | +| **F812** | **عمومی ضعیف** | **نه**{.text-danger} | | +| **T321** | **روال عمومی گذاشتن استناد** | **نه**{.text-danger} | | +| T321-01 | توابع تعریف شده توسط کاربر بدون اضافه بار | نه{.text-danger} | | +| T321-02 | روش های ذخیره شده تعریف شده توسط کاربر بدون اضافه بار | نه{.text-danger} | | +| T321-03 | فراخوانی تابع | نه{.text-danger} | | +| T321-04 | بیانیه تماس | نه{.text-danger} | | +| T321-05 | بیانیه بازگشت | نه{.text-danger} | | +| **T631** | **در گزاره با یک عنصر لیست** | **بله**{.text-success} | | diff --git a/docs/fa/sql-reference/data-types/aggregatefunction.md b/docs/fa/sql-reference/data-types/aggregatefunction.md new file mode 100644 index 00000000000..34a3634cd6e --- /dev/null +++ b/docs/fa/sql-reference/data-types/aggregatefunction.md @@ -0,0 +1,71 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: "\u06A9\u0627\u0631\u06A9\u0631\u062F(\u0646\u0627\u0645 \u0648 \u0646\u0627\ + \u0645 \u062E\u0627\u0646\u0648\u0627\u062F\u06AF\u06CC..)" +--- + +# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} + +Aggregate functions can have an implementation-defined intermediate state that can be serialized to an AggregateFunction(…) data type and stored in a table, usually, by means of [مشاهده محقق](../../sql-reference/statements/create.md#create-view). راه معمول برای تولید یک دولت تابع جمع است با فراخوانی تابع جمع با `-State` پسوند. برای دریافت نتیجه نهایی از تجمع در اینده, شما باید همان تابع کل با استفاده از `-Merge`پسوند. + +`AggregateFunction` — parametric data type. + +**پارامترها** + +- نام تابع جمع. + + If the function is parametric, specify its parameters too. + +- انواع استدلال تابع جمع. + +**مثال** + +``` sql +CREATE TABLE t +( + column1 AggregateFunction(uniq, UInt64), + column2 AggregateFunction(anyIf, String, UInt8), + column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) +) ENGINE = ... +``` + +[دانشگاه](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq). ([هر](../../sql-reference/aggregate-functions/reference.md#agg_function-any)+[اگر](../../sql-reference/aggregate-functions/combinators.md#agg-functions-combinator-if)) و [quantiles](../../sql-reference/aggregate-functions/reference.md) توابع مجموع پشتیبانی در خانه کلیک می باشد. + +## استفاده {#usage} + +### درج داده {#data-insertion} + +برای وارد کردن داده ها استفاده کنید `INSERT SELECT` با مجموع `-State`- توابع . + +**نمونه تابع** + +``` sql +uniqState(UserID) +quantilesState(0.5, 0.9)(SendTiming) +``` + +در مقایسه با توابع مربوطه `uniq` و `quantiles`, `-State`- توابع بازگشت به دولت, به جای ارزش نهایی. به عبارت دیگر ارزش بازگشت `AggregateFunction` نوع. + +در نتایج `SELECT` پرس و جو, ارزش `AggregateFunction` نوع اجرای خاص نمایندگی دودویی برای همه فرمت های خروجی کلیک کنید. اگر کمپرسی داده ها به, مثلا, `TabSeparated` قالب با `SELECT` پرس و جو, سپس این روگرفت را می توان با استفاده از لود `INSERT` پرس و جو. + +### گزینش داده {#data-selection} + +هنگام انتخاب داده ها از `AggregatingMergeTree` جدول استفاده کنید `GROUP BY` بند و توابع کل همان هنگام قرار دادن داده, اما با استفاده از `-Merge`پسوند. + +یک تابع جمع با `-Merge` پسوند مجموعه ای از ایالت ها را ترکیب می کند و نتیجه تجمع کامل داده ها را باز می گرداند. + +مثلا, دو نمایش داده شد زیر بازگشت به همان نتیجه: + +``` sql +SELECT uniq(UserID) FROM table + +SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) +``` + +## مثال طریقه استفاده {#usage-example} + +ببینید [ریزدانه](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) موتور باشرکت. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/fa/sql-reference/data-types/array.md b/docs/fa/sql-reference/data-types/array.md new file mode 100644 index 00000000000..218b0587e0a --- /dev/null +++ b/docs/fa/sql-reference/data-types/array.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 51 +toc_title: "& \u062A\u0648\u0631\u06CC)" +--- + +# & توری) {#data-type-array} + +مجموعه ای از `T`- نوع اقلام است. `T` می تواند هر نوع داده, از جمله مجموعه. + +## ایجاد یک مجموعه {#creating-an-array} + +شما می توانید یک تابع برای ایجاد مجموعه ای استفاده کنید: + +``` sql +array(T) +``` + +شما همچنین می توانید براکت مربع استفاده کنید. + +``` sql +[] +``` + +نمونه ای از ایجاد یک مجموعه: + +``` sql +SELECT array(1, 2) AS x, toTypeName(x) +``` + +``` text +┌─x─────┬─toTypeName(array(1, 2))─┐ +│ [1,2] │ Array(UInt8) │ +└───────┴─────────────────────────┘ +``` + +``` sql +SELECT [1, 2] AS x, toTypeName(x) +``` + +``` text +┌─x─────┬─toTypeName([1, 2])─┐ +│ [1,2] │ Array(UInt8) │ +└───────┴────────────────────┘ +``` + +## کار با انواع داده ها {#working-with-data-types} + +در هنگام ایجاد مجموعه ای در پرواز, خانه رعیتی به طور خودکار نوع استدلال به عنوان باریک ترین نوع داده است که می تواند تمام استدلال ذکر شده ذخیره تعریف. اگر وجود دارد [Nullable](nullable.md#data_type-nullable) یا تحت اللفظی [NULL](../../sql-reference/syntax.md#null-literal) ارزش, نوع عنصر مجموعه ای نیز می شود [Nullable](nullable.md). + +اگر فاحشه خانه می تواند نوع داده را تعیین نمی کند, این تولید یک استثنا. مثلا, این اتفاق می افتد زمانی که تلاش برای ایجاد مجموعه ای با رشته ها و اعداد به طور همزمان (`SELECT array(1, 'a')`). + +نمونه هایی از تشخیص نوع داده ها به صورت خودکار: + +``` sql +SELECT array(1, 2, NULL) AS x, toTypeName(x) +``` + +``` text +┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ +│ [1,2,NULL] │ Array(Nullable(UInt8)) │ +└────────────┴───────────────────────────────┘ +``` + +اگر شما سعی می کنید برای ایجاد مجموعه ای از انواع داده های ناسازگار, تاتر می اندازد یک استثنا: + +``` sql +SELECT array(1, 'a') +``` + +``` text +Received exception from server (version 1.1.54388): +Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/array/) diff --git a/docs/fa/sql-reference/data-types/boolean.md b/docs/fa/sql-reference/data-types/boolean.md new file mode 100644 index 00000000000..d5136604738 --- /dev/null +++ b/docs/fa/sql-reference/data-types/boolean.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u0628\u0648\u0644\u06CC" +--- + +# مقادیر بولی {#boolean-values} + +هیچ نوع جداگانه برای مقادیر بولی وجود دارد. استفاده از نوع اوینت8, محدود به ارزش 0 یا 1. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/boolean/) diff --git a/docs/fa/sql-reference/data-types/date.md b/docs/fa/sql-reference/data-types/date.md new file mode 100644 index 00000000000..401bc1a2e21 --- /dev/null +++ b/docs/fa/sql-reference/data-types/date.md @@ -0,0 +1,15 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: "\u062A\u0627\u0631\u06CC\u062E" +--- + +# تاریخ {#date} + +قرار ذخیره شده در دو بایت به عنوان تعداد روز از 1970-01-01 (بدون علامت). اجازه می دهد تا ذخیره سازی مقادیر از درست بعد از شروع عصر یونیکس به حد بالایی تعریف شده توسط ثابت در مرحله تدوین (در حال حاضر, این است تا سال 2106, اما نهایی سال به طور کامل پشتیبانی شده است 2105). +حداقل مقدار خروجی به عنوان 0000-00-00. + +ارزش تاریخ بدون منطقه زمانی ذخیره می شود. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/date/) diff --git a/docs/fa/sql-reference/data-types/datetime.md b/docs/fa/sql-reference/data-types/datetime.md new file mode 100644 index 00000000000..9de82d07420 --- /dev/null +++ b/docs/fa/sql-reference/data-types/datetime.md @@ -0,0 +1,129 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: DateTime +--- + +# تاریخ ساعت {#data_type-datetime} + +اجازه می دهد تا برای ذخیره یک لحظه در زمان, است که می تواند به عنوان یک تاریخ تقویم و یک زمان از یک روز بیان. + +نحو: + +``` sql +DateTime([timezone]) +``` + +محدوده پشتیبانی شده از ارزش ها: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. + +حل: 1 ثانیه. + +## اظهارات طریقه استفاده {#usage-remarks} + +نقطه در زمان به عنوان یک ذخیره می شود [برچسب زمان یونیکس](https://en.wikipedia.org/wiki/Unix_time), صرف نظر از منطقه زمانی و یا صرفه جویی در زمان نور روز. علاوه بر این `DateTime` نوع می توانید منطقه زمانی است که همین کار را برای کل ستون ذخیره, که تحت تاثیر قرار چگونه ارزش های `DateTime` مقادیر نوع در قالب متن نمایش داده می شود و چگونه مقادیر مشخص شده به عنوان رشته تجزیه می شوند (‘2020-01-01 05:00:01’). منطقه زمانی در ردیف جدول ذخیره نمی شود (و یا در نتیجه), اما در ابرداده ستون ذخیره می شود. +لیستی از مناطق زمانی پشتیبانی شده را می توان در [اانا پایگاه منطقه زمانی](https://www.iana.org/time-zones). +این `tzdata` بسته حاوی [اانا پایگاه منطقه زمانی](https://www.iana.org/time-zones), باید در سیستم نصب. استفاده از `timedatectl list-timezones` فرمان به لیست جغرافیایی شناخته شده توسط یک سیستم محلی. + +شما به صراحت می توانید یک منطقه زمانی برای `DateTime`- ستون نوع در هنگام ایجاد یک جدول. اگر منطقه زمانی تنظیم نشده است, خانه رعیتی با استفاده از ارزش [منطقهی زمانی](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) پارامتر در تنظیمات سرور و یا تنظیمات سیستم عامل در حال حاضر از شروع سرور کلیک. + +این [کلیک مشتری](../../interfaces/cli.md) اعمال منطقه زمانی سرور به طور پیش فرض اگر یک منطقه زمانی است که به صراحت تنظیم نشده است که مقدار دهی اولیه نوع داده ها. برای استفاده از منطقه زمان مشتری اجرا کنید `clickhouse-client` با `--use_client_time_zone` پارامتر. + +خروجی کلیک ارزش در `YYYY-MM-DD hh:mm:ss` قالب متن به طور پیش فرض. شما می توانید خروجی را با تغییر [formatDateTime](../../sql-reference/functions/date-time-functions.md#formatdatetime) تابع. + +هنگام قرار دادن داده ها به تاتر, شما می توانید فرمت های مختلف تاریخ و زمان رشته استفاده, بسته به ارزش [تغییر \_شماره](../../operations/settings/settings.md#settings-date_time_input_format) تنظیمات. + +## مثالها {#examples} + +**1.** ایجاد یک جدول با یک `DateTime`- ستون را تایپ کنید و داده ها را وارد کنید: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime('Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog; +``` + +``` sql +INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); +``` + +``` sql +SELECT * FROM dt; +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00 │ 1 │ +│ 2019-01-01 00:00:00 │ 2 │ +└─────────────────────┴──────────┘ +``` + +- هنگام قرار دادن تاریخ ساعت به عنوان یک عدد صحیح, این است که به عنوان برچسب زمان یونیکس درمان (مجموعه مقالات). `1546300800` نشان دهنده `'2019-01-01 00:00:00'` ادا کردن. با این حال, مانند `timestamp` ستون دارد `Europe/Moscow` (مجموعه مقالات+3) منطقه زمانی مشخص, در هنگام خروجی به عنوان رشته ارزش خواهد شد به عنوان نشان داده شده است `'2019-01-01 03:00:00'` +- هنگام قرار دادن مقدار رشته به عنوان تاریخ ساعت, این است که به عنوان بودن در منطقه زمانی ستون درمان. `'2019-01-01 00:00:00'` خواهد شد به عنوان در درمان `Europe/Moscow` منطقه زمانی و ذخیره به عنوان `1546290000`. + +**2.** پالایش بر روی `DateTime` مقادیر + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00 │ 2 │ +└─────────────────────┴──────────┘ +``` + +`DateTime` مقادیر ستون را می توان با استفاده از یک مقدار رشته در فیلتر `WHERE` مسندکردن. این تبدیل خواهد شد به `DateTime` به طور خودکار: + +``` sql +SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00 │ 1 │ +└─────────────────────┴──────────┘ +``` + +**3.** گرفتن یک منطقه زمانی برای یک `DateTime`- نوع ستون: + +``` sql +SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────column─┬─x─────────────────────────┐ +│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ +└─────────────────────┴───────────────────────────┘ +``` + +**4.** تبدیل منطقه زمانی + +``` sql +SELECT +toDateTime(timestamp, 'Europe/London') as lon_time, +toDateTime(timestamp, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────lon_time──┬────────────mos_time─┐ +│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ +│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ +└─────────────────────┴─────────────────────┘ +``` + +## همچنین نگاه کنید به {#see-also} + +- [توابع تبدیل نوع](../../sql-reference/functions/type-conversion-functions.md) +- [توابع برای کار با تاریخ و زمان](../../sql-reference/functions/date-time-functions.md) +- [توابع برای کار با ارریس](../../sql-reference/functions/array-functions.md) +- [این `date_time_input_format` تنظیم](../../operations/settings/settings.md#settings-date_time_input_format) +- [این `timezone` پارامتر پیکربندی سرور](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) +- [اپراتورها برای کار با تاریخ و زمان](../../sql-reference/operators/index.md#operators-datetime) +- [این `Date` نوع داده](date.md) + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/datetime/) diff --git a/docs/fa/sql-reference/data-types/datetime64.md b/docs/fa/sql-reference/data-types/datetime64.md new file mode 100644 index 00000000000..f168ef9444b --- /dev/null +++ b/docs/fa/sql-reference/data-types/datetime64.md @@ -0,0 +1,104 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 49 +toc_title: "\u0637\u0648\u0644 \u062A\u0627\u0631\u06CC\u062E 64" +--- + +# طول تاریخ 64 {#data_type-datetime64} + +اجازه می دهد تا برای ذخیره یک لحظه در زمان, است که می تواند به عنوان یک تاریخ تقویم و یک زمان از یک روز بیان, با دقت زیر دوم تعریف شده + +اندازه تیک (دقت): 10- دقت ثانیه + +نحو: + +``` sql +DateTime64(precision, [timezone]) +``` + +داخلی, ذخیره داده ها به عنوان تعدادی از ‘ticks’ از عصر شروع (1970-01-01 00:00:00 یو تی سی) به عنوان اینترنشنال64. وضوح تیک توسط پارامتر دقیق تعیین می شود. علاوه بر این `DateTime64` نوع می توانید منطقه زمانی است که همین کار را برای کل ستون ذخیره, که تحت تاثیر قرار چگونه ارزش های `DateTime64` مقادیر نوع در قالب متن نمایش داده می شود و چگونه مقادیر مشخص شده به عنوان رشته تجزیه می شوند (‘2020-01-01 05:00:01.000’). منطقه زمانی در ردیف جدول ذخیره نمی شود (و یا در نتیجه), اما در ابرداده ستون ذخیره می شود. مشاهده اطلاعات در [DateTime](datetime.md). + +## مثالها {#examples} + +**1.** ایجاد یک جدول با `DateTime64`- ستون را تایپ کنید و داده ها را وارد کنید: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime64(3, 'Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog +``` + +``` sql +INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) +``` + +``` sql +SELECT * FROM dt +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00.000 │ 1 │ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +- هنگام قرار دادن تاریخ ساعت به عنوان یک عدد صحیح, این است که به عنوان یک مناسب کوچک برچسب زمان یونیکس درمان (مجموعه مقالات). `1546300800000` (با دقت 3) نشان دهنده `'2019-01-01 00:00:00'` ادا کردن. با این حال, مانند `timestamp` ستون دارد `Europe/Moscow` (مجموعه مقالات+3) منطقه زمانی مشخص, در هنگام خروجی به عنوان یک رشته ارزش خواهد شد به عنوان نشان داده شده است `'2019-01-01 03:00:00'` +- هنگام قرار دادن مقدار رشته به عنوان تاریخ ساعت, این است که به عنوان بودن در منطقه زمانی ستون درمان. `'2019-01-01 00:00:00'` خواهد شد به عنوان در درمان `Europe/Moscow` منطقه زمانی و ذخیره شده به عنوان `1546290000000`. + +**2.** پالایش بر روی `DateTime64` مقادیر + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +برخلاف `DateTime`, `DateTime64` ارزش ها از تبدیل نمی `String` به طور خودکار + +**3.** گرفتن یک منطقه زمانی برای یک `DateTime64`- مقدار نوع: + +``` sql +SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────────column─┬─x──────────────────────────────┐ +│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ +└─────────────────────────┴────────────────────────────────┘ +``` + +**4.** تبدیل منطقه زمانی + +``` sql +SELECT +toDateTime64(timestamp, 3, 'Europe/London') as lon_time, +toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────────lon_time──┬────────────────mos_time─┐ +│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ +│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ +└─────────────────────────┴─────────────────────────┘ +``` + +## همچنین نگاه کنید به {#see-also} + +- [توابع تبدیل نوع](../../sql-reference/functions/type-conversion-functions.md) +- [توابع برای کار با تاریخ و زمان](../../sql-reference/functions/date-time-functions.md) +- [توابع برای کار با ارریس](../../sql-reference/functions/array-functions.md) +- [این `date_time_input_format` تنظیم](../../operations/settings/settings.md#settings-date_time_input_format) +- [این `timezone` پارامتر پیکربندی سرور](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) +- [اپراتورها برای کار با تاریخ و زمان](../../sql-reference/operators/index.md#operators-datetime) +- [`Date` نوع داده](date.md) +- [`DateTime` نوع داده](datetime.md) diff --git a/docs/fa/sql-reference/data-types/decimal.md b/docs/fa/sql-reference/data-types/decimal.md new file mode 100644 index 00000000000..722734ec6af --- /dev/null +++ b/docs/fa/sql-reference/data-types/decimal.md @@ -0,0 +1,109 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u062F\u0647\u062F\u0647\u06CC" +--- + +# Decimal(P, S) Decimal32(ع) Decimal64(ع) Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} + +امضا اعداد ثابت نقطه که دقت در طول اضافه کردن نگه دارید, تفریق و ضرب عملیات. برای تقسیم رقم حداقل قابل توجهی دور انداخته می شوند (گرد نیست). + +## پارامترها {#parameters} + +- ص دقیق. محدوده معتبر: \[ 1 : 38 \]. تعیین می کند که چگونه بسیاری از اعداد اعشاری می تواند داشته باشد (از جمله کسر). +- ص-مقیاس. محدوده معتبر: \[0: پ \]. تعیین می کند که چگونه بسیاری از رقم اعشاری کسر می تواند داشته باشد. + +بسته به فسفر اعشاری مقدار پارامتر (پ, بازدید کنندگان) مترادف برای است: +- پ از \[ 1 : 9 \] - برای اعشار (بازدید کنندگان) +- پ از \[ 10 : 18 \] - برای اعشار64(بازدید کنندگان) +- پ از \[ 19: 38 \] - برای اعشار128 (بازدید کنندگان) + +## محدوده مقدار دهدهی {#decimal-value-ranges} + +- دسیمال32 (بازدید کنندگان) - ( -1 \* 10^(9 - بازدید کنندگان), 1 \* 10^(9 بازدید کنندگان) ) +- اعشار64 (بازدید کنندگان) - ( -1 \* 10^(18 - س), 1 \* 10^(18 بازدید کنندگان) ) +- اعشار128 (بازدید کنندگان) - ( -1 \* 10^(38 - بازدید کنندگان), 1 \* 10^(38 بازدید کنندگان) ) + +برای مثال Decimal32(4) می تواند شامل اعداد از -99999.9999 به 99999.9999 با 0.0001 گام. + +## نمایندگی داخلی {#internal-representation} + +داخلی داده ها به عنوان اعداد صحیح امضا نرمال با عرض بیت مربوطه نشان داده است. محدوده ارزش واقعی است که می تواند در حافظه ذخیره می شود کمی بزرگتر از بالا مشخص, که تنها در تبدیل از یک رشته بررسی. + +چرا که پردازنده مدرن اعداد صحیح 128 بیتی بومی را پشتیبانی نمی کند, عملیات بر روی اعشار128 شبیه سازی. از آنجا که این Decimal128 با این نسخهها کار به طور قابل توجهی کندتر از Decimal32/Decimal64. + +## عملیات و نوع نتیجه {#operations-and-result-type} + +عملیات دودویی در نتیجه اعشاری در نوع نتیجه گسترده تر (با هر سفارش از استدلال). + +- `Decimal64(S1) Decimal32(S2) -> Decimal64(S)` +- `Decimal128(S1) Decimal32(S2) -> Decimal128(S)` +- `Decimal128(S1) Decimal64(S2) -> Decimal128(S)` + +قوانین برای مقیاس: + +- اضافه کردن به, تفریق کردن: بازدید کنندگان = حداکثر(بازدید کنندگان 1, بازدید کنندگان2). +- multuply: S = S1 + S2. +- شکاف: بازدید کنندگان = س1. + +برای عملیات مشابه بین دهدهی و اعداد صحیح, نتیجه اعشاری از همان اندازه به عنوان یک استدلال است. + +عملیات بین دهدهی و Float32/Float64 تعریف نشده. اگر شما به آنها نیاز دارید, شما می توانید به صراحت بازیگران یکی از استدلال با استفاده از toDecimal32, toDecimal64, toDecimal128 یا toFloat32, toFloat64 برنامهنویسی. به خاطر داشته باشید که نتیجه دقت از دست دادن و تبدیل نوع یک عملیات محاسباتی گران است. + +برخی از توابع در نتیجه بازگشت اعشاری به عنوان شناور64 (مثلا, ور یا استودف). محاسبات متوسط هنوز هم ممکن است در دهدهی انجام شود, که ممکن است به نتایج مختلف بین نت64 و ورودی اعشاری با ارزش های مشابه منجر شود. + +## بررسی سرریز {#overflow-checks} + +در طول محاسبات در اعشاری, عدد صحیح سرریز ممکن است رخ دهد. رقم بیش از حد در کسری دور انداخته می شوند (گرد نیست). رقم بیش از حد در بخش عدد صحیح به یک استثنا منجر شود. + +``` sql +SELECT toDecimal32(2, 4) AS x, x / 3 +``` + +``` text +┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ +│ 2.0000 │ 0.6666 │ +└────────┴──────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32(4.2, 8) AS x, x * x +``` + +``` text +DB::Exception: Scale is out of bounds. +``` + +``` sql +SELECT toDecimal32(4.2, 8) AS x, 6 * x +``` + +``` text +DB::Exception: Decimal math overflow. +``` + +سرریز چک منجر به کاهش سرعت عملیات. اگر مشخص است که سرریزهای امکان پذیر نیست, حس می کند برای غیر فعال کردن چک با استفاده از `decimal_check_overflow` تنظیمات. هنگامی که چک غیر فعال هستند و سرریز اتفاق می افتد, نتیجه نادرست خواهد بود: + +``` sql +SET decimal_check_overflow = 0; +SELECT toDecimal32(4.2, 8) AS x, 6 * x +``` + +``` text +┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ +│ 4.20000000 │ -17.74967296 │ +└────────────┴──────────────────────────────────┘ +``` + +چک سرریز اتفاق می افتد نه تنها در عملیات ریاضی بلکه در مقایسه ارزش: + +``` sql +SELECT toDecimal32(1, 8) < 100 +``` + +``` text +DB::Exception: Can't compare. +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/decimal/) diff --git a/docs/fa/sql-reference/data-types/domains/index.md b/docs/fa/sql-reference/data-types/domains/index.md new file mode 100644 index 00000000000..089e1c43eed --- /dev/null +++ b/docs/fa/sql-reference/data-types/domains/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u062F\u0627\u0645\u0646\u0647" +toc_priority: 56 +--- + + diff --git a/docs/fa/sql-reference/data-types/domains/ipv4.md b/docs/fa/sql-reference/data-types/domains/ipv4.md new file mode 100644 index 00000000000..645e839f6d8 --- /dev/null +++ b/docs/fa/sql-reference/data-types/domains/ipv4.md @@ -0,0 +1,84 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: IPv4 +--- + +## IPv4 {#ipv4} + +`IPv4` یک دامنه بر اساس `UInt32` نوع و به عنوان یک جایگزین تایپ شده برای ذخیره سازی مقادیر ایپو4 عمل می کند. این فراهم می کند ذخیره سازی جمع و جور با فرمت ورودی خروجی انسان پسند و نوع ستون اطلاعات در بازرسی. + +### استفاده عمومی {#basic-usage} + +``` sql +CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY url; + +DESCRIBE TABLE hits; +``` + +``` text +┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ +│ url │ String │ │ │ │ │ +│ from │ IPv4 │ │ │ │ │ +└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ +``` + +یا شما می توانید از دامنه ایپو4 به عنوان یک کلید استفاده کنید: + +``` sql +CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; +``` + +`IPv4` دامنه پشتیبانی از فرمت ورودی سفارشی به عنوان ایپو4 رشته: + +``` sql +INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.tech', '183.247.232.58')('https://clickhouse.yandex/docs/en/', '116.106.34.242'); + +SELECT * FROM hits; +``` + +``` text +┌─url────────────────────────────────┬───────────from─┐ +│ https://clickhouse.tech/docs/en/ │ 116.106.34.242 │ +│ https://wikipedia.org │ 116.253.40.133 │ +│ https://clickhouse.tech │ 183.247.232.58 │ +└────────────────────────────────────┴────────────────┘ +``` + +مقادیر به صورت باینری جمع و جور ذخیره می شود: + +``` sql +SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(from)─┬─hex(from)─┐ +│ IPv4 │ B7F7E83A │ +└──────────────────┴───────────┘ +``` + +ارزش دامنه به طور ضمنی قابل تبدیل به انواع دیگر از `UInt32`. +اگر شما می خواهید برای تبدیل `IPv4` ارزش به یک رشته, شما باید برای انجام این کار به صراحت با `IPv4NumToString()` تابع: + +``` sql +SELECT toTypeName(s), IPv4NumToString(from) as s FROM hits LIMIT 1; +``` + + ┌─toTypeName(IPv4NumToString(from))─┬─s──────────────┐ + │ String │ 183.247.232.58 │ + └───────────────────────────────────┴────────────────┘ + +یا بازیگران به یک `UInt32` مقدار: + +``` sql +SELECT toTypeName(i), CAST(from as UInt32) as i FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(CAST(from, 'UInt32'))─┬──────────i─┐ +│ UInt32 │ 3086477370 │ +└──────────────────────────────────┴────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/domains/ipv4) diff --git a/docs/fa/sql-reference/data-types/domains/ipv6.md b/docs/fa/sql-reference/data-types/domains/ipv6.md new file mode 100644 index 00000000000..6677916c49b --- /dev/null +++ b/docs/fa/sql-reference/data-types/domains/ipv6.md @@ -0,0 +1,86 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 60 +toc_title: IPv6 +--- + +## IPv6 {#ipv6} + +`IPv6` یک دامنه بر اساس `FixedString(16)` نوع و به عنوان یک جایگزین تایپ شده برای ذخیره سازی ارزش های ایپو6 عمل می کند. این فراهم می کند ذخیره سازی جمع و جور با فرمت ورودی خروجی انسان پسند و نوع ستون اطلاعات در بازرسی. + +### استفاده عمومی {#basic-usage} + +``` sql +CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url; + +DESCRIBE TABLE hits; +``` + +``` text +┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ +│ url │ String │ │ │ │ │ +│ from │ IPv6 │ │ │ │ │ +└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ +``` + +یا شما می توانید استفاده کنید `IPv6` دامنه به عنوان یک کلید: + +``` sql +CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from; +``` + +`IPv6` دامنه پشتیبانی از ورودی های سفارشی به عنوان ایپو6 رشته: + +``` sql +INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.tech', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.yandex/docs/en/', '2a02:e980:1e::1'); + +SELECT * FROM hits; +``` + +``` text +┌─url────────────────────────────────┬─from──────────────────────────┐ +│ https://clickhouse.tech │ 2001:44c8:129:2632:33:0:252:2 │ +│ https://clickhouse.tech/docs/en/ │ 2a02:e980:1e::1 │ +│ https://wikipedia.org │ 2a02:aa08:e000:3100::2 │ +└────────────────────────────────────┴───────────────────────────────┘ +``` + +مقادیر به صورت باینری جمع و جور ذخیره می شود: + +``` sql +SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(from)─┬─hex(from)────────────────────────┐ +│ IPv6 │ 200144C8012926320033000002520002 │ +└──────────────────┴──────────────────────────────────┘ +``` + +ارزش دامنه به طور ضمنی قابل تبدیل به انواع دیگر از `FixedString(16)`. +اگر شما می خواهید برای تبدیل `IPv6` ارزش به یک رشته, شما باید برای انجام این کار به صراحت با `IPv6NumToString()` تابع: + +``` sql +SELECT toTypeName(s), IPv6NumToString(from) as s FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(IPv6NumToString(from))─┬─s─────────────────────────────┐ +│ String │ 2001:44c8:129:2632:33:0:252:2 │ +└───────────────────────────────────┴───────────────────────────────┘ +``` + +یا بازیگران به یک `FixedString(16)` مقدار: + +``` sql +SELECT toTypeName(i), CAST(from as FixedString(16)) as i FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(CAST(from, 'FixedString(16)'))─┬─i───────┐ +│ FixedString(16) │ ��� │ +└───────────────────────────────────────────┴─────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/domains/ipv6) diff --git a/docs/fa/sql-reference/data-types/domains/overview.md b/docs/fa/sql-reference/data-types/domains/overview.md new file mode 100644 index 00000000000..4507ca850ef --- /dev/null +++ b/docs/fa/sql-reference/data-types/domains/overview.md @@ -0,0 +1,32 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "\u0628\u0631\u0631\u0633\u06CC \u0627\u062C\u0645\u0627\u0644\u06CC" +--- + +# دامنه {#domains} + +دامنه انواع خاصی است که اضافه کردن برخی از ویژگی های اضافی در بالای نوع پایه موجود, اما ترک بر روی سیم و بر روی دیسک فرمت از نوع داده اساسی دست نخورده. درحال حاضر, تاتر می کند دامنه تعریف شده توسط کاربر را پشتیبانی نمی کند. + +شما می توانید دامنه در هر نقطه نوع پایه مربوطه استفاده می شود, مثلا: + +- ایجاد یک ستون از یک نوع دامنه +- خواندن / نوشتن مقادیر از / به ستون دامنه +- اگر یک نوع پایه می تواند به عنوان یک شاخص استفاده می شود به عنوان شاخص استفاده می شود +- توابع تماس با مقادیر ستون دامنه + +### ویژگی های اضافی از دامنه {#extra-features-of-domains} + +- صریح نام نوع ستون در `SHOW CREATE TABLE` یا `DESCRIBE TABLE` +- ورودی از فرمت انسان دوستانه با `INSERT INTO domain_table(domain_column) VALUES(...)` +- خروجی به فرمت انسان دوستانه برای `SELECT domain_column FROM domain_table` +- بارگیری داده ها از یک منبع خارجی در قالب انسان دوستانه: `INSERT INTO domain_table FORMAT CSV ...` + +### محدودیت ها {#limitations} + +- می توانید ستون شاخص از نوع پایه به نوع دامنه از طریق تبدیل کنید `ALTER TABLE`. +- نمی تواند به طور ضمنی تبدیل مقادیر رشته به ارزش دامنه در هنگام قرار دادن داده ها از ستون یا جدول دیگر. +- دامنه می افزاید: هیچ محدودیتی در مقادیر ذخیره شده. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/domains/overview) diff --git a/docs/fa/sql-reference/data-types/enum.md b/docs/fa/sql-reference/data-types/enum.md new file mode 100644 index 00000000000..3ededf871b4 --- /dev/null +++ b/docs/fa/sql-reference/data-types/enum.md @@ -0,0 +1,132 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: "\u0634\u0645\u0627\u0631\u0634\u06CC" +--- + +# شمارشی {#enum} + +نوع شمارش متشکل از ارزش به نام. + +مقادیر نام شده باید به عنوان اعلام شود `'string' = integer` جفت انبار فروشگاه تنها اعداد, اما پشتیبانی از عملیات با ارزش از طریق نام خود را. + +پشتیبانی از کلیک: + +- 8 بیتی `Enum`. این می تواند تا 256 مقدار شمارش شده در `[-128, 127]` محدوده. +- 16 بیتی `Enum`. این می تواند تا 65536 مقدار شمارش شده در `[-32768, 32767]` محدوده. + +تاتر به طور خودکار انتخاب نوع `Enum` هنگامی که داده درج شده است. شما همچنین می توانید استفاده کنید `Enum8` یا `Enum16` انواع برای اطمینان در اندازه ذخیره سازی. + +## نمونه های استفاده {#usage-examples} + +در اینجا ما یک جدول با یک ایجاد می کنیم `Enum8('hello' = 1, 'world' = 2)` نوع ستون: + +``` sql +CREATE TABLE t_enum +( + x Enum('hello' = 1, 'world' = 2) +) +ENGINE = TinyLog +``` + +ستون `x` فقط می توانید مقادیر که در تعریف نوع ذکر شده را ذخیره کنید: `'hello'` یا `'world'`. اگر شما سعی می کنید برای صرفه جویی در هر مقدار دیگر, کلیک یک استثنا بالا می برد. اندازه 8 بیتی برای این `Enum` به طور خودکار انتخاب شده است. + +``` sql +INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') +``` + +``` text +Ok. +``` + +``` sql +INSERT INTO t_enum values('a') +``` + +``` text +Exception on client: +Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) +``` + +هنگامی که شما پرس و جو داده ها را از جدول, تاتر خروجی مقادیر رشته از `Enum`. + +``` sql +SELECT * FROM t_enum +``` + +``` text +┌─x─────┐ +│ hello │ +│ world │ +│ hello │ +└───────┘ +``` + +اگر شما نیاز به دیدن معادل عددی از ردیف, شما باید بازیگران `Enum` ارزش به نوع صحیح. + +``` sql +SELECT CAST(x, 'Int8') FROM t_enum +``` + +``` text +┌─CAST(x, 'Int8')─┐ +│ 1 │ +│ 2 │ +│ 1 │ +└─────────────────┘ +``` + +برای ایجاد یک مقدار شمارشی در پرس و جو, شما همچنین نیاز به استفاده از `CAST`. + +``` sql +SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) +``` + +``` text +┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ +│ Enum8('a' = 1, 'b' = 2) │ +└─────────────────────────────────────────────────────┘ +``` + +## قوانین عمومی و استفاده {#general-rules-and-usage} + +هر یک از مقادیر یک عدد در محدوده اختصاص داده شده است `-128 ... 127` برای `Enum8` یا در محدوده `-32768 ... 32767` برای `Enum16`. همه رشته ها و اعداد باید متفاوت باشد. یک رشته خالی مجاز است. اگر این نوع مشخص شده است (در یک تعریف جدول), اعداد را می توان در جهت دلخواه. با این حال, سفارش مهم نیست. + +نه رشته و نه مقدار عددی در یک `Enum` می تواند باشد [NULL](../../sql-reference/syntax.md). + +یک `Enum` می توان در [Nullable](nullable.md) نوع. بنابراین اگر شما یک جدول با استفاده از پرس و جو ایجاد کنید + +``` sql +CREATE TABLE t_enum_nullable +( + x Nullable( Enum8('hello' = 1, 'world' = 2) ) +) +ENGINE = TinyLog +``` + +این می تواند نه تنها ذخیره `'hello'` و `'world'` اما `NULL` همینطور + +``` sql +INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) +``` + +در رم `Enum` ستون به همان شیوه ذخیره می شود `Int8` یا `Int16` از مقادیر عددی مربوطه. + +هنگام خواندن در فرم متن, تاتر تجزیه ارزش به عنوان یک رشته و جستجو برای رشته مربوطه را از مجموعه ای از ارزش شمارشی. اگر یافت نشد, یک استثنا پرتاب می شود. هنگام خواندن در قالب متن, رشته به عنوان خوانده شده و مقدار عددی مربوطه نگاه کردن. یک استثنا پرتاب خواهد شد اگر یافت نشد. +هنگام نوشتن در فرم متن, این ارزش به عنوان رشته مربوطه می نویسد. اگر داده های ستون شامل زباله (اعداد است که از مجموعه معتبر نیست), یک استثنا پرتاب می شود. زمانی که خواندن و نوشتن در فایل باینری فرم آن را با این نسخهها کار به همان روش برای Int8 و Int16 انواع داده ها. +مقدار پیش فرض ضمنی ارزش با کمترین تعداد است. + +در طول `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` و به همین ترتیب, مادران رفتار به همان شیوه به عنوان اعداد مربوطه. مثلا, سفارش شده توسط انواع عددی. اپراتورهای برابری و مقایسه کار به همان شیوه در مادران به عنوان در مقادیر عددی اساسی انجام. + +مقادیر شمارشی را نمی توان با اعداد مقایسه شده است. شمارشی را می توان به یک رشته ثابت در مقایسه. اگر رشته در مقایسه با یک مقدار معتبر برای شمارشی نیست, یک استثنا پرتاب خواهد شد. اپراتور در با شمارشی در سمت چپ و مجموعه ای از رشته ها در سمت راست پشتیبانی می شود. رشته ارزش مربوط شمارشی هستند. + +Most numeric and string operations are not defined for Enum values, e.g. adding a number to an Enum or concatenating a string to an Enum. +با این حال, شمارشی طبیعی است `toString` تابع است که ارزش رشته خود را برمی گرداند. + +مقادیر شمارشی نیز قابل تبدیل به انواع عددی با استفاده از `toT` تابع, که تی یک نوع عددی است. هنگامی که تی مربوط به نوع عددی اساسی شمارشی است, این تبدیل صفر هزینه است. +نوع شمارشی را می توان بدون هزینه با استفاده از تغییر تغییر, اگر تنها مجموعه ای از ارزش تغییر است. ممکن است که به هر دو اضافه کردن و حذف اعضای شمارشی با استفاده از تغییر (از بین بردن امن است تنها در صورتی که مقدار حذف شده است هرگز در جدول استفاده می شود). به عنوان یک حفاظت, تغییر مقدار عددی از یک عضو شمارشی که قبلا تعریف یک استثنا پرتاب. + +با استفاده از تغییر آن را ممکن است برای تغییر یک Enum8 به Enum16 یا بالعکس فقط مانند تغییر یک Int8 به Int16. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/enum/) diff --git a/docs/fa/sql-reference/data-types/fixedstring.md b/docs/fa/sql-reference/data-types/fixedstring.md new file mode 100644 index 00000000000..9824acb0d2f --- /dev/null +++ b/docs/fa/sql-reference/data-types/fixedstring.md @@ -0,0 +1,63 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u0631\u0634\u062A\u0647 \u062B\u0627\u0628\u062A)" +--- + +# رشته ثابت {#fixedstring} + +یک رشته ثابت طول `N` بایت (نه شخصیت و نه نقاط کد). + +برای اعلام یک ستون از `FixedString` نوع, استفاده از نحو زیر: + +``` sql + FixedString(N) +``` + +کجا `N` یک عدد طبیعی است. + +این `FixedString` نوع زمانی موثر است که داده ها طول دقیق داشته باشند `N` بایت در تمام موارد دیگر, این احتمال وجود دارد به کاهش بهره وری. + +نمونه هایی از مقادیر است که می تواند موثر در ذخیره می شود `FixedString`- ستون های تایپ شده: + +- نمایندگی دودویی نشانی های اینترنتی (`FixedString(16)` برای ایپو6). +- Language codes (ru\_RU, en\_US … ). +- Currency codes (USD, RUB … ). +- نمایش دودویی رشته هش (`FixedString(16)` برای ام دی 5, `FixedString(32)` برای شی256). + +برای ذخیره مقادیر یوید از [UUID](uuid.md) نوع داده. + +هنگام قرار دادن داده ها, تاتر: + +- مکمل یک رشته با بایت پوچ اگر رشته شامل کمتر از `N` بایت +- پرتاب `Too large value for FixedString(N)` استثنا اگر رشته شامل بیش از `N` بایت + +در هنگام انتخاب داده, تاتر می کند بایت پوچ در پایان رشته را حذف کنید. اگر شما استفاده از `WHERE` بند, شما باید بایت پوچ دستی اضافه برای مطابقت با `FixedString` ارزش. مثال زیر نشان میدهد که چگونه به استفاده از `WHERE` بند با `FixedString`. + +بیایید جدول زیر را با تک در نظر بگیریم `FixedString(2)` ستون: + +``` text +┌─name──┐ +│ b │ +└───────┘ +``` + +پرسوجو `SELECT * FROM FixedStringTable WHERE a = 'b'` هیچ داده به عنوان یک نتیجه نمی گرداند. ما باید الگوی فیلتر با بایت پوچ تکمیل. + +``` sql +SELECT * FROM FixedStringTable +WHERE a = 'b\0' +``` + +``` text +┌─a─┐ +│ b │ +└───┘ +``` + +این رفتار از خروجی زیر برای متفاوت `CHAR` نوع (جایی که رشته ها با فضاهای خالی, و فضاهای برای خروجی حذف). + +توجه داشته باشید که طول `FixedString(N)` ارزش ثابت است. این [طول](../../sql-reference/functions/array-functions.md#array_functions-length) بازده عملکرد `N` حتی اگر `FixedString(N)` ارزش تنها با بایت پوچ پر, اما [خالی](../../sql-reference/functions/string-functions.md#empty) بازده عملکرد `1` در این مورد. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/fa/sql-reference/data-types/float.md b/docs/fa/sql-reference/data-types/float.md new file mode 100644 index 00000000000..25ce81c3645 --- /dev/null +++ b/docs/fa/sql-reference/data-types/float.md @@ -0,0 +1,87 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: Float32, Float64 +--- + +# Float32, Float64 {#float32-float64} + +[اعداد ممیز شناور](https://en.wikipedia.org/wiki/IEEE_754). + +انواع معادل انواع ج هستند: + +- `Float32` - `float` +- `Float64` - `double` + +ما توصیه می کنیم که شما ذخیره داده ها در فرم صحیح در هر زمان ممکن است. مثلا, تبدیل اعداد دقت ثابت به ارزش عدد صحیح, مانند مقدار پولی و یا بار بار صفحه در میلی ثانیه. + +## با استفاده از اعداد ممیز شناور {#using-floating-point-numbers} + +- محاسبات با اعداد ممیز شناور ممکن است یک خطای گرد کردن تولید. + + + +``` sql +SELECT 1 - 0.9 +``` + +``` text +┌───────minus(1, 0.9)─┐ +│ 0.09999999999999998 │ +└─────────────────────┘ +``` + +- نتیجه محاسبه بستگی به روش محاسبه (نوع پردازنده و معماری سیستم کامپیوتری). +- محاسبات ممیز شناور ممکن است در اعداد مانند بی نهایت منجر شود (`Inf`) و “not-a-number” (`NaN`). این را باید در نظر گرفته شود در هنگام پردازش نتایج محاسبات. +- هنگامی که تجزیه اعداد ممیز شناور از متن, نتیجه ممکن است نزدیکترین شماره ماشین نمایندگی. + +## هشدار داده می شود {#data_type-float-nan-inf} + +در مقابل به گذاشتن استاندارد, خانه رعیتی پشتیبانی از مقوله های زیر است از اعداد ممیز شناور: + +- `Inf` – Infinity. + + + +``` sql +SELECT 0.5 / 0 +``` + +``` text +┌─divide(0.5, 0)─┐ +│ inf │ +└────────────────┘ +``` + +- `-Inf` – Negative infinity. + + + +``` sql +SELECT -0.5 / 0 +``` + +``` text +┌─divide(-0.5, 0)─┐ +│ -inf │ +└─────────────────┘ +``` + +- `NaN` – Not a number. + + + +``` sql +SELECT 0 / 0 +``` + +``` text +┌─divide(0, 0)─┐ +│ nan │ +└──────────────┘ +``` + + See the rules for `NaN` sorting in the section [ORDER BY clause](../sql_reference/statements/select/order-by.md). + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/float/) diff --git a/docs/fa/sql-reference/data-types/index.md b/docs/fa/sql-reference/data-types/index.md new file mode 100644 index 00000000000..8ec0ba03469 --- /dev/null +++ b/docs/fa/sql-reference/data-types/index.md @@ -0,0 +1,15 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0627\u0646\u0648\u0627\u0639 \u062F\u0627\u062F\u0647 \u0647\u0627" +toc_priority: 37 +toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" +--- + +# انواع داده ها {#data_types} + +تاتر می توانید انواع مختلف داده ها در سلول های جدول ذخیره کنید. + +این بخش انواع داده های پشتیبانی شده و ملاحظات ویژه ای را برای استفاده و/یا در صورت وجود اجرا می کند. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/) diff --git a/docs/fa/sql-reference/data-types/int-uint.md b/docs/fa/sql-reference/data-types/int-uint.md new file mode 100644 index 00000000000..749c1b52a1b --- /dev/null +++ b/docs/fa/sql-reference/data-types/int-uint.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 +--- + +# UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} + +اعداد صحیح ثابت طول, با یا بدون نشانه. + +## محدوده اعضای هیات {#int-ranges} + +- بین8- \[-128 : 127\] +- اینتر16- \[-32768 : 32767\] +- اینتر32 - \[-2147483648: 2147483647\] +- اینتر64- \[-9223372036854775808 : 9223372036854775807\] + +## محدوده دانشگاه تهران {#uint-ranges} + +- توینت8- \[0: 255\] +- اوینت16- \[0: 65535\] +- اوینت32- \[0: 4294967295\] +- اوت64 - \[0: 18446744073709551615\] + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/int_uint/) diff --git a/docs/fa/sql-reference/data-types/nested-data-structures/index.md b/docs/fa/sql-reference/data-types/nested-data-structures/index.md new file mode 100644 index 00000000000..b6cbdb6dc16 --- /dev/null +++ b/docs/fa/sql-reference/data-types/nested-data-structures/index.md @@ -0,0 +1,13 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0633\u0627\u062E\u062A\u0627\u0631\u0647\u0627\u06CC \u062F\u0627\ + \u062F\u0647 \u062A\u0648 \u062F\u0631 \u062A\u0648" +toc_hidden: true +toc_priority: 54 +toc_title: "\u0645\u062E\u0641\u06CC" +--- + +# ساختارهای داده تو در تو {#nested-data-structures} + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nested_data_structures/) diff --git a/docs/fa/sql-reference/data-types/nested-data-structures/nested.md b/docs/fa/sql-reference/data-types/nested-data-structures/nested.md new file mode 100644 index 00000000000..4857274f47e --- /dev/null +++ b/docs/fa/sql-reference/data-types/nested-data-structures/nested.md @@ -0,0 +1,106 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "\u062A\u0648 \u062F\u0631 \u062A\u0648(Name1 Type1, Name2 Type2, ...)" +--- + +# Nested(name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} + +A nested data structure is like a table inside a cell. The parameters of a nested data structure – the column names and types – are specified the same way as in a [CREATE TABLE](../../../sql-reference/statements/create.md) پرس و جو. هر سطر جدول می تواند به هر تعداد از ردیف در یک ساختار داده تو در تو مطابقت. + +مثال: + +``` sql +CREATE TABLE test.visits +( + CounterID UInt32, + StartDate Date, + Sign Int8, + IsNew UInt8, + VisitID UInt64, + UserID UInt64, + ... + Goals Nested + ( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32 + ), + ... +) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) +``` + +این مثال اعلام کرد `Goals` ساختار داده های تو در تو, که شامل داده ها در مورد تبدیل (اهداف رسیده). هر سطر در ‘visits’ جدول می تواند به صفر یا هر تعداد از تبدیل مطابقت دارد. + +فقط یک سطح تودرتو تک پشتیبانی می شود. ستون های سازه های تو در تو حاوی ارریس معادل چندین بعدی هستند بنابراین پشتیبانی محدودی دارند (هیچ پشتیبانی ای برای ذخیره این ستون ها در جداول با موتور ادغام وجود ندارد). + +در بیشتر موارد, در هنگام کار با یک ساختار داده های تو در تو, ستون خود را با نام ستون جدا شده توسط یک نقطه مشخص. این ستون ها مجموعه ای از انواع تطبیق را تشکیل می دهند. تمام ستون ها از یک ساختار داده های تو در تو یکسان هستند. + +مثال: + +``` sql +SELECT + Goals.ID, + Goals.EventTime +FROM test.visits +WHERE CounterID = 101500 AND length(Goals.ID) < 5 +LIMIT 10 +``` + +``` text +┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ +│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ +│ [1073752] │ ['2014-03-17 00:28:25'] │ +│ [1073752] │ ['2014-03-17 10:46:20'] │ +│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ +│ [] │ [] │ +│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ +│ [] │ [] │ +│ [] │ [] │ +│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ +│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ +└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +ساده ترین راه این است که از یک ساختار داده های تو در تو فکر می کنم به عنوان مجموعه ای از مجموعه ای از مجموعه های ستون های متعدد از همان طول. + +تنها جایی که پرس و جو را انتخاب کنید می توانید نام کل ساختار داده های تو در تو به جای ستون های فردی مشخص مجموعه ملحق بند. برای کسب اطلاعات بیشتر, دیدن “ARRAY JOIN clause”. مثال: + +``` sql +SELECT + Goal.ID, + Goal.EventTime +FROM test.visits +ARRAY JOIN Goals AS Goal +WHERE CounterID = 101500 AND length(Goals.ID) < 5 +LIMIT 10 +``` + +``` text +┌─Goal.ID─┬──────Goal.EventTime─┐ +│ 1073752 │ 2014-03-17 16:38:10 │ +│ 591325 │ 2014-03-17 16:38:48 │ +│ 591325 │ 2014-03-17 16:42:27 │ +│ 1073752 │ 2014-03-17 00:28:25 │ +│ 1073752 │ 2014-03-17 10:46:20 │ +│ 1073752 │ 2014-03-17 13:59:20 │ +│ 591325 │ 2014-03-17 22:17:55 │ +│ 591325 │ 2014-03-17 22:18:07 │ +│ 591325 │ 2014-03-17 22:18:51 │ +│ 1073752 │ 2014-03-17 11:37:06 │ +└─────────┴─────────────────────┘ +``` + +شما نمی توانید انتخاب کنید برای کل ساختار داده های تو در تو انجام دهد. شما فقط می توانید به صراحت ستون های فردی را که بخشی از این هستند لیست کنید. + +برای پرس و جو درج, شما باید تمام عناصر ستون مولفه از یک ساختار داده های تو در تو به طور جداگانه منتقل (در صورتی که مجموعه فردی بودند). در حین درج سیستم چک می کند که همان طول را دارند. + +برای پرس و جو توصیف, ستون در یک ساختار داده های تو در تو به طور جداگانه در همان راه ذکر شده. + +پرس و جو را تغییر دهید برای عناصر در یک ساختار داده های تو در تو دارای محدودیت. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nested_data_structures/nested/) diff --git a/docs/fa/sql-reference/data-types/nullable.md b/docs/fa/sql-reference/data-types/nullable.md new file mode 100644 index 00000000000..96643e8ac6c --- /dev/null +++ b/docs/fa/sql-reference/data-types/nullable.md @@ -0,0 +1,46 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: Nullable +--- + +# Nullable(typename) {#data_type-nullable} + +اجازه می دهد تا برای ذخیره نشانگر ویژه ([NULL](../../sql-reference/syntax.md)) که نشان دهنده “missing value” در کنار مقادیر عادی مجاز `TypeName`. برای مثال یک `Nullable(Int8)` ستون نوع می تواند ذخیره شود `Int8` ارزش نوع و ردیف است که ارزش ذخیره خواهد شد `NULL`. + +برای یک `TypeName` شما نمی توانید از انواع داده های کامپوزیت استفاده کنید [& حذف](array.md) و [تاپل](tuple.md). انواع داده های کامپوزیت می تواند شامل `Nullable` مقادیر نوع مانند `Array(Nullable(Int8))`. + +A `Nullable` فیلد نوع را نمی توان در شاخص های جدول گنجانده شده است. + +`NULL` مقدار پیش فرض برای هر `Nullable` نوع, مگر اینکه در غیر این صورت در پیکربندی سرور کلیک مشخص. + +## ویژگی های ذخیره سازی {#storage-features} + +برای ذخیره `Nullable` ارزش نوع در یک ستون جدول, تاتر با استفاده از یک فایل جداگانه با `NULL` ماسک علاوه بر فایل عادی با ارزش. مطالب در ماسک فایل اجازه می دهد خانه کلیک برای تشخیص بین `NULL` و یک مقدار پیش فرض از نوع داده مربوطه را برای هر سطر جدول. به دلیل یک فایل اضافی, `Nullable` ستون مصرف فضای ذخیره سازی اضافی در مقایسه با یک نرمال مشابه. + +!!! info "یادداشت" + با استفاده از `Nullable` تقریبا همیشه منفی تاثیر می گذارد عملکرد, نگه داشتن این در ذهن در هنگام طراحی پایگاه داده های خود را. + +## مثال طریقه استفاده {#usage-example} + +``` sql +CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog +``` + +``` sql +INSERT INTO t_null VALUES (1, NULL), (2, 3) +``` + +``` sql +SELECT x + y FROM t_null +``` + +``` text +┌─plus(x, y)─┐ +│ ᴺᵁᴸᴸ │ +│ 5 │ +└────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/fa/sql-reference/data-types/simpleaggregatefunction.md b/docs/fa/sql-reference/data-types/simpleaggregatefunction.md new file mode 100644 index 00000000000..ddb1cd56be0 --- /dev/null +++ b/docs/fa/sql-reference/data-types/simpleaggregatefunction.md @@ -0,0 +1,38 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# عملکرد پلاکتی {#data-type-simpleaggregatefunction} + +`SimpleAggregateFunction(name, types_of_arguments…)` نوع داده ها ارزش فعلی عملکرد کل را ذخیره می کند و حالت کامل خود را ذخیره نمی کند [`AggregateFunction`](aggregatefunction.md) چرا این بهینه سازی را می توان به توابع که اموال زیر را نگه می دارد اعمال می شود: در نتیجه استفاده از یک تابع `f` به مجموعه ردیف `S1 UNION ALL S2` می توان با استفاده از `f` به بخش هایی از مجموعه ردیف به طور جداگانه, و سپس دوباره استفاده `f` به نتایج: `f(S1 UNION ALL S2) = f(f(S1) UNION ALL f(S2))`. این ویژگی تضمین می کند که نتایج تجمع بخشی به اندازه کافی برای محاسبه یک ترکیب هستند, بنابراین ما لازم نیست برای ذخیره و پردازش هر گونه اطلاعات اضافی. + +توابع زیر مجموع پشتیبانی می شوند: + +- [`any`](../../sql-reference/aggregate-functions/reference.md#agg_function-any) +- [`anyLast`](../../sql-reference/aggregate-functions/reference.md#anylastx) +- [`min`](../../sql-reference/aggregate-functions/reference.md#agg_function-min) +- [`max`](../../sql-reference/aggregate-functions/reference.md#agg_function-max) +- [`sum`](../../sql-reference/aggregate-functions/reference.md#agg_function-sum) +- [`groupBitAnd`](../../sql-reference/aggregate-functions/reference.md#groupbitand) +- [`groupBitOr`](../../sql-reference/aggregate-functions/reference.md#groupbitor) +- [`groupBitXor`](../../sql-reference/aggregate-functions/reference.md#groupbitxor) + +مقادیر `SimpleAggregateFunction(func, Type)` نگاه و ذخیره شده به همان شیوه به عنوان `Type` بنابراین شما نیازی به اعمال توابع با `-Merge`/`-State` پسوندها. `SimpleAggregateFunction` عملکرد بهتر از `AggregateFunction` با همان تابع تجمع. + +**پارامترها** + +- نام تابع جمع. +- انواع استدلال تابع جمع. + +**مثال** + +``` sql +CREATE TABLE t +( + column1 SimpleAggregateFunction(sum, UInt64), + column2 SimpleAggregateFunction(any, String) +) ENGINE = ... +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/simpleaggregatefunction/) diff --git a/docs/fa/sql-reference/data-types/special-data-types/expression.md b/docs/fa/sql-reference/data-types/special-data-types/expression.md new file mode 100644 index 00000000000..5efa0708cf5 --- /dev/null +++ b/docs/fa/sql-reference/data-types/special-data-types/expression.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "\u0639\u0628\u0627\u0631\u062A" +--- + +# عبارت {#expression} + +عبارات برای نمایندگی لامبداها در توابع بالا سفارش استفاده می شود. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/expression/) diff --git a/docs/fa/sql-reference/data-types/special-data-types/index.md b/docs/fa/sql-reference/data-types/special-data-types/index.md new file mode 100644 index 00000000000..901a39a5335 --- /dev/null +++ b/docs/fa/sql-reference/data-types/special-data-types/index.md @@ -0,0 +1,15 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0627\u0646\u0648\u0627\u0639 \u062F\u0627\u062F\u0647 \u0647\u0627\ + \u06CC \u0648\u06CC\u0698\u0647" +toc_hidden: true +toc_priority: 55 +toc_title: "\u0645\u062E\u0641\u06CC" +--- + +# انواع داده های ویژه {#special-data-types} + +مقادیر ویژه نوع داده را نمی توان برای صرفه جویی در یک جدول یا خروجی در نتایج پرس و جو سریال, اما می تواند به عنوان یک نتیجه متوسط در طول اجرای پرس و جو مورد استفاده قرار. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/) diff --git a/docs/fa/sql-reference/data-types/special-data-types/interval.md b/docs/fa/sql-reference/data-types/special-data-types/interval.md new file mode 100644 index 00000000000..7fcf722e0e5 --- /dev/null +++ b/docs/fa/sql-reference/data-types/special-data-types/interval.md @@ -0,0 +1,85 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "\u0641\u0627\u0635\u0644\u0647" +--- + +# فاصله {#data-type-interval} + +خانواده از انواع داده ها به نمایندگی از فواصل زمان و تاریخ. انواع حاصل از [INTERVAL](../../../sql-reference/operators/index.md#operator-interval) اپراتور + +!!! warning "اخطار" + `Interval` مقادیر نوع داده را نمی توان در جداول ذخیره کرد. + +ساختار: + +- فاصله زمانی به عنوان یک مقدار عدد صحیح بدون علامت. +- نوع فاصله. + +انواع فاصله پشتیبانی شده: + +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +برای هر نوع فاصله, یک نوع داده جداگانه وجود دارد. برای مثال `DAY` فاصله مربوط به `IntervalDay` نوع داده: + +``` sql +SELECT toTypeName(INTERVAL 4 DAY) +``` + +``` text +┌─toTypeName(toIntervalDay(4))─┐ +│ IntervalDay │ +└──────────────────────────────┘ +``` + +## اظهارات طریقه استفاده {#data-type-interval-usage-remarks} + +شما می توانید استفاده کنید `Interval`- ارزش نوع در عملیات ریاضی با [تاریخ](../../../sql-reference/data-types/date.md) و [DateTime](../../../sql-reference/data-types/datetime.md)- ارزش نوع . مثلا, شما می توانید اضافه کنید 4 روز به زمان فعلی: + +``` sql +SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY +``` + +``` text +┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ +│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ +└─────────────────────┴───────────────────────────────┘ +``` + +فواصل با انواع مختلف نمی تواند ترکیب شود. شما می توانید فواصل مانند استفاده کنید `4 DAY 1 HOUR`. مشخص فواصل در واحد است که کوچکتر یا برابر با کوچکترین واحد فاصله, مثلا, فاصله `1 day and an hour` فاصله را می توان به عنوان بیان شده است `25 HOUR` یا `90000 SECOND`. + +شما می توانید عملیات ریاضی با انجام نمی `Interval`- ارزش نوع, اما شما می توانید فواصل از انواع مختلف در نتیجه به ارزش در اضافه `Date` یا `DateTime` انواع داده ها. به عنوان مثال: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +پرس و جو زیر باعث یک استثنا: + +``` sql +select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) +``` + +``` text +Received exception from server (version 19.14.1): +Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. +``` + +## همچنین نگاه کنید به {#see-also} + +- [INTERVAL](../../../sql-reference/operators/index.md#operator-interval) اپراتور +- [توینتروال](../../../sql-reference/functions/type-conversion-functions.md#function-tointerval) توابع تبدیل نوع diff --git a/docs/fa/sql-reference/data-types/special-data-types/nothing.md b/docs/fa/sql-reference/data-types/special-data-types/nothing.md new file mode 100644 index 00000000000..4bc900edb67 --- /dev/null +++ b/docs/fa/sql-reference/data-types/special-data-types/nothing.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 60 +toc_title: "\u0647\u06CC\u0686\u06CC" +--- + +# هیچی {#nothing} + +تنها هدف از این نوع داده ها نشان دهنده مواردی است که انتظار نمی رود ارزش باشد. بنابراین شما می توانید یک ایجاد کنید `Nothing` نوع ارزش. + +مثلا, تحت اللفظی [NULL](../../../sql-reference/syntax.md#null-literal) دارای نوع `Nullable(Nothing)`. اطلاعات بیشتر در مورد [Nullable](../../../sql-reference/data-types/nullable.md). + +این `Nothing` نوع نیز می تواند مورد استفاده برای نشان دادن خالی: + +``` sql +SELECT toTypeName(array()) +``` + +``` text +┌─toTypeName(array())─┐ +│ Array(Nothing) │ +└─────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/nothing/) diff --git a/docs/fa/sql-reference/data-types/special-data-types/set.md b/docs/fa/sql-reference/data-types/special-data-types/set.md new file mode 100644 index 00000000000..9a5fcee4855 --- /dev/null +++ b/docs/fa/sql-reference/data-types/special-data-types/set.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: "\u062A\u0646\u0638\u06CC\u0645" +--- + +# تنظیم {#set} + +مورد استفاده برای نیمه راست یک [IN](../../operators/in.md#select-in-operators) اصطلاح. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/set/) diff --git a/docs/fa/sql-reference/data-types/string.md b/docs/fa/sql-reference/data-types/string.md new file mode 100644 index 00000000000..e260b681e0d --- /dev/null +++ b/docs/fa/sql-reference/data-types/string.md @@ -0,0 +1,20 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u0631\u0634\u062A\u0647" +--- + +# رشته {#string} + +رشته ها از طول دلخواه. طول محدود نمی شود. مقدار می تواند مجموعه دلخواه از بایت شامل, از جمله بایت پوچ. +نوع رشته جایگزین انواع لاکار, قطره, مسدود کردن, و دیگران را از دیگر سرویس بهداشتی. + +## کدگذاریها {#encodings} + +کلیکهاوس مفهوم کدگذاریها را ندارد. رشته ها می توانند شامل مجموعه دلخواه از بایت, که ذخیره می شود و خروجی به عنوان است. +اگر شما نیاز به ذخیره متون, توصیه می کنیم با استفاده از یونایتد-8 رمزگذاری. حداقل, اگر ترمینال خود را با استفاده از سخن گفتن-8 (به عنوان توصیه می شود), شما می توانید خواندن و نوشتن ارزش های خود را بدون ساخت تبدیل. +به طور مشابه, توابع خاص برای کار با رشته تغییرات جداگانه که با این فرض کار می کنند که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده-8. +برای مثال ‘length’ تابع محاسبه طول رشته در بایت, در حالی که ‘lengthUTF8’ تابع محاسبه طول رشته در نقاط کد یونیکد, فرض کنید که ارزش است گفتن-8 کد گذاری. + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/string/) diff --git a/docs/fa/sql-reference/data-types/tuple.md b/docs/fa/sql-reference/data-types/tuple.md new file mode 100644 index 00000000000..fc4aeb92fe0 --- /dev/null +++ b/docs/fa/sql-reference/data-types/tuple.md @@ -0,0 +1,52 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 53 +toc_title: "\u062A\u0627\u067E\u0644 (\u062A\u06CC1, \u062A\u06CC2,...)" +--- + +# Tuple(t1, T2, …) {#tuplet1-t2} + +یک تاپل از عناصر, هر یک با داشتن یک فرد [نوع](index.md#data_types). + +تاپل برای گروه بندی ستون موقت استفاده می شود. ستون ها را می توان گروه بندی کرد زمانی که یک عبارت در یک پرس و جو استفاده می شود, و برای مشخص کردن پارامترهای رسمی خاصی از توابع لامبدا. برای کسب اطلاعات بیشتر به بخش ها مراجعه کنید [در اپراتورها](../../sql-reference/operators/in.md) و [توابع سفارش بالاتر](../../sql-reference/functions/higher-order-functions.md). + +تاپل می تواند در نتیجه یک پرس و جو. در این مورد, برای فرمت های متنی غیر از جانسون, ارزش کاما از هم جدا در براکت. در فرمت های جوسون, تاپل خروجی به عنوان ارریس هستند (در براکت مربع). + +## ایجاد یک تاپل {#creating-a-tuple} + +شما می توانید یک تابع برای ایجاد یک تاپل استفاده کنید: + +``` sql +tuple(T1, T2, ...) +``` + +نمونه ای از ایجاد یک تاپل: + +``` sql +SELECT tuple(1,'a') AS x, toTypeName(x) +``` + +``` text +┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ +│ (1,'a') │ Tuple(UInt8, String) │ +└─────────┴───────────────────────────┘ +``` + +## کار با انواع داده ها {#working-with-data-types} + +در هنگام ایجاد یک تاپل در پرواز, تاتر به طور خودکار نوع هر استدلال به عنوان حداقل از انواع که می تواند ارزش استدلال ذخیره تشخیص. اگر استدلال است [NULL](../../sql-reference/syntax.md#null-literal), نوع عنصر تاپل است [Nullable](nullable.md). + +نمونه ای از تشخیص نوع داده ها به صورت خودکار: + +``` sql +SELECT tuple(1, NULL) AS x, toTypeName(x) +``` + +``` text +┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ +│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ +└──────────┴─────────────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/tuple/) diff --git a/docs/fa/sql-reference/data-types/uuid.md b/docs/fa/sql-reference/data-types/uuid.md new file mode 100644 index 00000000000..bc414b3b7e3 --- /dev/null +++ b/docs/fa/sql-reference/data-types/uuid.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: UUID +--- + +# UUID {#uuid-data-type} + +شناسه جهانی منحصر به فرد (شناسه) یک عدد 16 بایت مورد استفاده برای شناسایی سوابق است. برای کسب اطلاعات دقیق در مورد شناسه, دیدن [ویکیپدیا](https://en.wikipedia.org/wiki/Universally_unique_identifier). + +نمونه ای از ارزش نوع شناسه در زیر نشان داده شده است: + +``` text +61f0c404-5cb3-11e7-907b-a6006ad3dba0 +``` + +اگر شما مقدار ستون شناسه مشخص نیست در هنگام قرار دادن یک رکورد جدید, ارزش شناسه با صفر پر: + +``` text +00000000-0000-0000-0000-000000000000 +``` + +## چگونه برای تولید {#how-to-generate} + +برای تولید ارزش شناسه, خانه فراهم می کند [جنراتیدو4](../../sql-reference/functions/uuid-functions.md) تابع. + +## مثال طریقه استفاده {#usage-example} + +**مثال 1** + +این مثال نشان می دهد ایجاد یک جدول با ستون نوع شناسه و قرار دادن یک مقدار به جدول. + +``` sql +CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog +``` + +``` sql +INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +└──────────────────────────────────────┴───────────┘ +``` + +**مثال 2** + +در این مثال مقدار ستون یوید هنگام وارد کردن یک رکورد جدید مشخص نشده است. + +``` sql +INSERT INTO t_uuid (y) VALUES ('Example 2') +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ +└──────────────────────────────────────┴───────────┘ +``` + +## محدودیت ها {#restrictions} + +نوع داده شناسه تنها پشتیبانی از توابع که [رشته](string.md) نوع داده نیز پشتیبانی می کند (به عنوان مثال, [کمینه](../../sql-reference/aggregate-functions/reference.md#agg_function-min), [حداکثر](../../sql-reference/aggregate-functions/reference.md#agg_function-max) و [شمارش](../../sql-reference/aggregate-functions/reference.md#agg_function-count)). + +نوع داده یوید توسط عملیات ریاضی پشتیبانی نمی شود (به عنوان مثال, [شکم](../../sql-reference/functions/arithmetic-functions.md#arithm_func-abs)) و یا توابع دانه, مانند [جمع](../../sql-reference/aggregate-functions/reference.md#agg_function-sum) و [میانگین](../../sql-reference/aggregate-functions/reference.md#agg_function-avg). + +[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md new file mode 100644 index 00000000000..0cb27e5ec39 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md @@ -0,0 +1,71 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u0644\u063A\u062A\u0646\u0627\u0645\u0647\u0647\u0627 \u0633\u0644\u0633\ + \u0644\u0647 \u0645\u0631\u0627\u062A\u0628\u06CC" +--- + +# لغتنامهها سلسله مراتبی {#hierarchical-dictionaries} + +کلیک هاوس از لغت نامه های سلسله مراتبی با یک [کلید عددی](external-dicts-dict-structure.md#ext_dict-numeric-key). + +در ساختار سلسله مراتبی زیر نگاه کنید: + +``` text +0 (Common parent) +│ +├── 1 (Russia) +│ │ +│ └── 2 (Moscow) +│ │ +│ └── 3 (Center) +│ +└── 4 (Great Britain) + │ + └── 5 (London) +``` + +این سلسله مراتب را می توان به عنوان جدول فرهنگ لغت زیر بیان شده است. + +| \_ورود | \_ نواحی | نام \_خانوادگی | +|--------|----------|----------------| +| 1 | 0 | روسیه | +| 2 | 1 | مسکو | +| 3 | 2 | مرکز | +| 4 | 0 | بریتانیا | +| 5 | 4 | لندن | + +این جدول شامل یک ستون است `parent_region` که شامل کلید نزدیکترین پدر و مادر برای عنصر. + +تاتر از [سلسله مراتبی](external-dicts-dict-structure.md#hierarchical-dict-attr) املاک برای [فرهنگ لغت خارجی](index.md) صفات. این ویژگی اجازه می دهد تا شما را به پیکربندی فرهنگ لغت سلسله مراتبی شبیه به بالا توضیح داده شد. + +این [حکومت دیکتاتوری](../../../sql-reference/functions/ext-dict-functions.md#dictgethierarchy) تابع اجازه می دهد تا شما را به زنجیره پدر و مادر از یک عنصر. + +برای مثال ما ساختار فرهنگ لغت می تواند به شرح زیر است: + +``` xml + + + + region_id + + + + parent_region + UInt64 + 0 + true + + + + region_name + String + + + + + +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md new file mode 100644 index 00000000000..eee74368127 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -0,0 +1,397 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u0630\u062E\u06CC\u0631\u0647 \u0648\u0627\u0698\u0647\u0646\u0627\u0645\ + \u0647\u0647\u0627 \u062F\u0631 \u062D\u0627\u0641\u0638\u0647" +--- + +# ذخیره واژهنامهها در حافظه {#dicts-external-dicts-dict-layout} + +راه های مختلفی برای ذخیره لغت نامه ها در حافظه وجود دارد. + +ما توصیه می کنیم [تخت](#flat), [درهم](#dicts-external_dicts_dict_layout-hashed) و [\_ساخت مجتمع](#complex-key-hashed). که سرعت پردازش بهینه را فراهم می کند. + +ذخیره سازی به دلیل عملکرد بالقوه ضعیف و مشکلات در انتخاب پارامترهای مطلوب توصیه نمی شود. ادامه مطلب در بخش “[نهانگاه](#cache)”. + +راه های مختلفی برای بهبود عملکرد فرهنگ لغت وجود دارد: + +- پاسخ تابع برای کار با فرهنگ لغت پس از `GROUP BY`. +- علامت گذاری به عنوان ویژگی برای استخراج به عنوان تزریقی. یک ویژگی است که به نام عاطفی اگر مقادیر ویژگی های مختلف به کلید های مختلف مطابقت دارد. بنابراین زمانی که `GROUP BY` با استفاده از یک تابع است که بازخوانی ارزش ویژگی های کلیدی, این تابع به طور خودکار از گرفته `GROUP BY`. + +تاتر تولید یک استثنا برای خطا با لغت نامه. نمونه هایی از اشتباهات: + +- فرهنگ لغت در حال دسترسی نمی تواند لود شود. +- خطای پرسوجو یک `cached` فرهنگ لغت. + +شما می توانید لیستی از لغت نامه های خارجی و وضعیت خود را در `system.dictionaries` جدول + +پیکربندی به نظر می رسد مثل این: + +``` xml + + + ... + + + + + + ... + + +``` + +متناظر [توصیف](../../statements/create.md#create-dictionary-query): + +``` sql +CREATE DICTIONARY (...) +... +LAYOUT(LAYOUT_TYPE(param value)) -- layout settings +... +``` + +## راه هایی برای ذخیره لغت نامه ها در حافظه {#ways-to-store-dictionaries-in-memory} + +- [تخت](#flat) +- [درهم](#dicts-external_dicts_dict_layout-hashed) +- [فشردهسازی](#dicts-external_dicts_dict_layout-sparse_hashed) +- [نهانگاه](#cache) +- [مستقیم](#direct) +- [رنگها](#range-hashed) +- [\_ساخت مجتمع](#complex-key-hashed) +- [\_پیچید\_چهای پیچیده](#complex-key-cache) +- [شمال اروپا](#ip-trie) + +### تخت {#flat} + +فرهنگ لغت به طور کامل در حافظه در قالب مجموعه تخت ذخیره می شود. چقدر حافظه استفاده از فرهنگ لغت? مقدار متناسب با اندازه بزرگترین کلید است (در فضا استفاده می شود). + +کلید فرهنگ لغت است `UInt64` نوع و ارزش محدود به 500,000 است. اگر یک کلید بزرگتر کشف شده است در هنگام ایجاد فرهنگ لغت, تاتر می اندازد یک استثنا و فرهنگ لغت ایجاد کنید. + +تمام انواع منابع پشتیبانی می شوند. هنگام به روز رسانی, داده ها (از یک فایل و یا از یک جدول) در تمامیت خود را به عنوان خوانده شده. + +این روش بهترین عملکرد را در میان تمام روش های موجود ذخیره سازی فرهنگ لغت فراهم می کند. + +مثال پیکربندی: + +``` xml + + + +``` + +یا + +``` sql +LAYOUT(FLAT()) +``` + +### درهم {#dicts-external_dicts_dict_layout-hashed} + +فرهنگ لغت به طور کامل در حافظه در قالب یک جدول هش ذخیره می شود. فرهنگ لغت می تواند شامل هر تعداد از عناصر با هر شناسه در عمل تعداد کلید ده ها میلیون نفر از اقلام برسد. + +تمام انواع منابع پشتیبانی می شوند. هنگام به روز رسانی, داده ها (از یک فایل و یا از یک جدول) در تمامیت خود را به عنوان خوانده شده. + +مثال پیکربندی: + +``` xml + + + +``` + +یا + +``` sql +LAYOUT(HASHED()) +``` + +### فشردهسازی {#dicts-external_dicts_dict_layout-sparse_hashed} + +مشابه به `hashed`, اما با استفاده از حافظه کمتر به نفع استفاده از پردازنده بیشتر. + +مثال پیکربندی: + +``` xml + + + +``` + +``` sql +LAYOUT(SPARSE_HASHED()) +``` + +### \_ساخت مجتمع {#complex-key-hashed} + +این نوع ذخیره سازی برای استفاده با کامپوزیت است [کلید](external-dicts-dict-structure.md). مشابه به `hashed`. + +مثال پیکربندی: + +``` xml + + + +``` + +``` sql +LAYOUT(COMPLEX_KEY_HASHED()) +``` + +### رنگها {#range-hashed} + +فرهنگ لغت در حافظه به شکل یک جدول هش با مجموعه ای مرتب از محدوده ها و مقادیر مربوطه ذخیره می شود. + +این روش ذخیره سازی کار می کند به همان شیوه به عنوان درهم و اجازه می دهد تا با استفاده از تاریخ/زمان (نوع عددی دلخواه) محدوده علاوه بر کلید. + +مثال: جدول شامل تخفیف برای هر تبلیغ در قالب: + +``` text ++---------|-------------|-------------|------+ +| advertiser id | discount start date | discount end date | amount | ++===============+=====================+===================+========+ +| 123 | 2015-01-01 | 2015-01-15 | 0.15 | ++---------|-------------|-------------|------+ +| 123 | 2015-01-16 | 2015-01-31 | 0.25 | ++---------|-------------|-------------|------+ +| 456 | 2015-01-01 | 2015-01-15 | 0.05 | ++---------|-------------|-------------|------+ +``` + +برای استفاده از یک نمونه برای محدوده تاریخ, تعریف `range_min` و `range_max` عناصر در [ساختار](external-dicts-dict-structure.md). این عناصر باید حاوی عناصر `name` و`type` (اگر `type` مشخص نشده است, نوع پیش فرض استفاده خواهد شد - تاریخ). `type` می تواند هر نوع عددی (تاریخ / DateTime / UInt64 / Int32 / دیگران). + +مثال: + +``` xml + + + Id + + + first + Date + + + last + Date + + ... +``` + +یا + +``` sql +CREATE DICTIONARY somedict ( + id UInt64, + first Date, + last Date +) +PRIMARY KEY id +LAYOUT(RANGE_HASHED()) +RANGE(MIN first MAX last) +``` + +برای کار با این لغت نامه, شما نیاز به تصویب یک استدلال اضافی به `dictGetT` تابع, که یک محدوده انتخاب شده است: + +``` sql +dictGetT('dict_name', 'attr_name', id, date) +``` + +این تابع ارزش برای مشخص گرداند `id`بازدید کنندگان و محدوده تاریخ که شامل تاریخ گذشت. + +اطلاعات از الگوریتم: + +- اگر `id` یافت نشد و یا یک محدوده برای یافت نشد `id` مقدار پیش فرض فرهنگ لغت را برمی گرداند. +- اگر با هم تداخل دارند محدوده وجود دارد, شما می توانید هر استفاده. +- اگر جداساز محدوده باشد `NULL` یا نامعتبر تاریخ (مانند 1900-01-01 یا 2039-01-01) طیف وسیعی است که در سمت چپ باز است. محدوده را می توان در هر دو طرف باز کرد. + +مثال پیکربندی: + +``` xml + + + + ... + + + + + + + + Abcdef + + + StartTimeStamp + UInt64 + + + EndTimeStamp + UInt64 + + + XXXType + String + + + + + + +``` + +یا + +``` sql +CREATE DICTIONARY somedict( + Abcdef UInt64, + StartTimeStamp UInt64, + EndTimeStamp UInt64, + XXXType String DEFAULT '' +) +PRIMARY KEY Abcdef +RANGE(MIN StartTimeStamp MAX EndTimeStamp) +``` + +### نهانگاه {#cache} + +فرهنگ لغت در کش است که تعداد ثابتی از سلول های ذخیره می شود. این سلول ها حاوی عناصر اغلب استفاده می شود. + +هنگام جستجو برای یک فرهنگ لغت کش اول جستجو می شود. برای هر بلوک از داده ها, تمام کلید هایی که در کش یافت نشد و یا منسوخ شده از منبع با استفاده از درخواست `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. داده های دریافت شده است و سپس به کش نوشته شده است. + +برای لغت نامه کش, انقضا [طول عمر](external-dicts-dict-lifetime.md) از داده ها در کش را می توان تنظیم کرد. اگر زمان بیشتری از `lifetime` از زمان بارگذاری داده ها در یک سلول گذشت, ارزش سلول استفاده نمی شود, و دوباره درخواست دفعه بعد که نیاز به استفاده می شود. +این حداقل موثر از تمام راه هایی برای ذخیره لغت نامه است. سرعت کش به شدت در تنظیمات صحیح و سناریوی استفاده بستگی دارد. فرهنگ لغت نوع کش به خوبی انجام تنها زمانی که نرخ ضربه به اندازه کافی بالا هستند (توصیه می شود 99% و بالاتر). شما می توانید میزان ضربه به طور متوسط در مشاهده `system.dictionaries` جدول + +برای بهبود عملکرد کش, استفاده از یک خرده فروشی با `LIMIT`, و پاسخ تابع با فرهنگ لغت خارجی. + +پشتیبانی [منابع](external-dicts-dict-sources.md) پردازشگر پشتیبانی شده: + +مثال تنظیمات: + +``` xml + + + + 1000000000 + + +``` + +یا + +``` sql +LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) +``` + +تنظیم اندازه کش به اندازه کافی بزرگ است. شما نیاز به تجربه برای انتخاب تعدادی از سلول های: + +1. تنظیم برخی از ارزش. +2. نمایش داده شد اجرا تا کش کاملا کامل است. +3. ارزیابی مصرف حافظه با استفاده از `system.dictionaries` جدول +4. افزایش یا کاهش تعداد سلول ها تا زمانی که مصرف حافظه مورد نیاز رسیده است. + +!!! warning "اخطار" + هنوز تاتر به عنوان یک منبع استفاده نمی, چرا که کند است برای پردازش نمایش داده شد با تصادفی می خواند. + +### \_پیچید\_چهای پیچیده {#complex-key-cache} + +این نوع ذخیره سازی برای استفاده با کامپوزیت است [کلید](external-dicts-dict-structure.md). مشابه به `cache`. + +### مستقیم {#direct} + +فرهنگ لغت در حافظه ذخیره نمی شود و به طور مستقیم به منبع می رود در طول پردازش یک درخواست. + +کلید فرهنگ لغت است `UInt64` نوع. + +همه انواع [منابع](external-dicts-dict-sources.md), به جز فایل های محلی, پشتیبانی می شوند. + +مثال پیکربندی: + +``` xml + + + +``` + +یا + +``` sql +LAYOUT(DIRECT()) +``` + +### شمال اروپا {#ip-trie} + +این نوع ذخیره سازی برای پیشوندهای نقشه برداری شبکه (نشانی های اینترنتی) به فراداده مانند ان است. + +مثال: جدول شامل پیشوندهای شبکه و مربوط به خود را به عنوان شماره و کد کشور: + +``` text + +-----------|-----|------+ + | prefix | asn | cca2 | + +=================+=======+========+ + | 202.79.32.0/20 | 17501 | NP | + +-----------|-----|------+ + | 2620:0:870::/48 | 3856 | US | + +-----------|-----|------+ + | 2a02:6b8:1::/48 | 13238 | RU | + +-----------|-----|------+ + | 2001:db8::/32 | 65536 | ZZ | + +-----------|-----|------+ +``` + +هنگام استفاده از این نوع طرح, ساختار باید یک کلید کامپوزیت دارند. + +مثال: + +``` xml + + + + prefix + String + + + + asn + UInt32 + + + + cca2 + String + ?? + + ... +``` + +یا + +``` sql +CREATE DICTIONARY somedict ( + prefix String, + asn UInt32, + cca2 String DEFAULT '??' +) +PRIMARY KEY prefix +``` + +کلید باید تنها یک ویژگی نوع رشته ای داشته باشد که شامل یک پیشوند مجاز است. انواع دیگر هنوز پشتیبانی نمی شوند. + +برای نمایش داده شد, شما باید توابع مشابه استفاده کنید (`dictGetT` با یک تاپل) به عنوان لغت نامه با کلید های کامپوزیت: + +``` sql +dictGetT('dict_name', 'attr_name', tuple(ip)) +``` + +تابع طول می کشد یا `UInt32` برای ایپو4 یا `FixedString(16)` برای IPv6: + +``` sql +dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) +``` + +انواع دیگر هنوز پشتیبانی نمی شوند. تابع ویژگی برای پیشوند که مربوط به این نشانی اینترنتی را برمی گرداند. اگر پیشوند با هم تداخل دارند وجود دارد, یکی از خاص ترین بازگشته است. + +داده ها در یک ذخیره می شود `trie`. این به طور کامل باید به رم مناسب. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md new file mode 100644 index 00000000000..ed4485d4392 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md @@ -0,0 +1,92 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u0628\u0647 \u0631\u0648\u0632 \u0631\u0633\u0627\u0646\u06CC \u0641\u0631\ + \u0647\u0646\u06AF \u0644\u063A\u062A" +--- + +# به روز رسانی فرهنگ لغت {#dictionary-updates} + +خانه کلیک دوره به روز رسانی لغت نامه. فاصله به روز رسانی برای لغت نامه به طور کامل دانلود و فاصله ابطال لغت نامه کش در تعریف `` برچسب در ثانیه. + +به روز رسانی فرهنگ لغت (به غیر از بارگذاری برای استفاده اول) نمایش داده شد را مسدود کند. در طول به روز رسانی, نسخه های قدیمی از یک فرهنگ لغت استفاده شده است. اگر یک خطا در طول به روز رسانی رخ می دهد, خطا به ورود به سیستم سرور نوشته شده, و نمایش داده شد ادامه استفاده از نسخه های قدیمی از لغت نامه. + +مثال تنظیمات: + +``` xml + + ... + 300 + ... + +``` + +``` sql +CREATE DICTIONARY (...) +... +LIFETIME(300) +... +``` + +تنظیم `0` (`LIFETIME(0)`) جلوگیری از لغت نامه از به روز رسانی . + +شما می توانید یک بازه زمانی برای ارتقا تنظیم, و تاتر یک زمان یکنواخت تصادفی در این محدوده را انتخاب کنید. این به منظور توزیع بار بر روی منبع فرهنگ لغت در هنگام به روز رسانی در تعداد زیادی از سرور لازم است. + +مثال تنظیمات: + +``` xml + + ... + + 300 + 360 + + ... + +``` + +یا + +``` sql +LIFETIME(MIN 300 MAX 360) +``` + +اگر `0` و `0`, کلیک می کند فرهنگ لغت توسط ایست بارگذاری مجدد نیست. +در این مورد, تاتر می توانید فرهنگ لغت زودتر بارگذاری مجدد اگر فایل پیکربندی فرهنگ لغت تغییر یافت و یا `SYSTEM RELOAD DICTIONARY` فرمان اعدام شد. + +هنگام به روز رسانی لغت نامه, سرور کلیک اعمال منطق مختلف بسته به نوع [متن](external-dicts-dict-sources.md): + +هنگام به روز رسانی لغت نامه, سرور کلیک اعمال منطق مختلف بسته به نوع [متن](external-dicts-dict-sources.md): + +- برای یک فایل متنی زمان اصلاح را بررسی می کند. اگر زمان از زمان قبلا ثبت شده متفاوت, فرهنگ لغت به روز شده است. +- برای جداول میثم, زمان اصلاح بررسی می شود با استفاده از یک `SHOW TABLE STATUS` پرس و جو. +- واژهنامهها از منابع دیگر در هر زمان به طور پیش فرض به روز شد. + +برای خروجی زیر (دیگر), ان بی سی و منابع فاحشه خانه, شما می توانید راه اندازی یک پرس و جو است که لغت نامه تنها در صورتی که واقعا تغییر به روز رسانی, به جای هر زمان. برای انجام این کار این مراحل را دنبال کنید: + +- جدول فرهنگ لغت باید یک میدان است که همیشه تغییر زمانی که داده های منبع به روز شده است. +- تنظیمات منبع باید پرس و جو که بازیابی زمینه در حال تغییر را مشخص کنید. سرور کلیک تفسیر نتیجه پرس و جو به عنوان یک ردیف, و اگر این ردیف نسبت به حالت قبلی خود تغییر کرده است, فرهنگ لغت به روز شده است. مشخص کردن پرسوجو در `` درست در تنظیمات برای [متن](external-dicts-dict-sources.md). + +مثال تنظیمات: + +``` xml + + ... + + ... + SELECT update_time FROM dictionary_source where id = 1 + + ... + +``` + +یا + +``` sql +... +SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) +... +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md new file mode 100644 index 00000000000..81e0055d92e --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md @@ -0,0 +1,631 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u0645\u0646\u0627\u0628\u0639 \u0644\u063A\u062A \u0646\u0627\u0645\u0647\ + \ \u0647\u0627\u06CC \u062E\u0627\u0631\u062C\u06CC" +--- + +# منابع لغت نامه های خارجی {#dicts-external-dicts-dict-sources} + +فرهنگ لغت خارجی را می توان از بسیاری از منابع مختلف متصل می شود. + +اگر فرهنگ لغت پیکربندی شده است با استفاده از فایل های فشرده, پیکربندی به نظر می رسد مثل این: + +``` xml + + + ... + + + + + + ... + + ... + +``` + +در صورت [توصیف](../../statements/create.md#create-dictionary-query), پیکربندی برابر خواهد شد مانند به نظر می رسد: + +``` sql +CREATE DICTIONARY dict_name (...) +... +SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration +... +``` + +منبع در پیکربندی `source` بخش. + +برای انواع منبع [پرونده محلی](#dicts-external_dicts_dict_sources-local_file), [پرونده اجرایی](#dicts-external_dicts_dict_sources-executable), [HTTP(s)](#dicts-external_dicts_dict_sources-http), [فاحشه خانه](#dicts-external_dicts_dict_sources-clickhouse) +تنظیمات اختیاری در دسترس هستند: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + + 0 + + +``` + +یا + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +SETTINGS(format_csv_allow_single_quotes = 0) +``` + +انواع منابع (`source_type`): + +- [پرونده محلی](#dicts-external_dicts_dict_sources-local_file) +- [پرونده اجرایی](#dicts-external_dicts_dict_sources-executable) +- [HTTP(s)](#dicts-external_dicts_dict_sources-http) +- DBMS + - [ODBC](#dicts-external_dicts_dict_sources-odbc) + - [MySQL](#dicts-external_dicts_dict_sources-mysql) + - [فاحشه خانه](#dicts-external_dicts_dict_sources-clickhouse) + - [مانگودیبی](#dicts-external_dicts_dict_sources-mongodb) + - [ردیس](#dicts-external_dicts_dict_sources-redis) + +## پرونده محلی {#dicts-external_dicts_dict_sources-local_file} + +مثال تنظیمات: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + +``` + +یا + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +تنظیم فیلدها: + +- `path` – The absolute path to the file. +- `format` – The file format. All the formats described in “[فرشها](../../../interfaces/formats.md#formats)” پشتیبانی می شوند. + +## پرونده اجرایی {#dicts-external_dicts_dict_sources-executable} + +کار با فایل های اجرایی بستگی دارد [چگونه فرهنگ لغت در حافظه ذخیره می شود](external-dicts-dict-layout.md). اگر فرهنگ لغت با استفاده از ذخیره می شود `cache` و `complex_key_cache` کلیک هاوس کلید های لازم را با ارسال درخواست به فایل اجرایی درخواست می کند. در غیر این صورت, تاتر شروع می شود فایل اجرایی و خروجی خود را به عنوان داده فرهنگ لغت رفتار. + +مثال تنظیمات: + +``` xml + + + cat /opt/dictionaries/os.tsv + TabSeparated + + +``` + +یا + +``` sql +SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +تنظیم فیلدها: + +- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). +- `format` – The file format. All the formats described in “[فرشها](../../../interfaces/formats.md#formats)” پشتیبانی می شوند. + +## قام) {#dicts-external_dicts_dict_sources-http} + +کار با سرور اچ تی پی بستگی دارد [چگونه فرهنگ لغت در حافظه ذخیره می شود](external-dicts-dict-layout.md). اگر فرهنگ لغت با استفاده از ذخیره می شود `cache` و `complex_key_cache`, کلیک درخواست کلید های لازم با ارسال یک درخواست از طریق `POST` روش. + +مثال تنظیمات: + +``` xml + + + http://[::1]/os.tsv + TabSeparated + + user + password + + +
+ API-KEY + key +
+
+
+ +``` + +یا + +``` sql +SOURCE(HTTP( + url 'http://[::1]/os.tsv' + format 'TabSeparated' + credentials(user 'user' password 'password') + headers(header(name 'API-KEY' value 'key')) +)) +``` + +برای دسترسی به یک منبع اچ تی پی باید از اینجا کلیک کنید [پیکربندی اپنسسل](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-openssl) در پیکربندی سرور. + +تنظیم فیلدها: + +- `url` – The source URL. +- `format` – The file format. All the formats described in “[فرشها](../../../interfaces/formats.md#formats)” پشتیبانی می شوند. +- `credentials` – Basic HTTP authentication. Optional parameter. + - `user` – Username required for the authentication. + - `password` – Password required for the authentication. +- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. + - `header` – Single HTTP header entry. + - `name` – Identifiant name used for the header send on the request. + - `value` – Value set for a specific identifiant name. + +## ODBC {#dicts-external_dicts_dict_sources-odbc} + +شما می توانید از این روش برای اتصال هر پایگاه داده است که یک راننده بی سی استفاده کنید. + +مثال تنظیمات: + +``` xml + + + DatabaseName + ShemaName.TableName
+ DSN=some_parameters + SQL_QUERY +
+ +``` + +یا + +``` sql +SOURCE(ODBC( + db 'DatabaseName' + table 'SchemaName.TableName' + connection_string 'DSN=some_parameters' + invalidate_query 'SQL_QUERY' +)) +``` + +تنظیم فیلدها: + +- `db` – Name of the database. Omit it if the database name is set in the `` پارامترها +- `table` – Name of the table and schema if exists. +- `connection_string` – Connection string. +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [بهروزرسانی واژهنامهها](external-dicts-dict-lifetime.md). + +تاتر دریافت به نقل از علامت از او بی سی راننده و نقل قول تمام تنظیمات در نمایش داده شد به راننده, بنابراین لازم است به مجموعه ای از نام جدول بر این اساس به نام جدول مورد در پایگاه داده. + +اگر شما یک مشکل با کدگذاریها در هنگام استفاده از اوراکل, دیدن مربوطه [FAQ](../../../faq/general.md#oracle-odbc-encodings) مقاله. + +### قابلیت پذیری شناخته شده از قابلیت او بی سی فرهنگ لغت {#known-vulnerability-of-the-odbc-dictionary-functionality} + +!!! attention "توجه" + هنگام اتصال به پایگاه داده از طریق پارامتر اتصال درایور او بی سی `Servername` می تواند جایگزین شود. در این مورد ارزش `USERNAME` و `PASSWORD` از `odbc.ini` به سرور از راه دور ارسال می شود و می تواند به خطر بیافتد. + +**نمونه ای از استفاده نا امن** + +اجازه می دهد تا پیکربندی unixODBC برای PostgreSQL. محتوای `/etc/odbc.ini`: + +``` text +[gregtest] +Driver = /usr/lib/psqlodbca.so +Servername = localhost +PORT = 5432 +DATABASE = test_db +#OPTION = 3 +USERNAME = test +PASSWORD = test +``` + +اگر شما پس از ایجاد یک پرس و جو مانند + +``` sql +SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); +``` + +درایور او بی سی خواهد ارزش ارسال `USERNAME` و `PASSWORD` از `odbc.ini` به `some-server.com`. + +### به عنوان مثال از اتصال شل {#example-of-connecting-postgresql} + +سیستم عامل اوبونتو. + +نصب unixODBC و ODBC driver for PostgreSQL: + +``` bash +$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql +``` + +پیکربندی `/etc/odbc.ini` (یا `~/.odbc.ini`): + +``` text + [DEFAULT] + Driver = myconnection + + [myconnection] + Description = PostgreSQL connection to my_db + Driver = PostgreSQL Unicode + Database = my_db + Servername = 127.0.0.1 + UserName = username + Password = password + Port = 5432 + Protocol = 9.3 + ReadOnly = No + RowVersioning = No + ShowSystemTables = No + ConnSettings = +``` + +پیکربندی فرهنگ لغت در کلیک: + +``` xml + + + table_name + + + + + DSN=myconnection + postgresql_table
+
+ + + 300 + 360 + + + + + + + id + + + some_column + UInt64 + 0 + + +
+
+``` + +یا + +``` sql +CREATE DICTIONARY table_name ( + id UInt64, + some_column UInt64 DEFAULT 0 +) +PRIMARY KEY id +SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) +LAYOUT(HASHED()) +LIFETIME(MIN 300 MAX 360) +``` + +شما ممکن است نیاز به ویرایش `odbc.ini` برای مشخص کردن مسیر کامل به کتابخانه با راننده `DRIVER=/usr/local/lib/psqlodbcw.so`. + +### به عنوان مثال اتصال سرور کارشناسی ارشد گذاشتن {#example-of-connecting-ms-sql-server} + +سیستم عامل اوبونتو. + +نصب درایور: : + +``` bash +$ sudo apt-get install tdsodbc freetds-bin sqsh +``` + +پیکربندی راننده: + +``` bash + $ cat /etc/freetds/freetds.conf + ... + + [MSSQL] + host = 192.168.56.101 + port = 1433 + tds version = 7.0 + client charset = UTF-8 + + $ cat /etc/odbcinst.ini + ... + + [FreeTDS] + Description = FreeTDS + Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so + Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so + FileUsage = 1 + UsageCount = 5 + + $ cat ~/.odbc.ini + ... + + [MSSQL] + Description = FreeTDS + Driver = FreeTDS + Servername = MSSQL + Database = test + UID = test + PWD = test + Port = 1433 +``` + +پیکربندی فرهنگ لغت در کلیک: + +``` xml + + + test + + + dict
+ DSN=MSSQL;UID=test;PWD=test +
+ + + + 300 + 360 + + + + + + + + + k + + + s + String + + + +
+
+``` + +یا + +``` sql +CREATE DICTIONARY test ( + k UInt64, + s String DEFAULT '' +) +PRIMARY KEY k +SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) +LAYOUT(FLAT()) +LIFETIME(MIN 300 MAX 360) +``` + +## DBMS {#dbms} + +### Mysql {#dicts-external_dicts_dict_sources-mysql} + +مثال تنظیمات: + +``` xml + + + 3306 + clickhouse + qwerty + + example01-1 + 1 + + + example01-2 + 1 + + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +یا + +``` sql +SOURCE(MYSQL( + port 3306 + user 'clickhouse' + password 'qwerty' + replica(host 'example01-1' priority 1) + replica(host 'example01-2' priority 1) + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +تنظیم فیلدها: + +- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). + +- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). + +- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). + +- `replica` – Section of replica configurations. There can be multiple sections. + + - `replica/host` – The MySQL host. + - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. + +- `db` – Name of the database. + +- `table` – Name of the table. + +- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` بند در خروجی زیر, مثلا, `id > 10 AND id < 20`. پارامتر اختیاری. + +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [بهروزرسانی واژهنامهها](external-dicts-dict-lifetime.md). + +خروجی زیر را می توان در یک میزبان محلی از طریق سوکت متصل. برای انجام این کار, تنظیم `host` و `socket`. + +مثال تنظیمات: + +``` xml + + + localhost + /path/to/socket/file.sock + clickhouse + qwerty + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +یا + +``` sql +SOURCE(MYSQL( + host 'localhost' + socket '/path/to/socket/file.sock' + user 'clickhouse' + password 'qwerty' + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +### فاحشه خانه {#dicts-external_dicts_dict_sources-clickhouse} + +مثال تنظیمات: + +``` xml + + + example01-01-1 + 9000 + default + + default + ids
+ id=10 +
+ +``` + +یا + +``` sql +SOURCE(CLICKHOUSE( + host 'example01-01-1' + port 9000 + user 'default' + password '' + db 'default' + table 'ids' + where 'id=10' +)) +``` + +تنظیم فیلدها: + +- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [توزیع شده](../../../engines/table-engines/special/distributed.md) جدول و در تنظیمات بعدی وارد کنید. +- `port` – The port on the ClickHouse server. +- `user` – Name of the ClickHouse user. +- `password` – Password of the ClickHouse user. +- `db` – Name of the database. +- `table` – Name of the table. +- `where` – The selection criteria. May be omitted. +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [بهروزرسانی واژهنامهها](external-dicts-dict-lifetime.md). + +### مانگودیبی {#dicts-external_dicts_dict_sources-mongodb} + +مثال تنظیمات: + +``` xml + + + localhost + 27017 + + + test + dictionary_source + + +``` + +یا + +``` sql +SOURCE(MONGO( + host 'localhost' + port 27017 + user '' + password '' + db 'test' + collection 'dictionary_source' +)) +``` + +تنظیم فیلدها: + +- `host` – The MongoDB host. +- `port` – The port on the MongoDB server. +- `user` – Name of the MongoDB user. +- `password` – Password of the MongoDB user. +- `db` – Name of the database. +- `collection` – Name of the collection. + +### ردیس {#dicts-external_dicts_dict_sources-redis} + +مثال تنظیمات: + +``` xml + + + localhost + 6379 + simple + 0 + + +``` + +یا + +``` sql +SOURCE(REDIS( + host 'localhost' + port 6379 + storage_type 'simple' + db_index 0 +)) +``` + +تنظیم فیلدها: + +- `host` – The Redis host. +- `port` – The port on the Redis server. +- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` برای منابع ساده و برای منابع تک کلیدی درهم, `hash_map` برای منابع درهم با دو کلید. منابع در بازه زمانی و منابع کش با کلید پیچیده پشتیبانی نشده است. ممکن است حذف شود, مقدار پیش فرض است `simple`. +- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md new file mode 100644 index 00000000000..4df4e774bb4 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md @@ -0,0 +1,176 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u06A9\u0644\u06CC\u062F \u0641\u0631\u0647\u0646\u06AF \u0644\u063A\u062A\ + \ \u0648 \u0632\u0645\u06CC\u0646\u0647 \u0647\u0627\u06CC" +--- + +# کلید فرهنگ لغت و زمینه های {#dictionary-key-and-fields} + +این `` بند توصیف کلید فرهنگ لغت و زمینه های موجود برای نمایش داده شد. + +توصیف: + +``` xml + + + + Id + + + + + + + ... + + + +``` + +صفات در عناصر شرح داده شده است: + +- `` — [ستون کلید](external-dicts-dict-structure.md#ext_dict_structure-key). +- `` — [ستون داده](external-dicts-dict-structure.md#ext_dict_structure-attributes). می تواند تعدادی از ویژگی های وجود دارد. + +پرسوجو: + +``` sql +CREATE DICTIONARY dict_name ( + Id UInt64, + -- attributes +) +PRIMARY KEY Id +... +``` + +صفات در بدن پرس و جو توصیف: + +- `PRIMARY KEY` — [ستون کلید](external-dicts-dict-structure.md#ext_dict_structure-key) +- `AttrName AttrType` — [ستون داده](external-dicts-dict-structure.md#ext_dict_structure-attributes). می تواند تعدادی از ویژگی های وجود دارد. + +## کلید {#ext_dict_structure-key} + +تاتر از انواع زیر از کلید: + +- کلید عددی. `UInt64`. تعریف شده در `` برچسب یا استفاده `PRIMARY KEY` کلمه کلیدی. +- کلید کامپوزیت. مجموعه ای از مقادیر از انواع مختلف. تعریف شده در برچسب `` یا `PRIMARY KEY` کلمه کلیدی. + +یک ساختار میلی لیتر می تواند شامل موارد زیر باشد `` یا ``. دی ال پرس و جو باید شامل تک `PRIMARY KEY`. + +!!! warning "اخطار" + شما باید کلید به عنوان یک ویژگی توصیف نیست. + +### کلید عددی {#ext_dict-numeric-key} + +نوع: `UInt64`. + +مثال پیکربندی: + +``` xml + + Id + +``` + +حوزههای پیکربندی: + +- `name` – The name of the column with keys. + +برای & پرسوجو: + +``` sql +CREATE DICTIONARY ( + Id UInt64, + ... +) +PRIMARY KEY Id +... +``` + +- `PRIMARY KEY` – The name of the column with keys. + +### کلید کامپوزیت {#composite-key} + +کلید می تواند یک `tuple` از هر نوع زمینه. این [طرحبندی](external-dicts-dict-layout.md) در این مورد باید باشد `complex_key_hashed` یا `complex_key_cache`. + +!!! tip "نکته" + کلید کامپوزیت می تواند از یک عنصر واحد تشکیل شده است. این امکان استفاده از یک رشته به عنوان کلید, برای مثال. + +ساختار کلیدی در عنصر تنظیم شده است ``. زمینه های کلیدی در قالب همان فرهنگ لغت مشخص شده است [خصیصهها](external-dicts-dict-structure.md). مثال: + +``` xml + + + + field1 + String + + + field2 + UInt32 + + ... + +... +``` + +یا + +``` sql +CREATE DICTIONARY ( + field1 String, + field2 String + ... +) +PRIMARY KEY field1, field2 +... +``` + +برای پرس و جو به `dictGet*` تابع, یک تاپل به عنوان کلید به تصویب رسید. مثال: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. + +## خصیصهها {#ext_dict_structure-attributes} + +مثال پیکربندی: + +``` xml + + ... + + Name + ClickHouseDataType + + rand64() + true + true + true + + +``` + +یا + +``` sql +CREATE DICTIONARY somename ( + Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID +) +``` + +حوزههای پیکربندی: + +| برچسب | توصیف | مورد نیاز | +|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------| +| `name` | نام ستون. | بله | +| `type` | نوع داده کلیک.
تاتر تلاش می کند به بازیگران ارزش از فرهنگ لغت به نوع داده مشخص شده است. مثلا, برای خروجی زیر, زمینه ممکن است `TEXT`, `VARCHAR` یا `BLOB` در جدول منبع خروجی زیر, اما می تواند به عنوان ارسال `String` در فاحشه خانه.
[Nullable](../../../sql-reference/data-types/nullable.md) پشتیبانی نمی شود. | بله | +| `null_value` | مقدار پیش فرض برای یک عنصر غیر موجود.
در مثال این یک رشته خالی است. شما نمی توانید استفاده کنید `NULL` در این زمینه. | بله | +| `expression` | [عبارت](../../syntax.md#syntax-expressions) که فاحشه خانه اجرا در ارزش.
بیان می تواند یک نام ستون در پایگاه داده از راه دور گذاشتن. بدین ترتیب, شما می توانید برای ایجاد یک نام مستعار برای ستون از راه دور استفاده.

مقدار پیش فرض: بدون بیان. | نه | +| `hierarchical` | اگر `true`, ویژگی شامل ارزش یک کلید پدر و مادر برای کلید فعلی. ببینید [لغتنامهها سلسله مراتبی](external-dicts-dict-hierarchical.md).

مقدار پیشفرض: `false`. | نه | +| `injective` | پرچمی که نشان میدهد چه `id -> attribute` تصویر [تزریق](https://en.wikipedia.org/wiki/Injective_function).
اگر `true`, کلیک خانه به طور خودکار می تواند پس از محل `GROUP BY` بند درخواست به لغت نامه با تزریق. معمولا به طور قابل توجهی میزان چنین درخواست را کاهش می دهد.

مقدار پیشفرض: `false`. | نه | +| `is_object_id` | پرچمی که نشان میدهد پرسوجو برای سند مانگودیبی اجرا شده است `ObjectID`.

مقدار پیشفرض: `false`. | نه | + +## همچنین نگاه کنید به {#see-also} + +- [توابع برای کار با لغت نامه های خارجی](../../../sql-reference/functions/ext-dict-functions.md). + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md new file mode 100644 index 00000000000..9bd07022190 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md @@ -0,0 +1,54 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u067E\u06CC\u06A9\u0631\u0628\u0646\u062F\u06CC \u06CC\u06A9 \u0641\u0631\ + \u0647\u0646\u06AF \u0644\u063A\u062A \u062E\u0627\u0631\u062C\u06CC" +--- + +# پیکربندی یک فرهنگ لغت خارجی {#dicts-external-dicts-dict} + +اگر فرهنگ لغت با استفاده از فایل میلی لیتر پیکربندی, از پیکربندی فرهنگ لغت دارای ساختار زیر: + +``` xml + + dict_name + + + + + + + + + + + + + + + + + +``` + +متناظر [توصیف](../../statements/create.md#create-dictionary-query) دارای ساختار زیر است: + +``` sql +CREATE DICTIONARY dict_name +( + ... -- attributes +) +PRIMARY KEY ... -- complex or single key configuration +SOURCE(...) -- Source configuration +LAYOUT(...) -- Memory layout configuration +LIFETIME(...) -- Lifetime of dictionary in memory +``` + +- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. +- [متن](external-dicts-dict-sources.md) — Source of the dictionary. +- [طرحبندی](external-dicts-dict-layout.md) — Dictionary layout in memory. +- [ساختار](external-dicts-dict-structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. +- [طول عمر](external-dicts-dict-lifetime.md) — Frequency of dictionary updates. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts.md new file mode 100644 index 00000000000..3640c07a092 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/external-dicts.md @@ -0,0 +1,62 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u062A\u0648\u0636\u06CC\u062D\u0627\u062A \u06A9\u0644\u06CC" +--- + +# واژهنامهها خارجی {#dicts-external-dicts} + +شما می توانید لغت نامه خود را از منابع داده های مختلف اضافه کنید. منبع داده برای یک فرهنگ لغت می تواند یک متن محلی و یا فایل اجرایی, یک منبع اچتیتیپی(بازدید کنندگان), یا سندرم داون دیگر. برای کسب اطلاعات بیشتر, دیدن “[منابع لغت نامه های خارجی](external-dicts-dict-sources.md)”. + +فاحشه خانه: + +- به طور کامل و یا تا حدی فروشگاه لغت نامه در رم. +- دوره به روز رسانی لغت نامه ها و به صورت پویا بارهای ارزش از دست رفته. به عبارت دیگر, لغت نامه را می توان به صورت پویا لود. +- اجازه می دهد تا برای ایجاد لغت نامه های خارجی با فایل های میلی لیتر و یا [نمایش داده شد](../../statements/create.md#create-dictionary-query). + +پیکربندی لغت نامه های خارجی را می توان در یک یا چند میلی لیتر فایل واقع شده است. مسیر پیکربندی در مشخص [دیکشنامهای](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_config) پارامتر. + +واژهنامهها را می توان در هنگام راه اندازی سرور و یا در اولین استفاده لود, بسته به [\_بارگیری کامل](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) تنظیمات. + +این [واژهنامهها](../../../operations/system-tables.md#system_tables-dictionaries) جدول سیستم شامل اطلاعات در مورد لغت نامه پیکربندی در سرور. برای هر فرهنگ لغت شما می توانید وجود دارد: + +- وضعیت فرهنگ لغت. +- پارامترهای پیکربندی. +- معیارهای مانند مقدار رم اختصاص داده شده برای فرهنگ لغت و یا تعدادی از نمایش داده شد از فرهنگ لغت با موفقیت لود شد. + +فایل پیکربندی فرهنگ لغت دارای فرمت زیر است: + +``` xml + + An optional element with any content. Ignored by the ClickHouse server. + + + /etc/metrika.xml + + + + + + + + +``` + +شما می توانید [پیکربندی](external-dicts-dict.md) هر تعداد از لغت نامه ها در همان فایل. + +[نمایش داده شد دی ال برای لغت نامه](../../statements/create.md#create-dictionary-query) هیچ پرونده اضافی در پیکربندی سرور نیاز ندارد. اجازه می دهد برای کار با لغت نامه به عنوان نهادهای طبقه اول, مانند جداول و یا دیدگاه. + +!!! attention "توجه" + شما می توانید مقادیر را برای یک فرهنگ لغت کوچک با توصیف در یک تبدیل کنید `SELECT` پرسوجو (نگاه کنید به [تبدیل](../../../sql-reference/functions/other-functions.md) تابع). این قابلیت به لغت نامه های خارجی مربوط نیست. + +## همچنین نگاه کنید به {#ext-dicts-see-also} + +- [پیکربندی یک فرهنگ لغت خارجی](external-dicts-dict.md) +- [ذخیره واژهنامهها در حافظه](external-dicts-dict-layout.md) +- [به روز رسانی فرهنگ لغت](external-dicts-dict-lifetime.md) +- [منابع لغت نامه های خارجی](external-dicts-dict-sources.md) +- [کلید فرهنگ لغت و زمینه های](external-dicts-dict-structure.md) +- [توابع برای کار با لغت نامه های خارجی](../../../sql-reference/functions/ext-dict-functions.md) + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/fa/sql-reference/dictionaries/external-dictionaries/index.md b/docs/fa/sql-reference/dictionaries/external-dictionaries/index.md new file mode 100644 index 00000000000..28403e5355c --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/external-dictionaries/index.md @@ -0,0 +1,9 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0648\u0627\u0698\u0647\u0646\u0627\u0645\u0647\u0647\u0627 \u062E\ + \u0627\u0631\u062C\u06CC" +toc_priority: 37 +--- + + diff --git a/docs/fa/sql-reference/dictionaries/index.md b/docs/fa/sql-reference/dictionaries/index.md new file mode 100644 index 00000000000..ac575a9c885 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/index.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0648\u0627\u0698\u0647\u0646\u0627\u0645\u0647\u0647\u0627" +toc_priority: 35 +toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" +--- + +# واژهنامهها {#dictionaries} + +فرهنگ لغت نقشه برداری است (`key -> attributes`) که مناسب برای انواع مختلفی از لیست مرجع است. + +تاتر پشتیبانی از توابع خاص برای کار با لغت نامه است که می تواند در نمایش داده شد استفاده می شود. این ساده تر و موثر تر به استفاده از لغت نامه ها با توابع از یک است `JOIN` با جداول مرجع. + +[NULL](../../sql-reference/syntax.md#null-literal) ارزش ها را نمی توان در یک فرهنگ لغت ذخیره کرد. + +پشتیبانی از کلیک: + +- [ساخته شده در لغت نامه](internal-dicts.md#internal_dicts) با یک خاص [مجموعه ای از توابع](../../sql-reference/functions/ym-dict-functions.md). +- [افزونه لغت نامه (خارجی) ](external-dictionaries/external-dicts.md#dicts-external-dicts) با یک [مجموعه ای از توابع](../../sql-reference/functions/ext-dict-functions.md). + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/fa/sql-reference/dictionaries/internal-dicts.md b/docs/fa/sql-reference/dictionaries/internal-dicts.md new file mode 100644 index 00000000000..6e849733d20 --- /dev/null +++ b/docs/fa/sql-reference/dictionaries/internal-dicts.md @@ -0,0 +1,56 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u0648\u0627\u0698\u0647\u0646\u0627\u0645\u0647\u0647\u0627 \u062F\u0627\ + \u062E\u0644\u06CC" +--- + +# واژهنامهها داخلی {#internal_dicts} + +ClickHouse شامل ساخته شده است در ویژگی برای کار با یک geobase. + +این اجازه می دهد تا شما را به: + +- استفاده از شناسه یک منطقه به نام خود را در زبان مورد نظر. +- استفاده از یک منطقه شناسه برای دریافت شناسه شهر منطقه فدرال منطقه کشور یا قاره. +- بررسی کنید که یک منطقه بخشی از یک منطقه دیگر است. +- دریافت زنجیره ای از مناطق پدر و مادر. + +تمام توابع پشتیبانی “translocality,” توانایی به طور همزمان استفاده از دیدگاه های مختلف در مالکیت منطقه. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “Functions for working with Yandex.Metrica dictionaries”. + +واژهنامهها داخلی در بسته به طور پیش فرض غیر فعال. +برای فعال کردن پارامترها `path_to_regions_hierarchy_file` و `path_to_regions_names_files` در فایل پیکربندی سرور. + +پایگاه داده از فایل های متنی لود می شود. + +محل `regions_hierarchy*.txt` فایل ها به `path_to_regions_hierarchy_file` فهرست راهنما. این پارامتر پیکربندی باید مسیر را به `regions_hierarchy.txt` فایل (سلسله مراتب منطقه ای پیش فرض) و فایل های دیگر (`regions_hierarchy_ua.txt`) باید در همان دایرکتوری واقع شده است. + +قرار دادن `regions_names_*.txt` فایل ها در `path_to_regions_names_files` فهرست راهنما. + +شما همچنین می توانید این فایل ها خود را ایجاد کنید. فرمت فایل به شرح زیر است: + +`regions_hierarchy*.txt`: ستون (بدون هدر): + +- شناسه منطقه (`UInt32`) +- شناسه منطقه والد (`UInt32`) +- نوع منطقه (`UInt8`): 1 - قاره, 3 - کشور, 4 - منطقه فدرال, 5 - منطقه, 6-شهرستان; انواع دیگر ارزش ندارد +- جمعیت (`UInt32`) — optional column + +`regions_names_*.txt`: ستون (بدون هدر): + +- شناسه منطقه (`UInt32`) +- نام منطقه (`String`) — Can't contain tabs or line feeds, even escaped ones. + +مجموعه تخت برای ذخیره سازی در رم استفاده می شود. به همین دلیل شناسه نباید بیش از یک میلیون. + +واژهنامهها را می توان بدون راه اندازی مجدد سرور به روز شد. با این حال, مجموعه ای از لغت نامه های موجود به روز نمی. +برای به روز رسانی بار اصلاح فایل بررسی می شود. اگر یک فایل تغییر کرده است, فرهنگ لغت به روز شده است. +فاصله برای بررسی تغییرات در پیکربندی `builtin_dictionaries_reload_interval` پارامتر. +به روز رسانی فرهنگ لغت (به غیر از بارگذاری در اولین استفاده) نمایش داده شد را مسدود کند. در طول به روز رسانی, نمایش داده شد با استفاده از نسخه های قدیمی از لغت نامه. اگر یک خطا در طول به روز رسانی رخ می دهد, خطا به ورود به سیستم سرور نوشته شده, و نمایش داده شد ادامه استفاده از نسخه های قدیمی از لغت نامه. + +ما توصیه می کنیم دوره به روز رسانی لغت نامه با پایگاه داده. در طول به روز رسانی, تولید فایل های جدید و ارسال به یک مکان جداگانه. وقتی همه چیز اماده است فایل های مورد استفاده توسط سرور را تغییر دهید. + +همچنین توابع برای کار با شناسه های سیستم عامل و یاندکس وجود دارد.موتورهای جستجو متریکا, اما نباید استفاده شود. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/fa/sql-reference/functions/arithmetic-functions.md b/docs/fa/sql-reference/functions/arithmetic-functions.md new file mode 100644 index 00000000000..be1fa3497c8 --- /dev/null +++ b/docs/fa/sql-reference/functions/arithmetic-functions.md @@ -0,0 +1,87 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: "\u062D\u0633\u0627\u0628" +--- + +# توابع ریاضی {#arithmetic-functions} + +برای تمام توابع ریاضی, نوع نتیجه به عنوان کوچکترین نوع شماره که در نتیجه متناسب با محاسبه, اگر چنین نوع وجود دارد. حداقل به طور همزمان بر اساس تعداد بیت ها امضا شده است یا شناور است. اگر بیت به اندازه کافی وجود ندارد, بالاترین نوع بیت گرفته شده است. + +مثال: + +``` sql +SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) +``` + +``` text +┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ +│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ +└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ +``` + +حساب توابع کار برای هر جفت از انواع از UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32 یا Float64. + +سرریز به همان شیوه که در ج تولید++. + +## به علاوه (یک, ب), + اپراتور ب {#plusa-b-a-b-operator} + +محاسبه مجموع اعداد. +شما همچنین می توانید اعداد صحیح را با یک تاریخ یا تاریخ و زمان اضافه کنید. در مورد یک تاریخ, اضافه کردن یک عدد صحیح به معنی اضافه کردن تعداد مربوط به روز. برای تاریخ با زمان, به این معنی اضافه کردن شماره مربوطه را از ثانیه. + +## منفی (یک, ب), اپراتور الف ب {#minusa-b-a-b-operator} + +محاسبه تفاوت. نتیجه همیشه امضا شده است. + +You can also calculate integer numbers from a date or date with time. The idea is the same – see above for ‘plus’. + +## ضرب (ب) اپراتور \* ب {#multiplya-b-a-b-operator} + +محاسبه محصول از اعداد. + +## تقسیم کردن (یک, ب), یک / اپراتور ب {#dividea-b-a-b-operator} + +محاسبه خارج قسمت از اعداد. نوع نتیجه همیشه یک نوع شناور است. +این تقسیم عدد صحیح نیست. برای تقسیم عدد صحیح, استفاده از ‘intDiv’ تابع. +هنگامی که تقسیم بر صفر می کنید ‘inf’, ‘-inf’ یا ‘nan’. + +## اینترنت) {#intdiva-b} + +محاسبه خارج قسمت از اعداد. تقسیم به اعداد صحیح, گرد کردن پایین (با ارزش مطلق). +یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. + +## intDivOrZero(a, b) {#intdivorzeroa-b} + +متفاوت از ‘intDiv’ در این بازده صفر در هنگام تقسیم صفر و یا زمانی که تقسیم یک عدد منفی حداقل منهای یک. + +## مودولو (و, ب), یک % اپراتور ب {#moduloa-b-a-b-operator} + +محاسبه باقی مانده پس از تقسیم. +اگر استدلال اعداد ممیز شناور هستند قبل از تبدیل به اعداد صحیح با حذف بخش اعشاری هستند. +باقی مانده است به همان معنا که در ج گرفته++. تقسیم کوتاه برای اعداد منفی استفاده می شود. +یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. + +## moduloOrZero(a, b) {#moduloorzeroa-b} + +متفاوت از ‘modulo’ در که باز می گردد صفر زمانی که مقسوم علیه صفر است. + +## نفی (),- اپراتور {#negatea-a-operator} + +محاسبه یک عدد با علامت معکوس. نتیجه همیشه امضا شده است. + +## شکم(یک) {#arithm_func-abs} + +محاسبه ارزش مطلق تعداد (). به این معنا که, اگر یک \< 0, باز می گردد یک. برای انواع عدد صحیح امضا, این برمی گرداند یک عدد بدون علامت. + +## گسیدی(یک, ب) {#gcda-b} + +بازگرداندن بزرگترین مقسوم علیه مشترک از اعداد. +یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. + +## اندازه) {#lcma-b} + +بازگرداندن چند حداقل مشترک از اعداد. +یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/fa/sql-reference/functions/array-functions.md b/docs/fa/sql-reference/functions/array-functions.md new file mode 100644 index 00000000000..1988ed4266e --- /dev/null +++ b/docs/fa/sql-reference/functions/array-functions.md @@ -0,0 +1,1061 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0627\u0631\u0631\u06CC\u0633" +--- + +# توابع برای کار با ارریس {#functions-for-working-with-arrays} + +## خالی {#function-empty} + +بازده 1 برای یک مجموعه خالی, یا 0 برای یک مجموعه غیر خالی. +نتیجه این نوع UInt8. +این تابع نیز برای رشته کار می کند. + +## notEmpty {#function-notempty} + +بازده 0 برای یک مجموعه خالی, یا 1 برای یک مجموعه غیر خالی. +نتیجه این نوع UInt8. +این تابع نیز برای رشته کار می کند. + +## طول {#array_functions-length} + +بازگرداندن تعداد اقلام در مجموعه. +نتیجه این نوع UInt64. +این تابع نیز برای رشته کار می کند. + +## emptyArrayUInt8, emptyArrayUInt16, emptyArrayUInt32, emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} + +## emptyArrayInt8, emptyArrayInt16, emptyArrayInt32, emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} + +## emptyArrayFloat32, emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} + +## emptyArrayDate, emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} + +## تخت خواب {#emptyarraystring} + +قبول صفر استدلال و مجموعه ای خالی از نوع مناسب را برمی گرداند. + +## خالی {#emptyarraytosingle} + +یک مجموعه خالی را می پذیرد و یک مجموعه یک عنصر را که برابر با مقدار پیش فرض است باز می گرداند. + +## محدوده( پایان), دامنه (شروع, پایان \[, گام\]) {#rangeend-rangestart-end-step} + +بازگرداندن مجموعه ای از اعداد از ابتدا تا انتها-1 به گام. +اگر استدلال `start` مشخص نشده است, به طور پیش فرض به 0. +اگر استدلال `step` مشخص نشده است, به طور پیش فرض به 1. +این رفتار تقریبا مانند پیتون `range`. اما تفاوت این است که همه نوع استدلال باید باشد `UInt` اعداد. +فقط در مورد, یک استثنا پرتاب می شود اگر ارریس با طول کل بیش از 100,000,000 عناصر در یک بلوک داده ها ایجاد. + +## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} + +ایجاد مجموعه ای از استدلال تابع. +استدلال باید ثابت باشد و انواع که کوچکترین نوع رایج. حداقل یک استدلال باید تصویب شود, چرا که در غیر این صورت مشخص نیست که چه نوع از مجموعه ای برای ایجاد. به این معنا که شما نمی توانید از این تابع برای ایجاد یک مجموعه خالی استفاده کنید (برای انجام این کار از ‘emptyArray\*’ تابع در بالا توضیح داده شد). +بازگشت یک ‘Array(T)’ نوع نتیجه, جایی که ‘T’ کوچکترین نوع رایج از استدلال گذشت. + +## موافقم {#arrayconcat} + +ترکیبی از ارریس به عنوان استدلال گذشت. + +``` sql +arrayConcat(arrays) +``` + +**پارامترها** + +- `arrays` – Arbitrary number of arguments of [& حذف](../../sql-reference/data-types/array.md) نوع. + **مثال** + + + +``` sql +SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res +``` + +``` text +┌─res───────────┐ +│ [1,2,3,4,5,6] │ +└───────────────┘ +``` + +## هشدار داده می شود\] {#arrayelementarr-n-operator-arrn} + +عنصر را با شاخص دریافت کنید `n` از مجموعه `arr`. `n` باید هر نوع عدد صحیح باشد. +شاخص ها در مجموعه ای از یک شروع می شوند. +شاخص های منفی پشتیبانی می شوند. در این مورد, این انتخاب عنصر مربوطه شماره از پایان. به عنوان مثال, `arr[-1]` اخرین وسیله ست + +اگر شاخص می افتد در خارج از مرزهای مجموعه, این گرداند برخی از مقدار پیش فرض (0 برای اعداد, یک رشته خالی برای رشته, و غیره.), به جز برای مورد با یک مجموعه غیر ثابت و یک شاخص ثابت 0 (در این مورد وجود خواهد داشت یک خطا `Array indices are 1-based`). + +## است (ورود, علم) {#hasarr-elem} + +بررسی اینکه ‘arr’ اری ‘elem’ عنصر. +بازده 0 اگر عنصر در مجموعه نیست, یا 1 اگر. + +`NULL` به عنوان یک ارزش پردازش شده است. + +``` sql +SELECT has([1, 2, NULL], NULL) +``` + +``` text +┌─has([1, 2, NULL], NULL)─┐ +│ 1 │ +└─────────────────────────┘ +``` + +## حصال {#hasall} + +بررسی اینکه یک مجموعه زیر مجموعه دیگری باشد. + +``` sql +hasAll(set, subset) +``` + +**پارامترها** + +- `set` – Array of any type with a set of elements. +- `subset` – Array of any type with elements that should be tested to be a subset of `set`. + +**مقادیر بازگشتی** + +- `1` اگر `set` شامل تمام عناصر از `subset`. +- `0` وگرنه + +**خواص عجیب و غریب** + +- مجموعه خالی زیر مجموعه ای از هر است. +- `Null` پردازش به عنوان یک ارزش. +- منظور از ارزش ها در هر دو ارریس مهم نیست. + +**مثالها** + +`SELECT hasAll([], [])` بازده 1. + +`SELECT hasAll([1, Null], [Null])` بازده 1. + +`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` بازده 1. + +`SELECT hasAll(['a', 'b'], ['a'])` بازده 1. + +`SELECT hasAll([1], ['a'])` بازده 0. + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` بازده 0. + +## hasAny {#hasany} + +بررسی اینکه دو بند چهار راه توسط برخی از عناصر. + +``` sql +hasAny(array1, array2) +``` + +**پارامترها** + +- `array1` – Array of any type with a set of elements. +- `array2` – Array of any type with a set of elements. + +**مقادیر بازگشتی** + +- `1` اگر `array1` و `array2` حداقل یک عنصر مشابه داشته باشید. +- `0` وگرنه + +**خواص عجیب و غریب** + +- `Null` پردازش به عنوان یک ارزش. +- منظور از ارزش ها در هر دو ارریس مهم نیست. + +**مثالها** + +`SELECT hasAny([1], [])` بازگشت `0`. + +`SELECT hasAny([Null], [Null, 1])` بازگشت `1`. + +`SELECT hasAny([-128, 1., 512], [1])` بازگشت `1`. + +`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` بازگشت `0`. + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` بازگشت `1`. + +## هشدار داده می شود) {#indexofarr-x} + +بازگرداندن شاخص از اولین ‘x’ عنصر (با شروع از 1) اگر در مجموعه ای است, یا 0 اگر نیست. + +مثال: + +``` sql +SELECT indexOf([1, 3, NULL, NULL], NULL) +``` + +``` text +┌─indexOf([1, 3, NULL, NULL], NULL)─┐ +│ 3 │ +└───────────────────────────────────┘ +``` + +عناصر را به `NULL` به عنوان مقادیر طبیعی انجام می شود. + +## هشدار داده می شود) {#countequalarr-x} + +بازده تعداد عناصر موجود در آرایه برابر با x. معادل arrayCount (elem -\> elem = x arr). + +`NULL` عناصر به عنوان مقادیر جداگانه به کار گرفته. + +مثال: + +``` sql +SELECT countEqual([1, 2, NULL, NULL], NULL) +``` + +``` text +┌─countEqual([1, 2, NULL, NULL], NULL)─┐ +│ 2 │ +└──────────────────────────────────────┘ +``` + +## هشدار داده می شود) {#array_functions-arrayenumerate} + +Returns the array \[1, 2, 3, …, length (arr) \] + +این تابع به طور معمول با مجموعه ای استفاده می شود. این اجازه می دهد شمارش چیزی فقط یک بار برای هر مجموعه پس از استفاده از مجموعه پیوستن. مثال: + +``` sql +SELECT + count() AS Reaches, + countIf(num = 1) AS Hits +FROM test.hits +ARRAY JOIN + GoalsReached, + arrayEnumerate(GoalsReached) AS num +WHERE CounterID = 160656 +LIMIT 10 +``` + +``` text +┌─Reaches─┬──Hits─┐ +│ 95606 │ 31406 │ +└─────────┴───────┘ +``` + +در این مثال, می رسد تعداد تبدیل است (رشته دریافت پس از استفاده از مجموعه ملحق), و بازدید تعداد بازدید صفحات (رشته قبل از مجموعه ملحق). در این مورد خاص شما می توانید همان نتیجه را در یک راه ساده تر: + +``` sql +SELECT + sum(length(GoalsReached)) AS Reaches, + count() AS Hits +FROM test.hits +WHERE (CounterID = 160656) AND notEmpty(GoalsReached) +``` + +``` text +┌─Reaches─┬──Hits─┐ +│ 95606 │ 31406 │ +└─────────┴───────┘ +``` + +این تابع همچنین می توانید در توابع مرتبه بالاتر استفاده می شود. برای مثال می توانید از شاخص های مجموعه ای برای عناصری که با شرایط مطابقت دارند استفاده کنید. + +## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} + +بازگرداندن مجموعه ای به همان اندازه به عنوان مجموعه منبع, نشان می دهد برای هر عنصر چه موقعیت خود را در میان عناصر با همان مقدار. +به عنوان مثال: ارریینومراتونیک(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. + +این تابع در هنگام استفاده از مجموعه ای پیوستن و تجمع عناصر مجموعه ای مفید است. +مثال: + +``` sql +SELECT + Goals.ID AS GoalID, + sum(Sign) AS Reaches, + sumIf(Sign, num = 1) AS Visits +FROM test.visits +ARRAY JOIN + Goals, + arrayEnumerateUniq(Goals.ID) AS num +WHERE CounterID = 160656 +GROUP BY GoalID +ORDER BY Reaches DESC +LIMIT 10 +``` + +``` text +┌──GoalID─┬─Reaches─┬─Visits─┐ +│ 53225 │ 3214 │ 1097 │ +│ 2825062 │ 3188 │ 1097 │ +│ 56600 │ 2803 │ 488 │ +│ 1989037 │ 2401 │ 365 │ +│ 2830064 │ 2396 │ 910 │ +│ 1113562 │ 2372 │ 373 │ +│ 3270895 │ 2262 │ 812 │ +│ 1084657 │ 2262 │ 345 │ +│ 56599 │ 2260 │ 799 │ +│ 3271094 │ 2256 │ 812 │ +└─────────┴─────────┴────────┘ +``` + +در این مثال هر هدف شناسه محاسبه تعداد تبدیل (هر عنصر در اهداف تو در تو ساختار داده ها یک هدف است که رسیده بود که ما اشاره به عنوان یک تبدیل) و تعداد جلسات. بدون مجموعه ملحق, ما می خواهیم تعداد جلسات به عنوان مجموع شمارش (امضا کردن). اما در این مورد خاص ردیف شد ضرب در تو در تو در اهداف و ساختار آن در سفارش به تعداد هر جلسه یک بار بعد از این ما اعمال یک شرط به ارزش arrayEnumerateUniq(اهداف است.ID) تابع. + +تابع ارریینومراتونیک می تواند چندین بار از همان اندازه به عنوان استدلال استفاده کند. در این مورد, منحصر به فرد است برای تاپل از عناصر در موقعیت های مشابه در تمام ارریس در نظر گرفته. + +``` sql +SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res +``` + +``` text +┌─res───────────┐ +│ [1,2,1,1,2,1] │ +└───────────────┘ +``` + +این در هنگام استفاده از مجموعه با یک ساختار داده های تو در تو و تجمع بیشتر در سراسر عناصر متعدد در این ساختار ملحق لازم است. + +## عقبگرد {#arraypopback} + +حذف مورد گذشته از مجموعه. + +``` sql +arrayPopBack(array) +``` + +**پارامترها** + +- `array` – Array. + +**مثال** + +``` sql +SELECT arrayPopBack([1, 2, 3]) AS res +``` + +``` text +┌─res───┐ +│ [1,2] │ +└───────┘ +``` + +## ساحل {#arraypopfront} + +اولین مورد را از مجموعه حذف می کند. + +``` sql +arrayPopFront(array) +``` + +**پارامترها** + +- `array` – Array. + +**مثال** + +``` sql +SELECT arrayPopFront([1, 2, 3]) AS res +``` + +``` text +┌─res───┐ +│ [2,3] │ +└───────┘ +``` + +## عقب نشینی {#arraypushback} + +یک مورد را به انتهای مجموعه اضافه می کند. + +``` sql +arrayPushBack(array, single_value) +``` + +**پارامترها** + +- `array` – Array. +- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` نوع داده مجموعه را تایپ کنید. برای کسب اطلاعات بیشتر در مورد انواع داده ها در خانه کلیک کنید “[انواع داده ها](../../sql-reference/data-types/index.md#data_types)”. می تواند باشد `NULL`. تابع می افزاید: `NULL` عنصر به مجموعه ای, و نوع عناصر مجموعه ای تبدیل به `Nullable`. + +**مثال** + +``` sql +SELECT arrayPushBack(['a'], 'b') AS res +``` + +``` text +┌─res───────┐ +│ ['a','b'] │ +└───────────┘ +``` + +## ساحلی {#arraypushfront} + +یک عنصر را به ابتدای مجموعه اضافه می کند. + +``` sql +arrayPushFront(array, single_value) +``` + +**پارامترها** + +- `array` – Array. +- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` نوع داده مجموعه را تایپ کنید. برای کسب اطلاعات بیشتر در مورد انواع داده ها در خانه کلیک کنید “[انواع داده ها](../../sql-reference/data-types/index.md#data_types)”. می تواند باشد `NULL`. تابع می افزاید: `NULL` عنصر به مجموعه ای, و نوع عناصر مجموعه ای تبدیل به `Nullable`. + +**مثال** + +``` sql +SELECT arrayPushFront(['b'], 'a') AS res +``` + +``` text +┌─res───────┐ +│ ['a','b'] │ +└───────────┘ +``` + +## نمایش سایت {#arrayresize} + +طول مجموعه را تغییر می دهد. + +``` sql +arrayResize(array, size[, extender]) +``` + +**پارامترها:** + +- `array` — Array. +- `size` — Required length of the array. + - اگر `size` کمتر از اندازه اصلی مجموعه است, مجموعه ای از سمت راست کوتاه. +- اگر `size` مجموعه بزرگتر از اندازه اولیه مجموعه است که به سمت راست گسترش می یابد `extender` مقادیر یا مقادیر پیش فرض برای نوع داده از موارد مجموعه. +- `extender` — Value for extending an array. Can be `NULL`. + +**مقدار بازگشتی:** + +مجموعه ای از طول `size`. + +**نمونه هایی از تماس** + +``` sql +SELECT arrayResize([1], 3) +``` + +``` text +┌─arrayResize([1], 3)─┐ +│ [1,0,0] │ +└─────────────────────┘ +``` + +``` sql +SELECT arrayResize([1], 3, NULL) +``` + +``` text +┌─arrayResize([1], 3, NULL)─┐ +│ [1,NULL,NULL] │ +└───────────────────────────┘ +``` + +## بند {#arrayslice} + +یک تکه از مجموعه را برمی گرداند. + +``` sql +arraySlice(array, offset[, length]) +``` + +**پارامترها** + +- `array` – Array of data. +- `offset` – Indent from the edge of the array. A positive value indicates an offset on the left, and a negative value is an indent on the right. Numbering of the array items begins with 1. +- `length` - طول قطعه مورد نیاز . اگر شما یک مقدار منفی مشخص, تابع یک تکه باز می گرداند `[offset, array_length - length)`. اگر شما حذف ارزش, تابع برش می گرداند `[offset, the_end_of_array]`. + +**مثال** + +``` sql +SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res +``` + +``` text +┌─res────────┐ +│ [2,NULL,4] │ +└────────────┘ +``` + +عناصر مجموعه ای به `NULL` به عنوان مقادیر طبیعی انجام می شود. + +## arraySort(\[func,\] arr, …) {#array_functions-sort} + +عناصر را مرتب می کند `arr` صف در صعودی. اگر `func` تابع مشخص شده است, مرتب سازی سفارش توسط نتیجه تعیین `func` تابع اعمال شده به عناصر مجموعه. اگر `func` قبول استدلال های متعدد `arraySort` تابع به تصویب می رسد چند بند که استدلال `func` خواهد به مطابقت. نمونه های دقیق در پایان نشان داده شده است `arraySort` توصیف. + +نمونه ای از مقادیر صحیح مرتب سازی: + +``` sql +SELECT arraySort([1, 3, 3, 0]); +``` + +``` text +┌─arraySort([1, 3, 3, 0])─┐ +│ [0,1,3,3] │ +└─────────────────────────┘ +``` + +نمونه ای از مقادیر رشته مرتب سازی: + +``` sql +SELECT arraySort(['hello', 'world', '!']); +``` + +``` text +┌─arraySort(['hello', 'world', '!'])─┐ +│ ['!','hello','world'] │ +└────────────────────────────────────┘ +``` + +ترتیب مرتب سازی زیر را برای `NULL`, `NaN` و `Inf` مقادیر: + +``` sql +SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); +``` + +``` text +┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ +│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────────────────────────┘ +``` + +- `-Inf` مقادیر برای اولین بار در مجموعه هستند. +- `NULL` ارزشهای خبری عبارتند از: +- `NaN` مقادیر درست قبل هستند `NULL`. +- `Inf` مقادیر درست قبل هستند `NaN`. + +توجه داشته باشید که `arraySort` یک [عملکرد عالی مرتبه](higher-order-functions.md). شما می توانید یک تابع لامبدا را به عنوان اولین استدلال منتقل کنید. در این مورد ترتیب مرتب سازی بر اساس نتیجه تابع لامبدا اعمال شده به عناصر مجموعه تعیین می شود. + +بیایید مثال زیر را در نظر بگیریم: + +``` sql +SELECT arraySort((x) -> -x, [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [3,2,1] │ +└─────────┘ +``` + +For each element of the source array, the lambda function returns the sorting key, that is, \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Since the `arraySort` تابع انواع کلید به ترتیب صعودی, نتیجه این است \[3, 2, 1\]. بنابراین `(x) –> -x` عملکرد لامبدا مجموعه [ترتیب نزولی](#array_functions-reverse-sort) در یک مرتب سازی. + +تابع لامبدا می تواند استدلال های متعدد را قبول کند. در این مورد, شما نیاز به تصویب `arraySort` تابع چند بند از طول یکسان است که استدلال تابع لامبدا به مطابقت. مجموعه حاصل از عناصر از اولین مجموعه ورودی تشکیل شده است. به عنوان مثال: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res────────────────┐ +│ ['world', 'hello'] │ +└────────────────────┘ +``` + +در اینجا عناصر موجود در مجموعه دوم (\[2, 1\]) تعریف یک کلید مرتب سازی برای عنصر مربوطه از مجموعه منبع (\[‘hello’, ‘world’\]), به این معنا که, \[‘hello’ –\> 2, ‘world’ –\> 1\]. Since the lambda function doesn't use `x` مقادیر واقعی مجموعه منبع بر نظم در نتیجه تاثیر نمی گذارد. پس, ‘hello’ خواهد بود که عنصر دوم در نتیجه, و ‘world’ خواهد بود که برای اولین بار. + +نمونه های دیگر در زیر نشان داده شده. + +``` sql +SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; +``` + +``` text +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +``` sql +SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +!!! note "یادداشت" + برای بهبود کارایی مرتب سازی [تبدیل شوارتز](https://en.wikipedia.org/wiki/Schwartzian_transform) استفاده شده است. + +## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} + +عناصر را مرتب می کند `arr` صف در نزولی. اگر `func` تابع مشخص شده است, `arr` بر اساس نتیجه طبقه بندی شده اند `func` عملکرد به عناصر مجموعه اعمال می شود و سپس مجموعه مرتب شده معکوس می شود. اگر `func` قبول استدلال های متعدد `arrayReverseSort` تابع به تصویب می رسد چند بند که استدلال `func` خواهد به مطابقت. نمونه های دقیق در پایان نشان داده شده است `arrayReverseSort` توصیف. + +نمونه ای از مقادیر صحیح مرتب سازی: + +``` sql +SELECT arrayReverseSort([1, 3, 3, 0]); +``` + +``` text +┌─arrayReverseSort([1, 3, 3, 0])─┐ +│ [3,3,1,0] │ +└────────────────────────────────┘ +``` + +نمونه ای از مقادیر رشته مرتب سازی: + +``` sql +SELECT arrayReverseSort(['hello', 'world', '!']); +``` + +``` text +┌─arrayReverseSort(['hello', 'world', '!'])─┐ +│ ['world','hello','!'] │ +└───────────────────────────────────────────┘ +``` + +ترتیب مرتب سازی زیر را برای `NULL`, `NaN` و `Inf` مقادیر: + +``` sql +SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; +``` + +``` text +┌─res───────────────────────────────────┐ +│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────┘ +``` + +- `Inf` مقادیر برای اولین بار در مجموعه هستند. +- `NULL` ارزشهای خبری عبارتند از: +- `NaN` مقادیر درست قبل هستند `NULL`. +- `-Inf` مقادیر درست قبل هستند `NaN`. + +توجه داشته باشید که `arrayReverseSort` یک [عملکرد عالی مرتبه](higher-order-functions.md). شما می توانید یک تابع لامبدا را به عنوان اولین استدلال منتقل کنید. مثال زیر نشان داده شده. + +``` sql +SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [1,2,3] │ +└─────────┘ +``` + +این مجموعه به روش زیر مرتب شده است: + +1. ابتدا مجموعه منبع (\[1, 2, 3\]) با توجه به نتیجه تابع لامبدا اعمال شده به عناصر مجموعه طبقه بندی شده اند. نتیجه یک مجموعه است \[3, 2, 1\]. +2. مجموعه ای است که در مرحله قبل به دست, معکوس شده است. بنابراین, نتیجه نهایی است \[1, 2, 3\]. + +تابع لامبدا می تواند استدلال های متعدد را قبول کند. در این مورد, شما نیاز به تصویب `arrayReverseSort` تابع چند بند از طول یکسان است که استدلال تابع لامبدا به مطابقت. مجموعه حاصل از عناصر از اولین مجموعه ورودی تشکیل شده است. به عنوان مثال: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +در این مثال مجموعه به روش زیر مرتب شده است: + +1. در ابتدا مجموعه منبع (\[‘hello’, ‘world’\]) با توجه به نتیجه تابع لامبدا اعمال شده به عناصر از ارریس طبقه بندی شده اند. عناصر که در مجموعه دوم به تصویب رسید (\[2, 1\]), تعریف کلید مرتب سازی برای عناصر مربوطه را از مجموعه منبع. نتیجه یک مجموعه است \[‘world’, ‘hello’\]. +2. مجموعه ای که در مرحله قبل طبقه بندی شده اند, معکوس شده است. بنابراین نتیجه نهایی این است \[‘hello’, ‘world’\]. + +نمونه های دیگر در زیر نشان داده شده. + +``` sql +SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; +``` + +``` text +┌─res─────┐ +│ [5,3,4] │ +└─────────┘ +``` + +``` sql +SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; +``` + +``` text +┌─res─────┐ +│ [4,3,5] │ +└─────────┘ +``` + +## arrayUniq(arr, …) {#arrayuniqarr} + +اگر یک استدلال به تصویب می رسد, تعداد عناصر مختلف در مجموعه شمارش. +اگر استدلال های متعدد به تصویب می رسد, شمارش تعداد تاپل های مختلف از عناصر در موقعیت های مربوطه در مجموعه های متعدد. + +اگر شما می خواهید برای دریافت یک لیست از اقلام منحصر به فرد در مجموعه, شما می توانید از ارری راهاهن استفاده(‘groupUniqArray’, arr). + +## هشدار داده می شود) {#array-functions-join} + +یک تابع خاص. بخش را ببینید [“ArrayJoin function”](array-join.md#functions_arrayjoin). + +## کلیدواژه {#arraydifference} + +محاسبه تفاوت بین عناصر مجموعه مجاور. بازگرداندن مجموعه ای که عنصر اول خواهد بود 0, دوم تفاوت بین است `a[1] - a[0]`, etc. The type of elements in the resulting array is determined by the type inference rules for subtraction (e.g. `UInt8` - `UInt8` = `Int16`). + +**نحو** + +``` sql +arrayDifference(array) +``` + +**پارامترها** + +- `array` – [& حذف](https://clickhouse.yandex/docs/en/data_types/array/). + +**مقادیر بازگشتی** + +بازگرداندن مجموعه ای از تفاوت بین عناصر مجاور. + +نوع: [اینترنت\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#uint-ranges), [Int\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#int-ranges), [شناور\*](https://clickhouse.yandex/docs/en/data_types/float/). + +**مثال** + +پرسوجو: + +``` sql +SELECT arrayDifference([1, 2, 3, 4]) +``` + +نتیجه: + +``` text +┌─arrayDifference([1, 2, 3, 4])─┐ +│ [0,1,1,1] │ +└───────────────────────────────┘ +``` + +مثال سرریز به علت نوع نتیجه اینترن64: + +پرسوجو: + +``` sql +SELECT arrayDifference([0, 10000000000000000000]) +``` + +نتیجه: + +``` text +┌─arrayDifference([0, 10000000000000000000])─┐ +│ [0,-8446744073709551616] │ +└────────────────────────────────────────────┘ +``` + +## حوزه ارریددیست {#arraydistinct} + +مجموعه ای را می گیرد و تنها شامل عناصر مجزا می شود. + +**نحو** + +``` sql +arrayDistinct(array) +``` + +**پارامترها** + +- `array` – [& حذف](https://clickhouse.yandex/docs/en/data_types/array/). + +**مقادیر بازگشتی** + +بازگرداندن مجموعه ای حاوی عناصر متمایز. + +**مثال** + +پرسوجو: + +``` sql +SELECT arrayDistinct([1, 2, 2, 3, 1]) +``` + +نتیجه: + +``` text +┌─arrayDistinct([1, 2, 2, 3, 1])─┐ +│ [1,2,3] │ +└────────────────────────────────┘ +``` + +## هشدار داده می شود) {#array_functions-arrayenumeratedense} + +بازگرداندن مجموعه ای از همان اندازه به عنوان مجموعه منبع, نشان می دهد که هر عنصر برای اولین بار در مجموعه منبع به نظر می رسد. + +مثال: + +``` sql +SELECT arrayEnumerateDense([10, 20, 10, 30]) +``` + +``` text +┌─arrayEnumerateDense([10, 20, 10, 30])─┐ +│ [1,2,1,3] │ +└───────────────────────────────────────┘ +``` + +## هشدار داده می شود) {#array-functions-arrayintersect} + +طول می کشد مجموعه ای با عناصر که در تمام مجموعه منبع در حال حاضر می گرداند. عناصر سفارش در مجموعه حاصل همان است که در مجموعه اول است. + +مثال: + +``` sql +SELECT + arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, + arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect +``` + +``` text +┌─no_intersect─┬─intersect─┐ +│ [] │ [1] │ +└──────────────┴───────────┘ +``` + +## نمایش سایت {#arrayreduce} + +یک تابع کلی برای عناصر مجموعه ای اعمال می شود و نتیجه خود را باز می گرداند. نام تابع تجمع به عنوان یک رشته در نقل قول های تک منتقل می شود `'max'`, `'sum'`. هنگام استفاده از توابع دانه پارامتری پارامتر پس از نام تابع در پرانتز نشان داده شده است `'uniqUpTo(6)'`. + +**نحو** + +``` sql +arrayReduce(agg_func, arr1, arr2, ..., arrN) +``` + +**پارامترها** + +- `agg_func` — The name of an aggregate function which should be a constant [رشته](../../sql-reference/data-types/string.md). +- `arr` — Any number of [& حذف](../../sql-reference/data-types/array.md) نوع ستون به عنوان پارامترهای تابع تجمع. + +**مقدار بازگشتی** + +**مثال** + +``` sql +SELECT arrayReduce('max', [1, 2, 3]) +``` + +``` text +┌─arrayReduce('max', [1, 2, 3])─┐ +│ 3 │ +└───────────────────────────────┘ +``` + +اگر یک تابع جمع استدلال های متعدد طول می کشد, سپس این تابع باید به مجموعه های متعدد از همان اندازه اعمال. + +``` sql +SELECT arrayReduce('maxIf', [3, 5], [1, 0]) +``` + +``` text +┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ +│ 3 │ +└──────────────────────────────────────┘ +``` + +به عنوان مثال با یک تابع جمع پارامتری: + +``` sql +SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) +``` + +``` text +┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ +│ 4 │ +└─────────────────────────────────────────────────────────────┘ +``` + +## تغییرات {#arrayreduceinranges} + +یک تابع کلی برای عناصر مجموعه ای در محدوده های داده شده اعمال می شود و مجموعه ای حاوی نتیجه مربوط به هر محدوده را باز می گرداند. تابع همان نتیجه به عنوان چند بازگشت `arrayReduce(agg_func, arraySlice(arr1, index, length), ...)`. + +**نحو** + +``` sql +arrayReduceInRanges(agg_func, ranges, arr1, arr2, ..., arrN) +``` + +**پارامترها** + +- `agg_func` — The name of an aggregate function which should be a constant [رشته](../../sql-reference/data-types/string.md). +- `ranges` — The ranges to aggretate which should be an [& حذف](../../sql-reference/data-types/array.md) از [توپلس](../../sql-reference/data-types/tuple.md) که شامل شاخص و طول هر محدوده. +- `arr` — Any number of [& حذف](../../sql-reference/data-types/array.md) نوع ستون به عنوان پارامترهای تابع تجمع. + +**مقدار بازگشتی** + +**مثال** + +``` sql +SELECT arrayReduceInRanges( + 'sum', + [(1, 5), (2, 3), (3, 4), (4, 4)], + [1000000, 200000, 30000, 4000, 500, 60, 7] +) AS res +``` + +``` text +┌─res─────────────────────────┐ +│ [1234500,234000,34560,4567] │ +└─────────────────────────────┘ +``` + +## هشدار داده می شود) {#arrayreverse} + +بازگرداندن مجموعه ای از همان اندازه به عنوان مجموعه اصلی حاوی عناصر در جهت معکوس. + +مثال: + +``` sql +SELECT arrayReverse([1, 2, 3]) +``` + +``` text +┌─arrayReverse([1, 2, 3])─┐ +│ [3,2,1] │ +└─────────────────────────┘ +``` + +## معکوس) {#array-functions-reverse} + +مترادف برای [“arrayReverse”](#arrayreverse) + +## ارریفلاتتن {#arrayflatten} + +مجموعه ای از ارریس ها را به یک مجموعه صاف تبدیل می کند. + +تابع: + +- امر به هر عمق مجموعه های تو در تو. +- طعم هایی را که در حال حاضر مسطح هستند تغییر نمی دهد. + +مجموعه مسطح شامل تمام عناصر از تمام منابع است. + +**نحو** + +``` sql +flatten(array_of_arrays) +``` + +نام مستعار: `flatten`. + +**پارامترها** + +- `array_of_arrays` — [& حذف](../../sql-reference/data-types/array.md) ارریس به عنوان مثال, `[[1,2,3], [4,5]]`. + +**مثالها** + +``` sql +SELECT flatten([[[1]], [[2], [3]]]) +``` + +``` text +┌─flatten(array(array([1]), array([2], [3])))─┐ +│ [1,2,3] │ +└─────────────────────────────────────────────┘ +``` + +## اررایکمپکت {#arraycompact} + +عناصر تکراری متوالی را از یک مجموعه حذف می کند. ترتیب مقادیر نتیجه به ترتیب در مجموعه منبع تعیین می شود. + +**نحو** + +``` sql +arrayCompact(arr) +``` + +**پارامترها** + +`arr` — The [& حذف](../../sql-reference/data-types/array.md) برای بازرسی. + +**مقدار بازگشتی** + +مجموعه ای بدون تکراری. + +نوع: `Array`. + +**مثال** + +پرسوجو: + +``` sql +SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) +``` + +نتیجه: + +``` text +┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ +│ [1,nan,nan,2,3] │ +└────────────────────────────────────────────┘ +``` + +## ارریزیپ {#arrayzip} + +ترکیبی از چندین ردیف به یک مجموعه واحد. مجموعه حاصل شامل عناصر مربوطه را از ارریس منبع به تاپل در جهت ذکر شده از استدلال گروه بندی می شوند. + +**نحو** + +``` sql +arrayZip(arr1, arr2, ..., arrN) +``` + +**پارامترها** + +- `arrN` — [& حذف](../data-types/array.md). + +این تابع می تواند هر تعداد از مجموعه ای از انواع مختلف را. تمام ورودی های ورودی باید با اندازه یکسان باشند. + +**مقدار بازگشتی** + +- مجموعه ای با عناصر از ارریس منبع به گروه بندی می شوند [توپلس](../data-types/tuple.md). انواع داده ها در تاپل همان نوع از بند ورودی هستند و در همان جهت به عنوان ارریس به تصویب می رسد. + +نوع: [& حذف](../data-types/array.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT arrayZip(['a', 'b', 'c'], [5, 2, 1]) +``` + +نتیجه: + +``` text +┌─arrayZip(['a', 'b', 'c'], [5, 2, 1])─┐ +│ [('a',5),('b',2),('c',1)] │ +└──────────────────────────────────────┘ +``` + +## ارریایکو {#arrayauc} + +محاسبه حراج (منطقه تحت منحنی, که یک مفهوم در یادگیری ماشین است, مشاهده اطلاعات بیشتر: https://en.wikipedia.org/wiki/Receiver\_operating\_characteristic\#Area\_under\_the\_curve). + +**نحو** + +``` sql +arrayAUC(arr_scores, arr_labels) +``` + +**پارامترها** +- `arr_scores` — scores prediction model gives. +- `arr_labels` — labels of samples, usually 1 for positive sample and 0 for negtive sample. + +**مقدار بازگشتی** +را برمی گرداند ارزش حراج با نوع شناور64. + +**مثال** +پرسوجو: + +``` sql +select arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]) +``` + +نتیجه: + +``` text +┌─arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1])─┐ +│ 0.75 │ +└────────────────────────────────────────---──┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/fa/sql-reference/functions/array-join.md b/docs/fa/sql-reference/functions/array-join.md new file mode 100644 index 00000000000..4f4ee3eab60 --- /dev/null +++ b/docs/fa/sql-reference/functions/array-join.md @@ -0,0 +1,37 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "\u0627\u0631\u0631\u06CC\u062C\u06CC\u0646" +--- + +# تابع ارریجین {#functions_arrayjoin} + +این یک تابع بسیار غیر معمول است. + +توابع عادی انجام مجموعه ای از ردیف را تغییر دهید, اما فقط تغییر مقادیر در هر سطر (کوتاه). +توابع مجموع فشرده سازی مجموعه ای از ردیف (برابر یا کاهش). +این ‘arrayJoin’ تابع طول می کشد هر سطر و تولید مجموعه ای از ردیف (اشکار). + +این تابع یک مجموعه را به عنوان یک استدلال می گیرد و ردیف منبع را به چندین ردیف برای تعدادی از عناصر در مجموعه منتشر می کند. +تمام مقادیر ستون ها به سادگی کپی می شوند به جز مقادیر در ستون ای که این تابع اعمال می شود. + +پرس و جو می توانید چند استفاده کنید `arrayJoin` توابع. در این مورد تحول انجام شده است چندین بار. + +توجه داشته باشید که ترتیب پیوستن به نحو در پرس و جو را انتخاب کنید, فراهم می کند که امکانات گسترده تر. + +مثال: + +``` sql +SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src +``` + +``` text +┌─dst─┬─\'Hello\'─┬─src─────┐ +│ 1 │ Hello │ [1,2,3] │ +│ 2 │ Hello │ [1,2,3] │ +│ 3 │ Hello │ [1,2,3] │ +└─────┴───────────┴─────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/array_join/) diff --git a/docs/fa/sql-reference/functions/bit-functions.md b/docs/fa/sql-reference/functions/bit-functions.md new file mode 100644 index 00000000000..932b8b8656e --- /dev/null +++ b/docs/fa/sql-reference/functions/bit-functions.md @@ -0,0 +1,255 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: "\u0628\u06CC\u062A" +--- + +# توابع بیت {#bit-functions} + +بیت توابع کار برای هر جفت از انواع از UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32 یا Float64. + +نوع نتیجه یک عدد صحیح با بیت به حداکثر بیت از استدلال خود را برابر است. اگر حداقل یکی از استدلال امضا شده است, نتیجه یک شماره امضا شده است. اگر استدلال یک عدد ممیز شناور است, این است که به درون بازیگران64. + +## بیت و ب) {#bitanda-b} + +## bitOr(a, b) {#bitora-b} + +## هشدار داده می شود) {#bitxora-b} + +## bitNot(یک) {#bitnota} + +## اطلاعات دقیق) {#bitshiftlefta-b} + +## باز کردن پنجره روی برنامههای دیگر) {#bitshiftrighta-b} + +## هشدار داده می شود) {#bitrotatelefta-b} + +## حفاظت از بیت) {#bitrotaterighta-b} + +## بیتترین {#bittest} + +طول می کشد هر عدد صحیح و تبدیل به [شکل دودویی](https://en.wikipedia.org/wiki/Binary_number), بازگرداندن ارزش کمی در موقعیت مشخص. شمارش معکوس از 0 از سمت راست به سمت چپ شروع می شود. + +**نحو** + +``` sql +SELECT bitTest(number, index) +``` + +**پارامترها** + +- `number` – integer number. +- `index` – position of bit. + +**مقادیر بازگشتی** + +بازگرداندن مقدار کمی در موقعیت مشخص. + +نوع: `UInt8`. + +**مثال** + +مثلا, تعداد 43 در پایه-2 (دودویی) سیستم اعداد است 101011. + +پرسوجو: + +``` sql +SELECT bitTest(43, 1) +``` + +نتیجه: + +``` text +┌─bitTest(43, 1)─┐ +│ 1 │ +└────────────────┘ +``` + +مثال دیگر: + +پرسوجو: + +``` sql +SELECT bitTest(43, 2) +``` + +نتیجه: + +``` text +┌─bitTest(43, 2)─┐ +│ 0 │ +└────────────────┘ +``` + +## تماس {#bittestall} + +بازده نتیجه [ساخت منطقی](https://en.wikipedia.org/wiki/Logical_conjunction) (و اپراتور) از تمام بیت در موقعیت های داده شده. شمارش معکوس از 0 از سمت راست به سمت چپ شروع می شود. + +ساخت و ساز برای عملیات بیتی: + +0 AND 0 = 0 + +0 AND 1 = 0 + +1 AND 0 = 0 + +1 AND 1 = 1 + +**نحو** + +``` sql +SELECT bitTestAll(number, index1, index2, index3, index4, ...) +``` + +**پارامترها** + +- `number` – integer number. +- `index1`, `index2`, `index3`, `index4` – positions of bit. For example, for set of positions (`index1`, `index2`, `index3`, `index4`) درست است اگر و تنها اگر تمام موقعیت خود را درست هستند (`index1` ⋀ `index2`, ⋀ `index3` ⋀ `index4`). + +**مقادیر بازگشتی** + +بازده نتیجه منطقی conjuction. + +نوع: `UInt8`. + +**مثال** + +مثلا, تعداد 43 در پایه-2 (دودویی) سیستم اعداد است 101011. + +پرسوجو: + +``` sql +SELECT bitTestAll(43, 0, 1, 3, 5) +``` + +نتیجه: + +``` text +┌─bitTestAll(43, 0, 1, 3, 5)─┐ +│ 1 │ +└────────────────────────────┘ +``` + +مثال دیگر: + +پرسوجو: + +``` sql +SELECT bitTestAll(43, 0, 1, 3, 5, 2) +``` + +نتیجه: + +``` text +┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ +│ 0 │ +└───────────────────────────────┘ +``` + +## بیتستانی {#bittestany} + +بازده نتیجه [حکم منطقی](https://en.wikipedia.org/wiki/Logical_disjunction) (یا اپراتور) از تمام بیت در موقعیت های داده شده. شمارش معکوس از 0 از سمت راست به سمت چپ شروع می شود. + +دستور برای عملیات بیتی: + +0 OR 0 = 0 + +0 OR 1 = 1 + +1 OR 0 = 1 + +1 OR 1 = 1 + +**نحو** + +``` sql +SELECT bitTestAny(number, index1, index2, index3, index4, ...) +``` + +**پارامترها** + +- `number` – integer number. +- `index1`, `index2`, `index3`, `index4` – positions of bit. + +**مقادیر بازگشتی** + +بازده نتیجه ساخت و ساز منطقی. + +نوع: `UInt8`. + +**مثال** + +مثلا, تعداد 43 در پایه-2 (دودویی) سیستم اعداد است 101011. + +پرسوجو: + +``` sql +SELECT bitTestAny(43, 0, 2) +``` + +نتیجه: + +``` text +┌─bitTestAny(43, 0, 2)─┐ +│ 1 │ +└──────────────────────┘ +``` + +مثال دیگر: + +پرسوجو: + +``` sql +SELECT bitTestAny(43, 4, 2) +``` + +نتیجه: + +``` text +┌─bitTestAny(43, 4, 2)─┐ +│ 0 │ +└──────────────────────┘ +``` + +## شمارش {#bitcount} + +محاسبه تعداد بیت را به یکی در نمایندگی دودویی از یک عدد است. + +**نحو** + +``` sql +bitCount(x) +``` + +**پارامترها** + +- `x` — [عدد صحیح](../../sql-reference/data-types/int-uint.md) یا [شناور نقطه](../../sql-reference/data-types/float.md) شماره. تابع با استفاده از نمایندگی ارزش در حافظه. این اجازه می دهد تا حمایت از اعداد ممیز شناور. + +**مقدار بازگشتی** + +- تعداد بیت را به یکی در تعداد ورودی. + +تابع مقدار ورودی را به یک نوع بزرگتر تبدیل نمی کند ([ثبت نام پسوند](https://en.wikipedia.org/wiki/Sign_extension)). بنابراین, مثلا, `bitCount(toUInt8(-1)) = 8`. + +نوع: `UInt8`. + +**مثال** + +نگاهی به عنوان مثال تعداد 333. نمایندگی دودویی: 00000001001101. + +پرسوجو: + +``` sql +SELECT bitCount(333) +``` + +نتیجه: + +``` text +┌─bitCount(333)─┐ +│ 5 │ +└───────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/fa/sql-reference/functions/bitmap-functions.md b/docs/fa/sql-reference/functions/bitmap-functions.md new file mode 100644 index 00000000000..f7740cf02e9 --- /dev/null +++ b/docs/fa/sql-reference/functions/bitmap-functions.md @@ -0,0 +1,496 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 49 +toc_title: "\u0646\u06AF\u0627\u0634\u062A \u0628\u06CC\u062A" +--- + +# توابع نگاشت بیت {#bitmap-functions} + +توابع بیت مپ برای دو بیت مپ محاسبه ارزش شی کار, این است که بازگشت بیت مپ جدید و یا کارتیت در حالی که با استفاده از محاسبه فرمول, مانند و, یا, صخره نوردی, و نه, و غیره. + +2 نوع از روش های ساخت و ساز برای شی بیت مپ وجود دارد. یکی این است که توسط گروه بیت مپ تابع تجمع با دولت ساخته شود, دیگر این است که توسط شی مجموعه ای ساخته شود. این نیز برای تبدیل شی بیت مپ به مجموعه شی. + +نقشه شهری روارینگ به یک ساختار داده در حالی که ذخیره سازی واقعی از اجسام بیت مپ پیچیده شده است. هنگامی که کارتیت کمتر از یا برابر است 32, با استفاده از عینیت مجموعه. هنگامی که کارتیت بیشتر از است 32, با استفاده از شی نقشه شهری روارینگ. به همین دلیل است ذخیره سازی مجموعه کارتیت کم سریع تر است. + +برای کسب اطلاعات بیشتر در مورد نقشه شهری روارینگ: [پرورش دهنده](https://github.com/RoaringBitmap/CRoaring). + +## طراحی بیت مپ {#bitmap_functions-bitmapbuild} + +ساخت یک بیت مپ از مجموعه عدد صحیح بدون علامت. + +``` sql +bitmapBuild(array) +``` + +**پارامترها** + +- `array` – unsigned integer array. + +**مثال** + +``` sql +SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) +``` + +``` text +┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ +│  │ AggregateFunction(groupBitmap, UInt8) │ +└─────┴──────────────────────────────────────────────┘ +``` + +## بیت مپوری {#bitmaptoarray} + +تبدیل بیت مپ به مجموعه عدد صحیح. + +``` sql +bitmapToArray(bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + +``` text +┌─res─────────┐ +│ [1,2,3,4,5] │ +└─────────────┘ +``` + +## اطلاعات دقیق {#bitmap-functions-bitmapsubsetinrange} + +زیرمجموعه بازگشت در محدوده مشخص شده (دامنه را شامل نمی شود). + +``` sql +bitmapSubsetInRange(bitmap, range_start, range_end) +``` + +**پارامترها** + +- `bitmap` – [شی نگاشت بیت](#bitmap_functions-bitmapbuild). +- `range_start` – range start point. Type: [UInt32](../../sql-reference/data-types/int-uint.md). +- `range_end` – range end point(excluded). Type: [UInt32](../../sql-reference/data-types/int-uint.md). + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + +``` text +┌─res───────────────┐ +│ [30,31,32,33,100] │ +└───────────────────┘ +``` + +## نمایش سایت {#bitmapsubsetlimit} + +ایجاد یک زیر مجموعه از بیت مپ با عناصر نفر گرفته شده بین `range_start` و `cardinality_limit`. + +**نحو** + +``` sql +bitmapSubsetLimit(bitmap, range_start, cardinality_limit) +``` + +**پارامترها** + +- `bitmap` – [شی نگاشت بیت](#bitmap_functions-bitmapbuild). +- `range_start` – The subset starting point. Type: [UInt32](../../sql-reference/data-types/int-uint.md). +- `cardinality_limit` – The subset cardinality upper limit. Type: [UInt32](../../sql-reference/data-types/int-uint.md). + +**مقدار بازگشتی** + +زیرمجموعه. + +نوع: `Bitmap object`. + +**مثال** + +پرسوجو: + +``` sql +SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + +نتیجه: + +``` text +┌─res───────────────────────┐ +│ [30,31,32,33,100,200,500] │ +└───────────────────────────┘ +``` + +## اطلاعات دقیق {#bitmap_functions-bitmapcontains} + +بررسی اینکه نگاشت بیت شامل یک عنصر است. + +``` sql +bitmapContains(haystack, needle) +``` + +**پارامترها** + +- `haystack` – [شی نگاشت بیت](#bitmap_functions-bitmapbuild), جایی که تابع جستجو. +- `needle` – Value that the function searches. Type: [UInt32](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- 0 — If `haystack` شامل نمی شود `needle`. +- 1 — If `haystack` شامل `needle`. + +نوع: `UInt8`. + +**مثال** + +``` sql +SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## بیتمافاسانی {#bitmaphasany} + +بررسی اینکه دو بیت مپ دارند تقاطع توسط برخی از عناصر. + +``` sql +bitmapHasAny(bitmap1, bitmap2) +``` + +اگر شما اطمینان حاصل کنید که `bitmap2` حاوی شدت یک عنصر, در نظر با استفاده از [اطلاعات دقیق](#bitmap_functions-bitmapcontains) تابع. این کار موثر تر است. + +**پارامترها** + +- `bitmap*` – bitmap object. + +**مقادیر بازگشتی** + +- `1` اگر `bitmap1` و `bitmap2` حداقل یک عنصر مشابه داشته باشید. +- `0` وگرنه + +**مثال** + +``` sql +SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## بیتمافاسال {#bitmaphasall} + +مشابه به `hasAll(array, array)` بازده 1 اگر بیت مپ اول شامل تمام عناصر از یک ثانیه, 0 در غیر این صورت. +اگر استدلال دوم بیت مپ خالی است و سپس باز می گردد 1. + +``` sql +bitmapHasAll(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + +``` text +┌─res─┐ +│ 0 │ +└─────┘ +``` + +## هشدار داده می شود {#bitmapcardinality} + +Retrun بیت مپ cardinality از نوع UInt64. + +``` sql +bitmapCardinality(bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + +``` text +┌─res─┐ +│ 5 │ +└─────┘ +``` + +## بیت مپمن {#bitmapmin} + +Retrun کوچکترین مقدار از نوع UInt64 در مجموعه UINT32\_MAX اگر این مجموعه خالی است. + + bitmapMin(bitmap) + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 1 │ + └─────┘ + +## جرم اتمی {#bitmapmax} + +جابجایی بزرگترین ارزش نوع اوینت64 در مجموعه, 0 اگر مجموعه ای خالی است. + + bitmapMax(bitmap) + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 5 │ + └─────┘ + +## ترجمههای بیت مپ {#bitmaptransform} + +تبدیل مجموعه ای از ارزش ها در بیت مپ به مجموعه ای دیگر از ارزش, نتیجه یک بیت مپ جدید است. + + bitmapTransform(bitmap, from_array, to_array) + +**پارامترها** + +- `bitmap` – bitmap object. +- `from_array` – UInt32 array. For idx in range \[0, from\_array.size()), if bitmap contains from\_array\[idx\], then replace it with to\_array\[idx\]. Note that the result depends on array ordering if there are common elements between from\_array and to\_array. +- `to_array` – UInt32 array, its size shall be the same to from\_array. + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res +``` + + ┌─res───────────────────┐ + │ [1,3,4,6,7,8,9,10,20] │ + └───────────────────────┘ + +## بیت مپند {#bitmapand} + +دو بیت مپ و محاسبه, نتیجه یک بیت مپ جدید است. + +``` sql +bitmapAnd(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res─┐ +│ [3] │ +└─────┘ +``` + +## نگاشت بیت {#bitmapor} + +دو بیت مپ و یا محاسبه, نتیجه یک بیت مپ جدید است. + +``` sql +bitmapOr(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res─────────┐ +│ [1,2,3,4,5] │ +└─────────────┘ +``` + +## بیت مپکسور {#bitmapxor} + +دو محاسبه گز بیت مپ, نتیجه یک بیت مپ جدید است. + +``` sql +bitmapXor(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res───────┐ +│ [1,2,4,5] │ +└───────────┘ +``` + +## بیت مپندو {#bitmapandnot} + +دو محاسبه بیت مپ اندنوت, نتیجه یک بیت مپ جدید است. + +``` sql +bitmapAndnot(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res───┐ +│ [1,2] │ +└───────┘ +``` + +## اطلاعات دقیق {#bitmapandcardinality} + +دو بیت مپ و محاسبه بازگشت cardinality از نوع UInt64. + +``` sql +bitmapAndCardinality(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## کمبود سیگار {#bitmaporcardinality} + +دو بیت مپ و یا محاسبه بازگشت cardinality از نوع UInt64. + +``` sql +bitmapOrCardinality(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 5 │ +└─────┘ +``` + +## هشدار داده می شود {#bitmapxorcardinality} + +دو بیت مپ xor محاسبه بازگشت cardinality از نوع UInt64. + +``` sql +bitmapXorCardinality(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 4 │ +└─────┘ +``` + +## اطلاعات دقیق {#bitmapandnotcardinality} + +دو بیت مپ andnot محاسبه بازگشت cardinality از نوع UInt64. + +``` sql +bitmapAndnotCardinality(bitmap,bitmap) +``` + +**پارامترها** + +- `bitmap` – bitmap object. + +**مثال** + +``` sql +SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 2 │ +└─────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/fa/sql-reference/functions/comparison-functions.md b/docs/fa/sql-reference/functions/comparison-functions.md new file mode 100644 index 00000000000..61102ec38a6 --- /dev/null +++ b/docs/fa/sql-reference/functions/comparison-functions.md @@ -0,0 +1,37 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: "\u0645\u0642\u0627\u06CC\u0633\u0647" +--- + +# توابع مقایسه {#comparison-functions} + +توابع مقایسه همیشه بازگشت 0 یا 1 (اوینت8). + +انواع زیر را می توان مقایسه کرد: + +- اعداد +- رشته ها و رشته های ثابت +- تاریخ +- تاریخ با زمان + +در هر گروه, اما نه بین گروه های مختلف. + +مثلا, شما می توانید یک تاریخ را با یک رشته مقایسه نیست. شما مجبور به استفاده از یک تابع برای تبدیل رشته به یک تاریخ, و یا بالعکس. + +رشته ها با بایت مقایسه. یک رشته کوتاه تر کوچکتر از همه رشته هایی است که با این کار شروع می شوند و شامل حداقل یک شخصیت دیگر می شوند. + +## برابر, = ب و = = ب اپراتور {#function-equals} + +## کار در حالت اضطراری, یک ! اپراتور = ب و \< \> ب {#function-notequals} + +## کمتر, \< اپراتور {#function-less} + +## بیشتر, \> اپراتور {#function-greater} + +## اطلاعات دقیق {#function-lessorequals} + +## در حال بارگذاری {#function-greaterorequals} + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/fa/sql-reference/functions/conditional-functions.md b/docs/fa/sql-reference/functions/conditional-functions.md new file mode 100644 index 00000000000..47fa1f4773f --- /dev/null +++ b/docs/fa/sql-reference/functions/conditional-functions.md @@ -0,0 +1,207 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u0634\u0631\u0637\u06CC " +--- + +# توابع شرطی {#conditional-functions} + +## اگر {#if} + +کنترل انشعاب مشروط. بر خلاف اکثر سیستم های تاتر همیشه هر دو عبارت را ارزیابی کنید `then` و `else`. + +**نحو** + +``` sql +SELECT if(cond, then, else) +``` + +اگر شرایط `cond` ارزیابی به یک مقدار غیر صفر, می گرداند در نتیجه بیان `then` و نتیجه بیان `else`, اگر در حال حاضر, قلم است. اگر `cond` صفر یا `NULL` سپس نتیجه `then` بیان نادیده گرفته شده است و در نتیجه `else` عبارت, در صورت حاضر, بازگشته است. + +**پارامترها** + +- `cond` – The condition for evaluation that can be zero or not. The type is UInt8, Nullable(UInt8) or NULL. +- `then` - بیان به بازگشت اگر شرایط ملاقات کرده است. +- `else` - بیان به بازگشت اگر شرایط ملاقات نکرده است. + +**مقادیر بازگشتی** + +تابع اجرا می شود `then` و `else` عبارات و نتیجه خود را بر می گرداند, بسته به اینکه شرایط `cond` به پایان رسید تا صفر یا نه. + +**مثال** + +پرسوجو: + +``` sql +SELECT if(1, plus(2, 2), plus(2, 6)) +``` + +نتیجه: + +``` text +┌─plus(2, 2)─┐ +│ 4 │ +└────────────┘ +``` + +پرسوجو: + +``` sql +SELECT if(0, plus(2, 2), plus(2, 6)) +``` + +نتیجه: + +``` text +┌─plus(2, 6)─┐ +│ 8 │ +└────────────┘ +``` + +- `then` و `else` باید کمترین نوع مشترک دارند. + +**مثال:** + +اینو بگیر `LEFT_RIGHT` جدول: + +``` sql +SELECT * +FROM LEFT_RIGHT + +┌─left─┬─right─┐ +│ ᴺᵁᴸᴸ │ 4 │ +│ 1 │ 3 │ +│ 2 │ 2 │ +│ 3 │ 1 │ +│ 4 │ ᴺᵁᴸᴸ │ +└──────┴───────┘ +``` + +پرس و جو زیر مقایسه می کند `left` و `right` مقادیر: + +``` sql +SELECT + left, + right, + if(left < right, 'left is smaller than right', 'right is greater or equal than left') AS is_smaller +FROM LEFT_RIGHT +WHERE isNotNull(left) AND isNotNull(right) + +┌─left─┬─right─┬─is_smaller──────────────────────────┐ +│ 1 │ 3 │ left is smaller than right │ +│ 2 │ 2 │ right is greater or equal than left │ +│ 3 │ 1 │ right is greater or equal than left │ +└──────┴───────┴─────────────────────────────────────┘ +``` + +یادداشت: `NULL` ارزش ها در این مثال استفاده نمی شود, بررسی [ارزشهای پوچ در شرطی](#null-values-in-conditionals) بخش. + +## اپراتور سه تایی {#ternary-operator} + +این همان کار می کند `if` تابع. + +نحو: `cond ? then : else` + +بازگشت `then` اگر `cond` ارزیابی درست باشد (بیشتر از صفر), در غیر این صورت بازده `else`. + +- `cond` باید از نوع باشد `UInt8` و `then` و `else` باید کمترین نوع مشترک دارند. + +- `then` و `else` می تواند باشد `NULL` + +**همچنین نگاه کنید به** + +- [اطلاعات دقیق](other-functions.md#ifnotfinite). + +## چندف {#multiif} + +اجازه می دهد تا شما را به نوشتن [CASE](../operators/index.md#operator_case) اپراتور فشرده تر در پرس و جو. + +نحو: `multiIf(cond_1, then_1, cond_2, then_2, ..., else)` + +**پارامترها:** + +- `cond_N` — The condition for the function to return `then_N`. +- `then_N` — The result of the function when executed. +- `else` — The result of the function if none of the conditions is met. + +تابع می پذیرد `2N+1` پارامترها + +**مقادیر بازگشتی** + +تابع یکی از مقادیر را برمی گرداند `then_N` یا `else`, بسته به شرایط `cond_N`. + +**مثال** + +دوباره با استفاده از `LEFT_RIGHT` جدول + +``` sql +SELECT + left, + right, + multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result +FROM LEFT_RIGHT + +┌─left─┬─right─┬─result──────────┐ +│ ᴺᵁᴸᴸ │ 4 │ Null value │ +│ 1 │ 3 │ left is smaller │ +│ 2 │ 2 │ Both equal │ +│ 3 │ 1 │ left is greater │ +│ 4 │ ᴺᵁᴸᴸ │ Null value │ +└──────┴───────┴─────────────────┘ +``` + +## با استفاده از نتایج شرطی به طور مستقیم {#using-conditional-results-directly} + +شرطی همیشه به نتیجه `0`, `1` یا `NULL`. بنابراین شما می توانید نتایج شرطی به طور مستقیم مثل این استفاده کنید: + +``` sql +SELECT left < right AS is_small +FROM LEFT_RIGHT + +┌─is_small─┐ +│ ᴺᵁᴸᴸ │ +│ 1 │ +│ 0 │ +│ 0 │ +│ ᴺᵁᴸᴸ │ +└──────────┘ +``` + +## ارزشهای پوچ در شرطی {#null-values-in-conditionals} + +چه زمانی `NULL` ارزش ها در شرطی درگیر, نتیجه نیز خواهد بود `NULL`. + +``` sql +SELECT + NULL < 1, + 2 < NULL, + NULL < NULL, + NULL = NULL + +┌─less(NULL, 1)─┬─less(2, NULL)─┬─less(NULL, NULL)─┬─equals(NULL, NULL)─┐ +│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ +└───────────────┴───────────────┴──────────────────┴────────────────────┘ +``` + +بنابراین شما باید نمایش داده شد خود را با دقت ساخت اگر انواع هستند `Nullable`. + +مثال زیر نشان می دهد این شکست برای اضافه کردن شرایط برابر به `multiIf`. + +``` sql +SELECT + left, + right, + multiIf(left < right, 'left is smaller', left > right, 'right is smaller', 'Both equal') AS faulty_result +FROM LEFT_RIGHT + +┌─left─┬─right─┬─faulty_result────┐ +│ ᴺᵁᴸᴸ │ 4 │ Both equal │ +│ 1 │ 3 │ left is smaller │ +│ 2 │ 2 │ Both equal │ +│ 3 │ 1 │ right is smaller │ +│ 4 │ ᴺᵁᴸᴸ │ Both equal │ +└──────┴───────┴──────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/fa/sql-reference/functions/date-time-functions.md b/docs/fa/sql-reference/functions/date-time-functions.md new file mode 100644 index 00000000000..e956b7b71fa --- /dev/null +++ b/docs/fa/sql-reference/functions/date-time-functions.md @@ -0,0 +1,451 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u062A\u0627\u0631\u06CC\u062E \u0648\ + \ \u0632\u0645\u0627\u0646" +--- + +# توابع برای کار با تاریخ و زمان {#functions-for-working-with-dates-and-times} + +پشتیبانی از مناطق زمانی + +همه توابع برای کار با تاریخ و زمان است که یک استفاده منطقی برای منطقه زمانی می تواند یک زمان اختیاری استدلال منطقه دوم قبول. مثال: اسیا/یکاترینبورگ. در این مورد از منطقه زمانی مشخص شده به جای محلی (پیش فرض) استفاده می کنند. + +``` sql +SELECT + toDateTime('2016-06-15 23:00:00') AS time, + toDate(time) AS date_local, + toDate(time, 'Asia/Yekaterinburg') AS date_yekat, + toString(time, 'US/Samoa') AS time_samoa +``` + +``` text +┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ +│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ +└─────────────────────┴────────────┴────────────┴─────────────────────┘ +``` + +فقط مناطق زمانی که از مجموعه مقالات توسط تعداد کل ساعت متفاوت پشتیبانی می شوند. + +## توتیمزون {#totimezone} + +تبدیل زمان یا تاریخ و زمان به منطقه زمانی مشخص شده است. + +## اسباب بازی {#toyear} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت16 حاوی شماره سال (میلادی). + +## فهرست توزیع جدید {#toquarter} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد کوچک8 حاوی شماره سه ماهه. + +## تامونت {#tomonth} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد کوچک8 حاوی شماره ماه (1-12). + +## سال {#todayofyear} + +تبدیل یک تاریخ و یا تاریخ با گذشت زمان به یک UInt16 تعداد شامل تعداد روز از سال (1-366). + +## تودیفمون {#todayofmonth} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت8 حاوی تعداد روز از ماه (1-31). + +## تدیفوک {#todayofweek} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت8 حاوی تعداد روز هفته (دوشنبه است 1, و یکشنبه است 7). + +## تمام {#tohour} + +تبدیل تاریخ با هم به یک UInt8 شماره حاوی تعداد ساعت در زمان 24 ساعته (0-23). +This function assumes that if clocks are moved ahead, it is by one hour and occurs at 2 a.m., and if clocks are moved back, it is by one hour and occurs at 3 a.m. (which is not always true – even in Moscow the clocks were twice changed at a different time). + +## تامینوت {#tominute} + +تبدیل تاریخ با هم به یک UInt8 شماره حاوی تعداد دقیقه از ساعت (0-59). + +## جای خالی {#tosecond} + +تبدیل تاریخ با هم به یک UInt8 شماره حاوی شماره دوم در دقیقه (0-59). +ثانیه جهش برای به حساب نمی. + +## تیونیتیمستمپ {#to-unix-timestamp} + +برای استدلال حسگر ناحیه رنگی: تبدیل ارزش به نمایندگی عددی داخلی خود (برچسب زمان یونیکس). +برای استدلال رشته: تاریخ ساعت پارسه از رشته با توجه به منطقه زمانی (بحث دوم اختیاری, منطقه زمانی سرور به طور پیش فرض استفاده می شود) و مربوط برچسب زمان یونیکس می گرداند. +برای استدلال تاریخ: رفتار نامشخص است. + +**نحو** + +``` sql +toUnixTimestamp(datetime) +toUnixTimestamp(str, [timezone]) +``` + +**مقدار بازگشتی** + +- زمان یونیکس را برمی گرداند. + +نوع: `UInt32`. + +**مثال** + +پرسوجو: + +``` sql +SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp +``` + +نتیجه: + +``` text +┌─unix_timestamp─┐ +│ 1509836867 │ +└────────────────┘ +``` + +## سال نو {#tostartofyear} + +دور یک تاریخ یا تاریخ با زمان به روز اول سال. +تاریخ را برمی گرداند. + +## تاستارتوفیزیر {#tostartofisoyear} + +دور کردن تاریخ یا تاریخ با زمان به روز اول سال ایزو. +تاریخ را برمی گرداند. + +## تاستارتوفارتر {#tostartofquarter} + +دور یک تاریخ یا تاریخ با زمان به روز اول سه ماهه. +اولین روز از سه ماهه است یا 1 ژانویه, 1 مارس, 1 جولای, یا 1 اکتبر. +تاریخ را برمی گرداند. + +## ماهی تابه {#tostartofmonth} + +دور پایین تاریخ یا تاریخ با زمان به روز اول ماه. +تاریخ را برمی گرداند. + +!!! attention "توجه" + رفتار تجزیه تاریخ نادرست اجرای خاص است. تاتر ممکن است صفر تاریخ بازگشت, پرتاب یک استثنا و یا انجام “natural” سرریز کردن. + +## روز قیامت {#tomonday} + +دور کردن یک تاریخ یا تاریخ با زمان به نزدیکترین دوشنبه. +تاریخ را برمی گرداند. + +## تستارتوفک (تی \[, حالت\]) {#tostartofweektmode} + +دور یک تاریخ یا تاریخ را با زمان به نزدیکترین یکشنبه یا دوشنبه با حالت. +تاریخ را برمی گرداند. +استدلال حالت کار می کند دقیقا مانند استدلال حالت به یدک کش (). برای نحو تک استدلال, ارزش حالت 0 استفاده شده است. + +## روزهای سه بعدی {#tostartofday} + +دور پایین تاریخ با زمان به شروع روز. + +## تاستارتوفهور {#tostartofhour} + +دور پایین تاریخ با زمان به شروع ساعت. + +## حفاظت {#tostartofminute} + +دور پایین تاریخ با زمان به شروع دقیقه. + +## تستارتوفیفومینوت {#tostartoffiveminute} + +دور پایین تاریخ با زمان به شروع فاصله پنج دقیقه. + +## حفاظت {#tostartoftenminutes} + +دور پایین تاریخ با زمان به شروع فاصله ده دقیقه. + +## حفاظت از محیط زیست {#tostartoffifteenminutes} + +دور پایین تاریخ با زمان به شروع فاصله پانزده دقیقه. + +## toStartOfInterval(time\_or\_data فاصله x واحد \[, time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} + +این یک تعمیم توابع دیگر به نام است `toStartOf*`. به عنوان مثال, +`toStartOfInterval(t, INTERVAL 1 year)` همان را برمی گرداند `toStartOfYear(t)`, +`toStartOfInterval(t, INTERVAL 1 month)` همان را برمی گرداند `toStartOfMonth(t)`, +`toStartOfInterval(t, INTERVAL 1 day)` همان را برمی گرداند `toStartOfDay(t)`, +`toStartOfInterval(t, INTERVAL 15 minute)` همان را برمی گرداند `toStartOfFifteenMinutes(t)` و غیره + +## & تمام کردن {#totime} + +تبدیل یک تاریخ با زمان به یک تاریخ ثابت خاص, در حالی که حفظ زمان. + +## ترلتیویینوم {#torelativeyearnum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد سال, با شروع از یک نقطه ثابت خاص در گذشته. + +## ترلتیواارترن {#torelativequarternum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد سه ماهه, با شروع از یک نقطه ثابت خاص در گذشته. + +## ترلتیومنتنوم {#torelativemonthnum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد ماه, با شروع از یک نقطه ثابت خاص در گذشته. + +## ترلتیواکنام {#torelativeweeknum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد هفته, با شروع از یک نقطه ثابت خاص در گذشته. + +## ترلتیدینوم {#torelativedaynum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد روز, با شروع از یک نقطه ثابت خاص در گذشته. + +## تورلاتویورنام {#torelativehournum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد ساعت, با شروع از یک نقطه ثابت خاص در گذشته. + +## ترلتیومینوتنوم {#torelativeminutenum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد دقیقه, با شروع از یک نقطه ثابت خاص در گذشته. + +## ترلتیویسکنندوم {#torelativesecondnum} + +تبدیل یک تاریخ با زمان و یا تاریخ به تعداد دوم, با شروع از یک نقطه ثابت خاص در گذشته. + +## ریز ریز کردن {#toisoyear} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت16 حاوی شماره سال ایزو. + +## هشدار داده می شود {#toisoweek} + +تبدیل یک تاریخ و یا تاریخ با گذشت زمان به یک UInt8 تعداد شامل ISO هفته شماره. + +## تاریخ \[, حالت\]) {#toweekdatemode} + +این تابع تعداد هفته برای تاریخ و یا تاریخ ساعت می گرداند. فرم دو برهان یدک کش () شما را قادر به مشخص کنید که هفته در روز یکشنبه یا دوشنبه شروع می شود و چه مقدار بازگشتی باید در محدوده 0 تا 53 یا از 1 به 53 باشد. اگر استدلال حالت حذف شده است, حالت پیش فرض است 0. +`toISOWeek()`یک تابع سازگاری است که معادل است `toWeek(date,3)`. +جدول زیر توضیح می دهد که چگونه استدلال حالت کار می کند. + +| حالت | اولین روز هفته | گستره | Week 1 is the first week … | +|------|----------------|-------|-----------------------------| +| 0 | یکشنبه | 0-53 | با یکشنبه در این سال | +| 1 | دوشنبه | 0-53 | با 4 یا چند روز در سال جاری | +| 2 | یکشنبه | 1-53 | با یکشنبه در این سال | +| 3 | دوشنبه | 1-53 | با 4 یا چند روز در سال جاری | +| 4 | یکشنبه | 0-53 | با 4 یا چند روز در سال جاری | +| 5 | دوشنبه | 0-53 | با دوشنبه در این سال | +| 6 | یکشنبه | 1-53 | با 4 یا چند روز در سال جاری | +| 7 | دوشنبه | 1-53 | با دوشنبه در این سال | +| 8 | یکشنبه | 1-53 | شامل ژانویه 1 | +| 9 | دوشنبه | 1-53 | شامل ژانویه 1 | + +برای مقادیر حالت با معنی “with 4 or more days this year,” هفته ها با توجه به ایزو شماره 8601: 1988: + +- اگر هفته حاوی ژانویه 1 است 4 یا چند روز در سال جدید, هفته است 1. + +- در غیر این صورت, این هفته گذشته سال گذشته است, و هفته بعد هفته است 1. + +برای مقادیر حالت با معنی “contains January 1”, هفته شامل ژانویه 1 هفته است 1. مهم نیست که چند روز در سال جدید هفته شامل, حتی اگر شامل تنها یک روز. + +``` sql +toWeek(date, [, mode][, Timezone]) +``` + +**پارامترها** + +- `date` – Date or DateTime. +- `mode` – Optional parameter, Range of values is \[0,9\], default is 0. +- `Timezone` – Optional parameter, it behaves like any other conversion function. + +**مثال** + +``` sql +SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9; +``` + +``` text +┌───────date─┬─week0─┬─week1─┬─week9─┐ +│ 2016-12-27 │ 52 │ 52 │ 1 │ +└────────────┴───────┴───────┴───────┘ +``` + +## تاریخ \[, حالت\]) {#toyearweekdatemode} + +را برمی گرداند سال و هفته برای تاریخ. سال در نتیجه ممکن است متفاوت از سال در بحث تاریخ برای اولین و هفته گذشته سال. + +استدلال حالت کار می کند دقیقا مانند استدلال حالت به یدک کش (). برای نحو تک استدلال, ارزش حالت 0 استفاده شده است. + +`toISOYear()`یک تابع سازگاری است که معادل است `intDiv(toYearWeek(date,3),100)`. + +**مثال** + +``` sql +SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9; +``` + +``` text +┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┐ +│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ +└────────────┴───────────┴───────────┴───────────┘ +``` + +## حالا {#now} + +قبول صفر استدلال و بازده زمان فعلی در یکی از لحظات اجرای درخواست. +این تابع ثابت می گرداند, حتی اگر درخواست زمان طولانی برای تکمیل. + +## امروز {#today} + +قبول صفر استدلال و بازده تاریخ جاری در یکی از لحظات اجرای درخواست. +همان ‘toDate(now())’. + +## دیروز {#yesterday} + +قبول صفر استدلال و بازده تاریخ دیروز در یکی از لحظات اجرای درخواست. +همان ‘today() - 1’. + +## بازه زمانی {#timeslot} + +دور زمان به نیم ساعت. +این تابع خاص به یاندکس است.متریکا, از نیم ساعت حداقل مقدار زمان برای شکستن یک جلسه به دو جلسه است اگر یک تگ ردیابی نشان می دهد تعداد صفحات متوالی یک کاربر که در زمان به شدت بیش از این مقدار متفاوت. این به این معنی است که تاپل (شناسه برچسب, شناسه کاربری, و شکاف زمان) را می توان مورد استفاده قرار گیرد به جستجو برای تعداد صفحات که در جلسه مربوطه شامل. + +## ستاره فیلم سکسی {#toyyyymm} + +تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت32 حاوی تعداد سال و ماه (یی \* 100 + میلی متر). + +## ستاره فیلم سکسی {#toyyyymmdd} + +تبدیل یک تاریخ یا تاریخ با زمان به تعداد اوینت32 حاوی سال و ماه شماره (یی \* 10000 + میلی متر \* 100 + دی.دی. + +## اطلاعات دقیق {#toyyyymmddhhmmss} + +تبدیل یک تاریخ و یا تاریخ با گذشت زمان به یک UInt64 تعداد شامل سال و ماه شماره (YYYY \* 10000000000 + MM \* 100000000 + DD \* 1000000 + hh \* 10000 + mm \* 100 + ss) است. + +## addYears, addMonths, addWeeks, addDays, addHours, addMinutes, addSeconds, addQuarters {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} + +تابع می افزاید: یک تاریخ/فاصله زمانی به یک تاریخ/تاریخ ساعت و سپس بازگشت تاریخ / تاریخ ساعت. به عنوان مثال: + +``` sql +WITH + toDate('2018-01-01') AS date, + toDateTime('2018-01-01 00:00:00') AS date_time +SELECT + addYears(date, 1) AS add_years_with_date, + addYears(date_time, 1) AS add_years_with_date_time +``` + +``` text +┌─add_years_with_date─┬─add_years_with_date_time─┐ +│ 2019-01-01 │ 2019-01-01 00:00:00 │ +└─────────────────────┴──────────────────────────┘ +``` + +## subtractYears, subtractMonths, subtractWeeks, subtractDays, subtractHours, subtractMinutes, subtractSeconds, subtractQuarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} + +تابع تفریق یک تاریخ/فاصله زمانی به تاریخ/تاریخ ساعت و سپس بازگشت تاریخ / تاریخ ساعت. به عنوان مثال: + +``` sql +WITH + toDate('2019-01-01') AS date, + toDateTime('2019-01-01 00:00:00') AS date_time +SELECT + subtractYears(date, 1) AS subtract_years_with_date, + subtractYears(date_time, 1) AS subtract_years_with_date_time +``` + +``` text +┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ +│ 2018-01-01 │ 2018-01-01 00:00:00 │ +└──────────────────────────┴───────────────────────────────┘ +``` + +## dateDiff {#datediff} + +بازگرداندن تفاوت بین دو تاریخ و یا تاریخ ساعت ارزش. + +**نحو** + +``` sql +dateDiff('unit', startdate, enddate, [timezone]) +``` + +**پارامترها** + +- `unit` — Time unit, in which the returned value is expressed. [رشته](../syntax.md#syntax-string-literal). + + Supported values: + + | unit | + | ---- | + |second | + |minute | + |hour | + |day | + |week | + |month | + |quarter | + |year | + +- `startdate` — The first time value to compare. [تاریخ](../../sql-reference/data-types/date.md) یا [DateTime](../../sql-reference/data-types/datetime.md). + +- `enddate` — The second time value to compare. [تاریخ](../../sql-reference/data-types/date.md) یا [DateTime](../../sql-reference/data-types/datetime.md). + +- `timezone` — Optional parameter. If specified, it is applied to both `startdate` و `enddate`. اگر مشخص نشده, زمان از `startdate` و `enddate` استفاده می شود. در صورتی که یکسان نیست, نتیجه نامشخص است. + +**مقدار بازگشتی** + +تفاوت بین `startdate` و `enddate` بیان شده در `unit`. + +نوع: `int`. + +**مثال** + +پرسوجو: + +``` sql +SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); +``` + +نتیجه: + +``` text +┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ +│ 25 │ +└────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## زمانهای(StartTime, مدت,\[, اندازه\]) {#timeslotsstarttime-duration-size} + +برای یک بازه زمانی شروع در ‘StartTime’ و در ادامه برای ‘Duration’ ثانیه, این مجموعه ای از لحظات در زمان گرداند, متشکل از نقاط از این فاصله به گرد ‘Size’ در عرض چند ثانیه ‘Size’ یک پارامتر اختیاری است: یک ثابت اوینت32, مجموعه ای به 1800 به طور پیش فرض. +به عنوان مثال, `timeSlots(toDateTime('2012-01-01 12:20:00'), 600) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. +این برای جستجوی صفحات در جلسه مربوطه ضروری است. + +## formatDateTime(زمان فرمت \[منطقه زمانی\]) {#formatdatetime} + +Function formats a Time according given Format string. N.B.: Format is a constant expression, e.g. you can not have multiple formats for single result column. + +اصلاح کننده های پشتیبانی شده برای فرمت: +(“Example” ستون نتیجه قالب بندی برای زمان را نشان می دهد `2018-01-02 22:33:44`) + +| تغییردهنده | توصیف | مثال | +|------------|-----------------------------------------------------------------------------|------------| +| %C | سال تقسیم بر 100 و کوتاه به عدد صحیح (00-99) | 20 | +| \# د | روز از ماه, صفر خالی (01-31) | 02 | +| %D | کوتاه میلی متر/دی دی/یی تاریخ, معادل %متر/%د / %و | 01/02/18 | +| \# ا | روز از ماه, فضا خالی ( 1-31) | 2 | +| %F | کوتاه تاریخ یی-میلی متر-دی دی, معادل%و-%متر - % د | 2018-01-02 | +| %H | ساعت در فرمت 24 ساعت (00-23) | 22 | +| %I | ساعت در فرمت 12 ساعت (01-12) | 10 | +| \# ج | روز سال (001-366) | 002 | +| % متر | ماه به عنوان یک عدد اعشاری (01-12) | 01 | +| %M | دقیقه (00-59) | 33 | +| % ن | شخصیت جدید خط (") | | +| \# پ | هستم یا بعد از ظهر تعیین | PM | +| %R | 24-ساعت ساعت ساعت: زمان میلی متر, معادل %ساعت: % متر | 22:33 | +| %S | دوم (00-59) | 44 | +| % تی | شخصیت افقی تب (') | | +| %T | ایزو 8601 فرمت زمان (ساعت:میلی متر:اس اس), معادل %ساعت:%متر:%بازدید کنندگان | 22:33:44 | +| \# تو | ایزو 8601 روز هفته به عنوان شماره با دوشنبه به عنوان 1 (1-7) | 2 | +| %V | ایزو 8601 هفته شماره (01-53) | 01 | +| \# وات | روز هفته به عنوان یک عدد اعشاری با یکشنبه به عنوان 0 (0-6) | 2 | +| \#... | سال گذشته دو رقم (00-99) | 18 | +| %Y | سال | 2018 | +| %% | یک % نشانه | % | + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/fa/sql-reference/functions/encoding-functions.md b/docs/fa/sql-reference/functions/encoding-functions.md new file mode 100644 index 00000000000..761026075c9 --- /dev/null +++ b/docs/fa/sql-reference/functions/encoding-functions.md @@ -0,0 +1,175 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: "\u06A9\u062F\u0628\u0646\u062F\u06CC" +--- + +# توابع را پشتیبانی می کند {#encoding-functions} + +## کاراکتر {#char} + +بازگرداندن رشته با طول به عنوان تعدادی از استدلال گذشت و هر بایت دارای ارزش استدلال مربوطه. می پذیرد استدلال های متعدد از انواع عددی. اگر ارزش بحث خارج از محدوده UInt8 نوع داده آن است که تبدیل به UInt8 با امکان گرد کردن و سرریز. + +**نحو** + +``` sql +char(number_1, [number_2, ..., number_n]); +``` + +**پارامترها** + +- `number_1, number_2, ..., number_n` — Numerical arguments interpreted as integers. Types: [Int](../../sql-reference/data-types/int-uint.md), [شناور](../../sql-reference/data-types/float.md). + +**مقدار بازگشتی** + +- یک رشته از بایت داده. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello +``` + +نتیجه: + +``` text +┌─hello─┐ +│ hello │ +└───────┘ +``` + +شما می توانید یک رشته از رمزگذاری دلخواه با عبور از بایت مربوطه ساخت. در اینجا به عنوان مثال برای یونایتد-8 است: + +پرسوجو: + +``` sql +SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; +``` + +نتیجه: + +``` text +┌─hello──┐ +│ привет │ +└────────┘ +``` + +پرسوجو: + +``` sql +SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; +``` + +نتیجه: + +``` text +┌─hello─┐ +│ 你好 │ +└───────┘ +``` + +## هکس {#hex} + +بازگرداندن یک رشته حاوی نمایندگی هگزادسیمال استدلال. + +**نحو** + +``` sql +hex(arg) +``` + +تابع با استفاده از حروف بزرگ `A-F` و با استفاده از هیچ پیشوندها (مانند `0x`) یا پسوندها (مانند `h`). + +برای استدلال عدد صحیح رقم سحر و جادو را چاپ می کند (“nibbles”) از مهم ترین به حداقل قابل توجهی (اندی بزرگ یا “human readable” سفارش). این با مهم ترین بایت غیر صفر شروع می شود (پیشرو صفر بایت حذف می شوند) اما همیشه چاپ هر دو رقم از هر بایت حتی اگر رقم پیشرو صفر است. + +مثال: + +**مثال** + +پرسوجو: + +``` sql +SELECT hex(1); +``` + +نتیجه: + +``` text +01 +``` + +مقادیر نوع `Date` و `DateTime` به عنوان اعداد صحیح مربوطه فرمت (تعداد روز از عصر برای تاریخ و ارزش برچسب زمان یونیکس برای تاریخ ساعت داده). + +برای `String` و `FixedString`, تمام بایت به سادگی به عنوان دو عدد هگزادسیمال کد گذاری. صفر بایت حذف نشده است. + +ارزش های ممیز شناور و رقم اعشاری به عنوان نمایندگی خود را در حافظه کد گذاری. همانطور که ما از معماری اندیان کوچک حمایت می کنیم در اندی کوچک کد گذاری می شوند. صفر پیشرو / عقبی بایت حذف نشده است. + +**پارامترها** + +- `arg` — A value to convert to hexadecimal. Types: [رشته](../../sql-reference/data-types/string.md), [اینترنت](../../sql-reference/data-types/int-uint.md), [شناور](../../sql-reference/data-types/float.md), [دهدهی](../../sql-reference/data-types/decimal.md), [تاریخ](../../sql-reference/data-types/date.md) یا [DateTime](../../sql-reference/data-types/datetime.md). + +**مقدار بازگشتی** + +- یک رشته با نمایش هگزادسیمال استدلال. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); +``` + +نتیجه: + +``` text +┌─hex_presentation─┐ +│ 00007041 │ +│ 00008041 │ +└──────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); +``` + +نتیجه: + +``` text +┌─hex_presentation─┐ +│ 0000000000002E40 │ +│ 0000000000003040 │ +└──────────────────┘ +``` + +## unhex(str) {#unhexstr} + +می پذیرد یک رشته حاوی هر تعداد از رقم هگزادسیمال, و یک رشته حاوی بایت مربوطه را برمی گرداند. پشتیبانی از حروف بزرگ و کوچک تعداد ارقام هگزادسیمال ندارد به حتی. اگر عجیب و غریب است, رقم گذشته به عنوان نیمه حداقل قابل توجهی از بایت 00-0ف تفسیر. اگر رشته استدلال شامل هر چیزی غیر از رقم هگزادسیمال, برخی از نتیجه پیاده سازی تعریف بازگشته است (یک استثنا پرتاب نمی شود). +اگر شما می خواهید برای تبدیل نتیجه به یک عدد, شما می توانید با استفاده از ‘reverse’ و ‘reinterpretAsType’ توابع. + +## هشدار داده می شود) {#uuidstringtonumstr} + +می پذیرد یک رشته حاوی 36 کاراکتر در قالب `123e4567-e89b-12d3-a456-426655440000` و به عنوان مجموعه ای از بایت ها در یک رشته ثابت(16) باز می گردد. + +## هشدار داده می شود) {#uuidnumtostringstr} + +می پذیرد یک رشته ثابت (16) ارزش. بازگرداندن یک رشته حاوی 36 کاراکتر در قالب متن. + +## بیتماسکتولیست (عدد) {#bitmasktolistnum} + +می پذیرد یک عدد صحیح. بازگرداندن یک رشته حاوی لیستی از قدرت های دو که در مجموع تعداد منبع که خلاصه. با کاما از هم جدا بدون فاصله در قالب متن, به ترتیب صعودی. + +## هشدار داده می شود) {#bitmasktoarraynum} + +می پذیرد یک عدد صحیح. بازگرداندن مجموعه ای از اعداد اوینت64 حاوی لیستی از قدرت های دو که در مجموع تعداد منبع در هنگام خلاصه. اعداد به ترتیب صعودی هستند. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/fa/sql-reference/functions/ext-dict-functions.md b/docs/fa/sql-reference/functions/ext-dict-functions.md new file mode 100644 index 00000000000..204182cf3c1 --- /dev/null +++ b/docs/fa/sql-reference/functions/ext-dict-functions.md @@ -0,0 +1,206 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0648\u0627\u0698\u0647\u0646\u0627\u0645\ + \u0647\u0647\u0627 \u062E\u0627\u0631\u062C\u06CC" +--- + +# توابع برای کار با لغت نامه های خارجی {#ext_dict_functions} + +برای اطلاعات در مورد اتصال و پیکربندی لغت نامه های خارجی, دیدن [واژهنامهها خارجی](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +## دیکته کردن {#dictget} + +بازیابی یک مقدار از یک فرهنگ لغت خارجی. + +``` sql +dictGet('dict_name', 'attr_name', id_expr) +dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) +``` + +**پارامترها** + +- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `attr_name` — Name of the column of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `id_expr` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql-reference/data-types/int-uint.md) یا [تاپل](../../sql-reference/data-types/tuple.md)- نوع ارزش بسته به پیکربندی فرهنگ لغت . +- `default_value_expr` — Value returned if the dictionary doesn't contain a row with the `id_expr` کلید [عبارت](../syntax.md#syntax-expressions) بازگشت ارزش در نوع داده پیکربندی شده برای `attr_name` صفت کردن. + +**مقدار بازگشتی** + +- اگر تاتر تجزیه ویژگی موفقیت در [نوع داده خصیصه](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes), توابع بازگشت ارزش ویژگی فرهنگ لغت که مربوط به `id_expr`. + +- اگر هیچ کلید وجود دارد, مربوط به `id_expr`, در فرهنگ لغت, سپس: + + - `dictGet` returns the content of the `` element specified for the attribute in the dictionary configuration. + - `dictGetOrDefault` returns the value passed as the `default_value_expr` parameter. + +کلیک هاوس می اندازد یک استثنا اگر می تواند ارزش ویژگی تجزیه و یا ارزش می کند نوع داده ویژگی مطابقت ندارد. + +**مثال** + +ایجاد یک فایل متنی `ext-dict-text.csv` حاوی موارد زیر است: + +``` text +1,1 +2,2 +``` + +ستون اول است `id` ستون دوم `c1`. + +پیکربندی واژهنامه خارجی: + +``` xml + + + ext-dict-test + + + /path-to/ext-dict-test.csv + CSV + + + + + + + + id + + + c1 + UInt32 + + + + 0 + + +``` + +انجام پرس و جو: + +``` sql +SELECT + dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, + toTypeName(val) AS type +FROM system.numbers +LIMIT 3 +``` + +``` text +┌─val─┬─type───┐ +│ 1 │ UInt32 │ +│ 2 │ UInt32 │ +│ 20 │ UInt32 │ +└─────┴────────┘ +``` + +**همچنین نگاه کنید به** + +- [واژهنامهها خارجی](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) + +## دیکتس {#dicthas} + +بررسی اینکه یک کلید در حال حاضر در یک فرهنگ لغت است. + +``` sql +dictHas('dict_name', id_expr) +``` + +**پارامترها** + +- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `id_expr` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql-reference/data-types/int-uint.md)- نوع ارزش. + +**مقدار بازگشتی** + +- 0, اگر هیچ کلید وجود دارد. +- 1, اگر یک کلید وجود دارد. + +نوع: `UInt8`. + +## حکومت دیکتاتوری {#dictgethierarchy} + +یک مجموعه ای ایجاد می کند که شامل همه والدین یک کلید در [فرهنگ لغت سلسله مراتبی](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md). + +**نحو** + +``` sql +dictGetHierarchy('dict_name', key) +``` + +**پارامترها** + +- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `key` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql-reference/data-types/int-uint.md)- نوع ارزش. + +**مقدار بازگشتی** + +- پدر و مادر برای کلید. + +نوع: [Array(UInt64)](../../sql-reference/data-types/array.md). + +## دیکتاتوری {#dictisin} + +جد یک کلید را از طریق کل زنجیره سلسله مراتبی در فرهنگ لغت بررسی می کند. + +``` sql +dictIsIn('dict_name', child_id_expr, ancestor_id_expr) +``` + +**پارامترها** + +- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `child_id_expr` — Key to be checked. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql-reference/data-types/int-uint.md)- نوع ارزش. +- `ancestor_id_expr` — Alleged ancestor of the `child_id_expr` کلید [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql-reference/data-types/int-uint.md)- نوع ارزش. + +**مقدار بازگشتی** + +- 0 اگر `child_id_expr` یک کودک نیست `ancestor_id_expr`. +- 1 اگر `child_id_expr` یک کودک است `ancestor_id_expr` یا اگر `child_id_expr` یک `ancestor_id_expr`. + +نوع: `UInt8`. + +## توابع دیگر {#ext_dict_functions-other} + +تاتر پشتیبانی از توابع تخصصی است که تبدیل ارزش فرهنگ لغت ویژگی به یک نوع داده خاص بدون در نظر گرفتن پیکربندی فرهنگ لغت. + +توابع: + +- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` +- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` +- `dictGetFloat32`, `dictGetFloat64` +- `dictGetDate` +- `dictGetDateTime` +- `dictGetUUID` +- `dictGetString` + +همه این توابع `OrDefault` اصلاح. به عنوان مثال, `dictGetDateOrDefault`. + +نحو: + +``` sql +dictGet[Type]('dict_name', 'attr_name', id_expr) +dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) +``` + +**پارامترها** + +- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `attr_name` — Name of the column of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). +- `id_expr` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql-reference/data-types/int-uint.md)- نوع ارزش. +- `default_value_expr` — Value which is returned if the dictionary doesn't contain a row with the `id_expr` کلید [عبارت](../syntax.md#syntax-expressions) بازگشت یک مقدار در نوع داده پیکربندی شده برای `attr_name` صفت کردن. + +**مقدار بازگشتی** + +- اگر تاتر تجزیه ویژگی موفقیت در [نوع داده خصیصه](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes), توابع بازگشت ارزش ویژگی فرهنگ لغت که مربوط به `id_expr`. + +- در صورتی که هیچ درخواست وجود دارد `id_expr` در فرهنگ لغت و سپس: + + - `dictGet[Type]` returns the content of the `` element specified for the attribute in the dictionary configuration. + - `dictGet[Type]OrDefault` returns the value passed as the `default_value_expr` parameter. + +کلیک هاوس می اندازد یک استثنا اگر می تواند ارزش ویژگی تجزیه و یا ارزش می کند نوع داده ویژگی مطابقت ندارد. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/fa/sql-reference/functions/functions-for-nulls.md b/docs/fa/sql-reference/functions/functions-for-nulls.md new file mode 100644 index 00000000000..0415fc420d0 --- /dev/null +++ b/docs/fa/sql-reference/functions/functions-for-nulls.md @@ -0,0 +1,313 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 Nullable \u0627\u0633\u062A\u062F\u0644\ + \u0627\u0644" +--- + +# توابع برای کار با Nullable مصالح {#functions-for-working-with-nullable-aggregates} + +## isNull {#isnull} + +بررسی اینکه بحث چیست [NULL](../../sql-reference/syntax.md#null-literal). + +``` sql +isNull(x) +``` + +**پارامترها** + +- `x` — A value with a non-compound data type. + +**مقدار بازگشتی** + +- `1` اگر `x` هست `NULL`. +- `0` اگر `x` نیست `NULL`. + +**مثال** + +جدول ورودی + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +پرسوجو + +``` sql +SELECT x FROM t_null WHERE isNull(y) +``` + +``` text +┌─x─┐ +│ 1 │ +└───┘ +``` + +## اینترنت {#isnotnull} + +بررسی اینکه بحث چیست [NULL](../../sql-reference/syntax.md#null-literal). + +``` sql +isNotNull(x) +``` + +**پارامترها:** + +- `x` — A value with a non-compound data type. + +**مقدار بازگشتی** + +- `0` اگر `x` هست `NULL`. +- `1` اگر `x` نیست `NULL`. + +**مثال** + +جدول ورودی + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +پرسوجو + +``` sql +SELECT x FROM t_null WHERE isNotNull(y) +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## فلز کاری {#coalesce} + +چک از چپ به راست چه `NULL` استدلال به تصویب رسید و اولین غیر گرداند-`NULL` استدلال کردن. + +``` sql +coalesce(x,...) +``` + +**پارامترها:** + +- هر تعداد از پارامترهای یک نوع غیر مرکب. تمام پارامترها باید با نوع داده سازگار باشند. + +**مقادیر بازگشتی** + +- اولین غیر-`NULL` استدلال کردن. +- `NULL`, اگر همه استدلال ها `NULL`. + +**مثال** + +یک لیست از مخاطبین است که ممکن است راه های متعدد برای تماس با مشتری مشخص را در نظر بگیرید. + +``` text +┌─name─────┬─mail─┬─phone─────┬──icq─┐ +│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ +│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ +└──────────┴──────┴───────────┴──────┘ +``` + +این `mail` و `phone` زمینه های رشته نوع هستند, اما `icq` زمینه است `UInt32` بنابراین نیاز به تبدیل شدن به `String`. + +دریافت اولین روش تماس در دسترس برای مشتری از لیست تماس: + +``` sql +SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook +``` + +``` text +┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ +│ client 1 │ 123-45-67 │ +│ client 2 │ ᴺᵁᴸᴸ │ +└──────────┴──────────────────────────────────────────────────────┘ +``` + +## ifNull {#ifnull} + +بازگرداندن یک مقدار جایگزین اگر استدلال اصلی است `NULL`. + +``` sql +ifNull(x,alt) +``` + +**پارامترها:** + +- `x` — The value to check for `NULL`. +- `alt` — The value that the function returns if `x` هست `NULL`. + +**مقادیر بازگشتی** + +- مقدار `x` اگر `x` نیست `NULL`. +- مقدار `alt` اگر `x` هست `NULL`. + +**مثال** + +``` sql +SELECT ifNull('a', 'b') +``` + +``` text +┌─ifNull('a', 'b')─┐ +│ a │ +└──────────────────┘ +``` + +``` sql +SELECT ifNull(NULL, 'b') +``` + +``` text +┌─ifNull(NULL, 'b')─┐ +│ b │ +└───────────────────┘ +``` + +## nullIf {#nullif} + +بازگشت `NULL` اگر استدلال برابر هستند. + +``` sql +nullIf(x, y) +``` + +**پارامترها:** + +`x`, `y` — Values for comparison. They must be compatible types, or ClickHouse will generate an exception. + +**مقادیر بازگشتی** + +- `NULL`, اگر استدلال برابر هستند. +- این `x` ارزش, اگر استدلال برابر نیست. + +**مثال** + +``` sql +SELECT nullIf(1, 1) +``` + +``` text +┌─nullIf(1, 1)─┐ +│ ᴺᵁᴸᴸ │ +└──────────────┘ +``` + +``` sql +SELECT nullIf(1, 2) +``` + +``` text +┌─nullIf(1, 2)─┐ +│ 1 │ +└──────────────┘ +``` + +## قابل قبول {#assumenotnull} + +نتایج در ارزش نوع [Nullable](../../sql-reference/data-types/nullable.md) برای یک غیر- `Nullable`, اگر مقدار است `NULL`. + +``` sql +assumeNotNull(x) +``` + +**پارامترها:** + +- `x` — The original value. + +**مقادیر بازگشتی** + +- مقدار اصلی از غیر-`Nullable` نوع, اگر نیست `NULL`. +- مقدار پیش فرض برای غیر-`Nullable` نوع اگر مقدار اصلی بود `NULL`. + +**مثال** + +در نظر بگیرید که `t_null` جدول + +``` sql +SHOW CREATE TABLE t_null +``` + +``` text +┌─statement─────────────────────────────────────────────────────────────────┐ +│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ +└───────────────────────────────────────────────────────────────────────────┘ +``` + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +درخواست `assumeNotNull` تابع به `y` ستون. + +``` sql +SELECT assumeNotNull(y) FROM t_null +``` + +``` text +┌─assumeNotNull(y)─┐ +│ 0 │ +│ 3 │ +└──────────────────┘ +``` + +``` sql +SELECT toTypeName(assumeNotNull(y)) FROM t_null +``` + +``` text +┌─toTypeName(assumeNotNull(y))─┐ +│ Int8 │ +│ Int8 │ +└──────────────────────────────┘ +``` + +## قابل تنظیم {#tonullable} + +تبدیل نوع استدلال به `Nullable`. + +``` sql +toNullable(x) +``` + +**پارامترها:** + +- `x` — The value of any non-compound type. + +**مقدار بازگشتی** + +- مقدار ورودی با یک `Nullable` نوع. + +**مثال** + +``` sql +SELECT toTypeName(10) +``` + +``` text +┌─toTypeName(10)─┐ +│ UInt8 │ +└────────────────┘ +``` + +``` sql +SELECT toTypeName(toNullable(10)) +``` + +``` text +┌─toTypeName(toNullable(10))─┐ +│ Nullable(UInt8) │ +└────────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/fa/sql-reference/functions/geo.md b/docs/fa/sql-reference/functions/geo.md new file mode 100644 index 00000000000..31d13caba11 --- /dev/null +++ b/docs/fa/sql-reference/functions/geo.md @@ -0,0 +1,511 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 62 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0645\u062E\u062A\u0635\u0627\u062A \u062C\ + \u063A\u0631\u0627\u0641\u06CC\u0627\u06CC\u06CC" +--- + +# توابع برای کار با مختصات جغرافیایی {#functions-for-working-with-geographical-coordinates} + +## نمایش سایت {#greatcircledistance} + +محاسبه فاصله بین دو نقطه بر روی سطح زمین با استفاده از [فرمول دایره بزرگ](https://en.wikipedia.org/wiki/Great-circle_distance). + +``` sql +greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) +``` + +**پارامترهای ورودی** + +- `lon1Deg` — Longitude of the first point in degrees. Range: `[-180°, 180°]`. +- `lat1Deg` — Latitude of the first point in degrees. Range: `[-90°, 90°]`. +- `lon2Deg` — Longitude of the second point in degrees. Range: `[-180°, 180°]`. +- `lat2Deg` — Latitude of the second point in degrees. Range: `[-90°, 90°]`. + +مقادیر مثبت به طول و عرض جغرافیایی شمال شرق مطابقت, و مقادیر منفی به طول و عرض جغرافیایی جنوبی و طول جغرافیایی غرب مطابقت. + +**مقدار بازگشتی** + +فاصله بین دو نقطه بر روی سطح زمین, در متر. + +تولید یک استثنا زمانی که مقادیر پارامتر ورودی در خارج از محدوده قرار می گیرند. + +**مثال** + +``` sql +SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) +``` + +``` text +┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ +│ 14132374.194975413 │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## نقلقولهای جدید از این نویسنده {#pointinellipses} + +بررسی اینکه نقطه متعلق به حداقل یکی از بیضی. +مختصات هندسی در سیستم مختصات دکارتی هستند. + +``` sql +pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) +``` + +**پارامترهای ورودی** + +- `x, y` — Coordinates of a point on the plane. +- `xᵢ, yᵢ` — Coordinates of the center of the `i`- حذف هفتم . +- `aᵢ, bᵢ` — Axes of the `i`- حذف ت در واحد های ایکس, و مختصات. + +پارامترهای ورودی باید باشد `2+4⋅n` کجا `n` تعداد بیضی است. + +**مقادیر بازگشتی** + +`1` اگر نقطه در داخل حداقل یکی از بیضی; `0`اگر این طور نیست. + +**مثال** + +``` sql +SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) +``` + +``` text +┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ +│ 1 │ +└─────────────────────────────────────────────────┘ +``` + +## نقطه چین {#pointinpolygon} + +بررسی اینکه نقطه متعلق به چند ضلعی در هواپیما. + +``` sql +pointInPolygon((x, y), [(a, b), (c, d) ...], ...) +``` + +**مقادیر ورودی** + +- `(x, y)` — Coordinates of a point on the plane. Data type — [تاپل](../../sql-reference/data-types/tuple.md) — A tuple of two numbers. +- `[(a, b), (c, d) ...]` — Polygon vertices. Data type — [& حذف](../../sql-reference/data-types/array.md). هر راس است که توسط یک جفت مختصات نشان داده شده است `(a, b)`. راس باید در جهت عقربه های ساعت و یا در خلاف جهت عقربه مشخص شده است. حداقل تعداد راس است 3. چند ضلعی باید ثابت باشد. +- این تابع همچنین از چند ضلعی با سوراخ (برش بخش). در این مورد, اضافه چند ضلعی است که تعریف بخش برش با استفاده از استدلال های اضافی از تابع. تابع چند ضلعی غیر به سادگی متصل را پشتیبانی نمی کند. + +**مقادیر بازگشتی** + +`1` اگر نقطه در داخل چند ضلعی باشد, `0` اگر این طور نیست. +اگر نقطه در مرز چند ضلعی, تابع ممکن است یا بازگشت 0 یا 1. + +**مثال** + +``` sql +SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## کد جغرافیایی {#geohashencode} + +کد طول و عرض جغرافیایی به عنوان یک geohash-رشته مراجعه کنید (http://geohash.org/, https://en.wikipedia.org/wiki/Geohash). + +``` sql +geohashEncode(longitude, latitude, [precision]) +``` + +**مقادیر ورودی** + +- طول جغرافیایی-طول جغرافیایی بخشی از مختصات شما می خواهید به رمز. شناور در محدوده`[-180°, 180°]` +- عرض جغرافیایی-عرض جغرافیایی بخشی از مختصات شما می خواهید به رمز. شناور در محدوده `[-90°, 90°]` +- دقت-اختیاری, طول رشته کد گذاری نتیجه, به طور پیش فرض به `12`. عدد صحیح در محدوده `[1, 12]`. هر مقدار کمتر از `1` یا بیشتر از `12` در سکوت به تبدیل `12`. + +**مقادیر بازگشتی** + +- عدد و الفبایی `String` مختصات کد گذاری شده (نسخه اصلاح شده از الفبای باس32 رمزگذاری استفاده شده است). + +**مثال** + +``` sql +SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res +``` + +``` text +┌─res──────────┐ +│ ezs42d000000 │ +└──────────────┘ +``` + +## کد جغرافیایی {#geohashdecode} + +هر رشته جغرافیایی کد گذاری به طول و عرض جغرافیایی را رمزگشایی می کند. + +**مقادیر ورودی** + +- رشته کد گذاری-رشته جغرافیایی کد گذاری. + +**مقادیر بازگشتی** + +- (طول جغرافیایی, عرض جغرافیایی) - 2-تاپل از `Float64` ارزش طول و عرض جغرافیایی. + +**مثال** + +``` sql +SELECT geohashDecode('ezs42') AS res +``` + +``` text +┌─res─────────────────────────────┐ +│ (-5.60302734375,42.60498046875) │ +└─────────────────────────────────┘ +``` + +## جغرافیایی 3 {#geotoh3} + +بازگشت [H3](https://uber.github.io/h3/#/documentation/overview/introduction) شاخص نقطه `(lon, lat)` با وضوح مشخص شده است. + +[H3](https://uber.github.io/h3/#/documentation/overview/introduction) یک سیستم نمایه سازی جغرافیایی است که سطح زمین به کاشی های شش ضلعی حتی تقسیم شده است. این سیستم سلسله مراتبی است, به عنوان مثال. هر شش گوش در سطح بالا را می توان به هفت حتی اما کوچکتر و به همین ترتیب تقسیم. + +این شاخص در درجه اول برای مکان های جفتک انداختن و دیگر دستکاری های جغرافیایی استفاده می شود. + +**نحو** + +``` sql +geoToH3(lon, lat, resolution) +``` + +**پارامترها** + +- `lon` — Longitude. Type: [جسم شناور64](../../sql-reference/data-types/float.md). +- `lat` — Latitude. Type: [جسم شناور64](../../sql-reference/data-types/float.md). +- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- عدد شاخص شش گوش. +- 0 در صورت خطا. + +نوع: `UInt64`. + +**مثال** + +پرسوجو: + +``` sql +SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index +``` + +نتیجه: + +``` text +┌────────────h3Index─┐ +│ 644325524701193974 │ +└────────────────────┘ +``` + +## جعبه جواهر {#geohashesinbox} + +بازگرداندن مجموعه ای از رشته های جغرافیایی کد گذاری شده از دقت داده شده است که در داخل و تقاطع مرزهای جعبه داده شده قرار می گیرند, اساسا یک شبکه 2د مسطح به مجموعه. + +**مقادیر ورودی** + +- طولی-دقیقه طول جغرافیایی, ارزش شناور در محدوده `[-180°, 180°]` +- عرضی-دقیقه عرض جغرافیایی, ارزش شناور در محدوده `[-90°, 90°]` +- طولی-حداکثر طول جغرافیایی, ارزش شناور در محدوده `[-180°, 180°]` +- عرضی-حداکثر عرض جغرافیایی, ارزش شناور در محدوده `[-90°, 90°]` +- دقت-جغرافیایی دقیق, `UInt8` در محدوده `[1, 12]` + +لطفا توجه داشته باشید که تمام پارامترهای هماهنگ باید از همان نوع باشد: هم `Float32` یا `Float64`. + +**مقادیر بازگشتی** + +- مجموعه ای از رشته های دقت طولانی از زمینهاش جعبه پوشش منطقه فراهم, شما باید به ترتیب از اقلام تکیه نمی. +- \[\]- مجموعه خالی اگر *کمینه* ارزش *عرض جغرافیایی* و *طول جغرافیایی* کمتر از متناظر نیست *حداکثر* ارزشهای خبری عبارتند از: + +لطفا توجه داشته باشید که عملکرد یک استثنا را پرتاب می کند اگر مجموعه ای بیش از 10'000'000 باشد. + +**مثال** + +``` sql +SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos +``` + +``` text +┌─thasos──────────────────────────────────────┐ +│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ +└─────────────────────────────────────────────┘ +``` + +## هد3گتاسکل {#h3getbasecell} + +بازگرداندن تعداد سلول پایه از شاخص. + +**نحو** + +``` sql +h3GetBaseCell(index) +``` + +**پارامترها** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- شش گوش شماره سلول پایه. نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3GetBaseCell(612916788725809151) as basecell +``` + +نتیجه: + +``` text +┌─basecell─┐ +│ 12 │ +└──────────┘ +``` + +## ه3حکسرام2 {#h3hexaream2} + +میانگین منطقه شش گوش در متر مربع در وضوح داده شده. + +**نحو** + +``` sql +h3HexAreaM2(resolution) +``` + +**پارامترها** + +- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- Area in m². Type: [جسم شناور64](../../sql-reference/data-types/float.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3HexAreaM2(13) as area +``` + +نتیجه: + +``` text +┌─area─┐ +│ 43.9 │ +└──────┘ +``` + +## در حال بارگذاری {#h3indexesareneighbors} + +بازده یا نه فراهم هیندکس همسایه هستند. + +**نحو** + +``` sql +h3IndexesAreNeighbors(index1, index2) +``` + +**پارامترها** + +- `index1` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). +- `index2` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- بازگشت `1` اگر شاخص همسایه هستند, `0` وگرنه نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3IndexesAreNeighbors(617420388351344639, 617420388352655359) AS n +``` + +نتیجه: + +``` text +┌─n─┐ +│ 1 │ +└───┘ +``` + +## بچه گانه های 3 {#h3tochildren} + +بازگرداندن مجموعه ای با شاخص کودک از شاخص داده. + +**نحو** + +``` sql +h3ToChildren(index, resolution) +``` + +**پارامترها** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). +- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- با شاخص های اچ 3 کودک تنظیم کنید. مجموعه ای از نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3ToChildren(599405990164561919, 6) AS children +``` + +نتیجه: + +``` text +┌─children───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ [603909588852408319,603909588986626047,603909589120843775,603909589255061503,603909589389279231,603909589523496959,603909589657714687] │ +└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## ساعت 3 {#h3toparent} + +بازگرداندن پدر و مادر (درشت) شاخص حاوی شاخص داده. + +**نحو** + +``` sql +h3ToParent(index, resolution) +``` + +**پارامترها** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). +- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- شاخص اچ 3 پدر و مادر. نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3ToParent(599405990164561919, 3) as parent +``` + +نتیجه: + +``` text +┌─────────────parent─┐ +│ 590398848891879423 │ +└────────────────────┘ +``` + +## اچ 3 {#h3tostring} + +تبدیل نمایندگی هیندکس از شاخص به نمایندگی رشته. + +``` sql +h3ToString(index) +``` + +**پارامترها** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- نمایندگی رشته از شاخص اچ 3. نوع: [رشته](../../sql-reference/data-types/string.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3ToString(617420388352917503) as h3_string +``` + +نتیجه: + +``` text +┌─h3_string───────┐ +│ 89184926cdbffff │ +└─────────────────┘ +``` + +## استراینگتوه3 {#stringtoh3} + +تبدیل رشته به نمایندگی H3Index (UInt64) نمایندگی. + +``` sql +stringToH3(index_str) +``` + +**پارامترها** + +- `index_str` — String representation of the H3 index. Type: [رشته](../../sql-reference/data-types/string.md). + +**مقادیر بازگشتی** + +- عدد شاخص شش گوش. بازده 0 در خطا. نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT stringToH3('89184926cc3ffff') as index +``` + +نتیجه: + +``` text +┌──────────────index─┐ +│ 617420388351344639 │ +└────────────────────┘ +``` + +## انتقال انرژی 3 {#h3getresolution} + +بازگرداندن وضوح از شاخص. + +**نحو** + +``` sql +h3GetResolution(index) +``` + +**پارامترها** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مقادیر بازگشتی** + +- وضوح صفحه اول. گستره: `[0, 15]`. نوع: [UInt8](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT h3GetResolution(617420388352917503) as res +``` + +نتیجه: + +``` text +┌─res─┐ +│ 9 │ +└─────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/fa/sql-reference/functions/hash-functions.md b/docs/fa/sql-reference/functions/hash-functions.md new file mode 100644 index 00000000000..fae02d22950 --- /dev/null +++ b/docs/fa/sql-reference/functions/hash-functions.md @@ -0,0 +1,484 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: "\u0647\u0634" +--- + +# توابع هش {#hash-functions} + +توابع هش را می توان برای زدن شبه تصادفی قطعی از عناصر استفاده می شود. + +## نیم مترد5 {#hash-functions-halfmd5} + +[تفسیر](../../sql-reference/functions/type-conversion-functions.md#type_conversion_functions-reinterpretAsString) تمام پارامترهای ورودی به عنوان رشته ها و محاسبه [MD5](https://en.wikipedia.org/wiki/MD5) ارزش هش برای هر یک از. سپس هش ها را ترکیب می کند و اولین بایت 8 هش رشته حاصل را می گیرد و به عنوان تفسیر می کند `UInt64` به ترتیب بایت بزرگ اندی. + +``` sql +halfMD5(par1, ...) +``` + +تابع نسبتا کند است (5 میلیون رشته کوتاه در هر ثانیه در هر هسته پردازنده). +در نظر بگیرید با استفاده از [سیفون64](#hash_functions-siphash64) تابع به جای. + +**پارامترها** + +تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +A [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. + +**مثال** + +``` sql +SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type +``` + +``` text +┌────────halfMD5hash─┬─type───┐ +│ 186182704141653334 │ UInt64 │ +└────────────────────┴────────┘ +``` + +## MD5 {#hash_functions-md5} + +محاسبه ام دی 5 از یک رشته و مجموعه ای در نتیجه از بایت به عنوان رشته ثابت را برمی گرداند(16). +اگر شما ام دی 5 به طور خاص نیاز ندارد, اما شما نیاز به یک رمزنگاری مناسب و معقول هش 128 بیتی, استفاده از ‘sipHash128’ تابع به جای. +اگر شما می خواهید برای دریافت همان نتیجه به عنوان خروجی توسط ابزار موسسه خدمات مالی, استفاده از پایین تر(سحر و جادو کردن(توسعه هزاره5(بازدید کنندگان))). + +## سیفون64 {#hash_functions-siphash64} + +تولید 64 بیتی [سیفون](https://131002.net/siphash/) مقدار هش. + +``` sql +sipHash64(par1,...) +``` + +این یک تابع هش رمزنگاری است. این کار حداقل سه بار سریع تر از [MD5](#hash_functions-md5) تابع. + +تابع [تفسیر](../../sql-reference/functions/type-conversion-functions.md#type_conversion_functions-reinterpretAsString) تمام پارامترهای ورودی به عنوان رشته و محاسبه مقدار هش برای هر یک از. سپس هش ها را با الگوریتم زیر ترکیب می کند: + +1. پس از هش کردن تمام پارامترهای ورودی, تابع می شود مجموعه ای از رشته هش. +2. تابع عناصر اول و دوم را می گیرد و هش را برای مجموعه ای از این موارد محاسبه می کند. +3. سپس تابع مقدار هش را محاسبه می کند که در مرحله قبل محاسبه می شود و عنصر سوم هش های اولیه را محاسبه می کند و هش را برای مجموعه ای از انها محاسبه می کند. +4. گام قبلی برای تمام عناصر باقی مانده از مجموعه هش اولیه تکرار شده است. + +**پارامترها** + +تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +A [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. + +**مثال** + +``` sql +SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type +``` + +``` text +┌──────────────SipHash─┬─type───┐ +│ 13726873534472839665 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## سیفون128 {#hash_functions-siphash128} + +محاسبه سیفون از یک رشته. +می پذیرد استدلال رشته از نوع. را برمی گرداند رشته ثابت (16). +متفاوت از سیفون64 در که حالت نهایی صخره نوردی تاشو تنها تا 128 بیت انجام می شود. + +## 4تیهاش64 {#cityhash64} + +تولید 64 بیتی [هشدار داده می شود](https://github.com/google/cityhash) مقدار هش. + +``` sql +cityHash64(par1,...) +``` + +این یک تابع هش غیر رمزنگاری سریع است. با استفاده از الگوریتم سیتیاش برای پارامترهای رشته و اجرای خاص تابع هش غیر رمزنگاری سریع برای پارامترهای با انواع داده های دیگر. این تابع از ترکیب کننده سیتیاش برای دریافت نتایج نهایی استفاده می کند. + +**پارامترها** + +تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +A [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. + +**مثالها** + +مثال تماس: + +``` sql +SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type +``` + +``` text +┌─────────────CityHash─┬─type───┐ +│ 12072650598913549138 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +مثال زیر نشان می دهد که چگونه برای محاسبه کنترلی از کل جدول با دقت تا سفارش ردیف: + +``` sql +SELECT groupBitXor(cityHash64(*)) FROM table +``` + +## اینتش32 {#inthash32} + +محاسبه یک کد هش 32 بیتی از هر نوع عدد صحیح. +این یک تابع هش غیر رمزنگاری نسبتا سریع از کیفیت متوسط برای اعداد است. + +## اینتاش64 {#inthash64} + +محاسبه یک کد هش 64 بیتی از هر نوع عدد صحیح. +این کار سریع تر از اینتش32. میانگین کیفیت. + +## SHA1 {#sha1} + +## SHA224 {#sha224} + +## SHA256 {#sha256} + +محاسبه شا-1, شا-224, یا شا-256 از یک رشته و مجموعه ای در نتیجه از بایت به عنوان رشته گرداند(20), رشته ثابت(28), و یا رشته ثابت(32). +تابع کار می کند نسبتا کند (شا-1 پردازش در مورد 5 میلیون رشته کوتاه در هر ثانیه در هر هسته پردازنده, در حالی که شا-224 و شا-256 روند در مورد 2.2 میلیون). +ما توصیه می کنیم با استفاده از این تابع تنها در مواردی که شما نیاز به یک تابع هش خاص و شما می توانید انتخاب کنید. +حتی در این موارد توصیه می شود که از تابع به صورت افلاین استفاده کنید و مقادیر قبل از محاسبه هنگام وارد کردن جدول به جای استفاده در انتخاب ها. + +## نشانی اینترنتی\]) {#urlhashurl-n} + +یک تابع هش غیر رمزنگاری سریع و با کیفیت مناسب برای یک رشته از یک نشانی وب با استفاده از نوعی عادی سازی. +`URLHash(s)` – Calculates a hash from a string without one of the trailing symbols `/`,`?` یا `#` در پایان, اگر در حال حاضر. +`URLHash(s, N)` – Calculates a hash from a string up to the N level in the URL hierarchy, without one of the trailing symbols `/`,`?` یا `#` در پایان, اگر در حال حاضر. +سطح همان است که در هرج و مرج است. این تابع خاص به یاندکس است.متریکا + +## فرمان 64 {#farmhash64} + +تولید 64 بیتی [مزرعه دار](https://github.com/google/farmhash) مقدار هش. + +``` sql +farmHash64(par1, ...) +``` + +تابع با استفاده از `Hash64` روش از همه [روش های موجود](https://github.com/google/farmhash/blob/master/src/farmhash.h). + +**پارامترها** + +تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +A [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. + +**مثال** + +``` sql +SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type +``` + +``` text +┌─────────────FarmHash─┬─type───┐ +│ 17790458267262532859 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## جواهاش {#hash_functions-javahash} + +محاسبه [جواهاش](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) از یک رشته. این تابع هش نه سریع و نه با کیفیت خوب است. تنها دلیل استفاده از این است که این الگوریتم در حال حاضر در سیستم دیگری استفاده می شود و شما باید دقیقا همان نتیجه را محاسبه کنید. + +**نحو** + +``` sql +SELECT javaHash(''); +``` + +**مقدار بازگشتی** + +A `Int32` نوع داده مقدار هش. + +**مثال** + +پرسوجو: + +``` sql +SELECT javaHash('Hello, world!'); +``` + +نتیجه: + +``` text +┌─javaHash('Hello, world!')─┐ +│ -1880044555 │ +└───────────────────────────┘ +``` + +## جواهرشوتف16 {#javahashutf16le} + +محاسبه [جواهاش](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) از یک رشته, فرض کنید که شامل بایت به نمایندگی از یک رشته در رمزگذاری اوت-16ل. + +**نحو** + +``` sql +javaHashUTF16LE(stringUtf16le) +``` + +**پارامترها** + +- `stringUtf16le` — a string in UTF-16LE encoding. + +**مقدار بازگشتی** + +A `Int32` نوع داده مقدار هش. + +**مثال** + +درست پرس و جو با UTF-16LE کد گذاری رشته است. + +پرسوجو: + +``` sql +SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) +``` + +نتیجه: + +``` text +┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ +│ 3556498 │ +└──────────────────────────────────────────────────────────────┘ +``` + +## هیوهاش {#hash-functions-hivehash} + +محاسبه `HiveHash` از یک رشته. + +``` sql +SELECT hiveHash(''); +``` + +این فقط [جواهاش](#hash_functions-javahash) با کمی نشانه صفر کردن. این تابع در استفاده [زنبورک کندو](https://en.wikipedia.org/wiki/Apache_Hive) برای نسخه های قبل از 3.0. این تابع هش نه سریع و نه با کیفیت خوب است. تنها دلیل استفاده از این است که این الگوریتم در حال حاضر در سیستم دیگری استفاده می شود و شما باید دقیقا همان نتیجه را محاسبه کنید. + +**مقدار بازگشتی** + +A `Int32` نوع داده مقدار هش. + +نوع: `hiveHash`. + +**مثال** + +پرسوجو: + +``` sql +SELECT hiveHash('Hello, world!'); +``` + +نتیجه: + +``` text +┌─hiveHash('Hello, world!')─┐ +│ 267439093 │ +└───────────────────────────┘ +``` + +## متروهاش64 {#metrohash64} + +تولید 64 بیتی [متروهاش](http://www.jandrewrogers.com/2015/05/27/metrohash/) مقدار هش. + +``` sql +metroHash64(par1, ...) +``` + +**پارامترها** + +تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +A [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. + +**مثال** + +``` sql +SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type +``` + +``` text +┌────────────MetroHash─┬─type───┐ +│ 14235658766382344533 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## مورد احترام {#jumpconsistenthash} + +محاسبه JumpConsistentHash فرم UInt64. +می پذیرد دو استدلال: یک کلید بین 64 نوع و تعداد سطل. بازده Int32. +برای کسب اطلاعات بیشتر به لینک مراجعه کنید: [مورد احترام](https://arxiv.org/pdf/1406.2294.pdf) + +## سوفلش2\_32, سوفلشه2\_64 {#murmurhash2-32-murmurhash2-64} + +تولید یک [زمزمه 2](https://github.com/aappleby/smhasher) مقدار هش. + +``` sql +murmurHash2_32(par1, ...) +murmurHash2_64(par1, ...) +``` + +**پارامترها** + +هر دو توابع را به تعداد متغیر از پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +- این `murmurHash2_32` تابع را برمی گرداند مقدار هش داشتن [UInt32](../../sql-reference/data-types/int-uint.md) نوع داده. +- این `murmurHash2_64` تابع را برمی گرداند مقدار هش داشتن [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده. + +**مثال** + +``` sql +SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type +``` + +``` text +┌──────────MurmurHash2─┬─type───┐ +│ 11832096901709403633 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## اطلاعات دقیق {#gccmurmurhash} + +محاسبه 64 بیتی [زمزمه 2](https://github.com/aappleby/smhasher) مقدار هش با استفاده از همان دانه هش به عنوان [شورای همکاری خلیج فارس](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191). این قابل حمل بین کلانگ و شورای همکاری خلیج فارس ایجاد شده است. + +**نحو** + +``` sql +gccMurmurHash(par1, ...); +``` + +**پارامترها** + +- `par1, ...` — A variable number of parameters that can be any of the [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md#data_types). + +**مقدار بازگشتی** + +- محاسبه مقدار هش. + +نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT + gccMurmurHash(1, 2, 3) AS res1, + gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 +``` + +نتیجه: + +``` text +┌─────────────────res1─┬────────────────res2─┐ +│ 12384823029245979431 │ 1188926775431157506 │ +└──────────────────────┴─────────────────────┘ +``` + +## سوفلش3\_32, سوفلشه3\_64 {#murmurhash3-32-murmurhash3-64} + +تولید یک [سوفلهاش3](https://github.com/aappleby/smhasher) مقدار هش. + +``` sql +murmurHash3_32(par1, ...) +murmurHash3_64(par1, ...) +``` + +**پارامترها** + +هر دو توابع را به تعداد متغیر از پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql-reference/data-types/index.md). + +**مقدار بازگشتی** + +- این `murmurHash3_32` تابع یک [UInt32](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. +- این `murmurHash3_64` تابع یک [UInt64](../../sql-reference/data-types/int-uint.md) نوع داده مقدار هش. + +**مثال** + +``` sql +SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type +``` + +``` text +┌─MurmurHash3─┬─type───┐ +│ 2152717 │ UInt32 │ +└─────────────┴────────┘ +``` + +## سوفلش3\_128 {#murmurhash3-128} + +تولید 128 بیتی [سوفلهاش3](https://github.com/aappleby/smhasher) مقدار هش. + +``` sql +murmurHash3_128( expr ) +``` + +**پارامترها** + +- `expr` — [عبارتها](../syntax.md#syntax-expressions) بازگشت یک [رشته](../../sql-reference/data-types/string.md)- نوع ارزش. + +**مقدار بازگشتی** + +A [رشته ثابت (16)](../../sql-reference/data-types/fixedstring.md) نوع داده مقدار هش. + +**مثال** + +``` sql +SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type +``` + +``` text +┌─MurmurHash3──────┬─type────────────┐ +│ 6�1�4"S5KT�~~q │ FixedString(16) │ +└──────────────────┴─────────────────┘ +``` + +## بیست و 3264 {#hash-functions-xxhash32} + +محاسبه `xxHash` از یک رشته. این است که در دو طعم پیشنهاد, 32 و 64 بیت. + +``` sql +SELECT xxHash32(''); + +OR + +SELECT xxHash64(''); +``` + +**مقدار بازگشتی** + +A `Uint32` یا `Uint64` نوع داده مقدار هش. + +نوع: `xxHash`. + +**مثال** + +پرسوجو: + +``` sql +SELECT xxHash32('Hello, world!'); +``` + +نتیجه: + +``` text +┌─xxHash32('Hello, world!')─┐ +│ 834093149 │ +└───────────────────────────┘ +``` + +**همچنین نگاه کنید به** + +- [معلم](http://cyan4973.github.io/xxHash/). + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/fa/sql-reference/functions/higher-order-functions.md b/docs/fa/sql-reference/functions/higher-order-functions.md new file mode 100644 index 00000000000..ca0f56bbafe --- /dev/null +++ b/docs/fa/sql-reference/functions/higher-order-functions.md @@ -0,0 +1,264 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "\u0628\u0627\u0644\u0627\u062A\u0631 \u0633\u0641\u0627\u0631\u0634" +--- + +# توابع مرتبه بالاتر {#higher-order-functions} + +## `->` اپراتور, لامبدا (پارامترهای, اکسپر) تابع {#operator-lambdaparams-expr-function} + +Allows describing a lambda function for passing to a higher-order function. The left side of the arrow has a formal parameter, which is any ID, or multiple formal parameters – any IDs in a tuple. The right side of the arrow has an expression that can use these formal parameters, as well as any table columns. + +مثالها: `x -> 2 * x, str -> str != Referer.` + +توابع مرتبه بالاتر تنها می تواند توابع لامبدا به عنوان استدلال عملکردی خود را قبول. + +یک تابع لامبدا که استدلال های متعدد می پذیرد را می توان به یک تابع مرتبه بالاتر منتقل می شود. در این مورد, تابع مرتبه بالاتر به تصویب می رسد چند مجموعه ای از طول یکسان است که این استدلال به مطابقت. + +برای برخی از توابع مانند [پیاده کردن](#higher_order_functions-array-count) یا [ارریسوم](#higher_order_functions-array-count), استدلال اول (تابع لامبدا) را می توان حذف. در این مورد, نقشه برداری یکسان فرض شده است. + +یک تابع لامبدا را نمی توان برای توابع زیر حذف کرد: + +- [اررایماپ](#higher_order_functions-array-map) +- [شلوار لی](#higher_order_functions-array-filter) +- [شلوار لی](#higher_order_functions-array-fill) +- [نمایش سایت](#higher_order_functions-array-reverse-fill) +- [لرزش دستگاه](#higher_order_functions-array-split) +- [نمایش سایت](#higher_order_functions-array-reverse-split) +- [دریافیرست](#higher_order_functions-array-first) +- [نمایش سایت](#higher_order_functions-array-first-index) + +### arrayMap(func, arr1, …) {#higher_order_functions-array-map} + +بازگرداندن مجموعه ای از برنامه اصلی `func` عملکرد به هر عنصر در `arr` صف کردن. + +مثالها: + +``` sql +SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [3,4,5] │ +└─────────┘ +``` + +مثال زیر نشان می دهد که چگونه برای ایجاد یک تاپل از عناصر از مجموعه های مختلف: + +``` sql +SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res +``` + +``` text +┌─res─────────────────┐ +│ [(1,4),(2,5),(3,6)] │ +└─────────────────────┘ +``` + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayMap` تابع. + +### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} + +بازگرداندن مجموعه ای حاوی تنها عناصر در `arr1` برای کدام `func` چیزی غیر از 0 را برمی گرداند. + +مثالها: + +``` sql +SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res +``` + +``` text +┌─res───────────┐ +│ ['abc World'] │ +└───────────────┘ +``` + +``` sql +SELECT + arrayFilter( + (i, x) -> x LIKE '%World%', + arrayEnumerate(arr), + ['Hello', 'abc World'] AS arr) + AS res +``` + +``` text +┌─res─┐ +│ [2] │ +└─────┘ +``` + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFilter` تابع. + +### arrayFill(func, arr1, …) {#higher_order_functions-array-fill} + +پویش از طریق `arr1` از عنصر اول به عنصر گذشته و جایگزین `arr1[i]` توسط `arr1[i - 1]` اگر `func` بازده 0. اولین عنصر `arr1` جایگزین نخواهد شد. + +مثالها: + +``` sql +SELECT arrayFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res +``` + +``` text +┌─res──────────────────────────────┐ +│ [1,1,3,11,12,12,12,5,6,14,14,14] │ +└──────────────────────────────────┘ +``` + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFill` تابع. + +### arrayReverseFill(func, arr1, …) {#higher_order_functions-array-reverse-fill} + +پویش از طریق `arr1` از عنصر گذشته به عنصر اول و جایگزین `arr1[i]` توسط `arr1[i + 1]` اگر `func` بازده 0. عنصر گذشته از `arr1` جایگزین نخواهد شد. + +مثالها: + +``` sql +SELECT arrayReverseFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res +``` + +``` text +┌─res────────────────────────────────┐ +│ [1,3,3,11,12,5,5,5,6,14,NULL,NULL] │ +└────────────────────────────────────┘ +``` + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayReverseFill` تابع. + +### arraySplit(func, arr1, …) {#higher_order_functions-array-split} + +شکافتن `arr1` به چندین ردیف چه زمانی `func` بازگرداندن چیزی غیر از 0, مجموعه خواهد شد در سمت چپ عنصر تقسیم. مجموعه قبل از اولین عنصر تقسیم نخواهد شد. + +مثالها: + +``` sql +SELECT arraySplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res +``` + +``` text +┌─res─────────────┐ +│ [[1,2,3],[4,5]] │ +└─────────────────┘ +``` + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arraySplit` تابع. + +### arrayReverseSplit(func, arr1, …) {#higher_order_functions-array-reverse-split} + +شکافتن `arr1` به چندین ردیف چه زمانی `func` بازگرداندن چیزی غیر از 0, مجموعه خواهد شد در سمت راست عنصر تقسیم. مجموعه پس از عنصر گذشته تقسیم نخواهد شد. + +مثالها: + +``` sql +SELECT arrayReverseSplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res +``` + +``` text +┌─res───────────────┐ +│ [[1],[2,3,4],[5]] │ +└───────────────────┘ +``` + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arraySplit` تابع. + +### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} + +بازگرداندن تعدادی از عناصر در مجموعه ارر که فارک چیزی غیر از گرداند 0. اگر ‘func’ مشخص نشده است, تعداد عناصر غیر صفر گرداند در مجموعه. + +### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} + +بازده 1 اگر حداقل یک عنصر در وجود دارد ‘arr’ برای کدام ‘func’ چیزی غیر از 0 را برمی گرداند. در غیر این صورت, باز می گردد 0. + +### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} + +بازده 1 اگر ‘func’ چیزی غیر از 0 را برای تمام عناصر در ‘arr’. در غیر این صورت, باز می گردد 0. + +### arraySum(\[func,\] arr1, …) {#higher-order-functions-array-sum} + +بازگرداندن مجموع ‘func’ ارزشهای خبری عبارتند از: اگر تابع حذف شده است, فقط می گرداند مجموع عناصر مجموعه. + +### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} + +بازگرداندن اولین عنصر در ‘arr1’ تنظیم برای کدام ‘func’ چیزی غیر از 0 را برمی گرداند. + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFirst` تابع. + +### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} + +بازگرداندن شاخص عنصر اول در ‘arr1’ تنظیم برای کدام ‘func’ چیزی غیر از 0 را برمی گرداند. + +توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFirstIndex` تابع. + +### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} + +بازگرداندن مجموعه ای از مبالغ بخشی از عناصر در مجموعه منبع (مجموع در حال اجرا). اگر `func` تابع مشخص شده است, سپس ارزش عناصر مجموعه توسط این تابع قبل از جمع تبدیل. + +مثال: + +``` sql +SELECT arrayCumSum([1, 1, 1, 1]) AS res +``` + +``` text +┌─res──────────┐ +│ [1, 2, 3, 4] │ +└──────────────┘ +``` + +### هشدار داده می شود) {#arraycumsumnonnegativearr} + +مثل `arrayCumSum`, بازگرداندن مجموعه ای از مبالغ بخشی از عناصر در مجموعه منبع (مجموع در حال اجرا). متفاوت `arrayCumSum`, هنگامی که ارزش سپس بازگشت شامل یک مقدار کمتر از صفر, ارزش است جایگزین با صفر و محاسبه بعدی با صفر پارامترهای انجام. به عنوان مثال: + +``` sql +SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res +``` + +``` text +┌─res───────┐ +│ [1,2,0,1] │ +└───────────┘ +``` + +### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} + +بازگرداندن مجموعه ای به عنوان نتیجه مرتب سازی عناصر `arr1` به ترتیب صعودی. اگر `func` تابع مشخص شده است, مرتب سازی سفارش توسط نتیجه تابع تعیین `func` اعمال شده به عناصر مجموعه (ارریس) + +این [تبدیل شوارتز](https://en.wikipedia.org/wiki/Schwartzian_transform) برای بهبود کارایی مرتب سازی استفاده می شود. + +مثال: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); +``` + +``` text +┌─res────────────────┐ +│ ['world', 'hello'] │ +└────────────────────┘ +``` + +برای کسب اطلاعات بیشتر در مورد `arraySort` روش, دیدن [توابع برای کار با ارریس](array-functions.md#array_functions-sort) بخش. + +### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} + +بازگرداندن مجموعه ای به عنوان نتیجه مرتب سازی عناصر `arr1` به ترتیب نزولی. اگر `func` تابع مشخص شده است, مرتب سازی سفارش توسط نتیجه تابع تعیین `func` اعمال شده به عناصر مجموعه ای (ارریس). + +مثال: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +برای کسب اطلاعات بیشتر در مورد `arrayReverseSort` روش, دیدن [توابع برای کار با ارریس](array-functions.md#array_functions-reverse-sort) بخش. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/fa/sql-reference/functions/in-functions.md b/docs/fa/sql-reference/functions/in-functions.md new file mode 100644 index 00000000000..9c47b25135c --- /dev/null +++ b/docs/fa/sql-reference/functions/in-functions.md @@ -0,0 +1,27 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 60 +toc_title: "\u0627\u062C\u0631\u0627\u06CC \u0627\u067E\u0631\u0627\u062A\u0648\u0631\ + \ \u062F\u0631" +--- + +# توابع برای اجرای اپراتور در {#functions-for-implementing-the-in-operator} + +## در notIn, globalIn, globalNotIn {#in-functions} + +بخش را ببینید [در اپراتورها](../operators/in.md#select-in-operators). + +## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} + +یک تابع است که اجازه می دهد تا گروه بندی ستون های متعدد. +For columns with the types T1, T2, …, it returns a Tuple(T1, T2, …) type tuple containing these columns. There is no cost to execute the function. +تاپل به طور معمول به عنوان مقادیر متوسط برای بحث در اپراتورها و یا برای ایجاد یک لیست از پارامترهای رسمی توابع لامبدا استفاده می شود. تاپل را نمی توان به یک جدول نوشته شده است. + +## هشدار داده می شود {#tupleelementtuple-n-operator-x-n} + +یک تابع است که اجازه می دهد تا گرفتن یک ستون از یک تاپل. +‘N’ شاخص ستون است, با شروع از 1. نفر باید ثابت باشد. ‘N’ باید ثابت باشه ‘N’ باید یک عدد صحیح انتخابی سخت نه بیشتر از اندازه تاپل باشد. +هیچ هزینه ای برای اجرای تابع وجود دارد. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/fa/sql-reference/functions/index.md b/docs/fa/sql-reference/functions/index.md new file mode 100644 index 00000000000..e6e6c162f2a --- /dev/null +++ b/docs/fa/sql-reference/functions/index.md @@ -0,0 +1,74 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u062A\u0648\u0627\u0628\u0639" +toc_priority: 32 +toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" +--- + +# توابع {#functions} + +حداقل\* دو نوع از توابع وجود دارد - توابع به طور منظم (فقط به نام “functions”) and aggregate functions. These are completely different concepts. Regular functions work as if they are applied to each row separately (for each row, the result of the function doesn't depend on the other rows). Aggregate functions accumulate a set of values from various rows (i.e. they depend on the entire set of rows). + +در این بخش ما در مورد توابع به طور منظم. برای توابع کل, بخش را ببینید “Aggregate functions”. + +\* - یک نوع سوم از تابع که وجود دارد ‘arrayJoin’ توابع جدول همچنین می توانید به طور جداگانه ذکر شود.\* + +## تایپ قوی {#strong-typing} + +در مقابل به گذاشتن استاندارد, خانه رعیتی است تایپ قوی. به عبارت دیگر تبدیل ضمنی بین انواع را ندارد. هر تابع برای یک مجموعه خاص از انواع کار می کند. این به این معنی است که گاهی اوقات شما نیاز به استفاده از توابع تبدیل نوع. + +## رفع ضعف مشترک {#common-subexpression-elimination} + +همه عبارات در پرس و جو که همان اعضای هیات (همان رکورد و یا همان نتیجه تجزیه نحوی) در نظر گرفته به ارزش یکسان. چنین عبارات یک بار تایید و اجرا می شوند. زیرمجموعه های یکسان نیز این راه را حذف می کنند. + +## انواع نتایج {#types-of-results} + +همه توابع بازگشت بازگشت بازگشت تنها به عنوان نتیجه (چند ارزش نیست, و نه صفر ارزش). نوع نتیجه است که معمولا تنها با انواع استدلال تعریف, نه با ارزش. استثنا هستند tupleElement function (a.N اپراتور) و toFixedString تابع. + +## ثابتها {#constants} + +برای سادگی, توابع خاص تنها می تواند با ثابت برای برخی از استدلال کار. مثلا, استدلال درست از اپراتور مانند باید ثابت باشد. +تقریبا تمام توابع بازگشت ثابت برای استدلال ثابت. استثنا توابع است که تولید اعداد تصادفی است. +این ‘now’ تابع مقادیر مختلف برای نمایش داده شد که در زمان های مختلف اجرا شد را برمی گرداند, اما نتیجه در نظر گرفته ثابت, از ثبات در یک پرس و جو تنها مهم است. +یک عبارت ثابت نیز ثابت در نظر گرفته (مثلا, نیمه راست اپراتور مانند را می توان از ثابت های متعدد ساخته). + +توابع را می توان به روش های مختلف برای استدلال ثابت و غیر ثابت اجرا (کد های مختلف اجرا شده است). اما نتایج برای یک ثابت و برای یک ستون واقعی حاوی تنها همان مقدار باید با یکدیگر مطابقت. + +## پردازش پوچ {#null-processing} + +توابع رفتارهای زیر را دارند: + +- اگر حداقل یکی از استدلال از تابع است `NULL` نتیجه عملکرد نیز است `NULL`. +- رفتار ویژه ای است که به صورت جداگانه در شرح هر تابع مشخص. در کد منبع کلیک این توابع `UseDefaultImplementationForNulls=false`. + +## پایداری {#constancy} + +Functions can't change the values of their arguments – any changes are returned as the result. Thus, the result of calculating separate functions does not depend on the order in which the functions are written in the query. + +## خطا {#error-handling} + +برخی از توابع ممکن است یک استثنا پرتاب اگر داده نامعتبر است. در این مورد پرس و جو لغو شده است و یک متن خطا به مشتری بازگردانده می شود. برای پردازش توزیع, هنگامی که یک استثنا در یکی از سرورهای رخ می دهد, سرور های دیگر نیز تلاش برای لغو پرس و جو. + +## ارزیابی عبارات استدلال {#evaluation-of-argument-expressions} + +تقریبا در تمام زبان های برنامه نویسی, یکی از استدلال ممکن است برای اپراتورهای خاص ارزیابی نمی شود. این است که معمولا اپراتورها `&&`, `||` و `?:`. +اما در فاحشه خانه, استدلال از توابع (اپراتورهای) همیشه مورد بررسی قرار. دلیل این است که کل بخش هایی از ستون ها در یک بار مورد بررسی قرار, به جای محاسبه هر سطر به طور جداگانه. + +## انجام توابع برای پردازش پرس و جو توزیع شده {#performing-functions-for-distributed-query-processing} + +برای پردازش پرس و جو توزیع, به عنوان بسیاری از مراحل پردازش پرس و جو که ممکن است بر روی سرور از راه دور انجام, و بقیه مراحل (ادغام نتایج متوسط و همه چیز که) بر روی سرور درخواست انجام. + +این به این معنی است که توابع را می توان بر روی سرور های مختلف انجام می شود. +برای مثال در پرس و جو `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` + +- اگر یک `distributed_table` دارای حداقل دو خرده ریز, توابع ‘g’ و ‘h’ بر روی سرورهای راه دور و عملکرد انجام می شود ‘f’ بر روی سرور درخواست کننده انجام می شود. +- اگر یک `distributed_table` تنها یک سفال, تمام ‘f’, ‘g’ و ‘h’ توابع بر روی سرور این سفال انجام. + +نتیجه یک تابع معمولا بستگی ندارد که سرور انجام شده است. اما گاهی اوقات این مهم است. +مثلا, توابع است که با لغت نامه کار استفاده از فرهنگ لغت که بر روی سرور وجود دارد که در حال اجرا هستند در. +مثال دیگر این است که `hostName` تابع, که نام سرور را بر می گرداند در حال اجرا است به منظور ایجاد `GROUP BY` توسط سرور در یک `SELECT` پرس و جو. + +اگر یک تابع در یک پرس و جو بر روی سرور درخواست انجام, اما شما نیاز به انجام این کار بر روی سرور از راه دور, شما می توانید در یک بسته بندی ‘any’ تابع جمع و یا اضافه کردن به یک کلید در `GROUP BY`. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/fa/sql-reference/functions/introspection.md b/docs/fa/sql-reference/functions/introspection.md new file mode 100644 index 00000000000..3f47fa77943 --- /dev/null +++ b/docs/fa/sql-reference/functions/introspection.md @@ -0,0 +1,310 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 65 +toc_title: "\u062F\u0631\u0648\u0646 \u0646\u06AF\u0631\u06CC" +--- + +# توابع درون گرایی {#introspection-functions} + +شما می توانید توابع شرح داده شده در این فصل به درون نگری استفاده کنید [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) و [DWARF](https://en.wikipedia.org/wiki/DWARF) برای پروفایل پرس و جو. + +!!! warning "اخطار" + این توابع کند هستند و ممکن است ملاحظات امنیتی تحمیل کنند. + +برای بهره برداری مناسب از توابع درون گرایی: + +- نصب `clickhouse-common-static-dbg` بسته + +- تنظیم [اجازه دادن به \_فعال کردن اختلال در عملکرد](../../operations/settings/settings.md#settings-allow_introspection_functions) تنظیم به 1. + + For security reasons introspection functions are disabled by default. + +تاتر موجب صرفه جویی در گزارش نیمرخ به [\_قطع](../../operations/system-tables.md#system_tables-trace_log) جدول سیستم. اطمینان حاصل کنید که جدول و پیشفیلتر به درستی پیکربندی شده است. + +## افزودن مدخل جدید {#addresstoline} + +تبدیل آدرس حافظه مجازی در داخل ClickHouse فرایند سرور به نام فایل و شماره خط در ClickHouse کد منبع. + +اگر شما استفاده از بسته های رسمی تاتر, شما نیاز به نصب `clickhouse-common-static-dbg` بسته + +**نحو** + +``` sql +addressToLine(address_of_binary_instruction) +``` + +**پارامترها** + +- `address_of_binary_instruction` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Address of instruction in a running process. + +**مقدار بازگشتی** + +- نام فایل کد منبع و شماره خط در این فایل حد و مرز مشخصی توسط روده بزرگ. + + For example, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, where `199` is a line number. + +- نام یک باینری, اگر تابع می تواند اطلاعات اشکال زدایی پیدا کنید. + +- رشته خالی, اگر نشانی معتبر نیست. + +نوع: [رشته](../../sql-reference/data-types/string.md). + +**مثال** + +فعال کردن توابع درون گرایی: + +``` sql +SET allow_introspection_functions=1 +``` + +انتخاب رشته اول از `trace_log` جدول سیستم: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-19 +event_time: 2019-11-19 18:57:23 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 421b6855-1858-45a5-8f37-f383409d6d72 +trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] +``` + +این `trace` درست شامل ردیابی پشته در حال حاضر نمونه برداری. + +گرفتن نام فایل کد منبع و شماره خط برای یک نشانی واحد: + +``` sql +SELECT addressToLine(94784076370703) \G +``` + +``` text +Row 1: +────── +addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +``` + +استفاده از تابع به ردیابی کل پشته: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines +FROM system.trace_log +LIMIT 1 +\G +``` + +این [اررایماپ](higher-order-functions.md#higher_order_functions-array-map) تابع اجازه می دهد تا برای پردازش هر عنصر منحصر به فرد از `trace` تنظیم توسط `addressToLine` تابع. نتیجه این پردازش شما در دیدن `trace_source_code_lines` ستون خروجی. + +``` text +Row 1: +────── +trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so +/usr/lib/debug/usr/bin/clickhouse +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 +/usr/include/c++/9/bits/atomic_base.h:551 +/usr/lib/debug/usr/bin/clickhouse +/lib/x86_64-linux-gnu/libpthread-2.27.so +/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 +``` + +## افزودن موقعیت {#addresstosymbol} + +تبدیل آدرس حافظه مجازی در داخل ClickHouse سرور روند به نمادی از ClickHouse شی فایل های. + +**نحو** + +``` sql +addressToSymbol(address_of_binary_instruction) +``` + +**پارامترها** + +- `address_of_binary_instruction` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Address of instruction in a running process. + +**مقدار بازگشتی** + +- نماد از فایل های شی کلیکهاوس. +- رشته خالی, اگر نشانی معتبر نیست. + +نوع: [رشته](../../sql-reference/data-types/string.md). + +**مثال** + +فعال کردن توابع درون گرایی: + +``` sql +SET allow_introspection_functions=1 +``` + +انتخاب رشته اول از `trace_log` جدول سیستم: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +این `trace` درست شامل ردیابی پشته در حال حاضر نمونه برداری. + +گرفتن نماد برای یک نشانی واحد: + +``` sql +SELECT addressToSymbol(94138803686098) \G +``` + +``` text +Row 1: +────── +addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +``` + +استفاده از تابع به ردیابی کل پشته: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols +FROM system.trace_log +LIMIT 1 +\G +``` + +این [اررایماپ](higher-order-functions.md#higher_order_functions-array-map) تابع اجازه می دهد تا برای پردازش هر عنصر منحصر به فرد از `trace` تنظیم توسط `addressToSymbols` تابع. نتیجه این پردازش شما در دیدن `trace_symbols` ستون خروجی. + +``` text +Row 1: +────── +trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE +_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb +_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb +_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE +_ZN2DB27AggregatingBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB28AsynchronousBlockInputStream9calculateEv +_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data +_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E +_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv +_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E +execute_native_thread_routine +start_thread +clone +``` + +## درهم و برهم کردن {#demangle} + +تبدیل یک نماد است که شما می توانید با استفاده از [افزودن موقعیت](#addresstosymbol) تابع به ج++ نام تابع. + +**نحو** + +``` sql +demangle(symbol) +``` + +**پارامترها** + +- `symbol` ([رشته](../../sql-reference/data-types/string.md)) — Symbol from an object file. + +**مقدار بازگشتی** + +- نام تابع ج++. +- رشته خالی اگر یک نماد معتبر نیست. + +نوع: [رشته](../../sql-reference/data-types/string.md). + +**مثال** + +فعال کردن توابع درون گرایی: + +``` sql +SET allow_introspection_functions=1 +``` + +انتخاب رشته اول از `trace_log` جدول سیستم: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +این `trace` درست شامل ردیابی پشته در حال حاضر نمونه برداری. + +گرفتن نام تابع برای یک نشانی واحد: + +``` sql +SELECT demangle(addressToSymbol(94138803686098)) \G +``` + +``` text +Row 1: +────── +demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +``` + +استفاده از تابع به ردیابی کل پشته: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions +FROM system.trace_log +LIMIT 1 +\G +``` + +این [اررایماپ](higher-order-functions.md#higher_order_functions-array-map) تابع اجازه می دهد تا برای پردازش هر عنصر منحصر به فرد از `trace` تنظیم توسط `demangle` تابع. نتیجه این پردازش شما در دیدن `trace_functions` ستون خروجی. + +``` text +Row 1: +────── +trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const +DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) +DB::AggregatingBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::AsynchronousBlockInputStream::calculate() +std::_Function_handler::_M_invoke(std::_Any_data const&) +ThreadPoolImpl::worker(std::_List_iterator) +ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const +ThreadPoolImpl::worker(std::_List_iterator) +execute_native_thread_routine +start_thread +clone +``` diff --git a/docs/fa/sql-reference/functions/ip-address-functions.md b/docs/fa/sql-reference/functions/ip-address-functions.md new file mode 100644 index 00000000000..12a43878fdf --- /dev/null +++ b/docs/fa/sql-reference/functions/ip-address-functions.md @@ -0,0 +1,249 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 55 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0646\u0634\u0627\u0646\u06CC\u0647\u0627\ + \u06CC \u0627\u06CC\u0646\u062A\u0631\u0646\u062A\u06CC" +--- + +# توابع برای کار با نشانی های اینترنتی {#functions-for-working-with-ip-addresses} + +## اطلاعات دقیق) {#ipv4numtostringnum} + +طول می کشد یک UInt32 شماره. به عنوان یک نشانی اینترنتی 4 در اندی بزرگ تفسیر می کند. بازده یک رشته حاوی مربوطه آدرس IPv4 در قالب A. B. C. d (نقطه جدا کردن اعداد در شکل اعشاری). + +## مدت 4 ساعت) {#ipv4stringtonums} + +عملکرد معکوس ایپو4نومتوسترینگ. اگر نشانی اینترنتی4 دارای یک فرمت نامعتبر, باز می گردد 0. + +## اطلاعات دقیق) {#ipv4numtostringclasscnum} + +شبیه به IPv4NumToString اما با استفاده از \ به جای گذشته هشت تایی. + +مثال: + +``` sql +SELECT + IPv4NumToStringClassC(ClientIP) AS k, + count() AS c +FROM test.hits +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─k──────────────┬─────c─┐ +│ 83.149.9.xxx │ 26238 │ +│ 217.118.81.xxx │ 26074 │ +│ 213.87.129.xxx │ 25481 │ +│ 83.149.8.xxx │ 24984 │ +│ 217.118.83.xxx │ 22797 │ +│ 78.25.120.xxx │ 22354 │ +│ 213.87.131.xxx │ 21285 │ +│ 78.25.121.xxx │ 20887 │ +│ 188.162.65.xxx │ 19694 │ +│ 83.149.48.xxx │ 17406 │ +└────────────────┴───────┘ +``` + +از زمان استفاده ‘xxx’ بسیار غیر معمول است, این ممکن است در اینده تغییر. ما توصیه می کنیم که شما در قالب دقیق این قطعه تکیه نمی. + +### اطلاعات دقیق) {#ipv6numtostringx} + +یک رشته ثابت(16) مقدار حاوی نشانی اینترنتی6 را در قالب باینری می پذیرد. بازگرداندن یک رشته حاوی این نشانی در قالب متن. +نشانی های ایپو6-نقشه برداری ایپو4 خروجی در قالب هستند:: افف:111.222.33.44. مثالها: + +``` sql +SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr +``` + +``` text +┌─addr─────────┐ +│ 2a02:6b8::11 │ +└──────────────┘ +``` + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ +│ 2a02:2168:aaa:bbbb::2 │ 24695 │ +│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ +│ 2a02:6b8:0:fff::ff │ 16389 │ +│ 2a01:4f8:111:6666::2 │ 16016 │ +│ 2a02:2168:888:222::1 │ 15896 │ +│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ +│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ +│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ +│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ +│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ +└─────────────────────────────────────────┴───────┘ +``` + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─IPv6NumToString(ClientIP6)─┬──────c─┐ +│ ::ffff:94.26.111.111 │ 747440 │ +│ ::ffff:37.143.222.4 │ 529483 │ +│ ::ffff:5.166.111.99 │ 317707 │ +│ ::ffff:46.38.11.77 │ 263086 │ +│ ::ffff:79.105.111.111 │ 186611 │ +│ ::ffff:93.92.111.88 │ 176773 │ +│ ::ffff:84.53.111.33 │ 158709 │ +│ ::ffff:217.118.11.22 │ 154004 │ +│ ::ffff:217.118.11.33 │ 148449 │ +│ ::ffff:217.118.11.44 │ 148243 │ +└────────────────────────────┴────────┘ +``` + +## مدت 6 ساعت) {#ipv6stringtonums} + +عملکرد معکوس ایپو6نومتوسترینگ. اگر نشانی اینترنتی6 دارای یک فرمت نامعتبر, یک رشته از بایت پوچ را برمی گرداند. +سحر و جادو می تواند بزرگ یا کوچک. + +## IPv4ToIPv6(x) {#ipv4toipv6x} + +طول می کشد یک `UInt32` شماره. تفسیر به عنوان یک نشانی اینترنتی4 در [اندی بزرگ](https://en.wikipedia.org/wiki/Endianness). بازگرداندن یک `FixedString(16)` مقدار حاوی نشانی اینترنتی6 در قالب دودویی. مثالها: + +``` sql +SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr +``` + +``` text +┌─addr───────────────┐ +│ ::ffff:192.168.0.1 │ +└────────────────────┘ +``` + +## cutIPv6(x bytesToCutForIPv6, bytesToCutForIPv4) {#cutipv6x-bytestocutforipv6-bytestocutforipv4} + +یک رشته ثابت(16) مقدار حاوی نشانی اینترنتی6 را در قالب باینری می پذیرد. بازگرداندن یک رشته حاوی نشانی از تعداد مشخصی از بایت حذف شده در قالب متن. به عنوان مثال: + +``` sql +WITH + IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, + IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 +SELECT + cutIPv6(ipv6, 2, 0), + cutIPv6(ipv4, 0, 2) +``` + +``` text +┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ +│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ +└─────────────────────────────────────┴─────────────────────┘ +``` + +## IPv4CIDRToRange(ipv4, Cidr), {#ipv4cidrtorangeipv4-cidr} + +قبول یک IPv4 و UInt8 ارزش شامل [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing). یک تاپل را با دو لیگ4 حاوی محدوده پایین تر و محدوده بالاتر زیر شبکه باز کنید. + +``` sql +SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) +``` + +``` text +┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ +│ ('192.168.0.0','192.168.255.255') │ +└────────────────────────────────────────────┘ +``` + +## IPv6CIDRToRange(ipv6 Cidr), {#ipv6cidrtorangeipv6-cidr} + +قبول یک IPv6 و UInt8 ارزش حاوی CIDR. یک تاپل را با دو ایپو6 حاوی محدوده پایین تر و محدوده بالاتر زیر شبکه باز کنید. + +``` sql +SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); +``` + +``` text +┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ +│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ +└────────────────────────────────────────────────────────────────────────┘ +``` + +## تایپه 4 (رشته) {#toipv4string} + +یک نام مستعار برای `IPv4StringToNum()` که طول می کشد یک شکل رشته ای از ایپو4 نشانی و ارزش را برمی گرداند [IPv4](../../sql-reference/data-types/domains/ipv4.md) نوع باینری برابر با مقدار بازگشتی است `IPv4StringToNum()`. + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + toTypeName(IPv4StringToNum(IPv4_string)), + toTypeName(toIPv4(IPv4_string)) +``` + +``` text +┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ +│ UInt32 │ IPv4 │ +└──────────────────────────────────────────┴─────────────────────────────────┘ +``` + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + hex(IPv4StringToNum(IPv4_string)), + hex(toIPv4(IPv4_string)) +``` + +``` text +┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ +│ ABE1822D │ ABE1822D │ +└───────────────────────────────────┴──────────────────────────┘ +``` + +## تیپو6 (رشته) {#toipv6string} + +یک نام مستعار برای `IPv6StringToNum()` که طول می کشد یک شکل رشته ای از ایپو6 نشانی و ارزش را برمی گرداند [IPv6](../../sql-reference/data-types/domains/ipv6.md) نوع باینری برابر با مقدار بازگشتی است `IPv6StringToNum()`. + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + toTypeName(IPv6StringToNum(IPv6_string)), + toTypeName(toIPv6(IPv6_string)) +``` + +``` text +┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ +│ FixedString(16) │ IPv6 │ +└──────────────────────────────────────────┴─────────────────────────────────┘ +``` + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + hex(IPv6StringToNum(IPv6_string)), + hex(toIPv6(IPv6_string)) +``` + +``` text +┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ +│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ +└───────────────────────────────────┴──────────────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/fa/sql-reference/functions/json-functions.md b/docs/fa/sql-reference/functions/json-functions.md new file mode 100644 index 00000000000..0f53a751989 --- /dev/null +++ b/docs/fa/sql-reference/functions/json-functions.md @@ -0,0 +1,297 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 56 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u062C\u0627\u0646\u0633\u0648\u0646" +--- + +# توابع برای کار با جانسون {#functions-for-working-with-json} + +در یاندکسمتریکا جیسون توسط کاربران به عنوان پارامترهای جلسه منتقل می شود. برخی از توابع خاص برای کار با این جانسون وجود دارد. (اگر چه در بسیاری از موارد JSONs هستند علاوه بر این قبل از پردازش و در نتیجه ارزش ها قرار داده و در ستون جداگانه در خود پردازش فرمت.) همه این توابع در فرضیات قوی در مورد چه جانسون می تواند بر اساس, اما سعی می کنند به عنوان کوچک که ممکن است به کار انجام می شود. + +مفروضات زیر ساخته شده است: + +1. نام فیلد (استدلال تابع) باید ثابت باشد. +2. نام فیلد به نحوی می تواند در جیسون کد گذاری شود. به عنوان مثال: `visitParamHas('{"abc":"def"}', 'abc') = 1` اما `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` +3. زمینه ها برای در هر سطح تودرتو جستجو, یکسره. اگر زمینه های تطبیق های متعدد وجود دارد, وقوع اول استفاده شده است. +4. JSON ندارد کاراکتر فضای خارج از string literals. + +## ویسیتپراماس (پارامز, نام) {#visitparamhasparams-name} + +بررسی اینکه یک میدان با وجود ‘name’ اسم. + +## ویسیتپرامستراکتینت (پارامز, نام) {#visitparamextractuintparams-name} + +تجزیه ظاهری64 از ارزش این زمینه به نام ‘name’. اگر این یک رشته رشته زمینه, تلاش می کند به تجزیه یک عدد از ابتدای رشته. اگر میدان وجود ندارد, و یا وجود دارد اما حاوی یک عدد نیست, باز می گردد 0. + +## ویزیتپرامستراکتینت (پارامز, نام) {#visitparamextractintparams-name} + +همان Int64. + +## اطلاعات دقیق) {#visitparamextractfloatparams-name} + +همان است که برای شناور64. + +## ویسیتپرامسترکتبولبولول (پارامز, نام) {#visitparamextractboolparams-name} + +تجزیه واقعی / ارزش کاذب. نتیجه این است UInt8. + +## ویسیتپرمککتراو (پارامز, نام) {#visitparamextractrawparams-name} + +بازگرداندن ارزش یک میدان, از جمله جدا. + +مثالها: + +``` sql +visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' +visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' +``` + +## نام و نام خانوادگی) {#visitparamextractstringparams-name} + +تجزیه رشته در نقل قول دو. ارزش بی نتیجه است. اگر بیم شکست خورده, این یک رشته خالی می گرداند. + +مثالها: + +``` sql +visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' +visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' +visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' +visitParamExtractString('{"abc":"hello}', 'abc') = '' +``` + +در حال حاضر هیچ پشتیبانی برای نقاط کد در قالب وجود دارد `\uXXXX\uYYYY` این از هواپیما چند زبانه پایه نیست (به جای اوتو-8 تبدیل می شود). + +توابع زیر بر اساس [سیمدجسون](https://github.com/lemire/simdjson) طراحی شده برای نیازهای پیچیده تر جسون تجزیه. فرض 2 ذکر شده در بالا هنوز هم صدق. + +## هشدار داده می شود) {#isvalidjsonjson} + +چک که رشته گذشت جانسون معتبر است. + +مثالها: + +``` sql +SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 +SELECT isValidJSON('not a json') = 0 +``` + +## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} + +اگر مقدار در سند جسون وجود داشته باشد, `1` برگردانده خواهد شد. + +اگر مقدار وجود ندارد, `0` برگردانده خواهد شد. + +مثالها: + +``` sql +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 +``` + +`indices_or_keys` لیستی از استدلال های صفر یا بیشتر است که هر کدام می توانند رشته یا عدد صحیح باشند. + +- رشته = عضو شی دسترسی های کلیدی. +- عدد صحیح مثبت = از ابتدا به عضو / کلید نفر دسترسی پیدا کنید. +- عدد صحیح منفی = دسترسی به عضو / کلید نفر از پایان. + +حداقل شاخص عنصر 1 است. بنابراین عنصر 0 وجود ندارد. + +شما می توانید از اعداد صحیح برای دسترسی به هر دو اشیای جسون ارریس و جسون استفاده کنید. + +بنابراین, مثلا: + +``` sql +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' +``` + +## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} + +بازگشت طول یک مجموعه جانسون یا یک شی جانسون. + +اگر مقدار وجود ندارد و یا دارای یک نوع اشتباه, `0` برگردانده خواهد شد. + +مثالها: + +``` sql +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 +``` + +## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} + +بازگشت به نوع یک مقدار جانسون. + +اگر مقدار وجود ندارد, `Null` برگردانده خواهد شد. + +مثالها: + +``` sql +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' +``` + +## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} + +## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} + +## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} + +## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} + +تجزیه جانسون و استخراج ارزش. این توابع شبیه به `visitParam` توابع. + +اگر مقدار وجود ندارد و یا دارای یک نوع اشتباه, `0` برگردانده خواهد شد. + +مثالها: + +``` sql +SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 +SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 +SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 +``` + +## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} + +تجزیه جانسون و استخراج یک رشته. این تابع شبیه به `visitParamExtractString` توابع. + +اگر مقدار وجود ندارد و یا دارای یک نوع اشتباه, یک رشته خالی بازگردانده خواهد شد. + +ارزش بی نتیجه است. اگر بیم شکست خورده, این یک رشته خالی می گرداند. + +مثالها: + +``` sql +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' +SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' +SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' +SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' +SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' +``` + +## JSONExtract(json\[, indices\_or\_keys…\], Return\_type) {#jsonextractjson-indices-or-keys-return-type} + +تجزیه یک جسون و استخراج یک مقدار از نوع داده داده داده کلیک. + +این یک تعمیم قبلی است `JSONExtract` توابع. +این به این معنی است +`JSONExtract(..., 'String')` بازده دقیقا همان `JSONExtractString()`, +`JSONExtract(..., 'Float64')` بازده دقیقا همان `JSONExtractFloat()`. + +مثالها: + +``` sql +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL +SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 +SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' +SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' +``` + +## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], Value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} + +تجزیه جفت کلید ارزش از یک جانسون که ارزش از نوع داده داده داده خانه عروسکی هستند. + +مثال: + +``` sql +SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)] +``` + +## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} + +بازگرداندن بخشی از جانسون به عنوان رشته نامحدود. + +اگر بخش وجود ندارد و یا دارای یک نوع اشتباه, یک رشته خالی بازگردانده خواهد شد. + +مثال: + +``` sql +SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' +``` + +## JSONExtractArrayRaw(json\[, indices\_or\_keys…\]) {#jsonextractarrayrawjson-indices-or-keys} + +بازگرداندن مجموعه ای با عناصر از مجموعه جانسون,هر یک به عنوان رشته نامحدود نشان. + +اگر بخش وجود ندارد و یا مجموعه ای نیست, مجموعه ای خالی بازگردانده خواهد شد. + +مثال: + +``` sql +SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' +``` + +## در حال بارگذاری {#json-extract-keys-and-values-raw} + +عصاره داده های خام از یک شی جانسون. + +**نحو** + +``` sql +JSONExtractKeysAndValuesRaw(json[, p, a, t, h]) +``` + +**پارامترها** + +- `json` — [رشته](../data-types/string.md) با جانسون معتبر. +- `p, a, t, h` — Comma-separated indices or keys that specify the path to the inner field in a nested JSON object. Each argument can be either a [رشته](../data-types/string.md) برای دریافت این زمینه توسط کلید یا یک [عدد صحیح](../data-types/int-uint.md) برای دریافت میدان ازت هفتم (نمایه شده از 1 عدد صحیح منفی از پایان تعداد). اگر تنظیم نشده, طیف جانسون به عنوان شی سطح بالا تجزیه. پارامتر اختیاری. + +**مقادیر بازگشتی** + +- & حذف با `('key', 'value')` توپلس هر دو عضو تاپل رشته ها. +- مجموعه خالی اگر جسم درخواست شده وجود ندارد, یا جانسون ورودی نامعتبر است. + +نوع: [& حذف](../data-types/array.md)([تاپل](../data-types/tuple.md)([رشته](../data-types/string.md), [رشته](../data-types/string.md)). + +**مثالها** + +پرسوجو: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}') +``` + +نتیجه: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}')─┐ +│ [('a','[-100,200]'),('b','{"c":{"d":"hello","f":"world"}}')] │ +└──────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b') +``` + +نتیجه: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b')─┐ +│ [('c','{"d":"hello","f":"world"}')] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c') +``` + +نتیجه: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c')─┐ +│ [('d','"hello"'),('f','"world"')] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) diff --git a/docs/fa/sql-reference/functions/logical-functions.md b/docs/fa/sql-reference/functions/logical-functions.md new file mode 100644 index 00000000000..3e462ab98d1 --- /dev/null +++ b/docs/fa/sql-reference/functions/logical-functions.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u0645\u0646\u0637\u0642\u06CC" +--- + +# توابع منطقی {#logical-functions} + +توابع منطقی قبول هر نوع عددی, اما بازگشت یک عدد توینت8 برابر 0 یا 1. + +صفر به عنوان یک استدلال در نظر گرفته شده است “false,” در حالی که هر مقدار غیر صفر در نظر گرفته شده است “true”. + +## و, و اپراتور {#and-and-operator} + +## یا اپراتور {#or-or-operator} + +## نه, اپراتور نیست {#not-not-operator} + +## خور {#xor} + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/fa/sql-reference/functions/machine-learning-functions.md b/docs/fa/sql-reference/functions/machine-learning-functions.md new file mode 100644 index 00000000000..6cb2b7d8e0b --- /dev/null +++ b/docs/fa/sql-reference/functions/machine-learning-functions.md @@ -0,0 +1,21 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 64 +toc_title: "\u062A\u0648\u0627\u0628\u0639 \u06CC\u0627\u062F\u06AF\u06CC\u0631\u06CC\ + \ \u0645\u0627\u0634\u06CC\u0646" +--- + +# توابع یادگیری ماشین {#machine-learning-functions} + +## ارزیابی (پیش بینی) {#machine_learning_methods-evalmlmethod} + +پیش بینی با استفاده از مدل های رگرسیون نصب شده `evalMLMethod` تابع. مشاهده لینک در `linearRegression`. + +### رگرسیون خطی تصادفی {#stochastic-linear-regression} + +این [تنظیم مقررات](../../sql-reference/aggregate-functions/reference.md#agg_functions-stochasticlinearregression) تابع جمع پیاده سازی روش گرادیان نزولی تصادفی با استفاده از مدل خطی و تابع از دست دادن مرتبه اول. استفاده `evalMLMethod` برای پیش بینی در داده های جدید. + +### رگرسیون لجستیک تصادفی {#stochastic-logistic-regression} + +این [سرکوب مقررات عمومی](../../sql-reference/aggregate-functions/reference.md#agg_functions-stochasticlogisticregression) تابع جمع پیاده سازی روش گرادیان نزولی برای مشکل طبقه بندی دودویی. استفاده `evalMLMethod` برای پیش بینی در داده های جدید. diff --git a/docs/fa/sql-reference/functions/math-functions.md b/docs/fa/sql-reference/functions/math-functions.md new file mode 100644 index 00000000000..1adb18c6949 --- /dev/null +++ b/docs/fa/sql-reference/functions/math-functions.md @@ -0,0 +1,116 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u0631\u06CC\u0627\u0636\u06CC" +--- + +# توابع ریاضی {#mathematical-functions} + +همه توابع بازگشت یک عدد شناور64. دقت و صحت نتیجه به حداکثر دقت ممکن است اما نتیجه ممکن است همزمان با ماشین representable شماره نزدیکترین مربوطه عدد حقیقی است. + +## ا() {#e} + +بازگرداندن یک عدد شناور64 است که نزدیک به تعداد الکترونیکی. + +## پی() {#pi} + +Returns a Float64 number that is close to the number π. + +## واردات) {#expx} + +می پذیرد یک استدلال عددی و یک عدد شناور64 نزدیک به توان استدلال را برمی گرداند. + +## هشدار داده می شود) {#logx-lnx} + +یک استدلال عددی را می پذیرد و یک عدد شناور64 را نزدیک به لگاریتم طبیعی استدلال می کند. + +## exp2(x) {#exp2x} + +می پذیرد یک استدلال عددی و یک عدد شناور می گرداند نزدیک به 2 به قدرت ایکس. + +## log2(x) {#log2x} + +می پذیرد یک استدلال عددی و یک عدد جسم شناور64 را برمی گرداند نزدیک به لگاریتم باینری از استدلال. + +## exp10(x) {#exp10x} + +می پذیرد یک استدلال عددی و یک عدد شناور می گرداند نزدیک به 10 به قدرت ایکس. + +## ثبت 10 (ایکس) {#log10x} + +می پذیرد یک استدلال عددی و یک عدد جسم شناور64 نزدیک به لگاریتم اعشاری از استدلال را برمی گرداند. + +## هشدار داده می شود) {#sqrtx} + +می پذیرد یک استدلال عددی و یک عدد شناور می گرداند نزدیک به ریشه مربع از استدلال. + +## هشدار داده می شود) {#cbrtx} + +می پذیرد یک استدلال عددی و یک عدد جسم شناور را برمی گرداند نزدیک به ریشه مکعب استدلال. + +## عارف) {#erfx} + +اگر ‘x’ سپس غیر منفی است `erf(x / σ√2)` احتمال این که یک متغیر تصادفی داشتن یک توزیع نرمال با انحراف استاندارد است ‘σ’ طول می کشد ارزش است که از مقدار مورد انتظار توسط بیش از هم جدا ‘x’. + +مثال (قانون سه سیگما): + +``` sql +SELECT erf(3 / sqrt(2)) +``` + +``` text +┌─erf(divide(3, sqrt(2)))─┐ +│ 0.9973002039367398 │ +└─────────────────────────┘ +``` + +## erfc(x) {#erfcx} + +قبول یک استدلال عددی و یک عدد شناور را برمی گرداند نزدیک به 1 - دوره (ایکس), اما بدون از دست دادن دقت برای بزرگ ‘x’ ارزشهای خبری عبارتند از: + +## هشدار داده می شود) {#lgammax} + +لگاریتم تابع گاما. + +## ترجما) {#tgammax} + +تابع گاما + +## گناه) {#sinx} + +سینوس. + +## کسینوس (ایکس) {#cosx} + +کسینوس. + +## قهوهای مایل به زرد(ایکس) {#tanx} + +خط مماس. + +## اطلاعات دقیق) {#asinx} + +سینوسی قوس. + +## acos(x) {#acosx} + +قوس کسینوس. + +## هشدار داده می شود) {#atanx} + +مماس قوس. + +## صدای انفجار (ایکس, و), قدرت (ایکس, و) {#powx-y-powerx-y} + +طول می کشد دو استدلال عددی ایکس و و و. گرداند یک عدد جسم شناور64 نزدیک به ایکس به قدرت و. + +## اینتکسپ2 {#intexp2} + +می پذیرد یک استدلال عددی و باز می گردد یک عدد اوینت64 نزدیک به 2 به قدرت ایکس. + +## اینتکسپ10 {#intexp10} + +می پذیرد یک استدلال عددی و باز می گردد یک عدد اوینت64 نزدیک به 10 به قدرت ایکس. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/fa/sql-reference/functions/other-functions.md b/docs/fa/sql-reference/functions/other-functions.md new file mode 100644 index 00000000000..d18fac245c5 --- /dev/null +++ b/docs/fa/sql-reference/functions/other-functions.md @@ -0,0 +1,1205 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 66 +toc_title: "\u063A\u06CC\u0631\u0647" +--- + +# توابع دیگر {#other-functions} + +## نام میزبان() {#hostname} + +بازگرداندن یک رشته با نام میزبان که این تابع در انجام شد. برای پردازش توزیع شده, این نام میزبان سرور از راه دور است, اگر تابع بر روی یک سرور از راه دور انجام. + +## گدماکرو {#getmacro} + +می شود یک مقدار به نام از [& کلاندارها](../../operations/server-configuration-parameters/settings.md#macros) بخش پیکربندی سرور. + +**نحو** + +``` sql +getMacro(name); +``` + +**پارامترها** + +- `name` — Name to retrieve from the `macros` بخش. [رشته](../../sql-reference/data-types/string.md#string). + +**مقدار بازگشتی** + +- ارزش ماکرو مشخص. + +نوع: [رشته](../../sql-reference/data-types/string.md). + +**مثال** + +به عنوان مثال `macros` بخش در فایل پیکربندی سرور: + +``` xml + + Value + +``` + +پرسوجو: + +``` sql +SELECT getMacro('test'); +``` + +نتیجه: + +``` text +┌─getMacro('test')─┐ +│ Value │ +└──────────────────┘ +``` + +یک راه جایگزین برای دریافت همان مقدار: + +``` sql +SELECT * FROM system.macros +WHERE macro = 'test'; +``` + +``` text +┌─macro─┬─substitution─┐ +│ test │ Value │ +└───────┴──────────────┘ +``` + +## FQDN {#fqdn} + +بازگرداندن نام دامنه به طور کامل واجد شرایط. + +**نحو** + +``` sql +fqdn(); +``` + +این تابع غیر حساس است. + +**مقدار بازگشتی** + +- رشته با نام دامنه به طور کامل واجد شرایط. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT FQDN(); +``` + +نتیجه: + +``` text +┌─FQDN()──────────────────────────┐ +│ clickhouse.ru-central1.internal │ +└─────────────────────────────────┘ +``` + +## basename {#basename} + +عصاره قسمت انتهایی یک رشته پس از بریده بریده و یا ممیز گذشته. این تابع اگر اغلب مورد استفاده برای استخراج نام فایل از یک مسیر. + +``` sql +basename( expr ) +``` + +**پارامترها** + +- `expr` — Expression resulting in a [رشته](../../sql-reference/data-types/string.md) نوع ارزش. همه بک اسلش باید در ارزش حاصل فرار. + +**مقدار بازگشتی** + +یک رشته که شامل: + +- قسمت انتهایی یک رشته پس از بریده بریده و یا ممیز گذشته. + + If the input string contains a path ending with slash or backslash, for example, `/` or `c:\`, the function returns an empty string. + +- رشته اصلی اگر هیچ اسلش یا بک اسلش وجود دارد. + +**مثال** + +``` sql +SELECT 'some/long/path/to/file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some\\long\\path\\to\\file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some-file-name' AS a, basename(a) +``` + +``` text +┌─a──────────────┬─basename('some-file-name')─┐ +│ some-file-name │ some-file-name │ +└────────────────┴────────────────────────────┘ +``` + +## عریض) {#visiblewidthx} + +محاسبه عرض تقریبی در هنگام خروجی ارزش به کنسول در قالب متن (تب از هم جدا). +این تابع توسط سیستم برای اجرای فرمت های زیبا استفاده می شود. + +`NULL` به عنوان یک رشته مربوط به نمایندگی `NULL` داخل `Pretty` فرمتها. + +``` sql +SELECT visibleWidth(NULL) +``` + +``` text +┌─visibleWidth(NULL)─┐ +│ 4 │ +└────────────────────┘ +``` + +## نام کامل) {#totypenamex} + +بازگرداندن یک رشته حاوی نام نوع استدلال گذشت. + +اگر `NULL` به عنوان ورودی به عملکرد منتقل می شود و سپس باز می گردد `Nullable(Nothing)` نوع, که مربوط به داخلی `NULL` نمایندگی در فاحشه خانه. + +## blockSize() {#function-blocksize} + +می شود به اندازه بلوک. +در خانه, نمایش داده شد همیشه در بلوک های اجرا (مجموعه ای از قطعات ستون). این تابع اجازه می دهد تا اندازه بلوک را که شما برای نام برد دریافت کنید. + +## تحقق (ایکس) {#materializex} + +تبدیل ثابت به یک ستون کامل حاوی فقط یک مقدار. +در خانه, ستون کامل و ثابت متفاوت در حافظه نشان. توابع کار متفاوت برای استدلال ثابت و استدلال طبیعی (کد های مختلف اجرا شده است), اگر چه نتیجه این است که تقریبا همیشه همان. این تابع برای اشکال زدایی این رفتار. + +## ignore(…) {#ignore} + +می پذیرد هر استدلال, محتوی `NULL`. همیشه برمی گرداند 0. +با این حال, استدلال هنوز ارزیابی. این را می توان برای معیار استفاده می شود. + +## خواب (ثانیه) {#sleepseconds} + +خواب ‘seconds’ ثانیه در هر بلوک داده ها. شما می توانید یک عدد صحیح یا عدد ممیز شناور را مشخص کنید. + +## خواب (ثانیه) {#sleepeachrowseconds} + +خواب ‘seconds’ ثانیه در هر سطر. شما می توانید یک عدد صحیح یا عدد ممیز شناور را مشخص کنید. + +## متن() {#currentdatabase} + +بازگرداندن نام پایگاه داده فعلی. +شما می توانید این تابع در پارامترهای موتور جدول در یک پرس و جو جدول ایجاد جایی که شما نیاز به مشخص کردن پایگاه داده استفاده. + +## currentUser() {#other-function-currentuser} + +بازگرداندن ورود کاربر فعلی. ورود کاربر, که پرس و جو شروع, خواهد شد در پرس و جو مورد رقیق بازگشت. + +``` sql +SELECT currentUser(); +``` + +نام مستعار: `user()`, `USER()`. + +**مقادیر بازگشتی** + +- ورود کاربر فعلی. +- ورود کاربر که پرس و جو در صورت پرس و جو از کار افتاده است. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT currentUser(); +``` + +نتیجه: + +``` text +┌─currentUser()─┐ +│ default │ +└───────────────┘ +``` + +## & ایستانت {#is-constant} + +بررسی اینکه استدلال بیان ثابت است. + +A constant expression means an expression whose resulting value is known at the query analysis (i.e. before execution). For example, expressions over [literals](../syntax.md#literals) عبارات ثابت هستند. + +این تابع برای توسعه در نظر گرفته شده, اشکال زدایی و تظاهرات. + +**نحو** + +``` sql +isConstant(x) +``` + +**پارامترها** + +- `x` — Expression to check. + +**مقادیر بازگشتی** + +- `1` — `x` ثابت است. +- `0` — `x` غیر ثابت است. + +نوع: [UInt8](../data-types/int-uint.md). + +**مثالها** + +پرسوجو: + +``` sql +SELECT isConstant(x + 1) FROM (SELECT 43 AS x) +``` + +نتیجه: + +``` text +┌─isConstant(plus(x, 1))─┐ +│ 1 │ +└────────────────────────┘ +``` + +پرسوجو: + +``` sql +WITH 3.14 AS pi SELECT isConstant(cos(pi)) +``` + +نتیجه: + +``` text +┌─isConstant(cos(pi))─┐ +│ 1 │ +└─────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT isConstant(number) FROM numbers(1) +``` + +نتیجه: + +``` text +┌─isConstant(number)─┐ +│ 0 │ +└────────────────────┘ +``` + +## اطلاعات دقیق) {#isfinitex} + +قبول Float32 و Float64 و بازده UInt8 برابر با 1 اگر این استدلال بی نهایت است و نه یک نان در غیر این صورت 0 است. + +## اطلاعات دقیق) {#isinfinitex} + +قبول Float32 و Float64 و بازده UInt8 برابر با 1 اگر این استدلال بی نهایت است در غیر این صورت 0 است. توجه داشته باشید که 0 برای نان بازگشت. + +## اطلاعات دقیق {#ifnotfinite} + +بررسی اینکه مقدار ممیز شناور محدود است. + +**نحو** + + ifNotFinite(x,y) + +**پارامترها** + +- `x` — Value to be checked for infinity. Type: [شناور\*](../../sql-reference/data-types/float.md). +- `y` — Fallback value. Type: [شناور\*](../../sql-reference/data-types/float.md). + +**مقدار بازگشتی** + +- `x` اگر `x` محدود است. +- `y` اگر `x` محدود نیست. + +**مثال** + +پرسوجو: + + SELECT 1/0 as infimum, ifNotFinite(infimum,42) + +نتیجه: + + ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ + │ inf │ 42 │ + └─────────┴───────────────────────────────┘ + +شما می توانید نتیجه مشابه با استفاده از [اپراتور سه تایی](conditional-functions.md#ternary-operator): `isFinite(x) ? x : y`. + +## اطلاعات دقیق) {#isnanx} + +قبول Float32 و Float64 و بازده UInt8 برابر با 1 اگر استدلال این است که یک نان در غیر این صورت 0 است. + +## قابل تنظیم(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} + +می پذیرد رشته ثابت: نام پایگاه داده, نام جدول, و نام ستون. بازگرداندن یک بیان ثابت سنت8 برابر 1 اگر یک ستون وجود دارد, در غیر این صورت 0. اگر پارامتر نام میزبان تنظیم شده است, تست بر روی یک سرور از راه دور اجرا خواهد شد. +تابع می اندازد یک استثنا اگر جدول وجود ندارد. +برای عناصر در یک ساختار داده های تو در تو, تابع چک برای وجود یک ستون. برای ساختار داده های تو در تو خود, بازده تابع 0. + +## بار {#function-bar} + +اجازه می دهد تا ساخت یک نمودار یونیکد هنر. + +`bar(x, min, max, width)` تساوی یک گروه با عرض متناسب با `(x - min)` و برابر با `width` شخصیت زمانی که `x = max`. + +پارامترها: + +- `x` — Size to display. +- `min, max` — Integer constants. The value must fit in `Int64`. +- `width` — Constant, positive integer, can be fractional. + +گروه با دقت به یک هشتم نماد کشیده شده است. + +مثال: + +``` sql +SELECT + toHour(EventTime) AS h, + count() AS c, + bar(c, 0, 600000, 20) AS bar +FROM test.hits +GROUP BY h +ORDER BY h ASC +``` + +``` text +┌──h─┬──────c─┬─bar────────────────┐ +│ 0 │ 292907 │ █████████▋ │ +│ 1 │ 180563 │ ██████ │ +│ 2 │ 114861 │ ███▋ │ +│ 3 │ 85069 │ ██▋ │ +│ 4 │ 68543 │ ██▎ │ +│ 5 │ 78116 │ ██▌ │ +│ 6 │ 113474 │ ███▋ │ +│ 7 │ 170678 │ █████▋ │ +│ 8 │ 278380 │ █████████▎ │ +│ 9 │ 391053 │ █████████████ │ +│ 10 │ 457681 │ ███████████████▎ │ +│ 11 │ 493667 │ ████████████████▍ │ +│ 12 │ 509641 │ ████████████████▊ │ +│ 13 │ 522947 │ █████████████████▍ │ +│ 14 │ 539954 │ █████████████████▊ │ +│ 15 │ 528460 │ █████████████████▌ │ +│ 16 │ 539201 │ █████████████████▊ │ +│ 17 │ 523539 │ █████████████████▍ │ +│ 18 │ 506467 │ ████████████████▊ │ +│ 19 │ 520915 │ █████████████████▎ │ +│ 20 │ 521665 │ █████████████████▍ │ +│ 21 │ 542078 │ ██████████████████ │ +│ 22 │ 493642 │ ████████████████▍ │ +│ 23 │ 400397 │ █████████████▎ │ +└────┴────────┴────────────────────┘ +``` + +## تبدیل {#transform} + +تبدیل یک ارزش با توجه به نقشه برداری به صراحت تعریف شده از برخی از عناصر به دیگر. +دو نوع از این تابع وجود دارد: + +### تبدیل(x array\_from, array\_to به طور پیش فرض) {#transformx-array-from-array-to-default} + +`x` – What to transform. + +`array_from` – Constant array of values for converting. + +`array_to` – Constant array of values to convert the values in ‘from’ به. + +`default` – Which value to use if ‘x’ برابر است با هر یک از مقادیر در ‘from’. + +`array_from` و `array_to` – Arrays of the same size. + +انواع: + +`transform(T, Array(T), Array(U), U) -> U` + +`T` و `U` می تواند عددی, رشته,یا تاریخ و یا انواع تاریخ ساعت. +از کجا همان نامه نشان داده شده است (تی یا تو), برای انواع عددی این ممکن است تطبیق انواع, اما انواع که یک نوع رایج. +برای مثال استدلال می توانید نوع Int64 در حالی که دوم آرایه(UInt16) نوع. + +اگر ‘x’ ارزش به یکی از عناصر در برابر است ‘array\_from’ مجموعه, این بازگرداندن عنصر موجود (که شماره همان) از ‘array\_to’ صف کردن. در غیر این صورت, باز می گردد ‘default’. اگر عناصر تطبیق های متعدد در وجود دارد ‘array\_from’ این یکی از مسابقات را برمی گرداند. + +مثال: + +``` sql +SELECT + transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, + count() AS c +FROM test.hits +WHERE SearchEngineID != 0 +GROUP BY title +ORDER BY c DESC +``` + +``` text +┌─title─────┬──────c─┐ +│ Yandex │ 498635 │ +│ Google │ 229872 │ +│ Other │ 104472 │ +└───────────┴────────┘ +``` + +### تبدیل) {#transformx-array-from-array-to} + +متفاوت از تنوع برای اولین بار در که ‘default’ استدلال حذف شده است. +اگر ‘x’ ارزش به یکی از عناصر در برابر است ‘array\_from’ مجموعه, این بازگرداندن عنصر تطبیق (که شماره همان) از ‘array\_to’ صف کردن. در غیر این صورت, باز می گردد ‘x’. + +انواع: + +`transform(T, Array(T), Array(T)) -> T` + +مثال: + +``` sql +SELECT + transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, + count() AS c +FROM test.hits +GROUP BY domain(Referer) +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +┌─s──────────────┬───────c─┐ +│ │ 2906259 │ +│ www.yandex │ 867767 │ +│ ███████.ru │ 313599 │ +│ mail.yandex.ru │ 107147 │ +│ ██████.ru │ 100355 │ +│ █████████.ru │ 65040 │ +│ news.yandex.ru │ 64515 │ +│ ██████.net │ 59141 │ +│ example.com │ 57316 │ +└────────────────┴─────────┘ +``` + +## قالببندی) ایکس() {#formatreadablesizex} + +می پذیرد اندازه (تعداد بایت). بازگرداندن اندازه گرد با پسوند (کیلوبایت, مگابایت, و غیره.) به عنوان یک رشته . + +مثال: + +``` sql +SELECT + arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, + formatReadableSize(filesize_bytes) AS filesize +``` + +``` text +┌─filesize_bytes─┬─filesize───┐ +│ 1 │ 1.00 B │ +│ 1024 │ 1.00 KiB │ +│ 1048576 │ 1.00 MiB │ +│ 192851925 │ 183.92 MiB │ +└────────────────┴────────────┘ +``` + +## کمترین) {#leasta-b} + +بازگرداندن کوچکترین ارزش از یک و ب. + +## بزرگترین (و, ب) {#greatesta-b} + +بازگرداندن بزرگترین ارزش یک و ب. + +## زمان بالا() {#uptime} + +بازگرداندن زمان انجام کار سرور در ثانیه. + +## نسخه() {#version} + +بازگرداندن نسخه از سرور به عنوان یک رشته. + +## منطقهی زمانی() {#timezone} + +بازگرداندن منطقه زمانی از سرور. + +## blockNumber {#blocknumber} + +بازگرداندن تعداد دنباله ای از بلوک داده که در ردیف واقع شده است. + +## رفع موانع {#function-rownumberinblock} + +بازگرداندن تعداد ترتیبی از ردیف در بلوک داده. بلوک های داده های مختلف همیشه محاسبه. + +## بلوک های رونمبرینالیک() {#rownumberinallblocks} + +بازگرداندن تعداد ترتیبی از ردیف در بلوک داده. این تابع تنها بلوک های داده تحت تاثیر قرار می گیرد. + +## همسایه {#neighbor} + +تابع پنجره که دسترسی به یک ردیف در یک افست مشخص شده است که قبل یا بعد از ردیف فعلی یک ستون داده می شود فراهم می کند. + +**نحو** + +``` sql +neighbor(column, offset[, default_value]) +``` + +نتیجه عملکرد بستگی به بلوک های داده تحت تاثیر قرار و منظور از داده ها در بلوک. +اگر شما یک خرده فروشی با سفارش و پاسخ تابع از خارج از خرده فروشی, شما می توانید نتیجه مورد انتظار از. + +**پارامترها** + +- `column` — A column name or scalar expression. +- `offset` — The number of rows forwards or backwards from the current row of `column`. [Int64](../../sql-reference/data-types/int-uint.md). +- `default_value` — Optional. The value to be returned if offset goes beyond the scope of the block. Type of data blocks affected. + +**مقادیر بازگشتی** + +- مقدار برای `column` داخل `offset` فاصله از ردیف فعلی اگر `offset` ارزش خارج از مرزهای بلوک نیست. +- مقدار پیشفرض برای `column` اگر `offset` ارزش مرزهای بلوک خارج است. اگر `default_value` داده می شود و سپس استفاده می شود. + +نوع: نوع بلوک های داده را تحت تاثیر قرار و یا نوع مقدار پیش فرض. + +**مثال** + +پرسوجو: + +``` sql +SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; +``` + +نتیجه: + +``` text +┌─number─┬─neighbor(number, 2)─┐ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +│ 4 │ 6 │ +│ 5 │ 7 │ +│ 6 │ 8 │ +│ 7 │ 9 │ +│ 8 │ 0 │ +│ 9 │ 0 │ +└────────┴─────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; +``` + +نتیجه: + +``` text +┌─number─┬─neighbor(number, 2, 999)─┐ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +│ 4 │ 6 │ +│ 5 │ 7 │ +│ 6 │ 8 │ +│ 7 │ 9 │ +│ 8 │ 999 │ +│ 9 │ 999 │ +└────────┴──────────────────────────┘ +``` + +این تابع می تواند مورد استفاده قرار گیرد برای محاسبه ارزش متریک در سال بیش از سال: + +پرسوجو: + +``` sql +WITH toDate('2018-01-01') AS start_date +SELECT + toStartOfMonth(start_date + (number * 32)) AS month, + toInt32(month) % 100 AS money, + neighbor(money, -12) AS prev_year, + round(prev_year / money, 2) AS year_over_year +FROM numbers(16) +``` + +نتیجه: + +``` text +┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ +│ 2018-01-01 │ 32 │ 0 │ 0 │ +│ 2018-02-01 │ 63 │ 0 │ 0 │ +│ 2018-03-01 │ 91 │ 0 │ 0 │ +│ 2018-04-01 │ 22 │ 0 │ 0 │ +│ 2018-05-01 │ 52 │ 0 │ 0 │ +│ 2018-06-01 │ 83 │ 0 │ 0 │ +│ 2018-07-01 │ 13 │ 0 │ 0 │ +│ 2018-08-01 │ 44 │ 0 │ 0 │ +│ 2018-09-01 │ 75 │ 0 │ 0 │ +│ 2018-10-01 │ 5 │ 0 │ 0 │ +│ 2018-11-01 │ 36 │ 0 │ 0 │ +│ 2018-12-01 │ 66 │ 0 │ 0 │ +│ 2019-01-01 │ 97 │ 32 │ 0.33 │ +│ 2019-02-01 │ 28 │ 63 │ 2.25 │ +│ 2019-03-01 │ 56 │ 91 │ 1.62 │ +│ 2019-04-01 │ 87 │ 22 │ 0.25 │ +└────────────┴───────┴───────────┴────────────────┘ +``` + +## تغییر تنظیمات صدا) {#other_functions-runningdifference} + +Calculates the difference between successive row values ​​in the data block. +بازده 0 برای ردیف اول و تفاوت از ردیف قبلی برای هر سطر بعدی. + +نتیجه عملکرد بستگی به بلوک های داده تحت تاثیر قرار و منظور از داده ها در بلوک. +اگر شما یک خرده فروشی با سفارش و پاسخ تابع از خارج از خرده فروشی, شما می توانید نتیجه مورد انتظار از. + +مثال: + +``` sql +SELECT + EventID, + EventTime, + runningDifference(EventTime) AS delta +FROM +( + SELECT + EventID, + EventTime + FROM events + WHERE EventDate = '2016-11-24' + ORDER BY EventTime ASC + LIMIT 5 +) +``` + +``` text +┌─EventID─┬───────────EventTime─┬─delta─┐ +│ 1106 │ 2016-11-24 00:00:04 │ 0 │ +│ 1107 │ 2016-11-24 00:00:05 │ 1 │ +│ 1108 │ 2016-11-24 00:00:05 │ 0 │ +│ 1109 │ 2016-11-24 00:00:09 │ 4 │ +│ 1110 │ 2016-11-24 00:00:10 │ 1 │ +└─────────┴─────────────────────┴───────┘ +``` + +لطفا توجه داشته باشید-اندازه بلوک بر نتیجه تاثیر می گذارد. با هر بلوک جدید `runningDifference` دولت تنظیم مجدد است. + +``` sql +SELECT + number, + runningDifference(number + 1) AS diff +FROM numbers(100000) +WHERE diff != 1 +``` + +``` text +┌─number─┬─diff─┐ +│ 0 │ 0 │ +└────────┴──────┘ +┌─number─┬─diff─┐ +│ 65536 │ 0 │ +└────────┴──────┘ +``` + +``` sql +set max_block_size=100000 -- default value is 65536! + +SELECT + number, + runningDifference(number + 1) AS diff +FROM numbers(100000) +WHERE diff != 1 +``` + +``` text +┌─number─┬─diff─┐ +│ 0 │ 0 │ +└────────┴──────┘ +``` + +## در حال بارگذاری {#runningdifferencestartingwithfirstvalue} + +همان است که برای [عدم پذیرش](./other-functions.md#other_functions-runningdifference), تفاوت ارزش ردیف اول است, ارزش سطر اول بازگشت, و هر سطر بعدی تفاوت از ردیف قبلی را برمی گرداند. + +## هشدار داده می شود) {#macnumtostringnum} + +قبول UInt64 شماره. تفسیر به عنوان نشانی مک در اندی بزرگ. بازگرداندن یک رشته حاوی نشانی مک مربوطه را در قالب قلمی: ب: ر. ن:دکتر: ف.ا: ف. ف. (تعداد کولون جدا شده در فرم هگزادسیمال). + +## MACStringToNum(s) {#macstringtonums} + +عملکرد معکوس مک نومتوسترینگ. اگر نشانی مک دارای یک فرمت نامعتبر, باز می گردد 0. + +## درشتنمایی) {#macstringtoouis} + +می پذیرد یک نشانی مک در فرمت قلمی:بیت:ر.ن:دی. دی:اف (تعداد روده بزرگ از هم جدا در فرم هگزادسیمال). بازگرداندن سه هشت تایی اول به عنوان یک عدد ظاهری64. اگر نشانی مک دارای یک فرمت نامعتبر, باز می گردد 0. + +## نوع گیرنده {#getsizeofenumtype} + +بازگرداندن تعدادی از زمینه های در [شمارشی](../../sql-reference/data-types/enum.md). + +``` sql +getSizeOfEnumType(value) +``` + +**پارامترها:** + +- `value` — Value of type `Enum`. + +**مقادیر بازگشتی** + +- تعدادی از زمینه های با `Enum` مقادیر ورودی. +- یک استثنا پرتاب می شود اگر نوع نیست `Enum`. + +**مثال** + +``` sql +SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## بلوک سازی {#blockserializedsize} + +بازده اندازه بر روی دیسک (بدون در نظر گرفتن فشرده سازی حساب). + +``` sql +blockSerializedSize(value[, value[, ...]]) +``` + +**پارامترها:** + +- `value` — Any value. + +**مقادیر بازگشتی** + +- تعداد بایت خواهد شد که به دیسک برای بلوک از ارزش های نوشته شده (بدون فشرده سازی). + +**مثال** + +``` sql +SELECT blockSerializedSize(maxState(1)) as x +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## بدون نام {#tocolumntypename} + +بازگرداندن نام کلاس است که نشان دهنده نوع داده ها از ستون در رم. + +``` sql +toColumnTypeName(value) +``` + +**پارامترها:** + +- `value` — Any type of value. + +**مقادیر بازگشتی** + +- یک رشته با نام کلاس است که برای نمایندگی از استفاده `value` نوع داده در رم. + +**نمونه ای از تفاوت بین`toTypeName ' and ' toColumnTypeName`** + +``` sql +SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) +``` + +``` text +┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ DateTime │ +└─────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) +``` + +``` text +┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ Const(UInt32) │ +└───────────────────────────────────────────────────────────┘ +``` + +مثال نشان می دهد که `DateTime` نوع داده در حافظه ذخیره می شود به عنوان `Const(UInt32)`. + +## روبنا دامپکول {#dumpcolumnstructure} + +خروجی شرح مفصلی از ساختارهای داده در رم + +``` sql +dumpColumnStructure(value) +``` + +**پارامترها:** + +- `value` — Any type of value. + +**مقادیر بازگشتی** + +- یک رشته توصیف ساختار است که برای نمایندگی از استفاده `value` نوع داده در رم. + +**مثال** + +``` sql +SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) +``` + +``` text +┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ DateTime, Const(size = 1, UInt32(size = 1)) │ +└──────────────────────────────────────────────────────────────┘ +``` + +## نوع قراردادی {#defaultvalueofargumenttype} + +خروجی مقدار پیش فرض برای نوع داده. + +مقادیر پیش فرض برای ستون های سفارشی تعیین شده توسط کاربر را شامل نمی شود. + +``` sql +defaultValueOfArgumentType(expression) +``` + +**پارامترها:** + +- `expression` — Arbitrary type of value or an expression that results in a value of an arbitrary type. + +**مقادیر بازگشتی** + +- `0` برای اعداد. +- رشته خالی برای رشته. +- `ᴺᵁᴸᴸ` برای [Nullable](../../sql-reference/data-types/nullable.md). + +**مثال** + +``` sql +SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) +``` + +``` text +┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ +│ 0 │ +└─────────────────────────────────────────────┘ +``` + +``` sql +SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) +``` + +``` text +┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ +│ ᴺᵁᴸᴸ │ +└───────────────────────────────────────────────────────┘ +``` + +## تکرار {#other-functions-replicate} + +ایجاد مجموعه ای با یک مقدار واحد. + +مورد استفاده برای اجرای داخلی [ارریجین](array-join.md#functions_arrayjoin). + +``` sql +SELECT replicate(x, arr); +``` + +**پارامترها:** + +- `arr` — Original array. ClickHouse creates a new array of the same length as the original and fills it with the value `x`. +- `x` — The value that the resulting array will be filled with. + +**مقدار بازگشتی** + +مجموعه ای پر از ارزش `x`. + +نوع: `Array`. + +**مثال** + +پرسوجو: + +``` sql +SELECT replicate(1, ['a', 'b', 'c']) +``` + +نتیجه: + +``` text +┌─replicate(1, ['a', 'b', 'c'])─┐ +│ [1,1,1] │ +└───────────────────────────────┘ +``` + +## رشته های قابل استفاده {#filesystemavailable} + +بازگرداندن مقدار فضای باقی مانده بر روی سیستم فایل که فایل های پایگاه داده واقع. این است که همیشه کوچکتر از فضای کل رایگان ([بدون پرونده](#filesystemfree)) چرا که برخی از فضا برای سیستم عامل محفوظ می باشد. + +**نحو** + +``` sql +filesystemAvailable() +``` + +**مقدار بازگشتی** + +- مقدار فضای باقی مانده موجود در بایت. + +نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; +``` + +نتیجه: + +``` text +┌─Available space─┬─Type───┐ +│ 30.75 GiB │ UInt64 │ +└─────────────────┴────────┘ +``` + +## بدون پرونده {#filesystemfree} + +بازگرداندن مقدار کل فضای رایگان بر روی سیستم فایل که فایل های پایگاه داده واقع. همچنین نگاه کنید به `filesystemAvailable` + +**نحو** + +``` sql +filesystemFree() +``` + +**مقدار بازگشتی** + +- مقدار فضای رایگان در بایت. + +نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; +``` + +نتیجه: + +``` text +┌─Free space─┬─Type───┐ +│ 32.39 GiB │ UInt64 │ +└────────────┴────────┘ +``` + +## سختی پرونده {#filesystemcapacity} + +بازگرداندن ظرفیت فایل سیستم در بایت. برای ارزیابی [مسیر](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path) به دایرکتوری داده ها باید پیکربندی شود. + +**نحو** + +``` sql +filesystemCapacity() +``` + +**مقدار بازگشتی** + +- اطلاعات ظرفیت سیستم فایل در بایت. + +نوع: [UInt64](../../sql-reference/data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" +``` + +نتیجه: + +``` text +┌─Capacity──┬─Type───┐ +│ 39.32 GiB │ UInt64 │ +└───────────┴────────┘ +``` + +## پلاکتی {#function-finalizeaggregation} + +طول می کشد دولت از تابع جمع. بازده نتیجه تجمع (دولت نهایی). + +## خرابی اجرا {#function-runningaccumulate} + +طول می کشد کشورهای تابع جمع و یک ستون با ارزش را برمی گرداند, در نتیجه تجمع این کشورها برای مجموعه ای از خطوط بلوک هستند, از اول به خط فعلی. +برای مثال طول می کشد state of aggregate function (به عنوان مثال runningAccumulate(uniqState(UserID))) و برای هر ردیف از بلوک بازگشت نتیجه از مجموع عملکرد در ادغام دولت قبلی تمام ردیف و ردیف جاری است. +بنابراین نتیجه عملکرد بستگی به پارتیشن داده ها به بلوک ها و به ترتیب داده ها در بلوک دارد. + +## جوینت {#joinget} + +تابع شما اجازه می دهد استخراج داده ها از جدول به همان شیوه به عنوان از یک [واژهنامه](../../sql-reference/dictionaries/index.md). + +می شود داده ها از [پیوستن](../../engines/table-engines/special/join.md#creating-a-table) جداول با استفاده از کلید ملحق مشخص. + +فقط پشتیبانی از جداول ایجاد شده با `ENGINE = Join(ANY, LEFT, )` بیانیه. + +**نحو** + +``` sql +joinGet(join_storage_table_name, `value_column`, join_keys) +``` + +**پارامترها** + +- `join_storage_table_name` — an [شناسه](../syntax.md#syntax-identifiers) نشان می دهد که جستجو انجام شده است. شناسه در پایگاه داده به طور پیش فرض جستجو (پارامتر را ببینید `default_database` در فایل پیکربندی). برای نادیده گرفتن پایگاه داده پیش فرض از `USE db_name` یا پایگاه داده و جدول را از طریق جداساز مشخص کنید `db_name.db_table`, مثال را ببینید. +- `value_column` — name of the column of the table that contains required data. +- `join_keys` — list of keys. + +**مقدار بازگشتی** + +را برمی گرداند لیستی از ارزش مطابقت دارد به لیست کلید. + +اگر برخی در جدول منبع وجود ندارد و سپس `0` یا `null` خواهد شد بر اساس بازگشت [ارزشهای خبری عبارتند از:](../../operations/settings/settings.md#join_use_nulls) تنظیمات. + +اطلاعات بیشتر در مورد `join_use_nulls` داخل [پیوستن به عملیات](../../engines/table-engines/special/join.md). + +**مثال** + +جدول ورودی: + +``` sql +CREATE DATABASE db_test +CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 +INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) +``` + +``` text +┌─id─┬─val─┐ +│ 4 │ 13 │ +│ 2 │ 12 │ +│ 1 │ 11 │ +└────┴─────┘ +``` + +پرسوجو: + +``` sql +SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 +``` + +نتیجه: + +``` text +┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ +│ 0 │ +│ 11 │ +│ 12 │ +│ 0 │ +└──────────────────────────────────────────────────┘ +``` + +## modelEvaluate(model\_name, …) {#function-modelevaluate} + +ارزیابی مدل خارجی. +می پذیرد نام مدل و استدلال مدل. را برمی گرداند شناور64. + +## throwIf(x\[, custom\_message\]) {#throwifx-custom-message} + +پرتاب یک استثنا اگر استدلال غیر صفر است. +\_پیغام سفارشی-پارامتر اختیاری است: یک رشته ثابت, فراهم می کند یک پیغام خطا + +``` sql +SELECT throwIf(number = 3, 'Too many') FROM numbers(10); +``` + +``` text +↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): +Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. +``` + +## هویت {#identity} + +بازگرداندن همان مقدار که به عنوان استدلال خود مورد استفاده قرار گرفت. مورد استفاده برای اشکال زدایی و تست, اجازه می دهد تا به لغو با استفاده از شاخص, و عملکرد پرس و جو از یک اسکن کامل. هنگامی که پرس و جو برای استفاده احتمالی از شاخص تجزیه و تحلیل, تجزیه و تحلیل می کند در داخل نگاه نمی `identity` توابع. + +**نحو** + +``` sql +identity(x) +``` + +**مثال** + +پرسوجو: + +``` sql +SELECT identity(42) +``` + +نتیجه: + +``` text +┌─identity(42)─┐ +│ 42 │ +└──────────────┘ +``` + +## درباره ما {#randomascii} + +تولید یک رشته با مجموعه ای تصادفی از [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) شخصیت های قابل چاپ. + +**نحو** + +``` sql +randomPrintableASCII(length) +``` + +**پارامترها** + +- `length` — Resulting string length. Positive integer. + + If you pass `length < 0`, behavior of the function is undefined. + +**مقدار بازگشتی** + +- رشته با مجموعه ای تصادفی از [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) شخصیت های قابل چاپ. + +نوع: [رشته](../../sql-reference/data-types/string.md) + +**مثال** + +``` sql +SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 +``` + +``` text +┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ +│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ +│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ +│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ +└────────┴────────────────────────────────┴──────────────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/fa/sql-reference/functions/random-functions.md b/docs/fa/sql-reference/functions/random-functions.md new file mode 100644 index 00000000000..772d24885aa --- /dev/null +++ b/docs/fa/sql-reference/functions/random-functions.md @@ -0,0 +1,66 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 51 +toc_title: "\u062A\u0648\u0644\u06CC\u062F \u0627\u0639\u062F\u0627\u062F \u0634\u0628\ + \u0647 \u062A\u0635\u0627\u062F\u0641\u06CC" +--- + +# توابع برای تولید اعداد شبه تصادفی {#functions-for-generating-pseudo-random-numbers} + +ژنراتور غیر رمزنگاری اعداد شبه تصادفی استفاده می شود. + +تمام توابع قبول استدلال صفر و یا یک استدلال. +اگر استدلال به تصویب می رسد, این می تواند هر نوع, و ارزش خود را برای هر چیزی استفاده نمی شود. +تنها هدف از این استدلال این است که برای جلوگیری از حذف خشونت مشترک, به طوری که دو نمونه مختلف از همان تابع بازگشت ستون های مختلف با شماره های مختلف تصادفی. + +## رند {#rand} + +بازده یک شبه تصادفی UInt32 شماره به طور مساوی توزیع شده در میان تمام UInt32 از نوع اعداد است. +با استفاده از یک ژنراتور همخوان خطی. + +## رند64 {#rand64} + +بازده یک شبه تصادفی UInt64 شماره به طور مساوی توزیع شده در میان تمام UInt64 از نوع اعداد است. +با استفاده از یک ژنراتور همخوان خطی. + +## شرکت رندکونستانت {#randconstant} + +تولید یک ستون ثابت با یک مقدار تصادفی. + +**نحو** + +``` sql +randConstant([x]) +``` + +**پارامترها** + +- `x` — [عبارت](../syntax.md#syntax-expressions) در نتیجه در هر یک از [انواع داده های پشتیبانی شده](../data-types/index.md#data_types). ارزش حاصل دور انداخته می شود, اما بیان خود را اگر برای دور زدن استفاده [رفع ضعف مشترک](index.md#common-subexpression-elimination) اگر تابع چندین بار در یک پرس و جو نامیده می شود. پارامتر اختیاری. + +**مقدار بازگشتی** + +- عدد شبه تصادفی. + +نوع: [UInt32](../data-types/int-uint.md). + +**مثال** + +پرسوجو: + +``` sql +SELECT rand(), rand(1), rand(number), randConstant(), randConstant(1), randConstant(number) +FROM numbers(3) +``` + +نتیجه: + +``` text +┌─────rand()─┬────rand(1)─┬─rand(number)─┬─randConstant()─┬─randConstant(1)─┬─randConstant(number)─┐ +│ 3047369878 │ 4132449925 │ 4044508545 │ 2740811946 │ 4229401477 │ 1924032898 │ +│ 2938880146 │ 1267722397 │ 4154983056 │ 2740811946 │ 4229401477 │ 1924032898 │ +│ 956619638 │ 4238287282 │ 1104342490 │ 2740811946 │ 4229401477 │ 1924032898 │ +└────────────┴────────────┴──────────────┴────────────────┴─────────────────┴──────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/fa/sql-reference/functions/rounding-functions.md b/docs/fa/sql-reference/functions/rounding-functions.md new file mode 100644 index 00000000000..a11125290e4 --- /dev/null +++ b/docs/fa/sql-reference/functions/rounding-functions.md @@ -0,0 +1,190 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u06AF\u0631\u062F \u06A9\u0631\u062F\u0646" +--- + +# گرد کردن توابع {#rounding-functions} + +## طبقه (ایکس\]) {#floorx-n} + +بازگرداندن بیشترین تعداد دور است که کمتر از یا مساوی `x`. تعداد دور چند تن از 1/10 و یا نزدیکترین تعداد داده های مناسب نوع اگر 1 / 10 دقیق نیست. +‘N’ ثابت عدد صحیح است, پارامتر اختیاری. به طور پیش فرض صفر است, که به معنی به دور به یک عدد صحیح. +‘N’ ممکن است منفی باشد. + +مثالها: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` + +`x` هر نوع عددی است. نتیجه تعدادی از همان نوع است. +برای استدلال عدد صحیح را حس می کند به دور با منفی `N` ارزش (برای غیر منفی `N` تابع هیچ کاری نمی کند). +اگر گرد باعث سرریز (مثلا, کف سازی(-128, -1)), نتیجه اجرای خاص بازگشته است. + +## هشدار داده می شود\]) {#ceilx-n-ceilingx-n} + +بازگرداندن کوچکترین عدد دور است که بیشتر از یا مساوی `x`. در هر راه دیگر, این همان است که `floor` تابع (بالا را ببینید). + +## هشدار داده می شود\]) {#truncx-n-truncatex-n} + +بازگرداندن تعداد دور با بزرگترین ارزش مطلق است که ارزش مطلق کمتر یا مساوی `x`‘s. In every other way, it is the same as the ’floor’ تابع (بالا را ببینید). + +## دور (ایکس\]) {#rounding_functions-round} + +دور یک مقدار به تعداد مشخصی از رقم اعشار. + +تابع نزدیکترین تعداد از سفارش مشخص شده را برمی گرداند. در صورتی که تعداد داده شده است فاصله برابر با شماره های اطراف, تابع با استفاده از گرد کردن بانکدار برای انواع شماره شناور و دور به دور از صفر برای انواع شماره های دیگر. + +``` sql +round(expression [, decimal_places]) +``` + +**پارامترها:** + +- `expression` — A number to be rounded. Can be any [عبارت](../syntax.md#syntax-expressions) بازگشت عددی [نوع داده](../../sql-reference/data-types/index.md#data_types). +- `decimal-places` — An integer value. + - اگر `decimal-places > 0` سپس تابع دور ارزش به سمت راست از نقطه اعشار. + - اگر `decimal-places < 0` سپس تابع دور ارزش به سمت چپ نقطه اعشار. + - اگر `decimal-places = 0` سپس تابع دور ارزش به عدد صحیح. در این مورد استدلال را می توان حذف. + +**مقدار بازگشتی:** + +تعداد گرد از همان نوع به عنوان شماره ورودی. + +### مثالها {#examples} + +**مثال استفاده** + +``` sql +SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 +``` + +``` text +┌───x─┬─round(divide(number, 2))─┐ +│ 0 │ 0 │ +│ 0.5 │ 0 │ +│ 1 │ 1 │ +└─────┴──────────────────────────┘ +``` + +**نمونه هایی از گرد کردن** + +گرد کردن به نزدیکترین شماره. + +``` text +round(3.2, 0) = 3 +round(4.1267, 2) = 4.13 +round(22,-1) = 20 +round(467,-2) = 500 +round(-467,-2) = -500 +``` + +گرد کردن بانکدار. + +``` text +round(3.5) = 4 +round(4.5) = 4 +round(3.55, 1) = 3.6 +round(3.65, 1) = 3.6 +``` + +**همچنین نگاه کنید به** + +- [سرباز](#roundbankers) + +## سرباز {#roundbankers} + +دور یک عدد به یک موقعیت دهدهی مشخص شده است. + +- اگر تعداد گرد کردن در نیمه راه بین دو عدد است, تابع با استفاده از گرد کردن بانکدار. + + Banker's rounding is a method of rounding fractional numbers. When the rounding number is halfway between two numbers, it's rounded to the nearest even digit at the specified decimal position. For example: 3.5 rounds up to 4, 2.5 rounds down to 2. + + It's the default rounding method for floating point numbers defined in [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). The [round](#rounding_functions-round) function performs the same rounding for floating point numbers. The `roundBankers` function also rounds integers the same way, for example, `roundBankers(45, -1) = 40`. + +- در موارد دیگر تابع دور اعداد به نزدیکترین عدد صحیح. + +با استفاده از گرد کردن بانکدار, شما می توانید اثر است که گرد کردن اعداد در نتایج حاصل از جمع و یا کم کردن این اعداد را کاهش می دهد. + +مثلا, تعداد مجموع 1.5, 2.5, 3.5, 4.5 با گرد کردن متفاوت: + +- بدون گرد کردن: 1.5 + 2.5 + 3.5 + 4.5 = 12. +- گرد کردن بانکدار: 2 + 2 + 4 + 4 = 12. +- گرد کردن به نزدیکترین عدد صحیح: 2 + 3 + 4 + 5 = 14. + +**نحو** + +``` sql +roundBankers(expression [, decimal_places]) +``` + +**پارامترها** + +- `expression` — A number to be rounded. Can be any [عبارت](../syntax.md#syntax-expressions) بازگشت عددی [نوع داده](../../sql-reference/data-types/index.md#data_types). +- `decimal-places` — Decimal places. An integer number. + - `decimal-places > 0` — The function rounds the number to the given position right of the decimal point. Example: `roundBankers(3.55, 1) = 3.6`. + - `decimal-places < 0` — The function rounds the number to the given position left of the decimal point. Example: `roundBankers(24.55, -1) = 20`. + - `decimal-places = 0` — The function rounds the number to an integer. In this case the argument can be omitted. Example: `roundBankers(2.5) = 2`. + +**مقدار بازگشتی** + +ارزش گرد شده توسط روش گرد کردن بانکدار. + +### مثالها {#examples-1} + +**مثال استفاده** + +پرسوجو: + +``` sql + SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 +``` + +نتیجه: + +``` text +┌───x─┬─b─┐ +│ 0 │ 0 │ +│ 0.5 │ 0 │ +│ 1 │ 1 │ +│ 1.5 │ 2 │ +│ 2 │ 2 │ +│ 2.5 │ 2 │ +│ 3 │ 3 │ +│ 3.5 │ 4 │ +│ 4 │ 4 │ +│ 4.5 │ 4 │ +└─────┴───┘ +``` + +**نمونه هایی از گرد کردن بانکدار** + +``` text +roundBankers(0.4) = 0 +roundBankers(-3.5) = -4 +roundBankers(4.5) = 4 +roundBankers(3.55, 1) = 3.6 +roundBankers(3.65, 1) = 3.6 +roundBankers(10.35, 1) = 10.4 +roundBankers(10.755, 2) = 11,76 +``` + +**همچنین نگاه کنید به** + +- [گرد](#rounding_functions-round) + +## توسعه پایدار2) {#roundtoexp2num} + +می پذیرد تعداد. اگر تعداد کمتر از یک است, باز می گردد 0. در غیر این صورت, این دور تعداد پایین به نزدیکترین (مجموع غیر منفی) درجه دو. + +## طول عمر (تعداد) {#rounddurationnum} + +می پذیرد تعداد. اگر تعداد کمتر از یک است, باز می گردد 0. در غیر این صورت, این دور تعداد را به اعداد از مجموعه: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. این تابع خاص به یاندکس است.متریکا و مورد استفاده برای اجرای گزارش در طول جلسه. + +## عدد) {#roundagenum} + +می پذیرد تعداد. اگر تعداد کمتر از است 18, باز می گردد 0. در غیر این صورت, این دور تعداد را به یک عدد از مجموعه: 18, 25, 35, 45, 55. این تابع خاص به یاندکس است.متریکا و مورد استفاده برای اجرای گزارش در سن کاربر. + +## roundDown(num arr) {#rounddownnum-arr} + +یک عدد را می پذیرد و به یک عنصر در مجموعه مشخص شده منتقل می کند. اگر مقدار کمتر از پایین ترین حد محدود است, پایین ترین حد بازگشته است. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/fa/sql-reference/functions/splitting-merging-functions.md b/docs/fa/sql-reference/functions/splitting-merging-functions.md new file mode 100644 index 00000000000..75046b72307 --- /dev/null +++ b/docs/fa/sql-reference/functions/splitting-merging-functions.md @@ -0,0 +1,117 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: "\u062A\u0642\u0633\u06CC\u0645 \u0648 \u0627\u062F\u063A\u0627\u0645 \u0631\ + \u0634\u062A\u0647 \u0647\u0627 \u0648 \u0627\u0631\u0631\u06CC\u0633" +--- + +# توابع برای تقسیم و ادغام رشته ها و ارریس {#functions-for-splitting-and-merging-strings-and-arrays} + +## اسپلیت بیچار (جداساز) {#splitbycharseparator-s} + +انشعابات یک رشته به بسترهای جدا شده توسط یک شخصیت مشخص شده است. با استفاده از یک رشته ثابت `separator` که متشکل از دقیقا یک شخصیت. +بازگرداندن مجموعه ای از بسترهای انتخاب. بسترهای خالی ممکن است انتخاب شود اگر جدا در ابتدا یا انتهای رشته رخ می دهد, و یا اگر چند جداکننده متوالی وجود دارد. + +**نحو** + +``` sql +splitByChar(, ) +``` + +**پارامترها** + +- `separator` — The separator which should contain exactly one character. [رشته](../../sql-reference/data-types/string.md). +- `s` — The string to split. [رشته](../../sql-reference/data-types/string.md). + +**مقدار بازگشتی)** + +بازگرداندن مجموعه ای از بسترهای انتخاب. بسترهای خالی ممکن است انتخاب شود که: + +- جداساز در ابتدا یا انتهای رشته رخ می دهد; +- چندین جداکننده متوالی وجود دارد; +- رشته اصلی `s` خالیه + +نوع: [& حذف](../../sql-reference/data-types/array.md) از [رشته](../../sql-reference/data-types/string.md). + +**مثال** + +``` sql +SELECT splitByChar(',', '1,2,3,abcde') +``` + +``` text +┌─splitByChar(',', '1,2,3,abcde')─┐ +│ ['1','2','3','abcde'] │ +└─────────────────────────────────┘ +``` + +## رشته اسپلیتبیست (جداساز) {#splitbystringseparator-s} + +انشعابات یک رشته به بسترهای جدا شده توسط یک رشته. با استفاده از یک رشته ثابت `separator` از شخصیت های متعدد به عنوان جدا کننده. اگر رشته `separator` خالی است, این رشته تقسیم `s` به مجموعه ای از شخصیت های تک. + +**نحو** + +``` sql +splitByString(, ) +``` + +**پارامترها** + +- `separator` — The separator. [رشته](../../sql-reference/data-types/string.md). +- `s` — The string to split. [رشته](../../sql-reference/data-types/string.md). + +**مقدار بازگشتی)** + +بازگرداندن مجموعه ای از بسترهای انتخاب. بسترهای خالی ممکن است انتخاب شود که: + +نوع: [& حذف](../../sql-reference/data-types/array.md) از [رشته](../../sql-reference/data-types/string.md). + +- جدا کننده غیر خالی در ابتدا یا انتهای رشته رخ می دهد; +- چند جدا متوالی غیر خالی وجود دارد; +- رشته اصلی `s` خالی است در حالی که جدا خالی نیست. + +**مثال** + +``` sql +SELECT splitByString(', ', '1, 2 3, 4,5, abcde') +``` + +``` text +┌─splitByString(', ', '1, 2 3, 4,5, abcde')─┐ +│ ['1','2 3','4,5','abcde'] │ +└───────────────────────────────────────────┘ +``` + +``` sql +SELECT splitByString('', 'abcde') +``` + +``` text +┌─splitByString('', 'abcde')─┐ +│ ['a','b','c','d','e'] │ +└────────────────────────────┘ +``` + +## حذف میانبر در صفحه خانه\]) {#arraystringconcatarr-separator} + +رشته های ذکر شده در مجموعه را با جداساز مطابقت می دهد.'جدا کننده' پارامتر اختیاری است: یک رشته ثابت, مجموعه ای به یک رشته خالی به طور پیش فرض. +رشته را برمی گرداند. + +## اطلاعات دقیق) {#alphatokenss} + +انتخاب substrings متوالی بایت از محدوده a-z و A-Z. بازگرداندن یک آرایه از substrings. + +**مثال** + +``` sql +SELECT alphaTokens('abca1abc') +``` + +``` text +┌─alphaTokens('abca1abc')─┐ +│ ['abca','abc'] │ +└─────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/fa/sql-reference/functions/string-functions.md b/docs/fa/sql-reference/functions/string-functions.md new file mode 100644 index 00000000000..cc69b6fce32 --- /dev/null +++ b/docs/fa/sql-reference/functions/string-functions.md @@ -0,0 +1,489 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0631\u0634\u062A\u0647 \u0647\u0627" +--- + +# توابع برای کار با رشته {#functions-for-working-with-strings} + +## خالی {#empty} + +بازده 1 برای یک رشته خالی و یا 0 برای یک رشته غیر خالی. +نتیجه این نوع UInt8. +یک رشته در نظر گرفته شده است غیر خالی اگر شامل حداقل یک بایت, حتی اگر این یک فضا یا یک بایت پوچ است. +این تابع همچنین برای ارریس کار می کند. + +## notEmpty {#notempty} + +بازده 0 برای یک رشته خالی یا 1 برای یک رشته غیر خالی. +نتیجه این نوع UInt8. +این تابع همچنین برای ارریس کار می کند. + +## طول {#length} + +بازگرداندن طول یک رشته در بایت (نه در شخصیت, و نه در نقاط کد). +نتیجه این نوع UInt64. +این تابع همچنین برای ارریس کار می کند. + +## طول 8 {#lengthutf8} + +بازگرداندن طول یک رشته در نقاط کد یونیکد (نه در شخصیت), فرض کنید که رشته شامل مجموعه ای از بایت است که متن کد گذاری شده را تشکیل می دهند. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). +نتیجه این نوع UInt64. + +## \_شروع مجدد {#char-length} + +بازگرداندن طول یک رشته در نقاط کد یونیکد (نه در شخصیت), فرض کنید که رشته شامل مجموعه ای از بایت است که متن کد گذاری شده را تشکیل می دهند. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). +نتیجه این نوع UInt64. + +## \_شخصیت شناسی {#character-length} + +بازگرداندن طول یک رشته در نقاط کد یونیکد (نه در شخصیت), فرض کنید که رشته شامل مجموعه ای از بایت است که متن کد گذاری شده را تشکیل می دهند. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). +نتیجه این نوع UInt64. + +## پایین تر {#lower} + +تبدیل نمادهای اسکی لاتین در یک رشته به حروف کوچک. + +## بالارفتن {#upper} + +تبدیل نمادهای اسکی لاتین در یک رشته به حروف بزرگ. + +## لوراتف8 {#lowerutf8} + +تبدیل یک رشته به حروف کوچک, فرض رشته شامل مجموعه ای از بایت که یک متن کد گذاری شده-8 را تشکیل می دهند. +این زبان را تشخیص نمی دهد. بنابراین برای ترکیه نتیجه ممکن است دقیقا درست باشد. +اگر طول توالی یونایتد-8 بایت برای مورد بالا و پایین تر از یک نقطه کد متفاوت است, نتیجه ممکن است برای این نقطه کد نادرست. +اگر رشته شامل مجموعه ای از بایت است که سخن گفتن نیست-8, سپس رفتار تعریف نشده است. + +## یوتف8 {#upperutf8} + +تبدیل یک رشته به حروف بزرگ, فرض رشته شامل مجموعه ای از بایت که یک متن کد گذاری شده-8 را تشکیل می دهند. +این زبان را تشخیص نمی دهد. بنابراین برای ترکیه نتیجه ممکن است دقیقا درست باشد. +اگر طول توالی یونایتد-8 بایت برای مورد بالا و پایین تر از یک نقطه کد متفاوت است, نتیجه ممکن است برای این نقطه کد نادرست. +اگر رشته شامل مجموعه ای از بایت است که سخن گفتن نیست-8, سپس رفتار تعریف نشده است. + +## اسوالدیدوتف8 {#isvalidutf8} + +بازده 1, اگر مجموعه ای از کلمه در ادامه متن معتبر است-8 کد گذاری, در غیر این صورت 0. + +## تولدیدوتف8 {#tovalidutf8} + +8 کاراکتر نامعتبر را جایگزین می کند `�` اطلاعات دقیق همه در حال اجرا در یک ردیف شخصیت نامعتبر را به یک شخصیت جایگزین فرو ریخت. + +``` sql +toValidUTF8( input_string ) +``` + +پارامترها: + +- input\_string — Any set of bytes represented as the [رشته](../../sql-reference/data-types/string.md) شی نوع داده. + +مقدار بازگشتی: معتبر یونایتد-8 رشته. + +**مثال** + +``` sql +SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') +``` + +``` text +┌─toValidUTF8('a����b')─┐ +│ a�b │ +└───────────────────────┘ +``` + +## تکرار {#repeat} + +تکرار یک رشته را به عنوان چند بار به عنوان مشخص شده و concatenates تکراری ارزش به عنوان یک رشته است. + +**نحو** + +``` sql +repeat(s, n) +``` + +**پارامترها** + +- `s` — The string to repeat. [رشته](../../sql-reference/data-types/string.md). +- `n` — The number of times to repeat the string. [اینترنت](../../sql-reference/data-types/int-uint.md). + +**مقدار بازگشتی** + +تک رشته ای که حاوی رشته است `s` تکرار `n` زمان. اگر `n` \< 1, تابع رشته خالی می گرداند. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT repeat('abc', 10) +``` + +نتیجه: + +``` text +┌─repeat('abc', 10)──────────────┐ +│ abcabcabcabcabcabcabcabcabcabc │ +└────────────────────────────────┘ +``` + +## معکوس {#reverse} + +معکوس رشته (به عنوان یک دنباله از بایت). + +## معکوس کردن8 {#reverseutf8} + +معکوس دنباله ای از نقاط کد یونیکد, فرض کنید که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن گفته-8. در غیر این صورت, این کار چیز دیگری (این یک استثنا پرتاب نمی). + +## format(pattern, s0, s1, …) {#format} + +قالب بندی الگوی ثابت با رشته ذکر شده در استدلال. `pattern` یک الگوی فرمت پایتون ساده شده است. رشته فرمت شامل “replacement fields” احاطه شده توسط پرانتز فرفری `{}`. هر چیزی که در پرانتز موجود نیست در نظر گرفته شده است متن تحت اللفظی است که بدون تغییر به خروجی کپی شده است. اگر شما نیاز به شامل یک شخصیت بند در متن تحت اللفظی, این را می توان با دو برابر فرار: `{{ '{{' }}` و `{{ '}}' }}`. نام فیلد می تواند اعداد (با شروع از صفر) یا خالی (سپس به عنوان شماره نتیجه درمان می شوند). + +``` sql +SELECT format('{1} {0} {1}', 'World', 'Hello') +``` + +``` text +┌─format('{1} {0} {1}', 'World', 'Hello')─┐ +│ Hello World Hello │ +└─────────────────────────────────────────┘ +``` + +``` sql +SELECT format('{} {}', 'Hello', 'World') +``` + +``` text +┌─format('{} {}', 'Hello', 'World')─┐ +│ Hello World │ +└───────────────────────────────────┘ +``` + +## الحاق {#concat} + +رشته های ذکر شده در استدلال بدون جدا کننده را تصدیق می کند. + +**نحو** + +``` sql +concat(s1, s2, ...) +``` + +**پارامترها** + +ارزش رشته نوع و یا رشته ثابت. + +**مقادیر بازگشتی** + +را برمی گرداند رشته ای که منجر به از الحاق استدلال. + +اگر هر یک از مقادیر استدلال است `NULL`, `concat` بازگشت `NULL`. + +**مثال** + +پرسوجو: + +``` sql +SELECT concat('Hello, ', 'World!') +``` + +نتیجه: + +``` text +┌─concat('Hello, ', 'World!')─┐ +│ Hello, World! │ +└─────────────────────────────┘ +``` + +## همبسته {#concatassumeinjective} + +مثل [الحاق](#concat) تفاوت این است که شما نیاز به اطمینان حاصل شود که `concat(s1, s2, ...) → sn` این برای بهینه سازی گروه توسط استفاده می شود. + +تابع به نام “injective” اگر همیشه نتیجه های مختلف برای مقادیر مختلف استدلال می گرداند. به عبارت دیگر: استدلال های مختلف هرگز نتیجه یکسان عملکرد. + +**نحو** + +``` sql +concatAssumeInjective(s1, s2, ...) +``` + +**پارامترها** + +ارزش رشته نوع و یا رشته ثابت. + +**مقادیر بازگشتی** + +را برمی گرداند رشته ای که منجر به از الحاق استدلال. + +اگر هر یک از مقادیر استدلال است `NULL`, `concatAssumeInjective` بازگشت `NULL`. + +**مثال** + +جدول ورودی: + +``` sql +CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog; +INSERT INTO key_val VALUES ('Hello, ','World',1), ('Hello, ','World',2), ('Hello, ','World!',3), ('Hello',', World!',2); +SELECT * from key_val; +``` + +``` text +┌─key1────┬─key2─────┬─value─┐ +│ Hello, │ World │ 1 │ +│ Hello, │ World │ 2 │ +│ Hello, │ World! │ 3 │ +│ Hello │ , World! │ 2 │ +└─────────┴──────────┴───────┘ +``` + +پرسوجو: + +``` sql +SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY concatAssumeInjective(key1, key2) +``` + +نتیجه: + +``` text +┌─concat(key1, key2)─┬─sum(value)─┐ +│ Hello, World! │ 3 │ +│ Hello, World! │ 2 │ +│ Hello, World │ 3 │ +└────────────────────┴────────────┘ +``` + +## زیر رشته(بازدید کنندگان, انحراف, طول), اواسط(بازدید کنندگان, انحراف, طول), عام (بازدید کنندگان, انحراف, طول) {#substring} + +بازگرداندن یک رشته شروع با بایت از ‘offset’ شاخص این است ‘length’ کلمه در ادامه متن طولانی. نمایه سازی شخصیت از یک شروع می شود (همانطور که در گذاشتن استاندارد). این ‘offset’ و ‘length’ استدلال باید ثابت باشد. + +## زیر بغل کردن 8(بازدید کنندگان, انحراف, طول) {#substringutf8} + +همان ‘substring’, اما برای نقاط کد یونیکد. این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده وزارت مخابرات 8. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). + +## appendTrailingCharIfAbsent(s, c) {#appendtrailingcharifabsent} + +اگر ‘s’ رشته غیر خالی است و حاوی نیست ‘c’ شخصیت در پایان این برنامه ‘c’ شخصیت به پایان. + +## تبدیل(بازدید کنندگان, از, به) {#convertcharset} + +بازگرداندن رشته ‘s’ که از رمزگذاری در تبدیل شد ‘from’ به رمزگذاری در ‘to’. + +## کد زیر 64) {#base64encode} + +کدگذاریها ‘s’ رشته به پایگاه64 + +## کد زیر 64) {#base64decode} + +رمزگشایی پایگاه64-رشته کد گذاری شده ‘s’ به رشته اصلی. در صورت شکست را افزایش می دهد یک استثنا. + +## تریباس64دسیدی) {#trybase64decode} + +شبیه به حالت کد باس64, اما در صورت خطا یک رشته خالی می شود بازگشت. + +## endsWith(s, پسوند) {#endswith} + +بازگرداندن اینکه با پسوند مشخص شده پایان یابد. بازده 1 اگر رشته به پایان می رسد با پسوند مشخص, در غیر این صورت باز می گردد 0. + +## startsWith(str, پیشوند) {#startswith} + +بازده 1 اینکه رشته با پیشوند مشخص شروع می شود, در غیر این صورت باز می گردد 0. + +``` sql +SELECT startsWith('Spider-Man', 'Spi'); +``` + +**مقادیر بازگشتی** + +- 1, اگر رشته با پیشوند مشخص شروع می شود. +- 0, اگر رشته با پیشوند مشخص شروع نشد. + +**مثال** + +پرسوجو: + +``` sql +SELECT startsWith('Hello, world!', 'He'); +``` + +نتیجه: + +``` text +┌─startsWith('Hello, world!', 'He')─┐ +│ 1 │ +└───────────────────────────────────┘ +``` + +## تر و تمیز {#trim} + +حذف تمام شخصیت های مشخص شده از شروع یا پایان یک رشته. +به طور پیش فرض حذف همه وقوع متوالی از فضای سفید مشترک (شخصیت اسکی 32) از هر دو به پایان می رسد از یک رشته. + +**نحو** + +``` sql +trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) +``` + +**پارامترها** + +- `trim_character` — specified characters for trim. [رشته](../../sql-reference/data-types/string.md). +- `input_string` — string for trim. [رشته](../../sql-reference/data-types/string.md). + +**مقدار بازگشتی** + +یک رشته بدون پیشرو و (یا) انتهایی شخصیت مشخص شده است. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT trim(BOTH ' ()' FROM '( Hello, world! )') +``` + +نتیجه: + +``` text +┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ +│ Hello, world! │ +└───────────────────────────────────────────────┘ +``` + +## trimLeft {#trimleft} + +حذف تمام رخدادهای متوالی از فضای سفید مشترک (شخصیت اسکی 32) از ابتدای یک رشته. این کار انواع دیگر از شخصیت های فضای سفید را حذف کنید (باریکه, فضای بدون استراحت, و غیره.). + +**نحو** + +``` sql +trimLeft(input_string) +``` + +نام مستعار: `ltrim(input_string)`. + +**پارامترها** + +- `input_string` — string to trim. [رشته](../../sql-reference/data-types/string.md). + +**مقدار بازگشتی** + +یک رشته بدون پیشرو فضاهای سفید مشترک. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT trimLeft(' Hello, world! ') +``` + +نتیجه: + +``` text +┌─trimLeft(' Hello, world! ')─┐ +│ Hello, world! │ +└─────────────────────────────────────┘ +``` + +## trimRight {#trimright} + +حذف تمام رخدادهای متوالی از فضای سفید مشترک (شخصیت اسکی 32) از پایان یک رشته. این کار انواع دیگر از شخصیت های فضای سفید را حذف کنید (باریکه, فضای بدون استراحت, و غیره.). + +**نحو** + +``` sql +trimRight(input_string) +``` + +نام مستعار: `rtrim(input_string)`. + +**پارامترها** + +- `input_string` — string to trim. [رشته](../../sql-reference/data-types/string.md). + +**مقدار بازگشتی** + +یک رشته بدون انتهایی فضاهای خالی مشترک. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT trimRight(' Hello, world! ') +``` + +نتیجه: + +``` text +┌─trimRight(' Hello, world! ')─┐ +│ Hello, world! │ +└──────────────────────────────────────┘ +``` + +## اصلاح {#trimboth} + +حذف تمام رخدادهای متوالی از فضای سفید مشترک (شخصیت اسکی 32) از هر دو به پایان می رسد از یک رشته. این کار انواع دیگر از شخصیت های فضای سفید را حذف کنید (باریکه, فضای بدون استراحت, و غیره.). + +**نحو** + +``` sql +trimBoth(input_string) +``` + +نام مستعار: `trim(input_string)`. + +**پارامترها** + +- `input_string` — string to trim. [رشته](../../sql-reference/data-types/string.md). + +**مقدار بازگشتی** + +یک رشته بدون پیشرو و انتهایی فضاهای سفید مشترک. + +نوع: `String`. + +**مثال** + +پرسوجو: + +``` sql +SELECT trimBoth(' Hello, world! ') +``` + +نتیجه: + +``` text +┌─trimBoth(' Hello, world! ')─┐ +│ Hello, world! │ +└─────────────────────────────────────┘ +``` + +## CRC32(s) {#crc32} + +بازگرداندن کنترلی از یک رشته, با استفاده از کروک-32-یی 802.3 چند جملهای و مقدار اولیه `0xffffffff` هشدار داده می شود + +نتیجه این نوع UInt32. + +## CRC32IEEE(s) {#crc32ieee} + +را برمی گرداند کنترل از یک رشته, با استفاده از کروم-32-یی 802.3 چند جملهای. + +نتیجه این نوع UInt32. + +## CRC64(s) {#crc64} + +بازده CRC64 کنترلی از یک رشته با استفاده از CRC-64-ECMA چند جملهای. + +نتیجه این نوع UInt64. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/fa/sql-reference/functions/string-replace-functions.md b/docs/fa/sql-reference/functions/string-replace-functions.md new file mode 100644 index 00000000000..37551549ab5 --- /dev/null +++ b/docs/fa/sql-reference/functions/string-replace-functions.md @@ -0,0 +1,95 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u0628\u0631\u0627\u06CC \u062C\u0627\u06CC\u06AF\u0632\u06CC\u0646\u06CC\ + \ \u062F\u0631 \u0631\u0634\u062A\u0647\u0647\u0627" +--- + +# توابع برای جستجو و جایگزینی در رشته ها {#functions-for-searching-and-replacing-in-strings} + +## جایگزینی جایگزین) {#replaceonehaystack-pattern-replacement} + +جایگزین وقوع اول, در صورت وجود, از ‘pattern’ زیر رشته در ‘haystack’ با ‘replacement’ زیر رشته. +از این پس, ‘pattern’ و ‘replacement’ حتما ثابته + +## replaceAll(haystack, الگوی جایگزینی) جایگزین(haystack, الگوی جایگزینی) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} + +جایگزین تمام اتفاقات ‘pattern’ زیر رشته در ‘haystack’ با ‘replacement’ زیر رشته. + +## جایگزین کردن الگوی جایگزین) {#replaceregexponehaystack-pattern-replacement} + +جایگزینی با استفاده از ‘pattern’ عبارت منظم. دوباره2 عبارت منظم. +جایگزین تنها وقوع اول, در صورت وجود. +یک الگو را می توان به عنوان ‘replacement’. این الگو می تواند شامل تعویض `\0-\9`. +جایگزینی `\0` شامل کل عبارت منظم. درحال جایگزینی `\1-\9` مربوط به زیرخط numbers.To استفاده از `\` شخصیت در قالب, فرار با استفاده از `\`. +همچنین در نظر داشته باشید که یک رشته تحت اللفظی نیاز به فرار اضافی نگه دارید. + +مثال 1. تبدیل تاریخ به فرمت امریکایی: + +``` sql +SELECT DISTINCT + EventDate, + replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res +FROM test.hits +LIMIT 7 +FORMAT TabSeparated +``` + +``` text +2014-03-17 03/17/2014 +2014-03-18 03/18/2014 +2014-03-19 03/19/2014 +2014-03-20 03/20/2014 +2014-03-21 03/21/2014 +2014-03-22 03/22/2014 +2014-03-23 03/23/2014 +``` + +مثال 2. کپی کردن یک رشته ده بار: + +``` sql +SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res +``` + +``` text +┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ +└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## جایگزین کردن الگوی جایگزین) {#replaceregexpallhaystack-pattern-replacement} + +این کار همان چیزی, اما جایگزین همه وقوع. مثال: + +``` sql +SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res +``` + +``` text +┌─res────────────────────────┐ +│ HHeelllloo,, WWoorrlldd!! │ +└────────────────────────────┘ +``` + +به عنوان یک استثنا, اگر یک عبارت منظم در زیر رشته خالی کار می کرد, جایگزینی بیش از یک بار ساخته شده است. +مثال: + +``` sql +SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res +``` + +``` text +┌─res─────────────────┐ +│ here: Hello, World! │ +└─────────────────────┘ +``` + +## سرویس پرداخت درونبرنامهای پلی) {#regexpquotemetas} + +تابع می افزاید: یک بک اسلش قبل از برخی از شخصیت های از پیش تعریف شده در رشته. +نویسههای از پیش تعریفشده: ‘0’, ‘\\’, ‘\|’, ‘(’, ‘)’, ‘^’, ‘$’, ‘.’, ‘\[’, '\]', ‘?’, '\*‘,’+‘,’{‘,’:‘,’-'. +این اجرای کمی از دوباره متفاوت2::پاسخ2:: نقل قول. این فرار صفر بایت به عنوان \\ 0 بجای 00 و فرار شخصیت تنها مورد نیاز. +برای کسب اطلاعات بیشتر به لینک مراجعه کنید: [RE2](https://github.com/google/re2/blob/master/re2/re2.cc#L473) + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/fa/sql-reference/functions/string-search-functions.md b/docs/fa/sql-reference/functions/string-search-functions.md new file mode 100644 index 00000000000..af68dee0afa --- /dev/null +++ b/docs/fa/sql-reference/functions/string-search-functions.md @@ -0,0 +1,380 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u0628\u0631\u0627\u06CC \u062C\u0633\u062A\u062C\u0648\u06CC \u0631\u0634\ + \u062A\u0647\u0647\u0627" +--- + +# توابع برای جستجوی رشته ها {#functions-for-searching-strings} + +جستجو به طور پیش فرض در تمام این توابع حساس به حروف است. انواع جداگانه ای برای جستجوی غیر حساس مورد وجود دارد. + +## موقعیت (انبار کاه, سوزن), تعیین محل (انبار کاه, سوزن) {#position} + +بازگرداندن موقعیت (به بایت) از رشته پیدا شده است در رشته, با شروع از 1. + +این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری تک بایت. اگر این فرض ملاقات کرد و یک شخصیت نمی تواند با استفاده از یک بایت تنها نشان داده شود, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو بایت نشان, این دو بایت و غیره استفاده. + +برای یک جستجو غیر حساس به حالت, استفاده از تابع [حساس به حالت](#positioncaseinsensitive). + +**نحو** + +``` sql +position(haystack, needle) +``` + +نام مستعار: `locate(haystack, needle)`. + +**پارامترها** + +- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). + +**مقادیر بازگشتی** + +- موقعیت شروع در بایت (شمارش از 1), اگر زیر رشته پیدا شد. +- 0, اگر زیر رشته یافت نشد. + +نوع: `Integer`. + +**مثالها** + +عبارت “Hello, world!” شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری تک بایت. تابع بازده برخی از نتیجه انتظار می رود: + +پرسوجو: + +``` sql +SELECT position('Hello, world!', '!') +``` + +نتیجه: + +``` text +┌─position('Hello, world!', '!')─┐ +│ 13 │ +└────────────────────────────────┘ +``` + +همان عبارت در روسیه شامل شخصیت های که نمی تواند با استفاده از یک بایت نشان داده شود. تابع بازده برخی از نتیجه غیر منتظره (استفاده [موقعیت 8](#positionutf8) تابع برای متن چند بایت کد گذاری): + +پرسوجو: + +``` sql +SELECT position('Привет, мир!', '!') +``` + +نتیجه: + +``` text +┌─position('Привет, мир!', '!')─┐ +│ 21 │ +└───────────────────────────────┘ +``` + +## حساس به حالت {#positioncaseinsensitive} + +همان [موقعیت](#position) بازگرداندن موقعیت (به بایت) از رشته پیدا شده است در رشته, با شروع از 1. استفاده از تابع برای یک جستجو غیر حساس به حالت. + +این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری تک بایت. اگر این فرض ملاقات کرد و یک شخصیت نمی تواند با استفاده از یک بایت تنها نشان داده شود, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو بایت نشان, این دو بایت و غیره استفاده. + +**نحو** + +``` sql +positionCaseInsensitive(haystack, needle) +``` + +**پارامترها** + +- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). + +**مقادیر بازگشتی** + +- موقعیت شروع در بایت (شمارش از 1), اگر زیر رشته پیدا شد. +- 0, اگر زیر رشته یافت نشد. + +نوع: `Integer`. + +**مثال** + +پرسوجو: + +``` sql +SELECT positionCaseInsensitive('Hello, world!', 'hello') +``` + +نتیجه: + +``` text +┌─positionCaseInsensitive('Hello, world!', 'hello')─┐ +│ 1 │ +└───────────────────────────────────────────────────┘ +``` + +## موقعیت 8 {#positionutf8} + +بازگرداندن موقعیت (در نقاط یونیکد) از رشته پیدا شده است در رشته, با شروع از 1. + +این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده وزارت مخابرات 8. اگر این فرض ملاقات نمی, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو نقطه یونیکد نشان, این دو و غیره استفاده. + +برای یک جستجو غیر حساس به حالت, استفاده از تابع [در حال بارگذاری](#positioncaseinsensitiveutf8). + +**نحو** + +``` sql +positionUTF8(haystack, needle) +``` + +**پارامترها** + +- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). + +**مقادیر بازگشتی** + +- موقعیت شروع در یونیکد امتیاز (شمارش از 1), اگر زیر رشته پیدا شد. +- 0, اگر زیر رشته یافت نشد. + +نوع: `Integer`. + +**مثالها** + +عبارت “Hello, world!” در روسیه شامل مجموعه ای از نقاط یونیکد نمایندگی یک متن کد گذاری تک نقطه. تابع بازده برخی از نتیجه انتظار می رود: + +پرسوجو: + +``` sql +SELECT positionUTF8('Привет, мир!', '!') +``` + +نتیجه: + +``` text +┌─positionUTF8('Привет, мир!', '!')─┐ +│ 12 │ +└───────────────────────────────────┘ +``` + +عبارت “Salut, étudiante!”, جایی که شخصیت `é` می توان با استفاده از یک نقطه نشان داد (`U+00E9`) یا دو نقطه (`U+0065U+0301`) تابع را می توان بازگشت برخی از نتیجه غیر منتظره: + +پرسوجو برای نامه `é` که نشان داده شده است یک نقطه یونیکد `U+00E9`: + +``` sql +SELECT positionUTF8('Salut, étudiante!', '!') +``` + +نتیجه: + +``` text +┌─positionUTF8('Salut, étudiante!', '!')─┐ +│ 17 │ +└────────────────────────────────────────┘ +``` + +پرسوجو برای نامه `é` که به نمایندگی از دو نقطه یونیکد `U+0065U+0301`: + +``` sql +SELECT positionUTF8('Salut, étudiante!', '!') +``` + +نتیجه: + +``` text +┌─positionUTF8('Salut, étudiante!', '!')─┐ +│ 18 │ +└────────────────────────────────────────┘ +``` + +## در حال بارگذاری {#positioncaseinsensitiveutf8} + +همان [موقعیت 8](#positionutf8), اما غیر حساس به حروف است. بازگرداندن موقعیت (در نقاط یونیکد) از رشته پیدا شده است در رشته, با شروع از 1. + +این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده وزارت مخابرات 8. اگر این فرض ملاقات نمی, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو نقطه یونیکد نشان, این دو و غیره استفاده. + +**نحو** + +``` sql +positionCaseInsensitiveUTF8(haystack, needle) +``` + +**پارامترها** + +- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). + +**مقدار بازگشتی** + +- موقعیت شروع در یونیکد امتیاز (شمارش از 1), اگر زیر رشته پیدا شد. +- 0, اگر زیر رشته یافت نشد. + +نوع: `Integer`. + +**مثال** + +پرسوجو: + +``` sql +SELECT positionCaseInsensitiveUTF8('Привет, мир!', 'Мир') +``` + +نتیجه: + +``` text +┌─positionCaseInsensitiveUTF8('Привет, мир!', 'Мир')─┐ +│ 9 │ +└────────────────────────────────────────────────────┘ +``` + +## چند ضلعی {#multisearchallpositions} + +همان [موقعیت](string-search-functions.md#position) اما بازگشت `Array` از موقعیت (به بایت) از بسترهای مربوطه موجود در رشته. موقعیت ها با شروع از نمایه 1. + +جستجو در دنباله ای از بایت بدون توجه به رمزگذاری رشته و میترا انجام می شود. + +- برای جستجو اسکی غیر حساس به حالت, استفاده از تابع `multiSearchAllPositionsCaseInsensitive`. +- برای جستجو در یوتف-8, استفاده از تابع [چند ضلعی پایگاه داده های8](#multiSearchAllPositionsUTF8). +- برای غیر حساس به حالت جستجو-8, استفاده از تابع چند تخصیص چندگانه 18. + +**نحو** + +``` sql +multiSearchAllPositions(haystack, [needle1, needle2, ..., needlen]) +``` + +**پارامترها** + +- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). + +**مقادیر بازگشتی** + +- مجموعه ای از موقعیت های شروع در بایت (شمارش از 1), اگر زیر رشته مربوطه پیدا شد و 0 اگر یافت نشد. + +**مثال** + +پرسوجو: + +``` sql +SELECT multiSearchAllPositions('Hello, World!', ['hello', '!', 'world']) +``` + +نتیجه: + +``` text +┌─multiSearchAllPositions('Hello, World!', ['hello', '!', 'world'])─┐ +│ [0,13,0] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## چند ضلعی پایگاه داده های8 {#multiSearchAllPositionsUTF8} + +ببینید `multiSearchAllPositions`. + +## ترکیب چندجفتاری (هیستک, \[سوزن1 سوزن2, …, needleنه\]) {#multisearchfirstposition} + +همان `position` اما بازده سمت چپ افست از رشته `haystack` که به برخی از سوزن همسان. + +برای یک جستجوی غیر حساس مورد و یا / و در توابع استفاده از فرمت جی تی اف 8 `multiSearchFirstPositionCaseInsensitive, multiSearchFirstPositionUTF8, multiSearchFirstPositionCaseInsensitiveUTF8`. + +## مقالههای جدید مرتبط با تحقیق این نویسنده1 سوزن2, …, needleنه\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} + +بازگرداندن شاخص `i` (شروع از 1) سوزن چپ پیدا شده استمن ... در رشته `haystack` و 0 در غیر این صورت. + +برای یک جستجوی غیر حساس مورد و یا / و در توابع استفاده از فرمت جی تی اف 8 `multiSearchFirstIndexCaseInsensitive, multiSearchFirstIndexUTF8, multiSearchFirstIndexCaseInsensitiveUTF8`. + +## مولسیرچانی (هیستک, \[سوزن1 سوزن2, …, needleنه\]) {#function-multisearchany} + +بازده 1, اگر حداقل یک سوزن رشتهمن ... مسابقات رشته `haystack` و 0 در غیر این صورت. + +برای یک جستجوی غیر حساس مورد و یا / و در توابع استفاده از فرمت جی تی اف 8 `multiSearchAnyCaseInsensitive, multiSearchAnyUTF8, multiSearchAnyCaseInsensitiveUTF8`. + +!!! note "یادداشت" + در همه `multiSearch*` توابع تعداد سوزن ها باید کمتر از 2 باشد8 به دلیل مشخصات پیاده سازی. + +## همخوانی داشتن (کومه علف خشک, الگو) {#matchhaystack-pattern} + +بررسی اینکه رشته با `pattern` عبارت منظم. یک `re2` عبارت منظم. این [نحو](https://github.com/google/re2/wiki/Syntax) از `re2` عبارات منظم محدود تر از نحو عبارات منظم پرل است. + +بازده 0 اگر مطابقت ندارد, یا 1 اگر منطبق. + +توجه داشته باشید که نماد ممیز (`\`) برای فرار در عبارت منظم استفاده می شود. همان نماد برای فرار در لیتر رشته استفاده می شود. بنابراین به منظور فرار از نماد در یک عبارت منظم, شما باید دو بک اسلش ارسال (\\) در یک رشته تحت اللفظی. + +عبارت منظم با رشته کار می کند به عنوان اگر مجموعه ای از بایت است. عبارت منظم می تواند بایت پوچ نیست. +برای الگوهای به جستجو برای بسترهای در یک رشته, بهتر است به استفاده از مانند و یا ‘position’ از اونجایی که خیلی سریعتر کار میکنن + +## ملتمتچانی (کومه علف خشک, \[الگو1 الگو2, …, patternنه\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} + +همان `match`, اما بازده 0 اگر هیچ یک از عبارات منظم همسان و 1 اگر هر یک از الگوهای مسابقات. این استفاده می کند [hyperscan](https://github.com/intel/hyperscan) کتابخونه. برای الگوهای به جستجو بسترهای در یک رشته, بهتر است به استفاده از `multiSearchAny` چون خیلی سریعتر کار میکنه + +!!! note "یادداشت" + طول هر یک از `haystack` رشته باید کمتر از 2 باشد32 بایت در غیر این صورت استثنا پرتاب می شود. این محدودیت صورت می گیرد به دلیل hyperscan API. + +## مقالههای جدید مرتبط با تحقیق این نویسنده1 الگو2, …, patternنه\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} + +همان `multiMatchAny`, اما بازگرداندن هر شاخص که منطبق بر انبار کاه. + +## اطلاعات دقیق1 الگو2, …, patternنه\]) {#multimatchallindiceshaystack-pattern1-pattern2-patternn} + +همان `multiMatchAny`, اما بازگرداندن مجموعه ای از تمام شاخص که مطابقت انبار کاه در هر سفارش. + +## چندبازیماتچانی (هیستک, فاصله, \[الگو1 الگو2, …, patternنه\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} + +همان `multiMatchAny`, اما بازده 1 اگر هر الگوی منطبق انبار کاه در یک ثابت [ویرایش فاصله](https://en.wikipedia.org/wiki/Edit_distance). این تابع نیز در حالت تجربی است و می تواند بسیار کند باشد. برای اطلاعات بیشتر نگاه کنید به [hyperscan مستندات](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching). + +## چند شکلی (هیستاک, فاصله, \[الگو1 الگو2, …, patternنه\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} + +همان `multiFuzzyMatchAny`, اما می گرداند هر شاخص که منطبق بر انبار کاه در فاصله ویرایش ثابت. + +## بازهای چندگانه (انبار کاه, فاصله, \[الگو1 الگو2, …, patternنه\]) {#multifuzzymatchallindiceshaystack-distance-pattern1-pattern2-patternn} + +همان `multiFuzzyMatchAny`, اما بازگرداندن مجموعه ای از تمام شاخص در هر منظور که مطابقت با انبار کاه در فاصله ویرایش ثابت. + +!!! note "یادداشت" + `multiFuzzyMatch*` توابع از عبارات منظم یونایتد-8 پشتیبانی نمی کنند و چنین عبارات به عنوان بایت به دلیل محدودیت هیپراکسان درمان می شوند. + +!!! note "یادداشت" + برای خاموش کردن تمام توابع است که با استفاده از بیش از حد اسکان, استفاده از تنظیمات `SET allow_hyperscan = 0;`. + +## عصاره (انبار کاه, الگو) {#extracthaystack-pattern} + +عصاره یک قطعه از یک رشته با استفاده از یک عبارت منظم. اگر ‘haystack’ با ‘pattern’ عبارت منظم, یک رشته خالی بازگشته است. اگر عبارت منظم حاوی وسترن نیست, طول می کشد قطعه که منطبق بر کل عبارت منظم. در غیر این صورت قطعه ای را می گیرد که با اولین زیر دست ساز مطابقت دارد. + +## خارج تماس بگیرید) {#extractallhaystack-pattern} + +عصاره تمام قطعات از یک رشته با استفاده از یک عبارت منظم. اگر ‘haystack’ با ‘pattern’ عبارت منظم, یک رشته خالی بازگشته است. بازگرداندن مجموعه ای از رشته متشکل از تمام مسابقات به عبارت منظم. به طور کلی, رفتار همان است که ‘extract’ تابع (در آن طول می کشد برای اولین بار subpattern یا کل بیان اگر وجود ندارد subpattern). + +## مانند (کومه علف خشک, الگو), کومه علف خشک مانند اپراتور الگوی {#function-like} + +بررسی اینکه یک رشته منطبق یک عبارت ساده به طور منظم. +عبارت منظم می تواند حاوی متسیمبلس باشد `%` و `_`. + +`%` نشان می دهد هر مقدار از هر بایت (از جمله صفر شخصیت). + +`_` نشان می دهد هر یک بایت. + +از بک اسلش استفاده کنید (`\`) برای فرار از متسیمبلس . توجه داشته باشید در فرار در شرح ‘match’ تابع. + +برای عبارات منظم مانند `%needle%`, کد مطلوب تر است و کار می کند به همان سرعتی که `position` تابع. +برای دیگر عبارات منظم, کد همان است که برای است ‘match’ تابع. + +## notLike(انبار کاه pattern), انبار کاه نیست مانند الگوی اپراتور {#function-notlike} + +همان چیزی که به عنوان ‘like’, اما منفی. + +## نمک زدایی (انبار کاه, سوزن) {#ngramdistancehaystack-needle} + +محاسبه فاصله 4 گرم بین `haystack` و `needle`: counts the symmetric difference between two multisets of 4-grams and normalizes it by the sum of their cardinalities. Returns float number from 0 to 1 – the closer to zero, the more strings are similar to each other. If the constant `needle` یا `haystack` بیش از 32 کیلوبایت است, می اندازد یک استثنا. اگر برخی از غیر ثابت `haystack` یا `needle` رشته ها بیش از 32 کیلوبایت, فاصله است که همیشه یکی. + +برای جستجوی غیر حساس به حالت یا / و در توابع استفاده از فرمت جی تی اف 8 `ngramDistanceCaseInsensitive, ngramDistanceUTF8, ngramDistanceCaseInsensitiveUTF8`. + +## نگراماسراچ (هیستک سوزن) {#ngramsearchhaystack-needle} + +مثل `ngramDistance` اما محاسبه تفاوت غیر متقارن بین `needle` و `haystack` – the number of n-grams from needle minus the common number of n-grams normalized by the number of `needle` مامان بزرگ نزدیک تر به یک, بیشتر احتمال دارد `needle` در `haystack`. می تواند برای جستجو رشته فازی مفید باشد. + +برای جستجوی غیر حساس به حالت یا / و در توابع استفاده از فرمت جی تی اف 8 `ngramSearchCaseInsensitive, ngramSearchUTF8, ngramSearchCaseInsensitiveUTF8`. + +!!! note "یادداشت" + For UTF-8 case we use 3-gram distance. All these are not perfectly fair n-gram distances. We use 2-byte hashes to hash n-grams and then calculate the (non-)symmetric difference between these hash tables – collisions may occur. With UTF-8 case-insensitive format we do not use fair `tolower` function – we zero the 5-th bit (starting from zero) of each codepoint byte and first bit of zeroth byte if bytes more than one – this works for Latin and mostly for all Cyrillic letters. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/fa/sql-reference/functions/type-conversion-functions.md b/docs/fa/sql-reference/functions/type-conversion-functions.md new file mode 100644 index 00000000000..353701818b8 --- /dev/null +++ b/docs/fa/sql-reference/functions/type-conversion-functions.md @@ -0,0 +1,534 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "\u062A\u0628\u062F\u06CC\u0644 \u0646\u0648\u0639" +--- + +# توابع تبدیل نوع {#type-conversion-functions} + +## مشکلات متداول تبدیل عددی {#numeric-conversion-issues} + +هنگامی که شما یک مقدار تبدیل از یک به نوع داده های دیگر, شما باید به یاد داشته باشید که در مورد مشترک, این یک عملیات نا امن است که می تواند به از دست دادن داده ها منجر شود. از دست دادن داده ها می تواند رخ دهد اگر شما سعی می کنید به جا ارزش از یک نوع داده بزرگتر به یک نوع داده کوچکتر, و یا اگر شما ارزش بین انواع داده های مختلف تبدیل. + +کلیک کرده است [همان رفتار به عنوان ج++ برنامه](https://en.cppreference.com/w/cpp/language/implicit_conversion). + +## toInt(8/16/32/64) {#toint8163264} + +تبدیل یک مقدار ورودی به [Int](../../sql-reference/data-types/int-uint.md) نوع داده. این خانواده تابع شامل: + +- `toInt8(expr)` — Results in the `Int8` نوع داده. +- `toInt16(expr)` — Results in the `Int16` نوع داده. +- `toInt32(expr)` — Results in the `Int32` نوع داده. +- `toInt64(expr)` — Results in the `Int64` نوع داده. + +**پارامترها** + +- `expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد یا یک رشته با نمایش اعشاری یک عدد. دودویی, مبنای هشت, و بازنمایی هگزادسیمال از اعداد پشتیبانی نمی شوند. صفر منجر محروم هستند. + +**مقدار بازگشتی** + +مقدار صحیح در `Int8`, `Int16`, `Int32` یا `Int64` نوع داده. + +توابع استفاده [گرد کردن به سمت صفر](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) یعنی عدد کسری از اعداد را کوتاه می کنند. + +رفتار توابع برای [هشدار داده می شود](../../sql-reference/data-types/float.md#data_type-float-nan-inf) استدلال تعریف نشده است. به یاد داشته باشید در مورد [مسایل همگرایی عددی](#numeric-conversion-issues), هنگام استفاده از توابع. + +**مثال** + +``` sql +SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) +``` + +``` text +┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ +│ -9223372036854775808 │ 32 │ 16 │ 8 │ +└──────────────────────┴─────────────┴───────────────┴─────────────┘ +``` + +## toInt(8/16/32/64)OrZero {#toint8163264orzero} + +این استدلال از نوع رشته طول می کشد و تلاش می کند تا به اعضای هیات تجزیه (8 \| 16 \| 32 \| 64). اگر شکست خورده, بازده 0. + +**مثال** + +``` sql +select toInt64OrZero('123123'), toInt8OrZero('123qwe123') +``` + +``` text +┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ +│ 123123 │ 0 │ +└─────────────────────────┴───────────────────────────┘ +``` + +## toInt(8/16/32/64)OrNull {#toint8163264ornull} + +این استدلال از نوع رشته طول می کشد و تلاش می کند تا به اعضای هیات تجزیه (8 \| 16 \| 32 \| 64). اگر شکست خورده, تهی گرداند. + +**مثال** + +``` sql +select toInt64OrNull('123123'), toInt8OrNull('123qwe123') +``` + +``` text +┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ +│ 123123 │ ᴺᵁᴸᴸ │ +└─────────────────────────┴───────────────────────────┘ +``` + +## toUInt(8/16/32/64) {#touint8163264} + +تبدیل یک مقدار ورودی به [اینترنت](../../sql-reference/data-types/int-uint.md) نوع داده. این خانواده تابع شامل: + +- `toUInt8(expr)` — Results in the `UInt8` نوع داده. +- `toUInt16(expr)` — Results in the `UInt16` نوع داده. +- `toUInt32(expr)` — Results in the `UInt32` نوع داده. +- `toUInt64(expr)` — Results in the `UInt64` نوع داده. + +**پارامترها** + +- `expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد یا یک رشته با نمایش اعشاری یک عدد. دودویی, مبنای هشت, و بازنمایی هگزادسیمال از اعداد پشتیبانی نمی شوند. صفر منجر محروم هستند. + +**مقدار بازگشتی** + +مقدار صحیح در `UInt8`, `UInt16`, `UInt32` یا `UInt64` نوع داده. + +توابع استفاده [گرد کردن به سمت صفر](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) یعنی عدد کسری از اعداد را کوتاه می کنند. + +رفتار توابع برای کشاورزی منفی و برای [هشدار داده می شود](../../sql-reference/data-types/float.md#data_type-float-nan-inf) استدلال تعریف نشده است. اگر شما یک رشته عبور با تعداد منفی, مثلا `'-32'`, خانه را افزایش می دهد یک استثنا. به یاد داشته باشید در مورد [مسایل همگرایی عددی](#numeric-conversion-issues), هنگام استفاده از توابع. + +**مثال** + +``` sql +SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) +``` + +``` text +┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ +│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ +└─────────────────────┴───────────────┴────────────────┴──────────────┘ +``` + +## toUInt(8/16/32/64)OrZero {#touint8163264orzero} + +## toUInt(8/16/32/64)OrNull {#touint8163264ornull} + +## توفلوات (32/64) {#tofloat3264} + +## toFloat(32/64)OrZero {#tofloat3264orzero} + +## toFloat(32/64)OrNull {#tofloat3264ornull} + +## toDate {#todate} + +## تودارزرو {#todateorzero} + +## طول عمر {#todateornull} + +## toDateTime {#todatetime} + +## به اندازه تو {#todatetimeorzero} + +## طول عمر ترنول {#todatetimeornull} + +## toDecimal(32/64/128) {#todecimal3264128} + +تبدیل `value` به [دهدهی](../../sql-reference/data-types/decimal.md) نوع داده با دقت `S`. این `value` می تواند یک عدد یا یک رشته. این `S` (مقیاس) پارامتر تعداد رقم اعشار را مشخص می کند. + +- `toDecimal32(value, S)` +- `toDecimal64(value, S)` +- `toDecimal128(value, S)` + +## toDecimal(32/64/128)OrNull {#todecimal3264128ornull} + +تبدیل یک رشته ورودی به یک [Nullable(اعشاری(P,S))](../../sql-reference/data-types/decimal.md) مقدار نوع داده. این خانواده از توابع عبارتند از: + +- `toDecimal32OrNull(expr, S)` — Results in `Nullable(Decimal32(S))` نوع داده. +- `toDecimal64OrNull(expr, S)` — Results in `Nullable(Decimal64(S))` نوع داده. +- `toDecimal128OrNull(expr, S)` — Results in `Nullable(Decimal128(S))` نوع داده. + +این توابع باید به جای استفاده `toDecimal*()` توابع, اگر شما ترجیح می دهید برای دریافت یک `NULL` ارزش به جای یک استثنا در صورت خطا تجزیه ارزش ورودی. + +**پارامترها** + +- `expr` — [عبارت](../syntax.md#syntax-expressions), بازگرداندن یک مقدار در [رشته](../../sql-reference/data-types/string.md) نوع داده. تاتر انتظار نمایندگی متنی از عدد اعشاری. به عنوان مثال, `'1.111'`. +- `S` — Scale, the number of decimal places in the resulting value. + +**مقدار بازگشتی** + +یک مقدار در `Nullable(Decimal(P,S))` نوع داده. مقدار شامل: + +- شماره با `S` اعشار, اگر تاتر تفسیر رشته ورودی به عنوان یک عدد. +- `NULL`, اگر تاتر می توانید رشته ورودی به عنوان یک عدد تفسیر نمی کند و یا اگر تعداد ورودی شامل بیش از `S` رقم اعشار. + +**مثالها** + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ +│ -1.11100 │ Nullable(Decimal(9, 5)) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ +│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toDecimal(32/64/128)OrZero {#todecimal3264128orzero} + +تبدیل یک مقدار ورودی به [دهدهی)](../../sql-reference/data-types/decimal.md) نوع داده. این خانواده از توابع عبارتند از: + +- `toDecimal32OrZero( expr, S)` — Results in `Decimal32(S)` نوع داده. +- `toDecimal64OrZero( expr, S)` — Results in `Decimal64(S)` نوع داده. +- `toDecimal128OrZero( expr, S)` — Results in `Decimal128(S)` نوع داده. + +این توابع باید به جای استفاده `toDecimal*()` توابع, اگر شما ترجیح می دهید برای دریافت یک `0` ارزش به جای یک استثنا در صورت خطا تجزیه ارزش ورودی. + +**پارامترها** + +- `expr` — [عبارت](../syntax.md#syntax-expressions), بازگرداندن یک مقدار در [رشته](../../sql-reference/data-types/string.md) نوع داده. تاتر انتظار نمایندگی متنی از عدد اعشاری. به عنوان مثال, `'1.111'`. +- `S` — Scale, the number of decimal places in the resulting value. + +**مقدار بازگشتی** + +یک مقدار در `Nullable(Decimal(P,S))` نوع داده. مقدار شامل: + +- شماره با `S` اعشار, اگر تاتر تفسیر رشته ورودی به عنوان یک عدد. +- 0 با `S` رقم اعشار, اگر تاتر می توانید رشته ورودی به عنوان یک عدد تفسیر نمی کند و یا اگر تعداد ورودی شامل بیش از `S` رقم اعشار. + +**مثال** + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ +│ -1.11100 │ Decimal(9, 5) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ +│ 0.00 │ Decimal(9, 2) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toString {#tostring} + +توابع برای تبدیل بین اعداد, رشته ها (اما رشته ثابت نیست), تاریخ, و تاریخ با زمان. +همه این توابع قبول یک استدلال. + +در هنگام تبدیل به و یا از یک رشته, ارزش فرمت شده و یا تجزیه با استفاده از قوانین مشابه برای فرمت جدولبندیشده (و تقریبا تمام فرمت های متنی دیگر). اگر رشته را نمی توان تجزیه, یک استثنا پرتاب می شود و درخواست لغو شده است. + +هنگام تبدیل تاریخ به اعداد و یا بالعکس, تاریخ مربوط به تعداد روز از ابتدای عصر یونیکس. +هنگام تبدیل تاریخ با بار به اعداد و یا بالعکس, تاریخ با زمان مربوط به تعداد ثانیه از ابتدای عصر یونیکس. + +تاریخ و تاریخ-با-فرمت زمان برای toDate/toDateTime توابع تعریف شده به شرح زیر است: + +``` text +YYYY-MM-DD +YYYY-MM-DD hh:mm:ss +``` + +به عنوان یک استثنا اگر تبدیل از UInt32, Int32, UInt64 یا Int64 عددی انواع, به, تاریخ, و اگر عدد بزرگتر یا مساوی به 65536 تعدادی را به عنوان تفسیر یک زمان یونیکس (و نه به عنوان تعداد روز) و گرد است به تاریخ. این اجازه می دهد تا پشتیبانی از وقوع مشترک نوشتن ‘toDate(unix\_timestamp)’ که در غیر این صورت یک خطا خواهد بود و نیاز به نوشتن بیشتر دست و پا گیر ‘toDate(toDateTime(unix\_timestamp))’. + +تبدیل بین تاریخ و تاریخ با زمان انجام شده است راه طبیعی: با اضافه کردن یک زمان خالی و یا حذف زمان. + +تبدیل بین انواع عددی با استفاده از قوانین مشابه به عنوان تکالیف بین انواع مختلف عددی در ج++. + +علاوه بر این, تابع حول از استدلال حسگر ناحیه رنگی می توانید یک استدلال رشته دوم حاوی نام منطقه زمانی را. مثال: `Asia/Yekaterinburg` در این مورد, زمان با توجه به منطقه زمانی مشخص فرمت. + +``` sql +SELECT + now() AS now_local, + toString(now(), 'Asia/Yekaterinburg') AS now_yekat +``` + +``` text +┌───────────now_local─┬─now_yekat───────────┐ +│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ +└─────────────────────┴─────────────────────┘ +``` + +همچنین `toUnixTimestamp` تابع. + +## وضعیت زیستشناختی رکورد) {#tofixedstrings-n} + +تبدیل یک استدلال نوع رشته به یک رشته (نفر) نوع (یک رشته با طول ثابت نفر). نفر باید ثابت باشد. +اگر رشته دارای بایت کمتر از نفر, این است که با بایت پوچ به سمت راست خالی. اگر رشته دارای بایت بیش از نفر, یک استثنا پرتاب می شود. + +## در حال بارگذاری) {#tostringcuttozeros} + +می پذیرد یک رشته یا رشته ثابت استدلال. بازگرداندن رشته با محتوای کوتاه در اولین صفر بایت پیدا شده است. + +مثال: + +``` sql +SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut +``` + +``` text +┌─s─────────────┬─s_cut─┐ +│ foo\0\0\0\0\0 │ foo │ +└───────────────┴───────┘ +``` + +``` sql +SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut +``` + +``` text +┌─s──────────┬─s_cut─┐ +│ foo\0bar\0 │ foo │ +└────────────┴───────┘ +``` + +## reinterpretAsUInt(8/16/32/64) {#reinterpretasuint8163264} + +## reinterpretAsInt(8/16/32/64) {#reinterpretasint8163264} + +## تفسیر مجدد (32/64) {#reinterpretasfloat3264} + +## بازخوانی مجدد {#reinterpretasdate} + +## حسگر ناحیه رنگی {#reinterpretasdatetime} + +این توابع یک رشته را قبول می کنند و بایت هایی را که در ابتدای رشته قرار می گیرند به عنوان یک عدد در دستور میزبان (اندی کوچک) تفسیر می کنند. اگر رشته به اندازه کافی بلند نیست, توابع کار به عنوان اگر رشته با تعداد لازم از بایت پوچ خالی. اگر رشته طولانی تر از مورد نیاز است, بایت اضافی نادیده گرفته می شوند. تاریخ به عنوان تعداد روز از ابتدای عصر یونیکس تفسیر و تاریخ با زمان به عنوان تعداد ثانیه از ابتدای عصر یونیکس تفسیر شده است. + +## رشته مجدد {#type_conversion_functions-reinterpretAsString} + +این تابع یک شماره یا تاریخ و یا تاریخ با زمان می پذیرد, و یک رشته حاوی بایت به نمایندگی از ارزش مربوطه را در سفارش میزبان را برمی گرداند (اندی کمی). بایت پوچ از پایان کاهش یافته است. مثلا, ارزش نوع اوینت32 255 یک رشته است که یک بایت طولانی است. + +## رشته مجدد {#reinterpretasfixedstring} + +این تابع یک شماره یا تاریخ و یا تاریخ با زمان می پذیرد, و یک رشته ثابت حاوی بایت به نمایندگی از ارزش مربوطه را در سفارش میزبان را برمی گرداند (اندی کمی). بایت پوچ از پایان کاهش یافته است. مثلا, ارزش نوع اوینت32 255 رشته ثابت است که یک بایت طولانی است. + +## بازیگران(x, T) {#type_conversion_function-cast} + +تبدیل ‘x’ به ‘t’ نوع داده. بازیگران نحو (ایکس به عنوان تی) نیز پشتیبانی می کند. + +مثال: + +``` sql +SELECT + '2016-06-15 23:00:00' AS timestamp, + CAST(timestamp AS DateTime) AS datetime, + CAST(timestamp AS Date) AS date, + CAST(timestamp, 'String') AS string, + CAST(timestamp, 'FixedString(22)') AS fixed_string +``` + +``` text +┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ +│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ +└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ +``` + +تبدیل به FixedString(N) تنها با این نسخهها کار برای استدلال از نوع String یا FixedString(N). + +تبدیل نوع به [Nullable](../../sql-reference/data-types/nullable.md) و پشت پشتیبانی می شود. مثال: + +``` sql +SELECT toTypeName(x) FROM t_null +``` + +``` text +┌─toTypeName(x)─┐ +│ Int8 │ +│ Int8 │ +└───────────────┘ +``` + +``` sql +SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null +``` + +``` text +┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ +│ Nullable(UInt16) │ +│ Nullable(UInt16) │ +└─────────────────────────────────────────┘ +``` + +## توینتال (سال / سه ماهه / ماه / هفته / روز / ساعت / دقیقه / ثانیه) {#function-tointerval} + +تبدیل یک استدلال نوع شماره به یک [فاصله](../../sql-reference/data-types/special-data-types/interval.md) نوع داده. + +**نحو** + +``` sql +toIntervalSecond(number) +toIntervalMinute(number) +toIntervalHour(number) +toIntervalDay(number) +toIntervalWeek(number) +toIntervalMonth(number) +toIntervalQuarter(number) +toIntervalYear(number) +``` + +**پارامترها** + +- `number` — Duration of interval. Positive integer number. + +**مقادیر بازگشتی** + +- مقدار در `Interval` نوع داده. + +**مثال** + +``` sql +WITH + toDate('2019-01-01') AS date, + INTERVAL 1 WEEK AS interval_week, + toIntervalWeek(1) AS interval_to_week +SELECT + date + interval_week, + date + interval_to_week +``` + +``` text +┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ +│ 2019-01-08 │ 2019-01-08 │ +└───────────────────────────┴──────────────────────────────┘ +``` + +## پردازش زمان {#parsedatetimebesteffort} + +تبدیل یک تاریخ و زمان در [رشته](../../sql-reference/data-types/string.md) نمایندگی به [DateTime](../../sql-reference/data-types/datetime.md#data_type-datetime) نوع داده. + +تابع تجزیه می کند [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [1123-5.2.14 تومان-822 تاریخ و زمان مشخصات](https://tools.ietf.org/html/rfc1123#page-55), را کلیک کنید و برخی از فرمت های تاریخ و زمان دیگر. + +**نحو** + +``` sql +parseDateTimeBestEffort(time_string [, time_zone]); +``` + +**پارامترها** + +- `time_string` — String containing a date and time to convert. [رشته](../../sql-reference/data-types/string.md). +- `time_zone` — Time zone. The function parses `time_string` با توجه به منطقه زمانی. [رشته](../../sql-reference/data-types/string.md). + +**فرمت های غیر استاندارد پشتیبانی شده** + +- یک رشته حاوی 9..10 رقمی [برچسب زمان یونیکس](https://en.wikipedia.org/wiki/Unix_time). +- یک رشته با یک تاریخ و یک مولفه زمان: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`, و غیره. +- یک رشته با یک تاریخ, اما هیچ مولفه زمان: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` و غیره +- یک رشته با یک روز و زمان: `DD`, `DD hh`, `DD hh:mm`. در این مورد `YYYY-MM` به عنوان جایگزین `2000-01`. +- یک رشته است که شامل تاریخ و زمان همراه با منطقه زمانی اطلاعات افست: `YYYY-MM-DD hh:mm:ss ±h:mm`, و غیره. به عنوان مثال, `2020-12-12 17:36:00 -5:00`. + +برای همه فرمت های با جدا تابع تجزیه نام ماه بیان شده توسط نام کامل خود و یا با سه حرف اول یک نام ماه. مثالها: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. + +**مقدار بازگشتی** + +- `time_string` تبدیل به `DateTime` نوع داده. + +**مثالها** + +پرسوجو: + +``` sql +SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') +AS parseDateTimeBestEffort; +``` + +نتیجه: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2020-12-12 12:12:57 │ +└─────────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') +AS parseDateTimeBestEffort +``` + +نتیجه: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-08-18 10:22:16 │ +└─────────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT parseDateTimeBestEffort('1284101485') +AS parseDateTimeBestEffort +``` + +نتیجه: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2015-07-07 12:04:41 │ +└─────────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') +AS parseDateTimeBestEffort +``` + +نتیجه: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-12-12 10:12:12 │ +└─────────────────────────┘ +``` + +پرسوجو: + +``` sql +SELECT parseDateTimeBestEffort('10 20:19') +``` + +نتیجه: + +``` text +┌─parseDateTimeBestEffort('10 20:19')─┐ +│ 2000-01-10 20:19:00 │ +└─────────────────────────────────────┘ +``` + +**همچنین نگاه کنید به** + +- \[ایزو 8601 اطلاعیه توسط @xkcd\] (https://xkcd.com/1179/) +- [RFC 1123](https://tools.ietf.org/html/rfc1123) +- [toDate](#todate) +- [toDateTime](#todatetime) + +## - ترجمه نشده - {#parsedatetimebesteffortornull} + +همان است که برای [پردازش زمان](#parsedatetimebesteffort) با این تفاوت که وقتی با فرمت تاریخ مواجه می شود که نمی تواند پردازش شود تهی می شود. + +## - ترجمه نشده - {#parsedatetimebesteffortorzero} + +همان است که برای [پردازش زمان](#parsedatetimebesteffort) با این تفاوت که تاریخ صفر یا زمان صفر را باز می گرداند زمانی که یک فرمت تاریخ مواجه است که نمی تواند پردازش شود. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/fa/sql-reference/functions/url-functions.md b/docs/fa/sql-reference/functions/url-functions.md new file mode 100644 index 00000000000..054caee4c4c --- /dev/null +++ b/docs/fa/sql-reference/functions/url-functions.md @@ -0,0 +1,210 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0646\u0634\u0627\u0646\u06CC\u0647\u0627\ + \u06CC \u0627\u06CC\u0646\u062A\u0631\u0646\u062A\u06CC" +--- + +# توابع برای کار با نشانیهای اینترنتی {#functions-for-working-with-urls} + +همه این توابع را دنبال کنید. حداکثر برای بهبود عملکرد ساده شده اند. + +## توابع استخراج بخشهایی از نشانی وب {#functions-that-extract-parts-of-a-url} + +اگر قسمت مربوطه در نشانی وب وجود نداشته باشد یک رشته خالی برگردانده میشود. + +### قرارداد {#protocol} + +پروتکل را از نشانی اینترنتی خارج میکند. + +Examples of typical returned values: http, https, ftp, mailto, tel, magnet… + +### دامنه {#domain} + +نام میزبان را از یک نشانی اینترنتی استخراج می کند. + +``` sql +domain(url) +``` + +**پارامترها** + +- `url` — URL. Type: [رشته](../../sql-reference/data-types/string.md). + +نشانی وب را می توان با یا بدون یک طرح مشخص شده است. مثالها: + +``` text +svn+ssh://some.svn-hosting.com:80/repo/trunk +some.svn-hosting.com:80/repo/trunk +https://yandex.com/time/ +``` + +برای این نمونه ها `domain` تابع نتایج زیر را برمی گرداند: + +``` text +some.svn-hosting.com +some.svn-hosting.com +yandex.com +``` + +**مقادیر بازگشتی** + +- نام میزبان. اگر کلیک هاوس می تواند رشته ورودی را به عنوان نشانی وب تجزیه کند. +- رشته خالی. اگر کلیکهاوس نمیتواند رشته ورودی را به عنوان نشانی وب تجزیه کند. + +نوع: `String`. + +**مثال** + +``` sql +SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') +``` + +``` text +┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ +│ some.svn-hosting.com │ +└────────────────────────────────────────────────────────┘ +``` + +### دامینویتهویتوو {#domainwithoutwww} + +بازگرداندن دامنه و حذف بیش از یک ‘www.’ اگه از اول شروع بشه + +### توپولدومین {#topleveldomain} + +دامنه سطح بالا را از یک نشانی اینترنتی استخراج می کند. + +``` sql +topLevelDomain(url) +``` + +**پارامترها** + +- `url` — URL. Type: [رشته](../../sql-reference/data-types/string.md). + +نشانی وب را می توان با یا بدون یک طرح مشخص شده است. مثالها: + +``` text +svn+ssh://some.svn-hosting.com:80/repo/trunk +some.svn-hosting.com:80/repo/trunk +https://yandex.com/time/ +``` + +**مقادیر بازگشتی** + +- نام دامنه. اگر کلیک هاوس می تواند رشته ورودی را به عنوان نشانی وب تجزیه کند. +- رشته خالی. اگر کلیکهاوس نمیتواند رشته ورودی را به عنوان نشانی وب تجزیه کند. + +نوع: `String`. + +**مثال** + +``` sql +SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') +``` + +``` text +┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ +│ com │ +└────────────────────────────────────────────────────────────────────┘ +``` + +### در حال بارگذاری {#firstsignificantsubdomain} + +بازگرداندن “first significant subdomain”. این یک مفهوم غیر استاندارد خاص به یاندکس است.متریکا اولین زیر دامنه قابل توجهی یک دامنه سطح دوم است ‘com’, ‘net’, ‘org’ یا ‘co’. در غیر این صورت, این یک دامنه سطح سوم است. به عنوان مثال, `firstSignificantSubdomain (‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’`. فهرست “insignificant” دامنه های سطح دوم و سایر اطلاعات پیاده سازی ممکن است در اینده تغییر کند. + +### در حال بارگذاری {#cuttofirstsignificantsubdomain} + +بازگرداندن بخشی از دامنه است که شامل زیر دامنه سطح بالا تا “first significant subdomain” (توضیح بالا را ببینید). + +به عنوان مثال, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. + +### مسیر {#path} + +مسیر را برمی گرداند. مثال: `/top/news.html` مسیر رشته پرس و جو را شامل نمی شود. + +### مسیر {#pathfull} + +همان بالا, اما از جمله رشته پرس و جو و قطعه. مثال:/بالا / اخبار.زنگامصفحه = 2 \# نظرات + +### رشته {#querystring} + +بازگرداندن رشته پرس و جو. مثال: صفحه=1&چاپی=213. پرس و جو رشته علامت سوال اولیه را شامل نمی شود, و همچنین \# و همه چیز بعد از \#. + +### قطعه {#fragment} + +بازگرداندن شناسه قطعه. قطعه می کند نماد هش اولیه را شامل نمی شود. + +### وضعیت زیستشناختی رکورد {#querystringandfragment} + +بازگرداندن رشته پرس و جو و شناسه قطعه. مثال: صفحه=1\#29390. + +### نام) {#extracturlparameterurl-name} + +بازگرداندن ارزش ‘name’ پارامتر در نشانی وب, در صورت وجود. در غیر این صورت, یک رشته خالی. اگر پارامترهای بسیاری با این نام وجود دارد, این اولین رخداد را برمی گرداند. این تابع با این فرض کار می کند که نام پارامتر در نشانی اینترنتی دقیقا به همان شیوه در استدلال گذشت کد گذاری شده است. + +### شمارش معکوس) {#extracturlparametersurl} + +مجموعه ای از نام=رشته ارزش مربوط به پارامترهای نشانی وب را برمی گرداند. ارزش ها به هیچ وجه رمزگشایی نمی. + +### extractURLParameterNames(URL) {#extracturlparameternamesurl} + +مجموعه ای از نام رشته های مربوط به نام پارامترهای نشانی وب را باز می گرداند. ارزش ها به هیچ وجه رمزگشایی نمی. + +### URLHierarchy(URL) {#urlhierarchyurl} + +را برمی گرداند مجموعه ای حاوی نشانی اینترنتی, کوتاه در پایان توسط علامت /,? در مسیر و پرس و جو-رشته. کاراکتر جداکننده متوالی به عنوان یکی شمارش می شود. برش در موقعیت بعد از تمام کاراکتر جدا متوالی ساخته شده است. + +### URLPathHierarchy(URL) {#urlpathhierarchyurl} + +همانطور که در بالا, اما بدون پروتکل و میزبان در نتیجه. / عنصر (ریشه) گنجانده نشده است. به عنوان مثال: تابع استفاده می شود برای پیاده سازی درخت گزارش نشانی اینترنتی در یاندکس. متریک. + +``` text +URLPathHierarchy('https://example.com/browse/CONV-6788') = +[ + '/browse/', + '/browse/CONV-6788' +] +``` + +### نما & نشانی وب) {#decodeurlcomponenturl} + +را برمی گرداند نشانی اینترنتی رمزگشایی. +مثال: + +``` sql +SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; +``` + +``` text +┌─DecodedURL─────────────────────────────┐ +│ http://127.0.0.1:8123/?query=SELECT 1; │ +└────────────────────────────────────────┘ +``` + +## توابع حذف بخشی از نشانی وب {#functions-that-remove-part-of-a-url} + +اگر نشانی وب هیچ چیز مشابه ندارد, نشانی اینترنتی بدون تغییر باقی می ماند. + +### بریدن {#cutwww} + +حذف بیش از یک ‘www.’ از ابتدای دامنه نشانی اینترنتی در صورت وجود. + +### & رشته {#cutquerystring} + +حذف رشته پرس و جو. علامت سوال نیز حذف شده است. + +### تقسیم {#cutfragment} + +حذف شناسه قطعه. علامت شماره نیز حذف شده است. + +### هشدار داده می شود {#cutquerystringandfragment} + +حذف رشته پرس و جو و شناسه قطعه. علامت سوال و علامت شماره نیز حذف شده است. + +### cutURLParameter(URL, نام) {#cuturlparameterurl-name} + +حذف ‘name’ پارامتر نشانی وب, در صورت وجود. این تابع با این فرض کار می کند که نام پارامتر در نشانی اینترنتی دقیقا به همان شیوه در استدلال گذشت کد گذاری شده است. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/fa/sql-reference/functions/uuid-functions.md b/docs/fa/sql-reference/functions/uuid-functions.md new file mode 100644 index 00000000000..50f4d5e20f0 --- /dev/null +++ b/docs/fa/sql-reference/functions/uuid-functions.md @@ -0,0 +1,122 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 53 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u06CC\u0648\u06CC\u062F" +--- + +# توابع برای کار با یوید {#functions-for-working-with-uuid} + +توابع برای کار با شناسه به شرح زیر است. + +## جنراتیدو4 {#uuid-function-generate} + +تولید [UUID](../../sql-reference/data-types/uuid.md) از [نسخه 4](https://tools.ietf.org/html/rfc4122#section-4.4). + +``` sql +generateUUIDv4() +``` + +**مقدار بازگشتی** + +مقدار نوع شناسه. + +**مثال طریقه استفاده** + +این مثال نشان می دهد ایجاد یک جدول با ستون نوع شناسه و قرار دادن یک مقدار به جدول. + +``` sql +CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog + +INSERT INTO t_uuid SELECT generateUUIDv4() + +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┐ +│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ +└──────────────────────────────────────┘ +``` + +## شناسه بسته:) {#touuid-x} + +تبدیل مقدار نوع رشته به نوع شناسه. + +``` sql +toUUID(String) +``` + +**مقدار بازگشتی** + +مقدار نوع شناسه. + +**مثال طریقه استفاده** + +``` sql +SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid +``` + +``` text +┌─────────────────────────────────uuid─┐ +│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ +└──────────────────────────────────────┘ +``` + +## وضعیت زیستشناختی رکورد {#uuidstringtonum} + +می پذیرد یک رشته حاوی 36 کاراکتر در قالب `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` و به عنوان مجموعه ای از بایت ها در یک [رشته ثابت (16)](../../sql-reference/data-types/fixedstring.md). + +``` sql +UUIDStringToNum(String) +``` + +**مقدار بازگشتی** + +رشته ثابت (16) + +**نمونه های استفاده** + +``` sql +SELECT + '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, + UUIDStringToNum(uuid) AS bytes +``` + +``` text +┌─uuid─────────────────────────────────┬─bytes────────────┐ +│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ +└──────────────────────────────────────┴──────────────────┘ +``` + +## هشدار داده می شود {#uuidnumtostring} + +می پذیرد [رشته ثابت (16)](../../sql-reference/data-types/fixedstring.md) ارزش, و یک رشته حاوی گرداند 36 شخصیت در قالب متن. + +``` sql +UUIDNumToString(FixedString(16)) +``` + +**مقدار بازگشتی** + +رشته. + +**مثال طریقه استفاده** + +``` sql +SELECT + 'a/<@];!~p{jTj={)' AS bytes, + UUIDNumToString(toFixedString(bytes, 16)) AS uuid +``` + +``` text +┌─bytes────────────┬─uuid─────────────────────────────────┐ +│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ +└──────────────────┴──────────────────────────────────────┘ +``` + +## همچنین نگاه کنید به {#see-also} + +- [دیکتاتوری](ext-dict-functions.md#ext_dict_functions-other) + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/fa/sql-reference/functions/ym-dict-functions.md b/docs/fa/sql-reference/functions/ym-dict-functions.md new file mode 100644 index 00000000000..9e08ee16516 --- /dev/null +++ b/docs/fa/sql-reference/functions/ym-dict-functions.md @@ -0,0 +1,157 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u06CC\u0627\u0646\u062F\u06A9\u0633.\u0648\ + \u0627\u0698\u0647\u0646\u0627\u0645\u0647\u0647\u0627 \u0645\u062A\u0631\u06CC\u06A9\ + \u0627" +--- + +# توابع برای کار با یاندکس.واژهنامهها متریکا {#functions-for-working-with-yandex-metrica-dictionaries} + +به منظور توابع زیر به کار پیکربندی سرور باید مشخص مسیر و نشانی برای گرفتن تمام یاندکس.واژهنامهها متریکا. لغت نامه ها در اولین تماس از هر یک از این توابع لود می شود. اگر لیست مرجع نمی تواند لود شود, یک استثنا پرتاب می شود. + +برای اطلاعات در مورد ایجاد لیست مرجع, بخش را ببینید “Dictionaries”. + +## موقعیت جغرافیایی چندگانه {#multiple-geobases} + +ClickHouse پشتیبانی از کار با چند جایگزین geobases (منطقه ای سلسله مراتب) به طور همزمان به منظور حمایت از دیدگاه های مختلف که در آن کشورهای خاص مناطق متعلق به. + +این ‘clickhouse-server’ پیکربندی فایل را با سلسله مراتب منطقه ای مشخص می کند::`/opt/geo/regions_hierarchy.txt` + +علاوه بر این فایل, همچنین برای فایل های جستجو در این نزدیکی هست که نماد \_ و هر پسوند اضافه به نام (قبل از پسوند فایل). +مثلا, همچنین فایل را پیدا خواهد کرد `/opt/geo/regions_hierarchy_ua.txt`, اگر در حال حاضر. + +`ua` کلید فرهنگ لغت نامیده می شود. برای یک فرهنگ لغت بدون پسوند, کلید یک رشته خالی است. + +تمام واژهنامهها دوباره لود شده در زمان اجرا (یک بار در هر تعداد معینی از ثانیه, همانطور که در دستور داخلی تعریف شده \_فرهنگ\_ پارامتر پیکربندی, و یا یک بار در ساعت به طور پیش فرض). با این حال, لیست لغت نامه های موجود تعریف شده است یک بار, زمانی که سرور شروع می شود. + +All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. +مثال: + +``` sql +regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt +regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt +regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt +``` + +### regionToCity(id\[, geobase\]) {#regiontocityid-geobase} + +Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. + +### regionToArea(id\[, geobase\]) {#regiontoareaid-geobase} + +تبدیل یک منطقه به یک منطقه (نوع 5 در پایگاه داده). در هر راه دیگر, این تابع همان است که ‘regionToCity’. + +``` sql +SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + +``` text +┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ +│ │ +│ Moscow and Moscow region │ +│ St. Petersburg and Leningrad region │ +│ Belgorod region │ +│ Ivanovsk region │ +│ Kaluga region │ +│ Kostroma region │ +│ Kursk region │ +│ Lipetsk region │ +│ Orlov region │ +│ Ryazan region │ +│ Smolensk region │ +│ Tambov region │ +│ Tver region │ +│ Tula region │ +└──────────────────────────────────────────────────────┘ +``` + +### regionToDistrict(id\[, geobase\]) {#regiontodistrictid-geobase} + +تبدیل یک منطقه به یک منطقه فدرال (نوع 4 در پایگاه داده). در هر راه دیگر, این تابع همان است که ‘regionToCity’. + +``` sql +SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + +``` text +┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ +│ │ +│ Central federal district │ +│ Northwest federal district │ +│ South federal district │ +│ North Caucases federal district │ +│ Privolga federal district │ +│ Ural federal district │ +│ Siberian federal district │ +│ Far East federal district │ +│ Scotland │ +│ Faroe Islands │ +│ Flemish region │ +│ Brussels capital region │ +│ Wallonia │ +│ Federation of Bosnia and Herzegovina │ +└──────────────────────────────────────────────────────────┘ +``` + +### regionToCountry(id\[, geobase\]) {#regiontocountryid-geobase} + +تبدیل یک منطقه به یک کشور. در هر راه دیگر, این تابع همان است که ‘regionToCity’. +مثال: `regionToCountry(toUInt32(213)) = 225` تبدیل مسکو (213) به روسیه (225). + +### regionToContinent(id\[, geobase\]) {#regiontocontinentid-geobase} + +تبدیل یک منطقه به یک قاره. در هر راه دیگر, این تابع همان است که ‘regionToCity’. +مثال: `regionToContinent(toUInt32(213)) = 10001` تبدیل مسکو (213) به اوراسیا (10001). + +### نقلقولهای جدید از این نویسنده) {#regiontotopcontinent-regiontotopcontinent} + +بالاترین قاره را در سلسله مراتب منطقه پیدا می کند. + +**نحو** + +``` sql +regionToTopContinent(id[, geobase]); +``` + +**پارامترها** + +- `id` — Region ID from the Yandex geobase. [UInt32](../../sql-reference/data-types/int-uint.md). +- `geobase` — Dictionary key. See [موقعیت جغرافیایی چندگانه](#multiple-geobases). [رشته](../../sql-reference/data-types/string.md). اختیاری. + +**مقدار بازگشتی** + +- شناسه قاره سطح بالا (دومی زمانی که شما صعود سلسله مراتب مناطق). +- 0, اگر هیچ کدام وجود دارد. + +نوع: `UInt32`. + +### regionToPopulation(id\[, geobase\]) {#regiontopopulationid-geobase} + +می شود جمعیت برای یک منطقه. +جمعیت را می توان در فایل های با پایگاه داده ثبت شده است. بخش را ببینید “External dictionaries”. +اگر جمعیت برای منطقه ثبت نشده, باز می گردد 0. +در یاندکس پایگاه جغرافیایی, جمعیت ممکن است برای مناطق کودک ثبت, اما نه برای مناطق پدر و مادر. + +### regionIn(lhs, rhs\[, geobase\]) {#regioninlhs-rhs-geobase} + +بررسی اینکه یک ‘lhs’ منطقه متعلق به ‘rhs’ منطقه. بازگرداندن یک عدد 18 برابر 1 اگر متعلق, یا 0 اگر تعلق ندارد. +The relationship is reflexive – any region also belongs to itself. + +### regionHierarchy(id\[, geobase\]) {#regionhierarchyid-geobase} + +Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. +مثال: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. + +### شناسه بسته:\]) {#regiontonameid-lang} + +Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn't exist, an empty string is returned. + +`ua` و `uk` هر دو به معنای اوکراین. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/fa/sql-reference/index.md b/docs/fa/sql-reference/index.md new file mode 100644 index 00000000000..99095c9e47b --- /dev/null +++ b/docs/fa/sql-reference/index.md @@ -0,0 +1,20 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0645\u0631\u062C\u0639 \u0645\u0631\u0628\u0639" +toc_hidden: true +toc_priority: 28 +toc_title: "\u0645\u062E\u0641\u06CC" +--- + +# مرجع مربع {#sql-reference} + +تاتر از انواع زیر نمایش داده شد: + +- [SELECT](statements/select/index.md) +- [INSERT INTO](statements/insert-into.md) +- [CREATE](statements/create.md) +- [ALTER](statements/alter.md#query_language_queries_alter) +- [انواع دیگر نمایش داده شد](statements/misc.md) + +[مقاله اصلی](https://clickhouse.tech/docs/en/sql-reference/) diff --git a/docs/fa/sql-reference/operators/in.md b/docs/fa/sql-reference/operators/in.md new file mode 100644 index 00000000000..779d92e0174 --- /dev/null +++ b/docs/fa/sql-reference/operators/in.md @@ -0,0 +1,204 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +### در اپراتورها {#select-in-operators} + +این `IN`, `NOT IN`, `GLOBAL IN` و `GLOBAL NOT IN` اپراتورها به طور جداگانه تحت پوشش, از قابلیت های خود را کاملا غنی است. + +سمت چپ اپراتور یا یک ستون یا یک تاپل است. + +مثالها: + +``` sql +SELECT UserID IN (123, 456) FROM ... +SELECT (CounterID, UserID) IN ((34, 123), (101500, 456)) FROM ... +``` + +اگر سمت چپ یک ستون است که در شاخص است, و در سمت راست مجموعه ای از ثابت است, سیستم با استفاده از شاخص برای پردازش پرس و جو. + +Don't list too many values explicitly (i.e. millions). If a data set is large, put it in a temporary table (for example, see the section “External data for query processing”), سپس با استفاده از یک خرده فروشی. + +سمت راست اپراتور می تواند مجموعه ای از عبارات ثابت, مجموعه ای از تاپل با عبارات ثابت (نشان داده شده در نمونه های بالا), و یا به نام یک جدول پایگاه داده و یا زیرخاکی در داخل پرانتز را انتخاب کنید. + +اگر سمت راست اپراتور نام یک جدول است (مثلا, `UserID IN users`), این معادل به خرده فروشی است `UserID IN (SELECT * FROM users)`. با استفاده از این هنگام کار با داده های خارجی است که همراه با پرس و جو ارسال می شود. مثلا, پرس و جو را می توان همراه با مجموعه ای از شناسه کاربر لود شده به ارسال ‘users’ جدول موقت, که باید فیلتر شود. + +اگر در سمت راست اپراتور یک نام جدول است که موتور مجموعه ای است (مجموعه داده های تهیه شده است که همیشه در رم), مجموعه داده خواهد شد بیش از دوباره برای هر پرس و جو ایجاد نمی. + +زیرخاکری ممکن است بیش از یک ستون برای فیلتر کردن تاپل را مشخص کنید. +مثال: + +``` sql +SELECT (CounterID, UserID) IN (SELECT CounterID, UserID FROM ...) FROM ... +``` + +ستون به سمت چپ و راست اپراتور در باید همان نوع. + +اپراتور در و زیرخاکی ممکن است در هر بخشی از پرس و جو رخ می دهد, از جمله در توابع کل و توابع لامبدا. +مثال: + +``` sql +SELECT + EventDate, + avg(UserID IN + ( + SELECT UserID + FROM test.hits + WHERE EventDate = toDate('2014-03-17') + )) AS ratio +FROM test.hits +GROUP BY EventDate +ORDER BY EventDate ASC +``` + +``` text +┌──EventDate─┬────ratio─┐ +│ 2014-03-17 │ 1 │ +│ 2014-03-18 │ 0.807696 │ +│ 2014-03-19 │ 0.755406 │ +│ 2014-03-20 │ 0.723218 │ +│ 2014-03-21 │ 0.697021 │ +│ 2014-03-22 │ 0.647851 │ +│ 2014-03-23 │ 0.648416 │ +└────────────┴──────────┘ +``` + +برای هر روز پس از مارس 17, تعداد درصد تعداد بازدید از صفحات ساخته شده توسط کاربران که سایت در مارس 17 بازدید. +یک خرده فروشی در بند در همیشه اجرا فقط یک بار بر روی یک سرور. هیچ زیرمجموعه وابسته وجود دارد. + +## پردازش پوچ {#null-processing-1} + +در طول پردازش درخواست, در اپراتور فرض می شود که در نتیجه یک عملیات با [NULL](../syntax.md#null-literal) همیشه برابر است با `0`, صرف نظر از اینکه `NULL` است در سمت راست یا چپ اپراتور. `NULL` ارزش ها در هر مجموعه داده شامل نمی شود, به یکدیگر مربوط نیست و نمی توان در مقایسه. + +در اینجا یک مثال با است `t_null` جدول: + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +در حال اجرا پرس و جو `SELECT x FROM t_null WHERE y IN (NULL,3)` به شما نتیجه زیر را می دهد: + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +شما می توانید ببینید که ردیف که `y = NULL` از نتایج پرس و جو پرتاب می شود. دلیل این است که تاتر نمی توانید تصمیم بگیرید که چه `NULL` در `(NULL,3)` تنظیم, بازگشت `0` به عنوان نتیجه عملیات و `SELECT` این سطر را از خروجی نهایی حذف می کند. + +``` sql +SELECT y IN (NULL, 3) +FROM t_null +``` + +``` text +┌─in(y, tuple(NULL, 3))─┐ +│ 0 │ +│ 1 │ +└───────────────────────┘ +``` + +## توزیع Subqueries {#select-distributed-subqueries} + +دو گزینه برای در بازدید کنندگان با کارخانه های فرعی وجود دارد (شبیه به می پیوندد): طبیعی `IN` / `JOIN` و `GLOBAL IN` / `GLOBAL JOIN`. در نحوه اجرا برای پردازش پرس و جو توزیع شده متفاوت است. + +!!! attention "توجه" + به یاد داشته باشید که الگوریتم های زیر توضیح داده شده ممکن است متفاوت بسته به کار [تنظیمات](../../operations/settings/settings.md) `distributed_product_mode` تنظیمات. + +هنگام استفاده از به طور منظم در, پرس و جو به سرور از راه دور ارسال, و هر یک از اجرا می شود کارخانه های فرعی در `IN` یا `JOIN` بند بند. + +هنگام استفاده از `GLOBAL IN` / `GLOBAL JOINs`, اول همه زیرمجموعه ها برای اجرا `GLOBAL IN` / `GLOBAL JOINs` و نتایج در جداول موقت جمع می شوند. سپس جداول موقت به هر سرور از راه دور ارسال, جایی که نمایش داده شد با استفاده از این داده های موقت اجرا. + +برای پرس و جو غیر توزیع, استفاده از به طور منظم `IN` / `JOIN`. + +مراقب باشید در هنگام استفاده از کارخانه های فرعی در `IN` / `JOIN` بند برای پردازش پرس و جو توزیع. + +بیایید نگاهی به برخی از نمونه. فرض کنید که هر سرور در خوشه طبیعی است **\_تمل**. هر سرور همچنین دارای یک **توزیع \_تماس** جدول با **توزیع شده** نوع, که به نظر می رسد در تمام سرور در خوشه. + +برای پرس و جو به **توزیع \_تماس** پرس و جو به تمام سرورهای راه دور ارسال می شود و با استفاده از **\_تمل**. + +برای مثال پرس و جو + +``` sql +SELECT uniq(UserID) FROM distributed_table +``` + +به تمام سرورهای راه دور ارسال می شود + +``` sql +SELECT uniq(UserID) FROM local_table +``` + +و به صورت موازی اجرا می شود تا زمانی که به مرحله ای برسد که نتایج متوسط می تواند ترکیب شود. سپس نتایج میانی به سرور درخواست کننده بازگردانده می شود و با هم ادغام می شوند و نتیجه نهایی به مشتری ارسال می شود. + +حالا اجازه دهید به بررسی یک پرس و جو با در: + +``` sql +SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) +``` + +- محاسبه تقاطع مخاطبان از دو سایت. + +این پرس و جو خواهد شد به تمام سرور از راه دور به عنوان ارسال می شود + +``` sql +SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) +``` + +به عبارت دیگر, داده های تعیین شده در بند در خواهد شد بر روی هر سرور به طور مستقل جمع, تنها در سراسر داده است که به صورت محلی بر روی هر یک از سرور های ذخیره شده. + +این به درستی و بهینه کار خواهد کرد اگر شما برای این مورد تهیه و داده ها در سراسر سرورهای خوشه گسترش یافته اند به طوری که داده ها را برای یک شناسه تنها ساکن به طور کامل بر روی یک سرور واحد. در این مورد, تمام اطلاعات لازم در دسترس خواهد بود به صورت محلی بر روی هر سرور. در غیر این صورت نتیجه نادرست خواهد بود. ما به این تنوع از پرس و جو به عنوان مراجعه کنید “local IN”. + +برای اصلاح چگونه پرس و جو کار می کند زمانی که داده ها به طور تصادفی در سراسر سرور خوشه گسترش, شما می توانید مشخص **توزیع \_تماس** در داخل یک خرده فروشی. پرس و جو شبیه به این خواهد بود: + +``` sql +SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) +``` + +این پرس و جو خواهد شد به تمام سرور از راه دور به عنوان ارسال می شود + +``` sql +SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) +``` + +خرده فروشی شروع خواهد شد در حال اجرا بر روی هر سرور از راه دور. پس از زیرخاکری با استفاده از یک جدول توزیع, خرده فروشی است که در هر سرور از راه دور خواهد شد به هر سرور از راه دور به عنوان خشمگین + +``` sql +SELECT UserID FROM local_table WHERE CounterID = 34 +``` + +مثلا, اگر شما یک خوشه از 100 سرور, اجرای کل پرس و جو نیاز 10,000 درخواست ابتدایی, که به طور کلی در نظر گرفته غیر قابل قبول. + +در چنین مواردی, شما همیشه باید جهانی به جای در استفاده از. بیایید نگاه کنیم که چگونه برای پرس و جو کار می کند + +``` sql +SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID GLOBAL IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) +``` + +سرور درخواست کننده خرده فروشی را اجرا خواهد کرد + +``` sql +SELECT UserID FROM distributed_table WHERE CounterID = 34 +``` + +و در نتیجه خواهد شد در یک جدول موقت در رم قرار داده است. سپس درخواست خواهد شد به هر سرور از راه دور به عنوان ارسال + +``` sql +SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID GLOBAL IN _data1 +``` + +و جدول موقت `_data1` خواهد شد به هر سرور از راه دور با پرس و جو ارسال (نام جدول موقت پیاده سازی تعریف شده است). + +این مطلوب تر از استفاده از نرمال در است. با این حال, نگه داشتن نکات زیر را در ذهن: + +1. هنگام ایجاد یک جدول موقت داده های منحصر به فرد ساخته شده است. برای کاهش حجم داده های منتقل شده بر روی شبکه مشخص متمایز در زیرخاکری. (شما لازم نیست برای انجام این کار برای عادی در.) +2. جدول موقت خواهد شد به تمام سرور از راه دور ارسال. انتقال برای توپولوژی شبکه به حساب نمی. مثلا, اگر 10 سرور از راه دور در یک مرکز داده است که در رابطه با سرور درخواست بسیار از راه دور اقامت, داده ها ارسال خواهد شد 10 بار بیش از کانال به مرکز داده از راه دور. سعی کنید برای جلوگیری از مجموعه داده های بزرگ در هنگام استفاده از جهانی در. +3. هنگام انتقال داده ها به سرور از راه دور, محدودیت در پهنای باند شبکه قابل تنظیم نیست. شما ممکن است شبکه بیش از حد. +4. سعی کنید برای توزیع داده ها در سراسر سرور به طوری که شما لازم نیست که به استفاده از جهانی را به صورت منظم. +5. اگر شما نیاز به استفاده از جهانی در اغلب, برنامه ریزی محل خوشه خانه کلیک به طوری که یک گروه واحد از کپی ساکن در بیش از یک مرکز داده با یک شبکه سریع بین, به طوری که یک پرس و جو را می توان به طور کامل در یک مرکز داده واحد پردازش. + +همچنین حس می کند برای مشخص کردن یک جدول محلی در `GLOBAL IN` بند, در صورتی که این جدول محلی تنها بر روی سرور درخواست در دسترس است و شما می خواهید به استفاده از داده ها را از روی سرور از راه دور. diff --git a/docs/fa/sql-reference/operators/index.md b/docs/fa/sql-reference/operators/index.md new file mode 100644 index 00000000000..1d9d890c2be --- /dev/null +++ b/docs/fa/sql-reference/operators/index.md @@ -0,0 +1,277 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u0627\u067E\u0631\u0627\u062A\u0648\u0631\u0647\u0627" +--- + +# اپراتورها {#operators} + +ClickHouse تبدیل اپراتورها به توابع مربوط به خود را در پرس و جو و تجزیه مرحله با توجه به اولویت اولویت و associativity. + +## اپراتورهای دسترسی {#access-operators} + +`a[N]` – Access to an element of an array. The `arrayElement(a, N)` تابع. + +`a.N` – Access to a tuple element. The `tupleElement(a, N)` تابع. + +## اپراتور نفی عددی {#numeric-negation-operator} + +`-a` – The `negate (a)` تابع. + +## اپراتورهای ضرب و تقسیم {#multiplication-and-division-operators} + +`a * b` – The `multiply (a, b)` تابع. + +`a / b` – The `divide(a, b)` تابع. + +`a % b` – The `modulo(a, b)` تابع. + +## اپراتورهای جمع و تفریق {#addition-and-subtraction-operators} + +`a + b` – The `plus(a, b)` تابع. + +`a - b` – The `minus(a, b)` تابع. + +## مقایسه اپراتورها {#comparison-operators} + +`a = b` – The `equals(a, b)` تابع. + +`a == b` – The `equals(a, b)` تابع. + +`a != b` – The `notEquals(a, b)` تابع. + +`a <> b` – The `notEquals(a, b)` تابع. + +`a <= b` – The `lessOrEquals(a, b)` تابع. + +`a >= b` – The `greaterOrEquals(a, b)` تابع. + +`a < b` – The `less(a, b)` تابع. + +`a > b` – The `greater(a, b)` تابع. + +`a LIKE s` – The `like(a, b)` تابع. + +`a NOT LIKE s` – The `notLike(a, b)` تابع. + +`a BETWEEN b AND c` – The same as `a >= b AND a <= c`. + +`a NOT BETWEEN b AND c` – The same as `a < b OR a > c`. + +## اپراتورها برای کار با مجموعه داده ها {#operators-for-working-with-data-sets} + +*ببینید [در اپراتورها](in.md).* + +`a IN ...` – The `in(a, b)` تابع. + +`a NOT IN ...` – The `notIn(a, b)` تابع. + +`a GLOBAL IN ...` – The `globalIn(a, b)` تابع. + +`a GLOBAL NOT IN ...` – The `globalNotIn(a, b)` تابع. + +## اپراتورها برای کار با تاریخ و زمان {#operators-datetime} + +### EXTRACT {#operator-extract} + +``` sql +EXTRACT(part FROM date); +``` + +استخراج قطعات از یک تاریخ معین. مثلا, شما می توانید یک ماه از یک تاریخ معین بازیابی, یا یک ثانیه از یک زمان. + +این `part` پارامتر مشخص می کند که بخشی از تاریخ برای بازیابی. مقادیر زیر در دسترس هستند: + +- `DAY` — The day of the month. Possible values: 1–31. +- `MONTH` — The number of a month. Possible values: 1–12. +- `YEAR` — The year. +- `SECOND` — The second. Possible values: 0–59. +- `MINUTE` — The minute. Possible values: 0–59. +- `HOUR` — The hour. Possible values: 0–23. + +این `part` پارامتر غیر حساس به حروف است. + +این `date` پارامتر تاریخ یا زمان پردازش را مشخص می کند. هر دو [تاریخ](../../sql-reference/data-types/date.md) یا [DateTime](../../sql-reference/data-types/datetime.md) نوع پشتیبانی می شود. + +مثالها: + +``` sql +SELECT EXTRACT(DAY FROM toDate('2017-06-15')); +SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); +SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); +``` + +در مثال زیر ما یک جدول ایجاد می کنیم و با ارزش وارد می کنیم `DateTime` نوع. + +``` sql +CREATE TABLE test.Orders +( + OrderId UInt64, + OrderName String, + OrderDate DateTime +) +ENGINE = Log; +``` + +``` sql +INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); +``` + +``` sql +SELECT + toYear(OrderDate) AS OrderYear, + toMonth(OrderDate) AS OrderMonth, + toDayOfMonth(OrderDate) AS OrderDay, + toHour(OrderDate) AS OrderHour, + toMinute(OrderDate) AS OrderMinute, + toSecond(OrderDate) AS OrderSecond +FROM test.Orders; +``` + +``` text +┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ +│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ +└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ +``` + +شما می توانید نمونه های بیشتری را در [تستها](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). + +### INTERVAL {#operator-interval} + +ایجاد یک [فاصله](../../sql-reference/data-types/special-data-types/interval.md)- ارزش نوع است که باید در عملیات ریاضی با استفاده [تاریخ](../../sql-reference/data-types/date.md) و [DateTime](../../sql-reference/data-types/datetime.md)- ارزش نوع . + +انواع فواصل: +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +!!! warning "اخطار" + فواصل با انواع مختلف نمی تواند ترکیب شود. شما می توانید عبارات مانند استفاده کنید `INTERVAL 4 DAY 1 HOUR`. مشخص فواصل در واحد است که کوچکتر یا برابر با کوچکترین واحد فاصله, مثلا, `INTERVAL 25 HOUR`. شما می توانید عملیات متوالی مانند مثال زیر استفاده کنید. + +مثال: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +**همچنین نگاه کنید به** + +- [فاصله](../../sql-reference/data-types/special-data-types/interval.md) نوع داده +- [توینتروال](../../sql-reference/functions/type-conversion-functions.md#function-tointerval) توابع تبدیل نوع + +## اپراتور نفی منطقی {#logical-negation-operator} + +`NOT a` – The `not(a)` تابع. + +## منطقی و اپراتور {#logical-and-operator} + +`a AND b` – The`and(a, b)` تابع. + +## منطقی یا اپراتور {#logical-or-operator} + +`a OR b` – The `or(a, b)` تابع. + +## اپراتور شرطی {#conditional-operator} + +`a ? b : c` – The `if(a, b, c)` تابع. + +یادداشت: + +اپراتور مشروط محاسبه ارزش ب و ج, سپس چک چه شرایط ملاقات کرده است, و سپس مقدار مربوطه را برمی گرداند. اگر `b` یا `C` یک [ارریجین()](../../sql-reference/functions/array-join.md#functions_arrayjoin) تابع, هر ردیف خواهد شد بدون در نظر گرفتن تکرار “a” شرط. + +## عبارت شرطی {#operator_case} + +``` sql +CASE [x] + WHEN a THEN b + [WHEN ... THEN ...] + [ELSE c] +END +``` + +اگر `x` مشخص شده است, سپس `transform(x, [a, ...], [b, ...], c)` function is used. Otherwise – `multiIf(a, b, ..., c)`. + +اگر وجود ندارد `ELSE c` بند در بیان, مقدار پیش فرض است `NULL`. + +این `transform` تابع با کار نمی کند `NULL`. + +## اپراتور الحاق {#concatenation-operator} + +`s1 || s2` – The `concat(s1, s2) function.` + +## لامبدا اپراتور ایجاد {#lambda-creation-operator} + +`x -> expr` – The `lambda(x, expr) function.` + +اپراتورهای زیر اولویت ندارند زیرا براکت هستند: + +## اپراتور ایجاد مجموعه {#array-creation-operator} + +`[x1, ...]` – The `array(x1, ...) function.` + +## اپراتور ایجاد تاپل {#tuple-creation-operator} + +`(x1, x2, ...)` – The `tuple(x2, x2, ...) function.` + +## Associativity {#associativity} + +همه اپراتورهای دودویی انجمن را ترک کرده اند. به عنوان مثال, `1 + 2 + 3` تبدیل به `plus(plus(1, 2), 3)`. +گاهی اوقات این راه شما انتظار می رود کار نمی کند. به عنوان مثال, `SELECT 4 > 2 > 3` در نتیجه 0. + +برای بهره وری `and` و `or` توابع قبول هر تعداد از استدلال. زنجیره های مربوطه از `AND` و `OR` اپراتورها به یک تماس از این توابع تبدیل شده است. + +## در حال بررسی برای `NULL` {#checking-for-null} + +تاتر از `IS NULL` و `IS NOT NULL` اپراتورها. + +### IS NULL {#operator-is-null} + +- برای [Nullable](../../sql-reference/data-types/nullable.md) مقادیر نوع `IS NULL` بازگشت اپراتور: + - `1` اگر مقدار باشد `NULL`. + - `0` وگرنه +- برای ارزش های دیگر `IS NULL` اپراتور همیشه باز می گردد `0`. + + + +``` sql +SELECT x+100 FROM t_null WHERE y IS NULL +``` + +``` text +┌─plus(x, 100)─┐ +│ 101 │ +└──────────────┘ +``` + +### IS NOT NULL {#is-not-null} + +- برای [Nullable](../../sql-reference/data-types/nullable.md) مقادیر نوع `IS NOT NULL` بازگشت اپراتور: + - `0` اگر مقدار باشد `NULL`. + - `1` وگرنه +- برای ارزش های دیگر `IS NOT NULL` اپراتور همیشه باز می گردد `1`. + + + +``` sql +SELECT * FROM t_null WHERE y IS NOT NULL +``` + +``` text +┌─x─┬─y─┐ +│ 2 │ 3 │ +└───┴───┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/fa/sql-reference/statements/alter.md b/docs/fa/sql-reference/statements/alter.md new file mode 100644 index 00000000000..6afc311f74e --- /dev/null +++ b/docs/fa/sql-reference/statements/alter.md @@ -0,0 +1,602 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: ALTER +--- + +## ALTER {#query_language_queries_alter} + +این `ALTER` پرسوجو فقط برای پشتیبانی `*MergeTree` جداول و همچنین `Merge`و`Distributed`. پرس و جو دارای چندین تغییرات. + +### دستکاری ستون {#column-manipulations} + +تغییر ساختار جدول. + +``` sql +ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... +``` + +در پرس و جو, مشخص یک لیست از یک یا چند اقدامات کاما از هم جدا. +هر عمل یک عملیات بر روی یک ستون است. + +اقدامات زیر پشتیبانی می شوند: + +- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. +- [DROP COLUMN](#alter_drop-column) — Deletes the column. +- [CLEAR COLUMN](#alter_clear-column) — Resets column values. +- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. +- [MODIFY COLUMN](#alter_modify-column) — Changes column's type, default expression and TTL. + +این اقدامات در زیر توضیح داده شده است. + +#### ADD COLUMN {#alter_add-column} + +``` sql +ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] +``` + +یک ستون جدید به جدول با مشخص اضافه می کند `name`, `type`, [`codec`](create.md#codecs) و `default_expr` (نگاه کنید به بخش [عبارتهای پیشفرض](create.md#create-default-values)). + +اگر `IF NOT EXISTS` بند گنجانده شده است, پرس و جو یک خطا بازگشت نیست اگر ستون در حال حاضر وجود دارد. اگر شما مشخص کنید `AFTER name_after` (نام ستون دیگر), ستون پس از یک مشخص شده در لیست ستون جدول اضافه. در غیر این صورت, ستون به پایان جدول اضافه. توجه داشته باشید که هیچ راهی برای اضافه کردن یک ستون به ابتدای جدول وجود دارد. برای زنجیره ای از اقدامات, `name_after` می تواند نام یک ستون است که در یکی از اقدامات قبلی اضافه شده است. + +اضافه کردن یک ستون فقط تغییر ساختار جدول, بدون انجام هر گونه اقدامات با داده. داده ها بر روی دیسک پس از ظاهر نمی شود `ALTER`. اگر داده ها برای یک ستون از دست رفته در هنگام خواندن از جدول, این است که در با مقادیر پیش فرض پر (با انجام عبارت پیش فرض اگر یکی وجود دارد, و یا با استفاده از صفر یا رشته های خالی). ستون بر روی دیسک به نظر می رسد پس از ادغام قطعات داده (دیدن [ادغام](../../engines/table-engines/mergetree-family/mergetree.md)). + +این رویکرد اجازه می دهد تا ما را به تکمیل `ALTER` پرس و جو فورا, بدون افزایش حجم داده های قدیمی. + +مثال: + +``` sql +ALTER TABLE visits ADD COLUMN browser String AFTER user_id +``` + +#### DROP COLUMN {#alter_drop-column} + +``` sql +DROP COLUMN [IF EXISTS] name +``` + +ستون را با نام حذف می کند `name`. اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. + +حذف داده ها از سیستم فایل. از این حذف تمام فایل های پرس و جو تقریبا بلافاصله تکمیل شده است. + +مثال: + +``` sql +ALTER TABLE visits DROP COLUMN browser +``` + +#### CLEAR COLUMN {#alter_clear-column} + +``` sql +CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name +``` + +بازنشانی تمام داده ها در یک ستون برای یک پارتیشن مشخص. اطلاعات بیشتر در مورد تنظیم نام پارتیشن در بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). + +اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. + +مثال: + +``` sql +ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() +``` + +#### COMMENT COLUMN {#alter_comment-column} + +``` sql +COMMENT COLUMN [IF EXISTS] name 'comment' +``` + +می افزاید: نظر به ستون. اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. + +هر ستون می تواند یک نظر داشته باشد. اگر یک نظر در حال حاضر برای ستون وجود دارد, یک نظر جدید رونویسی نظر قبلی. + +نظرات در ذخیره می شود `comment_expression` ستون توسط [DESCRIBE TABLE](misc.md#misc-describe-table) پرس و جو. + +مثال: + +``` sql +ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' +``` + +#### MODIFY COLUMN {#alter_modify-column} + +``` sql +MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] +``` + +این پرسوجو تغییر میکند `name` ویژگیهای ستون: + +- نوع + +- عبارت پیشفرض + +- TTL + + For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). + +اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. + +هنگام تغییر نوع, ارزش ها به عنوان اگر تبدیل [نوع](../../sql-reference/functions/type-conversion-functions.md) توابع به کار گرفته شد. اگر تنها عبارت پیش فرض تغییر می کند, پرس و جو می کند هر چیزی پیچیده نیست, و تقریبا بلافاصله تکمیل. + +مثال: + +``` sql +ALTER TABLE visits MODIFY COLUMN browser Array(String) +``` + +Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. + +چندین مرحله پردازش وجود دارد: + +- تهیه فایل های موقت (جدید) با داده های اصلاح شده. +- تغییر نام فایل های قدیمی. +- تغییر نام فایل های موقت (جدید) به نام های قدیمی. +- حذف فایل های قدیمی. + +فقط مرحله اول زمان طول می کشد. در صورتی که یک شکست در این مرحله وجود دارد, داده ها تغییر نکرده است. +در صورتی که یک شکست در یکی از مراحل پی در پی وجود دارد, داده ها را می توان به صورت دستی ترمیم. استثنا است اگر فایل های قدیمی از سیستم فایل حذف شد اما داده ها را برای فایل های جدید را به دیسک نوشته شده است و از دست داده بود. + +این `ALTER` پرس و جو برای تغییر ستون تکرار شده است. دستورالعمل ها در باغ وحش ذخیره می شوند و سپس هر ماکت اعمال می شود. همه `ALTER` نمایش داده شد در همان جهت اجرا شود. پرس و جو منتظر اقدامات مناسب برای در کپی دیگر تکمیل شود. با این حال, پرس و جو برای تغییر ستون در یک جدول تکرار می تواند قطع, و تمام اقدامات غیر همزمان انجام خواهد شد. + +#### تغییر محدودیت پرس و جو {#alter-query-limitations} + +این `ALTER` پرس و جو به شما امکان ایجاد و حذف عناصر جداگانه (ستون) در ساختارهای داده های تو در تو, اما نه کل ساختارهای داده تو در تو. برای اضافه کردن یک ساختار داده های تو در تو, شما می توانید ستون با یک نام مانند اضافه `name.nested_name` و نوع `Array(T)`. ساختار داده های تو در تو معادل ستون های چندگانه با یک نام است که پیشوند مشابه قبل از نقطه است. + +هیچ پشتیبانی برای حذف ستون ها در کلید اصلی یا کلید نمونه برداری (ستون هایی که در استفاده می شود) وجود ندارد. `ENGINE` عبارت). تغییر نوع ستون که در کلید اصلی گنجانده شده است تنها ممکن است اگر این تغییر باعث نمی شود داده ها به اصلاح شود (مثلا, شما مجاز به اضافه کردن مقادیر به شمارشی و یا برای تغییر یک نوع از `DateTime` به `UInt32`). + +اگر `ALTER` پرس و جو برای ایجاد تغییرات جدول مورد نیاز کافی نیست شما می توانید یک جدول جدید ایجاد کنید و داده ها را با استفاده از داده ها کپی کنید [INSERT SELECT](insert-into.md#insert_query_insert-select) پرس و جو, سپس جداول با استفاده از تغییر [RENAME](misc.md#misc_operations-rename) پرس و جو و حذف جدول قدیمی. شما می توانید از [تاتر-کپی](../../operations/utilities/clickhouse-copier.md) به عنوان یک جایگزین برای `INSERT SELECT` پرس و جو. + +این `ALTER` بلوک پرس و جو همه می خواند و می نویسد برای جدول. به عبارت دیگر, اگر طولانی `SELECT` در حال اجرا است در زمان `ALTER` پرس و جو `ALTER` پرس و جو منتظر خواهد ماند تا کامل شود. همزمان, تمام نمایش داده شد جدید به همان جدول صبر کنید در حالی که این `ALTER` در حال اجرا است. + +برای جداول که داده های خود را ذخیره کنید (مانند `Merge` و `Distributed`), `ALTER` فقط ساختار جدول را تغییر می دهد و ساختار جداول تابع را تغییر نمی دهد. مثلا, زمانی که در حال اجرا را تغییر دهید برای یک `Distributed` جدول, شما همچنین نیاز به اجرا `ALTER` برای جداول در تمام سرور از راه دور. + +### دستکاری با عبارات کلیدی {#manipulations-with-key-expressions} + +دستور زیر پشتیبانی می شود: + +``` sql +MODIFY ORDER BY new_expression +``` + +این فقط برای جداول در کار می کند [`MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) خانواده (از جمله +[تکرار](../../engines/table-engines/mergetree-family/replication.md) جدول). فرمان تغییر +[کلید مرتب سازی](../../engines/table-engines/mergetree-family/mergetree.md) از جدول +به `new_expression` (بیان و یا یک تاپل از عبارات). کلید اصلی یکسان باقی می ماند. + +فرمان سبک وزن به این معنا است که تنها ابرداده را تغییر می دهد. برای حفظ اموال که بخش داده ها +ردیف ها توسط عبارت کلیدی مرتب سازی شما می توانید عبارات حاوی ستون های موجود اضافه کنید دستور داد +به کلید مرتب سازی (فقط ستون اضافه شده توسط `ADD COLUMN` فرمان در همان `ALTER` پرسوجو). + +### دستکاری با شاخص های پرش داده {#manipulations-with-data-skipping-indices} + +این فقط برای جداول در کار می کند [`*MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) خانواده (از جمله +[تکرار](../../engines/table-engines/mergetree-family/replication.md) جدول). عملیات زیر +در دسترس هستند: + +- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` - می افزاید توضیحات شاخص به ابرداده جداول . + +- `ALTER TABLE [db].name DROP INDEX name` - حذف شرح شاخص از ابرداده جداول و حذف فایل های شاخص از دیسک. + +این دستورات سبک وزن هستند به این معنا که فقط فراداده را تغییر می دهند یا فایل ها را حذف می کنند. +همچنین تکرار میشوند (همگامسازی فرادادههای شاخص از طریق باغ وحش). + +### دستکاری با محدودیت {#manipulations-with-constraints} + +مشاهده بیشتر در [قیدها](create.md#constraints) + +محدودیت ها می توانند با استفاده از نحو زیر اضافه یا حذف شوند: + +``` sql +ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; +ALTER TABLE [db].name DROP CONSTRAINT constraint_name; +``` + +نمایش داده شد اضافه خواهد شد و یا حذف ابرداده در مورد محدودیت از جدول به طوری که بلافاصله پردازش شده است. + +بررسی قید *اعدام نخواهد شد* در داده های موجود اگر اضافه شد. + +همه تغییرات در جداول تکرار در حال پخش به باغ وحش بنابراین خواهد شد در دیگر کپی اعمال می شود. + +### دستکاری با پارتیشن ها و قطعات {#alter_manipulations-with-partitions} + +عملیات زیر را با [پارتیشن ها](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) در دسترس هستند: + +- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` دایرکتوری و فراموش کرده ام. +- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. +- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` دایرکتوری به جدول. +- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. +- [REPLACE PARTITION](#alter_replace-partition) - پارتیشن داده ها را از یک جدول به دیگری کپی می کند و جایگزین می شود. +- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition)(\#تغییر\_موف\_ قابل تنظیم-پارتیشن) - پارتیشن داده را از یک جدول به دیگری حرکت دهید. +- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) - بازنشانی ارزش یک ستون مشخص شده در یک پارتیشن. +- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) - بازنشانی شاخص ثانویه مشخص شده در یک پارتیشن. +- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. +- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. +- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. + + + +#### DETACH PARTITION {#alter_detach-partition} + +``` sql +ALTER TABLE table_name DETACH PARTITION partition_expr +``` + +تمام داده ها را برای پارتیشن مشخص شده به `detached` فهرست راهنما. سرور فراموش در مورد پارتیشن داده جدا به عنوان اگر وجود ندارد. سرور نمی خواهد در مورد این داده ها می دانم تا زمانی که شما را به [ATTACH](#alter_attach-partition) پرس و جو. + +مثال: + +``` sql +ALTER TABLE visits DETACH PARTITION 201901 +``` + +اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). + +پس از پرس و جو اجرا شده است, شما می توانید هر کاری که می خواهید با داده ها در انجام `detached` directory — delete it from the file system, or just leave it. + +This query is replicated – it moves the data to the `detached` دایرکتوری در تمام کپی. توجه داشته باشید که شما می توانید این پرس و جو تنها در یک ماکت رهبر را اجرا کند. برای پیدا کردن اگر یک ماکت یک رهبر است, انجام `SELECT` پرسوجو به [سیستم.تکرار](../../operations/system-tables.md#system_tables-replicas) جدول متناوبا, راحت تر به یک است `DETACH` پرس و جو در تمام کپی - همه کپی پرتاب یک استثنا, به جز ماکت رهبر. + +#### DROP PARTITION {#alter_drop-partition} + +``` sql +ALTER TABLE table_name DROP PARTITION partition_expr +``` + +پارتیشن مشخص شده را از جدول حذف می کند. این برچسب ها پرس و جو پارتیشن به عنوان غیر فعال و حذف داده ها به طور کامل, حدود در 10 دقیقه. + +اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). + +The query is replicated – it deletes data on all replicas. + +#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} + +``` sql +ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr +``` + +بخش مشخص شده یا تمام قسمت های پارتیشن مشخص شده را از بین می برد `detached`. +اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). + +#### ATTACH PARTITION\|PART {#alter_attach-partition} + +``` sql +ALTER TABLE table_name ATTACH PARTITION|PART partition_expr +``` + +می افزاید داده ها به جدول از `detached` فهرست راهنما. ممکن است که به اضافه کردن داده ها برای کل پارتیشن و یا برای یک بخش جداگانه. مثالها: + +``` sql +ALTER TABLE visits ATTACH PARTITION 201901; +ALTER TABLE visits ATTACH PART 201901_2_2_0; +``` + +اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). + +این پرس و جو تکرار شده است. چک المثنی-ابتکار چه داده ها در وجود دارد `detached` فهرست راهنما. اگر داده وجود دارد, پرس و جو چک یکپارچگی خود را. اگر همه چیز درست است, پرس و جو می افزاید: داده ها به جدول. همه کپی دیگر دانلود داده ها از ماکت-مبتکر. + +بنابراین شما می توانید داده ها را به `detached` دایرکتوری در یک ماکت, و استفاده از `ALTER ... ATTACH` پرس و جو برای اضافه کردن به جدول در تمام کپی. + +#### ATTACH PARTITION FROM {#alter_attach-partition-from} + +``` sql +ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 +``` + +این پرس و جو پارتیشن داده را از `table1` به `table2` می افزاید داده ها به لیست موجود در `table2`. توجه داشته باشید که داده ها از حذف نمی شود `table1`. + +برای پرس و جو به اجرا با موفقیت, شرایط زیر باید رعایت شود: + +- هر دو جدول باید همان ساختار دارند. +- هر دو جدول باید کلید پارتیشن همان. + +#### REPLACE PARTITION {#alter_replace-partition} + +``` sql +ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 +``` + +این پرس و جو پارتیشن داده را از `table1` به `table2` و جایگزین پارتیشن موجود در `table2`. توجه داشته باشید که داده ها از حذف نمی شود `table1`. + +برای پرس و جو به اجرا با موفقیت, شرایط زیر باید رعایت شود: + +- هر دو جدول باید همان ساختار دارند. +- هر دو جدول باید کلید پارتیشن همان. + +#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} + +``` sql +ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest +``` + +این پرس و جو انتقال پارتیشن داده ها از `table_source` به `table_dest` با حذف داده ها از `table_source`. + +برای پرس و جو به اجرا با موفقیت, شرایط زیر باید رعایت شود: + +- هر دو جدول باید همان ساختار دارند. +- هر دو جدول باید کلید پارتیشن همان. +- هر دو جدول باید همان خانواده موتور باشد. (تکرار و یا غیر تکرار) +- هر دو جدول باید سیاست ذخیره سازی همان. + +#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} + +``` sql +ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr +``` + +بازنشانی تمام مقادیر در ستون مشخص شده در یک پارتیشن. اگر `DEFAULT` بند هنگام ایجاد یک جدول تعیین شد, این پرس و جو مجموعه مقدار ستون به یک مقدار پیش فرض مشخص. + +مثال: + +``` sql +ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 +``` + +#### FREEZE PARTITION {#alter_freeze-partition} + +``` sql +ALTER TABLE table_name FREEZE [PARTITION partition_expr] +``` + +این پرس و جو یک نسخه پشتیبان تهیه محلی از یک پارتیشن مشخص شده ایجاد می کند. اگر `PARTITION` بند حذف شده است, پرس و جو ایجاد پشتیبان گیری از تمام پارتیشن در یک بار. + +!!! note "یادداشت" + تمامی مراحل پشتیبان گیری بدون توقف سرور انجام می شود. + +توجه داشته باشید که برای جداول قدیمی مدل دهید شما می توانید پیشوند نام پارتیشن را مشخص کنید (به عنوان مثال, ‘2019’)- سپس پرس و جو پشتیبان گیری برای تمام پارتیشن مربوطه ایجاد می کند. اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). + +در زمان اجرای, برای یک تصویر لحظهای داده, پرس و جو ایجاد لینک به داده های جدول. پیوندهای سخت در دایرکتوری قرار می گیرند `/var/lib/clickhouse/shadow/N/...` کجا: + +- `/var/lib/clickhouse/` است دایرکتوری محل کلیک کار مشخص شده در پیکربندی. +- `N` تعداد افزایشی از نسخه پشتیبان تهیه شده است. + +!!! note "یادداشت" + در صورت استفاده [مجموعه ای از دیسک برای ذخیره سازی داده ها در یک جدول](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) این `shadow/N` دایرکتوری به نظر می رسد در هر دیسک, ذخیره سازی قطعات داده که توسط همسان `PARTITION` اصطلاح. + +همان ساختار دایرکتوری ها در داخل پشتیبان به عنوان داخل ایجاد شده است `/var/lib/clickhouse/`. پرس و جو انجام می شود ‘chmod’ برای همه پروندهها نوشتن رو ممنوع کردم + +پس از ایجاد نسخه پشتیبان تهیه, شما می توانید داده ها را از کپی `/var/lib/clickhouse/shadow/` به سرور از راه دور و سپس از سرور محلی حذف کنید. توجه داشته باشید که `ALTER t FREEZE PARTITION` پرس و جو تکرار نشده است. این یک نسخه پشتیبان تهیه محلی تنها بر روی سرور محلی ایجاد می کند. + +پرس و جو ایجاد نسخه پشتیبان تهیه تقریبا بلافاصله (اما برای اولین بار برای نمایش داده شد در حال حاضر به جدول مربوطه منتظر را به پایان برساند در حال اجرا). + +`ALTER TABLE t FREEZE PARTITION` نسخه تنها داده, ابرداده جدول نیست. برای تهیه نسخه پشتیبان از فراداده های جدول فایل را کپی کنید `/var/lib/clickhouse/metadata/database/table.sql` + +برای بازیابی اطلاعات از یک نسخه پشتیبان تهیه زیر را انجام دهید: + +1. ایجاد جدول اگر وجود ندارد. برای مشاهده پرس و جو, استفاده از .پرونده جدید `ATTACH` در این با `CREATE`). +2. رونوشت داده از `data/database/table/` دایرکتوری در داخل پشتیبان گیری به `/var/lib/clickhouse/data/database/table/detached/` فهرست راهنما. +3. بدو `ALTER TABLE t ATTACH PARTITION` نمایش داده شد برای اضافه کردن داده ها به یک جدول. + +بازگرداندن از یک نسخه پشتیبان تهیه می کند نیاز به متوقف کردن سرور نیست. + +برای کسب اطلاعات بیشتر در مورد پشتیبان گیری و بازیابی اطلاعات, دیدن [پشتیبان گیری داده ها](../../operations/backup.md) بخش. + +#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} + +``` sql +ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr +``` + +پرس و جو کار می کند شبیه به `CLEAR COLUMN`, اما بازنشانی شاخص به جای یک داده ستون. + +#### FETCH PARTITION {#alter_fetch-partition} + +``` sql +ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' +``` + +دانلود یک پارتیشن از سرور دیگر. این پرس و جو تنها برای جداول تکرار کار می کند. + +پرس و جو می کند به شرح زیر است: + +1. پارتیشن را از سفال مشخص شده دانلود کنید. داخل ‘path-in-zookeeper’ شما باید یک مسیر به سفال در باغ وحش را مشخص کنید. +2. سپس پرس و جو داده های دانلود شده را به `detached` دایرکتوری از `table_name` جدول استفاده از [ATTACH PARTITION\|PART](#alter_attach-partition) پرسوجو برای افزودن داده به جدول. + +به عنوان مثال: + +``` sql +ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; +ALTER TABLE users ATTACH PARTITION 201902; +``` + +توجه داشته باشید که: + +- این `ALTER ... FETCH PARTITION` پرس و جو تکرار نشده است. این پارتیشن را به `detached` دایرکتوری تنها بر روی سرور محلی. +- این `ALTER TABLE ... ATTACH` پرس و جو تکرار شده است. این می افزاید: داده ها به تمام کپی. داده ها به یکی از کپی ها از `detached` فهرست راهنما, و به دیگران - از کپی همسایه. + +قبل از دانلود, سیستم چک اگر پارتیشن وجود دارد و ساختار جدول مسابقات. ماکت مناسب ترین به طور خودکار از کپی سالم انتخاب شده است. + +اگر چه پرس و جو نامیده می شود `ALTER TABLE`, این ساختار جدول را تغییر دهید و بلافاصله داده های موجود در جدول را تغییر دهید. + +#### MOVE PARTITION\|PART {#alter_move-partition} + +پارتیشن ها یا قطعات داده را به حجم یا دیسک دیگری منتقل می کند `MergeTree`- جدول موتور . ببینید [با استفاده از دستگاه های بلوک های متعدد برای ذخیره سازی داده ها](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes). + +``` sql +ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' +``` + +این `ALTER TABLE t MOVE` پرسوجو: + +- تکرار نشده, به دلیل کپی های مختلف می توانید سیاست های ذخیره سازی مختلف دارند. +- بازگرداندن خطا در صورتی که دیسک یا حجم مشخص پیکربندی نشده است. پرس و جو نیز یک خطا را برمی گرداند اگر شرایط در حال حرکت داده, که مشخص شده در سیاست ذخیره سازی, نمی توان اعمال کرد. +- می توانید یک خطا در مورد بازگشت, زمانی که داده ها به نقل مکان کرد در حال حاضر توسط یک فرایند پس زمینه نقل مکان کرد, همزمان `ALTER TABLE t MOVE` پرس و جو و یا به عنوان یک نتیجه از ادغام داده های پس زمینه. کاربر باید هر گونه اقدامات اضافی در این مورد انجام نمی. + +مثال: + +``` sql +ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' +ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' +``` + +#### نحوه تنظیم بیان پارتیشن {#alter-how-to-specify-part-expr} + +شما می توانید بیان پارتیشن را مشخص کنید `ALTER ... PARTITION` نمایش داده شد به روش های مختلف: + +- به عنوان یک مقدار از `partition` ستون از `system.parts` جدول به عنوان مثال, `ALTER TABLE visits DETACH PARTITION 201901`. +- به عنوان بیان از ستون جدول. ثابت ها و عبارات ثابت پشتیبانی می شوند. به عنوان مثال, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. +- با استفاده از شناسه پارتیشن. شناسه پارتیشن شناسه رشته پارتیشن (انسان قابل خواندن در صورت امکان) است که به عنوان نام پارتیشن در فایل سیستم و در باغ وحش استفاده می شود. شناسه پارتیشن باید در `PARTITION ID` بند, در یک نقل قول واحد. به عنوان مثال, `ALTER TABLE visits DETACH PARTITION ID '201901'`. +- در [ALTER ATTACH PART](#alter_attach-partition) و [DROP DETACHED PART](#alter_drop-detached) پرس و جو, برای مشخص کردن نام یک بخش, استفاده از رشته تحت اللفظی با ارزش از `name` ستون از [سیستم.قطعات مجزا](../../operations/system-tables.md#system_tables-detached_parts) جدول به عنوان مثال, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. + +استفاده از نقل قول در هنگام مشخص کردن پارتیشن بستگی به نوع بیان پارتیشن. برای مثال برای `String` نوع, شما باید برای مشخص کردن نام خود را در نقل قول (`'`). برای `Date` و `Int*` انواع بدون نقل قول مورد نیاز است. + +برای جداول قدیمی به سبک, شما می توانید پارتیشن یا به عنوان یک عدد مشخص `201901` یا یک رشته `'201901'`. نحو برای جداول سبک جدید سختگیرانه تر با انواع است (شبیه به تجزیه کننده برای فرمت ورودی ارزش). + +تمام قوانین فوق نیز برای درست است [OPTIMIZE](misc.md#misc_operations-optimize) پرس و جو. اگر شما نیاز به مشخص کردن تنها پارتیشن در هنگام بهینه سازی یک جدول غیر تقسیم, تنظیم بیان `PARTITION tuple()`. به عنوان مثال: + +``` sql +OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; +``` + +نمونه هایی از `ALTER ... PARTITION` نمایش داده شد در تست نشان داده شده است [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) و [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). + +### دستکاری با جدول جدول {#manipulations-with-table-ttl} + +شما می توانید تغییر دهید [جدول](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) با درخواست فرم زیر: + +``` sql +ALTER TABLE table-name MODIFY TTL ttl-expression +``` + +### همزمانی تغییر نمایش داده شد {#synchronicity-of-alter-queries} + +برای جداول غیر قابل تکرار, همه `ALTER` نمایش داده شد همزمان انجام می شود. برای جداول تکرار, پرس و جو فقط می افزاید دستورالعمل برای اقدامات مناسب به `ZooKeeper` و اقدامات خود را در اسرع وقت انجام می شود. با این حال, پرس و جو می توانید صبر کنید برای این اقدامات در تمام کپی تکمیل شود. + +برای `ALTER ... ATTACH|DETACH|DROP` نمایش داده شد, شما می توانید با استفاده از `replication_alter_partitions_sync` راه اندازی به راه اندازی انتظار. +مقادیر ممکن: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. + +### جهشها {#alter-mutations} + +جهش یک نوع پرس و جو را تغییر دهید که اجازه می دهد تا تغییر یا حذف ردیف در یک جدول. در مقایسه با استاندارد `UPDATE` و `DELETE` نمایش داده شد که برای تغییرات داده نقطه در نظر گرفته شده, جهش برای عملیات سنگین است که تغییر بسیاری از ردیف در یک جدول در نظر گرفته شده. پشتیبانی برای `MergeTree` خانواده از موتورهای جدول از جمله موتورهای با پشتیبانی تکرار. + +جداول موجود برای جهش به عنوان (بدون تبدیل لازم), اما پس از جهش برای اولین بار است که به یک جدول اعمال, فرمت ابرداده خود را با نسخه های سرور قبلی ناسازگار می شود و سقوط به نسخه های قبلی غیر ممکن می شود. + +دستورات در حال حاضر در دسترس: + +``` sql +ALTER TABLE [db.]table DELETE WHERE filter_expr +``` + +این `filter_expr` باید از نوع باشد `UInt8`. پرس و جو حذف ردیف در جدول که این عبارت طول می کشد یک مقدار غیر صفر. + +``` sql +ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr +``` + +این `filter_expr` باید از نوع باشد `UInt8`. این پرس و جو به روز رسانی مقادیر ستون مشخص شده به ارزش عبارات مربوطه در ردیف که `filter_expr` طول می کشد یک مقدار غیر صفر. ارزش ها به نوع ستون با استفاده از قالبی `CAST` اپراتور به روز رسانی ستون هایی که در محاسبه اولیه استفاده می شود و یا کلید پارتیشن پشتیبانی نمی شود. + +``` sql +ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name +``` + +پرس و جو بازسازی شاخص ثانویه `name` در پارتیشن `partition_name`. + +یک پرس و جو می تواند شامل چندین دستورات جدا شده توسط کاما. + +برای \* جداول ادغام جهش اجرا با بازنویسی تمام قطعات داده. هیچ اتمیتی وجود ندارد - قطعات برای قطعات جهش یافته جایگزین می شوند به محض اینکه اماده باشند و `SELECT` پرس و جو است که شروع به اجرای در طول جهش داده ها از قطعات است که در حال حاضر همراه با داده ها از قطعات است که هنوز جهش یافته شده اند جهش را ببینید. + +جهش ها به طور کامل توسط نظم خلقت خود دستور داده می شوند و به هر بخش به این ترتیب اعمال می شوند. جهش نیز تا حدی با درج دستور داد - داده هایی که به جدول وارد شد قبل از جهش ارسال خواهد شد جهش یافته و داده هایی که پس از که قرار داده شد جهش یافته نمی شود. توجه داشته باشید که جهش درج به هیچ وجه مسدود نیست. + +یک جهش پرس و جو می گرداند بلافاصله پس از جهش مطلب اضافه شده است (در صورت تکرار جداول به باغ وحش برای nonreplicated جداول - به فایل سیستم). جهش خود را اجرا ناهمگام با استفاده از تنظیمات مشخصات سیستم. برای پیگیری پیشرفت جهش شما می توانید با استفاده از [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) جدول یک جهش است که با موفقیت ارسال شد ادامه خواهد داد برای اجرای حتی اگر سرور کلیک دوباره راه اندازی. هیچ راهی برای عقب انداختن جهش هنگامی که ارسال شده است وجود دارد, اما اگر جهش برای برخی از دلیل گیر می تواند با لغو [`KILL MUTATION`](misc.md#kill-mutation) پرس و جو. + +مطالب برای جهش به پایان رسید حذف نمی حق دور (تعداد نوشته های حفظ شده توسط تعیین `finished_mutations_to_keep` پارامتر موتور ذخیره سازی). نوشته جهش قدیمی تر حذف می شوند. + +## ALTER USER {#alter-user-statement} + +تغییرات حساب کاربر کلیک. + +### نحو {#alter-user-syntax} + +``` sql +ALTER USER [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}] + [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### توصیف {#alter-user-dscr} + +برای استفاده `ALTER USER` شما باید [ALTER USER](grant.md#grant-access-management) امتیاز. + +### مثالها {#alter-user-examples} + +تنظیم نقش های اعطا شده به عنوان پیش فرض: + +``` sql +ALTER USER user DEFAULT ROLE role1, role2 +``` + +اگر نقش قبلا به یک کاربر اعطا نمی, تاتر می اندازد یک استثنا. + +تنظیم تمام نقش های اعطا شده به طور پیش فرض: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +اگر یک نقش به یک کاربر در اینده اعطا خواهد شد به طور پیش فرض به طور خودکار تبدیل خواهد شد. + +تنظیم تمام نقش های اعطا شده به استثنای پیش فرض `role1` و `role2`: + +``` sql +ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2 +``` + +## ALTER ROLE {#alter-role-statement} + +نقش ها را تغییر می دهد. + +### نحو {#alter-role-syntax} + +``` sql +ALTER ROLE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +## ALTER ROW POLICY {#alter-row-policy-statement} + +سیاست تغییرات ردیف. + +### نحو {#alter-row-policy-syntax} + +``` sql +ALTER [ROW] POLICY [IF EXISTS] name [ON CLUSTER cluster_name] ON [database.]table + [RENAME TO new_name] + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING {condition | NONE}][,...] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +## ALTER QUOTA {#alter-quota-statement} + +سهمیه تغییرات. + +### نحو {#alter-quota-syntax} + +``` sql +ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +## ALTER SETTINGS PROFILE {#alter-settings-profile-statement} + +سهمیه تغییرات. + +### نحو {#alter-settings-profile-syntax} + +``` sql +ALTER SETTINGS PROFILE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/fa/sql-reference/statements/create.md b/docs/fa/sql-reference/statements/create.md new file mode 100644 index 00000000000..f6217b8e87f --- /dev/null +++ b/docs/fa/sql-reference/statements/create.md @@ -0,0 +1,502 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: CREATE +--- + +# ایجاد پرس و جو {#create-queries} + +## CREATE DATABASE {#query-language-create-database} + +ایجاد پایگاه داده. + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] +``` + +### بند {#clauses} + +- `IF NOT EXISTS` + اگر `db_name` پایگاه داده از قبل وجود دارد, سپس کلیک هاوس می کند یک پایگاه داده جدید ایجاد کنید و: + + - اگر بند مشخص شده است یک استثنا پرتاب نمی کند. + - می اندازد یک استثنا اگر بند مشخص نشده است. + +- `ON CLUSTER` + کلیک ایجاد می کند `db_name` پایگاه داده در تمام سرورهای یک خوشه مشخص. + +- `ENGINE` + + - [MySQL](../../engines/database-engines/mysql.md) + به شما اجازه می دهد برای بازیابی اطلاعات از سرور خروجی زیر از راه دور. + به طور پیش فرض, تاتر با استفاده از خود [موتور دادگان](../../engines/database-engines/index.md). + +## CREATE TABLE {#create-table-query} + +این `CREATE TABLE` پرس و جو می تواند اشکال مختلف داشته باشد. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], + ... +) ENGINE = engine +``` + +ایجاد یک جدول به نام ‘name’ در ‘db’ پایگاه داده یا پایگاه داده فعلی اگر ‘db’ تنظیم نشده است, با ساختار مشخص شده در براکت و ‘engine’ موتور +ساختار جدول یک لیست از توصیف ستون است. اگر شاخص ها توسط موتور پشتیبانی می شوند به عنوان پارامتر برای موتور جدول نشان داده می شوند. + +شرح ستون است `name type` در ساده ترین حالت. مثال: `RegionID UInt32`. +عبارات همچنین می توانید برای مقادیر پیش فرض تعریف شود (پایین را ببینید). + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] +``` + +ایجاد یک جدول با همان ساختار به عنوان جدول دیگر. شما می توانید یک موتور مختلف برای جدول مشخص کنید. اگر موتور مشخص نشده است, همان موتور خواهد شد که برای استفاده `db2.name2` جدول + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() +``` + +ایجاد یک جدول با ساختار و داده های بازگردانده شده توسط یک [تابع جدول](../table-functions/index.md#table-functions). + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... +``` + +ایجاد یک جدول با یک ساختار مانند نتیجه `SELECT` پرس و جو, با ‘engine’ موتور, و پر با داده ها از را انتخاب کنید. + +در همه موارد اگر `IF NOT EXISTS` مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر جدول در حال حاضر وجود دارد. در این مورد پرس و جو هیچ کاری انجام نخواهد داد. + +می تواند بند دیگر پس از وجود دارد `ENGINE` بند در پرس و جو. مشاهده مستندات دقیق در مورد چگونگی ایجاد جداول در شرح [موتورهای جدول](../../engines/table-engines/index.md#table_engines). + +### مقادیر پیشفرض {#create-default-values} + +شرح ستون می تواند یک عبارت برای یک مقدار پیش فرض مشخص, در یکی از روش های زیر:`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. +مثال: `URLDomain String DEFAULT domain(URL)`. + +اگر یک عبارت برای مقدار پیش فرض تعریف نشده است, مقادیر پیش فرض خواهد شد به صفر برای اعداد تنظیم, رشته های خالی برای رشته, طعمه خالی برای ارریس, و `0000-00-00` برای تاریخ و یا `0000-00-00 00:00:00` برای تاریخ با زمان. نقاط صفر پشتیبانی نمی شوند. + +اگر عبارت پیش فرض تعریف شده است, نوع ستون اختیاری است. در صورتی که یک نوع به صراحت تعریف شده وجود ندارد, نوع بیان پیش فرض استفاده شده است. مثال: `EventDate DEFAULT toDate(EventTime)` – the ‘Date’ نوع خواهد شد برای استفاده ‘EventDate’ ستون. + +اگر نوع داده ها و بیان پیش فرض به صراحت تعریف, این عبارت خواهد شد به نوع مشخص با استفاده از توابع نوع ریخته گری بازیگران. مثال: `Hits UInt32 DEFAULT 0` معنی همان چیزی که به عنوان `Hits UInt32 DEFAULT toUInt32(0)`. + +Default expressions may be defined as an arbitrary expression from table constants and columns. When creating and changing the table structure, it checks that expressions don't contain loops. For INSERT, it checks that expressions are resolvable – that all columns they can be calculated from have been passed. + +`DEFAULT expr` + +مقدار پیش فرض عادی. اگر پرس و جو درج می کند ستون مربوطه مشخص نیست, خواهد شد در محاسبات بیان مربوطه پر. + +`MATERIALIZED expr` + +بیان محقق. چنین ستون ای نمی تواند برای درج مشخص شود زیرا همیشه محاسبه می شود. +برای درج بدون یک لیست از ستون, این ستون ها در نظر گرفته نمی. +علاوه بر این, این ستون جایگزین نشده است که با استفاده از یک ستاره در یک پرس و جو را انتخاب کنید. این است که برای حفظ همواره که تخلیه با استفاده از `SELECT *` را می توان به جدول با استفاده از درج بدون مشخص کردن لیست ستون قرار داده شده. + +`ALIAS expr` + +دو واژه مترادف. چنین ستون در جدول ذخیره نمی شود و در همه. +ارزش های خود را نمی توان در یک جدول قرار داد و هنگام استفاده از ستاره در یک پرس و جو انتخاب جایگزین نمی شود. +این را می توان در انتخاب استفاده می شود اگر نام مستعار است که در طول تجزیه پرس و جو گسترش یافته است. + +هنگام استفاده از پرس و جو را تغییر دهید برای اضافه کردن ستون جدید, داده های قدیمی برای این ستون نوشته نشده است. بجای, در هنگام خواندن داده های قدیمی که ارزش برای ستون جدید ندارد, عبارات در پرواز به طور پیش فرض محاسبه. با این حال, اگر در حال اجرا عبارات نیاز به ستون های مختلف است که در پرس و جو نشان داده نمی, این ستون علاوه بر خوانده خواهد شد, اما فقط برای بلوک های داده که نیاز. + +اگر شما یک ستون جدید اضافه کردن به یک جدول اما بعد تغییر بیان پیش فرض خود, ارزش های مورد استفاده برای داده های قدیمی تغییر خواهد کرد (برای داده هایی که ارزش بر روی دیسک ذخیره نمی شد). توجه داشته باشید که هنگام اجرای ادغام پس زمینه, داده ها را برای ستون که در یکی از قطعات ادغام از دست رفته است به بخش ادغام شده نوشته شده. + +این ممکن است به مجموعه مقادیر پیش فرض برای عناصر در ساختارهای داده تو در تو. + +### قیدها {#constraints} + +همراه با ستون توصیف محدودیت می تواند تعریف شود: + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + ... + CONSTRAINT constraint_name_1 CHECK boolean_expr_1, + ... +) ENGINE = engine +``` + +`boolean_expr_1` می تواند با هر عبارت بولی. اگر قیود برای جدول تعریف شود هر کدام برای هر سطر بررسی خواهند شد `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. + +اضافه کردن مقدار زیادی از محدودیت های منفی می تواند عملکرد بزرگ را تحت تاثیر قرار `INSERT` نمایش داده شد. + +### عبارت دیگر {#ttl-expression} + +تعریف می کند زمان ذخیره سازی برای ارزش. می توان تنها برای ادغام مشخص-جداول خانواده. برای توضیحات دقیق, دیدن [ستون ها و جداول](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). + +### کدکهای فشردهسازی ستون {#codecs} + +به طور پیش فرض, تاتر اعمال `lz4` روش فشرده سازی. برای `MergeTree`- خانواده موتور شما می توانید روش فشرده سازی به طور پیش فرض در تغییر [فشردهسازی](../../operations/server-configuration-parameters/settings.md#server-settings-compression) بخش پیکربندی سرور. شما همچنین می توانید روش فشرده سازی برای هر ستون فردی در تعریف `CREATE TABLE` پرس و جو. + +``` sql +CREATE TABLE codec_example +( + dt Date CODEC(ZSTD), + ts DateTime CODEC(LZ4HC), + float_value Float32 CODEC(NONE), + double_value Float64 CODEC(LZ4HC(9)) + value Float32 CODEC(Delta, ZSTD) +) +ENGINE = +... +``` + +اگر یک کدک مشخص شده است, کدک به طور پیش فرض صدق نمی کند. به عنوان مثال کدک ها را می توان در یک خط لوله ترکیب کرد, `CODEC(Delta, ZSTD)`. برای انتخاب بهترین ترکیب کدک برای شما پروژه معیار شبیه به شرح داده شده در التیت منتقل می کند [کدگذاری های جدید برای بهبود بهره وری کلیک](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) مقاله. + +!!! warning "اخطار" + شما می توانید فایل های پایگاه داده کلیک از حالت فشرده خارج با تاسیسات خارجی مانند `lz4`. بجای, استفاده از ویژه [کلیک کمپرسور](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) سودمند. + +فشرده سازی برای موتورهای جدول زیر پشتیبانی می شود: + +- [ادغام](../../engines/table-engines/mergetree-family/mergetree.md) خانواده پشتیبانی از کدک های فشرده سازی ستون و انتخاب روش فشرده سازی پیش فرض توسط [فشردهسازی](../../operations/server-configuration-parameters/settings.md#server-settings-compression) تنظیمات. +- [ثبت](../../engines/table-engines/log-family/log-family.md) خانواده با استفاده از `lz4` روش فشرده سازی به طور پیش فرض و پشتیبانی از کدک های فشرده سازی ستون. +- [تنظیم](../../engines/table-engines/special/set.md). فقط فشرده سازی پیش فرض پشتیبانی می کند. +- [پیوستن](../../engines/table-engines/special/join.md). فقط فشرده سازی پیش فرض پشتیبانی می کند. + +تاتر با پشتیبانی از کدک های هدف مشترک و کدک های تخصصی. + +#### کدکهای تخصصی {#create-query-specialized-codecs} + +این کدک ها طراحی شده اند تا فشرده سازی را با استفاده از ویژگی های خاص داده ها موثر تر کند. برخی از این کدک ها اطلاعات خود را فشرده سازی نمی کنند. در عوض داده ها را برای یک کدک هدف مشترک تهیه می کنند که بهتر از بدون این دارو را فشرده می کند. + +کدکهای تخصصی: + +- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` برای ذخیره سازی مقادیر دلتا استفاده می شود, بنابراین `delta_bytes` حداکثر اندازه مقادیر خام است. ممکن است `delta_bytes` ارزش: 1, 2, 4, 8. مقدار پیش فرض برای `delta_bytes` هست `sizeof(type)` اگر به برابر 1, 2, 4, یا 8. در تمام موارد دیگر 1 است. +- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [گوریل: سریع, مقیاس پذیر, در حافظه پایگاه داده سری زمان](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [گوریل: سریع, مقیاس پذیر, در حافظه پایگاه داده سری زمان](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` و `DateTime`). در هر مرحله از الگوریتم کدک یک بلوک از ارزش های 64 را می گیرد و به ماتریس بیتی 6464 می رسد و بیت های استفاده نشده ارزش ها را تولید می کند و بقیه را به عنوان یک دنباله باز می گرداند. بیت های استفاده نشده بیت هایی هستند که بین مقادیر حداکثر و حداقل در کل بخش داده ای که فشرده سازی استفاده می شود متفاوت نیستند. + +`DoubleDelta` و `Gorilla` کدک ها در گوریل تسدب به عنوان اجزای الگوریتم فشرده سازی خود استفاده می شود. رویکرد گوریل در سناریوها موثر است زمانی که یک دنباله از ارزش های کم زمان خود را با تغییر دادن زمان وجود دارد. مهر زمانی به طور موثر توسط فشرده `DoubleDelta` کدک و ارزش ها به طور موثر توسط فشرده `Gorilla` وابسته به کدک. مثلا برای دریافت جدول ذخیره شده به طور موثر می توانید در تنظیمات زیر ایجاد کنید: + +``` sql +CREATE TABLE codec_example +( + timestamp DateTime CODEC(DoubleDelta), + slow_values Float32 CODEC(Gorilla) +) +ENGINE = MergeTree() +``` + +#### کدکهای هدف عمومی {#create-query-general-purpose-codecs} + +کدکها: + +- `NONE` — No compression. +- `LZ4` — Lossless [الگوریتم فشرده سازی داده ها](https://github.com/lz4/lz4) به طور پیش فرض استفاده می شود. اعمال فشرده سازی سریع 4. +- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` سطح پیش فرض اعمال می شود. سطوح ممکن: \[1, 12\]. محدوده سطح توصیه شده: \[4, 9\]. +- `ZSTD[(level)]` — [الگوریتم فشرد فشاری](https://en.wikipedia.org/wiki/Zstandard) با قابلیت تنظیم `level`. سطوح ممکن: \[1, 22\]. مقدار پیش فرض: 1. + +سطح فشرده سازی بالا برای حالات نامتقارن مفید هستند, مانند فشرده سازی یک بار, از حالت فشرده خارج بارها و بارها. سطوح بالاتر به معنای فشرده سازی بهتر و استفاده از پردازنده بالاتر است. + +## جداول موقت {#temporary-tables} + +تاتر از جداول موقت که دارای ویژگی های زیر: + +- جداول موقت ناپدید می شوند زمانی که جلسه به پایان می رسد, از جمله اگر اتصال از دست داده است. +- جدول موقت با استفاده از موتور حافظه تنها. +- دسی بل را نمی توان برای یک جدول موقت مشخص شده است. این است که در خارج از پایگاه داده ایجاد شده است. +- غیر ممکن است برای ایجاد یک جدول موقت با پرس و جو توزیع دی ال در تمام سرورهای خوشه (با استفاده از `ON CLUSTER`): این جدول تنها در جلسه فعلی وجود دارد. +- اگر یک جدول موقت است به همین نام به عنوان یکی دیگر و یک پرس و جو نام جدول بدون مشخص دسی بل مشخص, جدول موقت استفاده خواهد شد. +- برای پردازش پرس و جو توزیع, جداول موقت مورد استفاده در یک پرس و جو به سرور از راه دور منتقل. + +برای ایجاد یک جدول موقت از نحو زیر استفاده کنید: + +``` sql +CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) +``` + +در بیشتر موارد, جداول موقت به صورت دستی ایجاد نمی, اما در هنگام استفاده از داده های خارجی برای پرس و جو, و یا برای توزیع `(GLOBAL) IN`. برای کسب اطلاعات بیشتر به بخش های مناسب مراجعه کنید + +امکان استفاده از جداول با [موتور = حافظه](../../engines/table-engines/special/memory.md) به جای جداول موقت. + +## توزیع پرس و جو ددل (در بند خوشه) {#distributed-ddl-queries-on-cluster-clause} + +این `CREATE`, `DROP`, `ALTER` و `RENAME` نمایش داده شد حمایت از اجرای توزیع در یک خوشه. +برای مثال پرس و جو زیر ایجاد می کند `all_hits` `Distributed` جدول در هر میزبان در `cluster`: + +``` sql +CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) +``` + +به منظور اجرای این نمایش داده شد به درستی, هر یک از میزبان باید تعریف خوشه همان (برای ساده سازی تنظیمات همگام سازی, شما می توانید تعویض از باغ وحش استفاده). همچنین باید به سرورهای باغ وحش متصل شوند. +نسخه محلی از پرس و جو در نهایت بر روی هر یک از میزبان در خوشه اجرا می شود, حتی اگر برخی از میزبان در حال حاضر در دسترس نیست. سفارش برای اجرای نمایش داده شد در یک میزبان واحد تضمین شده است. + +## CREATE VIEW {#create-view} + +``` sql +CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... +``` + +ایجاد یک دیدگاه. دو نوع دیدگاه وجود دارد: طبیعی و تحقق. + +نمایش عادی هیچ داده ذخیره نمی, اما فقط انجام خواندن از جدول دیگر. به عبارت دیگر, یک نمایش عادی چیزی بیش از یک پرس و جو ذخیره شده است. هنگام خواندن از نظر, این پرس و جو را نجات داد به عنوان یک خرده فروشی در بند از استفاده. + +به عنوان مثال, فرض کنیم شما یک دیدگاه ایجاد کرده اید: + +``` sql +CREATE VIEW view AS SELECT ... +``` + +و پرس و جو نوشته شده است: + +``` sql +SELECT a, b, c FROM view +``` + +این پرس و جو به طور کامل به استفاده از خرده فروشی معادل است: + +``` sql +SELECT a, b, c FROM (SELECT ...) +``` + +نمایش ها محقق داده فروشگاه تبدیل شده توسط پرس و جو مربوطه را انتخاب کنید. + +هنگام ایجاد یک دیدگاه محقق بدون `TO [db].[table]`, you must specify ENGINE – the table engine for storing data. + +هنگام ایجاد یک دیدگاه محقق با `TO [db].[table]`, شما باید استفاده کنید `POPULATE`. + +مشاهده محقق به شرح زیر مرتب: هنگام قرار دادن داده ها به جدول مشخص شده در انتخاب, بخشی از داده های درج شده است این پرس و جو را انتخاب کنید تبدیل, و در نتیجه در نظر قرار داده. + +اگر شما جمعیت مشخص, داده های جدول موجود در نظر قرار داده در هنگام ایجاد, اگر ساخت یک `CREATE TABLE ... AS SELECT ...` . در غیر این صورت پرس و جو شامل تنها داده های درج شده در جدول پس از ایجاد دیدگاه. ما توصیه نمی کنیم با استفاده از جمعیت, از داده ها در جدول در طول ایجاد مشاهده قرار داده نمی شود. + +A `SELECT` پرسوجو می تواند شامل شود `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Note that the corresponding conversions are performed independently on each block of inserted data. For example, if `GROUP BY` تنظیم شده است, داده ها در طول درج جمع, اما تنها در یک بسته واحد از داده های درج شده. داده ها بیشتر جمع نمی شود. استثنا است که با استفاده از یک موتور است که به طور مستقل انجام تجمع داده ها, مانند `SummingMergeTree`. + +اعدام `ALTER` نمایش داده شد در نمایش محقق شده است به طور کامل توسعه یافته نیست, بنابراین ممکن است ناخوشایند. اگر مشاهده محقق با استفاده از ساخت و ساز `TO [db.]name` شما می توانید `DETACH` منظره, اجرا `ALTER` برای جدول هدف و سپس `ATTACH` قبلا جدا (`DETACH`) نظر . + +نمایش ها نگاه همان جداول عادی. برای مثال در نتیجه ذکر شده است `SHOW TABLES` پرس و جو. + +پرس و جو جداگانه برای حذف نمایش ها وجود ندارد. برای حذف یک نما, استفاده `DROP TABLE`. + +## CREATE DICTIONARY {#create-dictionary-query} + +``` sql +CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] +( + key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + attr1 type2 [DEFAULT|EXPRESSION expr3], + attr2 type2 [DEFAULT|EXPRESSION expr4] +) +PRIMARY KEY key1, key2 +SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) +LAYOUT(LAYOUT_NAME([param_name param_value])) +LIFETIME([MIN val1] MAX val2) +``` + +ایجاد [فرهنگ لغت خارجی](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) با توجه به [ساختار](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md), [متن](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md), [طرحبندی](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md) و [طول عمر](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md). + +ساختار فرهنگ لغت خارجی شامل ویژگی های. ویژگی فرهنگ لغت به طور مشابه به ستون جدول مشخص شده است. تنها ویژگی مورد نیاز ویژگی نوع خود است, تمام خواص دیگر ممکن است مقادیر پیش فرض دارند. + +بسته به فرهنگ لغت [طرحبندی](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md) یک یا چند ویژگی را می توان به عنوان کلید فرهنگ لغت مشخص شده است. + +برای کسب اطلاعات بیشتر, دیدن [واژهنامهها خارجی](../dictionaries/external-dictionaries/external-dicts.md) بخش. + +## CREATE USER {#create-user-statement} + +ایجاد یک [حساب کاربری](../../operations/access-rights.md#user-account-management). + +### نحو {#create-user-syntax} + +``` sql +CREATE USER [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [IDENTIFIED [WITH {NO_PASSWORD|PLAINTEXT_PASSWORD|SHA256_PASSWORD|SHA256_HASH|DOUBLE_SHA1_PASSWORD|DOUBLE_SHA1_HASH}] BY {'password'|'hash'}] + [HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...]] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +#### شناسایی {#identification} + +چندین راه برای شناسایی کاربر وجود دارد: + +- `IDENTIFIED WITH no_password` +- `IDENTIFIED WITH plaintext_password BY 'qwerty'` +- `IDENTIFIED WITH sha256_password BY 'qwerty'` یا `IDENTIFIED BY 'password'` +- `IDENTIFIED WITH sha256_hash BY 'hash'` +- `IDENTIFIED WITH double_sha1_password BY 'qwerty'` +- `IDENTIFIED WITH double_sha1_hash BY 'hash'` + +#### میزبان کاربر {#user-host} + +میزبان کاربر یک میزبان است که می تواند اتصال به سرور کلیک ایجاد شود. میزبان را می توان در `HOST` بخش پرس و جو به روش های زیر: + +- `HOST IP 'ip_address_or_subnetwork'` — User can connect to ClickHouse server only from the specified IP address or a [subnetwork](https://en.wikipedia.org/wiki/Subnetwork). مثالها: `HOST IP '192.168.0.0/16'`, `HOST IP '2001:DB8::/32'`. برای استفاده در تولید فقط مشخص کنید `HOST IP` عناصر (نشانی اینترنتی و ماسک خود را), از زمان استفاده از `host` و `host_regexp` ممکن است تاخیر اضافی شود. +- `HOST ANY` — User can connect from any location. This is default option. +- `HOST LOCAL` — User can connect only locally. +- `HOST NAME 'fqdn'` — User host can be specified as FQDN. For example, `HOST NAME 'mysite.com'`. +- `HOST NAME REGEXP 'regexp'` — You can use [pcre](http://www.pcre.org/) عبارات منظم در هنگام مشخص میزبان کاربر. به عنوان مثال, `HOST NAME REGEXP '.*\.mysite\.com'`. +- `HOST LIKE 'template'` — Allows you use the [LIKE](../functions/string-search-functions.md#function-like) اپراتور برای فیلتر کردن میزبان کاربر. به عنوان مثال, `HOST LIKE '%'` معادل است `HOST ANY`, `HOST LIKE '%.mysite.com'` فیلتر تمام میزبان در `mysite.com` دامنه. + +یکی دیگر از راه تعیین میزبان استفاده است `@` نحو با نام کاربر. مثالها: + +- `CREATE USER mira@'127.0.0.1'` — Equivalent to the `HOST IP` نحو. +- `CREATE USER mira@'localhost'` — Equivalent to the `HOST LOCAL` نحو. +- `CREATE USER mira@'192.168.%.%'` — Equivalent to the `HOST LIKE` نحو. + +!!! info "اخطار" + درمان کلیک `user_name@'address'` به عنوان یک نام کاربری به عنوان یک کل. بدین ترتیب, از لحاظ فنی شما می توانید چند کاربر با ایجاد `user_name` و سازه های مختلف پس از `@`. ما توصیه به انجام این کار. + +### مثالها {#create-user-examples} + +ایجاد حساب کاربری `mira` حفاظت شده توسط رمز عبور `qwerty`: + +``` sql +CREATE USER mira HOST IP '127.0.0.1' IDENTIFIED WITH sha256_password BY 'qwerty' +``` + +`mira` باید برنامه مشتری در میزبان که سرور کلیک اجرا می شود شروع می شود. + +ایجاد حساب کاربری `john` نقش ها را به طور پیش فرض اختصاص دهید و این نقش ها را پیش فرض کنید: + +``` sql +CREATE USER john DEFAULT ROLE role1, role2 +``` + +ایجاد حساب کاربری `john` و همه نقش های بعدی خود را به طور پیش فرض: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +هنگامی که برخی از نقش اختصاص داده خواهد شد به `john` در اینده این تبدیل خواهد شد به طور پیش فرض به طور خودکار. + +ایجاد حساب کاربری `john` و همه نقش های بعدی خود را به استثنای پیش فرض `role1` و `role2`: + +``` sql +ALTER USER john DEFAULT ROLE ALL EXCEPT role1, role2 +``` + +## CREATE ROLE {#create-role-statement} + +ایجاد یک [نقش](../../operations/access-rights.md#role-management). + +### نحو {#create-role-syntax} + +``` sql +CREATE ROLE [IF NOT EXISTS | OR REPLACE] name + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### توصیف {#create-role-description} + +نقش مجموعه ای از [امتیازات](grant.md#grant-privileges). کاربر اعطا شده با نقش می شود تمام امتیازات این نقش. + +کاربر را می توان با نقش های متعدد اختصاص داده است. کاربران می توانند نقش اعطا خود را در ترکیب دلخواه توسط اعمال [SET ROLE](misc.md#set-role-statement) بیانیه. دامنه نهایی امتیازات مجموعه ای ترکیبی از تمام امتیازات تمام نقش های کاربردی است. اگر یک کاربر امتیازات اعطا شده به طور مستقیم به حساب کاربری نیز با امتیازات اعطا شده توسط نقش ترکیب شده است. + +کاربر می تواند نقش پیش فرض که در ورود کاربر اعمال می شود. برای تنظیم نقش های پیش فرض از [SET DEFAULT ROLE](misc.md#set-default-role-statement) بیانیه یا [ALTER USER](alter.md#alter-user-statement) بیانیه. + +برای لغو نقش از [REVOKE](revoke.md) بیانیه. + +برای حذف نقش از [DROP ROLE](misc.md#drop-role-statement) بیانیه. نقش حذف شده به طور خودکار از تمام کاربران و نقش هایی که اعطا شد لغو می شود. + +### مثالها {#create-role-examples} + +``` sql +CREATE ROLE accountant; +GRANT SELECT ON db.* TO accountant; +``` + +این دنباله ای از نمایش داده شد نقش ایجاد می کند `accountant` که دارای امتیاز از خواندن داده ها از `accounting` بانک اطلاعات. + +اعطای نقش به کاربر `mira`: + +``` sql +GRANT accountant TO mira; +``` + +کاربر پس از این نقش اعطا می تواند استفاده و انجام نمایش داده شد مجاز است. به عنوان مثال: + +``` sql +SET ROLE accountant; +SELECT * FROM db.*; +``` + +## CREATE ROW POLICY {#create-row-policy-statement} + +ایجاد یک [پالایه برای سطرها](../../operations/access-rights.md#row-policy-management), که یک کاربر می تواند از یک جدول به عنوان خوانده شده. + +### نحو {#create-row-policy-syntax} + +``` sql +CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE] policy_name [ON CLUSTER cluster_name] ON [db.]table + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING condition] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +#### بخش به عنوان {#create-row-policy-as} + +با استفاده از این بخش شما می توانید سیاست های مجاز و یا محدود ایجاد کنید. + +سیاست مجاز دسترسی به ردیف کمک های مالی. سیاست های مجاز که به همان جدول اعمال می شود با هم با استفاده از بولی ترکیب `OR` اپراتور سیاست های مجاز به طور پیش فرض. + +سیاست محدود کننده دسترسی به ردیف محدود می کند. سیاست های محدود که به همان جدول اعمال می شود با هم با استفاده از بولی ترکیب شده است `AND` اپراتور + +سیاست های محدود به ردیف که فیلترهای مجاز گذشت اعمال می شود. اگر شما در تنظیم سیاست های محدود اما هیچ سیاست مجاز کاربر هر سطر از جدول می توانید. + +#### بخش به {#create-row-policy-to} + +در بخش `TO` شما می توانید یک لیست ترکیبی از نقش ها و کاربران را, مثلا, `CREATE ROW POLICY ... TO accountant, john@localhost`. + +کلیدواژه `ALL` به معنی تمام کاربران کلیک از جمله کاربر فعلی. کلیدواژهها `ALL EXCEPT` اجازه می دهد به حذف برخی از کاربران از لیست تمام کاربران به عنوان مثال `CREATE ROW POLICY ... TO ALL EXCEPT accountant, john@localhost` + +### مثالها {#examples} + +- `CREATE ROW POLICY filter ON mydb.mytable FOR SELECT USING a<1000 TO accountant, john@localhost` +- `CREATE ROW POLICY filter ON mydb.mytable FOR SELECT USING a<1000 TO ALL EXCEPT mira` + +## CREATE QUOTA {#create-quota-statement} + +ایجاد یک [سهمیه](../../operations/access-rights.md#quotas-management) این را می توان به یک کاربر یا نقش اختصاص داد. + +### نحو {#create-quota-syntax} + +``` sql +CREATE QUOTA [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +### مثال {#create-quota-example} + +محدود کردن حداکثر تعداد نمایش داده شد برای کاربر فعلی با 123 نمایش داده شد در 15 ماه محدودیت: + +``` sql +CREATE QUOTA qA FOR INTERVAL 15 MONTH MAX QUERIES 123 TO CURRENT_USER +``` + +## CREATE SETTINGS PROFILE {#create-settings-profile-statement} + +ایجاد یک [تنظیمات](../../operations/access-rights.md#settings-profiles-management) این را می توان به یک کاربر یا نقش اختصاص داد. + +### نحو {#create-settings-profile-syntax} + +``` sql +CREATE SETTINGS PROFILE [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + +# مثال {#create-settings-profile-syntax} + +ایجاد `max_memory_usage_profile` مشخصات تنظیمات با ارزش و محدودیت برای `max_memory_usage` تنظیمات. انتساب به `robin`: + +``` sql +CREATE SETTINGS PROFILE max_memory_usage_profile SETTINGS max_memory_usage = 100000001 MIN 90000000 MAX 110000000 TO robin +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/create/) diff --git a/docs/fa/sql-reference/statements/grant.md b/docs/fa/sql-reference/statements/grant.md new file mode 100644 index 00000000000..fd0274ea892 --- /dev/null +++ b/docs/fa/sql-reference/statements/grant.md @@ -0,0 +1,476 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: GRANT +--- + +# GRANT {#grant} + +- کمک های مالی [امتیازات](#grant-privileges) به حساب کاربر کلیک و یا نقش. +- اختصاص نقش به حساب های کاربری و یا به نقش های دیگر. + +برای لغو امتیازات از [REVOKE](revoke.md) بیانیه. همچنین شما می توانید لیست امتیازات اعطا شده توسط [SHOW GRANTS](show.md#show-grants-statement) بیانیه. + +## اعطای نحو امتیاز {#grant-privigele-syntax} + +``` sql +GRANT [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*} TO {user | role | CURRENT_USER} [,...] [WITH GRANT OPTION] +``` + +- `privilege` — Type of privilege. +- `role` — ClickHouse user role. +- `user` — ClickHouse user account. + +این `WITH GRANT OPTION` کمک های مالی بند `user` یا `role` با اجازه به انجام `GRANT` پرس و جو. کاربران می توانند امتیازات از همان دامنه دارند و کمتر اعطا. + +## اعطای نحو نقش {#assign-role-syntax} + +``` sql +GRANT [ON CLUSTER cluster_name] role [,...] TO {user | another_role | CURRENT_USER} [,...] [WITH ADMIN OPTION] +``` + +- `role` — ClickHouse user role. +- `user` — ClickHouse user account. + +این `WITH ADMIN OPTION` مجموعه بند [ADMIN OPTION](#admin-option-privilege) امتیاز برای `user` یا `role`. + +## استفاده {#grant-usage} + +برای استفاده `GRANT` حساب شما باید `GRANT OPTION` امتیاز. شما می توانید امتیازات تنها در داخل دامنه امتیازات حساب خود را اعطا. + +مثلا, مدیر امتیازات به اعطا کرده است `john` حساب توسط پرس و جو: + +``` sql +GRANT SELECT(x,y) ON db.table TO john WITH GRANT OPTION +``` + +این بدان معنی است که `john` دارای مجوز برای انجام: + +- `SELECT x,y FROM db.table`. +- `SELECT x FROM db.table`. +- `SELECT y FROM db.table`. + +`john` نمی تواند انجام دهد `SELECT z FROM db.table`. این `SELECT * FROM db.table` همچنین در دسترس نیست. پردازش این پرس و جو, تاتر هیچ داده بازگشت نیست, حتی `x` و `y`. تنها استثنا است اگر یک جدول شامل تنها `x` و `y` ستون, در این مورد کلیکهاوس را برمی گرداند تمام داده ها. + +همچنین `john` دارد `GRANT OPTION` امتیاز, بنابراین می تواند کاربران دیگر با امتیازات از همان و یا دامنه کوچکتر اعطا. + +مشخص امتیازات شما می توانید ستاره استفاده کنید (`*`) به جای یک جدول و یا یک نام پایگاه داده. برای مثال `GRANT SELECT ON db.* TO john` پرسوجو اجازه میدهد `john` برای انجام `SELECT` پرس و جو بیش از همه جداول در `db` بانک اطلاعات. همچنین می توانید نام پایگاه داده را حذف کنید. برای مثال در این مورد امتیازات برای پایگاه داده فعلی اعطا می شود: `GRANT SELECT ON * TO john` اعطا امتیاز در تمام جداول در پایگاه داده فعلی, `GRANT SELECT ON mytable TO john` اعطا امتیاز در `mytable` جدول در پایگاه داده فعلی. + +دسترسی به `system` پایگاه داده همیشه مجاز (از این پایگاه داده برای پردازش نمایش داده شد استفاده می شود). + +شما می توانید امتیازات متعدد به حساب های متعدد در یک پرس و جو عطا کند. پرسوجو `GRANT SELECT, INSERT ON *.* TO john, robin` اجازه می دهد تا حساب `john` و `robin` برای انجام `INSERT` و `SELECT` نمایش داده شد بیش از همه جداول در تمام پایگاه داده بر روی سرور. + +## امتیازات {#grant-privileges} + +امتیاز اجازه به انجام نوع خاصی از نمایش داده شد است. + +امتیازات یک ساختار سلسله مراتبی. مجموعه ای از نمایش داده شد مجاز بستگی به دامنه امتیاز. + +سلسله مراتب امتیازات: + +- [SELECT](#grant-select) +- [INSERT](#grant-insert) +- [ALTER](#grant-alter) + - `ALTER TABLE` + - `ALTER UPDATE` + - `ALTER DELETE` + - `ALTER COLUMN` + - `ALTER ADD COLUMN` + - `ALTER DROP COLUMN` + - `ALTER MODIFY COLUMN` + - `ALTER COMMENT COLUMN` + - `ALTER CLEAR COLUMN` + - `ALTER RENAME COLUMN` + - `ALTER INDEX` + - `ALTER ORDER BY` + - `ALTER ADD INDEX` + - `ALTER DROP INDEX` + - `ALTER MATERIALIZE INDEX` + - `ALTER CLEAR INDEX` + - `ALTER CONSTRAINT` + - `ALTER ADD CONSTRAINT` + - `ALTER DROP CONSTRAINT` + - `ALTER TTL` + - `ALTER MATERIALIZE TTL` + - `ALTER SETTINGS` + - `ALTER MOVE PARTITION` + - `ALTER FETCH PARTITION` + - `ALTER FREEZE PARTITION` + - `ALTER VIEW` + - `ALTER VIEW REFRESH` + - `ALTER VIEW MODIFY QUERY` +- [CREATE](#grant-create) + - `CREATE DATABASE` + - `CREATE TABLE` + - `CREATE VIEW` + - `CREATE DICTIONARY` + - `CREATE TEMPORARY TABLE` +- [DROP](#grant-drop) + - `DROP DATABASE` + - `DROP TABLE` + - `DROP VIEW` + - `DROP DICTIONARY` +- [TRUNCATE](#grant-truncate) +- [OPTIMIZE](#grant-optimize) +- [SHOW](#grant-show) + - `SHOW DATABASES` + - `SHOW TABLES` + - `SHOW COLUMNS` + - `SHOW DICTIONARIES` +- [KILL QUERY](#grant-kill-query) +- [ACCESS MANAGEMENT](#grant-access-management) + - `CREATE USER` + - `ALTER USER` + - `DROP USER` + - `CREATE ROLE` + - `ALTER ROLE` + - `DROP ROLE` + - `CREATE ROW POLICY` + - `ALTER ROW POLICY` + - `DROP ROW POLICY` + - `CREATE QUOTA` + - `ALTER QUOTA` + - `DROP QUOTA` + - `CREATE SETTINGS PROFILE` + - `ALTER SETTINGS PROFILE` + - `DROP SETTINGS PROFILE` + - `SHOW ACCESS` + - `SHOW_USERS` + - `SHOW_ROLES` + - `SHOW_ROW_POLICIES` + - `SHOW_QUOTAS` + - `SHOW_SETTINGS_PROFILES` + - `ROLE ADMIN` +- [SYSTEM](#grant-system) + - `SYSTEM SHUTDOWN` + - `SYSTEM DROP CACHE` + - `SYSTEM DROP DNS CACHE` + - `SYSTEM DROP MARK CACHE` + - `SYSTEM DROP UNCOMPRESSED CACHE` + - `SYSTEM RELOAD` + - `SYSTEM RELOAD CONFIG` + - `SYSTEM RELOAD DICTIONARY` + - `SYSTEM RELOAD EMBEDDED DICTIONARIES` + - `SYSTEM MERGES` + - `SYSTEM TTL MERGES` + - `SYSTEM FETCHES` + - `SYSTEM MOVES` + - `SYSTEM SENDS` + - `SYSTEM DISTRIBUTED SENDS` + - `SYSTEM REPLICATED SENDS` + - `SYSTEM REPLICATION QUEUES` + - `SYSTEM SYNC REPLICA` + - `SYSTEM RESTART REPLICA` + - `SYSTEM FLUSH` + - `SYSTEM FLUSH DISTRIBUTED` + - `SYSTEM FLUSH LOGS` +- [INTROSPECTION](#grant-introspection) + - `addressToLine` + - `addressToSymbol` + - `demangle` +- [SOURCES](#grant-sources) + - `FILE` + - `URL` + - `REMOTE` + - `YSQL` + - `ODBC` + - `JDBC` + - `HDFS` + - `S3` +- [دیکته کردن](#grant-dictget) + +نمونه هایی از چگونه این سلسله مراتب درمان می شود: + +- این `ALTER` امتیاز شامل تمام دیگر `ALTER*` امتیازات. +- `ALTER CONSTRAINT` شامل `ALTER ADD CONSTRAINT` و `ALTER DROP CONSTRAINT` امتیازات. + +امتیازات در سطوح مختلف اعمال می شود. دانستن یک سطح نشان می دهد نحو در دسترس برای امتیاز. + +سطح (از پایین به بالاتر): + +- `COLUMN` — Privilege can be granted for column, table, database, or globally. +- `TABLE` — Privilege can be granted for table, database, or globally. +- `VIEW` — Privilege can be granted for view, database, or globally. +- `DICTIONARY` — Privilege can be granted for dictionary, database, or globally. +- `DATABASE` — Privilege can be granted for database or globally. +- `GLOBAL` — Privilege can be granted only globally. +- `GROUP` — Groups privileges of different levels. When `GROUP`- امتیاز سطح اعطا شده است, تنها که امتیازات از گروه اعطا که به نحو استفاده مطابقت. + +نمونه هایی از نحو مجاز: + +- `GRANT SELECT(x) ON db.table TO user` +- `GRANT SELECT ON db.* TO user` + +نمونه هایی از نحو غیر مجاز: + +- `GRANT CREATE USER(x) ON db.table TO user` +- `GRANT CREATE USER ON db.* TO user` + +امتیاز ویژه [ALL](#grant-all) اعطا تمام امتیازات به یک حساب کاربری و یا نقش. + +به طور پیش فرض, یک حساب کاربری و یا نقش هیچ امتیازات. + +اگر یک کاربر یا نقش هیچ امتیاز به عنوان نمایش داده می شود [NONE](#grant-none) امتیاز. + +برخی از نمایش داده شد با اجرای خود نیاز به مجموعه ای از امتیازات. برای مثال برای انجام [RENAME](misc.md#misc_operations-rename) پرس و جو شما نیاز به امتیازات زیر: `SELECT`, `CREATE TABLE`, `INSERT` و `DROP TABLE`. + +### SELECT {#grant-select} + +اجازه می دهد تا برای انجام [SELECT](select/index.md) نمایش داده شد. + +سطح امتیاز: `COLUMN`. + +**توصیف** + +کاربر اعطا شده با این امتیاز می تواند انجام دهد `SELECT` نمایش داده شد بیش از یک لیست مشخص از ستون ها در جدول و پایگاه داده مشخص شده است. اگر کاربر شامل ستون های دیگر و سپس مشخص پرس و جو هیچ داده گرداند. + +امتیاز زیر را در نظر بگیرید: + +``` sql +GRANT SELECT(x,y) ON db.table TO john +``` + +این امتیاز اجازه می دهد `john` برای انجام هر `SELECT` پرس و جو که شامل داده ها از `x` و / یا `y` ستونها در `db.table`. به عنوان مثال, `SELECT x FROM db.table`. `john` نمی تواند انجام دهد `SELECT z FROM db.table`. این `SELECT * FROM db.table` همچنین در دسترس نیست. پردازش این پرس و جو, تاتر هیچ داده بازگشت نیست, حتی `x` و `y`. تنها استثنا است اگر یک جدول شامل تنها `x` و `y` ستون, در این مورد کلیکهاوس را برمی گرداند تمام داده ها. + +### INSERT {#grant-insert} + +اجازه می دهد تا انجام [INSERT](insert-into.md) نمایش داده شد. + +سطح امتیاز: `COLUMN`. + +**توصیف** + +کاربر اعطا شده با این امتیاز می تواند انجام دهد `INSERT` نمایش داده شد بیش از یک لیست مشخص از ستون ها در جدول و پایگاه داده مشخص شده است. اگر کاربر شامل ستون های دیگر و سپس مشخص پرس و جو هیچ داده وارد کنید. + +**مثال** + +``` sql +GRANT INSERT(x,y) ON db.table TO john +``` + +امتیاز اعطا شده اجازه می دهد `john` برای وارد کردن داده ها به `x` و / یا `y` ستونها در `db.table`. + +### ALTER {#grant-alter} + +اجازه می دهد تا انجام [ALTER](alter.md) نمایش داده شد مربوط به سلسله مراتب زیر از امتیازات: + +- `ALTER`. سطح: `COLUMN`. + - `ALTER TABLE`. سطح: `GROUP` + - `ALTER UPDATE`. سطح: `COLUMN`. نامگردانها: `UPDATE` + - `ALTER DELETE`. سطح: `COLUMN`. نامگردانها: `DELETE` + - `ALTER COLUMN`. سطح: `GROUP` + - `ALTER ADD COLUMN`. سطح: `COLUMN`. نامگردانها: `ADD COLUMN` + - `ALTER DROP COLUMN`. سطح: `COLUMN`. نامگردانها: `DROP COLUMN` + - `ALTER MODIFY COLUMN`. سطح: `COLUMN`. نامگردانها: `MODIFY COLUMN` + - `ALTER COMMENT COLUMN`. سطح: `COLUMN`. نامگردانها: `COMMENT COLUMN` + - `ALTER CLEAR COLUMN`. سطح: `COLUMN`. نامگردانها: `CLEAR COLUMN` + - `ALTER RENAME COLUMN`. سطح: `COLUMN`. نامگردانها: `RENAME COLUMN` + - `ALTER INDEX`. سطح: `GROUP`. نامگردانها: `INDEX` + - `ALTER ORDER BY`. سطح: `TABLE`. نامگردانها: `ALTER MODIFY ORDER BY`, `MODIFY ORDER BY` + - `ALTER ADD INDEX`. سطح: `TABLE`. نامگردانها: `ADD INDEX` + - `ALTER DROP INDEX`. سطح: `TABLE`. نامگردانها: `DROP INDEX` + - `ALTER MATERIALIZE INDEX`. سطح: `TABLE`. نامگردانها: `MATERIALIZE INDEX` + - `ALTER CLEAR INDEX`. سطح: `TABLE`. نامگردانها: `CLEAR INDEX` + - `ALTER CONSTRAINT`. سطح: `GROUP`. نامگردانها: `CONSTRAINT` + - `ALTER ADD CONSTRAINT`. سطح: `TABLE`. نامگردانها: `ADD CONSTRAINT` + - `ALTER DROP CONSTRAINT`. سطح: `TABLE`. نامگردانها: `DROP CONSTRAINT` + - `ALTER TTL`. سطح: `TABLE`. نامگردانها: `ALTER MODIFY TTL`, `MODIFY TTL` + - `ALTER MATERIALIZE TTL`. سطح: `TABLE`. نامگردانها: `MATERIALIZE TTL` + - `ALTER SETTINGS`. سطح: `TABLE`. نامگردانها: `ALTER SETTING`, `ALTER MODIFY SETTING`, `MODIFY SETTING` + - `ALTER MOVE PARTITION`. سطح: `TABLE`. نامگردانها: `ALTER MOVE PART`, `MOVE PARTITION`, `MOVE PART` + - `ALTER FETCH PARTITION`. سطح: `TABLE`. نامگردانها: `FETCH PARTITION` + - `ALTER FREEZE PARTITION`. سطح: `TABLE`. نامگردانها: `FREEZE PARTITION` + - `ALTER VIEW` سطح: `GROUP` + - `ALTER VIEW REFRESH`. سطح: `VIEW`. نامگردانها: `ALTER LIVE VIEW REFRESH`, `REFRESH VIEW` + - `ALTER VIEW MODIFY QUERY`. سطح: `VIEW`. نامگردانها: `ALTER TABLE MODIFY QUERY` + +نمونه هایی از چگونه این سلسله مراتب درمان می شود: + +- این `ALTER` امتیاز شامل تمام دیگر `ALTER*` امتیازات. +- `ALTER CONSTRAINT` شامل `ALTER ADD CONSTRAINT` و `ALTER DROP CONSTRAINT` امتیازات. + +**یادداشتها** + +- این `MODIFY SETTING` امتیاز اجازه می دهد تا برای تغییر تنظیمات موتور جدول. در تنظیمات و یا پارامترهای پیکربندی سرور تاثیر نمی گذارد. +- این `ATTACH` عملیات نیاز دارد [CREATE](#grant-create) امتیاز. +- این `DETACH` عملیات نیاز دارد [DROP](#grant-drop) امتیاز. +- برای جلوگیری از جهش توسط [KILL MUTATION](misc.md#kill-mutation) پرس و جو, شما نیاز به یک امتیاز برای شروع این جهش. مثلا, اگر شما می خواهید برای جلوگیری از `ALTER UPDATE` پرس و جو, شما نیاز به `ALTER UPDATE`, `ALTER TABLE` یا `ALTER` امتیاز. + +### CREATE {#grant-create} + +اجازه می دهد تا برای انجام [CREATE](create.md) و [ATTACH](misc.md#attach) دی ال-پرس و جو مربوط به سلسله مراتب زیر از امتیازات: + +- `CREATE`. سطح: `GROUP` + - `CREATE DATABASE`. سطح: `DATABASE` + - `CREATE TABLE`. سطح: `TABLE` + - `CREATE VIEW`. سطح: `VIEW` + - `CREATE DICTIONARY`. سطح: `DICTIONARY` + - `CREATE TEMPORARY TABLE`. سطح: `GLOBAL` + +**یادداشتها** + +- برای حذف جدول ایجاد شده نیاز کاربر [DROP](#grant-drop). + +### DROP {#grant-drop} + +اجازه می دهد تا برای انجام [DROP](misc.md#drop) و [DETACH](misc.md#detach) نمایش داده شد مربوط به سلسله مراتب زیر از امتیازات: + +- `DROP`. سطح: + - `DROP DATABASE`. سطح: `DATABASE` + - `DROP TABLE`. سطح: `TABLE` + - `DROP VIEW`. سطح: `VIEW` + - `DROP DICTIONARY`. سطح: `DICTIONARY` + +### TRUNCATE {#grant-truncate} + +اجازه می دهد تا برای انجام [TRUNCATE](misc.md#truncate-statement) نمایش داده شد. + +سطح امتیاز: `TABLE`. + +### OPTIMIZE {#grant-optimize} + +اجازه می دهد تا برای انجام [OPTIMIZE TABLE](misc.md#misc_operations-optimize) نمایش داده شد. + +سطح امتیاز: `TABLE`. + +### SHOW {#grant-show} + +اجازه می دهد تا برای انجام `SHOW`, `DESCRIBE`, `USE` و `EXISTS` نمایش داده شد, مربوط به سلسله مراتب زیر از امتیازات: + +- `SHOW`. سطح: `GROUP` + - `SHOW DATABASES`. سطح: `DATABASE`. اجازه می دهد تا برای اجرای `SHOW DATABASES`, `SHOW CREATE DATABASE`, `USE ` نمایش داده شد. + - `SHOW TABLES`. سطح: `TABLE`. اجازه می دهد تا برای اجرای `SHOW TABLES`, `EXISTS `, `CHECK
` نمایش داده شد. + - `SHOW COLUMNS`. سطح: `COLUMN`. اجازه می دهد تا برای اجرای `SHOW CREATE TABLE`, `DESCRIBE` نمایش داده شد. + - `SHOW DICTIONARIES`. سطح: `DICTIONARY`. اجازه می دهد تا برای اجرای `SHOW DICTIONARIES`, `SHOW CREATE DICTIONARY`, `EXISTS ` نمایش داده شد. + +**یادداشتها** + +یک کاربر است `SHOW` امتیاز اگر هر امتیاز دیگری در مورد جدول مشخص, فرهنگ لغت و یا پایگاه داده. + +### KILL QUERY {#grant-kill-query} + +اجازه می دهد تا برای انجام [KILL](misc.md#kill-query-statement) نمایش داده شد مربوط به سلسله مراتب زیر از امتیازات: + +سطح امتیاز: `GLOBAL`. + +**یادداشتها** + +`KILL QUERY` امتیاز اجازه می دهد تا یک کاربر برای کشتن نمایش داده شد از کاربران دیگر. + +### ACCESS MANAGEMENT {#grant-access-management} + +اجازه می دهد تا کاربر را به انجام نمایش داده شد که مدیریت کاربران, نقش ها و سیاست های ردیف. + +- `ACCESS MANAGEMENT`. سطح: `GROUP` + - `CREATE USER`. سطح: `GLOBAL` + - `ALTER USER`. سطح: `GLOBAL` + - `DROP USER`. سطح: `GLOBAL` + - `CREATE ROLE`. سطح: `GLOBAL` + - `ALTER ROLE`. سطح: `GLOBAL` + - `DROP ROLE`. سطح: `GLOBAL` + - `ROLE ADMIN`. سطح: `GLOBAL` + - `CREATE ROW POLICY`. سطح: `GLOBAL`. نامگردانها: `CREATE POLICY` + - `ALTER ROW POLICY`. سطح: `GLOBAL`. نامگردانها: `ALTER POLICY` + - `DROP ROW POLICY`. سطح: `GLOBAL`. نامگردانها: `DROP POLICY` + - `CREATE QUOTA`. سطح: `GLOBAL` + - `ALTER QUOTA`. سطح: `GLOBAL` + - `DROP QUOTA`. سطح: `GLOBAL` + - `CREATE SETTINGS PROFILE`. سطح: `GLOBAL`. نامگردانها: `CREATE PROFILE` + - `ALTER SETTINGS PROFILE`. سطح: `GLOBAL`. نامگردانها: `ALTER PROFILE` + - `DROP SETTINGS PROFILE`. سطح: `GLOBAL`. نامگردانها: `DROP PROFILE` + - `SHOW ACCESS`. سطح: `GROUP` + - `SHOW_USERS`. سطح: `GLOBAL`. نامگردانها: `SHOW CREATE USER` + - `SHOW_ROLES`. سطح: `GLOBAL`. نامگردانها: `SHOW CREATE ROLE` + - `SHOW_ROW_POLICIES`. سطح: `GLOBAL`. نامگردانها: `SHOW POLICIES`, `SHOW CREATE ROW POLICY`, `SHOW CREATE POLICY` + - `SHOW_QUOTAS`. سطح: `GLOBAL`. نامگردانها: `SHOW CREATE QUOTA` + - `SHOW_SETTINGS_PROFILES`. سطح: `GLOBAL`. نامگردانها: `SHOW PROFILES`, `SHOW CREATE SETTINGS PROFILE`, `SHOW CREATE PROFILE` + +این `ROLE ADMIN` امتیاز اجازه می دهد تا کاربر را به اعطای و لغو هر نقش از جمله کسانی که به کاربر با گزینه مدیریت داده نمی شود. + +### SYSTEM {#grant-system} + +اجازه می دهد تا کاربر را به انجام [SYSTEM](system.md) نمایش داده شد مربوط به سلسله مراتب زیر از امتیازات. + +- `SYSTEM`. سطح: `GROUP` + - `SYSTEM SHUTDOWN`. سطح: `GLOBAL`. نامگردانها: `SYSTEM KILL`, `SHUTDOWN` + - `SYSTEM DROP CACHE`. نامگردانها: `DROP CACHE` + - `SYSTEM DROP DNS CACHE`. سطح: `GLOBAL`. نامگردانها: `SYSTEM DROP DNS`, `DROP DNS CACHE`, `DROP DNS` + - `SYSTEM DROP MARK CACHE`. سطح: `GLOBAL`. نامگردانها: `SYSTEM DROP MARK`, `DROP MARK CACHE`, `DROP MARKS` + - `SYSTEM DROP UNCOMPRESSED CACHE`. سطح: `GLOBAL`. نامگردانها: `SYSTEM DROP UNCOMPRESSED`, `DROP UNCOMPRESSED CACHE`, `DROP UNCOMPRESSED` + - `SYSTEM RELOAD`. سطح: `GROUP` + - `SYSTEM RELOAD CONFIG`. سطح: `GLOBAL`. نامگردانها: `RELOAD CONFIG` + - `SYSTEM RELOAD DICTIONARY`. سطح: `GLOBAL`. نامگردانها: `SYSTEM RELOAD DICTIONARIES`, `RELOAD DICTIONARY`, `RELOAD DICTIONARIES` + - `SYSTEM RELOAD EMBEDDED DICTIONARIES`. سطح: `GLOBAL`. نامگردانها: تحقیق`ELOAD EMBEDDED DICTIONARIES` + - `SYSTEM MERGES`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP MERGES`, `SYSTEM START MERGES`, `STOP MERGES`, `START MERGES` + - `SYSTEM TTL MERGES`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP TTL MERGES`, `SYSTEM START TTL MERGES`, `STOP TTL MERGES`, `START TTL MERGES` + - `SYSTEM FETCHES`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP FETCHES`, `SYSTEM START FETCHES`, `STOP FETCHES`, `START FETCHES` + - `SYSTEM MOVES`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP MOVES`, `SYSTEM START MOVES`, `STOP MOVES`, `START MOVES` + - `SYSTEM SENDS`. سطح: `GROUP`. نامگردانها: `SYSTEM STOP SENDS`, `SYSTEM START SENDS`, `STOP SENDS`, `START SENDS` + - `SYSTEM DISTRIBUTED SENDS`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP DISTRIBUTED SENDS`, `SYSTEM START DISTRIBUTED SENDS`, `STOP DISTRIBUTED SENDS`, `START DISTRIBUTED SENDS` + - `SYSTEM REPLICATED SENDS`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP REPLICATED SENDS`, `SYSTEM START REPLICATED SENDS`, `STOP REPLICATED SENDS`, `START REPLICATED SENDS` + - `SYSTEM REPLICATION QUEUES`. سطح: `TABLE`. نامگردانها: `SYSTEM STOP REPLICATION QUEUES`, `SYSTEM START REPLICATION QUEUES`, `STOP REPLICATION QUEUES`, `START REPLICATION QUEUES` + - `SYSTEM SYNC REPLICA`. سطح: `TABLE`. نامگردانها: `SYNC REPLICA` + - `SYSTEM RESTART REPLICA`. سطح: `TABLE`. نامگردانها: `RESTART REPLICA` + - `SYSTEM FLUSH`. سطح: `GROUP` + - `SYSTEM FLUSH DISTRIBUTED`. سطح: `TABLE`. نامگردانها: `FLUSH DISTRIBUTED` + - `SYSTEM FLUSH LOGS`. سطح: `GLOBAL`. نامگردانها: `FLUSH LOGS` + +این `SYSTEM RELOAD EMBEDDED DICTIONARIES` امتیاز به طور ضمنی توسط اعطا `SYSTEM RELOAD DICTIONARY ON *.*` امتیاز. + +### INTROSPECTION {#grant-introspection} + +اجازه می دهد تا با استفاده از [درون نگری](../../operations/optimizing-performance/sampling-query-profiler.md) توابع. + +- `INTROSPECTION`. سطح: `GROUP`. نامگردانها: `INTROSPECTION FUNCTIONS` + - `addressToLine`. سطح: `GLOBAL` + - `addressToSymbol`. سطح: `GLOBAL` + - `demangle`. سطح: `GLOBAL` + +### SOURCES {#grant-sources} + +اجازه می دهد تا با استفاده از منابع داده های خارجی. امر به [موتورهای جدول](../../engines/table-engines/index.md) و [توابع جدول](../table-functions/index.md#table-functions). + +- `SOURCES`. سطح: `GROUP` + - `FILE`. سطح: `GLOBAL` + - `URL`. سطح: `GLOBAL` + - `REMOTE`. سطح: `GLOBAL` + - `YSQL`. سطح: `GLOBAL` + - `ODBC`. سطح: `GLOBAL` + - `JDBC`. سطح: `GLOBAL` + - `HDFS`. سطح: `GLOBAL` + - `S3`. سطح: `GLOBAL` + +این `SOURCES` امتیاز را قادر می سازد استفاده از تمام منابع. همچنین شما می توانید یک امتیاز برای هر منبع به صورت جداگانه اعطا. برای استفاده از منابع, شما نیاز به امتیازات اضافی. + +مثالها: + +- برای ایجاد یک جدول با [خروجی زیر موتور جدول](../../engines/table-engines/integrations/mysql.md) شما نیاز دارید `CREATE TABLE (ON db.table_name)` و `MYSQL` امتیازات. +- برای استفاده از [تابع جدول خروجی زیر](../table-functions/mysql.md) شما نیاز دارید `CREATE TEMPORARY TABLE` و `MYSQL` امتیازات. + +### دیکته کردن {#grant-dictget} + +- `dictGet`. نامگردانها: `dictHas`, `dictGetHierarchy`, `dictIsIn` + +اجازه می دهد تا کاربر را به اجرا [دیکته کردن](../functions/ext-dict-functions.md#dictget), [دیکتس](../functions/ext-dict-functions.md#dicthas), [حکومت دیکتاتوری](../functions/ext-dict-functions.md#dictgethierarchy), [دیکتاتوری](../functions/ext-dict-functions.md#dictisin) توابع. + +سطح امتیاز: `DICTIONARY`. + +**مثالها** + +- `GRANT dictGet ON mydb.mydictionary TO john` +- `GRANT dictGet ON mydictionary TO john` + +### ALL {#grant-all} + +اعطا تمام امتیازات در نهاد تنظیم به یک حساب کاربری و یا نقش. + +### NONE {#grant-none} + +هیچ امتیازاتی به دست نمیاره + +### ADMIN OPTION {#admin-option-privilege} + +این `ADMIN OPTION` امتیاز اجازه می دهد تا کاربر اعطای نقش خود را به یک کاربر دیگر. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/grant/) diff --git a/docs/fa/sql-reference/statements/index.md b/docs/fa/sql-reference/statements/index.md new file mode 100644 index 00000000000..3af2f1603c9 --- /dev/null +++ b/docs/fa/sql-reference/statements/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0628\u06CC\u0627\u0646\u06CC\u0647 \u0647\u0627" +toc_priority: 31 +--- + + diff --git a/docs/fa/sql-reference/statements/insert-into.md b/docs/fa/sql-reference/statements/insert-into.md new file mode 100644 index 00000000000..39950c99688 --- /dev/null +++ b/docs/fa/sql-reference/statements/insert-into.md @@ -0,0 +1,80 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: INSERT INTO +--- + +## INSERT {#insert} + +اضافه کردن داده ها. + +قالب پرس و جو عمومی: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... +``` + +پرسوجو میتواند فهرستی از ستونها را برای درج مشخص کند `[(c1, c2, c3)]`. در این مورد, بقیه ستون ها با پر: + +- مقادیر محاسبه شده از `DEFAULT` عبارات مشخص شده در تعریف جدول. +- صفر و رشته خالی, اگر `DEFAULT` عبارات تعریف نشده. + +اگر [\_مرحلهای دقیق = 1](../../operations/settings/settings.md) ستون هایی که ندارند `DEFAULT` تعریف شده باید در پرس و جو ذکر شده است. + +داده ها را می توان به درج در هر گذشت [قالب](../../interfaces/formats.md#formats) پشتیبانی شده توسط فاحشه خانه. قالب باید به صراحت در پرس و جو مشخص شود: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set +``` + +For example, the following query format is identical to the basic version of INSERT … VALUES: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... +``` + +تاتر حذف تمام فضاها و خوراک یک خط (در صورتی که وجود دارد) قبل از داده ها. هنگام تشکیل یک پرس و جو, توصیه می کنیم قرار دادن داده ها بر روی یک خط جدید پس از اپراتورهای پرس و جو (این مهم است که اگر داده ها با فضاهای شروع می شود). + +مثال: + +``` sql +INSERT INTO t FORMAT TabSeparated +11 Hello, world! +22 Qwerty +``` + +شما می توانید داده ها را به طور جداگانه از پرس و جو با استفاده از مشتری خط فرمان یا رابط اچ تی پی وارد کنید. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “[واسط](../../interfaces/index.md#interfaces)”. + +### قیدها {#constraints} + +اگر جدول [قیدها](create.md#constraints), their expressions will be checked for each row of inserted data. If any of those constraints is not satisfied — server will raise an exception containing constraint name and expression, the query will be stopped. + +### قرار دادن نتایج `SELECT` {#insert_query_insert-select} + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... +``` + +ستون ها با توجه به موقعیت خود را در بند را انتخاب کنید نقشه برداری. با این حال, نام خود را در عبارت را انتخاب کنید و جدول برای درج ممکن است متفاوت باشد. در صورت لزوم نوع ریخته گری انجام می شود. + +هیچ یک از فرمت های داده به جز مقادیر اجازه تنظیم مقادیر به عبارات مانند `now()`, `1 + 2` و به همین ترتیب. فرمت ارزش اجازه می دهد تا استفاده محدود از عبارات, اما این توصیه نمی شود, چرا که در این مورد کد کم است برای اجرای خود استفاده می شود. + +نمایش داده شد دیگر برای تغییر قطعات داده ها پشتیبانی نمی شوند: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. +با این حال, شما می توانید داده های قدیمی با استفاده از حذف `ALTER TABLE ... DROP PARTITION`. + +`FORMAT` بند باید در پایان پرس و جو مشخص شود اگر `SELECT` بند شامل تابع جدول [ورودی()](../table-functions/input.md). + +### ملاحظات عملکرد {#performance-considerations} + +`INSERT` داده های ورودی را با کلید اصلی مرتب می کند و توسط یک کلید پارتیشن به پارتیشن تقسیم می شود. اگر داده ها را به چندین پارتیشن در یک بار وارد کنید می تواند به طور قابل توجهی عملکرد را کاهش دهد `INSERT` پرس و جو. برای جلوگیری از این: + +- اضافه کردن داده ها در دسته نسبتا بزرگ, مانند 100,000 ردیف در یک زمان. +- داده های گروه توسط یک کلید پارتیشن قبل از بارگذاری به کلیک. + +عملکرد کاهش نخواهد یافت اگر: + +- داده ها در زمان واقعی اضافه شده است. +- شما داده ها است که معمولا بر اساس زمان طبقه بندی شده اند را بارگذاری کنید. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/fa/sql-reference/statements/misc.md b/docs/fa/sql-reference/statements/misc.md new file mode 100644 index 00000000000..d67983bd5ba --- /dev/null +++ b/docs/fa/sql-reference/statements/misc.md @@ -0,0 +1,358 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u063A\u06CC\u0631\u0647" +--- + +# نمایش داده شد دیگر {#miscellaneous-queries} + +## ATTACH {#attach} + +این پرس و جو دقیقا همان است `CREATE` اما + +- به جای کلمه `CREATE` با استفاده از این کلمه `ATTACH`. +- پرس و جو می کند داده ها بر روی دیسک ایجاد کنید, اما فرض می شود که داده ها در حال حاضر در مکان های مناسب, و فقط می افزاید: اطلاعات در مورد جدول به سرور. + پس از اجرای پرس و جو ضمیمه, سرور در مورد وجود جدول می دانم. + +اگر جدول قبلا جدا شد (`DETACH`), به این معنی که ساختار خود شناخته شده است, شما می توانید مختصر بدون تعریف ساختار استفاده. + +``` sql +ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] +``` + +این پرس و جو در هنگام شروع سرور استفاده می شود. سرور ذخیره ابرداده جدول به عنوان فایل های با `ATTACH` نمایش داده شد, که به سادگی در راه اندازی اجرا می شود (به غیر از جداول سیستم, که به صراحت بر روی سرور ایجاد). + +## CHECK TABLE {#check-table} + +چک اگر داده ها در جدول خراب شده است. + +``` sql +CHECK TABLE [db.]name +``` + +این `CHECK TABLE` پرس و جو اندازه فایل واقعی با مقادیر مورد انتظار که بر روی سرور ذخیره می شود مقایسه می کند. اگر اندازه فایل انجام مقادیر ذخیره شده مطابقت ندارد, به این معنی که داده ها خراب شده است. این می تواند باعث, مثلا, توسط یک تصادف سیستم در طول اجرای پرس و جو. + +پاسخ پرس و جو شامل `result` ستون با یک ردیف. ردیف دارای ارزش +[بولی](../../sql-reference/data-types/boolean.md) نوع: + +- 0-داده ها در جدول خراب شده است. +- 1-داده حفظ یکپارچگی. + +این `CHECK TABLE` پرس و جو از موتورهای جدول زیر پشتیبانی می کند: + +- [ثبت](../../engines/table-engines/log-family/log.md) +- [جمع شدن](../../engines/table-engines/log-family/tinylog.md) +- [خط زدن](../../engines/table-engines/log-family/stripelog.md) +- [ادغام خانواده](../../engines/table-engines/mergetree-family/mergetree.md) + +انجام بیش از جداول با موتورهای جدول دیگر باعث یک استثنا. + +موتورهای از `*Log` خانواده بازیابی اطلاعات خودکار در شکست را فراهم نمی کند. استفاده از `CHECK TABLE` پرس و جو برای پیگیری از دست دادن داده ها به موقع. + +برای `MergeTree` موتورهای خانواده `CHECK TABLE` پرس و جو نشان می دهد وضعیت چک برای هر بخش داده های فردی از یک جدول بر روی سرور محلی. + +**اگر داده ها خراب شده است** + +اگر جدول خراب شده است, شما می توانید داده های غیر خراب به جدول دیگر کپی کنید. برای انجام این کار: + +1. ایجاد یک جدول جدید با ساختار همان جدول صدمه دیده است. برای انجام این کار پرس و جو را اجرا کنید `CREATE TABLE AS `. +2. تنظیم [\_مخفی کردن](../../operations/settings/settings.md#settings-max_threads) ارزش به 1 برای پردازش پرس و جو بعدی در یک موضوع واحد. برای انجام این کار پرس و جو را اجرا کنید `SET max_threads = 1`. +3. اجرای پرسوجو `INSERT INTO SELECT * FROM `. این درخواست داده های غیر خراب شده را از جدول خراب شده به جدول دیگر کپی می کند. فقط داده ها قبل از قسمت خراب کپی خواهد شد. +4. راه اندازی مجدد `clickhouse-client` برای تنظیم مجدد `max_threads` ارزش. + +## DESCRIBE TABLE {#misc-describe-table} + +``` sql +DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +بازگرداندن موارد زیر `String` نوع ستونها: + +- `name` — Column name. +- `type`— Column type. +- `default_type` — Clause that is used in [عبارت پیشفرض](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` یا `ALIAS`). ستون شامل یک رشته خالی, اگر عبارت پیش فرض مشخص نشده است. +- `default_expression` — Value specified in the `DEFAULT` بند بند. +- `comment_expression` — Comment text. + +ساختارهای داده تو در تو خروجی در “expanded” قالب. هر ستون به طور جداگانه نشان داده شده است, با نام بعد از یک نقطه. + +## DETACH {#detach} + +حذف اطلاعات در مورد ‘name’ جدول از سرور. سرور متوقف می شود دانستن در مورد وجود جدول. + +``` sql +DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +این داده ها و یا ابرداده جدول را حذف کنید. در راه اندازی سرور بعدی, سرور خواهد ابرداده به عنوان خوانده شده و پیدا کردن در مورد جدول دوباره. +به طور مشابه “detached” جدول را می توان دوباره متصل با استفاده از `ATTACH` پرس و جو (به غیر از جداول سیستم, که ابرداده ذخیره شده برای ندارد). + +وجود ندارد `DETACH DATABASE` پرس و جو. + +## DROP {#drop} + +این پرسوجو دارای دو نوع است: `DROP DATABASE` و `DROP TABLE`. + +``` sql +DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] +``` + +حذف تمام جداول در داخل ‘db’ پایگاه داده, سپس حذف ‘db’ پایگاه داده خود را. +اگر `IF EXISTS` مشخص شده است, این خطا بازگشت نیست اگر پایگاه داده وجود ندارد. + +``` sql +DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +حذف جدول. +اگر `IF EXISTS` مشخص شده است, این خطا را نمی گرداند اگر جدول وجود ندارد و یا پایگاه داده وجود ندارد. + + DROP DICTIONARY [IF EXISTS] [db.]name + +دلس فرهنگ لغت. +اگر `IF EXISTS` مشخص شده است, این خطا را نمی گرداند اگر جدول وجود ندارد و یا پایگاه داده وجود ندارد. + +## DROP USER {#drop-user-statement} + +حذف یک کاربر. + +### نحو {#drop-user-syntax} + +``` sql +DROP USER [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROLE {#drop-role-statement} + +نقش را حذف می کند. + +نقش حذف شده از تمام نهادهایی که اعطا شد لغو می شود. + +### نحو {#drop-role-syntax} + +``` sql +DROP ROLE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROW POLICY {#drop-row-policy-statement} + +حذف یک سیاست ردیف. + +سیاست ردیف حذف شده است از تمام اشخاص لغو جایی که اختصاص داده شد. + +### نحو {#drop-row-policy-syntax} + +``` sql +DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] +``` + +## DROP QUOTA {#drop-quota-statement} + +حذف سهمیه. + +سهمیه حذف شده است از تمام اشخاص لغو جایی که اختصاص داده شد. + +### نحو {#drop-quota-syntax} + +``` sql +DROP QUOTA [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP SETTINGS PROFILE {#drop-settings-profile-statement} + +حذف سهمیه. + +سهمیه حذف شده است از تمام اشخاص لغو جایی که اختصاص داده شد. + +### نحو {#drop-settings-profile-syntax} + +``` sql +DROP [SETTINGS] PROFILE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## EXISTS {#exists-statement} + +``` sql +EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] +``` + +بازگرداندن یک `UInt8`- نوع ستون, که شامل ارزش واحد `0` اگر جدول یا پایگاه داده وجود ندارد, یا `1` اگر جدول در پایگاه داده مشخص شده وجود دارد. + +## KILL QUERY {#kill-query-statement} + +``` sql +KILL QUERY [ON CLUSTER cluster] + WHERE + [SYNC|ASYNC|TEST] + [FORMAT format] +``` + +تلاش برای به زور خاتمه نمایش داده شد در حال حاضر در حال اجرا. +نمایش داده شد به فسخ از سیستم انتخاب شده است.جدول پردازش ها با استفاده از معیارهای تعریف شده در `WHERE` بند از `KILL` پرس و جو. + +مثالها: + +``` sql +-- Forcibly terminates all queries with the specified query_id: +KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' + +-- Synchronously terminates all queries run by 'username': +KILL QUERY WHERE user='username' SYNC +``` + +فقط خواندنی کاربران تنها می تواند نمایش داده شد خود را متوقف کند. + +به طور پیش فرض, نسخه ناهمزمان از نمایش داده شد استفاده شده است (`ASYNC`), که برای تایید است که نمایش داده شد را متوقف کرده اند منتظر نیست. + +نسخه همزمان (`SYNC`) منتظر تمام نمایش داده شد برای متوقف کردن و نمایش اطلاعات در مورد هر فرایند به عنوان متوقف می شود. +پاسخ شامل `kill_status` ستون, که می تواند مقادیر زیر را: + +1. ‘finished’ – The query was terminated successfully. +2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. +3. The other values ​​explain why the query can't be stopped. + +پرسوجوی تست (`TEST`) فقط چک حقوق کاربر و نمایش یک لیست از نمایش داده شد برای متوقف کردن. + +## KILL MUTATION {#kill-mutation} + +``` sql +KILL MUTATION [ON CLUSTER cluster] + WHERE + [TEST] + [FORMAT format] +``` + +تلاش برای لغو و حذف [جهشها](alter.md#alter-mutations) که در حال حاضر اجرای. جهش به لغو از انتخاب [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) جدول با استفاده از فیلتر مشخص شده توسط `WHERE` بند از `KILL` پرس و جو. + +پرسوجوی تست (`TEST`) فقط چک حقوق کاربر و نمایش یک لیست از نمایش داده شد برای متوقف کردن. + +مثالها: + +``` sql +-- Cancel and remove all mutations of the single table: +KILL MUTATION WHERE database = 'default' AND table = 'table' + +-- Cancel the specific mutation: +KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' +``` + +The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). + +تغییرات در حال حاضر توسط جهش ساخته شده به عقب نورد نیست. + +## OPTIMIZE {#misc_operations-optimize} + +``` sql +OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] +``` + +این پرس و جو تلاش می کند تا ادغام برنامه ریزی نشده از قطعات داده برای جداول با یک موتور جدول از [ادغام](../../engines/table-engines/mergetree-family/mergetree.md) خانواده + +این `OPTMIZE` پرس و جو نیز برای پشتیبانی [ماده بینی](../../engines/table-engines/special/materializedview.md) و [بافر](../../engines/table-engines/special/buffer.md) موتورها. دیگر موتورهای جدول پشتیبانی نمی شوند. + +چه زمانی `OPTIMIZE` با استفاده از [تکرار غذای اصلی](../../engines/table-engines/mergetree-family/replication.md) خانواده از موتورهای جدول, تاتر ایجاد یک کار برای ادغام و منتظر اعدام در تمام گره (در صورتی که `replication_alter_partitions_sync` تنظیم فعال است). + +- اگر `OPTIMIZE` یک ادغام به هر دلیلی انجام نمی, این کار مشتری اطلاع نیست. برای فعال کردن اعلان ها از [ا\_فزون\_ف\_کوپ](../../operations/settings/settings.md#setting-optimize_throw_if_noop) تنظیمات. +- اگر شما یک مشخص `PARTITION` فقط پارتیشن مشخص شده بهینه شده است. [نحوه تنظیم بیان پارتیشن](alter.md#alter-how-to-specify-part-expr). +- اگر شما مشخص کنید `FINAL` حتی زمانی که تمام داده ها در حال حاضر در یک بخش بهینه سازی انجام شده است. +- اگر شما مشخص کنید `DEDUPLICATE` و سپس به طور کامل یکسان ردیف خواهد بود deduplicated (تمام ستون ها در مقایسه با) آن را حس می کند تنها برای MergeTree موتور. + +!!! warning "اخطار" + `OPTIMIZE` می توانید رفع نیست “Too many parts” خطا. + +## RENAME {#misc_operations-rename} + +تغییر نام یک یا چند جدول. + +``` sql +RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] +``` + +همه جداول تحت قفل جهانی تغییر نام داد. تغییر نام جداول یک عملیات نور است. اگر شما یک پایگاه داده دیگر نشان داد پس از به, جدول خواهد شد به این پایگاه داده منتقل. اما, دایرکتوری ها با پایگاه داده باید اقامت در همان فایل سیستم (در غیر این صورت یک خطا بازگشته است). + +## SET {#query-set} + +``` sql +SET param = value +``` + +انتساب `value` به `param` [تنظیم](../../operations/settings/index.md) برای جلسه فعلی. شما نمی توانید تغییر دهید [تنظیمات کارگزار](../../operations/server-configuration-parameters/index.md) از این طرف + +شما همچنین می توانید تمام مقادیر را از مشخصات تنظیمات مشخص شده در یک پرس و جو واحد تنظیم کنید. + +``` sql +SET profile = 'profile-name-from-the-settings-file' +``` + +برای کسب اطلاعات بیشتر, دیدن [تنظیمات](../../operations/settings/settings.md). + +## SET ROLE {#set-role-statement} + +فعال نقش برای کاربر فعلی. + +### نحو {#set-role-syntax} + +``` sql +SET ROLE {DEFAULT | NONE | role [,...] | ALL | ALL EXCEPT role [,...]} +``` + +## SET DEFAULT ROLE {#set-default-role-statement} + +مجموعه نقش به طور پیش فرض به یک کاربر. + +نقش پیش فرض به طور خودکار در ورود کاربر فعال می شود. شما می توانید به عنوان پیش فرض تنها نقش قبلا اعطا تنظیم شده است. اگر نقش به یک کاربر اعطا نمی, خانه عروسکی می اندازد یک استثنا. + +### نحو {#set-default-role-syntax} + +``` sql +SET DEFAULT ROLE {NONE | role [,...] | ALL | ALL EXCEPT role [,...]} TO {user|CURRENT_USER} [,...] +``` + +### مثالها {#set-default-role-examples} + +تنظیم نقش های پیش فرض چندگانه به یک کاربر: + +``` sql +SET DEFAULT ROLE role1, role2, ... TO user +``` + +تنظیم تمام نقش های اعطا شده به عنوان پیش فرض به یک کاربر: + +``` sql +SET DEFAULT ROLE ALL TO user +``` + +خالی کردن نقش پیشفرض از یک کاربر: + +``` sql +SET DEFAULT ROLE NONE TO user +``` + +مجموعه ای از تمام نقش های اعطا شده به عنوان پیش فرض به استثنای برخی از: + +``` sql +SET DEFAULT ROLE ALL EXCEPT role1, role2 TO user +``` + +## TRUNCATE {#truncate-statement} + +``` sql +TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +حذف تمام داده ها را از یک جدول. هنگامی که بند `IF EXISTS` حذف شده است, پرس و جو یک خطا می گرداند اگر جدول وجود ندارد. + +این `TRUNCATE` پرسوجو برای پشتیبانی نمیشود [نما](../../engines/table-engines/special/view.md), [پرونده](../../engines/table-engines/special/file.md), [URL](../../engines/table-engines/special/url.md) و [خالی](../../engines/table-engines/special/null.md) موتورهای جدول. + +## USE {#use} + +``` sql +USE db +``` + +به شما اجازه می دهد پایگاه داده فعلی را برای جلسه تنظیم کنید. +پایگاه داده فعلی برای جستجو برای جداول استفاده می شود اگر پایگاه داده به صراحت در پرس و جو با یک نقطه قبل از نام جدول تعریف نشده است. +این پرس و جو را نمی توان در هنگام استفاده از پروتکل قام ساخته شده, از هیچ مفهوم یک جلسه وجود دارد. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/fa/sql-reference/statements/revoke.md b/docs/fa/sql-reference/statements/revoke.md new file mode 100644 index 00000000000..c9fb77a3d48 --- /dev/null +++ b/docs/fa/sql-reference/statements/revoke.md @@ -0,0 +1,50 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: REVOKE +--- + +# REVOKE {#revoke} + +لغو امتیازات از کاربران و یا نقش. + +## نحو {#revoke-syntax} + +**لغو امتیازات از کاربران** + +``` sql +REVOKE [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*} FROM {user | CURRENT_USER} [,...] | ALL | ALL EXCEPT {user | CURRENT_USER} [,...] +``` + +**نقش لغو از کاربران** + +``` sql +REVOKE [ON CLUSTER cluster_name] [ADMIN OPTION FOR] role [,...] FROM {user | role | CURRENT_USER} [,...] | ALL | ALL EXCEPT {user_name | role_name | CURRENT_USER} [,...] +``` + +## توصیف {#revoke-description} + +برای لغو برخی از امتیاز شما می توانید یک امتیاز از دامنه گسترده تر استفاده کنید و سپس شما قصد لغو. برای مثال اگر یک کاربر `SELECT (x,y)` امتیاز مدیر می تواند انجام دهد `REVOKE SELECT(x,y) ...` یا `REVOKE SELECT * ...` یا حتی `REVOKE ALL PRIVILEGES ...` پرسوجو برای لغو این امتیاز. + +### لغو نسبی {#partial-revokes-dscr} + +شما می توانید بخشی از یک امتیاز لغو. برای مثال اگر یک کاربر `SELECT *.*` امتیاز شما می توانید از این امتیاز لغو به خواندن داده ها از برخی از جدول و یا یک پایگاه داده. + +## مثالها {#revoke-example} + +اعطای `john` حساب کاربری با یک امتیاز را انتخاب کنید از تمام پایگاه داده به استثنای `accounts` یک: + +``` sql +GRANT SELECT ON *.* TO john; +REVOKE SELECT ON accounts.* FROM john; +``` + +اعطای `mira` حساب کاربری با یک امتیاز را انتخاب کنید از تمام ستون ها از `accounts.staff` جدول به استثنای `wage` یک + +``` sql +GRANT SELECT ON accounts.staff TO mira; +REVOKE SELECT(wage) ON accounts.staff FROM mira; +``` + +{## [مقاله اصلی](https://clickhouse.tech/docs/en/operations/settings/settings/) ##} diff --git a/docs/fa/sql-reference/statements/select/array-join.md b/docs/fa/sql-reference/statements/select/array-join.md new file mode 100644 index 00000000000..28655e3554a --- /dev/null +++ b/docs/fa/sql-reference/statements/select/array-join.md @@ -0,0 +1,282 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# مجموعه پیوستن بند {#select-array-join-clause} + +این یک عملیات مشترک برای جداول است که حاوی یک ستون جداگانه برای تولید یک جدول جدید است که دارای یک ستون با هر عنصر جداگانه ای از ستون اولیه است در حالی که مقادیر ستون های دیگر تکرار می شوند. این مورد اساسی چه چیزی است `ARRAY JOIN` بند کند. + +نام خود را از این واقعیت است که می تواند در به عنوان اجرای نگاه `JOIN` با یک مجموعه یا ساختار داده های تو در تو. قصد شبیه به است [ارریجین](../../functions/array-join.md#functions_arrayjoin) تابع, اما قابلیت بند گسترده تر است. + +نحو: + +``` sql +SELECT +FROM +[LEFT] ARRAY JOIN +[WHERE|PREWHERE ] +... +``` + +شما می توانید تنها یک مشخص `ARRAY JOIN` بند در یک `SELECT` پرس و جو. + +انواع پشتیبانی شده از `ARRAY JOIN` به شرح زیر است: + +- `ARRAY JOIN` - در مورد پایه, بند خالی در نتیجه شامل نمی شود `JOIN`. +- `LEFT ARRAY JOIN` - نتیجه `JOIN` شامل ردیف با ارریس خالی است. مقدار برای یک مجموعه خالی است به مقدار پیش فرض برای نوع عنصر مجموعه (معمولا 0, رشته خالی و یا تهی). + +## پایه صف پیوستن به نمونه {#basic-array-join-examples} + +نمونه های زیر نشان می دهد استفاده از `ARRAY JOIN` و `LEFT ARRAY JOIN` بند. بیایید یک جدول با یک [& حذف](../../../sql-reference/data-types/array.md) ستون را تایپ کنید و مقادیر را وارد کنید: + +``` sql +CREATE TABLE arrays_test +( + s String, + arr Array(UInt8) +) ENGINE = Memory; + +INSERT INTO arrays_test +VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []); +``` + +``` text +┌─s───────────┬─arr─────┐ +│ Hello │ [1,2] │ +│ World │ [3,4,5] │ +│ Goodbye │ [] │ +└─────────────┴─────────┘ +``` + +مثال زیر از `ARRAY JOIN` بند: + +``` sql +SELECT s, arr +FROM arrays_test +ARRAY JOIN arr; +``` + +``` text +┌─s─────┬─arr─┐ +│ Hello │ 1 │ +│ Hello │ 2 │ +│ World │ 3 │ +│ World │ 4 │ +│ World │ 5 │ +└───────┴─────┘ +``` + +مثال بعدی با استفاده از `LEFT ARRAY JOIN` بند: + +``` sql +SELECT s, arr +FROM arrays_test +LEFT ARRAY JOIN arr; +``` + +``` text +┌─s───────────┬─arr─┐ +│ Hello │ 1 │ +│ Hello │ 2 │ +│ World │ 3 │ +│ World │ 4 │ +│ World │ 5 │ +│ Goodbye │ 0 │ +└─────────────┴─────┘ +``` + +## استفاده از نام مستعار {#using-aliases} + +یک نام مستعار می تواند برای مجموعه ای در `ARRAY JOIN` بند بند. در این مورد, یک مورد مجموعه ای را می توان با این نام مستعار دیده, اما مجموعه خود را با نام اصلی قابل دسترسی. مثال: + +``` sql +SELECT s, arr, a +FROM arrays_test +ARRAY JOIN arr AS a; +``` + +``` text +┌─s─────┬─arr─────┬─a─┐ +│ Hello │ [1,2] │ 1 │ +│ Hello │ [1,2] │ 2 │ +│ World │ [3,4,5] │ 3 │ +│ World │ [3,4,5] │ 4 │ +│ World │ [3,4,5] │ 5 │ +└───────┴─────────┴───┘ +``` + +با استفاده از نام مستعار, شما می توانید انجام `ARRAY JOIN` با یک مجموعه خارجی. به عنوان مثال: + +``` sql +SELECT s, arr_external +FROM arrays_test +ARRAY JOIN [1, 2, 3] AS arr_external; +``` + +``` text +┌─s───────────┬─arr_external─┐ +│ Hello │ 1 │ +│ Hello │ 2 │ +│ Hello │ 3 │ +│ World │ 1 │ +│ World │ 2 │ +│ World │ 3 │ +│ Goodbye │ 1 │ +│ Goodbye │ 2 │ +│ Goodbye │ 3 │ +└─────────────┴──────────────┘ +``` + +ارریس های متعدد را می توان با کاما از هم جدا در `ARRAY JOIN` بند بند. در این مورد, `JOIN` به طور همزمان (مجموع مستقیم و نه محصول دکارتی) انجام می شود. توجه داشته باشید که تمام ارریس باید به همان اندازه. مثال: + +``` sql +SELECT s, arr, a, num, mapped +FROM arrays_test +ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped; +``` + +``` text +┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ +│ Hello │ [1,2] │ 1 │ 1 │ 2 │ +│ Hello │ [1,2] │ 2 │ 2 │ 3 │ +│ World │ [3,4,5] │ 3 │ 1 │ 4 │ +│ World │ [3,4,5] │ 4 │ 2 │ 5 │ +│ World │ [3,4,5] │ 5 │ 3 │ 6 │ +└───────┴─────────┴───┴─────┴────────┘ +``` + +مثال زیر از [شناسه بسته:](../../../sql-reference/functions/array-functions.md#array_functions-arrayenumerate) تابع: + +``` sql +SELECT s, arr, a, num, arrayEnumerate(arr) +FROM arrays_test +ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; +``` + +``` text +┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ +│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ +│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ +│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ +│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ +│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ +└───────┴─────────┴───┴─────┴─────────────────────┘ +``` + +## مجموعه پیوستن با ساختار داده های تو در تو {#array-join-with-nested-data-structure} + +`ARRAY JOIN` همچنین با این نسخهها کار [ساختارهای داده تو در تو](../../../sql-reference/data-types/nested-data-structures/nested.md): + +``` sql +CREATE TABLE nested_test +( + s String, + nest Nested( + x UInt8, + y UInt32) +) ENGINE = Memory; + +INSERT INTO nested_test +VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []); +``` + +``` text +┌─s───────┬─nest.x──┬─nest.y─────┐ +│ Hello │ [1,2] │ [10,20] │ +│ World │ [3,4,5] │ [30,40,50] │ +│ Goodbye │ [] │ [] │ +└─────────┴─────────┴────────────┘ +``` + +``` sql +SELECT s, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN nest; +``` + +``` text +┌─s─────┬─nest.x─┬─nest.y─┐ +│ Hello │ 1 │ 10 │ +│ Hello │ 2 │ 20 │ +│ World │ 3 │ 30 │ +│ World │ 4 │ 40 │ +│ World │ 5 │ 50 │ +└───────┴────────┴────────┘ +``` + +هنگام مشخص کردن نام ساختارهای داده های تو در تو در `ARRAY JOIN`, معنای همان است که `ARRAY JOIN` با تمام عناصر مجموعه ای که شامل. نمونه به شرح زیر است: + +``` sql +SELECT s, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN `nest.x`, `nest.y`; +``` + +``` text +┌─s─────┬─nest.x─┬─nest.y─┐ +│ Hello │ 1 │ 10 │ +│ Hello │ 2 │ 20 │ +│ World │ 3 │ 30 │ +│ World │ 4 │ 40 │ +│ World │ 5 │ 50 │ +└───────┴────────┴────────┘ +``` + +این تنوع نیز حس می کند: + +``` sql +SELECT s, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN `nest.x`; +``` + +``` text +┌─s─────┬─nest.x─┬─nest.y─────┐ +│ Hello │ 1 │ [10,20] │ +│ Hello │ 2 │ [10,20] │ +│ World │ 3 │ [30,40,50] │ +│ World │ 4 │ [30,40,50] │ +│ World │ 5 │ [30,40,50] │ +└───────┴────────┴────────────┘ +``` + +نام مستعار ممکن است برای یک ساختار داده های تو در تو استفاده می شود, به منظور انتخاب هر دو `JOIN` نتیجه یا مجموعه منبع. مثال: + +``` sql +SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN nest AS n; +``` + +``` text +┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ +│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ +│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ +│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ +│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ +│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ +└───────┴─────┴─────┴─────────┴────────────┘ +``` + +نمونه ای از استفاده از [شناسه بسته:](../../../sql-reference/functions/array-functions.md#array_functions-arrayenumerate) تابع: + +``` sql +SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num +FROM nested_test +ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; +``` + +``` text +┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ +│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ +│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ +│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ +│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ +│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ +└───────┴─────┴─────┴─────────┴────────────┴─────┘ +``` + +## پیاده سازی اطلاعات {#implementation-details} + +سفارش اجرای پرس و جو در هنگام اجرا بهینه شده است `ARRAY JOIN`. اگرچه `ARRAY JOIN` همیشه باید قبل از مشخص شود [WHERE](where.md)/[PREWHERE](prewhere.md) بند در پرس و جو, از لحاظ فنی می تواند در هر سفارش انجام, مگر اینکه نتیجه `ARRAY JOIN` برای فیلتر کردن استفاده می شود. سفارش پردازش توسط بهینه ساز پرس و جو کنترل می شود. diff --git a/docs/fa/sql-reference/statements/select/distinct.md b/docs/fa/sql-reference/statements/select/distinct.md new file mode 100644 index 00000000000..9c2a454a729 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/distinct.md @@ -0,0 +1,63 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# بند مجزا {#select-distinct} + +اگر `SELECT DISTINCT` مشخص شده است, تنها ردیف منحصر به فرد در یک نتیجه پرس و جو باقی خواهد ماند. بنابراین تنها یک ردیف از تمام مجموعه از ردیف به طور کامل تطبیق در نتیجه باقی خواهد ماند. + +## پردازش پوچ {#null-processing} + +`DISTINCT` با این نسخهها کار میکند [NULL](../../syntax.md#null-literal) همانطور که اگر `NULL` یک مقدار خاص بودند, و `NULL==NULL`. به عبارت دیگر در `DISTINCT` نتایج, ترکیب های مختلف با `NULL` رخ می دهد تنها یک بار. این متفاوت است `NULL` پردازش در بسیاری از زمینه های دیگر. + +## جایگزین ها {#alternatives} + +ممکن است با استفاده از همان نتیجه حاصل شود [GROUP BY](group-by.md) در سراسر همان مجموعه ای از ارزش ها به عنوان مشخص شده به عنوان `SELECT` بند, بدون استفاده از هر گونه توابع کل. اما چند تفاوت از وجود دارد `GROUP BY` رویکرد: + +- `DISTINCT` می توان همراه با `GROUP BY`. +- چه زمانی [ORDER BY](order-by.md) حذف شده است و [LIMIT](limit.md) تعریف شده است, پرس و جو متوقف می شود در حال اجرا بلافاصله پس از تعداد مورد نیاز از ردیف های مختلف خوانده شده است. +- بلوک های داده خروجی به عنوان پردازش می شوند, بدون انتظار برای کل پرس و جو را به پایان برساند در حال اجرا. + +## محدودیت ها {#limitations} + +`DISTINCT` پشتیبانی نمی شود اگر `SELECT` حداقل یک ستون جداگانه دارد. + +## مثالها {#examples} + +کلیک پشتیبانی با استفاده از `DISTINCT` و `ORDER BY` بند برای ستون های مختلف در یک پرس و جو. این `DISTINCT` بند قبل از اجرا `ORDER BY` بند بند. + +جدول نمونه: + +``` text +┌─a─┬─b─┐ +│ 2 │ 1 │ +│ 1 │ 2 │ +│ 3 │ 3 │ +│ 2 │ 4 │ +└───┴───┘ +``` + +هنگام انتخاب داده ها با `SELECT DISTINCT a FROM t1 ORDER BY b ASC` پرس و جو, ما نتیجه زیر را دریافت کنید: + +``` text +┌─a─┐ +│ 2 │ +│ 1 │ +│ 3 │ +└───┘ +``` + +اگر ما جهت مرتب سازی را تغییر دهیم `SELECT DISTINCT a FROM t1 ORDER BY b DESC` ما نتیجه زیر را دریافت می کنیم: + +``` text +┌─a─┐ +│ 3 │ +│ 1 │ +│ 2 │ +└───┘ +``` + +سطر `2, 4` قبل از مرتب سازی قطع شد. + +نگاهی به این ویژگی پیاده سازی به حساب زمانی که برنامه نویسی نمایش داده شد. diff --git a/docs/fa/sql-reference/statements/select/format.md b/docs/fa/sql-reference/statements/select/format.md new file mode 100644 index 00000000000..27ac2233375 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/format.md @@ -0,0 +1,18 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# بند فرمت {#format-clause} + +تاتر پشتیبانی از طیف گسترده ای از [فرمت های ترتیب](../../../interfaces/formats.md) که می تواند در نتایج پرس و جو در میان چیزهای دیگر استفاده می شود. راه های متعدد برای انتخاب یک فرمت برای وجود دارد `SELECT` خروجی یکی از این موارد مشخص است `FORMAT format` در پایان پرس و جو برای دریافت و در نتیجه داده ها در هر فرمت خاص. + +فرمت خاص ممکن است یا برای راحتی استفاده می شود, ادغام با سیستم های دیگر و یا افزایش عملکرد. + +## قالب پیشفرض {#default-format} + +اگر `FORMAT` بند حذف شده است, فرمت پیش فرض استفاده شده است, که بستگی به هر دو تنظیمات و رابط مورد استفاده برای دسترسی به سرور کلیک. برای [رابط قام](../../../interfaces/http.md) و [مشتری خط فرمان](../../../interfaces/cli.md) در حالت دسته ای فرمت پیش فرض است `TabSeparated`. برای مشتری خط فرمان در حالت تعاملی فرمت پیش فرض است `PrettyCompact` (این تولید جداول جمع و جور انسان قابل خواندن). + +## پیاده سازی اطلاعات {#implementation-details} + +هنگام استفاده از سرویس گیرنده خط فرمان داده ها همیشه بر روی شبکه در فرمت موثر داخلی منتقل می شود (`Native`). مشتری به طور مستقل تفسیر می کند `FORMAT` بند از پرس و جو و فرمت های داده های خود را (در نتیجه تسکین شبکه و سرور از بار اضافی). diff --git a/docs/fa/sql-reference/statements/select/from.md b/docs/fa/sql-reference/statements/select/from.md new file mode 100644 index 00000000000..d2ec8f4c6ff --- /dev/null +++ b/docs/fa/sql-reference/statements/select/from.md @@ -0,0 +1,44 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# از بند {#select-from} + +این `FROM` بند منبع برای خواندن داده ها از مشخص: + +- [جدول](../../../engines/table-engines/index.md) +- [خرده فروشی](index.md) لینک بهتر ##} +- [تابع جدول](../../table-functions/index.md#table-functions) + +[JOIN](join.md) و [ARRAY JOIN](array-join.md) بند نیز ممکن است مورد استفاده قرار گیرد به گسترش قابلیت های `FROM` بند بند. + +خرده فروشی دیگر است `SELECT` پرسوجوی که ممکن است در داخل پرانتز مشخص شود `FROM` بند بند. + +`FROM` بند می تواند شامل منابع داده های متعدد, جدا شده توسط کاما, که معادل انجام است [CROSS JOIN](join.md) با اونا. + +## تغییردهنده نهایی {#select-from-final} + +چه زمانی `FINAL` مشخص شده است, تاتر به طور کامل ادغام داده ها قبل از بازگشت به نتیجه و در نتیجه انجام تمام تحولات داده که در طول ادغام برای موتور جدول داده شده اتفاق می افتد. + +این قابل اجرا است در هنگام انتخاب داده ها از جداول که با استفاده از [ادغام](../../../engines/table-engines/mergetree-family/mergetree.md)- خانواده موتور (به جز `GraphiteMergeTree`). همچنین برای پشتیبانی: + +- [تکرار](../../../engines/table-engines/mergetree-family/replication.md) نسخه های `MergeTree` موتورها. +- [نما](../../../engines/table-engines/special/view.md), [بافر](../../../engines/table-engines/special/buffer.md), [توزیع شده](../../../engines/table-engines/special/distributed.md) و [ماده بینی](../../../engines/table-engines/special/materializedview.md) موتورها که بیش از موتورهای دیگر کار می کنند به شرطی که بیش از ایجاد شده اند `MergeTree`- جدول موتور . + +### اشکالاتی {#drawbacks} + +نمایش داده شد که با استفاده از `FINAL` اعدام به همان سرعتی که نمایش داده شد مشابه که نمی, زیرا: + +- پرس و جو در یک موضوع اجرا و داده ها در طول اجرای پرس و جو با هم ادغام شدند. +- نمایش داده شد با `FINAL` خوانده شده ستون کلید اولیه در علاوه بر این به ستون مشخص شده در پرس و جو. + +**در بیشتر موارد, اجتناب از استفاده از `FINAL`.** روش معمول این است که از نمایش های مختلف استفاده کنید که فرایندهای پس زمینه را فرض می کنند `MergeTree` موتور هنوز اتفاق نیفتاده است و با استفاده از تجمع (به عنوان مثال برای دور انداختن تکراری) مقابله می کند. پردازشگر پشتیبانی شده: ##} + +## پیاده سازی اطلاعات {#implementation-details} + +اگر `FROM` بند حذف شده است, داده خواهد شد از خواندن `system.one` جدول +این `system.one` جدول شامل دقیقا یک ردیف است (این جدول همان هدف را به عنوان جدول دوگانه موجود در سایر دساماسها انجام می دهد). + +برای اجرای پرس و جو تمام ستون های ذکر شده در پرس و جو از جدول مناسب استخراج می شوند. هر ستون برای پرس و جو خارجی مورد نیاز نیست از کارخانه های فرعی پرتاب می شود. +اگر پرس و جو هیچ ستون لیست نیست (به عنوان مثال, `SELECT count() FROM t`), برخی از ستون از جدول استخراج به هر حال (کوچکترین ترجیح داده می شود), به منظور محاسبه تعداد ردیف. diff --git a/docs/fa/sql-reference/statements/select/group-by.md b/docs/fa/sql-reference/statements/select/group-by.md new file mode 100644 index 00000000000..9b543a4b606 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/group-by.md @@ -0,0 +1,132 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# گروه بر اساس بند {#select-group-by-clause} + +`GROUP BY` بند کلید `SELECT` پرس و جو به حالت تجمع, که به شرح زیر کار می کند: + +- `GROUP BY` بند شامل یک لیست از عبارات (و یا یک عبارت واحد, که در نظر گرفته می شود لیستی از طول یک). این لیست به عنوان یک عمل می کند “grouping key”, در حالی که هر بیان فردی خواهد شد به عنوان یک اشاره “key expressions”. +- تمام عبارات در [SELECT](index.md), [HAVING](having.md) و [ORDER BY](order-by.md) بند **باید** بر اساس عبارات کلیدی محاسبه می شود **یا** روشن [توابع مجموع](../../../sql-reference/aggregate-functions/index.md) بیش از عبارات غیر کلیدی (از جمله ستون ساده). به عبارت دیگر, هر ستون انتخاب شده از جدول باید یا در یک عبارت کلیدی و یا در داخل یک تابع جمع استفاده می شود, اما نه هر دو. +- نتیجه جمع `SELECT` پرس و جو شامل ردیف به عنوان بسیاری از ارزش های منحصر به فرد وجود دارد “grouping key” در جدول منبع. معمولا این نشانه را کاهش می دهد تعداد ردیف, اغلب توسط سفارشات از قدر, اما نه لزوما: تعداد ردیف همان باقی می ماند اگر همه “grouping key” ارزش متمایز بودند. + +!!! note "یادداشت" + یک راه اضافی برای اجرای تجمع بیش از یک جدول وجود دارد. اگر یک پرس و جو شامل ستون جدول تنها در داخل توابع کل, که `GROUP BY clause` می توان حذف, و تجمع توسط یک مجموعه خالی از کلید فرض بر این است. چنین نمایش داده شد همیشه دقیقا یک ردیف بازگشت. + +## پردازش پوچ {#null-processing} + +برای گروه بندی, تفسیر کلیک [NULL](../../syntax.md#null-literal) به عنوان یک ارزش, و `NULL==NULL`. این متفاوت است `NULL` پردازش در بسیاری از زمینه های دیگر. + +در اینجا یک مثال برای نشان دادن این بدان معنی است. + +فرض کنید شما باید این جدول: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +پرسوجو `SELECT sum(x), y FROM t_null_big GROUP BY y` نتایج در: + +``` text +┌─sum(x)─┬────y─┐ +│ 4 │ 2 │ +│ 3 │ 3 │ +│ 5 │ ᴺᵁᴸᴸ │ +└────────┴──────┘ +``` + +شما می توانید ببینید که `GROUP BY` برای `y = NULL` خلاصه تا `x`, به عنوان اگر `NULL` این مقدار است. + +اگر شما تصویب چند کلید به `GROUP BY`, نتیجه به شما تمام ترکیبی از انتخاب را, اگر `NULL` یک مقدار خاص بودند. + +## با اصلاح کننده بالغ {#with-totals-modifier} + +اگر `WITH TOTALS` اصلاح مشخص شده است, ردیف دیگر محاسبه خواهد شد. این ردیف ستون های کلیدی حاوی مقادیر پیش فرض (صفر یا خطوط خالی) و ستون های توابع جمع شده با مقادیر محاسبه شده در تمام ردیف ها ( “total” ارزش ها). + +این ردیف اضافی تنها در تولید `JSON*`, `TabSeparated*` و `Pretty*` فرمت ها به طور جداگانه از ردیف های دیگر: + +- داخل `JSON*` فرمت, این ردیف خروجی به عنوان یک جداگانه است ‘totals’ رشته. +- داخل `TabSeparated*` فرمت, ردیف پس از نتیجه اصلی, قبل از یک ردیف خالی (پس از داده های دیگر). +- داخل `Pretty*` فرمت, ردیف خروجی به عنوان یک جدول جداگانه پس از نتیجه اصلی است. +- در فرمت های دیگر در دسترس نیست. + +`WITH TOTALS` می توان در راه های مختلف اجرا زمانی که داشتن حاضر است. رفتار بستگی به ‘totals\_mode’ تنظیمات. + +### پیکربندی پردازش بالغ {#configuring-totals-processing} + +به طور پیش فرض, `totals_mode = 'before_having'`. در این مورد, ‘totals’ محاسبه شده است در تمام ردیف از جمله کسانی که عبور نمی کند از طریق داشتن و `max_rows_to_group_by`. + +جایگزین های دیگر شامل تنها ردیف است که از طریق داشتن در عبور ‘totals’ و رفتار متفاوت با تنظیم `max_rows_to_group_by` و `group_by_overflow_mode = 'any'`. + +`after_having_exclusive` – Don't include rows that didn't pass through `max_rows_to_group_by`. به عبارت دیگر, ‘totals’ کمتر از و یا به همان تعداد از ردیف به عنوان اگر داشته باشد `max_rows_to_group_by` حذف شد. + +`after_having_inclusive` – Include all the rows that didn't pass through ‘max\_rows\_to\_group\_by’ داخل ‘totals’. به عبارت دیگر, ‘totals’ بیش از و یا به همان تعداد از ردیف به عنوان اگر داشته باشد `max_rows_to_group_by` حذف شد. + +`after_having_auto` – Count the number of rows that passed through HAVING. If it is more than a certain amount (by default, 50%), include all the rows that didn't pass through ‘max\_rows\_to\_group\_by’ داخل ‘totals’. در غیر این صورت, را شامل نمی شود. + +`totals_auto_threshold` – By default, 0.5. The coefficient for `after_having_auto`. + +اگر `max_rows_to_group_by` و `group_by_overflow_mode = 'any'` استفاده نمی شود, تمام تغییرات از `after_having` یکسان هستند و شما می توانید از هر یک از این موارد استفاده کنید, `after_having_auto`). + +شما می توانید با استفاده از مجموع در subqueries از جمله subqueries در پیوستن به بند (در این مورد مربوطه مجموع ارزش ترکیب می شوند). + +## مثالها {#examples} + +مثال: + +``` sql +SELECT + count(), + median(FetchTiming > 60 ? 60 : FetchTiming), + count() - sum(Refresh) +FROM hits +``` + +با این حال, در مقابل به استاندارد گذاشتن, اگر جدول هیچ ردیف ندارد (یا هیچ در همه وجود ندارد, و یا هر پس از استفاده از جایی که برای فیلتر کردن وجود ندارد), یک نتیجه خالی بازگشته است, و نه در نتیجه از یکی از ردیف های حاوی مقادیر اولیه از توابع کل. + +همانطور که به خروجی زیر مخالف (و منطبق با استاندارد گذاشتن), شما می توانید برخی از ارزش برخی از ستون است که در یک کلید و یا کل تابع نیست (به جز عبارات ثابت). برای کار در اطراف این, شما می توانید با استفاده از ‘any’ تابع جمع (اولین مقدار مواجه می شوند) یا ‘min/max’. + +مثال: + +``` sql +SELECT + domainWithoutWWW(URL) AS domain, + count(), + any(Title) AS title -- getting the first occurred page header for each domain. +FROM hits +GROUP BY domain +``` + +برای هر مقدار کلیدی مختلف مواجه می شوند, گروه با محاسبه مجموعه ای از مقادیر تابع کل. + +گروه توسط ستون های مجموعه پشتیبانی نمی شود. + +ثابت را نمی توان به عنوان استدلال برای توابع کل مشخص شده است. مثال: مجموع(1). به جای این, شما می توانید از ثابت خلاص. مثال: `count()`. + +## پیاده سازی اطلاعات {#implementation-details} + +تجمع یکی از مهم ترین ویژگی های یک سندرم تونل کارپ ستون گرا است, و به این ترتیب اجرای یکی از قطعات به شدت بهینه سازی شده از خانه رعیتی است. به طور پیش فرض, تجمع در حافظه با استفاده از یک هش جدول انجام. این 40 + تخصص است که به طور خودکار بسته به انتخاب “grouping key” انواع داده ها. + +### گروه در حافظه خارجی {#select-group-by-in-external-memory} + +شما می توانید اطلاعات موقت تخلیه به دیسک را قادر به محدود کردن استفاده از حافظه در طول `GROUP BY`. +این [ا\_فزون\_بر\_گونهی\_گونهی زیر\_گروهها](../../../operations/settings/settings.md#settings-max_bytes_before_external_group_by) تنظیم تعیین کننده مصرف رم را برای تخلیه می کند `GROUP BY` اطلاعات موقت به سیستم فایل. اگر به 0 (به طور پیش فرض), غیر فعال است. + +هنگام استفاده از `max_bytes_before_external_group_by`, توصیه می کنیم که به شما در تنظیم `max_memory_usage` در مورد دو برابر بالا. این لازم است زیرا دو مرحله برای تجمع وجود دارد: خواندن داده ها و تشکیل داده های متوسط (1) و ادغام داده های متوسط (2). واژگون اطلاعات به سیستم فایل تنها می تواند در طول مرحله رخ می دهد 1. اگر داده های موقت ریخته نمی شد, سپس مرحله 2 ممکن است نیاز به همان مقدار از حافظه در مرحله 1. + +برای مثال اگر [\_کاساژ بیشینه](../../../operations/settings/settings.md#settings_max_memory_usage) به 1000000000 تنظیم شد و شما می خواهید به استفاده از تجمع خارجی, این را حس می کند به مجموعه `max_bytes_before_external_group_by` به 10000000000 و `max_memory_usage` به 20000000000. هنگامی که تجمع خارجی باعث شده است (اگر حداقل یک روگرفت از داده های موقت وجود دارد), حداکثر مصرف رم تنها کمی بیشتر از `max_bytes_before_external_group_by`. + +با پردازش پرس و جو توزیع, تجمع خارجی بر روی سرور از راه دور انجام. به منظور سرور درخواست به استفاده از تنها مقدار کمی از رم, تنظیم `distributed_aggregation_memory_efficient` به 1. + +هنگامی که ادغام داده ها به دیسک سرخ, و همچنین زمانی که ادغام نتایج حاصل از سرور از راه دور زمانی که `distributed_aggregation_memory_efficient` تنظیم فعال است, مصرف تا `1/256 * the_number_of_threads` از مقدار کل رم. + +هنگامی که تجمع خارجی فعال است, اگر کمتر از وجود دارد `max_bytes_before_external_group_by` of data (i.e. data was not flushed), the query runs just as fast as without external aggregation. If any temporary data was flushed, the run time will be several times longer (approximately three times). + +اگر شما یک [ORDER BY](order-by.md) با یک [LIMIT](limit.md) پس از `GROUP BY`, سپس مقدار رم استفاده می شود بستگی به مقدار داده ها در `LIMIT` نه تو کل میز اما اگر `ORDER BY` ندارد `LIMIT` فراموش نکنید که مرتب سازی خارجی را فعال کنید (`max_bytes_before_external_sort`). diff --git a/docs/fa/sql-reference/statements/select/having.md b/docs/fa/sql-reference/statements/select/having.md new file mode 100644 index 00000000000..56578743339 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/having.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# داشتن بند {#having-clause} + +اجازه می دهد تا فیلتر کردن نتایج تجمع تولید شده توسط [GROUP BY](group-by.md). این شبیه به [WHERE](where.md) بند, اما تفاوت این است که `WHERE` قبل از تجمع انجام, در حالی که `HAVING` بعد از اون انجام میشه + +ممکن است که به مرجع نتایج تجمع از `SELECT` بند در `HAVING` بند با نام مستعار خود. متناوبا, `HAVING` بند می تواند بر روی نتایج مصالح اضافی است که در نتایج پرس و جو بازگشت فیلتر کنید. + +## محدودیت ها {#limitations} + +`HAVING` نمی توان مورد استفاده قرار گیرد اگر تجمع انجام نشده است. استفاده `WHERE` در عوض diff --git a/docs/fa/sql-reference/statements/select/index.md b/docs/fa/sql-reference/statements/select/index.md new file mode 100644 index 00000000000..d919751dd37 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/index.md @@ -0,0 +1,158 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: SELECT +--- + +# نحو نمایش داده شد را انتخاب کنید {#select-queries-syntax} + +`SELECT` بازیابی داده ها را انجام می دهد. + +``` sql +[WITH expr_list|(subquery)] +SELECT [DISTINCT] expr_list +[FROM [db.]table | (subquery) | table_function] [FINAL] +[SAMPLE sample_coeff] +[ARRAY JOIN ...] +[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list +[PREWHERE expr] +[WHERE expr] +[GROUP BY expr_list] [WITH TOTALS] +[HAVING expr] +[ORDER BY expr_list] +[LIMIT [offset_value, ]n BY columns] +[LIMIT [n, ]m] +[UNION ALL ...] +[INTO OUTFILE filename] +[FORMAT format] +``` + +همه بند اختیاری هستند, به جز برای لیست مورد نیاز از عبارات بلافاصله پس از `SELECT` که بیشتر تحت پوشش است [در زیر](#select-clause). + +ویژگی های هر بند اختیاری در بخش های جداگانه تحت پوشش, که در همان جهت ذکر شده که اجرا می شوند: + +- [با بند](with.md) +- [بند مجزا](distinct.md) +- [از بند](from.md) +- [بند نمونه](sample.md) +- [پیوستن بند](join.md) +- [در بند](prewhere.md) +- [بند کجا](where.md) +- [گروه بر اساس بند](group-by.md) +- [محدود کردن بند](limit-by.md) +- [داشتن بند](having.md) +- [انتخاب بند](#select-clause) +- [بند محدود](limit.md) +- [اتحادیه همه بند](union-all.md) + +## انتخاب بند {#select-clause} + +[عبارتها](../../syntax.md#syntax-expressions) مشخص شده در `SELECT` بند بعد از تمام عملیات در بند بالا توضیح محاسبه به پایان رسید. این عبارات کار می کنند به عنوان اگر به ردیف جداگانه در نتیجه اعمال می شود. اگر عبارات در `SELECT` بند شامل مجموع توابع سپس ClickHouse فرآیندهای کل توابع و عبارات استفاده می شود به عنوان استدلال های خود را در طول [GROUP BY](group-by.md) تجمع. + +اگر شما می خواهید که شامل تمام ستون ها در نتیجه, استفاده از ستاره (`*`) نماد. به عنوان مثال, `SELECT * FROM ...`. + +برای مطابقت با برخی از ستون ها در نتیجه با یک [شماره 2](https://en.wikipedia.org/wiki/RE2_(software)) عبارت منظم می توانید از `COLUMNS` اصطلاح. + +``` sql +COLUMNS('regexp') +``` + +برای مثال جدول را در نظر بگیرید: + +``` sql +CREATE TABLE default.col_names (aa Int8, ab Int8, bc Int8) ENGINE = TinyLog +``` + +پرس و جو زیر داده ها را از تمام ستون های حاوی `a` نماد به نام خود. + +``` sql +SELECT COLUMNS('a') FROM col_names +``` + +``` text +┌─aa─┬─ab─┐ +│ 1 │ 1 │ +└────┴────┘ +``` + +ستون های انتخاب شده به ترتیب حروف الفبا بازگردانده نمی شوند. + +شما می توانید چند استفاده کنید `COLUMNS` عبارات در پرس و جو و اعمال توابع را به خود. + +به عنوان مثال: + +``` sql +SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names +``` + +``` text +┌─aa─┬─ab─┬─bc─┬─toTypeName(bc)─┐ +│ 1 │ 1 │ 1 │ Int8 │ +└────┴────┴────┴────────────────┘ +``` + +هر ستون توسط `COLUMNS` بیان به تابع به عنوان یک استدلال جداگانه منتقل می شود. همچنین شما می توانید استدلال های دیگر به تابع منتقل می کند اگر از. مراقب باشید در هنگام استفاده از توابع. اگر یک تابع تعداد استدلال شما را به تصویب را پشتیبانی نمی کند, خانه عروسکی می اندازد یک استثنا. + +به عنوان مثال: + +``` sql +SELECT COLUMNS('a') + COLUMNS('c') FROM col_names +``` + +``` text +Received exception from server (version 19.14.1): +Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of arguments for function plus doesn't match: passed 3, should be 2. +``` + +در این مثال, `COLUMNS('a')` بازگرداندن دو ستون: `aa` و `ab`. `COLUMNS('c')` بازگرداندن `bc` ستون. این `+` اپراتور نمی تواند به اعمال 3 استدلال, بنابراین تاتر می اندازد یک استثنا با پیام مربوطه. + +ستون که همسان `COLUMNS` بیان می تواند انواع داده های مختلف داشته باشد. اگر `COLUMNS` هیچ ستون مطابقت ندارد و تنها بیان در است `SELECT`, فاحشه خانه می اندازد یک استثنا. + +### ستاره {#asterisk} + +شما می توانید یک ستاره در هر بخشی از یک پرس و جو به جای بیان قرار داده است. هنگامی که پرس و جو تجزیه و تحلیل, ستاره به یک لیست از تمام ستون جدول گسترش (به استثنای `MATERIALIZED` و `ALIAS` ستون). تنها چند مورد وجود دارد که با استفاده از ستاره توجیه می شود: + +- هنگام ایجاد یک روگرفت جدول. +- برای جداول حاوی فقط چند ستون, مانند جداول سیستم. +- برای گرفتن اطلاعات در مورد چه ستون در یک جدول هستند. در این مورد, تنظیم `LIMIT 1`. اما بهتر است از `DESC TABLE` پرس و جو. +- هنگامی که فیلتراسیون قوی در تعداد کمی از ستون ها با استفاده از وجود دارد `PREWHERE`. +- در subqueries (از ستون های که مورد نیاز نیست برای خارجی پرس و جو از مطالعه حذف شدند subqueries). + +در تمام موارد دیگر, ما توصیه نمی با استفاده از ستاره, زیرا تنها به شما می دهد اشکالاتی از یک سندرم روده تحریک پذیر ستونی به جای مزایای. به عبارت دیگر با استفاده از ستاره توصیه نمی شود. + +### ارزش های شدید {#extreme-values} + +علاوه بر نتایج, شما همچنین می توانید حداقل و حداکثر ارزش برای ستون نتایج از. برای انجام این کار, تنظیم **افراط** تنظیم به 1. حداقل و حداکثر برای انواع عددی محاسبه, تاریخ, و تاریخ با بار. برای ستون های دیگر مقادیر پیش فرض خروجی هستند. + +An extra two rows are calculated – the minimums and maximums, respectively. These extra two rows are output in `JSON*`, `TabSeparated*` و `Pretty*` [فرشها](../../../interfaces/formats.md), جدا از ردیف های دیگر. خروجی برای فرمت های دیگر نیستند. + +داخل `JSON*` فرمت, ارزش شدید خروجی در یک جداگانه ‘extremes’ رشته. داخل `TabSeparated*` فرمت, ردیف پس از نتیجه اصلی, و بعد از ‘totals’ اگر در حال حاضر. این است که توسط یک ردیف خالی قبل (پس از داده های دیگر). داخل `Pretty*` فرمت, ردیف خروجی به عنوان یک جدول جداگانه پس از نتیجه اصلی است, و بعد از `totals` اگر در حال حاضر. + +مقادیر شدید برای ردیف قبل محاسبه می شود `LIMIT` اما بعد از `LIMIT BY`. با این حال, هنگام استفاده از `LIMIT offset, size`, ردیف قبل از `offset` در `extremes`. در درخواست جریان, نتیجه نیز ممکن است شامل تعداد کمی از ردیف که از طریق تصویب `LIMIT`. + +### یادداشتها {#notes} + +شما می توانید مترادف استفاده کنید (`AS` نام مستعار) در هر بخشی از یک پرس و جو. + +این `GROUP BY` و `ORDER BY` بند انجام استدلال موضعی را پشتیبانی نمی کند. این در تضاد خروجی زیر, اما مطابق با استاندارد گذاشتن. به عنوان مثال, `GROUP BY 1, 2` will be interpreted as grouping by constants (i.e. aggregation of all rows into one). + +## پیاده سازی اطلاعات {#implementation-details} + +اگر پرس و جو حذف `DISTINCT`, `GROUP BY` و `ORDER BY` بند و `IN` و `JOIN` کارخانه های فرعی, پرس و جو خواهد شد به طور کامل جریان پردازش, با استفاده از ای(1) مقدار رم. در غیر این صورت, پرس و جو ممکن است مقدار زیادی از رم مصرف اگر محدودیت های مناسب مشخص نشده است: + +- `max_memory_usage` +- `max_rows_to_group_by` +- `max_rows_to_sort` +- `max_rows_in_distinct` +- `max_bytes_in_distinct` +- `max_rows_in_set` +- `max_bytes_in_set` +- `max_rows_in_join` +- `max_bytes_in_join` +- `max_bytes_before_external_sort` +- `max_bytes_before_external_group_by` + +برای کسب اطلاعات بیشتر به بخش مراجعه کنید “Settings”. ممکن است که به استفاده از مرتب سازی خارجی (صرفه جویی در جداول موقت به یک دیسک) و تجمع خارجی. + +{## [مقاله اصلی](https://clickhouse.tech/docs/en/sql-reference/statements/select/) ##} diff --git a/docs/fa/sql-reference/statements/select/into-outfile.md b/docs/fa/sql-reference/statements/select/into-outfile.md new file mode 100644 index 00000000000..cdb428b4d08 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/into-outfile.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# به OUTFILE بند {#into-outfile-clause} + +افزودن `INTO OUTFILE filename` بند (جایی که نام فایل یک رشته تحت اللفظی است) به `SELECT query` برای تغییر مسیر خروجی خود را به فایل مشخص شده در سمت سرویس گیرنده. + +## پیاده سازی اطلاعات {#implementation-details} + +- این قابلیت در دسترس است [مشتری خط فرمان](../../../interfaces/cli.md) و [کلیک-محلی](../../../operations/utilities/clickhouse-local.md). بنابراین پرس و جو از طریق ارسال [رابط قام](../../../interfaces/http.md) شکست مواجه خواهد شد. +- پرس و جو شکست مواجه خواهد شد اگر یک فایل با نام فایل مشابه در حال حاضر وجود دارد. +- پیشفرض [فرمت خروجی](../../../interfaces/formats.md) هست `TabSeparated` (مانند در خط فرمان حالت دسته ای مشتری). diff --git a/docs/fa/sql-reference/statements/select/join.md b/docs/fa/sql-reference/statements/select/join.md new file mode 100644 index 00000000000..21e19c124fd --- /dev/null +++ b/docs/fa/sql-reference/statements/select/join.md @@ -0,0 +1,191 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# پیوستن بند {#select-join} + +اضافه کردن تولید یک جدول جدید با ترکیب ستون از یک یا چند جدول با استفاده از مقادیر مشترک به هر. این یک عملیات مشترک در پایگاه داده با پشتیبانی از گذاشتن است, که مربوط به [جبر رابطه ای](https://en.wikipedia.org/wiki/Relational_algebra#Joins_and_join-like_operators) ملحق شو مورد خاص یک جدول پیوستن است که اغلب به عنوان اشاره “self-join”. + +نحو: + +``` sql +SELECT +FROM +[GLOBAL] [ANY|ALL|ASOF] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER|SEMI|ANTI] JOIN +(ON )|(USING ) ... +``` + +عبارات از `ON` بند و ستون از `USING` بند نامیده می شوند “join keys”. مگر در مواردی که در غیر این صورت اعلام, پیوستن به تولید یک [محصول دکارتی](https://en.wikipedia.org/wiki/Cartesian_product) از ردیف با تطبیق “join keys”, که ممکن است نتایج را با ردیف خیلی بیشتر از جداول منبع تولید. + +## انواع پشتیبانی شده از پیوستن {#select-join-types} + +همه استاندارد [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) انواع پشتیبانی می شوند: + +- `INNER JOIN`, تنها ردیف تطبیق برگردانده می شوند. +- `LEFT OUTER JOIN`, ردیف غیر تطبیق از جدول سمت چپ علاوه بر تطبیق ردیف بازگشت. +- `RIGHT OUTER JOIN`, ردیف غیر تطبیق از جدول سمت چپ علاوه بر تطبیق ردیف بازگشت. +- `FULL OUTER JOIN`, ردیف غیر تطبیق از هر دو جدول علاوه بر تطبیق ردیف بازگشت. +- `CROSS JOIN`, تولید محصول دکارتی از تمام جداول, “join keys” هستند **نه** مشخص. + +`JOIN` بدون نوع مشخص نشان میدهد `INNER`. کلیدواژه `OUTER` می توان با خیال راحت حذف. نحو جایگزین برای `CROSS JOIN` مشخص جداول چندگانه در [از بند](from.md) جدا شده توسط کاما. + +پیوستن به انواع اضافی موجود در کلیک: + +- `LEFT SEMI JOIN` و `RIGHT SEMI JOIN`, یک لیست سفید در “join keys”, بدون تولید محصول دکارتی. +- `LEFT ANTI JOIN` و `RIGHT ANTI JOIN`, لیست سیاه در “join keys”, بدون تولید محصول دکارتی. + +## سختی {#select-join-strictness} + +تغییر چگونگی تطبیق توسط “join keys” انجام شده است + +- `ALL` — The standard `JOIN` رفتار در گذاشتن همانطور که در بالا توضیح. به طور پیش فرض. +- `ANY` — Partially (for opposite side of `LEFT` و `RIGHT`) یا به طور کامل (برای `INNER` و `FULL`) غیر فعال محصول دکارتی برای استاندارد `JOIN` انواع. +- `ASOF` — For joining sequences with a non-exact match. `ASOF JOIN` استفاده در زیر توضیح داده شده است. + +!!! note "یادداشت" + مقدار سختگیرانه پیش فرض را می توان با استفاده از لغو [بررسی اجمالی](../../../operations/settings/settings.md#settings-join_default_strictness) تنظیمات. + +### از این رو پیوستن به استفاده {#asof-join-usage} + +`ASOF JOIN` مفید است زمانی که شما نیاز به پیوستن به سوابق که هیچ بازی دقیق. + +جداول برای `ASOF JOIN` باید یک ستون توالی دستور داده اند. این ستون نمی تواند به تنهایی در یک جدول باشد و باید یکی از انواع داده ها باشد: `UInt32`, `UInt64`, `Float32`, `Float64`, `Date` و `DateTime`. + +نحو `ASOF JOIN ... ON`: + +``` sql +SELECT expressions_list +FROM table_1 +ASOF LEFT JOIN table_2 +ON equi_cond AND closest_match_cond +``` + +شما می توانید هر تعداد از شرایط برابری و دقیقا یکی از نزدیک ترین شرایط بازی استفاده کنید. به عنوان مثال, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`. + +شرایط پشتیبانی شده برای نزدیک ترین بازی: `>`, `>=`, `<`, `<=`. + +نحو `ASOF JOIN ... USING`: + +``` sql +SELECT expressions_list +FROM table_1 +ASOF JOIN table_2 +USING (equi_column1, ... equi_columnN, asof_column) +``` + +`ASOF JOIN` استفاده `equi_columnX` برای پیوستن به برابری و `asof_column` برای پیوستن به نزدیک ترین مسابقه با `table_1.asof_column >= table_2.asof_column` شرط. این `asof_column` ستون همیشه یکی از گذشته در `USING` بند بند. + +مثلا, جداول زیر را در نظر بگیرید: + + table_1 table_2 + event | ev_time | user_id event | ev_time | user_id + ----------|---------|---------- ----------|---------|---------- + ... ... + event_1_1 | 12:00 | 42 event_2_1 | 11:59 | 42 + ... event_2_2 | 12:30 | 42 + event_1_2 | 13:00 | 42 event_2_3 | 13:00 | 42 + ... ... + +`ASOF JOIN` می توانید برچسب زمان از یک رویداد کاربر از را `table_1` و پیدا کردن یک رویداد در `table_2` جایی که برچسب زمان نزدیک به زمان این رویداد از `table_1` مربوط به نزدیک ترین شرایط بازی. مقادیر برچسب زمان برابر نزدیک ترین در صورت موجود بودن. اینجا `user_id` ستون را می توان برای پیوستن به برابری و `ev_time` ستون را می توان برای پیوستن به در نزدیک ترین بازی استفاده می شود. در مثال ما, `event_1_1` می توان با پیوست `event_2_1` و `event_1_2` می توان با پیوست `event_2_3` اما `event_2_2` نمیشه عضو شد + +!!! note "یادداشت" + `ASOF` پیوستن است **نه** پردازشگر پشتیبانی شده: [پیوستن](../../../engines/table-engines/special/join.md) موتور جدول. + +## توزیع پیوستن {#global-join} + +دو راه برای اجرای پیوستن به جداول توزیع شده وجود دارد: + +- هنگام استفاده از نرمال `JOIN` پرس و جو به سرورهای راه دور ارسال می شود. زیرکریزها روی هر کدام اجرا می شوند تا میز مناسب را بسازند و پیوستن با این جدول انجام می شود. به عبارت دیگر, جدول سمت راست بر روی هر سرور تشکیل به طور جداگانه. +- هنگام استفاده از `GLOBAL ... JOIN`, اول سرور درخواست کننده اجرا می شود یک خرده فروشی برای محاسبه جدول سمت راست. این جدول موقت به هر سرور از راه دور منتقل می شود و نمایش داده می شود با استفاده از داده های موقت منتقل می شود. + +مراقب باشید در هنگام استفاده از `GLOBAL`. برای کسب اطلاعات بیشتر, دیدن [توزیع subqueries](../../operators/in.md#select-distributed-subqueries) بخش. + +## توصیه های استفاده {#usage-recommendations} + +### پردازش سلولهای خالی یا خالی {#processing-of-empty-or-null-cells} + +در حالی که پیوستن به جداول سلول های خالی ظاهر می شود. تنظیمات [ارزشهای خبری عبارتند از:](../../../operations/settings/settings.md#join_use_nulls) تعریف چگونه خانه را پر می کند این سلول ها. + +اگر `JOIN` کلید ها [Nullable](../../data-types/nullable.md) زمینه, ردیف که حداقل یکی از کلید های دارای ارزش [NULL](../../../sql-reference/syntax.md#null-literal) عضو نشده. + +### نحو {#syntax} + +ستون های مشخص شده در `USING` باید نام های مشابه در هر دو کارخانه های فرعی دارند, و ستون های دیگر باید متفاوت به نام. شما می توانید نام مستعار برای تغییر نام ستون ها در زیرکریز استفاده کنید. + +این `USING` بند یک یا چند ستون برای پیوستن به مشخص, که ایجاد برابری این ستون. لیست ستون ها بدون براکت تنظیم شده است. شرایط پیوستن پیچیده تر پشتیبانی نمی شوند. + +### محدودیت نحو {#syntax-limitations} + +برای چند `JOIN` بند در یک `SELECT` پرسوجو: + +- گرفتن تمام ستون ها از طریق `*` در دسترس است تنها اگر جداول پیوست, نمی فرعی. +- این `PREWHERE` بند در دسترس نیست. + +برای `ON`, `WHERE` و `GROUP BY` بند: + +- عبارات دلخواه را نمی توان در `ON`, `WHERE` و `GROUP BY` بند, اما شما می توانید یک عبارت در یک تعریف `SELECT` بند و سپس در این بند از طریق یک نام مستعار استفاده کنید. + +### عملکرد {#performance} + +هنگامی که در حال اجرا `JOIN` بهینه سازی سفارش اعدام در رابطه با سایر مراحل پرس و جو وجود ندارد. پیوستن (جستجو در جدول سمت راست) قبل از فیلتر کردن در اجرا می شود `WHERE` و قبل از تجمع. + +هر بار که پرس و جو با همان اجرا شود `JOIN`, خرده فروشی است دوباره اجرا به دلیل نتیجه ذخیره سازی نیست. برای جلوگیری از این, استفاده از ویژه [پیوستن](../../../engines/table-engines/special/join.md) موتور جدول, که مجموعه ای تهیه شده برای پیوستن است که همیشه در رم. + +در بعضی موارد کارایی بیشتری برای استفاده دارد [IN](../../operators/in.md) به جای `JOIN`. + +اگر شما نیاز به یک `JOIN` برای پیوستن به جداول بعد (این جداول نسبتا کوچک است که شامل خواص ابعاد هستند, مانند نام برای کمپین های تبلیغاتی), یک `JOIN` ممکن است بسیار مناسب با توجه به این واقعیت است که جدول سمت راست برای هر پرس و جو دوباره قابل دسترسی است. برای چنین مواردی وجود دارد “external dictionaries” ویژگی است که شما باید به جای استفاده از `JOIN`. برای کسب اطلاعات بیشتر, دیدن [واژهنامهها خارجی](../../dictionaries/external-dictionaries/external-dicts.md) بخش. + +### محدودیت حافظه {#memory-limitations} + +به طور پیش فرض, تاتر با استفاده از [هش پیوستن](https://en.wikipedia.org/wiki/Hash_join) الگوریتم. تاتر طول می کشد `` و یک جدول هش را در رم ایجاد می کند. پس از برخی از حد مصرف حافظه, خانه رعیتی می افتد به ادغام پیوستن الگوریتم. + +اگر شما نیاز به محدود کردن پیوستن به مصرف حافظه عملیات استفاده از تنظیمات زیر: + +- [\_پاک کردن \_روشن گرافیک](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) — Limits number of rows in the hash table. +- [\_پویش همیشگی](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) — Limits size of the hash table. + +هنگامی که هر یک از این محدودیت رسیده است, کلیک به عنوان عمل می کند [\_شروع مجدد](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) تنظیم دستور. + +## مثالها {#examples} + +مثال: + +``` sql +SELECT + CounterID, + hits, + visits +FROM +( + SELECT + CounterID, + count() AS hits + FROM test.hits + GROUP BY CounterID +) ANY LEFT JOIN +( + SELECT + CounterID, + sum(Sign) AS visits + FROM test.visits + GROUP BY CounterID +) USING CounterID +ORDER BY hits DESC +LIMIT 10 +``` + +``` text +┌─CounterID─┬───hits─┬─visits─┐ +│ 1143050 │ 523264 │ 13665 │ +│ 731962 │ 475698 │ 102716 │ +│ 722545 │ 337212 │ 108187 │ +│ 722889 │ 252197 │ 10547 │ +│ 2237260 │ 196036 │ 9522 │ +│ 23057320 │ 147211 │ 7689 │ +│ 722818 │ 90109 │ 17847 │ +│ 48221 │ 85379 │ 4652 │ +│ 19762435 │ 77807 │ 7026 │ +│ 722884 │ 77492 │ 11056 │ +└───────────┴────────┴────────┘ +``` diff --git a/docs/fa/sql-reference/statements/select/limit-by.md b/docs/fa/sql-reference/statements/select/limit-by.md new file mode 100644 index 00000000000..295b98090bc --- /dev/null +++ b/docs/fa/sql-reference/statements/select/limit-by.md @@ -0,0 +1,71 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# محدود کردن بند {#limit-by-clause} + +پرس و جو با `LIMIT n BY expressions` بند اول را انتخاب می کند `n` ردیف برای هر مقدار مجزا از `expressions`. کلید برای `LIMIT BY` می تواند شامل هر تعداد از [عبارتها](../../syntax.md#syntax-expressions). + +تاتر از انواع نحو زیر: + +- `LIMIT [offset_value, ]n BY expressions` +- `LIMIT n OFFSET offset_value BY expressions` + +در طول پردازش پرس و جو, خانه را انتخاب داده دستور داد با مرتب سازی کلید. کلید مرتب سازی به صراحت با استفاده از یک مجموعه [ORDER BY](order-by.md) بند یا به طور ضمنی به عنوان یک ویژگی از موتور جدول. سپس کلیک کنیداوس اعمال می شود `LIMIT n BY expressions` و اولین را برمی گرداند `n` ردیف برای هر ترکیب مجزا از `expressions`. اگر `OFFSET` مشخص شده است, سپس برای هر بلوک داده که متعلق به یک ترکیب متمایز از `expressions`. `offset_value` تعداد ردیف از ابتدای بلوک و حداکثر می گرداند `n` ردیف به عنوان یک نتیجه. اگر `offset_value` بزرگتر از تعدادی از ردیف در بلوک داده است, کلیک بازگشت صفر ردیف از بلوک. + +!!! note "یادداشت" + `LIMIT BY` مربوط به [LIMIT](limit.md). هر دو را می توان در همان پرس و جو استفاده کرد. + +## مثالها {#examples} + +جدول نمونه: + +``` sql +CREATE TABLE limit_by(id Int, val Int) ENGINE = Memory; +INSERT INTO limit_by VALUES (1, 10), (1, 11), (1, 12), (2, 20), (2, 21); +``` + +نمایش داده شد: + +``` sql +SELECT * FROM limit_by ORDER BY id, val LIMIT 2 BY id +``` + +``` text +┌─id─┬─val─┐ +│ 1 │ 10 │ +│ 1 │ 11 │ +│ 2 │ 20 │ +│ 2 │ 21 │ +└────┴─────┘ +``` + +``` sql +SELECT * FROM limit_by ORDER BY id, val LIMIT 1, 2 BY id +``` + +``` text +┌─id─┬─val─┐ +│ 1 │ 11 │ +│ 1 │ 12 │ +│ 2 │ 21 │ +└────┴─────┘ +``` + +این `SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` پرس و جو همان نتیجه را برمی گرداند. + +پرس و جو زیر را برمی گرداند بالا 5 ارجاع برای هر `domain, device_type` جفت با حداکثر 100 ردیف در مجموع (`LIMIT n BY + LIMIT`). + +``` sql +SELECT + domainWithoutWWW(URL) AS domain, + domainWithoutWWW(REFERRER_URL) AS referrer, + device_type, + count() cnt +FROM hits +GROUP BY domain, referrer, device_type +ORDER BY cnt DESC +LIMIT 5 BY domain, device_type +LIMIT 100 +``` diff --git a/docs/fa/sql-reference/statements/select/limit.md b/docs/fa/sql-reference/statements/select/limit.md new file mode 100644 index 00000000000..5e862b2ec34 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/limit.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# بند محدود {#limit-clause} + +`LIMIT m` اجازه می دهد برای انتخاب اولین `m` ردیف از نتیجه. + +`LIMIT n, m` اجازه می دهد تا انتخاب کنید `m` ردیف از نتیجه پس از پرش برای اولین بار `n` ردیف این `LIMIT m OFFSET n` نحو معادل است. + +`n` و `m` باید اعداد صحیح غیر منفی باشد. + +اگر وجود ندارد [ORDER BY](order-by.md) بند که به صراحت انواع نتایج, انتخاب ردیف برای نتیجه ممکن است خودسرانه و غیر قطعی. diff --git a/docs/fa/sql-reference/statements/select/order-by.md b/docs/fa/sql-reference/statements/select/order-by.md new file mode 100644 index 00000000000..3cc263efcad --- /dev/null +++ b/docs/fa/sql-reference/statements/select/order-by.md @@ -0,0 +1,72 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# ORDER BY {#select-order-by} + +این `ORDER BY` بند شامل یک لیست از عبارات, که می تواند هر یک را با نسبت داده `DESC` (نزولی) یا `ASC` (صعودی) اصلاح که تعیین جهت مرتب سازی. اگر جهت مشخص نشده است, `ASC` فرض بر این است, بنابراین معمولا حذف. جهت مرتب سازی شامل یک عبارت واحد, نه به کل لیست. مثال: `ORDER BY Visits DESC, SearchPhrase` + +ردیف که مقادیر یکسان برای لیست عبارات مرتب سازی خروجی در جهت دلخواه, که همچنین می تواند غیر قطعی شود (مختلف در هر زمان). +اگر منظور توسط بند حذف شده است, منظور از ردیف نیز تعریف نشده, و ممکن است غیر قطعی و همچنین. + +## مرتب سازی مقادیر ویژه {#sorting-of-special-values} + +دو روش برای `NaN` و `NULL` مرتب سازی سفارش: + +- به طور پیش فرض و یا با `NULLS LAST` تغییردهنده: ابتدا مقادیر, سپس `NaN` پس `NULL`. +- با `NULLS FIRST` تغییردهنده: اول `NULL` پس `NaN`, سپس ارزش های دیگر. + +### مثال {#example} + +برای جدول + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 2 │ +│ 1 │ nan │ +│ 2 │ 2 │ +│ 3 │ 4 │ +│ 5 │ 6 │ +│ 6 │ nan │ +│ 7 │ ᴺᵁᴸᴸ │ +│ 6 │ 7 │ +│ 8 │ 9 │ +└───┴──────┘ +``` + +اجرای پرس و جو `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` برای دریافت: + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 7 │ ᴺᵁᴸᴸ │ +│ 1 │ nan │ +│ 6 │ nan │ +│ 2 │ 2 │ +│ 2 │ 2 │ +│ 3 │ 4 │ +│ 5 │ 6 │ +│ 6 │ 7 │ +│ 8 │ 9 │ +└───┴──────┘ +``` + +هنگامی که اعداد ممیز شناور طبقه بندی شده اند, نان جدا از ارزش های دیگر هستند. صرف نظر از نظم مرتب سازی, نان در پایان. به عبارت دیگر برای مرتب سازی صعودی قرار می گیرند همانطور که بزرگتر از همه شماره های دیگر هستند در حالی که برای مرتب سازی کوچکتر از بقیه قرار می گیرند. + +## پشتیبانی تلفیقی {#collation-support} + +برای مرتب سازی بر اساس مقادیر رشته, شما می توانید میترا مشخص (مقایسه). مثال: `ORDER BY SearchPhrase COLLATE 'tr'` - برای مرتب سازی بر اساس کلمه کلیدی به ترتیب صعودی, با استفاده از الفبای ترکی, حساس به حروف, فرض کنید که رشته ها سخن گفتن-8 کد گذاری. تلفیق می تواند مشخص شود یا نه برای هر عبارت به منظور به طور مستقل. اگر مرکز کنترل و یا مرکز کنترل خارج رحمی مشخص شده است, تلفیقی بعد از مشخص. هنگام استفاده از برخورد, مرتب سازی است که همیشه غیر حساس به حروف. + +ما فقط توصیه می کنیم با استفاده از تلفیق برای مرتب سازی نهایی تعداد کمی از ردیف, از مرتب سازی با تلفیقی کمتر موثر تر از مرتب سازی طبیعی با بایت است. + +## پیاده سازی اطلاعات {#implementation-details} + +رم کمتر استفاده می شود اگر به اندازه کافی کوچک [LIMIT](limit.md) علاوه بر مشخص شده است `ORDER BY`. در غیر این صورت, مقدار حافظه صرف متناسب با حجم داده ها برای مرتب سازی است. برای پردازش پرس و جو توزیع, اگر [GROUP BY](group-by.md) حذف شده است, مرتب سازی تا حدی بر روی سرور از راه دور انجام, و نتایج در سرور درخواست با هم ادغام شدند. این به این معنی است که برای مرتب سازی توزیع, حجم داده ها برای مرتب کردن می تواند بیشتر از مقدار حافظه بر روی یک سرور واحد. + +در صورتی که رم به اندازه کافی وجود ندارد, ممکن است به انجام مرتب سازی در حافظه خارجی (ایجاد فایل های موقت بر روی یک دیسک). از تنظیمات استفاده کنید `max_bytes_before_external_sort` برای این منظور. اگر قرار است 0 (به طور پیش فرض), مرتب سازی خارجی غیر فعال است. اگر فعال باشد, زمانی که حجم داده ها برای مرتب کردن بر اساس تعداد مشخصی از بایت می رسد, اطلاعات جمع شده مرتب شده و ریخته را به یک فایل موقت. پس از همه داده ها خوانده شده است, تمام فایل های طبقه بندی شده اند با هم ادغام شدند و نتایج خروجی. فایل ها به نوشته `/var/lib/clickhouse/tmp/` دایرکتوری در پیکربندی (به طور پیش فرض, اما شما می توانید با استفاده از `tmp_path` پارامتر برای تغییر این تنظیم). + +در حال اجرا یک پرس و جو ممکن است حافظه بیش از استفاده `max_bytes_before_external_sort`. به همین دلیل این تنظیم باید یک مقدار قابل توجهی کوچکتر از `max_memory_usage`. به عنوان مثال, اگر سرور شما 128 گیگابایت رم و شما نیاز به اجرای یک پرس و جو واحد, تنظیم `max_memory_usage` به 100 گیگابایت, و `max_bytes_before_external_sort` به 80 گیگابایت. + +مرتب سازی خارجی کار می کند بسیار کمتر به طور موثر از مرتب سازی در رم. diff --git a/docs/fa/sql-reference/statements/select/prewhere.md b/docs/fa/sql-reference/statements/select/prewhere.md new file mode 100644 index 00000000000..a729b9df86e --- /dev/null +++ b/docs/fa/sql-reference/statements/select/prewhere.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# در بند {#prewhere-clause} + +در اینجا بهینه سازی برای اعمال فیلتر موثر تر است. این به طور پیش فرض حتی اگر فعال باشد `PREWHERE` بند به صراحت مشخص نشده است. این به طور خودکار در حال حرکت بخشی از کار می کند [WHERE](where.md) شرط به مرحله قبل از کجا. نقش `PREWHERE` بند تنها برای کنترل این بهینه سازی اگر شما فکر می کنم که شما می دانید که چگونه به انجام این کار بهتر از پیش فرض اتفاق می افتد است. + +با prewhere بهینه سازی در ابتدا تنها ستون لازم برای اجرای prewhere بیان بخوانید. سپس ستون های دیگر خوانده می شوند که برای اجرای بقیه پرس و جو مورد نیاز است اما تنها بلوک هایی که بیان قبل از هر کجا است “true” حداقل برای برخی از ردیف. اگر بلوک های زیادی وجود دارد که بیان قبل از کجا است “false” برای تمام سطر و جایی نیاز ستون کمتر از سایر بخش های پرس و جو, این اغلب اجازه می دهد تا به خواندن اطلاعات بسیار کمتر از دیسک برای اجرای پرس و جو. + +## کنترل دستی {#controlling-prewhere-manually} + +بند همان معنی به عنوان `WHERE` بند بند. تفاوت در این است که داده ها از جدول خوانده می شوند. هنگامی که دستی کنترل می شود `PREWHERE` برای شرایط فیلتراسیون که توسط اقلیتی از ستون ها در پرس و جو استفاده می شود, اما که فیلتراسیون داده های قوی. این باعث کاهش حجم داده ها به خواندن. + +پرسوجو ممکن است همزمان مشخص شود `PREWHERE` و `WHERE`. در این مورد, `PREWHERE` مقدمها `WHERE`. + +اگر `optimize_move_to_prewhere` تنظیم تنظیم شده است به 0, اکتشافی به طور خودکار حرکت بخش هایی از عبارات از `WHERE` به `PREWHERE` غیرفعال می شوند. + +## محدودیت ها {#limitations} + +`PREWHERE` تنها با جداول از پشتیبانی `*MergeTree` خانواده diff --git a/docs/fa/sql-reference/statements/select/sample.md b/docs/fa/sql-reference/statements/select/sample.md new file mode 100644 index 00000000000..4f04d69b293 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/sample.md @@ -0,0 +1,113 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# بند نمونه {#select-sample-clause} + +این `SAMPLE` بند اجازه می دهد تا برای تقریب `SELECT` پردازش پرس و جو. + +هنگامی که نمونه گیری داده ها فعال است, پرس و جو بر روی تمام داده ها انجام نمی, اما تنها در بخش خاصی از داده ها (نمونه). مثلا, اگر شما نیاز به محاسبه ارقام برای تمام بازدیدکننده داشته است, کافی است برای اجرای پرس و جو در 1/10 کسری از تمام بازدیدکننده داشته است و سپس ضرب در نتیجه 10. + +پردازش پرس و جو تقریبی می تواند در موارد زیر مفید باشد: + +- هنگامی که شما شرایط زمان بندی دقیق (مانند \<100 مگابایت) اما شما نمی توانید هزینه منابع سخت افزاری اضافی را برای دیدار با خود توجیه کنید. +- هنگامی که داده های خام خود را دقیق نیست, بنابراین تقریب می کند به طرز محسوسی کاهش کیفیت. +- کسب و کار مورد نیاز هدف قرار دادن نتایج تقریبی (برای مقرون به صرفه بودن, و یا به بازار نتایج دقیق به کاربران حق بیمه). + +!!! note "یادداشت" + شما فقط می توانید نمونه برداری با استفاده از جداول در [ادغام](../../../engines/table-engines/mergetree-family/mergetree.md) خانواده, و تنها در صورتی که بیان نمونه برداری در ایجاد جدول مشخص شد (دیدن [موتور ادغام](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)). + +ویژگی های نمونه گیری داده ها به شرح زیر است: + +- نمونهگیری دادهها یک مکانیسم قطعی است. نتیجه همان `SELECT .. SAMPLE` پرس و جو همیشه یکسان است. +- نمونه گیری به طور مداوم برای جداول مختلف کار می کند. برای جداول با یک کلید نمونه برداری تک, یک نمونه با ضریب همان همیشه زیر مجموعه همان داده های ممکن را انتخاب. برای مثال یک نمونه از شناسه های کاربر طول می کشد ردیف با همان زیر مجموعه از همه ممکن است شناسه کاربر از جداول مختلف. این به این معنی است که شما می توانید نمونه در کارخانه های فرعی در استفاده از [IN](../../operators/in.md) بند بند. همچنین شما می توانید نمونه ها را با استفاده از [JOIN](join.md) بند بند. +- نمونه گیری اجازه می دهد تا خواندن اطلاعات کمتر از یک دیسک. توجه داشته باشید که شما باید کلید نمونه برداری به درستی مشخص کنید. برای کسب اطلاعات بیشتر, دیدن [ایجاد یک جدول ادغام](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). + +برای `SAMPLE` بند نحو زیر پشتیبانی می شود: + +| SAMPLE Clause Syntax | توصیف | +|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `SAMPLE k` | اینجا `k` است تعداد از 0 به 1.
پرس و جو در اجرا `k` کسری از داده ها. به عنوان مثال, `SAMPLE 0.1` پرس و جو را در 10 درصد از داده ها اجرا می کند. [ادامه مطلب](#select-sample-k) | +| `SAMPLE n` | اینجا `n` عدد صحیح به اندازه کافی بزرگ است.
پرس و جو بر روی یک نمونه از حداقل اعدام `n` ردیف (اما نه به طور قابل توجهی بیشتر از این). به عنوان مثال, `SAMPLE 10000000` پرس و جو را در حداقل ردیف های 10000000 اجرا می کند. [ادامه مطلب](#select-sample-n) | +| `SAMPLE k OFFSET m` | اینجا `k` و `m` اعداد از 0 به 1.
پرس و جو بر روی یک نمونه از اعدام `k` کسری از داده ها. داده های مورد استفاده برای نمونه توسط جبران `m` کسر کردن. [ادامه مطلب](#select-sample-offset) | + +## SAMPLE K {#select-sample-k} + +اینجا `k` است تعداد از 0 به 1 (هر دو نمادهای کسری و اعشاری پشتیبانی می شوند). به عنوان مثال, `SAMPLE 1/2` یا `SAMPLE 0.5`. + +در یک `SAMPLE k` بند, نمونه از گرفته `k` کسری از داده ها. مثال زیر نشان داده شده است: + +``` sql +SELECT + Title, + count() * 10 AS PageViews +FROM hits_distributed +SAMPLE 0.1 +WHERE + CounterID = 34 +GROUP BY Title +ORDER BY PageViews DESC LIMIT 1000 +``` + +در این مثال پرس و جو اجرا شده است در یک نمونه از 0.1 (10%) از داده ها. ارزش توابع دانه ها به طور خودکار اصلاح نمی, بنابراین برای دریافت یک نتیجه تقریبی, ارزش `count()` به صورت دستی توسط ضرب 10. + +## SAMPLE N {#select-sample-n} + +اینجا `n` عدد صحیح به اندازه کافی بزرگ است. به عنوان مثال, `SAMPLE 10000000`. + +در این مورد, پرس و جو بر روی یک نمونه از حداقل اعدام `n` ردیف (اما نه به طور قابل توجهی بیشتر از این). به عنوان مثال, `SAMPLE 10000000` پرس و جو را در حداقل ردیف های 10000000 اجرا می کند. + +از حداقل واحد برای خواندن داده ها یک گرانول است (اندازه خود را توسط مجموعه `index_granularity` تنظیم), این را حس می کند به مجموعه ای از یک نمونه است که بسیار بزرگتر از اندازه گرانول. + +هنگام استفاده از `SAMPLE n` بند, شما نمی دانید که درصد نسبی داده پردازش شد. بنابراین شما نمی دانید ضریب توابع کل باید توسط ضرب. استفاده از `_sample_factor` ستون مجازی برای دریافت نتیجه تقریبی. + +این `_sample_factor` ستون شامل ضرایب نسبی است که به صورت پویا محاسبه می شود. این ستون به طور خودکار ایجاد زمانی که شما [ایجاد](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) یک جدول با کلید نمونه گیری مشخص. نمونه های استفاده از `_sample_factor` ستون در زیر نشان داده شده. + +بیایید جدول را در نظر بگیریم `visits`, که شامل ارقام در مورد بازدیدکننده داشته است سایت. مثال اول نشان می دهد که چگونه برای محاسبه تعداد بازدید از صفحه: + +``` sql +SELECT sum(PageViews * _sample_factor) +FROM visits +SAMPLE 10000000 +``` + +مثال بعدی نشان می دهد که چگونه برای محاسبه تعداد کل بازدیدکننده داشته است: + +``` sql +SELECT sum(_sample_factor) +FROM visits +SAMPLE 10000000 +``` + +مثال زیر نشان می دهد که چگونه برای محاسبه مدت زمان جلسه به طور متوسط. توجه داشته باشید که شما لازم نیست به استفاده از ضریب نسبی برای محاسبه مقادیر متوسط. + +``` sql +SELECT avg(Duration) +FROM visits +SAMPLE 10000000 +``` + +## SAMPLE K OFFSET M {#select-sample-offset} + +اینجا `k` و `m` اعداد از 0 به 1. نمونه های زیر نشان داده شده. + +**مثال 1** + +``` sql +SAMPLE 1/10 +``` + +در این مثال نمونه 1 / 10 از تمام داده ها است: + +`[++------------]` + +**مثال 2** + +``` sql +SAMPLE 1/10 OFFSET 1/2 +``` + +در اینجا یک نمونه از 10 درصد گرفته شده از نیمه دوم از داده ها. + +`[------++------]` diff --git a/docs/fa/sql-reference/statements/select/union-all.md b/docs/fa/sql-reference/statements/select/union-all.md new file mode 100644 index 00000000000..3c4fe5c1546 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/union-all.md @@ -0,0 +1,35 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# اتحادیه همه بند {#union-all-clause} + +شما می توانید استفاده کنید `UNION ALL` برای ترکیب هر تعداد از `SELECT` نمایش داده شد با گسترش نتایج خود را. مثال: + +``` sql +SELECT CounterID, 1 AS table, toInt64(count()) AS c + FROM test.hits + GROUP BY CounterID + +UNION ALL + +SELECT CounterID, 2 AS table, sum(Sign) AS c + FROM test.visits + GROUP BY CounterID + HAVING c > 0 +``` + +ستون نتیجه با شاخص خود را همسان (سفارش در داخل `SELECT`). اگر نام ستون مطابقت ندارند, نام برای نتیجه نهایی از پرس و جو برای اولین بار گرفته شده. + +نوع ریخته گری برای اتحادیه انجام می شود. برای مثال اگر دو نمایش داده شد در حال ترکیب باید همین زمینه را با غیر-`Nullable` و `Nullable` انواع از یک نوع سازگار, در نتیجه `UNION ALL` دارای یک `Nullable` نوع درست. + +نمایش داده شد که بخش هایی از `UNION ALL` نمی توان در براکت های گرد محصور کرد. [ORDER BY](order-by.md) و [LIMIT](limit.md) برای نمایش داده شد جداگانه به نتیجه نهایی اعمال می شود. اگر شما نیاز به اعمال تبدیل به نتیجه نهایی شما می توانید تمام نمایش داده شد با قرار دادن `UNION ALL` در یک خرده فروشی در [FROM](from.md) بند بند. + +## محدودیت ها {#limitations} + +فقط `UNION ALL` پشتیبانی می شود. منظم `UNION` (`UNION DISTINCT`) پشتیبانی نمی شود . اگر شما نیاز دارید `UNION DISTINCT`, شما می توانید ارسال `SELECT DISTINCT` از زیرخاکری حاوی `UNION ALL`. + +## پیاده سازی اطلاعات {#implementation-details} + +نمایش داده شد که بخش هایی از `UNION ALL` می توان به طور همزمان اجرا, و نتایج خود را می توان با هم مخلوط. diff --git a/docs/fa/sql-reference/statements/select/where.md b/docs/fa/sql-reference/statements/select/where.md new file mode 100644 index 00000000000..c9a55304421 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/where.md @@ -0,0 +1,15 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# بند کجا {#select-where} + +`WHERE` بند اجازه می دهد تا برای فیلتر کردن داده ها است که از [FROM](from.md) بند `SELECT`. + +اگر وجود دارد `WHERE` بند, باید حاوی یک عبارت با `UInt8` نوع. این است که معمولا بیان با مقایسه و اپراتورهای منطقی. ردیف هایی که این عبارت به 0 ارزیابی می شود از تحولات یا نتیجه بیشتر توضیح داده می شود. + +`WHERE` بیان بر توانایی استفاده از شاخص ها و هرس پارتیشن ارزیابی, اگر موتور جدول زمینه ای پشتیبانی می کند که. + +!!! note "یادداشت" + یک بهینه سازی فیلتر به نام وجود دارد [کجا](prewhere.md). diff --git a/docs/fa/sql-reference/statements/select/with.md b/docs/fa/sql-reference/statements/select/with.md new file mode 100644 index 00000000000..4c14386b881 --- /dev/null +++ b/docs/fa/sql-reference/statements/select/with.md @@ -0,0 +1,80 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +--- + +# با بند {#with-clause} + +در این بخش پشتیبانی از عبارات جدول مشترک فراهم می کند ([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL)), بنابراین نتایج حاصل از `WITH` بند را می توان در داخل استفاده کرد `SELECT` بند بند. + +## محدودیت ها {#limitations} + +1. نمایش داده شد بازگشتی پشتیبانی نمی شوند. +2. هنگامی که زیرخاکری در داخل با بخش استفاده می شود, این نتیجه باید اسکالر با دقیقا یک ردیف باشد. +3. نتایج بیان در زیرمجموعه ها در دسترس نیست. + +## مثالها {#examples} + +**مثال 1:** استفاده از عبارت ثابت به عنوان “variable” + +``` sql +WITH '2019-08-01 15:23:00' as ts_upper_bound +SELECT * +FROM hits +WHERE + EventDate = toDate(ts_upper_bound) AND + EventTime <= ts_upper_bound +``` + +**مثال 2:** جمع مبلغ (بایت) بیان نتیجه از بند لیست ستون را انتخاب کنید + +``` sql +WITH sum(bytes) as s +SELECT + formatReadableSize(s), + table +FROM system.parts +GROUP BY table +ORDER BY s +``` + +**مثال 3:** استفاده از نتایج حاصل از زیرکواری اسکالر + +``` sql +/* this example would return TOP 10 of most huge tables */ +WITH + ( + SELECT sum(bytes) + FROM system.parts + WHERE active + ) AS total_disk_usage +SELECT + (sum(bytes) / total_disk_usage) * 100 AS table_disk_usage, + table +FROM system.parts +GROUP BY table +ORDER BY table_disk_usage DESC +LIMIT 10 +``` + +**مثال 4:** استفاده مجدد از عبارت در زیرخاکری + +به عنوان یک راه حل برای محدودیت فعلی برای استفاده بیان در زیر مجموعه, شما ممکن است تکراری. + +``` sql +WITH ['hello'] AS hello +SELECT + hello, + * +FROM +( + WITH ['hello'] AS hello + SELECT hello +) +``` + +``` text +┌─hello─────┬─hello─────┐ +│ ['hello'] │ ['hello'] │ +└───────────┴───────────┘ +``` diff --git a/docs/fa/sql-reference/statements/show.md b/docs/fa/sql-reference/statements/show.md new file mode 100644 index 00000000000..57e8b90361d --- /dev/null +++ b/docs/fa/sql-reference/statements/show.md @@ -0,0 +1,169 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: SHOW +--- + +# نمایش & پرسوجو {#show-queries} + +## SHOW CREATE TABLE {#show-create-table} + +``` sql +SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +بازگرداندن یک `String`- نوع ‘statement’ column, which contains a single value – the `CREATE` پرس و جو مورد استفاده برای ایجاد شی مشخص شده است. + +## SHOW DATABASES {#show-databases} + +``` sql +SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] +``` + +چاپ یک لیست از تمام پایگاه های داده. +این پرس و جو یکسان است `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. + +## SHOW PROCESSLIST {#show-processlist} + +``` sql +SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] +``` + +خروجی محتوای [سیستم.فرایندها](../../operations/system-tables.md#system_tables-processes) جدول, که شامل یک لیست از نمایش داده شد که در حال حاضر پردازش, به استثنای `SHOW PROCESSLIST` نمایش داده شد. + +این `SELECT * FROM system.processes` پرس و جو داده ها در مورد تمام نمایش داده شد در حال حاضر را برمی گرداند. + +نکته (اجرا در کنسول): + +``` bash +$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" +``` + +## SHOW TABLES {#show-tables} + +نمایش یک لیست از جداول. + +``` sql +SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +اگر `FROM` بند مشخص نشده است, پرس و جو لیستی از جداول گرداند از پایگاه داده فعلی. + +شما می توانید نتایج مشابه را دریافت کنید `SHOW TABLES` پرسوجو به روش زیر: + +``` sql +SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**مثال** + +پرس و جو زیر انتخاب دو ردیف اول از لیست جداول در `system` پایگاه داده, که نام حاوی `co`. + +``` sql +SHOW TABLES FROM system LIKE '%co%' LIMIT 2 +``` + +``` text +┌─name───────────────────────────┐ +│ aggregate_function_combinators │ +│ collations │ +└────────────────────────────────┘ +``` + +## SHOW DICTIONARIES {#show-dictionaries} + +نمایش یک لیست از [واژهنامهها خارجی](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +``` sql +SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +اگر `FROM` بند مشخص نشده است, پرس و جو لیستی از لغت نامه ها را برمی گرداند از پایگاه داده در حال حاضر. + +شما می توانید نتایج مشابه را دریافت کنید `SHOW DICTIONARIES` پرسوجو به روش زیر: + +``` sql +SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**مثال** + +پرس و جو زیر انتخاب دو ردیف اول از لیست جداول در `system` پایگاه داده, که نام حاوی `reg`. + +``` sql +SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 +``` + +``` text +┌─name─────────┐ +│ regions │ +│ region_names │ +└──────────────┘ +``` + +## SHOW GRANTS {#show-grants-statement} + +نشان می دهد امتیازات برای یک کاربر. + +### نحو {#show-grants-syntax} + +``` sql +SHOW GRANTS [FOR user] +``` + +اگر کاربر مشخص نشده است, پرس و جو امتیازات برای کاربر فعلی را برمی گرداند. + +## SHOW CREATE USER {#show-create-user-statement} + +پارامترهای که در یک مورد استفاده قرار گرفت را نشان می دهد [ایجاد کاربر](create.md#create-user-statement). + +`SHOW CREATE USER` رمزهای عبور کاربر خروجی نیست. + +### نحو {#show-create-user-syntax} + +``` sql +SHOW CREATE USER [name | CURRENT_USER] +``` + +## SHOW CREATE ROLE {#show-create-role-statement} + +پارامترهای که در یک مورد استفاده قرار گرفت را نشان می دهد [ایجاد نقش](create.md#create-role-statement) + +### نحو {#show-create-role-syntax} + +``` sql +SHOW CREATE ROLE name +``` + +## SHOW CREATE ROW POLICY {#show-create-row-policy-statement} + +پارامترهای که در یک مورد استفاده قرار گرفت را نشان می دهد [ایجاد خط مشی سطر](create.md#create-row-policy-statement) + +### نحو {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE [ROW] POLICY name ON [database.]table +``` + +## SHOW CREATE QUOTA {#show-create-quota-statement} + +پارامترهای که در یک مورد استفاده قرار گرفت را نشان می دهد [ایجاد سهمیه](create.md#create-quota-statement) + +### نحو {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE QUOTA [name | CURRENT] +``` + +## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile-statement} + +پارامترهای که در یک مورد استفاده قرار گرفت را نشان می دهد [تنظیمات ایجاد پروفایل](create.md#create-settings-profile-statement) + +### نحو {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE [SETTINGS] PROFILE name +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/fa/sql-reference/statements/system.md b/docs/fa/sql-reference/statements/system.md new file mode 100644 index 00000000000..386bf982235 --- /dev/null +++ b/docs/fa/sql-reference/statements/system.md @@ -0,0 +1,113 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: SYSTEM +--- + +# نمایش داده شد سیستم {#query-language-system} + +- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) +- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) +- [DROP DNS CACHE](#query_language-system-drop-dns-cache) +- [DROP MARK CACHE](#query_language-system-drop-mark-cache) +- [FLUSH LOGS](#query_language-system-flush_logs) +- [RELOAD CONFIG](#query_language-system-reload-config) +- [SHUTDOWN](#query_language-system-shutdown) +- [KILL](#query_language-system-kill) +- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) +- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) +- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) +- [STOP MERGES](#query_language-system-stop-merges) +- [START MERGES](#query_language-system-start-merges) + +## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} + +بارگذاری مجدد تمام لغت نامه که با موفقیت قبل از لود شده است. +به طور پیش فرض, لغت نامه ها به صورت تنبلی لود (دیدن [\_بارگیری کامل](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load)), بنابراین به جای اینکه به طور خودکار در هنگام راه اندازی لود, در اولین دسترسی از طریق تابع دیکته مقداردهی اولیه و یا از جداول با موتور = فرهنگ لغت را انتخاب کنید. این `SYSTEM RELOAD DICTIONARIES` پرس و جو بارگذاری مجدد از جمله لغت نامه (لود شده). +همیشه باز می گردد `Ok.` صرف نظر از نتیجه به روز رسانی فرهنگ لغت. + +## بازخوانی لغتنامهها {#query_language-system-reload-dictionary} + +به طور کامل یک فرهنگ لغت را دوباره بارگذاری کنید `dictionary_name` بدون در نظر گرفتن دولت از فرهنگ لغت (لود / NOT\_LOADED / شکست خورده). +همیشه باز می گردد `Ok.` صرف نظر از نتیجه به روز رسانی فرهنگ لغت. +وضعیت فرهنگ لغت را می توان با پرس و جو بررسی کرد `system.dictionaries` جدول + +``` sql +SELECT name, status FROM system.dictionaries; +``` + +## DROP DNS CACHE {#query_language-system-drop-dns-cache} + +کش دی ان اس داخلی بازنشانی را کلیک کنید. گاهی اوقات (برای ClickHouse نسخه) لازم است برای استفاده از این دستور هنگامی که در حال تغییر زیرساخت ها (تغییر آدرس IP دیگر ClickHouse سرور یا سرور استفاده شده توسط لغت نامه). + +برای راحت تر (اتوماتیک) مدیریت کش دیدن disable\_internal\_dns\_cache, dns\_cache\_update\_period پارامترهای. + +## DROP MARK CACHE {#query_language-system-drop-mark-cache} + +بازنشانی کش علامت. مورد استفاده در توسعه تست های کلیک و عملکرد. + +## FLUSH LOGS {#query_language-system-flush_logs} + +Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. + +## RELOAD CONFIG {#query_language-system-reload-config} + +بارگذاری مجدد پیکربندی محل کلیک. استفاده می شود که پیکربندی در باغ وحش ذخیره می شود. + +## SHUTDOWN {#query_language-system-shutdown} + +به طور معمول خاموش کردن کلیک (مانند `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) + +## KILL {#query_language-system-kill} + +سقط فرایند کلیک (مانند `kill -9 {$ pid_clickhouse-server}`) + +## مدیریت جداول توزیع شده {#query-language-system-distributed} + +کلیک خانه می تواند مدیریت کند [توزیع شده](../../engines/table-engines/special/distributed.md) میز هنگامی که یک کاربر درج داده ها را به این جداول, خانه رعیتی برای اولین بار ایجاد یک صف از داده ها است که باید به گره های خوشه ای ارسال, سپس ناهمگام می فرستد. شما می توانید پردازش صف با مدیریت [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) و [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) نمایش داده شد. شما همچنین می توانید همزمان داده های توزیع شده را با `insert_distributed_sync` تنظیمات. + +### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} + +غیرفعال توزیع داده های پس زمینه در هنگام قرار دادن داده ها به جداول توزیع شده است. + +``` sql +SYSTEM STOP DISTRIBUTED SENDS [db.] +``` + +### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} + +نیروهای خانه را کلیک کنید برای ارسال داده ها به گره های خوشه همزمان. اگر هر گره در دسترس نیست, تاتر می اندازد یک استثنا و متوقف می شود اجرای پرس و جو. شما می توانید پرس و جو را دوباره امتحان کنید تا زمانی که موفق, که اتفاق خواهد افتاد زمانی که تمام گره ها در حال بازگشت. + +``` sql +SYSTEM FLUSH DISTRIBUTED [db.] +``` + +### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} + +توزیع داده های پس زمینه را هنگام قرار دادن داده ها به جداول توزیع می کند. + +``` sql +SYSTEM START DISTRIBUTED SENDS [db.] +``` + +### STOP MERGES {#query_language-system-stop-merges} + +فراهم می کند امکان متوقف ادغام پس زمینه برای جداول در خانواده ادغام: + +``` sql +SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] +``` + +!!! note "یادداشت" + `DETACH / ATTACH` جدول پس زمینه ادغام برای جدول شروع خواهد شد حتی در صورتی که ادغام برای تمام جداول ادغام قبل از متوقف شده است. + +### START MERGES {#query_language-system-start-merges} + +فراهم می کند امکان شروع پس زمینه ادغام برای جداول در خانواده ادغام: + +``` sql +SYSTEM START MERGES [[db.]merge_tree_family_table_name] +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/fa/sql-reference/syntax.md b/docs/fa/sql-reference/syntax.md new file mode 100644 index 00000000000..795f8302961 --- /dev/null +++ b/docs/fa/sql-reference/syntax.md @@ -0,0 +1,187 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "\u0646\u062D\u0648" +--- + +# نحو {#syntax} + +دو نوع تجزیه کننده در سیستم وجود دارد: تجزیه کننده کامل مربع (تجزیه کننده نزول بازگشتی) و تجزیه کننده فرمت داده (تجزیه کننده جریان سریع). +در تمام موارد به جز `INSERT` پرس و جو, تنها تجزیه کننده کامل گذاشتن استفاده شده است. +این `INSERT` پرس و جو از هر دو تجزیه کننده استفاده می کند: + +``` sql +INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') +``` + +این `INSERT INTO t VALUES` قطعه توسط تجزیه کننده کامل و داده ها تجزیه می شود `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` توسط تجزیه کننده جریان سریع تجزیه می شود. شما همچنین می توانید تجزیه کننده کامل برای داده ها با استفاده از [در حال خواندن:](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) تنظیمات. چه زمانی `input_format_values_interpret_expressions = 1` کلیک هاوس اول سعی می کند به تجزیه ارزش با تجزیه کننده جریان سریع. در صورت عدم موفقیت کلیک هاوس تلاش می کند تا از تجزیه کننده کامل برای داده ها استفاده کند و مانند یک مربع درمان شود [عبارت](#syntax-expressions). + +داده ها می توانند هر فرمت داشته باشند. هنگامی که یک پرس و جو را دریافت کرده است, سرور محاسبه بیش از [بیشینه\_کرکی\_سیز](../operations/settings/settings.md#settings-max_query_size) بایت از درخواست در رم (به طور پیش فرض, 1 مگابایت), و بقیه جریان تجزیه. +این اجازه می دهد تا برای اجتناب از مشکلات بزرگ `INSERT` نمایش داده شد. + +هنگام استفاده از `Values` قالب در یک `INSERT` پرس و جو, ممکن است به نظر می رسد که داده ها همان عبارات در تجزیه `SELECT` پرس و جو, اما این درست نیست. این `Values` فرمت بسیار محدود تر است. + +بقیه این مقاله تجزیه کننده کامل را پوشش می دهد. برای کسب اطلاعات بیشتر در مورد تجزیه کننده فرمت, دیدن [فرشها](../interfaces/formats.md) بخش. + +## فاصلهها {#spaces} + +ممکن است هر تعداد از نمادهای فضایی بین سازه های نحوی (از جمله شروع و پایان پرس و جو) وجود دارد. علامت فضا شامل فضا, باریکه, خوراک خط, کروم, و خوراک فرم. + +## توضیحات {#comments} + +تاتر پشتیبانی از هر دو گذاشتن به سبک و ج سبک نظرات. +گذاشتن به سبک نظرات با شروع `--` و در ادامه به پایان خط, یک فضای پس از `--` می توان حذف. +ج سبک از `/*` به `*/`و می تواند چند خطی, فضاهای مورد نیاز نیست یا. + +## کلیدواژهها {#syntax-keywords} + +کلمات کلیدی حساس به حروف هستند که مربوط به: + +- استاندارد گذاشتن. به عنوان مثال, `SELECT`, `select` و `SeLeCt` همه معتبر هستند. +- پیاده سازی در برخی از پایگاه داده محبوب (خروجی زیر و یا پست). به عنوان مثال, `DateTime` همان است `datetime`. + +این که نام نوع داده حساس به حروف باشد را میتوان در `system.data_type_families` جدول + +در مقایسه با استاندارد گذاشتن تمام کلمات کلیدی دیگر (از جمله توابع نام) هستند **حساس به حالت**. + +کلمات کلیدی محفوظ نیست; به عنوان مثل تنها در زمینه مربوطه درمان می شوند. در صورت استفاده [شناسهها](#syntax-identifiers) با همین نام به عنوان کلمات کلیدی, محصور را به دو نقل قول و یا پشت. برای مثال پرس و جو `SELECT "FROM" FROM table_name` معتبر است اگر جدول `table_name` دارای ستون با نام `"FROM"`. + +## شناسهها {#syntax-identifiers} + +شناسه ها عبارتند از: + +- خوشه, پایگاه داده, جدول, پارتیشن, و نام ستون. +- توابع. +- انواع داده ها. +- [نامگردانهای بیان](#syntax-expression_aliases). + +شناسه را می توان به نقل و یا غیر نقل. در حالت دوم ترجیح داده است. + +شناسه های غیر نقل قول باید عبارت منظم مطابقت `^[a-zA-Z_][0-9a-zA-Z_]*$` و نمی تواند برابر باشد [کلیدواژهها](#syntax-keywords). مثالها: `x, _1, X_y__Z123_.` + +اگر شما می خواهید به استفاده از شناسه همان کلمات کلیدی و یا شما می خواهید به استفاده از نمادهای دیگر در شناسه, نقل قول با استفاده از دو نقل قول و یا پشت پرده, مثلا, `"id"`, `` `id` ``. + +## Literals {#literals} + +عددی وجود دارد, رشته, ترکیب, و `NULL` literals. + +### عددی {#numeric} + +تحت اللفظی عددی تلاش می کند به تجزیه شود: + +- اولین, به عنوان یک شماره امضا 64 بیتی, با استفاده از [استرتول](https://en.cppreference.com/w/cpp/string/byte/strtoul) تابع. +- اگر ناموفق, به عنوان یک عدد بدون علامت 64 بیتی, با استفاده از [استرول](https://en.cppreference.com/w/cpp/string/byte/strtol) تابع. +- اگر ناموفق, به عنوان یک عدد شناور نقطه با استفاده از [رشته](https://en.cppreference.com/w/cpp/string/byte/strtof) تابع. +- در غیر این صورت, این خطا را برمی گرداند. + +ارزش تحت اللفظی کوچکترین نوع است که متناسب با ارزش است. +مثلا, 1 به عنوان تجزیه `UInt8` اما 256 به عنوان تجزیه شده است `UInt16`. برای کسب اطلاعات بیشتر, دیدن [انواع داده ها](../sql-reference/data-types/index.md). + +مثالها: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. + +### رشته {#syntax-string-literal} + +فقط رشته های رشته ای در نقل قول های تک پشتیبانی می شوند. شخصیت های محصور می تواند بک اسلش فرار. توالی فرار زیر یک مقدار خاص مربوطه: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. در تمام موارد دیگر, فرار توالی در قالب `\c` کجا `c` است هر شخصیت, به تبدیل `c`. این بدان معنی است که شما می توانید توالی استفاده کنید `\'`و`\\`. ارزش خواهد شد که [رشته](../sql-reference/data-types/string.md) نوع. + +در رشته لیتر, شما نیاز به فرار حداقل `'` و `\`. نقل قول تنها را می توان با نقل قول تنها فرار, لیتر `'It\'s'` و `'It''s'` برابر هستند. + +### ترکیب {#compound} + +ارریس با براکت مربع ساخته شده است `[1, 2, 3]`. نوپل ها با براکت های گرد ساخته می شوند `(1, 'Hello, world!', 2)`. +مشخصات فنی این نیست literals اما عبارات با آرایه ایجاد اپراتور و چند تایی ایجاد اپراتور بود. +مجموعه ای باید شامل حداقل یک مورد باشد و یک تاپل باید حداقل دو مورد داشته باشد. +یک مورد جداگانه وجود دارد که تاپل در ظاهر `IN` بند یک `SELECT` پرس و جو. نتایج پرس و جو می تواند شامل تاپل, اما تاپل را نمی توان به یک پایگاه داده ذخیره (به جز از جداول با [حافظه](../engines/table-engines/special/memory.md) موتور). + +### NULL {#null-literal} + +نشان می دهد که ارزش از دست رفته است. + +به منظور ذخیره `NULL` در یک میدان جدول باید از [Nullable](../sql-reference/data-types/nullable.md) نوع. + +بسته به فرمت داده (ورودی یا خروجی), `NULL` ممکن است نمایندگی های مختلف. برای کسب اطلاعات بیشتر, اسناد و مدارک برای دیدن [قالبهای داده](../interfaces/formats.md#formats). + +بسیاری از تفاوت های ظریف برای پردازش وجود دارد `NULL`. مثلا, اگر حداقل یکی از استدلال از یک عملیات مقایسه است `NULL` نتیجه این عملیات نیز است `NULL`. همان درست است برای ضرب است, بعلاوه, و عملیات دیگر. برای کسب اطلاعات بیشتر, خواندن اسناد و مدارک برای هر عملیات. + +در نمایش داده شد, شما می توانید بررسی کنید `NULL` با استفاده از [IS NULL](operators/index.md#operator-is-null) و [IS NOT NULL](operators/index.md) اپراتورها و توابع مرتبط `isNull` و `isNotNull`. + +## توابع {#functions} + +فراخوانی تابع مانند یک شناسه با یک لیست از استدلال نوشته شده (احتمالا خالی) در براکت دور. در مقابل به گذاشتن استاندارد, براکت مورد نیاز است, حتی برای یک لیست استدلال خالی. مثال: `now()`. +توابع منظم و جمع وجود دارد (بخش را ببینید “Aggregate functions”). برخی از توابع دانه می تواند شامل دو لیست از استدلال در براکت. مثال: `quantile (0.9) (x)`. این توابع مجموع نامیده می شوند “parametric” توابع, و استدلال در لیست اول نامیده می شوند “parameters”. نحو توابع کل بدون پارامتر همان است که برای توابع به طور منظم است. + +## اپراتورها {#operators} + +اپراتورها در حال تبدیل به توابع مربوط به خود را طی پرس و جو و تجزیه گرفتن اولویت خود را و associativity به حساب آورد. +برای مثال بیان `1 + 2 * 3 + 4` تبدیل به `plus(plus(1, multiply(2, 3)), 4)`. + +## انواع داده ها و موتورهای جدول پایگاه داده {#data_types-and-database-table-engines} + +انواع داده ها و موتورهای جدول در `CREATE` پرس و جو به همان شیوه به عنوان شناسه و یا توابع نوشته شده است. به عبارت دیگر, ممکن است یا ممکن است حاوی یک لیست استدلال در براکت نیست. برای کسب اطلاعات بیشتر به بخش ها مراجعه کنید “Data types,” “Table engines,” و “CREATE”. + +## نامگردانهای بیان {#syntax-expression_aliases} + +نام مستعار یک نام تعریف شده توسط کاربر برای بیان در پرس و جو است. + +``` sql +expr AS alias +``` + +- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` بند بدون استفاده از `AS` کلمه کلیدی. + + For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. + + In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. + +- `expr` — Any expression supported by ClickHouse. + + For example, `SELECT column_name * 2 AS double FROM some_table`. + +- `alias` — Name for `expr`. نام مستعار باید با پیروی از [شناسهها](#syntax-identifiers) نحو. + + For example, `SELECT "table t".column_name FROM table_name AS "table t"`. + +### نکاتی در مورد استفاده {#notes-on-usage} + +نام مستعار جهانی برای یک پرس و جو و یا زیرخاکی هستند, و شما می توانید یک نام مستعار در هر بخشی از یک پرس و جو برای هر بیان تعریف. به عنوان مثال, `SELECT (1 AS n) + 2, n`. + +نام مستعار قابل مشاهده نیست در subqueries و بین subqueries. مثلا, در حالی که اجرای پرس و جو `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` تاتر استثنا را تولید می کند `Unknown identifier: num`. + +اگر یک نام مستعار برای ستون نتیجه در تعریف `SELECT` بند یک خرده فروشی, این ستون ها در پرس و جو بیرونی قابل مشاهده هستند. به عنوان مثال, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. + +مراقب باشید با نام مستعار است که همان نام ستون یا جدول می باشد. بیایید مثال زیر را در نظر بگیریم: + +``` sql +CREATE TABLE t +( + a Int, + b Int +) +ENGINE = TinyLog() +``` + +``` sql +SELECT + argMax(a, b), + sum(b) AS b +FROM t +``` + +``` text +Received exception from server (version 18.14.17): +Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. +``` + +در این مثال ما اعلام جدول `t` با ستون `b`. سپس, در هنگام انتخاب داده, ما تعریف `sum(b) AS b` نام مستعار. به عنوان نام مستعار جهانی هستند, خانه را جایگزین تحت اللفظی `b` در عبارت `argMax(a, b)` با بیان `sum(b)`. این جایگزینی باعث استثنا. + +## ستاره {#asterisk} + +در یک `SELECT` پرس و جو, ستاره می تواند عبارت جایگزین. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “SELECT”. + +## عبارتها {#syntax-expressions} + +بیان یک تابع است, شناسه, تحت اللفظی, استفاده از یک اپراتور, بیان در داخل پرانتز, خرده فروشی, یا ستاره. همچنین می تواند شامل یک نام مستعار. +لیستی از عبارات یک یا چند عبارت از هم جدا شده توسط کاما است. +توابع و اپراتورهای, به نوبه خود, می توانید عبارات به عنوان استدلال دارند. + +[مقاله اصلی](https://clickhouse.tech/docs/en/sql_reference/syntax/) diff --git a/docs/fa/sql-reference/table-functions/file.md b/docs/fa/sql-reference/table-functions/file.md new file mode 100644 index 00000000000..7bb676670a4 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/file.md @@ -0,0 +1,121 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u067E\u0631\u0648\u0646\u062F\u0647" +--- + +# پرونده {#file} + +ایجاد یک جدول از یک فایل. این تابع جدول شبیه به [نشانی وب](url.md) و [hdfs](hdfs.md) یکی + +``` sql +file(path, format, structure) +``` + +**پارامترهای ورودی** + +- `path` — The relative path to the file from [\_مخفی کردن \_صفحه](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-user_files_path). مسیر به فایل پشتیبانی پس از دل تنگی در حالت فقط خواندنی: `*`, `?`, `{abc,def}` و `{N..M}` کجا `N`, `M` — numbers, \``'abc', 'def'` — strings. +- `format` — The [قالب](../../interfaces/formats.md#formats) پرونده +- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. + +**مقدار بازگشتی** + +یک جدول با ساختار مشخص شده برای خواندن یا نوشتن داده ها در فایل مشخص شده است. + +**مثال** + +تنظیم `user_files_path` و محتویات فایل `test.csv`: + +``` bash +$ grep user_files_path /etc/clickhouse-server/config.xml + /var/lib/clickhouse/user_files/ + +$ cat /var/lib/clickhouse/user_files/test.csv + 1,2,3 + 3,2,1 + 78,43,45 +``` + +جدول از`test.csv` و انتخاب دو ردیف اول: + +``` sql +SELECT * +FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +``` sql +-- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file +SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 +``` + +**دل تنگی در مسیر** + +اجزای مسیر چندگانه می تواند دل تنگی دارند. برای پردازش فایل باید وجود داشته باشد و مسابقات به الگوی کل مسیر (نه تنها پسوند یا پیشوند). + +- `*` — Substitutes any number of any characters except `/` از جمله رشته خالی. +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +سازه با `{}` شبیه به [عملکرد جدول از راه دور](../../sql-reference/table-functions/remote.md)). + +**مثال** + +1. فرض کنید ما چندین فایل با مسیرهای نسبی زیر داریم: + +- ‘some\_dir/some\_file\_1’ +- ‘some\_dir/some\_file\_2’ +- ‘some\_dir/some\_file\_3’ +- ‘another\_dir/some\_file\_1’ +- ‘another\_dir/some\_file\_2’ +- ‘another\_dir/some\_file\_3’ + +1. پرس و جو مقدار ردیف در این فایل ها: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. پرس و جو مقدار ردیف در تمام فایل های این دو دایرکتوری: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "اخطار" + اگر لیست خود را از فایل های حاوی محدوده تعداد با صفر پیشرو, استفاده از ساخت و ساز با پرانتز برای هر رقم به طور جداگانه و یا استفاده `?`. + +**مثال** + +پرس و جو داده ها از فایل های به نام `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## ستونهای مجازی {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**همچنین نگاه کنید به** + +- [ستونهای مجازی](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/fa/sql-reference/table-functions/generate.md b/docs/fa/sql-reference/table-functions/generate.md new file mode 100644 index 00000000000..535c98f068b --- /dev/null +++ b/docs/fa/sql-reference/table-functions/generate.md @@ -0,0 +1,44 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: "\u0698\u0646\u0631\u0627\u0644" +--- + +# ژنرال {#generaterandom} + +تولید داده های تصادفی با طرح داده شده است. +اجازه می دهد تا به جمعیت جداول تست با داده ها. +پشتیبانی از تمام انواع داده است که می تواند در جدول به جز ذخیره می شود `LowCardinality` و `AggregateFunction`. + +``` sql +generateRandom('name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_string_length'[, 'max_array_length']]]); +``` + +**پارامترها** + +- `name` — Name of corresponding column. +- `TypeName` — Type of corresponding column. +- `max_array_length` — Maximum array length for all generated arrays. Defaults to `10`. +- `max_string_length` — Maximum string length for all generated strings. Defaults to `10`. +- `random_seed` — Specify random seed manually to produce stable results. If NULL — seed is randomly generated. + +**مقدار بازگشتی** + +یک شی جدول با طرح درخواست. + +## مثال طریقه استفاده {#usage-example} + +``` sql +SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2) LIMIT 3; +``` + +``` text +┌─a────────┬────────────d─┬─c──────────────────────────────────────────────────────────────────┐ +│ [77] │ -124167.6723 │ ('2061-04-17 21:59:44.573','3f72f405-ec3e-13c8-44ca-66ef335f7835') │ +│ [32,110] │ -141397.7312 │ ('1979-02-09 03:43:48.526','982486d1-5a5d-a308-e525-7bd8b80ffa73') │ +│ [68] │ -67417.0770 │ ('2080-03-12 14:17:31.269','110425e5-413f-10a6-05ba-fa6b3e929f15') │ +└──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘ +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/generate/) diff --git a/docs/fa/sql-reference/table-functions/hdfs.md b/docs/fa/sql-reference/table-functions/hdfs.md new file mode 100644 index 00000000000..ae42eda5165 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/hdfs.md @@ -0,0 +1,104 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: hdfs +--- + +# hdfs {#hdfs} + +ایجاد یک جدول از فایل ها در اچ دی. این تابع جدول شبیه به [نشانی وب](url.md) و [پرونده](file.md) یکی + +``` sql +hdfs(URI, format, structure) +``` + +**پارامترهای ورودی** + +- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` و `{N..M}` کجا `N`, `M` — numbers, \``'abc', 'def'` — strings. +- `format` — The [قالب](../../interfaces/formats.md#formats) پرونده +- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. + +**مقدار بازگشتی** + +یک جدول با ساختار مشخص شده برای خواندن یا نوشتن داده ها در فایل مشخص شده است. + +**مثال** + +جدول از `hdfs://hdfs1:9000/test` و انتخاب دو ردیف اول: + +``` sql +SELECT * +FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +**دل تنگی در مسیر** + +اجزای مسیر چندگانه می تواند دل تنگی دارند. برای پردازش فایل باید وجود داشته باشد و مسابقات به الگوی کل مسیر (نه تنها پسوند یا پیشوند). + +- `*` — Substitutes any number of any characters except `/` از جمله رشته خالی. +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +سازه با `{}` شبیه به [عملکرد جدول از راه دور](../../sql-reference/table-functions/remote.md)). + +**مثال** + +1. فرض کنید که ما چندین فایل با اوریس زیر در اچ دی ها داریم: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. پرس و جو مقدار ردیف در این فایل ها: + + + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. پرس و جو مقدار ردیف در تمام فایل های این دو دایرکتوری: + + + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "اخطار" + اگر لیست خود را از فایل های حاوی محدوده تعداد با صفر پیشرو, استفاده از ساخت و ساز با پرانتز برای هر رقم به طور جداگانه و یا استفاده `?`. + +**مثال** + +پرس و جو داده ها از فایل های به نام `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## ستونهای مجازی {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**همچنین نگاه کنید به** + +- [ستونهای مجازی](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/fa/sql-reference/table-functions/index.md b/docs/fa/sql-reference/table-functions/index.md new file mode 100644 index 00000000000..0ed98d139b2 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/index.md @@ -0,0 +1,38 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u062A\u0648\u0627\u0628\u0639 \u062C\u062F\u0648\u0644" +toc_priority: 34 +toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" +--- + +# توابع جدول {#table-functions} + +توابع جدول روش برای ساخت جداول. + +شما می توانید توابع جدول در استفاده: + +- [FROM](../statements/select/from.md) بند از `SELECT` پرس و جو. + + The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. + +- [ایجاد جدول به عنوان \](../statements/create.md#create-table-query) پرس و جو. + + It's one of the methods of creating a table. + +!!! warning "اخطار" + شما می توانید توابع جدول اگر استفاده نمی [اجازه دادن به \_نشانی](../../operations/settings/permissions-for-queries.md#settings_allow_ddl) تنظیم غیر فعال است. + +| تابع | توصیف | +|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------| +| [پرونده](file.md) | ایجاد یک [پرونده](../../engines/table-engines/special/file.md)- جدول موتور. | +| [ادغام](merge.md) | ایجاد یک [ادغام](../../engines/table-engines/special/merge.md)- جدول موتور. | +| [اعداد](numbers.md) | ایجاد یک جدول با یک ستون پر از اعداد صحیح. | +| [دور](remote.md) | اجازه می دهد تا شما را به دسترسی به سرور از راه دور بدون ایجاد یک [توزیع شده](../../engines/table-engines/special/distributed.md)- جدول موتور. | +| [نشانی وب](url.md) | ایجاد یک [نشانی وب](../../engines/table-engines/special/url.md)- جدول موتور. | +| [خروجی زیر](mysql.md) | ایجاد یک [MySQL](../../engines/table-engines/integrations/mysql.md)- جدول موتور. | +| [جستجو](jdbc.md) | ایجاد یک [JDBC](../../engines/table-engines/integrations/jdbc.md)- جدول موتور. | +| [جستجو](odbc.md) | ایجاد یک [ODBC](../../engines/table-engines/integrations/odbc.md)- جدول موتور. | +| [hdfs](hdfs.md) | ایجاد یک [HDFS](../../engines/table-engines/integrations/hdfs.md)- جدول موتور. | + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/fa/sql-reference/table-functions/input.md b/docs/fa/sql-reference/table-functions/input.md new file mode 100644 index 00000000000..0c63761e78f --- /dev/null +++ b/docs/fa/sql-reference/table-functions/input.md @@ -0,0 +1,47 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: "\u0648\u0631\u0648\u062F\u06CC" +--- + +# ورودی {#input} + +`input(structure)` - تابع جدول که اجازه می دهد تا به طور موثر تبدیل و قرار دادن داده های ارسال شده به +سرور با ساختار داده شده به جدول با ساختار دیگر. + +`structure` - ساختار داده ها در قالب زیر به سرور ارسال می شود `'column1_name column1_type, column2_name column2_type, ...'`. +به عنوان مثال, `'id UInt32, name String'`. + +این تابع را می توان تنها در `INSERT SELECT` پرس و جو و تنها یک بار اما در غیر این صورت مانند تابع جدول معمولی رفتار می کنند +(مثلا, این را می توان در زیرخاکری مورد استفاده قرار, و غیره.). + +داده ها را می توان به هیچ وجه مانند عادی ارسال می شود `INSERT` پرس و جو و گذشت در هر موجود [قالب](../../interfaces/formats.md#formats) +که باید در پایان پرس و جو مشخص شود (بر خلاف عادی `INSERT SELECT`). + +ویژگی اصلی این تابع این است که وقتی سرور داده ها را از مشتری دریافت می کند به طور همزمان تبدیل می کند +با توجه به لیست عبارات در `SELECT` بند و درج به جدول هدف. جدول موقت +با تمام داده های منتقل شده ایجاد نمی شود. + +**مثالها** + +- اجازه دهید `test` جدول دارای ساختار زیر است `(a String, b String)` + و داده ها در `data.csv` دارای ساختار متفاوت `(col1 String, col2 Date, col3 Int32)`. پرسوجو برای درج + داده ها از `data.csv` به `test` جدول با تبدیل همزمان به نظر می رسد مثل این: + + + +``` bash +$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; +``` + +- اگر `data.csv` حاوی اطلاعات از ساختار مشابه `test_structure` به عنوان جدول `test` سپس این دو نمایش داده شد برابر هستند: + + + +``` bash +$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV" +$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV" +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/input/) diff --git a/docs/fa/sql-reference/table-functions/jdbc.md b/docs/fa/sql-reference/table-functions/jdbc.md new file mode 100644 index 00000000000..2625c65e1da --- /dev/null +++ b/docs/fa/sql-reference/table-functions/jdbc.md @@ -0,0 +1,29 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "jdbc" +--- + +# جستجو {#table-function-jdbc} + +`jdbc(jdbc_connection_uri, schema, table)` - جدول بازده است که از طریق راننده جدی بی سی متصل. + +این تابع جدول نیاز به جداگانه دارد `clickhouse-jdbc-bridge` برنامه در حال اجرا است. +این پشتیبانی از انواع باطل (بر اساس دسیدال جدول از راه دور است که تردید). + +**مثالها** + +``` sql +SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') +``` + +``` sql +SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'schema', 'table') +``` + +``` sql +SELECT * FROM jdbc('datasource://mysql-local', 'schema', 'table') +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/fa/sql-reference/table-functions/merge.md b/docs/fa/sql-reference/table-functions/merge.md new file mode 100644 index 00000000000..9893fb71838 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/merge.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "\u0627\u062F\u063A\u0627\u0645" +--- + +# ادغام {#merge} + +`merge(db_name, 'tables_regexp')` – Creates a temporary Merge table. For more information, see the section “Table engines, Merge”. + +ساختار جدول از جدول اول مواجه می شوند که منطبق بر عبارت منظم گرفته شده است. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/merge/) diff --git a/docs/fa/sql-reference/table-functions/mysql.md b/docs/fa/sql-reference/table-functions/mysql.md new file mode 100644 index 00000000000..3b37a4ad88f --- /dev/null +++ b/docs/fa/sql-reference/table-functions/mysql.md @@ -0,0 +1,86 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u062E\u0631\u0648\u062C\u06CC \u0632\u06CC\u0631" +--- + +# خروجی زیر {#mysql} + +اجازه می دهد `SELECT` نمایش داده شد به داده است که بر روی یک سرور خروجی از راه دور ذخیره می شود انجام می شود. + +``` sql +mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +**پارامترها** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` نمایش داده شد به `REPLACE INTO`. اگر `replace_query=1`, پرس و جو جایگزین شده است. + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` بیان است که به اضافه `INSERT` پرس و جو. + + Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. + + To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. + +ساده `WHERE` بند هایی مانند `=, !=, >, >=, <, <=` در حال حاضر بر روی سرور خروجی زیر اجرا شده است. + +بقیه شرایط و `LIMIT` محدودیت نمونه برداری در محل کلیک تنها پس از پرس و جو به پس از اتمام خروجی زیر اجرا شده است. + +**مقدار بازگشتی** + +یک شی جدول با ستون همان جدول خروجی زیر اصلی. + +## مثال طریقه استفاده {#usage-example} + +جدول در خروجی زیر: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +انتخاب داده ها از خانه کلیک: + +``` sql +SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## همچنین نگاه کنید به {#see-also} + +- [این ‘MySQL’ موتور جدول](../../engines/table-engines/integrations/mysql.md) +- [با استفاده از خروجی زیر به عنوان منبع فرهنگ لغت خارجی](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/fa/sql-reference/table-functions/numbers.md b/docs/fa/sql-reference/table-functions/numbers.md new file mode 100644 index 00000000000..a09d2d9fcfc --- /dev/null +++ b/docs/fa/sql-reference/table-functions/numbers.md @@ -0,0 +1,30 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u0627\u0639\u062F\u0627\u062F" +--- + +# اعداد {#numbers} + +`numbers(N)` – Returns a table with the single ‘number’ ستون (اوینت64)که شامل اعداد صحیح از 0 تا 1. +`numbers(N, M)` - بازگرداندن یک جدول با تک ‘number’ ستون (اوینت64) که شامل اعداد صحیح از نفر به (نفر + متر - 1). + +شبیه به `system.numbers` جدول را می توان برای تست و تولید مقادیر پی در پی استفاده کرد, `numbers(N, M)` کارایی بیشتر از `system.numbers`. + +نمایش داده شد زیر معادل هستند: + +``` sql +SELECT * FROM numbers(10); +SELECT * FROM numbers(0, 10); +SELECT * FROM system.numbers LIMIT 10; +``` + +مثالها: + +``` sql +-- Generate a sequence of dates from 2010-01-01 to 2010-12-31 +select toDate('2010-01-01') + number as d FROM numbers(365); +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/numbers/) diff --git a/docs/fa/sql-reference/table-functions/odbc.md b/docs/fa/sql-reference/table-functions/odbc.md new file mode 100644 index 00000000000..e5a8ad2af40 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/odbc.md @@ -0,0 +1,108 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u062C\u0633\u062A\u062C\u0648" +--- + +# جستجو {#table-functions-odbc} + +بازگرداندن جدول است که از طریق متصل [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +``` sql +odbc(connection_settings, external_database, external_table) +``` + +پارامترها: + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` پرونده. +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +با خیال راحت پیاده سازی اتصالات ان بی سی, تاتر با استفاده از یک برنامه جداگانه `clickhouse-odbc-bridge`. اگر راننده او بی سی به طور مستقیم از لود `clickhouse-server`, مشکلات راننده می تواند سرور تاتر سقوط. تاتر به طور خودکار شروع می شود `clickhouse-odbc-bridge` هنگامی که مورد نیاز است. برنامه پل او بی سی از همان بسته به عنوان نصب `clickhouse-server`. + +زمینه های با `NULL` مقادیر از جدول خارجی به مقادیر پیش فرض برای نوع داده پایه تبدیل می شوند. مثلا, اگر یک میدان جدول خروجی زیر از راه دور است `INT NULL` نوع این است که به 0 تبدیل (مقدار پیش فرض برای کلیک `Int32` نوع داده). + +## مثال طریقه استفاده {#usage-example} + +**گرفتن اطلاعات از نصب و راه اندازی خروجی زیر محلی از طریق ان بی سی** + +این مثال برای لینوکس اوبونتو 18.04 و سرور خروجی زیر 5.7 بررسی می شود. + +اطمینان حاصل شود که unixODBC و MySQL اتصال نصب شده است. + +به طور پیش فرض (در صورت نصب از بسته), کلیک خانه شروع می شود به عنوان کاربر `clickhouse`. بنابراین شما نیاز به ایجاد و پیکربندی این کاربر در سرور خروجی زیر. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +سپس اتصال را پیکربندی کنید `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +شما می توانید اتصال با استفاده از بررسی `isql` ابزار از unixODBC نصب و راه اندازی. + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +جدول در خروجی زیر: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +بازیابی اطلاعات از جدول خروجی زیر در کلیک: + +``` sql +SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ 0 │ 2 │ 0 │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## همچنین نگاه کنید به {#see-also} + +- [لغت نامه های خارجی ان بی سی](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [موتور جدول ان بی سی](../../engines/table-engines/integrations/odbc.md). + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/fa/sql-reference/table-functions/remote.md b/docs/fa/sql-reference/table-functions/remote.md new file mode 100644 index 00000000000..23a6753fd26 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/remote.md @@ -0,0 +1,83 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u062F\u0648\u0631" +--- + +# دور افتاده {#remote-remotesecure} + +اجازه می دهد تا شما را به دسترسی به سرور از راه دور بدون ایجاد یک `Distributed` جدول + +امضاها: + +``` sql +remote('addresses_expr', db, table[, 'user'[, 'password']]) +remote('addresses_expr', db.table[, 'user'[, 'password']]) +``` + +`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port` یا فقط `host`. میزبان را می توان به عنوان نام سرور مشخص, و یا به عنوان ایپو4 یا ایپو6 نشانی. نشانی اینترنتی6 در براکت مربع مشخص شده است. پورت پورت تی سی پی بر روی سرور از راه دور است. اگر پورت حذف شده است, با استفاده از `tcp_port` از فایل پیکربندی سرور (به طور پیش فرض, 9000). + +!!! important "مهم" + پورت برای یک نشانی اینترنتی6 مورد نیاز است. + +مثالها: + +``` text +example01-01-1 +example01-01-1:9000 +localhost +127.0.0.1 +[::]:9000 +[2a02:6b8:0:1111::11]:9000 +``` + +نشانی های متعدد را می توان با کاما از هم جدا شده است. در این مورد کلیک هاوس از پردازش توزیع شده استفاده می کند بنابراین پرس و جو را به تمام نشانیهای مشخص شده ارسال می کند (مانند داده های مختلف). + +مثال: + +``` text +example01-01-1,example01-02-1 +``` + +بخشی از بیان را می توان در براکت فرفری مشخص شده است. مثال قبلی را می توان به شرح زیر نوشته شده است: + +``` text +example01-0{1,2}-1 +``` + +براکت فرفری می تواند شامل طیف وسیعی از اعداد جدا شده توسط دو نقطه (اعداد صحیح غیر منفی). در این مورد, محدوده به مجموعه ای از ارزش هایی که تولید نشانی سفال گسترش. اگر عدد اول با صفر شروع می شود, ارزش ها با همان تراز صفر تشکیل. مثال قبلی را می توان به شرح زیر نوشته شده است: + +``` text +example01-{01..02}-1 +``` + +اگر شما جفت های متعدد از براکت در اشکال مختلف, این تولید محصول مستقیم از مجموعه مربوطه. + +نشانی ها و بخش هایی از نشانی در براکت فرفری را می توان با نماد لوله جدا (\|). در این مورد, مجموعه مربوطه را از نشانی ها به عنوان کپی تفسیر, و پرس و جو خواهد شد به اولین ماکت سالم ارسال. با این حال, کپی در نظم در حال حاضر در مجموعه تکرار [\_تبالسازی](../../operations/settings/settings.md) تنظیمات. + +مثال: + +``` text +example01-{01..02}-{1|2} +``` + +این مثال دو تکه که هر کدام دو کپی مشخص. + +تعداد نشانیهای تولید شده توسط یک ثابت محدود شده است. در حال حاضر این 1000 نشانی است. + +با استفاده از `remote` تابع جدول کمتر مطلوب تر از ایجاد یک است `Distributed` جدول, چرا که در این مورد, اتصال سرور دوباره تاسیس برای هر درخواست. علاوه بر این, اگر نام میزبان قرار است, نام حل و فصل, و خطا شمارش نیست در هنگام کار با کپی های مختلف. هنگامی که پردازش تعداد زیادی از نمایش داده شد, همیشه ایجاد `Distributed` جدول جلوتر از زمان, و استفاده نکنید `remote` تابع جدول. + +این `remote` تابع جدول می تواند در موارد زیر مفید باشد: + +- دسترسی به یک سرور خاص برای مقایسه داده ها, اشکال زدایی, و تست. +- نمایش داده شد بین خوشه های مختلف کلیک برای اهداف تحقیقاتی. +- درخواست توزیع نادر است که به صورت دستی ساخته شده. +- درخواست توزیع شده که مجموعه ای از سرورها در هر زمان دوباره تعریف شده است. + +اگر کاربر مشخص نشده است, `default` استفاده شده است. +اگر رمز عبور مشخص نشده است, رمز عبور خالی استفاده شده است. + +`remoteSecure` - مثل `remote` but with secured connection. Default port — [\_شروع مجدد](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) از پیکربندی و یا 9440. + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/fa/sql-reference/table-functions/url.md b/docs/fa/sql-reference/table-functions/url.md new file mode 100644 index 00000000000..bb7f5bdf419 --- /dev/null +++ b/docs/fa/sql-reference/table-functions/url.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u0646\u0634\u0627\u0646\u06CC \u0648\u0628" +--- + +# نشانی وب {#url} + +`url(URL, format, structure)` - بازگرداندن یک جدول ایجاد شده از `URL` با توجه به +`format` و `structure`. + +نشانی وب-نشانی کارساز اچتیتیپ یا اچتیتیپس که میتواند بپذیرد `GET` و / یا `POST` درخواست. + +قالب - [قالب](../../interfaces/formats.md#formats) از داده ها. + +ساختار-ساختار جدول در `'UserID UInt64, Name String'` قالب. تعیین نام ستون و انواع. + +**مثال** + +``` sql +-- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format. +SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3 +``` + +[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/url/) diff --git a/docs/fa/sql_reference/aggregate_functions/combinators.md b/docs/fa/sql_reference/aggregate_functions/combinators.md deleted file mode 100644 index 6c2450904fd..00000000000 --- a/docs/fa/sql_reference/aggregate_functions/combinators.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u062A\u0631\u06A9\u06CC\u0628 \u06A9\u0646\u0646\u062F\u0647\u0647\u0627\ - \u06CC \u062A\u0627\u0628\u0639 \u062C\u0645\u0639" ---- - -# ترکیب کنندههای تابع جمع {#aggregate_functions_combinators} - -نام یک تابع جمع می تواند یک پسوند اضافه شده است. این تغییر راه تابع کلی کار می کند. - -## - اگر {#agg-functions-combinator-if} - -The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). - -مثالها: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` و به همین ترتیب. - -با توابع مجموع شرطی, شما می توانید مصالح برای چندین شرایط در یک بار محاسبه, بدون استفاده از کارخانه های فرعی و `JOIN`برای مثال در یاندکس.متریکا, توابع مجموع مشروط استفاده می شود برای پیاده سازی قابلیت مقایسه بخش. - -## حداقل صفحه نمایش: {#agg-functions-combinator-array} - -پسوند مجموعه را می توان به هر تابع جمع اضافه شده است. در این مورد, تابع کل استدلال از طول می کشد ‘Array(T)’ نوع (ارریس) به جای ‘T’ استدلال نوع. اگر تابع جمع استدلال های متعدد را می پذیرد, این باید مجموعه ای از طول های برابر شود. هنگامی که پردازش ارریس, تابع کل کار می کند مانند تابع کل اصلی در تمام عناصر مجموعه. - -مثال 1: `sumArray(arr)` - مجموع تمام عناصر از همه ‘arr’ اراریس در این مثال می توانست بیشتر به سادگی نوشته شده است: `sum(arraySum(arr))`. - -مثال 2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ اراریس این می تواند انجام شود یک راه ساده تر: `uniq(arrayJoin(arr))` اما همیشه امکان اضافه کردن وجود ندارد ‘arrayJoin’ به پرس و جو. - -\- اگر و مجموعه ای می تواند ترکیب شود. هرچند, ‘Array’ پس اول باید بیای ‘If’. مثالها: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. با توجه به این سفارش ‘cond’ برهان صف نیست. - -## - وضعیت {#agg-functions-combinator-state} - -اگر شما درخواست این ترکیب, تابع کل می کند مقدار حاصل بازگشت نیست (مانند تعدادی از ارزش های منحصر به فرد برای [uniq](reference.md#agg_function-uniq) تابع) , اما یک دولت متوسط از تجمع (برای `uniq`, این جدول هش برای محاسبه تعداد ارزش های منحصر به فرد است). این یک `AggregateFunction(...)` که می تواند برای پردازش بیشتر استفاده می شود و یا ذخیره شده در یک جدول را به پایان برساند جمع بعد. - -برای کار با این کشورها, استفاده: - -- [ریزدانه](../../engines/table_engines/mergetree_family/aggregatingmergetree.md) موتور جدول. -- [پلاکتی](../../sql_reference/functions/other_functions.md#function-finalizeaggregation) تابع. -- [خرابی اجرا](../../sql_reference/functions/other_functions.md#function-runningaccumulate) تابع. -- [- ادغام](#aggregate_functions_combinators_merge) ترکیب کننده. -- [اطلاعات دقیق](#aggregate_functions_combinators_mergestate) ترکیب کننده. - -## - ادغام {#aggregate_functions_combinators-merge} - -اگر شما درخواست این ترکیب, تابع کل طول می کشد حالت تجمع متوسط به عنوان یک استدلال, ترکیبی از کشورهای به پایان تجمع, و ارزش حاصل می گرداند. - -## اطلاعات دقیق {#aggregate_functions_combinators-mergestate} - -ادغام کشورهای تجمع متوسط در همان راه به عنوان ترکیب-ادغام. با این حال, این مقدار حاصل بازگشت نیست, اما یک دولت تجمع متوسط, شبیه به ترکیب دولت. - -## - فورچ {#agg-functions-combinator-foreach} - -تبدیل یک تابع جمع برای جداول به یک تابع کلی برای ارریس که جمع اقلام مجموعه مربوطه و مجموعه ای از نتایج را برمی گرداند. به عنوان مثال, `sumForEach` برای ارریس `[1, 2]`, `[3, 4, 5]`و`[6, 7]`نتیجه را برمی گرداند `[10, 13, 5]` پس از اضافه کردن با هم موارد مجموعه مربوطه. - -## شناسه بسته: {#agg-functions-combinator-ordefault} - -پر مقدار پیش فرض از نوع بازگشت تابع جمع است اگر چیزی برای جمع وجود دارد. - -``` sql -SELECT avg(number), avgOrDefault(number) FROM numbers(0) -``` - -``` text -┌─avg(number)─┬─avgOrDefault(number)─┐ -│ nan │ 0 │ -└─────────────┴──────────────────────┘ -``` - -## اطلاعات دقیق {#agg-functions-combinator-ornull} - -پر `null` در صورتی که هیچ چیز به جمع وجود دارد. ستون بازگشت قابل ابطال خواهد بود. - -``` sql -SELECT avg(number), avgOrNull(number) FROM numbers(0) -``` - -``` text -┌─avg(number)─┬─avgOrNull(number)─┐ -│ nan │ ᴺᵁᴸᴸ │ -└─────────────┴───────────────────┘ -``` - --OrDefault و OrNull می تواند در ترکیب با دیگر combinators. این زمانی مفید است که تابع جمع می کند ورودی خالی را قبول نمی کند. - -``` sql -SELECT avgOrNullIf(x, x > 10) -FROM -( - SELECT toDecimal32(1.23, 2) AS x -) -``` - -``` text -┌─avgOrNullIf(x, greater(x, 10))─┐ -│ ᴺᵁᴸᴸ │ -└────────────────────────────────┘ -``` - -## - نمونه {#agg-functions-combinator-resample} - -به شما امکان می دهد داده ها را به گروه تقسیم کنید و سپس به طور جداگانه داده ها را در این گروه ها جمع کنید. گروه ها با تقسیم مقادیر از یک ستون به فواصل ایجاد شده است. - -``` sql -Resample(start, end, step)(, resampling_key) -``` - -**پارامترها** - -- `start` — Starting value of the whole required interval for `resampling_key` ارزشهای خبری عبارتند از: -- `stop` — Ending value of the whole required interval for `resampling_key` ارزشهای خبری عبارتند از: کل فاصله شامل نمی شود `stop` مقدار `[start, stop)`. -- `step` — Step for separating the whole interval into subintervals. The `aggFunction` بیش از هر یک از این زیرگروه اعدام به طور مستقل. -- `resampling_key` — Column whose values are used for separating data into intervals. -- `aggFunction_params` — `aggFunction` پارامترها - -**مقادیر بازگشتی** - -- مجموعه ای از `aggFunction` نتایج جستجو برای هر subinterval. - -**مثال** - -در نظر بگیرید که `people` جدول با داده های زیر: - -``` text -┌─name───┬─age─┬─wage─┐ -│ John │ 16 │ 10 │ -│ Alice │ 30 │ 15 │ -│ Mary │ 35 │ 8 │ -│ Evelyn │ 48 │ 11.5 │ -│ David │ 62 │ 9.9 │ -│ Brian │ 60 │ 16 │ -└────────┴─────┴──────┘ -``` - -بیایید نام افرادی که سن نهفته در فواصل `[30,60)` و `[60,75)`. پس ما با استفاده از نمایندگی عدد صحیح برای سن, ما سنین در `[30, 59]` و `[60,74]` فواصل زمانی. - -به نام کلی در مجموعه, ما با استفاده از [گرامری](reference.md#agg_function-grouparray) تابع جمع. طول می کشد تا یک استدلال. در مورد ما این است `name` ستون. این `groupArrayResample` تابع باید از `age` ستون به نام دانه های سن. برای تعریف فواصل مورد نیاز ما `30, 75, 30` نشانوندها به `groupArrayResample` تابع. - -``` sql -SELECT groupArrayResample(30, 75, 30)(name, age) FROM people -``` - -``` text -┌─groupArrayResample(30, 75, 30)(name, age)─────┐ -│ [['Alice','Mary','Evelyn'],['David','Brian']] │ -└───────────────────────────────────────────────┘ -``` - -در نظر گرفتن نتایج. - -`Jonh` خارج از نمونه است چرا که او بیش از حد جوان است. افراد دیگر با توجه به فواصل زمانی مشخص شده توزیع می شوند. - -حالا اجازه دهید تعداد کل مردم و متوسط دستمزد خود را در فواصل سنی مشخص شده است. - -``` sql -SELECT - countResample(30, 75, 30)(name, age) AS amount, - avgResample(30, 75, 30)(wage, age) AS avg_wage -FROM people -``` - -``` text -┌─amount─┬─avg_wage──────────────────┐ -│ [3,2] │ [11.5,12.949999809265137] │ -└────────┴───────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/fa/sql_reference/aggregate_functions/index.md b/docs/fa/sql_reference/aggregate_functions/index.md deleted file mode 100644 index 6442dddedd2..00000000000 --- a/docs/fa/sql_reference/aggregate_functions/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Aggregate Functions -toc_priority: 33 -toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" ---- - -# توابع مجموع {#aggregate-functions} - -توابع مجموع در کار [عادی](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) راه به عنوان کارشناسان پایگاه داده انتظار می رود. - -فاحشه خانه نیز پشتیبانی می کند: - -- [توابع مجموع پارامتری](parametric_functions.md#aggregate_functions_parametric), که قبول پارامترهای دیگر علاوه بر ستون. -- [ترکیب کنندهها](combinators.md#aggregate_functions_combinators) که تغییر رفتار مجموع توابع. - -## پردازش پوچ {#null-processing} - -در طول تجمع همه `NULL`بازدید کنندگان قلم می. - -**مثالها:** - -این جدول را در نظر بگیرید: - -``` text -┌─x─┬────y─┐ -│ 1 │ 2 │ -│ 2 │ ᴺᵁᴸᴸ │ -│ 3 │ 2 │ -│ 3 │ 3 │ -│ 3 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -بیایید می گویند شما نیاز به کل ارزش ها در `y` ستون: - -``` sql -SELECT sum(y) FROM t_null_big -``` - - ┌─sum(y)─┐ - │ 7 │ - └────────┘ - -این `sum` تابع تفسیر می کند `NULL` به عنوان `0`. به خصوص, این بدان معنی است که اگر تابع ورودی از یک انتخاب که تمام مقادیر دریافت `NULL` سپس نتیجه خواهد بود `0` نه `NULL`. - -حالا شما می توانید استفاده کنید `groupArray` تابع برای ایجاد مجموعه ای از `y` ستون: - -``` sql -SELECT groupArray(y) FROM t_null_big -``` - -``` text -┌─groupArray(y)─┐ -│ [2,2,3] │ -└───────────────┘ -``` - -`groupArray` شامل نمی شود `NULL` در مجموعه ای نتیجه. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/fa/sql_reference/aggregate_functions/parametric_functions.md b/docs/fa/sql_reference/aggregate_functions/parametric_functions.md deleted file mode 100644 index 3a45a615e07..00000000000 --- a/docs/fa/sql_reference/aggregate_functions/parametric_functions.md +++ /dev/null @@ -1,500 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: "\u062A\u0648\u0627\u0628\u0639 \u0645\u062C\u0645\u0648\u0639 \u067E\u0627\ - \u0631\u0627\u0645\u062A\u0631\u06CC" ---- - -# توابع مجموع پارامتری {#aggregate_functions_parametric} - -Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. - -## سابقهنما {#histogram} - -محاسبه هیستوگرام تطبیقی. این نتایج دقیق را تضمین نمی کند. - -``` sql -histogram(number_of_bins)(values) -``` - -توابع استفاده می کند [جریان الگوریتم درخت تصمیم موازی](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). مرزهای سطل هیستوگرام تنظیم به عنوان داده های جدید وارد یک تابع. در مورد مشترک عرض سطل برابر نیست. - -**پارامترها** - -`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. -`values` — [عبارت](../syntax.md#syntax-expressions) در نتیجه مقادیر ورودی. - -**مقادیر بازگشتی** - -- [& حذف](../../sql_reference/data_types/array.md) از [توپلس](../../sql_reference/data_types/tuple.md) از قالب زیر: - - ``` - [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] - ``` - - - `lower` — Lower bound of the bin. - - `upper` — Upper bound of the bin. - - `height` — Calculated height of the bin. - -**مثال** - -``` sql -SELECT histogram(5)(number + 1) -FROM ( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ -│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -شما می توانید یک هیستوگرام با تجسم [بار](../../sql_reference/functions/other_functions.md#function-bar) تابع برای مثال: - -``` sql -WITH histogram(5)(rand() % 100) AS hist -SELECT - arrayJoin(hist).3 AS height, - bar(height, 0, 6, 5) AS bar -FROM -( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─height─┬─bar───┐ -│ 2.125 │ █▋ │ -│ 3.25 │ ██▌ │ -│ 5.625 │ ████▏ │ -│ 5.625 │ ████▏ │ -│ 3.375 │ ██▌ │ -└────────┴───────┘ -``` - -در این مورد, شما باید به یاد داشته باشید که شما مرزهای هیستوگرام بن نمی دانند. - -## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} - -بررسی اینکه دنباله شامل یک زنجیره رویداد که منطبق بر الگوی. - -``` sql -sequenceMatch(pattern)(timestamp, cond1, cond2, ...) -``` - -!!! warning "اخطار" - رویدادهایی که در همان دوم رخ می دهد ممکن است در دنباله در سفارش تعریف نشده موثر بر نتیجه دراز. - -**پارامترها** - -- `pattern` — Pattern string. See [نحو الگو](#sequence-function-pattern-syntax). - -- `timestamp` — Column considered to contain time data. Typical data types are `Date` و `DateTime`. شما همچنین می توانید هر یک از پشتیبانی استفاده کنید [اینترنت](../../sql_reference/data_types/int_uint.md) انواع داده ها. - -- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. شما می توانید به تصویب تا 32 استدلال شرط. تابع طول می کشد تنها حوادث شرح داده شده در این شرایط به حساب. اگر دنباله حاوی اطلاعاتی است که در شرایط توصیف نشده, تابع پرش. - -**مقادیر بازگشتی** - -- 1, اگر الگوی همسان است. -- 0, اگر الگوی همسان نیست. - -نوع: `UInt8`. - - -**نحو الگو** - -- `(?N)` — Matches the condition argument at position `N`. شرایط در شماره `[1, 32]` محدوده. به عنوان مثال, `(?1)` با استدلال به تصویب رسید `cond1` پارامتر. - -- `.*` — Matches any number of events. You don't need conditional arguments to match this element of the pattern. - -- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` مسابقات رویدادهایی که رخ می دهد بیش از 1800 ثانیه از یکدیگر. تعداد دلخواه از هر رویدادی می تواند بین این حوادث دراز. شما می توانید از `>=`, `>`, `<`, `<=` اپراتورها. - -**مثالها** - -داده ها را در نظر بگیرید `t` جدول: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -└──────┴────────┘ -``` - -انجام پرس و جو: - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 1 │ -└───────────────────────────────────────────────────────────────────────┘ -``` - -تابع زنجیره رویداد که تعداد پیدا شده است 2 زیر شماره 1. این قلم شماره 3 بین, چرا که تعداد به عنوان یک رویداد توصیف نشده. اگر ما می خواهیم این شماره را در نظر بگیریم هنگام جستجو برای زنجیره رویداد داده شده در مثال باید شرایط را ایجاد کنیم. - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ -│ 0 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -در این مورد, تابع می تواند زنجیره رویداد تطبیق الگوی پیدا کنید, چرا که این رویداد برای شماره 3 رخ داده است بین 1 و 2. اگر در همان مورد ما شرایط را برای شماره بررسی 4, دنباله الگوی مطابقت. - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ -│ 1 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**همچنین نگاه کنید** - -- [شمارش معکوس](#function-sequencecount) - -## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} - -شمارش تعداد زنجیره رویداد که الگوی همسان. تابع جستجو زنجیره رویداد که با هم همپوشانی دارند. این شروع به جستجو برای زنجیره بعدی پس از زنجیره فعلی همسان است. - -!!! warning "اخطار" - رویدادهایی که در همان دوم رخ می دهد ممکن است در دنباله در سفارش تعریف نشده موثر بر نتیجه دراز. - -``` sql -sequenceCount(pattern)(timestamp, cond1, cond2, ...) -``` - -**پارامترها** - -- `pattern` — Pattern string. See [نحو الگو](#sequence-function-pattern-syntax). - -- `timestamp` — Column considered to contain time data. Typical data types are `Date` و `DateTime`. شما همچنین می توانید هر یک از پشتیبانی استفاده کنید [اینترنت](../../sql_reference/data_types/int_uint.md) انواع داده ها. - -- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. شما می توانید به تصویب تا 32 استدلال شرط. تابع طول می کشد تنها حوادث شرح داده شده در این شرایط به حساب. اگر دنباله حاوی اطلاعاتی است که در شرایط توصیف نشده, تابع پرش. - -**مقادیر بازگشتی** - -- تعداد زنجیره رویداد غیر با هم تداخل دارند که همسان. - -نوع: `UInt64`. - -**مثال** - -داده ها را در نظر بگیرید `t` جدول: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -│ 4 │ 1 │ -│ 5 │ 3 │ -│ 6 │ 2 │ -└──────┴────────┘ -``` - -تعداد چند بار تعداد 2 پس از شماره 1 با هر مقدار از شماره های دیگر بین رخ می دهد: - -``` sql -SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 2 │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -**همچنین نگاه کنید به** - -- [ترتیب سنج](#function-sequencematch) - -## در پنجره {#windowfunnel} - -جستجو برای زنجیره رویداد در یک پنجره زمان کشویی و محاسبه حداکثر تعداد رویدادهایی که از زنجیره رخ داده است. - -تابع با توجه به الگوریتم کار می کند: - -- تابع جستجو برای داده هایی که باعث شرط اول در زنجیره و مجموعه ضد رویداد به 1. این لحظه ای است که پنجره کشویی شروع می شود. - -- اگر حوادث از زنجیره پی در پی در پنجره رخ می دهد, ضد افزایش است. اگر دنباله ای از حوادث مختل شده است, شمارنده است افزایش نمی. - -- اگر داده های زنجیره رویداد های متعدد در نقاط مختلف از اتمام, تابع تنها خروجی به اندازه طولانی ترین زنجیره ای. - -**نحو** - -``` sql -windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) -``` - -**پارامترها** - -- `window` — Length of the sliding window in seconds. -- `mode` - این یک استدلال اختیاری است . - - `'strict'` - وقتی که `'strict'` تنظیم شده است, پنجره() اعمال شرایط تنها برای ارزش های منحصر به فرد. -- `timestamp` — Name of the column containing the timestamp. Data types supported: [تاریخ](../../sql_reference/data_types/date.md), [DateTime](../../sql_reference/data_types/datetime.md#data_type-datetime) و دیگر انواع عدد صحیح بدون علامت (توجه داشته باشید که حتی اگر برچسب زمان پشتیبانی از `UInt64` نوع, این مقدار می تواند بین المللی تجاوز نمی64 بیشترین, که 2^63 - 1). -- `cond` — Conditions or data describing the chain of events. [UInt8](../../sql_reference/data_types/int_uint.md). - -**مقدار بازگشتی** - -حداکثر تعداد متوالی باعث شرایط از زنجیره ای در پنجره زمان کشویی. -تمام زنجیره ها در انتخاب تجزیه و تحلیل می شوند. - -نوع: `Integer`. - -**مثال** - -تعیین کنید که یک دوره زمانی معین برای کاربر کافی باشد تا گوشی را انتخاب کند و دو بار در فروشگاه اینترنتی خریداری کند. - -زنجیره ای از وقایع زیر را تنظیم کنید: - -1. کاربر وارد شده به حساب خود را در فروشگاه (`eventID = 1003`). -2. کاربر برای یک تلفن جستجو می کند (`eventID = 1007, product = 'phone'`). -3. کاربر سفارش داده شده (`eventID = 1009`). -4. کاربر دوباره سفارش داد (`eventID = 1010`). - -جدول ورودی: - -``` text -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -``` - -یافتن پست های تا چه حد کاربر `user_id` می تواند از طریق زنجیره ای در یک دوره در ژانویه و فوریه از 2019. - -پرسوجو: - -``` sql -SELECT - level, - count() AS c -FROM -( - SELECT - user_id, - windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level - FROM trend - WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') - GROUP BY user_id -) -GROUP BY level -ORDER BY level ASC -``` - -نتیجه: - -``` text -┌─level─┬─c─┐ -│ 4 │ 1 │ -└───────┴───┘ -``` - -## نگهداری {#retention} - -تابع طول می کشد به عنوان استدلال مجموعه ای از شرایط از 1 به 32 استدلال از نوع `UInt8` که نشان می دهد که یک بیماری خاص برای این رویداد مواجه شد. -هر گونه شرایط را می توان به عنوان یک استدلال مشخص (همانطور که در [WHERE](../../sql_reference/statements/select.md#select-where)). - -شرایط, به جز اولین, درخواست در جفت: نتیجه دوم درست خواهد بود اگر اول و دوم درست باشد, از سوم اگر اولین و فیرد درست باشد, و غیره. - -**نحو** - -``` sql -retention(cond1, cond2, ..., cond32); -``` - -**پارامترها** - -- `cond` — an expression that returns a `UInt8` نتیجه (1 یا 0). - -**مقدار بازگشتی** - -مجموعه ای از 1 یا 0. - -- 1 — condition was met for the event. -- 0 — condition wasn't met for the event. - -نوع: `UInt8`. - -**مثال** - -بیایید یک نمونه از محاسبه را در نظر بگیریم `retention` تابع برای تعیین ترافیک سایت. - -**1.** Сreate a table to illustrate an example. - -``` sql -CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; - -INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); -INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); -INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); -``` - -جدول ورودی: - -پرسوجو: - -``` sql -SELECT * FROM retention_test -``` - -نتیجه: - -``` text -┌───────date─┬─uid─┐ -│ 2020-01-01 │ 0 │ -│ 2020-01-01 │ 1 │ -│ 2020-01-01 │ 2 │ -│ 2020-01-01 │ 3 │ -│ 2020-01-01 │ 4 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-02 │ 0 │ -│ 2020-01-02 │ 1 │ -│ 2020-01-02 │ 2 │ -│ 2020-01-02 │ 3 │ -│ 2020-01-02 │ 4 │ -│ 2020-01-02 │ 5 │ -│ 2020-01-02 │ 6 │ -│ 2020-01-02 │ 7 │ -│ 2020-01-02 │ 8 │ -│ 2020-01-02 │ 9 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-03 │ 0 │ -│ 2020-01-03 │ 1 │ -│ 2020-01-03 │ 2 │ -│ 2020-01-03 │ 3 │ -│ 2020-01-03 │ 4 │ -│ 2020-01-03 │ 5 │ -│ 2020-01-03 │ 6 │ -│ 2020-01-03 │ 7 │ -│ 2020-01-03 │ 8 │ -│ 2020-01-03 │ 9 │ -│ 2020-01-03 │ 10 │ -│ 2020-01-03 │ 11 │ -│ 2020-01-03 │ 12 │ -│ 2020-01-03 │ 13 │ -│ 2020-01-03 │ 14 │ -└────────────┴─────┘ -``` - -**2.** کاربران گروه با شناسه منحصر به فرد `uid` با استفاده از `retention` تابع. - -پرسوجو: - -``` sql -SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r -FROM retention_test -WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') -GROUP BY uid -ORDER BY uid ASC -``` - -نتیجه: - -``` text -┌─uid─┬─r───────┐ -│ 0 │ [1,1,1] │ -│ 1 │ [1,1,1] │ -│ 2 │ [1,1,1] │ -│ 3 │ [1,1,1] │ -│ 4 │ [1,1,1] │ -│ 5 │ [0,0,0] │ -│ 6 │ [0,0,0] │ -│ 7 │ [0,0,0] │ -│ 8 │ [0,0,0] │ -│ 9 │ [0,0,0] │ -│ 10 │ [0,0,0] │ -│ 11 │ [0,0,0] │ -│ 12 │ [0,0,0] │ -│ 13 │ [0,0,0] │ -│ 14 │ [0,0,0] │ -└─────┴─────────┘ -``` - -**3.** محاسبه تعداد کل بازدیدکننده داشته است سایت در هر روز. - -پرسوجو: - -``` sql -SELECT - sum(r[1]) AS r1, - sum(r[2]) AS r2, - sum(r[3]) AS r3 -FROM -( - SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r - FROM retention_test - WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') - GROUP BY uid -) -``` - -نتیجه: - -``` text -┌─r1─┬─r2─┬─r3─┐ -│ 5 │ 5 │ 5 │ -└────┴────┴────┘ -``` - -کجا: - -- `r1`- تعداد بازدید کنندگان منحصر به فرد که در طول 2020-01-01 (بازدید `cond1` شرط). -- `r2`- تعداد بازدید کنندگان منحصر به فرد که برای بازدید از سایت در طول یک دوره زمانی خاص بین 2020-01-01 و 2020-01-02 (`cond1` و `cond2` شرایط). -- `r3`- تعداد بازدید کنندگان منحصر به فرد که برای بازدید از سایت در طول یک دوره زمانی خاص بین 2020-01-01 و 2020-01-03 (`cond1` و `cond3` شرایط). - -## uniqUpTo(N)(x) {#uniquptonx} - -Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. - -توصیه می شود برای استفاده با شماره های کوچک, تا 10. حداکثر مقدار نفر است 100. - -برای دولت از یک تابع جمع, با استفاده از مقدار حافظه برابر با 1 + نفر \* اندازه یک مقدار بایت. -برای رشته, این فروشگاه یک هش غیر رمزنگاری 8 بایت. به این معنا که محاسبه برای رشته ها تقریبی است. - -این تابع همچنین برای چندین استدلال کار می کند. - -این کار به همان سرعتی که ممکن است, به جز برای موارد زمانی که یک مقدار نفر بزرگ استفاده می شود و تعدادی از ارزش های منحصر به فرد است کمی کمتر از ان. - -مثال طریقه استفاده: - -``` text -Problem: Generate a report that shows only keywords that produced at least 5 unique users. -Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) - -## sumMapFiltered(keys\_to\_keep)(کلید ارزش ها) {#summapfilteredkeys-to-keepkeys-values} - -رفتار مشابه [& سواپ](reference.md#agg_functions-summap) جز این که مجموعه ای از کلید به عنوان یک پارامتر منتقل می شود. این می تواند مفید باشد به خصوص در هنگام کار با یک کارت از کلید های بالا. diff --git a/docs/fa/sql_reference/aggregate_functions/reference.md b/docs/fa/sql_reference/aggregate_functions/reference.md deleted file mode 100644 index 6c76f2caff0..00000000000 --- a/docs/fa/sql_reference/aggregate_functions/reference.md +++ /dev/null @@ -1,1837 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 36 -toc_title: "\u0645\u0631\u062C\u0639" ---- - -# مرجع عملکرد {#function-reference} - -## شمارش {#agg_function-count} - -شمارش تعداد ردیف یا نه تهی ارزش. - -ClickHouse زیر پشتیبانی می کند syntaxes برای `count`: -- `count(expr)` یا `COUNT(DISTINCT expr)`. -- `count()` یا `COUNT(*)`. این `count()` نحو ClickHouse خاص. - -**پارامترها** - -این تابع می تواند: - -- صفر پارامتر. -- یک [عبارت](../syntax.md#syntax-expressions). - -**مقدار بازگشتی** - -- اگر تابع بدون پارامتر نامیده می شود تعداد ردیف شمارش. -- اگر [عبارت](../syntax.md#syntax-expressions) به تصویب می رسد, سپس تابع شمارش چند بار این عبارت بازگشت تهی نیست. اگر بیان می گرداند [Nullable](../../sql_reference/data_types/nullable.md)- نوع ارزش و سپس نتیجه `count` باقی نمی ماند `Nullable`. تابع بازده 0 اگر بیان بازگشت `NULL` برای تمام ردیف. - -در هر دو مورد نوع مقدار بازگشتی است [UInt64](../../sql_reference/data_types/int_uint.md). - -**اطلاعات دقیق** - -تاتر از `COUNT(DISTINCT ...)` نحو. رفتار این ساخت و ساز بستگی به [ا\_فزونهها](../../operations/settings/settings.md#settings-count_distinct_implementation) تنظیمات. این تعریف می کند که کدام یک از [uniq\*](#agg_function-uniq) توابع برای انجام عملیات استفاده می شود. به طور پیش فرض است [قرارداد اتحادیه](#agg_function-uniqexact) تابع. - -این `SELECT count() FROM table` پرس و جو بهینه سازی شده نیست, چرا که تعداد ورودی در جدول به طور جداگانه ذخیره نمی. این ستون کوچک را از جدول انتخاب می کند و تعداد مقادیر موجود را شمارش می کند. - -**مثالها** - -مثال 1: - -``` sql -SELECT count() FROM t -``` - -``` text -┌─count()─┐ -│ 5 │ -└─────────┘ -``` - -مثال 2: - -``` sql -SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' -``` - -``` text -┌─name──────────────────────────┬─value─────┐ -│ count_distinct_implementation │ uniqExact │ -└───────────────────────────────┴───────────┘ -``` - -``` sql -SELECT count(DISTINCT num) FROM t -``` - -``` text -┌─uniqExact(num)─┐ -│ 3 │ -└────────────────┘ -``` - -این مثال نشان می دهد که `count(DISTINCT num)` توسط `uniqExact` عملکرد با توجه به `count_distinct_implementation` مقدار تنظیم. - -## هر) {#agg_function-any} - -انتخاب اولین مقدار مواجه می شوند. -پرس و جو را می توان در هر سفارش و حتی در جهت های مختلف در هر زمان اجرا, بنابراین نتیجه این تابع نامشخص است. -برای دریافت یک نتیجه معین, شما می توانید با استفاده از ‘min’ یا ‘max’ تابع به جای ‘any’. - -در بعضی موارد, شما می توانید در جهت اعدام تکیه. این امر در مورد مواردی که انتخاب می شود از یک زیرخاکی است که از سفارش استفاده می کند. - -هنگامی که یک `SELECT` پرسوجو دارد `GROUP BY` بند و یا حداقل یک مجموع عملکرد ClickHouse (در مقایسه با MySQL) مستلزم آن است که تمام عبارات در `SELECT`, `HAVING` و `ORDER BY` بند از کلید و یا از توابع کل محاسبه می شود. به عبارت دیگر, هر ستون انتخاب شده از جدول باید یا در کلید و یا در داخل توابع دانه استفاده می شود. برای دریافت رفتار مانند خروجی زیر, شما می توانید ستون های دیگر در قرار `any` تابع جمع. - -## هشدار داده می شود) {#anyheavyx} - -انتخاب یک مقدار اغلب اتفاق می افتد با استفاده از [بزرگان سنگین](http://www.cs.umd.edu/~samir/498/karp.pdf) الگوریتم. در صورتی که یک مقدار که بیش از در نیمی از موارد در هر یک از موضوعات اعدام پرس و جو رخ می دهد وجود دارد, این مقدار بازگشته است. به طور معمول نتیجه nondeterministic. - -``` sql -anyHeavy(column) -``` - -**نشانوندها** - -- `column` – The column name. - -**مثال** - -نگاهی به [به موقع](../../getting_started/example_datasets/ontime.md) مجموعه داده ها و انتخاب هر مقدار اغلب اتفاق می افتد در `AirlineID` ستون. - -``` sql -SELECT anyHeavy(AirlineID) AS res -FROM ontime -``` - -``` text -┌───res─┐ -│ 19690 │ -└───────┘ -``` - -## حداقل صفحه نمایش:) {#anylastx} - -ارزش گذشته مواجه می شوند را انتخاب می کند. -نتیجه این است که فقط به عنوان نامشخص به عنوان برای `any` تابع. - -## گروه بیتاند {#groupbitand} - -اعمال بیتی `AND` برای مجموعه ای از اعداد. - -``` sql -groupBitAnd(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `UInt*` نوع. - -**مقدار بازگشتی** - -ارزش `UInt*` نوع. - -**مثال** - -داده های تست: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -پرسوجو: - -``` sql -SELECT groupBitAnd(num) FROM t -``` - -کجا `num` ستون با داده های تست است. - -نتیجه: - -``` text -binary decimal -00000100 = 4 -``` - -## ویرایشگر گروه {#groupbitor} - -اعمال بیتی `OR` برای مجموعه ای از اعداد. - -``` sql -groupBitOr(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `UInt*` نوع. - -**مقدار بازگشتی** - -ارزش `UInt*` نوع. - -**مثال** - -داده های تست: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -پرسوجو: - -``` sql -SELECT groupBitOr(num) FROM t -``` - -کجا `num` ستون با داده های تست است. - -نتیجه: - -``` text -binary decimal -01111101 = 125 -``` - -## گروهبیتکسور {#groupbitxor} - -شامل اعضای اتحادیه اروپا `XOR` برای مجموعه ای از اعداد. - -``` sql -groupBitXor(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `UInt*` نوع. - -**مقدار بازگشتی** - -ارزش `UInt*` نوع. - -**مثال** - -داده های تست: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -پرسوجو: - -``` sql -SELECT groupBitXor(num) FROM t -``` - -کجا `num` ستون با داده های تست است. - -نتیجه: - -``` text -binary decimal -01101000 = 104 -``` - -## نگاشت گروهی {#groupbitmap} - -بیت مپ و یا کل محاسبات از یک unsigned integer ستون بازگشت cardinality از نوع uint64 اگر اضافه کردن پسوند -دولت بازگشت [شی نگاشت بیت](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmap(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `UInt*` نوع. - -**مقدار بازگشتی** - -ارزش `UInt64` نوع. - -**مثال** - -داده های تست: - -``` text -UserID -1 -1 -2 -3 -``` - -پرسوجو: - -``` sql -SELECT groupBitmap(UserID) as num FROM t -``` - -نتیجه: - -``` text -num -3 -``` - -## کمینه) {#agg_function-min} - -محاسبه حداقل. - -## بیشینه) {#agg_function-max} - -محاسبه حداکثر. - -## هشدار داده می شود) {#agg-function-argmin} - -محاسبه ‘arg’ ارزش برای حداقل ‘val’ ارزش. اگر چندین مقدار مختلف وجود دارد ‘arg’ برای مقادیر حداقل ‘val’ اولین بار از این مقادیر مواجه خروجی است. - -**مثال:** - -``` text -┌─user─────┬─salary─┐ -│ director │ 5000 │ -│ manager │ 3000 │ -│ worker │ 1000 │ -└──────────┴────────┘ -``` - -``` sql -SELECT argMin(user, salary) FROM salary -``` - -``` text -┌─argMin(user, salary)─┐ -│ worker │ -└──────────────────────┘ -``` - -## هشدار داده می شود) {#agg-function-argmax} - -محاسبه ‘arg’ مقدار برای حداکثر ‘val’ ارزش. اگر چندین مقدار مختلف وجود دارد ‘arg’ برای حداکثر مقادیر ‘val’ اولین بار از این مقادیر مواجه خروجی است. - -## جمع) {#agg_function-sum} - -محاسبه مجموع. -فقط برای اعداد کار می کند. - -## ورود به سیستم) {#sumwithoverflowx} - -محاسبه مجموع اعداد, با استفاده از همان نوع داده برای نتیجه به عنوان پارامترهای ورودی. اگر مجموع بیش از حداکثر مقدار برای این نوع داده, تابع یک خطا می گرداند. - -فقط برای اعداد کار می کند. - -## sumMap(key, value) {#agg_functions-summap} - -مجموع ‘value’ تنظیم با توجه به کلید های مشخص شده در ‘key’ صف کردن. -تعداد عناصر در ‘key’ و ‘value’ باید همین کار را برای هر سطر است که بالغ بر شود. -Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. - -مثال: - -``` sql -CREATE TABLE sum_map( - date Date, - timeslot DateTime, - statusMap Nested( - status UInt16, - requests UInt64 - ) -) ENGINE = Log; -INSERT INTO sum_map VALUES - ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10]); -SELECT - timeslot, - sumMap(statusMap.status, statusMap.requests) -FROM sum_map -GROUP BY timeslot -``` - -``` text -┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┐ -│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ -│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ -└─────────────────────┴──────────────────────────────────────────────┘ -``` - -## سیخ کباب {#skewpop} - -محاسبه [skewness](https://en.wikipedia.org/wiki/Skewness) از یک توالی. - -``` sql -skewPop(expr) -``` - -**پارامترها** - -`expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد. - -**مقدار بازگشتی** - -The skewness of the given distribution. Type — [جسم شناور64](../../sql_reference/data_types/float.md) - -**مثال** - -``` sql -SELECT skewPop(value) FROM series_with_value_column -``` - -## سیخ {#skewsamp} - -محاسبه [نمونه skewness](https://en.wikipedia.org/wiki/Skewness) از یک توالی. - -این نشان دهنده یک تخمین بی طرفانه از اریب یک متغیر تصادفی اگر ارزش گذشت نمونه خود را تشکیل می دهند. - -``` sql -skewSamp(expr) -``` - -**پارامترها** - -`expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد. - -**مقدار بازگشتی** - -The skewness of the given distribution. Type — [جسم شناور64](../../sql_reference/data_types/float.md). اگر `n <= 1` (`n` اندازه نمونه است), سپس بازده تابع `nan`. - -**مثال** - -``` sql -SELECT skewSamp(value) FROM series_with_value_column -``` - -## کورتپ {#kurtpop} - -محاسبه [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) از یک توالی. - -``` sql -kurtPop(expr) -``` - -**پارامترها** - -`expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد. - -**مقدار بازگشتی** - -The kurtosis of the given distribution. Type — [جسم شناور64](../../sql_reference/data_types/float.md) - -**مثال** - -``` sql -SELECT kurtPop(value) FROM series_with_value_column -``` - -## کردها {#kurtsamp} - -محاسبه [نمونه kurtosis](https://en.wikipedia.org/wiki/Kurtosis) از یک توالی. - -این نشان دهنده یک تخمین بی طرفانه از کورتوز یک متغیر تصادفی اگر ارزش گذشت نمونه خود را تشکیل می دهند. - -``` sql -kurtSamp(expr) -``` - -**پارامترها** - -`expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد. - -**مقدار بازگشتی** - -The kurtosis of the given distribution. Type — [جسم شناور64](../../sql_reference/data_types/float.md). اگر `n <= 1` (`n` اندازه نمونه است) و سپس تابع بازده `nan`. - -**مثال** - -``` sql -SELECT kurtSamp(value) FROM series_with_value_column -``` - -## هشدار داده می شود) {#agg-function-timeseriesgroupsum} - -`timeSeriesGroupSum` می توانید سری های زمانی مختلف که برچسب زمان نمونه هم ترازی جمع نمی. -این برون یابی خطی بین دو برچسب زمان نمونه و سپس مجموع زمان سری با هم استفاده کنید. - -- `uid` سری زمان شناسه منحصر به فرد است, `UInt64`. -- `timestamp` است نوع درون64 به منظور حمایت میلی ثانیه یا میکروثانیه. -- `value` متریک است. - -تابع گرداند مجموعه ای از تاپل با `(timestamp, aggregated_value)` جفت - -قبل از استفاده از این تابع اطمینان حاصل کنید `timestamp` به ترتیب صعودی است. - -مثال: - -``` text -┌─uid─┬─timestamp─┬─value─┐ -│ 1 │ 2 │ 0.2 │ -│ 1 │ 7 │ 0.7 │ -│ 1 │ 12 │ 1.2 │ -│ 1 │ 17 │ 1.7 │ -│ 1 │ 25 │ 2.5 │ -│ 2 │ 3 │ 0.6 │ -│ 2 │ 8 │ 1.6 │ -│ 2 │ 12 │ 2.4 │ -│ 2 │ 18 │ 3.6 │ -│ 2 │ 24 │ 4.8 │ -└─────┴───────────┴───────┘ -``` - -``` sql -CREATE TABLE time_series( - uid UInt64, - timestamp Int64, - value Float64 -) ENGINE = Memory; -INSERT INTO time_series VALUES - (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), - (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); - -SELECT timeSeriesGroupSum(uid, timestamp, value) -FROM ( - SELECT * FROM time_series order by timestamp ASC -); -``` - -و نتیجه خواهد بود: - -``` text -[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] -``` - -## هشدار داده می شود) {#agg-function-timeseriesgroupratesum} - -به طور مشابه timeseriesgroupratesum, timeseriesgroupratesum را محاسبه نرخ سری زمانی و سپس مجموع نرخ با هم. -همچنین, برچسب زمان باید در جهت صعود قبل از استفاده از این تابع باشد. - -با استفاده از این تابع نتیجه مورد بالا خواهد بود: - -``` text -[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] -``` - -## میانگین) {#agg_function-avg} - -محاسبه متوسط. -فقط برای اعداد کار می کند. -نتیجه این است که همیشه شناور64. - -## uniq {#agg_function-uniq} - -محاسبه تعداد تقریبی مقادیر مختلف استدلال. - -``` sql -uniq(x[, ...]) -``` - -**پارامترها** - -تابع طول می کشد تعداد متغیر از پارامترهای. پارامترها می توانند باشند `Tuple`, `Array`, `Date`, `DateTime`, `String`, یا انواع عددی. - -**مقدار بازگشتی** - -- A [UInt64](../../sql_reference/data_types/int_uint.md)-نوع شماره. - -**پیاده سازی اطلاعات** - -تابع: - -- هش را برای تمام پارامترها در مجموع محاسبه می کند و سپس در محاسبات استفاده می شود. - -- با استفاده از یک تطبیقی نمونه الگوریتم. برای محاسبه دولت تابع با استفاده از یک نمونه از عنصر هش ارزش تا 65536. - - This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. - -- نتیجه را تعیین می کند (به سفارش پردازش پرس و جو بستگی ندارد). - -ما توصیه می کنیم با استفاده از این تابع تقریبا در تمام حالات. - -**همچنین نگاه کنید** - -- [مخلوط نشده](#agg_function-uniqcombined) -- [نیم قرن 64](#agg_function-uniqcombined64) -- [یونقلل12](#agg_function-uniqhll12) -- [قرارداد اتحادیه](#agg_function-uniqexact) - -## uniqCombined {#agg_function-uniqcombined} - -محاسبه تعداد تقریبی مقادیر استدلال های مختلف. - -``` sql -uniqCombined(HLL_precision)(x[, ...]) -``` - -این `uniqCombined` تابع یک انتخاب خوب برای محاسبه تعداد مقادیر مختلف است. - -**پارامترها** - -تابع طول می کشد تعداد متغیر از پارامترهای. پارامترها می توانند باشند `Tuple`, `Array`, `Date`, `DateTime`, `String`, یا انواع عددی. - -`HLL_precision` پایه-2 لگاریتم تعداد سلول ها در [جمع شدن](https://en.wikipedia.org/wiki/HyperLogLog). اختیاری, شما می توانید تابع به عنوان استفاده `uniqCombined(x[, ...])`. مقدار پیش فرض برای `HLL_precision` است 17, که به طور موثر 96 کیلوبایت فضا (2^17 سلول ها, 6 بیت در هر). - -**مقدار بازگشتی** - -- یک عدد [UInt64](../../sql_reference/data_types/int_uint.md)- نوع شماره . - -**پیاده سازی اطلاعات** - -تابع: - -- محاسبه هش (هش 64 بیتی برای `String` و در غیر این صورت 32 بیتی) برای تمام پارامترها در مجموع و سپس در محاسبات استفاده می شود. - -- با استفاده از ترکیبی از سه الگوریتم: مجموعه, جدول هش, و جمع شدن با جدول تصحیح خطا. - - For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. - -- نتیجه را تعیین می کند (به سفارش پردازش پرس و جو بستگی ندارد). - -!!! note "یادداشت" - از هش 32 بیتی برای غیر استفاده می کند-`String` نوع, نتیجه خطا بسیار بالا برای کاریت به طور قابل توجهی بزرگتر از اند `UINT_MAX` (خطا به سرعت پس از چند ده میلیارد ارزش متمایز افزایش خواهد یافت), از این رو در این مورد شما باید استفاده کنید [نیم قرن 64](#agg_function-uniqcombined64) - -در مقایسه با [uniq](#agg_function-uniq) عملکرد `uniqCombined`: - -- مصرف چندین بار حافظه کمتر. -- محاسبه با دقت چند بار بالاتر است. -- معمولا عملکرد کمی پایین تر است. در برخی از حالات, `uniqCombined` می توانید بهتر از انجام `uniq` برای مثال با توزیع نمایش داده شد که انتقال تعداد زیادی از جمع متحده بر روی شبکه. - -**همچنین نگاه کنید** - -- [دانشگاه](#agg_function-uniq) -- [نیم قرن 64](#agg_function-uniqcombined64) -- [یونقلل12](#agg_function-uniqhll12) -- [قرارداد اتحادیه](#agg_function-uniqexact) - -## نیم قرن 64 {#agg_function-uniqcombined64} - -مثل [مخلوط نشده](#agg_function-uniqcombined), اما با استفاده از هش 64 بیتی برای تمام انواع داده ها. - -## یونقلل12 {#agg_function-uniqhll12} - -محاسبه تعداد تقریبی مقادیر استدلال های مختلف, با استفاده از [جمع شدن](https://en.wikipedia.org/wiki/HyperLogLog) الگوریتم. - -``` sql -uniqHLL12(x[, ...]) -``` - -**پارامترها** - -این تابع یک متغیر تعدادی از پارامترهای. پارامترهای می تواند `Tuple`, `Array`, `Date`, `DateTime`, `String`, یا انواع عددی. - -**مقدار بازگشتی** - -- A [UInt64](../../sql_reference/data_types/int_uint.md)-نوع شماره. - -**پیاده سازی اطلاعات** - -تابع: - -- هش را برای تمام پارامترها در مجموع محاسبه می کند و سپس در محاسبات استفاده می شود. - -- با استفاده از الگوریتم جمع شدن تقریبی تعداد مقادیر استدلال های مختلف. - - 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). - -- نتیجه تعیین شده را فراهم می کند (به سفارش پردازش پرس و جو بستگی ندارد). - -ما توصیه نمی کنیم با استفاده از این تابع. در اغلب موارد از [دانشگاه](#agg_function-uniq) یا [مخلوط نشده](#agg_function-uniqcombined) تابع. - -**همچنین نگاه کنید** - -- [دانشگاه](#agg_function-uniq) -- [مخلوط نشده](#agg_function-uniqcombined) -- [قرارداد اتحادیه](#agg_function-uniqexact) - -## قرارداد اتحادیه {#agg_function-uniqexact} - -محاسبه تعداد دقیق ارزش استدلال های مختلف. - -``` sql -uniqExact(x[, ...]) -``` - -استفاده از `uniqExact` تابع اگر شما کاملا نیاز به یک نتیجه دقیق. در غیر این صورت استفاده از [uniq](#agg_function-uniq) تابع. - -این `uniqExact` تابع با استفاده از حافظه بیش از `uniq`, چرا که اندازه دولت رشد گشوده است به عنوان تعدادی از ارزش های مختلف را افزایش می دهد. - -**پارامترها** - -تابع طول می کشد تعداد متغیر از پارامترهای. پارامترها می توانند باشند `Tuple`, `Array`, `Date`, `DateTime`, `String`, یا انواع عددی. - -**همچنین نگاه کنید به** - -- [uniq](#agg_function-uniq) -- [مخلوط نشده](#agg_function-uniqcombined) -- [یونقلل12](#agg_function-uniqhll12) - -## groupArray(x) groupArray(max\_size)(x) {#agg_function-grouparray} - -مجموعه ای از مقادیر استدلال را ایجاد می کند. -مقادیر را می توان به ترتیب در هر (نامعین) اضافه کرد. - -نسخه دوم (با `max_size` پارامتر) اندازه مجموعه حاصل را محدود می کند `max_size` عناصر. -به عنوان مثال, `groupArray (1) (x)` معادل است `[any (x)]`. - -در بعضی موارد, شما هنوز هم می توانید در جهت اعدام تکیه. این امر در مورد مواردی که `SELECT` همراه از یک خرده فروشی که با استفاده از `ORDER BY`. - -## ارزش موقعیت) {#grouparrayinsertatvalue-position} - -مقدار را به مجموعه ای در موقعیت مشخص شده وارد می کند. - -!!! note "یادداشت" - این تابع با استفاده از موقعیت های مبتنی بر صفر, بر خلاف موقعیت های معمولی مبتنی بر یک برای فرود میدان. - -Accepts the value and position as input. If several values ​​are inserted into the same position, any of them might end up in the resulting array (the first one will be used in the case of single-threaded execution). If no value is inserted into a position, the position is assigned the default value. - -پارامترهای اختیاری: - -- مقدار پیش فرض برای جایگزینی در موقعیت های خالی. -- طول مجموعه حاصل. این اجازه می دهد تا شما را به دریافت مجموعه ای از همان اندازه برای تمام کلید های کل. هنگام استفاده از این پارامتر, مقدار پیش فرض باید مشخص شود. - -## هشدار داده می شود {#agg_function-grouparraymovingsum} - -محاسبه مجموع در حال حرکت از ارزش های ورودی. - -``` sql -groupArrayMovingSum(numbers_for_summing) -groupArrayMovingSum(window_size)(numbers_for_summing) -``` - -این تابع می تواند اندازه پنجره به عنوان یک پارامتر را. اگر سمت چپ نامشخص, تابع طول می کشد اندازه پنجره به تعداد ردیف در ستون برابر. - -**پارامترها** - -- `numbers_for_summing` — [عبارت](../syntax.md#syntax-expressions) در نتیجه یک مقدار نوع داده عددی. -- `window_size` — Size of the calculation window. - -**مقادیر بازگشتی** - -- مجموعه ای از همان اندازه و نوع به عنوان داده های ورودی. - -**مثال** - -جدول نمونه: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -نمایش داده شد: - -``` sql -SELECT - groupArrayMovingSum(int) AS I, - groupArrayMovingSum(float) AS F, - groupArrayMovingSum(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingSum(2)(int) AS I, - groupArrayMovingSum(2)(float) AS F, - groupArrayMovingSum(2)(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -## گروهاریموینگاوگ {#agg_function-grouparraymovingavg} - -محاسبه میانگین متحرک از ارزش های ورودی. - -``` sql -groupArrayMovingAvg(numbers_for_summing) -groupArrayMovingAvg(window_size)(numbers_for_summing) -``` - -این تابع می تواند اندازه پنجره به عنوان یک پارامتر را. اگر سمت چپ نامشخص, تابع طول می کشد اندازه پنجره به تعداد ردیف در ستون برابر. - -**پارامترها** - -- `numbers_for_summing` — [عبارت](../syntax.md#syntax-expressions) در نتیجه یک مقدار نوع داده عددی. -- `window_size` — Size of the calculation window. - -**مقادیر بازگشتی** - -- مجموعه ای از همان اندازه و نوع به عنوان داده های ورودی. - -تابع استفاده می کند [گرد کردن به سمت صفر](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). این کوتاه رقم اعشار ناچیز برای نوع داده و در نتیجه. - -**مثال** - -جدول نمونه `b`: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -نمایش داده شد: - -``` sql -SELECT - groupArrayMovingAvg(int) AS I, - groupArrayMovingAvg(float) AS F, - groupArrayMovingAvg(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ -│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ -└───────────┴─────────────────────────────────────┴───────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingAvg(2)(int) AS I, - groupArrayMovingAvg(2)(float) AS F, - groupArrayMovingAvg(2)(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ -│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ -└───────────┴──────────────────────────────────┴───────────────────────┘ -``` - -## groupUniqArray(x) groupUniqArray(max\_size)(x) {#groupuniqarrayx-groupuniqarraymax-sizex} - -مجموعه ای از مقادیر مختلف استدلال ایجاد می کند. مصرف حافظه همان است که برای `uniqExact` تابع. - -نسخه دوم (با `max_size` پارامتر) اندازه مجموعه حاصل را محدود می کند `max_size` عناصر. -به عنوان مثال, `groupUniqArray(1)(x)` معادل است `[any(x)]`. - -## quantile {#quantile} - -محاسبه تقریبی [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی. - -این تابع اعمال می شود [نمونه برداری مخزن](https://en.wikipedia.org/wiki/Reservoir_sampling) با اندازه مخزن تا 8192 و یک مولد عدد تصادفی برای نمونه برداری. نتیجه غیر قطعی است. برای دریافت یک کمی دقیق, استفاده از [کوانتوم](#quantileexact) تابع. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantile(level)(expr) -``` - -نام مستعار: `median`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [انواع داده ها](../../sql_reference/data_types/index.md#data_types), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). - -**مقدار بازگشتی** - -- کمی تقریبی از سطح مشخص شده است. - -نوع: - -- [جسم شناور64](../../sql_reference/data_types/float.md) برای ورودی نوع داده عددی. -- [تاریخ](../../sql_reference/data_types/date.md) اگر مقادیر ورودی `Date` نوع. -- [DateTime](../../sql_reference/data_types/datetime.md) اگر مقادیر ورودی `DateTime` نوع. - -**مثال** - -جدول ورودی: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -پرسوجو: - -``` sql -SELECT quantile(val) FROM t -``` - -نتیجه: - -``` text -┌─quantile(val)─┐ -│ 1.5 │ -└───────────────┘ -``` - -**همچنین نگاه کنید به** - -- [میانه](#median) -- [quantiles](#quantiles) - -## نامعینیهای کوانتی {#quantiledeterministic} - -محاسبه تقریبی [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی. - -این تابع اعمال می شود [نمونه برداری مخزن](https://en.wikipedia.org/wiki/Reservoir_sampling) با اندازه مخزن تا 8192 و الگوریتم قطعی نمونه گیری. نتیجه قطعی است. برای دریافت یک کمی دقیق, استفاده از [کوانتوم](#quantileexact) تابع. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileDeterministic(level)(expr, determinator) -``` - -نام مستعار: `medianDeterministic`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [انواع داده ها](../../sql_reference/data_types/index.md#data_types), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). -- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. - -**مقدار بازگشتی** - -- کمی تقریبی از سطح مشخص شده است. - -نوع: - -- [جسم شناور64](../../sql_reference/data_types/float.md) برای ورودی نوع داده عددی. -- [تاریخ](../../sql_reference/data_types/date.md) اگر مقادیر ورودی `Date` نوع. -- [DateTime](../../sql_reference/data_types/datetime.md) اگر مقادیر ورودی `DateTime` نوع. - -**مثال** - -جدول ورودی: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -پرسوجو: - -``` sql -SELECT quantileDeterministic(val, 1) FROM t -``` - -نتیجه: - -``` text -┌─quantileDeterministic(val, 1)─┐ -│ 1.5 │ -└───────────────────────────────┘ -``` - -**همچنین نگاه کنید** - -- [میانه](#median) -- [quantiles](#quantiles) - -## کوانتوم {#quantileexact} - -دقیقا محاسبه می کند [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی. - -To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` حافظه, جایی که `n` تعدادی از ارزش هایی که تصویب شد. اما, برای تعداد کمی از ارزش, تابع بسیار موثر است. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileExact(level)(expr) -``` - -نام مستعار: `medianExact`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [انواع داده ها](../../sql_reference/data_types/index.md#data_types), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). - -**مقدار بازگشتی** - -- Quantile از سطح مشخص شده. - -نوع: - -- [جسم شناور64](../../sql_reference/data_types/float.md) برای ورودی نوع داده عددی. -- [تاریخ](../../sql_reference/data_types/date.md) اگر مقادیر ورودی `Date` نوع. -- [DateTime](../../sql_reference/data_types/datetime.md) اگر مقادیر ورودی `DateTime` نوع. - -**مثال** - -پرسوجو: - -``` sql -SELECT quantileExact(number) FROM numbers(10) -``` - -نتیجه: - -``` text -┌─quantileExact(number)─┐ -│ 5 │ -└───────────────────────┘ -``` - -**همچنین نگاه کنید** - -- [میانه](#median) -- [quantiles](#quantiles) - -## نمایش سایت {#quantileexactweighted} - -دقیقا محاسبه می کند [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی, با در نظر گرفتن وزن هر عنصر. - -To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [کوانتوم](#quantileexact). شما می توانید این تابع به جای استفاده از `quantileExact` و وزن 1 را مشخص کنید. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileExactWeighted(level)(expr, weight) -``` - -نام مستعار: `medianExactWeighted`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [انواع داده ها](../../sql_reference/data_types/index.md#data_types), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). -- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. - -**مقدار بازگشتی** - -- Quantile از سطح مشخص شده. - -نوع: - -- [جسم شناور64](../../sql_reference/data_types/float.md) برای ورودی نوع داده عددی. -- [تاریخ](../../sql_reference/data_types/date.md) اگر مقادیر ورودی `Date` نوع. -- [DateTime](../../sql_reference/data_types/datetime.md) اگر مقادیر ورودی `DateTime` نوع. - -**مثال** - -جدول ورودی: - -``` text -┌─n─┬─val─┐ -│ 0 │ 3 │ -│ 1 │ 2 │ -│ 2 │ 1 │ -│ 5 │ 4 │ -└───┴─────┘ -``` - -پرسوجو: - -``` sql -SELECT quantileExactWeighted(n, val) FROM t -``` - -نتیجه: - -``` text -┌─quantileExactWeighted(n, val)─┐ -│ 1 │ -└───────────────────────────────┘ -``` - -**همچنین نگاه کنید به** - -- [میانه](#median) -- [quantiles](#quantiles) - -## زمان کمی {#quantiletiming} - -با دقت تعیین شده محاسبه می شود [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی. - -نتیجه قطعی است(به سفارش پردازش پرس و جو بستگی ندارد). این تابع برای کار با توالی هایی که توزیع هایی مانند بارگذاری صفحات وب بار یا زمان پاسخ باطن را توصیف می کنند بهینه شده است. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileTiming(level)(expr) -``` - -نام مستعار: `medianTiming`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). - -- `expr` — [عبارت](../syntax.md#syntax-expressions) بیش از یک مقادیر ستون بازگشت [شناور\*](../../sql_reference/data_types/float.md)-نوع شماره. - - - If negative values are passed to the function, the behavior is undefined. - - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. - -**دقت** - -محاسبه دقیق است اگر: - -- تعداد کل مقادیر 5670 تجاوز نمی کند. -- تعداد کل مقادیر بیش از 5670, اما زمان بارگذاری صفحه کمتر از است 1024خانم. - -در غیر این صورت, نتیجه محاسبه به نزدیکترین چند از گرد 16 خانم. - -!!! note "یادداشت" - برای محاسبه زمان بارگذاری صفحه quantiles این تابع این است که موثر تر و دقیق تر از [quantile](#quantile). - -**مقدار بازگشتی** - -- Quantile از سطح مشخص شده. - -نوع: `Float32`. - -!!! note "یادداشت" - اگر هیچ ارزش به تابع منتقل می شود (هنگام استفاده از `quantileTimingIf`), [نان](../../sql_reference/data_types/float.md#data_type-float-nan-inf) بازگشته است. هدف از این است که افتراق این موارد از مواردی که منجر به صفر. ببینید [ORDER BY](../statements/select.md#select-order-by) برای یادداشت ها در مرتب سازی `NaN` ارزشهای خبری عبارتند از: - -**مثال** - -جدول ورودی: - -``` text -┌─response_time─┐ -│ 72 │ -│ 112 │ -│ 126 │ -│ 145 │ -│ 104 │ -│ 242 │ -│ 313 │ -│ 168 │ -│ 108 │ -└───────────────┘ -``` - -پرسوجو: - -``` sql -SELECT quantileTiming(response_time) FROM t -``` - -نتیجه: - -``` text -┌─quantileTiming(response_time)─┐ -│ 126 │ -└───────────────────────────────┘ -``` - -**همچنین نگاه کنید به** - -- [میانه](#median) -- [quantiles](#quantiles) - -## زمان کمی {#quantiletimingweighted} - -با دقت تعیین شده محاسبه می شود [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی با توجه به وزن هر یک از اعضای دنباله. - -نتیجه قطعی است(به سفارش پردازش پرس و جو بستگی ندارد). این تابع برای کار با توالی هایی که توزیع هایی مانند بارگذاری صفحات وب بار یا زمان پاسخ باطن را توصیف می کنند بهینه شده است. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileTimingWeighted(level)(expr, weight) -``` - -نام مستعار: `medianTimingWeighted`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). - -- `expr` — [عبارت](../syntax.md#syntax-expressions) بیش از یک مقادیر ستون بازگشت [شناور\*](../../sql_reference/data_types/float.md)- نوع شماره . - - - If negative values are passed to the function, the behavior is undefined. - - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. - -- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. - -**دقت** - -محاسبه دقیق است اگر: - -- تعداد کل مقادیر 5670 تجاوز نمی کند. -- تعداد کل مقادیر بیش از 5670, اما زمان بارگذاری صفحه کمتر از است 1024خانم. - -در غیر این صورت, نتیجه محاسبه به نزدیکترین چند از گرد 16 خانم. - -!!! note "یادداشت" - برای محاسبه زمان بارگذاری صفحه quantiles این تابع این است که موثر تر و دقیق تر از [quantile](#quantile). - -**مقدار بازگشتی** - -- Quantile از سطح مشخص شده. - -نوع: `Float32`. - -!!! note "یادداشت" - اگر هیچ ارزش به تابع منتقل می شود (هنگام استفاده از `quantileTimingIf`), [نان](../../sql_reference/data_types/float.md#data_type-float-nan-inf) بازگشته است. هدف از این است که افتراق این موارد از مواردی که منجر به صفر. ببینید [ORDER BY](../statements/select.md#select-order-by) برای یادداشت ها در مرتب سازی `NaN` ارزشهای خبری عبارتند از: - -**مثال** - -جدول ورودی: - -``` text -┌─response_time─┬─weight─┐ -│ 68 │ 1 │ -│ 104 │ 2 │ -│ 112 │ 3 │ -│ 126 │ 2 │ -│ 138 │ 1 │ -│ 162 │ 1 │ -└───────────────┴────────┘ -``` - -پرسوجو: - -``` sql -SELECT quantileTimingWeighted(response_time, weight) FROM t -``` - -نتیجه: - -``` text -┌─quantileTimingWeighted(response_time, weight)─┐ -│ 112 │ -└───────────────────────────────────────────────┘ -``` - -**همچنین نگاه کنید** - -- [میانه](#median) -- [quantiles](#quantiles) - -## مقدار کمی {#quantiletdigest} - -محاسبه تقریبی [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی با استفاده از [خلاصه](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) الگوریتم. - -حداکثر خطا است 1%. مصرف حافظه است `log(n)` کجا `n` تعدادی از ارزش است. نتیجه بستگی دارد منظور از در حال اجرا پرس و جو و nondeterministic. - -عملکرد تابع کمتر از عملکرد است [quantile](#quantile) یا [زمان کمی](#quantiletiming). از لحاظ نسبت اندازه دولت به دقت, این تابع بسیار بهتر از `quantile`. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileTDigest(level)(expr) -``` - -نام مستعار: `medianTDigest`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [انواع داده ها](../../sql_reference/data_types/index.md#data_types), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). - -**مقدار بازگشتی** - -- کمی تقریبی از سطح مشخص شده است. - -نوع: - -- [جسم شناور64](../../sql_reference/data_types/float.md) برای ورودی نوع داده عددی. -- [تاریخ](../../sql_reference/data_types/date.md) اگر مقادیر ورودی `Date` نوع. -- [DateTime](../../sql_reference/data_types/datetime.md) اگر مقادیر ورودی `DateTime` نوع. - -**مثال** - -پرسوجو: - -``` sql -SELECT quantileTDigest(number) FROM numbers(10) -``` - -نتیجه: - -``` text -┌─quantileTDigest(number)─┐ -│ 4.5 │ -└─────────────────────────┘ -``` - -**همچنین نگاه کنید به** - -- [میانه](#median) -- [quantiles](#quantiles) - -## نمایش سایت {#quantiletdigestweighted} - -محاسبه تقریبی [quantile](https://en.wikipedia.org/wiki/Quantile) از یک توالی داده های عددی با استفاده از [خلاصه](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) الگوریتم. تابع طول می کشد را به حساب وزن هر یک از اعضای دنباله. حداکثر خطا است 1%. مصرف حافظه است `log(n)` کجا `n` تعدادی از ارزش است. - -عملکرد تابع کمتر از عملکرد است [quantile](#quantile) یا [زمان کمی](#quantiletiming). از لحاظ نسبت اندازه دولت به دقت, این تابع بسیار بهتر از `quantile`. - -نتیجه بستگی دارد منظور از در حال اجرا پرس و جو و nondeterministic. - -هنگام استفاده از چندین `quantile*` توابع با سطوح مختلف در پرس و جو, کشورهای داخلی در ترکیب نیست (به این معنا که, پرس و جو کار می کند موثر کمتر از می تواند). در این مورد از [quantiles](#quantiles) تابع. - -**نحو** - -``` sql -quantileTDigest(level)(expr) -``` - -نام مستعار: `medianTDigest`. - -**پارامترها** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` مقدار در محدوده `[0.01, 0.99]`. مقدار پیش فرض: 0.5. در `level=0.5` تابع محاسبه می کند [میانه](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [انواع داده ها](../../sql_reference/data_types/index.md#data_types), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). -- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. - -**مقدار بازگشتی** - -- کمی تقریبی از سطح مشخص شده است. - -نوع: - -- [جسم شناور64](../../sql_reference/data_types/float.md) برای ورودی نوع داده عددی. -- [تاریخ](../../sql_reference/data_types/date.md) اگر مقادیر ورودی `Date` نوع. -- [DateTime](../../sql_reference/data_types/datetime.md) اگر مقادیر ورودی `DateTime` نوع. - -**مثال** - -پرسوجو: - -``` sql -SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) -``` - -نتیجه: - -``` text -┌─quantileTDigestWeighted(number, 1)─┐ -│ 4.5 │ -└────────────────────────────────────┘ -``` - -**همچنین نگاه کنید به** - -- [میانه](#median) -- [quantiles](#quantiles) - -## میانه {#median} - -این `median*` توابع نام مستعار برای مربوطه `quantile*` توابع. متوسط یک نمونه داده عددی را محاسبه می کنند. - -توابع: - -- `median` — Alias for [quantile](#quantile). -- `medianDeterministic` — Alias for [نامعینیهای کوانتی](#quantiledeterministic). -- `medianExact` — Alias for [کوانتوم](#quantileexact). -- `medianExactWeighted` — Alias for [نمایش سایت](#quantileexactweighted). -- `medianTiming` — Alias for [زمان کمی](#quantiletiming). -- `medianTimingWeighted` — Alias for [زمان کمی](#quantiletimingweighted). -- `medianTDigest` — Alias for [مقدار کمی](#quantiletdigest). -- `medianTDigestWeighted` — Alias for [نمایش سایت](#quantiletdigestweighted). - -**مثال** - -جدول ورودی: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -پرسوجو: - -``` sql -SELECT medianDeterministic(val, 1) FROM t -``` - -نتیجه: - -``` text -┌─medianDeterministic(val, 1)─┐ -│ 1.5 │ -└─────────────────────────────┘ -``` - -## quantiles(level1, level2, …)(x) {#quantiles} - -تمام quantile توابع نیز مربوط quantiles توابع: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. این توابع محاسبه تمام کوانتوم از سطوح ذکر شده در یک پاس, و بازگشت مجموعه ای از مقادیر حاصل. - -## اطلاعات دقیق) {#varsampx} - -محاسبه مقدار `Σ((x - x̅)^2) / (n - 1)` کجا `n` اندازه نمونه است و `x̅`مقدار متوسط است `x`. - -این نشان دهنده یک تخمین بی طرفانه از واریانس یک متغیر تصادفی اگر ارزش گذشت نمونه خود را تشکیل می دهند. - -بازگشت `Float64`. چه زمانی `n <= 1`, بازگشت `+∞`. - -## هشدار داده می شود) {#varpopx} - -محاسبه مقدار `Σ((x - x̅)^2) / n` کجا `n` اندازه نمونه است و `x̅`مقدار متوسط است `x`. - -به عبارت دیگر, پراکندگی برای مجموعه ای از ارزش. بازگشت `Float64`. - -## اطلاعات دقیق) {#stddevsampx} - -نتیجه برابر با ریشه مربع است `varSamp(x)`. - -## اطلاعات دقیق) {#stddevpopx} - -نتیجه برابر با ریشه مربع است `varPop(x)`. - -## topK(N)(x) {#topknx} - -بازگرداندن مجموعه ای از مقادیر تقریبا شایع ترین در ستون مشخص. مجموعه حاصل به ترتیب نزولی فرکانس تقریبی ارزش ها (نه با ارزش های خود) طبقه بندی شده اند. - -پیاده سازی [فیلتر صرفه جویی در فضا](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) الگوریتم برای تجزیه و تحلیل توپک, بر اساس الگوریتم کاهش و ترکیب از [صرفه جویی در فضای موازی](https://arxiv.org/pdf/1401.0702.pdf). - -``` sql -topK(N)(column) -``` - -این تابع یک نتیجه تضمین شده را فراهم نمی کند. در شرایط خاص, اشتباهات ممکن است رخ دهد و ممکن است مقادیر مکرر که مقادیر شایع ترین نیست بازگشت. - -ما توصیه می کنیم با استفاده از `N < 10` عملکرد با بزرگ کاهش می یابد `N` ارزشهای خبری عبارتند از: حداکثر مقدار `N = 65536`. - -**پارامترها** - -- ‘N’ است تعدادی از عناصر به بازگشت. - -اگر پارامتر حذف شده است, مقدار پیش فرض 10 استفاده شده است. - -**نشانوندها** - -- ' x ' – The value to calculate frequency. - -**مثال** - -نگاهی به [به موقع](../../getting_started/example_datasets/ontime.md) مجموعه داده ها و انتخاب سه ارزش اغلب اتفاق می افتد در `AirlineID` ستون. - -``` sql -SELECT topK(3)(AirlineID) AS res -FROM ontime -``` - -``` text -┌─res─────────────────┐ -│ [19393,19790,19805] │ -└─────────────────────┘ -``` - -## کشتی کج {#topkweighted} - -مشابه به `topK` اما طول می کشد یک استدلال اضافی از نوع صحیح - `weight`. هر مقدار به حساب `weight` بار برای محاسبه فرکانس. - -**نحو** - -``` sql -topKWeighted(N)(x, weight) -``` - -**پارامترها** - -- `N` — The number of elements to return. - -**نشانوندها** - -- `x` – The value. -- `weight` — The weight. [UInt8](../../sql_reference/data_types/int_uint.md). - -**مقدار بازگشتی** - -بازگرداندن مجموعه ای از مقادیر با حداکثر مجموع تقریبی وزن. - -**مثال** - -پرسوجو: - -``` sql -SELECT topKWeighted(10)(number, number) FROM numbers(1000) -``` - -نتیجه: - -``` text -┌─topKWeighted(10)(number, number)──────────┐ -│ [999,998,997,996,995,994,993,992,991,990] │ -└───────────────────────────────────────────┘ -``` - -## هشدار داده می شود) {#covarsampx-y} - -محاسبه ارزش `Σ((x - x̅)(y - y̅)) / (n - 1)`. - -را برمی گرداند شناور64. زمانی که `n <= 1`, returns +∞. - -## نمایش سایت) {#covarpopx-y} - -محاسبه ارزش `Σ((x - x̅)(y - y̅)) / n`. - -## هشدار داده می شود) {#corrx-y} - -محاسبه ضریب همبستگی پیرسون: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. - -## طبقه بندی فرمول بندی {#categoricalinformationvalue} - -محاسبه ارزش `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` برای هر دسته. - -``` sql -categoricalInformationValue(category1, category2, ..., tag) -``` - -نتیجه نشان می دهد که چگونه یک ویژگی گسسته (قطعی) `[category1, category2, ...]` کمک به یک مدل یادگیری که پیش بینی ارزش `tag`. - -## ساده سازی مقررات {#simplelinearregression} - -انجام ساده (unidimensional) رگرسیون خطی. - -``` sql -simpleLinearRegression(x, y) -``` - -پارامترها: - -- `x` — Column with dependent variable values. -- `y` — Column with explanatory variable values. - -مقادیر بازگشتی: - -ثابتها `(a, b)` از خط نتیجه `y = a*x + b`. - -**مثالها** - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ -│ (1,0) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ -│ (1,3) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## تنظیم مقررات {#agg_functions-stochasticlinearregression} - -این تابع پیاده سازی رگرسیون خطی تصادفی. این پشتیبانی از پارامترهای سفارشی برای نرخ یادگیری, ل2 ضریب منظم, اندازه مینی دسته ای و دارای چند روش برای به روز رسانی وزن ([ادام](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (به طور پیش فرض استفاده می شود), [اطلاعات دقیق](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [شتاب](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [نستروف](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). - -### پارامترها {#agg_functions-stochasticlinearregression-parameters} - -4 پارامتر قابل تنظیم وجود دارد. به ترتیب تابع منتقل می شود اما بدون نیاز به تصویب تمام مقادیر چهار پیش فرض استفاده می شود با این حال مدل خوب مورد نیاز برخی از تنظیم پارامتر وجود دارد. - -``` text -stochasticLinearRegression(1.0, 1.0, 10, 'SGD') -``` - -1. `learning rate` ضریب در طول گام است, زمانی که گام گرادیان تبار انجام شده است. نرخ یادگیری بیش از حد بزرگ ممکن است وزن بی نهایت از مدل شود. پیشفرض `0.00001`. -2. `l2 regularization coefficient` که ممکن است کمک به جلوگیری از سوراخ سوراخ شدن بیش از حد. پیشفرض `0.1`. -3. `mini-batch size` مجموعه تعدادی از عناصر که شیب محاسبه خواهد شد و خلاصه به انجام یک مرحله از گرادیان تبار. تبار تصادفی خالص با استفاده از یک عنصر, با این حال داشتن دسته های کوچک(در باره 10 عناصر) را گام شیب پایدار تر. پیشفرض `15`. -4. `method for updating weights` اونا: `Adam` (به طور پیش فرض), `SGD`, `Momentum`, `Nesterov`. `Momentum` و `Nesterov` نیاز به کمی بیشتر محاسبات و حافظه, اما آنها به اتفاق مفید از نظر سرعت convergance و ثبات stochastic gradient روش. - -### استفاده {#agg_functions-stochasticlinearregression-usage} - -`stochasticLinearRegression` در دو مرحله استفاده می شود: اتصالات مدل و پیش بینی بر روی داده های جدید. به منظور متناسب با مدل و صرفه جویی در دولت خود را برای استفاده های بعدی استفاده می کنیم `-State` ترکیب کننده, که اساسا موجب صرفه جویی در دولت (وزن مدل, و غیره). -برای پیش بینی ما با استفاده از تابع [ارزیابی](../functions/machine_learning_functions.md#machine_learning_methods-evalmlmethod), که طول می کشد یک دولت به عنوان یک استدلال و همچنین ویژگی های به پیش بینی در. - - - -**1.** اتصالات - -چنین پرس و جو ممکن است مورد استفاده قرار گیرد. - -``` sql -CREATE TABLE IF NOT EXISTS train_data -( - param1 Float64, - param2 Float64, - target Float64 -) ENGINE = Memory; - -CREATE TABLE your_model ENGINE = Memory AS SELECT -stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) -AS state FROM train_data; -``` - -در اینجا ما همچنین نیاز به وارد کردن داده ها به `train_data` جدول تعداد پارامترهای ثابت نیست, این تنها در تعدادی از استدلال بستگی دارد, گذشت به `linearRegressionState`. همه باید مقادیر عددی باشد. -توجه داشته باشید که ستون با ارزش هدف(که ما می خواهم برای یادگیری به پیش بینی) به عنوان اولین استدلال قرار داده شده است. - -**2.** پیش بینی - -پس از ذخیره یک دولت به جدول, ما ممکن است چندین بار برای پیش بینی استفاده, و یا حتی با کشورهای دیگر ادغام و ایجاد مدل های جدید و حتی بهتر. - -``` sql -WITH (SELECT state FROM your_model) AS model SELECT -evalMLMethod(model, param1, param2) FROM test_data -``` - -پرس و جو یک ستون از مقادیر پیش بینی شده بازگشت. توجه داشته باشید که استدلال اول `evalMLMethod` هست `AggregateFunctionState` هدف, بعدی ستون از ویژگی های هستند. - -`test_data` یک جدول مانند `train_data` اما ممکن است حاوی ارزش هدف نیست. - -### یادداشتها {#agg_functions-stochasticlinearregression-notes} - -1. برای ادغام دو مدل کاربر ممکن است چنین پرس و جو ایجاد کنید: - `sql SELECT state1 + state2 FROM your_models` - کجا `your_models` جدول شامل هر دو مدل. این پرس و جو جدید باز خواهد گشت `AggregateFunctionState` اعتراض. - -2. کاربر ممکن است وزن مدل ایجاد شده برای اهداف خود را بدون صرفه جویی در مدل اگر هیچ واکشی `-State` ترکیب استفاده شده است. - `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` - چنین پرس و جو خواهد مدل مناسب و بازگشت وزن خود را - برای اولین بار وزن هستند, که به پارامترهای مدل مطابقت, یکی از گذشته تعصب است. بنابراین در مثال بالا پرس و جو یک ستون با 3 مقدار بازگشت. - -**همچنین نگاه کنید** - -- [سرکوب مقررات عمومی](#agg_functions-stochasticlogisticregression) -- [تفاوت رگرسیون خطی و لجستیک](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## سرکوب مقررات عمومی {#agg_functions-stochasticlogisticregression} - -این تابع پیاده سازی رگرسیون لجستیک تصادفی. این را می توان برای مشکل طبقه بندی دودویی استفاده, پشتیبانی از پارامترهای سفارشی به عنوان مقررات زدایی و کار به همان شیوه. - -### پارامترها {#agg_functions-stochasticlogisticregression-parameters} - -پارامترها دقیقا مشابه در تنظیم مقررات است: -`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. -برای اطلاعات بیشتر نگاه کنید به [پارامترها](#agg_functions-stochasticlinearregression-parameters). - -``` text -stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') -``` - -1. اتصالات - - - - See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. - - Predicted labels have to be in \[-1, 1\]. - -1. پیش بینی - - - - Using saved state we can predict probability of object having label `1`. - - ``` sql - WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) FROM test_data - ``` - - The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. - - We can also set a bound of probability, which assigns elements to different labels. - - ``` sql - SELECT ans < 1.1 AND ans > 0.5 FROM - (WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) AS ans FROM test_data) - ``` - - Then the result will be labels. - - `test_data` is a table like `train_data` but may not contain target value. - -**همچنین نگاه کنید** - -- [تنظیم مقررات](#agg_functions-stochasticlinearregression) -- [تفاوت بین رگرسیون خطی و لجستیک.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## گروهبیتمافند {#groupbitmapand} - -محاسبات و یک بیت مپ ستون بازگشت cardinality از نوع uint64 اگر اضافه کردن پسوند -دولت بازگشت [شی نگاشت بیت](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmapAnd(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` نوع. - -**مقدار بازگشتی** - -ارزش `UInt64` نوع. - -**مثال** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapAnd(z)─┐ -│ 3 │ -└───────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ -│ [6,8,10] │ -└──────────────────────────────────────────────────┘ -``` - -## گروهبیتمافور {#groupbitmapor} - -محاسبات و یا یک بیت مپ ستون بازگشت cardinality از نوع uint64 اگر اضافه کردن پسوند -دولت بازگشت [شی نگاشت بیت](../../sql_reference/functions/bitmap_functions.md). این معادل است `groupBitmapMerge`. - -``` sql -groupBitmapOr(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` نوع. - -**مقدار بازگشتی** - -ارزش `UInt64` نوع. - -**مثال** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapOr(z)─┐ -│ 15 │ -└──────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ -│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ -└─────────────────────────────────────────────────┘ -``` - -## گروهبیتمافکر {#groupbitmapxor} - -محاسبات xor یک بیت مپ ستون بازگشت cardinality از نوع uint64 اگر اضافه کردن پسوند -دولت بازگشت [شی نگاشت بیت](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmapOr(expr) -``` - -**پارامترها** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` نوع. - -**مقدار بازگشتی** - -ارزش `UInt64` نوع. - -**مثال** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapXor(z)─┐ -│ 10 │ -└───────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ -│ [1,3,5,6,8,10,11,13,14,15] │ -└──────────────────────────────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/fa/sql_reference/ansi.md b/docs/fa/sql_reference/ansi.md deleted file mode 120000 index ee0f9c8cb7e..00000000000 --- a/docs/fa/sql_reference/ansi.md +++ /dev/null @@ -1 +0,0 @@ -../../en/sql_reference/ansi.md \ No newline at end of file diff --git a/docs/fa/sql_reference/data_types/aggregatefunction.md b/docs/fa/sql_reference/data_types/aggregatefunction.md deleted file mode 100644 index f6430b6658c..00000000000 --- a/docs/fa/sql_reference/data_types/aggregatefunction.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 52 -toc_title: "\u06A9\u0627\u0631\u06A9\u0631\u062F(\u0646\u0627\u0645 \u0648 \u0646\u0627\ - \u0645 \u062E\u0627\u0646\u0648\u0627\u062F\u06AF\u06CC..)" ---- - -# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} - -Aggregate functions can have an implementation-defined intermediate state that can be serialized to an AggregateFunction(…) data type and stored in a table, usually, by means of [مشاهده محقق](../../sql_reference/statements/select.md#create-view). راه معمول برای تولید یک دولت تابع جمع است با فراخوانی تابع جمع با `-State` پسوند. برای دریافت نتیجه نهایی از تجمع در اینده, شما باید همان تابع کل با استفاده از `-Merge`پسوند. - -`AggregateFunction` — parametric data type. - -**پارامترها** - -- نام تابع جمع. - - If the function is parametric, specify its parameters too. - -- انواع استدلال تابع جمع. - -**مثال** - -``` sql -CREATE TABLE t -( - column1 AggregateFunction(uniq, UInt64), - column2 AggregateFunction(anyIf, String, UInt8), - column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) -) ENGINE = ... -``` - -[دانشگاه](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq). ([هر](../../sql_reference/aggregate_functions/reference.md#agg_function-any)+[اگر](../../sql_reference/aggregate_functions/combinators.md#agg-functions-combinator-if)) و [quantiles](../../sql_reference/aggregate_functions/reference.md) توابع مجموع پشتیبانی در خانه کلیک می باشد. - -## استفاده {#usage} - -### درج داده {#data-insertion} - -برای وارد کردن داده ها استفاده کنید `INSERT SELECT` با مجموع `-State`- توابع . - -**نمونه تابع** - -``` sql -uniqState(UserID) -quantilesState(0.5, 0.9)(SendTiming) -``` - -در مقایسه با توابع مربوطه `uniq` و `quantiles`, `-State`- توابع بازگشت به دولت, به جای ارزش نهایی. به عبارت دیگر ارزش بازگشت `AggregateFunction` نوع. - -در نتایج `SELECT` پرس و جو, ارزش `AggregateFunction` نوع اجرای خاص نمایندگی دودویی برای همه فرمت های خروجی کلیک کنید. اگر کمپرسی داده ها به, مثلا, `TabSeparated` قالب با `SELECT` پرس و جو, سپس این روگرفت را می توان با استفاده از لود `INSERT` پرس و جو. - -### گزینش داده {#data-selection} - -هنگام انتخاب داده ها از `AggregatingMergeTree` جدول استفاده کنید `GROUP BY` بند و همان مجموع توابع به عنوان زمانی که قرار دادن داده اما با استفاده از `-Merge`پسوند. - -یک تابع جمع با `-Merge` پسوند مجموعه ای از ایالت ها را ترکیب می کند و نتیجه تجمع کامل داده ها را باز می گرداند. - -مثلا, دو نمایش داده شد زیر بازگشت به همان نتیجه: - -``` sql -SELECT uniq(UserID) FROM table - -SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) -``` - -## مثال طریقه استفاده {#usage-example} - -ببینید [ریزدانه](../../engines/table_engines/mergetree_family/aggregatingmergetree.md) موتور باشرکت. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/fa/sql_reference/data_types/array.md b/docs/fa/sql_reference/data_types/array.md deleted file mode 100644 index 322e806b8ba..00000000000 --- a/docs/fa/sql_reference/data_types/array.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 51 -toc_title: "& \u062A\u0648\u0631\u06CC)" ---- - -# & توری) {#data-type-array} - -مجموعه ای از `T`- نوع اقلام است. `T` می تواند هر نوع داده, از جمله مجموعه. - -## ایجاد یک مجموعه {#creating-an-array} - -شما می توانید یک تابع برای ایجاد مجموعه ای استفاده کنید: - -``` sql -array(T) -``` - -شما همچنین می توانید براکت مربع استفاده کنید. - -``` sql -[] -``` - -نمونه ای از ایجاد یک مجموعه: - -``` sql -SELECT array(1, 2) AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName(array(1, 2))─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴─────────────────────────┘ -``` - -``` sql -SELECT [1, 2] AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName([1, 2])─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴────────────────────┘ -``` - -## کار با انواع داده ها {#working-with-data-types} - -در هنگام ایجاد مجموعه ای در پرواز, خانه رعیتی به طور خودکار نوع استدلال به عنوان باریک ترین نوع داده است که می تواند تمام استدلال ذکر شده ذخیره تعریف. اگر وجود دارد [Nullable](nullable.md#data_type-nullable) یا تحت اللفظی [NULL](../../sql_reference/syntax.md#null-literal) ارزش, نوع عنصر مجموعه ای نیز می شود [Nullable](nullable.md). - -اگر فاحشه خانه می تواند نوع داده را تعیین نمی کند, این تولید یک استثنا. مثلا, این اتفاق می افتد زمانی که تلاش برای ایجاد مجموعه ای با رشته ها و اعداد به طور همزمان (`SELECT array(1, 'a')`). - -نمونه هایی از تشخیص نوع داده ها به صورت خودکار: - -``` sql -SELECT array(1, 2, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ -│ [1,2,NULL] │ Array(Nullable(UInt8)) │ -└────────────┴───────────────────────────────┘ -``` - -اگر شما سعی می کنید برای ایجاد یک آرایه از ناسازگار انواع داده ها clickhouse پرتاب یک استثنا: - -``` sql -SELECT array(1, 'a') -``` - -``` text -Received exception from server (version 1.1.54388): -Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/array/) diff --git a/docs/fa/sql_reference/data_types/boolean.md b/docs/fa/sql_reference/data_types/boolean.md deleted file mode 100644 index a906de86943..00000000000 --- a/docs/fa/sql_reference/data_types/boolean.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: "\u0628\u0648\u0644\u06CC" ---- - -# مقادیر بولی {#boolean-values} - -هیچ نوع جداگانه برای مقادیر بولی وجود دارد. استفاده از نوع اوینت8, محدود به ارزش 0 یا 1. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/boolean/) diff --git a/docs/fa/sql_reference/data_types/date.md b/docs/fa/sql_reference/data_types/date.md deleted file mode 100644 index 2a9de86cfb5..00000000000 --- a/docs/fa/sql_reference/data_types/date.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 47 -toc_title: "\u062A\u0627\u0631\u06CC\u062E" ---- - -# تاریخ {#date} - -قرار ذخیره شده در دو بایت به عنوان تعداد روز از 1970-01-01 (بدون علامت). اجازه می دهد تا ذخیره سازی مقادیر از درست بعد از شروع عصر یونیکس به حد بالایی تعریف شده توسط ثابت در مرحله تدوین (در حال حاضر, این است تا سال 2106, اما نهایی سال به طور کامل پشتیبانی شده است 2105). -حداقل مقدار خروجی به عنوان 0000-00-00. - -ارزش تاریخ بدون منطقه زمانی ذخیره می شود. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/date/) diff --git a/docs/fa/sql_reference/data_types/datetime.md b/docs/fa/sql_reference/data_types/datetime.md deleted file mode 100644 index d2620b35038..00000000000 --- a/docs/fa/sql_reference/data_types/datetime.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 48 -toc_title: DateTime ---- - -# تاریخ ساعت {#data_type-datetime} - -اجازه می دهد تا برای ذخیره یک لحظه در زمان, است که می تواند به عنوان یک تاریخ تقویم و یک زمان از یک روز بیان. - -نحو: - -``` sql -DateTime([timezone]) -``` - -محدوده پشتیبانی شده از ارزش ها: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. - -حل: 1 ثانیه. - -## استفاده از سخنان {#usage-remarks} - -نقطه در زمان به عنوان یک ذخیره می شود [برچسب زمان یونیکس](https://en.wikipedia.org/wiki/Unix_time), صرف نظر از منطقه زمانی و یا صرفه جویی در زمان نور روز. علاوه بر این `DateTime` نوع می توانید منطقه زمانی است که همین کار را برای کل ستون ذخیره, که تحت تاثیر قرار چگونه ارزش های `DateTime` مقادیر نوع در قالب متن نمایش داده می شود و چگونه مقادیر مشخص شده به عنوان رشته تجزیه می شوند (‘2020-01-01 05:00:01’). منطقه زمانی در ردیف جدول ذخیره نمی شود (و یا در نتیجه), اما در ابرداده ستون ذخیره می شود. -لیستی از مناطق زمانی پشتیبانی شده را می توان در [اانا پایگاه منطقه زمانی](https://www.iana.org/time-zones). -این `tzdata` بسته حاوی [اانا پایگاه منطقه زمانی](https://www.iana.org/time-zones), باید در سیستم نصب. استفاده از `timedatectl list-timezones` فرمان به لیست جغرافیایی شناخته شده توسط یک سیستم محلی. - -شما به صراحت می توانید یک منطقه زمانی برای `DateTime`- ستون نوع در هنگام ایجاد یک جدول. اگر منطقه زمانی تنظیم نشده است, خانه رعیتی با استفاده از ارزش [منطقهی زمانی](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) پارامتر در تنظیمات سرور و یا تنظیمات سیستم عامل در حال حاضر از شروع سرور کلیک. - -این [کلیک مشتری](../../interfaces/cli.md) اعمال منطقه زمانی سرور به طور پیش فرض اگر یک منطقه زمانی است که به صراحت تنظیم نشده است که مقدار دهی اولیه نوع داده ها. برای استفاده از منطقه زمان مشتری اجرا کنید `clickhouse-client` با `--use_client_time_zone` پارامتر. - -خروجی کلیک ارزش در `YYYY-MM-DD hh:mm:ss` قالب متن به طور پیش فرض. شما می توانید خروجی را با تغییر [formatDateTime](../../sql_reference/functions/date_time_functions.md#formatdatetime) تابع. - -هنگام قرار دادن داده ها به تاتر, شما می توانید فرمت های مختلف تاریخ و زمان رشته استفاده, بسته به ارزش [تغییر \_شماره](../../operations/settings/settings.md#settings-date_time_input_format) تنظیمات. - -## مثالها {#examples} - -**1.** ایجاد یک جدول با یک `DateTime`- ستون را تایپ کنید و داده ها را وارد کنید: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime('Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog; -``` - -``` sql -INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); -``` - -``` sql -SELECT * FROM dt; -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -- هنگام قرار دادن تاریخ ساعت به عنوان یک عدد صحیح, این است که به عنوان برچسب زمان یونیکس درمان (مجموعه مقالات). `1546300800` نشان دهنده `'2019-01-01 00:00:00'` ادا کردن. با این حال, مانند `timestamp` ستون دارد `Europe/Moscow` (مجموعه مقالات+3) منطقه زمانی مشخص, در هنگام خروجی به عنوان رشته ارزش خواهد شد به عنوان نشان داده شده است `'2019-01-01 03:00:00'` -- هنگام قرار دادن مقدار رشته به عنوان تاریخ ساعت, این است که به عنوان بودن در منطقه زمانی ستون درمان. `'2019-01-01 00:00:00'` خواهد شد به عنوان در درمان `Europe/Moscow` منطقه زمانی و ذخیره به عنوان `1546290000`. - -**2.** پالایش بر روی `DateTime` مقادیر - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -`DateTime` مقادیر ستون را می توان با استفاده از یک مقدار رشته در فیلتر `WHERE` مسندکردن. این تبدیل خواهد شد به `DateTime` به طور خودکار: - -``` sql -SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -└─────────────────────┴──────────┘ -``` - -**3.** گرفتن یک منطقه زمانی برای یک `DateTime`- نوع ستون: - -``` sql -SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────column─┬─x─────────────────────────┐ -│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ -└─────────────────────┴───────────────────────────┘ -``` - -**4.** تبدیل منطقه زمانی - -``` sql -SELECT -toDateTime(timestamp, 'Europe/London') as lon_time, -toDateTime(timestamp, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────lon_time──┬────────────mos_time─┐ -│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ -│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ -└─────────────────────┴─────────────────────┘ -``` - -## همچنین نگاه کنید به {#see-also} - -- [توابع تبدیل نوع](../../sql_reference/functions/type_conversion_functions.md) -- [توابع برای کار با تاریخ و زمان](../../sql_reference/functions/date_time_functions.md) -- [توابع کار با آرایه ها](../../sql_reference/functions/array_functions.md) -- [این `date_time_input_format` تنظیم](../../operations/settings/settings.md#settings-date_time_input_format) -- [این `timezone` پارامتر پیکربندی سرور](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [اپراتورها برای کار با تاریخ و زمان](../../sql_reference/operators.md#operators-datetime) -- [این `Date` نوع داده](date.md) - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/datetime/) diff --git a/docs/fa/sql_reference/data_types/datetime64.md b/docs/fa/sql_reference/data_types/datetime64.md deleted file mode 100644 index 6e2ddaf9447..00000000000 --- a/docs/fa/sql_reference/data_types/datetime64.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 49 -toc_title: "\u0637\u0648\u0644 \u062A\u0627\u0631\u06CC\u062E 64" ---- - -# طول تاریخ 64 {#data_type-datetime64} - -اجازه می دهد تا برای ذخیره یک لحظه در زمان, است که می تواند به عنوان یک تاریخ تقویم و یک زمان از یک روز بیان, با دقت زیر دوم تعریف شده - -اندازه تیک (دقت): 10- دقت ثانیه - -نحو: - -``` sql -DateTime64(precision, [timezone]) -``` - -داخلی, ذخیره داده ها به عنوان تعدادی از ‘ticks’ از عصر شروع (1970-01-01 00:00:00 یو تی سی) به عنوان اینترنشنال64. وضوح تیک توسط پارامتر دقیق تعیین می شود. علاوه بر این `DateTime64` نوع می توانید منطقه زمانی است که همین کار را برای کل ستون ذخیره, که تحت تاثیر قرار چگونه ارزش های `DateTime64` مقادیر نوع در قالب متن نمایش داده می شود و چگونه مقادیر مشخص شده به عنوان رشته تجزیه می شوند (‘2020-01-01 05:00:01.000’). منطقه زمانی در ردیف جدول ذخیره نمی شود (و یا در نتیجه), اما در ابرداده ستون ذخیره می شود. مشاهده اطلاعات در [DateTime](datetime.md). - -## مثالها {#examples} - -**1.** ایجاد یک جدول با `DateTime64`- ستون را تایپ کنید و داده ها را وارد کنید: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime64(3, 'Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog -``` - -``` sql -INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) -``` - -``` sql -SELECT * FROM dt -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00.000 │ 1 │ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -- هنگام قرار دادن تاریخ ساعت به عنوان یک عدد صحیح, این است که به عنوان یک مناسب کوچک برچسب زمان یونیکس درمان (مجموعه مقالات). `1546300800000` (با دقت 3) نشان دهنده `'2019-01-01 00:00:00'` ادا کردن. با این حال, مانند `timestamp` ستون دارد `Europe/Moscow` (مجموعه مقالات+3) منطقه زمانی مشخص, در هنگام خروجی به عنوان یک رشته ارزش خواهد شد به عنوان نشان داده شده است `'2019-01-01 03:00:00'` -- هنگام قرار دادن مقدار رشته به عنوان تاریخ ساعت, این است که به عنوان بودن در منطقه زمانی ستون درمان. `'2019-01-01 00:00:00'` خواهد شد به عنوان در درمان `Europe/Moscow` منطقه زمانی و ذخیره شده به عنوان `1546290000000`. - -**2.** پالایش بر روی `DateTime64` مقادیر - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -برخلاف `DateTime`, `DateTime64` ارزش ها از تبدیل نمی `String` به طور خودکار - -**3.** گرفتن یک منطقه زمانی برای یک `DateTime64`- مقدار نوع: - -``` sql -SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────────column─┬─x──────────────────────────────┐ -│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ -└─────────────────────────┴────────────────────────────────┘ -``` - -**4.** تبدیل منطقه زمانی - -``` sql -SELECT -toDateTime64(timestamp, 3, 'Europe/London') as lon_time, -toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────────lon_time──┬────────────────mos_time─┐ -│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ -│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ -└─────────────────────────┴─────────────────────────┘ -``` - -## همچنین نگاه کنید {#see-also} - -- [توابع تبدیل نوع](../../sql_reference/functions/type_conversion_functions.md) -- [توابع برای کار با تاریخ و زمان](../../sql_reference/functions/date_time_functions.md) -- [توابع برای کار با ارریس](../../sql_reference/functions/array_functions.md) -- [این `date_time_input_format` تنظیم](../../operations/settings/settings.md#settings-date_time_input_format) -- [این `timezone` پارامتر پیکربندی سرور](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [اپراتورها برای کار با تاریخ و زمان](../../sql_reference/operators.md#operators-datetime) -- [`Date` نوع داده](date.md) -- [`DateTime` نوع داده](datetime.md) diff --git a/docs/fa/sql_reference/data_types/decimal.md b/docs/fa/sql_reference/data_types/decimal.md deleted file mode 100644 index e2c822e76bd..00000000000 --- a/docs/fa/sql_reference/data_types/decimal.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u062F\u0647\u062F\u0647\u06CC" ---- - -# Decimal(P, S) Decimal32(ع) Decimal64(ع) Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} - -امضا اعداد ثابت نقطه که دقت در طول اضافه کردن نگه دارید, تفریق و ضرب عملیات. برای تقسیم رقم حداقل قابل توجهی دور انداخته می شوند (گرد نیست). - -## پارامترها {#parameters} - -- ص دقیق. محدوده معتبر: \[ 1 : 38 \]. تعیین می کند که چگونه بسیاری از اعداد اعشاری می تواند داشته باشد (از جمله کسر). -- ص-مقیاس. محدوده معتبر: \[0: پ \]. تعیین می کند که چگونه بسیاری از رقم اعشاری کسر می تواند داشته باشد. - -بسته به فسفر اعشاری مقدار پارامتر (پ, بازدید کنندگان) مترادف برای است: -- پ از \[ 1 : 9 \] - برای اعشار (بازدید کنندگان) -- پ از \[ 10 : 18 \] - برای اعشار64(بازدید کنندگان) -- پ از \[ 19: 38 \] - برای اعشار128 (بازدید کنندگان) - -## محدوده مقدار دهدهی {#decimal-value-ranges} - -- دسیمال32 (بازدید کنندگان) - ( -1 \* 10^(9 - بازدید کنندگان), 1 \* 10^(9 بازدید کنندگان) ) -- اعشار64 (بازدید کنندگان) - ( -1 \* 10^(18 - س), 1 \* 10^(18 بازدید کنندگان) ) -- اعشار128 (بازدید کنندگان) - ( -1 \* 10^(38 - بازدید کنندگان), 1 \* 10^(38 بازدید کنندگان) ) - -برای مثال decimal32(4) می تواند شامل اعداد از -99999.9999 به 99999.9999 با 0.0001 گام. - -## نمایندگی داخلی {#internal-representation} - -داخلی داده ها به عنوان اعداد صحیح امضا نرمال با عرض بیت مربوطه نشان داده است. محدوده ارزش واقعی است که می تواند در حافظه ذخیره می شود کمی بزرگتر از بالا مشخص, که تنها در تبدیل از یک رشته بررسی. - -چرا که پردازنده مدرن اعداد صحیح 128 بیتی بومی را پشتیبانی نمی کند, عملیات بر روی اعشار128 شبیه سازی. از آنجا که این decimal128 با این نسخهها کار به طور قابل توجهی کندتر از decimal32/decimal64. - -## عملیات و نوع نتیجه {#operations-and-result-type} - -عملیات دودویی در نتیجه اعشاری در نوع نتیجه گسترده تر (با هر سفارش از استدلال). - -- اعشار64 (س1) Decimal32(S2) -\> Decimal64(S) -- اعشار128 (س1) Decimal32(S2) -\> Decimal128(S) -- اعشار128 (س1) Decimal64(S2) -\> Decimal128(S) - -قوانین برای مقیاس: - -- اضافه کردن به, تفریق کردن: بازدید کنندگان = حداکثر(بازدید کنندگان 1, بازدید کنندگان2). -- multuply: S = S1 + S2. -- تقسیم: S = S1. - -برای عملیات مشابه بین دهدهی و اعداد صحیح, نتیجه اعشاری از همان اندازه به عنوان یک استدلال است. - -عملیات بین دهدهی و float32/float64 تعریف نشده. اگر شما به آنها نیاز دارید, شما می توانید به صراحت بازیگران یکی از استدلال با استفاده از todecimal32, todecimal64, todecimal128 یا tofloat32, tofloat64 برنامهنویسی. به خاطر داشته باشید که نتیجه دقت از دست دادن و تبدیل نوع یک عملیات محاسباتی گران است. - -برخی از توابع در نتیجه بازگشت اعشاری به عنوان شناور64 (مثلا, ور یا استودف). محاسبات متوسط هنوز هم ممکن است در دهدهی انجام شود, که ممکن است به نتایج مختلف بین نت64 و ورودی اعشاری با ارزش های مشابه منجر شود. - -## بررسی سرریز {#overflow-checks} - -در طول محاسبات در اعشاری, عدد صحیح سرریز ممکن است رخ دهد. رقم بیش از حد در کسری دور انداخته می شوند (گرد نیست). رقم بیش از حد در بخش عدد صحیح به یک استثنا منجر شود. - -``` sql -SELECT toDecimal32(2, 4) AS x, x / 3 -``` - -``` text -┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ -│ 2.0000 │ 0.6666 │ -└────────┴──────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, x * x -``` - -``` text -DB::Exception: Scale is out of bounds. -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -DB::Exception: Decimal math overflow. -``` - -سرریز چک منجر به کاهش سرعت عملیات. اگر مشخص است که سرریزهای امکان پذیر نیست, حس می کند برای غیر فعال کردن چک با استفاده از `decimal_check_overflow` تنظیمات. هنگامی که چک غیر فعال هستند و سرریز اتفاق می افتد, نتیجه نادرست خواهد بود: - -``` sql -SET decimal_check_overflow = 0; -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ -│ 4.20000000 │ -17.74967296 │ -└────────────┴──────────────────────────────────┘ -``` - -چک سرریز اتفاق می افتد نه تنها در عملیات ریاضی بلکه در مقایسه ارزش: - -``` sql -SELECT toDecimal32(1, 8) < 100 -``` - -``` text -DB::Exception: Can't compare. -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/decimal/) diff --git a/docs/fa/sql_reference/data_types/domains/index.md b/docs/fa/sql_reference/data_types/domains/index.md deleted file mode 100644 index 3a743f84290..00000000000 --- a/docs/fa/sql_reference/data_types/domains/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Domains -toc_priority: 56 ---- - - diff --git a/docs/fa/sql_reference/data_types/domains/ipv4.md b/docs/fa/sql_reference/data_types/domains/ipv4.md deleted file mode 100644 index cd33df6acc9..00000000000 --- a/docs/fa/sql_reference/data_types/domains/ipv4.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 59 -toc_title: IPv4 ---- - -## IPv4 {#ipv4} - -`IPv4` یک دامنه بر اساس `UInt32` نوع و به عنوان یک جایگزین تایپ شده برای ذخیره سازی مقادیر ایپو4 عمل می کند. این فراهم می کند ذخیره سازی جمع و جور با فرمت ورودی خروجی انسان پسند و نوع ستون اطلاعات در بازرسی. - -### استفاده عمومی {#basic-usage} - -``` sql -CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY url; - -DESCRIBE TABLE hits; -``` - -``` text -┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ -│ url │ String │ │ │ │ │ -│ from │ IPv4 │ │ │ │ │ -└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ -``` - -یا شما می توانید از دامنه ایپو4 به عنوان یک کلید استفاده کنید: - -``` sql -CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; -``` - -`IPv4` دامنه پشتیبانی از فرمت ورودی سفارشی به عنوان ایپو4 رشته: - -``` sql -INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.tech', '183.247.232.58')('https://clickhouse.yandex/docs/en/', '116.106.34.242'); - -SELECT * FROM hits; -``` - -``` text -┌─url────────────────────────────────┬───────────from─┐ -│ https://clickhouse.tech/docs/en/ │ 116.106.34.242 │ -│ https://wikipedia.org │ 116.253.40.133 │ -│ https://clickhouse.tech │ 183.247.232.58 │ -└────────────────────────────────────┴────────────────┘ -``` - -مقادیر به صورت باینری جمع و جور ذخیره می شود: - -``` sql -SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(from)─┬─hex(from)─┐ -│ IPv4 │ B7F7E83A │ -└──────────────────┴───────────┘ -``` - -ارزش دامنه به طور ضمنی قابل تبدیل به انواع دیگر از `UInt32`. -اگر شما می خواهید برای تبدیل `IPv4` ارزش به یک رشته, شما باید برای انجام این کار به صراحت با `IPv4NumToString()` تابع: - -``` sql -SELECT toTypeName(s), IPv4NumToString(from) as s FROM hits LIMIT 1; -``` - - ┌─toTypeName(IPv4NumToString(from))─┬─s──────────────┐ - │ String │ 183.247.232.58 │ - └───────────────────────────────────┴────────────────┘ - -یا بازیگران به `UInt32` مقدار: - -``` sql -SELECT toTypeName(i), CAST(from as UInt32) as i FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(CAST(from, 'UInt32'))─┬──────────i─┐ -│ UInt32 │ 3086477370 │ -└──────────────────────────────────┴────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/domains/ipv4) diff --git a/docs/fa/sql_reference/data_types/domains/ipv6.md b/docs/fa/sql_reference/data_types/domains/ipv6.md deleted file mode 100644 index 8c2779777de..00000000000 --- a/docs/fa/sql_reference/data_types/domains/ipv6.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 60 -toc_title: IPv6 ---- - -## IPv6 {#ipv6} - -`IPv6` یک دامنه بر اساس `FixedString(16)` نوع و به عنوان یک جایگزین تایپ شده برای ذخیره سازی ارزش های ایپو6 عمل می کند. این فراهم می کند ذخیره سازی جمع و جور با فرمت ورودی خروجی انسان پسند و نوع ستون اطلاعات در بازرسی. - -### استفاده عمومی {#basic-usage} - -``` sql -CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url; - -DESCRIBE TABLE hits; -``` - -``` text -┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ -│ url │ String │ │ │ │ │ -│ from │ IPv6 │ │ │ │ │ -└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ -``` - -یا شما می توانید استفاده کنید `IPv6` دامنه به عنوان یک کلید: - -``` sql -CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from; -``` - -`IPv6` دامنه پشتیبانی از ورودی های سفارشی به عنوان ایپو6 رشته: - -``` sql -INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.tech', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.yandex/docs/en/', '2a02:e980:1e::1'); - -SELECT * FROM hits; -``` - -``` text -┌─url────────────────────────────────┬─from──────────────────────────┐ -│ https://clickhouse.tech │ 2001:44c8:129:2632:33:0:252:2 │ -│ https://clickhouse.tech/docs/en/ │ 2a02:e980:1e::1 │ -│ https://wikipedia.org │ 2a02:aa08:e000:3100::2 │ -└────────────────────────────────────┴───────────────────────────────┘ -``` - -مقادیر به صورت باینری جمع و جور ذخیره می شود: - -``` sql -SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(from)─┬─hex(from)────────────────────────┐ -│ IPv6 │ 200144C8012926320033000002520002 │ -└──────────────────┴──────────────────────────────────┘ -``` - -ارزش دامنه به طور ضمنی قابل تبدیل به انواع دیگر از `FixedString(16)`. -اگر شما می خواهید برای تبدیل `IPv6` ارزش به یک رشته, شما باید برای انجام این کار به صراحت با `IPv6NumToString()` تابع: - -``` sql -SELECT toTypeName(s), IPv6NumToString(from) as s FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(IPv6NumToString(from))─┬─s─────────────────────────────┐ -│ String │ 2001:44c8:129:2632:33:0:252:2 │ -└───────────────────────────────────┴───────────────────────────────┘ -``` - -یا بازیگران به یک `FixedString(16)` مقدار: - -``` sql -SELECT toTypeName(i), CAST(from as FixedString(16)) as i FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(CAST(from, 'FixedString(16)'))─┬─i───────┐ -│ FixedString(16) │ ��� │ -└───────────────────────────────────────────┴─────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/domains/ipv6) diff --git a/docs/fa/sql_reference/data_types/domains/overview.md b/docs/fa/sql_reference/data_types/domains/overview.md deleted file mode 100644 index ab6155caf64..00000000000 --- a/docs/fa/sql_reference/data_types/domains/overview.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 58 -toc_title: "\u0628\u0631\u0631\u0633\u06CC \u0627\u062C\u0645\u0627\u0644\u06CC" ---- - -# دامنه {#domains} - -دامنه انواع خاصی است که اضافه کردن برخی از ویژگی های اضافی در بالای نوع پایه موجود, اما ترک بر روی سیم و بر روی دیسک فرمت از نوع داده اساسی دست نخورده. درحال حاضر, تاتر می کند دامنه تعریف شده توسط کاربر را پشتیبانی نمی کند. - -شما می توانید دامنه در هر نقطه نوع پایه مربوطه استفاده می شود, مثلا: - -- ایجاد یک ستون از یک نوع دامنه -- خواندن / نوشتن مقادیر از / به ستون دامنه -- اگر یک نوع پایه می تواند به عنوان یک شاخص استفاده می شود به عنوان شاخص استفاده می شود -- توابع تماس با مقادیر ستون دامنه - -### ویژگی های اضافی از دامنه {#extra-features-of-domains} - -- صریح نام نوع ستون در `SHOW CREATE TABLE` یا `DESCRIBE TABLE` -- ورودی از فرمت انسان دوستانه با `INSERT INTO domain_table(domain_column) VALUES(...)` -- خروجی به فرمت انسان دوستانه برای `SELECT domain_column FROM domain_table` -- بارگیری داده ها از یک منبع خارجی در قالب انسان دوستانه: `INSERT INTO domain_table FORMAT CSV ...` - -### محدودیت ها {#limitations} - -- می توانید ستون شاخص از نوع پایه به نوع دامنه از طریق تبدیل کنید `ALTER TABLE`. -- نمی تواند به طور ضمنی تبدیل مقادیر رشته به ارزش دامنه در هنگام قرار دادن داده ها از ستون یا جدول دیگر. -- دامنه می افزاید: هیچ محدودیتی در مقادیر ذخیره شده. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/domains/overview) diff --git a/docs/fa/sql_reference/data_types/enum.md b/docs/fa/sql_reference/data_types/enum.md deleted file mode 100644 index e468c910106..00000000000 --- a/docs/fa/sql_reference/data_types/enum.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 50 -toc_title: "\u0634\u0645\u0627\u0631\u0634\u06CC" ---- - -# شمارشی {#enum} - -نوع شمارش متشکل از ارزش به نام. - -مقادیر نام شده باید به عنوان اعلام شود `'string' = integer` جفت انبار فروشگاه تنها اعداد, اما پشتیبانی از عملیات با ارزش از طریق نام خود را. - -پشتیبانی از کلیک: - -- 8 بیتی `Enum`. این می تواند تا 256 مقدار شمارش شده در `[-128, 127]` محدوده. -- 16 بیتی `Enum`. این می تواند تا 65536 مقدار شمارش شده در `[-32768, 32767]` محدوده. - -تاتر به طور خودکار انتخاب نوع `Enum` هنگامی که داده درج شده است. شما همچنین می توانید استفاده کنید `Enum8` یا `Enum16` انواع برای اطمینان در اندازه ذخیره سازی. - -## نمونه های استفاده {#usage-examples} - -در اینجا ما یک جدول با یک ایجاد می کنیم `Enum8('hello' = 1, 'world' = 2)` نوع ستون: - -``` sql -CREATE TABLE t_enum -( - x Enum('hello' = 1, 'world' = 2) -) -ENGINE = TinyLog -``` - -ستون `x` فقط می توانید مقادیر که در تعریف نوع ذکر شده را ذخیره کنید: `'hello'` یا `'world'`. اگر شما سعی می کنید برای صرفه جویی در هر مقدار دیگر, کلیک یک استثنا بالا می برد. اندازه 8 بیتی برای این `Enum` به طور خودکار انتخاب شده است. - -``` sql -INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') -``` - -``` text -Ok. -``` - -``` sql -INSERT INTO t_enum values('a') -``` - -``` text -Exception on client: -Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) -``` - -هنگامی که شما پرس و جو داده ها را از جدول, تاتر خروجی مقادیر رشته از `Enum`. - -``` sql -SELECT * FROM t_enum -``` - -``` text -┌─x─────┐ -│ hello │ -│ world │ -│ hello │ -└───────┘ -``` - -اگر شما نیاز به دیدن معادل عددی از ردیف, شما باید بازیگران `Enum` ارزش به نوع صحیح. - -``` sql -SELECT CAST(x, 'Int8') FROM t_enum -``` - -``` text -┌─CAST(x, 'Int8')─┐ -│ 1 │ -│ 2 │ -│ 1 │ -└─────────────────┘ -``` - -برای ایجاد یک مقدار شمارشی در پرس و جو, شما همچنین نیاز به استفاده از `CAST`. - -``` sql -SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) -``` - -``` text -┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ -│ Enum8('a' = 1, 'b' = 2) │ -└─────────────────────────────────────────────────────┘ -``` - -## قوانین عمومی و استفاده {#general-rules-and-usage} - -هر یک از مقادیر یک عدد در محدوده اختصاص داده شده است `-128 ... 127` برای `Enum8` یا در محدوده `-32768 ... 32767` برای `Enum16`. همه رشته ها و اعداد باید متفاوت باشد. یک رشته خالی مجاز است. اگر این نوع مشخص شده است (در یک تعریف جدول), اعداد را می توان در جهت دلخواه. با این حال, سفارش مهم نیست. - -نه رشته و نه مقدار عددی در یک `Enum` می تواند باشد [NULL](../../sql_reference/syntax.md). - -یک `Enum` می توان در [Nullable](nullable.md) نوع. بنابراین اگر شما یک جدول با استفاده از پرس و جو ایجاد کنید - -``` sql -CREATE TABLE t_enum_nullable -( - x Nullable( Enum8('hello' = 1, 'world' = 2) ) -) -ENGINE = TinyLog -``` - -این می تواند نه تنها ذخیره `'hello'` و `'world'` اما `NULL` همینطور - -``` sql -INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) -``` - -در رم `Enum` ستون به همان شیوه ذخیره می شود `Int8` یا `Int16` از مقادیر عددی مربوطه. - -هنگام خواندن در فرم متن, تاتر تجزیه ارزش به عنوان یک رشته و جستجو برای رشته مربوطه را از مجموعه ای از ارزش شمارشی. اگر یافت نشد, یک استثنا پرتاب می شود. هنگام خواندن در قالب متن, رشته به عنوان خوانده شده و مقدار عددی مربوطه نگاه کردن. یک استثنا پرتاب خواهد شد اگر یافت نشد. -هنگام نوشتن در فرم متن, این ارزش به عنوان رشته مربوطه می نویسد. اگر داده های ستون شامل زباله (اعداد است که از مجموعه معتبر نیست), یک استثنا پرتاب می شود. زمانی که خواندن و نوشتن در فایل باینری فرم آن را با این نسخهها کار به همان روش برای int8 و int16 انواع داده ها. -مقدار پیش فرض ضمنی ارزش با کمترین تعداد است. - -در طول `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` و به همین ترتیب, مادران رفتار به همان شیوه به عنوان اعداد مربوطه. مثلا, سفارش شده توسط انواع عددی. اپراتورهای برابری و مقایسه کار به همان شیوه در مادران به عنوان در مقادیر عددی اساسی انجام. - -مقادیر شمارشی را نمی توان با اعداد مقایسه شده است. شمارشی را می توان به یک رشته ثابت در مقایسه. اگر رشته در مقایسه با یک مقدار معتبر برای شمارشی نیست, یک استثنا پرتاب خواهد شد. اپراتور در با شمارشی در سمت چپ و مجموعه ای از رشته ها در سمت راست پشتیبانی می شود. رشته ارزش مربوط شمارشی هستند. - -Most numeric and string operations are not defined for Enum values, e.g. adding a number to an Enum or concatenating a string to an Enum. -با این حال, شمارشی طبیعی است `toString` تابع است که ارزش رشته خود را برمی گرداند. - -مقادیر شمارشی نیز قابل تبدیل به انواع عددی با استفاده از `toT` تابع, که تی یک نوع عددی است. هنگامی که تی مربوط به نوع عددی اساسی شمارشی است, این تبدیل صفر هزینه است. -نوع شمارشی را می توان بدون هزینه با استفاده از تغییر تغییر, اگر تنها مجموعه ای از ارزش تغییر است. ممکن است که به هر دو اضافه کردن و حذف اعضای شمارشی با استفاده از تغییر (از بین بردن امن است تنها در صورتی که مقدار حذف شده است هرگز در جدول استفاده می شود). به عنوان یک حفاظت, تغییر مقدار عددی از یک عضو شمارشی که قبلا تعریف یک استثنا پرتاب. - -با استفاده از تغییر آن را ممکن است برای تغییر یک enum8 به enum16 یا بالعکس فقط مانند تغییر یک int8 به int16. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/enum/) diff --git a/docs/fa/sql_reference/data_types/fixedstring.md b/docs/fa/sql_reference/data_types/fixedstring.md deleted file mode 100644 index e151008822c..00000000000 --- a/docs/fa/sql_reference/data_types/fixedstring.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: "\u0631\u0634\u062A\u0647 \u062B\u0627\u0628\u062A)" ---- - -# رشته ثابت {#fixedstring} - -یک رشته ثابت طول `N` بایت (نه شخصیت و نه نقاط کد). - -برای اعلام یک ستون از `FixedString` نوع, استفاده از نحو زیر: - -``` sql - FixedString(N) -``` - -کجا `N` یک عدد طبیعی است. - -این `FixedString` نوع زمانی موثر است که داده ها طول دقیق داشته باشند `N` بایت در تمام موارد دیگر, این احتمال وجود دارد به کاهش بهره وری. - -نمونه هایی از مقادیر است که می تواند موثر در ذخیره می شود `FixedString`- ستون های تایپ شده: - -- نمایندگی دودویی نشانی های اینترنتی (`FixedString(16)` برای ایپو6). -- Language codes (ru\_RU, en\_US … ). -- Currency codes (USD, RUB … ). -- نمایش دودویی رشته هش (`FixedString(16)` برای ام دی 5, `FixedString(32)` برای شی256). - -برای ذخیره مقادیر یوید از [UUID](uuid.md) نوع داده. - -هنگام قرار دادن داده ها, تاتر: - -- مکمل یک رشته با null بایت اگر رشته شامل کمتر از `N` بایت -- پرتاب `Too large value for FixedString(N)` استثنا اگر رشته شامل بیش از `N` بایت - -در هنگام انتخاب داده, تاتر می کند بایت پوچ در پایان رشته را حذف کنید. اگر شما استفاده از `WHERE` بند, شما باید بایت پوچ دستی اضافه برای مطابقت با `FixedString` ارزش. مثال زیر نشان میدهد که چگونه به استفاده از `WHERE` بند با `FixedString`. - -بیایید جدول زیر را با تک در نظر بگیریم `FixedString(2)` ستون: - -``` text -┌─name──┐ -│ b │ -└───────┘ -``` - -پرسوجو `SELECT * FROM FixedStringTable WHERE a = 'b'` هیچ داده به عنوان یک نتیجه نمی گرداند. ما باید الگوی فیلتر با بایت پوچ تکمیل. - -``` sql -SELECT * FROM FixedStringTable -WHERE a = 'b\0' -``` - -``` text -┌─a─┐ -│ b │ -└───┘ -``` - -این رفتار از خروجی زیر برای متفاوت `CHAR` نوع (جایی که رشته ها با فضاهای خالی, و فضاهای برای خروجی حذف). - -توجه داشته باشید که طول `FixedString(N)` ارزش ثابت است. این [طول](../../sql_reference/functions/array_functions.md#array_functions-length) بازده عملکرد `N` حتی اگر `FixedString(N)` ارزش تنها با بایت پوچ پر, اما [خالی](../../sql_reference/functions/string_functions.md#empty) بازده عملکرد `1` در این مورد. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/fa/sql_reference/data_types/float.md b/docs/fa/sql_reference/data_types/float.md deleted file mode 100644 index 99f25f4e810..00000000000 --- a/docs/fa/sql_reference/data_types/float.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: Float32, Float64 ---- - -# Float32, Float64 {#float32-float64} - -[اعداد ممیز شناور](https://en.wikipedia.org/wiki/IEEE_754). - -انواع معادل انواع ج هستند: - -- `Float32` - `float` -- `Float64` - `double` - -ما توصیه می کنیم که شما ذخیره داده ها در فرم صحیح در هر زمان ممکن است. مثلا, تبدیل اعداد دقت ثابت به ارزش عدد صحیح, مانند مقدار پولی و یا بار بار صفحه در میلی ثانیه. - -## با استفاده از اعداد ممیز شناور {#using-floating-point-numbers} - -- محاسبات با اعداد ممیز شناور ممکن است یک خطای گرد کردن تولید. - - - -``` sql -SELECT 1 - 0.9 -``` - -``` text -┌───────minus(1, 0.9)─┐ -│ 0.09999999999999998 │ -└─────────────────────┘ -``` - -- نتیجه محاسبه بستگی به روش محاسبه (نوع پردازنده و معماری سیستم کامپیوتری). -- محاسبات ممیز شناور ممکن است در اعداد مانند بی نهایت منجر شود (`Inf`) و “not-a-number” (`NaN`). این را باید در نظر گرفته شود در هنگام پردازش نتایج محاسبات. -- هنگامی که تجزیه اعداد ممیز شناور از متن, نتیجه ممکن است نزدیکترین شماره ماشین نمایندگی. - -## هشدار داده می شود {#data_type-float-nan-inf} - -در مقابل به گذاشتن استاندارد, خانه رعیتی پشتیبانی از مقوله های زیر است از اعداد ممیز شناور: - -- `Inf` – Infinity. - - - -``` sql -SELECT 0.5 / 0 -``` - -``` text -┌─divide(0.5, 0)─┐ -│ inf │ -└────────────────┘ -``` - -- `-Inf` – Negative infinity. - - - -``` sql -SELECT -0.5 / 0 -``` - -``` text -┌─divide(-0.5, 0)─┐ -│ -inf │ -└─────────────────┘ -``` - -- `NaN` – Not a number. - - - -``` sql -SELECT 0 / 0 -``` - -``` text -┌─divide(0, 0)─┐ -│ nan │ -└──────────────┘ -``` - - See the rules for `NaN` sorting in the section [ORDER BY clause](../sql_reference/statements/select.md). - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/float/) diff --git a/docs/fa/sql_reference/data_types/index.md b/docs/fa/sql_reference/data_types/index.md deleted file mode 100644 index cb5a702ddbd..00000000000 --- a/docs/fa/sql_reference/data_types/index.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Data Types -toc_priority: 37 -toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" ---- - -# انواع داده ها {#data_types} - -تاتر می توانید انواع مختلف داده ها در سلول های جدول ذخیره کنید. - -این بخش انواع داده های پشتیبانی شده و ملاحظات ویژه ای را برای استفاده و/یا در صورت وجود اجرا می کند. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/) diff --git a/docs/fa/sql_reference/data_types/int_uint.md b/docs/fa/sql_reference/data_types/int_uint.md deleted file mode 100644 index 600ffbc56e9..00000000000 --- a/docs/fa/sql_reference/data_types/int_uint.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 ---- - -# UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} - -اعداد صحیح ثابت طول, با یا بدون نشانه. - -## محدوده اعضای هیات {#int-ranges} - -- بین8- \[-128 : 127\] -- اینتر16- \[-32768 : 32767\] -- اینتر32 - \[-2147483648: 2147483647\] -- اینتر64- \[-9223372036854775808 : 9223372036854775807\] - -## محدوده دانشگاه تهران {#uint-ranges} - -- توینت8- \[0: 255\] -- اوینت16- \[0: 65535\] -- اوینت32- \[0: 4294967295\] -- اوت64 - \[0: 18446744073709551615\] - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/int_uint/) diff --git a/docs/fa/sql_reference/data_types/nested_data_structures/index.md b/docs/fa/sql_reference/data_types/nested_data_structures/index.md deleted file mode 100644 index f2885dc8a16..00000000000 --- a/docs/fa/sql_reference/data_types/nested_data_structures/index.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Nested Data Structures -toc_hidden: true -toc_priority: 54 -toc_title: "\u0645\u062E\u0641\u06CC" ---- - -# ساختارهای داده تو در تو {#nested-data-structures} - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nested_data_structures/) diff --git a/docs/fa/sql_reference/data_types/nested_data_structures/nested.md b/docs/fa/sql_reference/data_types/nested_data_structures/nested.md deleted file mode 100644 index 8d5b9897781..00000000000 --- a/docs/fa/sql_reference/data_types/nested_data_structures/nested.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 57 -toc_title: "\u062A\u0648 \u062F\u0631 \u062A\u0648(Name1 Type1, Name2 Type2, ...)" ---- - -# Nested(name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} - -A nested data structure is like a table inside a cell. The parameters of a nested data structure – the column names and types – are specified the same way as in a [CREATE TABLE](../../../sql_reference/statements/create.md) پرس و جو. هر سطر جدول می تواند به هر تعداد از ردیف در یک ساختار داده تو در تو مطابقت. - -مثال: - -``` sql -CREATE TABLE test.visits -( - CounterID UInt32, - StartDate Date, - Sign Int8, - IsNew UInt8, - VisitID UInt64, - UserID UInt64, - ... - Goals Nested - ( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32 - ), - ... -) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) -``` - -این مثال اعلام کرد `Goals` ساختار داده های تو در تو, که شامل داده ها در مورد تبدیل (اهداف رسیده). هر سطر در ‘visits’ جدول می تواند به صفر یا هر تعداد از تبدیل مطابقت دارد. - -فقط یک سطح تودرتو تک پشتیبانی می شود. ستون های سازه های تو در تو حاوی ارریس معادل چندین بعدی هستند بنابراین پشتیبانی محدودی دارند (هیچ پشتیبانی ای برای ذخیره این ستون ها در جداول با موتور ادغام وجود ندارد). - -در بیشتر موارد, در هنگام کار با یک ساختار داده های تو در تو, ستون خود را با نام ستون جدا شده توسط یک نقطه مشخص. این ستون ها مجموعه ای از انواع تطبیق را تشکیل می دهند. تمام ستون ها از یک ساختار داده های تو در تو یکسان هستند. - -مثال: - -``` sql -SELECT - Goals.ID, - Goals.EventTime -FROM test.visits -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ -│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ -│ [1073752] │ ['2014-03-17 00:28:25'] │ -│ [1073752] │ ['2014-03-17 10:46:20'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ -│ [] │ [] │ -│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ -│ [] │ [] │ -│ [] │ [] │ -│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ -└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -ساده ترین راه این است که از یک ساختار داده های تو در تو فکر می کنم به عنوان مجموعه ای از مجموعه ای از مجموعه های ستون های متعدد از همان طول. - -تنها جایی که پرس و جو را انتخاب کنید می توانید نام کل ساختار داده های تو در تو به جای ستون های فردی مشخص مجموعه ملحق بند. برای کسب اطلاعات بیشتر, دیدن “ARRAY JOIN clause”. مثال: - -``` sql -SELECT - Goal.ID, - Goal.EventTime -FROM test.visits -ARRAY JOIN Goals AS Goal -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goal.ID─┬──────Goal.EventTime─┐ -│ 1073752 │ 2014-03-17 16:38:10 │ -│ 591325 │ 2014-03-17 16:38:48 │ -│ 591325 │ 2014-03-17 16:42:27 │ -│ 1073752 │ 2014-03-17 00:28:25 │ -│ 1073752 │ 2014-03-17 10:46:20 │ -│ 1073752 │ 2014-03-17 13:59:20 │ -│ 591325 │ 2014-03-17 22:17:55 │ -│ 591325 │ 2014-03-17 22:18:07 │ -│ 591325 │ 2014-03-17 22:18:51 │ -│ 1073752 │ 2014-03-17 11:37:06 │ -└─────────┴─────────────────────┘ -``` - -شما نمی توانید انتخاب کنید برای کل ساختار داده های تو در تو انجام دهد. شما فقط می توانید به صراحت ستون های فردی را که بخشی از این هستند لیست کنید. - -برای پرس و جو درج, شما باید تمام عناصر ستون مولفه از یک ساختار داده های تو در تو به طور جداگانه منتقل (در صورتی که مجموعه فردی بودند). در حین درج سیستم چک می کند که همان طول را دارند. - -برای پرس و جو توصیف, ستون در یک ساختار داده های تو در تو به طور جداگانه در همان راه ذکر شده. - -پرس و جو را تغییر دهید برای عناصر در یک ساختار داده های تو در تو دارای محدودیت. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nested_data_structures/nested/) diff --git a/docs/fa/sql_reference/data_types/nullable.md b/docs/fa/sql_reference/data_types/nullable.md deleted file mode 100644 index 987f338c07e..00000000000 --- a/docs/fa/sql_reference/data_types/nullable.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 54 -toc_title: Nullable ---- - -# Nullable(typename) {#data_type-nullable} - -اجازه می دهد تا برای ذخیره نشانگر ویژه ([NULL](../../sql_reference/syntax.md)) که نشان دهنده “missing value” در کنار مقادیر عادی مجاز `TypeName`. برای مثال یک `Nullable(Int8)` ستون نوع می تواند ذخیره شود `Int8` ارزش نوع و ردیف است که ارزش ذخیره خواهد شد `NULL`. - -برای یک `TypeName` شما نمی توانید از انواع داده های کامپوزیت استفاده کنید [& حذف](array.md) و [تاپل](tuple.md). انواع داده های کامپوزیت می تواند شامل `Nullable` مقادیر نوع مانند `Array(Nullable(Int8))`. - -A `Nullable` فیلد نوع را نمی توان در شاخص های جدول گنجانده شده است. - -`NULL` مقدار پیش فرض برای هر `Nullable` نوع, مگر اینکه در غیر این صورت در پیکربندی سرور کلیک مشخص. - -## ویژگی های ذخیره سازی {#storage-features} - -برای ذخیره `Nullable` ارزش نوع در یک ستون جدول, تاتر با استفاده از یک فایل جداگانه با `NULL` ماسک علاوه بر فایل عادی با ارزش. مطالب در ماسک فایل اجازه می دهد خانه کلیک برای تشخیص بین `NULL` و یک مقدار پیش فرض از نوع داده مربوطه را برای هر سطر جدول. به دلیل یک فایل اضافی, `Nullable` ستون مصرف فضای ذخیره سازی اضافی در مقایسه با یک نرمال مشابه. - -!!! info "یادداشت" - با استفاده از `Nullable` تقریبا همیشه منفی تاثیر می گذارد عملکرد, نگه داشتن این در ذهن در هنگام طراحی پایگاه داده های خود را. - -## مثال طریقه استفاده {#usage-example} - -``` sql -CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog -``` - -``` sql -INSERT INTO t_null VALUES (1, NULL), (2, 3) -``` - -``` sql -SELECT x + y FROM t_null -``` - -``` text -┌─plus(x, y)─┐ -│ ᴺᵁᴸᴸ │ -│ 5 │ -└────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/fa/sql_reference/data_types/simpleaggregatefunction.md b/docs/fa/sql_reference/data_types/simpleaggregatefunction.md deleted file mode 120000 index 02fad64d50e..00000000000 --- a/docs/fa/sql_reference/data_types/simpleaggregatefunction.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/sql_reference/data_types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/fa/sql_reference/data_types/special_data_types/expression.md b/docs/fa/sql_reference/data_types/special_data_types/expression.md deleted file mode 100644 index 102136441b6..00000000000 --- a/docs/fa/sql_reference/data_types/special_data_types/expression.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 58 -toc_title: "\u0639\u0628\u0627\u0631\u062A" ---- - -# عبارت {#expression} - -عبارات برای نمایندگی لامبداها در توابع بالا سفارش استفاده می شود. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/expression/) diff --git a/docs/fa/sql_reference/data_types/special_data_types/index.md b/docs/fa/sql_reference/data_types/special_data_types/index.md deleted file mode 100644 index d77e3bd93d2..00000000000 --- a/docs/fa/sql_reference/data_types/special_data_types/index.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Special Data Types -toc_hidden: true -toc_priority: 55 -toc_title: "\u0645\u062E\u0641\u06CC" ---- - -# انواع داده های ویژه {#special-data-types} - -مقادیر ویژه نوع داده را نمی توان برای صرفه جویی در یک جدول یا خروجی در نتایج پرس و جو سریال, اما می تواند به عنوان یک نتیجه متوسط در طول اجرای پرس و جو مورد استفاده قرار. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/) diff --git a/docs/fa/sql_reference/data_types/special_data_types/interval.md b/docs/fa/sql_reference/data_types/special_data_types/interval.md deleted file mode 100644 index 7c108a72641..00000000000 --- a/docs/fa/sql_reference/data_types/special_data_types/interval.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 61 -toc_title: "\u0641\u0627\u0635\u0644\u0647" ---- - -# فاصله {#data-type-interval} - -خانواده از انواع داده ها به نمایندگی از فواصل زمان و تاریخ. انواع حاصل از [INTERVAL](../../../sql_reference/operators.md#operator-interval) اپراتور - -!!! warning "اخطار" - `Interval` مقادیر نوع داده را نمی توان در جداول ذخیره کرد. - -ساختار: - -- فاصله زمانی به عنوان یک مقدار عدد صحیح بدون علامت. -- نوع یک بازه ی زمانی. - -انواع فاصله پشتیبانی شده: - -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -برای هر نوع فاصله, یک نوع داده جداگانه وجود دارد. برای مثال `DAY` فاصله مربوط به `IntervalDay` نوع داده: - -``` sql -SELECT toTypeName(INTERVAL 4 DAY) -``` - -``` text -┌─toTypeName(toIntervalDay(4))─┐ -│ IntervalDay │ -└──────────────────────────────┘ -``` - -## اظهارات طریقه استفاده {#data-type-interval-usage-remarks} - -شما می توانید استفاده کنید `Interval`- ارزش نوع در عملیات ریاضی با [تاریخ](../../../sql_reference/data_types/date.md) و [DateTime](../../../sql_reference/data_types/datetime.md)- ارزش نوع . مثلا, شما می توانید اضافه کنید 4 روز به زمان فعلی: - -``` sql -SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY -``` - -``` text -┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ -│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ -└─────────────────────┴───────────────────────────────┘ -``` - -فواصل با انواع مختلف نمی تواند ترکیب شود. شما می توانید فواصل مانند استفاده کنید `4 DAY 1 HOUR`. تعیین فواصل در واحد هایی که کوچکتر یا مساوی به کوچکترین واحد از فاصله مثلا فاصله `1 day and an hour` فاصله را می توان به عنوان بیان شده است `25 HOUR` یا `90000 SECOND`. - -شما می توانید عملیات ریاضی با انجام نمی `Interval`- ارزش نوع, اما شما می توانید فواصل از انواع مختلف در نتیجه به ارزش در اضافه `Date` یا `DateTime` انواع داده ها. به عنوان مثال: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -پرس و جوی زیر باعث می شود یک استثنا: - -``` sql -select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) -``` - -``` text -Received exception from server (version 19.14.1): -Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. -``` - -## همچنین نگاه کنید به {#see-also} - -- [INTERVAL](../../../sql_reference/operators.md#operator-interval) اپراتور -- [توینتروال](../../../sql_reference/functions/type_conversion_functions.md#function-tointerval) توابع تبدیل نوع diff --git a/docs/fa/sql_reference/data_types/special_data_types/nothing.md b/docs/fa/sql_reference/data_types/special_data_types/nothing.md deleted file mode 100644 index eff72a116ea..00000000000 --- a/docs/fa/sql_reference/data_types/special_data_types/nothing.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 60 -toc_title: "\u0647\u06CC\u0686 \u0686\u06CC\u0632" ---- - -# هیچی {#nothing} - -تنها هدف از این نوع داده ها نشان دهنده مواردی است که انتظار نمی رود ارزش باشد. بنابراین شما می توانید یک ایجاد کنید `Nothing` نوع ارزش. - -مثلا, تحت اللفظی [NULL](../../../sql_reference/syntax.md#null-literal) دارای نوع `Nullable(Nothing)`. اطلاعات بیشتر در مورد [Nullable](../../../sql_reference/data_types/nullable.md). - -این `Nothing` نوع نیز می تواند مورد استفاده برای نشان دادن خالی: - -``` sql -SELECT toTypeName(array()) -``` - -``` text -┌─toTypeName(array())─┐ -│ Array(Nothing) │ -└─────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/nothing/) diff --git a/docs/fa/sql_reference/data_types/special_data_types/set.md b/docs/fa/sql_reference/data_types/special_data_types/set.md deleted file mode 100644 index a3146c4a321..00000000000 --- a/docs/fa/sql_reference/data_types/special_data_types/set.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 59 -toc_title: "\u062A\u0646\u0638\u06CC\u0645" ---- - -# تنظیم {#set} - -مورد استفاده برای نیمه راست یک [IN](../../../sql_reference/statements/select.md#select-in-operators) اصطلاح. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/special_data_types/set/) diff --git a/docs/fa/sql_reference/data_types/string.md b/docs/fa/sql_reference/data_types/string.md deleted file mode 100644 index 4cd48b2a2f2..00000000000 --- a/docs/fa/sql_reference/data_types/string.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u0631\u0634\u062A\u0647" ---- - -# رشته {#string} - -رشته ها از طول دلخواه. طول محدود نمی شود. مقدار می تواند مجموعه دلخواه از بایت شامل, از جمله بایت پوچ. -نوع رشته جایگزین انواع لاکار, قطره, مسدود کردن, و دیگران را از دیگر سرویس بهداشتی. - -## کدگذاریها {#encodings} - -کلیکهاوس مفهوم کدگذاریها را ندارد. رشته ها می توانند شامل مجموعه دلخواه از بایت, که ذخیره می شود و خروجی به عنوان است. -اگر شما نیاز به ذخیره متون, توصیه می کنیم با استفاده از یونایتد-8 رمزگذاری. حداقل, اگر ترمینال خود را با استفاده از سخن گفتن-8 (به عنوان توصیه می شود), شما می توانید خواندن و نوشتن ارزش های خود را بدون ساخت تبدیل. -به طور مشابه, توابع خاص برای کار با رشته تغییرات جداگانه که با این فرض کار می کنند که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده-8. -برای مثال ‘length’ تابع محاسبه طول رشته در بایت, در حالی که ‘lengthUTF8’ تابع محاسبه طول رشته در نقاط کد یونیکد, فرض کنید که ارزش است گفتن-8 کد گذاری. - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/string/) diff --git a/docs/fa/sql_reference/data_types/tuple.md b/docs/fa/sql_reference/data_types/tuple.md deleted file mode 100644 index c971a5432fe..00000000000 --- a/docs/fa/sql_reference/data_types/tuple.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 53 -toc_title: "\u062A\u0627\u067E\u0644 (\u062A\u06CC1, \u062A\u06CC2,...)" ---- - -# Tuple(t1, T2, …) {#tuplet1-t2} - -یک تاپل از عناصر, هر یک با داشتن یک فرد [نوع](index.md#data_types). - -تاپل برای گروه بندی ستون موقت استفاده می شود. ستون ها را می توان گروه بندی کرد زمانی که یک عبارت در یک پرس و جو استفاده می شود, و برای مشخص کردن پارامترهای رسمی خاصی از توابع لامبدا. برای کسب اطلاعات بیشتر به بخش ها مراجعه کنید [در اپراتورها](../../sql_reference/statements/select.md) و [توابع سفارش بالاتر](../../sql_reference/functions/higher_order_functions.md). - -تاپل می تواند در نتیجه یک پرس و جو. در این مورد, برای فرمت های متنی غیر از جانسون, ارزش کاما از هم جدا در براکت. در فرمت های جوسون, تاپل خروجی به عنوان ارریس هستند (در براکت مربع). - -## ایجاد یک تاپل {#creating-a-tuple} - -شما می توانید یک تابع برای ایجاد یک تاپل استفاده کنید: - -``` sql -tuple(T1, T2, ...) -``` - -نمونه ای از ایجاد یک تاپل: - -``` sql -SELECT tuple(1,'a') AS x, toTypeName(x) -``` - -``` text -┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ -│ (1,'a') │ Tuple(UInt8, String) │ -└─────────┴───────────────────────────┘ -``` - -## کار با انواع داده ها {#working-with-data-types} - -در هنگام ایجاد یک تاپل در پرواز, تاتر به طور خودکار نوع هر استدلال به عنوان حداقل از انواع که می تواند ارزش استدلال ذخیره تشخیص. اگر استدلال است [NULL](../../sql_reference/syntax.md#null-literal), نوع عنصر تاپل است [Nullable](nullable.md). - -نمونه ای از تشخیص نوع داده ها به صورت خودکار: - -``` sql -SELECT tuple(1, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ -│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ -└──────────┴─────────────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/tuple/) diff --git a/docs/fa/sql_reference/data_types/uuid.md b/docs/fa/sql_reference/data_types/uuid.md deleted file mode 100644 index c8ed8a7cf79..00000000000 --- a/docs/fa/sql_reference/data_types/uuid.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 46 -toc_title: UUID ---- - -# UUID {#uuid-data-type} - -شناسه جهانی منحصر به فرد (شناسه) یک عدد 16 بایت مورد استفاده برای شناسایی سوابق است. برای کسب اطلاعات دقیق در مورد شناسه, دیدن [ویکیپدیا](https://en.wikipedia.org/wiki/Universally_unique_identifier). - -نمونه ای از ارزش نوع شناسه در زیر نشان داده شده است: - -``` text -61f0c404-5cb3-11e7-907b-a6006ad3dba0 -``` - -اگر شما مقدار ستون شناسه مشخص نیست در هنگام قرار دادن یک رکورد جدید, ارزش شناسه با صفر پر: - -``` text -00000000-0000-0000-0000-000000000000 -``` - -## چگونه برای تولید {#how-to-generate} - -برای تولید ارزش شناسه, خانه فراهم می کند [جنراتیدو4](../../sql_reference/functions/uuid_functions.md) تابع. - -## مثال طریقه استفاده {#usage-example} - -**مثال 1** - -این مثال نشان می دهد ایجاد یک جدول با ستون نوع شناسه و قرار دادن یک مقدار به جدول. - -``` sql -CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog -``` - -``` sql -INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -└──────────────────────────────────────┴───────────┘ -``` - -**مثال 2** - -در این مثال مقدار ستون یوید هنگام وارد کردن یک رکورد جدید مشخص نشده است. - -``` sql -INSERT INTO t_uuid (y) VALUES ('Example 2') -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ -└──────────────────────────────────────┴───────────┘ -``` - -## محدودیت ها {#restrictions} - -نوع داده شناسه تنها پشتیبانی از توابع که [رشته](string.md) نوع داده نیز پشتیبانی می کند (به عنوان مثال, [کمینه](../../sql_reference/aggregate_functions/reference.md#agg_function-min), [حداکثر](../../sql_reference/aggregate_functions/reference.md#agg_function-max) و [شمارش](../../sql_reference/aggregate_functions/reference.md#agg_function-count)). - -نوع داده یوید توسط عملیات ریاضی پشتیبانی نمی شود (به عنوان مثال, [شکم](../../sql_reference/functions/arithmetic_functions.md#arithm_func-abs)) و یا توابع دانه, مانند [جمع](../../sql_reference/aggregate_functions/reference.md#agg_function-sum) و [میانگین](../../sql_reference/aggregate_functions/reference.md#agg_function-avg). - -[مقاله اصلی](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts.md deleted file mode 100644 index 0022f8186a6..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u062A\u0648\u0636\u06CC\u062D\u0627\u062A \u06A9\u0644\u06CC" ---- - -# واژهنامهها خارجی {#dicts-external-dicts} - -شما می توانید لغت نامه خود را از منابع داده های مختلف اضافه کنید. منبع داده برای یک فرهنگ لغت می تواند یک متن محلی و یا فایل اجرایی, یک منبع اچتیتیپی(بازدید کنندگان), یا سندرم داون دیگر. برای کسب اطلاعات بیشتر, دیدن “[منابع لغت نامه های خارجی](external_dicts_dict_sources.md)”. - -فاحشه خانه: - -- به طور کامل و یا تا حدی فروشگاه لغت نامه در رم. -- دوره به روز رسانی لغت نامه ها و به صورت پویا بارهای ارزش از دست رفته. به عبارت دیگر, لغت نامه را می توان به صورت پویا لود. -- اجازه می دهد تا برای ایجاد لغت نامه های خارجی با فایل های میلی لیتر و یا [نمایش داده شد](../../statements/create.md#create-dictionary-query). - -پیکربندی لغت نامه های خارجی را می توان در یک یا چند میلی لیتر فایل واقع شده است. مسیر پیکربندی در مشخص [دیکشنامهای](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_config) پارامتر. - -واژهنامهها را می توان در هنگام راه اندازی سرور و یا در اولین استفاده لود, بسته به [\_بارگیری کامل](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) تنظیمات. - -فایل پیکربندی فرهنگ لغت دارای فرمت زیر است: - -``` xml - - An optional element with any content. Ignored by the ClickHouse server. - - - /etc/metrika.xml - - - - - - - - -``` - -شما می توانید [پیکربندی](external_dicts_dict.md) هر تعداد از لغت نامه ها در همان فایل. - -[نمایش داده شد دی ال برای لغت نامه](../../statements/create.md#create-dictionary-query) هیچ پرونده اضافی در پیکربندی سرور نیاز ندارد. اجازه می دهد برای کار با لغت نامه به عنوان نهادهای طبقه اول, مانند جداول و یا دیدگاه. - -!!! attention "توجه" - شما می توانید مقادیر را برای یک فرهنگ لغت کوچک با توصیف در یک تبدیل کنید `SELECT` پرسوجو (نگاه کنید به [تبدیل](../../../sql_reference/functions/other_functions.md) تابع). این قابلیت به لغت نامه های خارجی مربوط نیست. - -## همچنین نگاه کنید به {#ext-dicts-see-also} - -- [پیکربندی یک فرهنگ لغت خارجی](external_dicts_dict.md) -- [ذخیره واژهنامهها در حافظه](external_dicts_dict_layout.md) -- [به روز رسانی فرهنگ لغت](external_dicts_dict_lifetime.md) -- [منابع لغت نامه های خارجی](external_dicts_dict_sources.md) -- [کلید فرهنگ لغت و زمینه های](external_dicts_dict_structure.md) -- [توابع برای کار با لغت نامه های خارجی](../../../sql_reference/functions/ext_dict_functions.md) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md deleted file mode 100644 index a33d3f4c18d..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "\u067E\u06CC\u06A9\u0631\u0628\u0646\u062F\u06CC \u06CC\u06A9 \u0641\u0631\ - \u0647\u0646\u06AF \u0644\u063A\u062A \u062E\u0627\u0631\u062C\u06CC" ---- - -# پیکربندی یک فرهنگ لغت خارجی {#dicts-external-dicts-dict} - -اگر فرهنگ لغت با استفاده از فایل میلی لیتر پیکربندی, از پیکربندی فرهنگ لغت دارای ساختار زیر: - -``` xml - - dict_name - - - - - - - - - - - - - - - - - -``` - -متناظر [توصیف](../../statements/create.md#create-dictionary-query) دارای ساختار زیر است: - -``` sql -CREATE DICTIONARY dict_name -( - ... -- attributes -) -PRIMARY KEY ... -- complex or single key configuration -SOURCE(...) -- Source configuration -LAYOUT(...) -- Memory layout configuration -LIFETIME(...) -- Lifetime of dictionary in memory -``` - -- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. -- [متن](external_dicts_dict_sources.md) — Source of the dictionary. -- [طرحبندی](external_dicts_dict_layout.md) — Dictionary layout in memory. -- [ساختار](external_dicts_dict_structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. -- [طول عمر](external_dicts_dict_lifetime.md) — Frequency of dictionary updates. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md deleted file mode 100644 index 15120b3e8c2..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: "\u0644\u063A\u062A\u0646\u0627\u0645\u0647\u0647\u0627 \u0633\u0644\u0633\ - \u0644\u0647 \u0645\u0631\u0627\u062A\u0628\u06CC" ---- - -# لغتنامهها سلسله مراتبی {#hierarchical-dictionaries} - -کلیک هاوس از لغت نامه های سلسله مراتبی با یک [کلید عددی](external_dicts_dict_structure.md#ext_dict-numeric-key). - -در ساختار سلسله مراتبی زیر نگاه کنید: - -``` text -0 (Common parent) -│ -├── 1 (Russia) -│ │ -│ └── 2 (Moscow) -│ │ -│ └── 3 (Center) -│ -└── 4 (Great Britain) - │ - └── 5 (London) -``` - -این سلسله مراتب را می توان به عنوان جدول فرهنگ لغت زیر بیان شده است. - -| \_ورود | \_ نواحی | نام \_خانوادگی | -|--------|----------|----------------| -| 1 | 0 | روسیه | -| 2 | 1 | مسکو | -| 3 | 2 | مرکز | -| 4 | 0 | بریتانیا | -| 5 | 4 | لندن | - -این جدول شامل یک ستون است `parent_region` که شامل کلید نزدیکترین پدر و مادر برای عنصر. - -تاتر از [سلسله مراتبی](external_dicts_dict_structure.md#hierarchical-dict-attr) املاک برای [فرهنگ لغت خارجی](index.md) صفات. این ویژگی اجازه می دهد تا شما را به پیکربندی فرهنگ لغت سلسله مراتبی شبیه به بالا توضیح داده شد. - -این [حکومت دیکتاتوری](../../../sql_reference/functions/ext_dict_functions.md#dictgethierarchy) تابع اجازه می دهد تا شما را به زنجیره پدر و مادر از یک عنصر. - -برای مثال ما ساختار فرهنگ لغت می تواند به شرح زیر است: - -``` xml - - - - region_id - - - - parent_region - UInt64 - 0 - true - - - - region_name - String - - - - - -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md deleted file mode 100644 index b1bbf407f7c..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md +++ /dev/null @@ -1,374 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: "\u0630\u062E\u06CC\u0631\u0647 \u0648\u0627\u0698\u0647\u0646\u0627\u0645\ - \u0647\u0647\u0627 \u062F\u0631 \u062D\u0627\u0641\u0638\u0647" ---- - -# ذخیره واژهنامهها در حافظه {#dicts-external-dicts-dict-layout} - -راه های مختلفی برای ذخیره لغت نامه ها در حافظه وجود دارد. - -ما توصیه می کنیم [تخت](#flat), [درهم](#dicts-external_dicts_dict_layout-hashed) و [\_ساخت مجتمع](#complex-key-hashed). که سرعت پردازش بهینه را فراهم می کند. - -ذخیره سازی به دلیل عملکرد بالقوه ضعیف و مشکلات در انتخاب پارامترهای مطلوب توصیه نمی شود. ادامه مطلب در بخش “[نهانگاه](#cache)”. - -راه های مختلفی برای بهبود عملکرد فرهنگ لغت وجود دارد: - -- پاسخ تابع برای کار با فرهنگ لغت پس از `GROUP BY`. -- علامت گذاری به عنوان ویژگی برای استخراج به عنوان تزریقی. یک ویژگی است که به نام عاطفی اگر مقادیر ویژگی های مختلف به کلید های مختلف مطابقت دارد. بنابراین زمانی که `GROUP BY` با استفاده از یک تابع است که بازخوانی ارزش ویژگی های کلیدی, این تابع به طور خودکار از گرفته `GROUP BY`. - -تاتر تولید یک استثنا برای خطا با لغت نامه. نمونه هایی از اشتباهات: - -- فرهنگ لغت در حال دسترسی نمی تواند لود شود. -- خطای پرسوجو یک `cached` فرهنگ لغت. - -شما می توانید لیستی از لغت نامه های خارجی و وضعیت خود را در `system.dictionaries` جدول - -پیکربندی به نظر می رسد مثل این: - -``` xml - - - ... - - - - - - ... - - -``` - -متناظر [توصیف](../../statements/create.md#create-dictionary-query): - -``` sql -CREATE DICTIONARY (...) -... -LAYOUT(LAYOUT_TYPE(param value)) -- layout settings -... -``` - -## راه هایی برای ذخیره لغت نامه ها در حافظه {#ways-to-store-dictionaries-in-memory} - -- [تخت](#flat) -- [درهم](#dicts-external_dicts_dict_layout-hashed) -- [فشردهسازی](#dicts-external_dicts_dict_layout-sparse_hashed) -- [نهانگاه](#cache) -- [رنگها](#range-hashed) -- [\_ساخت مجتمع](#complex-key-hashed) -- [\_پیچید\_چهای پیچیده](#complex-key-cache) -- [شمال اروپا](#ip-trie) - -### تخت {#flat} - -فرهنگ لغت به طور کامل در حافظه در قالب مجموعه تخت ذخیره می شود. چقدر حافظه استفاده از فرهنگ لغت? مقدار متناسب با اندازه بزرگترین کلید است (در فضا استفاده می شود). - -کلید فرهنگ لغت است `UInt64` نوع و ارزش محدود به 500,000 است. اگر یک کلید بزرگتر کشف شده است در هنگام ایجاد فرهنگ لغت, تاتر می اندازد یک استثنا و فرهنگ لغت ایجاد کنید. - -تمام انواع منابع پشتیبانی می شوند. هنگام به روز رسانی, داده ها (از یک فایل و یا از یک جدول) در تمامیت خود را به عنوان خوانده شده. - -این روش بهترین عملکرد را در میان تمام روش های موجود ذخیره سازی فرهنگ لغت فراهم می کند. - -مثال پیکربندی: - -``` xml - - - -``` - -یا - -``` sql -LAYOUT(FLAT()) -``` - -### درهم {#dicts-external_dicts_dict_layout-hashed} - -فرهنگ لغت به طور کامل در حافظه در قالب یک جدول هش ذخیره می شود. فرهنگ لغت می تواند شامل هر تعداد از عناصر با هر شناسه در عمل تعداد کلید ده ها میلیون نفر از اقلام برسد. - -تمام انواع منابع پشتیبانی می شوند. هنگام به روز رسانی, داده ها (از یک فایل و یا از یک جدول) در تمامیت خود را به عنوان خوانده شده. - -مثال پیکربندی: - -``` xml - - - -``` - -یا - -``` sql -LAYOUT(HASHED()) -``` - -### فشردهسازی {#dicts-external_dicts_dict_layout-sparse_hashed} - -مشابه به `hashed`, اما با استفاده از حافظه کمتر به نفع استفاده از پردازنده بیشتر. - -مثال پیکربندی: - -``` xml - - - -``` - -``` sql -LAYOUT(SPARSE_HASHED()) -``` - -### \_ساخت مجتمع {#complex-key-hashed} - -این نوع ذخیره سازی برای استفاده با کامپوزیت است [کلید](external_dicts_dict_structure.md). مشابه به `hashed`. - -مثال پیکربندی: - -``` xml - - - -``` - -``` sql -LAYOUT(COMPLEX_KEY_HASHED()) -``` - -### رنگها {#range-hashed} - -فرهنگ لغت در حافظه به شکل یک جدول هش با مجموعه ای مرتب از محدوده ها و مقادیر مربوطه ذخیره می شود. - -این روش ذخیره سازی کار می کند به همان شیوه به عنوان درهم و اجازه می دهد تا با استفاده از تاریخ/زمان (نوع عددی دلخواه) محدوده علاوه بر کلید. - -مثال: جدول شامل تخفیف برای هر تبلیغ در قالب: - -``` text -+---------|-------------|-------------|------+ -| advertiser id | discount start date | discount end date | amount | -+===============+=====================+===================+========+ -| 123 | 2015-01-01 | 2015-01-15 | 0.15 | -+---------|-------------|-------------|------+ -| 123 | 2015-01-16 | 2015-01-31 | 0.25 | -+---------|-------------|-------------|------+ -| 456 | 2015-01-01 | 2015-01-15 | 0.05 | -+---------|-------------|-------------|------+ -``` - -برای استفاده از یک نمونه برای محدوده تاریخ, تعریف `range_min` و `range_max` عناصر در [ساختار](external_dicts_dict_structure.md). این عناصر باید حاوی عناصر `name` و`type` (اگر `type` مشخص نشده است, نوع پیش فرض استفاده خواهد شد - تاریخ). `type` می تواند هر نوع عددی (تاریخ / DateTime / UInt64 / Int32 / دیگران). - -مثال: - -``` xml - - - Id - - - first - Date - - - last - Date - - ... -``` - -یا - -``` sql -CREATE DICTIONARY somedict ( - id UInt64, - first Date, - last Date -) -PRIMARY KEY id -LAYOUT(RANGE_HASHED()) -RANGE(MIN first MAX last) -``` - -برای کار با این لغت نامه, شما نیاز به تصویب یک استدلال اضافی به `dictGetT` تابع, که یک محدوده انتخاب شده است: - -``` sql -dictGetT('dict_name', 'attr_name', id, date) -``` - -این تابع ارزش برای مشخص گرداند `id`بازدید کنندگان و محدوده تاریخ که شامل تاریخ گذشت. - -اطلاعات از الگوریتم: - -- اگر `id` یافت نشد و یا یک محدوده برای یافت نشد `id` مقدار پیش فرض فرهنگ لغت را برمی گرداند. -- اگر با هم تداخل دارند محدوده وجود دارد, شما می توانید هر استفاده. -- اگر جداساز محدوده باشد `NULL` یا نامعتبر تاریخ (مانند 1900-01-01 یا 2039-01-01) طیف وسیعی است که در سمت چپ باز است. محدوده را می توان در هر دو طرف باز کرد. - -مثال پیکربندی: - -``` xml - - - - ... - - - - - - - - Abcdef - - - StartTimeStamp - UInt64 - - - EndTimeStamp - UInt64 - - - XXXType - String - - - - - - -``` - -یا - -``` sql -CREATE DICTIONARY somedict( - Abcdef UInt64, - StartTimeStamp UInt64, - EndTimeStamp UInt64, - XXXType String DEFAULT '' -) -PRIMARY KEY Abcdef -RANGE(MIN StartTimeStamp MAX EndTimeStamp) -``` - -### نهانگاه {#cache} - -فرهنگ لغت در کش است که تعداد ثابتی از سلول های ذخیره می شود. این سلول ها حاوی عناصر اغلب استفاده می شود. - -هنگام جستجو برای یک فرهنگ لغت کش اول جستجو می شود. برای هر بلوک از داده ها, تمام کلید هایی که در کش یافت نشد و یا منسوخ شده از منبع با استفاده از درخواست `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. داده های دریافت شده است و سپس به کش نوشته شده است. - -برای لغت نامه کش, انقضا [طول عمر](external_dicts_dict_lifetime.md) از داده ها در کش را می توان تنظیم کرد. اگر زمان بیشتری از `lifetime` از زمان بارگذاری داده ها در یک سلول گذشت, ارزش سلول استفاده نمی شود, و دوباره درخواست دفعه بعد که نیاز به استفاده می شود. -این حداقل موثر از تمام راه هایی برای ذخیره لغت نامه است. سرعت کش به شدت در تنظیمات صحیح و سناریوی استفاده بستگی دارد. فرهنگ لغت نوع کش به خوبی انجام تنها زمانی که نرخ ضربه به اندازه کافی بالا هستند (توصیه می شود 99% و بالاتر). شما می توانید میزان ضربه به طور متوسط در مشاهده `system.dictionaries` جدول - -برای بهبود عملکرد کش, استفاده از یک خرده فروشی با `LIMIT`, و پاسخ تابع با فرهنگ لغت خارجی. - -پشتیبانی [منابع](external_dicts_dict_sources.md) پردازشگر پشتیبانی شده: - -مثال تنظیمات: - -``` xml - - - - 1000000000 - - -``` - -یا - -``` sql -LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) -``` - -تنظیم اندازه کش به اندازه کافی بزرگ است. شما نیاز به تجربه برای انتخاب تعدادی از سلول های: - -1. تنظیم برخی از ارزش. -2. نمایش داده شد اجرا تا کش کاملا کامل است. -3. ارزیابی مصرف حافظه با استفاده از `system.dictionaries` جدول -4. افزایش یا کاهش تعداد سلول ها تا زمانی که مصرف حافظه مورد نیاز رسیده است. - -!!! warning "اخطار" - هنوز تاتر به عنوان یک منبع استفاده نمی, چرا که کند است برای پردازش نمایش داده شد با تصادفی می خواند. - -### \_پیچید\_چهای پیچیده {#complex-key-cache} - -این نوع ذخیره سازی برای استفاده با کامپوزیت است [کلید](external_dicts_dict_structure.md). مشابه به `cache`. - -### شمال اروپا {#ip-trie} - -این نوع ذخیره سازی برای پیشوندهای نقشه برداری شبکه (نشانی های اینترنتی) به فراداده مانند ان است. - -مثال: جدول شامل پیشوندهای شبکه و مربوط به خود را به عنوان شماره و کد کشور: - -``` text - +-----------|-----|------+ - | prefix | asn | cca2 | - +=================+=======+========+ - | 202.79.32.0/20 | 17501 | NP | - +-----------|-----|------+ - | 2620:0:870::/48 | 3856 | US | - +-----------|-----|------+ - | 2a02:6b8:1::/48 | 13238 | RU | - +-----------|-----|------+ - | 2001:db8::/32 | 65536 | ZZ | - +-----------|-----|------+ -``` - -هنگام استفاده از این نوع طرح, ساختار باید یک کلید کامپوزیت دارند. - -مثال: - -``` xml - - - - prefix - String - - - - asn - UInt32 - - - - cca2 - String - ?? - - ... -``` - -یا - -``` sql -CREATE DICTIONARY somedict ( - prefix String, - asn UInt32, - cca2 String DEFAULT '??' -) -PRIMARY KEY prefix -``` - -کلید باید تنها یک ویژگی نوع رشته ای داشته باشد که شامل یک پیشوند مجاز است. انواع دیگر هنوز پشتیبانی نمی شوند. - -برای نمایش داده شد, شما باید توابع مشابه استفاده کنید (`dictGetT` با یک تاپل) به لغت نامه ها با کلید های ترکیبی: - -``` sql -dictGetT('dict_name', 'attr_name', tuple(ip)) -``` - -تابع طول می کشد یا `UInt32` برای ایپو4 یا `FixedString(16)` برای IPv6: - -``` sql -dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) -``` - -انواع دیگر هنوز پشتیبانی نمی شوند. تابع ویژگی برای پیشوند که مربوط به این نشانی اینترنتی را برمی گرداند. اگر پیشوند با هم تداخل دارند وجود دارد, یکی از خاص ترین بازگشته است. - -داده ها در یک ذخیره می شود `trie`. این به طور کامل باید به رم مناسب. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md deleted file mode 100644 index cb315313a24..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u0628\u0647 \u0631\u0648\u0632 \u0631\u0633\u0627\u0646\u06CC \u0641\u0631\ - \u0647\u0646\u06AF \u0644\u063A\u062A" ---- - -# به روز رسانی فرهنگ لغت {#dictionary-updates} - -خانه کلیک دوره به روز رسانی لغت نامه. فاصله به روز رسانی برای لغت نامه به طور کامل دانلود و فاصله ابطال لغت نامه کش در تعریف `` برچسب در ثانیه. - -به روز رسانی فرهنگ لغت (به غیر از بارگذاری برای استفاده اول) نمایش داده شد را مسدود کند. در طول به روز رسانی, نسخه های قدیمی از یک فرهنگ لغت استفاده شده است. اگر یک خطا در طول به روز رسانی رخ می دهد, خطا به ورود به سیستم سرور نوشته شده, و نمایش داده شد ادامه استفاده از نسخه های قدیمی از لغت نامه. - -مثال تنظیمات: - -``` xml - - ... - 300 - ... - -``` - -``` sql -CREATE DICTIONARY (...) -... -LIFETIME(300) -... -``` - -تنظیم `0` (`LIFETIME(0)`) جلوگیری از لغت نامه از به روز رسانی . - -شما می توانید یک بازه زمانی برای ارتقا تنظیم, و تاتر یک زمان یکنواخت تصادفی در این محدوده را انتخاب کنید. این به منظور توزیع بار بر روی منبع فرهنگ لغت در هنگام به روز رسانی در تعداد زیادی از سرور لازم است. - -مثال تنظیمات: - -``` xml - - ... - - 300 - 360 - - ... - -``` - -یا - -``` sql -LIFETIME(MIN 300 MAX 360) -``` - -هنگام به روز رسانی لغت نامه, سرور کلیک اعمال منطق مختلف بسته به نوع [متن](external_dicts_dict_sources.md): - -- برای یک فایل متنی زمان اصلاح را بررسی می کند. اگر زمان از زمان قبلا ثبت شده متفاوت, فرهنگ لغت به روز شده است. -- برای جداول میثم, زمان اصلاح بررسی می شود با استفاده از یک `SHOW TABLE STATUS` پرس و جو. -- واژهنامهها از منابع دیگر در هر زمان به طور پیش فرض به روز شد. - -برای خروجی زیر (دیگر), ان بی سی و منابع فاحشه خانه, شما می توانید راه اندازی یک پرس و جو است که لغت نامه تنها در صورتی که واقعا تغییر به روز رسانی, به جای هر زمان. برای انجام این کار این مراحل را دنبال کنید: - -- جدول فرهنگ لغت باید یک میدان است که همیشه تغییر زمانی که داده های منبع به روز شده است. -- تنظیمات منبع باید پرس و جو که بازیابی زمینه در حال تغییر را مشخص کنید. سرور کلیک تفسیر نتیجه پرس و جو به عنوان یک ردیف, و اگر این ردیف نسبت به حالت قبلی خود تغییر کرده است, فرهنگ لغت به روز شده است. مشخص کردن پرسوجو در `` درست در تنظیمات برای [متن](external_dicts_dict_sources.md). - -مثال تنظیمات: - -``` xml - - ... - - ... - SELECT update_time FROM dictionary_source where id = 1 - - ... - -``` - -یا - -``` sql -... -SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) -... -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md deleted file mode 100644 index 398e4ceab39..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md +++ /dev/null @@ -1,609 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: "\u0645\u0646\u0627\u0628\u0639 \u0644\u063A\u062A \u0646\u0627\u0645\u0647\ - \ \u0647\u0627\u06CC \u062E\u0627\u0631\u062C\u06CC" ---- - -# منابع لغت نامه های خارجی {#dicts-external-dicts-dict-sources} - -فرهنگ لغت خارجی را می توان از بسیاری از منابع مختلف متصل می شود. - -اگر فرهنگ لغت پیکربندی شده است با استفاده از فایل های فشرده, پیکربندی به نظر می رسد مثل این: - -``` xml - - - ... - - - - - - ... - - ... - -``` - -در صورت [توصیف](../../statements/create.md#create-dictionary-query), پیکربندی برابر خواهد شد مانند به نظر می رسد: - -``` sql -CREATE DICTIONARY dict_name (...) -... -SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration -... -``` - -منبع در پیکربندی `source` بخش. - -انواع منابع (`source_type`): - -- [پرونده محلی](#dicts-external_dicts_dict_sources-local_file) -- [پرونده اجرایی](#dicts-external_dicts_dict_sources-executable) -- [HTTP(s)](#dicts-external_dicts_dict_sources-http) -- DBMS - - [ODBC](#dicts-external_dicts_dict_sources-odbc) - - [MySQL](#dicts-external_dicts_dict_sources-mysql) - - [فاحشه خانه](#dicts-external_dicts_dict_sources-clickhouse) - - [مانگودیبی](#dicts-external_dicts_dict_sources-mongodb) - - [ردیس](#dicts-external_dicts_dict_sources-redis) - -## پرونده محلی {#dicts-external_dicts_dict_sources-local_file} - -مثال تنظیمات: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - -``` - -یا - -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -تنظیم فیلدها: - -- `path` – The absolute path to the file. -- `format` – The file format. All the formats described in “[فرشها](../../../interfaces/formats.md#formats)” پشتیبانی می شوند. - -## پرونده اجرایی {#dicts-external_dicts_dict_sources-executable} - -کار با فایل های اجرایی بستگی دارد [چگونه فرهنگ لغت در حافظه ذخیره می شود](external_dicts_dict_layout.md). اگر فرهنگ لغت با استفاده از ذخیره می شود `cache` و `complex_key_cache` کلیک هاوس کلید های لازم را با ارسال درخواست به فایل اجرایی درخواست می کند. در غیر این صورت, تاتر شروع می شود فایل اجرایی و خروجی خود را به عنوان داده فرهنگ لغت رفتار. - -مثال تنظیمات: - -``` xml - - - cat /opt/dictionaries/os.tsv - TabSeparated - - -``` - -یا - -``` sql -SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -تنظیم فیلدها: - -- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). -- `format` – The file format. All the formats described in “[فرشها](../../../interfaces/formats.md#formats)” پشتیبانی می شوند. - -## قام) {#dicts-external_dicts_dict_sources-http} - -کار با سرور اچ تی پی بستگی دارد [چگونه فرهنگ لغت در حافظه ذخیره می شود](external_dicts_dict_layout.md). اگر فرهنگ لغت با استفاده از ذخیره می شود `cache` و `complex_key_cache`, کلیک درخواست کلید های لازم با ارسال یک درخواست از طریق `POST` روش. - -مثال تنظیمات: - -``` xml - - - http://[::1]/os.tsv - TabSeparated - - user - password - - -
- API-KEY - key -
-
-
- -``` - -یا - -``` sql -SOURCE(HTTP( - url 'http://[::1]/os.tsv' - format 'TabSeparated' - credentials(user 'user' password 'password') - headers(header(name 'API-KEY' value 'key')) -)) -``` - -برای دسترسی به یک منبع اچ تی پی باید از اینجا کلیک کنید [پیکربندی اپنسسل](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-openssl) در پیکربندی سرور. - -تنظیم فیلدها: - -- `url` – The source URL. -- `format` – The file format. All the formats described in “[فرشها](../../../interfaces/formats.md#formats)” پشتیبانی می شوند. -- `credentials` – Basic HTTP authentication. Optional parameter. - - `user` – Username required for the authentication. - - `password` – Password required for the authentication. -- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. - - `header` – Single HTTP header entry. - - `name` – Identifiant name used for the header send on the request. - - `value` – Value set for a specific identifiant name. - -## ODBC {#dicts-external_dicts_dict_sources-odbc} - -شما می توانید از این روش برای اتصال هر پایگاه داده است که یک راننده بی سی استفاده کنید. - -مثال تنظیمات: - -``` xml - - - DatabaseName -
ShemaName.TableName
- DSN=some_parameters - SQL_QUERY - - -``` - -یا - -``` sql -SOURCE(ODBC( - db 'DatabaseName' - table 'SchemaName.TableName' - connection_string 'DSN=some_parameters' - invalidate_query 'SQL_QUERY' -)) -``` - -تنظیم فیلدها: - -- `db` – Name of the database. Omit it if the database name is set in the `` پارامترها -- `table` – Name of the table and schema if exists. -- `connection_string` – Connection string. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [بهروزرسانی واژهنامهها](external_dicts_dict_lifetime.md). - -تاتر دریافت به نقل از علامت از او بی سی راننده و نقل قول تمام تنظیمات در نمایش داده شد به راننده, بنابراین لازم است به مجموعه ای از نام جدول بر این اساس به نام جدول مورد در پایگاه داده. - -اگر شما یک مشکل با کدگذاریها در هنگام استفاده از اوراکل, دیدن مربوطه [FAQ](../../../faq/general.md#oracle-odbc-encodings) مقاله. - -### قابلیت پذیری شناخته شده از قابلیت او بی سی فرهنگ لغت {#known-vulnerability-of-the-odbc-dictionary-functionality} - -!!! attention "توجه" - هنگام اتصال به پایگاه داده از طریق پارامتر اتصال درایور او بی سی `Servername` می تواند جایگزین شود. در این مورد ارزش `USERNAME` و `PASSWORD` از `odbc.ini` به سرور از راه دور ارسال می شود و می تواند به خطر بیافتد. - -**نمونه ای از استفاده نا امن** - -اجازه می دهد تا پیکربندی unixodbc برای postgresql. محتوای `/etc/odbc.ini`: - -``` text -[gregtest] -Driver = /usr/lib/psqlodbca.so -Servername = localhost -PORT = 5432 -DATABASE = test_db -#OPTION = 3 -USERNAME = test -PASSWORD = test -``` - -اگر شما پس از ایجاد یک پرس و جو مانند - -``` sql -SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); -``` - -درایور او بی سی خواهد ارزش ارسال `USERNAME` و `PASSWORD` از `odbc.ini` به `some-server.com`. - -### به عنوان مثال از اتصال شل {#example-of-connecting-postgresql} - -سیستم عامل اوبونتو. - -نصب unixodbc و odbc driver for postgresql: - -``` bash -$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql -``` - -پیکربندی `/etc/odbc.ini` (یا `~/.odbc.ini`): - -``` text - [DEFAULT] - Driver = myconnection - - [myconnection] - Description = PostgreSQL connection to my_db - Driver = PostgreSQL Unicode - Database = my_db - Servername = 127.0.0.1 - UserName = username - Password = password - Port = 5432 - Protocol = 9.3 - ReadOnly = No - RowVersioning = No - ShowSystemTables = No - ConnSettings = -``` - -پیکربندی فرهنگ لغت در کلیک: - -``` xml - - - table_name - - - - - DSN=myconnection - postgresql_table
-
- - - 300 - 360 - - - - - - - id - - - some_column - UInt64 - 0 - - -
-
-``` - -یا - -``` sql -CREATE DICTIONARY table_name ( - id UInt64, - some_column UInt64 DEFAULT 0 -) -PRIMARY KEY id -SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) -LAYOUT(HASHED()) -LIFETIME(MIN 300 MAX 360) -``` - -شما ممکن است نیاز به ویرایش `odbc.ini` برای مشخص کردن مسیر کامل به کتابخانه با راننده `DRIVER=/usr/local/lib/psqlodbcw.so`. - -### به عنوان مثال اتصال سرور کارشناسی ارشد گذاشتن {#example-of-connecting-ms-sql-server} - -سیستم عامل اوبونتو. - -نصب درایور: : - -``` bash -$ sudo apt-get install tdsodbc freetds-bin sqsh -``` - -پیکربندی راننده: - -``` bash - $ cat /etc/freetds/freetds.conf - ... - - [MSSQL] - host = 192.168.56.101 - port = 1433 - tds version = 7.0 - client charset = UTF-8 - - $ cat /etc/odbcinst.ini - ... - - [FreeTDS] - Description = FreeTDS - Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so - Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so - FileUsage = 1 - UsageCount = 5 - - $ cat ~/.odbc.ini - ... - - [MSSQL] - Description = FreeTDS - Driver = FreeTDS - Servername = MSSQL - Database = test - UID = test - PWD = test - Port = 1433 -``` - -پیکربندی فرهنگ لغت در کلیک: - -``` xml - - - test - - - dict
- DSN=MSSQL;UID=test;PWD=test -
- - - - 300 - 360 - - - - - - - - - k - - - s - String - - - -
-
-``` - -یا - -``` sql -CREATE DICTIONARY test ( - k UInt64, - s String DEFAULT '' -) -PRIMARY KEY k -SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) -LAYOUT(FLAT()) -LIFETIME(MIN 300 MAX 360) -``` - -## DBMS {#dbms} - -### Mysql {#dicts-external_dicts_dict_sources-mysql} - -مثال تنظیمات: - -``` xml - - - 3306 - clickhouse - qwerty - - example01-1 - 1 - - - example01-2 - 1 - - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -یا - -``` sql -SOURCE(MYSQL( - port 3306 - user 'clickhouse' - password 'qwerty' - replica(host 'example01-1' priority 1) - replica(host 'example01-2' priority 1) - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -تنظیم فیلدها: - -- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). - -- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `replica` – Section of replica configurations. There can be multiple sections. - - - `replica/host` – The MySQL host. - - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. - -- `db` – Name of the database. - -- `table` – Name of the table. - -- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` بند در خروجی زیر, مثلا, `id > 10 AND id < 20`. پارامتر اختیاری. - -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [بهروزرسانی واژهنامهها](external_dicts_dict_lifetime.md). - -خروجی زیر را می توان در یک میزبان محلی از طریق سوکت متصل. برای انجام این کار, تنظیم `host` و `socket`. - -مثال تنظیمات: - -``` xml - - - localhost - /path/to/socket/file.sock - clickhouse - qwerty - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -یا - -``` sql -SOURCE(MYSQL( - host 'localhost' - socket '/path/to/socket/file.sock' - user 'clickhouse' - password 'qwerty' - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -### فاحشه خانه {#dicts-external_dicts_dict_sources-clickhouse} - -مثال تنظیمات: - -``` xml - - - example01-01-1 - 9000 - default - - default - ids
- id=10 -
- -``` - -یا - -``` sql -SOURCE(CLICKHOUSE( - host 'example01-01-1' - port 9000 - user 'default' - password '' - db 'default' - table 'ids' - where 'id=10' -)) -``` - -تنظیم فیلدها: - -- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [توزیع شده](../../../engines/table_engines/special/distributed.md) جدول و در تنظیمات بعدی وارد کنید. -- `port` – The port on the ClickHouse server. -- `user` – Name of the ClickHouse user. -- `password` – Password of the ClickHouse user. -- `db` – Name of the database. -- `table` – Name of the table. -- `where` – The selection criteria. May be omitted. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [بهروزرسانی واژهنامهها](external_dicts_dict_lifetime.md). - -### مانگودیبی {#dicts-external_dicts_dict_sources-mongodb} - -مثال تنظیمات: - -``` xml - - - localhost - 27017 - - - test - dictionary_source - - -``` - -یا - -``` sql -SOURCE(MONGO( - host 'localhost' - port 27017 - user '' - password '' - db 'test' - collection 'dictionary_source' -)) -``` - -تنظیم فیلدها: - -- `host` – The MongoDB host. -- `port` – The port on the MongoDB server. -- `user` – Name of the MongoDB user. -- `password` – Password of the MongoDB user. -- `db` – Name of the database. -- `collection` – Name of the collection. - -### ردیس {#dicts-external_dicts_dict_sources-redis} - -مثال تنظیمات: - -``` xml - - - localhost - 6379 - simple - 0 - - -``` - -یا - -``` sql -SOURCE(REDIS( - host 'localhost' - port 6379 - storage_type 'simple' - db_index 0 -)) -``` - -تنظیم فیلدها: - -- `host` – The Redis host. -- `port` – The port on the Redis server. -- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` برای منابع ساده و برای منابع تک کلیدی درهم, `hash_map` برای منابع درهم با دو کلید. منابع در بازه زمانی و منابع کش با کلید پیچیده پشتیبانی نشده است. ممکن است حذف شود, مقدار پیش فرض است `simple`. -- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md deleted file mode 100644 index 914e7968e5c..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u06A9\u0644\u06CC\u062F \u0641\u0631\u0647\u0646\u06AF \u0644\u063A\u062A\ - \ \u0648 \u0632\u0645\u06CC\u0646\u0647 \u0647\u0627\u06CC" ---- - -# کلید فرهنگ لغت و زمینه های {#dictionary-key-and-fields} - -این `` بند توصیف کلید فرهنگ لغت و زمینه های موجود برای نمایش داده شد. - -توصیف: - -``` xml - - - - Id - - - - - - - ... - - - -``` - -صفات در عناصر شرح داده شده است: - -- `` — [ستون کلید](external_dicts_dict_structure.md#ext_dict_structure-key). -- `` — [ستون داده](external_dicts_dict_structure.md#ext_dict_structure-attributes). می تواند تعدادی از ویژگی های وجود دارد. - -پرسوجو: - -``` sql -CREATE DICTIONARY dict_name ( - Id UInt64, - -- attributes -) -PRIMARY KEY Id -... -``` - -صفات در بدن پرس و جو توصیف: - -- `PRIMARY KEY` — [ستون کلید](external_dicts_dict_structure.md#ext_dict_structure-key) -- `AttrName AttrType` — [ستون داده](external_dicts_dict_structure.md#ext_dict_structure-attributes). می تواند تعدادی از ویژگی های وجود دارد. - -## کلید {#ext_dict_structure-key} - -تاتر از انواع زیر از کلید: - -- کلید عددی. `UInt64`. تعریف شده در `` برچسب یا استفاده `PRIMARY KEY` کلمه کلیدی. -- کلید کامپوزیت. مجموعه ای از مقادیر از انواع مختلف. تعریف شده در برچسب `` یا `PRIMARY KEY` کلمه کلیدی. - -یک ساختار میلی لیتر می تواند شامل موارد زیر باشد `` یا ``. دی ال پرس و جو باید شامل تک `PRIMARY KEY`. - -!!! warning "اخطار" - شما باید کلید به عنوان یک ویژگی توصیف نیست. - -### کلید عددی {#ext_dict-numeric-key} - -نوع: `UInt64`. - -مثال پیکربندی: - -``` xml - - Id - -``` - -حوزههای پیکربندی: - -- `name` – The name of the column with keys. - -برای & پرسوجو: - -``` sql -CREATE DICTIONARY ( - Id UInt64, - ... -) -PRIMARY KEY Id -... -``` - -- `PRIMARY KEY` – The name of the column with keys. - -### کلید کامپوزیت {#composite-key} - -کلید می تواند یک `tuple` از هر نوع زمینه. این [طرحبندی](external_dicts_dict_layout.md) در این مورد باید باشد `complex_key_hashed` یا `complex_key_cache`. - -!!! tip "نکته" - کلید کامپوزیت می تواند از یک عنصر واحد تشکیل شده است. این امکان استفاده از یک رشته به عنوان کلید, برای مثال. - -ساختار کلیدی در عنصر تنظیم شده است ``. زمینه های کلیدی در قالب همان فرهنگ لغت مشخص شده است [خصیصهها](external_dicts_dict_structure.md). مثال: - -``` xml - - - - field1 - String - - - field2 - UInt32 - - ... - -... -``` - -یا - -``` sql -CREATE DICTIONARY ( - field1 String, - field2 String - ... -) -PRIMARY KEY field1, field2 -... -``` - -برای پرس و جو به `dictGet*` تابع, یک تاپل به عنوان کلید به تصویب رسید. مثال: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. - -## خصیصهها {#ext_dict_structure-attributes} - -مثال پیکربندی: - -``` xml - - ... - - Name - ClickHouseDataType - - rand64() - true - true - true - - -``` - -یا - -``` sql -CREATE DICTIONARY somename ( - Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID -) -``` - -حوزههای پیکربندی: - -| برچسب | توصیف | مورد نیاز | -|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------| -| `name` | نام ستون. | بله | -| `type` | نوع داده کلیک.
تاتر تلاش می کند به بازیگران ارزش از فرهنگ لغت به نوع داده مشخص شده است. مثلا, برای خروجی زیر, زمینه ممکن است `TEXT`, `VARCHAR` یا `BLOB` در جدول منبع خروجی زیر, اما می تواند به عنوان ارسال `String` در فاحشه خانه.
[Nullable](../../../sql_reference/data_types/nullable.md) پشتیبانی نمی شود. | بله | -| `null_value` | مقدار پیش فرض برای یک عنصر غیر موجود.
در مثال این یک رشته خالی است. شما نمی توانید استفاده کنید `NULL` در این زمینه. | بله | -| `expression` | [عبارت](../../syntax.md#syntax-expressions) که فاحشه خانه اجرا در ارزش.
بیان می تواند یک نام ستون در پایگاه داده از راه دور گذاشتن. بدین ترتیب, شما می توانید برای ایجاد یک نام مستعار برای ستون از راه دور استفاده.

مقدار پیش فرض: بدون بیان. | نه | -| `hierarchical` | اگر `true`, ویژگی شامل ارزش یک کلید پدر و مادر برای کلید فعلی. ببینید [لغتنامهها سلسله مراتبی](external_dicts_dict_hierarchical.md).

مقدار پیشفرض: `false`. | نه | -| `injective` | پرچمی که نشان میدهد چه `id -> attribute` تصویر [تزریق](https://en.wikipedia.org/wiki/Injective_function).
اگر `true`, کلیک خانه به طور خودکار می تواند پس از محل `GROUP BY` بند درخواست به لغت نامه با تزریق. معمولا به طور قابل توجهی میزان چنین درخواست را کاهش می دهد.

مقدار پیشفرض: `false`. | نه | -| `is_object_id` | پرچمی که نشان میدهد پرسوجو برای سند مانگودیبی اجرا شده است `ObjectID`.

مقدار پیشفرض: `false`. | نه | - -## همچنین نگاه کنید به {#see-also} - -- [توابع برای کار با لغت نامه های خارجی](../../../sql_reference/functions/ext_dict_functions.md). - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/fa/sql_reference/dictionaries/external_dictionaries/index.md b/docs/fa/sql_reference/dictionaries/external_dictionaries/index.md deleted file mode 100644 index b5c506f5d93..00000000000 --- a/docs/fa/sql_reference/dictionaries/external_dictionaries/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: External Dictionaries -toc_priority: 37 ---- - - diff --git a/docs/fa/sql_reference/dictionaries/index.md b/docs/fa/sql_reference/dictionaries/index.md deleted file mode 100644 index 004dfa7718a..00000000000 --- a/docs/fa/sql_reference/dictionaries/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Dictionaries -toc_priority: 35 -toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" ---- - -# واژهنامهها {#dictionaries} - -فرهنگ لغت نقشه برداری است (`key -> attributes`) که مناسب برای انواع مختلفی از لیست مرجع است. - -تاتر پشتیبانی از توابع خاص برای کار با لغت نامه است که می تواند در نمایش داده شد استفاده می شود. این ساده تر و موثر تر به استفاده از لغت نامه ها با توابع از یک است `JOIN` با جداول مرجع. - -[NULL](../syntax.md#null) ارزش ها را نمی توان در یک فرهنگ لغت ذخیره کرد. - -پشتیبانی از کلیک: - -- [ساخته شده در لغت نامه](internal_dicts.md#internal_dicts) با یک خاص [مجموعه ای از توابع](../../sql_reference/functions/ym_dict_functions.md). -- [افزونه لغت نامه (خارجی) ](external_dictionaries/external_dicts.md) با یک [خالص توابع](../../sql_reference/functions/ext_dict_functions.md). - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/fa/sql_reference/dictionaries/internal_dicts.md b/docs/fa/sql_reference/dictionaries/internal_dicts.md deleted file mode 100644 index 1b297c22a5a..00000000000 --- a/docs/fa/sql_reference/dictionaries/internal_dicts.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u0648\u0627\u0698\u0647\u0646\u0627\u0645\u0647\u0647\u0627 \u062F\u0627\ - \u062E\u0644\u06CC" ---- - -# واژهنامهها داخلی {#internal_dicts} - -ClickHouse شامل ساخته شده است در ویژگی برای کار با یک geobase. - -این اجازه می دهد تا شما را به: - -- استفاده از شناسه یک منطقه به نام خود را در زبان مورد نظر. -- استفاده از یک منطقه شناسه برای دریافت شناسه شهر منطقه فدرال منطقه کشور یا قاره. -- بررسی کنید که یک منطقه بخشی از یک منطقه دیگر است. -- دریافت زنجیره ای از مناطق پدر و مادر. - -تمام توابع پشتیبانی “translocality,” توانایی به طور همزمان استفاده از دیدگاه های مختلف در مالکیت منطقه. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “Functions for working with Yandex.Metrica dictionaries”. - -واژهنامهها داخلی در بسته به طور پیش فرض غیر فعال. -برای فعال کردن پارامترها `path_to_regions_hierarchy_file` و `path_to_regions_names_files` در فایل پیکربندی سرور. - -پایگاه داده از فایل های متنی لود می شود. - -محل `regions_hierarchy*.txt` فایل ها به `path_to_regions_hierarchy_file` فهرست راهنما. این پارامتر پیکربندی باید مسیر را به `regions_hierarchy.txt` فایل (سلسله مراتب منطقه ای پیش فرض) و فایل های دیگر (`regions_hierarchy_ua.txt`) باید در همان دایرکتوری واقع شده است. - -قرار دادن `regions_names_*.txt` فایل ها در `path_to_regions_names_files` فهرست راهنما. - -شما همچنین می توانید این فایل ها خود را ایجاد کنید. فرمت فایل به شرح زیر است: - -`regions_hierarchy*.txt`: ستون (بدون هدر): - -- شناسه منطقه (`UInt32`) -- شناسه منطقه والد (`UInt32`) -- نوع منطقه (`UInt8`): 1 - قاره, 3 - کشور, 4 - منطقه فدرال, 5 - منطقه, 6-شهرستان; انواع دیگر ارزش ندارد -- جمعیت (`UInt32`) — optional column - -`regions_names_*.txt`: ستون (بدون هدر): - -- شناسه منطقه (`UInt32`) -- نام منطقه (`String`) — Can't contain tabs or line feeds, even escaped ones. - -مجموعه تخت برای ذخیره سازی در رم استفاده می شود. به همین دلیل شناسه نباید بیش از یک میلیون. - -واژهنامهها را می توان بدون راه اندازی مجدد سرور به روز شد. با این حال, مجموعه ای از لغت نامه های موجود به روز نمی. -برای به روز رسانی بار اصلاح فایل بررسی می شود. اگر یک فایل تغییر کرده است, فرهنگ لغت به روز شده است. -فاصله برای بررسی تغییرات در پیکربندی `builtin_dictionaries_reload_interval` پارامتر. -به روز رسانی فرهنگ لغت (به غیر از بارگذاری در اولین استفاده) نمایش داده شد را مسدود کند. در طول به روز رسانی, نمایش داده شد با استفاده از نسخه های قدیمی از لغت نامه. اگر یک خطا در طول به روز رسانی رخ می دهد, خطا به ورود به سیستم سرور نوشته شده, و نمایش داده شد ادامه استفاده از نسخه های قدیمی از لغت نامه. - -ما توصیه می کنیم دوره به روز رسانی لغت نامه با پایگاه داده. در طول به روز رسانی, تولید فایل های جدید و ارسال به یک مکان جداگانه. وقتی همه چیز اماده است فایل های مورد استفاده توسط سرور را تغییر دهید. - -همچنین توابع برای کار با شناسه های سیستم عامل و یاندکس وجود دارد.موتورهای جستجو متریکا, اما نباید استفاده شود. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/fa/sql_reference/functions/arithmetic_functions.md b/docs/fa/sql_reference/functions/arithmetic_functions.md deleted file mode 100644 index 3d5af8b3536..00000000000 --- a/docs/fa/sql_reference/functions/arithmetic_functions.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 35 -toc_title: "\u062D\u0633\u0627\u0628" ---- - -# توابع ریاضی {#arithmetic-functions} - -برای تمام توابع ریاضی, نوع نتیجه به عنوان کوچکترین نوع شماره که در نتیجه متناسب با محاسبه, اگر چنین نوع وجود دارد. حداقل به طور همزمان بر اساس تعداد بیت ها امضا شده است یا شناور است. اگر بیت به اندازه کافی وجود ندارد, بالاترین نوع بیت گرفته شده است. - -مثال: - -``` sql -SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) -``` - -``` text -┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ -│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ -└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ -``` - -حساب توابع کار برای هر جفت از انواع از uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32 یا float64. - -سرریز به همان شیوه که در ج تولید++. - -## به علاوه (یک, ب), + اپراتور ب {#plusa-b-a-b-operator} - -محاسبه مجموع اعداد. -شما همچنین می توانید اعداد صحیح را با یک تاریخ یا تاریخ و زمان اضافه کنید. در مورد یک تاریخ, اضافه کردن یک عدد صحیح به معنی اضافه کردن تعداد مربوط به روز. برای تاریخ با زمان, به این معنی اضافه کردن شماره مربوطه را از ثانیه. - -## منفی (یک, ب), اپراتور الف ب {#minusa-b-a-b-operator} - -محاسبه تفاوت. نتیجه همیشه امضا شده است. - -You can also calculate integer numbers from a date or date with time. The idea is the same – see above for ‘plus’. - -## ضرب (ب) اپراتور \* ب {#multiplya-b-a-b-operator} - -محاسبه محصول از اعداد. - -## تقسیم کردن (یک, ب), یک / اپراتور ب {#dividea-b-a-b-operator} - -محاسبه خارج قسمت از اعداد. نوع نتیجه همیشه یک نوع شناور است. -این تقسیم عدد صحیح نیست. برای تقسیم عدد صحیح, استفاده از ‘intDiv’ تابع. -هنگامی که تقسیم بر صفر می کنید ‘inf’, ‘-inf’ یا ‘nan’. - -## اینترنت) {#intdiva-b} - -محاسبه خارج قسمت از اعداد. تقسیم به اعداد صحیح, گرد کردن پایین (با ارزش مطلق). -یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. - -## intDivOrZero(a, b) {#intdivorzeroa-b} - -متفاوت از ‘intDiv’ در این بازده صفر در هنگام تقسیم صفر و یا زمانی که تقسیم یک عدد منفی حداقل منهای یک. - -## مودولو (و, ب), یک % اپراتور ب {#moduloa-b-a-b-operator} - -محاسبه باقی مانده پس از تقسیم. -اگر استدلال اعداد ممیز شناور هستند قبل از تبدیل به اعداد صحیح با حذف بخش اعشاری هستند. -باقی مانده است به همان معنا که در ج گرفته++. تقسیم کوتاه برای اعداد منفی استفاده می شود. -یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. - -## moduloOrZero(a, b) {#moduloorzeroa-b} - -متفاوت از ‘modulo’ در که باز می گردد صفر زمانی که مقسوم علیه صفر است. - -## نفی (),- اپراتور {#negatea-a-operator} - -محاسبه یک عدد با علامت معکوس. نتیجه همیشه امضا شده است. - -## شکم(یک) {#arithm_func-abs} - -محاسبه ارزش مطلق تعداد (). به این معنا که, اگر یک \< 0, باز می گردد یک. برای انواع عدد صحیح امضا, این برمی گرداند یک عدد بدون علامت. - -## گسیدی(یک, ب) {#gcda-b} - -بازگرداندن بزرگترین مقسوم علیه مشترک از اعداد. -یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. - -## اندازه) {#lcma-b} - -بازگرداندن چند حداقل مشترک از اعداد. -یک استثنا در هنگام تقسیم بر صفر یا زمانی که تقسیم یک عدد منفی حداقل توسط منهای یک پرتاب می شود. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/fa/sql_reference/functions/array_functions.md b/docs/fa/sql_reference/functions/array_functions.md deleted file mode 100644 index 76064d612a8..00000000000 --- a/docs/fa/sql_reference/functions/array_functions.md +++ /dev/null @@ -1,1057 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 46 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0627\u0631\u0631\u06CC\u0633" ---- - -# توابع برای کار با ارریس {#functions-for-working-with-arrays} - -## خالی {#function-empty} - -بازده 1 برای یک مجموعه خالی, یا 0 برای یک مجموعه غیر خالی. -نتیجه این نوع uint8. -این تابع نیز برای رشته کار می کند. - -## notEmpty {#function-notempty} - -بازده 0 برای یک مجموعه خالی, یا 1 برای یک مجموعه غیر خالی. -نتیجه این نوع uint8. -این تابع نیز برای رشته کار می کند. - -## طول {#array_functions-length} - -بازگرداندن تعداد اقلام در مجموعه. -نتیجه این نوع uint64. -این تابع نیز برای رشته کار می کند. - -## emptyArrayUInt8, emptyArrayUInt16, emptyArrayUInt32, emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} - -## emptyArrayInt8, emptyArrayInt16, emptyArrayInt32, emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} - -## emptyArrayFloat32, emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} - -## emptyArrayDate, emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} - -## تخت خواب {#emptyarraystring} - -قبول صفر استدلال و مجموعه ای خالی از نوع مناسب را برمی گرداند. - -## خالی {#emptyarraytosingle} - -یک مجموعه خالی را می پذیرد و یک مجموعه یک عنصر را که برابر با مقدار پیش فرض است باز می گرداند. - -## محدوده( پایان), دامنه (شروع, پایان \[, گام\]) {#rangeend-rangestart-end-step} - -بازگرداندن مجموعه ای از اعداد از ابتدا تا انتها-1 به گام. -اگر استدلال `start` مشخص نشده است, به طور پیش فرض به 0. -اگر استدلال `step` مشخص نشده است, به طور پیش فرض به 1. -این رفتار تقریبا مانند پیتون `range`. اما تفاوت این است که همه نوع استدلال باید باشد `UInt` اعداد. -فقط در مورد, یک استثنا پرتاب می شود اگر ارریس با طول کل بیش از 100,000,000 عناصر در یک بلوک داده ها ایجاد. - -## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} - -ایجاد مجموعه ای از استدلال تابع. -استدلال باید ثابت باشد و انواع که کوچکترین نوع رایج. حداقل یک استدلال باید تصویب شود, چرا که در غیر این صورت مشخص نیست که چه نوع از مجموعه ای برای ایجاد. به این معنا که شما نمی توانید از این تابع برای ایجاد یک مجموعه خالی استفاده کنید (برای انجام این کار از ‘emptyArray\*’ تابع در بالا توضیح داده شد). -بازگشت یک ‘Array(T)’ نوع نتیجه, جایی که ‘T’ کوچکترین نوع رایج از استدلال گذشت. - -## موافقم {#arrayconcat} - -ترکیبی از ارریس به عنوان استدلال گذشت. - -``` sql -arrayConcat(arrays) -``` - -**پارامترها** - -- `arrays` – Arbitrary number of arguments of [& حذف](../../sql_reference/data_types/array.md) نوع. - **مثال** - - - -``` sql -SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,3,4,5,6] │ -└───────────────┘ -``` - -## هشدار داده می شود\] {#arrayelementarr-n-operator-arrn} - -عنصر را با شاخص دریافت کنید `n` از مجموعه `arr`. `n` باید هر نوع عدد صحیح باشد. -شاخص ها در مجموعه ای از یک شروع می شوند. -شاخص های منفی پشتیبانی می شوند. در این مورد آن را انتخاب می کند که عنصر مربوطه شماره از پایان. به عنوان مثال, `arr[-1]` اخرین وسیله ست - -اگر شاخص می افتد در خارج از مرزهای مجموعه, این گرداند برخی از مقدار پیش فرض (0 برای اعداد, یک رشته خالی برای رشته, و غیره.), به جز برای مورد با یک مجموعه غیر ثابت و یک شاخص ثابت 0 (در این مورد وجود خواهد داشت یک خطا `Array indices are 1-based`). - -## است (ورود, علم) {#hasarr-elem} - -بررسی اینکه ‘arr’ اری ‘elem’ عنصر. -بازده 0 اگر عنصر در مجموعه نیست, یا 1 اگر. - -`NULL` به عنوان یک ارزش پردازش شده است. - -``` sql -SELECT has([1, 2, NULL], NULL) -``` - -``` text -┌─has([1, 2, NULL], NULL)─┐ -│ 1 │ -└─────────────────────────┘ -``` - -## حصال {#hasall} - -بررسی اینکه یک مجموعه زیر مجموعه دیگری باشد. - -``` sql -hasAll(set, subset) -``` - -**پارامترها** - -- `set` – Array of any type with a set of elements. -- `subset` – Array of any type with elements that should be tested to be a subset of `set`. - -**مقادیر بازگشتی** - -- `1` اگر `set` شامل تمام عناصر از `subset`. -- `0` وگرنه - -**خواص عجیب و غریب** - -- مجموعه خالی زیر مجموعه ای از هر است. -- `Null` پردازش به عنوان یک ارزش. -- منظور از ارزش ها در هر دو ارریس مهم نیست. - -**مثالها** - -`SELECT hasAll([], [])` بازده 1. - -`SELECT hasAll([1, Null], [Null])` بازده 1. - -`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` بازده 1. - -`SELECT hasAll(['a', 'b'], ['a'])` بازده 1. - -`SELECT hasAll([1], ['a'])` بازده 0. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` بازده 0. - -## hasAny {#hasany} - -بررسی اینکه دو بند چهار راه توسط برخی از عناصر. - -``` sql -hasAny(array1, array2) -``` - -**پارامترها** - -- `array1` – Array of any type with a set of elements. -- `array2` – Array of any type with a set of elements. - -**بازگشت ارزش** - -- `1` اگر `array1` و `array2` حداقل یک عنصر مشابه داشته باشید. -- `0` وگرنه - -**خواص عجیب و غریب** - -- `Null` پردازش به عنوان یک ارزش. -- منظور از ارزش ها در هر دو ارریس مهم نیست. - -**مثالها** - -`SELECT hasAny([1], [])` بازگشت `0`. - -`SELECT hasAny([Null], [Null, 1])` بازگشت `1`. - -`SELECT hasAny([-128, 1., 512], [1])` بازگشت `1`. - -`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` بازگشت `0`. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` بازگشت `1`. - -## هشدار داده می شود) {#indexofarr-x} - -بازگرداندن شاخص از اولین ‘x’ عنصر (با شروع از 1) اگر در مجموعه ای است, یا 0 اگر نیست. - -مثال: - -``` sql -SELECT indexOf([1, 3, NULL, NULL], NULL) -``` - -``` text -┌─indexOf([1, 3, NULL, NULL], NULL)─┐ -│ 3 │ -└───────────────────────────────────┘ -``` - -عناصر را به `NULL` به عنوان مقادیر طبیعی انجام می شود. - -## هشدار داده می شود) {#countequalarr-x} - -بازده تعداد عناصر موجود در آرایه برابر با x. معادل arraycount (elem -\> elem = x arr). - -`NULL` عناصر به عنوان مقادیر جداگانه به کار گرفته. - -مثال: - -``` sql -SELECT countEqual([1, 2, NULL, NULL], NULL) -``` - -``` text -┌─countEqual([1, 2, NULL, NULL], NULL)─┐ -│ 2 │ -└──────────────────────────────────────┘ -``` - -## هشدار داده می شود) {#array_functions-arrayenumerate} - -Returns the array \[1, 2, 3, …, length (arr) \] - -این تابع به طور معمول با مجموعه ای استفاده می شود. این اجازه می دهد شمارش چیزی فقط یک بار برای هر مجموعه پس از استفاده از مجموعه پیوستن. مثال: - -``` sql -SELECT - count() AS Reaches, - countIf(num = 1) AS Hits -FROM test.hits -ARRAY JOIN - GoalsReached, - arrayEnumerate(GoalsReached) AS num -WHERE CounterID = 160656 -LIMIT 10 -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -در این مثال, می رسد تعداد تبدیل است (رشته دریافت پس از استفاده از مجموعه ملحق), و بازدید تعداد بازدید صفحات (رشته قبل از مجموعه ملحق). در این مورد خاص شما می توانید همان نتیجه را در یک راه ساده تر: - -``` sql -SELECT - sum(length(GoalsReached)) AS Reaches, - count() AS Hits -FROM test.hits -WHERE (CounterID = 160656) AND notEmpty(GoalsReached) -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -این تابع همچنین می توانید در توابع مرتبه بالاتر استفاده می شود. برای مثال می توانید از شاخص های مجموعه ای برای عناصری که با شرایط مطابقت دارند استفاده کنید. - -## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} - -بازگرداندن مجموعه ای به همان اندازه به عنوان مجموعه منبع, نشان می دهد برای هر عنصر چه موقعیت خود را در میان عناصر با همان مقدار. -به عنوان مثال: ارریینومراتونیک(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. - -این تابع در هنگام استفاده از مجموعه ای پیوستن و تجمع عناصر مجموعه ای مفید است. -مثال: - -``` sql -SELECT - Goals.ID AS GoalID, - sum(Sign) AS Reaches, - sumIf(Sign, num = 1) AS Visits -FROM test.visits -ARRAY JOIN - Goals, - arrayEnumerateUniq(Goals.ID) AS num -WHERE CounterID = 160656 -GROUP BY GoalID -ORDER BY Reaches DESC -LIMIT 10 -``` - -``` text -┌──GoalID─┬─Reaches─┬─Visits─┐ -│ 53225 │ 3214 │ 1097 │ -│ 2825062 │ 3188 │ 1097 │ -│ 56600 │ 2803 │ 488 │ -│ 1989037 │ 2401 │ 365 │ -│ 2830064 │ 2396 │ 910 │ -│ 1113562 │ 2372 │ 373 │ -│ 3270895 │ 2262 │ 812 │ -│ 1084657 │ 2262 │ 345 │ -│ 56599 │ 2260 │ 799 │ -│ 3271094 │ 2256 │ 812 │ -└─────────┴─────────┴────────┘ -``` - -در این مثال هر هدف شناسه محاسبه تعداد تبدیل (هر عنصر در اهداف تو در تو ساختار داده ها یک هدف است که رسیده بود که ما اشاره به عنوان یک تبدیل) و تعداد جلسات. بدون مجموعه ملحق, ما می خواهیم تعداد جلسات به عنوان مجموع شمارش (امضا کردن). اما در این مورد خاص ردیف شد ضرب در تو در تو در اهداف و ساختار آن در سفارش به تعداد هر جلسه یک بار بعد از این ما اعمال یک شرط به ارزش arrayenumerateuniq(اهداف است.id) تابع. - -تابع ارریینومراتونیک می تواند چندین بار از همان اندازه به عنوان استدلال استفاده کند. در این مورد, منحصر به فرد است برای تاپل از عناصر در موقعیت های مشابه در تمام ارریس در نظر گرفته. - -``` sql -SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,1,1,2,1] │ -└───────────────┘ -``` - -این در هنگام استفاده از مجموعه با یک ساختار داده های تو در تو و تجمع بیشتر در سراسر عناصر متعدد در این ساختار ملحق لازم است. - -## عقبگرد {#arraypopback} - -حذف مورد گذشته از مجموعه. - -``` sql -arrayPopBack(array) -``` - -**پارامترها** - -- `array` – Array. - -**مثال** - -``` sql -SELECT arrayPopBack([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## ساحل {#arraypopfront} - -اولین مورد را از مجموعه حذف می کند. - -``` sql -arrayPopFront(array) -``` - -**پارامترها** - -- `array` – Array. - -**مثال** - -``` sql -SELECT arrayPopFront([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [2,3] │ -└───────┘ -``` - -## عقب نشینی {#arraypushback} - -یک مورد را به انتهای مجموعه اضافه می کند. - -``` sql -arrayPushBack(array, single_value) -``` - -**پارامترها** - -- `array` – Array. -- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` نوع داده مجموعه را تایپ کنید. برای کسب اطلاعات بیشتر در مورد انواع داده ها در خانه کلیک کنید “[انواع داده ها](../../sql_reference/data_types/index.md#data_types)”. می توان `NULL`. تابع می افزاید: `NULL` عنصر به مجموعه ای, و نوع عناصر مجموعه ای تبدیل به `Nullable`. - -**مثال** - -``` sql -SELECT arrayPushBack(['a'], 'b') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## ساحلی {#arraypushfront} - -یک عنصر را به ابتدای مجموعه اضافه می کند. - -``` sql -arrayPushFront(array, single_value) -``` - -**پارامترها** - -- `array` – Array. -- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` نوع داده مجموعه را تایپ کنید. برای کسب اطلاعات بیشتر در مورد انواع داده ها در خانه کلیک کنید “[انواع داده ها](../../sql_reference/data_types/index.md#data_types)”. می تواند باشد `NULL`. این تابع می افزاید: `NULL` عنصر به مجموعه ای, و نوع عناصر مجموعه ای تبدیل به `Nullable`. - -**مثال** - -``` sql -SELECT arrayPushFront(['b'], 'a') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## نمایش سایت {#arrayresize} - -طول مجموعه را تغییر می دهد. - -``` sql -arrayResize(array, size[, extender]) -``` - -**پارامترها:** - -- `array` — Array. -- `size` — Required length of the array. - - اگر `size` کمتر از اندازه اصلی مجموعه است, مجموعه ای از سمت راست کوتاه. -- اگر `size` مجموعه بزرگتر از اندازه اولیه مجموعه است که به سمت راست گسترش می یابد `extender` مقادیر یا مقادیر پیش فرض برای نوع داده از موارد مجموعه. -- `extender` — Value for extending an array. Can be `NULL`. - -**مقدار بازگشتی:** - -مجموعه ای از طول `size`. - -**نمونه هایی از تماس** - -``` sql -SELECT arrayResize([1], 3) -``` - -``` text -┌─arrayResize([1], 3)─┐ -│ [1,0,0] │ -└─────────────────────┘ -``` - -``` sql -SELECT arrayResize([1], 3, NULL) -``` - -``` text -┌─arrayResize([1], 3, NULL)─┐ -│ [1,NULL,NULL] │ -└───────────────────────────┘ -``` - -## arraySlice {#arrayslice} - -یک تکه از مجموعه را برمی گرداند. - -``` sql -arraySlice(array, offset[, length]) -``` - -**پارامترها** - -- `array` – Array of data. -- `offset` – Indent from the edge of the array. A positive value indicates an offset on the left, and a negative value is an indent on the right. Numbering of the array items begins with 1. -- `length` - طول قطعه مورد نیاز . اگر شما یک مقدار منفی مشخص, تابع یک تکه باز می گرداند `[offset, array_length - length)`. اگر شما حذف ارزش, تابع برش می گرداند `[offset, the_end_of_array]`. - -**مثال** - -``` sql -SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res -``` - -``` text -┌─res────────┐ -│ [2,NULL,4] │ -└────────────┘ -``` - -عناصر مجموعه ای به `NULL` به عنوان مقادیر طبیعی انجام می شود. - -## arraySort(\[func,\] arr, …) {#array_functions-sort} - -عناصر را مرتب می کند `arr` صف در صعودی. اگر `func` تابع مشخص شده است, مرتب سازی سفارش توسط نتیجه تعیین `func` تابع اعمال شده به عناصر مجموعه. اگر `func` قبول استدلال های متعدد `arraySort` تابع به تصویب می رسد چند بند که استدلال `func` خواهد به مطابقت. نمونه های دقیق در پایان نشان داده شده است `arraySort` توصیف. - -نمونه ای از مقادیر صحیح مرتب سازی: - -``` sql -SELECT arraySort([1, 3, 3, 0]); -``` - -``` text -┌─arraySort([1, 3, 3, 0])─┐ -│ [0,1,3,3] │ -└─────────────────────────┘ -``` - -نمونه ای از مقادیر رشته مرتب سازی: - -``` sql -SELECT arraySort(['hello', 'world', '!']); -``` - -``` text -┌─arraySort(['hello', 'world', '!'])─┐ -│ ['!','hello','world'] │ -└────────────────────────────────────┘ -``` - -ترتیب مرتب سازی زیر را برای `NULL`, `NaN` و `Inf` مقادیر: - -``` sql -SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); -``` - -``` text -┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ -│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────────────────────────┘ -``` - -- `-Inf` مقادیر برای اولین بار در مجموعه هستند. -- `NULL` ارزشهای خبری عبارتند از: -- `NaN` مقادیر درست قبل هستند `NULL`. -- `Inf` مقادیر درست قبل هستند `NaN`. - -توجه داشته باشید که `arraySort` یک [عملکرد عالی مرتبه](higher_order_functions.md). شما می توانید یک تابع لامبدا را به عنوان اولین استدلال منتقل کنید. در این مورد مرتب سازی سفارش تعیین می شود در نتیجه از lambda تابع اعمال شده به عناصر آرایه است. - -بیایید مثال زیر را در نظر بگیریم: - -``` sql -SELECT arraySort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,2,1] │ -└─────────┘ -``` - -For each element of the source array, the lambda function returns the sorting key, that is, \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Since the `arraySort` تابع انواع کلید به ترتیب صعودی, نتیجه این است \[3, 2, 1\]. بنابراین `(x) –> -x` عملکرد لامبدا مجموعه [ترتیب نزولی](#array_functions-reverse-sort) در یک مرتب سازی. - -تابع لامبدا می تواند استدلال های متعدد را قبول کند. در این مورد, شما نیاز به تصویب `arraySort` تابع چند بند از طول یکسان است که استدلال تابع لامبدا به مطابقت. مجموعه حاصل از عناصر از اولین مجموعه ورودی تشکیل شده است. به عنوان مثال: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -در اینجا عناصر موجود در مجموعه دوم (\[2, 1\]) تعریف یک کلید مرتب سازی برای عنصر مربوطه از مجموعه منبع (\[‘hello’, ‘world’\]), به این معنا که, \[‘hello’ –\> 2, ‘world’ –\> 1\]. Since the lambda function doesn't use `x` مقادیر واقعی مجموعه منبع بر نظم در نتیجه تاثیر نمی گذارد. پس, ‘hello’ خواهد بود که عنصر دوم در نتیجه, و ‘world’ خواهد بود که برای اولین بار. - -نمونه های دیگر در زیر نشان داده شده. - -``` sql -SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -``` sql -SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -!!! note "یادداشت" - برای بهبود کارایی مرتب سازی [تبدیل شوارتز](https://en.wikipedia.org/wiki/Schwartzian_transform) استفاده شده است. - -## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} - -عناصر را مرتب می کند `arr` صف در نزولی. اگر `func` تابع مشخص شده است, `arr` بر اساس نتیجه طبقه بندی شده اند `func` عملکرد به عناصر مجموعه اعمال می شود و سپس مجموعه مرتب شده معکوس می شود. اگر `func` قبول استدلال های متعدد `arrayReverseSort` تابع به تصویب می رسد چند بند که استدلال `func` خواهد به مطابقت. نمونه های دقیق در پایان نشان داده شده است `arrayReverseSort` توصیف. - -نمونه ای از مقادیر صحیح مرتب سازی: - -``` sql -SELECT arrayReverseSort([1, 3, 3, 0]); -``` - -``` text -┌─arrayReverseSort([1, 3, 3, 0])─┐ -│ [3,3,1,0] │ -└────────────────────────────────┘ -``` - -نمونه ای از مقادیر رشته مرتب سازی: - -``` sql -SELECT arrayReverseSort(['hello', 'world', '!']); -``` - -``` text -┌─arrayReverseSort(['hello', 'world', '!'])─┐ -│ ['world','hello','!'] │ -└───────────────────────────────────────────┘ -``` - -ترتیب مرتب سازی زیر را برای `NULL`, `NaN` و `Inf` مقادیر: - -``` sql -SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; -``` - -``` text -┌─res───────────────────────────────────┐ -│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────┘ -``` - -- `Inf` مقادیر برای اولین بار در مجموعه هستند. -- `NULL` ارزشهای خبری عبارتند از: -- `NaN` مقادیر درست قبل هستند `NULL`. -- `-Inf` مقادیر درست قبل هستند `NaN`. - -توجه داشته باشید که `arrayReverseSort` یک [عملکرد عالی مرتبه](higher_order_functions.md). شما می توانید یک تابع لامبدا را به عنوان اولین استدلال منتقل کنید. مثال زیر نشان داده شده. - -``` sql -SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [1,2,3] │ -└─────────┘ -``` - -این مجموعه به روش زیر مرتب شده است: - -1. ابتدا مجموعه منبع (\[1, 2, 3\]) با توجه به نتیجه تابع لامبدا اعمال شده به عناصر مجموعه طبقه بندی شده اند. نتیجه یک مجموعه است \[3, 2, 1\]. -2. مجموعه ای است که در مرحله قبل به دست, معکوس شده است. بنابراین, نتیجه نهایی است \[1, 2, 3\]. - -تابع لامبدا می تواند استدلال های متعدد را قبول کند. در این مورد, شما نیاز به تصویب `arrayReverseSort` تابع چند بند از طول یکسان است که استدلال تابع لامبدا به مطابقت. مجموعه حاصل از عناصر از اولین مجموعه ورودی تشکیل شده است. به عنوان مثال: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -در این مثال مجموعه به روش زیر مرتب شده است: - -1. در ابتدا مجموعه منبع (\[‘hello’, ‘world’\]) با توجه به نتیجه تابع لامبدا اعمال شده به عناصر از ارریس طبقه بندی شده اند. عناصر که در مجموعه دوم به تصویب رسید (\[2, 1\]), تعریف کلید مرتب سازی برای عناصر مربوطه را از مجموعه منبع. نتیجه یک مجموعه است \[‘world’, ‘hello’\]. -2. مجموعه ای که در مرحله قبل طبقه بندی شده اند, معکوس شده است. بنابراین نتیجه نهایی این است \[‘hello’, ‘world’\]. - -نمونه های دیگر در زیر نشان داده شده. - -``` sql -SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; -``` - -``` text -┌─res─────┐ -│ [5,3,4] │ -└─────────┘ -``` - -``` sql -SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; -``` - -``` text -┌─res─────┐ -│ [4,3,5] │ -└─────────┘ -``` - -## arrayUniq(arr, …) {#arrayuniqarr} - -اگر یک استدلال به تصویب می رسد, تعداد عناصر مختلف در مجموعه شمارش. -اگر استدلال های متعدد به تصویب می رسد, شمارش تعداد تاپل های مختلف از عناصر در موقعیت های مربوطه در مجموعه های متعدد. - -اگر شما می خواهید برای دریافت یک لیست از اقلام منحصر به فرد در مجموعه, شما می توانید از ارری راهاهن استفاده(‘groupUniqArray’, arr). - -## هشدار داده می شود) {#array-functions-join} - -یک تابع خاص. بخش را ببینید [“ArrayJoin function”](array_join.md#functions_arrayjoin). - -## کلیدواژه {#arraydifference} - -محاسبه تفاوت بین عناصر مجموعه مجاور. بازگرداندن مجموعه ای که عنصر اول خواهد بود 0, دوم تفاوت بین است `a[1] - a[0]`, etc. The type of elements in the resulting array is determined by the type inference rules for subtraction (e.g. `UInt8` - `UInt8` = `Int16`). - -**نحو** - -``` sql -arrayDifference(array) -``` - -**پارامترها** - -- `array` – [& حذف](https://clickhouse.yandex/docs/en/data_types/array/). - -**مقادیر بازگشتی** - -بازگرداندن مجموعه ای از تفاوت بین عناصر مجاور. - -نوع: [اینترنت\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#uint-ranges), [Int\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#int-ranges), [شناور\*](https://clickhouse.yandex/docs/en/data_types/float/). - -**مثال** - -پرسوجو: - -``` sql -SELECT arrayDifference([1, 2, 3, 4]) -``` - -نتیجه: - -``` text -┌─arrayDifference([1, 2, 3, 4])─┐ -│ [0,1,1,1] │ -└───────────────────────────────┘ -``` - -مثال سرریز به علت نوع نتیجه اینترن64: - -پرسوجو: - -``` sql -SELECT arrayDifference([0, 10000000000000000000]) -``` - -نتیجه: - -``` text -┌─arrayDifference([0, 10000000000000000000])─┐ -│ [0,-8446744073709551616] │ -└────────────────────────────────────────────┘ -``` - -## حوزه ارریددیست {#arraydistinct} - -مجموعه ای را می گیرد و تنها شامل عناصر مجزا می شود. - -**نحو** - -``` sql -arrayDistinct(array) -``` - -**پارامترها** - -- `array` – [& حذف](https://clickhouse.yandex/docs/en/data_types/array/). - -**مقادیر بازگشتی** - -بازگرداندن مجموعه ای حاوی عناصر متمایز. - -**مثال** - -پرسوجو: - -``` sql -SELECT arrayDistinct([1, 2, 2, 3, 1]) -``` - -نتیجه: - -``` text -┌─arrayDistinct([1, 2, 2, 3, 1])─┐ -│ [1,2,3] │ -└────────────────────────────────┘ -``` - -## هشدار داده می شود) {#array_functions-arrayenumeratedense} - -بازگرداندن مجموعه ای از همان اندازه به عنوان مجموعه منبع, نشان می دهد که هر عنصر برای اولین بار در مجموعه منبع به نظر می رسد. - -مثال: - -``` sql -SELECT arrayEnumerateDense([10, 20, 10, 30]) -``` - -``` text -┌─arrayEnumerateDense([10, 20, 10, 30])─┐ -│ [1,2,1,3] │ -└───────────────────────────────────────┘ -``` - -## هشدار داده می شود) {#array-functions-arrayintersect} - -طول می کشد مجموعه ای با عناصر که در تمام مجموعه منبع در حال حاضر می گرداند. عناصر سفارش در مجموعه حاصل همان است که در مجموعه اول است. - -مثال: - -``` sql -SELECT - arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, - arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect -``` - -``` text -┌─no_intersect─┬─intersect─┐ -│ [] │ [1] │ -└──────────────┴───────────┘ -``` - -## نمایش سایت {#arrayreduce} - -یک تابع کلی برای عناصر مجموعه ای اعمال می شود و نتیجه خود را باز می گرداند. نام تابع تجمع به عنوان یک رشته در نقل قول های تک منتقل می شود `'max'`, `'sum'`. هنگام استفاده از توابع دانه پارامتری پارامتر پس از نام تابع در پرانتز نشان داده شده است `'uniqUpTo(6)'`. - -**نحو** - -``` sql -arrayReduce(agg_func, arr1, arr2, ..., arrN) -``` - -**پارامترها** - -- `agg_func` — The name of an aggregate function which should be a constant [رشته](../../sql_reference/data_types/string.md). -- `arr` — Any number of [& حذف](../../sql_reference/data_types/array.md) نوع ستون به عنوان پارامترهای تابع تجمع. - -**مقدار بازگشتی** - -**مثال** - -``` sql -SELECT arrayReduce('max', [1, 2, 3]) -``` - -``` text -┌─arrayReduce('max', [1, 2, 3])─┐ -│ 3 │ -└───────────────────────────────┘ -``` - -اگر یک تابع جمع استدلال های متعدد طول می کشد, سپس این تابع باید به مجموعه های متعدد از همان اندازه اعمال. - -``` sql -SELECT arrayReduce('maxIf', [3, 5], [1, 0]) -``` - -``` text -┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ -│ 3 │ -└──────────────────────────────────────┘ -``` - -به عنوان مثال با یک تابع جمع پارامتری: - -``` sql -SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -``` - -``` text -┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ -│ 4 │ -└─────────────────────────────────────────────────────────────┘ -``` - -## تغییرات {#arrayreduceinranges} - -یک تابع کلی برای عناصر مجموعه ای در محدوده های داده شده اعمال می شود و مجموعه ای حاوی نتیجه مربوط به هر محدوده را باز می گرداند. تابع همان نتیجه به عنوان چند بازگشت `arrayReduce(agg_func, arraySlice(arr1, index, length), ...)`. - -**نحو** - -``` sql -arrayReduceInRanges(agg_func, ranges, arr1, arr2, ..., arrN) -``` - -**پارامترها** - -- `agg_func` — The name of an aggregate function which should be a constant [رشته](../../sql_reference/data_types/string.md). -- `ranges` — The ranges to aggretate which should be an [& حذف](../../sql_reference/data_types/array.md) از [توپلس](../../sql_reference/data_types/tuple.md) که شامل شاخص و طول هر محدوده. -- `arr` — Any number of [& حذف](../../sql_reference/data_types/array.md) نوع ستون به عنوان پارامترهای تابع تجمع. - -**مقدار بازگشتی** - -**مثال** - -``` sql -SELECT arrayReduceInRanges( - 'sum', - [(1, 5), (2, 3), (3, 4), (4, 4)], - [1000000, 200000, 30000, 4000, 500, 60, 7] -) AS res -``` - -``` text -┌─res─────────────────────────┐ -│ [1234500,234000,34560,4567] │ -└─────────────────────────────┘ -``` - -## هشدار داده می شود) {#arrayreverse} - -بازگرداندن مجموعه ای از همان اندازه به عنوان مجموعه اصلی حاوی عناصر در جهت معکوس. - -مثال: - -``` sql -SELECT arrayReverse([1, 2, 3]) -``` - -``` text -┌─arrayReverse([1, 2, 3])─┐ -│ [3,2,1] │ -└─────────────────────────┘ -``` - -## معکوس) {#array-functions-reverse} - -مترادف برای [“arrayReverse”](#array_functions-arrayreverse) - -## ارریفلاتتن {#arrayflatten} - -مجموعه ای از ارریس ها را به یک مجموعه صاف تبدیل می کند. - -تابع: - -- امر به هر عمق مجموعه های تو در تو. -- طعم هایی را که در حال حاضر مسطح هستند تغییر نمی دهد. - -مجموعه مسطح شامل تمام عناصر از تمام منابع است. - -**نحو** - -``` sql -flatten(array_of_arrays) -``` - -نام مستعار: `flatten`. - -**پارامترها** - -- `array_of_arrays` — [& حذف](../../sql_reference/data_types/array.md) ارریس به عنوان مثال, `[[1,2,3], [4,5]]`. - -**مثالها** - -``` sql -SELECT flatten([[[1]], [[2], [3]]]) -``` - -``` text -┌─flatten(array(array([1]), array([2], [3])))─┐ -│ [1,2,3] │ -└─────────────────────────────────────────────┘ -``` - -## اررایکمپکت {#arraycompact} - -عناصر تکراری متوالی را از یک مجموعه حذف می کند. ترتیب مقادیر نتیجه به ترتیب در مجموعه منبع تعیین می شود. - -**نحو** - -``` sql -arrayCompact(arr) -``` - -**پارامترها** - -`arr` — The [& حذف](../../sql_reference/data_types/array.md) برای بازرسی. - -**مقدار بازگشتی** - -مجموعه ای بدون تکراری. - -نوع: `Array`. - -**مثال** - -پرسوجو: - -``` sql -SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) -``` - -نتیجه: - -``` text -┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ -│ [1,nan,nan,2,3] │ -└────────────────────────────────────────────┘ -``` - -## ارریزیپ {#arrayzip} - -Combine multiple Array type columns into one Array\[Tuple(…)\] column - -**نحو** - -``` sql -arrayZip(arr1, arr2, ..., arrN) -``` - -**پارامترها** - -`arr` — Any number of [& حذف](../../sql_reference/data_types/array.md) ستون نوع به ترکیب. - -**مقدار بازگشتی** - -The result of Array\[Tuple(…)\] type after the combination of these arrays - -**مثال** - -پرسوجو: - -``` sql -SELECT arrayZip(['a', 'b', 'c'], ['d', 'e', 'f']); -``` - -نتیجه: - -``` text -┌─arrayZip(['a', 'b', 'c'], ['d', 'e', 'f'])─┐ -│ [('a','d'),('b','e'),('c','f')] │ -└────────────────────────────────────────────┘ -``` - -## ارریایکو {#arrayauc} - -محاسبه حراج (منطقه تحت منحنی, که یک مفهوم در یادگیری ماشین است, مشاهده اطلاعات بیشتر: https://en.wikipedia.org/wiki/receiver\_operating\_characteristic\#area\_under\_the\_curve). - -**نحو** - -``` sql -arrayAUC(arr_scores, arr_labels) -``` - -**پارامترها** -- `arr_scores` — scores prediction model gives. -- `arr_labels` — labels of samples, usually 1 for positive sample and 0 for negtive sample. - -**مقدار بازگشتی** -را برمی گرداند ارزش حراج با نوع شناور64. - -**مثال** -پرسوجو: - -``` sql -select arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]) -``` - -نتیجه: - -``` text -┌─arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1])─┐ -│ 0.75 │ -└────────────────────────────────────────---──┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/fa/sql_reference/functions/array_join.md b/docs/fa/sql_reference/functions/array_join.md deleted file mode 100644 index 9d36eba1b89..00000000000 --- a/docs/fa/sql_reference/functions/array_join.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 61 -toc_title: "\u0627\u0631\u0631\u06CC\u062C\u06CC\u0646" ---- - -# تابع ارریجین {#functions_arrayjoin} - -این یک تابع بسیار غیر معمول است. - -توابع عادی انجام مجموعه ای از ردیف را تغییر دهید, اما فقط تغییر مقادیر در هر سطر (کوتاه). -توابع مجموع فشرده سازی مجموعه ای از ردیف (برابر یا کاهش). -این ‘arrayJoin’ تابع طول می کشد هر سطر و تولید مجموعه ای از ردیف (اشکار). - -این تابع یک مجموعه را به عنوان یک استدلال می گیرد و ردیف منبع را به چندین ردیف برای تعدادی از عناصر در مجموعه منتشر می کند. -تمام مقادیر ستون ها به سادگی کپی می شوند به جز مقادیر در ستون ای که این تابع اعمال می شود. - -پرس و جو می توانید چند استفاده کنید `arrayJoin` توابع. در این مورد تحول انجام شده است چندین بار. - -توجه داشته باشید که ترتیب پیوستن به نحو در پرس و جو را انتخاب کنید, فراهم می کند که امکانات گسترده تر. - -مثال: - -``` sql -SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src -``` - -``` text -┌─dst─┬─\'Hello\'─┬─src─────┐ -│ 1 │ Hello │ [1,2,3] │ -│ 2 │ Hello │ [1,2,3] │ -│ 3 │ Hello │ [1,2,3] │ -└─────┴───────────┴─────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/array_join/) diff --git a/docs/fa/sql_reference/functions/bit_functions.md b/docs/fa/sql_reference/functions/bit_functions.md deleted file mode 100644 index 5399bb3857a..00000000000 --- a/docs/fa/sql_reference/functions/bit_functions.md +++ /dev/null @@ -1,255 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 48 -toc_title: "\u0628\u06CC\u062A" ---- - -# توابع بیت {#bit-functions} - -بیت توابع کار برای هر جفت از انواع از uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32 یا float64. - -نوع نتیجه یک عدد صحیح با بیت به حداکثر بیت از استدلال خود را برابر است. اگر حداقل یکی از استدلال امضا شده است, نتیجه یک شماره امضا شده است. اگر استدلال یک عدد ممیز شناور است, این است که به درون بازیگران64. - -## بیت و ب) {#bitanda-b} - -## bitOr(a, b) {#bitora-b} - -## هشدار داده می شود) {#bitxora-b} - -## bitNot(یک) {#bitnota} - -## اطلاعات دقیق) {#bitshiftlefta-b} - -## باز کردن پنجره روی برنامههای دیگر) {#bitshiftrighta-b} - -## هشدار داده می شود) {#bitrotatelefta-b} - -## حفاظت از بیت) {#bitrotaterighta-b} - -## بیتترین {#bittest} - -طول می کشد هر عدد صحیح و تبدیل به [شکل دودویی](https://en.wikipedia.org/wiki/Binary_number), بازگرداندن ارزش کمی در موقعیت مشخص. شمارش معکوس از 0 از سمت راست به سمت چپ شروع می شود. - -**نحو** - -``` sql -SELECT bitTest(number, index) -``` - -**پارامترها** - -- `number` – integer number. -- `index` – position of bit. - -**مقادیر بازگشتی** - -بازگرداندن مقدار کمی در موقعیت مشخص. - -نوع: `UInt8`. - -**مثال** - -مثلا, تعداد 43 در پایه-2 (دودویی) سیستم اعداد است 101011. - -پرسوجو: - -``` sql -SELECT bitTest(43, 1) -``` - -نتیجه: - -``` text -┌─bitTest(43, 1)─┐ -│ 1 │ -└────────────────┘ -``` - -مثال دیگر: - -پرسوجو: - -``` sql -SELECT bitTest(43, 2) -``` - -نتیجه: - -``` text -┌─bitTest(43, 2)─┐ -│ 0 │ -└────────────────┘ -``` - -## تماس {#bittestall} - -بازده نتیجه [ساخت منطقی](https://en.wikipedia.org/wiki/Logical_conjunction) (و اپراتور) از تمام بیت در موقعیت های داده شده. شمارش معکوس از 0 از سمت راست به سمت چپ شروع می شود. - -ساخت و ساز برای عملیات بیتی: - -0 AND 0 = 0 - -0 AND 1 = 0 - -1 AND 0 = 0 - -1 AND 1 = 1 - -**نحو** - -``` sql -SELECT bitTestAll(number, index1, index2, index3, index4, ...) -``` - -**پارامترها** - -- `number` – integer number. -- `index1`, `index2`, `index3`, `index4` – positions of bit. For example, for set of positions (`index1`, `index2`, `index3`, `index4`) درست است اگر و تنها اگر تمام موقعیت خود را درست هستند (`index1` ⋀ `index2`, ⋀ `index3` ⋀ `index4`). - -**مقادیر بازگشتی** - -بازده نتیجه منطقی conjuction. - -نوع: `UInt8`. - -**مثال** - -مثلا, تعداد 43 در پایه-2 (دودویی) سیستم اعداد است 101011. - -پرسوجو: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5) -``` - -نتیجه: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5)─┐ -│ 1 │ -└────────────────────────────┘ -``` - -مثال دیگر: - -پرسوجو: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5, 2) -``` - -نتیجه: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ -│ 0 │ -└───────────────────────────────┘ -``` - -## بیتستانی {#bittestany} - -بازده نتیجه [حکم منطقی](https://en.wikipedia.org/wiki/Logical_disjunction) (یا اپراتور) از تمام بیت در موقعیت های داده شده. شمارش معکوس از 0 از سمت راست به سمت چپ شروع می شود. - -دستور برای عملیات بیتی: - -0 OR 0 = 0 - -0 OR 1 = 1 - -1 OR 0 = 1 - -1 OR 1 = 1 - -**نحو** - -``` sql -SELECT bitTestAny(number, index1, index2, index3, index4, ...) -``` - -**پارامترها** - -- `number` – integer number. -- `index1`, `index2`, `index3`, `index4` – positions of bit. - -**مقادیر بازگشتی** - -بازده نتیجه ساخت و ساز منطقی. - -نوع: `UInt8`. - -**مثال** - -مثلا, تعداد 43 در پایه-2 (دودویی) سیستم اعداد است 101011. - -پرسوجو: - -``` sql -SELECT bitTestAny(43, 0, 2) -``` - -نتیجه: - -``` text -┌─bitTestAny(43, 0, 2)─┐ -│ 1 │ -└──────────────────────┘ -``` - -مثال دیگر: - -پرسوجو: - -``` sql -SELECT bitTestAny(43, 4, 2) -``` - -نتیجه: - -``` text -┌─bitTestAny(43, 4, 2)─┐ -│ 0 │ -└──────────────────────┘ -``` - -## شمارش {#bitcount} - -محاسبه تعداد بیت را به یکی در نمایندگی دودویی از یک عدد است. - -**نحو** - -``` sql -bitCount(x) -``` - -**پارامترها** - -- `x` — [عدد صحیح](../../sql_reference/data_types/int_uint.md) یا [شناور نقطه](../../sql_reference/data_types/float.md) شماره. تابع با استفاده از نمایندگی ارزش در حافظه. این اجازه می دهد تا حمایت از اعداد ممیز شناور. - -**مقدار بازگشتی** - -- تعداد بیت را به یکی در تعداد ورودی. - -تابع مقدار ورودی را به یک نوع بزرگتر تبدیل نمی کند ([ثبت نام پسوند](https://en.wikipedia.org/wiki/Sign_extension)). بنابراین, مثلا, `bitCount(toUInt8(-1)) = 8`. - -نوع: `UInt8`. - -**مثال** - -نگاهی به عنوان مثال تعداد 333. نمایندگی دودویی: 00000001001101. - -پرسوجو: - -``` sql -SELECT bitCount(333) -``` - -نتیجه: - -``` text -┌─bitCount(333)─┐ -│ 5 │ -└───────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/fa/sql_reference/functions/bitmap_functions.md b/docs/fa/sql_reference/functions/bitmap_functions.md deleted file mode 100644 index e561baef9c0..00000000000 --- a/docs/fa/sql_reference/functions/bitmap_functions.md +++ /dev/null @@ -1,496 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 49 -toc_title: "\u0646\u06AF\u0627\u0634\u062A \u0628\u06CC\u062A" ---- - -# توابع نگاشت بیت {#bitmap-functions} - -توابع بیت مپ برای دو بیت مپ محاسبه ارزش شی کار, این است که بازگشت بیت مپ جدید و یا کارتیت در حالی که با استفاده از محاسبه فرمول, مانند و, یا, صخره نوردی, و نه, و غیره. - -2 نوع از روش های ساخت و ساز برای شی بیت مپ وجود دارد. یکی این است که توسط گروه بیت مپ تابع تجمع با دولت ساخته شود, دیگر این است که توسط شی مجموعه ای ساخته شود. این نیز برای تبدیل شی بیت مپ به مجموعه شی. - -نقشه شهری روارینگ به یک ساختار داده در حالی که ذخیره سازی واقعی از اجسام بیت مپ پیچیده شده است. هنگامی که کارتیت کمتر از یا برابر است 32, با استفاده از عینیت مجموعه. هنگامی که کارتیت بیشتر از است 32, با استفاده از شی نقشه شهری روارینگ. به همین دلیل است ذخیره سازی مجموعه کارتیت کم سریع تر است. - -برای کسب اطلاعات بیشتر در مورد نقشه شهری روارینگ: [پرورش دهنده](https://github.com/RoaringBitmap/CRoaring). - -## طراحی بیت مپ {#bitmap_functions-bitmapbuild} - -ساخت یک بیت مپ از مجموعه عدد صحیح بدون علامت. - -``` sql -bitmapBuild(array) -``` - -**پارامترها** - -- `array` – unsigned integer array. - -**مثال** - -``` sql -SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) -``` - -``` text -┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ -│  │ AggregateFunction(groupBitmap, UInt8) │ -└─────┴──────────────────────────────────────────────┘ -``` - -## بیت مپوری {#bitmaptoarray} - -تبدیل بیت مپ به مجموعه عدد صحیح. - -``` sql -bitmapToArray(bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## اطلاعات دقیق {#bitmap-functions-bitmapsubsetinrange} - -زیرمجموعه بازگشت در محدوده مشخص شده (دامنه را شامل نمی شود). - -``` sql -bitmapSubsetInRange(bitmap, range_start, range_end) -``` - -**پارامترها** - -- `bitmap` – [شی نگاشت بیت](#bitmap_functions-bitmapbuild). -- `range_start` – range start point. Type: [UInt32](../../sql_reference/data_types/int_uint.md). -- `range_end` – range end point(excluded). Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -``` text -┌─res───────────────┐ -│ [30,31,32,33,100] │ -└───────────────────┘ -``` - -## نمایش سایت {#bitmapsubsetlimit} - -ایجاد یک زیر مجموعه از بیت مپ با عناصر نفر گرفته شده بین `range_start` و `cardinality_limit`. - -**نحو** - -``` sql -bitmapSubsetLimit(bitmap, range_start, cardinality_limit) -``` - -**پارامترها** - -- `bitmap` – [شی نگاشت بیت](#bitmap_functions-bitmapbuild). -- `range_start` – The subset starting point. Type: [UInt32](../../sql_reference/data_types/int_uint.md). -- `cardinality_limit` – The subset cardinality upper limit. Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**مقدار بازگشتی** - -زیرمجموعه. - -نوع: `Bitmap object`. - -**مثال** - -پرسوجو: - -``` sql -SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -نتیجه: - -``` text -┌─res───────────────────────┐ -│ [30,31,32,33,100,200,500] │ -└───────────────────────────┘ -``` - -## اطلاعات دقیق {#bitmap_functions-bitmapcontains} - -بررسی اینکه نگاشت بیت شامل یک عنصر است. - -``` sql -bitmapContains(haystack, needle) -``` - -**پارامترها** - -- `haystack` – [شی نگاشت بیت](#bitmap_functions-bitmapbuild), جایی که تابع جستجو. -- `needle` – Value that the function searches. Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- 0 — If `haystack` شامل نمی شود `needle`. -- 1 — If `haystack` شامل `needle`. - -نوع: `UInt8`. - -**مثال** - -``` sql -SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## بیتمافاسانی {#bitmaphasany} - -بررسی اینکه دو بیت مپ دارند تقاطع توسط برخی از عناصر. - -``` sql -bitmapHasAny(bitmap1, bitmap2) -``` - -اگر شما اطمینان حاصل کنید که `bitmap2` حاوی شدت یک عنصر, در نظر با استفاده از [اطلاعات دقیق](#bitmap_functions-bitmapcontains) تابع. این کار موثر تر است. - -**پارامترها** - -- `bitmap*` – bitmap object. - -**بازگشت ارزش** - -- `1` اگر `bitmap1` و `bitmap2` حداقل یک عنصر مشابه داشته باشید. -- `0` وگرنه - -**مثال** - -``` sql -SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## بیتمافاسال {#bitmaphasall} - -مشابه به `hasAll(array, array)` بازده 1 اگر بیت مپ اول شامل تمام عناصر از یک ثانیه, 0 در غیر این صورت. -اگر استدلال دوم بیت مپ خالی است و سپس باز می گردد 1. - -``` sql -bitmapHasAll(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 0 │ -└─────┘ -``` - -## هشدار داده می شود {#bitmapcardinality} - -Retrun بیت مپ cardinality از نوع UInt64. - -``` sql -bitmapCardinality(bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## بیت مپمن {#bitmapmin} - -Retrun کوچکترین مقدار از نوع UInt64 در مجموعه UINT32\_MAX اگر این مجموعه خالی است. - - bitmapMin(bitmap) - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 1 │ - └─────┘ - -## جرم اتمی {#bitmapmax} - -جابجایی بزرگترین ارزش نوع اوینت64 در مجموعه, 0 اگر مجموعه ای خالی است. - - bitmapMax(bitmap) - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 5 │ - └─────┘ - -## ترجمههای بیت مپ {#bitmaptransform} - -تبدیل مجموعه ای از ارزش ها در بیت مپ به مجموعه ای دیگر از ارزش, نتیجه یک بیت مپ جدید است. - - bitmapTransform(bitmap, from_array, to_array) - -**پارامترها** - -- `bitmap` – bitmap object. -- `from_array` – UInt32 array. For idx in range \[0, from\_array.size()), if bitmap contains from\_array\[idx\], then replace it with to\_array\[idx\]. Note that the result depends on array ordering if there are common elements between from\_array and to\_array. -- `to_array` – UInt32 array, its size shall be the same to from\_array. - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res -``` - - ┌─res───────────────────┐ - │ [1,3,4,6,7,8,9,10,20] │ - └───────────────────────┘ - -## بیت مپند {#bitmapand} - -دو بیت مپ و محاسبه, نتیجه یک بیت مپ جدید است. - -``` sql -bitmapAnd(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─┐ -│ [3] │ -└─────┘ -``` - -## نگاشت بیت {#bitmapor} - -دو بیت مپ و یا محاسبه, نتیجه یک بیت مپ جدید است. - -``` sql -bitmapOr(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## بیت مپکسور {#bitmapxor} - -دو محاسبه گز بیت مپ, نتیجه یک بیت مپ جدید است. - -``` sql -bitmapXor(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,4,5] │ -└───────────┘ -``` - -## بیت مپندو {#bitmapandnot} - -دو محاسبه بیت مپ اندنوت, نتیجه یک بیت مپ جدید است. - -``` sql -bitmapAndnot(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## اطلاعات دقیق {#bitmapandcardinality} - -دو بیت مپ و محاسبه بازگشت cardinality از نوع uint64. - -``` sql -bitmapAndCardinality(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## کمبود سیگار {#bitmaporcardinality} - -دو بیت مپ و یا محاسبه بازگشت cardinality از نوع uint64. - -``` sql -bitmapOrCardinality(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## هشدار داده می شود {#bitmapxorcardinality} - -دو بیت مپ xor محاسبه بازگشت cardinality از نوع uint64. - -``` sql -bitmapXorCardinality(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 4 │ -└─────┘ -``` - -## اطلاعات دقیق {#bitmapandnotcardinality} - -دو بیت مپ andnot محاسبه بازگشت cardinality از نوع uint64. - -``` sql -bitmapAndnotCardinality(bitmap,bitmap) -``` - -**پارامترها** - -- `bitmap` – bitmap object. - -**مثال** - -``` sql -SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 2 │ -└─────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/fa/sql_reference/functions/comparison_functions.md b/docs/fa/sql_reference/functions/comparison_functions.md deleted file mode 100644 index aee5cfe664c..00000000000 --- a/docs/fa/sql_reference/functions/comparison_functions.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 36 -toc_title: "\u0645\u0642\u0627\u06CC\u0633\u0647" ---- - -# توابع مقایسه {#comparison-functions} - -توابع مقایسه همیشه بازگشت 0 یا 1 (اوینت8). - -انواع زیر را می توان مقایسه کرد: - -- اعداد -- رشته ها و رشته های ثابت -- تاریخ -- تاریخ با زمان - -در هر گروه, اما نه بین گروه های مختلف. - -مثلا, شما می توانید یک تاریخ را با یک رشته مقایسه نیست. شما مجبور به استفاده از یک تابع برای تبدیل رشته به یک تاریخ, و یا بالعکس. - -رشته ها با بایت مقایسه. یک رشته کوتاه تر کوچکتر از همه رشته هایی است که با این کار شروع می شوند و شامل حداقل یک شخصیت دیگر می شوند. - -## برابر, = ب و = = ب اپراتور {#function-equals} - -## کار در حالت اضطراری, یک ! اپراتور = ب و \< \> ب {#function-notequals} - -## کمتر, \< اپراتور {#function-less} - -## بیشتر, \> اپراتور {#function-greater} - -## اطلاعات دقیق {#function-lessorequals} - -## در حال بارگذاری {#function-greaterorequals} - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/fa/sql_reference/functions/conditional_functions.md b/docs/fa/sql_reference/functions/conditional_functions.md deleted file mode 100644 index a57820687dd..00000000000 --- a/docs/fa/sql_reference/functions/conditional_functions.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: "\u0634\u0631\u0637\u06CC " ---- - -# توابع شرطی {#conditional-functions} - -## اگر {#if} - -کنترل انشعاب مشروط. بر خلاف اکثر سیستم های تاتر همیشه هر دو عبارت را ارزیابی کنید `then` و `else`. - -**نحو** - -``` sql -SELECT if(cond, then, else) -``` - -اگر شرایط `cond` ارزیابی به یک مقدار غیر صفر, می گرداند در نتیجه بیان `then` و نتیجه بیان `else`, اگر در حال حاضر, قلم است. اگر `cond` صفر یا `NULL` سپس نتیجه `then` بیان نادیده گرفته شده است و در نتیجه `else` عبارت, در صورت حاضر, بازگشته است. - -**پارامترها** - -- `cond` – The condition for evaluation that can be zero or not. The type is UInt8, Nullable(UInt8) or NULL. -- `then` - بیان به بازگشت اگر شرایط ملاقات کرده است. -- `else` - بیان به بازگشت اگر شرایط ملاقات نکرده است. - -**مقادیر بازگشتی** - -تابع اجرا می شود `then` و `else` عبارات و نتیجه خود را بر می گرداند, بسته به اینکه شرایط `cond` به پایان رسید تا صفر یا نه. - -**مثال** - -پرسوجو: - -``` sql -SELECT if(1, plus(2, 2), plus(2, 6)) -``` - -نتیجه: - -``` text -┌─plus(2, 2)─┐ -│ 4 │ -└────────────┘ -``` - -پرسوجو: - -``` sql -SELECT if(0, plus(2, 2), plus(2, 6)) -``` - -نتیجه: - -``` text -┌─plus(2, 6)─┐ -│ 8 │ -└────────────┘ -``` - -- `then` و `else` باید کمترین نوع مشترک دارند. - -**مثال:** - -اینو بگیر `LEFT_RIGHT` جدول: - -``` sql -SELECT * -FROM LEFT_RIGHT - -┌─left─┬─right─┐ -│ ᴺᵁᴸᴸ │ 4 │ -│ 1 │ 3 │ -│ 2 │ 2 │ -│ 3 │ 1 │ -│ 4 │ ᴺᵁᴸᴸ │ -└──────┴───────┘ -``` - -پرس و جو زیر مقایسه می کند `left` و `right` مقادیر: - -``` sql -SELECT - left, - right, - if(left < right, 'left is smaller than right', 'right is greater or equal than left') AS is_smaller -FROM LEFT_RIGHT -WHERE isNotNull(left) AND isNotNull(right) - -┌─left─┬─right─┬─is_smaller──────────────────────────┐ -│ 1 │ 3 │ left is smaller than right │ -│ 2 │ 2 │ right is greater or equal than left │ -│ 3 │ 1 │ right is greater or equal than left │ -└──────┴───────┴─────────────────────────────────────┘ -``` - -یادداشت: `NULL` ارزش ها در این مثال استفاده نمی شود, بررسی [ارزشهای پوچ در شرطی](#null-values-in-conditionals) بخش. - -## اپراتور سه تایی {#ternary-operator} - -این همان کار می کند `if` تابع. - -نحو: `cond ? then : else` - -بازگشت `then` اگر `cond` ارزیابی درست باشد (بیشتر از صفر), در غیر این صورت بازده `else`. - -- `cond` باید از نوع باشد `UInt8` و `then` و `else` باید کمترین نوع مشترک دارند. - -- `then` و `else` می تواند باشد `NULL` - -**همچنین نگاه کنید به** - -- [اطلاعات دقیق](other_functions.md#ifnotfinite). - -## چندف {#multiif} - -اجازه می دهد تا شما را به نوشتن [CASE](../operators.md#operator_case) اپراتور فشرده تر در پرس و جو. - -نحو: `multiIf(cond_1, then_1, cond_2, then_2, ..., else)` - -**پارامترها:** - -- `cond_N` — The condition for the function to return `then_N`. -- `then_N` — The result of the function when executed. -- `else` — The result of the function if none of the conditions is met. - -تابع می پذیرد `2N+1` پارامترها - -**مقادیر بازگشتی** - -تابع یکی از مقادیر را برمی گرداند `then_N` یا `else`, بسته به شرایط `cond_N`. - -**مثال** - -دوباره با استفاده از `LEFT_RIGHT` جدول - -``` sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─result──────────┐ -│ ᴺᵁᴸᴸ │ 4 │ Null value │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ left is greater │ -│ 4 │ ᴺᵁᴸᴸ │ Null value │ -└──────┴───────┴─────────────────┘ -``` - -## با استفاده از نتایج شرطی به طور مستقیم {#using-conditional-results-directly} - -شرطی همیشه به نتیجه `0`, `1` یا `NULL`. بنابراین شما می توانید نتایج شرطی به طور مستقیم مثل این استفاده کنید: - -``` sql -SELECT left < right AS is_small -FROM LEFT_RIGHT - -┌─is_small─┐ -│ ᴺᵁᴸᴸ │ -│ 1 │ -│ 0 │ -│ 0 │ -│ ᴺᵁᴸᴸ │ -└──────────┘ -``` - -## ارزشهای پوچ در شرطی {#null-values-in-conditionals} - -زمانی که `NULL` ارزش ها در شرطی درگیر, نتیجه نیز خواهد بود `NULL`. - -``` sql -SELECT - NULL < 1, - 2 < NULL, - NULL < NULL, - NULL = NULL - -┌─less(NULL, 1)─┬─less(2, NULL)─┬─less(NULL, NULL)─┬─equals(NULL, NULL)─┐ -│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└───────────────┴───────────────┴──────────────────┴────────────────────┘ -``` - -بنابراین شما باید نمایش داده شد خود را با دقت ساخت اگر انواع هستند `Nullable`. - -مثال زیر نشان می دهد این شکست برای اضافه کردن شرایط برابر به `multiIf`. - -``` sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'right is smaller', 'Both equal') AS faulty_result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─faulty_result────┐ -│ ᴺᵁᴸᴸ │ 4 │ Both equal │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ right is smaller │ -│ 4 │ ᴺᵁᴸᴸ │ Both equal │ -└──────┴───────┴──────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/fa/sql_reference/functions/date_time_functions.md b/docs/fa/sql_reference/functions/date_time_functions.md deleted file mode 100644 index 8a34ad69b3f..00000000000 --- a/docs/fa/sql_reference/functions/date_time_functions.md +++ /dev/null @@ -1,451 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u062A\u0627\u0631\u06CC\u062E \u0648\ - \ \u0632\u0645\u0627\u0646" ---- - -# توابع برای کار با تاریخ و زمان {#functions-for-working-with-dates-and-times} - -پشتیبانی از مناطق زمانی - -همه توابع برای کار با تاریخ و زمان است که یک استفاده منطقی برای منطقه زمانی می تواند یک زمان اختیاری استدلال منطقه دوم قبول. مثال: اسیا/یکاترینبورگ. در این مورد از منطقه زمانی مشخص شده به جای محلی (پیش فرض) استفاده می کنند. - -``` sql -SELECT - toDateTime('2016-06-15 23:00:00') AS time, - toDate(time) AS date_local, - toDate(time, 'Asia/Yekaterinburg') AS date_yekat, - toString(time, 'US/Samoa') AS time_samoa -``` - -``` text -┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ -└─────────────────────┴────────────┴────────────┴─────────────────────┘ -``` - -فقط مناطق زمانی که از مجموعه مقالات توسط تعداد کل ساعت متفاوت پشتیبانی می شوند. - -## توتیمزون {#totimezone} - -تبدیل زمان یا تاریخ و زمان به منطقه زمانی مشخص شده است. - -## اسباب بازی {#toyear} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت16 حاوی شماره سال (میلادی). - -## فهرست توزیع جدید {#toquarter} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد کوچک8 حاوی شماره سه ماهه. - -## تامونت {#tomonth} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد کوچک8 حاوی شماره ماه (1-12). - -## سال {#todayofyear} - -تبدیل یک تاریخ و یا تاریخ با گذشت زمان به یک uint16 تعداد شامل تعداد روز از سال (1-366). - -## تودیفمون {#todayofmonth} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت8 حاوی تعداد روز از ماه (1-31). - -## تدیفوک {#todayofweek} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت8 حاوی تعداد روز هفته (دوشنبه است 1, و یکشنبه است 7). - -## تمام {#tohour} - -تبدیل تاریخ با هم به یک uint8 شماره حاوی تعداد ساعت در زمان 24 ساعته (0-23). -This function assumes that if clocks are moved ahead, it is by one hour and occurs at 2 a.m., and if clocks are moved back, it is by one hour and occurs at 3 a.m. (which is not always true – even in Moscow the clocks were twice changed at a different time). - -## تامینوت {#tominute} - -تبدیل تاریخ با هم به یک uint8 شماره حاوی تعداد دقیقه از ساعت (0-59). - -## جای خالی {#tosecond} - -تبدیل تاریخ با هم به یک uint8 شماره حاوی شماره دوم در دقیقه (0-59). -ثانیه جهش برای به حساب نمی. - -## تیونیتیمستمپ {#to-unix-timestamp} - -برای استدلال حسگر ناحیه رنگی: تبدیل ارزش به نمایندگی عددی داخلی خود (برچسب زمان یونیکس). -برای استدلال رشته: تاریخ ساعت پارسه از رشته با توجه به منطقه زمانی (بحث دوم اختیاری, منطقه زمانی سرور به طور پیش فرض استفاده می شود) و مربوط برچسب زمان یونیکس می گرداند. -برای استدلال تاریخ: رفتار نامشخص است. - -**نحو** - -``` sql -toUnixTimestamp(datetime) -toUnixTimestamp(str, [timezone]) -``` - -**مقدار بازگشتی** - -- زمان یونیکس را برمی گرداند. - -نوع: `UInt32`. - -**مثال** - -پرسوجو: - -``` sql -SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp -``` - -نتیجه: - -``` text -┌─unix_timestamp─┐ -│ 1509836867 │ -└────────────────┘ -``` - -## سال نو {#tostartofyear} - -دور یک تاریخ یا تاریخ با زمان به روز اول سال. -تاریخ را برمی گرداند. - -## تاستارتوفیزیر {#tostartofisoyear} - -دور کردن تاریخ یا تاریخ با زمان به روز اول سال ایزو. -تاریخ را برمی گرداند. - -## toStartOfQuarter {#tostartofquarter} - -دور یک تاریخ یا تاریخ با زمان به روز اول سه ماهه. -اولین روز از سه ماهه است یا 1 ژانویه, 1 مارس, 1 جولای, یا 1 اکتبر. -تاریخ را برمی گرداند. - -## ماهی تابه {#tostartofmonth} - -دور پایین تاریخ یا تاریخ با زمان به روز اول ماه. -تاریخ را برمی گرداند. - -!!! attention "توجه" - رفتار تجزیه تاریخ نادرست اجرای خاص است. تاتر ممکن است صفر تاریخ بازگشت, پرتاب یک استثنا و یا انجام “natural” سرریز کردن. - -## روز قیامت {#tomonday} - -دور کردن یک تاریخ یا تاریخ با زمان به نزدیکترین دوشنبه. -تاریخ را برمی گرداند. - -## تستارتوفک (تی \[, حالت\]) {#tostartofweektmode} - -دور یک تاریخ یا تاریخ را با زمان به نزدیکترین یکشنبه یا دوشنبه با حالت. -تاریخ را برمی گرداند. -استدلال حالت کار می کند دقیقا مانند استدلال حالت به یدک کش (). برای نحو تک استدلال, ارزش حالت 0 استفاده شده است. - -## روزهای سه بعدی {#tostartofday} - -دور پایین تاریخ با زمان به شروع روز. - -## تاستارتوفهور {#tostartofhour} - -دور پایین تاریخ با زمان به شروع ساعت. - -## حفاظت {#tostartofminute} - -دور پایین تاریخ با زمان به شروع دقیقه. - -## تستارتوفیفومینوت {#tostartoffiveminute} - -دور پایین تاریخ با زمان به شروع فاصله پنج دقیقه. - -## حفاظت {#tostartoftenminutes} - -دور پایین تاریخ با زمان به شروع فاصله ده دقیقه. - -## toStartOfFifteenMinutes {#tostartoffifteenminutes} - -دور پایین تاریخ با زمان به شروع فاصله پانزده دقیقه. - -## toStartOfInterval(time\_or\_data فاصله x واحد \[, time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} - -این یک تعمیم توابع دیگر به نام است `toStartOf*`. به عنوان مثال, -`toStartOfInterval(t, INTERVAL 1 year)` همان را برمی گرداند `toStartOfYear(t)`, -`toStartOfInterval(t, INTERVAL 1 month)` همان را برمی گرداند `toStartOfMonth(t)`, -`toStartOfInterval(t, INTERVAL 1 day)` همان را برمی گرداند `toStartOfDay(t)`, -`toStartOfInterval(t, INTERVAL 15 minute)` همان را برمی گرداند `toStartOfFifteenMinutes(t)` و غیره - -## & تمام کردن {#totime} - -تبدیل یک تاریخ با زمان به یک تاریخ ثابت خاص, در حالی که حفظ زمان. - -## ترلتیویینوم {#torelativeyearnum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد سال, با شروع از یک نقطه ثابت خاص در گذشته. - -## ترلتیواارترن {#torelativequarternum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد سه ماهه, با شروع از یک نقطه ثابت خاص در گذشته. - -## ترلتیومنتنوم {#torelativemonthnum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد ماه, با شروع از یک نقطه ثابت خاص در گذشته. - -## ترلتیواکنام {#torelativeweeknum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد هفته, با شروع از یک نقطه ثابت خاص در گذشته. - -## ترلتیدینوم {#torelativedaynum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد روز, با شروع از یک نقطه ثابت خاص در گذشته. - -## تورلاتویورنام {#torelativehournum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد ساعت, با شروع از یک نقطه ثابت خاص در گذشته. - -## ترلتیومینوتنوم {#torelativeminutenum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد دقیقه, با شروع از یک نقطه ثابت خاص در گذشته. - -## ترلتیویسکنندوم {#torelativesecondnum} - -تبدیل یک تاریخ با زمان و یا تاریخ به تعداد دوم, با شروع از یک نقطه ثابت خاص در گذشته. - -## ریز ریز کردن {#toisoyear} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت16 حاوی شماره سال ایزو. - -## هشدار داده می شود {#toisoweek} - -تبدیل یک تاریخ و یا تاریخ با گذشت زمان به یک uint8 تعداد شامل iso هفته شماره. - -## تاریخ \[, حالت\]) {#toweekdatemode} - -این تابع تعداد هفته برای تاریخ و یا تاریخ ساعت می گرداند. فرم دو برهان یدک کش () شما را قادر به مشخص کنید که هفته در روز یکشنبه یا دوشنبه شروع می شود و چه مقدار بازگشتی باید در محدوده 0 تا 53 یا از 1 به 53 باشد. اگر استدلال حالت حذف شده است, حالت پیش فرض است 0. -`toISOWeek()`یک تابع سازگاری است که معادل است `toWeek(date,3)`. -جدول زیر توضیح می دهد که چگونه استدلال حالت کار می کند. - -| حالت | اولین روز هفته | گستره | Week 1 is the first week … | -|------|----------------|-------|-----------------------------| -| 0 | یکشنبه | 0-53 | با یکشنبه در این سال | -| 1 | دوشنبه | 0-53 | با 4 یا چند روز در سال جاری | -| 2 | یکشنبه | 1-53 | با یکشنبه در این سال | -| 3 | دوشنبه | 1-53 | با 4 یا چند روز در سال جاری | -| 4 | یکشنبه | 0-53 | با 4 یا چند روز در سال جاری | -| 5 | دوشنبه | 0-53 | با دوشنبه در این سال | -| 6 | یکشنبه | 1-53 | با 4 یا چند روز در سال جاری | -| 7 | دوشنبه | 1-53 | با دوشنبه در این سال | -| 8 | یکشنبه | 1-53 | شامل ژانویه 1 | -| 9 | دوشنبه | 1-53 | شامل ژانویه 1 | - -برای مقادیر حالت با معنی “with 4 or more days this year,” هفته ها با توجه به ایزو شماره 8601: 1988: - -- اگر هفته حاوی ژانویه 1 است 4 یا چند روز در سال جدید, هفته است 1. - -- در غیر این صورت, این هفته گذشته سال گذشته است, و هفته بعد هفته است 1. - -برای مقادیر حالت با معنی “contains January 1”, هفته شامل ژانویه 1 هفته است 1. مهم نیست که چند روز در سال جدید هفته شامل, حتی اگر شامل تنها یک روز. - -``` sql -toWeek(date, [, mode][, Timezone]) -``` - -**پارامترها** - -- `date` – Date or DateTime. -- `mode` – Optional parameter, Range of values is \[0,9\], default is 0. -- `Timezone` – Optional parameter, it behaves like any other conversion function. - -**مثال** - -``` sql -SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9; -``` - -``` text -┌───────date─┬─week0─┬─week1─┬─week9─┐ -│ 2016-12-27 │ 52 │ 52 │ 1 │ -└────────────┴───────┴───────┴───────┘ -``` - -## تاریخ \[, حالت\]) {#toyearweekdatemode} - -را برمی گرداند سال و هفته برای تاریخ. سال در نتیجه ممکن است متفاوت از سال در بحث تاریخ برای اولین و هفته گذشته سال. - -استدلال حالت کار می کند دقیقا مانند استدلال حالت به یدک کش (). برای نحو تک استدلال, ارزش حالت 0 استفاده شده است. - -`toISOYear()`یک تابع سازگاری است که معادل است `intDiv(toYearWeek(date,3),100)`. - -**مثال** - -``` sql -SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9; -``` - -``` text -┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┐ -│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ -└────────────┴───────────┴───────────┴───────────┘ -``` - -## حالا {#now} - -قبول صفر استدلال و بازده زمان فعلی در یکی از لحظات اجرای درخواست. -این تابع ثابت می گرداند, حتی اگر درخواست زمان طولانی برای تکمیل. - -## امروز {#today} - -قبول صفر استدلال و بازده تاریخ جاری در یکی از لحظات اجرای درخواست. -همان ‘toDate(now())’. - -## دیروز {#yesterday} - -قبول صفر استدلال و بازده تاریخ دیروز در یکی از لحظات اجرای درخواست. -همان ‘today() - 1’. - -## سانس {#timeslot} - -دور زمان به نیم ساعت. -این تابع خاص به یاندکس است.متریکا, از نیم ساعت حداقل مقدار زمان برای شکستن یک جلسه به دو جلسه است اگر یک تگ ردیابی نشان می دهد تعداد صفحات متوالی یک کاربر که در زمان به شدت بیش از این مقدار متفاوت. این به این معنی است که تاپل (شناسه برچسب, شناسه کاربری, و شکاف زمان) را می توان مورد استفاده قرار گیرد به جستجو برای تعداد صفحات که در جلسه مربوطه شامل. - -## ستاره فیلم سکسی {#toyyyymm} - -تبدیل یک تاریخ یا تاریخ با زمان به یک عدد اوینت32 حاوی تعداد سال و ماه (یی \* 100 + میلی متر). - -## ستاره فیلم سکسی {#toyyyymmdd} - -تبدیل یک تاریخ یا تاریخ با زمان به تعداد اوینت32 حاوی سال و ماه شماره (یی \* 10000 + میلی متر \* 100 + دی.دی. - -## اطلاعات دقیق {#toyyyymmddhhmmss} - -تبدیل یک تاریخ و یا تاریخ با گذشت زمان به یک uint64 تعداد شامل سال و ماه شماره (yyyy \* 10000000000 + mm \* 100000000 + dd \* 1000000 + hh \* 10000 + mm \* 100 + ss) است. - -## addYears, addMonths, addWeeks, addDays, addHours, addMinutes, addSeconds, addQuarters {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} - -تابع می افزاید: یک تاریخ/فاصله زمانی به یک تاریخ/تاریخ ساعت و سپس بازگشت تاریخ / تاریخ ساعت. به عنوان مثال: - -``` sql -WITH - toDate('2018-01-01') AS date, - toDateTime('2018-01-01 00:00:00') AS date_time -SELECT - addYears(date, 1) AS add_years_with_date, - addYears(date_time, 1) AS add_years_with_date_time -``` - -``` text -┌─add_years_with_date─┬─add_years_with_date_time─┐ -│ 2019-01-01 │ 2019-01-01 00:00:00 │ -└─────────────────────┴──────────────────────────┘ -``` - -## subtractYears, subtractMonths, subtractWeeks, subtractDays, subtractHours, subtractMinutes, subtractSeconds, subtractQuarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} - -تابع تفریق یک تاریخ/فاصله زمانی به تاریخ/تاریخ ساعت و سپس بازگشت تاریخ / تاریخ ساعت. به عنوان مثال: - -``` sql -WITH - toDate('2019-01-01') AS date, - toDateTime('2019-01-01 00:00:00') AS date_time -SELECT - subtractYears(date, 1) AS subtract_years_with_date, - subtractYears(date_time, 1) AS subtract_years_with_date_time -``` - -``` text -┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ -│ 2018-01-01 │ 2018-01-01 00:00:00 │ -└──────────────────────────┴───────────────────────────────┘ -``` - -## dateDiff {#datediff} - -بازگرداندن تفاوت بین دو تاریخ و یا تاریخ ساعت ارزش. - -**نحو** - -``` sql -dateDiff('unit', startdate, enddate, [timezone]) -``` - -**پارامترها** - -- `unit` — Time unit, in which the returned value is expressed. [رشته](../syntax.md#syntax-string-literal). - - Supported values: - - | unit | - | ---- | - |second | - |minute | - |hour | - |day | - |week | - |month | - |quarter | - |year | - -- `startdate` — The first time value to compare. [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). - -- `enddate` — The second time value to compare. [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). - -- `timezone` — Optional parameter. If specified, it is applied to both `startdate` و `enddate`. اگر مشخص نشده, زمان از `startdate` و `enddate` استفاده می شود. در صورتی که یکسان نیست, نتیجه نامشخص است. - -**مقدار بازگشتی** - -تفاوت بین `startdate` و `enddate` بیان شده در `unit`. - -نوع: `int`. - -**مثال** - -پرسوجو: - -``` sql -SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); -``` - -نتیجه: - -``` text -┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ -│ 25 │ -└────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## زمانهای(StartTime, مدت,\[, اندازه\]) {#timeslotsstarttime-duration-size} - -برای یک بازه زمانی شروع در ‘StartTime’ و در ادامه برای ‘Duration’ ثانیه, این مجموعه ای از لحظات در زمان گرداند, متشکل از نقاط از این فاصله به گرد ‘Size’ در عرض چند ثانیه ‘Size’ یک پارامتر اختیاری است: یک ثابت اوینت32, مجموعه ای به 1800 به طور پیش فرض. -به عنوان مثال, `timeSlots(toDateTime('2012-01-01 12:20:00'), 600) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. -این برای جستجوی صفحات در جلسه مربوطه ضروری است. - -## formatDateTime(زمان فرمت \[منطقه زمانی\]) {#formatdatetime} - -Function formats a Time according given Format string. N.B.: Format is a constant expression, e.g. you can not have multiple formats for single result column. - -اصلاح کننده های پشتیبانی شده برای فرمت: -(“Example” ستون نتیجه قالب بندی برای زمان را نشان می دهد `2018-01-02 22:33:44`) - -| تغییردهنده | توصیف | مثال | -|------------|-----------------------------------------------------------------------------|------------| -| %C | سال تقسیم بر 100 و کوتاه به عدد صحیح (00-99) | 20 | -| \# د | روز از ماه, صفر خالی (01-31) | 02 | -| %D | کوتاه میلی متر/دی دی/یی تاریخ, معادل %متر/%د / %و | 01/02/18 | -| \# ا | روز از ماه, فضا خالی ( 1-31) | 2 | -| %F | کوتاه تاریخ یی-میلی متر-دی دی, معادل%و-%متر - % د | 2018-01-02 | -| %H | ساعت در فرمت 24 ساعت (00-23) | 22 | -| %I | ساعت در فرمت 12 ساعت (01-12) | 10 | -| \# ج | روز سال (001-366) | 002 | -| % متر | ماه به عنوان یک عدد اعشاری (01-12) | 01 | -| %M | دقیقه (00-59) | 33 | -| % ن | شخصیت جدید خط (") | | -| \# پ | هستم یا بعد از ظهر تعیین | PM | -| %R | 24-ساعت ساعت ساعت: زمان میلی متر, معادل %ساعت: % متر | 22:33 | -| %S | دوم (00-59) | 44 | -| % تی | شخصیت افقی تب (') | | -| %T | ایزو 8601 فرمت زمان (ساعت:میلی متر:اس اس), معادل %ساعت:%متر:%بازدید کنندگان | 22:33:44 | -| \# تو | ایزو 8601 روز هفته به عنوان شماره با دوشنبه به عنوان 1 (1-7) | 2 | -| %V | ایزو 8601 هفته شماره (01-53) | 01 | -| \# وات | روز هفته به عنوان یک عدد اعشاری با یکشنبه به عنوان 0 (0-6) | 2 | -| \#... | سال گذشته دو رقم (00-99) | 18 | -| %Y | سال | 2018 | -| %% | یک % نشانه | % | - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/fa/sql_reference/functions/encoding_functions.md b/docs/fa/sql_reference/functions/encoding_functions.md deleted file mode 100644 index 0c08d0cad86..00000000000 --- a/docs/fa/sql_reference/functions/encoding_functions.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 52 -toc_title: "\u06A9\u062F\u0628\u0646\u062F\u06CC" ---- - -# توابع را پشتیبانی می کند {#encoding-functions} - -## کاراکتر {#char} - -بازگرداندن رشته با طول به عنوان تعدادی از استدلال گذشت و هر بایت دارای ارزش استدلال مربوطه. می پذیرد استدلال های متعدد از انواع عددی. اگر ارزش بحث خارج از محدوده uint8 نوع داده آن است که تبدیل به uint8 با امکان گرد کردن و سرریز. - -**نحو** - -``` sql -char(number_1, [number_2, ..., number_n]); -``` - -**پارامترها** - -- `number_1, number_2, ..., number_n` — Numerical arguments interpreted as integers. Types: [Int](../../sql_reference/data_types/int_uint.md), [شناور](../../sql_reference/data_types/float.md). - -**مقدار بازگشتی** - -- یک رشته از بایت داده. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello -``` - -نتیجه: - -``` text -┌─hello─┐ -│ hello │ -└───────┘ -``` - -شما می توانید یک رشته از رمزگذاری دلخواه با عبور از بایت مربوطه ساخت. در اینجا به عنوان مثال برای یونایتد-8 است: - -پرسوجو: - -``` sql -SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; -``` - -نتیجه: - -``` text -┌─hello──┐ -│ привет │ -└────────┘ -``` - -پرسوجو: - -``` sql -SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; -``` - -نتیجه: - -``` text -┌─hello─┐ -│ 你好 │ -└───────┘ -``` - -## هکس {#hex} - -بازگرداندن یک رشته حاوی نمایندگی هگزادسیمال استدلال. - -**نحو** - -``` sql -hex(arg) -``` - -تابع با استفاده از حروف بزرگ `A-F` و با استفاده از هیچ پیشوندها (مانند `0x`) یا پسوندها (مانند `h`). - -برای استدلال عدد صحیح رقم سحر و جادو را چاپ می کند (“nibbles”) از مهم ترین به حداقل قابل توجهی (اندی بزرگ یا “human readable” سفارش). این با مهم ترین بایت غیر صفر شروع می شود (پیشرو صفر بایت حذف می شوند) اما همیشه چاپ هر دو رقم از هر بایت حتی اگر رقم پیشرو صفر است. - -مثال: - -**مثال** - -پرسوجو: - -``` sql -SELECT hex(1); -``` - -نتیجه: - -``` text -01 -``` - -مقادیر نوع `Date` و `DateTime` به عنوان اعداد صحیح مربوطه فرمت (تعداد روز از عصر برای تاریخ و ارزش برچسب زمان یونیکس برای تاریخ ساعت داده). - -برای `String` و `FixedString`, تمام بایت به سادگی به عنوان دو عدد هگزادسیمال کد گذاری. صفر بایت حذف نشده است. - -ارزش های ممیز شناور و رقم اعشاری به عنوان نمایندگی خود را در حافظه کد گذاری. همانطور که ما از معماری اندیان کوچک حمایت می کنیم در اندی کوچک کد گذاری می شوند. صفر پیشرو / عقبی بایت حذف نشده است. - -**پارامترها** - -- `arg` — A value to convert to hexadecimal. Types: [رشته](../../sql_reference/data_types/string.md), [اینترنت](../../sql_reference/data_types/int_uint.md), [شناور](../../sql_reference/data_types/float.md), [دهدهی](../../sql_reference/data_types/decimal.md), [تاریخ](../../sql_reference/data_types/date.md) یا [DateTime](../../sql_reference/data_types/datetime.md). - -**مقدار بازگشتی** - -- یک رشته با نمایش هگزادسیمال استدلال. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); -``` - -نتیجه: - -``` text -┌─hex_presentation─┐ -│ 00007041 │ -│ 00008041 │ -└──────────────────┘ -``` - -پرسوجو: - -``` sql -SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); -``` - -نتیجه: - -``` text -┌─hex_presentation─┐ -│ 0000000000002E40 │ -│ 0000000000003040 │ -└──────────────────┘ -``` - -## unhex(str) {#unhexstr} - -می پذیرد یک رشته حاوی هر تعداد از رقم هگزادسیمال, و یک رشته حاوی بایت مربوطه را برمی گرداند. پشتیبانی از حروف بزرگ و کوچک تعداد ارقام هگزادسیمال ندارد به حتی. اگر عجیب و غریب است, رقم گذشته به عنوان نیمه حداقل قابل توجهی از بایت 00-0ف تفسیر. اگر رشته استدلال شامل هر چیزی غیر از رقم هگزادسیمال, برخی از نتیجه پیاده سازی تعریف بازگشته است (یک استثنا پرتاب نمی شود). -اگر شما می خواهید برای تبدیل نتیجه به یک عدد, شما می توانید با استفاده از ‘reverse’ و ‘reinterpretAsType’ توابع. - -## هشدار داده می شود) {#uuidstringtonumstr} - -می پذیرد یک رشته حاوی 36 کاراکتر در قالب `123e4567-e89b-12d3-a456-426655440000` و به عنوان مجموعه ای از بایت ها در یک رشته ثابت(16) باز می گردد. - -## هشدار داده می شود) {#uuidnumtostringstr} - -می پذیرد یک رشته ثابت (16) ارزش. بازگرداندن یک رشته حاوی 36 کاراکتر در قالب متن. - -## بیتماسکتولیست (عدد) {#bitmasktolistnum} - -می پذیرد یک عدد صحیح. بازگرداندن یک رشته حاوی لیستی از قدرت های دو که در مجموع تعداد منبع که خلاصه. با کاما از هم جدا بدون فاصله در قالب متن, به ترتیب صعودی. - -## هشدار داده می شود) {#bitmasktoarraynum} - -می پذیرد یک عدد صحیح. بازگرداندن مجموعه ای از اعداد اوینت64 حاوی لیستی از قدرت های دو که در مجموع تعداد منبع در هنگام خلاصه. اعداد به ترتیب صعودی هستند. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/fa/sql_reference/functions/ext_dict_functions.md b/docs/fa/sql_reference/functions/ext_dict_functions.md deleted file mode 100644 index 622344f789c..00000000000 --- a/docs/fa/sql_reference/functions/ext_dict_functions.md +++ /dev/null @@ -1,206 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 58 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0648\u0627\u0698\u0647\u0646\u0627\u0645\ - \u0647\u0647\u0627 \u062E\u0627\u0631\u062C\u06CC" ---- - -# توابع برای کار با لغت نامه های خارجی {#ext_dict_functions} - -برای اطلاعات در مورد اتصال و پیکربندی لغت نامه های خارجی, دیدن [واژهنامهها خارجی](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -## دیکته کردن {#dictget} - -بازیابی یک مقدار از یک فرهنگ لغت خارجی. - -``` sql -dictGet('dict_name', 'attr_name', id_expr) -dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**پارامترها** - -- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `attr_name` — Name of the column of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql_reference/data_types/int_uint.md) یا [تاپل](../../sql_reference/data_types/tuple.md)- نوع ارزش بسته به پیکربندی فرهنگ لغت . -- `default_value_expr` — Value returned if the dictionary doesn't contain a row with the `id_expr` کلید [عبارت](../syntax.md#syntax-expressions) بازگشت ارزش در نوع داده پیکربندی شده برای `attr_name` صفت کردن. - -**مقدار بازگشتی** - -- اگر تاتر تجزیه ویژگی موفقیت در [نوع داده خصیصه](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes), توابع بازگشت ارزش ویژگی فرهنگ لغت که مربوط به `id_expr`. - -- اگر هیچ کلید وجود دارد, مربوط به `id_expr`, در فرهنگ لغت, سپس: - - - `dictGet` returns the content of the `` element specified for the attribute in the dictionary configuration. - - `dictGetOrDefault` returns the value passed as the `default_value_expr` parameter. - -کلیک هاوس می اندازد یک استثنا اگر می تواند ارزش ویژگی تجزیه و یا ارزش می کند نوع داده ویژگی مطابقت ندارد. - -**مثال** - -ایجاد یک فایل متنی `ext-dict-text.csv` حاوی موارد زیر است: - -``` text -1,1 -2,2 -``` - -ستون اول است `id` ستون دوم `c1`. - -پیکربندی واژهنامه خارجی: - -``` xml - - - ext-dict-test - - - /path-to/ext-dict-test.csv - CSV - - - - - - - - id - - - c1 - UInt32 - - - - 0 - - -``` - -انجام پرس و جو: - -``` sql -SELECT - dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, - toTypeName(val) AS type -FROM system.numbers -LIMIT 3 -``` - -``` text -┌─val─┬─type───┐ -│ 1 │ UInt32 │ -│ 2 │ UInt32 │ -│ 20 │ UInt32 │ -└─────┴────────┘ -``` - -**همچنین نگاه کنید** - -- [واژهنامهها خارجی](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) - -## دیکتس {#dicthas} - -بررسی اینکه یک کلید در حال حاضر در یک فرهنگ لغت است. - -``` sql -dictHas('dict_name', id_expr) -``` - -**پارامترها** - -- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql_reference/data_types/int_uint.md)- نوع ارزش. - -**مقدار بازگشتی** - -- 0, اگر هیچ کلید وجود دارد. -- 1, اگر یک کلید وجود دارد. - -نوع: `UInt8`. - -## حکومت دیکتاتوری {#dictgethierarchy} - -یک مجموعه ای ایجاد می کند که شامل همه والدین یک کلید در [فرهنگ لغت سلسله مراتبی](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md). - -**نحو** - -``` sql -dictGetHierarchy('dict_name', key) -``` - -**پارامترها** - -- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `key` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql_reference/data_types/int_uint.md)- نوع ارزش. - -**مقدار بازگشتی** - -- پدر و مادر برای کلید. - -نوع: [Array(UInt64)](../../sql_reference/data_types/array.md). - -## دیکتاتوری {#dictisin} - -جد یک کلید را از طریق کل زنجیره سلسله مراتبی در فرهنگ لغت بررسی می کند. - -``` sql -dictIsIn('dict_name', child_id_expr, ancestor_id_expr) -``` - -**پارامترها** - -- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `child_id_expr` — Key to be checked. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql_reference/data_types/int_uint.md)- نوع ارزش. -- `ancestor_id_expr` — Alleged ancestor of the `child_id_expr` کلید [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql_reference/data_types/int_uint.md)- نوع ارزش. - -**مقدار بازگشتی** - -- 0 اگر `child_id_expr` یک کودک نیست `ancestor_id_expr`. -- 1 اگر `child_id_expr` یک کودک است `ancestor_id_expr` یا اگر `child_id_expr` یک `ancestor_id_expr`. - -نوع: `UInt8`. - -## توابع دیگر {#ext_dict_functions-other} - -تاتر پشتیبانی از توابع تخصصی است که تبدیل ارزش فرهنگ لغت ویژگی به یک نوع داده خاص بدون در نظر گرفتن پیکربندی فرهنگ لغت. - -توابع: - -- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` -- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` -- `dictGetFloat32`, `dictGetFloat64` -- `dictGetDate` -- `dictGetDateTime` -- `dictGetUUID` -- `dictGetString` - -همه این توابع `OrDefault` اصلاح. به عنوان مثال, `dictGetDateOrDefault`. - -نحو: - -``` sql -dictGet[Type]('dict_name', 'attr_name', id_expr) -dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**پارامترها** - -- `dict_name` — Name of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `attr_name` — Name of the column of the dictionary. [رشته تحت اللفظی](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [عبارت](../syntax.md#syntax-expressions) بازگشت یک [UInt64](../../sql_reference/data_types/int_uint.md)- نوع ارزش. -- `default_value_expr` — Value which is returned if the dictionary doesn't contain a row with the `id_expr` کلید [عبارت](../syntax.md#syntax-expressions) بازگشت یک مقدار در نوع داده پیکربندی شده برای `attr_name` صفت کردن. - -**مقدار بازگشتی** - -- اگر تاتر تجزیه ویژگی موفقیت در [نوع داده خصیصه](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes), توابع بازگشت ارزش ویژگی فرهنگ لغت که مربوط به `id_expr`. - -- در صورتی که هیچ درخواست وجود دارد `id_expr` در فرهنگ لغت و سپس: - - - `dictGet[Type]` returns the content of the `` element specified for the attribute in the dictionary configuration. - - `dictGet[Type]OrDefault` returns the value passed as the `default_value_expr` parameter. - -کلیک هاوس می اندازد یک استثنا اگر می تواند ارزش ویژگی تجزیه و یا ارزش می کند نوع داده ویژگی مطابقت ندارد. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/fa/sql_reference/functions/functions_for_nulls.md b/docs/fa/sql_reference/functions/functions_for_nulls.md deleted file mode 100644 index 02efe209696..00000000000 --- a/docs/fa/sql_reference/functions/functions_for_nulls.md +++ /dev/null @@ -1,313 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 63 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 Nullable \u0627\u0633\u062A\u062F\u0644\ - \u0627\u0644" ---- - -# توابع برای کار با nullable مصالح {#functions-for-working-with-nullable-aggregates} - -## isNull {#isnull} - -بررسی اینکه بحث چیست [NULL](../syntax.md#null). - -``` sql -isNull(x) -``` - -**پارامترها** - -- `x` — A value with a non-compound data type. - -**مقدار بازگشتی** - -- `1` اگر `x` هست `NULL`. -- `0` اگر `x` نیست `NULL`. - -**مثال** - -جدول ورودی - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -پرسوجو - -``` sql -SELECT x FROM t_null WHERE isNull(y) -``` - -``` text -┌─x─┐ -│ 1 │ -└───┘ -``` - -## اینترنت {#isnotnull} - -بررسی اینکه بحث چیست [NULL](../syntax.md#null). - -``` sql -isNotNull(x) -``` - -**پارامترها:** - -- `x` — A value with a non-compound data type. - -**مقدار بازگشتی** - -- `0` اگر `x` هست `NULL`. -- `1` اگر `x` نیست `NULL`. - -**مثال** - -جدول ورودی - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -پرسوجو - -``` sql -SELECT x FROM t_null WHERE isNotNull(y) -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## فلز کاری {#coalesce} - -چک از چپ به راست چه `NULL` استدلال به تصویب رسید و اولین غیر گرداند-`NULL` استدلال کردن. - -``` sql -coalesce(x,...) -``` - -**پارامترها:** - -- هر تعداد از پارامترهای یک نوع غیر مرکب. تمام پارامترها باید با نوع داده سازگار باشند. - -**مقادیر بازگشتی** - -- اولین غیر-`NULL` استدلال کردن. -- `NULL`, اگر همه استدلال ها `NULL`. - -**مثال** - -یک لیست از مخاطبین است که ممکن است راه های متعدد برای تماس با مشتری مشخص را در نظر بگیرید. - -``` text -┌─name─────┬─mail─┬─phone─────┬──icq─┐ -│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ -│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└──────────┴──────┴───────────┴──────┘ -``` - -این `mail` و `phone` زمینه های رشته نوع هستند, اما `icq` زمینه است `UInt32` بنابراین نیاز به تبدیل شدن به `String`. - -دریافت اولین روش تماس در دسترس برای مشتری از لیست تماس: - -``` sql -SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook -``` - -``` text -┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ -│ client 1 │ 123-45-67 │ -│ client 2 │ ᴺᵁᴸᴸ │ -└──────────┴──────────────────────────────────────────────────────┘ -``` - -## ifNull {#ifnull} - -بازگرداندن یک مقدار جایگزین اگر استدلال اصلی است `NULL`. - -``` sql -ifNull(x,alt) -``` - -**پارامترها:** - -- `x` — The value to check for `NULL`. -- `alt` — The value that the function returns if `x` هست `NULL`. - -**مقادیر بازگشتی** - -- مقدار `x` اگر `x` نیست `NULL`. -- مقدار `alt` اگر `x` هست `NULL`. - -**مثال** - -``` sql -SELECT ifNull('a', 'b') -``` - -``` text -┌─ifNull('a', 'b')─┐ -│ a │ -└──────────────────┘ -``` - -``` sql -SELECT ifNull(NULL, 'b') -``` - -``` text -┌─ifNull(NULL, 'b')─┐ -│ b │ -└───────────────────┘ -``` - -## nullIf {#nullif} - -بازگشت `NULL` اگر استدلال برابر هستند. - -``` sql -nullIf(x, y) -``` - -**پارامترها:** - -`x`, `y` — Values for comparison. They must be compatible types, or ClickHouse will generate an exception. - -**مقادیر بازگشتی** - -- `NULL`, اگر استدلال برابر هستند. -- این `x` ارزش, اگر استدلال برابر نیست. - -**مثال** - -``` sql -SELECT nullIf(1, 1) -``` - -``` text -┌─nullIf(1, 1)─┐ -│ ᴺᵁᴸᴸ │ -└──────────────┘ -``` - -``` sql -SELECT nullIf(1, 2) -``` - -``` text -┌─nullIf(1, 2)─┐ -│ 1 │ -└──────────────┘ -``` - -## قابل قبول {#assumenotnull} - -نتایج در ارزش نوع [Nullable](../../sql_reference/data_types/nullable.md) برای یک غیر- `Nullable`, اگر مقدار است `NULL`. - -``` sql -assumeNotNull(x) -``` - -**پارامترها:** - -- `x` — The original value. - -**مقادیر بازگشتی** - -- مقدار اصلی از غیر-`Nullable` نوع, اگر نیست `NULL`. -- مقدار پیش فرض برای غیر-`Nullable` نوع اگر مقدار اصلی بود `NULL`. - -**مثال** - -در نظر بگیرید که `t_null` جدول - -``` sql -SHOW CREATE TABLE t_null -``` - -``` text -┌─statement─────────────────────────────────────────────────────────────────┐ -│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ -└───────────────────────────────────────────────────────────────────────────┘ -``` - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -درخواست `assumeNotNull` تابع به `y` ستون. - -``` sql -SELECT assumeNotNull(y) FROM t_null -``` - -``` text -┌─assumeNotNull(y)─┐ -│ 0 │ -│ 3 │ -└──────────────────┘ -``` - -``` sql -SELECT toTypeName(assumeNotNull(y)) FROM t_null -``` - -``` text -┌─toTypeName(assumeNotNull(y))─┐ -│ Int8 │ -│ Int8 │ -└──────────────────────────────┘ -``` - -## قابل تنظیم {#tonullable} - -تبدیل نوع استدلال به `Nullable`. - -``` sql -toNullable(x) -``` - -**پارامترها:** - -- `x` — The value of any non-compound type. - -**مقدار بازگشتی** - -- مقدار ورودی با یک `Nullable` نوع. - -**مثال** - -``` sql -SELECT toTypeName(10) -``` - -``` text -┌─toTypeName(10)─┐ -│ UInt8 │ -└────────────────┘ -``` - -``` sql -SELECT toTypeName(toNullable(10)) -``` - -``` text -┌─toTypeName(toNullable(10))─┐ -│ Nullable(UInt8) │ -└────────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/fa/sql_reference/functions/geo.md b/docs/fa/sql_reference/functions/geo.md deleted file mode 100644 index cafe88281d9..00000000000 --- a/docs/fa/sql_reference/functions/geo.md +++ /dev/null @@ -1,511 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 62 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0645\u062E\u062A\u0635\u0627\u062A \u062C\ - \u063A\u0631\u0627\u0641\u06CC\u0627\u06CC\u06CC" ---- - -# توابع برای کار با مختصات جغرافیایی {#functions-for-working-with-geographical-coordinates} - -## نمایش سایت {#greatcircledistance} - -محاسبه فاصله بین دو نقطه بر روی سطح زمین با استفاده از [فرمول دایره بزرگ](https://en.wikipedia.org/wiki/Great-circle_distance). - -``` sql -greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) -``` - -**پارامترهای ورودی** - -- `lon1Deg` — Longitude of the first point in degrees. Range: `[-180°, 180°]`. -- `lat1Deg` — Latitude of the first point in degrees. Range: `[-90°, 90°]`. -- `lon2Deg` — Longitude of the second point in degrees. Range: `[-180°, 180°]`. -- `lat2Deg` — Latitude of the second point in degrees. Range: `[-90°, 90°]`. - -مقادیر مثبت به طول و عرض جغرافیایی شمال شرق مطابقت, و مقادیر منفی به طول و عرض جغرافیایی جنوبی و طول جغرافیایی غرب مطابقت. - -**مقدار بازگشتی** - -فاصله بین دو نقطه بر روی سطح زمین, در متر. - -تولید یک استثنا زمانی که مقادیر پارامتر ورودی در خارج از محدوده قرار می گیرند. - -**مثال** - -``` sql -SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) -``` - -``` text -┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ -│ 14132374.194975413 │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## نقلقولهای جدید از این نویسنده {#pointinellipses} - -بررسی اینکه نقطه متعلق به حداقل یکی از بیضی. -مختصات هندسی در سیستم مختصات دکارتی هستند. - -``` sql -pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) -``` - -**پارامترهای ورودی** - -- `x, y` — Coordinates of a point on the plane. -- `xᵢ, yᵢ` — Coordinates of the center of the `i`- حذف هفتم . -- `aᵢ, bᵢ` — Axes of the `i`- حذف ت در واحد های ایکس, و مختصات. - -پارامترهای ورودی باید باشد `2+4⋅n` کجا `n` تعداد بیضی است. - -**مقادیر بازگشتی** - -`1` اگر نقطه در داخل است حداقل یکی از بیضی; `0`اگر این طور نیست. - -**مثال** - -``` sql -SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) -``` - -``` text -┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ -│ 1 │ -└─────────────────────────────────────────────────┘ -``` - -## نقطه چین {#pointinpolygon} - -بررسی اینکه نقطه متعلق به چند ضلعی در هواپیما. - -``` sql -pointInPolygon((x, y), [(a, b), (c, d) ...], ...) -``` - -**مقادیر ورودی** - -- `(x, y)` — Coordinates of a point on the plane. Data type — [تاپل](../../sql_reference/data_types/tuple.md) — A tuple of two numbers. -- `[(a, b), (c, d) ...]` — Polygon vertices. Data type — [& حذف](../../sql_reference/data_types/array.md). هر راس است که توسط یک جفت مختصات نشان داده شده است `(a, b)`. راس باید در جهت عقربه های ساعت و یا در خلاف جهت عقربه مشخص شده است. حداقل تعداد راس است 3. چند ضلعی باید ثابت باشد. -- این تابع همچنین از چند ضلعی با سوراخ (برش بخش). در این مورد, اضافه چند ضلعی است که تعریف بخش برش با استفاده از استدلال های اضافی از تابع. تابع چند ضلعی غیر به سادگی متصل را پشتیبانی نمی کند. - -**مقادیر بازگشتی** - -`1` اگر نقطه در داخل چند ضلعی باشد, `0` اگر این طور نیست. -اگر نقطه در مرز چند ضلعی, تابع ممکن است یا بازگشت 0 یا 1. - -**مثال** - -``` sql -SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## کد جغرافیایی {#geohashencode} - -کد طول و عرض جغرافیایی به عنوان یک geohash-رشته مراجعه کنید (http://geohash.org/, https://en.wikipedia.org/wiki/geohash). - -``` sql -geohashEncode(longitude, latitude, [precision]) -``` - -**مقادیر ورودی** - -- طول جغرافیایی-طول جغرافیایی بخشی از مختصات شما می خواهید به رمز. شناور در محدوده`[-180°, 180°]` -- عرض جغرافیایی-عرض جغرافیایی بخشی از مختصات شما می خواهید به رمز. شناور در محدوده `[-90°, 90°]` -- دقت-اختیاری, طول رشته کد گذاری نتیجه, به طور پیش فرض به `12`. عدد صحیح در محدوده `[1, 12]`. هر مقدار کمتر از `1` یا بیشتر از `12` در سکوت به تبدیل `12`. - -**مقادیر بازگشتی** - -- عدد و الفبایی `String` مختصات کد گذاری شده (نسخه اصلاح شده از الفبای باس32 رمزگذاری استفاده شده است). - -**مثال** - -``` sql -SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res -``` - -``` text -┌─res──────────┐ -│ ezs42d000000 │ -└──────────────┘ -``` - -## کد جغرافیایی {#geohashdecode} - -هر رشته جغرافیایی کد گذاری به طول و عرض جغرافیایی را رمزگشایی می کند. - -**مقادیر ورودی** - -- رشته کد گذاری-رشته جغرافیایی کد گذاری. - -**مقادیر بازگشتی** - -- (طول جغرافیایی, عرض جغرافیایی) - 2-تاپل از `Float64` ارزش طول و عرض جغرافیایی. - -**مثال** - -``` sql -SELECT geohashDecode('ezs42') AS res -``` - -``` text -┌─res─────────────────────────────┐ -│ (-5.60302734375,42.60498046875) │ -└─────────────────────────────────┘ -``` - -## جغرافیایی 3 {#geotoh3} - -بازگشت [H3](https://uber.github.io/h3/#/documentation/overview/introduction) شاخص نقطه `(lon, lat)` با وضوح مشخص شده است. - -[H3](https://uber.github.io/h3/#/documentation/overview/introduction) یک سیستم نمایه سازی جغرافیایی است که سطح زمین به کاشی های شش ضلعی حتی تقسیم شده است. این سیستم سلسله مراتبی است, به عنوان مثال. هر شش گوش در سطح بالا را می توان به هفت حتی اما کوچکتر و به همین ترتیب تقسیم. - -این شاخص در درجه اول برای مکان های جفتک انداختن و دیگر دستکاری های جغرافیایی استفاده می شود. - -**نحو** - -``` sql -geoToH3(lon, lat, resolution) -``` - -**پارامترها** - -- `lon` — Longitude. Type: [جسم شناور64](../../sql_reference/data_types/float.md). -- `lat` — Latitude. Type: [جسم شناور64](../../sql_reference/data_types/float.md). -- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- عدد شاخص شش گوش. -- 0 در صورت خطا. - -نوع: `UInt64`. - -**مثال** - -پرسوجو: - -``` sql -SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index -``` - -نتیجه: - -``` text -┌────────────h3Index─┐ -│ 644325524701193974 │ -└────────────────────┘ -``` - -## جعبه جواهر {#geohashesinbox} - -بازگرداندن مجموعه ای از رشته های جغرافیایی کد گذاری شده از دقت داده شده است که در داخل و تقاطع مرزهای جعبه داده شده قرار می گیرند, اساسا یک شبکه 2د مسطح به مجموعه. - -**مقادیر ورودی** - -- طولی-دقیقه طول جغرافیایی, ارزش شناور در محدوده `[-180°, 180°]` -- عرضی-دقیقه عرض جغرافیایی, ارزش شناور در محدوده `[-90°, 90°]` -- طولی-حداکثر طول جغرافیایی, ارزش شناور در محدوده `[-180°, 180°]` -- عرضی-حداکثر عرض جغرافیایی, ارزش شناور در محدوده `[-90°, 90°]` -- دقت-جغرافیایی دقیق, `UInt8` در محدوده `[1, 12]` - -لطفا توجه داشته باشید که تمام پارامترهای هماهنگ باید از همان نوع باشد: هم `Float32` یا `Float64`. - -**مقادیر بازگشتی** - -- مجموعه ای از رشته های دقت طولانی از زمینهاش جعبه پوشش منطقه فراهم, شما باید به ترتیب از اقلام تکیه نمی. -- \[\]- مجموعه خالی اگر *کمینه* ارزش *عرض جغرافیایی* و *طول جغرافیایی* کمتر از متناظر نیست *حداکثر* ارزشهای خبری عبارتند از: - -لطفا توجه داشته باشید که عملکرد یک استثنا را پرتاب می کند اگر مجموعه ای بیش از 10'000'000 باشد. - -**مثال** - -``` sql -SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos -``` - -``` text -┌─thasos──────────────────────────────────────┐ -│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ -└─────────────────────────────────────────────┘ -``` - -## هد3گتاسکل {#h3getbasecell} - -بازگرداندن تعداد سلول پایه از شاخص. - -**نحو** - -``` sql -h3GetBaseCell(index) -``` - -**پارامترها** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- شش گوش شماره سلول پایه. نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3GetBaseCell(612916788725809151) as basecell -``` - -نتیجه: - -``` text -┌─basecell─┐ -│ 12 │ -└──────────┘ -``` - -## ه3حکسرام2 {#h3hexaream2} - -میانگین منطقه شش گوش در متر مربع در وضوح داده شده. - -**نحو** - -``` sql -h3HexAreaM2(resolution) -``` - -**پارامترها** - -- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- Area in m². Type: [جسم شناور64](../../sql_reference/data_types/float.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3HexAreaM2(13) as area -``` - -نتیجه: - -``` text -┌─area─┐ -│ 43.9 │ -└──────┘ -``` - -## در حال بارگذاری {#h3indexesareneighbors} - -بازده یا نه فراهم هیندکس همسایه هستند. - -**نحو** - -``` sql -h3IndexesAreNeighbors(index1, index2) -``` - -**پارامترها** - -- `index1` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `index2` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- بازگشت `1` اگر شاخص همسایه هستند, `0` وگرنه نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3IndexesAreNeighbors(617420388351344639, 617420388352655359) AS n -``` - -نتیجه: - -``` text -┌─n─┐ -│ 1 │ -└───┘ -``` - -## بچه گانه های 3 {#h3tochildren} - -بازگرداندن مجموعه ای با شاخص کودک از شاخص داده. - -**نحو** - -``` sql -h3ToChildren(index, resolution) -``` - -**پارامترها** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- با شاخص های اچ 3 کودک تنظیم کنید. مجموعه ای از نوع: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3ToChildren(599405990164561919, 6) AS children -``` - -نتیجه: - -``` text -┌─children───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ [603909588852408319,603909588986626047,603909589120843775,603909589255061503,603909589389279231,603909589523496959,603909589657714687] │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## ساعت 3 {#h3toparent} - -بازگرداندن پدر و مادر (درشت) شاخص حاوی شاخص داده. - -**نحو** - -``` sql -h3ToParent(index, resolution) -``` - -**پارامترها** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `resolution` — Index resolution. Range: `[0, 15]`. نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- شاخص اچ 3 پدر و مادر. نوع: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3ToParent(599405990164561919, 3) as parent -``` - -نتیجه: - -``` text -┌─────────────parent─┐ -│ 590398848891879423 │ -└────────────────────┘ -``` - -## اچ 3 {#h3tostring} - -تبدیل نمایندگی هیندکس از شاخص به نمایندگی رشته. - -``` sql -h3ToString(index) -``` - -**پارامترها** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- نمایندگی رشته از شاخص اچ 3. نوع: [رشته](../../sql_reference/data_types/string.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3ToString(617420388352917503) as h3_string -``` - -نتیجه: - -``` text -┌─h3_string───────┐ -│ 89184926cdbffff │ -└─────────────────┘ -``` - -## استراینگتوه3 {#stringtoh3} - -تبدیل رشته به نمایندگی h3index (uint64) نمایندگی. - -``` sql -stringToH3(index_str) -``` - -**پارامترها** - -- `index_str` — String representation of the H3 index. Type: [رشته](../../sql_reference/data_types/string.md). - -**مقادیر بازگشتی** - -- عدد شاخص شش گوش. بازده 0 در خطا. نوع: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT stringToH3('89184926cc3ffff') as index -``` - -نتیجه: - -``` text -┌──────────────index─┐ -│ 617420388351344639 │ -└────────────────────┘ -``` - -## انتقال انرژی 3 {#h3getresolution} - -بازگرداندن وضوح از شاخص. - -**نحو** - -``` sql -h3GetResolution(index) -``` - -**پارامترها** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مقادیر بازگشتی** - -- وضوح صفحه اول. گستره: `[0, 15]`. نوع: [UInt8](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT h3GetResolution(617420388352917503) as res -``` - -نتیجه: - -``` text -┌─res─┐ -│ 9 │ -└─────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/fa/sql_reference/functions/hash_functions.md b/docs/fa/sql_reference/functions/hash_functions.md deleted file mode 100644 index 71ca3660ccf..00000000000 --- a/docs/fa/sql_reference/functions/hash_functions.md +++ /dev/null @@ -1,446 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 50 -toc_title: "\u0647\u0634" ---- - -# توابع هش {#hash-functions} - -توابع هش را می توان برای زدن شبه تصادفی قطعی از عناصر استفاده می شود. - -## نیم مترد5 {#hash-functions-halfmd5} - -[تفسیر](../../sql_reference/functions/type_conversion_functions.md#type_conversion_functions-reinterpretAsString) تمام پارامترهای ورودی به عنوان رشته ها و محاسبه [MD5](https://en.wikipedia.org/wiki/MD5) ارزش هش برای هر یک از. سپس هش ها را ترکیب می کند و اولین بایت 8 هش رشته حاصل را می گیرد و به عنوان تفسیر می کند `UInt64` به ترتیب بایت بزرگ اندی. - -``` sql -halfMD5(par1, ...) -``` - -تابع نسبتا کند است (5 میلیون رشته کوتاه در هر ثانیه در هر هسته پردازنده). -در نظر بگیرید با استفاده از [سیفون64](#hash_functions-siphash64) تابع به جای. - -**پارامترها** - -تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -A [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. - -**مثال** - -``` sql -SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type -``` - -``` text -┌────────halfMD5hash─┬─type───┐ -│ 186182704141653334 │ UInt64 │ -└────────────────────┴────────┘ -``` - -## MD5 {#hash_functions-md5} - -محاسبه ام دی 5 از یک رشته و مجموعه ای در نتیجه از بایت به عنوان رشته ثابت را برمی گرداند(16). -اگر شما ام دی 5 به طور خاص نیاز ندارد, اما شما نیاز به یک رمزنگاری مناسب و معقول هش 128 بیتی, استفاده از ‘sipHash128’ تابع به جای. -اگر شما می خواهید برای دریافت همان نتیجه به عنوان خروجی توسط ابزار موسسه خدمات مالی, استفاده از پایین تر(سحر و جادو کردن(توسعه هزاره5(بازدید کنندگان))). - -## سیفون64 {#hash_functions-siphash64} - -تولید 64 بیتی [سیفون](https://131002.net/siphash/) مقدار هش. - -``` sql -sipHash64(par1,...) -``` - -این یک تابع هش رمزنگاری است. این کار حداقل سه بار سریع تر از [MD5](#hash_functions-md5) تابع. - -تابع [تفسیر](../../sql_reference/functions/type_conversion_functions.md#type_conversion_functions-reinterpretAsString) تمام پارامترهای ورودی به عنوان رشته و محاسبه مقدار هش برای هر یک از. سپس هش ها را با الگوریتم زیر ترکیب می کند: - -1. پس از هش کردن تمام پارامترهای ورودی, تابع می شود مجموعه ای از رشته هش. -2. تابع عناصر اول و دوم را می گیرد و هش را برای مجموعه ای از این موارد محاسبه می کند. -3. سپس تابع مقدار هش را محاسبه می کند که در مرحله قبل محاسبه می شود و عنصر سوم هش های اولیه را محاسبه می کند و هش را برای مجموعه ای از انها محاسبه می کند. -4. گام قبلی برای تمام عناصر باقی مانده از مجموعه هش اولیه تکرار شده است. - -**پارامترها** - -تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -A [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. - -**مثال** - -``` sql -SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type -``` - -``` text -┌──────────────SipHash─┬─type───┐ -│ 13726873534472839665 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## سیفون128 {#hash_functions-siphash128} - -محاسبه سیفون از یک رشته. -می پذیرد استدلال رشته از نوع. را برمی گرداند رشته ثابت (16). -متفاوت از سیفون64 در که حالت نهایی صخره نوردی تاشو تنها تا 128 بیت انجام می شود. - -## 4تیهاش64 {#cityhash64} - -تولید 64 بیتی [هشدار داده می شود](https://github.com/google/cityhash) مقدار هش. - -``` sql -cityHash64(par1,...) -``` - -این یک تابع هش غیر رمزنگاری سریع است. با استفاده از الگوریتم سیتیاش برای پارامترهای رشته و اجرای خاص تابع هش غیر رمزنگاری سریع برای پارامترهای با انواع داده های دیگر. این تابع از ترکیب کننده سیتیاش برای دریافت نتایج نهایی استفاده می کند. - -**پارامترها** - -تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -A [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. - -**مثالها** - -مثال تماس: - -``` sql -SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type -``` - -``` text -┌─────────────CityHash─┬─type───┐ -│ 12072650598913549138 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -مثال زیر نشان می دهد که چگونه برای محاسبه کنترلی از کل جدول با دقت تا سفارش ردیف: - -``` sql -SELECT groupBitXor(cityHash64(*)) FROM table -``` - -## اینتش32 {#inthash32} - -محاسبه یک کد هش 32 بیتی از هر نوع عدد صحیح. -این یک تابع هش غیر رمزنگاری نسبتا سریع از کیفیت متوسط برای اعداد است. - -## اینتاش64 {#inthash64} - -محاسبه یک کد هش 64 بیتی از هر نوع عدد صحیح. -این کار سریع تر از اینتش32. میانگین کیفیت. - -## SHA1 {#sha1} - -## SHA224 {#sha224} - -## SHA256 {#sha256} - -محاسبه شا-1, شا-224, یا شا-256 از یک رشته و مجموعه ای در نتیجه از بایت به عنوان رشته گرداند(20), رشته ثابت(28), و یا رشته ثابت(32). -تابع کار می کند نسبتا کند (شا-1 پردازش در مورد 5 میلیون رشته کوتاه در هر ثانیه در هر هسته پردازنده, در حالی که شا-224 و شا-256 روند در مورد 2.2 میلیون). -ما توصیه می کنیم با استفاده از این تابع تنها در مواردی که شما نیاز به یک تابع هش خاص و شما می توانید انتخاب کنید. -حتی در این موارد توصیه می شود که از تابع به صورت افلاین استفاده کنید و مقادیر قبل از محاسبه هنگام وارد کردن جدول به جای استفاده در انتخاب ها. - -## نشانی اینترنتی\]) {#urlhashurl-n} - -یک تابع هش غیر رمزنگاری سریع و با کیفیت مناسب برای یک رشته از یک نشانی وب با استفاده از نوعی عادی سازی. -`URLHash(s)` – Calculates a hash from a string without one of the trailing symbols `/`,`?` یا `#` در پایان, اگر در حال حاضر. -`URLHash(s, N)` – Calculates a hash from a string up to the N level in the URL hierarchy, without one of the trailing symbols `/`,`?` یا `#` در پایان, اگر در حال حاضر. -سطح همان است که در هرج و مرج است. این تابع خاص به یاندکس است.متریکا - -## فرمان 64 {#farmhash64} - -تولید 64 بیتی [مزرعه دار](https://github.com/google/farmhash) مقدار هش. - -``` sql -farmHash64(par1, ...) -``` - -تابع با استفاده از `Hash64` روش از همه [روش های موجود](https://github.com/google/farmhash/blob/master/src/farmhash.h). - -**پارامترها** - -تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -A [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. - -**مثال** - -``` sql -SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type -``` - -``` text -┌─────────────FarmHash─┬─type───┐ -│ 17790458267262532859 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## جواهاش {#hash_functions-javahash} - -محاسبه [جواهاش](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) از یک رشته. این تابع هش نه سریع و نه با کیفیت خوب است. تنها دلیل استفاده از این است که این الگوریتم در حال حاضر در سیستم دیگری استفاده می شود و شما باید دقیقا همان نتیجه را محاسبه کنید. - -**نحو** - -``` sql -SELECT javaHash(''); -``` - -**مقدار بازگشتی** - -A `Int32` نوع داده مقدار هش. - -**مثال** - -پرسوجو: - -``` sql -SELECT javaHash('Hello, world!'); -``` - -نتیجه: - -``` text -┌─javaHash('Hello, world!')─┐ -│ -1880044555 │ -└───────────────────────────┘ -``` - -## جواهرشوتف16 {#javahashutf16le} - -محاسبه [جواهاش](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) از یک رشته, فرض کنید که شامل بایت به نمایندگی از یک رشته در رمزگذاری اوت-16ل. - -**نحو** - -``` sql -javaHashUTF16LE(stringUtf16le) -``` - -**پارامترها** - -- `stringUtf16le` — a string in UTF-16LE encoding. - -**مقدار بازگشتی** - -A `Int32` نوع داده مقدار هش. - -**مثال** - -درست پرس و جو با utf-16le کد گذاری رشته است. - -پرسوجو: - -``` sql -SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) -``` - -نتیجه: - -``` text -┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ -│ 3556498 │ -└──────────────────────────────────────────────────────────────┘ -``` - -## هیوهاش {#hash-functions-hivehash} - -محاسبه `HiveHash` از یک رشته. - -``` sql -SELECT hiveHash(''); -``` - -این فقط [جواهاش](#hash_functions-javahash) با کمی نشانه صفر کردن. این تابع در استفاده [زنبورک کندو](https://en.wikipedia.org/wiki/Apache_Hive) برای نسخه های قبل از 3.0. این تابع هش نه سریع و نه با کیفیت خوب است. تنها دلیل استفاده از این است که این الگوریتم در حال حاضر در سیستم دیگری استفاده می شود و شما باید دقیقا همان نتیجه را محاسبه کنید. - -**مقدار بازگشتی** - -A `Int32` نوع داده مقدار هش. - -نوع: `hiveHash`. - -**مثال** - -پرسوجو: - -``` sql -SELECT hiveHash('Hello, world!'); -``` - -نتیجه: - -``` text -┌─hiveHash('Hello, world!')─┐ -│ 267439093 │ -└───────────────────────────┘ -``` - -## متروهاش64 {#metrohash64} - -تولید 64 بیتی [متروهاش](http://www.jandrewrogers.com/2015/05/27/metrohash/) مقدار هش. - -``` sql -metroHash64(par1, ...) -``` - -**پارامترها** - -تابع طول می کشد تعداد متغیر پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -A [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. - -**مثال** - -``` sql -SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type -``` - -``` text -┌────────────MetroHash─┬─type───┐ -│ 14235658766382344533 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## مورد احترام {#jumpconsistenthash} - -محاسبه jumpconsistenthash فرم uint64. -می پذیرد دو استدلال: یک کلید بین 64 نوع و تعداد سطل. بازده int32. -برای کسب اطلاعات بیشتر به لینک مراجعه کنید: [مورد احترام](https://arxiv.org/pdf/1406.2294.pdf) - -## سوفلش2\_32, سوفلشه2\_64 {#murmurhash2-32-murmurhash2-64} - -تولید یک [زمزمه 2](https://github.com/aappleby/smhasher) مقدار هش. - -``` sql -murmurHash2_32(par1, ...) -murmurHash2_64(par1, ...) -``` - -**پارامترها** - -هر دو توابع را به تعداد متغیر از پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -- این `murmurHash2_32` تابع را برمی گرداند مقدار هش داشتن [UInt32](../../sql_reference/data_types/int_uint.md) نوع داده. -- این `murmurHash2_64` تابع را برمی گرداند مقدار هش داشتن [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده. - -**مثال** - -``` sql -SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type -``` - -``` text -┌──────────MurmurHash2─┬─type───┐ -│ 11832096901709403633 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## سوفلش3\_32, سوفلشه3\_64 {#murmurhash3-32-murmurhash3-64} - -تولید یک [سوفلهاش3](https://github.com/aappleby/smhasher) مقدار هش. - -``` sql -murmurHash3_32(par1, ...) -murmurHash3_64(par1, ...) -``` - -**پارامترها** - -هر دو توابع را به تعداد متغیر از پارامترهای ورودی. پارامترها می توانند هر یک از [انواع داده های پشتیبانی شده](../../sql_reference/data_types/index.md). - -**مقدار بازگشتی** - -- این `murmurHash3_32` تابع یک [UInt32](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. -- این `murmurHash3_64` تابع یک [UInt64](../../sql_reference/data_types/int_uint.md) نوع داده مقدار هش. - -**مثال** - -``` sql -SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3─┬─type───┐ -│ 2152717 │ UInt32 │ -└─────────────┴────────┘ -``` - -## سوفلش3\_128 {#murmurhash3-128} - -تولید 128 بیتی [سوفلهاش3](https://github.com/aappleby/smhasher) مقدار هش. - -``` sql -murmurHash3_128( expr ) -``` - -**پارامترها** - -- `expr` — [عبارتها](../syntax.md#syntax-expressions) بازگشت یک [رشته](../../sql_reference/data_types/string.md)- نوع ارزش. - -**مقدار بازگشتی** - -A [رشته ثابت (16)](../../sql_reference/data_types/fixedstring.md) نوع داده مقدار هش. - -**مثال** - -``` sql -SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3──────┬─type────────────┐ -│ 6�1�4"S5KT�~~q │ FixedString(16) │ -└──────────────────┴─────────────────┘ -``` - -## بیست و 3264 {#hash-functions-xxhash32} - -محاسبه `xxHash` از یک رشته. این است که در دو طعم پیشنهاد, 32 و 64 بیت. - -``` sql -SELECT xxHash32(''); - -OR - -SELECT xxHash64(''); -``` - -**مقدار بازگشتی** - -A `Uint32` یا `Uint64` نوع داده مقدار هش. - -نوع: `xxHash`. - -**مثال** - -پرسوجو: - -``` sql -SELECT xxHash32('Hello, world!'); -``` - -نتیجه: - -``` text -┌─xxHash32('Hello, world!')─┐ -│ 834093149 │ -└───────────────────────────┘ -``` - -**همچنین نگاه کنید به** - -- [معلم](http://cyan4973.github.io/xxHash/). - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/fa/sql_reference/functions/higher_order_functions.md b/docs/fa/sql_reference/functions/higher_order_functions.md deleted file mode 100644 index 44e7469a5f7..00000000000 --- a/docs/fa/sql_reference/functions/higher_order_functions.md +++ /dev/null @@ -1,264 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 57 -toc_title: "\u0628\u0627\u0644\u0627\u062A\u0631 \u0633\u0641\u0627\u0631\u0634" ---- - -# توابع مرتبه بالاتر {#higher-order-functions} - -## `->` اپراتور, لامبدا (پارامترهای, اکسپر) تابع {#operator-lambdaparams-expr-function} - -Allows describing a lambda function for passing to a higher-order function. The left side of the arrow has a formal parameter, which is any ID, or multiple formal parameters – any IDs in a tuple. The right side of the arrow has an expression that can use these formal parameters, as well as any table columns. - -مثالها: `x -> 2 * x, str -> str != Referer.` - -توابع مرتبه بالاتر تنها می تواند توابع لامبدا به عنوان استدلال عملکردی خود را قبول. - -یک تابع لامبدا که استدلال های متعدد می پذیرد را می توان به یک تابع مرتبه بالاتر منتقل می شود. در این مورد, تابع مرتبه بالاتر به تصویب می رسد چند مجموعه ای از طول یکسان است که این استدلال به مطابقت. - -برای برخی از توابع مانند [پیاده کردن](#higher_order_functions-array-count) یا [ارریسوم](#higher_order_functions-array-count), استدلال اول (تابع لامبدا) را می توان حذف. در این مورد, نقشه برداری یکسان فرض شده است. - -یک تابع لامبدا را نمی توان برای توابع زیر حذف کرد: - -- [اررایماپ](#higher_order_functions-array-map) -- [شلوار لی](#higher_order_functions-array-filter) -- [شلوار لی](#higher_order_functions-array-fill) -- [نمایش سایت](#higher_order_functions-array-reverse-fill) -- [لرزش دستگاه](#higher_order_functions-array-split) -- [نمایش سایت](#higher_order_functions-array-reverse-split) -- [دریافیرست](#higher_order_functions-array-first) -- [نمایش سایت](#higher_order_functions-array-first-index) - -### arrayMap(func, arr1, …) {#higher_order_functions-array-map} - -بازگرداندن مجموعه ای از برنامه اصلی `func` عملکرد به هر عنصر در `arr` صف کردن. - -مثالها: - -``` sql -SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,4,5] │ -└─────────┘ -``` - -مثال زیر نشان می دهد که چگونه برای ایجاد یک تاپل از عناصر از مجموعه های مختلف: - -``` sql -SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res -``` - -``` text -┌─res─────────────────┐ -│ [(1,4),(2,5),(3,6)] │ -└─────────────────────┘ -``` - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayMap` تابع. - -### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} - -بازگرداندن مجموعه ای حاوی تنها عناصر در `arr1` برای کدام `func` چیزی غیر از 0 را برمی گرداند. - -مثالها: - -``` sql -SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res -``` - -``` text -┌─res───────────┐ -│ ['abc World'] │ -└───────────────┘ -``` - -``` sql -SELECT - arrayFilter( - (i, x) -> x LIKE '%World%', - arrayEnumerate(arr), - ['Hello', 'abc World'] AS arr) - AS res -``` - -``` text -┌─res─┐ -│ [2] │ -└─────┘ -``` - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFilter` تابع. - -### arrayFill(func, arr1, …) {#higher_order_functions-array-fill} - -پویش از طریق `arr1` از عنصر اول به عنصر گذشته و جایگزین `arr1[i]` توسط `arr1[i - 1]` اگر `func` بازده 0. اولین عنصر `arr1` جایگزین نخواهد شد. - -مثالها: - -``` sql -SELECT arrayFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res -``` - -``` text -┌─res──────────────────────────────┐ -│ [1,1,3,11,12,12,12,5,6,14,14,14] │ -└──────────────────────────────────┘ -``` - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFill` تابع. - -### arrayReverseFill(func, arr1, …) {#higher_order_functions-array-reverse-fill} - -پویش از طریق `arr1` از عنصر گذشته به عنصر اول و جایگزین `arr1[i]` توسط `arr1[i + 1]` اگر `func` بازده 0. عنصر گذشته از `arr1` جایگزین نخواهد شد. - -مثالها: - -``` sql -SELECT arrayReverseFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res -``` - -``` text -┌─res────────────────────────────────┐ -│ [1,3,3,11,12,5,5,5,6,14,NULL,NULL] │ -└────────────────────────────────────┘ -``` - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayReverseFill` تابع. - -### arraySplit(func, arr1, …) {#higher_order_functions-array-split} - -شکافتن `arr1` به چندین ردیف چه زمانی `func` بازگرداندن چیزی غیر از 0, مجموعه خواهد شد در سمت چپ عنصر تقسیم. مجموعه قبل از اولین عنصر تقسیم نخواهد شد. - -مثالها: - -``` sql -SELECT arraySplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res -``` - -``` text -┌─res─────────────┐ -│ [[1,2,3],[4,5]] │ -└─────────────────┘ -``` - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arraySplit` تابع. - -### arrayReverseSplit(func, arr1, …) {#higher_order_functions-array-reverse-split} - -شکافتن `arr1` به چندین ردیف چه زمانی `func` بازگرداندن چیزی غیر از 0, مجموعه خواهد شد در سمت راست عنصر تقسیم. مجموعه پس از عنصر گذشته تقسیم نخواهد شد. - -مثالها: - -``` sql -SELECT arrayReverseSplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res -``` - -``` text -┌─res───────────────┐ -│ [[1],[2,3,4],[5]] │ -└───────────────────┘ -``` - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arraySplit` تابع. - -### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} - -بازگرداندن تعدادی از عناصر در مجموعه ارر که فارک چیزی غیر از گرداند 0. اگر ‘func’ مشخص نشده است, تعداد عناصر غیر صفر گرداند در مجموعه. - -### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} - -بازده 1 اگر حداقل یک عنصر در وجود دارد ‘arr’ برای کدام ‘func’ چیزی غیر از 0 را برمی گرداند. در غیر این صورت, باز می گردد 0. - -### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} - -بازده 1 اگر ‘func’ چیزی غیر از 0 را برای تمام عناصر در ‘arr’. در غیر این صورت, باز می گردد 0. - -### arraySum(\[func,\] arr1, …) {#higher-order-functions-array-sum} - -بازگرداندن مجموع ‘func’ ارزشهای خبری عبارتند از: اگر تابع حذف شده است, فقط می گرداند مجموع عناصر مجموعه. - -### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} - -بازگرداندن اولین عنصر در ‘arr1’ تنظیم برای کدام ‘func’ چیزی غیر از 0 را برمی گرداند. - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFirst` تابع. - -### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} - -بازگرداندن شاخص عنصر اول در ‘arr1’ تنظیم برای کدام ‘func’ چیزی غیر از 0 را برمی گرداند. - -توجه داشته باشید که استدلال اول (تابع لامبدا) را نمی توان در حذف `arrayFirstIndex` تابع. - -### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} - -بازگرداندن مجموعه ای از مبالغ بخشی از عناصر در مجموعه منبع (مجموع در حال اجرا). اگر `func` تابع مشخص شده است, سپس ارزش عناصر مجموعه توسط این تابع قبل از جمع تبدیل. - -مثال: - -``` sql -SELECT arrayCumSum([1, 1, 1, 1]) AS res -``` - -``` text -┌─res──────────┐ -│ [1, 2, 3, 4] │ -└──────────────┘ -``` - -### هشدار داده می شود) {#arraycumsumnonnegativearr} - -مثل `arrayCumSum`, بازگرداندن مجموعه ای از مبالغ بخشی از عناصر در مجموعه منبع (مجموع در حال اجرا). متفاوت `arrayCumSum`, هنگامی که ارزش سپس بازگشت شامل یک مقدار کمتر از صفر, ارزش است جایگزین با صفر و محاسبه بعدی با صفر پارامترهای انجام. به عنوان مثال: - -``` sql -SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,0,1] │ -└───────────┘ -``` - -### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} - -بازگرداندن مجموعه ای به عنوان نتیجه مرتب سازی عناصر `arr1` به ترتیب صعودی. اگر `func` تابع مشخص شده است, مرتب سازی سفارش توسط نتیجه تابع تعیین `func` اعمال شده به عناصر مجموعه (ارریس) - -این [تبدیل شوارتز](https://en.wikipedia.org/wiki/Schwartzian_transform) برای بهبود کارایی مرتب سازی استفاده می شود. - -مثال: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -برای کسب اطلاعات بیشتر در مورد `arraySort` روش, دیدن [توابع برای کار با ارریس](array_functions.md#array_functions-sort) بخش. - -### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} - -بازگرداندن مجموعه ای به عنوان نتیجه مرتب سازی عناصر `arr1` به ترتیب نزولی. اگر `func` تابع مشخص شده است, مرتب سازی سفارش توسط نتیجه تابع تعیین `func` اعمال شده به عناصر مجموعه ای (ارریس). - -مثال: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -برای کسب اطلاعات بیشتر در مورد `arrayReverseSort` روش, دیدن [توابع برای کار با ارریس](array_functions.md#array_functions-reverse-sort) بخش. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/fa/sql_reference/functions/in_functions.md b/docs/fa/sql_reference/functions/in_functions.md deleted file mode 100644 index 5beb072fad6..00000000000 --- a/docs/fa/sql_reference/functions/in_functions.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 60 -toc_title: "\u0627\u062C\u0631\u0627\u06CC \u0627\u067E\u0631\u0627\u062A\u0648\u0631\ - \ \u062F\u0631" ---- - -# توابع برای اجرای اپراتور در {#functions-for-implementing-the-in-operator} - -## در notIn, globalIn, globalNotIn {#in-functions} - -بخش را ببینید [در اپراتورها](../statements/select.md#select-in-operators). - -## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} - -یک تابع است که اجازه می دهد تا گروه بندی ستون های متعدد. -For columns with the types T1, T2, …, it returns a Tuple(T1, T2, …) type tuple containing these columns. There is no cost to execute the function. -تاپل به طور معمول به عنوان مقادیر متوسط برای بحث در اپراتورها و یا برای ایجاد یک لیست از پارامترهای رسمی توابع لامبدا استفاده می شود. تاپل را نمی توان به یک جدول نوشته شده است. - -## هشدار داده می شود {#tupleelementtuple-n-operator-x-n} - -یک تابع است که اجازه می دهد تا گرفتن یک ستون از یک تاپل. -‘N’ شاخص ستون است, با شروع از 1. نفر باید ثابت باشد. ‘N’ باید ثابت باشه ‘N’ باید یک عدد صحیح انتخابی سخت نه بیشتر از اندازه تاپل باشد. -هیچ هزینه ای برای اجرای تابع وجود دارد. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/fa/sql_reference/functions/index.md b/docs/fa/sql_reference/functions/index.md deleted file mode 100644 index 9d9679fca26..00000000000 --- a/docs/fa/sql_reference/functions/index.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Functions -toc_priority: 32 -toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" ---- - -# توابع {#functions} - -حداقل\* دو نوع از توابع وجود دارد - توابع به طور منظم (فقط به نام “functions”) and aggregate functions. These are completely different concepts. Regular functions work as if they are applied to each row separately (for each row, the result of the function doesn't depend on the other rows). Aggregate functions accumulate a set of values from various rows (i.e. they depend on the entire set of rows). - -در این بخش ما در مورد توابع به طور منظم. برای توابع کل, بخش را ببینید “Aggregate functions”. - -\* - یک نوع سوم از تابع که وجود دارد ‘arrayJoin’ توابع جدول همچنین می توانید به طور جداگانه ذکر شود.\* - -## تایپ قوی {#strong-typing} - -در مقابل به گذاشتن استاندارد, خانه رعیتی است تایپ قوی. به عبارت دیگر تبدیل ضمنی بین انواع را ندارد. هر تابع برای یک مجموعه خاص از انواع کار می کند. این به این معنی است که گاهی اوقات شما نیاز به استفاده از توابع تبدیل نوع. - -## رفع ضعف مشترک {#common-subexpression-elimination} - -همه عبارات در پرس و جو که همان اعضای هیات (همان رکورد و یا همان نتیجه تجزیه نحوی) در نظر گرفته به ارزش یکسان. چنین عبارات یک بار تایید و اجرا می شوند. زیرمجموعه های یکسان نیز این راه را حذف می کنند. - -## انواع نتایج {#types-of-results} - -همه توابع بازگشت بازگشت بازگشت تنها به عنوان نتیجه (چند ارزش نیست, و نه صفر ارزش). نوع نتیجه است که معمولا تنها با انواع استدلال تعریف, نه با ارزش. استثنا هستند tupleelement function (a.n اپراتور) و tofixedstring تابع. - -## ثابتها {#constants} - -برای سادگی, توابع خاص تنها می تواند با ثابت برای برخی از استدلال کار. مثلا, استدلال درست از اپراتور مانند باید ثابت باشد. -تقریبا تمام توابع بازگشت ثابت برای استدلال ثابت. استثنا توابع است که تولید اعداد تصادفی است. -این ‘now’ تابع مقادیر مختلف برای نمایش داده شد که در زمان های مختلف اجرا شد را برمی گرداند, اما نتیجه در نظر گرفته ثابت, از ثبات در یک پرس و جو تنها مهم است. -یک عبارت ثابت نیز ثابت در نظر گرفته (مثلا, نیمه راست اپراتور مانند را می توان از ثابت های متعدد ساخته). - -توابع را می توان به روش های مختلف برای استدلال ثابت و غیر ثابت اجرا (کد های مختلف اجرا شده است). اما نتایج برای یک ثابت و برای یک ستون واقعی حاوی تنها همان مقدار باید با یکدیگر مطابقت. - -## پردازش پوچ {#null-processing} - -توابع رفتارهای زیر را دارند: - -- اگر حداقل یکی از استدلال از تابع است `NULL` نتیجه عملکرد نیز است `NULL`. -- رفتار ویژه ای است که به صورت جداگانه در شرح هر تابع مشخص. در کد منبع کلیک این توابع `UseDefaultImplementationForNulls=false`. - -## پایداری {#constancy} - -Functions can't change the values of their arguments – any changes are returned as the result. Thus, the result of calculating separate functions does not depend on the order in which the functions are written in the query. - -## خطا {#error-handling} - -برخی از توابع ممکن است یک استثنا پرتاب اگر داده نامعتبر است. در این مورد پرس و جو لغو شده است و یک متن خطا به مشتری بازگردانده می شود. برای پردازش توزیع, هنگامی که یک استثنا در یکی از سرورهای رخ می دهد, سرور های دیگر نیز تلاش برای لغو پرس و جو. - -## ارزیابی عبارات استدلال {#evaluation-of-argument-expressions} - -تقریبا در تمام زبان های برنامه نویسی, یکی از استدلال ممکن است برای اپراتورهای خاص ارزیابی نمی شود. این است که معمولا اپراتورها `&&`, `||` و `?:`. -اما در فاحشه خانه, استدلال از توابع (اپراتورهای) همیشه مورد بررسی قرار. دلیل این است که کل بخش هایی از ستون ها در یک بار مورد بررسی قرار, به جای محاسبه هر سطر به طور جداگانه. - -## انجام توابع برای پردازش پرس و جو توزیع شده {#performing-functions-for-distributed-query-processing} - -برای پردازش پرس و جو توزیع, به عنوان بسیاری از مراحل پردازش پرس و جو که ممکن است بر روی سرور از راه دور انجام, و بقیه مراحل (ادغام نتایج متوسط و همه چیز که) بر روی سرور درخواست انجام. - -این به این معنی است که توابع را می توان بر روی سرور های مختلف انجام می شود. -برای مثال در پرس و جو `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` - -- اگر یک `distributed_table` دارای حداقل دو خرده ریز, توابع ‘g’ و ‘h’ بر روی سرورهای راه دور و عملکرد انجام می شود ‘f’ بر روی سرور درخواست کننده انجام می شود. -- اگر یک `distributed_table` تنها یک سفال, تمام ‘f’, ‘g’ و ‘h’ توابع بر روی سرور این سفال انجام. - -نتیجه یک تابع معمولا بستگی ندارد که سرور انجام شده است. اما گاهی اوقات این مهم است. -مثلا, توابع است که با لغت نامه کار استفاده از فرهنگ لغت که بر روی سرور وجود دارد که در حال اجرا هستند در. -مثال دیگر این است که `hostName` تابع, که نام سرور را بر می گرداند در حال اجرا است به منظور ایجاد `GROUP BY` توسط سرور در یک `SELECT` پرس و جو. - -اگر یک تابع در یک پرس و جو بر روی سرور درخواست انجام, اما شما نیاز به انجام این کار بر روی سرور از راه دور, شما می توانید در یک بسته بندی ‘any’ تابع جمع و یا اضافه کردن به یک کلید در `GROUP BY`. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/fa/sql_reference/functions/introspection.md b/docs/fa/sql_reference/functions/introspection.md deleted file mode 100644 index 6eb75456f08..00000000000 --- a/docs/fa/sql_reference/functions/introspection.md +++ /dev/null @@ -1,310 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 65 -toc_title: "\u062F\u0631\u0648\u0646 \u0646\u06AF\u0631\u06CC" ---- - -# توابع درون گرایی {#introspection-functions} - -شما می توانید توابع شرح داده شده در این فصل به درون نگری استفاده کنید [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) و [DWARF](https://en.wikipedia.org/wiki/DWARF) برای پروفایل پرس و جو. - -!!! warning "اخطار" - این توابع کند هستند و ممکن است ملاحظات امنیتی تحمیل کنند. - -برای بهره برداری مناسب از توابع درون گرایی: - -- نصب `clickhouse-common-static-dbg` بسته - -- تنظیم [اجازه دادن به \_فعال کردن اختلال در عملکرد](../../operations/settings/settings.md#settings-allow_introspection_functions) تنظیم به 1. - - For security reasons introspection functions are disabled by default. - -تاتر موجب صرفه جویی در گزارش نیمرخ به [\_قطع](../../operations/system_tables.md#system_tables-trace_log) جدول سیستم. اطمینان حاصل کنید که جدول و پیشفیلتر به درستی پیکربندی شده است. - -## افزودن مدخل جدید {#addresstoline} - -تبدیل آدرس حافظه مجازی در داخل clickhouse فرایند سرور به نام فایل و شماره خط در clickhouse کد منبع. - -اگر شما استفاده از بسته های رسمی تاتر, شما نیاز به نصب `clickhouse-common-static-dbg` بسته - -**نحو** - -``` sql -addressToLine(address_of_binary_instruction) -``` - -**پارامترها** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**مقدار بازگشتی** - -- نام فایل کد منبع و شماره خط در این فایل حد و مرز مشخصی توسط روده بزرگ. - - For example, `/build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.cpp:199`, where `199` is a line number. - -- نام یک باینری, اگر تابع می تواند اطلاعات اشکال زدایی پیدا کنید. - -- رشته خالی, اگر نشانی معتبر نیست. - -نوع: [رشته](../../sql_reference/data_types/string.md). - -**مثال** - -فعال کردن توابع درون گرایی: - -``` sql -SET allow_introspection_functions=1 -``` - -انتخاب رشته اول از `trace_log` جدول سیستم: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-19 -event_time: 2019-11-19 18:57:23 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 421b6855-1858-45a5-8f37-f383409d6d72 -trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] -``` - -این `trace` درست شامل ردیابی پشته در حال حاضر نمونه برداری. - -گرفتن نام فایل کد منبع و شماره خط برای یک نشانی واحد: - -``` sql -SELECT addressToLine(94784076370703) \G -``` - -``` text -Row 1: -────── -addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.cpp:199 -``` - -استفاده از تابع به ردیابی کل پشته: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines -FROM system.trace_log -LIMIT 1 -\G -``` - -این [اررایماپ](higher_order_functions.md#higher_order_functions-array-map) تابع اجازه می دهد تا برای پردازش هر عنصر منحصر به فرد از `trace` تنظیم توسط `addressToLine` تابع. در نتیجه این پردازش می بینید در `trace_source_code_lines` ستون خروجی. - -``` text -Row 1: -────── -trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so -/usr/lib/debug/usr/bin/clickhouse -/build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.cpp:199 -/build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.h:155 -/usr/include/c++/9/bits/atomic_base.h:551 -/usr/lib/debug/usr/bin/clickhouse -/lib/x86_64-linux-gnu/libpthread-2.27.so -/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -``` - -## افزودن موقعیت {#addresstosymbol} - -تبدیل آدرس حافظه مجازی در داخل clickhouse سرور روند به نمادی از clickhouse شی فایل های. - -**نحو** - -``` sql -addressToSymbol(address_of_binary_instruction) -``` - -**پارامترها** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**مقدار بازگشتی** - -- نمادی از clickhouse شی فایل های. -- رشته خالی, اگر نشانی معتبر نیست. - -نوع: [رشته](../../sql_reference/data_types/string.md). - -**مثال** - -فعال کردن توابع درون گرایی: - -``` sql -SET allow_introspection_functions=1 -``` - -انتخاب رشته اول از `trace_log` جدول سیستم: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -این `trace` درست شامل ردیابی پشته در حال حاضر نمونه برداری. - -گرفتن نماد برای یک نشانی واحد: - -``` sql -SELECT addressToSymbol(94138803686098) \G -``` - -``` text -Row 1: -────── -addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -``` - -استفاده از تابع به ردیابی کل پشته: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols -FROM system.trace_log -LIMIT 1 -\G -``` - -این [اررایماپ](higher_order_functions.md#higher_order_functions-array-map) تابع اجازه می دهد تا برای پردازش هر عنصر منحصر به فرد از `trace` تنظیم توسط `addressToSymbols` تابع. نتیجه این پردازش شما در دیدن `trace_symbols` ستون خروجی. - -``` text -Row 1: -────── -trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE -_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb -_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb -_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE -_ZN2DB27AggregatingBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB28AsynchronousBlockInputStream9calculateEv -_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data -_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E -_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv -_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E -execute_native_thread_routine -start_thread -clone -``` - -## درهم و برهم کردن {#demangle} - -تبدیل یک نماد است که شما می توانید با استفاده از [افزودن موقعیت](#addresstosymbol) تابع به ج++ نام تابع. - -**نحو** - -``` sql -demangle(symbol) -``` - -**پارامترها** - -- `symbol` ([رشته](../../sql_reference/data_types/string.md)) — Symbol from an object file. - -**مقدار بازگشتی** - -- نام تابع ج++. -- رشته خالی اگر یک نماد معتبر نیست. - -نوع: [رشته](../../sql_reference/data_types/string.md). - -**مثال** - -فعال کردن توابع درون گرایی: - -``` sql -SET allow_introspection_functions=1 -``` - -انتخاب رشته اول از `trace_log` جدول سیستم: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -این `trace` زمینه شامل ردیابی پشته در لحظه نمونه برداری. - -گرفتن نام تابع برای یک نشانی واحد: - -``` sql -SELECT demangle(addressToSymbol(94138803686098)) \G -``` - -``` text -Row 1: -────── -demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -``` - -استفاده از تابع به ردیابی کل پشته: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions -FROM system.trace_log -LIMIT 1 -\G -``` - -این [اررایماپ](higher_order_functions.md#higher_order_functions-array-map) تابع اجازه می دهد تا برای پردازش هر عنصر منحصر به فرد از `trace` تنظیم توسط `demangle` تابع. در نتیجه این پردازش می بینید در `trace_functions` ستون خروجی. - -``` text -Row 1: -────── -trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const -DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) -DB::AggregatingBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::AsynchronousBlockInputStream::calculate() -std::_Function_handler::_M_invoke(std::_Any_data const&) -ThreadPoolImpl::worker(std::_List_iterator) -ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const -ThreadPoolImpl::worker(std::_List_iterator) -execute_native_thread_routine -start_thread -clone -``` diff --git a/docs/fa/sql_reference/functions/ip_address_functions.md b/docs/fa/sql_reference/functions/ip_address_functions.md deleted file mode 100644 index fe4a6c7828e..00000000000 --- a/docs/fa/sql_reference/functions/ip_address_functions.md +++ /dev/null @@ -1,249 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 55 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0646\u0634\u0627\u0646\u06CC\u0647\u0627\ - \u06CC \u0627\u06CC\u0646\u062A\u0631\u0646\u062A\u06CC" ---- - -# توابع برای کار با نشانی های اینترنتی {#functions-for-working-with-ip-addresses} - -## اطلاعات دقیق) {#ipv4numtostringnum} - -طول می کشد یک uint32 شماره. به عنوان یک نشانی اینترنتی 4 در اندی بزرگ تفسیر می کند. بازده یک رشته حاوی مربوطه آدرس ipv4 در قالب a. b. c. d (نقطه جدا کردن اعداد در شکل اعشاری). - -## مدت 4 ساعت) {#ipv4stringtonums} - -عملکرد معکوس ایپو4نومتوسترینگ. اگر نشانی اینترنتی4 دارای یک فرمت نامعتبر, باز می گردد 0. - -## اطلاعات دقیق) {#ipv4numtostringclasscnum} - -شبیه به ipv4numtostring اما با استفاده از \ به جای گذشته هشت تایی. - -مثال: - -``` sql -SELECT - IPv4NumToStringClassC(ClientIP) AS k, - count() AS c -FROM test.hits -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─k──────────────┬─────c─┐ -│ 83.149.9.xxx │ 26238 │ -│ 217.118.81.xxx │ 26074 │ -│ 213.87.129.xxx │ 25481 │ -│ 83.149.8.xxx │ 24984 │ -│ 217.118.83.xxx │ 22797 │ -│ 78.25.120.xxx │ 22354 │ -│ 213.87.131.xxx │ 21285 │ -│ 78.25.121.xxx │ 20887 │ -│ 188.162.65.xxx │ 19694 │ -│ 83.149.48.xxx │ 17406 │ -└────────────────┴───────┘ -``` - -از زمان استفاده ‘xxx’ بسیار غیر معمول است, این ممکن است در اینده تغییر. ما توصیه می کنیم که شما در قالب دقیق این قطعه تکیه نمی. - -### اطلاعات دقیق) {#ipv6numtostringx} - -یک رشته ثابت(16) مقدار حاوی نشانی اینترنتی6 را در قالب باینری می پذیرد. بازگرداندن یک رشته حاوی این نشانی در قالب متن. -نشانی های ایپو6-نقشه برداری ایپو4 خروجی در قالب هستند:: افف:111.222.33.44. مثالها: - -``` sql -SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr -``` - -``` text -┌─addr─────────┐ -│ 2a02:6b8::11 │ -└──────────────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ -│ 2a02:2168:aaa:bbbb::2 │ 24695 │ -│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ -│ 2a02:6b8:0:fff::ff │ 16389 │ -│ 2a01:4f8:111:6666::2 │ 16016 │ -│ 2a02:2168:888:222::1 │ 15896 │ -│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ -│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ -│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ -│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ -│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ -└─────────────────────────────────────────┴───────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)─┬──────c─┐ -│ ::ffff:94.26.111.111 │ 747440 │ -│ ::ffff:37.143.222.4 │ 529483 │ -│ ::ffff:5.166.111.99 │ 317707 │ -│ ::ffff:46.38.11.77 │ 263086 │ -│ ::ffff:79.105.111.111 │ 186611 │ -│ ::ffff:93.92.111.88 │ 176773 │ -│ ::ffff:84.53.111.33 │ 158709 │ -│ ::ffff:217.118.11.22 │ 154004 │ -│ ::ffff:217.118.11.33 │ 148449 │ -│ ::ffff:217.118.11.44 │ 148243 │ -└────────────────────────────┴────────┘ -``` - -## مدت 6 ساعت) {#ipv6stringtonums} - -عملکرد معکوس ایپو6نومتوسترینگ. اگر نشانی اینترنتی6 دارای یک فرمت نامعتبر, یک رشته از بایت پوچ را برمی گرداند. -سحر و جادو می تواند بزرگ یا کوچک. - -## IPv4ToIPv6(x) {#ipv4toipv6x} - -طول می کشد یک `UInt32` شماره. تفسیر به عنوان یک نشانی اینترنتی4 در [اندی بزرگ](https://en.wikipedia.org/wiki/Endianness). بازگرداندن یک `FixedString(16)` مقدار حاوی نشانی اینترنتی6 در قالب دودویی. مثالها: - -``` sql -SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr -``` - -``` text -┌─addr───────────────┐ -│ ::ffff:192.168.0.1 │ -└────────────────────┘ -``` - -## cutIPv6(x bitsToCutForIPv6, bitsToCutForIPv4) {#cutipv6x-bitstocutforipv6-bitstocutforipv4} - -یک رشته ثابت(16) مقدار حاوی نشانی اینترنتی6 را در قالب باینری می پذیرد. بازگرداندن یک رشته حاوی نشانی از تعداد مشخصی از بیت در قالب متن حذف. به عنوان مثال: - -``` sql -WITH - IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, - IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 -SELECT - cutIPv6(ipv6, 2, 0), - cutIPv6(ipv4, 0, 2) -``` - -``` text -┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ -│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ -└─────────────────────────────────────┴─────────────────────┘ -``` - -## IPv4CIDRToRange(ipv4, cidr), {#ipv4cidrtorangeipv4-cidr} - -قبول یک ipv4 و uint8 ارزش شامل [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing). یک تاپل را با دو لیگ4 حاوی محدوده پایین تر و محدوده بالاتر زیر شبکه باز کنید. - -``` sql -SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) -``` - -``` text -┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ -│ ('192.168.0.0','192.168.255.255') │ -└────────────────────────────────────────────┘ -``` - -## IPv6CIDRToRange(ipv6 cidr), {#ipv6cidrtorangeipv6-cidr} - -قبول یک ipv6 و uint8 ارزش حاوی cidr. یک تاپل را با دو ایپو6 حاوی محدوده پایین تر و محدوده بالاتر زیر شبکه باز کنید. - -``` sql -SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); -``` - -``` text -┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ -│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ -└────────────────────────────────────────────────────────────────────────┘ -``` - -## تایپه 4 (رشته) {#toipv4string} - -یک نام مستعار برای `IPv4StringToNum()` که طول می کشد یک شکل رشته ای از ایپو4 نشانی و ارزش را برمی گرداند [IPv4](../../sql_reference/data_types/domains/ipv4.md) نوع باینری برابر با مقدار بازگشتی است `IPv4StringToNum()`. - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - toTypeName(IPv4StringToNum(IPv4_string)), - toTypeName(toIPv4(IPv4_string)) -``` - -``` text -┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ -│ UInt32 │ IPv4 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - hex(IPv4StringToNum(IPv4_string)), - hex(toIPv4(IPv4_string)) -``` - -``` text -┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ -│ ABE1822D │ ABE1822D │ -└───────────────────────────────────┴──────────────────────────┘ -``` - -## تیپو6 (رشته) {#toipv6string} - -یک نام مستعار برای `IPv6StringToNum()` که طول می کشد یک شکل رشته ای از ایپو6 نشانی و ارزش را برمی گرداند [IPv6](../../sql_reference/data_types/domains/ipv6.md) نوع باینری برابر با مقدار بازگشتی است `IPv6StringToNum()`. - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - toTypeName(IPv6StringToNum(IPv6_string)), - toTypeName(toIPv6(IPv6_string)) -``` - -``` text -┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ -│ FixedString(16) │ IPv6 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - hex(IPv6StringToNum(IPv6_string)), - hex(toIPv6(IPv6_string)) -``` - -``` text -┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ -│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ -└───────────────────────────────────┴──────────────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/fa/sql_reference/functions/json_functions.md b/docs/fa/sql_reference/functions/json_functions.md deleted file mode 100644 index fd5d30eaade..00000000000 --- a/docs/fa/sql_reference/functions/json_functions.md +++ /dev/null @@ -1,231 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 56 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u062C\u0627\u0646\u0633\u0648\u0646." ---- - -# توابع برای کار با جانسون {#functions-for-working-with-json} - -در یاندکسمتریکا جیسون توسط کاربران به عنوان پارامترهای جلسه منتقل می شود. برخی از توابع خاص برای کار با این جانسون وجود دارد. (اگر چه در بسیاری از موارد jsons هستند علاوه بر این قبل از پردازش و در نتیجه ارزش ها قرار داده و در ستون جداگانه در خود پردازش فرمت.) همه این توابع در فرضیات قوی در مورد چه جانسون می تواند بر اساس, اما سعی می کنند به عنوان کوچک که ممکن است به کار انجام می شود. - -مفروضات زیر ساخته شده است: - -1. نام فیلد (استدلال تابع) باید ثابت باشد. -2. نام فیلد به نحوی می تواند در جیسون کد گذاری شود. به عنوان مثال: `visitParamHas('{"abc":"def"}', 'abc') = 1` اما `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -3. زمینه ها برای در هر سطح تودرتو جستجو, یکسره. اگر زمینه های تطبیق های متعدد وجود دارد, وقوع اول استفاده شده است. -4. JSON ندارد کاراکتر فضای خارج از string literals. - -## ویسیتپراماس (پارامز, نام) {#visitparamhasparams-name} - -بررسی اینکه یک میدان با وجود ‘name’ اسم. - -## ویسیتپرامستراکتینت (پارامز, نام) {#visitparamextractuintparams-name} - -تجزیه ظاهری64 از ارزش این زمینه به نام ‘name’. اگر این یک رشته رشته زمینه, تلاش می کند به تجزیه یک عدد از ابتدای رشته. اگر میدان وجود ندارد, و یا وجود دارد اما حاوی یک عدد نیست, باز می گردد 0. - -## ویزیتپرامستراکتینت (پارامز, نام) {#visitparamextractintparams-name} - -همان int64. - -## اطلاعات دقیق) {#visitparamextractfloatparams-name} - -همان است که برای شناور64. - -## ویسیتپرامسترکتبولبولول (پارامز, نام) {#visitparamextractboolparams-name} - -تجزیه واقعی / ارزش کاذب. نتیجه این است uint8. - -## ویسیتپرمککتراو (پارامز, نام) {#visitparamextractrawparams-name} - -بازگرداندن ارزش یک میدان, از جمله جدا. - -مثالها: - -``` sql -visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' -visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' -``` - -## نام و نام خانوادگی) {#visitparamextractstringparams-name} - -تجزیه رشته در نقل قول دو. ارزش بی نتیجه است. اگر بیم شکست خورده, این یک رشته خالی می گرداند. - -مثالها: - -``` sql -visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' -visitParamExtractString('{"abc":"hello}', 'abc') = '' -``` - -در حال حاضر هیچ پشتیبانی برای نقاط کد در قالب وجود دارد `\uXXXX\uYYYY` این از هواپیما چند زبانه پایه نیست (به جای اوتو-8 تبدیل می شود). - -توابع زیر بر اساس [سیمدجسون](https://github.com/lemire/simdjson) طراحی شده برای نیازهای پیچیده تر جسون تجزیه. فرض 2 ذکر شده در بالا هنوز هم صدق. - -## هشدار داده می شود) {#isvalidjsonjson} - -چک که رشته گذشت جانسون معتبر است. - -مثالها: - -``` sql -SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 -SELECT isValidJSON('not a json') = 0 -``` - -## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} - -اگر مقدار در سند جسون وجود داشته باشد, `1` برگردانده خواهد شد. - -اگر این مقدار وجود ندارد, `0` برگردانده خواهد شد. - -مثالها: - -``` sql -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 -``` - -`indices_or_keys` لیستی از استدلال های صفر یا بیشتر است که هر کدام می توانند رشته یا عدد صحیح باشند. - -- رشته = عضو شی دسترسی های کلیدی. -- عدد صحیح مثبت = از ابتدا به عضو / کلید نفر دسترسی پیدا کنید. -- عدد صحیح منفی = دسترسی به عضو / کلید نفر از پایان. - -حداقل شاخص عنصر 1 است. بنابراین عنصر 0 وجود ندارد. - -شما می توانید از اعداد صحیح برای دسترسی به هر دو اشیای جسون ارریس و جسون استفاده کنید. - -بنابراین, مثلا: - -``` sql -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' -``` - -## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} - -بازگشت طول یک مجموعه جانسون یا یک شی جانسون. - -اگر مقدار وجود ندارد و یا دارای یک نوع اشتباه, `0` برگردانده خواهد شد. - -مثالها: - -``` sql -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 -``` - -## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} - -بازگشت به نوع یک مقدار جانسون. - -اگر این مقدار وجود ندارد, `Null` برگردانده خواهد شد. - -مثالها: - -``` sql -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' -``` - -## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} - -## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} - -## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} - -## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} - -تجزیه جانسون و استخراج ارزش. این توابع شبیه به `visitParam` توابع. - -اگر مقدار وجود ندارد و یا دارای یک نوع اشتباه, `0` برگردانده خواهد شد. - -مثالها: - -``` sql -SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 -SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 -SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 -``` - -## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} - -تجزیه جانسون و استخراج یک رشته. این تابع شبیه به `visitParamExtractString` توابع. - -اگر مقدار وجود ندارد و یا دارای یک نوع اشتباه, یک رشته خالی بازگردانده خواهد شد. - -ارزش بی نتیجه است. اگر بیم شکست خورده, این یک رشته خالی می گرداند. - -مثالها: - -``` sql -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' -SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' -SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' -``` - -## JSONExtract(json\[, indices\_or\_keys…\], return\_type) {#jsonextractjson-indices-or-keys-return-type} - -تجزیه یک جسون و استخراج یک مقدار از نوع داده داده داده کلیک. - -این یک تعمیم قبلی است `JSONExtract` توابع. -این به این معنی است -`JSONExtract(..., 'String')` بازده دقیقا همان `JSONExtractString()`, -`JSONExtract(..., 'Float64')` بازده دقیقا همان `JSONExtractFloat()`. - -مثالها: - -``` sql -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL -SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 -SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' -SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' -``` - -## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} - -پارسه جفت کلید ارزش از یک جانسون که ارزش از نوع داده داده خانه رعیتی هستند. - -مثال: - -``` sql -SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; -``` - -## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} - -بازگرداندن بخشی از جانسون. - -اگر بخش وجود ندارد و یا دارای یک نوع اشتباه, یک رشته خالی بازگردانده خواهد شد. - -مثال: - -``` sql -SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' -``` - -## JSONExtractArrayRaw(json\[, indices\_or\_keys\]…) {#jsonextractarrayrawjson-indices-or-keys} - -بازگرداندن مجموعه ای با عناصر از مجموعه جانسون,هر یک به عنوان رشته نامحدود نشان. - -اگر بخش وجود ندارد و یا مجموعه ای نیست, مجموعه ای خالی بازگردانده خواهد شد. - -مثال: - -``` sql -SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) diff --git a/docs/fa/sql_reference/functions/logical_functions.md b/docs/fa/sql_reference/functions/logical_functions.md deleted file mode 100644 index 47a7de029f0..00000000000 --- a/docs/fa/sql_reference/functions/logical_functions.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u0645\u0646\u0637\u0642\u06CC" ---- - -# توابع منطقی {#logical-functions} - -توابع منطقی قبول هر نوع عددی, اما بازگشت یک عدد توینت8 برابر 0 یا 1. - -صفر به عنوان یک استدلال در نظر گرفته شده است “false,” در حالی که هر مقدار غیر صفر در نظر گرفته شده است “true”. - -## و, و اپراتور {#and-and-operator} - -## یا اپراتور {#or-or-operator} - -## نه, اپراتور نیست {#not-not-operator} - -## خور {#xor} - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/fa/sql_reference/functions/machine_learning_functions.md b/docs/fa/sql_reference/functions/machine_learning_functions.md deleted file mode 100644 index 34b069cdebd..00000000000 --- a/docs/fa/sql_reference/functions/machine_learning_functions.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 64 -toc_title: "\u062A\u0648\u0627\u0628\u0639 \u06CC\u0627\u062F\u06AF\u06CC\u0631\u06CC\ - \ \u0645\u0627\u0634\u06CC\u0646" ---- - -# توابع یادگیری ماشین {#machine-learning-functions} - -## ارزیابی (پیش بینی) {#machine_learning_methods-evalmlmethod} - -پیش بینی با استفاده از مدل های رگرسیون نصب شده `evalMLMethod` تابع. مشاهده لینک در `linearRegression`. - -### رگرسیون خطی تصادفی {#stochastic-linear-regression} - -این [تنظیم مقررات](../../sql_reference/aggregate_functions/reference.md#agg_functions-stochasticlinearregression) تابع جمع پیاده سازی روش گرادیان نزولی تصادفی با استفاده از مدل خطی و تابع از دست دادن مرتبه اول. استفاده `evalMLMethod` برای پیش بینی در داده های جدید. - -### رگرسیون لجستیک تصادفی {#stochastic-logistic-regression} - -این [سرکوب مقررات عمومی](../../sql_reference/aggregate_functions/reference.md#agg_functions-stochasticlogisticregression) تابع جمع پیاده سازی روش گرادیان نزولی برای مشکل طبقه بندی دودویی. استفاده `evalMLMethod` برای پیش بینی در داده های جدید. diff --git a/docs/fa/sql_reference/functions/math_functions.md b/docs/fa/sql_reference/functions/math_functions.md deleted file mode 100644 index 37d6ca94c2f..00000000000 --- a/docs/fa/sql_reference/functions/math_functions.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u0631\u06CC\u0627\u0636\u06CC" ---- - -# توابع ریاضی {#mathematical-functions} - -همه توابع بازگشت یک عدد شناور64. دقت و صحت نتیجه به حداکثر دقت ممکن است اما نتیجه ممکن است همزمان با ماشین representable شماره نزدیکترین مربوطه عدد حقیقی است. - -## ا() {#e} - -بازگرداندن یک عدد شناور64 است که نزدیک به تعداد الکترونیکی. - -## پی() {#pi} - -Returns a Float64 number that is close to the number π. - -## واردات) {#expx} - -می پذیرد یک استدلال عددی و یک عدد شناور64 نزدیک به توان استدلال را برمی گرداند. - -## هشدار داده می شود) {#logx-lnx} - -یک استدلال عددی را می پذیرد و یک عدد شناور64 را نزدیک به لگاریتم طبیعی استدلال می کند. - -## exp2(x) {#exp2x} - -می پذیرد یک استدلال عددی و یک عدد شناور می گرداند نزدیک به 2 به قدرت ایکس. - -## log2(x) {#log2x} - -می پذیرد یک استدلال عددی و یک عدد جسم شناور64 را برمی گرداند نزدیک به لگاریتم باینری از استدلال. - -## exp10(x) {#exp10x} - -می پذیرد یک استدلال عددی و یک عدد شناور می گرداند نزدیک به 10 به قدرت ایکس. - -## ثبت 10 (ایکس) {#log10x} - -می پذیرد یک استدلال عددی و یک عدد جسم شناور64 نزدیک به لگاریتم اعشاری از استدلال را برمی گرداند. - -## هشدار داده می شود) {#sqrtx} - -می پذیرد یک استدلال عددی و یک عدد شناور می گرداند نزدیک به ریشه مربع از استدلال. - -## هشدار داده می شود) {#cbrtx} - -می پذیرد یک استدلال عددی و یک عدد جسم شناور را برمی گرداند نزدیک به ریشه مکعب استدلال. - -## عارف) {#erfx} - -اگر ‘x’ is non-negative, then erf(x / σ√2) احتمال این که یک متغیر تصادفی داشتن یک توزیع نرمال با انحراف استاندارد است ‘σ’ طول می کشد ارزش است که از مقدار مورد انتظار توسط بیش از هم جدا ‘x’. - -مثال (قانون سه سیگما): - -``` sql -SELECT erf(3 / sqrt(2)) -``` - -``` text -┌─erf(divide(3, sqrt(2)))─┐ -│ 0.9973002039367398 │ -└─────────────────────────┘ -``` - -## erfc(x) {#erfcx} - -قبول یک استدلال عددی و یک عدد شناور را برمی گرداند نزدیک به 1 - دوره (ایکس), اما بدون از دست دادن دقت برای بزرگ ‘x’ ارزشهای خبری عبارتند از: - -## هشدار داده می شود) {#lgammax} - -لگاریتم تابع گاما. - -## ترجما) {#tgammax} - -تابع گاما - -## گناه) {#sinx} - -سینوس. - -## کسینوس (ایکس) {#cosx} - -کسینوس. - -## قهوهای مایل به زرد(ایکس) {#tanx} - -خط مماس. - -## اطلاعات دقیق) {#asinx} - -سینوسی قوس. - -## acos(x) {#acosx} - -قوس کسینوس. - -## هشدار داده می شود) {#atanx} - -مماس قوس. - -## صدای انفجار (ایکس, و), قدرت (ایکس, و) {#powx-y-powerx-y} - -طول می کشد دو استدلال عددی ایکس و و و. گرداند یک عدد جسم شناور64 نزدیک به ایکس به قدرت و. - -## اینتکسپ2 {#intexp2} - -می پذیرد یک استدلال عددی و باز می گردد یک عدد اوینت64 نزدیک به 2 به قدرت ایکس. - -## اینتکسپ10 {#intexp10} - -می پذیرد یک استدلال عددی و باز می گردد یک عدد اوینت64 نزدیک به 10 به قدرت ایکس. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/fa/sql_reference/functions/other_functions.md b/docs/fa/sql_reference/functions/other_functions.md deleted file mode 100644 index 55c44241615..00000000000 --- a/docs/fa/sql_reference/functions/other_functions.md +++ /dev/null @@ -1,1079 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 66 -toc_title: "\u063A\u06CC\u0631\u0647" ---- - -# توابع دیگر {#other-functions} - -## نام میزبان() {#hostname} - -بازگرداندن یک رشته با نام میزبان که این تابع در انجام شد. برای پردازش توزیع شده, این نام میزبان سرور از راه دور است, اگر تابع بر روی یک سرور از راه دور انجام. - -## FQDN {#fqdn} - -بازگرداندن نام دامنه به طور کامل واجد شرایط. - -**نحو** - -``` sql -fqdn(); -``` - -این تابع غیر حساس است. - -**مقدار بازگشتی** - -- رشته با نام دامنه به طور کامل واجد شرایط. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT FQDN(); -``` - -نتیجه: - -``` text -┌─FQDN()──────────────────────────┐ -│ clickhouse.ru-central1.internal │ -└─────────────────────────────────┘ -``` - -## basename {#basename} - -عصاره قسمت انتهایی یک رشته پس از بریده بریده و یا ممیز گذشته. این تابع اگر اغلب مورد استفاده برای استخراج نام فایل از یک مسیر. - -``` sql -basename( expr ) -``` - -**پارامترها** - -- `expr` — Expression resulting in a [رشته](../../sql_reference/data_types/string.md) نوع ارزش. همه بک اسلش باید در ارزش حاصل فرار. - -**مقدار بازگشتی** - -یک رشته که شامل: - -- قسمت انتهایی یک رشته پس از بریده بریده و یا ممیز گذشته. - - If the input string contains a path ending with slash or backslash, for example, `/` or `c:\`, the function returns an empty string. - -- رشته اصلی اگر هیچ اسلش یا بک اسلش وجود دارد. - -**مثال** - -``` sql -SELECT 'some/long/path/to/file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some\\long\\path\\to\\file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some-file-name' AS a, basename(a) -``` - -``` text -┌─a──────────────┬─basename('some-file-name')─┐ -│ some-file-name │ some-file-name │ -└────────────────┴────────────────────────────┘ -``` - -## عریض) {#visiblewidthx} - -محاسبه عرض تقریبی در هنگام خروجی ارزش به کنسول در قالب متن (تب از هم جدا). -این تابع توسط سیستم برای اجرای فرمت های زیبا استفاده می شود. - -`NULL` به عنوان یک رشته مربوط به نمایندگی `NULL` داخل `Pretty` فرمتها. - -``` sql -SELECT visibleWidth(NULL) -``` - -``` text -┌─visibleWidth(NULL)─┐ -│ 4 │ -└────────────────────┘ -``` - -## نام کامل) {#totypenamex} - -بازگرداندن یک رشته حاوی نام نوع استدلال گذشت. - -اگر `NULL` به عنوان ورودی به عملکرد منتقل می شود و سپس باز می گردد `Nullable(Nothing)` نوع, که مربوط به داخلی `NULL` نمایندگی در فاحشه خانه. - -## blockSize() {#function-blocksize} - -می شود به اندازه بلوک. -در خانه, نمایش داده شد همیشه در بلوک های اجرا (مجموعه ای از قطعات ستون). این تابع اجازه می دهد تا اندازه بلوک را که شما برای نام برد دریافت کنید. - -## تحقق (ایکس) {#materializex} - -تبدیل ثابت به یک ستون کامل حاوی فقط یک مقدار. -در خانه, ستون کامل و ثابت متفاوت در حافظه نشان. توابع کار متفاوت برای استدلال ثابت و استدلال طبیعی (کد های مختلف اجرا شده است), اگر چه نتیجه این است که تقریبا همیشه همان. این تابع برای اشکال زدایی این رفتار. - -## ignore(…) {#ignore} - -می پذیرد هر استدلال, محتوی `NULL`. همیشه برمی گرداند 0. -با این حال, استدلال هنوز ارزیابی. این را می توان برای معیار استفاده می شود. - -## خواب (ثانیه) {#sleepseconds} - -خواب ‘seconds’ ثانیه در هر بلوک داده ها. شما می توانید یک عدد صحیح یا عدد ممیز شناور را مشخص کنید. - -## خواب (ثانیه) {#sleepeachrowseconds} - -خواب ‘seconds’ ثانیه در هر سطر. شما می توانید یک عدد صحیح یا عدد ممیز شناور را مشخص کنید. - -## متن() {#currentdatabase} - -بازگرداندن نام پایگاه داده فعلی. -شما می توانید این تابع در پارامترهای موتور جدول در یک پرس و جو جدول ایجاد جایی که شما نیاز به مشخص کردن پایگاه داده استفاده. - -## currentUser() {#other-function-currentuser} - -بازده ورود به سایت از کاربر فعلی. ورود کاربر که آغاز پرس و جو بازگردانده خواهد شد در مورد distibuted پرس و جو. - -``` sql -SELECT currentUser(); -``` - -نام مستعار: `user()`, `USER()`. - -**مقادیر بازگشتی** - -- ورود کاربر فعلی. -- ورود کاربر که پرس و جو در صورت پرس و جو از کار افتاده است. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT currentUser(); -``` - -نتیجه: - -``` text -┌─currentUser()─┐ -│ default │ -└───────────────┘ -``` - -## اطلاعات دقیق) {#isfinitex} - -قبول float32 و float64 و بازده uint8 برابر با 1 اگر این استدلال بی نهایت است و نه یک نان در غیر این صورت 0 است. - -## اطلاعات دقیق) {#isinfinitex} - -قبول float32 و float64 و بازده uint8 برابر با 1 اگر این استدلال بی نهایت است در غیر این صورت 0 است. توجه داشته باشید که 0 برای نان بازگشت. - -## اطلاعات دقیق {#ifnotfinite} - -بررسی اینکه مقدار ممیز شناور محدود است. - -**نحو** - - ifNotFinite(x,y) - -**پارامترها** - -- `x` — Value to be checked for infinity. Type: [شناور\*](../../sql_reference/data_types/float.md). -- `y` — Fallback value. Type: [شناور\*](../../sql_reference/data_types/float.md). - -**مقدار بازگشتی** - -- `x` اگر `x` محدود است. -- `y` اگر `x` محدود نیست. - -**مثال** - -پرسوجو: - - SELECT 1/0 as infimum, ifNotFinite(infimum,42) - -نتیجه: - - ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ - │ inf │ 42 │ - └─────────┴───────────────────────────────┘ - -شما می توانید نتیجه مشابه با استفاده از [اپراتور سه تایی](conditional_functions.md#ternary-operator): `isFinite(x) ? x : y`. - -## اطلاعات دقیق) {#isnanx} - -قبول float32 و float64 و بازده uint8 برابر با 1 اگر استدلال این است که یک نان در غیر این صورت 0 است. - -## قابل تنظیم(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} - -می پذیرد رشته ثابت: نام پایگاه داده, نام جدول, و نام ستون. بازگرداندن یک بیان ثابت سنت8 برابر 1 اگر یک ستون وجود دارد, در غیر این صورت 0. اگر پارامتر نام میزبان تنظیم شده است, تست بر روی یک سرور از راه دور اجرا خواهد شد. -تابع می اندازد یک استثنا اگر جدول وجود ندارد. -برای عناصر در یک ساختار داده های تو در تو, تابع چک برای وجود یک ستون. برای ساختار داده های تو در تو خود, بازده تابع 0. - -## بار {#function-bar} - -اجازه می دهد تا ساخت یک نمودار یونیکد هنر. - -`bar(x, min, max, width)` تساوی یک گروه با عرض متناسب با `(x - min)` و برابر با `width` شخصیت زمانی که `x = max`. - -پارامترها: - -- `x` — Size to display. -- `min, max` — Integer constants. The value must fit in `Int64`. -- `width` — Constant, positive integer, can be fractional. - -گروه با دقت به یک هشتم نماد کشیده شده است. - -مثال: - -``` sql -SELECT - toHour(EventTime) AS h, - count() AS c, - bar(c, 0, 600000, 20) AS bar -FROM test.hits -GROUP BY h -ORDER BY h ASC -``` - -``` text -┌──h─┬──────c─┬─bar────────────────┐ -│ 0 │ 292907 │ █████████▋ │ -│ 1 │ 180563 │ ██████ │ -│ 2 │ 114861 │ ███▋ │ -│ 3 │ 85069 │ ██▋ │ -│ 4 │ 68543 │ ██▎ │ -│ 5 │ 78116 │ ██▌ │ -│ 6 │ 113474 │ ███▋ │ -│ 7 │ 170678 │ █████▋ │ -│ 8 │ 278380 │ █████████▎ │ -│ 9 │ 391053 │ █████████████ │ -│ 10 │ 457681 │ ███████████████▎ │ -│ 11 │ 493667 │ ████████████████▍ │ -│ 12 │ 509641 │ ████████████████▊ │ -│ 13 │ 522947 │ █████████████████▍ │ -│ 14 │ 539954 │ █████████████████▊ │ -│ 15 │ 528460 │ █████████████████▌ │ -│ 16 │ 539201 │ █████████████████▊ │ -│ 17 │ 523539 │ █████████████████▍ │ -│ 18 │ 506467 │ ████████████████▊ │ -│ 19 │ 520915 │ █████████████████▎ │ -│ 20 │ 521665 │ █████████████████▍ │ -│ 21 │ 542078 │ ██████████████████ │ -│ 22 │ 493642 │ ████████████████▍ │ -│ 23 │ 400397 │ █████████████▎ │ -└────┴────────┴────────────────────┘ -``` - -## تبدیل {#transform} - -تبدیل یک ارزش با توجه به نقشه برداری به صراحت تعریف شده از برخی از عناصر به دیگر. -دو نوع از این تابع وجود دارد: - -### تبدیل(x array\_from, array\_to به طور پیش فرض) {#transformx-array-from-array-to-default} - -`x` – What to transform. - -`array_from` – Constant array of values for converting. - -`array_to` – Constant array of values to convert the values in ‘from’ به. - -`default` – Which value to use if ‘x’ برابر است با هر یک از مقادیر در ‘from’. - -`array_from` و `array_to` – Arrays of the same size. - -انواع: - -`transform(T, Array(T), Array(U), U) -> U` - -`T` و `U` می تواند عددی, رشته,یا تاریخ و یا انواع تاریخ ساعت. -از کجا همان نامه نشان داده شده است (تی یا تو), برای انواع عددی این ممکن است تطبیق انواع, اما انواع که یک نوع رایج. -برای مثال استدلال می توانید نوع int64 در حالی که دوم آرایه(uint16) نوع. - -اگر ‘x’ ارزش به یکی از عناصر در برابر است ‘array\_from’ مجموعه, این بازگرداندن عنصر موجود (که شماره همان) از ‘array\_to’ صف کردن. در غیر این صورت, باز می گردد ‘default’. اگر عناصر تطبیق های متعدد در وجود دارد ‘array\_from’ این یکی از مسابقات را برمی گرداند. - -مثال: - -``` sql -SELECT - transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, - count() AS c -FROM test.hits -WHERE SearchEngineID != 0 -GROUP BY title -ORDER BY c DESC -``` - -``` text -┌─title─────┬──────c─┐ -│ Yandex │ 498635 │ -│ Google │ 229872 │ -│ Other │ 104472 │ -└───────────┴────────┘ -``` - -### تبدیل) {#transformx-array-from-array-to} - -متفاوت از تنوع برای اولین بار در که ‘default’ استدلال حذف شده است. -اگر ‘x’ ارزش به یکی از عناصر در برابر است ‘array\_from’ مجموعه, این بازگرداندن عنصر تطبیق (که شماره همان) از ‘array\_to’ صف کردن. در غیر این صورت, باز می گردد ‘x’. - -انواع: - -`transform(T, Array(T), Array(T)) -> T` - -مثال: - -``` sql -SELECT - transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, - count() AS c -FROM test.hits -GROUP BY domain(Referer) -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -┌─s──────────────┬───────c─┐ -│ │ 2906259 │ -│ www.yandex │ 867767 │ -│ ███████.ru │ 313599 │ -│ mail.yandex.ru │ 107147 │ -│ ██████.ru │ 100355 │ -│ █████████.ru │ 65040 │ -│ news.yandex.ru │ 64515 │ -│ ██████.net │ 59141 │ -│ example.com │ 57316 │ -└────────────────┴─────────┘ -``` - -## قالببندی) ایکس() {#formatreadablesizex} - -می پذیرد اندازه (تعداد بایت). بازگرداندن اندازه گرد با پسوند (کیلوبایت, مگابایت, و غیره.) به عنوان یک رشته . - -مثال: - -``` sql -SELECT - arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, - formatReadableSize(filesize_bytes) AS filesize -``` - -``` text -┌─filesize_bytes─┬─filesize───┐ -│ 1 │ 1.00 B │ -│ 1024 │ 1.00 KiB │ -│ 1048576 │ 1.00 MiB │ -│ 192851925 │ 183.92 MiB │ -└────────────────┴────────────┘ -``` - -## کمترین) {#leasta-b} - -بازگرداندن کوچکترین ارزش از یک و ب. - -## بزرگترین (و, ب) {#greatesta-b} - -بازگرداندن بزرگترین ارزش یک و ب. - -## زمان بالا() {#uptime} - -بازگرداندن زمان انجام کار سرور در ثانیه. - -## نسخه() {#version} - -بازگرداندن نسخه از سرور به عنوان یک رشته. - -## منطقهی زمانی() {#timezone} - -بازگرداندن منطقه زمانی از سرور. - -## blockNumber {#blocknumber} - -بازگرداندن تعداد دنباله ای از بلوک داده که در ردیف واقع شده است. - -## رفع موانع {#function-rownumberinblock} - -بازگرداندن تعداد ترتیبی از ردیف در بلوک داده. بلوک های داده های مختلف همیشه محاسبه. - -## بلوک های رونمبرینالیک() {#rownumberinallblocks} - -بازگرداندن تعداد ترتیبی از ردیف در بلوک داده. این تابع تنها بلوک های داده تحت تاثیر قرار می گیرد. - -## همسایه {#neighbor} - -تابع پنجره که دسترسی به یک ردیف در یک افست مشخص شده است که قبل یا بعد از ردیف فعلی یک ستون داده می شود فراهم می کند. - -**نحو** - -``` sql -neighbor(column, offset[, default_value]) -``` - -نتیجه عملکرد بستگی به بلوک های داده تحت تاثیر قرار و منظور از داده ها در بلوک. -اگر شما یک خرده فروشی با سفارش و پاسخ تابع از خارج از خرده فروشی, شما می توانید نتیجه مورد انتظار از. - -**پارامترها** - -- `column` — A column name or scalar expression. -- `offset` — The number of rows forwards or backwards from the current row of `column`. [Int64](../../sql_reference/data_types/int_uint.md). -- `default_value` — Optional. The value to be returned if offset goes beyond the scope of the block. Type of data blocks affected. - -**مقادیر بازگشتی** - -- مقدار برای `column` داخل `offset` فاصله از ردیف فعلی اگر `offset` ارزش خارج از مرزهای بلوک نیست. -- مقدار پیشفرض برای `column` اگر `offset` ارزش مرزهای بلوک خارج است. اگر `default_value` داده می شود و سپس از آن استفاده خواهد شد. - -نوع: نوع بلوک های داده را تحت تاثیر قرار و یا نوع مقدار پیش فرض. - -**مثال** - -پرسوجو: - -``` sql -SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; -``` - -نتیجه: - -``` text -┌─number─┬─neighbor(number, 2)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 0 │ -│ 9 │ 0 │ -└────────┴─────────────────────┘ -``` - -پرسوجو: - -``` sql -SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; -``` - -نتیجه: - -``` text -┌─number─┬─neighbor(number, 2, 999)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 999 │ -│ 9 │ 999 │ -└────────┴──────────────────────────┘ -``` - -این تابع می تواند مورد استفاده قرار گیرد برای محاسبه ارزش متریک در سال بیش از سال: - -پرسوجو: - -``` sql -WITH toDate('2018-01-01') AS start_date -SELECT - toStartOfMonth(start_date + (number * 32)) AS month, - toInt32(month) % 100 AS money, - neighbor(money, -12) AS prev_year, - round(prev_year / money, 2) AS year_over_year -FROM numbers(16) -``` - -نتیجه: - -``` text -┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ -│ 2018-01-01 │ 32 │ 0 │ 0 │ -│ 2018-02-01 │ 63 │ 0 │ 0 │ -│ 2018-03-01 │ 91 │ 0 │ 0 │ -│ 2018-04-01 │ 22 │ 0 │ 0 │ -│ 2018-05-01 │ 52 │ 0 │ 0 │ -│ 2018-06-01 │ 83 │ 0 │ 0 │ -│ 2018-07-01 │ 13 │ 0 │ 0 │ -│ 2018-08-01 │ 44 │ 0 │ 0 │ -│ 2018-09-01 │ 75 │ 0 │ 0 │ -│ 2018-10-01 │ 5 │ 0 │ 0 │ -│ 2018-11-01 │ 36 │ 0 │ 0 │ -│ 2018-12-01 │ 66 │ 0 │ 0 │ -│ 2019-01-01 │ 97 │ 32 │ 0.33 │ -│ 2019-02-01 │ 28 │ 63 │ 2.25 │ -│ 2019-03-01 │ 56 │ 91 │ 1.62 │ -│ 2019-04-01 │ 87 │ 22 │ 0.25 │ -└────────────┴───────┴───────────┴────────────────┘ -``` - -## تغییر تنظیمات صدا) {#other_functions-runningdifference} - -Calculates the difference between successive row values ​​in the data block. -بازده 0 برای ردیف اول و تفاوت از ردیف قبلی برای هر سطر بعدی. - -نتیجه عملکرد بستگی به بلوک های داده تحت تاثیر قرار و منظور از داده ها در بلوک. -اگر شما یک خرده فروشی با سفارش و پاسخ تابع از خارج از خرده فروشی, شما می توانید نتیجه مورد انتظار از. - -مثال: - -``` sql -SELECT - EventID, - EventTime, - runningDifference(EventTime) AS delta -FROM -( - SELECT - EventID, - EventTime - FROM events - WHERE EventDate = '2016-11-24' - ORDER BY EventTime ASC - LIMIT 5 -) -``` - -``` text -┌─EventID─┬───────────EventTime─┬─delta─┐ -│ 1106 │ 2016-11-24 00:00:04 │ 0 │ -│ 1107 │ 2016-11-24 00:00:05 │ 1 │ -│ 1108 │ 2016-11-24 00:00:05 │ 0 │ -│ 1109 │ 2016-11-24 00:00:09 │ 4 │ -│ 1110 │ 2016-11-24 00:00:10 │ 1 │ -└─────────┴─────────────────────┴───────┘ -``` - -لطفا توجه داشته باشید-اندازه بلوک بر نتیجه تاثیر می گذارد. با هر بلوک جدید `runningDifference` دولت تنظیم مجدد است. - -``` sql -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -┌─number─┬─diff─┐ -│ 65536 │ 0 │ -└────────┴──────┘ -``` - -``` sql -set max_block_size=100000 -- default value is 65536! - -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -``` - -## در حال بارگذاری {#runningdifferencestartingwithfirstvalue} - -همان است که برای [عدم پذیرش](./other_functions.md#other_functions-runningdifference), تفاوت ارزش ردیف اول است, ارزش سطر اول بازگشت, و هر سطر بعدی تفاوت از ردیف قبلی را برمی گرداند. - -## هشدار داده می شود) {#macnumtostringnum} - -قبول uint64 شماره. تفسیر به عنوان نشانی مک در اندی بزرگ. بازگرداندن یک رشته حاوی نشانی مک مربوطه را در قالب قلمی: ب: ر. ن:دکتر: ف.ا: ف. ف. (تعداد کولون جدا شده در فرم هگزادسیمال). - -## MACStringToNum(s) {#macstringtonums} - -عملکرد معکوس مک نومتوسترینگ. اگر نشانی مک دارای یک فرمت نامعتبر, باز می گردد 0. - -## درشتنمایی) {#macstringtoouis} - -می پذیرد یک نشانی مک در فرمت قلمی:بیت:ر.ن:دی. دی:اف (تعداد روده بزرگ از هم جدا در فرم هگزادسیمال). بازگرداندن سه هشت تایی اول به عنوان یک عدد ظاهری64. اگر نشانی مک دارای یک فرمت نامعتبر, باز می گردد 0. - -## نوع گیرنده {#getsizeofenumtype} - -بازگرداندن تعدادی از زمینه های در [شمارشی](../../sql_reference/data_types/enum.md). - -``` sql -getSizeOfEnumType(value) -``` - -**پارامترها:** - -- `value` — Value of type `Enum`. - -**مقادیر بازگشتی** - -- تعدادی از زمینه های با `Enum` مقادیر ورودی. -- یک استثنا پرتاب می شود اگر نوع نیست `Enum`. - -**مثال** - -``` sql -SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## بلوک سازی {#blockserializedsize} - -بازده اندازه بر روی دیسک (بدون در نظر گرفتن فشرده سازی حساب). - -``` sql -blockSerializedSize(value[, value[, ...]]) -``` - -**پارامترها:** - -- `value` — Any value. - -**مقادیر بازگشتی** - -- تعداد بایت خواهد شد که به دیسک برای بلوک از ارزش های نوشته شده (بدون فشرده سازی). - -**مثال** - -``` sql -SELECT blockSerializedSize(maxState(1)) as x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## بدون نام {#tocolumntypename} - -بازگرداندن نام کلاس است که نشان دهنده نوع داده ها از ستون در رم. - -``` sql -toColumnTypeName(value) -``` - -**پارامترها:** - -- `value` — Any type of value. - -**مقادیر بازگشتی** - -- یک رشته با نام کلاس است که برای نمایندگی از استفاده `value` نوع داده در رم. - -**نمونه ای از تفاوت بین`toTypeName ' and ' toColumnTypeName`** - -``` sql -SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime │ -└─────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ Const(UInt32) │ -└───────────────────────────────────────────────────────────┘ -``` - -مثال نشان می دهد که `DateTime` نوع داده در حافظه ذخیره می شود به عنوان `Const(UInt32)`. - -## روبنا دامپکول {#dumpcolumnstructure} - -خروجی شرح مفصلی از ساختارهای داده در رم - -``` sql -dumpColumnStructure(value) -``` - -**پارامترها:** - -- `value` — Any type of value. - -**مقادیر بازگشتی** - -- یک رشته توصیف ساختار است که برای نمایندگی از استفاده `value` نوع داده در رم. - -**مثال** - -``` sql -SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) -``` - -``` text -┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime, Const(size = 1, UInt32(size = 1)) │ -└──────────────────────────────────────────────────────────────┘ -``` - -## نوع قراردادی {#defaultvalueofargumenttype} - -خروجی مقدار پیش فرض برای نوع داده. - -مقادیر پیش فرض برای ستون های سفارشی تعیین شده توسط کاربر را شامل نمی شود. - -``` sql -defaultValueOfArgumentType(expression) -``` - -**پارامترها:** - -- `expression` — Arbitrary type of value or an expression that results in a value of an arbitrary type. - -**مقادیر بازگشتی** - -- `0` برای اعداد. -- رشته خالی برای رشته. -- `ᴺᵁᴸᴸ` برای [Nullable](../../sql_reference/data_types/nullable.md). - -**مثال** - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ -│ 0 │ -└─────────────────────────────────────────────┘ -``` - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ -│ ᴺᵁᴸᴸ │ -└───────────────────────────────────────────────────────┘ -``` - -## تکرار {#other-functions-replicate} - -ایجاد مجموعه ای با یک مقدار واحد. - -مورد استفاده برای اجرای داخلی [ارریجین](array_join.md#functions_arrayjoin). - -``` sql -SELECT replicate(x, arr); -``` - -**پارامترها:** - -- `arr` — Original array. ClickHouse creates a new array of the same length as the original and fills it with the value `x`. -- `x` — The value that the resulting array will be filled with. - -**مقدار بازگشتی** - -مجموعه ای پر از ارزش `x`. - -نوع: `Array`. - -**مثال** - -پرسوجو: - -``` sql -SELECT replicate(1, ['a', 'b', 'c']) -``` - -نتیجه: - -``` text -┌─replicate(1, ['a', 'b', 'c'])─┐ -│ [1,1,1] │ -└───────────────────────────────┘ -``` - -## رشته های قابل استفاده {#filesystemavailable} - -بازگرداندن مقدار فضای باقی مانده بر روی سیستم فایل که فایل های پایگاه داده واقع. این است که همیشه کوچکتر از فضای کل رایگان ([بدون پرونده](#filesystemfree)) چرا که برخی از فضا برای سیستم عامل محفوظ می باشد. - -**نحو** - -``` sql -filesystemAvailable() -``` - -**مقدار بازگشتی** - -- مقدار فضای باقی مانده موجود در بایت. - -نوع: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; -``` - -نتیجه: - -``` text -┌─Available space─┬─Type───┐ -│ 30.75 GiB │ UInt64 │ -└─────────────────┴────────┘ -``` - -## بدون پرونده {#filesystemfree} - -بازگرداندن مقدار کل فضای رایگان بر روی سیستم فایل که فایل های پایگاه داده واقع. همچنین نگاه کنید به `filesystemAvailable` - -**نحو** - -``` sql -filesystemFree() -``` - -**مقدار بازگشتی** - -- مقدار فضای رایگان در بایت. - -نوع: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; -``` - -نتیجه: - -``` text -┌─Free space─┬─Type───┐ -│ 32.39 GiB │ UInt64 │ -└────────────┴────────┘ -``` - -## سختی پرونده {#filesystemcapacity} - -بازگرداندن ظرفیت فایل سیستم در بایت. برای ارزیابی [مسیر](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) به دایرکتوری داده ها باید پیکربندی شود. - -**نحو** - -``` sql -filesystemCapacity() -``` - -**مقدار بازگشتی** - -- اطلاعات ظرفیت سیستم فایل در بایت. - -نوع: [UInt64](../../sql_reference/data_types/int_uint.md). - -**مثال** - -پرسوجو: - -``` sql -SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" -``` - -نتیجه: - -``` text -┌─Capacity──┬─Type───┐ -│ 39.32 GiB │ UInt64 │ -└───────────┴────────┘ -``` - -## پلاکتی {#function-finalizeaggregation} - -طول می کشد دولت از تابع جمع. بازده نتیجه تجمع (دولت نهایی). - -## خرابی اجرا {#function-runningaccumulate} - -طول می کشد کشورهای تابع جمع و یک ستون با ارزش را برمی گرداند, در نتیجه تجمع این کشورها برای مجموعه ای از خطوط بلوک هستند, از اول به خط فعلی. -برای مثال طول می کشد state of aggregate function (به عنوان مثال runningaccumulate(uniqstate(userid))) و برای هر ردیف از بلوک بازگشت نتیجه از مجموع عملکرد در ادغام دولت قبلی تمام ردیف و ردیف جاری است. -بنابراین نتیجه عملکرد بستگی به پارتیشن داده ها به بلوک ها و به ترتیب داده ها در بلوک دارد. - -## جوینت {#joinget} - -تابع شما اجازه می دهد استخراج داده ها از جدول به همان شیوه به عنوان از یک [واژهنامه](../../sql_reference/dictionaries/index.md). - -می شود داده ها از [پیوستن](../../engines/table_engines/special/join.md#creating-a-table) جداول با استفاده از کلید ملحق مشخص. - -فقط پشتیبانی از جداول ایجاد شده با `ENGINE = Join(ANY, LEFT, )` بیانیه. - -**نحو** - -``` sql -joinGet(join_storage_table_name, `value_column`, join_keys) -``` - -**پارامترها** - -- `join_storage_table_name` — an [شناسه](../syntax.md#syntax-identifiers) نشان می دهد که جستجو انجام شده است. شناسه در پایگاه داده به طور پیش فرض جستجو (پارامتر را ببینید `default_database` در فایل پیکربندی). برای نادیده گرفتن پایگاه داده پیش فرض از `USE db_name` یا پایگاه داده و جدول را از طریق جداساز مشخص کنید `db_name.db_table`, مثال را ببینید. -- `value_column` — name of the column of the table that contains required data. -- `join_keys` — list of keys. - -**مقدار بازگشتی** - -را برمی گرداند لیستی از ارزش مطابقت دارد به لیست کلید. - -اگر برخی در جدول منبع وجود ندارد و سپس `0` یا `null` خواهد شد بر اساس بازگشت [ارزشهای خبری عبارتند از:](../../operations/settings/settings.md#join_use_nulls) تنظیمات. - -اطلاعات بیشتر در مورد `join_use_nulls` داخل [پیوستن به عملیات](../../engines/table_engines/special/join.md). - -**مثال** - -جدول ورودی: - -``` sql -CREATE DATABASE db_test -CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 -INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) -``` - -``` text -┌─id─┬─val─┐ -│ 4 │ 13 │ -│ 2 │ 12 │ -│ 1 │ 11 │ -└────┴─────┘ -``` - -پرسوجو: - -``` sql -SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 -``` - -نتیجه: - -``` text -┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ -│ 0 │ -│ 11 │ -│ 12 │ -│ 0 │ -└──────────────────────────────────────────────────┘ -``` - -## modelEvaluate(model\_name, …) {#function-modelevaluate} - -ارزیابی مدل خارجی. -می پذیرد نام مدل و استدلال مدل. را برمی گرداند شناور64. - -## throwIf(x\[, custom\_message\]) {#throwifx-custom-message} - -پرتاب یک استثنا اگر استدلال غیر صفر است. -\_پیغام سفارشی-پارامتر اختیاری است: یک رشته ثابت, فراهم می کند یک پیغام خطا - -``` sql -SELECT throwIf(number = 3, 'Too many') FROM numbers(10); -``` - -``` text -↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): -Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. -``` - -## هویت {#identity} - -بازگرداندن همان مقدار که به عنوان استدلال خود مورد استفاده قرار گرفت. مورد استفاده برای اشکال زدایی و تست, اجازه می دهد تا به لغو با استفاده از شاخص, و عملکرد پرس و جو از یک اسکن کامل. هنگامی که پرس و جو برای استفاده احتمالی از شاخص تجزیه و تحلیل, تجزیه و تحلیل می کند در داخل نگاه نمی `identity` توابع. - -**نحو** - -``` sql -identity(x) -``` - -**مثال** - -پرسوجو: - -``` sql -SELECT identity(42) -``` - -نتیجه: - -``` text -┌─identity(42)─┐ -│ 42 │ -└──────────────┘ -``` - -## درباره ما {#randomascii} - -تولید یک رشته با مجموعه ای تصادفی از [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) شخصیت های قابل چاپ. - -**نحو** - -``` sql -randomPrintableASCII(length) -``` - -**پارامترها** - -- `length` — Resulting string length. Positive integer. - - If you pass `length < 0`, behavior of the function is undefined. - -**مقدار بازگشتی** - -- رشته با مجموعه ای تصادفی از [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) شخصیت های قابل چاپ. - -نوع: [رشته](../../sql_reference/data_types/string.md) - -**مثال** - -``` sql -SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 -``` - -``` text -┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ -│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ -│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ -│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ -└────────┴────────────────────────────────┴──────────────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/fa/sql_reference/functions/random_functions.md b/docs/fa/sql_reference/functions/random_functions.md deleted file mode 100644 index fd98d228bc5..00000000000 --- a/docs/fa/sql_reference/functions/random_functions.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 51 -toc_title: "\u062A\u0648\u0644\u06CC\u062F \u0627\u0639\u062F\u0627\u062F \u0634\u0628\ - \u0647 \u062A\u0635\u0627\u062F\u0641\u06CC" ---- - -# توابع برای تولید اعداد شبه تصادفی {#functions-for-generating-pseudo-random-numbers} - -ژنراتور غیر رمزنگاری اعداد شبه تصادفی استفاده می شود. - -تمام توابع قبول استدلال صفر و یا یک استدلال. -اگر استدلال به تصویب می رسد, این می تواند هر نوع, و ارزش خود را برای هر چیزی استفاده نمی شود. -تنها هدف از این استدلال این است که برای جلوگیری از حذف خشونت مشترک, به طوری که دو نمونه مختلف از همان تابع بازگشت ستون های مختلف با شماره های مختلف تصادفی. - -## رند {#rand} - -بازده یک شبه تصادفی uint32 شماره به طور مساوی توزیع شده در میان تمام uint32 از نوع اعداد است. -با استفاده از یک خطی congruential ژنراتور. - -## رند64 {#rand64} - -بازده یک شبه تصادفی uint64 شماره به طور مساوی توزیع شده در میان تمام uint64 از نوع اعداد است. -با استفاده از یک ژنراتور همخوان خطی. - -## شرکت رندکونستانت {#randconstant} - -بازگرداندن یک عدد اوینت32 شبه تصادفی, ارزش یکی برای بلوک های مختلف است. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/fa/sql_reference/functions/rounding_functions.md b/docs/fa/sql_reference/functions/rounding_functions.md deleted file mode 100644 index 41ff2de5d3a..00000000000 --- a/docs/fa/sql_reference/functions/rounding_functions.md +++ /dev/null @@ -1,190 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: "\u06AF\u0631\u062F \u06A9\u0631\u062F\u0646" ---- - -# گرد کردن توابع {#rounding-functions} - -## طبقه (ایکس\]) {#floorx-n} - -بازگرداندن بیشترین تعداد دور است که کمتر از یا مساوی `x`. تعداد دور چند تن از 1/10 و یا نزدیکترین تعداد داده های مناسب نوع اگر 1 / 10 دقیق نیست. -‘N’ ثابت عدد صحیح است, پارامتر اختیاری. به طور پیش فرض صفر است, که به معنی به دور به یک عدد صحیح. -‘N’ ممکن است منفی باشد. - -مثالها: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` - -`x` هر نوع عددی است. نتیجه تعدادی از همان نوع است. -برای استدلال عدد صحیح را حس می کند به دور با منفی `N` ارزش (برای غیر منفی `N` تابع هیچ کاری نمی کند). -اگر گرد باعث سرریز (مثلا, کف سازی(-128, -1)), نتیجه اجرای خاص بازگشته است. - -## هشدار داده می شود\]) {#ceilx-n-ceilingx-n} - -بازگرداندن کوچکترین عدد دور است که بیشتر از یا مساوی `x`. در هر راه دیگر, این همان است که `floor` تابع (بالا را ببینید). - -## هشدار داده می شود\]) {#truncx-n-truncatex-n} - -بازگرداندن تعداد دور با بزرگترین ارزش مطلق است که ارزش مطلق کمتر یا مساوی `x`‘s. In every other way, it is the same as the ’floor’ تابع (بالا را ببینید). - -## دور (ایکس\]) {#rounding_functions-round} - -دور یک مقدار به تعداد مشخصی از رقم اعشار. - -تابع نزدیکترین تعداد از سفارش مشخص شده را برمی گرداند. در صورتی که تعداد داده شده است فاصله برابر با شماره های اطراف, تابع با استفاده از گرد کردن بانکدار برای انواع شماره شناور و دور به دور از صفر برای انواع شماره های دیگر. - -``` sql -round(expression [, decimal_places]) -``` - -**پارامترها:** - -- `expression` — A number to be rounded. Can be any [عبارت](../syntax.md#syntax-expressions) بازگشت عددی [نوع داده](../../sql_reference/data_types/index.md#data_types). -- `decimal-places` — An integer value. - - اگر `decimal-places > 0` سپس تابع دور ارزش به سمت راست از نقطه اعشار. - - اگر `decimal-places < 0` سپس تابع دور ارزش به سمت چپ نقطه اعشار. - - اگر `decimal-places = 0` سپس تابع دور ارزش به عدد صحیح. در این مورد استدلال را می توان حذف. - -**مقدار بازگشتی:** - -گرد شماره از همان نوع به عنوان ورودی شماره. - -### مثالها {#examples} - -**مثال استفاده** - -``` sql -SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 -``` - -``` text -┌───x─┬─round(divide(number, 2))─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -└─────┴──────────────────────────┘ -``` - -**نمونه هایی از گرد کردن** - -گرد کردن به نزدیکترین شماره. - -``` text -round(3.2, 0) = 3 -round(4.1267, 2) = 4.13 -round(22,-1) = 20 -round(467,-2) = 500 -round(-467,-2) = -500 -``` - -گرد کردن بانکدار. - -``` text -round(3.5) = 4 -round(4.5) = 4 -round(3.55, 1) = 3.6 -round(3.65, 1) = 3.6 -``` - -**همچنین نگاه کنید به** - -- [roundBankers](#roundbankers) - -## سرباز {#roundbankers} - -دور یک عدد به یک موقعیت دهدهی مشخص شده است. - -- اگر تعداد گرد کردن در نیمه راه بین دو عدد است, تابع با استفاده از گرد کردن بانکدار. - - Banker's rounding is a method of rounding fractional numbers. When the rounding number is halfway between two numbers, it's rounded to the nearest even digit at the specified decimal position. For example: 3.5 rounds up to 4, 2.5 rounds down to 2. - - It's the default rounding method for floating point numbers defined in [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). The [round](#rounding_functions-round) function performs the same rounding for floating point numbers. The `roundBankers` function also rounds integers the same way, for example, `roundBankers(45, -1) = 40`. - -- در موارد دیگر تابع دور اعداد به نزدیکترین عدد صحیح. - -با استفاده از گرد کردن بانکدار, شما می توانید اثر است که گرد کردن اعداد در نتایج حاصل از جمع و یا کم کردن این اعداد را کاهش می دهد. - -برای مثال مجموع اعداد 1.5, 2.5, 3.5, 4.5 مختلف گرد: - -- بدون گرد کردن: 1.5 + 2.5 + 3.5 + 4.5 = 12. -- گرد کردن بانکدار: 2 + 2 + 4 + 4 = 12. -- گرد کردن به نزدیکترین عدد صحیح: 2 + 3 + 4 + 5 = 14. - -**نحو** - -``` sql -roundBankers(expression [, decimal_places]) -``` - -**پارامترها** - -- `expression` — A number to be rounded. Can be any [عبارت](../syntax.md#syntax-expressions) بازگشت عددی [نوع داده](../../sql_reference/data_types/index.md#data_types). -- `decimal-places` — Decimal places. An integer number. - - `decimal-places > 0` — The function rounds the number to the given position right of the decimal point. Example: `roundBankers(3.55, 1) = 3.6`. - - `decimal-places < 0` — The function rounds the number to the given position left of the decimal point. Example: `roundBankers(24.55, -1) = 20`. - - `decimal-places = 0` — The function rounds the number to an integer. In this case the argument can be omitted. Example: `roundBankers(2.5) = 2`. - -**مقدار بازگشتی** - -ارزش گرد شده توسط روش گرد کردن بانکدار. - -### مثالها {#examples-1} - -**مثال استفاده** - -پرسوجو: - -``` sql - SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 -``` - -نتیجه: - -``` text -┌───x─┬─b─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -│ 1.5 │ 2 │ -│ 2 │ 2 │ -│ 2.5 │ 2 │ -│ 3 │ 3 │ -│ 3.5 │ 4 │ -│ 4 │ 4 │ -│ 4.5 │ 4 │ -└─────┴───┘ -``` - -**نمونه هایی از گرد کردن بانکدار** - -``` text -roundBankers(0.4) = 0 -roundBankers(-3.5) = -4 -roundBankers(4.5) = 4 -roundBankers(3.55, 1) = 3.6 -roundBankers(3.65, 1) = 3.6 -roundBankers(10.35, 1) = 10.4 -roundBankers(10.755, 2) = 11,76 -``` - -**همچنین نگاه کنید به** - -- [گرد](#rounding_functions-round) - -## توسعه پایدار2) {#roundtoexp2num} - -می پذیرد تعداد. اگر تعداد کمتر از یک است, باز می گردد 0. در غیر این صورت, این دور تعداد پایین به نزدیکترین (مجموع غیر منفی) درجه دو. - -## طول عمر (تعداد) {#rounddurationnum} - -می پذیرد تعداد. اگر تعداد کمتر از یک است, باز می گردد 0. در غیر این صورت, این دور تعداد را به اعداد از مجموعه: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. این تابع خاص به یاندکس است.متریکا و مورد استفاده برای اجرای گزارش در طول جلسه. - -## عدد) {#roundagenum} - -می پذیرد تعداد. اگر تعداد کمتر از است 18, باز می گردد 0. در غیر این صورت, این دور تعداد را به یک عدد از مجموعه: 18, 25, 35, 45, 55. این تابع خاص به یاندکس است.متریکا و مورد استفاده برای اجرای گزارش در سن کاربر. - -## roundDown(num arr) {#rounddownnum-arr} - -یک عدد را می پذیرد و به یک عنصر در مجموعه مشخص شده منتقل می کند. اگر مقدار کمتر از پایین ترین حد محدود است, پایین ترین حد بازگشته است. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/fa/sql_reference/functions/splitting_merging_functions.md b/docs/fa/sql_reference/functions/splitting_merging_functions.md deleted file mode 100644 index fdcb7bbac56..00000000000 --- a/docs/fa/sql_reference/functions/splitting_merging_functions.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 47 -toc_title: "\u062A\u0642\u0633\u06CC\u0645 \u0648 \u0627\u062F\u063A\u0627\u0645 \u0631\ - \u0634\u062A\u0647 \u0647\u0627 \u0648 \u0627\u0631\u0631\u06CC\u0633" ---- - -# توابع برای تقسیم و ادغام رشته ها و ارریس {#functions-for-splitting-and-merging-strings-and-arrays} - -## اسپلیت بیچار (جداساز) {#splitbycharseparator-s} - -انشعابات یک رشته به بسترهای جدا شده توسط یک شخصیت مشخص شده است. با استفاده از یک رشته ثابت `separator` که متشکل از دقیقا یک شخصیت. -بازگرداندن مجموعه ای از بسترهای انتخاب. بسترهای خالی ممکن است انتخاب شود اگر جدا در ابتدا یا انتهای رشته رخ می دهد, و یا اگر چند جداکننده متوالی وجود دارد. - -**نحو** - -``` sql -splitByChar(, ) -``` - -**پارامترها** - -- `separator` — The separator which should contain exactly one character. [رشته](../../sql_reference/data_types/string.md). -- `s` — The string to split. [رشته](../../sql_reference/data_types/string.md). - -**مقدار بازگشتی)** - -بازگرداندن مجموعه ای از بسترهای انتخاب. بسترهای خالی ممکن است انتخاب شود که: - -- جداساز در ابتدا یا انتهای رشته رخ می دهد; -- چندین جداکننده متوالی وجود دارد; -- رشته اصلی `s` خالیه - -نوع: [& حذف](../../sql_reference/data_types/array.md) از [رشته](../../sql_reference/data_types/string.md). - -**مثال** - -``` sql -SELECT splitByChar(',', '1,2,3,abcde') -``` - -``` text -┌─splitByChar(',', '1,2,3,abcde')─┐ -│ ['1','2','3','abcde'] │ -└─────────────────────────────────┘ -``` - -## رشته اسپلیتبیست (جداساز) {#splitbystringseparator-s} - -انشعابات یک رشته به بسترهای جدا شده توسط یک رشته. با استفاده از یک رشته ثابت `separator` از شخصیت های متعدد به عنوان جدا کننده. اگر رشته `separator` خالی است, این رشته تقسیم `s` به مجموعه ای از شخصیت های تک. - -**نحو** - -``` sql -splitByString(, ) -``` - -**پارامترها** - -- `separator` — The separator. [رشته](../../sql_reference/data_types/string.md). -- `s` — The string to split. [رشته](../../sql_reference/data_types/string.md). - -**مقدار بازگشتی)** - -بازگرداندن مجموعه ای از بسترهای انتخاب. بسترهای خالی ممکن است انتخاب شود که: - -نوع: [& حذف](../../sql_reference/data_types/array.md) از [رشته](../../sql_reference/data_types/string.md). - -- جدا کننده غیر خالی در ابتدا یا انتهای رشته رخ می دهد; -- چند جدا متوالی غیر خالی وجود دارد; -- رشته اصلی `s` خالی است در حالی که جدا خالی نیست. - -**مثال** - -``` sql -SELECT splitByString(', ', '1, 2 3, 4,5, abcde') -``` - -``` text -┌─splitByString(', ', '1, 2 3, 4,5, abcde')─┐ -│ ['1','2 3','4,5','abcde'] │ -└───────────────────────────────────────────┘ -``` - -``` sql -SELECT splitByString('', 'abcde') -``` - -``` text -┌─splitByString('', 'abcde')─┐ -│ ['a','b','c','d','e'] │ -└────────────────────────────┘ -``` - -## حذف میانبر در صفحه خانه\]) {#arraystringconcatarr-separator} - -رشته های ذکر شده در مجموعه را با جداساز مطابقت می دهد.'جدا کننده' پارامتر اختیاری است: یک رشته ثابت, مجموعه ای به یک رشته خالی به طور پیش فرض. -رشته را برمی گرداند. - -## اطلاعات دقیق) {#alphatokenss} - -انتخاب substrings متوالی بایت از محدوده a-z و a-z. بازگرداندن یک آرایه از substrings. - -**مثال** - -``` sql -SELECT alphaTokens('abca1abc') -``` - -``` text -┌─alphaTokens('abca1abc')─┐ -│ ['abca','abc'] │ -└─────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/fa/sql_reference/functions/string_functions.md b/docs/fa/sql_reference/functions/string_functions.md deleted file mode 100644 index 9a2bedf584e..00000000000 --- a/docs/fa/sql_reference/functions/string_functions.md +++ /dev/null @@ -1,489 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0631\u0634\u062A\u0647 \u0647\u0627" ---- - -# توابع برای کار با رشته {#functions-for-working-with-strings} - -## خالی {#empty} - -بازده 1 برای یک رشته خالی و یا 0 برای یک رشته غیر خالی. -نتیجه این نوع uint8. -یک رشته در نظر گرفته شده است غیر خالی اگر شامل حداقل یک بایت, حتی اگر این یک فضا یا یک بایت پوچ است. -این تابع همچنین برای ارریس کار می کند. - -## notEmpty {#notempty} - -بازده 0 برای یک رشته خالی یا 1 برای یک رشته غیر خالی. -نتیجه این نوع uint8. -این تابع همچنین برای ارریس کار می کند. - -## طول {#length} - -بازگرداندن طول یک رشته در بایت (نه در شخصیت, و نه در نقاط کد). -نتیجه این نوع uint64. -این تابع همچنین برای ارریس کار می کند. - -## طول 8 {#lengthutf8} - -بازگرداندن طول یک رشته در نقاط کد یونیکد (نه در شخصیت), فرض کنید که رشته شامل مجموعه ای از بایت است که متن کد گذاری شده را تشکیل می دهند. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). -نتیجه این نوع uint64. - -## \_شروع مجدد {#char-length} - -بازگرداندن طول یک رشته در نقاط کد یونیکد (نه در شخصیت), فرض کنید که رشته شامل مجموعه ای از بایت است که متن کد گذاری شده را تشکیل می دهند. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). -نتیجه این نوع uint64. - -## \_شخصیت شناسی {#character-length} - -بازگرداندن طول یک رشته در نقاط کد یونیکد (نه در شخصیت), فرض کنید که رشته شامل مجموعه ای از بایت است که متن کد گذاری شده را تشکیل می دهند. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). -نتیجه این نوع uint64. - -## پایین تر {#lower} - -تبدیل نمادهای اسکی لاتین در یک رشته به حروف کوچک. - -## بالارفتن {#upper} - -تبدیل نمادهای اسکی لاتین در یک رشته به حروف بزرگ. - -## لوراتف8 {#lowerutf8} - -تبدیل یک رشته به حروف کوچک, فرض رشته شامل مجموعه ای از بایت که یک متن کد گذاری شده-8 را تشکیل می دهند. -این زبان را تشخیص نمی دهد. بنابراین برای ترکیه نتیجه ممکن است دقیقا درست باشد. -اگر طول توالی یونایتد-8 بایت برای مورد بالا و پایین تر از یک نقطه کد متفاوت است, نتیجه ممکن است برای این نقطه کد نادرست. -اگر رشته شامل مجموعه ای از بایت است که سخن گفتن نیست-8, سپس رفتار تعریف نشده است. - -## یوتف8 {#upperutf8} - -تبدیل یک رشته به حروف بزرگ, فرض رشته شامل مجموعه ای از بایت که یک متن کد گذاری شده-8 را تشکیل می دهند. -این زبان را تشخیص نمی دهد. بنابراین برای ترکیه نتیجه ممکن است دقیقا درست باشد. -اگر طول توالی یونایتد-8 بایت برای مورد بالا و پایین تر از یک نقطه کد متفاوت است, نتیجه ممکن است برای این نقطه کد نادرست. -اگر رشته شامل مجموعه ای از بایت است که سخن گفتن نیست-8, سپس رفتار تعریف نشده است. - -## اسوالدیدوتف8 {#isvalidutf8} - -بازده 1, اگر مجموعه ای از کلمه در ادامه متن معتبر است-8 کد گذاری, در غیر این صورت 0. - -## تولدیدوتف8 {#tovalidutf8} - -8 کاراکتر نامعتبر را جایگزین می کند `�` اطلاعات دقیق همه در حال اجرا در یک ردیف شخصیت نامعتبر را به یک شخصیت جایگزین فرو ریخت. - -``` sql -toValidUTF8( input_string ) -``` - -پارامترها: - -- input\_string — Any set of bytes represented as the [رشته](../../sql_reference/data_types/string.md) شی نوع داده. - -مقدار بازگشتی: معتبر یونایتد-8 رشته. - -**مثال** - -``` sql -SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') -``` - -``` text -┌─toValidUTF8('a����b')─┐ -│ a�b │ -└───────────────────────┘ -``` - -## تکرار {#repeat} - -تکرار یک رشته را به عنوان چند بار به عنوان مشخص شده و concatenates تکراری ارزش به عنوان یک رشته است. - -**نحو** - -``` sql -repeat(s, n) -``` - -**پارامترها** - -- `s` — The string to repeat. [رشته](../../sql_reference/data_types/string.md). -- `n` — The number of times to repeat the string. [اینترنت](../../sql_reference/data_types/int_uint.md). - -**مقدار بازگشتی** - -تک رشته ای که حاوی رشته است `s` تکرار `n` زمان. اگر `n` \< 1, تابع رشته خالی می گرداند. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT repeat('abc', 10) -``` - -نتیجه: - -``` text -┌─repeat('abc', 10)──────────────┐ -│ abcabcabcabcabcabcabcabcabcabc │ -└────────────────────────────────┘ -``` - -## معکوس {#reverse} - -معکوس رشته (به عنوان یک دنباله از بایت). - -## معکوس کردن8 {#reverseutf8} - -معکوس دنباله ای از نقاط کد یونیکد, فرض کنید که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن گفته-8. در غیر این صورت, این کار چیز دیگری (این یک استثنا پرتاب نمی). - -## format(pattern, s0, s1, …) {#format} - -قالب بندی الگوی ثابت با رشته ذکر شده در استدلال. `pattern` یک الگوی فرمت پایتون ساده شده است. رشته فرمت شامل “replacement fields” احاطه شده توسط پرانتز فرفری `{}`. هر چیزی که در پرانتز موجود نیست در نظر گرفته شده است متن تحت اللفظی است که بدون تغییر به خروجی کپی شده است. اگر شما نیاز به شامل یک شخصیت بند در متن تحت اللفظی, این را می توان با دو برابر فرار: `{{ '{{' }}` و `{{ '}}' }}`. نام فیلد می تواند اعداد (با شروع از صفر) یا خالی (سپس به عنوان شماره نتیجه درمان می شوند). - -``` sql -SELECT format('{1} {0} {1}', 'World', 'Hello') -``` - -``` text -┌─format('{1} {0} {1}', 'World', 'Hello')─┐ -│ Hello World Hello │ -└─────────────────────────────────────────┘ -``` - -``` sql -SELECT format('{} {}', 'Hello', 'World') -``` - -``` text -┌─format('{} {}', 'Hello', 'World')─┐ -│ Hello World │ -└───────────────────────────────────┘ -``` - -## الحاق {#concat} - -رشته های ذکر شده در استدلال بدون جدا کننده را تصدیق می کند. - -**نحو** - -``` sql -concat(s1, s2, ...) -``` - -**پارامترها** - -ارزش رشته نوع و یا رشته ثابت. - -**مقادیر بازگشتی** - -را برمی گرداند رشته ای که منجر به از الحاق استدلال. - -اگر هر یک از مقادیر استدلال است `NULL`, `concat` بازگشت `NULL`. - -**مثال** - -پرسوجو: - -``` sql -SELECT concat('Hello, ', 'World!') -``` - -نتیجه: - -``` text -┌─concat('Hello, ', 'World!')─┐ -│ Hello, World! │ -└─────────────────────────────┘ -``` - -## همبسته {#concatassumeinjective} - -مثل [الحاق](#concat) تفاوت این است که شما نیاز به اطمینان حاصل شود که `concat(s1, s2, ...) → sn` این برای بهینه سازی گروه توسط استفاده می شود. - -تابع به نام “injective” اگر همیشه نتیجه های مختلف برای مقادیر مختلف استدلال می گرداند. به عبارت دیگر: استدلال های مختلف هرگز نتیجه یکسان عملکرد. - -**نحو** - -``` sql -concatAssumeInjective(s1, s2, ...) -``` - -**پارامترها** - -ارزش رشته نوع و یا رشته ثابت. - -**مقادیر بازگشتی** - -را برمی گرداند رشته ای که منجر به از الحاق استدلال. - -اگر هر یک از مقادیر استدلال است `NULL`, `concatAssumeInjective` بازگشت `NULL`. - -**مثال** - -جدول ورودی: - -``` sql -CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog; -INSERT INTO key_val VALUES ('Hello, ','World',1), ('Hello, ','World',2), ('Hello, ','World!',3), ('Hello',', World!',2); -SELECT * from key_val; -``` - -``` text -┌─key1────┬─key2─────┬─value─┐ -│ Hello, │ World │ 1 │ -│ Hello, │ World │ 2 │ -│ Hello, │ World! │ 3 │ -│ Hello │ , World! │ 2 │ -└─────────┴──────────┴───────┘ -``` - -پرسوجو: - -``` sql -SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY concatAssumeInjective(key1, key2) -``` - -نتیجه: - -``` text -┌─concat(key1, key2)─┬─sum(value)─┐ -│ Hello, World! │ 3 │ -│ Hello, World! │ 2 │ -│ Hello, World │ 3 │ -└────────────────────┴────────────┘ -``` - -## زیر رشته(بازدید کنندگان, انحراف, طول), اواسط(بازدید کنندگان, انحراف, طول), عام (بازدید کنندگان, انحراف, طول) {#substring} - -بازگرداندن یک رشته شروع با بایت از ‘offset’ شاخص این است ‘length’ کلمه در ادامه متن طولانی. نمایه سازی شخصیت از یک شروع می شود (همانطور که در گذاشتن استاندارد). این ‘offset’ و ‘length’ استدلال باید ثابت باشد. - -## زیر بغل کردن 8(بازدید کنندگان, انحراف, طول) {#substringutf8} - -همان ‘substring’, اما برای نقاط کد یونیکد. این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده وزارت مخابرات 8. اگر این فرض ملاقات نکرده است, این گرداند برخی از نتیجه (این یک استثنا پرتاب نمی کند). - -## appendTrailingCharIfAbsent(s, c) {#appendtrailingcharifabsent} - -اگر ‘s’ رشته غیر خالی است و حاوی نیست ‘c’ شخصیت در پایان این برنامه ‘c’ شخصیت به پایان. - -## تبدیل(بازدید کنندگان, از, به) {#convertcharset} - -بازگرداندن رشته ‘s’ که از رمزگذاری در تبدیل شد ‘from’ به رمزگذاری در ‘to’. - -## کد زیر 64) {#base64encode} - -کدگذاریها ‘s’ رشته به پایگاه64 - -## کد زیر 64) {#base64decode} - -رمزگشایی پایگاه64-رشته کد گذاری شده ‘s’ به رشته اصلی. در صورت شکست را افزایش می دهد یک استثنا. - -## تریباس64دسیدی) {#trybase64decode} - -شبیه به حالت کد باس64, اما در صورت خطا یک رشته خالی می شود بازگشت. - -## endsWith(s, پسوند) {#endswith} - -بازگرداندن اینکه با پسوند مشخص شده پایان یابد. بازده 1 اگر رشته به پایان می رسد با پسوند مشخص, در غیر این صورت باز می گردد 0. - -## startsWith(str, پیشوند) {#startswith} - -بازده 1 اینکه رشته با پیشوند مشخص شروع می شود, در غیر این صورت باز می گردد 0. - -``` sql -SELECT startsWith('Spider-Man', 'Spi'); -``` - -**مقادیر بازگشتی** - -- 1, اگر رشته با پیشوند مشخص شروع می شود. -- 0, اگر رشته با پیشوند مشخص شروع نشد. - -**مثال** - -پرسوجو: - -``` sql -SELECT startsWith('Hello, world!', 'He'); -``` - -نتیجه: - -``` text -┌─startsWith('Hello, world!', 'He')─┐ -│ 1 │ -└───────────────────────────────────┘ -``` - -## تر و تمیز {#trim} - -حذف تمام شخصیت های مشخص شده از شروع یا پایان یک رشته. -به طور پیش فرض حذف همه وقوع متوالی از فضای سفید مشترک (شخصیت اسکی 32) از هر دو به پایان می رسد از یک رشته. - -**نحو** - -``` sql -trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) -``` - -**پارامترها** - -- `trim_character` — specified characters for trim. [رشته](../../sql_reference/data_types/string.md). -- `input_string` — string for trim. [رشته](../../sql_reference/data_types/string.md). - -**مقدار بازگشتی** - -یک رشته بدون پیشرو و (یا) انتهایی شخصیت مشخص شده است. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT trim(BOTH ' ()' FROM '( Hello, world! )') -``` - -نتیجه: - -``` text -┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ -│ Hello, world! │ -└───────────────────────────────────────────────┘ -``` - -## trimLeft {#trimleft} - -حذف تمام رخدادهای متوالی از فضای سفید مشترک (شخصیت اسکی 32) از ابتدای یک رشته. آن را نمی کند, حذف انواع دیگر از کاراکترهای فضای سفید (برگه بدون شکستن فضا و غیره.). - -**نحو** - -``` sql -trimLeft(input_string) -``` - -نام مستعار: `ltrim(input_string)`. - -**پارامترها** - -- `input_string` — string to trim. [رشته](../../sql_reference/data_types/string.md). - -**مقدار بازگشتی** - -یک رشته بدون پیشرو فضاهای سفید مشترک. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT trimLeft(' Hello, world! ') -``` - -نتیجه: - -``` text -┌─trimLeft(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## trimRight {#trimright} - -حذف همه متوالی تکرار مشترک فضای خالی (ascii شخصیت 32) از پایان یک رشته است. آن را نمی کند, حذف انواع دیگر از کاراکترهای فضای سفید (برگه بدون شکستن فضا و غیره.). - -**نحو** - -``` sql -trimRight(input_string) -``` - -نام مستعار: `rtrim(input_string)`. - -**پارامترها** - -- `input_string` — string to trim. [رشته](../../sql_reference/data_types/string.md). - -**مقدار بازگشتی** - -یک رشته بدون انتهایی فضاهای خالی مشترک. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT trimRight(' Hello, world! ') -``` - -نتیجه: - -``` text -┌─trimRight(' Hello, world! ')─┐ -│ Hello, world! │ -└──────────────────────────────────────┘ -``` - -## اصلاح {#trimboth} - -حذف تمام رخدادهای متوالی از فضای سفید مشترک (شخصیت اسکی 32) از هر دو به پایان می رسد از یک رشته. این کار انواع دیگر از شخصیت های فضای سفید را حذف کنید (باریکه, فضای بدون استراحت, و غیره.). - -**نحو** - -``` sql -trimBoth(input_string) -``` - -نام مستعار: `trim(input_string)`. - -**پارامترها** - -- `input_string` — string to trim. [رشته](../../sql_reference/data_types/string.md). - -**مقدار بازگشتی** - -یک رشته بدون پیشرو و انتهایی فضاهای سفید مشترک. - -نوع: `String`. - -**مثال** - -پرسوجو: - -``` sql -SELECT trimBoth(' Hello, world! ') -``` - -نتیجه: - -``` text -┌─trimBoth(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## CRC32(s) {#crc32} - -بازگرداندن کنترلی از یک رشته, با استفاده از کروک-32-یی 802.3 چند جملهای و مقدار اولیه `0xffffffff` هشدار داده می شود - -نتیجه این نوع uint32. - -## CRC32IEEE(s) {#crc32ieee} - -را برمی گرداند کنترل از یک رشته, با استفاده از کروم-32-یی 802.3 چند جملهای. - -نتیجه این نوع uint32. - -## CRC64(s) {#crc64} - -بازده crc64 کنترلی از یک رشته با استفاده از crc-64-ecma چند جملهای. - -نتیجه این نوع uint64. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/fa/sql_reference/functions/string_replace_functions.md b/docs/fa/sql_reference/functions/string_replace_functions.md deleted file mode 100644 index 311c89c9a45..00000000000 --- a/docs/fa/sql_reference/functions/string_replace_functions.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u0628\u0631\u0627\u06CC \u062C\u0627\u06CC\u06AF\u0632\u06CC\u0646\u06CC\ - \ \u062F\u0631 \u0631\u0634\u062A\u0647\u0647\u0627" ---- - -# توابع برای جستجو و جایگزینی در رشته ها {#functions-for-searching-and-replacing-in-strings} - -## جایگزینی جایگزین) {#replaceonehaystack-pattern-replacement} - -جایگزین وقوع اول, در صورت وجود, از ‘pattern’ زیر رشته در ‘haystack’ با ‘replacement’ زیر رشته. -از این پس, ‘pattern’ و ‘replacement’ حتما ثابته - -## replaceAll(haystack, الگوی جایگزینی) جایگزین(haystack, الگوی جایگزینی) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} - -جایگزین تمام اتفاقات ‘pattern’ زیر رشته در ‘haystack’ با ‘replacement’ زیر رشته. - -## جایگزین کردن الگوی جایگزین) {#replaceregexponehaystack-pattern-replacement} - -جایگزینی با استفاده از ‘pattern’ عبارت منظم. دوباره2 عبارت منظم. -جایگزین تنها وقوع اول, در صورت وجود. -یک الگو را می توان به عنوان ‘replacement’. این الگو می تواند شامل تعویض `\0-\9`. -جایگزینی `\0` شامل کل عبارت منظم. درحال جایگزینی `\1-\9` مربوط به زیرخط numbers.To استفاده از `\` شخصیت در قالب, فرار با استفاده از `\`. -همچنین در نظر داشته باشید که یک رشته تحت اللفظی نیاز به فرار اضافی نگه دارید. - -مثال 1. تبدیل تاریخ به فرمت امریکایی: - -``` sql -SELECT DISTINCT - EventDate, - replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res -FROM test.hits -LIMIT 7 -FORMAT TabSeparated -``` - -``` text -2014-03-17 03/17/2014 -2014-03-18 03/18/2014 -2014-03-19 03/19/2014 -2014-03-20 03/20/2014 -2014-03-21 03/21/2014 -2014-03-22 03/22/2014 -2014-03-23 03/23/2014 -``` - -مثال 2. کپی کردن یک رشته ده بار: - -``` sql -SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res -``` - -``` text -┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## جایگزین کردن الگوی جایگزین) {#replaceregexpallhaystack-pattern-replacement} - -این کار همان چیزی, اما جایگزین همه وقوع. مثال: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res -``` - -``` text -┌─res────────────────────────┐ -│ HHeelllloo,, WWoorrlldd!! │ -└────────────────────────────┘ -``` - -به عنوان یک استثنا, اگر یک عبارت منظم در زیر رشته خالی کار می کرد, جایگزینی بیش از یک بار ساخته شده است. -مثال: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res -``` - -``` text -┌─res─────────────────┐ -│ here: Hello, World! │ -└─────────────────────┘ -``` - -## سرویس پرداخت درونبرنامهای پلی) {#regexpquotemetas} - -تابع می افزاید: یک بک اسلش قبل از برخی از شخصیت های از پیش تعریف شده در رشته. -نویسههای از پیش تعریفشده: ‘0’, ‘\\’, ‘\|’, ‘(’, ‘)’, ‘^’, ‘$’, ‘.’, ‘\[’, '\]', ‘?’, '\*‘,’+‘,’{‘,’:‘,’-'. -این اجرای کمی از دوباره متفاوت2::پاسخ2:: نقل قول. این فرار صفر بایت به عنوان \\ 0 بجای 00 و فرار شخصیت تنها مورد نیاز. -برای کسب اطلاعات بیشتر به لینک مراجعه کنید: [RE2](https://github.com/google/re2/blob/master/re2/re2.cc#L473) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/fa/sql_reference/functions/string_search_functions.md b/docs/fa/sql_reference/functions/string_search_functions.md deleted file mode 100644 index 9c18958d48f..00000000000 --- a/docs/fa/sql_reference/functions/string_search_functions.md +++ /dev/null @@ -1,380 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: "\u0628\u0631\u0627\u06CC \u062C\u0633\u062A\u062C\u0648\u06CC \u0631\u0634\ - \u062A\u0647\u0647\u0627" ---- - -# توابع برای جستجوی رشته ها {#functions-for-searching-strings} - -جستجو به طور پیش فرض در تمام این توابع حساس به حروف است. انواع جداگانه ای برای جستجوی غیر حساس مورد وجود دارد. - -## موقعیت (انبار کاه, سوزن), تعیین محل (انبار کاه, سوزن) {#position} - -بازگرداندن موقعیت (به بایت) از رشته پیدا شده است در رشته, با شروع از 1. - -این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری تک بایت. اگر این فرض ملاقات کرد و یک شخصیت نمی تواند با استفاده از یک بایت تنها نشان داده شود, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو بایت نشان, این دو بایت و غیره استفاده. - -برای یک جستجو غیر حساس به حالت, استفاده از تابع [حساس به حالت](#positioncaseinsensitive). - -**نحو** - -``` sql -position(haystack, needle) -``` - -نام مستعار: `locate(haystack, needle)`. - -**پارامترها** - -- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). - -**مقادیر بازگشتی** - -- موقعیت شروع در بایت (شمارش از 1), اگر زیر رشته پیدا شد. -- 0, اگر زیر رشته یافت نشد. - -نوع: `Integer`. - -**مثالها** - -عبارت “Hello, world!” شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری تک بایت. تابع بازده برخی از نتیجه انتظار می رود: - -پرسوجو: - -``` sql -SELECT position('Hello, world!', '!') -``` - -نتیجه: - -``` text -┌─position('Hello, world!', '!')─┐ -│ 13 │ -└────────────────────────────────┘ -``` - -همان عبارت در روسیه شامل شخصیت های که نمی تواند با استفاده از یک بایت نشان داده شود. تابع بازده برخی از نتیجه غیر منتظره (استفاده [موقعیت 8](#positionutf8) تابع برای متن چند بایت کد گذاری): - -پرسوجو: - -``` sql -SELECT position('Привет, мир!', '!') -``` - -نتیجه: - -``` text -┌─position('Привет, мир!', '!')─┐ -│ 21 │ -└───────────────────────────────┘ -``` - -## حساس به حالت {#positioncaseinsensitive} - -همان [موقعیت](#position) بازگرداندن موقعیت (به بایت) از رشته پیدا شده است در رشته, با شروع از 1. استفاده از تابع برای یک جستجو غیر حساس به حالت. - -این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری تک بایت. اگر این فرض ملاقات کرد و یک شخصیت نمی تواند با استفاده از یک بایت تنها نشان داده شود, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو بایت نشان, این دو بایت و غیره استفاده. - -**نحو** - -``` sql -positionCaseInsensitive(haystack, needle) -``` - -**پارامترها** - -- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). - -**مقادیر بازگشتی** - -- موقعیت شروع در بایت (شمارش از 1), اگر زیر رشته پیدا شد. -- 0, اگر زیر رشته یافت نشد. - -نوع: `Integer`. - -**مثال** - -پرسوجو: - -``` sql -SELECT positionCaseInsensitive('Hello, world!', 'hello') -``` - -نتیجه: - -``` text -┌─positionCaseInsensitive('Hello, world!', 'hello')─┐ -│ 1 │ -└───────────────────────────────────────────────────┘ -``` - -## موقعیت 8 {#positionutf8} - -بازگرداندن موقعیت (در نقاط یونیکد) از رشته پیدا شده است در رشته, با شروع از 1. - -این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده وزارت مخابرات 8. اگر این فرض ملاقات نمی, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو نقطه یونیکد نشان, این دو و غیره استفاده. - -برای یک جستجو غیر حساس به حالت, استفاده از تابع [در حال بارگذاری](#positioncaseinsensitiveutf8). - -**نحو** - -``` sql -positionUTF8(haystack, needle) -``` - -**پارامترها** - -- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). - -**مقادیر بازگشتی** - -- موقعیت شروع در یونیکد امتیاز (شمارش از 1), اگر زیر رشته پیدا شد. -- 0, اگر زیر رشته یافت نشد. - -نوع: `Integer`. - -**مثالها** - -عبارت “Hello, world!” در روسیه شامل مجموعه ای از نقاط یونیکد نمایندگی یک متن کد گذاری تک نقطه. تابع بازده برخی از نتیجه انتظار می رود: - -پرسوجو: - -``` sql -SELECT positionUTF8('Привет, мир!', '!') -``` - -نتیجه: - -``` text -┌─positionUTF8('Привет, мир!', '!')─┐ -│ 12 │ -└───────────────────────────────────┘ -``` - -عبارت “Salut, étudiante!”, جایی که شخصیت `é` می توان با استفاده از یک نقطه نشان داد (`U+00E9`) یا دو نقطه (`U+0065U+0301`) تابع را می توان بازگشت برخی از نتیجه غیر منتظره: - -پرسوجو برای نامه `é` که نشان داده شده است یک نقطه یونیکد `U+00E9`: - -``` sql -SELECT positionUTF8('Salut, étudiante!', '!') -``` - -نتیجه: - -``` text -┌─positionUTF8('Salut, étudiante!', '!')─┐ -│ 17 │ -└────────────────────────────────────────┘ -``` - -پرسوجو برای نامه `é` که به نمایندگی از دو نقطه یونیکد `U+0065U+0301`: - -``` sql -SELECT positionUTF8('Salut, étudiante!', '!') -``` - -نتیجه: - -``` text -┌─positionUTF8('Salut, étudiante!', '!')─┐ -│ 18 │ -└────────────────────────────────────────┘ -``` - -## در حال بارگذاری {#positioncaseinsensitiveutf8} - -همان [موقعیت 8](#positionutf8), اما غیر حساس به حروف است. بازگرداندن موقعیت (در نقاط یونیکد) از رشته پیدا شده است در رشته, با شروع از 1. - -این نسخهها کار میکند با این فرض که رشته شامل مجموعه ای از بایت به نمایندگی از یک متن کد گذاری شده وزارت مخابرات 8. اگر این فرض ملاقات نمی, تابع یک استثنا پرتاب نمی کند و برخی از نتیجه غیر منتظره را برمی گرداند. اگر شخصیت را می توان با استفاده از دو نقطه یونیکد نشان, این دو و غیره استفاده. - -**نحو** - -``` sql -positionCaseInsensitiveUTF8(haystack, needle) -``` - -**پارامترها** - -- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). - -**مقدار بازگشتی** - -- موقعیت شروع در یونیکد امتیاز (شمارش از 1), اگر زیر رشته پیدا شد. -- 0, اگر زیر رشته یافت نشد. - -نوع: `Integer`. - -**مثال** - -پرسوجو: - -``` sql -SELECT positionCaseInsensitiveUTF8('Привет, мир!', 'Мир') -``` - -نتیجه: - -``` text -┌─positionCaseInsensitiveUTF8('Привет, мир!', 'Мир')─┐ -│ 9 │ -└────────────────────────────────────────────────────┘ -``` - -## چند ضلعی {#multisearchallpositions} - -همان [موقعیت](string_search_functions.md#position) اما بازگشت `Array` از موقعیت (به بایت) از بسترهای مربوطه موجود در رشته. موقعیت ها با شروع از نمایه 1. - -جستجو در دنباله ای از بایت بدون توجه به رمزگذاری رشته و میترا انجام می شود. - -- برای جستجو اسکی غیر حساس به حالت, استفاده از تابع `multiSearchAllPositionsCaseInsensitive`. -- برای جستجو در یوتف-8, استفاده از تابع [چند ضلعی پایگاه داده های8](#multiSearchAllPositionsUTF8). -- برای غیر حساس به حالت جستجو-8, استفاده از تابع چند تخصیص چندگانه 18. - -**نحو** - -``` sql -multiSearchAllPositions(haystack, [needle1, needle2, ..., needlen]) -``` - -**پارامترها** - -- `haystack` — string, in which substring will to be searched. [رشته](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [رشته](../syntax.md#syntax-string-literal). - -**مقادیر بازگشتی** - -- مجموعه ای از موقعیت های شروع در بایت (شمارش از 1), اگر زیر رشته مربوطه پیدا شد و 0 اگر یافت نشد. - -**مثال** - -پرسوجو: - -``` sql -SELECT multiSearchAllPositions('Hello, World!', ['hello', '!', 'world']) -``` - -نتیجه: - -``` text -┌─multiSearchAllPositions('Hello, World!', ['hello', '!', 'world'])─┐ -│ [0,13,0] │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## چند ضلعی پایگاه داده های8 {#multiSearchAllPositionsUTF8} - -ببینید `multiSearchAllPositions`. - -## ترکیب چندجفتاری (هیستک, \[سوزن1 سوزن2, …, needleنه\]) {#multisearchfirstposition} - -همان `position` اما بازده سمت چپ افست از رشته `haystack` که به برخی از سوزن همسان. - -برای یک جستجوی غیر حساس مورد و یا / و در توابع استفاده از فرمت جی تی اف 8 `multiSearchFirstPositionCaseInsensitive, multiSearchFirstPositionUTF8, multiSearchFirstPositionCaseInsensitiveUTF8`. - -## مقالههای جدید مرتبط با تحقیق این نویسنده1 سوزن2, …, needleنه\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} - -بازگرداندن شاخص `i` (شروع از 1) سوزن چپ پیدا شده استمن ... در رشته `haystack` و 0 در غیر این صورت. - -برای یک جستجوی غیر حساس مورد و یا / و در توابع استفاده از فرمت جی تی اف 8 `multiSearchFirstIndexCaseInsensitive, multiSearchFirstIndexUTF8, multiSearchFirstIndexCaseInsensitiveUTF8`. - -## مولسیرچانی (هیستک, \[سوزن1 سوزن2, …, needleنه\]) {#function-multisearchany} - -بازده 1, اگر حداقل یک سوزن رشتهمن ... مسابقات رشته `haystack` و 0 در غیر این صورت. - -برای یک جستجوی غیر حساس مورد و یا / و در توابع استفاده از فرمت جی تی اف 8 `multiSearchAnyCaseInsensitive, multiSearchAnyUTF8, multiSearchAnyCaseInsensitiveUTF8`. - -!!! note "یادداشت" - در همه `multiSearch*` توابع تعداد سوزن ها باید کمتر از 2 باشد8 به دلیل مشخصات پیاده سازی. - -## همخوانی داشتن (کومه علف خشک, الگو) {#matchhaystack-pattern} - -بررسی اینکه رشته با `pattern` عبارت منظم. یک `re2` عبارت منظم. این [نحو](https://github.com/google/re2/wiki/Syntax) از `re2` عبارات منظم محدود تر از نحو عبارات منظم پرل است. - -بازده 0 اگر مطابقت ندارد, یا 1 اگر منطبق. - -توجه داشته باشید که نماد ممیز (`\`) برای فرار در عبارت منظم استفاده می شود. همان نماد برای فرار در لیتر رشته استفاده می شود. بنابراین به منظور فرار از نماد در یک عبارت منظم, شما باید دو بک اسلش ارسال (\\) در یک رشته تحت اللفظی. - -عبارت منظم با رشته کار می کند به عنوان اگر مجموعه ای از بایت است. عبارت منظم می تواند بایت پوچ نیست. -برای الگوهای به جستجو برای بسترهای در یک رشته, بهتر است به استفاده از مانند و یا ‘position’ از اونجایی که خیلی سریعتر کار میکنن - -## ملتمتچانی (کومه علف خشک, \[الگو1 الگو2, …, patternنه\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} - -همان `match`, اما بازده 0 اگر هیچ یک از عبارات منظم همسان و 1 اگر هر یک از الگوهای مسابقات. این استفاده می کند [hyperscan](https://github.com/intel/hyperscan) کتابخونه. برای الگوهای به جستجو بسترهای در یک رشته, بهتر است به استفاده از `multiSearchAny` چون خیلی سریعتر کار میکنه - -!!! note "یادداشت" - طول هر یک از `haystack` رشته باید کمتر از 2 باشد32 بایت در غیر این صورت استثنا پرتاب می شود. این محدودیت صورت می گیرد به دلیل hyperscan API. - -## مقالههای جدید مرتبط با تحقیق این نویسنده1 الگو2, …, patternنه\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} - -همان `multiMatchAny`, اما بازگرداندن هر شاخص که منطبق بر انبار کاه. - -## اطلاعات دقیق1 الگو2, …, patternنه\]) {#multimatchallindiceshaystack-pattern1-pattern2-patternn} - -همان `multiMatchAny`, اما بازگرداندن مجموعه ای از تمام شاخص که مطابقت انبار کاه در هر سفارش. - -## چندبازیماتچانی (هیستک, فاصله, \[الگو1 الگو2, …, patternنه\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} - -همان `multiMatchAny`, اما بازده 1 اگر هر الگوی منطبق انبار کاه در یک ثابت [ویرایش فاصله](https://en.wikipedia.org/wiki/Edit_distance). این تابع نیز در حالت تجربی است و می تواند بسیار کند باشد. برای اطلاعات بیشتر نگاه کنید به [hyperscan مستندات](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching). - -## چند شکلی (هیستاک, فاصله, \[الگو1 الگو2, …, patternنه\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} - -همان `multiFuzzyMatchAny`, اما می گرداند هر شاخص که منطبق بر انبار کاه در فاصله ویرایش ثابت. - -## بازهای چندگانه (انبار کاه, فاصله, \[الگو1 الگو2, …, patternنه\]) {#multifuzzymatchallindiceshaystack-distance-pattern1-pattern2-patternn} - -همان `multiFuzzyMatchAny`, اما بازگرداندن مجموعه ای از تمام شاخص در هر منظور که مطابقت با انبار کاه در فاصله ویرایش ثابت. - -!!! note "یادداشت" - `multiFuzzyMatch*` توابع از عبارات منظم یونایتد-8 پشتیبانی نمی کنند و چنین عبارات به عنوان بایت به دلیل محدودیت هیپراکسان درمان می شوند. - -!!! note "یادداشت" - برای خاموش کردن تمام توابع است که با استفاده از بیش از حد اسکان, استفاده از تنظیمات `SET allow_hyperscan = 0;`. - -## عصاره (انبار کاه, الگو) {#extracthaystack-pattern} - -عصاره یک قطعه از یک رشته با استفاده از یک عبارت منظم. اگر ‘haystack’ با ‘pattern’ عبارت منظم, یک رشته خالی بازگشته است. اگر عبارت منظم حاوی وسترن نیست, طول می کشد قطعه که منطبق بر کل عبارت منظم. در غیر این صورت قطعه ای را می گیرد که با اولین زیر دست ساز مطابقت دارد. - -## خارج تماس بگیرید) {#extractallhaystack-pattern} - -عصاره تمام قطعات از یک رشته با استفاده از یک عبارت منظم. اگر ‘haystack’ با ‘pattern’ عبارت منظم, یک رشته خالی بازگشته است. بازگرداندن مجموعه ای از رشته متشکل از تمام مسابقات به عبارت منظم. به طور کلی, رفتار همان است که ‘extract’ تابع (در آن طول می کشد برای اولین بار subpattern یا کل بیان اگر وجود ندارد subpattern). - -## مانند (کومه علف خشک, الگو), کومه علف خشک مانند اپراتور الگوی {#function-like} - -بررسی اینکه یک رشته منطبق یک عبارت ساده به طور منظم. -عبارت منظم می تواند حاوی متسیمبلس باشد `%` و `_`. - -`%` نشان می دهد هر مقدار از هر بایت (از جمله صفر شخصیت). - -`_` نشان می دهد هر یک بایت. - -از بک اسلش استفاده کنید (`\`) برای فرار از متسیمبلس . توجه داشته باشید در فرار در شرح ‘match’ تابع. - -برای عبارات منظم مانند `%needle%`, کد مطلوب تر است و کار می کند به همان سرعتی که `position` تابع. -برای دیگر عبارات منظم, کد همان است که برای است ‘match’ تابع. - -## notLike(انبار کاه pattern), انبار کاه نیست مانند الگوی اپراتور {#function-notlike} - -همان چیزی که به عنوان ‘like’, اما منفی. - -## نمک زدایی (انبار کاه, سوزن) {#ngramdistancehaystack-needle} - -محاسبه فاصله 4 گرم بین `haystack` و `needle`: counts the symmetric difference between two multisets of 4-grams and normalizes it by the sum of their cardinalities. Returns float number from 0 to 1 – the closer to zero, the more strings are similar to each other. If the constant `needle` یا `haystack` بیش از 32 کیلوبایت است, می اندازد یک استثنا. اگر برخی از غیر ثابت `haystack` یا `needle` رشته ها بیش از 32 کیلوبایت, فاصله است که همیشه یکی. - -برای جستجوی غیر حساس به حالت یا / و در توابع استفاده از فرمت جی تی اف 8 `ngramDistanceCaseInsensitive, ngramDistanceUTF8, ngramDistanceCaseInsensitiveUTF8`. - -## نگراماسراچ (هیستک سوزن) {#ngramsearchhaystack-needle} - -مثل `ngramDistance` اما محاسبه تفاوت غیر متقارن بین `needle` و `haystack` – the number of n-grams from needle minus the common number of n-grams normalized by the number of `needle` مامان بزرگ نزدیک تر به یک, بیشتر احتمال دارد `needle` در `haystack`. می تواند برای جستجو رشته فازی مفید باشد. - -برای جستجوی غیر حساس به حالت یا / و در توابع استفاده از فرمت جی تی اف 8 `ngramSearchCaseInsensitive, ngramSearchUTF8, ngramSearchCaseInsensitiveUTF8`. - -!!! note "یادداشت" - For UTF-8 case we use 3-gram distance. All these are not perfectly fair n-gram distances. We use 2-byte hashes to hash n-grams and then calculate the (non-)symmetric difference between these hash tables – collisions may occur. With UTF-8 case-insensitive format we do not use fair `tolower` function – we zero the 5-th bit (starting from zero) of each codepoint byte and first bit of zeroth byte if bytes more than one – this works for Latin and mostly for all Cyrillic letters. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/fa/sql_reference/functions/type_conversion_functions.md b/docs/fa/sql_reference/functions/type_conversion_functions.md deleted file mode 100644 index ed3c83b3031..00000000000 --- a/docs/fa/sql_reference/functions/type_conversion_functions.md +++ /dev/null @@ -1,534 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: "\u062A\u0628\u062F\u06CC\u0644 \u0646\u0648\u0639" ---- - -# توابع تبدیل نوع {#type-conversion-functions} - -## مشکلات متداول تبدیل عددی {#numeric-conversion-issues} - -هنگامی که شما یک مقدار تبدیل از یک به نوع داده های دیگر, شما باید به یاد داشته باشید که در مورد مشترک, این یک عملیات نا امن است که می تواند به از دست دادن داده ها منجر شود. از دست دادن داده ها می تواند رخ دهد اگر شما سعی می کنید به جا ارزش از یک نوع داده بزرگتر به یک نوع داده کوچکتر, و یا اگر شما ارزش بین انواع داده های مختلف تبدیل. - -کلیک کرده است [همان رفتار به عنوان ج++ برنامه](https://en.cppreference.com/w/cpp/language/implicit_conversion). - -## toInt(8/16/32/64) {#toint8163264} - -تبدیل یک مقدار ورودی به [Int](../../sql_reference/data_types/int_uint.md) نوع داده. این خانواده تابع شامل: - -- `toInt8(expr)` — Results in the `Int8` نوع داده. -- `toInt16(expr)` — Results in the `Int16` نوع داده. -- `toInt32(expr)` — Results in the `Int32` نوع داده. -- `toInt64(expr)` — Results in the `Int64` نوع داده. - -**پارامترها** - -- `expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد یا یک رشته با نمایش اعشاری یک عدد. دودویی, مبنای هشت, و بازنمایی هگزادسیمال از اعداد پشتیبانی نمی شوند. صفر منجر محروم هستند. - -**مقدار بازگشتی** - -مقدار صحیح در `Int8`, `Int16`, `Int32` یا `Int64` نوع داده. - -توابع استفاده [گرد کردن به سمت صفر](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) یعنی عدد کسری از اعداد را کوتاه می کنند. - -رفتار توابع برای [هشدار داده می شود](../../sql_reference/data_types/float.md#data_type-float-nan-inf) استدلال تعریف نشده است. به یاد داشته باشید در مورد [مسایل همگرایی عددی](#numeric-conversion-issues), هنگام استفاده از توابع. - -**مثال** - -``` sql -SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) -``` - -``` text -┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ -│ -9223372036854775808 │ 32 │ 16 │ 8 │ -└──────────────────────┴─────────────┴───────────────┴─────────────┘ -``` - -## toInt(8/16/32/64)OrZero {#toint8163264orzero} - -این استدلال از نوع رشته طول می کشد و تلاش می کند تا به اعضای هیات تجزیه (8 \| 16 \| 32 \| 64). اگر شکست خورده, بازده 0. - -**مثال** - -``` sql -select toInt64OrZero('123123'), toInt8OrZero('123qwe123') -``` - -``` text -┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ -│ 123123 │ 0 │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toInt(8/16/32/64)OrNull {#toint8163264ornull} - -این استدلال از نوع رشته طول می کشد و تلاش می کند تا به اعضای هیات تجزیه (8 \| 16 \| 32 \| 64). اگر شکست خورده, تهی گرداند. - -**مثال** - -``` sql -select toInt64OrNull('123123'), toInt8OrNull('123qwe123') -``` - -``` text -┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ -│ 123123 │ ᴺᵁᴸᴸ │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toUInt(8/16/32/64) {#touint8163264} - -تبدیل یک مقدار ورودی به [اینترنت](../../sql_reference/data_types/int_uint.md) نوع داده. این خانواده تابع شامل: - -- `toUInt8(expr)` — Results in the `UInt8` نوع داده. -- `toUInt16(expr)` — Results in the `UInt16` نوع داده. -- `toUInt32(expr)` — Results in the `UInt32` نوع داده. -- `toUInt64(expr)` — Results in the `UInt64` نوع داده. - -**پارامترها** - -- `expr` — [عبارت](../syntax.md#syntax-expressions) بازگشت یک عدد یا یک رشته با نمایش اعشاری یک عدد. دودویی, مبنای هشت, و بازنمایی هگزادسیمال از اعداد پشتیبانی نمی شوند. صفر منجر محروم هستند. - -**مقدار بازگشتی** - -مقدار صحیح در `UInt8`, `UInt16`, `UInt32` یا `UInt64` نوع داده. - -توابع استفاده [گرد کردن به سمت صفر](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) یعنی عدد کسری از اعداد را کوتاه می کنند. - -رفتار توابع برای کشاورزی منفی و برای [هشدار داده می شود](../../sql_reference/data_types/float.md#data_type-float-nan-inf) استدلال تعریف نشده است. اگر شما یک رشته عبور با تعداد منفی, مثلا `'-32'`, خانه را افزایش می دهد یک استثنا. به یاد داشته باشید در مورد [مسایل همگرایی عددی](#numeric-conversion-issues), هنگام استفاده از توابع. - -**مثال** - -``` sql -SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) -``` - -``` text -┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ -│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ -└─────────────────────┴───────────────┴────────────────┴──────────────┘ -``` - -## toUInt(8/16/32/64)OrZero {#touint8163264orzero} - -## toUInt(8/16/32/64)OrNull {#touint8163264ornull} - -## توفلوات (32/64) {#tofloat3264} - -## toFloat(32/64)OrZero {#tofloat3264orzero} - -## toFloat(32/64)OrNull {#tofloat3264ornull} - -## toDate {#todate} - -## تودارزرو {#todateorzero} - -## طول عمر {#todateornull} - -## toDateTime {#todatetime} - -## به اندازه تو {#todatetimeorzero} - -## طول عمر ترنول {#todatetimeornull} - -## toDecimal(32/64/128) {#todecimal3264128} - -تبدیل `value` به [دهدهی](../../sql_reference/data_types/decimal.md) نوع داده با دقت `S`. این `value` می تواند یک عدد یا یک رشته. این `S` (مقیاس) پارامتر تعداد رقم اعشار را مشخص می کند. - -- `toDecimal32(value, S)` -- `toDecimal64(value, S)` -- `toDecimal128(value, S)` - -## toDecimal(32/64/128)OrNull {#todecimal3264128ornull} - -تبدیل یک رشته ورودی به یک [Nullable(اعشاری(P,S))](../../sql_reference/data_types/decimal.md) مقدار نوع داده. این خانواده از توابع عبارتند از: - -- `toDecimal32OrNull(expr, S)` — Results in `Nullable(Decimal32(S))` نوع داده. -- `toDecimal64OrNull(expr, S)` — Results in `Nullable(Decimal64(S))` نوع داده. -- `toDecimal128OrNull(expr, S)` — Results in `Nullable(Decimal128(S))` نوع داده. - -این توابع باید به جای استفاده `toDecimal*()` توابع, اگر شما ترجیح می دهید برای دریافت یک `NULL` ارزش به جای یک استثنا در صورت خطا تجزیه ارزش ورودی. - -**پارامترها** - -- `expr` — [عبارت](../syntax.md#syntax-expressions), بازگرداندن یک مقدار در [رشته](../../sql_reference/data_types/string.md) نوع داده. تاتر انتظار نمایندگی متنی از عدد اعشاری. به عنوان مثال, `'1.111'`. -- `S` — Scale, the number of decimal places in the resulting value. - -**مقدار بازگشتی** - -یک مقدار در `Nullable(Decimal(P,S))` نوع داده. مقدار شامل: - -- شماره با `S` اعشار, اگر تاتر تفسیر رشته ورودی به عنوان یک عدد. -- `NULL`, اگر تاتر می توانید رشته ورودی به عنوان یک عدد تفسیر نمی کند و یا اگر تعداد ورودی شامل بیش از `S` رقم اعشار. - -**مثالها** - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ -│ -1.11100 │ Nullable(Decimal(9, 5)) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ -│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toDecimal(32/64/128)OrZero {#todecimal3264128orzero} - -تبدیل یک مقدار ورودی به [دهدهی)](../../sql_reference/data_types/decimal.md) نوع داده. این خانواده از توابع عبارتند از: - -- `toDecimal32OrZero( expr, S)` — Results in `Decimal32(S)` نوع داده. -- `toDecimal64OrZero( expr, S)` — Results in `Decimal64(S)` نوع داده. -- `toDecimal128OrZero( expr, S)` — Results in `Decimal128(S)` نوع داده. - -این توابع باید به جای استفاده `toDecimal*()` توابع, اگر شما ترجیح می دهید برای دریافت یک `0` ارزش به جای یک استثنا در صورت خطا تجزیه ارزش ورودی. - -**پارامترها** - -- `expr` — [عبارت](../syntax.md#syntax-expressions), بازگرداندن یک مقدار در [رشته](../../sql_reference/data_types/string.md) نوع داده. تاتر انتظار نمایندگی متنی از عدد اعشاری. به عنوان مثال, `'1.111'`. -- `S` — Scale, the number of decimal places in the resulting value. - -**مقدار بازگشتی** - -یک مقدار در `Nullable(Decimal(P,S))` نوع داده. مقدار شامل: - -- شماره با `S` اعشار, اگر تاتر تفسیر رشته ورودی به عنوان یک عدد. -- 0 با `S` رقم اعشار, اگر تاتر می توانید رشته ورودی به عنوان یک عدد تفسیر نمی کند و یا اگر تعداد ورودی شامل بیش از `S` رقم اعشار. - -**مثال** - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ -│ -1.11100 │ Decimal(9, 5) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ -│ 0.00 │ Decimal(9, 2) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toString {#tostring} - -توابع برای تبدیل بین اعداد, رشته ها (اما رشته ثابت نیست), تاریخ, و تاریخ با زمان. -همه این توابع قبول یک استدلال. - -در هنگام تبدیل به و یا از یک رشته, ارزش فرمت شده و یا تجزیه با استفاده از قوانین مشابه برای فرمت جدولبندیشده (و تقریبا تمام فرمت های متنی دیگر). اگر رشته را نمی توان تجزیه, یک استثنا پرتاب می شود و درخواست لغو شده است. - -هنگام تبدیل تاریخ به اعداد و یا بالعکس, تاریخ مربوط به تعداد روز از ابتدای عصر یونیکس. -هنگام تبدیل تاریخ با بار به اعداد و یا بالعکس, تاریخ با زمان مربوط به تعداد ثانیه از ابتدای عصر یونیکس. - -تاریخ و تاریخ-با-فرمت زمان برای todate/todatetime توابع تعریف شده به شرح زیر است: - -``` text -YYYY-MM-DD -YYYY-MM-DD hh:mm:ss -``` - -به عنوان یک استثنا اگر تبدیل از uint32, int32, uint64 یا int64 عددی انواع, به, تاریخ, و اگر عدد بزرگتر یا مساوی به 65536 تعدادی را به عنوان تفسیر یک زمان یونیکس (و نه به عنوان تعداد روز) و گرد است به تاریخ. این اجازه می دهد تا پشتیبانی از وقوع مشترک نوشتن ‘toDate(unix\_timestamp)’ که در غیر این صورت یک خطا خواهد بود و نیاز به نوشتن بیشتر دست و پا گیر ‘toDate(toDateTime(unix\_timestamp))’. - -تبدیل بین تاریخ و تاریخ با زمان انجام شده است راه طبیعی: با اضافه کردن یک زمان خالی و یا حذف زمان. - -تبدیل بین انواع عددی با استفاده از قوانین مشابه به عنوان تکالیف بین انواع مختلف عددی در ج++. - -علاوه بر این, تابع حول از استدلال حسگر ناحیه رنگی می توانید یک استدلال رشته دوم حاوی نام منطقه زمانی را. مثال: `Asia/Yekaterinburg` در این مورد, زمان با توجه به منطقه زمانی مشخص فرمت. - -``` sql -SELECT - now() AS now_local, - toString(now(), 'Asia/Yekaterinburg') AS now_yekat -``` - -``` text -┌───────────now_local─┬─now_yekat───────────┐ -│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ -└─────────────────────┴─────────────────────┘ -``` - -همچنین `toUnixTimestamp` تابع. - -## وضعیت زیستشناختی رکورد) {#tofixedstrings-n} - -تبدیل یک استدلال نوع رشته به یک رشته (نفر) نوع (یک رشته با طول ثابت نفر). نفر باید ثابت باشد. -اگر رشته دارای بایت کمتر از نفر, این است که با بایت پوچ به سمت راست منتقل. اگر رشته دارای بایت بیش از نفر, یک استثنا پرتاب می شود. - -## در حال بارگذاری) {#tostringcuttozeros} - -می پذیرد یک رشته یا رشته ثابت استدلال. بازگرداندن رشته با محتوای کوتاه در اولین صفر بایت پیدا شده است. - -مثال: - -``` sql -SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s─────────────┬─s_cut─┐ -│ foo\0\0\0\0\0 │ foo │ -└───────────────┴───────┘ -``` - -``` sql -SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s──────────┬─s_cut─┐ -│ foo\0bar\0 │ foo │ -└────────────┴───────┘ -``` - -## reinterpretAsUInt(8/16/32/64) {#reinterpretasuint8163264} - -## reinterpretAsInt(8/16/32/64) {#reinterpretasint8163264} - -## تفسیر مجدد (32/64) {#reinterpretasfloat3264} - -## بازخوانی مجدد {#reinterpretasdate} - -## حسگر ناحیه رنگی {#reinterpretasdatetime} - -این توابع یک رشته را قبول می کنند و بایت هایی را که در ابتدای رشته قرار می گیرند به عنوان یک عدد در دستور میزبان (اندی کوچک) تفسیر می کنند. اگر رشته به اندازه کافی بلند نیست, توابع کار به عنوان اگر رشته با تعداد لازم از بایت پوچ خالی. اگر رشته طولانی تر از مورد نیاز است, بایت اضافی نادیده گرفته می شوند. تاریخ به عنوان تعداد روز از ابتدای عصر یونیکس تفسیر و تاریخ با زمان به عنوان تعداد ثانیه از ابتدای عصر یونیکس تفسیر شده است. - -## رشته مجدد {#type_conversion_functions-reinterpretAsString} - -این تابع یک شماره یا تاریخ و یا تاریخ با زمان می پذیرد, و یک رشته حاوی بایت به نمایندگی از ارزش مربوطه را در سفارش میزبان را برمی گرداند (اندی کمی). بایت پوچ از پایان کاهش یافته است. مثلا, ارزش نوع اوینت32 255 یک رشته است که یک بایت طولانی است. - -## رشته مجدد {#reinterpretasfixedstring} - -این تابع یک شماره یا تاریخ و یا تاریخ با زمان می پذیرد, و یک رشته ثابت حاوی بایت به نمایندگی از ارزش مربوطه را در سفارش میزبان را برمی گرداند (اندی کمی). بایت پوچ از پایان کاهش یافته است. مثلا, ارزش نوع اوینت32 255 رشته ثابت است که یک بایت طولانی است. - -## قالب (ایکس تی) {#type_conversion_function-cast} - -تبدیل ‘x’ به ‘t’ نوع داده. بازیگران نحو (ایکس به عنوان تی) نیز پشتیبانی می کند. - -مثال: - -``` sql -SELECT - '2016-06-15 23:00:00' AS timestamp, - CAST(timestamp AS DateTime) AS datetime, - CAST(timestamp AS Date) AS date, - CAST(timestamp, 'String') AS string, - CAST(timestamp, 'FixedString(22)') AS fixed_string -``` - -``` text -┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ -└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ -``` - -تبدیل به fixedstring(n) تنها با این نسخهها کار برای استدلال از نوع string یا fixedstring(n). - -تبدیل نوع به [Nullable](../../sql_reference/data_types/nullable.md) و پشت پشتیبانی می شود. مثال: - -``` sql -SELECT toTypeName(x) FROM t_null -``` - -``` text -┌─toTypeName(x)─┐ -│ Int8 │ -│ Int8 │ -└───────────────┘ -``` - -``` sql -SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null -``` - -``` text -┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ -│ Nullable(UInt16) │ -│ Nullable(UInt16) │ -└─────────────────────────────────────────┘ -``` - -## توینتال (سال / سه ماهه / ماه / هفته / روز / ساعت / دقیقه / ثانیه) {#function-tointerval} - -تبدیل یک استدلال نوع شماره به یک [فاصله](../../sql_reference/data_types/special_data_types/interval.md) نوع داده. - -**نحو** - -``` sql -toIntervalSecond(number) -toIntervalMinute(number) -toIntervalHour(number) -toIntervalDay(number) -toIntervalWeek(number) -toIntervalMonth(number) -toIntervalQuarter(number) -toIntervalYear(number) -``` - -**پارامترها** - -- `number` — Duration of interval. Positive integer number. - -**مقادیر بازگشتی** - -- مقدار در `Interval` نوع داده. - -**مثال** - -``` sql -WITH - toDate('2019-01-01') AS date, - INTERVAL 1 WEEK AS interval_week, - toIntervalWeek(1) AS interval_to_week -SELECT - date + interval_week, - date + interval_to_week -``` - -``` text -┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ -│ 2019-01-08 │ 2019-01-08 │ -└───────────────────────────┴──────────────────────────────┘ -``` - -## پردازش زمان {#parsedatetimebesteffort} - -تبدیل یک تاریخ و زمان در [رشته](../../sql_reference/data_types/string.md) نمایندگی به [DateTime](../../sql_reference/data_types/datetime.md#data_type-datetime) نوع داده. - -تابع تجزیه می کند [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [1123-5.2.14 تومان-822 تاریخ و زمان مشخصات](https://tools.ietf.org/html/rfc1123#page-55), را کلیک کنید و برخی از فرمت های تاریخ و زمان دیگر. - -**نحو** - -``` sql -parseDateTimeBestEffort(time_string [, time_zone]); -``` - -**پارامترها** - -- `time_string` — String containing a date and time to convert. [رشته](../../sql_reference/data_types/string.md). -- `time_zone` — Time zone. The function parses `time_string` با توجه به منطقه زمانی. [رشته](../../sql_reference/data_types/string.md). - -**فرمت های غیر استاندارد پشتیبانی شده** - -- یک رشته حاوی 9..10 رقمی [برچسب زمان یونیکس](https://en.wikipedia.org/wiki/Unix_time). -- یک رشته با یک تاریخ و یک مولفه زمان: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`, و غیره. -- یک رشته با یک تاریخ, اما هیچ مولفه زمان: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` و غیره -- یک رشته با یک روز و زمان: `DD`, `DD hh`, `DD hh:mm`. در این مورد `YYYY-MM` به عنوان جایگزین `2000-01`. -- یک رشته است که شامل تاریخ و زمان همراه با منطقه زمانی اطلاعات افست: `YYYY-MM-DD hh:mm:ss ±h:mm`, و غیره. به عنوان مثال, `2020-12-12 17:36:00 -5:00`. - -برای همه فرمت های با جدا تابع تجزیه نام ماه بیان شده توسط نام کامل خود و یا با سه حرف اول یک نام ماه. مثالها: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. - -**مقدار بازگشتی** - -- `time_string` تبدیل به `DateTime` نوع داده. - -**مثالها** - -پرسوجو: - -``` sql -SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') -AS parseDateTimeBestEffort; -``` - -نتیجه: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2020-12-12 12:12:57 │ -└─────────────────────────┘ -``` - -پرسوجو: - -``` sql -SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') -AS parseDateTimeBestEffort -``` - -نتیجه: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2018-08-18 10:22:16 │ -└─────────────────────────┘ -``` - -پرسوجو: - -``` sql -SELECT parseDateTimeBestEffort('1284101485') -AS parseDateTimeBestEffort -``` - -نتیجه: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2015-07-07 12:04:41 │ -└─────────────────────────┘ -``` - -پرسوجو: - -``` sql -SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') -AS parseDateTimeBestEffort -``` - -نتیجه: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2018-12-12 10:12:12 │ -└─────────────────────────┘ -``` - -پرسوجو: - -``` sql -SELECT parseDateTimeBestEffort('10 20:19') -``` - -نتیجه: - -``` text -┌─parseDateTimeBestEffort('10 20:19')─┐ -│ 2000-01-10 20:19:00 │ -└─────────────────────────────────────┘ -``` - -**همچنین نگاه کنید** - -- \[ISO 8601 announcement by @xkcd\])https://xkcd.com/1179/) -- [RFC 1123](https://tools.ietf.org/html/rfc1123) -- [toDate](#todate) -- [toDateTime](#todatetime) - -## - ترجمه نشده - {#parsedatetimebesteffortornull} - -همان است که برای [پردازش زمان](#parsedatetimebesteffort) با این تفاوت که وقتی با فرمت تاریخ مواجه می شود که نمی تواند پردازش شود تهی می شود. - -## - ترجمه نشده - {#parsedatetimebesteffortorzero} - -همان است که برای [پردازش زمان](#parsedatetimebesteffort) با این تفاوت که تاریخ صفر یا زمان صفر را باز می گرداند زمانی که یک فرمت تاریخ مواجه است که نمی تواند پردازش شود. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/fa/sql_reference/functions/url_functions.md b/docs/fa/sql_reference/functions/url_functions.md deleted file mode 100644 index d2a4e5589c6..00000000000 --- a/docs/fa/sql_reference/functions/url_functions.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 54 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u0646\u0634\u0627\u0646\u06CC\u0647\u0627\ \u06CC \u0627\u06CC\u0646\u062A\u0631\u0646\u062A\u06CC" ---- - -# توابع برای کار با نشانیهای اینترنتی {#functions-for-working-with-urls} - -همه این توابع را دنبال کنید. حداکثر برای بهبود عملکرد ساده شده اند. - -## توابع استخراج بخشهایی از نشانی وب {#functions-that-extract-parts-of-a-url} - -اگر قسمت مربوطه در نشانی وب وجود نداشته باشد یک رشته خالی برگردانده میشود. - -### قرارداد {#protocol} - -پروتکل را از نشانی اینترنتی خارج میکند. - -Examples of typical returned values: http, https, ftp, mailto, tel, magnet… - -### دامنه {#domain} - -نام میزبان را از یک نشانی اینترنتی استخراج می کند. - -``` sql -domain(url) -``` - -**پارامترها** - -- `url` — URL. Type: [رشته](../../sql_reference/data_types/string.md). - -نشانی وب را می توان با یا بدون یک طرح مشخص شده است. مثالها: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -برای این نمونه ها `domain` تابع نتایج زیر را برمی گرداند: - -``` text -some.svn-hosting.com -some.svn-hosting.com -yandex.com -``` - -**مقادیر بازگشتی** - -- نام میزبان. اگر کلیک هاوس می تواند رشته ورودی را به عنوان نشانی وب تجزیه کند. -- رشته خالی. اگر کلیکهاوس نمیتواند رشته ورودی را به عنوان نشانی وب تجزیه کند. - -نوع: `String`. - -**مثال** - -``` sql -SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ -│ some.svn-hosting.com │ -└────────────────────────────────────────────────────────┘ -``` - -### دامینویتهویتوو {#domainwithoutwww} - -بازگرداندن دامنه و حذف بیش از یک ‘www.’ اگه از اول شروع بشه - -### توپولدومین {#topleveldomain} - -عصاره این دامنه سطح بالا از یک url. - -``` sql -topLevelDomain(url) -``` - -**پارامترها** - -- `url` — URL. Type: [رشته](../../sql_reference/data_types/string.md). - -نشانی وب را می توان با یا بدون یک طرح مشخص شده است. مثالها: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -**مقادیر بازگشتی** - -- نام دامنه. اگر کلیک هاوس می تواند رشته ورودی را به عنوان نشانی وب تجزیه کند. -- رشته خالی. اگر کلیکهاوس نمیتواند رشته ورودی را به عنوان نشانی وب تجزیه کند. - -نوع: `String`. - -**مثال** - -``` sql -SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ -│ com │ -└────────────────────────────────────────────────────────────────────┘ -``` - -### در حال بارگذاری {#firstsignificantsubdomain} - -بازگرداندن “first significant subdomain”. این یک مفهوم غیر استاندارد خاص به یاندکس است.متریکا اولین زیر دامنه قابل توجهی یک دامنه سطح دوم است ‘com’, ‘net’, ‘org’ یا ‘co’. در غیر این صورت, این یک دامنه سطح سوم است. به عنوان مثال, `firstSignificantSubdomain (‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’`. فهرست “insignificant” دامنه های سطح دوم و سایر اطلاعات پیاده سازی ممکن است در اینده تغییر کند. - -### در حال بارگذاری {#cuttofirstsignificantsubdomain} - -بازگرداندن بخشی از دامنه است که شامل زیر دامنه سطح بالا تا “first significant subdomain” (توضیح بالا را ببینید). - -به عنوان مثال, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. - -### مسیر {#path} - -مسیر را برمی گرداند. مثال: `/top/news.html` مسیر رشته پرس و جو را شامل نمی شود. - -### مسیر {#pathfull} - -همان بالا, اما از جمله رشته پرس و جو و قطعه. مثال:/بالا / اخبار.زنگامصفحه = 2 \# نظرات - -### رشته {#querystring} - -بازگرداندن رشته پرس و جو. مثال: صفحه=1&چاپی=213. پرس و جو رشته علامت سوال اولیه را شامل نمی شود, و همچنین \# و همه چیز بعد از \#. - -### قطعه {#fragment} - -بازگرداندن شناسه قطعه. قطعه می کند نماد هش اولیه را شامل نمی شود. - -### وضعیت زیستشناختی رکورد {#querystringandfragment} - -بازگرداندن رشته پرس و جو و شناسه قطعه. مثال: صفحه=1\#29390. - -### نام) {#extracturlparameterurl-name} - -بازگرداندن ارزش ‘name’ پارامتر در نشانی وب, در صورت وجود. در غیر این صورت, یک رشته خالی. اگر پارامترهای بسیاری با این نام وجود دارد, این اولین رخداد را برمی گرداند. این تابع با این فرض کار می کند که نام پارامتر در نشانی اینترنتی دقیقا به همان شیوه در استدلال گذشت کد گذاری شده است. - -### شمارش معکوس) {#extracturlparametersurl} - -مجموعه ای از نام=رشته ارزش مربوط به پارامترهای نشانی وب را برمی گرداند. ارزش ها به هیچ وجه رمزگشایی نمی. - -### extractURLParameterNames(URL) {#extracturlparameternamesurl} - -مجموعه ای از نام رشته های مربوط به نام پارامترهای نشانی وب را باز می گرداند. ارزش ها به هیچ وجه رمزگشایی نمی. - -### URLHierarchy(URL) {#urlhierarchyurl} - -را برمی گرداند مجموعه ای حاوی نشانی اینترنتی, کوتاه در پایان توسط علامت /,? در مسیر و پرس و جو-رشته. کاراکتر جداکننده متوالی به عنوان یکی شمارش می شود. برش در موقعیت بعد از تمام کاراکتر جدا متوالی ساخته شده است. - -### URLPathHierarchy(URL) {#urlpathhierarchyurl} - -همانطور که در بالا, اما بدون پروتکل و میزبان در نتیجه. / عنصر (ریشه) گنجانده نشده است. به عنوان مثال: تابع استفاده می شود برای پیاده سازی درخت گزارش نشانی اینترنتی در یاندکس. متریک. - -``` text -URLPathHierarchy('https://example.com/browse/CONV-6788') = -[ - '/browse/', - '/browse/CONV-6788' -] -``` - -### نما & نشانی وب) {#decodeurlcomponenturl} - -را برمی گرداند نشانی اینترنتی رمزگشایی. -مثال: - -``` sql -SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; -``` - -``` text -┌─DecodedURL─────────────────────────────┐ -│ http://127.0.0.1:8123/?query=SELECT 1; │ -└────────────────────────────────────────┘ -``` - -## توابع که حذف بخشی از یک نشانی وب. {#functions-that-remove-part-of-a-url} - -اگر نشانی وب هیچ چیز مشابه ندارد, نشانی اینترنتی بدون تغییر باقی می ماند. - -### بریدن {#cutwww} - -حذف بیش از یک ‘www.’ از ابتدای دامنه نشانی اینترنتی در صورت وجود. - -### & رشته {#cutquerystring} - -حذف رشته پرس و جو. علامت سوال نیز حذف شده است. - -### تقسیم {#cutfragment} - -حذف شناسه قطعه. علامت شماره نیز حذف شده است. - -### هشدار داده می شود {#cutquerystringandfragment} - -حذف رشته پرس و جو و شناسه قطعه. علامت سوال و علامت شماره نیز حذف شده است. - -### cutURLParameter(URL, نام) {#cuturlparameterurl-name} - -حذف ‘name’ پارامتر نشانی وب, در صورت وجود. این تابع با این فرض کار می کند که نام پارامتر در نشانی اینترنتی دقیقا به همان شیوه در استدلال گذشت کد گذاری شده است. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/fa/sql_reference/functions/uuid_functions.md b/docs/fa/sql_reference/functions/uuid_functions.md deleted file mode 100644 index d4c6f325b06..00000000000 --- a/docs/fa/sql_reference/functions/uuid_functions.md +++ /dev/null @@ -1,122 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 53 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u06CC\u0648\u06CC\u062F" ---- - -# توابع برای کار با یوید {#functions-for-working-with-uuid} - -توابع برای کار با شناسه به شرح زیر است. - -## جنراتیدو4 {#uuid-function-generate} - -تولید [UUID](../../sql_reference/data_types/uuid.md) از [نسخه 4](https://tools.ietf.org/html/rfc4122#section-4.4). - -``` sql -generateUUIDv4() -``` - -**مقدار بازگشتی** - -مقدار نوع شناسه. - -**مثال طریقه استفاده** - -این مثال نشان می دهد ایجاد یک جدول با ستون نوع شناسه و قرار دادن یک مقدار به جدول. - -``` sql -CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog - -INSERT INTO t_uuid SELECT generateUUIDv4() - -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┐ -│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ -└──────────────────────────────────────┘ -``` - -## شناسه بسته:) {#touuid-x} - -تبدیل مقدار نوع رشته به نوع شناسه. - -``` sql -toUUID(String) -``` - -**مقدار بازگشتی** - -این uuid نوع ارزش است. - -**مثال طریقه استفاده** - -``` sql -SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid -``` - -``` text -┌─────────────────────────────────uuid─┐ -│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ -└──────────────────────────────────────┘ -``` - -## وضعیت زیستشناختی رکورد {#uuidstringtonum} - -می پذیرد یک رشته حاوی 36 کاراکتر در قالب `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` و به عنوان مجموعه ای از بایت ها در یک [رشته ثابت (16)](../../sql_reference/data_types/fixedstring.md). - -``` sql -UUIDStringToNum(String) -``` - -**مقدار بازگشتی** - -رشته ثابت (16) - -**نمونه های استفاده** - -``` sql -SELECT - '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, - UUIDStringToNum(uuid) AS bytes -``` - -``` text -┌─uuid─────────────────────────────────┬─bytes────────────┐ -│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ -└──────────────────────────────────────┴──────────────────┘ -``` - -## هشدار داده می شود {#uuidnumtostring} - -می پذیرد [رشته ثابت (16)](../../sql_reference/data_types/fixedstring.md) ارزش, و یک رشته حاوی گرداند 36 شخصیت در قالب متن. - -``` sql -UUIDNumToString(FixedString(16)) -``` - -**مقدار بازگشتی** - -رشته. - -**مثال طریقه استفاده** - -``` sql -SELECT - 'a/<@];!~p{jTj={)' AS bytes, - UUIDNumToString(toFixedString(bytes, 16)) AS uuid -``` - -``` text -┌─bytes────────────┬─uuid─────────────────────────────────┐ -│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ -└──────────────────┴──────────────────────────────────────┘ -``` - -## همچنین نگاه کنید به {#see-also} - -- [دیکتاتوری](ext_dict_functions.md#ext_dict_functions-other) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/fa/sql_reference/functions/ym_dict_functions.md b/docs/fa/sql_reference/functions/ym_dict_functions.md deleted file mode 100644 index 25a31cd1020..00000000000 --- a/docs/fa/sql_reference/functions/ym_dict_functions.md +++ /dev/null @@ -1,157 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 59 -toc_title: "\u06A9\u0627\u0631 \u0628\u0627 \u06CC\u0627\u0646\u062F\u06A9\u0633.\u0648\ - \u0627\u0698\u0647\u0646\u0627\u0645\u0647\u0647\u0627 \u0645\u062A\u0631\u06CC\u06A9\ - \u0627" ---- - -# توابع برای کار با یاندکس.واژهنامهها متریکا {#functions-for-working-with-yandex-metrica-dictionaries} - -به منظور توابع زیر به کار پیکربندی سرور باید مشخص مسیر و نشانی برای گرفتن تمام یاندکس.واژهنامهها متریکا. لغت نامه ها در اولین تماس از هر یک از این توابع لود می شود. اگر لیست مرجع نمی تواند لود شود, یک استثنا پرتاب می شود. - -برای اطلاعات در مورد ایجاد لیست مرجع, بخش را ببینید “Dictionaries”. - -## موقعیت جغرافیایی چندگانه {#multiple-geobases} - -ClickHouse پشتیبانی از کار با چند جایگزین geobases (منطقه ای سلسله مراتب) به طور همزمان به منظور حمایت از دیدگاه های مختلف که در آن کشورهای خاص مناطق متعلق به. - -این ‘clickhouse-server’ پیکربندی فایل را با سلسله مراتب منطقه ای مشخص می کند::`/opt/geo/regions_hierarchy.txt` - -علاوه بر این فایل, همچنین برای فایل های جستجو در این نزدیکی هست که نماد \_ و هر پسوند اضافه به نام (قبل از پسوند فایل). -مثلا, همچنین فایل را پیدا خواهد کرد `/opt/geo/regions_hierarchy_ua.txt`, اگر در حال حاضر. - -`ua` کلید فرهنگ لغت نامیده می شود. برای یک فرهنگ لغت بدون پسوند, کلید یک رشته خالی است. - -تمام واژهنامهها دوباره لود شده در زمان اجرا (یک بار در هر تعداد معینی از ثانیه, همانطور که در دستور داخلی تعریف شده \_فرهنگ\_ پارامتر پیکربندی, و یا یک بار در ساعت به طور پیش فرض). با این حال, لیست لغت نامه های موجود تعریف شده است یک بار, زمانی که سرور شروع می شود. - -All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. -مثال: - -``` sql -regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt -regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt -regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt -``` - -### regionToCity(id\[, geobase\]) {#regiontocityid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. - -### regionToArea(id\[, geobase\]) {#regiontoareaid-geobase} - -تبدیل یک منطقه به یک منطقه (نوع 5 در پایگاه داده). در هر راه دیگر, این تابع همان است که ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ -│ │ -│ Moscow and Moscow region │ -│ St. Petersburg and Leningrad region │ -│ Belgorod region │ -│ Ivanovsk region │ -│ Kaluga region │ -│ Kostroma region │ -│ Kursk region │ -│ Lipetsk region │ -│ Orlov region │ -│ Ryazan region │ -│ Smolensk region │ -│ Tambov region │ -│ Tver region │ -│ Tula region │ -└──────────────────────────────────────────────────────┘ -``` - -### regionToDistrict(id\[, geobase\]) {#regiontodistrictid-geobase} - -تبدیل یک منطقه به یک منطقه فدرال (نوع 4 در پایگاه داده). در هر راه دیگر, این تابع همان است که ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ -│ │ -│ Central federal district │ -│ Northwest federal district │ -│ South federal district │ -│ North Caucases federal district │ -│ Privolga federal district │ -│ Ural federal district │ -│ Siberian federal district │ -│ Far East federal district │ -│ Scotland │ -│ Faroe Islands │ -│ Flemish region │ -│ Brussels capital region │ -│ Wallonia │ -│ Federation of Bosnia and Herzegovina │ -└──────────────────────────────────────────────────────────┘ -``` - -### regionToCountry(id\[, geobase\]) {#regiontocountryid-geobase} - -تبدیل یک منطقه به یک کشور. در هر راه دیگر, این تابع همان است که ‘regionToCity’. -مثال: `regionToCountry(toUInt32(213)) = 225` تبدیل مسکو (213) به روسیه (225). - -### regionToContinent(id\[, geobase\]) {#regiontocontinentid-geobase} - -تبدیل یک منطقه به یک قاره. در هر راه دیگر, این تابع همان است که ‘regionToCity’. -مثال: `regionToContinent(toUInt32(213)) = 10001` تبدیل مسکو (213) به اوراسیا (10001). - -### نقلقولهای جدید از این نویسنده) {#regiontotopcontinent-regiontotopcontinent} - -بالاترین قاره را در سلسله مراتب منطقه پیدا می کند. - -**نحو** - -``` sql -regionToTopContinent(id[, geobase]); -``` - -**پارامترها** - -- `id` — Region ID from the Yandex geobase. [UInt32](../../sql_reference/data_types/int_uint.md). -- `geobase` — Dictionary key. See [موقعیت جغرافیایی چندگانه](#multiple-geobases). [رشته](../../sql_reference/data_types/string.md). اختیاری. - -**مقدار بازگشتی** - -- شناسه قاره سطح بالا (دومی زمانی که شما صعود سلسله مراتب مناطق). -- 0, اگر هیچ کدام وجود دارد. - -نوع: `UInt32`. - -### regionToPopulation(id\[, geobase\]) {#regiontopopulationid-geobase} - -می شود جمعیت برای یک منطقه. -جمعیت را می توان در فایل های با پایگاه داده ثبت شده است. بخش را ببینید “External dictionaries”. -اگر جمعیت برای منطقه ثبت نشده, باز می گردد 0. -در یاندکس پایگاه جغرافیایی, جمعیت ممکن است برای مناطق کودک ثبت, اما نه برای مناطق پدر و مادر. - -### regionIn(lhs, rhs\[, geobase\]) {#regioninlhs-rhs-geobase} - -بررسی اینکه یک ‘lhs’ منطقه متعلق به ‘rhs’ منطقه. بازگرداندن یک عدد 18 برابر 1 اگر متعلق, یا 0 اگر تعلق ندارد. -The relationship is reflexive – any region also belongs to itself. - -### regionHierarchy(id\[, geobase\]) {#regionhierarchyid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. -مثال: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. - -### شناسه بسته:\]) {#regiontonameid-lang} - -Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn't exist, an empty string is returned. - -`ua` و `uk` هر دو به معنای اوکراین. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/fa/sql_reference/index.md b/docs/fa/sql_reference/index.md deleted file mode 100644 index bfee52fe239..00000000000 --- a/docs/fa/sql_reference/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: SQL Reference -toc_hidden: true -toc_priority: 28 -toc_title: "\u0645\u062E\u0641\u06CC" ---- - -# مرجع مربع {#sql-reference} - -- [SELECT](statements/select.md) -- [INSERT INTO](statements/insert_into.md) -- [CREATE](statements/create.md) -- [ALTER](statements/alter.md#query_language_queries_alter) -- [انواع دیگر نمایش داده شد](statements/misc.md) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/) diff --git a/docs/fa/sql_reference/operators.md b/docs/fa/sql_reference/operators.md deleted file mode 100644 index 577b9079998..00000000000 --- a/docs/fa/sql_reference/operators.md +++ /dev/null @@ -1,278 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u0627\u067E\u0631\u0627\u062A\u0648\u0631\u0647\u0627" ---- - -# اپراتورها {#operators} - -همه اپراتورها در حال تبدیل به توابع مربوط به خود را در پرس و جو و تجزیه مرحله مطابق با اولویت و associativity. -گروه اپراتورهای به ترتیب اولویت ذکر شده (بالاتر در لیست است, زودتر اپراتور به استدلال خود متصل). - -## اپراتورهای دسترسی {#access-operators} - -`a[N]` – Access to an element of an array. The `arrayElement(a, N)` تابع. - -`a.N` – Access to a tuple element. The `tupleElement(a, N)` تابع. - -## اپراتور نفی عددی {#numeric-negation-operator} - -`-a` – The `negate (a)` تابع. - -## اپراتورهای ضرب و تقسیم {#multiplication-and-division-operators} - -`a * b` – The `multiply (a, b)` تابع. - -`a / b` – The `divide(a, b)` تابع. - -`a % b` – The `modulo(a, b)` تابع. - -## اپراتورهای جمع و تفریق {#addition-and-subtraction-operators} - -`a + b` – The `plus(a, b)` تابع. - -`a - b` – The `minus(a, b)` تابع. - -## مقایسه اپراتورها {#comparison-operators} - -`a = b` – The `equals(a, b)` تابع. - -`a == b` – The `equals(a, b)` تابع. - -`a != b` – The `notEquals(a, b)` تابع. - -`a <> b` – The `notEquals(a, b)` تابع. - -`a <= b` – The `lessOrEquals(a, b)` تابع. - -`a >= b` – The `greaterOrEquals(a, b)` تابع. - -`a < b` – The `less(a, b)` تابع. - -`a > b` – The `greater(a, b)` تابع. - -`a LIKE s` – The `like(a, b)` تابع. - -`a NOT LIKE s` – The `notLike(a, b)` تابع. - -`a BETWEEN b AND c` – The same as `a >= b AND a <= c`. - -`a NOT BETWEEN b AND c` – The same as `a < b OR a > c`. - -## اپراتورها برای کار با مجموعه داده ها {#operators-for-working-with-data-sets} - -*ببینید [در اپراتورها](statements/select.md#select-in-operators).* - -`a IN ...` – The `in(a, b)` تابع. - -`a NOT IN ...` – The `notIn(a, b)` تابع. - -`a GLOBAL IN ...` – The `globalIn(a, b)` تابع. - -`a GLOBAL NOT IN ...` – The `globalNotIn(a, b)` تابع. - -## اپراتورها برای کار با تاریخ و زمان {#operators-datetime} - -### EXTRACT {#operator-extract} - -``` sql -EXTRACT(part FROM date); -``` - -عصاره بخشی از یک تاریخ معین. مثلا, شما می توانید یک ماه از یک تاریخ معین بازیابی, یا یک ثانیه از یک زمان. - -این `part` پارامتر مشخص می کند که بخشی از تاریخ برای بازیابی. مقادیر زیر در دسترس هستند: - -- `DAY` — The day of the month. Possible values: 1–31. -- `MONTH` — The number of a month. Possible values: 1–12. -- `YEAR` — The year. -- `SECOND` — The second. Possible values: 0–59. -- `MINUTE` — The minute. Possible values: 0–59. -- `HOUR` — The hour. Possible values: 0–23. - -این `part` پارامتر غیر حساس به حروف است. - -این `date` پارامتر تاریخ یا زمان پردازش را مشخص می کند. هر دو [تاریخ](../sql_reference/data_types/date.md) یا [DateTime](../sql_reference/data_types/datetime.md) نوع پشتیبانی می شود. - -مثالها: - -``` sql -SELECT EXTRACT(DAY FROM toDate('2017-06-15')); -SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); -SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); -``` - -در مثال زیر ما ایجاد یک جدول و قرار دادن به آن یک مقدار با `DateTime` نوع. - -``` sql -CREATE TABLE test.Orders -( - OrderId UInt64, - OrderName String, - OrderDate DateTime -) -ENGINE = Log; -``` - -``` sql -INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); -``` - -``` sql -SELECT - toYear(OrderDate) AS OrderYear, - toMonth(OrderDate) AS OrderMonth, - toDayOfMonth(OrderDate) AS OrderDay, - toHour(OrderDate) AS OrderHour, - toMinute(OrderDate) AS OrderMinute, - toSecond(OrderDate) AS OrderSecond -FROM test.Orders; -``` - -``` text -┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ -│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ -└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ -``` - -شما می توانید نمونه های بیشتری را در [تستها](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). - -### INTERVAL {#operator-interval} - -ایجاد یک [فاصله](../sql_reference/data_types/special_data_types/interval.md)- ارزش نوع است که باید در عملیات ریاضی با استفاده [تاریخ](../sql_reference/data_types/date.md) و [DateTime](../sql_reference/data_types/datetime.md)- ارزش نوع . - -انواع فواصل: -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -!!! warning "اخطار" - فواصل با انواع مختلف نمی تواند ترکیب شود. شما می توانید عبارات مانند استفاده کنید `INTERVAL 4 DAY 1 HOUR`. بیان فواصل در واحد است که کوچکتر یا مساوی کوچکترین واحد فاصله برای مثال `INTERVAL 25 HOUR`. شما می توانید عملیات تبعی مانند مثال زیر استفاده کنید. - -مثال: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -**همچنین نگاه کنید** - -- [فاصله](../sql_reference/data_types/special_data_types/interval.md) نوع داده -- [توینتروال](../sql_reference/functions/type_conversion_functions.md#function-tointerval) توابع تبدیل نوع - -## اپراتور نفی منطقی {#logical-negation-operator} - -`NOT a` – The `not(a)` تابع. - -## منطقی و اپراتور {#logical-and-operator} - -`a AND b` – The`and(a, b)` تابع. - -## منطقی یا اپراتور {#logical-or-operator} - -`a OR b` – The `or(a, b)` تابع. - -## اپراتور شرطی {#conditional-operator} - -`a ? b : c` – The `if(a, b, c)` تابع. - -یادداشت: - -اپراتور مشروط محاسبه ارزش ب و ج, سپس چک چه شرایط ملاقات کرده است, و سپس مقدار مربوطه را برمی گرداند. اگر `b` یا `C` یک [ارریجین()](../sql_reference/functions/array_join.md#functions_arrayjoin) عملکرد هر سطر خواهد بود تکرار صرف نظر از “a” شرط. - -## عبارت شرطی {#operator_case} - -``` sql -CASE [x] - WHEN a THEN b - [WHEN ... THEN ...] - [ELSE c] -END -``` - -اگر `x` مشخص شده است, سپس `transform(x, [a, ...], [b, ...], c)` function is used. Otherwise – `multiIf(a, b, ..., c)`. - -اگر وجود ندارد `ELSE c` بند در بیان, مقدار پیش فرض است `NULL`. - -این `transform` تابع با کار نمی کند `NULL`. - -## اپراتور الحاق {#concatenation-operator} - -`s1 || s2` – The `concat(s1, s2) function.` - -## لامبدا اپراتور ایجاد {#lambda-creation-operator} - -`x -> expr` – The `lambda(x, expr) function.` - -اپراتورهای زیر یک اولویت ندارد, از براکت هستند: - -## اپراتور ایجاد مجموعه {#array-creation-operator} - -`[x1, ...]` – The `array(x1, ...) function.` - -## اپراتور ایجاد تاپل {#tuple-creation-operator} - -`(x1, x2, ...)` – The `tuple(x2, x2, ...) function.` - -## Associativity {#associativity} - -همه اپراتورهای دودویی انجمن را ترک کرده اند. به عنوان مثال, `1 + 2 + 3` تبدیل به `plus(plus(1, 2), 3)`. -گاهی اوقات این راه شما انتظار می رود کار نمی کند. به عنوان مثال, `SELECT 4 > 2 > 3` در نتیجه 0. - -برای بهره وری `and` و `or` توابع قبول هر تعداد از استدلال. زنجیره های مربوطه از `AND` و `OR` اپراتورها به یک تماس از این توابع تبدیل شده است. - -## در حال بررسی برای `NULL` {#checking-for-null} - -تاتر از `IS NULL` و `IS NOT NULL` اپراتورها. - -### IS NULL {#operator-is-null} - -- برای [Nullable](../sql_reference/data_types/nullable.md) مقادیر نوع `IS NULL` بازگشت اپراتور: - - `1` اگر مقدار باشد `NULL`. - - `0` وگرنه -- برای ارزش های دیگر `IS NULL` اپراتور همیشه باز می گردد `0`. - - - -``` sql -SELECT x+100 FROM t_null WHERE y IS NULL -``` - -``` text -┌─plus(x, 100)─┐ -│ 101 │ -└──────────────┘ -``` - -### IS NOT NULL {#is-not-null} - -- برای [Nullable](../sql_reference/data_types/nullable.md) مقادیر نوع `IS NOT NULL` بازگشت اپراتور: - - `0` اگر مقدار باشد `NULL`. - - `1` وگرنه -- برای ارزش های دیگر `IS NOT NULL` اپراتور همیشه باز می گردد `1`. - - - -``` sql -SELECT * FROM t_null WHERE y IS NOT NULL -``` - -``` text -┌─x─┬─y─┐ -│ 2 │ 3 │ -└───┴───┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/fa/sql_reference/statements/alter.md b/docs/fa/sql_reference/statements/alter.md deleted file mode 100644 index c2b8561c299..00000000000 --- a/docs/fa/sql_reference/statements/alter.md +++ /dev/null @@ -1,505 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 36 -toc_title: ALTER ---- - -## ALTER {#query_language_queries_alter} - -این `ALTER` پرسوجو فقط برای پشتیبانی `*MergeTree` جداول و همچنین `Merge`و`Distributed`. پرس و جو دارای چندین تغییرات. - -### دستکاری ستون {#column-manipulations} - -تغییر ساختار جدول. - -``` sql -ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... -``` - -در پرس و جو, مشخص یک لیست از یک یا چند اقدامات کاما از هم جدا. -هر عمل یک عملیات بر روی یک ستون است. - -اقدامات زیر پشتیبانی می شوند: - -- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. -- [DROP COLUMN](#alter_drop-column) — Deletes the column. -- [CLEAR COLUMN](#alter_clear-column) — Resets column values. -- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. -- [MODIFY COLUMN](#alter_modify-column) — Changes column's type, default expression and TTL. - -این اقدامات در زیر توضیح داده شده است. - -#### ADD COLUMN {#alter_add-column} - -``` sql -ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] -``` - -یک ستون جدید به جدول با مشخص اضافه می کند `name`, `type`, [`codec`](create.md#codecs) و `default_expr` (نگاه کنید به بخش [عبارتهای پیشفرض](create.md#create-default-values)). - -اگر `IF NOT EXISTS` بند گنجانده شده است, پرس و جو یک خطا بازگشت نیست اگر ستون در حال حاضر وجود دارد. اگر شما مشخص کنید `AFTER name_after` (نام ستون دیگر), ستون پس از یک مشخص شده در لیست ستون جدول اضافه. در غیر این صورت, ستون به پایان جدول اضافه. توجه داشته باشید که هیچ راهی برای اضافه کردن یک ستون به ابتدای جدول وجود دارد. برای زنجیره ای از اقدامات, `name_after` می تواند نام یک ستون است که در یکی از اقدامات قبلی اضافه شده است. - -اضافه کردن یک ستون فقط تغییر ساختار جدول, بدون انجام هر گونه اقدامات با داده. داده ها بر روی دیسک پس از ظاهر نمی شود `ALTER`. اگر داده ها برای یک ستون از دست رفته در هنگام خواندن از جدول, این است که در با مقادیر پیش فرض پر (با انجام عبارت پیش فرض اگر یکی وجود دارد, و یا با استفاده از صفر یا رشته های خالی). ستون بر روی دیسک به نظر می رسد پس از ادغام قطعات داده (دیدن [ادغام](../../engines/table_engines/mergetree_family/mergetree.md)). - -این رویکرد به ما اجازه می دهد برای تکمیل `ALTER` پرس و جو فورا, بدون افزایش حجم داده های قدیمی. - -مثال: - -``` sql -ALTER TABLE visits ADD COLUMN browser String AFTER user_id -``` - -#### DROP COLUMN {#alter_drop-column} - -``` sql -DROP COLUMN [IF EXISTS] name -``` - -ستون را با نام حذف می کند `name`. اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. - -حذف داده ها از سیستم فایل. از این حذف تمام فایل های پرس و جو تقریبا بلافاصله تکمیل شده است. - -مثال: - -``` sql -ALTER TABLE visits DROP COLUMN browser -``` - -#### CLEAR COLUMN {#alter_clear-column} - -``` sql -CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name -``` - -بازنشانی تمام داده ها در یک ستون برای یک پارتیشن مشخص. اطلاعات بیشتر در مورد تنظیم نام پارتیشن در بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). - -اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. - -مثال: - -``` sql -ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() -``` - -#### COMMENT COLUMN {#alter_comment-column} - -``` sql -COMMENT COLUMN [IF EXISTS] name 'comment' -``` - -می افزاید: نظر به ستون. اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. - -هر ستون می تواند یک نظر داشته باشد. اگر یک نظر در حال حاضر برای ستون وجود دارد, یک نظر جدید رونویسی نظر قبلی. - -نظرات در ذخیره می شود `comment_expression` ستون توسط [DESCRIBE TABLE](misc.md#misc-describe-table) پرس و جو. - -مثال: - -``` sql -ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' -``` - -#### MODIFY COLUMN {#alter_modify-column} - -``` sql -MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] -``` - -این پرسوجو تغییر میکند `name` ویژگیهای ستون: - -- نوع - -- عبارت پیشفرض - -- TTL - - For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). - -اگر `IF EXISTS` بند مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر ستون وجود ندارد. - -هنگام تغییر نوع, ارزش ها به عنوان اگر تبدیل [نوع](../../sql_reference/functions/type_conversion_functions.md) توابع به کار گرفته شد. اگر تنها عبارت پیش فرض تغییر می کند, پرس و جو می کند هر چیزی پیچیده نیست, و تقریبا بلافاصله تکمیل. - -مثال: - -``` sql -ALTER TABLE visits MODIFY COLUMN browser Array(String) -``` - -Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. - -چندین مرحله پردازش وجود دارد: - -- تهیه فایل های موقت (جدید) با داده های اصلاح شده. -- تغییر نام فایل های قدیمی. -- تغییر نام فایل های موقت (جدید) به نام های قدیمی. -- حذف فایل های قدیمی. - -فقط مرحله اول زمان طول می کشد. در صورتی که یک شکست در این مرحله وجود دارد, داده ها تغییر نکرده است. -در صورتی که یک شکست در یکی از مراحل پی در پی وجود دارد, داده ها را می توان به صورت دستی ترمیم. استثنا است اگر فایل های قدیمی از سیستم فایل حذف شد اما داده ها را برای فایل های جدید را به دیسک نوشته شده است و از دست داده بود. - -این `ALTER` پرس و جو برای تغییر ستون تکرار شده است. دستورالعمل ها در باغ وحش ذخیره می شوند و سپس هر ماکت اعمال می شود. همه `ALTER` نمایش داده شد در همان جهت اجرا شود. پرس و جو منتظر اقدامات مناسب برای در کپی دیگر تکمیل شود. با این حال, پرس و جو برای تغییر ستون در یک جدول تکرار می تواند قطع, و تمام اقدامات غیر همزمان انجام خواهد شد. - -#### تغییر محدودیت پرس و جو {#alter-query-limitations} - -این `ALTER` پرس و جو به شما امکان ایجاد و حذف عناصر جداگانه (ستون) در ساختارهای داده های تو در تو, اما نه کل ساختارهای داده تو در تو. برای اضافه کردن یک ساختار داده های تو در تو, شما می توانید ستون با یک نام مانند اضافه `name.nested_name` و نوع `Array(T)`. ساختار داده های تو در تو معادل ستون های چندگانه با یک نام است که پیشوند مشابه قبل از نقطه است. - -هیچ پشتیبانی برای حذف ستون ها در کلید اصلی یا کلید نمونه برداری (ستون هایی که در استفاده می شود) وجود ندارد. `ENGINE` عبارت). تغییر نوع ستون که در کلید اصلی گنجانده شده است تنها ممکن است اگر این تغییر باعث نمی شود داده ها به اصلاح شود (مثلا, شما مجاز به اضافه کردن مقادیر به شمارشی و یا برای تغییر یک نوع از `DateTime` به `UInt32`). - -اگر `ALTER` پرس و جو برای ایجاد تغییرات جدول مورد نیاز کافی نیست شما می توانید یک جدول جدید ایجاد کنید و داده ها را با استفاده از داده ها کپی کنید [INSERT SELECT](insert_into.md#insert_query_insert-select) پرس و جو, سپس جداول با استفاده از تغییر [RENAME](misc.md#misc_operations-rename) پرس و جو و حذف جدول قدیمی. شما می توانید از [تاتر-کپی](../../operations/utilities/clickhouse-copier.md) به عنوان یک جایگزین برای `INSERT SELECT` پرس و جو. - -این `ALTER` بلوک پرس و جو همه می خواند و می نویسد برای جدول. به عبارت دیگر, اگر طولانی `SELECT` در حال اجرا است در زمان `ALTER` پرس و جو `ALTER` پرس و جو منتظر خواهد ماند تا کامل شود. همزمان, تمام نمایش داده شد جدید به همان جدول صبر کنید در حالی که این `ALTER` در حال اجرا است. - -برای جداول که داده های خود را ذخیره کنید (مانند `Merge` و `Distributed`), `ALTER` فقط ساختار جدول را تغییر می دهد و ساختار جداول تابع را تغییر نمی دهد. مثلا, زمانی که در حال اجرا را تغییر دهید برای یک `Distributed` جدول, شما همچنین نیاز به اجرا `ALTER` برای جداول در تمام سرور از راه دور. - -### دستکاری با عبارات کلیدی {#manipulations-with-key-expressions} - -دستور زیر پشتیبانی می شود: - -``` sql -MODIFY ORDER BY new_expression -``` - -این فقط برای جداول در کار می کند [`MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) خانواده (از جمله -[تکرار](../../engines/table_engines/mergetree_family/replication.md) جدول). فرمان تغییر -[کلید مرتب سازی](../../engines/table_engines/mergetree_family/mergetree.md) از جدول -به `new_expression` (بیان و یا یک تاپل از عبارات). کلید اصلی یکسان باقی می ماند. - -فرمان سبک وزن به این معنا است که تنها ابرداده را تغییر می دهد. برای حفظ اموال که بخش داده ها -ردیف ها توسط عبارت کلیدی مرتب سازی شما می توانید عبارات حاوی ستون های موجود اضافه کنید دستور داد -به کلید مرتب سازی (فقط ستون اضافه شده توسط `ADD COLUMN` فرمان در همان `ALTER` پرسوجو). - -### دستکاری با شاخص های پرش داده {#manipulations-with-data-skipping-indices} - -این فقط برای جداول در کار می کند [`*MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) خانواده (از جمله -[تکرار](../../engines/table_engines/mergetree_family/replication.md) جدول). عملیات زیر -در دسترس هستند: - -- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` - می افزاید توضیحات شاخص به ابرداده جداول . - -- `ALTER TABLE [db].name DROP INDEX name` - حذف شرح شاخص از ابرداده جداول و حذف فایل های شاخص از دیسک. - -این دستورات سبک وزن هستند به این معنا که فقط فراداده را تغییر می دهند یا فایل ها را حذف می کنند. -همچنین تکرار میشوند (همگامسازی فرادادههای شاخص از طریق باغ وحش). - -### دستکاری با محدودیت {#manipulations-with-constraints} - -مشاهده بیشتر در [قیدها](create.md#constraints) - -محدودیت ها می توانند با استفاده از نحو زیر اضافه یا حذف شوند: - -``` sql -ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; -ALTER TABLE [db].name DROP CONSTRAINT constraint_name; -``` - -نمایش داده شد اضافه خواهد شد و یا حذف ابرداده در مورد محدودیت از جدول به طوری که بلافاصله پردازش شده است. - -بررسی قید *اعدام نخواهد شد* در داده های موجود اگر اضافه شد. - -همه تغییرات در جداول تکرار در حال پخش به باغ وحش بنابراین خواهد شد در دیگر کپی اعمال می شود. - -### دستکاری با پارتیشن ها و قطعات {#alter_manipulations-with-partitions} - -عملیات زیر را با [پارتیشن ها](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) در دسترس هستند: - -- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` دایرکتوری و فراموش کرده ام. -- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. -- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` دایرکتوری به جدول. -- [REPLACE PARTITION](#alter_replace-partition) - پارتیشن داده ها را از یک جدول به دیگری کپی می کند. -- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. -- [REPLACE PARTITION](#alter_replace-partition) - پارتیشن داده ها را از یک جدول به دیگری کپی می کند و جایگزین می شود. -- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition) (\#تغییر\_موف\_ قابل تنظیم-پارتیشن) - پارتیشن داده را از یک جدول به دیگری حرکت دهید. -- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) - بازنشانی ارزش یک ستون مشخص شده در یک پارتیشن. -- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) - بازنشانی شاخص ثانویه مشخص شده در یک پارتیشن. -- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. -- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. -- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. - - - -#### جدا پارتیشن {\#alter\_detach-پارتیشن} {#detach-partition-alter-detach-partition} - -``` sql -ALTER TABLE table_name DETACH PARTITION partition_expr -``` - -تمام داده ها را برای پارتیشن مشخص شده به `detached` فهرست راهنما. سرور فراموش در مورد پارتیشن داده جدا به عنوان اگر وجود ندارد. سرور نمی خواهد در مورد این داده ها می دانم تا زمانی که شما را به [ATTACH](#alter_attach-partition) پرس و جو. - -مثال: - -``` sql -ALTER TABLE visits DETACH PARTITION 201901 -``` - -اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). - -پس از پرس و جو اجرا شده است, شما می توانید هر کاری که می خواهید با داده ها در انجام `detached` directory — delete it from the file system, or just leave it. - -This query is replicated – it moves the data to the `detached` دایرکتوری در تمام کپی. توجه داشته باشید که شما می توانید این پرس و جو تنها در یک ماکت رهبر را اجرا کند. برای پیدا کردن اگر یک ماکت یک رهبر است, انجام `SELECT` پرسوجو به [سیستم.تکرار](../../operations/system_tables.md#system_tables-replicas) جدول متناوبا, راحت تر به یک است `DETACH` پرس و جو در تمام کپی - همه کپی پرتاب یک استثنا, به جز ماکت رهبر. - -#### DROP PARTITION {#alter_drop-partition} - -``` sql -ALTER TABLE table_name DROP PARTITION partition_expr -``` - -پارتیشن مشخص شده را از جدول حذف می کند. این برچسب ها پرس و جو پارتیشن به عنوان غیر فعال و حذف داده ها به طور کامل, حدود در 10 دقیقه. - -اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). - -The query is replicated – it deletes data on all replicas. - -#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} - -``` sql -ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr -``` - -بخش مشخص شده یا تمام قسمت های پارتیشن مشخص شده را از بین می برد `detached`. -اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). - -#### ATTACH PARTITION\|PART {#alter_attach-partition} - -``` sql -ALTER TABLE table_name ATTACH PARTITION|PART partition_expr -``` - -می افزاید داده ها به جدول از `detached` فهرست راهنما. ممکن است که به اضافه کردن داده ها برای کل پارتیشن و یا برای یک بخش جداگانه. مثالها: - -``` sql -ALTER TABLE visits ATTACH PARTITION 201901; -ALTER TABLE visits ATTACH PART 201901_2_2_0; -``` - -اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). - -این پرس و جو تکرار شده است. چک المثنی-ابتکار چه داده ها در وجود دارد `detached` فهرست راهنما. اگر داده وجود دارد, پرس و جو چک یکپارچگی خود را. اگر همه چیز درست است, پرس و جو می افزاید: داده ها به جدول. همه کپی دیگر دانلود داده ها از ماکت-مبتکر. - -بنابراین شما می توانید داده ها را به `detached` دایرکتوری در یک ماکت, و استفاده از `ALTER ... ATTACH` پرس و جو برای اضافه کردن به جدول در تمام کپی. - -#### ATTACH PARTITION FROM {#alter_attach-partition-from} - -``` sql -ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 -``` - -این پرس و جو پارتیشن داده را از `table1` به `table2` می افزاید داده ها به لیست موجود در `table2`. توجه داشته باشید که داده ها از حذف نمی شود `table1`. - -برای پرس و جو به اجرا با موفقیت, شرایط زیر باید رعایت شود: - -- هر دو جدول باید همان ساختار دارند. -- هر دو جدول باید کلید پارتیشن همان. - -#### REPLACE PARTITION {#alter_replace-partition} - -``` sql -ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 -``` - -این پرس و جو پارتیشن داده را از `table1` به `table2` و جایگزین پارتیشن موجود در `table2`. توجه داشته باشید که داده ها از حذف نمی شود `table1`. - -برای پرس و جو به اجرا با موفقیت, شرایط زیر باید رعایت شود: - -- هر دو جدول باید همان ساختار دارند. -- هر دو جدول باید کلید پارتیشن همان. - -#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} - -``` sql -ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest -``` - -این پرس و جو انتقال پارتیشن داده ها از `table_source` به `table_dest` با حذف داده ها از `table_source`. - -برای پرس و جو به اجرا با موفقیت, شرایط زیر باید رعایت شود: - -- هر دو جدول باید همان ساختار دارند. -- هر دو جدول باید کلید پارتیشن همان. -- هر دو جدول باید همان خانواده موتور باشد. (تکرار و یا غیر تکرار) -- هر دو جدول باید سیاست ذخیره سازی همان. - -#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} - -``` sql -ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr -``` - -بازنشانی تمام مقادیر در ستون مشخص شده در یک پارتیشن. اگر `DEFAULT` بند هنگام ایجاد یک جدول تعیین شد, این پرس و جو مجموعه مقدار ستون به یک مقدار پیش فرض مشخص. - -مثال: - -``` sql -ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 -``` - -#### FREEZE PARTITION {#alter_freeze-partition} - -``` sql -ALTER TABLE table_name FREEZE [PARTITION partition_expr] -``` - -این پرس و جو یک نسخه پشتیبان تهیه محلی از یک پارتیشن مشخص شده ایجاد می کند. اگر `PARTITION` بند حذف شده است, پرس و جو ایجاد پشتیبان گیری از تمام پارتیشن در یک بار. - -!!! note "یادداشت" - تمامی مراحل پشتیبان گیری بدون توقف سرور انجام می شود. - -توجه داشته باشید که برای جداول قدیمی مدل دهید شما می توانید پیشوند نام پارتیشن را مشخص کنید (به عنوان مثال, ‘2019’)- سپس پرس و جو پشتیبان گیری برای تمام پارتیشن مربوطه ایجاد می کند. اطلاعات بیشتر در مورد تنظیم بیان پارتیشن در یک بخش [نحوه مشخص کردن عبارت پارتیشن](#alter-how-to-specify-part-expr). - -در زمان اجرای, برای یک تصویر لحظهای داده, پرس و جو ایجاد لینک به داده های جدول. پیوندهای سخت در دایرکتوری قرار می گیرند `/var/lib/clickhouse/shadow/N/...` کجا: - -- `/var/lib/clickhouse/` است دایرکتوری محل کلیک کار مشخص شده در پیکربندی. -- `N` تعداد افزایشی از نسخه پشتیبان تهیه شده است. - -!!! note "یادداشت" - در صورت استفاده [مجموعه ای از دیسک برای ذخیره سازی داده ها در یک جدول](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) این `shadow/N` دایرکتوری به نظر می رسد در هر دیسک, ذخیره سازی قطعات داده که توسط همسان `PARTITION` اصطلاح. - -همان ساختار دایرکتوری ها در داخل پشتیبان به عنوان داخل ایجاد شده است `/var/lib/clickhouse/`. پرس و جو انجام می شود ‘chmod’ برای همه پروندهها نوشتن رو ممنوع کردم - -پس از ایجاد نسخه پشتیبان تهیه, شما می توانید داده ها را از کپی `/var/lib/clickhouse/shadow/` به سرور از راه دور و سپس از سرور محلی حذف کنید. توجه داشته باشید که `ALTER t FREEZE PARTITION` پرس و جو تکرار نشده است. این یک نسخه پشتیبان تهیه محلی تنها بر روی سرور محلی ایجاد می کند. - -پرس و جو ایجاد نسخه پشتیبان تهیه تقریبا بلافاصله (اما برای اولین بار برای نمایش داده شد در حال حاضر به جدول مربوطه منتظر را به پایان برساند در حال اجرا). - -`ALTER TABLE t FREEZE PARTITION` نسخه تنها داده, ابرداده جدول نیست. برای تهیه نسخه پشتیبان از فراداده های جدول فایل را کپی کنید `/var/lib/clickhouse/metadata/database/table.sql` - -برای بازیابی اطلاعات از یک نسخه پشتیبان تهیه زیر را انجام دهید: - -1. ایجاد جدول اگر وجود ندارد. برای مشاهده پرس و جو, استفاده از .پرونده جدید `ATTACH` در این با `CREATE`). -2. رونوشت داده از `data/database/table/` دایرکتوری در داخل پشتیبان گیری به `/var/lib/clickhouse/data/database/table/detached/` فهرست راهنما. -3. بدو `ALTER TABLE t ATTACH PARTITION` نمایش داده شد برای اضافه کردن داده ها به یک جدول. - -بازگرداندن از یک نسخه پشتیبان تهیه می کند نیاز به متوقف کردن سرور نیست. - -برای کسب اطلاعات بیشتر در مورد پشتیبان گیری و بازیابی اطلاعات, دیدن [پشتیبان گیری داده ها](../../operations/backup.md) بخش. - -#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} - -``` sql -ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr -``` - -پرس و جو کار می کند شبیه به `CLEAR COLUMN`, اما بازنشانی شاخص به جای یک داده ستون. - -#### FETCH PARTITION {#alter_fetch-partition} - -``` sql -ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' -``` - -دانلود یک پارتیشن از سرور دیگر. این پرس و جو تنها برای جداول تکرار کار می کند. - -پرس و جو می کند به شرح زیر است: - -1. پارتیشن را از سفال مشخص شده دانلود کنید. داخل ‘path-in-zookeeper’ شما باید یک مسیر به سفال در باغ وحش را مشخص کنید. -2. سپس پرس و جو داده های دانلود شده را به `detached` دایرکتوری از `table_name` جدول استفاده از [ATTACH PARTITION\|PART](#alter_attach-partition) پرسوجو برای افزودن داده به جدول. - -به عنوان مثال: - -``` sql -ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; -ALTER TABLE users ATTACH PARTITION 201902; -``` - -توجه داشته باشید که: - -- این `ALTER ... FETCH PARTITION` پرس و جو تکرار نشده است. این پارتیشن را به `detached` دایرکتوری تنها بر روی سرور محلی. -- این `ALTER TABLE ... ATTACH` پرس و جو تکرار شده است. این می افزاید: داده ها به تمام کپی. داده ها به یکی از کپی ها از `detached` فهرست راهنما, و به دیگران - از کپی همسایه. - -قبل از دانلود, سیستم چک اگر پارتیشن وجود دارد و ساختار جدول مسابقات. ماکت مناسب ترین به طور خودکار از کپی سالم انتخاب شده است. - -اگر چه پرس و جو نامیده می شود `ALTER TABLE`, این ساختار جدول را تغییر دهید و بلافاصله داده های موجود در جدول را تغییر دهید. - -#### MOVE PARTITION\|PART {#alter_move-partition} - -پارتیشن ها یا قطعات داده را به حجم یا دیسک دیگری منتقل می کند `MergeTree`- جدول موتور . ببینید [با استفاده از دستگاه های بلوک های متعدد برای ذخیره سازی داده ها](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes). - -``` sql -ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' -``` - -این `ALTER TABLE t MOVE` پرسوجو: - -- تکرار نشده, به دلیل کپی های مختلف می توانید سیاست های ذخیره سازی مختلف دارند. -- بازگرداندن خطا در صورتی که دیسک یا حجم مشخص پیکربندی نشده است. پرس و جو نیز یک خطا را برمی گرداند اگر شرایط در حال حرکت داده, که مشخص شده در سیاست ذخیره سازی, نمی توان اعمال کرد. -- می توانید یک خطا در مورد بازگشت, زمانی که داده ها به نقل مکان کرد در حال حاضر توسط یک فرایند پس زمینه نقل مکان کرد, همزمان `ALTER TABLE t MOVE` پرس و جو و یا به عنوان یک نتیجه از ادغام داده های پس زمینه. کاربر باید هر گونه اقدامات اضافی در این مورد انجام نمی. - -مثال: - -``` sql -ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' -ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' -``` - -#### نحوه تنظیم بیان پارتیشن {#alter-how-to-specify-part-expr} - -شما می توانید بیان پارتیشن را مشخص کنید `ALTER ... PARTITION` نمایش داده شد به روش های مختلف: - -- به عنوان یک مقدار از `partition` ستون از `system.parts` جدول به عنوان مثال, `ALTER TABLE visits DETACH PARTITION 201901`. -- به عنوان بیان از ستون جدول. ثابت ها و عبارات ثابت پشتیبانی می شوند. به عنوان مثال, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. -- با استفاده از شناسه پارتیشن. شناسه پارتیشن شناسه رشته پارتیشن (انسان قابل خواندن در صورت امکان) است که به عنوان نام پارتیشن در فایل سیستم و در باغ وحش استفاده می شود. شناسه پارتیشن باید در `PARTITION ID` بند, در یک نقل قول واحد. به عنوان مثال, `ALTER TABLE visits DETACH PARTITION ID '201901'`. -- در [ALTER ATTACH PART](#alter_attach-partition) و [DROP DETACHED PART](#alter_drop-detached) پرس و جو, برای مشخص کردن نام یک بخش, استفاده از رشته تحت اللفظی با ارزش از `name` ستون از [سیستم.قطعات مجزا](../../operations/system_tables.md#system_tables-detached_parts) جدول به عنوان مثال, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. - -استفاده از نقل قول در هنگام مشخص کردن پارتیشن بستگی به نوع بیان پارتیشن. برای مثال برای `String` نوع, شما باید برای مشخص کردن نام خود را در نقل قول (`'`). برای `Date` و `Int*` انواع بدون نقل قول مورد نیاز است. - -برای جداول قدیمی به سبک, شما می توانید پارتیشن یا به عنوان یک عدد مشخص `201901` یا یک رشته `'201901'`. نحو برای جداول سبک جدید سختگیرانه تر با انواع است (شبیه به تجزیه کننده برای فرمت ورودی ارزش). - -تمام قوانین فوق نیز برای درست است [OPTIMIZE](misc.md#misc_operations-optimize) پرس و جو. اگر شما نیاز به مشخص کردن تنها پارتیشن در هنگام بهینه سازی یک جدول غیر تقسیم, تنظیم بیان `PARTITION tuple()`. به عنوان مثال: - -``` sql -OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; -``` - -نمونه هایی از `ALTER ... PARTITION` نمایش داده شد در تست نشان داده شده است [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) و [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). - -### دستکاری با جدول جدول {#manipulations-with-table-ttl} - -شما می توانید تغییر دهید [جدول](../../engines/table_engines/mergetree_family/mergetree.md#mergetree-table-ttl) با درخواست فرم زیر: - -``` sql -ALTER TABLE table-name MODIFY TTL ttl-expression -``` - -### همزمانی تغییر نمایش داده شد {#synchronicity-of-alter-queries} - -برای جداول غیر قابل تکرار, همه `ALTER` نمایش داده شد همزمان انجام می شود. برای جداول تکرار, پرس و جو فقط می افزاید دستورالعمل برای اقدامات مناسب به `ZooKeeper` و اقدامات خود را در اسرع وقت انجام می شود. با این حال, پرس و جو می توانید صبر کنید برای این اقدامات در تمام کپی تکمیل شود. - -برای `ALTER ... ATTACH|DETACH|DROP` نمایش داده شد, شما می توانید با استفاده از `replication_alter_partitions_sync` راه اندازی به راه اندازی انتظار. -مقادیر ممکن: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. - -### جهشها {#alter-mutations} - -جهش یک نوع پرس و جو را تغییر دهید که اجازه می دهد تا تغییر یا حذف ردیف در یک جدول. در مقایسه با استاندارد `UPDATE` و `DELETE` نمایش داده شد که برای تغییرات داده نقطه در نظر گرفته شده, جهش برای عملیات سنگین است که تغییر بسیاری از ردیف در یک جدول در نظر گرفته شده. پشتیبانی برای `MergeTree` خانواده از موتورهای جدول از جمله موتورهای با پشتیبانی تکرار. - -جداول موجود برای جهش به عنوان (بدون تبدیل لازم), اما پس از جهش برای اولین بار است که به یک جدول اعمال, فرمت ابرداده خود را با نسخه های سرور قبلی ناسازگار می شود و سقوط به نسخه های قبلی غیر ممکن می شود. - -دستورات در حال حاضر در دسترس: - -``` sql -ALTER TABLE [db.]table DELETE WHERE filter_expr -``` - -این `filter_expr` باید از نوع باشد `UInt8`. پرس و جو حذف ردیف در جدول که این عبارت طول می کشد یک مقدار غیر صفر. - -``` sql -ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr -``` - -این `filter_expr` باید از نوع باشد `UInt8`. این پرس و جو به روز رسانی مقادیر ستون مشخص شده به ارزش عبارات مربوطه در ردیف که `filter_expr` طول می کشد یک مقدار غیر صفر. ارزش ها به نوع ستون با استفاده از قالبی `CAST` اپراتور. به روز رسانی ستون هایی که در محاسبه اولیه استفاده می شود و یا کلید پارتیشن پشتیبانی نمی شود. - -``` sql -ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name -``` - -پرس و جو بازسازی شاخص ثانویه `name` در پارتیشن `partition_name`. - -یک پرس و جو می تواند شامل چندین دستورات جدا شده توسط کاما. - -برای \* جداول ادغام جهش اجرا با بازنویسی تمام قطعات داده. هیچ اتمیتی وجود ندارد - قطعات برای قطعات جهش یافته جایگزین می شوند به محض اینکه اماده باشند و `SELECT` پرس و جو است که شروع به اجرای در طول جهش داده ها از قطعات است که در حال حاضر همراه با داده ها از قطعات است که هنوز جهش یافته شده اند جهش را ببینید. - -جهش ها به طور کامل توسط نظم خلقت خود دستور داده می شوند و به هر بخش به این ترتیب اعمال می شوند. جهش نیز تا حدی با درج دستور داد - داده هایی که به جدول وارد شد قبل از جهش ارسال خواهد شد جهش یافته و داده هایی که پس از که قرار داده شد جهش یافته نمی شود. توجه داشته باشید که جهش درج به هیچ وجه مسدود نیست. - -یک جهش پرس و جو می گرداند بلافاصله پس از جهش مطلب اضافه شده است (در صورت تکرار جداول به باغ وحش برای nonreplicated جداول - به فایل سیستم). جهش خود را اجرا ناهمگام با استفاده از تنظیمات مشخصات سیستم. برای پیگیری پیشرفت جهش شما می توانید با استفاده از [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) جدول یک جهش است که با موفقیت ارسال شد ادامه خواهد داد برای اجرای حتی اگر سرور کلیک دوباره راه اندازی. هیچ راهی برای عقب انداختن جهش هنگامی که ارسال شده است وجود دارد, اما اگر جهش برای برخی از دلیل گیر می تواند با لغو [`KILL MUTATION`](misc.md#kill-mutation) پرس و جو. - -مطالب برای جهش به پایان رسید حذف نمی حق دور (تعداد نوشته های حفظ شده توسط تعیین `finished_mutations_to_keep` پارامتر موتور ذخیره سازی). نوشته جهش قدیمی تر حذف می شوند. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/fa/sql_reference/statements/create.md b/docs/fa/sql_reference/statements/create.md deleted file mode 100644 index 947239c39ce..00000000000 --- a/docs/fa/sql_reference/statements/create.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 35 -toc_title: CREATE ---- - -# ایجاد پرس و جو {#create-queries} - -## CREATE DATABASE {#query-language-create-database} - -ایجاد پایگاه داده. - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] -``` - -### بند {#clauses} - -- `IF NOT EXISTS` - - If the `db_name` database already exists, then ClickHouse doesn't create a new database and: - - - Doesn't throw an exception if clause is specified. - - Throws an exception if clause isn't specified. - -- `ON CLUSTER` - - ClickHouse creates the `db_name` database on all the servers of a specified cluster. - -- `ENGINE` - - - [MySQL](../engines/database_engines/mysql.md) - - Allows you to retrieve data from the remote MySQL server. - - By default, ClickHouse uses its own [database engine](../engines/database_engines/index.md). - -## CREATE TABLE {#create-table-query} - -این `CREATE TABLE` پرس و جو می تواند اشکال مختلف داشته باشد. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], - ... -) ENGINE = engine -``` - -ایجاد یک جدول به نام ‘name’ در ‘db’ پایگاه داده یا پایگاه داده فعلی اگر ‘db’ تنظیم نشده است, با ساختار مشخص شده در براکت و ‘engine’ موتور. -ساختار جدول یک لیست از توصیف ستون است. اگر شاخص ها توسط موتور پشتیبانی می شوند به عنوان پارامتر برای موتور جدول نشان داده می شوند. - -شرح ستون است `name type` در ساده ترین حالت. مثال: `RegionID UInt32`. -عبارات همچنین می توانید برای مقادیر پیش فرض تعریف شود (پایین را ببینید). - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] -``` - -ایجاد یک جدول با همان ساختار به عنوان جدول دیگر. شما می توانید یک موتور مختلف برای جدول مشخص کنید. اگر موتور مشخص نشده است, همان موتور خواهد شد که برای استفاده `db2.name2` جدول - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() -``` - -ایجاد یک جدول با ساختار و داده های بازگردانده شده توسط یک [تابع جدول](../table_functions/index.md). - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... -``` - -ایجاد یک جدول با یک ساختار مانند نتیجه `SELECT` پرس و جو, با ‘engine’ موتور, و پر با داده ها از را انتخاب کنید. - -در همه موارد اگر `IF NOT EXISTS` مشخص شده است, پرس و جو یک خطا بازگشت نیست اگر جدول در حال حاضر وجود دارد. در این مورد پرس و جو هیچ کاری انجام نخواهد داد. - -می تواند بند دیگر پس از وجود دارد `ENGINE` بند در پرس و جو. دیدن مستندات دقیق در مورد چگونگی ایجاد جدول در شرح [موتورهای جدول](../../engines/table_engines/index.md#table_engines). - -### مقادیر پیشفرض {#create-default-values} - -شرح ستون می تواند یک عبارت برای یک مقدار پیش فرض مشخص, در یکی از روش های زیر:`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. -مثال: `URLDomain String DEFAULT domain(URL)`. - -اگر یک عبارت برای مقدار پیش فرض تعریف نشده است, مقادیر پیش فرض خواهد شد به صفر برای اعداد تنظیم, رشته های خالی برای رشته, طعمه خالی برای ارریس, و `0000-00-00` برای تاریخ و یا `0000-00-00 00:00:00` برای تاریخ با زمان. نقاط صفر پشتیبانی نمی شوند. - -اگر عبارت پیش فرض تعریف شده است, نوع ستون اختیاری است. در صورتی که یک نوع به صراحت تعریف شده وجود ندارد, نوع بیان پیش فرض استفاده شده است. مثال: `EventDate DEFAULT toDate(EventTime)` – the ‘Date’ نوع خواهد شد برای استفاده ‘EventDate’ ستون. - -اگر نوع داده ها و پیش فرض بیان تعریف شده به صراحت این را بیان خواهد شد بازیگران به نوع مشخص شده با استفاده از نوع مصاحبه توابع. مثال: `Hits UInt32 DEFAULT 0` معنی همان چیزی که به عنوان `Hits UInt32 DEFAULT toUInt32(0)`. - -Default expressions may be defined as an arbitrary expression from table constants and columns. When creating and changing the table structure, it checks that expressions don't contain loops. For INSERT, it checks that expressions are resolvable – that all columns they can be calculated from have been passed. - -`DEFAULT expr` - -مقدار پیش فرض عادی. اگر پرس و جو درج می کند ستون مربوطه مشخص نیست, خواهد شد در محاسبات بیان مربوطه پر. - -`MATERIALIZED expr` - -بیان محقق. چنین ستون ای نمی تواند برای درج مشخص شود زیرا همیشه محاسبه می شود. -برای درج بدون یک لیست از ستون, این ستون ها در نظر گرفته نمی. -علاوه بر این, این ستون جایگزین نشده است که با استفاده از یک ستاره در یک پرس و جو را انتخاب کنید. این است که برای حفظ همواره که تخلیه با استفاده از `SELECT *` را می توان به جدول با استفاده از درج بدون مشخص کردن لیست ستون قرار داده شده. - -`ALIAS expr` - -دو واژه مترادف. چنین ستون در جدول ذخیره نمی شود و در همه. -ارزش های خود را نمی توان در یک جدول قرار داد و هنگام استفاده از ستاره در یک پرس و جو انتخاب جایگزین نمی شود. -این را می توان در انتخاب استفاده می شود اگر نام مستعار است که در طول تجزیه پرس و جو گسترش یافته است. - -هنگام استفاده از پرس و جو را تغییر دهید برای اضافه کردن ستون جدید, داده های قدیمی برای این ستون نوشته نشده است. بجای, در هنگام خواندن داده های قدیمی که ارزش برای ستون جدید ندارد, عبارات در پرواز به طور پیش فرض محاسبه. با این حال, اگر در حال اجرا عبارات نیاز به ستون های مختلف است که در پرس و جو نشان داده نمی, این ستون علاوه بر خوانده خواهد شد, اما فقط برای بلوک های داده که نیاز. - -اگر شما یک ستون جدید اضافه کردن به یک جدول اما بعد تغییر بیان پیش فرض خود, ارزش های مورد استفاده برای داده های قدیمی تغییر خواهد کرد (برای داده هایی که ارزش بر روی دیسک ذخیره نمی شد). توجه داشته باشید که هنگام اجرای ادغام پس زمینه, داده ها را برای ستون که در یکی از قطعات ادغام از دست رفته است به بخش ادغام شده نوشته شده. - -این ممکن است به مجموعه مقادیر پیش فرض برای عناصر در ساختارهای داده تو در تو. - -### قیدها {#constraints} - -همراه با ستون توصیف محدودیت می تواند تعریف شود: - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - ... - CONSTRAINT constraint_name_1 CHECK boolean_expr_1, - ... -) ENGINE = engine -``` - -`boolean_expr_1` می تواند با هر عبارت بولی. اگر قیود برای جدول تعریف شود هر کدام برای هر سطر بررسی خواهند شد `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. - -اضافه کردن مقدار زیادی از محدودیت های منفی می تواند عملکرد بزرگ را تحت تاثیر قرار `INSERT` نمایش داده شد. - -### عبارت دیگر {#ttl-expression} - -تعریف می کند زمان ذخیره سازی برای ارزش. می توان تنها برای ادغام مشخص-جداول خانواده. برای توضیحات دقیق, دیدن [ستون ها و جداول](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). - -### کدکهای فشردهسازی ستون {#codecs} - -به طور پیش فرض, تاتر اعمال `lz4` روش فشرده سازی. برای `MergeTree`- خانواده موتور شما می توانید روش فشرده سازی به طور پیش فرض در تغییر [فشردهسازی](../../operations/server_configuration_parameters/settings.md#server-settings-compression) بخش پیکربندی سرور. شما همچنین می توانید روش فشرده سازی برای هر ستون فردی در تعریف `CREATE TABLE` پرس و جو. - -``` sql -CREATE TABLE codec_example -( - dt Date CODEC(ZSTD), - ts DateTime CODEC(LZ4HC), - float_value Float32 CODEC(NONE), - double_value Float64 CODEC(LZ4HC(9)) - value Float32 CODEC(Delta, ZSTD) -) -ENGINE = -... -``` - -اگر یک کدک مشخص شده است, کدک به طور پیش فرض صدق نمی کند. به عنوان مثال کدک ها را می توان در یک خط لوله ترکیب کرد, `CODEC(Delta, ZSTD)`. برای انتخاب بهترین ترکیب کدک برای شما پروژه معیار شبیه به شرح داده شده در التیت منتقل می کند [کدگذاری های جدید برای بهبود بهره وری کلیک](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) مقاله. - -!!! warning "اخطار" - شما می توانید فایل های پایگاه داده کلیک از حالت فشرده خارج با تاسیسات خارجی مانند `lz4`. بجای, استفاده از ویژه [کلیک کمپرسور](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) سودمند. - -فشرده سازی برای موتورهای جدول زیر پشتیبانی می شود: - -- [ادغام](../../engines/table_engines/mergetree_family/mergetree.md) خانواده پشتیبانی از کدک های فشرده سازی ستون و انتخاب روش فشرده سازی پیش فرض توسط [فشردهسازی](../../operations/server_configuration_parameters/settings.md#server-settings-compression) تنظیمات. -- [ثبت](../../engines/table_engines/log_family/log_family.md) خانواده با استفاده از `lz4` روش فشرده سازی به طور پیش فرض و پشتیبانی از کدک های فشرده سازی ستون. -- [تنظیم](../../engines/table_engines/special/set.md). فقط فشرده سازی پیش فرض پشتیبانی می کند. -- [پیوستن](../../engines/table_engines/special/join.md). فقط فشرده سازی پیش فرض پشتیبانی می کند. - -تاتر با پشتیبانی از کدک های هدف مشترک و کدک های تخصصی. - -#### کدکهای تخصصی {#create-query-specialized-codecs} - -این کدک ها طراحی شده اند تا فشرده سازی را با استفاده از ویژگی های خاص داده ها موثر تر کند. برخی از این کدک ها اطلاعات خود را فشرده سازی نمی کنند. در عوض داده ها را برای یک کدک هدف مشترک تهیه می کنند که بهتر از بدون این دارو را فشرده می کند. - -کدکهای تخصصی: - -- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` برای ذخیره سازی مقادیر دلتا استفاده می شود, بنابراین `delta_bytes` حداکثر اندازه مقادیر خام است. ممکن است `delta_bytes` ارزش: 1, 2, 4, 8. مقدار پیش فرض برای `delta_bytes` هست `sizeof(type)` اگر به برابر 1, 2, 4, یا 8. در تمام موارد دیگر 1 است. -- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [گوریل: سریع, مقیاس پذیر, در حافظه پایگاه داده سری زمان](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [گوریل: سریع, مقیاس پذیر, در حافظه پایگاه داده سری زمان](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` و `DateTime`). در هر مرحله از الگوریتم کدک یک بلوک از ارزش های 64 را می گیرد و به ماتریس بیتی 6464 می رسد و بیت های استفاده نشده ارزش ها را تولید می کند و بقیه را به عنوان یک دنباله باز می گرداند. بیت های استفاده نشده بیت هایی هستند که بین مقادیر حداکثر و حداقل در کل بخش داده ای که فشرده سازی استفاده می شود متفاوت نیستند. - -`DoubleDelta` و `Gorilla` کدک ها در گوریل تسدب به عنوان اجزای الگوریتم فشرده سازی خود استفاده می شود. رویکرد گوریل در سناریوها موثر است زمانی که یک دنباله از ارزش های کم زمان خود را با تغییر دادن زمان وجود دارد. مهر زمانی به طور موثر توسط فشرده `DoubleDelta` کدک و ارزش ها به طور موثر توسط فشرده `Gorilla` وابسته به کدک. مثلا برای دریافت جدول ذخیره شده به طور موثر می توانید در تنظیمات زیر ایجاد کنید: - -``` sql -CREATE TABLE codec_example -( - timestamp DateTime CODEC(DoubleDelta), - slow_values Float32 CODEC(Gorilla) -) -ENGINE = MergeTree() -``` - -#### کدک های هدف مشترک {#create-query-common-purpose-codecs} - -کدکها: - -- `NONE` — No compression. -- `LZ4` — Lossless [الگوریتم فشرده سازی داده ها](https://github.com/lz4/lz4) به طور پیش فرض استفاده می شود. اعمال فشرده سازی سریع 4. -- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` سطح پیش فرض اعمال می شود. سطوح ممکن: \[1, 12\]. محدوده سطح توصیه شده: \[4, 9\]. -- `ZSTD[(level)]` — [الگوریتم فشرد فشاری](https://en.wikipedia.org/wiki/Zstandard) با قابلیت تنظیم `level`. سطوح ممکن: \[1, 22\]. مقدار پیش فرض: 1. - -سطح فشرده سازی بالا برای حالات نامتقارن مفید هستند, مانند فشرده سازی یک بار, از حالت فشرده خارج بارها و بارها. سطوح بالاتر به معنای فشرده سازی بهتر و استفاده از پردازنده بالاتر است. - -## جداول موقت {#temporary-tables} - -تاتر از جداول موقت که دارای ویژگی های زیر: - -- جداول موقت ناپدید می شوند هنگامی که جلسه به پایان می رسد از جمله اگر اتصال از دست داده است. -- جدول موقت با استفاده از موتور حافظه تنها. -- دسی بل را نمی توان برای یک جدول موقت مشخص شده است. این است که در خارج از پایگاه داده ایجاد شده است. -- غیر ممکن است برای ایجاد یک جدول موقت با پرس و جو توزیع دی ال در تمام سرورهای خوشه (با استفاده از `ON CLUSTER`): این جدول تنها در جلسه فعلی وجود دارد. -- اگر یک جدول موقت است به همین نام به عنوان یکی دیگر و یک پرس و جو نام جدول بدون مشخص دسی بل مشخص, جدول موقت استفاده خواهد شد. -- برای پردازش پرس و جو توزیع, جداول موقت مورد استفاده در یک پرس و جو به سرور از راه دور منتقل. - -برای ایجاد یک جدول موقت از نحو زیر استفاده کنید: - -``` sql -CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) -``` - -در بیشتر موارد, جداول موقت به صورت دستی ایجاد نمی, اما در هنگام استفاده از داده های خارجی برای پرس و جو, و یا برای توزیع `(GLOBAL) IN`. برای کسب اطلاعات بیشتر به بخش های مناسب مراجعه کنید - -امکان استفاده از جداول با [موتور = حافظه](../../engines/table_engines/special/memory.md) به جای جداول موقت. - -## توزیع پرس و جو ددل (در بند خوشه) {#distributed-ddl-queries-on-cluster-clause} - -این `CREATE`, `DROP`, `ALTER` و `RENAME` نمایش داده شد حمایت از اجرای توزیع در یک خوشه. -برای مثال پرس و جو زیر ایجاد می کند `all_hits` `Distributed` جدول در هر میزبان در `cluster`: - -``` sql -CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) -``` - -به منظور اجرای این نمایش داده شد به درستی, هر یک از میزبان باید تعریف خوشه همان (برای ساده سازی تنظیمات همگام سازی, شما می توانید تعویض از باغ وحش استفاده). همچنین باید به سرورهای باغ وحش متصل شوند. -نسخه محلی از پرس و جو در نهایت بر روی هر یک از میزبان در خوشه اجرا می شود, حتی اگر برخی از میزبان در حال حاضر در دسترس نیست. سفارش برای اجرای نمایش داده شد در یک میزبان واحد تضمین شده است. - -## CREATE VIEW {#create-view} - -``` sql -CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... -``` - -ایجاد یک دیدگاه. دو نوع دیدگاه وجود دارد: طبیعی و تحقق. - -نمایش عادی هیچ داده ذخیره نمی, اما فقط انجام خواندن از جدول دیگر. به عبارت دیگر, یک نمایش عادی چیزی بیش از یک پرس و جو ذخیره شده است. هنگام خواندن از نظر, این پرس و جو را نجات داد به عنوان یک خرده فروشی در بند از استفاده. - -به عنوان مثال, فرض کنیم شما یک دیدگاه ایجاد کرده اید: - -``` sql -CREATE VIEW view AS SELECT ... -``` - -و پرس و جو نوشته شده است: - -``` sql -SELECT a, b, c FROM view -``` - -این پرس و جو به طور کامل به استفاده از خرده فروشی معادل است: - -``` sql -SELECT a, b, c FROM (SELECT ...) -``` - -نمایش ها محقق داده فروشگاه تبدیل شده توسط پرس و جو مربوطه را انتخاب کنید. - -هنگام ایجاد یک دیدگاه محقق بدون `TO [db].[table]`, you must specify ENGINE – the table engine for storing data. - -هنگام ایجاد یک دیدگاه محقق با `TO [db].[table]`, شما باید استفاده کنید `POPULATE`. - -مشاهده محقق به شرح زیر مرتب: هنگام قرار دادن داده ها به جدول مشخص شده در انتخاب, بخشی از داده های درج شده است این پرس و جو را انتخاب کنید تبدیل, و در نتیجه در نظر قرار داده. - -اگر شما جمعیت مشخص, داده های جدول موجود در نظر قرار داده در هنگام ایجاد, اگر ساخت یک `CREATE TABLE ... AS SELECT ...` . در غیر این صورت پرس و جو شامل تنها داده های درج شده در جدول پس از ایجاد دیدگاه. ما توصیه نمی کنیم با استفاده از جمعیت, از داده ها در جدول در طول ایجاد مشاهده قرار داده نمی شود. - -A `SELECT` پرسوجو می تواند شامل شود `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Note that the corresponding conversions are performed independently on each block of inserted data. For example, if `GROUP BY` تنظیم شده است, داده ها در طول درج جمع, اما تنها در یک بسته واحد از داده های درج شده. داده ها بیشتر جمع نمی شود. استثنا است که با استفاده از یک موتور است که به طور مستقل انجام تجمع داده ها, مانند `SummingMergeTree`. - -اعدام `ALTER` نمایش داده شد در نمایش محقق شده است به طور کامل توسعه یافته نیست, بنابراین ممکن است ناخوشایند. اگر مشاهده محقق با استفاده از ساخت و ساز `TO [db.]name` شما می توانید `DETACH` منظره, اجرا `ALTER` برای جدول هدف و سپس `ATTACH` قبلا جدا (`DETACH`) نظر . - -نمایش ها نگاه همان جداول عادی. برای مثال در نتیجه ذکر شده است `SHOW TABLES` پرس و جو. - -پرس و جو جداگانه برای حذف نمایش ها وجود ندارد. برای حذف یک نما, استفاده `DROP TABLE`. - -## CREATE DICTIONARY {#create-dictionary-query} - -``` sql -CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] -( - key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - attr1 type2 [DEFAULT|EXPRESSION expr3], - attr2 type2 [DEFAULT|EXPRESSION expr4] -) -PRIMARY KEY key1, key2 -SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) -LAYOUT(LAYOUT_NAME([param_name param_value])) -LIFETIME([MIN val1] MAX val2) -``` - -ایجاد [فرهنگ لغت خارجی](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) با توجه به [ساختار](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md), [متن](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md), [طرحبندی](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md) و [طول عمر](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md). - -ساختار فرهنگ لغت خارجی شامل ویژگی های. ویژگی فرهنگ لغت به طور مشابه به ستون جدول مشخص شده است. تنها ویژگی مورد نیاز ویژگی نوع خود است, تمام خواص دیگر ممکن است مقادیر پیش فرض دارند. - -بسته به فرهنگ لغت [طرحبندی](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md) یک یا چند ویژگی را می توان به عنوان کلید فرهنگ لغت مشخص شده است. - -برای کسب اطلاعات بیشتر, دیدن [واژهنامهها خارجی](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) بخش. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/create/) diff --git a/docs/fa/sql_reference/statements/index.md b/docs/fa/sql_reference/statements/index.md deleted file mode 100644 index a2246679149..00000000000 --- a/docs/fa/sql_reference/statements/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Statements -toc_priority: 31 ---- - - diff --git a/docs/fa/sql_reference/statements/insert_into.md b/docs/fa/sql_reference/statements/insert_into.md deleted file mode 100644 index 25709b2ee67..00000000000 --- a/docs/fa/sql_reference/statements/insert_into.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 34 -toc_title: INSERT INTO ---- - -## INSERT {#insert} - -اضافه کردن داده ها. - -قالب پرس و جو عمومی: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... -``` - -پرسوجو میتواند فهرستی از ستونها را برای درج مشخص کند `[(c1, c2, c3)]`. در این مورد, بقیه ستون ها با پر: - -- مقادیر محاسبه شده از `DEFAULT` عبارات مشخص شده در تعریف جدول. -- صفر و رشته خالی, اگر `DEFAULT` عبارات تعریف نشده. - -اگر [\_مرحلهای دقیق = 1](../../operations/settings/settings.md) ستون هایی که ندارند `DEFAULT` تعریف شده باید در پرس و جو ذکر شده است. - -داده ها را می توان به درج در هر گذشت [قالب](../../interfaces/formats.md#formats) پشتیبانی شده توسط فاحشه خانه. قالب باید به صراحت در پرس و جو مشخص شود: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set -``` - -For example, the following query format is identical to the basic version of INSERT … VALUES: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... -``` - -تاتر حذف تمام فضاها و خوراک یک خط (در صورتی که وجود دارد) قبل از داده ها. هنگام تشکیل یک پرس و جو, توصیه می کنیم قرار دادن داده ها بر روی یک خط جدید پس از اپراتورهای پرس و جو (این مهم است که اگر داده ها با فضاهای شروع می شود). - -مثال: - -``` sql -INSERT INTO t FORMAT TabSeparated -11 Hello, world! -22 Qwerty -``` - -شما می توانید داده ها را به طور جداگانه از پرس و جو با استفاده از مشتری خط فرمان یا رابط اچ تی پی وارد کنید. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “[واسط](../../interfaces/index.md#interfaces)”. - -### قیدها {#constraints} - -اگر جدول [قیدها](create.md#constraints), their expressions will be checked for each row of inserted data. If any of those constraints is not satisfied — server will raise an exception containing constraint name and expression, the query will be stopped. - -### قرار دادن نتایج `SELECT` {#insert_query_insert-select} - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... -``` - -ستون ها با توجه به موقعیت خود را در بند را انتخاب کنید نقشه برداری. با این حال, نام خود را در عبارت را انتخاب کنید و جدول برای درج ممکن است متفاوت باشد. در صورت لزوم نوع ریخته گری انجام می شود. - -هیچ یک از فرمت های داده به جز مقادیر اجازه تنظیم مقادیر به عبارات مانند `now()`, `1 + 2` و به همین ترتیب. فرمت ارزش اجازه می دهد تا استفاده محدود از عبارات, اما این توصیه نمی شود, چرا که در این مورد کد کم است برای اجرای خود استفاده می شود. - -نمایش داده شد دیگر برای تغییر قطعات داده ها پشتیبانی نمی شوند: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. -با این حال, شما می توانید داده های قدیمی با استفاده از حذف `ALTER TABLE ... DROP PARTITION`. - -`FORMAT` بند باید در پایان پرس و جو مشخص شود اگر `SELECT` بند شامل تابع جدول [ورودی()](../table_functions/input.md). - -### ملاحظات عملکرد {#performance-considerations} - -`INSERT` داده های ورودی را با کلید اصلی مرتب می کند و توسط یک کلید پارتیشن به پارتیشن تقسیم می شود. اگر داده ها را به چندین پارتیشن در یک بار وارد کنید می تواند به طور قابل توجهی عملکرد را کاهش دهد `INSERT` پرس و جو. برای جلوگیری از این: - -- اضافه کردن داده ها در دسته نسبتا بزرگ, مانند 100,000 ردیف در یک زمان. -- داده های گروه توسط یک کلید پارتیشن قبل از بارگذاری به کلیک. - -عملکرد کاهش نخواهد یافت اگر: - -- داده ها در زمان واقعی اضافه شده است. -- شما داده ها است که معمولا بر اساس زمان طبقه بندی شده اند را بارگذاری کنید. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/fa/sql_reference/statements/misc.md b/docs/fa/sql_reference/statements/misc.md deleted file mode 100644 index 113c3e7173d..00000000000 --- a/docs/fa/sql_reference/statements/misc.md +++ /dev/null @@ -1,252 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u063A\u06CC\u0631\u0647" ---- - -# متفرقه نمایش داده شد {#miscellaneous-queries} - -## ATTACH {#attach} - -این پرس و جو دقیقا همان است `CREATE` اما - -- به جای کلمه `CREATE` با استفاده از این کلمه `ATTACH`. -- پرس و جو می کند داده ها بر روی دیسک ایجاد کنید, اما فرض می شود که داده ها در حال حاضر در مکان های مناسب, و فقط می افزاید: اطلاعات در مورد جدول به سرور. - پس از اجرای یک ضمیمه پرس و جو در سرور خواهد شد در مورد وجود جدول. - -اگر جدول قبلا جدا شد (`DETACH`), به این معنی که ساختار خود شناخته شده است, شما می توانید مختصر بدون تعریف ساختار استفاده. - -``` sql -ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] -``` - -این پرس و جو در هنگام شروع سرور استفاده می شود. سرور ذخیره ابرداده جدول به عنوان فایل های با `ATTACH` نمایش داده شد, که به سادگی در راه اندازی اجرا می شود (به غیر از جداول سیستم, که به صراحت بر روی سرور ایجاد). - -## CHECK TABLE {#check-table} - -چک اگر داده ها در جدول خراب شده است. - -``` sql -CHECK TABLE [db.]name -``` - -این `CHECK TABLE` پرس و جو اندازه فایل واقعی با مقادیر مورد انتظار که بر روی سرور ذخیره می شود مقایسه می کند. اگر اندازه فایل انجام مقادیر ذخیره شده مطابقت ندارد, به این معنی که داده ها خراب شده است. این می تواند باعث, مثلا, توسط یک تصادف سیستم در طول اجرای پرس و جو. - -پاسخ پرس و جو شامل `result` ستون با یک ردیف. ردیف دارای ارزش -[بولی](../../sql_reference/data_types/boolean.md) نوع: - -- 0-داده ها در جدول خراب شده است. -- 1-داده حفظ یکپارچگی. - -این `CHECK TABLE` پرس و جو از موتورهای جدول زیر پشتیبانی می کند: - -- [ثبت](../../engines/table_engines/log_family/log.md) -- [جمع شدن](../../engines/table_engines/log_family/tinylog.md) -- [خط زدن](../../engines/table_engines/log_family/stripelog.md) -- [ادغام خانواده](../../engines/table_engines/mergetree_family/mergetree.md) - -انجام بیش از جداول با موتورهای جدول دیگر باعث یک استثنا. - -موتورهای از `*Log` خانواده بازیابی اطلاعات خودکار در شکست را فراهم نمی کند. استفاده از `CHECK TABLE` پرس و جو برای پیگیری از دست دادن داده ها به موقع. - -برای `MergeTree` موتورهای خانواده `CHECK TABLE` پرس و جو نشان می دهد وضعیت چک برای هر بخش داده های فردی از یک جدول بر روی سرور محلی. - -**اگر داده ها خراب شده است** - -اگر جدول خراب شده است, شما می توانید داده های غیر خراب به جدول دیگر کپی کنید. برای انجام این کار: - -1. ایجاد یک جدول جدید با ساختار همان جدول صدمه دیده است. برای انجام این کار پرس و جو را اجرا کنید `CREATE TABLE AS `. -2. تنظیم [\_مخفی کردن](../../operations/settings/settings.md#settings-max_threads) ارزش به 1 برای پردازش پرس و جو بعدی در یک موضوع واحد. برای انجام این کار پرس و جو را اجرا کنید `SET max_threads = 1`. -3. اجرای پرسوجو `INSERT INTO SELECT * FROM `. این درخواست داده های غیر خراب شده را از جدول خراب شده به جدول دیگر کپی می کند. فقط داده ها قبل از قسمت خراب کپی خواهد شد. -4. راه اندازی مجدد `clickhouse-client` برای تنظیم مجدد `max_threads` ارزش. - -## DESCRIBE TABLE {#misc-describe-table} - -``` sql -DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -بازگرداندن موارد زیر `String` نوع ستونها: - -- `name` — Column name. -- `type`— Column type. -- `default_type` — Clause that is used in [عبارت پیشفرض](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` یا `ALIAS`). ستون شامل یک رشته خالی, اگر عبارت پیش فرض مشخص نشده است. -- `default_expression` — Value specified in the `DEFAULT` بند بند. -- `comment_expression` — Comment text. - -ساختارهای داده تو در تو خروجی در “expanded” قالب. هر ستون به طور جداگانه نشان داده شده است, با نام بعد از یک نقطه. - -## DETACH {#detach} - -حذف اطلاعات در مورد ‘name’ جدول از سرور. سرور متوقف می شود دانستن در مورد وجود جدول. - -``` sql -DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -این داده ها و یا ابرداده جدول را حذف کنید. در راه اندازی سرور بعدی, سرور خواهد ابرداده به عنوان خوانده شده و پیدا کردن در مورد جدول دوباره. -به طور مشابه “detached” جدول را می توان دوباره متصل با استفاده از `ATTACH` پرس و جو (به غیر از جداول سیستم که لازم نیست metadata ذخیره شده برای آنها). - -وجود ندارد `DETACH DATABASE` پرس و جو. - -## DROP {#drop} - -این پرسوجو دارای دو نوع است: `DROP DATABASE` و `DROP TABLE`. - -``` sql -DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] -``` - -حذف تمام جداول در داخل ‘db’ پایگاه داده, سپس حذف ‘db’ پایگاه داده خود را. -اگر `IF EXISTS` مشخص شده است, این خطا بازگشت نیست اگر پایگاه داده وجود ندارد. - -``` sql -DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -حذف جدول. -اگر `IF EXISTS` مشخص شده است, این خطا را نمی گرداند اگر جدول وجود ندارد و یا پایگاه داده وجود ندارد. - - DROP DICTIONARY [IF EXISTS] [db.]name - -دلس فرهنگ لغت. -اگر `IF EXISTS` مشخص شده است, این خطا را نمی گرداند اگر جدول وجود ندارد و یا پایگاه داده وجود ندارد. - -## EXISTS {#exists} - -``` sql -EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] -``` - -بازگرداندن یک `UInt8`- نوع ستون, که شامل ارزش واحد `0` اگر جدول یا پایگاه داده وجود ندارد, یا `1` اگر جدول در پایگاه داده مشخص شده وجود دارد. - -## KILL QUERY {#kill-query} - -``` sql -KILL QUERY [ON CLUSTER cluster] - WHERE - [SYNC|ASYNC|TEST] - [FORMAT format] -``` - -تلاش برای به زور خاتمه نمایش داده شد در حال حاضر در حال اجرا. -نمایش داده شد به فسخ از سیستم انتخاب شده است.جدول پردازش ها با استفاده از معیارهای تعریف شده در `WHERE` بند از `KILL` پرس و جو. - -مثالها: - -``` sql --- Forcibly terminates all queries with the specified query_id: -KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - --- Synchronously terminates all queries run by 'username': -KILL QUERY WHERE user='username' SYNC -``` - -فقط خواندنی کاربران تنها می تواند نمایش داده شد خود را متوقف کند. - -به طور پیش فرض, نسخه ناهمزمان از نمایش داده شد استفاده شده است (`ASYNC`), که برای تایید است که نمایش داده شد را متوقف کرده اند منتظر نیست. - -نسخه همزمان (`SYNC`) منتظر تمام نمایش داده شد برای متوقف کردن و نمایش اطلاعات در مورد هر فرایند به عنوان متوقف می شود. -پاسخ شامل `kill_status` ستون, که می تواند مقادیر زیر را: - -1. ‘finished’ – The query was terminated successfully. -2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. -3. The other values ​​explain why the query can't be stopped. - -پرسوجوی تست (`TEST`) فقط چک حقوق کاربر و نمایش یک لیست از نمایش داده شد برای متوقف کردن. - -## KILL MUTATION {#kill-mutation} - -``` sql -KILL MUTATION [ON CLUSTER cluster] - WHERE - [TEST] - [FORMAT format] -``` - -تلاش برای لغو و حذف [جهشها](alter.md#alter-mutations) که در حال حاضر اجرای. جهش به لغو از انتخاب [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) جدول با استفاده از فیلتر مشخص شده توسط `WHERE` بند از `KILL` پرس و جو. - -آزمون پرس و جو (`TEST`) فقط چک حقوق کاربر و نمایش یک لیست از نمایش داده شد برای متوقف کردن. - -مثالها: - -``` sql --- Cancel and remove all mutations of the single table: -KILL MUTATION WHERE database = 'default' AND table = 'table' - --- Cancel the specific mutation: -KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' -``` - -The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). - -تغییرات در حال حاضر توسط جهش ساخته شده به عقب نورد نیست. - -## OPTIMIZE {#misc_operations-optimize} - -``` sql -OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] -``` - -این پرس و جو تلاش می کند تا ادغام برنامه ریزی نشده از قطعات داده برای جداول با یک موتور جدول از [ادغام](../../engines/table_engines/mergetree_family/mergetree.md) خانواده - -این `OPTMIZE` پرس و جو نیز برای پشتیبانی [ماده بینی](../../engines/table_engines/special/materializedview.md) و [بافر](../../engines/table_engines/special/buffer.md) موتورها. دیگر موتورهای جدول پشتیبانی نمی شوند. - -زمانی که `OPTIMIZE` با استفاده از [تکرار غذای اصلی](../../engines/table_engines/mergetree_family/replication.md) خانواده از موتورهای جدول, تاتر ایجاد یک کار برای ادغام و منتظر اعدام در تمام گره (در صورتی که `replication_alter_partitions_sync` تنظیم فعال است). - -- اگر `OPTIMIZE` یک ادغام به هر دلیلی انجام نمی, این کار مشتری اطلاع نیست. برای فعال کردن اعلان ها از [ا\_فزون\_ف\_کوپ](../../operations/settings/settings.md#setting-optimize_throw_if_noop) تنظیمات. -- اگر شما یک مشخص `PARTITION` فقط پارتیشن مشخص شده بهینه شده است. [نحوه تنظیم بیان پارتیشن](alter.md#alter-how-to-specify-part-expr). -- اگر شما مشخص کنید `FINAL` حتی زمانی که تمام داده ها در حال حاضر در یک بخش بهینه سازی انجام شده است. -- اگر شما مشخص کنید `DEDUPLICATE` و سپس به طور کامل یکسان ردیف خواهد بود deduplicated (تمام ستون ها در مقایسه با) آن را حس می کند تنها برای MergeTree موتور. - -!!! warning "اخطار" - `OPTIMIZE` می توانید رفع نیست “Too many parts” خطا. - -## RENAME {#misc_operations-rename} - -تغییر نام یک یا چند جدول. - -``` sql -RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] -``` - -همه جداول تحت قفل جهانی تغییر نام داد. تغییر نام جداول یک عملیات نور است. اگر شما یک پایگاه داده دیگر نشان داد پس از به, جدول خواهد شد به این پایگاه داده منتقل. اما, دایرکتوری ها با پایگاه داده باید اقامت در همان فایل سیستم (در غیر این صورت یک خطا بازگشته است). - -## SET {#query-set} - -``` sql -SET param = value -``` - -انتساب `value` به `param` [تنظیم](../../operations/settings/index.md) برای جلسه فعلی. شما نمی توانید تغییر دهید [تنظیمات سرور](../../operations/server_configuration_parameters/index.md) از این طرف - -شما همچنین می توانید تمام مقادیر را از مشخصات تنظیمات مشخص شده در یک پرس و جو واحد تنظیم کنید. - -``` sql -SET profile = 'profile-name-from-the-settings-file' -``` - -برای کسب اطلاعات بیشتر, دیدن [تنظیمات](../../operations/settings/settings.md). - -## TRUNCATE {#truncate} - -``` sql -TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -حذف تمام داده ها را از یک جدول. هنگامی که بند `IF EXISTS` حذف شده است, پرس و جو یک خطا می گرداند اگر جدول وجود ندارد. - -این `TRUNCATE` پرسوجو برای پشتیبانی نمیشود [مشاهده](../../engines/table_engines/special/view.md), [پرونده](../../engines/table_engines/special/file.md), [URL](../../engines/table_engines/special/url.md) و [خالی](../../engines/table_engines/special/null.md) موتورهای جدول. - -## USE {#use} - -``` sql -USE db -``` - -به شما اجازه می دهد پایگاه داده فعلی را برای جلسه تنظیم کنید. -پایگاه داده فعلی برای جستجو برای جداول استفاده می شود اگر پایگاه داده به صراحت در پرس و جو با یک نقطه قبل از نام جدول تعریف نشده است. -این پرس و جو را نمی توان در هنگام استفاده از پروتکل قام ساخته شده, از هیچ مفهوم یک جلسه وجود دارد. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/fa/sql_reference/statements/select.md b/docs/fa/sql_reference/statements/select.md deleted file mode 100644 index a1f0a833e3f..00000000000 --- a/docs/fa/sql_reference/statements/select.md +++ /dev/null @@ -1,610 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 33 -toc_title: SELECT ---- - -# نحو نمایش داده شد را انتخاب کنید {#select-queries-syntax} - -`SELECT` بازیابی داده ها را انجام می دهد. - -``` sql -[WITH expr_list|(subquery)] -SELECT [DISTINCT] expr_list -[FROM [db.]table | (subquery) | table_function] [FINAL] -[SAMPLE sample_coeff] -[ARRAY JOIN ...] -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list -[PREWHERE expr] -[WHERE expr] -[GROUP BY expr_list] [WITH TOTALS] -[HAVING expr] -[ORDER BY expr_list] -[LIMIT [offset_value, ]n BY columns] -[LIMIT [n, ]m] -[UNION ALL ...] -[INTO OUTFILE filename] -[FORMAT format] -``` - -همه بند اختیاری هستند, به جز برای لیست مورد نیاز از عبارات بلافاصله پس از انتخاب. -بند های زیر تقریبا به همان ترتیب در نوار نقاله اجرای پرس و جو توصیف می شوند. - -اگر پرس و جو حذف `DISTINCT`, `GROUP BY` و `ORDER BY` بند و `IN` و `JOIN` subqueries این پرس و جو خواهد شد به طور کامل جریان پردازش با استفاده از O(1) میزان رم. -در غیر این صورت, پرس و جو ممکن است مقدار زیادی از رم مصرف اگر محدودیت های مناسب مشخص نشده است: `max_memory_usage`, `max_rows_to_group_by`, `max_rows_to_sort`, `max_rows_in_distinct`, `max_bytes_in_distinct`, `max_rows_in_set`, `max_bytes_in_set`, `max_rows_in_join`, `max_bytes_in_join`, `max_bytes_before_external_sort`, `max_bytes_before_external_group_by`. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “Settings”. ممکن است که به استفاده از مرتب سازی خارجی (صرفه جویی در جداول موقت به یک دیسک) و تجمع خارجی. `The system does not have "merge join"`. - -### با بند {#with-clause} - -در این بخش پشتیبانی از عبارات جدول مشترک فراهم می کند ([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL)), با برخی از محدودیت: -1. نمایش داده شد بازگشتی پشتیبانی نمی شوند -2. هنگامی که زیرخاکری در داخل با بخش استفاده می شود, این نتیجه باید اسکالر با دقیقا یک ردیف باشد -3. بیان نتایج در دسترس نیست در subqueries -نتایج با عبارات بند را می توان در داخل بند را انتخاب کنید استفاده می شود. - -مثال 1: با استفاده از عبارت ثابت به عنوان “variable” - -``` sql -WITH '2019-08-01 15:23:00' as ts_upper_bound -SELECT * -FROM hits -WHERE - EventDate = toDate(ts_upper_bound) AND - EventTime <= ts_upper_bound -``` - -مثال 2: جمع تخلیه(بایت) نتیجه بیان از بند لیست ستون را انتخاب کنید - -``` sql -WITH sum(bytes) as s -SELECT - formatReadableSize(s), - table -FROM system.parts -GROUP BY table -ORDER BY s -``` - -مثال 3: استفاده از نتایج عددی پرس - -``` sql -/* this example would return TOP 10 of most huge tables */ -WITH - ( - SELECT sum(bytes) - FROM system.parts - WHERE active - ) AS total_disk_usage -SELECT - (sum(bytes) / total_disk_usage) * 100 AS table_disk_usage, - table -FROM system.parts -GROUP BY table -ORDER BY table_disk_usage DESC -LIMIT 10 -``` - -مثال 4: استفاده مجدد از بیان در زیرخاکری -به عنوان یک راهحل برای محدودیت کنونی برای بیان استفاده در subqueries شما ممکن است تکراری است. - -``` sql -WITH ['hello'] AS hello -SELECT - hello, - * -FROM -( - WITH ['hello'] AS hello - SELECT hello -) -``` - -``` text -┌─hello─────┬─hello─────┐ -│ ['hello'] │ ['hello'] │ -└───────────┴───────────┘ -``` - -### از بند {#select-from} - -اگر از بند حذف شده است, داده خواهد شد از خواندن `system.one` جدول -این `system.one` جدول شامل دقیقا یک ردیف است (این جدول همان هدف را به عنوان جدول دوگانه موجود در سایر دساماسها انجام می دهد). - -این `FROM` بند منبع برای خواندن داده ها از مشخص: - -- جدول -- خرده فروشی -- [تابع جدول](../table_functions/index.md) - -`ARRAY JOIN` و به طور منظم `JOIN` همچنین ممکن است شامل شود (پایین را ببینید). - -به جای یک جدول `SELECT` خرده فروشی ممکن است در پرانتز مشخص. -در مقابل به گذاشتن استاندارد, مترادف نیازی به پس از یک خرده فروشی مشخص شود. - -برای اجرای پرس و جو تمام ستون های ذکر شده در پرس و جو از جدول مناسب استخراج می شوند. هر ستون برای پرس و جو خارجی مورد نیاز نیست از کارخانه های فرعی پرتاب می شود. -اگر پرس و جو هیچ ستون لیست نیست (به عنوان مثال, `SELECT count() FROM t`), برخی از ستون از جدول استخراج به هر حال (کوچکترین ترجیح داده می شود), به منظور محاسبه تعداد ردیف. - -#### تغییردهنده نهایی {#select-from-final} - -قابل استفاده در هنگام انتخاب داده ها از جداول از [ادغام](../../engines/table_engines/mergetree_family/mergetree.md)- خانواده موتور غیر از `GraphiteMergeTree`. چه زمانی `FINAL` مشخص شده است, تاتر به طور کامل ادغام داده ها قبل از بازگشت به نتیجه و در نتیجه انجام تمام تحولات داده که در طول ادغام برای موتور جدول داده شده اتفاق می افتد. - -همچنین برای پشتیبانی: -- [تکرار](../../engines/table_engines/mergetree_family/replication.md) نسخه های `MergeTree` موتورها. -- [نما](../../engines/table_engines/special/view.md), [بافر](../../engines/table_engines/special/buffer.md), [توزیع شده](../../engines/table_engines/special/distributed.md) و [ماده بینی](../../engines/table_engines/special/materializedview.md) موتورها که بیش از موتورهای دیگر کار می کنند به شرطی که بیش از ایجاد شده اند `MergeTree`- جدول موتور . - -نمایش داده شد که با استفاده از `FINAL` اعدام به همان سرعتی که نمایش داده شد مشابه که نمی, زیرا: - -- پرس و جو در یک موضوع اجرا و داده ها در طول اجرای پرس و جو با هم ادغام شدند. -- نمایش داده شد با `FINAL` خوانده شده ستون کلید اولیه در علاوه بر این به ستون مشخص شده در پرس و جو. - -در بیشتر موارد, اجتناب از استفاده از `FINAL`. - -### بند نمونه {#select-sample-clause} - -این `SAMPLE` بند اجازه می دهد تا برای پردازش پرس و جو تقریبی. - -هنگامی که نمونه گیری داده ها فعال است, پرس و جو بر روی تمام داده ها انجام نمی, اما تنها در بخش خاصی از داده ها (نمونه). مثلا, اگر شما نیاز به محاسبه ارقام برای تمام بازدیدکننده داشته است, کافی است برای اجرای پرس و جو در 1/10 کسری از تمام بازدیدکننده داشته است و سپس ضرب در نتیجه 10. - -پردازش پرس و جو تقریبی می تواند در موارد زیر مفید باشد: - -- هنگامی که شما شرایط زمان بندی دقیق (مانند \<100 مگابایت) اما شما نمی توانید هزینه منابع سخت افزاری اضافی را برای دیدار با خود توجیه کنید. -- هنگامی که داده های خام خود را دقیق نیست, بنابراین تقریب می کند به طرز محسوسی کاهش کیفیت. -- نیازهای کسب و کار هدف تقریبی نتایج (برای مقرون به صرفه بودن و یا به منظور به بازار دقیق نتایج به کاربران حق بیمه). - -!!! note "یادداشت" - شما فقط می توانید نمونه برداری با استفاده از جداول در [ادغام](../../engines/table_engines/mergetree_family/mergetree.md) خانواده, و تنها در صورتی که بیان نمونه برداری در ایجاد جدول مشخص شد (دیدن [موتور ادغام](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table)). - -ویژگی های نمونه گیری داده ها به شرح زیر است: - -- نمونهگیری دادهها یک مکانیسم قطعی است. نتیجه همان `SELECT .. SAMPLE` پرس و جو همیشه یکسان است. -- نمونه گیری به طور مداوم برای جداول مختلف کار می کند. برای جداول با یک کلید نمونه برداری تک, یک نمونه با ضریب همان همیشه زیر مجموعه همان داده های ممکن را انتخاب. برای مثال یک نمونه از شناسه های کاربر طول می کشد ردیف با همان زیر مجموعه از همه ممکن است شناسه کاربر از جداول مختلف. این به این معنی است که شما می توانید نمونه در کارخانه های فرعی در استفاده از [IN](#select-in-operators) بند بند. همچنین شما می توانید نمونه ها را با استفاده از [JOIN](#select-join) بند بند. -- نمونه گیری اجازه می دهد تا خواندن اطلاعات کمتر از یک دیسک. توجه داشته باشید که شما باید کلید نمونه برداری به درستی مشخص کنید. برای کسب اطلاعات بیشتر, دیدن [ایجاد یک جدول ادغام](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). - -برای `SAMPLE` بند نحو زیر پشتیبانی می شود: - -| SAMPLE Clause Syntax | توصیف | -|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `SAMPLE k` | اینجا `k` است تعداد از 0 به 1.
پرس و جو در اجرا `k` کسری از داده ها. به عنوان مثال, `SAMPLE 0.1` پرس و جو را در 10 درصد از داده ها اجرا می کند. [ادامه مطلب](#select-sample-k) | -| `SAMPLE n` | اینجا `n` عدد صحیح به اندازه کافی بزرگ است.
پرس و جو بر روی یک نمونه از حداقل اعدام `n` ردیف (اما نه به طور قابل توجهی بیشتر از این). به عنوان مثال, `SAMPLE 10000000` پرس و جو را در حداقل ردیف های 10000000 اجرا می کند. [ادامه مطلب](#select-sample-n) | -| `SAMPLE k OFFSET m` | اینجا `k` و `m` اعداد از 0 به 1.
پرس و جو بر روی یک نمونه از اعدام `k` کسری از داده ها. داده های مورد استفاده برای نمونه توسط جبران `m` کسر کردن. [ادامه مطلب](#select-sample-offset) | - -#### SAMPLE K {#select-sample-k} - -اینجا `k` است تعداد از 0 به 1 (هر دو نمادهای کسری و اعشاری پشتیبانی می شوند). به عنوان مثال, `SAMPLE 1/2` یا `SAMPLE 0.5`. - -در یک `SAMPLE k` بند, نمونه از گرفته `k` کسری از داده ها. مثال زیر نشان داده شده است: - -``` sql -SELECT - Title, - count() * 10 AS PageViews -FROM hits_distributed -SAMPLE 0.1 -WHERE - CounterID = 34 -GROUP BY Title -ORDER BY PageViews DESC LIMIT 1000 -``` - -در این مثال پرس و جو اجرا شده است در یک نمونه از 0.1 (10%) از داده ها. ارزش توابع دانه ها به طور خودکار اصلاح نمی, بنابراین برای دریافت یک نتیجه تقریبی, ارزش `count()` به صورت دستی توسط ضرب 10. - -#### SAMPLE N {#select-sample-n} - -اینجا `n` عدد صحیح به اندازه کافی بزرگ است. به عنوان مثال, `SAMPLE 10000000`. - -در این مورد, پرس و جو بر روی یک نمونه از حداقل اعدام `n` ردیف (اما نه به طور قابل توجهی بیشتر از این). به عنوان مثال, `SAMPLE 10000000` پرس و جو را در حداقل ردیف های 10000000 اجرا می کند. - -از حداقل واحد برای خواندن داده ها یک گرانول است (اندازه خود را توسط مجموعه `index_granularity` تنظیم), این را حس می کند به مجموعه ای از یک نمونه است که بسیار بزرگتر از اندازه گرانول. - -هنگام استفاده از `SAMPLE n` بند, شما نمی دانید که درصد نسبی داده پردازش شد. بنابراین شما نمی دانید ضریب توابع کل باید توسط ضرب. استفاده از `_sample_factor` ستون مجازی برای دریافت نتیجه تقریبی. - -این `_sample_factor` ستون شامل ضرایب نسبی است که به صورت پویا محاسبه می شود. این ستون به طور خودکار ایجاد زمانی که شما [ایجاد](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table) یک جدول با کلید نمونه گیری مشخص. نمونه های استفاده از `_sample_factor` ستون در زیر نشان داده شده. - -بیایید جدول را در نظر بگیریم `visits`, که شامل ارقام در مورد بازدیدکننده داشته است سایت. مثال اول نشان می دهد که چگونه برای محاسبه تعداد بازدید از صفحه: - -``` sql -SELECT sum(PageViews * _sample_factor) -FROM visits -SAMPLE 10000000 -``` - -مثال بعدی نشان می دهد که چگونه برای محاسبه تعداد کل بازدیدکننده داشته است: - -``` sql -SELECT sum(_sample_factor) -FROM visits -SAMPLE 10000000 -``` - -مثال زیر نشان می دهد که چگونه برای محاسبه مدت زمان جلسه به طور متوسط. توجه داشته باشید که شما لازم نیست به استفاده از ضریب نسبی برای محاسبه مقادیر متوسط. - -``` sql -SELECT avg(Duration) -FROM visits -SAMPLE 10000000 -``` - -#### SAMPLE K OFFSET M {#select-sample-offset} - -اینجا `k` و `m` اعداد از 0 به 1. نمونه های زیر نشان داده شده. - -**مثال 1** - -``` sql -SAMPLE 1/10 -``` - -در این مثال نمونه 1 / 10 از تمام داده ها است: - -`[++------------]` - -**مثال 2** - -``` sql -SAMPLE 1/10 OFFSET 1/2 -``` - -در اینجا یک نمونه از 10 درصد گرفته شده از نیمه دوم از داده ها. - -`[------++------]` - -### مجموعه پیوستن بند {#select-array-join-clause} - -اجازه می دهد تا اجرای `JOIN` با یک آرایه یا تو در تو ساختار داده ها. قصد این است که شبیه به [ارریجین](../../sql_reference/functions/array_join.md#functions_arrayjoin) تابع, اما قابلیت های خود را گسترده تر است. - -``` sql -SELECT -FROM -[LEFT] ARRAY JOIN -[WHERE|PREWHERE ] -... -``` - -شما می توانید تنها یک مشخص `ARRAY JOIN` بند در یک پرس و جو. - -سفارش اجرای پرس و جو در هنگام اجرا بهینه شده است `ARRAY JOIN`. اگرچه `ARRAY JOIN` همیشه باید قبل از مشخص شود `WHERE/PREWHERE` بند, این می تواند انجام شود یا قبل از `WHERE/PREWHERE` (اگر نتیجه در این بند مورد نیاز است), و یا پس از اتمام (برای کاهش حجم محاسبات). سفارش پردازش توسط بهینه ساز پرس و جو کنترل می شود. - -انواع پشتیبانی شده از `ARRAY JOIN` به شرح زیر است: - -- `ARRAY JOIN` - در این مورد, بند خالی در نتیجه شامل نمی شود `JOIN`. -- `LEFT ARRAY JOIN` - نتیجه `JOIN` شامل ردیف با ارریس خالی است. مقدار برای یک مجموعه خالی است به مقدار پیش فرض برای نوع عنصر مجموعه (معمولا 0, رشته خالی و یا تهی). - -نمونه های زیر نشان می دهد استفاده از `ARRAY JOIN` و `LEFT ARRAY JOIN` بند. بیایید یک جدول با یک [& حذف](../../sql_reference/data_types/array.md) ستون را تایپ کنید و مقادیر را وارد کنید: - -``` sql -CREATE TABLE arrays_test -( - s String, - arr Array(UInt8) -) ENGINE = Memory; - -INSERT INTO arrays_test -VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []); -``` - -``` text -┌─s───────────┬─arr─────┐ -│ Hello │ [1,2] │ -│ World │ [3,4,5] │ -│ Goodbye │ [] │ -└─────────────┴─────────┘ -``` - -مثال زیر از `ARRAY JOIN` بند: - -``` sql -SELECT s, arr -FROM arrays_test -ARRAY JOIN arr; -``` - -``` text -┌─s─────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -└───────┴─────┘ -``` - -مثال بعدی با استفاده از `LEFT ARRAY JOIN` بند: - -``` sql -SELECT s, arr -FROM arrays_test -LEFT ARRAY JOIN arr; -``` - -``` text -┌─s───────────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -│ Goodbye │ 0 │ -└─────────────┴─────┘ -``` - -#### استفاده از نام مستعار {#using-aliases} - -یک نام مستعار می تواند برای مجموعه ای در `ARRAY JOIN` بند بند. در این مورد, یک مورد مجموعه ای را می توان با این نام مستعار دیده, اما مجموعه خود را با نام اصلی قابل دسترسی. مثال: - -``` sql -SELECT s, arr, a -FROM arrays_test -ARRAY JOIN arr AS a; -``` - -``` text -┌─s─────┬─arr─────┬─a─┐ -│ Hello │ [1,2] │ 1 │ -│ Hello │ [1,2] │ 2 │ -│ World │ [3,4,5] │ 3 │ -│ World │ [3,4,5] │ 4 │ -│ World │ [3,4,5] │ 5 │ -└───────┴─────────┴───┘ -``` - -با استفاده از نام مستعار, شما می توانید انجام `ARRAY JOIN` با یک مجموعه خارجی. به عنوان مثال: - -``` sql -SELECT s, arr_external -FROM arrays_test -ARRAY JOIN [1, 2, 3] AS arr_external; -``` - -``` text -┌─s───────────┬─arr_external─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ Hello │ 3 │ -│ World │ 1 │ -│ World │ 2 │ -│ World │ 3 │ -│ Goodbye │ 1 │ -│ Goodbye │ 2 │ -│ Goodbye │ 3 │ -└─────────────┴──────────────┘ -``` - -ارریس های متعدد را می توان با کاما از هم جدا در `ARRAY JOIN` بند بند. در این مورد, `JOIN` به طور همزمان (مجموع مستقیم و نه محصول دکارتی) انجام می شود. توجه داشته باشید که تمام ارریس باید به همان اندازه. مثال: - -``` sql -SELECT s, arr, a, num, mapped -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ -│ Hello │ [1,2] │ 1 │ 1 │ 2 │ -│ Hello │ [1,2] │ 2 │ 2 │ 3 │ -│ World │ [3,4,5] │ 3 │ 1 │ 4 │ -│ World │ [3,4,5] │ 4 │ 2 │ 5 │ -│ World │ [3,4,5] │ 5 │ 3 │ 6 │ -└───────┴─────────┴───┴─────┴────────┘ -``` - -مثال زیر از [شناسه بسته:](../../sql_reference/functions/array_functions.md#array_functions-arrayenumerate) تابع: - -``` sql -SELECT s, arr, a, num, arrayEnumerate(arr) -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ -│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ -│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ -│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ -│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ -│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ -└───────┴─────────┴───┴─────┴─────────────────────┘ -``` - -#### مجموعه پیوستن با ساختار داده های تو در تو {#array-join-with-nested-data-structure} - -`ARRAY`پیوستن " همچنین با این نسخهها کار [ساختارهای داده تو در تو](../../sql_reference/data_types/nested_data_structures/nested.md). مثال: - -``` sql -CREATE TABLE nested_test -( - s String, - nest Nested( - x UInt8, - y UInt32) -) ENGINE = Memory; - -INSERT INTO nested_test -VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []); -``` - -``` text -┌─s───────┬─nest.x──┬─nest.y─────┐ -│ Hello │ [1,2] │ [10,20] │ -│ World │ [3,4,5] │ [30,40,50] │ -│ Goodbye │ [] │ [] │ -└─────────┴─────────┴────────────┘ -``` - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -هنگام مشخص کردن نام ساختارهای داده های تو در تو در `ARRAY JOIN`, معنای همان است که `ARRAY JOIN` با تمام عناصر مجموعه ای که شامل. نمونه به شرح زیر است: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`, `nest.y`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -این تنوع نیز حس می کند: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─────┐ -│ Hello │ 1 │ [10,20] │ -│ Hello │ 2 │ [10,20] │ -│ World │ 3 │ [30,40,50] │ -│ World │ 4 │ [30,40,50] │ -│ World │ 5 │ [30,40,50] │ -└───────┴────────┴────────────┘ -``` - -نام مستعار ممکن است برای یک ساختار داده های تو در تو استفاده می شود, به منظور انتخاب هر دو `JOIN` نتیجه یا مجموعه منبع. مثال: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest AS n; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ -└───────┴─────┴─────┴─────────┴────────────┘ -``` - -نمونه ای از استفاده از [شناسه بسته:](../../sql_reference/functions/array_functions.md#array_functions-arrayenumerate) تابع: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num -FROM nested_test -ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ -└───────┴─────┴─────┴─────────┴────────────┴─────┘ -``` - -### پیوستن بند {#select-join} - -می پیوندد داده ها در عادی [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) با عقل. - -!!! info "یادداشت" - نه مربوط به [ARRAY JOIN](#select-array-join-clause). - -``` sql -SELECT -FROM -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN -(ON )|(USING ) ... -``` - -نام جدول را می توان به جای مشخص `` و ``. این معادل است `SELECT * FROM table` خرده فروشی, به جز در یک مورد خاص زمانی که جدول است [پیوستن](../../engines/table_engines/special/join.md) engine – an array prepared for joining. - -#### انواع پشتیبانی شده از `JOIN` {#select-join-types} - -- `INNER JOIN` (یا `JOIN`) -- `LEFT JOIN` (یا `LEFT OUTER JOIN`) -- `RIGHT JOIN` (یا `RIGHT OUTER JOIN`) -- `FULL JOIN` (یا `FULL OUTER JOIN`) -- `CROSS JOIN` (یا `,` ) - -مشاهده استاندارد [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) توصیف. - -#### چند پیوستن {#multiple-join} - -انجام نمایش داده شد, بازنویسی کلیک خانه چند جدول می پیوندد به دنباله ای از دو جدول می پیوندد. مثلا, اگر چهار جدول برای عضویت کلیک خانه می پیوندد اول و دوم وجود دارد, سپس نتیجه می پیوندد با جدول سوم, و در مرحله گذشته, می پیوندد یک چهارم. - -اگر پرس و جو شامل `WHERE` بند ClickHouse تلاش می کند به pushdown فیلتر از این بند از طریق متوسط پیوستن به. اگر می تواند فیلتر به هر ملحق متوسط اعمال می شود, تاتر اعمال فیلتر بعد از همه می پیوندد به پایان رسید. - -ما توصیه می کنیم `JOIN ON` یا `JOIN USING` نحو برای ایجاد نمایش داده شد. به عنوان مثال: - -``` sql -SELECT * FROM t1 JOIN t2 ON t1.a = t2.a JOIN t3 ON t1.a = t3.a -``` - -شما می توانید لیست کاما از هم جدا از جداول در استفاده از `FROM` بند بند. به عنوان مثال: - -``` sql -SELECT * FROM t1, t2, t3 WHERE t1.a = t2.a AND t1.a = t3.a -``` - -این سینتکس را مخلوط نکنید. - -کلیکهاوس مستقیما از دستورات ارتباطی با کاما پشتیبانی نمی کند بنابراین توصیه نمی کنیم از انها استفاده کنید. الگوریتم تلاش می کند به بازنویسی پرس و جو از نظر `CROSS JOIN` و `INNER JOIN` بند و سپس به پرس و جو پردازش. هنگامی که بازنویسی پرس و جو, تاتر تلاش می کند برای بهینه سازی عملکرد و مصرف حافظه. به طور پیش فرض, تاتر رفتار کاما به عنوان یک `INNER JOIN` بند و تبدیل `INNER JOIN` به `CROSS JOIN` هنگامی که الگوریتم نمی تواند تضمین کند که `INNER JOIN` بازگرداندن اطلاعات مورد نیاز. - -#### سختی {#select-join-strictness} - -- `ALL` — If the right table has several matching rows, ClickHouse creates a [محصول دکارتی](https://en.wikipedia.org/wiki/Cartesian_product) از تطبیق ردیف. این استاندارد است `JOIN` رفتار در گذاشتن. -- `ANY` — If the right table has several matching rows, only the first one found is joined. If the right table has only one matching row, the results of queries with `ANY` و `ALL` کلمات کلیدی یکسان هستند. -- `ASOF` — For joining sequences with a non-exact match. `ASOF JOIN` استفاده در زیر توضیح داده شده است. - -**از این رو پیوستن به استفاده** - -`ASOF JOIN` مفید است زمانی که شما نیاز به پیوستن به سوابق که هیچ بازی دقیق. - -جداول برای `ASOF JOIN` باید یک ستون توالی دستور داده اند. این ستون نمی تواند به تنهایی در یک جدول باشد و باید یکی از انواع داده ها باشد: `UInt32`, `UInt64`, `Float32`, `Float64`, `Date` و `DateTime`. - -نحو `ASOF JOIN ... ON`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF LEFT JOIN table_2 -ON equi_cond AND closest_match_cond -``` - -شما می توانید هر تعداد از شرایط برابری و دقیقا یکی از نزدیک ترین شرایط بازی استفاده کنید. به عنوان مثال, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`. - -شرایط پشتیبانی شده برای نزدیک ترین بازی: `>`, `>=`, `<`, `<=`. - -نحو `ASOF JOIN ... USING`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF JOIN table_2 -USING (equi_column1, ... equi_columnN, asof_column) -``` - -`ASOF JOIN` استفاده `equi_columnX` برای پیوستن به برابری و `asof_column` برای پیوستن به نزدیک ترین مسابقه با `table_1.asof_column >= table_2.asof_column` شرط. این `asof_column` ستون همیشه یکی از گذشته در `USING` بند بند. - -مثلا, جداول زیر را در نظر بگیرید: - -"'متن -table\_1 table\_2 - -رویداد \| عصر / رویداد فراسوی / عصر / شناسه diff --git a/docs/fa/sql_reference/statements/show.md b/docs/fa/sql_reference/statements/show.md deleted file mode 100644 index 19b6fa5b622..00000000000 --- a/docs/fa/sql_reference/statements/show.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: SHOW ---- - -# نمایش & پرسوجو {#show-queries} - -## SHOW CREATE TABLE {#show-create-table} - -``` sql -SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -بازگرداندن یک `String`- نوع ‘statement’ column, which contains a single value – the `CREATE` پرس و جو مورد استفاده برای ایجاد شی مشخص شده است. - -## SHOW DATABASES {#show-databases} - -``` sql -SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] -``` - -چاپ یک لیست از تمام پایگاه های داده. -این پرس و جو یکسان است `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. - -## SHOW PROCESSLIST {#show-processlist} - -``` sql -SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] -``` - -خروجی محتوای [سیستم.فرایندها](../../operations/system_tables.md#system_tables-processes) جدول, که شامل یک لیست از نمایش داده شد که در حال حاضر پردازش, به استثنای `SHOW PROCESSLIST` نمایش داده شد. - -این `SELECT * FROM system.processes` پرس و جو داده ها در مورد تمام نمایش داده شد در حال حاضر را برمی گرداند. - -نکته (اجرا در کنسول): - -``` bash -$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" -``` - -## SHOW TABLES {#show-tables} - -نمایش یک لیست از جداول. - -``` sql -SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -اگر `FROM` بند مشخص نشده است, پرس و جو لیستی از جداول گرداند از پایگاه داده فعلی. - -شما می توانید نتایج مشابه را دریافت کنید `SHOW TABLES` پرسوجو به روش زیر: - -``` sql -SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**مثال** - -پرس و جو زیر انتخاب دو ردیف اول از لیست جداول در `system` پایگاه داده, که نام حاوی `co`. - -``` sql -SHOW TABLES FROM system LIKE '%co%' LIMIT 2 -``` - -``` text -┌─name───────────────────────────┐ -│ aggregate_function_combinators │ -│ collations │ -└────────────────────────────────┘ -``` - -## SHOW DICTIONARIES {#show-dictionaries} - -نمایش یک لیست از [واژهنامهها خارجی](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -``` sql -SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -اگر `FROM` بند مشخص نشده است, پرس و جو لیستی از لغت نامه ها را برمی گرداند از پایگاه داده در حال حاضر. - -شما می توانید نتایج مشابه را دریافت کنید `SHOW DICTIONARIES` پرسوجو به روش زیر: - -``` sql -SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**مثال** - -پرس و جو زیر انتخاب دو ردیف اول از لیست جداول در `system` پایگاه داده, که نام حاوی `reg`. - -``` sql -SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 -``` - -``` text -┌─name─────────┐ -│ regions │ -│ region_names │ -└──────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/fa/sql_reference/statements/system.md b/docs/fa/sql_reference/statements/system.md deleted file mode 100644 index 6dfedc03cc1..00000000000 --- a/docs/fa/sql_reference/statements/system.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: SYSTEM ---- - -# نمایش داده شد سیستم {#query-language-system} - -- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) -- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) -- [DROP DNS CACHE](#query_language-system-drop-dns-cache) -- [DROP MARK CACHE](#query_language-system-drop-mark-cache) -- [FLUSH LOGS](#query_language-system-flush_logs) -- [RELOAD CONFIG](#query_language-system-reload-config) -- [SHUTDOWN](#query_language-system-shutdown) -- [KILL](#query_language-system-kill) -- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) -- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) -- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) -- [STOP MERGES](#query_language-system-stop-merges) -- [START MERGES](#query_language-system-start-merges) - -## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} - -بارگذاری مجدد تمام لغت نامه که با موفقیت قبل از لود شده است. -به طور پیش فرض, لغت نامه ها به صورت تنبلی لود (دیدن [\_بارگیری کامل](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load)), بنابراین به جای اینکه به طور خودکار در هنگام راه اندازی لود, در اولین دسترسی از طریق تابع دیکته مقداردهی اولیه و یا از جداول با موتور = فرهنگ لغت را انتخاب کنید. این `SYSTEM RELOAD DICTIONARIES` پرس و جو بارگذاری مجدد از جمله لغت نامه (لود شده). -همیشه باز می گردد `Ok.` صرف نظر از نتیجه به روز رسانی فرهنگ لغت. - -## بازخوانی لغتنامهها {#query_language-system-reload-dictionary} - -به طور کامل یک فرهنگ لغت را دوباره بارگذاری کنید `dictionary_name` بدون در نظر گرفتن دولت از فرهنگ لغت (لود / NOT\_LOADED / شکست خورده). -همیشه باز می گردد `Ok.` صرف نظر از نتیجه به روز رسانی فرهنگ لغت. -وضعیت فرهنگ لغت را می توان با پرس و جو بررسی کرد `system.dictionaries` جدول - -``` sql -SELECT name, status FROM system.dictionaries; -``` - -## DROP DNS CACHE {#query_language-system-drop-dns-cache} - -کش دی ان اس داخلی بازنشانی را کلیک کنید. گاهی اوقات (برای clickhouse نسخه) لازم است برای استفاده از این دستور هنگامی که در حال تغییر زیرساخت ها (تغییر آدرس ip دیگر clickhouse سرور یا سرور استفاده شده توسط لغت نامه). - -برای راحت تر (اتوماتیک) مدیریت کش دیدن disable\_internal\_dns\_cache, dns\_cache\_update\_period پارامترهای. - -## DROP MARK CACHE {#query_language-system-drop-mark-cache} - -بازنشانی کش علامت. مورد استفاده در توسعه تست های کلیک و عملکرد. - -## FLUSH LOGS {#query_language-system-flush_logs} - -Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. - -## RELOAD CONFIG {#query_language-system-reload-config} - -بارگذاری مجدد پیکربندی محل کلیک. استفاده می شود که پیکربندی در باغ وحش ذخیره می شود. - -## SHUTDOWN {#query_language-system-shutdown} - -به طور معمول خاموش کردن کلیک (مانند `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) - -## KILL {#query_language-system-kill} - -سقط فرایند کلیک (مانند `kill -9 {$ pid_clickhouse-server}`) - -## مدیریت جداول توزیع شده {#query-language-system-distributed} - -کلیک خانه می تواند مدیریت کند [توزیع شده](../../engines/table_engines/special/distributed.md) میز هنگامی که یک کاربر درج داده ها را به این جداول, خانه رعیتی برای اولین بار ایجاد یک صف از داده ها است که باید به گره های خوشه ای ارسال, سپس ناهمگام می فرستد. شما می توانید پردازش صف با مدیریت [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) و [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) نمایش داده شد. شما همچنین می توانید همزمان داده های توزیع شده را با `insert_distributed_sync` تنظیمات. - -### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} - -غیرفعال توزیع داده های پس زمینه در هنگام قرار دادن داده ها به جداول توزیع شده است. - -``` sql -SYSTEM STOP DISTRIBUTED SENDS [db.] -``` - -### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} - -نیروهای خانه را کلیک کنید برای ارسال داده ها به گره های خوشه همزمان. اگر هر گره در دسترس نیست, تاتر می اندازد یک استثنا و متوقف می شود اجرای پرس و جو. شما می توانید پرس و جو را دوباره امتحان کنید تا زمانی که موفق, که اتفاق خواهد افتاد زمانی که تمام گره ها در حال بازگشت. - -``` sql -SYSTEM FLUSH DISTRIBUTED [db.] -``` - -### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} - -توزیع داده های پس زمینه را هنگام قرار دادن داده ها به جداول توزیع می کند. - -``` sql -SYSTEM START DISTRIBUTED SENDS [db.] -``` - -### STOP MERGES {#query_language-system-stop-merges} - -فراهم می کند امکان متوقف ادغام پس زمینه برای جداول در خانواده ادغام: - -``` sql -SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] -``` - -!!! note "یادداشت" - `DETACH / ATTACH` جدول پس زمینه ادغام برای جدول شروع خواهد شد حتی در صورتی که ادغام برای تمام جداول ادغام قبل از متوقف شده است. - -### START MERGES {#query_language-system-start-merges} - -فراهم می کند امکان شروع پس زمینه ادغام برای جداول در خانواده ادغام: - -``` sql -SYSTEM START MERGES [[db.]merge_tree_family_table_name] -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/fa/sql_reference/syntax.md b/docs/fa/sql_reference/syntax.md deleted file mode 100644 index 250b6c6aa5f..00000000000 --- a/docs/fa/sql_reference/syntax.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 31 -toc_title: "\u0646\u062D\u0648" ---- - -# نحو {#syntax} - -دو نوع تجزیه کننده در سیستم وجود دارد: تجزیه کننده کامل مربع (تجزیه کننده نزول بازگشتی) و تجزیه کننده فرمت داده (تجزیه کننده جریان سریع). -در تمام موارد به جز `INSERT` پرس و جو, تنها تجزیه کننده کامل گذاشتن استفاده شده است. -این `INSERT` پرس و جو از هر دو تجزیه کننده استفاده می کند: - -``` sql -INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') -``` - -این `INSERT INTO t VALUES` قطعه توسط تجزیه کننده کامل و داده ها تجزیه می شود `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` توسط تجزیه کننده جریان سریع تجزیه می شود. شما همچنین می توانید تجزیه کننده کامل برای داده ها با استفاده از [در حال خواندن:](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) تنظیمات. چه زمانی `input_format_values_interpret_expressions = 1` کلیک هاوس اول سعی می کند به تجزیه ارزش با تجزیه کننده جریان سریع. در صورت عدم موفقیت کلیک هاوس تلاش می کند تا از تجزیه کننده کامل برای داده ها استفاده کند و مانند یک مربع درمان شود [عبارت](#syntax-expressions). - -داده ها می توانند هر فرمت داشته باشند. هنگامی که یک پرس و جو را دریافت کرده است, سرور محاسبه بیش از [بیشینه\_کرکی\_سیز](../operations/settings/settings.md#settings-max_query_size) بایت از درخواست در رم (به طور پیش فرض, 1 مگابایت), و بقیه جریان تجزیه. -این به این معنی است که سیستم با مشکلات بزرگ ندارد `INSERT` نمایش داده شد, مانند خروجی زیر می کند. - -هنگام استفاده از `Values` قالب در یک `INSERT` پرس و جو, ممکن است به نظر می رسد که داده ها همان عبارات در تجزیه `SELECT` پرس و جو, اما این درست نیست. این `Values` فرمت بسیار محدود تر است. - -بعد ما تجزیه کننده کامل را پوشش خواهیم داد. برای کسب اطلاعات بیشتر در مورد تجزیه کننده فرمت, دیدن [فرشها](../interfaces/formats.md) بخش. - -## فاصلهها {#spaces} - -ممکن است هر تعداد از نمادهای فضایی بین سازه های نحوی (از جمله شروع و پایان پرس و جو) وجود دارد. علامت فضا شامل فضا, باریکه, خوراک خط, کروم, و خوراک فرم. - -## توضیحات {#comments} - -گذاشتن به سبک و ج سبک نظرات پشتیبانی می شوند. -گذاشتن به سبک نظرات: از `--` به انتهای خط فضای پس از `--` می توان حذف. -نظرات در ج سبک: از `/*` به `*/`. این نظرات می تواند چند خطی باشد. فضاهای اینجا مورد نیاز نیست, هم. - -## کلیدواژهها {#syntax-keywords} - -کلمات کلیدی حساس به حروف هستند که مربوط به: - -- استاندارد گذاشتن. به عنوان مثال, `SELECT`, `select` و `SeLeCt` همه معتبر هستند. -- پیاده سازی در برخی از پایگاه داده محبوب (خروجی زیر و یا پست). به عنوان مثال, `DateTime` همان است `datetime`. - -این که نام نوع داده حساس به حروف باشد را میتوان در `system.data_type_families` جدول - -در مقایسه با استاندارد گذاشتن تمام کلمات کلیدی دیگر (از جمله نام توابع) عبارتند از **حساس به حالت**. - -کلمات کلیدی محفوظ نیست (فقط به عنوان کلمات کلیدی در زمینه مربوطه تجزیه می شوند). در صورت استفاده [شناسهها](#syntax-identifiers) همان کلمات کلیدی را به نقل قول محصور. برای مثال پرس و جو `SELECT "FROM" FROM table_name` معتبر است اگر جدول `table_name` دارای ستون با نام `"FROM"`. - -## شناسهها {#syntax-identifiers} - -شناسه ها عبارتند از: - -- خوشه, پایگاه داده, جدول, پارتیشن و ستون نام. -- توابع. -- انواع داده ها. -- [نامگردانهای بیان](#syntax-expression_aliases). - -شناسه را می توان به نقل و یا غیر نقل. توصیه می شود از شناسه های غیر نقل قول استفاده کنید. - -شناسه های غیر نقل قول باید عبارت منظم مطابقت `^[a-zA-Z_][0-9a-zA-Z_]*$` و نمی تواند برابر باشد [کلیدواژهها](#syntax-keywords). مثالها: `x, _1, X_y__Z123_.` - -اگر شما می خواهید به استفاده از شناسه همان کلمات کلیدی و یا شما می خواهید به استفاده از نمادهای دیگر در شناسه, نقل قول با استفاده از دو نقل قول و یا پشت پرده, مثلا, `"id"`, `` `id` ``. - -## Literals {#literals} - -وجود دارد: عددی, رشته, ترکیب و `NULL` literals. - -### عددی {#numeric} - -تحت اللفظی عددی تلاش می کند به تجزیه شود: - -- برای اولین بار به عنوان یک شماره امضا 64 بیتی, با استفاده از [استرتول](https://en.cppreference.com/w/cpp/string/byte/strtoul) تابع. -- اگر ناموفق, به عنوان یک عدد بدون علامت 64 بیتی, با استفاده از [استرول](https://en.cppreference.com/w/cpp/string/byte/strtol) تابع. -- اگر ناموفق, به عنوان یک عدد شناور نقطه با استفاده از [رشته](https://en.cppreference.com/w/cpp/string/byte/strtof) تابع. -- در غیر این صورت, یک خطا بازگشته است. - -مقدار مربوطه کوچکترین نوع است که متناسب با ارزش داشته باشد. -مثلا, 1 به عنوان تجزیه `UInt8` اما 256 به عنوان تجزیه شده است `UInt16`. برای کسب اطلاعات بیشتر, دیدن [انواع داده ها](../sql_reference/data_types/index.md). - -مثالها: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. - -### رشته {#syntax-string-literal} - -فقط رشته های رشته ای در نقل قول های تک پشتیبانی می شوند. شخصیت های محصور می تواند بک اسلش فرار. توالی فرار زیر یک مقدار خاص مربوطه: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. در تمام موارد دیگر, فرار توالی در قالب `\c` کجا `c` است هر شخصیت, به تبدیل `c`. این به این معنی است که شما می توانید توالی استفاده کنید `\'`و`\\`. ارزش خواهد شد که [رشته](../sql_reference/data_types/string.md) نوع. - -حداقل مجموعه ای از شخصیت های که شما نیاز به فرار در لیتر رشته: `'` و `\`. نقل قول تنها را می توان با نقل قول تنها فرار, لیتر `'It\'s'` و `'It''s'` برابر هستند. - -### ترکیب {#compound} - -سازه ها برای ارریس پشتیبانی می شوند: `[1, 2, 3]` و تاپل: `(1, 'Hello, world!', 2)`.. -در واقع این نیست literals اما عبارات با آرایه ایجاد اپراتور و چند تایی ایجاد اپراتور بود. -مجموعه ای باید شامل حداقل یک مورد باشد و یک تاپل باید حداقل دو مورد داشته باشد. -تاپل یک هدف خاص برای استفاده در `IN` بند یک `SELECT` پرس و جو. توپلس می تواند به عنوان نتیجه یک پرس و جو به دست, اما نمی توان به یک پایگاه داده ذخیره (به غیر از [حافظه](../engines/table_engines/special/memory.md) جدول). - -### NULL {#null-literal} - -نشان می دهد که ارزش از دست رفته است. - -به منظور ذخیره `NULL` در یک میدان جدول باید از [Nullable](../sql_reference/data_types/nullable.md) نوع. - -بسته به فرمت داده (ورودی یا خروجی), `NULL` ممکن است نمایندگی های مختلف. برای کسب اطلاعات بیشتر, اسناد و مدارک برای دیدن [قالبهای داده](../interfaces/formats.md#formats). - -بسیاری از تفاوت های ظریف برای پردازش وجود دارد `NULL`. مثلا, اگر حداقل یکی از استدلال از یک عملیات مقایسه است `NULL` نتیجه این عملیات نیز خواهد بود `NULL`. همان درست است برای ضرب است, بعلاوه, و عملیات دیگر. برای کسب اطلاعات بیشتر, خواندن اسناد و مدارک برای هر عملیات. - -در نمایش داده شد, شما می توانید بررسی کنید `NULL` با استفاده از [IS NULL](operators.md#operator-is-null) و [IS NOT NULL](operators.md) اپراتورها و توابع مرتبط `isNull` و `isNotNull`. - -## توابع {#functions} - -توابع مانند یک شناسه با یک لیست از استدلال نوشته شده (احتمالا خالی) در داخل پرانتز. در مقابل به گذاشتن استاندارد, براکت مورد نیاز است, حتی برای یک لیست استدلال خالی. مثال: `now()`. -توابع منظم و جمع وجود دارد (بخش را ببینید “Aggregate functions”). برخی از توابع دانه می تواند شامل دو لیست از استدلال در براکت. مثال: `quantile (0.9) (x)`. این توابع مجموع نامیده می شوند “parametric” توابع, و استدلال در لیست اول نامیده می شوند “parameters”. نحو توابع کل بدون پارامتر همان است که برای توابع به طور منظم است. - -## اپراتورها {#operators} - -اپراتورها در حال تبدیل به توابع مربوط به خود را طی پرس و جو و تجزیه گرفتن اولویت خود را و associativity به حساب آورد. -برای مثال بیان `1 + 2 * 3 + 4` تبدیل به `plus(plus(1, multiply(2, 3)), 4)`. - -## انواع داده ها و موتورهای جدول پایگاه داده {#data_types-and-database-table-engines} - -انواع داده ها و موتورهای جدول در `CREATE` پرس و جو به همان شیوه به عنوان شناسه و یا توابع نوشته شده است. به عبارت دیگر, ممکن است یا ممکن است حاوی یک لیست استدلال در براکت نیست. برای کسب اطلاعات بیشتر به بخش ها مراجعه کنید “Data types,” “Table engines,” و “CREATE”. - -## نامگردانهای بیان {#syntax-expression_aliases} - -نام مستعار یک نام تعریف شده توسط کاربر برای بیان در پرس و جو است. - -``` sql -expr AS alias -``` - -- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` بند بدون استفاده از `AS` کلمه کلیدی. - - For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. - - In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. - -- `expr` — Any expression supported by ClickHouse. - - For example, `SELECT column_name * 2 AS double FROM some_table`. - -- `alias` — Name for `expr`. نام مستعار باید با پیروی از [شناسهها](#syntax-identifiers) نحو. - - For example, `SELECT "table t".column_name FROM table_name AS "table t"`. - -### نکاتی در مورد استفاده {#notes-on-usage} - -نام مستعار جهانی برای یک پرس و جو و یا زیرخاکی هستند و شما می توانید یک نام مستعار در هر بخشی از یک پرس و جو برای هر بیان تعریف. به عنوان مثال, `SELECT (1 AS n) + 2, n`. - -نام مستعار قابل مشاهده نیست در subqueries و بین subqueries. مثلا, در حالی که اجرای پرس و جو `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` تاتر استثنا را تولید می کند `Unknown identifier: num`. - -اگر یک نام مستعار برای ستون نتیجه در تعریف `SELECT` بند یک خرده فروشی, این ستون ها در پرس و جو بیرونی قابل مشاهده هستند. به عنوان مثال, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. - -مراقب باشید با نام مستعار است که همان نام ستون یا جدول می باشد. بیایید مثال زیر را در نظر بگیریم: - -``` sql -CREATE TABLE t -( - a Int, - b Int -) -ENGINE = TinyLog() -``` - -``` sql -SELECT - argMax(a, b), - sum(b) AS b -FROM t -``` - -``` text -Received exception from server (version 18.14.17): -Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. -``` - -در این مثال ما اعلام جدول `t` با ستون `b`. سپس, در هنگام انتخاب داده, ما تعریف `sum(b) AS b` نام مستعار. به عنوان نام مستعار جهانی هستند, خانه را جایگزین تحت اللفظی `b` در عبارت `argMax(a, b)` با بیان `sum(b)`. این جایگزینی باعث استثنا. - -## ستاره {#asterisk} - -در یک `SELECT` پرس و جو, ستاره می تواند عبارت جایگزین. برای کسب اطلاعات بیشتر به بخش مراجعه کنید “SELECT”. - -## عبارتها {#syntax-expressions} - -بیان یک تابع است, شناسه, تحت اللفظی, استفاده از یک اپراتور, بیان در داخل پرانتز, خرده فروشی, یا ستاره. همچنین می تواند شامل یک نام مستعار. -لیستی از عبارات یک یا چند عبارت از هم جدا شده توسط کاما است. -توابع و اپراتورهای, به نوبه خود, می توانید عبارات به عنوان استدلال دارند. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/syntax/) diff --git a/docs/fa/sql_reference/table_functions/file.md b/docs/fa/sql_reference/table_functions/file.md deleted file mode 100644 index 62e49c8cd80..00000000000 --- a/docs/fa/sql_reference/table_functions/file.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u067E\u0631\u0648\u0646\u062F\u0647" ---- - -# پرونده {#file} - -ایجاد یک جدول از یک فایل. این تابع جدول شبیه به [نشانی وب](url.md) و [hdfs](hdfs.md) یکی - -``` sql -file(path, format, structure) -``` - -**پارامترهای ورودی** - -- `path` — The relative path to the file from [\_مخفی کردن \_صفحه](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-user_files_path). مسیر به فایل پشتیبانی پس از دل تنگی در حالت فقط خواندنی: `*`, `?`, `{abc,def}` و `{N..M}` کجا `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [قالب](../../interfaces/formats.md#formats) پرونده -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**مقدار بازگشتی** - -یک جدول با ساختار مشخص شده برای خواندن یا نوشتن داده ها در فایل مشخص شده است. - -**مثال** - -تنظیم `user_files_path` و محتویات فایل `test.csv`: - -``` bash -$ grep user_files_path /etc/clickhouse-server/config.xml - /var/lib/clickhouse/user_files/ - -$ cat /var/lib/clickhouse/user_files/test.csv - 1,2,3 - 3,2,1 - 78,43,45 -``` - -جدول از`test.csv` و انتخاب دو ردیف اول: - -``` sql -SELECT * -FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -``` sql --- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file -SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 -``` - -**دل تنگی در مسیر** - -اجزای مسیر چندگانه می تواند دل تنگی دارند. برای پردازش فایل باید وجود داشته باشد و مسابقات به الگوی کل مسیر (نه تنها پسوند یا پیشوند). - -- `*` — Substitutes any number of any characters except `/` از جمله رشته خالی. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -سازه با `{}` شبیه به [عملکرد جدول از راه دور](../../sql_reference/table_functions/remote.md)). - -**مثال** - -1. فرض کنید ما چندین فایل با مسیرهای نسبی زیر داریم: - -- ‘some\_dir/some\_file\_1’ -- ‘some\_dir/some\_file\_2’ -- ‘some\_dir/some\_file\_3’ -- ‘another\_dir/some\_file\_1’ -- ‘another\_dir/some\_file\_2’ -- ‘another\_dir/some\_file\_3’ - -1. پرس و جو مقدار ردیف در این فایل ها: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. پرس و جو مقدار ردیف در تمام فایل های این دو دایرکتوری: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "اخطار" - اگر لیست خود را از فایل های حاوی محدوده تعداد با صفر پیشرو, استفاده از ساخت و ساز با پرانتز برای هر رقم به طور جداگانه و یا استفاده `?`. - -**مثال** - -پرس و جو داده ها از فایل های به نام `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## ستونهای مجازی {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**همچنین نگاه کنید به** - -- [مجازی ستون](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/fa/sql_reference/table_functions/generate.md b/docs/fa/sql_reference/table_functions/generate.md deleted file mode 100644 index 0236d99cf57..00000000000 --- a/docs/fa/sql_reference/table_functions/generate.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 47 -toc_title: "\u0698\u0646\u0631\u0627\u0644" ---- - -# ژنرال {#generaterandom} - -تولید داده های تصادفی با طرح داده شده است. -اجازه می دهد تا به جمعیت جداول تست با داده ها. -پشتیبانی از تمام انواع داده است که می تواند در جدول به جز ذخیره می شود `LowCardinality` و `AggregateFunction`. - -``` sql -generateRandom('name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_string_length'[, 'max_array_length']]]); -``` - -**پارامترها** - -- `name` — Name of corresponding column. -- `TypeName` — Type of corresponding column. -- `limit` — Number of rows to generate. -- `max_array_length` — Maximum array length for all generated arrays. Defaults to `10`. -- `max_string_length` — Maximum string length for all generated strings. Defaults to `10`. -- `random_seed` — Specify random seed manually to produce stable results. If NULL — seed is randomly generated. - -**مقدار بازگشتی** - -یک شی جدول با طرح درخواست. - -## مثال طریقه استفاده {#usage-example} - -``` sql -SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2); -``` - -``` text -┌─a────────┬────────────d─┬─c──────────────────────────────────────────────────────────────────┐ -│ [77] │ -124167.6723 │ ('2061-04-17 21:59:44.573','3f72f405-ec3e-13c8-44ca-66ef335f7835') │ -│ [32,110] │ -141397.7312 │ ('1979-02-09 03:43:48.526','982486d1-5a5d-a308-e525-7bd8b80ffa73') │ -│ [68] │ -67417.0770 │ ('2080-03-12 14:17:31.269','110425e5-413f-10a6-05ba-fa6b3e929f15') │ -└──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘ -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/generate/) diff --git a/docs/fa/sql_reference/table_functions/hdfs.md b/docs/fa/sql_reference/table_functions/hdfs.md deleted file mode 100644 index 44e9c1d627b..00000000000 --- a/docs/fa/sql_reference/table_functions/hdfs.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: hdfs ---- - -# hdfs {#hdfs} - -ایجاد یک جدول از فایل ها در اچ دی. این جدول عملکرد شبیه به [نشانی وب](url.md) و [پرونده](file.md) یکی - -``` sql -hdfs(URI, format, structure) -``` - -**پارامترهای ورودی** - -- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` و `{N..M}` کجا `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [قالب](../../interfaces/formats.md#formats) پرونده -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**مقدار بازگشتی** - -یک جدول با ساختار مشخص شده برای خواندن یا نوشتن داده ها در فایل مشخص شده است. - -**مثال** - -جدول از `hdfs://hdfs1:9000/test` و انتخاب دو ردیف اول: - -``` sql -SELECT * -FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -**دل تنگی در مسیر** - -اجزای مسیر چندگانه می تواند دل تنگی دارند. برای پردازش فایل باید وجود داشته باشد و مسابقات به الگوی کل مسیر (نه تنها پسوند یا پیشوند). - -- `*` — Substitutes any number of any characters except `/` از جمله رشته خالی. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -سازه با `{}` شبیه به [عملکرد جدول از راه دور](../../sql_reference/table_functions/remote.md)). - -**مثال** - -1. فرض کنید که ما چندین فایل با اوریس زیر در اچ دی ها داریم: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. پرس و جو مقدار ردیف در این فایل ها: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. پرس و جو مقدار ردیف در تمام فایل های این دو دایرکتوری: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "اخطار" - اگر لیست خود را از فایل های حاوی محدوده تعداد با صفر پیشرو, استفاده از ساخت و ساز با پرانتز برای هر رقم به طور جداگانه و یا استفاده `?`. - -**مثال** - -پرس و جو داده ها از فایل های به نام `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## ستونهای مجازی {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**همچنین نگاه کنید به** - -- [ستونهای مجازی](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/fa/sql_reference/table_functions/index.md b/docs/fa/sql_reference/table_functions/index.md deleted file mode 100644 index 58143c6a5dd..00000000000 --- a/docs/fa/sql_reference/table_functions/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Table Functions -toc_priority: 34 -toc_title: "\u0645\u0639\u0631\u0641\u06CC \u0634\u0631\u06A9\u062A" ---- - -# توابع جدول {#table-functions} - -توابع جدول روش برای ساخت جداول. - -شما می توانید توابع جدول در استفاده: - -- [FROM](../statements/select.md#select-from) بند از `SELECT` پرس و جو. - - The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. - -- [ایجاد جدول به عنوان \](../statements/create.md#create-table-query) پرس و جو. - - It's one of the methods of creating a table. - -!!! warning "اخطار" - شما می توانید توابع جدول اگر استفاده نمی [اجازه دادن به \_نشانی](../../operations/settings/permissions_for_queries.md#settings_allow_ddl) تنظیم غیر فعال است. - -| تابع | توصیف | -|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------| -| [پرونده](file.md) | ایجاد یک [پرونده](../../engines/table_engines/special/file.md)- جدول موتور. | -| [ادغام](merge.md) | ایجاد یک [ادغام](../../engines/table_engines/special/merge.md)- جدول موتور. | -| [اعداد](numbers.md) | ایجاد یک جدول با یک ستون پر از اعداد صحیح. | -| [دور](remote.md) | اجازه می دهد تا شما را به دسترسی به سرور از راه دور بدون ایجاد یک [توزیع شده](../../engines/table_engines/special/distributed.md)- جدول موتور. | -| [نشانی وب](url.md) | ایجاد یک [نشانی وب](../../engines/table_engines/special/url.md)- جدول موتور. | -| [خروجی زیر](mysql.md) | ایجاد یک [MySQL](../../engines/table_engines/integrations/mysql.md)- جدول موتور. | -| [جستجو](jdbc.md) | ایجاد یک [JDBC](../../engines/table_engines/integrations/jdbc.md)- جدول موتور. | -| [جستجو](odbc.md) | ایجاد یک [ODBC](../../engines/table_engines/integrations/odbc.md)- جدول موتور. | -| [hdfs](hdfs.md) | ایجاد یک [HDFS](../../engines/table_engines/integrations/hdfs.md)- جدول موتور. | - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/fa/sql_reference/table_functions/input.md b/docs/fa/sql_reference/table_functions/input.md deleted file mode 100644 index 0ab23171f73..00000000000 --- a/docs/fa/sql_reference/table_functions/input.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 46 -toc_title: "\u0648\u0631\u0648\u062F\u06CC" ---- - -# ورودی {#input} - -`input(structure)` - تابع جدول که اجازه می دهد تا به طور موثر تبدیل و قرار دادن داده های ارسال شده به -سرور با ساختار داده شده به جدول با ساختار دیگر. - -`structure` - ساختار داده ها در قالب زیر به سرور ارسال می شود `'column1_name column1_type, column2_name column2_type, ...'`. -به عنوان مثال, `'id UInt32, name String'`. - -این تابع را می توان تنها در `INSERT SELECT` پرس و جو و تنها یک بار اما در غیر این صورت مانند تابع جدول معمولی رفتار می کنند -(مثلا, این را می توان در زیرخاکری مورد استفاده قرار, و غیره.). - -داده ها را می توان به هیچ وجه مانند عادی ارسال می شود `INSERT` پرس و جو و گذشت در هر موجود [قالب](../../interfaces/formats.md#formats) -که باید در پایان پرس و جو مشخص شود (بر خلاف عادی `INSERT SELECT`). - -ویژگی اصلی این تابع این است که وقتی سرور داده ها را از مشتری دریافت می کند به طور همزمان تبدیل می کند -با توجه به لیست عبارات در `SELECT` بند و درج به جدول هدف. جدول موقت -با تمام داده های منتقل شده ایجاد نمی شود. - -**مثالها** - -- اجازه دهید `test` جدول دارای ساختار زیر است `(a String, b String)` - و داده ها در `data.csv` دارای ساختار متفاوت `(col1 String, col2 Date, col3 Int32)`. پرسوجو برای درج - داده ها از `data.csv` به `test` جدول با تبدیل همزمان به نظر می رسد مثل این: - - - -``` bash -$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; -``` - -- اگر `data.csv` حاوی اطلاعات از ساختار مشابه `test_structure` به عنوان جدول `test` سپس این دو نمایش داده شد برابر هستند: - - - -``` bash -$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV" -$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV" -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/input/) diff --git a/docs/fa/sql_reference/table_functions/jdbc.md b/docs/fa/sql_reference/table_functions/jdbc.md deleted file mode 100644 index 766d90fa5f3..00000000000 --- a/docs/fa/sql_reference/table_functions/jdbc.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 ---- - -# جستجو {#table-function-jdbc} - -`jdbc(jdbc_connection_uri, schema, table)` - جدول بازده است که از طریق راننده جدی بی سی متصل. - -این تابع جدول نیاز به جداگانه دارد `clickhouse-jdbc-bridge` برنامه در حال اجرا است. -این پشتیبانی از انواع باطل (بر اساس دسیدال جدول از راه دور است که تردید). - -**مثالها** - -``` sql -SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') -``` - -``` sql -SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'schema', 'table') -``` - -``` sql -SELECT * FROM jdbc('datasource://mysql-local', 'schema', 'table') -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/fa/sql_reference/table_functions/merge.md b/docs/fa/sql_reference/table_functions/merge.md deleted file mode 100644 index 5e843f4e460..00000000000 --- a/docs/fa/sql_reference/table_functions/merge.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: "\u0627\u062F\u063A\u0627\u0645" ---- - -# ادغام {#merge} - -`merge(db_name, 'tables_regexp')` – Creates a temporary Merge table. For more information, see the section “Table engines, Merge”. - -ساختار جدول از جدول اول مواجه می شوند که منطبق بر عبارت منظم گرفته شده است. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/merge/) diff --git a/docs/fa/sql_reference/table_functions/mysql.md b/docs/fa/sql_reference/table_functions/mysql.md deleted file mode 100644 index 2c00529040c..00000000000 --- a/docs/fa/sql_reference/table_functions/mysql.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u062E\u0631\u0648\u062C\u06CC \u0632\u06CC\u0631" ---- - -# خروجی زیر {#mysql} - -اجازه می دهد `SELECT` نمایش داده شد به داده است که بر روی یک سرور خروجی از راه دور ذخیره می شود انجام می شود. - -``` sql -mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -**پارامترها** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` نمایش داده شد به `REPLACE INTO`. اگر `replace_query=1`, پرس و جو جایگزین شده است. - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` بیان است که به اضافه `INSERT` پرس و جو. - - Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. - - To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. - -ساده `WHERE` بند هایی مانند `=, !=, >, >=, <, <=` در حال حاضر بر روی سرور خروجی زیر اجرا شده است. - -بقیه شرایط و `LIMIT` محدودیت نمونه برداری در محل کلیک تنها پس از پرس و جو به پس از اتمام خروجی زیر اجرا شده است. - -**مقدار بازگشتی** - -یک شی جدول با ستون همان جدول خروجی زیر اصلی. - -## مثال طریقه استفاده {#usage-example} - -جدول در خروجی زیر: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -انتخاب داده ها از خانه کلیک: - -``` sql -SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## همچنین نگاه کنید به {#see-also} - -- [این ‘MySQL’ موتور جدول](../../engines/table_engines/integrations/mysql.md) -- [با استفاده از خروجی زیر به عنوان منبع فرهنگ لغت خارجی](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/fa/sql_reference/table_functions/numbers.md b/docs/fa/sql_reference/table_functions/numbers.md deleted file mode 100644 index 86a4829ef72..00000000000 --- a/docs/fa/sql_reference/table_functions/numbers.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u0627\u0639\u062F\u0627\u062F" ---- - -# اعداد {#numbers} - -`numbers(N)` – Returns a table with the single ‘number’ ستون (اوینت64)که شامل اعداد صحیح از 0 تا 1. -`numbers(N, M)` - بازگرداندن یک جدول با تک ‘number’ ستون (اوینت64) که شامل اعداد صحیح از نفر به (نفر + متر - 1). - -شبیه به `system.numbers` جدول را می توان برای تست و تولید مقادیر پی در پی استفاده کرد, `numbers(N, M)` کارایی بیشتر از `system.numbers`. - -نمایش داده شد زیر معادل هستند: - -``` sql -SELECT * FROM numbers(10); -SELECT * FROM numbers(0, 10); -SELECT * FROM system.numbers LIMIT 10; -``` - -مثالها: - -``` sql --- Generate a sequence of dates from 2010-01-01 to 2010-12-31 -select toDate('2010-01-01') + number as d FROM numbers(365); -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/numbers/) diff --git a/docs/fa/sql_reference/table_functions/odbc.md b/docs/fa/sql_reference/table_functions/odbc.md deleted file mode 100644 index 088d1b9bd02..00000000000 --- a/docs/fa/sql_reference/table_functions/odbc.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u062C\u0633\u062A\u062C\u0648" ---- - -# جستجو {#table-functions-odbc} - -بازگرداندن جدول است که از طریق متصل [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -``` sql -odbc(connection_settings, external_database, external_table) -``` - -پارامترها: - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` پرونده. -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -با خیال راحت پیاده سازی اتصالات ان بی سی, تاتر با استفاده از یک برنامه جداگانه `clickhouse-odbc-bridge`. اگر راننده او بی سی به طور مستقیم از لود `clickhouse-server`, مشکلات راننده می تواند سرور تاتر سقوط. تاتر به طور خودکار شروع می شود `clickhouse-odbc-bridge` هنگامی که مورد نیاز است. برنامه پل او بی سی از همان بسته به عنوان نصب `clickhouse-server`. - -زمینه های با `NULL` مقادیر از جدول خارجی به مقادیر پیش فرض برای نوع داده پایه تبدیل می شوند. مثلا, اگر یک میدان جدول خروجی زیر از راه دور است `INT NULL` نوع این است که به 0 تبدیل (مقدار پیش فرض برای کلیک `Int32` نوع داده). - -## مثال طریقه استفاده {#usage-example} - -**گرفتن اطلاعات از نصب و راه اندازی خروجی زیر محلی از طریق ان بی سی** - -این مثال برای لینوکس اوبونتو 18.04 و سرور خروجی زیر 5.7 بررسی می شود. - -اطمینان حاصل شود که unixodbc و mysql اتصال نصب شده است. - -به طور پیش فرض (در صورت نصب از بسته), کلیک خانه شروع می شود به عنوان کاربر `clickhouse`. بنابراین شما نیاز به ایجاد و پیکربندی این کاربر در سرور خروجی زیر. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -سپس اتصال را پیکربندی کنید `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -شما می توانید اتصال با استفاده از بررسی `isql` ابزار از unixODBC نصب و راه اندازی. - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -جدول در خروجی زیر: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -بازیابی اطلاعات از جدول خروجی زیر در کلیک: - -``` sql -SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ 0 │ 2 │ 0 │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## همچنین نگاه کنید به {#see-also} - -- [لغت نامه های خارجی ان بی سی](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [موتور جدول ان بی سی](../../engines/table_engines/integrations/odbc.md). - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/fa/sql_reference/table_functions/remote.md b/docs/fa/sql_reference/table_functions/remote.md deleted file mode 100644 index 8763779d9d4..00000000000 --- a/docs/fa/sql_reference/table_functions/remote.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "\u062F\u0648\u0631" ---- - -# از راه دور remoteSecure {#remote-remotesecure} - -اجازه می دهد تا شما را به دسترسی به سرور از راه دور بدون ایجاد یک `Distributed` جدول - -امضاها: - -``` sql -remote('addresses_expr', db, table[, 'user'[, 'password']]) -remote('addresses_expr', db.table[, 'user'[, 'password']]) -``` - -`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port` یا فقط `host`. میزبان را می توان به عنوان نام سرور مشخص, و یا به عنوان ایپو4 یا ایپو6 نشانی. نشانی اینترنتی6 در براکت مربع مشخص شده است. پورت پورت تی سی پی بر روی سرور از راه دور است. اگر پورت حذف شده است, با استفاده از `tcp_port` از فایل پیکربندی سرور (به طور پیش فرض, 9000). - -!!! important "مهم" - پورت برای یک نشانی اینترنتی6 مورد نیاز است. - -مثالها: - -``` text -example01-01-1 -example01-01-1:9000 -localhost -127.0.0.1 -[::]:9000 -[2a02:6b8:0:1111::11]:9000 -``` - -نشانی های متعدد را می توان با کاما از هم جدا شده است. در این مورد کلیک هاوس از پردازش توزیع شده استفاده می کند بنابراین پرس و جو را به تمام نشانیهای مشخص شده ارسال می کند (مانند داده های مختلف). - -مثال: - -``` text -example01-01-1,example01-02-1 -``` - -بخشی از بیان را می توان در براکت فرفری مشخص شده است. مثال قبلی را می توان به شرح زیر نوشته شده است: - -``` text -example01-0{1,2}-1 -``` - -براکت فرفری می تواند شامل طیف وسیعی از اعداد جدا شده توسط دو نقطه (اعداد صحیح غیر منفی). در این مورد, محدوده به مجموعه ای از ارزش هایی که تولید نشانی سفال گسترش. اگر عدد اول با صفر شروع می شود, ارزش ها با همان تراز صفر تشکیل. مثال قبلی را می توان به شرح زیر نوشته شده است: - -``` text -example01-{01..02}-1 -``` - -اگر شما جفت های متعدد از براکت در اشکال مختلف, این تولید محصول مستقیم از مجموعه مربوطه. - -نشانی ها و بخش هایی از نشانی در براکت فرفری را می توان با نماد لوله جدا (\|). در این مورد, مجموعه مربوطه را از نشانی ها به عنوان کپی تفسیر, و پرس و جو خواهد شد به اولین ماکت سالم ارسال. با این حال, کپی در نظم در حال حاضر در مجموعه تکرار [\_تبالسازی](../../operations/settings/settings.md) تنظیمات. - -مثال: - -``` text -example01-{01..02}-{1|2} -``` - -این مثال دو تکه که هر کدام دو کپی مشخص. - -تعدادی از آدرس های تولید شده محدود است توسط یک ثابت است. در حال حاضر این 1000 نشانی است. - -با استفاده از `remote` تابع جدول کمتر مطلوب تر از ایجاد یک است `Distributed` جدول, چرا که در این مورد, اتصال سرور دوباره تاسیس برای هر درخواست. علاوه بر این, اگر نام میزبان قرار است, نام حل و فصل, و خطا شمارش نیست در هنگام کار با کپی های مختلف. هنگامی که پردازش تعداد زیادی از نمایش داده شد, همیشه ایجاد `Distributed` جدول جلوتر از زمان, و استفاده نکنید `remote` تابع جدول. - -این `remote` تابع جدول می تواند در موارد زیر مفید باشد: - -- دسترسی به یک سرور خاص برای مقایسه داده ها, اشکال زدایی, و تست. -- نمایش داده شد بین خوشه های مختلف کلیک برای اهداف تحقیقاتی. -- درخواست توزیع نادر است که به صورت دستی ساخته شده. -- درخواست توزیع شده که مجموعه ای از سرورها در هر زمان دوباره تعریف شده است. - -اگر کاربر مشخص نشده است, `default` استفاده شده است. -اگر رمز عبور مشخص نشده است, رمز عبور خالی استفاده شده است. - -`remoteSecure` - مثل `remote` but with secured connection. Default port — [\_شروع مجدد](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) از پیکربندی و یا 9440. - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/fa/sql_reference/table_functions/url.md b/docs/fa/sql_reference/table_functions/url.md deleted file mode 100644 index 0b282bf6633..00000000000 --- a/docs/fa/sql_reference/table_functions/url.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: "\u0646\u0634\u0627\u0646\u06CC \u0648\u0628" ---- - -# نشانی وب {#url} - -`url(URL, format, structure)` - بازگرداندن یک جدول ایجاد شده از `URL` با توجه به -`format` و `structure`. - -نشانی وب-نشانی کارساز اچتیتیپ یا اچتیتیپس که میتواند بپذیرد `GET` و / یا `POST` درخواست. - -قالب - [قالب](../../interfaces/formats.md#formats) از داده ها. - -ساختار-ساختار جدول در `'UserID UInt64, Name String'` قالب. تعیین نام ستون و انواع. - -**مثال** - -``` sql --- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format. -SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3 -``` - -[مقاله اصلی](https://clickhouse.tech/docs/en/query_language/table_functions/url/) diff --git a/docs/fa/whats-new/changelog/2017.md b/docs/fa/whats-new/changelog/2017.md new file mode 100644 index 00000000000..939ed966c22 --- /dev/null +++ b/docs/fa/whats-new/changelog/2017.md @@ -0,0 +1,268 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 79 +toc_title: '2017' +--- + +### ClickHouse انتشار 1.1.54327, 2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} + +این نسخه شامل رفع اشکال برای نسخه قبلی 1.1.54318: + +- اشکال ثابت با شرایط مسابقه ممکن است در تکرار است که می تواند به از دست دادن داده ها منجر شود. این مسئله تاثیر می گذارد نسخه 1.1.54310 و 1.1.54318. اگر شما استفاده از یکی از این نسخه ها با جداول تکرار, به روز رسانی است که به شدت توصیه می شود. این موضوع نشان می دهد در سیاهههای مربوط در پیام های هشدار دهنده مانند `Part ... from own log doesn't exist.` موضوع مربوط است حتی اگر شما این پیام ها در سیاهههای مربوط را نمی بینم. + +### ClickHouse انتشار 1.1.54318, 2017-11-30 {#clickhouse-release-1-1-54318-2017-11-30} + +این نسخه شامل رفع اشکال برای نسخه های قبلی 1.1.54310: + +- حذف ردیف نادرست ثابت در هنگام ادغام در موتور جمعبندی +- رفع نشت حافظه در موتورهای ادغام سه گانه +- تخریب عملکرد ثابت با درج مکرر در موتورهای ادغام +- ثابت است که شماره بود که باعث صف تکرار برای جلوگیری از در حال اجرا +- چرخش ثابت و بایگانی سیاهههای مربوط به سرور + +### ClickHouse انتشار 1.1.54310, 2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} + +#### ویژگی های جدید: {#new-features} + +- کلید پارتیشن بندی سفارشی برای خانواده ادغام موتورهای جدول. +- [کافکا](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) موتور جدول. +- اضافه شدن پشتیبانی برای بارگذاری [مانتو](https://catboost.yandex/) مدل ها و استفاده از داده های ذخیره شده در کلیک. +- اضافه شدن پشتیبانی برای مناطق زمانی با شیپور خاموشی غیر عدد صحیح از مجموعه مقالات. +- اضافه شدن پشتیبانی برای عملیات ریاضی با فواصل زمانی. +- طیف وسیعی از ارزش ها برای انواع تاریخ و تاریخ ساعت به سال گسترش 2105. +- اضافه شدن `CREATE MATERIALIZED VIEW x TO y` پرس و جو (مشخص یک جدول موجود برای ذخیره سازی داده ها از یک نمایش محقق). +- اضافه شدن `ATTACH TABLE` پرس و جو بدون استدلال. +- پردازش منطق به صورت تو در تو ستون با نام پایان در نقشه در یک SummingMergeTree جدول استخراج شد به sumMap مجموع عملکرد. شما هم اکنون می توانید این ستون ها به صراحت مشخص کنید. +- حداکثر اندازه فرهنگ لغت ایپ تری به ورودی های 128 متری افزایش می یابد. +- اضافه شدن تابع نوع گیرنده. +- اضافه شده تابع جمع مجموع ورود. +- اضافه شدن پشتیبانی از فرمت ورودی ورودی سروان پروتو. +- شما هم اکنون می توانید سطح فشرده سازی سفارشی در هنگام استفاده از الگوریتم زد. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes} + +- ایجاد جداول موقت با موتور غیر از حافظه مجاز نیست. +- ایجاد صریح جداول با مشاهده و یا موتور نمای مادی مجاز نیست. +- در طول ایجاد جدول, یک بررسی جدید تایید می کند که عبارت کلیدی نمونه برداری در کلید اصلی شامل. + +#### رفع اشکال: {#bug-fixes} + +- قطع ثابت زمانی که همزمان به یک جدول توزیع قرار دادن. +- ثابت غیر اتمی اضافه کردن و از بین بردن قطعات در جداول تکرار. +- داده های وارد شده به یک دیدگاه محقق شده در معرض تقسیم غیر ضروری نیست. +- اجرای یک پرس و جو به یک جدول توزیع که ماکت محلی است عقب مانده و کپی از راه دور در دسترس نیست در یک خطا منجر نمی شود. +- کاربران به مجوزهای دسترسی نیاز ندارند `default` پایگاه داده برای ایجاد جداول موقت دیگر. +- ثابت توفنده در هنگام تعیین نوع مجموعه بدون استدلال. +- قطع ثابت زمانی که حجم دیسک حاوی سیاهههای مربوط به سرور کامل است. +- سرریز در تابع تورلتیواکنام برای هفته اول عصر یونیکس ثابت شده است. + +#### بهبود ساخت: {#build-improvements} + +- چندین کتابخانه شخص ثالث (به ویژه کم) به روز شد و تبدیل به دستی دستگاه گوارش. + +### ClickHouse انتشار 1.1.54304, 2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} + +#### ویژگی های جدید: {#new-features-1} + +- پردازشگر پشتیبانی شده: `tcp_ssl_port` داخل `config.xml` ). + +#### رفع اشکال: {#bug-fixes-1} + +- `ALTER` برای جداول تکرار در حال حاضر تلاش می کند تا شروع به در حال اجرا در اسرع وقت. +- ثابت توفنده در هنگام خواندن داده ها با تنظیم `preferred_block_size_bytes=0.` +- سقوط ثابت از `clickhouse-client` هنگام فشار دادن `Page Down` +- تفسیر صحیح از برخی نمایش داده شد پیچیده با `GLOBAL IN` و `UNION ALL` +- `FREEZE PARTITION` همیشه از نظر عام کار می کند در حال حاضر. +- درخواست پست خالی در حال حاضر پاسخ با کد بازگشت 411. +- خطاهای تفسیر ثابت برای عبارات مانند `CAST(1 AS Nullable(UInt8)).` +- ثابت خطا در هنگام خواندن `Array(Nullable(String))` ستونها از `MergeTree` میز +- ثابت توفنده زمانی که نمایش داده شد تجزیه مانند `SELECT dummy AS dummy, dummy AS b` +- کاربران به درستی با نامعتبر به روز شد `users.xml` +- دست زدن درست زمانی که یک فرهنگ لغت اجرایی یک کد پاسخ غیر صفر می گرداند. + +### ClickHouse انتشار 1.1.54292, 2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} + +#### ویژگی های جدید: {#new-features-2} + +- اضافه شدن `pointInPolygon` تابع برای کار با مختصات در یک هواپیما مختصات. +- اضافه شدن `sumMap` تابع جمع برای محاسبه مجموع ارریس, شبیه به `SummingMergeTree`. +- اضافه شدن `trunc` تابع. بهبود عملکرد توابع گرد کردن (`round`, `floor`, `ceil`, `roundToExp2`) و اصلاح منطق چگونه کار می کنند. منطق را تغییر داد `roundToExp2` تابع برای کسر و اعداد منفی. +- این ClickHouse فایل اجرایی است که در حال حاضر کمتر وابسته به libc نسخه. همان فایل اجرایی کلیک می تواند بر روی طیف گسترده ای از سیستم های لینوکس اجرا شود. هنوز وابستگی وجود دارد که با استفاده از نمایش داده شد وارد (با تنظیم `compile = 1` , است که به طور پیش فرض استفاده نمی شود). +- کاهش زمان مورد نیاز برای تدوین پویا از نمایش داده شد. + +#### رفع اشکال: {#bug-fixes-2} + +- ثابت خطا که گاهی اوقات تولید `part ... intersects previous part` پیام ها و قوام ماکت ضعیف. +- رفع خطا که باعث سرور به قفل کردن اگر باغ وحش در طول خاموش کردن در دسترس نیست. +- حذف ورود به سیستم بیش از حد در هنگام بازگرداندن کپی. +- ثابت خطا در اتحادیه تمام اجرای. +- ثابت خطا در تابع الحاق که در صورتی که ستون اول در یک بلوک رخ داده است نوع مجموعه ای. +- پیشرفت در حال حاضر به درستی در سیستم نمایش داده می شود.ادغام جدول. + +### ClickHouse انتشار 1.1.54289, 2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} + +#### ویژگی های جدید: {#new-features-3} + +- `SYSTEM` نمایش داده شد برای مدیریت سرور: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. +- اضافه شدن توابع برای کار با ارریس: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. +- اضافه شده `root` و `identity` پارامترهای پیکربندی باغ وحش. این اجازه می دهد تا شما را به منزوی کردن کاربران فردی در خوشه باغ وحش است. +- اضافه شده توابع مجموع `groupBitAnd`, `groupBitOr` و `groupBitXor` (برای سازگاری, همچنین تحت نام در دسترس هستند `BIT_AND`, `BIT_OR` و `BIT_XOR`). +- لغت نامه های خارجی را می توان از خروجی زیر با مشخص کردن یک سوکت در سیستم فایل لود می شود. +- واژهنامهها خارجی را می توان از خروجی زیر بر اس اس ال لود می شود (`ssl_cert`, `ssl_key`, `ssl_ca` پارامترهای). +- اضافه شدن `max_network_bandwidth_for_user` تنظیم برای محدود کردن استفاده از پهنای باند کلی برای نمایش داده شد در هر کاربر. +- پشتیبانی از `DROP TABLE` برای جداول موقت. +- پشتیبانی از خواندن `DateTime` مقادیر در قالب برچسب زمان یونیکس از `CSV` و `JSONEachRow` فرمتها. +- تاخیر کپی در نمایش داده شد توزیع در حال حاضر به طور پیش فرض حذف شدند (حد پیش فرض است 5 دقیقه). +- قفل فیفو در طول تغییر استفاده می شود: پرس و جو را تغییر دهید به طور نامحدود برای نمایش داده شد به طور مداوم در حال اجرا مسدود شده است. +- گزینه ای برای تنظیم `umask` در فایل پیکربندی. +- بهبود عملکرد برای نمایش داده شد با `DISTINCT` . + +#### رفع اشکال: {#bug-fixes-3} + +- روند برای حذف گره های قدیمی در باغ وحش بهبود یافته است. قبلا, گره های قدیمی گاهی اوقات نمی حذف اگر درج بسیار مکرر وجود دارد, که باعث سرور به کند به تعطیل, در میان چیزهای دیگر. +- تصادفی ثابت در هنگام انتخاب میزبان برای اتصال به باغ وحش. +- رفع محرومیت از عقب انداختن کپی در نمایش داده شد توزیع اگر ماکت جایل هاست است. +- خطایی را که یک بخش داده در یک `ReplicatedMergeTree` جدول را می توان پس از در حال اجرا شکسته `ALTER MODIFY` بر روی یک عنصر در یک `Nested` ساختار. +- رفع خطا که می تواند پرس و جو را انتخاب کنید به باعث “hang”. +- بهبود نمایش داده شد توزیع شده است. +- پرس و جو را ثابت کرد `CREATE TABLE ... AS `. +- حل و فصل بن بست در `ALTER ... CLEAR COLUMN IN PARTITION` پرسوجو برای `Buffer` میز +- مقدار پیشفرض نامعتبر را ثابت کرد `Enum` بازدید کنندگان (0 به جای حداقل) در هنگام استفاده از `JSONEachRow` و `TSKV` فرمتها. +- حل و فصل ظاهر فرایندهای زامبی در هنگام استفاده از یک فرهنگ لغت با `executable` منبع. +- ثابت segfault برای سر پرس و جو. + +#### گردش کار بهبود یافته برای توسعه و مونتاژ تاتر: {#improved-workflow-for-developing-and-assembling-clickhouse} + +- شما می توانید استفاده کنید `pbuilder` برای ساخت فاحشه خانه. +- شما می توانید استفاده کنید `libc++` به جای `libstdc++` برای ایجاد بر روی لینوکس. +- دستورالعمل های اضافه شده برای استفاده از ابزار تجزیه و تحلیل کد استاتیک: `Coverage`, `clang-tidy`, `cppcheck`. + +#### لطفا توجه داشته باشید در هنگام به روز رسانی: {#please-note-when-upgrading} + +- در حال حاضر یک مقدار پیش فرض بالاتر برای تنظیم ادغام وجود دارد `max_bytes_to_merge_at_max_space_in_pool` (حداکثر اندازه کل قطعات داده به ادغام در بایت): از 100 دستگاه گوارش به 150 دستگاه گوارش افزایش یافته است. این ممکن است در ادغام بزرگ در حال اجرا پس از ارتقا سرور منجر, که می تواند افزایش بار بر روی زیر سیستم دیسک باعث. اگر فضای رایگان موجود بر روی سرور کمتر از دو برابر مقدار کل ادغام که در حال اجرا هستند, این باعث می شود همه ادغام دیگر برای جلوگیری از در حال اجرا, از جمله ادغام قطعات داده های کوچک. در نتیجه, قرار دادن نمایش داده شد با پیام شکست مواجه خواهد شد “Merges are processing significantly slower than inserts.” استفاده از `SELECT * FROM system.merges` پرس و جو برای نظارت بر وضعیت. شما همچنین می توانید بررسی کنید `DiskSpaceReservedForMerge` متریک در `system.metrics` جدول, و یا در گرافیت. شما لازم نیست برای انجام هر کاری برای رفع این مشکل خود را هنگامی که ادغام بزرگ پایان حل و فصل خواهد شد. اگر شما این غیر قابل قبول, شما می توانید مقدار قبلی برای بازگرداندن `max_bytes_to_merge_at_max_space_in_pool` تنظیمات. برای انجام این کار به `` بخش در پیکربندی.تنظیم ``` ``107374182400 ``` و راه اندازی مجدد سرور. + +### ClickHouse انتشار 1.1.54284, 2017-08-29 {#clickhouse-release-1-1-54284-2017-08-29} + +- این یک نسخه رفع اشکال برای نسخه 1.1.54282 قبلی است. این رفع نشت در دایرکتوری قطعات در باغ وحش. + +### ClickHouse انتشار 1.1.54282, 2017-08-23 {#clickhouse-release-1-1-54282-2017-08-23} + +این نسخه شامل رفع اشکال برای نسخه قبلی 1.1.54276: + +- ثابت `DB::Exception: Assertion violation: !_path.empty()` هنگام قرار دادن به یک جدول توزیع شده. +- تجزیه ثابت در هنگام قرار دادن در فرمت مربوط به حوزه علمیه اگر داده های ورودی با شروع می شود. +- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). + +### ClickHouse انتشار 1.1.54276, 2017-08-16 {#clickhouse-release-1-1-54276-2017-08-16} + +#### ویژگی های جدید: {#new-features-4} + +- اضافه شده اختیاری با بخش برای پرس و جو را انتخاب کنید. به عنوان مثال پرس و جو: `WITH 1+1 AS a SELECT a, a*a` +- درج را می توان همزمان در یک جدول توزیع انجام: خوب است تنها پس از بازگشت تمام داده ها بر روی تمام خرده ریز را نجات داد. این است که با تنظیم فعال می شود +- اضافه شده نوع داده شناسه برای کار با شناسه 16 بایت. +- نام مستعار اضافه شده از کاراکتر, شناور و انواع دیگر برای سازگاری با تابلو فرش. +- اضافه شده توابع toYYYYMM, toYYYYMMDD و toYYYYMMDDhhmmss برای تبدیل زمان به اعداد. +- شما می توانید از نشانی های اینترنتی (همراه با نام میزبان) برای شناسایی سرورها برای نمایش داده شد های هوشمند خوشه ای استفاده کنید. +- اضافه شدن پشتیبانی برای استدلال غیر ثابت و شیپور خاموشی منفی در تابع `substring(str, pos, len).` +- اضافه شدن پارامتر حداکثر `groupArray(max_size)(column)` عملکرد کلی و عملکرد خود را بهینه سازی کرد. + +#### تغییرات اصلی: {#main-changes} + +- بهبود امنیت: تمام فایل های سرور با مجوز 0640 ایجاد می شوند (می توانند از طریق تغییر کنند `` پارامتر پیکربندی). +- پیام های خطا بهبود یافته برای نمایش داده شد با نحو نامعتبر است. +- به طور قابل توجهی کاهش مصرف حافظه و بهبود عملکرد در هنگام ادغام بخش های زیادی از داده های ادغام. +- به طور قابل توجهی افزایش عملکرد ادغام داده ها برای موتور جایگزین. +- عملکرد بهبود یافته برای درج ناهمزمان از یک جدول توزیع شده با ترکیب درج منبع های متعدد. برای فعال کردن این قابلیت از تنظیمات پخش شده \_ تنظیم کننده \_منیتور\_برش\_برنده=1 استفاده کنید. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-1} + +- تغییر فرمت باینری از کشورهای جمع `groupArray(array_column)` توابع برای ارریس. + +#### لیست کامل تغییرات: {#complete-list-of-changes} + +- اضافه شدن `output_format_json_quote_denormals` تنظیمات, را قادر می سازد خروجی نان و ارزشهای جبهه ملی در فرمت جانسون. +- تخصیص جریان بهینه شده در هنگام خواندن از یک جدول توزیع شده است. +- تنظیمات را می توان در حالت فقط خواندنی پیکربندی در صورتی که ارزش تغییر نمی کند. +- اضافه شده توانایی برای بازیابی غیر صحیح گرانول از MergeTree موتور به منظور دیدار با محدودیت در اندازه بلوک مشخص شده در preferred\_block\_size\_bytes تنظیم. هدف این است که برای کاهش مصرف رم و افزایش محل کش در هنگام پردازش نمایش داده شد از جداول با ستون های بزرگ. +- استفاده موثر از شاخص هایی که حاوی عبارات هستند `toStartOfHour(x)` برای شرایطی مانند `toStartOfHour(x) op сonstexpr.` +- اضافه شدن تنظیمات جدید برای MergeTree موتورهای (به merge\_tree بخش در config.شمع): + - replicated\_deduplication\_window\_seconds مجموعه تعدادی از ثانیه های مجاز برای deduplicating درج در تکرار جداول. + - پاک کردن \_خروج \_پیروید تنظیم میکند که چگونه اغلب شروع به پاکسازی برای حذف اطلاعات منسوخ شده میکند. + - از تبدیل شدن به رهبر (و اختصاص ادغام) می توانید یک کپی از تبدیل شدن به رهبر جلوگیری کنید. +- پاکسازی شتاب به حذف اطلاعات منسوخ شده از باغ وحش. +- بهبود و رفع چندگانه برای نمایش داده شد دسته ای دی ال. از علاقه خاص است که تنظیم جدید distributed\_ddl\_task\_timeout که محدودیت زمان انتظار برای پاسخ از سرور در خوشه. اگر یک درخواست دی ال شده است در تمام میزبان انجام نشده است, پاسخ حاوی یک خطا ایست و یک درخواست خواهد شد در حالت کالاهای کابل اجرا. +- صفحه نمایش بهبود یافته از ردیابی پشته در سیاهههای مربوط به سرور. +- اضافه شدن “none” ارزش روش فشرده سازی. +- شما می توانید بخش های مختلف \_تنفورد کامل در پیکربندی استفاده کنید.. +- ممکن است که به اتصال به خروجی زیر را از طریق یک سوکت در سیستم فایل. +- سیستمجدول قطعات دارای یک ستون جدید با اطلاعات در مورد اندازه علامت, در بایت. + +#### رفع اشکال: {#bug-fixes-4} + +- جداول توزیع با استفاده از یک جدول ادغام در حال حاضر به درستی برای پرس و جو را انتخاب کنید با یک شرط در کار `_table` رشته. +- در هنگام چک کردن قطعات داده ها یک وضعیت مسابقه نادر در تکرار می شود. +- انجماد ممکن ثابت در “leader election” هنگام شروع یک سرور. +- این max\_replica\_delay\_for\_distributed\_queries تنظیم نادیده گرفته شد که با استفاده از یک محلی ماکت از منبع داده. این ثابت شده است. +- رفتار نادرست ثابت `ALTER TABLE CLEAR COLUMN IN PARTITION` هنگامی که تلاش برای تمیز کردن یک ستون غیر موجود. +- ثابت یک استثنا در تابع چندف در هنگام استفاده از مجموعه های خالی و یا رشته. +- تخصیص حافظه بیش از حد ثابت هنگام فراخوانی فرمت بومی. +- ثابت نادرست خودکار به روز رسانی از لغت نامه سه. +- ثابت یک استثنا زمانی که در حال اجرا نمایش داده شد با یک گروه بند از یک جدول ادغام در هنگام استفاده از نمونه. +- تصادف گروهی با استفاده از توزیع شده \_اگزا\_موری\_افلیتی کمبود=1 را ثابت کرد. +- حالا شما می توانید پایگاه داده را مشخص کنید.جدول در سمت راست در و پیوستن. +- بیش از حد بسیاری از موضوعات برای تجمع موازی مورد استفاده قرار گرفت. این ثابت شده است. +- ثابت چگونه “if” تابع با استدلال رشته کار می کند. +- انتخاب به اشتباه از یک جدول توزیع برای خرده ریز با وزن کار 0. این ثابت شده است. +- در حال اجرا `CREATE VIEW IF EXISTS no longer causes crashes.` +- رفتار نادرست ثابت در هنگام وارد کردن \_فصل\_سک\_کنون\_فیلدهای ورودی = 1 تنظیم شده است و اعداد منفی وجود دارد. +- ثابت یک حلقه بی نهایت در `dictGetHierarchy()` تابع در صورتی که برخی از داده های نامعتبر در فرهنگ لغت وجود دارد. +- ثابت `Syntax error: unexpected (...)` خطاها هنگامی که در حال اجرا نمایش داده شد توزیع شده با کارخانه های فرعی در یک در و یا پیوستن بند و ادغام جداول. +- ثابت تفسیر نادرست از پرس و جو را انتخاب کنید از جداول فرهنگ لغت. +- ثابت “Cannot mremap” خطا در هنگام استفاده از بند در و پیوستن به بند با بیش از 2 میلیارد عنصر. +- عدم موفقیت برای لغت نامه با خروجی زیر به عنوان منبع ثابت شده است. + +#### گردش کار بهبود یافته برای توسعه و مونتاژ تاتر: {#improved-workflow-for-developing-and-assembling-clickhouse-1} + +- ساخت را می توان در ارکادیا مونتاژ. +- شما می توانید شورای همکاری خلیج فارس 7 به کامپایل خانه عروسکی استفاده کنید. +- موازی ایجاد شده با استفاده از ccache+distcc سریع تر در حال حاضر. + +### ClickHouse انتشار 1.1.54245, 2017-07-04 {#clickhouse-release-1-1-54245-2017-07-04} + +#### ویژگی های جدید: {#new-features-5} + +- توزیع دی ال (به عنوان مثال, `CREATE TABLE ON CLUSTER`) +- پرسوجوی تکرار شده `ALTER TABLE CLEAR COLUMN IN PARTITION.` +- موتور برای جداول فرهنگ لغت (دسترسی به داده های فرهنگ لغت در قالب یک جدول). +- موتور پایگاه داده فرهنگ لغت (این نوع از پایگاه داده به طور خودکار دارای جداول فرهنگ لغت در دسترس برای تمام لغت نامه های خارجی متصل). +- شما می توانید برای به روز رسانی به فرهنگ لغت با ارسال یک درخواست به منبع را بررسی کنید. +- نام ستون واجد شرایط +- به نقل از شناسه با استفاده از علامت نقل قول دو. +- در حال بارگذاری +- پرس و جو بهینه سازی برای یک جدول تکرار می تواند نه تنها در رهبر را اجرا کنید. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-2} + +- حذف مجموعه جهانی است. + +#### تغییرات جزیی: {#minor-changes} + +- در حال حاضر پس از یک هشدار باعث شده است, ورود به سیستم چاپ ردیابی پشته کامل. +- تایید تعداد قطعات صدمه دیده/اضافی داده در هنگام راه اندازی (بیش از حد بسیاری مثبت کاذب وجود دارد). + +#### رفع اشکال: {#bug-fixes-5} + +- ثابت اتصال بد “sticking” هنگام قرار دادن به یک جدول توزیع شده. +- جهانی در حال حاضر برای پرس و جو از یک جدول ادغام که به نظر می رسد در یک جدول توزیع کار می کند. +- تعداد نادرست هسته بر روی یک ماشین مجازی موتور محاسبه گوگل تشخیص داده شد. این ثابت شده است. +- تغییرات در چگونه یک منبع اجرایی لغت نامه های خارجی ذخیره شده کار می کند. +- ثابت مقایسه رشته های حاوی شخصیت های پوچ. +- مقایسه زمینه های کلیدی اصلی شناور32 با ثابت ها را ثابت کرد. +- قبلا تخمین نادرست از اندازه یک میدان می تواند منجر به بیش از حد بزرگ تخصیص. +- ثابت تصادف در هنگام پرس و جو یک ستون باطل به یک جدول با استفاده از تغییر اضافه شده است. +- ثابت تصادف در هنگام مرتب سازی توسط یک ستون قابل ابطال, اگر تعداد ردیف کمتر از حد است. +- ثابت سفارش های خرده فروشی متشکل از ارزش تنها ثابت است. +- قبلا, یک جدول تکرار می تواند در حالت نامعتبر پس از یک جدول افت شکست خورده باقی می ماند. +- نام مستعار برای زیرکار اسکالر با نتایج خالی دیگر از دست داده. +- در حال حاضر پرس و جو که تلفیقی استفاده می شود با یک خطا شکست نیست در صورتی که . diff --git a/docs/fa/whats-new/changelog/2018.md b/docs/fa/whats-new/changelog/2018.md new file mode 100644 index 00000000000..3ad0570d5a4 --- /dev/null +++ b/docs/fa/whats-new/changelog/2018.md @@ -0,0 +1,1063 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 78 +toc_title: '2018' +--- + +## انتشار کلیک 18.16 {#clickhouse-release-18-16} + +### ClickHouse انتشار 18.16.1, 2018-12-21 {#clickhouse-release-18-16-1-2018-12-21} + +#### رفع اشکال: {#bug-fixes} + +- رفع خطا که به مشکلات با به روز رسانی لغت نامه با منبع ان بی سی منجر شده است. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- مجموعه دستگاه گوارش از توابع کل در حال حاضر با ستون های کمکاری کار می کند. [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) + +#### بهبود: {#improvements} + +- اضافه شدن `low_cardinality_allow_in_native_format` تنظیم (فعال به طور پیش فرض). هنگامی که غیر فعال, ستون های کم هزینه خواهد شد به ستون های معمولی برای نمایش داده شد را انتخاب کنید تبدیل و ستون عادی خواهد شد برای قرار دادن نمایش داده شد انتظار می رود. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) + +#### بهبود ساخت: {#build-improvements} + +- رفع برای ایجاد بر روی مکینتاش و بازو. + +### ClickHouse انتشار 18.16.0, 2018-12-14 {#clickhouse-release-18-16-0-2018-12-14} + +#### ویژگی های جدید: {#new-features} + +- `DEFAULT` عبارات برای زمینه های از دست رفته در هنگام بارگذاری داده ها در فرمت های ورودی نیمه ساختار ارزیابی (`JSONEachRow`, `TSKV`). این ویژگی با فعال `insert_sample_with_metadata` تنظیمات. [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) +- این `ALTER TABLE` پرس و جو در حال حاضر `MODIFY ORDER BY` اقدام برای تغییر کلید مرتب سازی هنگام اضافه کردن یا حذف یک ستون جدول. این برای جداول در مفید است `MergeTree` خانواده ای که انجام کارهای اضافی در هنگام ادغام بر اساس این کلید مرتب سازی, مانند `SummingMergeTree`, `AggregatingMergeTree` و به همین ترتیب. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) +- برای جداول در `MergeTree` خانواده, در حال حاضر شما می توانید یک کلید مرتب سازی های مختلف را مشخص کنید (`ORDER BY`) و شاخص (`PRIMARY KEY`). کلید مرتب سازی می تواند طولانی تر از شاخص باشد. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) +- اضافه شدن `hdfs` عملکرد جدول و `HDFS` موتور جدول برای واردات و صادرات داده ها به اچ دی اف. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) +- اضافه شدن توابع برای کار بازه64: `base64Encode`, `base64Decode`, `tryBase64Decode`. [الکساندر کرشنینیکف](https://github.com/ClickHouse/ClickHouse/pull/3350) +- حالا شما می توانید یک پارامتر برای پیکربندی دقت استفاده کنید `uniqCombined` تابع جمع (تعداد سلول های بیش از حد جمع را انتخاب کنید). [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) +- اضافه شدن `system.contributors` جدول که شامل نام هر کسی که مرتکب در خانه کلیک ساخته شده. [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) +- اضافه شدن توانایی حذف پارتیشن برای `ALTER TABLE ... FREEZE` پرس و جو به منظور پشتیبان گیری از تمام پارتیشن در یک بار. [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) +- اضافه شده `dictGet` و `dictGetOrDefault` توابع که نیاز به تعیین نوع مقدار بازگشتی ندارند. نوع به طور خودکار از توضیحات فرهنگ لغت تعیین می شود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3564) +- حالا شما می توانید نظرات را برای یک ستون در توضیحات جدول مشخص کنید و با استفاده از تغییر دهید `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) +- خواندن برای پشتیبانی `Join` نوع جداول با کلید های ساده. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3728) +- حالا شما می توانید گزینه های مشخص `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join` و `join_overflow_mode` هنگام ایجاد یک `Join` جدول نوع. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3728) +- اضافه شدن `joinGet` تابع است که اجازه می دهد تا شما را به استفاده از یک `Join` نوع جدول مانند یک فرهنگ لغت. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3728) +- اضافه شدن `partition_key`, `sorting_key`, `primary_key` و `sampling_key` ستونها به `system.tables` جدول به منظور فراهم کردن اطلاعات در مورد کلید های جدول. [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- اضافه شدن `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key` و `is_in_sampling_key` ستونها به `system.columns` جدول [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- اضافه شدن `min_time` و `max_time` ستونها به `system.parts` جدول این ستون ها جمعیت زمانی که کلید پارتیشن بندی بیان متشکل از است `DateTime` ستون ها [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) + +#### رفع اشکال: {#bug-fixes-1} + +- رفع و بهبود عملکرد برای `LowCardinality` نوع داده. `GROUP BY` با استفاده از `LowCardinality(Nullable(...))`. گرفتن ارزش `extremes`. پردازش توابع بالا سفارش. `LEFT ARRAY JOIN`. توزیع شده `GROUP BY`. توابع است که بازگشت `Array`. اعدام `ORDER BY`. نوشتن به `Distributed` جداول (نیکولولو). سازگاری به عقب برای `INSERT` نمایش داده شد از مشتریان قدیمی که پیاده سازی `Native` قانون پشتیبانی از `LowCardinality` برای `JOIN`. بهبود عملکرد در هنگام کار در یک جریان واحد. [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) +- ثابت چگونه `select_sequential_consistency` گزینه کار می کند. قبلا, زمانی که این تنظیم فعال بود, نتیجه ناقص گاهی اوقات پس از شروع به نوشتن به یک پارتیشن جدید بازگردانده شد. [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) +- پایگاه داده ها هنگام اجرای دی ال به درستی مشخص شده است `ON CLUSTER` نمایش داده شد و `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- پایگاه داده ها به درستی برای کارخانه های فرعی در داخل یک نمایش مشخص شده است. [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) +- رفع اشکال در `PREWHERE` با `FINAL` برای `VersionedCollapsingMergeTree`. [7167بد7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) +- حالا شما می توانید استفاده کنید `KILL QUERY` برای لغو نمایش داده شد که هنوز شروع نشده است زیرا انتظار دارند جدول قفل شود. [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) +- اصلاح محاسبات تاریخ و زمان اگر ساعت در نیمه شب منتقل شد (این اتفاق می افتد در ایران, و در مسکو از اتفاق افتاد 1981 به 1983). قبلا, این منجر به زمان در حال تنظیم مجدد یک روز زودتر از حد لازم, و همچنین باعث قالب بندی نادرست از تاریخ و زمان در قالب متن. [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) +- اشکالات ثابت در برخی موارد `VIEW` و کارخانه های فرعی که حذف پایگاه داده. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3521) +- ثابت شرایط مسابقه زمانی که به طور همزمان از یک خواندن `MATERIALIZED VIEW` و حذف یک `MATERIALIZED VIEW` با توجه به قفل کردن داخلی `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) +- خطا را ثابت کرد `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) +- پردازش پرس و جو ثابت زمانی که `compile_expressions` گزینه فعال است(به طور پیش فرض فعال است). عبارات ثابت نامشخص مانند `now` تابع دیگر گشوده. [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) +- ثابت تصادف در هنگام مشخص کردن یک استدلال مقیاس غیر ثابت در `toDecimal32/64/128` توابع. +- ثابت خطا در هنگام تلاش برای وارد کردن مجموعه ای با `NULL` عناصر در `Values` قالب در یک ستون از نوع `Array` بدون `Nullable` (اگر `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) +- ثابت ورود خطا مداوم در `DDLWorker` اگر باغ وحش در دسترس نیست. [8 اف 50620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) +- ثابت نوع بازگشت برای `quantile*` توابع از `Date` و `DateTime` انواع استدلال. [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) +- ثابت `WITH` بند اگر یک نام مستعار ساده و بدون عبارات مشخص. [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) +- پردازش ثابت نمایش داده شد با نام زیر نمایش داده شد و نام ستون واجد شرایط زمانی که `enable_optimize_predicate_expression` فعال است. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3588) +- خطا را ثابت کرد `Attempt to attach to nullptr thread group` در هنگام کار با نمایش محقق. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) +- ثابت تصادف در هنگام عبور استدلال نادرست خاص به `arrayReverse` تابع. [733ا7ب6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- ثابت سرریز بافر در `extractURLParameter` تابع. بهبود عملکرد. اضافه شده پردازش صحیح رشته حاوی صفر بایت. [1419799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) +- سرریز بافر ثابت در `lowerUTF8` و `upperUTF8` توابع. حذف توانایی برای اجرای این توابع بیش از `FixedString` استدلال نوع. [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) +- ثابت شرایط مسابقه نادر در هنگام حذف `MergeTree` میز [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) +- ثابت شرایط مسابقه در هنگام خواندن از `Buffer` جداول و به طور همزمان انجام `ALTER` یا `DROP` در جداول هدف. [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) +- ثابت segfault اگر `max_temporary_non_const_columns` حد بیش از حد شد. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### بهبود: {#improvements-1} + +- سرور فایل های پیکربندی پردازش شده را به `/etc/clickhouse-server/` فهرست راهنما. در عوض, این موجب صرفه جویی در `preprocessed_configs` فهرست راهنمای داخل `path`. این به این معنی است که `/etc/clickhouse-server/` دایرکتوری دسترسی نوشتن برای ندارد `clickhouse` کاربر, که باعث بهبود امنیت. [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) +- این `min_merge_bytes_to_use_direct_io` گزینه به 10 دستگاه گوارش به طور پیش فرض تنظیم شده است. ادغام که بخش های زیادی از جداول از خانواده ادغام را تشکیل می دهد در انجام خواهد شد `O_DIRECT` حالت, که مانع از اخراج کش صفحه بیش از حد. [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) +- شتاب سرور شروع زمانی که تعداد بسیار زیادی از جداول وجود دارد. [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) +- اضافه شدن یک استخر اتصال و قام `Keep-Alive` برای ارتباط بین کپی. [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) +- اگر نحو پرس و جو نامعتبر است `400 Bad Request` کد در بازگشت `HTTP` رابط (500 قبلا بازگردانده شد). [31ب680ا](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) +- این `join_default_strictness` گزینه تنظیم شده است `ALL` به طور پیش فرض برای سازگاری. [120الکترونیکی 2جبه](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) +- حذف ورود به سیستم `stderr` از `re2` کتابخانه برای عبارات منظم نامعتبر و یا پیچیده. [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) +- اضافه شده برای `Kafka` موتور جدول: چک برای اشتراک قبل از شروع به خواندن از کافکا; تنظیمات کافکا\_مکس\_بلک\_سیز برای جدول. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) +- این `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32` و `murmurHash3_64` توابع در حال حاضر برای هر تعداد از استدلال و برای استدلال در قالب تاپل کار می کنند. [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) +- این `arrayReverse` تابع در حال حاضر با هر نوع ارریس کار می کند. [733ا7ب6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- اضافه شده یک پارامتر اختیاری: اندازه اسلات برای `timeSlots` تابع. [کیریل شواکوف](https://github.com/ClickHouse/ClickHouse/pull/3724) +- برای `FULL` و `RIGHT JOIN` این `max_block_size` تنظیم برای یک جریان از داده های غیر پیوست از جدول سمت راست استفاده می شود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3699) +- اضافه شدن `--secure` پارامتر خط فرمان در `clickhouse-benchmark` و `clickhouse-performance-test` برای فعال کردن شماره تلفن. [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) +- تبدیل نوع زمانی که ساختار یک `Buffer` جدول نوع ساختار جدول مقصد مطابقت ندارد. [ویتالی بارانو](https://github.com/ClickHouse/ClickHouse/pull/3603) +- اضافه شدن `tcp_keep_alive_timeout` گزینه ای برای فعال نگه داشتن زنده بسته پس از عدم فعالیت برای فاصله زمانی مشخص شده است. [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) +- حذف نقل غیر ضروری از ارزش برای کلید پارتیشن در `system.parts` جدول اگر از یک ستون تشکیل شده است. [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) +- عملکرد پیمانه برای `Date` و `DateTime` انواع داده ها. [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) +- اضافه شده مترادف برای `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR` و `MID` توابع. [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) برخی از نام های تابع حروف حساس برای سازگاری با استاندارد گذاشتن. شکر نحوی اضافه شده است `SUBSTRING(expr FROM start FOR length)` برای سازگاری با گذاشتن. [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) +- توانایی اضافه شده به `mlock` صفحات حافظه مربوط به `clickhouse-server` کد اجرایی برای جلوگیری از مجبور شدن از حافظه. این ویژگی به طور پیش فرض غیر فعال. [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) +- بهبود عملکرد در هنگام خواندن از `O_DIRECT` (با `min_bytes_to_use_direct_io` گزینه فعال). [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) +- بهبود عملکرد `dictGet...OrDefault` تابع برای یک استدلال کلیدی ثابت و یک استدلال پیش فرض غیر ثابت. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3563) +- این `firstSignificantSubdomain` تابع در حال حاضر پردازش دامنه `gov`, `mil` و `edu`. [ایگور هاتاریست](https://github.com/ClickHouse/ClickHouse/pull/3601) بهبود عملکرد. [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) +- امکان مشخص کردن متغیرهای محیطی سفارشی برای شروع `clickhouse-server` با استفاده از `SYS-V init.d` اسکریپت با تعریف `CLICKHOUSE_PROGRAM_ENV` داخل `/etc/default/clickhouse`. + [پاولو باشینسکیی](https://github.com/ClickHouse/ClickHouse/pull/3612) +- کد بازگشت صحیح برای اسکریپت اینیت کلاینت سرور. [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) +- این `system.metrics` جدول در حال حاضر `VersionInteger` متریک و `system.build_options` دارای خط اضافه شده است `VERSION_INTEGER`, که شامل فرم عددی از نسخه کلیک, مانند `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) +- حذف توانایی مقایسه `Date` نوع با یک عدد برای جلوگیری از خطاهای بالقوه مانند `date = 2018-12-17`, جایی که نقل قول در سراسر تاریخ به اشتباه حذف. [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) +- ثابت رفتار توابع نفرت انگیز مانند `rowNumberInAllBlocks`. قبلا خروجی نتیجه که یک عدد بزرگتر با توجه به شروع در طول تجزیه و تحلیل پرس و جو بود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3729) +- اگر `force_restore_data` فایل را نمی توان حذف کرد, یک پیغام خطا نمایش داده می شود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3794) + +#### بهبود ساخت: {#build-improvements-1} + +- به روز شده در `jemalloc` کتابخانه, که رفع نشت حافظه بالقوه. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3557) +- پروفایل با `jemalloc` به طور پیش فرض به منظور اشکال زدایی ایجاد فعال است. [2سی82ف5 درجه سانتیگراد](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) +- اضافه شدن توانایی برای اجرای تست ادغام زمانی که تنها `Docker` بر روی سیستم نصب شده است. [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) +- اضافه شدن تست بیان ریش ریش شدن در نمایش داده شد را انتخاب کنید. [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) +- اضافه شدن یک تست استرس برای مرتکب, که انجام تست های کاربردی به صورت موازی و به صورت تصادفی برای تشخیص شرایط مسابقه بیشتر. [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) +- بهبود روش برای شروع کلیک سرور در یک تصویر کارگر بارانداز. [الغزال احمد](https://github.com/ClickHouse/ClickHouse/pull/3663) +- برای یک تصویر کارگر بارانداز, اضافه شدن پشتیبانی برای مقداردهی اولیه پایگاه داده با استفاده از فایل ها در `/docker-entrypoint-initdb.d` فهرست راهنما. [کنستانتین لبتوف](https://github.com/ClickHouse/ClickHouse/pull/3695) +- رفع برای ایجاد بر روی بازو. [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes} + +- حذف توانایی مقایسه `Date` نوع با یک عدد. به جای `toDate('2018-12-18') = 17883`, شما باید تبدیل نوع صریح و روشن استفاده `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) + +## انتشار کلیک 18.14 {#clickhouse-release-18-14} + +### ClickHouse انتشار 18.14.19, 2018-12-19 {#clickhouse-release-18-14-19-2018-12-19} + +#### رفع اشکال: {#bug-fixes-2} + +- رفع خطا که به مشکلات با به روز رسانی لغت نامه با منبع ان بی سی منجر شده است. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- پایگاه داده ها هنگام اجرای دی ال به درستی مشخص شده است `ON CLUSTER` نمایش داده شد. [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- ثابت segfault اگر `max_temporary_non_const_columns` حد بیش از حد شد. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### بهبود ساخت: {#build-improvements-2} + +- رفع برای ایجاد بر روی بازو. + +### ClickHouse انتشار 18.14.18, 2018-12-04 {#clickhouse-release-18-14-18-2018-12-04} + +#### رفع اشکال: {#bug-fixes-3} + +- خطای ثابت در `dictGet...` تابع برای لغت نامه از نوع `range`, اگر یکی از استدلال ثابت است و دیگر نیست. [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) +- خطا ثابت که باعث پیام `netlink: '...': attribute type 1 has an invalid length` برای چاپ در لینوکس هسته ورود که اتفاق می افتد تنها در نسخه های تازه به اندازه کافی از هسته لینوکس. [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) +- پیش فرض ثابت در عملکرد `empty` برای استدلال `FixedString` نوع. [دانیل, دا کوانگ مین](https://github.com/ClickHouse/ClickHouse/pull/3703) +- تخصیص حافظه بیش از حد ثابت در هنگام استفاده از مقدار زیادی از `max_query_size` تنظیم (یک تکه حافظه از `max_query_size` بایت در یک بار تخصیص داده شد). [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) + +#### ایجاد تغییرات: {#build-changes} + +- ساخت ثابت با کتابخانه های لووم/کلنگ نسخه 7 از بسته های سیستم عامل (این کتابخانه ها برای تدوین پرس و جو در زمان اجرا استفاده می شود). [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### ClickHouse انتشار 18.14.17, 2018-11-30 {#clickhouse-release-18-14-17-2018-11-30} + +#### رفع اشکال: {#bug-fixes-4} + +- موارد ثابت زمانی که روند پل ان بی سی با روند سرور اصلی خاتمه نیست. [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) +- درج همزمان ثابت به `Distributed` جدول با یک لیست ستون که از لیست ستون جدول از راه دور متفاوت. [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) +- ثابت یک بیماری مسابقه نادر است که می تواند به یک تصادف در هنگام حذف یک جدول ادغام منجر شود. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- ثابت بن بست پرس و جو در مورد زمانی که ایجاد موضوع پرس و جو با شکست مواجه `Resource temporarily unavailable` خطا. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- تجزیه ثابت از `ENGINE` بند زمانی که `CREATE AS table` نحو مورد استفاده قرار گرفت و `ENGINE` بند قبل از مشخص شد `AS table` (خطا منجر به نادیده گرفتن موتور مشخص شده). [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) + +### ClickHouse انتشار 18.14.15, 2018-11-21 {#clickhouse-release-18-14-15-2018-11-21} + +#### رفع اشکال: {#bug-fixes-5} + +- اندازه تکه حافظه دست بالا بود در حالی که غیرشخصی ستون از نوع `Array(String)` که منجر به “Memory limit exceeded” خطاها. این موضوع در نسخه 18.12.13 ظاهر شد. [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) + +### ClickHouse انتشار 18.14.14, 2018-11-20 {#clickhouse-release-18-14-14-2018-11-20} + +#### رفع اشکال: {#bug-fixes-6} + +- ثابت `ON CLUSTER` نمایش داده شد که خوشه پیکربندی به عنوان امن (پرچم ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) + +#### ایجاد تغییرات: {#build-changes-1} + +- مشکلات ثابت-7 از سیستم مکینتاش) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### ClickHouse انتشار 18.14.13, 2018-11-08 {#clickhouse-release-18-14-13-2018-11-08} + +#### رفع اشکال: {#bug-fixes-7} + +- ثابت `Block structure mismatch in MergingSorted stream` خطا. [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) +- ثابت `ON CLUSTER` نمایش داده شد در صورتی که اتصالات امن در در پیکربندی خوشه تبدیل شد (از `` پرچم). [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) +- ثابت خطا در نمایش داده شد که استفاده می شود `SAMPLE`, `PREWHERE` و ستون نام مستعار. [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) +- ثابت نادر `unknown compression method` خطا در هنگام `min_bytes_to_use_direct_io` تنظیمات فعال شد. [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) + +#### بهبود عملکرد: {#performance-improvements} + +- رگرسیون عملکرد ثابت نمایش داده شد با `GROUP BY` از ستون UInt16 یا نوع تاریخ که در اجرای AMD EPYC پردازنده. [ایگور لاپکو](https://github.com/ClickHouse/ClickHouse/pull/3512) +- رگرسیون عملکرد ثابت نمایش داده شد که رشته های طولانی را پردازش می کند. [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) + +#### بهبود ساخت: {#build-improvements-3} + +- بهبود برای ساده سازی ساخت ارکادیا. [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) + +### ClickHouse انتشار 18.14.12, 2018-11-02 {#clickhouse-release-18-14-12-2018-11-02} + +#### رفع اشکال: {#bug-fixes-8} + +- ثابت سقوط در پیوستن به دو کارخانه های فرعی که نامش ذکر نشده. [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) +- ثابت تولید نمایش داده شد نادرست (با خالی `WHERE` بند) هنگامی که پرس و جو پایگاه داده های خارجی. [هیلد](https://github.com/ClickHouse/ClickHouse/pull/3477) +- ثابت با استفاده از یک مقدار ایست نادرست در لغت نامه او بی سی. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) + +### ClickHouse انتشار 18.14.11, 2018-10-29 {#clickhouse-release-18-14-11-2018-10-29} + +#### رفع اشکال: {#bug-fixes-9} + +- خطا را ثابت کرد `Block structure mismatch in UNION stream: different number of columns` در حد نمایش داده شد. [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) +- خطاهای ثابت در هنگام ادغام داده ها در جداول حاوی ارریس در داخل ساختارهای تو در تو. [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) +- نتایج پرس و جو نادرست ثابت اگر `merge_tree_uniform_read_distribution` تنظیم غیر فعال است(به طور پیش فرض فعال). [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) +- ثابت خطا در درج به یک جدول توزیع شده در فرمت بومی. [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) + +### ClickHouse انتشار 18.14.10, 2018-10-23 {#clickhouse-release-18-14-10-2018-10-23} + +- این `compile_expressions` تنظیم (مجموعه دستگاه گوارش عبارات) به طور پیش فرض غیر فعال است. [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) +- این `enable_optimize_predicate_expression` تنظیم به طور پیش فرض غیر فعال است. + +### ClickHouse انتشار 18.14.9, 2018-10-16 {#clickhouse-release-18-14-9-2018-10-16} + +#### ویژگی های جدید: {#new-features-1} + +- این `WITH CUBE` تغییردهنده برای `GROUP BY` (نحو جایگزین `GROUP BY CUBE(...)` همچنین در دسترس است). [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) +- اضافه شدن `formatDateTime` تابع. [الکساندر کراشنینیکوف](https://github.com/ClickHouse/ClickHouse/pull/2770) +- اضافه شدن `JDBC` موتور جدول و `jdbc` تابع جدول (نیاز به نصب کلیک-جد بی سی پل). [الکساندر کراشنینیکوف](https://github.com/ClickHouse/ClickHouse/pull/3210) +- اضافه شدن توابع برای کار با شماره ایزو هفته: `toISOWeek`, `toISOYear`, `toStartOfISOYear` و `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) +- حالا شما می توانید استفاده کنید `Nullable` ستون برای `MySQL` و `ODBC` میز [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- ساختارهای داده تو در تو را می توان به عنوان اجسام تو در تو در خواندن `JSONEachRow` قالب. اضافه شدن `input_format_import_nested_json` تنظیمات. [ولمان یونکان](https://github.com/ClickHouse/ClickHouse/pull/3144) +- پردازش موازی برای بسیاری در دسترس است `MATERIALIZED VIEW`هنگام قرار دادن داده ها. دیدن `parallel_view_processing` تنظیمات. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) +- اضافه شدن `SYSTEM FLUSH LOGS` پرس و جو (مجبور ورود حملات گرگرفتگی به جداول سیستم مانند `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) +- حالا شما می توانید از پیش تعریف شده استفاده کنید `database` و `table` ماکروها هنگام اعلام `Replicated` میز [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) +- توانایی خواندن را اضافه کرد `Decimal` ارزش نوع در نماد مهندسی (نشان می دهد قدرت ده). [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) + +#### ویژگی های تجربی: {#experimental-features} + +- بهینه سازی گروه توسط بند برای `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) +- محاسبه بهینه از عبارات برای `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) + +#### بهبود: {#improvements-2} + +- به طور قابل توجهی کاهش مصرف حافظه برای نمایش داده شد با `ORDER BY` و `LIMIT`. دیدن `max_bytes_before_remerge_sort` تنظیمات. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- در صورت عدم وجود `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` فرض بر این است. [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) +- ستاره واجد شرایط به درستی در نمایش داده شد با کار `JOIN`. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3202) +- این `ODBC` موتور جدول به درستی انتخاب روش برای به نقل از شناسه در گویش گذاشتن یک پایگاه داده از راه دور. [الکساندر کراشنینیکوف](https://github.com/ClickHouse/ClickHouse/pull/3210) +- این `compile_expressions` تنظیم (مجموعه دستگاه گوارش از عبارات) به طور پیش فرض فعال است. +- رفتار ثابت برای پایگاه داده قطره به طور همزمان/جدول اگر وجود دارد و ایجاد پایگاه داده / جدول اگر وجود ندارد. قبلا `CREATE DATABASE ... IF NOT EXISTS` پرسوجو میتواند پیغام خطا را بازگرداند “File … already exists” و `CREATE TABLE ... IF NOT EXISTS` و `DROP TABLE IF EXISTS` نمایش داده شد می تواند بازگشت `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) +- مانند و در عبارات با نیمه راست ثابت به سرور از راه دور منتقل می شود که پرس و جو از خروجی زیر و یا جداول ان بی سی. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- مقایسه با عبارات ثابت در جایی که بند به سرور از راه دور منتقل می شود که پرس و جو از خروجی زیر و جداول ان بی سی. قبلا, تنها مقایسه با ثابت تصویب شد. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- محاسبه صحیح عرض ردیف در ترمینال برای `Pretty` فرمت, از جمله رشته با هیروگلیف. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3257). +- `ON CLUSTER` می توان برای مشخص `ALTER UPDATE` نمایش داده شد. +- بهبود عملکرد برای خواندن داده ها در `JSONEachRow` قالب. [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) +- اضافه شده مترادف برای `LENGTH` و `CHARACTER_LENGTH` توابع برای سازگاری. این `CONCAT` تابع دیگر حساس به حروف نیست. [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) +- اضافه شدن `TIMESTAMP` مترادف برای `DateTime` نوع. [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) +- همیشه فضای این سایت متعلق به پرس و جو کوری\_ید در سیاهههای مربوط به سرور وجود دارد, حتی اگر خط ورود به سیستم به یک پرس و جو مربوط نیست. این باعث می شود ساده تر به تجزیه سرور سیاهههای مربوط به متن با ابزار شخص ثالث. +- مصرف حافظه توسط پرس و جو وارد شده است که بیش از سطح بعدی از یک عدد صحیح گیگابایت است. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- اضافه شده حالت سازگاری برای مورد زمانی که کتابخانه مشتری که با استفاده از پروتکل بومی ستون کمتر به اشتباه می فرستد از سرور انتظار برای پرس و جو درج. این سناریو ممکن بود در هنگام استفاده از کتابخانه کلیک پردازنده. قبلا, این سناریو باعث سرور به سقوط. [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) +- در تعریف کاربر که بیان در `clickhouse-copier` شما هم اکنون می توانید از یک `partition_key` نام مستعار (برای فیلتر کردن اضافی توسط پارتیشن جدول منبع). این بسیار مفید است اگر طرح پارتیشن بندی در طول کپی تغییر, اما تنها کمی تغییر. [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) +- گردش کار از `Kafka` موتور شده است به یک استخر موضوع پس زمینه به منظور به طور خودکار کاهش سرعت خواندن داده ها در بارهای بالا نقل مکان کرد. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- پشتیبانی از خواندن `Tuple` و `Nested` ارزش سازه ها مانند `struct` در `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) +- فهرست دامنه های سطح بالا برای `firstSignificantSubdomain` تابع در حال حاضر شامل دامنه `biz`. [بریدن](https://github.com/ClickHouse/ClickHouse/pull/3219) +- در پیکربندی واژهنامهها خارجی, `null_value` به عنوان مقدار نوع داده پیش فرض تفسیر شده است. [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) +- پشتیبانی از `intDiv` و `intDivOrZero` توابع برای `Decimal`. [48402الکترونیکی8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) +- پشتیبانی از `Date`, `DateTime`, `UUID` و `Decimal` انواع به عنوان یک کلید برای `sumMap` تابع جمع. [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) +- پشتیبانی از `Decimal` نوع داده در لغت نامه های خارجی. [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) +- پشتیبانی از `Decimal` نوع داده در `SummingMergeTree` میز [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) +- اضافه شده تخصص برای `UUID` داخل `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) +- کاهش تعداد `open` و `close` سیستم هنگام خواندن از یک تماس می گیرد `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) +- A `TRUNCATE TABLE` پرس و جو را می توان در هر ماکت اجرا (پرس و جو به ماکت رهبر منتقل). [کیریل شواکوف](https://github.com/ClickHouse/ClickHouse/pull/3375) + +#### رفع اشکال: {#bug-fixes-10} + +- ثابت موضوع را با `Dictionary` جداول برای `range_hashed` واژهنامهها. این خطا در نسخه 18.12.17 رخ داده است. [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) +- ثابت خطا در هنگام بارگذاری `range_hashed` واژهنامهها (پیام `Unsupported type Nullable (...)`). این خطا در نسخه 18.12.17 رخ داده است. [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- خطاهای ثابت در `pointInPolygon` تابع با توجه به تجمع محاسبات نادرست برای چند ضلعی با تعداد زیادی از راس واقع نزدیک به یکدیگر. [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) +- اگر پس از ادغام قطعات داده, کنترلی برای بخش حاصل از نتیجه همان ادغام در ماکت دیگر متفاوت, نتیجه ادغام حذف شده است و بخش داده ها از ماکت های دیگر دانلود (این رفتار صحیح است). اما پس از دانلود بخش داده ها, این می تواند به مجموعه کار به دلیل یک خطا که بخشی در حال حاضر وجود دارد اضافه نمی شود (به این دلیل که بخش داده ها با برخی از تاخیر پس از ادغام حذف شد). این امر منجر به تلاش چرخه ای برای دانلود داده های مشابه. [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) +- محاسبه نادرست ثابت از مصرف کل حافظه توسط نمایش داده شد (به دلیل محاسبه نادرست `max_memory_usage_for_all_queries` تنظیم نادرست کار می کرد و `MemoryTracking` متریک مقدار نادرست بود). این خطا در نسخه 18.12.13 رخ داده است. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) +- ثابت قابلیت های `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` این خطا در نسخه 18.12.13 رخ داده است. [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) +- تهیه غیر ضروری ثابت از ساختارهای داده برای `JOIN`بازدید کنندگان بر روی سرور که شروع پرس و جو در صورتی که `JOIN` تنها بر روی سرور از راه دور انجام می شود. [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) +- اشکالات ثابت در `Kafka` موتور: بن بست پس از استثنا در هنگام شروع به خواندن داده ها و قفل پس از اتمام [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- برای `Kafka` جداول اختیاری `schema` پارامتر تصویب نشد (طرح از `Cap'n'Proto` قالب). [اطلاعات دقیق](https://github.com/ClickHouse/ClickHouse/pull/3150) +- اگر این گروه از باغ وحش سرور است سرور است که اتصال را قبول اما پس از آن بلافاصله آن را به جای پاسخ به از دست دادن ClickHouse انتخاب برای اتصال به سرور دیگری. قبلا این خطا را تولید کرد `Cannot read all data. Bytes read: 0. Bytes expected: 4.` و سرور نمی تواند شروع. [8218رف3](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) +- اگر این گروه از سرور باغ وحش شامل سرور که پرس و جو دی ان اس خطا می گرداند, این سرویس دهنده نادیده گرفته می شوند. [17ب8209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) +- تبدیل نوع ثابت بین `Date` و `DateTime` هنگام وارد کردن داده ها در `VALUES` قالب (اگر `input_format_values_interpret_expressions = 1`). قبلا, تبدیل بین مقدار عددی تعداد روز در زمان عصر یونیکس و برچسب زمان یونیکس انجام شد, که منجر به نتایج غیر منتظره. [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) +- اصلاح نوع تبدیل بین `Decimal` و اعداد صحیح. [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) +- خطاهای ثابت در `enable_optimize_predicate_expression` تنظیمات. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3231) +- یک خطای تجزیه کننده در فرمت سی سی اس وی با اعداد ممیز شناور ثابت شده است اگر جدا کننده سی سی اس وی غیر پیش فرض استفاده شود مانند `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) +- ثابت `arrayCumSumNonNegative` تابع (این مقادیر منفی تجمع می یابد اگر باتری کمتر از صفر است). [الکسی استدیو](https://github.com/ClickHouse/ClickHouse/pull/3163) +- ثابت چگونه `Merge` جداول در بالای کار `Distributed` جداول هنگام استفاده از `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) +- رفع اشکال در `ALTER UPDATE` پرس و جو. +- اشکالات ثابت در `odbc` تابع جدول که در نسخه ظاهر شد 18.12. [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) +- ثابت بهره برداری از توابع مجموع با `StateArray` ترکیب کننده ها [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) +- ثابت تصادف در هنگام تقسیم یک `Decimal` ارزش صفر. [69د6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) +- خروجی ثابت از انواع برای عملیات با استفاده از `Decimal` و استدلال عدد صحیح. [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) +- ثابت segfault در طول `GROUP BY` روشن `Decimal128`. [3359با06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) +- این `log_query_threads` تنظیم (ورود اطلاعات در مورد هر موضوع اجرای پرس و جو) در حال حاضر اثر تنها در صورتی که `log_queries` گزینه (ورود اطلاعات در مورد نمایش داده شد) به 1 تنظیم شده است. از زمان `log_query_threads` گزینه به طور پیش فرض فعال, اطلاعات در مورد موضوعات قبلا وارد شده بود حتی اگر ورود به سیستم پرس و جو غیر فعال شد. [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) +- ثابت خطا در توزیع, بهره برداری از quantiles aggregate function (پیام خطا `Not found column quantile...`). [292ا8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) +- ثابت مشکل سازگاری در هنگام کار بر روی یک خوشه از نسخه 18.12.17 سرور و سرور های قدیمی تر در همان زمان. برای نمایش داده شد توزیع شده با گروه های کلید از هر دو ثابت و غیر ثابت طول اگر وجود دارد مقدار زیادی از داده ها به کل بازگشت داده بود و نه همیشه به طور کامل جمع (دو ردیف مختلف شامل همان جمع کلید). [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) +- دست زدن به ثابت تعویض در `clickhouse-performance-test`, اگر پرس و جو شامل تنها بخشی از تعویض اعلام شده در تست. [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) +- ثابت خطا در هنگام استفاده از `FINAL` با `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- ثابت خطا در هنگام استفاده از `PREWHERE` بیش از ستون که در طول اضافه شد `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- اضافه شدن یک چک برای عدم وجود `arrayJoin` برای `DEFAULT` و `MATERIALIZED` عبارات. قبلا, `arrayJoin` منجر به خطا در هنگام قرار دادن داده ها. [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) +- اضافه شدن یک چک برای عدم وجود `arrayJoin` در یک `PREWHERE` بند بند. قبلا, این منجر به پیام هایی مانند `Size ... doesn't match` یا `Unknown compression method` هنگام اجرای نمایش داده شد. [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) +- ثابت segfault است که می تواند رخ دهد در موارد نادر پس از بهینه سازی است که جایگزین شده و زنجیره ای از برابری با ارزیابی مربوطه در بیان. [هشدار داده می شود](https://github.com/ClickHouse/ClickHouse/pull/3339) +- اصلاحات جزیی به `clickhouse-benchmark`: قبلا, اطلاعات مربوط به مشتری به سرور ارسال نمی شد; در حال حاضر تعداد نمایش داده شد اجرا شده است با دقت بیشتری محاسبه زمانی که بستن و برای محدود کردن تعداد تکرار. [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-1} + +- حذف `allow_experimental_decimal_type` انتخاب این `Decimal` نوع داده برای استفاده پیش فرض در دسترس است. [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) + +## انتشار کلیک 18.12 {#clickhouse-release-18-12} + +### ClickHouse انتشار 18.12.17, 2018-09-16 {#clickhouse-release-18-12-17-2018-09-16} + +#### ویژگی های جدید: {#new-features-2} + +- `invalidate_query` (قابلیت مشخص کردن پرس و جو برای بررسی اینکه یک فرهنگ لغت خارجی باید به روز شود) برای اجرا `clickhouse` منبع. [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) +- توانایی استفاده را اضافه کرد `UInt*`, `Int*` و `DateTime` انواع داده ها (همراه با `Date` نوع) به عنوان یک `range_hashed` کلید فرهنگ لغت خارجی که مرزهای محدوده را تعریف می کند. حالا `NULL` می توان برای تعیین محدوده باز استفاده کرد. [واسیلی نمکو](https://github.com/ClickHouse/ClickHouse/pull/3123) +- این `Decimal` نوع در حال حاضر پشتیبانی می کند `var*` و `stddev*` توابع مجموع. [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- این `Decimal` نوع در حال حاضر پشتیبانی از توابع ریاضی (`exp`, `sin` و به همین ترتیب.) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- این `system.part_log` جدول در حال حاضر `partition_id` ستون. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### رفع اشکال: {#bug-fixes-11} + +- `Merge` در حال حاضر به درستی کار می کند `Distributed` میز [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3159) +- ناسازگاری ثابت (وابستگی غیر ضروری به `glibc` نسخه) ساخته شده است که غیر ممکن است برای اجرای کلیک بر روی `Ubuntu Precise` و نسخه های قدیمی تر. ناسازگاری در نسخه 18.12.13 ظاهر شد. [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) +- خطاهای ثابت در `enable_optimize_predicate_expression` تنظیمات. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3107) +- ثابت یک موضوع کوچک با سازگاری به عقب که به نظر می رسد در هنگام کار با یک خوشه از کپی در نسخه های زودتر از 18.12.13 و به طور همزمان ایجاد یک کپی جدید از یک جدول بر روی یک سرور با یک نسخه جدیدتر (نشان داده شده در پیام `Can not clone replica, because the ... updated to new ClickHouse version` که منطقی است اما نباید اتفاق می افتد). [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-2} + +- این `enable_optimize_predicate_expression` گزینه به طور پیش فرض فعال (که است و نه خوش بینانه). اگر تجزیه و تحلیل پرس و جو خطا رخ می دهد که مربوط به جستجو برای نام ستون مجموعه `enable_optimize_predicate_expression` به 0. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3107) + +### ClickHouse انتشار 18.12.14, 2018-09-13 {#clickhouse-release-18-12-14-2018-09-13} + +#### ویژگی های جدید: {#new-features-3} + +- اضافه شدن پشتیبانی برای `ALTER UPDATE` نمایش داده شد. [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) +- اضافه شدن `allow_ddl` گزینه ای که دسترسی کاربر به پرس و جو دی ال را محدود می کند. [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) +- اضافه شدن `min_merge_bytes_to_use_direct_io` گزینه برای `MergeTree` موتورهای, که اجازه می دهد تا شما را به مجموعه یک خودداری برای اندازه کل ادغام (زمانی که بالاتر از حد خودداری, فایل های بخش داده خواهد شد با استفاده از اچ به کار گرفته). [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) +- این `system.merges` جدول سیستم در حال حاضر شامل `partition_id` ستون. [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) + +#### بهبود {#improvements-3} + +- اگر بخش داده ها در طول جهش بدون تغییر باقی می ماند, این است که توسط کپی دانلود کنید. [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) +- تکمیل خودکار برای نام تنظیمات در هنگام کار با در دسترس است `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) + +#### رفع اشکال: {#bug-fixes-12} + +- اضافه شدن یک چک برای اندازه ارریس که عناصر هستند `Nested` نوع زمینه در هنگام قرار دادن. [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) +- ثابت خطا به روز رسانی لغت نامه های خارجی با `ODBC` منبع و `hashed` انبار. این خطا در نسخه 18.12.13 رخ داده است. +- ثابت تصادف در هنگام ایجاد یک جدول موقت از پرس و جو با یک `IN` شرط. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3098) +- ثابت خطا در توابع کل برای ارریس است که می تواند داشته باشد `NULL` عناصر. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3097) + +### ClickHouse انتشار 18.12.13, 2018-09-10 {#clickhouse-release-18-12-13-2018-09-10} + +#### ویژگی های جدید: {#new-features-4} + +- اضافه شدن `DECIMAL(digits, scale)` نوع داده (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). برای فعال کردن از تنظیمات استفاده کنید `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) +- جدید `WITH ROLLUP` تغییردهنده برای `GROUP BY` (نحو جایگزین: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) +- در نمایش داده شد با پیوستن, شخصیت ستاره گسترش می یابد به یک لیست از ستون ها در تمام جداول, در انطباق با استاندارد گذاشتن. شما می توانید رفتار قدیمی با تنظیم بازگرداندن `asterisk_left_columns_only` به 1 در سطح پیکربندی کاربر. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2787) +- اضافه شدن پشتیبانی برای پیوستن با توابع جدول. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2907) +- تکمیل خودکار با فشار دادن زبانه در خانه مشتری. [سرگی شچربین](https://github.com/ClickHouse/ClickHouse/pull/2447) +- کنترل + ج در فاحشه خانه-مشتری پاک پرس و جو که وارد شد. [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) +- اضافه شدن `join_default_strictness` تنظیم (مقادیر: `"`, `'any'`, `'all'`). این اجازه می دهد تا شما را مشخص کنید `ANY` یا `ALL` برای `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) +- هر خط از ورود به سیستم سرور مربوط به پردازش پرس و جو نشان می دهد که شناسه پرس و جو. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- حالا شما می توانید سیاهههای مربوط به اجرای پرس و جو در خانه مشتری (با استفاده از `send_logs_level` تنظیمات). با پردازش پرس و جو توزیع, سیاهههای مربوط از تمام سرور های تهدیدی جدی. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- این `system.query_log` و `system.processes` (`SHOW PROCESSLIST`) جداول در حال حاضر اطلاعات در مورد تمام تنظیمات تغییر زمانی که شما یک پرس و جو (ساختار تو در تو از `Settings` اطلاعات دقیق اضافه شدن `log_query_settings` تنظیمات. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- این `system.query_log` و `system.processes` جداول در حال حاضر اطلاعات مربوط به تعدادی از موضوعات که در اجرای پرس و جو شرکت نشان می دهد (نگاه کنید به `thread_numbers` ستون). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- اضافه شده `ProfileEvents` شمارنده است که اندازه گیری زمان صرف شده در خواندن و نوشتن بر روی شبکه و خواندن و نوشتن بر روی دیسک, تعداد خطاهای شبکه, و زمان صرف انتظار زمانی که پهنای باند شبکه محدود است. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- اضافه شده `ProfileEvents`شمارنده است که شامل سیستم متریک از rusage (شما می توانید آنها را به دریافت اطلاعات در مورد CPU usage در userspace و هسته صفحه گسل و زمینه سوئیچ ها) و همچنین taskstats متریک (با استفاده از این برای به دست آوردن اطلاعات در مورد I/O منتظر زمان CPU صبر کنید زمان و مقدار اطلاعات خوانده شده و ثبت هر دو با و بدون صفحه کش). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- این `ProfileEvents` شمارنده در سطح جهانی و برای هر پرس و جو اعمال, و همچنین برای هر موضوع اعدام پرس و جو, که اجازه می دهد تا شما را به مشخصات مصرف منابع به طور مفصل. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- اضافه شدن `system.query_thread_log` جدول, که شامل اطلاعات در مورد هر موضوع اعدام پرس و جو. اضافه شدن `log_query_threads` تنظیمات. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- این `system.metrics` و `system.events` جداول در حال حاضر ساخته شده است در اسناد و مدارک. [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) +- اضافه شدن `arrayEnumerateDense` تابع. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2975) +- اضافه شدن `arrayCumSumNonNegative` و `arrayDifference` توابع. [الکسی استدیو](https://github.com/ClickHouse/ClickHouse/pull/2942) +- اضافه شدن `retention` تابع جمع. [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2887) +- حالا شما می توانید اضافه کنید (ادغام) ایالات کل توابع با استفاده از اپراتور به علاوه و ضرب ایالات کل توابع توسط یک ثابت نامنفی. [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) +- جداول در خانواده ادغام در حال حاضر ستون مجازی `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### ویژگی های تجربی: {#experimental-features-1} + +- اضافه شدن `LowCardinality(T)` نوع داده. این نوع داده به طور خودکار یک فرهنگ لغت محلی از ارزش ها ایجاد می کند و اجازه می دهد تا پردازش داده ها بدون باز کردن فرهنگ لغت. [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) +- اضافه شده یک کش از توابع دستگاه گوارش وارد شده و یک شمارنده برای تعداد استفاده قبل از کامپایل. به جیت کامپایل عبارات, فعال کردن `compile_expressions` تنظیمات. [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) + +#### بهبود: {#improvements-4} + +- ثابت مشکل با تجمع نامحدود از ورود به سیستم تکرار زمانی که کپی رها وجود دارد. اضافه شده یک حالت بهبود موثر برای کپی با تاخیر طولانی. +- بهبود عملکرد `GROUP BY` هنگامی که یکی از رشته ها رشته است و دیگران طول ثابت با زمینه های تجمع های متعدد. +- بهبود عملکرد در هنگام استفاده از `PREWHERE` و با انتقال ضمنی عبارات در `PREWHERE`. +- بهبود عملکرد تجزیه برای فرمت های متن (`CSV`, `TSV`). [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) +- بهبود عملکرد رشته خواندن و جذب در فرمت های باینری. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2955) +- افزایش عملکرد و کاهش مصرف حافظه برای نمایش داده شد به `system.tables` و `system.columns` هنگامی که تعداد بسیار زیادی از جداول در یک سرور وجود دارد. [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) +- رفع مشکل عملکرد در مورد یک جریان بزرگ از نمایش داده شد که منجر به خطا ( `_dl_addr` عملکرد در قابل مشاهده است `perf top` اما سرور پردازنده بسیار استفاده نمی شود). [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) +- شرایط به نظر بازیگران (وقتی که `enable_optimize_predicate_expression` فعال است). [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2907) +- بهبود عملکرد برای `UUID` نوع داده. [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) +- این `UUID` نوع داده ها در لغت نامه کیمیاگر پشتیبانی می شود. [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) +- این `visitParamExtractRaw` تابع به درستی کار می کند با ساختارهای تو در تو. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2974) +- هنگامی که `input_format_skip_unknown_fields` تنظیم فعال است, زمینه های شی در `JSONEachRow` قالب به درستی قلم. [بلکجک](https://github.com/ClickHouse/ClickHouse/pull/2958) +- برای یک `CASE` بیان با شرایط, شما هم اکنون می توانید حذف `ELSE` که معادل است `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) +- ایست عملیات هم اکنون می توانید پیکربندی شود در هنگام کار با باغ وحش. [اوریخی](https://github.com/ClickHouse/ClickHouse/pull/2971) +- شما می توانید افست برای مشخص `LIMIT n, m` به عنوان `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- شما می توانید از `SELECT TOP n` نحو به عنوان یک جایگزین برای `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- افزایش اندازه صف برای نوشتن به جداول سیستم, بنابراین `SystemLog parameter queue is full` خطا اغلب اتفاق نمی افتد. +- این `windowFunnel` تابع مجموع در حال حاضر پشتیبانی از اتفاقاتی که با شرایط متعدد. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2801) +- ستون های تکراری را می توان در یک `USING` بند برای `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) +- `Pretty` فرمت در حال حاضر محدودیتی در تراز ستون های عرض است. استفاده از `output_format_pretty_max_column_pad_width` تنظیمات. اگر مقدار گسترده تر است, هنوز هم در تمامیت خود را نمایش داده خواهد شد, اما سلول های دیگر در جدول نخواهد بود بیش از حد گسترده. [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) +- این `odbc` تابع جدول در حال حاضر اجازه می دهد تا به شما برای مشخص کردن پایگاه داده/نام طرح. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2885) +- توانایی استفاده از یک نام کاربری مشخص شده در `clickhouse-client` فایل پیکربندی. [ولادیمیر کوزبین](https://github.com/ClickHouse/ClickHouse/pull/2909) +- این `ZooKeeperExceptions` شمارنده به سه شمارنده تقسیم شده است: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions` و `ZooKeeperOtherExceptions`. +- `ALTER DELETE` نمایش داده شد برای نمایش محقق کار می کنند. +- تصادفی اضافه شده در هنگام اجرای موضوع پاکسازی به صورت دوره ای برای `ReplicatedMergeTree` جداول به منظور جلوگیری از خوشه بار دوره ای زمانی که تعداد بسیار زیادی از وجود دارد `ReplicatedMergeTree` میز +- پشتیبانی از `ATTACH TABLE ... ON CLUSTER` نمایش داده شد. [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) + +#### رفع اشکال: {#bug-fixes-13} + +- ثابت موضوع را با `Dictionary` جداول (پرتاب `Size of offsets doesn't match size of column` یا `Unknown compression method` استثنا). این اشکال در نسخه 18.10.3 ظاهر شد. [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) +- رفع اشکال هنگام ادغام `CollapsingMergeTree` جداول اگر یکی از قطعات داده خالی است (این قطعات در طول ادغام و یا تشکیل `ALTER DELETE` اگر تمام داده ها حذف شد), و `vertical` الگوریتم برای ادغام مورد استفاده قرار گرفت. [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) +- ثابت شرایط مسابقه در طول `DROP` یا `TRUNCATE` برای `Memory` جداول با همزمان `SELECT`, که می تواند به سقوط سرور منجر شود. این اشکال در نسخه 1.1.54388 ظاهر شد. [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) +- ثابت امکان از دست دادن داده ها در هنگام قرار دادن در `Replicated` جداول اگر `Session is expired` خطا بازگشته است (از دست دادن داده ها را می توان با شناسایی `ReplicatedDataLoss` متریک). این خطا در نسخه 1.1.54378 رخ داده است. [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) +- ثابت segfault در طول `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) +- ثابت خطا جستجو نام ستون زمانی که `WHERE` بیان به طور کامل شامل یک نام ستون واجد شرایط, مانند `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) +- ثابت “Not found column” خطا که هنگام اجرای نمایش داده شد توزیع رخ داده است اگر یک ستون متشکل از یک عبارت در با یک زیرخاکی از یک سرور از راه دور درخواست. [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) +- ثابت `Block structure mismatch in UNION stream: different number of columns` خطا که برای نمایش داده شد توزیع رخ داده است اگر یکی از خرده ریز محلی است و از سوی دیگر نمی باشد, و بهینه سازی حرکت به `PREWHERE` باعث شده است. [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) +- ثابت `pointInPolygon` تابع برای موارد خاصی از چند ضلعی غیر محدب. [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) +- ثابت نتیجه نادرست در هنگام مقایسه `nan` با اعداد صحیح. [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) +- ثابت خطا در `zlib-ng` کتابخانه ای که می تواند در موارد نادر به پیش فرض منجر شود. [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) +- ثابت نشت حافظه در هنگام قرار دادن به یک جدول با `AggregateFunction` ستون, اگر دولت از تابع کل ساده نیست (اختصاص حافظه به طور جداگانه), و اگر یک درخواست درج نتایج در بلوک های کوچک متعدد. [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) +- ثابت شرایط مسابقه در هنگام ایجاد و حذف همان `Buffer` یا `MergeTree` جدول به طور همزمان. +- ثابت امکان یک پشتک زمانی که مقایسه تاپل ساخته شده از برخی از انواع غیر بدیهی, مانند تاپل. [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) +- ثابت امکان یک پشتک زمانی که در حال اجرا خاص `ON CLUSTER` نمایش داده شد. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2960) +- ثابت خطا در `arrayDistinct` تابع برای `Nullable` عناصر مجموعه. [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) +- این `enable_optimize_predicate_expression` گزینه در حال حاضر به درستی پشتیبانی از موارد با `SELECT *`. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2929) +- ثابت شده است که در هنگام راه اندازی مجدد جلسه باغ وحش. [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) +- مسدود کردن پتانسیل ثابت در هنگام کار با باغ وحش. +- کد نادرست ثابت برای اضافه کردن ساختارهای داده تو در تو `SummingMergeTree`. +- هنگام تخصیص حافظه برای ایالت های توابع کل, تراز دلخواه به درستی در نظر گرفته شود, که این امکان را به استفاده از عملیات که نیاز به هم ترازی در هنگام اجرای کشورهای توابع دانه. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) + +#### تعمیر امنیتی: {#security-fix} + +- استفاده ایمن از منابع داده او بی سی. تعامل با رانندگان بی سی با استفاده از یک جداگانه `clickhouse-odbc-bridge` روند. خطاها در رانندگان اد بی سی شخص ثالث دیگر باعث مشکلات با ثبات سرور و یا ناپایداری. [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) +- اعتبار سنجی نادرست ثابت از مسیر فایل در `catBoostPool` تابع جدول. [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) +- محتویات جداول سیستم (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas` و `replication_queue`) با توجه به دسترسی پیکربندی شده کاربر به پایگاه داده فیلتر شده است (`allow_databases`). [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2856) + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-3} + +- در نمایش داده شد با پیوستن, شخصیت ستاره گسترش می یابد به یک لیست از ستون ها در تمام جداول, در انطباق با استاندارد گذاشتن. شما می توانید رفتار قدیمی با تنظیم بازگرداندن `asterisk_left_columns_only` به 1 در سطح پیکربندی کاربر. + +#### ایجاد تغییرات: {#build-changes-2} + +- اکثر تست های یکپارچه سازی هم اکنون می توانید توسط متعهد اجرا می شود. +- چک سبک کد همچنین می توانید با ارتکاب اجرا می شود. +- این `memcpy` پیاده سازی به درستی در هنگام ساخت در لینوکس7/فدورا انتخاب شده است. [اتین Champetier](https://github.com/ClickHouse/ClickHouse/pull/2912) +- هنگام استفاده از صدای شیپور برای ساخت, برخی از هشدارهای از `-Weverything` اضافه شده است, در علاوه بر این به طور منظم `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) +- اشکال زدایی ساخت با استفاده از `jemalloc` گزینه اشکال زدایی. +- رابط کتابخانه برای تعامل با باغ وحش انتزاعی اعلام شده است. [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) + +## انتشار کلیک 18.10 {#clickhouse-release-18-10} + +### انتشار کلیک خانه 18.10.3, 2018-08-13 {#clickhouse-release-18-10-3-2018-08-13} + +#### ویژگی های جدید: {#new-features-5} + +- قام را می توان برای تکرار استفاده می شود. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) +- اضافه شدن توابع `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64` و `murmurHash3_128` علاوه بر موجود `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) +- پشتیبانی از Nullable types در ClickHouse ODBC driver (`ODBCDriver2` فرمت خروجی). [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) +- پشتیبانی از `UUID` در ستون های کلیدی. + +#### بهبود: {#improvements-5} + +- خوشه ها را می توان بدون راه اندازی مجدد سرور هنگام حذف از فایل های پیکربندی حذف کرد. [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) +- لغت نامه های خارجی را می توان بدون راه اندازی مجدد سرور حذف زمانی که از فایل های پیکربندی حذف شده است. [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) +- اضافه شده `SETTINGS` پشتیبانی از `Kafka` موتور جدول. [الکساندر مارشالو](https://github.com/ClickHouse/ClickHouse/pull/2781) +- بهبود برای `UUID` نوع داده (هنوز کامل نیست). [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) +- پشتیبانی از قطعات خالی پس از ادغام در `SummingMergeTree`, `CollapsingMergeTree` و `VersionedCollapsingMergeTree` موتورها. [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) +- سوابق قدیمی جهش های تکمیل شده حذف می شوند (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) +- اضافه شدن `system.merge_tree_settings` جدول [کیریل شواکوف](https://github.com/ClickHouse/ClickHouse/pull/2841) +- این `system.tables` جدول در حال حاضر ستون وابستگی: `dependencies_database` و `dependencies_table`. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2851) +- اضافه شدن `max_partition_size_to_drop` گزینه پیکربندی. [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) +- اضافه شدن `output_format_json_escape_forward_slashes` انتخاب [الکساندر بوچاروف](https://github.com/ClickHouse/ClickHouse/pull/2812) +- اضافه شدن `max_fetch_partition_retries_count` تنظیمات. [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) +- اضافه شدن `prefer_localhost_replica` تنظیم برای غیر فعال کردن اولویت برای یک ماکت محلی و رفتن به یک ماکت محلی بدون تعامل بین فرایند. [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) +- این `quantileExact` بازده عملکرد کل `nan` در مورد تجمع در خالی `Float32` یا `Float64` حاضر [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2855) + +#### رفع اشکال: {#bug-fixes-14} + +- حذف غیر ضروری فرار از پارامترهای رشته اتصال برای ان بی سی, ساخته شده است که غیر ممکن است برای ایجاد یک اتصال. این خطا در نسخه 18.6.0 رخ داده است. +- ثابت منطق برای پردازش `REPLACE PARTITION` دستورات در صف تکرار. اگر دو وجود دارد `REPLACE` منطق نادرست میتواند باعث شود که در صف تکرار باقی بمانند و اعدام نشوند. [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) +- رفع اشکال ادغام زمانی که تمام قطعات داده خالی بود (بخش هایی که از ادغام و یا از تشکیل شد `ALTER DELETE` اگر تمام داده ها حذف شد). این اشکال در نسخه 18.1.0 ظاهر شد. [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) +- ثابت خطا برای همزمان `Set` یا `Join`. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2823) +- ثابت `Block structure mismatch in UNION stream: different number of columns` خطایی که برای `UNION ALL` نمایش داده شد در داخل زیر پرس و جو اگر یکی از `SELECT` نمایش داده شد شامل نام ستون تکراری. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2094) +- ثابت نشت حافظه اگر یک استثنا رخ داده است در هنگام اتصال به یک سرور خروجی زیر. +- ثابت نادرست کد پاسخ کلیک مشتری در صورت خطا پرس و جو. +- رفتار نادرست ثابت از دیدگاه محقق حاوی متمایز. [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) + +#### تغییرات ناسازگار به عقب {#backward-incompatible-changes-4} + +- پشتیبانی حذف برای بررسی جدول نمایش داده شد برای جداول توزیع شده است. + +#### ایجاد تغییرات: {#build-changes-3} + +- تخصیص جایگزین شده است: `jemalloc` در حال حاضر به جای استفاده می شود `tcmalloc`. در برخی از حالات, این افزایش سرعت تا 20%. با این حال, نمایش داده شد که تا کند شده وجود دارد 20%. مصرف حافظه شده است حدود کاهش 10% در برخی از حالات, با ثبات بهبود یافته. با بارهای بسیار رقابتی, استفاده از پردازنده در فضای کاربری و در سیستم نشان می دهد فقط یک افزایش کمی. [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) +- استفاده از libressl از یک submodule. [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) +- استفاده از unixodbc از یک submodule. [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) +- استفاده از ماریادب-اتصال-ج از یک زیر زمینی. [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) +- اضافه شده فایل های تست عملکردی به مخزن که در دسترس بودن داده های تست بستگی دارد (در حال حاضر, بدون داده های تست خود را). + +## انتشار کلیک 18.6 {#clickhouse-release-18-6} + +### ClickHouse انتشار 18.6.0, 2018-08-02 {#clickhouse-release-18-6-0-2018-08-02} + +#### ویژگی های جدید: {#new-features-6} + +- اضافه شدن پشتیبانی برای در عبارات برای عضویت در نحو: + `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` + بیان باید یک زنجیره ای از تجهیزات پیوست شده توسط و اپراتور باشد. هر طرف از برابری می تواند یک بیان دلخواه بیش از ستون از یکی از جداول. استفاده از نام ستون به طور کامل واجد شرایط پشتیبانی می شود (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`) برای جدول سمت راست . [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) +- قام را می توان برای تکرار فعال کنید. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) + +#### بهبود: {#improvements-6} + +- سرور بخشی پچ از نسخه خود را به مشتری می گذرد. اطلاعات در مورد مولفه نسخه پچ در `system.processes` و `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) + +## انتشار کلیک 18.5 {#clickhouse-release-18-5} + +### ClickHouse انتشار 18.5.1, 2018-07-31 {#clickhouse-release-18-5-1-2018-07-31} + +#### ویژگی های جدید: {#new-features-7} + +- تابع هش اضافه شده است `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). + +#### بهبود: {#improvements-7} + +- حالا شما می توانید استفاده کنید `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) نسبت به تنظیم مقادیر در فایل های پیکربندی از متغیرهای محیط زیست. +- نسخه های غیر حساس به حروف اضافه شده است `coalesce`, `ifNull` و `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). + +#### رفع اشکال: {#bug-fixes-15} + +- رفع اشکال ممکن است در هنگام شروع یک ماکت [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). + +## انتشار کلیک 18.4 {#clickhouse-release-18-4} + +### ClickHouse انتشار 18.4.0, 2018-07-28 {#clickhouse-release-18-4-0-2018-07-28} + +#### ویژگی های جدید: {#new-features-8} + +- جداول سیستم اضافه شده است: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). +- اضافه شدن توانایی استفاده از یک تابع جدول به جای یک جدول به عنوان یک استدلال از یک `remote` یا `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). +- پشتیبانی از `HTTP Basic` احراز هویت در پروتکل تکرار [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). +- این `has` تابع در حال حاضر اجازه می دهد تا جستجو برای یک مقدار عددی در مجموعه ای از `Enum` مقادیر [ماکسیم خریسانف](https://github.com/ClickHouse/ClickHouse/pull/2699). +- پشتیبانی از اضافه کردن جدا پیام دلخواه در هنگام خواندن از `Kafka` [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2701). + +#### بهبود: {#improvements-8} + +- این `ALTER TABLE t DELETE WHERE` پرس و جو می کند قطعات داده است که توسط جایی که شرایط تحت تاثیر قرار نمی بازنویسی نیست [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). +- این `use_minimalistic_checksums_in_zookeeper` گزینه برای `ReplicatedMergeTree` جداول به طور پیش فرض فعال. این تنظیمات اضافه شده در نسخه 1.1.54378, 2018-04-16. نسخه هایی که مسن تر از 1.1.54378 هستند دیگر نمی توانند نصب شوند. +- پشتیبانی از در حال اجرا `KILL` و `OPTIMIZE` نمایش داده شد که مشخص `ON CLUSTER` [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2689). + +#### رفع اشکال: {#bug-fixes-16} + +- خطا را ثابت کرد `Column ... is not under an aggregate function and not in GROUP BY` برای تجمع با بیان در. این اشکال در نسخه 18.1.0 ظاهر شد. ([ببد780ب](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) +- رفع اشکال در `windowFunnel aggregate function` [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2735). +- رفع اشکال در `anyHeavy` تابع جمع ([الف212](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) +- تصادف سرور ثابت در هنگام استفاده از `countArray()` تابع جمع. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-5} + +- پارامترها برای `Kafka` موتور از تغییر یافت `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` به `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. اگر جداول خود استفاده کنید `kafka_schema` یا `kafka_num_consumers` پارامترهای, شما باید به صورت دستی ویرایش فایل های ابرداده `path/metadata/database/table.sql` و اضافه کردن `kafka_row_delimiter` پارامتر با `''` ارزش. + +## انتشار کلیک 18.1 {#clickhouse-release-18-1} + +### ClickHouse انتشار 18.1.0, 2018-07-23 {#clickhouse-release-18-1-0-2018-07-23} + +#### ویژگی های جدید: {#new-features-9} + +- پشتیبانی از `ALTER TABLE t DELETE WHERE` پرسوجو برای جداول ادغام غیر تکرار شده ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). +- پشتیبانی از انواع دلخواه برای `uniq*` خانواده از توابع کل ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). +- پشتیبانی از انواع دلخواه در مقایسه اپراتورها ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). +- این `users.xml` فایل اجازه می دهد تا تنظیم یک ماسک زیر شبکه در قالب `10.0.0.1/255.255.255.0`. این برای استفاده از ماسک برای شبکه های اینترنتی6 با صفر در وسط ضروری است ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). +- اضافه شدن `arrayDistinct` تابع ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). +- این SummingMergeTree موتور هم اکنون می توانید کار با AggregateFunction نوع ستون ([پان سنتانتین](https://github.com/ClickHouse/ClickHouse/pull/2566)). + +#### بهبود: {#improvements-9} + +- طرح شماره برای نسخه های انتشار تغییر کرده است. در حال حاضر بخش اول شامل سال انتشار (A. D. مسکو منطقه زمانی منهای 2000) بخش دوم شامل تعدادی به صورت عمده تغییرات را افزایش می دهد برای بسیاری منتشر شده) و بخش سوم پچ نسخه. منتشر شده هنوز هم به عقب سازگار هستند, مگر اینکه در غیر این صورت در تغییرات اعلام. +- تبدیل سریع تر اعداد ممیز شناور به یک رشته ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2664)). +- اگر برخی از ردیف در طول درج به دلیل خطاهای تجزیه قلم شد (این ممکن است با `input_allow_errors_num` و `input_allow_errors_ratio` تنظیمات را فعال کنید), تعداد ردیف قلم در حال حاضر به ورود به سیستم سرور نوشته شده است ([لوناردو سیسیچی](https://github.com/ClickHouse/ClickHouse/pull/2669)). + +#### رفع اشکال: {#bug-fixes-17} + +- ثابت فرمان کوتاه برای جداول موقت ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2624)). +- ثابت بن بست نادر در کتابخانه مشتری باغ وحش که رخ داده است زمانی که یک خطای شبکه وجود دارد در حالی که خواندن پاسخ ([315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). +- ثابت خطا در طول بازیگران به Nullable types ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). +- ثابت نتیجه نادرست از `maxIntersection()` تابع زمانی که مرزهای فواصل همزمان ([مایکل فورمور](https://github.com/ClickHouse/ClickHouse/pull/2657)). +- تحول نادرست ثابت از زنجیره بیان و یا در یک استدلال تابع ([chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). +- تخریب عملکرد ثابت برای نمایش داده شد حاوی `IN (subquery)` عبارات در داخل یکی دیگر از خرده فروشی ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). +- ناسازگاری ثابت بین سرورها با نسخه های مختلف در نمایش داده شد توزیع شده است که با استفاده از یک `CAST` تابع است که در حروف بزرگ نیست ([ف8چ4د6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). +- اضافه شده از دست رفته به نقل از شناسه برای نمایش داده شد به سندرم تونل کارپ خارجی ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-6} + +- تبدیل یک رشته حاوی عدد صفر به تاریخ ساعت کار نمی کند. مثال: `SELECT toDateTime('0')`. این نیز دلیل است که `DateTime DEFAULT '0'` در جداول و همچنین کار نمی کند `0` در لغت نامه. راه حل: جایگزین کردن `0` با `0000-00-00 00:00:00`. + +## انتشار کلیک 1.1 {#clickhouse-release-1-1} + +### ClickHouse انتشار 1.1.54394, 2018-07-12 {#clickhouse-release-1-1-54394-2018-07-12} + +#### ویژگی های جدید: {#new-features-10} + +- اضافه شدن `histogram` تابع جمع ([میخیل سورین](https://github.com/ClickHouse/ClickHouse/pull/2521)). +- حالا `OPTIMIZE TABLE ... FINAL` می توان بدون مشخص کردن پارتیشن ها برای `ReplicatedMergeTree` ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2600)). + +#### رفع اشکال: {#bug-fixes-18} + +- رفع مشکل با یک ایست بسیار کوچک برای سوکت (یک ثانیه) برای خواندن و نوشتن در هنگام ارسال و دانلود داده تکرار, ساخته شده است که غیر ممکن است برای دانلود قطعات بزرگتر اگر یک بار بر روی شبکه و یا دیسک وجود دارد (در تلاش دوره ای برای دانلود قطعات منجر). این خطا در نسخه 1.1.54388 رخ داده است. +- مشکلات ثابت در هنگام استفاده از ریشه کن کردن در باغ وحش اگر شما بلوک های داده های تکراری در جدول قرار داده است. +- این `has` تابع در حال حاضر به درستی برای مجموعه ای با عناصر قابل تعویض کار می کند ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). +- این `system.tables` جدول در حال حاضر به درستی کار می کند زمانی که در نمایش داده شد توزیع استفاده می شود. این `metadata_modification_time` و `engine_full` ستون در حال حاضر غیر مجازی. ثابت خطا که رخ داده است اگر تنها این ستون از جدول تردید شد. +- ثابت چگونه خالی `TinyLog` جدول پس از قرار دادن یک بلوک داده خالی کار می کند ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). +- این `system.zookeeper` جدول کار می کند اگر ارزش گره در باغ وحش تهی است. + +### ClickHouse انتشار 1.1.54390, 2018-07-06 {#clickhouse-release-1-1-54390-2018-07-06} + +#### ویژگی های جدید: {#new-features-11} + +- نمایش داده شد را می توان در ارسال `multipart/form-data` قالب (در `query` رشته), مفید است که اگر داده های خارجی نیز برای پردازش پرس و جو ارسال ([اولگا هوستیکوا](https://github.com/ClickHouse/ClickHouse/pull/2490)). +- اضافه شدن توانایی برای فعال یا غیر فعال کردن پردازش نقل قول یک یا دو هنگام خواندن داده ها در فرمت سی سی.وی. شما می توانید این را در پیکربندی `format_csv_allow_single_quotes` و `format_csv_allow_double_quotes` تنظیمات ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2574)). +- حالا `OPTIMIZE TABLE ... FINAL` می توان بدون مشخص کردن پارتیشن برای انواع غیر تکرار استفاده کرد `MergeTree` ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2599)). + +#### بهبود: {#improvements-10} + +- بهبود عملکرد, کاهش مصرف حافظه, و ردیابی مصرف حافظه صحیح با استفاده از اپراتور در زمانی که یک شاخص جدول می تواند مورد استفاده قرار گیرد ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). +- حذف چک کردن کار برکنار شده از چک سام در هنگام اضافه کردن یک بخش داده ها. این مهم است که تعداد زیادی از کپی وجود دارد, چرا که در این موارد تعداد کل چک به نفر برابر بود^2. +- اضافه شدن پشتیبانی برای `Array(Tuple(...))` نشانوندها برای `arrayEnumerateUniq` تابع ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). +- اضافه شده `Nullable` پشتیبانی از `runningDifference` تابع ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). +- بهبود عملکرد تجزیه و تحلیل پرس و جو زمانی که تعداد بسیار زیادی از عبارات وجود دارد ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). +- انتخاب سریع تر از قطعات داده برای ادغام در `ReplicatedMergeTree` میز بازیابی سریع تر از جلسه باغ وحش ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). +- این `format_version.txt` پرونده برای `MergeTree` جداول دوباره ایجاد اگر از دست رفته است, که حس می کند اگر تاتر است پس از کپی کردن ساختار دایرکتوری بدون فایل راه اندازی ([Ciprian Hacman](https://github.com/ClickHouse/ClickHouse/pull/2593)). + +#### رفع اشکال: {#bug-fixes-19} + +- رفع اشکال در هنگام کار با باغ وحش است که می تواند غیر ممکن است برای بازیابی جلسه و خواندنی ایالات جداول قبل از راه اندازی مجدد سرور. +- رفع اشکال در هنگام کار با باغ وحش است که می تواند در گره های قدیمی در نتیجه حذف نمی شود اگر جلسه قطع شده است. +- ثابت خطا در `quantileTDigest` تابع برای استدلال شناور (این اشکال در نسخه 1.1.54388 معرفی شد) ([میخیل سورین](https://github.com/ClickHouse/ClickHouse/pull/2553)). +- رفع اشکال در شاخص برای جداول ادغام اگر ستون کلید اصلی در داخل تابع برای تبدیل انواع بین اعداد صحیح امضا و بدون علامت از همان اندازه واقع شده است ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). +- ثابت segfault اگر `macros` استفاده می شود اما در فایل پیکربندی نیستند ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). +- تعویض ثابت به پایگاه داده به طور پیش فرض در هنگام اتصال مجدد مشتری ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). +- رفع اشکال که زمانی رخ داده است `use_index_for_in_with_subqueries` تنظیم غیر فعال شد. + +#### تعمیر امنیتی: {#security-fix-1} + +- ارسال فایل های دیگر ممکن است زمانی که به خروجی زیر متصل می شود (`LOAD DATA LOCAL INFILE`). + +### ClickHouse انتشار 1.1.54388, 2018-06-28 {#clickhouse-release-1-1-54388-2018-06-28} + +#### ویژگی های جدید: {#new-features-12} + +- پشتیبانی از `ALTER TABLE t DELETE WHERE` پرس و جو برای جداول تکرار. اضافه شدن `system.mutations` جدول برای پیگیری پیشرفت این نوع از نمایش داده شد. +- پشتیبانی از `ALTER TABLE t [REPLACE|ATTACH] PARTITION` پرس و جو برای \* جداول ادغام. +- پشتیبانی از `TRUNCATE TABLE` پرسوجو ([زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2260)) +- چند جدید `SYSTEM` نمایش داده شد برای جداول تکرار (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). +- توانایی نوشتن به یک جدول با موتور خروجی زیر و عملکرد جدول مربوطه اضافه شده است ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2294)). +- اضافه شدن `url()` عملکرد جدول و `URL` موتور جدول ([الکساندر Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). +- اضافه شدن `windowFunnel` تابع جمع ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2352)). +- جدید `startsWith` و `endsWith` توابع برای رشته ها ([وادیم پلختینسکی](https://github.com/ClickHouse/ClickHouse/pull/2429)). +- این `numbers()` تابع جدول در حال حاضر اجازه می دهد تا شما را به مشخص افست ([زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2535)). +- رمز عبور به `clickhouse-client` می توان تعاملی وارد شده است. +- سیاهههای مربوط به سرور هم اکنون می توانید به وبلاگ ارسال می شود ([الکساندر کرشنینیکف](https://github.com/ClickHouse/ClickHouse/pull/2459)). +- پشتیبانی از ورود به لغت نامه ها با یک منبع کتابخانه مشترک ([الکساندر Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). +- پشتیبانی برای سفارشی CSV delimiters ([ایوان ژوکوف](https://github.com/ClickHouse/ClickHouse/pull/2263)) +- اضافه شدن `date_time_input_format` تنظیمات. اگر این تنظیم را تغییر دهید `'best_effort'`, ارزش تاریخ ساعت خواهد شد در طیف گسترده ای از فرمت های به عنوان خوانده شده. +- اضافه شدن `clickhouse-obfuscator` ابزار برای مبهم و تاریک کردن داده ها. مثال طریقه استفاده: انتشار داده های مورد استفاده در تست عملکرد. + +#### ویژگی های تجربی: {#experimental-features-2} + +- توانایی محاسبه اضافه شده است `and` استدلال تنها جایی که مورد نیاز هستند ([کشتن از سر ترحم تسارکوا](https://github.com/ClickHouse/ClickHouse/pull/2272)) +- مجموعه کیت به کد بومی در حال حاضر برای برخی از عبارات در دسترس است ([پایوس](https://github.com/ClickHouse/ClickHouse/pull/2277)). + +#### رفع اشکال: {#bug-fixes-20} + +- تکراری دیگر برای پرس و جو با ظاهر `DISTINCT` و `ORDER BY`. +- نمایش داده شد با `ARRAY JOIN` و `arrayFilter` دیگر نتیجه نادرست بازگشت. +- هنگام خواندن یک ستون جداگانه از یک ساختار تو در تو خطایی رخ داد ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). +- ثابت خطا در هنگام تجزیه و تحلیل نمایش داده شد با داشتن بند مانند `HAVING tuple IN (...)`. +- ثابت خطا در هنگام تجزیه و تحلیل نمایش داده شد با نام مستعار بازگشتی. +- ثابت خطا در هنگام خواندن از ReplacingMergeTree با یک بیماری در PREWHERE فیلتر است که تمام ردیف ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). +- هنگام استفاده از جلسات در رابط اچ تی پی تنظیمات پروفایل کاربر اعمال نشد. +- ثابت چگونه تنظیمات از پارامترهای خط فرمان در خانه کلیک اعمال می شود-محلی. +- کتابخانه مشتری باغ وحش در حال حاضر با استفاده از فاصله جلسه دریافت شده از سرور. +- رفع اشکال در کتابخانه مشتری باغ وحش زمانی که مشتری منتظر پاسخ سرور طولانی تر از ایست. +- هرس ثابت قطعات برای نمایش داده شد با شرایط در ستون های کلیدی پارتیشن ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). +- ادغام در حال حاضر ممکن است پس از `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). +- نقشه برداری نوع در تابع جدول او بی سی ثابت شده است ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2268)). +- مقایسه نوع برای ثابت شده است `DateTime` با و بدون منطقه زمانی ([الکساندر بوچاروف](https://github.com/ClickHouse/ClickHouse/pull/2400)). +- تجزیه نحوی ثابت و قالب بندی از `CAST` اپراتور +- درج ثابت به یک نمایش تحقق برای موتور جدول توزیع شده است ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). +- ثابت شرایط مسابقه در هنگام نوشتن داده ها از `Kafka` موتور به نمایش تحقق ([یانگکوان لیو](https://github.com/ClickHouse/ClickHouse/pull/2448)). +- در از راه دور() تابع جدول ثابت شده است. +- رفتار خروج ثابت از `clickhouse-client` در حالت چند خطی ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). + +#### بهبود: {#improvements-11} + +- وظایف پس زمینه در جداول تکرار در حال حاضر در یک استخر موضوع به جای در موضوعات جداگانه انجام می شود ([سیلو کاراژیا](https://github.com/ClickHouse/ClickHouse/pull/1722)). +- بهبود عملکرد فشرده سازی 2.4. +- تجزیه و تحلیل سریع تر برای نمایش داده شد با تعداد زیادی از می پیوندد و زیر نمایش داده شد. +- کش دی ان اس در حال حاضر به طور خودکار به روز هنگامی که بیش از حد بسیاری از خطاهای شبکه وجود دارد. +- درج جدول دیگر رخ می دهد اگر درج به یکی از دیدگاه های تحقق ممکن نیست چرا که بیش از حد بسیاری از قطعات. +- اصلاح اختلاف در شمارنده رویداد `Query`, `SelectQuery` و `InsertQuery`. +- عبارات مانند `tuple IN (SELECT tuple)` مجاز اگر انواع تاپل مطابقت. +- سرور با جداول تکرار می توانید شروع به حتی اگر شما باغ وحش پیکربندی نشده است. +- هنگام محاسبه تعداد هسته های پردازنده در دسترس, محدودیت در گروه های گروه در حال حاضر در نظر گرفته شود ([اتری شارما](https://github.com/ClickHouse/ClickHouse/pull/2325)). +- اضافه شده پیون برای دایرکتوری پیکربندی در فایل پیکربندی سیستم ([میخیل شیریو](https://github.com/ClickHouse/ClickHouse/pull/2421)). + +#### ایجاد تغییرات: {#build-changes-4} + +- کامپایلر جی سی8 را می توان برای ساخت استفاده می شود. +- اضافه شده توانایی برای ساخت llvm از submodule. +- این نسخه از librdkafka کتابخانه به روز شده است برای v0.11.4. +- اضافه شدن توانایی استفاده از کتابخانه سیستم لیبکپویید. نسخه کتابخانه شده است به 0.4.0 به روز شد. +- ثابت ساخت با استفاده از کتابخانه وکتورکلااس ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). +- در حال حاضر تولید فایل برای نینجا به طور پیش فرض (مانند هنگام استفاده از `-G Ninja`). +- اضافه شدن قابلیت استفاده از کتابخانه لیبتاینفو به جای نوشیدن شراب ([جورجی کندراتیف](https://github.com/ClickHouse/ClickHouse/pull/2519)). +- رفع یک درگیری فایل هدر در فدورا پوست دباغی نشده ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-7} + +- حذف فرار در `Vertical` و `Pretty*` فرمت ها و حذف `VerticalRaw` قالب. +- اگر سرور با نسخه 1.1.54388 (یا جدیدتر) و سرور با نسخه های قدیمی تر به طور همزمان در یک پرس و جو توزیع استفاده می شود و پرس و جو است `cast(x, 'Type')` بیان بدون `AS` کلمه کلیدی و کلمه ندارد `cast` در بزرگ, یک استثنا خواهد شد با یک پیام مانند پرتاب `Not found column cast(0, 'UInt8') in block`. تخلیه: به روز رسانی سرور در کل خوشه. + +### ClickHouse انتشار 1.1.54385, 2018-06-01 {#clickhouse-release-1-1-54385-2018-06-01} + +#### رفع اشکال: {#bug-fixes-21} + +- ثابت خطا که در برخی موارد باعث عملیات باغ وحش برای جلوگیری از. + +### ClickHouse انتشار 1.1.54383, 2018-05-22 {#clickhouse-release-1-1-54383-2018-05-22} + +#### رفع اشکال: {#bug-fixes-22} + +- ثابت کاهش سرعت صف تکرار اگر یک جدول است بسیاری از کپی. + +### ClickHouse انتشار 1.1.54381, 2018-05-14 {#clickhouse-release-1-1-54381-2018-05-14} + +#### رفع اشکال: {#bug-fixes-23} + +- ثابت نشت گره در باغ وحش زمانی که خانه رعیتی اتصال به سرور باغ وحش از دست می دهد. + +### ClickHouse انتشار 1.1.54380, 2018-04-21 {#clickhouse-release-1-1-54380-2018-04-21} + +#### ویژگی های جدید: {#new-features-13} + +- تابع جدول اضافه شده است `file(path, format, structure)`. به عنوان مثال خواندن بایت از `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. + +#### بهبود: {#improvements-12} + +- زیرمجموعه ها را می توان در `()` براکت به منظور افزایش خوانایی پرس و جو. به عنوان مثال: `(SELECT 1) UNION ALL (SELECT 1)`. +- ساده `SELECT` نمایش داده شد از `system.processes` جدول در شامل نمی شود `max_concurrent_queries` حد. + +#### رفع اشکال: {#bug-fixes-24} + +- رفتار نادرست ثابت از `IN` اپراتور هنگام انتخاب از `MATERIALIZED VIEW`. +- فیلتر نادرست ثابت توسط شاخص پارتیشن در عبارات مانند `partition_key_column IN (...)`. +- ناتوانی ثابت برای اجرا `OPTIMIZE` پرس و جو در ماکت غیر رهبر اگر `REANAME` بر روی میز انجام شد. +- خطای مجوز هنگام اجرای ثابت شد `OPTIMIZE` یا `ALTER` نمایش داده شد در یک ماکت غیر رهبر. +- انجماد ثابت `KILL QUERY`. +- رفع خطا در کتابخانه مشتری باغ وحش که منجر به از دست دادن ساعت انجماد توزیع صف دی ال و کاهش سرعت در صف تکرار اگر غیر خالی `chroot` پیشوند در پیکربندی باغ وحش استفاده می شود. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-8} + +- پشتیبانی حذف برای عبارات مانند `(a, b) IN (SELECT (a, b))` (شما می توانید بیان معادل استفاده کنید `(a, b) IN (SELECT a, b)`). در نسخه های قبلی, این عبارات منجر به نامشخص `WHERE` فیلتر کردن یا ایجاد خطا. + +### ClickHouse انتشار 1.1.54378, 2018-04-16 {#clickhouse-release-1-1-54378-2018-04-16} + +#### ویژگی های جدید: {#new-features-14} + +- ورود به سیستم سطح را می توان بدون راه اندازی مجدد سرور تغییر کرده است. +- اضافه شدن `SHOW CREATE DATABASE` پرس و جو. +- این `query_id` می توان به تصویب رسید `clickhouse-client` . +- تنظیمات جدید: `max_network_bandwidth_for_all_users`. +- اضافه شدن پشتیبانی برای `ALTER TABLE ... PARTITION ...` برای `MATERIALIZED VIEW`. +- اطلاعات اضافه شده در مورد اندازه قطعات داده در فرم غیر فشرده در جدول سیستم. +- پشتیبانی از رمزگذاری سرور به سرور برای جداول توزیع شده (`1` در پیکربندی ماکت در ``). +- پیکربندی سطح جدول برای `ReplicatedMergeTree` خانواده به منظور به حداقل رساندن مقدار داده های ذخیره شده در باغ وحش: : `use_minimalistic_checksums_in_zookeeper = 1` +- پیکربندی از `clickhouse-client` اعلان کردن. به طور پیش فرض, نام سرور در حال حاضر خروجی به اعلان. نام صفحه نمایش سرور را می توان تغییر داد. همچنین در ارسال `X-ClickHouse-Display-Name` HTTP header (Kirill Shvakov). +- چند کاما از هم جدا `topics` می توان برای مشخص `Kafka` موتور) +- هنگامی که یک پرس و جو توسط متوقف `KILL QUERY` یا `replace_running_query` مشتری دریافت می کند `Query was canceled` استثنا به جای یک نتیجه ناقص. + +#### بهبود: {#improvements-13} + +- `ALTER TABLE ... DROP/DETACH PARTITION` نمایش داده شد در مقابل صف تکرار اجرا شود. +- `SELECT ... FINAL` و `OPTIMIZE ... FINAL` می توان حتی زمانی که جدول دارای یک بخش داده واحد استفاده می شود. +- A `query_log` جدول در پرواز دوباره اگر به صورت دستی حذف شد (کریل شواکوف). +- این `lengthUTF8` عملکرد سریعتر اجرا می شود (ژانگ2014). +- بهبود عملکرد درج همزمان در `Distributed` جداول (`insert_distributed_sync = 1`) هنگامی که تعداد بسیار زیادی از خرده ریز وجود دارد. +- سرور می پذیرد `send_timeout` و `receive_timeout` تنظیمات از مشتری و در هنگام اتصال به مشتری اعمال می شود (که در جهت معکوس اعمال می شود: سوکت سرور `send_timeout` به مجموعه `receive_timeout` ارزش دریافت شده از مشتری و بالعکس). +- بازیابی سقوط قوی تر برای درج ناهمزمان به `Distributed` میز +- نوع بازگشت `countEqual` تابع تغییر از `UInt32` به `UInt64` (谢磊). + +#### رفع اشکال: {#bug-fixes-25} + +- ثابت خطا با `IN` هنگامی که سمت چپ عبارت است `Nullable`. +- نتایج صحیح در حال حاضر در هنگام استفاده از تاپل با بازگشت `IN` هنگامی که برخی از اجزای تاپل در شاخص جدول هستند. +- این `max_execution_time` محدود در حال حاضر به درستی کار می کند با نمایش داده شد توزیع شده است. +- خطاهای ثابت هنگام محاسبه اندازه ستون های کامپوزیت در `system.columns` جدول +- هنگام ایجاد یک جدول موقت خطایی رخ داد `CREATE TEMPORARY TABLE IF NOT EXISTS.` +- خطاهای ثابت در `StorageKafka` (\#\#2075) +- سقوط سرور ثابت از استدلال نامعتبر از توابع مجموع خاص. +- ثابت خطا که مانع از `DETACH DATABASE` پرسو جو از توقف وظایف پس زمینه برای `ReplicatedMergeTree` میز +- `Too many parts` دولت کمتر احتمال دارد به اتفاق می افتد در هنگام قرار دادن به نمایش مواد جمع (\#2084). +- دست زدن به بازگشتی اصلاح تعویض در پیکربندی اگر یک تعویض باید توسط جایگزینی دیگر در همان سطح به دنبال. +- اصلاح نحو در فایل ابرداده در هنگام ایجاد یک `VIEW` که با استفاده از یک پرس و جو با `UNION ALL`. +- `SummingMergeTree` در حال حاضر به درستی کار می کند برای جمع ساختارهای داده های تو در تو با یک کلید کامپوزیت. +- ثابت امکان شرایط مسابقه در هنگام انتخاب رهبر برای `ReplicatedMergeTree` میز + +#### ایجاد تغییرات: {#build-changes-5} + +- پشتیبانی ساخت `ninja` به جای `make` و موارد استفاده `ninja` به طور پیش فرض برای انتشار ساختمان. +- بسته تغییر نام داد: `clickhouse-server-base` داخل `clickhouse-common-static`; `clickhouse-server-common` داخل `clickhouse-server`; `clickhouse-common-dbg` داخل `clickhouse-common-static-dbg`. برای نصب استفاده کنید `clickhouse-server clickhouse-client`. بسته با نام های قدیمی هنوز هم در مخازن برای سازگاری بار. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-9} + +- حذف تفسیر خاص از یک عبارت در اگر مجموعه ای در سمت چپ مشخص شده است. قبلا بیان `arr IN (set)` به عنوان تفسیر شد “at least one `arr` element belongs to the `set`”. برای دریافت همان رفتار در نسخه جدید, نوشتن `arrayExists(x -> x IN (set), arr)`. +- استفاده نادرست از گزینه سوکت را غیرفعال کرد `SO_REUSEPORT`, که به اشتباه به طور پیش فرض در کتابخانه کم فعال شد. توجه داشته باشید که در لینوکس دیگر هیچ دلیلی وجود ندارد که به طور همزمان نشانی ها را مشخص کند `::` و `0.0.0.0` for listen – use just `::`, که اجازه می دهد گوش دادن به اتصال هر دو بیش از لیگ4 و ایپو6 (با تنظیمات پیکربندی هسته به طور پیش فرض). شما همچنین می توانید به رفتار از نسخه های قبلی با مشخص برگرداندن `1` در پیکربندی. + +### ClickHouse انتشار 1.1.54370, 2018-03-16 {#clickhouse-release-1-1-54370-2018-03-16} + +#### ویژگی های جدید: {#new-features-15} + +- اضافه شدن `system.macros` جدول و به روز رسانی خودکار از ماکروها زمانی که فایل پیکربندی تغییر کرده است. +- اضافه شدن `SYSTEM RELOAD CONFIG` پرس و جو. +- اضافه شدن `maxIntersections(left_col, right_col)` تابع جمع, که حداکثر تعداد فواصل به طور همزمان متقاطع گرداند `[left; right]`. این `maxIntersectionsPosition(left, right)` تابع می گرداند ابتدای “maximum” فاصله. ([مایکل فورمور](https://github.com/ClickHouse/ClickHouse/pull/2012)). + +#### بهبود: {#improvements-14} + +- هنگام وارد کردن داده ها در یک `Replicated` جدول, درخواست کمتر به ساخته شده `ZooKeeper` (و بسیاری از خطاهای سطح کاربر از ناپدید شد `ZooKeeper` ورود). +- توانایی ایجاد نام مستعار برای مجموعه داده ها اضافه شده است. مثال: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. + +#### رفع اشکال: {#bug-fixes-26} + +- ثابت `Illegal PREWHERE` خطا هنگام خواندن از جداول ادغام برای `Distributed`میز +- رفع اضافه شده است که به شما اجازه شروع کلیک سرور در ظروف فایل اجرایی فقط 4. +- ثابت شرایط مسابقه در هنگام خواندن از سیستم `system.parts_columns tables.` +- بافر دو حذف در طول یک درج همزمان به یک `Distributed` جدول, که می تواند باعث اتصال به ایست. +- رفع اشکال که باعث انتظار بیش از حد طولانی برای یک ماکت در دسترس نیست قبل از شروع یک `SELECT` پرس و جو. +- تاریخ نادرست ثابت در `system.parts` جدول +- رفع اشکال ساخته شده است که غیر ممکن است برای وارد کردن داده ها در یک `Replicated` جدول اگر `chroot` غیر خالی در پیکربندی بود `ZooKeeper` خوشه خوشه. +- ثابت الگوریتم ادغام عمودی برای خالی `ORDER BY` جدول +- ترمیم توانایی استفاده از لغت نامه در نمایش داده شد به جداول از راه دور, حتی اگر این لغت نامه در سرور درخواست وجود ندارد. این قابلیت در نسخه 1.1.54362 از دست داده بود. +- ترمیم رفتار برای نمایش داده شد مانند `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` هنگامی که در سمت راست از `IN` باید از راه دور استفاده کنید `default.table` به جای یک محلی. این رفتار در نسخه 1.1.54358 شکسته شد. +- حذف غیر اصلی ورود به سیستم سطح خطا از `Not found column ... in block`. + +### ClickHouse انتشار 1.1.54362, 2018-03-11 {#clickhouse-release-1-1-54362-2018-03-11} + +#### ویژگی های جدید: {#new-features-16} + +- تجمع بدون `GROUP BY` برای یک مجموعه خالی (مانند `SELECT count(*) FROM table WHERE 0`) در حال حاضر در نتیجه با یک ردیف با ارزش تهی برای توابع کل گرداند, در انطباق با استاندارد گذاشتن. برای بازگرداندن رفتار قدیمی (بازگشت به نتیجه خالی), تنظیم `empty_result_for_aggregation_by_empty_set` به 1. +- تبدیل نوع اضافه شده برای `UNION ALL`. نام مستعار مختلف مجاز است `SELECT` موقعیت در `UNION ALL`, در انطباق با استاندارد گذاشتن. +- عبارات دلخواه در پشتیبانی `LIMIT BY` بند. قبلا, تنها ممکن بود به استفاده از ستون ناشی از `SELECT`. +- یک شاخص از `MergeTree` جداول استفاده می شود که `IN` به یک تاپل عبارات از ستون کلید اصلی اعمال می شود. مثال: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` هشدار داده می شود +- اضافه شدن `clickhouse-copier` ابزار برای کپی کردن بین خوشه ها و داده های تغییر شکل (بتا). +- اضافه شده توابع هش سازگار: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. آنها را می توان به عنوان یک sharding کلیدی به منظور کاهش مقدار از ترافیک شبکه در طول پس از آن reshardings. +- اضافه شدن توابع: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. +- اضافه شدن `arrayCumSum` تابع (جوی سانتانا). +- اضافه شدن `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero` و `parseDateTimeBestEffortOrNull` توابع برای خواندن تاریخ ساعت از یک رشته حاوی متن در طیف گسترده ای از فرمت های ممکن. +- داده ها را می توان تا حدی از لغت نامه های خارجی در طول به روز رسانی دوباره (بار فقط سوابق که ارزش این زمینه مشخص شده بیشتر از در دانلود قبلی) (ارسن هاکوبیان). +- اضافه شدن `cluster` تابع جدول. مثال: `cluster(cluster_name, db, table)`. این `remote` تابع جدول می توانید نام خوشه به عنوان اولین استدلال قبول, اگر به عنوان یک شناسه مشخص. +- این `remote` و `cluster` توابع جدول را می توان در `INSERT` نمایش داده شد. +- اضافه شدن `create_table_query` و `engine_full` ستون های مجازی به `system.tables`جدول این `metadata_modification_time` ستون مجازی است. +- اضافه شدن `data_path` و `metadata_path` ستونها به `system.tables`و`system.databases` جداول و اضافه شدن `path` ستون به `system.parts` و `system.parts_columns` میز +- اضافه شدن اطلاعات اضافی در مورد ادغام در `system.part_log` جدول +- یک کلید پارتیشن بندی دلخواه می تواند برای `system.query_log` جدول (کریل شواکوف). +- این `SHOW TABLES` پرس و جو در حال حاضر نیز جداول موقت را نشان می دهد. جداول موقت و `is_temporary` ستون به `system.tables` (ژانگ2014). +- اضافه شده `DROP TEMPORARY TABLE` و `EXISTS TEMPORARY TABLE` نمایش داده شد (ژانگ2014). +- پشتیبانی از `SHOW CREATE TABLE` برای جداول موقت (ژانگ2014). +- اضافه شدن `system_profile` پارامتر پیکربندی برای تنظیمات مورد استفاده توسط فرایندهای داخلی. +- پشتیبانی از بارگذاری `object_id` به عنوان یک ویژگی در `MongoDB` واژهنامهها (پاول لیتویننکو). +- خواندن `null` به عنوان مقدار پیش فرض هنگام بارگذاری داده ها برای یک فرهنگ لغت خارجی با `MongoDB` منبع (پاول لیتویننکو). +- خواندن `DateTime` ارزش ها در `Values` فرمت از برچسب زمان یونیکس بدون نقل قول تنها. +- عدم موفقیت در پشتیبانی `remote` توابع جدول برای موارد زمانی که برخی از کپی از دست رفته جدول درخواست. +- تنظیمات پیکربندی را می توان در خط فرمان باطل زمانی که شما اجرا `clickhouse-server`. مثال: `clickhouse-server -- --logger.level=information`. +- اجرا `empty` تابع از یک `FixedString` استدلال: تابع بازده 1 اگر رشته شامل به طور کامل از بایت پوچ (ژانگ2014). +- اضافه شدن `listen_try`پارامتر پیکربندی برای گوش دادن به حداقل یکی از نشانی های گوش دادن بدون ترک, اگر برخی از نشانی ها را نمی توان به گوش (مفید برای سیستم های با پشتیبانی غیر فعال برای لیگ4 یا ایپو6). +- اضافه شدن `VersionedCollapsingMergeTree` موتور جدول. +- پشتیبانی از ردیف ها و انواع عددی دلخواه برای `library` منبع فرهنگ لغت. +- `MergeTree` جداول را می توان بدون یک کلید اولیه استفاده می شود (شما نیاز به مشخص `ORDER BY tuple()`). +- A `Nullable` نوع می تواند باشد `CAST` به یک غیر-`Nullable` نوع اگر استدلال نیست `NULL`. +- `RENAME TABLE` می توان برای انجام `VIEW`. +- اضافه شدن `throwIf` تابع. +- اضافه شدن `odbc_default_field_size` گزینه, که اجازه می دهد تا شما را به گسترش حداکثر اندازه از ارزش لود شده از یک منبع بی سی (به طور پیش فرض, این هست 1024). +- این `system.processes` جدول و `SHOW PROCESSLIST` در حال حاضر `is_cancelled` و `peak_memory_usage` ستون ها + +#### بهبود: {#improvements-15} + +- محدودیت ها و سهمیه بندی در نتیجه دیگر به داده های متوسط برای اعمال `INSERT SELECT` نمایش داده شد و یا برای `SELECT` subqueries. +- باعث کاذب کمتر از `force_restore_data` هنگام چک کردن وضعیت `Replicated` جداول زمانی که سرور شروع می شود. +- اضافه شدن `allow_distributed_ddl` انتخاب +- توابع نامشخص در عبارات برای مجاز نیست `MergeTree` کلید های جدول. +- پروندهها با جایگزینی از `config.d` دایرکتوری ها به ترتیب حروف الفبا لود می شود. +- بهبود عملکرد `arrayElement` تابع در مورد یک مجموعه چند بعدی ثابت با مجموعه ای خالی به عنوان یکی از عناصر. مثال: `[[1], []][x]`. +- سرور شروع می شود سریع تر در حال حاضر در هنگام استفاده از فایل های پیکربندی با تعویض بسیار بزرگ (به عنوان مثال, لیست بسیار زیادی از شبکه های اینترنتی). +- هنگامی که در حال اجرا یک پرس و جو, جدول توابع ارزش اجرا یک بار. قبلا, `remote` و `mysql` جدول ارزش توابع پرس و جو همان دو بار انجام برای بازیابی ساختار جدول از یک سرور از راه دور. +- این `MkDocs` ژنراتور مستندات استفاده شده است. +- هنگامی که شما سعی می کنید یک ستون جدول را حذف کنید که `DEFAULT`/`MATERIALIZED` عبارات از ستون های دیگر بستگی دارد, یک استثنا پرتاب می شود (ژانگ2014). +- اضافه شدن توانایی تجزیه یک خط خالی در فرمت های متن به عنوان شماره 0 برای `Float` انواع داده ها. این ویژگی قبلا در دسترس بود اما در نسخه 1.1.54342 از دست داده بود. +- `Enum` مقادیر را می توان در استفاده `min`, `max`, `sum` و برخی از توابع دیگر. در این موارد از مقادیر عددی مربوطه استفاده می شود. این ویژگی قبلا در دسترس بود اما در نسخه 1.1.54337 از دست داده بود. +- اضافه شده `max_expanded_ast_elements` برای محدود کردن اندازه از اس تی پس از نام مستعار به صورت بازگشتی در حال گسترش است. + +#### رفع اشکال: {#bug-fixes-27} + +- ثابت مواردی که غیر ضروری ستون حذف شده از subqueries در خطا یا حذف نشده از subqueries حاوی `UNION ALL`. +- رفع اشکال در ادغام برای `ReplacingMergeTree` میز +- درج همزمان ثابت در `Distributed` جداول (`insert_distributed_sync = 1`). +- پیش فرض ثابت برای استفاده های خاص از `FULL` و `RIGHT JOIN` با ستون تکراری در کارخانه های فرعی. +- پیش فرض ثابت برای استفاده های خاص از `replace_running_query` و `KILL QUERY`. +- ثابت منظور از `source` و `last_exception` ستون ها در `system.dictionaries` جدول +- رفع اشکال زمانی که `DROP DATABASE` پرس و جو فایل را با ابرداده را حذف کنید. +- ثابت `DROP DATABASE` پرسوجو برای `Dictionary` پایگاه داده. +- ثابت دقت کم `uniqHLL12` و `uniqCombined` توابع برای کارتنیت بیشتر از 100 میلیون مورد (الکس بوچاروف). +- ثابت محاسبه مقادیر پیش فرض ضمنی در صورت لزوم به طور همزمان محاسبه عبارات صریح و روشن به طور پیش فرض در `INSERT` نمایش داده شد (ژانگ2014). +- ثابت یک مورد نادر زمانی که یک پرس و جو به یک `MergeTree` جدول نمی تواند به پایان برسد (فکس ایکس سی). +- ثابت تصادف رخ داده است که در حال اجرا `CHECK` پرسوجو برای `Distributed` جداول اگر تمام خرده ریز محلی هستند (فکس.اطلاعات دقیق +- ثابت رگرسیون عملکرد کمی با توابع است که با استفاده از عبارات منظم. +- ثابت رگرسیون عملکرد در هنگام ایجاد مجموعه های چند بعدی از عبارات پیچیده است. +- رفع اشکال که می تواند اضافی شود `FORMAT` بخش به نظر می رسد در یک `.sql` فایل با ابرداده. +- رفع اشکال که باعث `max_table_size_to_drop` محدود به درخواست در هنگام تلاش برای حذف یک `MATERIALIZED VIEW` با نگاهی به یک جدول به صراحت مشخص. +- ناسازگاری ثابت با مشتریان قدیمی (مشتریان قدیمی گاهی اوقات داده ها را با `DateTime('timezone')` نوع, که درک نمی کنند). +- رفع اشکال در هنگام خواندن `Nested` عناصر ستون سازه هایی که با استفاده از اضافه شد `ALTER` اما این برای پارتیشن های قدیمی خالی است, زمانی که شرایط را برای این ستون ها به نقل مکان کرد `PREWHERE`. +- رفع اشکال هنگام فیلتر کردن جداول توسط مجازی `_table` ستون در نمایش داده شد به `Merge` میز +- رفع اشکال در هنگام استفاده از `ALIAS` ستونها در `Distributed` میز +- رفع اشکال ساخته شده است که تلفیقی پویا غیر ممکن است برای نمایش داده شد با توابع کل از `quantile` خانواده +- ثابت شرایط مسابقه در خط لوله اجرای پرس و جو که در موارد بسیار نادر رخ داده است در هنگام استفاده از `Merge` جداول با تعداد زیادی از جداول, و در هنگام استفاده از `GLOBAL` subqueries. +- تصادف را هنگام عبور از اندازه های مختلف به یک ثابت کرد `arrayReduce` تابع در هنگام استفاده از توابع کل از استدلال های متعدد. +- ممنوع استفاده از نمایش داده شد با `UNION ALL` در یک `MATERIALIZED VIEW`. +- خطا در هنگام مقدار دهی اولیه از ثابت `part_log` جدول سیستم زمانی که سرور شروع می شود (به طور پیش فرض, `part_log` غیر فعال است). + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-10} + +- حذف `distributed_ddl_allow_replicated_alter` انتخاب این رفتار به طور پیش فرض فعال. +- حذف `strict_insert_defaults` تنظیمات. اگر شما با استفاده از این قابلیت, ارسال به `clickhouse-feedback@yandex-team.com`. +- حذف `UnsortedMergeTree` موتور + +### ClickHouse انتشار 1.1.54343, 2018-02-05 {#clickhouse-release-1-1-54343-2018-02-05} + +- اضافه شدن پشتیبانی از ماکرو برای تعریف نام خوشه در نمایش داده شد ددل توزیع و سازنده جداول توزیع شده است: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. +- در حال حاضر نمایش داده شد مانند `SELECT ... FROM table WHERE expr IN (subquery)` با استفاده از پردازش `table` نمایه. +- پردازش تکراری بهبود یافته در هنگام قرار دادن به جداول تکرار, به طوری که دیگر کم کردن سرعت اجرای صف تکرار. + +### ClickHouse انتشار 1.1.54342, 2018-01-22 {#clickhouse-release-1-1-54342-2018-01-22} + +این نسخه شامل رفع اشکال برای نسخه قبلی 1.1.54337: + +- ثابت رگرسیون در 1.1.54337: اگر کاربر به طور پیش فرض دسترسی خوانده است, سپس سرور حاضر به راه اندازی با پیام `Cannot create database in readonly mode`. +- ثابت رگرسیون در 1.1.54337: در سیستم های با سیستم, سیاهههای مربوط همیشه به سای لاگ صرف نظر از پیکربندی نوشته شده; اسکریپت دیده بان هنوز هم با استفاده از اینیت.د +- ثابت رگرسیون در 1.1.54337: پیکربندی پیش فرض اشتباه در تصویر کارگر بارانداز. +- ثابت nondeterministic رفتار GraphiteMergeTree (شما می توانید آن را در ورود به سیستم پیام `Data after merge is not byte-identical to the data on another replicas`). +- رفع اشکال که ممکن است منجر به ادغام متناقض پس از بهینه سازی پرس و جو به تکرار جداول (شما ممکن است در پیام ورود به سیستم را ببینید `Part ... intersects the previous part`). +- جداول بافر در حال حاضر به درستی کار زمانی که ستون محقق در جدول مقصد وجود دارد (توسط ژانگ2014). +- رفع اشکال در اجرای پوچ. + +### ClickHouse انتشار 1.1.54337, 2018-01-18 {#clickhouse-release-1-1-54337-2018-01-18} + +#### ویژگی های جدید: {#new-features-17} + +- اضافه شدن پشتیبانی برای ذخیره سازی از مجموعه های چند بعدی و تاپل (`Tuple` نوع داده) در جداول. +- پشتیبانی از توابع جدول برای `DESCRIBE` و `INSERT` نمایش داده شد. اضافه شدن پشتیبانی برای کارخانه های فرعی در `DESCRIBE`. مثالها: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. پشتیبانی از `INSERT INTO TABLE` علاوه بر `INSERT INTO`. +- پشتیبانی بهبود یافته برای مناطق زمانی. این `DateTime` نوع داده را می توان با منطقه زمانی است که برای تجزیه و قالب بندی در فرمت های متنی استفاده مشروح. مثال: `DateTime('Europe/Moscow')`. هنگامی که زمان در توابع برای مشخص `DateTime` استدلال, نوع بازگشت منطقه زمانی پیگیری, و ارزش نمایش داده خواهد شد به عنوان انتظار می رود. +- اضافه شدن توابع `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. این `toRelativeHour`/`Minute`/`Second` توابع می توانند یک مقدار از نوع را `Date` به عنوان یک استدلال. این `now` نام تابع حساس به حروف است. +- اضافه شدن `toStartOfFifteenMinutes` تابع (کریل شواکوف). +- اضافه شدن `clickhouse format` ابزار برای قالب بندی نمایش داده شد. +- اضافه شدن `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` قالب. فایل های طرح را می توان تنها در دایرکتوری مشخص شده واقع شده است. +- اضافه شدن پشتیبانی برای تعویض پیکربندی (`incl` و `conf.d`) برای پیکربندی لغت نامه ها و مدل های خارجی (پاول یاکونین). +- اضافه شدن یک ستون با اسناد و مدارک برای `system.settings` جدول (کریل شواکوف). +- اضافه شدن `system.parts_columns` جدول با اطلاعات در مورد اندازه ستون در هر بخش داده ها از `MergeTree` میز +- اضافه شدن `system.models` جدول با اطلاعات در مورد لود `CatBoost` مدل های یادگیری ماشین. +- اضافه شدن `mysql` و `odbc` عملکرد جدول و متناظر `MySQL` و `ODBC` موتورهای جدول برای دسترسی به پایگاه داده از راه دور. این قابلیت در مرحله بتا است. +- اضافه شدن امکان به تصویب یک استدلال از نوع `AggregateFunction` برای `groupArray` تابع جمع (بنابراین شما می توانید مجموعه ای از کشورهای برخی از تابع جمع ایجاد). +- محدودیت حذف در ترکیب های مختلف از ترکیب تابع جمع. مثلا, شما می توانید استفاده کنید `avgForEachIf` و همچنین `avgIfForEach` توابع مجموع, که رفتارهای مختلف. +- این `-ForEach` ترکیب تابع مجموع برای مورد توابع مجموع استدلال های متعدد گسترش یافته است. +- اضافه شدن پشتیبانی از توابع کل `Nullable` استدلال حتی برای موارد زمانی که تابع غیر گرداند-`Nullable` نتیجه (اضافه شده با سهم سیلو کاروجا). مثال: `groupArray`, `groupUniqArray`, `topK`. +- اضافه شدن `max_client_network_bandwidth` برای `clickhouse-client` (Kirill Shvakov). +- کاربران با `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). +- اضافه شدن پشتیبانی برای استفاده از مصرف کنندگان متعدد با `Kafka` موتور گزینه های پیکربندی گسترده برای `Kafka` (Marek Vavruša). +- اضافه شدن `intExp3` و `intExp4` توابع. +- اضافه شدن `sumKahan` تابع جمع. +- اضافه شده به \* شماره\* توابع پرنده, جایی که \* شماره \* یک نوع عددی است. +- اضافه شدن پشتیبانی برای `WITH` بند برای `INSERT SELECT` پرس و جو (نویسنده: ژانگ2014). +- تنظیمات اضافه شده: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. به خصوص این تنظیمات برای دانلود قطعات داده ها برای تکرار استفاده می شود. تغییر این تنظیمات اجازه می دهد تا برای عدم موفقیت سریع تر اگر شبکه غیرمنتظره است. +- اضافه شدن پشتیبانی برای `ALTER` برای جداول نوع `Null` هشدار داده می شود +- این `reinterpretAsString` تابع برای تمام انواع داده ها که به روشنی در حافظه ذخیره می شود گسترش یافته است. +- اضافه شدن `--silent` گزینه ای برای `clickhouse-local` ابزار. این سرکوب چاپ اطلاعات اجرای پرس و جو در خ. +- اضافه شدن پشتیبانی برای خواندن مقادیر نوع `Date` از متن در قالب ای که ماه و / یا روز از ماه مشخص شده است با استفاده از یک رقم واحد به جای دو رقم (پرنده ایموس). + +#### بهینه سازی عملکرد: {#performance-optimizations} + +- عملکرد بهبود یافته از توابع کل `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` از استدلال رشته. +- عملکرد بهبود یافته از توابع `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. +- بهبود عملکرد تجزیه و قالب بندی `Date` و `DateTime` ارزش نوع در قالب متن. +- بهبود عملکرد و دقت تجزیه اعداد ممیز شناور. +- کاهش استفاده از حافظه برای `JOIN` در مورد زمانی که قطعات چپ و راست ستون با نام یکسان است که در موجود نیست `USING` . +- عملکرد بهبود یافته از توابع کل `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` با کاهش ثبات محاسباتی. توابع قدیمی تحت نام در دسترس هستند `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. + +#### رفع اشکال: {#bug-fixes-28} + +- تکرار داده های ثابت پس از اجرای یک `DROP` یا `DETACH PARTITION` پرس و جو. در نسخه های قبلی, حذف یک پارتیشن و قرار دادن داده های مشابه دوباره کار نمی کند چرا بلوک قرار داده تکراری در نظر گرفته شد. +- رفع اشکال که می تواند به تفسیر نادرست از منجر شود `WHERE` بند برای `CREATE MATERIALIZED VIEW` نمایش داده شد با `POPULATE` . +- رفع اشکال در استفاده از `root_path` پارامتر در `zookeeper_servers` پیکربندی. +- نتایج غیر منتظره ثابت از عبور از `Date` نشانوند به `toStartOfDay` . +- ثابت `addMonths` و `subtractMonths` توابع و حساب برای `INTERVAL n MONTH` در مواردی که نتیجه سال گذشته است. +- اضافه شدن پشتیبانی از دست رفته برای `UUID` نوع داده برای `DISTINCT` , `JOIN` و `uniq` توابع جمع و لغت نامه های خارجی (اوگنی ایوانف). پشتیبانی از `UUID` هنوز ناقصه +- ثابت `SummingMergeTree` رفتار در مواردی که ردیف خلاصه به صفر است. +- رفع مختلف برای `Kafka` engine (Marek Vavruša). +- رفتار نادرست ثابت از `Join` موتور جدول (پرنده ایموس). +- رفتار تخصیص نادرست ثابت تحت بورس و سیستم عامل ایکس. +- این `extractAll` تابع در حال حاضر مسابقات خالی پشتیبانی می کند. +- ثابت خطا که استفاده از مسدود `libressl` به جای `openssl` . +- ثابت `CREATE TABLE AS SELECT` پرس و جو از جداول موقت. +- ثابت غیر اتمی به روز رسانی صف تکرار. این می تواند منجر به کپی بودن خارج از سنکرون تا سرور راه اندازی مجدد. +- سرریز ممکن ثابت در `gcd` , `lcm` و `modulo` (`%` اپراتور) (ماکس اسکروخد). +- `-preprocessed` فایل ها در حال حاضر پس از تغییر ایجاد شده است `umask` (`umask` را می توان در پیکربندی تغییر). +- رفع اشکال در چک پس زمینه از قطعات (`MergeTreePartChecker` )هنگام استفاده از یک کلید پارتیشن سفارشی . +- تجزیه ثابت از تاپل (ارزش های `Tuple` نوع داده) در فرمت های متن. +- پیام های خطا بهبود یافته در مورد انواع ناسازگار منتقل شده به `multiIf` , `array` و برخی از توابع دیگر. +- پشتیبانی دوباره طراحی شده برای `Nullable` انواع. اشکالات ثابت که ممکن است به یک تصادف سرور منجر شود. ثابت تقریبا تمام اشکالات دیگر مربوط به `NULL` پشتیبانی: نادرست نوع تبدیل در وارد کردن را انتخاب کنید کافی برای حمایت از Nullable در داشتن و PREWHERE, `join_use_nulls` حالت, انواع قابل ابطال به عنوان استدلال `OR` اپراتور و غیره +- اشکالات مختلف ثابت مربوط به معانی داخلی انواع داده ها. نمونه: جمع غیر ضروری از `Enum` فیلدهای تایپ شده `SummingMergeTree` ; تراز دلخواه `Enum` انواع در `Pretty` فرمت, و غیره. +- چک سختگیرانه تر برای ترکیب مجاز از ستون کامپوزیت. +- ثابت سرریز در هنگام تعیین یک پارامتر بسیار بزرگ برای `FixedString` نوع داده. +- رفع اشکال در `topK` تابع جمع در یک مورد عمومی. +- اضافه شدن چک از دست رفته برای برابری اندازه مجموعه ای در استدلال از انواع ن-عرایی از توابع کل با `-Array` ترکیب کننده. +- رفع اشکال در `--pager` برای `clickhouse-client` (نویسنده: کس1322). +- ثابت دقت از `exp10` تابع. +- ثابت رفتار `visitParamExtract` تابع برای انطباق بهتر با اسناد و مدارک. +- ثابت تصادف زمانی که انواع داده های نادرست مشخص شده است. +- رفتار را ثابت کرد `DISTINCT` در مورد زمانی که همه ستون ثابت هستند. +- قالب بندی پرس و جو ثابت در مورد استفاده از `tupleElement` تابع با یک عبارت ثابت پیچیده به عنوان شاخص عنصر تاپل. +- رفع اشکال در `Dictionary` جداول برای `range_hashed` واژهنامهها. +- رفع اشکال که منجر به ردیف بیش از حد در نتیجه `FULL` و `RIGHT JOIN` (پرنده ایموس). +- ثابت سقوط سرور در هنگام ایجاد و از بین بردن فایل های موقت در `config.d` دایرکتوری در طول بازنگری پیکربندی. +- ثابت `SYSTEM DROP DNS CACHE` پرس و جو: کش سرخ شد اما نشانی از گره های خوشه ای به روز شد. +- رفتار را ثابت کرد `MATERIALIZED VIEW` پس از اجرای `DETACH TABLE` for the table under the view (Marek Vavruša). + +#### بهبود ساخت: {#build-improvements-4} + +- این `pbuilder` ابزار برای ساخت استفاده می شود. روند ساخت تقریبا به طور کامل مستقل از محیط میزبان ساخت است. +- ساخت تک برای نسخه های سیستم عامل های مختلف استفاده می شود. بسته ها و فایل های باینری سازگار با طیف گسترده ای از سیستم های لینوکس ساخته شده است. +- اضافه شدن `clickhouse-test` بسته این می تواند مورد استفاده قرار گیرد برای اجرای تست های کاربردی. +- قطار سریع السیر منبع هم اکنون می توانید به مخزن منتشر شود. این می تواند مورد استفاده قرار گیرد به تولید مثل ساخت بدون استفاده از گیتهاب. +- اضافه شده ادغام محدود با تراویس سی. با توجه به محدودیت در زمان ساخت در تراویس, تنها ساخت اشکال زدایی تست شده است و یک زیر مجموعه محدود از تست اجرا می شوند. +- اضافه شدن پشتیبانی برای `Cap'n'Proto` در ساخت به طور پیش فرض. +- فرمت منابع اسناد را تغییر داد `Restricted Text` به `Markdown`. +- اضافه شدن پشتیبانی برای `systemd` (ولادیمیر اسمیرنوف). این است که به طور پیش فرض به دلیل ناسازگاری با برخی از تصاویر سیستم عامل غیر فعال است و می تواند به صورت دستی فعال کنید. +- برای تولید کد پویا, `clang` و `lld` به جاسازی شده `clickhouse` دودویی. همچنین می توانند به عنوان `clickhouse clang` و `clickhouse lld` . +- استفاده از پسوندهای گنو از کد حذف شده است. فعال کردن `-Wextra` انتخاب هنگام ساخت با `clang` به طور پیش فرض است `libc++` به جای `libstdc++`. +- استخراج شده `clickhouse_parsers` و `clickhouse_common_io` کتابخانه ها برای سرعت بخشیدن به ایجاد ابزارهای مختلف. + +#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-11} + +- قالب برای علامت در `Log` جداول نوع که شامل `Nullable` ستون در راه ناسازگار به عقب تغییر یافت. اگر شما این جداول, شما باید به تبدیل `TinyLog` قبل از شروع نسخه سرور جدید تایپ کنید. برای انجام این کار جایگزین کنید `ENGINE = Log` با `ENGINE = TinyLog` در مربوطه `.sql` پرونده در `metadata` فهرست راهنما. اگر جدول شما ندارد `Nullable` ستون و یا اگر نوع جدول خود را نمی `Log` پس نیازی نیست کاری بکنی +- حذف `experimental_allow_extended_storage_definition_syntax` تنظیمات. در حال حاضر این ویژگی به طور پیش فرض فعال است. +- این `runningIncome` تابع به تغییر نام داد `runningDifferenceStartingWithFirstvalue` برای جلوگیری از سردرگمی. +- حذف `FROM ARRAY JOIN arr` نحو زمانی که مجموعه اضافه کردن به طور مستقیم پس از با هیچ جدول مشخص (پرنده ایموس). +- حذف `BlockTabSeparated` فرمت که صرفا برای اهداف تظاهرات مورد استفاده قرار گرفت. +- فرمت دولت برای توابع کل تغییر `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. اگر شما ایالات از این توابع کل در جداول ذخیره شده اند (با استفاده از `AggregateFunction` نوع داده و یا نمایش تحقق با کشورهای مربوطه), لطفا به ارسال clickhouse-feedback@yandex-team.com. +- در نسخه های سرور قبلی یک ویژگی مستند نشده وجود داشت: اگر یک تابع جمع شده به پارامترها بستگی داشته باشد هنوز هم می توانید بدون پارامتر در نوع داده قابلیت کارکرد مشخص کنید. مثال: `AggregateFunction(quantiles, UInt64)` به جای `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. این ویژگی از دست داده بود. ما قصد داریم دوباره در نسخه های بعدی پشتیبانی کنیم. +- انواع داده شمارشی را نمی توان در توابع جمع دقیقه/حداکثر استفاده می شود. این توانایی خواهد شد در نسخه بعدی بازگشت. + +#### لطفا توجه داشته باشید در هنگام به روز رسانی: {#please-note-when-upgrading} + +- هنگام انجام یک به روز رسانی نورد در یک خوشه, در نقطه ای که برخی از کپی در حال اجرا هستند نسخه های قدیمی از تاتر و برخی در حال اجرا هستند نسخه جدید, تکرار است به طور موقت متوقف و پیام `unknown parameter 'shard'` به نظر می رسد در ورود به سیستم. تکرار ادامه خواهد داد پس از همه کپی از خوشه به روز می شوند. +- اگر نسخه های مختلف از تاتر در حال اجرا بر روی سرورهای خوشه, ممکن است که نمایش داده شد توزیع با استفاده از توابع زیر نتایج نادرست داشته باشد: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. شما باید تمام گره های خوشه ای به روز رسانی. + +## [تغییرات برای 2017](./2017.md#clickhouse-release-1-1-54327-2017-12-21) {#changelog-for-2017} diff --git a/docs/fa/whats-new/changelog/2019.md b/docs/fa/whats-new/changelog/2019.md new file mode 100644 index 00000000000..2cf0cfce7b3 --- /dev/null +++ b/docs/fa/whats-new/changelog/2019.md @@ -0,0 +1,2074 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 77 +toc_title: '2019' +--- + +## انتشار کلیک 19.17 {#clickhouse-release-v19-17} + +### ClickHouse انتشار 19.17.6.36, 2019-12-27 {#clickhouse-release-v19-17-6-36-2019-12-27} + +#### رفع اشکال {#bug-fix} + +- سرریز بافر بالقوه ثابت در حالت فشرده خارج. کاربر مخرب می تواند داده های فشرده ساخته شده است که می تواند باعث به عنوان خوانده شده پس از بافر منتقل می کند. این موضوع توسط الدار زیتوف از تیم امنیت اطلاعات یاندکس یافت شد. [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت سقوط سرور ممکن است (`std::terminate`) هنگامی که سرور نمی تواند ارسال و یا ارسال داده ها در فرمت جسون یا میلی لیتر با ارزش از نوع داده رشته (که نیاز به اعتبار سنجی-8) و یا زمانی که فشرده سازی داده ها نتیجه با الگوریتم بروتلی و یا در برخی موارد نادر دیگر. [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- لغت نامه های ثابت با منبع از یک کلیک `VIEW` در حال حاضر خواندن چنین واژهنامهها خطا ایجاد نمی کند `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- چک کردن ثابت اگر یک میزبان مشتری توسط \_شخصی میزبان مشخص شده در کاربران مجاز باشد.. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([ویتالی بارانو](https://github.com/vitlibar)) +- `RENAME TABLE` برای یک جدول توزیع در حال حاضر تغییر نام پوشه حاوی داده های درج شده قبل از ارسال به خرده ریز. این رفع یک موضوع را با تغییر نام های پی در پی `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([تاولوبیکس](https://github.com/tavplubix)) +- `range_hashed` واژهنامهها خارجی ایجاد شده توسط دی ال نمایش داده شد در حال حاضر اجازه می دهد محدوده از انواع عددی دلخواه. [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([الساپین](https://github.com/alesapin)) +- ثابت `INSERT INTO table SELECT ... FROM mysql(...)` تابع جدول. [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([تاولوبیکس](https://github.com/tavplubix)) +- ثابت segfault در `INSERT INTO TABLE FUNCTION file()` در حالی که قرار دادن به یک فایل که وجود ندارد. در حال حاضر در این مورد فایل ایجاد می شود و سپس قرار دادن پردازش می شود. [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- خطای بیت مپ ثابت زمانی که متقاطع بیت مپ جمع و بیت مپ اسکالر. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([یو هوانگ](https://github.com/moon03432)) +- ثابت زمانی که segfault `EXISTS` پرس و جو بدون استفاده شد `TABLE` یا `DICTIONARY` مقدماتی, درست مثل `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نوع بازگشت ثابت برای توابع `rand` و `randConstant` در صورت بحث باطل. در حال حاضر توابع همیشه بازگشت `UInt32` و هرگز `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- ثابت `DROP DICTIONARY IF EXISTS db.dict` در حال حاضر استثنا پرتاب نمی کند اگر `db` وجود نداره [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([ویتالی بارانو](https://github.com/vitlibar)) +- اگر یک جدول به دلیل سقوط سرور به طور کامل کاهش یافته است, سرور سعی خواهد کرد برای بازگرداندن و بارگذاری [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([تاولوبیکس](https://github.com/tavplubix)) +- ثابت پرس و جو تعداد بی اهمیت برای یک جدول توزیع اگر بیش از دو میز محلی سفال وجود دارد. [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) +- اشکال ثابت که منجر به یک مسابقه داده در DB::BlockStreamProfileInfo::calculateRowsBeforeLimit() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([الکساندر کازاکوف](https://github.com/Akazz)) +- ثابت `ALTER table MOVE part` اعدام بلافاصله پس از ادغام بخش مشخص, که می تواند باعث حرکت بخشی که بخش مشخص شده به هم ادغام شدند. در حال حاضر به درستی حرکت می کند بخش مشخص شده است. [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- عبارات برای لغت نامه را می توان به عنوان رشته در حال حاضر مشخص شده است. این بسیار مفید است برای محاسبه ویژگی های در حالی که استخراج داده ها از غیر ClickHouse منابع به دلیل آن اجازه می دهد تا به استفاده از غیر ClickHouse نحو برای آن دسته از عبارات. [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([الساپین](https://github.com/alesapin)) +- ثابت یک مسابقه بسیار نادر در `clickhouse-copier` به دلیل سرریز در زکسید. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([هشدار داده می شود](https://github.com/dingxiangfei2009)) +- رفع اشکال زمانی که پس از پرس و جو شکست خورده (با توجه به “Too many simultaneous queries” به عنوان مثال) این اطلاعات جداول خارجی را نمی خواند و + درخواست بعدی این اطلاعات را به عنوان ابتدای پرس و جو بعدی تفسیر می کند که باعث خطا می شود `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([ازات خوژین](https://github.com/azat)) +- اجتناب از اختلاف پوچ پس از “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([ازات خوژین](https://github.com/azat)) +- بازگرداندن پشتیبانی از تمام مناطق ایکو, اضافه کردن توانایی به درخواست تلفیقی برای عبارات ثابت و اضافه کردن نام زبان به سیستم.collations جدول. [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([الساپین](https://github.com/alesapin)) +- تعداد جریان برای خواندن از `StorageFile` و `StorageHDFS` در حال حاضر محدود, برای جلوگیری از بیش از حد حافظه. [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([الساپین](https://github.com/alesapin)) +- ثابت `CHECK TABLE` پرسوجو برای `*MergeTree` جداول بدون کلید. [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([الساپین](https://github.com/alesapin)) +- حذف تعداد جهش از یک نام بخشی در صورتی که هیچ جهش وجود دارد. این حذف بهبود سازگاری با نسخه های قدیمی تر. [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([الساپین](https://github.com/alesapin)) +- رفع اشکال که جهش برای برخی از قطعات متصل به دلیل انحراف خود قلم بزرگتر از نسخه جهش جدول. [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([ژیچنگ یو](https://github.com/yuzhichang)) +- اجازه شروع سرور با کپی کار برکنار شده از قطعات پس از حرکت به دستگاه دیگر. [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- خطا را ثابت کرد “Sizes of columns doesn’t match” که ممکن است در هنگام استفاده از ستون تابع جمع به نظر می رسد. [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([بوریس گرانویو](https://github.com/bgranvea)) +- در حال حاضر یک استثنا خواهد شد در صورت استفاده با روابط در کنار محدودیت های پرتاب. و در حال حاضر امکان استفاده از بالا با محدودیت توسط. [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) +- رفع بارگذاری مجدد فرهنگ لغت در صورتی که `invalidate_query` که متوقف به روز رسانی و برخی از استثنا در به روز رسانی قبلی تلاش می کند. [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([الساپین](https://github.com/alesapin)) + +### ClickHouse انتشار 19.17.4.11, 2019-11-22 {#clickhouse-release-v19-17-4-11-2019-11-22} + +#### تغییر ناسازگار به عقب {#backward-incompatible-change} + +- با استفاده از ستون به جای اس تی برای ذخیره نتایج زیرخاکری اسکالر برای عملکرد بهتر است. تنظیم `enable_scalar_subquery_optimization` در 19.17 اضافه شد و به طور پیش فرض فعال شد. این منجر به اشتباهات مانند [این](https://github.com/ClickHouse/ClickHouse/issues/7851) در طی ارتقا به 19.17.2 یا 19.17.3 از نسخه های قبلی است. این تنظیم به طور پیش فرض فعال در 19.17.4 را ممکن است به روز رسانی از 19.16 و نسخه های قدیمی تر و بدون خطا. [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([ایموس پرنده](https://github.com/amosbird)) + +#### ویژگی جدید {#new-feature} + +- اضافه کردن توانایی برای ایجاد لغت نامه با پرس و جو ددل. [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([الساپین](https://github.com/alesapin)) +- ساخت `bloom_filter` نوع حمایت از شاخص `LowCardinality` و `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- افزودن تابع `isValidJSON` برای بررسی رشته گذشت که جانسون معتبر است. [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([ولادیمیر](https://github.com/Vdimir)) +- پیاده سازی `arrayCompact` تابع [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([یادداشت](https://github.com/Joeywzr)) +- تابع ایجاد شده `hex` برای اعداد اعشاری. این کار مانند `hex(reinterpretAsString())` اما صفر بایت گذشته را حذف کنید. [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([میخیل کوروتف](https://github.com/millb)) +- افزودن `arrayFill` و `arrayReverseFill` توابع که عناصر را با عناصر دیگر در جلو/عقب در مجموعه جایگزین می کنند. [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([هکز](https://github.com/hczhcz)) +- افزودن `CRC32IEEE()`/`CRC64()` پردازشگر پشتیبانی شده: [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([ازات خوژین](https://github.com/azat)) +- پیاده سازی `char` عملکرد شبیه به یک در [خروجی زیر](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- افزودن `bitmapTransform` تابع. این مجموعه ای از ارزش ها را در بیت مپ به مجموعه ای دیگر از ارزش ها تبدیل می کند و نتیجه یک بیت مپ جدید است [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([ژیچنگ یو](https://github.com/yuzhichang)) +- پیادهسازی شده `javaHashUTF16LE()` تابع [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([ایشیمب](https://github.com/achimbab)) +- افزودن `_shard_num` ستون مجازی برای موتور توزیع شده [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([ازات خوژین](https://github.com/azat)) + +#### ویژگی تجربی {#experimental-feature} + +- پشتیبانی از پردازنده (خط لوله اجرای پرس و جو جدید) در `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) + +#### رفع اشکال {#bug-fix-1} + +- رفع شناور نادرست تجزیه در `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([تاولوبیکس](https://github.com/tavplubix)) +- رفع بن بست نادر است که می تواند رخ دهد که ردیاب را فعال کنید. [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([فیلیمونف](https://github.com/filimonov)) +- جلوگیری از تکرار پیام در هنگام تولید جدول کافکا دارای هر گونه رزومه انتخاب از [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([ایوان](https://github.com/abyss7)) +- پشتیبانی از `Array(LowCardinality(Nullable(String)))` داخل `IN`. برطرف [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([ایشیمب](https://github.com/achimbab)) +- اضافه کردن سیستم های انتقال مواد از `SQL_TINYINT` و `SQL_BIGINT`, و رفع دست زدن به `SQL_FLOAT` انواع منبع داده در اد بی سی پل. [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([دنیس گلازاشف](https://github.com/traceon)) +- رفع تجمع (`avg` و تعداد کمی) روی ستونهای دهدهی خالی [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([اندری کونیایف](https://github.com/akonyaev90)) +- ثابت `INSERT` به توزیع با `MATERIALIZED` ستونها [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([ازات خوژین](https://github.com/azat)) +- ساخت `MOVE PARTITION` کار اگر برخی از قسمت های پارتیشن در حال حاضر بر روی دیسک مقصد یا حجم [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- اشکال ثابت با لینک های سخت عدم در طول جهش در ایجاد می شود `ReplicatedMergeTree` در تنظیمات چند دیسک. [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- رفع اشکال با یک جهش در ادغام زمانی که تمام قسمت بدون تغییر باقی می ماند و بهترین فضا است که بر روی دیسک دیگر یافت می شود [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- اشکال ثابت با `keep_free_space_ratio` از پیکربندی دیسکها قابل خواندن نیست [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- رفع اشکال با جدول شامل تنها `Tuple` ستون ها یا ستون ها با مسیرهای پیچیده. رفع [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([الساپین](https://github.com/alesapin)) +- حافظه را برای موتور بافر در حداکثر\_موری\_سیاژ حساب نکنید [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([ازات خوژین](https://github.com/azat)) +- رفع استفاده از علامت نهایی در `MergeTree` جداول مرتب شده بر اساس `tuple()`. در موارد نادر می تواند منجر به `Can't adjust last granule` خطا هنگام انتخاب. [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع اشکال در جهش که با اقداماتی که نیاز به زمینه (به عنوان مثال توابع برای جانسون) مسند که ممکن است منجر به سقوط و یا استثنا عجیب و غریب. [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([الساپین](https://github.com/alesapin)) +- رفع عدم تطابق پایگاه داده و نام جدول فرار در `data/` و `shadow/` & فهرستهای راهنما [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([الکساندر بورمک](https://github.com/Alex-Burmak)) +- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. رفع سقوط در این مورد. [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([زویکوف](https://github.com/4ertus2)) +- ثابت `Not found column in block` هنگام پیوستن به در بیان با راست یا کامل ملحق. [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([زویکوف](https://github.com/4ertus2)) +- یکی دیگر از تلاش برای رفع حلقه بی نهایت در `PrettySpace` قالب [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- رفع اشکال در `concat` تابع زمانی که همه استدلال شد `FixedString` از همان اندازه. [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([الساپین](https://github.com/alesapin)) +- استثنا ثابت در صورت استفاده از 1 استدلال در حالی که تعریف اس3, نشانی اینترنتی و ذخیره سازی اچ دی. [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- رفع دامنه تفسیری برای نمایش با پرس و جو [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([ازات خوژین](https://github.com/azat)) + +#### بهبود {#improvement} + +- `Nullable` ستون به رسمیت شناخته شده و تهی ارزش به درستی توسط ان بی سی پل به کار گرفته [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([واسیلی نمکو](https://github.com/Enmk)) +- ارسال دسته ای در حال حاضر برای توزیع ارسال اتمی [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([ازات خوژین](https://github.com/azat)) +- پرتاب یک استثنا اگر ما می توانیم جدول برای نام ستون در پرس و جو تشخیص نیست. [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([زویکوف](https://github.com/4ertus2)) +- افزودن `merge_max_block_size` تنظیم به `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([زویکوف](https://github.com/4ertus2)) +- نمایش داده شد با `HAVING` و بدون `GROUP BY` فرض گروه های ثابت. پس, `SELECT 1 HAVING 1` در حال حاضر نتیجه را برمی گرداند. [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([ایموس پرنده](https://github.com/amosbird)) +- تجزیه پشتیبانی `(X,)` به عنوان تاپل شبیه به پایتون. [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([ایموس پرنده](https://github.com/amosbird)) +- ساخت `range` رفتارهای تابع تقریبا مانند یک پیتون. [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- افزودن `constraints` ستونها به جدول `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([ویتالی بارانو](https://github.com/vitlibar)) +- فرمت پوچ بهتر برای کنترل کننده تی پی, به طوری که ممکن است به استفاده از `select ignore() from table format Null` برای اندازه گیری نیروی هوایی پاکستان از طریق کلیک مشتری [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([ایموس پرنده](https://github.com/amosbird)) +- نمایش داده شد مانند `CREATE TABLE ... AS (SELECT (1, 2))` به درستی تجزیه شده است [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([هکز](https://github.com/hczhcz)) + +#### بهبود عملکرد {#performance-improvement} + +- عملکرد تجمع بیش از کلید های رشته کوتاه بهبود یافته است. [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([الکساندر کوزمنکوف](https://github.com/akuzm), [ایموس پرنده](https://github.com/amosbird)) +- یک پاس دیگر از تجزیه و تحلیل نحو/بیان را اجرا کنید تا بهینه سازی های بالقوه پس از پیش بینی های ثابت خورده شوند. [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([ایموس پرنده](https://github.com/amosbird)) +- استفاده از ذخیره سازی متا اطلاعات به ارزیابی بی اهمیت `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([ایموس پرنده](https://github.com/amosbird), [الکسی میلویدو](https://github.com/alexey-milovidov)) +- Vectorize پردازش `arrayReduce` شبیه به تجمعی `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([ایموس پرنده](https://github.com/amosbird)) +- بهبود صغیر در عملکرد `Kafka` مصرف [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([ایوان](https://github.com/abyss7)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement} + +- اضافه کردن پشتیبانی برای متقابل کامپایل به معماری پردازنده عاشق64. Refactor packager اسکریپت. [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([ایوان](https://github.com/abyss7)) +- باز کردن داروین-x86\_64 و لینوکس-aarch64 toolchains به نصب Docker دوره زمانی که ساختمان بسته [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([ایوان](https://github.com/abyss7)) +- به روز رسانی تصویر کارگر بارانداز برای باینری بسته بندی [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([ایوان](https://github.com/abyss7)) +- خطاهای کامپایل ثابت در مکینتاش کاتالینا [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([ارنست پلتایف](https://github.com/ernestp)) +- برخی از فاکتورگیری مجدد در منطق تجزیه و تحلیل پرس و جو: تقسیم کلاس پیچیده را به چند ساده. [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([زویکوف](https://github.com/4ertus2)) +- رفع ساخت بدون زیر منو [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([پرولر](https://github.com/proller)) +- بهتر `add_globs` در فایل های کیک [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([ایموس پرنده](https://github.com/amosbird)) +- حذف مسیرهای سختشده در `unwind` هدف [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([کنستانتین پودشوموک](https://github.com/podshumok)) +- مجاز به استفاده از فرمت خروجی زیر بدون اس اس ال [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([پرولر](https://github.com/proller)) + +#### غیره {#other} + +- اضافه شده ANTLR4 گرامر برای ClickHouse SQL گویش [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +## انتشار کلیک 19.16 {#clickhouse-release-v19-16} + +#### انتشار کلیک 19.16.14.65, 2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} + +- رفع اشکال در محاسبات باریکش از عملیات منطقی سه تایی در استدلال های متعدد (بیش از 10). [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([الکساندر کازاکوف](https://github.com/Akazz)) این bugfix شد backported به نسخه 19.16 توسط یک درخواست ویژه از Altinity. + +#### انتشار کلیک 19.16.14.65, 2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} + +- رفع ناسازگاری خرده فروشی توزیع با نسخه های قدیمی تر کانال. رفع [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) + [(تبلوبیکس)](https://github.com/tavplubix) +- هنگام اجرای `CREATE` پرس و جو, برابر عبارات ثابت در استدلال موتور ذخیره سازی. جایگزین کردن نام دادگان خالی با دادگان فعلی. رفع [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). همچنین رفع بررسی برای نشانی محلی در `ClickHouseDictionarySource`. + [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(تبلوبیکس)](https://github.com/tavplubix) +- در حال حاضر پس زمینه ادغام در `*MergeTree` موتورهای جدول خانواده حفظ سیاست ذخیره سازی حجم سفارش دقیق تر. + [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- جلوگیری از از دست دادن داده ها در `Kafka` در موارد نادر زمانی که استثنا اتفاق می افتد پس از خواندن پسوند اما قبل از ارتکاب. رفع [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). مرتبط: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) + [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(فیلیمونف)](https://github.com/filimonov) +- رفع اشکال منجر به ختم سرور در هنگام تلاش برای استفاده / رها کردن `Kafka` جدول ایجاد شده با پارامترهای اشتباه. رفع [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). دارای [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). + [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(فیلیمونف)](https://github.com/filimonov) +- اجازه استفاده `MaterializedView` با subqueries بالا `Kafka` میز + [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([فیلیمونف](https://github.com/filimonov)) + +#### ویژگی جدید {#new-feature-1} + +- افزودن `deduplicate_blocks_in_dependent_materialized_views` گزینه ای برای کنترل رفتار درج ژولیده به جداول با نمایش محقق. این ویژگی جدید توسط یک درخواست ویژه از التیت به نسخه رفع اشکال اضافه شد. + [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [.)](https://github.com/urykhy) + +### انتشار کلیک خانه 19.16.2.2, 2019-10-30 {#clickhouse-release-v19-16-2-2-2019-10-30} + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-1} + +- اضافه کردن گم شده arity اعتبار برای تعداد/counIf. + [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) + [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([ولادیمیر](https://github.com/Vdimir)) +- حذف میراث `asterisk_left_columns_only` تنظیم (به طور پیش فرض غیر فعال شد). + [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([علم هنر + زویکوف](https://github.com/4ertus2)) +- رشته فرمت برای قالب فرمت داده در حال حاضر در فایل های مشخص شده است. + [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([تاولوبیکس](https://github.com/tavplubix)) + +#### ویژگی جدید {#new-feature-2} + +- معرفی uniqCombined64() برای محاسبه cardinality بیشتر از UINT\_MAX. + [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), + [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([ازات + خوژین](https://github.com/azat)) +- پشتیبانی از شاخص های فیلتر بلوم در ستون های مجموعه. + [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) + ([ایشیمب](https://github.com/achimbab)) +- اضافه کردن یک تابع `getMacro(name)` که رشته را برمی گرداند با ارزش مربوطه `` + از پیکربندی سرور. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) + ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تنظیم دو گزینه پیکربندی برای یک فرهنگ لغت بر اساس یک منبع قام: `credentials` و + `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([گیمه + کاسری](https://github.com/YiuRULE)) +- افزودن سابقه جدید `Merge` که تعداد پس زمینه راه اندازی ادغام. + [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([میخیل + کوروتف](https://github.com/millb)) +- اضافه کردن تابع نام کامل است که یک نام دامنه به طور کامل واجد شرایط را برمی گرداند. + [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) + [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- افزودن تابع `arraySplit` و `arrayReverseSplit` که یک مجموعه تقسیم شده توسط “cut off” + شرایط. در دست زدن به توالی زمان مفید هستند. + [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([هکز](https://github.com/hczhcz)) +- اضافه کردن توابع جدید است که بازگشت مجموعه ای از تمام شاخص های همسان در خانواده چند از توابع. + [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([دنیلا + کوتنین](https://github.com/danlark1)) +- اضافه کردن یک موتور پایگاه داده جدید `Lazy` این است که برای ذخیره سازی تعداد زیادی از کوچک ورود به سیستم بهینه شده است + میز [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([نیکیتا + واسیلیف](https://github.com/nikvas0)) +- اضافه کردن توابع جمع گروهبیت مپند,- یا, - صخره نوردی برای ستون بیت مپ. [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([ژیچنگ + یو](https://github.com/yuzhichang)) +- اضافه کردن مجموع عملکرد combinators -OrNull و OrDefault که بازگشت تهی + یا مقادیر پیش فرض زمانی که هیچ چیز به جمع وجود دارد. + [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) + ([هکز](https://github.com/hczhcz)) +- قالب داده های سفارشی را معرفی کنید که از فرار سفارشی پشتیبانی می کند و + قوانین جداساز. [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([تاولوبیکس](https://github.com/tavplubix)) +- پشتیبانی ردیس به عنوان منبع فرهنگ لغت خارجی. [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([کموندی](https://github.com/comunodi), [انتون + پوپوف](https://github.com/CurtizJ)) + +#### رفع اشکال {#bug-fix-2} + +- رفع نتیجه پرس و جو اشتباه در صورتی که `WHERE IN (SELECT ...)` بخش و `optimize_read_in_order` هست + استفاده می شود. [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([انتون + پوپوف](https://github.com/CurtizJ)) +- پلاگین احراز هویت ماریادب غیر فعال, که بستگی به فایل های خارج از پروژه. + [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([یوری + بارانوف](https://github.com/yurriy)) +- رفع استثنا `Cannot convert column ... because it is constant but values of constants are different in source and result` که به ندرت می تواند رخ دهد زمانی که توابع `now()`, `today()`, + `yesterday()`, `randConstant()` استفاده می شود. + [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([نیکولای + کوچتو](https://github.com/KochetovNicolai)) +- شماره ثابت با استفاده از اچ.تی. پی را نگه دارید ایست زنده به جای تی. پی نگه داشتن ایست زنده است. + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([واسیلی + نمکو](https://github.com/Enmk)) +- گسل تقسیم بندی را در گروهبیتماپور ثابت کرد (شماره [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). + [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([ژیچنگ + یو](https://github.com/yuzhichang)) +- برای نمایش تحقق مرتکب کافکا نامیده می شود پس از تمام داده ها نوشته شده است. + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([ایوان](https://github.com/abyss7)) +- اشتباه ثابت `duration_ms` مقدار در `system.part_log` جدول ده بار خاموش بود. + [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([ولادیمیر + Chebotarev](https://github.com/excitoon)) +- رفع سریع برای حل و فصل سقوط در جدول نمایش زنده و دوباره قادر می سازد تمام تست نمایش زنده. + [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) + ([وزکازنیکوف](https://github.com/vzakaznikov)) +- مرتب کردن مقادیر صفر به درستی در شاخص دقیقه/حداکثر از قطعات ادغام. + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([الکساندر + کوزمنکوف](https://github.com/akuzm)) +- هنوز ستون مجازی به قرار داده نشده .ابرداده گذاشتن زمانی که جدول به عنوان ایجاد شده است `CREATE TABLE AS`. + [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([ایوان](https://github.com/abyss7)) +- رفع گسل تقسیم بندی در `ATTACH PART` پرس و جو. + [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) + ([الساپین](https://github.com/alesapin)) +- رفع نتیجه اشتباه برای برخی از نمایش داده شد داده شده توسط بهینه سازی خالی در کارخانه های فرعی و خالی + INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([نیکولای + کوچتو](https://github.com/KochetovNicolai)) +- رفع AddressSanitizer خطا در نمایش زنده getHeader روش (). + [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) + ([وزکازنیکوف](https://github.com/vzakaznikov)) + +#### بهبود {#improvement-1} + +- اضافه کردن یک پیام در صورت صبر کردن \_موا\_مایش صورت می گیرد. + [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([ازات + خوژین](https://github.com/azat)) +- تنظیم ساخته شده `s3_min_upload_part_size` جدول سطح. + [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([ولادیمیر + Chebotarev](https://github.com/excitoon)) +- در حال بارگذاری [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) + ([بستنی و مغز گردو](https://github.com/sundy-li)) +- بلوک کدو دست چپ در ادغام بخشی ملحق (بهینه سازی). + [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([علم هنر + زویکوف](https://github.com/4ertus2)) +- اجازه ندهید که توابع غیر قطعی در جهش موتورهای جدول تکرار, چرا که این + می توانید تناقضات بین کپی معرفی. + [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([الکساندر + کازاکوف](https://github.com/Akazz)) +- غیر فعال کردن ردیاب حافظه در حالی که تبدیل ردیابی پشته استثنا به رشته. این می تواند از دست دادن جلوگیری کند + از پیغام خطا از نوع `Memory limit exceeded` بر روی سرور, که باعث `Attempt to read after eof` استثنا در مشتری. [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) + ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- بهبود فرمت های دیگر. برطرف + [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), + [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), + [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), + [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) + [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) + ([تاولوبیکس](https://github.com/tavplubix)) +- خانه را نادیده می گیرد ارزش در سمت راست در اپراتور که قابل تبدیل به سمت چپ نیست + side type. Make it work properly for compound types – Array and Tuple. + [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([الکساندر + کوزمنکوف](https://github.com/akuzm)) +- پشتیبانی از نابرابری های از دست رفته برای عضویت. این ممکن است برای پیوستن به نوع کمتر یا برابر و سخت + انواع بیشتر و کمتر برای ستون اسوف در نحو. + [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([علم هنر + زویکوف](https://github.com/4ertus2)) +- بهینه سازی بخشی ادغام اضافه کردن. [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) + ([زویکوف](https://github.com/4ertus2)) +- آیا استفاده از بیش از 98K حافظه در uniqCombined توابع. + [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), + [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([ازات + خوژین](https://github.com/azat)) +- قطعات خیط و پیت کردن از جدول پیوستن به دست راست بر روی دیسک در پارتیالمگرمین (اگر کافی نیست + حافظه). بارگیری داده ها در صورت نیاز. [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) + ([زویکوف](https://github.com/4ertus2)) + +#### بهبود عملکرد {#performance-improvement-1} + +- سرعت جوینت با استدلال توایع با اجتناب از تکرار داده ها. + [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([ایموس + پرنده](https://github.com/amosbird)) +- بازگشت اولیه اگر زیرخاکری خالی است. + [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) +- بهینه سازی تجزیه بیان گذاشتن در مقادیر. + [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) + ([تاولوبیکس](https://github.com/tavplubix)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-1} + +- غیر فعال کردن برخی از موارد برای متقابل تلفیقی به سیستم عامل مک. + [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([ایوان](https://github.com/abyss7)) +- اضافه کردن گم شده ارتباط با PocoXML برای clickhouse\_common\_io. + [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([ازات + خوژین](https://github.com/azat)) +- قبول استدلال فیلتر تست های متعدد در فاحشه خانه تست. + [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([الکساندر + کوزمنکوف](https://github.com/akuzm)) +- فعال musl و jemalloc برای ARM. [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) + ([ایموس پرنده](https://github.com/amosbird)) +- اضافه شده `--client-option` پارامتر به `clickhouse-test` به تصویب پارامترهای اضافی به مشتری. + [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([نیکولای + کوچتو](https://github.com/KochetovNicolai)) +- حفظ تنظیمات موجود در دور در دقیقه ارتقا بسته. + [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) + ([فیلیمونف](https://github.com/filimonov)) +- رفع خطاهای شناسایی شده توسط پوس. [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([علم هنر + زویکوف](https://github.com/4ertus2)) +- رفع ساخت برای داروین. [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) + ([ایوان](https://github.com/abyss7)) +- glibc 2.29 سازگاری. [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([ایموس + پرنده](https://github.com/amosbird)) +- اطمینان حاصل کنید که دکلین می کند فایل های منبع بالقوه را لمس نمی. + [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([ایموس + پرنده](https://github.com/amosbird)) +- تلاش برای جلوگیری از درگیری در هنگام به روز رسانی از دور در دقیقه التیت - فایل پیکربندی بسته بندی شده به طور جداگانه + در کلیک-سرور-مشترک. [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) + ([فیلیمونف](https://github.com/filimonov)) +- بهینه سازی برخی از فایل های هدر برای بازسازی سریع تر. + [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), + [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([الکساندر + کوزمنکوف](https://github.com/akuzm)) +- اضافه کردن تست عملکرد برای تاریخ و تاریخ ساعت. [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([واسیلی + نمکو](https://github.com/Enmk)) +- رفع برخی از تست هایی که حاوی جهش های غیر قطعی هستند. + [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([الکساندر + کازاکوف](https://github.com/Akazz)) +- اضافه کردن ساخت با حفظ به سی. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) + ([الکساندر کوزمنکوف](https://github.com/akuzm)) +- اجتناب از استفاده از ارزش های بی قید و شرط در مترسستر. + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([ازات + خوژین](https://github.com/azat)) +- رفع برخی از مشکلات در زمینه های پیدا شده توسط حفظ کننده. + [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), + [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([الکساندر + کوزمنکوف](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) + ([ایموس پرنده](https://github.com/amosbird)) +- رفع رفتار تعریف نشده در سوفلش32. [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([ایموس + پرنده](https://github.com/amosbird)) +- رفع رفتار تعریف نشده در استورگیسنفستولینگ. [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) + ([تاولوبیکس](https://github.com/tavplubix)) +- عبارات ثابت ثابت تاشو برای موتورهای پایگاه داده خارجی (خروجی زیر ,او بی سی, ال بی سی). در گذشته + نسخه این بود برای عبارات ثابت متعدد کار نمی کند و در همه برای تاریخ کار نمی کند, + تاریخ ساعت و امید. این رفع [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) + ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع ThreadSanitizer اطلاعات مسابقه خطا در نمایش زنده در هنگام دسترسی به no\_users\_thread متغیر است. + [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) + ([وزکازنیکوف](https://github.com/vzakaznikov)) +- خلاص شدن از شر نمادها مالوک در لیبکمون + [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), + [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([ایموس + پرنده](https://github.com/amosbird)) +- اضافه کردن توانمندسازهای پرچم جهانی برای غیر فعال کردن تمام کتابخانه ها. + [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) + ([پرولر](https://github.com/proller)) + +#### پاکسازی کد {#code-cleanup} + +- تعمیم مخزن پیکربندی برای تهیه دی ال برای لغت نامه. [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) + ([الساپین](https://github.com/alesapin)) +- تجزیه کننده برای لغت نامه دی ال بدون هیچ معنایی. + [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) + ([الساپین](https://github.com/alesapin)) +- تقسیم پارسرکری به تجزیه کننده های مختلف کوچکتر. + [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) + ([الساپین](https://github.com/alesapin)) +- فاکتورگیری مجدد کوچک و تغییر نام در نزدیکی لغت نامه های خارجی. + [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) + ([الساپین](https://github.com/alesapin)) +- گیرنده برخی از کد برای تهیه برای کنترل دسترسی مبتنی بر نقش. [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([ویتالی + بارانوف](https://github.com/vitlibar)) +- برخی از پیشرفت های در کد بانک اطلاعاتی. + [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([نیکیتا + واسیلیف](https://github.com/nikvas0)) +- آیا استفاده از iterators در پیدا کردن() و emplace() روش جداول هش. + [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([الکساندر + کوزمنکوف](https://github.com/akuzm)) +- رفع گیرنده در صورتی که ریشه پارامتر خالی نیست. [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) + ([میخیل کوروتف](https://github.com/millb)) +- حذف برخی از کپی و چسباندن (TemporaryFile و TemporaryFileStream) + [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([علم هنر + زویکوف](https://github.com/4ertus2)) +- بهبود خوانایی کد کمی (`MergeTreeData::getActiveContainingPart`). + [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([ولادیمیر + Chebotarev](https://github.com/excitoon)) +- منتظر تمام مشاغل برنامه ریزی شده باشید که از اشیا محلی استفاده می کنند `ThreadPool::schedule(...)` پرت + یک استثنا. تغییر نام `ThreadPool::schedule(...)` به `ThreadPool::scheduleOrThrowOnError(...)` و + رفع نظرات برای ایجاد واضح است که ممکن است پرتاب. + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) + ([تاولوبیکس](https://github.com/tavplubix)) + +## انتشار کلیک 19.15 {#clickhouse-release-19-15} + +### انتشار کلیک خانه 19.15.4.10, 2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} + +#### رفع اشکال {#bug-fix-3} + +- اضافه شده دست زدن به SQL\_TINYINT و SQL\_BIGINT و ثابت دست زدن به SQL\_FLOAT منبع داده در انواع ODBC پل. + [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([دنیس گلازاشف](https://github.com/traceon)) +- مجاز به برخی از قطعات بر روی دیسک مقصد و یا حجم در پارتیشن حرکت. + [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- ثابت NULL-ارزش در nullable ستون از طریق ODBC-پل. + [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([واسیلی نمکو](https://github.com/Enmk)) +- درج ثابت به گره غیر محلی توزیع شده با ستون محقق. + [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([ازات خوژین](https://github.com/azat)) +- تابع ثابت دریافت می کند. + [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([میخیل کوروتف](https://github.com/millb)) +- شماره ثابت با استفاده از اچ.تی. پی را نگه دارید ایست زنده به جای تی. پی نگه داشتن ایست زنده است. + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([واسیلی نمکو](https://github.com/Enmk)) +- صبر کنید برای همه مشاغل را به پایان برساند در استثنا (رفع حملات نادر). + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([تاولوبیکس](https://github.com/tavplubix)) +- هنگام وارد کردن به میز کافکا به موفکا فشار ندهید. + [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([ایوان](https://github.com/abyss7)) +- غیر فعال کردن ردیاب حافظه برای استثنا پشته. + [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- کد بد ثابت در تبدیل پرس و جو برای پایگاه داده خارجی. + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجتناب از استفاده از ارزش های بی قید و شرط در مترسستر. + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([ازات خوژین](https://github.com/azat)) +- اضافه شده به عنوان مثال پیکربندی با ماکروها برای تست ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.15.3.6, 2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} + +#### رفع اشکال {#bug-fix-4} + +- بد\_واریانت ثابت در درهم فرهنگ لغت. + ([الساپین](https://github.com/alesapin)) +- ثابت کردن اشکال با گسل تقسیم بندی در ضمیمه پرس و جو بخش. + ([الساپین](https://github.com/alesapin)) +- محاسبه زمان ثابت در `MergeTreeData`. + ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- متعهد به کافکا به صراحت پس از نوشتن نهایی است. + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([ایوان](https://github.com/abyss7)) +- مرتب کردن مقادیر صفر به درستی در شاخص دقیقه/حداکثر از قطعات ادغام. + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([الکساندر کوزمنکوف](https://github.com/akuzm)) + +### انتشار کلیک خانه 19.15.2.2, 2019-10-01 {#clickhouse-release-19-15-2-2-2019-10-01} + +#### ویژگی جدید {#new-feature-3} + +- ذخیره سازی چند طبقه: پشتیبانی از استفاده از حجم ذخیره سازی های متعدد برای جداول با موتور ادغام. امکان ذخیره داده های تازه بر روی اس اس دی و انتقال خودکار داده های قدیمی به هارد وجود دارد. ([مثال](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([ایگر](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([الساپین](https://github.com/alesapin)) +- اضافه کردن تابع جدول `input` برای خواندن داده های ورودی در `INSERT SELECT` پرس و جو. [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([هشدار داده می شود](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([انتون پوپوف](https://github.com/CurtizJ)) +- افزودن یک `sparse_hashed` طرح فرهنگ لغت, که عملکرد به معادل `hashed` طرح, اما حافظه بیشتر موثر است. این در مورد حافظه دو برابر کمتر با هزینه بازیابی ارزش کندتر استفاده می کند. [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([ازات خوژین](https://github.com/azat)) +- پیاده سازی توانایی تعریف لیستی از کاربران برای دسترسی به لغت نامه. فقط پایگاه داده متصل فعلی با استفاده از. [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- افزودن `LIMIT` گزینه ای برای `SHOW` پرس و جو. [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([فیلیپ مالکوفسکی](https://github.com/malkfilipp)) +- افزودن `bitmapSubsetLimit(bitmap, range_start, limit)` تابع, که زیر مجموعه از کوچکترین گرداند `limit` ارزش ها در مجموعه ای است که هیچ کوچکتر از `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([ژیچنگ یو](https://github.com/yuzhichang)) +- افزودن `bitmapMin` و `bitmapMax` توابع. [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([ژیچنگ یو](https://github.com/yuzhichang)) +- افزودن تابع `repeat` مربوط به [شماره-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([فلین](https://github.com/ucasFL)) + +#### ویژگی تجربی {#experimental-feature-1} + +- پیاده سازی (در حافظه) ادغام پیوستن به نوع که خط لوله فعلی را تغییر دهید. نتیجه تا حدی توسط کلید ادغام طبقه بندی شده اند. تنظیم `partial_merge_join = 1` برای استفاده از این ویژگی. ادغام پیوستن هنوز در حال توسعه است. [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([زویکوف](https://github.com/4ertus2)) +- افزودن `S3` موتور و عملکرد جدول. هنوز در حال توسعه است (هنوز پشتیبانی احراز هویت وجود ندارد). [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([ولادیمیر چبوتراف](https://github.com/excitoon)) + +#### بهبود {#improvement-2} + +- هر پیامی که از کافکا خوانده می شود به صورت عام وارد می شود. این حل مشکلات تقریبا همه شناخته شده با موتور کافکا. [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([ایوان](https://github.com/abyss7)) +- بهبود برای عدم موفقیت نمایش داده شد توزیع شده است. کوتاه شدن زمان بازیابی, همچنین در حال حاضر قابل تنظیم است و می تواند در دیده `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([واسیلی نمکو](https://github.com/Enmk)) +- پشتیبانی از مقادیر عددی برای شمارشی به طور مستقیم در `IN` بخش. \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([دیماروب2000](https://github.com/dimarub2000)) +- پشتیبانی (اختیاری, غیر فعال به طور پیش فرض) تغییرمسیر در ذخیره سازی نشانی وب. [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([رول](https://github.com/maqroll)) +- اضافه کردن پیام اطلاعات زمانی که مشتری با نسخه های قدیمی تر متصل به یک سرور. [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([فیلیپ مالکوفسکی](https://github.com/malkfilipp)) +- حذف حداکثر محدودیت زمانی خواب برای ارسال داده ها در جداول توزیع شده [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([ازات خوژین](https://github.com/azat)) +- اضافه کردن توانایی ارسال رویدادهای پروفایل (شمارنده) با ارزش تجمعی به گرافیت. این را می توان تحت فعال `` در کارساز `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([ازات خوژین](https://github.com/azat)) +- اضافه کردن نوع بازیگران به طور خودکار `T` به `LowCardinality(T)` در حالی که قرار دادن داده ها در ستون نوع `LowCardinality(T)` در قالب بومی از طریق قام. [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اضافه کردن توانایی استفاده از تابع `hex` بدون استفاده از `reinterpretAsString` برای `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([میخیل کوروتف](https://github.com/millb)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-2} + +- اضافه کردن گدی شاخص به کلیک باینری با اطلاعات اشکال زدایی. این سرعت زمان راه اندازی را افزایش می دهد `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([الساپین](https://github.com/alesapin)) +- بسته بندی با سرعت بالا با بسته بندی پچ پچ که با استفاده از `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([الساپین](https://github.com/alesapin)) +- تنظیم `enable_fuzzing = 1` برای فعال کردن ابزار دقیق رایگان از تمام کد پروژه. [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([کیپریزل](https://github.com/kyprizel)) +- اضافه کردن تست دود ساخت تقسیم در سی. [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([الساپین](https://github.com/alesapin)) +- اضافه کردن ساخت با حفظ به سی. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([الکساندر کوزمنکوف](https://github.com/akuzm)) +- جایگزینی `libsparsehash` با `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([ازات خوژین](https://github.com/azat)) + +#### رفع اشکال {#bug-fix-5} + +- تجزیه عملکرد ثابت تجزیه و تحلیل شاخص بر روی کلید های پیچیده در جداول بزرگ. این رفع \# 6924. [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع خطا منطقی باعث حملات در هنگام انتخاب از کافکا موضوع خالی. [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([ایوان](https://github.com/abyss7)) +- رفع خیلی زود خروجی زیر اتصال نزدیک در `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- پشتیبانی از دانه های لینوکس بسیار قدیمی (ثابت [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع از دست دادن داده ها ممکن است در `insert select` پرس و جو در صورت بلوک خالی در جریان ورودی. \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- ثابت برای عملکرد `АrrayEnumerateUniqRanked` با بند خالی در پارامز [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([پرولر](https://github.com/proller)) +- رفع نمایش داده شد پیچیده با مجموعه ای می پیوندد و فرعی جهانی است. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([ایوان](https://github.com/abyss7)) +- ثابت `Unknown identifier` خطا در ترتیب و گروه با چند می پیوندد [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([زویکوف](https://github.com/4ertus2)) +- ثابت `MSan` هشدار هنگام اجرای تابع با `LowCardinality` استدلال کردن. [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-2} + +- تغییر فرمت ترتیب از بیت مپ \* تابع مجموع می گوید برای بهبود عملکرد. ایالات سریال بیت مپ\* از نسخه های قبلی را نمی توان به عنوان خوانده شده. [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([ژیچنگ یو](https://github.com/yuzhichang)) + +## انتشار کلیک 19.14 {#clickhouse-release-19-14} + +### ClickHouse انتشار 19.14.7.15, 2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} + +#### رفع اشکال {#bug-fix-6} + +- این نسخه همچنین شامل تمام رفع اشکال از 19.11.12.69. +- سازگاری ثابت برای نمایش داده شد توزیع بین 19.14 و نسخه های قبلی. این رفع [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### ClickHouse انتشار 19.14.6.12, 2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} + +#### رفع اشکال {#bug-fix-7} + +- ثابت برای عملکرد `АrrayEnumerateUniqRanked` با بند خالی در پارامز. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([پرولر](https://github.com/proller)) +- نام زیرخاکی ثابت در نمایش داده شد با `ARRAY JOIN` و `GLOBAL IN subquery` با نام مستعار. استفاده از نام مستعار زیرخاکی برای نام جدول خارجی اگر مشخص شده است. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([ایوان](https://github.com/abyss7)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-3} + +- ثابت [زدن](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) تست `00715_fetch_merged_or_mutated_part_zookeeper` با بازنویسی به اسکریپت پوسته چون نیاز به صبر برای جهش به درخواست. [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([الکساندر کازاکوف](https://github.com/Akazz)) +- شکست ثابت اوبسان و ممسان در عملکرد `groupUniqArray` با استدلال امتپی ار این با قرار دادن خالی ایجاد شد `PaddedPODArray` به هش جدول صفر سلول به دلیل سازنده برای ارزش سلول صفر نامیده می شد. [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([ایموس پرنده](https://github.com/amosbird)) + +### انتشار کلیک خانه 19.14.3.3, 2019-09-10 {#clickhouse-release-19-14-3-3-2019-09-10} + +#### ویژگی جدید {#new-feature-4} + +- `WITH FILL` تغییردهنده برای `ORDER BY`. (ادامه [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([انتون پوپوف](https://github.com/CurtizJ)) +- `WITH TIES` تغییردهنده برای `LIMIT`. (ادامه [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([انتون پوپوف](https://github.com/CurtizJ)) +- تجزیه unquoted `NULL` تحت اللفظی به عنوان پوچ (اگر تنظیم `format_csv_unquoted_null_literal_as_null=1`). مقداردهی اولیه زمینه های تهی با مقادیر پیش فرض اگر نوع داده ها از این زمینه است قابل ابطال نیست (اگر تنظیم `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([تاولوبیکس](https://github.com/tavplubix)) +- پشتیبانی از نویسه عام در مسیرهای توابع جدول `file` و `hdfs`. اگر مسیر شامل نویسه عام, جدول خوانده خواهد شد. مثال استفاده: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` و `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- جدید `system.metric_log` جدول که ارزش ها را ذخیره می کند `system.events` و `system.metrics` با فاصله زمانی مشخص شده است. [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجازه به نوشتن سیاهههای مربوط به متن کلیک به `system.text_log` جدول [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نمایش علامت خصوصی در اثری پشته (این است که از طریق تجزیه جداول نماد فایل های جن انجام). اضافه شدن اطلاعات در مورد فایل و شماره خط در اثری پشته اگر اطلاعات اشکال زدایی وجود دارد. نام نماد افزایش سرعت مراجعه با علامت نمایه سازی در حال حاضر در برنامه. اضافه شده توابع جدید گذاشتن برای درون گرایی: `demangle` و `addressToLine`. تابع تغییر نام داد `symbolizeAddress` به `addressToSymbol` برای ثبات. تابع `addressToSymbol` خواهد نام لت و پار به دلایل عملکرد بازگشت و شما باید به درخواست `demangle`. اضافه شدن تنظیمات `allow_introspection_functions` که به طور پیش فرض خاموش است. [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تابع جدول `values` (نام غیر حساس به حروف است). این اجازه می دهد تا از خواندن `VALUES` فهرست پیشنهادی در [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). مثال: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([دیماروب2000](https://github.com/dimarub2000)) +- توانایی تغییر تنظیمات ذخیره سازی اضافه شده است. نحو: `ALTER TABLE MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([الساپین](https://github.com/alesapin)) +- پشتیبانی از حذف قطعات جدا شده. نحو: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([تاولوبیکس](https://github.com/tavplubix)) +- محدودیت های جدول. اجازه می دهد تا برای اضافه کردن محدودیت به تعریف جدول خواهد شد که در درج بررسی می شود. [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([گلب نویکوف](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پشتیبانی برای نمایش ساختگی محقق. [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([ایموس پرنده](https://github.com/amosbird)) +- روشن کردن پیشفیلتر پرس و جو به طور پیش فرض برای نمونه هر موضوع اعدام پرس و جو یک بار در ثانیه. [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- قالب ورودی `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([اکونیک 90](https://github.com/akonyaev90)) +- اضافه شدن دو توابع جدید: `sigmoid` و `tanh` (که برای برنامه های کاربردی یادگیری ماشین مفید هستند). [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تابع `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` برای بررسی اگر نشانه داده شده است در انبار کاه. رمز یک زیر رشته طول حداکثر بین دو شخصیت اسکی غیر الفبایی است (یا مرزهای انبار کاه). رمز باید یک رشته ثابت باشد. پشتیبانی شده توسط تخصص شاخص توکنبف1. [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([واسیلی نمکو](https://github.com/Enmk)) +- عملکرد جدید `neighbor(value, offset[, default_value])`. اجازه می دهد تا برای رسیدن به مقدار قبلی/بعدی در ستون در یک بلوک از داده ها. [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([الکس کرش](https://github.com/alex-krash)) [6685365اب8ک5ب74ف9650492ج88012596ب1ب06](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341الکترونیکی4587وا18065سی2دا1ک888ج73389ف48ک36 درجه سانتیگراد](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [الکسی میلویدو](https://github.com/alexey-milovidov) +- ایجاد یک تابع `currentUser()`, ورود بازگشت از کاربر مجاز. نام مستعار اضافه شده است `user()` برای سازگاری با خروجی زیر. [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([الکس کرش](https://github.com/alex-krash)) +- توابع جدید مجموع `quantilesExactInclusive` و `quantilesExactExclusive` که در پیشنهاد شد [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([دیماروب2000](https://github.com/dimarub2000)) +- تابع `bitmapRange(bitmap, range_begin, range_end)` که برمی گرداند مجموعه ای جدید با محدوده مشخص شده (شامل نمی شود `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([ژیچنگ یو](https://github.com/yuzhichang)) +- تابع `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` که مجموعه ای از رشته های دقیق طولانی از جعبه های جغرافیایی را پوشش می دهد. [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([واسیلی نمکو](https://github.com/Enmk)) +- پیاده سازی پشتیبانی برای قرار دادن پرس و جو با `Kafka` میز [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([ایوان](https://github.com/abyss7)) +- اضافه شدن پشتیبانی برای `_partition` و `_timestamp` ستون مجازی به موتور کافکا. [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([ایوان](https://github.com/abyss7)) +- امکان حذف اطلاعات حساس از `query_log`, سیاهههای مربوط به سرور, لیست فرایند با قوانین مبتنی بر عبارت منظم. [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([فیلیمونف](https://github.com/filimonov)) + +#### ویژگی تجربی {#experimental-feature-2} + +- فرمت داده ورودی و خروجی `Template`. این اجازه می دهد برای مشخص رشته فرمت های سفارشی برای ورودی و خروجی. [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([تاولوبیکس](https://github.com/tavplubix)) +- اجرای `LIVE VIEW` جداول که در اصل در پیشنهاد شد [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898) در حال بارگذاری [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925) و سپس به روز شده در [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). ببینید [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) برای شرح مفصلی. [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([وزکازنیکوف](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([وزکازنیکوف](https://github.com/vzakaznikov)) توجه داشته باشید که `LIVE VIEW` ویژگی ممکن است در نسخه های بعدی حذف شده است. + +#### رفع اشکال {#bug-fix-8} + +- این نسخه همچنین شامل رفع اشکال از 19.13 و 19.11. +- رفع گسل تقسیم بندی زمانی که جدول شاخص جست و خیز و ادغام عمودی اتفاق می افتد. [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([الساپین](https://github.com/alesapin)) +- رفع ستون در هر ستون با پیش فرض ستون غیر بدیهی است. پیش از این در مورد نیروی تی ال ادغام با `OPTIMIZE ... FINAL` پرس و جو, ارزش منقضی شده توسط پیش فرض نوع به جای پیش فرض ستون مشخص شده توسط کاربر جایگزین شد. [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع مشکل پیام های کافکا تقلید در راه اندازی مجدد سرور طبیعی است. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([ایوان](https://github.com/abyss7)) +- حلقه بی نهایت ثابت در هنگام خواندن پیام کافکا. مکث نکنید / مصرف کننده رزومه در اشتراک در همه-در غیر این صورت ممکن است به طور نامحدود در برخی از حالات متوقف. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([ایوان](https://github.com/abyss7)) +- ثابت `Key expression contains comparison between inconvertible types` استثنا در `bitmapContains` تابع. [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([دیماروب2000](https://github.com/dimarub2000)) +- اصلاح سگو با فعال `optimize_skip_unused_shards` و از دست رفته کلید شاردینگ. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([انتون پوپوف](https://github.com/CurtizJ)) +- کد اشتباه ثابت در جهش است که ممکن است به فساد حافظه منجر شود. سگو ثابت با خواندن نشانی `0x14c0` که ممکن است به دلیل همزمان اتفاق `DROP TABLE` و `SELECT` از `system.parts` یا `system.parts_columns`. شرایط مسابقه ثابت در تهیه نمایش داده شد جهش. بن بست ثابت ناشی از `OPTIMIZE` از جداول تکرار و عملیات اصلاح همزمان مانند تغییر. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حذف ورود به سیستم طولانی اضافی در رابط خروجی زیر [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بازگشت توانایی به تجزیه تنظیمات بولی از ‘true’ و ‘false’ در فایل پیکربندی. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([الساپین](https://github.com/alesapin)) +- رفع سقوط در `quantile` و `median` عملکرد بیش از `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([زویکوف](https://github.com/4ertus2)) +- ثابت نتیجه ناقص ممکن توسط بازگشت `SELECT` پرسوجو با `WHERE` شرایط در کلید اولیه شامل تبدیل به نوع شناور. این با چک کردن نادرست از یکنواختی در ایجاد شد `toFloat` تابع. [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([دیماروب2000](https://github.com/dimarub2000)) +- بررسی `max_expanded_ast_elements` تنظیم برای جهش. پاک کردن جهش پس از `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([زمستان ژانگ](https://github.com/zhang2014)) +- ثابت پیوستن به نتایج برای ستون های کلیدی زمانی که با استفاده `join_use_nulls`. ضمیمه نقاط صفر به جای ستون پیش فرض. [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([زویکوف](https://github.com/4ertus2)) +- ثابت برای پرش شاخص با ادغام عمودی و تغییر دهید. ثابت برای `Bad size of marks file` استثنا. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([الساپین](https://github.com/alesapin)) +- رفع سقوط نادر در `ALTER MODIFY COLUMN` و ادغام عمودی زمانی که یکی از قطعات ادغام شده/تغییر داده شده خالی است (0 ردیف) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([الساپین](https://github.com/alesapin)) +- اشکال ثابت در تبدیل `LowCardinality` انواع در `AggregateFunctionFactory`. این رفع [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع رفتار اشتباه و حملات احتمالی در `topK` و `topKWeighted` توابع جمع. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([انتون پوپوف](https://github.com/CurtizJ)) +- کد ناامن ثابت در اطراف `getIdentifier` تابع. [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اشکال ثابت در خروجی زیر پروتکل سیم (استفاده می شود در حالی که اتصال به خانه فرم خروجی زیر مشتری). ناشی از سرریز بافر پشته در `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([یوری بارانوف](https://github.com/yurriy)) +- نشت حافظه ثابت در `bitmapSubsetInRange` تابع. [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([ژیچنگ یو](https://github.com/yuzhichang)) +- رفع اشکال نادر زمانی که جهش اجرا پس از تغییر دانه بودن. [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([الساپین](https://github.com/alesapin)) +- اجازه دادن به پیام پروتوبوف با تمام زمینه ها به طور پیش فرض. [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع اشکال با `nullIf` تابع هنگامی که ما ارسال `NULL` استدلال در بحث دوم. [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- رفع اشکال نادر با تخصیص حافظه اشتباه / تخصیص در لغت نامه کش کلید پیچیده با رشته های رشته ای که منجر به مصرف حافظه بی نهایت (به نظر می رسد مانند نشت حافظه). اشکال بازتولید زمانی که اندازه رشته قدرت دو شروع از هشت بود (8, 16, 32, و غیره). [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([الساپین](https://github.com/alesapin)) +- پشتیبانی می کند گوریل ثابت در توالی های کوچک که باعث استثنا `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([واسیلی نمکو](https://github.com/Enmk)) +- اجازه استفاده از انواع قابل ابطال نیست در می پیوندد با `join_use_nulls` فعال شد [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([زویکوف](https://github.com/4ertus2)) +- غیرفعالسازی `Poco::AbstractConfiguration` جایگزینی پرسوجو در `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجتناب از بن بست در `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- با استفاده از `arrayReduce` برای استدلال های ثابت ممکن است به پیش فرض منجر شود. [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع قطعات متناقض است که می تواند به نظر می رسد اگر ماکت پس از ترمیم شد `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([تاولوبیکس](https://github.com/tavplubix)) +- ثابت قطع در `JSONExtractRaw` تابع. [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال با نادرست جست و خیز شاخص ترتیب و تجمع با دانه دانه تطبیقی. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([الساپین](https://github.com/alesapin)) +- ثابت `WITH ROLLUP` و `WITH CUBE` اصلاح کننده های `GROUP BY` با تجمع دو سطح. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع اشکال با نوشتن شاخص ثانویه نشانه با دانه دانه تطبیقی. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([الساپین](https://github.com/alesapin)) +- رفع مقدار دهی اولیه سفارش در حالی که راه اندازی سرور. از `StorageMergeTree::background_task_handle` مقدار دهی اولیه در `startup()` این `MergeTreeBlockOutputStream::write()` ممکن است سعی کنید قبل از مقدار دهی اولیه استفاده کنید. فقط بررسی کنید اگر مقداردهی اولیه شده است. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([ایوان](https://github.com/abyss7)) +- پاک کردن بافر داده ها از عملیات خواندن قبلی که با یک خطا تکمیل شد. [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([نیکولای](https://github.com/bopohaa)) +- رفع اشکال با فعال کردن دانه دانه تطبیقی در هنگام ایجاد یک ماکت جدید برای تکرار\*جدول ادغام. [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([الساپین](https://github.com/alesapin)) +- تصادف ممکن است ثابت در هنگام راه اندازی سرور در صورت استثنا در اتفاق افتاد `libunwind` در طول استثنا در دسترسی به بی قید و شرط `ThreadStatus` ساختار. [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) +- رفع سقوط در `yandexConsistentHash` تابع. پیدا شده توسط تست ریش شدن. [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت امکان معلق نمایش داده شد زمانی که سرور غیرمنتظره است و استخر موضوع جهانی در نزدیکی کامل می شود. این بالاتر شانس اتفاق می افتد در خوشه با تعداد زیادی از خرده ریز (صدها), به دلیل نمایش داده شد توزیع اختصاص یک موضوع در هر اتصال به هر سفال. مثلا, این موضوع ممکن است تکثیر اگر یک خوشه از 330 خرده ریز در حال پردازش 30 نمایش داده شد توزیع همزمان. این موضوع بر تمام نسخه های با شروع از 19.2. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- منطق ثابت `arrayEnumerateUniqRanked` تابع. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت شده است که جدول نماد رمز گشایی. [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([ایموس پرنده](https://github.com/amosbird)) +- استثنا بی ربط ثابت در بازیگران `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- حذف نقل قول اضافی از توضیحات در `system.settings` جدول [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجتناب از بن بست ممکن است در `TRUNCATE` از جدول تکرار. [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع خواندن به منظور مرتب سازی کلید. [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([انتون پوپوف](https://github.com/CurtizJ)) +- ثابت `ALTER TABLE ... UPDATE` پرسو جو برای جداول با `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([الساپین](https://github.com/alesapin)) +- رفع اشکال باز شده توسط [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (پیش 19.4.0). بازتولید در نمایش داده شد به جداول توزیع بیش از جداول ادغام هنگامی که ما هیچ ستون پرس و جو نیست (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([الساپین](https://github.com/alesapin)) +- سرریز ثابت در تقسیم عدد صحیح از نوع امضا شده به نوع بدون علامت. رفتار دقیقا همانطور که در ج یا ج++ زبان (قوانین ترویج عدد صحیح) که ممکن است جای تعجب بود. لطفا توجه داشته باشید که سرریز هنوز هم ممکن است در هنگام تقسیم تعداد زیادی امضا به تعداد بزرگ بدون علامت و یا بالعکس (اما این مورد کمتر معمول است). این موضوع در تمام نسخه های سرور وجود داشته است. [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- محدود کردن حداکثر زمان خواب برای متوقف کردن زمانی که `max_execution_speed` یا `max_execution_speed_bytes` قرار است. خطاهای غلط ثابت مانند `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- مشکلات ثابت در مورد استفاده از `MATERIALIZED` ستون ها و نام مستعار در `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([ایموس پرنده](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `FormatFactory` رفتار برای جریان ورودی که به عنوان پردازنده اجرا نمی شود. [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- خطای تایپی ثابت. [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([الکس ریندین](https://github.com/alexryndin)) +- خطای تایپی در پیام خطا (است - \> هستند ). [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([دنیس ژورولو](https://github.com/den-crane)) +- خطا ثابت در حالی که تجزیه لیست ستون از رشته اگر نوع حاوی کاما (این موضوع مربوط به بود `File`, `URL`, `HDFS` ذخیره سازی) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([دیماروب2000](https://github.com/dimarub2000)) + +#### تعمیر امنیتی {#security-fix} + +- این نسخه همچنین شامل تمام اشکال امنیتی رفع از 19.13 و 19.11. +- ثابت امکان پرس و جو ساخته به علت سقوط سرور به دلیل سرریز پشته در پارسر گذاشتن. ثابت امکان سرریز پشته در ادغام و توزیع جداول محقق انداز و شرایط برای ردیف-سطح امنیتی است که شامل subqueries. [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### بهبود {#improvement-3} + +- اجرای صحیح منطق سه تایی برای `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([الکساندر کازاکوف](https://github.com/Akazz)) +- در حال حاضر ارزش ها و ردیف با تت ال منقضی شده خواهد شد پس از حذف `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` پرس و جو. اضافه شده نمایش داده شد `SYSTEM STOP/START TTL MERGES` برای غیرفعال کردن / اجازه می دهد ادغام اختصاص با کنترل از راه دور و فیلتر مقادیر منقضی شده در تمام ادغام. [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([انتون پوپوف](https://github.com/CurtizJ)) +- امکان تغییر محل فایل تاریخچه کلیک برای مشتری با استفاده از `CLICKHOUSE_HISTORY_FILE` انوف [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([فیلیمونف](https://github.com/filimonov)) +- حذف `dry_run` پرچم از `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- پشتیبانی `ASOF JOIN` با `ON` بخش. [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([زویکوف](https://github.com/4ertus2)) +- پشتیبانی بهتر از شاخص جست و خیز برای جهش و تکرار. پشتیبانی از `MATERIALIZE/CLEAR INDEX ... IN PARTITION` پرس و جو. `UPDATE x = x` محاسبه تمام شاخص هایی که از ستون استفاده می کنند `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- اجازه دادن به `ATTACH` نمایش زنده (مثلا, در هنگام راه اندازی سرور) بدون در نظر گرفتن به `allow_experimental_live_view` تنظیمات. [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- برای ردیابی پشته جمع شده توسط پیشفیلتر پرس و جو, انجام فریم پشته تولید شده توسط پیشفیلتر پرس و جو خود را شامل نمی شود. [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- در حال حاضر توابع جدول `values`, `file`, `url`, `hdfs` پشتیبانی از ستون نام مستعار. [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پرتاب یک استثنا اگر `config.d` فایل عنصر ریشه مربوطه به عنوان فایل پیکربندی ندارد. [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([دیماروب2000](https://github.com/dimarub2000)) +- چاپ اطلاعات اضافی در پیام استثنا برای `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([تاولوبیکس](https://github.com/tavplubix)) +- هنگام تعیین تکه های یک `Distributed` جدول به یک پرس و جو به عنوان خوانده شده تحت پوشش (برای `optimize_skip_unused_shards` = 1) تاتر در حال حاضر چک شرایط از هر دو `prewhere` و `where` بند از بیانیه را انتخاب کنید. [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([الکساندر کازاکوف](https://github.com/Akazz)) +- فعال شد `SIMDJSON` برای ماشین های بدون AVX2 اما با SSE 4.2 و PCLMUL مجموعه آموزش. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تاتر می توانید بر روی فایل سیستم بدون کار `O_DIRECT` پردازشگر پشتیبانی شده: [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پشتیبانی از فشار پایین گزاره برای خرده فروشی نهایی. [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([تسیسون](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بهتر `JOIN ON` استخراج کلید [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([زویکوف](https://github.com/4ertus2)) +- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بهینه سازی انتخاب کوچکترین ستون برای `SELECT count()` پرس و جو. [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([ایموس پرنده](https://github.com/amosbird)) +- اضافه شده `strict` پارامتر در `windowFunnel()`. هنگامی که `strict` تنظیم شده است `windowFunnel()` اعمال شرایط تنها برای ارزش های منحصر به فرد. [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([ایشیمب](https://github.com/achimbab)) +- رابط امن تر از `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([مربی](https://github.com/avasiliev)) +- گزینه های اندازه خط در هنگام اجرای با `--help` گزینه در حال حاضر با اندازه ترمینال مربوط. [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([دیماروب2000](https://github.com/dimarub2000)) +- غیرفعالسازی “read in order” بهینه سازی برای تجمع بدون کلید. [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([انتون پوپوف](https://github.com/CurtizJ)) +- کد وضعیت قام برای `INCORRECT_DATA` و `TYPE_MISMATCH` کد خطا از پیش فرض تغییر یافت `500 Internal Server Error` به `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([الکساندر رودین](https://github.com/a-rodin)) +- حرکت پیوستن شی از `ExpressionAction` به `AnalyzedJoin`. `ExpressionAnalyzer` و `ExpressionAction` در مورد نمی دانم `Join` کلاس دیگر. منطق خود را با پنهان `AnalyzedJoin` صورت. [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([زویکوف](https://github.com/4ertus2)) +- بن بست ممکن ثابت از نمایش داده شد توزیع زمانی که یکی از خرده ریز جایلهاست اما پرس و جو از طریق اتصال به شبکه ارسال می شود. [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تغییر معنایی جداول چندگانه `RENAME` برای جلوگیری از بن بست ممکن است. [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بازنویسی خروجی زیر سرور سازگاری برای جلوگیری از بارگذاری محموله بسته کامل در حافظه است. کاهش مصرف حافظه برای هر اتصال به حدود `2 * DBMS_DEFAULT_BUFFER_SIZE` (خواندن / نوشتن بافر). [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([یوری بارانوف](https://github.com/yurriy)) +- حرکت اس تی نام مستعار تفسیر منطق از تجزیه کننده که لازم نیست به دانستن هر چیزی در مورد معناشناسی پرس و جو. [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([زویکوف](https://github.com/4ertus2)) +- تجزیه کمی امن تر از `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `clickhouse-copier`: اجازه استفاده `where_condition` از پیکربندی با `partition_key` نام مستعار در پرس و جو برای چک کردن وجود پارتیشن (قبلا فقط در خواندن نمایش داده شد داده ها مورد استفاده قرار گرفت). [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([پرولر](https://github.com/proller)) +- اضافه شده استدلال پیام اختیاری در `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([ولادیمیر](https://github.com/Vdimir)) +- استثنا سرور کردم در حالی که ارسال داده های درج در حال حاضر در حال پردازش در مشتری نیز هست. [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([دیماروب2000](https://github.com/dimarub2000)) +- اضافه شده متریک `DistributedFilesToInsert` که نشان می دهد تعداد کل فایل ها در سیستم فایل که انتخاب می شوند برای ارسال به سرور از راه دور توسط جداول توزیع شده است. تعداد در تمام خرده ریز خلاصه. [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حرکت بسیاری از می پیوندد تهیه منطق از `ExpressionAction/ExpressionAnalyzer` به `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([زویکوف](https://github.com/4ertus2)) +- رفع تسان [اخطار](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([واسیلی نمکو](https://github.com/Enmk)) +- پیام های اطلاعات بهتر در مورد عدم قابلیت های لینوکس. ورود به سیستم خطاهای کشنده با “fatal” سطح, که ساده تر خواهد شد برای پیدا کردن در `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- هنگام فعال کردن اطلاعات موقت تخلیه به دیسک برای محدود کردن استفاده از حافظه در طول `GROUP BY`, `ORDER BY` فضای دیسک رایگان را بررسی نکرد. ثابت اضافه کردن یک محیط جدید `min_free_disk_space`, هنگامی که فضای دیسک رایگان کوچکتر و سپس حد, پرس و جو را متوقف خواهد کرد و پرتاب `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([در حال بارگذاری](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رواندا بازگشتی حذف شده توسط موضوع. این باعث می شود هیچ حس, چرا که موضوعات بین نمایش داده شد مورد استفاده مجدد قرار. `SELECT` پرس و جو ممکن است یک قفل در یک موضوع, یک قفل از موضوع دیگر نگه دارید و خروج از موضوع اول. در همان زمان اولین موضوع را می توان با استفاده مجدد `DROP` پرس و جو. این به نادرست منجر شود “Attempt to acquire exclusive lock recursively” پیام [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- شکافتن `ExpressionAnalyzer.appendJoin()`. تهیه یک مکان در `ExpressionAnalyzer` برای `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([زویکوف](https://github.com/4ertus2)) +- اضافه شده `mysql_native_password` پلاگین احراز هویت به خروجی زیر سرور سازگاری. [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([یوری بارانوف](https://github.com/yurriy)) +- تعداد کمتر از `clock_gettime` سازگاری ابی ثابت بین اشکال زدایی / انتشار در `Allocator` (موضوع ناچیز). [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حرکت کن `collectUsedColumns` از `ExpressionAnalyzer` به `SyntaxAnalyzer`. `SyntaxAnalyzer` می سازد `required_source_columns` خود را در حال حاضر. [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([زویکوف](https://github.com/4ertus2)) +- افزودن تنظیمات `joined_subquery_requires_alias` برای نیاز به نام مستعار برای انتخاب و توابع جدول در `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([زویکوف](https://github.com/4ertus2)) +- استخراج `GetAggregatesVisitor` رده از `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([زویکوف](https://github.com/4ertus2)) +- `system.query_log`: تغییر نوع داده `type` ستون به `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) +- پیوند استاتیک `sha256_password` پلاگین احراز هویت. [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([یوری بارانوف](https://github.com/yurriy)) +- اجتناب از وابستگی اضافی برای تنظیم `compile` سر کار. در نسخه های قبلی کاربر ممکن است مانند خطا دریافت کنید `cannot open crti.o`, `unable to find library -lc` و غیره [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اعتبار سنجی بیشتر از ورودی که ممکن است از ماکت های مخرب است. [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حالا `clickhouse-obfuscator` پرونده در دسترس است `clickhouse-client` بسته در نسخه های قبلی در دسترس بود `clickhouse obfuscator` (با فضای خالی). [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([دیماروب2000](https://github.com/dimarub2000)) +- بن بست ثابت زمانی که ما حداقل دو نمایش داده شد که حداقل دو جدول در جهت های مختلف و پرس و جو دیگری که انجام عملیات دسیدل در یکی از جداول به عنوان خوانده شده. ثابت دیگر بن بست بسیار نادر است. [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شده `os_thread_ids` ستون به `system.processes` و `system.query_log` برای احتمالات اشکال زدایی بهتر. [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- یک راه حل برای اشکالات پسوند پی اچ پی میسورند که زمانی رخ می دهد `sha256_password` به عنوان یک پلاگین احراز هویت پیش فرض (شرح داده شده در [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([یوری بارانوف](https://github.com/yurriy)) +- حذف محل غیر ضروری با ستون ابطال تغییر. [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([زویکوف](https://github.com/4ertus2)) +- تنظیم مقدار پیشفرض `queue_max_wait_ms` به صفر, به دلیل ارزش فعلی (پنج ثانیه) می سازد هیچ حس. شرایط نادر وجود دارد که این تنظیمات هر گونه استفاده. تنظیمات اضافه شده `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` و `connection_pool_max_wait_ms` برای ابهامزدایی. [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- استخراج `SelectQueryExpressionAnalyzer` از `ExpressionAnalyzer`. نگه داشتن یکی از گذشته برای نمایش داده شد غیر را انتخاب کنید. [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([زویکوف](https://github.com/4ertus2)) +- حذف تکثیر فرمت های ورودی و خروجی. [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اجازه دادن به کاربر برای لغو `poll_interval` و `idle_connection_timeout` تنظیمات در اتصال. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `MergeTree` در حال حاضر دارای یک گزینه اضافی `ttl_only_drop_parts` (غیر فعال به طور پیش فرض) برای جلوگیری از هرس بخشی از قطعات, به طوری که به طور کامل کاهش یافته است که تمام ردیف در یک بخش منقضی شده است. [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([سرگی ولدیکین](https://github.com/svladykin)) +- نوع چک برای توابع شاخص مجموعه. پرتاب استثنا اگر تابع یک نوع اشتباه. این رفع تست ریش شدن با اوبسان. [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([نیکیتا واسیلیف](https://github.com/nikvas0)) + +#### بهبود عملکرد {#performance-improvement-2} + +- بهینه سازی نمایش داده شد با `ORDER BY expressions` بند, جایی که `expressions` پیشوند همزمان با مرتب سازی کلید در `MergeTree` میز این بهینه سازی توسط کنترل `optimize_read_in_order` تنظیمات. [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([انتون پوپوف](https://github.com/CurtizJ)) +- اجازه استفاده از موضوعات متعدد در طول بارگذاری قطعات و حذف. [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نوع دسته ای اجرا از به روز رسانی کشورهای تابع جمع. ممکن است به مزایای عملکرد منجر شود. [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- با استفاده از `FastOps` کتابخانه برای توابع `exp`, `log`, `sigmoid`, `tanh`. FastOps سریع بردار ریاضی کتابخانه از مایکل Parakhin (Yandex CTO). بهبود عملکرد `exp` و `log` توابع بیش از 6 بار. توابع `exp` و `log` از `Float32` استدلال باز خواهد گشت `Float32` (در نسخه های قبلی همیشه باز می گردند `Float64`). حالا `exp(nan)` ممکن است بازگشت `inf`. نتیجه `exp` و `log` توابع ممکن است نزدیکترین ماشین تعداد نمایندگی به پاسخ واقعی نیست. [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) با استفاده از Danila Kutenin نوع را fastops کار [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- غیر فعال کردن بهینه سازی کلید متوالی برای `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([اکوزم](https://github.com/akuzm)) +- بهبود عملکرد `simdjson` کتابخانه با خلاص شدن از تخصیص پویا در `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([ویتالی بارانو](https://github.com/vitlibar)) +- صفحات پیش گسل هنگام تخصیص حافظه با `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([اکوزم](https://github.com/akuzm)) +- رفع اشکال عملکرد در `Decimal` مقایسه. [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([زویکوف](https://github.com/4ertus2)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-4} + +- حذف کامپایلر (نمونه زمان اجرا الگو) چرا که ما بیش از عملکرد این برنده ام. [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تست عملکرد اضافه شده برای نشان دادن تخریب عملکرد در شورای همکاری خلیج فارس-9 در راه بیشتر جدا شده است. [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تابع جدول اضافه شده است `numbers_mt`, که است که نسخه چند رشته ای از `numbers`. تست های عملکرد به روز شده با توابع هش. [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- حالت مقایسه در `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([دیماروب2000](https://github.com/dimarub2000)) +- بهترین تلاش برای چاپ اثری پشته. همچنین اضافه شده است `SIGPROF` به عنوان یک سیگنال اشکال زدایی برای چاپ ردیابی پشته از یک موضوع در حال اجرا. [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- هر تابع در فایل خود را, بخش 10. [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حذف توایع دو برابر `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([فیلیمونف](https://github.com/filimonov)) +- تغییرات قالب بندی برای `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([اکوزم](https://github.com/akuzm)) +- خرده فروشی بهتر برای پیوستن به ایجاد در `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([زویکوف](https://github.com/4ertus2)) +- حذف یک وضعیت کار برکنار شده (پیدا شده توسط پوس استودیو). [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([اکوزم](https://github.com/akuzm)) +- جدا کردن رابط جدول هش برای `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([اکوزم](https://github.com/akuzm)) +- فاکتورگیری مجدد از تنظیمات. [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([الساپین](https://github.com/alesapin)) +- اضافه کردن نظر برای `set` توابع شاخص. [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- افزایش نمره اتم در نسخه اشکال زدایی در لینوکس. [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([اکوزم](https://github.com/akuzm)) +- در حال حاضر در ساخت اشکال زدایی کار می کنند. [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([در حال بارگذاری](https://github.com/weiqxu)) +- اضافه شدن یک تست به `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن تست برای نمایش چند مادی برای جدول کافکا. [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([ایوان](https://github.com/abyss7)) +- ایجاد یک طرح ساخت بهتر است. [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([ایوان](https://github.com/abyss7)) +- ثابت `test_external_dictionaries` ادغام در صورتی که تحت کاربر غیر ریشه اعدام شد. [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اشکال بازتولید زمانی که اندازه کل بسته های نوشته شده بیش از `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([یوری بارانوف](https://github.com/yurriy)) +- اضافه شدن یک تست برای `RENAME` شرایط مسابقه جدول [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجتناب از مسابقه داده ها در تنظیمات در `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن تست ادغام برای دست زدن به اشتباهات توسط یک فرهنگ لغت کش. [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([ویتالی بارانو](https://github.com/vitlibar)) +- غیر فعال کردن تجزیه فایل های شی جن در سیستم عامل مک, زیرا باعث می شود هیچ حس. [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تلاش برای ایجاد ژنراتور تغییرات بهتر است. [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن `-Wshadow` تغییر به شورای همکاری خلیج فارس. [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([کروزرکریگ](https://github.com/kreuzerkrieg)) +- حذف کد منسوخ برای `mimalloc` پشتیبانی [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `zlib-ng` قابلیت های ایکس86 را تعیین می کند و این اطلاعات را به متغیرهای جهانی ذخیره می کند. این است که در تماس دفالتینیت انجام, که ممکن است توسط موضوعات مختلف به طور همزمان ساخته شده. برای جلوگیری از چند رشته ای می نویسد, این کار را در هنگام راه اندازی کتابخانه. [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([اکوزم](https://github.com/akuzm)) +- تست رگرسیون برای یک اشکال که در پیوستن که در ثابت شد [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([بختیاری روازیف](https://github.com/theruziev)) +- ثابت MSan گزارش. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع زدن تست فلش. [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([انتون پوپوف](https://github.com/CurtizJ)) +- مسابقه داده های نادرست ثابت در `MergeTreeDataPart::is_frozen` رشته. [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- وقفه ثابت در تست ریش شدن. در نسخه های قبلی این موفق به پیدا کردن غلط معوق در پرس و جو `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن چک اشکال زدایی به `static_cast` از ستون. [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پشتیبانی از اوراکل لینوکس در بسته های رسمی دور در دقیقه. [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تغییر کامل جانسون از `once` به `loop` نوع. [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- `odbc-bridge.cpp` تعریف `main()` بنابراین نباید در `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([اوروج دش](https://github.com/orivej)) +- تست تصادف در `FULL|RIGHT JOIN` با نقاط صفر در کلید جدول سمت راست. [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([زویکوف](https://github.com/4ertus2)) +- اضافه شده یک تست برای حد در گسترش نام مستعار فقط در مورد. [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تغییر از `boost::filesystem` به `std::filesystem` از کجا مناسب. [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شده بسته دور در دقیقه به وب سایت. [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن یک تست برای ثابت `Unknown identifier` استثنا در `IN` بخش. [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([زویکوف](https://github.com/4ertus2)) +- ساده کردن `shared_ptr_helper` چون مردم با مشکلاتی روبرو هستند که این را درک می کنند. [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تست عملکرد اضافه شده برای گوریل ثابت و کدک مضاعف. [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([واسیلی نمکو](https://github.com/Enmk)) +- تقسیم تست ادغام `test_dictionaries` به 4 تست جداگانه. [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([ویتالی بارانو](https://github.com/vitlibar)) +- پردازشگر پشتیبانی شده: `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- مجاز به استفاده `library` منبع فرهنگ لغت با اسان. [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن گزینه برای تولید تغییرات از یک لیست از روابط عمومی. [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- قفل `TinyLog` ذخیره سازی در هنگام خواندن. [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([اکوزم](https://github.com/akuzm)) +- بررسی برای پیوندهای نمادی شکسته در سی. [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- افزایش اتمام وقت برای “stack overflow” تست کنید زیرا ممکن است مدت زمان طولانی در ساخت اشکال زدایی طول بکشد. [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن یک چک برای فضاهای خالی دو برابر شود. [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `new/delete` ردیابی حافظه در هنگام ساخت با ضد عفونی کننده. ردیابی مشخص نیست. این تنها مانع از استثنا حد حافظه در تست. [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([زویکوف](https://github.com/4ertus2)) +- فعال کردن چک از علامت تعریف نشده در حالی که ارتباط. [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([ایوان](https://github.com/abyss7)) +- اجتناب از بازسازی `hyperscan` هر روز [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- گزارش ثابت اوبسان در `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجازه ندهید که از پیشفیلتر پرس و جو با ضدعفونی کننده استفاده کنید زیرا سازگار نیست. [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن تست برای بارگذاری یک فرهنگ لغت پس از شکست تایمر. [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع تناقض در `PipelineExecutor::prepareProcessor` نوع استدلال. [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اضافه شده یک تست برای ادرار بد. [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن چک بیشتر به `CAST` تابع. این باید اطلاعات بیشتری در مورد گسل تقسیم بندی در تست فازی دریافت کنید. [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اضافه شده `gcc-9` پشتیبانی به `docker/builder` کانتینر که ایجاد تصویر به صورت محلی. [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([گلب نویکوف](https://github.com/NanoBjorn)) +- تست برای کلید اولیه با `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([دیماروب2000](https://github.com/dimarub2000)) +- تست های ثابت تحت تاثیر اثر کند پشته اثری چاپ. [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن یک مورد تست برای سقوط در `groupUniqArray` ثابت در [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([اکوزم](https://github.com/akuzm)) +- شاخص های ثابت تست جهش. [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- در تست عملکرد, انجام ورود پرس و جو برای نمایش داده شد ما را اجرا کنید به عنوان خوانده شده. [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([اکوزم](https://github.com/akuzm)) +- محقق نمایش در حال حاضر می تواند با ایجاد هر گونه کم cardinality انواع بدون توجه به تنظیمات مورد مشکوک کم cardinality انواع. [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- تست های به روز شده برای `send_logs_level` تنظیمات. [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع ساخت تحت شورای همکاری خلیج فارس-8.2. [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([مکس اخمدوف](https://github.com/zlobober)) +- ثابت ساخت با لیبک داخلی++. [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([ایوان](https://github.com/abyss7)) +- رفع ساخت مشترک با `rdkafka` کتابخانه [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([ایوان](https://github.com/abyss7)) +- رفع برای سیستم عامل مک ساخت (ناقص). [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([اطلاعات دقیق](https://github.com/alex-zaitsev)) +- ثابت “splitted” ساختن. [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- دیگر رفع ساخت: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([ایموس پرنده](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([وکسیدر](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([ایوان](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([پرولر](https://github.com/proller)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-3} + +- حذف تابع جدول به ندرت استفاده می شود `catBoostPool` و ذخیره سازی `CatBoostPool`. اگر شما این تابع جدول استفاده کرده اند, لطفا ارسال ایمیل به `clickhouse-feedback@yandex-team.com`. توجه داشته باشید که ادغام ادم کودن و احمق باقی می ماند و پشتیبانی خواهد شد. [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- غیرفعالسازی `ANY RIGHT JOIN` و `ANY FULL JOIN` به طور پیش فرض. تنظیم `any_join_distinct_right_table_keys` تنظیم برای فعال کردن. [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([زویکوف](https://github.com/4ertus2)) + +## انتشار کلیک 19.13 {#clickhouse-release-19-13} + +### انتشار کلیک خانه 19.13.6.51, 2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} + +#### رفع اشکال {#bug-fix-9} + +- این نسخه همچنین شامل تمام رفع اشکال از 19.11.12.69. + +### انتشار کلیک خانه 19.13.5.44, 2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} + +#### رفع اشکال {#bug-fix-10} + +- این نسخه همچنین شامل تمام رفع اشکال از 19.14.6.12. +- ثابت وضعیت متناقض ممکن است از جدول در حالی که اجرای `DROP` پرس و جو برای جدول تکرار در حالی که باغ وحش در دسترس نیست. [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) +- ثابت برای مسابقه داده ها در انبار ذخیره سازی [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال معرفی شده در پیشفیلتر پرس و جو که منجر به ضبط بی پایان از سوکت. [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([الساپین](https://github.com/alesapin)) +- رفع استفاده از پردازنده بیش از حد در حالی که اجرای `JSONExtractRaw` عملکرد بیش از یک مقدار بولی. [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع رگرسیون در حالی که هل دادن به مشاهده محقق. [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([ایوان](https://github.com/abyss7)) +- تابع جدول `url` در صورت امکان پذیری اجازه مهاجم برای تزریق هدر قام دلخواه در درخواست. این موضوع توسط [نیکیتا تیکومیرو](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع بی فایده `AST` بررسی در شاخص مجموعه. [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- تجزیه ثابت از `AggregateFunction` ارزش های جاسازی شده در پرس و جو. [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([ژیچنگ یو](https://github.com/yuzhichang)) +- رفتار اشتباه ثابت `trim` توابع خانواده. [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.13.4.32, 2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} + +#### رفع اشکال {#bug-fix-11} + +- این نسخه همچنین شامل تمام اشکال امنیتی رفع از 19.11.9.52 و 19.11.10.54. +- مسابقه داده ثابت در `system.parts` جدول و `ALTER` پرس و جو. [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- هدر عدم تطابق ثابت در جریان در صورت خواندن از جدول توزیع خالی با نمونه و قبل از وقوع اتفاق افتاد. [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([Lixiang کیان](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- تصادف ثابت در هنگام استفاده از `IN` بند با یک زیر کشت با یک تاپل. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([تاولوبیکس](https://github.com/tavplubix)) +- ثابت مورد با نام ستون در `GLOBAL JOIN ON` بخش. [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([زویکوف](https://github.com/4ertus2)) +- رفع تصادف در هنگام ریخته گری انواع به `Decimal` که این کار را پشتیبانی نمی کند. پرتاب استثنا به جای. [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([زویکوف](https://github.com/4ertus2)) +- تصادف ثابت در `extractAll()` تابع. [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([زویکوف](https://github.com/4ertus2)) +- تبدیل پرسوجو برای `MySQL`, `ODBC`, `JDBC` توابع جدول در حال حاضر به درستی کار می کند برای `SELECT WHERE` نمایش داده شد با چند `AND` عبارات. [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([دیماروب2000](https://github.com/dimarub2000)) +- اضافه شده چک اعلامیه قبلی برای خروجی زیر 8 ادغام. [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([مایکل دیوید تینکو](https://github.com/rafaeldtinoco)) + +#### تعمیر امنیتی {#security-fix-1} + +- رفع دو ناپایداری در کدک در فاز رفع فشار (کاربر مخرب می تواند داده های فشرده که منجر به سرریز بافر در رفع فشار ساخت). [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([زویکوف](https://github.com/4ertus2)) + +### ClickHouse انتشار 19.13.3.26, 2019-08-22 {#clickhouse-release-19-13-3-26-2019-08-22} + +#### رفع اشکال {#bug-fix-12} + +- ثابت `ALTER TABLE ... UPDATE` پرسو جو برای جداول با `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([الساپین](https://github.com/alesapin)) +- ثابت نانپ در هنگام استفاده در بند با یک زیرخاکری با یک تاپل. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([تاولوبیکس](https://github.com/tavplubix)) +- ثابت یک موضوع است که اگر یک ماکت کهنه زنده می شود, هنوز هم ممکن است قطعات داده که توسط پارتیشن قطره حذف شد. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([تاولوبیکس](https://github.com/tavplubix)) +- موضوع ثابت با تجزیه سی اس وی [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([تاولوبیکس](https://github.com/tavplubix)) +- مسابقه داده ثابت در سیستم.جدول قطعات و تغییر پرس و جو. این رفع [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- کد اشتباه ثابت در جهش است که ممکن است به فساد حافظه منجر شود. سگو ثابت با خواندن نشانی `0x14c0` که ممکن است به دلیل همزمان اتفاق `DROP TABLE` و `SELECT` از `system.parts` یا `system.parts_columns`. شرایط مسابقه ثابت در تهیه نمایش داده شد جهش. بن بست ثابت ناشی از `OPTIMIZE` از جداول تکرار و عملیات اصلاح همزمان مانند تغییر. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- از دست دادن داده های ممکن ثابت پس از `ALTER DELETE` پرس و جو در جدول با پرش شاخص. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([نیکیتا واسیلیف](https://github.com/nikvas0)) + +#### تعمیر امنیتی {#security-fix-2} + +- اگر مهاجم دارای دسترسی نوشتن به باغ وحش است و قادر به اجرای سفارشی سرور موجود در شبکه که در آن ClickHouse اجرای آن می توانید ایجاد و سفارشی-ساخته شده در سرور های مخرب است که به عنوان ClickHouse المثنی و ثبت آن در باغ وحش. هنگامی که ماکت دیگر بخش داده ها از ماکت های مخرب واکشی, می تواند فاحشه خانه و سرور را مجبور به ارسال به مسیر دلخواه در فایل سیستم. پیدا شده توسط الدار زیتوف, تیم امنیت اطلاعات در یاندکس. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.13.2.19, 2019-08-14 {#clickhouse-release-19-13-2-19-2019-08-14} + +#### ویژگی جدید {#new-feature-5} + +- نمونه برداری پیشفیلتر در سطح پرس و جو. [مثال](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) +- اجازه برای مشخص کردن یک لیست از ستون با `COLUMNS('regexp')` بیان که مانند یک نوع پیچیده تر از کار می کند `*` ستاره دار. [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([مازریدنتال](https://github.com/mfridental)), ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `CREATE TABLE AS table_function()` در حال حاضر امکان [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([دیماروب2000](https://github.com/dimarub2000)) +- بهینه ساز ادام برای نزول گرادیان تصادفی به طور پیش فرض در استفاده `stochasticLinearRegression()` و `stochasticLogisticRegression()` توابع مجموع, چرا که نشان می دهد با کیفیت خوب و بدون تقریبا هر تنظیم. [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([کد37](https://github.com/Quid37)) +- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([اندی یانگ](https://github.com/andyyzh)) +- `RENAME` نمایش داده شد در حال حاضر با تمام ذخیره سازی کار می کنند. [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([ایوان](https://github.com/abyss7)) +- در حال حاضر مشتری دریافت سیاهههای مربوط از سرور با هر سطح مورد نظر با تنظیم `send_logs_level` بدون در نظر گرفتن سطح ورود به سیستم مشخص شده در تنظیمات سرور. [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-4} + +- تنظیمات `input_format_defaults_for_omitted_fields` به طور پیش فرض فعال است. درج در جداول توزیع شده نیاز به این تنظیم به همان در خوشه (شما نیاز به تنظیم قبل از بروز رسانی نورد). این را قادر می سازد محاسبه عبارات پیش فرض پیچیده برای زمینه های حذف شده در `JSONEachRow` و `CSV*` فرمتها. این باید رفتار مورد انتظار باشد اما ممکن است منجر به تفاوت عملکرد ناچیز. [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([زویکوف](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([اکوزم](https://github.com/akuzm)) + +#### ویژگی های تجربی {#experimental-features} + +- خط لوله پردازش پرس و جو جدید. استفاده `experimental_use_processors=1` گزینه ای برای فعال کردن. برای مشکل خود استفاده کنید. [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) + +#### رفع اشکال {#bug-fix-13} + +- ادغام کافکا در این نسخه ثابت شده است. +- ثابت `DoubleDelta` کدبندی `Int64` برای بزرگ `DoubleDelta` ارزش, بهبود یافته `DoubleDelta` رمزگذاری برای داده های تصادفی برای `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([واسیلی نمکو](https://github.com/Enmk)) +- بیش از حد ثابت از `max_rows_to_read` اگر تنظیمات `merge_tree_uniform_read_distribution` تنظیم 0. [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### بهبود {#improvement-4} + +- می اندازد یک استثنا اگر `config.d` فایل عنصر ریشه مربوطه به عنوان فایل پیکربندی ندارد [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([دیماروب2000](https://github.com/dimarub2000)) + +#### بهبود عملکرد {#performance-improvement-3} + +- بهینهسازی `count()`. در حال حاضر با استفاده از کوچکترین ستون (در صورت امکان). [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([ایموس پرنده](https://github.com/amosbird)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-5} + +- گزارش استفاده از حافظه در تست عملکرد. [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([اکوزم](https://github.com/akuzm)) +- رفع ساخت با خارجی `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([ایوان](https://github.com/abyss7)) +- رفع ساخت مشترک با `rdkafka` کتابخانه [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([ایوان](https://github.com/abyss7)) + +## انتشار کلیک 19.11 {#clickhouse-release-19-11} + +### انتشار کلیک 19.11.13.74, 2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} + +#### رفع اشکال {#bug-fix-14} + +- تصادف نادر ثابت در `ALTER MODIFY COLUMN` و ادغام عمودی زمانی که یکی از قطعات با هم ادغام شدند/تغییر خالی است (0 ردیف). [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([الساپین](https://github.com/alesapin)) +- به روز رسانی دستی `SIMDJSON`. این رفع جاری شدن سیل ممکن است از فایل های استدر با جعلی جانسون پیام های تشخیصی. [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([الکساندر کازاکوف](https://github.com/Akazz)) +- اشکال ثابت با `mrk` پسوند پرونده برای جهش ([الساپین](https://github.com/alesapin)) + +### انتشار کلیک خانه 19.11.12.69, 2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} + +#### رفع اشکال {#bug-fix-15} + +- تجزیه عملکرد ثابت تجزیه و تحلیل شاخص بر روی کلید های پیچیده در جداول بزرگ. این رفع [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجتناب از سیگزگف نادر در حالی که ارسال داده ها در جداول با موتور توزیع شده (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([ازات خوژین](https://github.com/azat)) +- ثابت `Unknown identifier` با چند می پیوندد. این رفع [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([زویکوف](https://github.com/4ertus2)) + +### ClickHouse انتشار 19.11.11.57, 2019-09-13 {#clickhouse-release-19-11-11-57-2019-09-13} + +- رفع خطا منطقی باعث حملات در هنگام انتخاب از کافکا موضوع خالی. [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([ایوان](https://github.com/abyss7)) +- ثابت برای عملکرد `АrrayEnumerateUniqRanked` با بند خالی در پارامز. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([پرولر](https://github.com/proller)) + +### انتشار کلیک خانه 19.11.10.54, 2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} + +#### رفع اشکال {#bug-fix-16} + +- پیام های کافکا را به صورت دستی ذخیره کنید تا بتوانید همه را در یک زمان برای تمام پارتیشن ها انجام دهید. رفع تقلید بالقوه در “one consumer - many partitions” سناریو [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([ایوان](https://github.com/abyss7)) + +### ClickHouse انتشار 19.11.9.52, 2019-09-6 {#clickhouse-release-19-11-9-52-2019-09-6} + +- بهبود دست زدن به خطا در لغت نامه کش. [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([ویتالی بارانو](https://github.com/vitlibar)) +- اشکال ثابت در عملکرد `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([پرولر](https://github.com/proller)) +- ثابت `JSONExtract` عملکرد در حالی که استخراج یک `Tuple` از جسون [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([ویتالی بارانو](https://github.com/vitlibar)) +- از دست دادن داده های ممکن ثابت پس از `ALTER DELETE` پرس و جو در جدول با پرش شاخص. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- تست عملکرد ثابت. [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پارکت: رفع خواندن ستون بولی. [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفتار اشتباه ثابت `nullIf` تابع برای استدلال ثابت. [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع مشکل پیام های کافکا تقلید در راه اندازی مجدد سرور طبیعی است. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([ایوان](https://github.com/abyss7)) +- ثابت موضوع زمانی که طولانی است `ALTER UPDATE` یا `ALTER DELETE` ممکن است ادغام به طور منظم به اجرا جلوگیری می کند. جلوگیری از جهش از اجرای اگر هیچ موضوعات رایگان به اندازه کافی در دسترس وجود دارد. [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([تاولوبیکس](https://github.com/tavplubix)) +- خطا ثابت با پردازش “timezone” در فایل پیکربندی سرور. [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع تست کافکا. [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([ایوان](https://github.com/abyss7)) + +#### تعمیر امنیتی {#security-fix-3} + +- اگر مهاجم دارای دسترسی نوشتن به باغ وحش است و قادر به اجرای سفارشی سرور موجود در شبکه که در آن ClickHouse اجرا می شود, آن می تواند ایجاد سفارشی-ساخته شده در سرور های مخرب است که به عنوان ClickHouse المثنی و ثبت آن در باغ وحش. هنگامی که ماکت دیگر بخش داده ها از ماکت های مخرب واکشی, می تواند فاحشه خانه و سرور را مجبور به ارسال به مسیر دلخواه در فایل سیستم. پیدا شده توسط الدار زیتوف, تیم امنیت اطلاعات در یاندکس. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### ClickHouse انتشار 19.11.8.46, 2019-08-22 {#clickhouse-release-19-11-8-46-2019-08-22} + +#### رفع اشکال {#bug-fix-17} + +- ثابت `ALTER TABLE ... UPDATE` پرسو جو برای جداول با `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([الساپین](https://github.com/alesapin)) +- ثابت نانپ در هنگام استفاده در بند با یک زیرخاکری با یک تاپل. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([تاولوبیکس](https://github.com/tavplubix)) +- ثابت یک موضوع است که اگر یک ماکت کهنه زنده می شود, هنوز هم ممکن است قطعات داده که توسط پارتیشن قطره حذف شد. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([تاولوبیکس](https://github.com/tavplubix)) +- موضوع ثابت با تجزیه سی اس وی [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([تاولوبیکس](https://github.com/tavplubix)) +- مسابقه داده ثابت در سیستم.جدول قطعات و تغییر پرس و جو. این رفع [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- کد اشتباه ثابت در جهش است که ممکن است به فساد حافظه منجر شود. سگو ثابت با خواندن نشانی `0x14c0` که ممکن است به دلیل همزمان اتفاق `DROP TABLE` و `SELECT` از `system.parts` یا `system.parts_columns`. شرایط مسابقه ثابت در تهیه نمایش داده شد جهش. بن بست ثابت ناشی از `OPTIMIZE` از جداول تکرار و عملیات اصلاح همزمان مانند تغییر. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### ClickHouse انتشار 19.11.7.40, 2019-08-14 {#clickhouse-release-19-11-7-40-2019-08-14} + +#### رفع اشکال {#bug-fix-18} + +- ادغام کافکا در این نسخه ثابت شده است. +- در هنگام استفاده از سگو را رفع کنید `arrayReduce` برای استدلال ثابت. [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `toFloat()` یکنواختی. [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([دیماروب2000](https://github.com/dimarub2000)) +- اصلاح سگو با فعال `optimize_skip_unused_shards` و از دست رفته کلید شاردینگ. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([کورتیزج](https://github.com/CurtizJ)) +- منطق ثابت `arrayEnumerateUniqRanked` تابع. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حذف ورود به سیستم طولانی اضافی از کنترل خروجی زیر. [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع رفتار اشتباه و حملات احتمالی در `topK` و `topKWeighted` توابع جمع. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([کورتیزج](https://github.com/CurtizJ)) +- ستون های مجازی را در معرض قرار ندهید `system.columns` جدول این برای سازگاری عقب مورد نیاز است. [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال با تخصیص حافظه برای رشته در فرهنگ لغت کش کلید پیچیده است. [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([الساپین](https://github.com/alesapin)) +- رفع اشکال با فعال کردن دانه دانه تطبیقی در هنگام ایجاد ماکت جدید برای `Replicated*MergeTree` جدول [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([الساپین](https://github.com/alesapin)) +- رفع حلقه بی نهایت در هنگام خواندن پیام کافکا. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([پایان 7](https://github.com/abyss7)) +- ثابت امکان پرس و جو ساخته به علت سقوط سرور به دلیل سرریز پشته در گذاشتن مربع و امکان سرریز پشته در `Merge` و `Distributed` جداول [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطا را پشتیبانی می کند گوریل ثابت در توالی های کوچک. [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([انمک](https://github.com/Enmk)) + +#### بهبود {#improvement-5} + +- اجازه دادن به کاربر برای لغو `poll_interval` و `idle_connection_timeout` تنظیمات در اتصال. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.11.5.28, 2019-08-05 {#clickhouse-release-19-11-5-28-2019-08-05} + +#### رفع اشکال {#bug-fix-19} + +- ثابت امکان معلق نمایش داده شد زمانی که سرور غیرمنتظره است. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- در مورد نیاز: این رفع [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اشکال ثابت در تبدیل `LowCardinality` انواع در `AggregateFunctionFactory`. این رفع [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع تجزیه از `bool` تنظیمات از `true` و `false` رشته ها در فایل های پیکربندی. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([الساپین](https://github.com/alesapin)) +- رفع اشکال نادر با هدر جریان ناسازگار در نمایش داده شد به `Distributed` جدول بیش از `MergeTree` جدول زمانی که بخشی از `WHERE` حرکت به `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([الساپین](https://github.com/alesapin)) +- سرریز ثابت در تقسیم عدد صحیح از نوع امضا شده به نوع بدون علامت. این رفع [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-5} + +- `Kafka` هنوز شکسته. + +### انتشار کلیک خانه 19.11.4.24, 2019-08-01 {#clickhouse-release-19-11-4-24-2019-08-01} + +#### رفع اشکال {#bug-fix-20} + +- رفع اشکال با نوشتن شاخص ثانویه نشانه با دانه دانه تطبیقی. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([الساپین](https://github.com/alesapin)) +- ثابت `WITH ROLLUP` و `WITH CUBE` اصلاح کننده های `GROUP BY` با تجمع دو سطح. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([انتون پوپوف](https://github.com/CurtizJ)) +- ثابت قطع در `JSONExtractRaw` تابع. ثابت [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع segfault در ExternalLoader::reloadOutdated(). [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([ویتالی بارانو](https://github.com/vitlibar)) +- ثابت مورد زمانی که سرور ممکن است گوش دادن سوکت اما خاموش نمی بستن و ادامه خدمت نمایش داده شد باقی مانده است. شما ممکن است در نهایت با دو در حال اجرا فرایندهای فاحشه خانه و سرور. گاهی, سرور ممکن است یک خطا بازگشت `bad_function_call` برای نمایش داده شد باقی مانده است. [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- شرایط بی فایده و نادرست ثابت در زمینه به روز رسانی برای بارگذاری اولیه از لغت نامه های خارجی از طریق ال بی سی, خروجی زیر, کلیک و قام. این رفع [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- استثنا بی ربط ثابت در بازیگران `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع نتیجه غیر قطعی از “uniq” تابع مجموع در موارد شدید نادر. اشکال در حال حاضر در تمام نسخه های تاتر بود. [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- Segfault هنگامی که ما مجموعه ای کمی بیش از حد بالا CIDR در تابع `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- ثابت نشت حافظه کوچک زمانی که سرور پرتاب استثنا بسیاری از بسیاری از زمینه های مختلف. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع وضعیت زمانی که مصرف کننده قبل از اشتراک متوقف شد و پس از سر گرفت. [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([ایوان](https://github.com/abyss7)) توجه داشته باشید که کافکا در این نسخه شکسته. +- پاک کردن بافر داده کافکا از عملیات خواندن قبلی که با یک خطا تکمیل شد [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([نیکولای](https://github.com/bopohaa)) توجه داشته باشید که کافکا در این نسخه شکسته. +- از `StorageMergeTree::background_task_handle` مقدار دهی اولیه در `startup()` این `MergeTreeBlockOutputStream::write()` ممکن است سعی کنید قبل از مقدار دهی اولیه استفاده کنید. فقط بررسی کنید اگر مقداردهی اولیه شده است. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([ایوان](https://github.com/abyss7)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-6} + +- اضافه شده رسمی `rpm` بسته. [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([پرولر](https://github.com/proller)) ([الساپین](https://github.com/alesapin)) +- اضافه کردن توانایی ساخت `.rpm` و `.tgz` بسته با `packager` خط نوشتن. [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([الساپین](https://github.com/alesapin)) +- رفع برای “Arcadia” ساخت سیستم. [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([پرولر](https://github.com/proller)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-6} + +- `Kafka` در این نسخه شکسته. + +### انتشار کلیک خانه 19.11.3.11, 2019-07-18 {#clickhouse-release-19-11-3-11-2019-07-18} + +#### ویژگی جدید {#new-feature-6} + +- اضافه شدن پشتیبانی از اظهارات تهیه شده است. [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([الکساندر](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `DoubleDelta` و `Gorilla` کدکهای ستون [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([واسیلی نمکو](https://github.com/Enmk)) +- اضافه شده `os_thread_priority` تنظیم که اجازه می دهد تا برای کنترل “nice” ارزش موضوعات پردازش پرس و جو است که توسط سیستم عامل مورد استفاده برای تنظیم اولویت برنامه ریزی پویا. این نیاز دارد `CAP_SYS_NICE` قابلیت به کار. این پیاده سازی [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پیاده سازی `_topic`, `_offset`, `_key` ستون برای موتور کافکا [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([ایوان](https://github.com/abyss7)) توجه داشته باشید که کافکا در این نسخه شکسته. +- اضافه کردن ترکیب تابع جمع `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([هکز](https://github.com/hczhcz)) +- توابع مجموع `groupArrayMovingSum(win_size)(x)` و `groupArrayMovingAvg(win_size)(x)` که محاسبه حرکت مجموع / میانگین با یا بدون محدودیت اندازه پنجره. [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([اختراع2004](https://github.com/inv2004)) +- افزودن سینونیم `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([هکز](https://github.com/hczhcz)) +- Intergate H3 تابع `geoToH3` از بارگذاری. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen ایوان](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### رفع اشکال {#bug-fix-21} + +- پیاده سازی کش دی ان اس با به روز رسانی ناهمزمان. موضوع جداگانه برطرف تمام میزبان و به روز رسانی دی ان اس کش با دوره (تنظیم `dns_cache_update_period`). این باید زمانی کمک کند که میزبان اغلب تغییر کند. [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع segfault در `Delta` کدک که ستون با مقادیر کمتر از 32 بیت اندازه تاثیر می گذارد. اشکال منجر به فساد حافظه تصادفی. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([الساپین](https://github.com/alesapin)) +- رفع اشکال در ادغام ستون های غیر فیزیکی در بلوک. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع اشکال نادر در چک کردن بخشی با `LowCardinality` ستون. قبلا `checkDataPart` همیشه برای بخشی با شکست مواجه `LowCardinality` ستون. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([الساپین](https://github.com/alesapin)) +- اجتناب از اتصالات معلق زمانی که سرور استخر موضوع کامل است. این برای اتصال از مهم است `remote` تابع جدول و یا اتصال به یک سفال بدون کپی زمانی که فاصله اتصال طولانی وجود دارد. این رفع [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پشتیبانی از استدلال های ثابت به `evalMLModel` تابع. این رفع [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت موضوع زمانی که تاتر تعیین منطقه زمانی به طور پیش فرض به عنوان `UCT` به جای `UTC`. این رفع [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- زیر جریان بافر ثابت در `visitParamExtractRaw`. این رفع [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- در حال حاضر توزیع شده است `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` نمایش داده شد خواهد شد به طور مستقیم در ماکت رهبر اجرا شده است. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([الساپین](https://github.com/alesapin)) +- ثابت `coalesce` برای `ColumnConst` با `ColumnNullable` + تغییرات مرتبط . [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([زویکوف](https://github.com/4ertus2)) +- رفع `ReadBufferFromKafkaConsumer` به طوری که نگه می دارد خواندن پیام های جدید پس از `commit()` حتی اگر قبلا متوقف شده بود [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([ایوان](https://github.com/abyss7)) +- ثابت `FULL` و `RIGHT` پیوستن به نتایج در هنگام پیوستن به `Nullable` کلید در جدول سمت راست. [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([زویکوف](https://github.com/4ertus2)) +- رفع احتمالی خواب بی نهایت نمایش داده شد اولویت پایین. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع شرایط مسابقه, که باعث می شود که برخی از نمایش داده شد ممکن است در کواریلاگ پس از به نظر می رسد `SYSTEM FLUSH LOGS` پرس و جو. [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([انتون پوپوف](https://github.com/CurtizJ)) +- ثابت `heap-use-after-free` اسان هشدار در خوشه بندی ناشی از سازمان دیده بان که سعی کنید به استفاده از شی کپی در حال حاضر حذف شده است. [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اشتباه ثابت `StringRef` اشاره گر بازگشت توسط برخی از پیاده سازی از `IColumn::deserializeAndInsertFromArena`. این اشکال تحت تاثیر قرار تنها واحد تست. [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- جلوگیری از منبع و مجموعه ای متوسط پیوستن به ستون از پوشش ستون همان نام. [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([زویکوف](https://github.com/4ertus2)) +- رفع درج و پرس و جو را انتخاب کنید به خروجی زیر موتور با خروجی زیر شناسه سبک به نقل از. [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([زمستان ژانگ](https://github.com/zhang2014)) +- حالا `CHECK TABLE` پرس و جو می تواند با خانواده موتور ادغام کار می کنند. این گرداند بررسی وضعیت و پیام اگر هر برای هر بخش (و یا فایل در مورد موتورهای ساده تر). همچنین, رفع اشکال در واکشی از یک بخش شکسته. [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([الساپین](https://github.com/alesapin)) +- رفع SPLIT\_SHARED\_LIBRARIES در زمان اجرا [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([نام و نام خانوادگی](https://github.com/danlark1)) +- مقدار دهی اولیه منطقه زمانی ثابت زمانی که `/etc/localtime` پیوند نمادی نسبی مانند است `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تاتر-کپی: رفع استفاده-پس از رایگان در خاموش کردن [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([پرولر](https://github.com/proller)) +- به روز شده `simdjson`. ثابت موضوع است که برخی از پارسونز نامعتبر با صفر بایت موفقیت تجزیه. [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع خاموش شدن سیستم ها [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع زمانی که وضعیت در باطل کردن\_قرقمی بستگی به یک فرهنگ لغت. [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([ویتالی بارانو](https://github.com/vitlibar)) + +#### بهبود {#improvement-6} + +- اجازه دادن به نشانیهای غیر قابل حل در پیکربندی خوشه. در دسترس نیستند و سعی می کنند در هر تلاش اتصال حل شوند. این امر به ویژه برای کوبرنتیس مفید. این رفع [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بستن اتصالات تی پی بیکار (با فاصله یک ساعت به طور پیش فرض). این امر به ویژه برای خوشه های بزرگ با جداول توزیع متعدد بر روی هر سرور مهم, چرا که هر سرور احتمالا می تواند نگه داشتن یک استخر اتصال به هر سرور دیگر, و پس از همزمانی پرس و جو اوج, اتصالات متوقف خواهد شد. این رفع [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- کیفیت بهتر `topK` تابع. تغییر رفتار فضا مجموعه به حذف عنصر گذشته اگر عنصر جدید یک وزن بزرگتر. [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- توابع نشانی وب برای کار با دامنه هم اکنون می توانید برای نشانیهای اینترنتی ناقص بدون طرح کار می کنند [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([الساپین](https://github.com/alesapin)) +- چک سام به اضافه `system.parts_columns` جدول [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) +- اضافه شده `Enum` نوع داده به عنوان یک سینونیم برای `Enum8` یا `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([دیماروب2000](https://github.com/dimarub2000)) +- بیت کامل انتقال نوع برای `T64` وابسته به کدک. می تواند منجر به فشرده سازی بهتر با `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([زویکوف](https://github.com/4ertus2)) +- شرط در `startsWith` تابع هم اکنون می توانید کلید اصلی استفاده می کند. این رفع [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) و [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([دیماروب2000](https://github.com/dimarub2000)) +- مجاز به استفاده `clickhouse-copier` با توپولوژی خوشه متقابل تکرار با اجازه نام پایگاه داده خالی. [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([نوارتولومی](https://github.com/nvartolomei)) +- استفاده `UTC` به عنوان منطقه زمانی پیش فرض بر روی یک سیستم بدون `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` چاپ شد و سرور و یا مشتری حاضر به شروع. [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بازگشت پشتیبانی از استدلال نقطه شناور در تابع `quantileTiming` برای سازگاری به عقب. [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نشان می دهد که جدول از دست رفته است ستون در پیام های خطا. [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([ایوان](https://github.com/abyss7)) +- حذف پرسوجوی اجرا با همان کویری\_ید توسط کاربران مختلف [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([پرولر](https://github.com/proller)) +- کد قوی تر برای ارسال معیارهای گرافیت. این حتی در طول چند طولانی کار خواهد کرد `RENAME TABLE` عمل [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بیشتر پیام های خطا اطلاع رسانی نمایش داده خواهد شد که سه گانه می توانید یک کار برای اجرای برنامه نیست. این رفع [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- معکوس نگرامش به بصری تر [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([نام و نام خانوادگی](https://github.com/danlark1)) +- در حال بارگذاری [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([اکونیک 90](https://github.com/akonyaev90)) +- به روز رسانی مقدار پیش فرض `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([قاسم کونوالوف](https://github.com/izebit)) +- اضافه شدن یک مفهوم از تنظیمات منسوخ باشد. تنظیم منسوخ `allow_experimental_low_cardinality_type` می توان بدون اثر استفاده کرد. [0ف15ج016802ف7سی141494سی12846ب898944](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [الکسی میلویدو](https://github.com/alexey-milovidov) + +#### بهبود عملکرد {#performance-improvement-4} + +- افزایش تعداد جریان از جدول ادغام برای توزیع یکنواخت تر از موضوعات را انتخاب کنید. اضافه شدن تنظیمات `max_streams_multiplier_for_merge_tables`. این رفع [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-7} + +- اضافه کردن یک تست سازگاری رو به عقب برای تعامل مشتری و سرور با نسخه های مختلف از تاتر. [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([الساپین](https://github.com/alesapin)) +- تست اطلاعات پوشش در هر مرتکب و جلو و درخواست. [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([الساپین](https://github.com/alesapin)) +- همکاری با نشانی ضد عفونی کننده برای حمایت از تخصیص سفارشی ما (`Arena` و `ArenaWithFreeLists`) برای اشکال زدایی بهتر از “use-after-free” خطاها. [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([اکوزم](https://github.com/akuzm)) +- سودهی به [اجرای رایگان](https://github.com/llvm-mirror/libunwind) برای ج++ دست زدن به استثنا و برای ردیابی پشته چاپ [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([نیکیتا لکوف](https://github.com/laplab)) +- اضافه کردن دو هشدار بیشتر از-ابزار [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجازه می دهد برای ساخت تاتر با ضد عفونی کننده حافظه. [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- گزارش ثابت اوبسان درباره `bitTest` تابع در تست ریش شدن. [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- کارگر بارانداز: اضافه شدن امکان به داخل یک نمونه کلیک که نیاز به احراز هویت. [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([هشدار داده می شود](https://github.com/shurshun)) +- به روز رسانی کتابدار به نسخه 1.1.0 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([ایوان](https://github.com/abyss7)) +- اضافه کردن ایست جهانی برای تست ادغام و غیر فعال کردن برخی از در کد تست. [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([الساپین](https://github.com/alesapin)) +- رفع برخی از شکست های سه گانه. [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([اکوزم](https://github.com/akuzm)) +- این `--no-undefined` گزینه نیروهای لینکر برای بررسی تمام نام های خارجی برای وجود در حالی که ارتباط. این بسیار مفید برای ردیابی وابستگی واقعی بین کتابخانه ها در حالت ساخت تقسیم شده است. [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([ایوان](https://github.com/abyss7)) +- تست عملکرد اضافه شده برای [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- سازگاری ثابت با شورای همکاری خلیج فارس-7. [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن پشتیبانی برای شورای همکاری خلیج فارس-9. این رفع [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطا ثابت زمانی که لیبناد را می توان به اشتباه مرتبط کرد. [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت چند هشدار پیدا شده توسط پوس استودیو. [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن پشتیبانی اولیه برای `clang-tidy` تجزیه و تحلیل استاتیک. [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تبدیل ماکرو اس دی/لینوکس اندی( ‘be64toh’ و ‘htobe64’) به معادل سیستم عامل مک ایکس [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([فو چن](https://github.com/fredchenbj)) +- بهبود ادغام تست راهنمای. [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- رفع ساخت در مکینتاش [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([فیلیمونف](https://github.com/filimonov)) +- رفع سخت به نقطه تایپی: سنگدانه -\> مصالح. [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([اکوزم](https://github.com/akuzm)) +- رفع ساخت بورس [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([پرولر](https://github.com/proller)) +- اضافه کردن لینک به کانال یوتیوب تجربی به وب سایت [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([ایوان بلینکو](https://github.com/blinkov)) +- چوب کوره: اضافه کردن گزینه برای پرچم پوشش: با برقی [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([پرولر](https://github.com/proller)) +- رفع اندازه اولیه برخی از درون خطی پودرای است. [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([اکوزم](https://github.com/akuzm)) +- فاحشه خانه-سرور.پستینست: رفع تشخیص سیستم عامل برای لینوکس 6 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([پرولر](https://github.com/proller)) +- نسل بسته بندی قوس لینوکس اضافه شده است. [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([ولادیمیر چبوتراف](https://github.com/excitoon)) +- تقسیم مشترک / پیکربندی.هشدار داده می شود) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([پرولر](https://github.com/proller)) +- رفع برای “Arcadia” ساخت پلت فرم [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([پرولر](https://github.com/proller)) +- رفع برای غیر متعارف ساخت (gcc9 هیچ submodules) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([پرولر](https://github.com/proller)) +- نیاز به نوع صریح و روشن در فروشگاه بدون خط زیرا ثابت شده بود که مستعد ابتلا به اشکال [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([اکوزم](https://github.com/akuzm)) +- رفع مکینتاش ساخت [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([فیلیمونف](https://github.com/filimonov)) +- تست عملکرد مربوط به ویژگی دستگاه گوارش جدید با مجموعه داده های بزرگتر, همانطور که در اینجا درخواست [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- تست های نفرت انگیز را در تست استرس اجرا کنید [12693568722ف11 است19859742ف56428455501فرد2ا](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([الساپین](https://github.com/alesapin)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-7} + +- `Kafka` در این نسخه شکسته. +- فعالسازی `adaptive_index_granularity` = 10 مگابایت به طور پیش فرض برای جدید `MergeTree` میز اگر شما ایجاد شده جدید MergeTree جداول در نسخه 19.11+, دانگرید به نسخه های قبل 19.6 غیر ممکن خواهد بود. [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([الساپین](https://github.com/alesapin)) +- حذف منسوخ لغت نامه تعبیه شده مستند نشده است که توسط یاندکس مورد استفاده قرار گرفت.متریکا توابع `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` دیگر در دسترس نیست. اگر شما با استفاده از این توابع, ارسال ایمیل به clickhouse-feedback@yandex-team.com. توجه: در حال حاضر ما تصمیم به نگه داشتن این توابع در حالی که برای. [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +## انتشار کلیک 19.10 {#clickhouse-release-19-10} + +### انتشار کلیک خانه 19.10.1.5, 2019-07-12 {#clickhouse-release-19-10-1-5-2019-07-12} + +#### ویژگی جدید {#new-feature-7} + +- اضافه کردن کدک ستون جدید: `T64`. ساخته شده به صورت (U)IntX/EnumX/Data(زمان)/DecimalX ستون. این باید برای ستون ها با مقادیر محدوده ثابت یا کوچک مناسب باشد. کدک خود را اجازه می دهد تا بزرگ و یا کوچک نوع داده بدون فشرده سازی مجدد. [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([زویکوف](https://github.com/4ertus2)) +- افزودن موتور دادگان `MySQL` که اجازه می دهد برای مشاهده تمام جداول در سرور خروجی از راه دور [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([زمستان ژانگ](https://github.com/zhang2014)) +- `bitmapContains` اجرا کردن. این 2 برابر سریعتر از `bitmapHasAny` اگر بیت مپ دوم شامل یک عنصر. [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([ژیچنگ یو](https://github.com/yuzhichang)) +- پشتیبانی از `crc32` تابع (با رفتار دقیقا همانطور که در خروجی زیر و یا پی اچ پی). اگر شما نیاز به یک تابع هش استفاده نکنید. [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen ایوان](https://github.com/BHYCHIK)) +- پیادهسازی شده `SYSTEM START/STOP DISTRIBUTED SENDS` نمایش داده شد برای کنترل درج ناهمزمان به `Distributed` میز [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([زمستان ژانگ](https://github.com/zhang2014)) + +#### رفع اشکال {#bug-fix-22} + +- نادیده گرفتن محدودیت اجرای پرس و جو و حداکثر اندازه قطعات برای محدودیت ادغام در حالی که اجرای جهش. [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع اشکال که ممکن است به تقسیم بلوک های طبیعی (بسیار نادر) و درج بلوک های تکراری (در اغلب موارد) منجر شود. [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([الساپین](https://github.com/alesapin)) +- رفع عملکرد `arrayEnumerateUniqRanked` برای نشانوندها با عرضهای خالی [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([پرولر](https://github.com/proller)) +- هنوز به موضوعات کافکا بدون قصد نظرسنجی هر پیام مشترک نیست. [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([ایوان](https://github.com/abyss7)) +- ایجاد تنظیمات `join_use_nulls` هیچ تاثیری برای انواع است که نمی تواند در داخل قابل ابطال است [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- ثابت `Incorrect size of index granularity` خطاها [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([کوراستر](https://github.com/coraxster)) +- ثابت شناور به دهدهی تبدیل سرریز [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([کوراستر](https://github.com/coraxster)) +- بافر خیط و پیت کردن زمانی که `WriteBufferFromHDFS`مخرب نامیده می شود. این رفع نوشتن به `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([Xindong پنگ](https://github.com/eejoin)) + +#### بهبود {#improvement-7} + +- درمان سلول های خالی در `CSV` به عنوان مقادیر پیش فرض هنگام تنظیم `input_format_defaults_for_omitted_fields` فعال است. [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([اکوزم](https://github.com/akuzm)) +- عدم مسدود کردن بارگذاری لغت نامه های خارجی. [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([ویتالی بارانو](https://github.com/vitlibar)) +- وقفه شبکه را می توان به صورت پویا برای اتصالات در حال حاضر تاسیس با توجه به تنظیمات تغییر کرده است. [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([کنستانتین پودشوموک](https://github.com/podshumok)) +- با استفاده از “public\_suffix\_list” برای توابع `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. این با استفاده از یک جدول هش کامل تولید شده توسط `gperf` با یک لیست تولید شده از فایل: https://publicsuffix.org/list/public\_suffix\_list.dat. (مثلا, در حال حاضر ما دامنه را تشخیص `ac.uk` به عنوان غیر قابل توجهی). [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- به تصویب رسید `IPv6` نوع داده در جداول سیستم. `system.processes` و `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- با استفاده از جلسات برای ارتباط با پروتکل سازگاری خروجی زیر. \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([یوری بارانوف](https://github.com/yurriy)) +- پشتیبانی بیشتر `ALTER` نمایش داده شد `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- پشتیبانی `` بخش در `clickhouse-local` فایل پیکربندی. [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([پرولر](https://github.com/proller)) +- اجازه اجرای پرس و جو با `remote` تابع جدول در `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([پرولر](https://github.com/proller)) + +#### بهبود عملکرد {#performance-improvement-5} + +- اضافه کردن امکان ارسال علامت نهایی در پایان ستون ادغام. این اجازه می دهد برای جلوگیری از بی فایده می خواند برای کلید های که خارج از محدوده داده های جدول می باشد. این فعال است تنها اگر دانه دانه دانه تطبیقی در حال استفاده است. [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([الساپین](https://github.com/alesapin)) +- بهبود عملکرد جداول ادغام در فایل سیستم بسیار کند با کاهش تعداد `stat` syscalls. [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تخریب عملکرد ثابت در خواندن از جداول ادغام که در نسخه معرفی شد 19.6. رفع \# 5631. [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-8} + +- پیادهسازی شده `TestKeeper` به عنوان یک پیاده سازی از رابط باغ وحش مورد استفاده برای تست [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([الکسی میلویدو](https://github.com/alexey-milovidov)) ([لوشکین الکسیر](https://github.com/alexey-milovidov)) +- از حالا به بعد `.sql` تست ها را می توان به صورت موازی با پایگاه داده تصادفی جدا شده توسط سرور اجرا کرد. این اجازه می دهد تا سریعتر اجرا شود و تست های جدید را با تنظیمات سرور سفارشی اضافه کنید و اطمینان حاصل کنید که تست های مختلف بر یکدیگر تاثیر نمی گذارد. [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([ایوان](https://github.com/abyss7)) +- حذف `` و `` از تست های عملکرد [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- ثابت “select\_format” تست عملکرد برای `Pretty` فرشها [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +## انتشار کلیک 19.9 {#clickhouse-release-19-9} + +### ClickHouse انتشار 19.9.3.31, 2019-07-05 {#clickhouse-release-19-9-3-31-2019-07-05} + +#### رفع اشکال {#bug-fix-23} + +- اصلاح سگو در کدک دلتا که ستون ها را با مقادیر کمتر از اندازه 32 بیت تحت تاثیر قرار می دهد. اشکال منجر به فساد حافظه تصادفی. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([الساپین](https://github.com/alesapin)) +- رفع اشکال نادر در چک کردن بخشی با ستون کم هزینه. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([الساپین](https://github.com/alesapin)) +- رفع اشکال در ادغام ستون های غیر فیزیکی در بلوک. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع خواب بی نهایت بالقوه نمایش داده شد با اولویت پایین. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت کنید که چگونه کلیک هاوس منطقه زمانی پیش فرض را به عنوان کمپانی یوسیت تعیین می کند. [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال در مورد اجرای توزیع قطره/تغییر/کوتاه / بهینه سازی در نمایش داده شد خوشه در ماکت پیرو قبل از ماکت رهبر. در حال حاضر به طور مستقیم بر روی ماکت رهبر اجرا خواهد شد. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([الساپین](https://github.com/alesapin)) +- رفع شرایط مسابقه, که باعث می شود که برخی از نمایش داده شد ممکن است در انبار کردن بلافاصله پس از سیستم پرس و جو سیاهههای مربوط خیط و پیت کردن ظاهر نمی شود. [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([انتون پوپوف](https://github.com/CurtizJ)) +- اضافه شدن پشتیبانی از دست رفته برای استدلال ثابت به `evalMLModel` تابع. [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.9.2.4, 2019-06-24 {#clickhouse-release-19-9-2-4-2019-06-24} + +#### ویژگی جدید {#new-feature-8} + +- اطلاعات چاپ در مورد قطعات یخ زده در `system.parts` جدول [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([پرولر](https://github.com/proller)) +- درخواست رمز عبور مشتری در کلیک-مشتری شروع در تیتی اگر در استدلال تنظیم نشده است [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([پرولر](https://github.com/proller)) +- پیاده سازی `dictGet` و `dictGetOrDefault` توابع برای انواع اعشاری. [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([زویکوف](https://github.com/4ertus2)) + +#### بهبود {#improvement-8} + +- دبیان اینیت: اضافه کردن سرویس ایست ایست [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([پرولر](https://github.com/proller)) +- اضافه کردن تنظیم ممنوع به طور پیش فرض برای ایجاد جدول با انواع مشکوک برای کم کاری [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- توابع رگرسیون وزن مدل بازگشت زمانی که به عنوان دولت در تابع استفاده نمی شود `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([کد37](https://github.com/Quid37)) +- تغییر نام و بهبود روش رگرسیون. [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([کد37](https://github.com/Quid37)) +- رابط های واضح تر از جستجوگران رشته. [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([نام و نام خانوادگی](https://github.com/danlark1)) + +#### رفع اشکال {#bug-fix-24} + +- رفع از دست دادن داده های بالقوه در کافکا [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([ایوان](https://github.com/abyss7)) +- رفع حلقه بی نهایت بالقوه در `PrettySpace` فرمت زمانی که با صفر ستون نامیده می شود [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- اشکال سرریز ثابت در مدل های خطی. اجازه مدل میلی لیتر اومال برای استدلال مدل غیر توایع. [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- `ALTER TABLE ... DROP INDEX IF EXISTS ...` اگر شاخص موجود وجود ندارد باید یک استثنا را افزایش نمی دهد [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([گلب نویکوف](https://github.com/NanoBjorn)) +- رفع segfault با `bitmapHasAny` در زیر مقیاس [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([ژیچنگ یو](https://github.com/yuzhichang)) +- خطا ثابت زمانی که استخر اتصال تکرار کند سعی مجدد نیست برای حل و فصل میزبان, حتی زمانی که کش دی ان اس کاهش یافته بود. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([الساپین](https://github.com/alesapin)) +- ثابت `ALTER ... MODIFY TTL` در تکرار غذای اصلی. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([انتون پوپوف](https://github.com/CurtizJ)) +- رفع درج در جدول توزیع شده با ستون محقق شده [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([ازات خوژین](https://github.com/azat)) +- رفع تخصیص بد زمانی که کوتاه پیوستن به ذخیره سازی [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([تسیسون](https://github.com/TCeason)) +- در نسخه های اخیر از بسته tzdata برخی از فایل ها symlinks در حال حاضر. مکانیسم فعلی برای تشخیص منطقه زمانی پیش فرض شکسته می شود و نام اشتباه برای برخی از جغرافیایی می دهد. در حال حاضر حداقل ما نام منطقه زمانی را مجبور به محتویات انجمن تاز در صورت فراهم. [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([ایوان](https://github.com/abyss7)) +- رفع برخی از موارد بسیار نادر با جستجوگر چندگانه هنگامی که سوزن ثابت در مجموع حداقل 16 کیلوبایت طولانی است. الگوریتم از دست رفته و یا بیش از حد نتایج قبلی که می تواند به نتیجه نادرست منجر شود `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([نام و نام خانوادگی](https://github.com/danlark1)) +- رفع مشکل زمانی که تنظیمات برای ExternalData درخواست نمی تواند با استفاده از ClickHouse تنظیمات. همچنین در حال حاضر تنظیمات `date_time_input_format` و `low_cardinality_allow_in_native_format` می تواند به دلیل ابهام از نام استفاده نمی شود (در داده های خارجی را می توان به عنوان فرمت جدول تفسیر و در پرس و جو می تواند یک محیط). [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([نام و نام خانوادگی](https://github.com/danlark1)) +- رفع اشکال زمانی که قطعات تنها از فدراسیون فوتبال بدون رها کردن از باغ وحش حذف شد. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([الساپین](https://github.com/alesapin)) +- حذف ورود اشکال زدایی از پروتکل خروجی زیر [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رد کردن زنود در طول پردازش پرس و جو دی ال [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([ازات خوژین](https://github.com/azat)) +- ثابت مخلوط `UNION ALL` نوع ستون نتیجه. موارد با داده های متناقض و انواع ستون ستون نتیجه وجود دارد. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([زویکوف](https://github.com/4ertus2)) +- پرتاب یک استثنا در اعداد صحیح اشتباه در `dictGetT` توابع به جای تصادف. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([زویکوف](https://github.com/4ertus2)) +- رفع اشتباه element\_count و load\_factor برای درهم لغت در `system.dictionaries` جدول [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([ازات خوژین](https://github.com/azat)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-9} + +- ساخت ثابت بدون `Brotli` پردازشگر پشتیبانی شده: (`ENABLE_BROTLI=OFF` هشدار داده می شود [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([انت یوژنینو](https://github.com/citrin)) +- شامل خروش.ساعت به عنوان خروش / خروشان.ه [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([اوروج دش](https://github.com/orivej)) +- رفع gcc9 هشدار در hyperscan (\#خط بخشنامه بد است!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([نام و نام خانوادگی](https://github.com/danlark1)) +- رفع تمام هشدارهای هنگام کامپایل با شورای همکاری خلیج فارس-9. رفع برخی از مشکلات احتمالی. یخ گرم9 رو درست کن و به باگزیلا بفرست [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([نام و نام خانوادگی](https://github.com/danlark1)) +- ثابت ارتباط با [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حذف تخصص های استفاده نشده در لغت نامه [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([زویکوف](https://github.com/4ertus2)) +- تست های عملکرد بهبود برای قالب بندی و تجزیه جداول برای انواع مختلف فایل ها [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([اولگا خوستیکوا](https://github.com/stavrolia)) +- رفع تست موازی اجرا [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([پرولر](https://github.com/proller)) +- کارگر بارانداز: تنظیمات استفاده از کلیک-تست [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([پرولر](https://github.com/proller)) +- رفع کامپایل برای بورس [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([پرولر](https://github.com/proller)) +- ارتقا افزایش به 1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([پرولر](https://github.com/proller)) +- رفع ساخت clickhouse به عنوان submodule [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([پرولر](https://github.com/proller)) +- بهبود تست های عملکرد فوق العاده [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([ویتالی بارانو](https://github.com/vitlibar)) + +## انتشار کلیک 19.8 {#clickhouse-release-19-8} + +### انتشار کلیک خانه 19.8.3.8, 2019-06-11 {#clickhouse-release-19-8-3-8-2019-06-11} + +#### ویژگی های جدید {#new-features} + +- اضافه شدن توابع برای کار با جانسون [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([هکز](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([ویتالی بارانو](https://github.com/vitlibar)) +- اضافه کردن یک تابع basename با مشابه رفتار یک تابع basename که وجود دارد در بسیاری از زبان ها (`os.path.basename` در پایتون, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- اضافه شده `LIMIT n, m BY` یا `LIMIT m OFFSET n BY` نحو به مجموعه جبران نفر برای حد بند. [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([انتون پوپوف](https://github.com/CurtizJ)) +- نوع داده جدید اضافه شده است `SimpleAggregateFunction` که اجازه می دهد ستون ها را با تجمع نور در یک `AggregatingMergeTree`. این تنها می تواند با توابع ساده مانند استفاده می شود `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([بوریس گرانویو](https://github.com/bgranvea)) +- اضافه شدن پشتیبانی برای استدلال غیر ثابت در تابع `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اضافه شدن توابع `skewPop`, `skewSamp`, `kurtPop` و `kurtSamp` برای محاسبه به صورت دنباله skewness نمونه skewness, kurtosis و نمونه kurtosis بود. [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([هکز](https://github.com/hczhcz)) +- پشتیبانی تغییر نام عملیات برای `MaterializeView` انبار. [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- اضافه شده سرور که اجازه می دهد تا اتصال به تاتر با استفاده از مشتری خروجی زیر. [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([یوری بارانوف](https://github.com/yurriy)) +- افزودن `toDecimal*OrZero` و `toDecimal*OrNull` توابع. [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([زویکوف](https://github.com/4ertus2)) +- پشتیبانی از انواع دهدهی در توابع: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted`, medianExactWeighted. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([زویکوف](https://github.com/4ertus2)) +- اضافه شده `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اضافه شده `format` تابع. قالب بندی الگوی ثابت (الگوی فرمت پایتون ساده) با رشته های ذکر شده در استدلال. [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اضافه شده `system.detached_parts` جدول حاوی اطلاعات در مورد قطعات جدا شده از `MergeTree` میز [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([اکوزم](https://github.com/akuzm)) +- اضافه شده `ngramSearch` تابع برای محاسبه تفاوت غیر متقارن بین سوزن و انبار کاه. [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اجرای روشهای یادگیری ماشین پایه (رگرسیون خطی تصادفی و رگرسیون لجستیک) با استفاده از رابط توابع کل. دارای استراتژی های مختلف برای به روز رسانی وزن مدل (نزول گرادیان ساده, روش شتاب, روش نستروف). همچنین پشتیبانی از مینی دسته از اندازه های سفارشی. [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([کد37](https://github.com/Quid37)) +- اجرای `geohashEncode` و `geohashDecode` توابع. [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([واسیلی نمکو](https://github.com/Enmk)) +- اضافه شدن تابع جمع `timeSeriesGroupSum`, که می تواند سری های زمانی مختلف جمع می شوند که برچسب زمان نمونه هم ترازی نیست. این برون یابی خطی بین دو برچسب زمان نمونه و سپس مجموع زمان سری با هم استفاده کنید. اضافه شدن تابع جمع `timeSeriesGroupRateSum` که محاسبه نرخ زمان سری و سپس مجموع نرخ با هم. [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([یانگکوان لیو](https://github.com/LiuYangkuan)) +- اضافه شدن توابع `IPv4CIDRtoIPv4Range` و `IPv6CIDRtoIPv6Range` برای محاسبه محدوده های پایین تر و بالاتر برای یک ای پی در زیر شبکه با استفاده از یک سیدر. [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) +- اضافه کردن یک ایکس کلیک-هدر خلاصه زمانی که ما یک پرس و جو با استفاده از قام با تنظیم را فعال کنید ارسال `send_progress_in_http_headers`. بازگشت اطلاعات معمول از ایکس کلیک-پیشرفت, با اطلاعات اضافی مانند چند سطر و بایت در پرس و جو قرار داده شد. [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) + +#### بهبود {#improvements} + +- اضافه شده `max_parts_in_total` تنظیم برای خانواده ادغام جداول (به طور پیش فرض: 100 000) که مانع از مشخصات نا امن از کلید پارتیشن \#5166. [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `clickhouse-obfuscator`: استخراج دانه برای ستون های فردی با ترکیب دانه اولیه با نام ستون, موقعیت ستون نیست. این در نظر گرفته شده برای تبدیل مجموعه داده با جداول مرتبط متعدد, به طوری که جداول پس از تحول قابل اجرا باقی خواهد ماند. [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن توابع `JSONExtractRaw`, `JSONExtractKeyAndValues`. توابع تغییر نام داد `jsonExtract` به `JSONExtract`. هنگامی که چیزی را اشتباه می رود این توابع بازگشت ارزش خبرنگار, نه `NULL`. تابع اصلاح شده `JSONExtract` در حال حاضر نوع بازگشتی از پارامتر گذشته خود را دریافت می کند و نابل ها را تزریق نمی کند. اجرا مجدد به RapidJSON در مورد AVX2 دستورالعمل در دسترس نیست. کتابخانه سیمدجسون به روز شده به یک نسخه جدید. [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([ویتالی بارانو](https://github.com/vitlibar)) +- حالا `if` و `multiIf` توابع به وضعیت تکیه نمی کنند `Nullable`, اما در شاخه برای سازگاری گذاشتن تکیه. [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([جیان وو](https://github.com/janplus)) +- `In` گزاره در حال حاضر تولید می کند `Null` نتیجه از `Null` ورودی مانند `Equal` تابع. [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([جیان وو](https://github.com/janplus)) +- بررسی محدودیت زمانی هر (flush\_interval / poll\_timeout) تعداد سطر از کافکا. این اجازه می دهد تا خواندن را از مصرف کننده کافکا بیشتر کند و محدودیت های زمانی جریان های سطح بالا را بررسی کند [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([ایوان](https://github.com/abyss7)) +- لینک rdkafka با همراه SASL. باید اجازه می دهد به استفاده از SASL گریختن احراز هویت [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([ایوان](https://github.com/abyss7)) +- Batched نسخه RowRefList برای همه می پیوندد. [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([زویکوف](https://github.com/4ertus2)) +- کلیک سرور: اطلاعات بیشتر گوش پیام های خطا. [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([پرولر](https://github.com/proller)) +- واژهنامهها پشتیبانی در تاتر-کپی برای توابع در `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([پرولر](https://github.com/proller)) +- افزودن تنظیمات جدید `kafka_commit_every_batch` برای تنظیم کافکا ارتکاب سیاست. + این اجازه می دهد تا به مجموعه ای متعهد حالت: پس از هر دسته ای از پیام های به کار گرفته شده است, و یا پس از کل بلوک به ذخیره سازی نوشته شده. این یک تجارت بین از دست دادن برخی از پیام ها و یا خواندن دو بار در برخی شرایط شدید است. [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([ایوان](https://github.com/abyss7)) +- ساخت `windowFunnel` پشتیبانی از دیگر انواع عدد صحیح بدون علامت. [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- اجازه دادن به سایه ستون مجازی `_table` در ادغام موتور. [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([ایوان](https://github.com/abyss7)) +- ساخت `sequenceMatch` توابع مجموع پشتیبانی دیگر انواع عدد صحیح بدون علامت [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- پیام های خطا بهتر اگر عدم تطابق کنترلی است به احتمال زیاد توسط شکست سخت افزار ایجاد می شود. [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بررسی کنید که جداول پایه نمونه برداری را پشتیبانی می کنند `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([ایوان](https://github.com/abyss7)) +- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- بهبود پروتکل سیم خروجی زیر. تغییر نام قالب به میسورقلوایر. با استفاده از RAII برای تماس RSA\_free. غیر فعال کردن اس اس ال اگر زمینه نمی تواند ایجاد شود. [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([یوری بارانوف](https://github.com/yurriy)) +- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([پرولر](https://github.com/proller)) +- تنظیمات پرس و جو احترام در درج ناهمزمان به جداول توزیع. [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([تسیسون](https://github.com/TCeason)) +- توابع تغییر نام داد `leastSqr` به `simpleLinearRegression`, `LinearRegression` به `linearRegression`, `LogisticRegression` به `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) + +#### بهبود عملکرد {#performance-improvements} + +- Parallelize پردازش قطعات غیر تکراری MergeTree جداول در تغییر و اصلاح پرس و جو. [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([ایوان کوش](https://github.com/IvanKush)) +- بهینه سازی در استخراج عبارات منظم. [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اضافه کردن راست پیوستن به ستون های کلیدی برای پیوستن به نتیجه اگر فقط در عضویت در بخش استفاده می شود. [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([زویکوف](https://github.com/4ertus2)) +- یخ بافر کافکا پس از اولین پاسخ خالی. از چندین اختراع اجتناب می کند `ReadBuffer::next()` برای نتیجه خالی در برخی از جریان ردیف تجزیه. [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([ایوان](https://github.com/abyss7)) +- `concat` بهینه سازی عملکرد برای استدلال های متعدد. [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([نام و نام خانوادگی](https://github.com/danlark1)) +- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([زویکوف](https://github.com/4ertus2)) +- پیاده سازی لنز 4 ما را با یک مرجع ارتقا دهید تا فشرده سازی سریع تر داشته باشید. [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([نام و نام خانوادگی](https://github.com/danlark1)) +- پردازشگر پشتیبانی شده: [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([اوگنی پراودا](https://github.com/kvinty)) + +#### رفع اشکال {#bug-fixes} + +- رفع فشار نیاز به ستون با پیوستن [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([زمستان ژانگ](https://github.com/zhang2014)) +- اشکال ثابت, زمانی که تاتر توسط سیستم اجرا, فرمان `sudo service clickhouse-server forcerestart` کار نمی کند به عنوان انتظار می رود. [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([پرولر](https://github.com/proller)) +- رفع کدهای خطای اچ. تی. اچ. تی. پی در کد 9009 پورت همیشه کد 200 را حتی در خطاها برگرداند. [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([پرولر](https://github.com/proller)) +- رفع SimpleAggregateFunction برای رشته بیش از MAX\_SMALL\_STRING\_SIZE [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([ازات خوژین](https://github.com/azat)) +- رفع خطا برای `Decimal` به `Nullable(Decimal)` تبدیل در. پشتیبانی از دیگر دهدهی به دهدهی تبدیل (از جمله مقیاس های مختلف). [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([زویکوف](https://github.com/4ertus2)) +- مسدود کردن فلش ثابت در کتابخانه سیمدجسون که منجر به محاسبه اشتباه از `uniqHLL` و `uniqCombined` تابع کلی و توابع ریاضی مانند `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- دست زدن به ثابت موارد مخلوط ثابت/غیرنقدی در توابع جانسون. [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([ویتالی بارانو](https://github.com/vitlibar)) +- ثابت `retention` تابع. در حال حاضر تمام شرایطی که در یک ردیف از داده ها راضی به دولت داده ها اضافه شده است. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) +- رفع نوع نتیجه برای `quantileExact` با اعشار. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([زویکوف](https://github.com/4ertus2)) + +#### مستندات {#documentation} + +- ترجمه مستندات برای `CollapsingMergeTree` به سلامتی چینیها [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) +- ترجمه برخی از اسناد و مدارک در مورد موتورهای جدول به چینی. + [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) + [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) + ([هرگز لی](https://github.com/neverlee)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements} + +- رفع برخی از گزارش ضد عفونی که نشان می دهد احتمالی استفاده پس از رایگان.[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([ایوان](https://github.com/abyss7)) +- حرکت تست عملکرد از دایرکتوری جداگانه برای راحتی. [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع تست عملکرد نادرست. [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([الساپین](https://github.com/alesapin)) +- اضافه شدن یک ابزار برای محاسبه چک سام ناشی از کمی پایین بپرد به مشکلات اشکال زدایی سخت افزار. [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اسکریپت دونده قابل استفاده تر است. [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([فیلیمونف](https://github.com/filimonov)) +- اضافه کردن دستور العمل کوچک چگونه برای نوشتن تست عملکرد. [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([الساپین](https://github.com/alesapin)) +- اضافه کردن قابلیت تعویض در ایجاد, پر کردن و رها کردن پرس و جو در تست عملکرد [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([اولگا خوستیکوا](https://github.com/stavrolia)) + +## انتشار کلیک 19.7 {#clickhouse-release-19-7} + +### انتشار کلیک خانه 19.7.5.29, 2019-07-05 {#clickhouse-release-19-7-5-29-2019-07-05} + +#### رفع اشکال {#bug-fix-25} + +- رفع رگرسیون عملکرد در برخی از نمایش داده شد با پیوستن. [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([زمستان ژانگ](https://github.com/zhang2014)) + +### انتشار کلیک خانه 19.7.5.27, 2019-06-09 {#clickhouse-release-19-7-5-27-2019-06-09} + +#### ویژگی های جدید {#new-features-1} + +- اضافه شده توابع مربوط بیت مپ `bitmapHasAny` و `bitmapHasAll` مشابه به `hasAny` و `hasAll` توابع برای ارریس. [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([سرگی ولدیکین](https://github.com/svladykin)) + +#### رفع اشکال {#bug-fixes-1} + +- رفع segfault در `minmax` شاخص با ارزش صفر. [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- علامت گذاری به عنوان تمام ستون های ورودی در حد خروجی به عنوان مورد نیاز است. این رفع ‘Not found column’ خطا در برخی از نمایش داده شد توزیع. [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([پان سنتانتین](https://github.com/kvap)) +- ثابت “Column ‘0’ already exists” خطا در `SELECT .. PREWHERE` در ستون با پیش فرض [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([پرولر](https://github.com/proller)) +- ثابت `ALTER MODIFY TTL` پرسوجو در `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([انتون پوپوف](https://github.com/CurtizJ)) +- هنگامی که مصرف کنندگان کافکا برای شروع شکست خورده اند سرور تصادف نیست. [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([ایوان](https://github.com/abyss7)) +- توابع بیت مپ ثابت تولید نتیجه اشتباه است. [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([اندی یانگ](https://github.com/andyyzh)) +- حذف عناصر برای دیکشنری درهم (شامل موارد تکراری نیست) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([ازات خوژین](https://github.com/azat)) +- استفاده از محتویات محیط زیست تغییر تنظیمات متغیر به عنوان نام برای منطقه زمانی. این کمک می کند تا به درستی شناسایی منطقه زمانی پیش فرض در برخی موارد.[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([ایوان](https://github.com/abyss7)) +- سعی نکنید برای تبدیل اعداد صحیح در `dictGetT` توابع, چرا که به درستی کار نمی کند. پرتاب یک استثنا به جای. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([زویکوف](https://github.com/4ertus2)) +- رفع تنظیمات در درخواست خارجی. [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([دنیلا + کوتنین](https://github.com/danlark1)) +- رفع اشکال زمانی که قطعات تنها از فدراسیون فوتبال بدون رها کردن از باغ وحش حذف شد. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([الساپین](https://github.com/alesapin)) +- رفع گسل تقسیم بندی در `bitmapHasAny` تابع. [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([ژیچنگ یو](https://github.com/yuzhichang)) +- خطا ثابت زمانی که استخر اتصال تکرار کند سعی مجدد نیست برای حل و فصل میزبان, حتی زمانی که کش دی ان اس کاهش یافته بود. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([الساپین](https://github.com/alesapin)) +- ثابت `DROP INDEX IF EXISTS` پرس و جو. حالا `ALTER TABLE ... DROP INDEX IF EXISTS ...` پرس و جو یک استثنا را افزایش نمی دهد اگر شاخص وجود ندارد. [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([گلب نویکوف](https://github.com/NanoBjorn)) +- رفع اتحادیه تمام ستون نوع فوق. موارد با داده های متناقض و انواع ستون ستون نتیجه وجود دارد. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([زویکوف](https://github.com/4ertus2)) +- جست و خیز ZNONODE در طول دستورات پرس و جو پردازش. قبل از اگر گره دیگر حذف زنود در صف کار, یکی که + اما در حال حاضر لیستی از کودکان را دریافت نمی کند موضوع کار کرم را خاتمه می دهد. [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([ازات خوژین](https://github.com/azat)) +- ثابت قرار دادن به توزیع() جدول با ستون محقق. [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([ازات خوژین](https://github.com/azat)) + +### انتشار کلیک خانه 19.7.3.9, 2019-05-30 {#clickhouse-release-19-7-3-9-2019-05-30} + +#### ویژگی های جدید {#new-features-2} + +- اجازه می دهد برای محدود کردن طیف وسیعی از یک محیط است که می تواند توسط کاربر مشخص شده است. + این محدودیت ها را می توان در مشخصات تنظیمات کاربر تنظیم شده است. + [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([ویتالی + بارانوف](https://github.com/vitlibar)) +- اضافه کردن نسخه دوم از تابع `groupUniqArray` با اختیاری + `max_size` پارامتر که اندازه مجموعه نتیجه را محدود می کند. این + رفتار شبیه به `groupArray(max_size)(x)` تابع. + [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([گیمه + کاسری](https://github.com/YiuRULE)) +- برای TSVWithNames/CSVWithNames ورودی فرمت های فایل های ستون سفارش در حال حاضر می تواند + تعیین شده از هدر فایل. این است که با کنترل + `input_format_with_names_use_header` پارامتر. + [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) + ([الکساندر](https://github.com/Akazz)) + +#### رفع اشکال {#bug-fixes-2} + +- سقوط با غیر فشرده + عضویت در هنگام ادغام (\#5197) + [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([دنیلا + کوتنین](https://github.com/danlark1)) +- گسل تقسیم بندی در یک پرس و جو کلیک مشتری به جداول سیستم. \#5066 + [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) + ([ایوان](https://github.com/abyss7)) +- از دست دادن داده ها در بار سنگین از طریق کافکاینگین (\#4736) + [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) + ([ایوان](https://github.com/abyss7)) +- ثابت شرایط مسابقه داده بسیار نادر است که می تواند در هنگام اجرای یک پرس و جو با اتحادیه همه شامل حداقل دو انتخاب از سیستم اتفاق می افتد.ستون, سیستم.جداول, سیستم.قطعات, سیستم.\_شبردارها یا جداول ادغام خانواده و انجام تغییر ستون از جداول مرتبط به صورت همزمان. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### بهبود عملکرد {#performance-improvements-1} + +- استفاده از مرتب سازی بر رادیوگرافی برای مرتب سازی بر اساس ستون عددی در `ORDER BY` بدون + `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), + [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) + ([اوگنی پراودا](https://github.com/kvinty), + [الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### مستندات {#documentation-1} + +- ترجمه اسناد و مدارک برای برخی از موتورهای جدول به چینی. + [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), + [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), + [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) + ([张风啸](https://github.com/AlexZFX)), + [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([هرگز + لی](https://github.com/neverlee)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-1} + +- نسخه قابل چاپ سخن گفتن-8 کاراکتر به درستی در `clickhouse-test`. + [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) + ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن پارامتر خط فرمان برای فاحشه خانه-مشتری برای همیشه بار پیشنهاد + داده ها. [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) + ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حل و فصل برخی از هشدارهای پوس استودیو. + [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) + ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- به روز رسانی LZ4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([دنیلا + کوتنین](https://github.com/danlark1)) +- اضافه کردن پردازنده گرافیکی برای ساخت الزامات مورد نیاز برای درخواست پیش رو کشیدن \# 5030. + [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) + ([پرولر](https://github.com/proller)) + +## انتشار کلیک 19.6 {#clickhouse-release-19-6} + +### انتشار کلیک خانه 19.6.3.18, 2019-06-13 {#clickhouse-release-19-6-3-18-2019-06-13} + +#### رفع اشکال {#bug-fixes-3} + +- ثابت در شرایط فشار برای نمایش داده شد از توابع جدول `mysql` و `odbc` و موتورهای جدول مربوطه. این رفع \# 3540 و \# 2384. [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع بن بست در باغ وحش. [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([گیتهاب 1یولک](https://github.com/github1youlc)) +- اجازه اعشار نقل در سی سی. وی. [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([زویکوف](https://github.com/4ertus2) +- عدم تبدیل از اینف شناور / نان به اعشار (استثنا پرتاب). [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([زویکوف](https://github.com/4ertus2)) +- رفع مسابقه داده ها در تغییر نام پرس و جو. [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([زمستان ژانگ](https://github.com/zhang2014)) +- به طور موقت غیر فعال کردن کلیک. استفاده از LFAlloc ممکن است منجر به بسیاری از MAP\_FAILED در تخصیص UncompressedCache و در نتیجه به سقوط از نمایش داده شد در بالا لود سرور. [لامپ کم مصرف93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([نام و نام خانوادگی](https://github.com/danlark1)) + +### انتشار کلیک خانه 19.6.2.11, 2019-05-13 {#clickhouse-release-19-6-2-11-2019-05-13} + +#### ویژگی های جدید {#new-features-3} + +- عبارات برای ستون ها و جداول. [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([انتون پوپوف](https://github.com/CurtizJ)) +- اضافه شدن پشتیبانی برای `brotli` فشردهسازی برای پاسخهای قام (پذیرش کدبندی: برزیلی) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([میخیل](https://github.com/fandyushin)) +- اضافه شدن تابع جدید `isValidUTF8` برای بررسی اینکه مجموعه ای از بایت ها به درستی کد گذاری شده باشد-8. [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اضافه کردن سیاست متعادل کننده بار جدید `first_or_random` که نمایش داده شد به اولین میزبان مشخص می فرستد و اگر غیر قابل دسترس ارسال نمایش داده شد به میزبان تصادفی از سفال. مفید برای تنظیم توپولوژی متقابل تکرار. [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([نوارتولومی](https://github.com/nvartolomei)) + +#### ویژگی های تجربی {#experimental-features-1} + +- افزودن تنظیمات `index_granularity_bytes` (تطبیقی دانه دانه دانه شاخص) برای ادغام \* خانواده جداول. [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([الساپین](https://github.com/alesapin)) + +#### بهبود {#improvements-1} + +- اضافه شدن پشتیبانی برای اندازه و طول استدلال غیر ثابت و منفی برای عملکرد `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- غیر فعال کردن فشار به پایین به جدول سمت راست در سمت چپ عضویت, جدول سمت چپ در راست عضویت, و هر دو جدول به طور کامل ملحق. این رفع اشتباه پیوستن به نتایج در برخی موارد. [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([ایوان](https://github.com/abyss7)) +- `clickhouse-copier`: بارگذاری خودکار پیکربندی وظیفه از `--task-file` گزینه [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([پرولر](https://github.com/proller)) +- اضافه شده کنترل غلط املایی برای کارخانه ذخیره سازی و توابع جدول کارخانه. [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([نام و نام خانوادگی](https://github.com/danlark1)) +- ستاره پشتیبانی و ستاره واجد شرایط برای چند می پیوندد بدون زیر کشت [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([زویکوف](https://github.com/4ertus2)) +- پیام خطای ستون گم شده را کاربر پسند تر کنید. [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([زویکوف](https://github.com/4ertus2)) + +#### بهبود عملکرد {#performance-improvements-2} + +- افزایش سرعت قابل توجهی از عضویت [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([مرتیجن باکر](https://github.com/Gladdy)) + +#### تغییرات ناسازگار به عقب {#backward-incompatible-changes} + +- HTTP header `Query-Id` به تغییر نام داد `X-ClickHouse-Query-Id` برای ثبات. [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([میخیل](https://github.com/fandyushin)) + +#### رفع اشکال {#bug-fixes-4} + +- اختلاف اشاره گر صفر پتانسیل ثابت در `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([پرولر](https://github.com/proller)) +- خطای ثابت در پرس و جو با پیوستن + مجموعه پیوستن [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([زویکوف](https://github.com/4ertus2)) +- ثابت معلق در شروع سرور زمانی که یک فرهنگ لغت بستگی به فرهنگ لغت دیگری از طریق یک پایگاه داده با موتور=فرهنگ لغت. [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([ویتالی بارانو](https://github.com/vitlibar)) +- Partially fix distributed\_product\_mode = local. It's possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There's not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([زویکوف](https://github.com/4ertus2)) +- رفع نتیجه به طور بالقوه اشتباه برای `SELECT DISTINCT` با `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([زویکوف](https://github.com/4ertus2)) +- ثابت شرایط مسابقه داده بسیار نادر است که می تواند در هنگام اجرای یک پرس و جو با اتحادیه همه شامل حداقل دو انتخاب از سیستم اتفاق می افتد.ستون, سیستم.جداول, سیستم.قطعات, سیستم.\_شبردارها یا جداول ادغام خانواده و انجام تغییر ستون از جداول مرتبط به صورت همزمان. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-2} + +- شکست تست ثابت زمانی که در حال اجرا خانه عروسکی سرور در میزبان های مختلف [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([واسیلی نمکو](https://github.com/Enmk)) +- تاتر-تست: غیر فعال کردن توالی کنترل رنگ در محیط غیر تیتی. [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([الساپین](https://github.com/alesapin)) +- کلیک-تست: اجازه استفاده از هر پایگاه داده تست (برداشتن `test.` صلاحیت در صورت امکان) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([پرولر](https://github.com/proller)) +- رفع خطاهای اوبان [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([ویتالی بارانو](https://github.com/vitlibar)) +- Yandex LFAlloc اضافه شد به ClickHouse به تخصیص MarkCache و UncompressedCache داده ها در روش های مختلف برای گرفتن segfaults بیشتر قابل اعتماد [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([نام و نام خانوادگی](https://github.com/danlark1)) +- پایتون ییل برای کمک به با کوله پشتی و تغییرات. [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([ایوان](https://github.com/abyss7)) + +## انتشار کلیک 19.5 {#clickhouse-release-19-5} + +### انتشار کلیک خانه 19.5.4.22, 2019-05-13 {#clickhouse-release-19-5-4-22-2019-05-13} + +#### رفع اشکال {#bug-fixes-5} + +- تصادف ممکن است ثابت در بیت مپ [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([اندی یانگ](https://github.com/andyyzh)) +- ثابت شرایط مسابقه داده بسیار نادر است که می تواند در هنگام اجرای یک پرس و جو با اتحادیه همه شامل حداقل دو انتخاب از سیستم اتفاق می افتد.ستون, سیستم.جداول, سیستم.قطعات, سیستم.\_شبردارها یا جداول ادغام خانواده و انجام تغییر ستون از جداول مرتبط به صورت همزمان. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطای ثابت `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. این خطا اتفاق افتاد اگر ستون کمکاری بخشی از کلید اصلی بود. \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اصلاح تابع حفظ و نگهداری: اگر یک ردیف ارضا هر دو شرط اول و بعد از ظهر, تنها اولین شرط راضی به دولت داده اضافه. در حال حاضر تمام شرایطی که در یک ردیف از داده ها راضی به دولت داده ها اضافه شده است. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) + +### انتشار کلیک خانه 19.5.3.8, 2019-04-18 {#clickhouse-release-19-5-3-8-2019-04-18} + +#### رفع اشکال {#bug-fixes-6} + +- نوع ثابت تنظیم `max_partitions_per_insert_block` از بولی به UInt64. [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([محمد حسین Sekhavat](https://github.com/mhsekhavat)) + +### انتشار کلیک خانه 19.5.2.6, 2019-04-15 {#clickhouse-release-19-5-2-6-2019-04-15} + +#### ویژگی های جدید {#new-features-4} + +- [Hyperscan](https://github.com/intel/hyperscan) تطبیق عبارت منظم چندگانه اضافه شد (توابع `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([نام و نام خانوادگی](https://github.com/danlark1)) +- `multiSearchFirstPosition` تابع اضافه شد. [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([نام و نام خانوادگی](https://github.com/danlark1)) +- فیلتر بیان از پیش تعریف شده را در هر ردیف برای جداول اجرا کنید. [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([ایوان](https://github.com/abyss7)) +- نوع جدیدی از شاخص های داده پرش بر اساس فیلتر بلوم (می تواند برای استفاده `equal`, `in` و `like` توابع). [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- اضافه شده `ASOF JOIN` که اجازه می دهد برای اجرای نمایش داده شد که پیوستن به ارزش های اخیر شناخته شده است. [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([مرتیجن باکر](https://github.com/Gladdy), [زویکوف](https://github.com/4ertus2)) +- بازنویسی چندگانه `COMMA JOIN` به `CROSS JOIN`. سپس دوباره نوشتن به `INNER JOIN` در صورت امکان. [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([زویکوف](https://github.com/4ertus2)) + +#### بهبود {#improvement-9} + +- `topK` و `topKWeighted` در حال حاضر پشتیبانی سفارشی `loadFactor` (رفع مشکل [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([Kirill Danshin](https://github.com/kirillDanshin)) +- مجاز به استفاده `parallel_replicas_count > 1` حتی برای جداول بدون نمونه گیری (تنظیم به سادگی برای نادیده گرفته می شود). در نسخه های قبلی منجر به استثنا شد. [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([الکسی الیمانوف](https://github.com/digitalist)) +- پشتیبانی از `CREATE OR REPLACE VIEW`. اجازه می دهد برای ایجاد یک نمایش و یا تنظیم یک تعریف جدید در یک بیانیه واحد. [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([بوریس گرانویو](https://github.com/bgranvea)) +- `Buffer` موتور جدول در حال حاضر پشتیبانی می کند `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([یانگکوان لیو](https://github.com/LiuYangkuan)) +- اضافه کردن توانایی برای شروع جدول تکرار بدون ابرداده در باغ وحش در `readonly` حالت. [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([الساپین](https://github.com/alesapin)) +- سوسو زدن ثابت از نوار پیشرفت در خانه کلیک مشتری. این موضوع در هنگام استفاده قابل توجه بود `FORMAT Null` با نمایش داده شد جریان. [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجازه برای غیر فعال کردن توابع با `hyperscan` کتابخانه بر اساس هر کاربر برای محدود کردن استفاده از منابع بالقوه بیش از حد و کنترل نشده. [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن شماره نسخه ورود به سیستم در تمام اشتباهات. [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([پرولر](https://github.com/proller)) +- محدودیت اضافه شده به `multiMatch` توابع که نیاز به اندازه رشته به جا به `unsigned int`. همچنین اضافه شده تعداد استدلال محدود به `multiSearch` توابع. [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([نام و نام خانوادگی](https://github.com/danlark1)) +- استفاده بهبود یافته از فضای خراش و دست زدن به خطا در هیپرسکان. [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([نام و نام خانوادگی](https://github.com/danlark1)) +- پر کردن `system.graphite_detentions` از پیکربندی جدول `*GraphiteMergeTree` جداول موتور. [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- تغییر نام `trigramDistance` تابع به `ngramDistance` و اضافه کردن توابع بیشتر با `CaseInsensitive` و `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([نام و نام خانوادگی](https://github.com/danlark1)) +- داده های بهبود پرش محاسبه شاخص. [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- عادی نگه دارید, `DEFAULT`, `MATERIALIZED` و `ALIAS` ستون ها در یک لیست واحد (رفع مشکل [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([الکس زتلپین](https://github.com/ztlpn)) + +#### رفع اشکال {#bug-fix-26} + +- اجتناب از `std::terminate` در صورت شکست تخصیص حافظه. حالا `std::bad_alloc` استثنا پرتاب به عنوان انتظار می رود. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع کاپپروتو خواندن از بافر. گاهی اوقات فایل ها با موفقیت توسط اچ تی پی لود نمی شد. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ولادیسلاو](https://github.com/smirnov-vs)) +- رفع خطا `Unknown log entry type: 0` پس از `OPTIMIZE TABLE FINAL` پرس و جو. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([ایموس پرنده](https://github.com/amosbird)) +- نشانوندهای نادرست برای `hasAny` یا `hasAll` توابع ممکن است منجر به تقسیم بندی شوند. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بن بست ممکن است رخ دهد در حالی که اجرای `DROP DATABASE dictionary` پرس و جو. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع رفتار تعریف نشده در `median` و `quantile` توابع. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([هکز](https://github.com/hczhcz)) +- رفع تشخیص سطح فشرده سازی زمانی که `network_compression_method` با حروف کوچک. شکسته در و19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([پرولر](https://github.com/proller)) +- جهل ثابت `UTC` تنظیم (رفع مشکل [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([پرولر](https://github.com/proller)) +- ثابت `histogram` رفتار عملکرد با `Distributed` میز [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([اولگ](https://github.com/olegkv)) +- ثابت گزارش تسان `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- گزارش ساان ثابت در خاموش کردن با توجه به شرایط مسابقه در استفاده از سیستم سیاهههای مربوط. استفاده از پتانسیل ثابت-پس از رایگان در خاموش کردن زمانی که قطعه فعال است. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع قطعات بررسی مجدد در `ReplicatedMergeTreeAlterThread` در صورت خطا. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- عملیات ریاضی در کشورهای تابع جمع متوسط برای استدلال ثابت کار نمی کند (مانند نتایج زیرخاکی). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نام ستون همیشه نقل مکان کردن در ابرداده. در غیر این صورت ایجاد یک جدول با ستون به نام غیرممکن است `index` (سرور به دلیل ناقص راه اندازی مجدد نخواهد شد `ATTACH` پرس و جو در ابرداده). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع سقوط در `ALTER ... MODIFY ORDER BY` روشن `Distributed` جدول [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([تسیسون](https://github.com/TCeason)) +- رفع segfault در `JOIN ON` با فعال `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([زمستان ژانگ](https://github.com/zhang2014)) +- رفع اشکال با اضافه کردن یک ردیف غیر اصلی پس از مصرف یک پیام محافظ از کافکا. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع سقوط از `JOIN` نه-nullable در مقابل nullable ستون. ثابت `NULLs` در کلید سمت راست در `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([زویکوف](https://github.com/4ertus2)) +- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) +- شرایط مسابقه ثابت در `SELECT` از `system.tables` اگر جدول تغییر نام و یا تغییر به صورت همزمان. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- مسابقه داده ثابت زمانی که واکشی بخش داده است که در حال حاضر منسوخ شده است. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- مسابقه داده های نادر ثابت که می تواند در طول اتفاق می افتد `RENAME` جدول خانواده ادغام. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- گسل تقسیم بندی ثابت در عملکرد `arrayIntersect`. گسل تقسیم بندی می تواند رخ دهد اگر تابع با استدلال ثابت و عادی مخلوط نامیده می شد. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang کیان](https://github.com/fancyqlx)) +- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع سقوط در `FULL/RIGHT JOIN` هنگامی که ما در پیوستن به nullable در مقابل نه nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([زویکوف](https://github.com/4ertus2)) +- ثابت `No message received` استثنا در حالی که دلربا قطعات بین کپی. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([الساپین](https://github.com/alesapin)) +- ثابت `arrayIntersect` عملکرد نتیجه اشتباه در مورد چندین مقدار تکرار در مجموعه تک. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع شرایط مسابقه در طول همزمان `ALTER COLUMN` نمایش داده شد که می تواند به یک تصادف سرور منجر شود (رفع مشکل [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([الکس زتلپین](https://github.com/ztlpn)) +- رفع نتیجه نادرست در `FULL/RIGHT JOIN` با ستون توایع. [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([زویکوف](https://github.com/4ertus2)) +- رفع موارد تکراری در `GLOBAL JOIN` با ستاره. [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([زویکوف](https://github.com/4ertus2)) +- رفع کسر پارامتر در `ALTER MODIFY` از ستون `CODEC` هنگامی که نوع ستون مشخص نشده است. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([الساپین](https://github.com/alesapin)) +- توابع `cutQueryStringAndFragment()` و `queryStringAndFragment()` در حال حاضر به درستی کار می کند زمانی که `URL` شامل یک قطعه و بدون پرس و جو. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع اشکال نادر هنگام تنظیم `min_bytes_to_use_direct_io` بزرگتر از صفر است, که رخ می دهد زمانی که موضوع باید به دنبال عقب در فایل ستون. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([الساپین](https://github.com/alesapin)) +- رفع انواع استدلال اشتباه برای توابع مجموع با `LowCardinality` نشانوندها (رفع مشکل [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع صلاحیت نام اشتباه در `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([زویکوف](https://github.com/4ertus2)) +- تابع ثابت `toISOWeek` نتیجه برای سال 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `DROP`, `TRUNCATE` و `OPTIMIZE` نمایش داده شد تقلید, زمانی که در اجرا `ON CLUSTER` برای `ReplicatedMergeTree*` خانواده جداول. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([الساپین](https://github.com/alesapin)) + +#### تغییر ناسازگار به عقب {#backward-incompatible-change-8} + +- تغییر نام تنظیمات `insert_sample_with_metadata` به تنظیم `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([زویکوف](https://github.com/4ertus2)) +- اضافه شدن تنظیمات `max_partitions_per_insert_block` (با مقدار 100 به طور پیش فرض). اگر بلوک قرار داده شامل تعداد بیشتری از پارتیشن, یک استثنا پرتاب می شود. تنظیم به 0 اگر شما می خواهید به حذف حد (توصیه نمی شود). [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- توابع چند جستجو تغییر نام داد (`multiPosition` به `multiSearchAllPositions`, `multiSearch` به `multiSearchAny`, `firstMatch` به `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([نام و نام خانوادگی](https://github.com/danlark1)) + +#### بهبود عملکرد {#performance-improvement-6} + +- بهینه سازی Volnitsky جستجوگر توسط inlining دادن حدود 5-10% بهبود جستجو برای نمایش داده شد و با بسیاری از سوزن و یا بسیاری از شبیه bigrams. [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([نام و نام خانوادگی](https://github.com/danlark1)) +- رفع مشکل عملکرد در هنگام تنظیم `use_uncompressed_cache` بزرگتر از صفر است, که به نظر می رسد زمانی که همه اطلاعات به عنوان خوانده شده موجود در کش. [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([الساپین](https://github.com/alesapin)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-10} + +- سخت شدن اشکال زدایی ساخت: بیشتر نگاشت حافظه دانه و اصل مطلب; اضافه کردن حفاظت از حافظه برای کش علامت و شاخص. این اجازه می دهد تا برای پیدا کردن حافظه بیشتر کوبیدن اشکالات در صورتی که زمانی که اسان و ام اسان نمی تواند این کار را انجام. [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن پشتیبانی از متغیرهای کیک `ENABLE_PROTOBUF`, `ENABLE_PARQUET` و `ENABLE_BROTLI` که اجازه می دهد برای فعال/غیر فعال کردن ویژگی های فوق (همان است که ما می توانیم برای کتابدار انجام, خروجی زیر, و غیره). [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([سیلو کاراژیا](https://github.com/silviucpp)) +- اضافه کردن توانایی برای چاپ لیست روند و بند از تمام موضوعات اگر برخی از نمایش داده شد پس از اجرای تست را قطع کرد. [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([الساپین](https://github.com/alesapin)) +- اضافه کردن مجدد در `Connection loss` خطا در `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([الساپین](https://github.com/alesapin)) +- اضافه کردن ساخت بورس با ولگرد و ساخت با ضد عفونی کننده موضوع به اسکریپت بسته بندی. [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([الساپین](https://github.com/alesapin)) +- در حال حاضر کاربر برای رمز عبور برای کاربر خواسته `'default'` در هنگام نصب. [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([پرولر](https://github.com/proller)) +- سرکوب هشدار در `rdkafka` کتابخونه. [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجازه توانایی ساخت بدون اس اس ال. [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([پرولر](https://github.com/proller)) +- اضافه کردن یک راه برای راه اندازی تاتر-تصویر سرور از یک کاربر سفارشی. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- ارتقا تقویت میله به 1.69. [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([پرولر](https://github.com/proller)) +- غیر فعال کردن استفاده از `mremap` هنگامی که با ضد عفونی کننده موضوع وارد شده است. با کمال تعجب به اندازه کافی, تسان می کند رهگیری نیست `mremap` (هر چند که رهگیری `mmap`, `munmap`) که منجر به مثبت کاذب. گزارش تسان ثابت در تست نفرت انگیز. [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن چک کردن تست با استفاده از طرح فرمت از طریق رابط قام. [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([ویتالی بارانو](https://github.com/vitlibar)) + +## انتشار کلیک 19.4 {#clickhouse-release-19-4} + +### انتشار کلیک خانه 19.4.33, 2019-04-17 {#clickhouse-release-19-4-4-33-2019-04-17} + +#### رفع اشکال {#bug-fixes-7} + +- اجتناب از `std::terminate` در صورت شکست تخصیص حافظه. حالا `std::bad_alloc` استثنا پرتاب به عنوان انتظار می رود. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع کاپپروتو خواندن از بافر. گاهی اوقات فایل ها با موفقیت توسط اچ تی پی لود نمی شد. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ولادیسلاو](https://github.com/smirnov-vs)) +- رفع خطا `Unknown log entry type: 0` پس از `OPTIMIZE TABLE FINAL` پرس و جو. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([ایموس پرنده](https://github.com/amosbird)) +- نشانوندهای نادرست برای `hasAny` یا `hasAll` توابع ممکن است منجر به تقسیم بندی شوند. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بن بست ممکن است رخ دهد در حالی که اجرای `DROP DATABASE dictionary` پرس و جو. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع رفتار تعریف نشده در `median` و `quantile` توابع. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([هکز](https://github.com/hczhcz)) +- رفع تشخیص سطح فشرده سازی زمانی که `network_compression_method` با حروف کوچک. شکسته در و19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([پرولر](https://github.com/proller)) +- جهل ثابت `UTC` تنظیم (رفع مشکل [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([پرولر](https://github.com/proller)) +- ثابت `histogram` رفتار عملکرد با `Distributed` میز [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([اولگ](https://github.com/olegkv)) +- ثابت گزارش تسان `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- گزارش ساان ثابت در خاموش کردن با توجه به شرایط مسابقه در استفاده از سیستم سیاهههای مربوط. استفاده از پتانسیل ثابت-پس از رایگان در خاموش کردن زمانی که قطعه فعال است. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع قطعات بررسی مجدد در `ReplicatedMergeTreeAlterThread` در صورت خطا. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- عملیات ریاضی در کشورهای تابع جمع متوسط برای استدلال ثابت کار نمی کند (مانند نتایج زیرخاکی). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نام ستون همیشه نقل مکان کردن در ابرداده. در غیر این صورت ایجاد یک جدول با ستون به نام غیرممکن است `index` (سرور به دلیل ناقص راه اندازی مجدد نخواهد شد `ATTACH` پرس و جو در ابرداده). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع سقوط در `ALTER ... MODIFY ORDER BY` روشن `Distributed` جدول [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([تسیسون](https://github.com/TCeason)) +- رفع segfault در `JOIN ON` با فعال `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([زمستان ژانگ](https://github.com/zhang2014)) +- رفع اشکال با اضافه کردن یک ردیف غیر اصلی پس از مصرف یک پیام محافظ از کافکا. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) +- شرایط مسابقه ثابت در `SELECT` از `system.tables` اگر جدول تغییر نام و یا تغییر به صورت همزمان. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- مسابقه داده ثابت زمانی که واکشی بخش داده است که در حال حاضر منسوخ شده است. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- مسابقه داده های نادر ثابت که می تواند در طول اتفاق می افتد `RENAME` جدول خانواده ادغام. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- گسل تقسیم بندی ثابت در عملکرد `arrayIntersect`. گسل تقسیم بندی می تواند رخ دهد اگر تابع با استدلال ثابت و عادی مخلوط نامیده می شد. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang کیان](https://github.com/fancyqlx)) +- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- ثابت `No message received` استثنا در حالی که دلربا قطعات بین کپی. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([الساپین](https://github.com/alesapin)) +- ثابت `arrayIntersect` عملکرد نتیجه اشتباه در مورد چندین مقدار تکرار در مجموعه تک. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- رفع شرایط مسابقه در طول همزمان `ALTER COLUMN` نمایش داده شد که می تواند به یک تصادف سرور منجر شود (رفع مشکل [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([الکس زتلپین](https://github.com/ztlpn)) +- رفع کسر پارامتر در `ALTER MODIFY` از ستون `CODEC` هنگامی که نوع ستون مشخص نشده است. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([الساپین](https://github.com/alesapin)) +- توابع `cutQueryStringAndFragment()` و `queryStringAndFragment()` در حال حاضر به درستی کار می کند زمانی که `URL` شامل یک قطعه و بدون پرس و جو. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([ویتالی بارانو](https://github.com/vitlibar)) +- رفع اشکال نادر هنگام تنظیم `min_bytes_to_use_direct_io` بزرگتر از صفر است, که رخ می دهد زمانی که موضوع باید به دنبال عقب در فایل ستون. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([الساپین](https://github.com/alesapin)) +- رفع انواع استدلال اشتباه برای توابع مجموع با `LowCardinality` نشانوندها (رفع مشکل [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- تابع ثابت `toISOWeek` نتیجه برای سال 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `DROP`, `TRUNCATE` و `OPTIMIZE` نمایش داده شد تقلید, زمانی که در اجرا `ON CLUSTER` برای `ReplicatedMergeTree*` خانواده جداول. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([الساپین](https://github.com/alesapin)) + +#### بهبود {#improvements-2} + +- عادی نگه دارید, `DEFAULT`, `MATERIALIZED` و `ALIAS` ستون ها در یک لیست واحد (رفع مشکل [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([الکس زتلپین](https://github.com/ztlpn)) + +### ClickHouse انتشار 19.4.3.11, 2019-04-02 {#clickhouse-release-19-4-3-11-2019-04-02} + +#### رفع اشکال {#bug-fixes-8} + +- رفع سقوط در `FULL/RIGHT JOIN` هنگامی که ما در پیوستن به nullable در مقابل نه nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([زویکوف](https://github.com/4ertus2)) +- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-11} + +- اضافه کردن یک راه برای راه اندازی تاتر-تصویر سرور از یک کاربر سفارشی. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### انتشار کلیک خانه 19.4.2.7, 2019-03-30 {#clickhouse-release-19-4-2-7-2019-03-30} + +#### رفع اشکال {#bug-fixes-9} + +- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) + +### انتشار کلیک خانه 19.4.1.3, 2019-03-19 {#clickhouse-release-19-4-1-3-2019-03-19} + +#### رفع اشکال {#bug-fixes-10} + +- نمایش داده شد از راه دور ثابت که شامل هر دو `LIMIT BY` و `LIMIT`. قبلا اگر `LIMIT BY` و `LIMIT` برای پرس و جو از راه دور استفاده شد, `LIMIT` می تواند قبل از اتفاق می افتد `LIMIT BY`, که منجر به نتیجه بیش از حد فیلتر. [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([پان سنتانتین](https://github.com/kvap)) + +### انتشار کلیک خانه 19.4.0.49, 2019-03-09 {#clickhouse-release-19-4-0-49-2019-03-09} + +#### ویژگی های جدید {#new-features-5} + +- اضافه شدن پشتیبانی کامل برای `Protobuf` قالب (ورودی و خروجی, ساختارهای داده تو در تو). [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([ویتالی بارانو](https://github.com/vitlibar)) +- توابع بیت مپ اضافه شده با بیت مپ خروشان. [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([اندی یانگ](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([ویتالی بارانو](https://github.com/vitlibar)) +- پشتیبانی از فرمت پارکت. [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([پرولر](https://github.com/proller)) +- فاصله ان گرم برای مقایسه رشته فازی اضافه شد. این شبیه به معیارهای پرسش گرم در زبان تحقیق است. [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([نام و نام خانوادگی](https://github.com/danlark1)) +- ترکیب قوانین برای رولپ گرافیت از تجمع اختصاصی و الگوهای نگهداری. [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- اضافه شده `max_execution_speed` و `max_execution_speed_bytes` برای محدود کردن استفاده از منابع. اضافه شده `min_execution_speed_bytes` تنظیم برای تکمیل `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([زمستان ژانگ](https://github.com/zhang2014)) +- تابع اجرا شده `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([الکسی میلویدو](https://github.com/alexey-milovidov), [کزون](https://github.com/kzon)) +- اضافه شدن توابع `arrayEnumerateDenseRanked` و `arrayEnumerateUniqRanked` (مثل این است `arrayEnumerateUniq` اما اجازه می دهد تا به عمق مجموعه لحن خوب به داخل مجموعه چند بعدی نگاه). [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([پرولر](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([زویکوف](https://github.com/4ertus2)) + +#### رفع اشکال {#bug-fixes-11} + +- این نسخه همچنین شامل تمام رفع اشکال از 19.3 و 19.1. +- اشکال ثابت در داده های پرش شاخص: سفارش گرانول پس از درج نادرست بود. [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- ثابت `set` نمایه برای `Nullable` و `LowCardinality` ستون ها قبل از اون, `set` نمایه با `Nullable` یا `LowCardinality` ستون منجر به خطا `Data type must be deserialized with multiple streams` در حالی که انتخاب. [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- به درستی تنظیم update\_time کامل `executable` فرهنگ لغت به روز رسانی. [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([تما نویکوف](https://github.com/temoon)) +- رفع نوار پیشرفت شکسته در 19.3. [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([فیلیمونف](https://github.com/filimonov)) +- مقادیر متناقض ثابت از یادداشت دوست داشتنی زمانی که منطقه حافظه کفن شد, در موارد خاص. [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفتار تعریف نشده ثابت در استخر. [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تصادف بسیار نادر با پیام را ثابت کرد `mutex lock failed: Invalid argument` که می تواند رخ دهد زمانی که یک جدول ادغام همزمان با انتخاب کاهش یافته بود. [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([الکس زتلپین](https://github.com/ztlpn)) +- سازگاری درایور اودن بی سی با `LowCardinality` نوع داده. [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([پرولر](https://github.com/proller)) +- FreeBSD: Fixup برای `AIOcontextPool: Found io_event with unknown id 0` خطا. [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([هشدار داده می شود](https://github.com/urgordeadbeef)) +- `system.part_log` جدول ایجاد شد بدون در نظر گرفتن به پیکربندی. [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع رفتار تعریف نشده در `dictIsIn` تابع برای لغت نامه کش. [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([الساپین](https://github.com/alesapin)) +- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([الکس زتلپین](https://github.com/ztlpn)) +- غیر فعال کردن اکسپرس به طور پیش فرض تا زمانی که ما خود را دریافت کنید `llvm` تماس با ما و می توانید با تست `clang` و `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([الساپین](https://github.com/alesapin)) +- جلوگیری از `std::terminate` چه زمانی `invalidate_query` برای `clickhouse` منبع فرهنگ لغت خارجی نتیجه اشتباه بازگشته است (خالی یا بیش از یک ردیف یا بیش از یک ستون). موضوع ثابت زمانی که `invalidate_query` هر پنج ثانیه انجام شد بدون در نظر گرفتن به `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- جلوگیری از بن بست زمانی که `invalidate_query` برای یک فرهنگ لغت با `clickhouse` منبع شامل شد `system.dictionaries` جدول یا `Dictionaries` پایگاه (مورد نادر). [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع صلیب با خالی جایی که بپیوندید. [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([زویکوف](https://github.com/4ertus2)) +- پیش فرض ثابت در عملکرد “replicate” هنگامی که استدلال ثابت به تصویب می رسد. [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع عملکرد لامبدا با بهینه ساز پیش فرض. [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([زمستان ژانگ](https://github.com/zhang2014)) +- چندگانه می پیوندد رفع متعدد. [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([زویکوف](https://github.com/4ertus2)) + +#### بهبود {#improvements-3} + +- نام مستعار پشتیبانی در عضویت در بخش ستون جدول سمت راست. [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([زویکوف](https://github.com/4ertus2)) +- نتیجه چند پیوستن نیاز به نام نتیجه درست در زیر مجموعه استفاده می شود. جایگزین نام مستعار تخت با نام منبع در نتیجه. [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([زویکوف](https://github.com/4ertus2)) +- بهبود منطق فشار به پایین برای اظهارات پیوست. [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([ایوان](https://github.com/abyss7)) + +#### بهبود عملکرد {#performance-improvements-3} + +- اکتشافی بهبود یافته از “move to PREWHERE” بهینهسازی. [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- استفاده از جداول مراجعه مناسب است که با استفاده از رابط برنامه کاربردی هش را برای کلید 8 بیتی و 16 بیتی. [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([ایموس پرنده](https://github.com/amosbird)) +- بهبود عملکرد مقایسه رشته. [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پاکسازی صف دی ال در یک موضوع جداگانه توزیع به طوری که کم کردن سرعت حلقه اصلی که پردازش توزیع وظایف دسیدال نیست. [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([الکس زتلپین](https://github.com/ztlpn)) +- چه زمانی `min_bytes_to_use_direct_io` تنظیم شده است 1, هر فایل با حالت اچ باز شد چرا که اندازه داده ها به خواندن گاهی اوقات به اندازه یک بلوک فشرده دست کم گرفت. [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-12} + +- اضافه شدن پشتیبانی برای صدای جرنگ جرنگ-9 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشتباه `__asm__` دستورالعمل ها (دوباره) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([کنستانتین پودشوموک](https://github.com/podshumok)) +- اضافه کردن قابلیت مشخص کردن تنظیمات برای `clickhouse-performance-test` از خط فرمان. [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([الساپین](https://github.com/alesapin)) +- اضافه کردن لغت نامه تست به تست ادغام. [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([الساپین](https://github.com/alesapin)) +- اضافه شده نمایش داده شد از معیار در وب سایت به تست عملکرد خودکار. [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `xxhash.h` در لنز خارجی 4 وجود ندارد زیرا این یک پیاده سازی دقیق است و نمادهای خود را با فضای نام `XXH_NAMESPACE` ماکرو. زمانی که lz4 خارجی xxHash به خارجی بیش از حد و وابستگان به لینک به آن. [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([اوروج دش](https://github.com/orivej)) +- ثابت مورد زمانی که `quantileTiming` تابع جمع را می توان با استدلال نقطه منفی یا شناور نامیده می شود (این رفع تست ریش شدن با ضد عفونی کننده رفتار تعریف نشده). [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تصحیح خطای املایی. [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) +- رفع تلفیقی در مک. [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([ویتالی بارانو](https://github.com/vitlibar)) +- ساخت رفع برای بورس و تنظیمات مختلف ساخت غیر معمول. [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([پرولر](https://github.com/proller)) + +## انتشار کلیک 19.3 {#clickhouse-release-19-3} + +### انتشار کلیک خانه 19.3.9.1, 2019-04-02 {#clickhouse-release-19-3-9-1-2019-04-02} + +#### رفع اشکال {#bug-fixes-12} + +- رفع سقوط در `FULL/RIGHT JOIN` هنگامی که ما در پیوستن به nullable در مقابل نه nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([زویکوف](https://github.com/4ertus2)) +- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) +- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-13} + +- اضافه کردن یک راه برای راه اندازی تاتر-تصویر سرور از یک کاربر سفارشی [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### انتشار کلیک خانه 19.3.7, 2019-03-12 {#clickhouse-release-19-3-7-2019-03-12} + +#### رفع اشکال {#bug-fixes-13} + +- خطا ثابت در \# 3920. این خطا خود را به عنوان فساد کش تصادفی (پیام) نشان می دهد `Unknown codec family code`, `Cannot seek through file`) و segfaults. این اشکال اول به نظر می رسد در نسخه 19.1 و در حال حاضر در نسخه های تا به 19.1.10 و 19.3.6. [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.3.6, 2019-03-02 {#clickhouse-release-19-3-6-2019-03-02} + +#### رفع اشکال {#bug-fixes-14} + +- هنگامی که بیش از 1000 موضوع در استخر موضوع وجود دارد, `std::terminate` ممکن است در خروج موضوع اتفاق می افتد. [ازات خوژین](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- در حال حاضر این امکان وجود دارد برای ایجاد `ReplicatedMergeTree*` جداول با نظرات در ستون بدون پیش فرض و جداول با کدک ستون بدون نظر و پیش فرض. همچنین مقایسه کدک ها را رفع کنید. [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([الساپین](https://github.com/alesapin)) +- تصادف ثابت در پیوستن با مجموعه یا تاپل. [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([زویکوف](https://github.com/4ertus2)) +- تصادف ثابت در تاتر-کپی با پیام `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([زویکوف](https://github.com/4ertus2)) +- قطع ثابت در خاموش کردن سرور اگر دستی توزیع مورد استفاده قرار گرفت. [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([الکس زتلپین](https://github.com/ztlpn)) +- تعداد ستون نادرست در پیام خطا در مورد فرمت متن تجزیه برای ستون با تعداد بیشتر از چاپ شد 10. [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-3} + +- ساخت ثابت با اوکس را فعال کنید. [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- حسابداری گسترده و حسابداری یو را بر اساس نسخه شناخته شده خوب به جای هسته ای که وارد شده است فعال کنید. [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([نوارتولومی](https://github.com/nvartolomei)) +- اجازه به جست و خیز تنظیم از رمز و راز.کلیمی, هشدار به جای پرتاب اگر مجموعه ای محدود شکست. [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([پرولر](https://github.com/proller)) +- حذف `inline` برچسب ها از `void readBinary(...)` داخل `Field.cpp`. همچنین با هم ادغام شدند کار برکنار شده `namespace DB` بلاک [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([هکز](https://github.com/hczhcz)) + +### انتشار کلیک خانه 19.3.5, 2019-02-21 {#clickhouse-release-19-3-5-2019-02-21} + +#### رفع اشکال {#bug-fixes-15} + +- اشکال ثابت با پردازش نمایش داده شد قرار دادن قام بزرگ است. [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([الساپین](https://github.com/alesapin)) +- ناسازگاری عقب ثابت با نسخه های قدیمی به دلیل اجرای اشتباه از `send_logs_level` تنظیمات. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ناسازگاری عقب مانده تابع جدول ثابت `remote` معرفی شده با نظرات ستون. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.3.4, 2019-02-16 {#clickhouse-release-19-3-4-2019-02-16} + +#### بهبود {#improvements-4} + +- اندازه شاخص جدول برای محدودیت حافظه در هنگام انجام به حساب نمی `ATTACH TABLE` پرس و جو. اجتناب از احتمال که یک جدول می تواند پس از جدا شدن متصل نمی شود. [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- کمی محدودیت در حداکثر رشته و مجموعه ای اندازه دریافت شده از باغ وحش مطرح شده است. این اجازه می دهد تا برای ادامه کار با افزایش اندازه `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` در باغ وحش. [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اجازه می دهد برای تعمیر ماکت رها حتی اگر در حال حاضر تعداد زیادی از گره ها در صف خود. [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه کردن یک استدلال مورد نیاز برای `SET` شاخص (حداکثر تعداد ردیف های ذخیره شده). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([نیکیتا واسیلیف](https://github.com/nikvas0)) + +#### رفع اشکال {#bug-fixes-16} + +- ثابت `WITH ROLLUP` نتیجه برای گروه های تک `LowCardinality` کلید [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- اشکال ثابت در شاخص مجموعه (حذف گرانول اگر شامل بیش از `max_rows` ردیف). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- بسیاری از رفع بورس ساخت. [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([پرولر](https://github.com/proller)) +- جایگزینی نام مستعار ثابت در نمایش داده شد با زیرخاکی حاوی همان نام مستعار (موضوع [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([زویکوف](https://github.com/4ertus2)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-4} + +- اضافه کردن قابلیت اجرا `clickhouse-server` برای تست بدون تابعیت در تصویر کارگر بارانداز. [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([واسیلی نمکو](https://github.com/Enmk)) + +### ClickHouse انتشار 19.3.3, 2019-02-13 {#clickhouse-release-19-3-3-2019-02-13} + +#### ویژگی های جدید {#new-features-6} + +- اضافه شدن `KILL MUTATION` بیانیه ای که اجازه می دهد تا از بین بردن جهش است که برای برخی از دلایل گیر کرده است. اضافه شده `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` زمینه به `system.mutations` جدول برای عیب یابی ساده تر. [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([الکس زتلپین](https://github.com/ztlpn)) +- اضافه شدن تابع جمع `entropy` که شانون انتروپی رو محاسبه میکنه [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([کد37](https://github.com/Quid37)) +- توانایی اضافه شده به ارسال نمایش داده شد `INSERT INTO tbl VALUES (....` به سرور بدون تقسیم در `query` و `data` قطعات. [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([الساپین](https://github.com/alesapin)) +- اجرای عمومی `arrayWithConstant` تابع اضافه شد. [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پیادهسازی شده `NOT BETWEEN` اپراتور مقایسه. [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([دیمیتری نوموف](https://github.com/nezed)) +- پیاده سازی `sumMapFiltered` به منظور قادر به محدود کردن تعداد کلید که ارزش خواهد شد خلاصه `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- اضافه شدن پشتیبانی از `Nullable` انواع در `mysql` تابع جدول. [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) +- پشتیبانی از عبارات ثابت دلخواه در `LIMIT` بند بند. [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([جعبه 3](https://github.com/k3box)) +- اضافه شده `topKWeighted` تابع مجموع طول می کشد که استدلال اضافی با (عدد صحیح بدون علامت) وزن. [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([اندرو گولمن](https://github.com/andrewgolman)) +- `StorageJoin` در حال حاضر پشتیبانی `join_any_take_last_row` تنظیم که اجازه می دهد تا جای نوشتن ارزش های موجود از همان کلید. [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([ایموس پرنده](https://github.com/amosbird) +- اضافه شدن تابع `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([ویتالی بارانو](https://github.com/vitlibar)) +- اضافه شده `RowBinaryWithNamesAndTypes` قالب. [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([اولگ و کوزلوک](https://github.com/DarkWanderer)) +- اضافه شده `IPv4` و `IPv6` انواع داده ها. پیاده سازی موثر تر از `IPv*` توابع. [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([واسیلی نمکو](https://github.com/Enmk)) +- اضافه شدن تابع `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([ویتالی بارانو](https://github.com/vitlibar)) +- اضافه شده `Protobuf` فرمت خروجی. [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([ویتالی بارانو](https://github.com/vitlibar)) +- اضافه شده brotli پشتیبانی از HTTP رابط برای واردات داده ها (درج). [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([میخیل](https://github.com/fandyushin)) +- نکات اضافه شده در حالی که کاربر را تایپی در نام تابع و یا نوع در مشتری خط فرمان. [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([نام و نام خانوادگی](https://github.com/danlark1)) +- اضافه شده `Query-Id` به هدر پاسخ قام سرور. [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([میخیل](https://github.com/fandyushin)) + +#### ویژگی های تجربی {#experimental-features-2} + +- اضافه شده `minmax` و `set` داده پرش شاخص برای ادغام جدول موتورهای خانواده. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- تبدیل اضافه شده از `CROSS JOIN` به `INNER JOIN` در صورت امکان. [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([زویکوف](https://github.com/4ertus2)) + +#### رفع اشکال {#bug-fixes-17} + +- ثابت `Not found column` برای ستون های تکراری در `JOIN ON` بخش. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([زویکوف](https://github.com/4ertus2)) +- ساخت `START REPLICATED SENDS` شروع فرمان تکرار می فرستد. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([نوارتولومی](https://github.com/nvartolomei)) +- ثابت توابع مجموع اعدام با `Array(LowCardinality)` بحث کردن. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- رفتار اشتباه ثابت هنگام انجام `INSERT ... SELECT ... FROM file(...)` پرس و جو و فایل است `CSVWithNames` یا `TSVWIthNames` فرمت و ردیف داده برای اولین بار از دست رفته است. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تصادف ثابت در بازنگری فرهنگ لغت اگر فرهنگ لغت در دسترس نیست. این اشکال در 19.1.6 ظاهر شد. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([پرولر](https://github.com/proller)) +- ثابت `ALL JOIN` با تکراری در جدول سمت راست. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([زویکوف](https://github.com/4ertus2)) +- گسل تقسیم بندی ثابت با `use_uncompressed_cache=1` و استثنا با اندازه غیر فشرده اشتباه است. این اشکال در 19.1.6 ظاهر شد. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([الساپین](https://github.com/alesapin)) +- ثابت `compile_expressions` اشکال با مقایسه بزرگ (بیش از مقدمه16) تاریخ. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([الساپین](https://github.com/alesapin)) +- حلقه بی نهایت ثابت در هنگام انتخاب از تابع جدول `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- به طور موقت بهینه سازی پیش فرض برای غیر فعال کردن `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([زمستان ژانگ](https://github.com/zhang2014)) +- ثابت `Illegal instruction` خطا در هنگام استفاده از توابع بازه64 در پردازنده های قدیمی. این خطا تکثیر شده است تنها زمانی که فاحشه خانه با شورای همکاری خلیج فارس وارد شد-8. [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `No message received` خطا در هنگام تعامل با راننده خیال راحت اد بی سی از طریق اتصال. همچنین رفع segfault در هنگام استفاده از MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نتیجه نادرست ثابت زمانی که `Date` و `DateTime` استدلال ها در شاخه های اپراتور شرطی (تابع `if`). مورد عمومی برای عملکرد اضافه شده است `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- لغت نامه کلیک کن در داخل بار `clickhouse` روند. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بن بست ثابت زمانی که `SELECT` از یک جدول با `File` موتور پس از دوباره انجام شد `No such file or directory` خطا. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- شرایط مسابقه ثابت در هنگام انتخاب از `system.tables` ممکن است به `table doesn't exist` خطا. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `clickhouse-client` می توانید در هنگام خروج به طور مرتب داده ها را برای پیشنهادات خط فرمان بارگیری کنید اگر در حالت تعاملی اجرا شود. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال زمانی که اجرای جهش های حاوی `IN` اپراتورها نتایج نادرست تولید می کردند. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([الکس زتلپین](https://github.com/ztlpn)) +- خطا ثابت: اگر یک پایگاه داده با وجود `Dictionary` موتور, تمام لغت نامه مجبور به بارگذاری در هنگام راه اندازی سرور, و اگر یک فرهنگ لغت با منبع کلیک از منبع محلی هاست وجود دارد, فرهنگ لغت نمی تواند بار. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطا ثابت زمانی که سیستم سیاهههای مربوط به تلاش برای ایجاد دوباره در خاموش کردن سرور. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- به درستی نوع مناسب را باز کنید و قفل ها را به درستی مدیریت کنید `joinGet` تابع. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([ایموس پرنده](https://github.com/amosbird)) +- اضافه شده `sumMapWithOverflow` تابع. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- ثابت segfault با `allow_experimental_multiple_joins_emulation`. [52دسی 2 درجه سانتیگراد](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([زویکوف](https://github.com/4ertus2)) +- اشکال ثابت با نادرست `Date` و `DateTime` مقایسه. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([حداکثر](https://github.com/valexey)) +- تست ریش ریش شدن ثابت تحت تعریف نشده رفتار ضد عفونی کننده: اضافه شدن نوع پارامتر را بررسی کنید `quantile*Weighted` خانواده از توابع. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- شرایط مسابقه نادر ثابت در هنگام از بین بردن قطعات داده های قدیمی می تواند با شکست مواجه `File not found` خطا. [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت نصب بسته با گم شده /و غیره/خانه کلیک-سرور / پیکربندی.. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([پرولر](https://github.com/proller)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-5} + +- دبیان بسته بندی: درست /و غیره/کلیک-سرور/لینک پیش پردازش با توجه به پیکربندی. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([پرولر](https://github.com/proller)) +- رفع ساخت های مختلف برای بورس. [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([پرولر](https://github.com/proller)) +- توانایی اضافه شده به ایجاد, پر کردن و رها کردن جداول در اصلح. [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([الساپین](https://github.com/alesapin)) +- اضافه شده یک اسکریپت برای تکراری بررسی شامل. [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- توانایی اضافه شده به اجرا نمایش داده شد توسط شاخص در تست عملکرد. [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([الساپین](https://github.com/alesapin)) +- بسته بندی با علامت اشکال زدایی پیشنهاد می شود نصب شود. [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بازسازی عملکرد-تست. ورود به سیستم بهتر و سیگنال های دست زدن به. [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([الساپین](https://github.com/alesapin)) +- اسناد اضافه شده به ناشناس یاندکس.مجموعه داده های متریکا. [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([الساپین](https://github.com/alesapin)) +- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([الکس زتلپین](https://github.com/ztlpn)) +- اسناد اضافه شده در مورد دو مجموعه داده در اس3. [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([الساپین](https://github.com/alesapin)) +- اضافه شده اسکریپت که ایجاد تغییرات از کشش درخواست توضیحات. [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([کوچتونیکولای](https://github.com/KochetovNicolai)) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- اضافه شده ماژول عروسک خیمه شب بازی برای فاحشه خانه. [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([ماکسیم فدوتف](https://github.com/MaxFedotov)) +- اسناد اضافه شده برای یک گروه از توابع مستند نشده. [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([زمستان ژانگ](https://github.com/zhang2014)) +- بازوی رفع ساخت. [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([پرولر](https://github.com/proller)) ([پرولر](https://github.com/proller)) +- تست فرهنگ لغت در حال حاضر قادر به اجرا از `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([پرولر](https://github.com/proller)) +- حالا `/etc/ssl` به عنوان دایرکتوری پیش فرض با گواهی اس اس ال استفاده می شود. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شده چک کردن اس اس اس و توضیحات در شروع. [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([ایگر](https://github.com/igron99)) +- اسکریپت اینیت سرور صبر کنید تا شروع. [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([پرولر](https://github.com/proller)) + +#### تغییرات ناسازگار به عقب {#backward-incompatible-changes-1} + +- حذف شد `allow_experimental_low_cardinality_type` تنظیمات. `LowCardinality` انواع داده ها تولید می شوند. [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- کاهش اندازه علامت کش و اندازه کش غیر فشرده بر این اساس به مقدار حافظه در دسترس است. [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([لوپاتین کنستانتین](https://github.com/k-lopatin) +- کلمه کلیدی اضافه شده است `INDEX` داخل `CREATE TABLE` پرس و جو. یک ستون با نام `index` باید با پشتی یا نقل قول های دوگانه نقل قول شود: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([نیکیتا واسیلیف](https://github.com/nikvas0)) +- `sumMap` در حال حاضر نوع نتیجه به جای سرریز ترویج. قدیمی `sumMap` رفتار را می توان با استفاده از `sumMapWithOverflow` تابع. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) + +#### بهبود عملکرد {#performance-improvements-4} + +- `std::sort` جایگزین شده توسط `pdqsort` برای نمایش داده شد بدون `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([اوگنی پراودا](https://github.com/kvinty)) +- در حال حاضر سرور موضوعات استفاده مجدد از استخر موضوع جهانی است. این عملکرد در برخی موارد گوشه تاثیر می گذارد. [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### بهبود {#improvements-5} + +- پیاده سازی پشتیبانی برای بورس. [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([هشدار داده می شود](https://github.com/urgordeadbeef)) +- `SELECT * FROM a JOIN b USING a, b` حالا برگرد `a` و `b` ستون تنها از جدول سمت چپ. [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([زویکوف](https://github.com/4ertus2)) +- اجازه داده شود `-C` گزینه مشتری برای کار به عنوان `-c` انتخاب [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([سیمینسرگی](https://github.com/syominsergey)) +- در حال حاضر گزینه `--password` استفاده بدون ارزش نیاز به رمز عبور از استدین. [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([حداقل صفحه نمایش:](https://github.com/bsd-conqueror)) +- افزود برجسته از unescaped metacharacters در string literals که حاوی `LIKE` عبارات و یا عبارت منظم. [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شده لغو قام به عنوان خوانده شده تنها نمایش داده شد اگر سوکت مشتری از بین می رود. [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([نوارتولومی](https://github.com/nvartolomei)) +- در حال حاضر گزارش سرور پیشرفت برای زنده نگه داشتن اتصالات مشتری. [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([ایوان](https://github.com/abyss7)) +- پیام کمی بهتر با دلیل برای بهینه سازی پرس و جو با `optimize_throw_if_noop` تنظیم را فعال کنید. [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن پشتیبانی از `--version` گزینه ای برای سرور کلیک. [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([لوپاتین کنستانتین](https://github.com/k-lopatin)) +- اضافه شده `--help/-h` گزینه ای برای `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([یوری بارانوف](https://github.com/yurriy)) +- اضافه شدن پشتیبانی برای زیرمجموعه اسکالر با تابع کل نتیجه دولت است. [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) +- بهبود زمان خاموش کردن سرور و تغییر زمان انتظار. [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شدن اطلاعات در مورد تنظیمات \_شروع مجدد به سیستم.کپی و اضافه کردن ورود به سیستم اگر ماکت نمی خواهد سعی کنید برای تبدیل شدن به رهبر. [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([الکس زتلپین](https://github.com/ztlpn)) + +## انتشار کلیک 19.1 {#clickhouse-release-19-1} + +### انتشار کلیک خانه 19.1.14, 2019-03-14 {#clickhouse-release-19-1-14-2019-03-14} + +- خطای ثابت `Column ... queried more than once` که ممکن است اتفاق می افتد اگر تنظیمات `asterisk_left_columns_only` در صورت استفاده به 1 تنظیم می شود `GLOBAL JOIN` با `SELECT *` (مورد نادر). این موضوع در وجود ندارد 19.3 و جدیدتر. [6باک7د8د](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([زویکوف](https://github.com/4ertus2)) + +### انتشار کلیک خانه 19.1.13, 2019-03-12 {#clickhouse-release-19-1-13-2019-03-12} + +این نسخه شامل دقیقا همان مجموعه ای از تکه های به عنوان 19.3.7. + +### انتشار کلیک خانه 19.1.10, 2019-03-03 {#clickhouse-release-19-1-10-2019-03-03} + +این نسخه شامل دقیقا همان مجموعه ای از تکه های به عنوان 19.3.6. + +## انتشار کلیک 19.1 {#clickhouse-release-19-1-1} + +### انتشار کلیک خانه 19.1.9, 2019-02-21 {#clickhouse-release-19-1-9-2019-02-21} + +#### رفع اشکال {#bug-fixes-18} + +- ناسازگاری عقب ثابت با نسخه های قدیمی به دلیل اجرای اشتباه از `send_logs_level` تنظیمات. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ناسازگاری عقب مانده تابع جدول ثابت `remote` معرفی شده با نظرات ستون. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.1.8, 2019-02-16 {#clickhouse-release-19-1-8-2019-02-16} + +#### رفع اشکال {#bug-fixes-19} + +- ثابت نصب بسته با گم شده /و غیره/خانه کلیک-سرور / پیکربندی.. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([پرولر](https://github.com/proller)) + +## انتشار کلیک 19.1 {#clickhouse-release-19-1-2} + +### انتشار کلیک خانه 19.1.7, 2019-02-15 {#clickhouse-release-19-1-7-2019-02-15} + +#### رفع اشکال {#bug-fixes-20} + +- به درستی نوع مناسب را باز کنید و قفل ها را به درستی مدیریت کنید `joinGet` تابع. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([ایموس پرنده](https://github.com/amosbird)) +- خطا ثابت زمانی که سیستم سیاهههای مربوط به تلاش برای ایجاد دوباره در خاموش کردن سرور. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطا ثابت: اگر یک پایگاه داده با وجود `Dictionary` موتور, تمام لغت نامه مجبور به بارگذاری در هنگام راه اندازی سرور, و اگر یک فرهنگ لغت با منبع کلیک از منبع محلی هاست وجود دارد, فرهنگ لغت نمی تواند بار. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال زمانی که اجرای جهش های حاوی `IN` اپراتورها نتایج نادرست تولید می کردند. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([الکس زتلپین](https://github.com/ztlpn)) +- `clickhouse-client` می توانید در هنگام خروج به طور مرتب داده ها را برای پیشنهادات خط فرمان بارگیری کنید اگر در حالت تعاملی اجرا شود. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- شرایط مسابقه ثابت در هنگام انتخاب از `system.tables` ممکن است به `table doesn't exist` خطا. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- بن بست ثابت زمانی که `SELECT` از یک جدول با `File` موتور پس از دوباره انجام شد `No such file or directory` خطا. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت موضوع: لغت نامه خانه کلیک محلی از طریق تی سی پی لود, اما باید در روند بارگذاری. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `No message received` خطا در هنگام تعامل با راننده خیال راحت اد بی سی از طریق اتصال. همچنین رفع segfault در هنگام استفاده از MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- به طور موقت بهینه سازی پیش فرض برای غیر فعال کردن `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([زمستان ژانگ](https://github.com/zhang2014)) +- حلقه بی نهایت ثابت در هنگام انتخاب از تابع جدول `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت `compile_expressions` اشکال با مقایسه بزرگ (بیش از مقدمه16) تاریخ. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([الساپین](https://github.com/alesapin)) +- گسل تقسیم بندی ثابت با `uncompressed_cache=1` و استثنا با اندازه غیر فشرده اشتباه است. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([الساپین](https://github.com/alesapin)) +- ثابت `ALL JOIN` با تکراری در جدول سمت راست. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([زویکوف](https://github.com/4ertus2)) +- رفتار اشتباه ثابت هنگام انجام `INSERT ... SELECT ... FROM file(...)` پرس و جو و فایل است `CSVWithNames` یا `TSVWIthNames` فرمت و ردیف داده برای اولین بار از دست رفته است. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت توابع مجموع اعدام با `Array(LowCardinality)` بحث کردن. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- دبیان بسته بندی: درست /و غیره/کلیک-سرور/لینک پیش پردازش با توجه به پیکربندی. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([پرولر](https://github.com/proller)) +- تست ریش ریش شدن ثابت تحت تعریف نشده رفتار ضد عفونی کننده: اضافه شدن نوع پارامتر را بررسی کنید `quantile*Weighted` خانواده از توابع. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ساخت `START REPLICATED SENDS` شروع فرمان تکرار می فرستد. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([نوارتولومی](https://github.com/nvartolomei)) +- ثابت `Not found column` برای ستون های تکراری در عضویت در بخش. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([زویکوف](https://github.com/4ertus2)) +- حالا `/etc/ssl` به عنوان دایرکتوری پیش فرض با گواهی اس اس ال استفاده می شود. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- تصادف ثابت در بازنگری فرهنگ لغت اگر فرهنگ لغت در دسترس نیست. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([پرولر](https://github.com/proller)) +- اشکال ثابت با نادرست `Date` و `DateTime` مقایسه. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([حداکثر](https://github.com/valexey)) +- نتیجه نادرست ثابت زمانی که `Date` و `DateTime` استدلال ها در شاخه های اپراتور شرطی (تابع `if`). مورد عمومی برای عملکرد اضافه شده است `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +### انتشار کلیک خانه 19.1.6, 2019-01-24 {#clickhouse-release-19-1-6-2019-01-24} + +#### ویژگی های جدید {#new-features-7} + +- سفارشی در هر کدک های فشرده سازی ستون برای جداول. [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([الساپین](https://github.com/alesapin), [زمستان ژانگ](https://github.com/zhang2014), [انتولی](https://github.com/Sindbag)) +- اضافه شده کدک فشرده سازی `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([الساپین](https://github.com/alesapin)) +- اجازه دادن به `ALTER` کدک های فشرده سازی. [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([الساپین](https://github.com/alesapin)) +- اضافه شدن توابع `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` برای سازگاری استاندارد گذاشتن. [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([ایوان بلینکو](https://github.com/blinkov)) +- پشتیبانی از نوشتن در `HDFS` جداول و `hdfs` تابع جدول. [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([الساپین](https://github.com/alesapin)) +- اضافه شدن توابع به جستجو برای رشته ثابت متعدد از انبار کاه بزرگ: `multiPosition`, `multiSearch` ,`firstMatch` همچنین با `-UTF8`, `-CaseInsensitive` و `-CaseInsensitiveUTF8` انواع. [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([نام و نام خانوادگی](https://github.com/danlark1)) +- هرس کردن تکه های استفاده نشده اگر `SELECT` فیلترهای پرس و جو با کلید شاردینگ (تنظیم `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([گلب کنتروف](https://github.com/kanterov), [ایوان](https://github.com/abyss7)) +- اجازه داده شود `Kafka` موتور به چشم پوشی از برخی از تعدادی از خطاهای تجزیه در هر بلوک. [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([ایوان](https://github.com/abyss7)) +- اضافه شدن پشتیبانی برای `CatBoost` multiclass مدل های ارزیابی. تابع `modelEvaluate` را برمی گرداند تاپل با پیش بینی های خام در هر کلاس برای مدل های چند طبقه. `libcatboostmodel.so` باید با ساخته شده است [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- اضافه شدن توابع `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([بوریس گرانویو](https://github.com/bgranvea)) +- اضافه شده توابع هش کردن `xxHash64` و `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([فیلیمونف](https://github.com/filimonov)) +- اضافه شده `gccMurmurHash` تابع هش (شورای همکاری خلیج فارس طعم زمزمه هش) که با استفاده از همان دانه هش به عنوان [شورای همکاری خلیج فارس](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([بستنی و مغز گردو](https://github.com/sundy-li)) +- اضافه شده توابع هش کردن `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([شانگشویی365](https://github.com/shangshujie365)) +- تابع جدول اضافه شده است `remoteSecure`. تابع به عنوان کار می کند `remote`, اما با استفاده از اتصال امن. [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([پرولر](https://github.com/proller)) + +#### ویژگی های تجربی {#experimental-features-3} + +- اضافه شده چند تقلید می پیوندد (`allow_experimental_multiple_joins_emulation` تنظیمات). [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([زویکوف](https://github.com/4ertus2)) + +#### رفع اشکال {#bug-fixes-21} + +- ساخت `compiled_expression_cache_size` تنظیم به طور پیش فرض برای کاهش مصرف حافظه محدود شده است. [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([الساپین](https://github.com/alesapin)) +- رفع اشکال که منجر به hangups در تاپیک های که انجام تغییر از تکرار جداول و در این موضوع است که به روز رسانی پیکربندی از باغ وحش. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([الکس زتلپین](https://github.com/ztlpn)) +- ثابت شرایط مسابقه در هنگام اجرای یک کار تغییر توزیع شده است. شرایط مسابقه منجر به بیش از یک ماکت در تلاش برای اجرای کار و همه کپی به جز یک شکست با یک خطای باغ وحش. [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([الکس زتلپین](https://github.com/ztlpn)) +- رفع اشکال زمانی که `from_zk` عناصر پیکربندی شد پس از یک درخواست به باغ وحش به پایان رسیده است تجدید نیست. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([الکس زتلپین](https://github.com/ztlpn)) +- رفع اشکال با پیشوند اشتباه برای ماسک زیر شبکه ایپسویچ. [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([الساپین](https://github.com/alesapin)) +- تصادف ثابت (`std::terminate`) در موارد نادر زمانی که یک موضوع جدید نمی تواند به دلیل منابع خسته ایجاد شود. [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال زمانی که در `remote` اجرای تابع جدول زمانی که محدودیت اشتباه برای در مورد استفاده قرار گرفت `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([الساپین](https://github.com/alesapin)) +- رفع نشت از سوکت نتلینک. در یک استخر قرار گرفتند که هرگز حذف نشدند و سوکت های جدید در ابتدای یک موضوع جدید ایجاد شد زمانی که همه سوکت های فعلی استفاده می شد. [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([الکس زتلپین](https://github.com/ztlpn)) +- رفع اشکال با بسته شدن `/proc/self/fd` دایرکتوری زودتر از همه پزشکان از خوانده شد `/proc` پس از مجبور `odbc-bridge` مانع عبور. [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([الساپین](https://github.com/alesapin)) +- رشته ثابت به تبدیل یکنواخت کهنه در مورد رشته استفاده در کلید اولیه. [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([زمستان ژانگ](https://github.com/zhang2014)) +- خطا ثابت در محاسبه یکنواختی تابع تبدیل عدد صحیح. [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت segfault در `arrayEnumerateUniq`, `arrayEnumerateDense` توابع در مورد برخی از استدلال نامعتبر. [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- در حال بارگذاری [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([ایموس پرنده](https://github.com/amosbird)) +- پیش فرض ثابت در توابع `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطای ثابت: توابع `round`, `floor`, `trunc`, `ceil` ممکن است نتیجه جعلی بازگشت زمانی که در استدلال صحیح و مقیاس بزرگ منفی اجرا. [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- رفع اشکال ناشی از ‘kill query sync’ که منجر به روگرفت هسته. [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([شناسه بسته:](https://github.com/fancyqlx)) +- رفع اشکال با تاخیر طولانی پس از صف تکرار خالی است. [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([الساپین](https://github.com/alesapin)) +- استفاده از حافظه بیش از حد ثابت در صورت قرار دادن به جدول با `LowCardinality` کلید اصلی. [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- ثابت `LowCardinality` ترتیب برای `Native` فرمت در مورد مجموعه های خالی. [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- نتیجه نادرست ثابت در حالی که با استفاده از مجزا توسط ستون عددی کم حافظه. [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- تجمع تخصصی ثابت با کلید کمکاری (در صورتی که `compile` تنظیم فعال است). [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- رفع کاربر و رمز عبور حمل و نقل برای جداول تکرار نمایش داده شد. [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([الساپین](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) +- ثابت شرایط مسابقه بسیار نادر است که می تواند رخ دهد که لیست جداول در پایگاه داده فرهنگ لغت در حالی که بارگذاری لغت نامه. [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- نتیجه نادرست ثابت زمانی که با رولپ یا مکعب مورد استفاده قرار گرفت. [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([سام چو](https://github.com/reflection)) +- نام مستعار ستون ثابت برای پرس و جو با `JOIN ON` نحو و جداول توزیع. [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([زمستان ژانگ](https://github.com/zhang2014)) +- خطای ثابت در اجرای داخلی `quantileTDigest` (که توسط آرتم Vakhrushev). این خطا اتفاق هرگز در ClickHouse و مناسب بود تنها برای کسانی که استفاده از ClickHouse کدهای به عنوان یک کتابخانه به طور مستقیم. [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### بهبود {#improvements-6} + +- پشتیبانی از `IF NOT EXISTS` داخل `ALTER TABLE ADD COLUMN` بیانیه همراه با `IF EXISTS` داخل `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([بوریس گرانویو](https://github.com/bgranvea)) +- تابع `parseDateTimeBestEffort`: پشتیبانی از فرمت های `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` و مشابه. [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- `CapnProtoInputStream` در حال حاضر سازه های ناهموار ممکن میکند پشتیبانی می کند. [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) +- بهبود قابلیت استفاده: اضافه شدن چک که روند سرور از صاحب دایرکتوری داده ها شروع شده است. اجازه ندهید سرور را از ریشه شروع کنید اگر داده ها متعلق به کاربر غیر ریشه باشد. [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([سرگی-وی-گالتسف](https://github.com/sergey-v-galtsev)) +- منطق بهتر از چک کردن ستون های مورد نیاز در طول تجزیه و تحلیل نمایش داده شد با می پیوندد. [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([زویکوف](https://github.com/4ertus2)) +- تعداد اتصالات در صورت تعداد زیادی از جداول توزیع شده در یک سرور کاهش یافته است. [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([زمستان ژانگ](https://github.com/zhang2014)) +- بالغ پشتیبانی ردیف برای `WITH TOTALS` پرس و جو برای راننده او بی سی. [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([مکسیم کریتکی](https://github.com/nightweb)) +- مجاز به استفاده `Enum`به عنوان اعداد صحیح در داخل اگر تابع. [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([ایوان](https://github.com/abyss7)) +- اضافه شده `low_cardinality_allow_in_native_format` تنظیمات. اگر غیر فعال, استفاده نکنید `LowCadrinality` نوع در `Native` قالب. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([کوچتونیکولای](https://github.com/KochetovNicolai)) +- حذف برخی از اجسام کار برکنار شده از عبارات وارد کش به کاهش استفاده از حافظه است. [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([الساپین](https://github.com/alesapin)) +- اضافه کردن چک که `SET send_logs_level = 'value'` پرس و جو قبول ارزش مناسب. [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([سابین ماکسیم](https://github.com/s-mx)) +- بررسی نوع داده ثابت در توابع تبدیل نوع. [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([زمستان ژانگ](https://github.com/zhang2014)) + +#### بهبود عملکرد {#performance-improvements-5} + +- افزودن تنظیمات ادغام `use_minimalistic_part_header_in_zookeeper`. اگر فعال, جداول تکرار خواهد ابرداده بخش جمع و جور در یک قسمت صفر ذخیره. این به طور چشمگیری می تواند به کاهش اندازه عکس فوری باغ وحش (به خصوص اگر جداول یک مقدار زیادی از ستون). توجه داشته باشید که پس از فعال کردن این تنظیمات شما قادر نخواهد بود به جمع و جور کردن به نسخه ای که پشتیبانی نمی کند. [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([الکس زتلپین](https://github.com/ztlpn)) +- اضافه کردن یک پیاده سازی مبتنی بر وزارت امور خارجه برای توابع `sequenceMatch` و `sequenceCount` در مورد الگوی حاوی زمان نیست. [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- بهبود عملکرد برای اعداد صحیح ترتیب. [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([ایموس پرنده](https://github.com/amosbird)) +- صفر پدرارهای چپ به طوری که -1 عنصر همیشه معتبر و صفر است. این برای محاسبه بدون شاخه از شیپور خاموشی استفاده می شود. [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([ایموس پرنده](https://github.com/amosbird)) +- واگردانی `jemalloc` نسخه که منجر به تخریب عملکرد. [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([الکسی میلویدو](https://github.com/alexey-milovidov)) + +#### تغییرات ناسازگار به عقب {#backward-incompatible-changes-2} + +- حذف ویژگی مستند نشده است `ALTER MODIFY PRIMARY KEY` چرا که توسط جایگزین شد `ALTER MODIFY ORDER BY` فرمان. [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([الکس زتلپین](https://github.com/ztlpn)) +- تابع حذف شده `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- منع استفاده از زیرکورهای اسکالر با نتیجه نوع `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([ایوان](https://github.com/abyss7)) + +#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-6} + +- اضافه شدن پشتیبانی برای پاور (`ppc64le`) ساختن . [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([نام و نام خانوادگی](https://github.com/danlark1)) +- تست های عملکردی نفرت انگیز بر روی مجموعه داده های عمومی در دسترس اجرا. [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- خطا ثابت زمانی که سرور نمی تواند با شروع `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` پیام در داکر یا سیستم-خوانده. [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- به روز شده `rdkafka` کتابخانه به 1. 0. 0-ارک5. کپکافکا مورد استفاده به جای رابط ج خام. [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([ایوان](https://github.com/abyss7)) +- به روز شده `mariadb-client` کتابخونه. ثابت یکی از مشکلات پیدا شده توسط اوبسان. [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- برخی از رفع برای اوبسان ایجاد. [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شده در هر مرتکب اجرا می شود از تست با ساخت اوبان. +- اضافه شده در هر مرتکب اجرا می شود از پوس استودیو تجزیه و تحلیل استاتیک می باشد. +- اشکالات ثابت پیدا شده توسط پوس استودیو. [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت glibc مسائل مربوط به سازگاری. [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- انتقال تصاویر کارگر بارانداز به 18.10 و اضافه کردن فایل سازگاری برای چرب \> = 2.28 [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([الساپین](https://github.com/alesapin)) +- اضافه کردن متغیر پاکت اگر کاربر نمی خواهید به دایرکتوری پی ان در سرور تصویر کارگر بارانداز. [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([الساپین](https://github.com/alesapin)) +- فعال بسیاری از هشدارهای از `-Weverything` تو کلانگ فعال شد `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- اضافه شده چند هشدار که تنها در صدای جرنگ جرنگ در دسترس هستند 8. [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- پیوند به `libLLVM` در هنگام استفاده از پیوند مشترک به جای استفاده از لوب های فردی لورم. [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([اوروج دش](https://github.com/orivej)) +- اضافه شده متغیرهای ضد عفونی کننده برای تصاویر تست. [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([الساپین](https://github.com/alesapin)) +- `clickhouse-server` بسته دبیان توصیه خواهد شد `libcap2-bin` بسته برای استفاده `setcap` ابزار برای تنظیم قابلیت های. این اختیاری است. [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- زمان تدوین بهبود, ثابت شامل. [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([پرولر](https://github.com/proller)) +- تست عملکرد اضافه شده برای توابع هش. [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([فیلیمونف](https://github.com/filimonov)) +- وابستگی کتابخانه چرخهای ثابت. [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([پرولر](https://github.com/proller)) +- تلفیقی بهبود یافته با حافظه کم در دسترس است. [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([پرولر](https://github.com/proller)) +- اضافه شدن اسکریپت تست به تکثیر تخریب عملکرد در `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([الکسی میلویدو](https://github.com/alexey-milovidov)) +- ثابت misspells در نظرات و string literals تحت `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([مامان](https://github.com/maiha)) +- غلط املایی ثابت در نظرات. [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([اوگنی پراودا](https://github.com/kvinty)) + +## [تغییرات برای 2018](./2018.md#clickhouse-release-18-16) {#changelog-for-2018} diff --git a/docs/fa/whats-new/changelog/index.md b/docs/fa/whats-new/changelog/index.md new file mode 100644 index 00000000000..28acaeef587 --- /dev/null +++ b/docs/fa/whats-new/changelog/index.md @@ -0,0 +1,9 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u062A\u063A\u06CC\u06CC\u0631\u0627\u062A" +toc_priority: 74 +toc_title: '2020' +--- + +{% include "content/changelog.md" %} diff --git a/docs/fa/whats-new/index.md b/docs/fa/whats-new/index.md new file mode 100644 index 00000000000..2f4484f2bda --- /dev/null +++ b/docs/fa/whats-new/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u0686\u0647 \u062C\u062F\u06CC\u062F" +toc_priority: 72 +--- + + diff --git a/docs/fa/whats-new/roadmap.md b/docs/fa/whats-new/roadmap.md new file mode 100644 index 00000000000..e0e5f93c221 --- /dev/null +++ b/docs/fa/whats-new/roadmap.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 74 +toc_title: "\u0646\u0642\u0634\u0647 \u0631\u0627\u0647" +--- + +# نقشه راه {#roadmap} + +## Q1 2020 {#q1-2020} + +- کنترل دسترسی مبتنی بر نقش + +## Q2 2020 {#q2-2020} + +- ادغام با خدمات احراز هویت خارجی +- استخر منابع برای توزیع دقیق تر از ظرفیت خوشه ای بین کاربران + +{## [مقاله اصلی](https://clickhouse.tech/docs/en/roadmap/) ##} diff --git a/docs/fa/whats-new/security-changelog.md b/docs/fa/whats-new/security-changelog.md new file mode 100644 index 00000000000..2b0a0bcf846 --- /dev/null +++ b/docs/fa/whats-new/security-changelog.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 76 +toc_title: "\u062A\u063A\u06CC\u06CC\u0631\u0627\u062A \u0627\u0645\u0646\u06CC\u062A\ + \u06CC" +--- + +## ثابت در ClickHouse انتشار 19.14.3.3, 2019-09-10 {#fixed-in-clickhouse-release-19-14-3-3-2019-09-10} + +### CVE-2019-15024 {#cve-2019-15024} + +Аn attacker that has write access to ZooKeeper and who ican run a custom server available from the network where ClickHouse runs, can create a custom-built malicious server that will act as a ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from the malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. + +اعتبار: الدار زیتوف تیم امنیت اطلاعات یاندکس + +### CVE-2019-16535 {#cve-2019-16535} + +Аn OOB read, OOB write and integer underflow in decompression algorithms can be used to achieve RCE or DoS via native protocol. + +اعتبار: الدار زیتوف تیم امنیت اطلاعات یاندکس + +### CVE-2019-16536 {#cve-2019-16536} + +سرریز پشته منجر به داس را می توان با یک مشتری تصدیق مخرب باعث. + +اعتبار: الدار زیتوف تیم امنیت اطلاعات یاندکس + +## ثابت در ClickHouse انتشار 19.13.6.1, 2019-09-20 {#fixed-in-clickhouse-release-19-13-6-1-2019-09-20} + +### CVE-2019-18657 {#cve-2019-18657} + +تابع جدول `url` در صورت امکان پذیری اجازه مهاجم برای تزریق هدر قام دلخواه در درخواست. + +اعتبار: [نیکیتا تیکومیرو](https://github.com/NSTikhomirov) + +## ثابت در ClickHouse انتشار 18.12.13, 2018-09-10 {#fixed-in-clickhouse-release-18-12-13-2018-09-10} + +### CVE-2018-14672 {#cve-2018-14672} + +توابع برای بارگذاری مدل های ادم کودن و احمق اجازه عبور مسیر و خواندن فایل های دلخواه از طریق پیام های خطا. + +اعتبار: اندری کراسیچکوف از تیم امنیت اطلاعات یاندکس + +## ثابت در ClickHouse انتشار 18.10.3, 2018-08-13 {#fixed-in-clickhouse-release-18-10-3-2018-08-13} + +### CVE-2018-14671 {#cve-2018-14671} + +unixODBC اجازه بارگذاری دلخواه اشیاء مشترک از فایل سیستم است که منجر به اجرای کد از راه دور آسیب پذیری. + +اعتبار: اندری کراسیچکوف و اوگنی سیدوروف از تیم امنیت اطلاعات یاندکس + +## ثابت در ClickHouse انتشار 1.1.54388, 2018-06-28 {#fixed-in-clickhouse-release-1-1-54388-2018-06-28} + +### CVE-2018-14668 {#cve-2018-14668} + +“remote” تابع جدول اجازه نمادهای دلخواه در “user”, “password” و “default\_database” زمینه های که منجر به عبور از پروتکل درخواست حملات جعل. + +اعتبار: اندری کراسیچکوف از تیم امنیت اطلاعات یاندکس + +## ثابت در ClickHouse انتشار 1.1.54390, 2018-07-06 {#fixed-in-clickhouse-release-1-1-54390-2018-07-06} + +### CVE-2018-14669 {#cve-2018-14669} + +کلاینت خروجی زیر کلیک بود “LOAD DATA LOCAL INFILE” قابلیت را فعال کنید که اجازه یک پایگاه داده خروجی زیر مخرب خواندن فایل های دلخواه از سرور کلیک متصل می شود. + +اعتبار: اندری کراسیچکوف و اوگنی سیدوروف از تیم امنیت اطلاعات یاندکس + +## ثابت در ClickHouse انتشار 1.1.54131, 2017-01-10 {#fixed-in-clickhouse-release-1-1-54131-2017-01-10} + +### CVE-2018-14670 {#cve-2018-14670} + +پیکربندی نادرست در بسته دب می تواند به استفاده غیر مجاز از پایگاه داده منجر شود. + +اعتبار: انگلستان National Cyber Security Centre (NCSC) + +{## [مقاله اصلی](https://clickhouse.tech/docs/en/security_changelog/) ##} diff --git a/docs/fa/whats_new/changelog/2017.md b/docs/fa/whats_new/changelog/2017.md deleted file mode 100644 index da41e1828b2..00000000000 --- a/docs/fa/whats_new/changelog/2017.md +++ /dev/null @@ -1,268 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 79 -toc_title: '2017' ---- - -### انتشار کلیک 1.1.54327, 2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} - -این نسخه شامل رفع اشکال برای نسخه قبلی 1.1.54318: - -- اشکال ثابت با شرایط مسابقه ممکن است در تکرار است که می تواند به از دست دادن داده ها منجر شود. این مسئله تاثیر می گذارد نسخه 1.1.54310 و 1.1.54318. اگر شما استفاده از یکی از این نسخه ها با جداول تکرار, به روز رسانی است که به شدت توصیه می شود. این موضوع نشان می دهد در سیاهههای مربوط در پیام های هشدار دهنده مانند `Part ... from own log doesn't exist.` موضوع مربوط است حتی اگر شما این پیام ها در سیاهههای مربوط را نمی بینم. - -### انتشار کلیک 1.1.54318, 2017-11-30 {#clickhouse-release-1-1-54318-2017-11-30} - -این نسخه شامل رفع اشکال برای نسخه های قبلی 1.1.54310: - -- حذف ردیف نادرست ثابت در هنگام ادغام در موتور جمعبندی -- رفع نشت حافظه در موتورهای ادغام سه گانه -- تخریب عملکرد ثابت با درج مکرر در موتورهای ادغام -- ثابت است که شماره بود که باعث صف تکرار برای جلوگیری از در حال اجرا -- چرخش ثابت و بایگانی سیاهههای مربوط به سرور - -### انتشار کلیک 1.1.54310, 2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} - -#### ویژگی های جدید: {#new-features} - -- کلید پارتیشن بندی سفارشی برای خانواده ادغام موتورهای جدول. -- [کافکا](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) موتور جدول. -- اضافه شدن پشتیبانی برای بارگذاری [مانتو](https://catboost.yandex/) مدل ها و استفاده از داده های ذخیره شده در کلیک. -- اضافه شدن پشتیبانی برای مناطق زمانی با شیپور خاموشی غیر عدد صحیح از مجموعه مقالات. -- اضافه شدن پشتیبانی برای عملیات ریاضی با فواصل زمانی. -- طیف وسیعی از ارزش ها برای انواع تاریخ و تاریخ ساعت به سال گسترش 2105. -- اضافه شدن `CREATE MATERIALIZED VIEW x TO y` پرس و جو (مشخص یک جدول موجود برای ذخیره سازی داده ها از یک نمایش محقق). -- اضافه شدن `ATTACH TABLE` پرس و جو بدون استدلال. -- پردازش منطق به صورت تو در تو ستون با نام پایان در نقشه در یک summingmergetree جدول استخراج شد به summap مجموع عملکرد. شما هم اکنون می توانید این ستون ها به صراحت مشخص کنید. -- حداکثر اندازه فرهنگ لغت ایپ تری به ورودی های 128 متری افزایش می یابد. -- اضافه شدن تابع نوع گیرنده. -- اضافه شده تابع جمع مجموع ورود. -- اضافه شدن پشتیبانی از فرمت ورودی ورودی سروان پروتو. -- شما هم اکنون می توانید سطح فشرده سازی سفارشی در هنگام استفاده از الگوریتم زد. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes} - -- ایجاد جداول موقت با موتور غیر از حافظه مجاز نیست. -- ایجاد صریح جداول با مشاهده و یا موتور نمای مادی مجاز نیست. -- در طول ایجاد جدول, یک بررسی جدید تایید می کند که عبارت کلیدی نمونه برداری در کلید اصلی شامل. - -#### رفع اشکال: {#bug-fixes} - -- قطع ثابت زمانی که همزمان به یک جدول توزیع قرار دادن. -- ثابت غیر اتمی اضافه کردن و از بین بردن قطعات در جداول تکرار. -- داده های وارد شده به یک دیدگاه محقق شده در معرض تقسیم غیر ضروری نیست. -- اجرای یک پرس و جو به یک جدول توزیع که ماکت محلی است عقب مانده و کپی از راه دور در دسترس نیست در یک خطا منجر نمی شود. -- کاربران به مجوزهای دسترسی نیاز ندارند `default` پایگاه داده برای ایجاد جداول موقت دیگر. -- ثابت توفنده در هنگام تعیین نوع مجموعه بدون استدلال. -- قطع ثابت زمانی که حجم دیسک حاوی سیاهههای مربوط به سرور کامل است. -- سرریز در تابع تورلتیواکنام برای هفته اول عصر یونیکس ثابت شده است. - -#### بهبود ساخت: {#build-improvements} - -- چندین کتابخانه شخص ثالث (به ویژه کم) به روز شد و تبدیل به دستی دستگاه گوارش. - -### انتشار کلیک 1.1.54304, 2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} - -#### ویژگی های جدید: {#new-features-1} - -- پردازشگر پشتیبانی شده: `tcp_ssl_port` داخل `config.xml` ). - -#### رفع اشکال: {#bug-fixes-1} - -- `ALTER` برای جداول تکرار در حال حاضر تلاش می کند تا شروع به در حال اجرا در اسرع وقت. -- ثابت توفنده در هنگام خواندن داده ها با تنظیم `preferred_block_size_bytes=0.` -- سقوط ثابت از `clickhouse-client` هنگام فشار دادن `Page Down` -- تفسیر صحیح از برخی نمایش داده شد پیچیده با `GLOBAL IN` و `UNION ALL` -- `FREEZE PARTITION` همیشه از نظر عام کار می کند در حال حاضر. -- درخواست پست خالی در حال حاضر پاسخ با کد بازگشت 411. -- خطاهای تفسیر ثابت برای عبارات مانند `CAST(1 AS Nullable(UInt8)).` -- ثابت خطا در هنگام خواندن `Array(Nullable(String))` ستون از `MergeTree` میز -- ثابت توفنده زمانی که نمایش داده شد تجزیه مانند `SELECT dummy AS dummy, dummy AS b` -- کاربران به درستی با نامعتبر به روز شد `users.xml` -- دست زدن درست زمانی که یک فرهنگ لغت اجرایی یک کد پاسخ غیر صفر می گرداند. - -### انتشار کلیک 1.1.54292, 2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} - -#### ویژگی های جدید: {#new-features-2} - -- اضافه شدن `pointInPolygon` تابع برای کار با مختصات در یک هواپیما مختصات. -- اضافه شدن `sumMap` تابع جمع برای محاسبه مجموع ارریس, شبیه به `SummingMergeTree`. -- اضافه شدن `trunc` تابع. بهبود عملکرد توابع گرد کردن (`round`, `floor`, `ceil`, `roundToExp2`) و اصلاح منطق چگونه کار می کنند. منطق را تغییر داد `roundToExp2` تابع برای کسر و اعداد منفی. -- این clickhouse فایل اجرایی است که در حال حاضر کمتر وابسته به libc نسخه. همان فایل اجرایی کلیک می تواند بر روی طیف گسترده ای از سیستم های لینوکس اجرا شود. هنوز وابستگی وجود دارد که با استفاده از نمایش داده شد وارد (با تنظیم `compile = 1` , است که به طور پیش فرض استفاده نمی شود). -- کاهش زمان مورد نیاز برای تدوین پویا از نمایش داده شد. - -#### رفع اشکال: {#bug-fixes-2} - -- ثابت خطا که گاهی اوقات تولید `part ... intersects previous part` پیام ها و قوام ماکت ضعیف. -- رفع خطا که باعث سرور به قفل کردن اگر باغ وحش در طول خاموش کردن در دسترس نیست. -- حذف ورود به سیستم بیش از حد در هنگام بازگرداندن کپی. -- ثابت خطا در اتحادیه تمام اجرای. -- ثابت خطا در تابع الحاق که در صورتی که ستون اول در یک بلوک رخ داده است نوع مجموعه ای. -- پیشرفت در حال حاضر به درستی در سیستم نمایش داده می شود.ادغام جدول. - -### انتشار کلیک 1.1.54289, 2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} - -#### ویژگی های جدید: {#new-features-3} - -- `SYSTEM` نمایش داده شد برای مدیریت سرور: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. -- اضافه شدن توابع برای کار با ارریس: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. -- اضافه شده `root` و `identity` پارامترهای پیکربندی باغ وحش. این اجازه می دهد تا شما را به منزوی کردن کاربران فردی در خوشه باغ وحش است. -- اضافه شده توابع مجموع `groupBitAnd`, `groupBitOr` و `groupBitXor` (برای سازگاری, همچنین تحت نام در دسترس هستند `BIT_AND`, `BIT_OR` و `BIT_XOR`). -- لغت نامه های خارجی را می توان از خروجی زیر با مشخص کردن یک سوکت در سیستم فایل لود می شود. -- خارجی دیکشنری می توان از mysql بیش از ssl (`ssl_cert`, `ssl_key`, `ssl_ca` پارامترهای). -- اضافه شدن `max_network_bandwidth_for_user` تنظیم برای محدود کردن استفاده از پهنای باند کلی برای نمایش داده شد در هر کاربر. -- پشتیبانی از `DROP TABLE` برای جداول موقت. -- پشتیبانی برای خواندن `DateTime` مقادیر در قالب برچسب زمان یونیکس از `CSV` و `JSONEachRow` فرمتها. -- تاخیر کپی در نمایش داده شد توزیع در حال حاضر به طور پیش فرض حذف شدند (حد پیش فرض است 5 دقیقه). -- قفل فیفو در طول تغییر استفاده می شود: پرس و جو را تغییر دهید به طور نامحدود برای نمایش داده شد به طور مداوم در حال اجرا مسدود شده است. -- گزینه ای برای تنظیم `umask` در فایل پیکربندی. -- بهبود عملکرد برای نمایش داده شد با `DISTINCT` . - -#### رفع اشکال: {#bug-fixes-3} - -- بهبود فرآیند برای حذف پیر گره ها در باغ وحش. قبلا, گره های قدیمی گاهی اوقات نمی حذف اگر درج بسیار مکرر وجود دارد, که باعث سرور به کند به تعطیل, در میان چیزهای دیگر. -- تصادفی ثابت در هنگام انتخاب میزبان برای اتصال به باغ وحش. -- رفع محرومیت از عقب انداختن کپی در نمایش داده شد توزیع اگر ماکت جایل هاست است. -- خطایی را که یک بخش داده در یک `ReplicatedMergeTree` جدول را می توان پس از در حال اجرا شکسته `ALTER MODIFY` بر روی یک عنصر در یک `Nested` ساختار. -- رفع خطا که می تواند پرس و جو را انتخاب کنید به باعث “hang”. -- بهبود نمایش داده شد توزیع شده است. -- پرس و جو را ثابت کرد `CREATE TABLE ... AS `. -- حل و فصل بن بست در `ALTER ... CLEAR COLUMN IN PARTITION` پرسوجو برای `Buffer` میز -- مقدار پیشفرض نامعتبر را ثابت کرد `Enum` بازدید کنندگان (0 به جای حداقل) در هنگام استفاده از `JSONEachRow` و `TSKV` فرمتها. -- حل و فصل ظاهر فرایندهای زامبی در هنگام استفاده از یک فرهنگ لغت با `executable` منبع. -- ثابت segfault برای سر پرس و جو. - -#### گردش کار بهبود یافته برای توسعه و مونتاژ تاتر: {#improved-workflow-for-developing-and-assembling-clickhouse} - -- شما می توانید استفاده کنید `pbuilder` برای ساخت فاحشه خانه. -- شما می توانید استفاده کنید `libc++` به جای `libstdc++` برای ایجاد بر روی لینوکس. -- دستورالعمل های اضافه شده برای استفاده از ابزار تجزیه و تحلیل کد استاتیک: `Coverage`, `clang-tidy`, `cppcheck`. - -#### لطفا توجه داشته باشید در هنگام به روز رسانی: {#please-note-when-upgrading} - -- در حال حاضر یک مقدار پیش فرض بالاتر برای تنظیم ادغام وجود دارد `max_bytes_to_merge_at_max_space_in_pool` (حداکثر اندازه کل قطعات داده به ادغام در بایت): از 100 دستگاه گوارش به 150 دستگاه گوارش افزایش یافته است. این ممکن است در ادغام بزرگ در حال اجرا پس از ارتقا سرور منجر, که می تواند افزایش بار بر روی زیر سیستم دیسک باعث. اگر فضای رایگان موجود بر روی سرور کمتر از دو برابر مقدار کل ادغام که در حال اجرا هستند, این باعث می شود همه ادغام دیگر برای جلوگیری از در حال اجرا, از جمله ادغام قطعات داده های کوچک. در نتیجه, قرار دادن نمایش داده شد با پیام شکست مواجه خواهد شد “Merges are processing significantly slower than inserts.” استفاده از `SELECT * FROM system.merges` پرس و جو برای نظارت بر وضعیت. شما همچنین می توانید بررسی کنید `DiskSpaceReservedForMerge` متریک در `system.metrics` جدول, و یا در گرافیت. شما لازم نیست برای انجام هر کاری برای رفع این مشکل خود را هنگامی که ادغام بزرگ پایان حل و فصل خواهد شد. اگر شما این غیر قابل قبول, شما می توانید مقدار قبلی برای بازگرداندن `max_bytes_to_merge_at_max_space_in_pool` تنظیمات. برای انجام این کار به بخش در پیکربندی.تنظیم ``` ``107374182400 ``` و راه اندازی مجدد سرور. - -### انتشار کلیک 1.1.54284, 2017-08-29 {#clickhouse-release-1-1-54284-2017-08-29} - -- این یک نسخه رفع اشکال برای نسخه 1.1.54282 قبلی است. این رفع نشت در دایرکتوری قطعات در باغ وحش. - -### انتشار کلیک 1.1.54282, 2017-08-23 {#clickhouse-release-1-1-54282-2017-08-23} - -این نسخه شامل رفع اشکال برای نسخه قبلی 1.1.54276: - -- ثابت `DB::Exception: Assertion violation: !_path.empty()` هنگام قرار دادن به یک جدول توزیع شده. -- تجزیه ثابت در هنگام قرار دادن در فرمت مربوط به حوزه علمیه اگر داده های ورودی با شروع می شود. -- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). - -### انتشار کلیک 1.1.54276, 2017-08-16 {#clickhouse-release-1-1-54276-2017-08-16} - -#### ویژگی های جدید: {#new-features-4} - -- اضافه شده اختیاری با بخش برای پرس و جو را انتخاب کنید. به عنوان مثال پرس و جو: `WITH 1+1 AS a SELECT a, a*a` -- درج را می توان همزمان در یک جدول توزیع انجام: خوب است تنها پس از بازگشت تمام داده ها بر روی تمام خرده ریز را نجات داد. این است که با تنظیم فعال می شود -- اضافه شده نوع داده شناسه برای کار با شناسه 16 بایت. -- نام مستعار اضافه شده از کاراکتر, شناور و انواع دیگر برای سازگاری با تابلو فرش. -- اضافه شده توابع toyyyymm, toyyyymmdd و toyyyymmddhhmmss برای تبدیل زمان به اعداد. -- شما می توانید از نشانی های اینترنتی (همراه با نام میزبان) برای شناسایی سرورها برای نمایش داده شد های هوشمند خوشه ای استفاده کنید. -- اضافه شدن پشتیبانی برای استدلال غیر ثابت و شیپور خاموشی منفی در تابع `substring(str, pos, len).` -- اضافه شدن پارامتر حداکثر `groupArray(max_size)(column)` عملکرد کلی و عملکرد خود را بهینه سازی کرد. - -#### تغییرات اصلی: {#main-changes} - -- بهبود امنیت: تمام فایل های سرور با مجوز 0640 ایجاد می شوند (می توانند از طریق تغییر کنند پارامتر پیکربندی). -- پیام های خطا بهبود یافته برای نمایش داده شد با نحو نامعتبر است. -- به طور قابل توجهی کاهش مصرف حافظه و بهبود عملکرد در هنگام ادغام بخش های زیادی از داده های ادغام. -- به طور قابل توجهی افزایش عملکرد ادغام داده ها برای موتور جایگزین. -- عملکرد بهبود یافته برای درج ناهمزمان از یک جدول توزیع شده با ترکیب درج منبع های متعدد. برای فعال کردن این قابلیت از تنظیمات پخش شده \_ تنظیم کننده \_منیتور\_برش\_برنده=1 استفاده کنید. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-1} - -- تغییر فرمت باینری از کشورهای جمع `groupArray(array_column)` توابع برای ارریس. - -#### لیست کامل تغییرات: {#complete-list-of-changes} - -- اضافه شدن `output_format_json_quote_denormals` تنظیمات, را قادر می سازد خروجی نان و ارزشهای جبهه ملی در فرمت جانسون. -- تخصیص جریان بهینه شده در هنگام خواندن از یک جدول توزیع شده است. -- تنظیمات را می توان در حالت فقط خواندنی پیکربندی در صورتی که ارزش تغییر نمی کند. -- اضافه شده توانایی برای بازیابی غیر صحیح گرانول از mergetree موتور به منظور دیدار با محدودیت در اندازه بلوک مشخص شده در preferred\_block\_size\_bytes تنظیم. هدف این است که برای کاهش مصرف رم و افزایش محل کش در هنگام پردازش نمایش داده شد از جداول با ستون های بزرگ. -- استفاده موثر از شاخص هایی که حاوی عبارات هستند `toStartOfHour(x)` برای شرایطی مانند `toStartOfHour(x) op сonstexpr.` -- اضافه شدن تنظیمات جدید برای mergetree موتورهای (به merge\_tree بخش در config.شمع): - - replicated\_deduplication\_window\_seconds مجموعه تعدادی از ثانیه های مجاز برای deduplicating درج در تکرار جداول. - - پاک کردن \_خروج \_پیروید تنظیم میکند که چگونه اغلب شروع به پاکسازی برای حذف اطلاعات منسوخ شده میکند. - - از تبدیل شدن به رهبر (و اختصاص ادغام) می توانید یک کپی از تبدیل شدن به رهبر جلوگیری کنید. -- پاکسازی شتاب به حذف اطلاعات منسوخ شده از باغ وحش. -- بهبود و رفع چندگانه برای نمایش داده شد دسته ای دی ال. از علاقه خاص است که تنظیم جدید distributed\_ddl\_task\_timeout که محدودیت زمان انتظار برای پاسخ از سرور در خوشه. اگر یک درخواست دی ال شده است در تمام میزبان انجام نشده است, پاسخ حاوی یک خطا ایست و یک درخواست خواهد شد در حالت کالاهای کابل اجرا. -- صفحه نمایش بهبود یافته از ردیابی پشته در سیاهههای مربوط به سرور. -- اضافه شدن “none” ارزش روش فشرده سازی. -- شما می توانید بخش های مختلف \_تنفورد کامل در پیکربندی استفاده کنید.. -- ممکن است که به اتصال به خروجی زیر را از طریق یک سوکت در سیستم فایل. -- سیستمجدول قطعات دارای یک ستون جدید با اطلاعات در مورد اندازه علامت, در بایت. - -#### رفع اشکال: {#bug-fixes-4} - -- جداول توزیع با استفاده از یک جدول ادغام در حال حاضر به درستی برای پرس و جو را انتخاب کنید با یک شرط در کار `_table` رشته. -- در هنگام چک کردن قطعات داده ها یک وضعیت مسابقه نادر در تکرار می شود. -- انجماد ممکن ثابت در “leader election” هنگام شروع یک سرور. -- این max\_replica\_delay\_for\_distributed\_queries تنظیم نادیده گرفته شد که با استفاده از یک محلی ماکت از منبع داده. این ثابت شده است. -- رفتار نادرست ثابت `ALTER TABLE CLEAR COLUMN IN PARTITION` هنگامی که تلاش برای تمیز کردن یک ستون غیر موجود. -- ثابت یک استثنا در تابع چندف در هنگام استفاده از مجموعه های خالی و یا رشته. -- تخصیص حافظه بیش از حد ثابت هنگام فراخوانی فرمت بومی. -- ثابت نادرست خودکار به روز رسانی از لغت نامه سه. -- ثابت یک استثنا زمانی که در حال اجرا نمایش داده شد با یک گروه بند از یک جدول ادغام در هنگام استفاده از نمونه. -- تصادف گروهی با استفاده از توزیع شده \_اگزا\_موری\_افلیتی کمبود=1 را ثابت کرد. -- حالا شما می توانید پایگاه داده را مشخص کنید.جدول در سمت راست در و پیوستن. -- بیش از حد بسیاری از موضوعات برای تجمع موازی مورد استفاده قرار گرفت. این ثابت شده است. -- ثابت چگونه “if” تابع با استدلال رشته کار می کند. -- انتخاب به اشتباه از یک جدول توزیع برای خرده ریز با وزن کار 0. این ثابت شده است. -- در حال اجرا `CREATE VIEW IF EXISTS no longer causes crashes.` -- رفتار نادرست ثابت در هنگام وارد کردن \_فصل\_سک\_کنون\_فیلدهای ورودی = 1 تنظیم شده است و اعداد منفی وجود دارد. -- ثابت یک حلقه بی نهایت در `dictGetHierarchy()` تابع در صورتی که برخی از داده های نامعتبر در فرهنگ لغت وجود دارد. -- ثابت `Syntax error: unexpected (...)` خطاها هنگامی که در حال اجرا نمایش داده شد توزیع شده با کارخانه های فرعی در یک در و یا پیوستن بند و ادغام جداول. -- ثابت تفسیر نادرست از پرس و جو را انتخاب کنید از جداول فرهنگ لغت. -- ثابت “Cannot mremap” خطا در هنگام استفاده از بند در و پیوستن به بند با بیش از 2 میلیارد عنصر. -- عدم موفقیت برای لغت نامه با خروجی زیر به عنوان منبع ثابت شده است. - -#### گردش کار بهبود یافته برای توسعه و مونتاژ تاتر: {#improved-workflow-for-developing-and-assembling-clickhouse-1} - -- ساخت را می توان در ارکادیا مونتاژ. -- شما می توانید شورای همکاری خلیج فارس 7 به کامپایل خانه عروسکی استفاده کنید. -- موازی ایجاد شده با استفاده از ccache+distcc سریع تر در حال حاضر. - -### انتشار کلیک 1.1.54245, 2017-07-04 {#clickhouse-release-1-1-54245-2017-07-04} - -#### ویژگی های جدید: {#new-features-5} - -- توزیع دی ال (به عنوان مثال, `CREATE TABLE ON CLUSTER`) -- پرسوجوی تکرار شده `ALTER TABLE CLEAR COLUMN IN PARTITION.` -- موتور برای جداول فرهنگ لغت (دسترسی به داده های فرهنگ لغت در قالب یک جدول). -- موتور پایگاه داده فرهنگ لغت (این نوع از پایگاه داده به طور خودکار دارای جداول فرهنگ لغت در دسترس برای تمام لغت نامه های خارجی متصل). -- شما می توانید برای به روز رسانی به فرهنگ لغت با ارسال یک درخواست به منبع را بررسی کنید. -- نام ستون واجد شرایط -- به نقل از شناسه با استفاده از علامت نقل قول دو. -- در حال بارگذاری -- پرس و جو بهینه سازی برای یک جدول تکرار می تواند نه تنها در رهبر را اجرا کنید. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-2} - -- حذف مجموعه جهانی است. - -#### تغییرات جزیی: {#minor-changes} - -- در حال حاضر پس از یک هشدار باعث شده است, ورود به سیستم چاپ ردیابی پشته کامل. -- تایید تعداد قطعات صدمه دیده/اضافی داده در هنگام راه اندازی (بیش از حد بسیاری مثبت کاذب وجود دارد). - -#### رفع اشکال: {#bug-fixes-5} - -- ثابت اتصال بد “sticking” هنگام قرار دادن به یک جدول توزیع شده. -- جهانی در حال حاضر برای پرس و جو از یک جدول ادغام که به نظر می رسد در یک جدول توزیع کار می کند. -- تعداد نادرست هسته بر روی یک ماشین مجازی موتور محاسبه گوگل تشخیص داده شد. این ثابت شده است. -- تغییرات در چگونه یک منبع اجرایی لغت نامه های خارجی ذخیره شده کار می کند. -- ثابت مقایسه رشته های حاوی شخصیت های پوچ. -- مقایسه زمینه های کلیدی اصلی شناور32 با ثابت ها را ثابت کرد. -- قبلا تخمین نادرست از اندازه یک میدان می تواند منجر به بیش از حد بزرگ تخصیص. -- ثابت تصادف در هنگام پرس و جو یک ستون باطل به یک جدول با استفاده از تغییر اضافه شده است. -- ثابت تصادف در هنگام مرتب سازی توسط یک ستون قابل ابطال, اگر تعداد ردیف کمتر از حد است. -- ثابت سفارش های خرده فروشی متشکل از ارزش تنها ثابت است. -- قبلا, یک جدول تکرار می تواند در حالت نامعتبر پس از یک جدول افت شکست خورده باقی می ماند. -- نام مستعار برای زیرکار اسکالر با نتایج خالی دیگر از دست داده. -- در حال حاضر پرس و جو که تلفیقی استفاده می شود با یک خطا شکست نیست در صورتی که . diff --git a/docs/fa/whats_new/changelog/2018.md b/docs/fa/whats_new/changelog/2018.md deleted file mode 100644 index 65d9b37dfc1..00000000000 --- a/docs/fa/whats_new/changelog/2018.md +++ /dev/null @@ -1,1063 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 78 -toc_title: '2018' ---- - -## انتشار کلیک 18.16 {#clickhouse-release-18-16} - -### انتشار کلیک 18.16.1, 2018-12-21 {#clickhouse-release-18-16-1-2018-12-21} - -#### رفع اشکال: {#bug-fixes} - -- رفع خطا که به مشکلات با به روز رسانی لغت نامه با منبع ان بی سی منجر شده است. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- مجموعه دستگاه گوارش از توابع کل در حال حاضر با ستون های کمکاری کار می کند. [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) - -#### بهبود: {#improvements} - -- اضافه شدن `low_cardinality_allow_in_native_format` تنظیم (فعال به طور پیش فرض). هنگامی که غیر فعال, ستون های کم هزینه خواهد شد به ستون های معمولی برای نمایش داده شد را انتخاب کنید تبدیل و ستون عادی خواهد شد برای قرار دادن نمایش داده شد انتظار می رود. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) - -#### بهبود ساخت: {#build-improvements} - -- رفع برای ایجاد بر روی مکینتاش و بازو. - -### انتشار کلیک 18.16.0, 2018-12-14 {#clickhouse-release-18-16-0-2018-12-14} - -#### ویژگی های جدید: {#new-features} - -- `DEFAULT` عبارات برای زمینه های از دست رفته در هنگام بارگذاری داده ها در فرمت های ورودی نیمه ساختار ارزیابی (`JSONEachRow`, `TSKV`). این ویژگی با فعال `insert_sample_with_metadata` تنظیمات. [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) -- این `ALTER TABLE` پرس و جو در حال حاضر `MODIFY ORDER BY` اقدام برای تغییر کلید مرتب سازی هنگام اضافه کردن یا حذف یک ستون جدول. این برای جداول در مفید است `MergeTree` خانواده ای که انجام کارهای اضافی در هنگام ادغام بر اساس این کلید مرتب سازی, مانند `SummingMergeTree`, `AggregatingMergeTree` و به همین ترتیب. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) -- برای جداول در `MergeTree` خانواده, در حال حاضر شما می توانید یک کلید مرتب سازی های مختلف را مشخص کنید (`ORDER BY`) و شاخص (`PRIMARY KEY`). کلید مرتب سازی می تواند طولانی تر از شاخص باشد. [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) -- اضافه شدن `hdfs` عملکرد جدول و `HDFS` موتور جدول برای واردات و صادرات داده ها به اچ دی اف. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) -- اضافه شدن توابع برای کار بازه64: `base64Encode`, `base64Decode`, `tryBase64Decode`. [الکساندر کرشنینیکف](https://github.com/ClickHouse/ClickHouse/pull/3350) -- حالا شما می توانید یک پارامتر برای پیکربندی دقت استفاده کنید `uniqCombined` تابع جمع (تعداد سلول های بیش از حد جمع را انتخاب کنید). [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) -- اضافه شدن `system.contributors` جدول که شامل نام هر کسی که مرتکب در خانه کلیک ساخته شده. [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) -- اضافه شدن توانایی حذف پارتیشن برای `ALTER TABLE ... FREEZE` پرس و جو به منظور پشتیبان گیری از تمام پارتیشن در یک بار. [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) -- اضافه شده `dictGet` و `dictGetOrDefault` توابع که نیاز به تعیین نوع مقدار بازگشتی ندارند. نوع به طور خودکار از توضیحات فرهنگ لغت تعیین می شود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3564) -- حالا شما می توانید نظرات را برای یک ستون در توضیحات جدول مشخص کنید و با استفاده از تغییر دهید `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) -- خواندن برای پشتیبانی `Join` نوع جداول با کلید های ساده. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3728) -- حالا شما می توانید گزینه های مشخص `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join` و `join_overflow_mode` هنگام ایجاد یک `Join` جدول نوع. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3728) -- اضافه شدن `joinGet` تابع است که اجازه می دهد تا شما را به استفاده از یک `Join` نوع جدول مانند یک فرهنگ لغت. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3728) -- اضافه شدن `partition_key`, `sorting_key`, `primary_key` و `sampling_key` ستونها به `system.tables` جدول به منظور فراهم کردن اطلاعات در مورد کلید های جدول. [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- اضافه شدن `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key` و `is_in_sampling_key` ستونها به `system.columns` جدول [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- اضافه شدن `min_time` و `max_time` ستونها به `system.parts` جدول این ستون ها جمعیت زمانی که کلید پارتیشن بندی بیان متشکل از است `DateTime` ستون ها [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) - -#### رفع اشکال: {#bug-fixes-1} - -- رفع و بهبود عملکرد برای `LowCardinality` نوع داده. `GROUP BY` با استفاده از `LowCardinality(Nullable(...))`. گرفتن ارزش `extremes`. پردازش توابع بالا سفارش. `LEFT ARRAY JOIN`. توزیع شده `GROUP BY`. توابع است که بازگشت `Array`. اعدام `ORDER BY`. نوشتن به `Distributed` جداول (نیکولولو). سازگاری به عقب برای `INSERT` نمایش داده شد از مشتریان قدیمی که پیاده سازی `Native` قانون پشتیبانی از `LowCardinality` برای `JOIN`. بهبود عملکرد در هنگام کار در یک جریان واحد. [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) -- ثابت چگونه `select_sequential_consistency` گزینه کار می کند. قبلا, زمانی که این تنظیم فعال بود, نتیجه ناقص گاهی اوقات پس از شروع به نوشتن به یک پارتیشن جدید بازگردانده شد. [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) -- پایگاه داده ها هنگام اجرای دی ال به درستی مشخص شده است `ON CLUSTER` نمایش داده شد و `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- پایگاه داده ها به درستی برای کارخانه های فرعی در داخل یک نمایش مشخص شده است. [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) -- رفع اشکال در `PREWHERE` با `FINAL` برای `VersionedCollapsingMergeTree`. [7167بد7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) -- حالا شما می توانید استفاده کنید `KILL QUERY` برای لغو نمایش داده شد که هنوز شروع نشده است زیرا انتظار دارند جدول قفل شود. [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) -- اصلاح محاسبات تاریخ و زمان اگر ساعت در نیمه شب منتقل شد (این اتفاق می افتد در ایران, و در مسکو از اتفاق افتاد 1981 به 1983). قبلا, این منجر به زمان در حال تنظیم مجدد یک روز زودتر از حد لازم, و همچنین باعث قالب بندی نادرست از تاریخ و زمان در قالب متن. [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) -- اشکالات ثابت در برخی موارد `VIEW` و کارخانه های فرعی که حذف پایگاه داده. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3521) -- ثابت شرایط مسابقه زمانی که به طور همزمان از یک خواندن `MATERIALIZED VIEW` و حذف یک `MATERIALIZED VIEW` با توجه به قفل کردن داخلی `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) -- خطا را ثابت کرد `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) -- پردازش پرس و جو ثابت زمانی که `compile_expressions` گزینه فعال است(به طور پیش فرض فعال است). عبارات ثابت نامشخص مانند `now` تابع دیگر گشوده. [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) -- ثابت تصادف در هنگام مشخص کردن یک استدلال مقیاس غیر ثابت در `toDecimal32/64/128` توابع. -- ثابت خطا در هنگام تلاش برای وارد کردن مجموعه ای با `NULL` عناصر در `Values` قالب در یک ستون از نوع `Array` بدون `Nullable` (اگر `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) -- ثابت ورود خطا مداوم در `DDLWorker` اگر باغ وحش در دسترس نیست. [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) -- ثابت نوع بازگشت برای `quantile*` توابع از `Date` و `DateTime` انواع استدلال. [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) -- ثابت `WITH` بند اگر یک نام مستعار ساده و بدون عبارات مشخص. [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) -- پردازش ثابت نمایش داده شد با نام زیر نمایش داده شد و نام ستون واجد شرایط زمانی که `enable_optimize_predicate_expression` فعال است. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3588) -- خطا را ثابت کرد `Attempt to attach to nullptr thread group` در هنگام کار با نمایش محقق. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) -- ثابت تصادف در هنگام عبور استدلال نادرست خاص به `arrayReverse` تابع. [733ا7ب6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- ثابت سرریز بافر در `extractURLParameter` تابع. بهبود عملکرد. اضافه شده پردازش صحیح رشته حاوی صفر بایت. [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) -- سرریز بافر ثابت در `lowerUTF8` و `upperUTF8` توابع. حذف توانایی برای اجرای این توابع بیش از `FixedString` استدلال نوع. [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) -- ثابت شرایط مسابقه نادر در هنگام حذف `MergeTree` میز [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) -- ثابت شرایط مسابقه در هنگام خواندن از `Buffer` جداول و به طور همزمان انجام `ALTER` یا `DROP` در جداول هدف. [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) -- ثابت segfault اگر `max_temporary_non_const_columns` حد بیش از حد شد. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### بهبود: {#improvements-1} - -- سرور فایل های پیکربندی پردازش شده را به `/etc/clickhouse-server/` فهرست راهنما. در عوض, این موجب صرفه جویی در `preprocessed_configs` فهرست راهنمای داخل `path`. این به این معنی است که `/etc/clickhouse-server/` دایرکتوری دسترسی نوشتن برای ندارد `clickhouse` کاربر, که باعث بهبود امنیت. [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) -- این `min_merge_bytes_to_use_direct_io` گزینه به 10 دستگاه گوارش به طور پیش فرض تنظیم شده است. ادغام که بخش های زیادی از جداول از خانواده ادغام را تشکیل می دهد در انجام خواهد شد `O_DIRECT` حالت, که مانع از اخراج کش صفحه بیش از حد. [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) -- شتاب سرور شروع زمانی که تعداد بسیار زیادی از جداول وجود دارد. [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) -- اضافه شدن یک استخر اتصال و قام `Keep-Alive` برای ارتباط بین کپی. [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) -- اگر نحو پرس و جو نامعتبر است `400 Bad Request` کد در بازگشت `HTTP` رابط (500 قبلا بازگردانده شد). [31ب680ا](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) -- این `join_default_strictness` گزینه تنظیم شده است `ALL` به طور پیش فرض برای سازگاری. [120الکترونیکی 2جبه](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) -- حذف ورود به سیستم `stderr` از `re2` کتابخانه برای عبارات منظم نامعتبر و یا پیچیده. [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) -- اضافه شده برای `Kafka` موتور جدول: چک برای اشتراک قبل از شروع به خواندن از کافکا; تنظیمات کافکا\_مکس\_بلک\_سیز برای جدول. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) -- این `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32` و `murmurHash3_64` توابع در حال حاضر برای هر تعداد از استدلال و برای استدلال در قالب تاپل کار می کنند. [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) -- این `arrayReverse` تابع در حال حاضر با هر نوع ارریس کار می کند. [733ا7ب6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- اضافه شده یک پارامتر اختیاری: اندازه اسلات برای `timeSlots` تابع. [کیریل شواکوف](https://github.com/ClickHouse/ClickHouse/pull/3724) -- برای `FULL` و `RIGHT JOIN` این `max_block_size` تنظیم برای یک جریان از داده های غیر پیوست از جدول سمت راست استفاده می شود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3699) -- اضافه شدن `--secure` پارامتر خط فرمان در `clickhouse-benchmark` و `clickhouse-performance-test` برای فعال کردن شماره تلفن. [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) -- تبدیل نوع زمانی که ساختار یک `Buffer` جدول نوع ساختار جدول مقصد مطابقت ندارد. [ویتالی بارانو](https://github.com/ClickHouse/ClickHouse/pull/3603) -- اضافه شدن `tcp_keep_alive_timeout` گزینه ای برای فعال نگه داشتن زنده بسته پس از عدم فعالیت برای فاصله زمانی مشخص شده است. [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) -- حذف نقل غیر ضروری از ارزش برای کلید پارتیشن در `system.parts` جدول اگر از یک ستون تشکیل شده است. [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) -- عملکرد پیمانه برای `Date` و `DateTime` انواع داده ها. [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) -- اضافه شده مترادف برای `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR` و `MID` توابع. [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) برخی از نام های تابع حروف حساس برای سازگاری با استاندارد گذاشتن. شکر نحوی اضافه شده است `SUBSTRING(expr FROM start FOR length)` برای سازگاری با گذاشتن. [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) -- توانایی اضافه شده به `mlock` صفحات حافظه مربوط به `clickhouse-server` کد اجرایی برای جلوگیری از مجبور شدن از حافظه. این ویژگی به طور پیش فرض غیر فعال. [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) -- بهبود عملکرد در هنگام خواندن از `O_DIRECT` (با `min_bytes_to_use_direct_io` گزینه فعال). [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) -- بهبود عملکرد `dictGet...OrDefault` تابع برای یک استدلال کلیدی ثابت و یک استدلال پیش فرض غیر ثابت. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3563) -- این `firstSignificantSubdomain` تابع در حال حاضر پردازش دامنه `gov`, `mil` و `edu`. [ایگور هاتاریست](https://github.com/ClickHouse/ClickHouse/pull/3601) بهبود عملکرد. [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) -- امکان مشخص کردن متغیرهای محیطی سفارشی برای شروع `clickhouse-server` با استفاده از `SYS-V init.d` اسکریپت با تعریف `CLICKHOUSE_PROGRAM_ENV` داخل `/etc/default/clickhouse`. - [پاولو باشینسکیی](https://github.com/ClickHouse/ClickHouse/pull/3612) -- کد بازگشت صحیح برای اسکریپت اینیت کلاینت سرور. [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) -- این `system.metrics` جدول در حال حاضر `VersionInteger` متریک و `system.build_options` دارای خط اضافه شده است `VERSION_INTEGER`, که شامل فرم عددی از نسخه کلیک, مانند `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) -- حذف توانایی مقایسه `Date` نوع با یک عدد برای جلوگیری از خطاهای بالقوه مانند `date = 2018-12-17`, جایی که نقل قول در سراسر تاریخ به اشتباه حذف. [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) -- ثابت رفتار توابع نفرت انگیز مانند `rowNumberInAllBlocks`. قبلا خروجی نتیجه که یک عدد بزرگتر با توجه به شروع در طول تجزیه و تحلیل پرس و جو بود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3729) -- اگر `force_restore_data` فایل را نمی توان حذف کرد, یک پیغام خطا نمایش داده می شود. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3794) - -#### بهبود ساخت: {#build-improvements-1} - -- به روز شده در `jemalloc` کتابخانه, که رفع نشت حافظه بالقوه. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3557) -- پروفایل با `jemalloc` به طور پیش فرض به منظور اشکال زدایی ایجاد فعال است. [2سی82ف5 درجه سانتیگراد](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) -- اضافه شدن توانایی برای اجرای تست ادغام زمانی که تنها `Docker` بر روی سیستم نصب شده است. [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) -- اضافه شدن تست بیان ریش ریش شدن در نمایش داده شد را انتخاب کنید. [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) -- اضافه شدن یک تست استرس برای مرتکب, که انجام تست های کاربردی به صورت موازی و به صورت تصادفی برای تشخیص شرایط مسابقه بیشتر. [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) -- بهبود روش برای شروع کلیک سرور در یک تصویر کارگر بارانداز. [الغزال احمد](https://github.com/ClickHouse/ClickHouse/pull/3663) -- برای یک تصویر کارگر بارانداز, اضافه شدن پشتیبانی برای مقداردهی اولیه پایگاه داده با استفاده از فایل ها در `/docker-entrypoint-initdb.d` فهرست راهنما. [کنستانتین لبتوف](https://github.com/ClickHouse/ClickHouse/pull/3695) -- رفع برای ایجاد بر روی بازو. [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes} - -- حذف توانایی مقایسه `Date` نوع با یک عدد. به جای `toDate('2018-12-18') = 17883`, شما باید تبدیل نوع صریح و روشن استفاده `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) - -## انتشار کلیک 18.14 {#clickhouse-release-18-14} - -### انتشار کلیک 18.14.19, 2018-12-19 {#clickhouse-release-18-14-19-2018-12-19} - -#### رفع اشکال: {#bug-fixes-2} - -- رفع خطا که به مشکلات با به روز رسانی لغت نامه با منبع ان بی سی منجر شده است. [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- پایگاه داده ها هنگام اجرای دی ال به درستی مشخص شده است `ON CLUSTER` نمایش داده شد. [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- ثابت segfault اگر `max_temporary_non_const_columns` حد بیش از حد شد. [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### بهبود ساخت: {#build-improvements-2} - -- رفع برای ایجاد بر روی بازو. - -### انتشار کلیک 18.14.18, 2018-12-04 {#clickhouse-release-18-14-18-2018-12-04} - -#### رفع اشکال: {#bug-fixes-3} - -- خطای ثابت در `dictGet...` تابع برای لغت نامه از نوع `range`, اگر یکی از استدلال ثابت است و دیگر نیست. [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) -- خطا ثابت که باعث پیام `netlink: '...': attribute type 1 has an invalid length` برای چاپ در لینوکس هسته ورود که اتفاق می افتد تنها در نسخه های تازه به اندازه کافی از هسته لینوکس. [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) -- پیش فرض ثابت در عملکرد `empty` برای استدلال `FixedString` نوع. [دانیل, دا کوانگ مین](https://github.com/ClickHouse/ClickHouse/pull/3703) -- تخصیص حافظه بیش از حد ثابت در هنگام استفاده از مقدار زیادی از `max_query_size` تنظیم (یک تکه حافظه از `max_query_size` بایت در یک بار تخصیص داده شد). [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) - -#### ایجاد تغییرات: {#build-changes} - -- ساخت ثابت با کتابخانه های لووم/کلنگ نسخه 7 از بسته های سیستم عامل (این کتابخانه ها برای تدوین پرس و جو در زمان اجرا استفاده می شود). [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### انتشار کلیک 18.14.17, 2018-11-30 {#clickhouse-release-18-14-17-2018-11-30} - -#### رفع اشکال: {#bug-fixes-4} - -- موارد ثابت زمانی که روند پل ان بی سی با روند سرور اصلی خاتمه نیست. [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) -- درج همزمان ثابت به `Distributed` جدول با یک لیست ستون که از لیست ستون جدول از راه دور متفاوت. [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) -- ثابت یک بیماری مسابقه نادر است که می تواند به یک تصادف در هنگام حذف یک جدول ادغام منجر شود. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- ثابت بن بست پرس و جو در مورد زمانی که ایجاد موضوع پرس و جو با شکست مواجه `Resource temporarily unavailable` خطا. [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- تجزیه ثابت از `ENGINE` بند زمانی که `CREATE AS table` نحو مورد استفاده قرار گرفت و `ENGINE` بند قبل از مشخص شد `AS table` (خطا منجر به نادیده گرفتن موتور مشخص شده). [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) - -### انتشار کلیک 18.14.15, 2018-11-21 {#clickhouse-release-18-14-15-2018-11-21} - -#### رفع اشکال: {#bug-fixes-5} - -- اندازه تکه حافظه دست بالا بود در حالی که غیرشخصی ستون از نوع `Array(String)` که منجر به “Memory limit exceeded” خطاها. این موضوع در نسخه 18.12.13 ظاهر شد. [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) - -### انتشار کلیک 18.14.14, 2018-11-20 {#clickhouse-release-18-14-14-2018-11-20} - -#### رفع اشکال: {#bug-fixes-6} - -- ثابت `ON CLUSTER` نمایش داده شد که خوشه پیکربندی به عنوان امن (پرچم ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) - -#### ایجاد تغییرات: {#build-changes-1} - -- مشکلات ثابت-7 از سیستم مکینتاش) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### انتشار کلیک 18.14.13, 2018-11-08 {#clickhouse-release-18-14-13-2018-11-08} - -#### رفع اشکال: {#bug-fixes-7} - -- ثابت `Block structure mismatch in MergingSorted stream` خطا. [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) -- ثابت `ON CLUSTER` نمایش داده شد در صورتی که اتصالات امن در در پیکربندی خوشه تبدیل شد (از `` پرچم). [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) -- ثابت خطا در نمایش داده شد که استفاده می شود `SAMPLE`, `PREWHERE` و ستون نام مستعار. [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) -- ثابت نادر `unknown compression method` خطا در هنگام `min_bytes_to_use_direct_io` تنظیمات فعال شد. [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) - -#### بهبود عملکرد: {#performance-improvements} - -- رگرسیون عملکرد ثابت نمایش داده شد با `GROUP BY` از ستون UInt16 یا نوع تاریخ که در اجرای AMD EPYC پردازنده. [ایگور لاپکو](https://github.com/ClickHouse/ClickHouse/pull/3512) -- رگرسیون عملکرد ثابت نمایش داده شد که رشته های طولانی را پردازش می کند. [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) - -#### بهبود ساخت: {#build-improvements-3} - -- بهبود برای ساده سازی ساخت ارکادیا. [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) - -### انتشار کلیک 18.14.12, 2018-11-02 {#clickhouse-release-18-14-12-2018-11-02} - -#### رفع اشکال: {#bug-fixes-8} - -- ثابت سقوط در پیوستن به دو کارخانه های فرعی که نامش ذکر نشده. [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) -- ثابت تولید نمایش داده شد نادرست (با خالی `WHERE` بند) هنگامی که پرس و جو پایگاه داده های خارجی. [هیلد](https://github.com/ClickHouse/ClickHouse/pull/3477) -- ثابت با استفاده از یک مقدار ایست نادرست در لغت نامه او بی سی. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) - -### انتشار کلیک 18.14.11, 2018-10-29 {#clickhouse-release-18-14-11-2018-10-29} - -#### رفع اشکال: {#bug-fixes-9} - -- خطا را ثابت کرد `Block structure mismatch in UNION stream: different number of columns` در حد نمایش داده شد. [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) -- خطاهای ثابت در هنگام ادغام داده ها در جداول حاوی ارریس در داخل ساختارهای تو در تو. [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) -- نتایج پرس و جو نادرست ثابت اگر `merge_tree_uniform_read_distribution` تنظیم غیر فعال است(به طور پیش فرض فعال). [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) -- ثابت خطا در درج به یک جدول توزیع شده در فرمت بومی. [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) - -### انتشار کلیک 18.14.10, 2018-10-23 {#clickhouse-release-18-14-10-2018-10-23} - -- این `compile_expressions` تنظیم (مجموعه دستگاه گوارش عبارات) به طور پیش فرض غیر فعال است. [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) -- این `enable_optimize_predicate_expression` تنظیم به طور پیش فرض غیر فعال است. - -### انتشار کلیک 18.14.9, 2018-10-16 {#clickhouse-release-18-14-9-2018-10-16} - -#### ویژگی های جدید: {#new-features-1} - -- این `WITH CUBE` تغییردهنده برای `GROUP BY` (نحو جایگزین `GROUP BY CUBE(...)` همچنین در دسترس است). [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) -- اضافه شدن `formatDateTime` تابع. [الکساندر کراشنینیکوف](https://github.com/ClickHouse/ClickHouse/pull/2770) -- اضافه شدن `JDBC` موتور جدول و `jdbc` تابع جدول (نیاز به نصب کلیک-جد بی سی پل). [الکساندر کراشنینیکوف](https://github.com/ClickHouse/ClickHouse/pull/3210) -- اضافه شدن توابع برای کار با شماره ایزو هفته: `toISOWeek`, `toISOYear`, `toStartOfISOYear` و `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) -- حالا شما می توانید استفاده کنید `Nullable` ستون برای `MySQL` و `ODBC` میز [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- ساختارهای داده تو در تو را می توان به عنوان اجسام تو در تو در خواندن `JSONEachRow` قالب. اضافه شدن `input_format_import_nested_json` تنظیمات. [ولمان یونکان](https://github.com/ClickHouse/ClickHouse/pull/3144) -- پردازش موازی برای بسیاری در دسترس است `MATERIALIZED VIEW`هنگام قرار دادن داده ها. دیدن `parallel_view_processing` تنظیمات. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) -- اضافه شدن `SYSTEM FLUSH LOGS` پرس و جو (مجبور ورود حملات گرگرفتگی به جداول سیستم مانند `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) -- حالا شما می توانید از پیش تعریف شده استفاده کنید `database` و `table` ماکروها هنگام اعلام `Replicated` میز [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) -- توانایی خواندن را اضافه کرد `Decimal` ارزش نوع در نماد مهندسی (نشان می دهد قدرت ده). [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) - -#### ویژگی های تجربی: {#experimental-features} - -- بهینه سازی گروه بند برای `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) -- محاسبه بهینه از عبارات برای `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) - -#### بهبود: {#improvements-2} - -- به طور قابل توجهی کاهش مصرف حافظه برای نمایش داده شد با `ORDER BY` و `LIMIT`. دیدن `max_bytes_before_remerge_sort` تنظیمات. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- در صورت عدم وجود `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` فرض بر این است. [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) -- ستاره واجد شرایط به درستی در نمایش داده شد با کار `JOIN`. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3202) -- این `ODBC` موتور جدول به درستی انتخاب روش برای به نقل از شناسه در گویش گذاشتن یک پایگاه داده از راه دور. [الکساندر کراشنینیکوف](https://github.com/ClickHouse/ClickHouse/pull/3210) -- این `compile_expressions` تنظیم (مجموعه دستگاه گوارش از عبارات) به طور پیش فرض فعال است. -- رفتار ثابت برای پایگاه داده قطره به طور همزمان/جدول اگر وجود دارد و ایجاد پایگاه داده / جدول اگر وجود ندارد. قبلا `CREATE DATABASE ... IF NOT EXISTS` پرسوجو میتواند پیغام خطا را بازگرداند “File … already exists” و `CREATE TABLE ... IF NOT EXISTS` و `DROP TABLE IF EXISTS` نمایش داده شد می تواند بازگشت `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) -- مانند و در عبارات با نیمه راست ثابت به سرور از راه دور منتقل می شود که پرس و جو از خروجی زیر و یا جداول ان بی سی. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- مقایسه با عبارات ثابت در جایی که بند به سرور از راه دور منتقل می شود که پرس و جو از خروجی زیر و جداول ان بی سی. قبلا, تنها مقایسه با ثابت تصویب شد. [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- محاسبه صحیح عرض ردیف در ترمینال برای `Pretty` فرمت, از جمله رشته با هیروگلیف. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/3257). -- `ON CLUSTER` می توان برای مشخص `ALTER UPDATE` نمایش داده شد. -- بهبود عملکرد برای خواندن داده ها در `JSONEachRow` قالب. [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) -- اضافه شده مترادف برای `LENGTH` و `CHARACTER_LENGTH` توابع برای سازگاری. این `CONCAT` تابع دیگر حساس به حروف نیست. [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) -- اضافه شدن `TIMESTAMP` مترادف برای `DateTime` نوع. [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) -- همیشه فضای این سایت متعلق به پرس و جو کوری\_ید در سیاهههای مربوط به سرور وجود دارد, حتی اگر خط ورود به سیستم به یک پرس و جو مربوط نیست. این باعث می شود ساده تر به تجزیه سرور سیاهههای مربوط به متن با ابزار شخص ثالث. -- مصرف حافظه توسط پرس و جو وارد شده است که بیش از سطح بعدی از یک عدد صحیح گیگابایت است. [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- اضافه شده حالت سازگاری برای مورد زمانی که کتابخانه مشتری که با استفاده از پروتکل بومی ستون کمتر به اشتباه می فرستد از سرور انتظار برای پرس و جو درج. این سناریو ممکن بود در هنگام استفاده از کتابخانه کلیک پردازنده. قبلا, این سناریو باعث سرور به سقوط. [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) -- در تعریف کاربر که بیان در `clickhouse-copier` شما هم اکنون می توانید از یک `partition_key` نام مستعار (برای فیلتر کردن اضافی توسط پارتیشن جدول منبع). این بسیار مفید است اگر طرح پارتیشن بندی در طول کپی تغییر, اما تنها کمی تغییر. [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) -- گردش کار از `Kafka` موتور شده است به یک استخر موضوع پس زمینه به منظور به طور خودکار کاهش سرعت خواندن داده ها در بارهای بالا نقل مکان کرد. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- پشتیبانی از خواندن `Tuple` و `Nested` ارزش سازه ها مانند `struct` در `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) -- فهرست دامنه های سطح بالا برای `firstSignificantSubdomain` تابع در حال حاضر شامل دامنه `biz`. [بریدن](https://github.com/ClickHouse/ClickHouse/pull/3219) -- در پیکربندی واژهنامهها خارجی, `null_value` به عنوان مقدار نوع داده پیش فرض تفسیر شده است. [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) -- پشتیبانی از `intDiv` و `intDivOrZero` توابع برای `Decimal`. [48402الکترونیکی8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) -- پشتیبانی از `Date`, `DateTime`, `UUID` و `Decimal` انواع به عنوان یک کلید برای `sumMap` تابع جمع. [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) -- پشتیبانی از `Decimal` نوع داده در لغت نامه های خارجی. [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) -- پشتیبانی از `Decimal` نوع داده در `SummingMergeTree` میز [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) -- اضافه شده تخصص برای `UUID` داخل `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) -- کاهش تعداد `open` و `close` سیستم هنگام خواندن از یک تماس می گیرد `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) -- A `TRUNCATE TABLE` پرس و جو را می توان در هر ماکت اجرا (پرس و جو به ماکت رهبر منتقل). [کیریل شواکوف](https://github.com/ClickHouse/ClickHouse/pull/3375) - -#### رفع اشکال: {#bug-fixes-10} - -- ثابت موضوع را با `Dictionary` جداول برای `range_hashed` واژهنامهها. این خطا در نسخه 18.12.17 رخ داده است. [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) -- ثابت خطا در هنگام بارگذاری `range_hashed` واژهنامهها (پیام `Unsupported type Nullable (...)`). این خطا در نسخه 18.12.17 رخ داده است. [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- خطاهای ثابت در `pointInPolygon` تابع با توجه به تجمع محاسبات نادرست برای چند ضلعی با تعداد زیادی از راس واقع نزدیک به یکدیگر. [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) -- اگر پس از ادغام قطعات داده, کنترلی برای بخش حاصل از نتیجه همان ادغام در ماکت دیگر متفاوت, نتیجه ادغام حذف شده است و بخش داده ها از ماکت های دیگر دانلود (این رفتار صحیح است). اما پس از دانلود بخش داده ها, این می تواند به مجموعه کار به دلیل یک خطا که بخشی در حال حاضر وجود دارد اضافه نمی شود (به این دلیل که بخش داده ها با برخی از تاخیر پس از ادغام حذف شد). این امر منجر به تلاش چرخه ای برای دانلود داده های مشابه. [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) -- محاسبه نادرست ثابت از مصرف کل حافظه توسط نمایش داده شد (به دلیل محاسبه نادرست `max_memory_usage_for_all_queries` تنظیم نادرست کار می کرد و `MemoryTracking` متریک مقدار نادرست بود). این خطا در نسخه 18.12.13 رخ داده است. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) -- ثابت قابلیت های `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` این خطا در نسخه 18.12.13 رخ داده است. [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) -- تهیه غیر ضروری ثابت از ساختارهای داده برای `JOIN`بازدید کنندگان بر روی سرور که شروع پرس و جو در صورتی که `JOIN` تنها بر روی سرور از راه دور انجام می شود. [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) -- اشکالات ثابت در `Kafka` موتور: بن بست پس از استثنا در هنگام شروع به خواندن داده ها و قفل پس از اتمام [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- برای `Kafka` جداول اختیاری `schema` پارامتر تصویب نشد (طرح از `Cap'n'Proto` قالب). [اطلاعات دقیق](https://github.com/ClickHouse/ClickHouse/pull/3150) -- اگر این گروه از باغ وحش سرور است سرور است که اتصال را قبول اما پس از آن بلافاصله آن را به جای پاسخ به از دست دادن clickhouse انتخاب برای اتصال به سرور دیگری. قبلا این خطا را تولید کرد `Cannot read all data. Bytes read: 0. Bytes expected: 4.` و سرور نمی تواند شروع. [8218رف3](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) -- اگر این گروه از سرور باغ وحش شامل سرور که پرس و جو دی ان اس خطا می گرداند, این سرویس دهنده نادیده گرفته می شوند. [17ب8209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) -- تبدیل نوع ثابت بین `Date` و `DateTime` هنگام وارد کردن داده ها در `VALUES` قالب (اگر `input_format_values_interpret_expressions = 1`). قبلا, تبدیل بین مقدار عددی تعداد روز در زمان عصر یونیکس و برچسب زمان یونیکس انجام شد, که منجر به نتایج غیر منتظره. [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) -- اصلاح نوع تبدیل بین `Decimal` و اعداد صحیح. [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) -- خطاهای ثابت در `enable_optimize_predicate_expression` تنظیمات. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3231) -- یک خطای تجزیه کننده در فرمت سی سی اس وی با اعداد ممیز شناور ثابت شده است اگر جدا کننده سی سی اس وی غیر پیش فرض استفاده شود مانند `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) -- ثابت `arrayCumSumNonNegative` تابع (این مقادیر منفی تجمع می یابد اگر باتری کمتر از صفر است). [الکسی استدیو](https://github.com/ClickHouse/ClickHouse/pull/3163) -- ثابت چگونه `Merge` جداول در بالای کار `Distributed` جداول هنگام استفاده از `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) -- رفع اشکال در `ALTER UPDATE` پرس و جو. -- اشکالات ثابت در `odbc` تابع جدول که در نسخه ظاهر شد 18.12. [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) -- ثابت بهره برداری از توابع مجموع با `StateArray` ترکیب کننده ها [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) -- ثابت تصادف در هنگام تقسیم یک `Decimal` ارزش صفر. [69د6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) -- خروجی ثابت از انواع برای عملیات با استفاده از `Decimal` و استدلال عدد صحیح. [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) -- ثابت segfault در طول `GROUP BY` روشن `Decimal128`. [3359با06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) -- این `log_query_threads` تنظیم (ورود اطلاعات در مورد هر موضوع اجرای پرس و جو) در حال حاضر اثر تنها در صورتی که `log_queries` گزینه (ورود اطلاعات در مورد نمایش داده شد) به 1 تنظیم شده است. از زمان `log_query_threads` گزینه به طور پیش فرض فعال, اطلاعات در مورد موضوعات قبلا وارد شده بود حتی اگر ورود به سیستم پرس و جو غیر فعال شد. [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) -- ثابت خطا در توزیع, بهره برداری از quantiles aggregate function (پیام خطا `Not found column quantile...`). [292ا8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) -- ثابت مشکل سازگاری در هنگام کار بر روی یک خوشه از نسخه 18.12.17 سرور و سرور های قدیمی تر در همان زمان. برای نمایش داده شد توزیع شده با گروه های کلید از هر دو ثابت و غیر ثابت طول اگر وجود دارد مقدار زیادی از داده ها به کل بازگشت داده بود و نه همیشه به طور کامل جمع (دو ردیف مختلف شامل همان جمع کلید). [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) -- ثابت دست زدن به تعویض در `clickhouse-performance-test`, اگر پرس و جو شامل تنها بخشی از تعویض اعلام شده در تست. [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) -- ثابت خطا در هنگام استفاده از `FINAL` با `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- ثابت خطا در هنگام استفاده از `PREWHERE` بیش از ستون که در طول اضافه شد `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- اضافه شدن یک چک برای عدم وجود `arrayJoin` برای `DEFAULT` و `MATERIALIZED` عبارات. قبلا, `arrayJoin` منجر به خطا در هنگام قرار دادن داده ها. [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) -- اضافه شدن یک چک برای عدم وجود `arrayJoin` در یک `PREWHERE` بند بند. قبلا, این منجر به پیام هایی مانند `Size ... doesn't match` یا `Unknown compression method` هنگام اجرای نمایش داده شد. [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) -- ثابت segfault است که می تواند رخ دهد در موارد نادر پس از بهینه سازی است که جایگزین شده و زنجیره ای از برابری با ارزیابی مربوطه در بیان. [هشدار داده می شود](https://github.com/ClickHouse/ClickHouse/pull/3339) -- اصلاحات جزیی به `clickhouse-benchmark`: قبلا, اطلاعات مربوط به مشتری به سرور ارسال نمی شد; در حال حاضر تعداد نمایش داده شد اجرا شده است با دقت بیشتری محاسبه زمانی که بستن و برای محدود کردن تعداد تکرار. [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-1} - -- حذف `allow_experimental_decimal_type` انتخاب این `Decimal` نوع داده برای استفاده پیش فرض در دسترس است. [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) - -## انتشار کلیک 18.12 {#clickhouse-release-18-12} - -### انتشار کلیک 18.12.17, 2018-09-16 {#clickhouse-release-18-12-17-2018-09-16} - -#### ویژگی های جدید: {#new-features-2} - -- `invalidate_query` (قابلیت مشخص کردن پرس و جو برای بررسی اینکه یک فرهنگ لغت خارجی باید به روز شود) برای اجرا `clickhouse` منبع. [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) -- توانایی استفاده را اضافه کرد `UInt*`, `Int*` و `DateTime` انواع داده ها (همراه با `Date` نوع) به عنوان یک `range_hashed` کلید فرهنگ لغت خارجی که مرزهای محدوده را تعریف می کند. حالا `NULL` می توان برای تعیین محدوده باز استفاده کرد. [واسیلی نمکو](https://github.com/ClickHouse/ClickHouse/pull/3123) -- این `Decimal` نوع در حال حاضر پشتیبانی می کند `var*` و `stddev*` توابع مجموع. [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- این `Decimal` نوع در حال حاضر پشتیبانی از توابع ریاضی (`exp`, `sin` و به همین ترتیب.) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- این `system.part_log` جدول در حال حاضر `partition_id` ستون. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### رفع اشکال: {#bug-fixes-11} - -- `Merge` در حال حاضر به درستی کار می کند `Distributed` میز [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3159) -- ناسازگاری ثابت (وابستگی غیر ضروری به `glibc` نسخه) ساخته شده است که غیر ممکن است برای اجرای کلیک بر روی `Ubuntu Precise` و نسخه های قدیمی تر. ناسازگاری در نسخه 18.12.13 ظاهر شد. [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) -- خطاهای ثابت در `enable_optimize_predicate_expression` تنظیمات. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3107) -- ثابت یک موضوع کوچک با سازگاری به عقب که به نظر می رسد در هنگام کار با یک خوشه از کپی در نسخه های زودتر از 18.12.13 و به طور همزمان ایجاد یک کپی جدید از یک جدول بر روی یک سرور با یک نسخه جدیدتر (نشان داده شده در پیام `Can not clone replica, because the ... updated to new ClickHouse version` که منطقی است اما نباید اتفاق می افتد). [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-2} - -- این `enable_optimize_predicate_expression` گزینه به طور پیش فرض فعال (که است و نه خوش بینانه). اگر تجزیه و تحلیل پرس و جو خطا رخ می دهد که مربوط به جستجو برای نام ستون مجموعه `enable_optimize_predicate_expression` به 0. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3107) - -### انتشار کلیک 18.12.14, 2018-09-13 {#clickhouse-release-18-12-14-2018-09-13} - -#### ویژگی های جدید: {#new-features-3} - -- اضافه شدن پشتیبانی برای `ALTER UPDATE` نمایش داده شد. [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) -- اضافه شدن `allow_ddl` گزینه ای که دسترسی کاربر به پرس و جو دی ال را محدود می کند. [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) -- اضافه شدن `min_merge_bytes_to_use_direct_io` گزینه برای `MergeTree` موتورهای, که اجازه می دهد تا شما را به مجموعه یک خودداری برای اندازه کل ادغام (زمانی که بالاتر از حد خودداری, فایل های بخش داده خواهد شد با استفاده از اچ به کار گرفته). [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) -- این `system.merges` جدول سیستم در حال حاضر شامل `partition_id` ستون. [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) - -#### بهبود {#improvements-3} - -- اگر بخش داده ها در طول جهش بدون تغییر باقی می ماند, این است که توسط کپی دانلود کنید. [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) -- تکمیل خودکار برای نام تنظیمات در هنگام کار با در دسترس است `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) - -#### رفع اشکال: {#bug-fixes-12} - -- اضافه شدن یک چک برای اندازه ارریس که عناصر هستند `Nested` نوع زمینه در هنگام قرار دادن. [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) -- ثابت خطا به روز رسانی لغت نامه های خارجی با `ODBC` منبع و `hashed` انبار. این خطا در نسخه 18.12.13 رخ داده است. -- ثابت تصادف در هنگام ایجاد یک جدول موقت از پرس و جو با یک `IN` شرط. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3098) -- ثابت خطا در توابع کل برای ارریس است که می تواند داشته باشد `NULL` عناصر. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/3097) - -### انتشار کلیک 18.12.13, 2018-09-10 {#clickhouse-release-18-12-13-2018-09-10} - -#### ویژگی های جدید: {#new-features-4} - -- اضافه شدن `DECIMAL(digits, scale)` نوع داده (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). برای فعال کردن از تنظیمات استفاده کنید `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) -- جدید `WITH ROLLUP` تغییردهنده برای `GROUP BY` (نحو جایگزین: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) -- در نمایش داده شد با پیوستن, شخصیت ستاره گسترش می یابد به یک لیست از ستون ها در تمام جداول, در انطباق با استاندارد گذاشتن. شما می توانید رفتار قدیمی با تنظیم بازگرداندن `asterisk_left_columns_only` به 1 در سطح پیکربندی کاربر. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2787) -- اضافه شدن پشتیبانی برای پیوستن با توابع جدول. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2907) -- تکمیل خودکار با فشار دادن زبانه در خانه مشتری. [سرگی شچربین](https://github.com/ClickHouse/ClickHouse/pull/2447) -- کنترل + ج در فاحشه خانه-مشتری پاک پرس و جو که وارد شد. [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) -- اضافه شدن `join_default_strictness` تنظیم (مقادیر: `"`, `'any'`, `'all'`). این اجازه می دهد تا شما را مشخص کنید `ANY` یا `ALL` برای `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) -- هر خط از ورود به سیستم سرور مربوط به پردازش پرس و جو نشان می دهد که شناسه پرس و جو. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- حالا شما می توانید سیاهههای مربوط به اجرای پرس و جو در خانه مشتری (با استفاده از `send_logs_level` تنظیمات). با پردازش پرس و جو توزیع, سیاهههای مربوط از تمام سرور های تهدیدی جدی. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- این `system.query_log` و `system.processes` (`SHOW PROCESSLIST`) جداول در حال حاضر اطلاعات در مورد تمام تنظیمات تغییر زمانی که شما یک پرس و جو (ساختار تو در تو از `Settings` اطلاعات دقیق اضافه شدن `log_query_settings` تنظیمات. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- این `system.query_log` و `system.processes` جداول در حال حاضر اطلاعات مربوط به تعدادی از موضوعات که در اجرای پرس و جو شرکت نشان می دهد (نگاه کنید به `thread_numbers` ستون). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- اضافه شده `ProfileEvents` شمارنده است که اندازه گیری زمان صرف شده در خواندن و نوشتن بر روی شبکه و خواندن و نوشتن بر روی دیسک, تعداد خطاهای شبکه, و زمان صرف انتظار زمانی که پهنای باند شبکه محدود است. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- اضافه شده `ProfileEvents`شمارنده است که شامل سیستم متریک از rusage (شما می توانید آنها را به دریافت اطلاعات در مورد CPU usage در userspace و هسته صفحه گسل و زمینه سوئیچ ها) و همچنین taskstats متریک (با استفاده از این برای به دست آوردن اطلاعات در مورد I/O منتظر زمان CPU صبر کنید زمان و مقدار اطلاعات خوانده شده و ثبت هر دو با و بدون صفحه کش). [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- این `ProfileEvents` شمارنده در سطح جهانی و برای هر پرس و جو اعمال, و همچنین برای هر موضوع اعدام پرس و جو, که اجازه می دهد تا شما را به مشخصات مصرف منابع به طور مفصل. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- اضافه شدن `system.query_thread_log` جدول, که شامل اطلاعات در مورد هر موضوع اعدام پرس و جو. اضافه شدن `log_query_threads` تنظیمات. [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- این `system.metrics` و `system.events` جداول در حال حاضر ساخته شده است در اسناد و مدارک. [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) -- اضافه شدن `arrayEnumerateDense` تابع. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2975) -- اضافه شدن `arrayCumSumNonNegative` و `arrayDifference` توابع. [الکسی استدیو](https://github.com/ClickHouse/ClickHouse/pull/2942) -- اضافه شدن `retention` تابع جمع. [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2887) -- حالا شما می توانید اضافه کنید (ادغام) ایالات کل توابع با استفاده از اپراتور به علاوه و ضرب ایالات کل توابع توسط یک ثابت نامنفی. [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) -- جداول در خانواده ادغام در حال حاضر ستون مجازی `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### ویژگی های تجربی: {#experimental-features-1} - -- اضافه شدن `LowCardinality(T)` نوع داده. این نوع داده به طور خودکار یک فرهنگ لغت محلی از ارزش ها ایجاد می کند و اجازه می دهد تا پردازش داده ها بدون باز کردن فرهنگ لغت. [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) -- اضافه شده یک کش از توابع دستگاه گوارش وارد شده و یک شمارنده برای تعداد استفاده قبل از کامپایل. به جیت کامپایل عبارات, فعال کردن `compile_expressions` تنظیمات. [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) - -#### بهبود: {#improvements-4} - -- ثابت مشکل با تجمع نامحدود از ورود به سیستم تکرار زمانی که کپی رها وجود دارد. اضافه شده یک حالت بهبود موثر برای کپی با تاخیر طولانی. -- بهبود عملکرد `GROUP BY` هنگامی که یکی از رشته ها رشته است و دیگران طول ثابت با زمینه های تجمع های متعدد. -- بهبود عملکرد در هنگام استفاده از `PREWHERE` و با انتقال ضمنی عبارات در `PREWHERE`. -- بهبود عملکرد تجزیه برای فرمت های متن (`CSV`, `TSV`). [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) -- بهبود عملکرد رشته خواندن و جذب در فرمت های باینری. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2955) -- افزایش عملکرد و کاهش مصرف حافظه برای نمایش داده شد به `system.tables` و `system.columns` هنگامی که تعداد بسیار زیادی از جداول در یک سرور وجود دارد. [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) -- رفع مشکل عملکرد در مورد یک جریان بزرگ از نمایش داده شد که منجر به خطا ( `_dl_addr` عملکرد در قابل مشاهده است `perf top` اما سرور پردازنده بسیار استفاده نمی شود). [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) -- شرایط به نظر بازیگران (وقتی که `enable_optimize_predicate_expression` فعال است). [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2907) -- بهبود عملکرد برای `UUID` نوع داده. [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) -- این `UUID` نوع داده ها در لغت نامه کیمیاگر پشتیبانی می شود. [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) -- این `visitParamExtractRaw` تابع به درستی کار می کند با ساختارهای تو در تو. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2974) -- هنگامی که `input_format_skip_unknown_fields` تنظیم فعال است, زمینه های شی در `JSONEachRow` قالب به درستی قلم. [بلکجک](https://github.com/ClickHouse/ClickHouse/pull/2958) -- برای یک `CASE` بیان با شرایط, شما هم اکنون می توانید حذف `ELSE` که معادل است `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) -- ایست عملیات هم اکنون می توانید پیکربندی شود در هنگام کار با باغ وحش. [اوریخی](https://github.com/ClickHouse/ClickHouse/pull/2971) -- شما می توانید افست برای مشخص `LIMIT n, m` به عنوان `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- شما می توانید از `SELECT TOP n` نحو به عنوان یک جایگزین برای `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- افزایش اندازه صف برای نوشتن به جداول سیستم, بنابراین `SystemLog parameter queue is full` خطا اغلب اتفاق نمی افتد. -- این `windowFunnel` تابع مجموع در حال حاضر پشتیبانی از اتفاقاتی که با شرایط متعدد. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2801) -- ستون های تکراری را می توان در یک `USING` بند برای `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) -- `Pretty` فرمت در حال حاضر محدودیتی در تراز ستون های عرض است. استفاده از `output_format_pretty_max_column_pad_width` تنظیمات. اگر مقدار گسترده تر است, هنوز هم در تمامیت خود را نمایش داده خواهد شد, اما سلول های دیگر در جدول نخواهد بود بیش از حد گسترده. [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) -- این `odbc` تابع جدول در حال حاضر اجازه می دهد تا به شما برای مشخص کردن پایگاه داده/نام طرح. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2885) -- توانایی استفاده از یک نام کاربری مشخص شده در `clickhouse-client` فایل پیکربندی. [ولادیمیر کوزبین](https://github.com/ClickHouse/ClickHouse/pull/2909) -- این `ZooKeeperExceptions` شمارنده به سه شمارنده تقسیم شده است: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions` و `ZooKeeperOtherExceptions`. -- `ALTER DELETE` نمایش داده شد و کار را برای محقق views. -- تصادفی اضافه شده در هنگام اجرای موضوع پاکسازی به صورت دوره ای برای `ReplicatedMergeTree` جداول به منظور جلوگیری از خوشه بار دوره ای زمانی که تعداد بسیار زیادی از وجود دارد `ReplicatedMergeTree` میز -- پشتیبانی از `ATTACH TABLE ... ON CLUSTER` نمایش داده شد. [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) - -#### رفع اشکال: {#bug-fixes-13} - -- ثابت موضوع را با `Dictionary` جداول (پرتاب `Size of offsets doesn't match size of column` یا `Unknown compression method` استثنا). این اشکال در نسخه 18.10.3 ظاهر شد. [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) -- رفع اشکال هنگام ادغام `CollapsingMergeTree` جداول اگر یکی از قطعات داده خالی است (این قطعات در طول ادغام و یا تشکیل `ALTER DELETE` اگر تمام داده ها حذف شد), و `vertical` الگوریتم برای ادغام مورد استفاده قرار گرفت. [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) -- ثابت شرایط مسابقه در طول `DROP` یا `TRUNCATE` برای `Memory` جداول با همزمان `SELECT`, که می تواند به سقوط سرور منجر شود. این اشکال در نسخه 1.1.54388 ظاهر شد. [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) -- ثابت امکان از دست دادن داده ها در هنگام قرار دادن در `Replicated` جداول اگر `Session is expired` خطا بازگشته است (از دست دادن داده ها را می توان با شناسایی `ReplicatedDataLoss` متریک). این خطا در نسخه 1.1.54378 رخ داده است. [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) -- ثابت segfault در طول `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) -- ثابت خطا جستجو نام ستون زمانی که `WHERE` بیان به طور کامل شامل یک نام ستون واجد شرایط, مانند `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) -- ثابت “Not found column” خطا که هنگام اجرای نمایش داده شد توزیع رخ داده است اگر یک ستون متشکل از یک عبارت در با یک زیرخاکی از یک سرور از راه دور درخواست. [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) -- ثابت `Block structure mismatch in UNION stream: different number of columns` خطا که برای نمایش داده شد توزیع رخ داده است اگر یکی از خرده ریز محلی است و از سوی دیگر نمی باشد, و بهینه سازی حرکت به `PREWHERE` باعث شده است. [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) -- ثابت `pointInPolygon` تابع برای موارد خاصی از چند ضلعی غیر محدب. [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) -- ثابت نتیجه نادرست در هنگام مقایسه `nan` با اعداد صحیح. [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) -- ثابت خطا در `zlib-ng` کتابخانه ای که می تواند در موارد نادر به پیش فرض منجر شود. [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) -- ثابت نشت حافظه در هنگام قرار دادن به یک جدول با `AggregateFunction` ستون, اگر دولت از تابع کل ساده نیست (اختصاص حافظه به طور جداگانه), و اگر یک درخواست درج نتایج در بلوک های کوچک متعدد. [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) -- ثابت شرایط مسابقه در هنگام ایجاد و حذف همان `Buffer` یا `MergeTree` جدول به طور همزمان. -- ثابت امکان یک پشتک زمانی که مقایسه تاپل ساخته شده از برخی از انواع غیر بدیهی, مانند تاپل. [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) -- ثابت امکان یک پشتک زمانی که در حال اجرا خاص `ON CLUSTER` نمایش داده شد. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2960) -- ثابت خطا در `arrayDistinct` تابع برای `Nullable` عناصر مجموعه. [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) -- این `enable_optimize_predicate_expression` گزینه در حال حاضر به درستی پشتیبانی از موارد با `SELECT *`. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2929) -- ثابت شده است که در هنگام راه اندازی مجدد جلسه باغ وحش. [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) -- مسدود کردن پتانسیل ثابت در هنگام کار با باغ وحش. -- کد نادرست ثابت برای اضافه کردن ساختارهای داده تو در تو `SummingMergeTree`. -- هنگام تخصیص حافظه برای ایالت های توابع کل, تراز دلخواه به درستی در نظر گرفته شود, که این امکان را به استفاده از عملیات که نیاز به هم ترازی در هنگام اجرای کشورهای توابع دانه. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) - -#### تعمیر امنیتی: {#security-fix} - -- استفاده ایمن از منابع داده او بی سی. تعامل با رانندگان بی سی با استفاده از یک جداگانه `clickhouse-odbc-bridge` روند. خطاها در رانندگان اد بی سی شخص ثالث دیگر باعث مشکلات با ثبات سرور و یا ناپایداری. [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) -- اعتبار سنجی نادرست ثابت از مسیر فایل در `catBoostPool` تابع جدول. [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) -- محتویات جداول سیستم (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas` و `replication_queue`) با توجه به دسترسی پیکربندی شده کاربر به پایگاه داده فیلتر شده است (`allow_databases`). [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2856) - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-3} - -- در نمایش داده شد با پیوستن, شخصیت ستاره گسترش می یابد به یک لیست از ستون ها در تمام جداول, در انطباق با استاندارد گذاشتن. شما می توانید رفتار قدیمی با تنظیم بازگرداندن `asterisk_left_columns_only` به 1 در سطح پیکربندی کاربر. - -#### ایجاد تغییرات: {#build-changes-2} - -- اکثر تست های یکپارچه سازی هم اکنون می توانید توسط متعهد اجرا می شود. -- چک سبک کد همچنین می توانید با ارتکاب اجرا می شود. -- این `memcpy` پیاده سازی به درستی در هنگام ساخت در لینوکس7/فدورا انتخاب شده است. [اتین champetier](https://github.com/ClickHouse/ClickHouse/pull/2912) -- هنگام استفاده از صدای شیپور برای ساخت, برخی از هشدارهای از `-Weverything` اضافه شده است, در علاوه بر این به طور منظم `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) -- اشکال زدایی ساخت با استفاده از `jemalloc` گزینه اشکال زدایی. -- رابط کتابخانه برای تعامل با باغ وحش انتزاعی اعلام شده است. [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) - -## انتشار کلیک 18.10 {#clickhouse-release-18-10} - -### انتشار کلیک خانه 18.10.3, 2018-08-13 {#clickhouse-release-18-10-3-2018-08-13} - -#### ویژگی های جدید: {#new-features-5} - -- قام را می توان برای تکرار استفاده می شود. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) -- اضافه شدن توابع `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64` و `murmurHash3_128` علاوه بر موجود `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) -- پشتیبانی از nullable types در clickhouse odbc driver (`ODBCDriver2` فرمت خروجی). [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) -- پشتیبانی از `UUID` در ستون های کلیدی. - -#### بهبود: {#improvements-5} - -- خوشه ها را می توان بدون راه اندازی مجدد سرور هنگام حذف از فایل های پیکربندی حذف کرد. [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) -- لغت نامه های خارجی را می توان بدون راه اندازی مجدد سرور حذف زمانی که از فایل های پیکربندی حذف شده است. [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) -- اضافه شده `SETTINGS` پشتیبانی از `Kafka` موتور جدول. [الکساندر مارشالو](https://github.com/ClickHouse/ClickHouse/pull/2781) -- بهبود برای `UUID` نوع داده (هنوز کامل نیست). [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) -- پشتیبانی از قطعات خالی پس از ادغام در `SummingMergeTree`, `CollapsingMergeTree` و `VersionedCollapsingMergeTree` موتورها. [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) -- سوابق قدیمی جهش های تکمیل شده حذف می شوند (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) -- اضافه شدن `system.merge_tree_settings` جدول [کیریل شواکوف](https://github.com/ClickHouse/ClickHouse/pull/2841) -- این `system.tables` جدول در حال حاضر ستون وابستگی: `dependencies_database` و `dependencies_table`. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2851) -- اضافه شدن `max_partition_size_to_drop` گزینه پیکربندی. [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) -- اضافه شدن `output_format_json_escape_forward_slashes` انتخاب [الکساندر بوچاروف](https://github.com/ClickHouse/ClickHouse/pull/2812) -- اضافه شدن `max_fetch_partition_retries_count` تنظیمات. [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) -- اضافه شدن `prefer_localhost_replica` تنظیم برای غیر فعال کردن اولویت برای یک ماکت محلی و رفتن به یک ماکت محلی بدون تعامل بین فرایند. [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) -- این `quantileExact` بازده عملکرد کل `nan` در مورد تجمع در خالی `Float32` یا `Float64` حاضر [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2855) - -#### رفع اشکال: {#bug-fixes-14} - -- حذف غیر ضروری فرار از پارامترهای رشته اتصال برای ان بی سی, ساخته شده است که غیر ممکن است برای ایجاد یک اتصال. این خطا در نسخه 18.6.0 رخ داده است. -- ثابت منطق برای پردازش `REPLACE PARTITION` دستورات در صف تکرار. اگر دو وجود دارد `REPLACE` منطق نادرست میتواند باعث شود که در صف تکرار باقی بمانند و اعدام نشوند. [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) -- رفع اشکال ادغام زمانی که تمام قطعات داده خالی بود (بخش هایی که از ادغام و یا از تشکیل شد `ALTER DELETE` اگر تمام داده ها حذف شد). این اشکال در نسخه 18.1.0 ظاهر شد. [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) -- ثابت خطا برای همزمان `Set` یا `Join`. [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2823) -- ثابت `Block structure mismatch in UNION stream: different number of columns` خطایی که برای `UNION ALL` نمایش داده شد در داخل زیر پرس و جو اگر یکی از `SELECT` نمایش داده شد شامل نام ستون تکراری. [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2094) -- ثابت نشت حافظه اگر یک استثنا رخ داده است در هنگام اتصال به یک سرور خروجی زیر. -- ثابت نادرست کد پاسخ کلیک مشتری در صورت خطا پرس و جو. -- رفتار نادرست ثابت از دیدگاه محقق حاوی متمایز. [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) - -#### تغییرات ناسازگار به عقب {#backward-incompatible-changes-4} - -- پشتیبانی حذف برای بررسی جدول نمایش داده شد برای جداول توزیع شده است. - -#### ایجاد تغییرات: {#build-changes-3} - -- تخصیص جایگزین شده است: `jemalloc` در حال حاضر به جای استفاده می شود `tcmalloc`. در برخی از حالات, این افزایش سرعت تا 20%. با این حال, نمایش داده شد که تا کند شده وجود دارد 20%. مصرف حافظه شده است حدود کاهش 10% در برخی از حالات, با ثبات بهبود یافته. با بارهای بسیار رقابتی, استفاده از پردازنده در فضای کاربری و در سیستم نشان می دهد فقط یک افزایش کمی. [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) -- استفاده از libressl از یک submodule. [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) -- استفاده از unixodbc از یک submodule. [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) -- استفاده از ماریادب-اتصال-ج از یک زیر زمینی. [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) -- اضافه شده فایل های تست عملکردی به مخزن که در دسترس بودن داده های تست بستگی دارد (در حال حاضر, بدون داده های تست خود را). - -## انتشار کلیک 18.6 {#clickhouse-release-18-6} - -### انتشار کلیک 18.6.0, 2018-08-02 {#clickhouse-release-18-6-0-2018-08-02} - -#### ویژگی های جدید: {#new-features-6} - -- اضافه شدن پشتیبانی برای در عبارات برای عضویت در نحو: - `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` - بیان باید یک زنجیره ای از تجهیزات پیوست شده توسط و اپراتور باشد. هر طرف از برابری می تواند یک بیان دلخواه بیش از ستون از یکی از جداول. استفاده از نام ستون به طور کامل واجد شرایط پشتیبانی می شود (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`) برای جدول سمت راست . [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) -- قام را می توان برای تکرار فعال کنید. [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) - -#### بهبود: {#improvements-6} - -- سرور بخشی پچ از نسخه خود را به مشتری می گذرد. اطلاعات در مورد مولفه نسخه پچ در `system.processes` و `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) - -## انتشار کلیک 18.5 {#clickhouse-release-18-5} - -### ClickHouse انتشار 18.5.1, 2018-07-31 {#clickhouse-release-18-5-1-2018-07-31} - -#### ویژگی های جدید: {#new-features-7} - -- تابع هش اضافه شده است `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). - -#### بهبود: {#improvements-7} - -- حالا شما می توانید استفاده کنید `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) نسبت به تنظیم مقادیر در فایل های پیکربندی از متغیرهای محیط زیست. -- نسخه های غیر حساس به حروف اضافه شده است `coalesce`, `ifNull` و `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). - -#### رفع اشکال: {#bug-fixes-15} - -- رفع اشکال ممکن است در هنگام شروع یک ماکت [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). - -## انتشار کلیک 18.4 {#clickhouse-release-18-4} - -### انتشار کلیک 18.4.0, 2018-07-28 {#clickhouse-release-18-4-0-2018-07-28} - -#### ویژگی های جدید: {#new-features-8} - -- جداول سیستم اضافه شده است: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). -- اضافه شدن توانایی استفاده از یک تابع جدول به جای یک جدول به عنوان یک استدلال از یک `remote` یا `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). -- پشتیبانی از `HTTP Basic` احراز هویت در پروتکل تکرار [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). -- این `has` تابع در حال حاضر اجازه می دهد تا جستجو برای یک مقدار عددی در مجموعه ای از `Enum` مقادیر [ماکسیم خریسانف](https://github.com/ClickHouse/ClickHouse/pull/2699). -- پشتیبانی از اضافه کردن جدا پیام دلخواه در هنگام خواندن از `Kafka` [ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2701). - -#### بهبود: {#improvements-8} - -- این `ALTER TABLE t DELETE WHERE` پرس و جو می کند قطعات داده است که توسط جایی که شرایط تحت تاثیر قرار نمی بازنویسی نیست [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). -- این `use_minimalistic_checksums_in_zookeeper` گزینه برای `ReplicatedMergeTree` جداول به طور پیش فرض فعال. این تنظیمات اضافه شده در نسخه 1.1.54378, 2018-04-16. نسخه هایی که مسن تر از 1.1.54378 هستند دیگر نمی توانند نصب شوند. -- پشتیبانی از در حال اجرا `KILL` و `OPTIMIZE` نمایش داده شد که مشخص `ON CLUSTER` [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2689). - -#### رفع اشکال: {#bug-fixes-16} - -- خطا را ثابت کرد `Column ... is not under an aggregate function and not in GROUP BY` برای تجمع با بیان در. این اشکال در نسخه 18.1.0 ظاهر شد. ([ببد780ب](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) -- رفع اشکال در `windowFunnel aggregate function` [زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2735). -- رفع اشکال در `anyHeavy` تابع جمع ([الف212](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) -- تصادف سرور ثابت در هنگام استفاده از `countArray()` تابع جمع. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-5} - -- پارامترها برای `Kafka` موتور از تغییر یافت `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` به `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. اگر جداول خود استفاده کنید `kafka_schema` یا `kafka_num_consumers` پارامترهای, شما باید به صورت دستی ویرایش فایل های ابرداده `path/metadata/database/table.sql` و اضافه کردن `kafka_row_delimiter` پارامتر با `''` ارزش. - -## انتشار کلیک 18.1 {#clickhouse-release-18-1} - -### ClickHouse انتشار 18.1.0, 2018-07-23 {#clickhouse-release-18-1-0-2018-07-23} - -#### ویژگی های جدید: {#new-features-9} - -- پشتیبانی از `ALTER TABLE t DELETE WHERE` پرسوجو برای جداول ادغام غیر تکرار شده ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). -- پشتیبانی از انواع دلخواه برای `uniq*` خانواده از توابع کل ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). -- پشتیبانی از انواع دلخواه در مقایسه اپراتورها ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). -- این `users.xml` فایل اجازه می دهد تا تنظیم یک ماسک زیر شبکه در قالب `10.0.0.1/255.255.255.0`. این برای استفاده از ماسک برای شبکه های اینترنتی6 با صفر در وسط ضروری است ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). -- اضافه شدن `arrayDistinct` تابع ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). -- این summingmergetree موتور هم اکنون می توانید کار با aggregatefunction نوع ستون ([پان سنتانتین](https://github.com/ClickHouse/ClickHouse/pull/2566)). - -#### بهبود: {#improvements-9} - -- طرح شماره برای نسخه های انتشار تغییر کرده است. در حال حاضر بخش اول شامل سال انتشار (a. d. مسکو منطقه زمانی منهای 2000) بخش دوم شامل تعدادی به صورت عمده تغییرات را افزایش می دهد برای بسیاری منتشر شده) و بخش سوم پچ نسخه. منتشر شده هنوز هم به عقب سازگار هستند, مگر اینکه در غیر این صورت در تغییرات اعلام. -- تبدیل سریع تر اعداد ممیز شناور به یک رشته ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2664)). -- اگر برخی از ردیف در طول درج به دلیل خطاهای تجزیه قلم شد (این ممکن است با `input_allow_errors_num` و `input_allow_errors_ratio` تنظیمات را فعال کنید), تعداد ردیف قلم در حال حاضر به ورود به سیستم سرور نوشته شده است ([لوناردو سیسیچی](https://github.com/ClickHouse/ClickHouse/pull/2669)). - -#### رفع اشکال: {#bug-fixes-17} - -- ثابت فرمان کوتاه برای جداول موقت ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2624)). -- ثابت بن بست نادر در کتابخانه مشتری باغ وحش که رخ داده است زمانی که یک خطای شبکه وجود دارد در حالی که خواندن پاسخ ([315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). -- ثابت خطا در طول بازیگران به nullable types ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). -- ثابت نتیجه نادرست از `maxIntersection()` تابع زمانی که مرزهای فواصل همزمان ([مایکل فورمور](https://github.com/ClickHouse/ClickHouse/pull/2657)). -- تحول نادرست ثابت از زنجیره بیان و یا در یک استدلال تابع ([chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). -- تخریب عملکرد ثابت برای نمایش داده شد حاوی `IN (subquery)` عبارات در داخل یکی دیگر از خرده فروشی ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). -- ناسازگاری ثابت بین سرورها با نسخه های مختلف در نمایش داده شد توزیع شده است که با استفاده از یک `CAST` تابع است که در حروف بزرگ نیست ([ف8چ4د6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). -- اضافه شده از دست رفته به نقل از شناسه برای نمایش داده شد به سندرم تونل کارپ خارجی ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-6} - -- تبدیل یک رشته حاوی عدد صفر به تاریخ ساعت کار نمی کند. مثال: `SELECT toDateTime('0')`. این نیز دلیل است که `DateTime DEFAULT '0'` در جداول و همچنین کار نمی کند `0` در لغت نامه. راه حل: جایگزین کردن `0` با `0000-00-00 00:00:00`. - -## انتشار کلیک 1.1 {#clickhouse-release-1-1} - -### انتشار کلیک 1.1.54394, 2018-07-12 {#clickhouse-release-1-1-54394-2018-07-12} - -#### ویژگی های جدید: {#new-features-10} - -- اضافه شدن `histogram` تابع جمع ([میخیل سورین](https://github.com/ClickHouse/ClickHouse/pull/2521)). -- حالا `OPTIMIZE TABLE ... FINAL` می توان بدون مشخص کردن پارتیشن ها برای `ReplicatedMergeTree` ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2600)). - -#### رفع اشکال: {#bug-fixes-18} - -- رفع مشکل با یک ایست بسیار کوچک برای سوکت (یک ثانیه) برای خواندن و نوشتن در هنگام ارسال و دانلود داده تکرار, ساخته شده است که غیر ممکن است برای دانلود قطعات بزرگتر اگر یک بار بر روی شبکه و یا دیسک وجود دارد (در تلاش دوره ای برای دانلود قطعات منجر). این خطا در نسخه 1.1.54388 رخ داده است. -- مشکلات ثابت در هنگام استفاده از ریشه کن کردن در باغ وحش اگر شما بلوک های داده های تکراری در جدول قرار داده است. -- این `has` تابع در حال حاضر به درستی برای مجموعه ای با عناصر قابل تعویض کار می کند ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). -- این `system.tables` جدول در حال حاضر به درستی کار می کند زمانی که در نمایش داده شد توزیع استفاده می شود. این `metadata_modification_time` و `engine_full` ستون در حال حاضر غیر مجازی. ثابت خطا که رخ داده است اگر تنها این ستون از جدول تردید شد. -- ثابت چگونه خالی `TinyLog` جدول پس از قرار دادن یک بلوک داده خالی کار می کند ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). -- این `system.zookeeper` جدول کار می کند اگر ارزش گره در باغ وحش تهی است. - -### انتشار کلیک 1.1.54390, 2018-07-06 {#clickhouse-release-1-1-54390-2018-07-06} - -#### ویژگی های جدید: {#new-features-11} - -- نمایش داده شد را می توان در ارسال `multipart/form-data` قالب (در `query` رشته), مفید است که اگر داده های خارجی نیز برای پردازش پرس و جو ارسال ([اولگا هوستیکوا](https://github.com/ClickHouse/ClickHouse/pull/2490)). -- اضافه شدن توانایی برای فعال یا غیر فعال کردن پردازش نقل قول یک یا دو هنگام خواندن داده ها در فرمت سی سی.وی. شما می توانید این را در پیکربندی `format_csv_allow_single_quotes` و `format_csv_allow_double_quotes` تنظیمات ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2574)). -- حالا `OPTIMIZE TABLE ... FINAL` می توان بدون مشخص کردن پارتیشن برای انواع غیر تکرار استفاده کرد `MergeTree` ([ایموس پرنده](https://github.com/ClickHouse/ClickHouse/pull/2599)). - -#### بهبود: {#improvements-10} - -- بهبود عملکرد, کاهش مصرف حافظه, و ردیابی مصرف حافظه صحیح با استفاده از اپراتور در زمانی که یک شاخص جدول می تواند مورد استفاده قرار گیرد ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). -- حذف چک کردن کار برکنار شده از چک سام در هنگام اضافه کردن یک بخش داده ها. این مهم است که تعداد زیادی از کپی وجود دارد, چرا که در این موارد تعداد کل چک به نفر برابر بود^2. -- اضافه شدن پشتیبانی برای `Array(Tuple(...))` نشانوندها برای `arrayEnumerateUniq` تابع ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). -- اضافه شده `Nullable` پشتیبانی از `runningDifference` تابع ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). -- بهبود عملکرد تجزیه و تحلیل پرس و جو زمانی که تعداد بسیار زیادی از عبارات وجود دارد ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). -- انتخاب سریع تر از قطعات داده برای ادغام در `ReplicatedMergeTree` میز بازیابی سریع تر از جلسه باغ وحش ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). -- این `format_version.txt` پرونده برای `MergeTree` جداول دوباره ایجاد اگر از دست رفته است, که حس می کند اگر تاتر است پس از کپی کردن ساختار دایرکتوری بدون فایل راه اندازی ([Ciprian Hacman](https://github.com/ClickHouse/ClickHouse/pull/2593)). - -#### رفع اشکال: {#bug-fixes-19} - -- رفع اشکال در هنگام کار با باغ وحش است که می تواند غیر ممکن است برای بازیابی جلسه و خواندنی ایالات جداول قبل از راه اندازی مجدد سرور. -- رفع اشکال در هنگام کار با باغ وحش است که می تواند در گره های قدیمی در نتیجه حذف نمی شود اگر جلسه قطع شده است. -- ثابت خطا در `quantileTDigest` تابع برای استدلال شناور (این اشکال در نسخه 1.1.54388 معرفی شد) ([میخیل سورین](https://github.com/ClickHouse/ClickHouse/pull/2553)). -- رفع اشکال در شاخص برای جداول ادغام اگر ستون کلید اصلی در داخل تابع برای تبدیل انواع بین اعداد صحیح امضا و بدون علامت از همان اندازه واقع شده است ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). -- ثابت segfault اگر `macros` استفاده می شود اما در فایل پیکربندی نیستند ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). -- تعویض ثابت به پایگاه داده به طور پیش فرض در هنگام اتصال مجدد مشتری ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). -- رفع اشکال که زمانی رخ داده است `use_index_for_in_with_subqueries` تنظیم غیر فعال شد. - -#### تعمیر امنیتی: {#security-fix-1} - -- ارسال فایل های دیگر ممکن است زمانی که به خروجی زیر متصل می شود (`LOAD DATA LOCAL INFILE`). - -### انتشار کلیک 1.1.54388, 2018-06-28 {#clickhouse-release-1-1-54388-2018-06-28} - -#### ویژگی های جدید: {#new-features-12} - -- پشتیبانی از `ALTER TABLE t DELETE WHERE` پرس و جو برای جداول تکرار. اضافه شدن `system.mutations` جدول برای پیگیری پیشرفت این نوع از نمایش داده شد. -- پشتیبانی از `ALTER TABLE t [REPLACE|ATTACH] PARTITION` پرس و جو برای \* جداول ادغام. -- پشتیبانی از `TRUNCATE TABLE` پرسوجو ([زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2260)) -- چند جدید `SYSTEM` نمایش داده شد برای جداول تکرار (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). -- توانایی نوشتن به یک جدول با موتور خروجی زیر و عملکرد جدول مربوطه اضافه شده است ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2294)). -- اضافه شدن `url()` عملکرد جدول و `URL` موتور جدول ([الکساندر sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). -- اضافه شدن `windowFunnel` تابع جمع ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2352)). -- جدید `startsWith` و `endsWith` توابع برای رشته ها ([وادیم پلختینسکی](https://github.com/ClickHouse/ClickHouse/pull/2429)). -- این `numbers()` تابع جدول در حال حاضر اجازه می دهد تا شما را به مشخص افست ([زمستان ژانگ](https://github.com/ClickHouse/ClickHouse/pull/2535)). -- رمز عبور به `clickhouse-client` می توان تعاملی وارد شده است. -- سیاهههای مربوط به سرور هم اکنون می توانید به وبلاگ ارسال می شود ([الکساندر کرشنینیکف](https://github.com/ClickHouse/ClickHouse/pull/2459)). -- پشتیبانی از ورود به لغت نامه ها با یک منبع کتابخانه مشترک ([الکساندر sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). -- پشتیبانی برای سفارشی csv delimiters ([ایوان ژوکوف](https://github.com/ClickHouse/ClickHouse/pull/2263)) -- اضافه شدن `date_time_input_format` تنظیمات. اگر این تنظیم را تغییر دهید `'best_effort'`, ارزش تاریخ ساعت خواهد شد در طیف گسترده ای از فرمت های به عنوان خوانده شده. -- اضافه شدن `clickhouse-obfuscator` ابزار برای مبهم و تاریک کردن داده ها. مثال طریقه استفاده: انتشار داده های مورد استفاده در تست عملکرد. - -#### ویژگی های تجربی: {#experimental-features-2} - -- توانایی محاسبه اضافه شده است `and` استدلال تنها جایی که مورد نیاز هستند ([کشتن از سر ترحم تسارکوا](https://github.com/ClickHouse/ClickHouse/pull/2272)) -- مجموعه کیت به کد بومی در حال حاضر برای برخی از عبارات در دسترس است ([پایوس](https://github.com/ClickHouse/ClickHouse/pull/2277)). - -#### رفع اشکال: {#bug-fixes-20} - -- تکراری دیگر برای پرس و جو با ظاهر `DISTINCT` و `ORDER BY`. -- نمایش داده شد با `ARRAY JOIN` و `arrayFilter` دیگر نتیجه نادرست بازگشت. -- هنگام خواندن یک ستون جداگانه از یک ساختار تو در تو خطایی رخ داد ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). -- ثابت خطا در هنگام تجزیه و تحلیل نمایش داده شد با داشتن بند مانند `HAVING tuple IN (...)`. -- ثابت خطا در هنگام تجزیه و تحلیل نمایش داده شد با نام مستعار بازگشتی. -- ثابت خطا در هنگام خواندن از replacingmergetree با یک بیماری در prewhere فیلتر است که تمام ردیف ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). -- هنگام استفاده از جلسات در رابط اچ تی پی تنظیمات پروفایل کاربر اعمال نشد. -- ثابت چگونه تنظیمات از پارامترهای خط فرمان در خانه کلیک اعمال می شود-محلی. -- کتابخانه مشتری باغ وحش در حال حاضر با استفاده از فاصله جلسه دریافت شده از سرور. -- رفع اشکال در کتابخانه مشتری باغ وحش زمانی که مشتری منتظر پاسخ سرور طولانی تر از ایست. -- هرس ثابت قطعات برای نمایش داده شد با شرایط در ستون های کلیدی پارتیشن ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). -- ادغام در حال حاضر ممکن است پس از `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). -- نقشه برداری نوع در تابع جدول او بی سی ثابت شده است ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2268)). -- مقایسه نوع برای ثابت شده است `DateTime` با و بدون منطقه زمانی ([الکساندر بوچاروف](https://github.com/ClickHouse/ClickHouse/pull/2400)). -- تجزیه نحوی ثابت و قالب بندی از `CAST` اپراتور -- درج ثابت به یک نمایش تحقق برای موتور جدول توزیع شده است ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). -- ثابت شرایط مسابقه در هنگام نوشتن داده ها از `Kafka` موتور به نمایش تحقق ([Yangkuan لیو](https://github.com/ClickHouse/ClickHouse/pull/2448)). -- در از راه دور() تابع جدول ثابت شده است. -- رفتار خروج ثابت از `clickhouse-client` در حالت چند خطی ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). - -#### بهبود: {#improvements-11} - -- وظایف پس زمینه در جداول تکرار در حال حاضر در یک استخر موضوع به جای در موضوعات جداگانه انجام می شود ([سیلو کاراژیا](https://github.com/ClickHouse/ClickHouse/pull/1722)). -- بهبود عملکرد فشرده سازی 2.4. -- تجزیه و تحلیل سریع تر برای نمایش داده شد با تعداد زیادی از می پیوندد و زیر نمایش داده شد. -- کش دی ان اس در حال حاضر به طور خودکار به روز هنگامی که بیش از حد بسیاری از خطاهای شبکه وجود دارد. -- جدول درج دیگر رخ می دهد, اگر وارد یکی از این محقق views امکان پذیر نیست به دلیل آن است بیش از حد بسیاری از قطعات. -- اصلاح اختلاف در شمارنده رویداد `Query`, `SelectQuery` و `InsertQuery`. -- عبارات مانند `tuple IN (SELECT tuple)` مجاز اگر انواع تاپل مطابقت. -- سرور با جداول تکرار می توانید شروع به حتی اگر شما باغ وحش پیکربندی نشده است. -- هنگام محاسبه تعداد هسته های پردازنده در دسترس, محدودیت در گروه های گروه در حال حاضر در نظر گرفته شود ([اتری شارما](https://github.com/ClickHouse/ClickHouse/pull/2325)). -- اضافه شده پیون برای دایرکتوری پیکربندی در فایل پیکربندی سیستم ([میخیل شیریو](https://github.com/ClickHouse/ClickHouse/pull/2421)). - -#### ایجاد تغییرات: {#build-changes-4} - -- کامپایلر جی سی8 را می توان برای ساخت استفاده می شود. -- اضافه شده توانایی برای ساخت llvm از submodule. -- این نسخه از librdkafka کتابخانه به روز شده است برای v0.11.4. -- اضافه شدن توانایی استفاده از کتابخانه سیستم لیبکپویید. نسخه کتابخانه شده است به 0.4.0 به روز شد. -- ثابت ساخت با استفاده از vectorclass کتابخانه ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). -- در حال حاضر تولید فایل برای نینجا به طور پیش فرض (مانند هنگام استفاده از `-G Ninja`). -- اضافه شدن قابلیت استفاده از کتابخانه لیبتاینفو به جای نوشیدن شراب ([جورجی کندراتیف](https://github.com/ClickHouse/ClickHouse/pull/2519)). -- رفع یک درگیری فایل هدر در فدورا پوست دباغی نشده ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-7} - -- حذف فرار در `Vertical` و `Pretty*` فرمت ها و حذف `VerticalRaw` قالب. -- اگر سرور با نسخه 1.1.54388 (یا جدیدتر) و سرور با نسخه های قدیمی تر به طور همزمان در یک پرس و جو توزیع استفاده می شود و پرس و جو است `cast(x, 'Type')` بیان بدون `AS` کلمه کلیدی و کلمه ندارد `cast` در بزرگ, یک استثنا خواهد شد با یک پیام مانند پرتاب `Not found column cast(0, 'UInt8') in block`. تخلیه: به روز رسانی سرور در کل خوشه. - -### انتشار کلیک 1.1.54385, 2018-06-01 {#clickhouse-release-1-1-54385-2018-06-01} - -#### رفع اشکال: {#bug-fixes-21} - -- ثابت خطا که در برخی موارد باعث عملیات باغ وحش برای جلوگیری از. - -### انتشار کلیک 1.1.54383, 2018-05-22 {#clickhouse-release-1-1-54383-2018-05-22} - -#### رفع اشکال: {#bug-fixes-22} - -- ثابت کاهش سرعت صف تکرار اگر یک جدول است بسیاری از کپی. - -### انتشار کلیک 1.1.54381, 2018-05-14 {#clickhouse-release-1-1-54381-2018-05-14} - -#### رفع اشکال: {#bug-fixes-23} - -- ثابت نشت گره در باغ وحش زمانی که خانه رعیتی اتصال به سرور باغ وحش از دست می دهد. - -### ClickHouse انتشار 1.1.54380, 2018-04-21 {#clickhouse-release-1-1-54380-2018-04-21} - -#### ویژگی های جدید: {#new-features-13} - -- تابع جدول اضافه شده است `file(path, format, structure)`. به عنوان مثال خواندن بایت از `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. - -#### بهبود: {#improvements-12} - -- زیرمجموعه ها را می توان در `()` براکت به منظور افزایش خوانایی پرس و جو. به عنوان مثال: `(SELECT 1) UNION ALL (SELECT 1)`. -- ساده `SELECT` نمایش داده شد از `system.processes` جدول در شامل نمی شود `max_concurrent_queries` حد. - -#### رفع اشکال: {#bug-fixes-24} - -- رفتار نادرست ثابت از `IN` اپراتور هنگام انتخاب از `MATERIALIZED VIEW`. -- فیلتر نادرست ثابت توسط شاخص پارتیشن در عبارات مانند `partition_key_column IN (...)`. -- ناتوانی ثابت برای اجرا `OPTIMIZE` پرس و جو در ماکت غیر رهبر اگر `REANAME` بر روی میز انجام شد. -- خطای مجوز هنگام اجرای ثابت شد `OPTIMIZE` یا `ALTER` نمایش داده شد در یک ماکت غیر رهبر. -- انجماد ثابت `KILL QUERY`. -- رفع خطا در کتابخانه مشتری باغ وحش که منجر به از دست دادن ساعت انجماد توزیع صف دی ال و کاهش سرعت در صف تکرار اگر غیر خالی `chroot` پیشوند در پیکربندی باغ وحش استفاده می شود. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-8} - -- پشتیبانی حذف برای عبارات مانند `(a, b) IN (SELECT (a, b))` (شما می توانید بیان معادل استفاده کنید `(a, b) IN (SELECT a, b)`). در نسخه های قبلی, این عبارات منجر به نامشخص `WHERE` فیلتر کردن یا ایجاد خطا. - -### انتشار کلیک 1.1.54378, 2018-04-16 {#clickhouse-release-1-1-54378-2018-04-16} - -#### ویژگی های جدید: {#new-features-14} - -- ورود به سیستم سطح را می توان بدون راه اندازی مجدد سرور تغییر کرده است. -- اضافه شدن `SHOW CREATE DATABASE` پرس و جو. -- این `query_id` می توان به تصویب رسید `clickhouse-client` . -- تنظیمات جدید: `max_network_bandwidth_for_all_users`. -- اضافه شدن پشتیبانی برای `ALTER TABLE ... PARTITION ...` برای `MATERIALIZED VIEW`. -- اطلاعات اضافه شده در مورد اندازه قطعات داده در فرم غیر فشرده در جدول سیستم. -- پشتیبانی از رمزگذاری سرور به سرور برای جداول توزیع شده (`1` در پیکربندی ماکت در ``). -- پیکربندی سطح جدول برای `ReplicatedMergeTree` خانواده به منظور به حداقل رساندن مقدار داده های ذخیره شده در باغ وحش: : `use_minimalistic_checksums_in_zookeeper = 1` -- پیکربندی از `clickhouse-client` اعلان کردن. به طور پیش فرض, نام سرور در حال حاضر خروجی به اعلان. نام صفحه نمایش سرور را می توان تغییر داد. همچنین در ارسال `X-ClickHouse-Display-Name` HTTP header (Kirill Shvakov). -- چند کاما از هم جدا `topics` می توان برای مشخص `Kafka` موتور (توبیاس Adamson) -- هنگامی که یک پرس و جو توسط متوقف `KILL QUERY` یا `replace_running_query` مشتری دریافت می کند `Query was canceled` استثنا به جای یک نتیجه ناقص. - -#### بهبود: {#improvements-13} - -- `ALTER TABLE ... DROP/DETACH PARTITION` نمایش داده شد در مقابل صف تکرار اجرا شود. -- `SELECT ... FINAL` و `OPTIMIZE ... FINAL` می توان حتی زمانی که جدول دارای یک بخش داده واحد استفاده می شود. -- A `query_log` جدول در پرواز دوباره اگر به صورت دستی حذف شد (کریل شواکوف). -- این `lengthUTF8` عملکرد سریعتر اجرا می شود (ژانگ2014). -- بهبود عملکرد درج همزمان در `Distributed` جداول (`insert_distributed_sync = 1`) هنگامی که تعداد بسیار زیادی از خرده ریز وجود دارد. -- سرور می پذیرد `send_timeout` و `receive_timeout` تنظیمات از مشتری و در هنگام اتصال به مشتری اعمال می شود (که در جهت معکوس اعمال می شود: سوکت سرور `send_timeout` به مجموعه `receive_timeout` ارزش دریافت شده از مشتری و بالعکس). -- بازیابی سقوط قوی تر برای درج ناهمزمان به `Distributed` میز -- نوع بازگشت `countEqual` تابع تغییر از `UInt32` به `UInt64` (谢磊). - -#### رفع اشکال: {#bug-fixes-25} - -- ثابت خطا با `IN` هنگامی که سمت چپ عبارت است `Nullable`. -- نتایج صحیح در حال حاضر در هنگام استفاده از تاپل با بازگشت `IN` هنگامی که برخی از اجزای تاپل در شاخص جدول هستند. -- این `max_execution_time` محدود در حال حاضر به درستی کار می کند با نمایش داده شد توزیع شده است. -- خطاهای ثابت هنگام محاسبه اندازه ستون های کامپوزیت در `system.columns` جدول -- هنگام ایجاد یک جدول موقت خطایی رخ داد `CREATE TEMPORARY TABLE IF NOT EXISTS.` -- خطاهای ثابت در `StorageKafka` (\#\#2075) -- سقوط سرور ثابت از استدلال نامعتبر از توابع مجموع خاص. -- ثابت خطا که مانع از `DETACH DATABASE` پرسو جو از توقف وظایف پس زمینه برای `ReplicatedMergeTree` میز -- `Too many parts` دولت کمتر احتمال دارد به اتفاق می افتد در هنگام قرار دادن به نمایش مواد جمع (\#2084). -- دست زدن به بازگشتی اصلاح تعویض در پیکربندی اگر یک تعویض باید توسط جایگزینی دیگر در همان سطح به دنبال. -- اصلاح نحو در فایل ابرداده در هنگام ایجاد یک `VIEW` که با استفاده از یک پرس و جو با `UNION ALL`. -- `SummingMergeTree` در حال حاضر به درستی کار می کند برای جمع ساختارهای داده های تو در تو با یک کلید کامپوزیت. -- ثابت امکان شرایط مسابقه در هنگام انتخاب رهبر برای `ReplicatedMergeTree` میز - -#### ایجاد تغییرات: {#build-changes-5} - -- پشتیبانی ساخت `ninja` به جای `make` و موارد استفاده `ninja` به طور پیش فرض برای انتشار ساختمان. -- بسته تغییر نام داد: `clickhouse-server-base` داخل `clickhouse-common-static`; `clickhouse-server-common` داخل `clickhouse-server`; `clickhouse-common-dbg` داخل `clickhouse-common-static-dbg`. برای نصب استفاده کنید `clickhouse-server clickhouse-client`. بسته با نام های قدیمی هنوز هم در مخازن برای سازگاری بار. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-9} - -- حذف تفسیر خاص از یک عبارت در اگر مجموعه ای در سمت چپ مشخص شده است. قبلا بیان `arr IN (set)` به عنوان تفسیر شد “at least one `arr` element belongs to the `set`”. برای دریافت همان رفتار در نسخه جدید, نوشتن `arrayExists(x -> x IN (set), arr)`. -- استفاده نادرست از گزینه سوکت را غیرفعال کرد `SO_REUSEPORT`, که به اشتباه به طور پیش فرض در کتابخانه کم فعال شد. توجه داشته باشید که در لینوکس دیگر هیچ دلیلی وجود ندارد که به طور همزمان نشانی ها را مشخص کند `::` و `0.0.0.0` for listen – use just `::`, که اجازه می دهد گوش دادن به اتصال هر دو بیش از لیگ4 و ایپو6 (با تنظیمات پیکربندی هسته به طور پیش فرض). شما همچنین می توانید به رفتار از نسخه های قبلی با مشخص برگرداندن `1` در پیکربندی. - -### انتشار کلیک 1.1.54370, 2018-03-16 {#clickhouse-release-1-1-54370-2018-03-16} - -#### ویژگی های جدید: {#new-features-15} - -- اضافه شدن `system.macros` جدول و به روز رسانی خودکار از ماکروها زمانی که فایل پیکربندی تغییر کرده است. -- اضافه شدن `SYSTEM RELOAD CONFIG` پرس و جو. -- اضافه شدن `maxIntersections(left_col, right_col)` تابع جمع, که حداکثر تعداد فواصل به طور همزمان متقاطع گرداند `[left; right]`. این `maxIntersectionsPosition(left, right)` تابع می گرداند ابتدای “maximum” فاصله. ([مایکل فورمور](https://github.com/ClickHouse/ClickHouse/pull/2012)). - -#### بهبود: {#improvements-14} - -- هنگام وارد کردن داده ها در یک `Replicated` جدول, درخواست کمتر به ساخته شده `ZooKeeper` (و بسیاری از خطاهای سطح کاربر از ناپدید شد `ZooKeeper` ورود). -- توانایی ایجاد نام مستعار برای مجموعه داده ها اضافه شده است. مثال: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. - -#### رفع اشکال: {#bug-fixes-26} - -- ثابت `Illegal PREWHERE` خطا هنگام خواندن از جداول ادغام برای `Distributed`میز -- رفع اضافه شده است که به شما اجازه شروع کلیک سرور در ظروف فایل اجرایی فقط 4. -- ثابت شرایط مسابقه در هنگام خواندن از سیستم `system.parts_columns tables.` -- بافر دو حذف در طول یک درج همزمان به یک `Distributed` جدول, که می تواند باعث اتصال به ایست. -- رفع اشکال که باعث انتظار بیش از حد طولانی برای یک ماکت در دسترس نیست قبل از شروع یک `SELECT` پرس و جو. -- تاریخ نادرست ثابت در `system.parts` جدول -- رفع اشکال ساخته شده است که غیر ممکن است برای وارد کردن داده ها در یک `Replicated` جدول اگر `chroot` غیر خالی در پیکربندی بود `ZooKeeper` خوشه خوشه. -- ثابت الگوریتم ادغام عمودی برای خالی `ORDER BY` جدول -- ترمیم توانایی استفاده از لغت نامه در نمایش داده شد به جداول از راه دور, حتی اگر این لغت نامه در سرور درخواست وجود ندارد. این قابلیت در نسخه 1.1.54362 از دست داده بود. -- ترمیم رفتار برای نمایش داده شد مانند `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` هنگامی که در سمت راست از `IN` باید از راه دور استفاده کنید `default.table` به جای یک محلی. این رفتار در نسخه 1.1.54358 شکسته شد. -- حذف غیر اصلی ورود به سیستم سطح خطا از `Not found column ... in block`. - -### انتشار کلیک 1.1.54362, 2018-03-11 {#clickhouse-release-1-1-54362-2018-03-11} - -#### ویژگی های جدید: {#new-features-16} - -- تجمع بدون `GROUP BY` برای یک مجموعه خالی (مانند `SELECT count(*) FROM table WHERE 0`) در حال حاضر در نتیجه با یک ردیف با ارزش تهی برای توابع کل گرداند, در انطباق با استاندارد گذاشتن. برای بازگرداندن رفتار قدیمی (بازگشت به نتیجه خالی), تنظیم `empty_result_for_aggregation_by_empty_set` به 1. -- تبدیل نوع اضافه شده برای `UNION ALL`. نام مستعار مختلف مجاز است `SELECT` موقعیت خود را در `UNION ALL`, در انطباق با استاندارد گذاشتن. -- عبارات دلخواه در پشتیبانی `LIMIT BY` بند. قبلا, تنها ممکن بود به استفاده از ستون ناشی از `SELECT`. -- یک شاخص از `MergeTree` جداول استفاده می شود که `IN` به یک تاپل عبارات از ستون کلید اصلی اعمال می شود. مثال: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` هشدار داده می شود -- اضافه شدن `clickhouse-copier` ابزار برای کپی کردن بین خوشه ها و داده های تغییر شکل (بتا). -- اضافه شده توابع هش سازگار: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. آنها را می توان به عنوان یک sharding کلیدی به منظور کاهش مقدار از ترافیک شبکه در طول پس از آن reshardings. -- اضافه شدن توابع: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. -- اضافه شدن `arrayCumSum` تابع (جوی سانتانا). -- اضافه شدن `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero` و `parseDateTimeBestEffortOrNull` توابع برای خواندن تاریخ ساعت از یک رشته حاوی متن در طیف گسترده ای از فرمت های ممکن. -- داده ها را می توان تا حدی از لغت نامه های خارجی در طول به روز رسانی دوباره (بار فقط سوابق که ارزش این زمینه مشخص شده بیشتر از در دانلود قبلی) (ارسن هاکوبیان). -- اضافه شدن `cluster` تابع جدول. مثال: `cluster(cluster_name, db, table)`. این `remote` تابع جدول می توانید نام خوشه به عنوان اولین استدلال قبول, اگر به عنوان یک شناسه مشخص. -- این `remote` و `cluster` توابع جدول را می توان در `INSERT` نمایش داده شد. -- اضافه شدن `create_table_query` و `engine_full` ستون های مجازی به `system.tables`جدول این `metadata_modification_time` ستون مجازی است. -- اضافه شدن `data_path` و `metadata_path` ستونها به `system.tables`و`system.databases` جداول و اضافه شدن `path` ستون به `system.parts` و `system.parts_columns` میز -- اضافه شدن اطلاعات اضافی در مورد ادغام در `system.part_log` جدول -- یک کلید پارتیشن بندی دلخواه می تواند برای `system.query_log` جدول (کریل شواکوف). -- این `SHOW TABLES` پرس و جو در حال حاضر نیز جداول موقت را نشان می دهد. جداول موقت و `is_temporary` ستون به `system.tables` (ژانگ2014). -- اضافه شده `DROP TEMPORARY TABLE` و `EXISTS TEMPORARY TABLE` نمایش داده شد (ژانگ2014). -- پشتیبانی از `SHOW CREATE TABLE` برای جداول موقت (ژانگ2014). -- اضافه شدن `system_profile` پارامتر پیکربندی برای تنظیمات مورد استفاده توسط فرایندهای داخلی. -- پشتیبانی برای بارگذاری `object_id` به عنوان یک ویژگی در `MongoDB` واژهنامهها (پاول لیتویننکو). -- خواندن `null` به عنوان مقدار پیش فرض هنگام بارگذاری داده ها برای یک فرهنگ لغت خارجی با `MongoDB` منبع (پاول لیتویننکو). -- خواندن `DateTime` ارزش در `Values` فرمت از برچسب زمان یونیکس بدون نقل قول تنها. -- عدم موفقیت در پشتیبانی `remote` توابع جدول برای موارد زمانی که برخی از کپی از دست رفته جدول درخواست. -- تنظیمات پیکربندی را می توان در خط فرمان باطل زمانی که شما اجرا `clickhouse-server`. مثال: `clickhouse-server -- --logger.level=information`. -- اجرا `empty` تابع از یک `FixedString` استدلال: تابع بازده 1 اگر رشته شامل به طور کامل از بایت پوچ (ژانگ2014). -- اضافه شدن `listen_try`پارامتر پیکربندی برای گوش دادن به حداقل یکی از نشانی های گوش دادن بدون ترک, اگر برخی از نشانی ها را نمی توان به گوش (مفید برای سیستم های با پشتیبانی غیر فعال برای لیگ4 یا ایپو6). -- اضافه شدن `VersionedCollapsingMergeTree` موتور جدول. -- پشتیبانی از ردیف ها و انواع عددی دلخواه برای `library` منبع فرهنگ لغت. -- `MergeTree` جداول را می توان بدون یک کلید اولیه استفاده می شود (شما نیاز به مشخص `ORDER BY tuple()`). -- A `Nullable` نوع می تواند باشد `CAST` به یک غیر-`Nullable` نوع اگر استدلال نیست `NULL`. -- `RENAME TABLE` می توان برای انجام `VIEW`. -- اضافه شدن `throwIf` تابع. -- اضافه شدن `odbc_default_field_size` گزینه, که اجازه می دهد تا شما را به گسترش حداکثر اندازه از ارزش لود شده از یک منبع بی سی (به طور پیش فرض, این هست 1024). -- این `system.processes` جدول و `SHOW PROCESSLIST` در حال حاضر `is_cancelled` و `peak_memory_usage` ستون ها - -#### بهبود: {#improvements-15} - -- محدودیت ها و سهمیه بندی در نتیجه دیگر به داده های متوسط برای اعمال `INSERT SELECT` نمایش داده شد و یا برای `SELECT` subqueries. -- باعث کاذب کمتر از `force_restore_data` هنگام چک کردن وضعیت `Replicated` جداول زمانی که سرور شروع می شود. -- اضافه شدن `allow_distributed_ddl` انتخاب -- توابع نامشخص در عبارات برای مجاز نیست `MergeTree` کلید های جدول. -- پروندهها با جایگزینی از `config.d` دایرکتوری ها به ترتیب حروف الفبا لود می شود. -- بهبود عملکرد `arrayElement` تابع در مورد یک مجموعه چند بعدی ثابت با مجموعه ای خالی به عنوان یکی از عناصر. مثال: `[[1], []][x]`. -- سرور شروع می شود سریع تر در حال حاضر در هنگام استفاده از فایل های پیکربندی با تعویض بسیار بزرگ (به عنوان مثال, لیست بسیار زیادی از شبکه های اینترنتی). -- هنگامی که در حال اجرا یک پرس و جو, جدول توابع ارزش اجرا یک بار. قبلا, `remote` و `mysql` جدول ارزش توابع پرس و جو همان دو بار انجام برای بازیابی ساختار جدول از یک سرور از راه دور. -- این `MkDocs` ژنراتور مستندات استفاده شده است. -- هنگامی که شما سعی می کنید یک ستون جدول را حذف کنید که `DEFAULT`/`MATERIALIZED` عبارات از ستون های دیگر بستگی دارد, یک استثنا پرتاب می شود (ژانگ2014). -- اضافه شدن توانایی تجزیه یک خط خالی در فرمت های متن به عنوان شماره 0 برای `Float` انواع داده ها. این ویژگی قبلا در دسترس بود اما در نسخه 1.1.54342 از دست داده بود. -- `Enum` مقادیر را می توان در استفاده `min`, `max`, `sum` و برخی دیگر توابع. در این موارد با استفاده از آن مربوط به مقادیر عددی. این ویژگی قبلا در دسترس بود اما از دست رفته در انتشار 1.1.54337. -- اضافه شده `max_expanded_ast_elements` برای محدود کردن اندازه از اس تی پس از نام مستعار به صورت بازگشتی در حال گسترش است. - -#### رفع اشکال: {#bug-fixes-27} - -- ثابت مواردی که غیر ضروری ستون حذف شده از subqueries در خطا یا حذف نشده از subqueries حاوی `UNION ALL`. -- رفع اشکال در ادغام برای `ReplacingMergeTree` میز -- درج همزمان ثابت در `Distributed` جداول (`insert_distributed_sync = 1`). -- پیش فرض ثابت برای استفاده های خاص از `FULL` و `RIGHT JOIN` با ستون تکراری در کارخانه های فرعی. -- پیش فرض ثابت برای استفاده های خاص از `replace_running_query` و `KILL QUERY`. -- ثابت منظور از `source` و `last_exception` ستون ها در `system.dictionaries` جدول -- رفع اشکال زمانی که `DROP DATABASE` پرس و جو فایل را با ابرداده را حذف کنید. -- ثابت `DROP DATABASE` پرسوجو برای `Dictionary` پایگاه داده. -- ثابت دقت کم `uniqHLL12` و `uniqCombined` توابع برای کارتنیت بیشتر از 100 میلیون مورد (الکس بوچاروف). -- ثابت محاسبه مقادیر پیش فرض ضمنی در صورت لزوم به طور همزمان محاسبه عبارات صریح و روشن به طور پیش فرض در `INSERT` نمایش داده شد (ژانگ2014). -- ثابت یک مورد نادر زمانی که یک پرس و جو به یک `MergeTree` جدول نمی تواند به پایان برسد (فکس ایکس سی). -- ثابت تصادف رخ داده است که در حال اجرا `CHECK` پرسوجو برای `Distributed` جداول اگر تمام خرده ریز محلی هستند (فکس.اطلاعات دقیق -- ثابت رگرسیون عملکرد کمی با توابع است که با استفاده از عبارات منظم. -- ثابت رگرسیون عملکرد در هنگام ایجاد مجموعه های چند بعدی از عبارات پیچیده است. -- ثابت یک اشکال است که می تواند اضافی `FORMAT` بخش به نظر می رسد در یک `.sql` فایل با ابرداده. -- رفع اشکال که باعث `max_table_size_to_drop` محدود به درخواست در هنگام تلاش برای حذف یک `MATERIALIZED VIEW` با نگاهی به یک جدول به صراحت مشخص. -- ناسازگاری ثابت با مشتریان قدیمی (مشتریان قدیمی گاهی اوقات داده ها را با `DateTime('timezone')` نوع, که درک نمی کنند). -- رفع اشکال در هنگام خواندن `Nested` عناصر ستون سازه هایی که با استفاده از اضافه شد `ALTER` اما این برای پارتیشن های قدیمی خالی است, زمانی که شرایط را برای این ستون ها به نقل مکان کرد `PREWHERE`. -- رفع اشکال هنگام فیلتر کردن جداول توسط مجازی `_table` ستون در نمایش داده شد به `Merge` میز -- رفع اشکال در هنگام استفاده از `ALIAS` ستونها در `Distributed` میز -- رفع اشکال ساخته شده است که تلفیقی پویا غیر ممکن است برای نمایش داده شد با توابع کل از `quantile` خانواده -- ثابت شرایط مسابقه در خط لوله اجرای پرس و جو که در موارد بسیار نادر رخ داده است در هنگام استفاده از `Merge` جداول با تعداد زیادی از جداول, و در هنگام استفاده از `GLOBAL` subqueries. -- تصادف را هنگام عبور از اندازه های مختلف به یک ثابت کرد `arrayReduce` تابع در هنگام استفاده از توابع کل از استدلال های متعدد. -- ممنوع استفاده از نمایش داده شد با `UNION ALL` در یک `MATERIALIZED VIEW`. -- خطا در هنگام مقدار دهی اولیه از ثابت `part_log` جدول سیستم زمانی که سرور شروع می شود (به طور پیش فرض, `part_log` غیر فعال است). - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-10} - -- حذف `distributed_ddl_allow_replicated_alter` انتخاب این رفتار به طور پیش فرض فعال. -- حذف `strict_insert_defaults` تنظیمات. اگر شما با استفاده از این قابلیت, ارسال به `clickhouse-feedback@yandex-team.com`. -- حذف `UnsortedMergeTree` موتور - -### انتشار کلیک 1.1.54343, 2018-02-05 {#clickhouse-release-1-1-54343-2018-02-05} - -- اضافه شدن پشتیبانی از ماکرو برای تعریف نام خوشه در نمایش داده شد ددل توزیع و سازنده جداول توزیع شده است: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. -- در حال حاضر نمایش داده شد مانند `SELECT ... FROM table WHERE expr IN (subquery)` با استفاده از پردازش `table` نمایه. -- پردازش تکراری بهبود یافته در هنگام قرار دادن به جداول تکرار, به طوری که دیگر کم کردن سرعت اجرای صف تکرار. - -### انتشار کلیک 1.1.54342, 2018-01-22 {#clickhouse-release-1-1-54342-2018-01-22} - -این نسخه شامل رفع اشکال برای نسخه قبلی 1.1.54337: - -- ثابت رگرسیون در 1.1.54337: اگر کاربر به طور پیش فرض دسترسی خوانده است, سپس سرور حاضر به راه اندازی با پیام `Cannot create database in readonly mode`. -- ثابت رگرسیون در 1.1.54337: در سیستم های با سیستم, سیاهههای مربوط همیشه به سای لاگ صرف نظر از پیکربندی نوشته شده; اسکریپت دیده بان هنوز هم با استفاده از اینیت.د -- ثابت رگرسیون در 1.1.54337: پیکربندی پیش فرض اشتباه در تصویر کارگر بارانداز. -- ثابت nondeterministic رفتار graphitemergetree (شما می توانید آن را در ورود به سیستم پیام `Data after merge is not byte-identical to the data on another replicas`). -- رفع اشکال که ممکن است منجر به ادغام متناقض پس از بهینه سازی پرس و جو به تکرار جداول (شما ممکن است در پیام ورود به سیستم را ببینید `Part ... intersects the previous part`). -- جداول بافر در حال حاضر به درستی کار زمانی که ستون محقق در جدول مقصد وجود دارد (توسط ژانگ2014). -- رفع اشکال در اجرای پوچ. - -### انتشار کلیک 1.1.54337, 2018-01-18 {#clickhouse-release-1-1-54337-2018-01-18} - -#### ویژگی های جدید: {#new-features-17} - -- اضافه شدن پشتیبانی برای ذخیره سازی از مجموعه های چند بعدی و تاپل (`Tuple` نوع داده) در جداول. -- پشتیبانی از توابع جدول برای `DESCRIBE` و `INSERT` نمایش داده شد. اضافه شدن پشتیبانی برای کارخانه های فرعی در `DESCRIBE`. مثالها: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. پشتیبانی از `INSERT INTO TABLE` علاوه بر `INSERT INTO`. -- پشتیبانی بهبود یافته برای مناطق زمانی. این `DateTime` نوع داده را می توان با منطقه زمانی است که برای تجزیه و قالب بندی در فرمت های متنی استفاده مشروح. مثال: `DateTime('Europe/Moscow')`. هنگامی که زمان در توابع برای مشخص `DateTime` استدلال, نوع بازگشت منطقه زمانی پیگیری, و ارزش نمایش داده خواهد شد به عنوان انتظار می رود. -- اضافه شدن توابع `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. این `toRelativeHour`/`Minute`/`Second` توابع می توانند یک مقدار از نوع را `Date` به عنوان یک استدلال. این `now` نام تابع حساس به حروف است. -- اضافه شدن `toStartOfFifteenMinutes` تابع (کریل شواکوف). -- اضافه شدن `clickhouse format` ابزار برای قالب بندی نمایش داده شد. -- اضافه شدن `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` قالب. فایل های طرح را می توان تنها در دایرکتوری مشخص شده واقع شده است. -- اضافه شدن پشتیبانی برای تعویض پیکربندی (`incl` و `conf.d`) برای پیکربندی لغت نامه ها و مدل های خارجی (پاول یاکونین). -- اضافه شدن یک ستون با اسناد و مدارک برای `system.settings` جدول (Kirill Shvakov). -- اضافه شدن `system.parts_columns` جدول با اطلاعات در مورد اندازه ستون در هر بخش داده ها از `MergeTree` میز -- اضافه شدن `system.models` جدول با اطلاعات در مورد لود `CatBoost` مدل های یادگیری ماشین. -- اضافه شدن `mysql` و `odbc` عملکرد جدول و متناظر `MySQL` و `ODBC` موتورهای جدول برای دسترسی به پایگاه داده از راه دور. این قابلیت در مرحله بتا است. -- اضافه شدن امکان به تصویب یک استدلال از نوع `AggregateFunction` برای `groupArray` تابع جمع (بنابراین شما می توانید مجموعه ای از کشورهای برخی از تابع جمع ایجاد). -- محدودیت حذف در ترکیب های مختلف از ترکیب تابع جمع. مثلا, شما می توانید استفاده کنید `avgForEachIf` و همچنین `avgIfForEach` توابع مجموع, که رفتارهای مختلف. -- این `-ForEach` ترکیب تابع مجموع برای مورد توابع مجموع استدلال های متعدد گسترش یافته است. -- اضافه شدن پشتیبانی از توابع کل `Nullable` استدلال حتی برای موارد زمانی که تابع غیر گرداند-`Nullable` نتیجه (اضافه شده با سهم سیلو کاروجا). مثال: `groupArray`, `groupUniqArray`, `topK`. -- اضافه شدن `max_client_network_bandwidth` برای `clickhouse-client` (Kirill Shvakov). -- کاربران با `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). -- اضافه شدن پشتیبانی برای استفاده از مصرف کنندگان متعدد با `Kafka` موتور گزینه های پیکربندی گسترده برای `Kafka` (Marek Vavruša). -- اضافه شدن `intExp3` و `intExp4` توابع. -- اضافه شدن `sumKahan` تابع جمع. -- اضافه شده به \* شماره\* توابع پرنده, جایی که \* شماره \* یک نوع عددی است. -- اضافه شدن پشتیبانی برای `WITH` جملات برای `INSERT SELECT` پرس و جو (نویسنده: ژانگ2014). -- تنظیمات اضافه شده: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. به خصوص این تنظیمات برای دانلود قطعات داده ها برای تکرار استفاده می شود. تغییر این تنظیمات اجازه می دهد تا برای عدم موفقیت سریع تر اگر شبکه غیرمنتظره است. -- اضافه شدن پشتیبانی برای `ALTER` برای جداول نوع `Null` هشدار داده می شود -- این `reinterpretAsString` تابع برای تمام انواع داده ها که به روشنی در حافظه ذخیره می شود گسترش یافته است. -- اضافه شدن `--silent` گزینه ای برای `clickhouse-local` ابزار. این سرکوب چاپ اطلاعات اجرای پرس و جو در خ. -- اضافه شدن پشتیبانی برای خواندن مقادیر نوع `Date` از متن در قالب ای که ماه و / یا روز از ماه مشخص شده است با استفاده از یک رقم واحد به جای دو رقم (پرنده ایموس). - -#### بهینه سازی عملکرد: {#performance-optimizations} - -- عملکرد بهبود یافته از توابع کل `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` از استدلال رشته. -- عملکرد بهبود یافته از توابع `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. -- بهبود عملکرد تجزیه و قالب بندی `Date` و `DateTime` ارزش نوع در قالب متن. -- بهبود عملکرد و دقت تجزیه اعداد ممیز شناور. -- کاهش استفاده از حافظه برای `JOIN` در مورد زمانی که قطعات چپ و راست ستون با نام یکسان است که در موجود نیست `USING` . -- عملکرد بهبود یافته از توابع کل `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` با کاهش ثبات محاسباتی. توابع قدیمی تحت نام در دسترس هستند `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. - -#### رفع اشکال: {#bug-fixes-28} - -- ثابت data deduplication را پس از اجرا `DROP` یا `DETACH PARTITION` پرس و جو. در نسخه های قبلی, حذف یک پارتیشن و قرار دادن داده های مشابه دوباره کار نمی کند چرا بلوک قرار داده تکراری در نظر گرفته شد. -- رفع اشکال که می تواند به تفسیر نادرست از منجر شود `WHERE` بند برای `CREATE MATERIALIZED VIEW` نمایش داده شد با `POPULATE` . -- رفع اشکال در استفاده از `root_path` پارامتر در `zookeeper_servers` پیکربندی. -- نتایج غیر منتظره ثابت از عبور از `Date` نشانوند به `toStartOfDay` . -- ثابت `addMonths` و `subtractMonths` توابع و حساب برای `INTERVAL n MONTH` در مواردی که نتیجه سال گذشته است. -- اضافه شدن پشتیبانی از دست رفته برای `UUID` نوع داده برای `DISTINCT` , `JOIN` و `uniq` توابع جمع و لغت نامه های خارجی (اوگنی ایوانف). پشتیبانی از `UUID` هنوز ناقصه -- ثابت `SummingMergeTree` رفتار در مواردی که ردیف خلاصه به صفر است. -- رفع مختلف برای `Kafka` engine (Marek Vavruša). -- رفتار نادرست ثابت از `Join` موتور جدول (پرنده ایموس). -- رفتار تخصیص نادرست ثابت تحت بورس و سیستم عامل ایکس. -- این `extractAll` تابع در حال حاضر مسابقات خالی پشتیبانی می کند. -- ثابت خطا که استفاده از مسدود `libressl` به جای `openssl` . -- ثابت `CREATE TABLE AS SELECT` پرس و جو از جداول موقت. -- ثابت غیر atomicity از به روز رسانی تکرار صف. این می تواند منجر به کپی بودن از همگام سازی تا سرور ری استارت. -- سرریز ممکن ثابت در `gcd` , `lcm` و `modulo` (`%` اپراتور) (ماکس اسکروخد). -- `-preprocessed` فایل ها در حال حاضر پس از تغییر ایجاد شده است `umask` (`umask` را می توان در پیکربندی تغییر). -- رفع اشکال در چک پس زمینه از قطعات (`MergeTreePartChecker` )هنگام استفاده از یک کلید پارتیشن سفارشی . -- تجزیه ثابت از تاپل (ارزش های `Tuple` نوع داده) در فرمت های متن. -- پیام های خطا بهبود یافته در مورد انواع ناسازگار منتقل شده به `multiIf` , `array` و برخی دیگر توابع. -- پشتیبانی دوباره طراحی شده برای `Nullable` انواع. اشکالات ثابت که ممکن است به یک تصادف سرور منجر شود. ثابت تقریبا تمام اشکالات دیگر مربوط به `NULL` پشتیبانی: نادرست نوع تبدیل در وارد کردن را انتخاب کنید کافی برای حمایت از Nullable در داشتن و PREWHERE, `join_use_nulls` حالت, انواع قابل ابطال به عنوان استدلال `OR` اپراتور و غیره -- اشکالات مختلف ثابت مربوط به معانی داخلی انواع داده ها. نمونه: جمع غیر ضروری از `Enum` فیلدهای تایپ شده `SummingMergeTree` ; تراز دلخواه `Enum` انواع در `Pretty` فرمت, و غیره. -- چک سختگیرانه تر برای ترکیب مجاز از ستون کامپوزیت. -- ثابت سرریز در هنگام تعیین یک پارامتر بسیار بزرگ برای `FixedString` نوع داده. -- رفع اشکال در `topK` تابع جمع در یک مورد عمومی. -- اضافه شدن چک از دست رفته برای برابری اندازه مجموعه ای در استدلال از انواع ن-عرایی از توابع کل با `-Array` ترکیب کننده. -- رفع اشکال در `--pager` برای `clickhouse-client` (نویسنده: کس1322). -- ثابت دقت از `exp10` تابع. -- ثابت رفتار `visitParamExtract` تابع برای انطباق بهتر با اسناد و مدارک. -- ثابت تصادف زمانی که انواع داده های نادرست مشخص شده است. -- رفتار را ثابت کرد `DISTINCT` در مورد زمانی که همه ستون ثابت هستند. -- قالب بندی پرس و جو ثابت در مورد استفاده از `tupleElement` تابع با یک عبارت ثابت پیچیده به عنوان شاخص عنصر تاپل. -- رفع اشکال در `Dictionary` جداول برای `range_hashed` واژهنامهها. -- رفع اشکال که منجر به ردیف بیش از حد در نتیجه `FULL` و `RIGHT JOIN` (پرنده ایموس). -- ثابت سقوط سرور در هنگام ایجاد و از بین بردن فایل های موقت در `config.d` دایرکتوری در طول بازنگری پیکربندی. -- ثابت `SYSTEM DROP DNS CACHE` پرس و جو: کش سرخ شد اما نشانی از گره های خوشه ای به روز شد. -- رفتار را ثابت کرد `MATERIALIZED VIEW` پس از اجرای `DETACH TABLE` for the table under the view (Marek Vavruša). - -#### بهبود ساخت: {#build-improvements-4} - -- این `pbuilder` ابزار برای ساخت استفاده می شود. روند ساخت تقریبا به طور کامل مستقل از محیط میزبان ساخت است. -- ساخت تک برای نسخه های سیستم عامل های مختلف استفاده می شود. بسته ها و فایل های باینری سازگار با طیف گسترده ای از سیستم های لینوکس ساخته شده است. -- اضافه شدن `clickhouse-test` بسته این می تواند مورد استفاده قرار گیرد برای اجرای تست های کاربردی. -- قطار سریع السیر منبع هم اکنون می توانید به مخزن منتشر شود. این می تواند مورد استفاده قرار گیرد به تولید مثل ساخت بدون استفاده از گیتهاب. -- اضافه شده ادغام محدود با تراویس سی. با توجه به محدودیت در زمان ساخت در تراویس, تنها ساخت اشکال زدایی تست شده است و یک زیر مجموعه محدود از تست اجرا می شوند. -- اضافه شدن پشتیبانی برای `Cap'n'Proto` در ساخت به طور پیش فرض. -- فرمت منابع اسناد را تغییر داد `Restricted Text` به `Markdown`. -- اضافه شدن پشتیبانی برای `systemd` (ولادیمیر اسمیرنوف). این است که به طور پیش فرض به دلیل ناسازگاری با برخی از تصاویر سیستم عامل غیر فعال است و می تواند به صورت دستی فعال کنید. -- برای تولید کد پویا, `clang` و `lld` به جاسازی شده `clickhouse` دودویی. همچنین می توانند به عنوان `clickhouse clang` و `clickhouse lld` . -- استفاده از پسوندهای گنو از کد حذف شده است. فعال کردن `-Wextra` انتخاب هنگام ساخت با `clang` به طور پیش فرض است `libc++` به جای `libstdc++`. -- استخراج شده `clickhouse_parsers` و `clickhouse_common_io` کتابخانه ها برای سرعت بخشیدن به ایجاد ابزارهای مختلف. - -#### تغییرات ناسازگار به عقب: {#backward-incompatible-changes-11} - -- قالب برای علامت در `Log` جداول نوع که شامل `Nullable` ستون در راه ناسازگار به عقب تغییر یافت. اگر شما این جداول, شما باید به تبدیل `TinyLog` قبل از شروع نسخه سرور جدید تایپ کنید. برای انجام این کار جایگزین کنید `ENGINE = Log` با `ENGINE = TinyLog` در مربوطه `.sql` پرونده در `metadata` فهرست راهنما. اگر جدول شما ندارد `Nullable` ستون و یا اگر نوع جدول خود را نمی `Log` پس نیازی نیست کاری بکنی -- حذف `experimental_allow_extended_storage_definition_syntax` تنظیمات. در حال حاضر این ویژگی به طور پیش فرض فعال است. -- این `runningIncome` تابع به تغییر نام داد `runningDifferenceStartingWithFirstvalue` برای جلوگیری از سردرگمی. -- حذف `FROM ARRAY JOIN arr` نحو زمانی که مجموعه اضافه کردن به طور مستقیم پس از با هیچ جدول مشخص (پرنده ایموس). -- حذف `BlockTabSeparated` فرمت که صرفا برای اهداف تظاهرات مورد استفاده قرار گرفت. -- فرمت دولت برای توابع کل تغییر `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. اگر شما ایالات از این توابع کل در جداول ذخیره شده اند (با استفاده از `AggregateFunction` نوع داده و یا نمایش تحقق با کشورهای مربوطه), لطفا به ارسال clickhouse-feedback@yandex-team.com. -- در نسخه های سرور قبلی یک ویژگی مستند نشده وجود داشت: اگر یک تابع جمع شده به پارامترها بستگی داشته باشد هنوز هم می توانید بدون پارامتر در نوع داده قابلیت کارکرد مشخص کنید. مثال: `AggregateFunction(quantiles, UInt64)` به جای `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. این ویژگی از دست داده بود. ما قصد داریم دوباره در نسخه های بعدی پشتیبانی کنیم. -- انواع داده شمارشی را نمی توان در توابع جمع دقیقه/حداکثر استفاده می شود. این توانایی خواهد شد در نسخه بعدی بازگشت. - -#### لطفا توجه داشته باشید در هنگام به روز رسانی: {#please-note-when-upgrading} - -- هنگام انجام یک به روز رسانی نورد در یک خوشه, در نقطه ای که برخی از کپی در حال اجرا هستند نسخه های قدیمی از تاتر و برخی در حال اجرا هستند نسخه جدید, تکرار است به طور موقت متوقف و پیام `unknown parameter 'shard'` به نظر می رسد در ورود به سیستم. تکرار ادامه خواهد داد پس از همه کپی از خوشه به روز می شوند. -- اگر نسخه های مختلف از تاتر در حال اجرا بر روی سرورهای خوشه, ممکن است که نمایش داده شد توزیع با استفاده از توابع زیر نتایج نادرست داشته باشد: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. شما باید تمام گره های خوشه ای به روز رسانی. - -## [تغییرات برای 2017](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2017.md) {#changelog-for-2017} diff --git a/docs/fa/whats_new/changelog/2019.md b/docs/fa/whats_new/changelog/2019.md deleted file mode 100644 index 60e34307c25..00000000000 --- a/docs/fa/whats_new/changelog/2019.md +++ /dev/null @@ -1,2074 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 77 -toc_title: '2019' ---- - -## انتشار کلیک و19. 17 {#clickhouse-release-v19-17} - -### ClickHouse انتشار v19.17.6.36, 2019-12-27 {#clickhouse-release-v19-17-6-36-2019-12-27} - -#### رفع اشکال {#bug-fix} - -- سرریز بافر بالقوه ثابت در حالت فشرده خارج. کاربر مخرب می تواند داده های فشرده ساخته شده است که می تواند باعث به عنوان خوانده شده پس از بافر منتقل می کند. این موضوع توسط الدار زیتوف از تیم امنیت اطلاعات یاندکس یافت شد. [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت سقوط سرور ممکن است (`std::terminate`) هنگامی که سرور نمی تواند ارسال و یا ارسال داده ها در فرمت جسون یا میلی لیتر با ارزش از نوع داده رشته (که نیاز به اعتبار سنجی-8) و یا زمانی که فشرده سازی داده ها نتیجه با الگوریتم بروتلی و یا در برخی موارد نادر دیگر. [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت لغت نامه با منبع از یک clickhouse `VIEW` در حال حاضر خواندن چنین واژهنامهها خطا ایجاد نمی کند `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- ثابت چک کردن اگر یک مشتری میزبان مجاز است با host\_regexp مشخص شده در کاربران.. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([ویتالی بارانو](https://github.com/vitlibar)) -- `RENAME TABLE` برای یک جدول توزیع در حال حاضر تغییر نام پوشه حاوی داده های درج شده قبل از ارسال به خرده ریز. این رفع یک موضوع را با تغییر نام های پی در پی `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([تاولوبیکس](https://github.com/tavplubix)) -- `range_hashed` واژهنامهها خارجی ایجاد شده توسط دی ال نمایش داده شد در حال حاضر اجازه می دهد محدوده از انواع عددی دلخواه. [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([الساپین](https://github.com/alesapin)) -- ثابت `INSERT INTO table SELECT ... FROM mysql(...)` تابع جدول. [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت segfault در `INSERT INTO TABLE FUNCTION file()` در حالی که قرار دادن به یک فایل که وجود ندارد. در حال حاضر در این مورد فایل ایجاد می شود و سپس قرار دادن پردازش می شود. [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- خطای بیت مپ ثابت زمانی که متقاطع بیت مپ جمع و بیت مپ اسکالر. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([یو هوانگ](https://github.com/moon03432)) -- ثابت زمانی که segfault `EXISTS` پرس و جو بدون استفاده شد `TABLE` یا `DICTIONARY` مقدماتی, درست مثل `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نوع بازگشت ثابت برای توابع `rand` و `randConstant` در صورت بحث باطل. در حال حاضر توابع همیشه بازگشت `UInt32` و هرگز `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- ثابت `DROP DICTIONARY IF EXISTS db.dict` در حال حاضر استثنا پرتاب نمی کند اگر `db` وجود نداره [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([ویتالی بارانو](https://github.com/vitlibar)) -- اگر یک جدول به دلیل سقوط سرور به طور کامل کاهش یافته است, سرور سعی خواهد کرد برای بازگرداندن و بارگذاری [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت پرس و جو تعداد بی اهمیت برای یک جدول توزیع اگر بیش از دو میز محلی سفال وجود دارد. [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- اشکال ثابت که منجر به یک مسابقه داده در db::blockstreamprofileinfo::calculaterowsbeforelimit() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([الکساندر کازاکوف](https://github.com/Akazz)) -- ثابت `ALTER table MOVE part` اعدام بلافاصله پس از ادغام بخش مشخص, که می تواند باعث حرکت بخشی که بخش مشخص شده به هم ادغام شدند. در حال حاضر به درستی حرکت می کند بخش مشخص شده است. [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- عبارات برای لغت نامه را می توان به عنوان رشته در حال حاضر مشخص شده است. این بسیار مفید است برای محاسبه ویژگی های در حالی که استخراج داده ها از غیر clickhouse منابع به دلیل آن اجازه می دهد تا به استفاده از غیر clickhouse نحو برای آن دسته از عبارات. [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([الساپین](https://github.com/alesapin)) -- ثابت یک مسابقه بسیار نادر در `clickhouse-copier` به دلیل سرریز در زکسید. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([هشدار داده می شود](https://github.com/dingxiangfei2009)) -- رفع اشکال زمانی که پس از پرس و جو شکست خورده (با توجه به “Too many simultaneous queries” به عنوان مثال) این اطلاعات جداول خارجی را نمی خواند و - درخواست بعدی این اطلاعات را به عنوان ابتدای پرس و جو بعدی تفسیر می کند که باعث خطا می شود `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([ازات خوژین](https://github.com/azat)) -- اجتناب از اختلاف پوچ پس از “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([ازات خوژین](https://github.com/azat)) -- بازگرداندن پشتیبانی از تمام مناطق ایکو, اضافه کردن توانایی به درخواست تلفیقی برای عبارات ثابت و اضافه کردن نام زبان به سیستم.collations جدول. [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([الساپین](https://github.com/alesapin)) -- تعداد جریان برای خواندن از `StorageFile` و `StorageHDFS` در حال حاضر محدود, برای جلوگیری از بیش از حد حافظه. [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([الساپین](https://github.com/alesapin)) -- ثابت `CHECK TABLE` پرسوجو برای `*MergeTree` جداول بدون کلید. [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([الساپین](https://github.com/alesapin)) -- حذف تعداد جهش از یک نام بخشی در صورتی که هیچ جهش وجود دارد. این حذف بهبود سازگاری با نسخه های قدیمی تر. [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([الساپین](https://github.com/alesapin)) -- رفع اشکال که جهش برای برخی از قطعات متصل به دلیل انحراف خود قلم بزرگتر از نسخه جهش جدول. [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([ژیچنگ یو](https://github.com/yuzhichang)) -- اجازه شروع سرور با کپی کار برکنار شده از قطعات پس از حرکت به دستگاه دیگر. [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- خطا را ثابت کرد “Sizes of columns doesn’t match” که ممکن است در هنگام استفاده از ستون تابع جمع به نظر می رسد. [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([بوریس گرانویو](https://github.com/bgranvea)) -- در حال حاضر یک استثنا خواهد شد در صورت استفاده با روابط در کنار محدودیت های پرتاب. و در حال حاضر امکان استفاده از بالا با محدودیت توسط. [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- رفع بارگذاری مجدد فرهنگ لغت در صورتی که `invalidate_query` که متوقف به روز رسانی و برخی از استثنا در به روز رسانی قبلی تلاش می کند. [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([الساپین](https://github.com/alesapin)) - -### ClickHouse انتشار v19.17.4.11, 2019-11-22 {#clickhouse-release-v19-17-4-11-2019-11-22} - -#### تغییر ناسازگار به عقب {#backward-incompatible-change} - -- با استفاده از ستون به جای اس تی برای ذخیره نتایج زیرخاکری اسکالر برای عملکرد بهتر است. تنظیم `enable_scalar_subquery_optimization` در 19.17 اضافه شد و به طور پیش فرض فعال شد. این منجر به اشتباهات مانند [این](https://github.com/ClickHouse/ClickHouse/issues/7851) در طی ارتقا به 19.17.2 یا 19.17.3 از نسخه های قبلی است. این تنظیم به طور پیش فرض فعال در 19.17.4 را ممکن است به روز رسانی از 19.16 و نسخه های قدیمی تر و بدون خطا. [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([ایموس پرنده](https://github.com/amosbird)) - -#### ویژگی جدید {#new-feature} - -- اضافه کردن توانایی برای ایجاد لغت نامه با پرس و جو ددل. [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([الساپین](https://github.com/alesapin)) -- ساخت `bloom_filter` نوع حمایت از شاخص `LowCardinality` و `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- افزودن تابع `isValidJSON` برای بررسی رشته گذشت که جانسون معتبر است. [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([ولادیمیر](https://github.com/Vdimir)) -- پیاده سازی `arrayCompact` تابع [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([یادداشت](https://github.com/Joeywzr)) -- تابع ایجاد شده `hex` برای اعداد اعشاری. این کار مانند `hex(reinterpretAsString())` اما صفر بایت گذشته را حذف کنید. [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([میخیل کوروتف](https://github.com/millb)) -- افزودن `arrayFill` و `arrayReverseFill` توابع که عناصر را با عناصر دیگر در جلو/عقب در مجموعه جایگزین می کنند. [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([هکز](https://github.com/hczhcz)) -- افزودن `CRC32IEEE()`/`CRC64()` پردازشگر پشتیبانی شده: [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([ازات خوژین](https://github.com/azat)) -- پیاده سازی `char` عملکرد شبیه به یک در [خروجی زیر](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- افزودن `bitmapTransform` تابع. این مجموعه ای از ارزش ها را در بیت مپ به مجموعه ای دیگر از ارزش ها تبدیل می کند و نتیجه یک بیت مپ جدید است [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([ژیچنگ یو](https://github.com/yuzhichang)) -- پیادهسازی شده `javaHashUTF16LE()` تابع [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([ایشیمب](https://github.com/achimbab)) -- افزودن `_shard_num` ستون مجازی برای موتور توزیع شده [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([ازات خوژین](https://github.com/azat)) - -#### ویژگی تجربی {#experimental-feature} - -- پشتیبانی از پردازنده (خط لوله اجرای پرس و جو جدید) در `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -#### رفع اشکال {#bug-fix-1} - -- رفع شناور نادرست تجزیه در `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع بن بست نادر است که می تواند رخ دهد که ردیاب را فعال کنید. [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([فیلیمونف](https://github.com/filimonov)) -- جلوگیری از تکرار پیام در هنگام تولید جدول کافکا دارای هر گونه رزومه انتخاب از [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([ایوان](https://github.com/abyss7)) -- پشتیبانی از `Array(LowCardinality(Nullable(String)))` داخل `IN`. برطرف [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([ایشیمب](https://github.com/achimbab)) -- اضافه کردن سیستم های انتقال مواد از `SQL_TINYINT` و `SQL_BIGINT`, و رفع دست زدن به `SQL_FLOAT` انواع منبع داده در اد بی سی پل. [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([دنیس گلازاشف](https://github.com/traceon)) -- رفع تجمع (`avg` و تعداد کمی) روی ستونهای دهدهی خالی [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([اندری کونیایف](https://github.com/akonyaev90)) -- ثابت `INSERT` به توزیع با `MATERIALIZED` ستونها [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([ازات خوژین](https://github.com/azat)) -- ساخت `MOVE PARTITION` کار اگر برخی از قسمت های پارتیشن در حال حاضر بر روی دیسک مقصد یا حجم [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اشکال ثابت با لینک های سخت عدم در طول جهش در ایجاد می شود `ReplicatedMergeTree` در تنظیمات چند دیسک. [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع اشکال با یک جهش در ادغام زمانی که تمام قسمت بدون تغییر باقی می ماند و بهترین فضا است که بر روی دیسک دیگر یافت می شود [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اشکال ثابت با `keep_free_space_ratio` از پیکربندی دیسکها قابل خواندن نیست [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع اشکال با جدول شامل تنها `Tuple` ستون ها یا ستون ها با مسیرهای پیچیده. رفع [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([الساپین](https://github.com/alesapin)) -- حافظه را برای موتور بافر در حداکثر\_موری\_سیاژ حساب نکنید [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([ازات خوژین](https://github.com/azat)) -- رفع استفاده از علامت نهایی در `MergeTree` جداول مرتب شده بر اساس `tuple()`. در موارد نادر می تواند منجر به `Can't adjust last granule` خطا هنگام انتخاب. [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع اشکال در جهش که با اقداماتی که نیاز به زمینه (به عنوان مثال توابع برای جانسون) مسند که ممکن است منجر به سقوط و یا استثنا عجیب و غریب. [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([الساپین](https://github.com/alesapin)) -- رفع عدم تطابق پایگاه داده و نام جدول فرار در `data/` و `shadow/` & فهرستهای راهنما [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([الکساندر بورمک](https://github.com/Alex-Burmak)) -- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. رفع سقوط در این مورد. [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([زویکوف](https://github.com/4ertus2)) -- ثابت `Not found column in block` هنگام پیوستن به در بیان با راست یا کامل ملحق. [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([زویکوف](https://github.com/4ertus2)) -- یکی دیگر از تلاش برای رفع حلقه بی نهایت در `PrettySpace` قالب [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- رفع اشکال در `concat` تابع زمانی که همه استدلال شد `FixedString` از همان اندازه. [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([الساپین](https://github.com/alesapin)) -- استثنا ثابت در صورت استفاده از 1 استدلال در حالی که تعریف اس3, نشانی اینترنتی و ذخیره سازی اچ دی. [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع دامنه تفسیری برای نمایش با پرس و جو [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([ازات خوژین](https://github.com/azat)) - -#### بهبود {#improvement} - -- `Nullable` ستون به رسمیت شناخته شده و تهی ارزش به درستی توسط ان بی سی پل به کار گرفته [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([واسیلی نمکو](https://github.com/Enmk)) -- ارسال دسته ای در حال حاضر برای توزیع ارسال اتمی [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([ازات خوژین](https://github.com/azat)) -- پرتاب یک استثنا اگر ما می توانیم جدول برای نام ستون در پرس و جو تشخیص نیست. [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([زویکوف](https://github.com/4ertus2)) -- افزودن `merge_max_block_size` تنظیم به `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([زویکوف](https://github.com/4ertus2)) -- نمایش داده شد با `HAVING` و بدون `GROUP BY` فرض گروه های ثابت. پس, `SELECT 1 HAVING 1` در حال حاضر نتیجه را برمی گرداند. [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([ایموس پرنده](https://github.com/amosbird)) -- تجزیه پشتیبانی `(X,)` به عنوان تاپل شبیه به پایتون. [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([ایموس پرنده](https://github.com/amosbird)) -- ساخت `range` رفتارهای تابع تقریبا مانند یک پیتون. [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- افزودن `constraints` ستونها به جدول `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([ویتالی بارانو](https://github.com/vitlibar)) -- فرمت پوچ بهتر برای کنترل کننده تی پی, به طوری که ممکن است به استفاده از `select ignore() from table format Null` برای اندازه گیری نیروی هوایی پاکستان از طریق کلیک مشتری [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([ایموس پرنده](https://github.com/amosbird)) -- نمایش داده شد مانند `CREATE TABLE ... AS (SELECT (1, 2))` به درستی تجزیه شده است [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([هکز](https://github.com/hczhcz)) - -#### بهبود عملکرد {#performance-improvement} - -- عملکرد تجمع بیش از کلید های رشته کوتاه بهبود یافته است. [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([الکساندر کوزمنکوف](https://github.com/akuzm), [ایموس پرنده](https://github.com/amosbird)) -- یک پاس دیگر از تجزیه و تحلیل نحو/بیان را اجرا کنید تا بهینه سازی های بالقوه پس از پیش بینی های ثابت خورده شوند. [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([ایموس پرنده](https://github.com/amosbird)) -- استفاده از ذخیره سازی متا اطلاعات به ارزیابی بی اهمیت `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([ایموس پرنده](https://github.com/amosbird), [الکسی میلویدو](https://github.com/alexey-milovidov)) -- Vectorize پردازش `arrayReduce` شبیه به تجمعی `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([ایموس پرنده](https://github.com/amosbird)) -- بهبود صغیر در عملکرد `Kafka` مصرف [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([ایوان](https://github.com/abyss7)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement} - -- اضافه کردن پشتیبانی برای متقابل کامپایل به معماری پردازنده عاشق64. refactor packager اسکریپت. [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([ایوان](https://github.com/abyss7)) -- باز کردن داروین-x86\_64 و لینوکس-aarch64 toolchains به نصب docker دوره زمانی که ساختمان بسته [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([ایوان](https://github.com/abyss7)) -- به روز رسانی تصویر کارگر بارانداز برای باینری بسته بندی [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([ایوان](https://github.com/abyss7)) -- خطاهای کامپایل ثابت در مکینتاش کاتالینا [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([ارنست پلتایف](https://github.com/ernestp)) -- برخی از فاکتورگیری مجدد در منطق تجزیه و تحلیل پرس و جو: تقسیم کلاس پیچیده را به چند ساده. [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([زویکوف](https://github.com/4ertus2)) -- رفع ساخت بدون زیر منو [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([پرولر](https://github.com/proller)) -- بهتر `add_globs` در فایل های کیک [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([ایموس پرنده](https://github.com/amosbird)) -- حذف مسیرهای سختشده در `unwind` هدف [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([کنستانتین پودشوموک](https://github.com/podshumok)) -- مجاز به استفاده از فرمت خروجی زیر بدون اس اس ال [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([پرولر](https://github.com/proller)) - -#### غیره {#other} - -- اضافه شده antlr4 گرامر برای clickhouse sql گویش [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -## انتشار کلیک و19. 16 {#clickhouse-release-v19-16} - -#### انتشار کلیک و19.16. 14. 65, 2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} - -- رفع اشکال در محاسبات باریکش از عملیات منطقی سه تایی در استدلال های متعدد (بیش از 10). [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([الکساندر کازاکوف](https://github.com/Akazz)) این bugfix شد backported به نسخه 19.16 توسط یک درخواست ویژه از Altinity. - -#### Clickhouse انتشار v19.16.14.65 و 2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} - -- رفع ناسازگاری خرده فروشی توزیع با نسخه های قدیمی تر کانال. رفع [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) - [(تبلوبیکس)](https://github.com/tavplubix) -- هنگام اجرای `CREATE` پرس و جو, برابر عبارات ثابت در استدلال موتور ذخیره سازی. جایگزین کردن نام دادگان خالی با دادگان فعلی. رفع [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). همچنین رفع بررسی برای نشانی محلی در `ClickHouseDictionarySource`. - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(تبلوبیکس)](https://github.com/tavplubix) -- در حال حاضر پس زمینه ادغام در `*MergeTree` موتورهای جدول خانواده حفظ سیاست ذخیره سازی حجم سفارش دقیق تر. - [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- جلوگیری از از دست دادن داده ها در `Kafka` در موارد نادر زمانی که استثنا اتفاق می افتد پس از خواندن پسوند اما قبل از ارتکاب. رفع [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). مرتبط: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(فیلیمونف)](https://github.com/filimonov) -- رفع اشکال منجر به ختم سرور در هنگام تلاش برای استفاده / رها کردن `Kafka` جدول ایجاد شده با پارامترهای اشتباه. رفع [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). دارای [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(فیلیمونف)](https://github.com/filimonov) -- اجازه استفاده `MaterializedView` با subqueries بالا `Kafka` میز - [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([فیلیمونف](https://github.com/filimonov)) - -#### ویژگی جدید {#new-feature-1} - -- افزودن `deduplicate_blocks_in_dependent_materialized_views` گزینه ای برای کنترل رفتار درج ژولیده به جداول با نمایش محقق. این ویژگی جدید توسط یک درخواست ویژه از التیت به نسخه رفع اشکال اضافه شد. - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [.)](https://github.com/urykhy) - -### ClickHouse انتشار v19.16.2.2, 2019-10-30 {#clickhouse-release-v19-16-2-2-2019-10-30} - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-1} - -- اضافه کردن گم شده arity اعتبار برای تعداد/counif. - [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) - [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([ولادیمیر](https://github.com/Vdimir)) -- حذف میراث `asterisk_left_columns_only` تنظیم (به طور پیش فرض غیر فعال شد). - [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([علم هنر - زویکوف](https://github.com/4ertus2)) -- رشته فرمت برای قالب فرمت داده در حال حاضر در فایل های مشخص شده است. - [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([تاولوبیکس](https://github.com/tavplubix)) - -#### ویژگی جدید {#new-feature-2} - -- معرفی uniqcombined64() برای محاسبه cardinality بیشتر از uint\_max. - [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), - [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([ازات - خوژین](https://github.com/azat)) -- پشتیبانی از شاخص های فیلتر بلوم در ستون های مجموعه. - [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) - ([ایشیمب](https://github.com/achimbab)) -- اضافه کردن یک تابع `getMacro(name)` که رشته را برمی گرداند با ارزش مربوطه `` - از پیکربندی سرور. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) - ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تنظیم دو گزینه پیکربندی برای یک فرهنگ لغت بر اساس یک منبع قام: `credentials` و - `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([گیمه - کاسری](https://github.com/YiuRULE)) -- افزودن سابقه جدید `Merge` که تعداد پس زمینه راه اندازی ادغام. - [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([میخیل - کوروتف](https://github.com/millb)) -- اضافه کردن تابع نام کامل است که یک نام دامنه به طور کامل واجد شرایط را برمی گرداند. - [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) - [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- افزودن تابع `arraySplit` و `arrayReverseSplit` که یک مجموعه تقسیم شده توسط “cut off” - شرایط. در دست زدن به توالی زمان مفید هستند. - [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([هکز](https://github.com/hczhcz)) -- اضافه کردن توابع جدید است که بازگشت مجموعه ای از تمام شاخص های همسان در خانواده چند از توابع. - [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([دنیلا - کوتنین](https://github.com/danlark1)) -- اضافه کردن یک موتور پایگاه داده جدید `Lazy` این است که برای ذخیره سازی تعداد زیادی از کوچک ورود به سیستم بهینه شده است - میز [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([نیکیتا - واسیلیف](https://github.com/nikvas0)) -- اضافه کردن توابع جمع گروهبیت مپند,- یا, - صخره نوردی برای ستون بیت مپ. [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([ژیچنگ - یو](https://github.com/yuzhichang)) -- اضافه کردن مجموع عملکرد combinators -ornull و ordefault که بازگشت تهی - یا مقادیر پیش فرض زمانی که هیچ چیز به جمع وجود دارد. - [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) - ([هکز](https://github.com/hczhcz)) -- قالب داده های سفارشی را معرفی کنید که از فرار سفارشی پشتیبانی می کند و - قوانین جداساز. [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([تاولوبیکس](https://github.com/tavplubix)) -- پشتیبانی ردیس به عنوان منبع فرهنگ لغت خارجی. [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([کموندی](https://github.com/comunodi), [انتون - پوپوف](https://github.com/CurtizJ)) - -#### رفع اشکال {#bug-fix-2} - -- رفع نتیجه پرس و جو اشتباه در صورتی که `WHERE IN (SELECT ...)` بخش و `optimize_read_in_order` هست - استفاده می شود. [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([انتون - پوپوف](https://github.com/CurtizJ)) -- پلاگین احراز هویت ماریادب غیر فعال, که بستگی به فایل های خارج از پروژه. - [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([یوری - Baranov](https://github.com/yurriy)) -- رفع استثنا `Cannot convert column ... because it is constant but values of constants are different in source and result` که به ندرت می تواند رخ دهد زمانی که توابع `now()`, `today()`, - `yesterday()`, `randConstant()` استفاده می شود. - [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([نیکولای - کوچتو](https://github.com/KochetovNicolai)) -- شماره ثابت با استفاده از اچ.تی. پی را نگه دارید ایست زنده به جای تی. پی نگه داشتن ایست زنده است. - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([واسیلی - نمکو](https://github.com/Enmk)) -- گسل تقسیم بندی را در گروهبیتماپور ثابت کرد (شماره [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). - [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([ژیچنگ - یو](https://github.com/yuzhichang)) -- برای نمایش تحقق مرتکب کافکا نامیده می شود پس از تمام داده ها نوشته شده است. - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([ایوان](https://github.com/abyss7)) -- اشتباه ثابت `duration_ms` مقدار در `system.part_log` جدول ده بار خاموش بود. - [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([ولادیمیر - Chebotarev](https://github.com/excitoon)) -- رفع سریع برای حل و فصل سقوط در جدول نمایش زنده و دوباره قادر می سازد تمام تست نمایش زنده. - [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) - ([vzakaznikov](https://github.com/vzakaznikov)) -- مرتب کردن مقادیر صفر به درستی در شاخص دقیقه/حداکثر از قطعات ادغام. - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([الکساندر - کوزمنکوف](https://github.com/akuzm)) -- قرار نیست ستون مجازی به .sql ابرداده هنگامی که جدول ایجاد شده است `CREATE TABLE AS`. - [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([ایوان](https://github.com/abyss7)) -- رفع گسل تقسیم بندی در `ATTACH PART` پرس و جو. - [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) - ([الساپین](https://github.com/alesapin)) -- رفع نتیجه اشتباه برای برخی از نمایش داده شد داده شده توسط بهینه سازی خالی در کارخانه های فرعی و خالی - INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([نیکولای - کوچتو](https://github.com/KochetovNicolai)) -- رفع addresssanitizer خطا در نمایش زنده getheader روش (). - [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) - ([vzakaznikov](https://github.com/vzakaznikov)) - -#### بهبود {#improvement-1} - -- اضافه کردن یک پیام در صورت صبر کردن \_موا\_مایش صورت می گیرد. - [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([ازات - خوژین](https://github.com/azat)) -- تنظیم ساخته شده `s3_min_upload_part_size` جدول سطح. - [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([ولادیمیر - Chebotarev](https://github.com/excitoon)) -- در حال بارگذاری [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) - ([بستنی و مغز گردو](https://github.com/sundy-li)) -- بلوک کدو دست چپ در ادغام بخشی ملحق (بهینه سازی). - [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([علم هنر - زویکوف](https://github.com/4ertus2)) -- اجازه ندهید که توابع غیر قطعی در جهش موتورهای جدول تکرار, چرا که این - می توانید تناقضات بین کپی معرفی. - [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([الکساندر - کازاکوف](https://github.com/Akazz)) -- غیر فعال کردن ردیاب حافظه در حالی که تبدیل ردیابی پشته استثنا به رشته. این می تواند از دست دادن جلوگیری کند - از پیغام خطا از نوع `Memory limit exceeded` بر روی سرور, که باعث `Attempt to read after eof` استثنا در مشتری. [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) - ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- بهبود فرمت های دیگر. برطرف - [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), - [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), - [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), - [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) - [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) - ([تاولوبیکس](https://github.com/tavplubix)) -- خانه را نادیده می گیرد ارزش در سمت راست در اپراتور که قابل تبدیل به سمت چپ نیست - side type. Make it work properly for compound types – Array and Tuple. - [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([الکساندر - کوزمنکوف](https://github.com/akuzm)) -- پشتیبانی از نابرابری های از دست رفته برای عضویت. این ممکن است برای پیوستن به نوع کمتر یا برابر و سخت - انواع بیشتر و کمتر برای ستون اسوف در نحو. - [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([علم هنر - Zuikov](https://github.com/4ertus2)) -- بهینه سازی بخشی ادغام اضافه کردن. [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) - ([زویکوف](https://github.com/4ertus2)) -- آیا استفاده از بیش از 98k حافظه در uniqcombined توابع. - [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), - [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([ازات - خوژین](https://github.com/azat)) -- قطعات خیط و پیت کردن از جدول پیوستن به دست راست بر روی دیسک در پارتیالمگرمین (اگر کافی نیست - حافظه). بارگیری داده ها در صورت نیاز. [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) - ([زویکوف](https://github.com/4ertus2)) - -#### بهبود عملکرد {#performance-improvement-1} - -- سرعت جوینت با استدلال توایع با اجتناب از تکرار داده ها. - [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([ایموس - پرنده](https://github.com/amosbird)) -- بازگشت اولیه اگر زیرخاکری خالی است. - [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) -- بهینه سازی تجزیه بیان گذاشتن در مقادیر. - [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) - ([تاولوبیکس](https://github.com/tavplubix)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-1} - -- غیر فعال کردن برخی از موارد برای متقابل تلفیقی به سیستم عامل مک. - [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([ایوان](https://github.com/abyss7)) -- اضافه کردن گم شده ارتباط با pocoxml برای clickhouse\_common\_io. - [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([ازات - خوژین](https://github.com/azat)) -- قبول متعدد تست فیلتر استدلال در clickhouse آزمون. - [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([الکساندر - کوزمنکوف](https://github.com/akuzm)) -- فعال musl و jemalloc برای arm. [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) - ([ایموس پرنده](https://github.com/amosbird)) -- اضافه شده `--client-option` پارامتر به `clickhouse-test` به تصویب پارامترهای اضافی به مشتری. - [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([نیکولای - کوچتو](https://github.com/KochetovNicolai)) -- حفظ تنظیمات موجود در دور در دقیقه ارتقا بسته. - [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) - ([فیلیمونف](https://github.com/filimonov)) -- رفع خطاهای شناسایی شده توسط پوس. [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([علم هنر - Zuikov](https://github.com/4ertus2)) -- رفع ساخت برای داروین. [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) - ([ایوان](https://github.com/abyss7)) -- glibc 2.29 سازگاری. [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([ایموس - پرنده](https://github.com/amosbird)) -- اطمینان حاصل کنید که دکلین می کند فایل های منبع بالقوه را لمس نمی. - [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([ایموس - پرنده](https://github.com/amosbird)) -- تلاش برای جلوگیری از درگیری در هنگام به روز رسانی از دور در دقیقه التیت - فایل پیکربندی بسته بندی شده به طور جداگانه - در کلیک-سرور-مشترک. [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) - ([فیلیمونف](https://github.com/filimonov)) -- بهینه سازی برخی از فایل های هدر برای بازسازی سریع تر. - [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), - [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([الکساندر - کوزمنکوف](https://github.com/akuzm)) -- اضافه کردن تست عملکرد برای تاریخ و تاریخ ساعت. [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([واسیلی - نمکو](https://github.com/Enmk)) -- رفع برخی از تست هایی که حاوی جهش های غیر قطعی هستند. - [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([الکساندر - کازاکوف](https://github.com/Akazz)) -- اضافه کردن ساخت با حفظ به سی. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) - ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- اجتناب از استفاده از آماده سازی نشده ارزش در metricstransmitter. - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([ازات - خوژین](https://github.com/azat)) -- رفع برخی از مشکلات در زمینه های پیدا شده توسط حفظ کننده. - [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), - [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([الکساندر - کوزمنکوف](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) - ([ایموس پرنده](https://github.com/amosbird)) -- رفع رفتار تعریف نشده در سوفلش32. [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([ایموس - پرنده](https://github.com/amosbird)) -- رفع رفتار تعریف نشده در استورگیسنفستولینگ. [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) - ([تاولوبیکس](https://github.com/tavplubix)) -- عبارات ثابت ثابت تاشو برای موتورهای پایگاه داده خارجی (خروجی زیر ,او بی سی, ال بی سی). در گذشته - نسخه این بود برای عبارات ثابت متعدد کار نمی کند و در همه برای تاریخ کار نمی کند, - تاریخ ساعت و امید. این رفع [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) - ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع threadsanitizer اطلاعات مسابقه خطا در نمایش زنده در هنگام دسترسی به no\_users\_thread متغیر است. - [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) - ([وزکازنیکوف](https://github.com/vzakaznikov)) -- خلاص شدن از شر نمادها مالوک در لیبکمون - [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), - [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([ایموس - پرنده](https://github.com/amosbird)) -- اضافه کردن توانمندسازهای پرچم جهانی برای غیر فعال کردن تمام کتابخانه ها. - [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) - ([پرولر](https://github.com/proller)) - -#### پاکسازی کد {#code-cleanup} - -- تعمیم مخزن پیکربندی برای تهیه دی ال برای لغت نامه. [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) - ([الساپین](https://github.com/alesapin)) -- تجزیه کننده برای لغت نامه دی ال بدون هیچ معنایی. - [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) - ([الساپین](https://github.com/alesapin)) -- تقسیم پارسرکری به تجزیه کننده های مختلف کوچکتر. - [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) - ([الساپین](https://github.com/alesapin)) -- فاکتورگیری مجدد کوچک و تغییر نام در نزدیکی لغت نامه های خارجی. - [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) - ([الساپین](https://github.com/alesapin)) -- گیرنده برخی از کد برای تهیه برای کنترل دسترسی مبتنی بر نقش. [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([ویتالی - بارانوف](https://github.com/vitlibar)) -- برخی از پیشرفت های در کد بانک اطلاعاتی. - [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([نیکیتا - واسیلیف](https://github.com/nikvas0)) -- آیا استفاده از iterators در پیدا کردن() و emplace() روش جداول هش. - [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([الکساندر - کوزمنکوف](https://github.com/akuzm)) -- رفع گیرنده در صورتی که ریشه پارامتر خالی نیست. [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) - ([میخیل کوروتف](https://github.com/millb)) -- حذف برخی از کپی و چسباندن (temporaryfile و temporaryfilestream) - [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([علم هنر - زویکوف](https://github.com/4ertus2)) -- بهبود خوانایی کد کمی (`MergeTreeData::getActiveContainingPart`). - [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([ولادیمیر - Chebotarev](https://github.com/excitoon)) -- منتظر تمام مشاغل برنامه ریزی شده باشید که از اشیا محلی استفاده می کنند `ThreadPool::schedule(...)` پرت - یک استثنا. تغییر نام `ThreadPool::schedule(...)` به `ThreadPool::scheduleOrThrowOnError(...)` و - رفع نظرات برای ایجاد واضح است که ممکن است پرتاب. - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) - ([تاولوبیکس](https://github.com/tavplubix)) - -## انتشار کلیک 19.15 {#clickhouse-release-19-15} - -### انتشار کلیک خانه 19.15.4.10, 2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} - -#### رفع اشکال {#bug-fix-3} - -- اضافه شده دست زدن به sql\_tinyint و sql\_bigint و ثابت دست زدن به sql\_float منبع داده در انواع odbc پل. - [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([دنیس گلازاشف](https://github.com/traceon)) -- مجاز به برخی از قطعات بر روی دیسک مقصد و یا حجم در پارتیشن حرکت. - [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- ثابت null-ارزش در nullable ستون از طریق odbc-پل. - [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([واسیلی نمکو](https://github.com/Enmk)) -- درج ثابت به گره غیر محلی توزیع شده با ستون محقق. - [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([ازات خوژین](https://github.com/azat)) -- تابع ثابت دریافت می کند. - [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([میخیل کوروتف](https://github.com/millb)) -- شماره ثابت با استفاده از اچ.تی. پی را نگه دارید ایست زنده به جای تی. پی نگه داشتن ایست زنده است. - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([واسیلی نمکو](https://github.com/Enmk)) -- صبر کنید برای همه مشاغل را به پایان برساند در استثنا (رفع حملات نادر). - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([تاولوبیکس](https://github.com/tavplubix)) -- هنگام وارد کردن به میز کافکا به موفکا فشار ندهید. - [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([ایوان](https://github.com/abyss7)) -- غیر فعال کردن ردیاب حافظه برای استثنا پشته. - [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- کد بد ثابت در تبدیل پرس و جو برای پایگاه داده خارجی. - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از استفاده از ارزش های بی قید و شرط در مترسستر. - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([ازات خوژین](https://github.com/azat)) -- اضافه شده به عنوان مثال پیکربندی با ماکروها برای تست ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.15.3.6, 2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} - -#### رفع اشکال {#bug-fix-4} - -- بد\_واریانت ثابت در درهم فرهنگ لغت. - ([الساپین](https://github.com/alesapin)) -- ثابت کردن اشکال با گسل تقسیم بندی در ضمیمه پرس و جو بخش. - ([الساپین](https://github.com/alesapin)) -- محاسبه زمان ثابت در `MergeTreeData`. - ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- متعهد به کافکا به صراحت پس از نوشتن نهایی است. - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([ایوان](https://github.com/abyss7)) -- مرتب کردن مقادیر صفر به درستی در شاخص دقیقه/حداکثر از قطعات ادغام. - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([الکساندر کوزمنکوف](https://github.com/akuzm)) - -### انتشار کلیک خانه 19.15.2.2, 2019-10-01 {#clickhouse-release-19-15-2-2-2019-10-01} - -#### ویژگی جدید {#new-feature-3} - -- ذخیره سازی چند طبقه: پشتیبانی از استفاده از حجم ذخیره سازی های متعدد برای جداول با موتور ادغام. امکان ذخیره داده های تازه بر روی اس اس دی و انتقال خودکار داده های قدیمی به هارد وجود دارد. ([مثال](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([ایگر](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([الساپین](https://github.com/alesapin)) -- اضافه کردن تابع جدول `input` برای خواندن داده های ورودی در `INSERT SELECT` پرس و جو. [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([هشدار داده می شود](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([انتون پوپوف](https://github.com/CurtizJ)) -- افزودن یک `sparse_hashed` طرح فرهنگ لغت, که عملکرد به معادل `hashed` طرح, اما حافظه بیشتر موثر است. این در مورد حافظه دو برابر کمتر با هزینه بازیابی ارزش کندتر استفاده می کند. [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([ازات خوژین](https://github.com/azat)) -- پیاده سازی توانایی تعریف لیستی از کاربران برای دسترسی به لغت نامه. فقط پایگاه داده متصل فعلی با استفاده از. [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- افزودن `LIMIT` گزینه ای برای `SHOW` پرس و جو. [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([فیلیپ مالکوفسکی](https://github.com/malkfilipp)) -- افزودن `bitmapSubsetLimit(bitmap, range_start, limit)` تابع, که زیر مجموعه از کوچکترین گرداند `limit` ارزش ها در مجموعه ای است که هیچ کوچکتر از `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([ژیچنگ یو](https://github.com/yuzhichang)) -- افزودن `bitmapMin` و `bitmapMax` توابع. [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([ژیچنگ یو](https://github.com/yuzhichang)) -- افزودن تابع `repeat` مربوط به [شماره-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([فلین](https://github.com/ucasFL)) - -#### ویژگی تجربی {#experimental-feature-1} - -- پیاده سازی (در حافظه) ادغام پیوستن به نوع که خط لوله فعلی را تغییر دهید. نتیجه تا حدی توسط کلید ادغام طبقه بندی شده اند. تنظیم `partial_merge_join = 1` برای استفاده از این ویژگی. ادغام پیوستن هنوز در حال توسعه است. [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([زویکوف](https://github.com/4ertus2)) -- افزودن `S3` موتور و عملکرد جدول. هنوز در حال توسعه است (هنوز پشتیبانی احراز هویت وجود ندارد). [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([ولادیمیر چبوتراف](https://github.com/excitoon)) - -#### بهبود {#improvement-2} - -- هر پیامی که از کافکا خوانده می شود به صورت عام وارد می شود. این حل مشکلات تقریبا همه شناخته شده با موتور کافکا. [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([ایوان](https://github.com/abyss7)) -- بهبود برای عدم موفقیت نمایش داده شد توزیع شده است. کوتاه شدن زمان بازیابی, همچنین در حال حاضر قابل تنظیم است و می تواند در دیده `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([واسیلی نمکو](https://github.com/Enmk)) -- پشتیبانی از مقادیر عددی برای شمارشی به طور مستقیم در `IN` بخش. \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([دیماروب2000](https://github.com/dimarub2000)) -- پشتیبانی (اختیاری, غیر فعال به طور پیش فرض) تغییرمسیر در ذخیره سازی نشانی وب. [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([رول](https://github.com/maqroll)) -- اضافه کردن پیام اطلاعات زمانی که مشتری با نسخه های قدیمی تر متصل به یک سرور. [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([فیلیپ مالکوفسکی](https://github.com/malkfilipp)) -- حذف حداکثر محدودیت زمانی خواب برای ارسال داده ها در جداول توزیع شده [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([ازات خوژین](https://github.com/azat)) -- اضافه کردن توانایی ارسال رویدادهای پروفایل (شمارنده) با ارزش تجمعی به گرافیت. این را می توان تحت فعال `` در کارساز `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([ازات خوژین](https://github.com/azat)) -- اضافه کردن نوع بازیگران به طور خودکار `T` به `LowCardinality(T)` در حالی که قرار دادن داده ها در ستون نوع `LowCardinality(T)` در قالب بومی از طریق قام. [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اضافه کردن توانایی استفاده از تابع `hex` بدون استفاده از `reinterpretAsString` برای `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([میخیل کوروتف](https://github.com/millb)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-2} - -- اضافه کردن گدی شاخص به کلیک باینری با اطلاعات اشکال زدایی. این سرعت زمان راه اندازی را افزایش می دهد `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([الساپین](https://github.com/alesapin)) -- بسته بندی با سرعت بالا با بسته بندی پچ پچ که با استفاده از `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([الساپین](https://github.com/alesapin)) -- تنظیم `enable_fuzzing = 1` برای فعال کردن ابزار دقیق رایگان از تمام کد پروژه. [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([کیپریزل](https://github.com/kyprizel)) -- اضافه کردن تست دود ساخت تقسیم در سی. [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([الساپین](https://github.com/alesapin)) -- اضافه کردن ساخت با حفظ به سی. [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- جایگزینی `libsparsehash` با `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([ازات خوژین](https://github.com/azat)) - -#### رفع اشکال {#bug-fix-5} - -- تجزیه عملکرد ثابت تجزیه و تحلیل شاخص بر روی کلید های پیچیده در جداول بزرگ. این رفع \# 6924. [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع خطا منطقی باعث حملات در هنگام انتخاب از کافکا موضوع خالی. [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([ایوان](https://github.com/abyss7)) -- رفع خیلی زود خروجی زیر اتصال نزدیک در `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- پشتیبانی از دانه های لینوکس بسیار قدیمی (ثابت [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع از دست دادن داده ها ممکن است در `insert select` پرس و جو در صورت بلوک خالی در جریان ورودی. \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- ثابت برای عملکرد `АrrayEnumerateUniqRanked` با بند خالی در پارامز [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([پرولر](https://github.com/proller)) -- رفع نمایش داده شد پیچیده با مجموعه ای می پیوندد و فرعی جهانی است. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([ایوان](https://github.com/abyss7)) -- ثابت `Unknown identifier` خطا در ترتیب و گروه با چند می پیوندد [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([زویکوف](https://github.com/4ertus2)) -- ثابت `MSan` هشدار هنگام اجرای تابع با `LowCardinality` استدلال کردن. [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-2} - -- تغییر فرمت ترتیب از بیت مپ \* تابع مجموع می گوید برای بهبود عملکرد. ایالات سریال بیت مپ\* از نسخه های قبلی را نمی توان به عنوان خوانده شده. [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([ژیچنگ یو](https://github.com/yuzhichang)) - -## انتشار کلیک 19.14 {#clickhouse-release-19-14} - -### انتشار کلیک کنیدهاوس 19.14.7.15, 2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} - -#### رفع اشکال {#bug-fix-6} - -- این نسخه همچنین شامل تمام رفع اشکال از 19.11.12.69. -- سازگاری ثابت برای نمایش داده شد توزیع بین 19.14 و نسخه های قبلی. این رفع [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک کنیدهاوس 19.14.6.12, 2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} - -#### رفع اشکال {#bug-fix-7} - -- ثابت برای عملکرد `АrrayEnumerateUniqRanked` با بند خالی در پارامز. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([پرولر](https://github.com/proller)) -- نام زیرخاکی ثابت در نمایش داده شد با `ARRAY JOIN` و `GLOBAL IN subquery` با نام مستعار. استفاده از نام مستعار زیرخاکی برای نام جدول خارجی اگر مشخص شده است. [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([ایوان](https://github.com/abyss7)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-3} - -- ثابت [زدن](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) تست `00715_fetch_merged_or_mutated_part_zookeeper` با بازنویسی به اسکریپت پوسته چون نیاز به صبر برای جهش به درخواست. [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([الکساندر کازاکوف](https://github.com/Akazz)) -- شکست ثابت اوبسان و ممسان در عملکرد `groupUniqArray` با استدلال امتپی ار این با قرار دادن خالی ایجاد شد `PaddedPODArray` به هش جدول صفر سلول به دلیل سازنده برای ارزش سلول صفر نامیده می شد. [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([ایموس پرنده](https://github.com/amosbird)) - -### انتشار کلیک خانه 19.14.3.3, 2019-09-10 {#clickhouse-release-19-14-3-3-2019-09-10} - -#### ویژگی جدید {#new-feature-4} - -- `WITH FILL` تغییردهنده برای `ORDER BY`. (ادامه [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([انتون پوپوف](https://github.com/CurtizJ)) -- `WITH TIES` تغییردهنده برای `LIMIT`. (ادامه [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([انتون پوپوف](https://github.com/CurtizJ)) -- تجزیه unquoted `NULL` تحت اللفظی به عنوان پوچ (اگر تنظیم `format_csv_unquoted_null_literal_as_null=1`). مقداردهی اولیه زمینه های تهی با مقادیر پیش فرض اگر نوع داده ها از این زمینه است قابل ابطال نیست (اگر تنظیم `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([تاولوبیکس](https://github.com/tavplubix)) -- پشتیبانی از نویسه عام در مسیرهای توابع جدول `file` و `hdfs`. اگر مسیر شامل نویسه عام, جدول خوانده خواهد شد. مثال استفاده: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` و `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- جدید `system.metric_log` جدول است که فروشگاه ها ارزش `system.events` و `system.metrics` با فاصله زمانی مشخص شده است. [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه به نوشتن سیاهههای مربوط به متن کلیک به `system.text_log` جدول [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نمایش علامت خصوصی در اثری پشته (این است که از طریق تجزیه جداول نماد فایل های جن انجام). اضافه شدن اطلاعات در مورد فایل و شماره خط در اثری پشته اگر اطلاعات اشکال زدایی وجود دارد. نام نماد افزایش سرعت مراجعه با علامت نمایه سازی در حال حاضر در برنامه. اضافه شده توابع جدید گذاشتن برای درون گرایی: `demangle` و `addressToLine`. تابع تغییر نام داد `symbolizeAddress` به `addressToSymbol` برای ثبات. تابع `addressToSymbol` خواهد نام لت و پار به دلایل عملکرد بازگشت و شما باید به درخواست `demangle`. اضافه شدن تنظیمات `allow_introspection_functions` که به طور پیش فرض خاموش است. [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تابع جدول `values` (نام غیر حساس به حروف است). این اجازه می دهد تا از خواندن `VALUES` فهرست پیشنهادی در [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). مثال: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([دیماروب2000](https://github.com/dimarub2000)) -- توانایی تغییر تنظیمات ذخیره سازی اضافه شده است. نحو: `ALTER TABLE
MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([الساپین](https://github.com/alesapin)) -- پشتیبانی از حذف قطعات جدا شده. نحو: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([تاولوبیکس](https://github.com/tavplubix)) -- محدودیت های جدول. اجازه می دهد تا برای اضافه کردن محدودیت به تعریف جدول خواهد شد که در درج بررسی می شود. [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([گلب novikov](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پشتیبانی برای نمایش ساختگی محقق. [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([ایموس پرنده](https://github.com/amosbird)) -- روشن کردن پیشفیلتر پرس و جو به طور پیش فرض برای نمونه هر موضوع اعدام پرس و جو یک بار در ثانیه. [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- قالب ورودی `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([اکونیک 90](https://github.com/akonyaev90)) -- اضافه شدن دو توابع جدید: `sigmoid` و `tanh` (که برای برنامه های کاربردی یادگیری ماشین مفید هستند). [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تابع `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` برای بررسی اگر نشانه داده شده است در انبار کاه. رمز یک زیر رشته طول حداکثر بین دو شخصیت اسکی غیر الفبایی است (یا مرزهای انبار کاه). رمز باید یک رشته ثابت باشد. پشتیبانی شده توسط تخصص شاخص توکنبف1. [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([واسیلی نمکو](https://github.com/Enmk)) -- عملکرد جدید `neighbor(value, offset[, default_value])`. اجازه می دهد تا برای رسیدن به مقدار قبلی/بعدی در ستون در یک بلوک از داده ها. [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([الکس کرش](https://github.com/alex-krash)) [6685365اب8ک5ب74ف9650492ج88012596ب1ب06](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341الکترونیکی4587وا18065سی2دا1ک888ج73389ف48ک36 درجه سانتیگراد](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [الکسی میلویدو](https://github.com/alexey-milovidov) -- ایجاد یک تابع `currentUser()`, ورود بازگشت از کاربر مجاز. نام مستعار اضافه شده است `user()` برای سازگاری با خروجی زیر. [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([الکس کرش](https://github.com/alex-krash)) -- توابع جدید مجموع `quantilesExactInclusive` و `quantilesExactExclusive` که در پیشنهاد شد [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([دیماروب2000](https://github.com/dimarub2000)) -- تابع `bitmapRange(bitmap, range_begin, range_end)` که برمی گرداند مجموعه ای جدید با محدوده مشخص شده (شامل نمی شود `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([ژیچنگ یو](https://github.com/yuzhichang)) -- تابع `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` که مجموعه ای از رشته های دقیق طولانی از جعبه های جغرافیایی را پوشش می دهد. [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([واسیلی نمکو](https://github.com/Enmk)) -- پیاده سازی پشتیبانی برای قرار دادن پرس و جو با `Kafka` میز [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([ایوان](https://github.com/abyss7)) -- اضافه شدن پشتیبانی برای `_partition` و `_timestamp` ستون مجازی به موتور کافکا. [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([ایوان](https://github.com/abyss7)) -- امکان حذف اطلاعات حساس از `query_log`, سیاهههای مربوط به سرور, لیست فرایند با قوانین مبتنی بر عبارت منظم. [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([فیلیمونف](https://github.com/filimonov)) - -#### ویژگی تجربی {#experimental-feature-2} - -- فرمت داده ورودی و خروجی `Template`. این اجازه می دهد برای مشخص رشته فرمت های سفارشی برای ورودی و خروجی. [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([تاولوبیکس](https://github.com/tavplubix)) -- اجرای `LIVE VIEW` جداول که در اصل در پیشنهاد شد [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898) در حال بارگذاری [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925) و سپس به روز شده در [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). ببینید [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) برای شرح مفصلی. [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([وزکازنیکوف](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([vzakaznikov](https://github.com/vzakaznikov)) توجه داشته باشید که `LIVE VIEW` ویژگی ممکن است در نسخه های بعدی حذف شده است. - -#### رفع اشکال {#bug-fix-8} - -- این نسخه همچنین شامل رفع اشکال از 19.13 و 19.11. -- رفع گسل تقسیم بندی زمانی که جدول شاخص جست و خیز و ادغام عمودی اتفاق می افتد. [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([الساپین](https://github.com/alesapin)) -- رفع ستون در هر ستون با پیش فرض ستون غیر بدیهی است. پیش از این در مورد نیروی تی ال ادغام با `OPTIMIZE ... FINAL` پرس و جو, ارزش منقضی شده توسط پیش فرض نوع به جای پیش فرض ستون مشخص شده توسط کاربر جایگزین شد. [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع کافکا پیام های تکراری مشکل در سرور معمولی راه اندازی مجدد. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([ایوان](https://github.com/abyss7)) -- حلقه بی نهایت ثابت در هنگام خواندن پیام کافکا. مکث نکنید / مصرف کننده رزومه در اشتراک در همه-در غیر این صورت ممکن است به طور نامحدود در برخی از حالات متوقف. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([ایوان](https://github.com/abyss7)) -- ثابت `Key expression contains comparison between inconvertible types` استثنا در `bitmapContains` تابع. [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([دیماروب2000](https://github.com/dimarub2000)) -- اصلاح سگو با فعال `optimize_skip_unused_shards` و از دست رفته کلید شاردینگ. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([انتون پوپوف](https://github.com/CurtizJ)) -- کد اشتباه ثابت در جهش است که ممکن است به فساد حافظه منجر شود. سگو ثابت با خواندن نشانی `0x14c0` که ممکن است به دلیل همزمان اتفاق `DROP TABLE` و `SELECT` از `system.parts` یا `system.parts_columns`. شرایط مسابقه ثابت در تهیه نمایش داده شد جهش. بن بست ثابت ناشی از `OPTIMIZE` از جداول تکرار و عملیات اصلاح همزمان مانند تغییر. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف ورود به سیستم طولانی اضافی در رابط خروجی زیر [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بازگشت توانایی به تجزیه تنظیمات بولی از ‘true’ و ‘false’ در فایل پیکربندی. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([الساپین](https://github.com/alesapin)) -- رفع سقوط در `quantile` و `median` عملکرد بیش از `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([زویکوف](https://github.com/4ertus2)) -- ثابت نتیجه ناقص ممکن توسط بازگشت `SELECT` پرسوجو با `WHERE` شرایط در کلید اولیه شامل تبدیل به نوع شناور. این با چک کردن نادرست از یکنواختی در ایجاد شد `toFloat` تابع. [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([دیماروب2000](https://github.com/dimarub2000)) -- بررسی `max_expanded_ast_elements` تنظیم برای جهش. پاک کردن جهش پس از `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([زمستان ژانگ](https://github.com/zhang2014)) -- ثابت پیوستن به نتایج برای ستون های کلیدی زمانی که با استفاده `join_use_nulls`. ضمیمه نقاط صفر به جای ستون پیش فرض. [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([زویکوف](https://github.com/4ertus2)) -- ثابت برای پرش شاخص با ادغام عمودی و تغییر دهید. ثابت برای `Bad size of marks file` استثنا. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([الساپین](https://github.com/alesapin)) -- رفع سقوط نادر در `ALTER MODIFY COLUMN` و ادغام عمودی زمانی که یکی از قطعات ادغام شده/تغییر داده شده خالی است (0 ردیف) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([الساپین](https://github.com/alesapin)) -- اشکال ثابت در تبدیل `LowCardinality` انواع در `AggregateFunctionFactory`. این رفع [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع رفتار اشتباه و حملات احتمالی در `topK` و `topKWeighted` توابع جمع. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([انتون پوپوف](https://github.com/CurtizJ)) -- کد ناامن ثابت در اطراف `getIdentifier` تابع. [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اشکال ثابت در خروجی زیر پروتکل سیم (استفاده می شود در حالی که اتصال به خانه فرم خروجی زیر مشتری). ناشی از سرریز بافر پشته در `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([یوری بارانوف](https://github.com/yurriy)) -- نشت حافظه ثابت در `bitmapSubsetInRange` تابع. [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([ژیچنگ یو](https://github.com/yuzhichang)) -- رفع اشکال نادر زمانی که جهش اجرا پس از تغییر دانه بودن. [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([الساپین](https://github.com/alesapin)) -- اجازه دادن به پیام پروتوبوف با تمام زمینه ها به طور پیش فرض. [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع اشکال با `nullIf` تابع هنگامی که ما ارسال `NULL` استدلال در بحث دوم. [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- رفع اشکال نادر با تخصیص حافظه اشتباه / تخصیص در لغت نامه کش کلید پیچیده با رشته های رشته ای که منجر به مصرف حافظه بی نهایت (به نظر می رسد مانند نشت حافظه). اشکال بازتولید زمانی که اندازه رشته قدرت دو شروع از هشت بود (8, 16, 32, و غیره). [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([الساپین](https://github.com/alesapin)) -- پشتیبانی می کند گوریل ثابت در توالی های کوچک که باعث استثنا `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([واسیلی نمکو](https://github.com/Enmk)) -- اجازه استفاده از انواع قابل ابطال نیست در می پیوندد با `join_use_nulls` فعال شد [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([زویکوف](https://github.com/4ertus2)) -- غیرفعالسازی `Poco::AbstractConfiguration` جایگزینی پرسوجو در `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از بن بست در `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- با استفاده از `arrayReduce` برای استدلال های ثابت ممکن است به پیش فرض منجر شود. [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع قطعات متناقض است که می تواند به نظر می رسد اگر ماکت پس از ترمیم شد `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت قطع در `JSONExtractRaw` تابع. [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال با نادرست جست و خیز شاخص ترتیب و تجمع با دانه دانه تطبیقی. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([الساپین](https://github.com/alesapin)) -- ثابت `WITH ROLLUP` و `WITH CUBE` اصلاح کننده های `GROUP BY` با تجمع دو سطح. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع اشکال با نوشتن شاخص ثانویه نشانه با دانه دانه تطبیقی. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([الساپین](https://github.com/alesapin)) -- رفع مقدار دهی اولیه سفارش در حالی که راه اندازی سرور. از `StorageMergeTree::background_task_handle` مقدار دهی اولیه در `startup()` این `MergeTreeBlockOutputStream::write()` ممکن است سعی کنید قبل از مقدار دهی اولیه استفاده کنید. فقط بررسی کنید اگر مقداردهی اولیه شده است. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([ایوان](https://github.com/abyss7)) -- پاک کردن بافر داده ها از عملیات خواندن قبلی که با یک خطا تکمیل شد. [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([نیکولای](https://github.com/bopohaa)) -- رفع اشکال با فعال کردن دانه دانه تطبیقی در هنگام ایجاد یک ماکت جدید برای تکرار\*جدول ادغام. [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([الساپین](https://github.com/alesapin)) -- تصادف ممکن است ثابت در هنگام راه اندازی سرور در صورت استثنا در اتفاق افتاد `libunwind` در طول استثنا در دسترسی به بی قید و شرط `ThreadStatus` ساختار. [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- رفع سقوط در `yandexConsistentHash` تابع. پیدا شده توسط تست ریش شدن. [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت امکان معلق نمایش داده شد زمانی که سرور غیرمنتظره است و استخر موضوع جهانی در نزدیکی کامل می شود. این بالاتر شانس اتفاق می افتد در خوشه با تعداد زیادی از خرده ریز (صدها), به دلیل نمایش داده شد توزیع اختصاص یک موضوع در هر اتصال به هر سفال. مثلا, این موضوع ممکن است تکثیر اگر یک خوشه از 330 خرده ریز در حال پردازش 30 نمایش داده شد توزیع همزمان. این موضوع بر تمام نسخه های با شروع از 19.2. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- منطق ثابت `arrayEnumerateUniqRanked` تابع. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت شده است که جدول نماد رمز گشایی. [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([ایموس پرنده](https://github.com/amosbird)) -- استثنا بی ربط ثابت در بازیگران `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- حذف نقل قول اضافی از توضیحات در `system.settings` جدول [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از بن بست ممکن است در `TRUNCATE` از جدول تکرار. [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع خواندن به منظور مرتب سازی کلید. [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([انتون پوپوف](https://github.com/CurtizJ)) -- ثابت `ALTER TABLE ... UPDATE` پرسو جو برای جداول با `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([الساپین](https://github.com/alesapin)) -- رفع اشکال باز شده توسط [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (پیش 19.4.0). بازتولید در نمایش داده شد به جداول توزیع بیش از جداول ادغام هنگامی که ما هیچ ستون پرس و جو نیست (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([الساپین](https://github.com/alesapin)) -- سرریز ثابت در تقسیم عدد صحیح از نوع امضا شده به نوع بدون علامت. رفتار دقیقا همانطور که در ج یا ج++ زبان (قوانین ترویج عدد صحیح) که ممکن است جای تعجب بود. لطفا توجه داشته باشید که سرریز هنوز هم ممکن است در هنگام تقسیم تعداد زیادی امضا به تعداد بزرگ بدون علامت و یا بالعکس (اما این مورد کمتر معمول است). این موضوع در تمام نسخه های سرور وجود داشته است. [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- محدود کردن حداکثر زمان خواب برای متوقف کردن زمانی که `max_execution_speed` یا `max_execution_speed_bytes` قرار است. خطاهای غلط ثابت مانند `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- مشکلات ثابت در مورد استفاده از `MATERIALIZED` ستون ها و نام مستعار در `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([ایموس پرنده](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `FormatFactory` رفتار برای جریان ورودی که به عنوان پردازنده اجرا نمی شود. [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- خطای تایپی ثابت. [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([الکس ریندین](https://github.com/alexryndin)) -- خطای تایپی در پیام خطا (است - \> هستند ). [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([دنیس ژورولو](https://github.com/den-crane)) -- خطا ثابت در حالی که تجزیه لیست ستون از رشته اگر نوع حاوی کاما (این موضوع مربوط به بود `File`, `URL`, `HDFS` ذخیره سازی) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([دیماروب2000](https://github.com/dimarub2000)) - -#### تعمیر امنیتی {#security-fix} - -- این نسخه همچنین شامل تمام اشکال امنیتی رفع از 19.13 و 19.11. -- ثابت امکان پرس و جو ساخته به علت سقوط سرور به دلیل سرریز پشته در پارسر گذاشتن. ثابت امکان سرریز پشته در ادغام و توزیع جداول محقق انداز و شرایط برای ردیف-سطح امنیتی است که شامل subqueries. [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود {#improvement-3} - -- اجرای صحیح منطق سه تایی برای `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([الکساندر کازاکوف](https://github.com/Akazz)) -- در حال حاضر ارزش ها و ردیف با تت ال منقضی شده خواهد شد پس از حذف `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` پرس و جو. اضافه شده نمایش داده شد `SYSTEM STOP/START TTL MERGES` برای غیرفعال کردن / اجازه می دهد ادغام اختصاص با کنترل از راه دور و فیلتر مقادیر منقضی شده در تمام ادغام. [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([انتون پوپوف](https://github.com/CurtizJ)) -- امکان تغییر محل فایل تاریخچه کلیک برای مشتری با استفاده از `CLICKHOUSE_HISTORY_FILE` انوف [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([فیلیمونف](https://github.com/filimonov)) -- حذف `dry_run` پرچم از `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- پشتیبانی `ASOF JOIN` با `ON` بخش. [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([زویکوف](https://github.com/4ertus2)) -- پشتیبانی بهتر از شاخص جست و خیز برای جهش و تکرار. پشتیبانی از `MATERIALIZE/CLEAR INDEX ... IN PARTITION` پرس و جو. `UPDATE x = x` محاسبه تمام شاخص هایی که از ستون استفاده می کنند `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- اجازه دادن به `ATTACH` نمایش زنده (مثلا, در هنگام راه اندازی سرور) بدون در نظر گرفتن به `allow_experimental_live_view` تنظیمات. [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- برای ردیابی پشته جمع شده توسط پیشفیلتر پرس و جو, انجام فریم پشته تولید شده توسط پیشفیلتر پرس و جو خود را شامل نمی شود. [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر توابع جدول `values`, `file`, `url`, `hdfs` پشتیبانی از ستون نام مستعار. [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پرتاب یک استثنا اگر `config.d` فایل عنصر ریشه مربوطه به عنوان فایل پیکربندی ندارد. [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([دیماروب2000](https://github.com/dimarub2000)) -- چاپ اطلاعات اضافی در پیام استثنا برای `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([تاولوبیکس](https://github.com/tavplubix)) -- هنگام تعیین تکه های یک `Distributed` جدول به یک پرس و جو به عنوان خوانده شده تحت پوشش (برای `optimize_skip_unused_shards` = 1) تاتر در حال حاضر چک شرایط از هر دو `prewhere` و `where` بند از بیانیه را انتخاب کنید. [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([الکساندر کازاکوف](https://github.com/Akazz)) -- فعال شد `SIMDJSON` برای ماشین های بدون AVX2 اما با SSE 4.2 و PCLMUL مجموعه آموزش. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تاتر می توانید بر روی فایل سیستم بدون کار `O_DIRECT` پردازشگر پشتیبانی شده: [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پشتیبانی از فشار پایین گزاره برای خرده فروشی نهایی. [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([تسیسون](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهتر `JOIN ON` استخراج کلید [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([زویکوف](https://github.com/4ertus2)) -- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهینه سازی انتخاب کوچکترین ستون برای `SELECT count()` پرس و جو. [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([ایموس پرنده](https://github.com/amosbird)) -- اضافه شده `strict` پارامتر در `windowFunnel()`. هنگامی که `strict` تنظیم شده است `windowFunnel()` اعمال شرایط تنها برای ارزش های منحصر به فرد. [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([ایشیمب](https://github.com/achimbab)) -- رابط امن تر از `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([مربی](https://github.com/avasiliev)) -- گزینه های اندازه خط در هنگام اجرای با `--help` گزینه در حال حاضر با اندازه ترمینال مربوط. [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([دیماروب2000](https://github.com/dimarub2000)) -- غیرفعالسازی “read in order” بهینه سازی برای تجمع بدون کلید. [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([انتون پوپوف](https://github.com/CurtizJ)) -- کد وضعیت قام برای `INCORRECT_DATA` و `TYPE_MISMATCH` کد خطا از پیش فرض تغییر یافت `500 Internal Server Error` به `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([الکساندر رودین](https://github.com/a-rodin)) -- حرکت پیوستن شی از `ExpressionAction` به `AnalyzedJoin`. `ExpressionAnalyzer` و `ExpressionAction` در مورد نمی دانم `Join` کلاس دیگر. منطق خود را با پنهان `AnalyzedJoin` صورت. [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([زویکوف](https://github.com/4ertus2)) -- بن بست ممکن ثابت از نمایش داده شد توزیع زمانی که یکی از خرده ریز جایلهاست اما پرس و جو از طریق اتصال به شبکه ارسال می شود. [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تغییر معنایی جداول چندگانه `RENAME` برای جلوگیری از بن بست ممکن است. [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بازنویسی خروجی زیر سرور سازگاری برای جلوگیری از بارگذاری محموله بسته کامل در حافظه است. کاهش مصرف حافظه برای هر اتصال به حدود `2 * DBMS_DEFAULT_BUFFER_SIZE` (خواندن / نوشتن بافر). [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([یوری بارانوف](https://github.com/yurriy)) -- حرکت اس تی نام مستعار تفسیر منطق از تجزیه کننده که لازم نیست به دانستن هر چیزی در مورد معناشناسی پرس و جو. [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([زویکوف](https://github.com/4ertus2)) -- تجزیه کمی امن تر از `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `clickhouse-copier`: اجازه استفاده `where_condition` از پیکربندی با `partition_key` نام مستعار در پرس و جو برای چک کردن وجود پارتیشن (قبلا فقط در خواندن نمایش داده شد داده ها مورد استفاده قرار گرفت). [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([پرولر](https://github.com/proller)) -- اضافه شده استدلال پیام اختیاری در `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([ولادیمیر](https://github.com/Vdimir)) -- استثنا سرور کردم در حالی که ارسال داده های درج در حال حاضر در حال پردازش در مشتری نیز هست. [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([دیماروب2000](https://github.com/dimarub2000)) -- اضافه شده متریک `DistributedFilesToInsert` که نشان می دهد تعداد کل فایل ها در سیستم فایل که انتخاب می شوند برای ارسال به سرور از راه دور توسط جداول توزیع شده است. تعداد در تمام خرده ریز خلاصه. [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حرکت بسیاری از می پیوندد تهیه منطق از `ExpressionAction/ExpressionAnalyzer` به `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([زویکوف](https://github.com/4ertus2)) -- رفع تسان [اخطار](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([واسیلی نمکو](https://github.com/Enmk)) -- پیام های اطلاعات بهتر در مورد عدم قابلیت های لینوکس. ورود به سیستم خطاهای کشنده با “fatal” سطح, که ساده تر خواهد شد برای پیدا کردن در `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- هنگام فعال کردن اطلاعات موقت تخلیه به دیسک برای محدود کردن استفاده از حافظه در طول `GROUP BY`, `ORDER BY` فضای دیسک رایگان را بررسی نکرد. ثابت اضافه کردن یک محیط جدید `min_free_disk_space`, هنگامی که فضای دیسک رایگان کوچکتر و سپس حد, پرس و جو را متوقف خواهد کرد و پرتاب `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([Weiqing زو](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رواندا بازگشتی حذف شده توسط موضوع. این باعث می شود هیچ حس, چرا که موضوعات بین نمایش داده شد مورد استفاده مجدد قرار. `SELECT` پرس و جو ممکن است یک قفل در یک موضوع, یک قفل از موضوع دیگر نگه دارید و خروج از موضوع اول. در همان زمان اولین موضوع را می توان با استفاده مجدد `DROP` پرس و جو. این به نادرست منجر شود “Attempt to acquire exclusive lock recursively” پیام [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شکافتن `ExpressionAnalyzer.appendJoin()`. تهیه یک مکان در `ExpressionAnalyzer` برای `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده `mysql_native_password` پلاگین احراز هویت به خروجی زیر سرور سازگاری. [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([یوری بارانوف](https://github.com/yurriy)) -- تعداد کمتر از `clock_gettime` سازگاری ابی ثابت بین اشکال زدایی / انتشار در `Allocator` (موضوع ناچیز). [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حرکت کن `collectUsedColumns` از `ExpressionAnalyzer` به `SyntaxAnalyzer`. `SyntaxAnalyzer` می سازد `required_source_columns` خود را در حال حاضر. [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([زویکوف](https://github.com/4ertus2)) -- افزودن تنظیمات `joined_subquery_requires_alias` برای نیاز به نام مستعار برای انتخاب و توابع جدول در `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([زویکوف](https://github.com/4ertus2)) -- استخراج `GetAggregatesVisitor` رده از `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([زویکوف](https://github.com/4ertus2)) -- `system.query_log`: تغییر نوع داده `type` ستون به `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- پیوند استاتیک `sha256_password` پلاگین احراز هویت. [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([یوری بارانوف](https://github.com/yurriy)) -- اجتناب از وابستگی اضافی برای تنظیم `compile` سر کار. در نسخه های قبلی کاربر ممکن است مانند خطا دریافت کنید `cannot open crti.o`, `unable to find library -lc` و غیره [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اعتبار سنجی بیشتر از ورودی که ممکن است از ماکت های مخرب است. [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حالا `clickhouse-obfuscator` پرونده در دسترس است `clickhouse-client` بسته در نسخه های قبلی در دسترس بود `clickhouse obfuscator` (با فضای خالی). [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([دیماروب2000](https://github.com/dimarub2000)) -- بن بست ثابت زمانی که ما حداقل دو نمایش داده شد که حداقل دو جدول در جهت های مختلف و پرس و جو دیگری که انجام عملیات دسیدل در یکی از جداول به عنوان خوانده شده. ثابت دیگر بن بست بسیار نادر است. [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده `os_thread_ids` ستون به `system.processes` و `system.query_log` برای احتمالات اشکال زدایی بهتر. [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- یک راه حل برای اشکالات پسوند پی اچ پی میسورند که زمانی رخ می دهد `sha256_password` به عنوان یک پلاگین احراز هویت پیش فرض (شرح داده شده در [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([یوری baranov](https://github.com/yurriy)) -- حذف محل غیر ضروری با ستون ابطال تغییر. [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([زویکوف](https://github.com/4ertus2)) -- تنظیم مقدار پیشفرض `queue_max_wait_ms` به صفر, به دلیل ارزش فعلی (پنج ثانیه) می سازد هیچ حس. شرایط نادر وجود دارد که این تنظیمات هر گونه استفاده. تنظیمات اضافه شده `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` و `connection_pool_max_wait_ms` برای ابهامزدایی. [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- استخراج `SelectQueryExpressionAnalyzer` از `ExpressionAnalyzer`. نگه داشتن یکی از گذشته برای نمایش داده شد غیر را انتخاب کنید. [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([زویکوف](https://github.com/4ertus2)) -- حذف تکثیر فرمت های ورودی و خروجی. [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اجازه دادن به کاربر برای لغو `poll_interval` و `idle_connection_timeout` تنظیمات در اتصال. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `MergeTree` در حال حاضر دارای یک گزینه اضافی `ttl_only_drop_parts` (غیر فعال به طور پیش فرض) برای جلوگیری از هرس بخشی از قطعات, به طوری که به طور کامل کاهش یافته است که تمام ردیف در یک بخش منقضی شده است. [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([سرگی ولدیکین](https://github.com/svladykin)) -- نوع چک برای توابع شاخص مجموعه. پرتاب استثنا اگر تابع یک نوع اشتباه. این رفع تست ریش شدن با اوبسان. [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([نیکیتا واسیلیف](https://github.com/nikvas0)) - -#### بهبود عملکرد {#performance-improvement-2} - -- بهینه سازی نمایش داده شد با `ORDER BY expressions` بند, جایی که `expressions` پیشوند همزمان با مرتب سازی کلید در `MergeTree` میز این بهینه سازی توسط کنترل `optimize_read_in_order` تنظیمات. [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([انتون پوپوف](https://github.com/CurtizJ)) -- اجازه می دهد به استفاده از موضوعات مختلف در بخش بارگذاری و حذف. [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نوع دسته ای اجرا از به روز رسانی کشورهای تابع جمع. ممکن است به مزایای عملکرد منجر شود. [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- با استفاده از `FastOps` کتابخانه برای توابع `exp`, `log`, `sigmoid`, `tanh`. FastOps سریع بردار ریاضی کتابخانه از مایکل Parakhin (Yandex CTO). بهبود عملکرد `exp` و `log` توابع بیش از 6 بار. توابع `exp` و `log` از `Float32` استدلال باز خواهد گشت `Float32` (در نسخه های قبلی همیشه باز می گردند `Float64`). حالا `exp(nan)` ممکن است بازگشت `inf`. نتیجه `exp` و `log` توابع ممکن است نزدیکترین ماشین تعداد نمایندگی به پاسخ واقعی نیست. [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) با استفاده از Danila Kutenin نوع را fastops کار [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- غیر فعال کردن بهینه سازی کلید متوالی برای `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([اکوزم](https://github.com/akuzm)) -- بهبود عملکرد `simdjson` کتابخانه با خلاص شدن از تخصیص پویا در `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([ویتالی بارانو](https://github.com/vitlibar)) -- صفحات پیش گسل هنگام تخصیص حافظه با `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([اکوزم](https://github.com/akuzm)) -- رفع اشکال عملکرد در `Decimal` مقایسه. [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([زویکوف](https://github.com/4ertus2)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-4} - -- حذف کامپایلر (نمونه زمان اجرا الگو) چرا که ما بیش از عملکرد این برنده ام. [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تست عملکرد اضافه شده برای نشان دادن تخریب عملکرد در شورای همکاری خلیج فارس-9 در راه بیشتر جدا شده است. [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تابع جدول اضافه شده است `numbers_mt`, که است که نسخه چند رشته ای از `numbers`. تست های عملکرد به روز شده با توابع هش. [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- حالت مقایسه در `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([دیماروب2000](https://github.com/dimarub2000)) -- بهترین تلاش برای چاپ اثری پشته. همچنین اضافه شده است `SIGPROF` به عنوان یک سیگنال اشکال زدایی برای چاپ ردیابی پشته از یک موضوع در حال اجرا. [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- هر تابع در فایل خود را, بخش 10. [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف دو برابر const `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([فیلیمونف](https://github.com/filimonov)) -- تغییرات قالب بندی برای `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([اکوزم](https://github.com/akuzm)) -- خرده فروشی بهتر برای پیوستن به ایجاد در `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([زویکوف](https://github.com/4ertus2)) -- حذف یک وضعیت کار برکنار شده (پیدا شده توسط پوس استودیو). [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([اکوزم](https://github.com/akuzm)) -- جدا کردن رابط جدول هش برای `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([اکوزم](https://github.com/akuzm)) -- فاکتورگیری مجدد از تنظیمات. [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([الساپین](https://github.com/alesapin)) -- اضافه کردن نظر برای `set` توابع شاخص. [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- افزایش نمره اتم در نسخه اشکال زدایی در لینوکس. [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([اکوزم](https://github.com/akuzm)) -- در حال حاضر در ساخت اشکال زدایی کار می کنند. [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([Weiqing زو](https://github.com/weiqxu)) -- اضافه شدن یک تست به `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن تست برای نمایش چند مادی برای جدول کافکا. [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([ایوان](https://github.com/abyss7)) -- ایجاد یک طرح ساخت بهتر است. [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([ایوان](https://github.com/abyss7)) -- ثابت `test_external_dictionaries` ادغام در صورتی که تحت کاربر غیر ریشه اعدام شد. [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اشکال بازتولید زمانی که اندازه کل بسته های نوشته شده بیش از `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([یوری بارانوف](https://github.com/yurriy)) -- اضافه شدن یک تست برای `RENAME` شرایط مسابقه جدول [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از مسابقه داده ها در تنظیمات در `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن تست ادغام برای دست زدن به اشتباهات توسط یک فرهنگ لغت کش. [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([ویتالی بارانو](https://github.com/vitlibar)) -- غیر فعال کردن تجزیه فایل های شی جن در سیستم عامل مک, زیرا باعث می شود هیچ حس. [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تلاش برای ایجاد ژنراتور تغییرات بهتر است. [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن `-Wshadow` تغییر به شورای همکاری خلیج فارس. [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([کروزرکریگ](https://github.com/kreuzerkrieg)) -- حذف کد منسوخ برای `mimalloc` پشتیبانی [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `zlib-ng` قابلیت های ایکس86 را تعیین می کند و این اطلاعات را به متغیرهای جهانی ذخیره می کند. این است که در تماس دفالتینیت انجام, که ممکن است توسط موضوعات مختلف به طور همزمان ساخته شده. برای جلوگیری از چند رشته ای می نویسد, این کار را در هنگام راه اندازی کتابخانه. [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([اکوزم](https://github.com/akuzm)) -- تست رگرسیون برای یک اشکال که در پیوستن که در ثابت شد [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([بختیاری روازیف](https://github.com/theruziev)) -- ثابت msan گزارش. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع زدن تست فلش. [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([انتون پوپوف](https://github.com/CurtizJ)) -- مسابقه داده های نادرست ثابت در `MergeTreeDataPart::is_frozen` رشته. [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- وقفه ثابت در تست ریش شدن. در نسخه های قبلی این موفق به پیدا کردن غلط معوق در پرس و جو `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن چک اشکال زدایی به `static_cast` از ستون. [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پشتیبانی از اوراکل لینوکس در بسته های رسمی دور در دقیقه. [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تغییر کامل جانسون از `once` به `loop` نوع. [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- `odbc-bridge.cpp` تعریف `main()` بنابراین نباید در `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([اوروج دش](https://github.com/orivej)) -- تست تصادف در `FULL|RIGHT JOIN` با نقاط صفر در کلید جدول سمت راست. [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده یک تست برای حد در گسترش نام مستعار فقط در مورد. [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تغییر از `boost::filesystem` به `std::filesystem` از کجا مناسب. [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده بسته دور در دقیقه به وب سایت. [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن یک تست برای ثابت `Unknown identifier` استثنا در `IN` بخش. [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([زویکوف](https://github.com/4ertus2)) -- ساده کردن `shared_ptr_helper` چون مردم با مشکلاتی روبرو هستند که این را درک می کنند. [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تست عملکرد اضافه شده برای گوریل ثابت و کدک مضاعف. [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([واسیلی نمکو](https://github.com/Enmk)) -- تقسیم تست ادغام `test_dictionaries` به 4 تست جداگانه. [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([ویتالی بارانو](https://github.com/vitlibar)) -- پردازشگر پشتیبانی شده: `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اجازه می دهد به استفاده از `library` منبع فرهنگ لغت با اسان. [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن گزینه برای تولید تغییرات از یک لیست از روابط عمومی. [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- قفل `TinyLog` ذخیره سازی در هنگام خواندن. [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([اکوزم](https://github.com/akuzm)) -- بررسی برای پیوندهای نمادی شکسته در سی. [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- افزایش اتمام وقت برای “stack overflow” تست کنید زیرا ممکن است مدت زمان طولانی در ساخت اشکال زدایی طول بکشد. [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن یک چک برای فضاهای خالی دو برابر شود. [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `new/delete` ردیابی حافظه در هنگام ساخت با ضد عفونی کننده. ردیابی مشخص نیست. این تنها مانع از استثنا حد حافظه در تست. [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([زویکوف](https://github.com/4ertus2)) -- فعال کردن چک از علامت تعریف نشده در حالی که ارتباط. [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([ایوان](https://github.com/abyss7)) -- اجتناب از بازسازی `hyperscan` هر روز [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- گزارش ثابت اوبسان در `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه ندهید که از پیشفیلتر پرس و جو با ضدعفونی کننده استفاده کنید زیرا سازگار نیست. [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن تست برای بارگذاری یک فرهنگ لغت پس از شکست تایمر. [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع تناقض در `PipelineExecutor::prepareProcessor` استدلال نوع. [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اضافه شده یک تست برای ادرار بد. [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن چک بیشتر به `CAST` تابع. این باید دریافت اطلاعات بیشتر در مورد گسل تقسیم بندی فازی در تست. [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اضافه شده `gcc-9` پشتیبانی به `docker/builder` کانتینر که ایجاد تصویر به صورت محلی. [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([گلب novikov](https://github.com/NanoBjorn)) -- تست برای کلید اولیه با `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([دیماروب2000](https://github.com/dimarub2000)) -- تست های ثابت تحت تاثیر اثر کند پشته اثری چاپ. [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن یک مورد تست برای سقوط در `groupUniqArray` ثابت در [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([اکوزم](https://github.com/akuzm)) -- شاخص های ثابت تست جهش. [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- در تست عملکرد, انجام ورود پرس و جو برای نمایش داده شد ما را اجرا کنید به عنوان خوانده شده. [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([اکوزم](https://github.com/akuzm)) -- محقق نمایش در حال حاضر می تواند با ایجاد هر گونه کم cardinality انواع بدون توجه به تنظیمات مورد مشکوک کم cardinality انواع. [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- تست های به روز شده برای `send_logs_level` تنظیمات. [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع ساخت تحت شورای همکاری خلیج فارس-8.2. [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([مکس اخمدوف](https://github.com/zlobober)) -- ثابت ساخت با لیبک داخلی++. [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([ایوان](https://github.com/abyss7)) -- رفع ساخت مشترک با `rdkafka` کتابخانه [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([ایوان](https://github.com/abyss7)) -- رفع برای سیستم عامل مک ساخت (ناقص). [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([اطلاعات دقیق](https://github.com/alex-zaitsev)) -- ثابت “splitted” ساختن. [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- دیگر رفع ساخت: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([ایموس پرنده](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([وکسیدر](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([ایوان](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([پرولر](https://github.com/proller)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-3} - -- حذف تابع جدول به ندرت استفاده می شود `catBoostPool` و ذخیره سازی `CatBoostPool`. اگر شما این تابع جدول استفاده کرده اند, لطفا ارسال ایمیل به `clickhouse-feedback@yandex-team.com`. توجه داشته باشید که ادغام ادم کودن و احمق باقی می ماند و پشتیبانی خواهد شد. [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- غیرفعالسازی `ANY RIGHT JOIN` و `ANY FULL JOIN` به طور پیش فرض. تنظیم `any_join_distinct_right_table_keys` تنظیم برای فعال کردن. [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([زویکوف](https://github.com/4ertus2)) - -## انتشار کلیک 19.13 {#clickhouse-release-19-13} - -### انتشار کلیک خانه 19.13.6.51, 2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} - -#### رفع اشکال {#bug-fix-9} - -- این نسخه همچنین شامل تمام رفع اشکال از 19.11.12.69. - -### انتشار کلیک خانه 19.13.5.44, 2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} - -#### رفع اشکال {#bug-fix-10} - -- این نسخه همچنین شامل تمام رفع اشکال از 19.14.6.12. -- ثابت وضعیت متناقض ممکن است از جدول در حالی که اجرای `DROP` پرس و جو برای جدول تکرار در حالی که باغ وحش در دسترس نیست. [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- ثابت برای مسابقه داده ها در انبار ذخیره سازی [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال معرفی شده در پیشفیلتر پرس و جو که منجر به ضبط بی پایان از سوکت. [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([الساپین](https://github.com/alesapin)) -- رفع استفاده از پردازنده بیش از حد در حالی که اجرای `JSONExtractRaw` عملکرد بیش از یک مقدار بولی. [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع رگرسیون در حالی که هل دادن به مشاهده محقق. [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([ایوان](https://github.com/abyss7)) -- تابع جدول `url` در صورت امکان پذیری اجازه مهاجم برای تزریق هدر قام دلخواه در درخواست. این موضوع توسط [نیکیتا تیکومیرو](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع بی فایده `AST` بررسی در شاخص مجموعه. [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- تجزیه ثابت از `AggregateFunction` ارزش های جاسازی شده در پرس و جو. [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([ژیچنگ یو](https://github.com/yuzhichang)) -- رفتار اشتباه ثابت `trim` توابع خانواده. [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### ClickHouse انتشار 19.13.4.32, 2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} - -#### رفع اشکال {#bug-fix-11} - -- این نسخه همچنین شامل تمام اشکال امنیتی رفع از 19.11.9.52 و 19.11.10.54. -- مسابقه داده ثابت در `system.parts` جدول و `ALTER` پرس و جو. [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- هدر عدم تطابق ثابت در جریان در صورت خواندن از جدول توزیع خالی با نمونه و قبل از وقوع اتفاق افتاد. [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([Lixiang کیان](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- تصادف ثابت در هنگام استفاده از `IN` بند با یک زیر کشت با یک تاپل. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت مورد با نام ستون در `GLOBAL JOIN ON` بخش. [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([زویکوف](https://github.com/4ertus2)) -- رفع تصادف در هنگام ریخته گری انواع به `Decimal` که این کار را پشتیبانی نمی کند. پرتاب استثنا به جای. [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([زویکوف](https://github.com/4ertus2)) -- تصادف ثابت در `extractAll()` تابع. [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([زویکوف](https://github.com/4ertus2)) -- تبدیل پرسوجو برای `MySQL`, `ODBC`, `JDBC` توابع جدول در حال حاضر به درستی کار می کند برای `SELECT WHERE` نمایش داده شد با چند `AND` عبارات. [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([دیماروب2000](https://github.com/dimarub2000)) -- اضافه شده چک اعلامیه قبلی برای خروجی زیر 8 ادغام. [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([مایکل دیوید تینکو](https://github.com/rafaeldtinoco)) - -#### تعمیر امنیتی {#security-fix-1} - -- رفع دو ناپایداری در کدک در فاز رفع فشار (کاربر مخرب می تواند داده های فشرده که منجر به سرریز بافر در رفع فشار ساخت). [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([زویکوف](https://github.com/4ertus2)) - -### انتشار کلیک کنیدهاوس 19.13.3.26, 2019-08-22 {#clickhouse-release-19-13-3-26-2019-08-22} - -#### رفع اشکال {#bug-fix-12} - -- ثابت `ALTER TABLE ... UPDATE` پرسو جو برای جداول با `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([الساپین](https://github.com/alesapin)) -- ثابت نانپ در هنگام استفاده در بند با یک زیرخاکری با یک تاپل. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت یک موضوع است که اگر یک ماکت کهنه زنده می شود, هنوز هم ممکن است قطعات داده که توسط پارتیشن قطره حذف شد. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([تاولوبیکس](https://github.com/tavplubix)) -- موضوع ثابت با تجزیه سی اس وی [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([تاولوبیکس](https://github.com/tavplubix)) -- مسابقه داده ثابت در سیستم.جدول قطعات و تغییر پرس و جو. این رفع [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- کد اشتباه ثابت در جهش است که ممکن است به فساد حافظه منجر شود. سگو ثابت با خواندن نشانی `0x14c0` که ممکن است به دلیل همزمان اتفاق `DROP TABLE` و `SELECT` از `system.parts` یا `system.parts_columns`. شرایط مسابقه ثابت در تهیه نمایش داده شد جهش. بن بست ثابت ناشی از `OPTIMIZE` از جداول تکرار و عملیات اصلاح همزمان مانند تغییر. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- از دست دادن داده های ممکن ثابت پس از `ALTER DELETE` پرس و جو در جدول با پرش شاخص. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([نیکیتا واسیلیف](https://github.com/nikvas0)) - -#### تعمیر امنیتی {#security-fix-2} - -- اگر مهاجم دارای دسترسی نوشتن به باغ وحش است و قادر به اجرای سفارشی سرور موجود در شبکه که در آن clickhouse اجرای آن می توانید ایجاد و سفارشی-ساخته شده در سرور های مخرب است که به عنوان clickhouse المثنی و ثبت آن در باغ وحش. هنگامی که ماکت دیگر بخش داده ها از ماکت های مخرب واکشی, می تواند فاحشه خانه و سرور را مجبور به ارسال به مسیر دلخواه در فایل سیستم. پیدا شده توسط الدار زیتوف, تیم امنیت اطلاعات در یاندکس. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.13.2.19, 2019-08-14 {#clickhouse-release-19-13-2-19-2019-08-14} - -#### ویژگی جدید {#new-feature-5} - -- نمونه برداری پیشفیلتر در سطح پرس و جو. [مثال](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) -- اجازه برای مشخص کردن یک لیست از ستون با `COLUMNS('regexp')` بیان که مانند یک نوع پیچیده تر از کار می کند `*` ستاره دار. [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([مازریدنتال](https://github.com/mfridental)), ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `CREATE TABLE AS table_function()` در حال حاضر امکان [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([دیماروب2000](https://github.com/dimarub2000)) -- بهینه ساز ادام برای نزول گرادیان تصادفی به طور پیش فرض در استفاده `stochasticLinearRegression()` و `stochasticLogisticRegression()` توابع مجموع, چرا که نشان می دهد با کیفیت خوب و بدون تقریبا هر تنظیم. [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([کد37](https://github.com/Quid37)) -- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([اندی یانگ](https://github.com/andyyzh)) -- `RENAME` نمایش داده شد در حال حاضر با تمام ذخیره سازی کار می کنند. [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([ایوان](https://github.com/abyss7)) -- در حال حاضر مشتری دریافت سیاهههای مربوط از سرور با هر سطح مورد نظر با تنظیم `send_logs_level` بدون در نظر گرفتن سطح ورود به سیستم مشخص شده در تنظیمات سرور. [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-4} - -- تنظیمات `input_format_defaults_for_omitted_fields` به طور پیش فرض فعال است. درج در جداول توزیع شده نیاز به این تنظیم به همان در خوشه (شما نیاز به تنظیم قبل از بروز رسانی نورد). این را قادر می سازد محاسبه عبارات پیش فرض پیچیده برای زمینه های حذف شده در `JSONEachRow` و `CSV*` فرمتها. این باید رفتار مورد انتظار باشد اما ممکن است منجر به تفاوت عملکرد ناچیز. [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([زویکوف](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([اکوزم](https://github.com/akuzm)) - -#### ویژگی های تجربی {#experimental-features} - -- خط لوله پردازش پرس و جو جدید. استفاده `experimental_use_processors=1` گزینه ای برای فعال کردن. برای مشکل خود استفاده کنید. [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -#### رفع اشکال {#bug-fix-13} - -- ادغام کافکا در این نسخه ثابت شده است. -- ثابت `DoubleDelta` کدبندی `Int64` برای بزرگ `DoubleDelta` ارزش, بهبود یافته `DoubleDelta` رمزگذاری برای داده های تصادفی برای `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([واسیلی نمکو](https://github.com/Enmk)) -- بیش از حد ثابت از `max_rows_to_read` اگر تنظیمات `merge_tree_uniform_read_distribution` تنظیم 0. [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود {#improvement-4} - -- می اندازد یک استثنا اگر `config.d` فایل عنصر ریشه مربوطه به عنوان فایل پیکربندی ندارد [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([دیماروب2000](https://github.com/dimarub2000)) - -#### بهبود عملکرد {#performance-improvement-3} - -- بهینهسازی `count()`. در حال حاضر با استفاده از کوچکترین ستون (در صورت امکان). [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([ایموس پرنده](https://github.com/amosbird)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-5} - -- گزارش استفاده از حافظه در تست عملکرد. [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([اکوزم](https://github.com/akuzm)) -- رفع ساخت با خارجی `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([ایوان](https://github.com/abyss7)) -- رفع ساخت مشترک با `rdkafka` کتابخانه [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([ایوان](https://github.com/abyss7)) - -## انتشار کلیک 19.11 {#clickhouse-release-19-11} - -### انتشار کلیک 19.11.13.74, 2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} - -#### رفع اشکال {#bug-fix-14} - -- تصادف نادر ثابت در `ALTER MODIFY COLUMN` و ادغام عمودی زمانی که یکی از قطعات با هم ادغام شدند/تغییر خالی است (0 ردیف). [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([الساپین](https://github.com/alesapin)) -- به روز رسانی دستی `SIMDJSON`. این رفع جاری شدن سیل ممکن است از فایل های استدر با جعلی جانسون پیام های تشخیصی. [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([الکساندر کازاکوف](https://github.com/Akazz)) -- اشکال ثابت با `mrk` پسوند پرونده برای جهش ([الساپین](https://github.com/alesapin)) - -### انتشار کلیک خانه 19.11.12.69, 2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} - -#### رفع اشکال {#bug-fix-15} - -- تجزیه عملکرد ثابت تجزیه و تحلیل شاخص بر روی کلید های پیچیده در جداول بزرگ. این رفع [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از سیگزگف نادر در حالی که ارسال داده ها در جداول با موتور توزیع شده (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([ازات خوژین](https://github.com/azat)) -- ثابت `Unknown identifier` با چند می پیوندد. این رفع [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([زویکوف](https://github.com/4ertus2)) - -### انتشار تاتر 19.11.11.57, 2019-09-13 {#clickhouse-release-19-11-11-57-2019-09-13} - -- رفع خطا منطقی باعث حملات در هنگام انتخاب از کافکا موضوع خالی. [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([ایوان](https://github.com/abyss7)) -- ثابت برای عملکرد `АrrayEnumerateUniqRanked` با بند خالی در پارامز. [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([پرولر](https://github.com/proller)) - -### انتشار کلیک خانه 19.11.10.54, 2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} - -#### رفع اشکال {#bug-fix-16} - -- فراموش فروشگاه شیپور خاموشی برای کافکا پیام های دستی قادر به ارتکاب آنها را همه در یک بار و برای همه پارتیشن. رفع بالقوه تقلید در “one consumer - many partitions” سناریو [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([ایوان](https://github.com/abyss7)) - -### انتشار کلیک کنیدهاوس 19.11.9.52, 2019-09-6 {#clickhouse-release-19-11-9-52-2019-09-6} - -- بهبود دست زدن به خطا در لغت نامه کش. [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([ویتالی بارانو](https://github.com/vitlibar)) -- اشکال ثابت در عملکرد `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([پرولر](https://github.com/proller)) -- ثابت `JSONExtract` عملکرد در حالی که استخراج یک `Tuple` از جسون [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([ویتالی بارانو](https://github.com/vitlibar)) -- از دست دادن داده های ممکن ثابت پس از `ALTER DELETE` پرس و جو در جدول با پرش شاخص. [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- تست عملکرد ثابت. [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پارکت: رفع خواندن ستون بولی. [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفتار اشتباه ثابت `nullIf` تابع برای استدلال ثابت. [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع مشکل پیام های کافکا تقلید در راه اندازی مجدد سرور طبیعی است. [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([ایوان](https://github.com/abyss7)) -- ثابت موضوع زمانی که طولانی است `ALTER UPDATE` یا `ALTER DELETE` ممکن است ادغام به طور منظم به اجرا جلوگیری می کند. جلوگیری از جهش از اجرای اگر هیچ موضوعات رایگان به اندازه کافی در دسترس وجود دارد. [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([تاولوبیکس](https://github.com/tavplubix)) -- خطا ثابت با پردازش “timezone” در فایل پیکربندی سرور. [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع تست کافکا. [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([ایوان](https://github.com/abyss7)) - -#### تعمیر امنیتی {#security-fix-3} - -- اگر مهاجم دارای دسترسی نوشتن به باغ وحش است و قادر به اجرای سفارشی سرور موجود در شبکه که در آن clickhouse اجرا می شود, آن می تواند ایجاد سفارشی-ساخته شده در سرور های مخرب است که به عنوان clickhouse المثنی و ثبت آن در باغ وحش. هنگامی که ماکت دیگر بخش داده ها از ماکت های مخرب واکشی, می تواند فاحشه خانه و سرور را مجبور به ارسال به مسیر دلخواه در فایل سیستم. پیدا شده توسط الدار زیتوف, تیم امنیت اطلاعات در یاندکس. [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک کنیدهاوس 19.11.8.46, 2019-08-22 {#clickhouse-release-19-11-8-46-2019-08-22} - -#### رفع اشکال {#bug-fix-17} - -- ثابت `ALTER TABLE ... UPDATE` پرسو جو برای جداول با `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([الساپین](https://github.com/alesapin)) -- ثابت نانپ در هنگام استفاده در بند با یک زیرخاکری با یک تاپل. [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت یک موضوع است که اگر یک ماکت کهنه زنده می شود, هنوز هم ممکن است قطعات داده که توسط پارتیشن قطره حذف شد. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([تاولوبیکس](https://github.com/tavplubix)) -- موضوع ثابت با تجزیه سی اس وی [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([تاولوبیکس](https://github.com/tavplubix)) -- مسابقه داده ثابت در سیستم.جدول قطعات و تغییر پرس و جو. این رفع [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت کد اشتباه در جهش است که ممکن است منجر به حافظه فساد است. ثابت segfault با خواندن آدرس `0x14c0` که ممکن است به دلیل همزمان اتفاق `DROP TABLE` و `SELECT` از `system.parts` یا `system.parts_columns`. شرایط مسابقه ثابت در تهیه نمایش داده شد جهش. بن بست ثابت ناشی از `OPTIMIZE` از جداول تکرار و عملیات اصلاح همزمان مانند تغییر. [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک کنیدهاوس 19.11.7.40, 2019-08-14 {#clickhouse-release-19-11-7-40-2019-08-14} - -#### رفع اشکال {#bug-fix-18} - -- ادغام کافکا در این نسخه ثابت شده است. -- در هنگام استفاده از سگو را رفع کنید `arrayReduce` برای استدلال ثابت. [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `toFloat()` یکنواختی. [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([دیماروب2000](https://github.com/dimarub2000)) -- اصلاح سگو با فعال `optimize_skip_unused_shards` و از دست رفته کلید شاردینگ. [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([کورتیزج](https://github.com/CurtizJ)) -- منطق ثابت `arrayEnumerateUniqRanked` تابع. [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف ورود به سیستم طولانی اضافی از کنترل خروجی زیر. [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع رفتار اشتباه و حملات احتمالی در `topK` و `topKWeighted` توابع جمع. [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([کورتیزج](https://github.com/CurtizJ)) -- ستون های مجازی را در معرض قرار ندهید `system.columns` جدول این برای سازگاری عقب مورد نیاز است. [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال با تخصیص حافظه برای رشته در فرهنگ لغت کش کلید پیچیده است. [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([الساپین](https://github.com/alesapin)) -- رفع اشکال با فعال کردن دانه دانه تطبیقی در هنگام ایجاد ماکت جدید برای `Replicated*MergeTree` جدول [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([الساپین](https://github.com/alesapin)) -- رفع حلقه بی نهایت در هنگام خواندن پیام کافکا. [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([پایان 7](https://github.com/abyss7)) -- ثابت امکان پرس و جو ساخته به علت سقوط سرور به دلیل سرریز پشته در گذاشتن مربع و امکان سرریز پشته در `Merge` و `Distributed` جداول [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطا را پشتیبانی می کند گوریل ثابت در توالی های کوچک. [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([انمک](https://github.com/Enmk)) - -#### بهبود {#improvement-5} - -- اجازه دادن به کاربر برای لغو `poll_interval` و `idle_connection_timeout` تنظیمات در اتصال. [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.11.5.28, 2019-08-05 {#clickhouse-release-19-11-5-28-2019-08-05} - -#### رفع اشکال {#bug-fix-19} - -- ثابت امکان معلق نمایش داده شد زمانی که سرور غیرمنتظره است. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در مورد نیاز: این رفع [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اشکال ثابت در تبدیل `LowCardinality` انواع در `AggregateFunctionFactory`. این رفع [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع تجزیه از `bool` تنظیمات از `true` و `false` رشته ها در فایل های پیکربندی. [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([الساپین](https://github.com/alesapin)) -- رفع اشکال نادر با هدر جریان ناسازگار در نمایش داده شد به `Distributed` جدول بیش از `MergeTree` جدول زمانی که بخشی از `WHERE` حرکت به `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([الساپین](https://github.com/alesapin)) -- سرریز ثابت در تقسیم عدد صحیح از نوع امضا شده به نوع بدون علامت. این رفع [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-5} - -- `Kafka` هنوز شکسته. - -### انتشار کلیک خانه 19.11.4.24, 2019-08-01 {#clickhouse-release-19-11-4-24-2019-08-01} - -#### رفع اشکال {#bug-fix-20} - -- رفع اشکال با نوشتن شاخص ثانویه نشانه با دانه دانه تطبیقی. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([الساپین](https://github.com/alesapin)) -- ثابت `WITH ROLLUP` و `WITH CUBE` اصلاح کننده های `GROUP BY` با تجمع دو سطح. [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([انتون پوپوف](https://github.com/CurtizJ)) -- ثابت قطع در `JSONExtractRaw` تابع. ثابت [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع segfault در externalloader::reloadoutdated(). [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([ویتالی بارانو](https://github.com/vitlibar)) -- ثابت مورد زمانی که سرور ممکن است گوش دادن سوکت اما خاموش نمی بستن و ادامه خدمت نمایش داده شد باقی مانده است. شما ممکن است در نهایت با دو در حال اجرا فرایندهای فاحشه خانه و سرور. گاهی, سرور ممکن است یک خطا بازگشت `bad_function_call` برای نمایش داده شد باقی مانده است. [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شرایط بی فایده و نادرست ثابت در زمینه به روز رسانی برای بارگذاری اولیه از لغت نامه های خارجی از طریق ال بی سی, خروجی زیر, کلیک و قام. این رفع [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- استثنا بی ربط ثابت در بازیگران `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع نتیجه غیر قطعی از “uniq” تابع مجموع در موارد شدید نادر. اشکال در حال حاضر در تمام نسخه های تاتر بود. [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- Segfault هنگامی که ما مجموعه ای کمی بیش از حد بالا CIDR در تابع `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- ثابت نشت حافظه کوچک زمانی که سرور پرتاب استثنا بسیاری از بسیاری از زمینه های مختلف. [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع وضعیت زمانی که مصرف کننده قبل از اشتراک متوقف شد و پس از سر گرفت. [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([ایوان](https://github.com/abyss7)) توجه داشته باشید که کافکا در این نسخه شکسته. -- پاک کردن بافر داده کافکا از عملیات خواندن قبلی که با یک خطا تکمیل شد [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([نیکولای](https://github.com/bopohaa)) توجه داشته باشید که کافکا در این نسخه شکسته. -- از `StorageMergeTree::background_task_handle` مقدار دهی اولیه در `startup()` این `MergeTreeBlockOutputStream::write()` ممکن است سعی کنید قبل از مقدار دهی اولیه استفاده کنید. فقط بررسی کنید اگر مقداردهی اولیه شده است. [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([ایوان](https://github.com/abyss7)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-6} - -- اضافه شده رسمی `rpm` بسته. [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([پرولر](https://github.com/proller)) ([الساپین](https://github.com/alesapin)) -- اضافه کردن توانایی ساخت `.rpm` و `.tgz` بسته با `packager` خط نوشتن. [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([الساپین](https://github.com/alesapin)) -- رفع برای “Arcadia” ساخت سیستم. [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([پرولر](https://github.com/proller)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-6} - -- `Kafka` در این نسخه شکسته. - -### انتشار کلیک خانه 19.11.3.11, 2019-07-18 {#clickhouse-release-19-11-3-11-2019-07-18} - -#### ویژگی جدید {#new-feature-6} - -- اضافه شدن پشتیبانی از اظهارات تهیه شده است. [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([الکساندر](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `DoubleDelta` و `Gorilla` کدکهای ستون [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([واسیلی نمکو](https://github.com/Enmk)) -- اضافه شده `os_thread_priority` تنظیم که اجازه می دهد تا برای کنترل “nice” ارزش موضوعات پردازش پرس و جو است که توسط سیستم عامل مورد استفاده برای تنظیم اولویت برنامه ریزی پویا. این نیاز دارد `CAP_SYS_NICE` قابلیت به کار. این پیاده سازی [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پیاده سازی `_topic`, `_offset`, `_key` ستون برای موتور کافکا [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([ایوان](https://github.com/abyss7)) توجه داشته باشید که کافکا در این نسخه شکسته. -- اضافه کردن ترکیب تابع جمع `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([هکز](https://github.com/hczhcz)) -- توابع مجموع `groupArrayMovingSum(win_size)(x)` و `groupArrayMovingAvg(win_size)(x)` که محاسبه حرکت مجموع / میانگین با یا بدون محدودیت اندازه پنجره. [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([اختراع2004](https://github.com/inv2004)) -- افزودن سینونیم `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([هکز](https://github.com/hczhcz)) -- Intergate H3 تابع `geoToH3` از بارگذاری. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen ایوان](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### رفع اشکال {#bug-fix-21} - -- پیاده سازی کش دی ان اس با به روز رسانی ناهمزمان. موضوع جداگانه برطرف تمام میزبان و به روز رسانی دی ان اس کش با دوره (تنظیم `dns_cache_update_period`). این باید زمانی کمک کند که میزبان اغلب تغییر کند. [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع segfault در `Delta` کدک که ستون با مقادیر کمتر از 32 بیت اندازه تاثیر می گذارد. اشکال منجر به فساد حافظه تصادفی. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([الساپین](https://github.com/alesapin)) -- رفع اشکال در ادغام ستون های غیر فیزیکی در بلوک. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع اشکال نادر در چک کردن بخشی با `LowCardinality` ستون. قبلا `checkDataPart` همیشه برای بخشی با شکست مواجه `LowCardinality` ستون. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([الساپین](https://github.com/alesapin)) -- اجتناب از اتصالات معلق زمانی که سرور استخر موضوع کامل است. این برای اتصال از مهم است `remote` تابع جدول و یا اتصال به یک سفال بدون کپی زمانی که فاصله اتصال طولانی وجود دارد. این رفع [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پشتیبانی از استدلال های ثابت به `evalMLModel` تابع. این رفع [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت موضوع زمانی که تاتر تعیین منطقه زمانی به طور پیش فرض به عنوان `UCT` به جای `UTC`. این رفع [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- زیر جریان بافر ثابت در `visitParamExtractRaw`. این رفع [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر توزیع شده است `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` نمایش داده شد خواهد شد به طور مستقیم در ماکت رهبر اجرا شده است. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([الساپین](https://github.com/alesapin)) -- ثابت `coalesce` برای `ColumnConst` با `ColumnNullable` + تغییرات مرتبط . [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([زویکوف](https://github.com/4ertus2)) -- رفع `ReadBufferFromKafkaConsumer` به طوری که آن را نگه می دارد و خواندن پیام های جدید پس از `commit()` حتی اگر قبلا متوقف شده بود [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([ایوان](https://github.com/abyss7)) -- ثابت `FULL` و `RIGHT` پیوستن به نتایج در هنگام پیوستن به `Nullable` کلید در جدول سمت راست. [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([زویکوف](https://github.com/4ertus2)) -- رفع احتمالی خواب بی نهایت نمایش داده شد اولویت پایین. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع شرایط مسابقه, که باعث می شود که برخی از نمایش داده شد ممکن است در کواریلاگ پس از به نظر می رسد `SYSTEM FLUSH LOGS` پرس و جو. [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([انتون پوپوف](https://github.com/CurtizJ)) -- ثابت `heap-use-after-free` اسان هشدار در خوشه بندی ناشی از سازمان دیده بان که سعی کنید به استفاده از شی کپی در حال حاضر حذف شده است. [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اشتباه ثابت `StringRef` گر بازگشت توسط برخی از پیاده سازی `IColumn::deserializeAndInsertFromArena`. این اشکال تحت تاثیر قرار تنها واحد تست. [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- جلوگیری از منبع و مجموعه ای متوسط پیوستن به ستون از پوشش ستون همان نام. [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([زویکوف](https://github.com/4ertus2)) -- رفع درج و پرس و جو را انتخاب کنید به خروجی زیر موتور با خروجی زیر شناسه سبک به نقل از. [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([زمستان ژانگ](https://github.com/zhang2014)) -- حالا `CHECK TABLE` پرس و جو می تواند با خانواده موتور ادغام کار می کنند. این گرداند بررسی وضعیت و پیام اگر هر برای هر بخش (و یا فایل در مورد موتورهای ساده تر). همچنین, رفع اشکال در واکشی از یک بخش شکسته. [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([الساپین](https://github.com/alesapin)) -- رفع split\_shared\_libraries در زمان اجرا [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([نام و نام خانوادگی](https://github.com/danlark1)) -- مقدار دهی اولیه منطقه زمانی ثابت زمانی که `/etc/localtime` پیوند نمادی نسبی مانند است `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- clickhouse-کپی: ثابت استفاده رایگان در خاموش کردن [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([پرولر](https://github.com/proller)) -- به روز شده `simdjson`. ثابت موضوع است که برخی از پارسونز نامعتبر با صفر بایت موفقیت تجزیه. [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع خاموش کردن systemlogs [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع زمانی که وضعیت در باطل کردن\_قرقمی بستگی به یک فرهنگ لغت. [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([ویتالی بارانو](https://github.com/vitlibar)) - -#### بهبود {#improvement-6} - -- اجازه دادن به نشانیهای غیر قابل حل در پیکربندی خوشه. در دسترس نیستند و سعی می کنند در هر تلاش اتصال حل شوند. این امر به ویژه برای کوبرنتیس مفید. این رفع [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بستن اتصالات تی پی بیکار (با فاصله یک ساعت به طور پیش فرض). این امر به ویژه برای خوشه های بزرگ با جداول توزیع متعدد بر روی هر سرور مهم, چرا که هر سرور احتمالا می تواند نگه داشتن یک استخر اتصال به هر سرور دیگر, و پس از همزمانی پرس و جو اوج, اتصالات متوقف خواهد شد. این رفع [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- کیفیت بهتر `topK` تابع. تغییر رفتار فضا مجموعه به حذف عنصر گذشته اگر عنصر جدید یک وزن بزرگتر. [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- توابع نشانی وب برای کار با دامنه هم اکنون می توانید برای نشانیهای اینترنتی ناقص بدون طرح کار می کنند [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([الساپین](https://github.com/alesapin)) -- چک سام به اضافه `system.parts_columns` جدول [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- اضافه شده `Enum` نوع داده به عنوان یک سینونیم برای `Enum8` یا `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([دیماروب2000](https://github.com/dimarub2000)) -- بیت کامل انتقال نوع برای `T64` وابسته به کدک. می تواند منجر به فشرده سازی بهتر با `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([زویکوف](https://github.com/4ertus2)) -- شرط در `startsWith` تابع هم اکنون می توانید کلید اصلی استفاده می کند. این رفع [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) و [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([دیماروب2000](https://github.com/dimarub2000)) -- مجاز به استفاده `clickhouse-copier` با توپولوژی خوشه متقابل تکرار با اجازه نام پایگاه داده خالی. [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([نوارتولومی](https://github.com/nvartolomei)) -- استفاده `UTC` به عنوان منطقه زمانی پیش فرض بر روی یک سیستم بدون `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` چاپ شد و سرور و یا مشتری حاضر به شروع. [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بازگشت پشتیبانی از استدلال نقطه شناور در تابع `quantileTiming` برای سازگاری به عقب. [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نشان می دهد که جدول از دست رفته است ستون در پیام های خطا. [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([ایوان](https://github.com/abyss7)) -- حذف پرسوجوی اجرا با همان کویری\_ید توسط کاربران مختلف [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([پرولر](https://github.com/proller)) -- کد قوی تر برای ارسال معیارهای گرافیت. این حتی در طول چند طولانی کار خواهد کرد `RENAME TABLE` عمل [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بیشتر پیام های خطا اطلاع رسانی نمایش داده خواهد شد که سه گانه می توانید یک کار برای اجرای برنامه نیست. این رفع [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- معکوس نگرامش به بصری تر [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([نام و نام خانوادگی](https://github.com/danlark1)) -- در حال بارگذاری [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([اکونیک 90](https://github.com/akonyaev90)) -- به روز رسانی مقدار پیش فرض `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([قاسم کونوالوف](https://github.com/izebit)) -- اضافه شدن یک مفهوم از تنظیمات منسوخ باشد. تنظیم منسوخ `allow_experimental_low_cardinality_type` می توان بدون اثر استفاده کرد. [0ف15ج016802ف7سی141494سی12846ب898944](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [الکسی میلویدو](https://github.com/alexey-milovidov) - -#### بهبود عملکرد {#performance-improvement-4} - -- افزایش تعداد جریان از جدول ادغام برای توزیع یکنواخت تر از موضوعات را انتخاب کنید. اضافه شدن تنظیمات `max_streams_multiplier_for_merge_tables`. این رفع [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-7} - -- اضافه کردن یک تست سازگاری رو به عقب برای تعامل مشتری و سرور با نسخه های مختلف از تاتر. [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([الساپین](https://github.com/alesapin)) -- تست اطلاعات پوشش در هر مرتکب و جلو و درخواست. [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([الساپین](https://github.com/alesapin)) -- همکاری با نشانی ضد عفونی کننده برای حمایت از تخصیص سفارشی ما (`Arena` و `ArenaWithFreeLists`) برای اشکال زدایی بهتر از “use-after-free” خطاها. [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([اکوزم](https://github.com/akuzm)) -- سودهی به [اجرای رایگان](https://github.com/llvm-mirror/libunwind) برای ج++ دست زدن به استثنا و برای ردیابی پشته چاپ [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([نیکیتا لکوف](https://github.com/laplab)) -- اضافه کردن دو هشدار بیشتر از-ابزار [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه می دهد برای ساخت تاتر با ضد عفونی کننده حافظه. [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت ubsan گزارش مورد `bitTest` تابع در تست ریش شدن. [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- کارگر بارانداز: اضافه شدن امکان به داخل یک نمونه کلیک که نیاز به احراز هویت. [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([هشدار داده می شود](https://github.com/shurshun)) -- به روز رسانی کتابدار به نسخه 1.1.0 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([ایوان](https://github.com/abyss7)) -- اضافه کردن ایست جهانی برای تست ادغام و غیر فعال کردن برخی از در کد تست. [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([الساپین](https://github.com/alesapin)) -- رفع برخی از شکست های سه گانه. [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([اکوزم](https://github.com/akuzm)) -- این `--no-undefined` گزینه نیروهای لینکر برای بررسی تمام نام های خارجی برای وجود در حالی که ارتباط. این بسیار مفید برای ردیابی وابستگی واقعی بین کتابخانه ها در حالت ساخت تقسیم شده است. [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([ایوان](https://github.com/abyss7)) -- تست عملکرد اضافه شده برای [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- سازگاری ثابت با شورای همکاری خلیج فارس-7. [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن پشتیبانی برای شورای همکاری خلیج فارس-9. این رفع [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطا ثابت زمانی که لیبناد را می توان به اشتباه مرتبط کرد. [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت چند هشدار پیدا شده توسط پوس استودیو. [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن پشتیبانی اولیه برای `clang-tidy` تجزیه و تحلیل استاتیک. [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تبدیل ماکرو اس دی/لینوکس اندی( ‘be64toh’ و ‘htobe64’) به معادل سیستم عامل مک ایکس [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([فو چن](https://github.com/fredchenbj)) -- بهبود ادغام تست راهنمای. [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع ساخت در مکینتاش [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([فیلیمونف](https://github.com/filimonov)) -- رفع سخت به نقطه تایپی: سنگدانه -\> مصالح. [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([اکوزم](https://github.com/akuzm)) -- رفع ساخت بورس [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([پرولر](https://github.com/proller)) -- اضافه کردن لینک به کانال یوتیوب تجربی به وب سایت [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([ایوان بلینکو](https://github.com/blinkov)) -- چوب کوره: اضافه کردن گزینه برای پرچم پوشش: با برقی [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([پرولر](https://github.com/proller)) -- رفع اندازه اولیه برخی از درون خطی پودرای است. [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([اکوزم](https://github.com/akuzm)) -- فاحشه خانه-سرور.پستینست: رفع تشخیص سیستم عامل برای لینوکس 6 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([پرولر](https://github.com/proller)) -- نسل بسته بندی قوس لینوکس اضافه شده است. [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- تقسیم مشترک / پیکربندی.هشدار داده می شود) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([پرولر](https://github.com/proller)) -- رفع برای “Arcadia” ساخت پلت فرم [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([پرولر](https://github.com/proller)) -- رفع برای غیر متعارف ساخت (gcc9 هیچ submodules) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([پرولر](https://github.com/proller)) -- نیاز به نوع صریح و روشن در فروشگاه بدون خط زیرا ثابت شده بود که مستعد ابتلا به اشکال [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([اکوزم](https://github.com/akuzm)) -- رفع مکینتاش ساخت [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([فیلیمونف](https://github.com/filimonov)) -- تست عملکرد مربوط به ویژگی دستگاه گوارش جدید با مجموعه داده های بزرگتر, همانطور که در اینجا درخواست [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- تست های نفرت انگیز را در تست استرس اجرا کنید [12693568722ف11 است19859742ف56428455501فرد2ا](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([الساپین](https://github.com/alesapin)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-7} - -- `Kafka` در این نسخه شکسته. -- فعالسازی `adaptive_index_granularity` = 10 مگابایت به طور پیش فرض برای جدید `MergeTree` میز اگر شما ایجاد شده جدید MergeTree جداول در نسخه 19.11+, دانگرید به نسخه های قبل 19.6 غیر ممکن خواهد بود. [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([الساپین](https://github.com/alesapin)) -- حذف منسوخ لغت نامه تعبیه شده مستند نشده است که توسط یاندکس مورد استفاده قرار گرفت.متریکا توابع `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` دیگر در دسترس نیست. اگر شما با استفاده از این توابع, ارسال ایمیل به clickhouse-feedback@yandex-team.com. توجه: در حال حاضر ما تصمیم به نگه داشتن این توابع در حالی که برای. [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -## انتشار کلیک 19.10 {#clickhouse-release-19-10} - -### انتشار کلیک خانه 19.10.1.5, 2019-07-12 {#clickhouse-release-19-10-1-5-2019-07-12} - -#### ویژگی جدید {#new-feature-7} - -- اضافه کردن کدک ستون جدید: `T64`. ساخته شده به صورت (U)IntX/EnumX/Data(زمان)/DecimalX ستون. این باید برای ستون ها با مقادیر محدوده ثابت یا کوچک مناسب باشد. کدک خود را اجازه می دهد تا بزرگ و یا کوچک نوع داده بدون فشرده سازی مجدد. [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([زویکوف](https://github.com/4ertus2)) -- افزودن موتور دادگان `MySQL` که اجازه می دهد برای مشاهده تمام جداول در سرور خروجی از راه دور [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([زمستان ژانگ](https://github.com/zhang2014)) -- `bitmapContains` اجرا کردن. این 2 برابر سریعتر از `bitmapHasAny` اگر بیت مپ دوم شامل یک عنصر. [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([ژیچنگ یو](https://github.com/yuzhichang)) -- پشتیبانی از `crc32` تابع (با رفتار دقیقا همانطور که در خروجی زیر و یا پی اچ پی). اگر شما نیاز به یک تابع هش استفاده نکنید. [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen ایوان](https://github.com/BHYCHIK)) -- پیادهسازی شده `SYSTEM START/STOP DISTRIBUTED SENDS` نمایش داده شد برای کنترل درج ناهمزمان به `Distributed` میز [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([زمستان ژانگ](https://github.com/zhang2014)) - -#### رفع اشکال {#bug-fix-22} - -- نادیده گرفتن محدودیت اجرای پرس و جو و حداکثر اندازه قطعات برای محدودیت ادغام در حالی که اجرای جهش. [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع اشکال که ممکن است به تقسیم بلوک های طبیعی (بسیار نادر) و درج بلوک های تکراری (در اغلب موارد) منجر شود. [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([الساپین](https://github.com/alesapin)) -- رفع عملکرد `arrayEnumerateUniqRanked` برای نشانوندها با عرضهای خالی [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([پرولر](https://github.com/proller)) -- هنوز به موضوعات کافکا بدون قصد نظرسنجی هر پیام مشترک نیست. [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([ایوان](https://github.com/abyss7)) -- ایجاد تنظیمات `join_use_nulls` هیچ تاثیری برای انواع است که نمی تواند در داخل قابل ابطال است [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- ثابت `Incorrect size of index granularity` خطاها [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([کوراستر](https://github.com/coraxster)) -- ثابت شناور به دهدهی تبدیل سرریز [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([کوراستر](https://github.com/coraxster)) -- بافر خیط و پیت کردن زمانی که `WriteBufferFromHDFS`مخرب نامیده می شود. این رفع نوشتن به `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([Xindong پنگ](https://github.com/eejoin)) - -#### بهبود {#improvement-7} - -- درمان سلول های خالی در `CSV` به عنوان مقادیر پیش فرض هنگام تنظیم `input_format_defaults_for_omitted_fields` فعال است. [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([اکوزم](https://github.com/akuzm)) -- عدم مسدود کردن بارگذاری لغت نامه های خارجی. [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([ویتالی بارانو](https://github.com/vitlibar)) -- وقفه شبکه را می توان به صورت پویا برای اتصالات در حال حاضر تاسیس با توجه به تنظیمات تغییر کرده است. [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([کنستانتین پودشوموک](https://github.com/podshumok)) -- با استفاده از “public\_suffix\_list” برای توابع `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. این با استفاده از یک جدول هش کامل تولید شده توسط `gperf` با یک لیست تولید شده از فایل: https://publicsuffix.org/list/public\_suffix\_list.dat. (مثلا, در حال حاضر ما دامنه را تشخیص `ac.uk` به عنوان غیر قابل توجهی). [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- به تصویب رسید `IPv6` نوع داده در جداول سیستم. `system.processes` و `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- با استفاده از جلسات برای ارتباط با پروتکل سازگاری خروجی زیر. \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([یوری بارانوف](https://github.com/yurriy)) -- پشتیبانی بیشتر `ALTER` نمایش داده شد `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- پشتیبانی `` بخش در `clickhouse-local` فایل پیکربندی. [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([پرولر](https://github.com/proller)) -- اجازه اجرای پرس و جو با `remote` تابع جدول در `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([پرولر](https://github.com/proller)) - -#### بهبود عملکرد {#performance-improvement-5} - -- اضافه کردن امکان ارسال علامت نهایی در پایان ستون ادغام. این اجازه می دهد برای جلوگیری از بی فایده می خواند برای کلید های که خارج از محدوده داده های جدول می باشد. این فعال است تنها اگر دانه دانه دانه تطبیقی در حال استفاده است. [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([الساپین](https://github.com/alesapin)) -- بهبود عملکرد جداول ادغام در فایل سیستم بسیار کند با کاهش تعداد `stat` syscalls. [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تخریب عملکرد ثابت در خواندن از جداول ادغام که در نسخه معرفی شد 19.6. رفع \# 5631. [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-8} - -- پیادهسازی شده `TestKeeper` به عنوان یک پیاده سازی از رابط باغ وحش مورد استفاده برای تست [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([الکسی میلویدو](https://github.com/alexey-milovidov)) ([لوشکین الکسیر](https://github.com/alexey-milovidov)) -- از حالا به بعد `.sql` تست ها را می توان به صورت موازی با پایگاه داده تصادفی جدا شده توسط سرور اجرا کرد. این اجازه می دهد تا سریعتر اجرا شود و تست های جدید را با تنظیمات سرور سفارشی اضافه کنید و اطمینان حاصل کنید که تست های مختلف بر یکدیگر تاثیر نمی گذارد. [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([ایوان](https://github.com/abyss7)) -- حذف `` و `` از تست های عملکرد [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- ثابت “select\_format” تست عملکرد برای `Pretty` فرشها [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -## انتشار کلیک 19.9 {#clickhouse-release-19-9} - -### انتشار تاتر 19.9.3.31, 2019-07-05 {#clickhouse-release-19-9-3-31-2019-07-05} - -#### رفع اشکال {#bug-fix-23} - -- اصلاح سگو در کدک دلتا که ستون ها را با مقادیر کمتر از اندازه 32 بیت تحت تاثیر قرار می دهد. اشکال منجر به فساد حافظه تصادفی. [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([الساپین](https://github.com/alesapin)) -- رفع اشکال نادر در چک کردن بخشی با ستون کم هزینه. [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([الساپین](https://github.com/alesapin)) -- رفع اشکال در ادغام ستون های غیر فیزیکی در بلوک. [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع خواب بی نهایت بالقوه نمایش داده شد با اولویت پایین. [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت کنید که چگونه کلیک هاوس منطقه زمانی پیش فرض را به عنوان کمپانی یوسیت تعیین می کند. [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال در مورد اجرای توزیع قطره/تغییر/کوتاه / بهینه سازی در نمایش داده شد خوشه در ماکت پیرو قبل از ماکت رهبر. در حال حاضر به طور مستقیم بر روی ماکت رهبر اجرا خواهد شد. [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([الساپین](https://github.com/alesapin)) -- رفع شرایط مسابقه, که باعث می شود که برخی از نمایش داده شد ممکن است در انبار کردن بلافاصله پس از سیستم پرس و جو سیاهههای مربوط خیط و پیت کردن ظاهر نمی شود. [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([انتون پوپوف](https://github.com/CurtizJ)) -- اضافه شدن پشتیبانی از دست رفته برای استدلال ثابت به `evalMLModel` تابع. [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.9.2.4, 2019-06-24 {#clickhouse-release-19-9-2-4-2019-06-24} - -#### ویژگی جدید {#new-feature-8} - -- اطلاعات چاپ در مورد قطعات یخ زده در `system.parts` جدول [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([پرولر](https://github.com/proller)) -- درخواست رمز عبور مشتری در کلیک-مشتری شروع در تیتی اگر در استدلال تنظیم نشده است [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([پرولر](https://github.com/proller)) -- پیاده سازی `dictGet` و `dictGetOrDefault` توابع برای انواع اعشاری. [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([زویکوف](https://github.com/4ertus2)) - -#### بهبود {#improvement-8} - -- دبیان اینیت: اضافه کردن سرویس ایست ایست [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([پرولر](https://github.com/proller)) -- اضافه کردن تنظیم ممنوع به طور پیش فرض برای ایجاد جدول با انواع مشکوک برای کم کاری [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- توابع رگرسیون وزن مدل بازگشت زمانی که به عنوان دولت در تابع استفاده نمی شود `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([کد37](https://github.com/Quid37)) -- تغییر نام و بهبود روش رگرسیون. [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([کد37](https://github.com/Quid37)) -- رابط های واضح تر از جستجوگران رشته. [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([نام و نام خانوادگی](https://github.com/danlark1)) - -#### رفع اشکال {#bug-fix-24} - -- رفع از دست دادن داده های بالقوه در کافکا [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([ایوان](https://github.com/abyss7)) -- رفع حلقه بی نهایت بالقوه در `PrettySpace` فرمت زمانی که با صفر ستون نامیده می شود [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- اشکال سرریز ثابت در مدل های خطی. اجازه مدل میلی لیتر اومال برای استدلال مدل غیر توایع. [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- `ALTER TABLE ... DROP INDEX IF EXISTS ...` اگر شاخص موجود وجود ندارد باید یک استثنا را افزایش نمی دهد [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([گلب novikov](https://github.com/NanoBjorn)) -- رفع segfault با `bitmapHasAny` در زیر مقیاس [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([ژیچنگ یو](https://github.com/yuzhichang)) -- خطا ثابت زمانی که استخر اتصال تکرار کند سعی مجدد نیست برای حل و فصل میزبان, حتی زمانی که کش دی ان اس کاهش یافته بود. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([الساپین](https://github.com/alesapin)) -- ثابت `ALTER ... MODIFY TTL` در تکرار غذای اصلی. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع درج در جدول توزیع شده با ستون محقق شده [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([ازات خوژین](https://github.com/azat)) -- رفع تخصیص بد زمانی که کوتاه پیوستن به ذخیره سازی [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([تسیسون](https://github.com/TCeason)) -- در نسخه های اخیر از بسته tzdata برخی از فایل ها symlinks در حال حاضر. مکانیسم فعلی برای تشخیص منطقه زمانی پیش فرض شکسته می شود و نام اشتباه برای برخی از جغرافیایی می دهد. در حال حاضر حداقل ما نام منطقه زمانی را مجبور به محتویات انجمن تاز در صورت فراهم. [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([ایوان](https://github.com/abyss7)) -- رفع برخی از موارد بسیار نادر با جستجوگر چندگانه هنگامی که سوزن ثابت در مجموع حداقل 16 کیلوبایت طولانی است. الگوریتم از دست رفته و یا بیش از حد نتایج قبلی که می تواند به نتیجه نادرست منجر شود `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([نام و نام خانوادگی](https://github.com/danlark1)) -- رفع مشکل زمانی که تنظیمات برای externaldata درخواست نمی تواند با استفاده از clickhouse تنظیمات. همچنین در حال حاضر تنظیمات `date_time_input_format` و `low_cardinality_allow_in_native_format` می تواند به دلیل ابهام از نام استفاده نمی شود (در داده های خارجی را می توان به عنوان فرمت جدول تفسیر و در پرس و جو می تواند یک محیط). [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([نام و نام خانوادگی](https://github.com/danlark1)) -- رفع اشکال زمانی که قطعات تنها از فدراسیون فوتبال بدون رها کردن از باغ وحش حذف شد. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([الساپین](https://github.com/alesapin)) -- حذف ورود اشکال زدایی از پروتکل خروجی زیر [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رد کردن زنود در طول پردازش پرس و جو دی ال [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([ازات خوژین](https://github.com/azat)) -- ثابت مخلوط `UNION ALL` نوع ستون نتیجه. موارد با داده های متناقض و انواع ستون ستون نتیجه وجود دارد. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([زویکوف](https://github.com/4ertus2)) -- پرتاب یک استثنا در اعداد صحیح اشتباه در `dictGetT` توابع به جای تصادف. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([زویکوف](https://github.com/4ertus2)) -- رفع اشتباه element\_count و load\_factor برای درهم لغت در `system.dictionaries` جدول [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([ازات خوژین](https://github.com/azat)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-9} - -- ساخت ثابت بدون `Brotli` پردازشگر پشتیبانی شده: (`ENABLE_BROTLI=OFF` هشدار داده می شود [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([انت یوژنینو](https://github.com/citrin)) -- شامل خروش.ساعت به عنوان خروش / خروشان.ه [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([اوروج دش](https://github.com/orivej)) -- رفع gcc9 هشدار در hyperscan (\#خط بخشنامه بد است!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([نام و نام خانوادگی](https://github.com/danlark1)) -- رفع تمام هشدارهای هنگام کامپایل با شورای همکاری خلیج فارس-9. رفع برخی از مشکلات احتمالی. یخ گرم9 رو درست کن و به باگزیلا بفرست [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([نام و نام خانوادگی](https://github.com/danlark1)) -- ثابت ارتباط با [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف تخصص های استفاده نشده در لغت نامه [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([زویکوف](https://github.com/4ertus2)) -- تست های عملکرد بهبود برای قالب بندی و تجزیه جداول برای انواع مختلف فایل ها [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- رفع تست موازی اجرا [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([پرولر](https://github.com/proller)) -- کارگر بارانداز: تنظیمات استفاده از کلیک-تست [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([پرولر](https://github.com/proller)) -- رفع کامپایل برای بورس [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([پرولر](https://github.com/proller)) -- ارتقا افزایش به 1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([پرولر](https://github.com/proller)) -- رفع ساخت clickhouse به عنوان submodule [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([پرولر](https://github.com/proller)) -- بهبود تست های عملکرد فوق العاده [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([ویتالی بارانو](https://github.com/vitlibar)) - -## انتشار کلیک 19.8 {#clickhouse-release-19-8} - -### انتشار کلیک خانه 19.8.3.8, 2019-06-11 {#clickhouse-release-19-8-3-8-2019-06-11} - -#### ویژگی های جدید {#new-features} - -- اضافه شدن توابع برای کار با جانسون [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([هکز](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([ویتالی بارانو](https://github.com/vitlibar)) -- اضافه کردن یک تابع basename با مشابه رفتار یک تابع basename که وجود دارد در بسیاری از زبان ها (`os.path.basename` در پایتون, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- اضافه شده `LIMIT n, m BY` یا `LIMIT m OFFSET n BY` نحو به مجموعه جبران نفر برای حد بند. [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([انتون پوپوف](https://github.com/CurtizJ)) -- نوع داده جدید اضافه شده است `SimpleAggregateFunction` که اجازه می دهد ستون ها را با تجمع نور در یک `AggregatingMergeTree`. این تنها می تواند با توابع ساده مانند استفاده می شود `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([بوریس گرانویو](https://github.com/bgranvea)) -- اضافه شدن پشتیبانی برای استدلال غیر ثابت در تابع `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اضافه شدن توابع `skewPop`, `skewSamp`, `kurtPop` و `kurtSamp` برای محاسبه به صورت دنباله skewness نمونه skewness, kurtosis و نمونه kurtosis بود. [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([هکز](https://github.com/hczhcz)) -- پشتیبانی تغییر نام عملیات برای `MaterializeView` انبار. [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- اضافه شده سرور که اجازه می دهد تا اتصال به تاتر با استفاده از مشتری خروجی زیر. [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([یوری بارانوف](https://github.com/yurriy)) -- افزودن `toDecimal*OrZero` و `toDecimal*OrNull` توابع. [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([زویکوف](https://github.com/4ertus2)) -- پشتیبانی از انواع دهدهی در توابع: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted`, medianExactWeighted. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اضافه شده `format` تابع. قالب بندی الگوی ثابت (الگوی فرمت پایتون ساده) با رشته های ذکر شده در استدلال. [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اضافه شده `system.detached_parts` جدول حاوی اطلاعات در مورد قطعات جدا شده از `MergeTree` میز [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([اکوزم](https://github.com/akuzm)) -- اضافه شده `ngramSearch` تابع برای محاسبه تفاوت غیر متقارن بین سوزن و انبار کاه. [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اجرای روشهای یادگیری ماشین پایه (رگرسیون خطی تصادفی و رگرسیون لجستیک) با استفاده از رابط توابع کل. دارای استراتژی های مختلف برای به روز رسانی وزن مدل (نزول گرادیان ساده, روش شتاب, روش نستروف). همچنین پشتیبانی از مینی دسته از اندازه های سفارشی. [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([کد37](https://github.com/Quid37)) -- اجرای `geohashEncode` و `geohashDecode` توابع. [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([واسیلی نمکو](https://github.com/Enmk)) -- اضافه شدن تابع جمع `timeSeriesGroupSum`, که می تواند سری های زمانی مختلف جمع می شوند که برچسب زمان نمونه هم ترازی نیست. این برون یابی خطی بین دو برچسب زمان نمونه و سپس مجموع زمان سری با هم استفاده کنید. اضافه شدن تابع جمع `timeSeriesGroupRateSum` که محاسبه نرخ زمان سری و سپس مجموع نرخ با هم. [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([یانگکوان لیو](https://github.com/LiuYangkuan)) -- اضافه شدن توابع `IPv4CIDRtoIPv4Range` و `IPv6CIDRtoIPv6Range` برای محاسبه محدوده های پایین تر و بالاتر برای یک ای پی در زیر شبکه با استفاده از یک سیدر. [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- اضافه کردن یک ایکس کلیک-هدر خلاصه زمانی که ما یک پرس و جو با استفاده از قام با تنظیم را فعال کنید ارسال `send_progress_in_http_headers`. بازگشت اطلاعات معمول از ایکس کلیک-پیشرفت, با اطلاعات اضافی مانند چند سطر و بایت در پرس و جو قرار داده شد. [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) - -#### بهبود {#improvements} - -- اضافه شده `max_parts_in_total` تنظیم برای خانواده ادغام جداول (به طور پیش فرض: 100 000) که مانع از مشخصات نا امن از کلید پارتیشن \#5166. [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `clickhouse-obfuscator`: استخراج دانه برای ستون های فردی با ترکیب دانه اولیه با نام ستون, موقعیت ستون نیست. این در نظر گرفته شده برای تبدیل مجموعه داده با جداول مرتبط متعدد, به طوری که جداول پس از تحول قابل اجرا باقی خواهد ماند. [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن توابع `JSONExtractRaw`, `JSONExtractKeyAndValues`. توابع تغییر نام داد `jsonExtract` به `JSONExtract`. هنگامی که چیزی را اشتباه می رود این توابع بازگشت ارزش خبرنگار, نه `NULL`. تابع اصلاح شده `JSONExtract` در حال حاضر نوع بازگشتی از پارامتر گذشته خود را دریافت می کند و نابل ها را تزریق نمی کند. اجرا مجدد به RapidJSON در مورد AVX2 دستورالعمل در دسترس نیست. کتابخانه سیمدجسون به روز شده به یک نسخه جدید. [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([ویتالی بارانو](https://github.com/vitlibar)) -- حالا `if` و `multiIf` توابع به وضعیت تکیه نمی کنند `Nullable`, اما در شاخه برای سازگاری گذاشتن تکیه. [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([جیان وو](https://github.com/janplus)) -- `In` گزاره در حال حاضر تولید می کند `Null` نتیجه از `Null` ورودی مانند `Equal` تابع. [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([جیان وو](https://github.com/janplus)) -- بررسی محدودیت زمانی هر (flush\_interval / poll\_timeout) تعداد سطر از کافکا. این اجازه می دهد تا خواندن را از مصرف کننده کافکا بیشتر کند و محدودیت های زمانی جریان های سطح بالا را بررسی کند [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([ایوان](https://github.com/abyss7)) -- لینک rdkafka با همراه sasl. باید اجازه می دهد به استفاده از sasl گریختن احراز هویت [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([ایوان](https://github.com/abyss7)) -- Batched نسخه RowRefList برای همه می پیوندد. [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([زویکوف](https://github.com/4ertus2)) -- کلیک سرور: اطلاعات بیشتر گوش پیام های خطا. [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([پرولر](https://github.com/proller)) -- واژهنامهها پشتیبانی در تاتر-کپی برای توابع در `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([پرولر](https://github.com/proller)) -- افزودن تنظیمات جدید `kafka_commit_every_batch` برای تنظیم کافکا ارتکاب سیاست. - این اجازه می دهد تا به مجموعه ای متعهد حالت: پس از هر دسته ای از پیام های به کار گرفته شده است, و یا پس از کل بلوک به ذخیره سازی نوشته شده. این یک تجارت بین از دست دادن برخی از پیام ها و یا خواندن دو بار در برخی شرایط شدید است. [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([ایوان](https://github.com/abyss7)) -- ساخت `windowFunnel` پشتیبانی از دیگر انواع عدد صحیح بدون علامت. [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- اجازه دادن به سایه ستون مجازی `_table` در ادغام موتور. [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([ایوان](https://github.com/abyss7)) -- ساخت `sequenceMatch` توابع مجموع پشتیبانی دیگر انواع عدد صحیح بدون علامت [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- پیام های خطا بهتر اگر عدم تطابق کنترلی است به احتمال زیاد توسط شکست سخت افزار ایجاد می شود. [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بررسی کنید که جداول پایه نمونه برداری را پشتیبانی می کنند `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([ایوان](https://github.com/abyss7)) -- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- بهبود پروتکل سیم خروجی زیر. تغییر نام قالب به میسورقلوایر. با استفاده از raii برای تماس rsa\_free. غیر فعال کردن اس اس ال اگر زمینه نمی تواند ایجاد شود. [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([یوری baranov](https://github.com/yurriy)) -- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([پرولر](https://github.com/proller)) -- تنظیمات پرس و جو احترام در درج ناهمزمان به جداول توزیع. [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([تسیسون](https://github.com/TCeason)) -- توابع تغییر نام داد `leastSqr` به `simpleLinearRegression`, `LinearRegression` به `linearRegression`, `LogisticRegression` به `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -#### بهبود عملکرد {#performance-improvements} - -- Parallelize پردازش قطعات غیر تکراری MergeTree جداول در تغییر و اصلاح پرس و جو. [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([ایوان کوش](https://github.com/IvanKush)) -- بهینه سازی در استخراج عبارات منظم. [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اضافه کردن راست پیوستن به ستون های کلیدی برای پیوستن به نتیجه اگر فقط در عضویت در بخش استفاده می شود. [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([زویکوف](https://github.com/4ertus2)) -- یخ بافر کافکا پس از اولین پاسخ خالی. از چندین اختراع اجتناب می کند `ReadBuffer::next()` برای نتیجه خالی در برخی از جریان ردیف تجزیه. [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([ایوان](https://github.com/abyss7)) -- `concat` بهینه سازی عملکرد برای استدلال های متعدد. [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([نام و نام خانوادگی](https://github.com/danlark1)) -- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([زویکوف](https://github.com/4ertus2)) -- پیاده سازی لنز 4 ما را با یک مرجع ارتقا دهید تا فشرده سازی سریع تر داشته باشید. [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([نام و نام خانوادگی](https://github.com/danlark1)) -- پردازشگر پشتیبانی شده: [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([اوگنی پراودا](https://github.com/kvinty)) - -#### رفع اشکال {#bug-fixes} - -- رفع فشار نیاز به ستون با پیوستن [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([زمستان ژانگ](https://github.com/zhang2014)) -- اشکال ثابت, زمانی که تاتر توسط سیستم اجرا, فرمان `sudo service clickhouse-server forcerestart` کار نمی کند به عنوان انتظار می رود. [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([پرولر](https://github.com/proller)) -- رفع کدهای خطای اچ. تی. اچ. تی. پی در کد 9009 پورت همیشه کد 200 را حتی در خطاها برگرداند. [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([پرولر](https://github.com/proller)) -- رفع simpleaggregatefunction برای رشته بیش از max\_small\_string\_size [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([ازات خوژین](https://github.com/azat)) -- رفع خطا برای `Decimal` به `Nullable(Decimal)` تبدیل در. پشتیبانی از دیگر دهدهی به دهدهی تبدیل (از جمله مقیاس های مختلف). [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([زویکوف](https://github.com/4ertus2)) -- مسدود کردن فلش ثابت در کتابخانه سیمدجسون که منجر به محاسبه اشتباه از `uniqHLL` و `uniqCombined` تابع کلی و توابع ریاضی مانند `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- دست زدن به ثابت موارد مخلوط ثابت/غیرنقدی در توابع جانسون. [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([ویتالی بارانو](https://github.com/vitlibar)) -- ثابت `retention` تابع. در حال حاضر تمام شرایطی که در یک ردیف از داده ها راضی به دولت داده ها اضافه شده است. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) -- رفع نوع نتیجه برای `quantileExact` با اعشار. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([زویکوف](https://github.com/4ertus2)) - -#### مستندات {#documentation} - -- ترجمه مستندات برای `CollapsingMergeTree` به سلامتی چینیها [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) -- ترجمه برخی از اسناد و مدارک در مورد موتورهای جدول به چینی. - [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) - [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) - ([هرگز لی](https://github.com/neverlee)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements} - -- رفع برخی از گزارش ضد عفونی که نشان می دهد احتمالی استفاده پس از رایگان.[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([ایوان](https://github.com/abyss7)) -- حرکت تست عملکرد از دایرکتوری جداگانه برای راحتی. [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع تست عملکرد نادرست. [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([الساپین](https://github.com/alesapin)) -- اضافه شدن یک ابزار برای محاسبه چک سام ناشی از کمی پایین بپرد به مشکلات اشکال زدایی سخت افزار. [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اسکریپت دونده قابل استفاده تر است. [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([فیلیمونف](https://github.com/filimonov)) -- اضافه کردن دستور العمل کوچک چگونه برای نوشتن تست عملکرد. [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([الساپین](https://github.com/alesapin)) -- اضافه کردن قابلیت تعویض در ایجاد, پر کردن و رها کردن پرس و جو در تست عملکرد [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([اولگا خوستیکوا](https://github.com/stavrolia)) - -## انتشار کلیک 19.7 {#clickhouse-release-19-7} - -### انتشار کلیک خانه 19.7.5.29, 2019-07-05 {#clickhouse-release-19-7-5-29-2019-07-05} - -#### رفع اشکال {#bug-fix-25} - -- رفع رگرسیون عملکرد در برخی از نمایش داده شد با پیوستن. [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([زمستان ژانگ](https://github.com/zhang2014)) - -### انتشار کلیک خانه 19.7.5.27, 2019-06-09 {#clickhouse-release-19-7-5-27-2019-06-09} - -#### ویژگی های جدید {#new-features-1} - -- اضافه شده توابع مربوط بیت مپ `bitmapHasAny` و `bitmapHasAll` مشابه به `hasAny` و `hasAll` توابع برای ارریس. [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([سرگی ولدیکین](https://github.com/svladykin)) - -#### رفع اشکال {#bug-fixes-1} - -- رفع segfault در `minmax` شاخص با ارزش صفر. [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- علامت گذاری به عنوان تمام ستون های ورودی در حد خروجی به عنوان مورد نیاز است. این رفع ‘Not found column’ خطا در برخی از نمایش داده شد توزیع. [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([پان سنتانتین](https://github.com/kvap)) -- ثابت “Column ‘0’ already exists” خطا در `SELECT .. PREWHERE` در ستون با پیش فرض [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([پرولر](https://github.com/proller)) -- ثابت `ALTER MODIFY TTL` پرسوجو در `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([انتون پوپوف](https://github.com/CurtizJ)) -- هنگامی که مصرف کنندگان کافکا برای شروع شکست خورده اند سرور تصادف نیست. [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([ایوان](https://github.com/abyss7)) -- توابع بیت مپ ثابت تولید نتیجه اشتباه است. [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([اندی یانگ](https://github.com/andyyzh)) -- حذف عناصر برای دیکشنری درهم (شامل موارد تکراری نیست) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([ازات خوژین](https://github.com/azat)) -- استفاده از محتویات محیط زیست تغییر تنظیمات متغیر به عنوان نام برای منطقه زمانی. این کمک می کند تا به درستی شناسایی منطقه زمانی پیش فرض در برخی موارد.[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([ایوان](https://github.com/abyss7)) -- سعی نکنید برای تبدیل اعداد صحیح در `dictGetT` توابع, چرا که به درستی کار نمی کند. پرتاب یک استثنا به جای. [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([زویکوف](https://github.com/4ertus2)) -- رفع تنظیمات در درخواست خارجی. [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([دنیلا - کوتنین](https://github.com/danlark1)) -- رفع اشکال زمانی که قطعات تنها از فدراسیون فوتبال بدون رها کردن از باغ وحش حذف شد. [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([الساپین](https://github.com/alesapin)) -- رفع گسل تقسیم بندی در `bitmapHasAny` تابع. [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([ژیچنگ یو](https://github.com/yuzhichang)) -- خطا ثابت زمانی که استخر اتصال تکرار کند سعی مجدد نیست برای حل و فصل میزبان, حتی زمانی که کش دی ان اس کاهش یافته بود. [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([الساپین](https://github.com/alesapin)) -- ثابت `DROP INDEX IF EXISTS` پرس و جو. حالا `ALTER TABLE ... DROP INDEX IF EXISTS ...` پرس و جو یک استثنا را افزایش نمی دهد اگر شاخص وجود ندارد. [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([گلب نویکوف](https://github.com/NanoBjorn)) -- رفع اتحادیه تمام ستون نوع فوق. موارد با داده های متناقض و انواع ستون ستون نتیجه وجود دارد. [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([زویکوف](https://github.com/4ertus2)) -- جست و خیز znonode در طول دستورات پرس و جو پردازش. قبل از اگر گره دیگر حذف زنود در صف کار, یکی که - اما در حال حاضر لیستی از کودکان را دریافت نمی کند موضوع کار کرم را خاتمه می دهد. [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([ازات خوژین](https://github.com/azat)) -- ثابت قرار دادن به توزیع() جدول با ستون محقق. [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([ازات خوژین](https://github.com/azat)) - -### انتشار کلیک خانه 19.7.3.9, 2019-05-30 {#clickhouse-release-19-7-3-9-2019-05-30} - -#### ویژگی های جدید {#new-features-2} - -- اجازه می دهد برای محدود کردن طیف وسیعی از یک محیط است که می تواند توسط کاربر مشخص شده است. - این محدودیت ها را می توان در مشخصات تنظیمات کاربر تنظیم شده است. - [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([ویتالی - بارانوف](https://github.com/vitlibar)) -- اضافه کردن نسخه دوم از تابع `groupUniqArray` با اختیاری - `max_size` پارامتر که اندازه مجموعه نتیجه را محدود می کند. این - رفتار شبیه به `groupArray(max_size)(x)` تابع. - [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([گیمه - کاسری](https://github.com/YiuRULE)) -- برای tsvwithnames/csvwithnames ورودی فرمت های فایل های ستون سفارش در حال حاضر می تواند - تعیین شده از هدر فایل. این است که با کنترل - `input_format_with_names_use_header` پارامتر. - [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) - ([الکساندر](https://github.com/Akazz)) - -#### رفع اشکال {#bug-fixes-2} - -- سقوط با غیر فشرده + عضویت در هنگام ادغام (\#5197) - [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([دنیلا - کوتنین](https://github.com/danlark1)) -- گسل تقسیم بندی در یک پرس و جو کلیک مشتری به جداول سیستم. \#5066 - [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) - ([ایوان](https://github.com/abyss7)) -- از دست دادن داده ها در بار سنگین از طریق کافکاینگین (\#4736) - [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) - ([ایوان](https://github.com/abyss7)) -- ثابت شرایط مسابقه داده بسیار نادر است که می تواند در هنگام اجرای یک پرس و جو با اتحادیه همه شامل حداقل دو انتخاب از سیستم اتفاق می افتد.ستون, سیستم.جداول, سیستم.قطعات, سیستم.\_شبردارها یا جداول ادغام خانواده و انجام تغییر ستون از جداول مرتبط به صورت همزمان. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود عملکرد {#performance-improvements-1} - -- استفاده از مرتب سازی بر رادیوگرافی برای مرتب سازی بر اساس ستون عددی در `ORDER BY` بدون - `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), - [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) - ([اوگنی پراودا](https://github.com/kvinty), - [الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### مستندات {#documentation-1} - -- ترجمه اسناد و مدارک برای برخی از موتورهای جدول به چینی. - [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), - [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), - [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) - ([张风啸](https://github.com/AlexZFX)), - [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([هرگز - لی](https://github.com/neverlee)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-1} - -- نسخه قابل چاپ سخن گفتن-8 کاراکتر به درستی در `clickhouse-test`. - [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) - ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن پارامتر خط فرمان برای فاحشه خانه-مشتری برای همیشه بار پیشنهاد - داده ها. [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) - ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حل و فصل برخی از هشدارهای پوس استودیو. - [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) - ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز رسانی lz4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([دنیلا - کوتنین](https://github.com/danlark1)) -- اضافه کردن پردازنده گرافیکی برای ساخت الزامات مورد نیاز برای درخواست پیش رو کشیدن \# 5030. - [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) - ([پرولر](https://github.com/proller)) - -## انتشار کلیک 19.6 {#clickhouse-release-19-6} - -### انتشار کلیک خانه 19.6.3.18, 2019-06-13 {#clickhouse-release-19-6-3-18-2019-06-13} - -#### رفع اشکال {#bug-fixes-3} - -- ثابت در شرایط فشار برای نمایش داده شد از توابع جدول `mysql` و `odbc` و موتورهای جدول مربوطه. این رفع \# 3540 و \# 2384. [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع بن بست در باغ وحش. [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([گیتهاب 1یولک](https://github.com/github1youlc)) -- اجازه اعشار نقل در سی سی. وی. [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([زویکوف](https://github.com/4ertus2) -- عدم تبدیل از اینف شناور / نان به اعشار (استثنا پرتاب). [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([زویکوف](https://github.com/4ertus2)) -- رفع مسابقه داده ها در تغییر نام پرس و جو. [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([زمستان ژانگ](https://github.com/zhang2014)) -- به طور موقت غیر فعال کردن کلیک. استفاده از lfalloc ممکن است منجر به بسیاری از map\_failed در تخصیص uncompressedcache و در نتیجه به سقوط از نمایش داده شد در بالا لود سرور. [لامپ کم مصرف93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([نام و نام خانوادگی](https://github.com/danlark1)) - -### انتشار کلیک خانه 19.6.2.11, 2019-05-13 {#clickhouse-release-19-6-2-11-2019-05-13} - -#### ویژگی های جدید {#new-features-3} - -- عبارات برای ستون ها و جداول. [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([انتون پوپوف](https://github.com/CurtizJ)) -- اضافه شدن پشتیبانی برای `brotli` فشردهسازی برای پاسخهای قام (پذیرش کدبندی: برزیلی) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([میخیل](https://github.com/fandyushin)) -- اضافه شدن تابع جدید `isValidUTF8` برای بررسی اینکه مجموعه ای از بایت ها به درستی کد گذاری شده باشد-8. [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اضافه کردن سیاست متعادل کننده بار جدید `first_or_random` که نمایش داده شد به اولین میزبان مشخص می فرستد و اگر غیر قابل دسترس ارسال نمایش داده شد به میزبان تصادفی از سفال. مفید برای تنظیم توپولوژی متقابل تکرار. [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([نوارتولومی](https://github.com/nvartolomei)) - -#### ویژگی های تجربی {#experimental-features-1} - -- افزودن تنظیمات `index_granularity_bytes` (تطبیقی دانه دانه دانه شاخص) برای ادغام \* خانواده جداول. [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([الساپین](https://github.com/alesapin)) - -#### بهبود {#improvements-1} - -- اضافه شدن پشتیبانی برای اندازه و طول استدلال غیر ثابت و منفی برای عملکرد `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- غیر فعال کردن فشار به پایین به جدول سمت راست در سمت چپ عضویت, جدول سمت چپ در راست عضویت, و هر دو جدول به طور کامل ملحق. این رفع اشتباه پیوستن به نتایج در برخی موارد. [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([ایوان](https://github.com/abyss7)) -- `clickhouse-copier`: بارگذاری خودکار پیکربندی وظیفه از `--task-file` گزینه [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([پرولر](https://github.com/proller)) -- اضافه شده کنترل غلط املایی برای کارخانه ذخیره سازی و توابع جدول کارخانه. [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([نام و نام خانوادگی](https://github.com/danlark1)) -- ستاره پشتیبانی و ستاره واجد شرایط برای چند می پیوندد بدون زیر کشت [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([زویکوف](https://github.com/4ertus2)) -- پیام خطای ستون گم شده را کاربر پسند تر کنید. [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([زویکوف](https://github.com/4ertus2)) - -#### بهبود عملکرد {#performance-improvements-2} - -- افزایش سرعت قابل توجهی از عضویت [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([مرتیجن باکر](https://github.com/Gladdy)) - -#### تغییرات ناسازگار به عقب {#backward-incompatible-changes} - -- HTTP header `Query-Id` به تغییر نام داد `X-ClickHouse-Query-Id` برای ثبات. [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([میخیل](https://github.com/fandyushin)) - -#### رفع اشکال {#bug-fixes-4} - -- اختلاف اشاره گر صفر پتانسیل ثابت در `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([پرولر](https://github.com/proller)) -- خطای ثابت در پرس و جو با پیوستن + مجموعه پیوستن [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([زویکوف](https://github.com/4ertus2)) -- ثابت معلق در شروع سرور زمانی که یک فرهنگ لغت بستگی به فرهنگ لغت دیگری از طریق یک پایگاه داده با موتور=فرهنگ لغت. [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([ویتالی بارانو](https://github.com/vitlibar)) -- Partially fix distributed\_product\_mode = local. It's possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There's not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([زویکوف](https://github.com/4ertus2)) -- رفع نتیجه به طور بالقوه اشتباه برای `SELECT DISTINCT` با `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([زویکوف](https://github.com/4ertus2)) -- ثابت شرایط مسابقه داده بسیار نادر است که می تواند در هنگام اجرای یک پرس و جو با اتحادیه همه شامل حداقل دو انتخاب از سیستم اتفاق می افتد.ستون, سیستم.جداول, سیستم.قطعات, سیستم.\_شبردارها یا جداول ادغام خانواده و انجام تغییر ستون از جداول مرتبط به صورت همزمان. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-2} - -- شکست تست ثابت زمانی که در حال اجرا خانه عروسکی سرور در میزبان های مختلف [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([واسیلی نمکو](https://github.com/Enmk)) -- تاتر-تست: غیر فعال کردن توالی کنترل رنگ در محیط غیر تیتی. [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([الساپین](https://github.com/alesapin)) -- کلیک-تست: اجازه استفاده از هر پایگاه داده تست (برداشتن `test.` صلاحیت در صورت امکان) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([پرولر](https://github.com/proller)) -- رفع خطاهای اوبان [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([ویتالی بارانو](https://github.com/vitlibar)) -- Yandex LFAlloc اضافه شد به ClickHouse به تخصیص MarkCache و UncompressedCache داده ها در روش های مختلف برای گرفتن segfaults بیشتر قابل اعتماد [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([نام و نام خانوادگی](https://github.com/danlark1)) -- پایتون ییل برای کمک به با کوله پشتی و تغییرات. [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([ایوان](https://github.com/abyss7)) - -## انتشار کلیک 19.5 {#clickhouse-release-19-5} - -### انتشار کلیک خانه 19.5.4.22, 2019-05-13 {#clickhouse-release-19-5-4-22-2019-05-13} - -#### رفع اشکال {#bug-fixes-5} - -- تصادف ممکن است ثابت در بیت مپ [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([اندی یانگ](https://github.com/andyyzh)) -- ثابت شرایط مسابقه داده بسیار نادر است که می تواند در هنگام اجرای یک پرس و جو با اتحادیه همه شامل حداقل دو انتخاب از سیستم اتفاق می افتد.ستون, سیستم.جداول, سیستم.قطعات, سیستم.\_شبردارها یا جداول ادغام خانواده و انجام تغییر ستون از جداول مرتبط به صورت همزمان. [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطای ثابت `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. این خطا اتفاق افتاد اگر ستون کمکاری بخشی از کلید اصلی بود. \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اصلاح تابع حفظ و نگهداری: اگر یک ردیف ارضا هر دو شرط اول و بعد از ظهر, تنها اولین شرط راضی به دولت داده اضافه. در حال حاضر تمام شرایطی که در یک ردیف از داده ها راضی به دولت داده ها اضافه شده است. [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) - -### انتشار کلیک خانه 19.5.3.8, 2019-04-18 {#clickhouse-release-19-5-3-8-2019-04-18} - -#### رفع اشکال {#bug-fixes-6} - -- نوع ثابت تنظیم `max_partitions_per_insert_block` از بولی به UInt64. [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([محمد حسین sekhavat](https://github.com/mhsekhavat)) - -### انتشار کلیک خانه 19.5.2.6, 2019-04-15 {#clickhouse-release-19-5-2-6-2019-04-15} - -#### ویژگی های جدید {#new-features-4} - -- [Hyperscan](https://github.com/intel/hyperscan) تطبیق عبارت منظم چندگانه اضافه شد (توابع `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([نام و نام خانوادگی](https://github.com/danlark1)) -- `multiSearchFirstPosition` تابع اضافه شد. [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([نام و نام خانوادگی](https://github.com/danlark1)) -- فیلتر بیان از پیش تعریف شده را در هر ردیف برای جداول اجرا کنید. [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([ایوان](https://github.com/abyss7)) -- نوع جدیدی از شاخص های داده پرش بر اساس فیلتر بلوم (می تواند برای استفاده `equal`, `in` و `like` توابع). [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- اضافه شده `ASOF JOIN` که اجازه می دهد برای اجرای نمایش داده شد که پیوستن به ارزش های اخیر شناخته شده است. [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([مرتیجن باکر](https://github.com/Gladdy), [زویکوف](https://github.com/4ertus2)) -- بازنویسی چندگانه `COMMA JOIN` به `CROSS JOIN`. سپس دوباره نوشتن به `INNER JOIN` در صورت امکان. [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([زویکوف](https://github.com/4ertus2)) - -#### بهبود {#improvement-9} - -- `topK` و `topKWeighted` در حال حاضر پشتیبانی سفارشی `loadFactor` (رفع مشکل [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([Kirill Danshin](https://github.com/kirillDanshin)) -- مجاز به استفاده `parallel_replicas_count > 1` حتی برای جداول بدون نمونه گیری (تنظیم به سادگی برای نادیده گرفته می شود). در نسخه های قبلی منجر به استثنا شد. [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([الکسی الیمانوف](https://github.com/digitalist)) -- پشتیبانی از `CREATE OR REPLACE VIEW`. اجازه می دهد برای ایجاد یک نمایش و یا تنظیم یک تعریف جدید در یک بیانیه واحد. [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([بوریس گرانویو](https://github.com/bgranvea)) -- `Buffer` موتور جدول در حال حاضر پشتیبانی می کند `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([یانگکوان لیو](https://github.com/LiuYangkuan)) -- اضافه کردن توانایی برای شروع جدول تکرار بدون ابرداده در باغ وحش در `readonly` حالت. [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([الساپین](https://github.com/alesapin)) -- سوسو زدن ثابت از نوار پیشرفت در خانه کلیک مشتری. این موضوع در هنگام استفاده قابل توجه بود `FORMAT Null` با نمایش داده شد جریان. [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه برای غیر فعال کردن توابع با `hyperscan` کتابخانه بر اساس هر کاربر برای محدود کردن استفاده از منابع بالقوه بیش از حد و کنترل نشده. [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن شماره نسخه ورود به سیستم در تمام اشتباهات. [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([پرولر](https://github.com/proller)) -- محدودیت اضافه شده به `multiMatch` توابع که نیاز به اندازه رشته به جا به `unsigned int`. همچنین اضافه شده تعداد استدلال محدود به `multiSearch` توابع. [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([نام و نام خانوادگی](https://github.com/danlark1)) -- استفاده بهبود یافته از فضای خراش و دست زدن به خطا در هیپرسکان. [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([نام و نام خانوادگی](https://github.com/danlark1)) -- پر کردن `system.graphite_detentions` از پیکربندی جدول `*GraphiteMergeTree` جداول موتور. [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- تغییر نام `trigramDistance` تابع به `ngramDistance` و اضافه کردن توابع بیشتر با `CaseInsensitive` و `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([نام و نام خانوادگی](https://github.com/danlark1)) -- داده های بهبود پرش محاسبه شاخص. [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- عادی نگه دارید, `DEFAULT`, `MATERIALIZED` و `ALIAS` ستون ها در یک لیست واحد (رفع مشکل [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([الکس زتلپین](https://github.com/ztlpn)) - -#### رفع اشکال {#bug-fix-26} - -- اجتناب از `std::terminate` در صورت شکست تخصیص حافظه. حالا `std::bad_alloc` استثنا پرتاب به عنوان انتظار می رود. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع کاپپروتو خواندن از بافر. گاهی اوقات فایل ها با موفقیت توسط اچ تی پی لود نمی شد. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ولادیسلاو](https://github.com/smirnov-vs)) -- رفع خطا `Unknown log entry type: 0` پس از `OPTIMIZE TABLE FINAL` پرس و جو. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([ایموس پرنده](https://github.com/amosbird)) -- نشانوندهای نادرست برای `hasAny` یا `hasAll` توابع ممکن است منجر به تقسیم بندی شوند. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بن بست ممکن است رخ دهد در حالی که اجرای `DROP DATABASE dictionary` پرس و جو. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع رفتار تعریف نشده در `median` و `quantile` توابع. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([هکز](https://github.com/hczhcz)) -- رفع تشخیص سطح فشرده سازی زمانی که `network_compression_method` با حروف کوچک. شکسته در و19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([پرولر](https://github.com/proller)) -- جهل ثابت `UTC` تنظیم (رفع مشکل [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([پرولر](https://github.com/proller)) -- ثابت `histogram` رفتار عملکرد با `Distributed` میز [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([اولگ](https://github.com/olegkv)) -- ثابت گزارش تسان `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- گزارش ساان ثابت در خاموش کردن با توجه به شرایط مسابقه در استفاده از سیستم سیاهههای مربوط. استفاده از پتانسیل ثابت-پس از رایگان در خاموش کردن زمانی که قطعه فعال است. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع قطعات بررسی مجدد در `ReplicatedMergeTreeAlterThread` در صورت خطا. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- عملیات ریاضی در کشورهای تابع جمع متوسط برای استدلال ثابت کار نمی کند (مانند نتایج زیرخاکی). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نام ستون همیشه نقل مکان کردن در ابرداده. در غیر این صورت ایجاد یک جدول با ستون به نام غیرممکن است `index` (سرور به دلیل ناقص راه اندازی مجدد نخواهد شد `ATTACH` پرس و جو در ابرداده). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع سقوط در `ALTER ... MODIFY ORDER BY` روشن `Distributed` جدول [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([تسیسون](https://github.com/TCeason)) -- رفع segfault در `JOIN ON` با فعال `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([زمستان ژانگ](https://github.com/zhang2014)) -- رفع اشکال با اضافه کردن یک ردیف غیر اصلی پس از مصرف یک پیام محافظ از کافکا. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع سقوط از `JOIN` نه-nullable در مقابل nullable ستون. ثابت `NULLs` در کلید سمت راست در `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([زویکوف](https://github.com/4ertus2)) -- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) -- شرایط مسابقه ثابت در `SELECT` از `system.tables` اگر جدول تغییر نام و یا تغییر به صورت همزمان. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- مسابقه داده ثابت زمانی که واکشی بخش داده است که در حال حاضر منسوخ شده است. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- مسابقه داده های نادر ثابت که می تواند در طول اتفاق می افتد `RENAME` جدول خانواده ادغام. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- گسل تقسیم بندی ثابت در عملکرد `arrayIntersect`. گسل تقسیم بندی می تواند رخ دهد اگر تابع با استدلال ثابت و عادی مخلوط نامیده می شد. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang کیان](https://github.com/fancyqlx)) -- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع سقوط در `FULL/RIGHT JOIN` هنگامی که ما در پیوستن به nullable در مقابل نه nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([زویکوف](https://github.com/4ertus2)) -- ثابت `No message received` استثنا در حالی که دلربا قطعات بین کپی. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([الساپین](https://github.com/alesapin)) -- ثابت `arrayIntersect` عملکرد نتیجه اشتباه در مورد چندین مقدار تکرار در مجموعه تک. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع شرایط مسابقه در طول همزمان `ALTER COLUMN` نمایش داده شد که می تواند به یک تصادف سرور منجر شود (رفع مشکل [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([الکس زتلپین](https://github.com/ztlpn)) -- رفع نتیجه نادرست در `FULL/RIGHT JOIN` با ستون توایع. [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([زویکوف](https://github.com/4ertus2)) -- رفع موارد تکراری در `GLOBAL JOIN` با ستاره. [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([زویکوف](https://github.com/4ertus2)) -- رفع کسر پارامتر در `ALTER MODIFY` از ستون `CODEC` هنگامی که نوع ستون مشخص نشده است. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([الساپین](https://github.com/alesapin)) -- توابع `cutQueryStringAndFragment()` و `queryStringAndFragment()` در حال حاضر به درستی کار می کند زمانی که `URL` شامل یک قطعه و بدون پرس و جو. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع اشکال نادر هنگام تنظیم `min_bytes_to_use_direct_io` بزرگتر از صفر است, که رخ می دهد زمانی که موضوع باید به دنبال عقب در فایل ستون. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([الساپین](https://github.com/alesapin)) -- رفع انواع استدلال اشتباه برای توابع مجموع با `LowCardinality` نشانوندها (رفع مشکل [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع صلاحیت نام اشتباه در `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([زویکوف](https://github.com/4ertus2)) -- تابع ثابت `toISOWeek` نتیجه برای سال 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `DROP`, `TRUNCATE` و `OPTIMIZE` نمایش داده شد تقلید, زمانی که در اجرا `ON CLUSTER` برای `ReplicatedMergeTree*` خانواده جداول. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([الساپین](https://github.com/alesapin)) - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-8} - -- تغییر نام تنظیمات `insert_sample_with_metadata` به تنظیم `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([زویکوف](https://github.com/4ertus2)) -- اضافه شدن تنظیمات `max_partitions_per_insert_block` (با مقدار 100 به طور پیش فرض). اگر بلوک قرار داده شامل تعداد بیشتری از پارتیشن, یک استثنا پرتاب می شود. تنظیم به 0 اگر شما می خواهید به حذف حد (توصیه نمی شود). [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- توابع چند جستجو تغییر نام داد (`multiPosition` به `multiSearchAllPositions`, `multiSearch` به `multiSearchAny`, `firstMatch` به `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([نام و نام خانوادگی](https://github.com/danlark1)) - -#### بهبود عملکرد {#performance-improvement-6} - -- بهینه سازی volnitsky جستجوگر توسط inlining دادن حدود 5-10% بهبود جستجو برای نمایش داده شد و با بسیاری از سوزن و یا بسیاری از شبیه bigrams. [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([نام و نام خانوادگی](https://github.com/danlark1)) -- رفع مشکل عملکرد در هنگام تنظیم `use_uncompressed_cache` بزرگتر از صفر است, که به نظر می رسد زمانی که همه اطلاعات به عنوان خوانده شده موجود در کش. [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([الساپین](https://github.com/alesapin)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-10} - -- سخت شدن اشکال زدایی ساخت: بیشتر نگاشت حافظه دانه و اصل مطلب; اضافه کردن حفاظت از حافظه برای کش علامت و شاخص. این اجازه می دهد تا برای پیدا کردن حافظه بیشتر کوبیدن اشکالات در صورتی که زمانی که اسان و ام اسان نمی تواند این کار را انجام. [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن پشتیبانی از متغیرهای کیک `ENABLE_PROTOBUF`, `ENABLE_PARQUET` و `ENABLE_BROTLI` که اجازه می دهد برای فعال/غیر فعال کردن ویژگی های فوق (همان است که ما می توانیم برای کتابدار انجام, خروجی زیر, و غیره). [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([سیلو کاراژیا](https://github.com/silviucpp)) -- اضافه کردن توانایی برای چاپ لیست روند و بند از تمام موضوعات اگر برخی از نمایش داده شد پس از اجرای تست را قطع کرد. [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([الساپین](https://github.com/alesapin)) -- اضافه کردن مجدد در `Connection loss` خطا در `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([الساپین](https://github.com/alesapin)) -- اضافه کردن ساخت بورس با ولگرد و ساخت با ضد عفونی کننده موضوع به اسکریپت بسته بندی. [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([الساپین](https://github.com/alesapin)) -- در حال حاضر کاربر برای رمز عبور برای کاربر خواسته `'default'` در هنگام نصب. [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([پرولر](https://github.com/proller)) -- سرکوب هشدار در `rdkafka` کتابخونه. [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه توانایی ساخت بدون اس اس ال. [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([پرولر](https://github.com/proller)) -- اضافه کردن یک راه برای راه اندازی تاتر-تصویر سرور از یک کاربر سفارشی. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- ارتقا تقویت میله به 1.69. [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([پرولر](https://github.com/proller)) -- غیر فعال کردن استفاده از `mremap` هنگامی که با ضد عفونی کننده موضوع وارد شده است. با کمال تعجب به اندازه کافی, تسان می کند رهگیری نیست `mremap` (هر چند که رهگیری `mmap`, `munmap`) که منجر به مثبت کاذب. گزارش تسان ثابت در تست نفرت انگیز. [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن چک کردن تست با استفاده از طرح فرمت از طریق رابط قام. [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([ویتالی بارانو](https://github.com/vitlibar)) - -## انتشار کلیک 19.4 {#clickhouse-release-19-4} - -### انتشار کلیک خانه 19.4.33, 2019-04-17 {#clickhouse-release-19-4-4-33-2019-04-17} - -#### رفع اشکال {#bug-fixes-7} - -- اجتناب از `std::terminate` در صورت شکست تخصیص حافظه. حالا `std::bad_alloc` استثنا پرتاب به عنوان انتظار می رود. [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع کاپپروتو خواندن از بافر. گاهی اوقات فایل ها با موفقیت توسط اچ تی پی لود نمی شد. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ولادیسلاو](https://github.com/smirnov-vs)) -- رفع خطا `Unknown log entry type: 0` پس از `OPTIMIZE TABLE FINAL` پرس و جو. [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([ایموس پرنده](https://github.com/amosbird)) -- نشانوندهای نادرست برای `hasAny` یا `hasAll` توابع ممکن است منجر به تقسیم بندی شوند. [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بن بست ممکن است رخ دهد در حالی که اجرای `DROP DATABASE dictionary` پرس و جو. [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع رفتار تعریف نشده در `median` و `quantile` توابع. [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([هکز](https://github.com/hczhcz)) -- رفع تشخیص سطح فشرده سازی زمانی که `network_compression_method` با حروف کوچک. شکسته در و19.1. [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([پرولر](https://github.com/proller)) -- جهل ثابت `UTC` تنظیم (رفع مشکل [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([پرولر](https://github.com/proller)) -- ثابت `histogram` رفتار عملکرد با `Distributed` میز [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([اولگ](https://github.com/olegkv)) -- ثابت گزارش تسان `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- گزارش ساان ثابت در خاموش کردن با توجه به شرایط مسابقه در استفاده از سیستم سیاهههای مربوط. استفاده از پتانسیل ثابت-پس از رایگان در خاموش کردن زمانی که قطعه فعال است. [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع قطعات بررسی مجدد در `ReplicatedMergeTreeAlterThread` در صورت خطا. [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- عملیات ریاضی در کشورهای تابع جمع متوسط برای استدلال ثابت کار نمی کند (مانند نتایج زیرخاکی). [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نام ستون همیشه نقل مکان کردن در ابرداده. در غیر این صورت ایجاد یک جدول با ستون به نام غیرممکن است `index` (سرور به دلیل ناقص راه اندازی مجدد نخواهد شد `ATTACH` پرس و جو در ابرداده). [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع سقوط در `ALTER ... MODIFY ORDER BY` روشن `Distributed` جدول [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([تسیسون](https://github.com/TCeason)) -- رفع segfault در `JOIN ON` با فعال `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([زمستان ژانگ](https://github.com/zhang2014)) -- رفع اشکال با اضافه کردن یک ردیف غیر اصلی پس از مصرف یک پیام محافظ از کافکا. [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) -- شرایط مسابقه ثابت در `SELECT` از `system.tables` اگر جدول تغییر نام و یا تغییر به صورت همزمان. [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- مسابقه داده ثابت زمانی که واکشی بخش داده است که در حال حاضر منسوخ شده است. [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- مسابقه داده های نادر ثابت که می تواند در طول اتفاق می افتد `RENAME` جدول خانواده ادغام. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- گسل تقسیم بندی ثابت در عملکرد `arrayIntersect`. گسل تقسیم بندی می تواند رخ دهد اگر تابع با استدلال ثابت و عادی مخلوط نامیده می شد. [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang کیان](https://github.com/fancyqlx)) -- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- ثابت `No message received` استثنا در حالی که دلربا قطعات بین کپی. [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([الساپین](https://github.com/alesapin)) -- ثابت `arrayIntersect` عملکرد نتیجه اشتباه در مورد چندین مقدار تکرار در مجموعه تک. [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع شرایط مسابقه در طول همزمان `ALTER COLUMN` نمایش داده شد که می تواند به یک تصادف سرور منجر شود (رفع مشکل [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([الکس زتلپین](https://github.com/ztlpn)) -- رفع کسر پارامتر در `ALTER MODIFY` از ستون `CODEC` هنگامی که نوع ستون مشخص نشده است. [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([الساپین](https://github.com/alesapin)) -- توابع `cutQueryStringAndFragment()` و `queryStringAndFragment()` در حال حاضر به درستی کار می کند زمانی که `URL` شامل یک قطعه و بدون پرس و جو. [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع اشکال نادر هنگام تنظیم `min_bytes_to_use_direct_io` بزرگتر از صفر است, که رخ می دهد زمانی که موضوع باید به دنبال عقب در فایل ستون. [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([الساپین](https://github.com/alesapin)) -- رفع انواع استدلال اشتباه برای توابع مجموع با `LowCardinality` نشانوندها (رفع مشکل [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- تابع ثابت `toISOWeek` نتیجه برای سال 1970. [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `DROP`, `TRUNCATE` و `OPTIMIZE` نمایش داده شد تقلید, زمانی که در اجرا `ON CLUSTER` برای `ReplicatedMergeTree*` خانواده جداول. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([الساپین](https://github.com/alesapin)) - -#### بهبود {#improvements-2} - -- عادی نگه دارید, `DEFAULT`, `MATERIALIZED` و `ALIAS` ستون ها در یک لیست واحد (رفع مشکل [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([الکس زتلپین](https://github.com/ztlpn)) - -### انتشار کلیک کنیدهاوس 19.4.3.11, 2019-04-02 {#clickhouse-release-19-4-3-11-2019-04-02} - -#### رفع اشکال {#bug-fixes-8} - -- رفع سقوط در `FULL/RIGHT JOIN` هنگامی که ما در پیوستن به nullable در مقابل نه nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([زویکوف](https://github.com/4ertus2)) -- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-11} - -- اضافه کردن یک راه برای راه اندازی تاتر-تصویر سرور از یک کاربر سفارشی. [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### انتشار کلیک خانه 19.4.2.7, 2019-03-30 {#clickhouse-release-19-4-2-7-2019-03-30} - -#### رفع اشکال {#bug-fixes-9} - -- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -### انتشار کلیک خانه 19.4.1.3, 2019-03-19 {#clickhouse-release-19-4-1-3-2019-03-19} - -#### رفع اشکال {#bug-fixes-10} - -- نمایش داده شد از راه دور ثابت که شامل هر دو `LIMIT BY` و `LIMIT`. قبلا اگر `LIMIT BY` و `LIMIT` برای پرس و جو از راه دور استفاده شد, `LIMIT` می تواند قبل از اتفاق می افتد `LIMIT BY`, که منجر به نتیجه بیش از حد فیلتر. [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([پان سنتانتین](https://github.com/kvap)) - -### انتشار کلیک خانه 19.4.0.49, 2019-03-09 {#clickhouse-release-19-4-0-49-2019-03-09} - -#### ویژگی های جدید {#new-features-5} - -- اضافه شدن پشتیبانی کامل برای `Protobuf` قالب (ورودی و خروجی, ساختارهای داده تو در تو). [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([ویتالی بارانو](https://github.com/vitlibar)) -- توابع بیت مپ اضافه شده با بیت مپ خروشان. [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([اندی یانگ](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([ویتالی بارانو](https://github.com/vitlibar)) -- پشتیبانی از فرمت پارکت. [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([پرولر](https://github.com/proller)) -- فاصله ان گرم برای مقایسه رشته فازی اضافه شد. این شبیه به معیارهای پرسش گرم در زبان تحقیق است. [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([نام و نام خانوادگی](https://github.com/danlark1)) -- ترکیب قوانین برای رولپ گرافیت از تجمع اختصاصی و الگوهای نگهداری. [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- اضافه شده `max_execution_speed` و `max_execution_speed_bytes` برای محدود کردن استفاده از منابع. اضافه شده `min_execution_speed_bytes` تنظیم برای تکمیل `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([زمستان ژانگ](https://github.com/zhang2014)) -- تابع اجرا شده `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([الکسی میلویدو](https://github.com/alexey-milovidov), [کزون](https://github.com/kzon)) -- اضافه شدن توابع `arrayEnumerateDenseRanked` و `arrayEnumerateUniqRanked` (مثل این است `arrayEnumerateUniq` اما اجازه می دهد تا به عمق مجموعه لحن خوب به داخل مجموعه چند بعدی نگاه). [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([پرولر](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([زویکوف](https://github.com/4ertus2)) - -#### رفع اشکال {#bug-fixes-11} - -- این نسخه همچنین شامل تمام رفع اشکال از 19.3 و 19.1. -- اشکال ثابت در داده های پرش شاخص: سفارش گرانول پس از درج نادرست بود. [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- ثابت `set` نمایه برای `Nullable` و `LowCardinality` ستون ها قبل از اون, `set` نمایه با `Nullable` یا `LowCardinality` ستون منجر به خطا `Data type must be deserialized with multiple streams` در حالی که انتخاب. [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- به درستی تنظیم update\_time کامل `executable` فرهنگ لغت به روز رسانی. [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([تما نویکوف](https://github.com/temoon)) -- رفع نوار پیشرفت شکسته در 19.3. [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([فیلیمونف](https://github.com/filimonov)) -- مقادیر متناقض ثابت از یادداشت دوست داشتنی زمانی که منطقه حافظه کفن شد, در موارد خاص. [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفتار تعریف نشده ثابت در استخر. [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تصادف بسیار نادر با پیام را ثابت کرد `mutex lock failed: Invalid argument` که می تواند رخ دهد زمانی که یک جدول ادغام همزمان با انتخاب کاهش یافته بود. [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([الکس زتلپین](https://github.com/ztlpn)) -- سازگاری درایور اودن بی سی با `LowCardinality` نوع داده. [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([پرولر](https://github.com/proller)) -- FreeBSD: Fixup برای `AIOcontextPool: Found io_event with unknown id 0` خطا. [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([هشدار داده می شود](https://github.com/urgordeadbeef)) -- `system.part_log` جدول ایجاد شد بدون در نظر گرفتن به پیکربندی. [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع رفتار تعریف نشده در `dictIsIn` تابع برای لغت نامه کش. [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([الساپین](https://github.com/alesapin)) -- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([الکس زتلپین](https://github.com/ztlpn)) -- غیر فعال کردن اکسپرس به طور پیش فرض تا زمانی که ما خود را دریافت کنید `llvm` تماس با ما و می توانید با تست `clang` و `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([الساپین](https://github.com/alesapin)) -- جلوگیری از `std::terminate` چه زمانی `invalidate_query` برای `clickhouse` منبع فرهنگ لغت خارجی نتیجه اشتباه بازگشته است (خالی یا بیش از یک ردیف یا بیش از یک ستون). موضوع ثابت زمانی که `invalidate_query` هر پنج ثانیه انجام شد بدون در نظر گرفتن به `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- جلوگیری از بن بست زمانی که `invalidate_query` برای یک فرهنگ لغت با `clickhouse` منبع شامل شد `system.dictionaries` جدول یا `Dictionaries` پایگاه (مورد نادر). [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع صلیب با خالی جایی که بپیوندید. [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([زویکوف](https://github.com/4ertus2)) -- پیش فرض ثابت در عملکرد “replicate” هنگامی که استدلال ثابت به تصویب می رسد. [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع عملکرد لامبدا با بهینه ساز پیش فرض. [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([زمستان ژانگ](https://github.com/zhang2014)) -- چندگانه می پیوندد رفع متعدد. [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([زویکوف](https://github.com/4ertus2)) - -#### بهبود {#improvements-3} - -- نام مستعار پشتیبانی در عضویت در بخش ستون جدول سمت راست. [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([زویکوف](https://github.com/4ertus2)) -- نتیجه چند پیوستن نیاز به نام نتیجه درست در زیر مجموعه استفاده می شود. جایگزین نام مستعار تخت با نام منبع در نتیجه. [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([زویکوف](https://github.com/4ertus2)) -- بهبود منطق فشار به پایین برای اظهارات پیوست. [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([ایوان](https://github.com/abyss7)) - -#### بهبود عملکرد {#performance-improvements-3} - -- اکتشافی بهبود یافته از “move to PREWHERE” بهینهسازی. [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- استفاده از جداول مراجعه مناسب است که با استفاده از رابط برنامه کاربردی هش را برای کلید 8 بیتی و 16 بیتی. [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([ایموس پرنده](https://github.com/amosbird)) -- بهبود عملکرد مقایسه رشته. [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پاکسازی صف دی ال در یک موضوع جداگانه توزیع به طوری که کم کردن سرعت حلقه اصلی که پردازش توزیع وظایف دسیدال نیست. [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([الکس زتلپین](https://github.com/ztlpn)) -- زمانی که `min_bytes_to_use_direct_io` تنظیم شده است 1, هر فایل با حالت اچ باز شد چرا که اندازه داده ها به خواندن گاهی اوقات به اندازه یک بلوک فشرده دست کم گرفت. [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-12} - -- اضافه شدن پشتیبانی برای صدای جرنگ جرنگ-9 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشتباه `__asm__` دستورالعمل ها (دوباره) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([کنستانتین پودشوموک](https://github.com/podshumok)) -- اضافه کردن قابلیت مشخص کردن تنظیمات برای `clickhouse-performance-test` از خط فرمان. [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([الساپین](https://github.com/alesapin)) -- اضافه کردن لغت نامه تست به تست ادغام. [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([الساپین](https://github.com/alesapin)) -- اضافه شده نمایش داده شد از معیار در وب سایت به تست عملکرد خودکار. [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `xxhash.h` در لنز خارجی 4 وجود ندارد زیرا این یک پیاده سازی دقیق است و نمادهای خود را با فضای نام `XXH_NAMESPACE` ماکرو. زمانی که lz4 خارجی xxHash به خارجی بیش از حد و وابستگان به لینک به آن. [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([اوروج دش](https://github.com/orivej)) -- ثابت مورد زمانی که `quantileTiming` تابع جمع را می توان با استدلال نقطه منفی یا شناور نامیده می شود (این رفع تست ریش شدن با ضد عفونی کننده رفتار تعریف نشده). [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تصحیح خطای املایی. [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) -- رفع تلفیقی در مک. [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([ویتالی بارانو](https://github.com/vitlibar)) -- ساخت رفع برای بورس و تنظیمات مختلف ساخت غیر معمول. [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([پرولر](https://github.com/proller)) - -## انتشار کلیک 19.3 {#clickhouse-release-19-3} - -### انتشار کلیک خانه 19.3.9.1, 2019-04-02 {#clickhouse-release-19-3-9-1-2019-04-02} - -#### رفع اشکال {#bug-fixes-12} - -- رفع سقوط در `FULL/RIGHT JOIN` هنگامی که ما در پیوستن به nullable در مقابل نه nullable. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([زویکوف](https://github.com/4ertus2)) -- رفع گسل تقسیم بندی در `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([پرولر](https://github.com/proller)) -- خواندن ثابت از `Array(LowCardinality)` ستون در مورد نادر زمانی که ستون شامل یک توالی طولانی از مجموعه خالی. [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-13} - -- اضافه کردن یک راه برای راه اندازی تاتر-تصویر سرور از یک کاربر سفارشی [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### انتشار کلیک خانه 19.3.7, 2019-03-12 {#clickhouse-release-19-3-7-2019-03-12} - -#### رفع اشکال {#bug-fixes-13} - -- خطا ثابت در \# 3920. این خطا خود را به عنوان فساد کش تصادفی (پیام) نشان می دهد `Unknown codec family code`, `Cannot seek through file`) و segfaults. این اشکال اول به نظر می رسد در نسخه 19.1 و در حال حاضر در نسخه های تا به 19.1.10 و 19.3.6. [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.3.6, 2019-03-02 {#clickhouse-release-19-3-6-2019-03-02} - -#### رفع اشکال {#bug-fixes-14} - -- هنگامی که بیش از 1000 موضوع در استخر موضوع وجود دارد, `std::terminate` ممکن است در خروج موضوع اتفاق می افتد. [ازات خوژین](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر این امکان وجود دارد برای ایجاد `ReplicatedMergeTree*` جداول با نظرات در ستون بدون پیش فرض و جداول با کدک ستون بدون نظر و پیش فرض. همچنین مقایسه کدک ها را رفع کنید. [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([الساپین](https://github.com/alesapin)) -- تصادف ثابت در پیوستن با مجموعه یا تاپل. [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([زویکوف](https://github.com/4ertus2)) -- تصادف ثابت در تاتر-کپی با پیام `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([زویکوف](https://github.com/4ertus2)) -- قطع ثابت در خاموش کردن سرور اگر دستی توزیع مورد استفاده قرار گرفت. [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([الکس زتلپین](https://github.com/ztlpn)) -- تعداد ستون نادرست در پیام خطا در مورد فرمت متن تجزیه برای ستون با تعداد بیشتر از چاپ شد 10. [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-3} - -- ساخت ثابت با اوکس را فعال کنید. [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حسابداری گسترده و حسابداری یو را بر اساس نسخه شناخته شده خوب به جای هسته ای که وارد شده است فعال کنید. [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([نوارتولومی](https://github.com/nvartolomei)) -- اجازه به جست و خیز تنظیم از رمز و راز.کلیمی, هشدار به جای پرتاب اگر مجموعه ای محدود شکست. [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([پرولر](https://github.com/proller)) -- حذف `inline` برچسب ها از `void readBinary(...)` داخل `Field.cpp`. همچنین با هم ادغام شدند کار برکنار شده `namespace DB` بلاک [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([هکز](https://github.com/hczhcz)) - -### انتشار کلیک خانه 19.3.5, 2019-02-21 {#clickhouse-release-19-3-5-2019-02-21} - -#### رفع اشکال {#bug-fixes-15} - -- اشکال ثابت با پردازش نمایش داده شد قرار دادن قام بزرگ است. [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([الساپین](https://github.com/alesapin)) -- ناسازگاری عقب ثابت با نسخه های قدیمی به دلیل اجرای اشتباه از `send_logs_level` تنظیمات. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ناسازگاری عقب مانده تابع جدول ثابت `remote` معرفی شده با نظرات ستون. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.3.4, 2019-02-16 {#clickhouse-release-19-3-4-2019-02-16} - -#### بهبود {#improvements-4} - -- اندازه شاخص جدول برای محدودیت حافظه در هنگام انجام به حساب نمی `ATTACH TABLE` پرس و جو. اجتناب از احتمال که یک جدول می تواند پس از جدا شدن متصل نمی شود. [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- کمی محدودیت در حداکثر رشته و مجموعه ای اندازه دریافت شده از باغ وحش مطرح شده است. این اجازه می دهد تا برای ادامه کار با افزایش اندازه `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` در باغ وحش. [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه می دهد برای تعمیر ماکت رها حتی اگر در حال حاضر تعداد زیادی از گره ها در صف خود. [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن یک استدلال مورد نیاز برای `SET` شاخص (حداکثر تعداد ردیف های ذخیره شده). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([نیکیتا واسیلیف](https://github.com/nikvas0)) - -#### رفع اشکال {#bug-fixes-16} - -- ثابت `WITH ROLLUP` نتیجه برای گروه های تک `LowCardinality` کلیدی است. [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اشکال ثابت در شاخص مجموعه (حذف گرانول اگر شامل بیش از `max_rows` ردیف). [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- بسیاری از رفع بورس ساخت. [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([پرولر](https://github.com/proller)) -- جایگزینی نام مستعار ثابت در نمایش داده شد با زیرخاکی حاوی همان نام مستعار (موضوع [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([زویکوف](https://github.com/4ertus2)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-4} - -- اضافه کردن قابلیت اجرا `clickhouse-server` برای تست بدون تابعیت در تصویر کارگر بارانداز. [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([واسیلی نمکو](https://github.com/Enmk)) - -### انتشار تاتر 19.3.3, 2019-02-13 {#clickhouse-release-19-3-3-2019-02-13} - -#### ویژگی های جدید {#new-features-6} - -- اضافه شدن `KILL MUTATION` بیانیه ای که اجازه می دهد تا از بین بردن جهش است که برای برخی از دلایل گیر کرده است. اضافه شده `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` زمینه به `system.mutations` جدول برای عیب یابی ساده تر. [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([الکس زتلپین](https://github.com/ztlpn)) -- اضافه شدن تابع جمع `entropy` که شانون انتروپی رو محاسبه میکنه [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([کد37](https://github.com/Quid37)) -- توانایی اضافه شده به ارسال نمایش داده شد `INSERT INTO tbl VALUES (....` به سرور بدون تقسیم در `query` و `data` قطعات. [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([الساپین](https://github.com/alesapin)) -- اجرای عمومی `arrayWithConstant` تابع اضافه شد. [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پیادهسازی شده `NOT BETWEEN` اپراتور مقایسه. [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([دیمیتری نوموف](https://github.com/nezed)) -- پیاده سازی `sumMapFiltered` به منظور قادر به محدود کردن تعداد کلید که ارزش خواهد شد خلاصه `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- اضافه شدن پشتیبانی از `Nullable` انواع در `mysql` تابع جدول. [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) -- پشتیبانی از عبارات ثابت دلخواه در `LIMIT` بند بند. [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([جعبه 3](https://github.com/k3box)) -- اضافه شده `topKWeighted` تابع مجموع طول می کشد که استدلال اضافی با (عدد صحیح بدون علامت) وزن. [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([اندرو گولمن](https://github.com/andrewgolman)) -- `StorageJoin` در حال حاضر پشتیبانی `join_any_take_last_row` تنظیم که اجازه می دهد تا جای نوشتن ارزش های موجود از همان کلید. [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([ایموس پرنده](https://github.com/amosbird) -- اضافه شدن تابع `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([ویتالی بارانو](https://github.com/vitlibar)) -- اضافه شده `RowBinaryWithNamesAndTypes` قالب. [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([اولگ و کوزلوک](https://github.com/DarkWanderer)) -- اضافه شده `IPv4` و `IPv6` انواع داده ها. پیاده سازی موثر تر از `IPv*` توابع. [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([واسیلی نمکو](https://github.com/Enmk)) -- اضافه شدن تابع `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([ویتالی بارانو](https://github.com/vitlibar)) -- اضافه شده `Protobuf` فرمت خروجی. [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([ویتالی بارانو](https://github.com/vitlibar)) -- اضافه شده brotli پشتیبانی از http رابط برای واردات داده ها (درج). [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([میخیل](https://github.com/fandyushin)) -- نکات اضافه شده در حالی که کاربر را تایپی در نام تابع و یا نوع در مشتری خط فرمان. [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([نام و نام خانوادگی](https://github.com/danlark1)) -- اضافه شده `Query-Id` به هدر پاسخ قام سرور. [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([میخیل](https://github.com/fandyushin)) - -#### ویژگی های تجربی {#experimental-features-2} - -- اضافه شده `minmax` و `set` داده پرش شاخص برای ادغام جدول موتورهای خانواده. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- تبدیل اضافه شده از `CROSS JOIN` به `INNER JOIN` در صورت امکان. [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([زویکوف](https://github.com/4ertus2)) - -#### رفع اشکال {#bug-fixes-17} - -- ثابت `Not found column` برای ستون های تکراری در `JOIN ON` بخش. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([زویکوف](https://github.com/4ertus2)) -- ساخت `START REPLICATED SENDS` شروع فرمان تکرار می فرستد. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([نوارتولومی](https://github.com/nvartolomei)) -- ثابت توابع مجموع اعدام با `Array(LowCardinality)` بحث کردن. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- رفتار اشتباه ثابت هنگام انجام `INSERT ... SELECT ... FROM file(...)` پرس و جو و فایل است `CSVWithNames` یا `TSVWIthNames` فرمت و ردیف داده برای اولین بار از دست رفته است. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تصادف ثابت در بازنگری فرهنگ لغت اگر فرهنگ لغت در دسترس نیست. این اشکال در 19.1.6 ظاهر شد. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([پرولر](https://github.com/proller)) -- ثابت `ALL JOIN` با تکراری در جدول سمت راست. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([زویکوف](https://github.com/4ertus2)) -- گسل تقسیم بندی ثابت با `use_uncompressed_cache=1` و استثنا با اندازه غیر فشرده اشتباه است. این اشکال در 19.1.6 ظاهر شد. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([الساپین](https://github.com/alesapin)) -- ثابت `compile_expressions` اشکال با مقایسه بزرگ (بیش از مقدمه16) تاریخ. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([الساپین](https://github.com/alesapin)) -- حلقه بی نهایت ثابت در هنگام انتخاب از تابع جدول `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به طور موقت بهینه سازی پیش فرض برای غیر فعال کردن `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([زمستان ژانگ](https://github.com/zhang2014)) -- ثابت `Illegal instruction` خطا در هنگام استفاده از توابع بازه64 در پردازنده های قدیمی. این خطا تکثیر شده است تنها زمانی که فاحشه خانه با شورای همکاری خلیج فارس وارد شد-8. [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `No message received` خطا در هنگام تعامل با راننده خیال راحت اد بی سی از طریق اتصال. همچنین رفع segfault در هنگام استفاده از MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نتیجه نادرست ثابت زمانی که `Date` و `DateTime` استدلال ها در شاخه های اپراتور شرطی (تابع `if`). مورد عمومی برای عملکرد اضافه شده است `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- لغت نامه کلیک کن در داخل بار `clickhouse` روند. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بن بست ثابت زمانی که `SELECT` از یک جدول با `File` موتور پس از دوباره انجام شد `No such file or directory` خطا. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شرایط مسابقه ثابت در هنگام انتخاب از `system.tables` ممکن است به `table doesn't exist` خطا. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `clickhouse-client` می توانید در هنگام خروج به طور مرتب داده ها را برای پیشنهادات خط فرمان بارگیری کنید اگر در حالت تعاملی اجرا شود. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال زمانی که اجرای جهش های حاوی `IN` اپراتورها نتایج نادرست تولید می کردند. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([الکس زتلپین](https://github.com/ztlpn)) -- خطا ثابت: اگر یک پایگاه داده با وجود `Dictionary` موتور, تمام لغت نامه مجبور به بارگذاری در هنگام راه اندازی سرور, و اگر یک فرهنگ لغت با منبع کلیک از منبع محلی هاست وجود دارد, فرهنگ لغت نمی تواند بار. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطا ثابت زمانی که سیستم سیاهههای مربوط به تلاش برای ایجاد دوباره در خاموش کردن سرور. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به درستی نوع مناسب را باز کنید و قفل ها را به درستی مدیریت کنید `joinGet` تابع. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([ایموس پرنده](https://github.com/amosbird)) -- اضافه شده `sumMapWithOverflow` تابع. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- ثابت segfault با `allow_experimental_multiple_joins_emulation`. [52دسی 2 درجه سانتیگراد](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([زویکوف](https://github.com/4ertus2)) -- اشکال ثابت با نادرست `Date` و `DateTime` مقایسه. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([حداکثر](https://github.com/valexey)) -- تست ریش ریش شدن ثابت تحت تعریف نشده رفتار ضد عفونی کننده: اضافه شدن نوع پارامتر را بررسی کنید `quantile*Weighted` خانواده از توابع. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شرایط مسابقه نادر ثابت در هنگام از بین بردن قطعات داده های قدیمی می تواند با شکست مواجه `File not found` خطا. [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت نصب بسته با گم شده /و غیره/خانه کلیک-سرور / پیکربندی.. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([پرولر](https://github.com/proller)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-5} - -- دبیان بسته بندی: درست /و غیره/کلیک-سرور/لینک پیش پردازش با توجه به پیکربندی. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([پرولر](https://github.com/proller)) -- رفع ساخت های مختلف برای بورس. [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([پرولر](https://github.com/proller)) -- توانایی اضافه شده به ایجاد, پر کردن و رها کردن جداول در اصلح. [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([الساپین](https://github.com/alesapin)) -- اضافه شده یک اسکریپت برای تکراری بررسی شامل. [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- توانایی اضافه شده به اجرا نمایش داده شد توسط شاخص در تست عملکرد. [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([الساپین](https://github.com/alesapin)) -- بسته بندی با علامت اشکال زدایی پیشنهاد می شود نصب شود. [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بازسازی عملکرد-تست. ورود به سیستم بهتر و سیگنال های دست زدن به. [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([الساپین](https://github.com/alesapin)) -- اسناد اضافه شده به ناشناس یاندکس.مجموعه داده های متریکا. [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([الساپین](https://github.com/alesapin)) -- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([الکس زتلپین](https://github.com/ztlpn)) -- اسناد اضافه شده در مورد دو مجموعه داده در اس3. [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([الساپین](https://github.com/alesapin)) -- اضافه شده اسکریپت که ایجاد تغییرات از کشش درخواست توضیحات. [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([کوچتونیکولای](https://github.com/KochetovNicolai)) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- اضافه شده ماژول عروسک خیمه شب بازی برای فاحشه خانه. [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([ماکسیم فدوتف](https://github.com/MaxFedotov)) -- اسناد اضافه شده برای یک گروه از توابع مستند نشده. [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([زمستان ژانگ](https://github.com/zhang2014)) -- بازوی رفع ساخت. [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([پرولر](https://github.com/proller)) ([پرولر](https://github.com/proller)) -- تست فرهنگ لغت در حال حاضر قادر به اجرا از `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([پرولر](https://github.com/proller)) -- حالا `/etc/ssl` به عنوان دایرکتوری پیش فرض با گواهی اس اس ال استفاده می شود. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده چک کردن اس اس اس و توضیحات در شروع. [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([ایگر](https://github.com/igron99)) -- اسکریپت اینیت سرور صبر کنید تا شروع. [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([پرولر](https://github.com/proller)) - -#### تغییرات ناسازگار به عقب {#backward-incompatible-changes-1} - -- حذف شد `allow_experimental_low_cardinality_type` تنظیمات. `LowCardinality` انواع داده ها تولید می شوند. [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- کاهش اندازه علامت کش و اندازه کش غیر فشرده بر این اساس به مقدار حافظه در دسترس است. [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([لوپاتین کنستانتین](https://github.com/k-lopatin) -- کلمه کلیدی اضافه شده است `INDEX` داخل `CREATE TABLE` پرس و جو. یک ستون با نام `index` باید با پشتی یا نقل قول های دوگانه نقل قول شود: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- `sumMap` در حال حاضر نوع نتیجه به جای سرریز ترویج. قدیمی `sumMap` رفتار را می توان با استفاده از `sumMapWithOverflow` تابع. [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) - -#### بهبود عملکرد {#performance-improvements-4} - -- `std::sort` جایگزین شده توسط `pdqsort` برای نمایش داده شد بدون `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([اوگنی پراودا](https://github.com/kvinty)) -- در حال حاضر سرور موضوعات استفاده مجدد از استخر موضوع جهانی است. این عملکرد در برخی موارد گوشه تاثیر می گذارد. [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود {#improvements-5} - -- پیاده سازی پشتیبانی برای بورس. [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([هشدار داده می شود](https://github.com/urgordeadbeef)) -- `SELECT * FROM a JOIN b USING a, b` حالا برگرد `a` و `b` ستون تنها از جدول سمت چپ. [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([زویکوف](https://github.com/4ertus2)) -- اجازه داده شود `-C` گزینه مشتری برای کار به عنوان `-c` انتخاب [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([سیمینسرگی](https://github.com/syominsergey)) -- در حال حاضر گزینه `--password` استفاده بدون ارزش نیاز به رمز عبور از استدین. [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([حداقل صفحه نمایش:](https://github.com/bsd-conqueror)) -- افزود برجسته از unescaped metacharacters در string literals که حاوی `LIKE` عبارات و یا عبارت منظم. [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده لغو قام به عنوان خوانده شده تنها نمایش داده شد اگر سوکت مشتری از بین می رود. [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([نوارتولومی](https://github.com/nvartolomei)) -- در حال حاضر گزارش سرور پیشرفت برای زنده نگه داشتن اتصالات مشتری. [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([ایوان](https://github.com/abyss7)) -- پیام کمی بهتر با دلیل برای بهینه سازی پرس و جو با `optimize_throw_if_noop` تنظیم را فعال کنید. [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن پشتیبانی از `--version` گزینه ای برای سرور کلیک. [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([لوپاتین کنستانتین](https://github.com/k-lopatin)) -- اضافه شده `--help/-h` گزینه ای برای `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([یوری baranov](https://github.com/yurriy)) -- اضافه شدن پشتیبانی برای زیرمجموعه اسکالر با تابع کل نتیجه دولت است. [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- بهبود زمان خاموش کردن سرور و تغییر زمان انتظار. [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن اطلاعات در مورد تنظیمات \_شروع مجدد به سیستم.کپی و اضافه کردن ورود به سیستم اگر ماکت نمی خواهد سعی کنید برای تبدیل شدن به رهبر. [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([الکس زتلپین](https://github.com/ztlpn)) - -## انتشار کلیک 19.1 {#clickhouse-release-19-1} - -### انتشار کلیک خانه 19.1.14, 2019-03-14 {#clickhouse-release-19-1-14-2019-03-14} - -- خطای ثابت `Column ... queried more than once` که ممکن است اتفاق می افتد اگر تنظیمات `asterisk_left_columns_only` در صورت استفاده به 1 تنظیم می شود `GLOBAL JOIN` با `SELECT *` (مورد نادر). این موضوع در وجود ندارد 19.3 و جدیدتر. [6باک7د8د](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([زویکوف](https://github.com/4ertus2)) - -### انتشار کلیک خانه 19.1.13, 2019-03-12 {#clickhouse-release-19-1-13-2019-03-12} - -این نسخه شامل دقیقا همان مجموعه ای از تکه های به عنوان 19.3.7. - -### انتشار کلیک خانه 19.1.10, 2019-03-03 {#clickhouse-release-19-1-10-2019-03-03} - -این نسخه شامل دقیقا همان مجموعه ای از تکه های به عنوان 19.3.6. - -## انتشار کلیک 19.1 {#clickhouse-release-19-1-1} - -### انتشار کلیک خانه 19.1.9, 2019-02-21 {#clickhouse-release-19-1-9-2019-02-21} - -#### رفع اشکال {#bug-fixes-18} - -- ناسازگاری عقب ثابت با نسخه های قدیمی به دلیل اجرای اشتباه از `send_logs_level` تنظیمات. [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ناسازگاری عقب مانده تابع جدول ثابت `remote` معرفی شده با نظرات ستون. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.1.8, 2019-02-16 {#clickhouse-release-19-1-8-2019-02-16} - -#### رفع اشکال {#bug-fixes-19} - -- ثابت نصب بسته با گم شده /و غیره/خانه کلیک-سرور / پیکربندی.. [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([پرولر](https://github.com/proller)) - -## انتشار کلیک 19.1 {#clickhouse-release-19-1-2} - -### انتشار کلیک خانه 19.1.7, 2019-02-15 {#clickhouse-release-19-1-7-2019-02-15} - -#### رفع اشکال {#bug-fixes-20} - -- به درستی نوع مناسب را باز کنید و قفل ها را به درستی مدیریت کنید `joinGet` تابع. [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([ایموس پرنده](https://github.com/amosbird)) -- خطا ثابت زمانی که سیستم سیاهههای مربوط به تلاش برای ایجاد دوباره در خاموش کردن سرور. [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطا ثابت: اگر یک پایگاه داده با وجود `Dictionary` موتور, تمام لغت نامه مجبور به بارگذاری در هنگام راه اندازی سرور, و اگر یک فرهنگ لغت با منبع کلیک از منبع محلی هاست وجود دارد, فرهنگ لغت نمی تواند بار. [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال زمانی که اجرای جهش های حاوی `IN` اپراتورها نتایج نادرست تولید می کردند. [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([الکس زتلپین](https://github.com/ztlpn)) -- `clickhouse-client` می توانید در هنگام خروج به طور مرتب داده ها را برای پیشنهادات خط فرمان بارگیری کنید اگر در حالت تعاملی اجرا شود. [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شرایط مسابقه ثابت در هنگام انتخاب از `system.tables` ممکن است به `table doesn't exist` خطا. [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بن بست ثابت زمانی که `SELECT` از یک جدول با `File` موتور پس از دوباره انجام شد `No such file or directory` خطا. [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت موضوع: لغت نامه خانه کلیک محلی از طریق تی سی پی لود, اما باید در روند بارگذاری. [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `No message received` خطا در هنگام تعامل با راننده خیال راحت اد بی سی از طریق اتصال. همچنین رفع segfault در هنگام استفاده از MySQL ODBC Driver. [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به طور موقت بهینه سازی پیش فرض برای غیر فعال کردن `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([زمستان ژانگ](https://github.com/zhang2014)) -- حلقه بی نهایت ثابت در هنگام انتخاب از تابع جدول `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `compile_expressions` اشکال با مقایسه بزرگ (بیش از مقدمه16) تاریخ. [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([الساپین](https://github.com/alesapin)) -- گسل تقسیم بندی ثابت با `uncompressed_cache=1` و استثنا با اندازه غیر فشرده اشتباه است. [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([الساپین](https://github.com/alesapin)) -- ثابت `ALL JOIN` با تکراری در جدول سمت راست. [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([زویکوف](https://github.com/4ertus2)) -- رفتار اشتباه ثابت هنگام انجام `INSERT ... SELECT ... FROM file(...)` پرس و جو و فایل است `CSVWithNames` یا `TSVWIthNames` فرمت و ردیف داده برای اولین بار از دست رفته است. [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت توابع مجموع اعدام با `Array(LowCardinality)` بحث کردن. [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- دبیان بسته بندی: درست /و غیره/کلیک-سرور/لینک پیش پردازش با توجه به پیکربندی. [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([پرولر](https://github.com/proller)) -- تست ریش ریش شدن ثابت تحت تعریف نشده رفتار ضد عفونی کننده: اضافه شدن نوع پارامتر را بررسی کنید `quantile*Weighted` خانواده از توابع. [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ساخت `START REPLICATED SENDS` شروع فرمان تکرار می فرستد. [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([نوارتولومی](https://github.com/nvartolomei)) -- ثابت `Not found column` برای ستون های تکراری در عضویت در بخش. [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([زویکوف](https://github.com/4ertus2)) -- حالا `/etc/ssl` به عنوان دایرکتوری پیش فرض با گواهی اس اس ال استفاده می شود. [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تصادف ثابت در بازنگری فرهنگ لغت اگر فرهنگ لغت در دسترس نیست. [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([پرولر](https://github.com/proller)) -- اشکال ثابت با نادرست `Date` و `DateTime` مقایسه. [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([حداکثر](https://github.com/valexey)) -- نتیجه نادرست ثابت زمانی که `Date` و `DateTime` استدلال ها در شاخه های اپراتور شرطی (تابع `if`). مورد عمومی برای عملکرد اضافه شده است `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -### انتشار کلیک خانه 19.1.6, 2019-01-24 {#clickhouse-release-19-1-6-2019-01-24} - -#### ویژگی های جدید {#new-features-7} - -- سفارشی در هر کدک های فشرده سازی ستون برای جداول. [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([الساپین](https://github.com/alesapin), [زمستان ژانگ](https://github.com/zhang2014), [انتولی](https://github.com/Sindbag)) -- اضافه شده کدک فشرده سازی `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([الساپین](https://github.com/alesapin)) -- اجازه دادن به `ALTER` کدک های فشرده سازی. [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([الساپین](https://github.com/alesapin)) -- اضافه شدن توابع `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` برای سازگاری استاندارد گذاشتن. [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([ایوان بلینکو](https://github.com/blinkov)) -- پشتیبانی از نوشتن در `HDFS` جداول و `hdfs` تابع جدول. [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([الساپین](https://github.com/alesapin)) -- اضافه شدن توابع به جستجو برای رشته ثابت متعدد از انبار کاه بزرگ: `multiPosition`, `multiSearch` ,`firstMatch` همچنین با `-UTF8`, `-CaseInsensitive` و `-CaseInsensitiveUTF8` انواع. [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([نام و نام خانوادگی](https://github.com/danlark1)) -- هرس کردن تکه های استفاده نشده اگر `SELECT` فیلترهای پرس و جو با کلید شاردینگ (تنظیم `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([گلب کنتروف](https://github.com/kanterov), [ایوان](https://github.com/abyss7)) -- اجازه داده شود `Kafka` موتور به چشم پوشی از برخی از تعدادی از خطاهای تجزیه در هر بلوک. [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([ایوان](https://github.com/abyss7)) -- اضافه شدن پشتیبانی برای `CatBoost` multiclass مدل های ارزیابی. تابع `modelEvaluate` را برمی گرداند تاپل با پیش بینی های خام در هر کلاس برای مدل های چند طبقه. `libcatboostmodel.so` باید با ساخته شده است [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- اضافه شدن توابع `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([بوریس گرانویو](https://github.com/bgranvea)) -- اضافه شده توابع هش کردن `xxHash64` و `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([فیلیمونف](https://github.com/filimonov)) -- اضافه شده `gccMurmurHash` تابع هش (شورای همکاری خلیج فارس طعم زمزمه هش) که با استفاده از همان دانه هش به عنوان [شورای همکاری خلیج فارس](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- اضافه شده توابع هش کردن `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([شانگشویی365](https://github.com/shangshujie365)) -- تابع جدول اضافه شده است `remoteSecure`. تابع به عنوان کار می کند `remote`, اما با استفاده از اتصال امن. [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([پرولر](https://github.com/proller)) - -#### ویژگی های تجربی {#experimental-features-3} - -- اضافه شده چند تقلید می پیوندد (`allow_experimental_multiple_joins_emulation` تنظیمات). [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([زویکوف](https://github.com/4ertus2)) - -#### رفع اشکال {#bug-fixes-21} - -- ساخت `compiled_expression_cache_size` تنظیم به طور پیش فرض برای کاهش مصرف حافظه محدود شده است. [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([الساپین](https://github.com/alesapin)) -- رفع اشکال که منجر به hangups در تاپیک های که انجام تغییر از تکرار جداول و در این موضوع است که به روز رسانی پیکربندی از باغ وحش. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([الکس زتلپین](https://github.com/ztlpn)) -- ثابت شرایط مسابقه در هنگام اجرای یک کار تغییر توزیع شده است. شرایط مسابقه منجر به بیش از یک ماکت در تلاش برای اجرای کار و همه کپی به جز یک شکست با یک خطای باغ وحش. [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([الکس زتلپین](https://github.com/ztlpn)) -- رفع اشکال زمانی که `from_zk` عناصر پیکربندی شد پس از یک درخواست به باغ وحش به پایان رسیده است تجدید نیست. [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([الکس زتلپین](https://github.com/ztlpn)) -- رفع اشکال با پیشوند اشتباه برای ماسک زیر شبکه ایپسویچ. [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([الساپین](https://github.com/alesapin)) -- تصادف ثابت (`std::terminate`) در موارد نادر زمانی که یک موضوع جدید نمی تواند به دلیل منابع خسته ایجاد شود. [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال زمانی که در `remote` اجرای تابع جدول زمانی که محدودیت اشتباه برای در مورد استفاده قرار گرفت `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([الساپین](https://github.com/alesapin)) -- رفع نشت از سوکت نتلینک. در یک استخر قرار گرفتند که هرگز حذف نشدند و سوکت های جدید در ابتدای یک موضوع جدید ایجاد شد زمانی که همه سوکت های فعلی استفاده می شد. [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([الکس زتلپین](https://github.com/ztlpn)) -- رفع اشکال با بسته شدن `/proc/self/fd` دایرکتوری زودتر از همه پزشکان از خوانده شد `/proc` پس از مجبور `odbc-bridge` مانع عبور. [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([الساپین](https://github.com/alesapin)) -- رشته ثابت به تبدیل یکنواخت کهنه در مورد رشته استفاده در کلید اولیه. [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([زمستان ژانگ](https://github.com/zhang2014)) -- خطا ثابت در محاسبه یکنواختی تابع تبدیل عدد صحیح. [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت segfault در `arrayEnumerateUniq`, `arrayEnumerateDense` توابع در مورد برخی از استدلال نامعتبر. [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال بارگذاری [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([ایموس پرنده](https://github.com/amosbird)) -- پیش فرض ثابت در توابع `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطای ثابت: توابع `round`, `floor`, `trunc`, `ceil` ممکن است نتیجه جعلی بازگشت زمانی که در استدلال صحیح و مقیاس بزرگ منفی اجرا. [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال ناشی از ‘kill query sync’ که منجر به روگرفت هسته. [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([شناسه بسته:](https://github.com/fancyqlx)) -- رفع اشکال با تاخیر طولانی پس از صف تکرار خالی است. [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([الساپین](https://github.com/alesapin)) -- استفاده از حافظه بیش از حد ثابت در صورت قرار دادن به جدول با `LowCardinality` کلید اصلی. [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- ثابت `LowCardinality` ترتیب برای `Native` فرمت در مورد مجموعه های خالی. [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- نتیجه نادرست ثابت در حالی که با استفاده از مجزا توسط ستون عددی کم حافظه. [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- تجمع تخصصی ثابت با کلید کمکاری (در صورتی که `compile` تنظیم فعال است). [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- رفع کاربر و رمز عبور حمل و نقل برای جداول تکرار نمایش داده شد. [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([الساپین](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) -- ثابت شرایط مسابقه بسیار نادر است که می تواند رخ دهد که لیست جداول در پایگاه داده فرهنگ لغت در حالی که بارگذاری لغت نامه. [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نتیجه نادرست ثابت زمانی که با رولپ یا مکعب مورد استفاده قرار گرفت. [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([سام چو](https://github.com/reflection)) -- نام مستعار ستون ثابت برای پرس و جو با `JOIN ON` نحو و جداول توزیع. [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([زمستان ژانگ](https://github.com/zhang2014)) -- خطای ثابت در اجرای داخلی `quantileTDigest` (که توسط آرتم Vakhrushev). این خطا اتفاق هرگز در ClickHouse و مناسب بود تنها برای کسانی که استفاده از ClickHouse کدهای به عنوان یک کتابخانه به طور مستقیم. [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود {#improvements-6} - -- پشتیبانی از `IF NOT EXISTS` داخل `ALTER TABLE ADD COLUMN` بیانیه همراه با `IF EXISTS` داخل `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([بوریس گرانویو](https://github.com/bgranvea)) -- تابع `parseDateTimeBestEffort`: پشتیبانی از فرمت های `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` و مشابه. [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- `CapnProtoInputStream` در حال حاضر سازه های ناهموار ممکن میکند پشتیبانی می کند. [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) -- بهبود قابلیت استفاده: اضافه شدن چک که روند سرور از صاحب دایرکتوری داده ها شروع شده است. اجازه ندهید سرور را از ریشه شروع کنید اگر داده ها متعلق به کاربر غیر ریشه باشد. [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([سرگی-وی-گالتسف](https://github.com/sergey-v-galtsev)) -- منطق بهتر از چک کردن ستون های مورد نیاز در طول تجزیه و تحلیل نمایش داده شد با می پیوندد. [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([زویکوف](https://github.com/4ertus2)) -- تعداد اتصالات در صورت تعداد زیادی از جداول توزیع شده در یک سرور کاهش یافته است. [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([زمستان ژانگ](https://github.com/zhang2014)) -- بالغ پشتیبانی ردیف برای `WITH TOTALS` پرس و جو برای راننده او بی سی. [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([مکسیم کریتکی](https://github.com/nightweb)) -- مجاز به استفاده `Enum`به عنوان اعداد صحیح در داخل اگر تابع. [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([ایوان](https://github.com/abyss7)) -- اضافه شده `low_cardinality_allow_in_native_format` تنظیمات. اگر غیر فعال, استفاده نکنید `LowCadrinality` نوع در `Native` قالب. [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([کوچتونیکولای](https://github.com/KochetovNicolai)) -- حذف برخی از اجسام کار برکنار شده از عبارات وارد کش به کاهش استفاده از حافظه است. [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([الساپین](https://github.com/alesapin)) -- اضافه کردن چک که `SET send_logs_level = 'value'` پرس و جو قبول ارزش مناسب. [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([سابین ماکسیم](https://github.com/s-mx)) -- بررسی نوع داده ثابت در توابع تبدیل نوع. [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([زمستان ژانگ](https://github.com/zhang2014)) - -#### بهبود عملکرد {#performance-improvements-5} - -- افزودن تنظیمات ادغام `use_minimalistic_part_header_in_zookeeper`. اگر فعال, جداول تکرار خواهد ابرداده بخش جمع و جور در یک قسمت صفر ذخیره. این به طور چشمگیری می تواند به کاهش اندازه عکس فوری باغ وحش (به خصوص اگر جداول یک مقدار زیادی از ستون). توجه داشته باشید که پس از فعال کردن این تنظیمات شما قادر نخواهد بود به جمع و جور کردن به نسخه ای که پشتیبانی نمی کند. [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([الکس زتلپین](https://github.com/ztlpn)) -- اضافه کردن یک پیاده سازی مبتنی بر وزارت امور خارجه برای توابع `sequenceMatch` و `sequenceCount` در مورد الگوی حاوی زمان نیست. [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- بهبود عملکرد برای اعداد صحیح ترتیب. [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([ایموس پرنده](https://github.com/amosbird)) -- صفر پدرارهای چپ به طوری که -1 عنصر همیشه معتبر و صفر است. این برای محاسبه بدون شاخه از شیپور خاموشی استفاده می شود. [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([ایموس پرنده](https://github.com/amosbird)) -- واگردانی `jemalloc` نسخه که منجر به تخریب عملکرد. [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### تغییرات ناسازگار به عقب {#backward-incompatible-changes-2} - -- حذف ویژگی مستند نشده است `ALTER MODIFY PRIMARY KEY` چرا که توسط جایگزین شد `ALTER MODIFY ORDER BY` فرمان. [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([الکس زتلپین](https://github.com/ztlpn)) -- تابع حذف شده `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- منع استفاده از زیرکورهای اسکالر با نتیجه نوع `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([ایوان](https://github.com/abyss7)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvements-6} - -- اضافه شدن پشتیبانی برای پاور (`ppc64le`) ساختن . [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([نام و نام خانوادگی](https://github.com/danlark1)) -- تست های عملکردی نفرت انگیز بر روی مجموعه داده های عمومی در دسترس اجرا. [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطا ثابت زمانی که سرور نمی تواند با شروع `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` پیام در داکر یا سیستم-خوانده. [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز شده `rdkafka` کتابخانه به 1. 0. 0-ارک5. کپکافکا مورد استفاده به جای رابط ج خام. [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([ایوان](https://github.com/abyss7)) -- به روز شده `mariadb-client` کتابخونه. ثابت یکی از مشکلات پیدا شده توسط اوبسان. [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- برخی از رفع برای اوبسان ایجاد. [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده در هر مرتکب اجرا می شود از تست با ساخت اوبان. -- اضافه شده در هر مرتکب اجرا می شود از پوس استودیو تجزیه و تحلیل استاتیک می باشد. -- اشکالات ثابت پیدا شده توسط پوس استودیو. [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت glibc مسائل مربوط به سازگاری. [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- انتقال تصاویر کارگر بارانداز به 18.10 و اضافه کردن فایل سازگاری برای چرب \> = 2.28 [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([الساپین](https://github.com/alesapin)) -- اضافه کردن متغیر پاکت اگر کاربر نمی خواهید به دایرکتوری پی ان در سرور تصویر کارگر بارانداز. [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([الساپین](https://github.com/alesapin)) -- فعال بسیاری از هشدارهای از `-Weverything` تو کلانگ فعال شد `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده چند هشدار که تنها در صدای جرنگ جرنگ در دسترس هستند 8. [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پیوند به `libLLVM` در هنگام استفاده از پیوند مشترک به جای استفاده از لوب های فردی لورم. [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([اوروج دش](https://github.com/orivej)) -- اضافه شده متغیرهای ضد عفونی کننده برای تصاویر تست. [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([الساپین](https://github.com/alesapin)) -- `clickhouse-server` بسته دبیان توصیه خواهد شد `libcap2-bin` بسته برای استفاده `setcap` ابزار برای تنظیم قابلیت های. این اختیاری است. [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- زمان تدوین بهبود, ثابت شامل. [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([پرولر](https://github.com/proller)) -- تست عملکرد اضافه شده برای توابع هش. [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([فیلیمونف](https://github.com/filimonov)) -- وابستگی کتابخانه چرخهای ثابت. [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([پرولر](https://github.com/proller)) -- تلفیقی بهبود یافته با حافظه کم در دسترس است. [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([پرولر](https://github.com/proller)) -- اضافه شدن اسکریپت تست به تکثیر تخریب عملکرد در `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت misspells در نظرات و string literals تحت `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([مامان](https://github.com/maiha)) -- غلط املایی ثابت در نظرات. [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([اوگنی پراودا](https://github.com/kvinty)) - -## [تغییرات برای 2018](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2018.md) {#changelog-for-2018} diff --git a/docs/fa/whats_new/changelog/index.md b/docs/fa/whats_new/changelog/index.md deleted file mode 100644 index 8dcc20e9409..00000000000 --- a/docs/fa/whats_new/changelog/index.md +++ /dev/null @@ -1,668 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Changelog -toc_priority: 74 -toc_title: '2020' ---- - -## انتشار کلیک و 20.3 {#clickhouse-release-v20-3} - -### ClickHouse انتشار v20.3.4.10, 2020-03-20 {#clickhouse-release-v20-3-4-10-2020-03-20} - -#### رفع اشکال {#bug-fix} - -- این نسخه همچنین شامل تمام رفع اشکال از 20.1.8.41 -- رفع از دست رفته `rows_before_limit_at_least` برای نمایش داده شد بیش از قام (با پردازنده خط لوله). این رفع [\#9730](https://github.com/ClickHouse/ClickHouse/issues/9730). [\#9757](https://github.com/ClickHouse/ClickHouse/pull/9757) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -### انتشار کلیک و 20.3.3.6, 2020-03-17 {#clickhouse-release-v20-3-3-6-2020-03-17} - -#### رفع اشکال {#bug-fix-1} - -- این نسخه همچنین شامل تمام رفع اشکال از 20.1.7.38 -- رفع اشکال در تکرار می کند که تکرار اجازه نمی دهد به کار اگر کاربر جهش در نسخه های قبلی اجرا کرده است. این رفع [\#9645](https://github.com/ClickHouse/ClickHouse/issues/9645). [\#9652](https://github.com/ClickHouse/ClickHouse/pull/9652) ([الساپین](https://github.com/alesapin)). این باعث می شود نسخه 20.3 به عقب سازگار دوباره. -- افزودن تنظیمات `use_compact_format_in_distributed_parts_names` که اجازه می دهد برای نوشتن فایل برای `INSERT` نمایش داده شد به `Distributed` جدول با فرمت جمع و جور تر. این رفع [\#9647](https://github.com/ClickHouse/ClickHouse/issues/9647). [\#9653](https://github.com/ClickHouse/ClickHouse/pull/9653) ([الساپین](https://github.com/alesapin)). این باعث می شود نسخه 20.3 به عقب سازگار دوباره. - -### انتشار کلیک و 20.3.2.1, 2020-03-12 {#clickhouse-release-v20-3-2-1-2020-03-12} - -#### تغییر ناسازگار به عقب {#backward-incompatible-change} - -- ثابت موضوع `file name too long` هنگام ارسال داده ها برای `Distributed` جداول برای تعداد زیادی از کپی. ثابت این موضوع که اعتبار ماکت در ورود به سیستم سرور قرار گرفتند. فرمت نام دایرکتوری بر روی دیسک به تغییر یافت `[shard{shard_index}[_replica{replica_index}]]`. [\#8911](https://github.com/ClickHouse/ClickHouse/pull/8911) ([میخیل کوروتف](https://github.com/millb)) پس از شما به نسخه جدید ارتقا دهید, شما نمی قادر خواهد بود به جمع و جور کردن بدون دخالت دستی, به دلیل نسخه سرور قدیمی می کند فرمت دایرکتوری جدید به رسمیت نمی شناسد. اگر شما می خواهید به جمع و جور کردن, شما باید به صورت دستی تغییر نام دایرکتوری مربوطه را به فرمت های قدیمی. این تغییر مربوط است تنها اگر شما ناهمزمان استفاده کرده اند `INSERT`اس به `Distributed` میز در نسخه 20.3.3 ما یک محیط است که به شما اجازه فعال کردن فرمت جدید به تدریج معرفی. -- فرمت ورودی ورود به سیستم تکرار برای دستورات جهش تغییر کرده است. شما باید صبر کنید برای جهش های قدیمی برای پردازش قبل از نصب نسخه جدید. -- پیاده سازی پیشفیلتر حافظه ساده است که افسردگی زخم به `system.trace_log` هر بایت بر سر حد تخصیص نرم [\#8765](https://github.com/ClickHouse/ClickHouse/pull/8765) ([ایوان](https://github.com/abyss7)) [\#9472](https://github.com/ClickHouse/ClickHouse/pull/9472) ([الکسی میلویدو](https://github.com/alexey-milovidov)) ستون `system.trace_log` از تغییر نام داد `timer_type` به `trace_type`. این تغییرات در تجزیه و تحلیل عملکرد شخص ثالث و ابزارهای پردازش فلامگراف نیاز دارد. -- استفاده از شناسه موضوع سیستم عامل در همه جا به جای شماره موضوع داخلی. این رفع [\#7477](https://github.com/ClickHouse/ClickHouse/issues/7477) قدیمی `clickhouse-client` می توانید سیاهههای مربوط که از سرور ارسال زمانی که تنظیم دریافت نمی `send_logs_level` فعال است, چرا که نام و نوع پیام ورود به سیستم ساختار تغییر یافت. از سوی دیگر نسخه های سرور مختلف سیاهههای مربوط با انواع مختلف به یکدیگر ارسال کنید. هنگامی که شما از `send_logs_level` محیط, شما باید مهم نیست. [\#8954](https://github.com/ClickHouse/ClickHouse/pull/8954) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف `indexHint` تابع [\#9542](https://github.com/ClickHouse/ClickHouse/pull/9542) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف `findClusterIndex`, `findClusterValue` توابع. این رفع [\#8641](https://github.com/ClickHouse/ClickHouse/issues/8641). اگر شما با استفاده از این توابع, ارسال یک ایمیل به `clickhouse-feedback@yandex-team.com` [\#9543](https://github.com/ClickHouse/ClickHouse/pull/9543) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر مجاز به ایجاد ستون و یا اضافه کردن ستون با `SELECT` زیرخاکری به عنوان عبارت پیش فرض. [\#9481](https://github.com/ClickHouse/ClickHouse/pull/9481) ([الساپین](https://github.com/alesapin)) -- نیاز نام مستعار برای کارخانه های فرعی در عضویت. [\#9274](https://github.com/ClickHouse/ClickHouse/pull/9274) ([زویکوف](https://github.com/4ertus2)) -- بهبود `ALTER MODIFY/ADD` نمایش داده شد منطق. حالا شما نمی توانید `ADD` ستون بدون نوع, `MODIFY` عبارت پیش فرض نوع ستون را تغییر نمی دهد و `MODIFY` نوع ارزش بیان پیش فرض را از دست نمی دهد. رفع [\#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). [\#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) ([الساپین](https://github.com/alesapin)) -- نیاز به سرور برای راه اندازی مجدد برای اعمال تغییرات در پیکربندی ورود به سیستم. این یک راه حل موقت برای جلوگیری از اشکال که سرور سیاهههای مربوط به یک فایل ورود به سیستم حذف شده است (دیدن [\#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [\#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- تنظیمات `experimental_use_processors` به طور پیش فرض فعال است. این تنظیم را قادر می سازد استفاده از خط لوله پرس و جو جدید. این فاکتورگیری مجدد داخلی است و ما انتظار داریم هیچ تغییری قابل مشاهده. اگر مشکلی خواهید دید صفر را تنظیم کنید. [\#8768](https://github.com/ClickHouse/ClickHouse/pull/8768) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ویژگی جدید {#new-feature} - -- افزودن `Avro` و `AvroConfluent` فرمت های ورودی/خروجی [\#8571](https://github.com/ClickHouse/ClickHouse/pull/8571) ([اندرو انیشچوک](https://github.com/oandrew)) [\#8957](https://github.com/ClickHouse/ClickHouse/pull/8957) ([اندرو انیشچوک](https://github.com/oandrew)) [\#8717](https://github.com/ClickHouse/ClickHouse/pull/8717) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز رسانی چند رشته ای و غیر مسدود کردن کلید منقضی شده در `cache` واژهنامهها (با اجازه اختیاری به خواندن قدیمی). [\#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- افزودن پرسوجو `ALTER ... MATERIALIZE TTL`. این اجرا می شود جهش است که نیروهای به حذف داده های منقضی شده توسط کنترل از راه دور و دوباره حساب متا اطلاعات در مورد کنترل از راه دور در تمام نقاط. [\#8775](https://github.com/ClickHouse/ClickHouse/pull/8775) ([انتون پوپوف](https://github.com/CurtizJ)) -- سوئیچ از hashjoin به mergejoin (بر روی دیسک) در صورت نیاز [\#9082](https://github.com/ClickHouse/ClickHouse/pull/9082) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده `MOVE PARTITION` فرمان برای `ALTER TABLE` [\#4729](https://github.com/ClickHouse/ClickHouse/issues/4729) [\#6168](https://github.com/ClickHouse/ClickHouse/pull/6168) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- بارگذاری مجدد پیکربندی ذخیره سازی از فایل پیکربندی در پرواز. [\#8594](https://github.com/ClickHouse/ClickHouse/pull/8594) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- مجاز به تغییر `storage_policy` به یکی کمتر غنی. [\#8107](https://github.com/ClickHouse/ClickHouse/pull/8107) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اضافه شدن پشتیبانی برای کره / نویسه عام برای ذخیره سازی اس3 و عملکرد جدول. [\#8851](https://github.com/ClickHouse/ClickHouse/pull/8851) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- پیاده سازی `bitAnd`, `bitOr`, `bitXor`, `bitNot` برای `FixedString(N)` نوع داده. [\#9091](https://github.com/ClickHouse/ClickHouse/pull/9091) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- اضافه شدن تابع `bitCount`. این رفع [\#8702](https://github.com/ClickHouse/ClickHouse/issues/8702). [\#8708](https://github.com/ClickHouse/ClickHouse/pull/8708) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#8749](https://github.com/ClickHouse/ClickHouse/pull/8749) ([درباره ما](https://github.com/ikopylov)) -- افزودن `generateRandom` تابع جدول برای تولید ردیف تصادفی با طرح داده شده است. اجازه می دهد تا به جمعیت جدول تست دلخواه با داده ها. [\#8994](https://github.com/ClickHouse/ClickHouse/pull/8994) ([ایلیا یاتسیشین](https://github.com/qoega)) -- `JSONEachRowFormat`: پشتیبانی از موارد خاص زمانی که اشیا محصور شده در مجموعه سطح بالا. [\#8860](https://github.com/ClickHouse/ClickHouse/pull/8860) ([کروگلو پاول](https://github.com/Avogar)) -- در حال حاضر امکان ایجاد یک ستون با `DEFAULT` عبارت که به یک ستون با پیش فرض بستگی دارد `ALIAS` اصطلاح. [\#9489](https://github.com/ClickHouse/ClickHouse/pull/9489) ([الساپین](https://github.com/alesapin)) -- اجازه مشخص کردن `--limit` بیش از اندازه منبع داده در `clickhouse-obfuscator`. داده ها خود را با دانه های مختلف تصادفی تکرار. [\#9155](https://github.com/ClickHouse/ClickHouse/pull/9155) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده `groupArraySample` تابع (شبیه به `groupArray`) با الگوریتم نمونه برداری ذخیره. [\#8286](https://github.com/ClickHouse/ClickHouse/pull/8286) ([ایموس پرنده](https://github.com/amosbird)) -- حالا شما می توانید اندازه صف به روز رسانی در نظارت `cache`/`complex_key_cache` واژهنامهها از طریق معیارهای سیستم. [\#9413](https://github.com/ClickHouse/ClickHouse/pull/9413) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- اجازه دهید به عنوان یک جداساز خط در فرمت خروجی سی. سی. وی با تنظیم استفاده کنید `output_format_csv_crlf_end_of_line` به 1 تنظیم شده است [\#8934](https://github.com/ClickHouse/ClickHouse/pull/8934) [\#8935](https://github.com/ClickHouse/ClickHouse/pull/8935) [\#8963](https://github.com/ClickHouse/ClickHouse/pull/8963) ([میخیل کوروتف](https://github.com/millb)) -- اجرای توابع بیشتری از [H3](https://github.com/uber/h3) API: `h3GetBaseCell`, `h3HexAreaM2`, `h3IndexesAreNeighbors`, `h3ToChildren`, `h3ToString` و `stringToH3` [\#8938](https://github.com/ClickHouse/ClickHouse/pull/8938) ([نیکو مان پودری](https://github.com/nmandery)) -- تنظیمات جدید معرفی شده است: `max_parser_depth` برای کنترل حداکثر اندازه پشته و اجازه می دهد نمایش داده شد پیچیده بزرگ است. این رفع [\#6681](https://github.com/ClickHouse/ClickHouse/issues/6681) و [\#7668](https://github.com/ClickHouse/ClickHouse/issues/7668). [\#8647](https://github.com/ClickHouse/ClickHouse/pull/8647) ([ماکسیم اسمیرنوف](https://github.com/qMBQx8GH)) -- افزودن یک تنظیم `force_optimize_skip_unused_shards` تنظیم به پرتاب اگر پرش از خرده ریز استفاده نشده امکان پذیر نیست [\#8805](https://github.com/ClickHouse/ClickHouse/pull/8805) ([ازات خوژین](https://github.com/azat)) -- مجاز به پیکربندی چندین دیسک / حجم برای ذخیره سازی داده ها برای ارسال در `Distributed` موتور [\#8756](https://github.com/ClickHouse/ClickHouse/pull/8756) ([ازات خوژین](https://github.com/azat)) -- سیاست ذخیره سازی پشتیبانی (``)برای ذخیره سازی داده های موقت . [\#8750](https://github.com/ClickHouse/ClickHouse/pull/8750) ([ازات خوژین](https://github.com/azat)) -- اضافه شده `X-ClickHouse-Exception-Code` هدر قام است که اگر استثنا قبل از ارسال داده ها پرتاب شد. این پیاده سازی [\#4971](https://github.com/ClickHouse/ClickHouse/issues/4971). [\#8786](https://github.com/ClickHouse/ClickHouse/pull/8786) ([میخیل کوروتف](https://github.com/millb)) -- اضافه شدن تابع `ifNotFinite`. این فقط یک شکر نحوی است: `ifNotFinite(x, y) = isFinite(x) ? x : y`. [\#8710](https://github.com/ClickHouse/ClickHouse/pull/8710) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده `last_successful_update_time` ستون در `system.dictionaries` جدول [\#9394](https://github.com/ClickHouse/ClickHouse/pull/9394) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- افزودن `blockSerializedSize` تابع (اندازه بر روی دیسک بدون فشرده سازی) [\#8952](https://github.com/ClickHouse/ClickHouse/pull/8952) ([ازات خوژین](https://github.com/azat)) -- افزودن تابع `moduloOrZero` [\#9358](https://github.com/ClickHouse/ClickHouse/pull/9358) ([هکز](https://github.com/hczhcz)) -- جداول سیستم اضافه شده است `system.zeros` و `system.zeros_mt` و همچنین توابع داستان `zeros()` و `zeros_mt()`. جداول (و توابع جدول) شامل یک ستون با نام `zero` و نوع `UInt8`. این ستون حاوی صفر. این است که برای اهداف تست به عنوان سریع ترین روش برای تولید بسیاری از ردیف مورد نیاز است. این رفع [\#6604](https://github.com/ClickHouse/ClickHouse/issues/6604) [\#9593](https://github.com/ClickHouse/ClickHouse/pull/9593) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) - -#### ویژگی تجربی {#experimental-feature} - -- اضافه کردن فرمت جمع و جور جدید از قطعات در `MergeTree`- جداول خانواده که در تمام ستون ها در یک فایل ذخیره می شود . این کمک می کند برای افزایش عملکرد درج کوچک و مکرر. فرمت قدیمی (یک فایل در هر ستون) در حال حاضر گسترده ای نامیده می شود. فرمت ذخیره سازی داده ها توسط تنظیمات کنترل می شود `min_bytes_for_wide_part` و `min_rows_for_wide_part`. [\#8290](https://github.com/ClickHouse/ClickHouse/pull/8290) ([انتون پوپوف](https://github.com/CurtizJ)) -- پشتیبانی از ذخیره سازی اس 3 برای `Log`, `TinyLog` و `StripeLog` میز [\#8862](https://github.com/ClickHouse/ClickHouse/pull/8862) ([پاول کووالنکو](https://github.com/Jokser)) - -#### رفع اشکال {#bug-fix-2} - -- فضاهای خالی متناقض ثابت در پیام های ورود به سیستم. [\#9322](https://github.com/ClickHouse/ClickHouse/pull/9322) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال که در مجموعه ای از تاپل نامش ذکر نشده به عنوان ساختارهای تو در تو در ایجاد جدول پهن شد. [\#8866](https://github.com/ClickHouse/ClickHouse/pull/8866) ([اچولکوف2](https://github.com/achulkov2)) -- ثابت موضوع زمانی که “Too many open files” خطا ممکن است رخ دهد اگر بیش از حد بسیاری از فایل های تطبیق الگوی لکه در وجود دارد `File` جدول یا `file` تابع جدول. در حال حاضر فایل ها باز تنبلی. این رفع [\#8857](https://github.com/ClickHouse/ClickHouse/issues/8857) [\#8861](https://github.com/ClickHouse/ClickHouse/pull/8861) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- قطره جدول موقت در حال حاضر قطره تنها جدول موقت. [\#8907](https://github.com/ClickHouse/ClickHouse/pull/8907) ([ویتالی بارانو](https://github.com/vitlibar)) -- حذف پارتیشن منسوخ شده زمانی که ما خاموش کردن سرور و یا جدا / ضمیمه یک جدول. [\#8602](https://github.com/ClickHouse/ClickHouse/pull/8602) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- برای چگونه دیسک پیش فرض محاسبه فضای رایگان از `data` شاخه فرعی. ثابت موضوع زمانی که مقدار فضای رایگان به درستی محاسبه نمی شود اگر `data` دایرکتوری به یک دستگاه جداگانه (مورد نادر) نصب شده است. این رفع [\#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) [\#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) ([میخیل کوروتف](https://github.com/millb)) -- اجازه کاما (صلیب) عضویت با در () داخل. [\#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) ([زویکوف](https://github.com/4ertus2)) -- اجازه می دهد به بازنویسی صلیب به درونی ملحق اگر وجود دارد \[نه\] مانند اپراتور در جایی که بخش. [\#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) ([زویکوف](https://github.com/4ertus2)) -- رفع نتیجه نادرست ممکن است پس از `GROUP BY` با تنظیم فعال `distributed_aggregation_memory_efficient`. رفع [\#9134](https://github.com/ClickHouse/ClickHouse/issues/9134). [\#9289](https://github.com/ClickHouse/ClickHouse/pull/9289) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- کلید پیدا شده است به عنوان در معیارهای لغت نامه کش از دست رفته شمارش شد. [\#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- رفع ناسازگاری پروتکل تکرار معرفی شده در [\#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [\#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([الساپین](https://github.com/alesapin)) -- شرایط مسابقه ثابت در `queue_task_handle` در هنگام راه اندازی `ReplicatedMergeTree` میز [\#9552](https://github.com/ClickHouse/ClickHouse/pull/9552) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رمز `NOT` جواب نداد `SHOW TABLES NOT LIKE` پرسوجو [\#8727](https://github.com/ClickHouse/ClickHouse/issues/8727) [\#8940](https://github.com/ClickHouse/ClickHouse/pull/8940) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن محدوده چک به تابع `h3EdgeLengthM`. بدون این چک, سرریز بافر امکان پذیر است. [\#8945](https://github.com/ClickHouse/ClickHouse/pull/8945) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال در محاسبات باریکش از عملیات منطقی سه تایی در استدلال های متعدد (بیش از 10). [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([الکساندر کازاکوف](https://github.com/Akazz)) -- رفع خطای prewhere بهینه سازی است که می تواند منجر به segfaults یا `Inconsistent number of columns got from MergeTreeRangeReader` استثنا. [\#9024](https://github.com/ClickHouse/ClickHouse/pull/9024) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع غیر منتظره `Timeout exceeded while reading from socket` استثنا, که به طور تصادفی در اتصال امن اتفاق می افتد قبل از ایست در واقع بیش از حد و هنگامی که پیشفیلتر پرس و جو فعال است. همچنین اضافه کنید `connect_timeout_with_failover_secure_ms` تنظیمات (به طور پیش فرض 100 مگابایت), که شبیه به است `connect_timeout_with_failover_ms`, اما برای اتصالات امن استفاده می شود (به دلیل دست دادن اس اس ال کندتر است, از اتصال تی پی معمولی) [\#9026](https://github.com/ClickHouse/ClickHouse/pull/9026) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع اشکال با جهش نهایی, زمانی که جهش ممکن است در حالت قطع با `parts_to_do=0` و `is_done=0`. [\#9022](https://github.com/ClickHouse/ClickHouse/pull/9022) ([الساپین](https://github.com/alesapin)) -- استفاده از جدید هر پیوستن به منطق با `partial_merge_join` تنظیمات. این ممکن است به `ANY|ALL|SEMI LEFT` و `ALL INNER` می پیوندد با `partial_merge_join=1` حالا [\#8932](https://github.com/ClickHouse/ClickHouse/pull/8932) ([زویکوف](https://github.com/4ertus2)) -- سفال در حال حاضر بست تنظیمات کردم از مبتکر به مواضع سفال به جای پرتاب یک استثنا. این ثابت اجازه می دهد تا برای ارسال نمایش داده شد به یک سفال با محدودیت های دیگر. [\#9447](https://github.com/ClickHouse/ClickHouse/pull/9447) ([ویتالی بارانو](https://github.com/vitlibar)) -- مشکل مدیریت حافظه ثابت در `MergeTreeReadPool`. [\#8791](https://github.com/ClickHouse/ClickHouse/pull/8791) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- ثابت `toDecimal*OrNull()` توابع خانواده که با رشته به نام `e`. رفع [\#8312](https://github.com/ClickHouse/ClickHouse/issues/8312) [\#8764](https://github.com/ClickHouse/ClickHouse/pull/8764) ([زویکوف](https://github.com/4ertus2)) -- اطمینان حاصل کنید که `FORMAT Null` هیچ اطلاعاتی را به مشتری ارسال نمی کند. [\#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- رفع اشکال که برچسب زمان در `LiveViewBlockInputStream` به روز نمی. `LIVE VIEW` یکی از ویژگی های تجربی است. [\#8644](https://github.com/ClickHouse/ClickHouse/pull/8644) ([وکسیدر](https://github.com/Vxider)) [\#8625](https://github.com/ClickHouse/ClickHouse/pull/8625) ([وکسیدر](https://github.com/Vxider)) -- ثابت `ALTER MODIFY TTL` رفتار اشتباه است که اجازه نمی دهد به حذف عبارات قدیمی. [\#8422](https://github.com/ClickHouse/ClickHouse/pull/8422) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- گزارش ثابت اوبسان در ادغام. این رفع [\#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) [\#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفتار را ثابت کرد `match` و `extract` توابع زمانی که کومه علف خشک است صفر بایت. رفتار اشتباه بود که کومه علف خشک ثابت بود. این رفع [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از پرتاب از تخریب کننده در کتابخانه ' 3-حزب خود نمایی. [\#9066](https://github.com/ClickHouse/ClickHouse/pull/9066) ([اندرو انیشچوک](https://github.com/oandrew)) -- هنوز یک دسته نظرسنجی از مرتکب نشده `Kafka` تا حدی که می تواند به سوراخ در داده ها منجر شود. [\#8876](https://github.com/ClickHouse/ClickHouse/pull/8876) ([فیلیمونف](https://github.com/filimonov)) -- ثابت `joinGet` با انواع بازگشت باطل. https://github.com/ClickHouse/ClickHouse/issues/8919 [\#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) ([ایموس پرنده](https://github.com/amosbird)) -- رفع ناسازگاری داده ها در هنگام فشرده با `T64` وابسته به کدک. [\#9016](https://github.com/ClickHouse/ClickHouse/pull/9016) ([زویکوف](https://github.com/4ertus2)) رفع شناسه نوع داده در `T64` کدک فشرده سازی است که منجر به اشتباه (د) فشرده سازی در نسخه های تحت تاثیر قرار. [\#9033](https://github.com/ClickHouse/ClickHouse/pull/9033) ([زویکوف](https://github.com/4ertus2)) -- افزودن تنظیمات `enable_early_constant_folding` و در برخی موارد که منجر به خطا غیر فعال کنید. [\#9010](https://github.com/ClickHouse/ClickHouse/pull/9010) ([زویکوف](https://github.com/4ertus2)) -- رفع pushdown گزاره optimizer با مشاهده و فعال کردن آزمون [\#9011](https://github.com/ClickHouse/ClickHouse/pull/9011) ([زمستان ژانگ](https://github.com/zhang2014)) -- رفع segfault در `Merge` جداول, که می تواند رخ دهد در هنگام خواندن از `File` ذخیره سازی [\#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) ([تاولوبیکس](https://github.com/tavplubix)) -- اضافه شدن یک چک برای سیاست ذخیره سازی در `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE`. در غیر این صورت می تواند داده ها از بخش غیر قابل دسترس پس از راه اندازی مجدد و جلوگیری از کلیک برای شروع. [\#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اصلاح تغییر می دهد اگر برای جدول تنظیم شده است. [\#8800](https://github.com/ClickHouse/ClickHouse/pull/8800) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع شرایط مسابقه است که می تواند رخ دهد که `SYSTEM RELOAD ALL DICTIONARIES` اعدام در حالی که برخی از فرهنگ لغت است که اصلاح/اضافه/حذف شده است. [\#8801](https://github.com/ClickHouse/ClickHouse/pull/8801) ([ویتالی بارانو](https://github.com/vitlibar)) -- در نسخه های قبلی `Memory` موتور پایگاه داده استفاده از مسیر داده خالی, بنابراین جداول در ایجاد `path` directory (e.g. `/var/lib/clickhouse/`), not in data directory of database (e.g. `/var/lib/clickhouse/db_name`). [\#8753](https://github.com/ClickHouse/ClickHouse/pull/8753) ([تاولوبیکس](https://github.com/tavplubix)) -- ثابت پیام ورود به سیستم اشتباه در مورد از دست رفته دیسک به طور پیش فرض و یا سیاست. [\#9530](https://github.com/ClickHouse/ClickHouse/pull/9530) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- ثابت نیست (است ()) برای شاخص نفخ\_فیلتر از انواع مجموعه. [\#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([ایشیمب](https://github.com/achimbab)) -- اجازه دادن ستون اول (ها) در یک جدول با `Log` موتور یک نام مستعار است [\#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) ([ایوان](https://github.com/abyss7)) -- رفع منظور از محدوده در حالی که خواندن از `MergeTree` جدول در یک موضوع. این می تواند به استثنا از منجر `MergeTreeRangeReader` یا نتایج پرس و جو اشتباه است. [\#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) ([انتون پوپوف](https://github.com/CurtizJ)) -- ساخت `reinterpretAsFixedString` برای بازگشت `FixedString` به جای `String`. [\#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) ([اندرو انیشچوک](https://github.com/oandrew)) -- اجتناب از موارد بسیار نادر زمانی که کاربر می تواند پیغام خطا اشتباه دریافت کنید (`Success` به جای شرح خطا دقیق). [\#9457](https://github.com/ClickHouse/ClickHouse/pull/9457) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- هنگام استفاده از تصادف نکنید `Template` قالب با قالب ردیف خالی. [\#8785](https://github.com/ClickHouse/ClickHouse/pull/8785) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- فایل های ابرداده برای جداول سیستم را می توان در جای اشتباه ایجاد شده است [\#8653](https://github.com/ClickHouse/ClickHouse/pull/8653) ([تاولوبیکس](https://github.com/tavplubix)) رفع [\#8581](https://github.com/ClickHouse/ClickHouse/issues/8581). -- رفع مسابقه داده ها به استثنای در فرهنگ لغت کش [\#8303](https://github.com/ClickHouse/ClickHouse/issues/8303). [\#9379](https://github.com/ClickHouse/ClickHouse/pull/9379) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- یک استثنا برای پرس و جو پرتاب نکنید `ATTACH TABLE IF NOT EXISTS`. پیش از این پرتاب شد اگر جدول در حال حاضر وجود دارد, با وجود `IF NOT EXISTS` بند بند. [\#8967](https://github.com/ClickHouse/ClickHouse/pull/8967) ([انتون پوپوف](https://github.com/CurtizJ)) -- ثابت بسته شدن از دست رفته پین در پیام استثنا. [\#8811](https://github.com/ClickHouse/ClickHouse/pull/8811) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از پیام `Possible deadlock avoided` در راه اندازی تاتر مشتری در حالت تعاملی. [\#9455](https://github.com/ClickHouse/ClickHouse/pull/9455) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت موضوع زمانی که بالشتک در پایان پایگاه64 ارزش کد گذاری را می توان ناقص. به روز رسانی پایگاه64 کتابخانه. این رفع [\#9491](https://github.com/ClickHouse/ClickHouse/issues/9491) بسته [\#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [\#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- جلوگیری از از دست دادن داده ها در `Kafka` در موارد نادر زمانی که استثنا اتفاق می افتد پس از خواندن پسوند اما قبل از ارتکاب. رفع [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378) [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) ([فیلیمونف](https://github.com/filimonov)) -- استثنا ثابت در `DROP TABLE IF EXISTS` [\#8663](https://github.com/ClickHouse/ClickHouse/pull/8663) ([نیکیتا واسیلیف](https://github.com/nikvas0)) -- رفع سقوط زمانی که یک کاربر تلاش می کند `ALTER MODIFY SETTING` برای قدیمی شکل گرفته `MergeTree` موتورهای جدول خانواده. [\#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([الساپین](https://github.com/alesapin)) -- پشتیبانی از uint64 اعداد است که مناسب نیست در int64 در json-توابع مربوط. به روز رسانی سیمدجسون به استاد. این رفع [\#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) [\#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت اعدام inversed predicates که غیر به شدت monotinic عملکردی شاخص استفاده شده است. [\#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) ([الکساندر کازاکوف](https://github.com/Akazz)) -- سعی نکنید به برابر `IN` ثابت در `GROUP BY` [\#8868](https://github.com/ClickHouse/ClickHouse/pull/8868) ([ایموس پرنده](https://github.com/amosbird)) -- رفع اشکال در `ALTER DELETE` جهش که منجر به شاخص فساد. این رفع [\#9019](https://github.com/ClickHouse/ClickHouse/issues/9019) و [\#8982](https://github.com/ClickHouse/ClickHouse/issues/8982). علاوه بر این رفع شرایط مسابقه بسیار نادر در `ReplicatedMergeTree` `ALTER` نمایش داده شد. [\#9048](https://github.com/ClickHouse/ClickHouse/pull/9048) ([الساپین](https://github.com/alesapin)) -- هنگامی که تنظیمات `compile_expressions` فعال است, شما می توانید `unexpected column` داخل `LLVMExecutableFunction` هنگامی که ما با استفاده از `Nullable` نوع [\#8910](https://github.com/ClickHouse/ClickHouse/pull/8910) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- رفع چندگانه برای `Kafka` موتور: 1) ثابت تکراری که در طول توازن گروه مصرف کننده ظاهر شد. 2) رفع نادر ‘holes’ به نظر می رسد زمانی که داده ها از چندین پارتیشن با یک نظرسنجی نظرسنجی نظرسنجی نظرسنجی شد و تا حدی متعهد (در حال حاضر ما همیشه پردازش / مرتکب کل نظرسنجی بلوک از پیام). 3) رفع حملات گرگرفتگی با اندازه بلوک (قبل از که تنها با فاصله گرگرفتگی به درستی کار می کرد). 4) روش اشتراک بهتر (با بازخورد انتساب). 5) را تست کار سریع تر (با فواصل پیش فرض و وقفه). با توجه به این واقعیت است که داده ها توسط اندازه بلوک قبل از سرخ نیست (همانطور که باید با توجه به اسناد و مدارک), که روابط عمومی ممکن است به برخی از تخریب عملکرد با تنظیمات پیش فرض منجر شود (با توجه به بیشتر & حملات گرگرفتگی قلع که کمتر بهینه هستند). اگر موضوع عملکرد شما روبرو می شوند که پس از تغییر - لطفا افزایش می دهد `kafka_max_block_size` در جدول به ارزش بزرگتر ( به عنوان مثال `CREATE TABLE ...Engine=Kafka ... SETTINGS ... kafka_max_block_size=524288`). رفع [\#7259](https://github.com/ClickHouse/ClickHouse/issues/7259) [\#8917](https://github.com/ClickHouse/ClickHouse/pull/8917) ([فیلیمونف](https://github.com/filimonov)) -- ثابت `Parameter out of bound` استثنا در برخی از نمایش داده شد پس از بهینه سازی در همه جا. [\#8914](https://github.com/ClickHouse/ClickHouse/pull/8914) ([Baudouin Giard](https://github.com/bgiard)) -- ثابت مورد مخلوط ثابت استدلال از تابع `arrayZip`. [\#8705](https://github.com/ClickHouse/ClickHouse/pull/8705) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- هنگام اجرای `CREATE` پرس و جو, برابر عبارات ثابت در استدلال موتور ذخیره سازی. جایگزین کردن نام دادگان خالی با دادگان فعلی. رفع [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492) [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) ([تاولوبیکس](https://github.com/tavplubix)) -- در حال حاضر امکان ایجاد یا اضافه کردن ستون ها با نام مستعار چرخه ای ساده مانند وجود ندارد `a DEFAULT b, b DEFAULT a`. [\#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([الساپین](https://github.com/alesapin)) -- رفع اشکال با حرکت دو که ممکن است بخش اصلی فاسد است. این مربوط است اگر شما استفاده کنید `ALTER TABLE MOVE` [\#8680](https://github.com/ClickHouse/ClickHouse/pull/8680) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اجازه داده شود `interval` شناسه به درستی تجزیه و تحلیل بدون پشت. موضوع ثابت زمانی که پرس و جو نمی تواند اجرا شود حتی اگر `interval` شناسه در پشت و یا به نقل از دو محصور. این رفع [\#9124](https://github.com/ClickHouse/ClickHouse/issues/9124). [\#9142](https://github.com/ClickHouse/ClickHouse/pull/9142) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تست ریش ریش شدن ثابت و رفتار نادرست از `bitTestAll`/`bitTestAny` توابع. [\#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع سقوط احتمالی / تعداد اشتباه ردیف در `LIMIT n WITH TIES` هنگامی که بسیاری از ردیف به نفر ردیف برابر وجود دارد. [\#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع جهش با قطعات نوشته شده با فعال `insert_quorum`. [\#9463](https://github.com/ClickHouse/ClickHouse/pull/9463) ([الساپین](https://github.com/alesapin)) -- رفع مسابقه داده ها در نابودی `Poco::HTTPServer`. این می تواند رخ دهد زمانی که سرور شروع شده است و بلافاصله تعطیل. [\#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع اشکال که در هنگام اجرای پیغام خطای گمراه کننده نشان داده شده است `SHOW CREATE TABLE a_table_that_does_not_exist`. [\#8899](https://github.com/ClickHouse/ClickHouse/pull/8899) ([اچولکوف2](https://github.com/achulkov2)) -- ثابت `Parameters are out of bound` استثنا در برخی موارد نادر زمانی که ما یک ثابت در `SELECT` بند زمانی که ما یک `ORDER BY` و یک `LIMIT` بند بند. [\#8892](https://github.com/ClickHouse/ClickHouse/pull/8892) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- رفع جهش نهایی, زمانی که در حال حاضر انجام جهش می تواند وضعیت را داشته باشد `is_done=0`. [\#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) ([الساپین](https://github.com/alesapin)) -- جلوگیری از اجرای `ALTER ADD INDEX` برای جداول ادغام با نحو قدیمی, چرا که کار نمی کند. [\#8822](https://github.com/ClickHouse/ClickHouse/pull/8822) ([میخیل کوروتف](https://github.com/millb)) -- در هنگام راه اندازی سرور جدول دسترسی پیدا کنید, که `LIVE VIEW` بستگی دارد, بنابراین سرور قادر به شروع خواهد بود. همچنین حذف `LIVE VIEW` وابستگی زمانی که جدا `LIVE VIEW`. `LIVE VIEW` یکی از ویژگی های تجربی است. [\#8824](https://github.com/ClickHouse/ClickHouse/pull/8824) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع اشکال احتمالی در `MergeTreeRangeReader`, در حالی که اجرای `PREWHERE`. [\#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع چک عدم تطابق ممکن است با ستون. [\#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع اشکال زمانی که قطعات شد که در پس زمینه با قوانین تغییر زمان در مورد نقل مکان کرد زمانی که تنها یک حجم وجود دارد. [\#8672](https://github.com/ClickHouse/ClickHouse/pull/8672) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- ثابت موضوع `Method createColumn() is not implemented for data type Set`. این رفع [\#7799](https://github.com/ClickHouse/ClickHouse/issues/7799). [\#8674](https://github.com/ClickHouse/ClickHouse/pull/8674) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر ما سعی خواهد کرد نهایی جهش بیشتر. [\#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([الساپین](https://github.com/alesapin)) -- ثابت `intDiv` توسط منهای یک ثابت [\#9351](https://github.com/ClickHouse/ClickHouse/pull/9351) ([هکز](https://github.com/hczhcz)) -- رفع شرایط مسابقه ممکن است در `BlockIO`. [\#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع اشکال منجر به ختم سرور در هنگام تلاش برای استفاده / رها کردن `Kafka` جدول ایجاد شده با اشتباه پارامترهای. [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) ([فیلیمونف](https://github.com/filimonov)) -- اضافه شده راه حل اگر سیستم عامل نتیجه اشتباه را برمی گرداند `timer_create` تابع. [\#8837](https://github.com/ClickHouse/ClickHouse/pull/8837) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خطای ثابت در استفاده از `min_marks_for_seek` پارامتر. ثابت پیام خطا زمانی که هیچ کلید شارژ در جدول توزیع وجود دارد و ما سعی می کنیم به جست و خیز خرده ریز استفاده نشده. [\#8908](https://github.com/ClickHouse/ClickHouse/pull/8908) ([ازات خوژین](https://github.com/azat)) - -#### بهبود {#improvement} - -- پیاده سازی `ALTER MODIFY/DROP` نمایش داده شد در بالای جهش برای `ReplicatedMergeTree*` خانواده موتور. حالا `ALTERS` بلوک تنها در مرحله به روز رسانی ابرداده, و بعد از که مسدود نمی. [\#8701](https://github.com/ClickHouse/ClickHouse/pull/8701) ([الساپین](https://github.com/alesapin)) -- اضافه کردن توانایی بازنویسی صلیب به درونی می پیوندد با `WHERE` بخش حاوی نام بدون تغییر. [\#9512](https://github.com/ClickHouse/ClickHouse/pull/9512) ([زویکوف](https://github.com/4ertus2)) -- ساخت `SHOW TABLES` و `SHOW DATABASES` نمایش داده شد حمایت از `WHERE` عبارات و `FROM`/`IN` [\#9076](https://github.com/ClickHouse/ClickHouse/pull/9076) ([بستنی و مغز گردو](https://github.com/sundy-li)) -- اضافه شدن یک تنظیم `deduplicate_blocks_in_dependent_materialized_views`. [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) ([اوریخی](https://github.com/urykhy)) -- پس از تغییرات اخیر مشتری خروجی زیر شروع به چاپ رشته های باینری در سحر و جادو در نتیجه ساخت قابل خواندن نیست ([\#9032](https://github.com/ClickHouse/ClickHouse/issues/9032)). راه حل در محل کلیک است به علامت ستون رشته به عنوان سخن گفتن-8, که همیشه نمی, اما معمولا مورد. [\#9079](https://github.com/ClickHouse/ClickHouse/pull/9079) ([یوری بارانوف](https://github.com/yurriy)) -- اضافه کردن پشتیبانی از رشته و کلید رشته برای `sumMap` [\#8903](https://github.com/ClickHouse/ClickHouse/pull/8903) ([Baudouin Giard](https://github.com/bgiard)) -- کلید های رشته پشتیبانی در نقشه های خلاصه [\#8933](https://github.com/ClickHouse/ClickHouse/pull/8933) ([Baudouin Giard](https://github.com/bgiard)) -- سیگنال ختم موضوع به استخر موضوع حتی اگر موضوع استثنا پرتاب کرده است [\#8736](https://github.com/ClickHouse/ClickHouse/pull/8736) ([هشدار داده می شود](https://github.com/dingxiangfei2009)) -- مجاز به تنظیم `query_id` داخل `clickhouse-benchmark` [\#9416](https://github.com/ClickHouse/ClickHouse/pull/9416) ([انتون پوپوف](https://github.com/CurtizJ)) -- اجازه نمی دهد عبارات عجیب و غریب در `ALTER TABLE ... PARTITION partition` پرس و جو. این آدرس [\#7192](https://github.com/ClickHouse/ClickHouse/issues/7192) [\#8835](https://github.com/ClickHouse/ClickHouse/pull/8835) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- جدول `system.table_engines` در حال حاضر اطلاعات در مورد پشتیبانی از ویژگی فراهم می کند (مانند `supports_ttl` یا `supports_sort_order`). [\#8830](https://github.com/ClickHouse/ClickHouse/pull/8830) ([مکس اخمدوف](https://github.com/zlobober)) -- فعالسازی `system.metric_log` به طور پیش فرض. آن را شامل ردیف های با ارزش از ProfileEvents, CurrentMetrics جمع آوری شده با “collect\_interval\_milliseconds” فاصله (یک ثانیه به طور پیش فرض). جدول بسیار کوچک است (معمولا به ترتیب مگابایت) و جمع اوری این داده ها به طور پیش فرض معقول است. [\#9225](https://github.com/ClickHouse/ClickHouse/pull/9225) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries. Fixes [\#6964](https://github.com/ClickHouse/ClickHouse/issues/6964) [\#8874](https://github.com/ClickHouse/ClickHouse/pull/8874) ([ایوان](https://github.com/abyss7)) -- در حال حاضر موقت `LIVE VIEW` ایجاد شده توسط `CREATE LIVE VIEW name WITH TIMEOUT [42] ...` به جای `CREATE TEMPORARY LIVE VIEW ...`, چرا که نحو قبلی بود سازگار با نیست `CREATE TEMPORARY TABLE ...` [\#9131](https://github.com/ClickHouse/ClickHouse/pull/9131) ([تاولوبیکس](https://github.com/tavplubix)) -- اضافه کردن \_خروج.پارامتر پیکربندی سطح برای محدود کردن ورودی که می رود به `system.text_log` جدول [\#8809](https://github.com/ClickHouse/ClickHouse/pull/8809) ([ازات خوژین](https://github.com/azat)) -- اجازه می دهد برای قرار دادن بخش دانلود شده به دیسک/حجم با توجه به قوانین تی ال [\#8598](https://github.com/ClickHouse/ClickHouse/pull/8598) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- برای لغت نامه خروجی زیر خارجی, اجازه می دهد برای تغییر دادن خروجی زیر استخر اتصال به “share” در میان واژهنامهها. این گزینه به طور قابل توجهی تعداد اتصالات به سرور خروجی زیر را کاهش می دهد. [\#9409](https://github.com/ClickHouse/ClickHouse/pull/9409) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- نمایش نزدیکترین زمان اجرای پرس و جو برای کوانتوم در `clickhouse-benchmark` خروجی به جای مقادیر درونیابی. بهتر است برای نشان دادن ارزش هایی که مربوط به زمان اجرای برخی از نمایش داده شد. [\#8712](https://github.com/ClickHouse/ClickHouse/pull/8712) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- امکان اضافه کردن کلید و زمان بندی برای پیام هنگام قرار دادن داده ها به کافکا. رفع [\#7198](https://github.com/ClickHouse/ClickHouse/issues/7198) [\#8969](https://github.com/ClickHouse/ClickHouse/pull/8969) ([فیلیمونف](https://github.com/filimonov)) -- اگر سرور از ترمینال اجرا, تعداد موضوع برجسته, شناسه پرس و جو و اولویت ورود به سیستم با رنگ. این است که برای خوانایی بهبود یافته از پیام ورود به سیستم در ارتباط برای توسعه دهندگان. [\#8961](https://github.com/ClickHouse/ClickHouse/pull/8961) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پیام استثنا بهتر در حالی که بارگذاری جداول برای `Ordinary` پایگاه داده است. [\#9527](https://github.com/ClickHouse/ClickHouse/pull/9527) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پیاده سازی `arraySlice` برای ارریس با عملکرد کل ایالات. این رفع [\#9388](https://github.com/ClickHouse/ClickHouse/issues/9388) [\#9391](https://github.com/ClickHouse/ClickHouse/pull/9391) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجازه می دهد توابع ثابت و مجموعه های ثابت در سمت راست در اپراتور استفاده می شود. [\#8813](https://github.com/ClickHouse/ClickHouse/pull/8813) ([انتون پوپوف](https://github.com/CurtizJ)) -- اگر استثنا باغ وحش اتفاق افتاده است در حالی که واکشی داده ها برای سیستم.تکرار, نمایش در یک ستون جداگانه. این پیاده سازی [\#9137](https://github.com/ClickHouse/ClickHouse/issues/9137) [\#9138](https://github.com/ClickHouse/ClickHouse/pull/9138) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بطور عام حذف قطعات داده ادغام در نابود کردن. [\#8402](https://github.com/ClickHouse/ClickHouse/pull/8402) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- پشتیبانی امنیت سطح ردیف برای جداول توزیع شده است. [\#8926](https://github.com/ClickHouse/ClickHouse/pull/8926) ([ایوان](https://github.com/abyss7)) -- Now we recognize suffix (like KB, KiB…) in settings values. [\#8072](https://github.com/ClickHouse/ClickHouse/pull/8072) ([میخیل کوروتف](https://github.com/millb)) -- جلوگیری از حافظه در حالی که ساخت نتیجه یک بزرگ بپیوندید. [\#8637](https://github.com/ClickHouse/ClickHouse/pull/8637) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده نام خوشه به پیشنهادات در حالت تعاملی در `clickhouse-client`. [\#8709](https://github.com/ClickHouse/ClickHouse/pull/8709) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries [\#8820](https://github.com/ClickHouse/ClickHouse/pull/8820) ([ایوان](https://github.com/abyss7)) -- ستون اضافه شده `exception_code` داخل `system.query_log` جدول [\#8770](https://github.com/ClickHouse/ClickHouse/pull/8770) ([میخیل کوروتف](https://github.com/millb)) -- فعال خروجی زیر سرور سازگاری در بندر `9004` در فایل پیکربندی سرور به طور پیش فرض. دستور تولید رمز عبور ثابت در مثال در پیکربندی. [\#8771](https://github.com/ClickHouse/ClickHouse/pull/8771) ([یوری بارانوف](https://github.com/yurriy)) -- جلوگیری از سقط جنین در خاموش کردن اگر سیستم فایل به صورت خوانده است. این رفع [\#9094](https://github.com/ClickHouse/ClickHouse/issues/9094) [\#9100](https://github.com/ClickHouse/ClickHouse/pull/9100) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پیام استثنا بهتر زمانی که طول در قام پست پرس و جو مورد نیاز است. [\#9453](https://github.com/ClickHouse/ClickHouse/pull/9453) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- افزودن `_path` و `_file` ستون مجازی به `HDFS` و `File` موتور و `hdfs` و `file` توابع جدول [\#8489](https://github.com/ClickHouse/ClickHouse/pull/8489) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- رفع خطا `Cannot find column` در حالی که قرار دادن به `MATERIALIZED VIEW` در صورتی که اگر ستون جدید برای مشاهده جدول داخلی اضافه شد. [\#8766](https://github.com/ClickHouse/ClickHouse/pull/8766) [\#8788](https://github.com/ClickHouse/ClickHouse/pull/8788) ([vzakaznikov](https://github.com/vzakaznikov)) [\#8788](https://github.com/ClickHouse/ClickHouse/issues/8788) [\#8806](https://github.com/ClickHouse/ClickHouse/pull/8806) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) [\#8803](https://github.com/ClickHouse/ClickHouse/pull/8803) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع پیشرفت بیش از پروتکل کلاینت سرور بومی, با ارسال پیشرفت پس از به روز رسانی نهایی (مانند سیاهههای مربوط). این ممکن است تنها مربوط به برخی از ابزار های شخص ثالث که با استفاده از پروتکل های بومی. [\#9495](https://github.com/ClickHouse/ClickHouse/pull/9495) ([ازات خوژین](https://github.com/azat)) -- اضافه کردن یک سیستم متریک ردیابی تعداد اتصالات مشتری با استفاده از پروتکل خروجی زیر ([\#9013](https://github.com/ClickHouse/ClickHouse/issues/9013)). [\#9015](https://github.com/ClickHouse/ClickHouse/pull/9015) ([یوجین کلیموف](https://github.com/Slach)) -- از این به بعد پاسخ های اچ تی پی `X-ClickHouse-Timezone` هدر را به مقدار منطقه زمانی همان است که `SELECT timezone()` دوست گزارش. [\#9493](https://github.com/ClickHouse/ClickHouse/pull/9493) ([دنیس گلازاشف](https://github.com/traceon)) - -#### بهبود عملکرد {#performance-improvement} - -- بهبود عملکرد شاخص تجزیه و تحلیل با در [\#9261](https://github.com/ClickHouse/ClickHouse/pull/9261) ([انتون پوپوف](https://github.com/CurtizJ)) -- کد ساده تر و موثر تر در توابع منطقی + پاکسازی کد. پیگیری به [\#8718](https://github.com/ClickHouse/ClickHouse/issues/8718) [\#8728](https://github.com/ClickHouse/ClickHouse/pull/8728) ([الکساندر کازاکوف](https://github.com/Akazz)) -- بهبود عملکرد کلی (در محدوده 5%..200% برای نمایش داده شد تحت تاثیر قرار) با تضمین و حتی بایاس سخت تر با ج++20 ویژگی های. [\#9304](https://github.com/ClickHouse/ClickHouse/pull/9304) ([ایموس پرنده](https://github.com/amosbird)) -- مقایسه دقیق تر برای حلقه های داخلی توابع مقایسه. [\#9327](https://github.com/ClickHouse/ClickHouse/pull/9327) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بایاس سخت تر برای حلقه داخلی از توابع ریاضی. [\#9325](https://github.com/ClickHouse/ClickHouse/pull/9325) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- A ~3 بار سریع تر برای اجرای ColumnVector::تکرار () از طریق آن ColumnConst::convertToFullColumn() اجرا شده است. همچنین در تست مفید خواهد بود که تحقق ثابت. [\#9293](https://github.com/ClickHouse/ClickHouse/pull/9293) ([الکساندر کازاکوف](https://github.com/Akazz)) -- یکی دیگر از بهبود عملکرد کوچک به `ColumnVector::replicate()` (این سرعت `materialize` عملکرد و توابع سفارش بالاتر) بهبود و حتی بیشتر به [\#9293](https://github.com/ClickHouse/ClickHouse/issues/9293) [\#9442](https://github.com/ClickHouse/ClickHouse/pull/9442) ([الکساندر کازاکوف](https://github.com/Akazz)) -- بهبود عملکرد `stochasticLinearRegression` تابع جمع. این پچ توسط اینتل کمک. [\#8652](https://github.com/ClickHouse/ClickHouse/pull/8652) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهبود عملکرد `reinterpretAsFixedString` تابع. [\#9342](https://github.com/ClickHouse/ClickHouse/pull/9342) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بلوک ها را به مشتری ارسال نکنید `Null` فرمت در پردازنده خط لوله. [\#8797](https://github.com/ClickHouse/ClickHouse/pull/8797) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) [\#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([الکساندر کوزمنکوف](https://github.com/akuzm)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement} - -- سیستم های انتقال مواد استثنا در حال حاضر به درستی کار می کند در زیر سیستم ویندوز برای لینوکس. ببینید https://github.com/clickhouse-extras/libunwind/pull/3 این رفع [\#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [\#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([سوبولسو](https://github.com/sobolevsv)) -- جایگزینی `readline` با `replxx` برای ویرایش خط تعاملی در `clickhouse-client` [\#8416](https://github.com/ClickHouse/ClickHouse/pull/8416) ([ایوان](https://github.com/abyss7)) -- بهتر است زمان ساخت و کمتر در قالب instantiations در functionscomparison. [\#9324](https://github.com/ClickHouse/ClickHouse/pull/9324) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ادغام اضافه شده با `clang-tidy` در سی. همچنین نگاه کنید به [\#6044](https://github.com/ClickHouse/ClickHouse/issues/6044) [\#9566](https://github.com/ClickHouse/ClickHouse/pull/9566) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر ما لینک کلیک در سی با استفاده از `lld` حتی برای `gcc`. [\#9049](https://github.com/ClickHouse/ClickHouse/pull/9049) ([الساپین](https://github.com/alesapin)) -- اجازه می دهد به صورت تصادفی برنامه ریزی موضوع و درج اشکالات زمانی که `THREAD_FUZZER_*` متغیرهای محیطی تنظیم شده است. این کمک می کند تا تست. [\#9459](https://github.com/ClickHouse/ClickHouse/pull/9459) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- فعال کردن سوکت امن در تست بدون تابعیت [\#9288](https://github.com/ClickHouse/ClickHouse/pull/9288) ([تاولوبیکس](https://github.com/tavplubix)) -- را split\_shared\_libraries=خاموش قوی تر [\#9156](https://github.com/ClickHouse/ClickHouse/pull/9156) ([ازات خوژین](https://github.com/azat)) -- ساخت “performance\_introspection\_and\_logging” تست قابل اعتماد به سرور تصادفی گیر کرده است. این ممکن است در محیط زیست سی اتفاق می افتد. همچنین نگاه کنید به [\#9515](https://github.com/ClickHouse/ClickHouse/issues/9515) [\#9528](https://github.com/ClickHouse/ClickHouse/pull/9528) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اعتبار میلی لیتر در چک سبک. [\#9550](https://github.com/ClickHouse/ClickHouse/pull/9550) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شرایط مسابقه ثابت در تست `00738_lock_for_inner_table`. این تست به خواب متکی بود. [\#9555](https://github.com/ClickHouse/ClickHouse/pull/9555) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تست عملکرد نوع را حذف کنید `once`. این مورد نیاز است برای اجرای تمام تست های عملکرد در حالت مقایسه استاتیک (قابل اعتماد تر). [\#9557](https://github.com/ClickHouse/ClickHouse/pull/9557) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده تست عملکرد برای توابع ریاضی. [\#9326](https://github.com/ClickHouse/ClickHouse/pull/9326) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تست عملکرد اضافه شده برای `sumMap` و `sumMapWithOverflow` توابع مجموع. پیگیری برای [\#8933](https://github.com/ClickHouse/ClickHouse/issues/8933) [\#8947](https://github.com/ClickHouse/ClickHouse/pull/8947) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اطمینان از سبک کد های خطا با چک سبک. [\#9370](https://github.com/ClickHouse/ClickHouse/pull/9370) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن اسکریپت برای تست تاریخ. [\#8796](https://github.com/ClickHouse/ClickHouse/pull/8796) ([الساپین](https://github.com/alesapin)) -- افزودن هشدار شورای همکاری خلیج فارس `-Wsuggest-override` برای قرار دادن و رفع تمام مکان هایی که `override` کلمه کلیدی باید استفاده شود. [\#8760](https://github.com/ClickHouse/ClickHouse/pull/8760) ([کروزرکریگ](https://github.com/kreuzerkrieg)) -- نادیده گرفتن نماد ضعیف تحت سیستم عامل مک ایکس زیرا باید تعریف شود [\#9538](https://github.com/ClickHouse/ClickHouse/pull/9538) ([کاربر حذفشده](https://github.com/ghost)) -- عادی زمان در حال اجرا از برخی از نمایش داده شد در تست عملکرد. این است که در تهیه برای اجرای تمام تست های عملکرد در حالت مقایسه انجام می شود. [\#9565](https://github.com/ClickHouse/ClickHouse/pull/9565) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع برخی از تست ها برای حمایت از تست های پرس و جو [\#9062](https://github.com/ClickHouse/ClickHouse/pull/9062) ([ایوان](https://github.com/abyss7)) -- فعال کردن اس اس ال در ساخت با ام اس ان, بنابراین سرور نمی خواهد شکست در هنگام راه اندازی در حال اجرا تست بدون تابعیت [\#9531](https://github.com/ClickHouse/ClickHouse/pull/9531) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع جایگزینی پایگاه داده در نتایج تست [\#9384](https://github.com/ClickHouse/ClickHouse/pull/9384) ([ایلیا یاتسیشین](https://github.com/qoega)) -- ساخت رفع برای سیستم عامل های دیگر [\#9381](https://github.com/ClickHouse/ClickHouse/pull/9381) ([پرولر](https://github.com/proller)) [\#8755](https://github.com/ClickHouse/ClickHouse/pull/8755) ([پرولر](https://github.com/proller)) [\#8631](https://github.com/ClickHouse/ClickHouse/pull/8631) ([پرولر](https://github.com/proller)) -- اضافه شدن بخش دیسک به بدون تابعیت با پوشش تصویر داکر تست [\#9213](https://github.com/ClickHouse/ClickHouse/pull/9213) ([پاول کووالنکو](https://github.com/Jokser)) -- خلاص شدن از شر در منبع درخت فایل در هنگام ساخت با پتروشیمی [\#9588](https://github.com/ClickHouse/ClickHouse/pull/9588) ([ایموس پرنده](https://github.com/amosbird)) -- زمان ساخت کمی سریع تر با از بین بردن تجزیه طلبان از زمینه. کد را ساده تر کنید. [\#9232](https://github.com/ClickHouse/ClickHouse/pull/9232) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز شده در چک کردن برای نمایش داده شد را قطع کرد در اسکریپت کلیک تست [\#8858](https://github.com/ClickHouse/ClickHouse/pull/8858) ([الکساندر کازاکوف](https://github.com/Akazz)) -- حذف برخی از فایل های بی فایده از مخزن. [\#8843](https://github.com/ClickHouse/ClickHouse/pull/8843) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نوع تغییر کامل ریاضی از `once` به `loop`. [\#8783](https://github.com/ClickHouse/ClickHouse/pull/8783) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اضافه کردن تصویر کارگر بارانداز که اجازه می دهد تا برای ساخت کد تعاملی مرورگر گزارش متنی برای کدهای ما. [\#8781](https://github.com/ClickHouse/ClickHouse/pull/8781) ([الساپین](https://github.com/alesapin)) ببینید [مرورگر کد ووبوک](https://clickhouse.tech/codebrowser/html_report///ClickHouse/dbms/src/index.html) -- سرکوب برخی از شکست تست تحت مسان. [\#8780](https://github.com/ClickHouse/ClickHouse/pull/8780) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- افزایش سرعت “exception while insert” امتحان این تست اغلب زمان در اشکال زدایی با پوشش ساخت. [\#8711](https://github.com/ClickHouse/ClickHouse/pull/8711) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز شده `libcxx` و `libcxxabi` به سلامتی استاد در تهیه به [\#9304](https://github.com/ClickHouse/ClickHouse/issues/9304) [\#9308](https://github.com/ClickHouse/ClickHouse/pull/9308) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع تست پوسته شدن `00910_zookeeper_test_alter_compression_codecs`. [\#9525](https://github.com/ClickHouse/ClickHouse/pull/9525) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پاک کردن پرچم لینکر تکرار. اطمینان حاصل کنید که لینکر نمی خواهد نگاه کردن یک نماد غیر منتظره. [\#9433](https://github.com/ClickHouse/ClickHouse/pull/9433) ([ایموس پرنده](https://github.com/amosbird)) -- افزودن `clickhouse-odbc` درایور را به تصاویر تست. این اجازه می دهد تا به تست تعامل ClickHouse با ClickHouse از طریق خود ODBC driver. [\#9348](https://github.com/ClickHouse/ClickHouse/pull/9348) ([فیلیمونف](https://github.com/filimonov)) -- رفع چندین باگ در تست واحد. [\#9047](https://github.com/ClickHouse/ClickHouse/pull/9047) ([الساپین](https://github.com/alesapin)) -- فعالسازی `-Wmissing-include-dirs` هشدار شورای همکاری خلیج فارس برای از بین بردن تمام غیر موجود شامل-عمدتا به عنوان یک نتیجه از خطاهای برنامه نویسی کیک [\#8704](https://github.com/ClickHouse/ClickHouse/pull/8704) ([کروزرکریگ](https://github.com/kreuzerkrieg)) -- توصیف دلایل اگر پیشفیلتر پرس و جو نمی تواند کار کند. این است که برای در نظر گرفته شده [\#9049](https://github.com/ClickHouse/ClickHouse/issues/9049) [\#9144](https://github.com/ClickHouse/ClickHouse/pull/9144) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز رسانی اپنسسل به بالادست استاد. ثابت موضوع زمانی که اتصالات ال اس ممکن است با پیام شکست `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error` و `SSL Exception: error:2400006E:random number generator::error retrieving entropy`. این موضوع در حال حاضر در نسخه 20.1 بود. [\#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز رسانی صفحه مدیریت برای سرور [\#8893](https://github.com/ClickHouse/ClickHouse/pull/8893) ([ایلیا مزایف](https://github.com/ne-ray)) -- اصلاحات جزیی در ساخت شورای همکاری خلیج فارس از منابع اسکریپت [\#8774](https://github.com/ClickHouse/ClickHouse/pull/8774) ([مایکل ناچاروف](https://github.com/mnach)) -- جایگزینی `numbers` به `zeros` در کامل کجا `number` ستون استفاده نمی شود. این به نتایج تست تمیز تر منجر شود. [\#9600](https://github.com/ClickHouse/ClickHouse/pull/9600) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع مشکل سرریز پشته در هنگام استفاده از مقدار دهی اولیه در سازنده ستون. [\#9367](https://github.com/ClickHouse/ClickHouse/pull/9367) ([کاربر حذفشده](https://github.com/ghost)) -- ارتقا کتابدار به نسخه 1. 3.0. فعالسازی همراه `rdkafka` و `gsasl` کتابخانه ها در سیستم عامل مک ایکس. [\#9000](https://github.com/ClickHouse/ClickHouse/pull/9000) ([اندرو انیشچوک](https://github.com/oandrew)) -- ساخت ثابت در شورای همکاری خلیج فارس 9.2.0 [\#9306](https://github.com/ClickHouse/ClickHouse/pull/9306) ([وکسیدر](https://github.com/Vxider)) - -## انتشار کلیک و 20.1 {#clickhouse-release-v20-1} - -### ClickHouse انتشار v20.1.8.41, 2020-03-20 {#clickhouse-release-v20-1-8-41-2020-03-20} - -#### رفع اشکال {#bug-fix-3} - -- رفع همیشگی احتمالی `Cannot schedule a task` خطا (با توجه به استثنای بدون مانع در `ParallelAggregatingBlockInputStream::Handler::onFinish/onFinishThread`). این رفع [\#6833](https://github.com/ClickHouse/ClickHouse/issues/6833). [\#9154](https://github.com/ClickHouse/ClickHouse/pull/9154) ([ازات خوژین](https://github.com/azat)) -- رفع مصرف حافظه بیش از حد در `ALTER` نمایش داده شد (جهش). این رفع [\#9533](https://github.com/ClickHouse/ClickHouse/issues/9533) و [\#9670](https://github.com/ClickHouse/ClickHouse/issues/9670). [\#9754](https://github.com/ClickHouse/ClickHouse/pull/9754) ([الساپین](https://github.com/alesapin)) -- رفع اشکال در عقب نشینی در لغت نامه های خارجی. این رفع [\#9619](https://github.com/ClickHouse/ClickHouse/issues/9619). [\#9734](https://github.com/ClickHouse/ClickHouse/pull/9734) ([الساپین](https://github.com/alesapin)) - -### ClickHouse انتشار v20.1.7.38, 2020-03-18 {#clickhouse-release-v20-1-7-38-2020-03-18} - -#### رفع اشکال {#bug-fix-4} - -- ثابت نادرست نام تابع داخلی برای `sumKahan` و `sumWithOverflow`. من به استثنا منجر شود در حالی که با استفاده از این توابع در نمایش داده شد از راه دور. [\#9636](https://github.com/ClickHouse/ClickHouse/pull/9636) ([ازات خوژین](https://github.com/azat)). این موضوع در تمام نسخه های کلیک خانه بود. -- اجازه داده شود `ALTER ON CLUSTER` از `Distributed` جداول با تکرار داخلی. این رفع [\#3268](https://github.com/ClickHouse/ClickHouse/issues/3268). [\#9617](https://github.com/ClickHouse/ClickHouse/pull/9617) ([شینی2](https://github.com/shinoi2)). این موضوع در تمام نسخه های کلیک خانه بود. -- رفع استثناهای احتمالی `Size of filter doesn't match size of column` و `Invalid number of rows in Chunk` داخل `MergeTreeRangeReader`. می توانند هنگام اجرای ظاهر شوند `PREWHERE` در برخی موارد. رفع [\#9132](https://github.com/ClickHouse/ClickHouse/issues/9132). [\#9612](https://github.com/ClickHouse/ClickHouse/pull/9612) ([انتون پوپوف](https://github.com/CurtizJ)) -- ثابت موضوع: منطقه زمانی حفظ نشده بود اگر شما نوشتن یک عبارت ریاضی ساده مانند `time + 1` (در مقایسه با بیان مانند `time + INTERVAL 1 SECOND`). این رفع [\#5743](https://github.com/ClickHouse/ClickHouse/issues/5743). [\#9323](https://github.com/ClickHouse/ClickHouse/pull/9323) ([الکسی میلویدو](https://github.com/alexey-milovidov)). این موضوع در تمام نسخه های کلیک خانه بود. -- در حال حاضر امکان ایجاد یا اضافه کردن ستون ها با نام مستعار چرخه ای ساده مانند وجود ندارد `a DEFAULT b, b DEFAULT a`. [\#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([الساپین](https://github.com/alesapin)) -- ثابت موضوع که بالشتک در پایان base64 کد گذاری ارزش می تواند ناقص. به روز رسانی پایگاه64 کتابخانه. این رفع [\#9491](https://github.com/ClickHouse/ClickHouse/issues/9491) بسته [\#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [\#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع مسابقه داده ها در نابودی `Poco::HTTPServer`. این می تواند رخ دهد زمانی که سرور شروع شده است و بلافاصله تعطیل. [\#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع سقوط احتمالی / تعداد اشتباه ردیف در `LIMIT n WITH TIES` هنگامی که بسیاری از ردیف به نفر ردیف برابر وجود دارد. [\#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع چک عدم تطابق ممکن است با ستون. [\#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([انتون پوپوف](https://github.com/CurtizJ)) -- رفع سقوط زمانی که یک کاربر تلاش می کند `ALTER MODIFY SETTING` برای قدیمی شکل گرفته `MergeTree` موتورهای جدول خانواده. [\#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([الساپین](https://github.com/alesapin)) -- در حال حاضر ما سعی خواهد کرد نهایی جهش بیشتر. [\#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([الساپین](https://github.com/alesapin)) -- رفع ناسازگاری پروتکل تکرار معرفی شده در [\#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [\#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([الساپین](https://github.com/alesapin)) -- ثابت نیست (است ()) برای شاخص نفخ\_فیلتر از انواع مجموعه. [\#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([ایشیمب](https://github.com/achimbab)) -- رفتار را ثابت کرد `match` و `extract` توابع زمانی که کومه علف خشک است صفر بایت. رفتار اشتباه بود که کومه علف خشک ثابت بود. این رفع [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([الکسی میلویدو](https://github.com/alexey-milovidov)) [\#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-1} - -- سیستم های انتقال مواد استثنا در حال حاضر به درستی کار می کند در زیر سیستم ویندوز برای لینوکس. ببینید https://github.com/clickhouse-extras/libunwind/pull/3 این رفع [\#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [\#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([سوبولسو](https://github.com/sobolevsv)) - -### ClickHouse انتشار v20.1.6.30, 2020-03-05 {#clickhouse-release-v20-1-6-30-2020-03-05} - -#### رفع اشکال {#bug-fix-5} - -- رفع ناسازگاری داده ها در هنگام فشرده با `T64` وابسته به کدک. - [\#9039](https://github.com/ClickHouse/ClickHouse/pull/9039) [(بی پایان 7)](https://github.com/abyss7) -- ثابت منظور از محدوده در حالی که خواندن از جدول ادغام در یک موضوع. رفع [\#8964](https://github.com/ClickHouse/ClickHouse/issues/8964). - [\#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) [(کورتیزج)](https://github.com/CurtizJ) -- رفع اشکال احتمالی در `MergeTreeRangeReader`, در حالی که اجرای `PREWHERE`. رفع [\#9064](https://github.com/ClickHouse/ClickHouse/issues/9064). - [\#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) [(کورتیزج)](https://github.com/CurtizJ) -- ثابت `reinterpretAsFixedString` برای بازگشت `FixedString` به جای `String`. - [\#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) [(اوندرو)](https://github.com/oandrew) -- ثابت `joinGet` با انواع بازگشت باطل. رفع [\#8919](https://github.com/ClickHouse/ClickHouse/issues/8919) - [\#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) [(طرقه)](https://github.com/amosbird) -- تعمیر ریش ریش شدن آزمون و نادرست رفتار bittestall/bittestany توابع. - [\#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) [(الکسی میلویدو)](https://github.com/alexey-milovidov) -- رفع رفتار توابع بازی و استخراج زمانی که انبار کاه است صفر بایت. رفتار اشتباه بود که کومه علف خشک ثابت بود. رفع [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) - [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) [(الکسی میلویدو)](https://github.com/alexey-milovidov) -- ثابت اعدام inversed predicates که غیر به شدت monotinic عملکردی شاخص استفاده شده است. رفع [\#9034](https://github.com/ClickHouse/ClickHouse/issues/9034) - [\#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) [(اکازز)](https://github.com/Akazz) -- اجازه به بازنویسی `CROSS` به `INNER JOIN` اگر وجود دارد `[NOT] LIKE` اپراتور در `WHERE` بخش. رفع [\#9191](https://github.com/ClickHouse/ClickHouse/issues/9191) - [\#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) [(4رتوس2)](https://github.com/4ertus2) -- اجازه ستون اول (بازدید کنندگان) در یک جدول با موتور ورود به سیستم یک نام مستعار. - [\#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) [(بی پایان 7)](https://github.com/abyss7) -- اجازه دادن به کاما از هم پیوستن با `IN()` داخل رفع [\#7314](https://github.com/ClickHouse/ClickHouse/issues/7314). - [\#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) [(4رتوس2)](https://github.com/4ertus2) -- بهبود `ALTER MODIFY/ADD` نمایش داده شد منطق. حالا شما نمی توانید `ADD` ستون بدون نوع, `MODIFY` عبارت پیش فرض نوع ستون را تغییر نمی دهد و `MODIFY` نوع ارزش بیان پیش فرض را از دست نمی دهد. رفع [\#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). - [\#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) [(الساپین)](https://github.com/alesapin) -- رفع جهش نهایی, زمانی که جهش در حال حاضر انجام می شود می توانید وضعیت داشته باشد \_دون=0. - [\#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) [(الساپین)](https://github.com/alesapin) -- پشتیبانی “Processors” خط لوله برای سیستم.اعداد و سیستم.\_شماره. این نیز رفع اشکال زمانی که `max_execution_time` محترم نیست. - [\#7796](https://github.com/ClickHouse/ClickHouse/pull/7796) [.)](https://github.com/KochetovNicolai) -- رفع شمارش اشتباه از `DictCacheKeysRequestedFound` متریک. - [\#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) [(نیکیتامیخایلو)](https://github.com/nikitamikhaylov) -- اضافه شدن یک چک برای سیاست ذخیره سازی در `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE` که در غیر این صورت می تواند داده ها از بخش غیر قابل دسترس پس از راه اندازی مجدد و جلوگیری از کلیک برای شروع. - [\#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) [(هیجان)](https://github.com/excitoon) -- گزارش ثابت اوبسان در `MergeTreeIndexSet`. این رفع [\#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) - [\#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) [(الکسی میلویدو)](https://github.com/alexey-milovidov) -- رفع فضای داده ممکن در بلوکیو. - [\#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) [.)](https://github.com/KochetovNicolai) -- پشتیبانی از `UInt64` اعداد است که متناسب نیست در درون64 در توابع مربوط به جانسون. بهروزرسانی `SIMDJSON` به سلامتی استاد این رفع [\#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) - [\#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) [(الکسی میلویدو)](https://github.com/alexey-milovidov) -- رفع مشکل زمانی که مقدار فضای رایگان به درستی محاسبه نمی شود اگر دایرکتوری داده ها به یک دستگاه جداگانه نصب شود. برای دیسک پیش فرض محاسبه فضای رایگان از دایرکتوری فرعی داده ها. این رفع [\#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) - [\#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) [(میلب)](https://github.com/millb) -- رفع مشکل زمانی که اتصالات ال اس ممکن است با پیام شکست `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error and SSL Exception: error:2400006E:random number generator::error retrieving entropy.` به روز رسانی اپنسسل به بالادست استاد. - [\#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) [(الکسی میلویدو)](https://github.com/alexey-milovidov) -- هنگام اجرای `CREATE` پرس و جو, برابر عبارات ثابت در استدلال موتور ذخیره سازی. جایگزین کردن نام دادگان خالی با دادگان فعلی. رفع [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). همچنین رفع بررسی برای نشانی های محلی در کلیک کنیدشاهارزش. - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(تبلوبیکس)](https://github.com/tavplubix) -- رفع segfault در `StorageMerge`, که می تواند در هنگام خواندن از داستان اتفاق می افتد. - [\#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) [(تبلوبیکس)](https://github.com/tavplubix) -- جلوگیری از از دست دادن داده ها در `Kafka` در موارد نادر زمانی که استثنا اتفاق می افتد پس از خواندن پسوند اما قبل از ارتکاب. رفع [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). مرتبط: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(فیلیمونف)](https://github.com/filimonov) -- رفع اشکال منجر به ختم سرور در هنگام تلاش برای استفاده / رها کردن `Kafka` جدول ایجاد شده با پارامترهای اشتباه. رفع [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). دارای [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(فیلیمونف)](https://github.com/filimonov) - -#### ویژگی جدید {#new-feature-1} - -- افزودن `deduplicate_blocks_in_dependent_materialized_views` گزینه ای برای کنترل رفتار درج ژولیده به جداول با نمایش محقق. این ویژگی جدید توسط یک درخواست ویژه از التیت به نسخه رفع اشکال اضافه شد. - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [.)](https://github.com/urykhy) - -### ClickHouse انتشار v20.1.2.4, 2020-01-22 {#clickhouse-release-v20-1-2-4-2020-01-22} - -#### تغییر ناسازگار به عقب {#backward-incompatible-change-1} - -- ایجاد تنظیمات `merge_tree_uniform_read_distribution` منسوخ شده. سرور هنوز این تنظیم به رسمیت می شناسد اما هیچ اثر. [\#8308](https://github.com/ClickHouse/ClickHouse/pull/8308) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- نوع بازگشت تغییر از تابع `greatCircleDistance` به `Float32` چرا که در حال حاضر نتیجه محاسبه است `Float32`. [\#7993](https://github.com/ClickHouse/ClickHouse/pull/7993) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر انتظار می رود که پارامترهای پرس و جو در “escaped” قالب. مثلا, به تصویب رشته `ab` شما باید برای نوشتن `a\tb` یا `a\b` و به ترتیب, `a%5Ctb` یا `a%5C%09b` در URL. این مورد نیاز است برای اضافه کردن امکان به تصویب تهی به عنوان `\N`. این رفع [\#7488](https://github.com/ClickHouse/ClickHouse/issues/7488). [\#8517](https://github.com/ClickHouse/ClickHouse/pull/8517) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- فعالسازی `use_minimalistic_part_header_in_zookeeper` تنظیم برای `ReplicatedMergeTree` به طور پیش فرض. این به طور قابل توجهی مقدار داده های ذخیره شده در باغ وحش را کاهش دهد. این تنظیم از نسخه 19.1 پشتیبانی می شود و ما در حال حاضر در تولید خدمات متعدد بدون هیچ مشکلی برای بیش از نیم سال استفاده می کنیم. غیر فعال کردن این تنظیم اگر شما یک فرصت برای جمع و جور کردن به نسخه های قدیمی تر از 19.1. [\#6850](https://github.com/ClickHouse/ClickHouse/pull/6850) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شاخص های پرش داده ها تولید می شوند و به طور پیش فرض فعال می شوند. تنظیمات `allow_experimental_data_skipping_indices`, `allow_experimental_cross_to_join_conversion` و `allow_experimental_multiple_joins_emulation` در حال حاضر منسوخ و هیچ چیز. [\#7974](https://github.com/ClickHouse/ClickHouse/pull/7974) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- افزودن جدید `ANY JOIN` منطق برای `StorageJoin` سازگار با `JOIN` عمل به روز رسانی بدون تغییر در رفتار شما نیاز به اضافه کردن `SETTINGS any_join_distinct_right_table_keys = 1` به موتور پیوستن ابرداده جداول و یا از نو خلق این جداول پس از ارتقا دهید. [\#8400](https://github.com/ClickHouse/ClickHouse/pull/8400) ([زویکوف](https://github.com/4ertus2)) -- نیاز به سرور برای راه اندازی مجدد برای اعمال تغییرات در پیکربندی ورود به سیستم. این یک راه حل موقت برای جلوگیری از اشکال که سرور سیاهههای مربوط به یک فایل ورود به سیستم حذف شده است (دیدن [\#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [\#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([الکساندر کوزمنکوف](https://github.com/akuzm)) - -#### ویژگی جدید {#new-feature-2} - -- اطلاعات اضافه شده در مورد مسیرهای بخشی به `system.merges`. [\#8043](https://github.com/ClickHouse/ClickHouse/pull/8043) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- افزودن قابلیت اجرا `SYSTEM RELOAD DICTIONARY` پرسوجو در `ON CLUSTER` حالت. [\#8288](https://github.com/ClickHouse/ClickHouse/pull/8288) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) -- افزودن قابلیت اجرا `CREATE DICTIONARY` نمایش داده شد در `ON CLUSTER` حالت. [\#8163](https://github.com/ClickHouse/ClickHouse/pull/8163) ([الساپین](https://github.com/alesapin)) -- در حال حاضر مشخصات کاربر در `users.xml` می توانید پروفایل های متعدد به ارث می برند. [\#8343](https://github.com/ClickHouse/ClickHouse/pull/8343) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- اضافه شده `system.stack_trace` جدول که اجازه می دهد تا در اثری پشته از تمام موضوعات سرور نگاه. این برای توسعه دهندگان به درون نگری دولت سرور مفید است. این رفع [\#7576](https://github.com/ClickHouse/ClickHouse/issues/7576). [\#8344](https://github.com/ClickHouse/ClickHouse/pull/8344) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- افزودن `DateTime64` نوع داده با دقت زیر دوم قابل تنظیم. [\#7170](https://github.com/ClickHouse/ClickHouse/pull/7170) ([واسیلی نمکو](https://github.com/Enmk)) -- اضافه کردن تابع جدول `clusterAllReplicas` که اجازه می دهد به پرس و جو تمام گره در خوشه. [\#8493](https://github.com/ClickHouse/ClickHouse/pull/8493) ([کیران سونکری](https://github.com/kiransunkari)) -- اضافه کردن تابع جمع `categoricalInformationValue` که محاسبه ارزش اطلاعات از ویژگی های گسسته. [\#8117](https://github.com/ClickHouse/ClickHouse/pull/8117) ([هکز](https://github.com/hczhcz)) -- سرعت تجزیه فایل های داده در `CSV`, `TSV` و `JSONEachRow` قالب با انجام این کار به صورت موازی. [\#7780](https://github.com/ClickHouse/ClickHouse/pull/7780) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- افزودن تابع `bankerRound` که انجام گرد بانکدار. [\#8112](https://github.com/ClickHouse/ClickHouse/pull/8112) ([هکز](https://github.com/hczhcz)) -- پشتیبانی از زبان های بیشتر در فرهنگ لغت تعبیه شده برای نام منطقه: ‘ru’, ‘en’, ‘ua’, ‘uk’, ‘by’, ‘kz’, ‘tr’, ‘de’, ‘uz’, ‘lv’, ‘lt’, ‘et’, ‘pt’, ‘he’, ‘vi’. [\#8189](https://github.com/ClickHouse/ClickHouse/pull/8189) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهبود در سازگاری `ANY JOIN` منطق. حالا `t1 ANY LEFT JOIN t2` برابر `t2 ANY RIGHT JOIN t1`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([زویکوف](https://github.com/4ertus2)) -- افزودن تنظیمات `any_join_distinct_right_table_keys` که رفتار قدیمی را قادر می سازد `ANY INNER JOIN`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([زویکوف](https://github.com/4ertus2)) -- افزودن جدید `SEMI` و `ANTI JOIN`. قدیمی `ANY INNER JOIN` رفتار در حال حاضر به عنوان در دسترس `SEMI LEFT JOIN`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده `Distributed` قالب برای `File` موتور و `file` تابع جدول که اجازه می دهد تا از خواندن `.bin` فایل های تولید شده توسط درج ناهمزمان به `Distributed` جدول [\#8535](https://github.com/ClickHouse/ClickHouse/pull/8535) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اضافه کردن استدلال ستون تنظیم مجدد اختیاری برای `runningAccumulate` که اجازه می دهد برای تنظیم مجدد نتایج تجمع برای هر مقدار کلید جدید. [\#8326](https://github.com/ClickHouse/ClickHouse/pull/8326) ([سرگی کنوننکو](https://github.com/kononencheg)) -- اضافه کردن توانایی استفاده از فاحشه خانه به عنوان نقطه پایانی پرومته. [\#7900](https://github.com/ClickHouse/ClickHouse/pull/7900) ([ولادیمیر](https://github.com/Vdimir)) -- اضافه کردن بخش `` داخل `config.xml` که میزبان مجاز برای موتورهای جدول از راه دور و توابع جدول را محدود می کند `URL`, `S3`, `HDFS`. [\#7154](https://github.com/ClickHouse/ClickHouse/pull/7154) ([میخیل کوروتف](https://github.com/millb)) -- اضافه شدن تابع `greatCircleAngle` که محاسبه فاصله در یک کره در درجه. [\#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- شعاع زمین تغییر می شود سازگار با ساعت3 کتابخانه. [\#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شده `JSONCompactEachRow` و `JSONCompactEachRowWithNamesAndTypes` فرمت برای ورودی و خروجی. [\#7841](https://github.com/ClickHouse/ClickHouse/pull/7841) ([میخیل کوروتف](https://github.com/millb)) -- ویژگی اضافه شده برای موتورهای جدول مربوط به فایل و توابع جدول (`File`, `S3`, `URL`, `HDFS`) که اجازه می دهد به خواندن و نوشتن `gzip` فایل ها بر اساس پارامتر موتور اضافی و یا فرمت فایل. [\#7840](https://github.com/ClickHouse/ClickHouse/pull/7840) ([هشدار داده می شود](https://github.com/apbodrov)) -- اضافه شدن `randomASCII(length)` تابع, تولید یک رشته با یک مجموعه تصادفی از [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) شخصیت های قابل چاپ. [\#8401](https://github.com/ClickHouse/ClickHouse/pull/8401) ([سرنیزه](https://github.com/BayoNet)) -- اضافه شدن تابع `JSONExtractArrayRaw` که مجموعه ای از عناصر مجموعه ای از جیسون نامحدود را باز می کند `JSON` رشته. [\#8081](https://github.com/ClickHouse/ClickHouse/pull/8081) ([اولگ متررخین](https://github.com/errx)) -- افزودن `arrayZip` تابع است که اجازه می دهد تا به ترکیب مجموعه ای از چند بند از طول برابر به یک مجموعه ای از تاپل. [\#8149](https://github.com/ClickHouse/ClickHouse/pull/8149) ([زمستان ژانگ](https://github.com/zhang2014)) -- اضافه کردن توانایی انتقال داده ها بین دیسک ها با توجه به پیکربندی `TTL`- عبارات برای `*MergeTree` موتورهای جدول خانواده. [\#8140](https://github.com/ClickHouse/ClickHouse/pull/8140) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اضافه شدن تابع جمع جدید `avgWeighted` که اجازه می دهد برای محاسبه میانگین وزن. [\#7898](https://github.com/ClickHouse/ClickHouse/pull/7898) ([هشدار داده می شود](https://github.com/apbodrov)) -- در حال حاضر تجزیه موازی به طور پیش فرض برای فعال `TSV`, `TSKV`, `CSV` و `JSONEachRow` فرمتها. [\#7894](https://github.com/ClickHouse/ClickHouse/pull/7894) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- اضافه کردن چندین توابع جغرافیایی از `H3` کتابخانه: `h3GetResolution`, `h3EdgeAngle`, `h3EdgeLength`, `h3IsValid` و `h3kRing`. [\#8034](https://github.com/ClickHouse/ClickHouse/pull/8034) ([کنستانتین مالانچو](https://github.com/hombit)) -- اضافه شدن پشتیبانی برای برتلی (`br`) فشرده سازی در ذخیره سازی مربوط به فایل و توابع جدول . این رفع [\#8156](https://github.com/ClickHouse/ClickHouse/issues/8156). [\#8526](https://github.com/ClickHouse/ClickHouse/pull/8526) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- افزودن `groupBit*` توابع برای `SimpleAggregationFunction` نوع. [\#8485](https://github.com/ClickHouse/ClickHouse/pull/8485) ([کارخانه شراب سازی گیوم](https://github.com/YiuRULE)) - -#### رفع اشکال {#bug-fix-6} - -- رفع تغییر نام جداول با `Distributed` موتور رفع مشکل [\#7868](https://github.com/ClickHouse/ClickHouse/issues/7868). [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([تاولوبیکس](https://github.com/tavplubix)) -- در حال حاضر پشتیبانی لغت نامه `EXPRESSION` برای ویژگی های در رشته دلخواه در گویش غیر کلیک میدان. [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([الساپین](https://github.com/alesapin)) -- رفع شکسته `INSERT SELECT FROM mysql(...)` پرس و جو. این رفع [\#8070](https://github.com/ClickHouse/ClickHouse/issues/8070) و [\#7960](https://github.com/ClickHouse/ClickHouse/issues/7960). [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع خطا “Mismatch column sizes” هنگام وارد کردن پیشفرض `Tuple` از `JSONEachRow`. این رفع [\#5653](https://github.com/ClickHouse/ClickHouse/issues/5653). [\#8606](https://github.com/ClickHouse/ClickHouse/pull/8606) ([تاولوبیکس](https://github.com/tavplubix)) -- در حال حاضر یک استثنا خواهد شد در صورت استفاده از پرتاب `WITH TIES` در کنار `LIMIT BY`. همچنین توانایی استفاده را اضافه کنید `TOP` با `LIMIT BY`. این رفع [\#7472](https://github.com/ClickHouse/ClickHouse/issues/7472). [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- رفع unintendent وابستگی از تازه glibc نسخه در `clickhouse-odbc-bridge` دودویی. [\#8046](https://github.com/ClickHouse/ClickHouse/pull/8046) ([ایموس پرنده](https://github.com/amosbird)) -- رفع اشکال در بررسی عملکرد `*MergeTree` خانواده موتور. در حال حاضر در صورتی که زمانی که ما مقدار مساوی از ردیف در گرانول گذشته و علامت گذشته (غیر نهایی) شکست نیست. [\#8047](https://github.com/ClickHouse/ClickHouse/pull/8047) ([الساپین](https://github.com/alesapin)) -- رفع درج در `Enum*` ستون پس از `ALTER` پرس و جو, زمانی که زمینه ای نوع عددی به جدول نوع مشخص برابر است. این رفع [\#7836](https://github.com/ClickHouse/ClickHouse/issues/7836). [\#7908](https://github.com/ClickHouse/ClickHouse/pull/7908) ([انتون پوپوف](https://github.com/CurtizJ)) -- مجاز منفی غیر ثابت “size” استدلال برای عملکرد `substring`. این اشتباه مجاز نیست. این رفع [\#4832](https://github.com/ClickHouse/ClickHouse/issues/4832). [\#7703](https://github.com/ClickHouse/ClickHouse/pull/7703) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال تجزیه زمانی که تعداد اشتباه استدلال به تصویب رسید `(O|J)DBC` موتور جدول. [\#7709](https://github.com/ClickHouse/ClickHouse/pull/7709) ([الساپین](https://github.com/alesapin)) -- با استفاده از نام فرمان از روند در حال اجرا خانه کلیک در هنگام ارسال سیاهههای مربوط به سیسلوگ. در نسخه های قبلی, رشته خالی به جای نام فرمان مورد استفاده قرار گرفت. [\#8460](https://github.com/ClickHouse/ClickHouse/pull/8460) ([مایکل ناچاروف](https://github.com/mnach)) -- رفع چک میزبان مجاز برای `localhost`. این روابط عمومی رفع راه حل در [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241). [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع سقوط نادر در `argMin` و `argMax` توابع برای استدلال رشته طولانی, زمانی که نتیجه در استفاده `runningAccumulate` تابع. این رفع [\#8325](https://github.com/ClickHouse/ClickHouse/issues/8325) [\#8341](https://github.com/ClickHouse/ClickHouse/pull/8341) ([دایناسور](https://github.com/769344359)) -- رفع بیش از حد حافظه برای جداول با `Buffer` موتور [\#8345](https://github.com/ClickHouse/ClickHouse/pull/8345) ([ازات خوژین](https://github.com/azat)) -- اشکال بالقوه ثابت در توابع است که می تواند `NULL` به عنوان یکی از استدلال و بازگشت غیر تهی. [\#8196](https://github.com/ClickHouse/ClickHouse/pull/8196) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- معیارهای محاسبات بهتر در استخر موضوع برای فرایندهای پس زمینه برای `MergeTree` موتورهای جدول. [\#8194](https://github.com/ClickHouse/ClickHouse/pull/8194) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- تابع ثابت `IN` داخل `WHERE` بیانیه ای که در سطح ردیف فیلتر جدول وجود دارد. رفع [\#6687](https://github.com/ClickHouse/ClickHouse/issues/6687) [\#8357](https://github.com/ClickHouse/ClickHouse/pull/8357) ([ایوان](https://github.com/abyss7)) -- در حال حاضر یک استثنا پرتاب می شود اگر ارزش جدایی ناپذیر است به طور کامل برای مقادیر تنظیمات تجزیه نشده است. [\#7678](https://github.com/ClickHouse/ClickHouse/pull/7678) ([میخیل کوروتف](https://github.com/millb)) -- رفع استثنا زمانی که عملکرد دانه ها در پرس و جو به جدول توزیع شده با بیش از دو خرده ریز محلی استفاده می شود. [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- در حال حاضر فیلتر بلوم می توانید طول صفر عرایز رسیدگی می کند و محاسبات کار برکنار شده انجام نمی دهد. [\#8242](https://github.com/ClickHouse/ClickHouse/pull/8242) ([ایشیمب](https://github.com/achimbab)) -- چک کردن ثابت اگر یک میزبان مشتری با تطبیق میزبان مشتری به اجازه `host_regexp` مشخص شده در `users.xml`. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241) ([ویتالی بارانو](https://github.com/vitlibar)) -- استراحت چک ستون مبهم است که منجر به مثبت کاذب در چند `JOIN ON` بخش. [\#8385](https://github.com/ClickHouse/ClickHouse/pull/8385) ([زویکوف](https://github.com/4ertus2)) -- ثابت سقوط سرور ممکن است (`std::terminate`) هنگامی که سرور نمی تواند ارسال و یا نوشتن داده ها در `JSON` یا `XML` قالب با مقادیر `String` نوع داده (که نیاز به `UTF-8` اعتبار سنجی) و یا زمانی که فشرده سازی داده های نتیجه با الگوریتم برتلی و یا در برخی موارد نادر دیگر. این رفع [\#7603](https://github.com/ClickHouse/ClickHouse/issues/7603) [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع شرایط مسابقه در `StorageDistributedDirectoryMonitor` پیدا شده توسط سی. این رفع [\#8364](https://github.com/ClickHouse/ClickHouse/issues/8364). [\#8383](https://github.com/ClickHouse/ClickHouse/pull/8383) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- در حال حاضر پس زمینه ادغام در `*MergeTree` جدول موتورهای خانواده حفظ سیاست ذخیره سازی حجم سفارش دقیق تر است. [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- در حال حاضر موتور جدول `Kafka` به درستی کار می کند با `Native` قالب. این رفع [\#6731](https://github.com/ClickHouse/ClickHouse/issues/6731) [\#7337](https://github.com/ClickHouse/ClickHouse/issues/7337) [\#8003](https://github.com/ClickHouse/ClickHouse/issues/8003). [\#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([فیلیمونف](https://github.com/filimonov)) -- فرمت های ثابت با هدر (مانند `CSVWithNames`) که پرتاب شد استثنا در مورد ایف برای موتور جدول `Kafka`. [\#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([فیلیمونف](https://github.com/filimonov)) -- رفع اشکال با ساخت مجموعه ای از زیرخاکری در قسمت سمت راست از `IN` بخش. این رفع [\#5767](https://github.com/ClickHouse/ClickHouse/issues/5767) و [\#2542](https://github.com/ClickHouse/ClickHouse/issues/2542). [\#7755](https://github.com/ClickHouse/ClickHouse/pull/7755) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- رفع سقوط احتمالی در هنگام خواندن از ذخیره سازی `File`. [\#7756](https://github.com/ClickHouse/ClickHouse/pull/7756) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- خواندن ثابت از فایل ها در `Parquet` قالب حاوی ستونهای نوع `list`. [\#8334](https://github.com/ClickHouse/ClickHouse/pull/8334) ([مکسولان](https://github.com/maxulan)) -- رفع خطا `Not found column` برای نمایش داده شد توزیع با `PREWHERE` شرایط وابسته به کلید نمونه برداری اگر `max_parallel_replicas > 1`. [\#7913](https://github.com/ClickHouse/ClickHouse/pull/7913) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع خطا `Not found column` اگر پرسوجو استفاده شود `PREWHERE` وابسته به نام مستعار جدول و مجموعه نتیجه به دلیل شرایط کلیدی اولیه خالی بود. [\#7911](https://github.com/ClickHouse/ClickHouse/pull/7911) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- نوع بازگشت ثابت برای توابع `rand` و `randConstant` در صورت `Nullable` استدلال کردن. در حال حاضر توابع همیشه بازگشت `UInt32` و هرگز `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- پیش فرض غیر فعال فشار پایین برای `WITH FILL` اصطلاح. این رفع [\#7784](https://github.com/ClickHouse/ClickHouse/issues/7784). [\#7789](https://github.com/ClickHouse/ClickHouse/pull/7789) ([زمستان ژانگ](https://github.com/zhang2014)) -- نادرست ثابت `count()` نتیجه برای `SummingMergeTree` چه زمانی `FINAL` بخش استفاده شده است. [\#3280](https://github.com/ClickHouse/ClickHouse/issues/3280) [\#7786](https://github.com/ClickHouse/ClickHouse/pull/7786) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- رفع نتیجه نادرست ممکن است برای توابع ثابت از سرور از راه دور. این برای نمایش داده شد با توابع مانند اتفاق افتاد `version()`, `uptime()`, و غیره. که برمی گرداند مقادیر ثابت مختلف برای سرورهای مختلف. این رفع [\#7666](https://github.com/ClickHouse/ClickHouse/issues/7666). [\#7689](https://github.com/ClickHouse/ClickHouse/pull/7689) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع اشکال پیچیده در بهینه سازی پیش فرض فشار به پایین که منجر به نتایج اشتباه است. این مشکلات زیادی را در بهینه سازی پیش فرض پایین حل می کند. [\#8503](https://github.com/ClickHouse/ClickHouse/pull/8503) ([زمستان ژانگ](https://github.com/zhang2014)) -- رفع سقوط در `CREATE TABLE .. AS dictionary` پرس و جو. [\#8508](https://github.com/ClickHouse/ClickHouse/pull/8508) ([ازات خوژین](https://github.com/azat)) -- چند بهبود دستور زبان کلیک در `.g4` پرونده. [\#8294](https://github.com/ClickHouse/ClickHouse/pull/8294) ([taiyang-li](https://github.com/taiyang-li)) -- رفع اشکال که منجر به سقوط در `JOIN`با جداول با موتور `Join`. این رفع [\#7556](https://github.com/ClickHouse/ClickHouse/issues/7556) [\#8254](https://github.com/ClickHouse/ClickHouse/issues/8254) [\#7915](https://github.com/ClickHouse/ClickHouse/issues/7915) [\#8100](https://github.com/ClickHouse/ClickHouse/issues/8100). [\#8298](https://github.com/ClickHouse/ClickHouse/pull/8298) ([زویکوف](https://github.com/4ertus2)) -- رفع لغت نامه کار برکنار بارگذاری مجدد در `CREATE DATABASE`. [\#7916](https://github.com/ClickHouse/ClickHouse/pull/7916) ([ازات خوژین](https://github.com/azat)) -- محدود کردن حداکثر تعداد جریان برای خواندن از `StorageFile` و `StorageHDFS`. رفع https://github.com/ClickHouse/ClickHouse/issues/7650. [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([الساپین](https://github.com/alesapin)) -- رفع اشکال در `ALTER ... MODIFY ... CODEC` پرس و جو, زمانی که کاربر هر دو عبارت به طور پیش فرض و کدک را مشخص کنید. رفع [8593](https://github.com/ClickHouse/ClickHouse/issues/8593). [\#8614](https://github.com/ClickHouse/ClickHouse/pull/8614) ([الساپین](https://github.com/alesapin)) -- رفع خطا در ادغام پس زمینه ستون ها با `SimpleAggregateFunction(LowCardinality)` نوع. [\#8613](https://github.com/ClickHouse/ClickHouse/pull/8613) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- بررسی نوع ثابت در عملکرد `toDateTime64`. [\#8375](https://github.com/ClickHouse/ClickHouse/pull/8375) ([واسیلی نمکو](https://github.com/Enmk)) -- در حال حاضر سرور در سقوط نیست `LEFT` یا `FULL JOIN` با و پیوستن به موتور و پشتیبانی نشده `join_use_nulls` تنظیمات. [\#8479](https://github.com/ClickHouse/ClickHouse/pull/8479) ([زویکوف](https://github.com/4ertus2)) -- حالا `DROP DICTIONARY IF EXISTS db.dict` پرس و جو می کند و پرتاب استثنا اگر `db` وجود نداره [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([ویتالی بارانو](https://github.com/vitlibar)) -- رفع سقوط احتمالی در توابع جدول (`file`, `mysql`, `remote`) ناشی از استفاده از مرجع به حذف `IStorage` اعتراض. رفع تجزیه نادرست از ستون مشخص شده در درج به تابع جدول. [\#7762](https://github.com/ClickHouse/ClickHouse/pull/7762) ([تاولوبیکس](https://github.com/tavplubix)) -- اطمینان از شبکه قبل از شروع `clickhouse-server`. این رفع [\#7507](https://github.com/ClickHouse/ClickHouse/issues/7507). [\#8570](https://github.com/ClickHouse/ClickHouse/pull/8570) ([ژیچنگ یو](https://github.com/yuzhichang)) -- رفع وقفه دست زدن به برای اتصالات امن, بنابراین نمایش داده شد می کند بی تعریف قطع نمی. این رفع [\#8126](https://github.com/ClickHouse/ClickHouse/issues/8126). [\#8128](https://github.com/ClickHouse/ClickHouse/pull/8128) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `clickhouse-copier`مشاجره کار برکنار بین کارگران همزمان. [\#7816](https://github.com/ClickHouse/ClickHouse/pull/7816) ([هشدار داده می شود](https://github.com/dingxiangfei2009)) -- در حال حاضر جهش می کند قطعات متصل جست و خیز نیست, حتی اگر نسخه جهش خود را بزرگتر از نسخه جهش فعلی بود. [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([ژیچنگ یو](https://github.com/yuzhichang)) [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([الساپین](https://github.com/alesapin)) -- چشمپوشی از نسخههای برکنار شده `*MergeTree` قطعات داده ها پس از حرکت به یکی دیگر از دیسک و سرور راه اندازی مجدد. [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع سقوط در `FULL JOIN` با `LowCardinality` داخل `JOIN` کلیدی است. [\#8252](https://github.com/ClickHouse/ClickHouse/pull/8252) ([زویکوف](https://github.com/4ertus2)) -- ممنوع به استفاده از نام ستون بیش از یک بار در قرار دادن پرس و جو مانند `INSERT INTO tbl (x, y, x)`. این رفع [\#5465](https://github.com/ClickHouse/ClickHouse/issues/5465), [\#7681](https://github.com/ClickHouse/ClickHouse/issues/7681). [\#7685](https://github.com/ClickHouse/ClickHouse/pull/7685) ([الساپین](https://github.com/alesapin)) -- اضافه شدن مجدد برای تشخیص تعداد هسته های پردازنده فیزیکی برای پردازنده ناشناخته (با استفاده از تعدادی از هسته های پردازنده منطقی). این رفع [\#5239](https://github.com/ClickHouse/ClickHouse/issues/5239). [\#7726](https://github.com/ClickHouse/ClickHouse/pull/7726) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `There's no column` خطا برای مفردات و نام مستعار ستون. [\#8210](https://github.com/ClickHouse/ClickHouse/pull/8210) ([زویکوف](https://github.com/4ertus2)) -- تصادف شدید ثابت زمانی که `EXISTS` پرس و جو بدون استفاده شد `TABLE` یا `DICTIONARY` مقدماتی. درست مثل `EXISTS t`. این رفع [\#8172](https://github.com/ClickHouse/ClickHouse/issues/8172). این اشکال در نسخه 19.17 معرفی شد. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشکال نادر با خطا `"Sizes of columns doesn't match"` که ممکن است به نظر می رسد در هنگام استفاده از `SimpleAggregateFunction` ستون. [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([بوریس گرانویو](https://github.com/bgranvea)) -- رفع اشکال که کاربر با خالی است `allow_databases` دسترسی به تمام پایگاه های داده کردم (و همین کار را برای `allow_dictionaries`). [\#7793](https://github.com/ClickHouse/ClickHouse/pull/7793) ([دوفایت](https://github.com/DeifyTheGod)) -- رفع سقوط مشتری زمانی که سرور در حال حاضر از مشتری قطع شده است. [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([ازات خوژین](https://github.com/azat)) -- ثابت `ORDER BY` رفتار در صورت مرتب سازی بر اساس پیشوند کلید اولیه و پسوند کلید غیر اولیه. [\#7759](https://github.com/ClickHouse/ClickHouse/pull/7759) ([انتون پوپوف](https://github.com/CurtizJ)) -- بررسی کنید که در حال حاضر ستون واجد شرایط در جدول. این رفع [\#6836](https://github.com/ClickHouse/ClickHouse/issues/6836). [\#7758](https://github.com/ClickHouse/ClickHouse/pull/7758) ([زویکوف](https://github.com/4ertus2)) -- رفتار ثابت با `ALTER MOVE` فرار بلافاصله پس از ادغام پایان حرکت سوپر شروع مشخص شده است. رفع [\#8103](https://github.com/ClickHouse/ClickHouse/issues/8103). [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع سقوط سرور ممکن است در حالی که با استفاده از `UNION` با شماره های مختلف ستون. رفع [\#7279](https://github.com/ClickHouse/ClickHouse/issues/7279). [\#7929](https://github.com/ClickHouse/ClickHouse/pull/7929) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع اندازه زیر رشته نتیجه برای عملکرد `substr` با اندازه منفی. [\#8589](https://github.com/ClickHouse/ClickHouse/pull/8589) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- در حال حاضر سرور جهش بخشی در اجرا نیست `MergeTree` اگر موضوعات رایگان به اندازه کافی در استخر پس زمینه وجود ندارد. [\#8588](https://github.com/ClickHouse/ClickHouse/pull/8588) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع خطای تایپی کوچک در قالب بندی `UNION ALL` AST. [\#7999](https://github.com/ClickHouse/ClickHouse/pull/7999) ([لیتا91](https://github.com/litao91)) -- ثابت نتایج فیلتر شکوفه نادرست برای اعداد منفی. این رفع [\#8317](https://github.com/ClickHouse/ClickHouse/issues/8317). [\#8566](https://github.com/ClickHouse/ClickHouse/pull/8566) ([زمستان ژانگ](https://github.com/zhang2014)) -- سرریز بافر بالقوه ثابت در حالت فشرده خارج. کاربر مخرب می تواند داده های فشرده ساخته شده است که باعث می شود پس از بافر به عنوان خوانده شده منتقل می کند. این موضوع توسط الدار زیتوف از تیم امنیت اطلاعات یاندکس یافت شد. [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع نتیجه نادرست به دلیل سرریز اعداد صحیح در `arrayIntersect`. [\#7777](https://github.com/ClickHouse/ClickHouse/pull/7777) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- حالا `OPTIMIZE TABLE` پرس و جو نمی خواهد برای کپی نیست منتظر به انجام عملیات. [\#8314](https://github.com/ClickHouse/ClickHouse/pull/8314) ([جوی سانتانا](https://github.com/javisantana)) -- ثابت `ALTER TTL` تجزیه کننده برای `Replicated*MergeTree` میز [\#8318](https://github.com/ClickHouse/ClickHouse/pull/8318) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع ارتباط بین سرور و کلاینت, بنابراین سرور خواندن اطلاعات جداول موقت پس از شکست پرس و جو. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([ازات خوژین](https://github.com/azat)) -- ثابت `bitmapAnd` خطای تابع هنگام تقاطع کردن بیت مپ جمع و بیت مپ اسکالر. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([یو هوانگ](https://github.com/moon03432)) -- اصلاح تعریف `ZXid` با توجه به راهنمای برنامه نویس باغ وحش که رفع اشکال در `clickhouse-cluster-copier`. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([هشدار داده می شود](https://github.com/dingxiangfei2009)) -- `odbc` تابع جدول در حال حاضر احترام می گذارد `external_table_functions_use_nulls` تنظیمات. [\#7506](https://github.com/ClickHouse/ClickHouse/pull/7506) ([واسیلی نمکو](https://github.com/Enmk)) -- اشکال ثابت که منجر به یک مسابقه داده نادر است. [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([الکساندر کازاکوف](https://github.com/Akazz)) -- حالا `SYSTEM RELOAD DICTIONARY` بارگذاری مجدد یک فرهنگ لغت به طور کامل, نادیده گرفتن `update_field`. این رفع [\#7440](https://github.com/ClickHouse/ClickHouse/issues/7440). [\#8037](https://github.com/ClickHouse/ClickHouse/pull/8037) ([ویتالی بارانو](https://github.com/vitlibar)) -- اضافه کردن توانایی برای بررسی اگر فرهنگ لغت در ایجاد پرس و جو وجود دارد. [\#8032](https://github.com/ClickHouse/ClickHouse/pull/8032) ([الساپین](https://github.com/alesapin)) -- ثابت `Float*` تجزیه در `Values` قالب. این رفع [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817). [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([تاولوبیکس](https://github.com/tavplubix)) -- رفع سقوط زمانی که ما نمی توانیم فضای ذخیره در برخی از عملیات پس زمینه از `*MergeTree` موتورهای جدول خانواده. [\#7873](https://github.com/ClickHouse/ClickHouse/pull/7873) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- رفع سقوط عملیات ادغام زمانی که جدول شامل `SimpleAggregateFunction(LowCardinality)` ستون. این رفع [\#8515](https://github.com/ClickHouse/ClickHouse/issues/8515). [\#8522](https://github.com/ClickHouse/ClickHouse/pull/8522) ([ازات خوژین](https://github.com/azat)) -- بازگرداندن پشتیبانی از تمام مناطق فناوری اطلاعات و ارتباطات و اضافه کردن توانایی به درخواست تلفیقی برای عبارات ثابت. همچنین نام زبان را اضافه کنید `system.collations` جدول [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([الساپین](https://github.com/alesapin)) -- رفع اشکال در هنگام خارجی لغت نامه صفر و حداقل طول عمر (`LIFETIME(MIN 0 MAX N)`, `LIFETIME(N)`) در پس زمینه به روز رسانی نیست . [\#7983](https://github.com/ClickHouse/ClickHouse/pull/7983) ([الساپین](https://github.com/alesapin)) -- رفع تصادف در هنگام فرهنگ لغت خارجی با منبع کلیک است زیرخاکی در پرس و جو. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- رفع نادرست تجزیه پسوند فایل در جدول با موتور `URL`. این رفع [\#8157](https://github.com/ClickHouse/ClickHouse/issues/8157). [\#8419](https://github.com/ClickHouse/ClickHouse/pull/8419) ([هشدار داده می شود](https://github.com/apbodrov)) -- ثابت `CHECK TABLE` پرسوجو برای `*MergeTree` جداول بدون کلید. رفع [\#7543](https://github.com/ClickHouse/ClickHouse/issues/7543). [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([الساپین](https://github.com/alesapin)) -- تبدیل ثابت از `Float64` به نوع خروجی زیر. [\#8079](https://github.com/ClickHouse/ClickHouse/pull/8079) ([یوری بارانوف](https://github.com/yurriy)) -- در حال حاضر اگر جدول به طور کامل به دلیل سقوط سرور کاهش یافته است, سرور سعی خواهد کرد برای بازگرداندن و بارگذاری. [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([تاولوبیکس](https://github.com/tavplubix)) -- تصادف ثابت در عملکرد جدول `file` در حالی که قرار دادن به فایل که وجود ندارد. در حال حاضر در این مورد فایل ایجاد می شود و سپس قرار دادن پردازش می شود. [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- رفع بن بست نادر است که می تواند زمانی اتفاق می افتد `trace_log` در را فعال کنید. [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([فیلیمونف](https://github.com/filimonov)) -- اضافه کردن توانایی برای کار با انواع مختلف علاوه بر `Date` داخل `RangeHashed` فرهنگ لغت خارجی ایجاد شده از پرس و جو دی ال. رفع [7899](https://github.com/ClickHouse/ClickHouse/issues/7899). [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([الساپین](https://github.com/alesapin)) -- رفع سقوط زمانی که `now64()` با نتیجه تابع دیگری نامیده می شود. [\#8270](https://github.com/ClickHouse/ClickHouse/pull/8270) ([واسیلی نمکو](https://github.com/Enmk)) -- اشکال ثابت با تشخیص قانون مجازات اسلامی مشتری برای اتصال به شبکه از طریق پروتکل سیم خروجی زیر. [\#7743](https://github.com/ClickHouse/ClickHouse/pull/7743) ([دیمیتری موزیکا](https://github.com/dmitriy-myz)) -- رفع دست زدن به مجموعه خالی در `arraySplit` تابع. این رفع [\#7708](https://github.com/ClickHouse/ClickHouse/issues/7708). [\#7747](https://github.com/ClickHouse/ClickHouse/pull/7747) ([هکز](https://github.com/hczhcz)) -- ثابت موضوع زمانی که `pid-file` از یکی دیگر از در حال اجرا `clickhouse-server` ممکن است حذف شود. [\#8487](https://github.com/ClickHouse/ClickHouse/pull/8487) ([Weiqing زو](https://github.com/weiqxu)) -- رفع بارگذاری مجدد فرهنگ لغت در صورتی که `invalidate_query` که متوقف به روز رسانی و برخی از استثنا در به روز رسانی قبلی تلاش می کند. [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([الساپین](https://github.com/alesapin)) -- ثابت خطا در تابع `arrayReduce` که ممکن است منجر به “double free” و خطا در ترکیب تابع کل `Resample` که ممکن است به نشت حافظه منجر شود. اضافه شدن تابع جمع `aggThrow`. این تابع را می توان برای اهداف تست استفاده کرد. [\#8446](https://github.com/ClickHouse/ClickHouse/pull/8446) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود {#improvement-1} - -- ورود به سیستم بهبود یافته در هنگام کار با `S3` موتور جدول. [\#8251](https://github.com/ClickHouse/ClickHouse/pull/8251) ([گریگوری پرواکوف](https://github.com/GrigoryPervakov)) -- پیام راهنما چاپ شده زمانی که هیچ استدلال در هنگام تماس گذشت `clickhouse-local`. این رفع [\#5335](https://github.com/ClickHouse/ClickHouse/issues/5335). [\#8230](https://github.com/ClickHouse/ClickHouse/pull/8230) ([هشدار داده می شود](https://github.com/Melancholic)) -- افزودن تنظیمات `mutations_sync` که اجازه می دهد تا صبر کنید `ALTER UPDATE/DELETE` نمایش داده شد همزمان. [\#8237](https://github.com/ClickHouse/ClickHouse/pull/8237) ([الساپین](https://github.com/alesapin)) -- اجازه برای راه اندازی نسبی `user_files_path` داخل `config.xml` (در راه شبیه به `format_schema_path`). [\#7632](https://github.com/ClickHouse/ClickHouse/pull/7632) ([هکز](https://github.com/hczhcz)) -- اضافه کردن استثنا برای انواع غیر قانونی برای توابع تبدیل با `-OrZero` پسوند. [\#7880](https://github.com/ClickHouse/ClickHouse/pull/7880) ([اندری کونیایف](https://github.com/akonyaev90)) -- ساده فرمت هدر داده ارسال به سفال در پرس و جو توزیع شده است. [\#8044](https://github.com/ClickHouse/ClickHouse/pull/8044) ([ویتالی بارانو](https://github.com/vitlibar)) -- `Live View` تعمیر مجدد موتور جدول. [\#8519](https://github.com/ClickHouse/ClickHouse/pull/8519) ([vzakaznikov](https://github.com/vzakaznikov)) -- اضافه کردن چک های اضافی برای لغت نامه های خارجی ایجاد شده از دی ال نمایش داده شد. [\#8127](https://github.com/ClickHouse/ClickHouse/pull/8127) ([الساپین](https://github.com/alesapin)) -- رفع خطا `Column ... already exists` در حالی که با استفاده از `FINAL` و `SAMPLE` together, e.g. `select count() from table final sample 1/2`. رفع [\#5186](https://github.com/ClickHouse/ClickHouse/issues/5186). [\#7907](https://github.com/ClickHouse/ClickHouse/pull/7907) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- در حال حاضر جدول استدلال اول `joinGet` تابع می تواند جدول شناسایی. [\#7707](https://github.com/ClickHouse/ClickHouse/pull/7707) ([ایموس پرنده](https://github.com/amosbird)) -- اجازه استفاده `MaterializedView` با subqueries بالا `Kafka` میز [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([فیلیمونف](https://github.com/filimonov)) -- در حال حاضر پس زمینه بین دیسک ها حرکت می کند استخر تار شده را اجرا می کند. [\#7670](https://github.com/ClickHouse/ClickHouse/pull/7670) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- `SYSTEM RELOAD DICTIONARY` در حال حاضر اجرا همزمان. [\#8240](https://github.com/ClickHouse/ClickHouse/pull/8240) ([ویتالی بارانو](https://github.com/vitlibar)) -- ردیابی پشته در حال حاضر نمایش نشانی های فیزیکی (شیپور خاموشی در فایل شی) به جای نشانی های حافظه مجازی (جایی که فایل شی لود شد). که اجازه می دهد تا استفاده از `addr2line` هنگامی که باینری موقعیت مستقل است و اصل فعال است. این رفع [\#8360](https://github.com/ClickHouse/ClickHouse/issues/8360). [\#8387](https://github.com/ClickHouse/ClickHouse/pull/8387) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- پشتیبانی از نحو جدید برای فیلترهای امنیتی سطح ردیف: `
`. رفع [\#5779](https://github.com/ClickHouse/ClickHouse/issues/5779). [\#8381](https://github.com/ClickHouse/ClickHouse/pull/8381) ([ایوان](https://github.com/abyss7)) -- حالا `cityHash` تابع می تواند با کار `Decimal` و `UUID` انواع. رفع [\#5184](https://github.com/ClickHouse/ClickHouse/issues/5184). [\#7693](https://github.com/ClickHouse/ClickHouse/pull/7693) ([میخیل کوروتف](https://github.com/millb)) -- دانه دانه دانه دانه ثابت حذف (1024 بود) از سیاهههای مربوط به سیستم به دلیل منسوخ پس از اجرای دانه دانه تطبیقی. [\#7698](https://github.com/ClickHouse/ClickHouse/pull/7698) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- فعال خروجی زیر سرور سازگاری زمانی که تاتر بدون اس اس ال وارد شده است. [\#7852](https://github.com/ClickHouse/ClickHouse/pull/7852) ([یوری بارانوف](https://github.com/yurriy)) -- در حال حاضر چک سرور دسته توزیع, می دهد که خطاهای طولانی تر در مورد داده های خراب شده در دسته ای. [\#7914](https://github.com/ClickHouse/ClickHouse/pull/7914) ([ازات خوژین](https://github.com/azat)) -- پشتیبانی `DROP DATABASE`, `DETACH TABLE`, `DROP TABLE` و `ATTACH TABLE` برای `MySQL` موتور پایگاه داده. [\#8202](https://github.com/ClickHouse/ClickHouse/pull/8202) ([زمستان ژانگ](https://github.com/zhang2014)) -- اضافه کردن احراز هویت در اس 3 تابع جدول و موتور جدول. [\#7623](https://github.com/ClickHouse/ClickHouse/pull/7623) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اضافه شدن چک برای قطعات اضافی از `MergeTree` در دیسک های مختلف, به منظور اجازه نمی دهد به دست قطعات داده در دیسک تعریف نشده. [\#8118](https://github.com/ClickHouse/ClickHouse/pull/8118) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- فعال کردن پشتیبانی اس اس ال برای مشتری مک و سرور. [\#8297](https://github.com/ClickHouse/ClickHouse/pull/8297) ([ایوان](https://github.com/abyss7)) -- در حال حاضر clickhouse کار می تواند به عنوان خروجی يکپارچه سرور (دیدن https://dev.mysql.com/doc/refman/5.7/en/federated-create-server.html). [\#7717](https://github.com/ClickHouse/ClickHouse/pull/7717) ([ماکسیم فدوتف](https://github.com/MaxFedotov)) -- `clickhouse-client` در حال حاضر تنها فعال `bracketed-paste` هنگامی که چند ضلعی روشن است و چند خطی خاموش است. این رفع (\#7757) \[https://github.com/ClickHouse/ClickHouse/issues/7757\]. [\#7761](https://github.com/ClickHouse/ClickHouse/pull/7761) ([ایموس پرنده](https://github.com/amosbird)) -- پشتیبانی `Array(Decimal)` داخل `if` تابع. [\#7721](https://github.com/ClickHouse/ClickHouse/pull/7721) ([زویکوف](https://github.com/4ertus2)) -- اعشار پشتیبانی در `arrayDifference`, `arrayCumSum` و `arrayCumSumNegative` توابع. [\#7724](https://github.com/ClickHouse/ClickHouse/pull/7724) ([زویکوف](https://github.com/4ertus2)) -- اضافه شده `lifetime` ستون به `system.dictionaries` جدول [\#6820](https://github.com/ClickHouse/ClickHouse/issues/6820) [\#7727](https://github.com/ClickHouse/ClickHouse/pull/7727) ([کیککول](https://github.com/kekekekule)) -- بررسی بهبود یافته برای قطعات موجود بر روی دیسک های مختلف برای `*MergeTree` موتورهای جدول. نشانیهای [\#7660](https://github.com/ClickHouse/ClickHouse/issues/7660). [\#8440](https://github.com/ClickHouse/ClickHouse/pull/8440) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- ادغام با `AWS SDK` برای `S3` فعل و انفعالات که اجازه می دهد تا به استفاده از تمام 3 ویژگی های خارج از جعبه. [\#8011](https://github.com/ClickHouse/ClickHouse/pull/8011) ([پاول کووالنکو](https://github.com/Jokser)) -- اضافه شدن پشتیبانی برای کارخانه های فرعی در `Live View` میز [\#7792](https://github.com/ClickHouse/ClickHouse/pull/7792) ([vzakaznikov](https://github.com/vzakaznikov)) -- بررسی برای استفاده از `Date` یا `DateTime` ستون از `TTL` عبارات حذف شد. [\#7920](https://github.com/ClickHouse/ClickHouse/pull/7920) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- اطلاعات در مورد دیسک به اضافه شد `system.detached_parts` جدول [\#7833](https://github.com/ClickHouse/ClickHouse/pull/7833) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- در حال حاضر تنظیمات `max_(table|partition)_size_to_drop` را می توان بدون راه اندازی مجدد تغییر کرده است. [\#7779](https://github.com/ClickHouse/ClickHouse/pull/7779) ([گریگوری پرواکوف](https://github.com/GrigoryPervakov)) -- قابلیت استفاده کمی بهتر از پیام های خطا. از کاربر بخواهید که خطوط زیر را حذف کند `Stack trace:`. [\#7897](https://github.com/ClickHouse/ClickHouse/pull/7897) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- خواندن بهتر پیام ها از `Kafka` موتور در فرمت های مختلف پس از [\#7935](https://github.com/ClickHouse/ClickHouse/issues/7935). [\#8035](https://github.com/ClickHouse/ClickHouse/pull/8035) ([ایوان](https://github.com/abyss7)) -- سازگاری بهتر با مشتریان خروجی زیر که پشتیبانی نمی کند `sha2_password` auth پلاگین. [\#8036](https://github.com/ClickHouse/ClickHouse/pull/8036) ([یوری baranov](https://github.com/yurriy)) -- پشتیبانی از انواع ستون بیشتر در خروجی زیر سرور سازگاری. [\#7975](https://github.com/ClickHouse/ClickHouse/pull/7975) ([یوری baranov](https://github.com/yurriy)) -- پیاده سازی `ORDER BY` بهینه سازی برای `Merge`, `Buffer` و `Materilized View` ذخیره سازی با زمینه `MergeTree` میز [\#8130](https://github.com/ClickHouse/ClickHouse/pull/8130) ([انتون پوپوف](https://github.com/CurtizJ)) -- در حال حاضر ما همیشه اجرای پسوند استفاده از `getrandom` برای سازگاری بهتر با دانه های قدیمی (\<3.17). [\#7940](https://github.com/ClickHouse/ClickHouse/pull/7940) ([ایموس پرنده](https://github.com/amosbird)) -- بررسی بهتر برای مقصد معتبر در یک قانون حرکت تغییر جنسیت. [\#8410](https://github.com/ClickHouse/ClickHouse/pull/8410) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- چک بهتر برای دسته درج شکسته برای `Distributed` موتور جدول. [\#7933](https://github.com/ClickHouse/ClickHouse/pull/7933) ([ازات خوژین](https://github.com/azat)) -- اضافه کردن ستون با مجموعه ای از نام قطعات که جهش باید در اینده پردازش به `system.mutations` جدول [\#8179](https://github.com/ClickHouse/ClickHouse/pull/8179) ([الساپین](https://github.com/alesapin)) -- موازی با مرتب کردن بر اساس ادغام بهینه سازی برای پردازنده. [\#8552](https://github.com/ClickHouse/ClickHouse/pull/8552) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- تنظیمات `mark_cache_min_lifetime` در حال حاضر منسوخ و هیچ کاری نمی کند. در نسخه های قبلی, علامت گذاری به عنوان کش می تواند در حافظه بزرگتر از رشد `mark_cache_size` به جای داده ها در `mark_cache_min_lifetime` چند ثانیه که منجر به سردرگمی و استفاده از حافظه بالاتر از حد انتظار است که به خصوص بد در حافظه محدود سیستم. اگر شما تخریب عملکرد پس از نصب این نسخه را ببینید, شما باید افزایش `mark_cache_size`. [\#8484](https://github.com/ClickHouse/ClickHouse/pull/8484) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- طرز تهیه برای استفاده `tid` همه جا این برای مورد نیاز است [\#7477](https://github.com/ClickHouse/ClickHouse/issues/7477). [\#8276](https://github.com/ClickHouse/ClickHouse/pull/8276) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -#### بهبود عملکرد {#performance-improvement-1} - -- بهینه سازی عملکرد در خط لوله پردازنده. [\#7988](https://github.com/ClickHouse/ClickHouse/pull/7988) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- به روز رسانی غیر مسدود کردن کلید منقضی شده در لغت نامه کش (با اجازه خواندن قدیمی). [\#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- کامپایل تاتر بدون `-fno-omit-frame-pointer` در سطح جهانی به فراغت یک ثبت نام بیشتر. [\#8097](https://github.com/ClickHouse/ClickHouse/pull/8097) ([ایموس پرنده](https://github.com/amosbird)) -- افزایش سرعت `greatCircleDistance` عملکرد و تست عملکرد را اضافه کنید. [\#7307](https://github.com/ClickHouse/ClickHouse/pull/7307) ([اولگا خوستیکوا](https://github.com/stavrolia)) -- بهبود عملکرد عملکرد `roundDown`. [\#8465](https://github.com/ClickHouse/ClickHouse/pull/8465) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهبود عملکرد `max`, `min`, `argMin`, `argMax` برای `DateTime64` نوع داده. [\#8199](https://github.com/ClickHouse/ClickHouse/pull/8199) ([واسیلی نمکو](https://github.com/Enmk)) -- بهبود عملکرد مرتب سازی بدون محدودیت و یا با حد بزرگ و مرتب سازی خارجی. [\#8545](https://github.com/ClickHouse/ClickHouse/pull/8545) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهبود عملکرد قالب بندی اعداد ممیز شناور تا 6 بار. [\#8542](https://github.com/ClickHouse/ClickHouse/pull/8542) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهبود عملکرد `modulo` تابع. [\#7750](https://github.com/ClickHouse/ClickHouse/pull/7750) ([ایموس پرنده](https://github.com/amosbird)) -- بهینهسازی شده `ORDER BY` و ادغام با کلید ستون. [\#8335](https://github.com/ClickHouse/ClickHouse/pull/8335) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجرای بهتر برای `arrayReduce`, `-Array` و `-State` ترکیب کننده ها [\#7710](https://github.com/ClickHouse/ClickHouse/pull/7710) ([ایموس پرنده](https://github.com/amosbird)) -- حالا `PREWHERE` باید بهینه سازی شود حداقل به عنوان موثر به عنوان `WHERE`. [\#7769](https://github.com/ClickHouse/ClickHouse/pull/7769) ([ایموس پرنده](https://github.com/amosbird)) -- بهبود راه `round` و `roundBankers` دست زدن به اعداد منفی. [\#8229](https://github.com/ClickHouse/ClickHouse/pull/8229) ([هکز](https://github.com/hczhcz)) -- رمزگشایی بهبود عملکرد `DoubleDelta` و `Gorilla` کدک های تقریبا 30-40%. این رفع [\#7082](https://github.com/ClickHouse/ClickHouse/issues/7082). [\#8019](https://github.com/ClickHouse/ClickHouse/pull/8019) ([واسیلی نمکو](https://github.com/Enmk)) -- بهبود عملکرد `base64` توابع مرتبط. [\#8444](https://github.com/ClickHouse/ClickHouse/pull/8444) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه شدن یک تابع `geoDistance`. این شبیه به `greatCircleDistance` اما با استفاده از تقریب به دندان-84 مدل بیضی. عملکرد هر دو توابع در نزدیکی یکسان هستند. [\#8086](https://github.com/ClickHouse/ClickHouse/pull/8086) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- سریع تر `min` و `max` توابع تجمع برای `Decimal` نوع داده. [\#8144](https://github.com/ClickHouse/ClickHouse/pull/8144) ([زویکوف](https://github.com/4ertus2)) -- Vectorize پردازش `arrayReduce`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([ایموس پرنده](https://github.com/amosbird)) -- `if` زنجیر در حال حاضر به عنوان بهینه سازی شده `multiIf`. [\#8355](https://github.com/ClickHouse/ClickHouse/pull/8355) ([کمالف روسلان](https://github.com/kamalov-ruslan)) -- رفع رگرسیون عملکرد `Kafka` موتور جدول معرفی شده در 19.15. این رفع [\#7261](https://github.com/ClickHouse/ClickHouse/issues/7261). [\#7935](https://github.com/ClickHouse/ClickHouse/pull/7935) ([فیلیمونف](https://github.com/filimonov)) -- حذف شد “pie” تولید کد که `gcc` از بسته های دبیان گاهی اوقات به طور پیش فرض به ارمغان بیاورد. [\#8483](https://github.com/ClickHouse/ClickHouse/pull/8483) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- موازی تجزیه فرمت های داده [\#6553](https://github.com/ClickHouse/ClickHouse/pull/6553) ([نیکیتا میخایلو](https://github.com/nikitamikhaylov)) -- به کار انداختن تجزیه کننده بهینه `Values` با عبارات به طور پیش فرض (`input_format_values_deduce_templates_of_expressions=1`). [\#8231](https://github.com/ClickHouse/ClickHouse/pull/8231) ([تاولوبیکس](https://github.com/tavplubix)) - -#### ساخت/تست / بهبود بسته بندی {#buildtestingpackaging-improvement-2} - -- ساخت رفع برای `ARM` و در حالت حداقل. [\#8304](https://github.com/ClickHouse/ClickHouse/pull/8304) ([پرولر](https://github.com/proller)) -- اضافه کردن پوشش خیط و پیت کردن فایل برای `clickhouse-server` وقتی بیماری مقاربتی:: اختلال نامیده می شود نیست. همچنین کمی بهبود یافته ورود به سیستم در تست بدون تابعیت با پوشش. [\#8267](https://github.com/ClickHouse/ClickHouse/pull/8267) ([الساپین](https://github.com/alesapin)) -- به روز رسانی llvm کتابخانه در contrib. اجتناب از استفاده از llvm از سیستم عامل بسته است. [\#8258](https://github.com/ClickHouse/ClickHouse/pull/8258) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- را همراه `curl` ساخت کاملا ساکت. [\#8232](https://github.com/ClickHouse/ClickHouse/pull/8232) [\#8203](https://github.com/ClickHouse/ClickHouse/pull/8203) ([پاول کووالنکو](https://github.com/Jokser)) -- رفع برخی از `MemorySanitizer` اخطار. [\#8235](https://github.com/ClickHouse/ClickHouse/pull/8235) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- استفاده `add_warning` و `no_warning` ماکروها در `CMakeLists.txt`. [\#8604](https://github.com/ClickHouse/ClickHouse/pull/8604) ([ایوان](https://github.com/abyss7)) -- اضافه کردن پشتیبانی از minio s3 سازگار شی (https://min.io/) برای ادغام بهتر شد. [\#7863](https://github.com/ClickHouse/ClickHouse/pull/7863) [\#7875](https://github.com/ClickHouse/ClickHouse/pull/7875) ([پاول کووالنکو](https://github.com/Jokser)) -- وارد شده `libc` سرصفحهها به کنترب. این اجازه می دهد تا به ایجاد بیشتر سازگار در سراسر سیستم های مختلف (فقط برای `x86_64-linux-gnu`). [\#5773](https://github.com/ClickHouse/ClickHouse/pull/5773) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حذف `-fPIC` از برخی از کتابخانه ها. [\#8464](https://github.com/ClickHouse/ClickHouse/pull/8464) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تمیز `CMakeLists.txt` برای حلقه. ببینید https://github.com/ClickHouse/ClickHouse/pull/8011\#issuecomment-569478910 [\#8459](https://github.com/ClickHouse/ClickHouse/pull/8459) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- هشدار خاموش در `CapNProto` کتابخونه. [\#8220](https://github.com/ClickHouse/ClickHouse/pull/8220) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اضافه کردن تست عملکرد برای رشته کوتاه بهینه سازی جداول هش. [\#7679](https://github.com/ClickHouse/ClickHouse/pull/7679) ([ایموس پرنده](https://github.com/amosbird)) -- در حال حاضر خانه کلیک بر روی ساخت `AArch64` حتی اگر `MADV_FREE` در دسترس نیست. این رفع [\#8027](https://github.com/ClickHouse/ClickHouse/issues/8027). [\#8243](https://github.com/ClickHouse/ClickHouse/pull/8243) ([ایموس پرنده](https://github.com/amosbird)) -- بهروزرسانی `zlib-ng` برای رفع مشکلات ضدعفونی کننده حافظه. [\#7182](https://github.com/ClickHouse/ClickHouse/pull/7182) [\#8206](https://github.com/ClickHouse/ClickHouse/pull/8206) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- فعال کردن کتابخانه خروجی زیر داخلی در سیستم غیر لینوکس, به دلیل استفاده از بسته های سیستم عامل بسیار شکننده است و معمولا در همه کار نمی کند. این رفع [\#5765](https://github.com/ClickHouse/ClickHouse/issues/5765). [\#8426](https://github.com/ClickHouse/ClickHouse/pull/8426) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ساخت ثابت در برخی از سیستم های پس از فعال کردن `libc++`. این جانشین [\#8374](https://github.com/ClickHouse/ClickHouse/issues/8374). [\#8380](https://github.com/ClickHouse/ClickHouse/pull/8380) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ساخت `Field` مواد و روش ها نوع بیشتر-امن برای پیدا کردن خطاهای بیشتر. [\#7386](https://github.com/ClickHouse/ClickHouse/pull/7386) [\#8209](https://github.com/ClickHouse/ClickHouse/pull/8209) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- اضافه شده فایل های از دست رفته به `libc-headers` submodule. [\#8507](https://github.com/ClickHouse/ClickHouse/pull/8507) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع اشتباه `JSON` نقل قول در خروجی تست عملکرد. [\#8497](https://github.com/ClickHouse/ClickHouse/pull/8497) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- در حال حاضر ردیابی پشته برای نمایش داده می شود `std::exception` و `Poco::Exception`. در نسخه های قبلی فقط برای `DB::Exception`. این باعث بهبود تشخیص می شود. [\#8501](https://github.com/ClickHouse/ClickHouse/pull/8501) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بارینگ `clock_gettime` و `clock_nanosleep` برای نسخه های چرب زبان تازه. [\#8054](https://github.com/ClickHouse/ClickHouse/pull/8054) ([ایموس پرنده](https://github.com/amosbird)) -- فعالسازی `part_log` در مثال پیکربندی برای توسعه دهندگان. [\#8609](https://github.com/ClickHouse/ClickHouse/pull/8609) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- رفع ماهیت کالاهای کابل از بازنگری در `01036_no_superfluous_dict_reload_on_create_database*`. [\#8111](https://github.com/ClickHouse/ClickHouse/pull/8111) ([ازات خوژین](https://github.com/azat)) -- تست عملکرد کدک ثابت. [\#8615](https://github.com/ClickHouse/ClickHouse/pull/8615) ([واسیلی نمکو](https://github.com/Enmk)) -- اضافه کردن اسکریپت نصب برای `.tgz` ساخت و اسناد و مدارک برای خود. [\#8612](https://github.com/ClickHouse/ClickHouse/pull/8612) [\#8591](https://github.com/ClickHouse/ClickHouse/pull/8591) ([الساپین](https://github.com/alesapin)) -- حذف قدیمی `ZSTD` تست (این در سال 2016 ایجاد شد به تکثیر اشکال که قبل از 1.0 نسخه از زد تا به حال). این رفع [\#8618](https://github.com/ClickHouse/ClickHouse/issues/8618). [\#8619](https://github.com/ClickHouse/ClickHouse/pull/8619) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ساخت ثابت در سیستم عامل مک کاتالینا. [\#8600](https://github.com/ClickHouse/ClickHouse/pull/8600) ([مو](https://github.com/meob)) -- افزایش تعداد ردیف در تست عملکرد کدک برای ایجاد نتایج قابل توجه است. [\#8574](https://github.com/ClickHouse/ClickHouse/pull/8574) ([واسیلی نمکو](https://github.com/Enmk)) -- در اشکال زدایی ایجاد, درمان `LOGICAL_ERROR` استثنا به عنوان شکست ادعای, به طوری که راحت تر به اطلاع. [\#8475](https://github.com/ClickHouse/ClickHouse/pull/8475) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- تست عملکرد مربوط به فرمت را قطعی تر کنید. [\#8477](https://github.com/ClickHouse/ClickHouse/pull/8477) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- بهروزرسانی `lz4` برای رفع یک شکست حفظ کننده. [\#8181](https://github.com/ClickHouse/ClickHouse/pull/8181) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- سرکوب یک یادداشت شناخته شده مثبت کاذب در دست زدن به استثنا. [\#8182](https://github.com/ClickHouse/ClickHouse/pull/8182) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- بهروزرسانی `gcc` و `g++` به نسخه 9 در `build/docker/build.sh` [\#7766](https://github.com/ClickHouse/ClickHouse/pull/7766) ([تلیتسکی](https://github.com/tlightsky)) -- اضافه کردن مورد تست عملکرد برای تست که `PREWHERE` بدتر از `WHERE`. [\#7768](https://github.com/ClickHouse/ClickHouse/pull/7768) ([ایموس پرنده](https://github.com/amosbird)) -- پیشرفت به سمت رفع یک تست فلکی. [\#8621](https://github.com/ClickHouse/ClickHouse/pull/8621) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- اجتناب از گزارش یادداشت برای داده ها از `libunwind`. [\#8539](https://github.com/ClickHouse/ClickHouse/pull/8539) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- به روز شده `libc++` به جدیدترین نسخه. [\#8324](https://github.com/ClickHouse/ClickHouse/pull/8324) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ساخت کتابخانه ایکو از منابع. این رفع [\#6460](https://github.com/ClickHouse/ClickHouse/issues/6460). [\#8219](https://github.com/ClickHouse/ClickHouse/pull/8219) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تغییر از `libressl` به `openssl`. ClickHouse باید پشتیبانی از TLS 1.3 و SNI پس از این تغییر. این رفع [\#8171](https://github.com/ClickHouse/ClickHouse/issues/8171). [\#8218](https://github.com/ClickHouse/ClickHouse/pull/8218) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- گزارش ثابت اوبسان هنگام استفاده `chacha20_poly1305` از اس اس ال (اتفاق می افتد در اتصال به https://yandex.ru/). [\#8214](https://github.com/ClickHouse/ClickHouse/pull/8214) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- حالت ثابت فایل رمز عبور پیش فرض برای `.deb` توزیع لینوکس. [\#8075](https://github.com/ClickHouse/ClickHouse/pull/8075) ([پرولر](https://github.com/proller)) -- بیان بهبود یافته برای گرفتن `clickhouse-server` PID در `clickhouse-test`. [\#8063](https://github.com/ClickHouse/ClickHouse/pull/8063) ([الکساندر کازاکوف](https://github.com/Akazz)) -- به روز شده در تماس/ماده چسبنده و لزج به نسخه برداری1.10.0. [\#8587](https://github.com/ClickHouse/ClickHouse/pull/8587) ([الکساندر بورمک](https://github.com/Alex-Burmak)) -- گزارش سه گانه ثابت در `base64` کتابخونه. همچنین این کتابخانه به جدیدترین نسخه به روز, اما مهم نیست. این رفع [\#8397](https://github.com/ClickHouse/ClickHouse/issues/8397). [\#8403](https://github.com/ClickHouse/ClickHouse/pull/8403) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ثابت `00600_replace_running_query` برای پردازنده. [\#8272](https://github.com/ClickHouse/ClickHouse/pull/8272) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- حذف پشتیبانی برای `tcmalloc` برای ساخت `CMakeLists.txt` ساده تر [\#8310](https://github.com/ClickHouse/ClickHouse/pull/8310) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- انتشار شورای همکاری خلیج فارس ایجاد در حال حاضر استفاده کنید `libc++` به جای `libstdc++`. اخیرا `libc++` تنها با صدای جرنگ جرنگ مورد استفاده قرار گرفت. این ثبات تنظیمات ساخت و قابلیت حمل را بهبود بخشد. [\#8311](https://github.com/ClickHouse/ClickHouse/pull/8311) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- فعال کردن کتابخانه فناوری اطلاعات و ارتباطات برای ساخت با حفظ. [\#8222](https://github.com/ClickHouse/ClickHouse/pull/8222) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- سرکوب هشدارها از `CapNProto` کتابخونه. [\#8224](https://github.com/ClickHouse/ClickHouse/pull/8224) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- موارد خاص حذف کد برای `tcmalloc`, زیرا دیگر پشتیبانی. [\#8225](https://github.com/ClickHouse/ClickHouse/pull/8225) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- کشتن سرور برازنده اجازه می دهد تا برای ذخیره گزارش پوشش. این رفع گزارش پوشش ناقص ما به تازگی دیدن شده است. [\#8142](https://github.com/ClickHouse/ClickHouse/pull/8142) ([الساپین](https://github.com/alesapin)) -- تست عملکرد برای تمام کدک در برابر `Float64` و `UInt64` ارزشهای خبری عبارتند از: [\#8349](https://github.com/ClickHouse/ClickHouse/pull/8349) ([واسیلی نمکو](https://github.com/Enmk)) -- `termcap` بسیار توصیه شده و منجر به مشکلات مختلف (f.g. از دست رفته “up” کلاه و انعکاس `^J` به جای چند خط). به نفع `terminfo` یا همراه `ncurses`. [\#7737](https://github.com/ClickHouse/ClickHouse/pull/7737) ([ایموس پرنده](https://github.com/amosbird)) -- ثابت `test_storage_s3` تست ادغام. [\#7734](https://github.com/ClickHouse/ClickHouse/pull/7734) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- پشتیبانی `StorageFile(, null)` برای قرار دادن بلوک به فایل فرمت داده شده بدون در واقع به دیسک ارسال. این برای تست عملکرد مورد نیاز است. [\#8455](https://github.com/ClickHouse/ClickHouse/pull/8455) ([ایموس پرنده](https://github.com/amosbird)) -- استدلال اضافه شده `--print-time` به تست های عملکردی که زمان اجرای هر تست را چاپ می کند. [\#8001](https://github.com/ClickHouse/ClickHouse/pull/8001) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اضافه ادعا به `KeyCondition` در حالی که ارزیابی مالیات بر ارزش افزوده. این هشدار را از شورای همکاری خلیج فارس-9 حل کنند. [\#8279](https://github.com/ClickHouse/ClickHouse/pull/8279) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- تخلیه گزینه های چوب کوره در سی ایجاد. [\#8273](https://github.com/ClickHouse/ClickHouse/pull/8273) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- اطلاعات اشکال زدایی برای برخی از کتابخانه های چربی تولید نمی کند. [\#8271](https://github.com/ClickHouse/ClickHouse/pull/8271) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- ساخت `log_to_console.xml` همیشه به خ ورود, صرف نظر از تعاملی است یا نه. [\#8395](https://github.com/ClickHouse/ClickHouse/pull/8395) ([الکساندر کوزمنکوف](https://github.com/akuzm)) -- حذف برخی از ویژگی های استفاده نشده از `clickhouse-performance-test` ابزار. [\#8555](https://github.com/ClickHouse/ClickHouse/pull/8555) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- در حال حاضر ما نیز برای جستجو `lld-X` با متناظر `clang-X` نسخه. [\#8092](https://github.com/ClickHouse/ClickHouse/pull/8092) ([الساپین](https://github.com/alesapin)) -- پارکت ساخت بهبود. [\#8421](https://github.com/ClickHouse/ClickHouse/pull/8421) ([مکسولان](https://github.com/maxulan)) -- هشدارهای شورای همکاری خلیج فارس بیشتر [\#8221](https://github.com/ClickHouse/ClickHouse/pull/8221) ([کروزرکریگ](https://github.com/kreuzerkrieg)) -- بسته بندی برای قوس لینوکس در حال حاضر اجازه می دهد تا برای اجرای سرور کلیک, و نه تنها مشتری. [\#8534](https://github.com/ClickHouse/ClickHouse/pull/8534) ([ولادیمیر چبوتراف](https://github.com/excitoon)) -- ثابت تست با پردازنده. رفع عملکرد کوچک. [\#7672](https://github.com/ClickHouse/ClickHouse/pull/7672) ([نیکولای کوچتو](https://github.com/KochetovNicolai)) -- اطلاعات دقیق [\#8256](https://github.com/ClickHouse/ClickHouse/pull/8256) ([هشدار داده می شود](https://github.com/matwey)) -- در تهیه تعویض به سی++20 به عنوان یک جشن سال نو. “May the C++ force be with ClickHouse.” [\#8447](https://github.com/ClickHouse/ClickHouse/pull/8447) ([ایموس پرنده](https://github.com/amosbird)) - -#### ویژگی تجربی {#experimental-feature-1} - -- اضافه شدن تنظیمات تجربی `min_bytes_to_use_mmap_io`. این اجازه می دهد به خواندن فایل های بزرگ بدون کپی کردن داده ها از هسته به فضای کاربری. تنظیمات به طور پیش فرض غیر فعال. توصیه می شود در حدود 64 مگابایت است, چون اماسپ / مون مپ کند است. [\#8520](https://github.com/ClickHouse/ClickHouse/pull/8520) ([الکسی میلویدو](https://github.com/alexey-milovidov)) -- سهمیه به عنوان بخشی از سیستم کنترل دسترسی دوباره. جدول جدید اضافه شده است `system.quotas` توابع جدید `currentQuota`, `currentQuotaKey` نحو گذاشتن جدید `CREATE QUOTA`, `ALTER QUOTA`, `DROP QUOTA`, `SHOW QUOTA`. [\#7257](https://github.com/ClickHouse/ClickHouse/pull/7257) ([ویتالی بارانو](https://github.com/vitlibar)) -- اجازه پرش تنظیمات ناشناخته با هشدار به جای پرتاب استثنا. [\#7653](https://github.com/ClickHouse/ClickHouse/pull/7653) ([ویتالی بارانو](https://github.com/vitlibar)) -- سیاست های ردیف به عنوان بخشی از سیستم کنترل دسترسی دوباره. جدول جدید اضافه شده است `system.row_policies` تابع جدید `currentRowPolicies()` نحو گذاشتن جدید `CREATE POLICY`, `ALTER POLICY`, `DROP POLICY`, `SHOW CREATE POLICY`, `SHOW POLICIES`. [\#7808](https://github.com/ClickHouse/ClickHouse/pull/7808) ([ویتالی بارانو](https://github.com/vitlibar)) - -#### تعمیر امنیتی {#security-fix} - -- ثابت امکان خواندن ساختار دایرکتوری در جداول با `File` موتور جدول. این رفع [\#8536](https://github.com/ClickHouse/ClickHouse/issues/8536). [\#8537](https://github.com/ClickHouse/ClickHouse/pull/8537) ([الکسی میلویدو](https://github.com/alexey-milovidov)) - -## [تغییرات برای 2019](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2019.md) {#changelog-for-2019} diff --git a/docs/fa/whats_new/index.md b/docs/fa/whats_new/index.md deleted file mode 100644 index ac27b70b8bd..00000000000 --- a/docs/fa/whats_new/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: What's New -toc_priority: 72 ---- - - diff --git a/docs/fa/whats_new/roadmap.md b/docs/fa/whats_new/roadmap.md deleted file mode 100644 index f51b57e3a2a..00000000000 --- a/docs/fa/whats_new/roadmap.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 74 -toc_title: "\u0646\u0642\u0634\u0647 \u0631\u0627\u0647" ---- - -# نقشه راه {#roadmap} - -## Q1 2020 {#q1-2020} - -- کنترل دسترسی مبتنی بر نقش - -## Q2 2020 {#q2-2020} - -- ادغام با خدمات احراز هویت خارجی -- استخر منابع برای توزیع دقیق تر از ظرفیت خوشه ای بین کاربران - -{## [مقاله اصلی](https://clickhouse.tech/docs/en/roadmap/) ##} diff --git a/docs/fa/whats_new/security_changelog.md b/docs/fa/whats_new/security_changelog.md deleted file mode 100644 index 79eb2230b03..00000000000 --- a/docs/fa/whats_new/security_changelog.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 76 -toc_title: "\u062A\u063A\u06CC\u06CC\u0631\u0627\u062A \u0627\u0645\u0646\u06CC\u062A\ - \u06CC" ---- - -## ثابت در clickhouse انتشار 19.14.3.3, 2019-09-10 {#fixed-in-clickhouse-release-19-14-3-3-2019-09-10} - -### CVE-2019-15024 {#cve-2019-15024} - -Аn attacker that has write access to ZooKeeper and who ican run a custom server available from the network where ClickHouse runs, can create a custom-built malicious server that will act as a ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from the malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. - -اعتبار: الدار زیتوف تیم امنیت اطلاعات یاندکس - -### CVE-2019-16535 {#cve-2019-16535} - -Аn OOB read, OOB write and integer underflow in decompression algorithms can be used to achieve RCE or DoS via native protocol. - -اعتبار: الدار زیتوف تیم امنیت اطلاعات یاندکس - -### CVE-2019-16536 {#cve-2019-16536} - -سرریز پشته منجر به داس را می توان با یک مشتری تصدیق مخرب باعث. - -اعتبار: الدار زیتوف تیم امنیت اطلاعات یاندکس - -## ثابت در clickhouse انتشار 19.13.6.1, 2019-09-20 {#fixed-in-clickhouse-release-19-13-6-1-2019-09-20} - -### CVE-2019-18657 {#cve-2019-18657} - -تابع جدول `url` در صورت امکان پذیری اجازه مهاجم برای تزریق هدر قام دلخواه در درخواست. - -اعتبار: [نیکیتا تیکومیرو](https://github.com/NSTikhomirov) - -## ثابت در clickhouse انتشار 18.12.13, 2018-09-10 {#fixed-in-clickhouse-release-18-12-13-2018-09-10} - -### CVE-2018-14672 {#cve-2018-14672} - -توابع برای بارگذاری مدل های ادم کودن و احمق اجازه عبور مسیر و خواندن فایل های دلخواه از طریق پیام های خطا. - -اعتبار: اندری کراسیچکوف از تیم امنیت اطلاعات یاندکس - -## ثابت در clickhouse انتشار 18.10.3, 2018-08-13 {#fixed-in-clickhouse-release-18-10-3-2018-08-13} - -### CVE-2018-14671 {#cve-2018-14671} - -unixODBC اجازه بارگذاری دلخواه اشیاء مشترک از فایل سیستم است که منجر به اجرای کد از راه دور آسیب پذیری. - -اعتبار: اندری کراسیچکوف و اوگنی سیدوروف از تیم امنیت اطلاعات یاندکس - -## ثابت در clickhouse انتشار 1.1.54388, 2018-06-28 {#fixed-in-clickhouse-release-1-1-54388-2018-06-28} - -### CVE-2018-14668 {#cve-2018-14668} - -“remote” تابع جدول اجازه نمادهای دلخواه در “user”, “password” و “default\_database” زمینه های که منجر به عبور از پروتکل درخواست حملات جعل. - -اعتبار: اندری کراسیچکوف از تیم امنیت اطلاعات یاندکس - -## ثابت در clickhouse انتشار 1.1.54390, 2018-07-06 {#fixed-in-clickhouse-release-1-1-54390-2018-07-06} - -### CVE-2018-14669 {#cve-2018-14669} - -کلاینت خروجی زیر کلیک بود “LOAD DATA LOCAL INFILE” قابلیت را فعال کنید که اجازه یک پایگاه داده خروجی زیر مخرب خواندن فایل های دلخواه از سرور کلیک متصل می شود. - -اعتبار: اندری کراسیچکوف و اوگنی سیدوروف از تیم امنیت اطلاعات یاندکس - -## ثابت در clickhouse انتشار 1.1.54131, 2017-01-10 {#fixed-in-clickhouse-release-1-1-54131-2017-01-10} - -### CVE-2018-14670 {#cve-2018-14670} - -پیکربندی نادرست در بسته دب می تواند به استفاده غیر مجاز از پایگاه داده منجر شود. - -اعتبار: انگلستان national cyber security centre (ncsc) - -{## [مقاله اصلی](https://clickhouse.tech/docs/en/security_changelog/) ##} diff --git a/docs/fr/commercial/cloud.md b/docs/fr/commercial/cloud.md index 3a04f95fc9a..13013065bfe 100644 --- a/docs/fr/commercial/cloud.md +++ b/docs/fr/commercial/cloud.md @@ -1,6 +1,8 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 1 +toc_title: Nuage --- # Fournisseurs De Services Cloud ClickHouse {#clickhouse-cloud-service-providers} @@ -12,7 +14,7 @@ machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 [Service géré Yandex pour ClickHouse](https://cloud.yandex.com/services/managed-clickhouse?utm_source=referrals&utm_medium=clickhouseofficialsite&utm_campaign=link3) offre les fonctionnalités suivantes: -- Service ZooKeeper entièrement géré pour [Réplication de ClickHouse](../engines/table_engines/mergetree_family/replication.md) +- Service ZooKeeper entièrement géré pour [Réplication de ClickHouse](../engines/table-engines/mergetree-family/replication.md) - Choix multiples de type de stockage - Répliques dans différentes zones de disponibilité - Le chiffrement et l'isolement diff --git a/docs/fr/commercial/index.md b/docs/fr/commercial/index.md index 296ea571a59..388f9a47fc8 100644 --- a/docs/fr/commercial/index.md +++ b/docs/fr/commercial/index.md @@ -1,8 +1,9 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Commercial toc_priority: 70 +toc_title: Commercial --- diff --git a/docs/fr/commercial/support.md b/docs/fr/commercial/support.md deleted file mode 120000 index 1eb20ccf36a..00000000000 --- a/docs/fr/commercial/support.md +++ /dev/null @@ -1 +0,0 @@ -../../en/commercial/support.md \ No newline at end of file diff --git a/docs/fr/commercial/support.md b/docs/fr/commercial/support.md new file mode 100644 index 00000000000..f5ce091272f --- /dev/null +++ b/docs/fr/commercial/support.md @@ -0,0 +1,23 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 3 +toc_title: Soutien +--- + +# Fournisseurs De Services De Soutien Commercial ClickHouse {#clickhouse-commercial-support-service-providers} + +!!! info "Info" + Si vous avez lancé un service de support commercial ClickHouse, n'hésitez pas à [ouvrir une demande d'extraction](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/commercial/support.md) ajouter à la liste suivante. + +## Altinity {#altinity} + +Altinity offre le support et les services de ClickHouse d'entreprise depuis 2017. Les clients d'Altinity vont des entreprises Fortune 100 aux startups. Visiter [www.altinity.com](https://www.altinity.com/) pour plus d'informations. + +## Mafiree {#mafiree} + +[Description du Service](http://mafiree.com/clickhouse-analytics-services.php) + +## MinervaDB {#minervadb} + +[Description du Service](https://minervadb.com/index.php/clickhouse-consulting-and-support-by-minervadb/) diff --git a/docs/fr/development/architecture.md b/docs/fr/development/architecture.md index eb9cab7ecf9..97de3c8d1ce 100644 --- a/docs/fr/development/architecture.md +++ b/docs/fr/development/architecture.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 62 toc_title: Vue d'ensemble de L'Architecture ClickHouse --- @@ -122,7 +122,7 @@ Il y a des fonctions ordinaires et des fonctions agrégées. Pour les fonctions Ordinary functions don't change the number of rows – they work as if they are processing each row independently. In fact, functions are not called for individual rows, but for `Block`'s de données pour implémenter l'exécution de requête vectorisée. -Il y a quelques fonctions diverses, comme [la taille de bloc](../sql_reference/functions/other_functions.md#function-blocksize), [rowNumberInBlock](../sql_reference/functions/other_functions.md#function-rownumberinblock), et [runningAccumulate](../sql_reference/functions/other_functions.md#function-runningaccumulate), qui exploitent le traitement de bloc et violent l'indépendance des lignes. +Il y a quelques fonctions diverses, comme [la taille de bloc](../sql-reference/functions/other-functions.md#function-blocksize), [rowNumberInBlock](../sql-reference/functions/other-functions.md#function-rownumberinblock), et [runningAccumulate](../sql-reference/functions/other-functions.md#function-runningaccumulate), qui exploitent le traitement de bloc et violent l'indépendance des lignes. ClickHouse a un typage fort, donc il n'y a pas de conversion de type implicite. Si une fonction ne prend pas en charge une combinaison spécifique de types, elle lève une exception. Mais les fonctions peuvent fonctionner (être surchargées) pour de nombreuses combinaisons de types différentes. Par exemple, l' `plus` fonction (pour mettre en œuvre la `+` opérateur) fonctionne pour toute combinaison de types numériques: `UInt8` + `Float32`, `UInt16` + `Int8` et ainsi de suite. En outre, certaines fonctions variadiques peuvent accepter n'importe quel nombre d'arguments, tels que `concat` fonction. diff --git a/docs/fr/development/browse-code.md b/docs/fr/development/browse-code.md new file mode 100644 index 00000000000..ef8beb600c6 --- /dev/null +++ b/docs/fr/development/browse-code.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: Parcourir Le Code Source +--- + +# Parcourir Le Code Source De ClickHouse {#browse-clickhouse-source-code} + +Vous pouvez utiliser **Woboq** navigateur de code en ligne disponible [ici](https://clickhouse.tech/codebrowser/html_report/ClickHouse/src/index.html). Il fournit la navigation de code et la mise en évidence sémantique, la recherche et l'indexation. L'instantané de code est mis à jour quotidiennement. + +Aussi, vous pouvez parcourir les sources sur [GitHub](https://github.com/ClickHouse/ClickHouse) comme à l'habitude. + +Si vous êtes intéressé par L'IDE à utiliser, nous vous recommandons CLion, Qt Creator, VS Code et KDevelop (avec des mises en garde). Vous pouvez utiliser N'importe quel IDE préféré. Vim et Emacs comptent également. diff --git a/docs/fr/development/browse_code.md b/docs/fr/development/browse_code.md deleted file mode 100644 index 0d708da5beb..00000000000 --- a/docs/fr/development/browse_code.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 63 -toc_title: Parcourir Le Code Source De ClickHouse ---- - -# Parcourir Le Code Source De ClickHouse {#browse-clickhouse-source-code} - -Vous pouvez utiliser **Woboq** navigateur de code en ligne disponible [ici](https://clickhouse.tech/codebrowser/html_report///ClickHouse/dbms/index.html). Il fournit la navigation de code et la mise en évidence sémantique, la recherche et l'indexation. L'instantané de code est mis à jour quotidiennement. - -Aussi, vous pouvez parcourir les sources sur [GitHub](https://github.com/ClickHouse/ClickHouse) comme à l'habitude. - -Si vous êtes intéressé par L'IDE à utiliser, nous vous recommandons CLion, Qt Creator, VS Code et KDevelop (avec des mises en garde). Vous pouvez utiliser N'importe quel IDE préféré. Vim et Emacs comptent également. diff --git a/docs/fr/development/build-cross-arm.md b/docs/fr/development/build-cross-arm.md new file mode 100644 index 00000000000..472862eabe5 --- /dev/null +++ b/docs/fr/development/build-cross-arm.md @@ -0,0 +1,43 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 67 +toc_title: Comment Construire ClickHouse sur Linux pour AARCH64 (ARM64) +--- + +# Comment Construire ClickHouse sur Linux pour L'Architecture AARCH64 (ARM64) {#how-to-build-clickhouse-on-linux-for-aarch64-arm64-architecture} + +C'est pour le cas où vous avez machine Linux et que vous voulez utiliser pour construire `clickhouse` binaire qui fonctionnera sur une autre machine Linux avec une architecture CPU AARCH64. Ceci est destiné aux contrôles d'intégration continus qui s'exécutent sur des serveurs Linux. + +La construction croisée pour AARCH64 est basée sur [Instructions de construction](build.md), suivez d'abord. + +# Installer Clang-8 {#install-clang-8} + +Suivez les instructions de https://apt.llvm.org/ pour votre configuration Ubuntu ou Debian. +Par exemple, dans Ubuntu Bionic vous pouvez utiliser les commandes suivantes: + +``` bash +echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee /etc/apt/sources.list.d/llvm.list +sudo apt-get update +sudo apt-get install clang-8 +``` + +# Installer Un Ensemble D'Outils De Compilation Croisée {#install-cross-compilation-toolset} + +``` bash +cd ClickHouse +mkdir -p build-aarch64/cmake/toolchain/linux-aarch64 +wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en' -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz +tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build-aarch64/cmake/toolchain/linux-aarch64 --strip-components=1 +``` + +# Construire ClickHouse {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-arm64 +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake +ninja -C build-arm64 +``` + +Le binaire résultant s'exécutera uniquement sur Linux avec l'architecture CPU AARCH64. diff --git a/docs/fr/development/build-cross-osx.md b/docs/fr/development/build-cross-osx.md new file mode 100644 index 00000000000..4fa97a65c7b --- /dev/null +++ b/docs/fr/development/build-cross-osx.md @@ -0,0 +1,64 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 66 +toc_title: Comment Construire ClickHouse sur Linux pour Mac OS X +--- + +# Comment Construire ClickHouse sur Linux pour Mac OS X {#how-to-build-clickhouse-on-linux-for-mac-os-x} + +C'est pour le cas où vous avez machine Linux et que vous voulez utiliser pour construire `clickhouse` binaire qui s'exécutera sur OS X. Ceci est destiné aux contrôles d'intégration continus qui s'exécutent sur des serveurs Linux. Si vous voulez construire ClickHouse directement sur Mac OS X, puis procéder à [une autre instruction](build-osx.md). + +Le cross-build pour Mac OS X est basé sur le [Instructions de construction](build.md), suivez d'abord. + +# Installer Clang-8 {#install-clang-8} + +Suivez les instructions de https://apt.llvm.org/ pour votre configuration Ubuntu ou Debian. +Par exemple les commandes pour Bionic sont comme: + +``` bash +sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list +sudo apt-get install clang-8 +``` + +# Installer Un Ensemble D'Outils De Compilation Croisée {#install-cross-compilation-toolset} + +Souvenons nous du chemin où nous installons `cctools` comme ${CCTOOLS} + +``` bash +mkdir ${CCTOOLS} + +git clone https://github.com/tpoechtrager/apple-libtapi.git +cd apple-libtapi +INSTALLPREFIX=${CCTOOLS} ./build.sh +./install.sh +cd .. + +git clone https://github.com/tpoechtrager/cctools-port.git +cd cctools-port/cctools +./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin +make install +``` + +En outre, nous devons télécharger macOS X SDK dans l'arbre de travail. + +``` bash +cd ClickHouse +wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' +mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 +tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 +``` + +# Construire ClickHouse {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-osx +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ + -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ + -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ + -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld +ninja -C build-osx +``` + +Le binaire résultant aura un format exécutable Mach-O et ne pourra pas être exécuté sous Linux. diff --git a/docs/fr/development/build-osx.md b/docs/fr/development/build-osx.md new file mode 100644 index 00000000000..677e257a637 --- /dev/null +++ b/docs/fr/development/build-osx.md @@ -0,0 +1,93 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 65 +toc_title: Comment Construire ClickHouse sur Mac OS X +--- + +# Comment Construire ClickHouse sur Mac OS X {#how-to-build-clickhouse-on-mac-os-x} + +Build devrait fonctionner sur Mac OS X 10.15 (Catalina) + +## Installer Homebrew {#install-homebrew} + +``` bash +$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +## Installez les compilateurs, outils et bibliothèques requis {#install-required-compilers-tools-and-libraries} + +``` bash +$ brew install cmake ninja libtool gettext +``` + +## Commander Clickhouse Sources {#checkout-clickhouse-sources} + +``` bash +$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git +``` + +ou + +``` bash +$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git + +$ cd ClickHouse +``` + +## Construire ClickHouse {#build-clickhouse} + +``` bash +$ mkdir build +$ cd build +$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` +$ ninja +$ cd .. +``` + +## Mises en garde {#caveats} + +Si vous avez l'intention d'exécuter clickhouse-server, assurez-vous d'augmenter la variable maxfiles du système. + +!!! info "Note" + Vous aurez besoin d'utiliser sudo. + +Pour ce faire, créez le fichier suivant: + +/ Bibliothèque / LaunchDaemons / limite.maxfiles.plist: + +``` xml + + + + + Label + limit.maxfiles + ProgramArguments + + launchctl + limit + maxfiles + 524288 + 524288 + + RunAtLoad + + ServiceIPC + + + +``` + +Exécutez la commande suivante: + +``` bash +$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist +``` + +Redémarrer. + +Pour vérifier si elle fonctionne, vous pouvez utiliser `ulimit -n` commande. + +[Article Original](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/fr/development/build.md b/docs/fr/development/build.md index 0a5e5838d66..a57e0f20337 100644 --- a/docs/fr/development/build.md +++ b/docs/fr/development/build.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 64 toc_title: Comment Construire ClickHouse sur Linux --- diff --git a/docs/fr/development/build_cross_arm.md b/docs/fr/development/build_cross_arm.md deleted file mode 100644 index 7da37869583..00000000000 --- a/docs/fr/development/build_cross_arm.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 67 -toc_title: Comment Construire ClickHouse sur Linux pour AARCH64 (ARM64) ---- - -# Comment Construire ClickHouse sur Linux pour l'architecture AARCH64 (ARM64) {#how-to-build-clickhouse-on-linux-for-aarch64-arm64-architecture} - -C'est pour le cas où vous avez machine Linux et que vous voulez utiliser pour construire `clickhouse` binaire qui fonctionnera sur une autre machine Linux avec une architecture CPU AARCH64. Ceci est destiné aux contrôles d'intégration continus qui s'exécutent sur des serveurs Linux. - -La construction croisée pour AARCH64 est basée sur [Instructions de construction](build.md), suivez d'abord. - -# Installer Clang-8 {#install-clang-8} - -Suivez les instructions de https://apt.llvm.org/ pour votre configuration Ubuntu ou Debian. -Par exemple, dans Ubuntu Bionic vous pouvez utiliser les commandes suivantes: - -``` bash -echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee /etc/apt/sources.list.d/llvm.list -sudo apt-get update -sudo apt-get install clang-8 -``` - -# Installer Un Ensemble D'Outils De Compilation Croisée {#install-cross-compilation-toolset} - -``` bash -cd ClickHouse -mkdir -p build-aarch64/cmake/toolchain/linux-aarch64 -wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en' -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build-aarch64/cmake/toolchain/linux-aarch64 --strip-components=1 -``` - -# Construire ClickHouse {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-arm64 -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake -ninja -C build-arm64 -``` - -Le binaire résultant s'exécutera uniquement sur Linux avec l'architecture CPU AARCH64. diff --git a/docs/fr/development/build_cross_osx.md b/docs/fr/development/build_cross_osx.md deleted file mode 100644 index 809b6ef0dd6..00000000000 --- a/docs/fr/development/build_cross_osx.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 66 -toc_title: Comment Construire ClickHouse sur Linux pour Mac OS X ---- - -# Comment Construire ClickHouse sur Linux pour Mac OS X {#how-to-build-clickhouse-on-linux-for-mac-os-x} - -C'est pour le cas où vous avez machine Linux et que vous voulez utiliser pour construire `clickhouse` binaire qui s'exécutera sur OS X. Ceci est destiné aux contrôles d'intégration continus qui s'exécutent sur des serveurs Linux. Si vous voulez construire ClickHouse directement sur Mac OS X, puis procéder à [une autre instruction](build_osx.md). - -Le cross-build pour Mac OS X est basé sur le [Instructions de construction](build.md), suivez d'abord. - -# Installer Clang-8 {#install-clang-8} - -Suivez les instructions de https://apt.llvm.org/ pour votre configuration Ubuntu ou Debian. -Par exemple les commandes pour Bionic sont comme: - -``` bash -sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list -sudo apt-get install clang-8 -``` - -# Installer Un Ensemble D'Outils De Compilation Croisée {#install-cross-compilation-toolset} - -Souvenons nous du chemin où nous installons `cctools` comme ${CCTOOLS} - -``` bash -mkdir ${CCTOOLS} - -git clone https://github.com/tpoechtrager/apple-libtapi.git -cd apple-libtapi -INSTALLPREFIX=${CCTOOLS} ./build.sh -./install.sh -cd .. - -git clone https://github.com/tpoechtrager/cctools-port.git -cd cctools-port/cctools -./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin -make install -``` - -En outre, nous devons télécharger macOS X SDK dans l'arbre de travail. - -``` bash -cd ClickHouse -wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' -mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 -tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 -``` - -# Construire ClickHouse {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-osx -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ - -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ - -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ - -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld -ninja -C build-osx -``` - -Le binaire résultant aura un format exécutable Mach-O et ne pourra pas être exécuté sous Linux. diff --git a/docs/fr/development/build_osx.md b/docs/fr/development/build_osx.md deleted file mode 100644 index b2122c2117f..00000000000 --- a/docs/fr/development/build_osx.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 65 -toc_title: Comment Construire ClickHouse sur Mac OS X ---- - -# Comment Construire ClickHouse sur Mac OS X {#how-to-build-clickhouse-on-mac-os-x} - -Build devrait fonctionner sur Mac OS X 10.15 (Catalina) - -## Installer Homebrew {#install-homebrew} - -``` bash -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` - -## Installez les compilateurs, outils et bibliothèques requis {#install-required-compilers-tools-and-libraries} - -``` bash -$ brew install cmake ninja libtool gettext -``` - -## Commander Clickhouse Sources {#checkout-clickhouse-sources} - -``` bash -$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git -``` - -ou - -``` bash -$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git - -$ cd ClickHouse -``` - -## Construire ClickHouse {#build-clickhouse} - -``` bash -$ mkdir build -$ cd build -$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` -$ ninja -$ cd .. -``` - -## Mises en garde {#caveats} - -Si vous avez l'intention d'exécuter clickhouse-server, assurez-vous d'augmenter la variable maxfiles du système. - -!!! info "Note" - Vous aurez besoin d'utiliser sudo. - -Pour ce faire, créez le fichier suivant: - -/ Bibliothèque / LaunchDaemons / limite.maxfiles.plist: - -``` xml - - - - - Label - limit.maxfiles - ProgramArguments - - launchctl - limit - maxfiles - 524288 - 524288 - - RunAtLoad - - ServiceIPC - - - -``` - -Exécutez la commande suivante: - -``` bash -$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist -``` - -Redémarrer. - -Pour vérifier si elle fonctionne, vous pouvez utiliser `ulimit -n` commande. - -[Article Original](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/fr/development/contrib.md b/docs/fr/development/contrib.md index 9750b348541..52eac7a71ac 100644 --- a/docs/fr/development/contrib.md +++ b/docs/fr/development/contrib.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 70 toc_title: "Biblioth\xE8ques Tierces Utilis\xE9es" --- diff --git a/docs/fr/development/developer-instruction.md b/docs/fr/development/developer-instruction.md new file mode 100644 index 00000000000..a20066fa3f7 --- /dev/null +++ b/docs/fr/development/developer-instruction.md @@ -0,0 +1,287 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "Le D\xE9butant Clickhouse Developer Instruction" +--- + +La construction de ClickHouse est prise en charge sous Linux, FreeBSD et Mac OS X. + +# Si Vous Utilisez Windows {#if-you-use-windows} + +Si vous utilisez Windows, vous devez créer une machine virtuelle avec Ubuntu. Pour commencer à travailler avec une machine virtuelle, installez VirtualBox. Vous pouvez télécharger Ubuntu sur le site: https://www.ubuntu.com/\#download. veuillez créer une machine virtuelle à partir de l'image téléchargée (vous devez réserver au moins 4 Go de RAM pour cela). Pour exécuter un terminal de ligne de commande dans Ubuntu, recherchez un programme contenant le mot “terminal” dans son nom (gnome-terminal, konsole etc.) ou appuyez simplement sur Ctrl + Alt + T. + +# Si vous utilisez un système 32 bits {#if-you-use-a-32-bit-system} + +ClickHouse ne peut pas fonctionner ou construire sur un système 32 bits. Vous devez acquérir l'accès à un système 64 bits et vous pouvez continuer la lecture. + +# Création d'un référentiel sur GitHub {#creating-a-repository-on-github} + +Pour commencer à travailler avec clickhouse repository, vous aurez besoin d'un compte GitHub. + +Vous en avez probablement déjà un, mais si vous ne le faites pas, veuillez vous inscrire à https://github.com. dans le cas où vous n'avez pas de clés SSH, vous devez les générer, puis les télécharger sur GitHub. Il est nécessaire pour l'envoi de vos correctifs. Il est également possible d'utiliser les mêmes clés SSH que vous utilisez avec d'autres serveurs SSH - vous les avez probablement déjà. + +Créer un fork de clickhouse repository. Pour ce faire, cliquez sur l' “fork” bouton dans le coin supérieur droit à https://github.com/ClickHouse/ClickHouse. il fourche votre propre copie de ClickHouse / ClickHouse à votre compte. + +Le processus de développement consiste d'abord à valider les modifications prévues dans votre fork de ClickHouse, puis à créer un “pull request” pour que ces modifications soient acceptées dans le référentiel principal (ClickHouse/ClickHouse). + +Pour travailler avec les dépôts git, veuillez installer `git`. + +Pour ce faire dans Ubuntu vous exécutez dans le terminal de ligne de commande: + + sudo apt update + sudo apt install git + +Un bref manuel sur l'utilisation de Git peut être trouvé ici: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf. +Pour un manuel détaillé sur Git voir https://git-scm.com/book/en/v2. + +# Clonage D'un référentiel sur votre machine de développement {#cloning-a-repository-to-your-development-machine} + +Ensuite, vous devez télécharger les fichiers source sur votre machine de travail. Ceci est appelé “to clone a repository” parce qu'il crée une copie locale du dépôt sur votre machine de travail. + +Dans le terminal de ligne de commande exécuter: + + git clone --recursive git@github.com:your_github_username/ClickHouse.git + cd ClickHouse + +Remarque: Veuillez remplacer *your\_github\_username* avec ce qui est approprié! + +Cette commande va créer un répertoire `ClickHouse` contenant la copie de travail du projet. + +Il est important que le chemin d'accès au répertoire de travail ne contienne aucun espace, car cela peut entraîner des problèmes lors de l'exécution du système de construction. + +Veuillez noter que clickhouse repository utilise `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` drapeau comme dans l'exemple ci-dessus. Si le dépôt a été cloné sans submodules, pour télécharger, vous devez exécuter les opérations suivantes: + + git submodule init + git submodule update + +Vous pouvez vérifier l'état avec la commande: `git submodule status`. + +Si vous obtenez le message d'erreur suivantes: + + Permission denied (publickey). + fatal: Could not read from remote repository. + + Please make sure you have the correct access rights + and the repository exists. + +Cela signifie généralement que les clés SSH pour la connexion à GitHub sont manquantes. Ces clés sont normalement situés dans `~/.ssh`. Pour que les clés SSH soient acceptées, vous devez les télécharger dans la section Paramètres de L'interface utilisateur GitHub. + +Vous pouvez également cloner le référentiel via le protocole https: + + git clone https://github.com/ClickHouse/ClickHouse.git + +Ceci, cependant, ne vous permettra pas d'envoyer vos modifications sur le serveur. Vous pouvez toujours l'utiliser temporairement et ajouter les clés SSH plus tard en remplaçant l'adresse distante du référentiel par `git remote` commande. + +Vous pouvez également ajouter l'adresse du dépôt clickhouse original à votre référentiel local pour extraire les mises à jour à partir de là: + + git remote add upstream git@github.com:ClickHouse/ClickHouse.git + +Après avoir exécuté avec succès cette commande vous serez en mesure de tirer les mises à jour du repo clickhouse principal en exécutant `git pull upstream master`. + +## Travailler avec des Submodules {#working-with-submodules} + +Travailler avec des sous-modules dans git pourrait être douloureux. Prochaines commandes aidera à gérer: + + # ! each command accepts --recursive + # Update remote URLs for submodules. Barely rare case + git submodule sync + # Add new submodules + git submodule init + # Update existing submodules to the current state + git submodule update + # Two last commands could be merged together + git submodule update --init + +Les commandes suivantes vous aideront à réinitialiser tous les sous-modules à l'état initial (!AVERTISSEMENT! - tout changement à l'intérieur sera supprimé): + + # Synchronizes submodules' remote URL with .gitmodules + git submodule sync --recursive + # Update the registered submodules with initialize not yet initialized + git submodule update --init --recursive + # Reset all changes done after HEAD + git submodule foreach git reset --hard + # Clean files from .gitignore + git submodule foreach git clean -xfd + # Repeat last 4 commands for all submodule + git submodule foreach git submodule sync --recursive + git submodule foreach git submodule update --init --recursive + git submodule foreach git submodule foreach git reset --hard + git submodule foreach git submodule foreach git clean -xfd + +# Système De Construction {#build-system} + +ClickHouse utilise CMake et Ninja pour la construction. + +CMake - un système de méta-construction qui peut générer des fichiers Ninja (tâches de construction). +Ninja - un système de construction plus petit avec un accent sur la vitesse utilisée pour exécuter ces tâches générées cmake. + +Pour installer sur Ubuntu, Debian ou mint run `sudo apt install cmake ninja-build`. + +Sur CentOS, RedHat run `sudo yum install cmake ninja-build`. + +Si vous utilisez Arch ou Gentoo, vous savez probablement vous - même comment installer CMake. + +Pour installer CMake et Ninja sur Mac OS X installez D'abord Homebrew puis installez tout le reste via brew: + + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install cmake ninja + +Ensuite, vérifiez la version de CMake: `cmake --version`. Si elle est inférieure à 3.3, vous devez installer une version plus récente du site web: https://cmake.org/download/. + +# Bibliothèques Externes Facultatives {#optional-external-libraries} + +ClickHouse utilise plusieurs bibliothèques externes pour la construction. Tous n'ont pas besoin d'être installés séparément car ils sont construits avec ClickHouse à partir des sources situées dans les sous-modules. Vous pouvez vérifier la liste dans `contrib`. + +# Compilateur C++ {#c-compiler} + +Les compilateurs GCC à partir de la version 9 et Clang version 8 ou supérieure sont pris en charge pour construire ClickHouse. + +Les builds officiels de Yandex utilisent actuellement GCC car ils génèrent du code machine de performances légèrement meilleures (ce qui donne une différence allant jusqu'à plusieurs pour cent selon nos benchmarks). Et Clang est plus pratique pour le développement habituellement. Cependant, notre plate-forme d'intégration continue (CI) vérifie environ une douzaine de combinaisons de construction. + +Pour installer GCC sur Ubuntu Exécutez: `sudo apt install gcc g++` + +Vérifiez la version de gcc: `gcc --version`. Si elle est inférieure à 9, suivez les instructions ici: https://clickhouse.tech/docs/fr/development/build/#install-gcc-9. + +Mac OS X build est pris en charge uniquement pour Clang. Il suffit d'exécuter `brew install llvm` + +Si vous décidez d'utiliser Clang, vous pouvez également installer `libc++` et `lld` si vous savez ce que c'est. Utiliser `ccache` est également recommandé. + +# Le Processus De Construction {#the-building-process} + +Maintenant que vous êtes prêt à construire ClickHouse nous vous conseillons de créer un répertoire séparé `build` à l'intérieur de `ClickHouse` qui contiendra tous les artefacts de construction: + + mkdir build + cd build + +Vous pouvez avoir plusieurs répertoires différents (build\_release, build\_debug, etc.) pour les différents types de construction. + +Tandis qu'à l'intérieur de la `build` répertoire, configurez votre build en exécutant CMake. Avant la première exécution, vous devez définir des variables d'environnement qui spécifient le compilateur (compilateur gcc version 9 dans cet exemple). + +Linux: + + export CC=gcc-9 CXX=g++-9 + cmake .. + +Mac OS X: + + export CC=clang CXX=clang++ + cmake .. + +Le `CC` variable spécifie le compilateur pour C (abréviation de compilateur C), et `CXX` variable indique quel compilateur C++ doit être utilisé pour la construction. + +Pour une version plus rapide, vous pouvez recourir à l' `debug` build type - Une construction sans optimisations. Pour cela fournissez le paramètre suivant `-D CMAKE_BUILD_TYPE=Debug`: + + cmake -D CMAKE_BUILD_TYPE=Debug .. + +Vous pouvez modifier le type de génération en exécutant cette commande dans le `build` répertoire. + +Exécutez ninja pour construire: + + ninja clickhouse-server clickhouse-client + +Seules les binaires vont être construites dans cet exemple. + +Si vous avez besoin de construire tous les binaires (utilitaires et tests), vous devez exécuter ninja sans paramètres: + + ninja + +La construction complète nécessite environ 30 Go d'espace disque libre ou 15 Go pour construire les binaires principaux. + +Lorsqu'une grande quantité de RAM est disponible sur la machine de construction vous devez limiter le nombre de tâches de construction exécutées en parallèle avec `-j` param: + + ninja -j 1 clickhouse-server clickhouse-client + +Sur les machines avec 4 Go de RAM, il est recommandé de spécifier 1, pour 8 Go de RAM `-j 2` est recommandé. + +Si vous recevez le message: `ninja: error: loading 'build.ninja': No such file or directory`, cela signifie que la génération d'une configuration de construction a échoué et que vous devez inspecter le message ci-dessus. + +Après le démarrage réussi du processus de construction, vous verrez la progression de la construction - le nombre de tâches traitées et le nombre total de tâches. + +Lors de la construction de messages sur les fichiers protobuf dans la bibliothèque libhdfs2 comme `libprotobuf WARNING` peuvent apparaître. Ils touchent rien et sont sûrs d'être ignoré. + +Lors de la construction, vous obtenez un fichier exécutable `ClickHouse//programs/clickhouse`: + + ls -l programs/clickhouse + +# Exécution de L'exécutable construit de ClickHouse {#running-the-built-executable-of-clickhouse} + +Pour exécuter le serveur sous l'utilisateur actuel vous devez naviguer vers `ClickHouse/programs/server/` (situé à l'extérieur de `build` et les exécuter: + + ../../build/programs/clickhouse server + +Dans ce cas, ClickHouse utilisera les fichiers de configuration situés dans le répertoire courant. Vous pouvez l'exécuter `clickhouse server` depuis n'importe quel répertoire spécifiant le chemin d'accès à un fichier de configuration en tant que paramètre de ligne de commande `--config-file`. + +Pour vous connecter à ClickHouse avec clickhouse-client dans un autre terminal, accédez à `ClickHouse/build/programs/` et exécuter `clickhouse client`. + +Si vous obtenez `Connection refused` message sur Mac OS X ou FreeBSD, essayez de spécifier l'adresse hôte 127.0.0.1: + + clickhouse client --host 127.0.0.1 + +Vous pouvez remplacer la version de production de clickhouse binary installée dans votre système par votre clickhouse Binary sur mesure. Pour ce faire, installez ClickHouse sur votre machine en suivant les instructions du site officiel. Ensuite, exécutez ce qui suit: + + sudo service clickhouse-server stop + sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ + sudo service clickhouse-server start + +Notez que `clickhouse-client`, `clickhouse-server` et d'autres sont des liens symboliques à la commune `clickhouse` binaire. + +Vous pouvez également exécuter votre binaire ClickHouse personnalisé avec le fichier de configuration du package clickhouse installé sur votre système: + + sudo service clickhouse-server stop + sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml + +# IDE (environnement de développement intégré) {#ide-integrated-development-environment} + +Si vous ne savez pas quel IDE utiliser, nous vous recommandons D'utiliser CLion. CLion est un logiciel commercial, mais il offre une période d'essai gratuite de 30 jours. Il est également gratuit pour les étudiants. CLion peut être utilisé à la fois sur Linux et sur Mac OS X. + +KDevelop et QTCreator sont d'autres grandes alternatives D'un IDE pour développer ClickHouse. KDevelop est un IDE très pratique bien qu'instable. Si KDevelop se bloque après un certain temps lors de l'ouverture du projet, vous devez cliquer sur “Stop All” bouton dès qu'il a ouvert la liste des fichiers du projet. Après cela, KDevelop devrait être bien pour travailler avec. + +En tant qu'éditeurs de code simples, vous pouvez utiliser Sublime Text ou Visual Studio Code, ou Kate (qui sont tous disponibles sur Linux). + +Juste au cas où, il convient de mentionner que CLion crée `build` chemin sur son propre, il aussi sur son propre sélectionne `debug` pour le type de construction, pour la configuration, il utilise une version de CMake définie dans CLion et non celle installée par vous, et enfin, CLion utilisera `make` pour exécuter construire des tâches au lieu de `ninja`. C'est un comportement normal, gardez cela à l'esprit pour éviter toute confusion. + +# L'Écriture De Code {#writing-code} + +La description de l'architecture ClickHouse peut être trouvée ici: https://clickhouse.tech/docs/fr/développement/architecture/ + +Le code Style Guide: https://clickhouse.tech/docs/fr/développement/style/ + +Rédaction de tests: https://clickhouse.tech/docs/fr/développement/tests/ + +Liste des tâches: https://github.com/ClickHouse/ClickHouse/contribute + +# Des Données De Test {#test-data} + +Le développement de ClickHouse nécessite souvent le chargement d'ensembles de données réalistes. Il est particulièrement important pour les tests de performance. Nous avons un ensemble spécialement préparé de données anonymisées de Yandex.Metrica. Il nécessite en outre quelques 3 Go d'espace disque libre. Notez que ces données ne sont pas requises pour accomplir la plupart des tâches de développement. + + sudo apt install wget xz-utils + + wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz + wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz + + xz -v -d hits_v1.tsv.xz + xz -v -d visits_v1.tsv.xz + + clickhouse-client + + CREATE DATABASE IF NOT EXISTS test + + CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); + + CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); + + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv + +# La Création De Pull Request {#creating-pull-request} + +Accédez à votre référentiel fork dans L'interface utilisateur de GitHub. Si vous avez développé dans une branche, vous devez sélectionner cette branche. Il y aura un “Pull request” bouton situé sur l'écran. En substance, cela signifie “create a request for accepting my changes into the main repository”. + +Une demande d'extraction peuvent être créés, même si le travail n'est pas encore terminée. Dans ce cas veuillez mettre le mot “WIP” (travaux en cours) au début du titre, il peut être modifié plus tard. Ceci est utile pour l'examen coopératif et la discussion des changements ainsi que pour l'exécution de tous les tests disponibles. Il est important que vous fournissiez une brève description de vos modifications, il sera ensuite utilisé pour générer des journaux de modifications de version. + +Les tests commenceront dès que les employés de Yandex étiqueteront votre PR avec une étiquette “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. + +Le système préparera les builds binaires ClickHouse pour votre demande de tirage individuellement. Pour récupérer ces versions cliquez sur le “Details” lien à côté “ClickHouse build check” entrée dans la liste de vérifications. Vous y trouverez des liens directs vers les construit .paquets deb de ClickHouse que vous pouvez déployer même sur vos serveurs de production (si vous n'avez pas peur). + +Très probablement, certaines des constructions échoueront à la première fois. Cela est dû au fait que nous avons vérifier s'appuie à la fois avec gcc, ainsi qu'avec clang, pratiquement tous les avertissements existants (toujours avec le `-Werror` drapeau) activé pour clang. Sur cette même page, vous pouvez trouver tous les journaux de construction afin que vous n'ayez pas à construire ClickHouse de toutes les manières possibles. diff --git a/docs/fr/development/developer_instruction.md b/docs/fr/development/developer_instruction.md deleted file mode 100644 index cf15f8f36ac..00000000000 --- a/docs/fr/development/developer_instruction.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 61 -toc_title: "Le D\xE9butant Clickhouse Developer Instruction" ---- - -La construction de ClickHouse est prise en charge sous Linux, FreeBSD et Mac OS X. - -# Si vous utilisez Windows {#if-you-use-windows} - -Si vous utilisez Windows, vous devez créer une machine virtuelle avec Ubuntu. Pour commencer à travailler avec une machine virtuelle, installez VirtualBox. Vous pouvez télécharger Ubuntu sur le site: https://www.ubuntu.com/\#download. veuillez créer une machine virtuelle à partir de l'image téléchargée (vous devez réserver au moins 4 Go de RAM pour cela). Pour exécuter un terminal de ligne de commande dans Ubuntu, recherchez un programme contenant le mot “terminal” dans son nom (gnome-terminal, konsole etc.) ou appuyez simplement sur Ctrl + Alt + T. - -# Si vous utilisez un système 32 bits {#if-you-use-a-32-bit-system} - -ClickHouse ne peut pas fonctionner ou construire sur un système 32 bits. Vous devez acquérir l'accès à un système 64 bits et vous pouvez continuer la lecture. - -# Création d'un référentiel sur GitHub {#creating-a-repository-on-github} - -Pour commencer à travailler avec clickhouse repository, vous aurez besoin d'un compte GitHub. - -Vous en avez probablement déjà un, mais si vous ne le faites pas, veuillez vous inscrire à https://github.com. dans le cas où vous n'avez pas de clés SSH, vous devez les générer, puis les télécharger sur GitHub. Il est nécessaire pour l'envoi de vos correctifs. Il est également possible d'utiliser les mêmes clés SSH que vous utilisez avec d'autres serveurs SSH - vous les avez probablement déjà. - -Créer un fork de clickhouse repository. Pour ce faire, cliquez sur l' “fork” bouton dans le coin supérieur droit à https://github.com/ClickHouse/ClickHouse. il fourche votre propre copie de ClickHouse / ClickHouse à votre compte. - -Le processus de développement consiste d'abord à valider les modifications prévues dans votre fork de ClickHouse, puis à créer un “pull request” pour que ces modifications soient acceptées dans le référentiel principal (ClickHouse/ClickHouse). - -Pour travailler avec les dépôts git, veuillez installer `git`. - -Pour ce faire dans Ubuntu vous exécutez dans le terminal de ligne de commande: - - sudo apt update - sudo apt install git - -Un bref manuel sur l'utilisation de Git peut être trouvé ici: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf. -Pour un manuel détaillé sur Git voir https://git-scm.com/book/en/v2. - -# Clonage d'un référentiel sur votre machine de développement {#cloning-a-repository-to-your-development-machine} - -Ensuite, vous devez télécharger les fichiers source sur votre machine de travail. Ceci est appelé “to clone a repository” parce qu'il crée une copie locale du dépôt sur votre machine de travail. - -Dans le terminal de ligne de commande exécuter: - - git clone --recursive git@guthub.com:your_github_username/ClickHouse.git - cd ClickHouse - -Remarque: Veuillez remplacer *your\_github\_username* avec ce qui est approprié! - -Cette commande va créer un répertoire `ClickHouse` contenant la copie de travail du projet. - -Il est important que le chemin d'accès au répertoire de travail ne contienne aucun espace, car cela peut entraîner des problèmes lors de l'exécution du système de construction. - -Veuillez noter que clickhouse repository utilise `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` drapeau comme dans l'exemple ci-dessus. Si le dépôt a été cloné sans submodules, pour télécharger, vous devez exécuter les opérations suivantes: - - git submodule init - git submodule update - -Vous pouvez vérifier l'état avec la commande: `git submodule status`. - -Si vous obtenez le message d'erreur suivantes: - - Permission denied (publickey). - fatal: Could not read from remote repository. - - Please make sure you have the correct access rights - and the repository exists. - -Cela signifie généralement que les clés SSH pour la connexion à GitHub sont manquantes. Ces clés sont normalement situés dans `~/.ssh`. Pour que les clés SSH soient acceptées, vous devez les télécharger dans la section Paramètres de L'interface utilisateur GitHub. - -Vous pouvez également cloner le référentiel via le protocole https: - - git clone https://github.com/ClickHouse/ClickHouse.git - -Ceci, cependant, ne vous permettra pas d'envoyer vos modifications sur le serveur. Vous pouvez toujours l'utiliser temporairement et ajouter les clés SSH plus tard en remplaçant l'adresse distante du référentiel par `git remote` commande. - -Vous pouvez également ajouter l'adresse du dépôt clickhouse original à votre référentiel local pour extraire les mises à jour à partir de là: - - git remote add upstream git@github.com:ClickHouse/ClickHouse.git - -Après avoir exécuté avec succès cette commande vous serez en mesure de tirer les mises à jour du repo clickhouse principal en exécutant `git pull upstream master`. - -## Travailler avec des submodules {#working-with-submodules} - -Travailler avec des sous-modules dans git pourrait être douloureux. Prochaines commandes aidera à gérer: - - # ! each command accepts --recursive - # Update remote URLs for submodules. Barely rare case - git submodule sync - # Add new submodules - git submodule init - # Update existing submodules to the current state - git submodule update - # Two last commands could be merged together - git submodule update --init - -Les commandes suivantes vous aideront à réinitialiser tous les sous-modules à l'état initial (!AVERTISSEMENT! - tout changement à l'intérieur sera supprimé): - - # Synchronizes submodules' remote URL with .gitmodules - git submodule sync --recursive - # Update the registered submodules with initialize not yet initialized - git submodule update --init --recursive - # Reset all changes done after HEAD - git submodule foreach git reset --hard - # Clean files from .gitignore - git submodule foreach git clean -xfd - # Repeat last 4 commands for all submodule - git submodule foreach git submodule sync --recursive - git submodule foreach git submodule update --init --recursive - git submodule foreach git submodule foreach git reset --hard - git submodule foreach git submodule foreach git clean -xfd - -# Système De Construction {#build-system} - -ClickHouse utilise CMake et Ninja pour la construction. - -CMake - un système de méta-construction qui peut générer des fichiers Ninja (tâches de construction). -Ninja - un système de construction plus petit avec un accent sur la vitesse utilisée pour exécuter ces tâches générées cmake. - -Pour installer sur Ubuntu, Debian ou mint run `sudo apt install cmake ninja-build`. - -Sur CentOS, RedHat run `sudo yum install cmake ninja-build`. - -Si vous utilisez Arch ou Gentoo, vous savez probablement vous - même comment installer CMake. - -Pour installer CMake et Ninja sur Mac OS X installez D'abord Homebrew puis installez tout le reste via brew: - - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew install cmake ninja - -Ensuite, vérifiez la version de CMake: `cmake --version`. Si elle est inférieure à 3.3, vous devez installer une version plus récente du site web: https://cmake.org/download/. - -# Bibliothèques Externes Facultatives {#optional-external-libraries} - -ClickHouse utilise plusieurs bibliothèques externes pour la construction. Tous n'ont pas besoin d'être installés séparément car ils sont construits avec ClickHouse à partir des sources situées dans les sous-modules. Vous pouvez vérifier la liste dans `contrib`. - -# Compilateur C++ {#c-compiler} - -Les compilateurs GCC à partir de la version 9 et Clang version 8 ou supérieure sont pris en charge pour construire ClickHouse. - -Les builds officiels de Yandex utilisent actuellement GCC car ils génèrent du code machine de performances légèrement meilleures (ce qui donne une différence allant jusqu'à plusieurs pour cent selon nos benchmarks). Et Clang est plus pratique pour le développement habituellement. Cependant, notre plate-forme d'intégration continue (CI) vérifie environ une douzaine de combinaisons de construction. - -Pour installer GCC sur Ubuntu Exécutez: `sudo apt install gcc g++` - -Vérifiez la version de gcc: `gcc --version`. Si elle est inférieure à 9, suivez les instructions ici: https://clickhouse.tech/docs/fr/développement/construction/\#install-gcc-9. - -Mac OS X build est pris en charge uniquement pour Clang. Il suffit d'exécuter `brew install llvm` - -Si vous décidez d'utiliser Clang, vous pouvez également installer `libc++` et `lld` si vous savez ce que c'est. Utiliser `ccache` est également recommandé. - -# Le processus de construction {#the-building-process} - -Maintenant que vous êtes prêt à construire ClickHouse nous vous conseillons de créer un répertoire séparé `build` à l'intérieur de `ClickHouse` qui contiendra tous les artefacts de construction: - - mkdir build - cd build - -Vous pouvez avoir plusieurs répertoires différents (build\_release, build\_debug, etc.) pour les différents types de construction. - -Tandis qu'à l'intérieur de la `build` répertoire, configurez votre build en exécutant CMake. Avant la première exécution, vous devez définir des variables d'environnement qui spécifient le compilateur (compilateur gcc version 9 dans cet exemple). - -Linux: - - export CC=gcc-9 CXX=g++-9 - cmake .. - -Mac OS X: - - export CC=clang CXX=clang++ - cmake .. - -Le `CC` variable spécifie le compilateur pour C (abréviation de compilateur C), et `CXX` variable indique quel compilateur C++ doit être utilisé pour la construction. - -Pour une version plus rapide, vous pouvez recourir à l' `debug` build type - Une construction sans optimisations. Pour cela fournissez le paramètre suivant `-D CMAKE_BUILD_TYPE=Debug`: - - cmake -D CMAKE_BUILD_TYPE=Debug .. - -Vous pouvez modifier le type de génération en exécutant cette commande dans le `build` répertoire. - -Exécutez ninja pour construire: - - ninja clickhouse-server clickhouse-client - -Seules les binaires vont être construites dans cet exemple. - -Si vous avez besoin de construire tous les binaires (utilitaires et tests), vous devez exécuter ninja sans paramètres: - - ninja - -La construction complète nécessite environ 30 Go d'espace disque libre ou 15 Go pour construire les binaires principaux. - -Lorsqu'une grande quantité de RAM est disponible sur la machine de construction vous devez limiter le nombre de tâches de construction exécutées en parallèle avec `-j` param: - - ninja -j 1 clickhouse-server clickhouse-client - -Sur les machines avec 4 Go de RAM, il est recommandé de spécifier 1, pour 8 Go de RAM `-j 2` est recommandé. - -Si vous recevez le message: `ninja: error: loading 'build.ninja': No such file or directory`, cela signifie que la génération d'une configuration de construction a échoué et que vous devez inspecter le message ci-dessus. - -Après le démarrage réussi du processus de construction, vous verrez la progression de la construction - le nombre de tâches traitées et le nombre total de tâches. - -Lors de la construction de messages sur les fichiers protobuf dans la bibliothèque libhdfs2 comme `libprotobuf WARNING` peuvent apparaître. Ils touchent rien et sont sûrs d'être ignoré. - -Lors de la construction, vous obtenez un fichier exécutable `ClickHouse//programs/clickhouse`: - - ls -l programs/clickhouse - -# Exécution de L'exécutable construit de ClickHouse {#running-the-built-executable-of-clickhouse} - -Pour exécuter le serveur sous l'utilisateur actuel vous devez naviguer vers `ClickHouse/programs/server/` (situé à l'extérieur de `build` et les exécuter: - - ../../../build/programs/clickhouse server - -Dans ce cas, ClickHouse utilisera les fichiers de configuration situés dans le répertoire courant. Vous pouvez l'exécuter `clickhouse server` depuis n'importe quel répertoire spécifiant le chemin d'accès à un fichier de configuration en tant que paramètre de ligne de commande `--config-file`. - -Pour vous connecter à ClickHouse avec clickhouse-client dans un autre terminal, accédez à `ClickHouse/build/programs/` et exécuter `clickhouse client`. - -Si vous obtenez `Connection refused` message sur Mac OS X ou FreeBSD, essayez de spécifier l'adresse hôte 127.0.0.1: - - clickhouse client --host 127.0.0.1 - -Vous pouvez remplacer la version de production de clickhouse binary installée dans votre système par votre clickhouse Binary sur mesure. Pour ce faire, installez ClickHouse sur votre machine en suivant les instructions du site officiel. Ensuite, exécutez ce qui suit: - - sudo service clickhouse-server stop - sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ - sudo service clickhouse-server start - -Notez que `clickhouse-client`, `clickhouse-server` et d'autres sont des liens symboliques à la commune `clickhouse` binaire. - -Vous pouvez également exécuter votre binaire ClickHouse personnalisé avec le fichier de configuration du package clickhouse installé sur votre système: - - sudo service clickhouse-server stop - sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml - -# IDE (environnement de développement intégré) {#ide-integrated-development-environment} - -Si vous ne savez pas quel IDE utiliser, nous vous recommandons D'utiliser CLion. CLion est un logiciel commercial, mais il offre une période d'essai gratuite de 30 jours. Il est également gratuit pour les étudiants. CLion peut être utilisé à la fois sur Linux et sur Mac OS X. - -KDevelop et QTCreator sont d'autres grandes alternatives D'un IDE pour développer ClickHouse. KDevelop est un IDE très pratique bien qu'instable. Si KDevelop se bloque après un certain temps lors de l'ouverture du projet, vous devez cliquer sur “Stop All” bouton dès qu'il a ouvert la liste des fichiers du projet. Après cela, KDevelop devrait être bien pour travailler avec. - -En tant qu'éditeurs de code simples, vous pouvez utiliser Sublime Text ou Visual Studio Code, ou Kate (qui sont tous disponibles sur Linux). - -Juste au cas où, il convient de mentionner que CLion crée `build` chemin sur son propre, il aussi sur son propre sélectionne `debug` pour le type de construction, pour la configuration, il utilise une version de CMake définie dans CLion et non celle installée par vous, et enfin, CLion utilisera `make` pour exécuter construire des tâches au lieu de `ninja`. C'est un comportement normal, gardez cela à l'esprit pour éviter toute confusion. - -# L'Écriture De Code {#writing-code} - -La description de l'architecture ClickHouse peut être trouvée ici: https://clickhouse.tech/docs/fr/développement/architecture/ - -Le code Style Guide: https://clickhouse.tech/docs/fr/développement/style/ - -Rédaction de tests: https://clickhouse.tech/docs/fr/développement/tests/ - -Liste des tâches: https://github.com/ClickHouse/ClickHouse/blob/master/testsructions/easy\_tasks\_sorted\_en.md - -# Des Données De Test {#test-data} - -Le développement de ClickHouse nécessite souvent le chargement d'ensembles de données réalistes. Il est particulièrement important pour les tests de performance. Nous avons un ensemble spécialement préparé de données anonymisées de Yandex.Metrica. Il nécessite en outre quelques 3 Go d'espace disque libre. Notez que ces données ne sont pas requises pour accomplir la plupart des tâches de développement. - - sudo apt install wget xz-utils - - wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz - wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz - - xz -v -d hits_v1.tsv.xz - xz -v -d visits_v1.tsv.xz - - clickhouse-client - - CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); - - CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); - - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv - -# La Création De Pull Request {#creating-pull-request} - -Accédez à votre référentiel fork dans L'interface utilisateur de GitHub. Si vous avez développé dans une branche, vous devez sélectionner cette branche. Il y aura un “Pull request” bouton situé sur l'écran. En substance, cela signifie “create a request for accepting my changes into the main repository”. - -Une demande d'extraction peuvent être créés, même si le travail n'est pas encore terminée. Dans ce cas veuillez mettre le mot “WIP” (travaux en cours) au début du titre, il peut être modifié plus tard. Ceci est utile pour l'examen coopératif et la discussion des changements ainsi que pour l'exécution de tous les tests disponibles. Il est important que vous fournissiez une brève description de vos modifications, il sera ensuite utilisé pour générer des journaux de modifications de version. - -Les tests commenceront dès que les employés de Yandex étiqueteront votre PR avec une étiquette “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. - -Le système préparera les builds binaires ClickHouse pour votre demande de tirage individuellement. Pour récupérer ces versions cliquez sur le “Details” lien à côté “ClickHouse build check” entrée dans la liste de vérifications. Vous y trouverez des liens directs vers les construit .paquets deb de ClickHouse que vous pouvez déployer même sur vos serveurs de production (si vous n'avez pas peur). - -Très probablement, certaines des constructions échoueront à la première fois. Cela est dû au fait que nous avons vérifier s'appuie à la fois avec gcc, ainsi qu'avec clang, pratiquement tous les avertissements existants (toujours avec le `-Werror` drapeau) activé pour clang. Sur cette même page, vous pouvez trouver tous les journaux de construction afin que vous n'ayez pas à construire ClickHouse de toutes les manières possibles. diff --git a/docs/fr/development/index.md b/docs/fr/development/index.md index 1461fcae7bb..6a6dbe34dda 100644 --- a/docs/fr/development/index.md +++ b/docs/fr/development/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Development +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "D\xE9veloppement" toc_hidden: true toc_priority: 58 toc_title: "cach\xE9s" diff --git a/docs/fr/development/style.md b/docs/fr/development/style.md index 606e6af920e..ef50570fbdf 100644 --- a/docs/fr/development/style.md +++ b/docs/fr/development/style.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 68 toc_title: "Comment \xE9crire du Code C++ " --- diff --git a/docs/fr/development/tests.md b/docs/fr/development/tests.md index 6637e9546fe..c059472bb0c 100644 --- a/docs/fr/development/tests.md +++ b/docs/fr/development/tests.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 69 toc_title: "Comment ex\xE9cuter des Tests ClickHouse" --- @@ -34,7 +34,7 @@ sens. `long` est pour les tests qui s'exécutent légèrement plus longtemps qu' désactivez ces groupes de tests en utilisant `--no-zookeeper`, `--no-shard` et `--no-long` options, respectivement. -## Bugs connus {#known-bugs} +## Bugs Connus {#known-bugs} Si nous connaissons des bugs qui peuvent être facilement reproduits par des tests fonctionnels, nous plaçons des tests fonctionnels préparés dans `tests/queries/bugs` répertoire. Ces tests seront déplacés à `tests/queries/0_stateless` quand les bugs sont corrigés. @@ -56,17 +56,17 @@ Ce n'est pas nécessairement d'avoir des tests unitaires si le code est déjà c Les tests de Performance permettent de mesurer et de comparer les performances d'une partie isolée de ClickHouse sur des requêtes synthétiques. Les Tests sont situés à `tests/performance`. Chaque test est représenté par `.xml` fichier avec description du cas de test. Les Tests sont exécutés avec `clickhouse performance-test` outil (qui est incorporé dans `clickhouse` binaire). Voir `--help` pour l'invocation. -Chaque essai un ou miltiple requêtes (éventuellement avec des combinaisons de paramètres) dans une boucle avec certaines conditions pour l'arrêt (comme “maximum execution speed is not changing in three seconds”) et mesurer certaines mesures sur les performances de la requête (comme “maximum execution speed”). Certains tests peuvent contenir des conditions préalables sur un ensemble de données de test préchargé. +Chaque essai d'exécuter une ou plusieurs requêtes (éventuellement avec des combinaisons de paramètres) dans une boucle avec certaines conditions pour l'arrêt (comme “maximum execution speed is not changing in three seconds”) et mesurer certaines mesures sur les performances de la requête (comme “maximum execution speed”). Certains tests peuvent contenir des conditions préalables sur un ensemble de données de test préchargé. Si vous souhaitez améliorer les performances de ClickHouse dans certains scénarios, et si des améliorations peuvent être observées sur des requêtes simples, il est fortement recommandé d'écrire un test de performance. Il est toujours logique d'utiliser `perf top` ou d'autres outils perf pendant vos tests. -## Outils Et Scripts De Test {#test-tools-and-scripts} +## Outils et Scripts de Test {#test-tools-and-scripts} -Certains programmes dans `tests` directory ne sont pas des tests préparés, mais sont des outils de test. Par exemple, pour `Lexer` il est un outil `dbms/Parsers/tests/lexer` Cela fait juste la tokenisation de stdin et écrit le résultat colorisé dans stdout. Vous pouvez utiliser ce genre d'outils comme exemples de code et pour l'exploration et les tests manuels. +Certains programmes dans `tests` directory ne sont pas des tests préparés, mais sont des outils de test. Par exemple, pour `Lexer` il est un outil `src/Parsers/tests/lexer` Cela fait juste la tokenisation de stdin et écrit le résultat colorisé dans stdout. Vous pouvez utiliser ce genre d'outils comme exemples de code et pour l'exploration et les tests manuels. Vous pouvez également placer une paire de fichiers `.sh` et `.reference` avec l'outil pour l'exécuter sur une entrée prédéfinie - alors le résultat du script peut être comparé à `.reference` fichier. Ce genre de tests ne sont pas automatisés. -## Tests Divers {#miscellanous-tests} +## Divers Tests {#miscellaneous-tests} Il existe des tests pour les dictionnaires externes situés à `tests/external_dictionaries` et pour machine appris modèles dans `tests/external_models`. Ces tests ne sont pas mis à jour et doivent être transférés aux tests d'intégration. @@ -165,11 +165,11 @@ Par exemple, construire avec des paquets système est une mauvaise pratique, car Bien que nous ne puissions pas exécuter tous les tests sur toutes les variantes de builds, nous voulons vérifier au moins que les différentes variantes de build ne sont pas cassées. Pour cela nous utilisons les essais de construction. -## Test De Compatibilité Du Protocole {#testing-for-protocol-compatibility} +## Test de compatibilité du protocole {#testing-for-protocol-compatibility} Lorsque nous étendons le protocole réseau ClickHouse, nous testons manuellement que l'ancien clickhouse-client fonctionne avec le nouveau clickhouse-server et que le nouveau clickhouse-client fonctionne avec l'ancien clickhouse-server (simplement en exécutant des binaires à partir des paquets correspondants). -## L'Aide Du Compilateur {#help-from-the-compiler} +## L'aide du Compilateur {#help-from-the-compiler} Code ClickHouse principal (qui est situé dans `dbms` annuaire) est construit avec `-Wall -Wextra -Werror` et avec quelques avertissements supplémentaires activés. Bien que ces options ne soient pas activées pour les bibliothèques tierces. @@ -199,13 +199,23 @@ Version de débogage de `jemalloc` est utilisé pour la construction de débogag ## Fuzzing {#fuzzing} -Nous utilisons un simple test fuzz pour générer des requêtes SQL aléatoires et vérifier que le serveur ne meurt pas. Le test de Fuzz est effectué avec un désinfectant D'adresse. Vous pouvez le trouver dans `00746_sql_fuzzy.pl`. Ce test doit être exécuté en continu (pendant la nuit et plus longtemps). +Clickhouse fuzzing est implémenté à la fois en utilisant [libFuzzer](https://llvm.org/docs/LibFuzzer.html) et des requêtes SQL aléatoires. +Tous les tests de fuzz doivent être effectués avec des désinfectants (adresse et indéfini). -En décembre 2018, nous n'utilisons toujours pas de tests fuzz isolés du code de la bibliothèque. +LibFuzzer est utilisé pour les tests de fuzz isolés du code de la bibliothèque. Les Fuzzers sont implémentés dans le cadre du code de test et ont “\_fuzzer” nom postfixes. +Exemple Fuzzer peut être trouvé à `src/Parsers/tests/lexer_fuzzer.cpp`. Les configs, dictionnaires et corpus spécifiques à LibFuzzer sont stockés à `tests/fuzz`. +Nous vous encourageons à écrire des tests fuzz pour chaque fonctionnalité qui gère l'entrée de l'utilisateur. + +Fuzzers ne sont pas construits par défaut. Pour construire fuzzers à la fois `-DENABLE_FUZZING=1` et `-DENABLE_TESTS=1` options doivent être définies. +Nous vous recommandons de désactiver Jemalloc lors de la construction de fuzzers. Configuration utilisée pour intégrer clickhouse fuzzing à +Google OSS-Fuzz peut être trouvé à `docker/fuzz`. + +Nous utilisons également un simple test fuzz pour générer des requêtes SQL aléatoires et vérifier que le serveur ne meurt pas en les exécutant. +Vous pouvez le trouver dans `00746_sql_fuzzy.pl`. Ce test doit être exécuté en continu (pendant la nuit et plus longtemps). ## Audit De Sécurité {#security-audit} -Les gens du Département Cloud de Yandex font un aperçu de base des capacités de ClickHouse du point de vue de la sécurité. +Les gens de L'équipe de sécurité Yandex font un aperçu de base des capacités de ClickHouse du point de vue de la sécurité. ## Analyseurs Statiques {#static-analyzers} @@ -249,4 +259,3 @@ Nous n'utilisons pas Travis CI en raison de la limite de temps et de puissance d On n'utilise pas Jenkins. Il a été utilisé avant et maintenant nous sommes heureux de ne pas utiliser Jenkins. [Article Original](https://clickhouse.tech/docs/en/development/tests/) -développement/tests/) diff --git a/docs/fr/engines/database-engines/index.md b/docs/fr/engines/database-engines/index.md new file mode 100644 index 00000000000..a5b08b63453 --- /dev/null +++ b/docs/fr/engines/database-engines/index.md @@ -0,0 +1,21 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Moteurs De Base De Donn\xE9es" +toc_priority: 27 +toc_title: Introduction +--- + +# Moteurs De Base De Données {#database-engines} + +Moteurs de base de données vous permettent de travailler avec des tables. + +Par défaut, ClickHouse utilise son moteur de base de données natif, qui fournit [moteurs de table](../../engines/table-engines/index.md) et un [Dialecte SQL](../../sql-reference/syntax.md). + +Vous pouvez également utiliser les moteurs de base de données suivants: + +- [MySQL](mysql.md) + +- [Paresseux](lazy.md) + +[Article Original](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/fr/engines/database-engines/lazy.md b/docs/fr/engines/database-engines/lazy.md new file mode 100644 index 00000000000..545936ae861 --- /dev/null +++ b/docs/fr/engines/database-engines/lazy.md @@ -0,0 +1,18 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: Paresseux +--- + +# Paresseux {#lazy} + +Conserve les tables en RAM uniquement `expiration_time_in_seconds` secondes après le dernier accès. Peut être utilisé uniquement avec les tables \* Log. + +Il est optimisé pour stocker de nombreuses petites tables \*Log, pour lesquelles il y a un long intervalle de temps entre les accès. + +## La création d'une Base de données {#creating-a-database} + + CREATE DATABASE testlazy ENGINE = Lazy(expiration_time_in_seconds); + +[Article Original](https://clickhouse.tech/docs/en/database_engines/lazy/) diff --git a/docs/fr/engines/database-engines/mysql.md b/docs/fr/engines/database-engines/mysql.md new file mode 100644 index 00000000000..b40c8961b92 --- /dev/null +++ b/docs/fr/engines/database-engines/mysql.md @@ -0,0 +1,135 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 30 +toc_title: MySQL +--- + +# MySQL {#mysql} + +Permet de se connecter à des bases de données sur un serveur MySQL distant et `INSERT` et `SELECT` requêtes pour échanger des données entre Clickhouse et MySQL. + +Le `MySQL` moteur de base de données traduire les requêtes sur le serveur MySQL afin que vous puissiez effectuer des opérations telles que `SHOW TABLES` ou `SHOW CREATE TABLE`. + +Vous ne pouvez pas effectuer les requêtes suivantes: + +- `RENAME` +- `CREATE TABLE` +- `ALTER` + +## La création d'une Base de données {#creating-a-database} + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] +ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') +``` + +**Les Paramètres Du Moteur** + +- `host:port` — MySQL server address. +- `database` — Remote database name. +- `user` — MySQL user. +- `password` — User password. + +## Types De Données Soutien {#data_types-support} + +| MySQL | ClickHouse | +|----------------------------------|--------------------------------------------------------------| +| UNSIGNED TINYINT | [UInt8](../../sql-reference/data-types/int-uint.md) | +| TINYINT | [Int8](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED SMALLINT | [UInt16](../../sql-reference/data-types/int-uint.md) | +| SMALLINT | [Int16](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../sql-reference/data-types/int-uint.md) | +| INT, MEDIUMINT | [Int32](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED BIGINT | [UInt64](../../sql-reference/data-types/int-uint.md) | +| BIGINT | [Int64](../../sql-reference/data-types/int-uint.md) | +| FLOAT | [Float32](../../sql-reference/data-types/float.md) | +| DOUBLE | [Float64](../../sql-reference/data-types/float.md) | +| DATE | [Date](../../sql-reference/data-types/date.md) | +| DATETIME, TIMESTAMP | [DateTime](../../sql-reference/data-types/datetime.md) | +| BINARY | [FixedString](../../sql-reference/data-types/fixedstring.md) | + +Tous les autres types de données MySQL sont convertis en [Chaîne](../../sql-reference/data-types/string.md). + +[Nullable](../../sql-reference/data-types/nullable.md) est pris en charge. + +## Exemples D'utilisation {#examples-of-use} + +Table dans MySQL: + +``` text +mysql> USE test; +Database changed + +mysql> CREATE TABLE `mysql_table` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `float` FLOAT NOT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from mysql_table; ++------+-----+ +| int_id | value | ++------+-----+ +| 1 | 2 | ++------+-----+ +1 row in set (0,00 sec) +``` + +Base de données dans ClickHouse, échange de données avec le serveur MySQL: + +``` sql +CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') +``` + +``` sql +SHOW DATABASES +``` + +``` text +┌─name─────┐ +│ default │ +│ mysql_db │ +│ system │ +└──────────┘ +``` + +``` sql +SHOW TABLES FROM mysql_db +``` + +``` text +┌─name─────────┐ +│ mysql_table │ +└──────────────┘ +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +└────────┴───────┘ +``` + +``` sql +INSERT INTO mysql_db.mysql_table VALUES (3,4) +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +│ 3 │ 4 │ +└────────┴───────┘ +``` + +[Article Original](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/fr/engines/database_engines/index.md b/docs/fr/engines/database_engines/index.md deleted file mode 100644 index 5b019ef4e75..00000000000 --- a/docs/fr/engines/database_engines/index.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Database Engines -toc_priority: 27 -toc_title: Introduction ---- - -# Moteurs De Base De Données {#database-engines} - -Moteurs de base de données vous permettent de travailler avec des tables. - -Par défaut, ClickHouse utilise son moteur de base de données natif, qui fournit [moteurs de table](../../engines/table_engines/index.md) et un [Dialecte SQL](../../sql_reference/syntax.md). - -Vous pouvez également utiliser les moteurs de base de données suivants: - -- [MySQL](mysql.md) - -- [Paresseux](lazy.md) - -[Article Original](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/fr/engines/database_engines/lazy.md b/docs/fr/engines/database_engines/lazy.md deleted file mode 100644 index 77a2cb15dde..00000000000 --- a/docs/fr/engines/database_engines/lazy.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 31 -toc_title: Paresseux ---- - -# Paresseux {#lazy} - -Conserve les tables en RAM uniquement `expiration_time_in_seconds` secondes après le dernier accès. Peut être utilisé uniquement avec les tables \* Log. - -Il est optimisé pour stocker de nombreuses petites tables \*Log, pour lesquelles il y a un long intervalle de temps entre les accès. - -## La création d'une Base de données {#creating-a-database} - - CREATE DATABASE testlazy ENGINE = Lazy(expiration_time_in_seconds); - -[Article Original](https://clickhouse.tech/docs/en/database_engines/lazy/) diff --git a/docs/fr/engines/database_engines/mysql.md b/docs/fr/engines/database_engines/mysql.md deleted file mode 100644 index ebe50498967..00000000000 --- a/docs/fr/engines/database_engines/mysql.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 30 -toc_title: MySQL ---- - -# Mysql {#mysql} - -Permet de se connecter à des bases de données sur un serveur MySQL distant et `INSERT` et `SELECT` requêtes pour échanger des données entre Clickhouse et MySQL. - -Le `MySQL` moteur de base de données traduire les requêtes sur le serveur MySQL afin que vous puissiez effectuer des opérations telles que `SHOW TABLES` ou `SHOW CREATE TABLE`. - -Vous ne pouvez pas effectuer les requêtes suivantes: - -- `RENAME` -- `CREATE TABLE` -- `ALTER` - -## La création d'une Base de données {#creating-a-database} - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] -ENGINE = MySQL('host:port', 'database', 'user', 'password') -``` - -**Les Paramètres Du Moteur** - -- `host:port` — MySQL server address. -- `database` — Remote database name. -- `user` — MySQL user. -- `password` — User password. - -## Types De Données Soutien {#data_types-support} - -| MySQL | ClickHouse | -|----------------------------------|--------------------------------------------------------------| -| UNSIGNED TINYINT | [UInt8](../../sql_reference/data_types/int_uint.md) | -| TINYINT | [Int8](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED SMALLINT | [UInt16](../../sql_reference/data_types/int_uint.md) | -| SMALLINT | [Int16](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../sql_reference/data_types/int_uint.md) | -| INT, MEDIUMINT | [Int32](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED BIGINT | [UInt64](../../sql_reference/data_types/int_uint.md) | -| BIGINT | [Int64](../../sql_reference/data_types/int_uint.md) | -| FLOAT | [Float32](../../sql_reference/data_types/float.md) | -| DOUBLE | [Float64](../../sql_reference/data_types/float.md) | -| DATE | [Date](../../sql_reference/data_types/date.md) | -| DATETIME, TIMESTAMP | [DateTime](../../sql_reference/data_types/datetime.md) | -| BINARY | [FixedString](../../sql_reference/data_types/fixedstring.md) | - -Tous les autres types de données MySQL sont convertis en [Chaîne](../../sql_reference/data_types/string.md). - -[Nullable](../../sql_reference/data_types/nullable.md) est pris en charge. - -## Exemples D'Utilisation {#examples-of-use} - -Table dans MySQL: - -``` text -mysql> USE test; -Database changed - -mysql> CREATE TABLE `mysql_table` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `float` FLOAT NOT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from mysql_table; -+------+-----+ -| int_id | value | -+------+-----+ -| 1 | 2 | -+------+-----+ -1 row in set (0,00 sec) -``` - -Base de données dans ClickHouse, échange de données avec le serveur MySQL: - -``` sql -CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') -``` - -``` sql -SHOW DATABASES -``` - -``` text -┌─name─────┐ -│ default │ -│ mysql_db │ -│ system │ -└──────────┘ -``` - -``` sql -SHOW TABLES FROM mysql_db -``` - -``` text -┌─name─────────┐ -│ mysql_table │ -└──────────────┘ -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -└────────┴───────┘ -``` - -``` sql -INSERT INTO mysql_db.mysql_table VALUES (3,4) -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -│ 3 │ 4 │ -└────────┴───────┘ -``` - -[Article Original](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/fr/engines/index.md b/docs/fr/engines/index.md index af36619876c..3dfb7bf3748 100644 --- a/docs/fr/engines/index.md +++ b/docs/fr/engines/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Engines +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Moteur toc_priority: 25 --- diff --git a/docs/fr/engines/table-engines/index.md b/docs/fr/engines/table-engines/index.md new file mode 100644 index 00000000000..a05ab19868c --- /dev/null +++ b/docs/fr/engines/table-engines/index.md @@ -0,0 +1,85 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Moteurs De Table +toc_priority: 26 +toc_title: Introduction +--- + +# Moteurs De Table {#table_engines} + +Le moteur de table (type de table) détermine: + +- Comment et où les données sont stockées, où les écrire et où les lire. +- Quelles requêtes sont prises en charge et comment. +- Accès simultané aux données. +- Utilisation des index, si elle est présente. +- Indique si l'exécution d'une requête multithread est possible. +- Paramètres de réplication des données. + +## Familles De Moteurs {#engine-families} + +### MergeTree {#mergetree} + +Les moteurs de table les plus universels et fonctionnels pour les tâches à forte charge. La propriété partagée par ces moteurs est l'insertion rapide des données avec traitement ultérieur des données d'arrière-plan. `MergeTree` les moteurs de la famille prennent en charge la réplication des données (avec [Répliqué\*](mergetree-family/replication.md#table_engines-replication) versions de moteurs), le partitionnement, et d'autres fonctionnalités non prises en charge dans d'autres moteurs. + +Moteurs dans la famille: + +- [MergeTree](mergetree-family/mergetree.md#mergetree) +- [ReplacingMergeTree](mergetree-family/replacingmergetree.md#replacingmergetree) +- [SummingMergeTree](mergetree-family/summingmergetree.md#summingmergetree) +- [AggregatingMergeTree](mergetree-family/aggregatingmergetree.md#aggregatingmergetree) +- [CollapsingMergeTree](mergetree-family/collapsingmergetree.md#table_engine-collapsingmergetree) +- [VersionedCollapsingMergeTree](mergetree-family/versionedcollapsingmergetree.md#versionedcollapsingmergetree) +- [GraphiteMergeTree](mergetree-family/graphitemergetree.md#graphitemergetree) + +### Journal {#log} + +Léger [moteur](log-family/index.md) avec une fonctionnalité minimale. Ils sont les plus efficaces lorsque vous devez écrire rapidement de nombreuses petites tables (jusqu'à environ 1 million de lignes) et les lire plus tard dans leur ensemble. + +Moteurs dans la famille: + +- [TinyLog](log-family/tinylog.md#tinylog) +- [StripeLog](log-family/stripelog.md#stripelog) +- [Journal](log-family/log.md#log) + +### Moteurs D'Intégration {#integration-engines} + +Moteurs de communication avec d'autres systèmes de stockage et de traitement de données. + +Moteurs dans la famille: + +- [Kafka](integrations/kafka.md#kafka) +- [MySQL](integrations/mysql.md#mysql) +- [ODBC](integrations/odbc.md#table-engine-odbc) +- [JDBC](integrations/jdbc.md#table-engine-jdbc) +- [HDFS](integrations/hdfs.md#hdfs) + +### Moteurs Spéciaux {#special-engines} + +Moteurs dans la famille: + +- [Distribué](special/distributed.md#distributed) +- [MaterializedView](special/materializedview.md#materializedview) +- [Dictionnaire](special/dictionary.md#dictionary) +- \[Fusion\](spécial/de fusion.md\#fusion +- [Fichier](special/file.md#file) +- [NULL](special/null.md#null) +- [Définir](special/set.md#set) +- [Rejoindre](special/join.md#join) +- [URL](special/url.md#table_engines-url) +- [Vue](special/view.md#table_engines-view) +- [Mémoire](special/memory.md#memory) +- [Tampon](special/buffer.md#buffer) + +## Les Colonnes Virtuelles {#table_engines-virtual_columns} + +Colonne virtuelle est un attribut de moteur de table intégrale qui est défini dans le code source du moteur. + +Vous ne devez pas spécifier de colonnes virtuelles dans `CREATE TABLE` requête et vous ne pouvez pas les voir dans `SHOW CREATE TABLE` et `DESCRIBE TABLE` les résultats de la requête. Les colonnes virtuelles sont également en lecture seule, vous ne pouvez donc pas insérer de données dans des colonnes virtuelles. + +Pour sélectionner des données dans une colonne virtuelle, vous devez spécifier son nom `SELECT` requête. `SELECT *` ne renvoie pas de valeurs à partir de colonnes virtuelles. + +Si vous créez une table avec une colonne portant le même nom que l'une des colonnes virtuelles de la table, la colonne virtuelle devient inaccessible. Nous ne recommandons pas de faire cela. Pour éviter les conflits, les noms de colonnes virtuelles sont généralement précédés d'un trait de soulignement. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/fr/engines/table-engines/integrations/hdfs.md b/docs/fr/engines/table-engines/integrations/hdfs.md new file mode 100644 index 00000000000..fd207793b02 --- /dev/null +++ b/docs/fr/engines/table-engines/integrations/hdfs.md @@ -0,0 +1,123 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: HDFS +--- + +# HDFS {#table_engines-hdfs} + +Ce moteur fournit l'intégration avec [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) l'écosystème en permettant de gérer les données sur [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)via ClickHouse. Ce moteur est similaire +à l' [Fichier](../special/file.md#table_engines-file) et [URL](../special/url.md#table_engines-url) moteurs, mais fournit des fonctionnalités spécifiques Hadoop. + +## Utilisation {#usage} + +``` sql +ENGINE = HDFS(URI, format) +``` + +Le `URI` paramètre est L'URI du fichier entier dans HDFS. +Le `format` paramètre spécifie l'un des formats de fichier disponibles. Effectuer +`SELECT` requêtes, le format doit être pris en charge pour l'entrée, et à effectuer +`INSERT` queries – for output. The available formats are listed in the +[Format](../../../interfaces/formats.md#formats) section. +Le chemin le cadre de `URI` peut contenir des globules. Dans ce cas, le tableau serait en lecture seule. + +**Exemple:** + +**1.** Configurer le `hdfs_engine_table` table: + +``` sql +CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') +``` + +**2.** Remplir le fichier: + +``` sql +INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) +``` + +**3.** Interroger les données: + +``` sql +SELECT * FROM hdfs_engine_table LIMIT 2 +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Détails De Mise En Œuvre {#implementation-details} + +- Les lectures et les écritures peuvent être parallèles +- Pas pris en charge: + - `ALTER` et `SELECT...SAMPLE` opérations. + - Index. + - Réplication. + +**Globs dans le chemin** + +Plusieurs composants de chemin peuvent avoir des globs. Pour être traité, le fichier devrait exister et correspondre au modèle de chemin entier. Liste des fichiers détermine pendant `SELECT` (pas à l' `CREATE` moment). + +- `*` — Substitutes any number of any characters except `/` y compris la chaîne vide. +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +Les Constructions avec `{}` sont similaires à l' [distant](../../../sql-reference/table-functions/remote.md) table de fonction. + +**Exemple** + +1. Supposons que nous ayons plusieurs fichiers au format TSV avec les URI suivants sur HDFS: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. Il y a plusieurs façons de faire une table composée des six fichiers: + + + +``` sql +CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') +``` + +Une autre façon: + +``` sql +CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') +``` + +Table se compose de tous les fichiers dans les deux répertoires (tous les fichiers doivent satisfaire le format et le schéma décrits dans la requête): + +``` sql +CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') +``` + +!!! warning "Avertissement" + Si la liste des fichiers contient des plages de nombres avec des zéros en tête, utilisez la construction avec des accolades pour chaque chiffre séparément ou utilisez `?`. + +**Exemple** + +Créer une table avec des fichiers nommés `file000`, `file001`, … , `file999`: + +``` sql +CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') +``` + +## Les Colonnes Virtuelles {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**Voir Aussi** + +- [Les colonnes virtuelles](../index.md#table_engines-virtual_columns) + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/fr/engines/table-engines/integrations/index.md b/docs/fr/engines/table-engines/integrations/index.md new file mode 100644 index 00000000000..205b631880b --- /dev/null +++ b/docs/fr/engines/table-engines/integrations/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Int\xE9gration" +toc_priority: 30 +--- + + diff --git a/docs/fr/engines/table-engines/integrations/jdbc.md b/docs/fr/engines/table-engines/integrations/jdbc.md new file mode 100644 index 00000000000..e67209f2709 --- /dev/null +++ b/docs/fr/engines/table-engines/integrations/jdbc.md @@ -0,0 +1,90 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: JDBC +--- + +# JDBC {#table-engine-jdbc} + +Permet à ClickHouse de se connecter à des bases de données externes via [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). + +Pour implémenter la connexion JDBC, ClickHouse utilise le programme séparé [clickhouse-JDBC-pont](https://github.com/alex-krash/clickhouse-jdbc-bridge) cela devrait fonctionner comme un démon. + +Ce moteur prend en charge le [Nullable](../../../sql-reference/data-types/nullable.md) type de données. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name +( + columns list... +) +ENGINE = JDBC(dbms_uri, external_database, external_table) +``` + +**Les Paramètres Du Moteur** + +- `dbms_uri` — URI of an external DBMS. + + Format: `jdbc:://:/?user=&password=`. + Exemple pour MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. + +- `external_database` — Database in an external DBMS. + +- `external_table` — Name of the table in `external_database`. + +## Exemple D'Utilisation {#usage-example} + +Création d'une table dans le serveur MySQL en se connectant directement avec son client console: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Création d'une table dans le serveur ClickHouse et sélection des données: + +``` sql +CREATE TABLE jdbc_table +( + `int_id` Int32, + `int_nullable` Nullable(Int32), + `float` Float32, + `float_nullable` Nullable(Float32) +) +ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') +``` + +``` sql +SELECT * +FROM jdbc_table +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## Voir Aussi {#see-also} + +- [Fonction de table JDBC](../../../sql-reference/table-functions/jdbc.md). + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/fr/engines/table-engines/integrations/kafka.md b/docs/fr/engines/table-engines/integrations/kafka.md new file mode 100644 index 00000000000..d4a2de42f22 --- /dev/null +++ b/docs/fr/engines/table-engines/integrations/kafka.md @@ -0,0 +1,180 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: Kafka +--- + +# Kafka {#kafka} + +Ce moteur fonctionne avec [Apache Kafka](http://kafka.apache.org/). + +Kafka vous permet de: + +- Publier ou s'abonner aux flux de données. +- Organiser le stockage tolérant aux pannes. +- Traiter les flux à mesure qu'ils deviennent disponibles. + +## Création d'une Table {#table_engine-kafka-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = Kafka() +SETTINGS + kafka_broker_list = 'host:port', + kafka_topic_list = 'topic1,topic2,...', + kafka_group_name = 'group_name', + kafka_format = 'data_format'[,] + [kafka_row_delimiter = 'delimiter_symbol',] + [kafka_schema = '',] + [kafka_num_consumers = N,] + [kafka_max_block_size = 0,] + [kafka_skip_broken_messages = N,] + [kafka_commit_every_batch = 0] +``` + +Les paramètres requis: + +- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). +- `kafka_topic_list` – A list of Kafka topics. +- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don't want messages to be duplicated in the cluster, use the same group name everywhere. +- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` la fonction, tels que `JSONEachRow`. Pour plus d'informations, voir le [Format](../../../interfaces/formats.md) section. + +Paramètres facultatifs: + +- `kafka_row_delimiter` – Delimiter character, which ends the message. +- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap'n Proto](https://capnproto.org/) nécessite le chemin d'accès du fichier de schéma et le nom de la racine `schema.capnp:Message` objet. +- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Spécifiez plus de consommateurs si le débit d'un consommateur est insuffisant. Le nombre total de consommateurs ne doit pas dépasser le nombre de partitions dans la rubrique, car un seul consommateur peut être affecté par partition. +- `kafka_max_block_size` - La taille maximale du lot (dans les messages) pour le sondage (par défaut: `max_block_size`). +- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. Si `kafka_skip_broken_messages = N` puis le moteur saute *N* Messages Kafka qui ne peuvent pas être analysés (un message est égal à une ligne de données). +- `kafka_commit_every_batch` - Commit chaque lot consommé et traité au lieu d'un seul commit après avoir écrit un bloc entier (par défaut: `0`). + +Exemple: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + SELECT * FROM queue LIMIT 5; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', + kafka_topic_list = 'topic', + kafka_group_name = 'group1', + kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') + SETTINGS kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; +``` + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets. Si possible, optez anciens projets à la méthode décrite ci-dessus. + +``` sql +Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format + [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) +``` + +
+ +## Description {#description} + +Les messages livrés sont suivis automatiquement, de sorte que chaque message d'un groupe n'est compté qu'une seule fois. Si vous souhaitez obtenir les données deux fois, créez une copie de la table avec un autre nom de groupe. + +Les groupes sont flexibles et synchronisés sur le cluster. Par exemple, si vous avez 10 thèmes et 5 copies d'une table dans un cluster, chaque copie obtient 2 sujets. Si le nombre de copies change, les rubriques sont redistribuées automatiquement entre les copies. En savoir plus à ce sujet à http://kafka.apache.org/intro. + +`SELECT` n'est pas particulièrement utile pour la lecture de messages (sauf pour le débogage), car chaque message ne peut être lu qu'une seule fois. Il est plus pratique de créer des threads en temps réel à l'aide de vues matérialisées. Pour ce faire: + +1. Utilisez le moteur pour créer un consommateur Kafka et considérez-le comme un flux de données. +2. Créez une table avec la structure souhaitée. +3. Créer une vue matérialisée qui convertit les données du moteur et le met dans une table créée précédemment. + +Lorsque l' `MATERIALIZED VIEW` rejoint le moteur, il commence à collecter des données en arrière-plan. Cela vous permet de recevoir continuellement des messages de Kafka et de les convertir au format requis en utilisant `SELECT`. +Une table kafka peut avoir autant de vues matérialisées que vous le souhaitez, elles ne lisent pas directement les données de la table kafka, mais reçoivent de nouveaux enregistrements( en blocs), de cette façon vous pouvez écrire sur plusieurs tables avec différents niveaux de détail (avec regroupement - agrégation et sans). + +Exemple: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + CREATE TABLE daily ( + day Date, + level String, + total UInt64 + ) ENGINE = SummingMergeTree(day, (day, level), 8192); + + CREATE MATERIALIZED VIEW consumer TO daily + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + FROM queue GROUP BY day, level; + + SELECT level, sum(total) FROM daily GROUP BY level; +``` + +Pour améliorer les performances, les messages reçus sont regroupées en blocs de la taille de [max\_insert\_block\_size](../../../operations/server-configuration-parameters/settings.md#settings-max_insert_block_size). Si le bloc n'a pas été formé à l'intérieur [stream\_flush\_interval\_ms](../../../operations/server-configuration-parameters/settings.md) millisecondes, les données seront vidées dans le tableau, indépendamment de l'intégralité du bloc. + +Pour arrêter de recevoir des données de rubrique ou pour modifier la logique de conversion, détachez la vue matérialisée: + +``` sql + DETACH TABLE consumer; + ATTACH TABLE consumer; +``` + +Si vous souhaitez modifier la table cible en utilisant `ALTER`, nous vous recommandons de désactiver la vue matériel pour éviter les divergences entre la table cible et les données de la vue. + +## Configuration {#configuration} + +Similaire à GraphiteMergeTree, le moteur Kafka prend en charge la configuration étendue à l'aide du fichier de configuration ClickHouse. Il y a deux clés de configuration que vous pouvez utiliser: global (`kafka`) et des rubriques (`kafka_*`). La configuration globale est appliquée en premier, puis la configuration au niveau de la rubrique est appliquée (si elle existe). + +``` xml + + + cgrp + smallest + + + + + 250 + 100000 + +``` + +Pour obtenir une liste des options de configuration possibles, consultez [librdkafka référence de configuration](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Utilisez le trait de soulignement (`_`) au lieu d'un point dans la configuration ClickHouse. Exemple, `check.crcs=true` sera `true`. + +## Les Colonnes Virtuelles {#virtual-columns} + +- `_topic` — Kafka topic. +- `_key` — Key of the message. +- `_offset` — Offset of the message. +- `_timestamp` — Timestamp of the message. +- `_partition` — Partition of Kafka topic. + +**Voir Aussi** + +- [Les colonnes virtuelles](../index.md#table_engines-virtual_columns) + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/fr/engines/table-engines/integrations/mysql.md b/docs/fr/engines/table-engines/integrations/mysql.md new file mode 100644 index 00000000000..bc291e0aebe --- /dev/null +++ b/docs/fr/engines/table-engines/integrations/mysql.md @@ -0,0 +1,105 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: MySQL +--- + +# Mysql {#mysql} + +Le moteur MySQL vous permet d'effectuer `SELECT` requêtes sur les données stockées sur un serveur MySQL distant. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... +) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +Voir une description détaillée de la [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) requête. + +La structure de la table peut différer de la structure de la table MySQL d'origine: + +- Les noms de colonnes doivent être les mêmes que dans la table MySQL d'origine, mais vous pouvez utiliser seulement certaines de ces colonnes et dans n'importe quel ordre. +- Les types de colonnes peuvent différer de ceux de la table MySQL d'origine. ClickHouse essaie de [jeter](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) valeurs des types de données ClickHouse. + +**Les Paramètres Du Moteur** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` les requêtes de `REPLACE INTO`. Si `replace_query=1` la requête est substitué. + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expression qui est ajoutée à la `INSERT` requête. + + Exemple: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, où `on_duplicate_clause` être `UPDATE c2 = c2 + 1`. Voir la [Documentation de MySQL](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) pour trouver lequel `on_duplicate_clause` vous pouvez utiliser avec le `ON DUPLICATE KEY` clause. + + Spécifier `on_duplicate_clause` vous avez besoin de passer `0` à l' `replace_query` paramètre. Si vous passez simultanément `replace_query = 1` et `on_duplicate_clause`, Clickhouse génère une exception. + +Simple `WHERE` des clauses telles que `=, !=, >, >=, <, <=` sont exécutés sur le serveur MySQL. + +Le reste des conditions et le `LIMIT` les contraintes d'échantillonnage sont exécutées dans ClickHouse uniquement après la fin de la requête à MySQL. + +## Exemple D'Utilisation {#usage-example} + +Table dans MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Table dans ClickHouse, récupération des données de la table MySQL créée ci-dessus: + +``` sql +CREATE TABLE mysql_table +( + `float_nullable` Nullable(Float32), + `int_id` Int32 +) +ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` sql +SELECT * FROM mysql_table +``` + +``` text +┌─float_nullable─┬─int_id─┐ +│ ᴺᵁᴸᴸ │ 1 │ +└────────────────┴────────┘ +``` + +## Voir Aussi {#see-also} + +- [Le ‘mysql’ fonction de table](../../../sql-reference/table-functions/mysql.md) +- [Utilisation de MySQL comme source de dictionnaire externe](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/fr/engines/table-engines/integrations/odbc.md b/docs/fr/engines/table-engines/integrations/odbc.md new file mode 100644 index 00000000000..ee0ffb171d2 --- /dev/null +++ b/docs/fr/engines/table-engines/integrations/odbc.md @@ -0,0 +1,132 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: ODBC +--- + +# ODBC {#table-engine-odbc} + +Permet à ClickHouse de se connecter à des bases de données externes via [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +Pour implémenter en toute sécurité les connexions ODBC, ClickHouse utilise un programme distinct `clickhouse-odbc-bridge`. Si le pilote ODBC est chargé directement depuis `clickhouse-server`, les problèmes de pilote peuvent planter le serveur ClickHouse. Clickhouse démarre automatiquement `clickhouse-odbc-bridge` lorsque cela est nécessaire. Le programme ODBC bridge est installé à partir du même package que `clickhouse-server`. + +Ce moteur prend en charge le [Nullable](../../../sql-reference/data-types/nullable.md) type de données. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1], + name2 [type2], + ... +) +ENGINE = ODBC(connection_settings, external_database, external_table) +``` + +Voir une description détaillée de la [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) requête. + +La structure de la table peut différer de la structure de la table source: + +- Les noms de colonnes doivent être les mêmes que dans la table source, mais vous pouvez utiliser quelques-unes de ces colonnes et dans n'importe quel ordre. +- Les types de colonnes peuvent différer de ceux de la table source. ClickHouse essaie de [jeter](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) valeurs des types de données ClickHouse. + +**Les Paramètres Du Moteur** + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` fichier. +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +## Exemple D'Utilisation {#usage-example} + +**Récupération des données de L'installation MySQL locale via ODBC** + +Cet exemple est vérifié pour Ubuntu Linux 18.04 et MySQL server 5.7. + +Assurez-vous que unixODBC et MySQL Connector sont installés. + +Par défaut (si installé à partir de paquets), ClickHouse démarre en tant qu'utilisateur `clickhouse`. Ainsi, vous devez créer et configurer cet utilisateur dans le serveur MySQL. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +Puis configurez la connexion dans `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +Vous pouvez vérifier la connexion en utilisant le `isql` utilitaire de l'installation unixODBC. + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +Table dans MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Table dans ClickHouse, récupération des données de la table MySQL: + +``` sql +CREATE TABLE odbc_t +( + `int_id` Int32, + `float_nullable` Nullable(Float32) +) +ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') +``` + +``` sql +SELECT * FROM odbc_t +``` + +``` text +┌─int_id─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ +└────────┴────────────────┘ +``` + +## Voir Aussi {#see-also} + +- [Dictionnaires externes ODBC](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [Fonction de table ODBC](../../../sql-reference/table-functions/odbc.md) + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/fr/engines/table-engines/log-family/index.md b/docs/fr/engines/table-engines/log-family/index.md new file mode 100644 index 00000000000..9b94463744c --- /dev/null +++ b/docs/fr/engines/table-engines/log-family/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Journal De La Famille +toc_priority: 29 +--- + + diff --git a/docs/fr/engines/table-engines/log-family/log-family.md b/docs/fr/engines/table-engines/log-family/log-family.md new file mode 100644 index 00000000000..4ff840b9699 --- /dev/null +++ b/docs/fr/engines/table-engines/log-family/log-family.md @@ -0,0 +1,46 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: Introduction +--- + +# Famille De Moteurs En Rondins {#log-engine-family} + +Ces moteurs ont été développés pour les scénarios où vous devez écrire rapidement de nombreuses petites tables (jusqu'à environ 1 million de lignes) et les lire plus tard dans leur ensemble. + +Les moteurs de la famille: + +- [StripeLog](stripelog.md) +- [Journal](log.md) +- [TinyLog](tinylog.md) + +## Propriétés Communes {#common-properties} + +Moteur: + +- Stocker des données sur un disque. + +- Ajouter des données à la fin du fichier lors de l'écriture. + +- Bloque simultanées dans l'accès aux données. + + Lors `INSERT` requêtes, la table est verrouillée, et d'autres requêtes pour la lecture et l'écriture de données attendent que la table se déverrouille. S'il n'y a pas de requêtes d'écriture de données, un certain nombre de requêtes de lecture de données peuvent être effectuées simultanément. + +- Ne prennent pas en charge [mutation](../../../sql-reference/statements/alter.md#alter-mutations) opérations. + +- Ne prennent pas en charge les index. + + Cela signifie que `SELECT` les requêtes pour les plages de données ne sont pas efficaces. + +- N'écrivez pas de données de manière atomique. + + Vous pouvez obtenir une table avec des données corrompues si quelque chose interrompt l'opération d'écriture, par exemple, un arrêt anormal du serveur. + +## Différence {#differences} + +Le `TinyLog` le moteur est le plus simple de la famille et offre la fonctionnalité la plus pauvre et la plus faible efficacité. Le `TinyLog` le moteur ne prend pas en charge la lecture de données parallèles par plusieurs threads. Il lit les données plus lentement que les autres moteurs de la famille qui prennent en charge la lecture parallèle et utilise presque autant de descripteurs que `Log` moteur, car il stocke chaque colonne dans un fichier séparé. Utilisez-le dans des scénarios simples à faible charge. + +Le `Log` et `StripeLog` les moteurs prennent en charge la lecture de données parallèle. Lors de la lecture de données, ClickHouse utilise plusieurs threads. Chaque thread traite un bloc de données séparé. Le `Log` le moteur utilise un fichier distinct pour chaque colonne de la table. `StripeLog` stocke toutes les données dans un seul fichier. En conséquence, la `StripeLog` moteur utilise moins de descripteurs dans le système d'exploitation, mais le `Log` moteur fournit une plus grande efficacité lors de la lecture des données. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/fr/engines/table-engines/log-family/log.md b/docs/fr/engines/table-engines/log-family/log.md new file mode 100644 index 00000000000..33302e2b7f2 --- /dev/null +++ b/docs/fr/engines/table-engines/log-family/log.md @@ -0,0 +1,16 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: Journal +--- + +# Journal {#log} + +Moteur appartient à la famille de journal des moteurs. Voir les propriétés communes des moteurs de journal et leurs différences dans le [Famille De Moteurs En Rondins](log-family.md) article. + +Journal diffère de [TinyLog](tinylog.md) dans un petit fichier de “marks” réside avec les fichiers de colonne. Ces marques sont écrites sur chaque bloc de données et contiennent des décalages qui indiquent où commencer à lire le fichier afin d'ignorer le nombre de lignes spécifié. Cela permet de lire les données de table dans plusieurs threads. +Pour l'accès aux données simultanées, les opérations de lecture peuvent être effectuées simultanément, tandis que les opérations d'écriture bloc lit et l'autre. +Le moteur de journal ne prend pas en charge les index. De même, si l'écriture dans une table a échoué, la table est cassée et la lecture de celle-ci renvoie une erreur. Le moteur de journal est approprié pour les données temporaires, les tables en écriture unique, et à des fins de test ou de démonstration. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/fr/engines/table-engines/log-family/stripelog.md b/docs/fr/engines/table-engines/log-family/stripelog.md new file mode 100644 index 00000000000..390be1d34e3 --- /dev/null +++ b/docs/fr/engines/table-engines/log-family/stripelog.md @@ -0,0 +1,95 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: StripeLog +--- + +# Stripelog {#stripelog} + +Ce moteur appartient à la famille des moteurs en rondins. Voir les propriétés communes des moteurs de journal et leurs différences dans le [Famille De Moteurs En Rondins](log-family.md) article. + +Utilisez ce moteur dans des scénarios lorsque vous devez écrire de nombreuses tables avec une petite quantité de données (moins de 1 million de lignes). + +## Création d'une Table {#table_engines-stripelog-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = StripeLog +``` + +Voir la description détaillée de la [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) requête. + +## L'écriture des Données {#table_engines-stripelog-writing-the-data} + +Le `StripeLog` moteur stocke toutes les colonnes dans un fichier. Pour chaque `INSERT` requête, ClickHouse ajoute le bloc de données à la fin d'un fichier de table, en écrivant des colonnes une par une. + +Pour chaque table ClickHouse écrit les fichiers: + +- `data.bin` — Data file. +- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. + +Le `StripeLog` moteur ne prend pas en charge la `ALTER UPDATE` et `ALTER DELETE` opérations. + +## La lecture des Données {#table_engines-stripelog-reading-the-data} + +Le fichier avec des marques permet à ClickHouse de paralléliser la lecture des données. Cela signifie qu'une `SELECT` la requête renvoie des lignes dans un ordre imprévisible. L'utilisation de la `ORDER BY` clause pour trier les lignes. + +## Exemple D'utilisation {#table_engines-stripelog-example-of-use} + +Création d'une table: + +``` sql +CREATE TABLE stripe_log_table +( + timestamp DateTime, + message_type String, + message String +) +ENGINE = StripeLog +``` + +Insertion de données: + +``` sql +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') +``` + +Nous avons utilisé deux `INSERT` requêtes pour créer deux blocs de données `data.bin` fichier. + +ClickHouse utilise plusieurs threads lors de la sélection des données. Chaque thread lit un bloc de données séparé et renvoie les lignes résultantes indépendamment à la fin. En conséquence, l'ordre des blocs de lignes dans le résultat ne correspond pas à l'ordre des mêmes blocs dans l'entrée, dans la plupart des cas. Exemple: + +``` sql +SELECT * FROM stripe_log_table +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +┌───────────timestamp─┬─message_type─┬─message───────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +└─────────────────────┴──────────────┴───────────────────────────┘ +``` + +Trier les résultats (ordre croissant par défaut): + +``` sql +SELECT * FROM stripe_log_table ORDER BY timestamp +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +``` + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/fr/engines/table-engines/log-family/tinylog.md b/docs/fr/engines/table-engines/log-family/tinylog.md new file mode 100644 index 00000000000..54292730851 --- /dev/null +++ b/docs/fr/engines/table-engines/log-family/tinylog.md @@ -0,0 +1,16 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: TinyLog +--- + +# TinyLog {#tinylog} + +Le moteur appartient à la famille de moteurs en rondins. Voir [Famille De Moteurs En Rondins](log-family.md) pour les propriétés communes des moteurs en rondins et leurs différences. + +Ce moteur de table est généralement utilisé avec la méthode write-once: écrivez des données une fois, puis lisez-les autant de fois que nécessaire. Par exemple, vous pouvez utiliser `TinyLog`- tapez des tables pour les données intermédiaires qui sont traitées en petits lots. Notez que le stockage des données dans un grand nombre de petites tables est inefficace. + +Les requêtes sont exécutées dans un flux unique. En d'autres termes, ce moteur est destiné à des tables relativement petites (jusqu'à environ 1 000 000 de lignes). Il est logique d'utiliser ce moteur de table si vous avez beaucoup de petites tables, car il est plus simple que le [Journal](log.md) moteur (moins de fichiers doivent être ouverts). + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/fr/engines/table-engines/mergetree-family/aggregatingmergetree.md b/docs/fr/engines/table-engines/mergetree-family/aggregatingmergetree.md new file mode 100644 index 00000000000..e8e74960545 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/aggregatingmergetree.md @@ -0,0 +1,105 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: AggregatingMergeTree +--- + +# Aggregatingmergetree {#aggregatingmergetree} + +Le moteur hérite de [MergeTree](mergetree.md#table_engines-mergetree), modifier la logique pour les parties de données Fusion. ClickHouse remplace toutes les lignes avec la même clé primaire (ou, plus précisément, avec la même [clé de tri](mergetree.md)) avec une seule ligne (dans un rayon d'une partie des données) qui stocke une combinaison d'états de fonctions d'agrégation. + +Vous pouvez utiliser `AggregatingMergeTree` tables pour l'agrégation incrémentielle des données, y compris pour les vues matérialisées agrégées. + +Le moteur traite toutes les colonnes avec les types suivants: + +- [AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) +- [SimpleAggregateFunction](../../../sql-reference/data-types/simpleaggregatefunction.md) + +Il est approprié d'utiliser `AggregatingMergeTree` si elle réduit le nombre de lignes par commande. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = AggregatingMergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[TTL expr] +[SETTINGS name=value, ...] +``` + +Pour une description des paramètres de requête, voir [demande de description](../../../sql-reference/statements/create.md). + +**Les clauses de requête** + +Lors de la création d'un `AggregatingMergeTree` la table de la même [clause](mergetree.md) sont nécessaires, comme lors de la création d'un `MergeTree` table. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +Tous les paramètres ont la même signification que dans `MergeTree`. +
+ +## Sélectionner et insérer {#select-and-insert} + +Pour insérer des données, utilisez [INSERT SELECT](../../../sql-reference/statements/insert-into.md) requête avec l'ensemble-l'État des fonctions. +Lors de la sélection des données `AggregatingMergeTree` table, utilisez `GROUP BY` et les mêmes fonctions d'agrégat que lors de l'insertion de données, mais en utilisant `-Merge` suffixe. + +Dans les résultats de `SELECT` requête, les valeurs de `AggregateFunction` type ont une représentation binaire spécifique à l'implémentation pour tous les formats de sortie ClickHouse. Si les données de vidage dans, par exemple, `TabSeparated` format avec `SELECT` requête alors ce vidage peut être chargé en utilisant `INSERT` requête. + +## Exemple D'une vue matérialisée agrégée {#example-of-an-aggregated-materialized-view} + +`AggregatingMergeTree` vue matérialisée qui regarde le `test.visits` table: + +``` sql +CREATE MATERIALIZED VIEW test.basic +ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) +AS SELECT + CounterID, + StartDate, + sumState(Sign) AS Visits, + uniqState(UserID) AS Users +FROM test.visits +GROUP BY CounterID, StartDate; +``` + +Insertion de données dans la `test.visits` table. + +``` sql +INSERT INTO test.visits ... +``` + +Les données sont insérées dans la table et la vue `test.basic` que va effectuer l'agrégation. + +Pour obtenir les données agrégées, nous devons exécuter une requête telle que `SELECT ... GROUP BY ...` à partir de la vue `test.basic`: + +``` sql +SELECT + StartDate, + sumMerge(Visits) AS Visits, + uniqMerge(Users) AS Users +FROM test.basic +GROUP BY StartDate +ORDER BY StartDate; +``` + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/fr/engines/table-engines/mergetree-family/collapsingmergetree.md b/docs/fr/engines/table-engines/mergetree-family/collapsingmergetree.md new file mode 100644 index 00000000000..80f61622539 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/collapsingmergetree.md @@ -0,0 +1,306 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: CollapsingMergeTree +--- + +# CollapsingMergeTree {#table_engine-collapsingmergetree} + +Le moteur hérite de [MergeTree](mergetree.md) et ajoute la logique de l'effondrement des lignes de données de pièces algorithme de fusion. + +`CollapsingMergeTree` supprime de manière asynchrone (réduit) les paires de lignes si tous les champs d'une clé de tri (`ORDER BY`) sont équivalents à l'exception du champ particulier `Sign` ce qui peut avoir `1` et `-1` valeur. Les lignes sans paire sont conservées. Pour plus de détails, voir le [Effondrer](#table_engine-collapsingmergetree-collapsing) la section du document. + +Le moteur peut réduire considérablement le volume de stockage et augmenter l'efficacité de `SELECT` requête en conséquence. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = CollapsingMergeTree(sign) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Pour une description des paramètres de requête, voir [description de la requête](../../../sql-reference/statements/create.md). + +**Paramètres CollapsingMergeTree** + +- `sign` — Name of the column with the type of row: `1` est un “state” rangée, `-1` est un “cancel” rangée. + + Column data type — `Int8`. + +**Les clauses de requête** + +Lors de la création d'un `CollapsingMergeTree` de table, de la même [les clauses de requête](mergetree.md#table_engine-mergetree-creating-a-table) sont nécessaires, comme lors de la création d'un `MergeTree` table. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) +``` + +Tous les paramètres excepté `sign` ont la même signification que dans `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` — “state” rangée, `-1` — “cancel” rangée. + + Column Data Type — `Int8`. + +
+ +## Effondrer {#table_engine-collapsingmergetree-collapsing} + +### Données {#data} + +Considérez la situation où vous devez enregistrer des données en constante évolution pour un objet. Il semble logique d'avoir une ligne pour un objet et de la mettre à jour à tout changement, mais l'opération de mise à jour est coûteuse et lente pour le SGBD car elle nécessite une réécriture des données dans le stockage. Si vous avez besoin d'écrire des données rapidement, la mise à jour n'est pas acceptable, mais vous pouvez écrire les modifications d'un objet de manière séquentielle comme suit. + +Utilisez la colonne particulière `Sign`. Si `Sign = 1` cela signifie que la ligne est un état d'un objet, appelons-la “state” rangée. Si `Sign = -1` il signifie l'annulation de l'état d'un objet avec les mêmes attributs, nous allons l'appeler “cancel” rangée. + +Par exemple, nous voulons calculer combien de pages les utilisateurs ont vérifié sur un site et combien de temps ils étaient là. À un certain moment nous écrire la ligne suivante avec l'état de l'activité de l'utilisateur: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +À un moment donné, nous enregistrons le changement d'activité de l'utilisateur et l'écrivons avec les deux lignes suivantes. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +La première ligne annule le précédent état de l'objet (utilisateur). Il doit copier les champs de clé de tri de l'état annulé sauf `Sign`. + +La deuxième ligne contient l'état actuel. + +Comme nous avons besoin seulement le dernier état de l'activité de l'utilisateur, les lignes + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +peut être supprimé en réduisant l'état invalide (ancien) d'un objet. `CollapsingMergeTree` fait cela lors de la fusion des parties de données. + +Pourquoi nous avons besoin de 2 lignes pour chaque changement lu dans le [Algorithme](#table_engine-collapsingmergetree-collapsing-algorithm) paragraphe. + +**Propriétés particulières d'une telle approche** + +1. Le programme qui écrit les données doit se souvenir de l'état d'un objet pour pouvoir l'annuler. “Cancel” string doit contenir des copies des champs de clé de tri du “state” chaîne et le contraire `Sign`. Il augmente la taille initiale de stockage, mais permet d'écrire les données rapidement. +2. Les tableaux de plus en plus longs dans les colonnes réduisent l'efficacité du moteur en raison de la charge pour l'écriture. Plus les données sont simples, plus l'efficacité est élevée. +3. Le `SELECT` les résultats dépendent fortement de la cohérence de l'historique des modifications d'objet. Être précis lors de la préparation des données pour l'insertion. Vous pouvez obtenir des résultats imprévisibles dans des données incohérentes, par exemple des valeurs négatives pour des mesures non négatives telles que la profondeur de session. + +### Algorithme {#table_engine-collapsingmergetree-collapsing-algorithm} + +Lorsque ClickHouse fusionne des parties de données, chaque groupe de lignes consécutives avec la même clé de tri (`ORDER BY`) est réduit à pas plus de deux rangées, une avec `Sign = 1` (“state” ligne) et l'autre avec `Sign = -1` (“cancel” rangée). En d'autres termes, les entrées de l'effondrement. + +Pour chaque partie de données résultante clickhouse enregistre: + +1. Première “cancel” et la dernière “state” lignes, si le nombre de “state” et “cancel” lignes correspond et la dernière ligne est un “state” rangée. +2. La dernière “state” ligne, si il y a plus de “state” les lignes de “cancel” rangée. +3. Première “cancel” ligne, si il y a plus de “cancel” les lignes de “state” rangée. +4. Aucune des lignes, dans tous les autres cas. + +Aussi quand il y a au moins 2 plus “state” les lignes de “cancel” les lignes, ou au moins 2 de plus “cancel” rangs puis “state” la fusion continue, mais ClickHouse traite cette situation comme une erreur logique et l'enregistre dans le journal du serveur. Cette erreur peut se produire si les mêmes données ont été insérées plus d'une fois. + +Ainsi, l'effondrement ne devrait pas changer les résultats du calcul des statistiques. +Les changements se sont progressivement effondrés de sorte qu'à la fin seul le dernier état de presque tous les objets à gauche. + +Le `Sign` est nécessaire car l'algorithme de fusion ne garantit pas que toutes les lignes avec la même clé de tri seront dans la même partie de données résultante et même sur le même serveur physique. Processus de ClickHouse `SELECT` les requêtes avec plusieurs threads, et il ne peut pas prédire l'ordre des lignes dans le résultat. L'agrégation est nécessaire s'il y a un besoin d'obtenir complètement “collapsed” les données de `CollapsingMergeTree` table. + +Pour finaliser la réduction, écrivez une requête avec `GROUP BY` fonctions de clause et d'agrégation qui tiennent compte du signe. Par exemple, pour calculer la quantité, l'utilisation `sum(Sign)` plutôt `count()`. Pour calculer la somme de quelque chose, utilisez `sum(Sign * x)` plutôt `sum(x)` et ainsi de suite , et également ajouter `HAVING sum(Sign) > 0`. + +Aggregate `count`, `sum` et `avg` pourrait être calculée de cette manière. Aggregate `uniq` peut être calculé si un objet a au moins un état non réduit. Aggregate `min` et `max` impossible de calculer parce que `CollapsingMergeTree` n'enregistre pas l'historique des valeurs des États réduits. + +Si vous avez besoin d'extraire des données sans agrégation (par exemple, pour vérifier si des lignes sont présentes dont les valeurs les plus récentes correspondent à certaines conditions), vous pouvez utiliser `FINAL` le modificateur du `FROM` clause. Cette approche est nettement moins efficace. + +## Exemple D'utilisation {#example-of-use} + +Les données de l'exemple: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Création de la table: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Insertion des données: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) +``` + +Nous utilisons deux `INSERT` requêtes pour créer deux parties de données différentes. Si nous insérons les données avec une requête, ClickHouse crée une partie de données et n'effectuera aucune fusion. + +L'obtention de données: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Que voyons-nous et où s'effondre? + +Avec deux `INSERT` requêtes, nous avons créé 2 parties de données. Le `SELECT` la requête a été effectuée dans 2 threads, et nous avons obtenu un ordre aléatoire de lignes. L'effondrement n'a pas eu lieu car il n'y avait pas encore de fusion des parties de données. ClickHouse fusionne une partie des données dans un moment inconnu que nous ne pouvons pas prédire. + +Nous avons donc besoin d'agrégation: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration +FROM UAct +GROUP BY UserID +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +Si nous n'avons pas besoin d'agrégation et de vouloir forcer l'effondrement, nous pouvons utiliser `FINAL` le modificateur `FROM` clause. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Cette façon de sélectionner les données est très inefficace. Ne l'utilisez pas pour les grandes tables. + +## Exemple D'une autre approche {#example-of-another-approach} + +Les données de l'exemple: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ -5 │ -146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +L'idée est que les fusions ne prennent en compte que les champs clés. Et dans le “Cancel” ligne nous pouvons spécifier des valeurs négatives qui égalisent la version précédente de la ligne lors de la sommation sans utiliser la colonne de signe. Pour cette approche, il est nécessaire de changer le type de données `PageViews`,`Duration` pour stocker les valeurs négatives de UInt8 - \> Int16. + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews Int16, + Duration Int16, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Nous allons tester l'approche: + +``` sql +insert into UAct values(4324182021466249494, 5, 146, 1); +insert into UAct values(4324182021466249494, -5, -146, -1); +insert into UAct values(4324182021466249494, 6, 185, 1); + +select * from UAct final; // avoid using final in production (just for a test or small tables) +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +``` sql +SELECT + UserID, + sum(PageViews) AS PageViews, + sum(Duration) AS Duration +FROM UAct +GROUP BY UserID +```text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +``` sqk +select count() FROM UAct +``` + +``` text +┌─count()─┐ +│ 3 │ +└─────────┘ +``` + +``` sql +optimize table UAct final; + +select * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/fr/engines/table-engines/mergetree-family/custom-partitioning-key.md b/docs/fr/engines/table-engines/mergetree-family/custom-partitioning-key.md new file mode 100644 index 00000000000..3617655adb1 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/custom-partitioning-key.md @@ -0,0 +1,127 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: "Cl\xE9 De Partitionnement Personnalis\xE9e" +--- + +# Clé De Partitionnement Personnalisée {#custom-partitioning-key} + +Le partitionnement est disponible pour [MergeTree](mergetree.md) table de famille (y compris les [répliqué](replication.md) table). [Les vues matérialisées](../special/materializedview.md#materializedview) basé sur les tables MergeTree prennent également en charge le partitionnement. + +Une partition est une combinaison logique d'enregistrements dans une table selon un critère spécifié. Vous pouvez définir une partition par un critère arbitraire, comme, par mois, par jour, ou par type d'événement. Chaque partition est stockée séparément pour simplifier les manipulations de ces données. Lors de l'accès aux données, ClickHouse utilise le plus petit sous-ensemble de partitions possible. + +La partition est spécifiée dans le `PARTITION BY expr` clause lors de [création d'une table](mergetree.md#table_engine-mergetree-creating-a-table). La clé de partition peut être n'importe quelle expression des colonnes de la table. Par exemple, pour spécifier le partitionnement par mois, utilisez l'expression `toYYYYMM(date_column)`: + +``` sql +CREATE TABLE visits +( + VisitDate Date, + Hour UInt8, + ClientID UUID +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(VisitDate) +ORDER BY Hour; +``` + +La clé de partition peut également être un tuple d'expressions (similaire à la [clé primaire](mergetree.md#primary-keys-and-indexes-in-queries)). Exemple: + +``` sql +ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) +PARTITION BY (toMonday(StartDate), EventType) +ORDER BY (CounterID, StartDate, intHash32(UserID)); +``` + +Dans cet exemple, nous définissons le partitionnement par les types d'événements qui se sont produits au cours de la semaine en cours. + +Lors de l'insertion de nouvelles données dans une table, ces données sont stockées en tant que partie séparée (bloc) triée par la clé primaire. Dans 10-15 minutes après l'insertion, les parties de la même partition sont fusionnées dans la partie entière. + +!!! info "Info" + Une fusion ne fonctionne que pour les parties de données qui ont la même valeur pour l'expression de partitionnement. Cela signifie **vous ne devriez pas faire des partitions trop granulaires** (plus d'un millier de partitions). Sinon, l' `SELECT` la requête fonctionne mal en raison d'un nombre déraisonnablement élevé de fichiers dans le système de fichiers et des descripteurs de fichiers ouverts. + +L'utilisation de la [système.partie](../../../operations/system-tables.md#system_tables-parts) table pour afficher les parties et les partitions de la table. Par exemple, supposons que nous avons une `visits` table avec partitionnement par mois. Nous allons effectuer le `SELECT` la requête pour l' `system.parts` table: + +``` sql +SELECT + partition, + name, + active +FROM system.parts +WHERE table = 'visits' +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 1 │ +│ 201902 │ 201902_11_11_0 │ 1 │ +└───────────┴────────────────┴────────┘ +``` + +Le `partition` colonne contient les noms des partitions. Il y a deux partitions dans cet exemple: `201901` et `201902`. Vous pouvez utiliser cette valeur de colonne pour spécifier le nom de [ALTER … PARTITION](#alter_manipulations-with-partitions) requête. + +Le `name` colonne contient les noms des parties de données de partition. Vous pouvez utiliser cette colonne pour spécifier le nom de la partie dans la [ALTER ATTACH PART](#alter_attach-partition) requête. + +Décomposons le nom de la première partie: `201901_1_3_1`: + +- `201901` est le nom de la partition. +- `1` est le nombre minimum du bloc de données. +- `3` est le nombre maximal de blocs de données. +- `1` est le niveau de bloc (la profondeur de l'arbre de fusion à partir duquel il est formé). + +!!! info "Info" + Les parties des tables de type ancien ont le nom: `20190117_20190123_2_2_0` (date minimale - date maximale - numéro de bloc minimum - numéro de bloc maximum-niveau). + +Le `active` colonne indique le statut de la partie. `1` est active; `0` est inactif. Les parties inactives sont, par exemple, des parties source restant après la fusion à une partie plus grande. Les parties de données corrompues sont également indiquées comme inactives. + +Comme vous pouvez le voir dans l'exemple, il y a plusieurs parties séparées de la même partition (par exemple, `201901_1_3_1` et `201901_1_9_2`). Cela signifie que ces parties ne sont pas encore fusionnées. Clickhouse fusionne les parties insérées des données périodiquement, environ 15 minutes après l'insertion. En outre, vous pouvez effectuer une fusion non planifiée en utilisant [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) requête. Exemple: + +``` sql +OPTIMIZE TABLE visits PARTITION 201902; +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 0 │ +│ 201902 │ 201902_4_11_2 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 0 │ +│ 201902 │ 201902_11_11_0 │ 0 │ +└───────────┴────────────────┴────────┘ +``` + +Les parties inactives seront supprimées environ 10 minutes après la fusion. + +Une autre façon d'afficher un ensemble de pièces et de partitions est d'aller dans le répertoire de la table: `/var/lib/clickhouse/data///`. Exemple: + +``` bash +/var/lib/clickhouse/data/default/visits$ ls -l +total 40 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached +``` + +Dossier ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ et ainsi de suite sont les répertoires des parties. Chaque partie se rapporte à une partition correspondante et contient des données juste pour un certain mois (la table dans cet exemple a partitionnement par mois). + +Le `detached` le répertoire contient des parties qui ont été détachées de la table à l'aide [DETACH](../../../sql-reference/statements/alter.md#alter_detach-partition) requête. Les parties corrompues sont également déplacées dans ce répertoire, au lieu d'être supprimées. Le serveur n'utilise pas les pièces de la `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql-reference/statements/alter.md#alter_attach-partition) requête. + +Notez que sur le serveur d'exploitation, vous ne pouvez pas modifier manuellement l'ensemble de pièces ou leurs données sur le système de fichiers, car le serveur ne le saura pas. Pour les tables non répliquées, vous pouvez le faire lorsque le serveur est arrêté, mais ce n'est pas recommandé. Pour les tables répliquées, l'ensemble de pièces ne peut en aucun cas être modifié. + +ClickHouse vous permet d'effectuer des opérations avec les partitions: les supprimer, copier d'une table à une autre, ou créer une sauvegarde. Voir la liste de toutes les opérations de la section [Manipulations avec des Partitions et des pièces](../../../sql-reference/statements/alter.md#alter_manipulations-with-partitions). + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/fr/engines/table-engines/mergetree-family/graphitemergetree.md b/docs/fr/engines/table-engines/mergetree-family/graphitemergetree.md new file mode 100644 index 00000000000..d1dc5e64a4f --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/graphitemergetree.md @@ -0,0 +1,174 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: GraphiteMergeTree +--- + +# GraphiteMergeTree {#graphitemergetree} + +Ce moteur est conçu pour l'amincissement et l'agrégation / moyenne (cumul) [Graphite](http://graphite.readthedocs.io/en/latest/index.html) données. Il peut être utile aux développeurs qui veulent utiliser ClickHouse comme un magasin de données pour Graphite. + +Vous pouvez utiliser N'importe quel moteur de table ClickHouse pour stocker les données Graphite si vous n'avez pas besoin de cumul, mais si vous avez besoin d'un cumul, utilisez `GraphiteMergeTree`. Le moteur réduit le volume de stockage et augmente l'efficacité des requêtes de Graphite. + +Le moteur hérite des propriétés de [MergeTree](mergetree.md). + +## Création d'une Table {#creating-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE = GraphiteMergeTree(config_section) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Voir une description détaillée de la [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) requête. + +Un tableau pour les données de Graphite devrait avoir les colonnes suivantes pour les données suivantes: + +- Nom métrique (Capteur De Graphite). Type de données: `String`. + +- Temps de mesure de la métrique. Type de données: `DateTime`. + +- La valeur de la métrique. Type de données: tout numérique. + +- La Version de la métrique. Type de données: tout numérique. + + ClickHouse enregistre les lignes avec la version la plus élevée ou la dernière écrite si les versions sont les mêmes. Les autres lignes sont supprimées lors de la fusion des parties de données. + +Les noms de ces colonnes doivent être définis dans la configuration de cumul. + +**GraphiteMergeTree paramètres** + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +**Les clauses de requête** + +Lors de la création d'un `GraphiteMergeTree` de table, de la même [clause](mergetree.md#table_engine-mergetree-creating-a-table) sont nécessaires, comme lors de la création d'un `MergeTree` table. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + EventDate Date, + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) +``` + +Tous les paramètres excepté `config_section` ont la même signification que dans `MergeTree`. + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +
+ +## Configuration De Cumul {#rollup-configuration} + +Les paramètres de cumul sont définis par [graphite\_rollup](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-graphite) paramètre dans la configuration du serveur. Le nom du paramètre pourrait être tout. Vous pouvez créer plusieurs configurations et les utiliser pour différentes tables. + +Structure de configuration de cumul: + + required-columns + patterns + +### Les Colonnes Requises {#required-columns} + +- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. +- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. +- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Valeur par défaut: `Value`. +- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. + +### Modèle {#patterns} + +La Structure de la `patterns` section: + +``` text +pattern + regexp + function +pattern + regexp + age + precision + ... +pattern + regexp + function + age + precision + ... +pattern + ... +default + function + age + precision + ... +``` + +!!! warning "Attention" + Les motifs doivent être strictement commandés: + + 1. Patterns without `function` or `retention`. + 1. Patterns with both `function` and `retention`. + 1. Pattern `default`. + +Lors du traitement d'une ligne, ClickHouse vérifie les règles `pattern` section. Chacun `pattern` (comprendre `default`) les articles peuvent contenir des `function` paramètre d'agrégation, `retention` les paramètres ou les deux à la fois. Si le nom de la métrique correspond `regexp` les règles de la `pattern` section (ou sections) sont appliquées; sinon, les règles de la `default` section sont utilisés. + +Champs pour `pattern` et `default` section: + +- `regexp`– A pattern for the metric name. +- `age` – The minimum age of the data in seconds. +- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). +- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. + +### Exemple De Configuration {#configuration-example} + +``` xml + + Version + + click_cost + any + + 0 + 5 + + + 86400 + 60 + + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/fr/engines/table-engines/mergetree-family/index.md b/docs/fr/engines/table-engines/mergetree-family/index.md new file mode 100644 index 00000000000..e2de11a7591 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Famille MergeTree +toc_priority: 28 +--- + + diff --git a/docs/fr/engines/table-engines/mergetree-family/mergetree.md b/docs/fr/engines/table-engines/mergetree-family/mergetree.md new file mode 100644 index 00000000000..3906eabfc47 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/mergetree.md @@ -0,0 +1,654 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 30 +toc_title: MergeTree +--- + +# MergeTree {#table_engines-mergetree} + +Le `MergeTree` moteur et autres moteurs de cette famille (`*MergeTree`) sont les moteurs de table ClickHouse les plus robustes. + +Les moteurs de la `MergeTree` famille sont conçus pour l'insertion d'une très grande quantité de données dans une table. Les données sont rapidement écrites dans la table partie par partie, puis des règles sont appliquées pour fusionner les parties en arrière-plan. Cette méthode est beaucoup plus efficace que de réécrire continuellement les données dans le stockage pendant l'insertion. + +Principales caractéristiques: + +- Stocke les données triées par clé primaire. + + Cela vous permet de créer un petit index clairsemé qui aide à trouver les données plus rapidement. + +- Les Partitions peuvent être utilisées si [clé de partitionnement](custom-partitioning-key.md) est spécifié. + + ClickHouse prend en charge certaines opérations avec des partitions plus efficaces que les opérations générales sur les mêmes données avec le même résultat. ClickHouse Coupe également automatiquement les données de partition où la clé de partitionnement est spécifiée dans la requête. Cela améliore également les performances de la requête. + +- Prise en charge de la réplication des données. + + La famille de `ReplicatedMergeTree` tables fournit la réplication des données. Pour plus d'informations, voir [Réplication des données](replication.md). + +- Appui d'échantillonnage de données. + + Si nécessaire, vous pouvez définir la méthode d'échantillonnage des données dans le tableau. + +!!! info "Info" + Le [Fusionner](../special/merge.md#merge) le moteur n'appartient pas à la `*MergeTree` famille. + +## Création d'une Table {#table_engine-mergetree-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... + INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, + INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 +) ENGINE = MergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] +[SETTINGS name=value, ...] +``` + +Pour une description des paramètres, voir [Créer une description de requête](../../../sql-reference/statements/create.md). + +!!! note "Note" + `INDEX` est une fonctionnalité expérimentale, voir [Index De Saut De Données](#table_engine-mergetree-data_skipping-indexes). + +### Les Clauses De Requête {#mergetree-query-clauses} + +- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. Le `MergeTree` le moteur n'a pas de paramètres. + +- `PARTITION BY` — The [clé de partitionnement](custom-partitioning-key.md). + + Pour le partitionnement par mois, utilisez les `toYYYYMM(date_column)` l'expression, où `date_column` est une colonne avec une date du type [Date](../../../sql-reference/data-types/date.md). Les noms de partition ici ont le `"YYYYMM"` format. + +- `ORDER BY` — The sorting key. + + Un tuple de colonnes ou d'expressions arbitraires. Exemple: `ORDER BY (CounterID, EventDate)`. + +- `PRIMARY KEY` — The primary key if it [diffère de la clé de tri](#choosing-a-primary-key-that-differs-from-the-sorting-key). + + Par défaut, la clé primaire est la même que la clé de tri (qui est spécifiée par `ORDER BY` clause). Ainsi dans la plupart des cas il n'est pas nécessaire de spécifier un `PRIMARY KEY` clause. + +- `SAMPLE BY` — An expression for sampling. + + Si un échantillonnage expression est utilisée, la clé primaire doit contenir. Exemple: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. + +- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [entre disques et volumes](#table_engine-mergetree-multiple-volumes). + + L'Expression doit en avoir une `Date` ou `DateTime` colonne comme un résultat. Exemple: + `TTL date + INTERVAL 1 DAY` + + Le Type de la règle `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` spécifie une action à effectuer avec la partie si l'expression est satisfaite (atteint l'heure actuelle): suppression des Lignes expirées, déplacement d'une partie (si l'expression est satisfaite pour toutes les lignes d'une partie) sur le disque spécifié (`TO DISK 'xxx'`) ou de volume (`TO VOLUME 'xxx'`). Le type par défaut de la règle est suppression (`DELETE`). Liste de règles multiples peut spécifié, mais il ne devrait pas y avoir plus d'un `DELETE` règle. + + Pour plus de détails, voir [TTL pour les colonnes et les tableaux](#table_engine-mergetree-ttl) + +- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: + + - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Le Stockage De Données](#mergetree-data-storage). + - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Le Stockage De Données](#mergetree-data-storage). + - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` paramètre. Avant la version 19.11, il n'y avait que le `index_granularity` réglage pour restreindre la taille des granules. Le `index_granularity_bytes` le paramètre améliore les performances de ClickHouse lors de la sélection de données à partir de tables avec de grandes lignes (des dizaines et des centaines de mégaoctets). Si vous avez des tables avec de grandes lignes, vous pouvez activer ce paramètre pour les tables d'améliorer l'efficacité de `SELECT` requête. + - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, puis Zookeeper stocke moins de données. Pour plus d'informations, voir le [Description du réglage](../../../operations/server-configuration-parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) dans “Server configuration parameters”. + - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` octets, ClickHouse lit et écrit les données sur le disque de stockage en utilisant l'interface d'E/S directe (`O_DIRECT` option). Si `min_merge_bytes_to_use_direct_io = 0`, puis les e/s directes sont désactivées. Valeur par défaut: `10 * 1024 * 1024 * 1024` octet. + + - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). + - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don't turn it off. + - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. + - `storage_policy` — Storage policy. See [Utilisation de plusieurs périphériques de bloc pour le stockage de données](#table_engine-mergetree-multiple-volumes). + +**Exemple de réglage des Sections** + +``` sql +ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 +``` + +Dans l'exemple, nous définissons le partitionnement par mois. + +Nous définissons également une expression pour l'échantillonnage en tant que hachage par l'ID utilisateur. Cela vous permet de pseudorandomiser les données dans la table pour chaque `CounterID` et `EventDate`. Si vous définissez un [SAMPLE](../../../sql-reference/statements/select/sample.md#select-sample-clause) clause lors de la sélection des données, ClickHouse retournera un échantillon de données uniformément pseudo-aléatoire pour un sous-ensemble d'utilisateurs. + +Le `index_granularity` paramètre peut être omis, car 8192 est la valeur par défaut. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets. Si possible, optez anciens projets à la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +**Paramètres MergeTree ()** + +- `date-column` — The name of a column of the [Date](../../../sql-reference/data-types/date.md) type. ClickHouse crée automatiquement des partitions par mois en fonction de cette colonne. Les noms de partition sont dans le `"YYYYMM"` format. +- `sampling_expression` — An expression for sampling. +- `(primary, key)` — Primary key. Type: [Tuple()](../../../sql-reference/data-types/tuple.md) +- `index_granularity` — The granularity of an index. The number of data rows between the “marks” d'un index. La valeur 8192 est appropriée pour la plupart des tâches. + +**Exemple** + +``` sql +MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) +``` + +Le `MergeTree` le moteur est configuré de la même manière que dans l'exemple ci-dessus pour la méthode de configuration du moteur principal. +
+ +## Le Stockage De Données {#mergetree-data-storage} + +Une table se compose de parties de données triées par clé primaire. + +Lorsque des données sont insérées dans une table, des parties de données distinctes sont créées et chacune d'elles est lexicographiquement triée par clé primaire. Par exemple, si la clé primaire est `(CounterID, Date)`, les données de la pièce sont triées par `CounterID` et au sein de chaque `CounterID` il est commandé par `Date`. + +Les données appartenant à différentes partitions sont séparés en différentes parties. En arrière-plan, ClickHouse fusionne des parties de données pour un stockage plus efficace. Les parties appartenant à des partitions différentes ne sont pas fusionnées. La fusion mécanisme ne garantit pas que toutes les lignes avec la même clé primaire sera dans la même partie des données. + +Chaque partie de données est logiquement divisée en granules. Un granule est le plus petit ensemble de données indivisible que ClickHouse lit lors de la sélection des données. ClickHouse ne divise pas les lignes ou les valeurs, de sorte que chaque granule contient toujours un nombre entier de lignes. La première rangée de granules est marqué avec la valeur de la clé primaire de la ligne. Pour chaque partie de données, ClickHouse crée un fichier d'index qui stocke les marques. Pour chaque colonne, que ce soit dans la clé primaire ou non, ClickHouse stocke également les mêmes marques. Ces marques vous permettent de trouver des données directement dans les fichiers de colonnes. + +La taille de granule est limitée par `index_granularity` et `index_granularity_bytes` paramètres du moteur de table. Le nombre de lignes dans un granule jette dans la `[1, index_granularity]` gamme, en fonction de la taille des lignes. La taille des granulés peut dépasser `index_granularity_bytes` si la taille d'une seule ligne est supérieure à la valeur du paramètre. Dans ce cas, la taille du granule est égale à la taille de la ligne. + +## Clés primaires et Index dans les requêtes {#primary-keys-and-indexes-in-queries} + +Prendre la `(CounterID, Date)` clé primaire comme un exemple. Dans ce cas, le tri et l'index peuvent être illustrés comme suit: + + Whole data: [---------------------------------------------] + CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] + Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] + Marks: | | | | | | | | | | | + a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 + Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 + +Si la requête de données spécifie: + +- `CounterID in ('a', 'h')` le serveur lit les données dans les gammes des marques `[0, 3)` et `[6, 8)`. +- `CounterID IN ('a', 'h') AND Date = 3` le serveur lit les données dans les gammes des marques `[1, 3)` et `[7, 8)`. +- `Date = 3`, le serveur lit les données de la plage de marque `[1, 10]`. + +Les exemples ci-dessus montrent qu'il est toujours plus efficace d'utiliser un indice qu'une analyse complète. + +Un index clairsemé permet de lire des données supplémentaires. Lors de la lecture d'une plage unique de la clé primaire, jusqu'à `index_granularity * 2` lignes supplémentaires dans chaque bloc de données peut être lu. + +Les index clairsemés vous permettent de travailler avec un très grand nombre de lignes de table, car dans la plupart des cas, ces index tiennent dans la RAM de l'ordinateur. + +ClickHouse ne nécessite pas de clé primaire unique. Vous pouvez insérer plusieurs lignes avec la même clé primaire. + +### Sélection de la clé primaire {#selecting-the-primary-key} + +Le nombre de colonnes de la clé primaire n'est pas explicitement limitée. Selon la structure de données, vous pouvez inclure plus ou moins de colonnes dans la clé primaire. Cela peut: + +- Améliorer la performance d'un indice. + + Si la clé primaire est `(a, b)`, puis ajouter une autre colonne `c` pour améliorer les performances si les conditions suivantes sont réunies: + + - Il y a des requêtes avec une condition sur la colonne `c`. + - Longues plages de données (plusieurs fois plus longues que `index_granularity`) avec des valeurs identiques pour `(a, b)` sont communs. En d'autres termes, lors de l'ajout d'une autre colonne vous permet de passer très longues plages de données. + +- Améliorer la compression des données. + + ClickHouse trie les données par clé primaire, donc plus la cohérence est élevée, meilleure est la compression. + +- Fournir une logique supplémentaire lors de la fusion de parties de [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) et [SummingMergeTree](summingmergetree.md) moteur. + + Dans ce cas, on peut spécifier l' *clé de tri* qui est différente de la clé primaire. + +Une clé primaire longue affectera négativement les performances d'insertion et la consommation de mémoire, mais des colonnes supplémentaires dans la clé primaire n'affecteront pas les performances de ClickHouse pendant `SELECT` requête. + +### Choisir une clé primaire qui diffère de la clé de tri {#choosing-a-primary-key-that-differs-from-the-sorting-key} + +Il est possible de spécifier une clé primaire (une expression avec des valeurs qui sont écrites dans le fichier d'index pour chaque marque) qui est différente de la clé de tri (une expression pour trier les lignes dans les parties de données). Dans ce cas, le tuple d'expression de clé primaire doit être un préfixe du tuple d'expression de clé de tri. + +Cette fonctionnalité est utile lorsque vous utilisez le [SummingMergeTree](summingmergetree.md) et +[AggregatingMergeTree](aggregatingmergetree.md) table des moteurs. Dans un cas courant lors de l'utilisation de ces moteurs, la table a deux types de colonnes: *dimension* et *mesure*. Les requêtes typiques agrégent les valeurs des colonnes de mesure avec arbitraire `GROUP BY` et filtrage par dimensions. Comme SummingMergeTree et AggregatingMergeTree regroupent des lignes avec la même valeur de la clé de tri, il est naturel d'y ajouter toutes les dimensions. En conséquence, l'expression se compose d'une longue liste de colonnes, et cette liste doit être mise à jour fréquemment avec nouvellement ajoutée. + +Dans ce cas, il est logique de ne laisser que quelques colonnes dans la clé primaire qui fourniront des analyses de plage efficaces et ajouteront les colonnes de dimension restantes au tuple de clé de tri. + +[ALTER](../../../sql-reference/statements/alter.md) la clé de tri est une opération légère car lorsqu'une nouvelle colonne est ajoutée simultanément à la table et à la clé de tri, les parties de données existantes n'ont pas besoin d'être modifiées. Comme l'ancienne clé de tri est un préfixe de la nouvelle clé de tri et qu'il n'y a pas de données dans la colonne nouvellement ajoutée, les données sont triées à la fois par l'ancienne et la nouvelle clé de tri au moment de la modification de la table. + +### Utilisation D'Index et de Partitions dans les requêtes {#use-of-indexes-and-partitions-in-queries} + +Pour `SELECT` requêtes, clickhouse analyse si un index peut être utilisé. Un index peut être utilisé si le `WHERE/PREWHERE` clause a une expression (comme l'un des éléments de conjonction, ou entièrement) qui représente une opération de comparaison d'égalité ou d'inégalité, ou si elle a `IN` ou `LIKE` avec un préfixe fixe sur les colonnes ou les expressions qui sont dans la clé primaire ou la clé de partitionnement, ou sur certaines fonctions partiellement répétitives de ces colonnes, ou les relations logiques de ces expressions. + +Ainsi, il est possible d'exécuter des requêtes sur une ou plusieurs plages de la clé primaire. Dans cet exemple, les requêtes seront rapides lorsqu'elles sont exécutées pour une balise de suivi spécifique, pour une balise et une plage de dates spécifiques, pour une balise et une date spécifiques, pour plusieurs balises avec une plage de dates, etc. + +Regardons le moteur configuré comme suit: + + ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 + +Dans ce cas, dans les requêtes: + +``` sql +SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 +SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) +SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) +``` + +ClickHouse utilisera l'index de clé primaire pour supprimer les données incorrectes et la clé de partitionnement mensuel pour supprimer les partitions qui se trouvent dans des plages de dates incorrectes. + +Les requêtes ci-dessus montrent que l'index est utilisé même pour les expressions complexes. La lecture de la table est organisée de sorte que l'utilisation de l'index ne peut pas être plus lente qu'une analyse complète. + +Dans l'exemple ci-dessous, l'index ne peut pas être utilisé. + +``` sql +SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' +``` + +Pour vérifier si ClickHouse pouvez utiliser l'index lors de l'exécution d'une requête, utilisez les paramètres [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) et [force\_primary\_key](../../../operations/settings/settings.md). + +La clé de partitionnement par mois permet de lire uniquement les blocs de données qui contiennent des dates de la plage appropriée. Dans ce cas, le bloc de données peut contenir des données pour plusieurs dates (jusqu'à un mois entier). Dans un bloc, les données sont triées par clé primaire, qui peut ne pas contenir la date comme première colonne. Pour cette raison, l'utilisation d'une requête avec seulement une condition de date qui ne spécifie pas le préfixe de clé primaire entraînera la lecture de plus de données que pour une seule date. + +### Utilisation de L'Index pour les clés primaires partiellement monotones {#use-of-index-for-partially-monotonic-primary-keys} + +Considérons, par exemple, les jours du mois. Ils forment un [monotone de la séquence](https://en.wikipedia.org/wiki/Monotonic_function) pendant un mois, mais pas monotone pendant des périodes plus longues. C'est une séquence partiellement monotone. Si un utilisateur crée la table avec une clé primaire partiellement monotone, ClickHouse crée un index clairsemé comme d'habitude. Lorsqu'un utilisateur sélectionne des données à partir de ce type de table, ClickHouse analyse les conditions de requête. Si L'utilisateur veut obtenir des données entre deux marques de l'index et que ces deux marques tombent dans un mois, ClickHouse peut utiliser l'index dans ce cas particulier car il peut calculer la distance entre les paramètres d'une requête et les marques d'index. + +ClickHouse ne peut pas utiliser un index si les valeurs de la clé primaire dans la plage de paramètres de requête ne représentent pas une séquence monotone. Dans ce cas, ClickHouse utilise la méthode full scan. + +ClickHouse utilise cette logique non seulement pour les séquences de jours du mois, mais pour toute clé primaire qui représente une séquence partiellement monotone. + +### Index de saut de données (expérimental) {#table_engine-mergetree-data_skipping-indexes} + +La déclaration d'index se trouve dans la section colonnes du `CREATE` requête. + +``` sql +INDEX index_name expr TYPE type(...) GRANULARITY granularity_value +``` + +Pour les tables de la `*MergeTree` famille, les indices de saut de données peuvent être spécifiés. + +Ces indices agrégent certaines informations sur l'expression spécifiée sur les blocs, qui consistent en `granularity_value` granules (la taille du granule est spécifiée en utilisant `index_granularity` réglage dans le moteur de table). Ensuite, ces agrégats sont utilisés dans `SELECT` requêtes pour réduire la quantité de données à lire à partir du disque en ignorant de gros blocs de données `where` la requête ne peut pas être satisfait. + +**Exemple** + +``` sql +CREATE TABLE table_name +( + u64 UInt64, + i32 Int32, + s String, + ... + INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, + INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 +) ENGINE = MergeTree() +... +``` + +Les Indices de L'exemple peuvent être utilisés par ClickHouse pour réduire la quantité de données à lire à partir du disque dans les requêtes suivantes: + +``` sql +SELECT count() FROM table WHERE s < 'z' +SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 +``` + +#### Types d'Indices disponibles {#available-types-of-indices} + +- `minmax` + + Magasins extrêmes de l'expression spécifiée (si l'expression est `tuple` puis il stocke les extrêmes pour chaque élément de `tuple`), utilise les informations stockées pour sauter des blocs de données comme la clé primaire. + +- `set(max_rows)` + + Stocke les valeurs uniques de l'expression spécifiée (pas plus de `max_rows` rangée, `max_rows=0` moyen “no limits”). Utilise les valeurs pour vérifier si le `WHERE` l'expression n'est pas satisfiable sur un bloc de données. + +- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Magasins un [Filtre de Bloom](https://en.wikipedia.org/wiki/Bloom_filter) qui contient tous les ngrams d'un bloc de données. Fonctionne uniquement avec des chaînes. Peut être utilisé pour l'optimisation de `equals`, `like` et `in` expression. + + - `n` — ngram size, + - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). + - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. + - `random_seed` — The seed for Bloom filter hash functions. + +- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Le même que `ngrambf_v1`, mais stocke des jetons au lieu de ngrams. Les jetons sont des séquences séparées par des caractères non alphanumériques. + +- `bloom_filter([false_positive])` — Stores a [Filtre de Bloom](https://en.wikipedia.org/wiki/Bloom_filter) pour les colonnes spécifiées. + + Facultatif `false_positive` le paramètre est la probabilité de recevoir une réponse faussement positive du filtre. Valeurs possibles: (0, 1). Valeur par défaut: 0.025. + + Types de données pris en charge: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. + + Les fonctions suivantes peuvent l'utiliser: [égal](../../../sql-reference/functions/comparison-functions.md), [notEquals](../../../sql-reference/functions/comparison-functions.md), [dans](../../../sql-reference/functions/in-functions.md), [notIn](../../../sql-reference/functions/in-functions.md), [avoir](../../../sql-reference/functions/array-functions.md). + + + +``` sql +INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 +INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 +INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 +``` + +#### Les Fonctions De Soutien {#functions-support} + +Les Conditions dans le `WHERE` la clause contient des appels des fonctions qui fonctionnent avec des colonnes. Si la colonne fait partie d'un index, ClickHouse essaie d'utiliser cet index lors de l'exécution des fonctions. ClickHouse prend en charge différents sous-ensembles de fonctions pour l'utilisation d'index. + +Le `set` l'indice peut être utilisé avec toutes les fonctions. Les sous-ensembles de fonctions pour les autres index sont présentés dans le tableau ci-dessous. + +| Fonction (opérateur) / Indice de | clé primaire | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | +|--------------------------------------------------------------------------------------------------------------|--------------|--------|-------------|-------------|---------------| +| [égal (=, ==)](../../../sql-reference/functions/comparison-functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notEquals (!=, \<\>)](../../../sql-reference/functions/comparison-functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [comme](../../../sql-reference/functions/string-search-functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [notLike](../../../sql-reference/functions/string-search-functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [startsWith](../../../sql-reference/functions/string-functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | +| [endsWith](../../../sql-reference/functions/string-functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | +| [multiSearchAny](../../../sql-reference/functions/string-search-functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | +| [dans](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notIn](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [peu (\<)](../../../sql-reference/functions/comparison-functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [grand (\>)](../../../sql-reference/functions/comparison-functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [lessOrEquals (\<=)](../../../sql-reference/functions/comparison-functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [greaterOrEquals ( \> =)](../../../sql-reference/functions/comparison-functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [vide](../../../sql-reference/functions/array-functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [notEmpty](../../../sql-reference/functions/array-functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | + +Les fonctions avec un argument constant inférieur à la taille ngram ne peuvent pas être utilisées par `ngrambf_v1` pour l'optimisation de la requête. + +Les filtres Bloom peuvent avoir des correspondances faussement positives, de sorte que le `ngrambf_v1`, `tokenbf_v1`, et `bloom_filter` les index ne peuvent pas être utilisés pour optimiser les requêtes où le résultat d'une fonction est censé être faux, par exemple: + +- Peut être optimisé: + - `s LIKE '%test%'` + - `NOT s NOT LIKE '%test%'` + - `s = 1` + - `NOT s != 1` + - `startsWith(s, 'test')` +- Ne peut pas être optimisé: + - `NOT s LIKE '%test%'` + - `s NOT LIKE '%test%'` + - `NOT s = 1` + - `s != 1` + - `NOT startsWith(s, 'test')` + +## Accès Simultané Aux Données {#concurrent-data-access} + +Pour l'accès aux tables simultanées, nous utilisons le multi-versioning. En d'autres termes, lorsqu'une table est lue et mise à jour simultanément, les données sont lues à partir d'un ensemble de parties en cours au moment de la requête. Il n'y a pas de longues mèches. Les Inserts ne gênent pas les opérations de lecture. + +Lecture à partir d'un tableau est automatiquement parallélisée. + +## TTL pour les colonnes et les tableaux {#table_engine-mergetree-ttl} + +Détermine la durée de vie de des valeurs. + +Le `TTL` clause peut être définie pour la table entière et pour chaque colonne individuelle. Ttl de niveau Table peut également spécifier la logique de déplacement automatique des données entre les disques et les volumes. + +Les Expressions doivent évaluer pour [Date](../../../sql-reference/data-types/date.md) ou [DateTime](../../../sql-reference/data-types/datetime.md) type de données. + +Exemple: + +``` sql +TTL time_column +TTL time_column + interval +``` + +Définir `interval`, utiliser [intervalle](../../../sql-reference/operators/index.md#operators-datetime) opérateur. + +``` sql +TTL date_time + INTERVAL 1 MONTH +TTL date_time + INTERVAL 15 HOUR +``` + +### Colonne TTL {#mergetree-column-ttl} + +Lorsque les valeurs de la colonne expirent, ClickHouse les remplace par les valeurs par défaut du type de données de la colonne. Si toutes les valeurs de colonne de la partie données expirent, ClickHouse supprime cette colonne de la partie données d'un système de fichiers. + +Le `TTL` la clause ne peut pas être utilisée pour les colonnes clés. + +Exemple: + +Création d'une table avec TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int TTL d + INTERVAL 1 MONTH, + b Int TTL d + INTERVAL 1 MONTH, + c String +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d; +``` + +Ajout de TTL à une colonne d'une table existante + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 DAY; +``` + +Modification de TTL de la colonne + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 MONTH; +``` + +### Tableau TTL {#mergetree-table-ttl} + +Table peut avoir une expression pour la suppression de Lignes expirées, et plusieurs expressions pour le déplacement automatique de pièces entre [disques ou volumes](#table_engine-mergetree-multiple-volumes). Lorsque les lignes de la table expirent, ClickHouse supprime toutes les lignes correspondantes. Pour les pièces en mouvement, toutes les lignes d'une pièce doivent satisfaire aux critères d'expression de mouvement. + +``` sql +TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... +``` + +Type de règle TTL peut suivre chaque expression TTL. Il affecte une action qui doit être faite une fois que l'expression est satisfaite (atteint l'heure actuelle): + +- `DELETE` - supprimer les Lignes expirées (action par défaut); +- `TO DISK 'aaa'` - déplacer la partie sur le disque `aaa`; +- `TO VOLUME 'bbb'` - déplacer la partie sur le disque `bbb`. + +Exemple: + +Création d'une table avec TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d +TTL d + INTERVAL 1 MONTH [DELETE], + d + INTERVAL 1 WEEK TO VOLUME 'aaa', + d + INTERVAL 2 WEEK TO DISK 'bbb'; +``` + +Modification de TTL de la table + +``` sql +ALTER TABLE example_table + MODIFY TTL d + INTERVAL 1 DAY; +``` + +**Suppression De Données** + +Les données avec un TTL expiré sont supprimées lorsque ClickHouse fusionne des parties de données. + +Lorsque ClickHouse voit que les données sont expirées, il effectue une fusion hors calendrier. Pour contrôler la fréquence de ces fusions, vous pouvez définir `merge_with_ttl_timeout`. Si la valeur est trop faible, il effectuera de nombreuses fusions hors calendrier qui peuvent consommer beaucoup de ressources. + +Si vous effectuez la `SELECT` requête entre les fusionne, vous pouvez obtenir des données expirées. Pour éviter cela, utilisez la [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) requête avant de l' `SELECT`. + +## Utilisation de plusieurs périphériques de bloc pour le stockage de données {#table_engine-mergetree-multiple-volumes} + +### Introduction {#introduction} + +`MergeTree` les moteurs de table de famille peuvent stocker des données sur plusieurs périphériques de bloc. Par exemple, il peut être utile lorsque les données d'un tableau sont implicitement divisé en “hot” et “cold”. Les données les plus récentes sont régulièrement demandées mais ne nécessitent qu'une petite quantité d'espace. Au contraire, les données historiques à queue grasse sont rarement demandées. Si plusieurs disques sont disponibles, la “hot” les données peuvent être situées sur des disques rapides (par exemple, SSD NVMe ou en mémoire), tandis que le “cold” des données relativement lente (par exemple, disque dur). + +La partie de données est l'unité mobile minimum pour `MergeTree`-tables de moteur. Les données appartenant à une partie sont stockées sur un disque. Les parties de données peuvent être déplacées entre les disques en arrière-plan (selon les paramètres de l'utilisateur) ainsi qu'au moyen du [ALTER](../../../sql-reference/statements/alter.md#alter_move-partition) requête. + +### Terme {#terms} + +- Disk — Block device mounted to the filesystem. +- Default disk — Disk that stores the path specified in the [chemin](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path) paramètre de serveur. +- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). +- Storage policy — Set of volumes and the rules for moving data between them. + +Les noms donnés aux entités décrites peuvent être trouvés dans les tables système, [système.storage\_policies](../../../operations/system-tables.md#system_tables-storage_policies) et [système.disque](../../../operations/system-tables.md#system_tables-disks). Pour appliquer l'une des stratégies de stockage configurées pour une table, utilisez `storage_policy` réglage de `MergeTree`-moteur de table de famille. + +### Configuration {#table_engine-mergetree-multiple-volumes_configure} + +Les disques, les volumes et les stratégies de stockage doivent être déclarés `` étiquette, soit dans le fichier principal `config.xml` ou dans un fichier distinct dans le `config.d` répertoire. + +Structure de Configuration: + +``` xml + + + + /mnt/fast_ssd/clickhouse/ + + + /mnt/hdd1/clickhouse/ + 10485760 + + + /mnt/hdd2/clickhouse/ + 10485760 + + + ... + + + ... + +``` + +Balise: + +- `` — Disk name. Names must be different for all disks. +- `path` — path under which a server will store data (`data` et `shadow` des dossiers), doit être terminé par ‘/’. +- `keep_free_space_bytes` — the amount of free disk space to be reserved. + +L'ordre du disque définition n'est pas important. + +Stratégies de stockage balisage de configuration: + +``` xml + + ... + + + + + disk_name_from_disks_configuration + 1073741824 + + + + + + + 0.2 + + + + + + + + ... + +``` + +Balise: + +- `policy_name_N` — Policy name. Policy names must be unique. +- `volume_name_N` — Volume name. Volume names must be unique. +- `disk` — a disk within a volume. +- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume's disks. +- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). + +Exemples de Cofiguration: + +``` xml + + ... + + + + + disk1 + disk2 + + + + + + + + fast_ssd + 1073741824 + + + disk1 + + + 0.2 + + + ... + +``` + +Dans l'exemple donné, la `hdd_in_order` politique met en œuvre les [round-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) approche. Ainsi cette politique ne définit qu'un seul volume (`single`), les parties des données sont stockées sur tous ses disques dans l'ordre circulaire. Une telle politique peut être très utile s'il y a plusieurs disques similaires sont montés sur le système, mais RAID N'est pas configuré. Gardez à l'esprit que chaque lecteur de disque n'est pas fiable et vous pouvez compenser avec facteur de réplication de 3 ou plus. + +S'il existe différents types de disques disponibles dans le système, `moving_from_ssd_to_hdd` la stratégie peut être utilisée à la place. Volume `hot` se compose d'un disque SSD (`fast_ssd`), et la taille maximale d'une pièce qui peut être stocké sur ce volume est de 1 go. Toutes les pièces avec la taille plus grande que 1 GB sera stocké directement sur le `cold` le volume, qui contient un disque dur de disque `disk1`. +Aussi, une fois le disque `fast_ssd` est complété par plus de 80%, les données seront transférées à la `disk1` par un processus d'arrière-plan. + +L'ordre d'énumération des volumes dans une stratégie de stockage est important. Une fois qu'un volume est surchargé, les données sont déplacées vers le suivant. L'ordre d'énumération des disques est important parce que les données sont stockées dans les virages. + +Lors de la création d'une table, on peut lui appliquer l'une des stratégies de stockage configurées: + +``` sql +CREATE TABLE table_with_non_default_policy ( + EventDate Date, + OrderID UInt64, + BannerID UInt64, + SearchPhrase String +) ENGINE = MergeTree +ORDER BY (OrderID, BannerID) +PARTITION BY toYYYYMM(EventDate) +SETTINGS storage_policy = 'moving_from_ssd_to_hdd' +``` + +Le `default` la Politique de stockage implique d'utiliser un seul volume, qui se compose d'un seul disque donné dans ``. Une fois qu'une table est créée, sa stratégie de stockage ne peut pas être modifiée. + +### Détail {#details} + +Dans le cas de `MergeTree` les tableaux, les données sont sur le disque de différentes façons: + +- En tant que résultat d'un insert (`INSERT` requête). +- En arrière-plan fusionne et [mutation](../../../sql-reference/statements/alter.md#alter-mutations). +- Lors du téléchargement à partir d'une autre réplique. +- À la suite du gel de la partition [ALTER TABLE … FREEZE PARTITION](../../../sql-reference/statements/alter.md#alter_freeze-partition). + +Dans tous ces cas, à l'exception des mutations et du gel de partition, une pièce est stockée sur un volume et un disque selon la Politique de stockage donnée: + +1. Le premier volume (dans l'ordre de définition) qui a suffisamment d'espace disque pour stocker une pièce (`unreserved_space > current_part_size`) et permet de stocker des pièces d'une taille donnée (`max_data_part_size_bytes > current_part_size`) est choisi. +2. Dans ce volume, ce disque est choisi qui suit celui, qui a été utilisé pour stocker le bloc de données précédent, et qui a de l'espace libre plus que la taille de la pièce (`unreserved_space - keep_free_space_bytes > current_part_size`). + +Sous le capot, les mutations et la congélation des cloisons utilisent [des liens en dur](https://en.wikipedia.org/wiki/Hard_link). Les liens durs entre différents disques ne sont pas pris en charge, donc dans de tels cas, les pièces résultantes sont stockées sur les mêmes disques que les disques initiaux. + +En arrière - plan, les pièces sont déplacées entre les volumes en fonction de la quantité d'espace libre (`move_factor` paramètre) selon l'ordre les volumes sont déclarées dans le fichier de configuration. +Les données ne sont jamais transférées du dernier et dans le premier. On peut utiliser des tables système [système.part\_log](../../../operations/system-tables.md#system_tables-part-log) (champ `type = MOVE_PART`) et [système.partie](../../../operations/system-tables.md#system_tables-parts) (Fields `path` et `disk`) pour surveiller l'arrière-plan se déplace. Aussi, les informations détaillées peuvent être trouvées dans les journaux du serveur. + +L'utilisateur peut forcer le déplacement d'une partie ou d'une partition d'un volume à l'autre à l'aide de la requête [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql-reference/statements/alter.md#alter_move-partition), toutes les restrictions pour les opérations de fond sont prises en compte. La requête initie un mouvement seul et n'attend pas que les opérations d'arrière-plan soient terminées. L'utilisateur recevra un message d'erreur si pas assez d'espace libre est disponible ou si l'une des conditions requises ne sont pas remplies. + +Le déplacement des données n'interfère pas avec la réplication des données. Par conséquent, différentes stratégies de stockage peuvent être spécifiées pour la même table sur différents réplicas. + +Après l'achèvement des fusions d'arrière-plan et des mutations, les anciennes parties ne sont supprimées qu'après un certain temps (`old_parts_lifetime`). +Pendant ce temps, ils ne sont pas déplacés vers d'autres volumes ou des disques. Par conséquent, jusqu'à ce que les pièces soient finalement supprimées, elles sont toujours prises en compte pour l'évaluation de l'espace disque occupé. + +[Article Original](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/fr/engines/table-engines/mergetree-family/replacingmergetree.md b/docs/fr/engines/table-engines/mergetree-family/replacingmergetree.md new file mode 100644 index 00000000000..ac3c0f3b021 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/replacingmergetree.md @@ -0,0 +1,69 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: ReplacingMergeTree +--- + +# ReplacingMergeTree {#replacingmergetree} + +Le moteur diffère de [MergeTree](mergetree.md#table_engines-mergetree) en ce qu'il supprime les doublons avec la même valeur de clé primaire (ou, plus précisément, avec la même [clé de tri](mergetree.md) valeur). + +La déduplication des données se produit uniquement lors d'une fusion. La fusion se produit en arrière-plan à un moment inconnu, vous ne pouvez donc pas le planifier. Certaines des données peuvent rester non traitées. Bien que vous puissiez exécuter une fusion imprévue en utilisant le `OPTIMIZE` requête, ne comptez pas l'utiliser, parce que la `OPTIMIZE` requête va lire et écrire une grande quantité de données. + +Ainsi, `ReplacingMergeTree` convient pour effacer les données en double en arrière-plan afin d'économiser de l'espace, mais cela ne garantit pas l'absence de doublons. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = ReplacingMergeTree([ver]) +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Pour une description des paramètres de requête, voir [demande de description](../../../sql-reference/statements/create.md). + +**ReplacingMergeTree Paramètres** + +- `ver` — column with version. Type `UInt*`, `Date` ou `DateTime`. Paramètre facultatif. + + Lors de la fusion, `ReplacingMergeTree` de toutes les lignes avec la même clé primaire ne laisse qu'un: + + - Dernier dans la sélection, si `ver` pas ensemble. + - Avec la version maximale, si `ver` défini. + +**Les clauses de requête** + +Lors de la création d'un `ReplacingMergeTree` la table de la même [clause](mergetree.md) sont nécessaires, comme lors de la création d'un `MergeTree` table. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) +``` + +Tous les paramètres excepté `ver` ont la même signification que dans `MergeTree`. + +- `ver` - colonne avec la version. Paramètre facultatif. Pour une description, voir le texte ci-dessus. + +
+ +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/fr/engines/table-engines/mergetree-family/replication.md b/docs/fr/engines/table-engines/mergetree-family/replication.md new file mode 100644 index 00000000000..49690204869 --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/replication.md @@ -0,0 +1,218 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "R\xE9plication Des Donn\xE9es" +--- + +# Réplication Des Données {#table_engines-replication} + +La réplication n'est prise en charge que pour les tables de la famille MergeTree: + +- ReplicatedMergeTree +- ReplicatedSummingMergeTree +- ReplicatedReplacingMergeTree +- ReplicatedAggregatingMergeTree +- ReplicatedCollapsingMergeTree +- ReplicatedVersionedCollapsingMergetree +- ReplicatedGraphiteMergeTree + +La réplication fonctionne au niveau d'une table individuelle, Pas du serveur entier. Un serveur peut stocker des tables répliquées et non répliquées en même temps. + +La réplication ne dépend pas de la fragmentation. Chaque fragment a sa propre réplication indépendante. + +Données compressées pour `INSERT` et `ALTER` les requêtes sont répliquées (pour plus d'informations, consultez la documentation de [ALTER](../../../sql-reference/statements/alter.md#query_language_queries_alter)). + +`CREATE`, `DROP`, `ATTACH`, `DETACH` et `RENAME` les requêtes sont exécutées sur un seul serveur et ne sont pas répliquées: + +- Le `CREATE TABLE` query crée une nouvelle table réplicable sur le serveur où la requête est exécutée. Si cette table existe déjà sur d'autres serveurs, il ajoute une nouvelle réplique. +- Le `DROP TABLE` requête supprime la réplique situé sur le serveur où l'exécution de la requête. +- Le `RENAME` requête renomme la table sur l'une des répliques. En d'autres termes, les tables répliquées peuvent avoir des noms différents sur différentes répliques. + +Clickhouse utilise [Apache ZooKeeper](https://zookeeper.apache.org) pour stocker des informations méta répliques. Utilisez ZooKeeper version 3.4.5 ou plus récente. + +Pour utiliser la réplication, définissez les paramètres [zookeeper](../../../operations/server-configuration-parameters/settings.md#server-settings_zookeeper) section de configuration du serveur. + +!!! attention "Attention" + Ne négligez pas la sécurité. Clickhouse soutient le `digest` [Schéma ACL](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) du sous-système de sécurité ZooKeeper. + +Exemple de définition des adresses du cluster ZooKeeper: + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + + example3 + 2181 + + +``` + +Vous pouvez spécifier N'importe quel cluster Zookeeper existant et le système utilisera un répertoire pour ses propres données (le répertoire est spécifié lors de la création d'une table réplicable). + +Si ZooKeeper n'est pas défini dans le fichier de configuration, vous ne pouvez pas créer de tables répliquées et toutes les tables répliquées existantes seront en lecture seule. + +La gardienne n'est pas utilisé dans `SELECT` requêtes car la réplication n'affecte pas les performances de `SELECT` et les requêtes s'exécutent aussi vite que pour les tables non répliquées. Lors de l'interrogation de tables répliquées distribuées, le comportement de ClickHouse est contrôlé par les paramètres [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) et [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). + +Pour chaque `INSERT` requête, environ dix entrées sont ajoutées à ZooKeeper par le biais de plusieurs transactions. (Pour être plus précis, c'est pour chaque bloc de données inséré; une requête D'insertion contient un bloc ou un bloc par `max_insert_block_size = 1048576` rangée.) Cela conduit à des latences légèrement plus longues pour `INSERT` par rapport aux tables non répliquées. Mais si vous suivez les recommandations pour insérer des données dans des lots de pas plus d'un `INSERT` par seconde, cela ne crée aucun problème. L'ensemble du cluster clickhouse utilisé pour coordonner un cluster ZooKeeper a un total de plusieurs centaines `INSERTs` par seconde. Le débit sur les insertions de données (le nombre de lignes par seconde) est aussi élevé que pour les non-données répliquées. + +Pour les clusters très volumineux, vous pouvez utiliser différents clusters ZooKeeper pour différents fragments. Cependant, cela ne s'est pas avéré nécessaire sur le Yandex.Cluster Metrica (environ 300 serveurs). + +La réplication est asynchrone et multi-maître. `INSERT` les requêtes (ainsi que `ALTER`) peuvent être envoyés à n'importe quel serveur disponible. Les données sont insérées sur le serveur où la requête est exécutée, puis il est copié sur les autres serveurs. Comme il est asynchrone, les données récemment insérées apparaissent sur les autres répliques avec une certaine latence. Si une partie des répliques ne sont pas disponibles, les données sont écrites lorsqu'elles sont disponibles. Si une réplique est disponible, la latence correspond au temps nécessaire pour transférer le bloc de données compressées sur le réseau. + +Par défaut, une requête INSERT attend la confirmation de l'écriture des données à partir d'un seul réplica. Si les données ont été correctement écrit sur une seule réplique et le serveur avec cette réplique cesse d'exister, les données enregistrées seront perdues. Pour activer la confirmation des Écritures de données à partir de plusieurs réplicas, utilisez `insert_quorum` option. + +Chaque bloc de données est écrit de manière atomique. La requête D'insertion est divisée en blocs jusqu'à `max_insert_block_size = 1048576` rangée. En d'autres termes, si l' `INSERT` la requête a moins de 1048576 lignes, elle est faite de manière atomique. + +Les blocs de données sont dédupliquées. Pour plusieurs écritures du même bloc de données (blocs de données de même taille contenant les mêmes lignes dans le même ordre), le bloc n'est écrit qu'une seule fois. La raison en est en cas de défaillance du réseau lorsque l'application cliente ne sait pas si les données ont été écrites dans la base de données, de sorte que le `INSERT` requête peut simplement être répété. Peu importe à quelles insertions de réplica ont été envoyées avec des données identiques. `INSERTs` sont idempotents. Les paramètres de déduplication sont contrôlés par [merge\_tree](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree) les paramètres du serveur. + +Pendant la réplication, seules les données source à insérer sont transférées sur le réseau. D'autres transformations de données (fusion) sont coordonnées et effectuées sur toutes les répliques de la même manière. Cela minimise l'utilisation du réseau, ce qui signifie que la réplication fonctionne bien lorsque les répliques résident dans différents centres de données. (Notez que la duplication de données dans différents centres de données est l'objectif principal de la réplication.) + +Vous pouvez avoir n'importe quel nombre de répliques des mêmes données. Yandex.Metrica utilise la double réplication en production. Chaque serveur utilise RAID-5 ou RAID-6, et RAID-10 dans certains cas. C'est une solution relativement fiable et pratique. + +Le système surveille la synchronicité des données sur les répliques et est capable de récupérer après une défaillance. Le basculement est automatique (pour les petites différences de données) ou semi-automatique (lorsque les données diffèrent trop, ce qui peut indiquer une erreur de configuration). + +## Création De Tables Répliquées {#creating-replicated-tables} + +Le `Replicated` le préfixe est ajouté au nom du moteur de table. Exemple:`ReplicatedMergeTree`. + +**Répliqué \* MergeTree paramètres** + +- `zoo_path` — The path to the table in ZooKeeper. +- `replica_name` — The replica name in ZooKeeper. + +Exemple: + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +``` + +
+ +Exemple de syntaxe obsolète + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) +``` + +
+ +Comme le montre l'exemple, ces paramètres peuvent contenir des substitutions entre crochets. Les valeurs substituées sont tirées de la ‘macros’ section du fichier de configuration. Exemple: + +``` xml + + 05 + 02 + example05-02-1.yandex.ru + +``` + +Le chemin d'accès à la table dans ZooKeeper doit être unique pour chaque table répliquée. Les Tables sur différents fragments doivent avoir des chemins différents. +Dans ce cas, le chemin se compose des parties suivantes: + +`/clickhouse/tables/` est le préfixe commun. Nous vous recommandons d'utiliser exactement celui-ci. + +`{layer}-{shard}` est l'identificateur de fragment. Dans cet exemple, il se compose de deux parties, depuis l'Yandex.Le cluster Metrica utilise le sharding à deux niveaux. Pour la plupart des tâches, vous ne pouvez laisser que la substitution {shard}, qui sera étendue à l'Identificateur de partition. + +`table_name` est le nom du nœud de la table dans ZooKeeper. C'est une bonne idée de le rendre identique au nom de la table. Il est défini explicitement, car contrairement au nom de la table, il ne change pas après une requête de renommage. +*HINT*: vous pouvez ajouter un nom de base de données devant `table_name` Aussi. E. g. `db_name.table_name` + +Le nom du réplica identifie différentes réplicas de la même table. Vous pouvez utiliser le nom de serveur pour cela, comme dans l'exemple. Le nom doit seulement être unique dans chaque fragment. + +Vous pouvez définir les paramètres explicitement au lieu d'utiliser des substitutions. Cela peut être pratique pour tester et configurer de petits clusters. Cependant, vous ne pouvez pas utiliser de requêtes DDL distribuées (`ON CLUSTER`) dans ce cas. + +Lorsque vous travaillez avec de grands clusters, nous vous recommandons d'utiliser des substitutions car elles réduisent la probabilité d'erreur. + +Exécutez l' `CREATE TABLE` requête sur chaque réplique. Cette requête crée une nouvelle table répliquée, ou ajoute une nouvelle réplique à un existant. + +Si vous ajoutez une nouvelle réplique après que la table contient déjà des données sur d'autres répliques, les données seront copiées des autres répliques vers la nouvelle après l'exécution de la requête. En d'autres termes, la nouvelle réplique synchronise avec les autres. + +Pour supprimer une réplique, exécutez `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. + +## Récupération Après Des Échecs {#recovery-after-failures} + +Si ZooKeeper n'est pas disponible au démarrage d'un serveur, les tables répliquées passent en mode Lecture seule. Le système tente périodiquement de se connecter à ZooKeeper. + +Si ZooKeeper est indisponible pendant un `INSERT`, ou une erreur se produit lors de l'interaction avec ZooKeeper, une exception est levée. + +Après la connexion à ZooKeeper, le système vérifie si l'ensemble de données du système de fichiers local correspond à l'ensemble de données attendu (ZooKeeper stocke ces informations). S'il y a des incohérences mineures, le système les résout en synchronisant les données avec les répliques. + +Si le système détecte des parties de données brisées (avec la mauvaise taille des fichiers) ou des parties non reconnues (parties écrites dans le système de fichiers mais non enregistrées dans ZooKeeper), il les déplace vers le `detached` sous-répertoire (ils ne sont pas supprimés). Toutes les pièces manquantes sont copiées à partir des répliques. + +Notez que ClickHouse n'effectue aucune action destructrice telle que la suppression automatique d'une grande quantité de données. + +Lorsque le serveur démarre (ou établit une nouvelle session avec ZooKeeper), il vérifie uniquement la quantité et la taille de tous les fichiers. Si les tailles de fichier correspondent mais que les octets ont été modifiés quelque part au milieu, cela n'est pas détecté immédiatement, mais uniquement lorsque vous tentez de lire les données `SELECT` requête. La requête lève une exception concernant une somme de contrôle ou une taille non correspondante d'un bloc compressé. Dans ce cas, des parties de données sont ajoutées à la file d'attente de vérification et copiées à partir des répliques si nécessaire. + +Si la série de données diffère trop de celle attendue, un mécanisme de sécurité est déclenché. Le serveur entre cela dans le journal et refuse de lancer. La raison en est que ce cas peut indiquer une erreur de configuration, par exemple si une réplique sur un fragment a été accidentellement configurée comme une réplique sur un fragment différent. Cependant, les seuils pour ce mécanisme sont fixés assez bas, et cette situation peut se produire pendant la récupération normale de la défaillance. Dans ce cas, les données sont restaurées semi-automatiquement - par “pushing a button”. + +Pour démarrer la récupération, créez le nœud `/path_to_table/replica_name/flags/force_restore_data` dans ZooKeeper avec n'importe quel contenu, ou exécutez la commande pour restaurer toutes les tables répliquées: + +``` bash +sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data +``` + +Puis redémarrez le serveur. Au démarrage, le serveur supprime ces indicateurs et démarre la récupération. + +## Récupération Après La Perte De Données Complète {#recovery-after-complete-data-loss} + +Si toutes les données et métadonnées ont disparu de l'un des serveurs, procédez comme suit pour la récupération: + +1. Installez ClickHouse sur le serveur. Définissez correctement les substitutions dans le fichier de configuration qui contient l'Identificateur de fragment et les répliques, si vous les utilisez. +2. Si vous avez des tables non compliquées qui doivent être dupliquées manuellement sur les serveurs, copiez leurs données à partir d'un réplica (dans le répertoire `/var/lib/clickhouse/data/db_name/table_name/`). +3. Copier les définitions de table situées dans `/var/lib/clickhouse/metadata/` à partir d'une réplique. Si un identificateur de fragment ou de réplica est défini explicitement dans les définitions de table, corrigez-le de manière à ce qu'il corresponde à ce réplica. (Alternativement, démarrez le serveur et faites tous les `ATTACH TABLE` les requêtes qui auraient dû être dans les .les fichiers sql dans `/var/lib/clickhouse/metadata/`.) +4. Pour démarrer la récupération, créez le nœud ZooKeeper `/path_to_table/replica_name/flags/force_restore_data` tout contenu, ou d'exécuter la commande pour restaurer toutes les tables répliquées: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` + +Ensuite, démarrez le serveur (redémarrez, s'il est déjà en cours d'exécution). Les données seront téléchargées à partir de répliques. + +Une autre option de récupération consiste à supprimer des informations sur la réplique perdue de ZooKeeper (`/path_to_table/replica_name`), puis créez à nouveau la réplique comme décrit dans “[Création de tables répliquées](#creating-replicated-tables)”. + +Il n'y a aucune restriction sur la bande passante réseau pendant la récupération. Gardez cela à l'esprit si vous restaurez de nombreuses répliques à la fois. + +## Conversion de MergeTree en ReplicatedMergeTree {#converting-from-mergetree-to-replicatedmergetree} + +Nous utilisons le terme `MergeTree` pour consulter tous les moteurs de la `MergeTree family` le même que pour `ReplicatedMergeTree`. + +Si vous avez eu une `MergeTree` table qui a été répliquée manuellement, vous pouvez le convertir en une table répliquée. Vous devrez peut-être le faire si vous avez déjà recueilli une grande quantité de données dans un `MergeTree` table et maintenant vous voulez activer la réplication. + +Si les données diffèrent sur différentes répliques, synchronisez-les d'abord ou supprimez-les sur toutes les répliques sauf une. + +Renommez la table mergetree existante, puis créez un `ReplicatedMergeTree` table avec l'ancien nom. +Déplacez les données de l'ancienne table vers `detached` sous-répertoire à l'intérieur du répertoire avec les nouvelles données de la table (`/var/lib/clickhouse/data/db_name/table_name/`). +Ensuite, exécutez `ALTER TABLE ATTACH PARTITION` sur l'une des répliques d'ajouter ces données à des parties de l'ensemble de travail. + +## Conversion de ReplicatedMergeTree en MergeTree {#converting-from-replicatedmergetree-to-mergetree} + +Créez une table MergeTree avec un nom différent. Déplacez toutes les données du répertoire avec le `ReplicatedMergeTree` données de la table dans le répertoire de données de la nouvelle table. Ensuite, supprimer le `ReplicatedMergeTree` table et redémarrez le serveur. + +Si vous voulez vous débarrasser d'un `ReplicatedMergeTree` table sans lancer le serveur: + +- Supprimer la `.sql` fichier dans le répertoire de métadonnées (`/var/lib/clickhouse/metadata/`). +- Supprimer le chemin correspondant dans ZooKeeper (`/path_to_table/replica_name`). + +Après cela, vous pouvez lancer le serveur, créer un `MergeTree` tableau, déplacer les données de son répertoire, puis redémarrez le serveur. + +## Récupération lorsque les métadonnées du Cluster Zookeeper sont perdues ou endommagées {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} + +Si les données de ZooKeeper ont été perdues ou endommagées, vous pouvez les enregistrer en les déplaçant dans une table non compliquée comme décrit ci-dessus. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/fr/engines/table-engines/mergetree-family/summingmergetree.md b/docs/fr/engines/table-engines/mergetree-family/summingmergetree.md new file mode 100644 index 00000000000..f4f2b94a93f --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/summingmergetree.md @@ -0,0 +1,141 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: SummingMergeTree +--- + +# SummingMergeTree {#summingmergetree} + +Le moteur hérite de [MergeTree](mergetree.md#table_engines-mergetree). La différence est que lors de la fusion de parties de données pour `SummingMergeTree` tables ClickHouse remplace toutes les lignes avec la même clé primaire (ou, plus précisément, avec la même [clé de tri](mergetree.md)) avec une ligne qui contient des valeurs résumées pour les colonnes avec le type de données numériques. Si la clé de tri est composée de telle sorte qu'une seule valeur de clé correspond à un grand nombre de lignes, cela réduit considérablement le volume de stockage et accélère la sélection des données. + +Nous vous recommandons d'utiliser le moteur avec `MergeTree`. Stocker des données complètes dans `MergeTree` table, et l'utilisation `SummingMergeTree` pour le stockage de données agrégées, par exemple, lors de la préparation de rapports. Une telle approche vous empêchera de perdre des données précieuses en raison d'une clé primaire mal composée. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = SummingMergeTree([columns]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Pour une description des paramètres de requête, voir [demande de description](../../../sql-reference/statements/create.md). + +**Paramètres de SummingMergeTree** + +- `columns` - un n-uplet avec les noms de colonnes où les valeurs seront résumées. Paramètre facultatif. + Les colonnes doivent être d'un type numérique et ne doit pas être dans la clé primaire. + + Si `columns` non spécifié, ClickHouse résume les valeurs dans toutes les colonnes avec un type de données numérique qui ne sont pas dans la clé primaire. + +**Les clauses de requête** + +Lors de la création d'un `SummingMergeTree` la table de la même [clause](mergetree.md) sont nécessaires, comme lors de la création d'un `MergeTree` table. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) +``` + +Tous les paramètres excepté `columns` ont la même signification que dans `MergeTree`. + +- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. + +
+ +## Exemple D'Utilisation {#usage-example} + +Considérons le tableau suivant: + +``` sql +CREATE TABLE summtt +( + key UInt32, + value UInt32 +) +ENGINE = SummingMergeTree() +ORDER BY key +``` + +Insérer des données: + +``` sql +INSERT INTO summtt Values(1,1),(1,2),(2,1) +``` + +ClickHouse peut résumer toutes les lignes pas complètement ([voir ci-dessous](#data-processing)), nous utilisons donc une fonction d'agrégation `sum` et `GROUP BY` la clause dans la requête. + +``` sql +SELECT key, sum(value) FROM summtt GROUP BY key +``` + +``` text +┌─key─┬─sum(value)─┐ +│ 2 │ 1 │ +│ 1 │ 3 │ +└─────┴────────────┘ +``` + +## Le Traitement Des Données {#data-processing} + +Lorsque les données sont insérées dans une table, elles sont enregistrées telles quelles. Clickhouse fusionne périodiquement les parties de données insérées et c'est à ce moment que les lignes avec la même clé primaire sont additionnées et remplacées par une pour chaque partie de données résultante. + +ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) une fonction d'agrégation [somme()](../../../sql-reference/aggregate-functions/reference.md#agg_function-sum) et `GROUP BY` la clause doit être utilisé dans une requête comme décrit dans l'exemple ci-dessus. + +### Règles communes pour la sommation {#common-rules-for-summation} + +Les valeurs dans les colonnes avec le type de données numériques sont résumées. L'ensemble des colonnes est défini par le paramètre `columns`. + +Si les valeurs étaient 0 dans toutes les colonnes pour la sommation, la ligne est supprimée. + +Si la colonne n'est pas dans la clé primaire et n'est pas résumée, une valeur arbitraire est sélectionnée parmi celles existantes. + +Les valeurs ne sont pas résumés des colonnes de la clé primaire. + +### La somme dans les colonnes Aggregatefunction {#the-summation-in-the-aggregatefunction-columns} + +Pour les colonnes de [Type AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) ClickHouse se comporte comme [AggregatingMergeTree](aggregatingmergetree.md) moteur d'agrégation selon la fonction. + +### Structures Imbriquées {#nested-structures} + +Table peut avoir des structures de données imbriquées qui sont traitées d'une manière spéciale. + +Si le nom d'une table imbriquée se termine avec `Map` et il contient au moins deux colonnes qui répondent aux critères suivants: + +- la première colonne est numérique `(*Int*, Date, DateTime)` ou une chaîne de caractères `(String, FixedString)`, nous allons l'appeler `key`, +- les autres colonnes sont arithmétique `(*Int*, Float32/64)`, nous allons l'appeler `(values...)`, + +ensuite, cette table imbriquée est interprétée comme un mappage de `key => (values...)` et lors de la fusion de ses lignes, les éléments de deux ensembles de données sont regroupées par `key` avec une sommation du correspondant `(values...)`. + +Exemple: + +``` text +[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] +[(1, 100)] + [(1, 150)] -> [(1, 250)] +[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] +[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] +``` + +Lorsque vous demandez des données, utilisez [sumMap (clé, valeur)](../../../sql-reference/aggregate-functions/reference.md) fonction pour l'agrégation de `Map`. + +Pour la structure de données imbriquée, vous n'avez pas besoin de spécifier ses colonnes dans le tuple de colonnes pour la sommation. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/fr/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md b/docs/fr/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md new file mode 100644 index 00000000000..9be9fb5e76e --- /dev/null +++ b/docs/fr/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md @@ -0,0 +1,238 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: VersionedCollapsingMergeTree +--- + +# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} + +Ce moteur: + +- Permet l'écriture rapide des États d'objet qui changent continuellement. +- Supprime les anciens États d'objets en arrière-plan. Cela réduit considérablement le volume de stockage. + +Voir la section [Effondrer](#table_engines_versionedcollapsingmergetree) pour plus de détails. + +Le moteur hérite de [MergeTree](mergetree.md#table_engines-mergetree) et ajoute la logique de réduction des lignes à l'algorithme de fusion des parties de données. `VersionedCollapsingMergeTree` sert le même but que [CollapsingMergeTree](collapsingmergetree.md) mais utilise un autre effondrement algorithme qui permet d'insérer les données dans n'importe quel ordre avec plusieurs threads. En particulier, l' `Version` la colonne aide à réduire correctement les lignes même si elles sont insérées dans le mauvais ordre. Contrairement, `CollapsingMergeTree` permet uniquement une insertion strictement consécutive. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = VersionedCollapsingMergeTree(sign, version) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Pour une description des paramètres de requête, voir les [description de la requête](../../../sql-reference/statements/create.md). + +**Les Paramètres Du Moteur** + +``` sql +VersionedCollapsingMergeTree(sign, version) +``` + +- `sign` — Name of the column with the type of row: `1` est un “state” rangée, `-1` est un “cancel” rangée. + + Le type de données de colonne doit être `Int8`. + +- `version` — Name of the column with the version of the object state. + + Le type de données de colonne doit être `UInt*`. + +**Les Clauses De Requête** + +Lors de la création d'un `VersionedCollapsingMergeTree` de table, de la même [clause](mergetree.md) sont requis lors de la création d'un `MergeTree` table. + +
+ +Méthode obsolète pour créer une Table + +!!! attention "Attention" + N'utilisez pas cette méthode dans les nouveaux projets. Si possible, passer les anciens projets à la méthode décrite ci-dessus. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] VersionedCollapsingMergeTree(date-column [, samp#table_engines_versionedcollapsingmergetreeling_expression], (primary, key), index_granularity, sign, version) +``` + +Tous les paramètres, à l'exception `sign` et `version` ont la même signification que dans `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` est un “state” rangée, `-1` est un “cancel” rangée. + + Column Data Type — `Int8`. + +- `version` — Name of the column with the version of the object state. + + Le type de données de colonne doit être `UInt*`. + +
+ +## Effondrer {#table_engines_versionedcollapsingmergetree} + +### Données {#data} + +Considérez une situation où vous devez enregistrer des données en constante évolution pour un objet. Il est raisonnable d'avoir une ligne pour un objet et de mettre à jour la ligne chaque fois qu'il y a des modifications. Cependant, l'opération de mise à jour est coûteuse et lente pour un SGBD car elle nécessite la réécriture des données dans le stockage. La mise à jour n'est pas acceptable si vous devez écrire des données rapidement, mais vous pouvez écrire les modifications sur un objet de manière séquentielle comme suit. + +L'utilisation de la `Sign` colonne lors de l'écriture de la ligne. Si `Sign = 1` cela signifie que la ligne est un état d'un objet (appelons-la “state” rangée). Si `Sign = -1` il indique l'annulation de l'état d'un objet avec les mêmes attributs (appelons-la “cancel” rangée). Également utiliser l' `Version` colonne, qui doit identifier chaque état d'un objet avec un numéro distinct. + +Par exemple, nous voulons calculer le nombre de pages visitées sur le site et combien de temps ils étaient là. À un moment donné nous écrivons la ligne suivante avec l'état de l'activité de l'utilisateur: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +À un moment donné, nous enregistrons le changement d'activité de l'utilisateur et l'écrivons avec les deux lignes suivantes. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +La première ligne annule le précédent état de l'objet (utilisateur). Il doit copier tous les champs de l'état annulé sauf `Sign`. + +La deuxième ligne contient l'état actuel. + +Parce que nous avons besoin seulement le dernier état de l'activité de l'utilisateur, les lignes + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +peut être supprimé, réduisant l'état invalide (ancien) de l'objet. `VersionedCollapsingMergeTree` fait cela lors de la fusion des parties de données. + +Pour savoir pourquoi nous avons besoin de deux lignes pour chaque changement, voir [Algorithme](#table_engines-versionedcollapsingmergetree-algorithm). + +**Notes sur l'Utilisation de la** + +1. Le programme qui écrit les données devraient se souvenir de l'état d'un objet afin de l'annuler. Le “cancel” chaîne doit être une copie de la “state” chaîne avec le contraire `Sign`. Cela augmente la taille initiale de stockage, mais permet d'écrire les données rapidement. +2. Les tableaux de plus en plus longs dans les colonnes réduisent l'efficacité du moteur en raison de la charge d'écriture. Plus les données sont simples, meilleure est l'efficacité. +3. `SELECT` les résultats dépendent fortement de la cohérence de l'histoire de l'objet change. Être précis lors de la préparation des données pour l'insertion. Vous pouvez obtenir des résultats imprévisibles avec des données incohérentes, telles que des valeurs négatives pour des métriques non négatives telles que la profondeur de session. + +### Algorithme {#table_engines-versionedcollapsingmergetree-algorithm} + +Lorsque ClickHouse fusionne des parties de données, il supprime chaque paire de lignes ayant la même clé primaire et la même version et différentes `Sign`. L'ordre des lignes n'a pas d'importance. + +Lorsque ClickHouse insère des données, il ordonne les lignes par la clé primaire. Si l' `Version` la colonne n'est pas dans la clé primaire, ClickHouse ajoute à la clé primaire implicitement que le dernier champ et l'utilise pour la commande. + +## La Sélection De Données {#selecting-data} + +ClickHouse ne garantit pas que toutes les lignes avec la même clé primaire sera dans la même partie des données ou même sur le même serveur physique. Cela est vrai à la fois pour l'écriture des données et pour la fusion ultérieure des parties de données. En outre, les processus ClickHouse `SELECT` requêtes avec plusieurs threads, et il ne peut pas prédire l'ordre des lignes dans le résultat. Cela signifie que le regroupement est nécessaire s'il est nécessaire pour obtenir complètement “collapsed” données à partir d'un `VersionedCollapsingMergeTree` table. + +Pour finaliser la réduction, écrivez une requête avec un `GROUP BY` fonctions de clause et d'agrégation qui tiennent compte du signe. Par exemple, pour calculer la quantité, l'utilisation `sum(Sign)` plutôt `count()`. Pour calculer la somme de quelque chose, utilisez `sum(Sign * x)` plutôt `sum(x)` et d'ajouter `HAVING sum(Sign) > 0`. + +Aggregate `count`, `sum` et `avg` peut être calculée de cette manière. Aggregate `uniq` peut être calculé si un objet a au moins un non-état effondré. Aggregate `min` et `max` ne peut pas être calculé, car `VersionedCollapsingMergeTree` ne sauvegarde pas l'historique des valeurs des États réduits. + +Si vous avez besoin d'extraire les données avec “collapsing” mais sans agrégation (par exemple, pour vérifier si des lignes sont présentes dont les valeurs les plus récentes correspondent à certaines conditions), vous pouvez utiliser `FINAL` le modificateur du `FROM` clause. Cette approche est inefficace et ne devrait pas être utilisée avec de grandes tables. + +## Exemple D'utilisation {#example-of-use} + +Les données de l'exemple: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Création de la table: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8, + Version UInt8 +) +ENGINE = VersionedCollapsingMergeTree(Sign, Version) +ORDER BY UserID +``` + +Insérer les données: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) +``` + +Nous utilisons deux `INSERT` requêtes pour créer deux parties de données différentes. Si nous insérons les données avec une seule requête, ClickHouse crée une partie de données et n'effectuera jamais de fusion. + +L'obtention de données: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Que voyons-nous ici et où sont les parties effondrées? +Nous avons créé deux parties de données en utilisant deux `INSERT` requête. Le `SELECT` la requête a été effectuée dans deux threads, et le résultat est un ordre aléatoire de lignes. +L'effondrement n'a pas eu lieu car les parties de données n'ont pas encore été fusionnées. ClickHouse fusionne des parties de données à un moment inconnu que nous ne pouvons pas prédire. + +C'est pourquoi nous avons besoin de l'agrégation: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration, + Version +FROM UAct +GROUP BY UserID, Version +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 2 │ +└─────────────────────┴───────────┴──────────┴─────────┘ +``` + +Si nous n'avons pas besoin d'agrégation et que nous voulons forcer l'effondrement, nous pouvons utiliser le `FINAL` le modificateur du `FROM` clause. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +C'est un moyen très inefficace de sélectionner des données. Ne l'utilisez pas pour les grandes tables. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/fr/engines/table-engines/special/buffer.md b/docs/fr/engines/table-engines/special/buffer.md new file mode 100644 index 00000000000..af26b32177b --- /dev/null +++ b/docs/fr/engines/table-engines/special/buffer.md @@ -0,0 +1,71 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: Tampon +--- + +# Tampon {#buffer} + +Met en mémoire tampon les données à écrire dans la RAM, les vidant périodiquement dans une autre table. Pendant l'opération de lecture, les données sont lues à partir de la mémoire tampon, et l'autre simultanément. + +``` sql +Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) +``` + +Les paramètres du moteur: + +- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. +- `table` – Table to flush data to. +- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` indépendant de tampons. Valeur recommandée: 16. +- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, et `max_bytes` – Conditions for flushing data from the buffer. + +Les données sont vidées du tampon et écrites dans la table de destination si toutes les `min*` conditions ou au moins un `max*` conditions sont remplies. + +- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. +- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. +- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. + +Pendant l'opération d'écriture, les données sont insérées dans un `num_layers` nombre aléatoire de tampons. Ou, si la partie de données à insérer est suffisamment grande (supérieure à `max_rows` ou `max_bytes`), il est écrit directement dans la table de destination, en omettant le tampon. + +Les conditions de purger les données sont calculées séparément pour chacun des `num_layers` tampon. Par exemple, si `num_layers = 16` et `max_bytes = 100000000`, la consommation maximale de RAM est de 1,6 Go. + +Exemple: + +``` sql +CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) +``` + +La création d'un ‘merge.hits\_buffer’ table avec la même structure que ‘merge.hits’ et en utilisant le moteur tampon. Lors de l'écriture dans cette table, les données sont mises en mémoire tampon dans la RAM ‘merge.hits’ table. 16 tampons sont créés. Les données dans chacun d'entre eux est rincé si 100 secondes sont écoulées, ou un million de lignes ont été écrites, ou 100 MO de données ont été écrits; ou si, simultanément, 10 secondes et 10 000 lignes et 10 MO de données ont été écrites. Par exemple, si une ligne a été écrite, après 100 secondes, il sera vidé, n'importe quoi. Mais si plusieurs lignes ont été écrites, les données seront vidées plus tôt. + +Lorsque le serveur est arrêté, avec DROP TABLE ou DETACH TABLE, les données du tampon sont également vidées vers la table de destination. + +Vous pouvez définir des chaînes vides entre guillemets simples pour le nom de la base de données et de la table. Cela indique l'absence d'une table de destination. Dans ce cas, lorsque les conditions de vidage des données sont atteintes, le tampon est simplement effacé. Cela peut être utile pour garder une fenêtre de données dans la mémoire. + +Lors de la lecture à partir d'une table tampon, les données sont traitées à la fois à partir du tampon et de la table de destination (s'il y en a une). +Notez que les tables de tampon ne prennent pas en charge un index. En d'autres termes, les données dans le tampon sont entièrement analysées, ce qui peut être lent pour les grands tampons. (Pour les données dans une table subordonnée, l'index qu'il prend en charge sera utilisé.) + +Si l'ensemble de colonnes de la table tampon ne correspond pas à l'ensemble de colonnes d'une table subordonnée, un sous-ensemble de colonnes existant dans les deux tables est inséré. + +Si les types ne correspondent pas à l'une des colonnes de la table tampon et à une table subordonnée, un message d'erreur est entré dans le journal du serveur et le tampon est effacé. +La même chose se produit si la table subordonnée n'existe pas lorsque le tampon est vidé. + +Si vous devez exécuter ALTER pour une table subordonnée et la table tampon, nous vous recommandons de supprimer d'abord la table tampon, d'exécuter ALTER pour la table subordonnée, puis de créer à nouveau la table tampon. + +Si le serveur est redémarré anormalement, les données dans le tampon sont perdues. + +FINAL et SAMPLE ne fonctionnent pas correctement pour les tables tampon. Ces conditions sont transmises à la table de destination, mais ne sont pas utilisées pour traiter les données dans le tampon. Si ces fonctionnalités sont nécessaires, nous vous recommandons d'utiliser uniquement la table tampon pour l'écriture, lors de la lecture à partir de la table de destination. + +Lors de l'ajout de données à un Tampon, un des tampons est verrouillé. Cela entraîne des retards si une opération de lecture est effectuée simultanément à partir de la table. + +Les données insérées dans une table tampon peuvent se retrouver dans la table subordonnée dans un ordre différent et dans des blocs différents. Pour cette raison, une table tampon est difficile à utiliser pour écrire correctement dans un CollapsingMergeTree. Pour éviter les problèmes, vous pouvez définir ‘num\_layers’ 1. + +Si la table de destination est répliquée, certaines caractéristiques attendues des tables répliquées sont perdues lors de l'écriture dans une table tampon. Les modifications aléatoires apportées à l'ordre des lignes et des tailles des parties de données provoquent l'arrêt de la déduplication des données, ce qui signifie qu'il n'est pas possible d'avoir un ‘exactly once’ Ecrire dans des tables répliquées. + +En raison de ces inconvénients, nous ne pouvons recommander l'utilisation d'une table tampon que dans de rares cas. + +Une table tampon est utilisée lorsque trop D'insertions sont reçues d'un grand nombre de serveurs sur une unité de temps et que les données ne peuvent pas être mises en mémoire tampon avant l'insertion, ce qui signifie que les insertions ne peuvent pas s'exécuter assez rapidement. + +Notez qu'il n'est pas judicieux d'insérer des données d'une ligne de temps, même pour Tampon tables. Cela ne produira qu'une vitesse de quelques milliers de lignes par seconde, tandis que l'insertion de blocs de données plus grands peut produire plus d'un million de lignes par seconde (voir la section “Performance”). + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/fr/engines/table-engines/special/dictionary.md b/docs/fr/engines/table-engines/special/dictionary.md new file mode 100644 index 00000000000..530d6510d51 --- /dev/null +++ b/docs/fr/engines/table-engines/special/dictionary.md @@ -0,0 +1,97 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: Dictionnaire +--- + +# Dictionnaire {#dictionary} + +Le `Dictionary` le moteur affiche le [dictionnaire](../../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) données comme une table ClickHouse. + +À titre d'exemple, considérons un dictionnaire de `products` avec la configuration suivante: + +``` xml + + + products + + +
products
+ DSN=some-db-server + + + + 300 + 360 + + + + + + + product_id + + + title + String + + + + + +``` + +Interroger les données du dictionnaire: + +``` sql +SELECT + name, + type, + key, + attribute.names, + attribute.types, + bytes_allocated, + element_count, + source +FROM system.dictionaries +WHERE name = 'products' +``` + +``` text +┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ +│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ +└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ +``` + +Vous pouvez utiliser l' [dictGet\*](../../../sql-reference/functions/ext-dict-functions.md#ext_dict_functions) fonction pour obtenir les données du dictionnaire dans ce format. + +Cette vue n'est pas utile lorsque vous avez besoin d'obtenir des données brutes ou `JOIN` opération. Pour ces cas, vous pouvez utiliser le `Dictionary` moteur, qui affiche les données du dictionnaire dans une table. + +Syntaxe: + +``` sql +CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` +``` + +Exemple d'utilisation: + +``` sql +create table products (product_id UInt64, title String) Engine = Dictionary(products); +``` + + Ok + +Jetez un oeil à ce qui est dans le tableau. + +``` sql +select * from products limit 1; +``` + +``` text +┌────product_id─┬─title───────────┐ +│ 152689 │ Some item │ +└───────────────┴─────────────────┘ +``` + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/fr/engines/table-engines/special/distributed.md b/docs/fr/engines/table-engines/special/distributed.md new file mode 100644 index 00000000000..566172bdb66 --- /dev/null +++ b/docs/fr/engines/table-engines/special/distributed.md @@ -0,0 +1,152 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: "Distribu\xE9" +--- + +# Distribué {#distributed} + +**Les Tables avec moteur distribué ne stockent aucune donnée par elles mêmes**, mais autoriser le traitement des requêtes distribuées sur plusieurs serveurs. +La lecture est automatiquement parallélisée. Lors d'une lecture, les index de table sur les serveurs distants sont utilisés, s'il y en a. + +Le moteur distribué accepte les paramètres: + +- le nom du cluster dans le fichier de configuration du serveur + +- le nom d'une base de données distante + +- le nom d'une table distante + +- (en option) sharding clé + +- (éventuellement) nom de la stratégie, il sera utilisé pour stocker des fichiers temporaires pour l'envoi asynchrone + + Voir aussi: + + - `insert_distributed_sync` paramètre + - [MergeTree](../mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) pour les exemples + +Exemple: + +``` sql +Distributed(logs, default, hits[, sharding_key[, policy_name]]) +``` + +Les données seront lues à partir de tous les serveurs ‘logs’ cluster, à partir de la valeur par défaut.hits table située sur chaque serveur du cluster. +Les données ne sont pas seulement lues mais sont partiellement traitées sur les serveurs distants (dans la mesure du possible). +Par exemple, pour une requête avec GROUP BY, les données seront agrégées sur des serveurs distants et les états intermédiaires des fonctions d'agrégation seront envoyés au serveur demandeur. Ensuite, les données seront plus agrégées. + +Au lieu du nom de la base de données, vous pouvez utiliser une expression constante qui renvoie une chaîne. Par exemple: currentDatabase(). + +logs – The cluster name in the server's config file. + +Les Clusters sont définis comme ceci: + +``` xml + + + + + 1 + + false + + example01-01-1 + 9000 + + + example01-01-2 + 9000 + + + + 2 + false + + example01-02-1 + 9000 + + + example01-02-2 + 1 + 9440 + + + + +``` + +Ici un cluster est défini avec le nom ‘logs’ qui se compose de deux fragments, dont chacune contient deux répliques. +Les partitions se réfèrent aux serveurs qui contiennent différentes parties des données (pour lire toutes les données, vous devez accéder à tous les partitions). +Les répliques sont des serveurs de duplication (afin de lire toutes les données, vous pouvez accéder aux données sur l'une des répliques). + +Les noms de Cluster ne doivent pas contenir de points. + +Paramètre `host`, `port` et , éventuellement, `user`, `password`, `secure`, `compression` sont spécifiés pour chaque serveur: +- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. +- `port` – The TCP port for messenger activity (‘tcp\_port’ dans la configuration, généralement définie sur 9000). Ne le confondez pas avec http\_port. +- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Les droits d'accès](../../../operations/access-rights.md). +- `password` – The password for connecting to a remote server (not masked). Default value: empty string. +- `secure` - Utilisez ssl pour la connexion, généralement vous devez également définir `port` = 9440. Le serveur doit écouter `9440` et avoir des certificats corrects. +- `compression` - Utiliser la compression de données. Valeur par défaut: true. + +When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [équilibrage](../../../operations/settings/settings.md#settings-load_balancing) paramètre. +Si la connexion avec le serveur n'est pas établie, il y aura une tentative de connexion avec un court délai. Si la connexion échoue, la réplique suivante sera sélectionnée, et ainsi de suite pour toutes les répliques. Si la tentative de connexion a échoué pour toutes les répliques, la tentative sera répété de la même façon, plusieurs fois. +Cela fonctionne en faveur de la résilience, mais ne fournit pas de tolérance aux pannes complète: un serveur distant peut accepter la connexion, mais peut ne pas fonctionner ou fonctionner mal. + +Vous pouvez spécifier un seul des fragments (dans ce cas, le traitement de la requête doit être appelé distant, plutôt que distribué) ou jusqu'à un nombre quelconque de fragments. Dans chaque fragment, vous pouvez spécifier un nombre de répliques. Vous pouvez spécifier un nombre différent de répliques pour chaque fragment. + +Vous pouvez spécifier autant de clusters que vous souhaitez dans la configuration. + +Pour afficher vos clusters, utilisez ‘system.clusters’ table. + +Le moteur distribué permet de travailler avec un cluster comme un serveur local. Cependant, le cluster est inextensible: vous devez écrire sa configuration dans le fichier de configuration du serveur (encore mieux, pour tous les serveurs du cluster). + +The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the ‘remote’ fonction de table à la place. Voir la section [Les fonctions de Table](../../../sql-reference/table-functions/index.md). + +Il existe deux méthodes pour écrire des données dans un cluster: + +Tout d'abord, vous pouvez définir les serveurs d'écrire les données à et effectuer l'écriture directement sur chaque fragment. En d'autres termes, effectuez INSERT dans les tables que la table distribuée “looks at”. C'est la solution la plus flexible car vous pouvez utiliser n'importe quel schéma de sharding, qui pourrait être non trivial en raison des exigences du sujet. C'est également la solution la plus optimale puisque les données peuvent être écrites sur différents fragments de manière complètement indépendante. + +Deuxièmement, vous pouvez effectuer INSERT dans une table distribuée. Dans ce cas, la table distribuera les données insérées sur les serveurs eux-mêmes. Pour écrire dans une table distribuée, elle doit avoir un jeu de clés de sharding (le dernier paramètre). De plus, s'il n'y a qu'un seul fragment, l'opération d'écriture fonctionne sans spécifier la clé de sharding, car cela ne signifie rien dans ce cas. + +Chaque fragment peut avoir un poids défini dans le fichier de configuration. Par défaut, le poids est égal à un. Les données sont réparties entre les fragments dans la quantité proportionnelle au poids des fragments. Par exemple, si il y a deux tessons et le premier a un poids de 9 tandis que la seconde a un poids de 10, le premier sera envoyé 9 / 19 parties de lignes, et le second sera envoyé 10 / 19. + +Chaque fragment peut avoir le ‘internal\_replication’ paramètre défini dans le fichier de configuration. + +Si ce paramètre est défini à ‘true’, l'opération d'écriture sélectionne le premier saine réplique et écrit les données. Utilisez cette option si le tableau Distribué “looks at” tables répliquées. En d'autres termes, si la table où les données seront écrites va répliquer elle-même. + +Si elle est définie sur ‘false’ (par défaut), les données sont écrites dans toutes les répliques. En substance, cela signifie que la table distribuée réplique les données elle-même. C'est pire que d'utiliser des tables répliquées, car la cohérence des répliques n'est pas vérifiée et, au fil du temps, elles contiendront des données légèrement différentes. + +Pour sélectionner le fragment auquel une ligne de données est envoyée, l'expression de sharding est analysée et son reste est extrait de la diviser par le poids total des fragments. La ligne est envoyée au fragment qui correspond au demi-intervalle des restes de ‘prev\_weight’ de ‘prev\_weights + weight’, où ‘prev\_weights’ c'est le poids total des tessons avec le plus petit nombre, et ‘weight’ est le poids de cet éclat. Par exemple, s'il y a deux fragments, et que le premier a un poids de 9 tandis que le second a un poids de 10, la ligne sera envoyée au premier fragment pour les restes de la plage \[0, 9), et au second pour les restes de la plage \[9, 19). + +L'expression de sharding peut être n'importe quelle expression de constantes et de colonnes de table qui renvoie un entier. Par exemple, vous pouvez utiliser l'expression ‘rand()’ pour la distribution aléatoire des données, ou ‘UserID’ pour la distribution par le reste de la division de L'ID de l'utilisateur (alors les données d'un seul utilisateur résideront sur un seul fragment, ce qui simplifie l'exécution et la jointure par les utilisateurs). Si l'une des colonnes n'est pas assez répartie uniformément, vous pouvez l'envelopper dans une fonction de hachage: intHash64 (UserID). + +Un simple rappel de la division est une solution limitée pour le sharding et n'est pas toujours approprié. Cela fonctionne pour des volumes de données moyens et importants (des dizaines de serveurs), mais pas pour des volumes de données très importants (des centaines de serveurs ou plus). Dans ce dernier cas, utilisez le schéma de répartition requis par le domaine, plutôt que d'utiliser des entrées dans des tableaux distribués. + +SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. + +Vous devriez être préoccupé par le système de sharding dans les cas suivants: + +- Les requêtes sont utilisées qui nécessitent des données de jointure (IN ou JOIN) par une clé spécifique. Si les données sont partagées par cette clé, vous pouvez utiliser local in ou JOIN au lieu de GLOBAL IN ou global JOIN, ce qui est beaucoup plus efficace. +- Un grand nombre de serveurs est utilisé (des centaines ou plus) avec un grand nombre de petites requêtes (requêtes de clients individuels - sites Web, annonceurs ou partenaires). Pour que les petites requêtes n'affectent pas l'ensemble du cluster, il est logique de localiser les données d'un seul client sur un seul fragment. Alternativement, comme nous l'avons fait dans Yandex.Metrica, vous pouvez configurer le sharding à deux niveaux: divisez le cluster entier en “layers”, où une couche peut être constituée de plusieurs éclats. Les données d'un seul client sont situées sur une seule couche, mais des fragments peuvent être ajoutés à une couche si nécessaire, et les données sont distribuées aléatoirement à l'intérieur de celles-ci. Des tables distribuées sont créées pour chaque couche et une seule table distribuée partagée est créée pour les requêtes globales. + +Les données sont écrites de manière asynchrone. Lorsqu'il est inséré dans la table, le bloc de données est simplement écrit dans le système de fichiers local. Les données sont envoyées aux serveurs distants en arrière-plan dès que possible. La période d'envoi des données est gérée par [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) et [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) paramètre. Le `Distributed` moteur envoie chaque fichier de données insérées séparément, mais vous pouvez activer le lot envoi de fichiers avec l' [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) paramètre. Ce paramètre améliore les performances du cluster en utilisant mieux les ressources réseau et serveur local. Vous devriez vérifier si les données sont envoyées avec succès en vérifiant la liste des fichiers (données en attente d'envoi) dans le répertoire de la table: `/var/lib/clickhouse/data/database/table/`. + +Si le serveur a cessé d'exister ou a subi un redémarrage Brutal (par exemple, après une panne de périphérique) après une insertion dans une table distribuée, les données insérées peuvent être perdues. Si une partie de données endommagée est détectée dans le répertoire de la table, elle est transférée ‘broken’ sous-répertoire et n'est plus utilisé. + +Lorsque l'option max\_parallel\_replicas est activée, le traitement des requêtes est parallélisé entre toutes les répliques d'un seul fragment. Pour plus d'informations, consultez la section [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). + +## Les Colonnes Virtuelles {#virtual-columns} + +- `_shard_num` — Contains the `shard_num` (de `system.clusters`). Type: [UInt32](../../../sql-reference/data-types/int-uint.md). + +!!! note "Note" + Depuis [`remote`](../../../sql-reference/table-functions/remote.md)/`cluster` les fonctions de table créent en interne une instance temporaire du même moteur distribué, `_shard_num` est disponible là-bas aussi. + +**Voir Aussi** + +- [Les colonnes virtuelles](index.md#table_engines-virtual_columns) + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/fr/engines/table-engines/special/external-data.md b/docs/fr/engines/table-engines/special/external-data.md new file mode 100644 index 00000000000..acf63600f61 --- /dev/null +++ b/docs/fr/engines/table-engines/special/external-data.md @@ -0,0 +1,68 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: "De donn\xE9es externes" +--- + +# Données externes pour le traitement des requêtes {#external-data-for-query-processing} + +ClickHouse permet d'Envoyer à un serveur les données nécessaires au traitement d'une requête, ainsi qu'une requête SELECT. Ces données sont placées dans une table temporaire (voir la section “Temporary tables”) et peut être utilisé dans la requête (par exemple, dans les DANS les opérateurs). + +Par exemple, si vous disposez d'un fichier texte avec important des identifiants d'utilisateur, vous pouvez le télécharger sur le serveur avec une requête qui utilise la filtration par cette liste. + +Si vous devez exécuter plusieurs requêtes avec un volume important de données externes, n'utilisez pas cette fonctionnalité. Il est préférable de télécharger les données sur la base de données à l'avance. + +Les données externes peuvent être téléchargées à l'aide du client de ligne de commande (en mode non interactif) ou à l'aide de L'interface HTTP. + +Dans le client de ligne de commande, vous pouvez spécifier une section paramètres du format + +``` bash +--external --file=... [--name=...] [--format=...] [--types=...|--structure=...] +``` + +Vous pouvez avoir plusieurs sections comme ça, pour le nombre de tables étant transmis. + +**–external** – Marks the beginning of a clause. +**–file** – Path to the file with the table dump, or -, which refers to stdin. +Une seule table peut être récupérée à partir de stdin. + +Les paramètres suivants sont facultatifs: **–name**– Name of the table. If omitted, \_data is used. +**–format** – Data format in the file. If omitted, TabSeparated is used. + +L'un des paramètres suivants est requis:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … +**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Définit les noms et les types de colonnes. + +Les fichiers spécifiés dans ‘file’ sera analysé par le format spécifié dans ‘format’, en utilisant les types de données spécifié dans ‘types’ ou ‘structure’. La table sera téléchargée sur le serveur et accessible en tant que table temporaire avec le nom dans ‘name’. + +Exemple: + +``` bash +$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 +849897 +$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +Lors de l'utilisation de L'interface HTTP, les données externes sont transmises au format multipart/form-data. Chaque tableau est transmis en tant que fichier séparé. Le nom de la table est tiré du nom du fichier. Le ‘query\_string’ est passé les paramètres ‘name\_format’, ‘name\_types’, et ‘name\_structure’, où ‘name’ est le nom de la table que ces paramètres correspondent. La signification des paramètres est la même que lors de l'utilisation du client de ligne de commande. + +Exemple: + +``` bash +$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv + +$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +Pour le traitement des requêtes distribuées, les tables temporaires sont envoyées à tous les serveurs distants. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/fr/engines/table-engines/special/file.md b/docs/fr/engines/table-engines/special/file.md new file mode 100644 index 00000000000..eedc1206527 --- /dev/null +++ b/docs/fr/engines/table-engines/special/file.md @@ -0,0 +1,90 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: Fichier +--- + +# Fichier {#table_engines-file} + +Le moteur de table de fichiers conserve les données dans un fichier dans l'un des [fichier +format](../../../interfaces/formats.md#formats) (TabSeparated, Native, etc.). + +Exemples d'utilisation: + +- Exportation de données de ClickHouse vers un fichier. +- Convertir des données d'un format à un autre. +- Mise à jour des données dans ClickHouse via l'édition d'un fichier sur un disque. + +## Utilisation dans le serveur ClickHouse {#usage-in-clickhouse-server} + +``` sql +File(Format) +``` + +Le `Format` paramètre spécifie l'un des formats de fichier disponibles. Effectuer +`SELECT` requêtes, le format doit être pris en charge pour l'entrée, et à effectuer +`INSERT` queries – for output. The available formats are listed in the +[Format](../../../interfaces/formats.md#formats) section. + +ClickHouse ne permet pas de spécifier le chemin du système de fichiers pour`File`. Il utilisera le dossier défini par [chemin](../../../operations/server-configuration-parameters/settings.md) réglage dans la configuration du serveur. + +Lors de la création de la table en utilisant `File(Format)` il crée sous-répertoire vide dans ce dossier. Lorsque les données sont écrites dans cette table, elles sont mises dans `data.Format` fichier dans ce répertoire. + +Vous pouvez créer manuellement ce sous dossier et ce fichier dans le système de fichiers [ATTACH](../../../sql-reference/statements/misc.md) il à la table des informations avec le nom correspondant, de sorte que vous pouvez interroger les données de ce fichier. + +!!! warning "Avertissement" + Soyez prudent avec cette fonctionnalité, car ClickHouse ne garde pas trace des modifications externes apportées à ces fichiers. Le résultat des Écritures simultanées via ClickHouse et en dehors de ClickHouse n'est pas défini. + +**Exemple:** + +**1.** Configurer le `file_engine_table` table: + +``` sql +CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) +``` + +Par défaut ClickHouse va créer un dossier `/var/lib/clickhouse/data/default/file_engine_table`. + +**2.** Créer manuellement `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` contenant: + +``` bash +$ cat data.TabSeparated +one 1 +two 2 +``` + +**3.** Interroger les données: + +``` sql +SELECT * FROM file_engine_table +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Utilisation dans ClickHouse-local {#usage-in-clickhouse-local} + +Dans [clickhouse-local](../../../operations/utilities/clickhouse-local.md) Fichier moteur accepte chemin d'accès au fichier en plus `Format`. Les flux d'entrée / sortie par défaut peuvent être spécifiés en utilisant des noms numériques ou lisibles par l'homme comme `0` ou `stdin`, `1` ou `stdout`. +**Exemple:** + +``` bash +$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" +``` + +## Les détails de mise en Œuvre {#details-of-implementation} + +- Plusieurs `SELECT` les requêtes peuvent être effectuées simultanément, mais `INSERT` requêtes s'attendre les uns les autres. +- Prise en charge de la création d'un nouveau fichier par `INSERT` requête. +- Si le fichier existe, `INSERT` ajouterait de nouvelles valeurs dedans. +- Pas pris en charge: + - `ALTER` + - `SELECT ... SAMPLE` + - Index + - Réplication + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/fr/engines/table-engines/special/generate.md b/docs/fr/engines/table-engines/special/generate.md new file mode 100644 index 00000000000..9b2aa57c3e5 --- /dev/null +++ b/docs/fr/engines/table-engines/special/generate.md @@ -0,0 +1,61 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: GenerateRandom +--- + +# Generaterandom {#table_engines-generate} + +Le moteur de table GenerateRandom produit des données aléatoires pour un schéma de table donné. + +Exemples d'utilisation: + +- Utiliser dans le test pour remplir une grande table reproductible. +- Générer une entrée aléatoire pour les tests de fuzzing. + +## Utilisation dans le serveur ClickHouse {#usage-in-clickhouse-server} + +``` sql +ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) +``` + +Le `max_array_length` et `max_string_length` les paramètres spécifient la longueur maximale de tous +colonnes et chaînes de tableau en conséquence dans les données générées. + +Générer le moteur de table prend en charge uniquement `SELECT` requête. + +Il prend en charge tous les [Les types de données](../../../sql-reference/data-types/index.md) cela peut être stocké dans une table sauf `LowCardinality` et `AggregateFunction`. + +**Exemple:** + +**1.** Configurer le `generate_engine_table` table: + +``` sql +CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) +``` + +**2.** Interroger les données: + +``` sql +SELECT * FROM generate_engine_table LIMIT 3 +``` + +``` text +┌─name─┬──────value─┐ +│ c4xJ │ 1412771199 │ +│ r │ 1791099446 │ +│ 7#$ │ 124312908 │ +└──────┴────────────┘ +``` + +## Les détails de mise en Œuvre {#details-of-implementation} + +- Pas pris en charge: + - `ALTER` + - `SELECT ... SAMPLE` + - `INSERT` + - Index + - Réplication + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/fr/engines/table-engines/special/index.md b/docs/fr/engines/table-engines/special/index.md new file mode 100644 index 00000000000..424a80c511d --- /dev/null +++ b/docs/fr/engines/table-engines/special/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Sp\xE9cial" +toc_priority: 31 +--- + + diff --git a/docs/fr/engines/table-engines/special/join.md b/docs/fr/engines/table-engines/special/join.md new file mode 100644 index 00000000000..a3b33a7aa32 --- /dev/null +++ b/docs/fr/engines/table-engines/special/join.md @@ -0,0 +1,111 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: Rejoindre +--- + +# Rejoindre {#join} + +Structure de données préparée pour l'utilisation dans [JOIN](../../../sql-reference/statements/select/join.md#select-join) opérations. + +## Création d'une Table {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], +) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) +``` + +Voir la description détaillée de la [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) requête. + +**Les Paramètres Du Moteur** + +- `join_strictness` – [ADHÉRER à la rigueur](../../../sql-reference/statements/select/join.md#select-join-strictness). +- `join_type` – [Type de jointure](../../../sql-reference/statements/select/join.md#select-join-types). +- `k1[, k2, ...]` – Key columns from the `USING` la clause que l' `JOIN` l'opération est faite avec de la. + +Entrer `join_strictness` et `join_type` paramètres sans guillemets, par exemple, `Join(ANY, LEFT, col1)`. Ils doivent correspondre à la `JOIN` fonctionnement que le tableau sera utilisé pour. Si les paramètres ne correspondent pas, ClickHouse ne lance pas d'exception et peut renvoyer des données incorrectes. + +## Utilisation Du Tableau {#table-usage} + +### Exemple {#example} + +Création de la table de gauche: + +``` sql +CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog +``` + +``` sql +INSERT INTO id_val VALUES (1,11)(2,12)(3,13) +``` + +Création du côté droit `Join` table: + +``` sql +CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) +``` + +``` sql +INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) +``` + +Rejoindre les tables: + +``` sql +SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 +``` + +``` text +┌─id─┬─val─┬─id_val_join.val─┐ +│ 1 │ 11 │ 21 │ +│ 2 │ 12 │ ᴺᵁᴸᴸ │ +│ 3 │ 13 │ 23 │ +└────┴─────┴─────────────────┘ +``` + +Comme alternative, vous pouvez récupérer des données de la `Join` table, spécifiant la valeur de la clé de jointure: + +``` sql +SELECT joinGet('id_val_join', 'val', toUInt32(1)) +``` + +``` text +┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ +│ 21 │ +└────────────────────────────────────────────┘ +``` + +### Sélection et insertion de données {#selecting-and-inserting-data} + +Vous pouvez utiliser `INSERT` requêtes pour ajouter des données au `Join`-tables de moteur. Si la table a été créée avec `ANY` rigueur, les données pour les clés en double sont ignorées. Avec l' `ALL` rigueur, toutes les lignes sont ajoutées. + +Vous ne pouvez pas effectuer un `SELECT` requête directement à partir de la table. Au lieu de cela, utilisez l'une des méthodes suivantes: + +- Placez la table sur le côté droit dans un `JOIN` clause. +- Appelez le [joinGet](../../../sql-reference/functions/other-functions.md#joinget) fonction, qui vous permet d'extraire des données de la table de la même manière que d'un dictionnaire. + +### Limitations et paramètres {#join-limitations-and-settings} + +Lors de la création d'un tableau, les paramètres suivants sont appliqués: + +- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) +- [max\_rows\_in\_join](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) +- [max\_bytes\_in\_join](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) +- [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) +- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) + +Le `Join`- les tables de moteur ne peuvent pas être utilisées dans `GLOBAL JOIN` opérations. + +Le `Join`-moteur permet d'utiliser [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) réglage de la `CREATE TABLE` déclaration. Et [SELECT](../../../sql-reference/statements/select/index.md) requête permet d'utiliser `join_use_nulls` trop. Si vous avez différents `join_use_nulls` paramètres, vous pouvez obtenir une table de jointure d'erreur. Il dépend de type de JOINTURE. Lorsque vous utilisez [joinGet](../../../sql-reference/functions/other-functions.md#joinget) fonction, vous devez utiliser le même `join_use_nulls` réglage en `CRATE TABLE` et `SELECT` déclaration. + +## Le Stockage De Données {#data-storage} + +`Join` les données de la table sont toujours situées dans la RAM. Lors de l'insertion de lignes dans une table, ClickHouse écrit des blocs de données dans le répertoire du disque afin qu'ils puissent être restaurés lorsque le serveur redémarre. + +Si le serveur redémarre incorrectement, le bloc de données sur le disque peut être perdu ou endommagé. Dans ce cas, vous devrez peut-être supprimer manuellement le fichier contenant des données endommagées. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/fr/engines/table-engines/special/materializedview.md b/docs/fr/engines/table-engines/special/materializedview.md new file mode 100644 index 00000000000..e1b4d4a708d --- /dev/null +++ b/docs/fr/engines/table-engines/special/materializedview.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: MaterializedView +--- + +# Materializedview {#materializedview} + +Utilisé pour implémenter des vues matérialisées (pour plus d'informations, voir [CREATE TABLE](../../../sql-reference/statements/create.md)). Pour stocker des données, il utilise un moteur différent qui a été spécifié lors de la création de la vue. Lors de la lecture d'une table, il utilise juste ce moteur. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/fr/engines/table-engines/special/memory.md b/docs/fr/engines/table-engines/special/memory.md new file mode 100644 index 00000000000..94e619eae07 --- /dev/null +++ b/docs/fr/engines/table-engines/special/memory.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "M\xE9moire" +--- + +# Mémoire {#memory} + +Le moteur de mémoire stocke les données en RAM, sous forme non compressée. Les données sont stockées exactement sous la même forme qu'elles sont reçues lors de la lecture. En d'autres termes, la lecture de ce tableau est entièrement gratuit. +L'accès aux données simultanées est synchronisé. Les verrous sont courts: les opérations de lecture et d'écriture ne se bloquent pas. +Les index ne sont pas pris en charge. La lecture est parallélisée. +La productivité maximale (plus de 10 Go / s) est atteinte sur les requêtes simples, car il n'y a pas de lecture à partir du disque, de décompression ou de désérialisation des données. (Il convient de noter que dans de nombreux cas, la productivité du moteur MergeTree est presque aussi élevée.) +Lors du redémarrage d'un serveur, les données disparaissent de la table et la table devient vide. +Normalement, l'utilisation de ce moteur de table n'est pas justifiée. Cependant, il peut être utilisé pour des tests, et pour des tâches où la vitesse maximale est requise sur un nombre relativement faible de lignes (jusqu'à environ 100 000 000). + +Le moteur de mémoire est utilisé par le système pour les tables temporaires avec des données de requête externes (voir la section “External data for processing a query”), et pour la mise en œuvre globale dans (voir la section “IN operators”). + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/fr/engines/table-engines/special/merge.md b/docs/fr/engines/table-engines/special/merge.md new file mode 100644 index 00000000000..991204c7dd6 --- /dev/null +++ b/docs/fr/engines/table-engines/special/merge.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: Fusionner +--- + +# Fusionner {#merge} + +Le `Merge` moteur (à ne pas confondre avec `MergeTree`) ne stocke pas les données elles-mêmes, mais permet la lecture de n'importe quel nombre d'autres tables simultanément. +La lecture est automatiquement parallélisée. L'écriture dans une table n'est pas prise en charge. Lors de la lecture, les index des tables en cours de lecture sont utilisés, s'ils existent. +Le `Merge` engine accepte les paramètres: le nom de la base de données et une expression régulière pour les tables. + +Exemple: + +``` sql +Merge(hits, '^WatchLog') +``` + +Les données seront lues à partir des tableaux du `hits` base de données dont les noms correspondent à l'expression régulière ‘`^WatchLog`’. + +Au lieu du nom de la base de données, vous pouvez utiliser une expression constante qui renvoie une chaîne. Exemple, `currentDatabase()`. + +Regular expressions — [re2](https://github.com/google/re2) (prend en charge un sous-ensemble de PCRE), sensible à la casse. +Voir les notes sur les symboles d'échappement dans les expressions régulières “match” section. + +Lors de la sélection des tables à lire, le `Merge` le tableau lui-même ne sera pas choisie, même si elle correspond à l'expression rationnelle. C'est pour éviter les boucles. +Il est possible de créer deux `Merge` des tables qui essaieront sans cesse de lire les données des autres, mais ce n'est pas une bonne idée. + +L'utilisation traditionnelle de la `Merge` moteur pour travailler avec un grand nombre de `TinyLog` les tables comme si avec une seule table. + +Exemple 2: + +Disons que vous avez une ancienne table (WatchLog\_old) et que vous avez décidé de changer de partitionnement sans déplacer les données vers une nouvelle table (WatchLog\_new) et que vous devez voir les données des deux tables. + +``` sql +CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree(date, (UserId, EventType), 8192); +INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); + +CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; +INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); + +CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); + +SELECT * +FROM WatchLog +``` + +``` text +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-01 │ 1 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-02 │ 2 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +``` + +## Les Colonnes Virtuelles {#virtual-columns} + +- `_table` — Contains the name of the table from which data was read. Type: [Chaîne](../../../sql-reference/data-types/string.md). + + Vous pouvez définir les conditions constantes sur `_table` dans le `WHERE/PREWHERE` clause (par exemple, `WHERE _table='xyz'`). Dans ce cas l'opération de lecture est effectuée uniquement pour les tables où la condition sur `_table` est satisfaite, pour le `_table` colonne agit comme un index. + +**Voir Aussi** + +- [Les colonnes virtuelles](index.md#table_engines-virtual_columns) + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/fr/engines/table-engines/special/null.md b/docs/fr/engines/table-engines/special/null.md new file mode 100644 index 00000000000..5215fc753be --- /dev/null +++ b/docs/fr/engines/table-engines/special/null.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: 'NULL' +--- + +# NULL {#null} + +Lors de l'écriture dans une table Null, Les données sont ignorées. Lors de la lecture à partir d'une table Null, la réponse est vide. + +Toutefois, vous pouvez créer une vue matérialisée sur une table Nuls. Ainsi, les données écrites dans la table finira dans la vue. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/fr/engines/table-engines/special/set.md b/docs/fr/engines/table-engines/special/set.md new file mode 100644 index 00000000000..32bfde63698 --- /dev/null +++ b/docs/fr/engines/table-engines/special/set.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "D\xE9finir" +--- + +# Définir {#set} + +Un ensemble de données qui est toujours en RAM. Il est conçu pour être utilisé sur le côté droit de l'opérateur (voir la section “IN operators”). + +Vous pouvez utiliser INSERT pour insérer des données dans la table. De nouveaux éléments seront ajoutés à l'ensemble de données, tandis que les doublons seront ignorés. +Mais vous ne pouvez pas effectuer SELECT à partir de la table. La seule façon de récupérer des données est en l'utilisant dans la moitié droite de l'opérateur. + +Les données sont toujours situées dans la RAM. Pour INSERT, les blocs de données insérées sont également écrits dans le répertoire des tables sur le disque. Lors du démarrage du serveur, ces données sont chargées dans la RAM. En d'autres termes, après le redémarrage, les données restent en place. + +Pour un redémarrage brutal du serveur, le bloc de données sur le disque peut être perdu ou endommagé. Dans ce dernier cas, vous devrez peut-être supprimer manuellement le fichier contenant des données endommagées. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/fr/engines/table-engines/special/url.md b/docs/fr/engines/table-engines/special/url.md new file mode 100644 index 00000000000..36068845546 --- /dev/null +++ b/docs/fr/engines/table-engines/special/url.md @@ -0,0 +1,82 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: URL +--- + +# URL (URL, Format) {#table_engines-url} + +Gère les données sur un serveur HTTP / HTTPS distant. Ce moteur est similaire +à l' [Fichier](file.md) moteur. + +## Utilisation du moteur dans le serveur ClickHouse {#using-the-engine-in-the-clickhouse-server} + +Le `format` doit être celui que ClickHouse peut utiliser dans +`SELECT` les requêtes et, si nécessaire, en `INSERTs`. Pour la liste complète des formats pris en charge, voir +[Format](../../../interfaces/formats.md#formats). + +Le `URL` doit être conforme à la structure D'un Localisateur de ressources uniforme. L'URL spécifiée doit pointer vers un serveur +qui utilise le protocole HTTP ou HTTPS. Cela ne nécessite pas de +en-têtes supplémentaires pour obtenir une réponse du serveur. + +`INSERT` et `SELECT` les requêtes sont transformées en `POST` et `GET` demande, +respectivement. Pour le traitement `POST` demandes, le serveur distant doit prendre en charge +[Encodage de transfert en morceaux](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). + +Vous pouvez limiter le nombre maximal de sauts de redirection HTTP GET en utilisant [max\_http\_get\_redirects](../../../operations/settings/settings.md#setting-max_http_get_redirects) paramètre. + +**Exemple:** + +**1.** Créer un `url_engine_table` table sur le serveur : + +``` sql +CREATE TABLE url_engine_table (word String, value UInt64) +ENGINE=URL('http://127.0.0.1:12345/', CSV) +``` + +**2.** Créez un serveur HTTP de base à l'aide des outils Python 3 standard et +démarrer: + +``` python3 +from http.server import BaseHTTPRequestHandler, HTTPServer + +class CSVHTTPServer(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header('Content-type', 'text/csv') + self.end_headers() + + self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) + +if __name__ == "__main__": + server_address = ('127.0.0.1', 12345) + HTTPServer(server_address, CSVHTTPServer).serve_forever() +``` + +``` bash +$ python3 server.py +``` + +**3.** Les données de la demande: + +``` sql +SELECT * FROM url_engine_table +``` + +``` text +┌─word──┬─value─┐ +│ Hello │ 1 │ +│ World │ 2 │ +└───────┴───────┘ +``` + +## Les détails de mise en Œuvre {#details-of-implementation} + +- Les lectures et les écritures peuvent être parallèles +- Pas pris en charge: + - `ALTER` et `SELECT...SAMPLE` opérations. + - Index. + - Réplication. + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/fr/engines/table-engines/special/view.md b/docs/fr/engines/table-engines/special/view.md new file mode 100644 index 00000000000..aaeb6ce90cb --- /dev/null +++ b/docs/fr/engines/table-engines/special/view.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: Vue +--- + +# Vue {#table_engines-view} + +Utilisé pour implémenter des vues (pour plus d'informations, voir `CREATE VIEW query`). Il ne stocke pas de données, mais stocke uniquement les `SELECT` requête. Lors de la lecture d'une table, il exécute cette requête (et supprime toutes les colonnes inutiles de la requête). + +[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/fr/engines/table_engines/index.md b/docs/fr/engines/table_engines/index.md deleted file mode 100644 index 3e199de8ebd..00000000000 --- a/docs/fr/engines/table_engines/index.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Table Engines -toc_priority: 26 -toc_title: Introduction ---- - -# Moteurs De Table {#table_engines} - -Le moteur de table (type de table) détermine: - -- Comment et où les données sont stockées, où les écrire et où les lire. -- Quelles requêtes sont prises en charge et comment. -- Accès simultané aux données. -- Utilisation des index, si elle est présente. -- Indique si l'exécution d'une requête multithread est possible. -- Paramètres de réplication des données. - -## Familles De Moteurs {#engine-families} - -### Mergetree {#mergetree} - -Les moteurs de table les plus universels et fonctionnels pour les tâches à forte charge. La propriété partagée par ces moteurs est l'insertion rapide des données avec traitement ultérieur des données d'arrière-plan. `MergeTree` les moteurs de la famille prennent en charge la réplication des données (avec [Répliqué\*](mergetree_family/replication.md) versions de moteurs), le partitionnement, et d'autres fonctionnalités non prises en charge dans d'autres moteurs. - -Moteurs dans la famille: - -- [MergeTree](mergetree_family/mergetree.md) -- [ReplacingMergeTree](mergetree_family/replacingmergetree.md) -- [SummingMergeTree](mergetree_family/summingmergetree.md) -- [AggregatingMergeTree](mergetree_family/aggregatingmergetree.md) -- [CollapsingMergeTree](mergetree_family/collapsingmergetree.md) -- [VersionedCollapsingMergeTree](mergetree_family/versionedcollapsingmergetree.md) -- [GraphiteMergeTree](mergetree_family/graphitemergetree.md) - -### Journal {#log} - -Léger [moteur](log_family/index.md) avec une fonctionnalité minimale. Ils sont les plus efficaces lorsque vous devez écrire rapidement de nombreuses petites tables (jusqu'à environ 1 million de lignes) et les lire plus tard dans leur ensemble. - -Moteurs dans la famille: - -- [TinyLog](log_family/tinylog.md) -- [StripeLog](log_family/stripelog.md) -- [Journal](log_family/log.md) - -### Moteurs D'Intégration {#integration-engines} - -Moteurs de communication avec d'autres systèmes de stockage et de traitement de données. - -Moteurs dans la famille: - -- [Kafka](integrations/kafka.md) -- [MySQL](integrations/mysql.md) -- [ODBC](integrations/odbc.md) -- [JDBC](integrations/jdbc.md) -- [HDFS](integrations/hdfs.md) - -### Moteurs Spéciaux {#special-engines} - -Moteurs dans la famille: - -- [Distribué](special/distributed.md) -- [MaterializedView](special/materializedview.md) -- [Dictionnaire](special/dictionary.md) -- [Fusionner](special/merge.md) -- [Fichier](special/file.md) -- [NULL](special/null.md) -- [Définir](special/set.md) -- [Rejoindre](special/join.md) -- [URL](special/url.md) -- [Vue](special/view.md) -- [Mémoire](special/memory.md) -- [Tampon](special/buffer.md) - -## Les Colonnes Virtuelles {#table_engines-virtual-columns} - -Colonne virtuelle est un attribut de moteur de table intégrale qui est défini dans le code source du moteur. - -Vous ne devez pas spécifier de colonnes virtuelles dans `CREATE TABLE` requête et vous ne pouvez pas les voir dans `SHOW CREATE TABLE` et `DESCRIBE TABLE` les résultats de la requête. Les colonnes virtuelles sont également en lecture seule, vous ne pouvez donc pas insérer de données dans des colonnes virtuelles. - -Pour sélectionner des données dans une colonne virtuelle, vous devez spécifier son nom `SELECT` requête. `SELECT *` ne renvoie pas de valeurs à partir de colonnes virtuelles. - -Si vous créez une table avec une colonne portant le même nom que l'une des colonnes virtuelles de la table, la colonne virtuelle devient inaccessible. Nous ne recommandons pas de faire cela. Pour éviter les conflits, les noms de colonnes virtuelles sont généralement précédés d'un trait de soulignement. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/fr/engines/table_engines/integrations/hdfs.md b/docs/fr/engines/table_engines/integrations/hdfs.md deleted file mode 100644 index 0cc1b423983..00000000000 --- a/docs/fr/engines/table_engines/integrations/hdfs.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 36 -toc_title: HDFS ---- - -# HDFS {#table_engines-hdfs} - -Ce moteur fournit l'intégration avec [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) l'écosystème en permettant de gérer les données sur [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)via ClickHouse. Ce moteur est similaire -à l' [Fichier](../special/file.md) et [URL](../special/url.md) moteurs, mais fournit des fonctionnalités spécifiques Hadoop. - -## Utilisation {#usage} - -``` sql -ENGINE = HDFS(URI, format) -``` - -Le `URI` paramètre est L'URI du fichier entier dans HDFS. -Le `format` paramètre spécifie l'un des formats de fichier disponibles. Effectuer -`SELECT` requêtes, le format doit être pris en charge pour l'entrée, et à effectuer -`INSERT` queries – for output. The available formats are listed in the -[Format](../../../interfaces/formats.md#formats) section. -Le chemin le cadre de `URI` peut contenir des globules. Dans ce cas, le tableau serait en lecture seule. - -**Exemple:** - -**1.** Configurer le `hdfs_engine_table` table: - -``` sql -CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') -``` - -**2.** Remplir le fichier: - -``` sql -INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) -``` - -**3.** Interroger les données: - -``` sql -SELECT * FROM hdfs_engine_table LIMIT 2 -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Détails De Mise En Œuvre {#implementation-details} - -- Les lectures et les écritures peuvent être parallèles -- Pas pris en charge: - - `ALTER` et `SELECT...SAMPLE` opérations. - - Index. - - Réplication. - -**Globs dans le chemin** - -Plusieurs composants de chemin peuvent avoir des globs. Pour être traité, le fichier devrait exister et correspondre au modèle de chemin entier. Liste des fichiers détermine pendant `SELECT` (pas à l' `CREATE` moment). - -- `*` — Substitutes any number of any characters except `/` y compris la chaîne vide. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -Les Constructions avec `{}` sont similaires à l' [distant](../../../sql_reference/table_functions/remote.md) table de fonction. - -**Exemple** - -1. Supposons que nous ayons plusieurs fichiers au format TSV avec les URI suivants sur HDFS: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. Il y a plusieurs façons de faire une table composée des six fichiers: - - - -``` sql -CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') -``` - -Une autre façon: - -``` sql -CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') -``` - -Table se compose de tous les fichiers dans les deux répertoires (tous les fichiers doivent satisfaire le format et le schéma décrits dans la requête): - -``` sql -CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') -``` - -!!! warning "Avertissement" - Si la liste des fichiers contient des plages de nombres avec des zéros en tête, utilisez la construction avec des accolades pour chaque chiffre séparément ou utilisez `?`. - -**Exemple** - -Créer une table avec des fichiers nommés `file000`, `file001`, … , `file999`: - -``` sql -CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') -``` - -## Les Colonnes Virtuelles {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**Voir Aussi** - -- [Les colonnes virtuelles](../index.md#table_engines-virtual_columns) - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/fr/engines/table_engines/integrations/index.md b/docs/fr/engines/table_engines/integrations/index.md deleted file mode 100644 index 705aa507d6a..00000000000 --- a/docs/fr/engines/table_engines/integrations/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Integrations -toc_priority: 30 ---- - - diff --git a/docs/fr/engines/table_engines/integrations/jdbc.md b/docs/fr/engines/table_engines/integrations/jdbc.md deleted file mode 100644 index de636f70abc..00000000000 --- a/docs/fr/engines/table_engines/integrations/jdbc.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 34 -toc_title: JDBC ---- - -# JDBC {#table-engine-jdbc} - -Permet à ClickHouse de se connecter à des bases de données externes via [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). - -Pour implémenter la connexion JDBC, ClickHouse utilise le programme séparé [clickhouse-JDBC-pont](https://github.com/alex-krash/clickhouse-jdbc-bridge) cela devrait fonctionner comme un démon. - -Ce moteur prend en charge le [Nullable](../../../sql_reference/data_types/nullable.md) type de données. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name -( - columns list... -) -ENGINE = JDBC(dbms_uri, external_database, external_table) -``` - -**Les Paramètres Du Moteur** - -- `dbms_uri` — URI of an external DBMS. - - Format: `jdbc:://:/?user=&password=`. - Exemple pour MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. - -- `external_database` — Database in an external DBMS. - -- `external_table` — Name of the table in `external_database`. - -## Exemple D'Utilisation {#usage-example} - -Création d'une table dans le serveur MySQL en se connectant directement avec son client console: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Création d'une table dans le serveur ClickHouse et sélection des données: - -``` sql -CREATE TABLE jdbc_table -( - `int_id` Int32, - `int_nullable` Nullable(Int32), - `float` Float32, - `float_nullable` Nullable(Float32) -) -ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') -``` - -``` sql -SELECT * -FROM jdbc_table -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## Voir Aussi {#see-also} - -- [Fonction de table JDBC](../../../sql_reference/table_functions/jdbc.md). - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/fr/engines/table_engines/integrations/kafka.md b/docs/fr/engines/table_engines/integrations/kafka.md deleted file mode 100644 index 6bb2f2a1bad..00000000000 --- a/docs/fr/engines/table_engines/integrations/kafka.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 32 -toc_title: Kafka ---- - -# Kafka {#kafka} - -Ce moteur fonctionne avec [Apache Kafka](http://kafka.apache.org/). - -Kafka vous permet de: - -- Publier ou s'abonner aux flux de données. -- Organiser le stockage tolérant aux pannes. -- Traiter les flux à mesure qu'ils deviennent disponibles. - -## Création d'une Table {#table_engine-kafka-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = Kafka() -SETTINGS - kafka_broker_list = 'host:port', - kafka_topic_list = 'topic1,topic2,...', - kafka_group_name = 'group_name', - kafka_format = 'data_format'[,] - [kafka_row_delimiter = 'delimiter_symbol',] - [kafka_schema = '',] - [kafka_num_consumers = N,] - [kafka_skip_broken_messages = N] -``` - -Les paramètres requis: - -- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). -- `kafka_topic_list` – A list of Kafka topics. -- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don't want messages to be duplicated in the cluster, use the same group name everywhere. -- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` la fonction, tels que `JSONEachRow`. Pour plus d'informations, voir le [Format](../../../interfaces/formats.md) section. - -Paramètres facultatifs: - -- `kafka_row_delimiter` – Delimiter character, which ends the message. -- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap'n Proto](https://capnproto.org/) nécessite le chemin d'accès du fichier de schéma et le nom de la racine `schema.capnp:Message` objet. -- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Spécifiez plus de consommateurs si le débit d'un consommateur est insuffisant. Le nombre total de consommateurs ne doit pas dépasser le nombre de partitions dans la rubrique, car un seul consommateur peut être affecté par partition. -- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. Si `kafka_skip_broken_messages = N` puis le moteur saute *N* Messages Kafka qui ne peuvent pas être analysés (un message est égal à une ligne de données). - -Exemple: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - SELECT * FROM queue LIMIT 5; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', - kafka_topic_list = 'topic', - kafka_group_name = 'group1', - kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') - SETTINGS kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; -``` - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets. Si possible, optez anciens projets à la méthode décrite ci-dessus. - -``` sql -Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format - [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) -``` - -
- -## Description {#description} - -Les messages livrés sont suivis automatiquement, de sorte que chaque message d'un groupe n'est compté qu'une seule fois. Si vous souhaitez obtenir les données deux fois, créez une copie de la table avec un autre nom de groupe. - -Les groupes sont flexibles et synchronisés sur le cluster. Par exemple, si vous avez 10 thèmes et 5 copies d'une table dans un cluster, chaque copie obtient 2 sujets. Si le nombre de copies change, les rubriques sont redistribuées automatiquement entre les copies. En savoir plus à ce sujet à http://kafka.apache.org/intro. - -`SELECT` n'est pas particulièrement utile pour la lecture de messages (sauf pour le débogage), car chaque message ne peut être lu qu'une seule fois. Il est plus pratique de créer des threads en temps réel à l'aide de vues matérialisées. Pour ce faire: - -1. Utilisez le moteur pour créer un consommateur Kafka et considérez-le comme un flux de données. -2. Créez une table avec la structure souhaitée. -3. Créer une vue matérialisée qui convertit les données du moteur et le met dans une table créée précédemment. - -Lorsque l' `MATERIALIZED VIEW` rejoint le moteur, il commence à collecter des données en arrière-plan. Cela vous permet de recevoir continuellement des messages de Kafka et de les convertir au format requis en utilisant `SELECT`. -Une table kafka peut avoir autant de vues matérialisées que vous le souhaitez, elles ne lisent pas directement les données de la table kafka, mais reçoivent de nouveaux enregistrements( en blocs), de cette façon vous pouvez écrire sur plusieurs tables avec différents niveaux de détail (avec regroupement - agrégation et sans). - -Exemple: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - CREATE TABLE daily ( - day Date, - level String, - total UInt64 - ) ENGINE = SummingMergeTree(day, (day, level), 8192); - - CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total - FROM queue GROUP BY day, level; - - SELECT level, sum(total) FROM daily GROUP BY level; -``` - -Pour améliorer les performances, les messages reçus sont regroupées en blocs de la taille de [max\_insert\_block\_size](../../../operations/server_configuration_parameters/settings.md#settings-max_insert_block_size). Si le bloc n'a pas été formé à l'intérieur [stream\_flush\_interval\_ms](../../../operations/server_configuration_parameters/settings.md) millisecondes, les données seront vidées dans le tableau, indépendamment de l'intégralité du bloc. - -Pour arrêter de recevoir des données de rubrique ou pour modifier la logique de conversion, détachez la vue matérialisée: - -``` sql - DETACH TABLE consumer; - ATTACH TABLE consumer; -``` - -Si vous souhaitez modifier la table cible en utilisant `ALTER`, nous vous recommandons de désactiver la vue matériel pour éviter les divergences entre la table cible et les données de la vue. - -## Configuration {#configuration} - -Similaire à GraphiteMergeTree, le moteur Kafka prend en charge la configuration étendue à l'aide du fichier de configuration ClickHouse. Il y a deux clés de configuration que vous pouvez utiliser: global (`kafka`) et des rubriques (`kafka_*`). La configuration globale est appliquée en premier, puis la configuration au niveau de la rubrique est appliquée (si elle existe). - -``` xml - - - cgrp - smallest - - - - - 250 - 100000 - -``` - -Pour obtenir une liste des options de configuration possibles, consultez [librdkafka référence de configuration](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Utilisez le trait de soulignement (`_`) au lieu d'un point dans la configuration ClickHouse. Exemple, `check.crcs=true` sera `true`. - -## Les Colonnes Virtuelles {#virtual-columns} - -- `_topic` — Kafka topic. -- `_key` — Key of the message. -- `_offset` — Offset of the message. -- `_timestamp` — Timestamp of the message. -- `_partition` — Partition of Kafka topic. - -**Voir Aussi** - -- [Les colonnes virtuelles](../index.md#table_engines-virtual_columns) - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/fr/engines/table_engines/integrations/mysql.md b/docs/fr/engines/table_engines/integrations/mysql.md deleted file mode 100644 index 5cec6701228..00000000000 --- a/docs/fr/engines/table_engines/integrations/mysql.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 33 -toc_title: MySQL ---- - -# Mysql {#mysql} - -Le moteur MySQL vous permet d'effectuer `SELECT` requêtes sur les données stockées sur un serveur MySQL distant. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... -) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -Voir une description détaillée de la [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) requête. - -La structure de la table peut différer de la structure de la table MySQL d'origine: - -- Les noms de colonnes doivent être les mêmes que dans la table MySQL d'origine, mais vous pouvez utiliser seulement certaines de ces colonnes et dans n'importe quel ordre. -- Les types de colonnes peuvent différer de ceux de la table MySQL d'origine. ClickHouse essaie de [jeter](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) valeurs des types de données ClickHouse. - -**Les Paramètres Du Moteur** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` les requêtes de `REPLACE INTO`. Si `replace_query=1` la requête est substitué. - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` expression qui est ajoutée à la `INSERT` requête. - - Exemple: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, où `on_duplicate_clause` être `UPDATE c2 = c2 + 1`. Voir la [Documentation de MySQL](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) pour trouver lequel `on_duplicate_clause` vous pouvez utiliser avec le `ON DUPLICATE KEY` clause. - - Spécifier `on_duplicate_clause` vous avez besoin de passer `0` à l' `replace_query` paramètre. Si vous passez simultanément `replace_query = 1` et `on_duplicate_clause`, Clickhouse génère une exception. - -Simple `WHERE` des clauses telles que `=, !=, >, >=, <, <=` sont exécutés sur le serveur MySQL. - -Le reste des conditions et le `LIMIT` les contraintes d'échantillonnage sont exécutées dans ClickHouse uniquement après la fin de la requête à MySQL. - -## Exemple D'Utilisation {#usage-example} - -Table dans MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Table dans ClickHouse, récupération des données de la table MySQL créée ci-dessus: - -``` sql -CREATE TABLE mysql_table -( - `float_nullable` Nullable(Float32), - `int_id` Int32 -) -ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` sql -SELECT * FROM mysql_table -``` - -``` text -┌─float_nullable─┬─int_id─┐ -│ ᴺᵁᴸᴸ │ 1 │ -└────────────────┴────────┘ -``` - -## Voir Aussi {#see-also} - -- [Le ‘mysql’ fonction de table](../../../sql_reference/table_functions/mysql.md) -- [Utilisation de MySQL comme source de dictionnaire externe](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/fr/engines/table_engines/integrations/odbc.md b/docs/fr/engines/table_engines/integrations/odbc.md deleted file mode 100644 index 22db868bdad..00000000000 --- a/docs/fr/engines/table_engines/integrations/odbc.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 35 -toc_title: ODBC ---- - -# ODBC {#table-engine-odbc} - -Permet à ClickHouse de se connecter à des bases de données externes via [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -Pour implémenter en toute sécurité les connexions ODBC, ClickHouse utilise un programme distinct `clickhouse-odbc-bridge`. Si le pilote ODBC est chargé directement depuis `clickhouse-server`, les problèmes de pilote peuvent planter le serveur ClickHouse. Clickhouse démarre automatiquement `clickhouse-odbc-bridge` lorsque cela est nécessaire. Le programme ODBC bridge est installé à partir du même package que `clickhouse-server`. - -Ce moteur prend en charge le [Nullable](../../../sql_reference/data_types/nullable.md) type de données. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1], - name2 [type2], - ... -) -ENGINE = ODBC(connection_settings, external_database, external_table) -``` - -Voir une description détaillée de la [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) requête. - -La structure de la table peut différer de la structure de la table source: - -- Les noms de colonnes doivent être les mêmes que dans la table source, mais vous pouvez utiliser quelques-unes de ces colonnes et dans n'importe quel ordre. -- Les types de colonnes peuvent différer de ceux de la table source. ClickHouse essaie de [jeter](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) valeurs des types de données ClickHouse. - -**Les Paramètres Du Moteur** - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` fichier. -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -## Exemple D'Utilisation {#usage-example} - -**Récupération des données de L'installation MySQL locale via ODBC** - -Cet exemple est vérifié pour Ubuntu Linux 18.04 et MySQL server 5.7. - -Assurez-vous que unixODBC et MySQL Connector sont installés. - -Par défaut (si installé à partir de paquets), ClickHouse démarre en tant qu'utilisateur `clickhouse`. Ainsi, vous devez créer et configurer cet utilisateur dans le serveur MySQL. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -Puis configurez la connexion dans `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -Vous pouvez vérifier la connexion en utilisant le `isql` utilitaire de l'installation unixODBC. - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -Table dans MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Table dans ClickHouse, récupération des données de la table MySQL: - -``` sql -CREATE TABLE odbc_t -( - `int_id` Int32, - `float_nullable` Nullable(Float32) -) -ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') -``` - -``` sql -SELECT * FROM odbc_t -``` - -``` text -┌─int_id─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ -└────────┴────────────────┘ -``` - -## Voir Aussi {#see-also} - -- [Dictionnaires externes ODBC](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [Fonction de table ODBC](../../../sql_reference/table_functions/odbc.md) - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/fr/engines/table_engines/log_family/index.md b/docs/fr/engines/table_engines/log_family/index.md deleted file mode 100644 index c698303a8ac..00000000000 --- a/docs/fr/engines/table_engines/log_family/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Log Family -toc_priority: 29 ---- - - diff --git a/docs/fr/engines/table_engines/log_family/log.md b/docs/fr/engines/table_engines/log_family/log.md deleted file mode 100644 index 9adcd4cf9fa..00000000000 --- a/docs/fr/engines/table_engines/log_family/log.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 33 -toc_title: Journal ---- - -# Journal {#log} - -Moteur appartient à la famille de journal des moteurs. Voir les propriétés communes des moteurs de journal et leurs différences dans le [Famille De Moteurs En Rondins](log_family.md) article. - -Journal diffère de [TinyLog](tinylog.md) dans un petit fichier de “marks” réside avec les fichiers de colonne. Ces marques sont écrites sur chaque bloc de données et contiennent des décalages qui indiquent où commencer à lire le fichier afin d'ignorer le nombre de lignes spécifié. Cela permet de lire les données de table dans plusieurs threads. -Pour l'accès aux données simultanées, les opérations de lecture peuvent être effectuées simultanément, tandis que les opérations d'écriture bloc lit et l'autre. -Le moteur de journal ne prend pas en charge les index. De même, si l'écriture dans une table a échoué, la table est cassée et la lecture de celle-ci renvoie une erreur. Le moteur de journal est approprié pour les données temporaires, les tables en écriture unique, et à des fins de test ou de démonstration. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/fr/engines/table_engines/log_family/log_family.md b/docs/fr/engines/table_engines/log_family/log_family.md deleted file mode 100644 index e16f9e6639a..00000000000 --- a/docs/fr/engines/table_engines/log_family/log_family.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 31 -toc_title: Introduction ---- - -# Famille De Moteurs En Rondins {#log-engine-family} - -Ces moteurs ont été développés pour les scénarios où vous devez écrire rapidement de nombreuses petites tables (jusqu'à environ 1 million de lignes) et les lire plus tard dans leur ensemble. - -Les moteurs de la famille: - -- [StripeLog](stripelog.md) -- [Journal](log.md) -- [TinyLog](tinylog.md) - -## Propriétés Communes {#common-properties} - -Moteur: - -- Stocker des données sur un disque. - -- Ajouter des données à la fin du fichier lors de l'écriture. - -- Bloque simultanées dans l'accès aux données. - - Lors `INSERT` requêtes, la table est verrouillée, et d'autres requêtes pour la lecture et l'écriture de données attendent que la table se déverrouille. S'il n'y a pas de requêtes d'écriture de données, un certain nombre de requêtes de lecture de données peuvent être effectuées simultanément. - -- Ne prennent pas en charge [mutation](../../../sql_reference/statements/alter.md#alter-mutations) opérations. - -- Ne prennent pas en charge les index. - - Cela signifie que `SELECT` les requêtes pour les plages de données ne sont pas efficaces. - -- N'écrivez pas de données de manière atomique. - - Vous pouvez obtenir une table avec des données corrompues si quelque chose interrompt l'opération d'écriture, par exemple, un arrêt anormal du serveur. - -## Différence {#differences} - -Le `TinyLog` le moteur est le plus simple de la famille et offre la fonctionnalité la plus pauvre et la plus faible efficacité. Le `TinyLog` le moteur ne prend pas en charge la lecture de données parallèles par plusieurs threads. Il lit les données plus lentement que les autres moteurs de la famille qui prennent en charge la lecture parallèle et utilise presque autant de descripteurs que `Log` moteur, car il stocke chaque colonne dans un fichier séparé. Utilisez-le dans des scénarios simples à faible charge. - -Le `Log` et `StripeLog` les moteurs prennent en charge la lecture de données parallèle. Lors de la lecture de données, ClickHouse utilise plusieurs threads. Chaque thread traite un bloc de données séparé. Le `Log` le moteur utilise un fichier distinct pour chaque colonne de la table. `StripeLog` stocke toutes les données dans un seul fichier. En conséquence, la `StripeLog` moteur utilise moins de descripteurs dans le système d'exploitation, mais le `Log` moteur fournit une plus grande efficacité lors de la lecture des données. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/fr/engines/table_engines/log_family/stripelog.md b/docs/fr/engines/table_engines/log_family/stripelog.md deleted file mode 100644 index 35d4706c592..00000000000 --- a/docs/fr/engines/table_engines/log_family/stripelog.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 32 -toc_title: StripeLog ---- - -# Stripelog {#stripelog} - -Ce moteur appartient à la famille des moteurs en rondins. Voir les propriétés communes des moteurs de journal et leurs différences dans le [Famille De Moteurs En Rondins](log_family.md) article. - -Utilisez ce moteur dans des scénarios lorsque vous devez écrire de nombreuses tables avec une petite quantité de données (moins de 1 million de lignes). - -## Création d'une Table {#table_engines-stripelog-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = StripeLog -``` - -Voir la description détaillée de la [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) requête. - -## L'écriture des Données {#table_engines-stripelog-writing-the-data} - -Le `StripeLog` moteur stocke toutes les colonnes dans un fichier. Pour chaque `INSERT` requête, ClickHouse ajoute le bloc de données à la fin d'un fichier de table, en écrivant des colonnes une par une. - -Pour chaque table ClickHouse écrit les fichiers: - -- `data.bin` — Data file. -- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. - -Le `StripeLog` moteur ne prend pas en charge la `ALTER UPDATE` et `ALTER DELETE` opérations. - -## La lecture des Données {#table_engines-stripelog-reading-the-data} - -Le fichier avec des marques permet à ClickHouse de paralléliser la lecture des données. Cela signifie qu'une `SELECT` la requête renvoie des lignes dans un ordre imprévisible. L'utilisation de la `ORDER BY` clause pour trier les lignes. - -## Exemple D'Utilisation {#table_engines-stripelog-example-of-use} - -Création d'une table: - -``` sql -CREATE TABLE stripe_log_table -( - timestamp DateTime, - message_type String, - message String -) -ENGINE = StripeLog -``` - -Insertion de données: - -``` sql -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') -``` - -Nous avons utilisé deux `INSERT` requêtes pour créer deux blocs de données `data.bin` fichier. - -ClickHouse utilise plusieurs threads lors de la sélection des données. Chaque thread lit un bloc de données séparé et renvoie les lignes résultantes indépendamment à la fin. En conséquence, l'ordre des blocs de lignes dans le résultat ne correspond pas à l'ordre des mêmes blocs dans l'entrée, dans la plupart des cas. Exemple: - -``` sql -SELECT * FROM stripe_log_table -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -┌───────────timestamp─┬─message_type─┬─message───────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -└─────────────────────┴──────────────┴───────────────────────────┘ -``` - -Trier les résultats (ordre croissant par défaut): - -``` sql -SELECT * FROM stripe_log_table ORDER BY timestamp -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -``` - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/fr/engines/table_engines/log_family/tinylog.md b/docs/fr/engines/table_engines/log_family/tinylog.md deleted file mode 100644 index ddf935ba789..00000000000 --- a/docs/fr/engines/table_engines/log_family/tinylog.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 34 -toc_title: TinyLog ---- - -# TinyLog {#tinylog} - -Le moteur appartient à la famille de moteurs en rondins. Voir [Famille De Moteurs En Rondins](log_family.md) pour les propriétés communes des moteurs en rondins et leurs différences. - -Ce moteur de table est généralement utilisé avec la méthode write-once: écrivez des données une fois, puis lisez-les autant de fois que nécessaire. Par exemple, vous pouvez utiliser `TinyLog`- tapez des tables pour les données intermédiaires qui sont traitées en petits lots. Notez que le stockage des données dans un grand nombre de petites tables est inefficace. - -Les requêtes sont exécutées dans un flux unique. En d'autres termes, ce moteur est destiné à des tables relativement petites (jusqu'à environ 1 000 000 de lignes). Il est logique d'utiliser ce moteur de table si vous avez beaucoup de petites tables, car il est plus simple que le [Journal](log.md) moteur (moins de fichiers doivent être ouverts). - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/fr/engines/table_engines/mergetree_family/aggregatingmergetree.md b/docs/fr/engines/table_engines/mergetree_family/aggregatingmergetree.md deleted file mode 100644 index 307e9ac3aff..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/aggregatingmergetree.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 35 -toc_title: AggregatingMergeTree ---- - -# Aggregatingmergetree {#aggregatingmergetree} - -Le moteur hérite de [MergeTree](mergetree.md#table_engines-mergetree), modifier la logique pour les parties de données Fusion. ClickHouse remplace toutes les lignes avec la même clé primaire (ou, plus précisément, avec la même [clé de tri](mergetree.md)) avec une seule ligne (dans un rayon d'une partie des données) qui stocke une combinaison d'états de fonctions d'agrégation. - -Vous pouvez utiliser `AggregatingMergeTree` tables pour l'agrégation incrémentielle des données, y compris pour les vues matérialisées agrégées. - -Le moteur traite toutes les colonnes avec [AggregateFunction](../../../sql_reference/data_types/aggregatefunction.md) type. - -Il est approprié d'utiliser `AggregatingMergeTree` si elle réduit le nombre de lignes par commande. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = AggregatingMergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[TTL expr] -[SETTINGS name=value, ...] -``` - -Pour une description des paramètres de requête, voir [demande de description](../../../sql_reference/statements/create.md). - -**Les clauses de requête** - -Lors de la création d'un `AggregatingMergeTree` la table de la même [clause](mergetree.md) sont nécessaires, comme lors de la création d'un `MergeTree` table. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -Tous les paramètres ont la même signification que dans `MergeTree`. -
- -## Sélectionner et insérer {#select-and-insert} - -Pour insérer des données, utilisez [INSERT SELECT](../../../sql_reference/statements/insert_into.md) requête avec l'ensemble-l'État des fonctions. -Lors de la sélection des données `AggregatingMergeTree` table, utilisez `GROUP BY` et les mêmes fonctions d'agrégat que lors de l'insertion de données, mais en utilisant `-Merge` suffixe. - -Dans les résultats de `SELECT` requête, les valeurs de `AggregateFunction` type ont une représentation binaire spécifique à l'implémentation pour tous les formats de sortie ClickHouse. Si les données de vidage dans, par exemple, `TabSeparated` format avec `SELECT` requête alors ce vidage peut être chargé en utilisant `INSERT` requête. - -## Exemple D'une vue matérialisée agrégée {#example-of-an-aggregated-materialized-view} - -`AggregatingMergeTree` vue matérialisée qui regarde le `test.visits` table: - -``` sql -CREATE MATERIALIZED VIEW test.basic -ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) -AS SELECT - CounterID, - StartDate, - sumState(Sign) AS Visits, - uniqState(UserID) AS Users -FROM test.visits -GROUP BY CounterID, StartDate; -``` - -Insertion de données dans la `test.visits` table. - -``` sql -INSERT INTO test.visits ... -``` - -Les données sont insérées dans la table et la vue `test.basic` que va effectuer l'agrégation. - -Pour obtenir les données agrégées, nous devons exécuter une requête telle que `SELECT ... GROUP BY ...` à partir de la vue `test.basic`: - -``` sql -SELECT - StartDate, - sumMerge(Visits) AS Visits, - uniqMerge(Users) AS Users -FROM test.basic -GROUP BY StartDate -ORDER BY StartDate; -``` - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/fr/engines/table_engines/mergetree_family/collapsingmergetree.md b/docs/fr/engines/table_engines/mergetree_family/collapsingmergetree.md deleted file mode 100644 index b58a4e7ebe8..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/collapsingmergetree.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 36 -toc_title: CollapsingMergeTree ---- - -# Collapsingmergetree {#table_engine-collapsingmergetree} - -Le moteur hérite de [MergeTree](mergetree.md) et ajoute la logique de l'effondrement des lignes de données de pièces algorithme de fusion. - -`CollapsingMergeTree` supprime de manière asynchrone (réduit) les paires de lignes si tous les champs d'une clé de tri (`ORDER BY`) sont équivalents à l'exception du champ particulier `Sign` ce qui peut avoir `1` et `-1` valeur. Les lignes sans paire sont conservées. Pour plus de détails, voir le [Effondrer](#table_engine-collapsingmergetree-collapsing) la section du document. - -Le moteur peut réduire considérablement le volume de stockage et augmenter l'efficacité de `SELECT` requête en conséquence. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = CollapsingMergeTree(sign) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Pour une description des paramètres de requête, voir [description de la requête](../../../sql_reference/statements/create.md). - -**Paramètres CollapsingMergeTree** - -- `sign` — Name of the column with the type of row: `1` est un “state” rangée, `-1` est un “cancel” rangée. - - Column data type — `Int8`. - -**Les clauses de requête** - -Lors de la création d'un `CollapsingMergeTree` de table, de la même [les clauses de requête](mergetree.md#table_engine-mergetree-creating-a-table) sont nécessaires, comme lors de la création d'un `MergeTree` table. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) -``` - -Tous les paramètres excepté `sign` ont la même signification que dans `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` — “state” rangée, `-1` — “cancel” rangée. - - Column Data Type — `Int8`. - -
- -## Effondrer {#table_engine-collapsingmergetree-collapsing} - -### Données {#data} - -Considérez la situation où vous devez enregistrer des données en constante évolution pour un objet. Il semble logique d'avoir une ligne pour un objet et de la mettre à jour à tout changement, mais l'opération de mise à jour est coûteuse et lente pour le SGBD car elle nécessite une réécriture des données dans le stockage. Si vous avez besoin d'écrire des données rapidement, la mise à jour n'est pas acceptable, mais vous pouvez écrire les modifications d'un objet de manière séquentielle comme suit. - -Utilisez la colonne particulière `Sign`. Si `Sign = 1` cela signifie que la ligne est un état d'un objet, appelons-la “state” rangée. Si `Sign = -1` il signifie l'annulation de l'état d'un objet avec les mêmes attributs, nous allons l'appeler “cancel” rangée. - -Par exemple, nous voulons calculer combien de pages les utilisateurs ont vérifié sur un site et combien de temps ils étaient là. À un certain moment nous écrire la ligne suivante avec l'état de l'activité de l'utilisateur: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -À un moment donné, nous enregistrons le changement d'activité de l'utilisateur et l'écrivons avec les deux lignes suivantes. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -La première ligne annule le précédent état de l'objet (utilisateur). Il doit copier les champs de clé de tri de l'état annulé sauf `Sign`. - -La deuxième ligne contient l'état actuel. - -Comme nous avons besoin seulement le dernier état de l'activité de l'utilisateur, les lignes - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -peut être supprimé en réduisant l'état invalide (ancien) d'un objet. `CollapsingMergeTree` fait cela lors de la fusion des parties de données. - -Pourquoi nous avons besoin de 2 lignes pour chaque changement lu dans le [Algorithme](#table_engine-collapsingmergetree-collapsing-algorithm) paragraphe. - -**Propriétés particulières d'une telle approche** - -1. Le programme qui écrit les données doit se souvenir de l'état d'un objet pour pouvoir l'annuler. “Cancel” string doit contenir des copies des champs de clé de tri du “state” chaîne et le contraire `Sign`. Il augmente la taille initiale de stockage, mais permet d'écrire les données rapidement. -2. Les tableaux de plus en plus longs dans les colonnes réduisent l'efficacité du moteur en raison de la charge pour l'écriture. Plus les données sont simples, plus l'efficacité est élevée. -3. Le `SELECT` les résultats dépendent fortement de la cohérence de l'historique des modifications d'objet. Être précis lors de la préparation des données pour l'insertion. Vous pouvez obtenir des résultats imprévisibles dans des données incohérentes, par exemple des valeurs négatives pour des mesures non négatives telles que la profondeur de session. - -### Algorithme {#table_engine-collapsingmergetree-collapsing-algorithm} - -Lorsque ClickHouse fusionne des parties de données, chaque groupe de lignes consécutives avec la même clé de tri (`ORDER BY`) est réduit à pas plus de deux rangées, une avec `Sign = 1` (“state” ligne) et l'autre avec `Sign = -1` (“cancel” rangée). En d'autres termes, les entrées de l'effondrement. - -Pour chaque partie de données résultante clickhouse enregistre: - -1. Première “cancel” et la dernière “state” lignes, si le nombre de “state” et “cancel” lignes correspond et la dernière ligne est un “state” rangée. - -2. La dernière “state” ligne, si il y a plus de “state” les lignes de “cancel” rangée. - -3. Première “cancel” ligne, si il y a plus de “cancel” les lignes de “state” rangée. - -4. Aucune des lignes, dans tous les autres cas. - -Aussi quand il y a au moins 2 plus “state” les lignes de “cancel” les lignes, ou au moins 2 de plus “cancel” rangs puis “state” la fusion continue, mais ClickHouse traite cette situation comme une erreur logique et l'enregistre dans le journal du serveur. Cette erreur peut se produire si les mêmes données ont été insérées plus d'une fois. - -Ainsi, l'effondrement ne devrait pas changer les résultats du calcul des statistiques. -Les changements se sont progressivement effondrés de sorte qu'à la fin seul le dernier état de presque tous les objets à gauche. - -Le `Sign` est nécessaire car l'algorithme de fusion ne garantit pas que toutes les lignes avec la même clé de tri seront dans la même partie de données résultante et même sur le même serveur physique. Processus de ClickHouse `SELECT` les requêtes avec plusieurs threads, et il ne peut pas prédire l'ordre des lignes dans le résultat. L'agrégation est nécessaire s'il y a un besoin d'obtenir complètement “collapsed” les données de `CollapsingMergeTree` table. - -Pour finaliser la réduction, écrivez une requête avec `GROUP BY` fonctions de clause et d'agrégation qui tiennent compte du signe. Par exemple, pour calculer la quantité, l'utilisation `sum(Sign)` plutôt `count()`. Pour calculer la somme de quelque chose, utilisez `sum(Sign * x)` plutôt `sum(x)` et ainsi de suite , et également ajouter `HAVING sum(Sign) > 0`. - -Aggregate `count`, `sum` et `avg` pourrait être calculée de cette manière. Aggregate `uniq` peut être calculé si un objet a au moins un état non réduit. Aggregate `min` et `max` impossible de calculer parce que `CollapsingMergeTree` n'enregistre pas l'historique des valeurs des États réduits. - -Si vous avez besoin d'extraire des données sans agrégation (par exemple, pour vérifier si des lignes sont présentes dont les valeurs les plus récentes correspondent à certaines conditions), vous pouvez utiliser `FINAL` le modificateur du `FROM` clause. Cette approche est nettement moins efficace. - -## Exemple D'Utilisation {#example-of-use} - -Les données de l'exemple: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Création de la table: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Insertion des données: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) -``` - -Nous utilisons deux `INSERT` requêtes pour créer deux parties de données différentes. Si nous insérons les données avec une requête, ClickHouse crée une partie de données et n'effectuera aucune fusion. - -L'obtention de données: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Que voyons-nous et où s'effondre? - -Avec deux `INSERT` requêtes, nous avons créé 2 parties de données. Le `SELECT` la requête a été effectuée dans 2 threads, et nous avons obtenu un ordre aléatoire de lignes. L'effondrement n'a pas eu lieu car il n'y avait pas encore de fusion des parties de données. ClickHouse fusionne une partie des données dans un moment inconnu que nous ne pouvons pas prédire. - -Nous avons donc besoin d'agrégation: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration -FROM UAct -GROUP BY UserID -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -Si nous n'avons pas besoin d'agrégation et de vouloir forcer l'effondrement, nous pouvons utiliser `FINAL` le modificateur `FROM` clause. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Cette façon de sélectionner les données est très inefficace. Ne l'utilisez pas pour les grandes tables. - -## Exemple D'Une Autre Approche {#example-of-another-approach} - -Les données de l'exemple: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ -5 │ -146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -L'idée est que les fusions ne prennent en compte que les champs clés. Et dans le “Cancel” ligne nous pouvons spécifier des valeurs négatives qui égalisent la version précédente de la ligne lors de la sommation sans utiliser la colonne de signe. Pour cette approche, il est nécessaire de changer le type de données `PageViews`,`Duration` pour stocker les valeurs négatives de UInt8 - \> Int16. - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews Int16, - Duration Int16, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Nous allons tester l'approche: - -``` sql -insert into UAct values(4324182021466249494, 5, 146, 1); -insert into UAct values(4324182021466249494, -5, -146, -1); -insert into UAct values(4324182021466249494, 6, 185, 1); - -select * from UAct final; // avoid using final in production (just for a test or small tables) -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -``` sql -SELECT - UserID, - sum(PageViews) AS PageViews, - sum(Duration) AS Duration -FROM UAct -GROUP BY UserID -```text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -``` sqk -select count() FROM UAct -``` - -``` text -┌─count()─┐ -│ 3 │ -└─────────┘ -``` - -``` sql -optimize table UAct final; - -select * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/fr/engines/table_engines/mergetree_family/custom_partitioning_key.md b/docs/fr/engines/table_engines/mergetree_family/custom_partitioning_key.md deleted file mode 100644 index 499d71f3f00..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/custom_partitioning_key.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 32 -toc_title: "Cl\xE9 De Partitionnement Personnalis\xE9e" ---- - -# Clé De Partitionnement Personnalisée {#custom-partitioning-key} - -Le partitionnement est disponible pour [MergeTree](mergetree.md) table de famille (y compris les [répliqué](replication.md) table). [Les vues matérialisées](../special/materializedview.md) basé sur les tables MergeTree prennent également en charge le partitionnement. - -Une partition est une combinaison logique d'enregistrements dans une table selon un critère spécifié. Vous pouvez définir une partition par un critère arbitraire, comme, par mois, par jour, ou par type d'événement. Chaque partition est stockée séparément pour simplifier les manipulations de ces données. Lors de l'accès aux données, ClickHouse utilise le plus petit sous-ensemble de partitions possible. - -La partition est spécifiée dans le `PARTITION BY expr` clause lors de [création d'une table](mergetree.md#table_engine-mergetree-creating-a-table). La clé de partition peut être n'importe quelle expression des colonnes de la table. Par exemple, pour spécifier le partitionnement par mois, utilisez l'expression `toYYYYMM(date_column)`: - -``` sql -CREATE TABLE visits -( - VisitDate Date, - Hour UInt8, - ClientID UUID -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(VisitDate) -ORDER BY Hour; -``` - -La clé de partition peut également être un tuple d'expressions (similaire à la [clé primaire](mergetree.md#primary-keys-and-indexes-in-queries)). Exemple: - -``` sql -ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) -PARTITION BY (toMonday(StartDate), EventType) -ORDER BY (CounterID, StartDate, intHash32(UserID)); -``` - -Dans cet exemple, nous définissons le partitionnement par les types d'événements qui se sont produits au cours de la semaine en cours. - -Lors de l'insertion de nouvelles données dans une table, ces données sont stockées en tant que partie séparée (bloc) triée par la clé primaire. Dans 10-15 minutes après l'insertion, les parties de la même partition sont fusionnées dans la partie entière. - -!!! info "Info" - Une fusion ne fonctionne que pour les parties de données qui ont la même valeur pour l'expression de partitionnement. Cela signifie **vous ne devriez pas faire des partitions trop granulaires** (plus d'un millier de partitions). Sinon, l' `SELECT` la requête fonctionne mal en raison d'un nombre déraisonnablement élevé de fichiers dans le système de fichiers et des descripteurs de fichiers ouverts. - -L'utilisation de la [système.partie](../../../operations/system_tables.md#system_tables-parts) table pour afficher les parties et les partitions de la table. Par exemple, supposons que nous avons une `visits` table avec partitionnement par mois. Nous allons effectuer le `SELECT` la requête pour l' `system.parts` table: - -``` sql -SELECT - partition, - name, - active -FROM system.parts -WHERE table = 'visits' -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 1 │ -│ 201902 │ 201902_11_11_0 │ 1 │ -└───────────┴────────────────┴────────┘ -``` - -Le `partition` colonne contient les noms des partitions. Il y a deux partitions dans cet exemple: `201901` et `201902`. Vous pouvez utiliser cette valeur de colonne pour spécifier le nom de [ALTER … PARTITION](#alter_manipulations-with-partitions) requête. - -Le `name` colonne contient les noms des parties de données de partition. Vous pouvez utiliser cette colonne pour spécifier le nom de la partie dans la [ALTER ATTACH PART](#alter_attach-partition) requête. - -Décomposons le nom de la première partie: `201901_1_3_1`: - -- `201901` est le nom de la partition. -- `1` est le nombre minimum du bloc de données. -- `3` est le nombre maximal de blocs de données. -- `1` est le niveau de bloc (la profondeur de l'arbre de fusion à partir duquel il est formé). - -!!! info "Info" - Les parties des tables de type ancien ont le nom: `20190117_20190123_2_2_0` (date minimale - date maximale - numéro de bloc minimum - numéro de bloc maximum-niveau). - -Le `active` colonne indique le statut de la partie. `1` est active; `0` est inactif. Les parties inactives sont, par exemple, des parties source restant après la fusion à une partie plus grande. Les parties de données corrompues sont également indiquées comme inactives. - -Comme vous pouvez le voir dans l'exemple, il y a plusieurs parties séparées de la même partition (par exemple, `201901_1_3_1` et `201901_1_9_2`). Cela signifie que ces parties ne sont pas encore fusionnées. Clickhouse fusionne les parties insérées des données périodiquement, environ 15 minutes après l'insertion. En outre, vous pouvez effectuer une fusion non planifiée en utilisant [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) requête. Exemple: - -``` sql -OPTIMIZE TABLE visits PARTITION 201902; -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 0 │ -│ 201902 │ 201902_4_11_2 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 0 │ -│ 201902 │ 201902_11_11_0 │ 0 │ -└───────────┴────────────────┴────────┘ -``` - -Les parties inactives seront supprimées environ 10 minutes après la fusion. - -Une autre façon d'afficher un ensemble de pièces et de partitions est d'aller dans le répertoire de la table: `/var/lib/clickhouse/data///`. Exemple: - -``` bash -/var/lib/clickhouse/data/default/visits$ ls -l -total 40 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached -``` - -Dossier ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ et ainsi de suite sont les répertoires des parties. Chaque partie se rapporte à une partition correspondante et contient des données juste pour un certain mois (la table dans cet exemple a partitionnement par mois). - -Le `detached` le répertoire contient des parties qui ont été détachées de la table à l'aide [DETACH](#alter_detach-partition) requête. Les parties corrompues sont également déplacées dans ce répertoire, au lieu d'être supprimées. Le serveur n'utilise pas les pièces de la `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql_reference/statements/alter.md#alter_attach-partition) requête. - -Notez que sur le serveur d'exploitation, vous ne pouvez pas modifier manuellement l'ensemble de pièces ou leurs données sur le système de fichiers, car le serveur ne le saura pas. Pour les tables non répliquées, vous pouvez le faire lorsque le serveur est arrêté, mais ce n'est pas recommandé. Pour les tables répliquées, l'ensemble de pièces ne peut en aucun cas être modifié. - -ClickHouse vous permet d'effectuer des opérations avec les partitions: les supprimer, copier d'une table à une autre, ou créer une sauvegarde. Voir la liste de toutes les opérations de la section [Manipulations avec des Partitions et des pièces](../../../sql_reference/statements/alter.md#alter_manipulations-with-partitions). - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/fr/engines/table_engines/mergetree_family/graphitemergetree.md b/docs/fr/engines/table_engines/mergetree_family/graphitemergetree.md deleted file mode 100644 index e0cb60c088f..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/graphitemergetree.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 38 -toc_title: GraphiteMergeTree ---- - -# Graphitemergetree {#graphitemergetree} - -Ce moteur est conçu pour l'amincissement et l'agrégation / moyenne (cumul) [Graphite](http://graphite.readthedocs.io/en/latest/index.html) données. Il peut être utile aux développeurs qui veulent utiliser ClickHouse comme un magasin de données pour Graphite. - -Vous pouvez utiliser N'importe quel moteur de table ClickHouse pour stocker les données Graphite si vous n'avez pas besoin de cumul, mais si vous avez besoin d'un cumul, utilisez `GraphiteMergeTree`. Le moteur réduit le volume de stockage et augmente l'efficacité des requêtes de Graphite. - -Le moteur hérite des propriétés de [MergeTree](mergetree.md). - -## Création d'une Table {#creating-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE = GraphiteMergeTree(config_section) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Voir une description détaillée de la [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) requête. - -Un tableau pour les données de Graphite devrait avoir les colonnes suivantes pour les données suivantes: - -- Nom métrique (Capteur De Graphite). Type de données: `String`. - -- Temps de mesure de la métrique. Type de données: `DateTime`. - -- La valeur de la métrique. Type de données: tout numérique. - -- La Version de la métrique. Type de données: tout numérique. - - ClickHouse enregistre les lignes avec la version la plus élevée ou la dernière écrite si les versions sont les mêmes. Les autres lignes sont supprimées lors de la fusion des parties de données. - -Les noms de ces colonnes doivent être définis dans la configuration de cumul. - -**GraphiteMergeTree paramètres** - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -**Les clauses de requête** - -Lors de la création d'un `GraphiteMergeTree` de table, de la même [clause](mergetree.md#table_engine-mergetree-creating-a-table) sont nécessaires, comme lors de la création d'un `MergeTree` table. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - EventDate Date, - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) -``` - -Tous les paramètres excepté `config_section` ont la même signification que dans `MergeTree`. - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -
- -## Configuration De Cumul {#rollup-configuration} - -Les paramètres de cumul sont définis par [graphite\_rollup](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) paramètre dans la configuration du serveur. Le nom du paramètre pourrait être tout. Vous pouvez créer plusieurs configurations et les utiliser pour différentes tables. - -Structure de configuration de cumul: - - required-columns - patterns - -### Les Colonnes Requises {#required-columns} - -- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. -- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. -- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Valeur par défaut: `Value`. -- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. - -### Modèle {#patterns} - -La Structure de la `patterns` section: - -``` text -pattern - regexp - function -pattern - regexp - age + precision - ... -pattern - regexp - function - age + precision - ... -pattern - ... -default - function - age + precision - ... -``` - -!!! warning "Attention" - Les motifs doivent être strictement commandés: - - 1. Patterns without `function` or `retention`. - 1. Patterns with both `function` and `retention`. - 1. Pattern `default`. - -Lors du traitement d'une ligne, ClickHouse vérifie les règles `pattern` section. Chacun `pattern` (comprendre `default`) les articles peuvent contenir des `function` paramètre d'agrégation, `retention` les paramètres ou les deux à la fois. Si le nom de la métrique correspond `regexp` les règles de la `pattern` section (ou sections) sont appliquées; sinon, les règles de la `default` section sont utilisés. - -Champs pour `pattern` et `default` section: - -- `regexp`– A pattern for the metric name. -- `age` – The minimum age of the data in seconds. -- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). -- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. - -### Exemple De Configuration {#configuration-example} - -``` xml - - Version - - click_cost - any - - 0 - 5 - - - 86400 - 60 - - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/fr/engines/table_engines/mergetree_family/index.md b/docs/fr/engines/table_engines/mergetree_family/index.md deleted file mode 100644 index 82c36cfc29f..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: MergeTree Family -toc_priority: 28 ---- - - diff --git a/docs/fr/engines/table_engines/mergetree_family/mergetree.md b/docs/fr/engines/table_engines/mergetree_family/mergetree.md deleted file mode 100644 index f45d072c4c0..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/mergetree.md +++ /dev/null @@ -1,654 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 30 -toc_title: MergeTree ---- - -# Mergetree {#table_engines-mergetree} - -Le `MergeTree` moteur et autres moteurs de cette famille (`*MergeTree`) sont les moteurs de table ClickHouse les plus robustes. - -Les moteurs de la `MergeTree` famille sont conçus pour l'insertion d'une très grande quantité de données dans une table. Les données sont rapidement écrites dans la table partie par partie, puis des règles sont appliquées pour fusionner les parties en arrière-plan. Cette méthode est beaucoup plus efficace que de réécrire continuellement les données dans le stockage pendant l'insertion. - -Principales caractéristiques: - -- Stocke les données triées par clé primaire. - - Cela vous permet de créer un petit index clairsemé qui aide à trouver les données plus rapidement. - -- Les Partitions peuvent être utilisées si [clé de partitionnement](custom_partitioning_key.md) est spécifié. - - ClickHouse prend en charge certaines opérations avec des partitions plus efficaces que les opérations générales sur les mêmes données avec le même résultat. ClickHouse Coupe également automatiquement les données de partition où la clé de partitionnement est spécifiée dans la requête. Cela améliore également les performances de la requête. - -- Prise en charge de la réplication des données. - - La famille de `ReplicatedMergeTree` tables fournit la réplication des données. Pour plus d'informations, voir [Réplication des données](replication.md). - -- Appui d'échantillonnage de données. - - Si nécessaire, vous pouvez définir la méthode d'échantillonnage des données dans le tableau. - -!!! info "Info" - Le [Fusionner](../special/merge.md) le moteur n'appartient pas à la `*MergeTree` famille. - -## Création d'une Table {#table_engine-mergetree-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... - INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, - INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 -) ENGINE = MergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] -[SETTINGS name=value, ...] -``` - -Pour une description des paramètres, voir [Créer une description de requête](../../../sql_reference/statements/create.md). - -!!! note "Note" - `INDEX` est une fonctionnalité expérimentale, voir [Index De Saut De Données](#table_engine-mergetree-data_skipping-indexes). - -### Les Clauses De Requête {#mergetree-query-clauses} - -- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. Le `MergeTree` le moteur n'a pas de paramètres. - -- `PARTITION BY` — The [clé de partitionnement](custom_partitioning_key.md). - - Pour le partitionnement par mois, utilisez les `toYYYYMM(date_column)` l'expression, où `date_column` est une colonne avec une date du type [Date](../../../sql_reference/data_types/date.md). Les noms de partition ici ont le `"YYYYMM"` format. - -- `ORDER BY` — The sorting key. - - Un tuple de colonnes ou d'expressions arbitraires. Exemple: `ORDER BY (CounterID, EventDate)`. - -- `PRIMARY KEY` — The primary key if it [diffère de la clé de tri](#choosing-a-primary-key-that-differs-from-the-sorting-key). - - Par défaut, la clé primaire est la même que la clé de tri (qui est spécifiée par `ORDER BY` clause). Ainsi dans la plupart des cas il n'est pas nécessaire de spécifier un `PRIMARY KEY` clause. - -- `SAMPLE BY` — An expression for sampling. - - Si un échantillonnage expression est utilisée, la clé primaire doit contenir. Exemple: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. - -- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [entre disques et volumes](#table_engine-mergetree-multiple-volumes). - - L'Expression doit en avoir une `Date` ou `DateTime` colonne comme un résultat. Exemple: - `TTL date + INTERVAL 1 DAY` - - Le Type de la règle `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` spécifie une action à effectuer avec la partie si l'expression est satisfaite (atteint l'heure actuelle): suppression des Lignes expirées, déplacement d'une partie (si l'expression est satisfaite pour toutes les lignes d'une partie) sur le disque spécifié (`TO DISK 'xxx'`) ou de volume (`TO VOLUME 'xxx'`). Le type par défaut de la règle est suppression (`DELETE`). Liste de règles multiples peut spécifié, mais il ne devrait pas y avoir plus d'un `DELETE` règle. - - Pour plus de détails, voir [TTL pour les colonnes et les tableaux](#table_engine-mergetree-ttl) - -- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: - - - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Le Stockage De Données](#mergetree-data-storage). - - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Le Stockage De Données](#mergetree-data-storage). - - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` paramètre. Avant la version 19.11, il n'y avait que le `index_granularity` réglage pour restreindre la taille des granules. Le `index_granularity_bytes` le paramètre améliore les performances de ClickHouse lors de la sélection de données à partir de tables avec de grandes lignes (des dizaines et des centaines de mégaoctets). Si vous avez des tables avec de grandes lignes, vous pouvez activer ce paramètre pour les tables d'améliorer l'efficacité de `SELECT` requête. - - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, puis Zookeeper stocke moins de données. Pour plus d'informations, voir le [Description du réglage](../../../operations/server_configuration_parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) dans “Server configuration parameters”. - - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` octets, ClickHouse lit et écrit les données sur le disque de stockage en utilisant l'interface d'E/S directe (`O_DIRECT` option). Si `min_merge_bytes_to_use_direct_io = 0`, puis les e/s directes sont désactivées. Valeur par défaut: `10 * 1024 * 1024 * 1024` octet. - - - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). - - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don't turn it off. - - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. - - `storage_policy` — Storage policy. See [Utilisation de plusieurs périphériques de bloc pour le stockage de données](#table_engine-mergetree-multiple-volumes). - -**Exemple de réglage des Sections** - -``` sql -ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 -``` - -Dans l'exemple, nous définissons le partitionnement par mois. - -Nous définissons également une expression pour l'échantillonnage en tant que hachage par l'ID utilisateur. Cela vous permet de pseudorandomiser les données dans la table pour chaque `CounterID` et `EventDate`. Si vous définissez un [SAMPLE](../../../sql_reference/statements/select.md#select-sample-clause) clause lors de la sélection des données, ClickHouse retournera un échantillon de données uniformément pseudo-aléatoire pour un sous-ensemble d'utilisateurs. - -Le `index_granularity` paramètre peut être omis, car 8192 est la valeur par défaut. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets. Si possible, optez anciens projets à la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -**Paramètres MergeTree ()** - -- `date-column` — The name of a column of the [Date](../../../sql_reference/data_types/date.md) type. ClickHouse crée automatiquement des partitions par mois en fonction de cette colonne. Les noms de partition sont dans le `"YYYYMM"` format. -- `sampling_expression` — An expression for sampling. -- `(primary, key)` — Primary key. Type: [Tuple()](../../../sql_reference/data_types/tuple.md) -- `index_granularity` — The granularity of an index. The number of data rows between the “marks” d'un index. La valeur 8192 est appropriée pour la plupart des tâches. - -**Exemple** - -``` sql -MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) -``` - -Le `MergeTree` le moteur est configuré de la même manière que dans l'exemple ci-dessus pour la méthode de configuration du moteur principal. -
- -## Le Stockage De Données {#mergetree-data-storage} - -Une table se compose de parties de données triées par clé primaire. - -Lorsque des données sont insérées dans une table, des parties de données distinctes sont créées et chacune d'elles est lexicographiquement triée par clé primaire. Par exemple, si la clé primaire est `(CounterID, Date)`, les données de la pièce sont triées par `CounterID` et au sein de chaque `CounterID` il est commandé par `Date`. - -Les données appartenant à différentes partitions sont séparés en différentes parties. En arrière-plan, ClickHouse fusionne des parties de données pour un stockage plus efficace. Les parties appartenant à des partitions différentes ne sont pas fusionnées. La fusion mécanisme ne garantit pas que toutes les lignes avec la même clé primaire sera dans la même partie des données. - -Chaque partie de données est logiquement divisée en granules. Un granule est le plus petit ensemble de données indivisible que ClickHouse lit lors de la sélection des données. ClickHouse ne divise pas les lignes ou les valeurs, de sorte que chaque granule contient toujours un nombre entier de lignes. La première rangée de granules est marqué avec la valeur de la clé primaire de la ligne. Pour chaque partie de données, ClickHouse crée un fichier d'index qui stocke les marques. Pour chaque colonne, que ce soit dans la clé primaire ou non, ClickHouse stocke également les mêmes marques. Ces marques vous permettent de trouver des données directement dans les fichiers de colonnes. - -La taille de granule est limitée par `index_granularity` et `index_granularity_bytes` paramètres du moteur de table. Le nombre de lignes dans un granule jette dans la `[1, index_granularity]` gamme, en fonction de la taille des lignes. La taille des granulés peut dépasser `index_granularity_bytes` si la taille d'une seule ligne est supérieure à la valeur du paramètre. Dans ce cas, la taille du granule est égale à la taille de la ligne. - -## Clés primaires et Index dans les requêtes {#primary-keys-and-indexes-in-queries} - -Prendre la `(CounterID, Date)` clé primaire comme un exemple. Dans ce cas, le tri et l'index peuvent être illustrés comme suit: - - Whole data: [---------------------------------------------] - CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] - Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] - Marks: | | | | | | | | | | | - a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 - Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 - -Si la requête de données spécifie: - -- `CounterID in ('a', 'h')` le serveur lit les données dans les gammes des marques `[0, 3)` et `[6, 8)`. -- `CounterID IN ('a', 'h') AND Date = 3` le serveur lit les données dans les gammes des marques `[1, 3)` et `[7, 8)`. -- `Date = 3`, le serveur lit les données de la plage de marque `[1, 10]`. - -Les exemples ci-dessus montrent qu'il est toujours plus efficace d'utiliser un indice qu'une analyse complète. - -Un index clairsemé permet de lire des données supplémentaires. Lors de la lecture d'une plage unique de la clé primaire, jusqu'à `index_granularity * 2` lignes supplémentaires dans chaque bloc de données peut être lu. - -Les index clairsemés vous permettent de travailler avec un très grand nombre de lignes de table, car dans la plupart des cas, ces index tiennent dans la RAM de l'ordinateur. - -ClickHouse ne nécessite pas de clé primaire unique. Vous pouvez insérer plusieurs lignes avec la même clé primaire. - -### Sélection de la clé primaire {#selecting-the-primary-key} - -Le nombre de colonnes de la clé primaire n'est pas explicitement limitée. Selon la structure de données, vous pouvez inclure plus ou moins de colonnes dans la clé primaire. Cela peut: - -- Améliorer la performance d'un indice. - - Si la clé primaire est `(a, b)`, puis ajouter une autre colonne `c` pour améliorer les performances si les conditions suivantes sont réunies: - - - Il y a des requêtes avec une condition sur la colonne `c`. - - Longues plages de données (plusieurs fois plus longues que `index_granularity`) avec des valeurs identiques pour `(a, b)` sont communs. En d'autres termes, lors de l'ajout d'une autre colonne vous permet de passer très longues plages de données. - -- Améliorer la compression des données. - - ClickHouse trie les données par clé primaire, donc plus la cohérence est élevée, meilleure est la compression. - -- Fournir une logique supplémentaire lors de la fusion de parties de [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) et [SummingMergeTree](summingmergetree.md) moteur. - - Dans ce cas, on peut spécifier l' *clé de tri* qui est différente de la clé primaire. - -Une clé primaire longue affectera négativement les performances d'insertion et la consommation de mémoire, mais des colonnes supplémentaires dans la clé primaire n'affecteront pas les performances de ClickHouse pendant `SELECT` requête. - -### Choisir une clé primaire qui diffère de la clé de tri {#choosing-a-primary-key-that-differs-from-the-sorting-key} - -Il est possible de spécifier une clé primaire (une expression avec des valeurs qui sont écrites dans le fichier d'index pour chaque marque) qui est différente de la clé de tri (une expression pour trier les lignes dans les parties de données). Dans ce cas, le tuple d'expression de clé primaire doit être un préfixe du tuple d'expression de clé de tri. - -Cette fonctionnalité est utile lorsque vous utilisez le [SummingMergeTree](summingmergetree.md) et -[AggregatingMergeTree](aggregatingmergetree.md) table des moteurs. Dans un cas courant lors de l'utilisation de ces moteurs, la table a deux types de colonnes: *dimension* et *mesure*. Les requêtes typiques agrégent les valeurs des colonnes de mesure avec arbitraire `GROUP BY` et filtrage par dimensions. Comme SummingMergeTree et AggregatingMergeTree regroupent des lignes avec la même valeur de la clé de tri, il est naturel d'y ajouter toutes les dimensions. En conséquence, l'expression se compose d'une longue liste de colonnes, et cette liste doit être mise à jour fréquemment avec nouvellement ajoutée. - -Dans ce cas, il est logique de ne laisser que quelques colonnes dans la clé primaire qui fourniront des analyses de plage efficaces et ajouteront les colonnes de dimension restantes au tuple de clé de tri. - -[ALTER](../../../sql_reference/statements/alter.md) la clé de tri est une opération légère car lorsqu'une nouvelle colonne est ajoutée simultanément à la table et à la clé de tri, les parties de données existantes n'ont pas besoin d'être modifiées. Comme l'ancienne clé de tri est un préfixe de la nouvelle clé de tri et qu'il n'y a pas de données dans la colonne nouvellement ajoutée, les données sont triées à la fois par l'ancienne et la nouvelle clé de tri au moment de la modification de la table. - -### Utilisation D'Index et de Partitions dans les requêtes {#use-of-indexes-and-partitions-in-queries} - -Pour `SELECT` requêtes, clickhouse analyse si un index peut être utilisé. Un index peut être utilisé si le `WHERE/PREWHERE` clause a une expression (comme l'un des éléments de conjonction, ou entièrement) qui représente une opération de comparaison d'égalité ou d'inégalité, ou si elle a `IN` ou `LIKE` avec un préfixe fixe sur les colonnes ou les expressions qui sont dans la clé primaire ou la clé de partitionnement, ou sur certaines fonctions partiellement répétitives de ces colonnes, ou les relations logiques de ces expressions. - -Ainsi, il est possible d'exécuter des requêtes sur une ou plusieurs plages de la clé primaire. Dans cet exemple, les requêtes seront rapides lorsqu'elles sont exécutées pour une balise de suivi spécifique, pour une balise et une plage de dates spécifiques, pour une balise et une date spécifiques, pour plusieurs balises avec une plage de dates, etc. - -Regardons le moteur configuré comme suit: - - ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 - -Dans ce cas, dans les requêtes: - -``` sql -SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 -SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) -SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) -``` - -ClickHouse utilisera l'index de clé primaire pour supprimer les données incorrectes et la clé de partitionnement mensuel pour supprimer les partitions qui se trouvent dans des plages de dates incorrectes. - -Les requêtes ci-dessus montrent que l'index est utilisé même pour les expressions complexes. La lecture de la table est organisée de sorte que l'utilisation de l'index ne peut pas être plus lente qu'une analyse complète. - -Dans l'exemple ci-dessous, l'index ne peut pas être utilisé. - -``` sql -SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' -``` - -Pour vérifier si ClickHouse pouvez utiliser l'index lors de l'exécution d'une requête, utilisez les paramètres [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) et [force\_primary\_key](../../../operations/settings/settings.md). - -La clé de partitionnement par mois permet de lire uniquement les blocs de données qui contiennent des dates de la plage appropriée. Dans ce cas, le bloc de données peut contenir des données pour plusieurs dates (jusqu'à un mois entier). Dans un bloc, les données sont triées par clé primaire, qui peut ne pas contenir la date comme première colonne. Pour cette raison, l'utilisation d'une requête avec seulement une condition de date qui ne spécifie pas le préfixe de clé primaire entraînera la lecture de plus de données que pour une seule date. - -### Utilisation de L'Index pour les clés primaires partiellement monotones {#use-of-index-for-partially-monotonic-primary-keys} - -Considérons, par exemple, les jours du mois. Ils forment un [monotone de la séquence](https://en.wikipedia.org/wiki/Monotonic_function) pendant un mois, mais pas monotone pendant des périodes plus longues. C'est une séquence partiellement monotone. Si un utilisateur crée la table avec une clé primaire partiellement monotone, ClickHouse crée un index clairsemé comme d'habitude. Lorsqu'un utilisateur sélectionne des données à partir de ce type de table, ClickHouse analyse les conditions de requête. Si L'utilisateur veut obtenir des données entre deux marques de l'index et que ces deux marques tombent dans un mois, ClickHouse peut utiliser l'index dans ce cas particulier car il peut calculer la distance entre les paramètres d'une requête et les marques d'index. - -ClickHouse ne peut pas utiliser un index si les valeurs de la clé primaire dans la plage de paramètres de requête ne représentent pas une séquence monotone. Dans ce cas, ClickHouse utilise la méthode full scan. - -ClickHouse utilise cette logique non seulement pour les séquences de jours du mois, mais pour toute clé primaire qui représente une séquence partiellement monotone. - -### Index de saut de données (expérimental) {#table_engine-mergetree-data_skipping-indexes} - -La déclaration d'index se trouve dans la section colonnes du `CREATE` requête. - -``` sql -INDEX index_name expr TYPE type(...) GRANULARITY granularity_value -``` - -Pour les tables de la `*MergeTree` famille, les indices de saut de données peuvent être spécifiés. - -Ces indices agrégent certaines informations sur l'expression spécifiée sur les blocs, qui consistent en `granularity_value` granules (la taille du granule est spécifiée en utilisant `index_granularity` réglage dans le moteur de table). Ensuite, ces agrégats sont utilisés dans `SELECT` requêtes pour réduire la quantité de données à lire à partir du disque en ignorant de gros blocs de données `where` la requête ne peut pas être satisfait. - -**Exemple** - -``` sql -CREATE TABLE table_name -( - u64 UInt64, - i32 Int32, - s String, - ... - INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, - INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 -) ENGINE = MergeTree() -... -``` - -Les Indices de L'exemple peuvent être utilisés par ClickHouse pour réduire la quantité de données à lire à partir du disque dans les requêtes suivantes: - -``` sql -SELECT count() FROM table WHERE s < 'z' -SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 -``` - -#### Types D'Indices Disponibles {#available-types-of-indices} - -- `minmax` - - Magasins extrêmes de l'expression spécifiée (si l'expression est `tuple` puis il stocke les extrêmes pour chaque élément de `tuple`), utilise les informations stockées pour sauter des blocs de données comme la clé primaire. - -- `set(max_rows)` - - Stocke les valeurs uniques de l'expression spécifiée (pas plus de `max_rows` rangée, `max_rows=0` moyen “no limits”). Utilise les valeurs pour vérifier si le `WHERE` l'expression n'est pas satisfiable sur un bloc de données. - -- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Magasins un [Filtre de Bloom](https://en.wikipedia.org/wiki/Bloom_filter) qui contient tous les ngrams d'un bloc de données. Fonctionne uniquement avec des chaînes. Peut être utilisé pour l'optimisation de `equals`, `like` et `in` expression. - - - `n` — ngram size, - - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). - - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. - - `random_seed` — The seed for Bloom filter hash functions. - -- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Le même que `ngrambf_v1`, mais stocke des jetons au lieu de ngrams. Les jetons sont des séquences séparées par des caractères non alphanumériques. - -- `bloom_filter([false_positive])` — Stores a [Filtre de Bloom](https://en.wikipedia.org/wiki/Bloom_filter) pour les colonnes spécifiées. - - Facultatif `false_positive` le paramètre est la probabilité de recevoir une réponse faussement positive du filtre. Valeurs possibles: (0, 1). Valeur par défaut: 0.025. - - Types de données pris en charge: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. - - Les fonctions suivantes peuvent l'utiliser: [égal](../../../sql_reference/functions/comparison_functions.md), [notEquals](../../../sql_reference/functions/comparison_functions.md), [dans](../../../sql_reference/functions/in_functions.md), [notIn](../../../sql_reference/functions/in_functions.md), [avoir](../../../sql_reference/functions/array_functions.md). - - - -``` sql -INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 -INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 -INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 -``` - -#### Les Fonctions De Soutien {#functions-support} - -Les Conditions dans le `WHERE` la clause contient des appels des fonctions qui fonctionnent avec des colonnes. Si la colonne fait partie d'un index, ClickHouse essaie d'utiliser cet index lors de l'exécution des fonctions. ClickHouse prend en charge différents sous-ensembles de fonctions pour l'utilisation d'index. - -Le `set` l'indice peut être utilisé avec toutes les fonctions. Les sous-ensembles de fonctions pour les autres index sont présentés dans le tableau ci-dessous. - -| Fonction (opérateur) / Indice de | clé primaire | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | -|--------------------------------------------------------------------------------------------------------------|--------------|--------|-------------|-------------|---------------| -| [égal (=, ==)](../../../sql_reference/functions/comparison_functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notEquals (!=, \<\>)](../../../sql_reference/functions/comparison_functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [comme](../../../sql_reference/functions/string_search_functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [notLike](../../../sql_reference/functions/string_search_functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [startsWith](../../../sql_reference/functions/string_functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | -| [endsWith](../../../sql_reference/functions/string_functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | -| [multiSearchAny](../../../sql_reference/functions/string_search_functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | -| [dans](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notIn](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [peu (\<)](../../../sql_reference/functions/comparison_functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [grand (\>)](../../../sql_reference/functions/comparison_functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [lessOrEquals (\<=)](../../../sql_reference/functions/comparison_functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [greaterOrEquals ( \> =)](../../../sql_reference/functions/comparison_functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [vide](../../../sql_reference/functions/array_functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [notEmpty](../../../sql_reference/functions/array_functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | - -Les fonctions avec un argument constant inférieur à la taille ngram ne peuvent pas être utilisées par `ngrambf_v1` pour l'optimisation de la requête. - -Les filtres Bloom peuvent avoir des correspondances faussement positives, de sorte que le `ngrambf_v1`, `tokenbf_v1`, et `bloom_filter` les index ne peuvent pas être utilisés pour optimiser les requêtes où le résultat d'une fonction est censé être faux, par exemple: - -- Peut être optimisé: - - `s LIKE '%test%'` - - `NOT s NOT LIKE '%test%'` - - `s = 1` - - `NOT s != 1` - - `startsWith(s, 'test')` -- Ne peut pas être optimisé: - - `NOT s LIKE '%test%'` - - `s NOT LIKE '%test%'` - - `NOT s = 1` - - `s != 1` - - `NOT startsWith(s, 'test')` - -## Accès Simultané Aux Données {#concurrent-data-access} - -Pour l'accès aux tables simultanées, nous utilisons le multi-versioning. En d'autres termes, lorsqu'une table est lue et mise à jour simultanément, les données sont lues à partir d'un ensemble de parties en cours au moment de la requête. Il n'y a pas de longues mèches. Les Inserts ne gênent pas les opérations de lecture. - -Lecture à partir d'un tableau est automatiquement parallélisée. - -## TTL pour les colonnes et les tableaux {#table_engine-mergetree-ttl} - -Détermine la durée de vie de des valeurs. - -Le `TTL` clause peut être définie pour la table entière et pour chaque colonne individuelle. Ttl de niveau Table peut également spécifier la logique de déplacement automatique des données entre les disques et les volumes. - -Les Expressions doivent évaluer pour [Date](../../../sql_reference/data_types/date.md) ou [DateTime](../../../sql_reference/data_types/datetime.md) type de données. - -Exemple: - -``` sql -TTL time_column -TTL time_column + interval -``` - -Définir `interval`, utiliser [intervalle](../../../sql_reference/operators.md#operators-datetime) opérateur. - -``` sql -TTL date_time + INTERVAL 1 MONTH -TTL date_time + INTERVAL 15 HOUR -``` - -### Colonne TTL {#mergetree-column-ttl} - -Lorsque les valeurs de la colonne expirent, ClickHouse les remplace par les valeurs par défaut du type de données de la colonne. Si toutes les valeurs de colonne de la partie données expirent, ClickHouse supprime cette colonne de la partie données d'un système de fichiers. - -Le `TTL` la clause ne peut pas être utilisée pour les colonnes clés. - -Exemple: - -Création d'une table avec TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int TTL d + INTERVAL 1 MONTH, - b Int TTL d + INTERVAL 1 MONTH, - c String -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d; -``` - -Ajout de TTL à une colonne d'une table existante - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 DAY; -``` - -Modification de TTL de la colonne - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 MONTH; -``` - -### Tableau TTL {#mergetree-table-ttl} - -Table peut avoir une expression pour la suppression de Lignes expirées, et plusieurs expressions pour le déplacement automatique de pièces entre [disques ou volumes](#table_engine-mergetree-multiple-volumes). Lorsque les lignes de la table expirent, ClickHouse supprime toutes les lignes correspondantes. Pour les pièces en mouvement, toutes les lignes d'une pièce doivent satisfaire aux critères d'expression de mouvement. - -``` sql -TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... -``` - -Type de règle TTL peut suivre chaque expression TTL. Il affecte une action qui doit être faite une fois que l'expression est satisfaite (atteint l'heure actuelle): - -- `DELETE` - supprimer les Lignes expirées (action par défaut); -- `TO DISK 'aaa'` - déplacer la partie sur le disque `aaa`; -- `TO VOLUME 'bbb'` - déplacer la partie sur le disque `bbb`. - -Exemple: - -Création d'une table avec TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d -TTL d + INTERVAL 1 MONTH [DELETE], - d + INTERVAL 1 WEEK TO VOLUME 'aaa', - d + INTERVAL 2 WEEK TO DISK 'bbb'; -``` - -Modification de TTL de la table - -``` sql -ALTER TABLE example_table - MODIFY TTL d + INTERVAL 1 DAY; -``` - -**Suppression De Données** - -Les données avec un TTL expiré sont supprimées lorsque ClickHouse fusionne des parties de données. - -Lorsque ClickHouse voit que les données sont expirées, il effectue une fusion hors calendrier. Pour contrôler la fréquence de ces fusions, vous pouvez définir [merge\_with\_ttl\_timeout](#mergetree_setting-merge_with_ttl_timeout). Si la valeur est trop faible, il effectuera de nombreuses fusions hors calendrier qui peuvent consommer beaucoup de ressources. - -Si vous effectuez la `SELECT` requête entre les fusionne, vous pouvez obtenir des données expirées. Pour éviter cela, utilisez la [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) requête avant de l' `SELECT`. - -## Utilisation De Plusieurs Périphériques De Bloc Pour Le Stockage De Données {#table_engine-mergetree-multiple-volumes} - -### Introduction {#introduction} - -`MergeTree` les moteurs de table de famille peuvent stocker des données sur plusieurs périphériques de bloc. Par exemple, il peut être utile lorsque les données d'un tableau sont implicitement divisé en “hot” et “cold”. Les données les plus récentes sont régulièrement demandées mais ne nécessitent qu'une petite quantité d'espace. Au contraire, les données historiques à queue grasse sont rarement demandées. Si plusieurs disques sont disponibles, la “hot” les données peuvent être situées sur des disques rapides (par exemple, SSD NVMe ou en mémoire), tandis que le “cold” des données relativement lente (par exemple, disque dur). - -La partie de données est l'unité mobile minimum pour `MergeTree`-tables de moteur. Les données appartenant à une partie sont stockées sur un disque. Les parties de données peuvent être déplacées entre les disques en arrière-plan (selon les paramètres de l'utilisateur) ainsi qu'au moyen du [ALTER](../../../sql_reference/statements/alter.md#alter_move-partition) requête. - -### Terme {#terms} - -- Disk — Block device mounted to the filesystem. -- Default disk — Disk that stores the path specified in the [chemin](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) paramètre de serveur. -- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). -- Storage policy — Set of volumes and the rules for moving data between them. - -Les noms donnés aux entités décrites peuvent être trouvés dans les tables système, [système.storage\_policies](../../../operations/system_tables.md#system_tables-storage_policies) et [système.disque](../../../operations/system_tables.md#system_tables-disks). Pour appliquer l'une des stratégies de stockage configurées pour une table, utilisez `storage_policy` réglage de `MergeTree`-moteur de table de famille. - -### Configuration {#table_engine-mergetree-multiple-volumes-configure} - -Les disques, les volumes et les stratégies de stockage doivent être déclarés `` étiquette, soit dans le fichier principal `config.xml` ou dans un fichier distinct dans le `config.d` répertoire. - -Structure de Configuration: - -``` xml - - - - /mnt/fast_ssd/clickhouse/ - - - /mnt/hdd1/clickhouse/ - 10485760 - - - /mnt/hdd2/clickhouse/ - 10485760 - - - ... - - - ... - -``` - -Balise: - -- `` — Disk name. Names must be different for all disks. -- `path` — path under which a server will store data (`data` et `shadow` des dossiers), doit être terminé par ‘/’. -- `keep_free_space_bytes` — the amount of free disk space to be reserved. - -L'ordre du disque définition n'est pas important. - -Stratégies de stockage balisage de configuration: - -``` xml - - ... - - - - - disk_name_from_disks_configuration - 1073741824 - - - - - - - 0.2 - - - - - - - - ... - -``` - -Balise: - -- `policy_name_N` — Policy name. Policy names must be unique. -- `volume_name_N` — Volume name. Volume names must be unique. -- `disk` — a disk within a volume. -- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume's disks. -- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). - -Exemples de Cofiguration: - -``` xml - - ... - - - - - disk1 - disk2 - - - - - - - - fast_ssd - 1073741824 - - - disk1 - - - 0.2 - - - ... - -``` - -Dans l'exemple donné, la `hdd_in_order` politique met en œuvre les [round-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) approche. Ainsi cette politique ne définit qu'un seul volume (`single`), les parties des données sont stockées sur tous ses disques dans l'ordre circulaire. Une telle politique peut être très utile s'il y a plusieurs disques similaires sont montés sur le système, mais RAID N'est pas configuré. Gardez à l'esprit que chaque lecteur de disque n'est pas fiable et vous pouvez compenser avec facteur de réplication de 3 ou plus. - -S'il existe différents types de disques disponibles dans le système, `moving_from_ssd_to_hdd` la stratégie peut être utilisée à la place. Volume `hot` se compose d'un disque SSD (`fast_ssd`), et la taille maximale d'une pièce qui peut être stocké sur ce volume est de 1 go. Toutes les pièces avec la taille plus grande que 1 GB sera stocké directement sur le `cold` le volume, qui contient un disque dur de disque `disk1`. -Aussi, une fois le disque `fast_ssd` est complété par plus de 80%, les données seront transférées à la `disk1` par un processus d'arrière-plan. - -L'ordre d'énumération des volumes dans une stratégie de stockage est important. Une fois qu'un volume est surchargé, les données sont déplacées vers le suivant. L'ordre d'énumération des disques est important parce que les données sont stockées dans les virages. - -Lors de la création d'une table, on peut lui appliquer l'une des stratégies de stockage configurées: - -``` sql -CREATE TABLE table_with_non_default_policy ( - EventDate Date, - OrderID UInt64, - BannerID UInt64, - SearchPhrase String -) ENGINE = MergeTree -ORDER BY (OrderID, BannerID) -PARTITION BY toYYYYMM(EventDate) -SETTINGS storage_policy = 'moving_from_ssd_to_hdd' -``` - -Le `default` la Politique de stockage implique d'utiliser un seul volume, qui se compose d'un seul disque donné dans ``. Une fois qu'une table est créée, sa stratégie de stockage ne peut pas être modifiée. - -### Détail {#details} - -Dans le cas de `MergeTree` les tableaux, les données sont sur le disque de différentes façons: - -- En tant que résultat d'un insert (`INSERT` requête). -- En arrière-plan fusionne et [mutation](../../../sql_reference/statements/alter.md#alter-mutations). -- Lors du téléchargement à partir d'une autre réplique. -- À la suite du gel de la partition [ALTER TABLE … FREEZE PARTITION](../../../sql_reference/statements/alter.md#alter_freeze-partition). - -Dans tous ces cas, à l'exception des mutations et du gel de partition, une pièce est stockée sur un volume et un disque selon la Politique de stockage donnée: - -1. Le premier volume (dans l'ordre de définition) qui a suffisamment d'espace disque pour stocker une pièce (`unreserved_space > current_part_size`) et permet de stocker des pièces d'une taille donnée (`max_data_part_size_bytes > current_part_size`) est choisi. -2. Dans ce volume, ce disque est choisi qui suit celui, qui a été utilisé pour stocker le bloc de données précédent, et qui a de l'espace libre plus que la taille de la pièce (`unreserved_space - keep_free_space_bytes > current_part_size`). - -Sous le capot, les mutations et la congélation des cloisons utilisent [des liens en dur](https://en.wikipedia.org/wiki/Hard_link). Les liens durs entre différents disques ne sont pas pris en charge, donc dans de tels cas, les pièces résultantes sont stockées sur les mêmes disques que les disques initiaux. - -En arrière - plan, les pièces sont déplacées entre les volumes en fonction de la quantité d'espace libre (`move_factor` paramètre) selon l'ordre les volumes sont déclarées dans le fichier de configuration. -Les données ne sont jamais transférées du dernier et dans le premier. On peut utiliser des tables système [système.part\_log](../../../operations/system_tables.md#system_tables-part-log) (champ `type = MOVE_PART`) et [système.partie](../../../operations/system_tables.md#system_tables-parts) (Fields `path` et `disk`) pour surveiller l'arrière-plan se déplace. Aussi, les informations détaillées peuvent être trouvées dans les journaux du serveur. - -L'utilisateur peut forcer le déplacement d'une partie ou d'une partition d'un volume à l'autre à l'aide de la requête [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql_reference/statements/alter.md#alter_move-partition), toutes les restrictions pour les opérations de fond sont prises en compte. La requête initie un mouvement seul et n'attend pas que les opérations d'arrière-plan soient terminées. L'utilisateur recevra un message d'erreur si pas assez d'espace libre est disponible ou si l'une des conditions requises ne sont pas remplies. - -Le déplacement des données n'interfère pas avec la réplication des données. Par conséquent, différentes stratégies de stockage peuvent être spécifiées pour la même table sur différents réplicas. - -Après l'achèvement des fusions d'arrière-plan et des mutations, les anciennes parties ne sont supprimées qu'après un certain temps (`old_parts_lifetime`). -Pendant ce temps, ils ne sont pas déplacés vers d'autres volumes ou des disques. Par conséquent, jusqu'à ce que les pièces soient finalement supprimées, elles sont toujours prises en compte pour l'évaluation de l'espace disque occupé. - -[Article Original](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/fr/engines/table_engines/mergetree_family/replacingmergetree.md b/docs/fr/engines/table_engines/mergetree_family/replacingmergetree.md deleted file mode 100644 index 8051bf5bfcc..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/replacingmergetree.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 33 -toc_title: ReplacingMergeTree ---- - -# Replacingmergetree {#replacingmergetree} - -Le moteur diffère de [MergeTree](mergetree.md#table_engines-mergetree) en ce qu'il supprime les doublons avec la même valeur de clé primaire (ou, plus précisément, avec la même [clé de tri](mergetree.md) valeur). - -La déduplication des données se produit uniquement lors d'une fusion. La fusion se produit en arrière-plan à un moment inconnu, vous ne pouvez donc pas le planifier. Certaines des données peuvent rester non traitées. Bien que vous puissiez exécuter une fusion imprévue en utilisant le `OPTIMIZE` requête, ne comptez pas l'utiliser, parce que la `OPTIMIZE` requête va lire et écrire une grande quantité de données. - -Ainsi, `ReplacingMergeTree` convient pour effacer les données en double en arrière-plan afin d'économiser de l'espace, mais cela ne garantit pas l'absence de doublons. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = ReplacingMergeTree([ver]) -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Pour une description des paramètres de requête, voir [demande de description](../../../sql_reference/statements/create.md). - -**ReplacingMergeTree Paramètres** - -- `ver` — column with version. Type `UInt*`, `Date` ou `DateTime`. Paramètre facultatif. - - Lors de la fusion, `ReplacingMergeTree` de toutes les lignes avec la même clé primaire ne laisse qu'un: - - - Dernier dans la sélection, si `ver` pas ensemble. - - Avec la version maximale, si `ver` défini. - -**Les clauses de requête** - -Lors de la création d'un `ReplacingMergeTree` la table de la même [clause](mergetree.md) sont nécessaires, comme lors de la création d'un `MergeTree` table. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) -``` - -Tous les paramètres excepté `ver` ont la même signification que dans `MergeTree`. - -- `ver` - colonne avec la version. Paramètre facultatif. Pour une description, voir le texte ci-dessus. - -
- -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/fr/engines/table_engines/mergetree_family/replication.md b/docs/fr/engines/table_engines/mergetree_family/replication.md deleted file mode 100644 index cf02e3da217..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/replication.md +++ /dev/null @@ -1,218 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 31 -toc_title: "R\xE9plication Des Donn\xE9es" ---- - -# Réplication Des Données {#table_engines-replication} - -La réplication n'est prise en charge que pour les tables de la famille MergeTree: - -- ReplicatedMergeTree -- ReplicatedSummingMergeTree -- ReplicatedReplacingMergeTree -- ReplicatedAggregatingMergeTree -- ReplicatedCollapsingMergeTree -- ReplicatedVersionedCollapsingMergetree -- ReplicatedGraphiteMergeTree - -La réplication fonctionne au niveau d'une table individuelle, Pas du serveur entier. Un serveur peut stocker des tables répliquées et non répliquées en même temps. - -La réplication ne dépend pas de la fragmentation. Chaque fragment a sa propre réplication indépendante. - -Données compressées pour `INSERT` et `ALTER` les requêtes sont répliquées (pour plus d'informations, consultez la documentation de [ALTER](../../../sql_reference/statements/alter.md#query_language_queries_alter)). - -`CREATE`, `DROP`, `ATTACH`, `DETACH` et `RENAME` les requêtes sont exécutées sur un seul serveur et ne sont pas répliquées: - -- Le `CREATE TABLE` query crée une nouvelle table réplicable sur le serveur où la requête est exécutée. Si cette table existe déjà sur d'autres serveurs, il ajoute une nouvelle réplique. -- Le `DROP TABLE` requête supprime la réplique situé sur le serveur où l'exécution de la requête. -- Le `RENAME` requête renomme la table sur l'une des répliques. En d'autres termes, les tables répliquées peuvent avoir des noms différents sur différentes répliques. - -Clickhouse utilise [Apache ZooKeeper](https://zookeeper.apache.org) pour stocker des informations méta répliques. Utilisez ZooKeeper version 3.4.5 ou plus récente. - -Pour utiliser la réplication, définissez les paramètres [zookeeper](../../../operations/server_configuration_parameters/settings.md#server-settings_zookeeper) section de configuration du serveur. - -!!! attention "Attention" - Ne négligez pas la sécurité. Clickhouse soutient le `digest` [Schéma ACL](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) du sous-système de sécurité ZooKeeper. - -Exemple de définition des adresses du cluster ZooKeeper: - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - - example3 - 2181 - - -``` - -Vous pouvez spécifier N'importe quel cluster Zookeeper existant et le système utilisera un répertoire pour ses propres données (le répertoire est spécifié lors de la création d'une table réplicable). - -Si ZooKeeper n'est pas défini dans le fichier de configuration, vous ne pouvez pas créer de tables répliquées et toutes les tables répliquées existantes seront en lecture seule. - -La gardienne n'est pas utilisé dans `SELECT` requêtes car la réplication n'affecte pas les performances de `SELECT` et les requêtes s'exécutent aussi vite que pour les tables non répliquées. Lors de l'interrogation de tables répliquées distribuées, le comportement de ClickHouse est contrôlé par les paramètres [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) et [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). - -Pour chaque `INSERT` requête, environ dix entrées sont ajoutées à ZooKeeper par le biais de plusieurs transactions. (Pour être plus précis, c'est pour chaque bloc de données inséré; une requête D'insertion contient un bloc ou un bloc par `max_insert_block_size = 1048576` rangée.) Cela conduit à des latences légèrement plus longues pour `INSERT` par rapport aux tables non répliquées. Mais si vous suivez les recommandations pour insérer des données dans des lots de pas plus d'un `INSERT` par seconde, cela ne crée aucun problème. L'ensemble du cluster clickhouse utilisé pour coordonner un cluster ZooKeeper a un total de plusieurs centaines `INSERTs` par seconde. Le débit sur les insertions de données (le nombre de lignes par seconde) est aussi élevé que pour les non-données répliquées. - -Pour les clusters très volumineux, vous pouvez utiliser différents clusters ZooKeeper pour différents fragments. Cependant, cela ne s'est pas avéré nécessaire sur le Yandex.Cluster Metrica (environ 300 serveurs). - -La réplication est asynchrone et multi-maître. `INSERT` les requêtes (ainsi que `ALTER`) peuvent être envoyés à n'importe quel serveur disponible. Les données sont insérées sur le serveur où la requête est exécutée, puis il est copié sur les autres serveurs. Comme il est asynchrone, les données récemment insérées apparaissent sur les autres répliques avec une certaine latence. Si une partie des répliques ne sont pas disponibles, les données sont écrites lorsqu'elles sont disponibles. Si une réplique est disponible, la latence correspond au temps nécessaire pour transférer le bloc de données compressées sur le réseau. - -Par défaut, une requête INSERT attend la confirmation de l'écriture des données à partir d'un seul réplica. Si les données ont été correctement écrit sur une seule réplique et le serveur avec cette réplique cesse d'exister, les données enregistrées seront perdues. Pour activer la confirmation des Écritures de données à partir de plusieurs réplicas, utilisez `insert_quorum` option. - -Chaque bloc de données est écrit de manière atomique. La requête D'insertion est divisée en blocs jusqu'à `max_insert_block_size = 1048576` rangée. En d'autres termes, si l' `INSERT` la requête a moins de 1048576 lignes, elle est faite de manière atomique. - -Les blocs de données sont dédupliquées. Pour plusieurs écritures du même bloc de données (blocs de données de même taille contenant les mêmes lignes dans le même ordre), le bloc n'est écrit qu'une seule fois. La raison en est en cas de défaillance du réseau lorsque l'application cliente ne sait pas si les données ont été écrites dans la base de données, de sorte que le `INSERT` requête peut simplement être répété. Peu importe à quelles insertions de réplica ont été envoyées avec des données identiques. `INSERTs` sont idempotents. Les paramètres de déduplication sont contrôlés par [merge\_tree](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-merge_tree) les paramètres du serveur. - -Pendant la réplication, seules les données source à insérer sont transférées sur le réseau. D'autres transformations de données (fusion) sont coordonnées et effectuées sur toutes les répliques de la même manière. Cela minimise l'utilisation du réseau, ce qui signifie que la réplication fonctionne bien lorsque les répliques résident dans différents centres de données. (Notez que la duplication de données dans différents centres de données est l'objectif principal de la réplication.) - -Vous pouvez avoir n'importe quel nombre de répliques des mêmes données. Yandex.Metrica utilise la double réplication en production. Chaque serveur utilise RAID-5 ou RAID-6, et RAID-10 dans certains cas. C'est une solution relativement fiable et pratique. - -Le système surveille la synchronicité des données sur les répliques et est capable de récupérer après une défaillance. Le basculement est automatique (pour les petites différences de données) ou semi-automatique (lorsque les données diffèrent trop, ce qui peut indiquer une erreur de configuration). - -## Création De Tables Répliquées {#creating-replicated-tables} - -Le `Replicated` le préfixe est ajouté au nom du moteur de table. Exemple:`ReplicatedMergeTree`. - -**Répliqué \* MergeTree paramètres** - -- `zoo_path` — The path to the table in ZooKeeper. -- `replica_name` — The replica name in ZooKeeper. - -Exemple: - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -``` - -
- -Exemple de syntaxe obsolète - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) -``` - -
- -Comme le montre l'exemple, ces paramètres peuvent contenir des substitutions entre crochets. Les valeurs substituées sont tirées de la ‘macros’ section du fichier de configuration. Exemple: - -``` xml - - 05 - 02 - example05-02-1.yandex.ru - -``` - -Le chemin d'accès à la table dans ZooKeeper doit être unique pour chaque table répliquée. Les Tables sur différents fragments doivent avoir des chemins différents. -Dans ce cas, le chemin se compose des parties suivantes: - -`/clickhouse/tables/` est le préfixe commun. Nous vous recommandons d'utiliser exactement celui-ci. - -`{layer}-{shard}` est l'identificateur de fragment. Dans cet exemple, il se compose de deux parties, depuis l'Yandex.Le cluster Metrica utilise le sharding à deux niveaux. Pour la plupart des tâches, vous ne pouvez laisser que la substitution {shard}, qui sera étendue à l'Identificateur de partition. - -`table_name` est le nom du nœud de la table dans ZooKeeper. C'est une bonne idée de le rendre identique au nom de la table. Il est défini explicitement, car contrairement au nom de la table, il ne change pas après une requête de renommage. -*HINT*: vous pouvez ajouter un nom de base de données devant `table_name` Aussi. E. g. `db_name.table_name` - -Le nom du réplica identifie différentes réplicas de la même table. Vous pouvez utiliser le nom de serveur pour cela, comme dans l'exemple. Le nom doit seulement être unique dans chaque fragment. - -Vous pouvez définir les paramètres explicitement au lieu d'utiliser des substitutions. Cela peut être pratique pour tester et configurer de petits clusters. Cependant, vous ne pouvez pas utiliser de requêtes DDL distribuées (`ON CLUSTER`) dans ce cas. - -Lorsque vous travaillez avec de grands clusters, nous vous recommandons d'utiliser des substitutions car elles réduisent la probabilité d'erreur. - -Exécutez l' `CREATE TABLE` requête sur chaque réplique. Cette requête crée une nouvelle table répliquée, ou ajoute une nouvelle réplique à un existant. - -Si vous ajoutez une nouvelle réplique après que la table contient déjà des données sur d'autres répliques, les données seront copiées des autres répliques vers la nouvelle après l'exécution de la requête. En d'autres termes, la nouvelle réplique synchronise avec les autres. - -Pour supprimer une réplique, exécutez `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. - -## Récupération Après Des Échecs {#recovery-after-failures} - -Si ZooKeeper n'est pas disponible au démarrage d'un serveur, les tables répliquées passent en mode Lecture seule. Le système tente périodiquement de se connecter à ZooKeeper. - -Si ZooKeeper est indisponible pendant un `INSERT`, ou une erreur se produit lors de l'interaction avec ZooKeeper, une exception est levée. - -Après la connexion à ZooKeeper, le système vérifie si l'ensemble de données du système de fichiers local correspond à l'ensemble de données attendu (ZooKeeper stocke ces informations). S'il y a des incohérences mineures, le système les résout en synchronisant les données avec les répliques. - -Si le système détecte des parties de données brisées (avec la mauvaise taille des fichiers) ou des parties non reconnues (parties écrites dans le système de fichiers mais non enregistrées dans ZooKeeper), il les déplace vers le `detached` sous-répertoire (ils ne sont pas supprimés). Toutes les pièces manquantes sont copiées à partir des répliques. - -Notez que ClickHouse n'effectue aucune action destructrice telle que la suppression automatique d'une grande quantité de données. - -Lorsque le serveur démarre (ou établit une nouvelle session avec ZooKeeper), il vérifie uniquement la quantité et la taille de tous les fichiers. Si les tailles de fichier correspondent mais que les octets ont été modifiés quelque part au milieu, cela n'est pas détecté immédiatement, mais uniquement lorsque vous tentez de lire les données `SELECT` requête. La requête lève une exception concernant une somme de contrôle ou une taille non correspondante d'un bloc compressé. Dans ce cas, des parties de données sont ajoutées à la file d'attente de vérification et copiées à partir des répliques si nécessaire. - -Si la série de données diffère trop de celle attendue, un mécanisme de sécurité est déclenché. Le serveur entre cela dans le journal et refuse de lancer. La raison en est que ce cas peut indiquer une erreur de configuration, par exemple si une réplique sur un fragment a été accidentellement configurée comme une réplique sur un fragment différent. Cependant, les seuils pour ce mécanisme sont fixés assez bas, et cette situation peut se produire pendant la récupération normale de la défaillance. Dans ce cas, les données sont restaurées semi-automatiquement - par “pushing a button”. - -Pour démarrer la récupération, créez le nœud `/path_to_table/replica_name/flags/force_restore_data` dans ZooKeeper avec n'importe quel contenu, ou exécutez la commande pour restaurer toutes les tables répliquées: - -``` bash -sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data -``` - -Puis redémarrez le serveur. Au démarrage, le serveur supprime ces indicateurs et démarre la récupération. - -## Récupération Après La Perte De Données Complète {#recovery-after-complete-data-loss} - -Si toutes les données et métadonnées ont disparu de l'un des serveurs, procédez comme suit pour la récupération: - -1. Installez ClickHouse sur le serveur. Définissez correctement les substitutions dans le fichier de configuration qui contient l'Identificateur de fragment et les répliques, si vous les utilisez. -2. Si vous avez des tables non compliquées qui doivent être dupliquées manuellement sur les serveurs, copiez leurs données à partir d'un réplica (dans le répertoire `/var/lib/clickhouse/data/db_name/table_name/`). -3. Copier les définitions de table situées dans `/var/lib/clickhouse/metadata/` à partir d'une réplique. Si un identificateur de fragment ou de réplica est défini explicitement dans les définitions de table, corrigez-le de manière à ce qu'il corresponde à ce réplica. (Alternativement, démarrez le serveur et faites tous les `ATTACH TABLE` les requêtes qui auraient dû être dans les .les fichiers sql dans `/var/lib/clickhouse/metadata/`.) -4. Pour démarrer la récupération, créez le nœud ZooKeeper `/path_to_table/replica_name/flags/force_restore_data` tout contenu, ou d'exécuter la commande pour restaurer toutes les tables répliquées: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` - -Ensuite, démarrez le serveur (redémarrez, s'il est déjà en cours d'exécution). Les données seront téléchargées à partir de répliques. - -Une autre option de récupération consiste à supprimer des informations sur la réplique perdue de ZooKeeper (`/path_to_table/replica_name`), puis créez à nouveau la réplique comme décrit dans “[Création de tables répliquées](#creating-replicated-tables)”. - -Il n'y a aucune restriction sur la bande passante réseau pendant la récupération. Gardez cela à l'esprit si vous restaurez de nombreuses répliques à la fois. - -## Conversion De Mergetree En Replicatedmergetree {#converting-from-mergetree-to-replicatedmergetree} - -Nous utilisons le terme `MergeTree` pour consulter tous les moteurs de la `MergeTree family` le même que pour `ReplicatedMergeTree`. - -Si vous avez eu une `MergeTree` table qui a été répliquée manuellement, vous pouvez le convertir en une table répliquée. Vous devrez peut-être le faire si vous avez déjà recueilli une grande quantité de données dans un `MergeTree` table et maintenant vous voulez activer la réplication. - -Si les données diffèrent sur différentes répliques, synchronisez-les d'abord ou supprimez-les sur toutes les répliques sauf une. - -Renommez la table mergetree existante, puis créez un `ReplicatedMergeTree` table avec l'ancien nom. -Déplacez les données de l'ancienne table vers `detached` sous-répertoire à l'intérieur du répertoire avec les nouvelles données de la table (`/var/lib/clickhouse/data/db_name/table_name/`). -Ensuite, exécutez `ALTER TABLE ATTACH PARTITION` sur l'une des répliques d'ajouter ces données à des parties de l'ensemble de travail. - -## Conversion De Replicatedmergetree En Mergetree {#converting-from-replicatedmergetree-to-mergetree} - -Créez une table MergeTree avec un nom différent. Déplacez toutes les données du répertoire avec le `ReplicatedMergeTree` données de la table dans le répertoire de données de la nouvelle table. Ensuite, supprimer le `ReplicatedMergeTree` table et redémarrez le serveur. - -Si vous voulez vous débarrasser d'un `ReplicatedMergeTree` table sans lancer le serveur: - -- Supprimer la `.sql` fichier dans le répertoire de métadonnées (`/var/lib/clickhouse/metadata/`). -- Supprimer le chemin correspondant dans ZooKeeper (`/path_to_table/replica_name`). - -Après cela, vous pouvez lancer le serveur, créer un `MergeTree` tableau, déplacer les données de son répertoire, puis redémarrez le serveur. - -## Récupération lorsque les métadonnées du Cluster Zookeeper sont perdues ou endommagées {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} - -Si les données de ZooKeeper ont été perdues ou endommagées, vous pouvez les enregistrer en les déplaçant dans une table non compliquée comme décrit ci-dessus. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/fr/engines/table_engines/mergetree_family/summingmergetree.md b/docs/fr/engines/table_engines/mergetree_family/summingmergetree.md deleted file mode 100644 index 52bfaee15ca..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/summingmergetree.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 34 -toc_title: SummingMergeTree ---- - -# Summingmergetree {#summingmergetree} - -Le moteur hérite de [MergeTree](mergetree.md#table_engines-mergetree). La différence est que lors de la fusion de parties de données pour `SummingMergeTree` tables ClickHouse remplace toutes les lignes avec la même clé primaire (ou, plus précisément, avec la même [clé de tri](mergetree.md)) avec une ligne qui contient des valeurs résumées pour les colonnes avec le type de données numériques. Si la clé de tri est composée de telle sorte qu'une seule valeur de clé correspond à un grand nombre de lignes, cela réduit considérablement le volume de stockage et accélère la sélection des données. - -Nous vous recommandons d'utiliser le moteur avec `MergeTree`. Stocker des données complètes dans `MergeTree` table, et l'utilisation `SummingMergeTree` pour le stockage de données agrégées, par exemple, lors de la préparation de rapports. Une telle approche vous empêchera de perdre des données précieuses en raison d'une clé primaire mal composée. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = SummingMergeTree([columns]) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Pour une description des paramètres de requête, voir [demande de description](../../../sql_reference/statements/create.md). - -**Paramètres de SummingMergeTree** - -- `columns` - un n-uplet avec les noms de colonnes où les valeurs seront résumées. Paramètre facultatif. - Les colonnes doivent être d'un type numérique et ne doit pas être dans la clé primaire. - - Si `columns` non spécifié, ClickHouse résume les valeurs dans toutes les colonnes avec un type de données numérique qui ne sont pas dans la clé primaire. - -**Les clauses de requête** - -Lors de la création d'un `SummingMergeTree` la table de la même [clause](mergetree.md) sont nécessaires, comme lors de la création d'un `MergeTree` table. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets et, si possible, remplacez les anciens projets par la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) -``` - -Tous les paramètres excepté `columns` ont la même signification que dans `MergeTree`. - -- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. - -
- -## Exemple D'Utilisation {#usage-example} - -Considérons le tableau suivant: - -``` sql -CREATE TABLE summtt -( - key UInt32, - value UInt32 -) -ENGINE = SummingMergeTree() -ORDER BY key -``` - -Insérer des données: - -``` sql -INSERT INTO summtt Values(1,1),(1,2),(2,1) -``` - -ClickHouse peut résumer toutes les lignes pas complètement ([voir ci-dessous](#data-processing)), nous utilisons donc une fonction d'agrégation `sum` et `GROUP BY` la clause dans la requête. - -``` sql -SELECT key, sum(value) FROM summtt GROUP BY key -``` - -``` text -┌─key─┬─sum(value)─┐ -│ 2 │ 1 │ -│ 1 │ 3 │ -└─────┴────────────┘ -``` - -## Le Traitement Des Données {#data-processing} - -Lorsque les données sont insérées dans une table, elles sont enregistrées telles quelles. Clickhouse fusionne périodiquement les parties de données insérées et c'est à ce moment que les lignes avec la même clé primaire sont additionnées et remplacées par une pour chaque partie de données résultante. - -ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) une fonction d'agrégation [somme()](../../../sql_reference/aggregate_functions/reference.md#agg_function-sum) et `GROUP BY` la clause doit être utilisé dans une requête comme décrit dans l'exemple ci-dessus. - -### Règles Communes Pour La Sommation {#common-rules-for-summation} - -Les valeurs dans les colonnes avec le type de données numériques sont résumées. L'ensemble des colonnes est défini par le paramètre `columns`. - -Si les valeurs étaient 0 dans toutes les colonnes pour la sommation, la ligne est supprimée. - -Si la colonne n'est pas dans la clé primaire et n'est pas résumée, une valeur arbitraire est sélectionnée parmi celles existantes. - -Les valeurs ne sont pas résumés des colonnes de la clé primaire. - -### La somme dans les colonnes Aggregatefunction {#the-summation-in-the-aggregatefunction-columns} - -Pour les colonnes de [Type AggregateFunction](../../../sql_reference/data_types/aggregatefunction.md) ClickHouse se comporte comme [AggregatingMergeTree](aggregatingmergetree.md) moteur d'agrégation selon la fonction. - -### Structures Imbriquées {#nested-structures} - -Table peut avoir des structures de données imbriquées qui sont traitées d'une manière spéciale. - -Si le nom d'une table imbriquée se termine avec `Map` et il contient au moins deux colonnes qui répondent aux critères suivants: - -- la première colonne est numérique `(*Int*, Date, DateTime)` ou une chaîne de caractères `(String, FixedString)`, nous allons l'appeler `key`, -- les autres colonnes sont arithmétique `(*Int*, Float32/64)`, nous allons l'appeler `(values...)`, - -ensuite, cette table imbriquée est interprétée comme un mappage de `key => (values...)` et lors de la fusion de ses lignes, les éléments de deux ensembles de données sont regroupées par `key` avec une sommation du correspondant `(values...)`. - -Exemple: - -``` text -[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] -[(1, 100)] + [(1, 150)] -> [(1, 250)] -[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] -[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] -``` - -Lorsque vous demandez des données, utilisez [sumMap (clé, valeur)](../../../sql_reference/aggregate_functions/reference.md) fonction pour l'agrégation de `Map`. - -Pour la structure de données imbriquée, vous n'avez pas besoin de spécifier ses colonnes dans le tuple de colonnes pour la sommation. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/fr/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md b/docs/fr/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md deleted file mode 100644 index 9f80a1683bd..00000000000 --- a/docs/fr/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 37 -toc_title: VersionedCollapsingMergeTree ---- - -# Versionedcollapsingmergetree {#versionedcollapsingmergetree} - -Ce moteur: - -- Permet l'écriture rapide des États d'objet qui changent continuellement. -- Supprime les anciens États d'objets en arrière-plan. Cela réduit considérablement le volume de stockage. - -Voir la section [Effondrer](#table_engines_versionedcollapsingmergetree) pour plus de détails. - -Le moteur hérite de [MergeTree](mergetree.md#table_engines-mergetree) et ajoute la logique de réduction des lignes à l'algorithme de fusion des parties de données. `VersionedCollapsingMergeTree` sert le même but que [CollapsingMergeTree](collapsingmergetree.md) mais utilise un autre effondrement algorithme qui permet d'insérer les données dans n'importe quel ordre avec plusieurs threads. En particulier, l' `Version` la colonne aide à réduire correctement les lignes même si elles sont insérées dans le mauvais ordre. Contrairement, `CollapsingMergeTree` permet uniquement une insertion strictement consécutive. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = VersionedCollapsingMergeTree(sign, version) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Pour une description des paramètres de requête, voir les [description de la requête](../../../sql_reference/statements/create.md). - -**Les Paramètres Du Moteur** - -``` sql -VersionedCollapsingMergeTree(sign, version) -``` - -- `sign` — Name of the column with the type of row: `1` est un “state” rangée, `-1` est un “cancel” rangée. - - Le type de données de colonne doit être `Int8`. - -- `version` — Name of the column with the version of the object state. - - Le type de données de colonne doit être `UInt*`. - -**Les Clauses De Requête** - -Lors de la création d'un `VersionedCollapsingMergeTree` de table, de la même [clause](mergetree.md) sont requis lors de la création d'un `MergeTree` table. - -
- -Méthode obsolète pour créer une Table - -!!! attention "Attention" - N'utilisez pas cette méthode dans les nouveaux projets. Si possible, passer les anciens projets à la méthode décrite ci-dessus. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] VersionedCollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign, version) -``` - -Tous les paramètres, à l'exception `sign` et `version` ont la même signification que dans `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` est un “state” rangée, `-1` est un “cancel” rangée. - - Column Data Type — `Int8`. - -- `version` — Name of the column with the version of the object state. - - Le type de données de colonne doit être `UInt*`. - -
- -## Effondrer {#table_engines-versionedcollapsingmergetree} - -### Données {#data} - -Considérez une situation où vous devez enregistrer des données en constante évolution pour un objet. Il est raisonnable d'avoir une ligne pour un objet et de mettre à jour la ligne chaque fois qu'il y a des modifications. Cependant, l'opération de mise à jour est coûteuse et lente pour un SGBD car elle nécessite la réécriture des données dans le stockage. La mise à jour n'est pas acceptable si vous devez écrire des données rapidement, mais vous pouvez écrire les modifications sur un objet de manière séquentielle comme suit. - -L'utilisation de la `Sign` colonne lors de l'écriture de la ligne. Si `Sign = 1` cela signifie que la ligne est un état d'un objet (appelons-la “state” rangée). Si `Sign = -1` il indique l'annulation de l'état d'un objet avec les mêmes attributs (appelons-la “cancel” rangée). Également utiliser l' `Version` colonne, qui doit identifier chaque état d'un objet avec un numéro distinct. - -Par exemple, nous voulons calculer le nombre de pages visitées sur le site et combien de temps ils étaient là. À un moment donné nous écrivons la ligne suivante avec l'état de l'activité de l'utilisateur: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -À un moment donné, nous enregistrons le changement d'activité de l'utilisateur et l'écrivons avec les deux lignes suivantes. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -La première ligne annule le précédent état de l'objet (utilisateur). Il doit copier tous les champs de l'état annulé sauf `Sign`. - -La deuxième ligne contient l'état actuel. - -Parce que nous avons besoin seulement le dernier état de l'activité de l'utilisateur, les lignes - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -peut être supprimé, réduisant l'état invalide (ancien) de l'objet. `VersionedCollapsingMergeTree` fait cela lors de la fusion des parties de données. - -Pour savoir pourquoi nous avons besoin de deux lignes pour chaque changement, voir [Algorithme](#table_engines-versionedcollapsingmergetree-algorithm). - -**Notes sur l'Utilisation de la** - -1. Le programme qui écrit les données devraient se souvenir de l'état d'un objet afin de l'annuler. Le “cancel” chaîne doit être une copie de la “state” chaîne avec le contraire `Sign`. Cela augmente la taille initiale de stockage, mais permet d'écrire les données rapidement. -2. Les tableaux de plus en plus longs dans les colonnes réduisent l'efficacité du moteur en raison de la charge d'écriture. Plus les données sont simples, meilleure est l'efficacité. -3. `SELECT` les résultats dépendent fortement de la cohérence de l'histoire de l'objet change. Être précis lors de la préparation des données pour l'insertion. Vous pouvez obtenir des résultats imprévisibles avec des données incohérentes, telles que des valeurs négatives pour des métriques non négatives telles que la profondeur de session. - -### Algorithme {#table_engines-versionedcollapsingmergetree-algorithm} - -Lorsque ClickHouse fusionne des parties de données, il supprime chaque paire de lignes ayant la même clé primaire et la même version et différentes `Sign`. L'ordre des lignes n'a pas d'importance. - -Lorsque ClickHouse insère des données, il ordonne les lignes par la clé primaire. Si l' `Version` la colonne n'est pas dans la clé primaire, ClickHouse ajoute à la clé primaire implicitement que le dernier champ et l'utilise pour la commande. - -## La Sélection De Données {#selecting-data} - -ClickHouse ne garantit pas que toutes les lignes avec la même clé primaire sera dans la même partie des données ou même sur le même serveur physique. Cela est vrai à la fois pour l'écriture des données et pour la fusion ultérieure des parties de données. En outre, les processus ClickHouse `SELECT` requêtes avec plusieurs threads, et il ne peut pas prédire l'ordre des lignes dans le résultat. Cela signifie que le regroupement est nécessaire s'il est nécessaire pour obtenir complètement “collapsed” données à partir d'un `VersionedCollapsingMergeTree` table. - -Pour finaliser la réduction, écrivez une requête avec un `GROUP BY` fonctions de clause et d'agrégation qui tiennent compte du signe. Par exemple, pour calculer la quantité, l'utilisation `sum(Sign)` plutôt `count()`. Pour calculer la somme de quelque chose, utilisez `sum(Sign * x)` plutôt `sum(x)` et d'ajouter `HAVING sum(Sign) > 0`. - -Aggregate `count`, `sum` et `avg` peut être calculée de cette manière. Aggregate `uniq` peut être calculé si un objet a au moins un non-état effondré. Aggregate `min` et `max` ne peut pas être calculé, car `VersionedCollapsingMergeTree` ne sauvegarde pas l'historique des valeurs des États réduits. - -Si vous avez besoin d'extraire les données avec “collapsing” mais sans agrégation (par exemple, pour vérifier si des lignes sont présentes dont les valeurs les plus récentes correspondent à certaines conditions), vous pouvez utiliser `FINAL` le modificateur du `FROM` clause. Cette approche est inefficace et ne devrait pas être utilisée avec de grandes tables. - -## Exemple D'Utilisation {#example-of-use} - -Les données de l'exemple: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Création de la table: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8, - Version UInt8 -) -ENGINE = VersionedCollapsingMergeTree(Sign, Version) -ORDER BY UserID -``` - -Insérer les données: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) -``` - -Nous utilisons deux `INSERT` requêtes pour créer deux parties de données différentes. Si nous insérons les données avec une seule requête, ClickHouse crée une partie de données et n'effectuera jamais de fusion. - -L'obtention de données: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Que voyons-nous ici et où sont les parties effondrées? -Nous avons créé deux parties de données en utilisant deux `INSERT` requête. Le `SELECT` la requête a été effectuée dans deux threads, et le résultat est un ordre aléatoire de lignes. -L'effondrement n'a pas eu lieu car les parties de données n'ont pas encore été fusionnées. ClickHouse fusionne des parties de données à un moment inconnu que nous ne pouvons pas prédire. - -C'est pourquoi nous avons besoin de l'agrégation: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration, - Version -FROM UAct -GROUP BY UserID, Version -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 2 │ -└─────────────────────┴───────────┴──────────┴─────────┘ -``` - -Si nous n'avons pas besoin d'agrégation et que nous voulons forcer l'effondrement, nous pouvons utiliser le `FINAL` le modificateur du `FROM` clause. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -C'est un moyen très inefficace de sélectionner des données. Ne l'utilisez pas pour les grandes tables. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/fr/engines/table_engines/special/buffer.md b/docs/fr/engines/table_engines/special/buffer.md deleted file mode 100644 index 5ffc6e6724c..00000000000 --- a/docs/fr/engines/table_engines/special/buffer.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 45 -toc_title: Tampon ---- - -# Tampon {#buffer} - -Met en mémoire tampon les données à écrire dans la RAM, les vidant périodiquement dans une autre table. Pendant l'opération de lecture, les données sont lues à partir de la mémoire tampon, et l'autre simultanément. - -``` sql -Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) -``` - -Les paramètres du moteur: - -- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. -- `table` – Table to flush data to. -- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` indépendant de tampons. Valeur recommandée: 16. -- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, et `max_bytes` – Conditions for flushing data from the buffer. - -Les données sont vidées du tampon et écrites dans la table de destination si toutes les `min*` conditions ou au moins un `max*` conditions sont remplies. - -- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. -- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. -- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. - -Pendant l'opération d'écriture, les données sont insérées dans un `num_layers` nombre aléatoire de tampons. Ou, si la partie de données à insérer est suffisamment grande (supérieure à `max_rows` ou `max_bytes`), il est écrit directement dans la table de destination, en omettant le tampon. - -Les conditions de purger les données sont calculées séparément pour chacun des `num_layers` tampon. Par exemple, si `num_layers = 16` et `max_bytes = 100000000`, la consommation maximale de RAM est de 1,6 Go. - -Exemple: - -``` sql -CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) -``` - -La création d'un ‘merge.hits\_buffer’ table avec la même structure que ‘merge.hits’ et en utilisant le moteur tampon. Lors de l'écriture dans cette table, les données sont mises en mémoire tampon dans la RAM ‘merge.hits’ table. 16 tampons sont créés. Les données dans chacun d'entre eux est rincé si 100 secondes sont écoulées, ou un million de lignes ont été écrites, ou 100 MO de données ont été écrits; ou si, simultanément, 10 secondes et 10 000 lignes et 10 MO de données ont été écrites. Par exemple, si une ligne a été écrite, après 100 secondes, il sera vidé, n'importe quoi. Mais si plusieurs lignes ont été écrites, les données seront vidées plus tôt. - -Lorsque le serveur est arrêté, avec DROP TABLE ou DETACH TABLE, les données du tampon sont également vidées vers la table de destination. - -Vous pouvez définir des chaînes vides entre guillemets simples pour le nom de la base de données et de la table. Cela indique l'absence d'une table de destination. Dans ce cas, lorsque les conditions de vidage des données sont atteintes, le tampon est simplement effacé. Cela peut être utile pour garder une fenêtre de données dans la mémoire. - -Lors de la lecture à partir d'une table tampon, les données sont traitées à la fois à partir du tampon et de la table de destination (s'il y en a une). -Notez que les tables de tampon ne prennent pas en charge un index. En d'autres termes, les données dans le tampon sont entièrement analysées, ce qui peut être lent pour les grands tampons. (Pour les données dans une table subordonnée, l'index qu'il prend en charge sera utilisé.) - -Si l'ensemble de colonnes de la table tampon ne correspond pas à l'ensemble de colonnes d'une table subordonnée, un sous-ensemble de colonnes existant dans les deux tables est inséré. - -Si les types ne correspondent pas à l'une des colonnes de la table tampon et à une table subordonnée, un message d'erreur est entré dans le journal du serveur et le tampon est effacé. -La même chose se produit si la table subordonnée n'existe pas lorsque le tampon est vidé. - -Si vous devez exécuter ALTER pour une table subordonnée et la table tampon, nous vous recommandons de supprimer d'abord la table tampon, d'exécuter ALTER pour la table subordonnée, puis de créer à nouveau la table tampon. - -Si le serveur est redémarré anormalement, les données dans le tampon sont perdues. - -FINAL et SAMPLE ne fonctionnent pas correctement pour les tables tampon. Ces conditions sont transmises à la table de destination, mais ne sont pas utilisées pour traiter les données dans le tampon. Si ces fonctionnalités sont nécessaires, nous vous recommandons d'utiliser uniquement la table tampon pour l'écriture, lors de la lecture à partir de la table de destination. - -Lors de l'ajout de données à un Tampon, un des tampons est verrouillé. Cela entraîne des retards si une opération de lecture est effectuée simultanément à partir de la table. - -Les données insérées dans une table tampon peuvent se retrouver dans la table subordonnée dans un ordre différent et dans des blocs différents. Pour cette raison, une table tampon est difficile à utiliser pour écrire correctement dans un CollapsingMergeTree. Pour éviter les problèmes, vous pouvez définir ‘num\_layers’ 1. - -Si la table de destination est répliquée, certaines caractéristiques attendues des tables répliquées sont perdues lors de l'écriture dans une table tampon. Les modifications aléatoires apportées à l'ordre des lignes et des tailles des parties de données provoquent l'arrêt de la déduplication des données, ce qui signifie qu'il n'est pas possible d'avoir un ‘exactly once’ Ecrire dans des tables répliquées. - -En raison de ces inconvénients, nous ne pouvons recommander l'utilisation d'une table tampon que dans de rares cas. - -Une table tampon est utilisée lorsque trop D'insertions sont reçues d'un grand nombre de serveurs sur une unité de temps et que les données ne peuvent pas être mises en mémoire tampon avant l'insertion, ce qui signifie que les insertions ne peuvent pas s'exécuter assez rapidement. - -Notez qu'il n'est pas judicieux d'insérer des données d'une ligne de temps, même pour Tampon tables. Cela ne produira qu'une vitesse de quelques milliers de lignes par seconde, tandis que l'insertion de blocs de données plus grands peut produire plus d'un million de lignes par seconde (voir la section “Performance”). - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/fr/engines/table_engines/special/dictionary.md b/docs/fr/engines/table_engines/special/dictionary.md deleted file mode 100644 index 79b05a5c855..00000000000 --- a/docs/fr/engines/table_engines/special/dictionary.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 35 -toc_title: Dictionnaire ---- - -# Dictionnaire {#dictionary} - -Le `Dictionary` le moteur affiche le [dictionnaire](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) données comme une table ClickHouse. - -À titre d'exemple, considérons un dictionnaire de `products` avec la configuration suivante: - -``` xml - - - products - - -
products
- DSN=some-db-server - - - - 300 - 360 - - - - - - - product_id - - - title - String - - - - - -``` - -Interroger les données du dictionnaire: - -``` sql -SELECT - name, - type, - key, - attribute.names, - attribute.types, - bytes_allocated, - element_count, - source -FROM system.dictionaries -WHERE name = 'products' -``` - -``` text -┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ -│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ -└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ -``` - -Vous pouvez utiliser l' [dictGet\*](../../../sql_reference/functions/ext_dict_functions.md#ext_dict_functions) fonction pour obtenir les données du dictionnaire dans ce format. - -Cette vue n'est pas utile lorsque vous avez besoin d'obtenir des données brutes ou `JOIN` opération. Pour ces cas, vous pouvez utiliser le `Dictionary` moteur, qui affiche les données du dictionnaire dans une table. - -Syntaxe: - -``` sql -CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` -``` - -Exemple d'utilisation: - -``` sql -create table products (product_id UInt64, title String) Engine = Dictionary(products); -``` - - Ok - -Jetez un oeil à ce qui est dans le tableau. - -``` sql -select * from products limit 1; -``` - -``` text -┌────product_id─┬─title───────────┐ -│ 152689 │ Some item │ -└───────────────┴─────────────────┘ -``` - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/fr/engines/table_engines/special/distributed.md b/docs/fr/engines/table_engines/special/distributed.md deleted file mode 100644 index 39ce3d72e3e..00000000000 --- a/docs/fr/engines/table_engines/special/distributed.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 33 -toc_title: "Distribu\xE9" ---- - -# Distribué {#distributed} - -**Les Tables avec moteur distribué ne stockent aucune donnée par elles mêmes**, mais autoriser le traitement des requêtes distribuées sur plusieurs serveurs. -La lecture est automatiquement parallélisée. Lors d'une lecture, les index de table sur les serveurs distants sont utilisés, s'il y en a. - -Le moteur distribué accepte les paramètres: - -- le nom du cluster dans le fichier de configuration du serveur - -- le nom d'une base de données distante - -- le nom d'une table distante - -- (en option) sharding clé - -- (éventuellement) nom de la stratégie, il sera utilisé pour stocker des fichiers temporaires pour l'envoi asynchrone - - Voir aussi: - - - `insert_distributed_sync` paramètre - - [MergeTree](../mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) pour les exemples - -Exemple: - -``` sql -Distributed(logs, default, hits[, sharding_key[, policy_name]]) -``` - -Les données seront lues à partir de tous les serveurs ‘logs’ cluster, à partir de la valeur par défaut.hits table située sur chaque serveur du cluster. -Les données ne sont pas seulement lues mais sont partiellement traitées sur les serveurs distants (dans la mesure du possible). -Par exemple, pour une requête avec GROUP BY, les données seront agrégées sur des serveurs distants et les états intermédiaires des fonctions d'agrégation seront envoyés au serveur demandeur. Ensuite, les données seront plus agrégées. - -Au lieu du nom de la base de données, vous pouvez utiliser une expression constante qui renvoie une chaîne. Par exemple: currentDatabase(). - -logs – The cluster name in the server's config file. - -Les Clusters sont définis comme ceci: - -``` xml - - - - - 1 - - false - - example01-01-1 - 9000 - - - example01-01-2 - 9000 - - - - 2 - false - - example01-02-1 - 9000 - - - example01-02-2 - 1 - 9440 - - - - -``` - -Ici un cluster est défini avec le nom ‘logs’ qui se compose de deux fragments, dont chacune contient deux répliques. -Les partitions se réfèrent aux serveurs qui contiennent différentes parties des données (pour lire toutes les données, vous devez accéder à tous les partitions). -Les répliques sont des serveurs de duplication (afin de lire toutes les données, vous pouvez accéder aux données sur l'une des répliques). - -Les noms de Cluster ne doivent pas contenir de points. - -Paramètre `host`, `port` et , éventuellement, `user`, `password`, `secure`, `compression` sont spécifiés pour chaque serveur: -- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. -- `port` – The TCP port for messenger activity (‘tcp\_port’ dans la configuration, généralement définie sur 9000). Ne le confondez pas avec http\_port. -- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Les droits d'accès](../../../operations/access_rights.md). -- `password` – The password for connecting to a remote server (not masked). Default value: empty string. -- `secure` - Utilisez ssl pour la connexion, généralement vous devez également définir `port` = 9440. Le serveur doit écouter 9440 et avoir des certificats corrects. -- `compression` - Utiliser la compression de données. Valeur par défaut: true. - -When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [équilibrage](../../../operations/settings/settings.md#settings-load_balancing) paramètre. -Si la connexion avec le serveur n'est pas établie, il y aura une tentative de connexion avec un court délai. Si la connexion échoue, la réplique suivante sera sélectionnée, et ainsi de suite pour toutes les répliques. Si la tentative de connexion a échoué pour toutes les répliques, la tentative sera répété de la même façon, plusieurs fois. -Cela fonctionne en faveur de la résilience, mais ne fournit pas de tolérance aux pannes complète: un serveur distant peut accepter la connexion, mais peut ne pas fonctionner ou fonctionner mal. - -Vous pouvez spécifier un seul des fragments (dans ce cas, le traitement de la requête doit être appelé distant, plutôt que distribué) ou jusqu'à un nombre quelconque de fragments. Dans chaque fragment, vous pouvez spécifier un nombre de répliques. Vous pouvez spécifier un nombre différent de répliques pour chaque fragment. - -Vous pouvez spécifier autant de clusters que vous souhaitez dans la configuration. - -Pour afficher vos clusters, utilisez ‘system.clusters’ table. - -Le moteur distribué permet de travailler avec un cluster comme un serveur local. Cependant, le cluster est inextensible: vous devez écrire sa configuration dans le fichier de configuration du serveur (encore mieux, pour tous les serveurs du cluster). - -The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the ‘remote’ fonction de table à la place. Voir la section [Les fonctions de Table](../../../sql_reference/table_functions/index.md). - -Il existe deux méthodes pour écrire des données dans un cluster: - -Tout d'abord, vous pouvez définir les serveurs d'écrire les données à et effectuer l'écriture directement sur chaque fragment. En d'autres termes, effectuez INSERT dans les tables que la table distribuée “looks at”. C'est la solution la plus flexible car vous pouvez utiliser n'importe quel schéma de sharding, qui pourrait être non trivial en raison des exigences du sujet. C'est également la solution la plus optimale puisque les données peuvent être écrites sur différents fragments de manière complètement indépendante. - -Deuxièmement, vous pouvez effectuer INSERT dans une table distribuée. Dans ce cas, la table distribuera les données insérées sur les serveurs eux-mêmes. Pour écrire dans une table distribuée, elle doit avoir un jeu de clés de sharding (le dernier paramètre). De plus, s'il n'y a qu'un seul fragment, l'opération d'écriture fonctionne sans spécifier la clé de sharding, car cela ne signifie rien dans ce cas. - -Chaque fragment peut avoir un poids défini dans le fichier de configuration. Par défaut, le poids est égal à un. Les données sont réparties entre les fragments dans la quantité proportionnelle au poids des fragments. Par exemple, si il y a deux tessons et le premier a un poids de 9 tandis que la seconde a un poids de 10, le premier sera envoyé 9 / 19 parties de lignes, et le second sera envoyé 10 / 19. - -Chaque fragment peut avoir le ‘internal\_replication’ paramètre défini dans le fichier de configuration. - -Si ce paramètre est défini à ‘true’, l'opération d'écriture sélectionne le premier saine réplique et écrit les données. Utilisez cette option si le tableau Distribué “looks at” tables répliquées. En d'autres termes, si la table où les données seront écrites va répliquer elle-même. - -Si elle est définie sur ‘false’ (par défaut), les données sont écrites dans toutes les répliques. En substance, cela signifie que la table distribuée réplique les données elle-même. C'est pire que d'utiliser des tables répliquées, car la cohérence des répliques n'est pas vérifiée et, au fil du temps, elles contiendront des données légèrement différentes. - -Pour sélectionner le fragment auquel une ligne de données est envoyée, l'expression de sharding est analysée et son reste est extrait de la diviser par le poids total des fragments. La ligne est envoyée au fragment qui correspond au demi-intervalle des restes de ‘prev\_weight’ de ‘prev\_weights + weight’, où ‘prev\_weights’ c'est le poids total des tessons avec le plus petit nombre, et ‘weight’ est le poids de cet éclat. Par exemple, s'il y a deux fragments, et que le premier a un poids de 9 tandis que le second a un poids de 10, la ligne sera envoyée au premier fragment pour les restes de la plage \[0, 9), et au second pour les restes de la plage \[9, 19). - -L'expression de sharding peut être n'importe quelle expression de constantes et de colonnes de table qui renvoie un entier. Par exemple, vous pouvez utiliser l'expression ‘rand()’ pour la distribution aléatoire des données, ou ‘UserID’ pour la distribution par le reste de la division de L'ID de l'utilisateur (alors les données d'un seul utilisateur résideront sur un seul fragment, ce qui simplifie l'exécution et la jointure par les utilisateurs). Si l'une des colonnes n'est pas assez répartie uniformément, vous pouvez l'envelopper dans une fonction de hachage: intHash64 (UserID). - -Un simple rappel de la division est une solution limitée pour le sharding et n'est pas toujours approprié. Cela fonctionne pour des volumes de données moyens et importants (des dizaines de serveurs), mais pas pour des volumes de données très importants (des centaines de serveurs ou plus). Dans ce dernier cas, utilisez le schéma de répartition requis par le domaine, plutôt que d'utiliser des entrées dans des tableaux distribués. - -SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. - -Vous devriez être préoccupé par le système de sharding dans les cas suivants: - -- Les requêtes sont utilisées qui nécessitent des données de jointure (IN ou JOIN) par une clé spécifique. Si les données sont partagées par cette clé, vous pouvez utiliser local in ou JOIN au lieu de GLOBAL IN ou global JOIN, ce qui est beaucoup plus efficace. -- Un grand nombre de serveurs est utilisé (des centaines ou plus) avec un grand nombre de petites requêtes (requêtes de clients individuels - sites Web, annonceurs ou partenaires). Pour que les petites requêtes n'affectent pas l'ensemble du cluster, il est logique de localiser les données d'un seul client sur un seul fragment. Alternativement, comme nous l'avons fait dans Yandex.Metrica, vous pouvez configurer le sharding à deux niveaux: divisez le cluster entier en “layers”, où une couche peut être constituée de plusieurs éclats. Les données d'un seul client sont situées sur une seule couche, mais des fragments peuvent être ajoutés à une couche si nécessaire, et les données sont distribuées aléatoirement à l'intérieur de celles-ci. Des tables distribuées sont créées pour chaque couche et une seule table distribuée partagée est créée pour les requêtes globales. - -Les données sont écrites de manière asynchrone. Lorsqu'il est inséré dans la table, le bloc de données est simplement écrit dans le système de fichiers local. Les données sont envoyées aux serveurs distants en arrière-plan dès que possible. La période d'envoi des données est gérée par [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) et [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) paramètre. Le `Distributed` moteur envoie chaque fichier de données insérées séparément, mais vous pouvez activer le lot envoi de fichiers avec l' [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) paramètre. Ce paramètre améliore les performances du cluster en utilisant mieux les ressources réseau et serveur local. Vous devriez vérifier si les données sont envoyées avec succès en vérifiant la liste des fichiers (données en attente d'envoi) dans le répertoire de la table: `/var/lib/clickhouse/data/database/table/`. - -Si le serveur a cessé d'exister ou a subi un redémarrage Brutal (par exemple, après une panne de périphérique) après une insertion dans une table distribuée, les données insérées peuvent être perdues. Si une partie de données endommagée est détectée dans le répertoire de la table, elle est transférée ‘broken’ sous-répertoire et n'est plus utilisé. - -Lorsque l'option max\_parallel\_replicas est activée, le traitement des requêtes est parallélisé entre toutes les répliques d'un seul fragment. Pour plus d'informations, consultez la section [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). - -## Les Colonnes Virtuelles {#virtual-columns} - -- `_shard_num` — Contains the `shard_num` (de `system.clusters`). Type: [UInt32](../../../sql_reference/data_types/int_uint.md). - -!!! note "Note" - Depuis [`remote`](../../../sql_reference/table_functions/remote.md)/`cluster` les fonctions de table créent en interne une instance temporaire du même moteur distribué, `_shard_num` est disponible là-bas aussi. - -**Voir Aussi** - -- [Les colonnes virtuelles](../index.md#table_engines-virtual_columns) - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/fr/engines/table_engines/special/external_data.md b/docs/fr/engines/table_engines/special/external_data.md deleted file mode 100644 index 2c1f1633e3e..00000000000 --- a/docs/fr/engines/table_engines/special/external_data.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 34 -toc_title: "De donn\xE9es externes" ---- - -# Données externes pour le traitement des requêtes {#external-data-for-query-processing} - -ClickHouse permet d'Envoyer à un serveur les données nécessaires au traitement d'une requête, ainsi qu'une requête SELECT. Ces données sont placées dans une table temporaire (voir la section “Temporary tables”) et peut être utilisé dans la requête (par exemple, dans les DANS les opérateurs). - -Par exemple, si vous disposez d'un fichier texte avec important des identifiants d'utilisateur, vous pouvez le télécharger sur le serveur avec une requête qui utilise la filtration par cette liste. - -Si vous devez exécuter plusieurs requêtes avec un volume important de données externes, n'utilisez pas cette fonctionnalité. Il est préférable de télécharger les données sur la base de données à l'avance. - -Les données externes peuvent être téléchargées à l'aide du client de ligne de commande (en mode non interactif) ou à l'aide de L'interface HTTP. - -Dans le client de ligne de commande, vous pouvez spécifier une section paramètres du format - -``` bash ---external --file=... [--name=...] [--format=...] [--types=...|--structure=...] -``` - -Vous pouvez avoir plusieurs sections comme ça, pour le nombre de tables étant transmis. - -**–external** – Marks the beginning of a clause. -**–file** – Path to the file with the table dump, or -, which refers to stdin. -Une seule table peut être récupérée à partir de stdin. - -Les paramètres suivants sont facultatifs: **–name**– Name of the table. If omitted, \_data is used. -**–format** – Data format in the file. If omitted, TabSeparated is used. - -L'un des paramètres suivants est requis:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … -**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Définit les noms et les types de colonnes. - -Les fichiers spécifiés dans ‘file’ sera analysé par le format spécifié dans ‘format’, en utilisant les types de données spécifié dans ‘types’ ou ‘structure’. La table sera téléchargée sur le serveur et accessible en tant que table temporaire avec le nom dans ‘name’. - -Exemple: - -``` bash -$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 -849897 -$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -Lors de l'utilisation de L'interface HTTP, les données externes sont transmises au format multipart/form-data. Chaque tableau est transmis en tant que fichier séparé. Le nom de la table est tiré du nom du fichier. Le ‘query\_string’ est passé les paramètres ‘name\_format’, ‘name\_types’, et ‘name\_structure’, où ‘name’ est le nom de la table que ces paramètres correspondent. La signification des paramètres est la même que lors de l'utilisation du client de ligne de commande. - -Exemple: - -``` bash -$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv - -$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -Pour le traitement des requêtes distribuées, les tables temporaires sont envoyées à tous les serveurs distants. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/fr/engines/table_engines/special/file.md b/docs/fr/engines/table_engines/special/file.md deleted file mode 100644 index c24444e09f2..00000000000 --- a/docs/fr/engines/table_engines/special/file.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 37 -toc_title: Fichier ---- - -# Fichier {#table_engines-file} - -Le moteur de table de fichiers conserve les données dans un fichier dans l'un des [fichier -format](../../../interfaces/formats.md#formats) (TabSeparated, Native, etc.). - -Exemples d'utilisation: - -- Exportation de données de ClickHouse vers un fichier. -- Convertir des données d'un format à un autre. -- Mise à jour des données dans ClickHouse via l'édition d'un fichier sur un disque. - -## Utilisation Dans Le Serveur Clickhouse {#usage-in-clickhouse-server} - -``` sql -File(Format) -``` - -Le `Format` paramètre spécifie l'un des formats de fichier disponibles. Effectuer -`SELECT` requêtes, le format doit être pris en charge pour l'entrée, et à effectuer -`INSERT` queries – for output. The available formats are listed in the -[Format](../../../interfaces/formats.md#formats) section. - -ClickHouse ne permet pas de spécifier le chemin du système de fichiers pour`File`. Il utilisera le dossier défini par [chemin](../../../operations/server_configuration_parameters/settings.md) réglage dans la configuration du serveur. - -Lors de la création de la table en utilisant `File(Format)` il crée sous-répertoire vide dans ce dossier. Lorsque les données sont écrites dans cette table, elles sont mises dans `data.Format` fichier dans ce répertoire. - -Vous pouvez créer manuellement ce sous dossier et ce fichier dans le système de fichiers [ATTACH](../../../sql_reference/statements/misc.md) il à la table des informations avec le nom correspondant, de sorte que vous pouvez interroger les données de ce fichier. - -!!! warning "Avertissement" - Soyez prudent avec cette fonctionnalité, car ClickHouse ne garde pas trace des modifications externes apportées à ces fichiers. Le résultat des Écritures simultanées via ClickHouse et en dehors de ClickHouse n'est pas défini. - -**Exemple:** - -**1.** Configurer le `file_engine_table` table: - -``` sql -CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) -``` - -Par défaut ClickHouse va créer un dossier `/var/lib/clickhouse/data/default/file_engine_table`. - -**2.** Créer manuellement `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` contenant: - -``` bash -$ cat data.TabSeparated -one 1 -two 2 -``` - -**3.** Interroger les données: - -``` sql -SELECT * FROM file_engine_table -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Utilisation dans Clickhouse-local {#usage-in-clickhouse-local} - -Dans [clickhouse-local](../../../operations/utilities/clickhouse-local.md) Fichier moteur accepte chemin d'accès au fichier en plus `Format`. Les flux d'entrée / sortie par défaut peuvent être spécifiés en utilisant des noms numériques ou lisibles par l'homme comme `0` ou `stdin`, `1` ou `stdout`. -**Exemple:** - -``` bash -$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" -``` - -## Les Détails De Mise En Œuvre {#details-of-implementation} - -- Plusieurs `SELECT` les requêtes peuvent être effectuées simultanément, mais `INSERT` requêtes s'attendre les uns les autres. -- Prise en charge de la création d'un nouveau fichier par `INSERT` requête. -- Si le fichier existe, `INSERT` ajouterait de nouvelles valeurs dedans. -- Pas pris en charge: - - `ALTER` - - `SELECT ... SAMPLE` - - Index - - Réplication - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/fr/engines/table_engines/special/generate.md b/docs/fr/engines/table_engines/special/generate.md deleted file mode 100644 index 43709c54af1..00000000000 --- a/docs/fr/engines/table_engines/special/generate.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 46 -toc_title: GenerateRandom ---- - -# Generaterandom {#table_engines-generate} - -Le moteur de table GenerateRandom produit des données aléatoires pour un schéma de table donné. - -Exemples d'utilisation: - -- Utiliser dans le test pour remplir une grande table reproductible. -- Générer une entrée aléatoire pour les tests de fuzzing. - -## Utilisation Dans Le Serveur Clickhouse {#usage-in-clickhouse-server} - -``` sql -ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) -``` - -Le `max_array_length` et `max_string_length` les paramètres spécifient la longueur maximale de tous -colonnes et chaînes de tableau en conséquence dans les données générées. - -Générer le moteur de table prend en charge uniquement `SELECT` requête. - -Il prend en charge tous les [Les types de données](../../../sql_reference/data_types/index.md) cela peut être stocké dans une table sauf `LowCardinality` et `AggregateFunction`. - -**Exemple:** - -**1.** Configurer le `generate_engine_table` table: - -``` sql -CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) -``` - -**2.** Interroger les données: - -``` sql -SELECT * FROM generate_engine_table LIMIT 3 -``` - -``` text -┌─name─┬──────value─┐ -│ c4xJ │ 1412771199 │ -│ r │ 1791099446 │ -│ 7#$ │ 124312908 │ -└──────┴────────────┘ -``` - -## Les Détails De Mise En Œuvre {#details-of-implementation} - -- Pas pris en charge: - - `ALTER` - - `SELECT ... SAMPLE` - - `INSERT` - - Index - - Réplication - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/fr/engines/table_engines/special/index.md b/docs/fr/engines/table_engines/special/index.md deleted file mode 100644 index 481be47314c..00000000000 --- a/docs/fr/engines/table_engines/special/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Special -toc_priority: 31 ---- - - diff --git a/docs/fr/engines/table_engines/special/join.md b/docs/fr/engines/table_engines/special/join.md deleted file mode 100644 index 946b9464cdb..00000000000 --- a/docs/fr/engines/table_engines/special/join.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 40 -toc_title: Rejoindre ---- - -# Rejoindre {#join} - -Structure de données préparée pour l'utilisation dans [JOIN](../../../sql_reference/statements/select.md#select-join) opérations. - -## Création d'une Table {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], -) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) -``` - -Voir la description détaillée de la [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) requête. - -**Les Paramètres Du Moteur** - -- `join_strictness` – [ADHÉRER à la rigueur](../../../sql_reference/statements/select.md#select-join-strictness). -- `join_type` – [Type de jointure](../../../sql_reference/statements/select.md#select-join-types). -- `k1[, k2, ...]` – Key columns from the `USING` la clause que l' `JOIN` l'opération est faite avec de la. - -Entrer `join_strictness` et `join_type` paramètres sans guillemets, par exemple, `Join(ANY, LEFT, col1)`. Ils doivent correspondre à la `JOIN` fonctionnement que le tableau sera utilisé pour. Si les paramètres ne correspondent pas, ClickHouse ne lance pas d'exception et peut renvoyer des données incorrectes. - -## Utilisation Du Tableau {#table-usage} - -### Exemple {#example} - -Création de la table de gauche: - -``` sql -CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog -``` - -``` sql -INSERT INTO id_val VALUES (1,11)(2,12)(3,13) -``` - -Création du côté droit `Join` table: - -``` sql -CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) -``` - -``` sql -INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) -``` - -Rejoindre les tables: - -``` sql -SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 -``` - -``` text -┌─id─┬─val─┬─id_val_join.val─┐ -│ 1 │ 11 │ 21 │ -│ 2 │ 12 │ ᴺᵁᴸᴸ │ -│ 3 │ 13 │ 23 │ -└────┴─────┴─────────────────┘ -``` - -Comme alternative, vous pouvez récupérer des données de la `Join` table, spécifiant la valeur de la clé de jointure: - -``` sql -SELECT joinGet('id_val_join', 'val', toUInt32(1)) -``` - -``` text -┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ -│ 21 │ -└────────────────────────────────────────────┘ -``` - -### Sélection et insertion de données {#selecting-and-inserting-data} - -Vous pouvez utiliser `INSERT` requêtes pour ajouter des données au `Join`-tables de moteur. Si la table a été créée avec `ANY` rigueur, les données pour les clés en double sont ignorées. Avec l' `ALL` rigueur, toutes les lignes sont ajoutées. - -Vous ne pouvez pas effectuer un `SELECT` requête directement à partir de la table. Au lieu de cela, utilisez l'une des méthodes suivantes: - -- Placez la table sur le côté droit dans un `JOIN` clause. -- Appelez le [joinGet](../../../sql_reference/functions/other_functions.md#joinget) fonction, qui vous permet d'extraire des données de la table de la même manière que d'un dictionnaire. - -### Limitations et paramètres {#join-limitations-and-settings} - -Lors de la création d'un tableau, les paramètres suivants sont appliqués: - -- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) -- [max\_rows\_in\_join](../../../operations/settings/query_complexity.md#settings-max_rows_in_join) -- [max\_bytes\_in\_join](../../../operations/settings/query_complexity.md#settings-max_bytes_in_join) -- [join\_overflow\_mode](../../../operations/settings/query_complexity.md#settings-join_overflow_mode) -- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) - -Le `Join`- les tables de moteur ne peuvent pas être utilisées dans `GLOBAL JOIN` opérations. - -Le `Join`-moteur permet d'utiliser [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) réglage de la `CREATE TABLE` déclaration. Et [SELECT](../../../sql_reference/statements/select.md) requête permet d'utiliser `join_use_nulls` trop. Si vous avez différents `join_use_nulls` paramètres, vous pouvez obtenir une table de jointure d'erreur. Il dépend de type de JOINTURE. Lorsque vous utilisez [joinGet](../../../sql_reference/functions/other_functions.md#joinget) fonction, vous devez utiliser le même `join_use_nulls` réglage en `CRATE TABLE` et `SELECT` déclaration. - -## Le Stockage De Données {#data-storage} - -`Join` les données de la table sont toujours situées dans la RAM. Lors de l'insertion de lignes dans une table, ClickHouse écrit des blocs de données dans le répertoire du disque afin qu'ils puissent être restaurés lorsque le serveur redémarre. - -Si le serveur redémarre incorrectement, le bloc de données sur le disque peut être perdu ou endommagé. Dans ce cas, vous devrez peut-être supprimer manuellement le fichier contenant des données endommagées. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/fr/engines/table_engines/special/materializedview.md b/docs/fr/engines/table_engines/special/materializedview.md deleted file mode 100644 index bd9177e7203..00000000000 --- a/docs/fr/engines/table_engines/special/materializedview.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 43 -toc_title: MaterializedView ---- - -# Materializedview {#materializedview} - -Utilisé pour implémenter des vues matérialisées (pour plus d'informations, voir [CREATE TABLE](../../../sql_reference/statements/create.md)). Pour stocker des données, il utilise un moteur différent qui a été spécifié lors de la création de la vue. Lors de la lecture d'une table, il utilise juste ce moteur. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/fr/engines/table_engines/special/memory.md b/docs/fr/engines/table_engines/special/memory.md deleted file mode 100644 index 4f8411188ee..00000000000 --- a/docs/fr/engines/table_engines/special/memory.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 44 -toc_title: "M\xE9moire" ---- - -# Mémoire {#memory} - -Le moteur de mémoire stocke les données en RAM, sous forme non compressée. Les données sont stockées exactement sous la même forme qu'elles sont reçues lors de la lecture. En d'autres termes, la lecture de ce tableau est entièrement gratuit. -L'accès aux données simultanées est synchronisé. Les verrous sont courts: les opérations de lecture et d'écriture ne se bloquent pas. -Les index ne sont pas pris en charge. La lecture est parallélisée. -La productivité maximale (plus de 10 Go / s) est atteinte sur les requêtes simples, car il n'y a pas de lecture à partir du disque, de décompression ou de désérialisation des données. (Il convient de noter que dans de nombreux cas, la productivité du moteur MergeTree est presque aussi élevée.) -Lors du redémarrage d'un serveur, les données disparaissent de la table et la table devient vide. -Normalement, l'utilisation de ce moteur de table n'est pas justifiée. Cependant, il peut être utilisé pour des tests, et pour des tâches où la vitesse maximale est requise sur un nombre relativement faible de lignes (jusqu'à environ 100 000 000). - -Le moteur de mémoire est utilisé par le système pour les tables temporaires avec des données de requête externes (voir la section “External data for processing a query”), et pour la mise en œuvre globale dans (voir la section “IN operators”). - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/fr/engines/table_engines/special/merge.md b/docs/fr/engines/table_engines/special/merge.md deleted file mode 100644 index 4f879c5e76e..00000000000 --- a/docs/fr/engines/table_engines/special/merge.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 36 -toc_title: Fusionner ---- - -# Fusionner {#merge} - -Le `Merge` moteur (à ne pas confondre avec `MergeTree`) ne stocke pas les données elles-mêmes, mais permet la lecture de n'importe quel nombre d'autres tables simultanément. -La lecture est automatiquement parallélisée. L'écriture dans une table n'est pas prise en charge. Lors de la lecture, les index des tables en cours de lecture sont utilisés, s'ils existent. -Le `Merge` engine accepte les paramètres: le nom de la base de données et une expression régulière pour les tables. - -Exemple: - -``` sql -Merge(hits, '^WatchLog') -``` - -Les données seront lues à partir des tableaux du `hits` base de données dont les noms correspondent à l'expression régulière ‘`^WatchLog`’. - -Au lieu du nom de la base de données, vous pouvez utiliser une expression constante qui renvoie une chaîne. Exemple, `currentDatabase()`. - -Regular expressions — [re2](https://github.com/google/re2) (prend en charge un sous-ensemble de PCRE), sensible à la casse. -Voir les notes sur les symboles d'échappement dans les expressions régulières “match” section. - -Lors de la sélection des tables à lire, le `Merge` le tableau lui-même ne sera pas choisie, même si elle correspond à l'expression rationnelle. C'est pour éviter les boucles. -Il est possible de créer deux `Merge` des tables qui essaieront sans cesse de lire les données des autres, mais ce n'est pas une bonne idée. - -L'utilisation traditionnelle de la `Merge` moteur pour travailler avec un grand nombre de `TinyLog` les tables comme si avec une seule table. - -Exemple 2: - -Disons que vous avez une ancienne table (WatchLog\_old) et que vous avez décidé de changer de partitionnement sans déplacer les données vers une nouvelle table (WatchLog\_new) et que vous devez voir les données des deux tables. - -``` sql -CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree(date, (UserId, EventType), 8192); -INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); - -CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; -INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); - -CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); - -SELECT * -FROM WatchLog -``` - -``` text -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-01 │ 1 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-02 │ 2 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -``` - -## Les Colonnes Virtuelles {#virtual-columns} - -- `_table` — Contains the name of the table from which data was read. Type: [Chaîne](../../../sql_reference/data_types/string.md). - - Vous pouvez définir les conditions constantes sur `_table` dans le `WHERE/PREWHERE` clause (par exemple, `WHERE _table='xyz'`). Dans ce cas l'opération de lecture est effectuée uniquement pour les tables où la condition sur `_table` est satisfaite, pour le `_table` colonne agit comme un index. - -**Voir Aussi** - -- [Les colonnes virtuelles](index.md#table_engines-virtual_columns) - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/fr/engines/table_engines/special/null.md b/docs/fr/engines/table_engines/special/null.md deleted file mode 100644 index 8122f91ae7c..00000000000 --- a/docs/fr/engines/table_engines/special/null.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 38 -toc_title: 'NULL' ---- - -# NULL {#null} - -Lors de l'écriture dans une table Null, Les données sont ignorées. Lors de la lecture à partir d'une table Null, la réponse est vide. - -Toutefois, vous pouvez créer une vue matérialisée sur une table Nuls. Ainsi, les données écrites dans la table finira dans la vue. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/fr/engines/table_engines/special/set.md b/docs/fr/engines/table_engines/special/set.md deleted file mode 100644 index 44b03fd89d4..00000000000 --- a/docs/fr/engines/table_engines/special/set.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 39 -toc_title: "D\xE9finir" ---- - -# Définir {#set} - -Un ensemble de données qui est toujours en RAM. Il est conçu pour être utilisé sur le côté droit de l'opérateur (voir la section “IN operators”). - -Vous pouvez utiliser INSERT pour insérer des données dans la table. De nouveaux éléments seront ajoutés à l'ensemble de données, tandis que les doublons seront ignorés. -Mais vous ne pouvez pas effectuer SELECT à partir de la table. La seule façon de récupérer des données est en l'utilisant dans la moitié droite de l'opérateur. - -Les données sont toujours situées dans la RAM. Pour INSERT, les blocs de données insérées sont également écrits dans le répertoire des tables sur le disque. Lors du démarrage du serveur, ces données sont chargées dans la RAM. En d'autres termes, après le redémarrage, les données restent en place. - -Pour un redémarrage brutal du serveur, le bloc de données sur le disque peut être perdu ou endommagé. Dans ce dernier cas, vous devrez peut-être supprimer manuellement le fichier contenant des données endommagées. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/fr/engines/table_engines/special/url.md b/docs/fr/engines/table_engines/special/url.md deleted file mode 100644 index a32c49a180c..00000000000 --- a/docs/fr/engines/table_engines/special/url.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 41 -toc_title: URL ---- - -# URL (URL, Format) {#table_engines-url} - -Gère les données sur un serveur HTTP / HTTPS distant. Ce moteur est similaire -à l' [Fichier](file.md) moteur. - -## Utilisation du moteur dans le serveur Clickhouse {#using-the-engine-in-the-clickhouse-server} - -Le `format` doit être celui que ClickHouse peut utiliser dans -`SELECT` les requêtes et, si nécessaire, en `INSERTs`. Pour la liste complète des formats pris en charge, voir -[Format](../../../interfaces/formats.md#formats). - -Le `URL` doit être conforme à la structure D'un Localisateur de ressources uniforme. L'URL spécifiée doit pointer vers un serveur -qui utilise le protocole HTTP ou HTTPS. Cela ne nécessite pas de -en-têtes supplémentaires pour obtenir une réponse du serveur. - -`INSERT` et `SELECT` les requêtes sont transformées en `POST` et `GET` demande, -respectivement. Pour le traitement `POST` demandes, le serveur distant doit prendre en charge -[Encodage de transfert en morceaux](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). - -Vous pouvez limiter le nombre maximal de sauts de redirection HTTP GET en utilisant [max\_http\_get\_redirects](../../../operations/settings/settings.md#setting-max_http_get_redirects) paramètre. - -**Exemple:** - -**1.** Créer un `url_engine_table` table sur le serveur : - -``` sql -CREATE TABLE url_engine_table (word String, value UInt64) -ENGINE=URL('http://127.0.0.1:12345/', CSV) -``` - -**2.** Créez un serveur HTTP de base à l'aide des outils Python 3 standard et -démarrer: - -``` python3 -from http.server import BaseHTTPRequestHandler, HTTPServer - -class CSVHTTPServer(BaseHTTPRequestHandler): - def do_GET(self): - self.send_response(200) - self.send_header('Content-type', 'text/csv') - self.end_headers() - - self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) - -if __name__ == "__main__": - server_address = ('127.0.0.1', 12345) - HTTPServer(server_address, CSVHTTPServer).serve_forever() -``` - -``` bash -$ python3 server.py -``` - -**3.** Les données de la demande: - -``` sql -SELECT * FROM url_engine_table -``` - -``` text -┌─word──┬─value─┐ -│ Hello │ 1 │ -│ World │ 2 │ -└───────┴───────┘ -``` - -## Les Détails De Mise En Œuvre {#details-of-implementation} - -- Les lectures et les écritures peuvent être parallèles -- Pas pris en charge: - - `ALTER` et `SELECT...SAMPLE` opérations. - - Index. - - Réplication. - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/fr/engines/table_engines/special/view.md b/docs/fr/engines/table_engines/special/view.md deleted file mode 100644 index 4898e7ba41f..00000000000 --- a/docs/fr/engines/table_engines/special/view.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 42 -toc_title: Vue ---- - -# Vue {#table_engines-view} - -Utilisé pour implémenter des vues (pour plus d'informations, voir `CREATE VIEW query`). Il ne stocke pas de données, mais stocke uniquement les `SELECT` requête. Lors de la lecture d'une table, il exécute cette requête (et supprime toutes les colonnes inutiles de la requête). - -[Article Original](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/fr/faq/general.md b/docs/fr/faq/general.md index d42e1432f99..bd2765be2d2 100644 --- a/docs/fr/faq/general.md +++ b/docs/fr/faq/general.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 78 toc_title: "Questions G\xE9n\xE9rales" --- @@ -29,7 +29,7 @@ NLS_LANG=RUSSIAN_RUSSIA.UTF8 ### Utilisation de la Clause INTO OUTFILE {#using-into-outfile-clause} -Ajouter un [INTO OUTFILE](../query_language/select/#into-outfile-clause) clause à votre requête. +Ajouter un [INTO OUTFILE](../sql-reference/statements/select/into-outfile.md#into-outfile-clause) clause à votre requête. Exemple: @@ -37,7 +37,7 @@ Exemple: SELECT * FROM table INTO OUTFILE 'file' ``` -Par défaut, ClickHouse utilise [TabSeparated](../interfaces/formats.md#tabseparated) format pour les données de sortie. Pour sélectionner le [format de données](../interfaces/formats.md), utiliser le [FORMAT de la clause](../query_language/select/#format-clause). +Par défaut, ClickHouse utilise [TabSeparated](../interfaces/formats.md#tabseparated) format pour les données de sortie. Pour sélectionner le [format de données](../interfaces/formats.md), utiliser le [FORMAT de la clause](../sql-reference/statements/select/format.md#format-clause). Exemple: @@ -47,7 +47,7 @@ SELECT * FROM table INTO OUTFILE 'file' FORMAT CSV ### Utilisation d'une Table de moteur de fichiers {#using-a-file-engine-table} -Voir [Fichier](../engines/table_engines/special/file.md). +Voir [Fichier](../engines/table-engines/special/file.md). ### Utilisation De La Redirection En Ligne De Commande {#using-command-line-redirection} diff --git a/docs/fr/faq/index.md b/docs/fr/faq/index.md index 062df2298ea..a44dbb31e89 100644 --- a/docs/fr/faq/index.md +++ b/docs/fr/faq/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: F.A.Q. toc_priority: 76 --- diff --git a/docs/fr/getting-started/example-datasets/amplab-benchmark.md b/docs/fr/getting-started/example-datasets/amplab-benchmark.md new file mode 100644 index 00000000000..066bd128ff6 --- /dev/null +++ b/docs/fr/getting-started/example-datasets/amplab-benchmark.md @@ -0,0 +1,129 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 17 +toc_title: AMPLab Big Data Benchmark +--- + +# AMPLab Big Data Benchmark {#amplab-big-data-benchmark} + +Tu vois https://amplab.cs.berkeley.edu/benchmark/ + +Inscrivez-vous pour un compte GRATUIT à https://aws.amazon.com. il nécessite une carte de crédit, e-mail et numéro de téléphone. Obtenir une nouvelle clé d'accès à https://console.aws.amazon.com/iam/home?nc2=h\_m\_sc\#security\_credential + +Exécutez ce qui suit dans la console: + +``` bash +$ sudo apt-get install s3cmd +$ mkdir tiny; cd tiny; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/tiny/ . +$ cd .. +$ mkdir 1node; cd 1node; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/1node/ . +$ cd .. +$ mkdir 5nodes; cd 5nodes; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . +$ cd .. +``` + +Exécutez les requêtes ClickHouse suivantes: + +``` sql +CREATE TABLE rankings_tiny +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_tiny +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); + +CREATE TABLE rankings_1node +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_1node +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); + +CREATE TABLE rankings_5nodes_on_single +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_5nodes_on_single +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); +``` + +Retournez à la console: + +``` bash +$ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done +$ for i in tiny/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_tiny FORMAT CSV"; done +$ for i in 1node/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_1node FORMAT CSV"; done +$ for i in 1node/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_1node FORMAT CSV"; done +$ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_5nodes_on_single FORMAT CSV"; done +$ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done +``` + +Requêtes pour obtenir des échantillons de données: + +``` sql +SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 + +SELECT substring(sourceIP, 1, 8), sum(adRevenue) FROM uservisits_1node GROUP BY substring(sourceIP, 1, 8) + +SELECT + sourceIP, + sum(adRevenue) AS totalRevenue, + avg(pageRank) AS pageRank +FROM rankings_1node ALL INNER JOIN +( + SELECT + sourceIP, + destinationURL AS pageURL, + adRevenue + FROM uservisits_1node + WHERE (visitDate > '1980-01-01') AND (visitDate < '1980-04-01') +) USING pageURL +GROUP BY sourceIP +ORDER BY totalRevenue DESC +LIMIT 1 +``` + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/amplab_benchmark/) diff --git a/docs/fr/getting-started/example-datasets/criteo.md b/docs/fr/getting-started/example-datasets/criteo.md new file mode 100644 index 00000000000..8b52390cdcf --- /dev/null +++ b/docs/fr/getting-started/example-datasets/criteo.md @@ -0,0 +1,81 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 19 +toc_title: "T\xE9raoctet click Logs de Criteo" +--- + +# Téraoctet de journaux de clics de Criteo {#terabyte-of-click-logs-from-criteo} + +Télécharger les données à partir de http://labs.criteo.com/downloads/download-terabyte-click-logs/ + +Créer une table pour importer le journal: + +``` sql +CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log +``` + +Télécharger les données: + +``` bash +$ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done +``` + +Créer une table pour les données converties: + +``` sql +CREATE TABLE criteo +( + date Date, + clicked UInt8, + int1 Int32, + int2 Int32, + int3 Int32, + int4 Int32, + int5 Int32, + int6 Int32, + int7 Int32, + int8 Int32, + int9 Int32, + int10 Int32, + int11 Int32, + int12 Int32, + int13 Int32, + icat1 UInt32, + icat2 UInt32, + icat3 UInt32, + icat4 UInt32, + icat5 UInt32, + icat6 UInt32, + icat7 UInt32, + icat8 UInt32, + icat9 UInt32, + icat10 UInt32, + icat11 UInt32, + icat12 UInt32, + icat13 UInt32, + icat14 UInt32, + icat15 UInt32, + icat16 UInt32, + icat17 UInt32, + icat18 UInt32, + icat19 UInt32, + icat20 UInt32, + icat21 UInt32, + icat22 UInt32, + icat23 UInt32, + icat24 UInt32, + icat25 UInt32, + icat26 UInt32 +) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192) +``` + +Transformez les données du journal brut et placez - les dans la deuxième table: + +``` sql +INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log; + +DROP TABLE criteo_log; +``` + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/criteo/) diff --git a/docs/fr/getting-started/example-datasets/index.md b/docs/fr/getting-started/example-datasets/index.md new file mode 100644 index 00000000000..03b2f15890b --- /dev/null +++ b/docs/fr/getting-started/example-datasets/index.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Exemple De Jeux De Donn\xE9es" +toc_priority: 12 +toc_title: Introduction +--- + +# Exemple De Jeux De Données {#example-datasets} + +Cette section décrit comment obtenir des exemples de jeux de données et les importer dans ClickHouse. +Pour certains ensembles de données exemple les requêtes sont également disponibles. + +- [Yandex Anonymisé.Metrica Dataset](metrica.md) +- [Référence Du Schéma En Étoile](star-schema.md) +- [WikiStat](wikistat.md) +- [Téraoctet de journaux de clics de Criteo](criteo.md) +- [AMPLab Big Data Benchmark](amplab-benchmark.md) +- [New York Taxi Données](nyc-taxi.md) +- [OnTime](ontime.md) + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/fr/getting-started/example-datasets/metrica.md b/docs/fr/getting-started/example-datasets/metrica.md new file mode 100644 index 00000000000..6cc8f93b1c2 --- /dev/null +++ b/docs/fr/getting-started/example-datasets/metrica.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 14 +toc_title: "Yandex.Metrica De Donn\xE9es" +--- + +# Yandex Anonymisé.Metrica De Données {#anonymized-yandex-metrica-data} + +Dataset se compose de deux tables contenant des données anonymisées sur les hits (`hits_v1`) et les visites (`visits_v1`) de Yandex.Metrica. Vous pouvez en savoir plus sur Yandex.Metrica dans [Histoire de ClickHouse](../../introduction/history.md) section. + +L'ensemble de données se compose de deux tables, l'une d'elles peut être téléchargée sous forme compressée `tsv.xz` fichier ou comme partitions préparées. En outre, une version étendue de l' `hits` table contenant 100 millions de lignes est disponible comme TSV à https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits\_100m\_obfuscated\_v1.tsv.xz et comme partitions préparées à https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits\_100m\_obfuscated\_v1.tar.xz. + +## Obtention de Tables à partir de Partitions préparées {#obtaining-tables-from-prepared-partitions} + +Télécharger et importer la table hits: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar +tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Télécharger et importer des visites: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar +tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Obtention de Tables à partir D'un fichier TSV compressé {#obtaining-tables-from-compressed-tsv-file} + +Télécharger et importer des hits à partir du fichier TSV compressé: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Télécharger et importer des visites à partir du fichier TSV compressé: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Exemple De Requêtes {#example-queries} + +[Tutoriel ClickHouse](../../getting-started/tutorial.md) est basé sur Yandex.Metrica dataset et la façon recommandée pour commencer avec cet ensemble de données est de simplement passer par tutoriel. + +D'autres exemples de requêtes pour ces tables peuvent être trouvés parmi [tests avec État](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) de ClickHouse (ils sont nommés `test.hists` et `test.visits` y). diff --git a/docs/fr/getting-started/example-datasets/nyc-taxi.md b/docs/fr/getting-started/example-datasets/nyc-taxi.md new file mode 100644 index 00000000000..92818ac9d3f --- /dev/null +++ b/docs/fr/getting-started/example-datasets/nyc-taxi.md @@ -0,0 +1,390 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 16 +toc_title: "New York Taxi Donn\xE9es" +--- + +# New York Taxi Données {#new-york-taxi-data} + +Ce jeu de données peut être obtenu de deux façons: + +- importation à partir de données brutes +- téléchargement de partitions + +## Comment importer les données brutes {#how-to-import-the-raw-data} + +Tu vois https://github.com/toddwschneider/nyc-taxi-data et http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html pour la description d'un ensemble de données et les instructions de téléchargement. + +Le téléchargement entraînera environ 227 Go de données non compressées dans des fichiers CSV. Le téléchargement prend environ une heure sur une connexion 1 Gbit (téléchargement parallèle depuis s3.amazonaws.com récupère au moins la moitié d'un canal 1 Gbit). +Certains fichiers peuvent ne pas télécharger entièrement. Vérifiez la taille des fichiers et re-télécharger tout ce qui semble douteux. + +Certains fichiers peuvent contenir des lignes invalides. Vous pouvez les corriger comme suit: + +``` bash +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ +mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv +mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv +``` + +Ensuite, les données doivent être pré-traitées dans PostgreSQL. Cela créera des sélections de points dans les polygones (pour faire correspondre les points sur la carte avec les arrondissements de New York) et combinera toutes les données en une seule table plate dénormalisée à l'aide d'une jointure. Pour ce faire, vous devrez installer PostgreSQL avec le support PostGIS. + +Soyez prudent lors de l'exécution `initialize_database.sh` et vérifiez à nouveau manuellement que toutes les tables ont été créées correctement. + +Il faut environ 20-30 minutes pour traiter la valeur de chaque mois de données dans PostgreSQL, pour un total d'environ 48 heures. + +Vous pouvez vérifier le nombre de téléchargé lignes comme suit: + +``` bash +$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" +## Count + 1298979494 +(1 row) + +real 7m9.164s +``` + +(C'est un peu plus de 1,1 milliard de lignes rapportées par Mark Litwintschik dans une série de billets de blog.) + +Les données de PostgreSQL utilisent 370 GO d'espace. + +Exportation des données depuis PostgreSQL: + +``` sql +COPY +( + SELECT trips.id, + trips.vendor_id, + trips.pickup_datetime, + trips.dropoff_datetime, + trips.store_and_fwd_flag, + trips.rate_code_id, + trips.pickup_longitude, + trips.pickup_latitude, + trips.dropoff_longitude, + trips.dropoff_latitude, + trips.passenger_count, + trips.trip_distance, + trips.fare_amount, + trips.extra, + trips.mta_tax, + trips.tip_amount, + trips.tolls_amount, + trips.ehail_fee, + trips.improvement_surcharge, + trips.total_amount, + trips.payment_type, + trips.trip_type, + trips.pickup, + trips.dropoff, + + cab_types.type cab_type, + + weather.precipitation_tenths_of_mm rain, + weather.snow_depth_mm, + weather.snowfall_mm, + weather.max_temperature_tenths_degrees_celsius max_temp, + weather.min_temperature_tenths_degrees_celsius min_temp, + weather.average_wind_speed_tenths_of_meters_per_second wind, + + pick_up.gid pickup_nyct2010_gid, + pick_up.ctlabel pickup_ctlabel, + pick_up.borocode pickup_borocode, + pick_up.boroname pickup_boroname, + pick_up.ct2010 pickup_ct2010, + pick_up.boroct2010 pickup_boroct2010, + pick_up.cdeligibil pickup_cdeligibil, + pick_up.ntacode pickup_ntacode, + pick_up.ntaname pickup_ntaname, + pick_up.puma pickup_puma, + + drop_off.gid dropoff_nyct2010_gid, + drop_off.ctlabel dropoff_ctlabel, + drop_off.borocode dropoff_borocode, + drop_off.boroname dropoff_boroname, + drop_off.ct2010 dropoff_ct2010, + drop_off.boroct2010 dropoff_boroct2010, + drop_off.cdeligibil dropoff_cdeligibil, + drop_off.ntacode dropoff_ntacode, + drop_off.ntaname dropoff_ntaname, + drop_off.puma dropoff_puma + FROM trips + LEFT JOIN cab_types + ON trips.cab_type_id = cab_types.id + LEFT JOIN central_park_weather_observations_raw weather + ON weather.date = trips.pickup_datetime::date + LEFT JOIN nyct2010 pick_up + ON pick_up.gid = trips.pickup_nyct2010_gid + LEFT JOIN nyct2010 drop_off + ON drop_off.gid = trips.dropoff_nyct2010_gid +) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; +``` + +L'instantané de données est créé à une vitesse d'environ 50 Mo par seconde. Lors de la création de l'instantané, PostgreSQL lit à partir du disque à une vitesse d'environ 28 Mo par seconde. +Cela prend environ 5 heures. Le fichier TSV résultant est 590612904969 octets. + +Créer une table temporaire dans ClickHouse: + +``` sql +CREATE TABLE trips +( +trip_id UInt32, +vendor_id String, +pickup_datetime DateTime, +dropoff_datetime Nullable(DateTime), +store_and_fwd_flag Nullable(FixedString(1)), +rate_code_id Nullable(UInt8), +pickup_longitude Nullable(Float64), +pickup_latitude Nullable(Float64), +dropoff_longitude Nullable(Float64), +dropoff_latitude Nullable(Float64), +passenger_count Nullable(UInt8), +trip_distance Nullable(Float64), +fare_amount Nullable(Float32), +extra Nullable(Float32), +mta_tax Nullable(Float32), +tip_amount Nullable(Float32), +tolls_amount Nullable(Float32), +ehail_fee Nullable(Float32), +improvement_surcharge Nullable(Float32), +total_amount Nullable(Float32), +payment_type Nullable(String), +trip_type Nullable(UInt8), +pickup Nullable(String), +dropoff Nullable(String), +cab_type Nullable(String), +precipitation Nullable(UInt8), +snow_depth Nullable(UInt8), +snowfall Nullable(UInt8), +max_temperature Nullable(UInt8), +min_temperature Nullable(UInt8), +average_wind_speed Nullable(UInt8), +pickup_nyct2010_gid Nullable(UInt8), +pickup_ctlabel Nullable(String), +pickup_borocode Nullable(UInt8), +pickup_boroname Nullable(String), +pickup_ct2010 Nullable(String), +pickup_boroct2010 Nullable(String), +pickup_cdeligibil Nullable(FixedString(1)), +pickup_ntacode Nullable(String), +pickup_ntaname Nullable(String), +pickup_puma Nullable(String), +dropoff_nyct2010_gid Nullable(UInt8), +dropoff_ctlabel Nullable(String), +dropoff_borocode Nullable(UInt8), +dropoff_boroname Nullable(String), +dropoff_ct2010 Nullable(String), +dropoff_boroct2010 Nullable(String), +dropoff_cdeligibil Nullable(String), +dropoff_ntacode Nullable(String), +dropoff_ntaname Nullable(String), +dropoff_puma Nullable(String) +) ENGINE = Log; +``` + +Il est nécessaire pour convertir les champs en types de données plus corrects et, si possible, pour éliminer les valeurs Null. + +``` bash +$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv + +real 75m56.214s +``` + +Les données sont lues à une vitesse de 112-140 Mo/seconde. +Le chargement de données dans une table de type de journal dans un flux a pris 76 minutes. +Les données de ce tableau utilisent 142 GO. + +(L'importation de données directement depuis Postgres est également possible en utilisant `COPY ... TO PROGRAM`.) + +Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. + +Pour commencer, nous allons créer une table sur un serveur unique. Plus tard, nous ferons le tableau distribué. + +Créer et remplir un tableau récapitulatif: + +``` sql +CREATE TABLE trips_mergetree +ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +AS SELECT + +trip_id, +CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, +toDate(pickup_datetime) AS pickup_date, +ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, +toDate(dropoff_datetime) AS dropoff_date, +ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, +assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, +assumeNotNull(rate_code_id) AS rate_code_id, +assumeNotNull(pickup_longitude) AS pickup_longitude, +assumeNotNull(pickup_latitude) AS pickup_latitude, +assumeNotNull(dropoff_longitude) AS dropoff_longitude, +assumeNotNull(dropoff_latitude) AS dropoff_latitude, +assumeNotNull(passenger_count) AS passenger_count, +assumeNotNull(trip_distance) AS trip_distance, +assumeNotNull(fare_amount) AS fare_amount, +assumeNotNull(extra) AS extra, +assumeNotNull(mta_tax) AS mta_tax, +assumeNotNull(tip_amount) AS tip_amount, +assumeNotNull(tolls_amount) AS tolls_amount, +assumeNotNull(ehail_fee) AS ehail_fee, +assumeNotNull(improvement_surcharge) AS improvement_surcharge, +assumeNotNull(total_amount) AS total_amount, +CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, +assumeNotNull(trip_type) AS trip_type, +ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, +ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, +CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, + +assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, +toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, +assumeNotNull(pickup_borocode) AS pickup_borocode, +CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, +toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, +toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, +CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, +toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, + +CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, + +toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, + +assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, +toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, +assumeNotNull(dropoff_borocode) AS dropoff_borocode, +CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, +toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, +toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, +CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, +toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, + +CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, + +toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma + +FROM trips +``` + +Cela prend 3030 secondes à une vitesse d'environ 428 000 lignes par seconde. +Pour le charger plus rapidement, vous pouvez créer la table avec le `Log` le moteur de `MergeTree`. Dans ce cas, le téléchargement fonctionne plus rapidement que 200 secondes. + +La table utilise 126 GO d'espace disque. + +``` sql +SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active +``` + +``` text +┌─formatReadableSize(sum(bytes))─┐ +│ 126.18 GiB │ +└────────────────────────────────┘ +``` + +Entre autres choses, vous pouvez exécuter la requête OPTIMIZE sur MergeTree. Mais ce n'est pas nécessaire puisque tout ira bien sans elle. + +## Téléchargement des Partitions préparées {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar +$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" +``` + +!!! info "Info" + Si vous exécutez les requêtes décrites ci-dessous, vous devez utiliser le nom complet de la table, `datasets.trips_mergetree`. + +## Résultats sur un seul serveur {#results-on-single-server} + +Q1: + +``` sql +SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type +``` + +0.490 secondes. + +Q2: + +``` sql +SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count +``` + +1.224 secondes. + +Q3: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year +``` + +2.104 secondes. + +Q4: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) +FROM trips_mergetree +GROUP BY passenger_count, year, distance +ORDER BY year, count(*) DESC +``` + +3.593 secondes. + +Le serveur suivant a été utilisé: + +Deux Intel (R) Xeon (R) CPU E5-2650 v2 @ 2.60 GHz, 16 noyaux physiques total, 128 GiB RAM, 8x6 TB HD sur le matériel RAID-5 + +Temps d'exécution est le meilleur des trois pistes. Mais à partir de la deuxième exécution, les requêtes lisent les données du cache du système de fichiers. Aucune autre mise en cache ne se produit: les données sont lues et traitées à chaque exécution. + +La création d'un tableau sur trois serveurs: + +Sur chaque serveur: + +``` sql +CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +``` + +Sur le serveur source: + +``` sql +CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) +``` + +La requête suivante redistribue les données: + +``` sql +INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree +``` + +Cela prend 2454 secondes. + +Sur les trois serveurs: + +Q1: 0.212 secondes. +Q2: 0.438 secondes. +Q3: 0.733 secondes. +Q4: 1.241 secondes. + +Pas de surprise ici, depuis les requêtes sont réparties linéairement. + +Nous avons également les résultats d'un cluster de 140 serveurs: + +Q1: 0,028 sec. +Q2: 0,043 sec. +Q3: 0,051 sec. +Q4: 0,072 sec. + +Dans ce cas, le temps de traitement des requêtes est déterminé surtout par la latence du réseau. +Nous avons exécuté des requêtes en utilisant un client situé dans un centre de données Yandex en Finlande sur un cluster en Russie, ce qui a ajouté environ 20 ms de latence. + +## Résumé {#summary} + +| serveur | Q1 | Q2 | Q3 | Q4 | +|---------|-------|-------|-------|-------| +| 1 | 0.490 | 1.224 | 2.104 | 3.593 | +| 3 | 0.212 | 0.438 | 0.733 | 1.241 | +| 140 | 0.028 | 0.043 | 0.051 | 0.072 | + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/fr/getting-started/example-datasets/ontime.md b/docs/fr/getting-started/example-datasets/ontime.md new file mode 100644 index 00000000000..4040e2a1900 --- /dev/null +++ b/docs/fr/getting-started/example-datasets/ontime.md @@ -0,0 +1,412 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 15 +toc_title: OnTime +--- + +# OnTime {#ontime} + +Ce jeu de données peut être obtenu de deux façons: + +- importation à partir de données brutes +- téléchargement de partitions + +## Importation à partir de données brutes {#import-from-raw-data} + +Téléchargement de données: + +``` bash +for s in `seq 1987 2018` +do +for m in `seq 1 12` +do +wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip +done +done +``` + +(à partir de https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) + +Création d'une table: + +``` sql +CREATE TABLE `ontime` ( + `Year` UInt16, + `Quarter` UInt8, + `Month` UInt8, + `DayofMonth` UInt8, + `DayOfWeek` UInt8, + `FlightDate` Date, + `UniqueCarrier` FixedString(7), + `AirlineID` Int32, + `Carrier` FixedString(2), + `TailNum` String, + `FlightNum` String, + `OriginAirportID` Int32, + `OriginAirportSeqID` Int32, + `OriginCityMarketID` Int32, + `Origin` FixedString(5), + `OriginCityName` String, + `OriginState` FixedString(2), + `OriginStateFips` String, + `OriginStateName` String, + `OriginWac` Int32, + `DestAirportID` Int32, + `DestAirportSeqID` Int32, + `DestCityMarketID` Int32, + `Dest` FixedString(5), + `DestCityName` String, + `DestState` FixedString(2), + `DestStateFips` String, + `DestStateName` String, + `DestWac` Int32, + `CRSDepTime` Int32, + `DepTime` Int32, + `DepDelay` Int32, + `DepDelayMinutes` Int32, + `DepDel15` Int32, + `DepartureDelayGroups` String, + `DepTimeBlk` String, + `TaxiOut` Int32, + `WheelsOff` Int32, + `WheelsOn` Int32, + `TaxiIn` Int32, + `CRSArrTime` Int32, + `ArrTime` Int32, + `ArrDelay` Int32, + `ArrDelayMinutes` Int32, + `ArrDel15` Int32, + `ArrivalDelayGroups` Int32, + `ArrTimeBlk` String, + `Cancelled` UInt8, + `CancellationCode` FixedString(1), + `Diverted` UInt8, + `CRSElapsedTime` Int32, + `ActualElapsedTime` Int32, + `AirTime` Int32, + `Flights` Int32, + `Distance` Int32, + `DistanceGroup` UInt8, + `CarrierDelay` Int32, + `WeatherDelay` Int32, + `NASDelay` Int32, + `SecurityDelay` Int32, + `LateAircraftDelay` Int32, + `FirstDepTime` String, + `TotalAddGTime` String, + `LongestAddGTime` String, + `DivAirportLandings` String, + `DivReachedDest` String, + `DivActualElapsedTime` String, + `DivArrDelay` String, + `DivDistance` String, + `Div1Airport` String, + `Div1AirportID` Int32, + `Div1AirportSeqID` Int32, + `Div1WheelsOn` String, + `Div1TotalGTime` String, + `Div1LongestGTime` String, + `Div1WheelsOff` String, + `Div1TailNum` String, + `Div2Airport` String, + `Div2AirportID` Int32, + `Div2AirportSeqID` Int32, + `Div2WheelsOn` String, + `Div2TotalGTime` String, + `Div2LongestGTime` String, + `Div2WheelsOff` String, + `Div2TailNum` String, + `Div3Airport` String, + `Div3AirportID` Int32, + `Div3AirportSeqID` Int32, + `Div3WheelsOn` String, + `Div3TotalGTime` String, + `Div3LongestGTime` String, + `Div3WheelsOff` String, + `Div3TailNum` String, + `Div4Airport` String, + `Div4AirportID` Int32, + `Div4AirportSeqID` Int32, + `Div4WheelsOn` String, + `Div4TotalGTime` String, + `Div4LongestGTime` String, + `Div4WheelsOff` String, + `Div4TailNum` String, + `Div5Airport` String, + `Div5AirportID` Int32, + `Div5AirportSeqID` Int32, + `Div5WheelsOn` String, + `Div5TotalGTime` String, + `Div5LongestGTime` String, + `Div5WheelsOff` String, + `Div5TailNum` String +) ENGINE = MergeTree +PARTITION BY Year +ORDER BY (Carrier, FlightDate) +SETTINGS index_granularity = 8192; +``` + +Le chargement des données: + +``` bash +$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done +``` + +## Téléchargement des Partitions préparées {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar +$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.ontime" +``` + +!!! info "Info" + Si vous exécutez les requêtes décrites ci-dessous, vous devez utiliser le nom complet de la table, `datasets.ontime`. + +## Requête {#queries} + +Q0. + +``` sql +SELECT avg(c1) +FROM +( + SELECT Year, Month, count(*) AS c1 + FROM ontime + GROUP BY Year, Month +); +``` + +T1. Le nombre de vols par jour de l'année 2000 à 2008 + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +T2. Le nombre de vols retardés de plus de 10 minutes, regroupés par jour de la semaine, pour 2000-2008 + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +T3. Le nombre de retards par l'aéroport pour 2000-2008 + +``` sql +SELECT Origin, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY Origin +ORDER BY c DESC +LIMIT 10; +``` + +T4. Nombre de retards par transporteur pour 2007 + +``` sql +SELECT Carrier, count(*) +FROM ontime +WHERE DepDelay>10 AND Year=2007 +GROUP BY Carrier +ORDER BY count(*) DESC; +``` + +Q5. Pourcentage de retards par transporteur pour 2007 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year=2007 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year=2007 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Meilleure version de la même requête: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year=2007 +GROUP BY Carrier +ORDER BY c3 DESC +``` + +Q6. La demande précédente pour une plus large gamme d'années, 2000-2008 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year>=2000 AND Year<=2008 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year>=2000 AND Year<=2008 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Meilleure version de la même requête: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY Carrier +ORDER BY c3 DESC; +``` + +Q7. Pourcentage de vols retardés de plus de 10 minutes, par année + +``` sql +SELECT Year, c1/c2 +FROM +( + select + Year, + count(*)*100 as c1 + from ontime + WHERE DepDelay>10 + GROUP BY Year +) +JOIN +( + select + Year, + count(*) as c2 + from ontime + GROUP BY Year +) USING (Year) +ORDER BY Year; +``` + +Meilleure version de la même requête: + +``` sql +SELECT Year, avg(DepDelay>10)*100 +FROM ontime +GROUP BY Year +ORDER BY Year; +``` + +Q8. Les destinations les plus populaires par le nombre de villes directement connectées pour différentes plages d'années + +``` sql +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +WHERE Year >= 2000 and Year <= 2010 +GROUP BY DestCityName +ORDER BY u DESC LIMIT 10; +``` + +Q9. + +``` sql +SELECT Year, count(*) AS c1 +FROM ontime +GROUP BY Year; +``` + +Q10. + +``` sql +SELECT + min(Year), max(Year), Carrier, count(*) AS cnt, + sum(ArrDelayMinutes>30) AS flights_delayed, + round(sum(ArrDelayMinutes>30)/count(*),2) AS rate +FROM ontime +WHERE + DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') + AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') + AND FlightDate < '2010-01-01' +GROUP by Carrier +HAVING cnt>100000 and max(Year)>1990 +ORDER by rate DESC +LIMIT 1000; +``` + +Bonus: + +``` sql +SELECT avg(cnt) +FROM +( + SELECT Year,Month,count(*) AS cnt + FROM ontime + WHERE DepDel15=1 + GROUP BY Year,Month +); + +SELECT avg(c1) FROM +( + SELECT Year,Month,count(*) AS c1 + FROM ontime + GROUP BY Year,Month +); + +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +GROUP BY DestCityName +ORDER BY u DESC +LIMIT 10; + +SELECT OriginCityName, DestCityName, count() AS c +FROM ontime +GROUP BY OriginCityName, DestCityName +ORDER BY c DESC +LIMIT 10; + +SELECT OriginCityName, count() AS c +FROM ontime +GROUP BY OriginCityName +ORDER BY c DESC +LIMIT 10; +``` + +Ce test de performance a été créé par Vadim Tkachenko. Voir: + +- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ +- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ +- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ +- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ +- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ +- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/fr/getting-started/example-datasets/star-schema.md b/docs/fr/getting-started/example-datasets/star-schema.md new file mode 100644 index 00000000000..6a32faaa357 --- /dev/null +++ b/docs/fr/getting-started/example-datasets/star-schema.md @@ -0,0 +1,370 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 20 +toc_title: "R\xE9f\xE9rence Du Sch\xE9ma En \xC9toile" +--- + +# Référence Du Schéma En Étoile {#star-schema-benchmark} + +Compilation de dbgen: + +``` bash +$ git clone git@github.com:vadimtk/ssb-dbgen.git +$ cd ssb-dbgen +$ make +``` + +La production de données: + +!!! warning "Attention" + Avec `-s 100` dbgen génère 600 millions de lignes (67 Go), tandis que while `-s 1000` il génère 6 milliards de lignes (ce qui prend beaucoup de temps) + +``` bash +$ ./dbgen -s 1000 -T c +$ ./dbgen -s 1000 -T l +$ ./dbgen -s 1000 -T p +$ ./dbgen -s 1000 -T s +$ ./dbgen -s 1000 -T d +``` + +Création de tables dans ClickHouse: + +``` sql +CREATE TABLE customer +( + C_CUSTKEY UInt32, + C_NAME String, + C_ADDRESS String, + C_CITY LowCardinality(String), + C_NATION LowCardinality(String), + C_REGION LowCardinality(String), + C_PHONE String, + C_MKTSEGMENT LowCardinality(String) +) +ENGINE = MergeTree ORDER BY (C_CUSTKEY); + +CREATE TABLE lineorder +( + LO_ORDERKEY UInt32, + LO_LINENUMBER UInt8, + LO_CUSTKEY UInt32, + LO_PARTKEY UInt32, + LO_SUPPKEY UInt32, + LO_ORDERDATE Date, + LO_ORDERPRIORITY LowCardinality(String), + LO_SHIPPRIORITY UInt8, + LO_QUANTITY UInt8, + LO_EXTENDEDPRICE UInt32, + LO_ORDTOTALPRICE UInt32, + LO_DISCOUNT UInt8, + LO_REVENUE UInt32, + LO_SUPPLYCOST UInt32, + LO_TAX UInt8, + LO_COMMITDATE Date, + LO_SHIPMODE LowCardinality(String) +) +ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY); + +CREATE TABLE part +( + P_PARTKEY UInt32, + P_NAME String, + P_MFGR LowCardinality(String), + P_CATEGORY LowCardinality(String), + P_BRAND LowCardinality(String), + P_COLOR LowCardinality(String), + P_TYPE LowCardinality(String), + P_SIZE UInt8, + P_CONTAINER LowCardinality(String) +) +ENGINE = MergeTree ORDER BY P_PARTKEY; + +CREATE TABLE supplier +( + S_SUPPKEY UInt32, + S_NAME String, + S_ADDRESS String, + S_CITY LowCardinality(String), + S_NATION LowCardinality(String), + S_REGION LowCardinality(String), + S_PHONE String +) +ENGINE = MergeTree ORDER BY S_SUPPKEY; +``` + +Insertion de données: + +``` bash +$ clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl +$ clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl +$ clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl +$ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl +``` + +Conversion “star schema” pour dénormalisée “flat schema”: + +``` sql +SET max_memory_usage = 20000000000; + +CREATE TABLE lineorder_flat +ENGINE = MergeTree +PARTITION BY toYear(LO_ORDERDATE) +ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS +SELECT + l.LO_ORDERKEY AS LO_ORDERKEY, + l.LO_LINENUMBER AS LO_LINENUMBER, + l.LO_CUSTKEY AS LO_CUSTKEY, + l.LO_PARTKEY AS LO_PARTKEY, + l.LO_SUPPKEY AS LO_SUPPKEY, + l.LO_ORDERDATE AS LO_ORDERDATE, + l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY, + l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY, + l.LO_QUANTITY AS LO_QUANTITY, + l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE, + l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE, + l.LO_DISCOUNT AS LO_DISCOUNT, + l.LO_REVENUE AS LO_REVENUE, + l.LO_SUPPLYCOST AS LO_SUPPLYCOST, + l.LO_TAX AS LO_TAX, + l.LO_COMMITDATE AS LO_COMMITDATE, + l.LO_SHIPMODE AS LO_SHIPMODE, + c.C_NAME AS C_NAME, + c.C_ADDRESS AS C_ADDRESS, + c.C_CITY AS C_CITY, + c.C_NATION AS C_NATION, + c.C_REGION AS C_REGION, + c.C_PHONE AS C_PHONE, + c.C_MKTSEGMENT AS C_MKTSEGMENT, + s.S_NAME AS S_NAME, + s.S_ADDRESS AS S_ADDRESS, + s.S_CITY AS S_CITY, + s.S_NATION AS S_NATION, + s.S_REGION AS S_REGION, + s.S_PHONE AS S_PHONE, + p.P_NAME AS P_NAME, + p.P_MFGR AS P_MFGR, + p.P_CATEGORY AS P_CATEGORY, + p.P_BRAND AS P_BRAND, + p.P_COLOR AS P_COLOR, + p.P_TYPE AS P_TYPE, + p.P_SIZE AS P_SIZE, + p.P_CONTAINER AS P_CONTAINER +FROM lineorder AS l +INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY +INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY +INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; +``` + +Exécution des requêtes: + +Q1.1 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toYear(LO_ORDERDATE) = 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25; +``` + +Q1.2 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toYYYYMM(LO_ORDERDATE) = 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35; +``` + +Q1.3 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toISOWeek(LO_ORDERDATE) = 6 AND toYear(LO_ORDERDATE) = 1994 + AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35; +``` + +Q2.1 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q2.2 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_BRAND >= 'MFGR#2221' AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q2.3 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q3.1 + +``` sql +SELECT + C_NATION, + S_NATION, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year >= 1992 AND year <= 1997 +GROUP BY + C_NATION, + S_NATION, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.2 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE C_NATION = 'UNITED STATES' AND S_NATION = 'UNITED STATES' AND year >= 1992 AND year <= 1997 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.3 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND year >= 1992 AND year <= 1997 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.4 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND toYYYYMM(LO_ORDERDATE) = 199712 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q4.1 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + C_NATION, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') +GROUP BY + year, + C_NATION +ORDER BY + year ASC, + C_NATION ASC; +``` + +Q4.2 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + S_NATION, + P_CATEGORY, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year = 1997 OR year = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') +GROUP BY + year, + S_NATION, + P_CATEGORY +ORDER BY + year ASC, + S_NATION ASC, + P_CATEGORY ASC; +``` + +Q4.3 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + S_CITY, + P_BRAND, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE S_NATION = 'UNITED STATES' AND (year = 1997 OR year = 1998) AND P_CATEGORY = 'MFGR#14' +GROUP BY + year, + S_CITY, + P_BRAND +ORDER BY + year ASC, + S_CITY ASC, + P_BRAND ASC; +``` + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/star_schema/) diff --git a/docs/fr/getting-started/example-datasets/wikistat.md b/docs/fr/getting-started/example-datasets/wikistat.md new file mode 100644 index 00000000000..cecd5ef0728 --- /dev/null +++ b/docs/fr/getting-started/example-datasets/wikistat.md @@ -0,0 +1,35 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 18 +toc_title: WikiStat +--- + +# WikiStat {#wikistat} + +Voir: http://dumps.wikimedia.org/other/pagecounts-raw/ + +Création d'une table: + +``` sql +CREATE TABLE wikistat +( + date Date, + time DateTime, + project String, + subproject String, + path String, + hits UInt64, + size UInt64 +) ENGINE = MergeTree(date, (path, time), 8192); +``` + +Le chargement des données: + +``` bash +$ for i in {2007..2016}; do for j in {01..12}; do echo $i-$j >&2; curl -sSL "http://dumps.wikimedia.org/other/pagecounts-raw/$i/$i-$j/" | grep -oE 'pagecounts-[0-9]+-[0-9]+\.gz'; done; done | sort | uniq | tee links.txt +$ cat links.txt | while read link; do wget http://dumps.wikimedia.org/other/pagecounts-raw/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1/')/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1-\2/')/$link; done +$ ls -1 /opt/wikistat/ | grep gz | while read i; do echo $i; gzip -cd /opt/wikistat/$i | ./wikistat-loader --time="$(echo -n $i | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})\.gz/\1-\2-\3 \4-00-00/')" | clickhouse-client --query="INSERT INTO wikistat FORMAT TabSeparated"; done +``` + +[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/wikistat/) diff --git a/docs/fr/getting-started/index.md b/docs/fr/getting-started/index.md new file mode 100644 index 00000000000..3b90ff92b89 --- /dev/null +++ b/docs/fr/getting-started/index.md @@ -0,0 +1,17 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Prise En Main +toc_hidden: true +toc_priority: 8 +toc_title: "cach\xE9s" +--- + +# Prise En Main {#getting-started} + +Si vous êtes nouveau à ClickHouse et que vous voulez obtenir un sentiment pratique de sa performance, tout d'abord, vous devez passer par le [processus d'installation](install.md). Après cela, vous pouvez: + +- [Passez par tutoriel détaillé](tutorial.md) +- [Expérience avec des exemples de jeux de données](example-datasets/ontime.md) + +[Article Original](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/fr/getting-started/install.md b/docs/fr/getting-started/install.md new file mode 100644 index 00000000000..3659369fb4a --- /dev/null +++ b/docs/fr/getting-started/install.md @@ -0,0 +1,182 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 11 +toc_title: Installation +--- + +# Installation {#installation} + +## Configuration Système Requise {#system-requirements} + +ClickHouse peut fonctionner sur N'importe quel Linux, FreeBSD ou Mac OS X avec une architecture CPU x86\_64, AArch64 ou PowerPC64LE. + +Les binaires pré-construits officiels sont généralement compilés pour le jeu d'instructions x86\_64 et leverage SSE 4.2, donc sauf indication contraire, l'utilisation du processeur qui le prend en charge devient une exigence système supplémentaire. Voici la commande pour vérifier si le processeur actuel prend en charge SSE 4.2: + +``` bash +$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" +``` + +Pour exécuter ClickHouse sur des processeurs qui ne prennent pas en charge SSE 4.2 ou qui ont une architecture AArch64 ou PowerPC64LE, vous devez [construire ClickHouse à partir de sources](#from-sources) avec des ajustements de configuration appropriés. + +## Options D'Installation Disponibles {#available-installation-options} + +### À partir de paquets DEB {#install-from-deb-packages} + +Il est recommandé d'utiliser officiel pré-compilé `deb` Paquets Pour Debian ou Ubuntu. Exécutez ces commandes pour installer les paquets: + +``` bash +{% include 'install/deb.sh' %} +``` + +Si vous souhaitez utiliser la version la plus récente, remplacer `stable` avec `testing` (ceci est recommandé pour vos environnements de test). + +Vous pouvez également télécharger et installer des paquets manuellement à partir de [ici](https://repo.clickhouse.tech/deb/stable/main/). + +#### Paquet {#packages} + +- `clickhouse-common-static` — Installs ClickHouse compiled binary files. +- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` et installe la configuration du serveur par défaut. +- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` et d'autres outils. et installe les fichiers de configuration du client. +- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. + +### À partir de paquets RPM {#from-rpm-packages} + +Il est recommandé d'utiliser officiel pré-compilé `rpm` packages pour CentOS, RedHat et toutes les autres distributions Linux basées sur rpm. + +Tout d'abord, vous devez ajouter le dépôt officiel: + +``` bash +sudo yum install yum-utils +sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG +sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 +``` + +Si vous souhaitez utiliser la version la plus récente, remplacer `stable` avec `testing` (ceci est recommandé pour vos environnements de test). Le `prestable` la balise est parfois trop. + +Exécutez ensuite ces commandes pour installer les paquets: + +``` bash +sudo yum install clickhouse-server clickhouse-client +``` + +Vous pouvez également télécharger et installer des paquets manuellement à partir de [ici](https://repo.clickhouse.tech/rpm/stable/x86_64). + +### À Partir D'Archives Tgz {#from-tgz-archives} + +Il est recommandé d'utiliser officiel pré-compilé `tgz` archives pour toutes les distributions Linux, où l'installation de `deb` ou `rpm` les emballages n'est pas possible. + +La version requise peut être téléchargée avec `curl` ou `wget` depuis le référentiel https://repo.clickhouse.tech/tgz/. +Après cela, les archives téléchargées doivent être décompressées et installées avec des scripts d'installation. Exemple pour la dernière version: + +``` bash +export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz + +tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz +sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz +sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-server-$LATEST_VERSION.tgz +sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh +sudo /etc/init.d/clickhouse-server start + +tar -xzvf clickhouse-client-$LATEST_VERSION.tgz +sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh +``` + +Pour les environnements de production, il est recommandé d'utiliser la dernière `stable`-version. Vous pouvez trouver son numéro sur la page GitHub https://github.com/ClickHouse/ClickHouse/tags avec postfix `-stable`. + +### À Partir De L'Image Docker {#from-docker-image} + +Pour exécuter Clickhouse à L'intérieur Docker suivez le guide sur [Hub Docker](https://hub.docker.com/r/yandex/clickhouse-server/). Ces images utilisent officiel `deb` les paquets à l'intérieur. + +### À Partir De Sources {#from-sources} + +Pour compiler manuellement ClickHouse, suivez les instructions pour [Linux](../development/build.md) ou [Mac OS X](../development/build-osx.md). + +Vous pouvez compiler des paquets et les installer ou utiliser des programmes sans installer de paquets. En outre, en construisant manuellement, vous pouvez désactiver L'exigence SSE 4.2 ou construire pour les processeurs AArch64. + + Client: programs/clickhouse-client + Server: programs/clickhouse-server + +Vous devrez créer un dossier de données et de métadonnées et `chown` pour l'utilisateur souhaité. Leurs chemins peuvent être modifiés dans la configuration du serveur (src / programs / server / config.xml), par défaut, ils sont: + + /opt/clickhouse/data/default/ + /opt/clickhouse/metadata/default/ + +Sur Gentoo, vous pouvez simplement utiliser `emerge clickhouse` pour installer ClickHouse à partir de sources. + +## Lancer {#launch} + +Pour démarrer le serveur en tant que démon, exécutez: + +``` bash +$ sudo service clickhouse-server start +``` + +Si vous n'avez pas `service` commande, exécuter comme + +``` bash +$ sudo /etc/init.d/clickhouse-server start +``` + +Voir les journaux dans le `/var/log/clickhouse-server/` répertoire. + +Si le serveur ne démarre pas, vérifiez les configurations dans le fichier `/etc/clickhouse-server/config.xml`. + +Vous pouvez également lancer manuellement le serveur à partir de la console: + +``` bash +$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml +``` + +Dans ce cas, le journal sera imprimé sur la console, ce qui est pratique lors du développement. +Si le fichier de configuration se trouve dans le répertoire courant, vous n'avez pas besoin `--config-file` paramètre. Par défaut, il utilise `./config.xml`. + +ClickHouse prend en charge les paramètres de restriction d'accès. Ils sont situés dans la `users.xml` fichier (à côté de `config.xml`). +Par défaut, l'accès est autorisé depuis n'importe où pour `default` l'utilisateur, sans un mot de passe. Voir `user/default/networks`. +Pour plus d'informations, consultez la section [“Configuration Files”](../operations/configuration-files.md). + +Après le lancement du serveur, vous pouvez utiliser le client de ligne de commande pour vous y connecter: + +``` bash +$ clickhouse-client +``` + +Par défaut, il se connecte à `localhost:9000` au nom de l'utilisateur `default` sans un mot de passe. Il peut également être utilisé pour se connecter à un serveur distant en utilisant `--host` argument. + +Le terminal doit utiliser L'encodage UTF-8. +Pour plus d'informations, consultez la section [“Command-line client”](../interfaces/cli.md). + +Exemple: + +``` bash +$ ./clickhouse-client +ClickHouse client version 0.0.18749. +Connecting to localhost:9000. +Connected to ClickHouse server version 0.0.18749. + +:) SELECT 1 + +SELECT 1 + +┌─1─┐ +│ 1 │ +└───┘ + +1 rows in set. Elapsed: 0.003 sec. + +:) +``` + +**Félicitations, le système fonctionne!** + +Pour continuer à expérimenter, vous pouvez télécharger l'un des jeux de données de test ou passer par [tutoriel](https://clickhouse.tech/tutorial.html). + +[Article Original](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/fr/getting-started/playground.md b/docs/fr/getting-started/playground.md new file mode 100644 index 00000000000..6ddded13782 --- /dev/null +++ b/docs/fr/getting-started/playground.md @@ -0,0 +1,48 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 14 +toc_title: "R\xE9cr\xE9ation" +--- + +# Clickhouse Aire De Jeux {#clickhouse-playground} + +[Clickhouse Aire De Jeux](https://play.clickhouse.tech?file=welcome) permet aux utilisateurs d'expérimenter avec ClickHouse en exécutant des requêtes instantanément, sans configurer leur serveur ou leur cluster. +Plusieurs exemples de jeux de données sont disponibles dans le terrain de jeu ainsi que des exemples de requêtes qui montrent les fonctionnalités de ClickHouse. + +Les requêtes sont exécutées comme un utilisateur en lecture seule. Cela implique certaines limites: + +- Les requêtes DDL ne sont pas autorisées +- Les requêtes D'insertion ne sont pas autorisées + +Les paramètres suivants sont également appliquées: +- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) +- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) +- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) +- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) + +Clickhouse Playground donne l'expérience du m2.Petite +[Service géré pour ClickHouse](https://cloud.yandex.com/services/managed-clickhouse) +exemple hébergé dans [Yandex.Nuage](https://cloud.yandex.com/). +Plus d'informations sur [les fournisseurs de cloud](../commercial/cloud.md). + +Clickhouse Playground interface web fait des demandes via ClickHouse [HTTP API](../interfaces/http.md). +Le backend Playground est juste un cluster ClickHouse sans aucune application Côté Serveur supplémentaire. +ClickHouse HTTPS endpoint est également disponible dans le cadre du terrain de jeu. + +Vous pouvez effectuer des requêtes sur playground en utilisant n'importe quel client HTTP, par exemple [curl](https://curl.haxx.se) ou [wget](https://www.gnu.org/software/wget/), ou configurer une connexion en utilisant [JDBC](../interfaces/jdbc.md) ou [ODBC](../interfaces/odbc.md) pilote. +Plus d'informations sur les produits logiciels qui prennent en charge ClickHouse est disponible [ici](../interfaces/index.md). + +| Paramètre | Valeur | +|:-------------|:----------------------------------------------| +| Terminaison | https://play-api.clickhouse.technologie: 8443 | +| Utilisateur | `playground` | +| Mot de passe | `clickhouse` | + +Notez que ce paramètre nécessite une connexion sécurisée. + +Exemple: + +``` bash +curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" +``` diff --git a/docs/fr/getting-started/tutorial.md b/docs/fr/getting-started/tutorial.md new file mode 100644 index 00000000000..e8a0e8d81cb --- /dev/null +++ b/docs/fr/getting-started/tutorial.md @@ -0,0 +1,666 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 12 +toc_title: Tutoriel +--- + +# Tutoriel ClickHouse {#clickhouse-tutorial} + +## À quoi S'attendre de ce tutoriel? {#what-to-expect-from-this-tutorial} + +En parcourant ce tutoriel, vous apprendrez à configurer un cluster ClickHouse simple. Ce sera petit, mais tolérant aux pannes et évolutif. Ensuite, nous utiliserons l'un des exemples de jeux de données pour le remplir de données et exécuter des requêtes de démonstration. + +## Configuration De Noeud Unique {#single-node-setup} + +Pour retarder les complexités d'un environnement distribué, nous allons commencer par déployer ClickHouse sur un seul serveur ou une machine virtuelle. ClickHouse est généralement installé à partir de [deb](install.md#install-from-deb-packages) ou [tr / min](install.md#from-rpm-packages) les paquets, mais il y a [alternative](install.md#from-docker-image) pour les systèmes d'exploitation qui ne sont pas les soutenir. + +Par exemple, vous avez choisi `deb` paquets et exécutés: + +``` bash +{% include 'install/deb.sh' %} +``` + +Quelles sont les paquets installés: + +- `clickhouse-client` package contient [clickhouse-client](../interfaces/cli.md) application, client interactif de console de ClickHouse. +- `clickhouse-common` paquet contient un fichier exécutable ClickHouse. +- `clickhouse-server` package contient des fichiers de configuration pour exécuter ClickHouse en tant que serveur. + +Les fichiers de configuration du serveur sont `/etc/clickhouse-server/`. Avant d'aller plus loin, notez le `` élément `config.xml`. Path détermine l'emplacement pour le stockage des données, il doit donc être situé sur le volume avec une grande capacité de disque; la valeur par défaut est `/var/lib/clickhouse/`. Si vous souhaitez ajuster la configuration, il n'est pas pratique de modifier directement `config.xml` fichier, considérant qu'il pourrait obtenir réécrit sur les futures mises à jour du progiciel. La façon recommandée de remplacer les éléments de configuration est de créer [fichiers dans config.d: répertoire](../operations/configuration-files.md) qui servent de “patches” config.XML. + +Comme vous l'avez peut-être remarqué, `clickhouse-server` n'est pas lancé automatiquement après l'installation du paquet. Il ne sera pas redémarré automatiquement après les mises à jour, non plus. La façon dont vous démarrez le serveur dépend de votre système d'initialisation, généralement, c'est: + +``` bash +sudo service clickhouse-server start +``` + +ou + +``` bash +sudo /etc/init.d/clickhouse-server start +``` + +L'emplacement par défaut pour les journaux du serveur est `/var/log/clickhouse-server/`. Le serveur est prêt à gérer les connexions client une fois `Ready for connections` message. + +Une fois l' `clickhouse-server` est opérationnel, nous pouvons utiliser `clickhouse-client` pour se connecter au serveur et effectuer des tests de requêtes comme `SELECT "Hello, world!";`. + +
+ +Conseils rapides pour clickhouse-client + +Mode interactif: + +``` bash +clickhouse-client +clickhouse-client --host=... --port=... --user=... --password=... +``` + +Activer les requêtes multilignes: + +``` bash +clickhouse-client -m +clickhouse-client --multiline +``` + +Exécuter des requêtes en mode batch: + +``` bash +clickhouse-client --query='SELECT 1' +echo 'SELECT 1' | clickhouse-client +clickhouse-client <<< 'SELECT 1' +``` + +Insérer des données à partir d'un fichier au format spécifié: + +``` bash +clickhouse-client --query='INSERT INTO table VALUES' < data.txt +clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv +``` + +
+ +## Importer Un Échantillon De Données {#import-sample-dataset} + +Maintenant, il est temps de remplir notre serveur ClickHouse avec quelques exemples de données. Dans ce tutoriel, nous allons utiliser les données anonymisées de Yandex.Metrica, le premier service qui exécute ClickHouse en production avant de devenir open-source (plus à ce sujet dans [section d'histoire](../introduction/history.md)). Il y a [plusieurs façons d'importer Yandex.Metrica dataset](example-datasets/metrica.md), et pour le bien du tutoriel, nous irons avec le plus réaliste. + +### Télécharger et extraire les données de la Table {#download-and-extract-table-data} + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +``` + +Les fichiers extraits ont une taille d'environ 10 Go. + +### Créer Des Tables {#create-tables} + +Comme dans la plupart des systèmes de gestion de bases de données, clickhouse regroupe logiquement les tables en “databases”. Il y a un `default` base de données, mais nous allons en créer une nouvelle nommée `tutorial`: + +``` bash +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" +``` + +La syntaxe pour créer des tables est beaucoup plus compliquée par rapport aux bases de données (voir [référence](../sql-reference/statements/create.md). En général `CREATE TABLE` déclaration doit spécifier trois choses clés: + +1. Nom de la table à créer. +2. Table schema, i.e. list of columns and their [types de données](../sql-reference/data-types/index.md). +3. [Tableau moteur](../engines/table-engines/index.md) et ses paramètres, qui détermine tous les détails sur la façon dont les requêtes à cette table seront physiquement exécutées. + +Yandex.Metrica est un service d'analyse web, et l'exemple de jeu de données ne couvre pas toutes ses fonctionnalités, il n'y a donc que deux tables à créer: + +- `hits` est un tableau avec chaque action effectuée par tous les utilisateurs sur tous les sites couverts par le service. +- `visits` est une table qui contient des sessions pré-construites au lieu d'actions individuelles. + +Voyons et exécutons les vraies requêtes create table pour ces tables: + +``` sql +CREATE TABLE tutorial.hits_v1 +( + `WatchID` UInt64, + `JavaEnable` UInt8, + `Title` String, + `GoodEvent` Int16, + `EventTime` DateTime, + `EventDate` Date, + `CounterID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RegionID` UInt32, + `UserID` UInt64, + `CounterClass` Int8, + `OS` UInt8, + `UserAgent` UInt8, + `URL` String, + `Referer` String, + `URLDomain` String, + `RefererDomain` String, + `Refresh` UInt8, + `IsRobot` UInt8, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `FlashMinor2` String, + `NetMajor` UInt8, + `NetMinor` UInt8, + `UserAgentMajor` UInt16, + `UserAgentMinor` FixedString(2), + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `MobilePhone` UInt8, + `MobilePhoneModel` String, + `Params` String, + `IPNetworkID` UInt32, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `IsArtifical` UInt8, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `ClientTimeZone` Int16, + `ClientEventTime` DateTime, + `SilverlightVersion1` UInt8, + `SilverlightVersion2` UInt8, + `SilverlightVersion3` UInt32, + `SilverlightVersion4` UInt16, + `PageCharset` String, + `CodeVersion` UInt32, + `IsLink` UInt8, + `IsDownload` UInt8, + `IsNotBounce` UInt8, + `FUniqID` UInt64, + `HID` UInt32, + `IsOldCounter` UInt8, + `IsEvent` UInt8, + `IsParameter` UInt8, + `DontCountHits` UInt8, + `WithHash` UInt8, + `HitColor` FixedString(1), + `UTCEventTime` DateTime, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `WindowName` Int32, + `OpenerName` Int32, + `HistoryLength` Int16, + `BrowserLanguage` FixedString(2), + `BrowserCountry` FixedString(2), + `SocialNetwork` String, + `SocialAction` String, + `HTTPError` UInt16, + `SendTiming` Int32, + `DNSTiming` Int32, + `ConnectTiming` Int32, + `ResponseStartTiming` Int32, + `ResponseEndTiming` Int32, + `FetchTiming` Int32, + `RedirectTiming` Int32, + `DOMInteractiveTiming` Int32, + `DOMContentLoadedTiming` Int32, + `DOMCompleteTiming` Int32, + `LoadEventStartTiming` Int32, + `LoadEventEndTiming` Int32, + `NSToDOMContentLoadedTiming` Int32, + `FirstPaintTiming` Int32, + `RedirectCount` Int8, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `ParamPrice` Int64, + `ParamOrderID` String, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `GoalsReached` Array(UInt32), + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `RefererHash` UInt64, + `URLHash` UInt64, + `CLID` UInt32, + `YCLID` UInt64, + `ShareService` String, + `ShareURL` String, + `ShareTitle` String, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `IslandID` FixedString(16), + `RequestNum` UInt32, + `RequestTry` UInt8 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +``` sql +CREATE TABLE tutorial.visits_v1 +( + `CounterID` UInt32, + `StartDate` Date, + `Sign` Int8, + `IsNew` UInt8, + `VisitID` UInt64, + `UserID` UInt64, + `StartTime` DateTime, + `Duration` UInt32, + `UTCStartTime` DateTime, + `PageViews` Int32, + `Hits` Int32, + `IsBounce` UInt8, + `Referer` String, + `StartURL` String, + `RefererDomain` String, + `StartURLDomain` String, + `EndURL` String, + `LinkURL` String, + `IsDownload` UInt8, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `PlaceID` Int32, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `IsYandex` UInt8, + `GoalReachesDepth` Int32, + `GoalReachesURL` Int32, + `GoalReachesAny` Int32, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `MobilePhoneModel` String, + `ClientEventTime` DateTime, + `RegionID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `IPNetworkID` UInt32, + `SilverlightVersion3` UInt32, + `CodeVersion` UInt32, + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `UserAgentMajor` UInt16, + `UserAgentMinor` UInt16, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `SilverlightVersion2` UInt8, + `SilverlightVersion4` UInt16, + `FlashVersion3` UInt16, + `FlashVersion4` UInt16, + `ClientTimeZone` Int16, + `OS` UInt8, + `UserAgent` UInt8, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `NetMajor` UInt8, + `NetMinor` UInt8, + `MobilePhone` UInt8, + `SilverlightVersion1` UInt8, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `JavaEnable` UInt8, + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `BrowserLanguage` UInt16, + `BrowserCountry` UInt16, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `Params` Array(String), + `Goals` Nested( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32), + `WatchIDs` Array(UInt64), + `ParamSumPrice` Int64, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `ClickLogID` UInt64, + `ClickEventID` Int32, + `ClickGoodEvent` Int32, + `ClickEventTime` DateTime, + `ClickPriorityID` Int32, + `ClickPhraseID` Int32, + `ClickPageID` Int32, + `ClickPlaceID` Int32, + `ClickTypeID` Int32, + `ClickResourceID` Int32, + `ClickCost` UInt32, + `ClickClientIP` UInt32, + `ClickDomainID` UInt32, + `ClickURL` String, + `ClickAttempt` UInt8, + `ClickOrderID` UInt32, + `ClickBannerID` UInt32, + `ClickMarketCategoryID` UInt32, + `ClickMarketPP` UInt32, + `ClickMarketCategoryName` String, + `ClickMarketPPName` String, + `ClickAWAPSCampaignName` String, + `ClickPageName` String, + `ClickTargetType` UInt16, + `ClickTargetPhraseID` UInt64, + `ClickContextType` UInt8, + `ClickSelectType` Int8, + `ClickOptions` String, + `ClickGroupBannerID` Int32, + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `FirstVisit` DateTime, + `PredLastVisit` Date, + `LastVisit` Date, + `TotalVisits` UInt32, + `TraficSource` Nested( + ID Int8, + SearchEngineID UInt16, + AdvEngineID UInt8, + PlaceID UInt16, + SocialSourceNetworkID UInt8, + Domain String, + SearchPhrase String, + SocialSourcePage String), + `Attendance` FixedString(16), + `CLID` UInt32, + `YCLID` UInt64, + `NormalizedRefererHash` UInt64, + `SearchPhraseHash` UInt64, + `RefererDomainHash` UInt64, + `NormalizedStartURLHash` UInt64, + `StartURLDomainHash` UInt64, + `NormalizedEndURLHash` UInt64, + `TopLevelDomain` UInt64, + `URLScheme` UInt64, + `OpenstatServiceNameHash` UInt64, + `OpenstatCampaignIDHash` UInt64, + `OpenstatAdIDHash` UInt64, + `OpenstatSourceIDHash` UInt64, + `UTMSourceHash` UInt64, + `UTMMediumHash` UInt64, + `UTMCampaignHash` UInt64, + `UTMContentHash` UInt64, + `UTMTermHash` UInt64, + `FromHash` UInt64, + `WebVisorEnabled` UInt8, + `WebVisorActivity` UInt32, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `Market` Nested( + Type UInt8, + GoalID UInt32, + OrderID String, + OrderPrice Int64, + PP UInt32, + DirectPlaceID UInt32, + DirectOrderID UInt32, + DirectBannerID UInt32, + GoodID String, + GoodName String, + GoodQuantity Int32, + GoodPrice Int64), + `IslandID` FixedString(16) +) +ENGINE = CollapsingMergeTree(Sign) +PARTITION BY toYYYYMM(StartDate) +ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +Vous pouvez exécuter ces requêtes en utilisant le mode interactif de `clickhouse-client` (lancez - le simplement dans un terminal sans spécifier une requête à l'avance) ou essayez-en [interface de rechange](../interfaces/index.md) Si tu veux. + +Comme nous pouvons le voir, `hits_v1` utilise la [moteur MergeTree de base](../engines/table-engines/mergetree-family/mergetree.md) tandis que le `visits_v1` utilise la [Effondrer](../engines/table-engines/mergetree-family/collapsingmergetree.md) variante. + +### Importer Des Données {#import-data} + +L'importation de données vers ClickHouse se fait via [INSERT INTO](../sql-reference/statements/insert-into.md) requête comme dans de nombreuses autres bases de données SQL. Toutefois, les données sont généralement fournies dans l'une des [formats de sérialisation pris en charge](../interfaces/formats.md) plutôt `VALUES` clause (qui est également pris en charge). + +Les fichiers que nous avons téléchargés plus tôt sont au format séparé par des onglets, alors voici comment les importer via le client console: + +``` bash +clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv +clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv +``` + +ClickHouse a beaucoup de [les paramètres de tune](../operations/settings/index.md) et une façon de Les spécifier dans le client console est via des arguments, comme nous pouvons le voir avec `--max_insert_block_size`. La façon la plus simple de comprendre quels paramètres sont disponibles, que signifient-ils et quelles sont les valeurs par défaut est d'interroger le `system.settings` table: + +``` sql +SELECT name, value, changed, description +FROM system.settings +WHERE name LIKE '%max_insert_b%' +FORMAT TSV + +max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." +``` + +Optionnellement, vous pouvez [OPTIMIZE](../sql-reference/statements/misc.md#misc_operations-optimize) les tables après l'importation. Les Tables configurées avec un moteur de MergeTree-family font toujours des fusions de parties de données en arrière-plan pour optimiser le stockage des données (ou au moins vérifier si cela a du sens). Ces requêtes forcent le moteur de table à optimiser le stockage dès maintenant au lieu d'un certain temps plus tard: + +``` bash +clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" +clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" +``` + +Ces requêtes démarrent une opération intensive D'E/S et de CPU, donc si la table reçoit systématiquement de nouvelles données, il est préférable de la laisser seule et de laisser les fusions s'exécuter en arrière-plan. + +Maintenant, nous pouvons vérifier si l'importation de table a réussi: + +``` bash +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" +``` + +## Exemple De Requêtes {#example-queries} + +``` sql +SELECT + StartURL AS URL, + AVG(Duration) AS AvgDuration +FROM tutorial.visits_v1 +WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' +GROUP BY URL +ORDER BY AvgDuration DESC +LIMIT 10 +``` + +``` sql +SELECT + sum(Sign) AS visits, + sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, + (100. * goal_visits) / visits AS goal_percent +FROM tutorial.visits_v1 +WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') +``` + +## Déploiement De Cluster {#cluster-deployment} + +Clickhouse cluster est un cluster homogène. Étapes pour configurer: + +1. Installer clickhouse server sur toutes les machines du cluster +2. Configurer les configurations de cluster dans les fichiers de configuration +3. Créer des tables locales sur chaque instance +4. Créer un [Distribué table](../engines/table-engines/special/distributed.md) + +[Distribué table](../engines/table-engines/special/distributed.md) est en fait une sorte de “view” aux tables locales du cluster ClickHouse. SELECT query from a distributed table s'exécute à l'aide des ressources de tous les fragments du cluster. Vous pouvez spécifier des configurations pour plusieurs clusters et créer plusieurs tables distribuées fournissant des vues à différents clusters. + +Exemple de configuration pour un cluster avec trois fragments, une réplique chacun: + +``` xml + + + + + example-perftest01j.yandex.ru + 9000 + + + + + example-perftest02j.yandex.ru + 9000 + + + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +Pour plus de démonstration, créons une nouvelle table locale avec le même `CREATE TABLE` la requête que nous avons utilisé pour `hits_v1`, mais nom de table différent: + +``` sql +CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... +``` + +Création d'une table distribuée fournissant une vue dans les tables locales du cluster: + +``` sql +CREATE TABLE tutorial.hits_all AS tutorial.hits_local +ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); +``` + +Une pratique courante consiste à créer des tables distribuées similaires sur toutes les machines du cluster. Il permet d'exécuter des requêtes distribuées sur n'importe quelle machine du cluster. Il existe également une autre option pour créer une table distribuée temporaire pour une requête SELECT donnée en utilisant [distant](../sql-reference/table-functions/remote.md) table de fonction. + +Passons à l'exécution de [INSERT SELECT](../sql-reference/statements/insert-into.md) dans les Distribué table la table à plusieurs serveurs. + +``` sql +INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; +``` + +!!! warning "Avis" + Cette approche ne convient pas au sharding de grandes tables. Il y a un outil séparé [clickhouse-copieur](../operations/utilities/clickhouse-copier.md) cela peut re-fragmenter de grandes tables arbitraires. + +Comme vous pouvez vous y attendre, les requêtes lourdes de calcul s'exécutent N fois plus vite si elles utilisent 3 serveurs au lieu d'un. + +Dans ce cas, nous avons utilisé un cluster avec 3 fragments, et chacun contient une seule réplique. + +Pour assurer la résilience dans un environnement de production, nous recommandons que chaque fragment contienne 2-3 répliques réparties entre plusieurs zones de disponibilité ou centres de données (ou au moins des racks). Notez que ClickHouse prend en charge un nombre illimité de répliques. + +Exemple de configuration pour un cluster d'un fragment contenant trois répliques: + +``` xml + + ... + + + + example-perftest01j.yandex.ru + 9000 + + + example-perftest02j.yandex.ru + 9000 + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +Pour activer la réplication native [ZooKeeper](http://zookeeper.apache.org/) est requis. ClickHouse s'occupe de la cohérence des données sur toutes les répliques et exécute automatiquement la procédure de restauration après l'échec. Il est recommandé de déployer le cluster ZooKeeper sur des serveurs séparés (où aucun autre processus, y compris ClickHouse, n'est en cours d'exécution). + +!!! note "Note" + ZooKeeper est pas une exigence stricte: dans certains cas simples, vous pouvez dupliquer les données par écrit dans tous les réplicas de votre code d'application. Cette approche est **pas** recommandé, dans ce cas, ClickHouse ne sera pas en mesure de garantir la cohérence des données sur toutes les répliques. Ainsi, il devient la responsabilité de votre application. + +Les emplacements ZooKeeper sont spécifiés dans le fichier de configuration: + +``` xml + + + zoo01.yandex.ru + 2181 + + + zoo02.yandex.ru + 2181 + + + zoo03.yandex.ru + 2181 + + +``` + +En outre, nous devons définir des macros pour identifier chaque fragment et chaque réplique utilisés lors de la création de la table: + +``` xml + + 01 + 01 + +``` + +S'il n'y a pas de répliques pour le moment lors de la création de la table répliquée, une nouvelle première réplique est instanciée. S'il existe déjà des répliques en direct, la nouvelle réplique clone les données de celles existantes. Vous avez la possibilité de créer toutes les tables répliquées d'abord, et ensuite insérer les données. Une autre option consiste à créer des répliques et à en ajouter d'autres Après ou pendant l'insertion des données. + +``` sql +CREATE TABLE tutorial.hits_replica (...) +ENGINE = ReplcatedMergeTree( + '/clickhouse_perftest/tables/{shard}/hits', + '{replica}' +) +... +``` + +Ici, nous utilisons [ReplicatedMergeTree](../engines/table-engines/mergetree-family/replication.md) tableau moteur. Dans les paramètres, nous spécifions le chemin Zookeeper contenant des identificateurs de fragments et de répliques. + +``` sql +INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; +``` + +La réplication fonctionne en mode multi-maître. Les données peuvent être chargées dans n'importe quel réplica, et le système les synchronise ensuite automatiquement avec d'autres instances. La réplication est asynchrone, donc à un moment donné, toutes les répliques ne peuvent pas contenir de données récemment insérées. Au moins une réplique devrait être en place pour permettre l'ingestion de données. D'autres synchroniseront les données et répareront la cohérence une fois qu'ils redeviendront actifs. Notez que cette approche permet une faible possibilité de perte de données récemment insérées. + +[Article Original](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/fr/getting_started/example_datasets/amplab_benchmark.md b/docs/fr/getting_started/example_datasets/amplab_benchmark.md deleted file mode 100644 index 5e552480e01..00000000000 --- a/docs/fr/getting_started/example_datasets/amplab_benchmark.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 17 -toc_title: AMPLab Big Data Benchmark ---- - -# AMPLab Big Data Benchmark {#amplab-big-data-benchmark} - -Tu vois https://amplab.cs.berkeley.edu/benchmark/ - -Inscrivez-vous pour un compte GRATUIT à https://aws.amazon.com. il nécessite une carte de crédit, e-mail et numéro de téléphone. Obtenir une nouvelle clé d'accès à https://console.aws.amazon.com/iam/home?nc2=h\_m\_sc\#security\_credential - -Exécutez ce qui suit dans la console: - -``` bash -$ sudo apt-get install s3cmd -$ mkdir tiny; cd tiny; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/tiny/ . -$ cd .. -$ mkdir 1node; cd 1node; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/1node/ . -$ cd .. -$ mkdir 5nodes; cd 5nodes; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . -$ cd .. -``` - -Exécutez les requêtes ClickHouse suivantes: - -``` sql -CREATE TABLE rankings_tiny -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_tiny -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); - -CREATE TABLE rankings_1node -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_1node -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); - -CREATE TABLE rankings_5nodes_on_single -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_5nodes_on_single -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); -``` - -Retournez à la console: - -``` bash -$ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done -$ for i in tiny/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_tiny FORMAT CSV"; done -$ for i in 1node/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_1node FORMAT CSV"; done -$ for i in 1node/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_1node FORMAT CSV"; done -$ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_5nodes_on_single FORMAT CSV"; done -$ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done -``` - -Requêtes pour obtenir des échantillons de données: - -``` sql -SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 - -SELECT substring(sourceIP, 1, 8), sum(adRevenue) FROM uservisits_1node GROUP BY substring(sourceIP, 1, 8) - -SELECT - sourceIP, - sum(adRevenue) AS totalRevenue, - avg(pageRank) AS pageRank -FROM rankings_1node ALL INNER JOIN -( - SELECT - sourceIP, - destinationURL AS pageURL, - adRevenue - FROM uservisits_1node - WHERE (visitDate > '1980-01-01') AND (visitDate < '1980-04-01') -) USING pageURL -GROUP BY sourceIP -ORDER BY totalRevenue DESC -LIMIT 1 -``` - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/amplab_benchmark/) diff --git a/docs/fr/getting_started/example_datasets/criteo.md b/docs/fr/getting_started/example_datasets/criteo.md deleted file mode 100644 index 7669209d032..00000000000 --- a/docs/fr/getting_started/example_datasets/criteo.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 19 -toc_title: "T\xE9raoctet click Logs de Criteo" ---- - -# Téraoctet de journaux de clics de Criteo {#terabyte-of-click-logs-from-criteo} - -Télécharger les données à partir de http://labs.criteo.com/downloads/download-terabyte-click-logs/ - -Créer une table pour importer le journal: - -``` sql -CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log -``` - -Télécharger les données: - -``` bash -$ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done -``` - -Créer une table pour les données converties: - -``` sql -CREATE TABLE criteo -( - date Date, - clicked UInt8, - int1 Int32, - int2 Int32, - int3 Int32, - int4 Int32, - int5 Int32, - int6 Int32, - int7 Int32, - int8 Int32, - int9 Int32, - int10 Int32, - int11 Int32, - int12 Int32, - int13 Int32, - icat1 UInt32, - icat2 UInt32, - icat3 UInt32, - icat4 UInt32, - icat5 UInt32, - icat6 UInt32, - icat7 UInt32, - icat8 UInt32, - icat9 UInt32, - icat10 UInt32, - icat11 UInt32, - icat12 UInt32, - icat13 UInt32, - icat14 UInt32, - icat15 UInt32, - icat16 UInt32, - icat17 UInt32, - icat18 UInt32, - icat19 UInt32, - icat20 UInt32, - icat21 UInt32, - icat22 UInt32, - icat23 UInt32, - icat24 UInt32, - icat25 UInt32, - icat26 UInt32 -) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192) -``` - -Transformez les données du journal brut et placez - les dans la deuxième table: - -``` sql -INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log; - -DROP TABLE criteo_log; -``` - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/criteo/) diff --git a/docs/fr/getting_started/example_datasets/index.md b/docs/fr/getting_started/example_datasets/index.md deleted file mode 100644 index f3aaf473527..00000000000 --- a/docs/fr/getting_started/example_datasets/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Example Datasets -toc_priority: 12 -toc_title: Introduction ---- - -# Exemple De Jeux De Données {#example-datasets} - -Cette section décrit comment obtenir des exemples de jeux de données et les importer dans ClickHouse. -Pour certains ensembles de données exemple les requêtes sont également disponibles. - -- [Yandex Anonymisé.Metrica Dataset](metrica.md) -- [Référence Du Schéma En Étoile](star_schema.md) -- [WikiStat](wikistat.md) -- [Téraoctet de journaux de clics de Criteo](criteo.md) -- [AMPLab Big Data Benchmark](amplab_benchmark.md) -- [New York Taxi Données](nyc_taxi.md) -- [OnTime](ontime.md) - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/fr/getting_started/example_datasets/metrica.md b/docs/fr/getting_started/example_datasets/metrica.md deleted file mode 100644 index 7b148781e3a..00000000000 --- a/docs/fr/getting_started/example_datasets/metrica.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 21 -toc_title: "Yandex.Metrica De Donn\xE9es" ---- - -# Yandex Anonymisé.Metrica De Données {#anonymized-yandex-metrica-data} - -Dataset se compose de deux tables contenant des données anonymisées sur les hits (`hits_v1`) et les visites (`visits_v1`) de Yandex.Metrica. Vous pouvez en savoir plus sur Yandex.Metrica dans [Histoire de ClickHouse](../../introduction/history.md) section. - -L'ensemble de données se compose de deux tables, l'une d'elles peut être téléchargée sous forme compressée `tsv.xz` fichier ou comme partitions préparées. En outre, une version étendue de l' `hits` table contenant 100 millions de lignes est disponible comme TSV à https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits\_100m\_obfuscated\_v1.tsv.xz et comme partitions préparées à https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits\_100m\_obfuscated\_v1.tar.xz. - -## Obtention de Tables à partir de Partitions préparées {#obtaining-tables-from-prepared-partitions} - -Télécharger et importer la table hits: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar -tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Télécharger et importer des visites: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar -tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Obtention de Tables à partir D'un fichier TSV compressé {#obtaining-tables-from-compressed-tsv-file} - -Télécharger et importer des hits à partir du fichier TSV compressé: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Télécharger et importer des visites à partir du fichier TSV compressé: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Exemple De Requêtes {#example-queries} - -[Tutoriel ClickHouse](../../getting_started/tutorial.md) est basé sur Yandex.Metrica dataset et la façon recommandée pour commencer avec cet ensemble de données est de simplement passer par tutoriel. - -D'autres exemples de requêtes pour ces tables peuvent être trouvés parmi [tests avec État](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) de ClickHouse (ils sont nommés `test.hists` et `test.visits` y). diff --git a/docs/fr/getting_started/example_datasets/nyc_taxi.md b/docs/fr/getting_started/example_datasets/nyc_taxi.md deleted file mode 100644 index 6f002ecec9a..00000000000 --- a/docs/fr/getting_started/example_datasets/nyc_taxi.md +++ /dev/null @@ -1,390 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 16 -toc_title: "New York Taxi Donn\xE9es" ---- - -# New York Taxi Données {#new-york-taxi-data} - -Ce jeu de données peut être obtenu de deux façons: - -- importation à partir de données brutes -- téléchargement de partitions - -## Comment importer les données brutes {#how-to-import-the-raw-data} - -Tu vois https://github.com/toddwschneider/nyc-taxi-data et http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html pour la description d'un ensemble de données et les instructions de téléchargement. - -Le téléchargement entraînera environ 227 Go de données non compressées dans des fichiers CSV. Le téléchargement prend environ une heure sur une connexion 1 Gbit (téléchargement parallèle depuis s3.amazonaws.com récupère au moins la moitié d'un canal 1 Gbit). -Certains fichiers peuvent ne pas télécharger entièrement. Vérifiez la taille des fichiers et re-télécharger tout ce qui semble douteux. - -Certains fichiers peuvent contenir des lignes invalides. Vous pouvez les corriger comme suit: - -``` bash -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ -mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv -mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv -``` - -Ensuite, les données doivent être pré-traitées dans PostgreSQL. Cela créera des sélections de points dans les polygones (pour faire correspondre les points sur la carte avec les arrondissements de New York) et combinera toutes les données en une seule table plate dénormalisée à l'aide d'une jointure. Pour ce faire, vous devrez installer PostgreSQL avec le support PostGIS. - -Soyez prudent lors de l'exécution `initialize_database.sh` et vérifiez à nouveau manuellement que toutes les tables ont été créées correctement. - -Il faut environ 20-30 minutes pour traiter la valeur de chaque mois de données dans PostgreSQL, pour un total d'environ 48 heures. - -Vous pouvez vérifier le nombre de téléchargé lignes comme suit: - -``` bash -$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" -## Count - 1298979494 -(1 row) - -real 7m9.164s -``` - -(C'est un peu plus de 1,1 milliard de lignes rapportées par Mark Litwintschik dans une série de billets de blog.) - -Les données de PostgreSQL utilisent 370 GO d'espace. - -Exportation des données depuis PostgreSQL: - -``` sql -COPY -( - SELECT trips.id, - trips.vendor_id, - trips.pickup_datetime, - trips.dropoff_datetime, - trips.store_and_fwd_flag, - trips.rate_code_id, - trips.pickup_longitude, - trips.pickup_latitude, - trips.dropoff_longitude, - trips.dropoff_latitude, - trips.passenger_count, - trips.trip_distance, - trips.fare_amount, - trips.extra, - trips.mta_tax, - trips.tip_amount, - trips.tolls_amount, - trips.ehail_fee, - trips.improvement_surcharge, - trips.total_amount, - trips.payment_type, - trips.trip_type, - trips.pickup, - trips.dropoff, - - cab_types.type cab_type, - - weather.precipitation_tenths_of_mm rain, - weather.snow_depth_mm, - weather.snowfall_mm, - weather.max_temperature_tenths_degrees_celsius max_temp, - weather.min_temperature_tenths_degrees_celsius min_temp, - weather.average_wind_speed_tenths_of_meters_per_second wind, - - pick_up.gid pickup_nyct2010_gid, - pick_up.ctlabel pickup_ctlabel, - pick_up.borocode pickup_borocode, - pick_up.boroname pickup_boroname, - pick_up.ct2010 pickup_ct2010, - pick_up.boroct2010 pickup_boroct2010, - pick_up.cdeligibil pickup_cdeligibil, - pick_up.ntacode pickup_ntacode, - pick_up.ntaname pickup_ntaname, - pick_up.puma pickup_puma, - - drop_off.gid dropoff_nyct2010_gid, - drop_off.ctlabel dropoff_ctlabel, - drop_off.borocode dropoff_borocode, - drop_off.boroname dropoff_boroname, - drop_off.ct2010 dropoff_ct2010, - drop_off.boroct2010 dropoff_boroct2010, - drop_off.cdeligibil dropoff_cdeligibil, - drop_off.ntacode dropoff_ntacode, - drop_off.ntaname dropoff_ntaname, - drop_off.puma dropoff_puma - FROM trips - LEFT JOIN cab_types - ON trips.cab_type_id = cab_types.id - LEFT JOIN central_park_weather_observations_raw weather - ON weather.date = trips.pickup_datetime::date - LEFT JOIN nyct2010 pick_up - ON pick_up.gid = trips.pickup_nyct2010_gid - LEFT JOIN nyct2010 drop_off - ON drop_off.gid = trips.dropoff_nyct2010_gid -) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; -``` - -L'instantané de données est créé à une vitesse d'environ 50 Mo par seconde. Lors de la création de l'instantané, PostgreSQL lit à partir du disque à une vitesse d'environ 28 Mo par seconde. -Cela prend environ 5 heures. Le fichier TSV résultant est 590612904969 octets. - -Créer une table temporaire dans ClickHouse: - -``` sql -CREATE TABLE trips -( -trip_id UInt32, -vendor_id String, -pickup_datetime DateTime, -dropoff_datetime Nullable(DateTime), -store_and_fwd_flag Nullable(FixedString(1)), -rate_code_id Nullable(UInt8), -pickup_longitude Nullable(Float64), -pickup_latitude Nullable(Float64), -dropoff_longitude Nullable(Float64), -dropoff_latitude Nullable(Float64), -passenger_count Nullable(UInt8), -trip_distance Nullable(Float64), -fare_amount Nullable(Float32), -extra Nullable(Float32), -mta_tax Nullable(Float32), -tip_amount Nullable(Float32), -tolls_amount Nullable(Float32), -ehail_fee Nullable(Float32), -improvement_surcharge Nullable(Float32), -total_amount Nullable(Float32), -payment_type Nullable(String), -trip_type Nullable(UInt8), -pickup Nullable(String), -dropoff Nullable(String), -cab_type Nullable(String), -precipitation Nullable(UInt8), -snow_depth Nullable(UInt8), -snowfall Nullable(UInt8), -max_temperature Nullable(UInt8), -min_temperature Nullable(UInt8), -average_wind_speed Nullable(UInt8), -pickup_nyct2010_gid Nullable(UInt8), -pickup_ctlabel Nullable(String), -pickup_borocode Nullable(UInt8), -pickup_boroname Nullable(String), -pickup_ct2010 Nullable(String), -pickup_boroct2010 Nullable(String), -pickup_cdeligibil Nullable(FixedString(1)), -pickup_ntacode Nullable(String), -pickup_ntaname Nullable(String), -pickup_puma Nullable(String), -dropoff_nyct2010_gid Nullable(UInt8), -dropoff_ctlabel Nullable(String), -dropoff_borocode Nullable(UInt8), -dropoff_boroname Nullable(String), -dropoff_ct2010 Nullable(String), -dropoff_boroct2010 Nullable(String), -dropoff_cdeligibil Nullable(String), -dropoff_ntacode Nullable(String), -dropoff_ntaname Nullable(String), -dropoff_puma Nullable(String) -) ENGINE = Log; -``` - -Il est nécessaire pour convertir les champs en types de données plus corrects et, si possible, pour éliminer les valeurs Null. - -``` bash -$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv - -real 75m56.214s -``` - -Les données sont lues à une vitesse de 112-140 Mo/seconde. -Le chargement de données dans une table de type de journal dans un flux a pris 76 minutes. -Les données de ce tableau utilisent 142 GO. - -(L'importation de données directement depuis Postgres est également possible en utilisant `COPY ... TO PROGRAM`.) - -Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. - -Pour commencer, nous allons créer une table sur un serveur unique. Plus tard, nous ferons le tableau distribué. - -Créer et remplir un tableau récapitulatif: - -``` sql -CREATE TABLE trips_mergetree -ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -AS SELECT - -trip_id, -CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, -toDate(pickup_datetime) AS pickup_date, -ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, -toDate(dropoff_datetime) AS dropoff_date, -ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, -assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, -assumeNotNull(rate_code_id) AS rate_code_id, -assumeNotNull(pickup_longitude) AS pickup_longitude, -assumeNotNull(pickup_latitude) AS pickup_latitude, -assumeNotNull(dropoff_longitude) AS dropoff_longitude, -assumeNotNull(dropoff_latitude) AS dropoff_latitude, -assumeNotNull(passenger_count) AS passenger_count, -assumeNotNull(trip_distance) AS trip_distance, -assumeNotNull(fare_amount) AS fare_amount, -assumeNotNull(extra) AS extra, -assumeNotNull(mta_tax) AS mta_tax, -assumeNotNull(tip_amount) AS tip_amount, -assumeNotNull(tolls_amount) AS tolls_amount, -assumeNotNull(ehail_fee) AS ehail_fee, -assumeNotNull(improvement_surcharge) AS improvement_surcharge, -assumeNotNull(total_amount) AS total_amount, -CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, -assumeNotNull(trip_type) AS trip_type, -ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, -ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, -CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, - -assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, -toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, -assumeNotNull(pickup_borocode) AS pickup_borocode, -CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, -toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, -toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, -CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, -toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, - -CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, - -toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, - -assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, -toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, -assumeNotNull(dropoff_borocode) AS dropoff_borocode, -CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, -toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, -toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, -CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, -toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, - -CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, - -toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma - -FROM trips -``` - -Cela prend 3030 secondes à une vitesse d'environ 428 000 lignes par seconde. -Pour le charger plus rapidement, vous pouvez créer la table avec le `Log` le moteur de `MergeTree`. Dans ce cas, le téléchargement fonctionne plus rapidement que 200 secondes. - -La table utilise 126 GO d'espace disque. - -``` sql -SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active -``` - -``` text -┌─formatReadableSize(sum(bytes))─┐ -│ 126.18 GiB │ -└────────────────────────────────┘ -``` - -Entre autres choses, vous pouvez exécuter la requête OPTIMIZE sur MergeTree. Mais ce n'est pas nécessaire puisque tout ira bien sans elle. - -## Téléchargement des Partitions préparées {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar -$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" -``` - -!!! info "Info" - Si vous exécutez les requêtes décrites ci-dessous, vous devez utiliser le nom complet de la table, `datasets.trips_mergetree`. - -## Résultats sur un seul serveur {#results-on-single-server} - -Q1: - -``` sql -SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type -``` - -0.490 secondes. - -Q2: - -``` sql -SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count -``` - -1.224 secondes. - -Q3: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year -``` - -2.104 secondes. - -Q4: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) -FROM trips_mergetree -GROUP BY passenger_count, year, distance -ORDER BY year, count(*) DESC -``` - -3.593 secondes. - -Le serveur suivant a été utilisé: - -Deux Intel (R) Xeon (R) CPU E5-2650 v2 @ 2.60 GHz, 16 noyaux physiques total, 128 GiB RAM, 8x6 TB HD sur le matériel RAID-5 - -Temps d'exécution est le meilleur des trois pistes. Mais à partir de la deuxième exécution, les requêtes lisent les données du cache du système de fichiers. Aucune autre mise en cache ne se produit: les données sont lues et traitées à chaque exécution. - -La création d'un tableau sur trois serveurs: - -Sur chaque serveur: - -``` sql -CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -``` - -Sur le serveur source: - -``` sql -CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) -``` - -La requête suivante redistribue les données: - -``` sql -INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree -``` - -Cela prend 2454 secondes. - -Sur les trois serveurs: - -Q1: 0.212 secondes. -Q2: 0.438 secondes. -Q3: 0.733 secondes. -Q4: 1.241 secondes. - -Pas de surprise ici, depuis les requêtes sont réparties linéairement. - -Nous avons également les résultats d'un cluster de 140 serveurs: - -Q1: 0,028 sec. -Q2: 0,043 sec. -Q3: 0,051 sec. -Q4: 0,072 sec. - -Dans ce cas, le temps de traitement des requêtes est déterminé surtout par la latence du réseau. -Nous avons exécuté des requêtes en utilisant un client situé dans un centre de données Yandex en Finlande sur un cluster en Russie, ce qui a ajouté environ 20 ms de latence. - -## Résumé {#summary} - -| serveur | Q1 | Q2 | Q3 | Q4 | -|---------|-------|-------|-------|-------| -| 1 | 0.490 | 1.224 | 2.104 | 3.593 | -| 3 | 0.212 | 0.438 | 0.733 | 1.241 | -| 140 | 0.028 | 0.043 | 0.051 | 0.072 | - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/fr/getting_started/example_datasets/ontime.md b/docs/fr/getting_started/example_datasets/ontime.md deleted file mode 100644 index 2ee93d3d556..00000000000 --- a/docs/fr/getting_started/example_datasets/ontime.md +++ /dev/null @@ -1,412 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 15 -toc_title: OnTime ---- - -# OnTime {#ontime} - -Ce jeu de données peut être obtenu de deux façons: - -- importation à partir de données brutes -- téléchargement de partitions - -## Importation À Partir De Données Brutes {#import-from-raw-data} - -Téléchargement de données: - -``` bash -for s in `seq 1987 2018` -do -for m in `seq 1 12` -do -wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip -done -done -``` - -(à partir de https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) - -Création d'une table: - -``` sql -CREATE TABLE `ontime` ( - `Year` UInt16, - `Quarter` UInt8, - `Month` UInt8, - `DayofMonth` UInt8, - `DayOfWeek` UInt8, - `FlightDate` Date, - `UniqueCarrier` FixedString(7), - `AirlineID` Int32, - `Carrier` FixedString(2), - `TailNum` String, - `FlightNum` String, - `OriginAirportID` Int32, - `OriginAirportSeqID` Int32, - `OriginCityMarketID` Int32, - `Origin` FixedString(5), - `OriginCityName` String, - `OriginState` FixedString(2), - `OriginStateFips` String, - `OriginStateName` String, - `OriginWac` Int32, - `DestAirportID` Int32, - `DestAirportSeqID` Int32, - `DestCityMarketID` Int32, - `Dest` FixedString(5), - `DestCityName` String, - `DestState` FixedString(2), - `DestStateFips` String, - `DestStateName` String, - `DestWac` Int32, - `CRSDepTime` Int32, - `DepTime` Int32, - `DepDelay` Int32, - `DepDelayMinutes` Int32, - `DepDel15` Int32, - `DepartureDelayGroups` String, - `DepTimeBlk` String, - `TaxiOut` Int32, - `WheelsOff` Int32, - `WheelsOn` Int32, - `TaxiIn` Int32, - `CRSArrTime` Int32, - `ArrTime` Int32, - `ArrDelay` Int32, - `ArrDelayMinutes` Int32, - `ArrDel15` Int32, - `ArrivalDelayGroups` Int32, - `ArrTimeBlk` String, - `Cancelled` UInt8, - `CancellationCode` FixedString(1), - `Diverted` UInt8, - `CRSElapsedTime` Int32, - `ActualElapsedTime` Int32, - `AirTime` Int32, - `Flights` Int32, - `Distance` Int32, - `DistanceGroup` UInt8, - `CarrierDelay` Int32, - `WeatherDelay` Int32, - `NASDelay` Int32, - `SecurityDelay` Int32, - `LateAircraftDelay` Int32, - `FirstDepTime` String, - `TotalAddGTime` String, - `LongestAddGTime` String, - `DivAirportLandings` String, - `DivReachedDest` String, - `DivActualElapsedTime` String, - `DivArrDelay` String, - `DivDistance` String, - `Div1Airport` String, - `Div1AirportID` Int32, - `Div1AirportSeqID` Int32, - `Div1WheelsOn` String, - `Div1TotalGTime` String, - `Div1LongestGTime` String, - `Div1WheelsOff` String, - `Div1TailNum` String, - `Div2Airport` String, - `Div2AirportID` Int32, - `Div2AirportSeqID` Int32, - `Div2WheelsOn` String, - `Div2TotalGTime` String, - `Div2LongestGTime` String, - `Div2WheelsOff` String, - `Div2TailNum` String, - `Div3Airport` String, - `Div3AirportID` Int32, - `Div3AirportSeqID` Int32, - `Div3WheelsOn` String, - `Div3TotalGTime` String, - `Div3LongestGTime` String, - `Div3WheelsOff` String, - `Div3TailNum` String, - `Div4Airport` String, - `Div4AirportID` Int32, - `Div4AirportSeqID` Int32, - `Div4WheelsOn` String, - `Div4TotalGTime` String, - `Div4LongestGTime` String, - `Div4WheelsOff` String, - `Div4TailNum` String, - `Div5Airport` String, - `Div5AirportID` Int32, - `Div5AirportSeqID` Int32, - `Div5WheelsOn` String, - `Div5TotalGTime` String, - `Div5LongestGTime` String, - `Div5WheelsOff` String, - `Div5TailNum` String -) ENGINE = MergeTree -PARTITION BY Year -ORDER BY (Carrier, FlightDate) -SETTINGS index_granularity = 8192; -``` - -Le chargement des données: - -``` bash -$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done -``` - -## Téléchargement des Partitions préparées {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar -$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.ontime" -``` - -!!! info "Info" - Si vous exécutez les requêtes décrites ci-dessous, vous devez utiliser le nom complet de la table, `datasets.ontime`. - -## Requête {#queries} - -Q0. - -``` sql -SELECT avg(c1) -FROM -( - SELECT Year, Month, count(*) AS c1 - FROM ontime - GROUP BY Year, Month -); -``` - -T1. Le nombre de vols par jour de l'année 2000 à 2008 - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -T2. Le nombre de vols retardés de plus de 10 minutes, regroupés par jour de la semaine, pour 2000-2008 - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -T3. Le nombre de retards par l'aéroport pour 2000-2008 - -``` sql -SELECT Origin, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY Origin -ORDER BY c DESC -LIMIT 10; -``` - -T4. Nombre de retards par transporteur pour 2007 - -``` sql -SELECT Carrier, count(*) -FROM ontime -WHERE DepDelay>10 AND Year=2007 -GROUP BY Carrier -ORDER BY count(*) DESC; -``` - -Q5. Pourcentage de retards par transporteur pour 2007 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year=2007 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year=2007 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Meilleure version de la même requête: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year=2007 -GROUP BY Carrier -ORDER BY c3 DESC -``` - -Q6. La demande précédente pour une plus large gamme d'années, 2000-2008 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year>=2000 AND Year<=2008 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year>=2000 AND Year<=2008 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Meilleure version de la même requête: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY Carrier -ORDER BY c3 DESC; -``` - -Q7. Pourcentage de vols retardés de plus de 10 minutes, par année - -``` sql -SELECT Year, c1/c2 -FROM -( - select - Year, - count(*)*100 as c1 - from ontime - WHERE DepDelay>10 - GROUP BY Year -) -JOIN -( - select - Year, - count(*) as c2 - from ontime - GROUP BY Year -) USING (Year) -ORDER BY Year; -``` - -Meilleure version de la même requête: - -``` sql -SELECT Year, avg(DepDelay>10)*100 -FROM ontime -GROUP BY Year -ORDER BY Year; -``` - -Q8. Les destinations les plus populaires par le nombre de villes directement connectées pour différentes plages d'années - -``` sql -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -WHERE Year >= 2000 and Year <= 2010 -GROUP BY DestCityName -ORDER BY u DESC LIMIT 10; -``` - -Q9. - -``` sql -SELECT Year, count(*) AS c1 -FROM ontime -GROUP BY Year; -``` - -Q10. - -``` sql -SELECT - min(Year), max(Year), Carrier, count(*) AS cnt, - sum(ArrDelayMinutes>30) AS flights_delayed, - round(sum(ArrDelayMinutes>30)/count(*),2) AS rate -FROM ontime -WHERE - DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') - AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') - AND FlightDate < '2010-01-01' -GROUP by Carrier -HAVING cnt>100000 and max(Year)>1990 -ORDER by rate DESC -LIMIT 1000; -``` - -Bonus: - -``` sql -SELECT avg(cnt) -FROM -( - SELECT Year,Month,count(*) AS cnt - FROM ontime - WHERE DepDel15=1 - GROUP BY Year,Month -); - -SELECT avg(c1) FROM -( - SELECT Year,Month,count(*) AS c1 - FROM ontime - GROUP BY Year,Month -); - -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -GROUP BY DestCityName -ORDER BY u DESC -LIMIT 10; - -SELECT OriginCityName, DestCityName, count() AS c -FROM ontime -GROUP BY OriginCityName, DestCityName -ORDER BY c DESC -LIMIT 10; - -SELECT OriginCityName, count() AS c -FROM ontime -GROUP BY OriginCityName -ORDER BY c DESC -LIMIT 10; -``` - -Ce test de performance a été créé par Vadim Tkachenko. Voir: - -- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ -- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ -- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ -- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ -- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ -- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/fr/getting_started/example_datasets/star_schema.md b/docs/fr/getting_started/example_datasets/star_schema.md deleted file mode 100644 index f39d810623b..00000000000 --- a/docs/fr/getting_started/example_datasets/star_schema.md +++ /dev/null @@ -1,370 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 20 -toc_title: "R\xE9f\xE9rence Du Sch\xE9ma En \xC9toile" ---- - -# Référence Du Schéma En Étoile {#star-schema-benchmark} - -Compilation de dbgen: - -``` bash -$ git clone git@github.com:vadimtk/ssb-dbgen.git -$ cd ssb-dbgen -$ make -``` - -La production de données: - -!!! warning "Attention" - Avec `-s 100` dbgen génère 600 millions de lignes (67 Go), tandis que while `-s 1000` il génère 6 milliards de lignes (ce qui prend beaucoup de temps) - -``` bash -$ ./dbgen -s 1000 -T c -$ ./dbgen -s 1000 -T l -$ ./dbgen -s 1000 -T p -$ ./dbgen -s 1000 -T s -$ ./dbgen -s 1000 -T d -``` - -Création de tables dans ClickHouse: - -``` sql -CREATE TABLE customer -( - C_CUSTKEY UInt32, - C_NAME String, - C_ADDRESS String, - C_CITY LowCardinality(String), - C_NATION LowCardinality(String), - C_REGION LowCardinality(String), - C_PHONE String, - C_MKTSEGMENT LowCardinality(String) -) -ENGINE = MergeTree ORDER BY (C_CUSTKEY); - -CREATE TABLE lineorder -( - LO_ORDERKEY UInt32, - LO_LINENUMBER UInt8, - LO_CUSTKEY UInt32, - LO_PARTKEY UInt32, - LO_SUPPKEY UInt32, - LO_ORDERDATE Date, - LO_ORDERPRIORITY LowCardinality(String), - LO_SHIPPRIORITY UInt8, - LO_QUANTITY UInt8, - LO_EXTENDEDPRICE UInt32, - LO_ORDTOTALPRICE UInt32, - LO_DISCOUNT UInt8, - LO_REVENUE UInt32, - LO_SUPPLYCOST UInt32, - LO_TAX UInt8, - LO_COMMITDATE Date, - LO_SHIPMODE LowCardinality(String) -) -ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY); - -CREATE TABLE part -( - P_PARTKEY UInt32, - P_NAME String, - P_MFGR LowCardinality(String), - P_CATEGORY LowCardinality(String), - P_BRAND LowCardinality(String), - P_COLOR LowCardinality(String), - P_TYPE LowCardinality(String), - P_SIZE UInt8, - P_CONTAINER LowCardinality(String) -) -ENGINE = MergeTree ORDER BY P_PARTKEY; - -CREATE TABLE supplier -( - S_SUPPKEY UInt32, - S_NAME String, - S_ADDRESS String, - S_CITY LowCardinality(String), - S_NATION LowCardinality(String), - S_REGION LowCardinality(String), - S_PHONE String -) -ENGINE = MergeTree ORDER BY S_SUPPKEY; -``` - -Insertion de données: - -``` bash -$ clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl -$ clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl -$ clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl -$ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl -``` - -Conversion “star schema” pour dénormalisée “flat schema”: - -``` sql -SET max_memory_usage = 20000000000; - -CREATE TABLE lineorder_flat -ENGINE = MergeTree -PARTITION BY toYear(LO_ORDERDATE) -ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS -SELECT - l.LO_ORDERKEY AS LO_ORDERKEY, - l.LO_LINENUMBER AS LO_LINENUMBER, - l.LO_CUSTKEY AS LO_CUSTKEY, - l.LO_PARTKEY AS LO_PARTKEY, - l.LO_SUPPKEY AS LO_SUPPKEY, - l.LO_ORDERDATE AS LO_ORDERDATE, - l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY, - l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY, - l.LO_QUANTITY AS LO_QUANTITY, - l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE, - l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE, - l.LO_DISCOUNT AS LO_DISCOUNT, - l.LO_REVENUE AS LO_REVENUE, - l.LO_SUPPLYCOST AS LO_SUPPLYCOST, - l.LO_TAX AS LO_TAX, - l.LO_COMMITDATE AS LO_COMMITDATE, - l.LO_SHIPMODE AS LO_SHIPMODE, - c.C_NAME AS C_NAME, - c.C_ADDRESS AS C_ADDRESS, - c.C_CITY AS C_CITY, - c.C_NATION AS C_NATION, - c.C_REGION AS C_REGION, - c.C_PHONE AS C_PHONE, - c.C_MKTSEGMENT AS C_MKTSEGMENT, - s.S_NAME AS S_NAME, - s.S_ADDRESS AS S_ADDRESS, - s.S_CITY AS S_CITY, - s.S_NATION AS S_NATION, - s.S_REGION AS S_REGION, - s.S_PHONE AS S_PHONE, - p.P_NAME AS P_NAME, - p.P_MFGR AS P_MFGR, - p.P_CATEGORY AS P_CATEGORY, - p.P_BRAND AS P_BRAND, - p.P_COLOR AS P_COLOR, - p.P_TYPE AS P_TYPE, - p.P_SIZE AS P_SIZE, - p.P_CONTAINER AS P_CONTAINER -FROM lineorder AS l -INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY -INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY -INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; -``` - -Exécution des requêtes: - -Q1.1 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toYear(LO_ORDERDATE) = 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25; -``` - -Q1.2 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toYYYYMM(LO_ORDERDATE) = 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35; -``` - -Q1.3 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toISOWeek(LO_ORDERDATE) = 6 AND toYear(LO_ORDERDATE) = 1994 - AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35; -``` - -Q2.1 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q2.2 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_BRAND >= 'MFGR#2221' AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q2.3 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q3.1 - -``` sql -SELECT - C_NATION, - S_NATION, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year >= 1992 AND year <= 1997 -GROUP BY - C_NATION, - S_NATION, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.2 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE C_NATION = 'UNITED STATES' AND S_NATION = 'UNITED STATES' AND year >= 1992 AND year <= 1997 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.3 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND year >= 1992 AND year <= 1997 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.4 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND toYYYYMM(LO_ORDERDATE) = 199712 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q4.1 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - C_NATION, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') -GROUP BY - year, - C_NATION -ORDER BY - year ASC, - C_NATION ASC; -``` - -Q4.2 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - S_NATION, - P_CATEGORY, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year = 1997 OR year = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') -GROUP BY - year, - S_NATION, - P_CATEGORY -ORDER BY - year ASC, - S_NATION ASC, - P_CATEGORY ASC; -``` - -Q4.3 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - S_CITY, - P_BRAND, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE S_NATION = 'UNITED STATES' AND (year = 1997 OR year = 1998) AND P_CATEGORY = 'MFGR#14' -GROUP BY - year, - S_CITY, - P_BRAND -ORDER BY - year ASC, - S_CITY ASC, - P_BRAND ASC; -``` - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/star_schema/) diff --git a/docs/fr/getting_started/example_datasets/wikistat.md b/docs/fr/getting_started/example_datasets/wikistat.md deleted file mode 100644 index e3b8a322f09..00000000000 --- a/docs/fr/getting_started/example_datasets/wikistat.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 18 -toc_title: WikiStat ---- - -# WikiStat {#wikistat} - -Voir: http://dumps.wikimedia.org/other/pagecounts-raw/ - -Création d'une table: - -``` sql -CREATE TABLE wikistat -( - date Date, - time DateTime, - project String, - subproject String, - path String, - hits UInt64, - size UInt64 -) ENGINE = MergeTree(date, (path, time), 8192); -``` - -Le chargement des données: - -``` bash -$ for i in {2007..2016}; do for j in {01..12}; do echo $i-$j >&2; curl -sSL "http://dumps.wikimedia.org/other/pagecounts-raw/$i/$i-$j/" | grep -oE 'pagecounts-[0-9]+-[0-9]+\.gz'; done; done | sort | uniq | tee links.txt -$ cat links.txt | while read link; do wget http://dumps.wikimedia.org/other/pagecounts-raw/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1/')/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1-\2/')/$link; done -$ ls -1 /opt/wikistat/ | grep gz | while read i; do echo $i; gzip -cd /opt/wikistat/$i | ./wikistat-loader --time="$(echo -n $i | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})\.gz/\1-\2-\3 \4-00-00/')" | clickhouse-client --query="INSERT INTO wikistat FORMAT TabSeparated"; done -``` - -[Article Original](https://clickhouse.tech/docs/en/getting_started/example_datasets/wikistat/) diff --git a/docs/fr/getting_started/index.md b/docs/fr/getting_started/index.md deleted file mode 100644 index 375c87b112c..00000000000 --- a/docs/fr/getting_started/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Getting Started -toc_hidden: true -toc_priority: 8 -toc_title: "cach\xE9s" ---- - -# Prise En Main {#getting-started} - -Si vous êtes nouveau à ClickHouse et que vous voulez obtenir un sentiment pratique de sa performance, tout d'abord, vous devez passer par le [processus d'installation](install.md). Après cela, vous pouvez: - -- [Passez par tutoriel détaillé](tutorial.md) -- [Expérience avec des exemples de jeux de données](example_datasets/ontime.md) - -[Article Original](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/fr/getting_started/install.md b/docs/fr/getting_started/install.md deleted file mode 100644 index 1834577ca02..00000000000 --- a/docs/fr/getting_started/install.md +++ /dev/null @@ -1,185 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 11 -toc_title: Installation ---- - -# Installation {#installation} - -## Configuration Système Requise {#system-requirements} - -ClickHouse peut fonctionner sur N'importe quel Linux, FreeBSD ou Mac OS X avec une architecture CPU x86\_64, AArch64 ou PowerPC64LE. - -Les binaires pré-construits officiels sont généralement compilés pour le jeu d'instructions x86\_64 et leverage SSE 4.2, donc sauf indication contraire, l'utilisation du processeur qui le prend en charge devient une exigence système supplémentaire. Voici la commande pour vérifier si le processeur actuel prend en charge SSE 4.2: - -``` bash -$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" -``` - -Pour exécuter ClickHouse sur des processeurs qui ne prennent pas en charge SSE 4.2 ou qui ont une architecture AArch64 ou PowerPC64LE, vous devez [construire ClickHouse à partir de sources](#from-sources) avec des ajustements de configuration appropriés. - -## Options D'Installation Disponibles {#available-installation-options} - -### À partir de paquets DEB {#install-from-deb-packages} - -Il est recommandé d'utiliser officiel pré-compilé `deb` Paquets Pour Debian ou Ubuntu. - - -Exécutez ensuite ces commandes pour installer les paquets: - -``` bash -{% include 'install/deb.sh' %} -``` - -Si vous souhaitez utiliser la version la plus récente, remplacer `stable` avec `testing` (ceci est recommandé pour vos environnements de test). - -Vous pouvez également télécharger et installer des paquets manuellement à partir d'ici: https://repo.clickhouse.tech/deb/stable/main/. - -#### Paquet {#packages} - -- `clickhouse-common-static` — Installs ClickHouse compiled binary files. -- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` et installe la configuration du serveur par défaut. -- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` et d'autres outils. et installe les fichiers de configuration du client. -- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. - -### À partir de paquets RPM {#from-rpm-packages} - -Il est recommandé d'utiliser officiel pré-compilé `rpm` packages pour CentOS, RedHat et toutes les autres distributions Linux basées sur rpm. - -Tout d'abord, vous devez ajouter le dépôt officiel: - -``` bash -sudo yum install yum-utils -sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG -sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 -``` - -Si vous souhaitez utiliser la version la plus récente, remplacer `stable` avec `testing` (ceci est recommandé pour vos environnements de test). Le `prestable` la balise est parfois trop. - -Exécutez ensuite ces commandes pour installer les paquets: - -``` bash -sudo yum install clickhouse-server clickhouse-client -``` - -Vous pouvez également télécharger et installer des paquets manuellement à partir d'ici: https://repo.clickhouse.tech / rpm / stable / x86\_64. - -### À partir d'archives tgz {#from-tgz-archives} - -Il est recommandé d'utiliser officiel pré-compilé `tgz` archives pour toutes les distributions Linux, où l'installation de `deb` ou `rpm` les emballages n'est pas possible. - -La version requise peut être téléchargée avec `curl` ou `wget` depuis le référentiel https://repo.yandex.ru/clickhouse/tgz/. -Après cela, les archives téléchargées doivent être décompressées et installées avec des scripts d'installation. Exemple pour la dernière version: - -``` bash -export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz - -tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz -sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz -sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-server-$LATEST_VERSION.tgz -sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh -sudo /etc/init.d/clickhouse-server start - -tar -xzvf clickhouse-client-$LATEST_VERSION.tgz -sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh -``` - -Pour les environnements de production, il est recommandé d'utiliser la dernière `stable`-version. Vous pouvez trouver son numéro sur la page GitHub https://github.com/ClickHouse/ClickHouse/tags avec postfix `-stable`. - -### À Partir De L'Image Docker {#from-docker-image} - -Pour exécuter Clickhouse à L'intérieur Docker suivez le guide sur [Hub Docker](https://hub.docker.com/r/yandex/clickhouse-server/). Ces images utilisent officiel `deb` les paquets à l'intérieur. - -### À Partir De Sources {#from-sources} - -Pour compiler manuellement ClickHouse, suivez les instructions pour [Linux](../development/build.md) ou [Mac OS X](../development/build_osx.md). - -Vous pouvez compiler des paquets et les installer ou utiliser des programmes sans installer de paquets. En outre, en construisant manuellement, vous pouvez désactiver L'exigence SSE 4.2 ou construire pour les processeurs AArch64. - - Client: programs/clickhouse-client - Server: programs/clickhouse-server - -Vous devrez créer un dossier de données et de métadonnées et `chown` pour l'utilisateur souhaité. Leurs chemins peuvent être modifiés dans la configuration du serveur (src / programs / server / config.xml), par défaut, ils sont: - - /opt/clickhouse/data/default/ - /opt/clickhouse/metadata/default/ - -Sur Gentoo, vous pouvez simplement utiliser `emerge clickhouse` pour installer ClickHouse à partir de sources. - -## Lancer {#launch} - -Pour démarrer le serveur en tant que démon, exécutez: - -``` bash -$ sudo service clickhouse-server start -``` - -Si vous n'avez pas `service` commande, exécuter comme - -``` bash -$ sudo /etc/init.d/clickhouse-server start -``` - -Voir les journaux dans le `/var/log/clickhouse-server/` répertoire. - -Si le serveur ne démarre pas, vérifiez les configurations dans le fichier `/etc/clickhouse-server/config.xml`. - -Vous pouvez également lancer manuellement le serveur à partir de la console: - -``` bash -$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml -``` - -Dans ce cas, le journal sera imprimé sur la console, ce qui est pratique lors du développement. -Si le fichier de configuration se trouve dans le répertoire courant, vous n'avez pas besoin `--config-file` paramètre. Par défaut, il utilise `./config.xml`. - -ClickHouse prend en charge les paramètres de restriction d'accès. Ils sont situés dans la `users.xml` fichier (à côté de `config.xml`). -Par défaut, l'accès est autorisé depuis n'importe où pour `default` l'utilisateur, sans un mot de passe. Voir `user/default/networks`. -Pour plus d'informations, consultez la section [“Configuration Files”](../operations/configuration_files.md). - -Après le lancement du serveur, vous pouvez utiliser le client de ligne de commande pour vous y connecter: - -``` bash -$ clickhouse-client -``` - -Par défaut, il se connecte à `localhost:9000` au nom de l'utilisateur `default` sans un mot de passe. Il peut également être utilisé pour se connecter à un serveur distant en utilisant `--host` argument. - -Le terminal doit utiliser L'encodage UTF-8. -Pour plus d'informations, consultez la section [“Command-line client”](../interfaces/cli.md). - -Exemple: - -``` bash -$ ./clickhouse-client -ClickHouse client version 0.0.18749. -Connecting to localhost:9000. -Connected to ClickHouse server version 0.0.18749. - -:) SELECT 1 - -SELECT 1 - -┌─1─┐ -│ 1 │ -└───┘ - -1 rows in set. Elapsed: 0.003 sec. - -:) -``` - -**Félicitations, le système fonctionne!** - -Pour continuer à expérimenter, vous pouvez télécharger l'un des jeux de données de test ou passer par [tutoriel](https://clickhouse.tech/tutorial.html). - -[Article Original](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/fr/getting_started/playground.md b/docs/fr/getting_started/playground.md deleted file mode 100644 index 57993309923..00000000000 --- a/docs/fr/getting_started/playground.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 14 -toc_title: "R\xE9cr\xE9ation" ---- - -# Clickhouse Aire De Jeux {#clickhouse-playground} - -[Clickhouse Aire De Jeux](https://play.clickhouse.tech?file=welcome) permet aux utilisateurs d'expérimenter avec ClickHouse en exécutant des requêtes instantanément, sans configurer leur serveur ou leur cluster. -Plusieurs exemples de jeux de données sont disponibles dans le terrain de jeu ainsi que des exemples de requêtes qui montrent les fonctionnalités de ClickHouse. - -Les requêtes sont exécutées comme un utilisateur en lecture seule. Cela implique certaines limites: - -- Les requêtes DDL ne sont pas autorisées -- Les requêtes D'insertion ne sont pas autorisées - -Les paramètres suivants sont également appliquées: -- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) -- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) -- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) -- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) - -Clickhouse Playground donne l'expérience du m2.Petite -[Service géré pour ClickHouse](https://cloud.yandex.com/services/managed-clickhouse) -exemple hébergé dans [Yandex.Nuage](https://cloud.yandex.com/). -Plus d'informations sur [les fournisseurs de cloud](../commercial/cloud.md). - -Clickhouse Playground interface web fait des demandes via ClickHouse [HTTP API](../interfaces/http.md). -Le backend Playground est juste un cluster ClickHouse sans aucune application Côté Serveur supplémentaire. -ClickHouse HTTPS endpoint est également disponible dans le cadre du terrain de jeu. - -Vous pouvez effectuer des requêtes sur playground en utilisant n'importe quel client HTTP, par exemple [curl](https://curl.haxx.se) ou [wget](https://www.gnu.org/software/wget/), ou configurer une connexion en utilisant [JDBC](../interfaces/jdbc.md) ou [ODBC](../interfaces/odbc.md) pilote. -Plus d'informations sur les produits logiciels qui prennent en charge ClickHouse est disponible [ici](../interfaces/index.md). - -| Paramètre | Valeur | -|:-------------|:----------------------------------------------| -| Terminaison | https://play-api.clickhouse.technologie: 8443 | -| Utilisateur | `playground` | -| Mot de passe | `clickhouse` | - -Notez que ce paramètre nécessite une connexion sécurisée. - -Exemple: - -``` bash -curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" -``` diff --git a/docs/fr/getting_started/tutorial.md b/docs/fr/getting_started/tutorial.md deleted file mode 100644 index 0a4d6843984..00000000000 --- a/docs/fr/getting_started/tutorial.md +++ /dev/null @@ -1,665 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 12 -toc_title: Tutoriel ---- - -# Tutoriel ClickHouse {#clickhouse-tutorial} - -## À quoi S'attendre de ce tutoriel? {#what-to-expect-from-this-tutorial} - -En parcourant ce tutoriel, vous apprendrez à configurer un cluster ClickHouse simple. Ce sera petit, mais tolérant aux pannes et évolutif. Ensuite, nous utiliserons l'un des exemples de jeux de données pour le remplir de données et exécuter des requêtes de démonstration. - -## Configuration De Noeud Unique {#single-node-setup} - -Pour retarder les complexités d'un environnement distribué, nous allons commencer par déployer ClickHouse sur un seul serveur ou une machine virtuelle. ClickHouse est généralement installé à partir de [deb](install.md#install-from-deb-packages) ou [rpm](install.md#from-rpm-packages) les paquets, mais il y a [alternative](install.md#from-docker-image) pour les systèmes d'exploitation qui ne sont pas les soutenir. - -Par exemple, vous avez choisi `deb` paquets et exécutés: - -``` bash -{% include 'install/deb.sh' %} -``` - -Quelles sont les paquets installés: - -- `clickhouse-client` package contient [clickhouse-client](../interfaces/cli.md) application, client interactif de console de ClickHouse. -- `clickhouse-common` paquet contient un fichier exécutable ClickHouse. -- `clickhouse-server` package contient des fichiers de configuration pour exécuter ClickHouse en tant que serveur. - -Les fichiers de configuration du serveur sont `/etc/clickhouse-server/`. Avant d'aller plus loin, notez le `` élément `config.xml`. Path détermine l'emplacement pour le stockage des données, il doit donc être situé sur le volume avec une grande capacité de disque; la valeur par défaut est `/var/lib/clickhouse/`. Si vous souhaitez ajuster la configuration, il n'est pas pratique de modifier directement `config.xml` fichier, considérant qu'il pourrait obtenir réécrit sur les futures mises à jour du progiciel. La façon recommandée de remplacer les éléments de configuration est de créer [fichiers dans config.d: répertoire](../operations/configuration_files.md) qui servent de “patches” config.XML. - -Comme vous l'avez peut-être remarqué, `clickhouse-server` n'est pas lancé automatiquement après l'installation du paquet. Il ne sera pas redémarré automatiquement après les mises à jour, non plus. La façon dont vous démarrez le serveur dépend de votre système d'initialisation, généralement, c'est: - -``` bash -sudo service clickhouse-server start -``` - -ou - -``` bash -sudo /etc/init.d/clickhouse-server start -``` - -L'emplacement par défaut pour les journaux du serveur est `/var/log/clickhouse-server/`. Le serveur est prêt à gérer les connexions client une fois `Ready for connections` message. - -Une fois l' `clickhouse-server` est opérationnel, nous pouvons utiliser `clickhouse-client` pour se connecter au serveur et effectuer des tests de requêtes comme `SELECT "Hello, world!";`. - -
- -Conseils rapides pour clickhouse-client -Mode interactif: - -``` bash -clickhouse-client -clickhouse-client --host=... --port=... --user=... --password=... -``` - -Activer les requêtes multilignes: - -``` bash -clickhouse-client -m -clickhouse-client --multiline -``` - -Exécuter des requêtes en mode batch: - -``` bash -clickhouse-client --query='SELECT 1' -echo 'SELECT 1' | clickhouse-client -clickhouse-client <<< 'SELECT 1' -``` - -Insérer des données à partir d'un fichier au format spécifié: - -``` bash -clickhouse-client --query='INSERT INTO table VALUES' < data.txt -clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv -``` - -
- -## Importer Un Échantillon De Données {#import-sample-dataset} - -Maintenant, il est temps de remplir notre serveur ClickHouse avec quelques exemples de données. Dans ce tutoriel, nous allons utiliser les données anonymisées de Yandex.Metrica, le premier service qui exécute ClickHouse en production avant de devenir open-source (plus à ce sujet dans [section d'histoire](../introduction/history.md)). Il y a [plusieurs façons d'importer Yandex.Metrica dataset](example_datasets/metrica.md), et pour le bien du tutoriel, nous irons avec le plus réaliste. - -### Télécharger et extraire les données de la Table {#download-and-extract-table-data} - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -``` - -Les fichiers extraits ont une taille d'environ 10 Go. - -### Créer Des Tables {#create-tables} - -Comme dans la plupart des systèmes de gestion de bases de données, clickhouse regroupe logiquement les tables en “databases”. Il y a un `default` base de données, mais nous allons en créer une nouvelle nommée `tutorial`: - -``` bash -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" -``` - -La syntaxe pour créer des tables est beaucoup plus compliquée par rapport aux bases de données (voir [référence](../sql_reference/statements/create.md). En général `CREATE TABLE` déclaration doit spécifier trois choses clés: - -1. Nom de la table à créer. -2. Table schema, i.e. list of columns and their [types de données](../sql_reference/data_types/index.md). -3. [Tableau moteur](../engines/table_engines/index.md) et ce sont les paramètres, qui déterminent tous les détails sur la façon dont les requêtes à cette table seront physiquement exécutées. - -Yandex.Metrica est un service d'analyse web, et l'exemple de jeu de données ne couvre pas toutes ses fonctionnalités, il n'y a donc que deux tables à créer: - -- `hits` est un tableau avec chaque action effectuée par tous les utilisateurs sur tous les sites couverts par le service. -- `visits` est une table qui contient des sessions pré-construites au lieu d'actions individuelles. - -Voyons et exécutons les vraies requêtes create table pour ces tables: - -``` sql -CREATE TABLE tutorial.hits_v1 -( - `WatchID` UInt64, - `JavaEnable` UInt8, - `Title` String, - `GoodEvent` Int16, - `EventTime` DateTime, - `EventDate` Date, - `CounterID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RegionID` UInt32, - `UserID` UInt64, - `CounterClass` Int8, - `OS` UInt8, - `UserAgent` UInt8, - `URL` String, - `Referer` String, - `URLDomain` String, - `RefererDomain` String, - `Refresh` UInt8, - `IsRobot` UInt8, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `FlashMinor2` String, - `NetMajor` UInt8, - `NetMinor` UInt8, - `UserAgentMajor` UInt16, - `UserAgentMinor` FixedString(2), - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `MobilePhone` UInt8, - `MobilePhoneModel` String, - `Params` String, - `IPNetworkID` UInt32, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `IsArtifical` UInt8, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `ClientTimeZone` Int16, - `ClientEventTime` DateTime, - `SilverlightVersion1` UInt8, - `SilverlightVersion2` UInt8, - `SilverlightVersion3` UInt32, - `SilverlightVersion4` UInt16, - `PageCharset` String, - `CodeVersion` UInt32, - `IsLink` UInt8, - `IsDownload` UInt8, - `IsNotBounce` UInt8, - `FUniqID` UInt64, - `HID` UInt32, - `IsOldCounter` UInt8, - `IsEvent` UInt8, - `IsParameter` UInt8, - `DontCountHits` UInt8, - `WithHash` UInt8, - `HitColor` FixedString(1), - `UTCEventTime` DateTime, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `WindowName` Int32, - `OpenerName` Int32, - `HistoryLength` Int16, - `BrowserLanguage` FixedString(2), - `BrowserCountry` FixedString(2), - `SocialNetwork` String, - `SocialAction` String, - `HTTPError` UInt16, - `SendTiming` Int32, - `DNSTiming` Int32, - `ConnectTiming` Int32, - `ResponseStartTiming` Int32, - `ResponseEndTiming` Int32, - `FetchTiming` Int32, - `RedirectTiming` Int32, - `DOMInteractiveTiming` Int32, - `DOMContentLoadedTiming` Int32, - `DOMCompleteTiming` Int32, - `LoadEventStartTiming` Int32, - `LoadEventEndTiming` Int32, - `NSToDOMContentLoadedTiming` Int32, - `FirstPaintTiming` Int32, - `RedirectCount` Int8, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `ParamPrice` Int64, - `ParamOrderID` String, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `GoalsReached` Array(UInt32), - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `RefererHash` UInt64, - `URLHash` UInt64, - `CLID` UInt32, - `YCLID` UInt64, - `ShareService` String, - `ShareURL` String, - `ShareTitle` String, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `IslandID` FixedString(16), - `RequestNum` UInt32, - `RequestTry` UInt8 -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -``` sql -CREATE TABLE tutorial.visits_v1 -( - `CounterID` UInt32, - `StartDate` Date, - `Sign` Int8, - `IsNew` UInt8, - `VisitID` UInt64, - `UserID` UInt64, - `StartTime` DateTime, - `Duration` UInt32, - `UTCStartTime` DateTime, - `PageViews` Int32, - `Hits` Int32, - `IsBounce` UInt8, - `Referer` String, - `StartURL` String, - `RefererDomain` String, - `StartURLDomain` String, - `EndURL` String, - `LinkURL` String, - `IsDownload` UInt8, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `PlaceID` Int32, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `IsYandex` UInt8, - `GoalReachesDepth` Int32, - `GoalReachesURL` Int32, - `GoalReachesAny` Int32, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `MobilePhoneModel` String, - `ClientEventTime` DateTime, - `RegionID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `IPNetworkID` UInt32, - `SilverlightVersion3` UInt32, - `CodeVersion` UInt32, - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `UserAgentMajor` UInt16, - `UserAgentMinor` UInt16, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `SilverlightVersion2` UInt8, - `SilverlightVersion4` UInt16, - `FlashVersion3` UInt16, - `FlashVersion4` UInt16, - `ClientTimeZone` Int16, - `OS` UInt8, - `UserAgent` UInt8, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `NetMajor` UInt8, - `NetMinor` UInt8, - `MobilePhone` UInt8, - `SilverlightVersion1` UInt8, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `JavaEnable` UInt8, - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `BrowserLanguage` UInt16, - `BrowserCountry` UInt16, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `Params` Array(String), - `Goals` Nested( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32), - `WatchIDs` Array(UInt64), - `ParamSumPrice` Int64, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `ClickLogID` UInt64, - `ClickEventID` Int32, - `ClickGoodEvent` Int32, - `ClickEventTime` DateTime, - `ClickPriorityID` Int32, - `ClickPhraseID` Int32, - `ClickPageID` Int32, - `ClickPlaceID` Int32, - `ClickTypeID` Int32, - `ClickResourceID` Int32, - `ClickCost` UInt32, - `ClickClientIP` UInt32, - `ClickDomainID` UInt32, - `ClickURL` String, - `ClickAttempt` UInt8, - `ClickOrderID` UInt32, - `ClickBannerID` UInt32, - `ClickMarketCategoryID` UInt32, - `ClickMarketPP` UInt32, - `ClickMarketCategoryName` String, - `ClickMarketPPName` String, - `ClickAWAPSCampaignName` String, - `ClickPageName` String, - `ClickTargetType` UInt16, - `ClickTargetPhraseID` UInt64, - `ClickContextType` UInt8, - `ClickSelectType` Int8, - `ClickOptions` String, - `ClickGroupBannerID` Int32, - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `FirstVisit` DateTime, - `PredLastVisit` Date, - `LastVisit` Date, - `TotalVisits` UInt32, - `TraficSource` Nested( - ID Int8, - SearchEngineID UInt16, - AdvEngineID UInt8, - PlaceID UInt16, - SocialSourceNetworkID UInt8, - Domain String, - SearchPhrase String, - SocialSourcePage String), - `Attendance` FixedString(16), - `CLID` UInt32, - `YCLID` UInt64, - `NormalizedRefererHash` UInt64, - `SearchPhraseHash` UInt64, - `RefererDomainHash` UInt64, - `NormalizedStartURLHash` UInt64, - `StartURLDomainHash` UInt64, - `NormalizedEndURLHash` UInt64, - `TopLevelDomain` UInt64, - `URLScheme` UInt64, - `OpenstatServiceNameHash` UInt64, - `OpenstatCampaignIDHash` UInt64, - `OpenstatAdIDHash` UInt64, - `OpenstatSourceIDHash` UInt64, - `UTMSourceHash` UInt64, - `UTMMediumHash` UInt64, - `UTMCampaignHash` UInt64, - `UTMContentHash` UInt64, - `UTMTermHash` UInt64, - `FromHash` UInt64, - `WebVisorEnabled` UInt8, - `WebVisorActivity` UInt32, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `Market` Nested( - Type UInt8, - GoalID UInt32, - OrderID String, - OrderPrice Int64, - PP UInt32, - DirectPlaceID UInt32, - DirectOrderID UInt32, - DirectBannerID UInt32, - GoodID String, - GoodName String, - GoodQuantity Int32, - GoodPrice Int64), - `IslandID` FixedString(16) -) -ENGINE = CollapsingMergeTree(Sign) -PARTITION BY toYYYYMM(StartDate) -ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -Vous pouvez exécuter ces requêtes en utilisant le mode interactif de `clickhouse-client` (lancez - le simplement dans un terminal sans spécifier une requête à l'avance) ou essayez-en [interface de rechange](../interfaces/index.md) Si tu veux. - -Comme nous pouvons le voir, `hits_v1` utilise la [moteur MergeTree de base](../engines/table_engines/mergetree_family/mergetree.md) tandis que le `visits_v1` utilise la [Effondrer](../engines/table_engines/mergetree_family/collapsingmergetree.md) variante. - -### Importer Des Données {#import-data} - -L'importation de données vers ClickHouse se fait via [INSERT INTO](../sql_reference/statements/insert_into.md) requête comme dans de nombreuses autres bases de données SQL. Toutefois, les données sont généralement fournies dans l'une des [formats de sérialisation pris en charge](../interfaces/formats.md) plutôt `VALUES` clause (qui est également pris en charge). - -Les fichiers que nous avons téléchargés plus tôt sont au format séparé par des onglets, alors voici comment les importer via le client console: - -``` bash -clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv -clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv -``` - -ClickHouse a beaucoup de [les paramètres de tune](../operations/settings/index.md) et une façon de Les spécifier dans le client console est via des arguments, comme nous pouvons le voir avec `--max_insert_block_size`. La façon la plus simple de comprendre quels paramètres sont disponibles, que signifient-ils et quelles sont les valeurs par défaut est d'interroger le `system.settings` table: - -``` sql -SELECT name, value, changed, description -FROM system.settings -WHERE name LIKE '%max_insert_b%' -FORMAT TSV - -max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." -``` - -Optionnellement, vous pouvez [OPTIMIZE](../query_language/misc/#misc_operations-optimize) les tables après l'importation. Les Tables configurées avec un moteur de MergeTree-family font toujours des fusions de parties de données en arrière-plan pour optimiser le stockage des données (ou au moins vérifier si cela a du sens). Ces requêtes forcent le moteur de table à optimiser le stockage dès maintenant au lieu d'un certain temps plus tard: - -``` bash -clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" -clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" -``` - -Ces requêtes démarrent une opération intensive D'E/S et de CPU, donc si la table reçoit systématiquement de nouvelles données, il est préférable de la laisser seule et de laisser les fusions s'exécuter en arrière-plan. - -Maintenant, nous pouvons vérifier si l'importation de table a réussi: - -``` bash -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" -``` - -## Exemple De Requêtes {#example-queries} - -``` sql -SELECT - StartURL AS URL, - AVG(Duration) AS AvgDuration -FROM tutorial.visits_v1 -WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' -GROUP BY URL -ORDER BY AvgDuration DESC -LIMIT 10 -``` - -``` sql -SELECT - sum(Sign) AS visits, - sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, - (100. * goal_visits) / visits AS goal_percent -FROM tutorial.visits_v1 -WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') -``` - -## Déploiement De Cluster {#cluster-deployment} - -Clickhouse cluster est un cluster homogène. Étapes pour configurer: - -1. Installer clickhouse server sur toutes les machines du cluster -2. Configurer les configurations de cluster dans les fichiers de configuration -3. Créer des tables locales sur chaque instance -4. Créer un [Distribué table](../engines/table_engines/special/distributed.md) - -[Distribué table](../engines/table_engines/special/distributed.md) est en fait une sorte de “view” aux tables locales du cluster ClickHouse. SELECT query from a distributed table s'exécute à l'aide des ressources de tous les fragments du cluster. Vous pouvez spécifier des configurations pour plusieurs clusters et créer plusieurs tables distribuées fournissant des vues à différents clusters. - -Exemple de configuration pour un cluster avec trois fragments, une réplique chacun: - -``` xml - - - - - example-perftest01j.yandex.ru - 9000 - - - - - example-perftest02j.yandex.ru - 9000 - - - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -Pour plus de démonstration, créons une nouvelle table locale avec le même `CREATE TABLE` la requête que nous avons utilisé pour `hits_v1`, mais nom de table différent: - -``` sql -CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... -``` - -Création d'une table distribuée fournissant une vue dans les tables locales du cluster: - -``` sql -CREATE TABLE tutorial.hits_all AS tutorial.hits_local -ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); -``` - -Une pratique courante consiste à créer des tables distribuées similaires sur toutes les machines du cluster. Il permet d'exécuter des requêtes distribuées sur n'importe quelle machine du cluster. Il existe également une autre option pour créer une table distribuée temporaire pour une requête SELECT donnée en utilisant [distant](../sql_reference/table_functions/remote.md) table de fonction. - -Passons à l'exécution de [INSERT SELECT](../sql_reference/statements/insert_into.md) dans les Distribué table la table à plusieurs serveurs. - -``` sql -INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; -``` - -!!! warning "Avis" - Cette approche ne convient pas au sharding de grandes tables. Il y a un outil séparé [clickhouse-copieur](../operations/utilities/clickhouse-copier.md) cela peut re-fragmenter de grandes tables arbitraires. - -Comme vous pouvez vous y attendre, les requêtes lourdes de calcul s'exécutent N fois plus vite si elles utilisent 3 serveurs au lieu d'un. - -Dans ce cas, nous avons utilisé un cluster avec 3 fragments, et chacun contient une seule réplique. - -Pour assurer la résilience dans un environnement de production, nous recommandons que chaque fragment contienne 2-3 répliques réparties entre plusieurs zones de disponibilité ou centres de données (ou au moins des racks). Notez que ClickHouse prend en charge un nombre illimité de répliques. - -Exemple de configuration pour un cluster d'un fragment contenant trois répliques: - -``` xml - - ... - - - - example-perftest01j.yandex.ru - 9000 - - - example-perftest02j.yandex.ru - 9000 - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -Pour activer la réplication native [ZooKeeper](http://zookeeper.apache.org/) est requis. ClickHouse s'occupe de la cohérence des données sur toutes les répliques et exécute automatiquement la procédure de restauration après l'échec. Il est recommandé de déployer le cluster ZooKeeper sur des serveurs séparés (où aucun autre processus, y compris ClickHouse, n'est en cours d'exécution). - -!!! note "Note" - ZooKeeper est pas une exigence stricte: dans certains cas simples, vous pouvez dupliquer les données par écrit dans tous les réplicas de votre code d'application. Cette approche est **pas** recommandé, dans ce cas, ClickHouse ne sera pas en mesure de garantir la cohérence des données sur toutes les répliques. Ainsi, il devient la responsabilité de votre application. - -Les emplacements ZooKeeper sont spécifiés dans le fichier de configuration: - -``` xml - - - zoo01.yandex.ru - 2181 - - - zoo02.yandex.ru - 2181 - - - zoo03.yandex.ru - 2181 - - -``` - -En outre, nous devons définir des macros pour identifier chaque fragment et chaque réplique utilisés lors de la création de la table: - -``` xml - - 01 - 01 - -``` - -S'il n'y a pas de répliques pour le moment lors de la création de la table répliquée, une nouvelle première réplique est instanciée. S'il existe déjà des répliques en direct, la nouvelle réplique clone les données de celles existantes. Vous avez la possibilité de créer toutes les tables répliquées d'abord, et ensuite insérer les données. Une autre option consiste à créer des répliques et à en ajouter d'autres Après ou pendant l'insertion des données. - -``` sql -CREATE TABLE tutorial.hits_replica (...) -ENGINE = ReplcatedMergeTree( - '/clickhouse_perftest/tables/{shard}/hits', - '{replica}' -) -... -``` - -Ici, nous utilisons [ReplicatedMergeTree](../engines/table_engines/mergetree_family/replication.md) tableau moteur. Dans les paramètres, nous spécifions le chemin Zookeeper contenant des identificateurs de fragments et de répliques. - -``` sql -INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; -``` - -La réplication fonctionne en mode multi-maître. Les données peuvent être chargées dans n'importe quel réplica, et le système les synchronise ensuite automatiquement avec d'autres instances. La réplication est asynchrone, donc à un moment donné, toutes les répliques ne peuvent pas contenir de données récemment insérées. Au moins une réplique devrait être en place pour permettre l'ingestion de données. D'autres synchroniseront les données et répareront la cohérence une fois qu'ils redeviendront actifs. Notez que cette approche permet une faible possibilité de perte de données récemment insérées. - -[Article Original](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/fr/guides/apply-catboost-model.md b/docs/fr/guides/apply-catboost-model.md new file mode 100644 index 00000000000..1b6aae9bbbd --- /dev/null +++ b/docs/fr/guides/apply-catboost-model.md @@ -0,0 +1,239 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "Application Des Mod\xE8les CatBoost" +--- + +# Application D'un modèle Catboost dans ClickHouse {#applying-catboost-model-in-clickhouse} + +[CatBoost](https://catboost.ai) est une bibliothèque de dynamisation de gradient libre et open-source développée à [Yandex](https://yandex.com/company/) pour l'apprentissage automatique. + +Avec cette instruction, vous apprendrez à appliquer des modèles pré-formés dans ClickHouse en exécutant l'inférence de modèle à partir de SQL. + +Pour appliquer un modèle CatBoost dans ClickHouse: + +1. [Créer une Table](#create-table). +2. [Insérez les données dans la Table](#insert-data-to-table). +3. [Intégrer CatBoost dans ClickHouse](#integrate-catboost-into-clickhouse) (Étape facultative). +4. [Exécutez L'inférence du modèle à partir de SQL](#run-model-inference). + +Pour plus d'informations sur la formation des modèles CatBoost, voir [Formation et application de modèles](https://catboost.ai/docs/features/training.html#training). + +## Préalable {#prerequisites} + +Si vous n'avez pas le [Docker](https://docs.docker.com/install/) pourtant, l'installer. + +!!! note "Note" + [Docker](https://www.docker.com) est une plate-forme logicielle qui vous permet de créer des conteneurs qui isolent une installation CatBoost et ClickHouse du reste du système. + +Avant d'appliquer un modèle CatBoost: + +**1.** Tirez la [Docker image](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) à partir du registre: + +``` bash +$ docker pull yandex/tutorial-catboost-clickhouse +``` + +Cette image Docker contient tout ce dont vous avez besoin pour exécuter CatBoost et ClickHouse: code, runtime, bibliothèques, variables d'environnement et fichiers de configuration. + +**2.** Assurez-vous que l'image Docker a été tirée avec succès: + +``` bash +$ docker image ls +REPOSITORY TAG IMAGE ID CREATED SIZE +yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB +``` + +**3.** Démarrer un conteneur Docker basé sur cette image: + +``` bash +$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse +``` + +## 1. Créer une Table {#create-table} + +Pour créer une table ClickHouse pour l'exemple de formation: + +**1.** Démarrez clickhouse console client en mode interactif: + +``` bash +$ clickhouse client +``` + +!!! note "Note" + Le serveur ClickHouse est déjà en cours d'exécution dans le conteneur Docker. + +**2.** Créer la table à l'aide de la commande: + +``` sql +:) CREATE TABLE amazon_train +( + date Date MATERIALIZED today(), + ACTION UInt8, + RESOURCE UInt32, + MGR_ID UInt32, + ROLE_ROLLUP_1 UInt32, + ROLE_ROLLUP_2 UInt32, + ROLE_DEPTNAME UInt32, + ROLE_TITLE UInt32, + ROLE_FAMILY_DESC UInt32, + ROLE_FAMILY UInt32, + ROLE_CODE UInt32 +) +ENGINE = MergeTree ORDER BY date +``` + +**3.** Quitter le client de la console ClickHouse: + +``` sql +:) exit +``` + +## 2. Insérez les données dans la Table {#insert-data-to-table} + +Pour insérer les données: + +**1.** Exécutez la commande suivante: + +``` bash +$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv +``` + +**2.** Démarrez clickhouse console client en mode interactif: + +``` bash +$ clickhouse client +``` + +**3.** Assurez-vous que les données ont été téléchargées: + +``` sql +:) SELECT count() FROM amazon_train + +SELECT count() +FROM amazon_train + ++-count()-+ +| 65538 | ++-------+ +``` + +## 3. Intégrer CatBoost dans ClickHouse {#integrate-catboost-into-clickhouse} + +!!! note "Note" + **Étape facultative.** L'image Docker contient tout ce dont vous avez besoin pour exécuter CatBoost et ClickHouse. + +Pour intégrer CatBoost dans ClickHouse: + +**1.** Construire la bibliothèque d'évaluation. + +Le moyen le plus rapide d'évaluer un modèle CatBoost est la compilation `libcatboostmodel.` bibliothèque. Pour plus d'informations sur la création de la bibliothèque, voir [Documentation CatBoost](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). + +**2.** Créez un nouveau répertoire n'importe où et avec n'importe quel nom, par exemple, `data` et mettez la bibliothèque créée dedans. L'image Docker contient déjà la bibliothèque `data/libcatboostmodel.so`. + +**3.** Créez un nouveau répertoire pour le modèle de configuration n'importe où et avec n'importe quel nom, par exemple, `models`. + +**4.** Créez un fichier de configuration de modèle avec n'importe quel nom, par exemple, `models/amazon_model.xml`. + +**5.** Décrire la configuration du modèle: + +``` xml + + + + catboost + + amazon + + /home/catboost/tutorial/catboost_model.bin + + 0 + + +``` + +**6.** Ajoutez le chemin D'accès à CatBoost et la configuration du modèle à la configuration de ClickHouse: + +``` xml + +/home/catboost/data/libcatboostmodel.so +/home/catboost/models/*_model.xml +``` + +## 4. Exécutez L'inférence du modèle à partir de SQL {#run-model-inference} + +Pour le modèle de test exécutez le client ClickHouse `$ clickhouse client`. + +Assurons nous que le modèle fonctionne: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) > 0 AS prediction, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Note" + Fonction [modelEvaluate](../sql-reference/functions/other-functions.md#function-modelevaluate) retourne tuple avec des prédictions brutes par classe pour les modèles multiclasse. + +Prédisons la probabilité: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1 + exp(-prediction)) AS probability, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Note" + Plus d'infos sur [exp()](../sql-reference/functions/math-functions.md) fonction. + +Calculons LogLoss sur l'échantillon: + +``` sql +:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss +FROM +( + SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1. + exp(-prediction)) AS prob, + ACTION AS tg + FROM amazon_train +) +``` + +!!! note "Note" + Plus d'infos sur [avg()](../sql-reference/aggregate-functions/reference.md#agg_function-avg) et [journal()](../sql-reference/functions/math-functions.md) fonction. + +[Article Original](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/fr/guides/apply_catboost_model.md b/docs/fr/guides/apply_catboost_model.md deleted file mode 100644 index 698f26d10d2..00000000000 --- a/docs/fr/guides/apply_catboost_model.md +++ /dev/null @@ -1,239 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 41 -toc_title: "Application Des Mod\xE8les CatBoost" ---- - -# Application D'un modèle Catboost dans ClickHouse {#applying-catboost-model-in-clickhouse} - -[CatBoost](https://catboost.ai) est une bibliothèque de dynamisation de gradient libre et open-source développée à [Yandex](https://yandex.com/company/) pour l'apprentissage automatique. - -Avec cette instruction, vous apprendrez à appliquer des modèles pré-formés dans ClickHouse en exécutant l'inférence de modèle à partir de SQL. - -Pour appliquer un modèle CatBoost dans ClickHouse: - -1. [Créer une Table](#create-table). -2. [Insérez les données dans la Table](#insert-data-to-table). -3. [Intégrer CatBoost dans ClickHouse](#integrate-catboost-into-clickhouse) (Étape facultative). -4. [Exécutez L'inférence du modèle à partir de SQL](#run-model-inference). - -Pour plus d'informations sur la formation des modèles CatBoost, voir [Formation et application de modèles](https://catboost.ai/docs/features/training.html#training). - -## Préalable {#prerequisites} - -Si vous n'avez pas le [Docker](https://docs.docker.com/install/) pourtant, l'installer. - -!!! note "Note" - [Docker](https://www.docker.com) est une plate-forme logicielle qui vous permet de créer des conteneurs qui isolent une installation CatBoost et ClickHouse du reste du système. - -Avant d'appliquer un modèle CatBoost: - -**1.** Tirez la [Docker image](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) à partir du registre: - -``` bash -$ docker pull yandex/tutorial-catboost-clickhouse -``` - -Cette image Docker contient tout ce dont vous avez besoin pour exécuter CatBoost et ClickHouse: code, runtime, bibliothèques, variables d'environnement et fichiers de configuration. - -**2.** Assurez-vous que l'image Docker a été tirée avec succès: - -``` bash -$ docker image ls -REPOSITORY TAG IMAGE ID CREATED SIZE -yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB -``` - -**3.** Démarrer un conteneur Docker basé sur cette image: - -``` bash -$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse -``` - -## 1. Créer une Table {#create-table} - -Pour créer une table ClickHouse pour l'exemple de formation: - -**1.** Démarrez clickhouse console client en mode interactif: - -``` bash -$ clickhouse client -``` - -!!! note "Note" - Le serveur ClickHouse est déjà en cours d'exécution dans le conteneur Docker. - -**2.** Créer la table à l'aide de la commande: - -``` sql -:) CREATE TABLE amazon_train -( - date Date MATERIALIZED today(), - ACTION UInt8, - RESOURCE UInt32, - MGR_ID UInt32, - ROLE_ROLLUP_1 UInt32, - ROLE_ROLLUP_2 UInt32, - ROLE_DEPTNAME UInt32, - ROLE_TITLE UInt32, - ROLE_FAMILY_DESC UInt32, - ROLE_FAMILY UInt32, - ROLE_CODE UInt32 -) -ENGINE = MergeTree ORDER BY date -``` - -**3.** Quitter le client de la console ClickHouse: - -``` sql -:) exit -``` - -## 2. Insérez les données dans la Table {#insert-data-to-table} - -Pour insérer les données: - -**1.** Exécutez la commande suivante: - -``` bash -$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv -``` - -**2.** Démarrez clickhouse console client en mode interactif: - -``` bash -$ clickhouse client -``` - -**3.** Assurez-vous que les données ont été téléchargées: - -``` sql -:) SELECT count() FROM amazon_train - -SELECT count() -FROM amazon_train - -+-count()-+ -| 65538 | -+-------+ -``` - -## 3. Intégrer CatBoost dans ClickHouse {#integrate-catboost-into-clickhouse} - -!!! note "Note" - **Étape facultative.** L'image Docker contient tout ce dont vous avez besoin pour exécuter CatBoost et ClickHouse. - -Pour intégrer CatBoost dans ClickHouse: - -**1.** Construire la bibliothèque d'évaluation. - -Le moyen le plus rapide d'évaluer un modèle CatBoost est la compilation `libcatboostmodel.` bibliothèque. Pour plus d'informations sur la création de la bibliothèque, voir [Documentation CatBoost](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). - -**2.** Créez un nouveau répertoire n'importe où et avec n'importe quel nom, par exemple, `data` et mettez la bibliothèque créée dedans. L'image Docker contient déjà la bibliothèque `data/libcatboostmodel.so`. - -**3.** Créez un nouveau répertoire pour le modèle de configuration n'importe où et avec n'importe quel nom, par exemple, `models`. - -**4.** Créez un fichier de configuration de modèle avec n'importe quel nom, par exemple, `models/amazon_model.xml`. - -**5.** Décrire la configuration du modèle: - -``` xml - - - - catboost - - amazon - - /home/catboost/tutorial/catboost_model.bin - - 0 - - -``` - -**6.** Ajoutez le chemin D'accès à CatBoost et la configuration du modèle à la configuration de ClickHouse: - -``` xml - -/home/catboost/data/libcatboostmodel.so -/home/catboost/models/*_model.xml -``` - -## 4. Exécutez L'inférence du modèle à partir de SQL {#run-model-inference} - -Pour le modèle de test exécutez le client ClickHouse `$ clickhouse client`. - -Assurons nous que le modèle fonctionne: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) > 0 AS prediction, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Note" - Fonction [modelEvaluate](../sql_reference/functions/other_functions.md#function-modelevaluate) retourne tuple avec des prédictions brutes par classe pour les modèles multiclasse. - -Prédisons la probabilité: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1 + exp(-prediction)) AS probability, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Note" - Plus d'infos sur [exp()](../sql_reference/functions/math_functions.md) fonction. - -Calculons LogLoss sur l'échantillon: - -``` sql -:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss -FROM -( - SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1. + exp(-prediction)) AS prob, - ACTION AS tg - FROM amazon_train -) -``` - -!!! note "Note" - Plus d'infos sur [avg()](../sql_reference/aggregate_functions/reference.md#agg_function-avg) et [journal()](../sql_reference/functions/math_functions.md) fonction. - -[Article Original](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/fr/guides/index.md b/docs/fr/guides/index.md index 1149406b662..5f6552fdb45 100644 --- a/docs/fr/guides/index.md +++ b/docs/fr/guides/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Guides +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Guide toc_priority: 38 toc_title: "Aper\xE7u" --- @@ -10,7 +10,7 @@ toc_title: "Aper\xE7u" Liste des instructions détaillées étape par étape qui aident à résoudre diverses tâches en utilisant ClickHouse: -- [Tutoriel sur la configuration simple du cluster](../getting_started/tutorial.md) -- [Application D'un modèle CatBoost dans ClickHouse](apply_catboost_model.md) +- [Tutoriel sur la configuration simple du cluster](../getting-started/tutorial.md) +- [Application D'un modèle CatBoost dans ClickHouse](apply-catboost-model.md) [Article Original](https://clickhouse.tech/docs/en/guides/) diff --git a/docs/fr/index.md b/docs/fr/index.md index bcdeda0a693..fe714af8d49 100644 --- a/docs/fr/index.md +++ b/docs/fr/index.md @@ -1,11 +1,11 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 3 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 0 toc_title: "Aper\xE7u" --- -# Qu'est-ce que ClickHouse? {#what-is-clickhouse} +# Qu'Est-Ce Que ClickHouse? {#what-is-clickhouse} ClickHouse est un système de gestion de base de données orienté colonne (SGBD) pour le traitement analytique en ligne des requêtes (OLAP). @@ -64,11 +64,11 @@ Les bases de données orientées colonne sont mieux adaptées aux scénarios OLA **SGBD orienté ligne** -![Row-oriented](images/row_oriented.gif#) +![Row-oriented](images/row-oriented.gif#) **SGBD orienté colonne** -![Column-oriented](images/column_oriented.gif#) +![Column-oriented](images/column-oriented.gif#) Vous voyez la différence? diff --git a/docs/fr/interfaces/cli.md b/docs/fr/interfaces/cli.md index 118dc40ce7d..5b8ee67c31a 100644 --- a/docs/fr/interfaces/cli.md +++ b/docs/fr/interfaces/cli.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 17 toc_title: Client De Ligne De Commande --- @@ -9,7 +9,7 @@ toc_title: Client De Ligne De Commande ClickHouse fournit un client de ligne de commande natif: `clickhouse-client`. Le client prend en charge les options de ligne de commande et les fichiers de configuration. Pour plus d'informations, voir [Configuration](#interfaces_cli_configuration). -[Installer](../getting_started/index.md) à partir de la `clickhouse-client` package et l'exécuter avec la commande `clickhouse-client`. +[Installer](../getting-started/index.md) à partir de la `clickhouse-client` package et l'exécuter avec la commande `clickhouse-client`. ``` bash $ clickhouse-client @@ -89,7 +89,7 @@ Formatez une requête comme d'habitude, puis placez les valeurs que vous souhait ``` - `name` — Placeholder identifier. In the console client it should be used in app parameters as `--param_ = value`. -- `data type` — [Type de données](../sql_reference/data_types/index.md) de l'application valeur de paramètre. Par exemple, une structure de données comme `(integer, ('string', integer))` peut avoir la `Tuple(UInt8, Tuple(String, UInt8))` type de données (vous pouvez également utiliser un autre [entier](../sql_reference/data_types/int_uint.md) type). +- `data type` — [Type de données](../sql-reference/data-types/index.md) de l'application valeur de paramètre. Par exemple, une structure de données comme `(integer, ('string', integer))` peut avoir la `Tuple(UInt8, Tuple(String, UInt8))` type de données (vous pouvez également utiliser un autre [entier](../sql-reference/data-types/int-uint.md) type). #### Exemple {#example} diff --git a/docs/fr/interfaces/cpp.md b/docs/fr/interfaces/cpp.md index 7863e448ad6..0451b0722aa 100644 --- a/docs/fr/interfaces/cpp.md +++ b/docs/fr/interfaces/cpp.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 24 toc_title: "Biblioth\xE8que Client C++ " --- diff --git a/docs/fr/interfaces/formats.md b/docs/fr/interfaces/formats.md index 590812fe59c..13419cf6c35 100644 --- a/docs/fr/interfaces/formats.md +++ b/docs/fr/interfaces/formats.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 21 toc_title: "Formats d'entr\xE9e et de sortie" --- @@ -110,9 +110,9 @@ Seul un petit ensemble de symboles sont échappés. Vous pouvez facilement tombe Les tableaux sont écrits sous la forme d'une liste de valeurs séparées par des virgules entre crochets. Le nombre d'éléments dans le tableau sont formatés comme normalement. `Date` et `DateTime` les types sont écrits entre guillemets simples. Les chaînes sont écrites entre guillemets simples avec les mêmes règles d'échappement que ci-dessus. -[NULL](../sql_reference/syntax.md) est formaté en tant qu' `\N`. +[NULL](../sql-reference/syntax.md) est formaté en tant qu' `\N`. -Chaque élément de [Imbriqué](../sql_reference/data_types/nested_data_structures/nested.md) structures est représenté sous forme de tableau. +Chaque élément de [Imbriqué](../sql-reference/data-types/nested-data-structures/nested.md) structures est représenté sous forme de tableau. Exemple: @@ -332,7 +332,7 @@ SearchPhrase=curtain designs count()=1064 SearchPhrase=baku count()=1000 ``` -[NULL](../sql_reference/syntax.md) est formaté en tant qu' `\N`. +[NULL](../sql-reference/syntax.md) est formaté en tant qu' `\N`. ``` sql SELECT * FROM t_null FORMAT TSKV @@ -464,7 +464,7 @@ Si la requête contient GROUP BY, rows\_before\_limit\_at\_least est le nombre e Ce format n'est approprié que pour la sortie d'un résultat de requête, mais pas pour l'analyse (récupération des données à insérer dans une table). -Supports ClickHouse [NULL](../sql_reference/syntax.md) s'affiche à l'écran `null` dans la sortie JSON. +Supports ClickHouse [NULL](../sql-reference/syntax.md) s'affiche à l'écran `null` dans la sortie JSON. Voir aussi l' [JSONEachRow](#jsoneachrow) format. @@ -541,7 +541,7 @@ ClickHouse ignore les espaces entre les éléments et les virgules après les ob **Valeurs omises traitement** -Clickhouse remplace les valeurs omises par les valeurs par défaut pour le [types de données](../sql_reference/data_types/index.md). +Clickhouse remplace les valeurs omises par les valeurs par défaut pour le [types de données](../sql-reference/data-types/index.md). Si `DEFAULT expr` clickhouse utilise différentes règles de substitution en fonction de [input\_format\_defaults\_for\_omitted\_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields) paramètre. @@ -586,7 +586,7 @@ Contrairement à l' [JSON](#json) format, il n'y a pas de substitution de séque ### Utilisation de Structures imbriquées {#jsoneachrow-nested} -Si vous avez une table avec [Imbriqué](../sql_reference/data_types/nested_data_structures/nested.md) colonnes de type de données, vous pouvez insérer des données JSON avec la même structure. Activer cette fonctionnalité avec le [input\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) paramètre. +Si vous avez une table avec [Imbriqué](../sql-reference/data-types/nested-data-structures/nested.md) colonnes de type de données, vous pouvez insérer des données JSON avec la même structure. Activer cette fonctionnalité avec le [input\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) paramètre. Par exemple, considérez le tableau suivant: @@ -660,7 +660,7 @@ Affiche les données sous forme de tables Unicode-art, en utilisant également d Une grille complète de la table est dessinée, et chaque ligne occupe deux lignes dans le terminal. Chaque bloc de résultat est sorti sous la forme d'une table séparée. Ceci est nécessaire pour que les blocs puissent être sortis sans résultats de mise en mémoire tampon (la mise en mémoire tampon serait nécessaire pour pré-calculer la largeur visible de toutes les valeurs). -[NULL](../sql_reference/syntax.md) est sortie `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) est sortie `ᴺᵁᴸᴸ`. Exemple (montré pour le [PrettyCompact](#prettycompact) format): @@ -764,7 +764,7 @@ FixedString est représenté simplement comme une séquence d'octets. Le tableau est représenté sous la forme d'une longueur varint (non signée [LEB128](https://en.wikipedia.org/wiki/LEB128)), suivie par les éléments de la matrice. -Pour [NULL](../sql_reference/syntax.md#null-literal) un soutien, un octet supplémentaire contenant 1 ou 0 est ajouté avant chaque [Nullable](../sql_reference/data_types/nullable.md) valeur. Si la valeur est 1, alors la valeur est `NULL` et cet octet est interprétée comme une valeur distincte. Si 0, la valeur après l'octet n'est pas `NULL`. +Pour [NULL](../sql-reference/syntax.md#null-literal) un soutien, un octet supplémentaire contenant 1 ou 0 est ajouté avant chaque [Nullable](../sql-reference/data-types/nullable.md) valeur. Si la valeur est 1, alors la valeur est `NULL` et cet octet est interprétée comme une valeur distincte. Si 0, la valeur après l'octet n'est pas `NULL`. ## Rowbinarywithnamesettypes {#rowbinarywithnamesandtypes} @@ -776,7 +776,7 @@ Semblable à [RowBinary](#rowbinary) mais avec l'ajout de l'en-tête: ## Valeur {#data-format-values} -Imprime chaque ligne entre parenthèses. Les lignes sont séparées par des virgules. Il n'y a pas de virgule après la dernière ligne. Les valeurs entre parenthèses sont également séparées par des virgules. Les nombres sont produits dans un format décimal sans guillemets. Les tableaux sont affichés entre crochets. Les chaînes, les dates et les dates avec des heures sont affichées entre guillemets. Les règles d'échappement et l'analyse sont similaires à [TabSeparated](#tabseparated) format. Pendant le formatage, les espaces supplémentaires ne sont pas insérés, mais pendant l'analyse, ils sont autorisés et ignorés (sauf pour les espaces à l'intérieur des valeurs de tableau, qui ne sont pas autorisés). [NULL](../sql_reference/syntax.md) est représentée comme `NULL`. +Imprime chaque ligne entre parenthèses. Les lignes sont séparées par des virgules. Il n'y a pas de virgule après la dernière ligne. Les valeurs entre parenthèses sont également séparées par des virgules. Les nombres sont produits dans un format décimal sans guillemets. Les tableaux sont affichés entre crochets. Les chaînes, les dates et les dates avec des heures sont affichées entre guillemets. Les règles d'échappement et l'analyse sont similaires à [TabSeparated](#tabseparated) format. Pendant le formatage, les espaces supplémentaires ne sont pas insérés, mais pendant l'analyse, ils sont autorisés et ignorés (sauf pour les espaces à l'intérieur des valeurs de tableau, qui ne sont pas autorisés). [NULL](../sql-reference/syntax.md) est représentée comme `NULL`. The minimum set of characters that you need to escape when passing data in Values ​​format: single quotes and backslashes. @@ -788,7 +788,7 @@ Voir aussi: [input\_format\_values\_interpret\_expressions](../operations/settin Imprime chaque valeur sur une ligne distincte avec le nom de colonne spécifié. Ce format est pratique pour imprimer une ou plusieurs lignes si chaque ligne est constituée d'un grand nombre de colonnes. -[NULL](../sql_reference/syntax.md) est sortie `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) est sortie `ᴺᵁᴸᴸ`. Exemple: @@ -967,7 +967,7 @@ message MessageType { ``` ClickHouse tente de trouver une colonne nommée `x.y.z` (ou `x_y_z` ou `X.y_Z` et ainsi de suite). -Les messages imbriqués conviennent à l'entrée ou à la sortie d'un [structures de données imbriquées](../sql_reference/data_types/nested_data_structures/nested.md). +Les messages imbriqués conviennent à l'entrée ou à la sortie d'un [structures de données imbriquées](../sql-reference/data-types/nested-data-structures/nested.md). Valeurs par défaut définies dans un schéma protobuf comme ceci @@ -979,7 +979,7 @@ message MessageType { } ``` -ne sont pas appliquées; la [valeurs par défaut de la table](../sql_reference/statements/create.md#create-default-values) sont utilisés à leur place. +ne sont pas appliquées; la [valeurs par défaut de la table](../sql-reference/statements/create.md#create-default-values) sont utilisés à leur place. Clickhouse entrées et sorties messages protobuf dans le `length-delimited` format. Cela signifie avant que chaque message devrait être écrit sa longueur comme un [varint](https://developers.google.com/protocol-buffers/docs/encoding#varints). @@ -993,23 +993,23 @@ ClickHouse Avro format prend en charge la lecture et l'écriture [Fichiers de do ### Types De Données Correspondant {#data_types-matching} -Le tableau ci-dessous montre les types de données pris en charge et comment ils correspondent à ClickHouse [types de données](../sql_reference/data_types/index.md) dans `INSERT` et `SELECT` requête. +Le tableau ci-dessous montre les types de données pris en charge et comment ils correspondent à ClickHouse [types de données](../sql-reference/data-types/index.md) dans `INSERT` et `SELECT` requête. | Type de données Avro `INSERT` | Type de données ClickHouse | Type de données Avro `SELECT` | |---------------------------------------------|---------------------------------------------------------------------------------------------------------------------|-------------------------------| -| `boolean`, `int`, `long`, `float`, `double` | [Int (8/16/32)](../sql_reference/data_types/int_uint.md), [UInt (8/16/32)](../sql_reference/data_types/int_uint.md) | `int` | -| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql_reference/data_types/int_uint.md), [UInt64](../sql_reference/data_types/int_uint.md) | `long` | -| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql_reference/data_types/float.md) | `float` | -| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql_reference/data_types/float.md) | `double` | -| `bytes`, `string`, `fixed`, `enum` | [Chaîne](../sql_reference/data_types/string.md) | `bytes` | -| `bytes`, `string`, `fixed` | [FixedString (N)](../sql_reference/data_types/fixedstring.md) | `fixed(N)` | -| `enum` | [Enum (8/16)](../sql_reference/data_types/enum.md) | `enum` | -| `array(T)` | [Array(T)](../sql_reference/data_types/array.md) | `array(T)` | -| `union(null, T)`, `union(T, null)` | [Nullable (T)](../sql_reference/data_types/date.md) | `union(null, T)` | -| `null` | [Les Valeurs Null(Nothing)](../sql_reference/data_types/special_data_types/nothing.md) | `null` | -| `int (date)` \* | [Date](../sql_reference/data_types/date.md) | `int (date)` \* | -| `long (timestamp-millis)` \* | [DateTime64 (3)](../sql_reference/data_types/datetime.md) | `long (timestamp-millis)` \* | -| `long (timestamp-micros)` \* | [DateTime64 (6)](../sql_reference/data_types/datetime.md) | `long (timestamp-micros)` \* | +| `boolean`, `int`, `long`, `float`, `double` | [Int (8/16/32)](../sql-reference/data-types/int-uint.md), [UInt (8/16/32)](../sql-reference/data-types/int-uint.md) | `int` | +| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql-reference/data-types/int-uint.md), [UInt64](../sql-reference/data-types/int-uint.md) | `long` | +| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql-reference/data-types/float.md) | `float` | +| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql-reference/data-types/float.md) | `double` | +| `bytes`, `string`, `fixed`, `enum` | [Chaîne](../sql-reference/data-types/string.md) | `bytes` | +| `bytes`, `string`, `fixed` | [FixedString (N)](../sql-reference/data-types/fixedstring.md) | `fixed(N)` | +| `enum` | [Enum (8/16)](../sql-reference/data-types/enum.md) | `enum` | +| `array(T)` | [Array(T)](../sql-reference/data-types/array.md) | `array(T)` | +| `union(null, T)`, `union(T, null)` | [Nullable (T)](../sql-reference/data-types/date.md) | `union(null, T)` | +| `null` | [Les Valeurs Null(Nothing)](../sql-reference/data-types/special-data-types/nothing.md) | `null` | +| `int (date)` \* | [Date](../sql-reference/data-types/date.md) | `int (date)` \* | +| `long (timestamp-millis)` \* | [DateTime64 (3)](../sql-reference/data-types/datetime.md) | `long (timestamp-millis)` \* | +| `long (timestamp-micros)` \* | [DateTime64 (6)](../sql-reference/data-types/datetime.md) | `long (timestamp-micros)` \* | \* [Types logiques Avro](http://avro.apache.org/docs/current/spec.html#Logical+Types) @@ -1030,7 +1030,7 @@ Le schéma racine du fichier Avro d'entrée doit être de `record` type. Pour trouver la correspondance entre les colonnes de table et les champs du schéma Avro ClickHouse compare leurs noms. Cette comparaison est sensible à la casse. Les champs inutilisés sont ignorés. -Les types de données des colonnes de la table ClickHouse peuvent différer des champs correspondants des données Avro insérées. Lors de l'insertion de données, ClickHouse interprète les types de données selon le tableau ci-dessus, puis [jeter](../query_language/functions/type_conversion_functions/#type_conversion_function-cast) les données au type de colonne correspondant. +Les types de données des colonnes de la table ClickHouse peuvent différer des champs correspondants des données Avro insérées. Lors de l'insertion de données, ClickHouse interprète les types de données selon le tableau ci-dessus, puis [jeter](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) les données au type de colonne correspondant. ### La Sélection De Données {#selecting-data-1} @@ -1072,7 +1072,7 @@ $ kafkacat -b kafka-broker -C -t topic1 -o beginning -f '%s' -c 3 | clickhouse- 3 c ``` -Utiliser `AvroConfluent` avec [Kafka](../engines/table_engines/integrations/kafka.md): +Utiliser `AvroConfluent` avec [Kafka](../engines/table-engines/integrations/kafka.md): ``` sql CREATE TABLE topic1_stream @@ -1101,25 +1101,25 @@ SELECT * FROM topic1_stream; ### Types De Données Correspondant {#data_types-matching-2} -Le tableau ci-dessous montre les types de données pris en charge et comment ils correspondent à ClickHouse [types de données](../sql_reference/data_types/index.md) dans `INSERT` et `SELECT` requête. +Le tableau ci-dessous montre les types de données pris en charge et comment ils correspondent à ClickHouse [types de données](../sql-reference/data-types/index.md) dans `INSERT` et `SELECT` requête. | Type de données Parquet (`INSERT`) | Type de données ClickHouse | Type de données Parquet (`SELECT`) | |------------------------------------|-----------------------------------------------------------|------------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | `UINT8` | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | `INT8` | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | `UINT16` | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | `INT16` | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | `UINT32` | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | `INT32` | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | `UINT64` | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | `INT64` | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | `FLOAT` | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | `DOUBLE` | -| `DATE32` | [Date](../sql_reference/data_types/date.md) | `UINT16` | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | `UINT32` | -| `STRING`, `BINARY` | [Chaîne](../sql_reference/data_types/string.md) | `STRING` | -| — | [FixedString](../sql_reference/data_types/fixedstring.md) | `STRING` | -| `DECIMAL` | [Décimal](../sql_reference/data_types/decimal.md) | `DECIMAL` | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | `UINT8` | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | `INT8` | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | `UINT16` | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | `INT16` | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | `UINT32` | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | `INT32` | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | `UINT64` | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | `INT64` | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | `FLOAT` | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | `DOUBLE` | +| `DATE32` | [Date](../sql-reference/data-types/date.md) | `UINT16` | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | `UINT32` | +| `STRING`, `BINARY` | [Chaîne](../sql-reference/data-types/string.md) | `STRING` | +| — | [FixedString](../sql-reference/data-types/fixedstring.md) | `STRING` | +| `DECIMAL` | [Décimal](../sql-reference/data-types/decimal.md) | `DECIMAL` | Clickhouse prend en charge la précision configurable de `Decimal` type. Le `INSERT` requête traite le Parquet `DECIMAL` tapez comme le ClickHouse `Decimal128` type. @@ -1141,7 +1141,7 @@ Vous pouvez sélectionner des données à partir d'une table de ClickHouse et le $ clickhouse-client --query="SELECT * FROM {some_table} FORMAT Parquet" > {some_file.pq} ``` -Pour échanger des données avec Hadoop, vous pouvez utiliser [Moteur de table HDFS](../engines/table_engines/integrations/hdfs.md). +Pour échanger des données avec Hadoop, vous pouvez utiliser [Moteur de table HDFS](../engines/table-engines/integrations/hdfs.md). ## ORC {#data-format-orc} @@ -1149,30 +1149,30 @@ Pour échanger des données avec Hadoop, vous pouvez utiliser [Moteur de table H ### Types De Données Correspondant {#data_types-matching-3} -Le tableau ci-dessous montre les types de données pris en charge et comment ils correspondent à ClickHouse [types de données](../sql_reference/data_types/index.md) dans `INSERT` requête. +Le tableau ci-dessous montre les types de données pris en charge et comment ils correspondent à ClickHouse [types de données](../sql-reference/data-types/index.md) dans `INSERT` requête. | Type de données ORC (`INSERT`) | Type de données ClickHouse | |--------------------------------|-----------------------------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | -| `DATE32` | [Date](../sql_reference/data_types/date.md) | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | -| `STRING`, `BINARY` | [Chaîne](../sql_reference/data_types/string.md) | -| `DECIMAL` | [Décimal](../sql_reference/data_types/decimal.md) | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE32` | [Date](../sql-reference/data-types/date.md) | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | +| `STRING`, `BINARY` | [Chaîne](../sql-reference/data-types/string.md) | +| `DECIMAL` | [Décimal](../sql-reference/data-types/decimal.md) | Clickhouse prend en charge la précision configurable de la `Decimal` type. Le `INSERT` requête traite de l'ORC `DECIMAL` tapez comme le ClickHouse `Decimal128` type. Types de données ORC non pris en charge: `DATE32`, `TIME32`, `FIXED_SIZE_BINARY`, `JSON`, `UUID`, `ENUM`. -Les types de données des colonnes de la table ClickHouse ne doivent pas correspondre aux champs de données Orc correspondants. Lors de l'insertion de données, ClickHouse interprète les types de données selon le tableau ci-dessus, puis [jeter](../query_language/functions/type_conversion_functions/#type_conversion_function-cast) les données du type de données défini pour la colonne clickhouse table. +Les types de données des colonnes de la table ClickHouse ne doivent pas correspondre aux champs de données Orc correspondants. Lors de l'insertion de données, ClickHouse interprète les types de données selon le tableau ci-dessus, puis [jeter](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) les données du type de données défini pour la colonne clickhouse table. ### Insertion De Données {#inserting-data-2} @@ -1182,7 +1182,7 @@ Vous pouvez insérer des données ORC à partir d'un fichier dans la table Click $ cat filename.orc | clickhouse-client --query="INSERT INTO some_table FORMAT ORC" ``` -Pour échanger des données avec Hadoop, vous pouvez utiliser [Moteur de table HDFS](../engines/table_engines/integrations/hdfs.md). +Pour échanger des données avec Hadoop, vous pouvez utiliser [Moteur de table HDFS](../engines/table-engines/integrations/hdfs.md). ## Schéma De Format {#formatschema} @@ -1198,7 +1198,7 @@ peut contenir un chemin absolu, soit un chemin relatif au répertoire courant su Si vous utilisez le client dans le [mode batch](../interfaces/cli.md#cli_usage), le chemin d'accès au schéma doit être relatif pour des raisons de sécurité. Si vous entrez ou sortez des données via le [Interface HTTP](../interfaces/http.md) le nom de fichier spécifié dans le format de schéma -doit être situé dans le répertoire spécifié dans [format\_schema\_path](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-format_schema_path) +doit être situé dans le répertoire spécifié dans [format\_schema\_path](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-format_schema_path) dans la configuration du serveur. ## Sauter Les Erreurs {#skippingerrors} diff --git a/docs/fr/interfaces/http.md b/docs/fr/interfaces/http.md index bd90f511841..2de32747d4a 100644 --- a/docs/fr/interfaces/http.md +++ b/docs/fr/interfaces/http.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 19 toc_title: Interface HTTP --- @@ -11,7 +11,7 @@ L'interface HTTP vous permet D'utiliser ClickHouse sur n'importe quelle plate-fo Par défaut, clickhouse-server écoute HTTP sur le port 8123 (cela peut être modifié dans la configuration). -Si vous faites une requête GET / sans Paramètres, elle renvoie le code de réponse 200 et la chaîne définie dans [http\_server\_default\_response](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-http_server_default_response) valeur par défaut “Ok.” (avec un saut de ligne à la fin) +Si vous faites une requête GET / sans Paramètres, elle renvoie le code de réponse 200 et la chaîne définie dans [http\_server\_default\_response](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-http_server_default_response) valeur par défaut “Ok.” (avec un saut de ligne à la fin) ``` bash $ curl 'http://localhost:8123/' @@ -303,13 +303,16 @@ Exemple: ``` xml - - /metrics - GET - + + /predefined_query + POST,GET + + predefined_query_handler SELECT * FROM system.metrics LIMIT 5 FORMAT Template SETTINGS format_template_resultset = 'prometheus_template_output_format_resultset', format_template_row = 'prometheus_template_output_format_row', format_template_rows_between_delimiter = '\n' - - + + + ... + ... ``` @@ -318,21 +321,23 @@ Exemple: ``` bash -curl -vvv 'http://localhost:8123/metrics' +$ curl -v 'http://localhost:8123/predefined_query' * Trying ::1... * Connected to localhost (::1) port 8123 (#0) -> GET /metrics HTTP/1.1 +> GET /predefined_query HTTP/1.1 > Host: localhost:8123 > User-Agent: curl/7.47.0 > Accept: */* > < HTTP/1.1 200 OK -< Date: Wed, 27 Nov 2019 08:54:25 GMT +< Date: Tue, 28 Apr 2020 08:52:56 GMT < Connection: Keep-Alive < Content-Type: text/plain; charset=UTF-8 -< X-ClickHouse-Server-Display-Name: i-tl62qd0o +< X-ClickHouse-Server-Display-Name: i-mloy5trc < Transfer-Encoding: chunked -< X-ClickHouse-Query-Id: f39235f6-6ed7-488c-ae07-c7ceafb960f6 +< X-ClickHouse-Query-Id: 96fe0052-01e6-43ce-b12a-6b7370de6e8a +< X-ClickHouse-Format: Template +< X-ClickHouse-Timezone: Asia/Shanghai < Keep-Alive: timeout=3 < X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} < @@ -356,117 +361,62 @@ curl -vvv 'http://localhost:8123/metrics' # TYPE "ReplicatedSend" counter "ReplicatedSend" 0 +* Connection #0 to host localhost left intact + + * Connection #0 to host localhost left intact ``` -Comme vous pouvez le voir dans l'exemple, si `` est configuré dans la configuration.fichier xml, ClickHouse fera correspondre les requêtes HTTP reçues au type prédéfini dans ``, puis ClickHouse exécutera la requête prédéfinie correspondante si la correspondance est réussie. +Comme vous pouvez le voir dans l'exemple, si `` est configuré dans la configuration.fichier xml et `` peut contenir beaucoup `s`. ClickHouse fera correspondre les requêtes HTTP reçues au type prédéfini `` et la première appariés exécute le gestionnaire. Ensuite, ClickHouse exécutera la requête prédéfinie correspondante si la correspondance est réussie. -Maintenant `` pouvez configurer ``, ``, ``, `` et `` . +> Maintenant `` pouvez configurer ``, ``, ``,``: +> `` est responsable de la correspondance de la partie méthode de la requête HTTP. `` entièrement conforme à la définition de [méthode](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) dans le protocole HTTP. C'est une option de configuration. S'il n'est pas défini dans le fichier de configuration, il ne correspond pas à la partie méthode de la requête HTTP. +> +> `` est responsable de la correspondance de la partie url de la requête HTTP. Il est compatible avec [RE2](https://github.com/google/re2)s 'expressions régulières. C'est une option de configuration. S'il n'est pas défini dans le fichier de configuration, il ne correspond pas à la partie url de la requête HTTP. +> +> `` est responsable de la correspondance de la partie d'en-tête de la requête HTTP. Il est compatible avec les expressions régulières de RE2. C'est une option de configuration. S'il n'est pas défini dans le fichier de configuration, il ne correspond pas à la partie d'en-tête de la requête HTTP. +> +> `` contient la partie de traitement principale. Maintenant `` pouvez configurer ``, ``, ``, ``, ``, ``. +> \> `` prend actuellement en charge trois types: **predefined\_query\_handler**, **dynamic\_query\_handler**, **statique**. +> \> +> \> `` - utiliser avec le type predefined\_query\_handler, exécute la requête lorsque le gestionnaire est appelé. +> \> +> \> `` - utiliser avec le type dynamic\_query\_handler, extrait et exécute la valeur correspondant au `` valeur dans les paramètres de requête HTTP. +> \> +> \> `` - utiliser avec le type statique, code d'état de réponse. +> \> +> \> `` - utiliser avec statique type, réponse [content-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type). +> \> +> \> `` - utiliser avec le type statique, le contenu de la réponse envoyé au client, lors de l'utilisation du préfixe ‘file://’ ou ‘config://’, trouver le contenu du fichier ou de la configuration envoyer au client. -## root\_handler {#root_handler} - -`` renvoie le contenu spécifié pour la requête de chemin racine. Le contenu de retour spécifique est configuré par `http_server_default_response` dans la configuration.XML. si non spécifié, le retour **OK.** - -`http_server_default_response` n'est pas défini et une requête HTTP est envoyée à ClickHouse. Le résultat est comme suit: - -``` xml - - - -``` - - $ curl 'http://localhost:8123' - Ok. - -`http_server_default_response` est défini et une requête HTTP est envoyée à ClickHouse. Le résultat est comme suit: - -``` xml -
]]>
- - - - -``` - - $ curl 'http://localhost:8123' -
% - -## ping\_handler {#ping_handler} - -`` peut être utilisé pour sonder la santé du serveur clickhouse actuel. Lorsque le serveur HTTP ClickHouse est normal, l'accès à ClickHouse via `` sera de retour **OK.**. - -Exemple: - -``` xml - - /ping - -``` - -``` bash -$ curl 'http://localhost:8123/ping' -Ok. -``` - -## replicas\_status\_handler {#replicas_status_handler} - -`` est utilisé pour détecter l'état du nœud de réplica et le retour **OK.** si le nœud réplique n'a pas de délai. S'il y a un retard, renvoyez le retard spécifique. La valeur de `` prend en charge la personnalisation. Si vous ne spécifiez pas ``, ClickHouse réglage par défaut `` être **/ replicas\_status**. - -Exemple: - -``` xml - - /replicas_status - -``` - -Aucun retard de cas: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -Ok. -``` - -Retard de cas: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -db.stats: Absolute delay: 22. Relative delay: 22. -``` +Viennent ensuite les méthodes de configuration pour les différents ``. ## predefined\_query\_handler {#predefined_query_handler} -Vous pouvez configurer ``, ``, `` et `` dans ``. +`` prend en charge les paramètres de réglage et les valeurs query\_params. Vous pouvez configurer `` dans le type de ``. -`` est responsable de la correspondance de la partie méthode de la requête HTTP. `` entièrement conforme à la définition de [méthode](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) dans le protocole HTTP. C'est une option de configuration. S'il n'est pas défini dans le fichier de configuration, il ne correspond pas à la partie méthode de la requête HTTP - -`` est responsable de la correspondance de la partie url de la requête HTTP. Il est compatible avec [RE2](https://github.com/google/re2)s 'expressions régulières. C'est une option de configuration. S'il n'est pas défini dans le fichier de configuration, il ne correspond pas à la partie url de la requête HTTP - -`` est responsable de la correspondance de la partie d'en-tête de la requête HTTP. Il est compatible avec les expressions régulières de RE2. C'est une option de configuration. S'il n'est pas défini dans le fichier de configuration, il ne correspond pas à la partie d'en-tête de la requête HTTP - -`` la valeur est une requête prédéfinie de ``, qui est exécuté par ClickHouse lorsqu'une requête HTTP est mise en correspondance et que le résultat de la requête est renvoyé. C'est une configuration incontournable. - -`` prend en charge les paramètres de réglage et les valeurs query\_params. +`` la valeur est une requête prédéfinie de ``, qui est exécuté par ClickHouse lorsqu'une requête HTTP est mise en correspondance et que le résultat de la requête est renvoyé. C'est une configuration incontournable. L'exemple suivant définit les valeurs de `max_threads` et `max_alter_threads` Paramètres, puis interroge la table système pour vérifier si ces paramètres ont été définis avec succès. Exemple: ``` xml - - + + + [^/]+)(/(?P[^/]+))?]]> GET TEST_HEADER_VALUE [^/]+)(/(?P[^/]+))?]]> - [^/]+)(/(?P[^/]+))?]]> - + + predefined_query_handler SELECT value FROM system.settings WHERE name = {name_1:String} SELECT name, value FROM system.settings WHERE name = {name_2:String} - - - +
+
+
``` ``` bash @@ -475,37 +425,193 @@ $ curl -H 'XXX:TEST_HEADER_VALUE' -H 'PARAMS_XXX:max_threads' 'http://localhost: max_alter_threads 2 ``` -!!! note "Note" - Dans un ``, un `` prend en charge un seul `` d'un type d'insertion. +!!! note "précaution" + Dans un `` prend en charge un seul `` d'un type d'insertion. ## dynamic\_query\_handler {#dynamic_query_handler} -`` que `` augmenter `` . +Dans ``, la requête est écrite sous la forme de param de la requête HTTP. La différence est que dans ``, la requête est écrite dans le fichier de configuration. Vous pouvez configurer `` dans ``. -Clickhouse extrait et exécute la valeur correspondant au `` valeur dans l'url de la requête HTTP. -ClickHouse réglage par défaut `` être `/query` . C'est une option de configuration. Si il n'y a pas de définition dans le fichier de configuration, le paramètre n'est pas passé. +Clickhouse extrait et exécute la valeur correspondant au `` valeur dans l'url de la requête HTTP. La valeur par défaut de `` être `/query` . C'est une option de configuration. Si il n'y a pas de définition dans le fichier de configuration, le paramètre n'est pas passé. Pour expérimenter cette fonctionnalité, l'exemple définit les valeurs de max\_threads et max\_alter\_threads et demande si les paramètres ont été définis avec succès. -La différence est que dans ``, la requête est écrite dans le fichier de configuration. Mais dans ``, la requête est écrite sous la forme de param de la requête HTTP. Exemple: ``` xml - - - - TEST_HEADER_VALUE_DYNAMIC - [^/]+)(/(?P[^/]+))?]]> - + + + + TEST_HEADER_VALUE_DYNAMIC + + dynamic_query_handler query_param - - + +
+
``` ``` bash -$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' -H 'PARAMS_XXX:max_threads' 'http://localhost:8123/?query_param=SELECT%20value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D&max_threads=1&max_alter_threads=2¶m_name_2=max_alter_threads' -1 -2 +$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' 'http://localhost:8123/own?max_threads=1&max_alter_threads=2¶m_name_1=max_threads¶m_name_2=max_alter_threads&query_param=SELECT%20name,value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D' +max_threads 1 +max_alter_threads 2 +``` + +## statique {#static} + +`` peut-retour [content\_type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type), [statut](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) et response\_content. response\_content peut renvoyer le contenu spécifié + +Exemple: + +De retour d'un message. + +``` xml + + + GET + xxx + /hi + + static + 402 + text/html; charset=UTF-8 + Say Hi! + + + +``` + +``` bash +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/hi' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /hi HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 402 Payment Required +< Date: Wed, 29 Apr 2020 03:51:26 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +Say Hi!% +``` + +Trouvez le contenu de la configuration envoyer au client. + +``` xml +
]]>
+ + + + GET + xxx + /get_config_static_handler + + static + config://get_config_static_handler + + + +``` + +``` bash +$ curl -v -H 'XXX:xxx' 'http://localhost:8123/get_config_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_config_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:01:24 GMT +< Connection: Keep-Alive +< Content-Type: text/plain; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +
% +``` + +Trouvez le contenu du fichier envoyé au client. + +``` xml + + + GET + xxx + /get_absolute_path_static_handler + + static + text/html; charset=UTF-8 + file:///absolute_path_file.html + + + + GET + xxx + /get_relative_path_static_handler + + static + text/html; charset=UTF-8 + file://./relative_path_file.html + + + +``` + +``` bash +$ user_files_path='/var/lib/clickhouse/user_files' +$ sudo echo "Relative Path File" > $user_files_path/relative_path_file.html +$ sudo echo "Absolute Path File" > $user_files_path/absolute_path_file.html +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_absolute_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_absolute_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:16 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Absolute Path File +* Connection #0 to host localhost left intact +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_relative_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_relative_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:31 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Relative Path File +* Connection #0 to host localhost left intact ``` [Article Original](https://clickhouse.tech/docs/en/interfaces/http_interface/) diff --git a/docs/fr/interfaces/index.md b/docs/fr/interfaces/index.md index d85ce9cdbe3..bba875be1f2 100644 --- a/docs/fr/interfaces/index.md +++ b/docs/fr/interfaces/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Interfaces +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Interface toc_priority: 14 toc_title: Introduction --- @@ -22,7 +22,7 @@ Dans la plupart des cas, il est recommandé d'utiliser un outil ou une biblioth Il existe également un large éventail de bibliothèques tierces pour travailler avec ClickHouse: -- [Bibliothèques clientes](third-party/client_libraries.md) +- [Bibliothèques clientes](third-party/client-libraries.md) - [Intégration](third-party/integrations.md) - [Les interfaces visuelles](third-party/gui.md) diff --git a/docs/fr/interfaces/jdbc.md b/docs/fr/interfaces/jdbc.md index 1bd9dfe8e9f..dc68dcb9831 100644 --- a/docs/fr/interfaces/jdbc.md +++ b/docs/fr/interfaces/jdbc.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 22 toc_title: JDBC --- diff --git a/docs/fr/interfaces/mysql.md b/docs/fr/interfaces/mysql.md index ac57deefaba..b3ec2e30e26 100644 --- a/docs/fr/interfaces/mysql.md +++ b/docs/fr/interfaces/mysql.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 20 toc_title: Interface MySQL --- # Interface MySQL {#mysql-interface} -ClickHouse prend en charge le protocole de fil MySQL. Il peut être activé par [mysql\_port](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-mysql_port) paramètre dans le fichier de configuration: +ClickHouse prend en charge le protocole de fil MySQL. Il peut être activé par [mysql\_port](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-mysql_port) paramètre dans le fichier de configuration: ``` xml 9004 @@ -37,8 +37,8 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` -Pour la compatibilité avec tous les clients MySQL, il est recommandé de spécifier le mot de passe utilisateur avec [double SHA1](../operations/settings/settings_users.md#password_double_sha1_hex) dans le fichier de configuration. -Si le mot de passe de l'utilisateur est spécifié [SHA256](../operations/settings/settings_users.md#password_sha256_hex), certains clients ne pourront pas s'authentifier (mysqljs et anciennes versions de l'outil de ligne de commande mysql). +Pour la compatibilité avec tous les clients MySQL, il est recommandé de spécifier le mot de passe utilisateur avec [double SHA1](../operations/settings/settings-users.md#password_double_sha1_hex) dans le fichier de configuration. +Si le mot de passe de l'utilisateur est spécifié [SHA256](../operations/settings/settings-users.md#password_sha256_hex), certains clients ne pourront pas s'authentifier (mysqljs et anciennes versions de l'outil de ligne de commande mysql). Restriction: diff --git a/docs/fr/interfaces/odbc.md b/docs/fr/interfaces/odbc.md index 1f366f77d51..991dc833502 100644 --- a/docs/fr/interfaces/odbc.md +++ b/docs/fr/interfaces/odbc.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 23 toc_title: Pilote ODBC --- diff --git a/docs/fr/interfaces/tcp.md b/docs/fr/interfaces/tcp.md index 45e89776547..d1fa251e0e4 100644 --- a/docs/fr/interfaces/tcp.md +++ b/docs/fr/interfaces/tcp.md @@ -1,12 +1,12 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 18 toc_title: Interface Native (TCP) --- # Interface Native (TCP) {#native-interface-tcp} -Le protocole natif est utilisé dans le [client de ligne de commande](cli.md), pour la communication inter-serveur pendant le traitement de requête distribué, et également dans d'autres programmes C++. Malheureusement, le protocole clickhouse natif n'a pas encore de spécification formelle, mais il peut être rétro-conçu à partir du code source ClickHouse (démarrage [ici](https://github.com/ClickHouse/ClickHouse/tree/master/dbms/Client)) et/ou en interceptant et en analysant le trafic TCP. +Le protocole natif est utilisé dans le [client de ligne de commande](cli.md), pour la communication inter-serveur pendant le traitement de requête distribué, et également dans d'autres programmes C++. Malheureusement, le protocole clickhouse natif n'a pas encore de spécification formelle, mais il peut être rétro-conçu à partir du code source ClickHouse (démarrage [ici](https://github.com/ClickHouse/ClickHouse/tree/master/src/Client)) et/ou en interceptant et en analysant le trafic TCP. [Article Original](https://clickhouse.tech/docs/en/interfaces/tcp/) diff --git a/docs/fr/interfaces/third-party/client-libraries.md b/docs/fr/interfaces/third-party/client-libraries.md new file mode 100644 index 00000000000..f07a27aec6c --- /dev/null +++ b/docs/fr/interfaces/third-party/client-libraries.md @@ -0,0 +1,60 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 26 +toc_title: "Biblioth\xE8ques Clientes" +--- + +# Bibliothèques clientes de développeurs tiers {#client-libraries-from-third-party-developers} + +!!! warning "Avertissement" + Yandex ne **pas** maintenir les bibliothèques énumérées ci-dessous et n'ont pas fait de tests approfondis pour assurer leur qualité. + +- Python + - [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) + - [clickhouse-chauffeur](https://github.com/mymarilyn/clickhouse-driver) + - [clickhouse-client](https://github.com/yurial/clickhouse-client) + - [aiochclient](https://github.com/maximdanilchenko/aiochclient) +- PHP + - [smi2 / phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) + - [8bitov / clickhouse-PHP-client](https://packagist.org/packages/8bitov/clickhouse-php-client) + - [bozerkins / clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) + - [simpod / clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) + - [seva-code/php-cliquez-maison-client](https://packagist.org/packages/seva-code/php-click-house-client) + - [Client Seasclick c++ ](https://github.com/SeasX/SeasClick) +- Aller + - [clickhouse](https://github.com/kshvakov/clickhouse/) + - [aller-clickhouse](https://github.com/roistat/go-clickhouse) + - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) + - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) +- NodeJs + - [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) + - [node-clickhouse](https://github.com/apla/node-clickhouse) +- Perl + - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) + - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) + - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) +- Rubis + - [ClickHouse (Ruby)](https://github.com/shlima/click_house) + - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) +- R + - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) + - [RClickHouse](https://github.com/IMSMWU/RClickHouse) +- Java + - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) + - [clickhouse-client](https://github.com/Ecwid/clickhouse-client) +- Scala + - [clickhouse-Scala-client](https://github.com/crobox/clickhouse-scala-client) +- Kotlin + - [AORM](https://github.com/TanVD/AORM) +- C\# + - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) + - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) + - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) +- Elixir + - [clickhousex](https://github.com/appodeal/clickhousex/) + - [pilier](https://github.com/sofakingworld/pillar) +- Nim + - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) + +[Article Original](https://clickhouse.tech/docs/en/interfaces/third-party/client_libraries/) diff --git a/docs/fr/interfaces/third-party/client_libraries.md b/docs/fr/interfaces/third-party/client_libraries.md deleted file mode 100644 index e4be3a53646..00000000000 --- a/docs/fr/interfaces/third-party/client_libraries.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 26 -toc_title: "Biblioth\xE8ques Clientes" ---- - -# Bibliothèques clientes de développeurs tiers {#client-libraries-from-third-party-developers} - -!!! warning "Avertissement" - Yandex ne **pas** maintenir les bibliothèques énumérées ci-dessous et n'ont pas fait de tests approfondis pour assurer leur qualité. - -- Python - - [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) - - [clickhouse-chauffeur](https://github.com/mymarilyn/clickhouse-driver) - - [clickhouse-client](https://github.com/yurial/clickhouse-client) - - [aiochclient](https://github.com/maximdanilchenko/aiochclient) -- PHP - - [smi2 / phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) - - [8bitov / clickhouse-PHP-client](https://packagist.org/packages/8bitov/clickhouse-php-client) - - [bozerkins / clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) - - [simpod / clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) - - [seva-code/php-cliquez-maison-client](https://packagist.org/packages/seva-code/php-click-house-client) - - [Client Seasclick c++ ](https://github.com/SeasX/SeasClick) -- Aller - - [clickhouse](https://github.com/kshvakov/clickhouse/) - - [aller-clickhouse](https://github.com/roistat/go-clickhouse) - - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) - - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) -- NodeJs - - [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) - - [node-clickhouse](https://github.com/apla/node-clickhouse) -- Perl - - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) - - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) - - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) -- Rubis - - [ClickHouse (Ruby)](https://github.com/shlima/click_house) - - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) -- R - - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) - - [RClickhouse](https://github.com/IMSMWU/RClickhouse) -- Java - - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) - - [clickhouse-client](https://github.com/Ecwid/clickhouse-client) -- Scala - - [clickhouse-Scala-client](https://github.com/crobox/clickhouse-scala-client) -- Kotlin - - [AORM](https://github.com/TanVD/AORM) -- C\# - - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) - - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) - - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) -- Elixir - - [clickhousex](https://github.com/appodeal/clickhousex/) -- Nim - - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) - -[Article Original](https://clickhouse.tech/docs/en/interfaces/third-party/client_libraries/) diff --git a/docs/fr/interfaces/third-party/gui.md b/docs/fr/interfaces/third-party/gui.md index 1682c78fdbd..af25f86ee54 100644 --- a/docs/fr/interfaces/third-party/gui.md +++ b/docs/fr/interfaces/third-party/gui.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 28 toc_title: Les Interfaces Visuelles --- @@ -93,6 +93,10 @@ Caractéristique: [clickhouse-flamegraph](https://github.com/Slach/clickhouse-flamegraph) est un outil spécialisé pour visualiser la `system.trace_log` comme [flamegraph](http://www.brendangregg.com/flamegraphs.html). +### clickhouse-plantuml {#clickhouse-plantuml} + +[cickhouse-plantuml](https://pypi.org/project/clickhouse-plantuml/) est un script à générer [PlantUML](https://plantuml.com/) schéma des schémas des tableaux. + ## Commercial {#commercial} ### DataGrip {#datagrip} diff --git a/docs/fr/interfaces/third-party/index.md b/docs/fr/interfaces/third-party/index.md index 75062f3bad4..fd721a39c3e 100644 --- a/docs/fr/interfaces/third-party/index.md +++ b/docs/fr/interfaces/third-party/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Third-Party +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: tiers toc_priority: 24 --- diff --git a/docs/fr/interfaces/third-party/integrations.md b/docs/fr/interfaces/third-party/integrations.md index 565be2b9604..f252fd6229b 100644 --- a/docs/fr/interfaces/third-party/integrations.md +++ b/docs/fr/interfaces/third-party/integrations.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 27 toc_title: "Int\xE9gration" --- @@ -26,7 +26,11 @@ toc_title: "Int\xE9gration" - [ClickHouseMigrator](https://github.com/zlzforever/ClickHouseMigrator) - Files d'attente de messages - [Kafka](https://kafka.apache.org) - - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (utiliser [Allez client](https://github.com/kshvakov/clickhouse/)) + - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (utiliser [Allez client](https://github.com/ClickHouse/clickhouse-go/)) + - [stream-loader-clickhouse](https://github.com/adform/stream-loader) +- Traitement de flux + - [Flink](https://flink.apache.org) + - [flink-clickhouse-évier](https://github.com/ivi-ru/flink-clickhouse-sink) - Objet de stockages - [S3](https://en.wikipedia.org/wiki/Amazon_S3) - [clickhouse-sauvegarde](https://github.com/AlexAkulov/clickhouse-backup) @@ -42,7 +46,7 @@ toc_title: "Int\xE9gration" - [graphouse](https://github.com/yandex/graphouse) - [carbone-clickhouse](https://github.com/lomik/carbon-clickhouse) + - [graphite-clickhouse](https://github.com/lomik/graphite-clickhouse) - - [graphite-CH-optimizer](https://github.com/innogames/graphite-ch-optimizer) - optimise les partitions calées dans [\* GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md#graphitemergetree) si les règles de [configuration de cumul](../../engines/table_engines/mergetree_family/graphitemergetree.md#rollup-configuration) pourrait être appliquée + - [graphite-CH-optimizer](https://github.com/innogames/graphite-ch-optimizer) - optimise les partitions calées dans [\* GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md#graphitemergetree) si les règles de [configuration de cumul](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) pourrait être appliquée - [Grafana](https://grafana.com/) - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) - [Prometheus](https://prometheus.io/) @@ -74,15 +78,15 @@ toc_title: "Int\xE9gration" - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (utiliser [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - [Panda](https://pandas.pydata.org) - [pandahouse](https://github.com/kszucs/pandahouse) -- PHP +- PHP - [Doctrine](https://www.doctrine-project.org/) - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) - R - [dplyr](https://db.rstudio.com/dplyr/) - - [RClickhouse](https://github.com/IMSMWU/RClickhouse) (utiliser [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) + - [RClickHouse](https://github.com/IMSMWU/RClickHouse) (utiliser [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) - Java - [Hadoop](http://hadoop.apache.org) - - [clickhouse-HDFS-chargeur](https://github.com/jaykelin/clickhouse-hdfs-loader) (utiliser [JDBC](../../sql_reference/table_functions/jdbc.md)) + - [clickhouse-HDFS-chargeur](https://github.com/jaykelin/clickhouse-hdfs-loader) (utiliser [JDBC](../../sql-reference/table-functions/jdbc.md)) - Scala - [Akka](https://akka.io) - [clickhouse-Scala-client](https://github.com/crobox/clickhouse-scala-client) diff --git a/docs/fr/interfaces/third-party/proxy.md b/docs/fr/interfaces/third-party/proxy.md index 154c0b8efc1..0283cc7fbe6 100644 --- a/docs/fr/interfaces/third-party/proxy.md +++ b/docs/fr/interfaces/third-party/proxy.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 29 toc_title: Proxy --- diff --git a/docs/fr/introduction/adopters.md b/docs/fr/introduction/adopters.md index f03f0242c72..833fc111fbe 100644 --- a/docs/fr/introduction/adopters.md +++ b/docs/fr/introduction/adopters.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 8 toc_title: Adoptant --- @@ -10,73 +10,77 @@ toc_title: Adoptant !!! warning "Avertissement" La liste suivante des entreprises utilisant ClickHouse et leurs histoires de réussite est assemblé à partir de sources publiques, pourrait donc différer de la réalité actuelle. Nous vous serions reconnaissants si vous partager l'histoire de l'adoption de ClickHouse dans votre entreprise et [ajouter à la liste](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/introduction/adopters.md), mais assurez-vous que vous n'aurez aucun problème de NDA en le faisant. Fournir des mises à jour avec des publications d'autres entreprises est également utile. -| Entreprise | Industrie | Cas d'utilisation | La Taille De Cluster | (Onu)Taille Des Données Compressées\* | Référence | -|-------------------------------------------------------------------------------|-------------------------------------|------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [2gis](https://2gis.ru) | Cartographie | Surveiller | — | — | [Parler en russe, juillet 2019](https://youtu.be/58sPkXfq6nw) | -| [Aloha Navigateur](https://alohabrowser.com/) | Mobile App | Navigateur backend | — | — | [Diapositives en russe, mai 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | -| [Amadeus](https://amadeus.com/) | Voyage | Analytics | — | — | [Communiqué De Presse, Avril 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | -| [Appsflyer](https://www.appsflyer.com) | Mobile analytics | Produit principal | — | — | [Parler en russe, juillet 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | -| [ArenaData](https://arenadata.tech/) | Plate-Forme De Données | Produit principal | — | — | [Diapositives en russe, décembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | -| [Badoo](https://badoo.com) | Rencontres | Timeseries | — | — | [Diapositives en russe, décembre 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | -| [Benocs](https://www.benocs.com/) | Télémétrie et analyse de réseau | Produit Principal | — | — | [Diapositives en anglais, octobre 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | -| [Bloomberg](https://www.bloomberg.com/) | Les Finances, Les Médias | Surveiller | 102 serveurs | — | [Diapositives, Mai 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | -| [Bloxy](https://bloxy.info) | Blockchain | Analytics | — | — | [Diapositives en russe, août 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | -| `Dataliance/UltraPower` | Télécommunication | Analytics | — | — | [Diapositives en chinois, janvier 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | -| [CARTO](https://carto.com/) | Business Intelligence | GEO analytics | — | — | [Traitement géospatial avec Clickhouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | -| [CERN](http://public.web.cern.ch/public/) | Recherche | Expérience | — | — | [Communiqué De Presse, avril 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | -| [Cisco](http://cisco.com/) | Réseau | L'analyse de trafic | — | — | [Lightning talk, octobre 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | -| [Citadelle Titres](https://www.citadelsecurities.com/) | Finance | — | — | — | [Contribution, Mars 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | -| [Citymobil](https://city-mobil.ru) | Taxi | Analytics | — | — | [Billet de Blog en russe, mars 2020](https://habr.com/en/company/citymobil/blog/490660/) | -| [ContentSquare](https://contentsquare.com) | Web analytics | Produit principal | — | — | [Billet de Blog, novembre 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | -| [Cloudflare](https://cloudflare.com) | CDN | L'analyse de trafic | 36 serveurs | — | [Billet de Blog, mai 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Billet de Blog, mars 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | -| [Corunet](https://coru.net/) | Analytics | Produit principal | — | — | [Diapositives en anglais, avril 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | -| [CraiditX 氪信](https://creditx.com) | Les finances de l'IA | Analyse | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | -| [Criteo / Storetail](https://www.criteo.com/) | Détail | Produit principal | — | — | [Diapositives en anglais, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | -| [La Deutsche Bank](https://db.com) | Finance | BI Analytics | — | — | [Diapositives en anglais, octobre 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | -| [Diva-e](https://www.diva-e.com) | Conseil Digital | Produit Principal | — | — | [Diapositives en anglais, septembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | -| [Exness](https://www.exness.com) | Trading | Métriques, Journalisation | — | — | [Parler en russe, mai 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | -| [Geniee](https://geniee.co.jp) | Réseau publicitaire | Produit principal | — | — | [Billet de Blog en japonais, juillet 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | -| [HUYA](https://www.huya.com/) | Le Streaming Vidéo | Analytics | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | -| [Idealista](https://www.idealista.com) | Immobilier | Analytics | — | — | [Billet de Blog en anglais, avril 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | -| [Infovista](https://www.infovista.com/) | Réseau | Analytics | — | — | [Diapositives en anglais, octobre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | -| [InnoGames](https://www.innogames.com) | Jeu | Métriques, Journalisation | — | — | [Diapositives en russe, septembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | -| [Integros](https://integros.com) | Plate-forme pour les services vidéo | Analytics | — | — | [Diapositives en russe, mai 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Données Kodiak](https://www.kodiakdata.com/) | Nuage | Produit principal | — | — | [Diapositives en Engish, avril 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | -| [Kontur](https://kontur.ru) | Le Développement De Logiciels | Métrique | — | — | [Parler en russe, novembre 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | -| [LifeStreet](https://lifestreet.com/) | Réseau publicitaire | Produit principal | 75 serveurs (3 répliques) | 5.27 FRP | [Billet de Blog en russe, février 2017](https://habr.com/en/post/322620/) | -| [Mail.ru Solutions Cloud](https://mcs.mail.ru/) | Les services de Cloud | Produit principal | — | — | [Exécution de L'Instance ClickHouse, en russe](https://mcs.mail.ru/help/db-create/clickhouse#) | -| [MessageBird](https://www.messagebird.com) | Télécommunication | Statistique | — | — | [Diapositives en anglais, novembre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | -| [MGID](https://www.mgid.com/) | Réseau publicitaire | Web-analytics | — | — | [Notre expérience dans la mise en œuvre de SGBD analytique ClickHouse, en russe](http://gs-studio.com/news-about-it/32777----clickhouse---c) | -| [OneAPM](https://www.oneapm.com/) | Monitorings et analyse des données | Produit principal | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | -| [Pragma L'Innovation](http://www.pragma-innovation.fr/) | Télémétrie et analyse Big Data | Produit principal | — | — | [Diapositives en anglais, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | -| [QINGCLOUD](https://www.qingcloud.com/) | Les services de Cloud | Produit principal | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | -| [Qrator](https://qrator.net) | Protection DDoS | Produit principal | — | — | [Billet De Blog, Mars 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | -| [Beijing pour cent Information Technology Co., Ltd.](https://www.percent.cn/) | Analytics | Produit Principal | — | — | [Diapositives en chinois, juin 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | -| [Rambler](https://rambler.ru) | Services Internet | Analytics | — | — | [Parler en russe, avril 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | -| [Tencent](https://www.tencent.com) | Messagerie | Journalisation | — | — | [Parler en chinois, novembre 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | -| [Étoiles De Circulation](https://trafficstars.com/) | Réseau publicitaire | — | — | — | [Diapositives en russe, mai 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | -| [S7 Airlines](https://www.s7.ru) | Avion | Métriques, Journalisation | — | — | [Parler en russe, mars 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | -| [SEMrush](https://www.semrush.com/) | Marketing | Produit principal | — | — | [Diapositives en russe, août 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | -| [scireum GmbH](https://www.scireum.de/) | Ecommerce | Produit principal | — | — | [Présentation en allemand, février 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | -| [Sentry](https://sentry.io/) | Développeur de logiciels | Backend pour le produit | — | — | [Billet de Blog en anglais, mai 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | -| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr) | Gouvernement Sécurité Sociale | Analytics | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | -| [seo.do](https://seo.do/) | Analytics | Produit principal | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | -| [Sina](http://english.sina.com/index.html) | Nouvelles | — | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | -| [SMI2](https://smi2.ru/) | Nouvelles | Analytics | — | — | [Billet de Blog en russe, novembre 2017](https://habr.com/ru/company/smi2/blog/314558/) | -| [Splunk](https://www.splunk.com/) | Business Analytics | Produit principal | — | — | [Diapositives en anglais, janvier 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | -| [Spotify](https://www.spotify.com) | Musical | Expérimentation | — | — | [Diapositives, Juillet 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | -| [Tencent](https://www.tencent.com) | Big Data | Le traitement des données | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | -| [Uber](https://www.uber.com) | Taxi | Journalisation | — | — | [Diapositives, Février 2020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | -| [VKontakte](https://vk.com) | Réseau Social | Statistiques, Journalisation | — | — | [Diapositives en russe, août 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | -| [Wisebits](https://wisebits.com/) | Solutions informatiques | Analytics | — | — | [Diapositives en russe, mai 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Xiaoxin Tech.](https://www.xiaoheiban.cn/) | Éducation | But commun | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | -| [Ximalaya](https://www.ximalaya.com/) | Partage Audio | OLAP | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | -| [Yandex Cloud](https://cloud.yandex.ru/services/managed-clickhouse) | Le Cloud Public | Produit principal | — | — | [Parler en russe, décembre 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | -| [Yandex DataLens](https://cloud.yandex.ru/services/datalens) | Business Intelligence | Produit principal | — | — | [Diapositives en russe, décembre 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | -| [Yandex Marché](https://market.yandex.ru/) | Ecommerce | Métriques, Journalisation | — | — | [Parler en russe, janvier 2019](https://youtu.be/_l1qP0DyBcA?t=478) | -| [Yandex Metrica](https://metrica.yandex.com) | Web analytics | Produit principal | 360 serveurs dans un cluster, 1862 serveurs dans un département | 66,41 FRP / 5,68 FRP | [Diapositives, Février 2020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | -| [ЦВТ](https://htc-cs.ru/) | Le Développement De Logiciels | Métriques, Journalisation | — | — | [Billet de Blog, mars 2019, en russe](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | -| [МКБ](https://mkb.ru/) | Banque | Surveillance du système Web | — | — | [Diapositives en russe, septembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | -| [金数据](https://jinshuju.net) | BI Analytics | Produit principal | — | — | [Diapositives en chinois, octobre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | +| Entreprise | Industrie | Cas d'utilisation | La Taille De Cluster | (Onu)Taille Des Données Compressées\* | Référence | +|-------------------------------------------------------------------------------------------------|-------------------------------------|------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 2gis | Cartographie | Surveiller | — | — | [Parler en russe, juillet 2019](https://youtu.be/58sPkXfq6nw) | +| Aloha Browser | Mobile App | Navigateur backend | — | — | [Diapositives en russe, mai 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | +| Amadeus | Voyage | Analytics | — | — | [Communiqué De Presse, Avril 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | +| Appsflyer | Mobile analytics | Produit principal | — | — | [Parler en russe, juillet 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | +| ArenaData | Plate-Forme De Données | Produit principal | — | — | [Diapositives en russe, décembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | +| Badoo | Rencontres | Timeseries | — | — | [Diapositives en russe, décembre 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | +| Benocs | Télémétrie et analyse de réseau | Produit Principal | — | — | [Diapositives en anglais, octobre 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | +| Bloomberg | Les Finances, Les Médias | Surveiller | 102 serveurs | — | [Diapositives, Mai 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | +| Bloxy | Blockchain | Analytics | — | — | [Diapositives en russe, août 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | +| Dataliance pour China Telecom | Télécommunication | Analytics | — | — | [Diapositives en chinois, janvier 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | +| CARTO | Business Intelligence | GEO analytics | — | — | [Traitement géospatial avec ClickHouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | +| CERN | Recherche | Expérience | — | — | [Communiqué De Presse, avril 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | +| Cisco | Réseau | L'analyse de trafic | — | — | [Lightning talk, octobre 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | +| Citadel Securities | Finance | — | — | — | [Contribution, Mars 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | +| Citymobil | Taxi | Analytics | — | — | [Billet de Blog en russe, mars 2020](https://habr.com/en/company/citymobil/blog/490660/) | +| ContentSquare | Web analytics | Produit principal | — | — | [Billet de Blog, novembre 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | +| Cloudflare | CDN | L'analyse de trafic | 36 serveurs | — | [Billet de Blog, mai 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Billet de Blog, mars 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | +| Corunet | Analytics | Produit principal | — | — | [Diapositives en anglais, avril 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | +| CraiditX 氪信 | Les finances de l'IA | Analyse | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | +| Criteo | Détail | Produit principal | — | — | [Diapositives en anglais, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | +| Deutsche Bank | Finance | BI Analytics | — | — | [Diapositives en anglais, octobre 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | +| Diva-e | Conseil Digital | Produit Principal | — | — | [Diapositives en anglais, septembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | +| Exness | Trading | Métriques, Journalisation | — | — | [Parler en russe, mai 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | +| Geniee | Réseau publicitaire | Produit principal | — | — | [Billet de Blog en japonais, juillet 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | +| HUYA | Le Streaming Vidéo | Analytics | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | +| Idealista | Immobilier | Analytics | — | — | [Billet de Blog en anglais, avril 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | +| Infovista | Réseau | Analytics | — | — | [Diapositives en anglais, octobre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | +| InnoGames | Jeu | Métriques, Journalisation | — | — | [Diapositives en russe, septembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | +| Integros | Plate-forme pour les services vidéo | Analytics | — | — | [Diapositives en russe, mai 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| Données Kodiak | Nuage | Produit principal | — | — | [Diapositives en Engish, avril 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | +| Kontur | Le Développement De Logiciels | Métrique | — | — | [Parler en russe, novembre 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | +| LifeStreet | Réseau publicitaire | Produit principal | 75 serveurs (3 répliques) | 5.27 FRP | [Billet de Blog en russe, février 2017](https://habr.com/en/post/322620/) | +| Mail.ru Solutions Cloud | Les services de Cloud | Produit principal | — | — | [Article en russe](https://mcs.mail.ru/help/db-create/clickhouse#) | +| MessageBird | Télécommunication | Statistique | — | — | [Diapositives en anglais, novembre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | +| MGID | Réseau publicitaire | Web-analytics | — | — | [Billet de Blog en russe, avril 2020](http://gs-studio.com/news-about-it/32777----clickhouse---c) | +| OneAPM | Monitorings et analyse des données | Produit principal | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | +| Pragma Innovation | Télémétrie et analyse Big Data | Produit principal | — | — | [Diapositives en anglais, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | +| QINGCLOUD | Les services de Cloud | Produit principal | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | +| Qrator | Protection DDoS | Produit principal | — | — | [Billet De Blog, Mars 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | +| Percent 百分点 | Analytics | Produit Principal | — | — | [Diapositives en chinois, juin 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | +| Rambler | Services Internet | Analytics | — | — | [Parler en russe, avril 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | +| Tencent | Messagerie | Journalisation | — | — | [Parler en chinois, novembre 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | +| Traffic Stars | Réseau publicitaire | — | — | — | [Diapositives en russe, mai 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | +| S7 Airlines | Avion | Métriques, Journalisation | — | — | [Parler en russe, mars 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | +| SEMrush | Marketing | Produit principal | — | — | [Diapositives en russe, août 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | +| scireum GmbH | Ecommerce | Produit principal | — | — | [Présentation en allemand, février 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | +| Sentry | Développeur de logiciels | Backend pour le produit | — | — | [Billet de Blog en anglais, mai 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | +| SGK | Gouvernement Sécurité Sociale | Analytics | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | +| seo.do | Analytics | Produit principal | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | +| Sina | Nouvelles | — | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | +| SMI2 | Nouvelles | Analytics | — | — | [Billet de Blog en russe, novembre 2017](https://habr.com/ru/company/smi2/blog/314558/) | +| Splunk | Business Analytics | Produit principal | — | — | [Diapositives en anglais, janvier 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | +| Spotify | Musical | Expérimentation | — | — | [Diapositives, Juillet 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | +| Tencent | Big Data | Le traitement des données | — | — | [Diapositives en chinois, octobre 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | +| Uber | Taxi | Journalisation | — | — | [Diapositives, Février 2020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | +| VKontakte | Réseau Social | Statistiques, Journalisation | — | — | [Diapositives en russe, août 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | +| Wisebits | Solutions informatiques | Analytics | — | — | [Diapositives en russe, mai 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| Xiaoxin Tech | Éducation | But commun | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | +| Ximalaya | Partage Audio | OLAP | — | — | [Diapositives en anglais, novembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | +| Yandex Cloud | Le Cloud Public | Produit principal | — | — | [Parler en russe, décembre 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | +| Yandex DataLens | Business Intelligence | Produit principal | — | — | [Diapositives en russe, décembre 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | +| Yandex Market | Ecommerce | Métriques, Journalisation | — | — | [Parler en russe, janvier 2019](https://youtu.be/_l1qP0DyBcA?t=478) | +| Yandex Metrica | Web analytics | Produit principal | 360 serveurs dans un cluster, 1862 serveurs dans un département | 66,41 FRP / 5,68 FRP | [Diapositives, Février 2020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | +| ЦВТ | Le Développement De Logiciels | Métriques, Journalisation | — | — | [Billet de Blog, mars 2019, en russe](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | +| МКБ | Banque | Surveillance du système Web | — | — | [Diapositives en russe, septembre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | +| Jinshuju 金数据 | BI Analytics | Produit principal | — | — | [Diapositives en chinois, octobre 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | +| Instana | Plate-forme APM | Produit principal | — | — | [Après Twitter](https://twitter.com/mieldonkers/status/1248884119158882304) | +| Wargaming | Jeu | | — | — | [Entrevue](https://habr.com/en/post/496954/) | +| Crazypanda | Jeu | | — | — | Session en direct sur clickhouse meetup | +| FunCorp | Jeu | | — | — | [Article](https://www.altinity.com/blog/migrating-from-redshift-to-clickhouse) | [Article Original](https://clickhouse.tech/docs/en/introduction/adopters/) diff --git a/docs/fr/introduction/distinctive-features.md b/docs/fr/introduction/distinctive-features.md new file mode 100644 index 00000000000..9d01d245c4e --- /dev/null +++ b/docs/fr/introduction/distinctive-features.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 4 +toc_title: "particularit\xE9" +--- + +# Caractéristiques distinctives de ClickHouse {#distinctive-features-of-clickhouse} + +## Vrai SGBD orienté colonne {#true-column-oriented-dbms} + +Dans un vrai SGBD orienté colonne, aucune donnée supplémentaire n'est stockée avec les valeurs. Entre autres choses, cela signifie que les valeurs de longueur constante doivent être prises en charge, pour éviter de stocker leur longueur “number” à côté de ces valeurs. Par exemple, un milliard de valeurs de type UInt8 devrait consommer environ 1 Go non compressé, ou cela affecte fortement l'utilisation du processeur. Il est essentiel de stocker des données de manière compacte (sans “garbage”) même lorsqu'il n'est pas compressé, puisque la vitesse de décompression (utilisation du processeur) dépend principalement du volume de données non compressées. + +Il est à noter car il existe des systèmes qui peuvent stocker des valeurs de différentes colonnes séparément, mais qui ne peuvent pas traiter efficacement les requêtes analytiques en raison de leur optimisation pour d'autres scénarios. Les exemples sont HBase, BigTable, Cassandra et HyperTable. Dans ces systèmes, vous obtiendriez un débit d'environ cent mille lignes par seconde, mais pas des centaines de millions de lignes par seconde. + +Il est également intéressant de noter que ClickHouse est un système de gestion de base de données, pas une seule base de données. ClickHouse permet de créer des tables et des bases de données en cours d'exécution, de charger des données et d'exécuter des requêtes sans reconfigurer et redémarrer le serveur. + +## Compression De Données {#data-compression} + +Certains SGBD orientés colonne (InfiniDB CE et MonetDB) n'utilisent pas la compression de données. Cependant, la compression des données joue un rôle clé dans la réalisation d'excellentes performances. + +## Stockage de données sur disque {#disk-storage-of-data} + +Garder les données physiquement triées par clé primaire permet d'extraire des données pour ses valeurs spécifiques ou plages de valeurs avec une faible latence, moins de quelques dizaines de millisecondes. Certains SGBD orientés colonne (tels que SAP HANA et Google PowerDrill) ne peuvent fonctionner qu'en RAM. Cette approche encourage l'allocation d'un budget matériel plus important que ce qui est nécessaire pour l'analyse en temps réel. ClickHouse est conçu pour fonctionner sur des disques durs réguliers, ce qui signifie que le coût par Go de stockage de données est faible, mais SSD et RAM supplémentaire sont également entièrement utilisés si disponible. + +## Traitement parallèle sur plusieurs cœurs {#parallel-processing-on-multiple-cores} + +Les grandes requêtes sont parallélisées naturellement, en prenant toutes les ressources nécessaires disponibles sur le serveur actuel. + +## Traitement distribué sur plusieurs serveurs {#distributed-processing-on-multiple-servers} + +Presque aucun des SGBD en colonnes mentionnés ci-dessus ne prend en charge le traitement des requêtes distribuées. +Dans ClickHouse, les données peuvent résider sur différents fragments. Chaque fragment peut être un groupe de répliques utilisées pour la tolérance aux pannes. Tous les fragments sont utilisés pour exécuter une requête en parallèle, de façon transparente pour l'utilisateur. + +## Prise en charge SQL {#sql-support} + +ClickHouse prend en charge un langage de requête déclarative basé sur SQL qui est identique à la norme SQL dans de nombreux cas. +Les requêtes prises en charge incluent les clauses GROUP BY, ORDER BY, les sous-requêtes in FROM, IN et JOIN, ainsi que les sous-requêtes scalaires. +Les sous-requêtes dépendantes et les fonctions de fenêtre ne sont pas prises en charge. + +## Moteur Vectoriel {#vector-engine} + +Les données ne sont pas seulement stockées par des colonnes, mais sont traitées par des vecteurs (parties de colonnes), ce qui permet d'atteindre une efficacité élevée du processeur. + +## Données en temps réel des Mises à jour {#real-time-data-updates} + +ClickHouse prend en charge les tables avec une clé primaire. Pour effectuer rapidement des requêtes sur la plage de la clé primaire, les données sont triées progressivement à l'aide de l'arborescence de fusion. Pour cette raison, les données peuvent être continuellement ajoutées à la table. Pas de verrouillage lorsque de nouvelles données sont ingérés. + +## Index {#index} + +Avoir une donnée physiquement triée par clé primaire permet d'extraire des données pour ses valeurs spécifiques ou plages de valeurs avec une faible latence, moins de quelques dizaines de millisecondes. + +## Convient pour les requêtes en ligne {#suitable-for-online-queries} + +Faible latence signifie que les requêtes peuvent être traitées sans délai et sans essayer de préparer une réponse à l'avance, au même moment pendant le chargement de la page de l'interface utilisateur. En d'autres termes, en ligne. + +## Prise en charge des calculs approximatifs {#support-for-approximated-calculations} + +ClickHouse offre différentes façons d'échanger la précision pour la performance: + +1. Fonctions d'agrégation pour le calcul approximatif du nombre de valeurs distinctes, de médianes et de quantiles. +2. L'exécution d'une requête basée sur une partie (échantillon) de données et obtenir un pseudo résultat. Dans ce cas, proportionnellement, moins de données sont récupérées à partir du disque. +3. L'exécution d'une agrégation pour un nombre limité de clés aléatoires, au lieu de toutes les clés. Sous certaines conditions pour la distribution des clés dans les données, cela fournit un résultat raisonnablement précis tout en utilisant moins de ressources. + +## Prise en charge de la réplication et de l'intégrité des données {#data-replication-and-data-integrity-support} + +ClickHouse utilise la réplication multi-maître asynchrone. Après avoir été écrit dans n'importe quelle réplique disponible, toutes les répliques restantes récupèrent leur copie en arrière-plan. Le système conserve des données identiques sur différentes répliques. La récupération après la plupart des échecs est effectuée automatiquement ou semi-automatiquement dans les cas complexes. + +Pour plus d'informations, consultez la section [Réplication des données](../engines/table-engines/mergetree-family/replication.md). + +## Caractéristiques qui peuvent être considérées comme des inconvénients {#clickhouse-features-that-can-be-considered-disadvantages} + +1. Pas de transactions à part entière. +2. Manque de capacité à modifier ou supprimer des données déjà insérées avec un taux élevé et une faible latence. Des suppressions et des mises à jour par lots sont disponibles pour nettoyer ou modifier les données, par exemple pour [GDPR](https://gdpr-info.eu). +3. L'index clairsemé rend ClickHouse pas si approprié pour les requêtes ponctuelles récupérant des lignes simples par leurs clés. + +[Article Original](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/fr/introduction/distinctive_features.md b/docs/fr/introduction/distinctive_features.md deleted file mode 100644 index 2c825cac85a..00000000000 --- a/docs/fr/introduction/distinctive_features.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 4 -toc_title: "particularit\xE9" ---- - -# Caractéristiques distinctives de ClickHouse {#distinctive-features-of-clickhouse} - -## Vrai SGBD orienté colonne {#true-column-oriented-dbms} - -Dans un vrai SGBD orienté colonne, aucune donnée supplémentaire n'est stockée avec les valeurs. Entre autres choses, cela signifie que les valeurs de longueur constante doivent être prises en charge, pour éviter de stocker leur longueur “number” à côté de ces valeurs. Par exemple, un milliard de valeurs de type UInt8 devrait consommer environ 1 Go non compressé, ou cela affecte fortement l'utilisation du processeur. Il est essentiel de stocker des données de manière compacte (sans “garbage”) même lorsqu'il n'est pas compressé, puisque la vitesse de décompression (utilisation du processeur) dépend principalement du volume de données non compressées. - -Il est à noter car il existe des systèmes qui peuvent stocker des valeurs de différentes colonnes séparément, mais qui ne peuvent pas traiter efficacement les requêtes analytiques en raison de leur optimisation pour d'autres scénarios. Les exemples sont HBase, BigTable, Cassandra et HyperTable. Dans ces systèmes, vous obtiendriez un débit d'environ cent mille lignes par seconde, mais pas des centaines de millions de lignes par seconde. - -Il est également intéressant de noter que ClickHouse est un système de gestion de base de données, pas une seule base de données. ClickHouse permet de créer des tables et des bases de données en cours d'exécution, de charger des données et d'exécuter des requêtes sans reconfigurer et redémarrer le serveur. - -## Compression De Données {#data-compression} - -Certains SGBD orientés colonne (InfiniDB CE et MonetDB) n'utilisent pas la compression de données. Cependant, la compression des données joue un rôle clé dans la réalisation d'excellentes performances. - -## Stockage de données sur disque {#disk-storage-of-data} - -Garder les données physiquement triées par clé primaire permet d'extraire des données pour ses valeurs spécifiques ou plages de valeurs avec une faible latence, moins de quelques dizaines de millisecondes. Certains SGBD orientés colonne (tels que SAP HANA et Google PowerDrill) ne peuvent fonctionner qu'en RAM. Cette approche encourage l'allocation d'un budget matériel plus important que ce qui est nécessaire pour l'analyse en temps réel. ClickHouse est conçu pour fonctionner sur des disques durs réguliers, ce qui signifie que le coût par Go de stockage de données est faible, mais SSD et RAM supplémentaire sont également entièrement utilisés si disponible. - -## Traitement parallèle sur plusieurs cœurs {#parallel-processing-on-multiple-cores} - -Les grandes requêtes sont parallélisées naturellement, en prenant toutes les ressources nécessaires disponibles sur le serveur actuel. - -## Traitement distribué sur plusieurs serveurs {#distributed-processing-on-multiple-servers} - -Presque aucun des SGBD en colonnes mentionnés ci-dessus ne prend en charge le traitement des requêtes distribuées. -Dans ClickHouse, les données peuvent résider sur différents fragments. Chaque fragment peut être un groupe de répliques utilisées pour la tolérance aux pannes. Tous les fragments sont utilisés pour exécuter une requête en parallèle, de façon transparente pour l'utilisateur. - -## Prise en charge SQL {#sql-support} - -ClickHouse prend en charge un langage de requête déclarative basé sur SQL qui est identique à la norme SQL dans de nombreux cas. -Les requêtes prises en charge incluent les clauses GROUP BY, ORDER BY, les sous-requêtes in FROM, IN et JOIN, ainsi que les sous-requêtes scalaires. -Les sous-requêtes dépendantes et les fonctions de fenêtre ne sont pas prises en charge. - -## Moteur Vectoriel {#vector-engine} - -Les données ne sont pas seulement stockées par des colonnes, mais sont traitées par des vecteurs (parties de colonnes), ce qui permet d'atteindre une efficacité élevée du processeur. - -## Données en temps réel des Mises à jour {#real-time-data-updates} - -ClickHouse prend en charge les tables avec une clé primaire. Pour effectuer rapidement des requêtes sur la plage de la clé primaire, les données sont triées progressivement à l'aide de l'arborescence de fusion. Pour cette raison, les données peuvent être continuellement ajoutées à la table. Pas de verrouillage lorsque de nouvelles données sont ingérés. - -## Index {#index} - -Avoir une donnée physiquement triée par clé primaire permet d'extraire des données pour ses valeurs spécifiques ou plages de valeurs avec une faible latence, moins de quelques dizaines de millisecondes. - -## Convient pour les requêtes en ligne {#suitable-for-online-queries} - -Faible latence signifie que les requêtes peuvent être traitées sans délai et sans essayer de préparer une réponse à l'avance, au même moment pendant le chargement de la page de l'interface utilisateur. En d'autres termes, en ligne. - -## Prise en charge des calculs approximatifs {#support-for-approximated-calculations} - -ClickHouse offre différentes façons d'échanger la précision pour la performance: - -1. Fonctions d'agrégation pour le calcul approximatif du nombre de valeurs distinctes, de médianes et de quantiles. -2. L'exécution d'une requête basée sur une partie (échantillon) de données et obtenir un pseudo résultat. Dans ce cas, proportionnellement, moins de données sont récupérées à partir du disque. -3. L'exécution d'une agrégation pour un nombre limité de clés aléatoires, au lieu de toutes les clés. Sous certaines conditions pour la distribution des clés dans les données, cela fournit un résultat raisonnablement précis tout en utilisant moins de ressources. - -## Prise en charge de la réplication et de l'intégrité des données {#data-replication-and-data-integrity-support} - -ClickHouse utilise la réplication multi-maître asynchrone. Après avoir été écrit dans n'importe quelle réplique disponible, toutes les répliques restantes récupèrent leur copie en arrière-plan. Le système conserve des données identiques sur différentes répliques. La récupération après la plupart des échecs est effectuée automatiquement ou semi-automatiquement dans les cas complexes. - -Pour plus d'informations, consultez la section [Réplication des données](../engines/table_engines/mergetree_family/replication.md). - -## Caractéristiques de ClickHouse qui peuvent être considérées comme des inconvénients {#clickhouse-features-that-can-be-considered-disadvantages} - -1. Pas de transactions à part entière. -2. Manque de capacité à modifier ou supprimer des données déjà insérées avec un taux élevé et une faible latence. Des suppressions et des mises à jour par lots sont disponibles pour nettoyer ou modifier les données, par exemple pour [GDPR](https://gdpr-info.eu). -3. L'index clairsemé rend ClickHouse pas si approprié pour les requêtes ponctuelles récupérant des lignes simples par leurs clés. - -[Article Original](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/fr/introduction/history.md b/docs/fr/introduction/history.md index f40ae1eda52..8bf1400d7f7 100644 --- a/docs/fr/introduction/history.md +++ b/docs/fr/introduction/history.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 7 toc_title: Histoire --- diff --git a/docs/fr/introduction/index.md b/docs/fr/introduction/index.md index 365784abfca..e0496b30f00 100644 --- a/docs/fr/introduction/index.md +++ b/docs/fr/introduction/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Introduction toc_priority: 1 --- diff --git a/docs/fr/introduction/performance.md b/docs/fr/introduction/performance.md index 3e94830d7c0..30d521e11cd 100644 --- a/docs/fr/introduction/performance.md +++ b/docs/fr/introduction/performance.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 6 toc_title: Performance --- diff --git a/docs/fr/operations/access-rights.md b/docs/fr/operations/access-rights.md new file mode 100644 index 00000000000..350a19bb7de --- /dev/null +++ b/docs/fr/operations/access-rights.md @@ -0,0 +1,143 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: "Le Contr\xF4le d'acc\xE8s et de Gestion de Compte" +--- + +# Le Contrôle d'accès et de Gestion de Compte {#access-control} + +Clickhouse prend en charge la gestion du contrôle d'accès basée sur [RBAC](https://en.wikipedia.org/wiki/Role-based_access_control) approche. + +Entités d'accès ClickHouse: +- [Compte d'utilisateur](#user-account-management) +- [Rôle](#role-management) +- [La Ligne Politique](#row-policy-management) +- [Les Paramètres De Profil](#settings-profiles-management) +- [Quota](#quotas-management) + +Vous pouvez configurer des entités d'accès à l'aide de: + +- Flux de travail piloté par SQL. + + Vous avez besoin de [permettre](#enabling-access-control) cette fonctionnalité. + +- Serveur [les fichiers de configuration](configuration-files.md) `users.xml` et `config.xml`. + +Nous vous recommandons D'utiliser un workflow piloté par SQL. Les deux méthodes de configuration fonctionnent simultanément, donc si vous utilisez les fichiers de configuration du serveur pour gérer les comptes et les droits d'accès, vous pouvez passer doucement au flux de travail piloté par SQL. + +!!! note "Avertissement" + Vous ne pouvez pas gérer la même entité d'accès par les deux méthodes de configuration simultanément. + +## Utilisation {#access-control-usage} + +Par défaut, le serveur ClickHouse fournit le compte utilisateur `default` ce qui n'est pas autorisé à utiliser le contrôle D'accès piloté par SQL et la gestion de compte, mais a tous les droits et autorisations. Le `default` compte d'utilisateur est utilisé dans tous les cas, lorsque l'utilisateur n'est pas défini, par exemple, lors de la connexion du client ou dans les requêtes distribuées. Dans le traitement des requêtes distribuées, un compte utilisateur par défaut est utilisé si la configuration du serveur ou du cluster ne spécifie pas [d'utilisateur et mot de passe](../engines/table-engines/special/distributed.md) propriété. + +Si vous commencez simplement à utiliser ClickHouse, vous pouvez utiliser le scénario suivant: + +1. [Permettre](#enabling-access-control) Contrôle D'accès piloté par SQL et gestion de compte pour le `default` utilisateur. +2. Connexion en vertu de la `default` compte d'utilisateur et de créer tous les utilisateurs. N'oubliez pas de créer un compte d'administrateur (`GRANT ALL ON *.* WITH GRANT OPTION TO admin_user_account`). +3. [Restreindre les autorisations](settings/permissions-for-queries.md#permissions_for_queries) pour l' `default` utilisateur et désactiver le contrôle D'accès piloté par SQL et la gestion des comptes pour elle. + +### Propriétés de la Solution actuelle {#access-control-properties} + +- Vous pouvez accorder des autorisations pour les bases de données et les tables même si elles n'existent pas. +- Si une table a été supprimée, tous les privilèges correspondant à cette table ne sont pas révoqués. Ainsi, si une nouvelle table est créée plus tard avec le même nom, tous les privilèges redeviennent réels. Pour révoquer les privilèges correspondant à la table supprimée, vous devez effectuer, par exemple, l' `REVOKE ALL PRIVILEGES ON db.table FROM ALL` requête. +- Il n'y a pas de paramètres de durée de vie pour les privilèges. + +## Compte d'utilisateur {#user-account-management} + +Un compte d'utilisateur est une entité qui permet d'autoriser quelqu'un à ClickHouse. Un compte utilisateur contient: + +- Informations d'Identification. +- [Privilège](../sql-reference/statements/grant.md#grant-privileges) qui définissent l'étendue des requêtes que l'utilisateur peut effectuer. +- Hôtes à partir desquels la connexion au serveur ClickHouse est autorisée. +- Rôles accordés et par défaut. +- Paramètres avec leurs contraintes qui s'appliquent par défaut lors de la connexion de l'utilisateur. +- Profils de paramètres assignés. + +Des privilèges à un compte d'utilisateur peuvent être accordés par [GRANT](../sql-reference/statements/grant.md) requête ou en attribuant [rôle](#role-management). Pour révoquer les privilèges d'un utilisateur, ClickHouse fournit [REVOKE](../sql-reference/statements/revoke.md) requête. Pour lister les privilèges d'un utilisateur, utilisez - [SHOW GRANTS](../sql-reference/statements/show.md#show-grants-statement) déclaration. + +Gestion des requêtes: + +- [CREATE USER](../sql-reference/statements/create.md#create-user-statement) +- [ALTER USER](../sql-reference/statements/alter.md#alter-user-statement) +- [DROP USER](../sql-reference/statements/misc.md#drop-user-statement) +- [SHOW CREATE USER](../sql-reference/statements/show.md#show-create-user-statement) + +### Paramètres Application {#access-control-settings-applying} + +Les paramètres peuvent être définis de différentes manières: pour un compte utilisateur, dans ses profils de rôles et de paramètres accordés. Lors d'une connexion utilisateur, si un paramètre est défini dans différentes entités d'accès, la valeur et les contraintes de ce paramètre sont appliquées par les priorités suivantes (de plus haut à plus bas): + +1. Paramètre de compte utilisateur. +2. Les paramètres de rôles par défaut du compte d'utilisateur. Si un paramètre est défini dans certains rôles, l'ordre de la mise en application n'est pas défini. +3. Les paramètres dans les profils de paramètres attribués à un utilisateur ou à ses rôles par défaut. Si un paramètre est défini dans certains profils, l'ordre d'application des paramètres n'est pas défini. +4. Paramètres appliqués à l'ensemble du serveur par défaut [profil par défaut](server-configuration-parameters/settings.md#default-profile). + +## Rôle {#role-management} + +Le rôle est un conteneur pour l'accès des entités qui peuvent être accordées à un compte d'utilisateur. + +Rôle contient: + +- [Privilège](../sql-reference/statements/grant.md#grant-privileges) +- Paramètres et contraintes +- Liste des rôles attribués + +Gestion des requêtes: + +- [CREATE ROLE](../sql-reference/statements/create.md#create-role-statement) +- [ALTER ROLE](../sql-reference/statements/alter.md#alter-role-statement) +- [DROP ROLE](../sql-reference/statements/misc.md#drop-role-statement) +- [SET ROLE](../sql-reference/statements/misc.md#set-role-statement) +- [SET DEFAULT ROLE](../sql-reference/statements/misc.md#set-default-role-statement) +- [SHOW CREATE ROLE](../sql-reference/statements/show.md#show-create-role-statement) + +Les privilèges d'un rôle peuvent être accordés par [GRANT](../sql-reference/statements/grant.md) requête. Pour révoquer les privilèges D'un rôle ClickHouse fournit [REVOKE](../sql-reference/statements/revoke.md) requête. + +## La Ligne Politique {#row-policy-management} + +La stratégie de ligne est un filtre qui définit les lignes disponibles pour un utilisateur ou pour un rôle. La stratégie de ligne contient des filtres pour une table spécifique et une liste de rôles et / ou d'utilisateurs qui doivent utiliser cette stratégie de ligne. + +Gestion des requêtes: + +- [CREATE ROW POLICY](../sql-reference/statements/create.md#create-row-policy-statement) +- [ALTER ROW POLICY](../sql-reference/statements/alter.md#alter-row-policy-statement) +- [DROP ROW POLICY](../sql-reference/statements/misc.md#drop-row-policy-statement) +- [SHOW CREATE ROW POLICY](../sql-reference/statements/show.md#show-create-row-policy-statement) + +## Les Paramètres De Profil {#settings-profiles-management} + +Paramètres profil est une collection de [paramètre](settings/index.md). Le profil paramètres contient les paramètres et les contraintes, ainsi que la liste des rôles et/ou des utilisateurs auxquels ce quota est appliqué. + +Gestion des requêtes: + +- [CREATE SETTINGS PROFILE](../sql-reference/statements/create.md#create-settings-profile-statement) +- [ALTER SETTINGS PROFILE](../sql-reference/statements/alter.md#alter-settings-profile-statement) +- [DROP SETTINGS PROFILE](../sql-reference/statements/misc.md#drop-settings-profile-statement) +- [SHOW CREATE SETTINGS PROFILE](../sql-reference/statements/show.md#show-create-settings-profile-statement) + +## Quota {#quotas-management} + +Le Quota limite l'utilisation des ressources. Voir [Quota](quotas.md). + +Quota contient un ensemble de limites pour certaines durées, et la liste des rôles et/ou des utilisateurs qui devrait utiliser ce quota. + +Gestion des requêtes: + +- [CREATE QUOTA](../sql-reference/statements/create.md#create-quota-statement) +- [ALTER QUOTA](../sql-reference/statements/alter.md#alter-quota-statement) +- [DROP QUOTA](../sql-reference/statements/misc.md#drop-quota-statement) +- [SHOW CREATE QUOTA](../sql-reference/statements/show.md#show-create-quota-statement) + +## Activation du contrôle D'accès piloté par SQL et de la gestion de Compte {#enabling-access-control} + +- Configurez un répertoire pour le stockage des configurations. + + Clickhouse stocke les configurations d'entité d'accès dans le dossier défini dans [access\_control\_path](server-configuration-parameters/settings.md#access_control_path) paramètre de configuration du serveur. + +- Activez le contrôle D'accès piloté par SQL et la gestion de compte pour au moins un compte d'utilisateur. + + Par défaut, le contrôle D'accès piloté par SQL et la gestion des comptes sont activés pour tous les utilisateurs. Vous devez configurer au moins un utilisateur dans le `users.xml` fichier de configuration et affecter 1 au [access\_management](settings/settings-users.md#access_management-user-setting) paramètre. + +[Article Original](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/fr/operations/access_rights.md b/docs/fr/operations/access_rights.md deleted file mode 100644 index e01f8428209..00000000000 --- a/docs/fr/operations/access_rights.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 48 -toc_title: "Les Droits D'Acc\xE8s" ---- - -# Les Droits D'Accès {#access-rights} - -Les utilisateurs et les droits d'accès sont configurés dans la configuration utilisateur. Ce n'est généralement `users.xml`. - -Les utilisateurs sont enregistrés dans le `users` section. Voici un fragment de la `users.xml` fichier: - -``` xml - - - - - - - - - - - - default - - - default - - - - - - - web - default - - test - - - test - - - -``` - -Vous pouvez voir une déclaration de deux utilisateurs: `default`et`web`. Nous avons ajouté l' `web` utilisateur séparément. - -Le `default` l'utilisateur est choisi dans les cas où le nom d'utilisateur n'est pas passé. Le `default` l'utilisateur est également utilisé pour le traitement des requêtes distribuées, si la configuration du serveur ou du cluster `user` et `password` (voir la section sur les [Distribué](../engines/table_engines/special/distributed.md) moteur). - -The user that is used for exchanging information between servers combined in a cluster must not have substantial restrictions or quotas – otherwise, distributed queries will fail. - -Le mot de passe est spécifié en texte clair (non recommandé) ou en SHA-256. Le hash n'est pas salé. À cet égard, vous ne devez pas considérer ces mots de passe comme assurant la sécurité contre les attaques malveillantes potentielles. Au contraire, ils sont nécessaires pour la protection contre les employés. - -Une liste de réseaux est précisé que l'accès est autorisé à partir. Dans cet exemple, la liste des réseaux pour les utilisateurs est chargé à partir d'un fichier séparé (`/etc/metrika.xml`) contenant les `networks` substitution. Voici un fragment de: - -``` xml - - ... - - ::/64 - 203.0.113.0/24 - 2001:DB8::/32 - ... - - -``` - -Vous pouvez définir cette liste de réseaux directement dans `users.xml` ou dans un fichier dans le `users.d` répertoire (pour plus d'informations, consultez la section “[Fichiers de Configuration](configuration_files.md#configuration_files)”). - -La configuration comprend des commentaires expliquant comment ouvrir l'accès de partout. - -Pour une utilisation en production, spécifiez uniquement `ip` (adresses IP et leurs masques), depuis l'utilisation `host` et `hoost_regexp` peut causer une latence supplémentaire. - -Ensuite, le profil des paramètres utilisateur est spécifié (voir la section “[Les paramètres des profils](settings/settings_profiles.md)”. Vous pouvez spécifier le profil par défaut, `default'`. Le profil peut avoir n'importe quel nom. Vous pouvez spécifier le même profil pour différents utilisateurs. La chose la plus importante que vous pouvez écrire dans les paramètres de profil `readonly=1` qui assure un accès en lecture seule. Spécifiez ensuite le quota à utiliser (voir la section “[Quota](quotas.md#quotas)”). Vous pouvez spécifier le quota par défaut: `default`. It is set in the config by default to only count resource usage, without restricting it. The quota can have any name. You can specify the same quota for different users – in this case, resource usage is calculated for each user individually. - -Dans le facultatif `` section, vous pouvez également spécifier une liste de bases de données que l'utilisateur peut accéder. Par défaut, toutes les bases de données sont disponibles pour l'utilisateur. Vous pouvez spécifier l' `default` la base de données. Dans ce cas, l'utilisateur recevra l'accès à la base de données par défaut. - -Dans le facultatif `` section, vous pouvez également spécifier une liste de dictionnaires que l'utilisateur peut accéder. Par défaut, tous les dictionnaires sont disponibles pour l'utilisateur. - -L'accès à la `system` la base de données est toujours autorisée (puisque cette base de données est utilisée pour traiter les requêtes). - -L'utilisateur peut obtenir une liste de toutes les bases de données et tables en utilisant `SHOW` requêtes ou tables système, même si l'accès aux bases de données individuelles n'est pas autorisé. - -Accès de base de données n'est pas liée à la [ReadOnly](settings/permissions_for_queries.md#settings_readonly) paramètre. Vous ne pouvez pas accorder un accès complet à une base de données et `readonly` l'accès à un autre. - -[Article Original](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/fr/operations/backup.md b/docs/fr/operations/backup.md index 6d66e5a609c..9a463372947 100644 --- a/docs/fr/operations/backup.md +++ b/docs/fr/operations/backup.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 49 toc_title: "La Sauvegarde Des Donn\xE9es" --- # La Sauvegarde Des Données {#data-backup} -Alors [réplication](../engines/table_engines/mergetree_family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [vous ne pouvez pas simplement supprimer des tables avec un moteur de type MergeTree contenant plus de 50 Go de données](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Toutefois, ces garanties ne couvrent pas tous les cas possibles et peuvent être contournés. +Alors [réplication](../engines/table-engines/mergetree-family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [vous ne pouvez pas simplement supprimer des tables avec un moteur de type MergeTree contenant plus de 50 Go de données](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Toutefois, ces garanties ne couvrent pas tous les cas possibles et peuvent être contournés. Afin d'atténuer efficacement les erreurs humaines possibles, vous devez préparer soigneusement une stratégie de sauvegarde et de restauration de vos données **préalablement**. @@ -22,7 +22,7 @@ Souvent, les données qui sont ingérées dans ClickHouse sont livrées via une ## Instantanés Du Système De Fichiers {#filesystem-snapshots} -Certains systèmes de fichiers locaux fournissent des fonctionnalités d'instantané (par exemple, [ZFS](https://en.wikipedia.org/wiki/ZFS)), mais ils pourraient ne pas être le meilleur choix pour servir les requêtes actives. Une solution possible consiste à créer des répliques supplémentaires avec ce type de système de fichiers et à les exclure du [Distribué](../engines/table_engines/special/distributed.md) les tables qui sont utilisés pour `SELECT` requête. Les instantanés sur ces répliques seront hors de portée des requêtes qui modifient les données. En prime, ces répliques pourraient avoir des configurations matérielles spéciales avec plus de disques attachés par serveur, ce qui serait rentable. +Certains systèmes de fichiers locaux fournissent des fonctionnalités d'instantané (par exemple, [ZFS](https://en.wikipedia.org/wiki/ZFS)), mais ils pourraient ne pas être le meilleur choix pour servir les requêtes actives. Une solution possible consiste à créer des répliques supplémentaires avec ce type de système de fichiers et à les exclure du [Distribué](../engines/table-engines/special/distributed.md) les tables qui sont utilisés pour `SELECT` requête. Les instantanés sur ces répliques seront hors de portée des requêtes qui modifient les données. En prime, ces répliques pourraient avoir des configurations matérielles spéciales avec plus de disques attachés par serveur, ce qui serait rentable. ## clickhouse-copieur {#clickhouse-copier} @@ -30,11 +30,11 @@ Certains systèmes de fichiers locaux fournissent des fonctionnalités d'instant Pour de plus petits volumes de données, un simple `INSERT INTO ... SELECT ...` les tables distantes peuvent également fonctionner. -## Manipulations Avec Des Pièces {#manipulations-with-parts} +## Manipulations avec des pièces {#manipulations-with-parts} ClickHouse permet d'utiliser le `ALTER TABLE ... FREEZE PARTITION ...` requête pour créer une copie locale des partitions de table. Ceci est implémenté en utilisant des liens durs vers le `/var/lib/clickhouse/shadow/` dossier, donc il ne consomme généralement pas d'espace disque supplémentaire pour les anciennes données. Les copies créées des fichiers ne sont pas gérées par clickhouse server, vous pouvez donc les laisser là: vous aurez une sauvegarde simple qui ne nécessite aucun système externe supplémentaire, mais elle sera toujours sujette à des problèmes matériels. Pour cette raison, il est préférable de les copier à distance vers un autre emplacement, puis de supprimer les copies locales. Les systèmes de fichiers distribués et les magasins d'objets sont toujours une bonne option pour cela, mais les serveurs de fichiers attachés normaux avec une capacité suffisante peuvent également fonctionner (dans ce cas, le transfert se fera via le système de fichiers réseau ou peut-être [rsync](https://en.wikipedia.org/wiki/Rsync)). -Pour plus d'informations sur les requêtes liées aux manipulations de [Modifier la documentation](../sql_reference/statements/alter.md#alter_manipulations-with-partitions). +Pour plus d'informations sur les requêtes liées aux manipulations de [Modifier la documentation](../sql-reference/statements/alter.md#alter_manipulations-with-partitions). Un outil tiers est disponible pour automatiser cette approche: [clickhouse-sauvegarde](https://github.com/AlexAkulov/clickhouse-backup). diff --git a/docs/fr/operations/configuration-files.md b/docs/fr/operations/configuration-files.md new file mode 100644 index 00000000000..71569cc9385 --- /dev/null +++ b/docs/fr/operations/configuration-files.md @@ -0,0 +1,57 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: Fichiers De Configuration +--- + +# Fichiers De Configuration {#configuration_files} + +ClickHouse prend en charge la gestion de la configuration multi-fichiers. Le fichier de configuration du serveur principal est `/etc/clickhouse-server/config.xml`. Les autres fichiers doivent être dans le `/etc/clickhouse-server/config.d` répertoire. + +!!! note "Note" + Tous les fichiers de configuration doivent être au format XML. Aussi, ils doivent avoir le même élément racine, généralement ``. + +Certains paramètres spécifiés dans le fichier de configuration principal peuvent être remplacés dans d'autres fichiers de configuration. Le `replace` ou `remove` les attributs peuvent être spécifiés pour les éléments de ces fichiers de configuration. + +Si ni l'un ni l'autre n'est spécifié, il combine le contenu des éléments de manière récursive, remplaçant les valeurs des enfants en double. + +Si `replace` est spécifié, il remplace l'élément entier par celui spécifié. + +Si `remove` est spécifié, il supprime l'élément. + +La configuration peut également définir “substitutions”. Si un élément a le `incl` attribut, la substitution correspondante du fichier sera utilisée comme valeur. Par défaut, le chemin d'accès au fichier avec des substitutions est `/etc/metrika.xml`. Ceci peut être changé dans le [include\_from](server-configuration-parameters/settings.md#server_configuration_parameters-include_from) élément dans la configuration du serveur. Les valeurs de substitution sont spécifiées dans `/yandex/substitution_name` les éléments de ce fichier. Si une substitution spécifiée dans `incl` n'existe pas, il est enregistré dans le journal. Pour empêcher ClickHouse de consigner les substitutions manquantes, spécifiez `optional="true"` attribut (par exemple, les paramètres de [macro](server-configuration-parameters/settings.md)). + +Les Substitutions peuvent également être effectuées à partir de ZooKeeper. Pour ce faire, spécifiez l'attribut `from_zk = "/path/to/node"`. La valeur de l'élément est remplacé par le contenu du noeud au `/path/to/node` dans ZooKeeper. Vous pouvez également placer un sous-arbre XML entier sur le nœud ZooKeeper et il sera entièrement inséré dans l'élément source. + +Le `config.xml` le fichier peut spécifier une configuration distincte avec les paramètres utilisateur, les profils et les quotas. Le chemin relatif à cette configuration est défini dans `users_config` élément. Par défaut, il est `users.xml`. Si `users_config` est omis, les paramètres utilisateur, les profils et les quotas sont `config.xml`. + +La configuration des utilisateurs peut être divisée en fichiers séparés similaires à `config.xml` et `config.d/`. +Nom du répertoire est défini comme `users_config` sans `.xml` postfix concaténé avec `.d`. +Répertoire `users.d` est utilisé par défaut, comme `users_config` par défaut `users.xml`. +Par exemple, vous pouvez avoir séparé fichier de configuration pour chaque utilisateur comme ceci: + +``` bash +$ cat /etc/clickhouse-server/users.d/alice.xml +``` + +``` xml + + + + analytics + + ::/0 + + ... + analytics + + + +``` + +Pour chaque fichier de configuration, le serveur génère également `file-preprocessed.xml` les fichiers lors du démarrage. Ces fichiers contiennent toutes les remplacements et des remplacements, et ils sont destinés à l'usage informatif. Si des substitutions ZooKeeper ont été utilisées dans les fichiers de configuration mais que ZooKeeper n'est pas disponible au démarrage du serveur, le serveur charge la configuration à partir du fichier prétraité. + +Le serveur suit les changements dans les fichiers de configuration, ainsi que les fichiers et les nœuds ZooKeeper utilisés lors des substitutions et des remplacements, et recharge les paramètres pour les utilisateurs et les clusters à la volée. Cela signifie que vous pouvez modifier le cluster, les utilisateurs et leurs paramètres sans redémarrer le serveur. + +[Article Original](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/fr/operations/configuration_files.md b/docs/fr/operations/configuration_files.md deleted file mode 100644 index 0322551ab63..00000000000 --- a/docs/fr/operations/configuration_files.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 50 -toc_title: Fichiers De Configuration ---- - -# Fichiers De Configuration {#configuration_files} - -ClickHouse prend en charge la gestion de la configuration multi-fichiers. Le fichier de configuration du serveur principal est `/etc/clickhouse-server/config.xml`. Les autres fichiers doivent être dans le `/etc/clickhouse-server/config.d` répertoire. - -!!! note "Note" - Tous les fichiers de configuration doivent être au format XML. Aussi, ils doivent avoir le même élément racine, généralement ``. - -Certains paramètres spécifiés dans le fichier de configuration principal peuvent être remplacés dans d'autres fichiers de configuration. Le `replace` ou `remove` les attributs peuvent être spécifiés pour les éléments de ces fichiers de configuration. - -Si ni l'un ni l'autre n'est spécifié, il combine le contenu des éléments de manière récursive, remplaçant les valeurs des enfants en double. - -Si `replace` est spécifié, il remplace l'élément entier par celui spécifié. - -Si `remove` est spécifié, il supprime l'élément. - -La configuration peut également définir “substitutions”. Si un élément a le `incl` attribut, la substitution correspondante du fichier sera utilisée comme valeur. Par défaut, le chemin d'accès au fichier avec des substitutions est `/etc/metrika.xml`. Ceci peut être changé dans le [include\_from](server_configuration_parameters/settings.md#server_configuration_parameters-include_from) élément dans la configuration du serveur. Les valeurs de substitution sont spécifiées dans `/yandex/substitution_name` les éléments de ce fichier. Si une substitution spécifiée dans `incl` n'existe pas, il est enregistré dans le journal. Pour empêcher ClickHouse de consigner les substitutions manquantes, spécifiez `optional="true"` attribut (par exemple, les paramètres de [macro](server_configuration_parameters/settings.md)). - -Les Substitutions peuvent également être effectuées à partir de ZooKeeper. Pour ce faire, spécifiez l'attribut `from_zk = "/path/to/node"`. La valeur de l'élément est remplacé par le contenu du noeud au `/path/to/node` dans ZooKeeper. Vous pouvez également placer un sous-arbre XML entier sur le nœud ZooKeeper et il sera entièrement inséré dans l'élément source. - -Le `config.xml` le fichier peut spécifier une configuration distincte avec les paramètres utilisateur, les profils et les quotas. Le chemin relatif à cette configuration est défini dans `users_config` élément. Par défaut, il est `users.xml`. Si `users_config` est omis, les paramètres utilisateur, les profils et les quotas sont `config.xml`. - -La configuration des utilisateurs peut être divisée en fichiers séparés similaires à `config.xml` et `config.d/`. -Nom du répertoire est défini comme `users_config` sans `.xml` postfix concaténé avec `.d`. -Répertoire `users.d` est utilisé par défaut, comme `users_config` par défaut `users.xml`. -Par exemple, vous pouvez avoir séparé fichier de configuration pour chaque utilisateur comme ceci: - -``` bash -$ cat /etc/clickhouse-server/users.d/alice.xml -``` - -``` xml - - - - analytics - - ::/0 - - ... - analytics - - - -``` - -Pour chaque fichier de configuration, le serveur génère également `file-preprocessed.xml` les fichiers lors du démarrage. Ces fichiers contiennent toutes les remplacements et des remplacements, et ils sont destinés à l'usage informatif. Si des substitutions ZooKeeper ont été utilisées dans les fichiers de configuration mais que ZooKeeper n'est pas disponible au démarrage du serveur, le serveur charge la configuration à partir du fichier prétraité. - -Le serveur suit les changements dans les fichiers de configuration, ainsi que les fichiers et les nœuds ZooKeeper utilisés lors des substitutions et des remplacements, et recharge les paramètres pour les utilisateurs et les clusters à la volée. Cela signifie que vous pouvez modifier le cluster, les utilisateurs et leurs paramètres sans redémarrer le serveur. - -[Article Original](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/fr/operations/index.md b/docs/fr/operations/index.md index 92265ce9fcf..23f98bdaed2 100644 --- a/docs/fr/operations/index.md +++ b/docs/fr/operations/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Operations +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Op\xE9rations" toc_priority: 41 toc_title: Introduction --- @@ -15,14 +15,14 @@ Le manuel d'exploitation de ClickHouse comprend les principales sections suivant - [Dépannage](troubleshooting.md) - [Recommandations D'Utilisation](tips.md) - [Procédure De Mise À Jour](update.md) -- [Les Droits D'Accès](access_rights.md) +- [Les Droits D'Accès](access-rights.md) - [La Sauvegarde Des Données](backup.md) -- [Fichiers De Configuration](configuration_files.md) +- [Fichiers De Configuration](configuration-files.md) - [Quota](quotas.md) -- [Les Tables Système](system_tables.md) -- [Paramètres De Configuration Du Serveur](server_configuration_parameters/index.md) -- [Comment Tester Votre Matériel Avec ClickHouse](performance_test.md) +- [Les Tables Système](system-tables.md) +- [Paramètres De Configuration Du Serveur](server-configuration-parameters/index.md) +- [Comment Tester Votre Matériel Avec ClickHouse](performance-test.md) - [Paramètre](settings/index.md) - [Utilitaire](utilities/index.md) -[Article Original](https://clickhouse.tech/docs/en/operations/) +{## [Article Original](https://clickhouse.tech/docs/en/operations/) ##} diff --git a/docs/fr/operations/monitoring.md b/docs/fr/operations/monitoring.md index 851f3c73ce8..275e8a5d8ac 100644 --- a/docs/fr/operations/monitoring.md +++ b/docs/fr/operations/monitoring.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 45 toc_title: Surveiller --- @@ -24,20 +24,22 @@ Il est fortement recommandé de configurer la surveillance de: - Utilisation du système de stockage, de la RAM et du réseau. -## Métriques Du Serveur Clickhouse {#clickhouse-server-metrics} +## Métriques Du Serveur ClickHouse {#clickhouse-server-metrics} Clickhouse server a des instruments embarqués pour la surveillance de l'auto-état. -Pour suivre les événements du serveur, utilisez les journaux du serveur. Voir la [enregistreur](server_configuration_parameters/settings.md#server_configuration_parameters-logger) section du fichier de configuration. +Pour suivre les événements du serveur, utilisez les journaux du serveur. Voir la [enregistreur](server-configuration-parameters/settings.md#server_configuration_parameters-logger) section du fichier de configuration. Clickhouse recueille: - Différentes mesures de la façon dont le serveur utilise les ressources de calcul. - Statistiques communes sur le traitement des requêtes. -Vous pouvez trouver des mesures dans le [système.métrique](../operations/system_tables.md#system_tables-metrics), [système.événement](../operations/system_tables.md#system_tables-events), et [système.asynchronous\_metrics](../operations/system_tables.md#system_tables-asynchronous_metrics) table. +Vous pouvez trouver des mesures dans le [système.métrique](../operations/system-tables.md#system_tables-metrics), [système.événement](../operations/system-tables.md#system_tables-events), et [système.asynchronous\_metrics](../operations/system-tables.md#system_tables-asynchronous_metrics) table. -Vous pouvez configurer ClickHouse pour exporter des métriques vers [Graphite](https://github.com/graphite-project). Voir la [Graphite section](server_configuration_parameters/settings.md#server_configuration_parameters-graphite) dans le fichier de configuration du serveur ClickHouse. Avant de configurer l'exportation des métriques, vous devez configurer Graphite en suivant leur [guide](https://graphite.readthedocs.io/en/latest/install.html). +Vous pouvez configurer ClickHouse pour exporter des métriques vers [Graphite](https://github.com/graphite-project). Voir la [Graphite section](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) dans le fichier de configuration du serveur ClickHouse. Avant de configurer l'exportation des métriques, vous devez configurer Graphite en suivant leur [guide](https://graphite.readthedocs.io/en/latest/install.html). + +Vous pouvez configurer ClickHouse pour exporter des métriques vers [Prometheus](https://prometheus.io). Voir la [Prometheus section](server-configuration-parameters/settings.md#server_configuration_parameters-prometheus) dans le fichier de configuration du serveur ClickHouse. Avant de configurer l'exportation des métriques, vous devez configurer Prometheus en suivant leur [guide](https://prometheus.io/docs/prometheus/latest/installation/). De plus, vous pouvez surveiller la disponibilité du serveur via L'API HTTP. Envoyer la `HTTP GET` demande à `/ping`. Si le serveur est disponible, il répond avec `200 OK`. diff --git a/docs/fr/operations/optimizing-performance/index.md b/docs/fr/operations/optimizing-performance/index.md new file mode 100644 index 00000000000..3877d558eca --- /dev/null +++ b/docs/fr/operations/optimizing-performance/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Optimisation Des Performances +toc_priority: 52 +--- + + diff --git a/docs/fr/operations/optimizing-performance/sampling-query-profiler.md b/docs/fr/operations/optimizing-performance/sampling-query-profiler.md new file mode 100644 index 00000000000..ba8f3ecd110 --- /dev/null +++ b/docs/fr/operations/optimizing-performance/sampling-query-profiler.md @@ -0,0 +1,64 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Profilage De Requ\xEAte" +--- + +# Échantillonnage Du Profileur De Requête {#sampling-query-profiler} + +ClickHouse exécute un profileur d'échantillonnage qui permet d'analyser l'exécution des requêtes. En utilisant profiler, vous pouvez trouver des routines de code source qui ont utilisé le plus fréquemment lors de l'exécution de la requête. Vous pouvez suivre le temps CPU et le temps d'horloge murale passé, y compris le temps d'inactivité. + +Utilisation du générateur de profils: + +- Installation de la [trace\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) la section de la configuration du serveur. + + Cette section configure le [trace\_log](../../operations/system-tables.md#system_tables-trace_log) tableau système contenant les résultats du fonctionnement du profileur. Il est configuré par défaut. Rappelez-vous que les données de ce tableau est valable que pour un serveur en cours d'exécution. Après le redémarrage du serveur, ClickHouse ne nettoie pas la table et toute l'adresse de mémoire virtuelle stockée peut devenir invalide. + +- Installation de la [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) ou [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) paramètre. Les deux paramètres peuvent être utilisés simultanément. + + Ces paramètres vous permettent de configurer les minuteries du profileur. Comme il s'agit des paramètres de session, vous pouvez obtenir une fréquence d'échantillonnage différente pour l'ensemble du serveur, les utilisateurs individuels ou les profils d'utilisateurs, pour votre session interactive et pour chaque requête individuelle. + +La fréquence d'échantillonnage par défaut est d'un échantillon par seconde et le processeur et les minuteries réelles sont activés. Cette fréquence permet de collecter suffisamment d'informations sur le cluster ClickHouse. En même temps, en travaillant avec cette fréquence, profiler n'affecte pas les performances du serveur ClickHouse. Si vous avez besoin de profiler chaque requête individuelle, essayez d'utiliser une fréquence d'échantillonnage plus élevée. + +Pour analyser les `trace_log` système de table: + +- Installer le `clickhouse-common-static-dbg` paquet. Voir [Installer à partir de paquets DEB](../../getting-started/install.md#install-from-deb-packages). + +- Autoriser les fonctions d'introspection par [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) paramètre. + + Pour des raisons de sécurité, les fonctions d'introspection sont désactivées par défaut. + +- L'utilisation de la `addressToLine`, `addressToSymbol` et `demangle` [fonctions d'introspection](../../sql-reference/functions/introspection.md) pour obtenir les noms de fonctions et leurs positions dans le code ClickHouse. Pour obtenir un profil pour une requête, vous devez agréger les données du `trace_log` table. Vous pouvez agréger des données par des fonctions individuelles ou par l'ensemble des traces de la pile. + +Si vous avez besoin de visualiser `trace_log` info, essayez [flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) et [speedscope](https://github.com/laplab/clickhouse-speedscope). + +## Exemple {#example} + +Dans cet exemple, nous: + +- Filtrage `trace_log` données par un identifiant de requête et la date actuelle. + +- Agrégation par trace de pile. + +- En utilisant les fonctions d'introspection, nous obtiendrons un rapport de: + + - Noms des symboles et des fonctions de code source correspondantes. + - Emplacements de code Source de ces fonctions. + + + +``` sql +SELECT + count(), + arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym +FROM system.trace_log +WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) +GROUP BY trace +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +{% include "examples/sampling_query_profiler_result.txt" %} +``` diff --git a/docs/fr/operations/optimizing_performance/index.md b/docs/fr/operations/optimizing_performance/index.md deleted file mode 100644 index a596d617d8f..00000000000 --- a/docs/fr/operations/optimizing_performance/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Optimizing Performance -toc_priority: 52 ---- - - diff --git a/docs/fr/operations/optimizing_performance/sampling_query_profiler.md b/docs/fr/operations/optimizing_performance/sampling_query_profiler.md deleted file mode 100644 index a4dd88b2203..00000000000 --- a/docs/fr/operations/optimizing_performance/sampling_query_profiler.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 54 -toc_title: "Profilage De Requ\xEAte" ---- - -# Échantillonnage Du Profileur De Requête {#sampling-query-profiler} - -ClickHouse exécute un profileur d'échantillonnage qui permet d'analyser l'exécution des requêtes. En utilisant profiler, vous pouvez trouver des routines de code source qui ont utilisé le plus fréquemment lors de l'exécution de la requête. Vous pouvez suivre le temps CPU et le temps d'horloge murale passé, y compris le temps d'inactivité. - -Utilisation du générateur de profils: - -- Installation de la [trace\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) la section de la configuration du serveur. - - Cette section configure le [trace\_log](../../operations/system_tables.md#system_tables-trace_log) tableau système contenant les résultats du fonctionnement du profileur. Il est configuré par défaut. Rappelez-vous que les données de ce tableau est valable que pour un serveur en cours d'exécution. Après le redémarrage du serveur, ClickHouse ne nettoie pas la table et toute l'adresse de mémoire virtuelle stockée peut devenir invalide. - -- Installation de la [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) ou [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) paramètre. Les deux paramètres peuvent être utilisés simultanément. - - Ces paramètres vous permettent de configurer les minuteries du profileur. Comme il s'agit des paramètres de session, vous pouvez obtenir une fréquence d'échantillonnage différente pour l'ensemble du serveur, les utilisateurs individuels ou les profils d'utilisateurs, pour votre session interactive et pour chaque requête individuelle. - -La fréquence d'échantillonnage par défaut est d'un échantillon par seconde et le processeur et les minuteries réelles sont activés. Cette fréquence permet de collecter suffisamment d'informations sur le cluster ClickHouse. En même temps, en travaillant avec cette fréquence, profiler n'affecte pas les performances du serveur ClickHouse. Si vous avez besoin de profiler chaque requête individuelle, essayez d'utiliser une fréquence d'échantillonnage plus élevée. - -Pour analyser les `trace_log` système de table: - -- Installer le `clickhouse-common-static-dbg` paquet. Voir [Installer à partir de paquets DEB](../../getting_started/install.md#install-from-deb-packages). - -- Autoriser les fonctions d'introspection par [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) paramètre. - - Pour des raisons de sécurité, les fonctions d'introspection sont désactivées par défaut. - -- L'utilisation de la `addressToLine`, `addressToSymbol` et `demangle` [fonctions d'introspection](../../sql_reference/functions/introspection.md) pour obtenir les noms de fonctions et leurs positions dans le code ClickHouse. Pour obtenir un profil pour une requête, vous devez agréger les données du `trace_log` table. Vous pouvez agréger des données par des fonctions individuelles ou par l'ensemble des traces de la pile. - -Si vous avez besoin de visualiser `trace_log` info, essayez [flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) et [speedscope](https://github.com/laplab/clickhouse-speedscope). - -## Exemple {#example} - -Dans cet exemple, nous: - -- Filtrage `trace_log` données par un identifiant de requête et la date actuelle. - -- Agrégation par trace de pile. - -- En utilisant les fonctions d'introspection, nous obtiendrons un rapport de: - - - Noms des symboles et des fonctions de code source correspondantes. - - Emplacements de code Source de ces fonctions. - - - -``` sql -SELECT - count(), - arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym -FROM system.trace_log -WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) -GROUP BY trace -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -{% include "examples/sampling_query_profiler_result.txt" %} -``` diff --git a/docs/fr/operations/performance-test.md b/docs/fr/operations/performance-test.md new file mode 100644 index 00000000000..6093772aefe --- /dev/null +++ b/docs/fr/operations/performance-test.md @@ -0,0 +1,82 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Tester Le Mat\xE9riel" +--- + +# Comment tester votre matériel avec ClickHouse {#how-to-test-your-hardware-with-clickhouse} + +Avec cette instruction, vous pouvez exécuter le test de performance clickhouse de base sur n'importe quel serveur sans installation de paquets ClickHouse. + +1. Aller à “commits” page: https://github.com/ClickHouse/ClickHouse/commits/master + +2. Cliquez sur la première coche verte ou croix rouge avec vert “ClickHouse Build Check” et cliquez sur le “Details” lien de proximité “ClickHouse Build Check”. Il n'y a pas un tel lien dans certains commits, par exemple des commits avec de la documentation. Dans ce cas, choisissez le commit le plus proche ayant ce lien. + +3. Copiez le lien à “clickhouse” binaire pour amd64 ou aarch64. + +4. ssh sur le serveur et le télécharger avec wget: + + + + # For amd64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse + # For aarch64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse + # Then do: + chmod a+x clickhouse + +1. Télécharger configs: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml + mkdir config.d + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml + +1. Télécharger des fichiers de référence: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh + chmod a+x benchmark-new.sh + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql + +1. Télécharger les données de test selon le [Yandex.Metrica dataset](../getting-started/example-datasets/metrica.md) instruction (“hits” tableau contenant 100 millions de lignes). + + + + wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz + tar xvf hits_100m_obfuscated_v1.tar.xz -C . + mv hits_100m_obfuscated_v1/* . + +1. Exécuter le serveur: + + + + ./clickhouse server + +1. Vérifiez les données: ssh au serveur dans un autre terminal + + + + ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" + 100000000 + +1. Modifier le benchmark-new.sh, changement `clickhouse-client` de `./clickhouse client` et d'ajouter `–-max_memory_usage 100000000000` paramètre. + + + + mcedit benchmark-new.sh + +1. Exécutez le test: + + + + ./benchmark-new.sh hits_100m_obfuscated + +1. Envoyez les numéros et les informations sur votre configuration matérielle à clickhouse-feedback@yandex-team.com + +Tous les résultats sont publiés ici: https://clickhouse.tech/de référence/de matériel/ diff --git a/docs/fr/operations/performance_test.md b/docs/fr/operations/performance_test.md deleted file mode 100644 index 9b4df8e7fd4..00000000000 --- a/docs/fr/operations/performance_test.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 54 -toc_title: "Tester Le Mat\xE9riel" ---- - -# Comment Tester Votre Matériel Avec ClickHouse {#how-to-test-your-hardware-with-clickhouse} - -Avec cette instruction, vous pouvez exécuter le test de performance clickhouse de base sur n'importe quel serveur sans installation de paquets ClickHouse. - -1. Aller à “commits” page: https://github.com/ClickHouse/ClickHouse/commits/master - -2. Cliquez sur la première coche verte ou croix rouge avec vert “ClickHouse Build Check” et cliquez sur le “Details” lien de proximité “ClickHouse Build Check”. - -3. Copiez le lien à “clickhouse” binaire pour amd64 ou aarch64. - -4. ssh sur le serveur et le télécharger avec wget: - - - - # For amd64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse - # For aarch64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse - # Then do: - chmod a+x clickhouse - -1. Télécharger configs: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml - mkdir config.d - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml - -1. Télécharger des fichiers de référence: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh - chmod a+x benchmark-new.sh - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql - -1. Télécharger les données de test selon le [Yandex.Metrica dataset](../getting_started/example_datasets/metrica.md) instruction (“hits” tableau contenant 100 millions de lignes). - - - - wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz - tar xvf hits_100m_obfuscated_v1.tar.xz -C . - mv hits_100m_obfuscated_v1/* . - -1. Exécuter le serveur: - - - - ./clickhouse server - -1. Vérifiez les données: ssh au serveur dans un autre terminal - - - - ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" - 100000000 - -1. Modifier le benchmark-new.sh, changement “clickhouse-client” de “./clickhouse client” et d'ajouter “–max\_memory\_usage 100000000000” paramètre. - - - - mcedit benchmark-new.sh - -1. Exécutez le test: - - - - ./benchmark-new.sh hits_100m_obfuscated - -1. Envoyez les numéros et les informations sur votre configuration matérielle à clickhouse-feedback@yandex-team.com - -Tous les résultats sont publiés ici: https://clickhouse.tech / benchmark\_hardware.HTML diff --git a/docs/fr/operations/quotas.md b/docs/fr/operations/quotas.md index d81ff33c403..ae15c774eaf 100644 --- a/docs/fr/operations/quotas.md +++ b/docs/fr/operations/quotas.md @@ -1,14 +1,14 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 51 toc_title: Quota --- # Quota {#quotas} -Les Quotas permettent de limiter l'utilisation des ressources au cours d'une période de temps, ou tout simplement suivre l'utilisation des ressources. -Les Quotas sont configurés dans la configuration utilisateur. Ce n'est généralement ‘users.xml’. +Les Quotas permettent de limiter l'utilisation des ressources au cours d'une période de temps ou de suivre l'utilisation des ressources. +Les Quotas sont configurés dans la configuration utilisateur, qui est généralement ‘users.xml’. Le système dispose également d'une fonctionnalité pour limiter la complexité d'une seule requête. Voir la section “Restrictions on query complexity”). @@ -39,7 +39,7 @@ Regardons la section de la ‘users.xml’ fichier qui définit les quotas. ``` -Par défaut, le quota suit simplement la consommation de ressources pour chaque heure, sans limiter l'utilisation. +Par défaut, le quota suit la consommation de ressources pour chaque heure, sans limiter l'utilisation. La consommation de ressources calculé pour chaque intervalle est sortie dans le journal du serveur après chaque demande. ``` xml @@ -68,7 +68,7 @@ La consommation de ressources calculé pour chaque intervalle est sortie dans le ``` -Pour l' ‘statbox’ quota, restrictions sont fixées pour toutes les heures et pour toutes les 24 heures (86 400 secondes). L'intervalle de temps est compté à partir d'un moment fixe défini par l'implémentation. En d'autres termes, l'intervalle de 24 heures ne commence pas nécessairement à minuit. +Pour l' ‘statbox’ quota, restrictions sont fixées pour toutes les heures et pour toutes les 24 heures (86 400 secondes). L'intervalle de temps est compté, à partir d'un moment fixe défini par l'implémentation. En d'autres termes, l'intervalle de 24 heures ne commence pas nécessairement à minuit. Lorsque l'intervalle se termine, toutes les valeurs collectées sont effacées. Pour l'heure suivante, le calcul du quota recommence. @@ -78,15 +78,15 @@ Voici les montants qui peuvent être restreint: `errors` – The number of queries that threw an exception. -`result_rows` – The total number of rows given as the result. +`result_rows` – The total number of rows given as a result. -`read_rows` – The total number of source rows read from tables for running the query, on all remote servers. +`read_rows` – The total number of source rows read from tables for running the query on all remote servers. `execution_time` – The total query execution time, in seconds (wall time). Si la limite est dépassée pendant au moins un intervalle de temps, une exception est levée avec un texte indiquant quelle restriction a été dépassée, pour quel intervalle et quand le nouvel intervalle commence (lorsque les requêtes peuvent être envoyées à nouveau). -Les Quotas peuvent utiliser le “quota key” fonctionnalité afin de rendre compte des ressources pour plusieurs clés indépendamment. Voici un exemple de ce: +Les Quotas peuvent utiliser le “quota key” fonctionnalité de rapport sur les ressources pour plusieurs clés indépendamment. Voici un exemple de ce: ``` xml @@ -97,7 +97,7 @@ Les Quotas peuvent utiliser le “quota key” fonctionnalité afin de rendre co so the quota will be counted separately for each username. Using keys makes sense only if quota_key is transmitted by the program, not by a user. - You can also write so the IP address is used as the quota key. + You can also write , so the IP address is used as the quota key. (But keep in mind that users can change the IPv6 address fairly easily.) --> diff --git a/docs/fr/operations/requirements.md b/docs/fr/operations/requirements.md index 56730105760..936d6f57f5b 100644 --- a/docs/fr/operations/requirements.md +++ b/docs/fr/operations/requirements.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 44 toc_title: Exigence --- @@ -13,20 +13,20 @@ Pour l'installation à partir de paquets deb prédéfinis, utilisez un processeu ClickHouse implémente le traitement parallèle des données et utilise toutes les ressources matérielles disponibles. Lors du choix d'un processeur, tenez compte du fait que ClickHouse fonctionne plus efficacement dans les configurations avec un grand nombre de cœurs mais une fréquence d'horloge plus faible que dans les configurations avec moins de cœurs et une fréquence d'horloge plus élevée. Par exemple, 16 cœurs avec 2600 MHz est préférable à 8 cœurs avec 3600 MHz. -L'utilisation de **Turbo Boost** et **la technologie hyper-threading** technologies est recommandé. Il améliore sensiblement les performances avec une charge typique. +Il est recommandé d'utiliser **Turbo Boost** et **la technologie hyper-threading** technologie. Il améliore considérablement les performances avec une charge de travail typique. ## RAM {#ram} -Nous vous recommandons d'utiliser un minimum de 4 Go de RAM afin d'effectuer des requêtes non triviales. Le serveur ClickHouse peut fonctionner avec une quantité beaucoup plus petite de RAM, mais il nécessite de la mémoire pour traiter les requêtes. +Nous vous recommandons d'utiliser un minimum de 4 Go de RAM pour effectuer des requêtes non triviales. Le serveur ClickHouse peut fonctionner avec une quantité beaucoup plus petite de RAM, mais il nécessite de la mémoire pour traiter les requêtes. Le volume de RAM requis dépend de: - La complexité des requêtes. - La quantité de données traitées dans les requêtes. -Pour calculer le volume de RAM requis, vous devez estimer la taille des données temporaires pour [GROUP BY](../sql_reference/statements/select.md#select-group-by-clause), [DISTINCT](../sql_reference/statements/select.md#select-distinct), [JOIN](../sql_reference/statements/select.md#select-join) et d'autres opérations que vous utilisez. +Pour calculer le volume de RAM requis, vous devez estimer la taille des données temporaires pour [GROUP BY](../sql-reference/statements/select/group-by.md#select-group-by-clause), [DISTINCT](../sql-reference/statements/select/distinct.md#select-distinct), [JOIN](../sql-reference/statements/select/join.md#select-join) et d'autres opérations que vous utilisez. -ClickHouse peut utiliser la mémoire externe pour les données temporaires. Voir [Groupe par dans la mémoire externe](../sql_reference/statements/select.md#select-group-by-in-external-memory) pour plus de détails. +ClickHouse peut utiliser la mémoire externe pour les données temporaires. Voir [Groupe par dans la mémoire externe](../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory) pour plus de détails. ## Fichier D'Échange {#swap-file} @@ -56,6 +56,6 @@ La bande passante du réseau est essentielle pour traiter les requêtes distribu ## Logiciel {#software} -ClickHouse est développé pour la famille de systèmes D'exploitation Linux. La distribution Linux recommandée est Ubuntu. Le `tzdata` paquet doit être installé dans le système. +ClickHouse est développé principalement pour la famille de systèmes D'exploitation Linux. La distribution Linux recommandée est Ubuntu. Le `tzdata` paquet doit être installé dans le système. -ClickHouse peut également fonctionner dans d'autres familles de systèmes d'exploitation. Voir les détails dans le [Prise en main](../getting_started/index.md) section de la documentation. +ClickHouse peut également fonctionner dans d'autres familles de systèmes d'exploitation. Voir les détails dans le [Prise en main](../getting-started/index.md) section de la documentation. diff --git a/docs/fr/operations/server-configuration-parameters/index.md b/docs/fr/operations/server-configuration-parameters/index.md new file mode 100644 index 00000000000..0ecfb4a44cc --- /dev/null +++ b/docs/fr/operations/server-configuration-parameters/index.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Param\xE8tres De Configuration Du Serveur" +toc_priority: 54 +toc_title: Introduction +--- + +# Paramètres De Configuration Du Serveur {#server-settings} + +Cette section contient des descriptions des paramètres du serveur qui ne peuvent pas être modifiés au niveau de la session ou de la requête. + +Ces paramètres sont stockés dans la `config.xml` fichier sur le serveur ClickHouse. + +D'autres paramètres sont décrits dans le “[Paramètre](../settings/index.md#session-settings-intro)” section. + +Avant d'étudier les paramètres, lire la [Fichiers de Configuration](../configuration-files.md#configuration_files) section et notez l'utilisation de substitutions (le `incl` et `optional` attribut). + +[Article Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/fr/operations/server-configuration-parameters/settings.md b/docs/fr/operations/server-configuration-parameters/settings.md new file mode 100644 index 00000000000..45be3c5c009 --- /dev/null +++ b/docs/fr/operations/server-configuration-parameters/settings.md @@ -0,0 +1,906 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "Les Param\xE8tres Du Serveur" +--- + +# Les Paramètres Du Serveur {#server-settings} + +## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} + +L'intervalle en secondes avant de recharger les dictionnaires intégrés. + +Clickhouse recharge les dictionnaires intégrés toutes les X secondes. Cela permet d'éditer des dictionnaires “on the fly” sans redémarrer le serveur. + +Valeur par défaut: 3600. + +**Exemple** + +``` xml +3600 +``` + +## compression {#server-settings-compression} + +Paramètres de compression de données pour [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-tables de moteur. + +!!! warning "Avertissement" + Ne l'utilisez pas si vous venez de commencer à utiliser ClickHouse. + +Modèle de Configuration: + +``` xml + + + ... + ... + ... + + ... + +``` + +`` Fields: + +- `min_part_size` – The minimum size of a data part. +- `min_part_size_ratio` – The ratio of the data part size to the table size. +- `method` – Compression method. Acceptable values: `lz4` ou `zstd`. + +Vous pouvez configurer plusieurs `` section. + +Actions lorsque les conditions sont remplies: + +- Si une partie de données correspond à un ensemble de conditions, ClickHouse utilise la méthode de compression spécifiée. +- Si une partie de données correspond à plusieurs ensembles de conditions, ClickHouse utilise le premier ensemble de conditions correspondant. + +Si aucune condition n'est remplie pour une partie de données, ClickHouse utilise `lz4` compression. + +**Exemple** + +``` xml + + + 10000000000 + 0.01 + zstd + + +``` + +## default\_database {#default-database} + +La base de données par défaut. + +Pour obtenir une liste de bases de données, utilisez la [SHOW DATABASES](../../sql-reference/statements/show.md#show-databases) requête. + +**Exemple** + +``` xml +default +``` + +## default\_profile {#default-profile} + +Profil des paramètres par défaut. + +Les paramètres des profils sont situés dans le fichier spécifié dans le paramètre `user_config`. + +**Exemple** + +``` xml +default +``` + +## dictionaries\_config {#server_configuration_parameters-dictionaries_config} + +Chemin d'accès au fichier de configuration des dictionnaires externes. + +Chemin: + +- Spécifiez le chemin absolu ou le chemin relatif au fichier de configuration du serveur. +- Le chemin peut contenir des caractères génériques \* et ?. + +Voir aussi “[Dictionnaires externes](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md)”. + +**Exemple** + +``` xml +*_dictionary.xml +``` + +## dictionaries\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} + +Chargement paresseux des dictionnaires. + +Si `true` chaque dictionnaire est créé lors de la première utilisation. Si la création du dictionnaire a échoué, la fonction qui utilisait le dictionnaire lève une exception. + +Si `false`, tous les dictionnaires sont créés lorsque le serveur démarre, et si il y a une erreur, le serveur s'arrête. + +La valeur par défaut est `true`. + +**Exemple** + +``` xml +true +``` + +## format\_schema\_path {#server_configuration_parameters-format_schema_path} + +Le chemin d'accès au répertoire avec des régimes pour l'entrée de données, tels que les schémas pour l' [CapnProto](../../interfaces/formats.md#capnproto) format. + +**Exemple** + +``` xml + + format_schemas/ +``` + +## graphite {#server_configuration_parameters-graphite} + +Envoi de données à [Graphite](https://github.com/graphite-project). + +Paramètre: + +- host – The Graphite server. +- port – The port on the Graphite server. +- interval – The interval for sending, in seconds. +- timeout – The timeout for sending data, in seconds. +- root\_path – Prefix for keys. +- metrics – Sending data from the [système.métrique](../../operations/system-tables.md#system_tables-metrics) table. +- events – Sending deltas data accumulated for the time period from the [système.événement](../../operations/system-tables.md#system_tables-events) table. +- events\_cumulative – Sending cumulative data from the [système.événement](../../operations/system-tables.md#system_tables-events) table. +- asynchronous\_metrics – Sending data from the [système.asynchronous\_metrics](../../operations/system-tables.md#system_tables-asynchronous_metrics) table. + +Vous pouvez configurer plusieurs `` clause. Par exemple, vous pouvez l'utiliser pour envoyer des données différentes à différents intervalles. + +**Exemple** + +``` xml + + localhost + 42000 + 0.1 + 60 + one_min + true + true + false + true + +``` + +## graphite\_rollup {#server_configuration_parameters-graphite-rollup} + +Paramètres pour l'amincissement des données pour le Graphite. + +Pour plus de détails, voir [GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md). + +**Exemple** + +``` xml + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +## http\_port/https\_port {#http-porthttps-port} + +Port de connexion au serveur via HTTP(S). + +Si `https_port` est spécifié, [openSSL](#server_configuration_parameters-openssl) doit être configuré. + +Si `http_port` est spécifié, la configuration OpenSSL est ignorée même si elle est définie. + +**Exemple** + +``` xml +9999 +``` + +## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} + +Page affichée par défaut lorsque vous accédez au serveur HTTP(S) ClickHouse. +La valeur par défaut est “Ok.” (avec un saut de ligne à la fin) + +**Exemple** + +Ouvrir `https://tabix.io/` lors de l'accès à `http://localhost: http_port`. + +``` xml + +
]]> +
+``` + +## include\_from {#server_configuration_parameters-include_from} + +Le chemin d'accès au fichier avec des substitutions. + +Pour plus d'informations, consultez la section “[Fichiers de Configuration](../configuration-files.md#configuration_files)”. + +**Exemple** + +``` xml +/etc/metrica.xml +``` + +## interserver\_http\_port {#interserver-http-port} + +Port pour l'échange de données entre les serveurs ClickHouse. + +**Exemple** + +``` xml +9009 +``` + +## interserver\_http\_host {#interserver-http-host} + +Le nom d'hôte qui peut être utilisé par d'autres serveurs pour accéder à ce serveur. + +Si elle est omise, elle est définie de la même manière que `hostname-f` commande. + +Utile pour rompre avec une interface réseau spécifique. + +**Exemple** + +``` xml +example.yandex.ru +``` + +## interserver\_http\_credentials {#server-settings-interserver-http-credentials} + +Le nom d'utilisateur et le mot de passe utilisés pour [réplication](../../engines/table-engines/mergetree-family/replication.md) avec les moteurs \* répliqués. Ces informations d'identification sont utilisées uniquement pour la communication entre les répliques et ne sont pas liées aux informations d'identification des clients ClickHouse. Le serveur vérifie ces informations d'identification pour la connexion de répliques et utilise les mêmes informations d'identification lors de la connexion à d'autres répliques. Donc, ces informations d'identification doivent être identiques pour tous les réplicas dans un cluster. +Par défaut, l'authentification n'est pas utilisé. + +Cette section contient les paramètres suivants: + +- `user` — username. +- `password` — password. + +**Exemple** + +``` xml + + admin + 222 + +``` + +## keep\_alive\_timeout {#keep-alive-timeout} + +Le nombre de secondes que ClickHouse attend pour les demandes entrantes avant de fermer la connexion. Par défaut est de 3 secondes. + +**Exemple** + +``` xml +3 +``` + +## listen\_host {#server_configuration_parameters-listen_host} + +Restriction sur les hôtes dont les demandes peuvent provenir. Si vous voulez que le serveur réponde à tous, spécifiez `::`. + +Exemple: + +``` xml +::1 +127.0.0.1 +``` + +## enregistreur {#server_configuration_parameters-logger} + +Paramètres de journalisation. + +Touches: + +- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. +- log – The log file. Contains all the entries according to `level`. +- errorlog – Error log file. +- size – Size of the file. Applies to `log`et`errorlog`. Une fois que le fichier atteint `size`, Archives ClickHouse et le renomme, et crée un nouveau fichier journal à sa place. +- count – The number of archived log files that ClickHouse stores. + +**Exemple** + +``` xml + + trace + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 10 + +``` + +L'écriture dans le syslog est également prise en charge. Exemple de Config: + +``` xml + + 1 + +
syslog.remote:10514
+ myhost.local + LOG_LOCAL6 + syslog +
+
+``` + +Touches: + +- use\_syslog — Required setting if you want to write to the syslog. +- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. +- hostname — Optional. The name of the host that logs are sent from. +- facility — [Le mot clé syslog facility](https://en.wikipedia.org/wiki/Syslog#Facility) en majuscules avec la “LOG\_” préfixe: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` et ainsi de suite). + Valeur par défaut: `LOG_USER` si `address` est spécifié, `LOG_DAEMON otherwise.` +- format – Message format. Possible values: `bsd` et `syslog.` + +## macro {#macros} + +Substitutions de paramètres pour les tables répliquées. + +Peut être omis si les tables répliquées ne sont pas utilisées. + +Pour plus d'informations, consultez la section “[Création de tables répliquées](../../engines/table-engines/mergetree-family/replication.md)”. + +**Exemple** + +``` xml + +``` + +## mark\_cache\_size {#server-mark-cache-size} + +Taille approximative (en octets) du cache des marques utilisées par les [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) famille. + +Le cache est partagé pour le serveur et la mémoire est allouée au besoin. La taille du cache doit être d'au moins 5368709120. + +**Exemple** + +``` xml +5368709120 +``` + +## max\_concurrent\_queries {#max-concurrent-queries} + +Nombre maximal de demandes traitées simultanément. + +**Exemple** + +``` xml +100 +``` + +## max\_connections {#max-connections} + +Le nombre maximal de connexions entrantes. + +**Exemple** + +``` xml +4096 +``` + +## max\_open\_files {#max-open-files} + +Le nombre maximal de fichiers ouverts. + +Par défaut: `maximum`. + +Nous vous recommandons d'utiliser cette option sous Mac OS X depuis le `getrlimit()` la fonction renvoie une valeur incorrecte. + +**Exemple** + +``` xml +262144 +``` + +## max\_table\_size\_to\_drop {#max-table-size-to-drop} + +Restriction sur la suppression de tables. + +Si la taille d'un [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) table dépasse `max_table_size_to_drop` (en octets), vous ne pouvez pas le supprimer à l'aide d'une requête DROP. + +Si vous devez toujours supprimer la table sans redémarrer le serveur ClickHouse, créez le `/flags/force_drop_table` fichier et exécutez la requête DROP. + +Valeur par défaut: 50 Go. + +La valeur 0 signifie que vous pouvez supprimer toutes les tables sans aucune restriction. + +**Exemple** + +``` xml +0 +``` + +## merge\_tree {#server_configuration_parameters-merge_tree} + +Réglage fin des tables dans le [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). + +Pour plus d'informations, consultez MergeTreeSettings.h fichier d'en-tête. + +**Exemple** + +``` xml + + 5 + +``` + +## openSSL {#server_configuration_parameters-openssl} + +Configuration client/serveur SSL. + +Le Support pour SSL est fourni par le `libpoco` bibliothèque. L'interface est décrite dans le fichier [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) + +Clés pour les paramètres Serveur/client: + +- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. +- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` contient le certificat. +- caConfig – The path to the file or directory that contains trusted root certificates. +- verificationMode – The method for checking the node's certificates. Details are in the description of the [Cadre](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) classe. Valeurs possibles: `none`, `relaxed`, `strict`, `once`. +- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. +- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| +- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. +- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Les valeurs acceptables: `true`, `false`. +- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. Ce paramètre est toujours recommandé car il permet d'éviter les problèmes à la fois si le serveur met en cache la session et si le client demande la mise en cache. Valeur par défaut: `${application.name}`. +- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. +- sessionTimeout – Time for caching the session on the server. +- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. +- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. +- fips – Activates OpenSSL FIPS mode. Supported if the library's OpenSSL version supports FIPS. +- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. +- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . +- disableProtocols – Protocols that are not allowed to use. +- preferServerCiphers – Preferred server ciphers on the client. + +**Exemple de paramètres:** + +``` xml + + + + /etc/clickhouse-server/server.crt + /etc/clickhouse-server/server.key + + /etc/clickhouse-server/dhparam.pem + none + true + true + sslv2,sslv3 + true + + + true + true + sslv2,sslv3 + true + + + + RejectCertificateHandler + + + +``` + +## part\_log {#server_configuration_parameters-part-log} + +Journalisation des événements associés à [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). Par exemple, ajouter ou fusionner des données. Vous pouvez utiliser le journal pour simuler des algorithmes de fusion et comparer leurs caractéristiques. Vous pouvez visualiser le processus de fusion. + +Les requêtes sont enregistrées dans le [système.part\_log](../../operations/system-tables.md#system_tables-part-log) table, pas dans un fichier séparé. Vous pouvez configurer le nom de cette table dans le `table` paramètre (voir ci-dessous). + +Utilisez les paramètres suivants pour configurer la journalisation: + +- `database` – Name of the database. +- `table` – Name of the system table. +- `partition_by` – Sets a [partitionnement personnalisé clé](../../engines/table-engines/mergetree-family/custom-partitioning-key.md). +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +**Exemple** + +``` xml + + system + part_log
+ toMonday(event_date) + 7500 +
+``` + +## chemin {#server_configuration_parameters-path} + +Chemin d'accès au répertoire contenant des données. + +!!! note "Note" + La barre oblique de fin est obligatoire. + +**Exemple** + +``` xml +/var/lib/clickhouse/ +``` + +## prometheus {#server_configuration_parameters-prometheus} + +Exposer les données de métriques pour le raclage à partir [Prometheus](https://prometheus.io). + +Paramètre: + +- `endpoint` – HTTP endpoint for scraping metrics by prometheus server. Start from ‘/’. +- `port` – Port for `endpoint`. +- `metrics` – Flag that sets to expose metrics from the [système.métrique](../system-tables.md#system_tables-metrics) table. +- `events` – Flag that sets to expose metrics from the [système.événement](../system-tables.md#system_tables-events) table. +- `asynchronous_metrics` – Flag that sets to expose current metrics values from the [système.asynchronous\_metrics](../system-tables.md#system_tables-asynchronous_metrics) table. + +**Exemple** + +``` xml + + /metrics + 8001 + true + true + true + +``` + +## query\_log {#server_configuration_parameters-query-log} + +Réglage de la journalisation des requêtes reçues avec [log\_queries=1](../settings/settings.md) paramètre. + +Les requêtes sont enregistrées dans le [système.query\_log](../../operations/system-tables.md#system_tables-query_log) table, pas dans un fichier séparé. Vous pouvez modifier le nom de la table dans le `table` paramètre (voir ci-dessous). + +Utilisez les paramètres suivants pour configurer la journalisation: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [partitionnement personnalisé clé](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) pour une table. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +Si la table n'existe pas, ClickHouse la créera. Si la structure du journal des requêtes a été modifiée lors de la mise à jour du serveur ClickHouse, la table avec l'ancienne structure est renommée et une nouvelle table est créée automatiquement. + +**Exemple** + +``` xml + + system + query_log
+ toMonday(event_date) + 7500 +
+``` + +## query\_thread\_log {#server_configuration_parameters-query-thread-log} + +Réglage de la journalisation des threads de requêtes reçues avec [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads) paramètre. + +Les requêtes sont enregistrées dans le [système.query\_thread\_log](../../operations/system-tables.md#system_tables-query-thread-log) table, pas dans un fichier séparé. Vous pouvez modifier le nom de la table dans le `table` paramètre (voir ci-dessous). + +Utilisez les paramètres suivants pour configurer la journalisation: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [partitionnement personnalisé clé](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) pour un système de tableau. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +Si la table n'existe pas, ClickHouse la créera. Si la structure du journal des threads de requête a été modifiée lors de la mise à jour du serveur ClickHouse, la table avec l'ancienne structure est renommée et une nouvelle table est créée automatiquement. + +**Exemple** + +``` xml + + system + query_thread_log
+ toMonday(event_date) + 7500 +
+``` + +## trace\_log {#server_configuration_parameters-trace_log} + +Paramètres pour le [trace\_log](../../operations/system-tables.md#system_tables-trace_log) opération de table de système. + +Paramètre: + +- `database` — Database for storing a table. +- `table` — Table name. +- `partition_by` — [Partitionnement personnalisé clé](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) pour un système de tableau. +- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. + +Le fichier de configuration du serveur par défaut `config.xml` contient la section Paramètres suivante: + +``` xml + + system + trace_log
+ toYYYYMM(event_date) + 7500 +
+``` + +## query\_masking\_rules {#query-masking-rules} + +Règles basées sur Regexp, qui seront appliquées aux requêtes ainsi qu'à tous les messages de journal avant de les stocker dans les journaux du serveur, +`system.query_log`, `system.text_log`, `system.processes` table, et dans les journaux envoyés au client. Qui permet à la prévention de +fuite de données sensibles à partir de requêtes SQL (comme les noms, e-mails, +identificateurs ou numéros de carte de crédit) aux journaux. + +**Exemple** + +``` xml + + + hide SSN + (^|\D)\d{3}-\d{2}-\d{4}($|\D) + 000-00-0000 + + +``` + +Config champs: +- `name` - nom de la règle (facultatif) +- `regexp` - Expression régulière compatible RE2 (obligatoire) +- `replace` - chaîne de substitution pour les données sensibles (facultatif, par défaut - six astérisques) + +Les règles de masquage sont appliquées à l'ensemble de la requête (pour éviter les fuites de données sensibles provenant de requêtes malformées / Non analysables). + +`system.events` table ont compteur `QueryMaskingRulesMatch` qui ont un nombre global de requête de masquage des règles de correspondances. + +Pour les requêtes distribuées chaque serveur doivent être configurés séparément, sinon, les sous-requêtes transmises à d'autres +les nœuds seront stockés sans masquage. + +## remote\_servers {#server-settings-remote-servers} + +Configuration des clusters utilisés par le [Distribué](../../engines/table-engines/special/distributed.md) moteur de table et par le `cluster` table de fonction. + +**Exemple** + +``` xml + +``` + +Pour la valeur de l' `incl` attribut, voir la section “[Fichiers de Configuration](../configuration-files.md#configuration_files)”. + +**Voir Aussi** + +- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) + +## fuseau {#server_configuration_parameters-timezone} + +Le fuseau horaire du serveur. + +Spécifié comme identifiant IANA pour le fuseau horaire UTC ou l'emplacement géographique (par exemple, Afrique / Abidjan). + +Le fuseau horaire est nécessaire pour les conversions entre les formats String et DateTime lorsque les champs DateTime sont sortis au format texte (imprimés à l'écran ou dans un fichier) et lors de L'obtention de DateTime à partir d'une chaîne. En outre, le fuseau horaire est utilisé dans les fonctions qui fonctionnent avec l'heure et la date si elles ne reçoivent pas le fuseau horaire dans les paramètres d'entrée. + +**Exemple** + +``` xml +Europe/Moscow +``` + +## tcp\_port {#server_configuration_parameters-tcp_port} + +Port pour communiquer avec les clients via le protocole TCP. + +**Exemple** + +``` xml +9000 +``` + +## tcp\_port\_secure {#server_configuration_parameters-tcp_port_secure} + +Port TCP pour une communication sécurisée avec les clients. Utilisez le avec [OpenSSL](#server_configuration_parameters-openssl) paramètre. + +**Valeurs possibles** + +Entier positif. + +**Valeur par défaut** + +``` xml +9440 +``` + +## mysql\_port {#server_configuration_parameters-mysql_port} + +Port pour communiquer avec les clients via le protocole MySQL. + +**Valeurs possibles** + +Entier positif. + +Exemple + +``` xml +9004 +``` + +## tmp\_path {#server-settings-tmp_path} + +Chemin d'accès aux données temporaires pour le traitement des requêtes volumineuses. + +!!! note "Note" + La barre oblique de fin est obligatoire. + +**Exemple** + +``` xml +/var/lib/clickhouse/tmp/ +``` + +## tmp\_policy {#server-settings-tmp-policy} + +La politique de [`storage_configuration`](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) pour stocker des fichiers temporaires. +Si cela n'est pas [`tmp_path`](#server-settings-tmp_path) est utilisé, sinon elle est ignorée. + +!!! note "Note" + - `move_factor` est ignoré +- `keep_free_space_bytes` est ignoré +- `max_data_part_size_bytes` est ignoré +- vous devez avoir exactement un volume dans cette politique + +## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} + +Taille du Cache (en octets) pour les données non compressées utilisées par les [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). + +Il y a un cache partagé pour le serveur. La mémoire est allouée à la demande. Le cache est utilisé si l'option [use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) est activé. + +Le cache non compressé est avantageux pour les requêtes très courtes dans des cas individuels. + +**Exemple** + +``` xml +8589934592 +``` + +## user\_files\_path {#server_configuration_parameters-user_files_path} + +Le répertoire avec les fichiers utilisateur. Utilisé dans la fonction de table [fichier()](../../sql-reference/table-functions/file.md). + +**Exemple** + +``` xml +/var/lib/clickhouse/user_files/ +``` + +## users\_config {#users-config} + +Chemin d'accès au fichier qui contient: + +- Les configurations de l'utilisateur. +- Les droits d'accès. +- Les paramètres des profils. +- Les paramètres de Quota. + +**Exemple** + +``` xml +users.xml +``` + +## zookeeper {#server-settings_zookeeper} + +Contient des paramètres qui permettent à ClickHouse d'interagir avec [ZooKeeper](http://zookeeper.apache.org/) cluster. + +ClickHouse utilise ZooKeeper pour stocker les métadonnées des répliques lors de l'utilisation de tables répliquées. Si les tables répliquées ne sont pas utilisées, cette section de paramètres peut être omise. + +Cette section contient les paramètres suivants: + +- `node` — ZooKeeper endpoint. You can set multiple endpoints. + + Exemple: + + + +``` xml + + example_host + 2181 + +``` + + The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. + +- `session_timeout` — Maximum timeout for the client session in milliseconds. +- `root` — The [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) qui est utilisé comme racine pour les znodes utilisés par le serveur ClickHouse. Facultatif. +- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. + +**Exemple de configuration** + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + 30000 + 10000 + + /path/to/zookeeper/node + + user:password + +``` + +**Voir Aussi** + +- [Réplication](../../engines/table-engines/mergetree-family/replication.md) +- [Guide du programmeur ZooKeeper](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) + +## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} + +Méthode de stockage pour les en-têtes de partie de données dans ZooKeeper. + +Ce paramètre s'applique uniquement à l' `MergeTree` famille. Il peut être spécifié: + +- À l'échelle mondiale dans le [merge\_tree](#server_configuration_parameters-merge_tree) la section de la `config.xml` fichier. + + ClickHouse utilise le paramètre pour toutes les tables du serveur. Vous pouvez modifier le réglage à tout moment. Les tables existantes changent de comportement lorsque le paramètre change. + +- Pour chaque table. + + Lors de la création d'un tableau, indiquer la [moteur de réglage](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). Le comportement d'une table existante avec ce paramètre ne change pas, même si le paramètre global des changements. + +**Valeurs possibles** + +- 0 — Functionality is turned off. +- 1 — Functionality is turned on. + +Si `use_minimalistic_part_header_in_zookeeper = 1`, puis [répliqué](../../engines/table-engines/mergetree-family/replication.md) les tables stockent les en-têtes des parties de données de manière compacte à l'aide `znode`. Si la table contient plusieurs colonnes, cette méthode de stockage réduit considérablement le volume des données stockées dans Zookeeper. + +!!! attention "Attention" + Après l'application de `use_minimalistic_part_header_in_zookeeper = 1`, vous ne pouvez pas rétrograder le serveur ClickHouse vers une version qui ne prend pas en charge ce paramètre. Soyez prudent lors de la mise à niveau de ClickHouse sur les serveurs d'un cluster. Ne mettez pas à niveau tous les serveurs à la fois. Il est plus sûr de tester de nouvelles versions de ClickHouse dans un environnement de test, ou sur quelques serveurs d'un cluster. + + Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. + +**Valeur par défaut:** 0. + +## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} + +Désactive le cache DNS interne. Recommandé pour l'utilisation de ClickHouse dans les systèmes +avec des infrastructures en constante évolution telles que Kubernetes. + +**Valeur par défaut:** 0. + +## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} + +La période de mise à jour des adresses IP stockées dans le cache DNS interne de ClickHouse (en secondes). +La mise à jour est effectuée de manière asynchrone, dans un thread système séparé. + +**Valeur par défaut**: 15. + +## access\_control\_path {#access_control_path} + +Chemin d'accès à un dossier dans lequel un serveur clickhouse stocke les configurations utilisateur et rôle créées par les commandes SQL. + +Valeur par défaut: `/var/lib/clickhouse/access/`. + +**Voir aussi** + +- [Le Contrôle d'accès et de Gestion de Compte](../access-rights.md#access-control) + +[Article Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/fr/operations/server_configuration_parameters/index.md b/docs/fr/operations/server_configuration_parameters/index.md deleted file mode 100644 index 04581bc4f17..00000000000 --- a/docs/fr/operations/server_configuration_parameters/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Server Configuration Parameters -toc_priority: 54 -toc_title: Introduction ---- - -# Paramètres de configuration du serveur {#server-settings} - -Cette section contient des descriptions des paramètres du serveur qui ne peuvent pas être modifiés au niveau de la session ou de la requête. - -Ces paramètres sont stockés dans la `config.xml` fichier sur le serveur ClickHouse. - -D'autres paramètres sont décrits dans le “[Paramètre](../settings/index.md#settings)” section. - -Avant d'étudier les paramètres, lire la [Fichiers de Configuration](../configuration_files.md#configuration_files) section et notez l'utilisation de substitutions (le `incl` et `optional` attribut). - -[Article Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/fr/operations/server_configuration_parameters/settings.md b/docs/fr/operations/server_configuration_parameters/settings.md deleted file mode 100644 index eda744c384b..00000000000 --- a/docs/fr/operations/server_configuration_parameters/settings.md +++ /dev/null @@ -1,872 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 57 -toc_title: "Les Param\xE8tres Du Serveur" ---- - -# Les Paramètres Du Serveur {#server-settings} - -## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} - -L'intervalle en secondes avant de recharger les dictionnaires intégrés. - -Clickhouse recharge les dictionnaires intégrés toutes les X secondes. Cela permet d'éditer des dictionnaires “on the fly” sans redémarrer le serveur. - -Valeur par défaut: 3600. - -**Exemple** - -``` xml -3600 -``` - -## compression {#server-settings-compression} - -Paramètres de compression de données pour [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)-tables de moteur. - -!!! warning "Avertissement" - Ne l'utilisez pas si vous venez de commencer à utiliser ClickHouse. - -Modèle de Configuration: - -``` xml - - - ... - ... - ... - - ... - -``` - -`` Fields: - -- `min_part_size` – The minimum size of a data part. -- `min_part_size_ratio` – The ratio of the data part size to the table size. -- `method` – Compression method. Acceptable values: `lz4` ou `zstd`. - -Vous pouvez configurer plusieurs `` section. - -Actions lorsque les conditions sont remplies: - -- Si une partie de données correspond à un ensemble de conditions, ClickHouse utilise la méthode de compression spécifiée. -- Si une partie de données correspond à plusieurs ensembles de conditions, ClickHouse utilise le premier ensemble de conditions correspondant. - -Si aucune condition n'est remplie pour une partie de données, ClickHouse utilise `lz4` compression. - -**Exemple** - -``` xml - - - 10000000000 - 0.01 - zstd - - -``` - -## default\_database {#default-database} - -La base de données par défaut. - -Pour obtenir une liste de bases de données, utilisez la [SHOW DATABASES](../../sql_reference/statements/show.md#show-databases) requête. - -**Exemple** - -``` xml -default -``` - -## default\_profile {#default-profile} - -Profil des paramètres par défaut. - -Les paramètres des profils sont situés dans le fichier spécifié dans le paramètre `user_config`. - -**Exemple** - -``` xml -default -``` - -## dictionaries\_config {#server_configuration_parameters-dictionaries_config} - -Chemin d'accès au fichier de configuration des dictionnaires externes. - -Chemin: - -- Spécifiez le chemin absolu ou le chemin relatif au fichier de configuration du serveur. -- Le chemin peut contenir des caractères génériques \* et ?. - -Voir aussi “[Dictionnaires externes](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md)”. - -**Exemple** - -``` xml -*_dictionary.xml -``` - -## dictionaries\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} - -Chargement paresseux des dictionnaires. - -Si `true` chaque dictionnaire est créé lors de la première utilisation. Si la création du dictionnaire a échoué, la fonction qui utilisait le dictionnaire lève une exception. - -Si `false`, tous les dictionnaires sont créés lorsque le serveur démarre, et si il y a une erreur, le serveur s'arrête. - -La valeur par défaut est `true`. - -**Exemple** - -``` xml -true -``` - -## format\_schema\_path {#server_configuration_parameters-format_schema_path} - -Le chemin d'accès au répertoire avec des régimes pour l'entrée de données, tels que les schémas pour l' [CapnProto](../../interfaces/formats.md#capnproto) format. - -**Exemple** - -``` xml - - format_schemas/ -``` - -## graphite {#server_configuration_parameters-graphite} - -Envoi de données à [Graphite](https://github.com/graphite-project). - -Paramètre: - -- host – The Graphite server. -- port – The port on the Graphite server. -- interval – The interval for sending, in seconds. -- timeout – The timeout for sending data, in seconds. -- root\_path – Prefix for keys. -- metrics – Sending data from the [système.métrique](../../operations/system_tables.md#system_tables-metrics) table. -- events – Sending deltas data accumulated for the time period from the [système.événement](../../operations/system_tables.md#system_tables-events) table. -- events\_cumulative – Sending cumulative data from the [système.événement](../../operations/system_tables.md#system_tables-events) table. -- asynchronous\_metrics – Sending data from the [système.asynchronous\_metrics](../../operations/system_tables.md#system_tables-asynchronous_metrics) table. - -Vous pouvez configurer plusieurs `` clause. Par exemple, vous pouvez l'utiliser pour envoyer des données différentes à différents intervalles. - -**Exemple** - -``` xml - - localhost - 42000 - 0.1 - 60 - one_min - true - true - false - true - -``` - -## graphite\_rollup {#server_configuration_parameters-graphite-rollup} - -Paramètres pour l'amincissement des données pour le Graphite. - -Pour plus de détails, voir [GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md). - -**Exemple** - -``` xml - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -## http\_port/https\_port {#http-porthttps-port} - -Port de connexion au serveur via HTTP(S). - -Si `https_port` est spécifié, [openSSL](#server_configuration_parameters-openssl) doit être configuré. - -Si `http_port` est spécifié, la configuration OpenSSL est ignorée même si elle est définie. - -**Exemple** - -``` xml -0000 -``` - -## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} - -Page affichée par défaut lorsque vous accédez au serveur HTTP(S) ClickHouse. -La valeur par défaut est “Ok.” (avec un saut de ligne à la fin) - -**Exemple** - -Ouvrir `https://tabix.io/` lors de l'accès à `http://localhost: http_port`. - -``` xml - -
]]> -
-``` - -## include\_from {#server_configuration_parameters-include_from} - -Le chemin d'accès au fichier avec des substitutions. - -Pour plus d'informations, consultez la section “[Fichiers de Configuration](../configuration_files.md#configuration_files)”. - -**Exemple** - -``` xml -/etc/metrica.xml -``` - -## interserver\_http\_port {#interserver-http-port} - -Port pour l'échange de données entre les serveurs ClickHouse. - -**Exemple** - -``` xml -9009 -``` - -## interserver\_http\_host {#interserver-http-host} - -Le nom d'hôte qui peut être utilisé par d'autres serveurs pour accéder à ce serveur. - -Si elle est omise, elle est définie de la même manière que `hostname-f` commande. - -Utile pour rompre avec une interface réseau spécifique. - -**Exemple** - -``` xml -example.yandex.ru -``` - -## interserver\_http\_credentials {#server-settings-interserver-http-credentials} - -Le nom d'utilisateur et le mot de passe utilisés pour [réplication](../../engines/table_engines/mergetree_family/replication.md) avec les moteurs \* répliqués. Ces informations d'identification sont utilisées uniquement pour la communication entre les répliques et ne sont pas liées aux informations d'identification des clients ClickHouse. Le serveur vérifie ces informations d'identification pour la connexion de répliques et utilise les mêmes informations d'identification lors de la connexion à d'autres répliques. Donc, ces informations d'identification doivent être identiques pour tous les réplicas dans un cluster. -Par défaut, l'authentification n'est pas utilisé. - -Cette section contient les paramètres suivants: - -- `user` — username. -- `password` — password. - -**Exemple** - -``` xml - - admin - 222 - -``` - -## keep\_alive\_timeout {#keep-alive-timeout} - -Le nombre de secondes que ClickHouse attend pour les demandes entrantes avant de fermer la connexion. Par défaut est de 3 secondes. - -**Exemple** - -``` xml -3 -``` - -## listen\_host {#server_configuration_parameters-listen_host} - -Restriction sur les hôtes dont les demandes peuvent provenir. Si vous voulez que le serveur réponde à tous, spécifiez `::`. - -Exemple: - -``` xml -::1 -127.0.0.1 -``` - -## enregistreur {#server_configuration_parameters-logger} - -Paramètres de journalisation. - -Touches: - -- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. -- log – The log file. Contains all the entries according to `level`. -- errorlog – Error log file. -- size – Size of the file. Applies to `log`et`errorlog`. Une fois que le fichier atteint `size`, Archives ClickHouse et le renomme, et crée un nouveau fichier journal à sa place. -- count – The number of archived log files that ClickHouse stores. - -**Exemple** - -``` xml - - trace - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 10 - -``` - -L'écriture dans le syslog est également prise en charge. Exemple de Config: - -``` xml - - 1 - -
syslog.remote:10514
- myhost.local - LOG_LOCAL6 - syslog -
-
-``` - -Touches: - -- use\_syslog — Required setting if you want to write to the syslog. -- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. -- hostname — Optional. The name of the host that logs are sent from. -- facility — [Le mot clé syslog facility](https://en.wikipedia.org/wiki/Syslog#Facility) en majuscules avec la “LOG\_” préfixe: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` et ainsi de suite). - Valeur par défaut: `LOG_USER` si `address` est spécifié, `LOG_DAEMON otherwise.` -- format – Message format. Possible values: `bsd` et `syslog.` - -## macro {#macros} - -Substitutions de paramètres pour les tables répliquées. - -Peut être omis si les tables répliquées ne sont pas utilisées. - -Pour plus d'informations, consultez la section “[Création de tables répliquées](../../engines/table_engines/mergetree_family/replication.md)”. - -**Exemple** - -``` xml - -``` - -## mark\_cache\_size {#server-mark-cache-size} - -Taille approximative (en octets) du cache des marques utilisées par les [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) famille. - -Le cache est partagé pour le serveur et la mémoire est allouée au besoin. La taille du cache doit être d'au moins 5368709120. - -**Exemple** - -``` xml -5368709120 -``` - -## max\_concurrent\_queries {#max-concurrent-queries} - -Nombre maximal de demandes traitées simultanément. - -**Exemple** - -``` xml -100 -``` - -## max\_connections {#max-connections} - -Le nombre maximal de connexions entrantes. - -**Exemple** - -``` xml -4096 -``` - -## max\_open\_files {#max-open-files} - -Le nombre maximal de fichiers ouverts. - -Par défaut: `maximum`. - -Nous vous recommandons d'utiliser cette option sous Mac OS X depuis le `getrlimit()` la fonction renvoie une valeur incorrecte. - -**Exemple** - -``` xml -262144 -``` - -## max\_table\_size\_to\_drop {#max-table-size-to-drop} - -Restriction sur la suppression de tables. - -Si la taille d'un [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) table dépasse `max_table_size_to_drop` (en octets), vous ne pouvez pas le supprimer à l'aide d'une requête DROP. - -Si vous devez toujours supprimer la table sans redémarrer le serveur ClickHouse, créez le `/flags/force_drop_table` fichier et exécutez la requête DROP. - -Valeur par défaut: 50 Go. - -La valeur 0 signifie que vous pouvez supprimer toutes les tables sans aucune restriction. - -**Exemple** - -``` xml -0 -``` - -## merge\_tree {#server_configuration_parameters-merge_tree} - -Réglage fin des tables dans le [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). - -Pour plus d'informations, consultez MergeTreeSettings.h fichier d'en-tête. - -**Exemple** - -``` xml - - 5 - -``` - -## openSSL {#server_configuration_parameters-openssl} - -Configuration client/serveur SSL. - -Le Support pour SSL est fourni par le `libpoco` bibliothèque. L'interface est décrite dans le fichier [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) - -Clés pour les paramètres Serveur/client: - -- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. -- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` contient le certificat. -- caConfig – The path to the file or directory that contains trusted root certificates. -- verificationMode – The method for checking the node's certificates. Details are in the description of the [Cadre](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) classe. Valeurs possibles: `none`, `relaxed`, `strict`, `once`. -- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. -- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| -- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. -- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Les valeurs acceptables: `true`, `false`. -- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. Ce paramètre est toujours recommandé car il permet d'éviter les problèmes à la fois si le serveur met en cache la session et si le client demande la mise en cache. Valeur par défaut: `${application.name}`. -- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. -- sessionTimeout – Time for caching the session on the server. -- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. -- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. -- fips – Activates OpenSSL FIPS mode. Supported if the library's OpenSSL version supports FIPS. -- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. -- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . -- disableProtocols – Protocols that are not allowed to use. -- preferServerCiphers – Preferred server ciphers on the client. - -**Exemple de paramètres:** - -``` xml - - - - /etc/clickhouse-server/server.crt - /etc/clickhouse-server/server.key - - /etc/clickhouse-server/dhparam.pem - none - true - true - sslv2,sslv3 - true - - - true - true - sslv2,sslv3 - true - - - - RejectCertificateHandler - - - -``` - -## part\_log {#server_configuration_parameters-part-log} - -Journalisation des événements associés à [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). Par exemple, ajouter ou fusionner des données. Vous pouvez utiliser le journal pour simuler des algorithmes de fusion et comparer leurs caractéristiques. Vous pouvez visualiser le processus de fusion. - -Les requêtes sont enregistrées dans le [système.part\_log](../../operations/system_tables.md#system_tables-part-log) table, pas dans un fichier séparé. Vous pouvez configurer le nom de cette table dans le `table` paramètre (voir ci-dessous). - -Utilisez les paramètres suivants pour configurer la journalisation: - -- `database` – Name of the database. -- `table` – Name of the system table. -- `partition_by` – Sets a [partitionnement personnalisé clé](../../engines/table_engines/mergetree_family/custom_partitioning_key.md). -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -**Exemple** - -``` xml - - system - part_log
- toMonday(event_date) - 7500 -
-``` - -## chemin {#server_configuration_parameters-path} - -Chemin d'accès au répertoire contenant des données. - -!!! note "Note" - La barre oblique de fin est obligatoire. - -**Exemple** - -``` xml -/var/lib/clickhouse/ -``` - -## query\_log {#server_configuration_parameters-query-log} - -Réglage de la journalisation des requêtes reçues avec [log\_queries=1](../settings/settings.md) paramètre. - -Les requêtes sont enregistrées dans le [système.query\_log](../../operations/system_tables.md#system_tables-query_log) table, pas dans un fichier séparé. Vous pouvez modifier le nom de la table dans le `table` paramètre (voir ci-dessous). - -Utilisez les paramètres suivants pour configurer la journalisation: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [partitionnement personnalisé clé](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) pour une table. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -Si la table n'existe pas, ClickHouse la créera. Si la structure du journal des requêtes a été modifiée lors de la mise à jour du serveur ClickHouse, la table avec l'ancienne structure est renommée et une nouvelle table est créée automatiquement. - -**Exemple** - -``` xml - - system - query_log
- toMonday(event_date) - 7500 -
-``` - -## query\_thread\_log {#server_configuration_parameters-query-thread-log} - -Réglage de la journalisation des threads de requêtes reçues avec [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads) paramètre. - -Les requêtes sont enregistrées dans le [système.query\_thread\_log](../../operations/system_tables.md#system_tables-query-thread-log) table, pas dans un fichier séparé. Vous pouvez modifier le nom de la table dans le `table` paramètre (voir ci-dessous). - -Utilisez les paramètres suivants pour configurer la journalisation: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [partitionnement personnalisé clé](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) pour un système de tableau. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -Si la table n'existe pas, ClickHouse la créera. Si la structure du journal des threads de requête a été modifiée lors de la mise à jour du serveur ClickHouse, la table avec l'ancienne structure est renommée et une nouvelle table est créée automatiquement. - -**Exemple** - -``` xml - - system - query_thread_log
- toMonday(event_date) - 7500 -
-``` - -## trace\_log {#server_configuration_parameters-trace_log} - -Paramètres pour le [trace\_log](../../operations/system_tables.md#system_tables-trace_log) opération de table de système. - -Paramètre: - -- `database` — Database for storing a table. -- `table` — Table name. -- `partition_by` — [Partitionnement personnalisé clé](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) pour un système de tableau. -- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. - -Le fichier de configuration du serveur par défaut `config.xml` contient la section Paramètres suivante: - -``` xml - - system - trace_log
- toYYYYMM(event_date) - 7500 -
-``` - -## query\_masking\_rules {#query-masking-rules} - -Règles basées sur Regexp, qui seront appliquées aux requêtes ainsi qu'à tous les messages de journal avant de les stocker dans les journaux du serveur, -`system.query_log`, `system.text_log`, `system.processes` table, et dans les journaux envoyés au client. Qui permet à la prévention de -fuite de données sensibles à partir de requêtes SQL (comme les noms, e-mails, -identificateurs ou numéros de carte de crédit) aux journaux. - -**Exemple** - -``` xml - - - hide SSN - (^|\D)\d{3}-\d{2}-\d{4}($|\D) - 000-00-0000 - - -``` - -Config champs: -- `name` - nom de la règle (facultatif) -- `regexp` - Expression régulière compatible RE2 (obligatoire) -- `replace` - chaîne de substitution pour les données sensibles (facultatif, par défaut - six astérisques) - -Les règles de masquage sont appliquées à l'ensemble de la requête (pour éviter les fuites de données sensibles provenant de requêtes malformées / Non analysables). - -`system.events` table ont compteur `QueryMaskingRulesMatch` qui ont un nombre global de requête de masquage des règles de correspondances. - -Pour les requêtes distribuées chaque serveur doivent être configurés séparément, sinon, les sous-requêtes transmises à d'autres -les nœuds seront stockés sans masquage. - -## remote\_servers {#server-settings-remote-servers} - -Configuration des clusters utilisés par le [Distribué](../../engines/table_engines/special/distributed.md) moteur de table et par le `cluster` table de fonction. - -**Exemple** - -``` xml - -``` - -Pour la valeur de l' `incl` attribut, voir la section “[Fichiers de Configuration](../configuration_files.md#configuration_files)”. - -**Voir Aussi** - -- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) - -## fuseau {#server_configuration_parameters-timezone} - -Le fuseau horaire du serveur. - -Spécifié comme identifiant IANA pour le fuseau horaire UTC ou l'emplacement géographique (par exemple, Afrique / Abidjan). - -Le fuseau horaire est nécessaire pour les conversions entre les formats String et DateTime lorsque les champs DateTime sont sortis au format texte (imprimés à l'écran ou dans un fichier) et lors de L'obtention de DateTime à partir d'une chaîne. En outre, le fuseau horaire est utilisé dans les fonctions qui fonctionnent avec l'heure et la date si elles ne reçoivent pas le fuseau horaire dans les paramètres d'entrée. - -**Exemple** - -``` xml -Europe/Moscow -``` - -## tcp\_port {#server_configuration_parameters-tcp_port} - -Port pour communiquer avec les clients via le protocole TCP. - -**Exemple** - -``` xml -9000 -``` - -## tcp\_port\_secure {#server_configuration_parameters-tcp_port-secure} - -Port TCP pour une communication sécurisée avec les clients. Utilisez le avec [OpenSSL](#server_configuration_parameters-openssl) paramètre. - -**Valeurs possibles** - -Entier positif. - -**Valeur par défaut** - -``` xml -9440 -``` - -## mysql\_port {#server_configuration_parameters-mysql_port} - -Port pour communiquer avec les clients via le protocole MySQL. - -**Valeurs possibles** - -Entier positif. - -Exemple - -``` xml -9004 -``` - -## tmp\_path {#server-settings-tmp_path} - -Chemin d'accès aux données temporaires pour le traitement des requêtes volumineuses. - -!!! note "Note" - La barre oblique de fin est obligatoire. - -**Exemple** - -``` xml -/var/lib/clickhouse/tmp/ -``` - -## tmp\_policy {#server-settings-tmp-policy} - -La politique de [`storage_configuration`](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) pour stocker des fichiers temporaires. -Si cela n'est pas [`tmp_path`](#server-settings-tmp_path) est utilisé, sinon elle est ignorée. - -!!! note "Note" - - `move_factor` est ignoré -- `keep_free_space_bytes` est ignoré -- `max_data_part_size_bytes` est ignoré -- vous devez avoir exactement un volume dans cette politique - -## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} - -Taille du Cache (en octets) pour les données non compressées utilisées par les [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). - -Il y a un cache partagé pour le serveur. La mémoire est allouée à la demande. Le cache est utilisé si l'option [use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) est activé. - -Le cache non compressé est avantageux pour les requêtes très courtes dans des cas individuels. - -**Exemple** - -``` xml -8589934592 -``` - -## user\_files\_path {#server_configuration_parameters-user_files_path} - -Le répertoire avec les fichiers utilisateur. Utilisé dans la fonction de table [fichier()](../../sql_reference/table_functions/file.md). - -**Exemple** - -``` xml -/var/lib/clickhouse/user_files/ -``` - -## users\_config {#users-config} - -Chemin d'accès au fichier qui contient: - -- Les configurations de l'utilisateur. -- Les droits d'accès. -- Les paramètres des profils. -- Les paramètres de Quota. - -**Exemple** - -``` xml -users.xml -``` - -## zookeeper {#server-settings_zookeeper} - -Contient des paramètres qui permettent à ClickHouse d'interagir avec [ZooKeeper](http://zookeeper.apache.org/) cluster. - -ClickHouse utilise ZooKeeper pour stocker les métadonnées des répliques lors de l'utilisation de tables répliquées. Si les tables répliquées ne sont pas utilisées, cette section de paramètres peut être omise. - -Cette section contient les paramètres suivants: - -- `node` — ZooKeeper endpoint. You can set multiple endpoints. - - Exemple: - - - -``` xml - - example_host - 2181 - -``` - - The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. - -- `session_timeout` — Maximum timeout for the client session in milliseconds. -- `root` — The [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) qui est utilisé comme racine pour les znodes utilisés par le serveur ClickHouse. Facultatif. -- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. - -**Exemple de configuration** - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - 30000 - 10000 - - /path/to/zookeeper/node - - user:password - -``` - -**Voir Aussi** - -- [Réplication](../../engines/table_engines/mergetree_family/replication.md) -- [Guide du programmeur ZooKeeper](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) - -## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} - -Méthode de stockage pour les en-têtes de partie de données dans ZooKeeper. - -Ce paramètre s'applique uniquement à l' `MergeTree` famille. Il peut être spécifié: - -- À l'échelle mondiale dans le [merge\_tree](#server_configuration_parameters-merge_tree) la section de la `config.xml` fichier. - - ClickHouse utilise le paramètre pour toutes les tables du serveur. Vous pouvez modifier le réglage à tout moment. Les tables existantes changent de comportement lorsque le paramètre change. - -- Pour chaque table. - - Lors de la création d'un tableau, indiquer la [moteur de réglage](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). Le comportement d'une table existante avec ce paramètre ne change pas, même si le paramètre global des changements. - -**Valeurs possibles** - -- 0 — Functionality is turned off. -- 1 — Functionality is turned on. - -Si `use_minimalistic_part_header_in_zookeeper = 1`, puis [répliqué](../../engines/table_engines/mergetree_family/replication.md) les tables stockent les en-têtes des parties de données de manière compacte à l'aide `znode`. Si la table contient plusieurs colonnes, cette méthode de stockage réduit considérablement le volume des données stockées dans Zookeeper. - -!!! attention "Attention" - Après l'application de `use_minimalistic_part_header_in_zookeeper = 1`, vous ne pouvez pas rétrograder le serveur ClickHouse vers une version qui ne prend pas en charge ce paramètre. Soyez prudent lors de la mise à niveau de ClickHouse sur les serveurs d'un cluster. Ne mettez pas à niveau tous les serveurs à la fois. Il est plus sûr de tester de nouvelles versions de ClickHouse dans un environnement de test, ou sur quelques serveurs d'un cluster. - - Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. - -**Valeur par défaut:** 0. - -## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} - -Désactive le cache DNS interne. Recommandé pour l'utilisation de ClickHouse dans les systèmes -avec des infrastructures en constante évolution telles que Kubernetes. - -**Valeur par défaut:** 0. - -## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} - -La période de mise à jour des adresses IP stockées dans le cache DNS interne de ClickHouse (en secondes). -La mise à jour est effectuée de manière asynchrone, dans un thread système séparé. - -**Valeur par défaut**: 15. - -[Article Original](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/fr/operations/settings/constraints-on-settings.md b/docs/fr/operations/settings/constraints-on-settings.md new file mode 100644 index 00000000000..b9c34841da1 --- /dev/null +++ b/docs/fr/operations/settings/constraints-on-settings.md @@ -0,0 +1,75 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 62 +toc_title: "Contraintes sur les param\xE8tres" +--- + +# Contraintes sur les paramètres {#constraints-on-settings} + +Les contraintes sur les paramètres peuvent être définis dans le `profiles` la section de la `user.xml` fichier de configuration et interdire aux utilisateurs de modifier certains `SET` requête. +Les contraintes sont définies comme suit: + +``` xml + + + + + lower_boundary + + + upper_boundary + + + lower_boundary + upper_boundary + + + + + + + +``` + +Si l'utilisateur tente de violer les contraintes une exception est levée et le réglage n'est pas modifié. +Trois types de contraintes sont pris en charge: `min`, `max`, `readonly`. Le `min` et `max` les contraintes spécifient les limites supérieure et inférieure pour un paramètre numérique et peuvent être utilisées en combinaison. Le `readonly` contrainte spécifie que l'utilisateur ne peut pas modifier le paramètre correspondant à tous. + +**Exemple:** Laisser `users.xml` comprend des lignes: + +``` xml + + + 10000000000 + 0 + ... + + + 5000000000 + 20000000000 + + + + + + + +``` + +Les requêtes suivantes toutes les exceptions throw: + +``` sql +SET max_memory_usage=20000000001; +SET max_memory_usage=4999999999; +SET force_index_by_date=1; +``` + +``` text +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. +Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. +``` + +**Note:** le `default` le profil a une manipulation particulière: toutes les contraintes définies pour `default` le profil devient les contraintes par défaut, de sorte qu'ils restreignent tous les utilisateurs jusqu'à ce qu'ils soient explicitement remplacés pour ces utilisateurs. + +[Article Original](https://clickhouse.tech/docs/en/operations/settings/constraints_on_settings/) diff --git a/docs/fr/operations/settings/constraints_on_settings.md b/docs/fr/operations/settings/constraints_on_settings.md deleted file mode 100644 index 18094f50294..00000000000 --- a/docs/fr/operations/settings/constraints_on_settings.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 62 -toc_title: "Contraintes sur les param\xE8tres" ---- - -# Contraintes sur les paramètres {#constraints-on-settings} - -Les contraintes sur les paramètres peuvent être définis dans le `profiles` la section de la `user.xml` fichier de configuration et interdire aux utilisateurs de modifier certains `SET` requête. -Les contraintes sont définies comme suit: - -``` xml - - - - - lower_boundary - - - upper_boundary - - - lower_boundary - upper_boundary - - - - - - - -``` - -Si l'utilisateur tente de violer les contraintes une exception est levée et le réglage n'est pas modifié. -Trois types de contraintes sont pris en charge: `min`, `max`, `readonly`. Le `min` et `max` les contraintes spécifient les limites supérieure et inférieure pour un paramètre numérique et peuvent être utilisées en combinaison. Le `readonly` contrainte spécifie que l'utilisateur ne peut pas modifier le paramètre correspondant à tous. - -**Exemple:** Laisser `users.xml` comprend des lignes: - -``` xml - - - 10000000000 - 0 - ... - - - 5000000000 - 20000000000 - - - - - - - -``` - -Les requêtes suivantes toutes les exceptions throw: - -``` sql -SET max_memory_usage=20000000001; -SET max_memory_usage=4999999999; -SET force_index_by_date=1; -``` - -``` text -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. -Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. -``` - -**Note:** le `default` le profil a une manipulation particulière: toutes les contraintes définies pour `default` le profil devient les contraintes par défaut, de sorte qu'ils restreignent tous les utilisateurs jusqu'à ce qu'ils soient explicitement remplacés pour ces utilisateurs. - -[Article Original](https://clickhouse.tech/docs/en/operations/settings/constraints_on_settings/) diff --git a/docs/fr/operations/settings/index.md b/docs/fr/operations/settings/index.md index b29aa8c011b..0c81a2487c4 100644 --- a/docs/fr/operations/settings/index.md +++ b/docs/fr/operations/settings/index.md @@ -1,14 +1,15 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Settings +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Param\xE8tre" toc_priority: 55 toc_title: Introduction --- -# Paramètre {#settings} +# Paramètre {#session-settings-intro} + +Il existe plusieurs façons d'effectuer tous les paramètres décrits dans cette section de la documentation. -Il existe plusieurs façons de faire tous les paramètres décrits ci-dessous. Les paramètres sont configurés en couches, de sorte que chaque couche suivante redéfinit les paramètres précédents. Façons de configurer les paramètres, par ordre de priorité: diff --git a/docs/fr/operations/settings/permissions-for-queries.md b/docs/fr/operations/settings/permissions-for-queries.md new file mode 100644 index 00000000000..9107438e4b5 --- /dev/null +++ b/docs/fr/operations/settings/permissions-for-queries.md @@ -0,0 +1,61 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "Autorisations pour les requ\xEAtes" +--- + +# Autorisations pour les requêtes {#permissions_for_queries} + +Les requêtes dans ClickHouse peuvent être divisées en plusieurs types: + +1. Lire les requêtes de données: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. +2. Écrire des requêtes de données: `INSERT`, `OPTIMIZE`. +3. Modifier les paramètres requête: `SET`, `USE`. +4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) requête: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. +5. `KILL QUERY`. + +Les paramètres suivants règlent les autorisations utilisateur selon le type de requête: + +- [ReadOnly](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. +- [allow\_ddl](#settings_allow_ddl) — Restricts permissions for DDL queries. + +`KILL QUERY` peut être réalisée avec tous les paramètres. + +## ReadOnly {#settings_readonly} + +Restreint les autorisations pour lire des données, écrire des données et modifier les requêtes de paramètres. + +Voyez comment les requêtes sont divisées en types [surtout](#permissions_for_queries). + +Valeurs possibles: + +- 0 — All queries are allowed. +- 1 — Only read data queries are allowed. +- 2 — Read data and change settings queries are allowed. + +Après le réglage de `readonly = 1` l'utilisateur ne peut pas changer `readonly` et `allow_ddl` les paramètres de la session en cours. + +Lors de l'utilisation de la `GET` méthode dans le [Interface HTTP](../../interfaces/http.md), `readonly = 1` est définie automatiquement. Pour modifier les données, utilisez `POST` méthode. + +Paramètre `readonly = 1` interdire à l'utilisateur de modifier tous les paramètres. Il y a un moyen d'interdire à l'utilisateur +de modifier uniquement des paramètres spécifiques, pour plus de détails, voir [contraintes sur les paramètres](constraints-on-settings.md). + +Valeur par défaut: 0 + +## allow\_ddl {#settings_allow_ddl} + +Permet ou interdit [DDL](https://en.wikipedia.org/wiki/Data_definition_language) requête. + +Voyez comment les requêtes sont divisées en types [surtout](#permissions_for_queries). + +Valeurs possibles: + +- 0 — DDL queries are not allowed. +- 1 — DDL queries are allowed. + +Vous ne pouvez pas exécuter `SET allow_ddl = 1` si `allow_ddl = 0` pour la session en cours. + +Valeur par défaut: 1 + +[Article Original](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/fr/operations/settings/permissions_for_queries.md b/docs/fr/operations/settings/permissions_for_queries.md deleted file mode 100644 index e2b515e8d34..00000000000 --- a/docs/fr/operations/settings/permissions_for_queries.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 58 -toc_title: "Autorisations pour les requ\xEAtes" ---- - -# Autorisations pour les requêtes {#permissions_for_queries} - -Les requêtes dans ClickHouse peuvent être divisées en plusieurs types: - -1. Lire les requêtes de données: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. -2. Écrire des requêtes de données: `INSERT`, `OPTIMIZE`. -3. Modifier les paramètres requête: `SET`, `USE`. -4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) requête: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. -5. `KILL QUERY`. - -Les paramètres suivants règlent les autorisations utilisateur selon le type de requête: - -- [ReadOnly](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. -- [allow\_ddl](#settings_allow_ddl) — Restricts permissions for DDL queries. - -`KILL QUERY` peut être réalisée avec tous les paramètres. - -## ReadOnly {#settings_readonly} - -Restreint les autorisations pour lire des données, écrire des données et modifier les requêtes de paramètres. - -Voyez comment les requêtes sont divisées en types [surtout](#permissions_for_queries). - -Valeurs possibles: - -- 0 — All queries are allowed. -- 1 — Only read data queries are allowed. -- 2 — Read data and change settings queries are allowed. - -Après le réglage de `readonly = 1` l'utilisateur ne peut pas changer `readonly` et `allow_ddl` les paramètres de la session en cours. - -Lors de l'utilisation de la `GET` méthode dans le [Interface HTTP](../../interfaces/http.md), `readonly = 1` est définie automatiquement. Pour modifier les données, utilisez `POST` méthode. - -Paramètre `readonly = 1` interdire à l'utilisateur de modifier tous les paramètres. Il y a un moyen d'interdire à l'utilisateur -de modifier uniquement des paramètres spécifiques, pour plus de détails, voir [contraintes sur les paramètres](constraints_on_settings.md). - -Valeur par défaut: 0 - -## allow\_ddl {#settings_allow_ddl} - -Permet ou interdit [DDL](https://en.wikipedia.org/wiki/Data_definition_language) requête. - -Voyez comment les requêtes sont divisées en types [surtout](#permissions_for_queries). - -Valeurs possibles: - -- 0 — DDL queries are not allowed. -- 1 — DDL queries are allowed. - -Vous ne pouvez pas exécuter `SET allow_ddl = 1` si `allow_ddl = 0` pour la session en cours. - -Valeur par défaut: 1 - -[Article Original](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/fr/operations/settings/query-complexity.md b/docs/fr/operations/settings/query-complexity.md new file mode 100644 index 00000000000..7242c2e0222 --- /dev/null +++ b/docs/fr/operations/settings/query-complexity.md @@ -0,0 +1,301 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: "Restrictions sur la complexit\xE9 des requ\xEAtes" +--- + +# Restrictions sur la complexité des requêtes {#restrictions-on-query-complexity} + +Les Restrictions sur la complexité des requêtes font partie des paramètres. +Ils sont utilisés pour fournir une exécution plus sûre à partir de l'interface utilisateur. +Presque toutes les restrictions ne s'appliquent qu'à `SELECT`. Pour le traitement des requêtes distribuées, des restrictions sont appliquées sur chaque serveur séparément. + +ClickHouse vérifie les restrictions pour les parties de données, pas pour chaque ligne. Cela signifie que vous pouvez dépasser la valeur de restriction de la taille de la partie données. + +Restrictions sur l' “maximum amount of something” peut prendre la valeur 0, ce qui signifie “unrestricted”. +La plupart des restrictions ont également un ‘overflow\_mode’ paramètre signification que faire lorsque la limite est dépassée. +Il peut prendre deux valeurs: `throw` ou `break`. Les Restrictions sur l'agrégation (group\_by\_overflow\_mode) ont également la valeur `any`. + +`throw` – Throw an exception (default). + +`break` – Stop executing the query and return the partial result, as if the source data ran out. + +`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don't add new keys to the set. + +## max\_memory\_usage {#settings_max_memory_usage} + +La quantité maximale de RAM à utiliser pour exécuter une requête sur un seul serveur. + +Dans le fichier de configuration par défaut, le maximum est de 10 Go. + +Le réglage ne tient pas compte du volume de mémoire disponible ou du volume total de mémoire sur la machine. +La restriction s'applique à une seule requête au sein d'un seul serveur. +Vous pouvez utiliser `SHOW PROCESSLIST` pour vérifier la consommation de mémoire pour chaque requête. +En outre, la consommation de mémoire maximale est suivie pour chaque requête et écrite dans le journal. + +L'utilisation de la mémoire n'est pas surveillée pour les membres de certaines fonctions d'agrégation. + +L'utilisation de la mémoire n'est pas totalement suivies pour les états des fonctions d'agrégation `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` de `String` et `Array` argument. + +La consommation de mémoire est également limitée par les paramètres `max_memory_usage_for_user` et `max_memory_usage_for_all_queries`. + +## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} + +Quantité maximale de RAM à utiliser pour exécuter les requêtes d'un utilisateur sur un seul serveur. + +Les valeurs par défaut sont définies dans [Paramètre.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). Par défaut, le montant n'est pas limité (`max_memory_usage_for_user = 0`). + +Voir aussi la description de [max\_memory\_usage](#settings_max_memory_usage). + +## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} + +La quantité maximale de RAM à utiliser pour exécuter toutes les requêtes sur un seul serveur. + +Les valeurs par défaut sont définies dans [Paramètre.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). Par défaut, le montant n'est pas limité (`max_memory_usage_for_all_queries = 0`). + +Voir aussi la description de [max\_memory\_usage](#settings_max_memory_usage). + +## max\_rows\_to\_read {#max-rows-to-read} + +Les restrictions suivantes peut être vérifiée sur chaque bloc (au lieu de sur chaque ligne). Autrement dit, les restrictions peuvent être brisées un peu. +Lors de l'exécution d'une requête dans plusieurs threads, les restrictions suivantes s'appliquent à chaque thread séparément. + +Un nombre maximum de lignes pouvant être lues à partir d'un tableau lors de l'exécution d'une requête. + +## max\_bytes\_to\_read {#max-bytes-to-read} + +Nombre maximal d'octets (données non compressées) pouvant être lus à partir d'une table lors de l'exécution d'une requête. + +## read\_overflow\_mode {#read-overflow-mode} + +Que faire lorsque le volume de lecture de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. + +## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} + +Un nombre maximum de clés uniques reçues de l'agrégation. Ce paramètre permet de limiter la consommation de mémoire lors de l'agrégation. + +## group\_by\_overflow\_mode {#group-by-overflow-mode} + +Que faire lorsque le nombre de clés uniques pour l'agrégation dépasse la limite: ‘throw’, ‘break’, ou ‘any’. Par défaut, les jeter. +À l'aide de la ‘any’ valeur vous permet d'exécuter une approximation de GROUP BY. La qualité de cette approximation dépend de la nature statistique des données. + +## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} + +Active ou désactive l'exécution de `GROUP BY` clauses dans la mémoire externe. Voir [Groupe par dans la mémoire externe](../../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory). + +Valeurs possibles: + +- Volume maximal de RAM (en octets) pouvant être utilisé par le [GROUP BY](../../sql-reference/statements/select/group-by.md#select-group-by-clause) opération. +- 0 — `GROUP BY` dans la mémoire externe désactivé. + +Valeur par défaut: 0. + +## max\_rows\_to\_sort {#max-rows-to-sort} + +Un nombre maximum de lignes avant le tri. Cela vous permet de limiter la consommation de mémoire lors du tri. + +## max\_bytes\_to\_sort {#max-bytes-to-sort} + +Un nombre maximal d'octets avant le tri. + +## sort\_overflow\_mode {#sort-overflow-mode} + +Que faire si le nombre de lignes reçues avant le tri dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. + +## max\_result\_rows {#setting-max_result_rows} + +Limite sur le nombre de lignes dans le résultat. Également vérifié pour les sous-requêtes, et sur des serveurs distants lors de l'exécution de parties d'une requête distribuée. + +## max\_result\_bytes {#max-result-bytes} + +Limite sur le nombre d'octets dans le résultat. Le même que le réglage précédent. + +## result\_overflow\_mode {#result-overflow-mode} + +Que faire si le volume du résultat dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. + +Utiliser ‘break’ est similaire à L'utilisation de LIMIT. `Break` interrompt l'exécution seulement au niveau du bloc. Cela signifie que la quantité de lignes renvoyées est supérieure à [max\_result\_rows](#setting-max_result_rows) multiples de [max\_block\_size](settings.md#setting-max_block_size) et dépend de l' [max\_threads](settings.md#settings-max_threads). + +Exemple: + +``` sql +SET max_threads = 3, max_block_size = 3333; +SET max_result_rows = 3334, result_overflow_mode = 'break'; + +SELECT * +FROM numbers_mt(100000) +FORMAT Null; +``` + +Résultat: + +``` text +6666 rows in set. ... +``` + +## max\_execution\_time {#max-execution-time} + +Durée maximale d'exécution de la requête en secondes. +Pour le moment, il n'est pas vérifié pour l'une des étapes de tri, ni lors de la fusion et de la finalisation des fonctions d'agrégat. + +## timeout\_overflow\_mode {#timeout-overflow-mode} + +Que faire si la requête est exécutée plus de ‘max\_execution\_time’: ‘throw’ ou ‘break’. Par défaut, les jeter. + +## min\_execution\_speed {#min-execution-speed} + +Vitesse d'exécution minimale en lignes par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est inférieure, une exception est levée. + +## min\_execution\_speed\_bytes {#min-execution-speed-bytes} + +Un nombre minimum d'exécution d'octets par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est inférieure, une exception est levée. + +## max\_execution\_speed {#max-execution-speed} + +Un nombre maximal d'exécution de lignes par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est élevée, la vitesse d'exécution sera réduit. + +## max\_execution\_speed\_bytes {#max-execution-speed-bytes} + +Un nombre maximal d'exécution d'octets par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est élevée, la vitesse d'exécution sera réduit. + +## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} + +Vérifie que la vitesse d'exécution n'est pas trop lent (pas moins de ‘min\_execution\_speed’), après l'expiration du temps spécifié en secondes. + +## max\_columns\_to\_read {#max-columns-to-read} + +Nombre maximal de colonnes pouvant être lues à partir d'une table dans une seule requête. Si une requête nécessite la lecture d'un plus grand nombre de colonnes, il lève une exception. + +## max\_temporary\_columns {#max-temporary-columns} + +Nombre maximal de colonnes temporaires qui doivent être conservées en RAM en même temps lors de l'exécution d'une requête, y compris les colonnes constantes. S'il y a plus de colonnes temporaires que cela, il lève une exception. + +## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} + +La même chose que ‘max\_temporary\_columns’ mais sans compter constante colonnes. +Notez que les colonnes constantes sont formées assez souvent lors de l'exécution d'une requête, mais elles nécessitent environ zéro ressource informatique. + +## max\_subquery\_depth {#max-subquery-depth} + +Profondeur maximale de sous-requêtes. Si les sous-requêtes sont plus profondes, une exception est levée. Par défaut, 100. + +## max\_pipeline\_depth {#max-pipeline-depth} + +Profondeur maximale du pipeline. Correspond au nombre de transformations que chaque bloc de données lors du traitement des requêtes. Compté dans les limites d'un seul serveur. Si la profondeur du pipeline est supérieure, une exception est levée. Par défaut, 1000. + +## max\_ast\_depth {#max-ast-depth} + +Profondeur maximale d'une requête arbre syntaxique. En cas de dépassement, une exception est levée. +À ce moment, il n'est pas vérifié pendant l'analyse, mais seulement après l'analyse de la requête. Autrement dit, un arbre syntaxique trop profond peut être créé pendant l'analyse, mais la requête échouera. Par défaut, 1000. + +## max\_ast\_elements {#max-ast-elements} + +Un nombre maximal d'éléments dans une requête arbre syntaxique. En cas de dépassement, une exception est levée. +De la même manière que le paramètre précédent, il est vérifié qu'après l'analyse de la requête. Par défaut, 50 000. + +## max\_rows\_in\_set {#max-rows-in-set} + +Nombre maximal de lignes pour un ensemble de données dans la clause in créée à partir d'une sous-requête. + +## max\_bytes\_in\_set {#max-bytes-in-set} + +Nombre maximal d'octets (données non compressées) utilisés par un ensemble de la clause in créé à partir d'une sous-requête. + +## set\_overflow\_mode {#set-overflow-mode} + +Que faire lorsque la quantité de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. + +## max\_rows\_in\_distinct {#max-rows-in-distinct} + +Un nombre maximum de lignes différentes lors de L'utilisation de DISTINCT. + +## max\_bytes\_in\_distinct {#max-bytes-in-distinct} + +Nombre maximal d'octets utilisés par une table de hachage lors de L'utilisation de DISTINCT. + +## distinct\_overflow\_mode {#distinct-overflow-mode} + +Que faire lorsque la quantité de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. + +## max\_rows\_to\_transfer {#max-rows-to-transfer} + +Nombre maximal de lignes pouvant être transmises à un serveur distant ou enregistrées dans une table temporaire lors de L'utilisation de GLOBAL IN. + +## max\_bytes\_to\_transfer {#max-bytes-to-transfer} + +Nombre maximal d'octets (données non compressées) pouvant être transmis à un serveur distant ou enregistrés dans une table temporaire lors de L'utilisation de GLOBAL IN. + +## transfer\_overflow\_mode {#transfer-overflow-mode} + +Que faire lorsque la quantité de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. + +## max\_rows\_in\_join {#settings-max_rows_in_join} + +Limite le nombre de lignes dans la table de hachage utilisée lors de la jonction de tables. + +Ce réglage s'applique à [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) les opérations et les [Rejoindre](../../engines/table-engines/special/join.md) tableau moteur. + +Si une requête contient plusieurs jointures, ClickHouse vérifie ce paramètre pour chaque résultat intermédiaire. + +ClickHouse peut procéder à différentes actions lorsque la limite est atteinte. L'utilisation de la [join\_overflow\_mode](#settings-join_overflow_mode) réglage pour choisir l'action. + +Valeurs possibles: + +- Entier positif. +- 0 — Unlimited number of rows. + +Valeur par défaut: 0. + +## max\_bytes\_in\_join {#settings-max_bytes_in_join} + +Limite la taille en octets de la table de hachage utilisée lors de l'assemblage de tables. + +Ce réglage s'applique à [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) les opérations et les [Rejoindre le moteur de table](../../engines/table-engines/special/join.md). + +Si la requête contient des jointures, ClickHouse vérifie ce paramètre pour chaque résultat intermédiaire. + +ClickHouse peut procéder à différentes actions lorsque la limite est atteinte. Utiliser [join\_overflow\_mode](#settings-join_overflow_mode) paramètres pour choisir l'action. + +Valeurs possibles: + +- Entier positif. +- 0 — Memory control is disabled. + +Valeur par défaut: 0. + +## join\_overflow\_mode {#settings-join_overflow_mode} + +Définit l'action que ClickHouse effectue lorsque l'une des limites de jointure suivantes est atteinte: + +- [max\_bytes\_in\_join](#settings-max_bytes_in_join) +- [max\_rows\_in\_join](#settings-max_rows_in_join) + +Valeurs possibles: + +- `THROW` — ClickHouse throws an exception and breaks operation. +- `BREAK` — ClickHouse breaks operation and doesn't throw an exception. + +Valeur par défaut: `THROW`. + +**Voir Aussi** + +- [Clause de JOINTURE](../../sql-reference/statements/select/join.md#select-join) +- [Rejoindre le moteur de table](../../engines/table-engines/special/join.md) + +## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} + +Limite le nombre maximal de partitions dans un seul bloc inséré. + +- Entier positif. +- 0 — Unlimited number of partitions. + +Valeur par défaut: 100. + +**Détail** + +Lors de l'insertion de données, ClickHouse calcule le nombre de partitions dans le bloc inséré. Si le nombre de partitions est plus que `max_partitions_per_insert_block`, ClickHouse lève une exception avec le texte suivant: + +> “Too many partitions for single INSERT block (more than” + toString (max\_parts) + “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” + +[Article Original](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/fr/operations/settings/query_complexity.md b/docs/fr/operations/settings/query_complexity.md deleted file mode 100644 index 9c5e0e2d923..00000000000 --- a/docs/fr/operations/settings/query_complexity.md +++ /dev/null @@ -1,301 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 59 -toc_title: "Restrictions sur la complexit\xE9 des requ\xEAtes" ---- - -# Restrictions Sur La Complexité Des Requêtes {#restrictions-on-query-complexity} - -Les Restrictions sur la complexité des requêtes font partie des paramètres. -Ils sont utilisés pour fournir une exécution plus sûre à partir de l'interface utilisateur. -Presque toutes les restrictions ne s'appliquent qu'à `SELECT`. Pour le traitement des requêtes distribuées, des restrictions sont appliquées sur chaque serveur séparément. - -ClickHouse vérifie les restrictions pour les parties de données, pas pour chaque ligne. Cela signifie que vous pouvez dépasser la valeur de restriction de la taille de la partie données. - -Restrictions sur l' “maximum amount of something” peut prendre la valeur 0, ce qui signifie “unrestricted”. -La plupart des restrictions ont également un ‘overflow\_mode’ paramètre signification que faire lorsque la limite est dépassée. -Il peut prendre deux valeurs: `throw` ou `break`. Les Restrictions sur l'agrégation (group\_by\_overflow\_mode) ont également la valeur `any`. - -`throw` – Throw an exception (default). - -`break` – Stop executing the query and return the partial result, as if the source data ran out. - -`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don't add new keys to the set. - -## max\_memory\_usage {#settings_max_memory_usage} - -La quantité maximale de RAM à utiliser pour exécuter une requête sur un seul serveur. - -Dans le fichier de configuration par défaut, le maximum est de 10 Go. - -Le réglage ne tient pas compte du volume de mémoire disponible ou du volume total de mémoire sur la machine. -La restriction s'applique à une seule requête au sein d'un seul serveur. -Vous pouvez utiliser `SHOW PROCESSLIST` pour vérifier la consommation de mémoire pour chaque requête. -En outre, la consommation de mémoire maximale est suivie pour chaque requête et écrite dans le journal. - -L'utilisation de la mémoire n'est pas surveillée pour les membres de certaines fonctions d'agrégation. - -L'utilisation de la mémoire n'est pas totalement suivies pour les états des fonctions d'agrégation `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` de `String` et `Array` argument. - -La consommation de mémoire est également limitée par les paramètres `max_memory_usage_for_user` et `max_memory_usage_for_all_queries`. - -## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} - -Quantité maximale de RAM à utiliser pour exécuter les requêtes d'un utilisateur sur un seul serveur. - -Les valeurs par défaut sont définies dans [Paramètre.h](https://github.com/ClickHouse/ClickHouse/blob/master/dbms/Core/Settings.h#L288). Par défaut, le montant n'est pas limité (`max_memory_usage_for_user = 0`). - -Voir aussi la description de [max\_memory\_usage](#settings_max_memory_usage). - -## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} - -La quantité maximale de RAM à utiliser pour exécuter toutes les requêtes sur un seul serveur. - -Les valeurs par défaut sont définies dans [Paramètre.h](https://github.com/ClickHouse/ClickHouse/blob/master/dbms/Core/Settings.h#L289). Par défaut, le montant n'est pas limité (`max_memory_usage_for_all_queries = 0`). - -Voir aussi la description de [max\_memory\_usage](#settings_max_memory_usage). - -## max\_rows\_to\_read {#max-rows-to-read} - -Les restrictions suivantes peut être vérifiée sur chaque bloc (au lieu de sur chaque ligne). Autrement dit, les restrictions peuvent être brisées un peu. -Lors de l'exécution d'une requête dans plusieurs threads, les restrictions suivantes s'appliquent à chaque thread séparément. - -Un nombre maximum de lignes pouvant être lues à partir d'un tableau lors de l'exécution d'une requête. - -## max\_bytes\_to\_read {#max-bytes-to-read} - -Nombre maximal d'octets (données non compressées) pouvant être lus à partir d'une table lors de l'exécution d'une requête. - -## read\_overflow\_mode {#read-overflow-mode} - -Que faire lorsque le volume de lecture de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. - -## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} - -Un nombre maximum de clés uniques reçues de l'agrégation. Ce paramètre permet de limiter la consommation de mémoire lors de l'agrégation. - -## group\_by\_overflow\_mode {#group-by-overflow-mode} - -Que faire lorsque le nombre de clés uniques pour l'agrégation dépasse la limite: ‘throw’, ‘break’, ou ‘any’. Par défaut, les jeter. -À l'aide de la ‘any’ valeur vous permet d'exécuter une approximation de GROUP BY. La qualité de cette approximation dépend de la nature statistique des données. - -## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} - -Active ou désactive l'exécution de `GROUP BY` clauses dans la mémoire externe. Voir [Groupe par dans la mémoire externe](../../sql_reference/statements/select.md#select-group-by-in-external-memory). - -Valeurs possibles: - -- Volume maximal de RAM (en octets) pouvant être utilisé par le [GROUP BY](../../sql_reference/statements/select.md#select-group-by-clause) opération. -- 0 — `GROUP BY` dans la mémoire externe désactivé. - -Valeur par défaut: 0. - -## max\_rows\_to\_sort {#max-rows-to-sort} - -Un nombre maximum de lignes avant le tri. Cela vous permet de limiter la consommation de mémoire lors du tri. - -## max\_bytes\_to\_sort {#max-bytes-to-sort} - -Un nombre maximal d'octets avant le tri. - -## sort\_overflow\_mode {#sort-overflow-mode} - -Que faire si le nombre de lignes reçues avant le tri dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. - -## max\_result\_rows {#setting-max_result_rows} - -Limite sur le nombre de lignes dans le résultat. Également vérifié pour les sous-requêtes, et sur des serveurs distants lors de l'exécution de parties d'une requête distribuée. - -## max\_result\_bytes {#max-result-bytes} - -Limite sur le nombre d'octets dans le résultat. Le même que le réglage précédent. - -## result\_overflow\_mode {#result-overflow-mode} - -Que faire si le volume du résultat dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. - -Utiliser ‘break’ est similaire à L'utilisation de LIMIT. `Break` interrompt l'exécution seulement au niveau du bloc. Cela signifie que la quantité de lignes renvoyées est supérieure à [max\_result\_rows](#setting-max_result_rows) multiples de [max\_block\_size](settings.md#setting-max_block_size) et dépend de l' [max\_threads](settings.md#settings-max_threads). - -Exemple: - -``` sql -SET max_threads = 3, max_block_size = 3333; -SET max_result_rows = 3334, result_overflow_mode = 'break'; - -SELECT * -FROM numbers_mt(100000) -FORMAT Null; -``` - -Résultat: - -``` text -6666 rows in set. ... -``` - -## max\_execution\_time {#max-execution-time} - -Durée maximale d'exécution de la requête en secondes. -Pour le moment, il n'est pas vérifié pour l'une des étapes de tri, ni lors de la fusion et de la finalisation des fonctions d'agrégat. - -## timeout\_overflow\_mode {#timeout-overflow-mode} - -Que faire si la requête est exécutée plus de ‘max\_execution\_time’: ‘throw’ ou ‘break’. Par défaut, les jeter. - -## min\_execution\_speed {#min-execution-speed} - -Vitesse d'exécution minimale en lignes par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est inférieure, une exception est levée. - -## min\_execution\_speed\_bytes {#min-execution-speed-bytes} - -Un nombre minimum d'exécution d'octets par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est inférieure, une exception est levée. - -## max\_execution\_speed {#max-execution-speed} - -Un nombre maximal d'exécution de lignes par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est élevée, la vitesse d'exécution sera réduit. - -## max\_execution\_speed\_bytes {#max-execution-speed-bytes} - -Un nombre maximal d'exécution d'octets par seconde. Vérifié sur chaque bloc de données quand ‘timeout\_before\_checking\_execution\_speed’ expirer. Si la vitesse d'exécution est élevée, la vitesse d'exécution sera réduit. - -## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} - -Vérifie que la vitesse d'exécution n'est pas trop lent (pas moins de ‘min\_execution\_speed’), après l'expiration du temps spécifié en secondes. - -## max\_columns\_to\_read {#max-columns-to-read} - -Nombre maximal de colonnes pouvant être lues à partir d'une table dans une seule requête. Si une requête nécessite la lecture d'un plus grand nombre de colonnes, il lève une exception. - -## max\_temporary\_columns {#max-temporary-columns} - -Nombre maximal de colonnes temporaires qui doivent être conservées en RAM en même temps lors de l'exécution d'une requête, y compris les colonnes constantes. S'il y a plus de colonnes temporaires que cela, il lève une exception. - -## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} - -La même chose que ‘max\_temporary\_columns’ mais sans compter constante colonnes. -Notez que les colonnes constantes sont formées assez souvent lors de l'exécution d'une requête, mais elles nécessitent environ zéro ressource informatique. - -## max\_subquery\_depth {#max-subquery-depth} - -Profondeur maximale de sous-requêtes. Si les sous-requêtes sont plus profondes, une exception est levée. Par défaut, 100. - -## max\_pipeline\_depth {#max-pipeline-depth} - -Profondeur maximale du pipeline. Correspond au nombre de transformations que chaque bloc de données lors du traitement des requêtes. Compté dans les limites d'un seul serveur. Si la profondeur du pipeline est supérieure, une exception est levée. Par défaut, 1000. - -## max\_ast\_depth {#max-ast-depth} - -Profondeur maximale d'une requête arbre syntaxique. En cas de dépassement, une exception est levée. -À ce moment, il n'est pas vérifié pendant l'analyse, mais seulement après l'analyse de la requête. Autrement dit, un arbre syntaxique trop profond peut être créé pendant l'analyse, mais la requête échouera. Par défaut, 1000. - -## max\_ast\_elements {#max-ast-elements} - -Un nombre maximal d'éléments dans une requête arbre syntaxique. En cas de dépassement, une exception est levée. -De la même manière que le paramètre précédent, il est vérifié qu'après l'analyse de la requête. Par défaut, 50 000. - -## max\_rows\_in\_set {#max-rows-in-set} - -Nombre maximal de lignes pour un ensemble de données dans la clause in créée à partir d'une sous-requête. - -## max\_bytes\_in\_set {#max-bytes-in-set} - -Nombre maximal d'octets (données non compressées) utilisés par un ensemble de la clause in créé à partir d'une sous-requête. - -## set\_overflow\_mode {#set-overflow-mode} - -Que faire lorsque la quantité de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. - -## max\_rows\_in\_distinct {#max-rows-in-distinct} - -Un nombre maximum de lignes différentes lors de L'utilisation de DISTINCT. - -## max\_bytes\_in\_distinct {#max-bytes-in-distinct} - -Nombre maximal d'octets utilisés par une table de hachage lors de L'utilisation de DISTINCT. - -## distinct\_overflow\_mode {#distinct-overflow-mode} - -Que faire lorsque la quantité de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. - -## max\_rows\_to\_transfer {#max-rows-to-transfer} - -Nombre maximal de lignes pouvant être transmises à un serveur distant ou enregistrées dans une table temporaire lors de L'utilisation de GLOBAL IN. - -## max\_bytes\_to\_transfer {#max-bytes-to-transfer} - -Nombre maximal d'octets (données non compressées) pouvant être transmis à un serveur distant ou enregistrés dans une table temporaire lors de L'utilisation de GLOBAL IN. - -## transfer\_overflow\_mode {#transfer-overflow-mode} - -Que faire lorsque la quantité de données dépasse l'une des limites: ‘throw’ ou ‘break’. Par défaut, les jeter. - -## max\_rows\_in\_join {#settings-max_rows_in_join} - -Limite le nombre de lignes dans la table de hachage utilisée lors de la jonction de tables. - -Ce réglage s'applique à [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) les opérations et les [Rejoindre](../../engines/table_engines/special/join.md) tableau moteur. - -Si une requête contient plusieurs jointures, ClickHouse vérifie ce paramètre pour chaque résultat intermédiaire. - -ClickHouse peut procéder à différentes actions lorsque la limite est atteinte. L'utilisation de la [join\_overflow\_mode](#settings-join_overflow_mode) réglage pour choisir l'action. - -Valeurs possibles: - -- Entier positif. -- 0 — Unlimited number of rows. - -Valeur par défaut: 0. - -## max\_bytes\_in\_join {#settings-max_bytes_in_join} - -Limite la taille en octets de la table de hachage utilisée lors de l'assemblage de tables. - -Ce réglage s'applique à [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) les opérations et les [Rejoindre le moteur de table](../../engines/table_engines/special/join.md). - -Si la requête contient des jointures, ClickHouse vérifie ce paramètre pour chaque résultat intermédiaire. - -ClickHouse peut procéder à différentes actions lorsque la limite est atteinte. Utiliser [join\_overflow\_mode](#settings-join_overflow_mode) paramètres pour choisir l'action. - -Valeurs possibles: - -- Entier positif. -- 0 — Memory control is disabled. - -Valeur par défaut: 0. - -## join\_overflow\_mode {#settings-join_overflow_mode} - -Définit l'action que ClickHouse effectue lorsque l'une des limites de jointure suivantes est atteinte: - -- [max\_bytes\_in\_join](#settings-max_bytes_in_join) -- [max\_rows\_in\_join](#settings-max_rows_in_join) - -Valeurs possibles: - -- `THROW` — ClickHouse throws an exception and breaks operation. -- `BREAK` — ClickHouse breaks operation and doesn't throw an exception. - -Valeur par défaut: `THROW`. - -**Voir Aussi** - -- [Clause de JOINTURE](../../sql_reference/statements/select.md#select-join) -- [Rejoindre le moteur de table](../../engines/table_engines/special/join.md) - -## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} - -Limite le nombre maximal de partitions dans un seul bloc inséré. - -- Entier positif. -- 0 — Unlimited number of partitions. - -Valeur par défaut: 100. - -**Détail** - -Lors de l'insertion de données, ClickHouse calcule le nombre de partitions dans le bloc inséré. Si le nombre de partitions est plus que `max_partitions_per_insert_block`, ClickHouse lève une exception avec le texte suivant: - -> “Too many partitions for single INSERT block (more than” + toString (max\_parts) + “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” - -[Article Original](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/fr/operations/settings/settings-profiles.md b/docs/fr/operations/settings/settings-profiles.md new file mode 100644 index 00000000000..2a0338e7873 --- /dev/null +++ b/docs/fr/operations/settings/settings-profiles.md @@ -0,0 +1,81 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "Les Param\xE8tres Des Profils" +--- + +# Les Paramètres Des Profils {#settings-profiles} + +Un profil de paramètres est une collection de paramètres regroupés sous le même nom. + +!!! note "Information" + Clickhouse prend également en charge [Flux de travail piloté par SQL](../access-rights.md#access-control) pour gérer les profils de paramètres. Nous vous conseillons de l'utiliser. + +Un profil peut avoir n'importe quel nom. Le profil peut avoir n'importe quel nom. Vous pouvez spécifier le même profil pour différents utilisateurs. La chose la plus importante que vous pouvez écrire dans les paramètres de profil `readonly=1` qui assure un accès en lecture seule. + +Paramètres les profils peuvent hériter les uns des autres. Pour utiliser l'héritage, indiquer un ou plusieurs `profile` paramètres avant les autres paramètres répertoriés dans le profil. Dans le cas où un paramètre est défini dans les différents profils, les dernières définie est utilisée. + +Pour appliquer tous les paramètres d'un profil, définissez `profile` paramètre. + +Exemple: + +Installer le `web` profil. + +``` sql +SET profile = 'web' +``` + +Les profils de paramètres sont déclarés dans le fichier de configuration utilisateur. Ce n'est généralement `users.xml`. + +Exemple: + +``` xml + + + + + + 8 + + + + + 1000000000 + 100000000000 + + 1000000 + any + + 1000000 + 1000000000 + + 100000 + 100000000 + break + + 600 + 1000000 + 15 + + 25 + 100 + 50 + + 2 + 25 + 50 + 100 + + 1 + + +``` + +L'exemple spécifie deux profils: `default` et `web`. + +Le `default` profil a un but particulier: il doit toujours être présent et est appliquée lors du démarrage du serveur. En d'autres termes, l' `default` profil contient les paramètres par défaut. + +Le `web` profil est un profil régulier qui peut être défini à l'aide `SET` requête ou en utilisant un paramètre URL dans une requête HTTP. + +[Article Original](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/fr/operations/settings/settings-users.md b/docs/fr/operations/settings/settings-users.md new file mode 100644 index 00000000000..2be41d90533 --- /dev/null +++ b/docs/fr/operations/settings/settings-users.md @@ -0,0 +1,164 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "Les Param\xE8tres De L'Utilisateur" +--- + +# Les Paramètres De L'Utilisateur {#user-settings} + +Le `users` la section de la `user.xml` le fichier de configuration contient les paramètres utilisateur. + +!!! note "Information" + Clickhouse prend également en charge [Flux de travail piloté par SQL](../access-rights.md#access-control) pour gérer les utilisateurs. Nous vous conseillons de l'utiliser. + +La Structure de la `users` section: + +``` xml + + + + + + + + 0|1 + + + + + profile_name + + default + + + + + expression + + + + + + +``` + +### nom\_utilisateur/mot de passe {#user-namepassword} + +Le mot de passe peut être spécifié en texte clair ou en SHA256 (format hexadécimal). + +- Pour attribuer un mot de passe en clair (**pas recommandé**), la placer dans un `password` élément. + + Exemple, `qwerty`. Le mot de passe peut être laissé en blanc. + + + +- Pour attribuer un mot de passe à l'aide de son hachage SHA256, placez-le dans un `password_sha256_hex` élément. + + Exemple, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. + + Exemple de génération d'un mot de passe à partir du shell: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' + + La première ligne du résultat est le mot de passe. La deuxième ligne est le hachage SHA256 correspondant. + + + +- Pour la compatibilité avec les clients MySQL, le mot de passe peut être spécifié dans le hachage double SHA1. Le placer dans `password_double_sha1_hex` élément. + + Exemple, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. + + Exemple de génération d'un mot de passe à partir du shell: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' + + La première ligne du résultat est le mot de passe. La deuxième ligne est le double hachage SHA1 correspondant. + +### access\_management {#access_management-user-setting} + +Ce paramètre active de désactive l'utilisation de SQL-driven [le contrôle d'accès et de gestion de compte](../access-rights.md#access-control) pour l'utilisateur. + +Valeurs possibles: + +- 0 — Disabled. +- 1 — Enabled. + +Valeur par défaut: 0. + +### nom\_utilisateur / réseaux {#user-namenetworks} + +Liste des réseaux à partir desquels L'utilisateur peut se connecter au serveur ClickHouse. + +Chaque élément de la liste peut avoir l'une des formes suivantes: + +- `` — IP address or network mask. + + Exemple: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. + +- `` — Hostname. + + Exemple: `example01.host.ru`. + + Pour vérifier l'accès, une requête DNS est effectuée et toutes les adresses IP renvoyées sont comparées à l'adresse homologue. + +- `` — Regular expression for hostnames. + + Exemple, `^example\d\d-\d\d-\d\.host\.ru$` + + Pour vérifier l'accès, un [Requête DNS PTR](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) est effectuée pour l'adresse homologue, puis l'expression rationnelle spécifiée est appliquée. Ensuite, une autre requête DNS est effectuée pour les résultats de la requête PTR et toutes les adresses reçues sont comparées à l'adresse homologue. Nous recommandons fortement que regexp se termine avec $. + +Tous les résultats des requêtes DNS sont mis en cache jusqu'au redémarrage du serveur. + +**Exemple** + +Pour ouvrir l'accès de l'utilisateur à partir de n'importe quel réseau, spécifiez: + +``` xml +::/0 +``` + +!!! warning "Avertissement" + Il n'est pas sûr d'ouvrir l'accès à partir de n'importe quel réseau, sauf si vous avez un pare-feu correctement configuré ou si le serveur n'est pas directement connecté à Internet. + +Pour ouvrir l'accès uniquement à partir de localhost, spécifier: + +``` xml +::1 +127.0.0.1 +``` + +### nom\_utilisateur / profil {#user-nameprofile} + +Vous pouvez attribuer un profil des paramètres pour l'utilisateur. Les profils de paramètres sont configurés dans une section distincte du `users.xml` fichier. Pour plus d'informations, voir [Profils des paramètres](settings-profiles.md). + +### nom\_utilisateur / quota {#user-namequota} + +Les Quotas vous permettent de suivre ou de limiter l'utilisation des ressources sur une période donnée. Les Quotas sont configurés dans le `quotas` +la section de la `users.xml` fichier de configuration. + +Vous pouvez attribuer un jeu de quotas à l'utilisateur. Pour une description détaillée de la configuration des quotas, voir [Quota](../quotas.md#quotas). + +### nom\_utilisateur/bases de données {#user-namedatabases} + +Dans cette section, vous pouvez limiter les lignes renvoyées par ClickHouse pour `SELECT` requêtes faites par l'utilisateur actuel, implémentant ainsi la sécurité de base au niveau de la ligne. + +**Exemple** + +La configuration suivante force cet utilisateur `user1` ne peut voir les lignes de `table1` comme le résultat de `SELECT` requêtes, où la valeur de la `id` le champ est 1000. + +``` xml + + + + + id = 1000 + + + + +``` + +Le `filter` peut être n'importe quelle expression résultant en un [UInt8](../../sql-reference/data-types/int-uint.md)-le type de la valeur. Il contient généralement des comparaisons et des opérateurs logiques. Les lignes de `database_name.table1` où filtrer les résultats à 0 ne sont pas retournés pour cet utilisateur. Le filtrage est incompatible avec `PREWHERE` opérations et désactive `WHERE→PREWHERE` optimisation. + +[Article Original](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/fr/operations/settings/settings.md b/docs/fr/operations/settings/settings.md index 8de3ea3e7d5..ab26a114bcf 100644 --- a/docs/fr/operations/settings/settings.md +++ b/docs/fr/operations/settings/settings.md @@ -1,15 +1,13 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 60 -toc_title: "Param\xE8tre" +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd --- # Paramètre {#settings} ## distributed\_product\_mode {#distributed-product-mode} -Modifie le comportement de [distribués sous-requêtes](../../sql_reference/statements/select.md). +Modifie le comportement de [distribués sous-requêtes](../../sql-reference/operators/in.md). ClickHouse applies this setting when the query contains the product of distributed tables, i.e. when the query for a distributed table contains a non-GLOBAL subquery for the distributed table. @@ -18,7 +16,7 @@ Restriction: - Uniquement appliqué pour les sous-requêtes IN et JOIN. - Uniquement si la section FROM utilise une table distribuée contenant plus d'un fragment. - Si la sous-requête concerne un distribué tableau contenant plus d'un fragment. -- Pas utilisé pour une table [distant](../../sql_reference/table_functions/remote.md) fonction. +- Pas utilisé pour une table [distant](../../sql-reference/table-functions/remote.md) fonction. Valeurs possibles: @@ -53,7 +51,7 @@ Si `enable_optimize_predicate_expression = 0` puis le temps d'exécution de la d ## fallback\_to\_stale\_replicas\_for\_distributed\_queries {#settings-fallback_to_stale_replicas_for_distributed_queries} -Force une requête à un réplica obsolète si les données mises à jour ne sont pas disponibles. Voir [Réplication](../../engines/table_engines/mergetree_family/replication.md). +Force une requête à un réplica obsolète si les données mises à jour ne sont pas disponibles. Voir [Réplication](../../engines/table-engines/mergetree-family/replication.md). ClickHouse sélectionne le plus pertinent parmi les répliques obsolètes de la table. @@ -67,7 +65,7 @@ Désactive l'exécution de la requête si l'index ne peut pas être utilisé par Fonctionne avec les tables de la famille MergeTree. -Si `force_index_by_date=1`, Clickhouse vérifie si la requête a une condition de clé de date qui peut être utilisée pour restreindre les plages de données. S'il n'y a pas de condition appropriée, il lève une exception. Cependant, il ne vérifie pas si la condition réduit la quantité de données à lire. Par exemple, la condition `Date != ' 2000-01-01 '` est acceptable même lorsqu'il correspond à toutes les données de la table (c'est-à-dire que l'exécution de la requête nécessite une analyse complète). Pour plus d'informations sur les plages de données dans les tables MergeTree, voir [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +Si `force_index_by_date=1`, Clickhouse vérifie si la requête a une condition de clé de date qui peut être utilisée pour restreindre les plages de données. S'il n'y a pas de condition appropriée, il lève une exception. Cependant, il ne vérifie pas si la condition réduit la quantité de données à lire. Par exemple, la condition `Date != ' 2000-01-01 '` est acceptable même lorsqu'il correspond à toutes les données de la table (c'est-à-dire que l'exécution de la requête nécessite une analyse complète). Pour plus d'informations sur les plages de données dans les tables MergeTree, voir [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## force\_primary\_key {#force-primary-key} @@ -75,7 +73,7 @@ Désactive l'exécution de la requête si l'indexation par la clé primaire n'es Fonctionne avec les tables de la famille MergeTree. -Si `force_primary_key=1`, Clickhouse vérifie si la requête a une condition de clé primaire qui peut être utilisée pour restreindre les plages de données. S'il n'y a pas de condition appropriée, il lève une exception. Cependant, il ne vérifie pas si la condition réduit la quantité de données à lire. Pour plus d'informations sur les plages de données dans les tables MergeTree, voir [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +Si `force_primary_key=1`, Clickhouse vérifie si la requête a une condition de clé primaire qui peut être utilisée pour restreindre les plages de données. S'il n'y a pas de condition appropriée, il lève une exception. Cependant, il ne vérifie pas si la condition réduit la quantité de données à lire. Pour plus d'informations sur les plages de données dans les tables MergeTree, voir [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## format\_schema {#format-schema} @@ -136,7 +134,7 @@ Valeur par défaut: 0. ## max\_http\_get\_redirects {#setting-max_http_get_redirects} -Limite le nombre maximal de sauts de redirection HTTP GET pour [URL](../../engines/table_engines/special/url.md)-tables de moteur. Le paramètre s'applique aux deux types de tables: celles créées par [CREATE TABLE](../../query_language/create/#create-table-query) requête et par la [URL](../../sql_reference/table_functions/url.md) table de fonction. +Limite le nombre maximal de sauts de redirection HTTP GET pour [URL](../../engines/table-engines/special/url.md)-tables de moteur. Le paramètre s'applique aux deux types de tables: celles créées par [CREATE TABLE](../../sql-reference/statements/create.md#create-table-query) requête et par la [URL](../../sql-reference/table-functions/url.md) table de fonction. Valeurs possibles: @@ -172,7 +170,7 @@ Si les deux `input_format_allow_errors_num` et `input_format_allow_errors_ratio` ## input\_format\_values\_interpret\_expressions {#settings-input_format_values_interpret_expressions} -Active ou désactive L'analyseur SQL complet si l'analyseur de flux rapide ne peut pas analyser les données. Ce paramètre est utilisé uniquement pour la [Valeur](../../interfaces/formats.md#data-format-values) format lors de l'insertion des données. Pour plus d'informations sur l'analyse syntaxique, consultez [Syntaxe](../../sql_reference/syntax.md) section. +Active ou désactive L'analyseur SQL complet si l'analyseur de flux rapide ne peut pas analyser les données. Ce paramètre est utilisé uniquement pour la [Valeur](../../interfaces/formats.md#data-format-values) format lors de l'insertion des données. Pour plus d'informations sur l'analyse syntaxique, consultez [Syntaxe](../../sql-reference/syntax.md) section. Valeurs possibles: @@ -188,7 +186,7 @@ Valeur par défaut: 1. Exemple D'utilisation -Insérez le [DateTime](../../sql_reference/data_types/datetime.md) tapez valeur avec les différents paramètres. +Insérez le [DateTime](../../sql-reference/data-types/datetime.md) tapez valeur avec les différents paramètres. ``` sql SET input_format_values_interpret_expressions = 0; @@ -222,17 +220,24 @@ Ok. ## input\_format\_values\_deduce\_templates\_of\_expressions {#settings-input_format_values_deduce_templates_of_expressions} -Active ou désactive la déduction de modèle pour une expression SQL dans [Valeur](../../interfaces/formats.md#data-format-values) format. Il permet d'analyser et d'interpréter les expressions dans `Values` beaucoup plus rapide si les expressions dans des lignes consécutives ont la même structure. ClickHouse va essayer de déduire le modèle d'une expression, analyser les lignes suivantes en utilisant ce modèle et évaluer l'expression sur un lot de lignes analysées avec succès. Pour la requête suivante: +Active ou désactive la déduction de modèle pour les expressions SQL dans [Valeur](../../interfaces/formats.md#data-format-values) format. Il permet d'analyser et d'interpréter des expressions dans `Values` beaucoup plus rapide si les expressions dans des lignes consécutives ont la même structure. ClickHouse tente de déduire le modèle d'une expression, d'analyser les lignes suivantes à l'aide de ce modèle et d'évaluer l'expression sur un lot de lignes analysées avec succès. + +Valeurs possibles: + +- 0 — Disabled. +- 1 — Enabled. + +Valeur par défaut: 1. + +Pour la requête suivante: ``` sql INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), (upper('Values')), ... ``` -- si `input_format_values_interpret_expressions=1` et `format_values_deduce_templates_of_expressions=0` les expressions seront interprétées séparément pour chaque ligne (Ceci est très lent pour un grand nombre de lignes) -- si `input_format_values_interpret_expressions=0` et `format_values_deduce_templates_of_expressions=1` expressions dans les première, deuxième et troisième lignes seront analysées à l'aide du modèle `lower(String)` et interprété ensemble, l'expression est la quatrième ligne sera analysée avec un autre modèle (`upper(String)`) -- si `input_format_values_interpret_expressions=1` et `format_values_deduce_templates_of_expressions=1` - la même chose que dans le cas précédent, mais permet également d'interpréter les expressions séparément s'il n'est pas possible de déduire le modèle. - -Activé par défaut. +- Si `input_format_values_interpret_expressions=1` et `format_values_deduce_templates_of_expressions=0`, les expressions sont interprétées séparément pour chaque ligne (c'est très lent pour un grand nombre de lignes). +- Si `input_format_values_interpret_expressions=0` et `format_values_deduce_templates_of_expressions=1`, les expressions des première, deuxième et troisième lignes sont analysées à l'aide de template `lower(String)` et interprété ensemble, l'expression dans la quatrième ligne est analysée avec un autre modèle (`upper(String)`). +- Si `input_format_values_interpret_expressions=1` et `format_values_deduce_templates_of_expressions=1`, le même que dans le cas précédent, mais permet également d'interpréter les expressions séparément s'il n'est pas possible de déduire le modèle. ## input\_format\_values\_accurate\_types\_of\_literals {#settings-input-format-values-accurate-types-of-literals} @@ -244,9 +249,17 @@ Ce paramètre est utilisé uniquement lorsque `input_format_values_deduce_templa (..., abs(-1), ...), -- Int64 literal ``` -Lorsque ce paramètre est activé, ClickHouse vérifie le type réel de littéral et utilise un modèle d'expression du type correspondant. Dans certains cas, cela peut considérablement ralentir l'évaluation de l'expression dans `Values`. -When disabled, ClickHouse may use more general type for some literals (e.g. `Float64` ou `Int64` plutôt `UInt64` pour `42`), mais cela peut causer des problèmes de débordement et de précision. -Activé par défaut. +Valeurs possibles: + +- 0 — Disabled. + + In this case, ClickHouse may use a more general type for some literals (e.g., `Float64` ou `Int64` plutôt `UInt64` pour `42`), mais cela peut causer des problèmes de débordement et de précision. + +- 1 — Enabled. + + Dans ce cas, ClickHouse vérifie le type réel de littéral et utilise un modèle d'expression du type correspondant. Dans certains cas, cela peut considérablement ralentir l'évaluation de l'expression dans `Values`. + +Valeur par défaut: 1. ## input\_format\_defaults\_for\_omitted\_fields {#session_settings-input_format_defaults_for_omitted_fields} @@ -333,7 +346,7 @@ Valeur par défaut: 1. Permet de choisir un analyseur de la représentation textuelle de la date et de l'heure. -Le réglage ne s'applique pas à [fonctions date et heure](../../sql_reference/functions/date_time_functions.md). +Le réglage ne s'applique pas à [fonctions date et heure](../../sql-reference/functions/date-time-functions.md). Valeurs possibles: @@ -349,12 +362,12 @@ Valeur par défaut: `'basic'`. Voir aussi: -- [Type de données DateTime.](../../sql_reference/data_types/datetime.md) -- [Fonctions pour travailler avec des dates et des heures.](../../sql_reference/functions/date_time_functions.md) +- [Type de données DateTime.](../../sql-reference/data-types/datetime.md) +- [Fonctions pour travailler avec des dates et des heures.](../../sql-reference/functions/date-time-functions.md) ## join\_default\_strictness {#settings-join_default_strictness} -Définit la rigueur par défaut pour [JOIN clauses](../../sql_reference/statements/select.md#select-join). +Définit la rigueur par défaut pour [JOIN clauses](../../sql-reference/statements/select/join.md#select-join). Valeurs possibles: @@ -370,7 +383,7 @@ Valeur par défaut: `ALL`. Modifie le comportement des opérations de jointure avec `ANY` rigueur. !!! warning "Attention" - Ce paramètre s'applique uniquement pour `JOIN` opérations avec [Rejoindre](../../engines/table_engines/special/join.md) le moteur de tables. + Ce paramètre s'applique uniquement pour `JOIN` opérations avec [Rejoindre](../../engines/table-engines/special/join.md) le moteur de tables. Valeurs possibles: @@ -381,18 +394,18 @@ Valeur par défaut: 0. Voir aussi: -- [Clause de JOINTURE](../../sql_reference/statements/select.md#select-join) -- [Rejoindre le moteur de table](../../engines/table_engines/special/join.md) +- [Clause de JOINTURE](../../sql-reference/statements/select/join.md#select-join) +- [Rejoindre le moteur de table](../../engines/table-engines/special/join.md) - [join\_default\_strictness](#settings-join_default_strictness) ## join\_use\_nulls {#join_use_nulls} -Définit le type de [JOIN](../../sql_reference/statements/select.md) comportement. Lors de la fusion de tables, des cellules vides peuvent apparaître. ClickHouse les remplit différemment en fonction de ce paramètre. +Définit le type de [JOIN](../../sql-reference/statements/select/join.md) comportement. Lors de la fusion de tables, des cellules vides peuvent apparaître. ClickHouse les remplit différemment en fonction de ce paramètre. Valeurs possibles: - 0 — The empty cells are filled with the default value of the corresponding field type. -- 1 — `JOIN` se comporte de la même manière que dans SQL standard. Le type du champ correspondant est converti en [Nullable](../../sql_reference/data_types/nullable.md#data_type-nullable) et les cellules vides sont remplis avec [NULL](../../sql_reference/syntax.md). +- 1 — `JOIN` se comporte de la même manière que dans SQL standard. Le type du champ correspondant est converti en [Nullable](../../sql-reference/data-types/nullable.md#data_type-nullable) et les cellules vides sont remplis avec [NULL](../../sql-reference/syntax.md). Valeur par défaut: 0. @@ -412,7 +425,7 @@ Par défaut: 1 000 000. Cela ne fonctionne que lors de la lecture des moteurs Me ## merge\_tree\_min\_rows\_for\_concurrent\_read {#setting-merge-tree-min-rows-for-concurrent-read} -Si le nombre de lignes à lire à partir d'un fichier d'un [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) table dépasse `merge_tree_min_rows_for_concurrent_read` ensuite, ClickHouse essaie d'effectuer une lecture simultanée de ce fichier sur plusieurs threads. +Si le nombre de lignes à lire à partir d'un fichier d'un [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) table dépasse `merge_tree_min_rows_for_concurrent_read` ensuite, ClickHouse essaie d'effectuer une lecture simultanée de ce fichier sur plusieurs threads. Valeurs possibles: @@ -422,7 +435,7 @@ Valeur par défaut: 163840. ## merge\_tree\_min\_bytes\_for\_concurrent\_read {#setting-merge-tree-min-bytes-for-concurrent-read} -Si le nombre d'octets à lire à partir d'un fichier d'un [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)- table de moteur dépasse `merge_tree_min_bytes_for_concurrent_read` puis ClickHouse essaie de lire simultanément à partir de ce fichier dans plusieurs threads. +Si le nombre d'octets à lire à partir d'un fichier d'un [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)- table de moteur dépasse `merge_tree_min_bytes_for_concurrent_read` puis ClickHouse essaie de lire simultanément à partir de ce fichier dans plusieurs threads. Valeur Possible: @@ -464,7 +477,7 @@ Valeur par défaut: 8. Si ClickHouse devrait lire plus de `merge_tree_max_rows_to_use_cache` lignes dans une requête, il n'utilise pas le cache des blocs non compressés. -Le cache des blocs non compressés stocke les données extraites pour les requêtes. ClickHouse utilise ce cache pour accélérer les réponses aux petites requêtes répétées. Ce paramètre protège le cache contre le saccage par les requêtes qui lisent une grande quantité de données. Le [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) le paramètre serveur définit la taille du cache des blocs non compressés. +Le cache des blocs non compressés stocke les données extraites pour les requêtes. ClickHouse utilise ce cache pour accélérer les réponses aux petites requêtes répétées. Ce paramètre protège le cache contre le saccage par les requêtes qui lisent une grande quantité de données. Le [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) le paramètre serveur définit la taille du cache des blocs non compressés. Valeurs possibles: @@ -476,7 +489,7 @@ Default value: 128 ✕ 8192. Si ClickHouse devrait lire plus de `merge_tree_max_bytes_to_use_cache` octets dans une requête, il n'utilise pas le cache de non compressé blocs. -Le cache des blocs non compressés stocke les données extraites pour les requêtes. ClickHouse utilise ce cache pour accélérer les réponses aux petites requêtes répétées. Ce paramètre protège le cache contre le saccage par les requêtes qui lisent une grande quantité de données. Le [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) le paramètre serveur définit la taille du cache des blocs non compressés. +Le cache des blocs non compressés stocke les données extraites pour les requêtes. ClickHouse utilise ce cache pour accélérer les réponses aux petites requêtes répétées. Ce paramètre protège le cache contre le saccage par les requêtes qui lisent une grande quantité de données. Le [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) le paramètre serveur définit la taille du cache des blocs non compressés. Valeur Possible: @@ -501,7 +514,7 @@ Valeur par défaut: 0. Configuration de la journalisation des requêtes. -Les requêtes envoyées à ClickHouse avec cette configuration sont enregistrées selon les règles du [query\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-log) paramètre de configuration du serveur. +Les requêtes envoyées à ClickHouse avec cette configuration sont enregistrées selon les règles du [query\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query-log) paramètre de configuration du serveur. Exemple: @@ -509,11 +522,29 @@ Exemple: log_queries=1 ``` +## log\_queries\_min\_type {#settings-log-queries-min-type} + +`query_log` type minimal à enregistrer. + +Valeurs possibles: +- `QUERY_START` (`=1`) +- `QUERY_FINISH` (`=2`) +- `EXCEPTION_BEFORE_START` (`=3`) +- `EXCEPTION_WHILE_PROCESSING` (`=4`) + +Valeur par défaut: `QUERY_START`. + +Peut être utilisé pour limiter le nombre de entiries va va `query_log`, dites que vous êtes intéressant que dans les erreurs, alors vous pouvez utiliser `EXCEPTION_WHILE_PROCESSING`: + +``` text +log_queries_min_type='EXCEPTION_WHILE_PROCESSING' +``` + ## log\_query\_threads {#settings-log-query-threads} Configuration de la journalisation des threads de requête. -Les threads de requêtes exécutés par ClickHouse avec cette configuration sont journalisés selon les règles du [query\_thread\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) paramètre de configuration du serveur. +Les threads de requêtes exécutés par ClickHouse avec cette configuration sont journalisés selon les règles du [query\_thread\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) paramètre de configuration du serveur. Exemple: @@ -533,9 +564,31 @@ Valeur par défaut: 1 048 576 octets. La valeur par défaut est légèrement supérieure à `max_block_size`. La raison en est que certains moteurs de table (`*MergeTree`) former une partie de données sur le disque pour chaque bloc inséré, qui est une entité assez grande. Pareillement, `*MergeTree` les tables trient les données lors de l'insertion et une taille de bloc suffisamment grande permet de trier plus de données dans la RAM. +## min\_insert\_block\_size\_rows {#min-insert-block-size-rows} + +Définit le nombre minimum de lignes dans le bloc qui peut être inséré dans un tableau par un `INSERT` requête. Les blocs de plus petite taille sont écrasés en plus gros. + +Valeurs possibles: + +- Entier positif. +- 0 — Squashing disabled. + +Valeur par défaut: 1048576. + +## min\_insert\_block\_size\_bytes {#min-insert-block-size-bytes} + +Définit le nombre minimal d'octets dans le bloc qui peut être inséré dans un tableau par un `INSERT` requête. Les blocs de plus petite taille sont écrasés en plus gros. + +Valeurs possibles: + +- Entier positif. +- 0 — Squashing disabled. + +Valeur par défaut: 268435456. + ## max\_replica\_delay\_for\_distributed\_queries {#settings-max_replica_delay_for_distributed_queries} -Désactive les répliques en retard pour les requêtes distribuées. Voir [Réplication](../../engines/table_engines/mergetree_family/replication.md). +Désactive les répliques en retard pour les requêtes distribuées. Voir [Réplication](../../engines/table-engines/mergetree-family/replication.md). Définit le temps en secondes. Si une réplique accuse plus de retard que la valeur définie, cette réplique n'est pas utilisée. @@ -580,7 +633,7 @@ Ne confondez pas les blocs pour la compression (un morceau de mémoire constitu ## min\_compress\_block\_size {#min-compress-block-size} -Pour [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)" table. Afin de réduire la latence lors du traitement des requêtes, un bloc est compressé lors de l'écriture de la marque suivante si sa taille est au moins ‘min\_compress\_block\_size’. Par défaut, 65 536. +Pour [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)" table. Afin de réduire la latence lors du traitement des requêtes, un bloc est compressé lors de l'écriture de la marque suivante si sa taille est au moins ‘min\_compress\_block\_size’. Par défaut, 65 536. La taille réelle du bloc, si les données non compressées sont inférieures à ‘max\_compress\_block\_size’ pas moins de cette valeur et pas moins que le volume de données pour une marque. @@ -658,7 +711,7 @@ Pour plus d'informations, consultez la section “Extreme values”. ## use\_uncompressed\_cache {#setting-use_uncompressed_cache} Indique s'il faut utiliser un cache de blocs non compressés. Accepte 0 ou 1. Par défaut, 0 (désactivé). -L'utilisation du cache non compressé (uniquement pour les tables de la famille MergeTree) peut réduire considérablement la latence et augmenter le débit lorsque vous travaillez avec un grand nombre de requêtes courtes. Activez ce paramètre pour les utilisateurs qui envoient des requêtes courtes fréquentes. Faites également attention à la [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. +L'utilisation du cache non compressé (uniquement pour les tables de la famille MergeTree) peut réduire considérablement la latence et augmenter le débit lorsque vous travaillez avec un grand nombre de requêtes courtes. Activez ce paramètre pour les utilisateurs qui envoient des requêtes courtes fréquentes. Faites également attention à la [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. Pour les requêtes qui lisent au moins un volume de données assez important (un million de lignes ou plus), le cache non compressé est désactivé automatiquement pour économiser de l'espace pour les requêtes vraiment petites. Cela signifie que vous pouvez garder la ‘use\_uncompressed\_cache’ toujours la valeur 1. @@ -827,7 +880,7 @@ Voir aussi: - [insert\_quorum\_timeout](#settings-insert_quorum_timeout) - [select\_sequential\_consistency](#settings-select_sequential_consistency) -## insert\_quorum\_timeout {#settings-insert_quorum-timeout} +## insert\_quorum\_timeout {#settings-insert_quorum_timeout} Ecrire dans quorum timeout en secondes. Si le délai d'attente est passé et qu'aucune écriture n'a encore eu lieu, ClickHouse génère une exception et le client doit répéter la requête pour écrire le même bloc dans le même réplica ou tout autre réplica. @@ -869,7 +922,7 @@ Valeurs possibles: Valeur par défaut: 1. -Par défaut, les blocs insérés dans les tables répliquées `INSERT` déclaration sont dédupliquées (voir \[Réplication de Données\] (../moteurs/table\_engines/mergetree\_family/réplication.md). +Par défaut, les blocs insérés dans les tables répliquées `INSERT` déclaration sont dédupliquées (voir [Réplication Des Données](../../engines/table-engines/mergetree-family/replication.md)). ## déduplicate\_blocks\_in\_dependent\_materialized\_views {#settings-deduplicate-blocks-in-dependent-materialized-views} @@ -935,15 +988,15 @@ Valeur par défaut: 0. ## count\_distinct\_implementation {#settings-count_distinct_implementation} -Spécifie de l' `uniq*` les fonctions doivent être utilisées pour [COUNT(DISTINCT …)](../../sql_reference/aggregate_functions/reference.md#agg_function-count) construction. +Spécifie de l' `uniq*` les fonctions doivent être utilisées pour [COUNT(DISTINCT …)](../../sql-reference/aggregate-functions/reference.md#agg_function-count) construction. Valeurs possibles: -- [uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq) -- [uniqcombiné](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined) -- [uniqCombined64](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined64) -- [uniqHLL12](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqhll12) -- [uniqExact](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqexact) +- [uniq](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq) +- [uniqcombiné](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined) +- [uniqCombined64](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined64) +- [uniqHLL12](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqhll12) +- [uniqExact](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqexact) Valeur par défaut: `uniqExact`. @@ -1008,7 +1061,7 @@ Valeur par défaut: 0. ## optimize\_throw\_if\_noop {#setting-optimize_throw_if_noop} -Active ou désactive le lancement d'une exception si [OPTIMIZE](../../sql_reference/statements/misc.md#misc_operations-optimize) la requête n'a pas effectué de fusion. +Active ou désactive le lancement d'une exception si [OPTIMIZE](../../sql-reference/statements/misc.md#misc_operations-optimize) la requête n'a pas effectué de fusion. Par défaut, `OPTIMIZE` retourne avec succès même s'il n'a rien fait. Ce paramètre vous permet de différencier ces situations et d'obtenir la raison dans un message d'exception. @@ -1028,7 +1081,7 @@ Contrôle la vitesse à laquelle les erreurs dans les tables distribuées sont m Voir aussi: -- [Tableau moteur Distribués](../../engines/table_engines/special/distributed.md) +- [Tableau moteur Distribués](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_cap](#settings-distributed_replica_error_cap) ## distributed\_replica\_error\_cap {#settings-distributed_replica_error_cap} @@ -1040,12 +1093,12 @@ Le nombre d'erreurs de chaque réplique est plafonné à cette valeur, empêchan Voir aussi: -- [Tableau moteur Distribués](../../engines/table_engines/special/distributed.md) +- [Tableau moteur Distribués](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_half\_life](#settings-distributed_replica_error_half_life) ## distributed\_directory\_monitor\_sleep\_time\_ms {#distributed_directory_monitor_sleep_time_ms} -Intervalle de Base pour le [Distribué](../../engines/table_engines/special/distributed.md) tableau moteur à envoyer des données. L'intervalle réel augmente de façon exponentielle en cas d'erreurs. +Intervalle de Base pour le [Distribué](../../engines/table-engines/special/distributed.md) tableau moteur à envoyer des données. L'intervalle réel augmente de façon exponentielle en cas d'erreurs. Valeurs possibles: @@ -1055,7 +1108,7 @@ Valeur par défaut: 100 millisecondes. ## distributed\_directory\_monitor\_max\_sleep\_time\_ms {#distributed_directory_monitor_max_sleep_time_ms} -Intervalle maximal pour le [Distribué](../../engines/table_engines/special/distributed.md) tableau moteur à envoyer des données. Limite la croissance exponentielle de l'intervalle défini dans [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) paramètre. +Intervalle maximal pour le [Distribué](../../engines/table-engines/special/distributed.md) tableau moteur à envoyer des données. Limite la croissance exponentielle de l'intervalle défini dans [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) paramètre. Valeurs possibles: @@ -1067,7 +1120,7 @@ Valeur par défaut: 30000 millisecondes (30 secondes). Active / désactive l'envoi des données insérées par lots. -Lorsque l'envoi par lots est activé, le [Distribué](../../engines/table_engines/special/distributed.md) tableau moteur essaie d'envoyer plusieurs fichiers de données insérées dans une seule opération au lieu de les envoyer séparément. L'envoi par lots améliore les performances du cluster en utilisant mieux les ressources du serveur et du réseau. +Lorsque l'envoi par lots est activé, le [Distribué](../../engines/table-engines/special/distributed.md) tableau moteur essaie d'envoyer plusieurs fichiers de données insérées dans une seule opération au lieu de les envoyer séparément. L'envoi par lots améliore les performances du cluster en utilisant mieux les ressources du serveur et du réseau. Valeurs possibles: @@ -1093,7 +1146,7 @@ Valeur par défaut: 0. ## query\_profiler\_real\_time\_period\_ns {#query_profiler_real_time_period_ns} -Définit la période pour une horloge réelle de la [requête profiler](../../operations/optimizing_performance/sampling_query_profiler.md). La vraie minuterie d'horloge compte le temps d'horloge murale. +Définit la période pour une horloge réelle de la [requête profiler](../../operations/optimizing-performance/sampling-query-profiler.md). La vraie minuterie d'horloge compte le temps d'horloge murale. Valeurs possibles: @@ -1106,17 +1159,17 @@ Valeurs possibles: - 0 pour éteindre la minuterie. -Type: [UInt64](../../sql_reference/data_types/int_uint.md). +Type: [UInt64](../../sql-reference/data-types/int-uint.md). Valeur par défaut: 1000000000 nanosecondes (une fois par seconde). Voir aussi: -- Système de table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- Système de table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## query\_profiler\_cpu\_time\_period\_ns {#query_profiler_cpu_time_period_ns} -Définit la période pour une minuterie D'horloge CPU du [requête profiler](../../operations/optimizing_performance/sampling_query_profiler.md). Cette minuterie ne compte que le temps CPU. +Définit la période pour une minuterie D'horloge CPU du [requête profiler](../../operations/optimizing-performance/sampling-query-profiler.md). Cette minuterie ne compte que le temps CPU. Valeurs possibles: @@ -1129,17 +1182,17 @@ Valeurs possibles: - 0 pour éteindre la minuterie. -Type: [UInt64](../../sql_reference/data_types/int_uint.md). +Type: [UInt64](../../sql-reference/data-types/int-uint.md). Valeur par défaut: 1000000000 nanosecondes. Voir aussi: -- Système de table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- Système de table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## allow\_introspection\_functions {#settings-allow_introspection_functions} -Active des désactive [obscures fonctions](../../sql_reference/functions/introspection.md) pour le profilage de requête. +Active des désactive [obscures fonctions](../../sql-reference/functions/introspection.md) pour le profilage de requête. Valeurs possibles: @@ -1150,8 +1203,8 @@ Valeur par défaut: 0. **Voir Aussi** -- [Échantillonnage Du Profileur De Requête](../optimizing_performance/sampling_query_profiler.md) -- Système de table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- [Échantillonnage Du Profileur De Requête](../optimizing-performance/sampling-query-profiler.md) +- Système de table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## input\_format\_parallel\_parsing {#input-format-parallel-parsing} @@ -1199,4 +1252,14 @@ Type: URL Valeur par défaut: vide +## background\_pool\_size {#background_pool_size} + +Définit le nombre de threads effectuant des opérations d'arrière-plan dans les moteurs de table (par exemple, fusionne dans [Moteur MergeTree](../../engines/table-engines/mergetree-family/index.md) table). Ce paramètre est appliqué au démarrage du serveur ClickHouse et ne peut pas être modifié dans une session utilisateur. En ajustant ce paramètre, vous gérez la charge du processeur et du disque. Une taille de pool plus petite utilise moins de ressources CPU et disque, mais les processus d'arrière-plan avancent plus lentement, ce qui pourrait éventuellement avoir un impact sur les performances des requêtes. + +Valeurs possibles: + +- Tout nombre entier positif. + +Valeur par défaut: 16. + [Article Original](https://clickhouse.tech/docs/en/operations/settings/settings/) diff --git a/docs/fr/operations/settings/settings_profiles.md b/docs/fr/operations/settings/settings_profiles.md deleted file mode 100644 index 8a25c440d31..00000000000 --- a/docs/fr/operations/settings/settings_profiles.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 61 -toc_title: "Les Param\xE8tres Des Profils" ---- - -# Les Paramètres Des Profils {#settings-profiles} - -Un profil de paramètres est une collection de paramètres regroupés sous le même nom. Chaque utilisateur de ClickHouse a un profil. -Pour appliquer tous les paramètres d'un profil, définissez `profile` paramètre. - -Exemple: - -Installer le `web` profil. - -``` sql -SET profile = 'web' -``` - -Les profils de paramètres sont déclarés dans le fichier de configuration utilisateur. Ce n'est généralement `users.xml`. - -Exemple: - -``` xml - - - - - - 8 - - - - - 1000000000 - 100000000000 - - 1000000 - any - - 1000000 - 1000000000 - - 100000 - 100000000 - break - - 600 - 1000000 - 15 - - 25 - 100 - 50 - - 2 - 25 - 50 - 100 - - 1 - - -``` - -L'exemple spécifie deux profils: `default` et `web`. Le `default` profil a un but particulier: il doit toujours être présent et est appliquée lors du démarrage du serveur. En d'autres termes, l' `default` profil contient les paramètres par défaut. Le `web` profil est un profil régulier qui peut être défini à l'aide `SET` requête ou en utilisant un paramètre URL dans une requête HTTP. - -Paramètres les profils peuvent hériter les uns des autres. Pour utiliser l'héritage, indiquer un ou plusieurs `profile` paramètres avant les autres paramètres répertoriés dans le profil. Dans le cas où un paramètre est défini dans les différents profils, les dernières définie est utilisée. - -[Article Original](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/fr/operations/settings/settings_users.md b/docs/fr/operations/settings/settings_users.md deleted file mode 100644 index 2565f820163..00000000000 --- a/docs/fr/operations/settings/settings_users.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 63 -toc_title: "Les Param\xE8tres De L'Utilisateur" ---- - -# Les Paramètres De L'Utilisateur {#user-settings} - -Le `users` la section de la `user.xml` le fichier de configuration contient les paramètres utilisateur. - -La Structure de la `users` section: - -``` xml - - - - - - - - - - - profile_name - - default - - - - - expression - - - - - - -``` - -### nom\_utilisateur/mot de passe {#user-namepassword} - -Le mot de passe peut être spécifié en texte clair ou en SHA256 (format hexadécimal). - -- Pour attribuer un mot de passe en clair (**pas recommandé**), la placer dans un `password` élément. - - Exemple, `qwerty`. Le mot de passe peut être laissé en blanc. - - - -- Pour attribuer un mot de passe à l'aide de son hachage SHA256, placez-le dans un `password_sha256_hex` élément. - - Exemple, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. - - Exemple de génération d'un mot de passe à partir du shell: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' - - La première ligne du résultat est le mot de passe. La deuxième ligne est le hachage SHA256 correspondant. - - - -- Pour la compatibilité avec les clients MySQL, le mot de passe peut être spécifié dans le hachage double SHA1. Le placer dans `password_double_sha1_hex` élément. - - Exemple, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. - - Exemple de génération d'un mot de passe à partir du shell: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' - - La première ligne du résultat est le mot de passe. La deuxième ligne est le double hachage SHA1 correspondant. - -### nom\_utilisateur / réseaux {#user-namenetworks} - -Liste des réseaux à partir desquels L'utilisateur peut se connecter au serveur ClickHouse. - -Chaque élément de la liste peut avoir l'une des formes suivantes: - -- `` — IP address or network mask. - - Exemple: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. - -- `` — Hostname. - - Exemple: `example01.host.ru`. - - Pour vérifier l'accès, une requête DNS est effectuée et toutes les adresses IP renvoyées sont comparées à l'adresse homologue. - -- `` — Regular expression for hostnames. - - Exemple, `^example\d\d-\d\d-\d\.host\.ru$` - - Pour vérifier l'accès, un [Requête DNS PTR](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) est effectuée pour l'adresse homologue, puis l'expression rationnelle spécifiée est appliquée. Ensuite, une autre requête DNS est effectuée pour les résultats de la requête PTR et toutes les adresses reçues sont comparées à l'adresse homologue. Nous recommandons fortement que regexp se termine avec $. - -Tous les résultats des requêtes DNS sont mis en cache jusqu'au redémarrage du serveur. - -**Exemple** - -Pour ouvrir l'accès de l'utilisateur à partir de n'importe quel réseau, spécifiez: - -``` xml -::/0 -``` - -!!! warning "Avertissement" - Il n'est pas sûr d'ouvrir l'accès à partir de n'importe quel réseau, sauf si vous avez un pare-feu correctement configuré ou si le serveur n'est pas directement connecté à Internet. - -Pour ouvrir l'accès uniquement à partir de localhost, spécifier: - -``` xml -::1 -127.0.0.1 -``` - -### nom\_utilisateur / profil {#user-nameprofile} - -Vous pouvez attribuer un profil des paramètres pour l'utilisateur. Les profils de paramètres sont configurés dans une section distincte du `users.xml` fichier. Pour plus d'informations, voir [Profils des paramètres](settings_profiles.md). - -### nom\_utilisateur / quota {#user-namequota} - -Les Quotas vous permettent de suivre ou de limiter l'utilisation des ressources sur une période donnée. Les Quotas sont configurés dans le `quotas` -la section de la `users.xml` fichier de configuration. - -Vous pouvez attribuer un jeu de quotas à l'utilisateur. Pour une description détaillée de la configuration des quotas, voir [Quota](../quotas.md#quotas). - -### nom\_utilisateur/bases de données {#user-namedatabases} - -Dans cette section, vous pouvez limiter les lignes renvoyées par ClickHouse pour `SELECT` requêtes faites par l'utilisateur actuel, implémentant ainsi la sécurité de base au niveau de la ligne. - -**Exemple** - -La configuration suivante force cet utilisateur `user1` ne peut voir les lignes de `table1` comme le résultat de `SELECT` requêtes, où la valeur de la `id` le champ est 1000. - -``` xml - - - - - id = 1000 - - - - -``` - -Le `filter` peut être n'importe quelle expression résultant en un [UInt8](../../sql_reference/data_types/int_uint.md)-le type de la valeur. Il contient généralement des comparaisons et des opérateurs logiques. Les lignes de `database_name.table1` où filtrer les résultats à 0 ne sont pas retournés pour cet utilisateur. Le filtrage est incompatible avec `PREWHERE` opérations et désactive `WHERE→PREWHERE` optimisation. - -[Article Original](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/fr/operations/system-tables.md b/docs/fr/operations/system-tables.md new file mode 100644 index 00000000000..3a92eca20bb --- /dev/null +++ b/docs/fr/operations/system-tables.md @@ -0,0 +1,1168 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: "Les Tables Syst\xE8me" +--- + +# Les Tables Système {#system-tables} + +Les tables système sont utilisées pour implémenter une partie des fonctionnalités du système et pour fournir un accès à des informations sur le fonctionnement du système. +Vous ne pouvez pas supprimer une table système (mais vous pouvez effectuer un détachement). +Les tables système n'ont pas de fichiers avec des données sur le disque ou de fichiers avec des métadonnées. Le serveur crée toutes les tables système au démarrage. +Les tables système sont en lecture seule. +Ils sont situés dans la ‘system’ la base de données. + +## système.asynchronous\_metrics {#system_tables-asynchronous_metrics} + +Contient des mesures qui sont calculées périodiquement en arrière-plan. Par exemple, la quantité de RAM utilisée. + +Colonne: + +- `metric` ([Chaîne](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Float64](../sql-reference/data-types/float.md)) — Metric value. + +**Exemple** + +``` sql +SELECT * FROM system.asynchronous_metrics LIMIT 10 +``` + +``` text +┌─metric──────────────────────────────────┬──────value─┐ +│ jemalloc.background_thread.run_interval │ 0 │ +│ jemalloc.background_thread.num_runs │ 0 │ +│ jemalloc.background_thread.num_threads │ 0 │ +│ jemalloc.retained │ 422551552 │ +│ jemalloc.mapped │ 1682989056 │ +│ jemalloc.resident │ 1656446976 │ +│ jemalloc.metadata_thp │ 0 │ +│ jemalloc.metadata │ 10226856 │ +│ UncompressedCacheCells │ 0 │ +│ MarkCacheFiles │ 0 │ +└─────────────────────────────────────────┴────────────┘ +``` + +**Voir Aussi** + +- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. +- [système.métrique](#system_tables-metrics) — Contains instantly calculated metrics. +- [système.événement](#system_tables-events) — Contains a number of events that have occurred. +- [système.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. + +## système.cluster {#system-clusters} + +Contient des informations sur les clusters disponibles dans le fichier de configuration et les serveurs en eux. + +Colonne: + +- `cluster` (String) — The cluster name. +- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. +- `shard_weight` (UInt32) — The relative weight of the shard when writing data. +- `replica_num` (UInt32) — The replica number in the shard, starting from 1. +- `host_name` (String) — The host name, as specified in the config. +- `host_address` (String) — The host IP address obtained from DNS. +- `port` (UInt16) — The port to use for connecting to the server. +- `user` (String) — The name of the user for connecting to the server. +- `errors_count` (UInt32) - nombre de fois que cet hôte n'a pas atteint le réplica. +- `estimated_recovery_time` (UInt32) - secondes restantes jusqu'à ce que le nombre d'erreurs de réplique soit remis à zéro et qu'il soit considéré comme revenu à la normale. + +Veuillez noter que `errors_count` est mise à jour une fois par requête à la grappe, mais `estimated_recovery_time` est recalculé sur-demande. Il pourrait donc y avoir un cas de non-zéro `errors_count` et zéro `estimated_recovery_time`, cette requête suivante sera nulle `errors_count` et essayez d'utiliser des répliques comme si elle ne comporte pas d'erreurs. + +**Voir aussi** + +- [Tableau moteur Distribués](../engines/table-engines/special/distributed.md) +- [paramètre distributed\_replica\_error\_cap](settings/settings.md#settings-distributed_replica_error_cap) +- [paramètre distributed\_replica\_error\_half\_life](settings/settings.md#settings-distributed_replica_error_half_life) + +## système.colonne {#system-columns} + +Contient des informations sur les colonnes de toutes les tables. + +Vous pouvez utiliser ce tableau pour obtenir des informations similaires à l' [DESCRIBE TABLE](../sql-reference/statements/misc.md#misc-describe-table) requête, mais pour plusieurs tables à la fois. + +Le `system.columns` le tableau contient les colonnes suivantes (la colonne type est indiqué entre parenthèses): + +- `database` (String) — Database name. +- `table` (String) — Table name. +- `name` (String) — Column name. +- `type` (String) — Column type. +- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) pour la valeur par défaut, ou une chaîne vide si elle n'est pas définie. +- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. +- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. +- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. +- `marks_bytes` (UInt64) — The size of marks, in bytes. +- `comment` (String) — Comment on the column, or an empty string if it is not defined. +- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. +- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. +- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. +- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. + +## système.contributeur {#system-contributors} + +Contient des informations sur les donateurs. Tous les constributors dans un ordre aléatoire. L'ordre est aléatoire au moment de l'exécution de la requête. + +Colonne: + +- `name` (String) — Contributor (author) name from git log. + +**Exemple** + +``` sql +SELECT * FROM system.contributors LIMIT 10 +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +│ Max Vetrov │ +│ LiuYangkuan │ +│ svladykin │ +│ zamulla │ +│ Šimon Podlipský │ +│ BayoNet │ +│ Ilya Khomutov │ +│ Amy Krishnevsky │ +│ Loud_Scream │ +└──────────────────┘ +``` + +Trouver vous-même dans le tableau, utilisez une requête: + +``` sql +SELECT * FROM system.contributors WHERE name='Olga Khvostikova' +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +└──────────────────┘ +``` + +## système.les bases de données {#system-databases} + +Cette table contient une seule colonne de chaîne appelée ‘name’ – the name of a database. +Chaque base de données que le serveur connaît a une entrée correspondante dans la table. +Cette table système est utilisée pour implémenter `SHOW DATABASES` requête. + +## système.detached\_parts {#system_tables-detached_parts} + +Contient des informations sur les pièces détachées de [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) table. Le `reason` colonne spécifie pourquoi la pièce a été détachée. Pour les pièces détachées par l'utilisateur, la raison est vide. De telles pièces peuvent être attachées avec [ALTER TABLE ATTACH PARTITION\|PART](../sql-reference/statements/alter.md#alter_attach-partition) commande. Pour la description des autres colonnes, voir [système.partie](#system_tables-parts). Si le nom de pièce n'est pas valide, les valeurs de certaines colonnes peuvent être `NULL`. Ces pièces peuvent être supprimés avec [ALTER TABLE DROP DETACHED PART](../sql-reference/statements/alter.md#alter_drop-detached). + +## système.dictionnaire {#system_tables-dictionaries} + +Contient des informations sur [dictionnaires externes](../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +Colonne: + +- `database` ([Chaîne](../sql-reference/data-types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries. +- `name` ([Chaîne](../sql-reference/data-types/string.md)) — [Nom du dictionnaire](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md). +- `status` ([Enum8](../sql-reference/data-types/enum.md)) — Dictionary status. Possible values: + - `NOT_LOADED` — Dictionary was not loaded because it was not used. + - `LOADED` — Dictionary loaded successfully. + - `FAILED` — Unable to load the dictionary as a result of an error. + - `LOADING` — Dictionary is loading now. + - `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../sql-reference/statements/system.md#query_language-system-reload-dictionary) requête, délai d'attente, configuration du dictionnaire a changé). + - `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now. +- `origin` ([Chaîne](../sql-reference/data-types/string.md)) — Path to the configuration file that describes the dictionary. +- `type` ([Chaîne](../sql-reference/data-types/string.md)) — Type of a dictionary allocation. [Stockage des dictionnaires en mémoire](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md). +- `key` — [Type de clé](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-key): Touche Numérique ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) or Сomposite key ([Chaîne](../sql-reference/data-types/string.md)) — form “(type 1, type 2, …, type n)”. +- `attribute.names` ([Tableau](../sql-reference/data-types/array.md)([Chaîne](../sql-reference/data-types/string.md))) — Array of [les noms d'attribut](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) fournis par le dictionnaire. +- `attribute.types` ([Tableau](../sql-reference/data-types/array.md)([Chaîne](../sql-reference/data-types/string.md))) — Corresponding array of [les types d'attribut](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) qui sont fournis par le dictionnaire. +- `bytes_allocated` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary. +- `query_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot. +- `hit_rate` ([Float64](../sql-reference/data-types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache. +- `element_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of items stored in the dictionary. +- `load_factor` ([Float64](../sql-reference/data-types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). +- `source` ([Chaîne](../sql-reference/data-types/string.md)) — Text describing the [source de données](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md) pour le dictionnaire. +- `lifetime_min` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Minimum [vie](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) du dictionnaire en mémoire, après quoi ClickHouse tente de recharger le dictionnaire (si `invalidate_query` est définie, alors que si elle a changé). Réglez en quelques secondes. +- `lifetime_max` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Maximum [vie](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) du dictionnaire en mémoire, après quoi ClickHouse tente de recharger le dictionnaire (si `invalidate_query` est définie, alors que si elle a changé). Réglez en quelques secondes. +- `loading_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Start time for loading the dictionary. +- `last_successful_update_time` ([DateTime](../sql-reference/data-types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes. +- `loading_duration` ([Float32](../sql-reference/data-types/float.md)) — Duration of a dictionary loading. +- `last_exception` ([Chaîne](../sql-reference/data-types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. + +**Exemple** + +Configurez le dictionnaire. + +``` sql +CREATE DICTIONARY dictdb.dict +( + `key` Int64 DEFAULT -1, + `value_default` String DEFAULT 'world', + `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) +LIFETIME(MIN 0 MAX 1) +LAYOUT(FLAT()) +``` + +Assurez-vous que le dictionnaire est chargé. + +``` sql +SELECT * FROM system.dictionaries +``` + +``` text +┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ +│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ +└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ +``` + +## système.événement {#system_tables-events} + +Contient des informations sur le nombre d'événements survenus dans le système. Par exemple, dans le tableau, vous pouvez trouver combien `SELECT` les requêtes ont été traitées depuis le démarrage du serveur ClickHouse. + +Colonne: + +- `event` ([Chaîne](../sql-reference/data-types/string.md)) — Event name. +- `value` ([UInt64](../sql-reference/data-types/int-uint.md)) — Number of events occurred. +- `description` ([Chaîne](../sql-reference/data-types/string.md)) — Event description. + +**Exemple** + +``` sql +SELECT * FROM system.events LIMIT 5 +``` + +``` text +┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ +│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ +│ FileOpen │ 73 │ Number of files opened. │ +│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ +│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ +└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Voir Aussi** + +- [système.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [système.métrique](#system_tables-metrics) — Contains instantly calculated metrics. +- [système.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. + +## système.fonction {#system-functions} + +Contient des informations sur les fonctions normales et agrégées. + +Colonne: + +- `name`(`String`) – The name of the function. +- `is_aggregate`(`UInt8`) — Whether the function is aggregate. + +## système.graphite\_retentions {#system-graphite-retentions} + +Contient des informations sur les paramètres [graphite\_rollup](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) qui sont utilisés dans les tableaux avec [\* GraphiteMergeTree](../engines/table-engines/mergetree-family/graphitemergetree.md) moteur. + +Colonne: + +- `config_name` (Chaîne) - `graphite_rollup` nom du paramètre. +- `regexp` (Chaîne) - un modèle pour le nom de la métrique. +- `function` (Chaîne) - le nom de la fonction d'agrégation. +- `age` (UInt64) - l'âge minimum des données en secondes. +- `precision` (UInt64) - comment définir précisément l'âge des données en secondes. +- `priority` (UInt16) - priorité de motif. +- `is_default` (UInt8) - indique si le motif est la valeur par défaut. +- `Tables.database` (Array (String)) - tableau de noms de tables de base de données qui utilisent `config_name` paramètre. +- `Tables.table` (Array (String)) - tableau de noms de tables qui utilisent `config_name` paramètre. + +## système.fusionner {#system-merges} + +Contient des informations sur les fusions et les mutations de pièces actuellement en cours pour les tables de la famille MergeTree. + +Colonne: + +- `database` (String) — The name of the database the table is in. +- `table` (String) — Table name. +- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. +- `progress` (Float64) — The percentage of completed work from 0 to 1. +- `num_parts` (UInt64) — The number of pieces to be merged. +- `result_part_name` (String) — The name of the part that will be formed as the result of merging. +- `is_mutation` (UInt8) - 1 si ce processus est une mutation partielle. +- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. +- `total_size_marks` (UInt64) — The total number of marks in the merged parts. +- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. +- `rows_read` (UInt64) — Number of rows read. +- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. +- `rows_written` (UInt64) — Number of rows written. + +## système.métrique {#system_tables-metrics} + +Contient des mesures qui peuvent être calculées instantanément, ou ont une valeur actuelle. Par exemple, le nombre de requêtes traitées ou en cours réplique de retard. Ce tableau est toujours à jour. + +Colonne: + +- `metric` ([Chaîne](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Int64](../sql-reference/data-types/int-uint.md)) — Metric value. +- `description` ([Chaîne](../sql-reference/data-types/string.md)) — Metric description. + +La liste des mesures que vous pouvez trouver dans le [src / Common / CurrentMetrics.rpc](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) fichier source de ClickHouse. + +**Exemple** + +``` sql +SELECT * FROM system.metrics LIMIT 10 +``` + +``` text +┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 1 │ Number of executing queries │ +│ Merge │ 0 │ Number of executing background merges │ +│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ +│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ +│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ +│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ +│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ +│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ +│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ +│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ +└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Voir Aussi** + +- [système.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [système.événement](#system_tables-events) — Contains a number of events that occurred. +- [système.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. + +## système.metric\_log {#system_tables-metric_log} + +Contient l'historique des valeurs de métriques des tables `system.metrics` et `system.events` périodiquement vidé sur le disque. +Pour activer la collection d'historique des métriques `system.metric_log`, créer `/etc/clickhouse-server/config.d/metric_log.xml` avec le contenu suivant: + +``` xml + + + system + metric_log
+ 7500 + 1000 +
+
+``` + +**Exemple** + +``` sql +SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +event_date: 2020-02-18 +event_time: 2020-02-18 07:15:33 +milliseconds: 554 +ProfileEvent_Query: 0 +ProfileEvent_SelectQuery: 0 +ProfileEvent_InsertQuery: 0 +ProfileEvent_FileOpen: 0 +ProfileEvent_Seek: 0 +ProfileEvent_ReadBufferFromFileDescriptorRead: 1 +ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 +ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 +ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 +ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 +ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 +... +CurrentMetric_Query: 0 +CurrentMetric_Merge: 0 +CurrentMetric_PartMutation: 0 +CurrentMetric_ReplicatedFetch: 0 +CurrentMetric_ReplicatedSend: 0 +CurrentMetric_ReplicatedChecks: 0 +... +``` + +**Voir aussi** + +- [système.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [système.événement](#system_tables-events) — Contains a number of events that occurred. +- [système.métrique](#system_tables-metrics) — Contains instantly calculated metrics. +- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. + +## système.nombre {#system-numbers} + +Cette table contient une seule colonne UInt64 nommée ‘number’ qui contient presque tous les nombres naturels à partir de zéro. +Vous pouvez utiliser cette table pour les tests, ou si vous avez besoin de faire une recherche de force brute. +Les lectures de cette table ne sont pas parallélisées. + +## système.numbers\_mt {#system-numbers-mt} + +Le même que ‘system.numbers’ mais les lectures sont parallélisées. Les nombres peuvent être retournés dans n'importe quel ordre. +Utilisé pour les tests. + +## système.un {#system-one} + +Cette table contient une seule ligne avec un ‘dummy’ Colonne UInt8 contenant la valeur 0. +Cette table est utilisée si une requête SELECT ne spécifie pas la clause FROM. +Ceci est similaire à la table double trouvée dans d'autres SGBD. + +## système.partie {#system_tables-parts} + +Contient des informations sur les parties de [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) table. + +Chaque ligne décrit une partie des données. + +Colonne: + +- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql-reference/statements/alter.md#query_language_queries_alter) requête. + + Format: + + - `YYYYMM` pour le partitionnement automatique par mois. + - `any_string` lors du partitionnement manuel. + +- `name` (`String`) – Name of the data part. + +- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging. + +- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` par la granularité d'index (généralement 8192) (cet indice ne fonctionne pas pour la granularité adaptative). + +- `rows` (`UInt64`) – The number of rows. + +- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. + +- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `marks_bytes` (`UInt64`) – The size of the file with marks. + +- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| + +- `remove_time` (`DateTime`) – The time when the data part became inactive. + +- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. + +- `min_date` (`Date`) – The minimum value of the date key in the data part. + +- `max_date` (`Date`) – The maximum value of the date key in the data part. + +- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. + +- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. + +- `partition_id` (`String`) – ID of the partition. + +- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. + +- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. + +- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. + +- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). + +- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. + +- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. + +- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../sql-reference/statements/alter.md#alter_freeze-partition) + +- `database` (`String`) – Name of the database. + +- `table` (`String`) – Name of the table. + +- `engine` (`String`) – Name of the table engine without parameters. + +- `path` (`String`) – Absolute path to the folder with data part files. + +- `disk` (`String`) – Name of a disk that stores the data part. + +- `hash_of_all_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) de fichiers compressés. + +- `hash_of_uncompressed_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) de fichiers non compressés (fichiers avec des marques, fichier d'index, etc.). + +- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) des données dans les fichiers compressés comme s'ils étaient non compressé. + +- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. + +- `marks_size` (`UInt64`) – Alias for `marks_bytes`. + +## système.part\_log {#system_tables-part-log} + +Le `system.part_log` la table est créée uniquement si [part\_log](server-configuration-parameters/settings.md#server_configuration_parameters-part-log) serveur paramètre est spécifié. + +Ce tableau contient des informations sur les événements survenus avec [les parties de données](../engines/table-engines/mergetree-family/custom-partitioning-key.md) dans le [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) table de famille, telles que l'ajout ou la fusion de données. + +Le `system.part_log` le tableau contient les colonnes suivantes: + +- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: + - `NEW_PART` — Inserting of a new data part. + - `MERGE_PARTS` — Merging of data parts. + - `DOWNLOAD_PART` — Downloading a data part. + - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql-reference/statements/alter.md#alter_detach-partition). + - `MUTATE_PART` — Mutating of a data part. + - `MOVE_PART` — Moving the data part from the one disk to another one. +- `event_date` (Date) — Event date. +- `event_time` (DateTime) — Event time. +- `duration_ms` (UInt64) — Duration. +- `database` (String) — Name of the database the data part is in. +- `table` (String) — Name of the table the data part is in. +- `part_name` (String) — Name of the data part. +- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ si le partitionnement est par `tuple()`. +- `rows` (UInt64) — The number of rows in the data part. +- `size_in_bytes` (UInt64) — Size of the data part in bytes. +- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). +- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. +- `read_rows` (UInt64) — The number of rows was read during the merge. +- `read_bytes` (UInt64) — The number of bytes was read during the merge. +- `error` (UInt16) — The code number of the occurred error. +- `exception` (String) — Text message of the occurred error. + +Le `system.part_log` la table est créée après la première insertion de données `MergeTree` table. + +## système.processus {#system_tables-processes} + +Cette table système est utilisée pour implémenter `SHOW PROCESSLIST` requête. + +Colonne: + +- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` utilisateur. Le champ contient le nom d'utilisateur pour une requête spécifique, pas pour une requête que cette requête lancée. +- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` sur le serveur du demandeur de requête. +- `elapsed` (Float64) – The time in seconds since request execution started. +- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. +- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../operations/settings/query-complexity.md#settings_max_memory_usage) paramètre. +- `query` (String) – The query text. For `INSERT` il n'inclut pas les données à insérer. +- `query_id` (String) – Query ID, if defined. + +## système.text\_log {#system-tables-text-log} + +Contient des entrées de journalisation. Niveau de journalisation qui va à cette table peut être limité `text_log.level` paramètre de serveur. + +Colonne: + +- `event_date` (`Date`) - Date de l'entrée. +- `event_time` (`DateTime`) - Temps de l'entrée. +- `microseconds` (`UInt32`) - Microsecondes de l'entrée. +- `thread_name` (String) — Name of the thread from which the logging was done. +- `thread_id` (UInt64) — OS thread ID. +- `level` (`Enum8`) - Niveau d'entrée. + - `'Fatal' = 1` + - `'Critical' = 2` + - `'Error' = 3` + - `'Warning' = 4` + - `'Notice' = 5` + - `'Information' = 6` + - `'Debug' = 7` + - `'Trace' = 8` +- `query_id` (`String`)- ID de la requête. +- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) +- `message` (`String`) - Le message lui-même. +- `revision` (`UInt32`)- Révision ClickHouse. +- `source_file` (`LowCardinality(String)`)- Fichier Source à partir duquel la journalisation a été effectuée. +- `source_line` (`UInt64`)- Ligne Source à partir de laquelle la journalisation a été effectuée. + +## système.query\_log {#system_tables-query_log} + +Contient des informations sur l'exécution de requêtes. Pour chaque requête, vous pouvez voir l'Heure de début du traitement, la durée du traitement, les messages d'erreur et d'autres informations. + +!!! note "Note" + Le tableau ne contient pas les données d'entrée pour `INSERT` requête. + +Clickhouse crée cette table uniquement si [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) serveur paramètre est spécifié. Ce paramètre définit les règles de journalisation, tels que l'intervalle d'enregistrement ou le nom de la table, la requête sera connecté. + +Pour activer la journalisation des requêtes, définissez [log\_queries](settings/settings.md#settings-log-queries) paramètre 1. Pour plus de détails, voir le [Paramètre](settings/settings.md) section. + +Le `system.query_log` table enregistre deux types de requêtes: + +1. Requêtes initiales qui ont été exécutées directement par le client. +2. Requêtes enfants initiées par d'autres requêtes (pour l'exécution de requêtes distribuées). Pour ces types de requêtes, des informations sur les requêtes parentes sont affichées dans `initial_*` colonne. + +Colonne: + +- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: + - `'QueryStart' = 1` — Successful start of query execution. + - `'QueryFinish' = 2` — Successful end of query execution. + - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. + - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. +- `event_date` (Date) — Query starting date. +- `event_time` (DateTime) — Query starting time. +- `query_start_time` (DateTime) — Start time of query execution. +- `query_duration_ms` (UInt64) — Duration of query execution. +- `read_rows` (UInt64) — Number of read rows. +- `read_bytes` (UInt64) — Number of read bytes. +- `written_rows` (UInt64) — For `INSERT` des requêtes, le nombre de lignes. Pour les autres requêtes, la valeur de la colonne est 0. +- `written_bytes` (UInt64) — For `INSERT` des requêtes, le nombre d'octets écrits. Pour les autres requêtes, la valeur de la colonne est 0. +- `result_rows` (UInt64) — Number of rows in the result. +- `result_bytes` (UInt64) — Number of bytes in the result. +- `memory_usage` (UInt64) — Memory consumption by the query. +- `query` (String) — Query string. +- `exception` (String) — Exception message. +- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. +- `is_initial_query` (UInt8) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` (String) — Name of the user who initiated the current query. +- `query_id` (String) — ID of the query. +- `address` (IPv6) — IP address that was used to make the query. +- `port` (UInt16) — The client port that was used to make the query. +- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` (String) — ID of the initial query (for distributed query execution). +- `initial_address` (IPv6) — IP address that the parent query was launched from. +- `initial_port` (UInt16) — The client port that was used to make the parent query. +- `interface` (UInt8) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` (String) — OS's username who runs [clickhouse-client](../interfaces/cli.md). +- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP est exécuté. +- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) ou un autre nom de client TCP. +- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. +- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. +- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. +- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) ou une autre version du client TCP. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` la méthode a été utilisée. + - 2 — `POST` la méthode a été utilisée. +- `http_user_agent` (String) — The `UserAgent` en-tête passé dans la requête HTTP. +- `quota_key` (String) — The “quota key” spécifié dans le [quota](quotas.md) (voir `keyed`). +- `revision` (UInt32) — ClickHouse revision. +- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. +- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [système.événement](#system_tables-events) +- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` colonne. +- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` paramètre 1. +- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` colonne. + +Chaque requête crée une ou deux lignes dans le `query_log` le tableau, en fonction de l'état de la requête: + +1. Si l'exécution de la requête est réussie, deux événements de type 1 et 2 sont créés (voir `type` colonne). +2. Si une erreur s'est produite pendant le traitement de la requête, deux événements avec les types 1 et 4 sont créés. +3. Si une erreur s'est produite avant le lancement de la requête, un seul événement de type 3 est créé. + +Par défaut, les journaux sont ajoutés à la table à des intervalles de 7,5 secondes. Vous pouvez définir cet intervalle dans la [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) configuration du serveur (voir `flush_interval_milliseconds` paramètre). Pour vider les journaux de force du tampon mémoire dans la table, utilisez le `SYSTEM FLUSH LOGS` requête. + +Lorsque la table est supprimée manuellement, il sera automatiquement créé à la volée. Notez que tous les précédents journaux seront supprimés. + +!!! note "Note" + La période de stockage des journaux est illimitée. Les journaux ne sont pas automatiquement supprimés de la table. Vous devez organiser vous-même la suppression des journaux obsolètes. + +Vous pouvez spécifier une clé de partitionnement arbitraire pour `system.query_log` la table dans le [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) configuration du serveur (voir `partition_by` paramètre). + +## système.query\_thread\_log {#system_tables-query-thread-log} + +La table contient des informations sur chaque thread d'exécution de requête. + +Clickhouse crée cette table uniquement si [query\_thread\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) serveur paramètre est spécifié. Ce paramètre définit les règles de journalisation, tels que l'intervalle d'enregistrement ou le nom de la table, la requête sera connecté. + +Pour activer la journalisation des requêtes, définissez [log\_query\_threads](settings/settings.md#settings-log-query-threads) paramètre 1. Pour plus de détails, voir le [Paramètre](settings/settings.md) section. + +Colonne: + +- `event_date` (Date) — the date when the thread has finished execution of the query. +- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. +- `query_start_time` (DateTime) — Start time of query execution. +- `query_duration_ms` (UInt64) — Duration of query execution. +- `read_rows` (UInt64) — Number of read rows. +- `read_bytes` (UInt64) — Number of read bytes. +- `written_rows` (UInt64) — For `INSERT` des requêtes, le nombre de lignes. Pour les autres requêtes, la valeur de la colonne est 0. +- `written_bytes` (UInt64) — For `INSERT` des requêtes, le nombre d'octets écrits. Pour les autres requêtes, la valeur de la colonne est 0. +- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. +- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. +- `thread_name` (String) — Name of the thread. +- `thread_number` (UInt32) — Internal thread ID. +- `os_thread_id` (Int32) — OS thread ID. +- `master_thread_id` (UInt64) — OS initial ID of initial thread. +- `query` (String) — Query string. +- `is_initial_query` (UInt8) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` (String) — Name of the user who initiated the current query. +- `query_id` (String) — ID of the query. +- `address` (IPv6) — IP address that was used to make the query. +- `port` (UInt16) — The client port that was used to make the query. +- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` (String) — ID of the initial query (for distributed query execution). +- `initial_address` (IPv6) — IP address that the parent query was launched from. +- `initial_port` (UInt16) — The client port that was used to make the parent query. +- `interface` (UInt8) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` (String) — OS's username who runs [clickhouse-client](../interfaces/cli.md). +- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP est exécuté. +- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) ou un autre nom de client TCP. +- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. +- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. +- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. +- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) ou une autre version du client TCP. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` la méthode a été utilisée. + - 2 — `POST` la méthode a été utilisée. +- `http_user_agent` (String) — The `UserAgent` en-tête passé dans la requête HTTP. +- `quota_key` (String) — The “quota key” spécifié dans le [quota](quotas.md) (voir `keyed`). +- `revision` (UInt32) — ClickHouse revision. +- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [système.événement](#system_tables-events) +- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` colonne. + +Par défaut, les journaux sont ajoutés à la table à des intervalles de 7,5 secondes. Vous pouvez définir cet intervalle dans la [query\_thread\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) configuration du serveur (voir `flush_interval_milliseconds` paramètre). Pour vider les journaux de force du tampon mémoire dans la table, utilisez le `SYSTEM FLUSH LOGS` requête. + +Lorsque la table est supprimée manuellement, il sera automatiquement créé à la volée. Notez que tous les précédents journaux seront supprimés. + +!!! note "Note" + La période de stockage des journaux est illimitée. Les journaux ne sont pas automatiquement supprimés de la table. Vous devez organiser vous-même la suppression des journaux obsolètes. + +Vous pouvez spécifier une clé de partitionnement arbitraire pour `system.query_thread_log` la table dans le [query\_thread\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) configuration du serveur (voir `partition_by` paramètre). + +## système.trace\_log {#system_tables-trace_log} + +Contient des traces de pile collectées par le profileur de requête d'échantillonnage. + +Clickhouse crée cette table lorsque le [trace\_log](server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) la section de configuration du serveur est définie. Aussi l' [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) et [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) paramètres doivent être définis. + +Pour analyser les journaux, utilisez `addressToLine`, `addressToSymbol` et `demangle` fonctions d'introspection. + +Colonne: + +- `event_date` ([Date](../sql-reference/data-types/date.md)) — Date of sampling moment. + +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Timestamp of the sampling moment. + +- `timestamp_ns` ([UInt64](../sql-reference/data-types/int-uint.md)) — Timestamp of the sampling moment in nanoseconds. + +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ClickHouse server build revision. + + Lors de la connexion au serveur par `clickhouse-client`, vous voyez la chaîne similaire à `Connected to ClickHouse server version 19.18.1 revision 54429.`. Ce champ contient le `revision` mais pas le `version` d'un serveur. + +- `timer_type` ([Enum8](../sql-reference/data-types/enum.md)) — Timer type: + + - `Real` représente l'horloge murale. + - `CPU` représente le temps CPU. + +- `thread_number` ([UInt32](../sql-reference/data-types/int-uint.md)) — Thread identifier. + +- `query_id` ([Chaîne](../sql-reference/data-types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) système de table. + +- `trace` ([Tableau (UInt64)](../sql-reference/data-types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. + +**Exemple** + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-15 +event_time: 2019-11-15 15:09:38 +revision: 54428 +timer_type: Real +thread_number: 48 +query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 +trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] +``` + +## système.réplique {#system_tables-replicas} + +Contient des informations et l'état des tables répliquées résidant sur le serveur local. +Ce tableau peut être utilisé pour la surveillance. La table contient une ligne pour chaque Répliqué\* table. + +Exemple: + +``` sql +SELECT * +FROM system.replicas +WHERE table = 'visits' +FORMAT Vertical +``` + +``` text +Row 1: +────── +database: merge +table: visits +engine: ReplicatedCollapsingMergeTree +is_leader: 1 +can_become_leader: 1 +is_readonly: 0 +is_session_expired: 0 +future_parts: 1 +parts_to_check: 0 +zookeeper_path: /clickhouse/tables/01-06/visits +replica_name: example01-06-1.yandex.ru +replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru +columns_version: 9 +queue_size: 1 +inserts_in_queue: 0 +merges_in_queue: 1 +part_mutations_in_queue: 0 +queue_oldest_time: 2020-02-20 08:34:30 +inserts_oldest_time: 0000-00-00 00:00:00 +merges_oldest_time: 2020-02-20 08:34:30 +part_mutations_oldest_time: 0000-00-00 00:00:00 +oldest_part_to_get: +oldest_part_to_merge_to: 20200220_20284_20840_7 +oldest_part_to_mutate_to: +log_max_index: 596273 +log_pointer: 596274 +last_queue_update: 2020-02-20 08:34:32 +absolute_delay: 0 +total_replicas: 2 +active_replicas: 2 +``` + +Colonne: + +- `database` (`String`) - Nom de base de données +- `table` (`String`)- Nom de la Table +- `engine` (`String`)- Nom du moteur de Table +- `is_leader` (`UInt8`) - Si la réplique est le chef de file. + Une seule réplique à la fois peut être le leader. Le leader est responsable de la sélection des fusions d'arrière-plan à effectuer. + Notez que les Écritures peuvent être effectuées sur n'importe quel réplica disponible et ayant une session dans ZK, qu'il s'agisse d'un leader. +- `can_become_leader` (`UInt8`)- Si la réplique peut être élue en tant que leader. +- `is_readonly` (`UInt8`) - Si la réplique est en mode lecture seule. + Ce mode est activé si la configuration n'a pas de sections avec ZooKeeper, si une erreur inconnue s'est produite lors de la réinitialisation des sessions dans ZooKeeper et lors de la réinitialisation des sessions dans ZooKeeper. +- `is_session_expired` (`UInt8`)- la session avec ZooKeeper a expiré. Fondamentalement le même que `is_readonly`. +- `future_parts` (`UInt32`)- Le nombre de parties de données qui apparaîtront à la suite D'insertions ou de fusions qui n'ont pas encore été effectuées. +- `parts_to_check` (`UInt32`) - Le nombre de parties des données dans la file d'attente pour la vérification. Une pièce est placée dans la file d'attente de vérification s'il y a un soupçon qu'elle pourrait être endommagée. +- `zookeeper_path` (`String`)- Chemin d'accès aux données de la table dans ZooKeeper. +- `replica_name` (`String`) - Réplique nom de la Gardienne. Différentes répliques d'une même table ont des noms différents. +- `replica_path` (`String`)- Chemin vers les données de réplique dans ZooKeeper. La même chose que la concaténation ‘zookeeper\_path/replicas/replica\_path’. +- `columns_version` (`Int32`)- Numéro de Version de la structure de la table. Indique combien de fois ALTER a été effectué. Si les répliques ont des versions différentes, cela signifie que certaines répliques n'ont pas encore Toutes les modifications. +- `queue_size` (`UInt32`),- La taille de la file d'attente pour les opérations en attente d'être exécuté. Les opérations comprennent l'insertion de blocs de données, les fusions et certaines autres actions. Il coïncide généralement avec `future_parts`. +- `inserts_in_queue` (`UInt32`) - Nombre d'insertions de blocs de données qui doivent être faits. Les Insertions sont généralement répliquées assez rapidement. Si ce nombre est grand, cela signifie que quelque chose est faux. +- `merges_in_queue` (`UInt32`) - Le nombre de fusions en attente d'être fait. Parfois, les fusions sont longues, donc cette valeur peut être supérieure à zéro pendant une longue période. +- `part_mutations_in_queue` (`UInt32`) - Le nombre de mutations en attente d'être fait. +- `queue_oldest_time` (`DateTime`) - Si `queue_size` supérieur à 0, indique quand l'opération la plus ancienne a été ajoutée à la file d'attente. +- `inserts_oldest_time` (`DateTime`) - Voir `queue_oldest_time` +- `merges_oldest_time` (`DateTime`) - Voir `queue_oldest_time` +- `part_mutations_oldest_time` (`DateTime`) - Voir `queue_oldest_time` + +Les 4 colonnes suivantes ont une valeur non nulle uniquement lorsqu'il y a une session active avec ZK. + +- `log_max_index` (`UInt64`) - Maximum nombre d'entrées dans le journal de l'activité générale. +- `log_pointer` (`UInt64`)- Numéro d'entrée Maximum dans le journal de l'activité générale que le réplica a copié dans sa file d'attente d'exécution, plus un. Si `log_pointer` est beaucoup plus petite que `log_max_index` quelque chose ne va pas. +- `last_queue_update` (`DateTime`) - Lorsque la file d'attente a été mise à jour la dernière fois. +- `absolute_delay` (`UInt64`)- Combien de décalage en secondes la réplique actuelle A. +- `total_replicas` (`UInt8`) - Le nombre total de répliques connues de ce tableau. +- `active_replicas` (`UInt8`) - Le nombre de répliques de cette table qui ont une session dans ZooKeeper (c'est-à-dire le nombre de répliques fonctionnelles). + +Si vous demandez toutes les colonnes, la table peut fonctionner un peu lentement, car plusieurs lectures de ZooKeeper sont faites pour chaque ligne. +Si vous ne demandez pas les 4 dernières colonnes (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), la table fonctionne rapidement. + +Par exemple, vous pouvez vérifier que tout fonctionne correctement comme ceci: + +``` sql +SELECT + database, + table, + is_leader, + is_readonly, + is_session_expired, + future_parts, + parts_to_check, + columns_version, + queue_size, + inserts_in_queue, + merges_in_queue, + log_max_index, + log_pointer, + total_replicas, + active_replicas +FROM system.replicas +WHERE + is_readonly + OR is_session_expired + OR future_parts > 20 + OR parts_to_check > 10 + OR queue_size > 20 + OR inserts_in_queue > 10 + OR log_max_index - log_pointer > 10 + OR total_replicas < 2 + OR active_replicas < total_replicas +``` + +Si cette requête ne retourne rien, cela signifie que tout va bien. + +## système.paramètre {#system-tables-system-settings} + +Contient des informations sur les paramètres de session pour l'utilisateur actuel. + +Colonne: + +- `name` ([Chaîne](../sql-reference/data-types/string.md)) — Setting name. +- `value` ([Chaîne](../sql-reference/data-types/string.md)) — Setting value. +- `changed` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether a setting is changed from its default value. +- `description` ([Chaîne](../sql-reference/data-types/string.md)) — Short setting description. +- `min` ([Nullable](../sql-reference/data-types/nullable.md)([Chaîne](../sql-reference/data-types/string.md))) — Minimum value of the setting, if any is set via [contraintes](settings/constraints-on-settings.md#constraints-on-settings). Si le réglage n'a pas de valeur minimale, contient [NULL](../sql-reference/syntax.md#null-literal). +- `max` ([Nullable](../sql-reference/data-types/nullable.md)([Chaîne](../sql-reference/data-types/string.md))) — Maximum value of the setting, if any is set via [contraintes](settings/constraints-on-settings.md#constraints-on-settings). Si le réglage n'a pas de valeur maximale, contient [NULL](../sql-reference/syntax.md#null-literal). +- `readonly` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether the current user can change the setting: + - `0` — Current user can change the setting. + - `1` — Current user can't change the setting. + +**Exemple** + +L'exemple suivant montre comment obtenir des informations sur les paramètres dont le nom contient `min_i`. + +``` sql +SELECT * +FROM system.settings +WHERE name LIKE '%min_i%' +``` + +``` text +┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ +│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ +``` + +À l'aide de `WHERE changed` peut être utile, par exemple, lorsque vous voulez vérifier: + +- Indique si les paramètres des fichiers de configuration sont chargés correctement et sont utilisés. +- Paramètres modifiés dans la session en cours. + + + +``` sql +SELECT * FROM system.settings WHERE changed AND name='load_balancing' +``` + +**Voir aussi** + +- [Paramètre](settings/index.md#session-settings-intro) +- [Autorisations pour les requêtes](settings/permissions-for-queries.md#settings_readonly) +- [Contraintes sur les paramètres](settings/constraints-on-settings.md) + +## système.tableau\_moteurs {#system.table_engines} + +``` text +┌─name───────────────────┬─value───────┐ +│ max_threads │ 8 │ +│ use_uncompressed_cache │ 0 │ +│ load_balancing │ random │ +│ max_memory_usage │ 10000000000 │ +└────────────────────────┴─────────────┘ +``` + +## système.merge\_tree\_settings {#system-merge_tree_settings} + +Contient des informations sur les paramètres pour `MergeTree` table. + +Colonne: + +- `name` (String) — Setting name. +- `value` (String) — Setting value. +- `description` (String) — Setting description. +- `type` (String) — Setting type (implementation specific string value). +- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. + +## système.tableau\_moteurs {#system-table-engines} + +Contient une description des moteurs de table pris en charge par le serveur et leurs informations de support de fonctionnalité. + +Ce tableau contient les colonnes suivantes (le type de colonne est indiqué entre parenthèses): + +- `name` (String) — The name of table engine. +- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` clause. +- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [sauter les indices](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes). +- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). +- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` et `SAMPLE_BY`. +- `supports_replication` (UInt8) — Flag that indicates if table engine supports [réplication des données](../engines/table-engines/mergetree-family/replication.md). +- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. + +Exemple: + +``` sql +SELECT * +FROM system.table_engines +WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') +``` + +``` text +┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ +│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ +│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ +│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ +└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ +``` + +**Voir aussi** + +- Famille MergeTree [les clauses de requête](../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) +- Kafka [paramètre](../engines/table-engines/integrations/kafka.md#table_engine-kafka-creating-a-table) +- Rejoindre [paramètre](../engines/table-engines/special/join.md#join-limitations-and-settings) + +## système.table {#system-tables} + +Contient les métadonnées de chaque table que le serveur connaît. Les tableaux détachés ne sont pas représentés dans `system.tables`. + +Ce tableau contient les colonnes suivantes (le type de colonne est indiqué entre parenthèses): + +- `database` (String) — The name of the database the table is in. + +- `name` (String) — Table name. + +- `engine` (String) — Table engine name (without parameters). + +- `is_temporary` (UInt8) - indicateur qui indique si la table est temporaire. + +- `data_path` (Chaîne) - chemin d'accès aux données de la table dans le système de fichiers. + +- `metadata_path` (Chaîne) - chemin d'accès aux métadonnées de la table dans le système de fichiers. + +- `metadata_modification_time` (DateTime) - Heure de la dernière modification des métadonnées de la table. + +- `dependencies_database` (Array (String)) - dépendances de base de données. + +- `dependencies_table` (Array (String)) - dépendances de Table ([MaterializedView](../engines/table-engines/special/materializedview.md) tables basées sur le tableau actuel). + +- `create_table_query` (Chaîne) - la requête qui a été utilisée pour créer la table. + +- `engine_full` (Chaîne) - paramètres du moteur de table. + +- `partition_key` (String) - l'expression de clé de partition spécifiée dans le tableau. + +- `sorting_key` (String) - l'expression de clé de tri spécifiée dans la table. + +- `primary_key` (String) - l'expression de clé primaire spécifiée dans la table. + +- `sampling_key` (String) - l'expression de clé d'échantillonnage spécifiée dans la table. + +- `storage_policy` (String) - La politique de stockage: + + - [MergeTree](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) + - [Distribué](../engines/table-engines/special/distributed.md#distributed) + +- `total_rows` (Nullable (UInt64)) - nombre Total de lignes, s'il est possible de déterminer rapidement le nombre exact de lignes dans la table, sinon `Null` (y compris underying `Buffer` table). + +- `total_bytes` (Nullable (UInt64)) - nombre Total d'octets, s'il est possible de déterminer rapidement le nombre exact d'octets pour la table sur le stockage, sinon `Null` (**ne pas** comprend tout de stockage sous-jacent). + + - If the table stores data on disk, returns used space on disk (i.e. compressed). + - Si la table stocke des données en mémoire, renvoie un nombre approximatif d'octets utilisés en mémoire. + +Le `system.tables` le tableau est utilisé dans `SHOW TABLES` implémentation de requête. + +## système.zookeeper {#system-zookeeper} + +La table n'existe pas si ZooKeeper n'est pas configuré. Permet de lire les données du cluster Zookeeper défini dans la configuration. +La requête doit avoir un ‘path’ condition d'égalité dans la clause WHERE. C'est le chemin dans ZooKeeper pour les enfants pour lesquels vous souhaitez obtenir des données. + +Requête `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` données de sortie pour tous les enfants `/clickhouse` nœud. +Pour générer des données pour tous les nœuds racine, écrivez path = ‘/’. +Si le chemin d'accès spécifié dans ‘path’ n'existe pas, une exception sera levée. + +Colonne: + +- `name` (String) — The name of the node. +- `path` (String) — The path to the node. +- `value` (String) — Node value. +- `dataLength` (Int32) — Size of the value. +- `numChildren` (Int32) — Number of descendants. +- `czxid` (Int64) — ID of the transaction that created the node. +- `mzxid` (Int64) — ID of the transaction that last changed the node. +- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. +- `ctime` (DateTime) — Time of node creation. +- `mtime` (DateTime) — Time of the last modification of the node. +- `version` (Int32) — Node version: the number of times the node was changed. +- `cversion` (Int32) — Number of added or removed descendants. +- `aversion` (Int32) — Number of changes to the ACL. +- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. + +Exemple: + +``` sql +SELECT * +FROM system.zookeeper +WHERE path = '/clickhouse/tables/01-08/visits/replicas' +FORMAT Vertical +``` + +``` text +Row 1: +────── +name: example01-08-1.yandex.ru +value: +czxid: 932998691229 +mzxid: 932998691229 +ctime: 2015-03-27 16:49:51 +mtime: 2015-03-27 16:49:51 +version: 0 +cversion: 47 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021031383 +path: /clickhouse/tables/01-08/visits/replicas + +Row 2: +────── +name: example01-08-2.yandex.ru +value: +czxid: 933002738135 +mzxid: 933002738135 +ctime: 2015-03-27 16:57:01 +mtime: 2015-03-27 16:57:01 +version: 0 +cversion: 37 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021252247 +path: /clickhouse/tables/01-08/visits/replicas +``` + +## système.mutation {#system_tables-mutations} + +Le tableau contient des informations sur [mutation](../sql-reference/statements/alter.md#alter-mutations) des tables MergeTree et leur progression. Chaque commande de mutation est représentée par une seule ligne. Le tableau comporte les colonnes suivantes: + +**base de données**, **table** - Le nom de la base de données et de la table à laquelle la mutation a été appliquée. + +**mutation\_id** - Le numéro d'identification de la mutation. Pour les tables répliquées ces ID correspondent aux noms znode dans le `/mutations/` répertoire de la Gardienne. Pour les tables non compliquées, Les Id correspondent aux noms de fichiers dans le répertoire de données de la table. + +**commande** - La chaîne de commande mutation (la partie de la requête après `ALTER TABLE [db.]table`). + +**create\_time** - Quand cette commande de mutation a été soumise pour exécution. + +**block\_numbers.partition\_id**, **block\_numbers.nombre** - Une colonne imbriquée. Pour les mutations de tables répliquées, il contient un enregistrement pour chaque partition: l'ID de partition et le numéro de bloc acquis par la mutation (dans chaque partition, seules les parties contenant des blocs avec des nombres inférieurs au numéro de bloc acquis par la mutation dans cette partition seront mutées). Dans les tables non répliquées, les numéros de bloc de toutes les partitions forment une seule séquence. Cela signifie que pour les mutations de tables non répliquées, la colonne contiendra un enregistrement avec un seul numéro de bloc acquis par la mutation. + +**parts\_to\_do** - Le nombre de parties de données qui doivent être mutées pour que la mutation se termine. + +**\_done** - La mutation est faite? Notez que même si `parts_to_do = 0` il est possible qu'une mutation d'une table répliquée ne soit pas encore effectuée en raison d'un INSERT de longue durée qui créera une nouvelle partie de données qui devra être mutée. + +S'il y avait des problèmes avec la mutation de certaines parties, les colonnes suivantes contiennent des informations supplémentaires: + +**latest\_failed\_part** - Le nom de la partie la plus récente qui n'a pas pu être mutée. + +**latest\_fail\_time** - Le temps de la partie la plus récente mutation de l'échec. + +**latest\_fail\_reason** - Le message d'exception qui a provoqué l'échec de la mutation de pièce la plus récente. + +## système.disque {#system_tables-disks} + +Contient des informations sur les disques définis dans [configuration du serveur](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Colonne: + +- `name` ([Chaîne](../sql-reference/data-types/string.md)) — Name of a disk in the server configuration. +- `path` ([Chaîne](../sql-reference/data-types/string.md)) — Path to the mount point in the file system. +- `free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Free space on disk in bytes. +- `total_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Disk volume in bytes. +- `keep_free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` paramètre de configuration du disque. + +## système.storage\_policies {#system_tables-storage_policies} + +Contient des informations sur les stratégies de stockage et les volumes définis [configuration du serveur](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Colonne: + +- `policy_name` ([Chaîne](../sql-reference/data-types/string.md)) — Name of the storage policy. +- `volume_name` ([Chaîne](../sql-reference/data-types/string.md)) — Volume name defined in the storage policy. +- `volume_priority` ([UInt64](../sql-reference/data-types/int-uint.md)) — Volume order number in the configuration. +- `disks` ([Tableau(String)](../sql-reference/data-types/array.md)) — Disk names, defined in the storage policy. +- `max_data_part_size` ([UInt64](../sql-reference/data-types/int-uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). +- `move_factor` ([Float64](../sql-reference/data-types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. + +Si la stratégie de stockage contient plus d'un volume, les informations pour chaque volume sont stockées dans la ligne individuelle de la table. + +[Article Original](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/fr/operations/system_tables.md b/docs/fr/operations/system_tables.md deleted file mode 100644 index 99fe7e2a00e..00000000000 --- a/docs/fr/operations/system_tables.md +++ /dev/null @@ -1,1097 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_priority: 52 -toc_title: "Les Tables Syst\xE8me" ---- - -# Les Tables Système {#system-tables} - -Les tables système sont utilisées pour implémenter une partie des fonctionnalités du système et pour fournir un accès à des informations sur le fonctionnement du système. -Vous ne pouvez pas supprimer une table système (mais vous pouvez effectuer un détachement). -Les tables système n'ont pas de fichiers avec des données sur le disque ou de fichiers avec des métadonnées. Le serveur crée toutes les tables système au démarrage. -Les tables système sont en lecture seule. -Ils sont situés dans la ‘system’ la base de données. - -## système.asynchronous\_metrics {#system_tables-asynchronous_metrics} - -Contient des mesures qui sont calculées périodiquement en arrière-plan. Par exemple, la quantité de RAM utilisée. - -Colonne: - -- `metric` ([Chaîne](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Float64](../sql_reference/data_types/float.md)) — Metric value. - -**Exemple** - -``` sql -SELECT * FROM system.asynchronous_metrics LIMIT 10 -``` - -``` text -┌─metric──────────────────────────────────┬──────value─┐ -│ jemalloc.background_thread.run_interval │ 0 │ -│ jemalloc.background_thread.num_runs │ 0 │ -│ jemalloc.background_thread.num_threads │ 0 │ -│ jemalloc.retained │ 422551552 │ -│ jemalloc.mapped │ 1682989056 │ -│ jemalloc.resident │ 1656446976 │ -│ jemalloc.metadata_thp │ 0 │ -│ jemalloc.metadata │ 10226856 │ -│ UncompressedCacheCells │ 0 │ -│ MarkCacheFiles │ 0 │ -└─────────────────────────────────────────┴────────────┘ -``` - -**Voir Aussi** - -- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. -- [système.métrique](#system_tables-metrics) — Contains instantly calculated metrics. -- [système.événement](#system_tables-events) — Contains a number of events that have occurred. -- [système.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. - -## système.cluster {#system-clusters} - -Contient des informations sur les clusters disponibles dans le fichier de configuration et les serveurs en eux. - -Colonne: - -- `cluster` (String) — The cluster name. -- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. -- `shard_weight` (UInt32) — The relative weight of the shard when writing data. -- `replica_num` (UInt32) — The replica number in the shard, starting from 1. -- `host_name` (String) — The host name, as specified in the config. -- `host_address` (String) — The host IP address obtained from DNS. -- `port` (UInt16) — The port to use for connecting to the server. -- `user` (String) — The name of the user for connecting to the server. -- `errors_count` (UInt32) - nombre de fois que cet hôte n'a pas atteint le réplica. -- `estimated_recovery_time` (UInt32) - secondes restantes jusqu'à ce que le nombre d'erreurs de réplique soit remis à zéro et qu'il soit considéré comme revenu à la normale. - -Veuillez noter que `errors_count` est mise à jour une fois par requête à la grappe, mais `estimated_recovery_time` est recalculé sur-demande. Il pourrait donc y avoir un cas de non-zéro `errors_count` et zéro `estimated_recovery_time`, cette requête suivante sera nulle `errors_count` et essayez d'utiliser des répliques comme si elle ne comporte pas d'erreurs. - -**Voir aussi** - -- [Tableau moteur Distribués](../engines/table_engines/special/distributed.md) -- [paramètre distributed\_replica\_error\_cap](settings/settings.md#settings-distributed_replica_error_cap) -- [paramètre distributed\_replica\_error\_half\_life](settings/settings.md#settings-distributed_replica_error_half_life) - -## système.colonne {#system-columns} - -Contient des informations sur les colonnes de toutes les tables. - -Vous pouvez utiliser ce tableau pour obtenir des informations similaires à l' [DESCRIBE TABLE](../sql_reference/statements/misc.md#misc-describe-table) requête, mais pour plusieurs tables à la fois. - -Le `system.columns` le tableau contient les colonnes suivantes (la colonne type est indiqué entre parenthèses): - -- `database` (String) — Database name. -- `table` (String) — Table name. -- `name` (String) — Column name. -- `type` (String) — Column type. -- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) pour la valeur par défaut, ou une chaîne vide si elle n'est pas définie. -- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. -- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. -- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. -- `marks_bytes` (UInt64) — The size of marks, in bytes. -- `comment` (String) — Comment on the column, or an empty string if it is not defined. -- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. -- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. -- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. -- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. - -## système.contributeur {#system-contributors} - -Contient des informations sur les donateurs. Tous les constributors dans un ordre aléatoire. L'ordre est aléatoire au moment de l'exécution de la requête. - -Colonne: - -- `name` (String) — Contributor (author) name from git log. - -**Exemple** - -``` sql -SELECT * FROM system.contributors LIMIT 10 -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -│ Max Vetrov │ -│ LiuYangkuan │ -│ svladykin │ -│ zamulla │ -│ Šimon Podlipský │ -│ BayoNet │ -│ Ilya Khomutov │ -│ Amy Krishnevsky │ -│ Loud_Scream │ -└──────────────────┘ -``` - -Trouver vous-même dans le tableau, utilisez une requête: - -``` sql -SELECT * FROM system.contributors WHERE name='Olga Khvostikova' -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -└──────────────────┘ -``` - -## système.les bases de données {#system-databases} - -Cette table contient une seule colonne de chaîne appelée ‘name’ – the name of a database. -Chaque base de données que le serveur connaît a une entrée correspondante dans la table. -Cette table système est utilisée pour implémenter `SHOW DATABASES` requête. - -## système.detached\_parts {#system_tables-detached_parts} - -Contient des informations sur les pièces détachées de [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) table. Le `reason` colonne spécifie pourquoi la pièce a été détachée. Pour les pièces détachées par l'utilisateur, la raison est vide. De telles pièces peuvent être attachées avec [ALTER TABLE ATTACH PARTITION\|PART](../query_language/query_language/alter/#alter_attach-partition) commande. Pour la description des autres colonnes, voir [système.partie](#system_tables-parts). Si le nom de pièce n'est pas valide, les valeurs de certaines colonnes peuvent être `NULL`. Ces pièces peuvent être supprimés avec [ALTER TABLE DROP DETACHED PART](../query_language/query_language/alter/#alter_drop-detached). - -## système.dictionnaire {#system-dictionaries} - -Contient des informations sur les dictionnaires externes. - -Colonne: - -- `name` (String) — Dictionary name. -- `type` (String) — Dictionary type: Flat, Hashed, Cache. -- `origin` (String) — Path to the configuration file that describes the dictionary. -- `attribute.names` (Array(String)) — Array of attribute names provided by the dictionary. -- `attribute.types` (Array(String)) — Corresponding array of attribute types that are provided by the dictionary. -- `has_hierarchy` (UInt8) — Whether the dictionary is hierarchical. -- `bytes_allocated` (UInt64) — The amount of RAM the dictionary uses. -- `hit_rate` (Float64) — For cache dictionaries, the percentage of uses for which the value was in the cache. -- `element_count` (UInt64) — The number of items stored in the dictionary. -- `load_factor` (Float64) — The percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). -- `creation_time` (DateTime) — The time when the dictionary was created or last successfully reloaded. -- `last_exception` (String) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. -- `source` (String) — Text describing the data source for the dictionary. - -Notez que la quantité de mémoire utilisée par le dictionnaire n'est pas proportionnel au nombre d'articles qui s'y trouvent. Ainsi, pour les dictionnaires plats et mis en cache, toutes les cellules de mémoire sont pré-assignées, quelle que soit la capacité du dictionnaire. - -## système.événement {#system_tables-events} - -Contient des informations sur le nombre d'événements survenus dans le système. Par exemple, dans le tableau, vous pouvez trouver combien `SELECT` les requêtes ont été traitées depuis le démarrage du serveur ClickHouse. - -Colonne: - -- `event` ([Chaîne](../sql_reference/data_types/string.md)) — Event name. -- `value` ([UInt64](../sql_reference/data_types/int_uint.md)) — Number of events occurred. -- `description` ([Chaîne](../sql_reference/data_types/string.md)) — Event description. - -**Exemple** - -``` sql -SELECT * FROM system.events LIMIT 5 -``` - -``` text -┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ -│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ -│ FileOpen │ 73 │ Number of files opened. │ -│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ -│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ -└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Voir Aussi** - -- [système.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [système.métrique](#system_tables-metrics) — Contains instantly calculated metrics. -- [système.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. - -## système.fonction {#system-functions} - -Contient des informations sur les fonctions normales et agrégées. - -Colonne: - -- `name`(`String`) – The name of the function. -- `is_aggregate`(`UInt8`) — Whether the function is aggregate. - -## système.graphite\_retentions {#system-graphite-retentions} - -Contient des informations sur les paramètres [graphite\_rollup](server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) qui sont utilisés dans les tableaux avec [\* GraphiteMergeTree](../engines/table_engines/mergetree_family/graphitemergetree.md) moteur. - -Colonne: - -- `config_name` (Chaîne) - `graphite_rollup` nom du paramètre. -- `regexp` (Chaîne) - un modèle pour le nom de la métrique. -- `function` (Chaîne) - le nom de la fonction d'agrégation. -- `age` (UInt64) - l'âge minimum des données en secondes. -- `precision` (UInt64) - comment définir précisément l'âge des données en secondes. -- `priority` (UInt16) - priorité de motif. -- `is_default` (UInt8) - indique si le motif est la valeur par défaut. -- `Tables.database` (Array (String)) - tableau de noms de tables de base de données qui utilisent `config_name` paramètre. -- `Tables.table` (Array (String)) - tableau de noms de tables qui utilisent `config_name` paramètre. - -## système.fusionner {#system-merges} - -Contient des informations sur les fusions et les mutations de pièces actuellement en cours pour les tables de la famille MergeTree. - -Colonne: - -- `database` (String) — The name of the database the table is in. -- `table` (String) — Table name. -- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. -- `progress` (Float64) — The percentage of completed work from 0 to 1. -- `num_parts` (UInt64) — The number of pieces to be merged. -- `result_part_name` (String) — The name of the part that will be formed as the result of merging. -- `is_mutation` (UInt8) - 1 si ce processus est une mutation partielle. -- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. -- `total_size_marks` (UInt64) — The total number of marks in the merged parts. -- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. -- `rows_read` (UInt64) — Number of rows read. -- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. -- `rows_written` (UInt64) — Number of rows written. - -## système.métrique {#system_tables-metrics} - -Contient des mesures qui peuvent être calculées instantanément, ou ont une valeur actuelle. Par exemple, le nombre de requêtes traitées ou en cours réplique de retard. Ce tableau est toujours à jour. - -Colonne: - -- `metric` ([Chaîne](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Int64](../sql_reference/data_types/int_uint.md)) — Metric value. -- `description` ([Chaîne](../sql_reference/data_types/string.md)) — Metric description. - -La liste des mesures que vous pouvez trouver dans le [SGBD / commun / CurrentMetrics.rpc](https://github.com/ClickHouse/ClickHouse/blob/master/dbms/Common/CurrentMetrics.cpp) fichier source de ClickHouse. - -**Exemple** - -``` sql -SELECT * FROM system.metrics LIMIT 10 -``` - -``` text -┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 1 │ Number of executing queries │ -│ Merge │ 0 │ Number of executing background merges │ -│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ -│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ -│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ -│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ -│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ -│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ -│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ -│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ -└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Voir Aussi** - -- [système.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [système.événement](#system_tables-events) — Contains a number of events that occurred. -- [système.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. - -## système.metric\_log {#system_tables-metric_log} - -Contient l'historique des valeurs de métriques des tables `system.metrics` et `system.events` périodiquement vidé sur le disque. -Pour activer la collection d'historique des métriques `system.metric_log`, créer `/etc/clickhouse-server/config.d/metric_log.xml` avec le contenu suivant: - -``` xml - - - system - metric_log
- 7500 - 1000 -
-
-``` - -**Exemple** - -``` sql -SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; -``` - -``` text -Row 1: -────── -event_date: 2020-02-18 -event_time: 2020-02-18 07:15:33 -milliseconds: 554 -ProfileEvent_Query: 0 -ProfileEvent_SelectQuery: 0 -ProfileEvent_InsertQuery: 0 -ProfileEvent_FileOpen: 0 -ProfileEvent_Seek: 0 -ProfileEvent_ReadBufferFromFileDescriptorRead: 1 -ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 -ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 -ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 -ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 -ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 -... -CurrentMetric_Query: 0 -CurrentMetric_Merge: 0 -CurrentMetric_PartMutation: 0 -CurrentMetric_ReplicatedFetch: 0 -CurrentMetric_ReplicatedSend: 0 -CurrentMetric_ReplicatedChecks: 0 -... -``` - -**Voir aussi** - -- [système.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [système.événement](#system_tables-events) — Contains a number of events that occurred. -- [système.métrique](#system_tables-metrics) — Contains instantly calculated metrics. -- [Surveiller](monitoring.md) — Base concepts of ClickHouse monitoring. - -## système.nombre {#system-numbers} - -Cette table contient une seule colonne UInt64 nommée ‘number’ qui contient presque tous les nombres naturels à partir de zéro. -Vous pouvez utiliser cette table pour les tests, ou si vous avez besoin de faire une recherche de force brute. -Les lectures de cette table ne sont pas parallélisées. - -## système.numbers\_mt {#system-numbers-mt} - -Le même que ‘system.numbers’ mais les lectures sont parallélisées. Les nombres peuvent être retournés dans n'importe quel ordre. -Utilisé pour les tests. - -## système.un {#system-one} - -Cette table contient une seule ligne avec un ‘dummy’ Colonne UInt8 contenant la valeur 0. -Cette table est utilisée si une requête SELECT ne spécifie pas la clause FROM. -Ceci est similaire à la table double trouvée dans d'autres SGBD. - -## système.partie {#system_tables-parts} - -Contient des informations sur les parties de [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) table. - -Chaque ligne décrit une partie des données. - -Colonne: - -- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql_reference/statements/alter.md#query_language_queries_alter) requête. - - Format: - - - `YYYYMM` pour le partitionnement automatique par mois. - - `any_string` lors du partitionnement manuel. - -- `name` (`String`) – Name of the data part. - -- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging. - -- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` par la granularité d'index (généralement 8192) (cet indice ne fonctionne pas pour la granularité adaptative). - -- `rows` (`UInt64`) – The number of rows. - -- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. - -- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `marks_bytes` (`UInt64`) – The size of the file with marks. - -- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| - -- `remove_time` (`DateTime`) – The time when the data part became inactive. - -- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. - -- `min_date` (`Date`) – The minimum value of the date key in the data part. - -- `max_date` (`Date`) – The maximum value of the date key in the data part. - -- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. - -- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. - -- `partition_id` (`String`) – ID of the partition. - -- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. - -- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. - -- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. - -- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). - -- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. - -- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. - -- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../sql_reference/statements/alter.md#alter_freeze-partition) - -- `database` (`String`) – Name of the database. - -- `table` (`String`) – Name of the table. - -- `engine` (`String`) – Name of the table engine without parameters. - -- `path` (`String`) – Absolute path to the folder with data part files. - -- `disk` (`String`) – Name of a disk that stores the data part. - -- `hash_of_all_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) de fichiers compressés. - -- `hash_of_uncompressed_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) de fichiers non compressés (fichiers avec des marques, fichier d'index, etc.). - -- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) des données dans les fichiers compressés comme s'ils étaient non compressé. - -- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. - -- `marks_size` (`UInt64`) – Alias for `marks_bytes`. - -## système.part\_log {#system_tables-part-log} - -Le `system.part_log` la table est créée uniquement si [part\_log](server_configuration_parameters/settings.md#server_configuration_parameters-part-log) serveur paramètre est spécifié. - -Ce tableau contient des informations sur les événements survenus avec [les parties de données](../engines/table_engines/mergetree_family/custom_partitioning_key.md) dans le [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) table de famille, telles que l'ajout ou la fusion de données. - -Le `system.part_log` le tableau contient les colonnes suivantes: - -- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: - - `NEW_PART` — Inserting of a new data part. - - `MERGE_PARTS` — Merging of data parts. - - `DOWNLOAD_PART` — Downloading a data part. - - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql_reference/statements/alter.md#alter_detach-partition). - - `MUTATE_PART` — Mutating of a data part. - - `MOVE_PART` — Moving the data part from the one disk to another one. -- `event_date` (Date) — Event date. -- `event_time` (DateTime) — Event time. -- `duration_ms` (UInt64) — Duration. -- `database` (String) — Name of the database the data part is in. -- `table` (String) — Name of the table the data part is in. -- `part_name` (String) — Name of the data part. -- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ si le partitionnement est par `tuple()`. -- `rows` (UInt64) — The number of rows in the data part. -- `size_in_bytes` (UInt64) — Size of the data part in bytes. -- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). -- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. -- `read_rows` (UInt64) — The number of rows was read during the merge. -- `read_bytes` (UInt64) — The number of bytes was read during the merge. -- `error` (UInt16) — The code number of the occurred error. -- `exception` (String) — Text message of the occurred error. - -Le `system.part_log` la table est créée après la première insertion de données `MergeTree` table. - -## système.processus {#system_tables-processes} - -Cette table système est utilisée pour implémenter `SHOW PROCESSLIST` requête. - -Colonne: - -- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` utilisateur. Le champ contient le nom d'utilisateur pour une requête spécifique, pas pour une requête que cette requête lancée. -- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` sur le serveur du demandeur de requête. -- `elapsed` (Float64) – The time in seconds since request execution started. -- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. -- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../operations/settings/query_complexity.md#settings_max_memory_usage) paramètre. -- `query` (String) – The query text. For `INSERT` il n'inclut pas les données à insérer. -- `query_id` (String) – Query ID, if defined. - -## système.text\_log {#system-tables-text-log} - -Contient des entrées de journalisation. Niveau de journalisation qui va à cette table peut être limité `text_log.level` paramètre de serveur. - -Colonne: - -- `event_date` (`Date`) - Date de l'entrée. -- `event_time` (`DateTime`) - Temps de l'entrée. -- `microseconds` (`UInt32`) - Microsecondes de l'entrée. -- `thread_name` (String) — Name of the thread from which the logging was done. -- `thread_id` (UInt64) — OS thread ID. -- `level` (`Enum8`) - Niveau d'entrée. - - `'Fatal' = 1` - - `'Critical' = 2` - - `'Error' = 3` - - `'Warning' = 4` - - `'Notice' = 5` - - `'Information' = 6` - - `'Debug' = 7` - - `'Trace' = 8` -- `query_id` (`String`)- ID de la requête. -- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) -- `message` (`String`) - Le message lui-même. -- `revision` (`UInt32`)- Révision ClickHouse. -- `source_file` (`LowCardinality(String)`)- Fichier Source à partir duquel la journalisation a été effectuée. -- `source_line` (`UInt64`)- Ligne Source à partir de laquelle la journalisation a été effectuée. - -## système.query\_log {#system_tables-query_log} - -Contient des informations sur l'exécution de requêtes. Pour chaque requête, vous pouvez voir l'Heure de début du traitement, la durée du traitement, les messages d'erreur et d'autres informations. - -!!! note "Note" - Le tableau ne contient pas les données d'entrée pour `INSERT` requête. - -Clickhouse crée cette table uniquement si [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) serveur paramètre est spécifié. Ce paramètre définit les règles de journalisation, tels que l'intervalle d'enregistrement ou le nom de la table, la requête sera connecté. - -Pour activer la journalisation des requêtes, définissez [log\_queries](settings/settings.md#settings-log-queries) paramètre 1. Pour plus de détails, voir le [Paramètre](settings/settings.md) section. - -Le `system.query_log` table enregistre deux types de requêtes: - -1. Requêtes initiales qui ont été exécutées directement par le client. -2. Requêtes enfants initiées par d'autres requêtes (pour l'exécution de requêtes distribuées). Pour ces types de requêtes, des informations sur les requêtes parentes sont affichées dans `initial_*` colonne. - -Colonne: - -- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: - - `'QueryStart' = 1` — Successful start of query execution. - - `'QueryFinish' = 2` — Successful end of query execution. - - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. - - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. -- `event_date` (Date) — Query starting date. -- `event_time` (DateTime) — Query starting time. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` des requêtes, le nombre de lignes. Pour les autres requêtes, la valeur de la colonne est 0. -- `written_bytes` (UInt64) — For `INSERT` des requêtes, le nombre d'octets écrits. Pour les autres requêtes, la valeur de la colonne est 0. -- `result_rows` (UInt64) — Number of rows in the result. -- `result_bytes` (UInt64) — Number of bytes in the result. -- `memory_usage` (UInt64) — Memory consumption by the query. -- `query` (String) — Query string. -- `exception` (String) — Exception message. -- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS's username who runs [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP est exécuté. -- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) ou un autre nom de client TCP. -- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. -- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) ou une autre version du client TCP. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` la méthode a été utilisée. - - 2 — `POST` la méthode a été utilisée. -- `http_user_agent` (String) — The `UserAgent` en-tête passé dans la requête HTTP. -- `quota_key` (String) — The “quota key” spécifié dans le [quota](quotas.md) (voir `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [système.événement](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` colonne. -- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` paramètre 1. -- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` colonne. - -Chaque requête crée une ou deux lignes dans le `query_log` le tableau, en fonction de l'état de la requête: - -1. Si l'exécution de la requête est réussie, deux événements de type 1 et 2 sont créés (voir `type` colonne). -2. Si une erreur s'est produite pendant le traitement de la requête, deux événements avec les types 1 et 4 sont créés. -3. Si une erreur s'est produite avant le lancement de la requête, un seul événement de type 3 est créé. - -Par défaut, les journaux sont ajoutés à la table à des intervalles de 7,5 secondes. Vous pouvez définir cet intervalle dans la [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) configuration du serveur (voir `flush_interval_milliseconds` paramètre). Pour vider les journaux de force du tampon mémoire dans la table, utilisez le `SYSTEM FLUSH LOGS` requête. - -Lorsque la table est supprimée manuellement, il sera automatiquement créé à la volée. Notez que tous les précédents journaux seront supprimés. - -!!! note "Note" - La période de stockage des journaux est illimitée. Les journaux ne sont pas automatiquement supprimés de la table. Vous devez organiser vous-même la suppression des journaux obsolètes. - -Vous pouvez spécifier une clé de partitionnement arbitraire pour `system.query_log` la table dans le [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) configuration du serveur (voir `partition_by` paramètre). - -## système.query\_thread\_log {#system_tables-query-thread-log} - -La table contient des informations sur chaque thread d'exécution de requête. - -Clickhouse crée cette table uniquement si [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) serveur paramètre est spécifié. Ce paramètre définit les règles de journalisation, tels que l'intervalle d'enregistrement ou le nom de la table, la requête sera connecté. - -Pour activer la journalisation des requêtes, définissez [log\_query\_threads](settings/settings.md#settings-log-query-threads) paramètre 1. Pour plus de détails, voir le [Paramètre](settings/settings.md) section. - -Colonne: - -- `event_date` (Date) — the date when the thread has finished execution of the query. -- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` des requêtes, le nombre de lignes. Pour les autres requêtes, la valeur de la colonne est 0. -- `written_bytes` (UInt64) — For `INSERT` des requêtes, le nombre d'octets écrits. Pour les autres requêtes, la valeur de la colonne est 0. -- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. -- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. -- `thread_name` (String) — Name of the thread. -- `thread_number` (UInt32) — Internal thread ID. -- `os_thread_id` (Int32) — OS thread ID. -- `master_thread_id` (UInt64) — OS initial ID of initial thread. -- `query` (String) — Query string. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS's username who runs [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP est exécuté. -- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) ou un autre nom de client TCP. -- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. -- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) ou un autre client TCP. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) ou une autre version du client TCP. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` la méthode a été utilisée. - - 2 — `POST` la méthode a été utilisée. -- `http_user_agent` (String) — The `UserAgent` en-tête passé dans la requête HTTP. -- `quota_key` (String) — The “quota key” spécifié dans le [quota](quotas.md) (voir `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [système.événement](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` colonne. - -Par défaut, les journaux sont ajoutés à la table à des intervalles de 7,5 secondes. Vous pouvez définir cet intervalle dans la [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) configuration du serveur (voir `flush_interval_milliseconds` paramètre). Pour vider les journaux de force du tampon mémoire dans la table, utilisez le `SYSTEM FLUSH LOGS` requête. - -Lorsque la table est supprimée manuellement, il sera automatiquement créé à la volée. Notez que tous les précédents journaux seront supprimés. - -!!! note "Note" - La période de stockage des journaux est illimitée. Les journaux ne sont pas automatiquement supprimés de la table. Vous devez organiser vous-même la suppression des journaux obsolètes. - -Vous pouvez spécifier une clé de partitionnement arbitraire pour `system.query_thread_log` la table dans le [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) configuration du serveur (voir `partition_by` paramètre). - -## système.trace\_log {#system_tables-trace_log} - -Contient des traces de pile collectées par le profileur de requête d'échantillonnage. - -Clickhouse crée cette table lorsque le [trace\_log](server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) la section de configuration du serveur est définie. Aussi l' [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) et [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) paramètres doivent être définis. - -Pour analyser les journaux, utilisez `addressToLine`, `addressToSymbol` et `demangle` fonctions d'introspection. - -Colonne: - -- `event_date`([Date](../sql_reference/data_types/date.md)) — Date of sampling moment. - -- `event_time`([DateTime](../sql_reference/data_types/datetime.md)) — Timestamp of sampling moment. - -- `revision`([UInt32](../sql_reference/data_types/int_uint.md)) — ClickHouse server build revision. - - Lors de la connexion au serveur par `clickhouse-client`, vous voyez la chaîne similaire à `Connected to ClickHouse server version 19.18.1 revision 54429.`. Ce champ contient le `revision` mais pas le `version` d'un serveur. - -- `timer_type`([Enum8](../sql_reference/data_types/enum.md)) — Timer type: - - - `Real` représente l'horloge murale. - - `CPU` représente le temps CPU. - -- `thread_number`([UInt32](../sql_reference/data_types/int_uint.md)) — Thread identifier. - -- `query_id`([Chaîne](../sql_reference/data_types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) système de table. - -- `trace`([Tableau (UInt64)](../sql_reference/data_types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. - -**Exemple** - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-15 -event_time: 2019-11-15 15:09:38 -revision: 54428 -timer_type: Real -thread_number: 48 -query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 -trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] -``` - -## système.réplique {#system_tables-replicas} - -Contient des informations et l'état des tables répliquées résidant sur le serveur local. -Ce tableau peut être utilisé pour la surveillance. La table contient une ligne pour chaque Répliqué\* table. - -Exemple: - -``` sql -SELECT * -FROM system.replicas -WHERE table = 'visits' -FORMAT Vertical -``` - -``` text -Row 1: -────── -database: merge -table: visits -engine: ReplicatedCollapsingMergeTree -is_leader: 1 -can_become_leader: 1 -is_readonly: 0 -is_session_expired: 0 -future_parts: 1 -parts_to_check: 0 -zookeeper_path: /clickhouse/tables/01-06/visits -replica_name: example01-06-1.yandex.ru -replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru -columns_version: 9 -queue_size: 1 -inserts_in_queue: 0 -merges_in_queue: 1 -part_mutations_in_queue: 0 -queue_oldest_time: 2020-02-20 08:34:30 -inserts_oldest_time: 0000-00-00 00:00:00 -merges_oldest_time: 2020-02-20 08:34:30 -part_mutations_oldest_time: 0000-00-00 00:00:00 -oldest_part_to_get: -oldest_part_to_merge_to: 20200220_20284_20840_7 -oldest_part_to_mutate_to: -log_max_index: 596273 -log_pointer: 596274 -last_queue_update: 2020-02-20 08:34:32 -absolute_delay: 0 -total_replicas: 2 -active_replicas: 2 -``` - -Colonne: - -- `database` (`String`) - Nom de base de données -- `table` (`String`)- Nom de la Table -- `engine` (`String`)- Nom du moteur de Table -- `is_leader` (`UInt8`) - Si la réplique est le chef de file. - Une seule réplique à la fois peut être le leader. Le leader est responsable de la sélection des fusions d'arrière-plan à effectuer. - Notez que les Écritures peuvent être effectuées sur n'importe quel réplica disponible et ayant une session dans ZK, qu'il s'agisse d'un leader. -- `can_become_leader` (`UInt8`)- Si la réplique peut être élue en tant que leader. -- `is_readonly` (`UInt8`) - Si la réplique est en mode lecture seule. - Ce mode est activé si la configuration n'a pas de sections avec ZooKeeper, si une erreur inconnue s'est produite lors de la réinitialisation des sessions dans ZooKeeper et lors de la réinitialisation des sessions dans ZooKeeper. -- `is_session_expired` (`UInt8`)- la session avec ZooKeeper a expiré. Fondamentalement le même que `is_readonly`. -- `future_parts` (`UInt32`)- Le nombre de parties de données qui apparaîtront à la suite D'insertions ou de fusions qui n'ont pas encore été effectuées. -- `parts_to_check` (`UInt32`) - Le nombre de parties des données dans la file d'attente pour la vérification. Une pièce est placée dans la file d'attente de vérification s'il y a un soupçon qu'elle pourrait être endommagée. -- `zookeeper_path` (`String`)- Chemin d'accès aux données de la table dans ZooKeeper. -- `replica_name` (`String`) - Réplique nom de la Gardienne. Différentes répliques d'une même table ont des noms différents. -- `replica_path` (`String`)- Chemin vers les données de réplique dans ZooKeeper. La même chose que la concaténation ‘zookeeper\_path/replicas/replica\_path’. -- `columns_version` (`Int32`)- Numéro de Version de la structure de la table. Indique combien de fois ALTER a été effectué. Si les répliques ont des versions différentes, cela signifie que certaines répliques n'ont pas encore Toutes les modifications. -- `queue_size` (`UInt32`),- La taille de la file d'attente pour les opérations en attente d'être exécuté. Les opérations comprennent l'insertion de blocs de données, les fusions et certaines autres actions. Il coïncide généralement avec `future_parts`. -- `inserts_in_queue` (`UInt32`) - Nombre d'insertions de blocs de données qui doivent être faits. Les Insertions sont généralement répliquées assez rapidement. Si ce nombre est grand, cela signifie que quelque chose est faux. -- `merges_in_queue` (`UInt32`) - Le nombre de fusions en attente d'être fait. Parfois, les fusions sont longues, donc cette valeur peut être supérieure à zéro pendant une longue période. -- `part_mutations_in_queue` (`UInt32`) - Le nombre de mutations en attente d'être fait. -- `queue_oldest_time` (`DateTime`) - Si `queue_size` supérieur à 0, indique quand l'opération la plus ancienne a été ajoutée à la file d'attente. -- `inserts_oldest_time` (`DateTime`) - Voir `queue_oldest_time` -- `merges_oldest_time` (`DateTime`) - Voir `queue_oldest_time` -- `part_mutations_oldest_time` (`DateTime`) - Voir `queue_oldest_time` - -Les 4 colonnes suivantes ont une valeur non nulle uniquement lorsqu'il y a une session active avec ZK. - -- `log_max_index` (`UInt64`) - Maximum nombre d'entrées dans le journal de l'activité générale. -- `log_pointer` (`UInt64`)- Numéro d'entrée Maximum dans le journal de l'activité générale que le réplica a copié dans sa file d'attente d'exécution, plus un. Si `log_pointer` est beaucoup plus petite que `log_max_index` quelque chose ne va pas. -- `last_queue_update` (`DateTime`) - Lorsque la file d'attente a été mise à jour la dernière fois. -- `absolute_delay` (`UInt64`)- Combien de décalage en secondes la réplique actuelle A. -- `total_replicas` (`UInt8`) - Le nombre total de répliques connues de ce tableau. -- `active_replicas` (`UInt8`) - Le nombre de répliques de cette table qui ont une session dans ZooKeeper (c'est-à-dire le nombre de répliques fonctionnelles). - -Si vous demandez toutes les colonnes, la table peut fonctionner un peu lentement, car plusieurs lectures de ZooKeeper sont faites pour chaque ligne. -Si vous ne demandez pas les 4 dernières colonnes (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), la table fonctionne rapidement. - -Par exemple, vous pouvez vérifier que tout fonctionne correctement comme ceci: - -``` sql -SELECT - database, - table, - is_leader, - is_readonly, - is_session_expired, - future_parts, - parts_to_check, - columns_version, - queue_size, - inserts_in_queue, - merges_in_queue, - log_max_index, - log_pointer, - total_replicas, - active_replicas -FROM system.replicas -WHERE - is_readonly - OR is_session_expired - OR future_parts > 20 - OR parts_to_check > 10 - OR queue_size > 20 - OR inserts_in_queue > 10 - OR log_max_index - log_pointer > 10 - OR total_replicas < 2 - OR active_replicas < total_replicas -``` - -Si cette requête ne retourne rien, cela signifie que tout va bien. - -## système.paramètre {#system-settings} - -Contient des informations sur les paramètres actuellement utilisés. -I. e. utilisé pour l'exécution de la requête que vous utilisez pour lire à partir du système.les paramètres de la table. - -Colonne: - -- `name` (String) — Setting name. -- `value` (String) — Setting value. -- `description` (String) — Setting description. -- `type` (String) — Setting type (implementation specific string value). -- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. -- `min` (Nullable(String)) — Get minimum allowed value (if any is set via [contraintes](settings/constraints_on_settings.md#constraints-on-settings)). -- `max` (Nullable(String)) — Get maximum allowed value (if any is set via [contraintes](settings/constraints_on_settings.md#constraints-on-settings)). -- `readonly` (UInt8) — Can user change this setting (for more info, look into [contraintes](settings/constraints_on_settings.md#constraints-on-settings)). - -Exemple: - -``` sql -SELECT name, value -FROM system.settings -WHERE changed -``` - -``` text -┌─name───────────────────┬─value───────┐ -│ max_threads │ 8 │ -│ use_uncompressed_cache │ 0 │ -│ load_balancing │ random │ -│ max_memory_usage │ 10000000000 │ -└────────────────────────┴─────────────┘ -``` - -## système.merge\_tree\_settings {#system-merge_tree_settings} - -Contient des informations sur les paramètres pour `MergeTree` table. - -Colonne: - -- `name` (String) — Setting name. -- `value` (String) — Setting value. -- `description` (String) — Setting description. -- `type` (String) — Setting type (implementation specific string value). -- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. - -## système.tableau\_moteurs {#system-table-engines} - -Contient une description des moteurs de table pris en charge par le serveur et leurs informations de support de fonctionnalité. - -Ce tableau contient les colonnes suivantes (le type de colonne est indiqué entre parenthèses): - -- `name` (String) — The name of table engine. -- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` clause. -- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [sauter les indices](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-data_skipping-indexes). -- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). -- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` et `SAMPLE_BY`. -- `supports_replication` (UInt8) — Flag that indicates if table engine supports [réplication des données](../engines/table_engines/mergetree_family/replication.md). -- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. - -Exemple: - -``` sql -SELECT * -FROM system.table_engines -WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') -``` - -``` text -┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ -│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ -│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ -│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ -└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ -``` - -**Voir aussi** - -- Famille MergeTree [les clauses de requête](../engines/table_engines/mergetree_family/mergetree.md#mergetree-query-clauses) -- Kafka [paramètre](../engines/table_engines/integrations/kafka.md#table_engine-kafka-creating-a-table) -- Rejoindre [paramètre](../engines/table_engines/special/join.md#join-limitations-and-settings) - -## système.table {#system-tables} - -Contient les métadonnées de chaque table que le serveur connaît. Les tableaux détachés ne sont pas représentés dans `system.tables`. - -Ce tableau contient les colonnes suivantes (le type de colonne est indiqué entre parenthèses): - -- `database` (String) — The name of the database the table is in. - -- `name` (String) — Table name. - -- `engine` (String) — Table engine name (without parameters). - -- `is_temporary` (UInt8) - indicateur qui indique si la table est temporaire. - -- `data_path` (Chaîne) - chemin d'accès aux données de la table dans le système de fichiers. - -- `metadata_path` (Chaîne) - chemin d'accès aux métadonnées de la table dans le système de fichiers. - -- `metadata_modification_time` (DateTime) - Heure de la dernière modification des métadonnées de la table. - -- `dependencies_database` (Array (String)) - dépendances de base de données. - -- `dependencies_table` (Array (String)) - dépendances de Table ([MaterializedView](../engines/table_engines/special/materializedview.md) tables basées sur le tableau actuel). - -- `create_table_query` (Chaîne) - la requête qui a été utilisée pour créer la table. - -- `engine_full` (Chaîne) - paramètres du moteur de table. - -- `partition_key` (String) - l'expression de clé de partition spécifiée dans le tableau. - -- `sorting_key` (String) - l'expression de clé de tri spécifiée dans la table. - -- `primary_key` (String) - l'expression de clé primaire spécifiée dans la table. - -- `sampling_key` (String) - l'expression de clé d'échantillonnage spécifiée dans la table. - -- `storage_policy` (String) - La politique de stockage: - - - [MergeTree](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) - - [Distribué](../engines/table_engines/special/distributed.md#distributed) - -- `total_rows` (Nullable (UInt64)) - nombre Total de lignes, s'il est possible de déterminer rapidement le nombre exact de lignes dans la table, sinon `Null` (y compris underying `Buffer` table). - -- `total_bytes` (Nullable (UInt64)) - nombre Total d'octets, s'il est possible de déterminer rapidement le nombre exact d'octets pour la table sur le stockage, sinon `Null` (**ne pas** comprend tout de stockage sous-jacent). - - - If the table stores data on disk, returns used space on disk (i.e. compressed). - - Si la table stocke des données en mémoire, renvoie un nombre approximatif d'octets utilisés en mémoire. - -Le `system.tables` le tableau est utilisé dans `SHOW TABLES` implémentation de requête. - -## système.zookeeper {#system-zookeeper} - -La table n'existe pas si ZooKeeper n'est pas configuré. Permet de lire les données du cluster Zookeeper défini dans la configuration. -La requête doit avoir un ‘path’ condition d'égalité dans la clause WHERE. C'est le chemin dans ZooKeeper pour les enfants pour lesquels vous souhaitez obtenir des données. - -Requête `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` données de sortie pour tous les enfants `/clickhouse` nœud. -Pour générer des données pour tous les nœuds racine, écrivez path = ‘/’. -Si le chemin d'accès spécifié dans ‘path’ n'existe pas, une exception sera levée. - -Colonne: - -- `name` (String) — The name of the node. -- `path` (String) — The path to the node. -- `value` (String) — Node value. -- `dataLength` (Int32) — Size of the value. -- `numChildren` (Int32) — Number of descendants. -- `czxid` (Int64) — ID of the transaction that created the node. -- `mzxid` (Int64) — ID of the transaction that last changed the node. -- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. -- `ctime` (DateTime) — Time of node creation. -- `mtime` (DateTime) — Time of the last modification of the node. -- `version` (Int32) — Node version: the number of times the node was changed. -- `cversion` (Int32) — Number of added or removed descendants. -- `aversion` (Int32) — Number of changes to the ACL. -- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. - -Exemple: - -``` sql -SELECT * -FROM system.zookeeper -WHERE path = '/clickhouse/tables/01-08/visits/replicas' -FORMAT Vertical -``` - -``` text -Row 1: -────── -name: example01-08-1.yandex.ru -value: -czxid: 932998691229 -mzxid: 932998691229 -ctime: 2015-03-27 16:49:51 -mtime: 2015-03-27 16:49:51 -version: 0 -cversion: 47 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021031383 -path: /clickhouse/tables/01-08/visits/replicas - -Row 2: -────── -name: example01-08-2.yandex.ru -value: -czxid: 933002738135 -mzxid: 933002738135 -ctime: 2015-03-27 16:57:01 -mtime: 2015-03-27 16:57:01 -version: 0 -cversion: 37 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021252247 -path: /clickhouse/tables/01-08/visits/replicas -``` - -## système.mutation {#system_tables-mutations} - -Le tableau contient des informations sur [mutation](../sql_reference/statements/alter.md#alter-mutations) des tables MergeTree et leur progression. Chaque commande de mutation est représentée par une seule ligne. Le tableau comporte les colonnes suivantes: - -**base de données**, **table** - Le nom de la base de données et de la table à laquelle la mutation a été appliquée. - -**mutation\_id** - Le numéro d'identification de la mutation. Pour les tables répliquées ces ID correspondent aux noms znode dans le `/mutations/` répertoire de la Gardienne. Pour les tables non compliquées, Les Id correspondent aux noms de fichiers dans le répertoire de données de la table. - -**commande** - La chaîne de commande mutation (la partie de la requête après `ALTER TABLE [db.]table`). - -**create\_time** - Quand cette commande de mutation a été soumise pour exécution. - -**block\_numbers.partition\_id**, **block\_numbers.nombre** - Une colonne imbriquée. Pour les mutations de tables répliquées, il contient un enregistrement pour chaque partition: l'ID de partition et le numéro de bloc acquis par la mutation (dans chaque partition, seules les parties contenant des blocs avec des nombres inférieurs au numéro de bloc acquis par la mutation dans cette partition seront mutées). Dans les tables non répliquées, les numéros de bloc de toutes les partitions forment une seule séquence. Cela signifie que pour les mutations de tables non répliquées, la colonne contiendra un enregistrement avec un seul numéro de bloc acquis par la mutation. - -**parts\_to\_do** - Le nombre de parties de données qui doivent être mutées pour que la mutation se termine. - -**\_done** - La mutation est faite? Notez que même si `parts_to_do = 0` il est possible qu'une mutation d'une table répliquée ne soit pas encore effectuée en raison d'un INSERT de longue durée qui créera une nouvelle partie de données qui devra être mutée. - -S'il y avait des problèmes avec la mutation de certaines parties, les colonnes suivantes contiennent des informations supplémentaires: - -**latest\_failed\_part** - Le nom de la partie la plus récente qui n'a pas pu être mutée. - -**latest\_fail\_time** - Le temps de la partie la plus récente mutation de l'échec. - -**latest\_fail\_reason** - Le message d'exception qui a provoqué l'échec de la mutation de pièce la plus récente. - -## système.disque {#system_tables-disks} - -Contient des informations sur les disques définis dans [configuration du serveur](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Colonne: - -- `name` ([Chaîne](../sql_reference/data_types/string.md)) — Name of a disk in the server configuration. -- `path` ([Chaîne](../sql_reference/data_types/string.md)) — Path to the mount point in the file system. -- `free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Free space on disk in bytes. -- `total_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Disk volume in bytes. -- `keep_free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` paramètre de configuration du disque. - -## système.storage\_policies {#system_tables-storage_policies} - -Contient des informations sur les stratégies de stockage et les volumes définis [configuration du serveur](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Colonne: - -- `policy_name` ([Chaîne](../sql_reference/data_types/string.md)) — Name of the storage policy. -- `volume_name` ([Chaîne](../sql_reference/data_types/string.md)) — Volume name defined in the storage policy. -- `volume_priority` ([UInt64](../sql_reference/data_types/int_uint.md)) — Volume order number in the configuration. -- `disks` ([Tableau(String)](../sql_reference/data_types/array.md)) — Disk names, defined in the storage policy. -- `max_data_part_size` ([UInt64](../sql_reference/data_types/int_uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). -- `move_factor` ([Float64](../sql_reference/data_types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. - -Si la stratégie de stockage contient plus d'un volume, les informations pour chaque volume sont stockées dans la ligne individuelle de la table. - -[Article Original](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/fr/operations/tips.md b/docs/fr/operations/tips.md index 5122f21c0c1..a4fe5f844de 100644 --- a/docs/fr/operations/tips.md +++ b/docs/fr/operations/tips.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 58 toc_title: Recommandations D'Utilisation --- diff --git a/docs/fr/operations/troubleshooting.md b/docs/fr/operations/troubleshooting.md index e334786194f..0608569c61c 100644 --- a/docs/fr/operations/troubleshooting.md +++ b/docs/fr/operations/troubleshooting.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 46 toc_title: "D\xE9pannage" --- @@ -14,12 +14,12 @@ toc_title: "D\xE9pannage" ## Installation {#troubleshooting-installation-errors} -### Vous ne pouvez pas obtenir de paquets deb à partir du référentiel Clickhouse avec Apt-get {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} +### Vous ne pouvez pas obtenir de paquets deb à partir du référentiel ClickHouse avec Apt-get {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} - Vérifiez les paramètres du pare-feu. -- Si vous ne pouvez pas accéder au référentiel pour quelque raison que ce soit, téléchargez les packages comme décrit dans [Prise en main](../getting_started/index.md) article et les installer manuellement en utilisant le `sudo dpkg -i ` commande. Vous aurez aussi besoin d' `tzdata` paquet. +- Si vous ne pouvez pas accéder au référentiel pour quelque raison que ce soit, téléchargez les packages comme décrit dans [Prise en main](../getting-started/index.md) article et les installer manuellement en utilisant le `sudo dpkg -i ` commande. Vous aurez aussi besoin d' `tzdata` paquet. -## Connexion au serveur {#troubleshooting-accepts-no-connections} +## Connexion au Serveur {#troubleshooting-accepts-no-connections} Problèmes possibles: @@ -105,7 +105,7 @@ Vérifier: - Paramètres du point de terminaison. - Vérifier [listen\_host](server_configuration_parameters/settings.md#server_configuration_parameters-listen_host) et [tcp\_port](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port) paramètre. + Vérifier [listen\_host](server-configuration-parameters/settings.md#server_configuration_parameters-listen_host) et [tcp\_port](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port) paramètre. Clickhouse server accepte les connexions localhost uniquement par défaut. @@ -117,8 +117,8 @@ Vérifier: Vérifier: - - Le [tcp\_port\_secure](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) paramètre. - - Paramètres pour [SSL sertificates](server_configuration_parameters/settings.md#server_configuration_parameters-openssl). + - Le [tcp\_port\_secure](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) paramètre. + - Paramètres pour [SSL sertificates](server-configuration-parameters/settings.md#server_configuration_parameters-openssl). Utilisez les paramètres appropriés lors de la connexion. Par exemple, l'utilisation de la `port_secure` paramètre avec `clickhouse_client`. @@ -139,7 +139,7 @@ Si vous commencez à `clickhouse-client` avec l' `stack-trace` paramètre, Click Vous pouvez voir un message sur une connexion rompue. Dans ce cas, vous pouvez répéter la requête. Si la connexion se rompt chaque fois que vous effectuez la requête, vérifiez les journaux du serveur pour détecter les erreurs. -## Efficacité Du Traitement Des Requêtes {#troubleshooting-too-slow} +## Efficacité du traitement des requêtes {#troubleshooting-too-slow} Si vous voyez que ClickHouse fonctionne trop lentement, vous devez profiler la charge sur les ressources du serveur et le réseau pour vos requêtes. diff --git a/docs/fr/operations/update.md b/docs/fr/operations/update.md index 67aecbc9c1a..e1bfe57b0a3 100644 --- a/docs/fr/operations/update.md +++ b/docs/fr/operations/update.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 47 toc_title: "Mise \xC0 Jour De ClickHouse" --- diff --git a/docs/fr/operations/utilities/clickhouse-benchmark.md b/docs/fr/operations/utilities/clickhouse-benchmark.md index ebf31a962e1..975cb09814e 100644 --- a/docs/fr/operations/utilities/clickhouse-benchmark.md +++ b/docs/fr/operations/utilities/clickhouse-benchmark.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 61 toc_title: clickhouse-benchmark --- @@ -99,7 +99,7 @@ Dans le rapport, vous pouvez trouver: - Percentiles du temps d'exécution des requêtes. -## Mode de comparaison {#clickhouse-benchmark-comparison-mode} +## Mode De Comparaison {#clickhouse-benchmark-comparison-mode} `clickhouse-benchmark` peut comparer les performances pour deux serveurs clickhouse en cours d'exécution. diff --git a/docs/fr/operations/utilities/clickhouse-copier.md b/docs/fr/operations/utilities/clickhouse-copier.md index 31901b29baf..da96c41e8f2 100644 --- a/docs/fr/operations/utilities/clickhouse-copier.md +++ b/docs/fr/operations/utilities/clickhouse-copier.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 59 toc_title: clickhouse-copieur --- @@ -26,7 +26,7 @@ Après le démarrage de, `clickhouse-copier`: Pour réduire le trafic réseau, nous vous recommandons de `clickhouse-copier` sur le même serveur où se trouvent les données source. -## Course clickhouse-copieur {#running-clickhouse-copier} +## Course Clickhouse-copieur {#running-clickhouse-copier} L'utilitaire doit être exécuté manuellement: @@ -43,7 +43,7 @@ Paramètre: - `task-upload-force` — Force upload `task-file` même si le nœud existe déjà. - `base-dir` — The path to logs and auxiliary files. When it starts, `clickhouse-copier` crée `clickhouse-copier_YYYYMMHHSS_` les sous-répertoires `$base-dir`. Si ce paramètre est omis, les répertoires sont créés dans le répertoire où `clickhouse-copier` a été lancé. -## Format de zookeeper.XML {#format-of-zookeeper-xml} +## Format de Zookeeper.XML {#format-of-zookeeper-xml} ``` xml diff --git a/docs/fr/operations/utilities/clickhouse-local.md b/docs/fr/operations/utilities/clickhouse-local.md index 6051825dda0..5dfac0d89ca 100644 --- a/docs/fr/operations/utilities/clickhouse-local.md +++ b/docs/fr/operations/utilities/clickhouse-local.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 60 toc_title: clickhouse-local --- @@ -9,7 +9,7 @@ toc_title: clickhouse-local Le `clickhouse-local` programme vous permet d'effectuer un traitement rapide sur les fichiers locaux, sans avoir à déployer et configurer le serveur ClickHouse. -Accepte les données qui représentent des tables et les interroge en utilisant [Clickhouse dialecte SQL](../../sql_reference/index.md). +Accepte les données qui représentent des tables et les interroge en utilisant [Clickhouse dialecte SQL](../../sql-reference/index.md). `clickhouse-local` utilise le même noyau que clickhouse server, de sorte qu'il prend en charge la plupart des fonctionnalités et le même ensemble de formats et de moteurs de table. diff --git a/docs/fr/operations/utilities/index.md b/docs/fr/operations/utilities/index.md index 7523d5dd216..51a250bb996 100644 --- a/docs/fr/operations/utilities/index.md +++ b/docs/fr/operations/utilities/index.md @@ -1,7 +1,7 @@ --- machine_translated: true -machine_translated_rev: f865c9653f9df092694258e0ccdd733c339112f5 -toc_folder_title: Utilities +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Utilitaire toc_priority: 56 toc_title: "Aper\xE7u" --- diff --git a/docs/fr/sql-reference/aggregate-functions/combinators.md b/docs/fr/sql-reference/aggregate-functions/combinators.md new file mode 100644 index 00000000000..1aabd34051b --- /dev/null +++ b/docs/fr/sql-reference/aggregate-functions/combinators.md @@ -0,0 +1,245 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: Combinators +--- + +# Combinateurs De Fonction D'Agrégat {#aggregate_functions_combinators} + +Le nom d'une fonction d'agrégat peut avoir un suffixe ajouté. Cela change la façon dont la fonction d'agrégation fonctionne. + +## -Si {#agg-functions-combinator-if} + +The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). + +Exemple: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` et ainsi de suite. + +Avec les fonctions d'agrégat conditionnel, vous pouvez calculer des agrégats pour plusieurs conditions à la fois, sans utiliser de sous-requêtes et `JOIN`s. Par exemple, dans Yandex.Metrica, les fonctions d'agrégat conditionnel sont utilisées pour implémenter la fonctionnalité de comparaison de segment. + +## -Tableau {#agg-functions-combinator-array} + +Le Tableau suffixe peut être ajouté à toute fonction d'agrégation. Dans ce cas, la fonction d'agrégation des arguments de la ‘Array(T)’ type (tableaux) au lieu de ‘T’ tapez les arguments. Si la fonction aggregate accepte plusieurs arguments, il doit s'agir de tableaux de longueurs égales. Lors du traitement des tableaux, la fonction d'agrégation fonctionne comme la fonction d'agrégation d'origine sur tous les éléments du tableau. + +Exemple 1: `sumArray(arr)` - Totalise tous les éléments de tous ‘arr’ tableau. Dans cet exemple, il aurait pu être écrit plus simplement: `sum(arraySum(arr))`. + +Exemple 2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ tableau. Cela pourrait être fait d'une manière plus facile: `uniq(arrayJoin(arr))` mais ce n'est pas toujours possible d'ajouter des ‘arrayJoin’ pour une requête. + +\- Si et-tableau peut être combiné. Cependant, ‘Array’ doit venir en premier, puis ‘If’. Exemple: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. En raison de cet ordre, le ‘cond’ argument ne sera pas un tableau. + +## -État {#agg-functions-combinator-state} + +Si vous appliquez ce combinateur, la fonction d'agrégation ne renvoie pas la valeur résultante (par exemple le nombre de valeurs uniques pour [uniq](reference.md#agg_function-uniq) la fonction), mais un état intermédiaire de l'agrégation (pour `uniq`, c'est la table de hachage pour calculer le nombre de valeurs uniques). C'est un `AggregateFunction(...)` qui peuvent être utilisés pour un traitement ultérieur ou stockés dans un tableau pour terminer l'agrégation plus tard. + +Pour travailler avec ces états, utilisez: + +- [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) tableau moteur. +- [finalizeAggregation](../../sql-reference/functions/other-functions.md#function-finalizeaggregation) fonction. +- [runningAccumulate](../../sql-reference/functions/other-functions.md#function-runningaccumulate) fonction. +- [-Fusionner](#aggregate_functions_combinators-merge) combinator. +- [-MergeState](#aggregate_functions_combinators-mergestate) combinator. + +## -Fusionner {#aggregate_functions_combinators-merge} + +Si vous appliquez ce combinateur, la fonction d'agrégation prend l'état d'agrégation intermédiaire comme argument, combine les États pour terminer l'agrégation et renvoie la valeur résultante. + +## -MergeState {#aggregate_functions_combinators-mergestate} + +Fusionne les États d'agrégation intermédiaires de la même manière que le combinateur-Merge. Cependant, il ne renvoie pas la valeur résultante, mais un État d'agrégation intermédiaire, similaire au combinateur-State. + +## - ForEach {#agg-functions-combinator-foreach} + +Convertit une fonction d'agrégation pour les tables en une fonction d'agrégation pour les tableaux qui agrège les éléments de tableau correspondants et renvoie un tableau de résultats. Exemple, `sumForEach` pour les tableaux `[1, 2]`, `[3, 4, 5]`et`[6, 7]`renvoie le résultat `[10, 13, 5]` après avoir additionné les éléments de tableau correspondants. + +## - OrDefault {#agg-functions-combinator-ordefault} + +Modifie le comportement d'une fonction d'agrégat. + +Si une fonction d'agrégation n'a pas de valeurs d'entrée, avec ce combinateur, elle renvoie la valeur par défaut pour son type de données de retour. S'applique aux fonctions d'agrégation qui peuvent prendre des données d'entrée vides. + +`-OrDefault` peut être utilisé avec d'autres combinators. + +**Syntaxe** + +``` sql +OrDefault(x) +``` + +**Paramètre** + +- `x` — Aggregate function parameters. + +**Valeurs renvoyées** + +Renvoie la valeur par défaut du type de retour d'une fonction d'agrégation s'il n'y a rien à agréger. + +Le Type dépend de la fonction d'agrégation utilisée. + +**Exemple** + +Requête: + +``` sql +SELECT avg(number), avgOrDefault(number) FROM numbers(0) +``` + +Résultat: + +``` text +┌─avg(number)─┬─avgOrDefault(number)─┐ +│ nan │ 0 │ +└─────────────┴──────────────────────┘ +``` + +Également `-OrDefault` peut être utilisé avec un autre combinateur. Il est utile lorsque la fonction d'agrégation n'accepte pas l'entrée vide. + +Requête: + +``` sql +SELECT avgOrDefaultIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Résultat: + +``` text +┌─avgOrDefaultIf(x, greater(x, 10))─┐ +│ 0.00 │ +└───────────────────────────────────┘ +``` + +## - OrNull {#agg-functions-combinator-ornull} + +Modifie le comportement d'une fonction d'agrégat. + +Ce combinateur convertit un résultat d'une fonction d'agrégation à l' [Nullable](../data-types/nullable.md) type de données. Si la fonction d'agrégation n'a pas de valeurs à calculer elle renvoie [NULL](../syntax.md#null-literal). + +`-OrNull` peut être utilisé avec d'autres combinators. + +**Syntaxe** + +``` sql +OrNull(x) +``` + +**Paramètre** + +- `x` — Aggregate function parameters. + +**Valeurs renvoyées** + +- Le résultat de la fonction d'agrégat, converti en `Nullable` type de données. +- `NULL` si il n'y a rien à s'agréger. + +Type: `Nullable(aggregate function return type)`. + +**Exemple** + +Ajouter `-orNull` à la fin de la fonction d'agrégation. + +Requête: + +``` sql +SELECT sumOrNull(number), toTypeName(sumOrNull(number)) FROM numbers(10) WHERE number > 10 +``` + +Résultat: + +``` text +┌─sumOrNull(number)─┬─toTypeName(sumOrNull(number))─┐ +│ ᴺᵁᴸᴸ │ Nullable(UInt64) │ +└───────────────────┴───────────────────────────────┘ +``` + +Également `-OrNull` peut être utilisé avec un autre combinateur. Il est utile lorsque la fonction d'agrégation n'accepte pas l'entrée vide. + +Requête: + +``` sql +SELECT avgOrNullIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Résultat: + +``` text +┌─avgOrNullIf(x, greater(x, 10))─┐ +│ ᴺᵁᴸᴸ │ +└────────────────────────────────┘ +``` + +## -Resample {#agg-functions-combinator-resample} + +Permet de diviser les données en groupes, puis séparément agrège les données de ces groupes. Les groupes sont créés en divisant les valeurs d'une colonne en intervalles. + +``` sql +Resample(start, end, step)(, resampling_key) +``` + +**Paramètre** + +- `start` — Starting value of the whole required interval for `resampling_key` valeur. +- `stop` — Ending value of the whole required interval for `resampling_key` valeur. L'ensemble de l'intervalle ne comprend pas les `stop` valeur `[start, stop)`. +- `step` — Step for separating the whole interval into subintervals. The `aggFunction` est exécuté sur chacun de ces sous-intervalles indépendamment. +- `resampling_key` — Column whose values are used for separating data into intervals. +- `aggFunction_params` — `aggFunction` paramètre. + +**Valeurs renvoyées** + +- Tableau de `aggFunction` les résultats pour chaque subinterval. + +**Exemple** + +Envisager l' `people` le tableau avec les données suivantes: + +``` text +┌─name───┬─age─┬─wage─┐ +│ John │ 16 │ 10 │ +│ Alice │ 30 │ 15 │ +│ Mary │ 35 │ 8 │ +│ Evelyn │ 48 │ 11.5 │ +│ David │ 62 │ 9.9 │ +│ Brian │ 60 │ 16 │ +└────────┴─────┴──────┘ +``` + +Obtenons les noms des personnes dont l'âge se trouve dans les intervalles de `[30,60)` et `[60,75)`. Puisque nous utilisons la représentation entière pour l'âge, nous obtenons des âges dans le `[30, 59]` et `[60,74]` intervalle. + +Pour agréger des noms dans un tableau, nous utilisons [grouperay](reference.md#agg_function-grouparray) fonction d'agrégation. Il faut un argument. Dans notre cas, c'est l' `name` colonne. Le `groupArrayResample` fonction devrait utiliser le `age` colonne pour agréger les noms par âge. Pour définir les intervalles requis, nous passons le `30, 75, 30` des arguments dans la `groupArrayResample` fonction. + +``` sql +SELECT groupArrayResample(30, 75, 30)(name, age) FROM people +``` + +``` text +┌─groupArrayResample(30, 75, 30)(name, age)─────┐ +│ [['Alice','Mary','Evelyn'],['David','Brian']] │ +└───────────────────────────────────────────────┘ +``` + +Considérez les résultats. + +`Jonh` est hors de l'échantillon parce qu'il est trop jeune. D'autres personnes sont distribués selon les intervalles d'âge. + +Maintenant, nous allons compter le nombre total de personnes et leur salaire moyen dans les intervalles d'âge. + +``` sql +SELECT + countResample(30, 75, 30)(name, age) AS amount, + avgResample(30, 75, 30)(wage, age) AS avg_wage +FROM people +``` + +``` text +┌─amount─┬─avg_wage──────────────────┐ +│ [3,2] │ [11.5,12.949999809265137] │ +└────────┴───────────────────────────┘ +``` + +[Article Original](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/fr/sql-reference/aggregate-functions/index.md b/docs/fr/sql-reference/aggregate-functions/index.md new file mode 100644 index 00000000000..4f4e3f057ae --- /dev/null +++ b/docs/fr/sql-reference/aggregate-functions/index.md @@ -0,0 +1,62 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Les Fonctions D'Agr\xE9gation" +toc_priority: 33 +toc_title: Introduction +--- + +# Les Fonctions D'Agrégation {#aggregate-functions} + +Les fonctions d'agrégation fonctionnent dans le [normal](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) comme prévu par les experts de la base de données. + +Clickhouse prend également en charge: + +- [Fonctions d'agrégat paramétriques](parametric-functions.md#aggregate_functions_parametric) qui acceptent d'autres paramètres en plus des colonnes. +- [Combinators](combinators.md#aggregate_functions_combinators), qui modifient le comportement des fonctions d'agrégation. + +## Le Traitement NULL {#null-processing} + +Au cours de l'agrégation, tous les `NULL`s sont ignorés. + +**Exemple:** + +Considérez ce tableau: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +Disons que vous devez totaliser les valeurs dans le `y` colonne: + +``` sql +SELECT sum(y) FROM t_null_big +``` + + ┌─sum(y)─┐ + │ 7 │ + └────────┘ + +Le `sum` la fonction d'interprète `NULL` comme `0`. En particulier, cela signifie que si la fonction reçoit en entrée d'une sélection où toutes les valeurs sont `NULL`, alors le résultat sera `0`, pas `NULL`. + +Maintenant, vous pouvez utiliser le `groupArray` fonction pour créer un tableau à partir `y` colonne: + +``` sql +SELECT groupArray(y) FROM t_null_big +``` + +``` text +┌─groupArray(y)─┐ +│ [2,2,3] │ +└───────────────┘ +``` + +`groupArray` ne comprend pas `NULL` dans le tableau résultant. + +[Article Original](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/fr/sql-reference/aggregate-functions/parametric-functions.md b/docs/fr/sql-reference/aggregate-functions/parametric-functions.md new file mode 100644 index 00000000000..a8d6d533cb8 --- /dev/null +++ b/docs/fr/sql-reference/aggregate-functions/parametric-functions.md @@ -0,0 +1,499 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "Param\xE9trique" +--- + +# Fonctions D'Agrégat Paramétriques {#aggregate_functions_parametric} + +Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. + +## histogramme {#histogram} + +Calcule un histogramme adaptatif. Cela ne garantit pas des résultats précis. + +``` sql +histogram(number_of_bins)(values) +``` + +Les fonctions utilise [Un Algorithme D'Arbre De Décision Parallèle En Continu](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). Les bordures des bacs d'histogramme sont ajustées au fur et à mesure que de nouvelles données entrent dans une fonction. Dans le cas courant, les largeurs des bacs ne sont pas égales. + +**Paramètre** + +`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. +`values` — [Expression](../syntax.md#syntax-expressions) résultant en valeurs d'entrée. + +**Valeurs renvoyées** + +- [Tableau](../../sql-reference/data-types/array.md) de [Tuple](../../sql-reference/data-types/tuple.md) de le format suivant: + + ``` + [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] + ``` + + - `lower` — Lower bound of the bin. + - `upper` — Upper bound of the bin. + - `height` — Calculated height of the bin. + +**Exemple** + +``` sql +SELECT histogram(5)(number + 1) +FROM ( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ +│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +Vous pouvez visualiser un histogramme avec la [bar](../../sql-reference/functions/other-functions.md#function-bar) fonction, par exemple: + +``` sql +WITH histogram(5)(rand() % 100) AS hist +SELECT + arrayJoin(hist).3 AS height, + bar(height, 0, 6, 5) AS bar +FROM +( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─height─┬─bar───┐ +│ 2.125 │ █▋ │ +│ 3.25 │ ██▌ │ +│ 5.625 │ ████▏ │ +│ 5.625 │ ████▏ │ +│ 3.375 │ ██▌ │ +└────────┴───────┘ +``` + +Dans ce cas, vous devez vous rappeler que vous ne connaissez pas les frontières de la corbeille d'histogramme. + +## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} + +Vérifie si la séquence contient une chaîne d'événements qui correspond au modèle. + +``` sql +sequenceMatch(pattern)(timestamp, cond1, cond2, ...) +``` + +!!! warning "Avertissement" + Les événements qui se produisent à la même seconde peuvent se situer dans la séquence dans un ordre indéfini affectant le résultat. + +**Paramètre** + +- `pattern` — Pattern string. See [Syntaxe du motif](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` et `DateTime`. Vous pouvez également utiliser les prises en charge [UInt](../../sql-reference/data-types/int-uint.md) types de données. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. Vous pouvez passer jusqu'à 32 arguments de condition. La fonction ne prend en compte que les événements décrits dans ces conditions. Si la séquence contient des données qui ne sont pas décrites dans une condition, la fonction les ignore. + +**Valeurs renvoyées** + +- 1, si le profil correspond. +- 0, si le motif ne correspond pas. + +Type: `UInt8`. + + +**Syntaxe du motif** + +- `(?N)` — Matches the condition argument at position `N`. Les Conditions sont numérotées dans le `[1, 32]` gamme. Exemple, `(?1)` correspond à l'argument passé au `cond1` paramètre. + +- `.*` — Matches any number of events. You don't need conditional arguments to match this element of the pattern. + +- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` correspond à des événements qui se produisent plus de 1800 secondes les uns des autres. Un nombre arbitraire d'événements peut se trouver entre ces événements. Vous pouvez utiliser l' `>=`, `>`, `<`, `<=` opérateur. + +**Exemple** + +Considérer les données dans le `t` table: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +└──────┴────────┘ +``` + +Effectuer la requête: + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 1 │ +└───────────────────────────────────────────────────────────────────────┘ +``` + +La fonction a trouvé la chaîne d'événements où le numéro 2 suit le numéro 1. Il a sauté le numéro 3 entre eux, car le nombre n'est pas décrit comme un événement. Si nous voulons prendre ce nombre en compte lors de la recherche de l'événement de la chaîne donnée dans l'exemple, nous devrions en faire une condition. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ +│ 0 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +Dans ce cas, la fonction n'a pas pu trouver la chaîne d'événements correspondant au modèle, car l'événement pour le numéro 3 s'est produit entre 1 et 2. Si dans le même cas nous vérifions la condition pour le numéro 4, la séquence correspondrait au motif. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ +│ 1 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Voir Aussi** + +- [sequenceCount](#function-sequencecount) + +## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} + +Compte le nombre de chaînes d'événements correspondant au motif. La fonction recherche les chaînes d'événements qui ne se chevauchent pas. Il commence à rechercher la chaîne suivante après que la chaîne actuelle est appariée. + +!!! warning "Avertissement" + Les événements qui se produisent à la même seconde peuvent se situer dans la séquence dans un ordre indéfini affectant le résultat. + +``` sql +sequenceCount(pattern)(timestamp, cond1, cond2, ...) +``` + +**Paramètre** + +- `pattern` — Pattern string. See [Syntaxe du motif](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` et `DateTime`. Vous pouvez également utiliser les prises en charge [UInt](../../sql-reference/data-types/int-uint.md) types de données. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. Vous pouvez passer jusqu'à 32 arguments de condition. La fonction ne prend en compte que les événements décrits dans ces conditions. Si la séquence contient des données qui ne sont pas décrites dans une condition, la fonction les ignore. + +**Valeurs renvoyées** + +- Nombre de chaînes d'événements qui ne se chevauchent pas et qui sont mises en correspondance. + +Type: `UInt64`. + +**Exemple** + +Considérer les données dans le `t` table: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +│ 4 │ 1 │ +│ 5 │ 3 │ +│ 6 │ 2 │ +└──────┴────────┘ +``` + +Comptez combien de fois le nombre 2 se produit après le nombre 1 avec n'importe quelle quantité d'autres nombres entre eux: + +``` sql +SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 2 │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +**Voir Aussi** + +- [sequenceMatch](#function-sequencematch) + +## fenêtrefunnel {#windowfunnel} + +Recherche les chaînes d'événements dans une fenêtre de temps coulissante et calcule le nombre maximum d'événements qui se sont produits à partir de la chaîne. + +La fonction fonctionne selon l'algorithme: + +- La fonction recherche les données qui déclenchent la première condition de la chaîne et définit le compteur d'événements sur 1. C'est le moment où la fenêtre coulissante commence. + +- Si les événements de la chaîne se produisent séquentiellement dans la fenêtre, le compteur est incrémenté. Si la séquence d'événements est perturbée, le compteur n'est pas incrémenté. + +- Si les données ont plusieurs chaînes d'événements à différents points d'achèvement, la fonction affichera uniquement la taille de la chaîne la plus longue. + +**Syntaxe** + +``` sql +windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) +``` + +**Paramètre** + +- `window` — Length of the sliding window in seconds. +- `mode` - C'est un argument facultatif. + - `'strict'` - Lorsque le `'strict'` est défini, le windowFunnel() applique des conditions uniquement pour les valeurs uniques. +- `timestamp` — Name of the column containing the timestamp. Data types supported: [Date](../../sql-reference/data-types/date.md), [DateTime](../../sql-reference/data-types/datetime.md#data_type-datetime) et d'autres types entiers non signés (notez que même si timestamp prend en charge le `UInt64` type, sa valeur ne peut pas dépasser le maximum Int64, qui est 2^63 - 1). +- `cond` — Conditions or data describing the chain of events. [UInt8](../../sql-reference/data-types/int-uint.md). + +**Valeur renvoyée** + +Nombre maximal de conditions déclenchées consécutives de la chaîne dans la fenêtre de temps de glissement. +Toutes les chaînes de la sélection sont analysés. + +Type: `Integer`. + +**Exemple** + +Déterminer si une période de temps est suffisant pour l'utilisateur de sélectionner un téléphone et d'acheter deux fois dans la boutique en ligne. + +Définissez la chaîne d'événements suivante: + +1. L'utilisateur s'est connecté à son compte sur le magasin (`eventID = 1003`). +2. L'utilisateur recherche un téléphone (`eventID = 1007, product = 'phone'`). +3. Toute commande de l'utilisateur (`eventID = 1009`). +4. L'Utilisateur a fait la commande à nouveau (`eventID = 1010`). + +Table d'entrée: + +``` text +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +``` + +Savoir dans quelle mesure l'utilisateur `user_id` pourrait passer à travers la chaîne dans une période en Janvier-Février de 2019. + +Requête: + +``` sql +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level + FROM trend + WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC +``` + +Résultat: + +``` text +┌─level─┬─c─┐ +│ 4 │ 1 │ +└───────┴───┘ +``` + +## rétention {#retention} + +La fonction prend comme arguments un ensemble de conditions de 1 à 32 arguments de type `UInt8` qui indiquent si une certaine condition est remplie pour l'événement. +Toute condition peut être spécifiée comme argument (comme dans [WHERE](../../sql-reference/statements/select/where.md#select-where)). + +Les conditions, à l'exception de la première, s'appliquent par paires: le résultat de la seconde sera vrai si la première et la deuxième sont remplies, le troisième si la première et la fird sont vraies, etc. + +**Syntaxe** + +``` sql +retention(cond1, cond2, ..., cond32); +``` + +**Paramètre** + +- `cond` — an expression that returns a `UInt8` résultat (1 ou 0). + +**Valeur renvoyée** + +Le tableau de 1 ou 0. + +- 1 — condition was met for the event. +- 0 — condition wasn't met for the event. + +Type: `UInt8`. + +**Exemple** + +Prenons un exemple de calcul de la `retention` fonction pour déterminer le trafic du site. + +**1.** Сreate a table to illustrate an example. + +``` sql +CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; + +INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); +INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); +INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); +``` + +Table d'entrée: + +Requête: + +``` sql +SELECT * FROM retention_test +``` + +Résultat: + +``` text +┌───────date─┬─uid─┐ +│ 2020-01-01 │ 0 │ +│ 2020-01-01 │ 1 │ +│ 2020-01-01 │ 2 │ +│ 2020-01-01 │ 3 │ +│ 2020-01-01 │ 4 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-02 │ 0 │ +│ 2020-01-02 │ 1 │ +│ 2020-01-02 │ 2 │ +│ 2020-01-02 │ 3 │ +│ 2020-01-02 │ 4 │ +│ 2020-01-02 │ 5 │ +│ 2020-01-02 │ 6 │ +│ 2020-01-02 │ 7 │ +│ 2020-01-02 │ 8 │ +│ 2020-01-02 │ 9 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-03 │ 0 │ +│ 2020-01-03 │ 1 │ +│ 2020-01-03 │ 2 │ +│ 2020-01-03 │ 3 │ +│ 2020-01-03 │ 4 │ +│ 2020-01-03 │ 5 │ +│ 2020-01-03 │ 6 │ +│ 2020-01-03 │ 7 │ +│ 2020-01-03 │ 8 │ +│ 2020-01-03 │ 9 │ +│ 2020-01-03 │ 10 │ +│ 2020-01-03 │ 11 │ +│ 2020-01-03 │ 12 │ +│ 2020-01-03 │ 13 │ +│ 2020-01-03 │ 14 │ +└────────────┴─────┘ +``` + +**2.** Grouper les utilisateurs par ID unique `uid` à l'aide de la `retention` fonction. + +Requête: + +``` sql +SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r +FROM retention_test +WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') +GROUP BY uid +ORDER BY uid ASC +``` + +Résultat: + +``` text +┌─uid─┬─r───────┐ +│ 0 │ [1,1,1] │ +│ 1 │ [1,1,1] │ +│ 2 │ [1,1,1] │ +│ 3 │ [1,1,1] │ +│ 4 │ [1,1,1] │ +│ 5 │ [0,0,0] │ +│ 6 │ [0,0,0] │ +│ 7 │ [0,0,0] │ +│ 8 │ [0,0,0] │ +│ 9 │ [0,0,0] │ +│ 10 │ [0,0,0] │ +│ 11 │ [0,0,0] │ +│ 12 │ [0,0,0] │ +│ 13 │ [0,0,0] │ +│ 14 │ [0,0,0] │ +└─────┴─────────┘ +``` + +**3.** Calculer le nombre total de visites par jour. + +Requête: + +``` sql +SELECT + sum(r[1]) AS r1, + sum(r[2]) AS r2, + sum(r[3]) AS r3 +FROM +( + SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r + FROM retention_test + WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') + GROUP BY uid +) +``` + +Résultat: + +``` text +┌─r1─┬─r2─┬─r3─┐ +│ 5 │ 5 │ 5 │ +└────┴────┴────┘ +``` + +Où: + +- `r1`- le nombre de visiteurs uniques qui ont visité le site au cours du 2020-01-01 (le `cond1` condition). +- `r2`- le nombre de visiteurs uniques qui ont visité le site au cours d'une période donnée entre 2020-01-01 et 2020-01-02 (`cond1` et `cond2` condition). +- `r3`- le nombre de visiteurs uniques qui ont visité le site au cours d'une période donnée entre 2020-01-01 et 2020-01-03 (`cond1` et `cond3` condition). + +## uniqUpTo (N) (x) {#uniquptonx} + +Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. + +Recommandé pour une utilisation avec de petites Ns, jusqu'à 10. La valeur maximale de N est de 100. + +Pour l'état d'une fonction d'agrégation, il utilise la quantité de mémoire égale à 1 + N \* de la taille d'une valeur d'octets. +Pour les chaînes, il stocke un hachage non cryptographique de 8 octets. Soit le calcul est approchée pour les chaînes. + +La fonction fonctionne également pour plusieurs arguments. + +Cela fonctionne aussi vite que possible, sauf dans les cas où une grande valeur N est utilisée et le nombre de valeurs uniques est légèrement inférieur à N. + +Exemple d'utilisation: + +``` text +Problem: Generate a report that shows only keywords that produced at least 5 unique users. +Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 +``` + +[Article Original](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) + +## sumMapFiltered(keys\_to\_keep) (clés, valeurs) {#summapfilteredkeys-to-keepkeys-values} + +Même comportement que [sumMap](reference.md#agg_functions-summap) sauf qu'un tableau de clés est passé en paramètre. Cela peut être particulièrement utile lorsque vous travaillez avec une forte cardinalité de touches. diff --git a/docs/fr/sql-reference/aggregate-functions/reference.md b/docs/fr/sql-reference/aggregate-functions/reference.md new file mode 100644 index 00000000000..456a9e9c4b3 --- /dev/null +++ b/docs/fr/sql-reference/aggregate-functions/reference.md @@ -0,0 +1,1977 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: "R\xE9f\xE9rence" +--- + +# Référence De La Fonction Agrégée {#aggregate-functions-reference} + +## compter {#agg_function-count} + +Compte le nombre de lignes ou de valeurs non NULL. + +ClickHouse prend en charge les syntaxes suivantes pour `count`: +- `count(expr)` ou `COUNT(DISTINCT expr)`. +- `count()` ou `COUNT(*)`. Le `count()` la syntaxe est spécifique à ClickHouse. + +**Paramètre** + +La fonction peut prendre: + +- Zéro des paramètres. +- Un [expression](../syntax.md#syntax-expressions). + +**Valeur renvoyée** + +- Si la fonction est appelée sans paramètres, il compte le nombre de lignes. +- Si l' [expression](../syntax.md#syntax-expressions) est passé, alors la fonction compte combien de fois cette expression retournée not null. Si l'expression renvoie un [Nullable](../../sql-reference/data-types/nullable.md)- tapez la valeur, puis le résultat de `count` séjours pas `Nullable`. La fonction renvoie 0 si l'expression est retournée `NULL` pour toutes les lignes. + +Dans les deux cas le type de la valeur renvoyée est [UInt64](../../sql-reference/data-types/int-uint.md). + +**Détail** + +Clickhouse soutient le `COUNT(DISTINCT ...)` syntaxe. Le comportement de cette construction dépend de la [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation) paramètre. Il définit lequel des [uniq\*](#agg_function-uniq) fonctions est utilisée pour effectuer l'opération. La valeur par défaut est la [uniqExact](#agg_function-uniqexact) fonction. + +Le `SELECT count() FROM table` la requête n'est pas optimisé, car le nombre d'entrées dans la table n'est pas stockée séparément. Il choisit une petite colonne de la table et compte le nombre de valeurs qu'il contient. + +**Exemple** + +Exemple 1: + +``` sql +SELECT count() FROM t +``` + +``` text +┌─count()─┐ +│ 5 │ +└─────────┘ +``` + +Exemple 2: + +``` sql +SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' +``` + +``` text +┌─name──────────────────────────┬─value─────┐ +│ count_distinct_implementation │ uniqExact │ +└───────────────────────────────┴───────────┘ +``` + +``` sql +SELECT count(DISTINCT num) FROM t +``` + +``` text +┌─uniqExact(num)─┐ +│ 3 │ +└────────────────┘ +``` + +Cet exemple montre que `count(DISTINCT num)` est effectuée par le `uniqExact` en fonction de l' `count_distinct_implementation` valeur de réglage. + +## tout(x) {#agg_function-any} + +Sélectionne la première valeur rencontrée. +La requête peut être exécutée dans n'importe quel ordre, et même dans un ordre différent à chaque fois, de sorte que le résultat de cette fonction est indéterminée. +Pour obtenir un résultat déterminé, vous pouvez utiliser le ‘min’ ou ‘max’ fonction au lieu de ‘any’. + +Dans certains cas, vous pouvez compter sur l'ordre de l'exécution. Cela s'applique aux cas où SELECT provient d'une sous-requête qui utilise ORDER BY. + +Lorsqu'un `SELECT` la requête a l' `GROUP BY` ou au moins une fonction d'agrégat, ClickHouse (contrairement à MySQL) exige que toutes les expressions du `SELECT`, `HAVING`, et `ORDER BY` clauses être calculée à partir de clés ou de fonctions d'agrégation. En d'autres termes, chaque colonne sélectionnée dans la table doit être utilisée soit dans les clés, soit dans les fonctions d'agrégation. Pour obtenir un comportement comme dans MySQL, vous pouvez mettre les autres colonnes dans le `any` fonction d'agrégation. + +## anyHeavy (x) {#anyheavyx} + +Sélectionne une valeur fréquente à l'aide [poids lourds](http://www.cs.umd.edu/~samir/498/karp.pdf) algorithme. S'il y a une valeur qui se produit plus de la moitié des cas dans chacun des threads d'exécution de la requête, cette valeur est renvoyée. Normalement, le résultat est non déterministe. + +``` sql +anyHeavy(column) +``` + +**Argument** + +- `column` – The column name. + +**Exemple** + +Prendre la [OnTime](../../getting-started/example-datasets/ontime.md) ensemble de données et sélectionnez n'importe quelle valeur `AirlineID` colonne. + +``` sql +SELECT anyHeavy(AirlineID) AS res +FROM ontime +``` + +``` text +┌───res─┐ +│ 19690 │ +└───────┘ +``` + +## anyLast (x) {#anylastx} + +Sélectionne la dernière valeur rencontrés. +Le résultat est tout aussi indéterminé que pour le `any` fonction. + +## groupBitAnd {#groupbitand} + +S'applique au niveau du BIT `AND` pour les séries de nombres. + +``` sql +groupBitAnd(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `UInt*` type. + +**Valeur de retour** + +La valeur de la `UInt*` type. + +**Exemple** + +Des données de Test: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Requête: + +``` sql +SELECT groupBitAnd(num) FROM t +``` + +Où `num` est la colonne avec les données de test. + +Résultat: + +``` text +binary decimal +00000100 = 4 +``` + +## groupBitOr {#groupbitor} + +S'applique au niveau du BIT `OR` pour les séries de nombres. + +``` sql +groupBitOr(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `UInt*` type. + +**Valeur de retour** + +La valeur de la `UInt*` type. + +**Exemple** + +Des données de Test: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Requête: + +``` sql +SELECT groupBitOr(num) FROM t +``` + +Où `num` est la colonne avec les données de test. + +Résultat: + +``` text +binary decimal +01111101 = 125 +``` + +## groupBitXor {#groupbitxor} + +S'applique au niveau du BIT `XOR` pour les séries de nombres. + +``` sql +groupBitXor(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `UInt*` type. + +**Valeur de retour** + +La valeur de la `UInt*` type. + +**Exemple** + +Des données de Test: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Requête: + +``` sql +SELECT groupBitXor(num) FROM t +``` + +Où `num` est la colonne avec les données de test. + +Résultat: + +``` text +binary decimal +01101000 = 104 +``` + +## groupBitmap {#groupbitmap} + +Calculs Bitmap ou agrégés à partir d'une colonne entière non signée, retour cardinalité de type UInt64, si Ajouter suffixe-State, puis retour [objet bitmap](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmap(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `UInt*` type. + +**Valeur de retour** + +La valeur de la `UInt64` type. + +**Exemple** + +Des données de Test: + +``` text +UserID +1 +1 +2 +3 +``` + +Requête: + +``` sql +SELECT groupBitmap(UserID) as num FROM t +``` + +Résultat: + +``` text +num +3 +``` + +## min (x) {#agg_function-min} + +Calcule le minimum. + +## max (x) {#agg_function-max} + +Calcule le maximum. + +## argMin (arg, val) {#agg-function-argmin} + +Calcule la ‘arg’ valeur pour un minimum ‘val’ valeur. S'il y a plusieurs valeurs différentes de ‘arg’ pour des valeurs minimales de ‘val’ la première de ces valeurs rencontrées est de sortie. + +**Exemple:** + +``` text +┌─user─────┬─salary─┐ +│ director │ 5000 │ +│ manager │ 3000 │ +│ worker │ 1000 │ +└──────────┴────────┘ +``` + +``` sql +SELECT argMin(user, salary) FROM salary +``` + +``` text +┌─argMin(user, salary)─┐ +│ worker │ +└──────────────────────┘ +``` + +## argMax(arg, val) {#agg-function-argmax} + +Calcule la ‘arg’ valeur pour un maximum ‘val’ valeur. S'il y a plusieurs valeurs différentes de ‘arg’ pour les valeurs maximales de ‘val’ la première de ces valeurs rencontrées est de sortie. + +## sum(x) {#agg_function-sum} + +Calcule la somme. +Ne fonctionne que pour les numéros. + +## sumWithOverflow (x) {#sumwithoverflowx} + +Calcule la somme des nombres, en utilisant le même type de données pour le résultat que pour les paramètres d'entrée. Si la somme dépasse la valeur maximale pour ce type de données, la fonction renvoie une erreur. + +Ne fonctionne que pour les numéros. + +## sumMap(clé, valeur), sumMap(Tuple(clé, valeur)) {#agg_functions-summap} + +Les totaux de la ‘value’ tableau selon les clés spécifiés dans le ‘key’ tableau. +Le passage du tuple des tableaux de clés et de valeurs est synonyme du passage de deux tableaux de clés et de valeurs. +Le nombre d'éléments dans ‘key’ et ‘value’ doit être identique pour chaque ligne totalisée. +Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. + +Exemple: + +``` sql +CREATE TABLE sum_map( + date Date, + timeslot DateTime, + statusMap Nested( + status UInt16, + requests UInt64 + ), + statusMapTuple Tuple(Array(Int32), Array(Int32)) +) ENGINE = Log; +INSERT INTO sum_map VALUES + ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10], ([1, 2, 3], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10], ([3, 4, 5], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10], ([4, 5, 6], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10])); + +SELECT + timeslot, + sumMap(statusMap.status, statusMap.requests), + sumMap(statusMapTuple) +FROM sum_map +GROUP BY timeslot +``` + +``` text +┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┬─sumMap(statusMapTuple)─────────┐ +│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ ([1,2,3,4,5],[10,10,20,10,10]) │ +│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ ([4,5,6,7,8],[10,10,20,10,10]) │ +└─────────────────────┴──────────────────────────────────────────────┴────────────────────────────────┘ +``` + +## skewPop {#skewpop} + +Calcule la [asymétrie](https://en.wikipedia.org/wiki/Skewness) d'une séquence. + +``` sql +skewPop(expr) +``` + +**Paramètre** + +`expr` — [Expression](../syntax.md#syntax-expressions) retour d'un nombre. + +**Valeur renvoyée** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Exemple** + +``` sql +SELECT skewPop(value) FROM series_with_value_column +``` + +## skewSamp {#skewsamp} + +Calcule la [asymétrie de l'échantillon](https://en.wikipedia.org/wiki/Skewness) d'une séquence. + +Il représente une estimation non biaisée de l'asymétrie d'une variable aléatoire si les valeurs passées forme de son échantillon. + +``` sql +skewSamp(expr) +``` + +**Paramètre** + +`expr` — [Expression](../syntax.md#syntax-expressions) retour d'un nombre. + +**Valeur renvoyée** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). Si `n <= 1` (`n` est la taille de l'échantillon), alors la fonction renvoie `nan`. + +**Exemple** + +``` sql +SELECT skewSamp(value) FROM series_with_value_column +``` + +## kurtPop {#kurtpop} + +Calcule la [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) d'une séquence. + +``` sql +kurtPop(expr) +``` + +**Paramètre** + +`expr` — [Expression](../syntax.md#syntax-expressions) retour d'un nombre. + +**Valeur renvoyée** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Exemple** + +``` sql +SELECT kurtPop(value) FROM series_with_value_column +``` + +## kurtSamp {#kurtsamp} + +Calcule la [l'échantillon le coefficient d'aplatissement](https://en.wikipedia.org/wiki/Kurtosis) d'une séquence. + +Il représente une estimation non biaisée de la kurtose d'une variable aléatoire si les valeurs passées forment son échantillon. + +``` sql +kurtSamp(expr) +``` + +**Paramètre** + +`expr` — [Expression](../syntax.md#syntax-expressions) retour d'un nombre. + +**Valeur renvoyée** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). Si `n <= 1` (`n` la taille de l'échantillon), alors la fonction renvoie `nan`. + +**Exemple** + +``` sql +SELECT kurtSamp(value) FROM series_with_value_column +``` + +## timeSeriesGroupSum(uid, horodatage, valeur) {#agg-function-timeseriesgroupsum} + +`timeSeriesGroupSum` peut agréger différentes séries temporelles qui échantillonnent l'horodatage et non l'alignement. +Il utilisera une interpolation linéaire entre deux échantillons d'horodatage, puis additionnera les séries temporelles ensemble. + +- `uid` la série temporelle est elle unique, `UInt64`. +- `timestamp` est de type Int64 afin de prendre en charge la milliseconde ou la microseconde. +- `value` est la métrique. + +La fonction renvoie un tableau de tuples avec `(timestamp, aggregated_value)` pair. + +Avant d'utiliser cette fonction, assurez-vous `timestamp` est dans l'ordre croissant. + +Exemple: + +``` text +┌─uid─┬─timestamp─┬─value─┐ +│ 1 │ 2 │ 0.2 │ +│ 1 │ 7 │ 0.7 │ +│ 1 │ 12 │ 1.2 │ +│ 1 │ 17 │ 1.7 │ +│ 1 │ 25 │ 2.5 │ +│ 2 │ 3 │ 0.6 │ +│ 2 │ 8 │ 1.6 │ +│ 2 │ 12 │ 2.4 │ +│ 2 │ 18 │ 3.6 │ +│ 2 │ 24 │ 4.8 │ +└─────┴───────────┴───────┘ +``` + +``` sql +CREATE TABLE time_series( + uid UInt64, + timestamp Int64, + value Float64 +) ENGINE = Memory; +INSERT INTO time_series VALUES + (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), + (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); + +SELECT timeSeriesGroupSum(uid, timestamp, value) +FROM ( + SELECT * FROM time_series order by timestamp ASC +); +``` + +Et le résultat sera: + +``` text +[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] +``` + +## timeSeriesGroupRateSum(uid, ts, val) {#agg-function-timeseriesgroupratesum} + +De la même manière à `timeSeriesGroupSum`, `timeSeriesGroupRateSum` calcule le taux de séries chronologiques, puis additionne les taux ensemble. +En outre, l'horodatage doit être dans l'ordre croissant avant d'utiliser cette fonction. + +Application de cette fonction aux données du `timeSeriesGroupSum` exemple, vous obtenez le résultat suivant: + +``` text +[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] +``` + +## avg (x) {#agg_function-avg} + +Calcule la moyenne. +Ne fonctionne que pour les numéros. +Le résultat est toujours Float64. + +## avgWeighted {#avgweighted} + +Calcule la [moyenne arithmétique pondérée](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean). + +**Syntaxe** + +``` sql +avgWeighted(x, weight) +``` + +**Paramètre** + +- `x` — Values. [Entier](../data-types/int-uint.md) ou [virgule flottante](../data-types/float.md). +- `weight` — Weights of the values. [Entier](../data-types/int-uint.md) ou [virgule flottante](../data-types/float.md). + +Type de `x` et `weight` doit être le même. + +**Valeur renvoyée** + +- Moyenne pondérée. +- `NaN`. Si tous les poids sont égaux à 0. + +Type: [Float64](../data-types/float.md). + +**Exemple** + +Requête: + +``` sql +SELECT avgWeighted(x, w) +FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) +``` + +Résultat: + +``` text +┌─avgWeighted(x, weight)─┐ +│ 8 │ +└────────────────────────┘ +``` + +## uniq {#agg_function-uniq} + +Calcule le nombre approximatif des différentes valeurs de l'argument. + +``` sql +uniq(x[, ...]) +``` + +**Paramètre** + +La fonction prend un nombre variable de paramètres. Les paramètres peuvent être `Tuple`, `Array`, `Date`, `DateTime`, `String` ou des types numériques. + +**Valeur renvoyée** + +- A [UInt64](../../sql-reference/data-types/int-uint.md)numéro de type. + +**Détails de mise en œuvre** + +Fonction: + +- Calcule un hachage pour tous les paramètres de l'agrégat, puis l'utilise dans les calculs. + +- Utilise un algorithme d'échantillonnage adaptatif. Pour l'état de calcul, La fonction utilise un échantillon de valeurs de hachage d'éléments jusqu'à 65536. + + This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. + +- Fournit le résultat de manière déterministe (cela ne dépend pas de l'ordre de traitement de la requête). + +Nous vous recommandons d'utiliser cette fonction dans presque tous les scénarios. + +**Voir Aussi** + +- [uniqcombiné](#agg_function-uniqcombined) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqcombiné {#agg_function-uniqcombined} + +Calcule le nombre approximatif de différentes valeurs d'argument. + +``` sql +uniqCombined(HLL_precision)(x[, ...]) +``` + +Le `uniqCombined` la fonction est un bon choix pour calculer le nombre de valeurs différentes. + +**Paramètre** + +La fonction prend un nombre variable de paramètres. Les paramètres peuvent être `Tuple`, `Array`, `Date`, `DateTime`, `String` ou des types numériques. + +`HLL_precision` est le logarithme en base 2 du nombre de cellules dans [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). Facultatif, vous pouvez utiliser la fonction comme `uniqCombined(x[, ...])`. La valeur par défaut pour `HLL_precision` est 17, qui est effectivement 96 Ko d'espace(2 ^ 17 cellules, 6 bits chacune). + +**Valeur renvoyée** + +- Nombre [UInt64](../../sql-reference/data-types/int-uint.md)numéro de type. + +**Détails de mise en œuvre** + +Fonction: + +- Calcule un hachage (hachage 64 bits pour `String` et 32 bits sinon) pour tous les paramètres dans l'agrégat, puis l'utilise dans les calculs. + +- Utilise une combinaison de trois algorithmes: tableau, table de hachage et HyperLogLog avec une table de correction d'erreur. + + For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. + +- Fournit le résultat de manière déterministe (cela ne dépend pas de l'ordre de traitement de la requête). + +!!! note "Note" + Comme il utilise le hachage 32 bits pour non-`String` type, le résultat aura une erreur très élevée pour les cardinalités significativement plus grandes que `UINT_MAX` (erreur va augmenter rapidement après quelques dizaines de milliards de valeurs distinctes), donc dans ce cas, vous devez utiliser [uniqCombined64](#agg_function-uniqcombined64) + +Par rapport à la [uniq](#agg_function-uniq) la fonction, la `uniqCombined`: + +- Consomme plusieurs fois moins de mémoire. +- Calcule avec plusieurs fois plus de précision. +- A généralement des performances légèrement inférieures. Dans certains scénarios, `uniqCombined` peut faire mieux que `uniq` par exemple, avec des requêtes distribuées qui transmettent un grand nombre d'agrégation des états sur le réseau. + +**Voir Aussi** + +- [uniq](#agg_function-uniq) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined64 {#agg_function-uniqcombined64} + +Même que [uniqcombiné](#agg_function-uniqcombined), mais utilise le hachage 64 bits pour tous les types de données. + +## uniqHLL12 {#agg_function-uniqhll12} + +Calcule le nombre approximatif de différentes valeurs d'argument, en utilisant [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) algorithme. + +``` sql +uniqHLL12(x[, ...]) +``` + +**Paramètre** + +La fonction prend un nombre variable de paramètres. Les paramètres peuvent être `Tuple`, `Array`, `Date`, `DateTime`, `String` ou des types numériques. + +**Valeur renvoyée** + +- A [UInt64](../../sql-reference/data-types/int-uint.md)numéro de type. + +**Détails de mise en œuvre** + +Fonction: + +- Calcule un hachage pour tous les paramètres de l'agrégat, puis l'utilise dans les calculs. + +- Utilise L'algorithme HyperLogLog pour approximer le nombre de valeurs d'argument différentes. + + 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). + +- Fournit le résultat déterminé (il ne dépend pas de l'ordre de traitement de la requête). + +Nous ne recommandons pas d'utiliser cette fonction. Dans la plupart des cas, l'utilisation de la [uniq](#agg_function-uniq) ou [uniqcombiné](#agg_function-uniqcombined) fonction. + +**Voir Aussi** + +- [uniq](#agg_function-uniq) +- [uniqcombiné](#agg_function-uniqcombined) +- [uniqExact](#agg_function-uniqexact) + +## uniqExact {#agg_function-uniqexact} + +Calcule le nombre exact de différentes valeurs d'argument. + +``` sql +uniqExact(x[, ...]) +``` + +L'utilisation de la `uniqExact` fonction si vous avez absolument besoin d'un résultat exact. Sinon l'utilisation de la [uniq](#agg_function-uniq) fonction. + +Le `uniqExact` la fonction utilise plus de mémoire que `uniq` parce que la taille de l'état a surabondance de croissance que le nombre de valeurs différentes augmente. + +**Paramètre** + +La fonction prend un nombre variable de paramètres. Les paramètres peuvent être `Tuple`, `Array`, `Date`, `DateTime`, `String` ou des types numériques. + +**Voir Aussi** + +- [uniq](#agg_function-uniq) +- [uniqcombiné](#agg_function-uniqcombined) +- [uniqHLL12](#agg_function-uniqhll12) + +## groupArray(x), groupArray (max\_size) (x) {#agg_function-grouparray} + +Crée un tableau de valeurs de l'argument. +Les valeurs peuvent être ajoutées au tableau dans une (indéterminée) de commande. + +La deuxième version (avec le `max_size` paramètre) limite la taille du tableau résultant à `max_size` élément. +Exemple, `groupArray (1) (x)` est équivalent à `[any (x)]`. + +Dans certains cas, vous pouvez toujours compter sur l'ordre de l'exécution. Cela s'applique aux cas où `SELECT` provient d'une sous-requête qui utilise `ORDER BY`. + +## groupeparrayinsertat {#grouparrayinsertat} + +Insère une valeur dans le tableau à la position spécifiée. + +**Syntaxe** + +``` sql +groupArrayInsertAt(default_x, size)(x, pos); +``` + +Si dans une requête plusieurs valeurs sont insérées dans la même position, la fonction se comporte de la manière suivante: + +- Si une requête est exécutée dans un seul thread, la première des valeurs insérées est utilisée. +- Si une requête est exécutée dans plusieurs threads, le résultat est indéterminé l'une des valeurs insérées. + +**Paramètre** + +- `x` — Value to be inserted. [Expression](../syntax.md#syntax-expressions) résultant dans l'un des [types de données pris en charge](../../sql-reference/data-types/index.md). +- `pos` — Position at which the specified element `x` doit être inséré. L'indice de numérotation dans le tableau commence à partir de zéro. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). +- `default_x`— Default value for substituting in empty positions. Optional parameter. [Expression](../syntax.md#syntax-expressions) résultant dans le type de données configuré pour le `x` paramètre. Si `default_x` n'est pas définie, la [les valeurs par défaut](../../sql-reference/statements/create.md#create-default-values) sont utilisés. +- `size`— Length of the resulting array. Optional parameter. When using this parameter, the default value `default_x` doit être spécifié. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). + +**Valeur renvoyée** + +- Tableau avec des valeurs insérées. + +Type: [Tableau](../../sql-reference/data-types/array.md#data-type-array). + +**Exemple** + +Requête: + +``` sql +SELECT groupArrayInsertAt(toString(number), number * 2) FROM numbers(5); +``` + +Résultat: + +``` text +┌─groupArrayInsertAt(toString(number), multiply(number, 2))─┐ +│ ['0','','1','','2','','3','','4'] │ +└───────────────────────────────────────────────────────────┘ +``` + +Requête: + +``` sql +SELECT groupArrayInsertAt('-')(toString(number), number * 2) FROM numbers(5); +``` + +Résultat: + +``` text +┌─groupArrayInsertAt('-')(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2','-','3','-','4'] │ +└────────────────────────────────────────────────────────────────┘ +``` + +Requête: + +``` sql +SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); +``` + +Résultat: + +``` text +┌─groupArrayInsertAt('-', 5)(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2'] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +Insertion multi-thread d'éléments dans une position. + +Requête: + +``` sql +SELECT groupArrayInsertAt(number, 0) FROM numbers_mt(10) SETTINGS max_block_size = 1; +``` + +Comme un résultat de cette requête, vous obtenez entier aléatoire dans le `[0,9]` gamme. Exemple: + +``` text +┌─groupArrayInsertAt(number, 0)─┐ +│ [7] │ +└───────────────────────────────┘ +``` + +## groupeparraymovingsum {#agg_function-grouparraymovingsum} + +Calcule la somme mobile des valeurs d'entrée. + +``` sql +groupArrayMovingSum(numbers_for_summing) +groupArrayMovingSum(window_size)(numbers_for_summing) +``` + +La fonction peut prendre la taille de la fenêtre comme paramètre. Si spécifié, la fonction prend la taille de la fenêtre égal au nombre de lignes dans la colonne. + +**Paramètre** + +- `numbers_for_summing` — [Expression](../syntax.md#syntax-expressions) résultant en une valeur de type de données Numérique. +- `window_size` — Size of the calculation window. + +**Valeurs renvoyées** + +- Tableau de la même taille et de même type que les données d'entrée. + +**Exemple** + +La table d'échantillon: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Requête: + +``` sql +SELECT + groupArrayMovingSum(int) AS I, + groupArrayMovingSum(float) AS F, + groupArrayMovingSum(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingSum(2)(int) AS I, + groupArrayMovingSum(2)(float) AS F, + groupArrayMovingSum(2)(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +## groupArrayMovingAvg {#agg_function-grouparraymovingavg} + +Calcule la moyenne mobile des valeurs d'entrée. + +``` sql +groupArrayMovingAvg(numbers_for_summing) +groupArrayMovingAvg(window_size)(numbers_for_summing) +``` + +La fonction peut prendre la taille de la fenêtre comme paramètre. Si spécifié, la fonction prend la taille de la fenêtre égal au nombre de lignes dans la colonne. + +**Paramètre** + +- `numbers_for_summing` — [Expression](../syntax.md#syntax-expressions) résultant en une valeur de type de données Numérique. +- `window_size` — Size of the calculation window. + +**Valeurs renvoyées** + +- Tableau de la même taille et de même type que les données d'entrée. + +La fonction utilise [l'arrondi vers zéro](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). Il tronque les décimales insignifiantes pour le type de données résultant. + +**Exemple** + +La table d'échantillon `b`: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Requête: + +``` sql +SELECT + groupArrayMovingAvg(int) AS I, + groupArrayMovingAvg(float) AS F, + groupArrayMovingAvg(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ +│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ +└───────────┴─────────────────────────────────────┴───────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingAvg(2)(int) AS I, + groupArrayMovingAvg(2)(float) AS F, + groupArrayMovingAvg(2)(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ +│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ +└───────────┴──────────────────────────────────┴───────────────────────┘ +``` + +## groupUniqArray(x), groupUniqArray (max\_size) (x) {#groupuniqarrayx-groupuniqarraymax-sizex} + +Crée un tableau à partir de différentes valeurs d'argument. La consommation de mémoire est la même que pour la `uniqExact` fonction. + +La deuxième version (avec le `max_size` paramètre) limite la taille du tableau résultant à `max_size` élément. +Exemple, `groupUniqArray(1)(x)` est équivalent à `[any(x)]`. + +## quantile {#quantile} + +Calcule une approximation [quantile](https://en.wikipedia.org/wiki/Quantile) des données numériques de la séquence. + +Cette fonction s'applique [réservoir d'échantillonnage](https://en.wikipedia.org/wiki/Reservoir_sampling) avec une taille de réservoir jusqu'à 8192 et un générateur de nombres aléatoires pour l'échantillonnage. Le résultat est non-déterministe. Pour obtenir un quantile exact, Utilisez le [quantileExact](#quantileexact) fonction. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantile(level)(expr) +``` + +Alias: `median`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [types de données](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) ou [DateTime](../../sql-reference/data-types/datetime.md). + +**Valeur renvoyée** + +- Approximative de quantiles de niveau spécifié. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) pour l'entrée de type de données numériques. +- [Date](../../sql-reference/data-types/date.md) si les valeurs d'entrée ont le `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) si les valeurs d'entrée ont le `DateTime` type. + +**Exemple** + +Table d'entrée: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Requête: + +``` sql +SELECT quantile(val) FROM t +``` + +Résultat: + +``` text +┌─quantile(val)─┐ +│ 1.5 │ +└───────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileDeterministic {#quantiledeterministic} + +Calcule une approximation [quantile](https://en.wikipedia.org/wiki/Quantile) des données numériques de la séquence. + +Cette fonction s'applique [réservoir d'échantillonnage](https://en.wikipedia.org/wiki/Reservoir_sampling) avec une taille de réservoir jusqu'à 8192 et un algorithme déterministe d'échantillonnage. Le résultat est déterministe. Pour obtenir un quantile exact, Utilisez le [quantileExact](#quantileexact) fonction. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileDeterministic(level)(expr, determinator) +``` + +Alias: `medianDeterministic`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [types de données](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) ou [DateTime](../../sql-reference/data-types/datetime.md). +- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. + +**Valeur renvoyée** + +- Approximative de quantiles de niveau spécifié. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) pour l'entrée de type de données numériques. +- [Date](../../sql-reference/data-types/date.md) si les valeurs d'entrée ont le `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) si les valeurs d'entrée ont le `DateTime` type. + +**Exemple** + +Table d'entrée: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Requête: + +``` sql +SELECT quantileDeterministic(val, 1) FROM t +``` + +Résultat: + +``` text +┌─quantileDeterministic(val, 1)─┐ +│ 1.5 │ +└───────────────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileExact {#quantileexact} + +Exactement calcule l' [quantile](https://en.wikipedia.org/wiki/Quantile) des données numériques de la séquence. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` de mémoire, où `n` est un nombre de valeurs qui ont été passées. Cependant, pour un petit nombre de valeurs, la fonction est très efficace. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileExact(level)(expr) +``` + +Alias: `medianExact`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [types de données](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) ou [DateTime](../../sql-reference/data-types/datetime.md). + +**Valeur renvoyée** + +- Quantiles de niveau spécifié. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) pour l'entrée de type de données numériques. +- [Date](../../sql-reference/data-types/date.md) si les valeurs d'entrée ont le `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) si les valeurs d'entrée ont le `DateTime` type. + +**Exemple** + +Requête: + +``` sql +SELECT quantileExact(number) FROM numbers(10) +``` + +Résultat: + +``` text +┌─quantileExact(number)─┐ +│ 5 │ +└───────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileExactWeighted {#quantileexactweighted} + +Exactement calcule l' [quantile](https://en.wikipedia.org/wiki/Quantile) d'une séquence de données numériques, en tenant compte du poids de chaque élément. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [quantileExact](#quantileexact). Vous pouvez utiliser cette fonction au lieu de `quantileExact` et spécifiez le poids 1. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileExactWeighted(level)(expr, weight) +``` + +Alias: `medianExactWeighted`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [types de données](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) ou [DateTime](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. + +**Valeur renvoyée** + +- Quantiles de niveau spécifié. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) pour l'entrée de type de données numériques. +- [Date](../../sql-reference/data-types/date.md) si les valeurs d'entrée ont le `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) si les valeurs d'entrée ont le `DateTime` type. + +**Exemple** + +Table d'entrée: + +``` text +┌─n─┬─val─┐ +│ 0 │ 3 │ +│ 1 │ 2 │ +│ 2 │ 1 │ +│ 5 │ 4 │ +└───┴─────┘ +``` + +Requête: + +``` sql +SELECT quantileExactWeighted(n, val) FROM t +``` + +Résultat: + +``` text +┌─quantileExactWeighted(n, val)─┐ +│ 1 │ +└───────────────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileTiming {#quantiletiming} + +Avec la précision déterminée calcule le [quantile](https://en.wikipedia.org/wiki/Quantile) des données numériques de la séquence. + +Le résultat est déterministe (il ne dépend pas de l'ordre de traitement de la requête). La fonction est optimisée pour travailler avec des séquences qui décrivent des distributions comme les temps de chargement des pages web ou les temps de réponse du backend. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileTiming(level)(expr) +``` + +Alias: `medianTiming`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). + +- `expr` — [Expression](../syntax.md#syntax-expressions) sur une colonne Valeurs renvoyant un [Flottant\*](../../sql-reference/data-types/float.md)numéro de type. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +**Exactitude** + +Le calcul est précis si: + +- Le nombre Total de valeurs ne dépasse pas 5670. +- Le nombre Total de valeurs dépasse 5670, mais le temps de chargement de la page est inférieur à 1024ms. + +Sinon, le résultat du calcul est arrondi au plus proche multiple de 16 ms. + +!!! note "Note" + Pour calculer les quantiles de temps de chargement de page, cette fonction est plus efficace et précise que [quantile](#quantile). + +**Valeur renvoyée** + +- Quantiles de niveau spécifié. + +Type: `Float32`. + +!!! note "Note" + Si aucune valeur n'est transmise à la fonction (lors de l'utilisation de `quantileTimingIf`), [Nan](../../sql-reference/data-types/float.md#data_type-float-nan-inf) est retourné. Le but est de différencier ces cas de cas qui aboutissent à zéro. Voir [Clause ORDER BY](../statements/select/order-by.md#select-order-by) pour des notes sur le tri `NaN` valeur. + +**Exemple** + +Table d'entrée: + +``` text +┌─response_time─┐ +│ 72 │ +│ 112 │ +│ 126 │ +│ 145 │ +│ 104 │ +│ 242 │ +│ 313 │ +│ 168 │ +│ 108 │ +└───────────────┘ +``` + +Requête: + +``` sql +SELECT quantileTiming(response_time) FROM t +``` + +Résultat: + +``` text +┌─quantileTiming(response_time)─┐ +│ 126 │ +└───────────────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileTimingWeighted {#quantiletimingweighted} + +Avec la précision déterminée calcule le [quantile](https://en.wikipedia.org/wiki/Quantile) d'une séquence de données numériques en fonction du poids de chaque élément de séquence. + +Le résultat est déterministe (il ne dépend pas de l'ordre de traitement de la requête). La fonction est optimisée pour travailler avec des séquences qui décrivent des distributions comme les temps de chargement des pages web ou les temps de réponse du backend. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileTimingWeighted(level)(expr, weight) +``` + +Alias: `medianTimingWeighted`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). + +- `expr` — [Expression](../syntax.md#syntax-expressions) sur une colonne Valeurs renvoyant un [Flottant\*](../../sql-reference/data-types/float.md)numéro de type. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Exactitude** + +Le calcul est précis si: + +- Le nombre Total de valeurs ne dépasse pas 5670. +- Le nombre Total de valeurs dépasse 5670, mais le temps de chargement de la page est inférieur à 1024ms. + +Sinon, le résultat du calcul est arrondi au plus proche multiple de 16 ms. + +!!! note "Note" + Pour calculer les quantiles de temps de chargement de page, cette fonction est plus efficace et précise que [quantile](#quantile). + +**Valeur renvoyée** + +- Quantiles de niveau spécifié. + +Type: `Float32`. + +!!! note "Note" + Si aucune valeur n'est transmise à la fonction (lors de l'utilisation de `quantileTimingIf`), [Nan](../../sql-reference/data-types/float.md#data_type-float-nan-inf) est retourné. Le but est de différencier ces cas de cas qui aboutissent à zéro. Voir [Clause ORDER BY](../statements/select/order-by.md#select-order-by) pour des notes sur le tri `NaN` valeur. + +**Exemple** + +Table d'entrée: + +``` text +┌─response_time─┬─weight─┐ +│ 68 │ 1 │ +│ 104 │ 2 │ +│ 112 │ 3 │ +│ 126 │ 2 │ +│ 138 │ 1 │ +│ 162 │ 1 │ +└───────────────┴────────┘ +``` + +Requête: + +``` sql +SELECT quantileTimingWeighted(response_time, weight) FROM t +``` + +Résultat: + +``` text +┌─quantileTimingWeighted(response_time, weight)─┐ +│ 112 │ +└───────────────────────────────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileTDigest {#quantiletdigest} + +Calcule une approximation [quantile](https://en.wikipedia.org/wiki/Quantile) d'une séquence de données numériques utilisant [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algorithme. + +L'erreur maximale est de 1%. La consommation de mémoire est `log(n)`, où `n` est un certain nombre de valeurs. Le résultat dépend de l'ordre d'exécution de la requête et n'est pas déterministe. + +La performance de la fonction est inférieure à la performance de [quantile](#quantile) ou [quantileTiming](#quantiletiming). En termes de rapport entre la taille de L'état et la précision, cette fonction est bien meilleure que `quantile`. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileTDigest(level)(expr) +``` + +Alias: `medianTDigest`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [types de données](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) ou [DateTime](../../sql-reference/data-types/datetime.md). + +**Valeur renvoyée** + +- Approximative de quantiles de niveau spécifié. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) pour l'entrée de type de données numériques. +- [Date](../../sql-reference/data-types/date.md) si les valeurs d'entrée ont le `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) si les valeurs d'entrée ont le `DateTime` type. + +**Exemple** + +Requête: + +``` sql +SELECT quantileTDigest(number) FROM numbers(10) +``` + +Résultat: + +``` text +┌─quantileTDigest(number)─┐ +│ 4.5 │ +└─────────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## quantileTDigestWeighted {#quantiletdigestweighted} + +Calcule une approximation [quantile](https://en.wikipedia.org/wiki/Quantile) d'une séquence de données numériques utilisant [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algorithme. La fonction prend en compte le poids de chaque séquence de membre. L'erreur maximale est de 1%. La consommation de mémoire est `log(n)`, où `n` est un certain nombre de valeurs. + +La performance de la fonction est inférieure à la performance de [quantile](#quantile) ou [quantileTiming](#quantiletiming). En termes de rapport entre la taille de L'état et la précision, cette fonction est bien meilleure que `quantile`. + +Le résultat dépend de l'ordre d'exécution de la requête et n'est pas déterministe. + +Lorsque vous utilisez plusieurs `quantile*` fonctionne avec différents niveaux dans une requête, les états internes ne sont pas combinées (qui est, la requête fonctionne moins efficacement qu'il le pouvait). Dans ce cas, utilisez la [les quantiles](#quantiles) fonction. + +**Syntaxe** + +``` sql +quantileTDigest(level)(expr) +``` + +Alias: `medianTDigest`. + +**Paramètre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` la valeur dans la plage de `[0.01, 0.99]`. Valeur par défaut: 0.5. À `level=0.5` la fonction calcule [médian](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [types de données](../../sql-reference/data-types/index.md#data_types), [Date](../../sql-reference/data-types/date.md) ou [DateTime](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Valeur renvoyée** + +- Approximative de quantiles de niveau spécifié. + +Type: + +- [Float64](../../sql-reference/data-types/float.md) pour l'entrée de type de données numériques. +- [Date](../../sql-reference/data-types/date.md) si les valeurs d'entrée ont le `Date` type. +- [DateTime](../../sql-reference/data-types/datetime.md) si les valeurs d'entrée ont le `DateTime` type. + +**Exemple** + +Requête: + +``` sql +SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) +``` + +Résultat: + +``` text +┌─quantileTDigestWeighted(number, 1)─┐ +│ 4.5 │ +└────────────────────────────────────┘ +``` + +**Voir Aussi** + +- [médian](#median) +- [les quantiles](#quantiles) + +## médian {#median} + +Le `median*` les fonctions sont les Alias pour le correspondant `quantile*` fonction. Ils calculent la médiane d'un échantillon de données numériques. + +Fonction: + +- `median` — Alias for [quantile](#quantile). +- `medianDeterministic` — Alias for [quantileDeterministic](#quantiledeterministic). +- `medianExact` — Alias for [quantileExact](#quantileexact). +- `medianExactWeighted` — Alias for [quantileExactWeighted](#quantileexactweighted). +- `medianTiming` — Alias for [quantileTiming](#quantiletiming). +- `medianTimingWeighted` — Alias for [quantileTimingWeighted](#quantiletimingweighted). +- `medianTDigest` — Alias for [quantileTDigest](#quantiletdigest). +- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](#quantiletdigestweighted). + +**Exemple** + +Table d'entrée: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Requête: + +``` sql +SELECT medianDeterministic(val, 1) FROM t +``` + +Résultat: + +``` text +┌─medianDeterministic(val, 1)─┐ +│ 1.5 │ +└─────────────────────────────┘ +``` + +## quantiles(level1, level2, …)(x) {#quantiles} + +Toutes les fonctions quantiles ont également des fonctions quantiles correspondantes: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. Ces fonctions calculent tous les quantiles des niveaux listés en une seule passe et renvoient un tableau des valeurs résultantes. + +## varSamp (x) {#varsampx} + +Calcule le montant `Σ((x - x̅)^2) / (n - 1)`, où `n` est la taille de l'échantillon et `x̅`est la valeur moyenne de `x`. + +Il représente une estimation non biaisée de la variance d'une variable aléatoire si les valeurs passées forment son échantillon. + +Retourner `Float64`. Lorsque `n <= 1`, retourner `+∞`. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `varSampStable` fonction. Il fonctionne plus lentement, mais fournit une erreur de calcul inférieure. + +## varPop (x) {#varpopx} + +Calcule le montant `Σ((x - x̅)^2) / n`, où `n` est la taille de l'échantillon et `x̅`est la valeur moyenne de `x`. + +En d'autres termes, dispersion pour un ensemble de valeurs. Retourner `Float64`. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `varPopStable` fonction. Il fonctionne plus lentement, mais fournit une erreur de calcul inférieure. + +## stddevSamp (x) {#stddevsampx} + +Le résultat est égal à la racine carrée de `varSamp(x)`. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `stddevSampStable` fonction. Il fonctionne plus lentement, mais fournit une erreur de calcul inférieure. + +## stddevPop (x) {#stddevpopx} + +Le résultat est égal à la racine carrée de `varPop(x)`. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `stddevPopStable` fonction. Il fonctionne plus lentement, mais fournit une erreur de calcul inférieure. + +## topK (N) (x) {#topknx} + +Renvoie un tableau des valeurs approximativement les plus fréquentes dans la colonne spécifiée. Le tableau est trié par ordre décroissant de fréquence approximative des valeurs (et non par les valeurs elles-mêmes). + +Met en œuvre la [Gain De Place Filtré](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) algorithme d'analyse de TopK, basé sur l'algorithme de réduction et de combinaison de [Économie D'Espace Parallèle](https://arxiv.org/pdf/1401.0702.pdf). + +``` sql +topK(N)(column) +``` + +Cette fonction ne fournit pas un résultat garanti. Dans certaines situations, des erreurs peuvent se produire et renvoyer des valeurs fréquentes qui ne sont pas les valeurs les plus fréquentes. + +Nous vous recommandons d'utiliser l' `N < 10` valeur; performance est réduite avec grand `N` valeur. Valeur maximale de `N = 65536`. + +**Paramètre** + +- ‘N’ est le nombre d'éléments de retour. + +Si le paramètre est omis, la valeur par défaut 10 est utilisé. + +**Argument** + +- ' x ' – The value to calculate frequency. + +**Exemple** + +Prendre la [OnTime](../../getting-started/example-datasets/ontime.md) ensemble de données et sélectionnez les trois valeurs les plus fréquentes `AirlineID` colonne. + +``` sql +SELECT topK(3)(AirlineID) AS res +FROM ontime +``` + +``` text +┌─res─────────────────┐ +│ [19393,19790,19805] │ +└─────────────────────┘ +``` + +## topKWeighted {#topkweighted} + +Semblable à `topK` mais prend un argument de type entier - `weight`. Chaque valeur est comptabilisée `weight` les temps de calcul de fréquence. + +**Syntaxe** + +``` sql +topKWeighted(N)(x, weight) +``` + +**Paramètre** + +- `N` — The number of elements to return. + +**Argument** + +- `x` – The value. +- `weight` — The weight. [UInt8](../../sql-reference/data-types/int-uint.md). + +**Valeur renvoyée** + +Renvoie un tableau des valeurs avec la somme approximative maximale des poids. + +**Exemple** + +Requête: + +``` sql +SELECT topKWeighted(10)(number, number) FROM numbers(1000) +``` + +Résultat: + +``` text +┌─topKWeighted(10)(number, number)──────────┐ +│ [999,998,997,996,995,994,993,992,991,990] │ +└───────────────────────────────────────────┘ +``` + +## covarSamp(x, y) {#covarsampx-y} + +Calcule la valeur de `Σ((x - x̅)(y - y̅)) / (n - 1)`. + +Renvoie Float64. Lorsque `n <= 1`, returns +∞. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `covarSampStable` fonction. Il fonctionne plus lentement, mais fournit une erreur de calcul inférieure. + +## covarPop (x, y) {#covarpopx-y} + +Calcule la valeur de `Σ((x - x̅)(y - y̅)) / n`. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `covarPopStable` fonction. Cela fonctionne plus lentement mais fournit une erreur de calcul inférieure. + +## corr (x, y) {#corrx-y} + +Calcule le coefficient de corrélation de Pearson: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. + +!!! note "Note" + Cette fonction utilise un algorithme numériquement instable. Si vous avez besoin d' [stabilité numérique](https://en.wikipedia.org/wiki/Numerical_stability) dans les calculs, utiliser le `corrStable` fonction. Il fonctionne plus lentement, mais fournit une erreur de calcul inférieure. + +## categoricalInformationValue {#categoricalinformationvalue} + +Calcule la valeur de `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` pour chaque catégorie. + +``` sql +categoricalInformationValue(category1, category2, ..., tag) +``` + +Le résultat indique comment une caractéristique discrète (catégorique) `[category1, category2, ...]` contribuer à un modèle d'apprentissage qui prédit la valeur de `tag`. + +## simplelineearregression {#simplelinearregression} + +Effectue une régression linéaire simple (unidimensionnelle). + +``` sql +simpleLinearRegression(x, y) +``` + +Paramètre: + +- `x` — Column with dependent variable values. +- `y` — Column with explanatory variable values. + +Valeurs renvoyées: + +Constant `(a, b)` de la ligne `y = a*x + b`. + +**Exemple** + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ +│ (1,0) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ +│ (1,3) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## stochasticLinearRegression {#agg_functions-stochasticlinearregression} + +Cette fonction implémente la régression linéaire stochastique. Il prend en charge les paramètres personnalisés pour le taux d'apprentissage, le coefficient de régularisation L2, la taille de mini-lot et a peu de méthodes pour mettre à jour les poids ([Adam](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (utilisé par défaut), [simple SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [Élan](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). + +### Paramètre {#agg_functions-stochasticlinearregression-parameters} + +Il y a 4 paramètres personnalisables. Ils sont passés à la fonction séquentiellement, mais il n'est pas nécessaire de passer tous les quatre-les valeurs par défaut seront utilisées, mais un bon modèle nécessite un réglage des paramètres. + +``` text +stochasticLinearRegression(1.0, 1.0, 10, 'SGD') +``` + +1. `learning rate` est le coefficient sur la longueur de l'étape, lorsque l'étape de descente de gradient est effectuée. Un taux d'apprentissage trop élevé peut entraîner des poids infinis du modèle. Par défaut est `0.00001`. +2. `l2 regularization coefficient` ce qui peut aider à éviter le surajustement. Par défaut est `0.1`. +3. `mini-batch size` définit le nombre d'éléments, dont les gradients seront calculés et additionnés pour effectuer une étape de descente de gradient. La descente stochastique Pure utilise un élément, mais avoir de petits lots (environ 10 éléments) rend les étapes de gradient plus stables. Par défaut est `15`. +4. `method for updating weights` ils sont: `Adam` (par défaut), `SGD`, `Momentum`, `Nesterov`. `Momentum` et `Nesterov` nécessitent un peu plus de calculs et de mémoire, mais ils sont utiles en termes de vitesse de convergence et de stabilité des méthodes de gradient stochastique. + +### Utilisation {#agg_functions-stochasticlinearregression-usage} + +`stochasticLinearRegression` est utilisé en deux étapes: ajustement du modèle et prédiction sur de nouvelles données. Afin de correspondre le modèle et l'enregistrer son état pour utilisation ultérieure nous utilisons `-State` combinator, qui enregistre essentiellement l'état (poids du modèle, etc.). +Pour prédire nous utilisons la fonction [evalMLMethod](../functions/machine-learning-functions.md#machine_learning_methods-evalmlmethod) qui prend un état comme un argument ainsi que des fonctionnalités à prévoir sur. + + + +**1.** Raccord + +Une telle requête peut être utilisé. + +``` sql +CREATE TABLE IF NOT EXISTS train_data +( + param1 Float64, + param2 Float64, + target Float64 +) ENGINE = Memory; + +CREATE TABLE your_model ENGINE = Memory AS SELECT +stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) +AS state FROM train_data; +``` + +Ici, nous devons également insérer des données dans `train_data` table. Le nombre de paramètres n'est pas fixe, il dépend uniquement du nombre d'arguments, passés dans `linearRegressionState`. Ils doivent tous être des valeurs numériques. +Notez que la colonne avec la valeur cible (que nous aimerions apprendre à prédire) est insérée comme premier argument. + +**2.** Prédire + +Après avoir enregistré un État dans la table, nous pouvons l'utiliser plusieurs fois pour la prédiction, ou même fusionner avec d'autres États et créer de nouveaux modèles encore meilleurs. + +``` sql +WITH (SELECT state FROM your_model) AS model SELECT +evalMLMethod(model, param1, param2) FROM test_data +``` + +La requête renvoie une colonne de valeurs prédites. Notez que le premier argument de `evalMLMethod` être `AggregateFunctionState` objet, sont ensuite des colonnes de fonctionnalités. + +`test_data` est un tableau comme `train_data` mais peut ne pas contenir de valeur cible. + +### Note {#agg_functions-stochasticlinearregression-notes} + +1. Pour fusionner deux modèles l'utilisateur peut créer une telle requête: + `sql SELECT state1 + state2 FROM your_models` + où `your_models` le tableau contient les deux modèles. Cette requête renvoie la nouvelle `AggregateFunctionState` objet. + +2. L'utilisateur peut récupérer les poids du modèle pour ses propres fins, sans enregistrer le modèle, si aucune `-State` combinator est utilisé. + `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` + Une telle requête s'adaptera au Modèle et retournera ses poids-d'abord sont des poids, qui correspondent aux paramètres du modèle, le dernier est un biais. Ainsi, dans l'exemple ci-dessus, la requête renvoie une colonne avec 3 valeurs. + +**Voir Aussi** + +- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) +- [Différence entre les régressions linéaires et logistiques](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} + +Cette fonction implémente la régression logistique stochastique. Il peut être utilisé pour le problème de classification binaire, prend en charge les mêmes paramètres personnalisés que stochasticLinearRegression et fonctionne de la même manière. + +### Paramètre {#agg_functions-stochasticlogisticregression-parameters} + +Les paramètres sont exactement les mêmes que dans stochasticLinearRegression: +`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. +Pour plus d'informations, voir [paramètre](#agg_functions-stochasticlinearregression-parameters). + +``` text +stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') +``` + +1. Raccord + + + + See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. + + Predicted labels have to be in \[-1, 1\]. + +1. Prédire + + + + Using saved state we can predict probability of object having label `1`. + + ``` sql + WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) FROM test_data + ``` + + The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. + + We can also set a bound of probability, which assigns elements to different labels. + + ``` sql + SELECT ans < 1.1 AND ans > 0.5 FROM + (WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) AS ans FROM test_data) + ``` + + Then the result will be labels. + + `test_data` is a table like `train_data` but may not contain target value. + +**Voir Aussi** + +- [stochasticLinearRegression](#agg_functions-stochasticlinearregression) +- [Différence entre les régressions linéaires et logistiques.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## groupBitmapAnd {#groupbitmapand} + +Calculs le et d'une colonne bitmap, retour cardinalité de type UInt64, si Ajouter suffixe-État, puis retour [objet bitmap](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapAnd(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` type. + +**Valeur de retour** + +La valeur de la `UInt64` type. + +**Exemple** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapAnd(z)─┐ +│ 3 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ +│ [6,8,10] │ +└──────────────────────────────────────────────────┘ +``` + +## groupBitmapOr {#groupbitmapor} + +Calculs le ou d'une colonne bitmap, retour cardinalité de type UInt64, si Ajouter suffixe-État, puis retour [objet bitmap](../../sql-reference/functions/bitmap-functions.md). C'est l'équivalent de `groupBitmapMerge`. + +``` sql +groupBitmapOr(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` type. + +**Valeur de retour** + +La valeur de la `UInt64` type. + +**Exemple** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapOr(z)─┐ +│ 15 │ +└──────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ +│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ +└─────────────────────────────────────────────────┘ +``` + +## groupBitmapXor {#groupbitmapxor} + +Calculs le XOR d'une colonne bitmap, retour cardinalité de type UInt64, si Ajouter suffixe-État, puis retour [objet bitmap](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapOr(expr) +``` + +**Paramètre** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` type. + +**Valeur de retour** + +La valeur de la `UInt64` type. + +**Exemple** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapXor(z)─┐ +│ 10 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ +│ [1,3,5,6,8,10,11,13,14,15] │ +└──────────────────────────────────────────────────┘ +``` + +[Article Original](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/fr/sql-reference/ansi.md b/docs/fr/sql-reference/ansi.md new file mode 100644 index 00000000000..8fa5e272085 --- /dev/null +++ b/docs/fr/sql-reference/ansi.md @@ -0,0 +1,180 @@ +--- +machine_translated: true +machine_translated_rev: ad252bbb4f7e2899c448eb42ecc39ff195c8faa1 +toc_priority: 40 +toc_title: "La Compatibilit\xE9 ANSI" +--- + +# Compatibilité ANSI SQL du dialecte CLICKHOUSE SQL {#ansi-sql-compatibility-of-clickhouse-sql-dialect} + +!!! note "Note" + Cet article s'appuie sur le tableau 38, “Feature taxonomy and definition for mandatory features”, Annex F of ISO/IEC CD 9075-2:2013. + +## Différences de comportement {#differences-in-behaviour} + +Le tableau suivant répertorie les cas où la fonctionnalité de requête fonctionne dans ClickHouse, mais ne se comporte pas comme spécifié dans ANSI SQL. + +| Feature ID | Nom De La Fonctionnalité | Différence | +|------------|-------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| +| E011 | Types de données numériques | Le littéral numérique avec période est interprété comme approximatif (`Float64`) au lieu de exact (`Decimal`) | +| E051-05 | Les éléments sélectionnés peuvent être renommés | Les renommages d'élément ont une portée de visibilité plus large que le simple résultat de sélection | +| E141-01 | Contraintes non nulles | `NOT NULL` est implicite pour les colonnes de table par défaut | +| E011-04 | Opérateurs arithmétiques | Clickhouse déborde au lieu de l'arithmétique vérifiée et modifie le type de données de résultat en fonction des règles personnalisées | + +## Fonction D'État {#feature-status} + +| Feature ID | Nom De La Fonctionnalité | Statut | Commentaire | +|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **E011** | **Types de données numériques** | **Partiel**{.text-warning} | | +| E011-01 | Types de données INTEGER et SMALLINT | Oui{.text-success} | | +| E011-02 | Types de données réel, double précision et flottant types de données | Partiel{.text-warning} | `FLOAT()`, `REAL` et `DOUBLE PRECISION` ne sont pas pris en charge | +| E011-03 | Types de données décimales et numériques | Partiel{.text-warning} | Seulement `DECIMAL(p,s)` est pris en charge, pas `NUMERIC` | +| E011-04 | Opérateurs arithmétiques | Oui{.text-success} | | +| E011-05 | Comparaison numérique | Oui{.text-success} | | +| E011-06 | Casting implicite parmi les types de données numériques | Aucun{.text-danger} | ANSI SQL permet la distribution implicite arbitraire entre les types numériques, tandis que ClickHouse repose sur des fonctions ayant plusieurs surcharges au lieu de la distribution implicite | +| **E021** | **Types de chaînes de caractères** | **Partiel**{.text-warning} | | +| E021-01 | Type de données CARACTÈRE | Aucun{.text-danger} | | +| E021-02 | TYPE DE DONNÉES variable de caractère | Aucun{.text-danger} | `String` se comporte de la même manière, mais sans limite de longueur entre parenthèses | +| E021-03 | Littéraux de caractères | Partiel{.text-warning} | Aucune concaténation automatique de littéraux consécutifs et prise en charge du jeu de caractères | +| E021-04 | Fonction CHARACTER\_LENGTH | Partiel{.text-warning} | Aucun `USING` clause | +| E021-05 | Fonction OCTET\_LENGTH | Aucun{.text-danger} | `LENGTH` se comporte de la même façon | +| E021-06 | SUBSTRING | Partiel{.text-warning} | Pas de support pour `SIMILAR` et `ESCAPE` clauses, pas de `SUBSTRING_REGEX` variante | +| E021-07 | Concaténation de caractères | Partiel{.text-warning} | Aucun `COLLATE` clause | +| E021-08 | Fonctions supérieures et inférieures | Oui{.text-success} | | +| E021-09 | La fonction TRIM | Oui{.text-success} | | +| E021-10 | Conversion implicite entre les types de chaînes de caractères de longueur fixe et de longueur variable | Aucun{.text-danger} | ANSI SQL permet la distribution implicite arbitraire entre les types de chaîne, tandis que ClickHouse repose sur des fonctions ayant plusieurs surcharges au lieu de la distribution implicite | +| E021-11 | La POSITION de la fonction | Partiel{.text-warning} | Pas de support pour `IN` et `USING` clauses, pas de `POSITION_REGEX` variante | +| E021-12 | Comparaison de caractères | Oui{.text-success} | | +| **E031** | **Identificateur** | **Partiel**{.text-warning} | | +| E031-01 | Identificateurs délimités | Partiel{.text-warning} | Le support littéral Unicode est limité | +| E031-02 | Identificateurs minuscules | Oui{.text-success} | | +| E031-03 | Fuite de soulignement | Oui{.text-success} | | +| **E051** | **Spécification de requête de base** | **Partiel**{.text-warning} | | +| E051-01 | SELECT DISTINCT | Oui{.text-success} | | +| E051-02 | Groupe par clause | Oui{.text-success} | | +| E051-04 | GROUP BY peut contenir des colonnes `` | はい。{.text-success} | | +| E051-05 | 選択した項目の名前を変更できます | はい。{.text-success} | | +| E051-06 | 句を持つ | はい。{.text-success} | | +| E051-07 | 選択リストの修飾\* | はい。{.text-success} | | +| E051-08 | FROM句の相関名 | はい。{.text-success} | | +| E051-09 | FROM句の列の名前を変更します | いいえ。{.text-danger} | | +| **E061** | **基本的な述語と検索条件** | **部分的**{.text-warning} | | +| E061-01 | 比較述語 | はい。{.text-success} | | +| E061-02 | 述語の間 | 部分的{.text-warning} | いいえ。 `SYMMETRIC` と `ASYMMETRIC` 句 | +| E061-03 | 値のリストを持つ述語で | はい。{.text-success} | | +| E061-04 | 述語のように | はい。{.text-success} | | +| E061-05 | LIKE述語:エスケープ句 | いいえ。{.text-danger} | | +| E061-06 | Null述語 | はい。{.text-success} | | +| E061-07 | 定量化された比較述語 | いいえ。{.text-danger} | | +| E061-08 | 存在する述語 | いいえ。{.text-danger} | | +| E061-09 | 比較述語のサブクエリ | はい。{.text-success} | | +| E061-11 | In述語のサブクエリ | はい。{.text-success} | | +| E061-12 | 定量化された比較述語のサブクエリ | いいえ。{.text-danger} | | +| E061-13 | 相関サブクエリ | いいえ。{.text-danger} | | +| E061-14 | 検索条件 | はい。{.text-success} | | +| **E071** | **基本的なクエリ式** | **部分的**{.text-warning} | | +| E071-01 | UNION DISTINCTテーブル演算子 | いいえ。{.text-danger} | | +| E071-02 | UNION ALLテーブル演算子 | はい。{.text-success} | | +| E071-03 | DISTINCTテーブル演算子を除く | いいえ。{.text-danger} | | +| E071-05 | 列の結合経由でテーブル事業者の必要のない全く同じデータ型 | はい。{.text-success} | | +| E071-06 | サブクエリ内のテーブル演算子 | はい。{.text-success} | | +| **E081** | **基本権限** | **部分的**{.text-warning} | 進行中の作業 | +| **E091** | **関数の設定** | **はい。**{.text-success} | | +| E091-01 | AVG | はい。{.text-success} | | +| E091-02 | COUNT | はい。{.text-success} | | +| E091-03 | MAX | はい。{.text-success} | | +| E091-04 | MIN | はい。{.text-success} | | +| E091-05 | SUM | はい。{.text-success} | | +| E091-06 | すべての量指定子 | いいえ。{.text-danger} | | +| E091-07 | 異なる量指定子 | 部分的{.text-warning} | な集計機能に対応 | +| **E101** | **基本的なデータ操作** | **部分的**{.text-warning} | | +| E101-01 | INSERT文 | はい。{.text-success} | 注:ClickHouseの主キーは、 `UNIQUE` 制約 | +| E101-03 | 検索されたUPDATE文 | いいえ。{.text-danger} | そこには `ALTER UPDATE` バッチデータ変更のための命令 | +| E101-04 | 検索されたDELETE文 | いいえ。{.text-danger} | そこには `ALTER DELETE` バッチデータ削除のための命令 | +| **E111** | **単一行SELECTステートメント** | **いいえ。**{.text-danger} | | +| **E121** | **基本的にカーソルを支援** | **いいえ。**{.text-danger} | | +| E121-01 | DECLARE CURSOR | いいえ。{.text-danger} | | +| E121-02 | ORDER BY列を選択リストに含める必要はありません | いいえ。{.text-danger} | | +| E121-03 | ORDER BY句の値式 | いいえ。{.text-danger} | | +| E121-04 | 開いた声明 | いいえ。{.text-danger} | | +| E121-06 | 位置付きUPDATE文 | いいえ。{.text-danger} | | +| E121-07 | 位置づけDELETEステートメント | いいえ。{.text-danger} | | +| E121-08 | 閉じる文 | いいえ。{.text-danger} | | +| E121-10 | FETCHステートメント:暗黙的なNEXT | いいえ。{.text-danger} | | +| E121-17 | ホールドカーソル付き | いいえ。{.text-danger} | | +| **E131** | **Null値のサポート(値の代わりにnull)** | **部分的**{.text-warning} | 一部の制限が適用されます | +| **E141** | **基本的な整合性制約** | **部分的**{.text-warning} | | +| E141-01 | NULLでない制約 | はい。{.text-success} | 注: `NOT NULL` は黙示のためのテーブル列によるデフォルト | +| E141-02 | NULLでない列の一意制約 | いいえ。{.text-danger} | | +| E141-03 | 主キー制約 | いいえ。{.text-danger} | | +| E141-04 | 参照削除アクションと参照updateアクションの両方に対するNO ACTIONのデフォルトを持つ基本外部キー制約 | いいえ。{.text-danger} | | +| E141-06 | 制約のチェック | はい。{.text-success} | | +| E141-07 | 列の既定値 | はい。{.text-success} | | +| E141-08 | 主キーで推論されるNULLではありません | はい。{.text-success} | | +| E141-10 | 外部キーの名前は任意の順序で指定できます | いいえ。{.text-danger} | | +| **E151** | **取引サポート** | **いいえ。**{.text-danger} | | +| E151-01 | COMMIT文 | いいえ。{.text-danger} | | +| E151-02 | ROLLBACKステートメント | いいえ。{.text-danger} | | +| **E152** | **基本セット取引明細書** | **いいえ。**{.text-danger} | | +| E152-01 | SET TRANSACTION文:分離レベルSERIALIZABLE句 | いいえ。{.text-danger} | | +| E152-02 | SET TRANSACTION文:READ ONLY句とREAD WRITE句 | いいえ。{.text-danger} | | +| **E153** | **サブクエリを使用した更新可能なクエリ** | **いいえ。**{.text-danger} | | +| **E161** | **先頭のdouble minusを使用したSQLコメント** | **はい。**{.text-success} | | +| **E171** | **SQLSTATEサポート** | **いいえ。**{.text-danger} | | +| **E182** | **ホスト言語バインド** | **いいえ。**{.text-danger} | | +| **F031** | **基本的なスキーマ操作** | **部分的**{.text-warning} | | +| F031-01 | 永続ベーステーブルを作成するCREATE TABLE文 | 部分的{.text-warning} | いいえ。 `SYSTEM VERSIONING`, `ON COMMIT`, `GLOBAL`, `LOCAL`, `PRESERVE`, `DELETE`, `REF IS`, `WITH OPTIONS`, `UNDER`, `LIKE`, `PERIOD FOR` 句およびユーザー解決データ型のサポートなし | +| F031-02 | CREATE VIEW文 | 部分的{.text-warning} | いいえ。 `RECURSIVE`, `CHECK`, `UNDER`, `WITH OPTIONS` 句およびユーザー解決データ型のサポートなし | +| F031-03 | グラント声明 | はい。{.text-success} | | +| F031-04 | ALTER TABLE文:ADD COLUMN句 | 部分的{.text-warning} | サポートなし `GENERATED` 節およびシステム期間 | +| F031-13 | DROP TABLE文:RESTRICT句 | いいえ。{.text-danger} | | +| F031-16 | DROP VIEW文:RESTRICT句 | いいえ。{.text-danger} | | +| F031-19 | REVOKEステートメント:RESTRICT句 | いいえ。{.text-danger} | | +| **F041** | **基本的な結合テーブル** | **部分的**{.text-warning} | | +| F041-01 | Inner join必ずというわけではないが、内側のキーワード) | はい。{.text-success} | | +| F041-02 | 内部キーワード | はい。{.text-success} | | +| F041-03 | LEFT OUTER JOIN | はい。{.text-success} | | +| F041-04 | RIGHT OUTER JOIN | はい。{.text-success} | | +| F041-05 | 外部結合は入れ子にできます | はい。{.text-success} | | +| F041-07 | 左外部結合または右外部結合の内部テーブルは、内部結合でも使用できます | はい。{.text-success} | | +| F041-08 | すべての比較演算子がサポ) | いいえ。{.text-danger} | | +| **F051** | **基本日時** | **部分的**{.text-warning} | | +| F051-01 | 日付データ型(日付リテラルのサポートを含む) | 部分的{.text-warning} | リテラルなし | +| F051-02 | 秒の小数部の精度が0以上の時刻データ型(時刻リテラルのサポートを含む) | いいえ。{.text-danger} | | +| F051-03 | タイムスタンプのデータ型を含む支援のタイムスタンプ文字と小数点以下の秒の精度で少なくとも0-6 | いいえ。{.text-danger} | `DateTime64` timeは同様の機能を提供します | +| F051-04 | 日付、時刻、およびタイムスタンプのデータ型の比較述語 | 部分的{.text-warning} | 使用可能なデータ型は一つだけです | +| F051-05 | Datetime型と文字列型の間の明示的なキャスト | はい。{.text-success} | | +| F051-06 | CURRENT\_DATE | いいえ。{.text-danger} | `today()` 似ています | +| F051-07 | LOCALTIME | いいえ。{.text-danger} | `now()` 似ています | +| F051-08 | LOCALTIMESTAMP | いいえ。{.text-danger} | | +| **F081** | **ビュー内の組合および除く** | **部分的**{.text-warning} | | +| **F131** | **グループ化操作** | **部分的**{.text-warning} | | +| F131-01 | ここで、グループにより、条項対応してクエリを処理するクラウドの場合グ眺望 | はい。{.text-success} | | +| F131-02 | グループ化されたビュ | はい。{.text-success} | | +| F131-03 | セット機能に対応してクエリを処理するクラウドの場合グ眺望 | はい。{.text-success} | | +| F131-04 | GROUP BY句とHAVING句およびグループ化ビューを持つサブクエリ | はい。{.text-success} | | +| F131-05 | GROUP BY句およびHAVING句およびグループ化ビューを使用した単一行選択 | いいえ。{.text-danger} | | +| **F181** | **複数モジュール対応** | **いいえ。**{.text-danger} | | +| **F201** | **キャスト機能** | **はい。**{.text-success} | | +| **F221** | **明示的な既定値** | **いいえ。**{.text-danger} | | +| **F261** | **大文字と小文字の式** | **はい。**{.text-success} | | +| F261-01 | 簡単な場合 | はい。{.text-success} | | +| F261-02 | 検索ケース | はい。{.text-success} | | +| F261-03 | NULLIF | はい。{.text-success} | | +| F261-04 | COALESCE | はい。{.text-success} | | +| **F311** | **スキーマ定義文** | **部分的**{.text-warning} | | +| F311-01 | CREATE SCHEMA | いいえ。{.text-danger} | | +| F311-02 | 永続ベーステーブルのテーブルの作成 | はい。{.text-success} | | +| F311-03 | CREATE VIEW | はい。{.text-success} | | +| F311-04 | CREATE VIEW: WITH CHECK OPTION | いいえ。{.text-danger} | | +| F311-05 | グラント声明 | はい。{.text-success} | | +| **F471** | **スカラーサブクエリ値** | **はい。**{.text-success} | | +| **F481** | **展開されたNULL述語** | **はい。**{.text-success} | | +| **F812** | **基本的なフラグ設定** | **いいえ。**{.text-danger} | | +| **T321** | **基本的なSQL呼び出しルーチン** | **いいえ。**{.text-danger} | | +| T321-01 | オーバーロードのないユーザー定義関数 | いいえ。{.text-danger} | | +| T321-02 | 過負荷のないユーザー定義ストアドプロシージャ | いいえ。{.text-danger} | | +| T321-03 | 関数呼び出し | いいえ。{.text-danger} | | +| T321-04 | CALL文 | いいえ。{.text-danger} | | +| T321-05 | RETURN文 | いいえ。{.text-danger} | | +| **T631** | **一つのリスト要素を持つ述語で** | **はい。**{.text-success} | | diff --git a/docs/ja/sql-reference/data-types/aggregatefunction.md b/docs/ja/sql-reference/data-types/aggregatefunction.md new file mode 100644 index 00000000000..7051880ec7b --- /dev/null +++ b/docs/ja/sql-reference/data-types/aggregatefunction.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: "AggregateFunction(\u540D\u524D,types_of_arguments...)" +--- + +# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} + +Aggregate functions can have an implementation-defined intermediate state that can be serialized to an AggregateFunction(…) data type and stored in a table, usually, by means of [マテリアライズドビュー](../../sql-reference/statements/create.md#create-view). 集計関数の状態を生成する一般的な方法は、集計関数を呼び出すことです。 `-State` 接尾辞。 将来集計の最終結果を取得するには、同じ集計関数を使用する必要があります。 `-Merge`接尾辞。 + +`AggregateFunction` — parametric data type. + +**パラメータ** + +- 集計関数の名前。 + + If the function is parametric, specify its parameters too. + +- 集計関数の引数の型。 + +**例** + +``` sql +CREATE TABLE t +( + column1 AggregateFunction(uniq, UInt64), + column2 AggregateFunction(anyIf, String, UInt8), + column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) +) ENGINE = ... +``` + +[uniq](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq),anyIf ([任意](../../sql-reference/aggregate-functions/reference.md#agg_function-any)+[もし](../../sql-reference/aggregate-functions/combinators.md#agg-functions-combinator-if))と [分位数](../../sql-reference/aggregate-functions/reference.md) ClickHouseでサポートされている集計関数です。 + +## 使用法 {#usage} + +### データ挿入 {#data-insertion} + +データを挿入するには、 `INSERT SELECT` 総計を使って `-State`-機能。 + +**関数の例** + +``` sql +uniqState(UserID) +quantilesState(0.5, 0.9)(SendTiming) +``` + +対応する機能とは対照的に `uniq` と `quantiles`, `-State`-関数は、最終的な値の代わりに状態を返します。 言い換えれば、彼らはの値を返します `AggregateFunction` タイプ。 + +の結果 `SELECT` クエリ、の値 `AggregateFunction` typeは、すべてのClickHouse出力形式に対して実装固有のバイナリ表現を持ちます。 たとえば、データをダンプする場合, `TabSeparated` フォーマット `SELECT` このダンプは、以下を使用してロードバックできます `INSERT` クエリ。 + +### データ選択 {#data-selection} + +データを選択するとき `AggregatingMergeTree` テーブル、使用 `GROUP BY` データを挿入するときと同じ集計関数ですが、 `-Merge`接尾辞。 + +を持つ集合関数 `-Merge` suffixは、状態のセットを取得し、それらを結合し、完全なデータ集計の結果を返します。 + +たとえば、次の二つのクエリは同じ結果を返します: + +``` sql +SELECT uniq(UserID) FROM table + +SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) +``` + +## 使用例 {#usage-example} + +見る [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) エンジンの説明。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/ja/sql-reference/data-types/array.md b/docs/ja/sql-reference/data-types/array.md new file mode 100644 index 00000000000..93fbb057701 --- /dev/null +++ b/docs/ja/sql-reference/data-types/array.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 51 +toc_title: "\u914D\u5217(T)" +--- + +# 配列(t) {#data-type-array} + +の配列 `T`-タイプ項目。 `T` 配列を含む任意のデータ型を指定できます。 + +## 配列の作成 {#creating-an-array} + +関数を使用して配列を作成できます: + +``` sql +array(T) +``` + +角括弧を使用することもできます。 + +``` sql +[] +``` + +配列の作成例: + +``` sql +SELECT array(1, 2) AS x, toTypeName(x) +``` + +``` text +┌─x─────┬─toTypeName(array(1, 2))─┐ +│ [1,2] │ Array(UInt8) │ +└───────┴─────────────────────────┘ +``` + +``` sql +SELECT [1, 2] AS x, toTypeName(x) +``` + +``` text +┌─x─────┬─toTypeName([1, 2])─┐ +│ [1,2] │ Array(UInt8) │ +└───────┴────────────────────┘ +``` + +## データ型の操作 {#working-with-data-types} + +オンザフライで配列を作成するとき、ClickHouseは、リストされたすべての引数を格納できる最も狭いデータ型として引数型を自動的に定義します。 いずれかがある場合 [Null可能](nullable.md#data_type-nullable) またはリテラル [NULL](../../sql-reference/syntax.md#null-literal) 値を指定すると、配列要素の型も次のようになります [Null可能](nullable.md). + +ClickHouseがデータ型を判別できなかった場合、例外が生成されます。 たとえば、これは文字列と数値を同時に配列を作成しようとするときに発生します (`SELECT array(1, 'a')`). + +自動データ型検出の例: + +``` sql +SELECT array(1, 2, NULL) AS x, toTypeName(x) +``` + +``` text +┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ +│ [1,2,NULL] │ Array(Nullable(UInt8)) │ +└────────────┴───────────────────────────────┘ +``` + +互換性のないデータ型の配列を作成しようとすると、ClickHouseは例外をスローします: + +``` sql +SELECT array(1, 'a') +``` + +``` text +Received exception from server (version 1.1.54388): +Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/array/) diff --git a/docs/ja/sql-reference/data-types/boolean.md b/docs/ja/sql-reference/data-types/boolean.md new file mode 100644 index 00000000000..bcf5aa0289c --- /dev/null +++ b/docs/ja/sql-reference/data-types/boolean.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u30D6\u30FC\u30EB\u5024" +--- + +# ブール値 {#boolean-values} + +ブール値には別の型はありません。 UInt8型を使用し、値0または1に制限します。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/boolean/) diff --git a/docs/ja/sql-reference/data-types/date.md b/docs/ja/sql-reference/data-types/date.md new file mode 100644 index 00000000000..1de92a686a4 --- /dev/null +++ b/docs/ja/sql-reference/data-types/date.md @@ -0,0 +1,15 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: "\u65E5\u4ED8" +--- + +# 日付 {#date} + +デートだ 1970-01-01(符号なし)以降の日数として二バイト単位で格納されます。 Unixエポックの開始直後から、コンパイル段階で定数によって定義される上限しきい値までの値を格納できます(現在は2106年までですが、完全にサポート +最小値は0000-00-00として出力されます。 + +日付値は、タイムゾーンなしで格納されます。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/date/) diff --git a/docs/ja/sql-reference/data-types/datetime.md b/docs/ja/sql-reference/data-types/datetime.md new file mode 100644 index 00000000000..c4a74696be1 --- /dev/null +++ b/docs/ja/sql-reference/data-types/datetime.md @@ -0,0 +1,129 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: DateTime +--- + +# Datetime {#data_type-datetime} + +カレンダーの日付と一日の時間として表現することができ、時間内にインスタントを格納することができます。 + +構文: + +``` sql +DateTime([timezone]) +``` + +サポートされる値の範囲: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. + +解像度:1秒. + +## 使用上の注意 {#usage-remarks} + +時間のポイントはaとして救われます [Unixタイムスタン](https://en.wikipedia.org/wiki/Unix_time) タイムゾーンまたは夏時間に関係なく。 さらに、 `DateTime` 型は、列全体で同じタイムゾーンを格納することができます。 `DateTime` 型の値はテキスト形式で表示され、文字列として指定された値がどのように解析されるか (‘2020-01-01 05:00:01’). タイムゾーンは、テーブルの行(またはresultset)には格納されませんが、列メタデータに格納されます。 +サポートされているタイムゾーンのリストは、 [IANAタイムゾーンデータベ](https://www.iana.org/time-zones). +その `tzdata` パッケージ,含む [IANAタイムゾーンデータベ](https://www.iana.org/time-zones)、システムに取付けられているべきです。 使用する `timedatectl list-timezones` ローカルシステムが既知のタイムゾーンを一覧表示するコマンド。 + +タイムゾーンを明示的に設定することができます `DateTime`-テーブルを作成するときに列を入力します。 タイムゾーンが設定されていない場合、ClickHouseは [タイムゾーン](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) ClickHouseサーバー起動時のサーバー設定またはオペレーティングシステム設定のパラメータ。 + +その [clickhouse-クライアント](../../interfaces/cli.md) データ型の初期化時にタイムゾーンが明示的に設定されていない場合は、既定でサーバータイムゾーンを適用します。 クライアントのタイムゾーンを使用するには `clickhouse-client` と `--use_client_time_zone` パラメータ。 + +ClickHouseは、次の値を出力します `YYYY-MM-DD hh:mm:ss` デフォルトのテキスト形式。 出力を変更するには [formatDateTime](../../sql-reference/functions/date-time-functions.md#formatdatetime) 機能。 + +ClickHouseにデータを挿入するときは、データの値に応じて、日付と時刻の文字列の異なる形式を使用できます。 [date\_time\_input\_format](../../operations/settings/settings.md#settings-date_time_input_format) 設定。 + +## 例 {#examples} + +**1.** テーブルの作成 `DateTime`-列を入力し、そこにデータを挿入する: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime('Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog; +``` + +``` sql +INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); +``` + +``` sql +SELECT * FROM dt; +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00 │ 1 │ +│ 2019-01-01 00:00:00 │ 2 │ +└─────────────────────┴──────────┘ +``` + +- Datetimeを整数として挿入する場合は、Unix Timestamp(UTC)として扱われます。 `1546300800` を表す `'2019-01-01 00:00:00'` UTC しかし、 `timestamp` 列は `Europe/Moscow` (UTC+3)タイムゾーンが指定されている場合、文字列として出力すると、値は次のように表示されます `'2019-01-01 03:00:00'` +- 文字列値をdatetimeとして挿入すると、列タイムゾーンにあるものとして扱われます。 `'2019-01-01 00:00:00'` であるとして扱われます `Europe/Moscow` タイムゾーンとして保存 `1546290000`. + +**2.** フィルタリング `DateTime` 値 + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00 │ 2 │ +└─────────────────────┴──────────┘ +``` + +`DateTime` 列の値は、文字列の値を使用してフィルター処理できます。 `WHERE` 述語。 に変換されます `DateTime` 自動的に: + +``` sql +SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00 │ 1 │ +└─────────────────────┴──────────┘ +``` + +**3.** Aのタイムゾーンの取得 `DateTime`-タイプ列: + +``` sql +SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────column─┬─x─────────────────────────┐ +│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ +└─────────────────────┴───────────────────────────┘ +``` + +**4.** タイムゾーン変換 + +``` sql +SELECT +toDateTime(timestamp, 'Europe/London') as lon_time, +toDateTime(timestamp, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────lon_time──┬────────────mos_time─┐ +│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ +│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ +└─────────────────────┴─────────────────────┘ +``` + +## も参照。 {#see-also} + +- [型変換関数](../../sql-reference/functions/type-conversion-functions.md) +- [日付と時刻を操作するための関数](../../sql-reference/functions/date-time-functions.md) +- [配列を操作するための関数](../../sql-reference/functions/array-functions.md) +- [その `date_time_input_format` 設定](../../operations/settings/settings.md#settings-date_time_input_format) +- [その `timezone` サーバ構成パラメータ](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) +- [日付と時刻を操作する演算子](../../sql-reference/operators/index.md#operators-datetime) +- [その `Date` データ型](date.md) + +[元の記事](https://clickhouse.tech/docs/en/data_types/datetime/) diff --git a/docs/ja/sql-reference/data-types/datetime64.md b/docs/ja/sql-reference/data-types/datetime64.md new file mode 100644 index 00000000000..12a31595b70 --- /dev/null +++ b/docs/ja/sql-reference/data-types/datetime64.md @@ -0,0 +1,104 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 49 +toc_title: DateTime64 +--- + +# Datetime64 {#data_type-datetime64} + +定義された秒以下の精度で、カレンダーの日付と時刻として表すことができるインスタントを時間内に格納することができます + +目盛りのサイズ(精密):10-精密 秒 + +構文: + +``` sql +DateTime64(precision, [timezone]) +``` + +内部的には、データを ‘ticks’ エポック開始(1970-01-01 00:00:00UTC)以来、Int64として。 目盛りの解像度は、精度パラメータによって決定されます。 さらに、 `DateTime64` 型は、列全体で同じタイムゾーンを格納することができます。 `DateTime64` 型の値はテキスト形式で表示され、文字列として指定された値がどのように解析されるか (‘2020-01-01 05:00:01.000’). タイムゾーンは、テーブルの行(またはresultset)には格納されませんが、列メタデータに格納されます。 詳細はを参照。 [DateTime](datetime.md). + +## 例 {#examples} + +**1.** テーブルの作成 `DateTime64`-列を入力し、そこにデータを挿入する: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime64(3, 'Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog +``` + +``` sql +INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) +``` + +``` sql +SELECT * FROM dt +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00.000 │ 1 │ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +- Datetimeを整数として挿入する場合、適切にスケーリングされたUnixタイムスタンプ(UTC)として扱われます。 `1546300800000` (精度3で)を表します `'2019-01-01 00:00:00'` UTC しかし、 `timestamp` 列は `Europe/Moscow` (UTC+3)タイムゾーンが指定されている場合、文字列として出力すると、値は次のように表示されます `'2019-01-01 03:00:00'` +- 文字列値をdatetimeとして挿入すると、列タイムゾーンにあるものとして扱われます。 `'2019-01-01 00:00:00'` であるとして扱われます `Europe/Moscow` タイムゾーンとして保存 `1546290000000`. + +**2.** フィルタリング `DateTime64` 値 + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +異なり `DateTime`, `DateTime64` 値は変換されません `String` 自動的に + +**3.** Aのタイムゾーンの取得 `DateTime64`-タイプ値: + +``` sql +SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────────column─┬─x──────────────────────────────┐ +│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ +└─────────────────────────┴────────────────────────────────┘ +``` + +**4.** タイムゾーン変換 + +``` sql +SELECT +toDateTime64(timestamp, 3, 'Europe/London') as lon_time, +toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────────lon_time──┬────────────────mos_time─┐ +│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ +│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ +└─────────────────────────┴─────────────────────────┘ +``` + +## も参照。 {#see-also} + +- [型変換関数](../../sql-reference/functions/type-conversion-functions.md) +- [日付と時刻を操作するための関数](../../sql-reference/functions/date-time-functions.md) +- [配列を操作するための関数](../../sql-reference/functions/array-functions.md) +- [その `date_time_input_format` 設定](../../operations/settings/settings.md#settings-date_time_input_format) +- [その `timezone` サーバ構成パラメータ](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) +- [日付と時刻を操作する演算子](../../sql-reference/operators/index.md#operators-datetime) +- [`Date` データ型](date.md) +- [`DateTime` データ型](datetime.md) diff --git a/docs/ja/sql-reference/data-types/decimal.md b/docs/ja/sql-reference/data-types/decimal.md new file mode 100644 index 00000000000..52fc336d331 --- /dev/null +++ b/docs/ja/sql-reference/data-types/decimal.md @@ -0,0 +1,109 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u5C0F\u6570\u70B9" +--- + +# Decimal(P,S),Decimal32(S),Decimal64(S),Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} + +加算、減算、および乗算の演算中に精度を維持する符号付き固定小数点数。 除算の場合、最下位桁数は破棄されます(丸められません)。 + +## パラメータ {#parameters} + +- P-精度。 有効な範囲:\[1:38\]。 小数の桁数を決定します(分数を含む)。 +- Sスケール 有効な範囲:\[0:P\]。 小数の桁数を指定します。 + +Pに依存するパラメータ値Decimal(P,S)は、: +-P from\[1:9\]-For Decimal32(S) +-P from\[10:18\]-For Decimal64(S) +-P from\[19:38\]-For Decimal128(S) + +## 小数点以下の値の範囲 {#decimal-value-ranges} + +- Decimal32(S) - ( -1 \* 10^(9 - S),1\*10^(9-S) ) +- Decimal64(S) - ( -1 \* 10^(18 - S),1\*10^(18-S) ) +- Decimal128(S) - ( -1 \* 10^(38 - S),1\*10^(38-S) ) + +たとえば、Decimal32(4)には、-99999.9999から99999.9999までの0.0001ステップの数値を含めることができます。 + +## 内部表現 {#internal-representation} + +社内データとして表される通常の署名の整数をそれぞれのビット幅になります。 メモリに格納できる実際の値の範囲は、上記の指定よりも少し大きく、文字列からの変換時にのみチェックされます。 + +現代のCPUは128ビット整数をネイティブにサポートしていないため、Decimal128の演算はエミュレートされます。 このため、Decimal128はDecimal32/Decimal64よりも大幅に遅く動作します。 + +## 操作と結果の種類 {#operations-and-result-type} + +Decimalのバイナリ演算は、より広い結果の型になります(引数の順序は任意です)。 + +- `Decimal64(S1) Decimal32(S2) -> Decimal64(S)` +- `Decimal128(S1) Decimal32(S2) -> Decimal128(S)` +- `Decimal128(S1) Decimal64(S2) -> Decimal128(S)` + +スケールのルール: + +- 加算、減算:S=max(S1、S2)。 +- multuply:S=S1+S2. +- 除算:S=S1. + +Decimalと整数の間の同様の演算の場合、結果は引数と同じサイズのDecimalになります。 + +DecimalとFloat32/Float64の間の演算は定義されていません。 必要な場合は、toDecimal32、toDecimal64、toDecimal128、またはtoFloat32、toFloat64ビルトインを使用して引数のいずれかを明示的にキャストできます。 結果は精度が失われ、型変換は計算コストがかかる操作であることに注意してください。 + +Decimalの一部の関数はFloat64(varやstddevなど)として結果を返します。 これにより、Float64入力とDecimal入力が同じ値で異なる結果になる可能性があります。 + +## オーバーフローチェック {#overflow-checks} + +中計算は小数,整数であふれかが起こる。 小数部の過剰な数字は破棄されます(丸められません)。 整数部分の数字が過剰になると、例外が発生します。 + +``` sql +SELECT toDecimal32(2, 4) AS x, x / 3 +``` + +``` text +┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ +│ 2.0000 │ 0.6666 │ +└────────┴──────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32(4.2, 8) AS x, x * x +``` + +``` text +DB::Exception: Scale is out of bounds. +``` + +``` sql +SELECT toDecimal32(4.2, 8) AS x, 6 * x +``` + +``` text +DB::Exception: Decimal math overflow. +``` + +オーバーフローチェックが業務に減速した。 が知られていることができませんこを無効にするチェック `decimal_check_overflow` 設定。 時チェックを無効とオーバーフローが起こり、結果は正しくあり: + +``` sql +SET decimal_check_overflow = 0; +SELECT toDecimal32(4.2, 8) AS x, 6 * x +``` + +``` text +┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ +│ 4.20000000 │ -17.74967296 │ +└────────────┴──────────────────────────────────┘ +``` + +オーバーフローチェックが起こるだけでなく演算業務はもとより、価値との比較: + +``` sql +SELECT toDecimal32(1, 8) < 100 +``` + +``` text +DB::Exception: Can't compare. +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/decimal/) diff --git a/docs/ja/sql-reference/data-types/domains/index.md b/docs/ja/sql-reference/data-types/domains/index.md new file mode 100644 index 00000000000..d476fcefb51 --- /dev/null +++ b/docs/ja/sql-reference/data-types/domains/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u30C9\u30E1\u30A4\u30F3" +toc_priority: 56 +--- + + diff --git a/docs/ja/sql-reference/data-types/domains/ipv4.md b/docs/ja/sql-reference/data-types/domains/ipv4.md new file mode 100644 index 00000000000..e355ae4f70f --- /dev/null +++ b/docs/ja/sql-reference/data-types/domains/ipv4.md @@ -0,0 +1,84 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: IPv4 +--- + +## IPv4 {#ipv4} + +`IPv4` に基づくドメインです `UInt32` IPv4値を格納するための型指定された置換として機能します。 それは点検で人間に適する入出力フォーマットおよびコラムのタイプ情報を密集した貯蔵に与える。 + +### 基本的な使用法 {#basic-usage} + +``` sql +CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY url; + +DESCRIBE TABLE hits; +``` + +``` text +┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ +│ url │ String │ │ │ │ │ +│ from │ IPv4 │ │ │ │ │ +└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ +``` + +または、IPv4ドメインをキーとして使用できます: + +``` sql +CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; +``` + +`IPv4` ドメインはIPv4文字列としてカスタム入力形式をサポート: + +``` sql +INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.tech', '183.247.232.58')('https://clickhouse.yandex/docs/en/', '116.106.34.242'); + +SELECT * FROM hits; +``` + +``` text +┌─url────────────────────────────────┬───────────from─┐ +│ https://clickhouse.tech/docs/en/ │ 116.106.34.242 │ +│ https://wikipedia.org │ 116.253.40.133 │ +│ https://clickhouse.tech │ 183.247.232.58 │ +└────────────────────────────────────┴────────────────┘ +``` + +値が格納されコンパクトにバイナリ形式: + +``` sql +SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(from)─┬─hex(from)─┐ +│ IPv4 │ B7F7E83A │ +└──────────────────┴───────────┘ +``` + +ドメイン値は、暗黙的に型以外に変換できません `UInt32`. +変換したい場合 `IPv4` 文字列への値は、明示的にそれを行う必要があります `IPv4NumToString()` 関数: + +``` sql +SELECT toTypeName(s), IPv4NumToString(from) as s FROM hits LIMIT 1; +``` + + ┌─toTypeName(IPv4NumToString(from))─┬─s──────────────┐ + │ String │ 183.247.232.58 │ + └───────────────────────────────────┴────────────────┘ + +またはaにキャスト `UInt32` 値: + +``` sql +SELECT toTypeName(i), CAST(from as UInt32) as i FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(CAST(from, 'UInt32'))─┬──────────i─┐ +│ UInt32 │ 3086477370 │ +└──────────────────────────────────┴────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/domains/ipv4) diff --git a/docs/ja/sql-reference/data-types/domains/ipv6.md b/docs/ja/sql-reference/data-types/domains/ipv6.md new file mode 100644 index 00000000000..73227e7a2b7 --- /dev/null +++ b/docs/ja/sql-reference/data-types/domains/ipv6.md @@ -0,0 +1,86 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 60 +toc_title: IPv6 +--- + +## IPv6 {#ipv6} + +`IPv6` に基づくドメインです `FixedString(16)` IPv6値を格納するための型指定された置換として機能します。 それは点検で人間に適する入出力フォーマットおよびコラムのタイプ情報を密集した貯蔵に与える。 + +### 基本的な使用法 {#basic-usage} + +``` sql +CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url; + +DESCRIBE TABLE hits; +``` + +``` text +┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ +│ url │ String │ │ │ │ │ +│ from │ IPv6 │ │ │ │ │ +└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ +``` + +または、 `IPv6` キーとしてのドメイン: + +``` sql +CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from; +``` + +`IPv6` ドメイ: + +``` sql +INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.tech', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.yandex/docs/en/', '2a02:e980:1e::1'); + +SELECT * FROM hits; +``` + +``` text +┌─url────────────────────────────────┬─from──────────────────────────┐ +│ https://clickhouse.tech │ 2001:44c8:129:2632:33:0:252:2 │ +│ https://clickhouse.tech/docs/en/ │ 2a02:e980:1e::1 │ +│ https://wikipedia.org │ 2a02:aa08:e000:3100::2 │ +└────────────────────────────────────┴───────────────────────────────┘ +``` + +値が格納されコンパクトにバイナリ形式: + +``` sql +SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(from)─┬─hex(from)────────────────────────┐ +│ IPv6 │ 200144C8012926320033000002520002 │ +└──────────────────┴──────────────────────────────────┘ +``` + +ドメイン値は、暗黙的に型以外に変換できません `FixedString(16)`. +変換したい場合 `IPv6` 文字列への値は、明示的にそれを行う必要があります `IPv6NumToString()` 関数: + +``` sql +SELECT toTypeName(s), IPv6NumToString(from) as s FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(IPv6NumToString(from))─┬─s─────────────────────────────┐ +│ String │ 2001:44c8:129:2632:33:0:252:2 │ +└───────────────────────────────────┴───────────────────────────────┘ +``` + +またはaにキャスト `FixedString(16)` 値: + +``` sql +SELECT toTypeName(i), CAST(from as FixedString(16)) as i FROM hits LIMIT 1; +``` + +``` text +┌─toTypeName(CAST(from, 'FixedString(16)'))─┬─i───────┐ +│ FixedString(16) │ ��� │ +└───────────────────────────────────────────┴─────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/domains/ipv6) diff --git a/docs/ja/sql-reference/data-types/domains/overview.md b/docs/ja/sql-reference/data-types/domains/overview.md new file mode 100644 index 00000000000..958fce5beb4 --- /dev/null +++ b/docs/ja/sql-reference/data-types/domains/overview.md @@ -0,0 +1,32 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "\u6982\u8981" +--- + +# ドメイン {#domains} + +ドメインは、既存の基本型の上にいくつかの余分な機能を追加する特殊な目的の型ですが、基になるデータ型のオンワイヤおよびオンディスク形式は 現時点では、ClickHouseはユーザー定義ドメインをサポートしていません。 + +たとえば、対応する基本タイプを使用できる任意の場所でドメインを使用できます: + +- ドメイン型の列を作成する +- ドメイン列から/への読み取り/書き込み値 +- 基本型をインデックスとして使用できる場合は、インデックスとして使用します +- ドメイン列の値を持つ関数の呼び出し + +### ドメインの追加機能 {#extra-features-of-domains} + +- 明示的な列タイプ名 `SHOW CREATE TABLE` または `DESCRIBE TABLE` +- 人間に優しいフォーマットからの入力 `INSERT INTO domain_table(domain_column) VALUES(...)` +- 人間に優しいフォーマットへの出力 `SELECT domain_column FROM domain_table` +- 人間に優しい形式で外部ソースからデータを読み込む: `INSERT INTO domain_table FORMAT CSV ...` + +### 制限 {#limitations} + +- 基本型のインデックス列をドメイン型に変換できません `ALTER TABLE`. +- 別の列または表からデータを挿入するときに、文字列値を暗黙的にドメイン値に変換できません。 +- ドメインは、格納された値に制約を追加しません。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/domains/overview) diff --git a/docs/ja/sql-reference/data-types/enum.md b/docs/ja/sql-reference/data-types/enum.md new file mode 100644 index 00000000000..aef4855ef06 --- /dev/null +++ b/docs/ja/sql-reference/data-types/enum.md @@ -0,0 +1,132 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: Enum +--- + +# Enum {#enum} + +名前付き値で構成される列挙型。 + +名前の値として宣言された `'string' = integer` ペア。 ClickHouseは数値のみを格納しますが、名前による値の操作をサポートします。 + +ClickHouseサポート: + +- 8ビット `Enum`. それはで列挙される256までの価値を含むことができます `[-128, 127]` 範囲 +- 16ビット `Enum`. それはで列挙される65536までの価値を含むことができます `[-32768, 32767]` 範囲 + +ClickHouseは自動的に次のタイプを選択します `Enum` データが挿入されるとき。 また、 `Enum8` または `Enum16` ストレージのサイズを確認するタイプ。 + +## 使用例 {#usage-examples} + +ここでは、 `Enum8('hello' = 1, 'world' = 2)` タイプ列: + +``` sql +CREATE TABLE t_enum +( + x Enum('hello' = 1, 'world' = 2) +) +ENGINE = TinyLog +``` + +列 `x` 型定義にリストされている値のみを格納できます: `'hello'` または `'world'`. 他の値を保存しようとすると、ClickHouseは例外を発生させます。 このための8ビットサイズ `Enum` 自動的に選択されます。 + +``` sql +INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') +``` + +``` text +Ok. +``` + +``` sql +INSERT INTO t_enum values('a') +``` + +``` text +Exception on client: +Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) +``` + +テーブルからデータを照会すると、ClickHouseは文字列値を `Enum`. + +``` sql +SELECT * FROM t_enum +``` + +``` text +┌─x─────┐ +│ hello │ +│ world │ +│ hello │ +└───────┘ +``` + +行の等価な数値を見る必要がある場合は、次のようにキャストする必要があります `Enum` 整数型の値。 + +``` sql +SELECT CAST(x, 'Int8') FROM t_enum +``` + +``` text +┌─CAST(x, 'Int8')─┐ +│ 1 │ +│ 2 │ +│ 1 │ +└─────────────────┘ +``` + +クエリでEnum値を作成するには、次のものも使用する必要があります `CAST`. + +``` sql +SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) +``` + +``` text +┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ +│ Enum8('a' = 1, 'b' = 2) │ +└─────────────────────────────────────────────────────┘ +``` + +## 一般的なルールと使用法 {#general-rules-and-usage} + +各値には、範囲内の数値が割り当てられます `-128 ... 127` のために `Enum8` または範囲 `-32768 ... 32767` のために `Enum16`. すべての文字列と数字は異なる必要があります。 空の文字列を使用できます。 この型が(テーブル定義で)指定されている場合、数値は任意の順序にすることができます。 しかし、順序は重要ではありません。 + +の文字列も数値もない。 `Enum` ことができます [NULL](../../sql-reference/syntax.md). + +アン `Enum` に含めることができます [Null可能](nullable.md) タイプ。 だから、クエリを使用してテーブルを作成する場合 + +``` sql +CREATE TABLE t_enum_nullable +( + x Nullable( Enum8('hello' = 1, 'world' = 2) ) +) +ENGINE = TinyLog +``` + +できるアプリ `'hello'` と `'world'` でも `NULL` 同様に。 + +``` sql +INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) +``` + +RAMでは、 `Enum` 列は次のように格納されます `Int8` または `Int16` 対応する数値の。 + +テキスト形式で読み込む場合、ClickHouseは値を文字列として解析し、列挙型の値のセットから対応する文字列を検索します。 見つからない場合は、例外がスローされます。 テキスト形式で読み込むと、文字列が読み込まれ、対応する数値が検索されます。 見つからない場合は例外がスローされます。 +テキスト形式で書き込む場合、その値を対応する文字列として書き込みます。 列データにガベージ(有効なセット以外の数値)が含まれている場合は、例外がスローされます。 バイナリ形式で読み書きする場合、Int8およびInt16データ型と同じように動作します。 +暗黙的なデフォルト値は、数値が最も小さい値です。 + +中 `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` というように、列挙型は対応する数値と同じように動作します。 たとえば、ORDER BYは数値で並べ替えます。 等価演算子と比較演算子は、列挙型では、基になる数値と同じように動作します。 + +列挙型の値を数値と比較することはできません。 列挙型は定数文字列と比較できます。 比較対象の文字列が列挙型の有効な値でない場合は、例外がスローされます。 IN演算子は、左側の列挙型と右側の文字列のセットでサポートされています。 文字列は、対応する列挙型の値です。 + +Most numeric and string operations are not defined for Enum values, e.g. adding a number to an Enum or concatenating a string to an Enum. +しかし、Enumには自然なものがあります `toString` 文字列値を返す関数。 + +列挙型の値は、次の式を使用して数値型にも変換できます `toT` ここで、Tは数値型です。 Tが列挙型の基になる数値型に対応する場合、この変換はゼロコストになります。 +列挙型は、値のセットのみが変更されている場合、ALTERを使用してコストなしで変更できます。 ALTERを使用して列挙型のメンバーを追加および削除することは可能です(削除された値がテーブルで使用されていない場合にのみ削除が安全です)。 セーフガードとして、以前に定義された列挙型メンバーの数値を変更すると、例外がスローされます。 + +ALTERを使用すると、Int8をInt16に変更するのと同じように、Enum8をEnum16に変更することも、その逆も可能です。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/enum/) diff --git a/docs/ja/sql-reference/data-types/fixedstring.md b/docs/ja/sql-reference/data-types/fixedstring.md new file mode 100644 index 00000000000..4e2e5aae4e9 --- /dev/null +++ b/docs/ja/sql-reference/data-types/fixedstring.md @@ -0,0 +1,63 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u56FA\u5B9A\u6587\u5B57\u5217(N)" +--- + +# Fixedstring {#fixedstring} + +固定長の文字列 `N` バイト(文字もコードポイントもない)。 + +の列を宣言するには `FixedString` 次の構文を使用します: + +``` sql + FixedString(N) +``` + +どこに `N` は自然数である。 + +その `FixedString` データが正確に長さを持つ場合、型は効率的です `N` バイト数。 他のすべてのケースでは、効率を低下させる可能性があります。 + +効率的に格納できる値の例 `FixedString`-型指定された列: + +- IPアドレスのバイナリ表現 (`FixedString(16)` IPv6の場合)。 +- Language codes (ru\_RU, en\_US … ). +- Currency codes (USD, RUB … ). +- ハッシュのバイナリ表現 (`FixedString(16)` MD5の場合, `FixedString(32)` SHA256)のため。 + +UUID値を格納するには、 [UUID](uuid.md) データ型。 + +データを挿入するとき、ClickHouse: + +- 文字列が含まれている数がnullバイトの文字列を補完します `N` バイト数。 +- スロー `Too large value for FixedString(N)` 文字列に以下のものが含まれている場合は例外 `N` バイト数。 + +データを選択すると、ClickHouseは文字列の末尾にあるnullバイトを削除しません。 を使用する場合 `WHERE` この節では、nullバイトを手動で追加する必要があります。 `FixedString` 値。 次の例では、次の操作を実行する方法を示します `WHERE` との句 `FixedString`. + +次の表を単一のもので考えてみましょう `FixedString(2)` 列: + +``` text +┌─name──┐ +│ b │ +└───────┘ +``` + +クエリ `SELECT * FROM FixedStringTable WHERE a = 'b'` 結果としてデータを返しません。 このフィルターパターンはnullバイトまでとなります。 + +``` sql +SELECT * FROM FixedStringTable +WHERE a = 'b\0' +``` + +``` text +┌─a─┐ +│ b │ +└───┘ +``` + +この動作はMySQLとは異なります。 `CHAR` type(文字列はスペースで埋められ、スペースは出力のために削除されます)。 + +の長さに注意してください。 `FixedString(N)` 値は一定です。 その [長さ](../../sql-reference/functions/array-functions.md#array_functions-length) 関数の戻り値 `N` たとえ `FixedString(N)` 値はnullバイトのみで埋められますが、 [空](../../sql-reference/functions/string-functions.md#empty) 関数の戻り値 `1` この場合。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/ja/sql-reference/data-types/float.md b/docs/ja/sql-reference/data-types/float.md new file mode 100644 index 00000000000..b9333ae297d --- /dev/null +++ b/docs/ja/sql-reference/data-types/float.md @@ -0,0 +1,87 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "Float32\u3001Float64" +--- + +# Float32、Float64 {#float32-float64} + +[浮動小数点数](https://en.wikipedia.org/wiki/IEEE_754). + +型はCの型と同等です: + +- `Float32` - `float` +- `Float64` - `double` + +可能な限り整数形式でデータを格納することをお勧めします。 たとえば、固定精度の数値を、金額やページの読み込み時間などの整数値にミリ秒単位で変換します。 + +## 浮動小数点数の使用 {#using-floating-point-numbers} + +- 浮動小数点数を使用した計算では、丸め誤差が生じることがあります。 + + + +``` sql +SELECT 1 - 0.9 +``` + +``` text +┌───────minus(1, 0.9)─┐ +│ 0.09999999999999998 │ +└─────────────────────┘ +``` + +- 計算の結果は、計算方法(コンピュータシステムのプロセッサタイプおよびアーキテクチャ)に依存する。 +- 浮動小数点計算では、無限大などの数値が生成されることがあります (`Inf`)と “not-a-number” (`NaN`). これは、計算結果を処理するときに考慮する必要があります。 +- テキストから浮動小数点数を解析する場合、結果が最も近いマシン表現可能な数値ではない可能性があります。 + +## NaNおよびInf {#data_type-float-nan-inf} + +標準のSQLとは対照的に、ClickHouseは浮動小数点数の次のカテゴリをサポートしています: + +- `Inf` – Infinity. + + + +``` sql +SELECT 0.5 / 0 +``` + +``` text +┌─divide(0.5, 0)─┐ +│ inf │ +└────────────────┘ +``` + +- `-Inf` – Negative infinity. + + + +``` sql +SELECT -0.5 / 0 +``` + +``` text +┌─divide(-0.5, 0)─┐ +│ -inf │ +└─────────────────┘ +``` + +- `NaN` – Not a number. + + + +``` sql +SELECT 0 / 0 +``` + +``` text +┌─divide(0, 0)─┐ +│ nan │ +└──────────────┘ +``` + + See the rules for `NaN` sorting in the section [ORDER BY clause](../sql_reference/statements/select/order-by.md). + +[元の記事](https://clickhouse.tech/docs/en/data_types/float/) diff --git a/docs/ja/sql-reference/data-types/index.md b/docs/ja/sql-reference/data-types/index.md new file mode 100644 index 00000000000..5f82d86ce46 --- /dev/null +++ b/docs/ja/sql-reference/data-types/index.md @@ -0,0 +1,15 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u30C7\u30FC\u30BF\u578B" +toc_priority: 37 +toc_title: "\u306F\u3058\u3081\u306B" +--- + +# データ型 {#data_types} + +ClickHouseは、表のセルにさまざまな種類のデータを格納できます。 + +この章ではサポートされているデータの種類と特別な配慮のための利用および/または実施しています。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/) diff --git a/docs/ja/sql-reference/data-types/int-uint.md b/docs/ja/sql-reference/data-types/int-uint.md new file mode 100644 index 00000000000..e6ac277b3b5 --- /dev/null +++ b/docs/ja/sql-reference/data-types/int-uint.md @@ -0,0 +1,27 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "UInt8\u3001UInt16\u3001UInt32\u3001UInt64\u3001Int8\u3001Int16\u3001Int32\u3001\ + Int64" +--- + +# UInt8、UInt16、UInt32、UInt64、Int8、Int16、Int32、Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} + +符号の有無にかかわらず、固定長の整数。 + +## Intの範囲 {#int-ranges} + +- Int8-\[-128:127\] +- Int16-\[-32768:32767\] +- Int32-\[-2147483648:2147483647\] +- Int64-\[-9223372036854775808:9223372036854775807\] + +## Uintの範囲 {#uint-ranges} + +- UInt8-\[0:255\] +- UInt16-\[0:65535\] +- UInt32-\[0:4294967295\] +- UInt64-\[0:18446744073709551615\] + +[元の記事](https://clickhouse.tech/docs/en/data_types/int_uint/) diff --git a/docs/ja/sql-reference/data-types/nested-data-structures/index.md b/docs/ja/sql-reference/data-types/nested-data-structures/index.md new file mode 100644 index 00000000000..d003868a135 --- /dev/null +++ b/docs/ja/sql-reference/data-types/nested-data-structures/index.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u5165\u308C\u5B50\u30C7\u30FC\u30BF\u69CB\u9020" +toc_hidden: true +toc_priority: 54 +toc_title: "\u96A0\u3057" +--- + +# 入れ子データ構造 {#nested-data-structures} + +[元の記事](https://clickhouse.tech/docs/en/data_types/nested_data_structures/) diff --git a/docs/ja/sql-reference/data-types/nested-data-structures/nested.md b/docs/ja/sql-reference/data-types/nested-data-structures/nested.md new file mode 100644 index 00000000000..68b6337a15e --- /dev/null +++ b/docs/ja/sql-reference/data-types/nested-data-structures/nested.md @@ -0,0 +1,106 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "\u30CD\u30B9\u30C8\u3055\u308C\u305F(Name1Type1,Name2Type2,...)" +--- + +# Nested(name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} + +A nested data structure is like a table inside a cell. The parameters of a nested data structure – the column names and types – are specified the same way as in a [CREATE TABLE](../../../sql-reference/statements/create.md) クエリ。 各テーブルの行は、入れ子になったデータ構造内の任意の数の行に対応できます。 + +例: + +``` sql +CREATE TABLE test.visits +( + CounterID UInt32, + StartDate Date, + Sign Int8, + IsNew UInt8, + VisitID UInt64, + UserID UInt64, + ... + Goals Nested + ( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32 + ), + ... +) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) +``` + +この例では、 `Goals` コンバージョンに関するデータを含む入れ子になったデータ構造。 の各行 ‘visits’ tableは、ゼロまたは任意の数の変換に対応できます。 + +単一の入れ子レベルのみがサポートされます。 配列を含む入れ子になった構造体の列は多次元配列と同等なので、サポートが限られています(MergeTreeエンジンでこれらの列をテーブルに格納するサポートは + +ほとんどの場合、入れ子になったデータ構造を操作する場合、その列はドットで区切られた列名で指定されます。 これらの列は、一致する型の配列を構成します。 単一の入れ子になったデータ構造のすべての列配列の長さは同じです。 + +例: + +``` sql +SELECT + Goals.ID, + Goals.EventTime +FROM test.visits +WHERE CounterID = 101500 AND length(Goals.ID) < 5 +LIMIT 10 +``` + +``` text +┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ +│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ +│ [1073752] │ ['2014-03-17 00:28:25'] │ +│ [1073752] │ ['2014-03-17 10:46:20'] │ +│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ +│ [] │ [] │ +│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ +│ [] │ [] │ +│ [] │ [] │ +│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ +│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ +└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +ネストされたデータ構造は、同じ長さの複数の列配列のセットと考えるのが最も簡単です。 + +SELECTクエリで個々の列ではなく入れ子になったデータ構造全体の名前を指定できるのは、ARRAY JOIN句だけです。 詳細については、 “ARRAY JOIN clause”. 例: + +``` sql +SELECT + Goal.ID, + Goal.EventTime +FROM test.visits +ARRAY JOIN Goals AS Goal +WHERE CounterID = 101500 AND length(Goals.ID) < 5 +LIMIT 10 +``` + +``` text +┌─Goal.ID─┬──────Goal.EventTime─┐ +│ 1073752 │ 2014-03-17 16:38:10 │ +│ 591325 │ 2014-03-17 16:38:48 │ +│ 591325 │ 2014-03-17 16:42:27 │ +│ 1073752 │ 2014-03-17 00:28:25 │ +│ 1073752 │ 2014-03-17 10:46:20 │ +│ 1073752 │ 2014-03-17 13:59:20 │ +│ 591325 │ 2014-03-17 22:17:55 │ +│ 591325 │ 2014-03-17 22:18:07 │ +│ 591325 │ 2014-03-17 22:18:51 │ +│ 1073752 │ 2014-03-17 11:37:06 │ +└─────────┴─────────────────────┘ +``` + +入れ子になったデータ構造全体に対してSELECTは実行できません。 明示的にリストできるのは、その一部である個々の列のみです。 + +INSERTクエリでは、入れ子になったデータ構造のすべてのコンポーネント列配列を個別に渡す必要があります(個々の列配列と同様に)。 挿入時に、同じ長さであることがチェックされます。 + +DESCRIBEクエリの場合、入れ子になったデータ構造の列は、同じ方法で別々に表示されます。 + +入れ子になったデータ構造内の要素のALTERクエリには制限があります。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/nested_data_structures/nested/) diff --git a/docs/ja/sql-reference/data-types/nullable.md b/docs/ja/sql-reference/data-types/nullable.md new file mode 100644 index 00000000000..5c6631aa99a --- /dev/null +++ b/docs/ja/sql-reference/data-types/nullable.md @@ -0,0 +1,46 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Null\u53EF\u80FD" +--- + +# Nullable(型名) {#data_type-nullable} + +できる特別マーカー ([NULL](../../sql-reference/syntax.md))を表す。 “missing value” と共に正常値を許可する `TypeName`. たとえば、 `Nullable(Int8)` 型列が格納できます `Int8` 値を入力し、値を持たない行には格納されます `NULL`. + +のために `TypeName` 複合データ型は使用できません [配列](array.md) と [タプル](tuple.md). 複合データ型には `Nullable` 次のような型の値 `Array(Nullable(Int8))`. + +A `Nullable` typeフィールドできない含まれてテーブルスを作成します。 + +`NULL` のデフォルト値です `Nullable` ClickHouseサーバー構成で特に指定がない限り、入力します。 + +## ストレージ機能 {#storage-features} + +保存するには `Nullable` テーブルの列に値を入力すると、ClickHouseは別のファイルを使用します `NULL` 値を持つ通常のファイルに加えて、マスク。 マスクファイル内のエントリはClickHouseが `NULL` テーブル行ごとに対応するデータ型のデフォルト値。 追加のファイルのために, `Nullable` columnは、同様の通常のものと比較して追加の記憶領域を消費します。 + +!!! info "注" + を使用して `Nullable` ほとんどの場合、パフォーマンスに悪影響を及ぼします。 + +## 使用例 {#usage-example} + +``` sql +CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog +``` + +``` sql +INSERT INTO t_null VALUES (1, NULL), (2, 3) +``` + +``` sql +SELECT x + y FROM t_null +``` + +``` text +┌─plus(x, y)─┐ +│ ᴺᵁᴸᴸ │ +│ 5 │ +└────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/ja/sql-reference/data-types/simpleaggregatefunction.md b/docs/ja/sql-reference/data-types/simpleaggregatefunction.md new file mode 120000 index 00000000000..76a7ef3b802 --- /dev/null +++ b/docs/ja/sql-reference/data-types/simpleaggregatefunction.md @@ -0,0 +1 @@ +../../../en/sql-reference/data-types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/ja/sql-reference/data-types/special-data-types/expression.md b/docs/ja/sql-reference/data-types/special-data-types/expression.md new file mode 100644 index 00000000000..f777929abb6 --- /dev/null +++ b/docs/ja/sql-reference/data-types/special-data-types/expression.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "\u5F0F" +--- + +# 式 {#expression} + +式は、高次関数のラムダを表すために使用されます。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/expression/) diff --git a/docs/ja/sql-reference/data-types/special-data-types/index.md b/docs/ja/sql-reference/data-types/special-data-types/index.md new file mode 100644 index 00000000000..4ad98970909 --- /dev/null +++ b/docs/ja/sql-reference/data-types/special-data-types/index.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u7279\u6B8A\u30C7\u30FC\u30BF\u578B" +toc_hidden: true +toc_priority: 55 +toc_title: "\u96A0\u3057" +--- + +# 特殊データ型 {#special-data-types} + +特別なデータ型の値は、テーブルへの保存やクエリ結果の出力のためにシリアル化することはできませんが、クエリ実行時の中間結果として使用でき + +[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/) diff --git a/docs/ja/sql-reference/data-types/special-data-types/interval.md b/docs/ja/sql-reference/data-types/special-data-types/interval.md new file mode 100644 index 00000000000..99fbe212935 --- /dev/null +++ b/docs/ja/sql-reference/data-types/special-data-types/interval.md @@ -0,0 +1,85 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "\u9593\u9694" +--- + +# 間隔 {#data-type-interval} + +時間と日付間隔を表すデータ型のファミリ。 の結果の型 [INTERVAL](../../../sql-reference/operators/index.md#operator-interval) オペレーター + +!!! warning "警告" + `Interval` データ型の値はテーブルに格納できません。 + +構造: + +- 符号なし整数値としての時間間隔。 +- 間隔のタイプ。 + +サポートさ: + +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +間隔タイプごとに、個別のデータタイプがあります。 例えば、 `DAY` 区間は `IntervalDay` データ型: + +``` sql +SELECT toTypeName(INTERVAL 4 DAY) +``` + +``` text +┌─toTypeName(toIntervalDay(4))─┐ +│ IntervalDay │ +└──────────────────────────────┘ +``` + +## 使用上の注意 {#data-type-interval-usage-remarks} + +以下を使用できます `Interval`-算術演算の値を [日付](../../../sql-reference/data-types/date.md) と [DateTime](../../../sql-reference/data-types/datetime.md)-値を入力します。 たとえば、現在の時刻に4日を追加できます: + +``` sql +SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY +``` + +``` text +┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ +│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ +└─────────────────────┴───────────────────────────────┘ +``` + +異なるタイプの間隔は結合できません。 次のような間隔は使用できません `4 DAY 1 HOUR`. 間隔は、間隔など、間隔の最小単位より小さい単位または等しい単位で指定します `1 day and an hour` 間隔は次のように表現できます `25 HOUR` または `90000 SECOND`. + +次の操作で算術演算を実行することはできません `Interval`-値を入力しますが、結果として異なるタイプの間隔を値に追加することができます。 `Date` または `DateTime` データ型。 例えば: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +次のクエリでは、例外が発生します: + +``` sql +select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) +``` + +``` text +Received exception from server (version 19.14.1): +Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. +``` + +## も参照。 {#see-also} + +- [INTERVAL](../../../sql-reference/operators/index.md#operator-interval) 演算子 +- [toInterval](../../../sql-reference/functions/type-conversion-functions.md#function-tointerval) 型変換関数 diff --git a/docs/ja/sql-reference/data-types/special-data-types/nothing.md b/docs/ja/sql-reference/data-types/special-data-types/nothing.md new file mode 100644 index 00000000000..796a11f7a29 --- /dev/null +++ b/docs/ja/sql-reference/data-types/special-data-types/nothing.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 60 +toc_title: "\u4F55\u3082\u306A\u3044" +--- + +# 何もない {#nothing} + +このデータ型の唯一の目的は、値が期待されないケースを表すことです。 だから、作成することはできません `Nothing` タイプ値。 + +たとえば、リテラル [NULL](../../../sql-reference/syntax.md#null-literal) タイプをの有する `Nullable(Nothing)`. 詳細はこちら [Null可能](../../../sql-reference/data-types/nullable.md). + +その `Nothing` 型は空の配列を表すためにも使用できます: + +``` sql +SELECT toTypeName(array()) +``` + +``` text +┌─toTypeName(array())─┐ +│ Array(Nothing) │ +└─────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/nothing/) diff --git a/docs/ja/sql-reference/data-types/special-data-types/set.md b/docs/ja/sql-reference/data-types/special-data-types/set.md new file mode 100644 index 00000000000..bb4cded3df2 --- /dev/null +++ b/docs/ja/sql-reference/data-types/special-data-types/set.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: "\u30BB\u30C3\u30C8" +--- + +# セット {#set} + +の右半分に使用されます [IN](../../operators/in.md#select-in-operators) 式。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/set/) diff --git a/docs/ja/sql-reference/data-types/string.md b/docs/ja/sql-reference/data-types/string.md new file mode 100644 index 00000000000..f487314e5cb --- /dev/null +++ b/docs/ja/sql-reference/data-types/string.md @@ -0,0 +1,20 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u6587\u5B57\u5217" +--- + +# 文字列 {#string} + +任意の長さの文字列。 長さは限定されない。 値には、nullバイトを含む任意のバイトセットを含めることができます。 +文字列型は、他のDbmsのVARCHAR型、BLOB型、CLOB型などを置き換えます。 + +## エンコード {#encodings} + +ClickHouseにはエンコーディングの概念はありません。 文字列には、任意のバイトセットを含めることができます。 +が必要な場合は店舗テキストの使用をお勧めしまUTF-8エンコーディングです。 少なくとも、端末がUTF-8(推奨)を使用している場合は、変換を行わずに値を読み書きできます。 +同様に、文字列を操作するための特定の関数には、UTF-8でエンコードされたテキストを表すバイトセットが文字列に含まれているという前提の下で +例えば、 ‘length’ 関数は、文字列の長さをバイト単位で計算します。 ‘lengthUTF8’ 関数は、値がUTF-8でエンコードされていると仮定して、Unicodeコードポイントで文字列の長さを計算します。 + +[元の記事](https://clickhouse.tech/docs/en/data_types/string/) diff --git a/docs/ja/sql-reference/data-types/tuple.md b/docs/ja/sql-reference/data-types/tuple.md new file mode 100644 index 00000000000..7dbd2f3ea17 --- /dev/null +++ b/docs/ja/sql-reference/data-types/tuple.md @@ -0,0 +1,52 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 53 +toc_title: Tuple(T1,T2,...) +--- + +# Tuple(t1, T2, …) {#tuplet1-t2} + +要素のタプル、各個人を持つ [タイプ](index.md#data_types). + +組は、一時的な列のグループ化に使用されます。 列は、in式がクエリで使用され、lambda関数の特定の仮パラメータを指定するときにグループ化できます。 詳細については [演算子で](../../sql-reference/operators/in.md) と [高次関数](../../sql-reference/functions/higher-order-functions.md). + +タプルは、クエリの結果になります。 この場合、JSON以外のテキスト形式の場合、値は角かっこでカンマ区切られます。 JSON形式では、タプルは配列として出力されます(角括弧で囲みます)。 + +## タプルの作成 {#creating-a-tuple} + +関数を使用してタプルを作成できます: + +``` sql +tuple(T1, T2, ...) +``` + +タプルの作成例: + +``` sql +SELECT tuple(1,'a') AS x, toTypeName(x) +``` + +``` text +┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ +│ (1,'a') │ Tuple(UInt8, String) │ +└─────────┴───────────────────────────┘ +``` + +## データ型の操作 {#working-with-data-types} + +オンザフライでタプルを作成するとき、ClickHouseは自動的に各引数の型を引数値を格納できる型の最小値として検出します。 引数が [NULL](../../sql-reference/syntax.md#null-literal) タプル要素の型は [Null可能](nullable.md). + +自動データ型検出の例: + +``` sql +SELECT tuple(1, NULL) AS x, toTypeName(x) +``` + +``` text +┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ +│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ +└──────────┴─────────────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/data_types/tuple/) diff --git a/docs/ja/sql-reference/data-types/uuid.md b/docs/ja/sql-reference/data-types/uuid.md new file mode 100644 index 00000000000..3c691dda362 --- /dev/null +++ b/docs/ja/sql-reference/data-types/uuid.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: UUID +--- + +# UUID {#uuid-data-type} + +普遍一意識別子(UUID)は、レコードを識別するために使用される16バイトの番号です。 UUIDの詳細については、以下を参照してください [Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier). + +UUID型の値の例を以下に示します: + +``` text +61f0c404-5cb3-11e7-907b-a6006ad3dba0 +``` + +新しいレコードを挿入するときにUUID列の値を指定しない場合、UUID値はゼロで埋められます: + +``` text +00000000-0000-0000-0000-000000000000 +``` + +## 生成する方法 {#how-to-generate} + +Uuid値を生成するために、ClickHouseは [generateuidv4](../../sql-reference/functions/uuid-functions.md) 機能。 + +## 使用例 {#usage-example} + +**例1** + +この例では、UUID型の列を持つテーブルを作成し、テーブルに値を挿入する方法を示します。 + +``` sql +CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog +``` + +``` sql +INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +└──────────────────────────────────────┴───────────┘ +``` + +**例2** + +この例では、新しいレコードを挿入するときにUUID列の値は指定されません。 + +``` sql +INSERT INTO t_uuid (y) VALUES ('Example 2') +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ +└──────────────────────────────────────┴───────────┘ +``` + +## 制限 {#restrictions} + +UUIDデータ型は、以下の関数のみをサポートします [文字列](string.md) データ型もサポートしています(例, [分](../../sql-reference/aggregate-functions/reference.md#agg_function-min), [最大](../../sql-reference/aggregate-functions/reference.md#agg_function-max),and [カウント](../../sql-reference/aggregate-functions/reference.md#agg_function-count)). + +Uuidデータ型は、算術演算ではサポートされません(たとえば, [abs](../../sql-reference/functions/arithmetic-functions.md#arithm_func-abs))または、以下のような集計関数 [和](../../sql-reference/aggregate-functions/reference.md#agg_function-sum) と [avg](../../sql-reference/aggregate-functions/reference.md#agg_function-avg). + +[元の記事](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md new file mode 100644 index 00000000000..b46e09b0284 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u968E\u5C64\u8F9E\u66F8" +--- + +# 階層辞書 {#hierarchical-dictionaries} + +ClickHouseは、階層辞書をサポートしています [数値キー](external-dicts-dict-structure.md#ext_dict-numeric-key). + +次の階層構造を見てください: + +``` text +0 (Common parent) +│ +├── 1 (Russia) +│ │ +│ └── 2 (Moscow) +│ │ +│ └── 3 (Center) +│ +└── 4 (Great Britain) + │ + └── 5 (London) +``` + +この階層は、次の辞書テーブルとして表すことができます。 + +| region\_id | parent\_region | region\_name | +|------------|----------------|--------------| +| 1 | 0 | ロシア | +| 2 | 1 | モスクワ | +| 3 | 2 | 中央 | +| 4 | 0 | イギリス | +| 5 | 4 | ロンドン | + +このテーブル列 `parent_region` これには、要素の最も近い親のキーが含まれます。 + +クリックハウスは [階層](external-dicts-dict-structure.md#hierarchical-dict-attr) プロパティ [外部辞書](index.md) 属性。 このプロパティを使用すると、上記のような階層辞書を構成できます。 + +その [dictGetHierarchy](../../../sql-reference/functions/ext-dict-functions.md#dictgethierarchy) 関数を使用すると、要素の親チェーンを取得することができます。 + +この例では、dictionaryの構造は次のようになります: + +``` xml + + + + region_id + + + + parent_region + UInt64 + 0 + true + + + + region_name + String + + + + + +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md new file mode 100644 index 00000000000..4a7d5fb1c72 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -0,0 +1,396 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u30E1\u30E2\u30EA\u3078\u306E\u8F9E\u66F8\u306E\u683C\u7D0D" +--- + +# メモリへの辞書の格納 {#dicts-external-dicts-dict-layout} + +辞書をメモリに保存するには、さまざまな方法があります。 + +私達は推薦します [平ら](#flat), [ハッシュ](#dicts-external_dicts_dict_layout-hashed) と [complex\_key\_hashed](#complex-key-hashed). 最適の処理速度を提供するかどれが。 + +キャッシュ推奨されていないものになる可能性のある性能や困難の選定に最適なパラメータ。 セクションの続きを読む “[キャッシュ](#cache)”. + +する方法は幾つかあるが、今回は改善辞書性能: + +- 後で辞書を操作するための関数を呼び出します `GROUP BY`. +- 抽出する属性をinjectiveとしてマークします。 異なる属性値が異なるキーに対応する場合、属性はinjectiveと呼ばれます。 だからとき `GROUP BY` キーによって属性値を取得する関数を使用すると、この関数は自動的に `GROUP BY`. + +ClickHouseは、辞書のエラーに対して例外を生成します。 エラーの例: + +- アクセス中の辞書を読み込めませんでした。 +- クエリエラー `cached` 辞書。 + +外部辞書のリストとそのステータスは、 `system.dictionaries` テーブル。 + +設定は次のようになります: + +``` xml + + + ... + + + + + + ... + + +``` + +対応する [DDL-クエリ](../../statements/create.md#create-dictionary-query): + +``` sql +CREATE DICTIONARY (...) +... +LAYOUT(LAYOUT_TYPE(param value)) -- layout settings +... +``` + +## 辞書をメモリに保存する方法 {#ways-to-store-dictionaries-in-memory} + +- [平ら](#flat) +- [ハッシュ](#dicts-external_dicts_dict_layout-hashed) +- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) +- [キャッシュ](#cache) +- [直接](#direct) +- [range\_hashed](#range-hashed) +- [complex\_key\_hashed](#complex-key-hashed) +- [complex\_key\_cache](#complex-key-cache) +- [ip\_trie](#ip-trie) + +### 平ら {#flat} + +辞書は完全にフラット配列の形でメモリに格納されます。 辞書はどのくらいのメモリを使用しますか? 量は、最大のキーのサイズに比例します(使用されるスペース)。 + +辞書キーには `UInt64` タイプと値は500,000に制限されています。 辞書の作成時に大きなキーが検出された場合、ClickHouseは例外をスローし、辞書を作成しません。 + +すべての種類の源対応しています。 更新時には、ファイルまたはテーブルからのデータが全体として読み込まれます。 + +この方法は最高性能の中で利用可能なすべての方法を格納する辞書です。 + +設定例: + +``` xml + + + +``` + +または + +``` sql +LAYOUT(FLAT()) +``` + +### ハッシュ {#dicts-external_dicts_dict_layout-hashed} + +辞書は、ハッシュテーブルの形でメモリに完全に格納されます。 辞書には、実際には任意の識別子を持つ任意の数の要素を含めることができ、キーの数は数千万の項目に達することができます。 + +すべての種類の源対応しています。 更新時には、ファイルまたはテーブルからのデータが全体として読み込まれます。 + +設定例: + +``` xml + + + +``` + +または + +``` sql +LAYOUT(HASHED()) +``` + +### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} + +に類似した `hashed` が、使用メモリ賛以上のCPUます。 + +設定例: + +``` xml + + + +``` + +``` sql +LAYOUT(SPARSE_HASHED()) +``` + +### complex\_key\_hashed {#complex-key-hashed} + +このタイプの貯蔵は合成物との使用のためです [キー](external-dicts-dict-structure.md). に類似した `hashed`. + +設定例: + +``` xml + + + +``` + +``` sql +LAYOUT(COMPLEX_KEY_HASHED()) +``` + +### range\_hashed {#range-hashed} + +辞書は、範囲とそれに対応する値の順序付き配列を持つハッシュテーブルの形式でメモリに格納されます。 + +このストレージメソッドはハッシュ処理と同じように動作し、キーに加えて日付/時刻(任意の数値型)範囲を使用できます。 + +例:この表には、各広告主の割引が次の形式で含まれています: + +``` text ++---------|-------------|-------------|------+ +| advertiser id | discount start date | discount end date | amount | ++===============+=====================+===================+========+ +| 123 | 2015-01-01 | 2015-01-15 | 0.15 | ++---------|-------------|-------------|------+ +| 123 | 2015-01-16 | 2015-01-31 | 0.25 | ++---------|-------------|-------------|------+ +| 456 | 2015-01-01 | 2015-01-15 | 0.05 | ++---------|-------------|-------------|------+ +``` + +日付範囲のサンプルを使用するには、 `range_min` と `range_max` の要素 [構造](external-dicts-dict-structure.md). これらの要素の要素が含まれている必要があ `name` と`type` (もし `type` 指定されていない場合、デフォルトの型はuse-Dateになります)。 `type` 任意の数値型(Date/DateTime/UInt64/Int32/others)を指定できます。 + +例: + +``` xml + + + Id + + + first + Date + + + last + Date + + ... +``` + +または + +``` sql +CREATE DICTIONARY somedict ( + id UInt64, + first Date, + last Date +) +PRIMARY KEY id +LAYOUT(RANGE_HASHED()) +RANGE(MIN first MAX last) +``` + +これらの辞書を操作するには、追加の引数を渡す必要があります。 `dictGetT` 範囲が選択される関数: + +``` sql +dictGetT('dict_name', 'attr_name', id, date) +``` + +この関数は、指定された値を返します `id`sおよび渡された日付を含む日付範囲。 + +アルゴリズムの詳細: + +- もし `id` が見つからないか、範囲が見つからない。 `id`,ディクショナリのデフォルト値を返します。 +- 重複する範囲がある場合は、anyを使用できます。 +- 範囲区切り文字が `NULL` または無効な日付(1900-01-01または2039-01-01など)、範囲は開いたままになります。 範囲は両側で開くことができる。 + +設定例: + +``` xml + + + + ... + + + + + + + + Abcdef + + + StartTimeStamp + UInt64 + + + EndTimeStamp + UInt64 + + + XXXType + String + + + + + + +``` + +または + +``` sql +CREATE DICTIONARY somedict( + Abcdef UInt64, + StartTimeStamp UInt64, + EndTimeStamp UInt64, + XXXType String DEFAULT '' +) +PRIMARY KEY Abcdef +RANGE(MIN StartTimeStamp MAX EndTimeStamp) +``` + +### キャッシュ {#cache} + +辞書は、固定数のセルを持つキャッシュに格納されます。 これらの細胞を含む使用頻度の高います。 + +辞書を検索するときは、まずキャッシュが検索されます。 データの各ブロックについて、キャッシュ内に見つからない、または古いすべてのキーがソースから要求されます。 `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. 受信したデータは、キャッシュに書き込まれます。 + +キャッシュディクショナリの有効期限 [生涯](external-dicts-dict-lifetime.md) キャッシュ内のデータの設定が可能です。 より多くの時間が `lifetime` セルにデータをロードしてから経過した場合、セルの値は使用されず、次に使用する必要があるときに再要求されます。 +これは、辞書を保存するすべての方法の中で最も効果的ではありません。 キャッシュの速度は、正しい設定と使用シナリオに強く依存します。 キャッシュタイプディクショナリは、ヒット率が十分に高い(推奨99%以上)場合にのみ適切に機能します。 の平均ヒット率を表示することができます `system.dictionaries` テーブル。 + +キャッシュのパフォーマ `LIMIT`、および外部辞書を使用して関数を呼び出します。 + +サポート [ソース](external-dicts-dict-sources.md):MySQL、ClickHouse、実行可能ファイル、HTTP。 + +設定例: + +``` xml + + + + 1000000000 + + +``` + +または + +``` sql +LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) +``` + +設定するのに十分な大きさのキャッシュサイズです。 あなたは細胞の数を選択するために実験する必要があります: + +1. 値を設定します。 +2. 走行クエリーまでのキャッシュを完全に。 +3. を使用してメモリ消費量を評価する `system.dictionaries` テーブル。 +4. 必要なメモリ消費に達するまで、セル数を増減します。 + +!!! warning "警告" + ClickHouseをソースとして使用しないでください。 + +### complex\_key\_cache {#complex-key-cache} + +このタイプの貯蔵は合成物との使用のためです [キー](external-dicts-dict-structure.md). に類似した `cache`. + +### 直接 {#direct} + +辞書はメモリに格納されず、要求の処理中にソースに直接移動します。 + +辞書キーには `UInt64` タイプ。 + +すべてのタイプの [ソース](external-dicts-dict-sources.md) ローカルファイ + +設定例: + +``` xml + + + +``` + +または + +``` sql +LAYOUT(DIRECT()) +``` + +### ip\_trie {#ip-trie} + +このタイプの貯蔵するマッピングするネットワーク接頭辞(IPアドレスへのメタデータなどのASN. + +例:テーブルを含むネットワークの接頭辞およびその対応としての数および国コード: + +``` text + +-----------|-----|------+ + | prefix | asn | cca2 | + +=================+=======+========+ + | 202.79.32.0/20 | 17501 | NP | + +-----------|-----|------+ + | 2620:0:870::/48 | 3856 | US | + +-----------|-----|------+ + | 2a02:6b8:1::/48 | 13238 | RU | + +-----------|-----|------+ + | 2001:db8::/32 | 65536 | ZZ | + +-----------|-----|------+ +``` + +このタイプのレイアウトを使用する場合、構造に複合キーが必要です。 + +例: + +``` xml + + + + prefix + String + + + + asn + UInt32 + + + + cca2 + String + ?? + + ... +``` + +または + +``` sql +CREATE DICTIONARY somedict ( + prefix String, + asn UInt32, + cca2 String DEFAULT '??' +) +PRIMARY KEY prefix +``` + +キーには、許可されたIPプレフィックスを含む文字列型属性のみが必要です。 その他のタイプはサポートされていませんか。 + +クエリでは、同じ関数を使用する必要があります (`dictGetT` タプル付き)複合キーを持つ辞書については: + +``` sql +dictGetT('dict_name', 'attr_name', tuple(ip)) +``` + +この関数は、 `UInt32` IPv4の場合、または `FixedString(16)` IPv6の場合: + +``` sql +dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) +``` + +その他のタイプはサポートされていませんか。 この関数は、このIPアドレスに対応するプレフィックスの属性を返します。 重複する接頭辞がある場合は、最も特定の接頭辞が返されます。 + +データは `trie`. それはRAMに完全に収まる必要があります。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md new file mode 100644 index 00000000000..154c5b40bfb --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md @@ -0,0 +1,91 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u8F9E\u66F8\u306E\u66F4\u65B0" +--- + +# 辞書の更新 {#dictionary-updates} + +ClickHouseは定期的に辞書を更新します。 完全にダウンロードされた辞書の更新間隔と、キャッシュされた辞書の無効化間隔は、 `` 秒単位のタグ。 + +辞書の更新(最初の使用のための読み込み以外)は、クエリをブロックしません。 更新時には、古いバージョンの辞書が使用されます。 更新中にエラーが発生すると、エラーはサーバーログに書き込まれ、クエリは古いバージョンの辞書を使用し続けます。 + +設定例: + +``` xml + + ... + 300 + ... + +``` + +``` sql +CREATE DICTIONARY (...) +... +LIFETIME(300) +... +``` + +設定 `0` (`LIFETIME(0)`)辞書の更新を防ぎます。 + +しかしながら、セッションの時間間隔のアップグレード、ClickHouseを選定しランダム均一に時間以内であることが判明した。 これは、多数のサーバーでアップグレードするときに辞書ソースの負荷を分散するために必要です。 + +設定例: + +``` xml + + ... + + 300 + 360 + + ... + +``` + +または + +``` sql +LIFETIME(MIN 300 MAX 360) +``` + +もし `0` と `0`,ClickHouseはタイムアウトによって辞書をリロードしません。 +この場合、clickhouseは辞書設定ファイルが変更された場合、または `SYSTEM RELOAD DICTIONARY` コマンドが実行された。 + +ップする場合には辞書にClickHouseサーバーに適用の異なるロジックの種類によって [ソース](external-dicts-dict-sources.md): + +ップする場合には辞書にClickHouseサーバーに適用の異なるロジックの種類によって [ソース](external-dicts-dict-sources.md): + +- テキストファイルの場合、変更の時刻をチェックします。 時刻が以前に記録された時刻と異なる場合、辞書が更新されます。 +- MyISAMテーブルの場合、変更時刻は `SHOW TABLE STATUS` クエリ。 +- 他のソースからの辞書は、デフォルトで毎回updatedされます。 + +MySQL(InnoDB)、ODBC、およびClickHouseソースでは、毎回ではなく、実際に変更された場合にのみ辞書を更新するクエリを設定できます。 これを行うには、次の手順に従います: + +- 辞書テーブルには、ソースデータの更新時に常に変更されるフィールドが必要です。 +- ソースの設定では、変更フィールドを取得するクエリを指定する必要があります。 ClickHouseサーバーは、クエリ結果を行として解釈し、この行が以前の状態に対して相対的に変更された場合、辞書が更新されます。 のクエリを指定します。 `` の設定のフィールド [ソース](external-dicts-dict-sources.md). + +設定例: + +``` xml + + ... + + ... + SELECT update_time FROM dictionary_source where id = 1 + + ... + +``` + +または + +``` sql +... +SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) +... +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md new file mode 100644 index 00000000000..d0660444e15 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md @@ -0,0 +1,630 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u5916\u90E8\u8F9E\u66F8\u306E\u30BD\u30FC\u30B9" +--- + +# 外部辞書のソース {#dicts-external-dicts-dict-sources} + +外部辞書は、さまざまなソースから接続できます。 + +辞書がxml-fileを使用して構成されている場合、構成は次のようになります: + +``` xml + + + ... + + + + + + ... + + ... + +``` + +の場合 [DDL-クエリ](../../statements/create.md#create-dictionary-query)、等しい構成は次のようになります: + +``` sql +CREATE DICTIONARY dict_name (...) +... +SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration +... +``` + +ソースは、 `source` セクション + +ソースタイプの場合 [ローカル](#dicts-external_dicts_dict_sources-local_file), [実行可能ファイル](#dicts-external_dicts_dict_sources-executable), [HTTP(s)](#dicts-external_dicts_dict_sources-http), [クリックハウス](#dicts-external_dicts_dict_sources-clickhouse) +任意設定は利用できる: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + + 0 + + +``` + +または + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +SETTINGS(format_csv_allow_single_quotes = 0) +``` + +ソースの種類 (`source_type`): + +- [ローカル](#dicts-external_dicts_dict_sources-local_file) +- [実行可能ファイル](#dicts-external_dicts_dict_sources-executable) +- [HTTP(s)](#dicts-external_dicts_dict_sources-http) +- DBMS + - [ODBC](#dicts-external_dicts_dict_sources-odbc) + - [MySQL](#dicts-external_dicts_dict_sources-mysql) + - [クリックハウス](#dicts-external_dicts_dict_sources-clickhouse) + - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) + - [Redis](#dicts-external_dicts_dict_sources-redis) + +## ローカル {#dicts-external_dicts_dict_sources-local_file} + +設定例: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + +``` + +または + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +フィールドの設定: + +- `path` – The absolute path to the file. +- `format` – The file format. All the formats described in “[形式](../../../interfaces/formats.md#formats)” サポートされます。 + +## 実行可能ファイル {#dicts-external_dicts_dict_sources-executable} + +実行可能ファイルを操作するには [辞書をメモリに格納する方法](external-dicts-dict-layout.md). 辞書が以下を使用して格納されている場合 `cache` と `complex_key_cache`,ClickHouseは、実行可能ファイルのSTDINに要求を送信することによって、必要なキーを要求します。 その他、ClickHouse始まり実行可能ファイルを扱い、その出力としての辞書のデータです。 + +設定例: + +``` xml + + + cat /opt/dictionaries/os.tsv + TabSeparated + + +``` + +または + +``` sql +SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +フィールドの設定: + +- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). +- `format` – The file format. All the formats described in “[形式](../../../interfaces/formats.md#formats)” サポートされます。 + +## Http(s) {#dicts-external_dicts_dict_sources-http} + +HTTPサーバーでの作業は次のように依存します [辞書をメモリに格納する方法](external-dicts-dict-layout.md). 辞書が以下を使用して格納されている場合 `cache` と `complex_key_cache` クトを送信することにより、必要なキーを要求します。 `POST` 方法。 + +設定例: + +``` xml + + + http://[::1]/os.tsv + TabSeparated + + user + password + + +
+ API-KEY + key +
+
+
+ +``` + +または + +``` sql +SOURCE(HTTP( + url 'http://[::1]/os.tsv' + format 'TabSeparated' + credentials(user 'user' password 'password') + headers(header(name 'API-KEY' value 'key')) +)) +``` + +ClickHouseがHTTPSリソースにアクセスするには、次の操作が必要です [openSSLの設定](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-openssl) サーバー構成で。 + +フィールドの設定: + +- `url` – The source URL. +- `format` – The file format. All the formats described in “[形式](../../../interfaces/formats.md#formats)” サポートされます。 +- `credentials` – Basic HTTP authentication. Optional parameter. + - `user` – Username required for the authentication. + - `password` – Password required for the authentication. +- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. + - `header` – Single HTTP header entry. + - `name` – Identifiant name used for the header send on the request. + - `value` – Value set for a specific identifiant name. + +## ODBC {#dicts-external_dicts_dict_sources-odbc} + +このメソッドを使用して、ODBCドライバーを持つデータベースに接続できます。 + +設定例: + +``` xml + + + DatabaseName + ShemaName.TableName
+ DSN=some_parameters + SQL_QUERY +
+ +``` + +または + +``` sql +SOURCE(ODBC( + db 'DatabaseName' + table 'SchemaName.TableName' + connection_string 'DSN=some_parameters' + invalidate_query 'SQL_QUERY' +)) +``` + +フィールドの設定: + +- `db` – Name of the database. Omit it if the database name is set in the `` 変数。 +- `table` – Name of the table and schema if exists. +- `connection_string` – Connection string. +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [辞書の更新](external-dicts-dict-lifetime.md). + +ClickHouseはODBC-driverから引用シンボルを受け取り、クエリ内のすべての設定をdriverに引用するため、データベース内のテーブル名の大文字と小文字に応じてテーブル名を + +Oracleの使用時にエンコーディングに問題がある場合は、対応するものを参照してください [FAQ](../../../faq/general.md#oracle-odbc-encodings) 記事だ + +### ODBCディクショナリ機能の既知の脆弱性 {#known-vulnerability-of-the-odbc-dictionary-functionality} + +!!! attention "注意" + ODBCドライバー接続パラメーターでデータベースに接続する場合 `Servername` 置換可能である。 この場合の値は `USERNAME` と `PASSWORD` から `odbc.ini` リモートサーバーに送信され、侵害される可能性があります。 + +**安全でない使用の例** + +PostgreSQL用のunixODBCを設定しましょう。 の内容 `/etc/odbc.ini`: + +``` text +[gregtest] +Driver = /usr/lib/psqlodbca.so +Servername = localhost +PORT = 5432 +DATABASE = test_db +#OPTION = 3 +USERNAME = test +PASSWORD = test +``` + +次に、次のようなクエリを作成する場合 + +``` sql +SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); +``` + +ODBCドライバは、次の値を送信します `USERNAME` と `PASSWORD` から `odbc.ini` に `some-server.com`. + +### Postgresqlの接続例 {#example-of-connecting-postgresql} + +Ubuntu OS。 + +UnixodbcとPOSTGRESQL用ODBCドライバのインストール: + +``` bash +$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql +``` + +設定 `/etc/odbc.ini` (または `~/.odbc.ini`): + +``` text + [DEFAULT] + Driver = myconnection + + [myconnection] + Description = PostgreSQL connection to my_db + Driver = PostgreSQL Unicode + Database = my_db + Servername = 127.0.0.1 + UserName = username + Password = password + Port = 5432 + Protocol = 9.3 + ReadOnly = No + RowVersioning = No + ShowSystemTables = No + ConnSettings = +``` + +ClickHouseの辞書構成: + +``` xml + + + table_name + + + + + DSN=myconnection + postgresql_table
+
+ + + 300 + 360 + + + + + + + id + + + some_column + UInt64 + 0 + + +
+
+``` + +または + +``` sql +CREATE DICTIONARY table_name ( + id UInt64, + some_column UInt64 DEFAULT 0 +) +PRIMARY KEY id +SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) +LAYOUT(HASHED()) +LIFETIME(MIN 300 MAX 360) +``` + +編集が必要な場合があります `odbc.ini` ドライバを使用してライブラリへの完全パスを指定するには `DRIVER=/usr/local/lib/psqlodbcw.so`. + +### MS SQL Serverの接続例 {#example-of-connecting-ms-sql-server} + +Ubuntu OS。 + +ドライバの取り付け: : + +``` bash +$ sudo apt-get install tdsodbc freetds-bin sqsh +``` + +ドライバの設定: + +``` bash + $ cat /etc/freetds/freetds.conf + ... + + [MSSQL] + host = 192.168.56.101 + port = 1433 + tds version = 7.0 + client charset = UTF-8 + + $ cat /etc/odbcinst.ini + ... + + [FreeTDS] + Description = FreeTDS + Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so + Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so + FileUsage = 1 + UsageCount = 5 + + $ cat ~/.odbc.ini + ... + + [MSSQL] + Description = FreeTDS + Driver = FreeTDS + Servername = MSSQL + Database = test + UID = test + PWD = test + Port = 1433 +``` + +ClickHouseでの辞書の構成: + +``` xml + + + test + + + dict
+ DSN=MSSQL;UID=test;PWD=test +
+ + + + 300 + 360 + + + + + + + + + k + + + s + String + + + +
+
+``` + +または + +``` sql +CREATE DICTIONARY test ( + k UInt64, + s String DEFAULT '' +) +PRIMARY KEY k +SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) +LAYOUT(FLAT()) +LIFETIME(MIN 300 MAX 360) +``` + +## DBMS {#dbms} + +### Mysql {#dicts-external_dicts_dict_sources-mysql} + +設定例: + +``` xml + + + 3306 + clickhouse + qwerty + + example01-1 + 1 + + + example01-2 + 1 + + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +または + +``` sql +SOURCE(MYSQL( + port 3306 + user 'clickhouse' + password 'qwerty' + replica(host 'example01-1' priority 1) + replica(host 'example01-2' priority 1) + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +フィールドの設定: + +- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). + +- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). + +- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). + +- `replica` – Section of replica configurations. There can be multiple sections. + + - `replica/host` – The MySQL host. + - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. + +- `db` – Name of the database. + +- `table` – Name of the table. + +- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` MySQLの句、例えば, `id > 10 AND id < 20`. 任意パラメータ。 + +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [辞書の更新](external-dicts-dict-lifetime.md). + +MySQLはソケットを介してローカルホストに接続できます。 これを行うには、 `host` と `socket`. + +設定例: + +``` xml + + + localhost + /path/to/socket/file.sock + clickhouse + qwerty + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +または + +``` sql +SOURCE(MYSQL( + host 'localhost' + socket '/path/to/socket/file.sock' + user 'clickhouse' + password 'qwerty' + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +### クリックハウス {#dicts-external_dicts_dict_sources-clickhouse} + +設定例: + +``` xml + + + example01-01-1 + 9000 + default + + default + ids
+ id=10 +
+ +``` + +または + +``` sql +SOURCE(CLICKHOUSE( + host 'example01-01-1' + port 9000 + user 'default' + password '' + db 'default' + table 'ids' + where 'id=10' +)) +``` + +フィールドの設定: + +- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [分散](../../../engines/table-engines/special/distributed.md) テーブルと後続の構成でそれを入力します。 +- `port` – The port on the ClickHouse server. +- `user` – Name of the ClickHouse user. +- `password` – Password of the ClickHouse user. +- `db` – Name of the database. +- `table` – Name of the table. +- `where` – The selection criteria. May be omitted. +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [辞書の更新](external-dicts-dict-lifetime.md). + +### Mongodb {#dicts-external_dicts_dict_sources-mongodb} + +設定例: + +``` xml + + + localhost + 27017 + + + test + dictionary_source + + +``` + +または + +``` sql +SOURCE(MONGO( + host 'localhost' + port 27017 + user '' + password '' + db 'test' + collection 'dictionary_source' +)) +``` + +フィールドの設定: + +- `host` – The MongoDB host. +- `port` – The port on the MongoDB server. +- `user` – Name of the MongoDB user. +- `password` – Password of the MongoDB user. +- `db` – Name of the database. +- `collection` – Name of the collection. + +### Redis {#dicts-external_dicts_dict_sources-redis} + +設定例: + +``` xml + + + localhost + 6379 + simple + 0 + + +``` + +または + +``` sql +SOURCE(REDIS( + host 'localhost' + port 6379 + storage_type 'simple' + db_index 0 +)) +``` + +フィールドの設定: + +- `host` – The Redis host. +- `port` – The port on the Redis server. +- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` は簡単な源のためのハッシュされたシングルキー源, `hash_map` 二つのキーを持つハッシュソース用です。 距源およびキャッシュ源の複雑な鍵サポートされていません。 省略可能であり、デフォルト値は `simple`. +- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md new file mode 100644 index 00000000000..b35b0477b75 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md @@ -0,0 +1,175 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u8F9E\u66F8\u30AD\u30FC\u3068\u30D5\u30A3\u30FC\u30EB\u30C9" +--- + +# 辞書キーとフィールド {#dictionary-key-and-fields} + +その `` 句クエリで使用できる辞書キーとフィールドを説明します。 + +XMLの説明: + +``` xml + + + + Id + + + + + + + ... + + + +``` + +属性は要素に記述されています: + +- `` — [キー列](external-dicts-dict-structure.md#ext_dict_structure-key). +- `` — [データ列](external-dicts-dict-structure.md#ext_dict_structure-attributes). 複数の属性が存在する可能性があります。 + +DDLクエリ: + +``` sql +CREATE DICTIONARY dict_name ( + Id UInt64, + -- attributes +) +PRIMARY KEY Id +... +``` + +属性は、クエリの本文に記述されています: + +- `PRIMARY KEY` — [キー列](external-dicts-dict-structure.md#ext_dict_structure-key) +- `AttrName AttrType` — [データ列](external-dicts-dict-structure.md#ext_dict_structure-attributes). 複数の属性が存在する可能性があります。 + +## キー {#ext_dict_structure-key} + +ClickHouseは次の種類のキーをサポートしています: + +- 数値キー。 `UInt64`. で定義される。 `` タグまたは使用 `PRIMARY KEY` キーワード。 +- 複合キー。 異なる型の値のセット。 タグで定義 `` または `PRIMARY KEY` キーワード。 + +Xmlの構造を含むことができま `` または ``. DDL-クエリには単一を含む必要があります `PRIMARY KEY`. + +!!! warning "警告" + キーを属性として記述することはできません。 + +### 数値キー {#ext_dict-numeric-key} + +タイプ: `UInt64`. + +設定例: + +``` xml + + Id + +``` + +設定フィールド: + +- `name` – The name of the column with keys. + +DDLクエリの場合: + +``` sql +CREATE DICTIONARY ( + Id UInt64, + ... +) +PRIMARY KEY Id +... +``` + +- `PRIMARY KEY` – The name of the column with keys. + +### 複合キー {#composite-key} + +キーはaである場合もあります `tuple` フィールドの任意のタイプから。 その [レイアウト](external-dicts-dict-layout.md) この場合、 `complex_key_hashed` または `complex_key_cache`. + +!!! tip "ヒント" + 複合キーは、単一の要素で構成できます。 これにより、たとえば文字列をキーとして使用することができます。 + +キー構造は要素に設定されます ``. キーフィールドは、辞書と同じ形式で指定されます [属性](external-dicts-dict-structure.md). 例: + +``` xml + + + + field1 + String + + + field2 + UInt32 + + ... + +... +``` + +または + +``` sql +CREATE DICTIONARY ( + field1 String, + field2 String + ... +) +PRIMARY KEY field1, field2 +... +``` + +クエリに対して `dictGet*` 関数は、タプルがキーとして渡されます。 例: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. + +## 属性 {#ext_dict_structure-attributes} + +設定例: + +``` xml + + ... + + Name + ClickHouseDataType + + rand64() + true + true + true + + +``` + +または + +``` sql +CREATE DICTIONARY somename ( + Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID +) +``` + +設定フィールド: + +| タグ | 説明 | 必須 | +|------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| `name` | 列名。 | はい。 | +| `type` | ClickHouseデータ型。
ClickHouseは、dictionaryから指定されたデータ型に値をキャストしようとします。 例えば、MySQL、フィールドが `TEXT`, `VARCHAR`,または `BLOB` MySQLソーステーブルでは、次のようにアップロードできます `String` クリックハウスで
[Null可能](../../../sql-reference/data-types/nullable.md) サポートされていない。 | はい。 | +| `null_value` | 既存の要素以外の既定値。
この例では、空の文字列です。 使用できません `NULL` この分野で。 | はい。 | +| `expression` | [式](../../syntax.md#syntax-expressions) そのClickHouseは値に対して実行されます。
式には、リモートSQLデータベースの列名を指定できます。 したがって、リモート列の別名を作成するために使用できます。

デフォルト値:式なし。 | いいえ。 | +| `hierarchical` | もし `true` この属性には、現在のキーの親キーの値が含まれます。 見る [階層辞書](external-dicts-dict-hierarchical.md).

デフォルト値: `false`. | いいえ。 | +| `injective` | このフラグは `id -> attribute` 画像は [injective](https://en.wikipedia.org/wiki/Injective_function).
もし `true`、ClickHouseはの後に自動的に置くことができます `GROUP BY` 句インジェクションを使用した辞書への要求。 通常、そのような要求の量を大幅に削減します。

デフォルト値: `false`. | いいえ。 | +| `is_object_id` | クエリがMongoDBドキュメントに対して実行されるかどうかを示すフラグ `ObjectID`.

デフォルト値: `false`. | いいえ。 | + +## も参照。 {#see-also} + +- [外部辞書を操作するための関数](../../../sql-reference/functions/ext-dict-functions.md). + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md new file mode 100644 index 00000000000..6972e09e324 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md @@ -0,0 +1,53 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u5916\u90E8\u30C7\u30A3\u30AF\u30B7\u30E7\u30CA\u30EA\u306E\u69CB\u6210" +--- + +# 外部ディクショナリの構成 {#dicts-external-dicts-dict} + +辞書がxmlファイルを使用して構成されている場合、辞書の構成は次の構造になります: + +``` xml + + dict_name + + + + + + + + + + + + + + + + + +``` + +対応する [DDL-クエリ](../../statements/create.md#create-dictionary-query) 次の構造を持ちます: + +``` sql +CREATE DICTIONARY dict_name +( + ... -- attributes +) +PRIMARY KEY ... -- complex or single key configuration +SOURCE(...) -- Source configuration +LAYOUT(...) -- Memory layout configuration +LIFETIME(...) -- Lifetime of dictionary in memory +``` + +- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. +- [ソース](external-dicts-dict-sources.md) — Source of the dictionary. +- [レイアウト](external-dicts-dict-layout.md) — Dictionary layout in memory. +- [構造](external-dicts-dict-structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. +- [生涯](external-dicts-dict-lifetime.md) — Frequency of dictionary updates. + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts.md new file mode 100644 index 00000000000..51b3ecf1900 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/external-dicts.md @@ -0,0 +1,62 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u4E00\u822C\u7684\u306A\u8AAC\u660E" +--- + +# 外部辞書 {#dicts-external-dicts} + +さまざまなデータソースから独自の辞書を追加できます。 ディクショナリのデータソースには、ローカルテキストまたは実行可能ファイル、HTTPリソース、または別のDBMSを使用できます。 詳細については、 “[外部辞書のソース](external-dicts-dict-sources.md)”. + +クリックハウス: + +- 完全または部分的にRAMに辞書を格納します。 +- 辞書を定期的に更新し、欠損値を動的に読み込みます。 つまり、辞書は動的に読み込むことができます。 +- Xmlファイルで外部辞書を作成することができます。 [DDLクエリ](../../statements/create.md#create-dictionary-query). + +外部辞書の構成は、一つ以上のxmlファイルに配置できます。 設定へのパスは [dictionaries\_config](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_config) パラメータ。 + +辞書は、サーバーの起動時または最初の使用時に読み込むことができます。 [dictionaries\_lazy\_load](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) 設定。 + +その [辞書](../../../operations/system-tables.md#system_tables-dictionaries) システムテーブルについての情報が含まれて辞書に設定されます。 各辞書については、そこにあります: + +- 辞書の状態。 +- 設定パラメータ。 +- メトリクスのような量のメモリ割り当てのための辞書は多数のクエリからの辞書に成功したとみなされます。 + +辞書構成ファイルの形式は次のとおりです: + +``` xml + + An optional element with any content. Ignored by the ClickHouse server. + + + /etc/metrika.xml + + + + + + + + +``` + +あなたはできる [設定](external-dicts-dict.md) 同じファイル内の任意の数の辞書。 + +[辞書のDDLクエリ](../../statements/create.md#create-dictionary-query) サーバー構成に追加のレコードは必要ありません。 この仕事を辞書として第一級の体のように、テーブルやビュー。 + +!!! attention "注意" + 小さな辞書の値を変換するには、次のように記述します `SELECT` クエリ(参照 [変換](../../../sql-reference/functions/other-functions.md) 機能)。 この機能は外部辞書とは関係ありません。 + +## も参照。 {#ext-dicts-see-also} + +- [外部ディクショナリの構成](external-dicts-dict.md) +- [メモリへの辞書の格納](external-dicts-dict-layout.md) +- [辞書の更新](external-dicts-dict-lifetime.md) +- [外部辞書のソース](external-dicts-dict-sources.md) +- [辞書キーとフィールド](external-dicts-dict-structure.md) +- [外部辞書を操作するための関数](../../../sql-reference/functions/ext-dict-functions.md) + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/ja/sql-reference/dictionaries/external-dictionaries/index.md b/docs/ja/sql-reference/dictionaries/external-dictionaries/index.md new file mode 100644 index 00000000000..288dc59ef23 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/external-dictionaries/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u5916\u90E8\u8F9E\u66F8" +toc_priority: 37 +--- + + diff --git a/docs/ja/sql-reference/dictionaries/index.md b/docs/ja/sql-reference/dictionaries/index.md new file mode 100644 index 00000000000..cb6bb168e1f --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/index.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u8F9E\u66F8" +toc_priority: 35 +toc_title: "\u306F\u3058\u3081\u306B" +--- + +# 辞書 {#dictionaries} + +辞書はマッピングです (`key -> attributes`)それはさまざまなタイプの参照リストのために便利です。 + +ClickHouseは、クエリで使用できる辞書を操作するための特別な関数をサポートしています。 関数で辞書を使用する方が簡単で効率的です。 `JOIN` 参照のテーブルを使って。 + +[NULL](../../sql-reference/syntax.md#null-literal) 値を辞書に格納することはできません。 + +ClickHouseサポート: + +- [組み込み辞書](internal-dicts.md#internal_dicts) 特定の [関数のセット](../../sql-reference/functions/ym-dict-functions.md). +- [プラグイン(外部)辞書](external-dictionaries/external-dicts.md#dicts-external-dicts) と [関数のセット](../../sql-reference/functions/ext-dict-functions.md). + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/ja/sql-reference/dictionaries/internal-dicts.md b/docs/ja/sql-reference/dictionaries/internal-dicts.md new file mode 100644 index 00000000000..81b75075c27 --- /dev/null +++ b/docs/ja/sql-reference/dictionaries/internal-dicts.md @@ -0,0 +1,55 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u5185\u90E8\u8F9E\u66F8" +--- + +# 内部辞書 {#internal_dicts} + +ClickHouseには、ジオベースを操作するための組み込み機能が含まれています。 + +これにより、: + +- 地域のIDを使用して、目的の言語でその名前を取得します。 +- 地域のIDを使用して、都市、地域、連邦区、国、または大陸のIDを取得します。 +- ある地域が別の地域の一部であるかどうかを確認します。 +- 親領域のチェーンを取得します。 + +すべての機能サポート “translocality,” 地域の所有権に関する異なる視点を同時に使用する能力。 詳細については “Functions for working with Yandex.Metrica dictionaries”. + +既定のパッケージでは、内部辞書は無効になっています。 +よって、strncasecmpのパラメータ `path_to_regions_hierarchy_file` と `path_to_regions_names_files` サーバー設定ファイル内。 + +Geobaseはテキストファイルから読み込まれます。 + +を置く `regions_hierarchy*.txt` にファイル `path_to_regions_hierarchy_file` ディレクトリ。 この構成パラメータには、 `regions_hierarchy.txt` ファイル(既定の地域階層)、およびその他のファイル (`regions_hierarchy_ua.txt`)同じディレクトリにある必要があります。 + +を置く `regions_names_*.txt` のファイル `path_to_regions_names_files` ディレクトリ。 + +を作ることもできますこれらのファイル。 ファイル形式は次のとおりです: + +`regions_hierarchy*.txt`:TabSeparated(ヘッダーなし),列: + +- 地域ID (`UInt32`) +- 親リージョンID (`UInt32`) +- 地域タイプ (`UInt8`):1大陸、3国、4連邦区、5地域、6都市。 +- 人口 (`UInt32`) — optional column + +`regions_names_*.txt`:TabSeparated(ヘッダーなし),列: + +- 地域ID (`UInt32`) +- 地域名 (`String`) — Can't contain tabs or line feeds, even escaped ones. + +フラットアレイは、RAMに格納するために使用されます。 このため、Idは百万を超えるべきではありません。 + +辞書は、サーバーを再起動せずに更新できます。 ただし、使用可能な辞書のセットは更新されません。 +更新の場合、ファイルの変更時間がチェックされます。 ファイルが変更された場合は、辞書が更新されます。 +変更をチェックする間隔は、 `builtin_dictionaries_reload_interval` パラメータ。 +辞書の更新(最初の使用時の読み込み以外)は、クエリをブロックしません。 更新中、クエリは古いバージョンの辞書を使用します。 更新中にエラーが発生すると、エラーはサーバーログに書き込まれ、クエリは古いバージョンの辞書を使用し続けます。 + +Geobaseで辞書を定期的に更新することをお勧めします。 更新中に、新しいファイルを生成し、別の場所に書き込みます。 すべての準備ができたら、サーバーが使用するファイルに名前を変更します。 + +OS識別子とYandexを操作するための機能もあります。Metricaの調査エンジン、しかしそれらは使用されるべきではない。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/ja/sql-reference/functions/arithmetic-functions.md b/docs/ja/sql-reference/functions/arithmetic-functions.md new file mode 100644 index 00000000000..0afd85b63bc --- /dev/null +++ b/docs/ja/sql-reference/functions/arithmetic-functions.md @@ -0,0 +1,87 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: "\u7B97\u8853" +--- + +# 算術関数 {#arithmetic-functions} + +すべての算術関数について、結果の型は、そのような型がある場合、結果が収まる最小の数値型として計算されます。 最小値は、ビット数、署名されているかどうか、および浮動小数点数に基づいて同時に取得されます。 十分なビットがない場合は、最も高いビットタイプが取られます。 + +例: + +``` sql +SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) +``` + +``` text +┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ +│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ +└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ +``` + +算術関数は、UInt8、UInt16、UInt32、UInt64、Int8、Int16、Int32、Int64、Float32、Float64のいずれかの型のペアに対しても機能します。 + +オーバーフローは、C++と同じ方法で生成されます。 + +## プラス(a、b)、a+b演算子 {#plusa-b-a-b-operator} + +数値の合計を計算します。 +また、日付または日付と時刻を持つ整数を追加することもできます。 日付の場合、整数を追加することは、対応する日数を追加することを意味します。 日付と時刻の場合は、対応する秒数を加算することを意味します。 + +## マイナス(a,b),a-b演算子 {#minusa-b-a-b-operator} + +差を計算します。 結果は常に署名されます。 + +You can also calculate integer numbers from a date or date with time. The idea is the same – see above for ‘plus’. + +## 乗算(a,b),a\*b演算子 {#multiplya-b-a-b-operator} + +数値の積を計算します。 + +## 除算(a,b)、a/b演算子 {#dividea-b-a-b-operator} + +数値の商を計算します。 結果の型は常に浮動小数点型です。 +整数除算ではありません。 整数除算の場合は、 ‘intDiv’ 機能。 +ゼロで割ると ‘inf’, ‘-inf’,または ‘nan’. + +## intDiv(a,b) {#intdiva-b} + +数値の商を計算します。 整数に分割し、(絶対値で)丸めます。 +例外は、ゼロで除算するとき、または最小の負の数をマイナスで除算するときにスローされます。 + +## intDivOrZero(a,b) {#intdivorzeroa-b} + +とは異なる ‘intDiv’ ゼロで除算するとき、または最小の負の数をマイナスで除算するときにゼロを返します。 + +## modulo(a,b),a%b演算子 {#moduloa-b-a-b-operator} + +除算後の剰余を計算します。 +引数が浮動小数点数の場合は、小数点部分を削除することによって整数に事前変換されます。 +残りはC++と同じ意味で取られます。 切り捨て除算は、負の数に使用されます。 +例外は、ゼロで除算するとき、または最小の負の数をマイナスで除算するときにスローされます。 + +## moduloOrZero(a,b) {#moduloorzeroa-b} + +とは異なる ‘modulo’ 除数がゼロのときにゼロを返すという点で。 + +## 否定(a),-演算子 {#negatea-a-operator} + +逆符号で数値を計算します。 結果は常に署名されます。 + +## abs(a) {#arithm_func-abs} + +数値(a)の絶対値を算出する。 つまり、a\<0の場合、-aを返します。 符号付き整数型の場合、符号なしの数値を返します。 + +## gcd(a,b) {#gcda-b} + +数値の最大公約数を返します。 +例外は、ゼロで除算するとき、または最小の負の数をマイナスで除算するときにスローされます。 + +## lcm(a,b) {#lcma-b} + +数値の最小公倍数を返します。 +例外は、ゼロで除算するとき、または最小の負の数をマイナスで除算するときにスローされます。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/ja/sql-reference/functions/array-functions.md b/docs/ja/sql-reference/functions/array-functions.md new file mode 100644 index 00000000000..5a70770a54b --- /dev/null +++ b/docs/ja/sql-reference/functions/array-functions.md @@ -0,0 +1,1061 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: "\u914D\u5217\u306E\u64CD\u4F5C" +--- + +# 配列を操作するための関数 {#functions-for-working-with-arrays} + +## 空 {#function-empty} + +空の配列の場合は1、空でない配列の場合は0を返します。 +結果の型はUInt8です。 +この関数は文字列に対しても機能します。 + +## ノーテンプティ {#function-notempty} + +空の配列の場合は0、空でない配列の場合は1を返します。 +結果の型はUInt8です。 +この関数は文字列に対しても機能します。 + +## 長さ {#array_functions-length} + +配列内の項目の数を返します。 +結果の型はUInt64です。 +この関数は文字列に対しても機能します。 + +## emptyArrayUInt8,emptyArrayUInt16,emptyArrayUInt32,emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} + +## emptyArrayInt8,emptyArrayInt16,emptyArrayInt32,emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} + +## emptyArrayFloat32,emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} + +## emptyArrayDate,emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} + +## emptyArrayString {#emptyarraystring} + +ゼロの引数を受け取り、適切な型の空の配列を返します。 + +## エンプティアライトシングル {#emptyarraytosingle} + +空の配列を受け取り、既定値と等しい一要素配列を返します。 + +## 範囲(終了)、範囲(開始、終了\[、ステップ\]) {#rangeend-rangestart-end-step} + +開始から終了-1までの数値の配列をステップごとに返します。 +引数が `start` 既定値は0です。 +引数が `step` 既定値は1です。 +それはpythonicのように動作します `range`. しかし、違いは、すべての引数の型は `UInt` 数字だ +場合によっては、合計長が100,000,000を超える要素の配列がデータブロックに作成されると、例外がスローされます。 + +## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} + +関数の引数から配列を作成します。 +引数は定数であり、最小の共通型を持つ型を持つ必要があります。 それ以外の場合は、作成する配列の型が明確ではないためです。 つまり、この関数を使用して空の配列を作成することはできません(それを行うには、 ‘emptyArray\*’ 以上の機能)。 +を返す ‘Array(T)’ "result"と入力します。 ‘T’ 渡された引数のうち最小の共通型です。 + +## arrayConcat {#arrayconcat} + +引数として渡された配列を結合します。 + +``` sql +arrayConcat(arrays) +``` + +**パラメータ** + +- `arrays` – Arbitrary number of arguments of [配列](../../sql-reference/data-types/array.md) タイプ。 + **例** + + + +``` sql +SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res +``` + +``` text +┌─res───────────┐ +│ [1,2,3,4,5,6] │ +└───────────────┘ +``` + +## arrayElement(arr,n),演算子arr\[n\] {#arrayelementarr-n-operator-arrn} + +インデックスを持つ要素を取得します `n` 配列から `arr`. `n` 任意の整数型である必要があります。 +配列のインデックスは、配列から始まります。 +負の索引がサポートされます。 この場合、末尾から番号付きの対応する要素を選択する。 例えば, `arr[-1]` 配列内の最後の項目です。 + +インデックスが配列の境界の外にある場合、デフォルト値(数値の場合は0、文字列の場合は空の文字列など)を返します。非定数配列と定数インデックス0の場合を除きます(この場合はエラーが発生します `Array indices are 1-based`). + +## has(arr,elem) {#hasarr-elem} + +チェックかどうか ‘arr’ 配列は ‘elem’ 要素。 +要素が配列内にない場合は0を返し、要素が配列内にない場合は1を返します。 + +`NULL` 値として処理されます。 + +``` sql +SELECT has([1, 2, NULL], NULL) +``` + +``` text +┌─has([1, 2, NULL], NULL)─┐ +│ 1 │ +└─────────────────────────┘ +``` + +## hasAll {#hasall} + +ある配列が別の配列のサブセットかどうかを確認します。 + +``` sql +hasAll(set, subset) +``` + +**パラメータ** + +- `set` – Array of any type with a set of elements. +- `subset` – Array of any type with elements that should be tested to be a subset of `set`. + +**戻り値** + +- `1`,if `set` すべての要素が含まれています `subset`. +- `0` そうでなければ + +**独特の特性** + +- 空の配列は、任意の配列のサブセットです。 +- `Null` 値として処理されます。 +- 両方の配列の値の順序は重要ではありません。 + +**例** + +`SELECT hasAll([], [])` 1を返します。 + +`SELECT hasAll([1, Null], [Null])` 1を返します。 + +`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` 1を返します。 + +`SELECT hasAll(['a', 'b'], ['a'])` 1を返します。 + +`SELECT hasAll([1], ['a'])` 0を返します。 + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` 0を返します。 + +## ハサニー {#hasany} + +るかどうかを判二つの配列が互いの交差点にある。 + +``` sql +hasAny(array1, array2) +``` + +**パラメータ** + +- `array1` – Array of any type with a set of elements. +- `array2` – Array of any type with a set of elements. + +**戻り値** + +- `1`,if `array1` と `array2` 少なくとも一つの同様の要素があります。 +- `0` そうでなければ + +**独特の特性** + +- `Null` 値として処理されます。 +- 両方の配列の値の順序は重要ではありません。 + +**例** + +`SELECT hasAny([1], [])` ツづゥツ。 `0`. + +`SELECT hasAny([Null], [Null, 1])` ツづゥツ。 `1`. + +`SELECT hasAny([-128, 1., 512], [1])` ツづゥツ。 `1`. + +`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` ツづゥツ。 `0`. + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` ツづゥツ。 `1`. + +## インデックス(arr,x) {#indexofarr-x} + +最初のインデックスを返します ‘x’ 配列内にある場合は要素(1から始まる)、そうでない場合は0。 + +例: + +``` sql +SELECT indexOf([1, 3, NULL, NULL], NULL) +``` + +``` text +┌─indexOf([1, 3, NULL, NULL], NULL)─┐ +│ 3 │ +└───────────────────────────────────┘ +``` + +に設定された要素 `NULL` 通常の値として処理されます。 + +## カウントイカル(arr,x) {#countequalarr-x} + +Xと等しい配列内の要素の数を返します。arrayCount(elem-\>elem=x,arr)と同等です。 + +`NULL` 要素は個別の値として処理されます。 + +例: + +``` sql +SELECT countEqual([1, 2, NULL, NULL], NULL) +``` + +``` text +┌─countEqual([1, 2, NULL, NULL], NULL)─┐ +│ 2 │ +└──────────────────────────────────────┘ +``` + +## アレイン(arr) {#array_functions-arrayenumerate} + +Returns the array \[1, 2, 3, …, length (arr) \] + +この関数は通常、配列結合で使用されます。 配列結合を適用した後、配列ごとに一度だけ何かを数えることができます。 例: + +``` sql +SELECT + count() AS Reaches, + countIf(num = 1) AS Hits +FROM test.hits +ARRAY JOIN + GoalsReached, + arrayEnumerate(GoalsReached) AS num +WHERE CounterID = 160656 +LIMIT 10 +``` + +``` text +┌─Reaches─┬──Hits─┐ +│ 95606 │ 31406 │ +└─────────┴───────┘ +``` + +この例では、Reachはコンバージョン数(配列結合を適用した後に受信した文字列)、Hitsはページビュー数(配列結合の前の文字列)です。 この特定のケースでは、同じ結果を簡単に得ることができます: + +``` sql +SELECT + sum(length(GoalsReached)) AS Reaches, + count() AS Hits +FROM test.hits +WHERE (CounterID = 160656) AND notEmpty(GoalsReached) +``` + +``` text +┌─Reaches─┬──Hits─┐ +│ 95606 │ 31406 │ +└─────────┴───────┘ +``` + +この関数は、高次関数でも使用できます。 たとえば、条件に一致する要素の配列インデックスを取得するために使用できます。 + +## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} + +ソース配列と同じサイズの配列を返します。 +たとえば、arrayEnumerateUniq(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. + +この関数は、配列結合と配列要素の集計を使用する場合に便利です。 +例: + +``` sql +SELECT + Goals.ID AS GoalID, + sum(Sign) AS Reaches, + sumIf(Sign, num = 1) AS Visits +FROM test.visits +ARRAY JOIN + Goals, + arrayEnumerateUniq(Goals.ID) AS num +WHERE CounterID = 160656 +GROUP BY GoalID +ORDER BY Reaches DESC +LIMIT 10 +``` + +``` text +┌──GoalID─┬─Reaches─┬─Visits─┐ +│ 53225 │ 3214 │ 1097 │ +│ 2825062 │ 3188 │ 1097 │ +│ 56600 │ 2803 │ 488 │ +│ 1989037 │ 2401 │ 365 │ +│ 2830064 │ 2396 │ 910 │ +│ 1113562 │ 2372 │ 373 │ +│ 3270895 │ 2262 │ 812 │ +│ 1084657 │ 2262 │ 345 │ +│ 56599 │ 2260 │ 799 │ +│ 3271094 │ 2256 │ 812 │ +└─────────┴─────────┴────────┘ +``` + +この例では、各ゴールIDには、コンバージョン数(ゴールの入れ子になったデータ構造の各要素は、到達したゴールであり、これをコンバージョンと呼びます)とセッシ 配列結合がなければ、セッション数をsum(Sign)として数えました。 しかし、この特定のケースでは、行にネストされたGoals構造体が乗算されているため、この後に各セッションを一度カウントするために、arrayEnumerateUniq(Goals.ID)機能。 + +ArrayEnumerateUniq関数は、引数と同じサイズの複数の配列を取ることができます。 この場合、すべての配列の同じ位置にある要素のタプルに対して一意性が考慮されます。 + +``` sql +SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res +``` + +``` text +┌─res───────────┐ +│ [1,2,1,1,2,1] │ +└───────────────┘ +``` + +これは、入れ子になったデータ構造で配列結合を使用し、この構造体内の複数の要素間でさらに集計する場合に必要です。 + +## arrayPopBack {#arraypopback} + +配列から最後の項目を削除します。 + +``` sql +arrayPopBack(array) +``` + +**パラメータ** + +- `array` – Array. + +**例** + +``` sql +SELECT arrayPopBack([1, 2, 3]) AS res +``` + +``` text +┌─res───┐ +│ [1,2] │ +└───────┘ +``` + +## arrayPopFront {#arraypopfront} + +配列から最初の項目を削除します。 + +``` sql +arrayPopFront(array) +``` + +**パラメータ** + +- `array` – Array. + +**例** + +``` sql +SELECT arrayPopFront([1, 2, 3]) AS res +``` + +``` text +┌─res───┐ +│ [2,3] │ +└───────┘ +``` + +## arrayPushBack {#arraypushback} + +配列の最後に項目を追加します。 + +``` sql +arrayPushBack(array, single_value) +``` + +**パラメータ** + +- `array` – Array. +- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` 配列のデータ型の型。 ClickHouseのデータの種類の詳細については、次を参照してください “[データ型](../../sql-reference/data-types/index.md#data_types)”. ことができます `NULL`. この関数は `NULL` 要素を配列に変換し、配列要素の型を次のように変換します `Nullable`. + +**例** + +``` sql +SELECT arrayPushBack(['a'], 'b') AS res +``` + +``` text +┌─res───────┐ +│ ['a','b'] │ +└───────────┘ +``` + +## アレイプッシュフロント {#arraypushfront} + +配列の先頭に要素を追加します。 + +``` sql +arrayPushFront(array, single_value) +``` + +**パラメータ** + +- `array` – Array. +- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` 配列のデータ型の型。 ClickHouseのデータの種類の詳細については、次を参照してください “[データ型](../../sql-reference/data-types/index.md#data_types)”. ことができます `NULL`. この関数は `NULL` 要素を配列に変換し、配列要素の型を次のように変換します `Nullable`. + +**例** + +``` sql +SELECT arrayPushFront(['b'], 'a') AS res +``` + +``` text +┌─res───────┐ +│ ['a','b'] │ +└───────────┘ +``` + +## arrayResize {#arrayresize} + +配列の長さを変更します。 + +``` sql +arrayResize(array, size[, extender]) +``` + +**パラメータ:** + +- `array` — Array. +- `size` — Required length of the array. + - もし `size` 配列の元のサイズよりも小さい場合、配列は右から切り捨てられます。 +- もし `size` 配列の初期サイズよりも大きい場合、配列は次のように右に拡張されます `extender` 配列項目のデータ型の値または既定値。 +- `extender` — Value for extending an array. Can be `NULL`. + +**戻り値:** + +長さの配列 `size`. + +**コールの例** + +``` sql +SELECT arrayResize([1], 3) +``` + +``` text +┌─arrayResize([1], 3)─┐ +│ [1,0,0] │ +└─────────────────────┘ +``` + +``` sql +SELECT arrayResize([1], 3, NULL) +``` + +``` text +┌─arrayResize([1], 3, NULL)─┐ +│ [1,NULL,NULL] │ +└───────────────────────────┘ +``` + +## アレイスライス {#arrayslice} + +配列のスライスを返します。 + +``` sql +arraySlice(array, offset[, length]) +``` + +**パラメータ** + +- `array` – Array of data. +- `offset` – Indent from the edge of the array. A positive value indicates an offset on the left, and a negative value is an indent on the right. Numbering of the array items begins with 1. +- `length` -必要なスライスの長さ。 負の値を指定すると、関数は開いているスライスを返します `[offset, array_length - length)`. 値を省略すると、関数はスライスを返します `[offset, the_end_of_array]`. + +**例** + +``` sql +SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res +``` + +``` text +┌─res────────┐ +│ [2,NULL,4] │ +└────────────┘ +``` + +配列要素に設定 `NULL` 通常の値として処理されます。 + +## arraySort(\[func,\] arr, …) {#array_functions-sort} + +の要素を並べ替えます `arr` 昇順の配列。 もし `func` 関数が指定されると、並べ替え順序は `func` 配列の要素に適用される関数。 もし `func` 複数の引数を受け入れる。 `arraySort` 関数には、引数の配列が複数渡されます。 `func` に対応する。 詳しい例はの終わりに示されています `arraySort` 説明。 + +整数値ソートの例: + +``` sql +SELECT arraySort([1, 3, 3, 0]); +``` + +``` text +┌─arraySort([1, 3, 3, 0])─┐ +│ [0,1,3,3] │ +└─────────────────────────┘ +``` + +文字列値のソートの例: + +``` sql +SELECT arraySort(['hello', 'world', '!']); +``` + +``` text +┌─arraySort(['hello', 'world', '!'])─┐ +│ ['!','hello','world'] │ +└────────────────────────────────────┘ +``` + +次の並べ替え順序を考えてみましょう `NULL`, `NaN` と `Inf` 値: + +``` sql +SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); +``` + +``` text +┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ +│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────────────────────────┘ +``` + +- `-Inf` 値は配列の最初にあります。 +- `NULL` 値は配列の最後にあります。 +- `NaN` 値は直前です `NULL`. +- `Inf` 値は直前です `NaN`. + +なお `arraySort` は [高次関数](higher-order-functions.md). Lambda関数を最初の引数として渡すことができます。 この場合、並べ替え順序は、配列の要素に適用されたlambda関数の結果によって決定されます。 + +次の例を考えてみましょう: + +``` sql +SELECT arraySort((x) -> -x, [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [3,2,1] │ +└─────────┘ +``` + +For each element of the source array, the lambda function returns the sorting key, that is, \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Since the `arraySort` 関数は昇順にキーをソートし、結果は\[3、2、1\]です。 したがって、 `(x) –> -x` ラムダ関数は [降順](#array_functions-reverse-sort) ソートで。 + +Lambda関数は複数の引数を受け取ることができます。 この場合、 `arraySort` 関数lambda関数の引数が対応する同じ長さのいくつかの配列。 結果の配列は最初の入力配列の要素で構成され、次の入力配列の要素は並べ替えキーを指定します。 例えば: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res────────────────┐ +│ ['world', 'hello'] │ +└────────────────────┘ +``` + +ここでは、二番目の配列(\[2,1\])に渡される要素は、ソース配列の対応する要素の並べ替えキーを定義します (\[‘hello’, ‘world’\])、それは, \[‘hello’ –\> 2, ‘world’ –\> 1\]. Since the lambda function doesn't use `x`、ソース配列の実際の値は結果の順序に影響しません。 だから, ‘hello’ 結果の第二の要素になります。 ‘world’ 最初になります。 + +その他の例を以下に示す。 + +``` sql +SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; +``` + +``` text +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +``` sql +SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +!!! note "注" + 効率を分類することを改善するため、 [シュワルツ変換](https://en.wikipedia.org/wiki/Schwartzian_transform) が使用される。 + +## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} + +の要素を並べ替えます `arr` 降順の配列。 もし `func` 関数を指定します, `arr` の結果に従ってソートされます。 `func` 関数は、配列の要素に適用され、その後、ソートされた配列が逆になります。 もし `func` 複数の引数を受け入れる。 `arrayReverseSort` 関数には、引数の配列が複数渡されます。 `func` に対応する。 詳しい例はの終わりに示されています `arrayReverseSort` 説明。 + +整数値ソートの例: + +``` sql +SELECT arrayReverseSort([1, 3, 3, 0]); +``` + +``` text +┌─arrayReverseSort([1, 3, 3, 0])─┐ +│ [3,3,1,0] │ +└────────────────────────────────┘ +``` + +文字列値のソートの例: + +``` sql +SELECT arrayReverseSort(['hello', 'world', '!']); +``` + +``` text +┌─arrayReverseSort(['hello', 'world', '!'])─┐ +│ ['world','hello','!'] │ +└───────────────────────────────────────────┘ +``` + +次の並べ替え順序を考えてみましょう `NULL`, `NaN` と `Inf` 値: + +``` sql +SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; +``` + +``` text +┌─res───────────────────────────────────┐ +│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────┘ +``` + +- `Inf` 値は配列の最初にあります。 +- `NULL` 値は配列の最後にあります。 +- `NaN` 値は直前です `NULL`. +- `-Inf` 値は直前です `NaN`. + +なお、 `arrayReverseSort` は [高次関数](higher-order-functions.md). Lambda関数を最初の引数として渡すことができます。 以下に例を示す。 + +``` sql +SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [1,2,3] │ +└─────────┘ +``` + +配列は次のように並べ替えられます: + +1. 最初に、ソース配列(\[1,2,3\])は、配列の要素に適用されたlambda関数の結果に従ってソートされます。 結果は配列\[3,2,1\]です。 +2. 前のステップで取得された配列は、逆になります。 したがって、最終的な結果は\[1,2,3\]です。 + +Lambda関数は複数の引数を受け取ることができます。 この場合、 `arrayReverseSort` 関数lambda関数の引数が対応する同じ長さのいくつかの配列。 結果の配列は最初の入力配列の要素で構成され、次の入力配列の要素は並べ替えキーを指定します。 例えば: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +この例では、配列は次のように並べ替えられます: + +1. 最初は、ソース配列 (\[‘hello’, ‘world’\])は、配列の要素に適用されたlambda関数の結果に従ってソートされます。 二番目の配列(\[2,1\])に渡される要素は、ソース配列の対応する要素の並べ替えキーを定義します。 結果は配列です \[‘world’, ‘hello’\]. +2. 前のステップでソートされた配列は、逆になります。 だから、最終的な結果は \[‘hello’, ‘world’\]. + +その他の例を以下に示す。 + +``` sql +SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; +``` + +``` text +┌─res─────┐ +│ [5,3,4] │ +└─────────┘ +``` + +``` sql +SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; +``` + +``` text +┌─res─────┐ +│ [4,3,5] │ +└─────────┘ +``` + +## arrayUniq(arr, …) {#arrayuniqarr} + +一つの引数が渡されると、配列内の異なる要素の数がカウントされます。 +複数の引数が渡された場合、複数の配列内の対応する位置にある要素の異なるタプルの数をカウントします。 + +配列内の一意の項目のリストを取得する場合は、arrayReduceを使用できます(‘groupUniqArray’,arr)。 + +## アレイジョイン(arr) {#array-functions-join} + +特別な機能。 セクションを参照 [“ArrayJoin function”](array-join.md#functions_arrayjoin). + +## arrayDifference {#arraydifference} + +隣接する配列要素の差を計算します。 最初の要素が0になる配列を返します。 `a[1] - a[0]`, etc. The type of elements in the resulting array is determined by the type inference rules for subtraction (e.g. `UInt8` - `UInt8` = `Int16`). + +**構文** + +``` sql +arrayDifference(array) +``` + +**パラメータ** + +- `array` – [配列](https://clickhouse.yandex/docs/en/data_types/array/). + +**戻り値** + +隣接する要素間の差分の配列を返します。 + +タイプ: [UInt\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#uint-ranges), [Int\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#int-ranges), [フロート\*](https://clickhouse.yandex/docs/en/data_types/float/). + +**例** + +クエリ: + +``` sql +SELECT arrayDifference([1, 2, 3, 4]) +``` + +結果: + +``` text +┌─arrayDifference([1, 2, 3, 4])─┐ +│ [0,1,1,1] │ +└───────────────────────────────┘ +``` + +結果の型Int64によるオーバーフローの例: + +クエリ: + +``` sql +SELECT arrayDifference([0, 10000000000000000000]) +``` + +結果: + +``` text +┌─arrayDifference([0, 10000000000000000000])─┐ +│ [0,-8446744073709551616] │ +└────────────────────────────────────────────┘ +``` + +## アレイディスト {#arraydistinct} + +配列を受け取り、別個の要素のみを含む配列を返します。 + +**構文** + +``` sql +arrayDistinct(array) +``` + +**パラメータ** + +- `array` – [配列](https://clickhouse.yandex/docs/en/data_types/array/). + +**戻り値** + +個別の要素を含む配列を返します。 + +**例** + +クエリ: + +``` sql +SELECT arrayDistinct([1, 2, 2, 3, 1]) +``` + +結果: + +``` text +┌─arrayDistinct([1, 2, 2, 3, 1])─┐ +│ [1,2,3] │ +└────────────────────────────────┘ +``` + +## アレイニュメラテンセ(arr) {#array_functions-arrayenumeratedense} + +ソース配列と同じサイズの配列を返します。 + +例: + +``` sql +SELECT arrayEnumerateDense([10, 20, 10, 30]) +``` + +``` text +┌─arrayEnumerateDense([10, 20, 10, 30])─┐ +│ [1,2,1,3] │ +└───────────────────────────────────────┘ +``` + +## アレイインターセクト(arr) {#array-functions-arrayintersect} + +複数の配列を取り、すべてのソース配列に存在する要素を含む配列を返します。 結果の配列内の要素の順序は、最初の配列と同じです。 + +例: + +``` sql +SELECT + arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, + arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect +``` + +``` text +┌─no_intersect─┬─intersect─┐ +│ [] │ [1] │ +└──────────────┴───────────┘ +``` + +## arrayReduce {#arrayreduce} + +集計関数を配列要素に適用し、その結果を返します。 集計関数の名前は、単一引quotesで文字列として渡されます `'max'`, `'sum'`. パラメトリック集計関数を使用する場合、パラメーターは関数名の後に括弧で示されます `'uniqUpTo(6)'`. + +**構文** + +``` sql +arrayReduce(agg_func, arr1, arr2, ..., arrN) +``` + +**パラメータ** + +- `agg_func` — The name of an aggregate function which should be a constant [文字列](../../sql-reference/data-types/string.md). +- `arr` — Any number of [配列](../../sql-reference/data-types/array.md) 集計関数のパラメーターとして列を入力します。 + +**戻り値** + +**例** + +``` sql +SELECT arrayReduce('max', [1, 2, 3]) +``` + +``` text +┌─arrayReduce('max', [1, 2, 3])─┐ +│ 3 │ +└───────────────────────────────┘ +``` + +集計関数が複数の引数を取る場合、この関数は同じサイズの複数の配列に適用する必要があります。 + +``` sql +SELECT arrayReduce('maxIf', [3, 5], [1, 0]) +``` + +``` text +┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ +│ 3 │ +└──────────────────────────────────────┘ +``` + +パラメトリック集計関数の例: + +``` sql +SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) +``` + +``` text +┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ +│ 4 │ +└─────────────────────────────────────────────────────────────┘ +``` + +## arrayReduceInRanges {#arrayreduceinranges} + +指定された範囲の配列要素に集計関数を適用し、各範囲に対応する結果を含む配列を返します。 関数はmultipleと同じ結果を返します `arrayReduce(agg_func, arraySlice(arr1, index, length), ...)`. + +**構文** + +``` sql +arrayReduceInRanges(agg_func, ranges, arr1, arr2, ..., arrN) +``` + +**パラメータ** + +- `agg_func` — The name of an aggregate function which should be a constant [文字列](../../sql-reference/data-types/string.md). +- `ranges` — The ranges to aggretate which should be an [配列](../../sql-reference/data-types/array.md) の [タプル](../../sql-reference/data-types/tuple.md) これには、各範囲のインデックスと長さが含まれます。 +- `arr` — Any number of [配列](../../sql-reference/data-types/array.md) 集計関数のパラメーターとして列を入力します。 + +**戻り値** + +**例** + +``` sql +SELECT arrayReduceInRanges( + 'sum', + [(1, 5), (2, 3), (3, 4), (4, 4)], + [1000000, 200000, 30000, 4000, 500, 60, 7] +) AS res +``` + +``` text +┌─res─────────────────────────┐ +│ [1234500,234000,34560,4567] │ +└─────────────────────────────┘ +``` + +## アレイリバース(arr) {#arrayreverse} + +逆の順序で要素を含む元の配列と同じサイズの配列を返します。 + +例: + +``` sql +SELECT arrayReverse([1, 2, 3]) +``` + +``` text +┌─arrayReverse([1, 2, 3])─┐ +│ [3,2,1] │ +└─────────────────────────┘ +``` + +## リバース(arr) {#array-functions-reverse} + +の同義語 [“arrayReverse”](#arrayreverse) + +## アレイフラッテン {#arrayflatten} + +配列の配列をフラット配列に変換します。 + +関数: + +- ネストされた配列の任意の深さに適用されます。 +- 既にフラットな配列は変更しません。 + +の平坦化された配列を含むすべての要素をすべてソース配列. + +**構文** + +``` sql +flatten(array_of_arrays) +``` + +別名: `flatten`. + +**パラメータ** + +- `array_of_arrays` — [配列](../../sql-reference/data-types/array.md) 配列の。 例えば, `[[1,2,3], [4,5]]`. + +**例** + +``` sql +SELECT flatten([[[1]], [[2], [3]]]) +``` + +``` text +┌─flatten(array(array([1]), array([2], [3])))─┐ +│ [1,2,3] │ +└─────────────────────────────────────────────┘ +``` + +## アレイコンパクト {#arraycompact} + +配列から連続した重複要素を削除します。 結果の値の順序は、ソース配列の順序によって決まります。 + +**構文** + +``` sql +arrayCompact(arr) +``` + +**パラメータ** + +`arr` — The [配列](../../sql-reference/data-types/array.md) 検査する。 + +**戻り値** + +重複のない配列。 + +タイプ: `Array`. + +**例** + +クエリ: + +``` sql +SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) +``` + +結果: + +``` text +┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ +│ [1,nan,nan,2,3] │ +└────────────────────────────────────────────┘ +``` + +## arrayZip {#arrayzip} + +複数の配列を単一の配列に結合します。 結果の配列には、引数の順序で組にグループ化されたソース配列の対応する要素が含まれます。 + +**構文** + +``` sql +arrayZip(arr1, arr2, ..., arrN) +``` + +**パラメータ** + +- `arrN` — [配列](../data-types/array.md). + +関数は、異なる型の任意の数の配列を取ることができます。 すべての入力配列は同じサイズでなければなりません。 + +**戻り値** + +- ソース配列の要素をグループ化した配列 [タプル](../data-types/tuple.md). タプル内のデータ型は、入力配列の型と同じで、配列が渡される順序と同じです。 + +タイプ: [配列](../data-types/array.md). + +**例** + +クエリ: + +``` sql +SELECT arrayZip(['a', 'b', 'c'], [5, 2, 1]) +``` + +結果: + +``` text +┌─arrayZip(['a', 'b', 'c'], [5, 2, 1])─┐ +│ [('a',5),('b',2),('c',1)] │ +└──────────────────────────────────────┘ +``` + +## アレイオーク {#arrayauc} + +計算AUC(機械学習の概念である曲線の下の面積、詳細を参照してください:https://en.wikipedia.org/wiki/Receiver\_operating\_characteristic\#Area\_under\_the\_curve)。 + +**構文** + +``` sql +arrayAUC(arr_scores, arr_labels) +``` + +**パラメータ** +- `arr_scores` — scores prediction model gives. +- `arr_labels` — labels of samples, usually 1 for positive sample and 0 for negtive sample. + +**戻り値** +FLOAT64型のAUC値を返します。 + +**例** +クエリ: + +``` sql +select arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]) +``` + +結果: + +``` text +┌─arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1])─┐ +│ 0.75 │ +└────────────────────────────────────────---──┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/ja/sql-reference/functions/array-join.md b/docs/ja/sql-reference/functions/array-join.md new file mode 100644 index 00000000000..d3a2ab76398 --- /dev/null +++ b/docs/ja/sql-reference/functions/array-join.md @@ -0,0 +1,37 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "\u30A2\u30EC\u30A4\u30B8\u30E7\u30A4\u30F3" +--- + +# arrayJoin関数 {#functions_arrayjoin} + +これは非常に珍しい機能です。 + +通常の関数は行のセットを変更するのではなく、各行(map)の値を変更するだけです。 +集計関数は、行のセットを圧縮します(foldまたはreduce)。 +その ‘arrayJoin’ 関数は、各行を取り、行のセットを生成します(展開)。 + +この関数は、配列を引数として受け取り、配列内の要素数に対してソース行を複数の行に伝播します。 +この関数が適用される列の値を除いて、列内のすべての値は単純にコピーされます。 + +クエリでは、複数の `arrayJoin` 機能。 この場合、変換は複数回実行されます。 + +SELECTクエリの配列結合構文に注意してください。 + +例: + +``` sql +SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src +``` + +``` text +┌─dst─┬─\'Hello\'─┬─src─────┐ +│ 1 │ Hello │ [1,2,3] │ +│ 2 │ Hello │ [1,2,3] │ +│ 3 │ Hello │ [1,2,3] │ +└─────┴───────────┴─────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/array_join/) diff --git a/docs/ja/sql-reference/functions/bit-functions.md b/docs/ja/sql-reference/functions/bit-functions.md new file mode 100644 index 00000000000..6ea1189f6a4 --- /dev/null +++ b/docs/ja/sql-reference/functions/bit-functions.md @@ -0,0 +1,255 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: "\u30D3\u30C3\u30C8" +--- + +# ビット関数 {#bit-functions} + +ビット関数は、UInt8、UInt16、UInt32、UInt64、Int8、Int16、Int32、Int64、Float32、Float64のいずれかの型のペアに対しても機能します。 + +結果の型は、引数の最大ビットに等しいビットを持つ整数です。 引数のうち少なくともいずれかが署名されている場合、結果は符号付き番号になります。 引数が浮動小数点数の場合は、Int64にキャストされます。 + +## ビタン(a,b) {#bitanda-b} + +## ビター(a,b) {#bitora-b} + +## bitXor(a,b) {#bitxora-b} + +## bitNot(a) {#bitnota} + +## ビットシフトレフト(a,b) {#bitshiftlefta-b} + +## ビットシフトライト(a,b) {#bitshiftrighta-b} + +## ビットロタテレフト(a,b) {#bitrotatelefta-b} + +## ビットロータライト(a,b) {#bitrotaterighta-b} + +## bitTest {#bittest} + +間の任意の整数に換算しています。 [バイナリ形式](https://en.wikipedia.org/wiki/Binary_number),指定された位置にあるビットの値を返します。 カウントダウンは右から左に0から始まります。 + +**構文** + +``` sql +SELECT bitTest(number, index) +``` + +**パラメータ** + +- `number` – integer number. +- `index` – position of bit. + +**戻り値** + +指定された位置にあるbitの値を返します。 + +タイプ: `UInt8`. + +**例** + +たとえば、基数43-2(二進数)の数値システムでは101011です。 + +クエリ: + +``` sql +SELECT bitTest(43, 1) +``` + +結果: + +``` text +┌─bitTest(43, 1)─┐ +│ 1 │ +└────────────────┘ +``` + +別の例: + +クエリ: + +``` sql +SELECT bitTest(43, 2) +``` + +結果: + +``` text +┌─bitTest(43, 2)─┐ +│ 0 │ +└────────────────┘ +``` + +## ビッテスタール {#bittestall} + +の結果を返します [論理結合](https://en.wikipedia.org/wiki/Logical_conjunction) 指定された位置にあるすべてのビットの(and演算子)。 カウントダウンは右から左に0から始まります。 + +ビットごとの演算のための結合: + +0 AND 0 = 0 + +0 AND 1 = 0 + +1 AND 0 = 0 + +1 AND 1 = 1 + +**構文** + +``` sql +SELECT bitTestAll(number, index1, index2, index3, index4, ...) +``` + +**パラメータ** + +- `number` – integer number. +- `index1`, `index2`, `index3`, `index4` – positions of bit. For example, for set of positions (`index1`, `index2`, `index3`, `index4`)は、すべての位置が真である場合にのみtrueです (`index1` ⋀ `index2`, ⋀ `index3` ⋀ `index4`). + +**戻り値** + +論理結合の結果を返します。 + +タイプ: `UInt8`. + +**例** + +たとえば、基数43-2(二進数)の数値システムでは101011です。 + +クエリ: + +``` sql +SELECT bitTestAll(43, 0, 1, 3, 5) +``` + +結果: + +``` text +┌─bitTestAll(43, 0, 1, 3, 5)─┐ +│ 1 │ +└────────────────────────────┘ +``` + +別の例: + +クエリ: + +``` sql +SELECT bitTestAll(43, 0, 1, 3, 5, 2) +``` + +結果: + +``` text +┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ +│ 0 │ +└───────────────────────────────┘ +``` + +## ビッテスタニ {#bittestany} + +の結果を返します [論理和](https://en.wikipedia.org/wiki/Logical_disjunction) 指定された位置にあるすべてのビットの(または演算子)。 カウントダウンは右から左に0から始まります。 + +ビットごとの演算の分離: + +0 OR 0 = 0 + +0 OR 1 = 1 + +1 OR 0 = 1 + +1 OR 1 = 1 + +**構文** + +``` sql +SELECT bitTestAny(number, index1, index2, index3, index4, ...) +``` + +**パラメータ** + +- `number` – integer number. +- `index1`, `index2`, `index3`, `index4` – positions of bit. + +**戻り値** + +論理解釈の結果を返します。 + +タイプ: `UInt8`. + +**例** + +たとえば、基数43-2(二進数)の数値システムでは101011です。 + +クエリ: + +``` sql +SELECT bitTestAny(43, 0, 2) +``` + +結果: + +``` text +┌─bitTestAny(43, 0, 2)─┐ +│ 1 │ +└──────────────────────┘ +``` + +別の例: + +クエリ: + +``` sql +SELECT bitTestAny(43, 4, 2) +``` + +結果: + +``` text +┌─bitTestAny(43, 4, 2)─┐ +│ 0 │ +└──────────────────────┘ +``` + +## ビット数 {#bitcount} + +数値のバイナリ表現で一つに設定されたビット数を計算します。 + +**構文** + +``` sql +bitCount(x) +``` + +**パラメータ** + +- `x` — [整数](../../sql-reference/data-types/int-uint.md) または [浮動小数点数](../../sql-reference/data-types/float.md) 番号 この関数は、メモリ内の値表現を使用します。 浮動小数点数をサポートできます。 + +**戻り値** + +- 入力番号の一つに設定されたビット数。 + +この関数は、入力値をより大きな型に変換しません ([符号拡張](https://en.wikipedia.org/wiki/Sign_extension)). 例えば, `bitCount(toUInt8(-1)) = 8`. + +タイプ: `UInt8`. + +**例** + +たとえば、数333を取る。 そのバイナリ表現:00000000101001101。 + +クエリ: + +``` sql +SELECT bitCount(333) +``` + +結果: + +``` text +┌─bitCount(333)─┐ +│ 5 │ +└───────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/ja/sql-reference/functions/bitmap-functions.md b/docs/ja/sql-reference/functions/bitmap-functions.md new file mode 100644 index 00000000000..70fee866961 --- /dev/null +++ b/docs/ja/sql-reference/functions/bitmap-functions.md @@ -0,0 +1,496 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 49 +toc_title: "\u30D3\u30C3\u30C8\u30DE" +--- + +# ビットマップ関数 {#bitmap-functions} + +And、or、xor、notなどの数式の計算を使用しながら、新しいビットマップまたは基数を返すことです。 + +ビットマップオブジェクトの構築方法には2種類あります。 一つは-Stateを持つ集計関数groupBitmapによって構築され、もう一つはArray Objectによって構築されます。 でも変換するビットマップオブジェクト配列のオブジェクトです。 + +RoaringBitmapは、ビットマップオブジェクトの実際の格納中にデータ構造にラップされます。 基数が32以下の場合、Set objetが使用されます。 基数が32より大きい場合は、RoaringBitmapオブジェクトを使用します。 そのため、低基数セットの保存が高速になります。 + +RoaringBitmapの詳細については、以下を参照してください: [クロアリング](https://github.com/RoaringBitmap/CRoaring). + +## bitmapBuild {#bitmap_functions-bitmapbuild} + +符号なし整数配列からビットマップを作成します。 + +``` sql +bitmapBuild(array) +``` + +**パラメータ** + +- `array` – unsigned integer array. + +**例** + +``` sql +SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) +``` + +``` text +┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ +│  │ AggregateFunction(groupBitmap, UInt8) │ +└─────┴──────────────────────────────────────────────┘ +``` + +## bitmapToArray {#bitmaptoarray} + +ビットマップを整数配列に変換します。 + +``` sql +bitmapToArray(bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + +``` text +┌─res─────────┐ +│ [1,2,3,4,5] │ +└─────────────┘ +``` + +## bitmapSubsetInRange {#bitmap-functions-bitmapsubsetinrange} + +指定された範囲のサブセットを返します(range\_endは含まれません)。 + +``` sql +bitmapSubsetInRange(bitmap, range_start, range_end) +``` + +**パラメータ** + +- `bitmap` – [ビットマップ](#bitmap_functions-bitmapbuild). +- `range_start` – range start point. Type: [UInt32](../../sql-reference/data-types/int-uint.md). +- `range_end` – range end point(excluded). Type: [UInt32](../../sql-reference/data-types/int-uint.md). + +**例** + +``` sql +SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + +``` text +┌─res───────────────┐ +│ [30,31,32,33,100] │ +└───────────────────┘ +``` + +## bitmapSubsetLimit {#bitmapsubsetlimit} + +ビットマップのサブセットを作成します。 `range_start` と `cardinality_limit`. + +**構文** + +``` sql +bitmapSubsetLimit(bitmap, range_start, cardinality_limit) +``` + +**パラメータ** + +- `bitmap` – [ビットマップ](#bitmap_functions-bitmapbuild). +- `range_start` – The subset starting point. Type: [UInt32](../../sql-reference/data-types/int-uint.md). +- `cardinality_limit` – The subset cardinality upper limit. Type: [UInt32](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +サブセット。 + +タイプ: `Bitmap object`. + +**例** + +クエリ: + +``` sql +SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + +結果: + +``` text +┌─res───────────────────────┐ +│ [30,31,32,33,100,200,500] │ +└───────────────────────────┘ +``` + +## bitmapContains {#bitmap_functions-bitmapcontains} + +かどうかをチェックしますビットマップを含む要素になります。 + +``` sql +bitmapContains(haystack, needle) +``` + +**パラメータ** + +- `haystack` – [ビットマップ](#bitmap_functions-bitmapbuild)、関数が検索する場所。 +- `needle` – Value that the function searches. Type: [UInt32](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- 0 — If `haystack` 含まない `needle`. +- 1 — If `haystack` 含む `needle`. + +タイプ: `UInt8`. + +**例** + +``` sql +SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapHasAny {#bitmaphasany} + +るかどうかを判二つのビットマップしていることで交差点にある。 + +``` sql +bitmapHasAny(bitmap1, bitmap2) +``` + +あなたがそれを確信している場合 `bitmap2` 厳密に一つの要素が含まれています。 [bitmapContains](#bitmap_functions-bitmapcontains) 機能。 これは、より効率的に動作します。 + +**パラメータ** + +- `bitmap*` – bitmap object. + +**戻り値** + +- `1`,if `bitmap1` と `bitmap2` 少なくとも一つの同様の要素があります。 +- `0` そうでなければ + +**例** + +``` sql +SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapHasAll {#bitmaphasall} + +類似する `hasAll(array, array)` 返り値が1の場合は最初のビットマップを含むすべての要素は、0です。 +二番目の引数が空のビットマップの場合は、1を返します。 + +``` sql +bitmapHasAll(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + +``` text +┌─res─┐ +│ 0 │ +└─────┘ +``` + +## bitmapCardinality {#bitmapcardinality} + +UInt64型のビットマップ基数を再実行します。 + +``` sql +bitmapCardinality(bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + +``` text +┌─res─┐ +│ 5 │ +└─────┘ +``` + +## bitmapMin {#bitmapmin} + +セット内のUInt64型の最小値を再実行し、セットが空の場合はUINT32\_MAX。 + + bitmapMin(bitmap) + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 1 │ + └─────┘ + +## bitmapMax {#bitmapmax} + +セット内のUInt64型の最大値を再試行し、セットが空の場合は0を再試行します。 + + bitmapMax(bitmap) + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 5 │ + └─────┘ + +## bitmapTransform {#bitmaptransform} + +ビットマップ内の値の配列を別の値の配列に変換すると、結果は新しいビットマップになります。 + + bitmapTransform(bitmap, from_array, to_array) + +**パラメータ** + +- `bitmap` – bitmap object. +- `from_array` – UInt32 array. For idx in range \[0, from\_array.size()), if bitmap contains from\_array\[idx\], then replace it with to\_array\[idx\]. Note that the result depends on array ordering if there are common elements between from\_array and to\_array. +- `to_array` – UInt32 array, its size shall be the same to from\_array. + +**例** + +``` sql +SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res +``` + + ┌─res───────────────────┐ + │ [1,3,4,6,7,8,9,10,20] │ + └───────────────────────┘ + +## bitmapAnd {#bitmapand} + +二つのビットマップと計算、結果は新しいビットマップです。 + +``` sql +bitmapAnd(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res─┐ +│ [3] │ +└─────┘ +``` + +## bitmapOr {#bitmapor} + +結果は新しいビットマップです。 + +``` sql +bitmapOr(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res─────────┐ +│ [1,2,3,4,5] │ +└─────────────┘ +``` + +## bitmapXor {#bitmapxor} + +二つのビットマップxorの計算は、結果は新しいビットマップです。 + +``` sql +bitmapXor(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res───────┐ +│ [1,2,4,5] │ +└───────────┘ +``` + +## bitmapAndnot {#bitmapandnot} + +二つのビットマップandnot計算、結果は新しいビットマップです。 + +``` sql +bitmapAndnot(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res───┐ +│ [1,2] │ +└───────┘ +``` + +## bitmapAndCardinality {#bitmapandcardinality} + +Uint64型の基数を返します。 + +``` sql +bitmapAndCardinality(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapOrCardinality {#bitmaporcardinality} + +Uint64型の基数を返します。 + +``` sql +bitmapOrCardinality(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 5 │ +└─────┘ +``` + +## bitmapXorCardinality {#bitmapxorcardinality} + +Uint64型の基数を返します。 + +``` sql +bitmapXorCardinality(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 4 │ +└─────┘ +``` + +## bitmapAndnotCardinality {#bitmapandnotcardinality} + +Uint64型の基数を返します。 + +``` sql +bitmapAndnotCardinality(bitmap,bitmap) +``` + +**パラメータ** + +- `bitmap` – bitmap object. + +**例** + +``` sql +SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 2 │ +└─────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/ja/sql-reference/functions/comparison-functions.md b/docs/ja/sql-reference/functions/comparison-functions.md new file mode 100644 index 00000000000..ab223c36c6b --- /dev/null +++ b/docs/ja/sql-reference/functions/comparison-functions.md @@ -0,0 +1,37 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: "\u6BD4\u8F03" +--- + +# 比較関数 {#comparison-functions} + +比較関数は常に0または1(Uint8)を返します。 + +次のタイプを比較できます: + +- 数字 +- 文字列と固定文字列 +- 日付 +- 日付と時刻 + +各グループ内ではなく、異なるグループ間。 + +たとえば、日付と文字列を比較することはできません。 文字列を日付に変換するには関数を使用する必要があります。 + +文字列はバイト単位で比較されます。 短い文字列は、それで始まり、少なくとも一つ以上の文字を含むすべての文字列よりも小さくなります。 + +## 等しい、a=bおよびa==b演算子 {#function-equals} + +## ノートイコライザー、a! 演算子=bおよびa\<\>b {#function-notequals} + +## less,\<演算子 {#function-less} + +## より大きい、\>演算子 {#function-greater} + +## lessOrEquals,\<=演算子 {#function-lessorequals} + +## greaterOrEquals,\>=演算子 {#function-greaterorequals} + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/ja/sql-reference/functions/conditional-functions.md b/docs/ja/sql-reference/functions/conditional-functions.md new file mode 100644 index 00000000000..2a18caf743f --- /dev/null +++ b/docs/ja/sql-reference/functions/conditional-functions.md @@ -0,0 +1,207 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u6761\u4EF6\u4ED8\u304D " +--- + +# 条件関数 {#conditional-functions} + +## もし {#if} + +条件分岐を制御します。 と異なりほとんどのシステムClickHouse常に評価さの両方表現 `then` と `else`. + +**構文** + +``` sql +SELECT if(cond, then, else) +``` + +条件が `cond` ゼロ以外の値に評価され、式の結果を返します `then` 式の結果 `else`、存在する場合は、スキップされます。 もし `cond` ゼロまたは `NULL` の結果は `then` 式はスキップされ、 `else` expressionが存在する場合は、expressionが返されます。 + +**パラメータ** + +- `cond` – The condition for evaluation that can be zero or not. The type is UInt8, Nullable(UInt8) or NULL. +- `then` -条件が満たされた場合に返される式。 +- `else` -条件が満たされていない場合に返される式。 + +**戻り値** + +この関数は実行されます `then` と `else` 式とは、条件かどうかに応じて、その結果を返します `cond` ゼロかどうかになってしまいました。 + +**例** + +クエリ: + +``` sql +SELECT if(1, plus(2, 2), plus(2, 6)) +``` + +結果: + +``` text +┌─plus(2, 2)─┐ +│ 4 │ +└────────────┘ +``` + +クエリ: + +``` sql +SELECT if(0, plus(2, 2), plus(2, 6)) +``` + +結果: + +``` text +┌─plus(2, 6)─┐ +│ 8 │ +└────────────┘ +``` + +- `then` と `else` 共通タイプが最も低い必要があります。 + +**例:** + +これを取る `LEFT_RIGHT` テーブル: + +``` sql +SELECT * +FROM LEFT_RIGHT + +┌─left─┬─right─┐ +│ ᴺᵁᴸᴸ │ 4 │ +│ 1 │ 3 │ +│ 2 │ 2 │ +│ 3 │ 1 │ +│ 4 │ ᴺᵁᴸᴸ │ +└──────┴───────┘ +``` + +次のクエリは比較します `left` と `right` 値: + +``` sql +SELECT + left, + right, + if(left < right, 'left is smaller than right', 'right is greater or equal than left') AS is_smaller +FROM LEFT_RIGHT +WHERE isNotNull(left) AND isNotNull(right) + +┌─left─┬─right─┬─is_smaller──────────────────────────┐ +│ 1 │ 3 │ left is smaller than right │ +│ 2 │ 2 │ right is greater or equal than left │ +│ 3 │ 1 │ right is greater or equal than left │ +└──────┴───────┴─────────────────────────────────────┘ +``` + +注: `NULL` この例では値は使用されません。 [条件付きのNULL値](#null-values-in-conditionals) セクション + +## 三項演算子 {#ternary-operator} + +それは同じように働く `if` 機能。 + +構文: `cond ? then : else` + +ツづゥツ。 `then` もし `cond` true(ゼロより大きい)と評価されます。 `else`. + +- `cond` の型でなければなりません `UInt8`,and `then` と `else` 共通タイプが最も低い必要があります。 + +- `then` と `else` ことができます `NULL` + +**も参照。** + +- [ifNotFinite](other-functions.md#ifnotfinite). + +## multif {#multiif} + +あなたが書くことができます [CASE](../operators/index.md#operator_case) よりコンパクトにクエリ内の演算子。 + +構文: `multiIf(cond_1, then_1, cond_2, then_2, ..., else)` + +**パラメータ:** + +- `cond_N` — The condition for the function to return `then_N`. +- `then_N` — The result of the function when executed. +- `else` — The result of the function if none of the conditions is met. + +この関数は `2N+1` 変数。 + +**戻り値** + +関数は、次のいずれかの値を返します `then_N` または `else`、条件によって `cond_N`. + +**例** + +再び使用する `LEFT_RIGHT` テーブル。 + +``` sql +SELECT + left, + right, + multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result +FROM LEFT_RIGHT + +┌─left─┬─right─┬─result──────────┐ +│ ᴺᵁᴸᴸ │ 4 │ Null value │ +│ 1 │ 3 │ left is smaller │ +│ 2 │ 2 │ Both equal │ +│ 3 │ 1 │ left is greater │ +│ 4 │ ᴺᵁᴸᴸ │ Null value │ +└──────┴───────┴─────────────────┘ +``` + +## 条件付き結果を直接使用する {#using-conditional-results-directly} + +条件は常に次のようになります `0`, `1` または `NULL`. できますので使用条件と結果が直接このような: + +``` sql +SELECT left < right AS is_small +FROM LEFT_RIGHT + +┌─is_small─┐ +│ ᴺᵁᴸᴸ │ +│ 1 │ +│ 0 │ +│ 0 │ +│ ᴺᵁᴸᴸ │ +└──────────┘ +``` + +## 条件付きのNULL値 {#null-values-in-conditionals} + +とき `NULL` 値は条件に含まれ、結果も次のようになります `NULL`. + +``` sql +SELECT + NULL < 1, + 2 < NULL, + NULL < NULL, + NULL = NULL + +┌─less(NULL, 1)─┬─less(2, NULL)─┬─less(NULL, NULL)─┬─equals(NULL, NULL)─┐ +│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ +└───────────────┴───────────────┴──────────────────┴────────────────────┘ +``` + +その構築お問合せくの場合はタイプ `Nullable`. + +次の例では、equals条件の追加に失敗してこれを示します `multiIf`. + +``` sql +SELECT + left, + right, + multiIf(left < right, 'left is smaller', left > right, 'right is smaller', 'Both equal') AS faulty_result +FROM LEFT_RIGHT + +┌─left─┬─right─┬─faulty_result────┐ +│ ᴺᵁᴸᴸ │ 4 │ Both equal │ +│ 1 │ 3 │ left is smaller │ +│ 2 │ 2 │ Both equal │ +│ 3 │ 1 │ right is smaller │ +│ 4 │ ᴺᵁᴸᴸ │ Both equal │ +└──────┴───────┴──────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/ja/sql-reference/functions/date-time-functions.md b/docs/ja/sql-reference/functions/date-time-functions.md new file mode 100644 index 00000000000..88dd72dc7fc --- /dev/null +++ b/docs/ja/sql-reference/functions/date-time-functions.md @@ -0,0 +1,450 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u65E5\u4ED8\u3068\u6642\u523B\u306E\u64CD\u4F5C" +--- + +# 日付と時刻を操作するための関数 {#functions-for-working-with-dates-and-times} + +タイムゾーンのサポート + +タイムゾーンに論理的に使用される日付と時刻を操作するためのすべての関数は、オプションのタイムゾーン引数を受け入れることができます。 例:アジア/エカテリンブルク。 この場合、ローカル(既定)のタイムゾーンではなく、指定されたタイムゾーンを使用します。 + +``` sql +SELECT + toDateTime('2016-06-15 23:00:00') AS time, + toDate(time) AS date_local, + toDate(time, 'Asia/Yekaterinburg') AS date_yekat, + toString(time, 'US/Samoa') AS time_samoa +``` + +``` text +┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ +│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ +└─────────────────────┴────────────┴────────────┴─────────────────────┘ +``` + +UTCと時間数が異なるタイムゾーンのみがサポートされます。 + +## トティムゾーン {#totimezone} + +時刻または日付と時刻を指定したタイムゾーンに変換します。 + +## toYear {#toyear} + +日付または日付と時刻を、年番号(AD)を含むUInt16番号に変換します。 + +## トクアーター {#toquarter} + +Dateまたはdate with timeを、四半期番号を含むUInt8番号に変換します。 + +## トモンス {#tomonth} + +Dateまたはdate with timeを、月番号(1-12)を含むUInt8番号に変換します。 + +## 今日の年 {#todayofyear} + +日付または日付と時刻を、年の日の番号を含むUInt16番号(1-366)に変換します。 + +## 今日の月 {#todayofmonth} + +日付または日付と時刻を、月の日の番号を含むUInt8番号(1-31)に変換します。 + +## 今日の週 {#todayofweek} + +Dateまたはdate with timeを、曜日の番号を含むUInt8番号に変換します(月曜日は1、日曜日は7)。 + +## toHour {#tohour} + +時刻を持つ日付を、24時間(0-23)の時間数を含むUInt8数値に変換します。 +This function assumes that if clocks are moved ahead, it is by one hour and occurs at 2 a.m., and if clocks are moved back, it is by one hour and occurs at 3 a.m. (which is not always true – even in Moscow the clocks were twice changed at a different time). + +## トミヌテ {#tominute} + +時刻を持つ日付を、時間の分の数を含むUInt8番号(0-59)に変換します。 + +## toSecond {#tosecond} + +日付と時刻を、分(0-59)の秒数を含むUInt8数値に変換します。 +うるう秒は考慮されません。 + +## toUnixTimestamp {#to-unix-timestamp} + +DateTime引数の場合:値を内部の数値表現(Unixタイムスタンプ)に変換します。 +文字列引数の場合:タイムゾーンに従って文字列からdatetimeを解析し(オプションの第二引数、サーバーのタイムゾーンがデフォルトで使用されます)、対応するunixタ +Date引数の場合:動作は指定されていません。 + +**構文** + +``` sql +toUnixTimestamp(datetime) +toUnixTimestamp(str, [timezone]) +``` + +**戻り値** + +- Unixタイムスタンプを返す。 + +タイプ: `UInt32`. + +**例** + +クエリ: + +``` sql +SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp +``` + +結果: + +``` text +┌─unix_timestamp─┐ +│ 1509836867 │ +└────────────────┘ +``` + +## トスタート {#tostartofyear} + +日付または日付を年の最初の日に切り捨てます。 +日付を返します。 + +## トスタートフィソイヤー {#tostartofisoyear} + +日付または日付をiso年の最初の日に切り捨てます。 +日付を返します。 + +## toStartOfQuarter {#tostartofquarter} + +日付または日付を四半期の最初の日に切り捨てます。 +四半期の最初の日は、1月、1月、1月、または1月のいずれかです。 +日付を返します。 + +## トスタートモンス {#tostartofmonth} + +日付または日付を月の最初の日に切り捨てます。 +日付を返します。 + +!!! attention "注意" + 不正な日付を解析する動作は、実装固有です。 ClickHouseはゼロの日付を返すか、例外をスローするか “natural” オーバーフロー + +## トモンデイ {#tomonday} + +日付または日付を時刻とともに最も近い月曜日に切り捨てます。 +日付を返します。 + +## トスタートフィーク(t\[,モード\]) {#tostartofweektmode} + +日付または時刻の日付を、最も近い日曜日または月曜日にモードで切り捨てます。 +日付を返します。 +Mode引数は、toWeek()のmode引数とまったく同じように動作します。 単一引数構文では、モード値0が使用されます。 + +## トスタートフデイ {#tostartofday} + +日付を時刻とともに日の始まりまで切り捨てます。 + +## トスタートフール {#tostartofhour} + +日付と時刻を時間の開始まで切り捨てます。 + +## トスタートフミニュート {#tostartofminute} + +日付と時刻を分の開始まで切り捨てます。 + +## トスタートオフィブミニュート {#tostartoffiveminute} + +日付と時刻を切り捨てます。 + +## toStartOfTenMinutes {#tostartoftenminutes} + +日付と時刻を切り捨てて、十分間隔の開始まで切り捨てます。 + +## トスタートフィフテンミニュート {#tostartoffifteenminutes} + +日付を時刻とともに切り捨てて、十分間隔の開始まで切り捨てます。 + +## トスタートオフインターバル(time\_or\_data,区間x単位\[,time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} + +これは、名前付きの他の関数の一般化です `toStartOf*`. 例えば, +`toStartOfInterval(t, INTERVAL 1 year)` と同じを返します `toStartOfYear(t)`, +`toStartOfInterval(t, INTERVAL 1 month)` と同じを返します `toStartOfMonth(t)`, +`toStartOfInterval(t, INTERVAL 1 day)` と同じを返します `toStartOfDay(t)`, +`toStartOfInterval(t, INTERVAL 15 minute)` と同じを返します `toStartOfFifteenMinutes(t)` 等。 + +## トータイム {#totime} + +時刻を保持しながら、時刻を持つ日付を特定の固定日付に変換します。 + +## toRelativeYearNum {#torelativeyearnum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる年の番号に変換します。 + +## toRelativeQuarterNum {#torelativequarternum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる四半期の数値に変換します。 + +## トレラティブモンスヌム {#torelativemonthnum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる月の番号に変換します。 + +## toRelativeWeekNum {#torelativeweeknum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる週の数に変換します。 + +## toRelativeDayNum {#torelativedaynum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる日付の数値に変換します。 + +## toRelativeHourNum {#torelativehournum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる時間の数に変換します。 + +## トレラティブミノテン {#torelativeminutenum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる分の数に変換します。 + +## toRelativeSecondNum {#torelativesecondnum} + +時刻または日付を持つ日付を、過去の特定の固定点から始まる秒数に変換します。 + +## toISOYear {#toisoyear} + +Dateまたはdate with timeをISO年番号を含むUInt16番号に変換します。 + +## toISOWeek {#toisoweek} + +日付または日付と時刻をISO週番号を含むUInt8番号に変換します。 + +## トウィーク(日付\[,モード\]) {#toweekdatemode} + +この関数は、dateまたはdatetimeの週番号を返します。 二引数形式のtoWeek()を使用すると、週が日曜日か月曜日か、戻り値が0から53または1から53の範囲であるかどうかを指定できます。 引数modeを省略すると、デフォルトのモードは0になります。 +`toISOWeek()`と等価な互換性関数です `toWeek(date,3)`. +次の表は、mode引数の動作方法を示しています。 + +| モード | 週の最初の日 | 範囲 | Week 1 is the first week … | +|--------|--------------|------|----------------------------| +| 0 | 日曜日 | 0-53 | 今年の日曜日と | +| 1 | 月曜日 | 0-53 | 今年は4日以上 | +| 2 | 日曜日 | 1-53 | 今年の日曜日と | +| 3 | 月曜日 | 1-53 | 今年は4日以上 | +| 4 | 日曜日 | 0-53 | 今年は4日以上 | +| 5 | 月曜日 | 0-53 | 今年の月曜日と | +| 6 | 日曜日 | 1-53 | 今年は4日以上 | +| 7 | 月曜日 | 1-53 | 今年の月曜日と | +| 8 | 日曜日 | 1-53 | 1を含む | +| 9 | 月曜日 | 1-53 | 1を含む | + +の意味を持つモード値の場合 “with 4 or more days this year,” 週はISO8601:1988に従って番号が付けられます: + +- 1月を含む週が新年に4日以上ある場合、それは1週である。 + +- それ以外の場合は、前年の最後の週であり、次の週は1週です。 + +の意味を持つモード値の場合 “contains January 1”、1月を含む週は1週である。 たとえそれが一日だけ含まれていても、その週が含まれている新年の日数は問題ではありません。 + +``` sql +toWeek(date, [, mode][, Timezone]) +``` + +**パラメータ** + +- `date` – Date or DateTime. +- `mode` – Optional parameter, Range of values is \[0,9\], default is 0. +- `Timezone` – Optional parameter, it behaves like any other conversion function. + +**例** + +``` sql +SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9; +``` + +``` text +┌───────date─┬─week0─┬─week1─┬─week9─┐ +│ 2016-12-27 │ 52 │ 52 │ 1 │ +└────────────┴───────┴───────┴───────┘ +``` + +## toYearWeek(日付\[,モード\]) {#toyearweekdatemode} + +日付の年と週を返します。 結果の年は、年の最初と最後の週のdate引数の年とは異なる場合があります。 + +Mode引数は、toWeek()のmode引数とまったく同じように動作します。 単一引数構文では、モード値0が使用されます。 + +`toISOYear()`と等価な互換性関数です `intDiv(toYearWeek(date,3),100)`. + +**例** + +``` sql +SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9; +``` + +``` text +┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┐ +│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ +└────────────┴───────────┴───────────┴───────────┘ +``` + +## さて {#now} + +ゼロの引数を受け取り、要求の実行のいずれかの瞬間に現在の時刻を返します。 +この関数は、要求が完了するまでに時間がかかった場合でも、定数を返します。 + +## 今日 {#today} + +ゼロの引数を受け取り、要求の実行のいずれかの瞬間に現在の日付を返します。 +と同じ ‘toDate(now())’. + +## 昨日 {#yesterday} + +ゼロの引数を受け取り、要求の実行のいずれかの瞬間に昨日の日付を返します。 +と同じ ‘today() - 1’. + +## タイムスロット {#timeslot} + +時間を半分の時間に丸めます。 +この機能はYandexに固有のものです。Metricaは、トラッキングタグが単一のユーザーの連続したページビューを表示する場合、セッションを二つのセッションに分割するための最小時間であるため、こ つまり、タプル(タグID、ユーザー ID、およびタイムスロット)を使用して、対応するセッションに含まれるページビューを検索できます。 + +## トイヤイム {#toyyyymm} + +日付または日付と時刻を、年と月の番号(YYYY\*100+MM)を含むUInt32番号に変換します。 + +## トイヤイム {#toyyyymmdd} + +日付または日付と時刻を、年と月の番号(YYYY\*10000+MM\*100+DD)を含むUInt32番号に変換します。 + +## トイヤイム {#toyyyymmddhhmmss} + +日付または日付と時刻を、年と月の番号(YYYY\*10000000000+MM\*100000000+DD\*1000000+hh\*10000+mm\*100+ss)を含むUInt64番号に変換します。 + +## addYears,addMonths,addWeeks,addDays,addHours,addMinutes,addSeconds,addQuarters {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} + +関数は、日付/日付時刻に日付/日付時刻の間隔を追加し、日付/日付時刻を返します。 例えば: + +``` sql +WITH + toDate('2018-01-01') AS date, + toDateTime('2018-01-01 00:00:00') AS date_time +SELECT + addYears(date, 1) AS add_years_with_date, + addYears(date_time, 1) AS add_years_with_date_time +``` + +``` text +┌─add_years_with_date─┬─add_years_with_date_time─┐ +│ 2019-01-01 │ 2019-01-01 00:00:00 │ +└─────────────────────┴──────────────────────────┘ +``` + +## subtruttyears、subtrutmonths、subtrutweeks、subtrutdays、subtrutthours、subtrutminutes、subtrutseconds、subtrutquarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} + +関数Date/DateTime間隔をDate/DateTimeに減算し、Date/DateTimeを返します。 例えば: + +``` sql +WITH + toDate('2019-01-01') AS date, + toDateTime('2019-01-01 00:00:00') AS date_time +SELECT + subtractYears(date, 1) AS subtract_years_with_date, + subtractYears(date_time, 1) AS subtract_years_with_date_time +``` + +``` text +┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ +│ 2018-01-01 │ 2018-01-01 00:00:00 │ +└──────────────────────────┴───────────────────────────────┘ +``` + +## dateDiff {#datediff} + +Date値またはDateTime値の差を返します。 + +**構文** + +``` sql +dateDiff('unit', startdate, enddate, [timezone]) +``` + +**パラメータ** + +- `unit` — Time unit, in which the returned value is expressed. [文字列](../syntax.md#syntax-string-literal). + + Supported values: + + | unit | + | ---- | + |second | + |minute | + |hour | + |day | + |week | + |month | + |quarter | + |year | + +- `startdate` — The first time value to compare. [日付](../../sql-reference/data-types/date.md) または [DateTime](../../sql-reference/data-types/datetime.md). + +- `enddate` — The second time value to compare. [日付](../../sql-reference/data-types/date.md) または [DateTime](../../sql-reference/data-types/datetime.md). + +- `timezone` — Optional parameter. If specified, it is applied to both `startdate` と `enddate`. 指定されていない場合、 `startdate` と `enddate` 使用されます。 それらが同じでない場合、結果は未指定です。 + +**戻り値** + +の違い `startdate` と `enddate` で表される。 `unit`. + +タイプ: `int`. + +**例** + +クエリ: + +``` sql +SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); +``` + +結果: + +``` text +┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ +│ 25 │ +└────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## タイムスロット(StartTime,Duration,\[,Size\]) {#timeslotsstarttime-duration-size} + +で始まる時間間隔の場合 ‘StartTime’ そして続けるために ‘Duration’ これは、この区間の点で構成される時間内の瞬間の配列を返します。 ‘Size’ 秒で。 ‘Size’ 定数UInt32で、既定では1800に設定されます。 +例えば, `timeSlots(toDateTime('2012-01-01 12:20:00'), 600) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. +これは、対応するセッションでページビューを検索するために必要です。 + +## formatDateTime(時刻,Format\[,タイムゾーン\]) {#formatdatetime} + +Function formats a Time according given Format string. N.B.: Format is a constant expression, e.g. you can not have multiple formats for single result column. + +サポートされている形式の修飾子: +(“Example” 列に時間の書式設定の結果が表示されます `2018-01-02 22:33:44`) + +| 修飾子 | 説明 | 例 | +|--------|-------------------------------------------------|------------| +| %C | 年を100で割り、整数に切り捨てます(00-99) | 20 | +| %d | 月の日、ゼロパッド(01-31) | 02 | +| %D | %M/%d/%yに相当する短いMM/DD/YYの日付 | 01/02/18 | +| %e | 月の日,スペース埋め(1-31) | 2 | +| %F | %Y-%m-%dに相当します | 2018-01-02 | +| %H | 24時間形式(00-23時) | 22 | +| %I | 12時間形式(01-12) | 10 | +| %j | 年の日(001-366) | 002 | +| %m | 十進数としての月(01-12) | 01 | +| %M | 分(00-59) | 33 | +| %n | 改行文字(") | | +| %p | AMまたはPMの指定 | PM | +| %R | 24時間HH:MM時間、%H:%Mに相当 | 22:33 | +| %S | 第二(00-59) | 44 | +| %t | 横タブ文字(') | | +| %T | ISO8601時間形式(HH:MM:SS)、%H:%M:%Sに相当します | 22:33:44 | +| %u | ISO8601平日as番号、月曜日as1(1-7) | 2 | +| %V | ISO8601週番号(01-53) | 01 | +| %w | 曜日を十進数とし、日曜日を0(0-6)とします) | 2 | +| %y | 年,最後の二桁(00-99) | 18 | +| %Y | 年 | 2018 | +| %% | %記号 | % | + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/ja/sql-reference/functions/encoding-functions.md b/docs/ja/sql-reference/functions/encoding-functions.md new file mode 100644 index 00000000000..c3eaeaa18c3 --- /dev/null +++ b/docs/ja/sql-reference/functions/encoding-functions.md @@ -0,0 +1,175 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: "\u30A8\u30F3\u30B3\u30FC\u30C9" +--- + +# エンコード機能 {#encoding-functions} + +## char {#char} + +渡された引数の数として長さの文字列を返し、各バイトは対応する引数の値を持ちます。 数値型の複数の引数を受け取ります。 引数の値がUInt8データ型の範囲外である場合、丸めとオーバーフローの可能性があるUInt8に変換されます。 + +**構文** + +``` sql +char(number_1, [number_2, ..., number_n]); +``` + +**パラメータ** + +- `number_1, number_2, ..., number_n` — Numerical arguments interpreted as integers. Types: [Int](../../sql-reference/data-types/int-uint.md), [フロート](../../sql-reference/data-types/float.md). + +**戻り値** + +- 指定されたバイトの文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello +``` + +結果: + +``` text +┌─hello─┐ +│ hello │ +└───────┘ +``` + +を構築できます文字列の任意のエンコードに対応するバイトまでとなります。 UTF-8の例を次に示します: + +クエリ: + +``` sql +SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; +``` + +結果: + +``` text +┌─hello──┐ +│ привет │ +└────────┘ +``` + +クエリ: + +``` sql +SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; +``` + +結果: + +``` text +┌─hello─┐ +│ 你好 │ +└───────┘ +``` + +## hex {#hex} + +引数の十六進表現を含む文字列を返します。 + +**構文** + +``` sql +hex(arg) +``` + +関数は大文字を使用しています `A-F` そして、接頭辞を使用しない(のような `0x`)または接尾辞(のような `h`). + +整数引数の場合は、六桁を出力します (“nibbles”)最上位から最下位へ(ビッグエンディアンまたは “human readable” 順序)。 これは、最上位の非ゼロバイト(先頭のゼロバイトは省略されます)で始まりますが、先頭の数字がゼロであっても、常にすべてのバイトの両方の桁を + +例: + +**例** + +クエリ: + +``` sql +SELECT hex(1); +``` + +結果: + +``` text +01 +``` + +型の値 `Date` と `DateTime` 対応する整数(Dateの場合はエポックからの日数、DateTimeの場合はUnix Timestampの値)としてフォーマットされます。 + +のために `String` と `FixedString`、すべてのバイトは単に二進数として符号化される。 ゼロバイトは省略されません。 + +浮動小数点型とDecimal型の値は、メモリ内の表現としてエンコードされます。 支援においても少しエンディアン、建築、その符号化されたのでちょっとエンディアンです。※ 先頭/末尾のゼロバイトは省略されません。 + +**パラメータ** + +- `arg` — A value to convert to hexadecimal. Types: [文字列](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [フロート](../../sql-reference/data-types/float.md), [小数点](../../sql-reference/data-types/decimal.md), [日付](../../sql-reference/data-types/date.md) または [DateTime](../../sql-reference/data-types/datetime.md). + +**戻り値** + +- 引数の十六進表現を持つ文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); +``` + +結果: + +``` text +┌─hex_presentation─┐ +│ 00007041 │ +│ 00008041 │ +└──────────────────┘ +``` + +クエリ: + +``` sql +SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); +``` + +結果: + +``` text +┌─hex_presentation─┐ +│ 0000000000002E40 │ +│ 0000000000003040 │ +└──────────────────┘ +``` + +## unhex(str) {#unhexstr} + +任意の数の十六進数を含む文字列を受け取り、対応するバイトを含む文字列を返します。 大文字と小文字の両方をサポートしていますa-F進の桁数は偶数である必要はありません。 奇数の場合、最後の桁は00-0Fバイトの最下位半分として解釈されます。 引数文字列に十六進以外の桁数が含まれている場合、実装定義の結果が返されます(例外はスローされません)。 +結果を数値に変換する場合は、 ‘reverse’ と ‘reinterpretAsType’ 機能。 + +## UUIDStringToNum(str) {#uuidstringtonumstr} + +形式で36文字を含む文字列を受け入れます `123e4567-e89b-12d3-a456-426655440000` これをFixedString(16)内のバイトセットとして返す。 + +## UUIDNumToString(str) {#uuidnumtostringstr} + +FixedString(16)値を受け取ります。 36文字を含む文字列をテキスト形式で返します。 + +## ビットマスクトリスト(num) {#bitmasktolistnum} + +整数を受け取ります。 ソース番号を合計する二つの累乗のリストを含む文字列を返します。 これらは、テキスト形式のスペースなしで、昇順でコンマ区切りです。 + +## ビットマスクトアレイ(num) {#bitmasktoarraynum} + +整数を受け取ります。 合計されたときにソース番号を合計する二つのべき乗のリストを含むUInt64数値の配列を返します。 配列内の数値は昇順です。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/ja/sql-reference/functions/ext-dict-functions.md b/docs/ja/sql-reference/functions/ext-dict-functions.md new file mode 100644 index 00000000000..8a438d6e935 --- /dev/null +++ b/docs/ja/sql-reference/functions/ext-dict-functions.md @@ -0,0 +1,205 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "\u5916\u90E8\u8F9E\u66F8\u306E\u64CD\u4F5C" +--- + +# 外部辞書を操作するための関数 {#ext_dict_functions} + +情報の接続や設定の外部辞書参照 [外部辞書](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +## dictGet {#dictget} + +外部ディクショナリから値を取得します。 + +``` sql +dictGet('dict_name', 'attr_name', id_expr) +dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) +``` + +**パラメータ** + +- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `attr_name` — Name of the column of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `id_expr` — Key value. [式](../syntax.md#syntax-expressions) aを返す [UInt64](../../sql-reference/data-types/int-uint.md) または [タプル](../../sql-reference/data-types/tuple.md)-辞書構成に応じて値を入力します。 +- `default_value_expr` — Value returned if the dictionary doesn't contain a row with the `id_expr` キー [式](../syntax.md#syntax-expressions) データ型の値を返します。 `attr_name` 属性。 + +**戻り値** + +- ClickHouseが属性を正常に解析した場合、 [属性のデータ型](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes),関数は、に対応する辞書属性の値を返します `id_expr`. + +- キーがない場合、対応する `id_expr`、辞書では、: + + - `dictGet` returns the content of the `` element specified for the attribute in the dictionary configuration. + - `dictGetOrDefault` returns the value passed as the `default_value_expr` parameter. + +ClickHouseは、属性の値を解析できない場合、または値が属性データ型と一致しない場合に例外をスローします。 + +**例** + +テキストファイルの作成 `ext-dict-text.csv` 以下を含む: + +``` text +1,1 +2,2 +``` + +最初の列は次のとおりです `id` 二つ目の列は `c1`. + +外部辞書の構成: + +``` xml + + + ext-dict-test + + + /path-to/ext-dict-test.csv + CSV + + + + + + + + id + + + c1 + UInt32 + + + + 0 + + +``` + +クエリの実行: + +``` sql +SELECT + dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, + toTypeName(val) AS type +FROM system.numbers +LIMIT 3 +``` + +``` text +┌─val─┬─type───┐ +│ 1 │ UInt32 │ +│ 2 │ UInt32 │ +│ 20 │ UInt32 │ +└─────┴────────┘ +``` + +**も参照。** + +- [外部辞書](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) + +## ディクタス {#dicthas} + +キーが辞書に存在するかどうかを確認します。 + +``` sql +dictHas('dict_name', id_expr) +``` + +**パラメータ** + +- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `id_expr` — Key value. [式](../syntax.md#syntax-expressions) aを返す [UInt64](../../sql-reference/data-types/int-uint.md)-タイプ値。 + +**戻り値** + +- キーがない場合は0。 +- 1、キーがある場合。 + +タイプ: `UInt8`. + +## dictGetHierarchy {#dictgethierarchy} + +キーのすべての親を含む配列を作成します。 [階層辞書](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md). + +**構文** + +``` sql +dictGetHierarchy('dict_name', key) +``` + +**パラメータ** + +- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `key` — Key value. [式](../syntax.md#syntax-expressions) aを返す [UInt64](../../sql-reference/data-types/int-uint.md)-タイプ値。 + +**戻り値** + +- 鍵の親。 + +タイプ: [配列(UInt64)](../../sql-reference/data-types/array.md). + +## ジクチシン {#dictisin} + +辞書の階層チェーン全体を通して、キーの祖先をチェックします。 + +``` sql +dictIsIn('dict_name', child_id_expr, ancestor_id_expr) +``` + +**パラメータ** + +- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `child_id_expr` — Key to be checked. [式](../syntax.md#syntax-expressions) aを返す [UInt64](../../sql-reference/data-types/int-uint.md)-タイプ値。 +- `ancestor_id_expr` — Alleged ancestor of the `child_id_expr` キー [式](../syntax.md#syntax-expressions) aを返す [UInt64](../../sql-reference/data-types/int-uint.md)-タイプ値。 + +**戻り値** + +- 0の場合 `child_id_expr` の子ではありません `ancestor_id_expr`. +- 1の場合 `child_id_expr` の子である `ancestor_id_expr` または `child_id_expr` は `ancestor_id_expr`. + +タイプ: `UInt8`. + +## その他の機能 {#ext_dict_functions-other} + +ClickHouseは、辞書構成に関係なく、辞書属性の値を特定のデータ型に変換する特殊な関数をサポートしています。 + +関数: + +- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` +- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` +- `dictGetFloat32`, `dictGetFloat64` +- `dictGetDate` +- `dictGetDateTime` +- `dictGetUUID` +- `dictGetString` + +これらの関数はすべて、 `OrDefault` 修正 例えば, `dictGetDateOrDefault`. + +構文: + +``` sql +dictGet[Type]('dict_name', 'attr_name', id_expr) +dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) +``` + +**パラメータ** + +- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `attr_name` — Name of the column of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). +- `id_expr` — Key value. [式](../syntax.md#syntax-expressions) aを返す [UInt64](../../sql-reference/data-types/int-uint.md)-タイプ値。 +- `default_value_expr` — Value which is returned if the dictionary doesn't contain a row with the `id_expr` キー [式](../syntax.md#syntax-expressions) データ型に設定された値を返す `attr_name` 属性。 + +**戻り値** + +- ClickHouseが属性を正常に解析した場合、 [属性のデータ型](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes),関数は、に対応する辞書属性の値を返します `id_expr`. + +- 要求がない場合 `id_expr` 辞書では: + + - `dictGet[Type]` returns the content of the `` element specified for the attribute in the dictionary configuration. + - `dictGet[Type]OrDefault` returns the value passed as the `default_value_expr` parameter. + +ClickHouseは、属性の値を解析できない場合、または値が属性データ型と一致しない場合に例外をスローします。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/ja/sql-reference/functions/functions-for-nulls.md b/docs/ja/sql-reference/functions/functions-for-nulls.md new file mode 100644 index 00000000000..cbd981a3530 --- /dev/null +++ b/docs/ja/sql-reference/functions/functions-for-nulls.md @@ -0,0 +1,312 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "Null\u8A31\u5BB9\u5F15\u6570\u306E\u64CD\u4F5C" +--- + +# Null許容集計を操作するための関数 {#functions-for-working-with-nullable-aggregates} + +## isNull {#isnull} + +引数が [NULL](../../sql-reference/syntax.md#null-literal). + +``` sql +isNull(x) +``` + +**パラメータ** + +- `x` — A value with a non-compound data type. + +**戻り値** + +- `1` もし `x` は `NULL`. +- `0` もし `x` ではない `NULL`. + +**例** + +入力テーブル + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +クエリ + +``` sql +SELECT x FROM t_null WHERE isNull(y) +``` + +``` text +┌─x─┐ +│ 1 │ +└───┘ +``` + +## isNotNull {#isnotnull} + +引数が [NULL](../../sql-reference/syntax.md#null-literal). + +``` sql +isNotNull(x) +``` + +**パラメータ:** + +- `x` — A value with a non-compound data type. + +**戻り値** + +- `0` もし `x` は `NULL`. +- `1` もし `x` ではない `NULL`. + +**例** + +入力テーブル + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +クエリ + +``` sql +SELECT x FROM t_null WHERE isNotNull(y) +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## 合体 {#coalesce} + +左から右にチェックするかどうか `NULL` 引数が渡され、最初のnonを返します-`NULL` 引数。 + +``` sql +coalesce(x,...) +``` + +**パラメータ:** + +- 非複合型の任意の数のパラメーター。 すべてのパラメータに対応していることが必要となるデータ型になります。 + +**戻り値** + +- 最初の非-`NULL` 引数。 +- `NULL` すべての引数が `NULL`. + +**例** + +顧客に連絡する複数の方法を指定できる連絡先のリストを検討してください。 + +``` text +┌─name─────┬─mail─┬─phone─────┬──icq─┐ +│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ +│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ +└──────────┴──────┴───────────┴──────┘ +``` + +その `mail` と `phone` フィールドはString型ですが、 `icq` フィールドは `UInt32` したがって、変換する必要があります `String`. + +連絡先リストから顧客に対して最初に使用可能な連絡先方法を取得する: + +``` sql +SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook +``` + +``` text +┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ +│ client 1 │ 123-45-67 │ +│ client 2 │ ᴺᵁᴸᴸ │ +└──────────┴──────────────────────────────────────────────────────┘ +``` + +## ifNull {#ifnull} + +Main引数が次の場合、代替値を返します `NULL`. + +``` sql +ifNull(x,alt) +``` + +**パラメータ:** + +- `x` — The value to check for `NULL`. +- `alt` — The value that the function returns if `x` は `NULL`. + +**戻り値** + +- 値 `x`,if `x` ではない `NULL`. +- 値 `alt`,if `x` は `NULL`. + +**例** + +``` sql +SELECT ifNull('a', 'b') +``` + +``` text +┌─ifNull('a', 'b')─┐ +│ a │ +└──────────────────┘ +``` + +``` sql +SELECT ifNull(NULL, 'b') +``` + +``` text +┌─ifNull(NULL, 'b')─┐ +│ b │ +└───────────────────┘ +``` + +## ヌリフ {#nullif} + +ツづゥツ。 `NULL` 引数が等しい場合。 + +``` sql +nullIf(x, y) +``` + +**パラメータ:** + +`x`, `y` — Values for comparison. They must be compatible types, or ClickHouse will generate an exception. + +**戻り値** + +- `NULL`、引数が等しい場合。 +- その `x` 引数が等しくない場合の値。 + +**例** + +``` sql +SELECT nullIf(1, 1) +``` + +``` text +┌─nullIf(1, 1)─┐ +│ ᴺᵁᴸᴸ │ +└──────────────┘ +``` + +``` sql +SELECT nullIf(1, 2) +``` + +``` text +┌─nullIf(1, 2)─┐ +│ 1 │ +└──────────────┘ +``` + +## assumeNotNull {#assumenotnull} + +結果はtypeの値になります [Null可能](../../sql-reference/data-types/nullable.md) 非のため- `Nullable` 値が `NULL`. + +``` sql +assumeNotNull(x) +``` + +**パラメータ:** + +- `x` — The original value. + +**戻り値** + +- 非からの元の値-`Nullable` そうでない場合は、タイプ `NULL`. +- 非のデフォルト値-`Nullable` 元の値が `NULL`. + +**例** + +を考える `t_null` テーブル。 + +``` sql +SHOW CREATE TABLE t_null +``` + +``` text +┌─statement─────────────────────────────────────────────────────────────────┐ +│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ +└───────────────────────────────────────────────────────────────────────────┘ +``` + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +を適用する `assumeNotNull` に対する関数 `y` 列。 + +``` sql +SELECT assumeNotNull(y) FROM t_null +``` + +``` text +┌─assumeNotNull(y)─┐ +│ 0 │ +│ 3 │ +└──────────────────┘ +``` + +``` sql +SELECT toTypeName(assumeNotNull(y)) FROM t_null +``` + +``` text +┌─toTypeName(assumeNotNull(y))─┐ +│ Int8 │ +│ Int8 │ +└──────────────────────────────┘ +``` + +## toNullable {#tonullable} + +引数の型を次のように変換します `Nullable`. + +``` sql +toNullable(x) +``` + +**パラメータ:** + +- `x` — The value of any non-compound type. + +**戻り値** + +- Aを持つ入力値 `Nullable` タイプ。 + +**例** + +``` sql +SELECT toTypeName(10) +``` + +``` text +┌─toTypeName(10)─┐ +│ UInt8 │ +└────────────────┘ +``` + +``` sql +SELECT toTypeName(toNullable(10)) +``` + +``` text +┌─toTypeName(toNullable(10))─┐ +│ Nullable(UInt8) │ +└────────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/ja/sql-reference/functions/geo.md b/docs/ja/sql-reference/functions/geo.md new file mode 100644 index 00000000000..f6b2ebd3b62 --- /dev/null +++ b/docs/ja/sql-reference/functions/geo.md @@ -0,0 +1,510 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 62 +toc_title: "\u5730\u7406\u5EA7\u6A19\u306E\u64CD\u4F5C" +--- + +# 地理座標を操作するための関数 {#functions-for-working-with-geographical-coordinates} + +## グレートサークル距離 {#greatcircledistance} + +を使用して、地球の表面上の二つの点の間の距離を計算します [大円の公式](https://en.wikipedia.org/wiki/Great-circle_distance). + +``` sql +greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) +``` + +**入力パラメータ** + +- `lon1Deg` — Longitude of the first point in degrees. Range: `[-180°, 180°]`. +- `lat1Deg` — Latitude of the first point in degrees. Range: `[-90°, 90°]`. +- `lon2Deg` — Longitude of the second point in degrees. Range: `[-180°, 180°]`. +- `lat2Deg` — Latitude of the second point in degrees. Range: `[-90°, 90°]`. + +正の値は北緯と東経に対応し、負の値は南緯と西経に対応します。 + +**戻り値** + +メートル単位で、地球の表面上の二つの点の間の距離。 + +入力パラメーター値が範囲外にある場合に例外を生成します。 + +**例** + +``` sql +SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) +``` + +``` text +┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ +│ 14132374.194975413 │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## ポイントネリップス {#pointinellipses} + +点が少なくとも一方の楕円に属しているかどうかをチェックします。 +座標はデカルト座標系では幾何学的です。 + +``` sql +pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) +``` + +**入力パラメータ** + +- `x, y` — Coordinates of a point on the plane. +- `xᵢ, yᵢ` — Coordinates of the center of the `i`-番目の省略記号。 +- `aᵢ, bᵢ` — Axes of the `i`-x、y座標の単位で番目の省略記号。 + +入力パラメータ `2+4⋅n`,ここで `n` 楕円の数です。 + +**戻り値** + +`1` 点が楕円の少なくとも一方の内側にある場合; `0`そうでない場合。 + +**例** + +``` sql +SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) +``` + +``` text +┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ +│ 1 │ +└─────────────────────────────────────────────────┘ +``` + +## ポイントポリゴン {#pointinpolygon} + +ポイントが平面上のポリゴンに属するかどうかを確認します。 + +``` sql +pointInPolygon((x, y), [(a, b), (c, d) ...], ...) +``` + +**入力値** + +- `(x, y)` — Coordinates of a point on the plane. Data type — [タプル](../../sql-reference/data-types/tuple.md) — A tuple of two numbers. +- `[(a, b), (c, d) ...]` — Polygon vertices. Data type — [配列](../../sql-reference/data-types/array.md). 各頂点は、座標のペアで表されます `(a, b)`. 頂点は時計回りまたは反時計回りの順序で指定する必要があります。 頂点の最小数は3です。 多角形は一定でなければなりません。 +- この機能にも対応し多角形穴あき(切り抜く部門). この場合、関数の追加引数を使用して切り取られたセクションを定義するポリゴンを追加します。 この機能はサポートしない非単に接続ポリゴン. + +**戻り値** + +`1` ポイントがポリゴンの内側にある場合, `0` そうでない場合。 +ポイントがポリゴン境界上にある場合、関数は0または1のいずれかを返します。 + +**例** + +``` sql +SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## geohashEncode {#geohashencode} + +緯度と経度をジオハッシュ文字列としてエンコードします。http://geohash.org/,https://en.wikipedia.org/wiki/Geohash)。 + +``` sql +geohashEncode(longitude, latitude, [precision]) +``` + +**入力値** + +- 経度-エンコードする座標の経度部分。 範囲の浮遊`[-180°, 180°]` +- 緯度-エンコードする座標の緯度の部分。 範囲の浮遊 `[-90°, 90°]` +- 精度-オプションで、結果のエンコードされた文字列の長さ。 `12`. 範囲内の整数 `[1, 12]`. より小さい値 `1` またはより大きい `12` に変換されます。 `12`. + +**戻り値** + +- 英数字 `String` 符号化座標(base32エンコーディングアルファベットの修正バージョンが使用されます)。 + +**例** + +``` sql +SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res +``` + +``` text +┌─res──────────┐ +│ ezs42d000000 │ +└──────────────┘ +``` + +## geohashDecode {#geohashdecode} + +ジオハッシュでエンコードされた文字列を経度と緯度にデコードします。 + +**入力値** + +- エンコード文字列-ジオハッシュエンコード文字列。 + +**戻り値** + +- (経度,緯度)-2-タプルの `Float64` 経度と緯度の値。 + +**例** + +``` sql +SELECT geohashDecode('ezs42') AS res +``` + +``` text +┌─res─────────────────────────────┐ +│ (-5.60302734375,42.60498046875) │ +└─────────────────────────────────┘ +``` + +## geoToH3 {#geotoh3} + +ツづゥツ。 [H3](https://uber.github.io/h3/#/documentation/overview/introduction) ポイント指数 `(lon, lat)` 指定決断を使って。 + +[H3](https://uber.github.io/h3/#/documentation/overview/introduction) 地球の表面が六角形のタイルに分割された地理的索引システムです。 このシステムは階層的であり、すなわち最上位の各六角形は七つに分割することができますが、より小さなものなどです。 + +このインデックスは、主にバケットの場所やその他の地理空間操作に使用されます。 + +**構文** + +``` sql +geoToH3(lon, lat, resolution) +``` + +**パラメータ** + +- `lon` — Longitude. Type: [Float64](../../sql-reference/data-types/float.md). +- `lat` — Latitude. Type: [Float64](../../sql-reference/data-types/float.md). +- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- 六角形のインデックス番号。 +- エラーの場合は0。 + +タイプ: `UInt64`. + +**例** + +クエリ: + +``` sql +SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index +``` + +結果: + +``` text +┌────────────h3Index─┐ +│ 644325524701193974 │ +└────────────────────┘ +``` + +## geohashesInBox {#geohashesinbox} + +指定されたボックスの内側にあり、指定されたボックスの境界と交差する、指定された精度のジオハッシュエンコードされた文字列の配列を返しま + +**入力値** + +- longitudie\_min-最小の経度、範囲内の浮動小数点値 `[-180°, 180°]` +- latitude\_min-最小緯度、範囲内の浮動小数点値 `[-90°, 90°]` +- 縦方向max-最大経度、範囲内の浮動小数点値 `[-180°, 180°]` +- latitude\_max-最大緯度、範囲内の浮動小数点値 `[-90°, 90°]` +- 精度-ジオハッシュ精度, `UInt8` 範囲内 `[1, 12]` + +すべての座標パラメータは同じタイプでなければなりません。 `Float32` または `Float64`. + +**戻り値** + +- 精度の配列-提供された領域をカバーするジオハッシュボックスの長い文字列、あなたは項目の順序に頼るべきではありません。 +- \[\]-空の配列の場合 *分* の値 *緯度* と *経度* 対応するよりも小さくない *最大* 値。 + +結果の配列が10'000'000項目以上の場合、関数は例外をスローすることに注意してください。 + +**例** + +``` sql +SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos +``` + +``` text +┌─thasos──────────────────────────────────────┐ +│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ +└─────────────────────────────────────────────┘ +``` + +## h3GetBaseCell {#h3getbasecell} + +インデックスの基本セル番号を返します。 + +**構文** + +``` sql +h3GetBaseCell(index) +``` + +**パラメータ** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- 六角形のベースのセル番号。 タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT h3GetBaseCell(612916788725809151) as basecell +``` + +結果: + +``` text +┌─basecell─┐ +│ 12 │ +└──────────┘ +``` + +## h3HexAreaM2 {#h3hexaream2} + +与えられた解像度での平方メートルの平均六角形面積。 + +**構文** + +``` sql +h3HexAreaM2(resolution) +``` + +**パラメータ** + +- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- Area in m². Type: [Float64](../../sql-reference/data-types/float.md). + +**例** + +クエリ: + +``` sql +SELECT h3HexAreaM2(13) as area +``` + +結果: + +``` text +┌─area─┐ +│ 43.9 │ +└──────┘ +``` + +## h3IndexesAreNeighbors {#h3indexesareneighbors} + +指定されたH3indexがneighborであるかどうかを返します。 + +**構文** + +``` sql +h3IndexesAreNeighbors(index1, index2) +``` + +**パラメータ** + +- `index1` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). +- `index2` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- ツづゥツ。 `1` インデックスが近傍の場合, `0` そうでなければ タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT h3IndexesAreNeighbors(617420388351344639, 617420388352655359) AS n +``` + +結果: + +``` text +┌─n─┐ +│ 1 │ +└───┘ +``` + +## h3ToChildren {#h3tochildren} + +指定したインデックスの子インデックスを持つ配列を返します。 + +**構文** + +``` sql +h3ToChildren(index, resolution) +``` + +**パラメータ** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). +- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- 子h3インデックスを持つ配列。 型の配列: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT h3ToChildren(599405990164561919, 6) AS children +``` + +結果: + +``` text +┌─children───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ [603909588852408319,603909588986626047,603909589120843775,603909589255061503,603909589389279231,603909589523496959,603909589657714687] │ +└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## h3ToParent {#h3toparent} + +指定された索引を含む親(より粗い)索引を返します。 + +**構文** + +``` sql +h3ToParent(index, resolution) +``` + +**パラメータ** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). +- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- 親H3インデックス。 タイプ: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT h3ToParent(599405990164561919, 3) as parent +``` + +結果: + +``` text +┌─────────────parent─┐ +│ 590398848891879423 │ +└────────────────────┘ +``` + +## h3ToString {#h3tostring} + +インデックスのH3Index表現を文字列表現に変換します。 + +``` sql +h3ToString(index) +``` + +**パラメータ** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- H3インデックスの文字列表現。 タイプ: [文字列](../../sql-reference/data-types/string.md). + +**例** + +クエリ: + +``` sql +SELECT h3ToString(617420388352917503) as h3_string +``` + +結果: + +``` text +┌─h3_string───────┐ +│ 89184926cdbffff │ +└─────────────────┘ +``` + +## stringToH3 {#stringtoh3} + +文字列表現をH3Index(UInt64)表現に変換します。 + +``` sql +stringToH3(index_str) +``` + +**パラメータ** + +- `index_str` — String representation of the H3 index. Type: [文字列](../../sql-reference/data-types/string.md). + +**戻り値** + +- 六角形のインデックス番号。 エラーの場合は0を返します。 タイプ: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT stringToH3('89184926cc3ffff') as index +``` + +結果: + +``` text +┌──────────────index─┐ +│ 617420388351344639 │ +└────────────────────┘ +``` + +## h3GetResolution {#h3getresolution} + +インデックスの解像度を返します。 + +**構文** + +``` sql +h3GetResolution(index) +``` + +**パラメータ** + +- `index` — Hexagon index number. Type: [UInt64](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +- インデックスの解決。 範囲: `[0, 15]`. タイプ: [UInt8](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT h3GetResolution(617420388352917503) as res +``` + +結果: + +``` text +┌─res─┐ +│ 9 │ +└─────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/ja/sql-reference/functions/hash-functions.md b/docs/ja/sql-reference/functions/hash-functions.md new file mode 100644 index 00000000000..6710f30e196 --- /dev/null +++ b/docs/ja/sql-reference/functions/hash-functions.md @@ -0,0 +1,484 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: "\u30CF\u30C3\u30B7\u30E5" +--- + +# ハッシュ関数 {#hash-functions} + +ハッシュ関数は、要素の決定論的pseudo似乱数シャッフルに使用することができます。 + +## halfMD5 {#hash-functions-halfmd5} + +[解釈する](../../sql-reference/functions/type-conversion-functions.md#type_conversion_functions-reinterpretAsString) すべての入力パラメータを文字列として計算し、 [MD5](https://en.wikipedia.org/wiki/MD5) それぞれのハッシュ値。 次に、ハッシュを結合し、結果の文字列のハッシュの最初の8バイトを取り、それらを次のように解釈します `UInt64` ビッグエンディアンのバイト順。 + +``` sql +halfMD5(par1, ...) +``` + +この機能は比較的遅い(プロセッサコアあたり毎秒5万個の短い文字列)。 +の使用を検討します。 [sipHash64](#hash_functions-siphash64) 代わりに関数。 + +**パラメータ** + +この関数は、可変数の入力パラメータを受け取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +A [UInt64](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 + +**例** + +``` sql +SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type +``` + +``` text +┌────────halfMD5hash─┬─type───┐ +│ 186182704141653334 │ UInt64 │ +└────────────────────┴────────┘ +``` + +## MD5 {#hash_functions-md5} + +文字列からMD5を計算し、結果のバイトセットをFixedString(16)として返します。 +特にMD5を必要としないが、まともな暗号化128ビットハッシュが必要な場合は、 ‘sipHash128’ 代わりに関数。 +Md5sumユーティリティによる出力と同じ結果を得たい場合は、lower(hex(MD5(s)))を使用します。 + +## sipHash64 {#hash_functions-siphash64} + +64ビットを生成する [サイファッシュ](https://131002.net/siphash/) ハッシュ値。 + +``` sql +sipHash64(par1,...) +``` + +これは暗号化ハッシュ関数です。 それはより少なくとも三倍速く働きます [MD5](#hash_functions-md5) 機能。 + +関数 [解釈する](../../sql-reference/functions/type-conversion-functions.md#type_conversion_functions-reinterpretAsString) すべての入力パラメータを文字列として計算し、それぞれのハッシュ値を計算します。 次のアルゴリズムでハッシュを結合します: + +1. すべての入力パラメータをハッシュした後、関数はハッシュの配列を取得します。 +2. 関数は、最初と第二の要素を取り、それらの配列のハッシュを計算します。 +3. 次に、関数は、前のステップで計算されたハッシュ値、および最初のハッシュ配列の第三の要素を取り、それらの配列のハッシュを計算します。 +4. 前のステップは、初期ハッシュ配列の残りのすべての要素に対して繰り返されます。 + +**パラメータ** + +この関数は、可変数の入力パラメータを受け取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +A [UInt64](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 + +**例** + +``` sql +SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type +``` + +``` text +┌──────────────SipHash─┬─type───┐ +│ 13726873534472839665 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## sipHash128 {#hash_functions-siphash128} + +文字列からSipHashを計算します。 +文字列型の引数を受け取ります。 FixedString(16)を返します。 +SipHash64とは異なり、最終的なxor折り畳み状態は128ビットまでしか行われない。 + +## シティハッシュ64 {#cityhash64} + +64ビットを生成する [シティハッシュ](https://github.com/google/cityhash) ハッシュ値。 + +``` sql +cityHash64(par1,...) +``` + +これは高速な非暗号ハッシュ関数です。 文字列パラメータにはCityHashアルゴリズムを使用し、他のデータ型のパラメータには実装固有の高速非暗号化ハッシュ関数を使用します。 この関数は、最終的な結果を得るためにCityHash combinatorを使用します。 + +**パラメータ** + +この関数は、可変数の入力パラメータを受け取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +A [UInt64](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 + +**例** + +呼び出し例: + +``` sql +SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type +``` + +``` text +┌─────────────CityHash─┬─type───┐ +│ 12072650598913549138 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +次の例では、行の順序までの精度でテーブル全体のチェックサムを計算する方法を示します: + +``` sql +SELECT groupBitXor(cityHash64(*)) FROM table +``` + +## intHash32 {#inthash32} + +任意のタイプの整数から32ビットハッシュコードを計算します。 +これは、数値の平均品質の比較的高速な非暗号ハッシュ関数です。 + +## intHash64 {#inthash64} + +任意のタイプの整数から64ビットハッシュコードを計算します。 +それはintHash32よりも速く動作します。 平均品質。 + +## SHA1 {#sha1} + +## SHA224 {#sha224} + +## SHA256 {#sha256} + +文字列からSHA-1、SHA-224、またはSHA-256を計算し、結果のバイトセットをFixedString(20)、FixedString(28)、またはFixedString(32)として返します。 +この機能はかなりゆっくりと動作します(SHA-1はプロセッサコア毎秒約5万の短い文字列を処理しますが、SHA-224とSHA-256は約2.2万の短い文字列を処理 +この関数は、特定のハッシュ関数が必要で選択できない場合にのみ使用することをお勧めします。 +このような場合でも、SELECTに適用するのではなく、関数をオフラインで適用し、テーブルに挿入するときに値を事前に計算することをお勧めします。 + +## URLHash(url\[,N\]) {#urlhashurl-n} + +何らかのタイプの正規化を使用してURLから取得された文字列に対する、高速でまともな品質の非暗号化ハッシュ関数。 +`URLHash(s)` – Calculates a hash from a string without one of the trailing symbols `/`,`?` または `#` 最後に、存在する場合。 +`URLHash(s, N)` – Calculates a hash from a string up to the N level in the URL hierarchy, without one of the trailing symbols `/`,`?` または `#` 最後に、存在する場合。 +レベルはURLHierarchyと同じです。 この機能はYandexに固有のものです。メトリカ + +## farnhash64 {#farmhash64} + +64ビットを生成する [ファームハッシュ](https://github.com/google/farmhash) ハッシュ値。 + +``` sql +farmHash64(par1, ...) +``` + +この関数は `Hash64` すべてからの方法 [利用可能な方法](https://github.com/google/farmhash/blob/master/src/farmhash.h). + +**パラメータ** + +この関数は、可変数の入力パラメータを受け取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +A [UInt64](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 + +**例** + +``` sql +SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type +``` + +``` text +┌─────────────FarmHash─┬─type───┐ +│ 17790458267262532859 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## javaHash {#hash_functions-javahash} + +計算 [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) 文字列から。 このハッシュ関数は高速でも良質でもありません。 これを使用する唯一の理由は、このアルゴリズムが既に別のシステムで使用されており、まったく同じ結果を計算する必要がある場合です。 + +**構文** + +``` sql +SELECT javaHash(''); +``` + +**戻り値** + +A `Int32` データ型のハッシュ値。 + +**例** + +クエリ: + +``` sql +SELECT javaHash('Hello, world!'); +``` + +結果: + +``` text +┌─javaHash('Hello, world!')─┐ +│ -1880044555 │ +└───────────────────────────┘ +``` + +## javaHashUTF16LE {#javahashutf16le} + +計算 [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) 文字列から、UTF-16LEエンコーディングで文字列を表すバイトが含まれていると仮定します。 + +**構文** + +``` sql +javaHashUTF16LE(stringUtf16le) +``` + +**パラメータ** + +- `stringUtf16le` — a string in UTF-16LE encoding. + +**戻り値** + +A `Int32` データ型のハッシュ値。 + +**例** + +UTF-16LEエンコード文字列でクエリを修正します。 + +クエリ: + +``` sql +SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) +``` + +結果: + +``` text +┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ +│ 3556498 │ +└──────────────────────────────────────────────────────────────┘ +``` + +## hiveHash {#hash-functions-hivehash} + +計算 `HiveHash` 文字列から。 + +``` sql +SELECT hiveHash(''); +``` + +これはちょうどです [JavaHash](#hash_functions-javahash) ゼロアウト符号ビットを持つ。 この関数は [Apacheハイブ](https://en.wikipedia.org/wiki/Apache_Hive) 3.0より前のバージョンの場合。 このハッシュ関数は高速でも良質でもありません。 これを使用する唯一の理由は、このアルゴリズムが既に別のシステムで使用されており、まったく同じ結果を計算する必要がある場合です。 + +**戻り値** + +A `Int32` データ型のハッシュ値。 + +タイプ: `hiveHash`. + +**例** + +クエリ: + +``` sql +SELECT hiveHash('Hello, world!'); +``` + +結果: + +``` text +┌─hiveHash('Hello, world!')─┐ +│ 267439093 │ +└───────────────────────────┘ +``` + +## metroHash64 {#metrohash64} + +64ビットを生成する [メトロハシュ](http://www.jandrewrogers.com/2015/05/27/metrohash/) ハッシュ値。 + +``` sql +metroHash64(par1, ...) +``` + +**パラメータ** + +この関数は、可変数の入力パラメータを受け取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +A [UInt64](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 + +**例** + +``` sql +SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type +``` + +``` text +┌────────────MetroHash─┬─type───┐ +│ 14235658766382344533 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## jumpConsistentHash {#jumpconsistenthash} + +JumpConsistentHashを計算すると、UInt64を形成します。 +UInt64型のキーとバケットの数です。 Int32を返します。 +詳細は、リンクを参照してください: [JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) + +## murmurHash2\_32,murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} + +を生成する。 [つぶやき2](https://github.com/aappleby/smhasher) ハッシュ値。 + +``` sql +murmurHash2_32(par1, ...) +murmurHash2_64(par1, ...) +``` + +**パラメータ** + +両方の関数は、可変数の入力パラメータを取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +- その `murmurHash2_32` 関数はハッシュ値を返します。 [UInt32](../../sql-reference/data-types/int-uint.md) データ型。 +- その `murmurHash2_64` 関数はハッシュ値を返します。 [UInt64](../../sql-reference/data-types/int-uint.md) データ型。 + +**例** + +``` sql +SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type +``` + +``` text +┌──────────MurmurHash2─┬─type───┐ +│ 11832096901709403633 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## gccMurmurHash {#gccmurmurhash} + +64ビットの計算 [つぶやき2](https://github.com/aappleby/smhasher) 同じハッシュシードを使用するハッシュ値 [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191). これは、CLangとGCCビルドの間で移植可能です。 + +**構文** + +``` sql +gccMurmurHash(par1, ...); +``` + +**パラメータ** + +- `par1, ...` — A variable number of parameters that can be any of the [対応するデータ型](../../sql-reference/data-types/index.md#data_types). + +**戻り値** + +- 計算されたハッシュ値。 + +タイプ: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT + gccMurmurHash(1, 2, 3) AS res1, + gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 +``` + +結果: + +``` text +┌─────────────────res1─┬────────────────res2─┐ +│ 12384823029245979431 │ 1188926775431157506 │ +└──────────────────────┴─────────────────────┘ +``` + +## murmurHash3\_32,murmurHash3\_64 {#murmurhash3-32-murmurhash3-64} + +を生成する。 [マムルハシュ3世](https://github.com/aappleby/smhasher) ハッシュ値。 + +``` sql +murmurHash3_32(par1, ...) +murmurHash3_64(par1, ...) +``` + +**パラメータ** + +両方の関数は、可変数の入力パラメータを取ります。 パラメータは、以下のいずれかです [対応するデータ型](../../sql-reference/data-types/index.md). + +**戻り値** + +- その `murmurHash3_32` 関数はaを返します [UInt32](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 +- その `murmurHash3_64` 関数はaを返します [UInt64](../../sql-reference/data-types/int-uint.md) データ型のハッシュ値。 + +**例** + +``` sql +SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type +``` + +``` text +┌─MurmurHash3─┬─type───┐ +│ 2152717 │ UInt32 │ +└─────────────┴────────┘ +``` + +## つぶやき3\_128 {#murmurhash3-128} + +128ビットを生成する [マムルハシュ3世](https://github.com/aappleby/smhasher) ハッシュ値。 + +``` sql +murmurHash3_128( expr ) +``` + +**パラメータ** + +- `expr` — [式](../syntax.md#syntax-expressions) aを返す [文字列](../../sql-reference/data-types/string.md)-タイプ値。 + +**戻り値** + +A [FixedString(16)](../../sql-reference/data-types/fixedstring.md) データ型のハッシュ値。 + +**例** + +``` sql +SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type +``` + +``` text +┌─MurmurHash3──────┬─type────────────┐ +│ 6�1�4"S5KT�~~q │ FixedString(16) │ +└──────────────────┴─────────────────┘ +``` + +## xxHash32,xxHash64 {#hash-functions-xxhash32} + +計算 `xxHash` 文字列から。 これは、二つの味、32と64ビットで提案されています。 + +``` sql +SELECT xxHash32(''); + +OR + +SELECT xxHash64(''); +``` + +**戻り値** + +A `Uint32` または `Uint64` データ型のハッシュ値。 + +タイプ: `xxHash`. + +**例** + +クエリ: + +``` sql +SELECT xxHash32('Hello, world!'); +``` + +結果: + +``` text +┌─xxHash32('Hello, world!')─┐ +│ 834093149 │ +└───────────────────────────┘ +``` + +**も参照。** + +- [xxHash](http://cyan4973.github.io/xxHash/). + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/ja/sql-reference/functions/higher-order-functions.md b/docs/ja/sql-reference/functions/higher-order-functions.md new file mode 100644 index 00000000000..f130f9a2ee4 --- /dev/null +++ b/docs/ja/sql-reference/functions/higher-order-functions.md @@ -0,0 +1,264 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "\u9AD8\u6B21" +--- + +# 高次関数 {#higher-order-functions} + +## `->` 演算子,lambda(params,expr)関数 {#operator-lambdaparams-expr-function} + +Allows describing a lambda function for passing to a higher-order function. The left side of the arrow has a formal parameter, which is any ID, or multiple formal parameters – any IDs in a tuple. The right side of the arrow has an expression that can use these formal parameters, as well as any table columns. + +例: `x -> 2 * x, str -> str != Referer.` + +高階関数は、関数の引数としてラムダ関数のみを受け入れることができます。 + +複数の引数を受け入れるlambda関数は、高次関数に渡すことができます。 この場合、高次関数には、これらの引数が対応する同じ長さのいくつかの配列が渡されます。 + +以下のような一部の機能については [arrayCount](#higher_order_functions-array-count) または [アレイサム](#higher_order_functions-array-count)、最初の引数(ラムダ関数)は省略することができます。 この場合、同一の写像が仮定される。 + +Lambda関数は、次の関数では省略できません: + +- [arrayMap](#higher_order_functions-array-map) +- [arrayFilter](#higher_order_functions-array-filter) +- [arrayFill](#higher_order_functions-array-fill) +- [arrayReverseFill](#higher_order_functions-array-reverse-fill) +- [arraySplit](#higher_order_functions-array-split) +- [arrayReverseSplit](#higher_order_functions-array-reverse-split) +- [arrayFirst](#higher_order_functions-array-first) +- [arrayFirstIndex](#higher_order_functions-array-first-index) + +### arrayMap(func, arr1, …) {#higher_order_functions-array-map} + +の元のアプリケーションから取得した配列を返します。 `func` の各要素に対する関数 `arr` 配列 + +例: + +``` sql +SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [3,4,5] │ +└─────────┘ +``` + +異なる配列から要素のタプルを作成する方法を次の例に示します: + +``` sql +SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res +``` + +``` text +┌─res─────────────────┐ +│ [(1,4),(2,5),(3,6)] │ +└─────────────────────┘ +``` + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arrayMap` 機能。 + +### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} + +要素のみを含む配列を返します。 `arr1` そのために `func` 0以外のものを返します。 + +例: + +``` sql +SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res +``` + +``` text +┌─res───────────┐ +│ ['abc World'] │ +└───────────────┘ +``` + +``` sql +SELECT + arrayFilter( + (i, x) -> x LIKE '%World%', + arrayEnumerate(arr), + ['Hello', 'abc World'] AS arr) + AS res +``` + +``` text +┌─res─┐ +│ [2] │ +└─────┘ +``` + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arrayFilter` 機能。 + +### arrayFill(func, arr1, …) {#higher_order_functions-array-fill} + +スキャンスルー `arr1` 最初の要素から最後の要素へと置き換えます `arr1[i]` によって `arr1[i - 1]` もし `func` 0を返します。 の最初の要素 `arr1` 交換されません。 + +例: + +``` sql +SELECT arrayFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res +``` + +``` text +┌─res──────────────────────────────┐ +│ [1,1,3,11,12,12,12,5,6,14,14,14] │ +└──────────────────────────────────┘ +``` + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arrayFill` 機能。 + +### arrayReverseFill(func, arr1, …) {#higher_order_functions-array-reverse-fill} + +スキャンスルー `arr1` 最後の要素から最初の要素へと置き換えます `arr1[i]` によって `arr1[i + 1]` もし `func` 0を返します。 の最後の要素 `arr1` 交換されません。 + +例: + +``` sql +SELECT arrayReverseFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res +``` + +``` text +┌─res────────────────────────────────┐ +│ [1,3,3,11,12,5,5,5,6,14,NULL,NULL] │ +└────────────────────────────────────┘ +``` + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arrayReverseFill` 機能。 + +### arraySplit(func, arr1, …) {#higher_order_functions-array-split} + +分割 `arr1` 複数の配列に。 とき `func` 0以外のものを返すと、配列は要素の左側で分割されます。 配列は最初の要素の前に分割されません。 + +例: + +``` sql +SELECT arraySplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res +``` + +``` text +┌─res─────────────┐ +│ [[1,2,3],[4,5]] │ +└─────────────────┘ +``` + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arraySplit` 機能。 + +### arrayReverseSplit(func, arr1, …) {#higher_order_functions-array-reverse-split} + +分割 `arr1` 複数の配列に。 とき `func` 0以外のものを返すと、配列は要素の右側に分割されます。 配列は最後の要素の後に分割されません。 + +例: + +``` sql +SELECT arrayReverseSplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res +``` + +``` text +┌─res───────────────┐ +│ [[1],[2,3,4],[5]] │ +└───────────────────┘ +``` + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arraySplit` 機能。 + +### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} + +Funcが0以外のものを返すarr配列内の要素の数を返します。 もし ‘func’ 指定されていない場合は、配列内のゼロ以外の要素の数を返します。 + +### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} + +少なくとも一つの要素がある場合は1を返します ‘arr’ そのために ‘func’ 0以外のものを返します。 それ以外の場合は0を返します。 + +### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} + +場合は1を返します ‘func’ 内のすべての要素に対して0以外のものを返します ‘arr’. それ以外の場合は0を返します。 + +### arraySum(\[func,\] arr1, …) {#higher-order-functions-array-sum} + +の合計を返します。 ‘func’ 値。 関数を省略すると、配列要素の合計が返されます。 + +### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} + +の最初の要素を返します。 ‘arr1’ これに対する配列 ‘func’ 0以外のものを返します。 + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arrayFirst` 機能。 + +### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} + +の最初の要素のインデックスを返します。 ‘arr1’ これに対する配列 ‘func’ 0以外のものを返します。 + +最初の引数(ラムダ関数)は省略できないことに注意してください。 `arrayFirstIndex` 機能。 + +### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} + +ソース配列内の要素の部分和(実行中の合計)の配列を返します。 もし `func` 関数が指定されると、配列要素の値は合計する前にこの関数によって変換されます。 + +例: + +``` sql +SELECT arrayCumSum([1, 1, 1, 1]) AS res +``` + +``` text +┌─res──────────┐ +│ [1, 2, 3, 4] │ +└──────────────┘ +``` + +### arrayCumSumNonNegative(arr) {#arraycumsumnonnegativearr} + +同じ `arrayCumSum`,ソース配列内の要素の部分和の配列を返します(実行中の合計)。 異なる `arrayCumSum` 返された値にゼロ未満の値が含まれている場合、値はゼロに置き換えられ、その後の計算はゼロパラメータで実行されます。 例えば: + +``` sql +SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res +``` + +``` text +┌─res───────┐ +│ [1,2,0,1] │ +└───────────┘ +``` + +### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} + +の要素を並べ替えた結果として配列を返します `arr1` 昇順で。 もし `func` 関数が指定され、ソート順序は関数の結果によって決定されます `func` 配列(配列)の要素に適用されます) + +その [シュワルツ変換](https://en.wikipedia.org/wiki/Schwartzian_transform) 分類の効率を改善するのに使用されています。 + +例: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); +``` + +``` text +┌─res────────────────┐ +│ ['world', 'hello'] │ +└────────────────────┘ +``` + +詳細については、 `arraySort` 方法は、参照してください [配列を操作するための関数](array-functions.md#array_functions-sort) セクション + +### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} + +の要素を並べ替えた結果として配列を返します `arr1` 降順で。 もし `func` 関数が指定され、ソート順序は関数の結果によって決定されます `func` 配列(配列)の要素に適用されます。 + +例: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +詳細については、 `arrayReverseSort` 方法は、参照してください [配列を操作するための関数](array-functions.md#array_functions-reverse-sort) セクション + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/ja/sql-reference/functions/in-functions.md b/docs/ja/sql-reference/functions/in-functions.md new file mode 100644 index 00000000000..575f9787ec2 --- /dev/null +++ b/docs/ja/sql-reference/functions/in-functions.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 60 +toc_title: "IN\u6F14\u7B97\u5B50\u306E\u5B9F\u88C5" +--- + +# IN演算子を実装するための関数 {#functions-for-implementing-the-in-operator} + +## で、ノチン、グロバリン、グロバルノチン {#in-functions} + +セクションを参照 [演算子で](../operators/in.md#select-in-operators). + +## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} + +複数の列をグループ化できる関数。 +For columns with the types T1, T2, …, it returns a Tuple(T1, T2, …) type tuple containing these columns. There is no cost to execute the function. +タプルは、通常、in演算子の引数の中間値として、またはラムダ関数の仮パラメータのリストを作成するために使用されます。 タプルをテーブルに書き込むことはできません。 + +## tupleElement(タプル,n),演算子x.N {#tupleelementtuple-n-operator-x-n} + +タプルから列を取得できる関数。 +‘N’ 1から始まる列インデックスです。 Nは定数でなければなりません。 ‘N’ 定数でなければなりません。 ‘N’ 組のサイズより大きくない厳密なpostive整数でなければなりません。 +関数を実行するコストはありません。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/ja/sql-reference/functions/index.md b/docs/ja/sql-reference/functions/index.md new file mode 100644 index 00000000000..0a51bbb778e --- /dev/null +++ b/docs/ja/sql-reference/functions/index.md @@ -0,0 +1,74 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u95A2\u6570" +toc_priority: 32 +toc_title: "\u306F\u3058\u3081\u306B" +--- + +# 関数 {#functions} + +通常の関数(それらは単に呼び出されます)-関数の少なくとも\*二つの種類があります “functions”) and aggregate functions. These are completely different concepts. Regular functions work as if they are applied to each row separately (for each row, the result of the function doesn't depend on the other rows). Aggregate functions accumulate a set of values from various rows (i.e. they depend on the entire set of rows). + +本項では通常の関数について説明する。 のための集計関数の項をご参照ください “Aggregate functions”. + +\*-機能の第三のタイプがあります ‘arrayJoin’ テーブル関数は別にも言及することができます。\* + +## 強力なタイピング {#strong-typing} + +標準のSQLとは対照的に、ClickHouseには強力な型指定があります。 言い換えれば、型間で暗黙的な変換は行われません。 各関数は、特定の型セットに対して機能します。 つまり、型変換関数を使用する必要があることがあります。 + +## 共通の部分式の除去 {#common-subexpression-elimination} + +同じAST(同じレコードまたは構文解析結果)を持つクエリ内のすべての式は、同じ値を持つと見なされます。 このような式は連結され、一度実行されます。 同一のサブクエリもこの方法で削除されます。 + +## 結果のタイプ {#types-of-results} + +すべての関数は、結果として単一の戻り値を返します(複数の値ではなく、ゼロ値ではありません)。 結果の型は、通常、値ではなく、引数の型によってのみ定義されます。 例外は、tupleElement関数(a.N演算子)とtoFixedString関数です。 + +## 定数 {#constants} + +簡単にするために、特定の関数は、いくつかの引数の定数のみで動作できます。 たとえば、LIKE演算子の右引数は定数でなければなりません。 +ほとんどすべての関数は、定数引数の定数を返します。 例外は、乱数を生成する関数です。 +その ‘now’ 関数は、異なる時間に実行されたクエリに対して異なる値を返しますが、定数は単一のクエリ内でのみ重要であるため、結果は定数と見なされます。 +定数式は定数とも見なされます(たとえば、LIKE演算子の右半分は複数の定数から構成できます)。 + +関数は、定数と非定数引数のために異なる方法で実装することができます(異なるコードが実行されます)。 しかし、定数と同じ値だけを含む真の列の結果は、お互いに一致する必要があります。 + +## ヌル処理 {#null-processing} + +関数の動作は次のとおりです: + +- 関数の引数の少なくとも一つが `NULL`、関数の結果もあります `NULL`. +- 各関数の説明で個別に指定される特殊な動作。 ClickHouseのソースコードでは、これらの関数は `UseDefaultImplementationForNulls=false`. + +## 不変性 {#constancy} + +Functions can't change the values of their arguments – any changes are returned as the result. Thus, the result of calculating separate functions does not depend on the order in which the functions are written in the query. + +## エラー処理 {#error-handling} + +データが無効な場合、一部の関数は例外をスローすることがあります。 この場合、クエリはキャンセルされ、エラーテキストがクライアントに返されます。 分散処理の場合、いずれかのサーバーで例外が発生すると、他のサーバーもクエリを中止しようとします。 + +## 引数式の評価 {#evaluation-of-argument-expressions} + +ほぼすべてのプログラミング言語の一つの引数が評価される。 これは通常、演算子です `&&`, `||`,and `?:`. +しかし、ClickHouseでは、関数(演算子)の引数は常に評価されます。 これは、各行を別々に計算するのではなく、列の部分全体が一度に評価されるためです。 + +## 分散クエリ処理のための関数の実行 {#performing-functions-for-distributed-query-processing} + +分散クエリ処理の場合、リモートサーバーではできるだけ多くのステージのクエリ処理が実行され、残りのステージ(中間結果とそれ以降のすべてをマージ)はリクエ + +つまり、異なるサーバーで機能を実行できます。 +たとえば、クエリでは `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` + +- もし `distributed_table` 少なくとも二つの破片を持っている、機能 ‘g’ と ‘h’ は、リモートサーバ上で実行され、 ‘f’ 要求元サーバー上で実行されます。 +- もし `distributed_table` 一つだけの破片、すべてを持っています ‘f’, ‘g’,and ‘h’ 機能は、このシャードのサーバー上で実行されます。 + +通常、関数の結果は、実行されるサーバーに依存しません。 しかし、時にはこれが重要です。 +たとえば、辞書を操作する関数は、それらが実行されているサーバー上に存在する辞書を使用します。 +別の例は、 `hostName` 実行しているサーバーの名前を返す関数 `GROUP BY` aのサーバーによって `SELECT` クエリ。 + +クエリ内の関数がリクエスタサーバで実行されているが、リモートサーバで実行する必要がある場合は、リクエスタサーバにラップすることができます。 ‘any’ 関数を集計するか、キーに追加します `GROUP BY`. + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/ja/sql-reference/functions/introspection.md b/docs/ja/sql-reference/functions/introspection.md new file mode 100644 index 00000000000..4aef649b3cd --- /dev/null +++ b/docs/ja/sql-reference/functions/introspection.md @@ -0,0 +1,310 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 65 +toc_title: "\u5185\u7701" +--- + +# 内観関数 {#introspection-functions} + +この章で説明する関数を使用して、イントロスペクトできます [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) と [DWARF](https://en.wikipedia.org/wiki/DWARF) クエリプロファイル用。 + +!!! warning "警告" + これらの機能は、が必要となる場合があり安全に配慮し + +内観機能の適切な操作のため: + +- インストール `clickhouse-common-static-dbg` パッケージ。 + +- セット [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) 1に設定します。 + + For security reasons introspection functions are disabled by default. + +ClickHouseはプロファイラレポートを [trace\_log](../../operations/system-tables.md#system_tables-trace_log) システムテーブル。 のテーブルプロファイラで設定されます。 + +## アドレストリン {#addresstoline} + +ClickHouse serverプロセス内の仮想メモリアドレスを、ClickHouseソースコード内のファイル名と行番号に変換します。 + +公式のClickHouseパッケージを使用する場合は、 `clickhouse-common-static-dbg` パッケージ。 + +**構文** + +``` sql +addressToLine(address_of_binary_instruction) +``` + +**パラメータ** + +- `address_of_binary_instruction` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Address of instruction in a running process. + +**戻り値** + +- ソースコードのファイル名とこのファイル内の行番号をコロンで区切ります。 + + For example, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, where `199` is a line number. + +- 関数がデバッグ情報を見つけられなかった場合のバイナリの名前。 + +- アドレスが無効な場合は、空の文字列。 + +タイプ: [文字列](../../sql-reference/data-types/string.md). + +**例** + +イントロスペクション機能の有効化: + +``` sql +SET allow_introspection_functions=1 +``` + +から最初の文字列を選択する `trace_log` システム表: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-19 +event_time: 2019-11-19 18:57:23 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 421b6855-1858-45a5-8f37-f383409d6d72 +trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] +``` + +その `trace` 分野のスタックトレースを瞬時にサンプリングします。 + +単一のアドレスのソースコードのファイル名と行番号の取得: + +``` sql +SELECT addressToLine(94784076370703) \G +``` + +``` text +Row 1: +────── +addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +``` + +スタックトレース全体への関数の適用: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines +FROM system.trace_log +LIMIT 1 +\G +``` + +その [arrayMap](higher-order-functions.md#higher_order_functions-array-map) 機能はの各々の個々の要素を処理することを割り当てます `trace` による配列 `addressToLine` 機能。 この処理の結果は `trace_source_code_lines` 出力の列。 + +``` text +Row 1: +────── +trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so +/usr/lib/debug/usr/bin/clickhouse +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 +/usr/include/c++/9/bits/atomic_base.h:551 +/usr/lib/debug/usr/bin/clickhouse +/lib/x86_64-linux-gnu/libpthread-2.27.so +/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 +``` + +## addressToSymbol {#addresstosymbol} + +に変換する仮想メモリアドレス内ClickHouseサーバプロセスのシンボルからClickHouseオブジェクトファイルです。 + +**構文** + +``` sql +addressToSymbol(address_of_binary_instruction) +``` + +**パラメータ** + +- `address_of_binary_instruction` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Address of instruction in a running process. + +**戻り値** + +- ClickHouseオブジェクトファイルからの記号。 +- アドレスが無効な場合は、空の文字列。 + +タイプ: [文字列](../../sql-reference/data-types/string.md). + +**例** + +イントロスペクション機能の有効化: + +``` sql +SET allow_introspection_functions=1 +``` + +から最初の文字列を選択する `trace_log` システム表: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +その `trace` 分野のスタックトレースを瞬時にサンプリングします。 + +単一のアドレスのシンボルの取得: + +``` sql +SELECT addressToSymbol(94138803686098) \G +``` + +``` text +Row 1: +────── +addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +``` + +スタックトレース全体への関数の適用: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols +FROM system.trace_log +LIMIT 1 +\G +``` + +その [arrayMap](higher-order-functions.md#higher_order_functions-array-map) 機能はの各々の個々の要素を処理することを割り当てます `trace` による配列 `addressToSymbols` 機能。 この処理の結果は `trace_symbols` 出力の列。 + +``` text +Row 1: +────── +trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE +_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb +_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb +_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE +_ZN2DB27AggregatingBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB28AsynchronousBlockInputStream9calculateEv +_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data +_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E +_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv +_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E +execute_native_thread_routine +start_thread +clone +``` + +## デマングル {#demangle} + +を使用して取得できるシンボルを変換します [addressToSymbol](#addresstosymbol) C++関数名への関数。 + +**構文** + +``` sql +demangle(symbol) +``` + +**パラメータ** + +- `symbol` ([文字列](../../sql-reference/data-types/string.md)) — Symbol from an object file. + +**戻り値** + +- C++関数の名前。 +- シンボルが無効な場合は空の文字列。 + +タイプ: [文字列](../../sql-reference/data-types/string.md). + +**例** + +イントロスペクション機能の有効化: + +``` sql +SET allow_introspection_functions=1 +``` + +から最初の文字列を選択する `trace_log` システム表: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +その `trace` 分野のスタックトレースを瞬時にサンプリングします。 + +単一のアドレスの関数名の取得: + +``` sql +SELECT demangle(addressToSymbol(94138803686098)) \G +``` + +``` text +Row 1: +────── +demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +``` + +スタックトレース全体への関数の適用: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions +FROM system.trace_log +LIMIT 1 +\G +``` + +その [arrayMap](higher-order-functions.md#higher_order_functions-array-map) 機能はの各々の個々の要素を処理することを割り当てます `trace` による配列 `demangle` 機能。 この処理の結果は `trace_functions` 出力の列。 + +``` text +Row 1: +────── +trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const +DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) +DB::AggregatingBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::AsynchronousBlockInputStream::calculate() +std::_Function_handler::_M_invoke(std::_Any_data const&) +ThreadPoolImpl::worker(std::_List_iterator) +ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const +ThreadPoolImpl::worker(std::_List_iterator) +execute_native_thread_routine +start_thread +clone +``` diff --git a/docs/ja/sql-reference/functions/ip-address-functions.md b/docs/ja/sql-reference/functions/ip-address-functions.md new file mode 100644 index 00000000000..295a6f673b9 --- /dev/null +++ b/docs/ja/sql-reference/functions/ip-address-functions.md @@ -0,0 +1,248 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 55 +toc_title: "IP\u30A2\u30C9\u30EC\u30B9\u306E\u64CD\u4F5C" +--- + +# IPアドレスを操作するための関数 {#functions-for-working-with-ip-addresses} + +## IPv4NumToString(num) {#ipv4numtostringnum} + +UInt32番号を取ります。 ビッグエンディアンのIPv4アドレスとして解釈します。 対応するIPv4アドレスを含む文字列を、a.B.C.d(小数点以下のドット区切りの数値)の形式で返します。 + +## IPv4StringToNum(s) {#ipv4stringtonums} + +IPv4NumToStringの逆関数。 IPv4アドレスの形式が無効な場合は、0を返します。 + +## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} + +IPv4NumToStringに似ていますが、最後のオクテットの代わりにxxxを使用します。 + +例: + +``` sql +SELECT + IPv4NumToStringClassC(ClientIP) AS k, + count() AS c +FROM test.hits +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─k──────────────┬─────c─┐ +│ 83.149.9.xxx │ 26238 │ +│ 217.118.81.xxx │ 26074 │ +│ 213.87.129.xxx │ 25481 │ +│ 83.149.8.xxx │ 24984 │ +│ 217.118.83.xxx │ 22797 │ +│ 78.25.120.xxx │ 22354 │ +│ 213.87.131.xxx │ 21285 │ +│ 78.25.121.xxx │ 20887 │ +│ 188.162.65.xxx │ 19694 │ +│ 83.149.48.xxx │ 17406 │ +└────────────────┴───────┘ +``` + +を使用して以来 ‘xxx’ 非常に珍しいですが、これは将来的に変更される可能性があります。 このフラグメントの正確な形式に依存しないことをお勧めします。 + +### IPv6NumToString(x) {#ipv6numtostringx} + +バイナリ形式のIPv6アドレスを含むFixedString(16)値を受け入れます。 このアドレスを含む文字列をテキスト形式で返します。 +IPv6マップされたIPv4アドレスは、::ffff:111.222.33.44の形式で出力されます。 例: + +``` sql +SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr +``` + +``` text +┌─addr─────────┐ +│ 2a02:6b8::11 │ +└──────────────┘ +``` + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ +│ 2a02:2168:aaa:bbbb::2 │ 24695 │ +│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ +│ 2a02:6b8:0:fff::ff │ 16389 │ +│ 2a01:4f8:111:6666::2 │ 16016 │ +│ 2a02:2168:888:222::1 │ 15896 │ +│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ +│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ +│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ +│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ +│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ +└─────────────────────────────────────────┴───────┘ +``` + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─IPv6NumToString(ClientIP6)─┬──────c─┐ +│ ::ffff:94.26.111.111 │ 747440 │ +│ ::ffff:37.143.222.4 │ 529483 │ +│ ::ffff:5.166.111.99 │ 317707 │ +│ ::ffff:46.38.11.77 │ 263086 │ +│ ::ffff:79.105.111.111 │ 186611 │ +│ ::ffff:93.92.111.88 │ 176773 │ +│ ::ffff:84.53.111.33 │ 158709 │ +│ ::ffff:217.118.11.22 │ 154004 │ +│ ::ffff:217.118.11.33 │ 148449 │ +│ ::ffff:217.118.11.44 │ 148243 │ +└────────────────────────────┴────────┘ +``` + +## IPv6StringToNum(s) {#ipv6stringtonums} + +IPv6NumToStringの逆関数。 IPv6アドレスの形式が無効な場合は、nullバイトの文字列を返します。 +HEXは大文字または小文字です。 + +## IPv4ToIPv6(x) {#ipv4toipv6x} + +を取る `UInt32` 番号 これをIPv4アドレスとして解釈します。 [ビッグエンディアン](https://en.wikipedia.org/wiki/Endianness). Aを返します `FixedString(16)` IPv6アドレスをバイナリ形式で含む値。 例: + +``` sql +SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr +``` + +``` text +┌─addr───────────────┐ +│ ::ffff:192.168.0.1 │ +└────────────────────┘ +``` + +## cutIPv6(x,bytesToCutForIPv6,bytesToCutForIPv4) {#cutipv6x-bytestocutforipv6-bytestocutforipv4} + +バイナリ形式のIPv6アドレスを含むFixedString(16)値を受け入れます。 テキスト形式で削除された指定されたバイト数のアドレスを含む文字列を返します。 例えば: + +``` sql +WITH + IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, + IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 +SELECT + cutIPv6(ipv6, 2, 0), + cutIPv6(ipv4, 0, 2) +``` + +``` text +┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ +│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ +└─────────────────────────────────────┴─────────────────────┘ +``` + +## IPv4CIDRToRange(ipv4,Cidr), {#ipv4cidrtorangeipv4-cidr} + +IPv4およびuint8の値を受け入れます。 [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing). サブネットの低い範囲と高い範囲を含むIPv4のタプルを返します。 + +``` sql +SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) +``` + +``` text +┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ +│ ('192.168.0.0','192.168.255.255') │ +└────────────────────────────────────────────┘ +``` + +## IPv6CIDRToRange(ipv6,Cidr), {#ipv6cidrtorangeipv6-cidr} + +IPv6およびCidrを含むUInt8値を受け入れます。 サブネットの下位範囲と上位の範囲を含むIPv6のタプルを返します。 + +``` sql +SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); +``` + +``` text +┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ +│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ +└────────────────────────────────────────────────────────────────────────┘ +``` + +## toIPv4(文字列) {#toipv4string} + +エイリアス `IPv4StringToNum()` これは、IPv4アドレスの文字列形式をとり、の値を返します [IPv4](../../sql-reference/data-types/domains/ipv4.md) 返される値と等しいバイナリ型 `IPv4StringToNum()`. + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + toTypeName(IPv4StringToNum(IPv4_string)), + toTypeName(toIPv4(IPv4_string)) +``` + +``` text +┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ +│ UInt32 │ IPv4 │ +└──────────────────────────────────────────┴─────────────────────────────────┘ +``` + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + hex(IPv4StringToNum(IPv4_string)), + hex(toIPv4(IPv4_string)) +``` + +``` text +┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ +│ ABE1822D │ ABE1822D │ +└───────────────────────────────────┴──────────────────────────┘ +``` + +## toIPv6(文字列) {#toipv6string} + +エイリアス `IPv6StringToNum()` これは、IPv6アドレスの文字列形式を取り、の値を返します [IPv6](../../sql-reference/data-types/domains/ipv6.md) 返される値と等しいバイナリ型 `IPv6StringToNum()`. + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + toTypeName(IPv6StringToNum(IPv6_string)), + toTypeName(toIPv6(IPv6_string)) +``` + +``` text +┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ +│ FixedString(16) │ IPv6 │ +└──────────────────────────────────────────┴─────────────────────────────────┘ +``` + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + hex(IPv6StringToNum(IPv6_string)), + hex(toIPv6(IPv6_string)) +``` + +``` text +┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ +│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ +└───────────────────────────────────┴──────────────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/ja/sql-reference/functions/json-functions.md b/docs/ja/sql-reference/functions/json-functions.md new file mode 100644 index 00000000000..921efc675eb --- /dev/null +++ b/docs/ja/sql-reference/functions/json-functions.md @@ -0,0 +1,297 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 56 +toc_title: "JSON\u3067\u306E\u4F5C\u696D" +--- + +# JSONを操作するための関数 {#functions-for-working-with-json} + +Yandexので。Metrica、JSONで送信したユーザーとしてセッションパラメータ。 このJSONを操作するための特別な関数がいくつかあります。 (ほとんどの場合、Jsonはさらに前処理され、結果の値は処理された形式で別々の列に入れられます。)これらの関数はすべて、JSONが何であるかについての強い前提に基づいていますが、できるだけ少なくして仕事を終わらせようとします。 + +以下の仮定が行われます: + +1. フィールド名(関数の引数)は定数でなければなりません。 +2. フィールド名は何らかの形でjsonでエンコードされます。 例えば: `visitParamHas('{"abc":"def"}', 'abc') = 1` でも `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` +3. フィールドは、任意の入れ子レベルで無差別に検索されます。 複数の一致するフィールドがある場合は、最初の出現が使用されます。 +4. JSONには文字列リテラルの外側に空白文字はありません。 + +## visitParamHas(パラムス、名前) {#visitparamhasparams-name} + +があるかどうかをチェックします。 ‘name’ 名前 + +## ビジットパラメクストラクチュイント(params,name) {#visitparamextractuintparams-name} + +名前のフィールドの値からUInt64を解析します ‘name’. これが文字列フィールドの場合、文字列の先頭から数値を解析しようとします。 フィールドが存在しない場合、または存在するが数値が含まれていない場合は、0を返します。 + +## ビジットパラメクストラクチント(params,name) {#visitparamextractintparams-name} + +Int64と同じです。 + +## パラメーター) {#visitparamextractfloatparams-name} + +Float64と同じです。 + +## ビジットパラメクストラクトブール(params,name) {#visitparamextractboolparams-name} + +真/偽の値を解析します。 結果はUInt8です。 + +## ビジットパラメクストラクトロー(params,name) {#visitparamextractrawparams-name} + +区切り文字を含むフィールドの値を返します。 + +例: + +``` sql +visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' +visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' +``` + +## パラメーターを指定します) {#visitparamextractstringparams-name} + +二重引用符で文字列を解析します。 値はエスケープされていません。 エスケープ解除に失敗した場合は、空の文字列を返します。 + +例: + +``` sql +visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' +visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' +visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' +visitParamExtractString('{"abc":"hello}', 'abc') = '' +``` + +現在、この形式のコードポイントはサポートされていません `\uXXXX\uYYYY` それは基本的な多言語面からではありません(UTF-8の代わりにCESU-8に変換されます)。 + +以下の機能は、次のとおりです [simdjson](https://github.com/lemire/simdjson) より複雑なJSON解析要件用に設計されています。 上記の仮定2はまだ適用されます。 + +## isValidJSON(json) {#isvalidjsonjson} + +渡された文字列が有効なjsonであることを確認します。 + +例: + +``` sql +SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 +SELECT isValidJSON('not a json') = 0 +``` + +## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} + +値がJSONドキュメントに存在する場合, `1` 返されます。 + +値が存在しない場合, `0` 返されます。 + +例: + +``` sql +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 +``` + +`indices_or_keys` ゼロ以上の引数のリストは、それぞれ文字列または整数のいずれかになります。 + +- String=キ +- 正の整数=最初からn番目のメンバー/キーにアクセスします。 +- 負の整数=最後からn番目のメンバー/キーにアクセスします。 + +要素の最小インデックスは1です。 したがって、要素0は存在しません。 + +整数を使用してJSON配列とJSONオブジェクトの両方にアクセスできます。 + +例えば: + +``` sql +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' +``` + +## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} + +JSON配列またはJSONオブジェクトの長さを返します。 + +値が存在しない場合、または型が間違っている場合, `0` 返されます。 + +例: + +``` sql +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 +``` + +## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} + +JSON値の型を返します。 + +値が存在しない場合, `Null` 返されます。 + +例: + +``` sql +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' +``` + +## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} + +## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} + +## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} + +## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} + +JSONを解析して値を抽出します。 これらの機能と類似 `visitParam` 機能。 + +値が存在しない場合、または型が間違っている場合, `0` 返されます。 + +例: + +``` sql +SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 +SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 +SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 +``` + +## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} + +JSONを解析して文字列を抽出します。 この関数は次のようになります `visitParamExtractString` 機能。 + +値が存在しないか、型が間違っている場合は、空の文字列が返されます。 + +値はエスケープされていません。 エスケープ解除に失敗した場合は、空の文字列を返します。 + +例: + +``` sql +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' +SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' +SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' +SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' +SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' +``` + +## JSONExtract(json\[, indices\_or\_keys…\], Return\_type) {#jsonextractjson-indices-or-keys-return-type} + +JSONを解析し、指定されたClickHouseデータ型の値を抽出します。 + +これは以前のものの一般化です `JSONExtract` 機能。 +つまり +`JSONExtract(..., 'String')` とまったく同じを返します `JSONExtractString()`, +`JSONExtract(..., 'Float64')` とまったく同じを返します `JSONExtractFloat()`. + +例: + +``` sql +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL +SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 +SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' +SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' +``` + +## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], Value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} + +値が指定されたClickHouseデータ型であるJSONからキーと値のペアを解析します。 + +例: + +``` sql +SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)] +``` + +## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} + +JSONの一部を解析されていない文字列として返します。 + +パーツが存在しないか、型が間違っている場合は、空の文字列が返されます。 + +例: + +``` sql +SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' +``` + +## JSONExtractArrayRaw(json\[, indices\_or\_keys…\]) {#jsonextractarrayrawjson-indices-or-keys} + +JSON配列の要素を持つ配列を返します。 + +パーツが存在しないか配列でない場合は、空の配列が返されます。 + +例: + +``` sql +SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' +``` + +## JSONExtractKeysAndValuesRaw {#json-extract-keys-and-values-raw} + +JSONオブジェクトから生データを抽出します。 + +**構文** + +``` sql +JSONExtractKeysAndValuesRaw(json[, p, a, t, h]) +``` + +**パラメータ** + +- `json` — [文字列](../data-types/string.md) 有効なJSONで。 +- `p, a, t, h` — Comma-separated indices or keys that specify the path to the inner field in a nested JSON object. Each argument can be either a [文字列](../data-types/string.md) キーまたはキーでフィールドを取得するには [整数](../data-types/int-uint.md) N番目のフィールドを取得するには(1からインデックス付けされ、負の整数は最後から数えます)。 設定されていない場合、JSON全体がトップレベルのオブジェクトとして解析されます。 任意パラメータ。 + +**戻り値** + +- との配列 `('key', 'value')` タプル 両方のタプルメンバーは文字列です。 +- 要求されたオブジェクトが存在しない場合、または入力JSONが無効な場合は空の配列。 + +タイプ: [配列](../data-types/array.md)([タプル](../data-types/tuple.md)([文字列](../data-types/string.md), [文字列](../data-types/string.md)). + +**例** + +クエリ: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}') +``` + +結果: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}')─┐ +│ [('a','[-100,200]'),('b','{"c":{"d":"hello","f":"world"}}')] │ +└──────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +クエリ: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b') +``` + +結果: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b')─┐ +│ [('c','{"d":"hello","f":"world"}')] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +クエリ: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c') +``` + +結果: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c')─┐ +│ [('d','"hello"'),('f','"world"')] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) diff --git a/docs/ja/sql-reference/functions/logical-functions.md b/docs/ja/sql-reference/functions/logical-functions.md new file mode 100644 index 00000000000..b1b35c56c43 --- /dev/null +++ b/docs/ja/sql-reference/functions/logical-functions.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u8AD6\u7406" +--- + +# 論理関数 {#logical-functions} + +論理関数は任意の数値型を受け入れますが、UInt8は0または1に等しい数値を返します。 + +引数としてのゼロが考慮されます “false,” ゼロ以外の値は考慮されますが “true”. + +## and,and演算子 {#and-and-operator} + +## or,OR演算子 {#or-or-operator} + +## ない、ない演算子 {#not-not-operator} + +## xor {#xor} + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/ja/sql-reference/functions/machine-learning-functions.md b/docs/ja/sql-reference/functions/machine-learning-functions.md new file mode 100644 index 00000000000..484d2fdd693 --- /dev/null +++ b/docs/ja/sql-reference/functions/machine-learning-functions.md @@ -0,0 +1,20 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 64 +toc_title: "\u6A5F\u68B0\u5B66\u7FD2\u6A5F\u80FD" +--- + +# 機械学習機能 {#machine-learning-functions} + +## evalMLMethod(予測) {#machine_learning_methods-evalmlmethod} + +近似回帰モデルを使用した予測では `evalMLMethod` 機能。 リンクを参照 `linearRegression`. + +### 確率的線形回帰 {#stochastic-linear-regression} + +その [stochasticLinearRegression](../../sql-reference/aggregate-functions/reference.md#agg_functions-stochasticlinearregression) 集計関数は線形モデルとMSE損失関数を用いた確率勾配降下法を実装する。 用途 `evalMLMethod` 新しいデータを予測する。 + +### 確率ロジスティック回帰 {#stochastic-logistic-regression} + +その [stochasticLogisticRegression](../../sql-reference/aggregate-functions/reference.md#agg_functions-stochasticlogisticregression) 集計関数は、バイナリ分類問題のための確率勾配降下法を実装しています。 用途 `evalMLMethod` 新しいデータを予測する。 diff --git a/docs/ja/sql-reference/functions/math-functions.md b/docs/ja/sql-reference/functions/math-functions.md new file mode 100644 index 00000000000..656d1350043 --- /dev/null +++ b/docs/ja/sql-reference/functions/math-functions.md @@ -0,0 +1,116 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u6570\u5B66" +--- + +# 数学関数 {#mathematical-functions} + +すべての関数はFloat64番号を返します。 結果の精度は可能な最大精度に近いですが、結果は対応する実数に最も近い機械表現可能な数と一致しない可能性があります。 + +## e() {#e} + +数値eに近いFloat64番号を返します。 + +## pi() {#pi} + +Returns a Float64 number that is close to the number π. + +## exp(x) {#expx} + +数値引数を受け取り、引数の指数に近いFloat64番号を返します。 + +## ログ(x),ln(x) {#logx-lnx} + +数値引数を受け取り、引数の自然対数に近いFloat64数を返します。 + +## exp2(x) {#exp2x} + +数値引数を受け取り、Float64をxの累乗に近い2に近い数値を返します。 + +## log2(x) {#log2x} + +数値引数を受け取り、引数のバイナリ対数に近いFloat64数値を返します。 + +## exp10(x) {#exp10x} + +数値引数を受け取り、Float64のxの累乗に近い10の数値を返します。 + +## log10(x) {#log10x} + +数値引数を受け取り、引数の小数対数に近いFloat64数値を返します。 + +## sqrt(x) {#sqrtx} + +数値引数を受け取り、引数の平方根に近いFloat64番号を返します。 + +## cbrt(x) {#cbrtx} + +数値引数を受け取り、引数の三次根に近いFloat64番号を返します。 + +## erf(x) {#erfx} + +もし ‘x’ 負でない場合、 `erf(x / σ√2)` 確率変数が標準偏差を持つ正規分布を持つ確率です ‘σ’ より多くの期待値から分離された値を取ります ‘x’. + +例(三シグマ則): + +``` sql +SELECT erf(3 / sqrt(2)) +``` + +``` text +┌─erf(divide(3, sqrt(2)))─┐ +│ 0.9973002039367398 │ +└─────────────────────────┘ +``` + +## erfc(x) {#erfcx} + +数値引数を受け取り、Float64の1-erf(x)に近い数値を返します。 ‘x’ 値。 + +## lgamma(x) {#lgammax} + +ガンマ関数の対数。 + +## tgamma(x) {#tgammax} + +ガンマ関数 + +## sin(x) {#sinx} + +正弦。 + +## cos(x) {#cosx} + +コサイン + +## タン(x) {#tanx} + +接線。 + +## asin(x) {#asinx} + +アークサイン。 + +## acos(x) {#acosx} + +アークコサイン。 + +## アタン(x) {#atanx} + +円弧正接。 + +## pow(x,y),power(x,y) {#powx-y-powerx-y} + +Yの累乗に近いFloat64の数値を返します。 + +## intExp2 {#intexp2} + +数値引数を受け取り、xの累乗に近いUInt64数値を返します。 + +## intExp10 {#intexp10} + +数値引数を受け取り、xの累乗に10に近いUInt64の数値を返します。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/ja/sql-reference/functions/other-functions.md b/docs/ja/sql-reference/functions/other-functions.md new file mode 100644 index 00000000000..31d799f35a4 --- /dev/null +++ b/docs/ja/sql-reference/functions/other-functions.md @@ -0,0 +1,1205 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 66 +toc_title: "\u305D\u306E\u4ED6" +--- + +# その他の機能 {#other-functions} + +## ホスト名() {#hostname} + +この関数が実行されたホストの名前を持つ文字列を返します。 分散処理の場合、関数がリモートサーバーで実行される場合、これはリモートサーバーホストの名前です。 + +## getMacro {#getmacro} + +から名前付きの値を取得します [マクロ](../../operations/server-configuration-parameters/settings.md#macros) サーバー構成のセクション。 + +**構文** + +``` sql +getMacro(name); +``` + +**パラメータ** + +- `name` — Name to retrieve from the `macros` セクション [文字列](../../sql-reference/data-types/string.md#string). + +**戻り値** + +- 指定されたマクロの値。 + +タイプ: [文字列](../../sql-reference/data-types/string.md). + +**例** + +例 `macros` サーバー設定ファイルのセクション: + +``` xml + + Value + +``` + +クエリ: + +``` sql +SELECT getMacro('test'); +``` + +結果: + +``` text +┌─getMacro('test')─┐ +│ Value │ +└──────────────────┘ +``` + +同じ値を取得する別の方法: + +``` sql +SELECT * FROM system.macros +WHERE macro = 'test'; +``` + +``` text +┌─macro─┬─substitution─┐ +│ test │ Value │ +└───────┴──────────────┘ +``` + +## FQDN {#fqdn} + +完全修飾ドメイン名を返します。 + +**構文** + +``` sql +fqdn(); +``` + +この関数は、大文字と小文字を区別しません。 + +**戻り値** + +- 完全修飾ドメイン名を持つ文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT FQDN(); +``` + +結果: + +``` text +┌─FQDN()──────────────────────────┐ +│ clickhouse.ru-central1.internal │ +└─────────────────────────────────┘ +``` + +## ベース名 {#basename} + +最後のスラッシュまたはバックスラッシュの後の文字列の末尾の部分を抽出します。 この関数は、パスからファイル名を抽出するためによく使用されます。 + +``` sql +basename( expr ) +``` + +**パラメータ** + +- `expr` — Expression resulting in a [文字列](../../sql-reference/data-types/string.md) タイプ値。 結果の値では、すべての円記号をエスケープする必要があります。 + +**戻り値** + +以下を含む文字列: + +- 最後のスラッシュまたはバックスラッシュの後の文字列の末尾の部分。 + + If the input string contains a path ending with slash or backslash, for example, `/` or `c:\`, the function returns an empty string. + +- スラッシュまたは円記号がない場合の元の文字列。 + +**例** + +``` sql +SELECT 'some/long/path/to/file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some\\long\\path\\to\\file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some-file-name' AS a, basename(a) +``` + +``` text +┌─a──────────────┬─basename('some-file-name')─┐ +│ some-file-name │ some-file-name │ +└────────────────┴────────────────────────────┘ +``` + +## visibleWidth(x) {#visiblewidthx} + +テキスト形式(タブ区切り)でコンソールに値を出力するときのおおよその幅を計算します。 +この関数は、システムがPretty形式を実装するために使用されます。 + +`NULL` に対応する文字列として表される。 `NULL` で `Pretty` フォーマット。 + +``` sql +SELECT visibleWidth(NULL) +``` + +``` text +┌─visibleWidth(NULL)─┐ +│ 4 │ +└────────────────────┘ +``` + +## トータイプ名(x) {#totypenamex} + +渡された引数の型名を含む文字列を返します。 + +もし `NULL` 関数に入力として渡されると、 `Nullable(Nothing)` 内部に対応する型 `NULL` ClickHouseでの表現。 + +## ブロックサイズ() {#function-blocksize} + +ブロックのサイズを取得します。 +ClickHouseでは、クエリは常にブロック(列部分のセット)で実行されます。 この関数では、呼び出したブロックのサイズを取得できます。 + +## マテリアライズ(x) {#materializex} + +定数を一つの値だけを含む完全な列に変換します。 +ClickHouseでは、完全な列と定数はメモリ内で異なって表されます。 関数は、定数引数と通常の引数(異なるコードが実行される)では異なる動作をしますが、結果はほとんど常に同じです。 この機能はデバッグするための + +## ignore(…) {#ignore} + +受け入れる引数を含む `NULL`. 常に0を返します。 +しかし、引数はまだ評価されています。 これはベンチマークに使用できます。 + +## スリープ(秒) {#sleepseconds} + +眠る ‘seconds’ 各データブロックの秒数。 整数または浮動小数点数を指定できます。 + +## sleepEachRow(秒) {#sleepeachrowseconds} + +眠る ‘seconds’ 各行の秒数。 整数または浮動小数点数を指定できます。 + +## currentDatabase() {#currentdatabase} + +現在のデータベースの名前を返します。 +この関数は、データベースを指定する必要があるCREATE TABLEクエリのテーブルエンジンパラメーターで使用できます。 + +## currentUser() {#other-function-currentuser} + +現在のユーザーのログインを返します。 ユーザーのログイン、その開始されたクエリは、distibutedクエリの場合に返されます。 + +``` sql +SELECT currentUser(); +``` + +別名: `user()`, `USER()`. + +**戻り値** + +- 現在のユーザーのログイン。 +- 分割されたクエリの場合にクエリを開始したユーザーのログイン。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT currentUser(); +``` + +結果: + +``` text +┌─currentUser()─┐ +│ default │ +└───────────────┘ +``` + +## isConstant {#is-constant} + +引数が定数式かどうかを確認します。 + +A constant expression means an expression whose resulting value is known at the query analysis (i.e. before execution). For example, expressions over [リテラル](../syntax.md#literals) は定数式です。 + +この機能は開発のアプリケーションのデバッグおよびデモンストレーション + +**構文** + +``` sql +isConstant(x) +``` + +**パラメータ** + +- `x` — Expression to check. + +**戻り値** + +- `1` — `x` 定数です。 +- `0` — `x` は定数ではありません。 + +タイプ: [UInt8](../data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT isConstant(x + 1) FROM (SELECT 43 AS x) +``` + +結果: + +``` text +┌─isConstant(plus(x, 1))─┐ +│ 1 │ +└────────────────────────┘ +``` + +クエリ: + +``` sql +WITH 3.14 AS pi SELECT isConstant(cos(pi)) +``` + +結果: + +``` text +┌─isConstant(cos(pi))─┐ +│ 1 │ +└─────────────────────┘ +``` + +クエリ: + +``` sql +SELECT isConstant(number) FROM numbers(1) +``` + +結果: + +``` text +┌─isConstant(number)─┐ +│ 0 │ +└────────────────────┘ +``` + +## isFinite(x) {#isfinitex} + +Float32とFloat64を受け入れ、引数が無限でなくNaNでない場合はUInt8を1、それ以外の場合は0を返します。 + +## イシンフィナイト(x) {#isinfinitex} + +Float32とFloat64を受け入れ、引数が無限の場合はUInt8を1、それ以外の場合は0を返します。 NaNの場合は0が返されることに注意してください。 + +## ifNotFinite {#ifnotfinite} + +浮動小数点値が有限かどうかをチェックします。 + +**構文** + + ifNotFinite(x,y) + +**パラメータ** + +- `x` — Value to be checked for infinity. Type: [フロート\*](../../sql-reference/data-types/float.md). +- `y` — Fallback value. Type: [フロート\*](../../sql-reference/data-types/float.md). + +**戻り値** + +- `x` もし `x` は有限である。 +- `y` もし `x` 有限ではない。 + +**例** + +クエリ: + + SELECT 1/0 as infimum, ifNotFinite(infimum,42) + +結果: + + ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ + │ inf │ 42 │ + └─────────┴───────────────────────────────┘ + +同様の結果を得るには、次のようにします [三項演算子](conditional-functions.md#ternary-operator): `isFinite(x) ? x : y`. + +## イスナン(x) {#isnanx} + +Float32とFloat64を受け入れ、引数がNaNの場合はUInt8が1、それ以外の場合は0を返します。 + +## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} + +データベース名、テーブル名、および列名の定数文字列を受け入れます。 列がある場合はUInt8定数式を1、それ以外の場合は0を返します。 Hostnameパラメータが設定されている場合、テストはリモートサーバーで実行されます。 +テーブルが存在しない場合、この関数は例外をスローします。 +入れ子になったデータ構造の要素の場合、関数は列の存在をチェックします。 入れ子になったデータ構造自体の場合、関数は0を返します。 + +## バー {#function-bar} + +Unicodeアート図を作成できます。 + +`bar(x, min, max, width)` 幅に比例したバンドを描画します `(x - min)` と等しい `width` ときの文字 `x = max`. + +パラメータ: + +- `x` — Size to display. +- `min, max` — Integer constants. The value must fit in `Int64`. +- `width` — Constant, positive integer, can be fractional. + +バンドは、シンボルの第八に正確に描かれています。 + +例: + +``` sql +SELECT + toHour(EventTime) AS h, + count() AS c, + bar(c, 0, 600000, 20) AS bar +FROM test.hits +GROUP BY h +ORDER BY h ASC +``` + +``` text +┌──h─┬──────c─┬─bar────────────────┐ +│ 0 │ 292907 │ █████████▋ │ +│ 1 │ 180563 │ ██████ │ +│ 2 │ 114861 │ ███▋ │ +│ 3 │ 85069 │ ██▋ │ +│ 4 │ 68543 │ ██▎ │ +│ 5 │ 78116 │ ██▌ │ +│ 6 │ 113474 │ ███▋ │ +│ 7 │ 170678 │ █████▋ │ +│ 8 │ 278380 │ █████████▎ │ +│ 9 │ 391053 │ █████████████ │ +│ 10 │ 457681 │ ███████████████▎ │ +│ 11 │ 493667 │ ████████████████▍ │ +│ 12 │ 509641 │ ████████████████▊ │ +│ 13 │ 522947 │ █████████████████▍ │ +│ 14 │ 539954 │ █████████████████▊ │ +│ 15 │ 528460 │ █████████████████▌ │ +│ 16 │ 539201 │ █████████████████▊ │ +│ 17 │ 523539 │ █████████████████▍ │ +│ 18 │ 506467 │ ████████████████▊ │ +│ 19 │ 520915 │ █████████████████▎ │ +│ 20 │ 521665 │ █████████████████▍ │ +│ 21 │ 542078 │ ██████████████████ │ +│ 22 │ 493642 │ ████████████████▍ │ +│ 23 │ 400397 │ █████████████▎ │ +└────┴────────┴────────────────────┘ +``` + +## 変換 {#transform} + +いくつかの要素と他の要素との明示的に定義されたマッピングに従って値を変換します。 +あーならではのバリエーション機能: + +### transform(x,array\_from,array\_to,デフォルト) {#transformx-array-from-array-to-default} + +`x` – What to transform. + +`array_from` – Constant array of values for converting. + +`array_to` – Constant array of values to convert the values in ‘from’ に。 + +`default` – Which value to use if ‘x’ の値のいずれとも等しくない。 ‘from’. + +`array_from` と `array_to` – Arrays of the same size. + +タイプ: + +`transform(T, Array(T), Array(U), U) -> U` + +`T` と `U` 数値、文字列、または日付またはDateTime型を指定できます。 +同じ文字が示されている場合(TまたはU)、数値型の場合、これらは一致する型ではなく、共通の型を持つ型である可能性があります。 +たとえば、最初の引数はInt64型で、二番目の引数は配列(UInt16)型です。 + +もし ‘x’ 値は、要素のいずれかに等しいです。 ‘array\_from’ これは、配列から既存の要素(つまり、同じ番号が付けられている)を返します。 ‘array\_to’ 配列 それ以外の場合は、 ‘default’. 複数の一致する要素がある場合 ‘array\_from’,一致するもののいずれかを返します。 + +例: + +``` sql +SELECT + transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, + count() AS c +FROM test.hits +WHERE SearchEngineID != 0 +GROUP BY title +ORDER BY c DESC +``` + +``` text +┌─title─────┬──────c─┐ +│ Yandex │ 498635 │ +│ Google │ 229872 │ +│ Other │ 104472 │ +└───────────┴────────┘ +``` + +### 変換(x,array\_from,array\_to) {#transformx-array-from-array-to} + +最初のバリエーションとは異なり、 ‘default’ 引数は省略される。 +もし ‘x’ 値は、要素のいずれかに等しいです。 ‘array\_from’ これは、配列から一致する要素(つまり、同じ番号が付けられている)を返します。 ‘array\_to’ 配列 それ以外の場合は、 ‘x’. + +タイプ: + +`transform(T, Array(T), Array(T)) -> T` + +例: + +``` sql +SELECT + transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, + count() AS c +FROM test.hits +GROUP BY domain(Referer) +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +┌─s──────────────┬───────c─┐ +│ │ 2906259 │ +│ www.yandex │ 867767 │ +│ ███████.ru │ 313599 │ +│ mail.yandex.ru │ 107147 │ +│ ██████.ru │ 100355 │ +│ █████████.ru │ 65040 │ +│ news.yandex.ru │ 64515 │ +│ ██████.net │ 59141 │ +│ example.com │ 57316 │ +└────────────────┴─────────┘ +``` + +## formatReadableSize(x) {#formatreadablesizex} + +サイズ(バイト数)を受け入れます。 サフィックス(kib、MiBなど)を持つ丸められたサイズを返します。)文字列として。 + +例: + +``` sql +SELECT + arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, + formatReadableSize(filesize_bytes) AS filesize +``` + +``` text +┌─filesize_bytes─┬─filesize───┐ +│ 1 │ 1.00 B │ +│ 1024 │ 1.00 KiB │ +│ 1048576 │ 1.00 MiB │ +│ 192851925 │ 183.92 MiB │ +└────────────────┴────────────┘ +``` + +## 最小(a,b) {#leasta-b} + +Aとbの最小値を返します。 + +## グレイテスト(a,b) {#greatesta-b} + +Aとbの最大値を返します。 + +## 稼働時間() {#uptime} + +サーバーの稼働時間を秒単位で返します。 + +## バージョン() {#version} + +サーバーのバージョンを文字列として返します。 + +## タイムゾーン() {#timezone} + +サーバーのタイムゾーンを返します。 + +## ブロックナンバー {#blocknumber} + +行があるデータブロックのシーケンス番号を返します。 + +## rowNumberInBlock {#function-rownumberinblock} + +データブロック内の行の序数を返します。 異なるデータブロックは常に再計算されます。 + +## ローナンバリンブロック() {#rownumberinallblocks} + +データブロック内の行の序数を返します。 この機能のみを考慮した影響のデータブロックとなります。 + +## 隣人 {#neighbor} + +指定された列の現在の行の前または後に来る指定されたオフセットの行へのアクセスを提供するウィンドウ関数。 + +**構文** + +``` sql +neighbor(column, offset[, default_value]) +``` + +関数の結果は、影響を受けるデータブロックとブロック内のデータの順序によって異なります。 +ORDER BYを使用してサブクエリを作成し、サブクエリの外部から関数を呼び出すと、期待される結果が得られます。 + +**パラメータ** + +- `column` — A column name or scalar expression. +- `offset` — The number of rows forwards or backwards from the current row of `column`. [Int64](../../sql-reference/data-types/int-uint.md). +- `default_value` — Optional. The value to be returned if offset goes beyond the scope of the block. Type of data blocks affected. + +**戻り値** + +- の値 `column` で `offset` 現在の行からの距離if `offset` 値がブロック境界外ではありません。 +- のデフォルト値 `column` もし `offset` 値はブロック境界外です。 もし `default_value` が与えられると、それが使用されます。 + +タイプ:タイプのデータブロックの影響を受けまたはデフォルト値タイプです。 + +**例** + +クエリ: + +``` sql +SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; +``` + +結果: + +``` text +┌─number─┬─neighbor(number, 2)─┐ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +│ 4 │ 6 │ +│ 5 │ 7 │ +│ 6 │ 8 │ +│ 7 │ 9 │ +│ 8 │ 0 │ +│ 9 │ 0 │ +└────────┴─────────────────────┘ +``` + +クエリ: + +``` sql +SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; +``` + +結果: + +``` text +┌─number─┬─neighbor(number, 2, 999)─┐ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +│ 4 │ 6 │ +│ 5 │ 7 │ +│ 6 │ 8 │ +│ 7 │ 9 │ +│ 8 │ 999 │ +│ 9 │ 999 │ +└────────┴──────────────────────────┘ +``` + +この関数を使用して、前年比メトリック値を計算できます: + +クエリ: + +``` sql +WITH toDate('2018-01-01') AS start_date +SELECT + toStartOfMonth(start_date + (number * 32)) AS month, + toInt32(month) % 100 AS money, + neighbor(money, -12) AS prev_year, + round(prev_year / money, 2) AS year_over_year +FROM numbers(16) +``` + +結果: + +``` text +┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ +│ 2018-01-01 │ 32 │ 0 │ 0 │ +│ 2018-02-01 │ 63 │ 0 │ 0 │ +│ 2018-03-01 │ 91 │ 0 │ 0 │ +│ 2018-04-01 │ 22 │ 0 │ 0 │ +│ 2018-05-01 │ 52 │ 0 │ 0 │ +│ 2018-06-01 │ 83 │ 0 │ 0 │ +│ 2018-07-01 │ 13 │ 0 │ 0 │ +│ 2018-08-01 │ 44 │ 0 │ 0 │ +│ 2018-09-01 │ 75 │ 0 │ 0 │ +│ 2018-10-01 │ 5 │ 0 │ 0 │ +│ 2018-11-01 │ 36 │ 0 │ 0 │ +│ 2018-12-01 │ 66 │ 0 │ 0 │ +│ 2019-01-01 │ 97 │ 32 │ 0.33 │ +│ 2019-02-01 │ 28 │ 63 │ 2.25 │ +│ 2019-03-01 │ 56 │ 91 │ 1.62 │ +│ 2019-04-01 │ 87 │ 22 │ 0.25 │ +└────────────┴───────┴───────────┴────────────────┘ +``` + +## runningDifference(x) {#other_functions-runningdifference} + +Calculates the difference between successive row values ​​in the data block. +最初の行には0を返し、後続の行ごとに前の行との差を返します。 + +関数の結果は、影響を受けるデータブロックとブロック内のデータの順序によって異なります。 +ORDER BYを使用してサブクエリを作成し、サブクエリの外部から関数を呼び出すと、期待される結果が得られます。 + +例: + +``` sql +SELECT + EventID, + EventTime, + runningDifference(EventTime) AS delta +FROM +( + SELECT + EventID, + EventTime + FROM events + WHERE EventDate = '2016-11-24' + ORDER BY EventTime ASC + LIMIT 5 +) +``` + +``` text +┌─EventID─┬───────────EventTime─┬─delta─┐ +│ 1106 │ 2016-11-24 00:00:04 │ 0 │ +│ 1107 │ 2016-11-24 00:00:05 │ 1 │ +│ 1108 │ 2016-11-24 00:00:05 │ 0 │ +│ 1109 │ 2016-11-24 00:00:09 │ 4 │ +│ 1110 │ 2016-11-24 00:00:10 │ 1 │ +└─────────┴─────────────────────┴───────┘ +``` + +注意-ブロックサイズは結果に影響します。 それぞれの新しいブロックでは、 `runningDifference` 状態がリセットされます。 + +``` sql +SELECT + number, + runningDifference(number + 1) AS diff +FROM numbers(100000) +WHERE diff != 1 +``` + +``` text +┌─number─┬─diff─┐ +│ 0 │ 0 │ +└────────┴──────┘ +┌─number─┬─diff─┐ +│ 65536 │ 0 │ +└────────┴──────┘ +``` + +``` sql +set max_block_size=100000 -- default value is 65536! + +SELECT + number, + runningDifference(number + 1) AS diff +FROM numbers(100000) +WHERE diff != 1 +``` + +``` text +┌─number─┬─diff─┐ +│ 0 │ 0 │ +└────────┴──────┘ +``` + +## runningDifferenceStartingWithFirstvalue {#runningdifferencestartingwithfirstvalue} + +同じように [runningDifference](./other-functions.md#other_functions-runningdifference)、差は、最初の行の値であり、最初の行の値を返し、後続の各行は、前の行からの差を返します。 + +## マクナムトストリング(num) {#macnumtostringnum} + +UInt64番号を受け入れます。 ビッグエンディアンのMACアドレスとして解釈します。 対応するMACアドレスを含む文字列をAA:BB:CC:DD:EE:FF(十六進形式のコロン区切りの数値)の形式で返します。 + +## マクストリングトナム(s) {#macstringtonums} + +MACNumToStringの逆関数。 MACアドレスの形式が無効な場合は、0を返します。 + +## マクストリングトゥーイ(s) {#macstringtoouis} + +AA:BB:CC:DD:EE:FF(十六進形式のコロン区切りの数字)の形式でMACアドレスを受け入れます。 Uint64番号として最初の三つのオクテットを返します。 MACアドレスの形式が無効な場合は、0を返します。 + +## getSizeOfEnumType {#getsizeofenumtype} + +フィールドの数を返します。 [Enum](../../sql-reference/data-types/enum.md). + +``` sql +getSizeOfEnumType(value) +``` + +**パラメータ:** + +- `value` — Value of type `Enum`. + +**戻り値** + +- フィールドの数 `Enum` 入力値。 +- 型が指定されていない場合、例外がスローされます `Enum`. + +**例** + +``` sql +SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## blockSerializedSize {#blockserializedsize} + +圧縮を考慮せずにディスク上のサイズを返します。 + +``` sql +blockSerializedSize(value[, value[, ...]]) +``` + +**パラメータ:** + +- `value` — Any value. + +**戻り値** + +- 値のブロック(圧縮なし)のためにディスクに書き込まれるバイト数。 + +**例** + +``` sql +SELECT blockSerializedSize(maxState(1)) as x +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## toColumnTypeName {#tocolumntypename} + +RAM内の列のデータ型を表すクラスの名前を返します。 + +``` sql +toColumnTypeName(value) +``` + +**パラメータ:** + +- `value` — Any type of value. + +**戻り値** + +- 表すために使用されるクラスの名前を持つ文字列 `value` RAMのデータ型。 + +**の違いの例`toTypeName ' and ' toColumnTypeName`** + +``` sql +SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) +``` + +``` text +┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ DateTime │ +└─────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) +``` + +``` text +┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ Const(UInt32) │ +└───────────────────────────────────────────────────────────┘ +``` + +この例では、 `DateTime` デー `Const(UInt32)`. + +## dumpColumnStructure {#dumpcolumnstructure} + +RAM内のデータ構造の詳細な説明を出力します + +``` sql +dumpColumnStructure(value) +``` + +**パラメータ:** + +- `value` — Any type of value. + +**戻り値** + +- 表すために使用される構造体を記述する文字列 `value` RAMのデータ型。 + +**例** + +``` sql +SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) +``` + +``` text +┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ DateTime, Const(size = 1, UInt32(size = 1)) │ +└──────────────────────────────────────────────────────────────┘ +``` + +## defaultValueOfArgumentType {#defaultvalueofargumenttype} + +データ型の既定値を出力します。 + +ユーザーが設定したカスタム列の既定値は含まれません。 + +``` sql +defaultValueOfArgumentType(expression) +``` + +**パラメータ:** + +- `expression` — Arbitrary type of value or an expression that results in a value of an arbitrary type. + +**戻り値** + +- `0` 数字のために。 +- 文字列の場合は空の文字列です。 +- `ᴺᵁᴸᴸ` のために [Null可能](../../sql-reference/data-types/nullable.md). + +**例** + +``` sql +SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) +``` + +``` text +┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ +│ 0 │ +└─────────────────────────────────────────────┘ +``` + +``` sql +SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) +``` + +``` text +┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ +│ ᴺᵁᴸᴸ │ +└───────────────────────────────────────────────────────┘ +``` + +## 複製 {#other-functions-replicate} + +単一の値を持つ配列を作成します。 + +内部実装のために使用される [アレイジョイン](array-join.md#functions_arrayjoin). + +``` sql +SELECT replicate(x, arr); +``` + +**パラメータ:** + +- `arr` — Original array. ClickHouse creates a new array of the same length as the original and fills it with the value `x`. +- `x` — The value that the resulting array will be filled with. + +**戻り値** + +値で満たされた配列 `x`. + +タイプ: `Array`. + +**例** + +クエリ: + +``` sql +SELECT replicate(1, ['a', 'b', 'c']) +``` + +結果: + +``` text +┌─replicate(1, ['a', 'b', 'c'])─┐ +│ [1,1,1] │ +└───────────────────────────────┘ +``` + +## filesystemAvailable {#filesystemavailable} + +返金額の残存スペースのファイルシステムのファイルのデータベースはあります。 これは、常に合計空き領域よりも小さいです ([filesystemFree](#filesystemfree))一部のスペースはOS用に予約されているため。 + +**構文** + +``` sql +filesystemAvailable() +``` + +**戻り値** + +- バイト単位で使用可能な残りの領域の量。 + +タイプ: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; +``` + +結果: + +``` text +┌─Available space─┬─Type───┐ +│ 30.75 GiB │ UInt64 │ +└─────────────────┴────────┘ +``` + +## filesystemFree {#filesystemfree} + +データベースのファイルがあるファイルシステム上の空き領域の合計量を返します。 も参照。 `filesystemAvailable` + +**構文** + +``` sql +filesystemFree() +``` + +**戻り値** + +- バイト単位の空き領域の量。 + +タイプ: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; +``` + +結果: + +``` text +┌─Free space─┬─Type───┐ +│ 32.39 GiB │ UInt64 │ +└────────────┴────────┘ +``` + +## filesystemCapacity {#filesystemcapacity} + +ファイルシステムの容量をバイト単位で返します。 評価のために、 [パス](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path) データディレ + +**構文** + +``` sql +filesystemCapacity() +``` + +**戻り値** + +- バイト単位のファイルシステムの容量情報。 + +タイプ: [UInt64](../../sql-reference/data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" +``` + +結果: + +``` text +┌─Capacity──┬─Type───┐ +│ 39.32 GiB │ UInt64 │ +└───────────┴────────┘ +``` + +## finalizeAggregation {#function-finalizeaggregation} + +集計関数の状態をとります。 集計結果(最終状態)を返します。 + +## runningAccumulate {#function-runningaccumulate} + +集計関数の状態を取り、値を持つ列を返し、最初から現在の行に、ブロック行のセットのためにこれらの状態の蓄積の結果です。 +たとえば、集計関数の状態をとり(例えばrunningAccumulate(uniqState(UserID)))、ブロックの各行に対して、すべての前の行と現在の行の状態のマージ時に集計関数の結果を返します。 +したがって、関数の結果は、データのブロックへの分割およびブロック内のデータの順序に依存する。 + +## joinGet {#joinget} + +この関数を使用すると、aと同じ方法でテーブルからデータを抽出できます [辞書](../../sql-reference/dictionaries/index.md). + +データの取得 [参加](../../engines/table-engines/special/join.md#creating-a-table) 指定された結合キーを使用するテーブル。 + +サポートするだけでなくテーブルで作成された `ENGINE = Join(ANY, LEFT, )` 声明。 + +**構文** + +``` sql +joinGet(join_storage_table_name, `value_column`, join_keys) +``` + +**パラメータ** + +- `join_storage_table_name` — an [識別子](../syntax.md#syntax-identifiers) 検索が実行される場所を示します。 識別子は既定のデータベースで検索されます(パラメーターを参照 `default_database` 設定ファイル内)。 デフォルトのデータベースを上書きするには `USE db_name` またはを指定しデータベースのテーブルのセパレータ `db_name.db_table`、例を参照。 +- `value_column` — name of the column of the table that contains required data. +- `join_keys` — list of keys. + +**戻り値** + +キーのリストに対応する値のリストを返します。 + +ソーステーブルに特定のものが存在しない場合、 `0` または `null` に基づいて返されます [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls) 設定。 + +詳細について `join_use_nulls` で [結合操作](../../engines/table-engines/special/join.md). + +**例** + +入力テーブル: + +``` sql +CREATE DATABASE db_test +CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 +INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) +``` + +``` text +┌─id─┬─val─┐ +│ 4 │ 13 │ +│ 2 │ 12 │ +│ 1 │ 11 │ +└────┴─────┘ +``` + +クエリ: + +``` sql +SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 +``` + +結果: + +``` text +┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ +│ 0 │ +│ 11 │ +│ 12 │ +│ 0 │ +└──────────────────────────────────────────────────┘ +``` + +## modelEvaluate(model\_name, …) {#function-modelevaluate} + +外部モデルの評価 +モデル名とモデル引数を受け取ります。 Float64を返します。 + +## throwIf(x\[,custom\_message\]) {#throwifx-custom-message} + +引数がゼロ以外の場合は例外をスローします。 +custom\_message-オプションのパラメータです。 + +``` sql +SELECT throwIf(number = 3, 'Too many') FROM numbers(10); +``` + +``` text +↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): +Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. +``` + +## id {#identity} + +引数として使用されたのと同じ値を返します。 インデックスを使用してキャンセルし、フルスキャンのクエリパフォーマンスを取得することができます。 クエリを分析してインデックスを使用する可能性がある場合、アナライザは内部を見ません `identity` 機能。 + +**構文** + +``` sql +identity(x) +``` + +**例** + +クエリ: + +``` sql +SELECT identity(42) +``` + +結果: + +``` text +┌─identity(42)─┐ +│ 42 │ +└──────────────┘ +``` + +## randomPrintableASCII {#randomascii} + +のランダムなセットを持つ文字列を生成します [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 印刷可能な文字。 + +**構文** + +``` sql +randomPrintableASCII(length) +``` + +**パラメータ** + +- `length` — Resulting string length. Positive integer. + + If you pass `length < 0`, behavior of the function is undefined. + +**戻り値** + +- のランダムなセットを持つ文字列 [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 印刷可能な文字。 + +タイプ: [文字列](../../sql-reference/data-types/string.md) + +**例** + +``` sql +SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 +``` + +``` text +┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ +│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ +│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ +│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ +└────────┴────────────────────────────────┴──────────────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/ja/sql-reference/functions/random-functions.md b/docs/ja/sql-reference/functions/random-functions.md new file mode 100644 index 00000000000..b976ed513ea --- /dev/null +++ b/docs/ja/sql-reference/functions/random-functions.md @@ -0,0 +1,65 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 51 +toc_title: "\u64EC\u4F3C\u4E71\u6570\u306E\u751F\u6210" +--- + +# 擬似乱数を生成するための関数 {#functions-for-generating-pseudo-random-numbers} + +擬似乱数の非暗号生成器が使用される。 + +全ての機能を受け入れゼロの引数または一つの引数。 +引数が渡された場合は、任意の型にすることができ、その値は何にも使用されません。 +この引数の唯一の目的は、同じ関数の二つの異なるインスタンスが異なる乱数を持つ異なる列を返すように、共通の部分式の除去を防ぐことです。 + +## ランド {#rand} + +すべてのUInt32型の数値に均等に分布する擬似ランダムなUInt32数値を返します。 +線形合同ジェネレータを使用します。 + +## rand64 {#rand64} + +すべてのUInt64型の数値に均等に分布する擬似ランダムなUInt64数値を返します。 +線形合同ジェネレータを使用します。 + +## ランドコンスタント {#randconstant} + +ランダムな値を持つ定数列を生成します。 + +**構文** + +``` sql +randConstant([x]) +``` + +**パラメータ** + +- `x` — [式](../syntax.md#syntax-expressions) の何れかに終って [対応するデータ型](../data-types/index.md#data_types). 結果の値は破棄されますが、式自体がバイパスに使用されている場合は破棄されます [共通の部分式の除去](index.md#common-subexpression-elimination) 関数が一つのクエリで複数回呼び出された場合。 任意パラメータ。 + +**戻り値** + +- 擬似乱数。 + +タイプ: [UInt32](../data-types/int-uint.md). + +**例** + +クエリ: + +``` sql +SELECT rand(), rand(1), rand(number), randConstant(), randConstant(1), randConstant(number) +FROM numbers(3) +``` + +結果: + +``` text +┌─────rand()─┬────rand(1)─┬─rand(number)─┬─randConstant()─┬─randConstant(1)─┬─randConstant(number)─┐ +│ 3047369878 │ 4132449925 │ 4044508545 │ 2740811946 │ 4229401477 │ 1924032898 │ +│ 2938880146 │ 1267722397 │ 4154983056 │ 2740811946 │ 4229401477 │ 1924032898 │ +│ 956619638 │ 4238287282 │ 1104342490 │ 2740811946 │ 4229401477 │ 1924032898 │ +└────────────┴────────────┴──────────────┴────────────────┴─────────────────┴──────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/ja/sql-reference/functions/rounding-functions.md b/docs/ja/sql-reference/functions/rounding-functions.md new file mode 100644 index 00000000000..d4f566e53f6 --- /dev/null +++ b/docs/ja/sql-reference/functions/rounding-functions.md @@ -0,0 +1,190 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u4E38\u3081" +--- + +# 丸め関数 {#rounding-functions} + +## フロア(x\[,N\]) {#floorx-n} + +以下の最大ラウンド数を返します `x`. ラウンド数は1/10Nの倍数、または1/10Nが正確でない場合は適切なデータ型の最も近い数値です。 +‘N’ 整数定数、オプションのパラメーターです。 これは整数に丸めることを意味します。 +‘N’ 負の場合があります。 + +例: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` + +`x` 任意の数値型です。 結果は同じ型の数です。 +整数引数の場合、負の値で丸めるのが理にかなっています `N` 値(負でない場合 `N`、関数は何もしません)。 +丸めによってオーバーフローが発生した場合(たとえば、floor(-128,-1))、実装固有の結果が返されます。 + +## ceil(x\[,N\]),ceiling(x\[,N\]) {#ceilx-n-ceilingx-n} + +以上の最小の丸め数を返します `x`. 他のすべての方法では、それはと同じです `floor` 関数(上記参照)。 + +## trunc(x\[,N\]),truncate(x\[,N\]) {#truncx-n-truncatex-n} + +絶対値が以下の最大絶対値を持つ丸め数を返します `x`‘s. In every other way, it is the same as the ’floor’ 関数(上記参照)。 + +## round(x\[,N\]) {#rounding_functions-round} + +指定した小数点以下の桁数に値を丸めます。 + +この関数は、指定された順序の最も近い番号を返します。 指定された数値が周囲の数値と等しい距離を持つ場合、この関数は浮動小数点数型に対してバンカーの丸めを使用し、他の数値型に対してはゼロから + +``` sql +round(expression [, decimal_places]) +``` + +**パラメータ:** + +- `expression` — A number to be rounded. Can be any [式](../syntax.md#syntax-expressions) 数値を返す [データ型](../../sql-reference/data-types/index.md#data_types). +- `decimal-places` — An integer value. + - もし `decimal-places > 0` 次に、関数は値を小数点の右側に丸めます。 + - もし `decimal-places < 0` 次に、この関数は値を小数点の左側に丸めます。 + - もし `decimal-places = 0` 次に、この関数は値を整数に丸めます。 この場合、引数は省略できます。 + +**戻り値:** + +入力番号と同じタイプの丸められた数値。 + +### 例 {#examples} + +**使用例** + +``` sql +SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 +``` + +``` text +┌───x─┬─round(divide(number, 2))─┐ +│ 0 │ 0 │ +│ 0.5 │ 0 │ +│ 1 │ 1 │ +└─────┴──────────────────────────┘ +``` + +**丸めの例** + +最も近い数値に丸めます。 + +``` text +round(3.2, 0) = 3 +round(4.1267, 2) = 4.13 +round(22,-1) = 20 +round(467,-2) = 500 +round(-467,-2) = -500 +``` + +バンカーの丸め。 + +``` text +round(3.5) = 4 +round(4.5) = 4 +round(3.55, 1) = 3.6 +round(3.65, 1) = 3.6 +``` + +**も参照。** + +- [ラウンドバンカー](#roundbankers) + +## ラウンドバンカー {#roundbankers} + +数値を指定した小数点以下の位置に丸めます。 + +- 丸め数が二つの数値の中間にある場合、関数は銀行家の丸めを使用します。 + + Banker's rounding is a method of rounding fractional numbers. When the rounding number is halfway between two numbers, it's rounded to the nearest even digit at the specified decimal position. For example: 3.5 rounds up to 4, 2.5 rounds down to 2. + + It's the default rounding method for floating point numbers defined in [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). The [round](#rounding_functions-round) function performs the same rounding for floating point numbers. The `roundBankers` function also rounds integers the same way, for example, `roundBankers(45, -1) = 40`. + +- それ以外の場合、関数は数値を最も近い整数に丸めます。 + +銀行家の丸めを使用すると、丸めの数値がこれらの数値の合計または減算の結果に与える影響を減らすことができます。 + +たとえば、丸めが異なる合計値1.5、2.5、3.5、4.5などです: + +- 丸めなし: 1.5 + 2.5 + 3.5 + 4.5 = 12. +- バンカーの丸め: 2 + 2 + 4 + 4 = 12. +- 最も近い整数への丸め: 2 + 3 + 4 + 5 = 14. + +**構文** + +``` sql +roundBankers(expression [, decimal_places]) +``` + +**パラメータ** + +- `expression` — A number to be rounded. Can be any [式](../syntax.md#syntax-expressions) 数値を返す [データ型](../../sql-reference/data-types/index.md#data_types). +- `decimal-places` — Decimal places. An integer number. + - `decimal-places > 0` — The function rounds the number to the given position right of the decimal point. Example: `roundBankers(3.55, 1) = 3.6`. + - `decimal-places < 0` — The function rounds the number to the given position left of the decimal point. Example: `roundBankers(24.55, -1) = 20`. + - `decimal-places = 0` — The function rounds the number to an integer. In this case the argument can be omitted. Example: `roundBankers(2.5) = 2`. + +**戻り値** + +バンカーの丸め法によって丸められた値。 + +### 例 {#examples-1} + +**使用例** + +クエリ: + +``` sql + SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 +``` + +結果: + +``` text +┌───x─┬─b─┐ +│ 0 │ 0 │ +│ 0.5 │ 0 │ +│ 1 │ 1 │ +│ 1.5 │ 2 │ +│ 2 │ 2 │ +│ 2.5 │ 2 │ +│ 3 │ 3 │ +│ 3.5 │ 4 │ +│ 4 │ 4 │ +│ 4.5 │ 4 │ +└─────┴───┘ +``` + +**銀行家の丸めの例** + +``` text +roundBankers(0.4) = 0 +roundBankers(-3.5) = -4 +roundBankers(4.5) = 4 +roundBankers(3.55, 1) = 3.6 +roundBankers(3.65, 1) = 3.6 +roundBankers(10.35, 1) = 10.4 +roundBankers(10.755, 2) = 11,76 +``` + +**も参照。** + +- [丸](#rounding_functions-round) + +## roundToExp2(num) {#roundtoexp2num} + +番号を受け入れます。 数値が一つより小さい場合は、0を返します。 それ以外の場合は、数値を最も近い(負でない全体の)次数まで切り捨てます。 + +## roundDuration(num) {#rounddurationnum} + +番号を受け入れます。 数値が一つより小さい場合は、0を返します。 それ以外の場合は、数値をセットの数値に切り捨てます: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. この機能はYandexに固有のものです。Metricaとセッションの長さに関するレポートの実装に使用されます。 + +## roundAge(num) {#roundagenum} + +番号を受け入れます。 数値が18未満の場合は、0を返します。 それ以外の場合は、数値をセットの数値に切り捨てます: 18, 25, 35, 45, 55. この機能はYandexに固有のものです。ユーザー年齢に関するレポートを実装するために使用されます。 + +## ラウンドダウン(num,arr) {#rounddownnum-arr} + +数値を受け取り、指定された配列内の要素に切り捨てます。 値が最低限界より小さい場合は、最低限界が返されます。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/ja/sql-reference/functions/splitting-merging-functions.md b/docs/ja/sql-reference/functions/splitting-merging-functions.md new file mode 100644 index 00000000000..5f95efc793e --- /dev/null +++ b/docs/ja/sql-reference/functions/splitting-merging-functions.md @@ -0,0 +1,117 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: "\u6587\u5B57\u5217\u3068\u914D\u5217\u306E\u5206\u5272\u3068\u30DE\u30FC\ + \u30B8" +--- + +# 文字列と配列を分割および結合するための関数 {#functions-for-splitting-and-merging-strings-and-arrays} + +## splitByChar(セパレーター、s) {#splitbycharseparator-s} + +文字列を、指定した文字で区切られた部分文字列に分割します。 定数文字列を使用します `separator` これは正確に一つの文字で構成されます。 +選択した部分文字列の配列を返します。 文字列の先頭または末尾に区切り文字がある場合、または複数の連続した区切り文字がある場合は、空の部分文字列を選択できます。 + +**構文** + +``` sql +splitByChar(, ) +``` + +**パラメータ** + +- `separator` — The separator which should contain exactly one character. [文字列](../../sql-reference/data-types/string.md). +- `s` — The string to split. [文字列](../../sql-reference/data-types/string.md). + +**戻り値)** + +選択した部分文字列の配列を返します。 空の部分文字列は、次の場合に選択できます: + +- 区切り文字は、文字列の先頭または末尾にあります; +- 複数の連続した区切り文字があります; +- 元の文字列 `s` 空です。 + +タイプ: [配列](../../sql-reference/data-types/array.md) の [文字列](../../sql-reference/data-types/string.md). + +**例** + +``` sql +SELECT splitByChar(',', '1,2,3,abcde') +``` + +``` text +┌─splitByChar(',', '1,2,3,abcde')─┐ +│ ['1','2','3','abcde'] │ +└─────────────────────────────────┘ +``` + +## splitByString(セパレーター、s) {#splitbystringseparator-s} + +文字列を文字列で区切られた部分文字列に分割します。 定数文字列を使用します `separator` 区切り文字として複数の文字を指定します。 文字列の場合 `separator` 空の場合は、文字列を分割します `s` 単一の文字の配列に。 + +**構文** + +``` sql +splitByString(, ) +``` + +**パラメータ** + +- `separator` — The separator. [文字列](../../sql-reference/data-types/string.md). +- `s` — The string to split. [文字列](../../sql-reference/data-types/string.md). + +**戻り値)** + +選択した部分文字列の配列を返します。 空の部分文字列は、次の場合に選択できます: + +タイプ: [配列](../../sql-reference/data-types/array.md) の [文字列](../../sql-reference/data-types/string.md). + +- 空でない区切り文字は、文字列の先頭または末尾にあります; +- 連続した空でない区切り文字が複数あります; +- 元の文字列 `s` 区切り文字が空でない間は空です。 + +**例** + +``` sql +SELECT splitByString(', ', '1, 2 3, 4,5, abcde') +``` + +``` text +┌─splitByString(', ', '1, 2 3, 4,5, abcde')─┐ +│ ['1','2 3','4,5','abcde'] │ +└───────────────────────────────────────────┘ +``` + +``` sql +SELECT splitByString('', 'abcde') +``` + +``` text +┌─splitByString('', 'abcde')─┐ +│ ['a','b','c','d','e'] │ +└────────────────────────────┘ +``` + +## arrayStringConcat(arr\[,区切り記号\]) {#arraystringconcatarr-separator} + +配列にリストされている文字列を区切り文字で連結します。'separator'はオプションのパラメータです:定数文字列で、デフォルトでは空の文字列に設定されます。 +文字列を返します。 + +## アルファトケンス(曖昧さ回避) {#alphatokenss} + +A-zおよびA-Zの範囲から連続したバイトの部分文字列を選択します。 + +**例** + +``` sql +SELECT alphaTokens('abca1abc') +``` + +``` text +┌─alphaTokens('abca1abc')─┐ +│ ['abca','abc'] │ +└─────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/ja/sql-reference/functions/string-functions.md b/docs/ja/sql-reference/functions/string-functions.md new file mode 100644 index 00000000000..87cdb186e52 --- /dev/null +++ b/docs/ja/sql-reference/functions/string-functions.md @@ -0,0 +1,489 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u6587\u5B57\u5217\u306E\u64CD\u4F5C" +--- + +# 文字列を操作するための関数 {#functions-for-working-with-strings} + +## 空 {#empty} + +空の文字列の場合は1、空でない文字列の場合は0を返します。 +結果の型はUInt8です。 +文字列が空白またはnullバイトであっても、少なくとも一つのバイトが含まれている場合、文字列は空ではないと見なされます。 +この関数は配列に対しても機能します。 + +## ノーテンプティ {#notempty} + +空の文字列の場合は0、空でない文字列の場合は1を返します。 +結果の型はUInt8です。 +この関数は配列に対しても機能します。 + +## 長さ {#length} + +文字列の長さをバイト単位で返します(文字ではなく、コードポイントではありません)。 +結果の型はUInt64です。 +この関数は配列に対しても機能します。 + +## lengthUTF8 {#lengthutf8} + +文字列にUTF-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、Unicodeコードポイント(文字ではない)で文字列の長さを返 この仮定が満たされない場合、結果が返されます(例外はスローされません)。 +結果の型はUInt64です。 + +## char\_length,CHAR\_LENGTH {#char-length} + +文字列にUTF-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、Unicodeコードポイント(文字ではない)で文字列の長さを返 この仮定が満たされない場合、結果が返されます(例外はスローされません)。 +結果の型はUInt64です。 + +## character\_length,CHARACTER\_LENGTH {#character-length} + +文字列にUTF-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、Unicodeコードポイント(文字ではない)で文字列の長さを返 この仮定が満たされない場合、結果が返されます(例外はスローされません)。 +結果の型はUInt64です。 + +## lower,lcase {#lower} + +文字列内のASCIIラテン文字記号を小文字に変換します。 + +## アッパー,ucase {#upper} + +文字列内のASCIIラテン文字記号を大文字に変換します。 + +## lowerUTF8 {#lowerutf8} + +文字列にUTF-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、文字列を小文字に変換します。 +それは言語を検出しません。 そのためにトルコに結果が正確に正しい。 +UTF-8バイト-シーケンスの長さがコード-ポイントの大文字と小文字で異なる場合、このコード-ポイントの結果が正しくない可能性があります。 +文字列にUTF-8以外のバイトセットが含まれている場合、動作は未定義です。 + +## upperUTF8 {#upperutf8} + +文字列にUTF-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、文字列を大文字に変換します。 +それは言語を検出しません。 そのためにトルコに結果が正確に正しい。 +UTF-8バイト-シーケンスの長さがコード-ポイントの大文字と小文字で異なる場合、このコード-ポイントの結果が正しくない可能性があります。 +文字列にUTF-8以外のバイトセットが含まれている場合、動作は未定義です。 + +## isValidUTF8 {#isvalidutf8} + +バイトセットが有効なUTF-8エンコードの場合は1を返し、それ以外の場合は0を返します。 + +## toValidUTF8 {#tovalidutf8} + +無効なUTF-8文字を `�` (U+FFFD)文字。 行で実行されているすべての無効な文字は、一つの置換文字に折りたたまれます。 + +``` sql +toValidUTF8( input_string ) +``` + +パラメータ: + +- input\_string — Any set of bytes represented as the [文字列](../../sql-reference/data-types/string.md) データ型オブジェクト。 + +戻り値:有効なUTF-8文字列。 + +**例** + +``` sql +SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') +``` + +``` text +┌─toValidUTF8('a����b')─┐ +│ a�b │ +└───────────────────────┘ +``` + +## 繰り返し {#repeat} + +指定した回数だけ文字列を繰り返し、複製された値を単一の文字列として連結します。 + +**構文** + +``` sql +repeat(s, n) +``` + +**パラメータ** + +- `s` — The string to repeat. [文字列](../../sql-reference/data-types/string.md). +- `n` — The number of times to repeat the string. [UInt](../../sql-reference/data-types/int-uint.md). + +**戻り値** + +文字列を含む単一の文字列 `s` 繰り返し `n` タイムズ もし `n` \<1、関数は空の文字列を返します。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT repeat('abc', 10) +``` + +結果: + +``` text +┌─repeat('abc', 10)──────────────┐ +│ abcabcabcabcabcabcabcabcabcabc │ +└────────────────────────────────┘ +``` + +## 逆 {#reverse} + +文字列を(バイトのシーケンスとして)反転します。 + +## reverseUTF8 {#reverseutf8} + +文字列にUTF-8テキストを表すバイトのセットが含まれていると仮定して、Unicodeコードポイントのシーケンスを反転します。 それ以外の場合は、何か他のことをします(例外はスローされません)。 + +## format(pattern, s0, s1, …) {#format} + +引数にリストされた文字列で定数パターンを書式設定します。 `pattern` 単純化されたPython形式のパターンです。 書式指定文字列 “replacement fields” 中括弧で囲む `{}`. 中かっこに含まれていないものはリテラルテキストと見なされ、そのまま出力にコピーされます。 リテラルテキストに中かっこ文字を含める必要がある場合は、倍にすることでエスケープできます: `{{ '{{' }}` と `{{ '}}' }}`. フィールド名には、数値(ゼロから始まる)または空(結果の数値として扱われます)を指定できます。 + +``` sql +SELECT format('{1} {0} {1}', 'World', 'Hello') +``` + +``` text +┌─format('{1} {0} {1}', 'World', 'Hello')─┐ +│ Hello World Hello │ +└─────────────────────────────────────────┘ +``` + +``` sql +SELECT format('{} {}', 'Hello', 'World') +``` + +``` text +┌─format('{} {}', 'Hello', 'World')─┐ +│ Hello World │ +└───────────────────────────────────┘ +``` + +## コンカ {#concat} + +引数にリストされている文字列を、区切り記号なしで連結します。 + +**構文** + +``` sql +concat(s1, s2, ...) +``` + +**パラメータ** + +String型またはFixedString型の値。 + +**戻り値** + +引数を連結した結果の文字列を返します。 + +引数値のいずれかが `NULL`, `concat` ツづゥツ。 `NULL`. + +**例** + +クエリ: + +``` sql +SELECT concat('Hello, ', 'World!') +``` + +結果: + +``` text +┌─concat('Hello, ', 'World!')─┐ +│ Hello, World! │ +└─────────────────────────────┘ +``` + +## concatAssumeInjective {#concatassumeinjective} + +同じ [コンカ](#concat) 違いは、次のことを確認する必要があるということです `concat(s1, s2, ...) → sn` はinjectiveであり、GROUP BYの最適化に使用されます。 + +関数の名前は次のとおりです “injective” 引数の異なる値に対して常に異なる結果を返す場合。 言い換えれば異なる引数のない利回り同一の結果です。 + +**構文** + +``` sql +concatAssumeInjective(s1, s2, ...) +``` + +**パラメータ** + +String型またはFixedString型の値。 + +**戻り値** + +引数を連結した結果の文字列を返します。 + +引数値のいずれかが `NULL`, `concatAssumeInjective` ツづゥツ。 `NULL`. + +**例** + +入力テーブル: + +``` sql +CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog; +INSERT INTO key_val VALUES ('Hello, ','World',1), ('Hello, ','World',2), ('Hello, ','World!',3), ('Hello',', World!',2); +SELECT * from key_val; +``` + +``` text +┌─key1────┬─key2─────┬─value─┐ +│ Hello, │ World │ 1 │ +│ Hello, │ World │ 2 │ +│ Hello, │ World! │ 3 │ +│ Hello │ , World! │ 2 │ +└─────────┴──────────┴───────┘ +``` + +クエリ: + +``` sql +SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY concatAssumeInjective(key1, key2) +``` + +結果: + +``` text +┌─concat(key1, key2)─┬─sum(value)─┐ +│ Hello, World! │ 3 │ +│ Hello, World! │ 2 │ +│ Hello, World │ 3 │ +└────────────────────┴────────────┘ +``` + +## substring(s,offset,length),mid(s,offset,length),substr(s,offset,length) {#substring} + +バイトで始まる部分文字列を返します。 ‘offset’ であるインデックス ‘length’ バイト長。 文字割り出し開始から一つとしての標準SQL). その ‘offset’ と ‘length’ 引数は定数である必要があります。 + +## substringUTF8(s,オフセット,長さ) {#substringutf8} + +と同じ ‘substring’ しかし、Unicodeコードポイントの場合。 作品は、この文字列が含まれるセットを表すバイトのUTF-8で符号化されます。 この仮定が満たされない場合、結果が返されます(例外はスローされません)。 + +## appendTrailingCharIfAbsent(s,c) {#appendtrailingcharifabsent} + +もし ‘s’ 文字列は空ではなく、 ‘c’ 最後に文字を追加します。 ‘c’ 最後に文字。 + +## convertCharset(s,from,to) {#convertcharset} + +文字列を返します ‘s’ それはで符号化から変換された ‘from’ のエンコーディングに ‘to’. + +## base64Encode(s) {#base64encode} + +エンコード ‘s’ base64への文字列 + +## base64Decode(s) {#base64decode} + +Base64エンコードされた文字列をデコード ‘s’ 元の文字列に。 障害が発生した場合には例外を発生させます。 + +## tryBase64Decode(s) {#trybase64decode} + +Base64Decodeに似ていますが、エラーの場合は空の文字列が返されます。 + +## endsWith(s,接尾辞) {#endswith} + +指定した接尾辞で終わるかどうかを返します。 文字列が指定された接尾辞で終わる場合は1を返し、それ以外の場合は0を返します。 + +## startsWith(str,プレフィックス) {#startswith} + +文字列が指定された接頭辞で始まるかどうかは1を返します。 + +``` sql +SELECT startsWith('Spider-Man', 'Spi'); +``` + +**戻り値** + +- 文字列が指定された接頭辞で始まる場合は、1。 +- 文字列が指定された接頭辞で始まらない場合は0。 + +**例** + +クエリ: + +``` sql +SELECT startsWith('Hello, world!', 'He'); +``` + +結果: + +``` text +┌─startsWith('Hello, world!', 'He')─┐ +│ 1 │ +└───────────────────────────────────┘ +``` + +## トリム {#trim} + +指定したすべての文字を文字列の先頭または末尾から削除します。 +デフォルトでは、文字列の両端から共通の空白(ASCII文字32)が連続して出現するすべてを削除します。 + +**構文** + +``` sql +trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) +``` + +**パラメータ** + +- `trim_character` — specified characters for trim. [文字列](../../sql-reference/data-types/string.md). +- `input_string` — string for trim. [文字列](../../sql-reference/data-types/string.md). + +**戻り値** + +先頭および(または)末尾に指定された文字を含まない文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT trim(BOTH ' ()' FROM '( Hello, world! )') +``` + +結果: + +``` text +┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ +│ Hello, world! │ +└───────────────────────────────────────────────┘ +``` + +## トリムレフト {#trimleft} + +文字列の先頭から連続して出現する共通の空白(ASCII文字32)をすべて削除します。 他の種類の空白文字(タブ、改行なしスペースなど)は削除されません。). + +**構文** + +``` sql +trimLeft(input_string) +``` + +別名: `ltrim(input_string)`. + +**パラメータ** + +- `input_string` — string to trim. [文字列](../../sql-reference/data-types/string.md). + +**戻り値** + +共通の空白の先頭を持たない文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT trimLeft(' Hello, world! ') +``` + +結果: + +``` text +┌─trimLeft(' Hello, world! ')─┐ +│ Hello, world! │ +└─────────────────────────────────────┘ +``` + +## トリムライト {#trimright} + +文字列の末尾から連続して出現するすべての共通空白(ASCII文字32)を削除します。 他の種類の空白文字(タブ、改行なしスペースなど)は削除されません。). + +**構文** + +``` sql +trimRight(input_string) +``` + +別名: `rtrim(input_string)`. + +**パラメータ** + +- `input_string` — string to trim. [文字列](../../sql-reference/data-types/string.md). + +**戻り値** + +共通の空白を末尾に付けない文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT trimRight(' Hello, world! ') +``` + +結果: + +``` text +┌─trimRight(' Hello, world! ')─┐ +│ Hello, world! │ +└──────────────────────────────────────┘ +``` + +## トリンボス {#trimboth} + +文字列の両端から共通の空白(ASCII文字32)が連続して出現するすべてを削除します。 他の種類の空白文字(タブ、改行なしスペースなど)は削除されません。). + +**構文** + +``` sql +trimBoth(input_string) +``` + +別名: `trim(input_string)`. + +**パラメータ** + +- `input_string` — string to trim. [文字列](../../sql-reference/data-types/string.md). + +**戻り値** + +共通の空白文字の先頭と末尾を持たない文字列。 + +タイプ: `String`. + +**例** + +クエリ: + +``` sql +SELECT trimBoth(' Hello, world! ') +``` + +結果: + +``` text +┌─trimBoth(' Hello, world! ')─┐ +│ Hello, world! │ +└─────────────────────────────────────┘ +``` + +## CRC32(s) {#crc32} + +CRC-32-IEEE802.3多項式と初期値を使用して、文字列のCRC32チェックサムを返します `0xffffffff` (zlibの実装)。 + +結果の型はUInt32です。 + +## CRC32IEEE(s) {#crc32ieee} + +CRC-32-IEEE802.3多項式を使用して、文字列のCRC32チェックサムを返します。 + +結果の型はUInt32です。 + +## CRC64(s) {#crc64} + +CRC-64-ECMA多項式を使用して、文字列のCRC64チェックサムを返します。 + +結果の型はUInt64です。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/ja/sql-reference/functions/string-replace-functions.md b/docs/ja/sql-reference/functions/string-replace-functions.md new file mode 100644 index 00000000000..ea1b9cb66cd --- /dev/null +++ b/docs/ja/sql-reference/functions/string-replace-functions.md @@ -0,0 +1,94 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u6587\u5B57\u5217\u3067\u7F6E\u63DB\u3059\u308B\u5834\u5408" +--- + +# 文字列の検索と置換のための関数 {#functions-for-searching-and-replacing-in-strings} + +## replaceOne(干し草、パターン、置換) {#replaceonehaystack-pattern-replacement} + +それが存在する場合は、最初の出現を置き換えます。 ‘pattern’ サブストリング ‘haystack’ と ‘replacement’ 部分文字列。 +以降, ‘pattern’ と ‘replacement’ 定数である必要があります。 + +## replaceAll(干し草,パターン,置換),replace(干し草,パターン,置換) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} + +すべての出現を置き換えます。 ‘pattern’ サブストリング ‘haystack’ と ‘replacement’ 部分文字列。 + +## replaceRegexpOne(干し草、パターン、置換) {#replaceregexponehaystack-pattern-replacement} + +を使用して交換 ‘pattern’ 正規表現。 Re2正規表現。 +存在する場合は、最初の出現のみを置き換えます。 +パターンは次のように指定できます ‘replacement’. このパター `\0-\9`. +置換 `\0` 正規表現全体を含みます。 置換 `\1-\9` サブパターンに対応するnumbers.To 使用する `\` テンプレー `\`. +また、文字列リテラルには余分なエスケープが必要です。 + +例1 日付をアメリカ形式に変換する: + +``` sql +SELECT DISTINCT + EventDate, + replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res +FROM test.hits +LIMIT 7 +FORMAT TabSeparated +``` + +``` text +2014-03-17 03/17/2014 +2014-03-18 03/18/2014 +2014-03-19 03/19/2014 +2014-03-20 03/20/2014 +2014-03-21 03/21/2014 +2014-03-22 03/22/2014 +2014-03-23 03/23/2014 +``` + +例2。 文字列を十回コピーする: + +``` sql +SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res +``` + +``` text +┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ +└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## replaceRegexpAll(干し草の山,パターン,置換) {#replaceregexpallhaystack-pattern-replacement} + +これは同じことを行いますが、すべての出現を置き換えます。 例: + +``` sql +SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res +``` + +``` text +┌─res────────────────────────┐ +│ HHeelllloo,, WWoorrlldd!! │ +└────────────────────────────┘ +``` + +例外として、正規表現が空の部分文字列に対して機能した場合、置換は複数回行われません。 +例: + +``` sql +SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res +``` + +``` text +┌─res─────────────────┐ +│ here: Hello, World! │ +└─────────────────────┘ +``` + +## regexpQuoteMeta(s) {#regexpquotemetas} + +関数は、文字列内のいくつかの定義済み文字の前に円記号を追加します。 +定義済み文字: ‘0’, ‘\\’, ‘\|’, ‘(’, ‘)’, ‘^’, ‘$’, ‘.’, ‘\[’, '\]', ‘?’, '\*‘,’+‘,’{‘,’:‘,’-'. +この実装はre2::RE2::QuoteMetaとは若干異なります。 ゼロバイトは00の代わりに\\0としてエスケープされ、必要な文字のみがエスケープされます。 +詳細は、リンクを参照してください: [RE2](https://github.com/google/re2/blob/master/re2/re2.cc#L473) + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/ja/sql-reference/functions/string-search-functions.md b/docs/ja/sql-reference/functions/string-search-functions.md new file mode 100644 index 00000000000..00f68c061dd --- /dev/null +++ b/docs/ja/sql-reference/functions/string-search-functions.md @@ -0,0 +1,379 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u6587\u5B57\u5217\u3092\u691C\u7D22\u3059\u308B\u5834\u5408" +--- + +# 文字列を検索する関数 {#functions-for-searching-strings} + +これらのすべての関数では、デフォルトで大文字と小文字が区別されます。 あるvariantのための大文字と小文字を区別しません。 + +## 位置(干し草の山、針)、位置(干し草の山、針) {#position} + +文字列内で見つかった部分文字列の位置(バイト単位)を1から始めて返します。 + +作品は、この文字列が含まれるセットを表すバイトの単一のバイトの符号化されます。 この仮定が満たされず、文字を単一バイトで表すことができない場合、関数は例外をスローせず、予期しない結果を返します。 文字を二つのバイトで表現できる場合は、二つのバイトなどを使用します。 + +大文字と小文字を区別しない検索では、次の関数を使用します [ポジションカースインセンティブ](#positioncaseinsensitive). + +**構文** + +``` sql +position(haystack, needle) +``` + +別名: `locate(haystack, needle)`. + +**パラメータ** + +- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). + +**戻り値** + +- 部分文字列が見つかった場合は、開始位置(1から数える)をバイト単位で指定します。 +- 部分文字列が見つからなかった場合は0。 + +タイプ: `Integer`. + +**例** + +フレーズ “Hello, world!” を含むの設定を表すバイトの単一のバイトの符号化されます。 この関数は、期待される結果を返します: + +クエリ: + +``` sql +SELECT position('Hello, world!', '!') +``` + +結果: + +``` text +┌─position('Hello, world!', '!')─┐ +│ 13 │ +└────────────────────────────────┘ +``` + +ロシア語の同じ句には、単一バイトで表現できない文字が含まれています。 この関数は予期しない結果を返します(使用 [positionUTF8](#positionutf8) マルチバイトエンコードテキストの関数): + +クエリ: + +``` sql +SELECT position('Привет, мир!', '!') +``` + +結果: + +``` text +┌─position('Привет, мир!', '!')─┐ +│ 21 │ +└───────────────────────────────┘ +``` + +## ポジションカースインセンティブ {#positioncaseinsensitive} + +と同じ [位置](#position) 文字列内で見つかった部分文字列の位置(バイト単位)を1から始めて返します。 大文字と小文字を区別しない検索には、この関数を使用します。 + +作品は、この文字列が含まれるセットを表すバイトの単一のバイトの符号化されます。 この仮定が満たされず、文字を単一バイトで表すことができない場合、関数は例外をスローせず、予期しない結果を返します。 文字を二つのバイトで表現できる場合は、二つのバイトなどを使用します。 + +**構文** + +``` sql +positionCaseInsensitive(haystack, needle) +``` + +**パラメータ** + +- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). + +**戻り値** + +- 部分文字列が見つかった場合は、開始位置(1から数える)をバイト単位で指定します。 +- 部分文字列が見つからなかった場合は0。 + +タイプ: `Integer`. + +**例** + +クエリ: + +``` sql +SELECT positionCaseInsensitive('Hello, world!', 'hello') +``` + +結果: + +``` text +┌─positionCaseInsensitive('Hello, world!', 'hello')─┐ +│ 1 │ +└───────────────────────────────────────────────────┘ +``` + +## positionUTF8 {#positionutf8} + +文字列内で見つかった部分文字列の位置(Unicodeポイント)を1から始めて返します。 + +作品は、この文字列が含まれるセットを表すバイトのUTF-8で符号化されます。 この仮定が満たされない場合、関数は例外をスローせず、予期しない結果を返します。 文字が二つのUnicodeポイントを使用して表すことができる場合、それはように二つを使用します。 + +大文字と小文字を区別しない検索では、次の関数を使用します [positionCaseInsensitiveUTF8](#positioncaseinsensitiveutf8). + +**構文** + +``` sql +positionUTF8(haystack, needle) +``` + +**パラメータ** + +- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). + +**戻り値** + +- 部分文字列が見つかった場合、Unicodeポイントの開始位置(1から数える)。 +- 部分文字列が見つからなかった場合は0。 + +タイプ: `Integer`. + +**例** + +フレーズ “Hello, world!” ロシア語のUnicodeのポイントを表すシングルポイントで符号化されます。 この関数は、期待される結果を返します: + +クエリ: + +``` sql +SELECT positionUTF8('Привет, мир!', '!') +``` + +結果: + +``` text +┌─positionUTF8('Привет, мир!', '!')─┐ +│ 12 │ +└───────────────────────────────────┘ +``` + +フレーズ “Salut, étudiante!”,ここで文字 `é` 一点を使って表現することができます (`U+00E9`)または二点 (`U+0065U+0301`)関数は予期しない結果を返すことができます: + +手紙のクエリ `é` これは一つのUnicodeポイントで表されます `U+00E9`: + +``` sql +SELECT positionUTF8('Salut, étudiante!', '!') +``` + +結果: + +``` text +┌─positionUTF8('Salut, étudiante!', '!')─┐ +│ 17 │ +└────────────────────────────────────────┘ +``` + +手紙のクエリ `é` これは二つのUnicodeポイントで表されます `U+0065U+0301`: + +``` sql +SELECT positionUTF8('Salut, étudiante!', '!') +``` + +結果: + +``` text +┌─positionUTF8('Salut, étudiante!', '!')─┐ +│ 18 │ +└────────────────────────────────────────┘ +``` + +## positionCaseInsensitiveUTF8 {#positioncaseinsensitiveutf8} + +と同じ [positionUTF8](#positionutf8) しかし、大文字と小文字は区別されません。 文字列内で見つかった部分文字列の位置(Unicodeポイント)を1から始めて返します。 + +作品は、この文字列が含まれるセットを表すバイトのUTF-8で符号化されます。 この仮定が満たされない場合、関数は例外をスローせず、予期しない結果を返します。 文字が二つのUnicodeポイントを使用して表すことができる場合、それはように二つを使用します。 + +**構文** + +``` sql +positionCaseInsensitiveUTF8(haystack, needle) +``` + +**パラメータ** + +- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). + +**戻り値** + +- 部分文字列が見つかった場合、Unicodeポイントの開始位置(1から数える)。 +- 部分文字列が見つからなかった場合は0。 + +タイプ: `Integer`. + +**例** + +クエリ: + +``` sql +SELECT positionCaseInsensitiveUTF8('Привет, мир!', 'Мир') +``` + +結果: + +``` text +┌─positionCaseInsensitiveUTF8('Привет, мир!', 'Мир')─┐ +│ 9 │ +└────────────────────────────────────────────────────┘ +``` + +## マルチサーチアルポジション {#multisearchallpositions} + +と同じ [位置](string-search-functions.md#position) しかし、戻り `Array` 文字列内で見つかった対応する部分文字列の位置(バイト単位)。 位置は1から始まる索引付けです。 + +の検索を行い、配列のバイトを尊重することなく文字列エンコーディングと照合。 + +- 大文字と小文字を区別しないASCII検索では、次の関数を使用します `multiSearchAllPositionsCaseInsensitive`. +- UTF-8で検索するには、次の関数を使用します [multiSearchAllPositionsUTF8](#multiSearchAllPositionsUTF8). +- 大文字と小文字を区別しないUTF-8検索では、関数multiSearchAllPositionsCaseInsensitiveutf8を使用します。 + +**構文** + +``` sql +multiSearchAllPositions(haystack, [needle1, needle2, ..., needlen]) +``` + +**パラメータ** + +- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). +- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). + +**戻り値** + +- 対応する部分文字列が見つかった場合は1から数えます。 + +**例** + +クエリ: + +``` sql +SELECT multiSearchAllPositions('Hello, World!', ['hello', '!', 'world']) +``` + +結果: + +``` text +┌─multiSearchAllPositions('Hello, World!', ['hello', '!', 'world'])─┐ +│ [0,13,0] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## multiSearchAllPositionsUTF8 {#multiSearchAllPositionsUTF8} + +見る `multiSearchAllPositions`. + +## マルチサーチファーストポジション(ヘイスタック、\[針1、針2, …, needlen\]) {#multisearchfirstposition} + +と同じ `position` しかし、文字列の左端のオフセットを返します `haystack` それは針のいくつかに一致します。 + +大文字と小文字を区別しない検索または/およびUTF-8形式の場合は、関数を使用します `multiSearchFirstPositionCaseInsensitive, multiSearchFirstPositionUTF8, multiSearchFirstPositionCaseInsensitiveUTF8`. + +## マルチサーチファーストインデックス(haystack,\[needle1、針2, …, needlen\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} + +インデックスを返す `i` 一番左にある針の1から始まります私は 文字列の中で `haystack` それ以外の場合は0です。 + +大文字と小文字を区別しない検索または/およびUTF-8形式の場合は、関数を使用します `multiSearchFirstIndexCaseInsensitive, multiSearchFirstIndexUTF8, multiSearchFirstIndexCaseInsensitiveUTF8`. + +## マルチサーチャニー(干し草、\[針1、針2, …, needlen\]) {#function-multisearchany} + +1を返します。私は 文字列と一致します `haystack` それ以外の場合は0です。 + +大文字と小文字を区別しない検索または/およびUTF-8形式の場合は、関数を使用します `multiSearchAnyCaseInsensitive, multiSearchAnyUTF8, multiSearchAnyCaseInsensitiveUTF8`. + +!!! note "注" + すべて `multiSearch*` 機能針の数は2よりより少しべきです8 実装仕様のため。 + +## マッチ(曖昧さ回避) {#matchhaystack-pattern} + +文字列が `pattern` 正規表現。 A `re2` 正規表現。 その [構文](https://github.com/google/re2/wiki/Syntax) の `re2` 正規表現は、Perl正規表現の構文よりも制限されています。 + +一致しない場合は0、一致する場合は1を返します。 + +バックスラッシュ記号は (`\`)は正規表現でのエスケープに使用されます。 文字列リテラルのエスケープには同じ記号が使用されます。 したがって、正規表現のシンボルをエスケープするには、文字列リテラルに二つの円記号(\\)を記述する必要があります。 + +正規表現は、文字列がバイトのセットであるかのように動作します。 正規表現にはnullバイトを含めることはできません。 +文字列内の部分文字列を検索するパターンの場合は、LIKEまたはを使用する方が良いです ‘position’ 彼らははるかに高速に動作するので。 + +## マルチマッチャニー(曖昧さ回避1,パターン2, …, patternn\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} + +と同じ `match` しかし、正規表現が一致しない場合は0を返し、パターンが一致する場合は1を返します。 それは使用します [hyperscan](https://github.com/intel/hyperscan) 図書館 パターンが文字列内の部分文字列を検索するには、以下を使用する方が良いです `multiSearchAny` それははるかに高速に動作するので。 + +!!! note "注" + のいずれかの長さ `haystack` 文字列は2未満でなければなりません32 それ以外の場合は例外がスローされます。 この制限はhyperscan APIのために行われます。 + +## multiMatchAnyIndex(ヘイスタック,\[パターン1,パターン2, …, patternn\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} + +と同じ `multiMatchAny` しかし、干し草の山に一致する任意のインデックスを返します。 + +## multiMatchAllIndices(干し草の山、\[パターン1,パターン2, …, patternn\]) {#multimatchallindiceshaystack-pattern1-pattern2-patternn} + +と同じ `multiMatchAny` しかし、干し草の山に一致するすべての指標の配列を任意の順序で返します。 + +## マルチフジマッチャニー(干し草、距離、\[パターン1,パターン2, …, patternn\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} + +と同じ `multiMatchAny` しかし、定数内の干し草に一致するパターンがあれば1を返します [距離を編集](https://en.wikipedia.org/wiki/Edit_distance). この機能は実験モードでもあり、非常に遅くなる可能性があります。 詳細については、 [hyperscanドキュメント](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching). + +## multiFuzzyMatchAnyIndex(干し草の山,距離,\[パターン1,パターン2, …, patternn\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} + +と同じ `multiFuzzyMatchAny` しかし、一定の編集距離内の干し草の山に一致するインデックスを返します。 + +## multiFuzzyMatchAllIndices(干し草の山,距離,\[パターン1,パターン2, …, patternn\]) {#multifuzzymatchallindiceshaystack-distance-pattern1-pattern2-patternn} + +と同じ `multiFuzzyMatchAny`,butは、一定の編集距離内の干し草の山に一致する任意の順序ですべてのインデックスの配列を返します。 + +!!! note "注" + `multiFuzzyMatch*` 関数はUTF-8正規表現をサポートしておらず、ハイパースキャンの制限によりこのような式はバイトとして扱われます。 + +!!! note "注" + Hyperscanを使用するすべての機能をオフにするには、設定を使用します `SET allow_hyperscan = 0;`. + +## 抽出(干し草、パターン) {#extracthaystack-pattern} + +正規表現を使用して文字列の断片を抽出します。 もし ‘haystack’ 一致しない ‘pattern’ 正規表現では、空の文字列が返されます。 正規表現にサブパターンが含まれていない場合は、正規表現全体に一致するフラグメントを取ります。 それ以外の場合は、最初のサブパターンに一致するフラグメントを取ります。 + +## extractAll(干し草の山、パターン) {#extractallhaystack-pattern} + +正規表現を使用して文字列のすべてのフラグメントを抽出します。 もし ‘haystack’ 一致しない ‘pattern’ 正規表現では、空の文字列が返されます。 正規表現に一致するすべての文字列からなる配列を返します。 一般に、動作は ‘extract’ 関数(最初のサブパターンを取り、サブパターンがない場合は式全体を取ります)。 + +## like(干し草の山,パターン),干し草の山のようなパターン演算子 {#function-like} + +文字列が単純な正規表現に一致するかどうかを確認します。 +正規表現には、メタシンボルを含めることができます `%` と `_`. + +`%` 任意のバイト数(ゼロ文字を含む)を示します。 + +`_` 任意のバイトを示します。 + +バックスラッシュを使用する (`\`)メタシンボルを脱出するため。 の説明のエスケープに関する注意を参照してください。 ‘match’ 機能。 + +次のような正規表現の場合 `%needle%` コードは、より最適であり、同じくらい速く動作します `position` 機能。 +他の正規表現の場合、コードは ‘match’ 機能。 + +## notLike(haystack,pattern),haystack NOT LIKE pattern演算子 {#function-notlike} + +同じことと ‘like’ しかし、否定的。 + +## グラムディスタンス(曖昧さ回避) {#ngramdistancehaystack-needle} + +間の4グラムの距離を計算します `haystack` と `needle`: counts the symmetric difference between two multisets of 4-grams and normalizes it by the sum of their cardinalities. Returns float number from 0 to 1 – the closer to zero, the more strings are similar to each other. If the constant `needle` または `haystack` 32Kbを超える場合は、例外をスローします。 非定数のいくつかの場合 `haystack` または `needle` 文字列は32Kbを超え、距離は常に一つです。 + +大文字と小文字を区別しない検索や、UTF-8形式の場合は関数を使用します `ngramDistanceCaseInsensitive, ngramDistanceUTF8, ngramDistanceCaseInsensitiveUTF8`. + +## グラムサーチ(曖昧さ回避) {#ngramsearchhaystack-needle} + +同じ `ngramDistance` しかし、の間の非対称差を計算します `needle` と `haystack` – the number of n-grams from needle minus the common number of n-grams normalized by the number of `needle` nグラム 近いほど、可能性が高くなります `needle` にある `haystack`. あいまい文字列検索に役立ちます。 + +大文字と小文字を区別しない検索や、UTF-8形式の場合は関数を使用します `ngramSearchCaseInsensitive, ngramSearchUTF8, ngramSearchCaseInsensitiveUTF8`. + +!!! note "注" + For UTF-8 case we use 3-gram distance. All these are not perfectly fair n-gram distances. We use 2-byte hashes to hash n-grams and then calculate the (non-)symmetric difference between these hash tables – collisions may occur. With UTF-8 case-insensitive format we do not use fair `tolower` function – we zero the 5-th bit (starting from zero) of each codepoint byte and first bit of zeroth byte if bytes more than one – this works for Latin and mostly for all Cyrillic letters. + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/ja/sql-reference/functions/type-conversion-functions.md b/docs/ja/sql-reference/functions/type-conversion-functions.md new file mode 100644 index 00000000000..447e36a58b5 --- /dev/null +++ b/docs/ja/sql-reference/functions/type-conversion-functions.md @@ -0,0 +1,534 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "\u30BF\u30A4\u30D7\u5909\u63DB" +--- + +# 型変換関数 {#type-conversion-functions} + +## 数値変換の一般的な問題 {#numeric-conversion-issues} + +あるデータ型から別のデータ型に値を変換する場合、一般的なケースでは、データ損失につながる危険な操作であることを覚えておく必要があります。 大きいデータ型から小さいデータ型に値を近似しようとする場合、または異なるデータ型間で値を変換する場合、データ損失が発生する可能性があります。 + +クリックハウスは [C++プログラムと同じ動作](https://en.cppreference.com/w/cpp/language/implicit_conversion). + +## トイント(8/16/32/64) {#toint8163264} + +入力値を [Int](../../sql-reference/data-types/int-uint.md) データ型。 この関数ファミ: + +- `toInt8(expr)` — Results in the `Int8` データ型。 +- `toInt16(expr)` — Results in the `Int16` データ型。 +- `toInt32(expr)` — Results in the `Int32` データ型。 +- `toInt64(expr)` — Results in the `Int64` データ型。 + +**パラメータ** + +- `expr` — [式](../syntax.md#syntax-expressions) 数値または数値の十進表現を持つ文字列を返します。 数値の二進表現、八進表現、進表現はサポートされていません。 先頭のゼロは削除されます。 + +**戻り値** + +の整数値 `Int8`, `Int16`, `Int32`,または `Int64` データ型。 + +関数の使用 [ゼロへの丸め](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) つまり、数字の小数部の数字を切り捨てます。 + +に対する関数の振る舞い [NaNおよびInf](../../sql-reference/data-types/float.md#data_type-float-nan-inf) 引数は未定義です。 覚えておいて [数値変換の問題](#numeric-conversion-issues)、関数を使用する場合。 + +**例** + +``` sql +SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) +``` + +``` text +┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ +│ -9223372036854775808 │ 32 │ 16 │ 8 │ +└──────────────────────┴─────────────┴───────────────┴─────────────┘ +``` + +## toInt(8/16/32/64)OrZero {#toint8163264orzero} + +String型の引数を取り、それをIntに解析しようとします(8 \| 16 \| 32 \| 64). 失敗した場合は0を返します。 + +**例** + +``` sql +select toInt64OrZero('123123'), toInt8OrZero('123qwe123') +``` + +``` text +┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ +│ 123123 │ 0 │ +└─────────────────────────┴───────────────────────────┘ +``` + +## toInt(8/16/32/64)OrNull {#toint8163264ornull} + +String型の引数を取り、それをIntに解析しようとします(8 \| 16 \| 32 \| 64). 失敗した場合はNULLを返します。 + +**例** + +``` sql +select toInt64OrNull('123123'), toInt8OrNull('123qwe123') +``` + +``` text +┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ +│ 123123 │ ᴺᵁᴸᴸ │ +└─────────────────────────┴───────────────────────────┘ +``` + +## トゥイント(8/16/32/64) {#touint8163264} + +入力値を [UInt](../../sql-reference/data-types/int-uint.md) データ型。 この関数ファミ: + +- `toUInt8(expr)` — Results in the `UInt8` データ型。 +- `toUInt16(expr)` — Results in the `UInt16` データ型。 +- `toUInt32(expr)` — Results in the `UInt32` データ型。 +- `toUInt64(expr)` — Results in the `UInt64` データ型。 + +**パラメータ** + +- `expr` — [式](../syntax.md#syntax-expressions) 数値または数値の十進表現を持つ文字列を返します。 数値の二進表現、八進表現、進表現はサポートされていません。 先頭のゼロは削除されます。 + +**戻り値** + +の整数値 `UInt8`, `UInt16`, `UInt32`,または `UInt64` データ型。 + +関数の使用 [ゼロへの丸め](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) つまり、数字の小数部の数字を切り捨てます。 + +負の関数に対する関数の振る舞いと [NaNおよびInf](../../sql-reference/data-types/float.md#data_type-float-nan-inf) 引数は未定義です。 負の数の文字列を渡すと、次のようになります `'-32'`,ClickHouseは例外を発生させます。 覚えておいて [数値変換の問題](#numeric-conversion-issues)、関数を使用する場合。 + +**例** + +``` sql +SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) +``` + +``` text +┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ +│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ +└─────────────────────┴───────────────┴────────────────┴──────────────┘ +``` + +## トゥイント(8/16/32/64)オルゼロ {#touint8163264orzero} + +## トゥイント(8/16/32/64)OrNull {#touint8163264ornull} + +## トフロア(32/64) {#tofloat3264} + +## toFloat(32/64)OrZero {#tofloat3264orzero} + +## toFloat(32/64)OrNull {#tofloat3264ornull} + +## 東立(とうだて {#todate} + +## トダテオルゼロ {#todateorzero} + +## toDateOrNull {#todateornull} + +## toDateTime {#todatetime} + +## トダティメオルゼロ {#todatetimeorzero} + +## toDateTimeOrNull {#todatetimeornull} + +## トデシマル(32/64/128) {#todecimal3264128} + +変換 `value` に [小数点](../../sql-reference/data-types/decimal.md) 精度の高いデータ型 `S`. その `value` 数値または文字列を指定できます。 その `S` (scale)パラメータは、小数点以下の桁数を指定します。 + +- `toDecimal32(value, S)` +- `toDecimal64(value, S)` +- `toDecimal128(value, S)` + +## toDecimal(32/64/128)OrNull {#todecimal3264128ornull} + +入力文字列をaに変換します [Nullable(Decimal(P,S)))](../../sql-reference/data-types/decimal.md) データ型の値。 このファミリの機能など: + +- `toDecimal32OrNull(expr, S)` — Results in `Nullable(Decimal32(S))` データ型。 +- `toDecimal64OrNull(expr, S)` — Results in `Nullable(Decimal64(S))` データ型。 +- `toDecimal128OrNull(expr, S)` — Results in `Nullable(Decimal128(S))` データ型。 + +これらの関数は、 `toDecimal*()` あなたが得ることを好むならば、関数 `NULL` 入力値の解析エラーが発生した場合の例外ではなく、値。 + +**パラメータ** + +- `expr` — [式](../syntax.md#syntax-expressions) の値を返します。 [文字列](../../sql-reference/data-types/string.md) データ型。 ClickHouseは、十進数のテキスト表現を想定しています。 例えば, `'1.111'`. +- `S` — Scale, the number of decimal places in the resulting value. + +**戻り値** + +の値 `Nullable(Decimal(P,S))` データ型。 この値を含む: + +- との数 `S` ClickHouseが入力文字列を数値として解釈する場合は、小数点以下の桁数。 +- `NULL`、ClickHouseが入力文字列を数値として解釈できない場合、または入力番号に以下のものが含まれている場合 `S` 小数点以下の桁数。 + +**例** + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ +│ -1.11100 │ Nullable(Decimal(9, 5)) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ +│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toDecimal(32/64/128)OrZero {#todecimal3264128orzero} + +入力値を [小数(P,S)](../../sql-reference/data-types/decimal.md) データ型。 このファミリの機能など: + +- `toDecimal32OrZero( expr, S)` — Results in `Decimal32(S)` データ型。 +- `toDecimal64OrZero( expr, S)` — Results in `Decimal64(S)` データ型。 +- `toDecimal128OrZero( expr, S)` — Results in `Decimal128(S)` データ型。 + +これらの関数は、 `toDecimal*()` あなたが得ることを好むならば、関数 `0` 入力値の解析エラーが発生した場合の例外ではなく、値。 + +**パラメータ** + +- `expr` — [式](../syntax.md#syntax-expressions) の値を返します。 [文字列](../../sql-reference/data-types/string.md) データ型。 ClickHouseは、十進数のテキスト表現を想定しています。 例えば, `'1.111'`. +- `S` — Scale, the number of decimal places in the resulting value. + +**戻り値** + +の値 `Nullable(Decimal(P,S))` データ型。 この値を含む: + +- との数 `S` ClickHouseが入力文字列を数値として解釈する場合は、小数点以下の桁数。 +- 0とともに `S` ClickHouseが入力文字列を数値として解釈できない場合、または入力番号に以下のものが含まれている場合は、小数点以下の桁数 `S` 小数点以下の桁数。 + +**例** + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ +│ -1.11100 │ Decimal(9, 5) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ +│ 0.00 │ Decimal(9, 2) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toString {#tostring} + +数値、文字列(ただし、固定文字列ではありません)、日付、および時刻を持つ日付の間で変換するための関数。 +これら全ての機能を受け入れを一つの引数。 + +文字列との間で変換する場合、値はTabSeparated形式(およびほとんどすべての他のテキスト形式)と同じ規則を使用して書式設定または解析されます。 文字列を解析できない場合は、例外がスローされ、要求がキャンセルされます。 + +日付を数値に変換する場合、またはその逆の場合、日付はUnixエポックの開始からの日数に対応します。 +時刻付きの日付を数値に変換する場合、またはその逆の場合、時刻付きの日付はUnixエポックの開始からの秒数に対応します。 + +ToDate/toDateTime関数の日付および日付と時刻の形式は、次のように定義されます: + +``` text +YYYY-MM-DD +YYYY-MM-DD hh:mm:ss +``` + +例外として、uint32、Int32、UInt64、またはInt64の数値型からDateに変換する場合、数値が65536以上の場合、数値はUnixタイムスタンプとして解釈され(日数ではなく)、日付 この支援のための共通の発生を書く ‘toDate(unix\_timestamp)’ それ以外の場合はエラーになり、より面倒な書き込みが必要になります ‘toDate(toDateTime(unix\_timestamp))’. + +日付と時刻の間の変換は、null時間を追加するか、時間を削除することによって、自然な方法で実行されます。 + +数値型間の変換では、C++の異なる数値型間の代入と同じ規則が使用されます。 + +さらに、DateTime引数のtoString関数は、タイムゾーンの名前を含む第二の文字列引数を取ることができます。 例: `Asia/Yekaterinburg` この場合、時刻は指定されたタイムゾーンに従って書式設定されます。 + +``` sql +SELECT + now() AS now_local, + toString(now(), 'Asia/Yekaterinburg') AS now_yekat +``` + +``` text +┌───────────now_local─┬─now_yekat───────────┐ +│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ +└─────────────────────┴─────────────────────┘ +``` + +また、 `toUnixTimestamp` 機能。 + +## toFixedString(s,N) {#tofixedstrings-n} + +文字列型の引数をFixedString(N)型(固定長Nの文字列)に変換します。 Nは定数でなければなりません。 +文字列のバイト数がNより少ない場合は、右側にnullバイトが埋め込まれます。 文字列のバイト数がNより多い場合は、例外がスローされます。 + +## トストリングカットゼロ(s) {#tostringcuttozeros} + +文字列またはFixedString引数を受け取ります。 見つかった最初のゼロバイトで切り捨てられた内容の文字列を返します。 + +例: + +``` sql +SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut +``` + +``` text +┌─s─────────────┬─s_cut─┐ +│ foo\0\0\0\0\0 │ foo │ +└───────────────┴───────┘ +``` + +``` sql +SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut +``` + +``` text +┌─s──────────┬─s_cut─┐ +│ foo\0bar\0 │ foo │ +└────────────┴───────┘ +``` + +## 再解釈(8/16/32/64) {#reinterpretasuint8163264} + +## 再解釈(8/16/32/64) {#reinterpretasint8163264} + +## reinterpretAsFloat(32/64) {#reinterpretasfloat3264} + +## 再解釈日 {#reinterpretasdate} + +## データの再解釈 {#reinterpretasdatetime} + +これらの関数は、文字列を受け入れ、文字列の先頭に置かれたバイトをホスト順(リトルエンディアン)の数値として解釈します。 文字列が十分な長さでない場合、関数は文字列がnullバイトの必要な数で埋め込まれているかのように動作します。 文字列が必要以上に長い場合、余分なバイトは無視されます。 日付はUnixエポックの開始からの日数として解釈され、時刻を持つ日付はUnixエポックの開始からの秒数として解釈されます。 + +## 再解釈 {#type_conversion_functions-reinterpretAsString} + +この関数は、数値または日付または日付と時刻を受け入れ、対応する値をホスト順(リトルエンディアン)で表すバイトを含む文字列を返します。 Nullバイトは末尾から削除されます。 たとえば、UInt32型の値255は、バイト長の文字列です。 + +## reinterpretAsFixedString {#reinterpretasfixedstring} + +この関数は、数値または日付または日付と時刻を受け取り、ホスト順(リトルエンディアン)で対応する値を表すバイトを含むFixedStringを返します。 Nullバイトは末尾から削除されます。 たとえば、UInt32型の値255は、バイト長のFixedStringです。 + +## キャスト(x,T) {#type_conversion_function-cast} + +変換 ‘x’ に ‘t’ データ型。 構文CAST(x AS t)もサポートされています。 + +例: + +``` sql +SELECT + '2016-06-15 23:00:00' AS timestamp, + CAST(timestamp AS DateTime) AS datetime, + CAST(timestamp AS Date) AS date, + CAST(timestamp, 'String') AS string, + CAST(timestamp, 'FixedString(22)') AS fixed_string +``` + +``` text +┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ +│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ +└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ +``` + +FixedString(N)への変換は、String型またはFixedString(N)型の引数に対してのみ機能します。 + +タイプ変換 [Null可能](../../sql-reference/data-types/nullable.md) そして背部は支えられる。 例: + +``` sql +SELECT toTypeName(x) FROM t_null +``` + +``` text +┌─toTypeName(x)─┐ +│ Int8 │ +│ Int8 │ +└───────────────┘ +``` + +``` sql +SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null +``` + +``` text +┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ +│ Nullable(UInt16) │ +│ Nullable(UInt16) │ +└─────────────────────────────────────────┘ +``` + +## toInterval(年/四半期\|月/週\|日\|時/分/秒) {#function-tointerval} + +数値型引数を [間隔](../../sql-reference/data-types/special-data-types/interval.md) データ型。 + +**構文** + +``` sql +toIntervalSecond(number) +toIntervalMinute(number) +toIntervalHour(number) +toIntervalDay(number) +toIntervalWeek(number) +toIntervalMonth(number) +toIntervalQuarter(number) +toIntervalYear(number) +``` + +**パラメータ** + +- `number` — Duration of interval. Positive integer number. + +**戻り値** + +- の値 `Interval` データ型。 + +**例** + +``` sql +WITH + toDate('2019-01-01') AS date, + INTERVAL 1 WEEK AS interval_week, + toIntervalWeek(1) AS interval_to_week +SELECT + date + interval_week, + date + interval_to_week +``` + +``` text +┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ +│ 2019-01-08 │ 2019-01-08 │ +└───────────────────────────┴──────────────────────────────┘ +``` + +## parseDateTimeBestEffort {#parsedatetimebesteffort} + +の日付と時刻を変換します。 [文字列](../../sql-reference/data-types/string.md) への表現 [DateTime](../../sql-reference/data-types/datetime.md#data_type-datetime) データ型。 + +関数は解析します [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC1123-5.2.14RFC-822日付と時刻の仕様](https://tools.ietf.org/html/rfc1123#page-55)、ClickHouseのといくつかの他の日付と時刻の形式。 + +**構文** + +``` sql +parseDateTimeBestEffort(time_string [, time_zone]); +``` + +**パラメータ** + +- `time_string` — String containing a date and time to convert. [文字列](../../sql-reference/data-types/string.md). +- `time_zone` — Time zone. The function parses `time_string` タイムゾーンによると。 [文字列](../../sql-reference/data-types/string.md). + +**サポートされている非標準形式** + +- 9を含む文字列。.10桁 [unixタイムスタン](https://en.wikipedia.org/wiki/Unix_time). +- 日付と時刻コンポーネントを持つ文字列: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss` など。 +- 日付を持つ文字列ですが、時刻コンポーネントはありません: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` 等。 +- 日付と時刻の文字列: `DD`, `DD hh`, `DD hh:mm`. この場合 `YYYY-MM` と置き換えられる。 `2000-01`. +- 日付と時刻とタイムゾーンのオフセット情報を含む文字列: `YYYY-MM-DD hh:mm:ss ±h:mm` など。 例えば, `2020-12-12 17:36:00 -5:00`. + +区切り文字を持つすべての形式について、関数は月名をフルネームまたは月名の最初の三文字で表したものを解析します。 例: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. + +**戻り値** + +- `time_string` に変換されます。 `DateTime` データ型。 + +**例** + +クエリ: + +``` sql +SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') +AS parseDateTimeBestEffort; +``` + +結果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2020-12-12 12:12:57 │ +└─────────────────────────┘ +``` + +クエリ: + +``` sql +SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') +AS parseDateTimeBestEffort +``` + +結果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-08-18 10:22:16 │ +└─────────────────────────┘ +``` + +クエリ: + +``` sql +SELECT parseDateTimeBestEffort('1284101485') +AS parseDateTimeBestEffort +``` + +結果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2015-07-07 12:04:41 │ +└─────────────────────────┘ +``` + +クエリ: + +``` sql +SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') +AS parseDateTimeBestEffort +``` + +結果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-12-12 10:12:12 │ +└─────────────────────────┘ +``` + +クエリ: + +``` sql +SELECT parseDateTimeBestEffort('10 20:19') +``` + +結果: + +``` text +┌─parseDateTimeBestEffort('10 20:19')─┐ +│ 2000-01-10 20:19:00 │ +└─────────────────────────────────────┘ +``` + +**も参照。** + +- \[ISO8601による発表 @xkcd\](https://xkcd.com/1179/) +- [RFC 1123](https://tools.ietf.org/html/rfc1123) +- [東立(とうだて](#todate) +- [toDateTime](#todatetime) + +## parseDateTimeBestEffortOrNull {#parsedatetimebesteffortornull} + +同じように [parseDateTimeBestEffort](#parsedatetimebesteffort) ただし、処理できない日付形式が検出されるとnullが返されます。 + +## parseDateTimeBestEffortOrZero {#parsedatetimebesteffortorzero} + +同じように [parseDateTimeBestEffort](#parsedatetimebesteffort) ただし、処理できない日付形式が検出されたときにゼロの日付またはゼロの日付時刻を返します。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/ja/sql-reference/functions/url-functions.md b/docs/ja/sql-reference/functions/url-functions.md new file mode 100644 index 00000000000..e263a95d56f --- /dev/null +++ b/docs/ja/sql-reference/functions/url-functions.md @@ -0,0 +1,209 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Url\u306E\u64CD\u4F5C" +--- + +# Urlを操作するための関数 {#functions-for-working-with-urls} + +これらの関数はすべてRFCに従っていません。 それらは改善された性能のために最大限に簡単にされる。 + +## URLの一部を抽出する関数 {#functions-that-extract-parts-of-a-url} + +関連する部分がURLにない場合は、空の文字列が返されます。 + +### プロトコル {#protocol} + +URLからプロトコルを抽出します。 + +Examples of typical returned values: http, https, ftp, mailto, tel, magnet… + +### ドメイン {#domain} + +URLからホスト名を抽出します。 + +``` sql +domain(url) +``` + +**パラメータ** + +- `url` — URL. Type: [文字列](../../sql-reference/data-types/string.md). + +URLは、スキームの有無にかかわらず指定できます。 例: + +``` text +svn+ssh://some.svn-hosting.com:80/repo/trunk +some.svn-hosting.com:80/repo/trunk +https://yandex.com/time/ +``` + +これらの例では、 `domain` 関数は、次の結果を返します: + +``` text +some.svn-hosting.com +some.svn-hosting.com +yandex.com +``` + +**戻り値** + +- ホスト名。 ClickHouseが入力文字列をURLとして解析できる場合。 +- 空の文字列。 ClickHouseが入力文字列をURLとして解析できない場合。 + +タイプ: `String`. + +**例** + +``` sql +SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') +``` + +``` text +┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ +│ some.svn-hosting.com │ +└────────────────────────────────────────────────────────┘ +``` + +### domainWithoutWWW {#domainwithoutwww} + +ドメインを返し、複数のドメインを削除しません ‘www.’ それの始めから、存在する場合。 + +### トップレベルドメイン {#topleveldomain} + +URLからトップレベルドメインを抽出します。 + +``` sql +topLevelDomain(url) +``` + +**パラメータ** + +- `url` — URL. Type: [文字列](../../sql-reference/data-types/string.md). + +URLは、スキームの有無にかかわらず指定できます。 例: + +``` text +svn+ssh://some.svn-hosting.com:80/repo/trunk +some.svn-hosting.com:80/repo/trunk +https://yandex.com/time/ +``` + +**戻り値** + +- ドメイン名。 ClickHouseが入力文字列をURLとして解析できる場合。 +- 空の文字列。 ClickHouseが入力文字列をURLとして解析できない場合。 + +タイプ: `String`. + +**例** + +``` sql +SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') +``` + +``` text +┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ +│ com │ +└────────────────────────────────────────────────────────────────────┘ +``` + +### firstSignificantSubdomain {#firstsignificantsubdomain} + +を返す。 “first significant subdomain”. これはYandexに固有の非標準的な概念です。メトリカ 最初の重要なサブドメインは、次の場合にセカンドレベルドメインです ‘com’, ‘net’, ‘org’,または ‘co’. それ以外の場合は、サードレベルドメインです。 例えば, `firstSignificantSubdomain (‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’`. のリスト “insignificant” セカンドレベルドメイ + +### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} + +トップレベルのサブドメインを含むドメインの一部を返します。 “first significant subdomain” (上記の説明を参照)。 + +例えば, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. + +### パス {#path} + +パスを返します。 例: `/top/news.html` パスにはクエリ文字列は含まれません。 + +### パスフル {#pathfull} + +上記と同じですが、クエリ文字列とフラグメントを含みます。 例:/top/news.html?ページ=2\#コメント + +### クエリ文字列 {#querystring} + +クエリ文字列を返します。 例:ページ=1&lr=213. query-stringには、最初の疑問符だけでなく、\#と\#の後のすべても含まれていません。 + +### 断片 {#fragment} + +フラグメント識別子を返します。 fragmentには初期ハッシュ記号は含まれません。 + +### queryStringAndFragment {#querystringandfragment} + +クエリ文字列とフラグメント識別子を返します。 例:ページ=1\#29390. + +### extractURLParameter(URL,名前) {#extracturlparameterurl-name} + +の値を返します。 ‘name’ URLにパラメータがある場合。 それ以外の場合は、空の文字列です。 この名前のパラメーターが多い場合は、最初に出現するパラメーターを返します。 この関数は、パラメータ名が渡された引数とまったく同じ方法でURLにエンコードされるという前提の下で機能します。 + +### extractURLParameters(URL) {#extracturlparametersurl} + +URLパラメーターに対応するname=value文字列の配列を返します。 値はどのような方法でもデコードされません。 + +### extractURLParameterNames(URL) {#extracturlparameternamesurl} + +URLパラメーターの名前に対応する名前文字列の配列を返します。 値はどのような方法でもデコードされません。 + +### URLHierarchy(URL) {#urlhierarchyurl} + +URLを含む配列を返します。 パスとクエリ文字列で。 連続セパレータ文字として数えます。 カットは、すべての連続した区切り文字の後の位置に行われます。 + +### URLPathHierarchy(URL) {#urlpathhierarchyurl} + +上記と同じですが、結果にプロトコルとホストはありません。 要素(ルート)は含まれません。 例:関数は、ツリーを実装するために使用されるYandexの中のURLを報告します。 メートル法 + +``` text +URLPathHierarchy('https://example.com/browse/CONV-6788') = +[ + '/browse/', + '/browse/CONV-6788' +] +``` + +### decodeURLComponent(URL) {#decodeurlcomponenturl} + +デコードしたURLを返します。 +例: + +``` sql +SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; +``` + +``` text +┌─DecodedURL─────────────────────────────┐ +│ http://127.0.0.1:8123/?query=SELECT 1; │ +└────────────────────────────────────────┘ +``` + +## URLの一部を削除する関数 {#functions-that-remove-part-of-a-url} + +URLに類似のものがない場合、URLは変更されません。 + +### cutWWW {#cutwww} + +複数を削除しません ‘www.’ URLのドメインの先頭から存在する場合。 + +### cutQueryString {#cutquerystring} + +クエリ文字列を削除します。 疑問符も削除されます。 + +### カットフラグメント {#cutfragment} + +フラグメント識別子を削除します。 番号記号も削除されます。 + +### cutQueryStringAndFragment {#cutquerystringandfragment} + +クエリ文字列とフラグメント識別子を削除します。 疑問符と番号記号も削除されます。 + +### cutURLParameter(URL,名前) {#cuturlparameterurl-name} + +を削除します。 ‘name’ URLパラメータが存在する場合。 この関数は、パラメータ名が渡された引数とまったく同じ方法でURLにエンコードされるという前提の下で機能します。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/ja/sql-reference/functions/uuid-functions.md b/docs/ja/sql-reference/functions/uuid-functions.md new file mode 100644 index 00000000000..138d54b4d84 --- /dev/null +++ b/docs/ja/sql-reference/functions/uuid-functions.md @@ -0,0 +1,122 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 53 +toc_title: "UUID\u306E\u64CD\u4F5C" +--- + +# UUIDを操作するための関数 {#functions-for-working-with-uuid} + +UUIDを操作するための関数を以下に示します。 + +## generateuidv4 {#uuid-function-generate} + +を生成する。 [UUID](../../sql-reference/data-types/uuid.md) の [バージョン4](https://tools.ietf.org/html/rfc4122#section-4.4). + +``` sql +generateUUIDv4() +``` + +**戻り値** + +UUID型の値。 + +**使用例** + +この例では、UUID型の列を持つテーブルを作成し、テーブルに値を挿入する方法を示します。 + +``` sql +CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog + +INSERT INTO t_uuid SELECT generateUUIDv4() + +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┐ +│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ +└──────────────────────────────────────┘ +``` + +## トウイド(x) {#touuid-x} + +文字列型の値をUUID型に変換します。 + +``` sql +toUUID(String) +``` + +**戻り値** + +UUID型の値。 + +**使用例** + +``` sql +SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid +``` + +``` text +┌─────────────────────────────────uuid─┐ +│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ +└──────────────────────────────────────┘ +``` + +## UUIDStringToNum {#uuidstringtonum} + +形式で36文字を含む文字列を受け入れます `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` これを、aのバイトセットとして返します [FixedString(16)](../../sql-reference/data-types/fixedstring.md). + +``` sql +UUIDStringToNum(String) +``` + +**戻り値** + +FixedString(16) + +**使用例** + +``` sql +SELECT + '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, + UUIDStringToNum(uuid) AS bytes +``` + +``` text +┌─uuid─────────────────────────────────┬─bytes────────────┐ +│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ +└──────────────────────────────────────┴──────────────────┘ +``` + +## UUIDNumToString {#uuidnumtostring} + +受け入れるa [FixedString(16)](../../sql-reference/data-types/fixedstring.md) テキスト形式で36文字を含む文字列を返します。 + +``` sql +UUIDNumToString(FixedString(16)) +``` + +**戻り値** + +文字列 + +**使用例** + +``` sql +SELECT + 'a/<@];!~p{jTj={)' AS bytes, + UUIDNumToString(toFixedString(bytes, 16)) AS uuid +``` + +``` text +┌─bytes────────────┬─uuid─────────────────────────────────┐ +│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ +└──────────────────┴──────────────────────────────────────┘ +``` + +## も参照。 {#see-also} + +- [dictGetUUID](ext-dict-functions.md#ext_dict_functions-other) + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/ja/sql-reference/functions/ym-dict-functions.md b/docs/ja/sql-reference/functions/ym-dict-functions.md new file mode 100644 index 00000000000..ce9ec860203 --- /dev/null +++ b/docs/ja/sql-reference/functions/ym-dict-functions.md @@ -0,0 +1,155 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: "Yandex\u3067\u306E\u4F5C\u696D\u3002\u30E1\u30C8\u30EA\u30AB\u8F9E\u66F8" +--- + +# Yandexで作業するための機能。メトリカ辞書 {#functions-for-working-with-yandex-metrica-dictionaries} + +以下の機能を機能させるには、サーバー設定ですべてのYandexを取得するためのパスとアドレスを指定する必要があります。メトリカ辞書。 辞書は、これらの関数の最初の呼び出し時に読み込まれます。 参照リストをロードできない場合は、例外がスローされます。 + +のための情報を参照リストの項をご参照ください “Dictionaries”. + +## 複数のジオベース {#multiple-geobases} + +ClickHouseは、特定の地域が属する国のさまざまな視点をサポートするために、複数の代替ジオベース(地域階層)を同時に使用することをサポートしています。 + +その ‘clickhouse-server’ configは、地域階層を持つファイルを指定します::`/opt/geo/regions_hierarchy.txt` + +このファイル以外にも、名前に\_記号と接尾辞が付加された近くのファイルも検索します(ファイル拡張子の前に)。 +たとえば、次のファイルも検索します `/opt/geo/regions_hierarchy_ua.txt`、存在する場合。 + +`ua` 辞書キーと呼ばれます。 接尾辞のない辞書の場合、キーは空の文字列です。 + +すべての辞書は実行時に再ロードされます(builtin\_dictionaries\_reload\_interval設定パラメータで定義されているように、一定の秒数ごとに、またはデフォルトでは時間に一度)。 ただし、使用可能な辞書のリストは、サーバーの起動時に一度に定義されます。 + +All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. +例: + +``` sql +regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt +regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt +regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt +``` + +### リージョントシティ(id\[,geobase\]) {#regiontocityid-geobase} + +Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. + +### レギオントアレア(id\[,geobase\]) {#regiontoareaid-geobase} + +領域を領域に変換します(ジオベースのタイプ5)。 他のすべての方法では、この関数は次のように同じです ‘regionToCity’. + +``` sql +SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + +``` text +┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ +│ │ +│ Moscow and Moscow region │ +│ St. Petersburg and Leningrad region │ +│ Belgorod region │ +│ Ivanovsk region │ +│ Kaluga region │ +│ Kostroma region │ +│ Kursk region │ +│ Lipetsk region │ +│ Orlov region │ +│ Ryazan region │ +│ Smolensk region │ +│ Tambov region │ +│ Tver region │ +│ Tula region │ +└──────────────────────────────────────────────────────┘ +``` + +### レジオントディストリクト(id\[,geobase\]) {#regiontodistrictid-geobase} + +地域を連邦区(ジオベースのタイプ4)に変換します。 他のすべての方法では、この関数は次のように同じです ‘regionToCity’. + +``` sql +SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + +``` text +┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ +│ │ +│ Central federal district │ +│ Northwest federal district │ +│ South federal district │ +│ North Caucases federal district │ +│ Privolga federal district │ +│ Ural federal district │ +│ Siberian federal district │ +│ Far East federal district │ +│ Scotland │ +│ Faroe Islands │ +│ Flemish region │ +│ Brussels capital region │ +│ Wallonia │ +│ Federation of Bosnia and Herzegovina │ +└──────────────────────────────────────────────────────────┘ +``` + +### regionToCountry(id\[,geobase\]) {#regiontocountryid-geobase} + +地域を国に変換します。 他のすべての方法では、この関数は次のように同じです ‘regionToCity’. +例: `regionToCountry(toUInt32(213)) = 225` モスクワ(213)をロシア(225)に変換します。 + +### レジオントコンテンツ(id\[,geobase\]) {#regiontocontinentid-geobase} + +地域を大陸に変換します。 他のすべての方法では、この関数は次のように同じです ‘regionToCity’. +例: `regionToContinent(toUInt32(213)) = 10001` モスクワ(213)をユーラシア(10001)に変換します。 + +### regionToTopContinent(\#regiontotopcontinent) {#regiontotopcontinent-regiontotopcontinent} + +リージョンの階層内で最も高い大陸を検索します。 + +**構文** + +``` sql +regionToTopContinent(id[, geobase]); +``` + +**パラメータ** + +- `id` — Region ID from the Yandex geobase. [UInt32](../../sql-reference/data-types/int-uint.md). +- `geobase` — Dictionary key. See [複数のジオベース](#multiple-geobases). [文字列](../../sql-reference/data-types/string.md). 任意。 + +**戻り値** + +- トップレベルの大陸の識別子(後者は地域の階層を登るとき)。 +- ない場合は0。 + +タイプ: `UInt32`. + +### リージョントポピュレーション(id\[,geobase\]) {#regiontopopulationid-geobase} + +地域の人口を取得します。 +母集団は、ジオベースを持つファイルに記録することができます。 セクションを参照 “External dictionaries”. +人口が地域に記録されていない場合は、0を返します。 +Yandexジオベースでは、子リージョンに対して母集団が記録されますが、親リージョンに対しては記録されません。 + +### レギオニン(lhs,rhs\[,geobase\]) {#regioninlhs-rhs-geobase} + +Aかどうかチェック ‘lhs’ 地域はaに属します ‘rhs’ 地域。 UInt8が属している場合は1、属していない場合は0を返します。 +The relationship is reflexive – any region also belongs to itself. + +### リージョンハイアーキテクチャ(id\[,geobase\]) {#regionhierarchyid-geobase} + +Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. +例: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. + +### レジオントナム(id\[,lang\]) {#regiontonameid-lang} + +Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn't exist, an empty string is returned. + +`ua` と `uk` もうクです。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/ja/sql-reference/index.md b/docs/ja/sql-reference/index.md new file mode 100644 index 00000000000..31d451b63a9 --- /dev/null +++ b/docs/ja/sql-reference/index.md @@ -0,0 +1,20 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "SQL\u30EA\u30D5\u30A1\u30EC\u30F3\u30B9" +toc_hidden: true +toc_priority: 28 +toc_title: "\u96A0\u3057" +--- + +# SQLリファレンス {#sql-reference} + +ClickHouseは次の種類のクエリをサポートします: + +- [SELECT](statements/select/index.md) +- [INSERT INTO](statements/insert-into.md) +- [CREATE](statements/create.md) +- [ALTER](statements/alter.md#query_language_queries_alter) +- [その他の種類のクエリ](statements/misc.md) + +[元の記事](https://clickhouse.tech/docs/en/sql-reference/) diff --git a/docs/ja/sql-reference/operators/in.md b/docs/ja/sql-reference/operators/in.md new file mode 120000 index 00000000000..3a2feda2f61 --- /dev/null +++ b/docs/ja/sql-reference/operators/in.md @@ -0,0 +1 @@ +../../../en/sql-reference/operators/in.md \ No newline at end of file diff --git a/docs/ja/sql-reference/operators/index.md b/docs/ja/sql-reference/operators/index.md new file mode 100644 index 00000000000..37be3231a6c --- /dev/null +++ b/docs/ja/sql-reference/operators/index.md @@ -0,0 +1,277 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u6F14\u7B97\u5B50" +--- + +# 演算子 {#operators} + +ClickHouseは、優先順位、優先順位、および連想に従って、クエリ解析段階で演算子を対応する関数に変換します。 + +## アクセス演算子 {#access-operators} + +`a[N]` – Access to an element of an array. The `arrayElement(a, N)` 機能。 + +`a.N` – Access to a tuple element. The `tupleElement(a, N)` 機能。 + +## 数値否定演算子 {#numeric-negation-operator} + +`-a` – The `negate (a)` 機能。 + +## 乗算演算子と除算演算子 {#multiplication-and-division-operators} + +`a * b` – The `multiply (a, b)` 機能。 + +`a / b` – The `divide(a, b)` 機能。 + +`a % b` – The `modulo(a, b)` 機能。 + +## 加算演算子と減算演算子 {#addition-and-subtraction-operators} + +`a + b` – The `plus(a, b)` 機能。 + +`a - b` – The `minus(a, b)` 機能。 + +## 比較演算子 {#comparison-operators} + +`a = b` – The `equals(a, b)` 機能。 + +`a == b` – The `equals(a, b)` 機能。 + +`a != b` – The `notEquals(a, b)` 機能。 + +`a <> b` – The `notEquals(a, b)` 機能。 + +`a <= b` – The `lessOrEquals(a, b)` 機能。 + +`a >= b` – The `greaterOrEquals(a, b)` 機能。 + +`a < b` – The `less(a, b)` 機能。 + +`a > b` – The `greater(a, b)` 機能。 + +`a LIKE s` – The `like(a, b)` 機能。 + +`a NOT LIKE s` – The `notLike(a, b)` 機能。 + +`a BETWEEN b AND c` – The same as `a >= b AND a <= c`. + +`a NOT BETWEEN b AND c` – The same as `a < b OR a > c`. + +## データセットを操作する演算子 {#operators-for-working-with-data-sets} + +*見る [演算子で](in.md).* + +`a IN ...` – The `in(a, b)` 機能。 + +`a NOT IN ...` – The `notIn(a, b)` 機能。 + +`a GLOBAL IN ...` – The `globalIn(a, b)` 機能。 + +`a GLOBAL NOT IN ...` – The `globalNotIn(a, b)` 機能。 + +## 日付と時刻を操作する演算子 {#operators-datetime} + +### EXTRACT {#operator-extract} + +``` sql +EXTRACT(part FROM date); +``` + +特定の日付から部品を抽出します。 たとえば、特定の日付から月、または時間から秒を取得できます。 + +その `part` パラメータ取得する日付のどの部分を指定します。 使用可能な値は次のとおりです: + +- `DAY` — The day of the month. Possible values: 1–31. +- `MONTH` — The number of a month. Possible values: 1–12. +- `YEAR` — The year. +- `SECOND` — The second. Possible values: 0–59. +- `MINUTE` — The minute. Possible values: 0–59. +- `HOUR` — The hour. Possible values: 0–23. + +その `part` パラメータは大文字と小文字を区別する. + +その `date` パラメータ処理する日付または時刻を指定します。 どちらか [日付](../../sql-reference/data-types/date.md) または [DateTime](../../sql-reference/data-types/datetime.md) タイプに対応しています。 + +例: + +``` sql +SELECT EXTRACT(DAY FROM toDate('2017-06-15')); +SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); +SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); +``` + +次の例では、テーブルを作成し、そこに値を挿入します `DateTime` タイプ。 + +``` sql +CREATE TABLE test.Orders +( + OrderId UInt64, + OrderName String, + OrderDate DateTime +) +ENGINE = Log; +``` + +``` sql +INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); +``` + +``` sql +SELECT + toYear(OrderDate) AS OrderYear, + toMonth(OrderDate) AS OrderMonth, + toDayOfMonth(OrderDate) AS OrderDay, + toHour(OrderDate) AS OrderHour, + toMinute(OrderDate) AS OrderMinute, + toSecond(OrderDate) AS OrderSecond +FROM test.Orders; +``` + +``` text +┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ +│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ +└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ +``` + +以下の例を見ることができます [テスト](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). + +### INTERVAL {#operator-interval} + +を作成します。 [間隔](../../sql-reference/data-types/special-data-types/interval.md)-算術演算で使用されるべき型の値 [日付](../../sql-reference/data-types/date.md) と [DateTime](../../sql-reference/data-types/datetime.md)-値を入力します。 + +間隔のタイプ: +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +!!! warning "警告" + 異なるタイプの間隔は結合できません。 次のような式は使用できません `INTERVAL 4 DAY 1 HOUR`. 間隔は、間隔の最小単位より小さい単位または等しい単位で指定します。, `INTERVAL 25 HOUR`. 次の例のように、連続した操作を使用できます。 + +例: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +**も参照。** + +- [間隔](../../sql-reference/data-types/special-data-types/interval.md) データ型 +- [toInterval](../../sql-reference/functions/type-conversion-functions.md#function-tointerval) 型変換関数 + +## 論理否定演算子 {#logical-negation-operator} + +`NOT a` – The `not(a)` 機能。 + +## 論理And演算子 {#logical-and-operator} + +`a AND b` – The`and(a, b)` 機能。 + +## 論理OR演算子 {#logical-or-operator} + +`a OR b` – The `or(a, b)` 機能。 + +## 条件演算子 {#conditional-operator} + +`a ? b : c` – The `if(a, b, c)` 機能。 + +注: + +条件演算子は、bとcの値を計算し、条件aが満たされているかどうかをチェックし、対応する値を返します。 もし `b` または `C` は [アレイジョイン()](../../sql-reference/functions/array-join.md#functions_arrayjoin) 関数は、各行は関係なく、レプリケートされます “a” 条件だ + +## 条件式 {#operator_case} + +``` sql +CASE [x] + WHEN a THEN b + [WHEN ... THEN ...] + [ELSE c] +END +``` + +もし `x` が指定される。 `transform(x, [a, ...], [b, ...], c)` function is used. Otherwise – `multiIf(a, b, ..., c)`. + +がない場合 `ELSE c` 句式のデフォルト値は次のとおりです `NULL`. + +その `transform` 関数は動作しません `NULL`. + +## 連結演算子 {#concatenation-operator} + +`s1 || s2` – The `concat(s1, s2) function.` + +## ラムダ作成演算子 {#lambda-creation-operator} + +`x -> expr` – The `lambda(x, expr) function.` + +次の演算子は角かっこであるため、優先順位はありません: + +## 配列作成演算子 {#array-creation-operator} + +`[x1, ...]` – The `array(x1, ...) function.` + +## タプル作成演算子 {#tuple-creation-operator} + +`(x1, x2, ...)` – The `tuple(x2, x2, ...) function.` + +## 連想性 {#associativity} + +すべての二項演算子は連想性を残しています。 例えば, `1 + 2 + 3` に変換されます `plus(plus(1, 2), 3)`. +時にはこれはあなたが期待するように動作しません。 例えば, `SELECT 4 > 2 > 3` 結果は0になります。 + +効率のために、 `and` と `or` 関数は任意の数の引数を受け入れます。 の対応する鎖 `AND` と `OR` 演算子は、これらの関数の単一の呼び出しに変換されます。 + +## チェック `NULL` {#checking-for-null} + +クリックハウスは `IS NULL` と `IS NOT NULL` 演算子。 + +### IS NULL {#operator-is-null} + +- のために [Null可能](../../sql-reference/data-types/nullable.md) 型の値は、 `IS NULL` 演算子の戻り値: + - `1` 値が `NULL`. + - `0` そうでなければ +- その他の値については、 `IS NULL` 演算子は常に返します `0`. + + + +``` sql +SELECT x+100 FROM t_null WHERE y IS NULL +``` + +``` text +┌─plus(x, 100)─┐ +│ 101 │ +└──────────────┘ +``` + +### IS NOT NULL {#is-not-null} + +- のために [Null可能](../../sql-reference/data-types/nullable.md) 型の値は、 `IS NOT NULL` 演算子の戻り値: + - `0` 値が `NULL`. + - `1` そうでなければ +- その他の値については、 `IS NOT NULL` 演算子は常に返します `1`. + + + +``` sql +SELECT * FROM t_null WHERE y IS NOT NULL +``` + +``` text +┌─x─┬─y─┐ +│ 2 │ 3 │ +└───┴───┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/ja/sql-reference/statements/alter.md b/docs/ja/sql-reference/statements/alter.md new file mode 100644 index 00000000000..c5f3655411a --- /dev/null +++ b/docs/ja/sql-reference/statements/alter.md @@ -0,0 +1,602 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: ALTER +--- + +## ALTER {#query_language_queries_alter} + +その `ALTER` クエリーのみ対応して `*MergeTree` テーブルだけでなく、 `Merge`と`Distributed`. クエリに複数のバリエーションがあります。 + +### 列の操作 {#column-manipulations} + +テーブル構造の変更。 + +``` sql +ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... +``` + +クエリでは、コンマ区切りのアクションのリストを指定します。 +各アクションは、列に対する操作です。 + +次の操作がサポートされます: + +- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. +- [DROP COLUMN](#alter_drop-column) — Deletes the column. +- [CLEAR COLUMN](#alter_clear-column) — Resets column values. +- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. +- [MODIFY COLUMN](#alter_modify-column) — Changes column's type, default expression and TTL. + +これらの行動を詳細に説明します。 + +#### ADD COLUMN {#alter_add-column} + +``` sql +ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] +``` + +指定されたテーブルに新しい列を追加します `name`, `type`, [`codec`](create.md#codecs) と `default_expr` (節を参照 [既定の式](create.md#create-default-values)). + +もし `IF NOT EXISTS` 列が既に存在する場合、クエリはエラーを返しません。 指定した場合 `AFTER name_after` (別の列の名前)、列は表の列のリスト内で指定された列の後に追加されます。 それ以外の場合は、列がテーブルの最後に追加されます。 テーブルの先頭に列を追加する方法はないことに注意してください。 一連の行動のために, `name_after` 前の操作のいずれかで追加された列の名前を指定できます。 + +列を追加すると、データでアクションを実行せずにテーブル構造が変更されます。 その後、データはディスクに表示されません `ALTER`. テーブルから読み取るときに列のデータがない場合は、デフォルト値が入力されます(デフォルトの式がある場合はデフォルトの式を実行するか、ゼロ 列の表示のディスクと統合データ部品( [メルゲツリー](../../engines/table-engines/mergetree-family/mergetree.md)). + +このアプローチにより、 `ALTER` 古いデータの量を増やすことなく、瞬時にクエリ。 + +例: + +``` sql +ALTER TABLE visits ADD COLUMN browser String AFTER user_id +``` + +#### DROP COLUMN {#alter_drop-column} + +``` sql +DROP COLUMN [IF EXISTS] name +``` + +名前の列を削除します `name`. もし `IF EXISTS` 列が存在しない場合、クエリはエラーを返しません。 + +コンピュータのデータを削除するファイルシステム。 この削除全ファイル、クエリーがほぼ完了します。 + +例: + +``` sql +ALTER TABLE visits DROP COLUMN browser +``` + +#### CLEAR COLUMN {#alter_clear-column} + +``` sql +CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name +``` + +すべてリセットデータ列の指定されたパーティション セクションのパーティション名の設定の詳細を読む [パーティション式の指定方法](#alter-how-to-specify-part-expr). + +もし `IF EXISTS` 列が存在しない場合、クエリはエラーを返しません。 + +例: + +``` sql +ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() +``` + +#### COMMENT COLUMN {#alter_comment-column} + +``` sql +COMMENT COLUMN [IF EXISTS] name 'comment' +``` + +列にコメントを追加します。 もし `IF EXISTS` 列が存在しない場合、クエリはエラーを返しません。 + +各列には一つのコメントがあります。 列にコメントが既に存在する場合、新しいコメントは前のコメントを上書きします。 + +コメントは `comment_expression` によって返される列 [DESCRIBE TABLE](misc.md#misc-describe-table) クエリ。 + +例: + +``` sql +ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' +``` + +#### MODIFY COLUMN {#alter_modify-column} + +``` sql +MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] +``` + +このクエリは、 `name` 列のプロパティ: + +- タイプ + +- 既定の式 + +- TTL + + For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). + +もし `IF EXISTS` 列が存在しない場合、クエリはエラーを返しません。 + +型を変更するとき、値は次のように変換されます [トタイプ](../../sql-reference/functions/type-conversion-functions.md) 機能をそれらに適用した。 既定の式のみが変更された場合、クエリは複雑な処理を行わず、ほぼ即座に完了します。 + +例: + +``` sql +ALTER TABLE visits MODIFY COLUMN browser Array(String) +``` + +Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. + +いくつかの処理段階があります: + +- 準備一時(新しいファイルが修正データです。 +- 古いファイルの名前を変更する。 +- 一時(新しい)ファイルの名前を古い名前に変更します。 +- 古いファイルを削除します。 + +最初の段階だけ時間がかかります。 この段階で障害が発生した場合、データは変更されません。 +連続するいずれかの段階で障害が発生した場合、データを手動で復元することができます。 例外は、古いファイルがファイルシステムから削除されたが、新しいファイルのデータがディスクに書き込まれず、失われた場合です。 + +その `ALTER` 列を変更するクエリが複製されます。 命令はZooKeeperに保存され、各レプリカはそれらを適用します。 すべて `ALTER` クエリは同じ順序で実行されます。 クエリは、他のレプリカで適切なアクションが完了するのを待機します。 ただし、レプリケートされたテーブル内の列を変更するクエリは中断され、すべてのアクションが非同期に実行されます。 + +#### クエリの制限の変更 {#alter-query-limitations} + +その `ALTER` クエリを作成および削除個別要素(カラム)をネストしたデータ構造が全体に入れ子データ構造です。 入れ子になったデータ構造を追加するには、次のような名前の列を追加できます `name.nested_name` そしてタイプ `Array(T)`. 入れ子になったデータ構造は、ドットの前に同じプレフィックスを持つ名前を持つ複数の配列列と同等です。 + +主キーまたはサンプリングキーの列を削除することはサポートされていません。 `ENGINE` 式)。 主キーに含まれる列の型を変更することは、この変更によってデータが変更されない場合にのみ可能です(たとえば、列挙型に値を追加したり、型を変更 `DateTime` に `UInt32`). + +もし `ALTER` クエリでは、必要なテーブルの変更を行うのに十分ではありません。 [INSERT SELECT](insert-into.md#insert_query_insert-select) を使用してテーブルを切り替えます [RENAME](misc.md#misc_operations-rename) 古いテーブルを照会して削除します。 を使用することができます [クリックハウス-複写機](../../operations/utilities/clickhouse-copier.md) の代わりとして `INSERT SELECT` クエリ。 + +その `ALTER` クエリーのブロックすべてを読み込みと書き込んでいます。 言い換えれば、 `SELECT` の時に実行されている `ALTER` クエリは、 `ALTER` クエリは、それが完了するのを待ちます。 同時に、同じテーブルに対するすべての新しいクエリは、この間待機します `ALTER` 走ってる + +データ自体を格納しないテーブルの場合(以下のように `Merge` と `Distributed`), `ALTER` テーブル構造を変更するだけで、下位テーブルの構造は変更されません。 たとえば、 `Distributed` テーブル、あなたも実行する必要があります `ALTER` テーブルのすべてすることができます。 + +### キー式による操作 {#manipulations-with-key-expressions} + +次のコマン: + +``` sql +MODIFY ORDER BY new_expression +``` + +これは、 [`MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) 家族(含む +[複製](../../engines/table-engines/mergetree-family/replication.md) テーブル)。 このコマンドは +[ソートキー](../../engines/table-engines/mergetree-family/mergetree.md) テーブルの +に `new_expression` (式または式のタプル)。 主キーは同じままです。 + +このコマンドは、メタデータのみを変更するという意味で軽量です。 データ部分のプロパティを保持するには +行は並べ替えキー式で並べ替えられます既存の列を含む式は追加できません +によって追加された列のみ `ADD COLUMN` 同じコマンド `ALTER` クエリ)。 + +### 操作データを飛指標 {#manipulations-with-data-skipping-indices} + +これは、 [`*MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) 家族(含む +[複製](../../engines/table-engines/mergetree-family/replication.md) テーブル)。 次の操作 +利用できます: + +- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` -付加価指数の説明をテーブルメタデータを指すものとします。 + +- `ALTER TABLE [db].name DROP INDEX name` -除去す指標の説明からテーブルメタデータを削除を行指数のファイルからディスク。 + +これらのコマンドは軽量でいるという意味においてのみ変化メタデータの削除ファイルです。 +また、それらは複製されます(ZooKeeperを介して索引メタデータを同期)。 + +### 制約による操作 {#manipulations-with-constraints} + +詳細はこちら [制約](create.md#constraints) + +制約は、次の構文を使用して追加または削除できます: + +``` sql +ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; +ALTER TABLE [db].name DROP CONSTRAINT constraint_name; +``` + +クエリに追加または削除約メタデータの制約からテーブルで、速やかに処理します。 + +制約チェック *実行されません* 既存のデータが追加された場合。 + +変更後の内容の複製のテーブル放送への飼育係で適用されますその他のレプリカ. + +### パーティションとパーツの操作 {#alter_manipulations-with-partitions} + +次の操作は [仕切り](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 利用できます: + +- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` ディレクトリとそれを忘れ。 +- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. +- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` テーブルへのディレクトリ。 +- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. +- [REPLACE PARTITION](#alter_replace-partition) -コピーするデータを仕切りからテーブルにも置き換え. +- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition)(\#alter\_move\_to\_table-partition)-データ-パーティションをあるテーブルから別のテーブルに移動します。 +- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) -パーティション内の指定された列の値をリセットします。 +- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) -リセットの指定された二次インデックス、パーティション +- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. +- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. +- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. + + + +#### DETACH PARTITION {#alter_detach-partition} + +``` sql +ALTER TABLE table_name DETACH PARTITION partition_expr +``` + +指定されたパーティションのすべてのデータを `detached` ディレクトリ。 サーバーのを忘れているのは、一戸建てのデータを分配していない場合は存在します。 サーバーはこのデータについて知りません。 [ATTACH](#alter_attach-partition) クエリ。 + +例: + +``` sql +ALTER TABLE visits DETACH PARTITION 201901 +``` + +セクションでのパーティション式の設定について [パーティション式の指定方法](#alter-how-to-specify-part-expr). + +クエリが実行された後、データを使用して好きなことを行うことができます。 `detached` directory — delete it from the file system, or just leave it. + +This query is replicated – it moves the data to the `detached` すべてのレプリカ上の このクエリは、リーダーレプリカでのみ実行できます。 する場合は、レプリカは、オーソドックスなアプローチを行う `SELECT` クエリを実行する [システムレプリカ](../../operations/system-tables.md#system_tables-replicas) テーブル。 あるいは、 `DETACH` クエリはすべてのレプリカ-すべてのレプリカ、例外をスロー以外のリーダーレプリカ. + +#### DROP PARTITION {#alter_drop-partition} + +``` sql +ALTER TABLE table_name DROP PARTITION partition_expr +``` + +指定したパーティションを表から削除します。 このクエリのタグの仕切りとして休止または消去いたしますデータを完全に約10分です。 + +セクションでのパーティション式の設定について [パーティション式の指定方法](#alter-how-to-specify-part-expr). + +The query is replicated – it deletes data on all replicas. + +#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} + +``` sql +ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr +``` + +指定された部分または指定されたパーティションのすべての部分を `detached`. +セクションでのパーティション式の設定の詳細 [パーティション式の指定方法](#alter-how-to-specify-part-expr). + +#### ATTACH PARTITION\|PART {#alter_attach-partition} + +``` sql +ALTER TABLE table_name ATTACH PARTITION|PART partition_expr +``` + +テーブルにデータを追加します。 `detached` ディレクトリ。 パーティション全体または別の部分のデータを追加することができます。 例: + +``` sql +ALTER TABLE visits ATTACH PARTITION 201901; +ALTER TABLE visits ATTACH PART 201901_2_2_0; +``` + +セクションでのパーティション式の設定の詳細 [パーティション式の指定方法](#alter-how-to-specify-part-expr). + +このクエリは複製されます。 のレプリカ-イニシエータチェックがあるか否かのデータを `detached` ディレクトリ。 データが存在する場合、クエリはその整合性を確認します。 すべてが正しい場合、クエリはデータをテーブルに追加します。 他のすべてのレプリカをダウンロードからデータのレプリカ-イニシエータです。 + +だから、データを置くことができます `detached` ディレクトリを一つのレプリカ上に置き、 `ALTER ... ATTACH` すべてのレプリカのテーブルに追加するクエリ。 + +#### ATTACH PARTITION FROM {#alter_attach-partition-from} + +``` sql +ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 +``` + +このクエリは、データパーティションを `table1` に `table2` にデータを追加します。 `table2`. データは削除されないことに注意してください `table1`. + +クエリを正常に実行するには、次の条件を満たす必要があります: + +- 両方のテーブルを作成するときに必要となる構造です。 +- 両方のテーブルを作成するときに必要となる分割。 + +#### REPLACE PARTITION {#alter_replace-partition} + +``` sql +ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 +``` + +このクエリは、データパーティションを `table1` に `table2` の既存のパーティションを置き換え `table2`. データは削除されないことに注意してください `table1`. + +クエリを正常に実行するには、次の条件を満たす必要があります: + +- 両方のテーブルを作成するときに必要となる構造です。 +- 両方のテーブルを作成するときに必要となる分割。 + +#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} + +``` sql +ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest +``` + +このクエリは、データパーティションを `table_source` に `table_dest` からデータを削除すると `table_source`. + +クエリを正常に実行するには、次の条件を満たす必要があります: + +- 両方のテーブルを作成するときに必要となる構造です。 +- 両方のテーブルを作成するときに必要となる分割。 +- 両方のテーブルと同じでなければならエンジンです。 (複製または非複製) +- 両方のテーブルを作成するときに必要となる貯ます。 + +#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} + +``` sql +ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr +``` + +すべてリセット値で指定されたカラムがありました。 もし `DEFAULT` 句が決定されたテーブルを作成するときに、このクエリは、指定された既定値に列の値を設定します。 + +例: + +``` sql +ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 +``` + +#### FREEZE PARTITION {#alter_freeze-partition} + +``` sql +ALTER TABLE table_name FREEZE [PARTITION partition_expr] +``` + +このクエリーを作成し、地元のバックアップの指定されたパーティション もし `PARTITION` 条項を省略して、クエリーを作成し、バックアップの仕切ります。 + +!!! note "注" + バックアップ処理全体は、サーバーを停止せずに実行されます。 + +古いスタイルのテーブルの場合、パーティション名のプレフィックスを指定できます(例えば, ‘2019’)のクエリーを作成し、バックアップのためのすべてに対応する隔壁 セクションでのパーティション式の設定について [パーティション式の指定方法](#alter-how-to-specify-part-expr). + +実行時に、データスナップショットの場合、クエリはテーブルデータへのハードリンクを作成します。 Hardlinksに設置されているディレクトリ `/var/lib/clickhouse/shadow/N/...`,ここで: + +- `/var/lib/clickhouse/` 設定で指定された作業ClickHouseディレクトリです。 +- `N` バックアップの増分数です。 + +!!! note "注" + を使用する場合 [テーブル内のデータ格納用のディスクのセット](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) は、 `shadow/N` ディレクトリが表示される毎にディスクデータを格納する部品と合わせによる `PARTITION` 式。 + +バックアップの内部と同じディレクトリ構造が作成されます `/var/lib/clickhouse/`. クエリの実行 ‘chmod’ すべてのファイルの禁止に対して書き込みます。 + +バックアップの作成後、データをコピーするには `/var/lib/clickhouse/shadow/` ローカルサーバーから削除します。 なお、 `ALTER t FREEZE PARTITION` クエリは複製されません。 するための地元のバックアップ、現地サーバーです。 + +クエリをバックアップトで最初のでお待ちしておりますので、現在のクエリーに対応するテーブルに仕上げた。 + +`ALTER TABLE t FREEZE PARTITION` コピーのみのデータのないテーブルメタデータを指すものとします。 をバックアップテーブルメタデータ、コピー、ファイル `/var/lib/clickhouse/metadata/database/table.sql` + +バックアップからデータを復元するには: + +1. テーブルが存在しない場合はテーブルを作成します。 クエリを表示するには、を使用します。sqlファイル(置換 `ATTACH` それで `CREATE`). +2. からデータをコピーします `data/database/table/` バックアップ内のディレクトリ `/var/lib/clickhouse/data/database/table/detached/` ディレクトリ。 +3. 走れ。 `ALTER TABLE t ATTACH PARTITION` テーブルにデータを追加するクエリ。 + +復元からのバックアップを必要としないの停止、サーバーにコピーします。 + +バックアップおよびデータの復元の詳細については、 [データバックア](../../operations/backup.md) セクション + +#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} + +``` sql +ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr +``` + +クエリは次のように動作します `CLEAR COLUMN` しかし、列データではなくインデックスをリセットします。 + +#### FETCH PARTITION {#alter_fetch-partition} + +``` sql +ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' +``` + +ダウンロードパーティションから別のサーバーです。 このクエリーだけを再現します。 + +クエリは、次の操作を実行します: + +1. ダウンロードパーティションから、指定されたザ-シャー. で ‘path-in-zookeeper’ ZooKeeperでシャードへのパスを指定する必要があります。 +2. 次に、クエリはダウンロードしたデータを `detached` のディレクトリ `table_name` テーブル。 使用する [ATTACH PARTITION\|PART](#alter_attach-partition) テーブルにデータを追加するクエリ。 + +例えば: + +``` sql +ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; +ALTER TABLE users ATTACH PARTITION 201902; +``` + +なお: + +- その `ALTER ... FETCH PARTITION` クエリは複製されません。 それは仕切りをに置きます `detached` ディレクトリの現地サーバーです。 +- その `ALTER TABLE ... ATTACH` クエリが複製されます。 すべてのレプリカにデータを追加します。 データはレプリカのいずれかに追加されます。 `detached` ディレクトリ、および他の人に-隣接するレプリカから。 + +ダウンロードする前に、システムかどうかをチェックすると、パーティションが存在するとテーブル構造。 最も適切なレプリカは、正常なレプリカから自動的に選択されます。 + +クエリは呼び出されますが `ALTER TABLE` テーブル構造を変更せず、テーブル内で使用可能なデータを直ちに変更することはありません。 + +#### MOVE PARTITION\|PART {#alter_move-partition} + +パーティションまた `MergeTree`-エンジンテーブル。 見る [複数のブロックデバイスのためのデータ保存](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes). + +``` sql +ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' +``` + +その `ALTER TABLE t MOVE` クエリ: + +- な再現が異なるレプリカで保管。 +- 指定されたディスクまたはボリュ ストレージポリシーで指定されたデータ移動の条件を適用できない場合、Queryはエラーを返します。 +- 復帰できるエラーの場合、データの移動に移行している背景には、同時 `ALTER TABLE t MOVE` クエリまたはバックグラウンドデータマージの結果。 この場合、ユーザーは追加の操作を実行しないでください。 + +例: + +``` sql +ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' +ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' +``` + +#### パーティション式の設定方法 {#alter-how-to-specify-part-expr} + +パーティション式を指定するには `ALTER ... PARTITION` 異なる方法でのクエリ: + +- からの値として `partition` の列 `system.parts` テーブル。 例えば, `ALTER TABLE visits DETACH PARTITION 201901`. +- テーブル列からの式として。 定数と定数式がサポートされています。 例えば, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. +- パーティションIDの使用。 Partition IDは、ファイルシステムおよびZooKeeperのパーティションの名前として使用されるパーティションの文字列識別子(可能であれば人間が読める)です。 パーティションIDは、 `PARTITION ID` 一重引quotesで囲まれた句。 例えば, `ALTER TABLE visits DETACH PARTITION ID '201901'`. +- で [ALTER ATTACH PART](#alter_attach-partition) と [DROP DETACHED PART](#alter_drop-detached) パーツの名前を指定するには、文字列リテラルを使用します。 `name` の列 [システムdetached\_parts](../../operations/system-tables.md#system_tables-detached_parts) テーブル。 例えば, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. + +ご利用の引用符を指定する場合、パーティションのエントランスは目を引く壁面緑化を表現。 例えば、 `String` その名前を引用符で指定する必要があります (`'`). のために `Date` と `Int*` 型引用符は必要ありません。 + +古いスタイルのテーブルの場合は、パーティションを数値として指定できます `201901` または文字列 `'201901'`. 新しいスタイルのテーブルの構文は、型によってより厳密になります(値の入力形式のパーサーと同様)。 + +上記のすべてのルールは、 [OPTIMIZE](misc.md#misc_operations-optimize) クエリ。 を指定する場合にのみ分配時の最適化、非仕切られたテーブルセットの表現 `PARTITION tuple()`. 例えば: + +``` sql +OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; +``` + +の例 `ALTER ... PARTITION` クエリは、テストで示されます [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) と [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). + +### テーブルTTLによる操作 {#manipulations-with-table-ttl} + +変更できます [テーブルTTL](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) 以下のフォームのリクエストで: + +``` sql +ALTER TABLE table-name MODIFY TTL ttl-expression +``` + +### ALTERクエリの同期性 {#synchronicity-of-alter-queries} + +複製不可能なテーブルの場合、すべて `ALTER` クエリは同期的に実行されます。 のためのreplicatableテーブル、クエリーだけで追加指示のための適切な行動を `ZooKeeper` そして、アクション自体はできるだけ早く実行されます。 ただし、クエリは、すべてのレプリカでこれらの操作が完了するまで待機できます。 + +のために `ALTER ... ATTACH|DETACH|DROP` クエリを使用することができます `replication_alter_partitions_sync` 待機を設定する設定。 +可能な値: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. + +### 突然変異 {#alter-mutations} + +突然変異は、テーブル内の行を変更または削除できるALTER query variantです。 標準とは対照的に `UPDATE` と `DELETE` ポイントデータの変更、突然変異を目的としたクエリは、テーブル内の多くの行を変更する重い操作を目的としています。 のために支えられる `MergeTree` 家族のテーブルエンジンなどのエンジンの複製です。 + +既存のテーブルはそのままで(変換は必要ありません)突然変異の準備ができていますが、最初の突然変異がテーブルに適用されると、そのメタデータ形式 + +現在利用可能なコマンド: + +``` sql +ALTER TABLE [db.]table DELETE WHERE filter_expr +``` + +その `filter_expr` 型である必要があります `UInt8`. このクエリは、この式がゼロ以外の値をとるテーブル内の行を削除します。 + +``` sql +ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr +``` + +その `filter_expr` 型である必要があります `UInt8`. このクエリは、指定された列の値を、指定された列の行の対応する式の値に更新します。 `filter_expr` ゼロ以外の値をとります。 値は、列型にキャストされます。 `CAST` オペレーター プライマリキーまたはパーティションキーの計算で使用される列の更新はサポートされません。 + +``` sql +ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name +``` + +クエリを再建の二次指数 `name` パーティション内 `partition_name`. + +一つのクエリを含むことができ複数のコマンドをカンマで区切られています。 + +\*MergeTree表の場合、突然変異はデータ部分全体を書き換えることによって実行されます。 原子性がない-部品は準備ができているとすぐ変異させた部品のために置き換えられ、a `SELECT` 突然変異中に実行を開始したクエリには、すでに変異している部分のデータと、まだ変異していない部分のデータが表示されます。 + +突然変異は完全にそれらの作成順序によって順序付けられ、その順序で各部分に適用される。 突然変異が送信される前にテーブルに挿入されたデータは変異され、その後に挿入されたデータは変異されません。 突然変異は挿入を決してブロックしないことに注意してください。 + +突然変異クエリは、突然変異エントリが追加された直後に返されます(複製されたテーブルがZooKeeperに、複製されていないテーブルがファイルシステムに)。 の突然変異体の執行を非同利用システムの概要を設定します。 あなたが使用することができ、突然変異の進行を追跡するために [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) テーブル。 正常に送信された突然変異は、ClickHouseサーバーが再起動されても実行され続けます。 それが提出された後、突然変異をロールバックする方法はありませんが、突然変異が何らかの理由で立ち往生している場合、それは [`KILL MUTATION`](misc.md#kill-mutation) クエリ。 + +完了した突然変異のエントリはすぐに削除されません(保存されたエントリの数は、 `finished_mutations_to_keep` ストレージエンジ 古い突然変異エントリは削除されます。 + +## ALTER USER {#alter-user-statement} + +ClickHouseユーザーアカウントの変更。 + +### 構文 {#alter-user-syntax} + +``` sql +ALTER USER [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}] + [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### 説明 {#alter-user-dscr} + +使用するには `ALTER USER` あなたは、 [ALTER USER](grant.md#grant-access-management) 特権だ + +### 例 {#alter-user-examples} + +付与されたロールを既定に設定する: + +``` sql +ALTER USER user DEFAULT ROLE role1, role2 +``` + +ロールが以前にユーザーに付与されていない場合、ClickHouseは例外をスローします。 + +付与されたすべての役割をdefaultに設定します: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +将来ユーザーにロールが付与されると、自動的にデフォルトになります。 + +セットの付与の役割をデフォルトを除く `role1` と `role2`: + +``` sql +ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2 +``` + +## ALTER ROLE {#alter-role-statement} + +役割を変更します。 + +### 構文 {#alter-role-syntax} + +``` sql +ALTER ROLE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +## ALTER ROW POLICY {#alter-row-policy-statement} + +行ポリシーを変更します。 + +### 構文 {#alter-row-policy-syntax} + +``` sql +ALTER [ROW] POLICY [IF EXISTS] name [ON CLUSTER cluster_name] ON [database.]table + [RENAME TO new_name] + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING {condition | NONE}][,...] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +## ALTER QUOTA {#alter-quota-statement} + +クォータを変更します。 + +### 構文 {#alter-quota-syntax} + +``` sql +ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +## ALTER SETTINGS PROFILE {#alter-settings-profile-statement} + +クォータを変更します。 + +### 構文 {#alter-settings-profile-syntax} + +``` sql +ALTER SETTINGS PROFILE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/ja/sql-reference/statements/create.md b/docs/ja/sql-reference/statements/create.md new file mode 100644 index 00000000000..0d7ed3b1bc7 --- /dev/null +++ b/docs/ja/sql-reference/statements/create.md @@ -0,0 +1,502 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: CREATE +--- + +# クエリの作成 {#create-queries} + +## CREATE DATABASE {#query-language-create-database} + +データベースの作成 + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] +``` + +### 句 {#clauses} + +- `IF NOT EXISTS` + もし `db_name` データベースが既に存在する場合、ClickHouseは新しいデータベースを作成せず、: + + - 句が指定されている場合は例外をスローしません。 + - 句が指定されていない場合、例外をスローします。 + +- `ON CLUSTER` + クリックハウスは `db_name` データベースの全てのサーバーの指定されたクラスター + +- `ENGINE` + + - [MySQL](../../engines/database-engines/mysql.md) + リモートMySQLサーバーからデータを取得できます。 + 既定では、ClickHouseは独自のものを使用します [データベース](../../engines/database-engines/index.md). + +## CREATE TABLE {#create-table-query} + +その `CREATE TABLE` クエリには複数の形式があります。 + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], + ... +) ENGINE = engine +``` + +テーブルを作成します ‘name’ で ‘db’ データベー ‘db’ が設定されていない。 ‘engine’ エンジン +テーブルの構造は、列の説明のリストです。 た場合の指数については、エンジンとして表示していパラメータテーブルのエンジンです。 + +列の説明は次のとおりです `name type` 最も単純なケースでは。 例: `RegionID UInt32`. +デフォルト値に対して式を定義することもできます(下記参照)。 + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] +``` + +別のテーブルと同じ構造を持つテーブルを作成します。 テーブルに別のエンジンを指定できます。 エンジンが指定されていない場合、同じエンジンが使用されます。 `db2.name2` テーブル。 + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() +``` + +テーブルを作成しますの構造やデータによって返される [テーブル関数](../table-functions/index.md#table-functions). + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... +``` + +の結果のような構造体を持つテーブルを作成します。 `SELECT` クエリは、 ‘engine’ エンジン充填でのデータを選択します。 + +すべての場合において、 `IF NOT EXISTS` テーブルが既に存在する場合、クエリはエラーを返しません。 この場合、クエリは何もしません。 + +の後に他の句がある場合もあります。 `ENGINE` クエリ内の句。 テーブルの作成方法に関する詳細なドキュメントを参照してください [表エンジン](../../engines/table-engines/index.md#table_engines). + +### デフォルト値 {#create-default-values} + +列の説明では、次のいずれかの方法で既定値の式を指定できます:`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. +例: `URLDomain String DEFAULT domain(URL)`. + +既定値の式が定義されていない場合、既定値は数値の場合はゼロ、文字列の場合は空の文字列、配列の場合は空の配列、および `0000-00-00` 日付または `0000-00-00 00:00:00` 時間と日付のために。 Nullはサポートされていません。 + +既定の式が定義されている場合、列の型は省略可能です。 明示的に定義された型がない場合は、既定の式の型が使用されます。 例: `EventDate DEFAULT toDate(EventTime)` – the ‘Date’ タイプは ‘EventDate’ 列。 + +データ型と既定の式が明示的に定義されている場合、この式は型キャスト関数を使用して指定された型にキャストされます。 例: `Hits UInt32 DEFAULT 0` と同じことを意味します `Hits UInt32 DEFAULT toUInt32(0)`. + +Default expressions may be defined as an arbitrary expression from table constants and columns. When creating and changing the table structure, it checks that expressions don't contain loops. For INSERT, it checks that expressions are resolvable – that all columns they can be calculated from have been passed. + +`DEFAULT expr` + +標準のデフォルト値。 INSERTクエリで対応する列が指定されていない場合は、対応する式を計算して入力されます。 + +`MATERIALIZED expr` + +マテリアライズ式。 このような列は常に計算されるため、INSERTには指定できません。 +列のリストがない挿入の場合、これらの列は考慮されません。 +また、SELECTクエリでアスタリスクを使用する場合、この列は置換されません。 これは、ダンプが取得した不変量を保持するためです `SELECT *` 列のリストを指定せずにINSERTを使用してテーブルに挿入することができます。 + +`ALIAS expr` + +シノニム このような列は、テーブルにまったく格納されません。 +また、SELECTクエリでアスタリスクを使用する場合は、その値は置換されません。 +クエリの解析中にエイリアスが展開される場合は、Selectで使用できます。 + +ALTERクエリを使用して新しい列を追加する場合、これらの列の古いデータは書き込まれません。 代わりに、新しい列の値を持たない古いデータを読み取るときは、デフォルトで式がその場で計算されます。 ただし、式を実行するには、クエリで指定されていない異なる列が必要な場合は、これらの列はさらに読み取られますが、必要なデータブロックに対し + +テーブルに新しい列を追加し、後でその既定の式を変更すると、古いデータに使用される値が変更されます(値がディスクに格納されていないデータの場合)。 ご注意実行する場合背景が合併のデータ列を欠損の合流部に書かれて合併します。 + +入れ子になったデータ構造の要素に既定値を設定することはできません。 + +### 制約 {#constraints} + +列記述制約と一緒に定義することができます: + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + ... + CONSTRAINT constraint_name_1 CHECK boolean_expr_1, + ... +) ENGINE = engine +``` + +`boolean_expr_1` 任意のブール式で可能です。 場合に制約の定義のテーブルのそれぞれチェック毎に行 `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. + +追加大量の制約になる可能性の性能を大 `INSERT` クエリ。 + +### TTL式 {#ttl-expression} + +値の保存時間を定義します。 MergeTree-familyテーブルに対してのみ指定できます。 詳細な説明については、 [列および表のTTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). + +### 列圧縮コーデック {#codecs} + +デフォルトでは、ClickHouseは `lz4` 圧縮方法。 のために `MergeTree`-エンジンファミリでデフォルトの圧縮方法を変更できます。 [圧縮](../../operations/server-configuration-parameters/settings.md#server-settings-compression) サーバー構成のセクション。 また、圧縮方法を定義することもできます。 `CREATE TABLE` クエリ。 + +``` sql +CREATE TABLE codec_example +( + dt Date CODEC(ZSTD), + ts DateTime CODEC(LZ4HC), + float_value Float32 CODEC(NONE), + double_value Float64 CODEC(LZ4HC(9)) + value Float32 CODEC(Delta, ZSTD) +) +ENGINE = +... +``` + +コーデックが指定されている場合、既定のコーデックは適用されません。 コーデックはパイプラインで結合できます。, `CODEC(Delta, ZSTD)`. の選定と大型ブリッジダイオードコーデックの組み合わせますプロジェクト、ベンチマークと同様に記載のAltinity [ClickHouseの効率を改善する新しい符号化](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) 記事だ + +!!! warning "警告" + できない解凍ClickHouseデータベースファイルを外部の事のように `lz4`. 代わりに、特別な [clickhouse-コンプレッサー](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) ユーティリティ + +圧縮は、次の表エンジンでサポートされます: + +- [メルゲツリー](../../engines/table-engines/mergetree-family/mergetree.md) 家族だ 支柱の圧縮コーデックとの選択のデフォルトの圧縮メソッドによる [圧縮](../../operations/server-configuration-parameters/settings.md#server-settings-compression) 設定。 +- [ログ](../../engines/table-engines/log-family/log-family.md) 家族だ を使用して `lz4` 圧縮メソッドはデフォルト対応カラムの圧縮コーデック. +- [セット](../../engines/table-engines/special/set.md). 既定の圧縮のみをサポートしました。 +- [参加](../../engines/table-engines/special/join.md). 既定の圧縮のみをサポートしました。 + +ClickHouse支援共通の目的コーデックや専門のコーデック. + +#### 特殊なコーデック {#create-query-specialized-codecs} + +これらのコーデックしていただくための圧縮により効果的な利用の特徴データです。 これらのコーデックの一部は、データ自体を圧縮しません。 代わりに、共通の目的のコーデックのためにデータを準備し、この準備がない場合よりも圧縮します。 + +特殊なコーデック: + +- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` デルタ値を格納するために使用されます。 `delta_bytes` 生の値の最大サイズです。 可能 `delta_bytes` 値:1,2,4,8。 のデフォルト値 `delta_bytes` は `sizeof(type)` 1、2、4、または8に等しい場合。 他のすべてのケースでは、それは1です。 +- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [Gorilla:高速でスケーラブルなメモリ内の時系列データベース](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [Gorilla:高速でスケーラブルなメモリ内の時系列データベース](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` と `DateTime`). そのアルゴリズムの各ステップで、codecは64の値のブロックを取り、それらを64x64ビット行列に入れ、転置し、未使用の値のビットを切り取り、残りをシー 未使用ビットは、圧縮が使用されるデータ部分全体の最大値と最小値の間で異ならないビットです。 + +`DoubleDelta` と `Gorilla` Gorilla TSDBでは圧縮アルゴリズムの構成要素としてコーデックが使用されている。 Gorillaのアプローチは、タイムスタンプにゆっくりと変化する一連の値がある場合のシナリオで効果的です。 タイムスタンプは `DoubleDelta` によって効果的に圧縮されます `Gorilla` コーデック。 たとえば、効果的に格納されたテーブルを取得するには、次の構成で作成できます: + +``` sql +CREATE TABLE codec_example +( + timestamp DateTime CODEC(DoubleDelta), + slow_values Float32 CODEC(Gorilla) +) +ENGINE = MergeTree() +``` + +#### 汎用コーデック {#create-query-general-purpose-codecs} + +コーデック: + +- `NONE` — No compression. +- `LZ4` — Lossless [データ圧縮](https://github.com/lz4/lz4) 既定で使用されます。 LZ4高速圧縮を適用します。 +- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` 既定のレベルを適用します。 可能なレベル:\[1、12\]。 推奨レベル範囲:\[4、9\]。 +- `ZSTD[(level)]` — [ZSTD圧縮アルゴリズム](https://en.wikipedia.org/wiki/Zstandard) 構成可能を使って `level`. 可能なレベル:\[1、22\]。 デフォルト値:1。 + +高い圧縮レベルは、一度の圧縮、繰り返しの解凍などの非対称シナリオに役立ちます。 高いレベルは、より良い圧縮と高いCPU使用率を意味します。 + +## 一時テーブル {#temporary-tables} + +ClickHouseは、次の特性を持つ一時テーブルをサポートします: + +- 一時テーブルは、接続が失われた場合を含め、セッションが終了すると消滅します。 +- 一時テーブルはメモリエンジンのみを使用します。 +- 一時テーブルにDBを指定することはできません。 データベースの外部に作成されます。 +- すべてのクラスタサーバーで分散DDLクエリを使用して一時テーブルを作成することはできません `ON CLUSTER`):このテーブルは現在のセッションにのみ存在します。 +- 一時テーブルの名前が別のテーブルと同じで、クエリがDBを指定せずにテーブル名を指定した場合、一時テーブルが使用されます。 +- 分散クエリ処理では、クエリで使用される一時テーブルがリモートサーバーに渡されます。 + +一時テーブルを作成するには、次の構文を使用します: + +``` sql +CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) +``` + +ほとんどの場合、一時テーブルを手動で作成され、外部データを利用するためのクエリに対して、または配布 `(GLOBAL) IN`. 詳細については、該当する項を参照してください + +テーブルを使用することは可能です [エンジン=メモリ](../../engines/table-engines/special/memory.md) 一時テーブルの代わりに。 + +## 分散DDLクエリ(ON CLUSTER句) {#distributed-ddl-queries-on-cluster-clause} + +その `CREATE`, `DROP`, `ALTER`,and `RENAME` クエリの支援の分散実行クラスター +たとえば、次のクエリは、 `all_hits` `Distributed` 各ホストのテーブル `cluster`: + +``` sql +CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) +``` + +これらのクエリを正しく実行するには、各ホストが同じクラスタ定義を持っている必要があります(設定の同期を簡単にするために、ZooKeeperからの置換 また、ZooKeeperサーバーに接続する必要があります。 +一部のホストが現在利用できない場合でも、ローカルバージョンのクエリは最終的にクラスタ内の各ホストに実装されます。 単一のホスト内でクエリを実行する順序は保証されます。 + +## CREATE VIEW {#create-view} + +``` sql +CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... +``` + +ビューを作成します。 通常と実体化:ビューの二つのタイプがあります。 + +通常のビューはデータを格納せず、別のテーブルからの読み取りを実行するだけです。 つまり、通常のビューは保存されたクエリに過ぎません。 ビューから読み取るとき、この保存されたクエリはFROM句のサブクエリとして使用されます。 + +例として、ビューを作成したとします: + +``` sql +CREATE VIEW view AS SELECT ... +``` + +そして、クエリを書いた: + +``` sql +SELECT a, b, c FROM view +``` + +このクエリは、サブクエリの使用と完全に同等です: + +``` sql +SELECT a, b, c FROM (SELECT ...) +``` + +マテリアライズドビュ + +マテリアライズドビューを作成するとき `TO [db].[table]`, you must specify ENGINE – the table engine for storing data. + +マテリアライズドビューを作成するとき `TO [db].[table]`、使用してはいけません `POPULATE`. + +SELECTで指定されたテーブルにデータを挿入すると、挿入されたデータの一部がこのSELECTクエリによって変換され、結果がビューに挿入されます。 + +POPULATEを指定すると、既存のテーブルデータが作成時にビューに挿入されます。 `CREATE TABLE ... AS SELECT ...` . そうしないと、クエリーを含み、データを挿入し、表の作成後、作成した。 ビューの作成中にテーブルに挿入されたデータは挿入されないため、POPULATEを使用することはお勧めしません。 + +A `SELECT` クエリを含むことができ `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Note that the corresponding conversions are performed independently on each block of inserted data. For example, if `GROUP BY` データは挿入中に集計されますが、挿入されたデータの単一パケット内でのみ集計されます。 データはそれ以上集計されません。 例外は、次のように独立してデータ集計を実行するエンジンを使用する場合です `SummingMergeTree`. + +の実行 `ALTER` マテリアライズドビューのクエリは完全に開発されていないため、不便な場合があります。 マテリアライズドビューで構成を使用する場合 `TO [db.]name`、できます `DETACH` ビュー、実行 `ALTER` ターゲットテーブルの場合、次に `ATTACH` 以前に切り離された (`DETACH`)ビュー。 + +ビューの外観は通常のテーブルと同じです。 たとえば、それらは次の結果にリストされます `SHOW TABLES` クエリ。 + +ビューを削除するための別のクエリはありません。 ビューを削除するには `DROP TABLE`. + +## CREATE DICTIONARY {#create-dictionary-query} + +``` sql +CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] +( + key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + attr1 type2 [DEFAULT|EXPRESSION expr3], + attr2 type2 [DEFAULT|EXPRESSION expr4] +) +PRIMARY KEY key1, key2 +SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) +LAYOUT(LAYOUT_NAME([param_name param_value])) +LIFETIME([MIN val1] MAX val2) +``` + +作成 [外部辞書](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) 与えられたと [構造](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md), [ソース](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md), [レイアウト](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md) と [生涯](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md). + +外部辞書構造は属性で構成されます。 辞書属性は、表の列と同様に指定されます。 必要な属性プロパティはその型だけで、他のすべてのプロパティには既定値があります。 + +辞書によっては [レイアウト](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md) 一つ以上の属性を辞書キーとして指定できます。 + +詳細については、 [外部辞書](../dictionaries/external-dictionaries/external-dicts.md) セクション + +## CREATE USER {#create-user-statement} + +を作成します。 [ユーザー](../../operations/access-rights.md#user-account-management). + +### 構文 {#create-user-syntax} + +``` sql +CREATE USER [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [IDENTIFIED [WITH {NO_PASSWORD|PLAINTEXT_PASSWORD|SHA256_PASSWORD|SHA256_HASH|DOUBLE_SHA1_PASSWORD|DOUBLE_SHA1_HASH}] BY {'password'|'hash'}] + [HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...]] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +#### 識別情報 {#identification} + +ユーザー識別には複数の方法があります: + +- `IDENTIFIED WITH no_password` +- `IDENTIFIED WITH plaintext_password BY 'qwerty'` +- `IDENTIFIED WITH sha256_password BY 'qwerty'` または `IDENTIFIED BY 'password'` +- `IDENTIFIED WITH sha256_hash BY 'hash'` +- `IDENTIFIED WITH double_sha1_password BY 'qwerty'` +- `IDENTIFIED WITH double_sha1_hash BY 'hash'` + +#### ユーザホスト {#user-host} + +ユーザーホストは、ClickHouseサーバーへの接続を確立できるホストです。 ホストを指定することができます。 `HOST` 次の方法によるクエリのセクション: + +- `HOST IP 'ip_address_or_subnetwork'` — User can connect to ClickHouse server only from the specified IP address or a [サブネットワーク](https://en.wikipedia.org/wiki/Subnetwork). 例: `HOST IP '192.168.0.0/16'`, `HOST IP '2001:DB8::/32'`. の使用、生産を指定するだけでいいのです。 `HOST IP` 要素(IPアドレスとそのマスク)を使用しているため `host` と `host_regexp` が原因別の待ち時間をゼロにすることに +- `HOST ANY` — User can connect from any location. This is default option. +- `HOST LOCAL` — User can connect only locally. +- `HOST NAME 'fqdn'` — User host can be specified as FQDN. For example, `HOST NAME 'mysite.com'`. +- `HOST NAME REGEXP 'regexp'` — You can use [pcre](http://www.pcre.org/) ユーザーホストを指定するときの正規表現。 例えば, `HOST NAME REGEXP '.*\.mysite\.com'`. +- `HOST LIKE 'template'` — Allows you use the [LIKE](../functions/string-search-functions.md#function-like) ユーザーホストをフィルタする演算子。 例えば, `HOST LIKE '%'` に等しい。 `HOST ANY`, `HOST LIKE '%.mysite.com'` すべてのホストをフィルタする。 `mysite.com` ドメイン。 + +Hostを指定する別の方法は次のとおりです `@` ユーザー名の構文。 例: + +- `CREATE USER mira@'127.0.0.1'` — Equivalent to the `HOST IP` 構文。 +- `CREATE USER mira@'localhost'` — Equivalent to the `HOST LOCAL` 構文。 +- `CREATE USER mira@'192.168.%.%'` — Equivalent to the `HOST LIKE` 構文。 + +!!! info "警告" + クリックハウス `user_name@'address'` 全体としてのユーザー名として。 このように、技術的に作成できます複数のユーザー `user_name` そして後の異なった構造 `@`. 私たちはそうすることをお勧めしません。 + +### 例 {#create-user-examples} + +ユーザーアカウントの作成 `mira` パスワードで保護 `qwerty`: + +``` sql +CREATE USER mira HOST IP '127.0.0.1' IDENTIFIED WITH sha256_password BY 'qwerty' +``` + +`mira` 開始すべきお客様のアプリをホストにClickHouseサーバー運行しています。 + +ユーザーアカウントの作成 `john` ロールを割り当て、このロールをデフォルトにする: + +``` sql +CREATE USER john DEFAULT ROLE role1, role2 +``` + +ユーザーアカウントの作成 `john` 彼の将来の役割をすべてデフォルトにする: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +いくつかの役割が割り当てられるとき `john` 将来的には自動的にデフォルトになります。 + +ユーザーアカウントの作成 `john` く全ての彼の今後の役割はデフォルトを除く `role1` と `role2`: + +``` sql +ALTER USER john DEFAULT ROLE ALL EXCEPT role1, role2 +``` + +## CREATE ROLE {#create-role-statement} + +を作成します。 [役割](../../operations/access-rights.md#role-management). + +### 構文 {#create-role-syntax} + +``` sql +CREATE ROLE [IF NOT EXISTS | OR REPLACE] name + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### 説明 {#create-role-description} + +役割は、 [特権](grant.md#grant-privileges). ロールで付与されたユーザーは、このロールのすべての権限を取得します。 + +ユーザーの割り当てることができ複数の役割です。 ユーザーに適用できるのを助の役割の任意の組み合わせによる [SET ROLE](misc.md#set-role-statement) 声明。 特権の最終的なスコープは、適用されたすべてのロールのすべての特権の組み合わせです。 ユーザーが権限を付与に直接かつてのユーザーアカウント、または権限を付与する。 + +ユーザーがデフォルトの役割を応用したユーザーログインします。 デフォルトのロールを設定するには、 [SET DEFAULT ROLE](misc.md#set-default-role-statement) 文または [ALTER USER](alter.md#alter-user-statement) 声明。 + +ロールを取り消すには、 [REVOKE](revoke.md) 声明。 + +ロールを削除するには、 [DROP ROLE](misc.md#drop-role-statement) 声明。 削除されたロールは、付与されたすべてのユーザーおよびロールから自動的に取り消されます。 + +### 例 {#create-role-examples} + +``` sql +CREATE ROLE accountant; +GRANT SELECT ON db.* TO accountant; +``` + +この一連のクエリは、ロールを作成します `accountant` それはからデータを読み取る権限を持っています `accounting` データベース。 + +ユーザーへのロールの付与 `mira`: + +``` sql +GRANT accountant TO mira; +``` + +後の役割が付与されたユーザーが利用できる実行させます。 例えば: + +``` sql +SET ROLE accountant; +SELECT * FROM db.*; +``` + +## CREATE ROW POLICY {#create-row-policy-statement} + +を作成します。 [行のフィルタ](../../operations/access-rights.md#row-policy-management) ユーザーがテーブルから読み取ることができます。 + +### 構文 {#create-row-policy-syntax} + +``` sql +CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE] policy_name [ON CLUSTER cluster_name] ON [db.]table + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING condition] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +#### セクションAS {#create-row-policy-as} + +このセクショ + +確認方針にアクセスが付与されています。 同じテーブルに適用されるパーミッシブポリシーは、booleanを使用して結合されます `OR` オペレーター ポリシーは既定では許可されています。 + +制限的な政策アクセス制限を行います。 同じテーブルに適用される制限ポリシーは、ブール値を使用して結合されます `AND` オペレーター + +制限ポリシーは、許可フィルターを通過した行に適用されます。 制限的なポリシーを設定しても、許可的なポリシーを設定しない場合、ユーザーはテーブルから行を取得できません。 + +#### セクションへ {#create-row-policy-to} + +セクション内 `TO` ロールとユーザーの混在リストを指定できます。, `CREATE ROW POLICY ... TO accountant, john@localhost`. + +キーワード `ALL` 現在のユーザを含むすべてのClickHouseユーザを意味します。 キーワード `ALL EXCEPT` allow toは、すべてのユーザーリストから一部のユーザーを除外します。 `CREATE ROW POLICY ... TO ALL EXCEPT accountant, john@localhost` + +### 例 {#examples} + +- `CREATE ROW POLICY filter ON mydb.mytable FOR SELECT USING a<1000 TO accountant, john@localhost` +- `CREATE ROW POLICY filter ON mydb.mytable FOR SELECT USING a<1000 TO ALL EXCEPT mira` + +## CREATE QUOTA {#create-quota-statement} + +を作成します。 [クォータ](../../operations/access-rights.md#quotas-management) ユーザーまたはロールに割り当てることができます。 + +### 構文 {#create-quota-syntax} + +``` sql +CREATE QUOTA [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +### 例 {#create-quota-example} + +現在のユーザーに対するクエリの最大数を123か月以内に制限する制約: + +``` sql +CREATE QUOTA qA FOR INTERVAL 15 MONTH MAX QUERIES 123 TO CURRENT_USER +``` + +## CREATE SETTINGS PROFILE {#create-settings-profile-statement} + +を作成します。 [設定プロファイル](../../operations/access-rights.md#settings-profiles-management) ユーザーまたはロールに割り当てることができます。 + +### 構文 {#create-settings-profile-syntax} + +``` sql +CREATE SETTINGS PROFILE [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + +# 例 {#create-settings-profile-syntax} + +を作成します。 `max_memory_usage_profile` の値と制約を持つ設定プロファイル `max_memory_usage` 設定。 それを割り当てる `robin`: + +``` sql +CREATE SETTINGS PROFILE max_memory_usage_profile SETTINGS max_memory_usage = 100000001 MIN 90000000 MAX 110000000 TO robin +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/create/) diff --git a/docs/ja/sql-reference/statements/grant.md b/docs/ja/sql-reference/statements/grant.md new file mode 120000 index 00000000000..f2acbe125b4 --- /dev/null +++ b/docs/ja/sql-reference/statements/grant.md @@ -0,0 +1 @@ +../../../en/sql-reference/statements/grant.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/index.md b/docs/ja/sql-reference/statements/index.md new file mode 100644 index 00000000000..9111f424912 --- /dev/null +++ b/docs/ja/sql-reference/statements/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u6587" +toc_priority: 31 +--- + + diff --git a/docs/ja/sql-reference/statements/insert-into.md b/docs/ja/sql-reference/statements/insert-into.md new file mode 100644 index 00000000000..3a646cc214f --- /dev/null +++ b/docs/ja/sql-reference/statements/insert-into.md @@ -0,0 +1,80 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: INSERT INTO +--- + +## INSERT {#insert} + +データの追加。 + +基本的なクエリ形式: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... +``` + +クエリでは、挿入する列のリストを指定できます `[(c1, c2, c3)]`. この場合、残りの列は: + +- から計算される値 `DEFAULT` テーブル定義で指定された式。 +- ゼロと空の文字列 `DEFAULT` 式は定義されていません。 + +もし [strict\_insert\_defaults=1](../../operations/settings/settings.md),を持たない列 `DEFAULT` 定義され記載されていることを返します。 + +データは、任意の場所でINSERTに渡すことができます [形式](../../interfaces/formats.md#formats) ClickHouseがサポートしています。 この形式は、クエリで明示的に指定する必要があります: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set +``` + +For example, the following query format is identical to the basic version of INSERT … VALUES: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... +``` + +ClickHouseは、データの前にスペースと改行がある場合をすべて削除します。 クエリを作成するときは、クエリ演算子の後に新しい行にデータを置くことをお勧めします(データがスペースで始まる場合は重要です)。 + +例: + +``` sql +INSERT INTO t FORMAT TabSeparated +11 Hello, world! +22 Qwerty +``` + +挿入することができます。データから別のクエリのコマンドラインクライアント、HTTPインターフェース。 詳細については “[インター](../../interfaces/index.md#interfaces)”. + +### 制約 {#constraints} + +テーブルが [制約](create.md#constraints), their expressions will be checked for each row of inserted data. If any of those constraints is not satisfied — server will raise an exception containing constraint name and expression, the query will be stopped. + +### の結果を挿入する `SELECT` {#insert_query_insert-select} + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... +``` + +列は、SELECT句内の位置に従ってマップされます。 ただし、SELECT式とINSERTテーブルの名前は異なる場合があります。 必要に応じて、型鋳造が行われる。 + +値以外のデータ形式では、次のような式に値を設定できません `now()`, `1 + 2`、というように。 Values形式では式の使用は制限されますが、この場合は非効率的なコードが実行に使用されるため、これは推奨されません。 + +その他のクエリをデータ部品に対応していない: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. +ただし、古いデータを削除するには `ALTER TABLE ... DROP PARTITION`. + +`FORMAT` 次の場合、クエリの最後に句を指定する必要があります `SELECT` 句は、表関数を含みます [入力()](../table-functions/input.md). + +### パフォーマン {#performance-considerations} + +`INSERT` 入力データを主キーでソートし、パーティションキーでパーティションに分割します。 た場合のデータを挿入し複数の仕切りは一度で大幅に低減できることの `INSERT` クエリ。 これを避けるには: + +- 一度に100,000行など、かなり大きなバッチでデータを追加します。 +- グループによるデータのパーティション鍵のアップロード前にでClickHouse. + +パフォーマンスが低下しない場合: + +- データはリアルタイムで追加されます。 +- アップロードしたデータとは、通常はソートされました。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/ja/sql-reference/statements/misc.md b/docs/ja/sql-reference/statements/misc.md new file mode 100644 index 00000000000..8925ed645b3 --- /dev/null +++ b/docs/ja/sql-reference/statements/misc.md @@ -0,0 +1,358 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u305D\u306E\u4ED6" +--- + +# その他のクエリ {#miscellaneous-queries} + +## ATTACH {#attach} + +このクエリはまったく同じです `CREATE` でも + +- 言葉の代わりに `CREATE` それは単語を使用します `ATTACH`. +- クエリはディスク上にデータを作成するのではなく、データがすでに適切な場所にあると仮定し、テーブルに関する情報をサーバーに追加するだけです。 + アタッチクエリを実行すると、サーバーはテーブルの存在を知ります。 + +テーブルが以前にデタッチされた場合 (`DETACH`)、その構造が知られていることを意味する、あなたは構造を定義せずに省略形を使用することができます。 + +``` sql +ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] +``` + +このクエリは、サーバーの起動時に使用されます。 サーバーに店舗のテーブルメタデータとしてファイル `ATTACH` 単に起動時に実行されるクエリ(サーバー上で明示的に作成されるシステムテーブルを除く)。 + +## CHECK TABLE {#check-table} + +表のデータが破損しているかどうかを確認します。 + +``` sql +CHECK TABLE [db.]name +``` + +その `CHECK TABLE` queryは、実際のファイルサイズと、サーバーに格納されている期待値を比較します。 ファイルサイズが格納された値と一致しない場合は、データが破損していることを意味します。 このが発生する可能性があります、例えば、システムがクラッシュ時のクエリを実行します。 + +クエリ応答には、 `result` 単一行の列。 行の値は次のとおりです +[ブール値](../../sql-reference/data-types/boolean.md) タイプ: + +- 0-テーブル内のデータが破損しています。 +- 1-データは整合性を維持します。 + +その `CHECK TABLE` クエリは以下のテーブルエンジン: + +- [ログ](../../engines/table-engines/log-family/log.md) +- [TinyLog](../../engines/table-engines/log-family/tinylog.md) +- [ストリップログ](../../engines/table-engines/log-family/stripelog.md) +- [メルゲツリー族](../../engines/table-engines/mergetree-family/mergetree.md) + +これは、テーブルが別のテーブルエンジンの原因となる例外です。 + +からのエンジン `*Log` 家族は失敗の自動データ回復を提供しない。 使用する `CHECK TABLE` タイムリーにデータ損失を追跡するためのクエリ。 + +のために `MergeTree` ファミリーエンジン `CHECK TABLE` クエリを示すステータス確認のための個人データのテーブルに現地サーバーです。 + +**データが破損している場合** + +テーブルが破損している場合は、破損していないデータを別のテーブルにコピーできます。 これを行うには: + +1. 破損したテーブルと同じ構造を持つ新しいテーブルを作成します。 これを行うにはクエリを実行します `CREATE TABLE AS `. +2. セット [max\_threads](../../operations/settings/settings.md#settings-max_threads) 単一のスレッドで次のクエリを処理するには、値を1に設定します。 このクエリ `SET max_threads = 1`. +3. クエリの実行 `INSERT INTO SELECT * FROM `. この要求により、破損していないデータが破損した表から別の表にコピーされます。 破損した部分の前のデータのみがコピーされます。 +4. 再起動 `clickhouse-client` リセットするには `max_threads` 値。 + +## DESCRIBE TABLE {#misc-describe-table} + +``` sql +DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +次の値を返します `String` タイプ列: + +- `name` — Column name. +- `type`— Column type. +- `default_type` — Clause that is used in [既定の式](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` または `ALIAS`). 既定の式が指定されていない場合、Columnには空の文字列が含まれます。 +- `default_expression` — Value specified in the `DEFAULT` 句。 +- `comment_expression` — Comment text. + +入れ子になったデータ構造は “expanded” 形式。 各列は、ドットの後に名前を付けて別々に表示されます。 + +## DETACH {#detach} + +に関する情報を削除します。 ‘name’ サーバーからのテーブル。 サーバーは、テーブルの存在を知ることを停止します。 + +``` sql +DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +テーブルのデータまたはメタデータは削除されません。 次のサーバー起動時に、サーバーはメタデータを読み取り、テーブルについて再度確認します。 +同様に、 “detached” テーブルはを使用して再付すことができます `ATTACH` クエリ(メタデータが格納されていないシステムテーブルを除く)。 + +ありません `DETACH DATABASE` クエリ。 + +## DROP {#drop} + +このクエリ慮して、調教メニューを組み立て: `DROP DATABASE` と `DROP TABLE`. + +``` sql +DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] +``` + +内部のすべてのテーブルを削除 ‘db’ データベースを削除します。 ‘db’ データベース自体。 +もし `IF EXISTS` データベースが存在しない場合、エラーは返されません。 + +``` sql +DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +テーブルを削除します。 +もし `IF EXISTS` テーブルが存在しない場合、またはデータベースが存在しない場合、エラーは返されません。 + + DROP DICTIONARY [IF EXISTS] [db.]name + +辞書を削除します。 +もし `IF EXISTS` テーブルが存在しない場合、またはデータベースが存在しない場合、エラーは返されません。 + +## DROP USER {#drop-user-statement} + +ユーザーを削除します。 + +### 構文 {#drop-user-syntax} + +``` sql +DROP USER [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROLE {#drop-role-statement} + +ロールを削除します。 + +削除された役割は、付与されたすべてのエンティティから取り消されます。 + +### 構文 {#drop-role-syntax} + +``` sql +DROP ROLE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROW POLICY {#drop-row-policy-statement} + +行ポリシーを削除します。 + +削除行の政策が取り消すべての主体で割り当てられます。 + +### 構文 {#drop-row-policy-syntax} + +``` sql +DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] +``` + +## DROP QUOTA {#drop-quota-statement} + +クォータを削除します。 + +削除枠が取り消すべての主体で割り当てられます。 + +### 構文 {#drop-quota-syntax} + +``` sql +DROP QUOTA [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP SETTINGS PROFILE {#drop-settings-profile-statement} + +クォータを削除します。 + +削除枠が取り消すべての主体で割り当てられます。 + +### 構文 {#drop-settings-profile-syntax} + +``` sql +DROP [SETTINGS] PROFILE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## EXISTS {#exists-statement} + +``` sql +EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] +``` + +単一を返します `UInt8`-単一の値を含む列を入力します `0` テーブルまたはデータベースが存在しない場合、または `1` 指定されたデータベースにテーブルが存在する場合。 + +## KILL QUERY {#kill-query-statement} + +``` sql +KILL QUERY [ON CLUSTER cluster] + WHERE + [SYNC|ASYNC|TEST] + [FORMAT format] +``` + +現在実行中のクエリを強制的に終了しようとします。 +終了するクエリがシステムから選択されます。で定義された基準を使用してテーブルを処理します `WHERE` の節 `KILL` クエリ。 + +例: + +``` sql +-- Forcibly terminates all queries with the specified query_id: +KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' + +-- Synchronously terminates all queries run by 'username': +KILL QUERY WHERE user='username' SYNC +``` + +読み取り専用ユーザーは、独自のクエリのみを停止できます。 + +既定では、非同期バージョンのクエリが使用されます (`ASYNC`)、クエリが停止したことの確認を待たない。 + +同期バージョン (`SYNC`)すべてのクエリが停止するのを待機し、停止すると各プロセスに関する情報を表示します。 +応答には、 `kill_status` 列は、次の値を取ることができます: + +1. ‘finished’ – The query was terminated successfully. +2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. +3. The other values ​​explain why the query can't be stopped. + +テストクエリ (`TEST`)ユーザーの権限のみをチェックし、停止するクエリのリストを表示します。 + +## KILL MUTATION {#kill-mutation} + +``` sql +KILL MUTATION [ON CLUSTER cluster] + WHERE + [TEST] + [FORMAT format] +``` + +取り消しと削除を試みます [突然変異](alter.md#alter-mutations) 現在実行中です 取り消すべき突然変異はから選ばれます [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) によって指定されたフィルタを使用する表 `WHERE` の節 `KILL` クエリ。 + +テストクエリ (`TEST`)ユーザーの権限のみをチェックし、停止するクエリのリストを表示します。 + +例: + +``` sql +-- Cancel and remove all mutations of the single table: +KILL MUTATION WHERE database = 'default' AND table = 'table' + +-- Cancel the specific mutation: +KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' +``` + +The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). + +突然変異によって既に行われた変更はロールバックされません。 + +## OPTIMIZE {#misc_operations-optimize} + +``` sql +OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] +``` + +このクエリは、テーブルエンジンを使用してテーブルのデータ部分の予定外のマージを初期化しようとします。 [メルゲツリー](../../engines/table-engines/mergetree-family/mergetree.md) 家族だ + +その `OPTMIZE` クエリは、 [マテリアライズドビュー](../../engines/table-engines/special/materializedview.md) そして、 [バッファ](../../engines/table-engines/special/buffer.md) エンジンだ その他のテーブルエンジンなサポート。 + +とき `OPTIMIZE` と共に使用されます [複製マージツリー](../../engines/table-engines/mergetree-family/replication.md) テーブルエンジンのファミリでは、ClickHouseはマージ用のタスクを作成し、すべてのノードで実行を待機します。 `replication_alter_partitions_sync` 設定が有効になっています)。 + +- もし `OPTIMIZE` 何らかの理由でマージを実行せず、クライアントに通知しません。 通知を有効にするには、 [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop) 設定。 +- を指定した場合 `PARTITION` 指定したパーティションのみが最適化されます。 [パーティション式の設定方法](alter.md#alter-how-to-specify-part-expr). +- 指定した場合 `FINAL`、最適化は、すべてのデータが一つの部分に既にある場合でも実行されます。 +- 指定した場合 `DEDUPLICATE` その後、完全に同一の行が重複除外されます(すべての列が比較されます)。 + +!!! warning "警告" + `OPTIMIZE` できない修正 “Too many parts” エラー + +## RENAME {#misc_operations-rename} + +テーブルの名前を変更します。 + +``` sql +RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] +``` + +すべてのテーブル名変更"グローバルチェンジにおけるロックしなければなりません。 テーブルの名前を変更することは簡単な操作です。 TOの後に別のデータベースを指定した場合、表はこのデータベースに移動されます。 しかし、そのディレクトリのデータベースに格納してある必要がある同一ファイルシステム(それ以外の場合、エラーを返す。 + +## SET {#query-set} + +``` sql +SET param = value +``` + +割り当て `value` に `param` [設定](../../operations/settings/index.md) 現在のセッションの場合。 変更できません [サーバー設定](../../operations/server-configuration-parameters/index.md) こっちだ + +指定した設定プロファイルのすべての値を単一のクエリで設定することもできます。 + +``` sql +SET profile = 'profile-name-from-the-settings-file' +``` + +詳細については、 [設定](../../operations/settings/settings.md). + +## SET ROLE {#set-role-statement} + +現在のユーザーのロールを有効にします。 + +### 構文 {#set-role-syntax} + +``` sql +SET ROLE {DEFAULT | NONE | role [,...] | ALL | ALL EXCEPT role [,...]} +``` + +## SET DEFAULT ROLE {#set-default-role-statement} + +既定のロールをユーザーに設定します。 + +デフォルトの役割を自動的に起動されたユーザーログインします。 既定として設定できるのは、以前に付与されたロールのみです。 ロールがユーザーに付与されていない場合、ClickHouseは例外をスローします。 + +### 構文 {#set-default-role-syntax} + +``` sql +SET DEFAULT ROLE {NONE | role [,...] | ALL | ALL EXCEPT role [,...]} TO {user|CURRENT_USER} [,...] +``` + +### 例 {#set-default-role-examples} + +複数の既定のロールをユーザーに設定する: + +``` sql +SET DEFAULT ROLE role1, role2, ... TO user +``` + +付与されたすべてのロールを既定のユーザーに設定します: + +``` sql +SET DEFAULT ROLE ALL TO user +``` + +ユーザーからの既定の役割の削除: + +``` sql +SET DEFAULT ROLE NONE TO user +``` + +セットの付与の役割としてデフォルトの例外を除き、きっ: + +``` sql +SET DEFAULT ROLE ALL EXCEPT role1, role2 TO user +``` + +## TRUNCATE {#truncate-statement} + +``` sql +TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +表からすべてのデータを削除します。 とき句 `IF EXISTS` テーブルが存在しない場合、クエリはエラーを返します。 + +その `TRUNCATE` クエリはサポートされません [表示](../../engines/table-engines/special/view.md), [ファイル](../../engines/table-engines/special/file.md), [URL](../../engines/table-engines/special/url.md) と [Null](../../engines/table-engines/special/null.md) テーブルエンジン。 + +## USE {#use} + +``` sql +USE db +``` + +セッションの現在のデータベースを設定できます。 +現在のデータベースは、データベースがクエリで明示的に定義されていない場合、テーブルの検索に使用されます。 +セッションの概念がないため、HTTPプロトコルを使用する場合は、このクエリを実行できません。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/ja/sql-reference/statements/revoke.md b/docs/ja/sql-reference/statements/revoke.md new file mode 120000 index 00000000000..4321fdb14a7 --- /dev/null +++ b/docs/ja/sql-reference/statements/revoke.md @@ -0,0 +1 @@ +../../../en/sql-reference/statements/revoke.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/array-join.md b/docs/ja/sql-reference/statements/select/array-join.md new file mode 120000 index 00000000000..c341801e419 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/array-join.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/array-join.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/distinct.md b/docs/ja/sql-reference/statements/select/distinct.md new file mode 120000 index 00000000000..59319557dc1 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/distinct.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/distinct.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/format.md b/docs/ja/sql-reference/statements/select/format.md new file mode 120000 index 00000000000..106b2d9ebbc --- /dev/null +++ b/docs/ja/sql-reference/statements/select/format.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/format.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/from.md b/docs/ja/sql-reference/statements/select/from.md new file mode 120000 index 00000000000..f8ebfe655cc --- /dev/null +++ b/docs/ja/sql-reference/statements/select/from.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/from.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/group-by.md b/docs/ja/sql-reference/statements/select/group-by.md new file mode 120000 index 00000000000..cf519ad7781 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/group-by.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/group-by.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/having.md b/docs/ja/sql-reference/statements/select/having.md new file mode 120000 index 00000000000..4a038beb126 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/having.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/having.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/index.md b/docs/ja/sql-reference/statements/select/index.md new file mode 120000 index 00000000000..9c649322c82 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/index.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/index.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/into-outfile.md b/docs/ja/sql-reference/statements/select/into-outfile.md new file mode 120000 index 00000000000..2c9c812b3d5 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/into-outfile.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/into-outfile.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/join.md b/docs/ja/sql-reference/statements/select/join.md new file mode 120000 index 00000000000..5951a105137 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/join.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/join.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/limit-by.md b/docs/ja/sql-reference/statements/select/limit-by.md new file mode 120000 index 00000000000..f3a63e9fe22 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/limit-by.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/limit-by.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/limit.md b/docs/ja/sql-reference/statements/select/limit.md new file mode 120000 index 00000000000..e0a0c632dac --- /dev/null +++ b/docs/ja/sql-reference/statements/select/limit.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/limit.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/order-by.md b/docs/ja/sql-reference/statements/select/order-by.md new file mode 120000 index 00000000000..cc2567bce0b --- /dev/null +++ b/docs/ja/sql-reference/statements/select/order-by.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/order-by.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/prewhere.md b/docs/ja/sql-reference/statements/select/prewhere.md new file mode 120000 index 00000000000..567fc95356f --- /dev/null +++ b/docs/ja/sql-reference/statements/select/prewhere.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/prewhere.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/sample.md b/docs/ja/sql-reference/statements/select/sample.md new file mode 120000 index 00000000000..9df6e25d0f3 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/sample.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/sample.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/union-all.md b/docs/ja/sql-reference/statements/select/union-all.md new file mode 120000 index 00000000000..837caae2698 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/union-all.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/union-all.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/where.md b/docs/ja/sql-reference/statements/select/where.md new file mode 120000 index 00000000000..8ba28926879 --- /dev/null +++ b/docs/ja/sql-reference/statements/select/where.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/where.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/with.md b/docs/ja/sql-reference/statements/select/with.md new file mode 120000 index 00000000000..8b7ea4db44c --- /dev/null +++ b/docs/ja/sql-reference/statements/select/with.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/with.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/show.md b/docs/ja/sql-reference/statements/show.md new file mode 100644 index 00000000000..8f2ee59a259 --- /dev/null +++ b/docs/ja/sql-reference/statements/show.md @@ -0,0 +1,169 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: SHOW +--- + +# クエリを表示 {#show-queries} + +## SHOW CREATE TABLE {#show-create-table} + +``` sql +SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +単一を返します `String`-タイプ ‘statement’ column, which contains a single value – the `CREATE` 指定したオブジェクトの作成に使用するクエリ。 + +## SHOW DATABASES {#show-databases} + +``` sql +SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] +``` + +一覧の全てのデータベースです。 +このクエリは次と同じです `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. + +## SHOW PROCESSLIST {#show-processlist} + +``` sql +SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] +``` + +の内容を出力します。 [システムプロセス](../../operations/system-tables.md#system_tables-processes) 現在処理されているクエリのリストを含むテーブル。 `SHOW PROCESSLIST` クエリ。 + +その `SELECT * FROM system.processes` クエリを返しますデータに現在のすべてのクエリ. + +Tip(コンソールで実行): + +``` bash +$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" +``` + +## SHOW TABLES {#show-tables} + +テーブルの一覧を表示します。 + +``` sql +SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +もし `FROM` 句が指定されていない場合、クエリは現在のデータベースからテーブルの一覧を返します。 + +と同じ結果を得ることができます `SHOW TABLES` 次の方法でクエリを実行します: + +``` sql +SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**例** + +次のクエリでは、テーブルのリストから最初の二つの行を選択します。 `system` 名前が含まれるデータベース `co`. + +``` sql +SHOW TABLES FROM system LIKE '%co%' LIMIT 2 +``` + +``` text +┌─name───────────────────────────┐ +│ aggregate_function_combinators │ +│ collations │ +└────────────────────────────────┘ +``` + +## SHOW DICTIONARIES {#show-dictionaries} + +のリストを表示します [外部辞書](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +``` sql +SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +もし `FROM` 句が指定されていない場合、クエリは現在のデータベースから辞書のリストを返します。 + +と同じ結果を得ることができます `SHOW DICTIONARIES` 次の方法でクエリを実行します: + +``` sql +SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**例** + +次のクエリでは、テーブルのリストから最初の二つの行を選択します。 `system` 名前が含まれるデータベース `reg`. + +``` sql +SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 +``` + +``` text +┌─name─────────┐ +│ regions │ +│ region_names │ +└──────────────┘ +``` + +## SHOW GRANTS {#show-grants-statement} + +ユーザーの権限を表示します。 + +### 構文 {#show-grants-syntax} + +``` sql +SHOW GRANTS [FOR user] +``` + +Userが指定されていない場合、クエリは現在のユーザーの特権を返します。 + +## SHOW CREATE USER {#show-create-user-statement} + +Aで使用されたパラメータを示します [ユーザー作成](create.md#create-user-statement). + +`SHOW CREATE USER` ユーザパスワードを出力しません。 + +### 構文 {#show-create-user-syntax} + +``` sql +SHOW CREATE USER [name | CURRENT_USER] +``` + +## SHOW CREATE ROLE {#show-create-role-statement} + +Aで使用されたパラメータを示します [ロールの作成](create.md#create-role-statement) + +### 構文 {#show-create-role-syntax} + +``` sql +SHOW CREATE ROLE name +``` + +## SHOW CREATE ROW POLICY {#show-create-row-policy-statement} + +Aで使用されたパラメータを示します [行ポリシーの作成](create.md#create-row-policy-statement) + +### 構文 {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE [ROW] POLICY name ON [database.]table +``` + +## SHOW CREATE QUOTA {#show-create-quota-statement} + +Aで使用されたパラメータを示します [クォータの作成](create.md#create-quota-statement) + +### 構文 {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE QUOTA [name | CURRENT] +``` + +## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile-statement} + +Aで使用されたパラメータを示します [設定プロファイルの作成](create.md#create-settings-profile-statement) + +### 構文 {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE [SETTINGS] PROFILE name +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/ja/sql-reference/statements/system.md b/docs/ja/sql-reference/statements/system.md new file mode 100644 index 00000000000..4f39fd2ac6e --- /dev/null +++ b/docs/ja/sql-reference/statements/system.md @@ -0,0 +1,113 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: SYSTEM +--- + +# システムクエリ {#query-language-system} + +- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) +- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) +- [DROP DNS CACHE](#query_language-system-drop-dns-cache) +- [DROP MARK CACHE](#query_language-system-drop-mark-cache) +- [FLUSH LOGS](#query_language-system-flush_logs) +- [RELOAD CONFIG](#query_language-system-reload-config) +- [SHUTDOWN](#query_language-system-shutdown) +- [KILL](#query_language-system-kill) +- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) +- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) +- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) +- [STOP MERGES](#query_language-system-stop-merges) +- [START MERGES](#query_language-system-start-merges) + +## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} + +以前に正常に読み込まれたすべての辞書を再読み込みします。 +デフォルトでは、辞書は遅延して読み込まれます [dictionaries\_lazy\_load](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load))したがって、起動時に自動的にロードされるのではなく、dictGet関数による最初のアクセス時に初期化されるか、ENGINE=Dictionaryを使用してテーブルから選択されます。 その `SYSTEM RELOAD DICTIONARIES` クエバなどの辞書(ロード). +常に戻ります `Ok.` 辞書の更新の結果に関係なく。 + +## 辞書Dictionary\_nameを再読み込み {#query_language-system-reload-dictionary} + +辞書を完全に再読み込みします `dictionary_name` ディクショナリの状態に関係なく(LOADED/NOT\_LOADED/FAILED)。 +常に戻ります `Ok.` 辞書の更新の結果に関係なく。 +ディクショナリのステータスは、 `system.dictionaries` テーブル。 + +``` sql +SELECT name, status FROM system.dictionaries; +``` + +## DROP DNS CACHE {#query_language-system-drop-dns-cache} + +ClickHouseの内部DNSキャッシュをリセットします。 場合によっては(古いClickHouseバージョンの場合)、インフラストラクチャを変更するとき(別のClickHouseサーバーまたは辞書で使用されているサーバーのIPアドレスを変更す + +より便利な(自動)キャッシュ管理については、"disable\_internal\_dns\_cache,dns\_cache\_update\_periodパラメーター"を参照してください。 + +## DROP MARK CACHE {#query_language-system-drop-mark-cache} + +リセットをマークします。 ClickHouseおよび性能試験の開発で使用される。 + +## FLUSH LOGS {#query_language-system-flush_logs} + +Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. + +## RELOAD CONFIG {#query_language-system-reload-config} + +ClickHouse構成を再読み込みします。 設定がZookeeperに格納されている場合に使用されます。 + +## SHUTDOWN {#query_language-system-shutdown} + +通常はClickHouseをシャットダウンします `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) + +## KILL {#query_language-system-kill} + +クリックハウスプロセスを中止します `kill -9 {$ pid_clickhouse-server}`) + +## 分散テーブルの管理 {#query-language-system-distributed} + +ClickHouseは管理できます [分散](../../engines/table-engines/special/distributed.md) テーブル ユーザーがこれらのテーブルにデータを挿入すると、ClickHouseはまずクラスターノードに送信するデータのキューを作成し、それを非同期に送信します。 キュー処理を管理するには [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed),and [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) クエリ。 分散データを同期して挿入することもできます。 `insert_distributed_sync` 設定。 + +### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} + +を無効にした背景データの分布を挿入する際、データを配布します。 + +``` sql +SYSTEM STOP DISTRIBUTED SENDS [db.] +``` + +### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} + +ClickHouseが強制的にクラスターノードにデータを同期的に送信します。 使用できないノードがある場合、ClickHouseは例外をスローし、クエリの実行を停止します。 これは、すべてのノードがオンラインに戻ったときに発生します。 + +``` sql +SYSTEM FLUSH DISTRIBUTED [db.] +``` + +### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} + +を背景データの分布を挿入する際、データを配布します。 + +``` sql +SYSTEM START DISTRIBUTED SENDS [db.] +``` + +### STOP MERGES {#query_language-system-stop-merges} + +MergeTreeファミリ内のテーブルのバックグラウンドマージを停止できます: + +``` sql +SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] +``` + +!!! note "注" + `DETACH / ATTACH` 以前にすべてのMergeTreeテーブルに対してマージが停止された場合でも、tableはテーブルのバックグラウンドマージを開始します。 + +### START MERGES {#query_language-system-start-merges} + +MergeTreeファミリ内のテーブルのバックグラウンドマージを開始できます: + +``` sql +SYSTEM START MERGES [[db.]merge_tree_family_table_name] +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/ja/sql-reference/syntax.md b/docs/ja/sql-reference/syntax.md new file mode 100644 index 00000000000..9cd128b001c --- /dev/null +++ b/docs/ja/sql-reference/syntax.md @@ -0,0 +1,187 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "\u69CB\u6587" +--- + +# 構文 {#syntax} + +システムのパーサーには、完全SQLパーサー(再帰的降下パーサー)とデータ形式パーサー(高速ストリームパーサー)の二つのタイプがあります。 +を除くすべてのケースで `INSERT` 完全なSQLパーサーのみが使用されます。 +その `INSERT` クエリの両方を使用のパーサ: + +``` sql +INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') +``` + +その `INSERT INTO t VALUES` フラグメントは完全なパーサーによって解析され、データは `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 高速ストリームパーサーによって解析されます。 また、データの完全なパーサーをオンにするには [input\_format\_values\_interpret\_expressions](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) 設定。 とき `input_format_values_interpret_expressions = 1`,ClickHouseはまず、高速ストリームパーサーで値を解析しようとします。 失敗した場合、ClickHouseはデータに対して完全なパーサーを使用し、SQLのように扱います [式](#syntax-expressions). + +データの形式は任意です。 クエリが受信されると、サーバーは以下の値を計算しません [max\_query\_size](../operations/settings/settings.md#settings-max_query_size) 要求のバイトはRAM(デフォルトでは1MB)で、残りはストリーム解析されます。 +これを回避する問題の大き `INSERT` クエリ。 + +を使用する場合 `Values` フォーマット `INSERT` これは、データがaの式と同じように解析されるように見えるかもしれません `SELECT` クエリが、これは真実ではありません。 その `Values` 形式ははるかに限られています。 + +この記事の残りの部分は完全なパーサーをカバーします。 フォーマットパーサーの詳細については、 [形式](../interfaces/formats.md) セクション + +## スペース {#spaces} + +構文構成(クエリの開始と終了を含む)の間には、任意の数のスペースシンボルがあります。 スペース記号には、スペース、タブ、改行、CR、およびフォームフィードがあります。 + +## コメント {#comments} + +ClickHouse支援のいずれかのSQL型は、Cスタイルのコメント. +SQLスタイルのコメントで始まる `--` そして、行の終わり、後のスペースに進みます `--` 省略できる。 +Cスタイルは `/*` に `*/`そして複数行にすることができ、スペースも必要ありません。 + +## キーワード {#syntax-keywords} + +キーワードでは、大文字と小文字が区別されません: + +- SQL標準。 例えば, `SELECT`, `select` と `SeLeCt` すべて有効です。 +- いくつかの一般的なDBMS(MySQLまたはPostgres)での実装。 例えば, `DateTime` と同じです `datetime`. + +データ型名で大文字と小文字が区別されるかどうかは、 `system.data_type_families` テーブル。 + +標準SQLとは対照的に、他のすべてのキーワード(関数名を含む)は次のとおりです **大文字と小文字を区別**. + +キーワードは予約されていません。 を使用する場合 [識別子](#syntax-identifiers) キーワードと同じ名前で、二重引用符またはバッククォートで囲みます。 たとえば、次のクエリです `SELECT "FROM" FROM table_name` テーブルの場合は有効です `table_name` 名前を持つ列があります `"FROM"`. + +## 識別子 {#syntax-identifiers} + +識別子は: + +- クラスターデータベース、テーブル、パーティション、カラム名になってしまいます +- 機能。 +- データ型。 +- [式エイリアス](#syntax-expression_aliases). + +識別子で引用することは非引用されます。 後者が好ましい。 + +非引用識別子に一致しなければならなregex `^[a-zA-Z_][0-9a-zA-Z_]*$` と等しくすることはできません [キーワード](#syntax-keywords). 例: `x, _1, X_y__Z123_.` + +キーワードと同じ識別子を使用する場合や、識別子に他の記号を使用する場合は、二重引用符またはバッククォートを使用して引用符で囲みます。, `"id"`, `` `id` ``. + +## リテラル {#literals} + +数値、文字列、複合、および `NULL` リテラル。 + +### 数値 {#numeric} + +数値リテラルが解析されようとします: + +- まず、64ビット符号付きの数値として、 [ストルトゥール](https://en.cppreference.com/w/cpp/string/byte/strtoul) 機能。 +- 失敗した場合は、64ビット符号なしの数値として、 [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) 機能。 +- 失敗した場合は、浮動小数点数として [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) 機能。 +- それ以外の場合は、エラーを返します。 + +リテラル値は、値が収まる最小の型を持ちます。 +たとえば、1は次のように解析されます `UInt8` しかし、256は次のように解析されます `UInt16`. 詳細については、 [データ型](../sql-reference/data-types/index.md). + +例: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. + +### 文字列 {#syntax-string-literal} + +単一引quotesの文字列リテラルのみがサポートされます。 囲まれた文字はバックスラッシュエスケープできます。 以下のエスケープシーケンスに対応する特殊な値: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. それ以外の場合は、エスケープシーケンスの形式で `\c`,ここで `c` は任意の文字であり、 `c`. つまり、シーケンスを使用できます `\'`と`\\`. この値は [文字列](../sql-reference/data-types/string.md) タイプ。 + +文字列リテラルでは、少なくとも `'` と `\`. 単一引quotesは、単一引quote、リテラルでエスケープできます `'It\'s'` と `'It''s'` 等しい。 + +### 化合物 {#compound} + +配列は角括弧で構成されます `[1, 2, 3]`. Nuplesは丸括弧で構成されています `(1, 'Hello, world!', 2)`. +技術的には、これらはリテラルではなく、それぞれ配列作成演算子とタプル作成演算子を持つ式です。 +配列は少なくとも一つの項目で構成され、組は少なくとも二つの項目を持つ必要があります。 +タプルが表示される場合は別のケースがあります `IN` aの節 `SELECT` クエリ。 クエリ結果には組を含めることができますが、組をデータベースに保存することはできません [メモリ](../engines/table-engines/special/memory.md) エンジン)。 + +### NULL {#null-literal} + +値が欠落していることを示します。 + +保存するために `NULL` テーブルフィールドでは、 [Null可能](../sql-reference/data-types/nullable.md) タイプ。 + +データ形式(入力または出力)に応じて), `NULL` 異なる表現を有していてもよい。 詳細については、以下の文書を参照してください [データ形式](../interfaces/formats.md#formats). + +処理に多くのニュアンスがあります `NULL`. たとえば、比較演算の引数のうち少なくともいずれかが次のようになっている場合 `NULL` この操作の結果も `NULL`. 乗算、加算、およびその他の演算についても同様です。 詳細については、各操作のドキュメントを参照してください。 + +クエリでは、以下を確認できます `NULL` を使用して [IS NULL](operators/index.md#operator-is-null) と [IS NOT NULL](operators/index.md) 演算子と関連する関数 `isNull` と `isNotNull`. + +## 関数 {#functions} + +関数呼び出しは、引数のリスト(空の場合もあります)を丸括弧で囲んだ識別子のように書かれます。 標準のSQLとは対照的に、空の引数リストであっても角かっこが必要です。 例: `now()`. +正規関数と集計関数があります(セクションを参照 “Aggregate functions”). 一部の集計関数を含むことができ二つのリストの引数ットに固定して使用します。 例: `quantile (0.9) (x)`. これらの集計関数は “parametric” 関数と最初のリストの引数が呼び出されます “parameters”. パラメータのない集計関数の構文は、通常の関数と同じです。 + +## 演算子 {#operators} + +演算子は、クエリの解析中に、優先順位と連想を考慮して、対応する関数に変換されます。 +たとえば、次の式は `1 + 2 * 3 + 4` に変換されます `plus(plus(1, multiply(2, 3)), 4)`. + +## データの種類とデータベースのテーブルエンジン {#data_types-and-database-table-engines} + +のデータ型とテーブルエンジン `CREATE` クエリは、識別子または関数と同じ方法で記述されます。 つまり、かっこ内に引数リストを含むことも、含まないこともできます。 詳細については “Data types,” “Table engines,” と “CREATE”. + +## 式エイリアス {#syntax-expression_aliases} + +別名は、クエリ内の式のユーザー定義名です。 + +``` sql +expr AS alias +``` + +- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` を使用せずに句 `AS` キーワード。 + + For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. + + In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. + +- `expr` — Any expression supported by ClickHouse. + + For example, `SELECT column_name * 2 AS double FROM some_table`. + +- `alias` — Name for `expr`. エイリアスは [識別子](#syntax-identifiers) 構文。 + + For example, `SELECT "table t".column_name FROM table_name AS "table t"`. + +### 使用上の注意 {#notes-on-usage} + +エイリアスは、クエリまたはサブクエリのグローバルであり、任意の式のクエリの任意の部分でエイリアスを定義できます。 例えば, `SELECT (1 AS n) + 2, n`. + +エイリアスは、サブクエリおよびサブクエリ間では表示されません。 たとえば、クエリの実行中に `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouseは例外を生成します `Unknown identifier: num`. + +の結果列に対してエイリアスが定義されている場合 `SELECT` サブクエリの句は、これらの列は、外部クエリで表示されます。 例えば, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. + +列名またはテーブル名と同じ別名に注意してください。 次の例を考えてみましょう: + +``` sql +CREATE TABLE t +( + a Int, + b Int +) +ENGINE = TinyLog() +``` + +``` sql +SELECT + argMax(a, b), + sum(b) AS b +FROM t +``` + +``` text +Received exception from server (version 18.14.17): +Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. +``` + +この例では、テーブルを宣言しました `t` 列付き `b`. 次に、データを選択するときに、 `sum(b) AS b` 別名だ としてエイリアスは、グローバルClickHouse置換されているリテラル `b` 式では `argMax(a, b)` 式を使って `sum(b)`. この置換により例外が発生しました。 + +## アスタリスク {#asterisk} + +で `SELECT` クエリー、アスタリスクで置き換え異なるアイコンで表示されます。 詳細については “SELECT”. + +## 式 {#syntax-expressions} + +式は、関数、識別子、リテラル、演算子の適用、角かっこ内の式、サブクエリ、またはアスタリスクです。 別名を含めることもできます。 +式のリストは、カンマで区切られた一つ以上の式です。 +関数と演算子は、引数として式を持つことができます。 + +[元の記事](https://clickhouse.tech/docs/en/sql_reference/syntax/) diff --git a/docs/ja/sql-reference/table-functions/file.md b/docs/ja/sql-reference/table-functions/file.md new file mode 100644 index 00000000000..125ff8bf238 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/file.md @@ -0,0 +1,121 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u30D5\u30A1\u30A4\u30EB" +--- + +# ファイル {#file} + +ファイルからテーブルを作成します。 この表関数は次のようになります [url](url.md) と [hdfs](hdfs.md) ワンズ + +``` sql +file(path, format, structure) +``` + +**入力パラメータ** + +- `path` — The relative path to the file from [user\_files\_path](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-user_files_path). パスファイルをサポートglobに読み取り専用モード: `*`, `?`, `{abc,def}` と `{N..M}` どこに `N`, `M` — numbers, \``'abc', 'def'` — strings. +- `format` — The [形式](../../interfaces/formats.md#formats) ファイルの。 +- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. + +**戻り値** + +テーブルの指定された構造を読み取りまたは書き込みデータを、指定されたファイルです。 + +**例** + +設定 `user_files_path` そして、ファイルの内容 `test.csv`: + +``` bash +$ grep user_files_path /etc/clickhouse-server/config.xml + /var/lib/clickhouse/user_files/ + +$ cat /var/lib/clickhouse/user_files/test.csv + 1,2,3 + 3,2,1 + 78,43,45 +``` + +テーブルから`test.csv` そして、それから最初の二つの行の選択: + +``` sql +SELECT * +FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +``` sql +-- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file +SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 +``` + +**パス内のグロブ** + +複数のパスコンポーネ のための処理中のファイルが存在するマッチのパスのパターンのみならず接尾辞または接頭). + +- `*` — Substitutes any number of any characters except `/` 空の文字列を含む。 +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +構造との `{}` に類似しています [遠隔テーブル機能](../../sql-reference/table-functions/remote.md)). + +**例** + +1. 次の相対パスを持つ複数のファイルがあるとします: + +- ‘some\_dir/some\_file\_1’ +- ‘some\_dir/some\_file\_2’ +- ‘some\_dir/some\_file\_3’ +- ‘another\_dir/some\_file\_1’ +- ‘another\_dir/some\_file\_2’ +- ‘another\_dir/some\_file\_3’ + +1. これらのファイル内の行の量を照会します: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. クエリの量の行のすべてのファイルのディレクトリ: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "警告" + ファイ `?`. + +**例** + +クエリからのデータファイル名 `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## 仮想列 {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**も参照。** + +- [仮想列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/ja/sql-reference/table-functions/generate.md b/docs/ja/sql-reference/table-functions/generate.md new file mode 100644 index 00000000000..0e76b88945e --- /dev/null +++ b/docs/ja/sql-reference/table-functions/generate.md @@ -0,0 +1,44 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: generateRandom +--- + +# generateRandom {#generaterandom} + +をランダムなデータを指定されたschema. +テストテーブルにデータを設定できます。 +テーブルに格納できるすべてのデータ型をサポートします `LowCardinality` と `AggregateFunction`. + +``` sql +generateRandom('name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_string_length'[, 'max_array_length']]]); +``` + +**パラメータ** + +- `name` — Name of corresponding column. +- `TypeName` — Type of corresponding column. +- `max_array_length` — Maximum array length for all generated arrays. Defaults to `10`. +- `max_string_length` — Maximum string length for all generated strings. Defaults to `10`. +- `random_seed` — Specify random seed manually to produce stable results. If NULL — seed is randomly generated. + +**戻り値** + +テーブルオブジェクトご希望のスキーマ. + +## 使用例 {#usage-example} + +``` sql +SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2) LIMIT 3; +``` + +``` text +┌─a────────┬────────────d─┬─c──────────────────────────────────────────────────────────────────┐ +│ [77] │ -124167.6723 │ ('2061-04-17 21:59:44.573','3f72f405-ec3e-13c8-44ca-66ef335f7835') │ +│ [32,110] │ -141397.7312 │ ('1979-02-09 03:43:48.526','982486d1-5a5d-a308-e525-7bd8b80ffa73') │ +│ [68] │ -67417.0770 │ ('2080-03-12 14:17:31.269','110425e5-413f-10a6-05ba-fa6b3e929f15') │ +└──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘ +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/generate/) diff --git a/docs/ja/sql-reference/table-functions/hdfs.md b/docs/ja/sql-reference/table-functions/hdfs.md new file mode 100644 index 00000000000..ccf89095ce9 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/hdfs.md @@ -0,0 +1,104 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: hdfs +--- + +# hdfs {#hdfs} + +HDFS内のファイルからテーブルを作成します。 この表関数は次のようになります [url](url.md) と [ファイル](file.md) ワンズ + +``` sql +hdfs(URI, format, structure) +``` + +**入力パラメータ** + +- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` と `{N..M}` どこに `N`, `M` — numbers, \``'abc', 'def'` — strings. +- `format` — The [形式](../../interfaces/formats.md#formats) ファイルの。 +- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. + +**戻り値** + +テーブルの指定された構造を読み取りまたは書き込みデータを、指定されたファイルです。 + +**例** + +テーブルから `hdfs://hdfs1:9000/test` そして、それから最初の二つの行の選択: + +``` sql +SELECT * +FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +**パス内のグロブ** + +複数のパスコンポーネ のための処理中のファイルが存在するマッチのパスのパターンのみならず接尾辞または接頭). + +- `*` — Substitutes any number of any characters except `/` 空の文字列を含む。 +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +構造との `{}` に類似しています [遠隔テーブル機能](../../sql-reference/table-functions/remote.md)). + +**例** + +1. HDFSに次のUriを持つ複数のファイルがあるとします: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. これらのファイル内の行の量を照会します: + + + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. クエリの量の行のすべてのファイルのディレクトリ: + + + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "警告" + ファイ `?`. + +**例** + +クエリからのデータファイル名 `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## 仮想列 {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**も参照。** + +- [仮想列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/ja/sql-reference/table-functions/index.md b/docs/ja/sql-reference/table-functions/index.md new file mode 100644 index 00000000000..5d8e2592039 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/index.md @@ -0,0 +1,38 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u30C6\u30FC\u30D6\u30EB\u95A2\u6570" +toc_priority: 34 +toc_title: "\u306F\u3058\u3081\u306B" +--- + +# テーブル関数 {#table-functions} + +表関数は、表を構築するためのメソッドです。 + +次の表関数を使用できます: + +- [FROM](../statements/select/from.md) の節 `SELECT` クエリ。 + + The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. + +- [テーブルを\として作成](../statements/create.md#create-table-query) クエリ。 + + It's one of the methods of creating a table. + +!!! warning "警告" + テーブル関数を使用することはできません。 [allow\_ddl](../../operations/settings/permissions-for-queries.md#settings_allow_ddl) 設定は無効です。 + +| 関数 | 説明 | +|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------| +| [ファイル](file.md) | を作成します。 [ファイル](../../engines/table-engines/special/file.md)-エンジンテーブル。 | +| [マージ](merge.md) | を作成します。 [マージ](../../engines/table-engines/special/merge.md)-エンジンテーブル。 | +| [数字](numbers.md) | 整数で満たされた単一の列を持つテーブルを作成します。 | +| [リモート](remote.md) | へ自由にアクセスできるリモートサーバーを作成することなく [分散](../../engines/table-engines/special/distributed.md)-エンジンテーブル。 | +| [url](url.md) | を作成します。 [Url](../../engines/table-engines/special/url.md)-エンジンテーブル。 | +| [mysql](mysql.md) | を作成します。 [MySQL](../../engines/table-engines/integrations/mysql.md)-エンジンテーブル。 | +| [jdbc](jdbc.md) | を作成します。 [JDBC](../../engines/table-engines/integrations/jdbc.md)-エンジンテーブル。 | +| [odbc](odbc.md) | を作成します。 [ODBC](../../engines/table-engines/integrations/odbc.md)-エンジンテーブル。 | +| [hdfs](hdfs.md) | を作成します。 [HDFS](../../engines/table-engines/integrations/hdfs.md)-エンジンテーブル。 | + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/ja/sql-reference/table-functions/input.md b/docs/ja/sql-reference/table-functions/input.md new file mode 100644 index 00000000000..f40be9d250f --- /dev/null +++ b/docs/ja/sql-reference/table-functions/input.md @@ -0,0 +1,47 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: "\u5165\u529B" +--- + +# 入力 {#input} + +`input(structure)` -に送られるデータを効果的に変え、挿入することを可能にする表機能 +別の構造を持つテーブルに指定された構造を持つサーバー。 + +`structure` -以下の形式でサーバーに送信されるデータの構造 `'column1_name column1_type, column2_name column2_type, ...'`. +例えば, `'id UInt32, name String'`. + +この関数は、次の場合にのみ使用できます `INSERT SELECT` それ以外の場合は通常の表関数のように動作します +(例えば、サブクエリなどで使用できます。). + +データは通常のような方法で送信することができます `INSERT` クエリと任意の利用可能に渡されます [形式](../../interfaces/formats.md#formats) +クエリの最後に指定する必要があります(通常とは異なります `INSERT SELECT`). + +この機能の主な特徴は、サーバがクライアントからデータを受信すると同時に変換することです +の式のリストに従って `SELECT` 節とターゲットテーブルへの挿入。 一時テーブル +転送されたすべてのデータは作成されません。 + +**例** + +- は、 `test` 表の構造は次のとおりです `(a String, b String)` + そしてデータ `data.csv` 異なる構造を持っています `(col1 String, col2 Date, col3 Int32)`. 挿入のクエリ + からのデータ `data.csv` に `test` 同時変換のテーブルは次のようになります: + + + +``` bash +$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; +``` + +- もし `data.csv` 同じ構造のデータを含む `test_structure` 表として `test` そしてこれら二つのクエリが等しい: + + + +``` bash +$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV" +$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV" +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/input/) diff --git a/docs/ja/sql-reference/table-functions/jdbc.md b/docs/ja/sql-reference/table-functions/jdbc.md new file mode 100644 index 00000000000..f08c486d32f --- /dev/null +++ b/docs/ja/sql-reference/table-functions/jdbc.md @@ -0,0 +1,29 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: jdbc +--- + +# jdbc {#table-function-jdbc} + +`jdbc(jdbc_connection_uri, schema, table)` -JDBCドライバ経由で接続されたテーブルを返します。 + +このテーブル関数には、別々の `clickhouse-jdbc-bridge` 実行するプログラム。 +Null許容型をサポートします(照会されるリモートテーブルのDDLに基づきます)。 + +**例** + +``` sql +SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') +``` + +``` sql +SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'schema', 'table') +``` + +``` sql +SELECT * FROM jdbc('datasource://mysql-local', 'schema', 'table') +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/ja/sql-reference/table-functions/merge.md b/docs/ja/sql-reference/table-functions/merge.md new file mode 100644 index 00000000000..46981706844 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/merge.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "\u30DE\u30FC\u30B8" +--- + +# マージ {#merge} + +`merge(db_name, 'tables_regexp')` – Creates a temporary Merge table. For more information, see the section “Table engines, Merge”. + +テーブル構造は、正規表現に一致する最初に検出されたテーブルから取得されます。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/merge/) diff --git a/docs/ja/sql-reference/table-functions/mysql.md b/docs/ja/sql-reference/table-functions/mysql.md new file mode 100644 index 00000000000..d7b494bb423 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/mysql.md @@ -0,0 +1,86 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: mysql +--- + +# mysql {#mysql} + +許可 `SELECT` リモートMySQLサーバーに格納されているデータに対して実行されるクエリ。 + +``` sql +mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +**パラメータ** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` へのクエリ `REPLACE INTO`. もし `replace_query=1`、クエリが置き換えられます。 + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` に追加される式 `INSERT` クエリ。 + + Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. + + To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. + +シンプル `WHERE` 次のような句 `=, !=, >, >=, <, <=` 現在、MySQLサーバー上で実行されています。 + +残りの条件と `LIMIT` サンプリング制約は、MySQLへのクエリが終了した後にのみClickHouseで実行されます。 + +**戻り値** + +元のMySQLテーブルと同じ列を持つテーブルオブジェクト。 + +## 使用例 {#usage-example} + +MySQLのテーブル: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +ClickHouseからのデータの選択: + +``` sql +SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## も参照。 {#see-also} + +- [その ‘MySQL’ 表エンジン](../../engines/table-engines/integrations/mysql.md) +- [外部辞書のソースとしてMySQLを使用する](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/ja/sql-reference/table-functions/numbers.md b/docs/ja/sql-reference/table-functions/numbers.md new file mode 100644 index 00000000000..3cc35fc2d82 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/numbers.md @@ -0,0 +1,30 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u6570\u5B57" +--- + +# 数字 {#numbers} + +`numbers(N)` – Returns a table with the single ‘number’ 0からN-1までの整数を含む列(UInt64)。 +`numbers(N, M)` -単一のテーブルを返します ‘number’ nから(N+M-1)までの整数を含む列(UInt64)。 + +に類似した `system.numbers` テーブルに使用でき試験および発生連続値, `numbers(N, M)` より有効 `system.numbers`. + +次のクエリは同等です: + +``` sql +SELECT * FROM numbers(10); +SELECT * FROM numbers(0, 10); +SELECT * FROM system.numbers LIMIT 10; +``` + +例: + +``` sql +-- Generate a sequence of dates from 2010-01-01 to 2010-12-31 +select toDate('2010-01-01') + number as d FROM numbers(365); +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/numbers/) diff --git a/docs/ja/sql-reference/table-functions/odbc.md b/docs/ja/sql-reference/table-functions/odbc.md new file mode 100644 index 00000000000..746a8e44ddf --- /dev/null +++ b/docs/ja/sql-reference/table-functions/odbc.md @@ -0,0 +1,108 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: odbc +--- + +# odbc {#table-functions-odbc} + +接続されているテーブルを返します [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +``` sql +odbc(connection_settings, external_database, external_table) +``` + +パラメータ: + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` ファイル +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +ODBC接続を安全に実装するために、ClickHouseは別のプログラムを使用します `clickhouse-odbc-bridge`. ODBCドライバーが直接ロードされる場合 `clickhouse-server` ドライバの問題でクラッシュのClickHouseサーバーです。 ClickHouseは自動的に起動します `clickhouse-odbc-bridge` それが必要なとき。 ODBC bridgeプログラムは、 `clickhouse-server`. + +を持つフィールド `NULL` 外部テーブルの値は、基本データ型の既定値に変換されます。 たとえば、リモートMySQLテーブルフィールドに `INT NULL` 0に変換される型(ClickHouseのデフォルト値 `Int32` データ型)。 + +## 使用例 {#usage-example} + +**PpsはインタラクティブのMySQLのインストール目盛** + +この例では、Ubuntu Linux18.04およびMySQL server5.7がチェックされています。 + +UnixODBCとMySQL Connectorがインストールされていることを確認します。 + +デフォルトでインストールされた場合、パッケージから),ClickHouse開始してユーザー `clickhouse`. したがって、MySQLサーバでこのユーザを作成して構成する必要があります。 + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +次に、接続を設定します `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +接続を確認するには `isql` unixODBCの取付けからの実用性。 + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +MySQLのテーブル: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +ClickHouseのMySQLテーブルからのデータの取得: + +``` sql +SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ 0 │ 2 │ 0 │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## も参照。 {#see-also} + +- [ODBC外部辞書](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [ODBCテーブルエンジン](../../engines/table-engines/integrations/odbc.md). + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/ja/sql-reference/table-functions/remote.md b/docs/ja/sql-reference/table-functions/remote.md new file mode 100644 index 00000000000..5a68776d93f --- /dev/null +++ b/docs/ja/sql-reference/table-functions/remote.md @@ -0,0 +1,83 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u30EA\u30E2\u30FC\u30C8" +--- + +# リモート、remoteSecure {#remote-remotesecure} + +へ自由にアクセスできるリモートサーバーを作成することなく `Distributed` テーブル。 + +署名: + +``` sql +remote('addresses_expr', db, table[, 'user'[, 'password']]) +remote('addresses_expr', db.table[, 'user'[, 'password']]) +``` + +`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port`、または単に `host`. ホストは、サーバー名またはIPv4またはIPv6アドレスとして指定できます。 IPv6アドレスは角かっこで指定します。 ポートは、リモートサーバー上のTCPポートです。 ポートが省略されると、次のようになります `tcp_port` サーバーの設定ファイルから(デフォルトでは9000)。 + +!!! important "重要" + ポートはIPv6アドレスに必要です。 + +例: + +``` text +example01-01-1 +example01-01-1:9000 +localhost +127.0.0.1 +[::]:9000 +[2a02:6b8:0:1111::11]:9000 +``` + +複数のアドレスはコンマ区切りできます。 この場合、ClickHouseは分散処理を使用するため、指定されたすべてのアドレス(異なるデータを持つシャードなど)にクエリを送信します。 + +例: + +``` text +example01-01-1,example01-02-1 +``` + +式の一部は中括弧で指定できます。 前の例は次のように記述できます: + +``` text +example01-0{1,2}-1 +``` + +中括弧には、二つのドット(非負の整数)で区切られた数値の範囲を含めることができます。 この場合、範囲はシャードアドレスを生成する値のセットに拡張されます。 最初の数値がゼロで始まる場合、値は同じゼロ配置で形成されます。 前の例は次のように記述できます: + +``` text +example01-{01..02}-1 +``` + +中括弧のペアが複数ある場合、対応する集合の直接積を生成します。 + +中括弧の中の住所と住所の一部は、パイプ記号(\|)で区切ることができます。 この場合、対応するアドレスのセットはレプリカとして解釈され、クエリは最初の正常なレプリカに送信されます。 ただし、レプリカは、現在設定されている順序で反復処理されます。 [load\_balancing](../../operations/settings/settings.md) 設定。 + +例: + +``` text +example01-{01..02}-{1|2} +``` + +この例では、レプリカが二つあるシャードを指定します。 + +生成されるアドレスの数は定数によって制限されます。 今これは1000アドレスです。 + +を使用して `remote` テーブル関数は、 `Distributed` この場合、サーバー接続は要求ごとに再確立されるからです。 さらに、ホスト名が設定されている場合、名前は解決され、さまざまなレプリカで作業するときにエラーはカウントされません。 多数のクエリを処理する場合は、常に `Distributed` を使用しないでください。 `remote` テーブル関数。 + +その `remote` 表関数は、次の場合に役立ちます: + +- アクセスの特定のサーバーのためのデータとの比較、デバッグ、テスト実施をしておりました。 +- 研究目的のための様々なClickHouseクラスター間のクエリ。 +- 手動で行われる頻度の低い分散要求。 +- サーバーのセットが毎回定義される分散要求。 + +ユーザーが指定されていない場合, `default` が使用される。 +パスワードを指定しない場合は、空のパスワードが使用されます。 + +`remoteSecure` -同じように `remote` but with secured connection. Default port — [tcp\_port\_secure](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) 設定または9440から。 + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/ja/sql-reference/table-functions/url.md b/docs/ja/sql-reference/table-functions/url.md new file mode 100644 index 00000000000..245bbae29e0 --- /dev/null +++ b/docs/ja/sql-reference/table-functions/url.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: url +--- + +# url {#url} + +`url(URL, format, structure)` -から作成されたテーブルを返します `URL` 与えられたと +`format` と `structure`. + +URL-HTTPまたはHTTPSサーバーアドレス。 `GET` および/または `POST` リクエスト + +形式 - [形式](../../interfaces/formats.md#formats) データの。 + +structure-テーブルの構造 `'UserID UInt64, Name String'` 形式。 列名と型を決定します。 + +**例** + +``` sql +-- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format. +SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3 +``` + +[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/url/) diff --git a/docs/ja/sql_reference/aggregate_functions/combinators.md b/docs/ja/sql_reference/aggregate_functions/combinators.md deleted file mode 100644 index 0aba4497269..00000000000 --- a/docs/ja/sql_reference/aggregate_functions/combinators.md +++ /dev/null @@ -1,166 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u96C6\u8A08\u95A2\u6570\u306E\u30B3\u30F3\u30D3\u30CD\u30FC\u30BF" ---- - -# 集計関数のコンビネータ {#aggregate_functions_combinators} - -集計関数の名前には、それに接尾辞を付けることができます。 これにより、集計関数の動作方法が変更されます。 - -## -もし {#agg-functions-combinator-if} - -The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). - -例: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` というように。 - -条件付集計関数を使用すると、サブクエリを使用せずに複数の条件の集計を一度に計算できます。 `JOIN`例えば、Yandexの中。Metrica、条件付き集約関数は、セグメント比較機能を実装するために使用されます。 - -## -配列 {#agg-functions-combinator-array} - --arrayサフィックスは、任意の集計関数に追加できます。 この場合、aggregate関数は次の引数を取ります ‘Array(T)’ 代わりにタイプ(配列) ‘T’ 型引数。 集計関数が複数の引数を受け入れる場合、これは同じ長さの配列でなければなりません。 配列を処理する場合、aggregate関数は、すべての配列要素にわたって元の集計関数と同様に機能します。 - -例1: `sumArray(arr)` -すべてのすべての要素を合計します ‘arr’ 配列だ この例では、より簡単に書かれている可能性があります: `sum(arraySum(arr))`. - -例2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ 配列だ これは簡単な方法で行うことができます: `uniq(arrayJoin(arr))` しかし、それは常に追加することはできません ‘arrayJoin’ クエリに。 - --Ifと-配列を組み合わせることができます。 しかし, ‘Array’ 第一だから、その ‘If’. 例: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. この順序のために、 ‘cond’ 引数は配列ではありません。 - -## -状態 {#agg-functions-combinator-state} - -このコンビネーターを適用すると、集計関数は結果の値を返しません(たとえば、このコンビネーターの一意の値の数など)。 [uniq](reference.md#agg_function-uniq) の中間状態である。 `uniq`、これは一意の値の数を計算するためのハッシュテーブルです)。 これは `AggregateFunction(...)` これをさらなる処理に使用したり、テーブルに格納して後で集計を完了することができます。 - -これらの国は、利用: - -- [ツつィツ姪"ツつ"ツ債ツづュツつケ](../../engines/table_engines/mergetree_family/aggregatingmergetree.md) テーブルエンジン。 -- [finalizeAggregation](../../sql_reference/functions/other_functions.md#function-finalizeaggregation) 機能。 -- [runningAccumulate](../../sql_reference/functions/other_functions.md#function-runningaccumulate) 機能。 -- [-マージ](#aggregate_functions_combinators_merge) コンビネータ -- [-MergeState](#aggregate_functions_combinators_mergestate) コンビネータ - -## -マージ {#aggregate_functions_combinators-merge} - -このコンビネーターを適用すると、aggregate関数は中間の集約状態を引数として受け取り、状態を結合して集計を終了し、結果の値を返します。 - -## -MergeState {#aggregate_functions_combinators-mergestate} - --mergeコンビネータと同じ方法で中間の集約状態をマージします。 しかし、結果の値を返すのではなく、-stateコンビネータに似た中間の集約状態を返します。 - -## -ForEach {#agg-functions-combinator-foreach} - -テーブルの集計関数を、対応する配列項目を集約して結果の配列を返す配列の集計関数に変換します。 例えば, `sumForEach` 配列の場合 `[1, 2]`, `[3, 4, 5]`と`[6, 7]`結果を返します `[10, 13, 5]` 対応する配列項目を一緒に追加した後。 - -## -オルデフォルト {#agg-functions-combinator-ordefault} - -集約する値が何もない場合は、集計関数の戻り値のデフォルト値を設定します。 - -``` sql -SELECT avg(number), avgOrDefault(number) FROM numbers(0) -``` - -``` text -┌─avg(number)─┬─avgOrDefault(number)─┐ -│ nan │ 0 │ -└─────────────┴──────────────────────┘ -``` - -## -オルヌル {#agg-functions-combinator-ornull} - -塗りつぶし `null` 集計するものがない場合。 戻り列はnull可能になります。 - -``` sql -SELECT avg(number), avgOrNull(number) FROM numbers(0) -``` - -``` text -┌─avg(number)─┬─avgOrNull(number)─┐ -│ nan │ ᴺᵁᴸᴸ │ -└─────────────┴───────────────────┘ -``` - --OrDefaultと-OrNullは他のコンビネータと組み合わせることができます。 これは、集計関数が空の入力を受け入れない場合に便利です。 - -``` sql -SELECT avgOrNullIf(x, x > 10) -FROM -( - SELECT toDecimal32(1.23, 2) AS x -) -``` - -``` text -┌─avgOrNullIf(x, greater(x, 10))─┐ -│ ᴺᵁᴸᴸ │ -└────────────────────────────────┘ -``` - -## -リサンプル {#agg-functions-combinator-resample} - -データをグループに分割し、それらのグループのデータを個別に集計できます。 グループは、ある列の値を間隔に分割することによって作成されます。 - -``` sql -Resample(start, end, step)(, resampling_key) -``` - -**パラメータ** - -- `start` — Starting value of the whole required interval for `resampling_key` 値。 -- `stop` — Ending value of the whole required interval for `resampling_key` 値。 全体の間隔は含まれていません `stop` 値 `[start, stop)`. -- `step` — Step for separating the whole interval into subintervals. The `aggFunction` 実行されるそれぞれのsubintervals。 -- `resampling_key` — Column whose values are used for separating data into intervals. -- `aggFunction_params` — `aggFunction` パラメータ。 - -**戻り値** - -- の配列 `aggFunction` 各サブインターバルの結果。 - -**例えば** - -考慮する `people` テーブルのデータ: - -``` text -┌─name───┬─age─┬─wage─┐ -│ John │ 16 │ 10 │ -│ Alice │ 30 │ 15 │ -│ Mary │ 35 │ 8 │ -│ Evelyn │ 48 │ 11.5 │ -│ David │ 62 │ 9.9 │ -│ Brian │ 60 │ 16 │ -└────────┴─────┴──────┘ -``` - -のは、その年齢の間隔にある人の名前を取得してみましょう `[30,60)` と `[60,75)`. 私たちは年齢の整数表現を使用しているので、私たちはで年齢を取得します `[30, 59]` と `[60,74]` 間隔。 - -配列内の名前を集約するには、次のものを使用します [グルーパー](reference.md#agg_function-grouparray) 集計関数。 それは一つの議論を取る。 私たちの場合、それは `name` コラム その `groupArrayResample` 関数は `age` 年齢別に名前を集計する列。 必要な間隔を定義するために、 `30, 75, 30` への引数 `groupArrayResample` 機能。 - -``` sql -SELECT groupArrayResample(30, 75, 30)(name, age) FROM people -``` - -``` text -┌─groupArrayResample(30, 75, 30)(name, age)─────┐ -│ [['Alice','Mary','Evelyn'],['David','Brian']] │ -└───────────────────────────────────────────────┘ -``` - -結果を考慮する。 - -`Jonh` 彼は若すぎるので、サンプルの外です。 他の人は、指定された年齢区間に従って配布されます。 - -プラグインのインス数の合計人数とその平均賃金には、指定された年齢の間隔とします。 - -``` sql -SELECT - countResample(30, 75, 30)(name, age) AS amount, - avgResample(30, 75, 30)(wage, age) AS avg_wage -FROM people -``` - -``` text -┌─amount─┬─avg_wage──────────────────┐ -│ [3,2] │ [11.5,12.949999809265137] │ -└────────┴───────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/ja/sql_reference/aggregate_functions/index.md b/docs/ja/sql_reference/aggregate_functions/index.md deleted file mode 100644 index d36ade9a637..00000000000 --- a/docs/ja/sql_reference/aggregate_functions/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Aggregate Functions -toc_priority: 33 -toc_title: "\u5C0E\u5165" ---- - -# 集計関数 {#aggregate-functions} - -集計関数は、 [通常の](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) 方法として期待されデータベースの専門家です。 - -ClickHouseはまた支えます: - -- [パラメトリックに集計機能](parametric_functions.md#aggregate_functions_parametric) 列に加えて他のパラメータを受け入れる。 -- [Combinators](combinators.md#aggregate_functions_combinators)、集計関数の動作を変更します。 - -## NULLの場合の処理 {#null-processing} - -集計中、すべて `NULL`sはスキップされます。 - -**例:** - -この表を考慮する: - -``` text -┌─x─┬────y─┐ -│ 1 │ 2 │ -│ 2 │ ᴺᵁᴸᴸ │ -│ 3 │ 2 │ -│ 3 │ 3 │ -│ 3 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -の値を合計する必要があるとしましょう `y` 列: - -``` sql -SELECT sum(y) FROM t_null_big -``` - - ┌─sum(y)─┐ - │ 7 │ - └────────┘ - -その `sum` 関数の解釈 `NULL` として `0`. 特に、これは、関数がすべての値がある選択の入力を受け取った場合 `NULL` その後、結果は次のようになります `0`、ない `NULL`. - -今すぐ使用できます `groupArray` から配列を作成する関数 `y` 列: - -``` sql -SELECT groupArray(y) FROM t_null_big -``` - -``` text -┌─groupArray(y)─┐ -│ [2,2,3] │ -└───────────────┘ -``` - -`groupArray` 含まれていません `NULL` 結果の配列です。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/ja/sql_reference/aggregate_functions/parametric_functions.md b/docs/ja/sql_reference/aggregate_functions/parametric_functions.md deleted file mode 100644 index 6d61ee95c46..00000000000 --- a/docs/ja/sql_reference/aggregate_functions/parametric_functions.md +++ /dev/null @@ -1,499 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: "\u30D1\u30E9\u30E1\u30C8\u30EA\u30C3\u30AF\u96C6\u8A08\u95A2\u6570" ---- - -# パラメトリック集計関数 {#aggregate_functions_parametric} - -Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. - -## ヒストグラム {#histogram} - -適応ヒストグラムを計算します。 正確な結果を保証するものではありません。 - -``` sql -histogram(number_of_bins)(values) -``` - -関数は以下を使用します [ストリーミングの並列決定木アルゴリズム](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). ヒストグラムビンの境界は、新しいデータが関数に入ると調整されます。 一般的なケースでは、ビンの幅は等しくありません。 - -**パラメータ** - -`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. -`values` — [式](../syntax.md#syntax-expressions) その結果、入力値が得られます。 - -**戻り値** - -- [配列](../../sql_reference/data_types/array.md) の [タプル](../../sql_reference/data_types/tuple.md) 次の形式の: - - ``` - [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] - ``` - - - `lower` — Lower bound of the bin. - - `upper` — Upper bound of the bin. - - `height` — Calculated height of the bin. - -**例えば** - -``` sql -SELECT histogram(5)(number + 1) -FROM ( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ -│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -ヒストグラムを視覚化することができます [バー](../../sql_reference/functions/other_functions.md#function-bar) たとえば、関数: - -``` sql -WITH histogram(5)(rand() % 100) AS hist -SELECT - arrayJoin(hist).3 AS height, - bar(height, 0, 6, 5) AS bar -FROM -( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─height─┬─bar───┐ -│ 2.125 │ █▋ │ -│ 3.25 │ ██▌ │ -│ 5.625 │ ████▏ │ -│ 5.625 │ ████▏ │ -│ 3.375 │ ██▌ │ -└────────┴───────┘ -``` - -この場合、ヒストグラムビンの境界線がわからないことを覚えておく必要があります。 - -## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} - -かどうかをチェックします配列を含むイベントのチェーンに一致するパターンです。 - -``` sql -sequenceMatch(pattern)(timestamp, cond1, cond2, ...) -``` - -!!! warning "警告" - 同じ秒で発生するイベントは、結果に影響を与える未定義の順序でシーケンス内に置くことができます。 - -**パラメータ** - -- `pattern` — Pattern string. See [パターン構文](#sequence-function-pattern-syntax). - -- `timestamp` — Column considered to contain time data. Typical data types are `Date` と `DateTime`. も利用できますの対応 [UInt](../../sql_reference/data_types/int_uint.md) データ型。 - -- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. 最大32個の条件引数を渡すことができます。 この関数は、これらの条件で説明されているイベントのみを考慮します。 シーケンスに条件に記述されていないデータが含まれている場合、関数はそれらをスキップします。 - -**戻り値** - -- パターンが一致すれば、1。 -- 0、パターンが一致しない場合。 - -タイプ: `UInt8`. - - -**パターン構文** - -- `(?N)` — Matches the condition argument at position `N`. 条件には、 `[1, 32]` 範囲。 例えば, `(?1)` に渡された引数にマッチします。 `cond1` パラメータ。 - -- `.*` — Matches any number of events. You don't need conditional arguments to match this element of the pattern. - -- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` 互いに1800秒を超えて発生するイベントに一致します。 任意の数は、当社が定めるインターネットを築くことです。 を使用することができ `>=`, `>`, `<`, `<=` 演算子。 - -**例** - -のデータを考慮して下さい `t` テーブル: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -└──────┴────────┘ -``` - -クエリの実行: - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 1 │ -└───────────────────────────────────────────────────────────────────────┘ -``` - -この関数は、番号2が番号1に続くイベントチェーンを見つけました。 数字はイベントとして記述されていないため、3番をスキップしました。 この例で与えられたイベントチェーンを検索するときにこの番号を考慮に入れたい場合は、その条件を作成する必要があります。 - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ -│ 0 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -この場合、関数は、3番のイベントが1と2の間で発生したため、パターンに一致するイベントチェーンを見つけることができませんでした。 同じケースで4の条件をチェックした場合、シーケンスはパターンに一致します。 - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ -│ 1 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**また見なさい** - -- [sequenceCount](#function-sequencecount) - -## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} - -パターンに一致するイベントチェーンの数を数えます。 この関数は、重複しないイベントチェーンを検索します。 現在のチェーンが一致した後、次のチェーンの検索を開始します。 - -!!! warning "警告" - 同じ秒で発生するイベントは、結果に影響を与える未定義の順序でシーケンス内に置くことができます。 - -``` sql -sequenceCount(pattern)(timestamp, cond1, cond2, ...) -``` - -**パラメータ** - -- `pattern` — Pattern string. See [パターン構文](#sequence-function-pattern-syntax). - -- `timestamp` — Column considered to contain time data. Typical data types are `Date` と `DateTime`. も利用できますの対応 [UInt](../../sql_reference/data_types/int_uint.md) データ型。 - -- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. 最大32個の条件引数を渡すことができます。 この関数は、これらの条件で説明されているイベントのみを考慮します。 シーケンスに条件に記述されていないデータが含まれている場合、関数はそれらをスキップします。 - -**戻り値** - -- 一致する重複しないイベントチェーンの数。 - -タイプ: `UInt64`. - -**例えば** - -のデータを考慮して下さい `t` テーブル: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -│ 4 │ 1 │ -│ 5 │ 3 │ -│ 6 │ 2 │ -└──────┴────────┘ -``` - -数2は、それらの間の他の数字の任意の量と数1の後に発生した回数をカウント: - -``` sql -SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 2 │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -**また見なさい** - -- [sequenceMatch](#function-sequencematch) - -## windowfunnelcomment {#windowfunnel} - -スライドタイムウィンドウでイベントチェーンを検索し、チェーンから発生したイベントの最大数を計算します。 - -関数はアルゴリズムに従って動作します: - -- この関数は、チェーン内の最初の条件をトリガーするデータを検索し、イベントカウンターを1に設定します。 これは、スライドウィンドウが始まる瞬間です。 - -- だから、チェーンが順次内のウインドウのカウンタを増加されます。 イベントのシーケンスが中断された場合、カウンターは増分されません。 - -- データにさまざまな完了点で複数のイベントチェーンがある場合、関数は最長チェーンのサイズのみを出力します。 - -**構文** - -``` sql -windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) -``` - -**パラメータ** - -- `window` — Length of the sliding window in seconds. -- `mode` -省略可能な引数です。 - - `'strict'` -とき `'strict'` windowFunnel()は、一意の値に対してのみ条件を適用します。 -- `timestamp` — Name of the column containing the timestamp. Data types supported: [日付](../../sql_reference/data_types/date.md), [DateTime](../../sql_reference/data_types/datetime.md#data_type-datetime) その他の符号なし整数型(timestampがサポートしているにもかかわらず `UInt64` 値はInt64最大値を超えることはできません.2^63-1)。 -- `cond` — Conditions or data describing the chain of events. [UInt8](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -スライディングタイムウィンドウ内のチェーンからの連続トリガー条件の最大数。 -選択内のすべてのチェーンが分析されます。 - -タイプ: `Integer`. - -**例えば** - -ユーザーが電話を選択してオンラインストアで二度購入するのに十分な期間が設定されているかどうかを判断します。 - -次の一連のイベントを設定します: - -1. ユーザーがストアのアカウントにログインした場合 (`eventID = 1003`). -2. ユーザーは電話を検索します (`eventID = 1007, product = 'phone'`). -3. ユーザーが注文した (`eventID = 1009`). -4. ユーザーが再び注文した (`eventID = 1010`). - -入力テーブル: - -``` text -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -``` - -ユーザーの距離を調べる `user_id` を介して得ることができるチェーンで期間で月-月の2019。 - -クエリ: - -``` sql -SELECT - level, - count() AS c -FROM -( - SELECT - user_id, - windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level - FROM trend - WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') - GROUP BY user_id -) -GROUP BY level -ORDER BY level ASC -``` - -結果: - -``` text -┌─level─┬─c─┐ -│ 4 │ 1 │ -└───────┴───┘ -``` - -## 保持 {#retention} - -関数は引数として1から32までの条件のセットを受け取ります。 `UInt8` るかどうかを示す一定の条件を満ためのイベントです。 -任意の条件を引数として指定することができます。 [WHERE](../../sql_reference/statements/select.md#select-where)). - -第一と第二が真であれば第二の結果は真であり、第一と第二が真であれば第三の結果は真である。 - -**構文** - -``` sql -retention(cond1, cond2, ..., cond32); -``` - -**パラメータ** - -- `cond` — an expression that returns a `UInt8` 結果(1または0)。 - -**戻り値** - -1または0の配列。 - -- 1 — condition was met for the event. -- 0 — condition wasn't met for the event. - -タイプ: `UInt8`. - -**例えば** - -の計算の例を考えてみましょう `retention` サイトトラフィックを決定する機能。 - -**1.** Сreate a table to illustrate an example. - -``` sql -CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; - -INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); -INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); -INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); -``` - -入力テーブル: - -クエリ: - -``` sql -SELECT * FROM retention_test -``` - -結果: - -``` text -┌───────date─┬─uid─┐ -│ 2020-01-01 │ 0 │ -│ 2020-01-01 │ 1 │ -│ 2020-01-01 │ 2 │ -│ 2020-01-01 │ 3 │ -│ 2020-01-01 │ 4 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-02 │ 0 │ -│ 2020-01-02 │ 1 │ -│ 2020-01-02 │ 2 │ -│ 2020-01-02 │ 3 │ -│ 2020-01-02 │ 4 │ -│ 2020-01-02 │ 5 │ -│ 2020-01-02 │ 6 │ -│ 2020-01-02 │ 7 │ -│ 2020-01-02 │ 8 │ -│ 2020-01-02 │ 9 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-03 │ 0 │ -│ 2020-01-03 │ 1 │ -│ 2020-01-03 │ 2 │ -│ 2020-01-03 │ 3 │ -│ 2020-01-03 │ 4 │ -│ 2020-01-03 │ 5 │ -│ 2020-01-03 │ 6 │ -│ 2020-01-03 │ 7 │ -│ 2020-01-03 │ 8 │ -│ 2020-01-03 │ 9 │ -│ 2020-01-03 │ 10 │ -│ 2020-01-03 │ 11 │ -│ 2020-01-03 │ 12 │ -│ 2020-01-03 │ 13 │ -│ 2020-01-03 │ 14 │ -└────────────┴─────┘ -``` - -**2.** グループのユーザーによるユニークID `uid` を使用して `retention` 機能。 - -クエリ: - -``` sql -SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r -FROM retention_test -WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') -GROUP BY uid -ORDER BY uid ASC -``` - -結果: - -``` text -┌─uid─┬─r───────┐ -│ 0 │ [1,1,1] │ -│ 1 │ [1,1,1] │ -│ 2 │ [1,1,1] │ -│ 3 │ [1,1,1] │ -│ 4 │ [1,1,1] │ -│ 5 │ [0,0,0] │ -│ 6 │ [0,0,0] │ -│ 7 │ [0,0,0] │ -│ 8 │ [0,0,0] │ -│ 9 │ [0,0,0] │ -│ 10 │ [0,0,0] │ -│ 11 │ [0,0,0] │ -│ 12 │ [0,0,0] │ -│ 13 │ [0,0,0] │ -│ 14 │ [0,0,0] │ -└─────┴─────────┘ -``` - -**3.** 一日あたりのサイト訪問の合計数を計算します。 - -クエリ: - -``` sql -SELECT - sum(r[1]) AS r1, - sum(r[2]) AS r2, - sum(r[3]) AS r3 -FROM -( - SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r - FROM retention_test - WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') - GROUP BY uid -) -``` - -結果: - -``` text -┌─r1─┬─r2─┬─r3─┐ -│ 5 │ 5 │ 5 │ -└────┴────┴────┘ -``` - -どこに: - -- `r1`-2020-01-01の間にサイトを訪問したユニーク訪問者の数 `cond1` 条件)。 -- `r2`-2020-01-01から2020-01-02までの特定の期間にサイトを訪問したユニーク訪問者の数 (`cond1` と `cond2` 条件)。 -- `r3`-2020-01-01から2020-01-03までの特定の期間にサイトを訪問したユニーク訪問者の数 (`cond1` と `cond3` 条件)。 - -## uniqUpTo(N)(x) {#uniquptonx} - -Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. - -小さいnsの使用のために推薦される、10まで。 nの最大値は100です。 - -集計関数の状態については、1+n\*に等しいメモリの量をバイトの一つの値のサイズを使用しています。 -文字列の場合、8バイトの非暗号化ハッシュを格納します。 つまり、計算は文字列に対して近似されます。 - -この関数は、いくつかの引数でも機能します。 - -大きなn値が使用され、一意の値の数がnよりわずかに少ない場合を除いて、できるだけ速く動作します。 - -使用例: - -``` text -Problem: Generate a report that shows only keywords that produced at least 5 unique users. -Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) - -## sumMapFiltered(keys\_to\_keep)(キー、値) {#summapfilteredkeys-to-keepkeys-values} - -同じ動作として [sumMap](reference.md#agg_functions-summap) キーの配列がパラメータとして渡されることを除いて。 これは、キーの高い基数を扱うときに特に便利です。 diff --git a/docs/ja/sql_reference/aggregate_functions/reference.md b/docs/ja/sql_reference/aggregate_functions/reference.md deleted file mode 100644 index fb0f2310100..00000000000 --- a/docs/ja/sql_reference/aggregate_functions/reference.md +++ /dev/null @@ -1,1837 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 36 -toc_title: "\u53C2\u7167" ---- - -# 関数リファレンス {#function-reference} - -## カウント {#agg_function-count} - -行数またはnull以外の値をカウントします。 - -ClickHouseは以下の構文をサポートしています `count`: -- `count(expr)` または `COUNT(DISTINCT expr)`. -- `count()` または `COUNT(*)`. その `count()` 構文はClickHouse固有です。 - -**パラメータ** - -機能は取ることができます: - -- ゼロ変数。 -- ワン [式](../syntax.md#syntax-expressions). - -**戻り値** - -- 関数がパラメータなしで呼び出されると、行数がカウントされます。 -- この [式](../syntax.md#syntax-expressions) が渡されると、この関数は、この式がnullではなく返された回数をカウントします。 式がaを返す場合 [Nullable](../../sql_reference/data_types/nullable.md)-タイプ値、そして結果の `count` 滞在しない `Nullable`. 式が返された場合、関数は0を返します `NULL` すべての行について。 - -どちらの場合も、戻り値の型は次のようになります [UInt64](../../sql_reference/data_types/int_uint.md). - -**詳細** - -クリックハウスは `COUNT(DISTINCT ...)` 構文。 この構成の動作は、 [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation) 設定。 それはどれをの定義します [uniq\*](#agg_function-uniq) 関数は、操作を実行するために使用されます。 デフォルトは [ユニキャック](#agg_function-uniqexact) 機能。 - -その `SELECT count() FROM table` テーブル内のエントリの数が別々に格納されていないため、クエリは最適化されません。 テーブルから小さな列を選択し、その中の値の数を数えます。 - -**例** - -例1: - -``` sql -SELECT count() FROM t -``` - -``` text -┌─count()─┐ -│ 5 │ -└─────────┘ -``` - -例2: - -``` sql -SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' -``` - -``` text -┌─name──────────────────────────┬─value─────┐ -│ count_distinct_implementation │ uniqExact │ -└───────────────────────────────┴───────────┘ -``` - -``` sql -SELECT count(DISTINCT num) FROM t -``` - -``` text -┌─uniqExact(num)─┐ -│ 3 │ -└────────────────┘ -``` - -この例では、 `count(DISTINCT num)` によって実行される。 `uniqExact` に従う機能 `count_distinct_implementation` 設定値。 - -## 任意(x) {#agg_function-any} - -最初に検出された値を選択します。 -クエリは、毎回異なる順序で実行することができるため、この関数の結果は不確定です。 -確定的な結果を得るには、 ‘min’ または ‘max’ 関数の代わりに ‘any’. - -場合によっては、実行順序に頼ることができます。 これは、order byを使用するサブクエリからのselectの場合に適用されます。 - -とき `SELECT` クエリには `GROUP BY` 句または少なくとも一つの集計関数、ClickHouse(MySQLとは対照的に)内のすべての式ということが必要です `SELECT`, `HAVING`、と `ORDER BY` 句は、キーまたは集計関数から計算されます。 つまり、テーブルから選択された各列は、キーまたは集計関数内で使用する必要があります。 MySQLのような動作を得るには、他の列を `any` 集計関数。 - -## anyHeavy(x) {#anyheavyx} - -頻繁に発生する値を選択します。 [ヘビーヒッターズ](http://www.cs.umd.edu/~samir/498/karp.pdf) アルゴリズムだ 各クエリの実行スレッドのケースの半分を超える値がある場合は、この値が返されます。 通常、結果は非決定的です。 - -``` sql -anyHeavy(column) -``` - -**引数** - -- `column` – The column name. - -**例えば** - -を取る [オンタイム](../../getting_started/example_datasets/ontime.md) データセットと選択頻繁に発生する値で `AirlineID` コラム - -``` sql -SELECT anyHeavy(AirlineID) AS res -FROM ontime -``` - -``` text -┌───res─┐ -│ 19690 │ -└───────┘ -``` - -## anyllast(x) {#anylastx} - -最後に検出された値を選択します。 -結果は、次の場合と同様に不確定です `any` 機能。 - -## groupBitAnd {#groupbitand} - -ビットごとの適用 `AND` 一連の数字のために。 - -``` sql -groupBitAnd(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `UInt*` タイプ。 - -**戻り値** - -の値 `UInt*` タイプ。 - -**例えば** - -テストデータ: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -クエリ: - -``` sql -SELECT groupBitAnd(num) FROM t -``` - -どこに `num` テストデータの列です。 - -結果: - -``` text -binary decimal -00000100 = 4 -``` - -## groupBitOr {#groupbitor} - -ビットごとの適用 `OR` 一連の数字のために。 - -``` sql -groupBitOr(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `UInt*` タイプ。 - -**戻り値** - -の値 `UInt*` タイプ。 - -**例えば** - -テストデータ: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -クエリ: - -``` sql -SELECT groupBitOr(num) FROM t -``` - -どこに `num` テストデータの列です。 - -結果: - -``` text -binary decimal -01111101 = 125 -``` - -## groupBitXor {#groupbitxor} - -ビットごとの適用 `XOR` 一連の数字のために。 - -``` sql -groupBitXor(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `UInt*` タイプ。 - -**戻り値** - -の値 `UInt*` タイプ。 - -**例えば** - -テストデータ: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -クエリ: - -``` sql -SELECT groupBitXor(num) FROM t -``` - -どこに `num` テストデータの列です。 - -結果: - -``` text -binary decimal -01101000 = 104 -``` - -## groupBitmap {#groupbitmap} - -符号なし整数列からのビットマップ計算または集計計算を行い、uint64型のカーディナリティを返します。 [ビットマップ](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmap(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `UInt*` タイプ。 - -**戻り値** - -の値 `UInt64` タイプ。 - -**例えば** - -テストデータ: - -``` text -UserID -1 -1 -2 -3 -``` - -クエリ: - -``` sql -SELECT groupBitmap(UserID) as num FROM t -``` - -結果: - -``` text -num -3 -``` - -## 最小(x) {#agg_function-min} - -最小値を計算します。 - -## 最大(x) {#agg_function-max} - -最大値を計算します。 - -## argMin(arg,val) {#agg-function-argmin} - -を計算し ‘arg’ 最小値の値 ‘val’ 値。 いくつかの異なる値がある場合 ‘arg’ のための最小値 ‘val’ これらの値のうち、最初に検出された値が出力されます。 - -**例えば:** - -``` text -┌─user─────┬─salary─┐ -│ director │ 5000 │ -│ manager │ 3000 │ -│ worker │ 1000 │ -└──────────┴────────┘ -``` - -``` sql -SELECT argMin(user, salary) FROM salary -``` - -``` text -┌─argMin(user, salary)─┐ -│ worker │ -└──────────────────────┘ -``` - -## argMax(arg,val) {#agg-function-argmax} - -を計算し ‘arg’ 最大値の値 ‘val’ 値。 いくつかの異なる値がある場合 ‘arg’ の最大値 ‘val’ これらの値のうち、最初に検出された値が出力されます。 - -## sum(x) {#agg_function-sum} - -合計を計算します。 -数字のためにのみ動作します。 - -## sumWithOverflow(x) {#sumwithoverflowx} - -入力パラメーターの結果と同じデータ型を使用して、数値の合計を計算します。 合計がこのデータ型の最大値を超えると、関数はエラーを返します。 - -数字のためにのみ動作します。 - -## sumMap(キー,値) {#agg_functions-summap} - -合計 ‘value’ 配列に指定されたキーに応じて ‘key’ 配列だ -の要素の数 ‘key’ と ‘value’ 合計される行ごとに同じでなければなりません。 -Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. - -例えば: - -``` sql -CREATE TABLE sum_map( - date Date, - timeslot DateTime, - statusMap Nested( - status UInt16, - requests UInt64 - ) -) ENGINE = Log; -INSERT INTO sum_map VALUES - ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10]); -SELECT - timeslot, - sumMap(statusMap.status, statusMap.requests) -FROM sum_map -GROUP BY timeslot -``` - -``` text -┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┐ -│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ -│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ -└─────────────────────┴──────────────────────────────────────────────┘ -``` - -## skewPop {#skewpop} - -を計算します [歪み](https://en.wikipedia.org/wiki/Skewness) シーケンスの。 - -``` sql -skewPop(expr) -``` - -**パラメータ** - -`expr` — [式](../syntax.md#syntax-expressions) 番号を返す。 - -**戻り値** - -The skewness of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md) - -**例えば** - -``` sql -SELECT skewPop(value) FROM series_with_value_column -``` - -## 串焼き {#skewsamp} - -を計算します [サンプルの歪度](https://en.wikipedia.org/wiki/Skewness) シーケンスの。 - -これは、渡された値がそのサンプルを形成する場合、確率変数の歪度の不偏推定値を表します。 - -``` sql -skewSamp(expr) -``` - -**パラメータ** - -`expr` — [式](../syntax.md#syntax-expressions) 番号を返す。 - -**戻り値** - -The skewness of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md). もし `n <= 1` (`n` はサンプルのサイズです)、関数は次の値を返します `nan`. - -**例えば** - -``` sql -SELECT skewSamp(value) FROM series_with_value_column -``` - -## kurtPop {#kurtpop} - -を計算します [尖度](https://en.wikipedia.org/wiki/Kurtosis) シーケンスの。 - -``` sql -kurtPop(expr) -``` - -**パラメータ** - -`expr` — [式](../syntax.md#syntax-expressions) 番号を返す。 - -**戻り値** - -The kurtosis of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md) - -**例えば** - -``` sql -SELECT kurtPop(value) FROM series_with_value_column -``` - -## kurtSamp {#kurtsamp} - -を計算します [サンプル尖度](https://en.wikipedia.org/wiki/Kurtosis) のシーケンスです。 - -これは、渡された値がサンプルを形成する場合、確率変数の尖度の不偏推定値を表します。 - -``` sql -kurtSamp(expr) -``` - -**パラメータ** - -`expr` — [式](../syntax.md#syntax-expressions) 番号を返す。 - -**戻り値** - -The kurtosis of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md). もし `n <= 1` (`n` はサンプルのサイズです)、関数は次の値を返します `nan`. - -**例えば** - -``` sql -SELECT kurtSamp(value) FROM series_with_value_column -``` - -## timeSeriesGroupSum(uid,タイムスタンプ,値) {#agg-function-timeseriesgroupsum} - -`timeSeriesGroupSum` 総異なる時系列のサンプルのタイムスタンプなアライメントを実施します。 -これは、二つのサンプルタイムスタンプ間の線形補間を使用して、一緒に時系列を合計します。 - -- `uid` タイムシリーズの一意のidです, `UInt64`. -- `timestamp` ミリ秒またはマイクロ秒をサポートするためにInt64型です。 -- `value` メトリックです。 - -この関数は、以下のタプルの配列を返します `(timestamp, aggregated_value)` のペアになっています。 - -この機能を使用する前に確認 `timestamp` は昇順です。 - -例えば: - -``` text -┌─uid─┬─timestamp─┬─value─┐ -│ 1 │ 2 │ 0.2 │ -│ 1 │ 7 │ 0.7 │ -│ 1 │ 12 │ 1.2 │ -│ 1 │ 17 │ 1.7 │ -│ 1 │ 25 │ 2.5 │ -│ 2 │ 3 │ 0.6 │ -│ 2 │ 8 │ 1.6 │ -│ 2 │ 12 │ 2.4 │ -│ 2 │ 18 │ 3.6 │ -│ 2 │ 24 │ 4.8 │ -└─────┴───────────┴───────┘ -``` - -``` sql -CREATE TABLE time_series( - uid UInt64, - timestamp Int64, - value Float64 -) ENGINE = Memory; -INSERT INTO time_series VALUES - (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), - (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); - -SELECT timeSeriesGroupSum(uid, timestamp, value) -FROM ( - SELECT * FROM time_series order by timestamp ASC -); -``` - -結果は次のようになります: - -``` text -[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] -``` - -## timeSeriesGroupRateSum(uid,ts,val) {#agg-function-timeseriesgroupratesum} - -同様にtimeseriesgroupratesum、timeseriesgroupratesumは、時系列のレートを計算し、その後、一緒にレートを合計します。 -また、この関数を使用する前にタイムスタンプが昇順になるはずです。 - -この関数を使用すると、上記の結果は次のようになります: - -``` text -[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] -``` - -## 平均(x) {#agg_function-avg} - -平均を計算します。 -数字のためにのみ動作します。 -結果は常にfloat64です。 - -## uniq {#agg_function-uniq} - -引数の異なる値のおおよその数を計算します。 - -``` sql -uniq(x[, ...]) -``` - -**パラメータ** - -この関数は、可変個のパラメータを受け取ります。 変数は `Tuple`, `Array`, `Date`, `DateTime`, `String`、または数値型。 - -**戻り値** - -- A [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ番号。 - -**実装の詳細** - -機能: - -- 集計内のすべてのパラメータのハッシュを計算し、それを計算に使用します。 - -- を使用して適応サンプリングアルゴリズムです。 計算状態の場合、関数は65536までの要素ハッシュ値のサンプルを使用します。 - - This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. - -- 結果を確定的に提供します(クエリ処理の順序に依存しません)。 - -使用をお勧めしますこの機能はほとんど全てのシナリオ. - -**また見なさい** - -- [uniqCombined](#agg_function-uniqcombined) -- [uniqCombined64](#agg_function-uniqcombined64) -- [unihll12](#agg_function-uniqhll12) -- [ユニキャック](#agg_function-uniqexact) - -## uniqCombined {#agg_function-uniqcombined} - -異なる引数値のおおよその数を計算します。 - -``` sql -uniqCombined(HLL_precision)(x[, ...]) -``` - -その `uniqCombined` 関数は、異なる値の数を計算するのに適しています。 - -**パラメータ** - -この関数は、可変個のパラメータを受け取ります。 変数は `Tuple`, `Array`, `Date`, `DateTime`, `String`、または数値型。 - -`HLL_precision` は、2のセル数の底の対数です [ハイパーログ](https://en.wikipedia.org/wiki/HyperLogLog). オプションで、次のように関数を使用できます `uniqCombined(x[, ...])`. のデフォルト値 `HLL_precision` は17で、これは効果的に96KiBのスペース(2^17セル、6ビットそれぞれ)です。 - -**戻り値** - -- を番号 [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ番号。 - -**実装の詳細** - -機能: - -- ハッシュを計算します(64ビットのハッシュ `String` それ以外の場合は32ビット)は、集計内のすべてのパラメータに対して、それを計算に使用します。 - -- 配列、ハッシュテーブル、およびhyperloglogとエラー修正テーブルの組み合わせを使用します。 - - For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. - -- 結果を確定的に提供します(クエリ処理の順序に依存しません)。 - -!!! note "メモ" - それは32ビットハッシュを使用しているので-`String` タイプすると、結果はカーディナリティのエラーが非常に大きくなります `UINT_MAX` (エラーは数十億の異なる値の後にすぐに発生します)、この場合は次のようにしてください [uniqCombined64](#agg_function-uniqcombined64) - -に比べて [uniq](#agg_function-uniq) 機能、を `uniqCombined`: - -- 数回少ないメモリを消費します。 -- 数倍高い精度で計算します。 -- 通常は若干低い性能を持っています。 一部のシナリオでは, `uniqCombined` より良い実行できる `uniq` たとえば、ネットワークを介して多数の集約状態を送信する分散クエリを使用します。 - -**また見なさい** - -- [uniq](#agg_function-uniq) -- [uniqCombined64](#agg_function-uniqcombined64) -- [unihll12](#agg_function-uniqhll12) -- [ユニキャック](#agg_function-uniqexact) - -## uniqCombined64 {#agg_function-uniqcombined64} - -と同じ [uniqCombined](#agg_function-uniqcombined) ただし、すべてのデータ型に64ビットハッシュを使用します。 - -## unihll12 {#agg_function-uniqhll12} - -を使用して、異なる引数値のおおよその数を計算します [ハイパーログ](https://en.wikipedia.org/wiki/HyperLogLog) アルゴリズムだ - -``` sql -uniqHLL12(x[, ...]) -``` - -**パラメータ** - -この関数は、可変個のパラメータを受け取ります。 変数は `Tuple`, `Array`, `Date`, `DateTime`, `String`、または数値型。 - -**戻り値** - -- A [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ番号。 - -**実装の詳細** - -機能: - -- 集計内のすべてのパラメータのハッシュを計算し、それを計算に使用します。 - -- HyperLogLogアルゴリズムを使用して、異なる引数値の数を近似します。 - - 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). - -- 確定的な結果を提供します(クエリ処理の順序に依存しません)。 - -この機能を使用することはお勧めしません。 ほとんどの場合、 [uniq](#agg_function-uniq) または [uniqCombined](#agg_function-uniqcombined) 機能。 - -**また見なさい** - -- [uniq](#agg_function-uniq) -- [uniqCombined](#agg_function-uniqcombined) -- [ユニキャック](#agg_function-uniqexact) - -## ユニキャック {#agg_function-uniqexact} - -異なる引数値の正確な数を計算します。 - -``` sql -uniqExact(x[, ...]) -``` - -を使用 `uniqExact` 機能あなたは絶対に正確な結果が必要な場合。 それ以外の場合は、 [uniq](#agg_function-uniq) 機能。 - -その `uniqExact` 機能の使用ます。 `uniq`、状態のサイズは、異なる値の数が増加するにつれて無制限の成長を有するからである。 - -**パラメータ** - -この関数は、可変個のパラメータを受け取ります。 変数は `Tuple`, `Array`, `Date`, `DateTime`, `String`、または数値型。 - -**また見なさい** - -- [uniq](#agg_function-uniq) -- [uniqCombined](#agg_function-uniqcombined) -- [unihll12](#agg_function-uniqhll12) - -## groupArray(x),groupArray(max\_size)(x) {#agg_function-grouparray} - -引数の値の配列を作成します。 -値は、任意の(不確定な)順序で配列に追加できます。 - -第二のバージョン( `max_size` パラメータ)結果の配列のサイズを次のように制限します `max_size` 要素。 -例えば, `groupArray (1) (x)` に相当します `[any (x)]`. - -場合によっては、実行の順序に依拠することもできます。 これは、次の場合に適用されます `SELECT` 使用するサブクエリーから取得されます `ORDER BY`. - -## groupArrayInsertAt(値、位置) {#grouparrayinsertatvalue-position} - -指定した位置の配列に値を挿入します。 - -!!! note "メモ" - この関数はゼロベースの位置を使用します。 - -Accepts the value and position as input. If several values ​​are inserted into the same position, any of them might end up in the resulting array (the first one will be used in the case of single-threaded execution). If no value is inserted into a position, the position is assigned the default value. - -任意変数: - -- 空の位置に置き換えるためのデフォルト値。 -- 結果の配列の長さ。 これにより、すべての集約キーで同じサイズの配列を受け取ることができます。 このパラメーターを使用する場合は、既定値を指定する必要があります。 - -## グルーパーレイモビングサムcity in new mexico usa {#agg_function-grouparraymovingsum} - -入力値の移動和を計算します。 - -``` sql -groupArrayMovingSum(numbers_for_summing) -groupArrayMovingSum(window_size)(numbers_for_summing) -``` - -この機能できるウィンドウサイズとしてのパラメータとします。 指定しない場合、この関数は、列の行数と同じウィンドウサイズをとります。 - -**パラメータ** - -- `numbers_for_summing` — [式](../syntax.md#syntax-expressions) その結果、数値データ型の値が返されます。 -- `window_size` — Size of the calculation window. - -**戻り値** - -- 入力データと同じサイズおよびタイプの配列。 - -**例えば** - -サンプルテーブル: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -クエリ: - -``` sql -SELECT - groupArrayMovingSum(int) AS I, - groupArrayMovingSum(float) AS F, - groupArrayMovingSum(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingSum(2)(int) AS I, - groupArrayMovingSum(2)(float) AS F, - groupArrayMovingSum(2)(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -## groupparraymovingavg {#agg_function-grouparraymovingavg} - -入力値の移動平均を計算します。 - -``` sql -groupArrayMovingAvg(numbers_for_summing) -groupArrayMovingAvg(window_size)(numbers_for_summing) -``` - -この機能できるウィンドウサイズとしてのパラメータとします。 指定しない場合、この関数は、列の行数と同じウィンドウサイズをとります。 - -**パラメータ** - -- `numbers_for_summing` — [式](../syntax.md#syntax-expressions) その結果、数値データ型の値が返されます。 -- `window_size` — Size of the calculation window. - -**戻り値** - -- 入力データと同じサイズおよびタイプの配列。 - -この関数は [ゼロに向かって丸め](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). 結果のデータ型の小数点以下の桁を切り捨てます。 - -**例えば** - -サンプルテーブル `b`: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -クエリ: - -``` sql -SELECT - groupArrayMovingAvg(int) AS I, - groupArrayMovingAvg(float) AS F, - groupArrayMovingAvg(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ -│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ -└───────────┴─────────────────────────────────────┴───────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingAvg(2)(int) AS I, - groupArrayMovingAvg(2)(float) AS F, - groupArrayMovingAvg(2)(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ -│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ -└───────────┴──────────────────────────────────┴───────────────────────┘ -``` - -## groupUniqArray(x),groupUniqArray(max\_size)(x) {#groupuniqarrayx-groupuniqarraymax-sizex} - -異なる引数値から配列を作成します。 メモリ消費量は、 `uniqExact` 機能。 - -第二のバージョン( `max_size` パラメータ)結果の配列のサイズを次のように制限します `max_size` 要素。 -例えば, `groupUniqArray(1)(x)` に相当します `[any(x)]`. - -## 分位値 {#quantile} - -近似値を計算します [分位値](https://en.wikipedia.org/wiki/Quantile) 数値データシーケンス。 - -この関数が適用されます [貯蔵所の見本抽出](https://en.wikipedia.org/wiki/Reservoir_sampling) 8192までの貯蔵所のサイズおよび見本抽出のための乱数発電機を使って。 結果は非決定的です。 正確な分位値を取得するには、以下を使用します [quantileExact](#quantileexact) 機能。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantile(level)(expr) -``` - -エイリアス: `median`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [データ型](../../sql_reference/data_types/index.md#data_types), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). - -**戻り値** - -- 指定したレベルの概算値。 - -タイプ: - -- [Float64](../../sql_reference/data_types/float.md) 数値データ型の入力。 -- [日付](../../sql_reference/data_types/date.md) 入力値が `Date` タイプ。 -- [DateTime](../../sql_reference/data_types/datetime.md) 入力値が `DateTime` タイプ。 - -**例えば** - -入力テーブル: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -クエリ: - -``` sql -SELECT quantile(val) FROM t -``` - -結果: - -``` text -┌─quantile(val)─┐ -│ 1.5 │ -└───────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## quantiedeterministic {#quantiledeterministic} - -近似値を計算します [分位値](https://en.wikipedia.org/wiki/Quantile) 数値データシーケンス。 - -この関数が適用されます [貯蔵所の見本抽出](https://en.wikipedia.org/wiki/Reservoir_sampling) 8192までの貯蔵所のサイズおよび見本抽出の決定論のアルゴリズムを使って。 結果は決定的です。 正確な分位値を取得するには、以下を使用します [quantileExact](#quantileexact) 機能。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileDeterministic(level)(expr, determinator) -``` - -エイリアス: `medianDeterministic`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [データ型](../../sql_reference/data_types/index.md#data_types), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). -- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. - -**戻り値** - -- 指定したレベルの概算値。 - -タイプ: - -- [Float64](../../sql_reference/data_types/float.md) 数値データ型の入力。 -- [日付](../../sql_reference/data_types/date.md) 入力値が `Date` タイプ。 -- [DateTime](../../sql_reference/data_types/datetime.md) 入力値が `DateTime` タイプ。 - -**例えば** - -入力テーブル: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -クエリ: - -``` sql -SELECT quantileDeterministic(val, 1) FROM t -``` - -結果: - -``` text -┌─quantileDeterministic(val, 1)─┐ -│ 1.5 │ -└───────────────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## quantileExact {#quantileexact} - -正確に計算する [分位値](https://en.wikipedia.org/wiki/Quantile) 数値データシーケンス。 - -To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` メモリ、どこ `n` 渡された値の数です。 しかし、少数の値の場合、関数は非常に効果的です。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileExact(level)(expr) -``` - -エイリアス: `medianExact`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [データ型](../../sql_reference/data_types/index.md#data_types), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). - -**戻り値** - -- 指定されたレベルの分位値。 - -タイプ: - -- [Float64](../../sql_reference/data_types/float.md) 数値データ型の入力。 -- [日付](../../sql_reference/data_types/date.md) 入力値が `Date` タイプ。 -- [DateTime](../../sql_reference/data_types/datetime.md) 入力値が `DateTime` タイプ。 - -**例えば** - -クエリ: - -``` sql -SELECT quantileExact(number) FROM numbers(10) -``` - -結果: - -``` text -┌─quantileExact(number)─┐ -│ 5 │ -└───────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## quantileExactWeighted {#quantileexactweighted} - -正確に計算する [分位値](https://en.wikipedia.org/wiki/Quantile) 各要素の重みを考慮した数値データシーケンス。 - -To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [quantileExact](#quantileexact). この関数は、次の代わりに使用できます `quantileExact` そして、重み1を指定します。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileExactWeighted(level)(expr, weight) -``` - -エイリアス: `medianExactWeighted`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [データ型](../../sql_reference/data_types/index.md#data_types), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). -- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. - -**戻り値** - -- 指定されたレベルの分位値。 - -タイプ: - -- [Float64](../../sql_reference/data_types/float.md) 数値データ型の入力。 -- [日付](../../sql_reference/data_types/date.md) 入力値が `Date` タイプ。 -- [DateTime](../../sql_reference/data_types/datetime.md) 入力値が `DateTime` タイプ。 - -**例えば** - -入力テーブル: - -``` text -┌─n─┬─val─┐ -│ 0 │ 3 │ -│ 1 │ 2 │ -│ 2 │ 1 │ -│ 5 │ 4 │ -└───┴─────┘ -``` - -クエリ: - -``` sql -SELECT quantileExactWeighted(n, val) FROM t -``` - -結果: - -``` text -┌─quantileExactWeighted(n, val)─┐ -│ 1 │ -└───────────────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## クオンタイミング {#quantiletiming} - -決定された精度では、 [分位値](https://en.wikipedia.org/wiki/Quantile) 数値データシーケンス。 - -結果は決定的です(クエリ処理の順序に依存しません)。 この機能を最適化と配列における分布のような積載ウェブページではバックエンド対応。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileTiming(level)(expr) -``` - -エイリアス: `medianTiming`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). - -- `expr` — [式](../syntax.md#syntax-expressions) aを返す列の値を超える [フロート\*](../../sql_reference/data_types/float.md)-タイプ番号。 - - - If negative values are passed to the function, the behavior is undefined. - - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. - -**精度** - -計算は次の場合に正確です: - -- 値の総数は5670を超えません。 -- 値の総数は5670を超えていますが、ページの読み込み時間は1024ms未満です。 - -それ以外の場合、計算の結果は16msの最も近い倍数に丸められます。 - -!!! note "メモ" - ページの読み込み時間の分位数を計算するために、この関数はより効果的で正確です [分位値](#quantile). - -**戻り値** - -- 指定されたレベルの分位値。 - -タイプ: `Float32`. - -!!! note "メモ" - 関数に値が渡されない場合(以下を使用する場合 `quantileTimingIf`), [ナン](../../sql_reference/data_types/float.md#data_type-float-nan-inf) 返されます。 この目的は、これらのケースをゼロになるケースと区別することです。 見る [ORDER BY句](../statements/select.md#select-order-by) ソートに関する注意事項 `NaN` 値。 - -**例えば** - -入力テーブル: - -``` text -┌─response_time─┐ -│ 72 │ -│ 112 │ -│ 126 │ -│ 145 │ -│ 104 │ -│ 242 │ -│ 313 │ -│ 168 │ -│ 108 │ -└───────────────┘ -``` - -クエリ: - -``` sql -SELECT quantileTiming(response_time) FROM t -``` - -結果: - -``` text -┌─quantileTiming(response_time)─┐ -│ 126 │ -└───────────────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## quantitimingweighted {#quantiletimingweighted} - -決定された精度では、 [分位値](https://en.wikipedia.org/wiki/Quantile) 各シーケンスメンバの重みに応じた数値データシーケンス。 - -結果は決定的です(クエリ処理の順序に依存しません)。 この機能を最適化と配列における分布のような積載ウェブページではバックエンド対応。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileTimingWeighted(level)(expr, weight) -``` - -エイリアス: `medianTimingWeighted`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). - -- `expr` — [式](../syntax.md#syntax-expressions) aを返す列の値を超える [フロート\*](../../sql_reference/data_types/float.md)-タイプ番号。 - - - If negative values are passed to the function, the behavior is undefined. - - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. - -- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. - -**精度** - -計算は次の場合に正確です: - -- 値の総数は5670を超えません。 -- 値の総数は5670を超えていますが、ページの読み込み時間は1024ms未満です。 - -それ以外の場合、計算の結果は16msの最も近い倍数に丸められます。 - -!!! note "メモ" - ページの読み込み時間の分位数を計算するために、この関数はより効果的で正確です [分位値](#quantile). - -**戻り値** - -- 指定されたレベルの分位値。 - -タイプ: `Float32`. - -!!! note "メモ" - 関数に値が渡されない場合(以下を使用する場合 `quantileTimingIf`), [ナン](../../sql_reference/data_types/float.md#data_type-float-nan-inf) 返されます。 この目的は、これらのケースをゼロになるケースと区別することです。 見る [ORDER BY句](../statements/select.md#select-order-by) ソートに関する注意事項 `NaN` 値。 - -**例えば** - -入力テーブル: - -``` text -┌─response_time─┬─weight─┐ -│ 68 │ 1 │ -│ 104 │ 2 │ -│ 112 │ 3 │ -│ 126 │ 2 │ -│ 138 │ 1 │ -│ 162 │ 1 │ -└───────────────┴────────┘ -``` - -クエリ: - -``` sql -SELECT quantileTimingWeighted(response_time, weight) FROM t -``` - -結果: - -``` text -┌─quantileTimingWeighted(response_time, weight)─┐ -│ 112 │ -└───────────────────────────────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## quantiletdigestcomment {#quantiletdigest} - -近似値を計算します [分位値](https://en.wikipedia.org/wiki/Quantile) を使用する数値データシーケンスの [t-ダイジェスト](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) アルゴリズムだ - -最大誤差は1%です。 メモリ消費量は `log(n)`、どこ `n` 値の数です。 結果は、クエリの実行順序によって異なり、非決定的です。 - -機能の性能は性能より低いですの [分位値](#quantile) または [クオンタイミング](#quantiletiming). 状態サイズと精度の比に関しては、この関数はよりもはるかに優れています `quantile`. - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileTDigest(level)(expr) -``` - -エイリアス: `medianTDigest`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [データ型](../../sql_reference/data_types/index.md#data_types), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). - -**戻り値** - -- 指定したレベルの概算値。 - -タイプ: - -- [Float64](../../sql_reference/data_types/float.md) 数値データ型の入力。 -- [日付](../../sql_reference/data_types/date.md) 入力値が `Date` タイプ。 -- [DateTime](../../sql_reference/data_types/datetime.md) 入力値が `DateTime` タイプ。 - -**例えば** - -クエリ: - -``` sql -SELECT quantileTDigest(number) FROM numbers(10) -``` - -結果: - -``` text -┌─quantileTDigest(number)─┐ -│ 4.5 │ -└─────────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## quantileTDigestWeighted {#quantiletdigestweighted} - -近似値を計算します [分位値](https://en.wikipedia.org/wiki/Quantile) を使用する数値データシーケンスの [t-ダイジェスト](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) アルゴリズムだ この関数は、各シーケンスメンバーの重みを考慮に入れます。 最大誤差は1%です。 メモリ消費量は `log(n)`、どこ `n` 値の数です。 - -機能の性能は性能より低いですの [分位値](#quantile) または [クオンタイミング](#quantiletiming). 状態サイズと精度の比に関しては、この関数はよりもはるかに優れています `quantile`. - -結果は、クエリの実行順序によって異なり、非決定的です。 - -複数を使用する場合 `quantile*` クエリの異なるレベルを持つ関数は、内部状態が結合されていません(つまり、クエリはそれほど効率的ではありません)。 この場合は、 [分位数](#quantiles) 機能。 - -**構文** - -``` sql -quantileTDigest(level)(expr) -``` - -エイリアス: `medianTDigest`. - -**パラメータ** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` の範囲内の値 `[0.01, 0.99]`. デフォルト値:0.5. で `level=0.5` 機能は計算する [中央値](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [データ型](../../sql_reference/data_types/index.md#data_types), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). -- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. - -**戻り値** - -- 指定したレベルの概算値。 - -タイプ: - -- [Float64](../../sql_reference/data_types/float.md) 数値データ型の入力。 -- [日付](../../sql_reference/data_types/date.md) 入力値が `Date` タイプ。 -- [DateTime](../../sql_reference/data_types/datetime.md) 入力値が `DateTime` タイプ。 - -**例えば** - -クエリ: - -``` sql -SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) -``` - -結果: - -``` text -┌─quantileTDigestWeighted(number, 1)─┐ -│ 4.5 │ -└────────────────────────────────────┘ -``` - -**また見なさい** - -- [中央値](#median) -- [分位数](#quantiles) - -## 中央値 {#median} - -その `median*` 関数は、対応する関数のエイリアスです `quantile*` 機能。 数値データサンプルの中央値を計算します。 - -機能: - -- `median` — Alias for [分位値](#quantile). -- `medianDeterministic` — Alias for [quantiedeterministic](#quantiledeterministic). -- `medianExact` — Alias for [quantileExact](#quantileexact). -- `medianExactWeighted` — Alias for [quantileExactWeighted](#quantileexactweighted). -- `medianTiming` — Alias for [クオンタイミング](#quantiletiming). -- `medianTimingWeighted` — Alias for [quantitimingweighted](#quantiletimingweighted). -- `medianTDigest` — Alias for [quantiletdigestcomment](#quantiletdigest). -- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](#quantiletdigestweighted). - -**例えば** - -入力テーブル: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -クエリ: - -``` sql -SELECT medianDeterministic(val, 1) FROM t -``` - -結果: - -``` text -┌─medianDeterministic(val, 1)─┐ -│ 1.5 │ -└─────────────────────────────┘ -``` - -## quantiles(level1, level2, …)(x) {#quantiles} - -すべての分位数関数には、対応する分位数関数もあります: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. これらの関数は、あるパスでリストされたレベルのすべての分位数を計算し、結果の値の配列を返します。 - -## varSamp(x) {#varsampx} - -金額を計算します `Σ((x - x̅)^2) / (n - 1)`、どこ `n` サンプルサイズは `x̅`の平均値です `x`. - -これは、渡された値がそのサンプルを形成する場合、確率変数の分散の不偏推定値を表します。 - -を返します `Float64`. とき `n <= 1`、戻り値 `+∞`. - -## varPop(x) {#varpopx} - -金額を計算します `Σ((x - x̅)^2) / n`、どこ `n` サンプルサイズは `x̅`の平均値です `x`. - -つまり、値のセットの分散。 を返します `Float64`. - -## stddevSamp(x) {#stddevsampx} - -結果はの平方根に等しい `varSamp(x)`. - -## stddevPop(x) {#stddevpopx} - -結果はの平方根に等しい `varPop(x)`. - -## topK(N)(x) {#topknx} - -指定された列のほぼ最も頻繁に使用される値の配列を返します。 結果の配列は、値のおおよその頻度の降順でソートされます(値そのものではありません)。 - -実装する [ろ過されたスペース節約](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) からのreduce-and-combineアルゴリズムに基づいてTopKを分析するアルゴリズム [パラレル省スペース](https://arxiv.org/pdf/1401.0702.pdf). - -``` sql -topK(N)(column) -``` - -この関数は保証された結果を提供しません。 特定の状況では、エラーが発生し、最も頻度の高い値ではない頻繁な値が返されることがあります。 - -私達は使用を推薦します `N < 10` 価値;性能は大きいと減ります `N` 値。 の最大値 `N = 65536`. - -**パラメータ** - -- ‘N’ 返す要素の数です。 - -パラメーターを省略すると、既定値10が使用されます。 - -**引数** - -- ' x ' – The value to calculate frequency. - -**例えば** - -を取る [オンタイム](../../getting_started/example_datasets/ontime.md) データセットを選択し、最も頻繁に発生する三つの値を選択します。 `AirlineID` コラム - -``` sql -SELECT topK(3)(AirlineID) AS res -FROM ontime -``` - -``` text -┌─res─────────────────┐ -│ [19393,19790,19805] │ -└─────────────────────┘ -``` - -## トップクイット {#topkweighted} - -に似て `topK` しかし、整数型の一つの追加の引数を取ります - `weight`. あらゆる価値は説明されます `weight` 頻度計算のための時間。 - -**構文** - -``` sql -topKWeighted(N)(x, weight) -``` - -**パラメータ** - -- `N` — The number of elements to return. - -**引数** - -- `x` – The value. -- `weight` — The weight. [UInt8](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -最大およその重みの合計を持つ値の配列を返します。 - -**例えば** - -クエリ: - -``` sql -SELECT topKWeighted(10)(number, number) FROM numbers(1000) -``` - -結果: - -``` text -┌─topKWeighted(10)(number, number)──────────┐ -│ [999,998,997,996,995,994,993,992,991,990] │ -└───────────────────────────────────────────┘ -``` - -## covarSamp(x,y) {#covarsampx-y} - -の値を計算します `Σ((x - x̅)(y - y̅)) / (n - 1)`. - -Float64を返します。 とき `n <= 1`, returns +∞. - -## covarPop(x,y) {#covarpopx-y} - -の値を計算します `Σ((x - x̅)(y - y̅)) / n`. - -## corr(x,y) {#corrx-y} - -ピアソン相関係数を計算します: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. - -## categoricalInformationValue {#categoricalinformationvalue} - -の値を計算します `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` 各カテゴリの。 - -``` sql -categoricalInformationValue(category1, category2, ..., tag) -``` - -結果は、離散(カテゴリカル)フィーチャがどのようにして `[category1, category2, ...]` の値を予測する学習モデルに貢献する `tag`. - -## simplelearregression {#simplelinearregression} - -単純な(一次元的な)線形回帰を実行します。 - -``` sql -simpleLinearRegression(x, y) -``` - -パラメータ: - -- `x` — Column with dependent variable values. -- `y` — Column with explanatory variable values. - -戻り値: - -定数 `(a, b)` 結果の行の `y = a*x + b`. - -**例** - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ -│ (1,0) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ -│ (1,3) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## stochasticLinearRegression {#agg_functions-stochasticlinearregression} - -この関数は、確率的線形回帰を実装します。 それは率、l2正則化係数、ミニバッチサイズを学ぶための注文変数を支え、重量を更新するための少数の方法を有する ([アダム](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (デフォルトで使用), [シンプルSGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [勢い](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [ネステロフ](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). - -### パラメータ {#agg_functions-stochasticlinearregression-parameters} - -が4カスタマイズ可能パラメータ。 それらは関数に順番に渡されますが、すべての四つのデフォルト値を渡す必要はありませんが、良いモデルにはいくつかのパラメータ調整が必要で - -``` text -stochasticLinearRegression(1.0, 1.0, 10, 'SGD') -``` - -1. `learning rate` 勾配降下ステップが実行されるときのステップ長の係数です。 大きすぎる学習率の原因となり無限の量のモデルです。 デフォルトは `0.00001`. -2. `l2 regularization coefficient` これは過食防止に役立つ可能性があります。 デフォルトは `0.1`. -3. `mini-batch size` グラデーションディセントのステップを実行するために、グラデーションを計算して合計する要素の数を設定します。 純粋な確率降下は一つの要素を使用しますが、小さなバッチ(約10の要素)を持つことで勾配ステップがより安定します。 デフォルトは `15`. -4. `method for updating weights`、彼らは: `Adam` (デフォルトでは), `SGD`, `Momentum`, `Nesterov`. `Momentum` と `Nesterov` もう少し計算とメモリが必要ですが、確率勾配法の収束と安定性の点で有用です。 - -### 使い方 {#agg_functions-stochasticlinearregression-usage} - -`stochasticLinearRegression` モデルのフィッティングと新しいデータの予測です。 モデルを適合させ、後で使用するためにその状態を保存するために、 `-State` 基本的に状態(モデルの重みなど)を保存するcombinator。 -予測するには、関数を使用します [evalMLMethod](../functions/machine_learning_functions.md#machine_learning_methods-evalmlmethod) これは、状態を予測する機能と同様に引数として取ります。 - - - -**1.** 継手 - -このようなクエリを使用できます。 - -``` sql -CREATE TABLE IF NOT EXISTS train_data -( - param1 Float64, - param2 Float64, - target Float64 -) ENGINE = Memory; - -CREATE TABLE your_model ENGINE = Memory AS SELECT -stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) -AS state FROM train_data; -``` - -ここでは、データを挿入する必要もあります `train_data` テーブル。 パラメータの数は固定されていません。 `linearRegressionState`. 彼らはすべての必要数値です。 -ターゲット値(予測することを学びたい)を持つ列が最初の引数として挿入されることに注意してください。 - -**2.** 予測 - -状態をテーブルに保存した後、予測に複数回使用したり、他の状態とマージして新しいモデルを作成したりすることもできます。 - -``` sql -WITH (SELECT state FROM your_model) AS model SELECT -evalMLMethod(model, param1, param2) FROM test_data -``` - -クエリは予測値の列を返します。 その最初の引数に注意してください `evalMLMethod` は `AggregateFunctionState` オブジェクト、次はフィーチャの列です。 - -`test_data` のようなテーブルです `train_data` が含まれないことがあります。 - -### 備考 {#agg_functions-stochasticlinearregression-notes} - -1. 統合モデルにはユーザーの作成などのクエリ: - `sql SELECT state1 + state2 FROM your_models` - どこに `your_models` テーブルの両方のモデルです。 このクエリはnewを返します `AggregateFunctionState` オブジェクト。 - -2. ユーザーのフェッチのウエイトを作成したモデルとして独自の目的で保存しないモデルについていない場合 `-State` combinatorが使用されます。 - `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` - そのようなクエリはモデルに適合し、その重みを返します-最初はモデルのパラメータに対応する重みです。 したがって、上記の例では、クエリは3つの値を持つ列を返します。 - -**また見なさい** - -- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) -- [線形およびロジスティック回帰の違い](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} - -この関数は、確率論的ロジスティック回帰を実装します。 これは、バイナリ分類問題に使用することができ、stochasticlinearregressionと同じカスタムパラメータをサポートし、同じ方法で動作します。 - -### パラメータ {#agg_functions-stochasticlogisticregression-parameters} - -パラメーターは、stochasticlinearregressionとまったく同じです: -`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. -詳細については、 [パラメータ](#agg_functions-stochasticlinearregression-parameters). - -``` text -stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') -``` - -1. 継手 - - - - See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. - - Predicted labels have to be in \[-1, 1\]. - -1. 予測 - - - - Using saved state we can predict probability of object having label `1`. - - ``` sql - WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) FROM test_data - ``` - - The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. - - We can also set a bound of probability, which assigns elements to different labels. - - ``` sql - SELECT ans < 1.1 AND ans > 0.5 FROM - (WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) AS ans FROM test_data) - ``` - - Then the result will be labels. - - `test_data` is a table like `train_data` but may not contain target value. - -**また見なさい** - -- [stochasticLinearRegression](#agg_functions-stochasticlinearregression) -- [線形およびロジスティック回帰の違い。](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## groupbitmapandgenericname {#groupbitmapand} - -ビットマップ列のandを計算し、型uint64のカーディナリティを返します。 [ビットマップ](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmapAnd(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` タイプ。 - -**戻り値** - -の値 `UInt64` タイプ。 - -**例えば** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapAnd(z)─┐ -│ 3 │ -└───────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ -│ [6,8,10] │ -└──────────────────────────────────────────────────┘ -``` - -## groupBitmapOr {#groupbitmapor} - -ビットマップ列のorを計算し、型uint64のカーディナリティを返します。 [ビットマップ](../../sql_reference/functions/bitmap_functions.md). これは `groupBitmapMerge`. - -``` sql -groupBitmapOr(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` タイプ。 - -**戻り値** - -の値 `UInt64` タイプ。 - -**例えば** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapOr(z)─┐ -│ 15 │ -└──────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ -│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ -└─────────────────────────────────────────────────┘ -``` - -## groupBitmapXor {#groupbitmapxor} - -ビットマップ列のxorを計算し、uint64型のカーディナリティを返します。 [ビットマップ](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmapOr(expr) -``` - -**パラメータ** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` タイプ。 - -**戻り値** - -の値 `UInt64` タイプ。 - -**例えば** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapXor(z)─┐ -│ 10 │ -└───────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ -│ [1,3,5,6,8,10,11,13,14,15] │ -└──────────────────────────────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/ja/sql_reference/ansi.md b/docs/ja/sql_reference/ansi.md deleted file mode 120000 index ee0f9c8cb7e..00000000000 --- a/docs/ja/sql_reference/ansi.md +++ /dev/null @@ -1 +0,0 @@ -../../en/sql_reference/ansi.md \ No newline at end of file diff --git a/docs/ja/sql_reference/data_types/aggregatefunction.md b/docs/ja/sql_reference/data_types/aggregatefunction.md deleted file mode 100644 index 8436f02198f..00000000000 --- a/docs/ja/sql_reference/data_types/aggregatefunction.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 52 -toc_title: AggregateFunction(name,types_of_arguments)...) ---- - -# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} - -Aggregate functions can have an implementation-defined intermediate state that can be serialized to an AggregateFunction(…) data type and stored in a table, usually, by means of [マテリアライズドビュー](../../sql_reference/statements/select.md#create-view). 集計関数の状態を生成する一般的な方法は、集計関数を呼び出すことです `-State` 接尾辞。 将来の集約の最終結果を得るには、同じ集計関数を使用する必要があります `-Merge`接尾辞。 - -`AggregateFunction` — parametric data type. - -**パラメータ** - -- 集計関数の名前。 - - If the function is parametric, specify its parameters too. - -- 集計関数の引数の型です。 - -**例えば** - -``` sql -CREATE TABLE t -( - column1 AggregateFunction(uniq, UInt64), - column2 AggregateFunction(anyIf, String, UInt8), - column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) -) ENGINE = ... -``` - -[uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq),アーニフ ([任意の](../../sql_reference/aggregate_functions/reference.md#agg_function-any)+[もし](../../sql_reference/aggregate_functions/combinators.md#agg-functions-combinator-if))と [分位数](../../sql_reference/aggregate_functions/reference.md) ClickHouseでサポートされている集計関数です。 - -## 使い方 {#usage} - -### データ挿入 {#data-insertion} - -データを挿入するには `INSERT SELECT` 総計を使って `-State`-機能。 - -**関数の例** - -``` sql -uniqState(UserID) -quantilesState(0.5, 0.9)(SendTiming) -``` - -対応する機能とは対照的に `uniq` と `quantiles`, `-State`-関数は、最終的な値の代わりに状態を返します。 言い換えれば、それらは次の値を返します `AggregateFunction` タイプ。 - -の結果で `SELECT` クエリ、値の `AggregateFunction` タイプは、すべてのClickHouse出力形式に対して実装固有のバイナリ表現を持ちます。 たとえば、データをダンプする場合, `TabSeparated` フォーマット `SELECT` このダンプは、次のようにロードされます `INSERT` クエリ。 - -### データ選択 {#data-selection} - -データを選択するとき `AggregatingMergeTree` テーブル、使用 `GROUP BY` 句とデータを挿入するときと同じ集約関数が、 `-Merge`接尾辞。 - -以下の集計関数 `-Merge` suffixは、状態のセットを取得し、それらを結合し、完全なデータ集約の結果を返します。 - -たとえば、次の二つのクエリは同じ結果を返します: - -``` sql -SELECT uniq(UserID) FROM table - -SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) -``` - -## 使用例 {#usage-example} - -見る [ツつィツ姪"ツつ"ツ債ツづュツつケ](../../engines/table_engines/mergetree_family/aggregatingmergetree.md) エンジンの説明。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/ja/sql_reference/data_types/array.md b/docs/ja/sql_reference/data_types/array.md deleted file mode 100644 index c9bd9910bff..00000000000 --- a/docs/ja/sql_reference/data_types/array.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 51 -toc_title: "\u914D\u5217(T)" ---- - -# 配列(t) {#data-type-array} - -の配列 `T`-タイプのアイテム。 `T` 配列を含む任意のデータ型を指定できます。 - -## 配列の作成 {#creating-an-array} - -関数を使用して配列を作成できます: - -``` sql -array(T) -``` - -角括弧を使用することもできます。 - -``` sql -[] -``` - -配列の作成例: - -``` sql -SELECT array(1, 2) AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName(array(1, 2))─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴─────────────────────────┘ -``` - -``` sql -SELECT [1, 2] AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName([1, 2])─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴────────────────────┘ -``` - -## データ型の操作 {#working-with-data-types} - -その場で配列を作成するとき、clickhouseは自動的にすべてのリストされた引数を格納できる最も狭いデータ型として引数の型を定義します。 あれば [Nullable](nullable.md#data_type-nullable) またはリテラル [NULL](../../sql_reference/syntax.md#null-literal) 値は、配列要素の型も次のようになります [Nullable](nullable.md). - -ClickHouseでデータ型を特定できなかった場合は、例外が生成されます。 たとえば、文字列と数値を同時に持つ配列を作成しようとすると、これが発生します (`SELECT array(1, 'a')`). - -自動データ型検出の例: - -``` sql -SELECT array(1, 2, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ -│ [1,2,NULL] │ Array(Nullable(UInt8)) │ -└────────────┴───────────────────────────────┘ -``` - -互換性のないデータ型の配列を作成しようとすると、clickhouseは例外をスローします: - -``` sql -SELECT array(1, 'a') -``` - -``` text -Received exception from server (version 1.1.54388): -Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/array/) diff --git a/docs/ja/sql_reference/data_types/boolean.md b/docs/ja/sql_reference/data_types/boolean.md deleted file mode 100644 index 60e10ece0b2..00000000000 --- a/docs/ja/sql_reference/data_types/boolean.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: "\u30D6\u30FC\u30EB\u5024" ---- - -# ブール値 {#boolean-values} - -ブール値には別の型はありません。 uint8型を使用し、値0または1に制限します。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/boolean/) diff --git a/docs/ja/sql_reference/data_types/date.md b/docs/ja/sql_reference/data_types/date.md deleted file mode 100644 index 701b15f8fca..00000000000 --- a/docs/ja/sql_reference/data_types/date.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 47 -toc_title: "\u65E5\u4ED8" ---- - -# 日付 {#date} - -デートだ 1970-01-01(符号なし)からの日数として二バイトで格納されます。 unixエポックの開始直後から、コンパイル段階で定数によって定義された上限しきい値に値を格納できます(現在、これは2106年までですが、完全にサポート -最小値は0000-00-00として出力されます。 - -日付の値は、タイムゾーンなしで格納されます。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/date/) diff --git a/docs/ja/sql_reference/data_types/datetime.md b/docs/ja/sql_reference/data_types/datetime.md deleted file mode 100644 index 5cb696f0564..00000000000 --- a/docs/ja/sql_reference/data_types/datetime.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 48 -toc_title: DateTime ---- - -# Datetime {#data_type-datetime} - -カレンダーの日付と時刻として表現することができ、時間内にインスタントを格納することができます。 - -構文: - -``` sql -DateTime([timezone]) -``` - -サポートされる値の範囲: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. - -解像度:1秒。 - -## 使用上の注意 {#usage-remarks} - -のとして保存すると、 [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) タイムゾーンまたは夏時間に関係なく。 さらに、 `DateTime` タイプは、列全体で同じタイムゾーンを格納することができます。 `DateTime` 型の値は、テキスト形式で表示され、文字列として指定された値がどのように解析されますか (‘2020-01-01 05:00:01’). タイムゾーンはテーブルの行(またはresultset)に格納されず、列のメタデータに格納されます。 -リストの対応時間帯の [IANA時間帯のデータベース](https://www.iana.org/time-zones). -その `tzdata` パッケージ、含む [IANA時間帯のデータベース](https://www.iana.org/time-zones)、システムに取付けられているべきです。 を使用 `timedatectl list-timezones` ローカルシステ - -タイムゾーンを明示的に設定することができます `DateTime`-テーブルを作成するときに列を入力します。 タイムゾーンが設定されていない場合、ClickHouseはタイムゾーンの値を使用します。 [タイムゾーン](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) クリックハウスサーバーの起動時にサーバー設定またはオペレーティングシステム設定のパラメータ。 - -その [クリックハウス-顧客](../../interfaces/cli.md) データ型の初期化時にタイムゾーンが明示的に設定されていない場合は、既定でサーバーのタイムゾーンを適用します。 クライアントのタイムゾーンを使用するには `clickhouse-client` と `--use_client_time_zone` パラメータ。 - -ClickHouse出力値で `YYYY-MM-DD hh:mm:ss` デフォルトではテキスト形式。 出力を変更するには、次のようにします [formatDateTime](../../sql_reference/functions/date_time_functions.md#formatdatetime) 機能。 - -ClickHouseにデータを挿入するときは、日付と時刻の文字列の異なる形式を使用することができます。 [date\_time\_input\_format](../../operations/settings/settings.md#settings-date_time_input_format) 設定。 - -## 例 {#examples} - -**1.** テーブルを作成する `DateTime`-列を入力してデータを挿入する: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime('Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog; -``` - -``` sql -INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); -``` - -``` sql -SELECT * FROM dt; -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -- Datetimeを整数として挿入すると、Unixタイムスタンプ(UTC)として扱われます。 `1546300800` を表します `'2019-01-01 00:00:00'` UTC。 しかし、として `timestamp` 列は `Europe/Moscow` (UTC+3)タイムゾーン指定、文字列として出力すると、値は次のように表示されます `'2019-01-01 03:00:00'` -- 文字列値をdatetimeとして挿入すると、列timezoneにあるものとして扱われます。 `'2019-01-01 00:00:00'` するものとして扱われる `Europe/Moscow` タイムゾーンとして保存 `1546290000`. - -**2.** フィルタリング `DateTime` 値 - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -`DateTime` 列の値は、文字列値を使用してフィルター処理できます。 `WHERE` 述語。 それはに変換されます `DateTime` 自動的に: - -``` sql -SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -└─────────────────────┴──────────┘ -``` - -**3.** Aのタイムゾーンを取得する `DateTime`-タイプ列: - -``` sql -SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────column─┬─x─────────────────────────┐ -│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ -└─────────────────────┴───────────────────────────┘ -``` - -**4.** タイムゾーン変換 - -``` sql -SELECT -toDateTime(timestamp, 'Europe/London') as lon_time, -toDateTime(timestamp, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────lon_time──┬────────────mos_time─┐ -│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ -│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ -└─────────────────────┴─────────────────────┘ -``` - -## また見なさい {#see-also} - -- [型変換機能](../../sql_reference/functions/type_conversion_functions.md) -- [日付と時刻を操作するための関数](../../sql_reference/functions/date_time_functions.md) -- [配列を操作するための関数](../../sql_reference/functions/array_functions.md) -- [その `date_time_input_format` 設定](../../operations/settings/settings.md#settings-date_time_input_format) -- [その `timezone` サーバ設定パラメータ](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [日付と時刻を操作する演算子](../../sql_reference/operators.md#operators-datetime) -- [その `Date` データ型](date.md) - -[元の記事](https://clickhouse.tech/docs/en/data_types/datetime/) diff --git a/docs/ja/sql_reference/data_types/datetime64.md b/docs/ja/sql_reference/data_types/datetime64.md deleted file mode 100644 index d189ecf2b3b..00000000000 --- a/docs/ja/sql_reference/data_types/datetime64.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 49 -toc_title: DateTime64 ---- - -# Datetime64 {#data_type-datetime64} - -定義されたサブ秒の精度で、カレンダーの日付と時刻として表現することができる時刻にインスタントを格納することができます - -目盛りサイズ(精度):10-精密 秒 - -構文: - -``` sql -DateTime64(precision, [timezone]) -``` - -内部的には、データを次の数として格納します ‘ticks’ エポックスタート(1970-01-01 00:00:00UTC)はInt64です。 目盛りの分解能は、precisionパラメーターによって決まります。 さらに、 `DateTime64` タイプは、列全体で同じタイムゾーンを格納することができます。 `DateTime64` 型の値は、テキスト形式で表示され、文字列として指定された値がどのように解析されますか (‘2020-01-01 05:00:01.000’). タイムゾーンはテーブルの行(またはresultset)に格納されず、列のメタデータに格納されます。 詳細はこちら [DateTime](datetime.md). - -## 例 {#examples} - -**1.** テーブルの作成 `DateTime64`-列を入力してデータを挿入する: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime64(3, 'Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog -``` - -``` sql -INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) -``` - -``` sql -SELECT * FROM dt -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00.000 │ 1 │ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -- Datetimeを整数として挿入すると、適切にスケーリングされたUnixタイムスタンプ(UTC)として扱われます。 `1546300800000` (精度3)を表します `'2019-01-01 00:00:00'` UTC。 しかし、として `timestamp` 列は `Europe/Moscow` (UTC+3)タイムゾーン指定、文字列として出力すると、値は次のように表示されます `'2019-01-01 03:00:00'` -- 文字列値をdatetimeとして挿入すると、列timezoneにあるものとして扱われます。 `'2019-01-01 00:00:00'` れる。 `Europe/Moscow` タイムゾーンとして保存 `1546290000000`. - -**2.** フィルタリング `DateTime64` 値 - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -とは異なり `DateTime`, `DateTime64` 値は変換されません `String` 自動的に - -**3.** Aのタイムゾーンを取得する `DateTime64`-タイプ値: - -``` sql -SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────────column─┬─x──────────────────────────────┐ -│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ -└─────────────────────────┴────────────────────────────────┘ -``` - -**4.** タイムゾーン変換 - -``` sql -SELECT -toDateTime64(timestamp, 3, 'Europe/London') as lon_time, -toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────────lon_time──┬────────────────mos_time─┐ -│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ -│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ -└─────────────────────────┴─────────────────────────┘ -``` - -## また見なさい {#see-also} - -- [タイプ変換関数](../../sql_reference/functions/type_conversion_functions.md) -- [日付と時刻を操作するための関数](../../sql_reference/functions/date_time_functions.md) -- [配列を操作するための関数](../../sql_reference/functions/array_functions.md) -- [その `date_time_input_format` 設定](../../operations/settings/settings.md#settings-date_time_input_format) -- [その `timezone` サーバ設定パラメータ](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [日付と時刻を操作する演算子](../../sql_reference/operators.md#operators-datetime) -- [`Date` データ型](date.md) -- [`DateTime` データ型](datetime.md) diff --git a/docs/ja/sql_reference/data_types/decimal.md b/docs/ja/sql_reference/data_types/decimal.md deleted file mode 100644 index 32bd83fbd85..00000000000 --- a/docs/ja/sql_reference/data_types/decimal.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u5C0F\u6570" ---- - -# 小数点(p,s)、小数点32(s)、小数点64(s)、小数点128(s) {#decimalp-s-decimal32s-decimal64s-decimal128s} - -加算、減算、および乗算の演算時に精度を維持する符号付き固定小数点数。 除算の場合、最下位の数字は破棄されます(丸められていません)。 - -## パラメータ {#parameters} - -- P-精度。 有効な範囲:\[1:38\]。 小数点以下の桁数(分数を含む)を指定します。 -- S-スケール。 有効な範囲:\[0:P\]。 小数部の桁数を指定します。 - -Pパラメータ値に応じてDecimal(P,S)は以下のシノニムです: --Pから\[1:9\]-用Decimal32(S) --Pから\[10:18\]-用Decimal64(S) --Pから\[19:38\]-用Decimal128(S) - -## 小数値の範囲 {#decimal-value-ranges} - -- デシマル32(s) - ( -1 \* 10^(9 - s)、1\*10^(9-s) ) -- Decimal64(S) - ( -1 \* 10^(18 - S)、1\*10^(18-S) ) -- Decimal128(S) - ( -1 \* 10^(38 - S)、1\*10^(38-S) ) - -たとえば、decimal32(4)には、-99999.9999から99999.9999までの0.0001ステップの数値を含めることができます。 - -## 内部表現 {#internal-representation} - -社内データとして表される通常の署名の整数をそれぞれのビット幅になります。 メモリに格納できる実際の値の範囲は、上記で指定した値より少し大きくなり、文字列からの変換でのみチェックされます。 - -現代のcpuはネイティブに128ビットの整数をサポートしていないため、decimal128の演算はエミュレートされます。 このため、decimal128はdecimal32/decimal64よりも大幅に遅く動作します。 - -## 操作と結果の種類 {#operations-and-result-type} - -Decimalのバイナリ演算では、結果の型が広くなります(引数の順序は任意です)。 - -- Decimal64(S1) Decimal32(S2)-\>Decimal64(S) -- デシマル128(s1) Decimal32(S2)-\>Decimal128S) -- デシマル128(s1) Decimal64(S2)-\>Decimal128(S) - -スケールのルール: - -- 加算、減算:S=最大(S1、S2)。 -- multuply:S=S1+S2. -- 分割:S=S1。 - -Decimalと整数の間の同様の演算の場合、結果は引数と同じサイズのDecimalになります。 - -DecimalとFloat32/Float64の間の演算は定義されていません。 それらが必要な場合は、toDecimal32、toDecimal64、toDecimal128またはtoFloat32、tofat64組み込み関数を使用して明示的に引数をキャストできます。 結果は精度を失い、型変換は計算コストのかかる演算であることに注意してください。 - -Decimalの一部の関数は、Float64として結果を返します(たとえば、varまたはstddev)。 これは、Float64とDecimal入力の間で同じ値を持つ異なる結果につながる可能性があります。 - -## オーバーフロ {#overflow-checks} - -中計算は小数,整数であふれかが起こる。 小数部の余分な桁は破棄されます(丸められていません)。 整数部分の数字が多すぎると、例外が発生します。 - -``` sql -SELECT toDecimal32(2, 4) AS x, x / 3 -``` - -``` text -┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ -│ 2.0000 │ 0.6666 │ -└────────┴──────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, x * x -``` - -``` text -DB::Exception: Scale is out of bounds. -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -DB::Exception: Decimal math overflow. -``` - -オーバーフローチェックが業務に減速した。 オーバーフローが不可能であることがわかっている場合は、 `decimal_check_overflow` 設定。 時チェックを無効とオーバーフローが起こり、結果は正しくあり: - -``` sql -SET decimal_check_overflow = 0; -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ -│ 4.20000000 │ -17.74967296 │ -└────────────┴──────────────────────────────────┘ -``` - -オーバーフローチェックは算術演算だけでなく、値の比較にも発生します: - -``` sql -SELECT toDecimal32(1, 8) < 100 -``` - -``` text -DB::Exception: Can't compare. -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/decimal/) diff --git a/docs/ja/sql_reference/data_types/domains/index.md b/docs/ja/sql_reference/data_types/domains/index.md deleted file mode 100644 index 3a743f84290..00000000000 --- a/docs/ja/sql_reference/data_types/domains/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Domains -toc_priority: 56 ---- - - diff --git a/docs/ja/sql_reference/data_types/domains/ipv4.md b/docs/ja/sql_reference/data_types/domains/ipv4.md deleted file mode 100644 index 983ca07d184..00000000000 --- a/docs/ja/sql_reference/data_types/domains/ipv4.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 59 -toc_title: IPv4 ---- - -## IPv4 {#ipv4} - -`IPv4` ドメインは以下に基づきます `UInt32` 入力し、IPv4値を格納するための型指定された置換として機能します。 それは点検で人間に適する入出力形式およびコラムのタイプ情報を密集した貯蔵に与える。 - -### 基本的な使用法 {#basic-usage} - -``` sql -CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY url; - -DESCRIBE TABLE hits; -``` - -``` text -┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ -│ url │ String │ │ │ │ │ -│ from │ IPv4 │ │ │ │ │ -└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ -``` - -または、ipv4ドメインをキーとして使用できます: - -``` sql -CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; -``` - -`IPv4` ドメインはIPv4文字列としてカスタム入力形式をサポート: - -``` sql -INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.tech', '183.247.232.58')('https://clickhouse.yandex/docs/en/', '116.106.34.242'); - -SELECT * FROM hits; -``` - -``` text -┌─url────────────────────────────────┬───────────from─┐ -│ https://clickhouse.tech/docs/en/ │ 116.106.34.242 │ -│ https://wikipedia.org │ 116.253.40.133 │ -│ https://clickhouse.tech │ 183.247.232.58 │ -└────────────────────────────────────┴────────────────┘ -``` - -値が格納されコンパクトにバイナリ形式: - -``` sql -SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(from)─┬─hex(from)─┐ -│ IPv4 │ B7F7E83A │ -└──────────────────┴───────────┘ -``` - -ドメイン値は、以下の型以外の型に暗黙的に変換できません `UInt32`. -変換したい場合 `IPv4` 値を文字列に変換するには、それを明示的に行う必要があります `IPv4NumToString()` 機能: - -``` sql -SELECT toTypeName(s), IPv4NumToString(from) as s FROM hits LIMIT 1; -``` - - ┌─toTypeName(IPv4NumToString(from))─┬─s──────────────┐ - │ String │ 183.247.232.58 │ - └───────────────────────────────────┴────────────────┘ - -または `UInt32` 値: - -``` sql -SELECT toTypeName(i), CAST(from as UInt32) as i FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(CAST(from, 'UInt32'))─┬──────────i─┐ -│ UInt32 │ 3086477370 │ -└──────────────────────────────────┴────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/domains/ipv4) diff --git a/docs/ja/sql_reference/data_types/domains/ipv6.md b/docs/ja/sql_reference/data_types/domains/ipv6.md deleted file mode 100644 index 268bde0ff06..00000000000 --- a/docs/ja/sql_reference/data_types/domains/ipv6.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 60 -toc_title: IPv6 ---- - -## IPv6 {#ipv6} - -`IPv6` ドメインは以下に基づきます `FixedString(16)` タイプと入力の代替品の保管IPv6数値です。 それは点検で人間に適する入出力形式およびコラムのタイプ情報を密集した貯蔵に与える。 - -### 基本的な使用法 {#basic-usage} - -``` sql -CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url; - -DESCRIBE TABLE hits; -``` - -``` text -┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ -│ url │ String │ │ │ │ │ -│ from │ IPv6 │ │ │ │ │ -└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ -``` - -またはあなたが使用 `IPv6` 鍵としてのドメイン: - -``` sql -CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from; -``` - -`IPv6` ドメイン対応のカスタム入力としてIPv6-文字列: - -``` sql -INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.tech', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.yandex/docs/en/', '2a02:e980:1e::1'); - -SELECT * FROM hits; -``` - -``` text -┌─url────────────────────────────────┬─from──────────────────────────┐ -│ https://clickhouse.tech │ 2001:44c8:129:2632:33:0:252:2 │ -│ https://clickhouse.tech/docs/en/ │ 2a02:e980:1e::1 │ -│ https://wikipedia.org │ 2a02:aa08:e000:3100::2 │ -└────────────────────────────────────┴───────────────────────────────┘ -``` - -値が格納されコンパクトにバイナリ形式: - -``` sql -SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(from)─┬─hex(from)────────────────────────┐ -│ IPv6 │ 200144C8012926320033000002520002 │ -└──────────────────┴──────────────────────────────────┘ -``` - -ドメイン値は、以下の型以外の型に暗黙的に変換できません `FixedString(16)`. -変換したい場合 `IPv6` 値を文字列に変換するには、それを明示的に行う必要があります `IPv6NumToString()` 機能: - -``` sql -SELECT toTypeName(s), IPv6NumToString(from) as s FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(IPv6NumToString(from))─┬─s─────────────────────────────┐ -│ String │ 2001:44c8:129:2632:33:0:252:2 │ -└───────────────────────────────────┴───────────────────────────────┘ -``` - -または `FixedString(16)` 値: - -``` sql -SELECT toTypeName(i), CAST(from as FixedString(16)) as i FROM hits LIMIT 1; -``` - -``` text -┌─toTypeName(CAST(from, 'FixedString(16)'))─┬─i───────┐ -│ FixedString(16) │ ��� │ -└───────────────────────────────────────────┴─────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/domains/ipv6) diff --git a/docs/ja/sql_reference/data_types/domains/overview.md b/docs/ja/sql_reference/data_types/domains/overview.md deleted file mode 100644 index 24a14055491..00000000000 --- a/docs/ja/sql_reference/data_types/domains/overview.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 58 -toc_title: "\u6982\u8981" ---- - -# 藩 {#domains} - -ドメインは、既存の基本タイプの上にいくつかの追加機能を追加する特別な目的のタイプですが、基になるデータタイプのオンワイヤとオンディス 現時点では、clickhouseはユーザー定義ドメインをサポートしていません。 - -ドメインは、対応する基本タイプを使用できる任意の場所で使用できます。: - -- ドメイン型の列を作成する -- ドメイン列からの値の読み取り/書き込み -- 基本型をインデックスとして使用できる場合は、インデックスとして使用します -- ドメイン列の値を持つ関数の呼び出し - -### ドメインの追加機能 {#extra-features-of-domains} - -- 明示的な列タイプ名in `SHOW CREATE TABLE` または `DESCRIBE TABLE` -- 人間に優しいフォーマットからの入力 `INSERT INTO domain_table(domain_column) VALUES(...)` -- 人間に優しいフォーマットへの出力 `SELECT domain_column FROM domain_table` -- 人間に優しい形式で外部ソースからデータをロードする: `INSERT INTO domain_table FORMAT CSV ...` - -### 制限 {#limitations} - -- ベース型のインデックス列をドメイン型に変換できません `ALTER TABLE`. -- できない暗黙的に変換し文字列値がコマンドライン値を挿入する際、データから別のテーブルや列. -- ドメインは、格納された値に制約を追加しません。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/domains/overview) diff --git a/docs/ja/sql_reference/data_types/enum.md b/docs/ja/sql_reference/data_types/enum.md deleted file mode 100644 index 45705f0b608..00000000000 --- a/docs/ja/sql_reference/data_types/enum.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 50 -toc_title: "\u5217\u6319\u578B" ---- - -# 列挙型 {#enum} - -名前付きの値で構成される列挙型。 - -名前の値として宣言された `'string' = integer` ペア。 ClickHouseは数字のみを格納しますが、名前による値の操作をサポートします。 - -ClickHouse支援: - -- 8ビット `Enum`. それはで列挙可能な256までの値を含むことができます `[-128, 127]` 範囲。 -- 16ビット `Enum`. それはで列挙可能な65536まで値を含むことができます `[-32768, 32767]` 範囲。 - -ClickHouseは自動的に次のタイプを選択します `Enum` データが挿入されるとき。 また、 `Enum8` または `Enum16` ストレージのサイズを確認するタイプ。 - -## 使用例 {#usage-examples} - -ここでは、 `Enum8('hello' = 1, 'world' = 2)` タイプ列: - -``` sql -CREATE TABLE t_enum -( - x Enum('hello' = 1, 'world' = 2) -) -ENGINE = TinyLog -``` - -列 `x` 型定義にリストされている値のみを格納できます: `'hello'` または `'world'`. 他の値を保存しようとすると、ClickHouseは例外を発生させます。 このため8ビットサイズ `Enum` 自動的に選択されます。 - -``` sql -INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') -``` - -``` text -Ok. -``` - -``` sql -INSERT INTO t_enum values('a') -``` - -``` text -Exception on client: -Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) -``` - -テーブルからデータをクエリすると、clickhouseから文字列の値が出力されます `Enum`. - -``` sql -SELECT * FROM t_enum -``` - -``` text -┌─x─────┐ -│ hello │ -│ world │ -│ hello │ -└───────┘ -``` - -行に相当する数値を表示する必要がある場合は、次の行をキャストする必要があります `Enum` 整数型への値。 - -``` sql -SELECT CAST(x, 'Int8') FROM t_enum -``` - -``` text -┌─CAST(x, 'Int8')─┐ -│ 1 │ -│ 2 │ -│ 1 │ -└─────────────────┘ -``` - -クエリで列挙値を作成するには、次のものも使用する必要があります `CAST`. - -``` sql -SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) -``` - -``` text -┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ -│ Enum8('a' = 1, 'b' = 2) │ -└─────────────────────────────────────────────────────┘ -``` - -## 一般的なルールと使用法 {#general-rules-and-usage} - -各値には、範囲内の数値が割り当てられます `-128 ... 127` のために `Enum8` または範囲で `-32768 ... 32767` のために `Enum16`. すべての文字列と数字は異なる必要があります。 空の文字列が許可されます。 この型が(テーブル定義で)指定されている場合、数値は任意の順序で指定できます。 しかし、順序は重要ではありません。 - -文字列と数値のどちらも `Enum` できる。 [NULL](../../sql_reference/syntax.md). - -アン `Enum` に含まれることができる [Nullable](nullable.md) タイプ。 そのため、クエリを使用してテーブルを作成する場合 - -``` sql -CREATE TABLE t_enum_nullable -( - x Nullable( Enum8('hello' = 1, 'world' = 2) ) -) -ENGINE = TinyLog -``` - -それだけでなく、 `'hello'` と `'world'`、しかし `NULL` 同様に、。 - -``` sql -INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) -``` - -ラムでは、 `Enum` 列は次のように保存されます `Int8` または `Int16` 対応する数値の。 - -テキストフォームで読み取る場合、clickhouseは値を文字列として解析し、一連のenum値から対応する文字列を検索します。 見つからない場合は、例外がスローされます。 テキスト形式で読み込むと、文字列が読み込まれ、対応する数値が検索されます。 見つからない場合は、例外がスローされます。 -テキスト形式で書くときは、値を対応する文字列として書き込みます。 列データにガベージ(有効なセットに含まれていない数値)が含まれている場合は、例外がスローされます。 バイナリ形式で読み書きするときは、int8とint16のデータ型と同じように動作します。 -暗黙的なデフォルト値は、数値が最も小さい値です。 - -の間 `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` そして、Enumは対応する数字と同じように動作します。 たとえば、ORDER BYは数値的に並べ替えます。 等価演算子と比較演算子は、基になる数値と同じようにEnumでも機能します。 - -Enum値を数値と比較することはできません。 列挙型は、定数文字列と比較できます。 比較された文字列が列挙型の有効な値でない場合は、例外がスローされます。 IN演算子は、左側の列挙型と右側の文字列のセットでサポートされています。 文字列は、対応する列挙型の値です。 - -Most numeric and string operations are not defined for Enum values, e.g. adding a number to an Enum or concatenating a string to an Enum. -しかし、列挙型は自然を持っています `toString` 文字列値を返す関数。 - -また、enumの値は、以下を使用して数値型に変換できます。 `toT` ここで、Tは数値型です。 Tが列挙型の基になる数値型に対応する場合、この変換はゼロコストになります。 -値のセットのみが変更された場合、列挙型は、alterを使用してコストをかけずに変更できます。 alterを使用して列挙型のメンバーを追加および削除することができます(削除された値がテーブルで一度も使用されていない場合にのみ、削除は安全で セーフガードとして、以前に定義されたenumメンバの数値を変更すると例外がスローされます。 - -ALTERを使用すると、Int8をInt16に変更するのと同じように、Enum8をEnum16に変更することも、その逆も可能です。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/enum/) diff --git a/docs/ja/sql_reference/data_types/fixedstring.md b/docs/ja/sql_reference/data_types/fixedstring.md deleted file mode 100644 index ae9a23581da..00000000000 --- a/docs/ja/sql_reference/data_types/fixedstring.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: FixedString(N) ---- - -# Fixedstring {#fixedstring} - -の固定長文字列 `N` バイト(文字もコードポイントもない)。 - -の列を宣言するには `FixedString` タイプ、次の構文を使用します: - -``` sql - FixedString(N) -``` - -どこに `N` 自然数です。 - -その `FixedString` 型は、データの長さが正確である場合に効率的です `N` バイト。 他のすべてのケースでは、効率を低下させる可能性があります。 - -効率的に格納できる値の例 `FixedString`-型指定された列: - -- IPアドレスのバイナリ表現 (`FixedString(16)` IPv6用)。 -- Language codes (ru\_RU, en\_US … ). -- Currency codes (USD, RUB … ). -- ハッシュのバイナリ表現 (`FixedString(16)` MD5の場合, `FixedString(32)` 用SHA256)。 - -UUID値を格納するには、以下を使用します [UUID](uuid.md) データ型。 - -データを挿入するときは、clickhouse: - -- 文字列が含まれていない場合、nullバイトの文字列を補完します `N` バイト。 -- スロー `Too large value for FixedString(N)` る場合の例外の文字列です。 `N` バイトまでとなります。 - -データを選択するとき、clickhouseは文字列の末尾にあるnullバイトを削除しません。 を使用する場合 `WHERE` この節では、nullバイトを手動で追加して、 `FixedString` 値。 次の例では、次の例を使用する方法を示します `WHERE` との節 `FixedString`. - -のは、単一の次の表を考えてみましょう `FixedString(2)` 列: - -``` text -┌─name──┐ -│ b │ -└───────┘ -``` - -クエリ `SELECT * FROM FixedStringTable WHERE a = 'b'` 結果としてデータを返さない。 このフィルターパターンはnullバイトまでとなります。 - -``` sql -SELECT * FROM FixedStringTable -WHERE a = 'b\0' -``` - -``` text -┌─a─┐ -│ b │ -└───┘ -``` - -この動作は、mysqlとは異なります `CHAR` タイプ(文字列は空白で埋められ、空白は出力用に削除されます)。 - -の長さに注意してください。 `FixedString(N)` 値が一定になります。 その [長さ](../../sql_reference/functions/array_functions.md#array_functions-length) 関数の戻り値 `N` 場合においても `FixedString(N)` 値はnullバイトでのみ入力されるが、 [空](../../sql_reference/functions/string_functions.md#empty) 関数の戻り値 `1` この場合。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/ja/sql_reference/data_types/float.md b/docs/ja/sql_reference/data_types/float.md deleted file mode 100644 index d6843e492ba..00000000000 --- a/docs/ja/sql_reference/data_types/float.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: Float32,Float64 ---- - -# Float32,Float64 {#float32-float64} - -[浮動小数点数](https://en.wikipedia.org/wiki/IEEE_754). - -型はcの型と同じです: - -- `Float32` - `float` -- `Float64` - `double` - -可能な限り、データを整数形式で格納することをお勧めします。 たとえば、固定精度の数値を、金額やページの読み込み時間などの整数値にミリ秒単位で変換します。 - -## 浮動小数点数の使用 {#using-floating-point-numbers} - -- 浮動小数点数を使用した計算では、丸め誤差が発生することがあります。 - - - -``` sql -SELECT 1 - 0.9 -``` - -``` text -┌───────minus(1, 0.9)─┐ -│ 0.09999999999999998 │ -└─────────────────────┘ -``` - -- 計算の結果は、計算方法(プロセッサの種類とコンピュータシステムのアーキテクチャ)に依存します。 -- 浮動小数点の計算は、無限大などの数値になる可能性があります (`Inf`) “not-a-number” (`NaN`). これは、計算の結果を処理する際に考慮する必要があります。 -- テキストから浮動小数点数を解析する場合、結果は最も近いマシン表現可能な数値ではない可能性があります。 - -## NaNおよびInf {#data_type-float-nan-inf} - -標準sqlとは対照的に、clickhouseは浮動小数点数の次のカテゴリをサポートしています: - -- `Inf` – Infinity. - - - -``` sql -SELECT 0.5 / 0 -``` - -``` text -┌─divide(0.5, 0)─┐ -│ inf │ -└────────────────┘ -``` - -- `-Inf` – Negative infinity. - - - -``` sql -SELECT -0.5 / 0 -``` - -``` text -┌─divide(-0.5, 0)─┐ -│ -inf │ -└─────────────────┘ -``` - -- `NaN` – Not a number. - - - -``` sql -SELECT 0 / 0 -``` - -``` text -┌─divide(0, 0)─┐ -│ nan │ -└──────────────┘ -``` - - See the rules for `NaN` sorting in the section [ORDER BY clause](../sql_reference/statements/select.md). - -[元の記事](https://clickhouse.tech/docs/en/data_types/float/) diff --git a/docs/ja/sql_reference/data_types/index.md b/docs/ja/sql_reference/data_types/index.md deleted file mode 100644 index 126f3b95f04..00000000000 --- a/docs/ja/sql_reference/data_types/index.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Data Types -toc_priority: 37 -toc_title: "\u5C0E\u5165" ---- - -# データ型 {#data_types} - -ClickHouseは、表のセルにさまざまな種類のデータを格納できます。 - -この章ではサポートされているデータの種類と特別な配慮のための利用および/または実施しています。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/) diff --git a/docs/ja/sql_reference/data_types/int_uint.md b/docs/ja/sql_reference/data_types/int_uint.md deleted file mode 100644 index 17854f5d484..00000000000 --- a/docs/ja/sql_reference/data_types/int_uint.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "UInt8\u3001UInt16\u3001UInt32\u3001UInt64\u3001Int8\u3001Int16\u3001Int32\u3001\ - Int64" ---- - -# UInt8、UInt16、UInt32、UInt64、Int8、Int16、Int32、Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} - -符号の有無にかかわらず、固定長の整数。 - -## Intの範囲 {#int-ranges} - -- Int8-\[-128:127\] -- Int16-\[-32768:32767\] -- Int32-\[-2147483648:2147483647\] -- Int64-\[-9223372036854775808:9223372036854775807\] - -## Uint範囲 {#uint-ranges} - -- UInt8-\[0:255\] -- UInt16-\[0:65535\]\] -- UInt32-\[0:4294967295\] -- UInt64-\[0:18446744073709551615\] - -[元の記事](https://clickhouse.tech/docs/en/data_types/int_uint/) diff --git a/docs/ja/sql_reference/data_types/nested_data_structures/index.md b/docs/ja/sql_reference/data_types/nested_data_structures/index.md deleted file mode 100644 index c1177b2d9c0..00000000000 --- a/docs/ja/sql_reference/data_types/nested_data_structures/index.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Nested Data Structures -toc_hidden: true -toc_priority: 54 -toc_title: "\u96A0\u3055\u308C\u305F" ---- - -# 入れ子のデータ構造 {#nested-data-structures} - -[元の記事](https://clickhouse.tech/docs/en/data_types/nested_data_structures/) diff --git a/docs/ja/sql_reference/data_types/nested_data_structures/nested.md b/docs/ja/sql_reference/data_types/nested_data_structures/nested.md deleted file mode 100644 index 2bbf4ed73a7..00000000000 --- a/docs/ja/sql_reference/data_types/nested_data_structures/nested.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 57 -toc_title: "\u30CD\u30B9\u30C8(Name1\u30BF\u30A4\u30D71,Name2\u30BF\u30A4\u30D72,...)" ---- - -# Nested(name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} - -A nested data structure is like a table inside a cell. The parameters of a nested data structure – the column names and types – are specified the same way as in a [CREATE TABLE](../../../sql_reference/statements/create.md) クエリ。 各テーブル行は、入れ子になったデータ構造内の任意の数の行に対応できます。 - -例えば: - -``` sql -CREATE TABLE test.visits -( - CounterID UInt32, - StartDate Date, - Sign Int8, - IsNew UInt8, - VisitID UInt64, - UserID UInt64, - ... - Goals Nested - ( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32 - ), - ... -) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) -``` - -この例では、 `Goals` ネストされたデータ構造。 の各行 ‘visits’ 表は、ゼロまたは任意の数の変換に対応することができます。 - -単一の入れ子レベルのみがサポートされます。 配列を含むネストされた構造体の列は、多次元配列と同等であるため、サポートが制限されています(mergetreeエンジンを使用してこれらの列をテーブルに格 - -ほとんどの場合、入れ子になったデータ構造で作業する場合、その列はドットで区切られた列名で指定されます。 これらの列は、一致する型の配列を構成します。 単一の入れ子になったデータ構造のすべての列配列の長さは同じです。 - -例えば: - -``` sql -SELECT - Goals.ID, - Goals.EventTime -FROM test.visits -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ -│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ -│ [1073752] │ ['2014-03-17 00:28:25'] │ -│ [1073752] │ ['2014-03-17 10:46:20'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ -│ [] │ [] │ -│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ -│ [] │ [] │ -│ [] │ [] │ -│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ -└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -ネストされたデータ構造を、同じ長さの複数の列配列のセットと考えるのが最も簡単です。 - -SELECTクエリで、個々の列ではなくネストされたデータ構造全体の名前を指定できる唯一の場所は、ARRAY JOIN句です。 詳細については、 “ARRAY JOIN clause”. 例えば: - -``` sql -SELECT - Goal.ID, - Goal.EventTime -FROM test.visits -ARRAY JOIN Goals AS Goal -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goal.ID─┬──────Goal.EventTime─┐ -│ 1073752 │ 2014-03-17 16:38:10 │ -│ 591325 │ 2014-03-17 16:38:48 │ -│ 591325 │ 2014-03-17 16:42:27 │ -│ 1073752 │ 2014-03-17 00:28:25 │ -│ 1073752 │ 2014-03-17 10:46:20 │ -│ 1073752 │ 2014-03-17 13:59:20 │ -│ 591325 │ 2014-03-17 22:17:55 │ -│ 591325 │ 2014-03-17 22:18:07 │ -│ 591325 │ 2014-03-17 22:18:51 │ -│ 1073752 │ 2014-03-17 11:37:06 │ -└─────────┴─────────────────────┘ -``` - -ネストされたデータ構造全体のselectは実行できません。 明示的にリストできるのは、その一部である個々の列のみです。 - -挿入クエリでは、入れ子になったデータ構造のすべてのコンポーネント列配列を個別に渡す必要があります(個々の列配列と同様)。 挿入時に、システムは同じ長さを持つことをチェックします。 - -DESCRIBEクエリの場合、入れ子になったデータ構造内の列は、同じ方法で別々にリストされます。 - -入れ子になったデータ構造内の要素に対するalter queryには制限があります。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/nested_data_structures/nested/) diff --git a/docs/ja/sql_reference/data_types/nullable.md b/docs/ja/sql_reference/data_types/nullable.md deleted file mode 100644 index 79b06a832f4..00000000000 --- a/docs/ja/sql_reference/data_types/nullable.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 54 -toc_title: Nullable ---- - -# Nullable(typename) {#data_type-nullable} - -特別なマーカーを保存できます ([NULL](../../sql_reference/syntax.md))それは意味する “missing value” 通常の値と並んで `TypeName`. たとえば、 `Nullable(Int8)` タイプ列は保存できます `Int8` 値を入力すると、値を持たない行が格納されます `NULL`. - -のための `TypeName` 複合データ型は使用できません [配列](array.md) と [タプル](tuple.md). 複合データタイプを含むことができ `Nullable` 以下のようなタイプの値 `Array(Nullable(Int8))`. - -A `Nullable` typeフィールドできない含まれてテーブルスを作成します。 - -`NULL` anyのデフォルト値を指定します。 `Nullable` ClickHouseサーバー構成で別途指定されている場合を除き、入力します。 - -## ストレージ機能 {#storage-features} - -保存する `Nullable` 型の値テーブルのカラムClickHouse用途別のファイル `NULL` 値を持つ通常のファイルに加えて、マスク。 マスクファイル内のエントリは、ClickHouseが `NULL` そして、各テーブルの行の対応するデータ型のデフォルト値。 追加のファイルのため, `Nullable` 列は、同様の通常の記憶領域と比較して追加の記憶領域を消費します。 - -!!! info "メモ" - を使用して `Nullable` ほとんどの場合、パフォーマンスに悪影響を及ぼします。 - -## 使用例 {#usage-example} - -``` sql -CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog -``` - -``` sql -INSERT INTO t_null VALUES (1, NULL), (2, 3) -``` - -``` sql -SELECT x + y FROM t_null -``` - -``` text -┌─plus(x, y)─┐ -│ ᴺᵁᴸᴸ │ -│ 5 │ -└────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/ja/sql_reference/data_types/simpleaggregatefunction.md b/docs/ja/sql_reference/data_types/simpleaggregatefunction.md deleted file mode 120000 index 02fad64d50e..00000000000 --- a/docs/ja/sql_reference/data_types/simpleaggregatefunction.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/sql_reference/data_types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/ja/sql_reference/data_types/special_data_types/expression.md b/docs/ja/sql_reference/data_types/special_data_types/expression.md deleted file mode 100644 index 9786e8349c8..00000000000 --- a/docs/ja/sql_reference/data_types/special_data_types/expression.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 58 -toc_title: "\u5F0F" ---- - -# 式 {#expression} - -式は、高階関数でラムダを表すために使用されます。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/expression/) diff --git a/docs/ja/sql_reference/data_types/special_data_types/index.md b/docs/ja/sql_reference/data_types/special_data_types/index.md deleted file mode 100644 index 9e670337040..00000000000 --- a/docs/ja/sql_reference/data_types/special_data_types/index.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Special Data Types -toc_hidden: true -toc_priority: 55 -toc_title: "\u96A0\u3055\u308C\u305F" ---- - -# 特殊なデータ型 {#special-data-types} - -特別なデータ型の値は、テーブルに保存するためにシリアル化することも、クエリ結果に出力することもできませんが、クエリの実行中に中間結果とし - -[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/) diff --git a/docs/ja/sql_reference/data_types/special_data_types/interval.md b/docs/ja/sql_reference/data_types/special_data_types/interval.md deleted file mode 100644 index affd9034376..00000000000 --- a/docs/ja/sql_reference/data_types/special_data_types/interval.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 61 -toc_title: "\u9593\u9694" ---- - -# 間隔 {#data-type-interval} - -時刻と日付の間隔を表すデータ型のファミリ。 結果のタイプ [INTERVAL](../../../sql_reference/operators.md#operator-interval) オペレーター - -!!! warning "警告" - `Interval` データ型の値はテーブルに格納できません。 - -構造: - -- 符号なし整数値としての時間間隔。 -- 間隔のタイプ。 - -サポートさ: - -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -各区間タイプには、個別のデータタイプがあります。 たとえば、 `DAY` 間隔はに対応します `IntervalDay` データ型: - -``` sql -SELECT toTypeName(INTERVAL 4 DAY) -``` - -``` text -┌─toTypeName(toIntervalDay(4))─┐ -│ IntervalDay │ -└──────────────────────────────┘ -``` - -## 使用上の注意 {#data-type-interval-usage-remarks} - -を使用することができ `Interval`-との算術操作のタイプ値 [日付](../../../sql_reference/data_types/date.md) と [DateTime](../../../sql_reference/data_types/datetime.md)-タイプの値。 たとえば、現在の時刻に4日を追加できます: - -``` sql -SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY -``` - -``` text -┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ -│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ -└─────────────────────┴───────────────────────────────┘ -``` - -間隔の異なる種類できない。 次のような間隔は使用できません `4 DAY 1 HOUR`. 間隔は、間隔の最小単位(間隔など)より小さいか等しい単位で指定します `1 day and an hour` 間隔は次のように表現できます `25 HOUR` または `90000 SECOND`. - -あなたは算術演算を実行することはできません `Interval`-値を入力しますが、異なるタイプの間隔を追加することができます。 `Date` または `DateTime` データ型。 例えば: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -次のクエリでは、例外が発生します: - -``` sql -select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) -``` - -``` text -Received exception from server (version 19.14.1): -Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. -``` - -## また見なさい {#see-also} - -- [INTERVAL](../../../sql_reference/operators.md#operator-interval) 演算子 -- [toInterval](../../../sql_reference/functions/type_conversion_functions.md#function-tointerval) 型変換関数 diff --git a/docs/ja/sql_reference/data_types/special_data_types/nothing.md b/docs/ja/sql_reference/data_types/special_data_types/nothing.md deleted file mode 100644 index 8bd4b852d9f..00000000000 --- a/docs/ja/sql_reference/data_types/special_data_types/nothing.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 60 -toc_title: "\u4F55\u3082\u306A\u3044" ---- - -# 何もない {#nothing} - -このデータ型の唯一の目的は、値が予期されないケースを表すことです。 だから、作成することはできません `Nothing` タイプ値。 - -たとえば、リテラル [NULL](../../../sql_reference/syntax.md#null-literal) はタイプの `Nullable(Nothing)`. 詳細はこちら [Nullable](../../../sql_reference/data_types/nullable.md). - -その `Nothing` 型は、空の配列を示すためにも使用できます: - -``` sql -SELECT toTypeName(array()) -``` - -``` text -┌─toTypeName(array())─┐ -│ Array(Nothing) │ -└─────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/nothing/) diff --git a/docs/ja/sql_reference/data_types/special_data_types/set.md b/docs/ja/sql_reference/data_types/special_data_types/set.md deleted file mode 100644 index a9fb57e7249..00000000000 --- a/docs/ja/sql_reference/data_types/special_data_types/set.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 59 -toc_title: "\u30BB\u30C3\u30C8" ---- - -# セット {#set} - -の右半分のために使用される [IN](../../../sql_reference/statements/select.md#select-in-operators) 式。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/special_data_types/set/) diff --git a/docs/ja/sql_reference/data_types/string.md b/docs/ja/sql_reference/data_types/string.md deleted file mode 100644 index 893e79e14c2..00000000000 --- a/docs/ja/sql_reference/data_types/string.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u6587\u5B57\u5217" ---- - -# 文字列 {#string} - -任意の長さの文字列。 長さは限定されない。 値には、nullバイトを含む任意のバイトセットを含めることができます。 -文字列型は、他のdbmsのvarchar、blob、clobなどの型を置き換えます。 - -## エンコード {#encodings} - -ClickHouseにはエンコーディングの概念はありません。 文字列には、任意のバイトセットを含めることができます。 -が必要な場合は店舗テキストの使用をお勧めしまutf-8エンコーディングです。 少なくとも、端末がutf-8を使用している場合(推奨)、変換を行わずに値を読み書きできます。 -同様に、文字列を操作するための特定の関数には、文字列にutf-8でエンコードされたテキストを表すバイトのセットが含まれているという前提の下 -たとえば、 ‘length’ 関数は文字列の長さをバイト単位で計算します。 ‘lengthUTF8’ 関数を計算し、文字列の長さはUnicodeコードポイント価値をとした場合は、UTF-8エンコードされます。 - -[元の記事](https://clickhouse.tech/docs/en/data_types/string/) diff --git a/docs/ja/sql_reference/data_types/tuple.md b/docs/ja/sql_reference/data_types/tuple.md deleted file mode 100644 index 61492fe28f4..00000000000 --- a/docs/ja/sql_reference/data_types/tuple.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 53 -toc_title: "\u30BF\u30D7\u30EB(T1,T2,...)" ---- - -# Tuple(t1, T2, …) {#tuplet1-t2} - -要素のタプル。 [タイプ](index.md#data_types). - -タプルは、一時列のグループ化に使用されます。 列は、in式がクエリで使用されている場合、およびラムダ関数の特定の仮パラメータを指定するためにグループ化できます。 詳細については、以下を参照してください [演算子の場合](../../sql_reference/statements/select.md) と [高階関数](../../sql_reference/functions/higher_order_functions.md). - -タプルは、クエリの結果になります。 この場合、json以外のテキスト形式の場合、値は角かっこでカンマ区切りになります。 json形式では、タプルは配列として出力されます(角括弧内)。 - -## タプルの作成 {#creating-a-tuple} - -関数を使用してタプルを作成することができます: - -``` sql -tuple(T1, T2, ...) -``` - -タプルの作成例: - -``` sql -SELECT tuple(1,'a') AS x, toTypeName(x) -``` - -``` text -┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ -│ (1,'a') │ Tuple(UInt8, String) │ -└─────────┴───────────────────────────┘ -``` - -## データ型の操作 {#working-with-data-types} - -タプルをオンザフライで作成するとき、clickhouseは引数の値を格納できる型の最小値として各引数の型を自動的に検出します。 引数が [NULL](../../sql_reference/syntax.md#null-literal) タプル要素の型は次のとおりです [Nullable](nullable.md). - -自動データ型検出の例: - -``` sql -SELECT tuple(1, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ -│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ -└──────────┴─────────────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/data_types/tuple/) diff --git a/docs/ja/sql_reference/data_types/uuid.md b/docs/ja/sql_reference/data_types/uuid.md deleted file mode 100644 index 788e7ade8a1..00000000000 --- a/docs/ja/sql_reference/data_types/uuid.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 46 -toc_title: UUID ---- - -# UUID {#uuid-data-type} - -Universally unique identifier(UUID)は、レコードを識別するために使用される16バイトの数値です。 UUIDの詳細については、以下を参照してください [Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier). - -UUID型の値の例を以下に示します: - -``` text -61f0c404-5cb3-11e7-907b-a6006ad3dba0 -``` - -新しいレコードを挿入するときにuuid列の値を指定しない場合、uuidの値はゼロで埋められます: - -``` text -00000000-0000-0000-0000-000000000000 -``` - -## 生成する方法 {#how-to-generate} - -UUID値を生成するには、ClickHouseに次の値を指定します [generateUUIDv4](../../sql_reference/functions/uuid_functions.md) 機能。 - -## 使用例 {#usage-example} - -**例1** - -この例では、uuid型の列を使用してテーブルを作成し、テーブルに値を挿入する方法を示します。 - -``` sql -CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog -``` - -``` sql -INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -└──────────────────────────────────────┴───────────┘ -``` - -**例2** - -この例では、新しいレコードを挿入するときにuuid列の値が指定されていません。 - -``` sql -INSERT INTO t_uuid (y) VALUES ('Example 2') -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ -└──────────────────────────────────────┴───────────┘ -``` - -## 制限 {#restrictions} - -UUIDデータ型は、以下の関数のみをサポートします [文字列](string.md) データ型もサポートします(たとえば, [分](../../sql_reference/aggregate_functions/reference.md#agg_function-min), [最大](../../sql_reference/aggregate_functions/reference.md#agg_function-max)、と [カウント](../../sql_reference/aggregate_functions/reference.md#agg_function-count)). - -UUIDデータ型は、算術演算ではサポートされません(たとえば, [abs](../../sql_reference/functions/arithmetic_functions.md#arithm_func-abs) 以下のような)または集約関数 [合計](../../sql_reference/aggregate_functions/reference.md#agg_function-sum) と [平均](../../sql_reference/aggregate_functions/reference.md#agg_function-avg). - -[元の記事](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts.md deleted file mode 100644 index 0bee2e95916..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u4E00\u822C\u7684\u306A\u8AAC\u660E" ---- - -# 外部辞書 {#dicts-external-dicts} - -さまざまなデータソースから独自の辞書を追加できます。 ディクショナリのデータソースには、ローカルテキストまたは実行可能ファイル、http(s)リソース、または別のdbmsを指定できます。 詳細については、 “[外部辞書のソース](external_dicts_dict_sources.md)”. - -クリックハウス: - -- 完全または部分的にramに辞書を格納します。 -- 辞書を定期的に更新し、欠損値を動的に読み込みます。 つまり、辞書を動的に読み込むことができます。 -- Xmlファイルを使用して外部辞書を作成したり [DDLクエリ](../../statements/create.md#create-dictionary-query). - -外部辞書の設定は、一つ以上のxmlファイルに配置することができます。 設定へのパスは [dictionaries\_config](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_config) パラメータ。 - -辞書は、サーバーの起動時または最初の使用時にロードすることができます。 [dictionaries\_lazy\_load](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) 設定。 - -辞書構成ファイルの形式は次のとおりです: - -``` xml - - An optional element with any content. Ignored by the ClickHouse server. - - - /etc/metrika.xml - - - - - - - - -``` - -あなたはできる [設定](external_dicts_dict.md) 同じファイル内の任意の数の辞書。 - -[辞書のddlクエリ](../../statements/create.md#create-dictionary-query) サーバー構成に追加のレコードは必要ありません。 この仕事を辞書として第一級の体のように、テーブルやビュー。 - -!!! attention "注意" - 小さな辞書の値をaに記述することによって変換できます `SELECT` クエリ(参照 [変換](../../../sql_reference/functions/other_functions.md) 機能)。 この機能は外部辞書とは関係ありません。 - -## また見なさい {#ext-dicts-see-also} - -- [外部ディクショナリの設定](external_dicts_dict.md) -- [辞書をメモリに保存する](external_dicts_dict_layout.md) -- [辞書の更新](external_dicts_dict_lifetime.md) -- [外部辞書のソース](external_dicts_dict_sources.md) -- [辞書のキーとフィールド](external_dicts_dict_structure.md) -- [外部辞書を操作するための関数](../../../sql_reference/functions/ext_dict_functions.md) - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md deleted file mode 100644 index 2d10818a085..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "\u5916\u90E8\u30C7\u30A3\u30AF\u30B7\u30E7\u30CA\u30EA\u306E\u8A2D\u5B9A" ---- - -# 外部ディクショナリの設定 {#dicts-external-dicts-dict} - -Dictionaryがxmlファイルを使用して構成されている場合、than dictionary構成は次の構造を持ちます: - -``` xml - - dict_name - - - - - - - - - - - - - - - - - -``` - -対応 [DDL-クエリ](../../statements/create.md#create-dictionary-query) 次の構造を持っています: - -``` sql -CREATE DICTIONARY dict_name -( - ... -- attributes -) -PRIMARY KEY ... -- complex or single key configuration -SOURCE(...) -- Source configuration -LAYOUT(...) -- Memory layout configuration -LIFETIME(...) -- Lifetime of dictionary in memory -``` - -- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. -- [ソース](external_dicts_dict_sources.md) — Source of the dictionary. -- [レイアウト](external_dicts_dict_layout.md) — Dictionary layout in memory. -- [構造](external_dicts_dict_structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. -- [寿命](external_dicts_dict_lifetime.md) — Frequency of dictionary updates. - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md deleted file mode 100644 index 9ca1ef49b30..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: "\u968E\u5C64\u8F9E\u66F8" ---- - -# 階層辞書 {#hierarchical-dictionaries} - -クリックハウスは、 [数値キー](external_dicts_dict_structure.md#ext_dict-numeric-key). - -次の階層構造を見てください: - -``` text -0 (Common parent) -│ -├── 1 (Russia) -│ │ -│ └── 2 (Moscow) -│ │ -│ └── 3 (Center) -│ -└── 4 (Great Britain) - │ - └── 5 (London) -``` - -この階層として表現することができ、以下の辞書。 - -| region\_id | parent\_region | region\_name | -|------------|----------------|--------------| -| 1 | 0 | ロシア | -| 2 | 1 | モスクワ | -| 3 | 2 | 中央 | -| 4 | 0 | イギリス | -| 5 | 4 | ロンドン | - -この表には列が含まれます `parent_region` これには、要素の最も近い親のキーが含まれます。 - -クリックハウスは [階層](external_dicts_dict_structure.md#hierarchical-dict-attr) のための特性 [外部辞書](index.md) 属性。 このプロパティを使用すると、上記のような階層辞書を構成できます。 - -その [独裁主義体制](../../../sql_reference/functions/ext_dict_functions.md#dictgethierarchy) 関数を使用すると、要素の親チェーンを取得できます。 - -この例では、dictionaryの構造は次のようになります: - -``` xml - - - - region_id - - - - parent_region - UInt64 - 0 - true - - - - region_name - String - - - - - -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md deleted file mode 100644 index cbfc661263e..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md +++ /dev/null @@ -1,373 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: "\u8F9E\u66F8\u3092\u30E1\u30E2\u30EA\u306B\u4FDD\u5B58\u3059\u308B" ---- - -# 辞書をメモリに保存する {#dicts-external-dicts-dict-layout} - -辞書をメモリに保存するには、さまざまな方法があります。 - -私たちはお勧め [フラット](#flat), [ハッシュ](#dicts-external_dicts_dict_layout-hashed) と [complex\_key\_hashed](#complex-key-hashed). 最適の処理速度を提供するかどれが。 - -キャッシュ推奨されていないものになる可能性のある性能や困難の選定に最適なパラメータ。 セクションの続きを読む “[キャッシュ](#cache)”. - -辞書のパフォーマ: - -- 後に辞書を操作する関数を呼び出します `GROUP BY`. -- 射影として抽出する属性をマークします。 異なる属性値が異なるキーに対応する場合、属性はinjectiveと呼ばれます。 だからとき `GROUP BY` キーによって属性値をフェッチする関数を使用します。 `GROUP BY`. - -ClickHouseは、辞書のエラーの例外を生成します。 エラーの例: - -- アクセス中の辞書を読み込めませんでした。 -- エラーの照会 `cached` 辞書だ - -外部辞書のリストとそのステータスを表示することができます `system.dictionaries` テーブル。 - -構成は次のようになります: - -``` xml - - - ... - - - - - - ... - - -``` - -対応 [DDL-クエリ](../../statements/create.md#create-dictionary-query): - -``` sql -CREATE DICTIONARY (...) -... -LAYOUT(LAYOUT_TYPE(param value)) -- layout settings -... -``` - -## 辞書をメモリに格納する方法 {#ways-to-store-dictionaries-in-memory} - -- [フラット](#flat) -- [ハッシュ](#dicts-external_dicts_dict_layout-hashed) -- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) -- [キャッシュ](#cache) -- [range\_hashed](#range-hashed) -- [complex\_key\_hashed](#complex-key-hashed) -- [complex\_key\_cache](#complex-key-cache) -- [ip\_trie](#ip-trie) - -### フラット {#flat} - -辞書は完全にフラット配列の形でメモリに格納されています。 辞書はどのくらいのメモリを使用しますか? この量は、最大のキーのサイズに比例します(使用されるスペース)。 - -辞書キーには、 `UInt64` 値は500,000に制限されます。 辞書を作成するときに大きなキーが検出された場合、ClickHouseは例外をスローし、辞書を作成しません。 - -すべてのタイプの源は支えられる。 更新時には、ファイルまたはテーブルからのデータが完全に読み取られます。 - -この方法は最高性能の中で利用可能なすべての方法を格納する辞書です。 - -構成例: - -``` xml - - - -``` - -または - -``` sql -LAYOUT(FLAT()) -``` - -### ハッシュ {#dicts-external_dicts_dict_layout-hashed} - -辞書は、ハッシュテーブルの形式でメモリに完全に格納されます。 辞書には、実際には任意の識別子を持つ任意の数の要素を含めることができ、キーの数は数千万のアイテムに達することができます。 - -すべてのタイプの源は支えられる。 更新時には、ファイルまたはテーブルからのデータが完全に読み取られます。 - -構成例: - -``` xml - - - -``` - -または - -``` sql -LAYOUT(HASHED()) -``` - -### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} - -に似て `hashed` が、使用メモリ賛以上のCPUます。 - -構成例: - -``` xml - - - -``` - -``` sql -LAYOUT(SPARSE_HASHED()) -``` - -### complex\_key\_hashed {#complex-key-hashed} - -このタイプの貯蔵は合成の使用のためです [キー](external_dicts_dict_structure.md). に似て `hashed`. - -構成例: - -``` xml - - - -``` - -``` sql -LAYOUT(COMPLEX_KEY_HASHED()) -``` - -### range\_hashed {#range-hashed} - -辞書は、範囲とそれに対応する値の順序付けられた配列を持つハッシュテーブルの形式でメモリに格納されます。 - -このストレージメソッドは、hashedと同じように機能し、キーに加えて日付/時刻(任意の数値型)の範囲を使用できます。 - -例:この表には、各広告主の割引の形式が含まれています: - -``` text -+---------|-------------|-------------|------+ -| advertiser id | discount start date | discount end date | amount | -+===============+=====================+===================+========+ -| 123 | 2015-01-01 | 2015-01-15 | 0.15 | -+---------|-------------|-------------|------+ -| 123 | 2015-01-16 | 2015-01-31 | 0.25 | -+---------|-------------|-------------|------+ -| 456 | 2015-01-01 | 2015-01-15 | 0.05 | -+---------|-------------|-------------|------+ -``` - -日付範囲のサンプルを使用するには、以下を定義します `range_min` と `range_max` の要素 [構造](external_dicts_dict_structure.md). これらの要素の要素が含まれている必要があ `name` と`type` (もし `type` デフォルトのタイプが使用されます-Date)。 `type` 任意の数値型(Date/DateTime/UInt64/Int32/others)を指定できます。 - -例えば: - -``` xml - - - Id - - - first - Date - - - last - Date - - ... -``` - -または - -``` sql -CREATE DICTIONARY somedict ( - id UInt64, - first Date, - last Date -) -PRIMARY KEY id -LAYOUT(RANGE_HASHED()) -RANGE(MIN first MAX last) -``` - -これらの辞書を操作するには、追加の引数を渡す必要があります `dictGetT` 範囲が選択される関数: - -``` sql -dictGetT('dict_name', 'attr_name', id, date) -``` - -この関数は、指定された値を返します `id`sと、渡された日付を含む日付範囲。 - -アルゴリズムの詳細: - -- この `id` が見つからないか、または範囲が見つからない。 `id`、辞書のデフォルト値を返します。 -- 範囲が重複している場合は、anyを使用できます。 -- 範囲区切り文字が次の場合 `NULL` または無効な日付(1900-01-01や2039-01-01など)では、範囲は開いたままになります。 範囲は両側で開きます。 - -構成例: - -``` xml - - - - ... - - - - - - - - Abcdef - - - StartTimeStamp - UInt64 - - - EndTimeStamp - UInt64 - - - XXXType - String - - - - - - -``` - -または - -``` sql -CREATE DICTIONARY somedict( - Abcdef UInt64, - StartTimeStamp UInt64, - EndTimeStamp UInt64, - XXXType String DEFAULT '' -) -PRIMARY KEY Abcdef -RANGE(MIN StartTimeStamp MAX EndTimeStamp) -``` - -### キャッシュ {#cache} - -辞書は、固定数のセルを持つキャッシュに格納されます。 これらの細胞を含む使用頻度の高います。 - -辞書を検索するときは、まずキャッシュが検索されます。 各ブロックのデータは、すべてのキーが見つからないのキャッシュ古いから要求されてソースを使用 `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. 受信したデータは、キャッシュに書き込まれます。 - -キャッシュ辞書の場合、有効期限 [寿命](external_dicts_dict_lifetime.md) キャッシュ内のデータの設定が可能です。 より多くの時間より `lifetime` セルにデータをロードしてから、セルの値は使用されず、次に使用する必要があるときに再要求されます。 -これは、辞書を格納するすべての方法の中で最も効果的ではありません。 キャッシュの速度は、正しい設定と使用シナリオに強く依存します。 キャッシュタイプの辞書は、ヒット率が十分に高い場合にのみうまく機能します(推奨99%以上)。 あなたは平均ヒット率を表示することができます `system.dictionaries` テーブル。 - -キャッシュパフォーマン `LIMIT`、および外部ディクショナリで関数を呼び出します。 - -サポート [ソース](external_dicts_dict_sources.md):MySQL、ClickHouse、実行可能ファイル、HTTP。 - -設定例: - -``` xml - - - - 1000000000 - - -``` - -または - -``` sql -LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) -``` - -十分なキャッシュサイズを設定します。 あなたは、セルの数を選択する実験する必要があります: - -1. 値を設定します。 -2. キャッシュが一杯になるまでクエリを実行します。 -3. を使用してメモリ消費量を評価する `system.dictionaries` テーブル。 -4. 必要なメモリ消費量に達するまで、セル数を増減します。 - -!!! warning "警告" - ランダムな読み取りでクエリを処理するのが遅いため、ソースとしてclickhouseを使用しないでください。 - -### complex\_key\_cache {#complex-key-cache} - -このタイプの貯蔵は合成の使用のためです [キー](external_dicts_dict_structure.md). に似て `cache`. - -### ip\_trie {#ip-trie} - -このタイプの貯蔵するマッピングするネットワーク接頭辞(ipアドレスへのメタデータなどのasn. - -例:テーブルを含むネットワークの接頭辞およびその対応としての数および国コード: - -``` text - +-----------|-----|------+ - | prefix | asn | cca2 | - +=================+=======+========+ - | 202.79.32.0/20 | 17501 | NP | - +-----------|-----|------+ - | 2620:0:870::/48 | 3856 | US | - +-----------|-----|------+ - | 2a02:6b8:1::/48 | 13238 | RU | - +-----------|-----|------+ - | 2001:db8::/32 | 65536 | ZZ | - +-----------|-----|------+ -``` - -このタイプのレイアウトを使用する場合、構造に複合キーが必要です。 - -例えば: - -``` xml - - - - prefix - String - - - - asn - UInt32 - - - - cca2 - String - ?? - - ... -``` - -または - -``` sql -CREATE DICTIONARY somedict ( - prefix String, - asn UInt32, - cca2 String DEFAULT '??' -) -PRIMARY KEY prefix -``` - -キーには、許可されたipプレフィックスを含む文字列型属性のみが必要です。 その他のタイプはサポートされていませんか。 - -クエリの場合は、同じ関数を使用する必要があります (`dictGetT` 複合キーを持つ辞書については、タプルを使用する: - -``` sql -dictGetT('dict_name', 'attr_name', tuple(ip)) -``` - -のいずれか `UInt32` IPv4の場合、または `FixedString(16)` IPv6の場合: - -``` sql -dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) -``` - -その他のタイプはサポートされていませんか。 この関数は、このipアドレスに対応するプレフィックスの属性を返します。 がある場合に重なる接頭辞であり、具体的には返却されます。 - -データは `trie`. それは完全にRAMに収まる必要があります。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md deleted file mode 100644 index fbbc6b8fa97..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u8F9E\u66F8\u306E\u66F4\u65B0" ---- - -# 辞書の更新 {#dictionary-updates} - -ClickHouseは定期的に辞書を更新します。 完全にダウンロードされたディクショナリの更新間隔とキャッシュされたディクショナ `` 秒の札。 - -辞書の更新(最初の使用のための読み込み以外)は、クエリをブロックしません。 更新時には、古いバージョンの辞書が使用されます。 更新中にエラーが発生すると、エラーがサーバーログに書き込まれ、古いバージョンの辞書が引き続き使用されます。 - -設定例: - -``` xml - - ... - 300 - ... - -``` - -``` sql -CREATE DICTIONARY (...) -... -LIFETIME(300) -... -``` - -設定 `0` (`LIFETIME(0)`)辞書が更新されないようにします。 - -アップグレードの時間間隔を設定することができ、clickhouseはこの範囲内で一様にランダムな時間を選択します。 これは、多数のサーバーでアップグレードするときに、ディクショナリソースに負荷を分散するために必要です。 - -設定例: - -``` xml - - ... - - 300 - 360 - - ... - -``` - -または - -``` sql -LIFETIME(MIN 300 MAX 360) -``` - -ップする場合には辞書にclickhouseサーバーに適用の異なるロジックの種類によって [ソース](external_dicts_dict_sources.md): - -- テキストファイルの場合は、変更の時間をチェックします。 時間が以前に記録された時間と異なる場合、辞書は更新されます。 -- MyISAMテーブルの場合、変更時刻は次のようにしてチェックされます `SHOW TABLE STATUS` クエリ。 -- 他のソースからの辞書は、デフォルトで毎回updatedされます。 - -MySQL(InnoDB)、ODBC、ClickHouseのソースでは、辞書が実際に変更された場合にのみ、毎回ではなく、辞書を更新するクエリを設定できます。 これを行うには、次の手順に従います: - -- 辞書に表れてい分野に常に変化するソースデータを更新しました。 -- ソースの設定では、変更フィールドを取得するクエリを指定する必要があります。 クリックハウスサーバーは、クエリ結果を行として解釈し、この行が以前の状態に対して変更されている場合は、辞書が更新されます。 クエリを指定します。 `` の設定のフィールド [ソース](external_dicts_dict_sources.md). - -設定例: - -``` xml - - ... - - ... - SELECT update_time FROM dictionary_source where id = 1 - - ... - -``` - -または - -``` sql -... -SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) -... -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md deleted file mode 100644 index 7876b1d00b0..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md +++ /dev/null @@ -1,608 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: "\u5916\u90E8\u8F9E\u66F8\u306E\u30BD\u30FC\u30B9" ---- - -# 外部辞書のソース {#dicts-external-dicts-dict-sources} - -外部辞書は、さまざまなソースから接続できます。 - -辞書がxmlファイルを使用して設定されている場合、設定は次のようになります: - -``` xml - - - ... - - - - - - ... - - ... - -``` - -の場合 [DDL-クエリ](../../statements/create.md#create-dictionary-query)、等しい構成は次のようになります: - -``` sql -CREATE DICTIONARY dict_name (...) -... -SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration -... -``` - -ソースは、 `source` セクション。 - -ソースの種類 (`source_type`): - -- [Localファイル](#dicts-external_dicts_dict_sources-local_file) -- [実行可能ファイル](#dicts-external_dicts_dict_sources-executable) -- [HTTP(s)](#dicts-external_dicts_dict_sources-http) -- DBMS - - [ODBC](#dicts-external_dicts_dict_sources-odbc) - - [MySQL](#dicts-external_dicts_dict_sources-mysql) - - [クリックハウス](#dicts-external_dicts_dict_sources-clickhouse) - - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) - - [レディス](#dicts-external_dicts_dict_sources-redis) - -## Localファイル {#dicts-external_dicts_dict_sources-local_file} - -設定例: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - -``` - -または - -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -フィールドの設定: - -- `path` – The absolute path to the file. -- `format` – The file format. All the formats described in “[形式](../../../interfaces/formats.md#formats)” サポートされます。 - -## 実行可能ファイル {#dicts-external_dicts_dict_sources-executable} - -実行可能ファイルの操作は [辞書がメモリにどのように格納されるか](external_dicts_dict_layout.md). 辞書が以下を使用して格納されている場合 `cache` と `complex_key_cache` ClickHouseは、実行可能ファイルのSTDINに要求を送信することによって、必要なキーを要求します。 その他、ClickHouse始まり実行可能ファイルを扱い、その出力としての辞書のデータです。 - -設定例: - -``` xml - - - cat /opt/dictionaries/os.tsv - TabSeparated - - -``` - -または - -``` sql -SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -フィールドの設定: - -- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). -- `format` – The file format. All the formats described in “[形式](../../../interfaces/formats.md#formats)” サポートされます。 - -## Http(s) {#dicts-external_dicts_dict_sources-http} - -HTTP(s)サーバーの操作は次の条件によって異なります [辞書がメモリにどのように格納されるか](external_dicts_dict_layout.md). 辞書が以下を使用して格納されている場合 `cache` と `complex_key_cache`、ClickHouse要求を送信することによって必要なキーを経由して `POST` 方法。 - -設定例: - -``` xml - - - http://[::1]/os.tsv - TabSeparated - - user - password - - -
- API-KEY - key -
-
-
- -``` - -または - -``` sql -SOURCE(HTTP( - url 'http://[::1]/os.tsv' - format 'TabSeparated' - credentials(user 'user' password 'password') - headers(header(name 'API-KEY' value 'key')) -)) -``` - -ClickHouseがHTTPSリソースにアクセスするには、次のことが必要です [openSSLを設定](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-openssl) サーバー構成で。 - -フィールドの設定: - -- `url` – The source URL. -- `format` – The file format. All the formats described in “[形式](../../../interfaces/formats.md#formats)” サポートされます。 -- `credentials` – Basic HTTP authentication. Optional parameter. - - `user` – Username required for the authentication. - - `password` – Password required for the authentication. -- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. - - `header` – Single HTTP header entry. - - `name` – Identifiant name used for the header send on the request. - - `value` – Value set for a specific identifiant name. - -## ODBC {#dicts-external_dicts_dict_sources-odbc} - -このメソッドを使用して、odbcドライバーを持つデータベースを接続できます。 - -設定例: - -``` xml - - - DatabaseName - ShemaName.TableName
- DSN=some_parameters - SQL_QUERY -
- -``` - -または - -``` sql -SOURCE(ODBC( - db 'DatabaseName' - table 'SchemaName.TableName' - connection_string 'DSN=some_parameters' - invalidate_query 'SQL_QUERY' -)) -``` - -フィールドの設定: - -- `db` – Name of the database. Omit it if the database name is set in the `` パラメータ。 -- `table` – Name of the table and schema if exists. -- `connection_string` – Connection string. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [辞書の更新](external_dicts_dict_lifetime.md). - -ClickHouseはODBCドライバからクォート記号を受け取り、クエリのすべての設定をドライバに引用するので、データベースのテーブル名に応じてテーブル名を設定する - -Oracleを使用しているときにエンコードに問題がある場合は、対応する [FAQ](../../../faq/general.md#oracle-odbc-encodings) 記事。 - -### ODBCディクショナリ機能の既知の脆弱性 {#known-vulnerability-of-the-odbc-dictionary-functionality} - -!!! attention "注意" - ODBC driver connectionパラメーターを使用してデータベースに接続する場合 `Servername` 置換することができる。 この場合、 `USERNAME` と `PASSWORD` から `odbc.ini` リモートサーバーに送信され、侵害される可能性があります。 - -**安全でない使用例** - -PostgreSQL用にunixODBCを設定してみましょう。 の内容 `/etc/odbc.ini`: - -``` text -[gregtest] -Driver = /usr/lib/psqlodbca.so -Servername = localhost -PORT = 5432 -DATABASE = test_db -#OPTION = 3 -USERNAME = test -PASSWORD = test -``` - -次に、次のようなクエリを作成します - -``` sql -SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); -``` - -ODBCドライバーの値を送信します `USERNAME` と `PASSWORD` から `odbc.ini` に `some-server.com`. - -### Postgresqlの接続例 {#example-of-connecting-postgresql} - -UbuntuのOS。 - -UnixODBCとPostgreSQL用のODBCドライバのインストール: - -``` bash -$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql -``` - -設定 `/etc/odbc.ini` (または `~/.odbc.ini`): - -``` text - [DEFAULT] - Driver = myconnection - - [myconnection] - Description = PostgreSQL connection to my_db - Driver = PostgreSQL Unicode - Database = my_db - Servername = 127.0.0.1 - UserName = username - Password = password - Port = 5432 - Protocol = 9.3 - ReadOnly = No - RowVersioning = No - ShowSystemTables = No - ConnSettings = -``` - -クリックハウスの辞書構成: - -``` xml - - - table_name - - - - - DSN=myconnection - postgresql_table
-
- - - 300 - 360 - - - - - - - id - - - some_column - UInt64 - 0 - - -
-
-``` - -または - -``` sql -CREATE DICTIONARY table_name ( - id UInt64, - some_column UInt64 DEFAULT 0 -) -PRIMARY KEY id -SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) -LAYOUT(HASHED()) -LIFETIME(MIN 300 MAX 360) -``` - -編集が必要な場合があります `odbc.ini` ドライバを使用してライブラリへのフルパスを指定するには `DRIVER=/usr/local/lib/psqlodbcw.so`. - -### MS SQL Serverの接続例 {#example-of-connecting-ms-sql-server} - -UbuntuのOS。 - -設置のドライバー: : - -``` bash -$ sudo apt-get install tdsodbc freetds-bin sqsh -``` - -ドライバの設定: - -``` bash - $ cat /etc/freetds/freetds.conf - ... - - [MSSQL] - host = 192.168.56.101 - port = 1433 - tds version = 7.0 - client charset = UTF-8 - - $ cat /etc/odbcinst.ini - ... - - [FreeTDS] - Description = FreeTDS - Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so - Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so - FileUsage = 1 - UsageCount = 5 - - $ cat ~/.odbc.ini - ... - - [MSSQL] - Description = FreeTDS - Driver = FreeTDS - Servername = MSSQL - Database = test - UID = test - PWD = test - Port = 1433 -``` - -ClickHouseでの辞書の設定: - -``` xml - - - test - - - dict
- DSN=MSSQL;UID=test;PWD=test -
- - - - 300 - 360 - - - - - - - - - k - - - s - String - - - -
-
-``` - -または - -``` sql -CREATE DICTIONARY test ( - k UInt64, - s String DEFAULT '' -) -PRIMARY KEY k -SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) -LAYOUT(FLAT()) -LIFETIME(MIN 300 MAX 360) -``` - -## DBMS {#dbms} - -### Mysql {#dicts-external_dicts_dict_sources-mysql} - -設定例: - -``` xml - - - 3306 - clickhouse - qwerty - - example01-1 - 1 - - - example01-2 - 1 - - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -または - -``` sql -SOURCE(MYSQL( - port 3306 - user 'clickhouse' - password 'qwerty' - replica(host 'example01-1' priority 1) - replica(host 'example01-2' priority 1) - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -フィールドの設定: - -- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). - -- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `replica` – Section of replica configurations. There can be multiple sections. - - - `replica/host` – The MySQL host. - - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. - -- `db` – Name of the database. - -- `table` – Name of the table. - -- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` たとえば、MySQLの句, `id > 10 AND id < 20`. 省略可能なパラメータ。 - -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [辞書の更新](external_dicts_dict_lifetime.md). - -MySQLは、ローカルホスト上でソケット経由で接続できます。 これを行うには、 `host` と `socket`. - -設定例: - -``` xml - - - localhost - /path/to/socket/file.sock - clickhouse - qwerty - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -または - -``` sql -SOURCE(MYSQL( - host 'localhost' - socket '/path/to/socket/file.sock' - user 'clickhouse' - password 'qwerty' - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -### クリックハウス {#dicts-external_dicts_dict_sources-clickhouse} - -設定例: - -``` xml - - - example01-01-1 - 9000 - default - - default - ids
- id=10 -
- -``` - -または - -``` sql -SOURCE(CLICKHOUSE( - host 'example01-01-1' - port 9000 - user 'default' - password '' - db 'default' - table 'ids' - where 'id=10' -)) -``` - -フィールドの設定: - -- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [分散](../../../engines/table_engines/special/distributed.md) テーブルと後続の構成でそれを入力します。 -- `port` – The port on the ClickHouse server. -- `user` – Name of the ClickHouse user. -- `password` – Password of the ClickHouse user. -- `db` – Name of the database. -- `table` – Name of the table. -- `where` – The selection criteria. May be omitted. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [辞書の更新](external_dicts_dict_lifetime.md). - -### Mongodb {#dicts-external_dicts_dict_sources-mongodb} - -設定例: - -``` xml - - - localhost - 27017 - - - test - dictionary_source - - -``` - -または - -``` sql -SOURCE(MONGO( - host 'localhost' - port 27017 - user '' - password '' - db 'test' - collection 'dictionary_source' -)) -``` - -フィールドの設定: - -- `host` – The MongoDB host. -- `port` – The port on the MongoDB server. -- `user` – Name of the MongoDB user. -- `password` – Password of the MongoDB user. -- `db` – Name of the database. -- `collection` – Name of the collection. - -### レディス {#dicts-external_dicts_dict_sources-redis} - -設定例: - -``` xml - - - localhost - 6379 - simple - 0 - - -``` - -または - -``` sql -SOURCE(REDIS( - host 'localhost' - port 6379 - storage_type 'simple' - db_index 0 -)) -``` - -フィールドの設定: - -- `host` – The Redis host. -- `port` – The port on the Redis server. -- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` 単純なソースとハッシュされた単一のキーソース用です, `hash_map` は用ハッシュソースで二つのキー。 距源およびキャッシュ源の複雑な鍵サポートされていません。 省略することができ、デフォルト値は `simple`. -- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md deleted file mode 100644 index 07d639043a6..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u8F9E\u66F8\u306E\u30AD\u30FC\u3068\u30D5\u30A3\u30FC\u30EB\u30C9" ---- - -# 辞書のキーとフィールド {#dictionary-key-and-fields} - -その `` 条項の辞書のキーや分野での利用ます。 - -XMLの説明: - -``` xml - - - - Id - - - - - - - ... - - - -``` - -属性は要素に記述されています: - -- `` — [キー列](external_dicts_dict_structure.md#ext_dict_structure-key). -- `` — [データ列](external_dicts_dict_structure.md#ext_dict_structure-attributes). 複数の属性を指定できます。 - -DDLクエリ: - -``` sql -CREATE DICTIONARY dict_name ( - Id UInt64, - -- attributes -) -PRIMARY KEY Id -... -``` - -属性はクエリ本文に記述されます: - -- `PRIMARY KEY` — [キー列](external_dicts_dict_structure.md#ext_dict_structure-key) -- `AttrName AttrType` — [データ列](external_dicts_dict_structure.md#ext_dict_structure-attributes). 複数の属性を指定できます。 - -## キー {#ext_dict_structure-key} - -ClickHouseは次の種類のキーをサポートしています: - -- 数値キー。 `UInt64`. で定義される `` タグまたは使用 `PRIMARY KEY` キーワード。 -- 複合キー。 異なるタイプの値のセット。 タグ内で定義されている `` または `PRIMARY KEY` キーワード。 - -Xmlの構造を含むことができま `` または ``. DDL-クエリにsingleを含める必要があります `PRIMARY KEY`. - -!!! warning "警告" - Keyを属性として記述することはできません。 - -### 数値キー {#ext_dict-numeric-key} - -タイプ: `UInt64`. - -構成例: - -``` xml - - Id - -``` - -設定フィールド: - -- `name` – The name of the column with keys. - -DDLクエリの場合: - -``` sql -CREATE DICTIONARY ( - Id UInt64, - ... -) -PRIMARY KEY Id -... -``` - -- `PRIMARY KEY` – The name of the column with keys. - -### 複合キー {#composite-key} - -キーは次のようになります `tuple` フィールドの任意のタイプから。 その [レイアウト](external_dicts_dict_layout.md) この場合、 `complex_key_hashed` または `complex_key_cache`. - -!!! tip "ヒント" - 複合キーは、単一の要素で構成できます。 これにより、たとえば文字列をキーとして使用することができます。 - -キー構造は要素で設定されます ``. キーフィールドは、ディクショナリと同じ形式で指定します [属性](external_dicts_dict_structure.md). 例えば: - -``` xml - - - - field1 - String - - - field2 - UInt32 - - ... - -... -``` - -または - -``` sql -CREATE DICTIONARY ( - field1 String, - field2 String - ... -) -PRIMARY KEY field1, field2 -... -``` - -クエリの場合 `dictGet*` 関数は、タプルがキーとして渡されます。 例えば: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. - -## 属性 {#ext_dict_structure-attributes} - -構成例: - -``` xml - - ... - - Name - ClickHouseDataType - - rand64() - true - true - true - - -``` - -または - -``` sql -CREATE DICTIONARY somename ( - Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID -) -``` - -設定フィールド: - -| タグ | 説明 | 必須 | -|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| -| `name` | 列名。 | はい。 | -| `type` | ClickHouseデータタイプ。
ClickHouseは、dictionaryから指定されたデータ型に値をキャストしようとします。 例えば、MySQLの場合、フィールドは次のようになります `TEXT`, `VARCHAR`、または `BLOB` MySQLソーステーブルでは、次のようにアップロードできます `String` クリックハウスで。
[Nullable](../../../sql_reference/data_types/nullable.md) サポートされていない。 | はい。 | -| `null_value` | 既存の要素以外の要素のデフォルト値。
この例では、空の文字列です。 使用できません `NULL` この分野で。 | はい。 | -| `expression` | [式](../../syntax.md#syntax-expressions) そのClickHouseはその値を実行します。
この式には、リモートsqlデータベースの列名を指定できます。 したがって、これを使用して、リモート列の別名を作成できます。

デフォルト値:式なし。 | いいえ。 | -| `hierarchical` | もし `true`、属性は、現在のキーの親キーの値が含まれています。 見る [階層辞書](external_dicts_dict_hierarchical.md).

デフォルト値: `false`. | いいえ。 | -| `injective` | このフラグは、 `id -> attribute` 画像は [射影](https://en.wikipedia.org/wiki/Injective_function).
もし `true`、ClickHouseはの後に自動的に置くことができます `GROUP BY` 句注入を伴う辞書への要求。 通常、そのような要求の量が大幅に削減されます。

デフォルト値: `false`. | いいえ。 | -| `is_object_id` | MongoDBドキュメントに対してクエリが実行されるかどうかを示すフラグ `ObjectID`.

デフォルト値: `false`. | いいえ。 | - -## また見なさい {#see-also} - -- [外部辞書を操作するための関数](../../../sql_reference/functions/ext_dict_functions.md). - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/ja/sql_reference/dictionaries/external_dictionaries/index.md b/docs/ja/sql_reference/dictionaries/external_dictionaries/index.md deleted file mode 100644 index b5c506f5d93..00000000000 --- a/docs/ja/sql_reference/dictionaries/external_dictionaries/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: External Dictionaries -toc_priority: 37 ---- - - diff --git a/docs/ja/sql_reference/dictionaries/index.md b/docs/ja/sql_reference/dictionaries/index.md deleted file mode 100644 index bd08b421555..00000000000 --- a/docs/ja/sql_reference/dictionaries/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Dictionaries -toc_priority: 35 -toc_title: "\u5C0E\u5165" ---- - -# 辞書 {#dictionaries} - -辞書はマッピングです (`key -> attributes`)それはさまざまなタイプの参照リストのために便利です。 - -ClickHouseは、クエリで使用できる辞書を操作するための特別な機能をサポートしています。 Aよりも関数で辞書を使用する方が簡単で効率的です `JOIN` 参照テーブルと。 - -[NULL](../syntax.md#null) 値を辞書に格納することはできません。 - -ClickHouse支援: - -- [内蔵の辞書](internal_dicts.md#internal_dicts) 特定の [関数のセット](../../sql_reference/functions/ym_dict_functions.md). -- [プラグイン(外部)辞書](external_dictionaries/external_dicts.md) と [機能のネット](../../sql_reference/functions/ext_dict_functions.md). - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/ja/sql_reference/dictionaries/internal_dicts.md b/docs/ja/sql_reference/dictionaries/internal_dicts.md deleted file mode 100644 index 93e1b990819..00000000000 --- a/docs/ja/sql_reference/dictionaries/internal_dicts.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u5185\u90E8\u8F9E\u66F8" ---- - -# 内部辞書 {#internal_dicts} - -ClickHouseには、ジオベースを操作するための組み込み機能が含まれています。 - -ことができ: - -- 地域のidを使用して、目的の言語でその名前を取得します。 -- 地域のidを使用して、都市、地域、連邦区、国、または大陸のidを取得します。 -- 領域が別の領域の一部であるかどうかを確認します。 -- 親領域のチェーンを取得します。 - -すべての機能サポート “translocality,” 同時に地域の所有権に異なる視点を使用する機能。 詳細については、以下を参照してください “Functions for working with Yandex.Metrica dictionaries”. - -内部辞書は、既定のパッケージでは無効になっています。 -よって、strncasecmpのパラメータ `path_to_regions_hierarchy_file` と `path_to_regions_names_files` サーバー設定ファイルで。 - -Geobaseはテキストファイルからロードされます。 - -場所は `regions_hierarchy*.txt` へのファイル `path_to_regions_hierarchy_file` ディレクトリ。 この構成パラ `regions_hierarchy.txt` ファイル(デフォルトの地域階層)、およびその他のファイル (`regions_hierarchy_ua.txt`)同じディレクトリに配置する必要があります。 - -を置く `regions_names_*.txt` のファイル `path_to_regions_names_files` ディレクトリ。 - -を作ることもできますこれらのファイル。 ファイルフォーマットは以下: - -`regions_hierarchy*.txt`:TabSeparated(ヘッダーなし)、列: - -- 地域ID (`UInt32`) -- 親リージョンID (`UInt32`) -- 地域タイプ (`UInt8`):1-大陸,3-国,4-連邦区,5-地域,6-都市;その他のタイプには値がありません -- 人口 (`UInt32`) — optional column - -`regions_names_*.txt`:TabSeparated(ヘッダーなし)、列: - -- 地域ID (`UInt32`) -- 地域名 (`String`) — Can't contain tabs or line feeds, even escaped ones. - -フラット配列は、ramに格納するために使用されます。 このため、idは百万を超えてはいけません。 - -辞書は、サーバーを再起動せずに更新できます。 ただし、使用可能な辞書のセットは更新されません。 -更新の場合、ファイルの修正時刻がチェックされます。 ファイルが変更された場合は、辞書が更新されます。 -変更をチェックする間隔は、 `builtin_dictionaries_reload_interval` パラメータ。 -辞書updates(最初の使用時の読み込み以外)は、クエリをブロックしません。 更新時には、クエリは古いバージョンの辞書を使用します。 更新中にエラーが発生すると、エラーがサーバーログに書き込まれ、古いバージョンの辞書が引き続き使用されます。 - -Geobaseで辞書を定期的に更新することをお勧めします。 更新中に、新しいファイルを生成し、別の場所に書き込みます。 すべての準備ができたら、サーバーが使用するファイルに名前を変更します。 - -また、os識別子とyandexを操作するための機能もあります。metricaの調査エンジン、しかしそれらは使用されるべきではない。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/ja/sql_reference/functions/arithmetic_functions.md b/docs/ja/sql_reference/functions/arithmetic_functions.md deleted file mode 100644 index cbcc2d8dca7..00000000000 --- a/docs/ja/sql_reference/functions/arithmetic_functions.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 35 -toc_title: "\u7B97\u6570" ---- - -# 算術関数 {#arithmetic-functions} - -すべての算術関数の場合、結果の型は、そのような型がある場合、結果が収まる最小の数値型として計算されます。 最小値は、ビット数、符号付きかどうか、および浮動小数点かどうかに基づいて同時に取得されます。 十分なビットがない場合、最高のビットタイプが取られます。 - -例えば: - -``` sql -SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) -``` - -``` text -┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ -│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ -└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ -``` - -算術関数は、uint8、uint16、uint32、uint64、int8、int16、int32、int64、float32、またはfloat64の任意のペアの型に対して機能します。 - -オーバーフローはc++と同じ方法で生成されます。 - -## プラス(a、b)、a+b演算子 {#plusa-b-a-b-operator} - -数値の合計を計算します。 -また、日付または日付と時刻を持つ整数を追加することができます。 日付の場合、整数を追加すると、対応する日数を追加することを意味します。 時間のある日付の場合、対応する秒数を加算することを意味します。 - -## マイナス(a,b),a-b演算子 {#minusa-b-a-b-operator} - -差を計算します。 結果は常に署名されます。 - -You can also calculate integer numbers from a date or date with time. The idea is the same – see above for ‘plus’. - -## 乗算(a,b),a\*b演算子 {#multiplya-b-a-b-operator} - -数字の積を計算します。 - -## 除算(a,b),a/b演算子 {#dividea-b-a-b-operator} - -数値の商を計算します。 結果の型は常に浮動小数点型です。 -整数除算ではありません。 整数除算の場合は、以下を使用します ‘intDiv’ 機能。 -ゼロで割ると ‘inf’, ‘-inf’、または ‘nan’. - -## intDiv(a,b) {#intdiva-b} - -数値の商を計算します。 整数に分割し、(絶対値によって)切り捨てます。 -ゼロで除算するとき、または最小の負の数をマイナスの数で除算するときに例外がスローされます。 - -## intDivOrZero(a,b) {#intdivorzeroa-b} - -とは異なります ‘intDiv’ ゼロで除算するとき、または最小の負の数をマイナスの数で除算するときにゼロを返すという点で。 - -## モジュロ(a,b),a%b演算子 {#moduloa-b-a-b-operator} - -除算の後の剰余を計算します。 -引数が浮動小数点数である場合、それらは小数部分を削除することによって整数にあらかじめ変換されます。 -残りはc++と同じ意味で取られます。 負の数には切り捨て除算が使用されます。 -ゼロで除算するとき、または最小の負の数をマイナスの数で除算するときに例外がスローされます。 - -## モジュロオルゼロ(a,b) {#moduloorzeroa-b} - -とは異なります ‘modulo’ 除数がゼロのときにゼロを返すという点です。 - -## 否定(a),-演算子 {#negatea-a-operator} - -逆符号を持つ数値を計算します。 結果は常に署名されます。 - -## abs(a) {#arithm_func-abs} - -数値(a)の絶対値を計算します。 つまり、a\<0の場合、-a返します。 符号付き整数型の場合は、符号なしの数値を返します。 - -## gcd(a,b) {#gcda-b} - -数値の最大公約数を返します。 -ゼロで除算するとき、または最小の負の数をマイナスの数で除算するときに例外がスローされます。 - -## lcm(a,b) {#lcma-b} - -数値の最小公倍数を返します。 -ゼロで除算するとき、または最小の負の数をマイナスの数で除算するときに例外がスローされます。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/ja/sql_reference/functions/array_functions.md b/docs/ja/sql_reference/functions/array_functions.md deleted file mode 100644 index bf3e70eac33..00000000000 --- a/docs/ja/sql_reference/functions/array_functions.md +++ /dev/null @@ -1,1057 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 46 -toc_title: "\u914D\u5217\u306E\u64CD\u4F5C" ---- - -# 配列を操作するための関数 {#functions-for-working-with-arrays} - -## 空 {#function-empty} - -空の配列の場合は1、空でない配列の場合は0を返します。 -結果の型はuint8です。 -この関数は文字列に対しても機能します。 - -## notEmpty {#function-notempty} - -空の配列の場合は0、空でない配列の場合は1を返します。 -結果の型はuint8です。 -この関数は文字列に対しても機能します。 - -## 長さ {#array_functions-length} - -配列内の項目の数を返します。 -結果の型はuint64です。 -この関数は文字列に対しても機能します。 - -## emptyArrayUInt8,emptyArrayUInt16,emptyArrayUInt32,emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} - -## emptyArrayInt8,emptyArrayInt16,emptyArrayInt32,emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} - -## emptyArrayFloat32,emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} - -## emptyArrayDate,emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} - -## constellation name(optional) {#emptyarraystring} - -ゼロ引数を受け取り、適切な型の空の配列を返します。 - -## emptyArrayToSingle {#emptyarraytosingle} - -空の配列を受け取り、デフォルト値と等しいワンエレメント配列を返します。 - -## 範囲(終了)、範囲(開始、終了\[、ステップ\]) {#rangeend-rangestart-end-step} - -開始から終了までの数字の配列を返します-1ステップごとに。 -これは、 `start` デフォルトは0です。 -これは、 `step` デフォルトは1です。 -それはpythonicのように動作します `range`. しかし、違いは、すべての引数の型が `UInt` ナンバーズ -場合によっては、データブロック内に100,000,000要素を超える長さの配列が作成された場合、例外がスローされます。 - -## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} - -関数の引数から配列を作成します。 -引数は定数でなければならず、最小の共通型を持つ型を持つ必要があります。 なぜなら、それ以外の場合は、どのタイプの配列を作成するかは明確ではないからです。 つまり、この関数を使用して空の配列を作成することはできません(これを行うには、 ‘emptyArray\*’ 上記の関数)。 -を返します。 ‘Array(T)’ タイプの結果、ここで ‘T’ 渡された引数のうち最小の共通型です。 - -## arrayConcat {#arrayconcat} - -引数として渡される配列を結合します。 - -``` sql -arrayConcat(arrays) -``` - -**パラメータ** - -- `arrays` – Arbitrary number of arguments of [配列](../../sql_reference/data_types/array.md) タイプ。 - **例えば** - - - -``` sql -SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,3,4,5,6] │ -└───────────────┘ -``` - -## arrayElement(arr,n),演算子arr\[n\] {#arrayelementarr-n-operator-arrn} - -インデックスを持つ要素を取得する `n` 配列から `arr`. `n` 任意の整数型でなければなりません。 -インデックス配列の開始からです。 -負の索引がサポートされます。 この場合、最後から番号が付けられた対応する要素を選択します。 例えば, `arr[-1]` 配列の最後の項目です。 - -インデックスが配列の境界の外にある場合、いくつかのデフォルト値(数値の場合は0、文字列の場合は空の文字列など)を返します。)、非定数配列と定数インデックス0の場合を除いて(この場合はエラーが発生します `Array indices are 1-based`). - -## has(arr,elem) {#hasarr-elem} - -この ‘arr’ 配列には ‘elem’ 要素。 -要素が配列にない場合は0、ない場合は1を返します。 - -`NULL` 値として処理されます。 - -``` sql -SELECT has([1, 2, NULL], NULL) -``` - -``` text -┌─has([1, 2, NULL], NULL)─┐ -│ 1 │ -└─────────────────────────┘ -``` - -## hasAll {#hasall} - -ある配列が別の配列のサブセットかどうかを調べます。 - -``` sql -hasAll(set, subset) -``` - -**パラメータ** - -- `set` – Array of any type with a set of elements. -- `subset` – Array of any type with elements that should be tested to be a subset of `set`. - -**戻り値** - -- `1`,もし `set` からのすべての要素を含みます `subset`. -- `0` そうでなければ - -**特有の性質** - -- 空の配列は、任意の配列のサブセットです。 -- `Null` 値として処理されます。 -- 両方の配列の値の順序は関係ありません。 - -**例** - -`SELECT hasAll([], [])` 戻り値1. - -`SELECT hasAll([1, Null], [Null])` 戻り値1. - -`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` 戻り値1. - -`SELECT hasAll(['a', 'b'], ['a'])` 戻り値1. - -`SELECT hasAll([1], ['a'])` 0を返します。 - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` 0を返します。 - -## hasAny {#hasany} - -るかどうかを判二つの配列が互いの交差点にある。 - -``` sql -hasAny(array1, array2) -``` - -**パラメータ** - -- `array1` – Array of any type with a set of elements. -- `array2` – Array of any type with a set of elements. - -**戻り値** - -- `1`,もし `array1` と `array2` 少なくとも同様の要素を持っている。 -- `0` そうでなければ - -**特有の性質** - -- `Null` 値として処理されます。 -- 両方の配列の値の順序は関係ありません。 - -**例** - -`SELECT hasAny([1], [])` を返します `0`. - -`SELECT hasAny([Null], [Null, 1])` を返します `1`. - -`SELECT hasAny([-128, 1., 512], [1])` を返します `1`. - -`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` を返します `0`. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` を返します `1`. - -## インデクサー(arr,x) {#indexofarr-x} - -最初のインデックスを返します ‘x’ 要素(配列内にある場合は1から開始)、そうでない場合は0。 - -例えば: - -``` sql -SELECT indexOf([1, 3, NULL, NULL], NULL) -``` - -``` text -┌─indexOf([1, 3, NULL, NULL], NULL)─┐ -│ 3 │ -└───────────────────────────────────┘ -``` - -に設定された要素 `NULL` 通常の値として扱われます。 - -## countEqual(arr,x) {#countequalarr-x} - -配列内のxと等しい要素の数を返します。arraycount(elem-\>elem=x,arr)と等価です。 - -`NULL` 要素は個別の値として処理されます。 - -例えば: - -``` sql -SELECT countEqual([1, 2, NULL, NULL], NULL) -``` - -``` text -┌─countEqual([1, 2, NULL, NULL], NULL)─┐ -│ 2 │ -└──────────────────────────────────────┘ -``` - -## arrayEnumerate(arr) {#array_functions-arrayenumerate} - -Returns the array \[1, 2, 3, …, length (arr) \] - -この関数は通常、array joinと共に使用されます。 この計数かけま配列に適用後の配列。 例えば: - -``` sql -SELECT - count() AS Reaches, - countIf(num = 1) AS Hits -FROM test.hits -ARRAY JOIN - GoalsReached, - arrayEnumerate(GoalsReached) AS num -WHERE CounterID = 160656 -LIMIT 10 -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -この例では、reachesは変換の数(配列結合を適用した後に受け取った文字列)であり、hitsはページビューの数(配列結合の前の文字列)です。 この特定のケースでは、同じ結果をより簡単な方法で得ることができます: - -``` sql -SELECT - sum(length(GoalsReached)) AS Reaches, - count() AS Hits -FROM test.hits -WHERE (CounterID = 160656) AND notEmpty(GoalsReached) -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -この関数は、高階関数でも使用できます。 たとえば、これを使用して、条件に一致する要素の配列インデックスを取得できます。 - -## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} - -ソース配列と同じサイズの配列を返し、各要素に対して同じ値を持つ要素間の位置を示します。 -例えば:arrayenumerateuniq(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. - -この関数は、配列要素の配列の結合と集約を使用する場合に便利です。 -例えば: - -``` sql -SELECT - Goals.ID AS GoalID, - sum(Sign) AS Reaches, - sumIf(Sign, num = 1) AS Visits -FROM test.visits -ARRAY JOIN - Goals, - arrayEnumerateUniq(Goals.ID) AS num -WHERE CounterID = 160656 -GROUP BY GoalID -ORDER BY Reaches DESC -LIMIT 10 -``` - -``` text -┌──GoalID─┬─Reaches─┬─Visits─┐ -│ 53225 │ 3214 │ 1097 │ -│ 2825062 │ 3188 │ 1097 │ -│ 56600 │ 2803 │ 488 │ -│ 1989037 │ 2401 │ 365 │ -│ 2830064 │ 2396 │ 910 │ -│ 1113562 │ 2372 │ 373 │ -│ 3270895 │ 2262 │ 812 │ -│ 1084657 │ 2262 │ 345 │ -│ 56599 │ 2260 │ 799 │ -│ 3271094 │ 2256 │ 812 │ -└─────────┴─────────┴────────┘ -``` - -この例では、各ゴールidには、コンバージョン数(ゴールネストされたデータ構造の各要素は、達成されたゴールであり、コンバージョンと呼ばれます)とセッション 配列の結合がなければ、セッション数をsum(sign)としてカウントします。 しかし、この特定のケースでは、行はネストされたgoals構造体で乗算されたので、この後に各セッションをカウントするために、arrayenumerateuniq()の値に条件を適用しまgoals.id)関数。 - -ArrayEnumerateUniq関数は、引数と同じサイズの複数の配列を取ることができます。 この場合、すべての配列の同じ位置にある要素のタプルに対して一意性が考慮されます。 - -``` sql -SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,1,1,2,1] │ -└───────────────┘ -``` - -これは、ネストされたデータ構造で配列結合を使用し、この構造内の複数の要素間でさらに集約する場合に必要です。 - -## arrayPopBack {#arraypopback} - -配列から最後の項目を削除します。 - -``` sql -arrayPopBack(array) -``` - -**パラメータ** - -- `array` – Array. - -**例えば** - -``` sql -SELECT arrayPopBack([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## arrayPopFront {#arraypopfront} - -配列から最初の項目を削除します。 - -``` sql -arrayPopFront(array) -``` - -**パラメータ** - -- `array` – Array. - -**例えば** - -``` sql -SELECT arrayPopFront([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [2,3] │ -└───────┘ -``` - -## arrayPushBack {#arraypushback} - -配列の末尾に一つの項目を追加します。 - -``` sql -arrayPushBack(array, single_value) -``` - -**パラメータ** - -- `array` – Array. -- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` 配列のデータ型の型。 ClickHouseのデータ型の詳細については、以下を参照してください “[データ型](../../sql_reference/data_types/index.md#data_types)”. できる。 `NULL`. この関数は、 `NULL` 配列への要素、および配列要素の型に変換します `Nullable`. - -**例えば** - -``` sql -SELECT arrayPushBack(['a'], 'b') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## arrayPushFront {#arraypushfront} - -配列の先頭に一つの要素を追加します。 - -``` sql -arrayPushFront(array, single_value) -``` - -**パラメータ** - -- `array` – Array. -- `single_value` – A single value. Only numbers can be added to an array with numbers, and only strings can be added to an array of strings. When adding numbers, ClickHouse automatically sets the `single_value` 配列のデータ型の型。 ClickHouseのデータ型の詳細については、以下を参照してください “[データ型](../../sql_reference/data_types/index.md#data_types)”. できる。 `NULL`. この関数は、 `NULL` 配列への要素、および配列要素の型に変換します `Nullable`. - -**例えば** - -``` sql -SELECT arrayPushFront(['b'], 'a') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## arrayResize {#arrayresize} - -配列の長さを変更します。 - -``` sql -arrayResize(array, size[, extender]) -``` - -**パラメータ:** - -- `array` — Array. -- `size` — Required length of the array. - - もし `size` 配列の元のサイズより小さい場合、配列は右から切り捨てられます。 -- もし `size` は配列の初期サイズより大きく、配列は次のように右に拡張されます `extender` 配列項目のデータ型の値または既定値。 -- `extender` — Value for extending an array. Can be `NULL`. - -**戻り値:** - -長さの配列 `size`. - -**通話の例** - -``` sql -SELECT arrayResize([1], 3) -``` - -``` text -┌─arrayResize([1], 3)─┐ -│ [1,0,0] │ -└─────────────────────┘ -``` - -``` sql -SELECT arrayResize([1], 3, NULL) -``` - -``` text -┌─arrayResize([1], 3, NULL)─┐ -│ [1,NULL,NULL] │ -└───────────────────────────┘ -``` - -## arraySlice {#arrayslice} - -配列のスライスを返します。 - -``` sql -arraySlice(array, offset[, length]) -``` - -**パラメータ** - -- `array` – Array of data. -- `offset` – Indent from the edge of the array. A positive value indicates an offset on the left, and a negative value is an indent on the right. Numbering of the array items begins with 1. -- `length` -必要なスライスの長さ。 負の値を指定すると、関数は開いているスライスを返します `[offset, array_length - length)`. 値を省略すると、関数はスライスを返します `[offset, the_end_of_array]`. - -**例えば** - -``` sql -SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res -``` - -``` text -┌─res────────┐ -│ [2,NULL,4] │ -└────────────┘ -``` - -に設定された配列要素 `NULL` 通常の値として扱われます。 - -## arraySort(\[func,\] arr, …) {#array_functions-sort} - -の要素をソートします `arr` 昇順の配列。 この `func` の結果によって決定される。 `func` 関数は、配列の要素に適用されます。 もし `func` 複数の引数を受け取る。 `arraySort` 関数はいくつかの配列を渡されます。 `func` に対応します。 詳しい例は終わりにの示されています `arraySort` 説明。 - -整数値のソート例: - -``` sql -SELECT arraySort([1, 3, 3, 0]); -``` - -``` text -┌─arraySort([1, 3, 3, 0])─┐ -│ [0,1,3,3] │ -└─────────────────────────┘ -``` - -文字列値のソートの例: - -``` sql -SELECT arraySort(['hello', 'world', '!']); -``` - -``` text -┌─arraySort(['hello', 'world', '!'])─┐ -│ ['!','hello','world'] │ -└────────────────────────────────────┘ -``` - -次の並べ替え順序を考えてみましょう。 `NULL`, `NaN` と `Inf` 値: - -``` sql -SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); -``` - -``` text -┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ -│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────────────────────────┘ -``` - -- `-Inf` 値は配列の最初のものです。 -- `NULL` 値は配列の最後です。 -- `NaN` 値は直前です `NULL`. -- `Inf` 値は直前です `NaN`. - -それに注意 `arraySort` は [高階関数](higher_order_functions.md). 最初の引数としてラムダ関数を渡すことができます。 この場合、並べ替え順序は、配列の要素に適用されるlambda関数の結果によって決まります。 - -次の例を考えてみましょう: - -``` sql -SELECT arraySort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,2,1] │ -└─────────┘ -``` - -For each element of the source array, the lambda function returns the sorting key, that is, \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Since the `arraySort` 関数はキーを昇順にソートし、結果は\[3,2,1\]になります。 このように、 `(x) –> -x` ラムダ関数は、 [降順](#array_functions-reverse-sort) ソートで。 - -Lambda関数は複数の引数を受け取ることができます。 この場合、次のものを渡す必要があります `arraySort` 関数lambda関数の引数が対応する同じ長さのいくつかの配列。 結果の配列は最初の入力配列の要素で構成され、次の入力配列の要素はソートキーを指定します。 例えば: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -ここでは、第二の配列(\[2、1\])に渡される要素は、ソース配列から対応する要素のソートキーを定義します (\[‘hello’, ‘world’\])、それは, \[‘hello’ –\> 2, ‘world’ –\> 1\]. Since the lambda function doesn't use `x` ソース配列の実際の値は、結果の順序には影響しません。 だから, ‘hello’ 結果の二番目の要素になります。 ‘world’ 最初になります。 - -その他の例を以下に示す。 - -``` sql -SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -``` sql -SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -!!! note "メモ" - 効率を分類することを改善するため [シュワルツ語変換](https://en.wikipedia.org/wiki/Schwartzian_transform) 使用される。 - -## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} - -の要素をソートします `arr` 降順での配列。 この `func` 機能は指定されます, `arr` の結果に従ってソートされます。 `func` 関数は、配列の要素に適用され、その後、ソートされた配列が反転されます。 もし `func` 複数の引数を受け取る。 `arrayReverseSort` 関数はいくつかの配列を渡されます。 `func` に対応します。 詳しい例は終わりにの示されています `arrayReverseSort` 説明。 - -整数値のソート例: - -``` sql -SELECT arrayReverseSort([1, 3, 3, 0]); -``` - -``` text -┌─arrayReverseSort([1, 3, 3, 0])─┐ -│ [3,3,1,0] │ -└────────────────────────────────┘ -``` - -文字列値のソートの例: - -``` sql -SELECT arrayReverseSort(['hello', 'world', '!']); -``` - -``` text -┌─arrayReverseSort(['hello', 'world', '!'])─┐ -│ ['world','hello','!'] │ -└───────────────────────────────────────────┘ -``` - -次の並べ替え順序を考えてみましょう。 `NULL`, `NaN` と `Inf` 値: - -``` sql -SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; -``` - -``` text -┌─res───────────────────────────────────┐ -│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────┘ -``` - -- `Inf` 値は配列の最初のものです。 -- `NULL` 値は配列の最後です。 -- `NaN` 値は直前です `NULL`. -- `-Inf` 値は直前です `NaN`. - -それに注意しなさい `arrayReverseSort` は [高階関数](higher_order_functions.md). 最初の引数としてラムダ関数を渡すことができます。 例を以下に示す。 - -``` sql -SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [1,2,3] │ -└─────────┘ -``` - -配列は次の方法でソートされます: - -1. 最初に、ソース配列(\[1、2、3\])は、配列の要素に適用されたラムダ関数の結果に従ってソートされます。 結果は配列\[3,2,1\]です。 -2. 前のステップで取得された配列は、逆になります。 したがって、最終的な結果は\[1,2,3\]です。 - -Lambda関数は複数の引数を受け取ることができます。 この場合、次のものを渡す必要があります `arrayReverseSort` 関数lambda関数の引数が対応する同じ長さのいくつかの配列。 結果の配列は最初の入力配列の要素で構成され、次の入力配列の要素はソートキーを指定します。 例えば: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -この例では、配列は次のようにソートされています: - -1. 最初に、ソース配列 (\[‘hello’, ‘world’\])は、配列の要素に適用されたラムダ関数の結果に従ってソートされます。 第二の配列(\[2、1\])に渡される要素は、ソース配列から対応する要素のソートキーを定義します。 結果は配列です \[‘world’, ‘hello’\]. -2. 前のステップでソートされた配列は、逆になります。 したがって、最終的な結果は \[‘hello’, ‘world’\]. - -その他の例を以下に示す。 - -``` sql -SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; -``` - -``` text -┌─res─────┐ -│ [5,3,4] │ -└─────────┘ -``` - -``` sql -SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; -``` - -``` text -┌─res─────┐ -│ [4,3,5] │ -└─────────┘ -``` - -## arrayUniq(arr, …) {#arrayuniqarr} - -一つの引数が渡された場合、それは、配列内の異なる要素の数をカウントします。 -複数の引数が渡されると、複数の配列内の対応する位置にある要素の異なるタプルの数がカウントされます。 - -配列内の一意の項目のリストを取得する場合は、arrayreduceを使用できます(‘groupUniqArray’、arr)。 - -## arrayJoin(arr) {#array-functions-join} - -特殊関数。 セクションを見る [“ArrayJoin function”](array_join.md#functions_arrayjoin). - -## arrayDifference {#arraydifference} - -隣接する配列要素間の差を計算します。 最初の要素が0になる配列を返します。 `a[1] - a[0]`, etc. The type of elements in the resulting array is determined by the type inference rules for subtraction (e.g. `UInt8` - `UInt8` = `Int16`). - -**構文** - -``` sql -arrayDifference(array) -``` - -**パラメータ** - -- `array` – [配列](https://clickhouse.yandex/docs/en/data_types/array/). - -**戻り値** - -隣接する要素間の差異の配列を返します。 - -タイプ: [UInt\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#uint-ranges), [Int\*](https://clickhouse.yandex/docs/en/data_types/int_uint/#int-ranges), [フロート\*](https://clickhouse.yandex/docs/en/data_types/float/). - -**例えば** - -クエリ: - -``` sql -SELECT arrayDifference([1, 2, 3, 4]) -``` - -結果: - -``` text -┌─arrayDifference([1, 2, 3, 4])─┐ -│ [0,1,1,1] │ -└───────────────────────────────┘ -``` - -結果の型int64によるオーバーフローの例: - -クエリ: - -``` sql -SELECT arrayDifference([0, 10000000000000000000]) -``` - -結果: - -``` text -┌─arrayDifference([0, 10000000000000000000])─┐ -│ [0,-8446744073709551616] │ -└────────────────────────────────────────────┘ -``` - -## arrayDistinct {#arraydistinct} - -配列をとり、distinct要素のみを含む配列を返します。 - -**構文** - -``` sql -arrayDistinct(array) -``` - -**パラメータ** - -- `array` – [配列](https://clickhouse.yandex/docs/en/data_types/array/). - -**戻り値** - -Distinct要素を含む配列を返します。 - -**例えば** - -クエリ: - -``` sql -SELECT arrayDistinct([1, 2, 2, 3, 1]) -``` - -結果: - -``` text -┌─arrayDistinct([1, 2, 2, 3, 1])─┐ -│ [1,2,3] │ -└────────────────────────────────┘ -``` - -## arrayEnumerateDense(arr) {#array_functions-arrayenumeratedense} - -ソース配列と同じサイズの配列を返し、各要素がソース配列のどこに最初に現れるかを示します。 - -例えば: - -``` sql -SELECT arrayEnumerateDense([10, 20, 10, 30]) -``` - -``` text -┌─arrayEnumerateDense([10, 20, 10, 30])─┐ -│ [1,2,1,3] │ -└───────────────────────────────────────┘ -``` - -## arrayIntersect(arr) {#array-functions-arrayintersect} - -複数の配列を取り、すべてのソース配列に存在する要素を持つ配列を返します。 結果の配列内の要素の順序は、最初の配列と同じです。 - -例えば: - -``` sql -SELECT - arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, - arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect -``` - -``` text -┌─no_intersect─┬─intersect─┐ -│ [] │ [1] │ -└──────────────┴───────────┘ -``` - -## arrayReduce {#arrayreduce} - -集計関数を配列要素に適用し、その結果を返します。 集約関数の名前は、一重引quotesで文字列として渡されます `'max'`, `'sum'`. パラメトリック集約関数を使用する場合、パラメータは関数名の後に括弧で囲んで示されます `'uniqUpTo(6)'`. - -**構文** - -``` sql -arrayReduce(agg_func, arr1, arr2, ..., arrN) -``` - -**パラメータ** - -- `agg_func` — The name of an aggregate function which should be a constant [文字列](../../sql_reference/data_types/string.md). -- `arr` — Any number of [配列](../../sql_reference/data_types/array.md) 集計関数のパラメーターとして列を入力します。 - -**戻り値** - -**例えば** - -``` sql -SELECT arrayReduce('max', [1, 2, 3]) -``` - -``` text -┌─arrayReduce('max', [1, 2, 3])─┐ -│ 3 │ -└───────────────────────────────┘ -``` - -集計関数が複数の引数を取る場合、この関数は同じサイズの複数の配列に適用する必要があります。 - -``` sql -SELECT arrayReduce('maxIf', [3, 5], [1, 0]) -``` - -``` text -┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ -│ 3 │ -└──────────────────────────────────────┘ -``` - -パラメトリック集計関数の使用例: - -``` sql -SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -``` - -``` text -┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ -│ 4 │ -└─────────────────────────────────────────────────────────────┘ -``` - -## arrayreduceinrangesname {#arrayreduceinranges} - -指定された範囲の配列要素に集計関数を適用し、各範囲に対応する結果を含む配列を返します。 この関数は、同じ結果を複数として返します `arrayReduce(agg_func, arraySlice(arr1, index, length), ...)`. - -**構文** - -``` sql -arrayReduceInRanges(agg_func, ranges, arr1, arr2, ..., arrN) -``` - -**パラメータ** - -- `agg_func` — The name of an aggregate function which should be a constant [文字列](../../sql_reference/data_types/string.md). -- `ranges` — The ranges to aggretate which should be an [配列](../../sql_reference/data_types/array.md) の [タプル](../../sql_reference/data_types/tuple.md) 各範囲のインデックスと長さを含む。 -- `arr` — Any number of [配列](../../sql_reference/data_types/array.md) 集計関数のパラメーターとして列を入力します。 - -**戻り値** - -**例えば** - -``` sql -SELECT arrayReduceInRanges( - 'sum', - [(1, 5), (2, 3), (3, 4), (4, 4)], - [1000000, 200000, 30000, 4000, 500, 60, 7] -) AS res -``` - -``` text -┌─res─────────────────────────┐ -│ [1234500,234000,34560,4567] │ -└─────────────────────────────┘ -``` - -## arrayReverse(arr) {#arrayreverse} - -要素を含む元の配列と同じサイズの配列を逆の順序で返します。 - -例えば: - -``` sql -SELECT arrayReverse([1, 2, 3]) -``` - -``` text -┌─arrayReverse([1, 2, 3])─┐ -│ [3,2,1] │ -└─────────────────────────┘ -``` - -## リバース(arr) {#array-functions-reverse} - -の同義語 [“arrayReverse”](#array_functions-arrayreverse) - -## arrayFlatten {#arrayflatten} - -配列の配列をフラット配列に変換します。 - -機能: - -- ネストされた配列の任意の深さに適用されます。 -- 既にフラットな配列は変更されません。 - -の平坦化された配列を含むすべての要素をすべてソース配列. - -**構文** - -``` sql -flatten(array_of_arrays) -``` - -エイリアス: `flatten`. - -**パラメータ** - -- `array_of_arrays` — [配列](../../sql_reference/data_types/array.md) 配列の。 例えば, `[[1,2,3], [4,5]]`. - -**例** - -``` sql -SELECT flatten([[[1]], [[2], [3]]]) -``` - -``` text -┌─flatten(array(array([1]), array([2], [3])))─┐ -│ [1,2,3] │ -└─────────────────────────────────────────────┘ -``` - -## arrayCompact {#arraycompact} - -配列から連続した重複する要素を削除します。 結果値の順序は、ソース配列の順序によって決まります。 - -**構文** - -``` sql -arrayCompact(arr) -``` - -**パラメータ** - -`arr` — The [配列](../../sql_reference/data_types/array.md) 検査する。 - -**戻り値** - -重複のない配列。 - -タイプ: `Array`. - -**例えば** - -クエリ: - -``` sql -SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) -``` - -結果: - -``` text -┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ -│ [1,nan,nan,2,3] │ -└────────────────────────────────────────────┘ -``` - -## arrayZip {#arrayzip} - -Combine multiple Array type columns into one Array\[Tuple(…)\] column - -**構文** - -``` sql -arrayZip(arr1, arr2, ..., arrN) -``` - -**パラメータ** - -`arr` — Any number of [配列](../../sql_reference/data_types/array.md) 結合する列を入力します。 - -**戻り値** - -The result of Array\[Tuple(…)\] type after the combination of these arrays - -**例えば** - -クエリ: - -``` sql -SELECT arrayZip(['a', 'b', 'c'], ['d', 'e', 'f']); -``` - -結果: - -``` text -┌─arrayZip(['a', 'b', 'c'], ['d', 'e', 'f'])─┐ -│ [('a','d'),('b','e'),('c','f')] │ -└────────────────────────────────────────────┘ -``` - -## arrayAUC {#arrayauc} - -計算auc(機械学習の概念である曲線の下の面積は、詳細を参照してください:https://en.wikipedia.org/wiki/receiver\_operating\_characteristic\#area\_under\_the\_curve). - -**構文** - -``` sql -arrayAUC(arr_scores, arr_labels) -``` - -**パラメータ** -- `arr_scores` — scores prediction model gives. -- `arr_labels` — labels of samples, usually 1 for positive sample and 0 for negtive sample. - -**戻り値** -Float64型のAUC値を返します。 - -**例えば** -クエリ: - -``` sql -select arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]) -``` - -結果: - -``` text -┌─arrayAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1])─┐ -│ 0.75 │ -└────────────────────────────────────────---──┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/ja/sql_reference/functions/array_join.md b/docs/ja/sql_reference/functions/array_join.md deleted file mode 100644 index 4cbc0690b8b..00000000000 --- a/docs/ja/sql_reference/functions/array_join.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 61 -toc_title: arrayJoin ---- - -# arrayJoin関数 {#functions_arrayjoin} - -これは非常に珍しい機能です。 - -通常の関数は行のセットを変更するのではなく、各行(map)の値を変更するだけです。 -集計関数は、行のセットを圧縮します(折り畳みまたは縮小)。 -その ‘arrayJoin’ 関数は、各行を受け取り、行のセット(展開)を生成します。 - -この関数は、引数として配列を受け取り、配列内の要素の数のために複数の行にソース行を伝播します。 -列内のすべての値は、この関数が適用される列内の値を除いて単純にコピーされます。 - -クエリは複数を使用できます `arrayJoin` 機能。 この場合、変換は複数回実行されます。 - -メモselectクエリの配列結合の構文は、より広範な可能性を提供します。 - -例えば: - -``` sql -SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src -``` - -``` text -┌─dst─┬─\'Hello\'─┬─src─────┐ -│ 1 │ Hello │ [1,2,3] │ -│ 2 │ Hello │ [1,2,3] │ -│ 3 │ Hello │ [1,2,3] │ -└─────┴───────────┴─────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/array_join/) diff --git a/docs/ja/sql_reference/functions/bit_functions.md b/docs/ja/sql_reference/functions/bit_functions.md deleted file mode 100644 index d5d8c0ca769..00000000000 --- a/docs/ja/sql_reference/functions/bit_functions.md +++ /dev/null @@ -1,255 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 48 -toc_title: "\u30D3\u30C3\u30C8" ---- - -# ビット機能 {#bit-functions} - -ビット関数は、uint8、uint16、uint32、uint64、int8、int16、int32、int64、float32、またはfloat64のいずれかの種類のペアで機能します。 - -結果の型は、その引数の最大ビットに等しいビットを持つ整数です。 引数のうち少なくとも一方が署名されている場合、結果は署名された番号になります。 引数が浮動小数点数の場合、int64にキャストされます。 - -## bitAnd(a,b) {#bitanda-b} - -## bitOr(a,b) {#bitora-b} - -## bitXor(a,b) {#bitxora-b} - -## bitNot(a) {#bitnota} - -## ビットシフトレフト(a,b) {#bitshiftlefta-b} - -## ビットシフトライト(a,b) {#bitshiftrighta-b} - -## bitRotateLeft(a,b) {#bitrotatelefta-b} - -## bitRotateRight(a,b) {#bitrotaterighta-b} - -## 適者生存 {#bittest} - -任意の整数を受け取り、それを [バイナリ形式](https://en.wikipedia.org/wiki/Binary_number)、指定された位置にあるビットの値を返します。 カウントダウンは右から左に0から始まります。 - -**構文** - -``` sql -SELECT bitTest(number, index) -``` - -**パラメータ** - -- `number` – integer number. -- `index` – position of bit. - -**戻り値** - -指定された位置にあるbitの値を返します。 - -タイプ: `UInt8`. - -**例えば** - -たとえば、ベース43(バイナリ)数値システムの数値は101011です。 - -クエリ: - -``` sql -SELECT bitTest(43, 1) -``` - -結果: - -``` text -┌─bitTest(43, 1)─┐ -│ 1 │ -└────────────────┘ -``` - -別の例: - -クエリ: - -``` sql -SELECT bitTest(43, 2) -``` - -結果: - -``` text -┌─bitTest(43, 2)─┐ -│ 0 │ -└────────────────┘ -``` - -## bitTestAll {#bittestall} - -の結果を返します [論理結合](https://en.wikipedia.org/wiki/Logical_conjunction) 与えられた位置にあるすべてのビットの(and演算子)。 カウントダウンは右から左に0から始まります。 - -ビット演算のためのconjuction: - -0 AND 0 = 0 - -0 AND 1 = 0 - -1 AND 0 = 0 - -1 AND 1 = 1 - -**構文** - -``` sql -SELECT bitTestAll(number, index1, index2, index3, index4, ...) -``` - -**パラメータ** - -- `number` – integer number. -- `index1`, `index2`, `index3`, `index4` – positions of bit. For example, for set of positions (`index1`, `index2`, `index3`, `index4` すべてのポジションがtrueの場合にのみtrue (`index1` ⋀ `index2`, ⋀ `index3` ⋀ `index4`). - -**戻り値** - -論理conjuctionの結果を返します。 - -タイプ: `UInt8`. - -**例えば** - -たとえば、ベース43(バイナリ)数値システムの数値は101011です。 - -クエリ: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5) -``` - -結果: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5)─┐ -│ 1 │ -└────────────────────────────┘ -``` - -別の例: - -クエリ: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5, 2) -``` - -結果: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ -│ 0 │ -└───────────────────────────────┘ -``` - -## bitTestAny {#bittestany} - -の結果を返します [論理和](https://en.wikipedia.org/wiki/Logical_disjunction) 与えられた位置にあるすべてのビットの(または演算子)。 カウントダウンは右から左に0から始まります。 - -ビットごとの操作のための分離: - -0 OR 0 = 0 - -0 OR 1 = 1 - -1 OR 0 = 1 - -1 OR 1 = 1 - -**構文** - -``` sql -SELECT bitTestAny(number, index1, index2, index3, index4, ...) -``` - -**パラメータ** - -- `number` – integer number. -- `index1`, `index2`, `index3`, `index4` – positions of bit. - -**戻り値** - -論理disjuctionの結果を返します。 - -タイプ: `UInt8`. - -**例えば** - -たとえば、ベース43(バイナリ)数値システムの数値は101011です。 - -クエリ: - -``` sql -SELECT bitTestAny(43, 0, 2) -``` - -結果: - -``` text -┌─bitTestAny(43, 0, 2)─┐ -│ 1 │ -└──────────────────────┘ -``` - -別の例: - -クエリ: - -``` sql -SELECT bitTestAny(43, 4, 2) -``` - -結果: - -``` text -┌─bitTestAny(43, 4, 2)─┐ -│ 0 │ -└──────────────────────┘ -``` - -## ビット数 {#bitcount} - -数値のバイナリ表現で設定されたビット数を計算します。 - -**構文** - -``` sql -bitCount(x) -``` - -**パラメータ** - -- `x` — [整数](../../sql_reference/data_types/int_uint.md) または [浮動小数点](../../sql_reference/data_types/float.md) 番号 この関数は、メモリ内の値表現を使用します。 浮動小数点数をサポートすることができます。 - -**戻り値** - -- 入力番号内のビット数を一つに設定します。 - -この関数は入力値を大きな型に変換しません ([記号の拡張子](https://en.wikipedia.org/wiki/Sign_extension)). 例えば, `bitCount(toUInt8(-1)) = 8`. - -タイプ: `UInt8`. - -**例えば** - -例えば、数333を取ります。 そのバイナリ表現:00000000101001101。 - -クエリ: - -``` sql -SELECT bitCount(333) -``` - -結果: - -``` text -┌─bitCount(333)─┐ -│ 5 │ -└───────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/ja/sql_reference/functions/bitmap_functions.md b/docs/ja/sql_reference/functions/bitmap_functions.md deleted file mode 100644 index ddcef7b2093..00000000000 --- a/docs/ja/sql_reference/functions/bitmap_functions.md +++ /dev/null @@ -1,496 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 49 -toc_title: Bitmap ---- - -# ビットマップ関数 {#bitmap-functions} - -ビットマップ関数は、二つのビットマップオブジェクトの値の計算のために働く、そのような、および、または、xor、およびない、などの式の計算を使用し - -ビットマップオブジェクトの構築方法には2種類あります。 一つは-stateを持つ集約関数groupbitmapによって構築されることであり、もう一つは配列オブジェクトによって構築されることである。 また、bitmapオブジェクトをarrayオブジェクトに変換します。 - -RoaringBitmapは、ビットマップオブジェクトの実際の格納中にデータ構造にラップされます。 基数が32以下の場合、Set objetが使用されます。 カーディナリティが32より大きい場合、Rooaringbitmapオブジェクトが使用されます。 そのため、低カーディナリティセットの保存が高速になります。 - -RoaringBitmapの詳細については、以下を参照してください: [鳴き声](https://github.com/RoaringBitmap/CRoaring). - -## bitmapBuild {#bitmap_functions-bitmapbuild} - -符号なし整数配列からビットマップを作成します。 - -``` sql -bitmapBuild(array) -``` - -**パラメータ** - -- `array` – unsigned integer array. - -**例えば** - -``` sql -SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) -``` - -``` text -┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ -│  │ AggregateFunction(groupBitmap, UInt8) │ -└─────┴──────────────────────────────────────────────┘ -``` - -## bitmapToArray {#bitmaptoarray} - -ビットマップを整数配列に変換します。 - -``` sql -bitmapToArray(bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## bitmapSubsetInRange {#bitmap-functions-bitmapsubsetinrange} - -指定された範囲のサブセットを返します(range\_endは含みません)。 - -``` sql -bitmapSubsetInRange(bitmap, range_start, range_end) -``` - -**パラメータ** - -- `bitmap` – [ビットマップ](#bitmap_functions-bitmapbuild). -- `range_start` – range start point. Type: [UInt32](../../sql_reference/data_types/int_uint.md). -- `range_end` – range end point(excluded). Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -``` text -┌─res───────────────┐ -│ [30,31,32,33,100] │ -└───────────────────┘ -``` - -## bitmapSubsetLimit {#bitmapsubsetlimit} - -ビットマップのサブセットを作成します。 `range_start` と `cardinality_limit`. - -**構文** - -``` sql -bitmapSubsetLimit(bitmap, range_start, cardinality_limit) -``` - -**パラメータ** - -- `bitmap` – [ビットマップ](#bitmap_functions-bitmapbuild). -- `range_start` – The subset starting point. Type: [UInt32](../../sql_reference/data_types/int_uint.md). -- `cardinality_limit` – The subset cardinality upper limit. Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -サブセット。 - -タイプ: `Bitmap object`. - -**例えば** - -クエリ: - -``` sql -SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -結果: - -``` text -┌─res───────────────────────┐ -│ [30,31,32,33,100,200,500] │ -└───────────────────────────┘ -``` - -## bitmapContains {#bitmap_functions-bitmapcontains} - -かどうかをチェックしますビットマップを含む要素になります。 - -``` sql -bitmapContains(haystack, needle) -``` - -**パラメータ** - -- `haystack` – [ビットマップ](#bitmap_functions-bitmapbuild)、関数が検索する場所。 -- `needle` – Value that the function searches. Type: [UInt32](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- 0 — If `haystack` 含まない `needle`. -- 1 — If `haystack` 含む `needle`. - -タイプ: `UInt8`. - -**例えば** - -``` sql -SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAny {#bitmaphasany} - -るかどうかを判二つのビットマップしていることで交差点にある。 - -``` sql -bitmapHasAny(bitmap1, bitmap2) -``` - -あなたが確信している場合 `bitmap2` 一つの要素が含まれています。 [bitmapContains](#bitmap_functions-bitmapcontains) 機能。 これは、より効率的に動作します。 - -**パラメータ** - -- `bitmap*` – bitmap object. - -**戻り値** - -- `1`,もし `bitmap1` と `bitmap2` 少なくとも同様の要素を持っている。 -- `0` そうでなければ - -**例えば** - -``` sql -SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAll {#bitmaphasall} - -に類似した `hasAll(array, array)` 最初のビットマップに1番目のビットマップのすべての要素が含まれる場合は0を返します。 -二番目の引数が空のビットマップの場合、1を返します。 - -``` sql -bitmapHasAll(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 0 │ -└─────┘ -``` - -## bitmapCardinality {#bitmapcardinality} - -UInt64型のビットマップのカーディナリティを再度実行可能。 - -``` sql -bitmapCardinality(bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## bitmapmincomment {#bitmapmin} - -セット内のタイプuint64の最小値を再度取り消し、セットが空の場合はuint32\_max。 - - bitmapMin(bitmap) - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 1 │ - └─────┘ - -## bitmapMax {#bitmapmax} - -セット内のuint64型の最大値を取り消し、セットが空の場合は0になります。 - - bitmapMax(bitmap) - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 5 │ - └─────┘ - -## bitmapTransform {#bitmaptransform} - -ビットマップ内の値の配列を別の値の配列に変換すると、結果は新しいビットマップになります。 - - bitmapTransform(bitmap, from_array, to_array) - -**パラメータ** - -- `bitmap` – bitmap object. -- `from_array` – UInt32 array. For idx in range \[0, from\_array.size()), if bitmap contains from\_array\[idx\], then replace it with to\_array\[idx\]. Note that the result depends on array ordering if there are common elements between from\_array and to\_array. -- `to_array` – UInt32 array, its size shall be the same to from\_array. - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res -``` - - ┌─res───────────────────┐ - │ [1,3,4,6,7,8,9,10,20] │ - └───────────────────────┘ - -## bitmapAnd {#bitmapand} - -二つのビットマップと計算、結果は新しいビットマップです。 - -``` sql -bitmapAnd(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─┐ -│ [3] │ -└─────┘ -``` - -## bitmapOr {#bitmapor} - -二つのビットマップや計算、結果は新しいビットマップです。 - -``` sql -bitmapOr(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## bitmapXor {#bitmapxor} - -二つのビットマップxor計算、結果は新しいビットマップです。 - -``` sql -bitmapXor(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,4,5] │ -└───────────┘ -``` - -## bitmapAndnot {#bitmapandnot} - -二つのビットマップと計算ではなく、結果は新しいビットマップです。 - -``` sql -bitmapAndnot(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## bitmapAndCardinality {#bitmapandcardinality} - -二つのビットマップと計算、型uint64の戻り値のカーディナリティ。 - -``` sql -bitmapAndCardinality(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## ビットmapcardinality {#bitmaporcardinality} - -二つのビットマップまたは計算、型uint64の戻り値のカーディナリティ。 - -``` sql -bitmapOrCardinality(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## bitmapXorCardinality {#bitmapxorcardinality} - -二つのビットマップxor計算、型uint64の戻り値のカーディナリティ。 - -``` sql -bitmapXorCardinality(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 4 │ -└─────┘ -``` - -## bitmapAndnotCardinality {#bitmapandnotcardinality} - -二つのビットマップと計算ではなく、型uint64のカーディナリティを返します。 - -``` sql -bitmapAndnotCardinality(bitmap,bitmap) -``` - -**パラメータ** - -- `bitmap` – bitmap object. - -**例えば** - -``` sql -SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 2 │ -└─────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/ja/sql_reference/functions/comparison_functions.md b/docs/ja/sql_reference/functions/comparison_functions.md deleted file mode 100644 index e1b7364bda6..00000000000 --- a/docs/ja/sql_reference/functions/comparison_functions.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 36 -toc_title: "\u6BD4\u8F03" ---- - -# 比較関数 {#comparison-functions} - -比較関数は常に0または1(uint8)を返します。 - -次のタイプを比較できます: - -- 数字 -- 文字列と固定文字列 -- 日付 -- 時間のある日付 - -各グループ内ではなく、異なるグループ間。 - -たとえば、日付と文字列を比較することはできません。 文字列を日付に変換するには関数を使用する必要があります。 - -文字列はバイトで比較されます。 短い文字列は、それで始まり、少なくとも一つ以上の文字を含むすべての文字列よりも小さくなります。 - -## 等号、a=bおよびa===b演算子 {#function-equals} - -## notEquals,a! 演算子=bとa\<\>b {#function-notequals} - -## 演算子 {#function-less} - -## より大きい、\>演算子 {#function-greater} - -## リース、\<=演算子 {#function-lessorequals} - -## greaterOrEquals,\>=演算子 {#function-greaterorequals} - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/ja/sql_reference/functions/conditional_functions.md b/docs/ja/sql_reference/functions/conditional_functions.md deleted file mode 100644 index 4bb83bd44f7..00000000000 --- a/docs/ja/sql_reference/functions/conditional_functions.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: "\u6761\u4EF6\u4ED8\u304D " ---- - -# 条件関数 {#conditional-functions} - -## もし {#if} - -条件分岐を制御します。 と異なりほとんどのシステムclickhouse常に評価さの両方表現 `then` と `else`. - -**構文** - -``` sql -SELECT if(cond, then, else) -``` - -条件の場合 `cond` ゼロ以外の値として評価し、式の結果を返します `then`、および式の結果 `else`、存在する場合は、スキップされます。 この `cond` ゼロまたは `NULL` その後の結果 `then` 式はスキップされる。 `else` 式が存在する場合は、その式が返されます。 - -**パラメータ** - -- `cond` – The condition for evaluation that can be zero or not. The type is UInt8, Nullable(UInt8) or NULL. -- `then` -条件が満たされた場合に返される式。 -- `else` -条件が満たされていない場合に返される式。 - -**戻り値** - -関数が実行されます `then` と `else` 式とその結果を返します。 `cond` ゼロかどうかに終わった。 - -**例えば** - -クエリ: - -``` sql -SELECT if(1, plus(2, 2), plus(2, 6)) -``` - -結果: - -``` text -┌─plus(2, 2)─┐ -│ 4 │ -└────────────┘ -``` - -クエリ: - -``` sql -SELECT if(0, plus(2, 2), plus(2, 6)) -``` - -結果: - -``` text -┌─plus(2, 6)─┐ -│ 8 │ -└────────────┘ -``` - -- `then` と `else` 共通タイプが最も小さい。 - -**例えば:** - -これを取る `LEFT_RIGHT` テーブル: - -``` sql -SELECT * -FROM LEFT_RIGHT - -┌─left─┬─right─┐ -│ ᴺᵁᴸᴸ │ 4 │ -│ 1 │ 3 │ -│ 2 │ 2 │ -│ 3 │ 1 │ -│ 4 │ ᴺᵁᴸᴸ │ -└──────┴───────┘ -``` - -次のクエリは比較します `left` と `right` 値: - -``` sql -SELECT - left, - right, - if(left < right, 'left is smaller than right', 'right is greater or equal than left') AS is_smaller -FROM LEFT_RIGHT -WHERE isNotNull(left) AND isNotNull(right) - -┌─left─┬─right─┬─is_smaller──────────────────────────┐ -│ 1 │ 3 │ left is smaller than right │ -│ 2 │ 2 │ right is greater or equal than left │ -│ 3 │ 1 │ right is greater or equal than left │ -└──────┴───────┴─────────────────────────────────────┘ -``` - -メモ: `NULL` この例では値は使用されません。 [条件のnull値](#null-values-in-conditionals) セクション。 - -## 三項演算子 {#ternary-operator} - -この作品と同じ `if` 機能。 - -構文: `cond ? then : else` - -を返します `then` この `cond` true(ゼロより大きい)と評価され、それ以外の場合は `else`. - -- `cond` のタイプである必要があります `UInt8`、と `then` と `else` 共通タイプが最も小さい。 - -- `then` と `else` できる。 `NULL` - -**また見なさい** - -- [ifNotFinite](other_functions.md#ifnotfinite). - -## multif {#multiif} - -あなたが書くことができます [CASE](../operators.md#operator_case) クエリでよりコンパクトに演算子。 - -構文: `multiIf(cond_1, then_1, cond_2, then_2, ..., else)` - -**パラメータ:** - -- `cond_N` — The condition for the function to return `then_N`. -- `then_N` — The result of the function when executed. -- `else` — The result of the function if none of the conditions is met. - -この関数は、 `2N+1` パラメータ。 - -**戻り値** - -この関数は、いずれかの値を返します `then_N` または `else`、条件に応じて `cond_N`. - -**例えば** - -再度を使用して `LEFT_RIGHT` テーブル。 - -``` sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─result──────────┐ -│ ᴺᵁᴸᴸ │ 4 │ Null value │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ left is greater │ -│ 4 │ ᴺᵁᴸᴸ │ Null value │ -└──────┴───────┴─────────────────┘ -``` - -## 条件付き結果を直接使用する {#using-conditional-results-directly} - -条件は常に次のようになります `0`, `1` または `NULL`. できますので使用条件と結果が直接このような: - -``` sql -SELECT left < right AS is_small -FROM LEFT_RIGHT - -┌─is_small─┐ -│ ᴺᵁᴸᴸ │ -│ 1 │ -│ 0 │ -│ 0 │ -│ ᴺᵁᴸᴸ │ -└──────────┘ -``` - -## 条件のnull値 {#null-values-in-conditionals} - -とき `NULL` 値は条件文に含まれ、結果は次のようになります `NULL`. - -``` sql -SELECT - NULL < 1, - 2 < NULL, - NULL < NULL, - NULL = NULL - -┌─less(NULL, 1)─┬─less(2, NULL)─┬─less(NULL, NULL)─┬─equals(NULL, NULL)─┐ -│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└───────────────┴───────────────┴──────────────────┴────────────────────┘ -``` - -したがって、型が `Nullable`. - -次の例は、equals条件を追加できないことを示しています `multiIf`. - -``` sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'right is smaller', 'Both equal') AS faulty_result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─faulty_result────┐ -│ ᴺᵁᴸᴸ │ 4 │ Both equal │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ right is smaller │ -│ 4 │ ᴺᵁᴸᴸ │ Both equal │ -└──────┴───────┴──────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/ja/sql_reference/functions/date_time_functions.md b/docs/ja/sql_reference/functions/date_time_functions.md deleted file mode 100644 index 6a076711e4a..00000000000 --- a/docs/ja/sql_reference/functions/date_time_functions.md +++ /dev/null @@ -1,450 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u65E5\u4ED8\u3068\u6642\u523B\u306E\u64CD\u4F5C" ---- - -# 日付と時刻を操作するための関数 {#functions-for-working-with-dates-and-times} - -タイムゾーンのサポート - -タイムゾーンの論理的使用を持つ日付と時刻を操作するためのすべての関数は、二番目の省略可能なタイムゾーン引数を受け入れることができます。 例:アジア/エカテリンブルク。 この場合、ローカル(デフォルト)の代わりに指定されたタイムゾーンを使用します。 - -``` sql -SELECT - toDateTime('2016-06-15 23:00:00') AS time, - toDate(time) AS date_local, - toDate(time, 'Asia/Yekaterinburg') AS date_yekat, - toString(time, 'US/Samoa') AS time_samoa -``` - -``` text -┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ -└─────────────────────┴────────────┴────────────┴─────────────────────┘ -``` - -UTCと時間数が異なるタイムゾーンのみがサポートされます。 - -## トティメゾン {#totimezone} - -時刻または日付と時刻を指定したタイムゾーンに変換します。 - -## toYear {#toyear} - -時刻を含む日付または日付を年番号(ad)を含むuint16番号に変換します。 - -## toQuarter {#toquarter} - -時刻を含む日付または日付を、四半期番号を含むuint8番号に変換します。 - -## トモント県france.kgm {#tomonth} - -時刻を含む日付または日付を、月番号(1~12)を含むuint8番号に変換します。 - -## 今日の年 {#todayofyear} - -時刻を含む日付または日付を、その年の日付の番号(1-366)を含むuint16番号に変換します。 - -## toDayOfMonth {#todayofmonth} - -時刻を含む日付または日付を、その月の日の番号(1-31)を含むuint8番号に変換します。 - -## toDayOfWeek {#todayofweek} - -時刻を含む日付または日付を、曜日の番号を含むuint8番号に変換します(月曜日は1、日曜日は7)。 - -## tohourgenericname {#tohour} - -時刻を含む日付を、uint8の24時間(0-23)の時刻を含む数値に変換します。 -This function assumes that if clocks are moved ahead, it is by one hour and occurs at 2 a.m., and if clocks are moved back, it is by one hour and occurs at 3 a.m. (which is not always true – even in Moscow the clocks were twice changed at a different time). - -## toMinute {#tominute} - -時刻を含む日付を、時刻の分(0~59)の数を含むuint8数値に変換します。 - -## ト秒 {#tosecond} - -Timeを含む日付をUInt8の数値に変換します(0~59)。 -うるう秒は説明されていません。 - -## toUnixTimestamp {#to-unix-timestamp} - -For DateTime argument:値を内部の数値表現(Unixタイムスタンプ)に変換します。 -文字列引数の場合:タイムゾーンに従って文字列からのdatetimeを解析します(オプションの第二引数、サーバーのタイムゾーンはデフォルトで使用されます)。 -日付の引数の場合:この動作は指定されていません。 - -**構文** - -``` sql -toUnixTimestamp(datetime) -toUnixTimestamp(str, [timezone]) -``` - -**戻り値** - -- Unixタイムスタンプを返す。 - -タイプ: `UInt32`. - -**例えば** - -クエリ: - -``` sql -SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp -``` - -結果: - -``` text -┌─unix_timestamp─┐ -│ 1509836867 │ -└────────────────┘ -``` - -## toStartOfYear {#tostartofyear} - -日付または日付のある時刻を年の最初の日に切り捨てます。 -日付を返します。 - -## tostartofisoyearcomment {#tostartofisoyear} - -日付または日付と時刻をiso暦年の最初の日に切り捨てます。 -日付を返します。 - -## toStartOfQuarter {#tostartofquarter} - -日付または日付のある時刻を四半期の最初の日に切り捨てます。 -四半期の最初の日はどちらかです1月,1四月,1七月,若しくは1十月. -日付を返します。 - -## toStartOfMonth {#tostartofmonth} - -日付または日付と時刻を月の最初の日に切り捨てます。 -日付を返します。 - -!!! attention "注意" - 間違った日付を解析する動作は実装固有です。 clickhouseはゼロの日付を返したり、例外をスローしたりします “natural” オーバーフロー - -## toMonday {#tomonday} - -日付または日付と時刻を最も近い月曜日に切り捨てます。 -日付を返します。 - -## toStartOfWeek(t\[,mode\]) {#tostartofweektmode} - -日付または日付と時刻を、モード別に最も近い日曜日または月曜日に切り捨てます。 -日付を返します。 -Mode引数は、toWeek()のmode引数とまったく同じように動作します。 単一引数の構文では、モード値0が使用されます。 - -## toStartOfDay {#tostartofday} - -時刻を含む日付をその日の始まりに切り捨てます。 - -## toStartOfHour {#tostartofhour} - -時刻を含む日付を時間の開始位置に切り捨てます。 - -## toStartOfMinute {#tostartofminute} - -日付と時刻が分の先頭に切り捨てられます。 - -## toStartOfFiveMinute {#tostartoffiveminute} - -日付と時刻を切り捨てます。 - -## トスタートオフテンミニュート {#tostartoftenminutes} - -日付と時刻を切り捨てます。 - -## トスタートオフィフテンミニュート {#tostartoffifteenminutes} - -日付と時刻を切り捨てます。 - -## toStartOfInterval(time\_or\_data,間隔xユニット\[,time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} - -これは、名前の付いた他の関数の一般化です `toStartOf*`. 例えば, -`toStartOfInterval(t, INTERVAL 1 year)` と同じを返します `toStartOfYear(t)`, -`toStartOfInterval(t, INTERVAL 1 month)` と同じを返します `toStartOfMonth(t)`, -`toStartOfInterval(t, INTERVAL 1 day)` と同じを返します `toStartOfDay(t)`, -`toStartOfInterval(t, INTERVAL 15 minute)` と同じを返します `toStartOfFifteenMinutes(t)` など。 - -## トタイム {#totime} - -時刻を保持しながら、時刻を含む日付を特定の固定日付に変換します。 - -## torelativeyearnumcomment {#torelativeyearnum} - -時刻または日付の日付を、過去の特定の固定小数点から始まる年の数に変換します。 - -## torelativequarternumcomment {#torelativequarternum} - -時刻または日付の日付を、過去の特定の固定小数点から開始して、四半期の数に変換します。 - -## torelativemonthnumcomment {#torelativemonthnum} - -時刻または日付を含む日付を、過去の特定の固定小数点から始まる月の数に変換します。 - -## torelativeweeknumcomment {#torelativeweeknum} - -時刻または日付を含む日付を、過去の特定の固定小数点から始まる週の数に変換します。 - -## torrelativedaynumcomment {#torelativedaynum} - -時刻または日付を含む日付を、過去の特定の固定小数点から始まる日の数に変換します。 - -## torrelativehournumgenericname {#torelativehournum} - -時刻または日付の日付を、過去の特定の固定小数点から始まる時間の数値に変換します。 - -## toRelativeMinuteNum {#torelativeminutenum} - -時刻または日付の日付を、過去の特定の固定小数点から始まる分の数値に変換します。 - -## torrelativesecondnumcomdnamescription {#torelativesecondnum} - -時刻または日付の日付を、過去の特定の固定小数点から開始して秒の数値に変換します。 - -## toISOYear {#toisoyear} - -時刻を含む日付または日付を、iso年番号を含むuint16番号に変換します。 - -## toISOWeek {#toisoweek} - -時刻を含む日付または日付を、iso週番号を含むuint8番号に変換します。 - -## toWeek(日付\[,モード\]) {#toweekdatemode} - -この関数は、dateまたはdatetimeの週番号を返します。 また、戻り値の範囲が0から53または1から53のどちらであるかを指定することができます。 引数modeを省略すると、デフォルトのモードは0になります。 -`toISOWeek()`は、以下と同等の互換性関数です `toWeek(date,3)`. -次の表では、mode引数の動作について説明します。 - -| モード | 週の最初の日 | 範囲 | Week 1 is the first week … | -|--------|--------------|------|----------------------------| -| 0 | 日曜日 | 0-53 | 今年の日曜日に | -| 1 | 月曜日 | 0-53 | 今年は4日以上 | -| 2 | 日曜日 | 1-53 | 今年の日曜日に | -| 3 | 月曜日 | 1-53 | 今年は4日以上 | -| 4 | 日曜日 | 0-53 | 今年は4日以上 | -| 5 | 月曜日 | 0-53 | 今年の月曜日と | -| 6 | 日曜日 | 1-53 | 今年は4日以上 | -| 7 | 月曜日 | 1-53 | 今年の月曜日と | -| 8 | 日曜日 | 1-53 | 含まれ月1 | -| 9 | 月曜日 | 1-53 | 含まれ月1 | - -意味のあるモード値の場合 “with 4 or more days this year,” 週はISO8601:1988に従って番号が付けられます: - -- 1月を含む週がある場合4新年の日,それは週です1. - -- それ以外の場合は、前年の最後の週であり、次の週は1週です。 - -意味のあるモード値の場合 “contains January 1” の週の月には1週間に1. たとえそれが一日だけ含まれていても、その週に含まれている新年の日数は関係ありません。 - -``` sql -toWeek(date, [, mode][, Timezone]) -``` - -**パラメータ** - -- `date` – Date or DateTime. -- `mode` – Optional parameter, Range of values is \[0,9\], default is 0. -- `Timezone` – Optional parameter, it behaves like any other conversion function. - -**例えば** - -``` sql -SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9; -``` - -``` text -┌───────date─┬─week0─┬─week1─┬─week9─┐ -│ 2016-12-27 │ 52 │ 52 │ 1 │ -└────────────┴───────┴───────┴───────┘ -``` - -## toeearweek(日付\[,モード\]) {#toyearweekdatemode} - -日付の年と週を返します。 結果の年は、その年の最初と最後の週の日付の引数の年とは異なる場合があります。 - -Mode引数は、toWeek()のmode引数とまったく同じように動作します。 単一引数の構文では、モード値0が使用されます。 - -`toISOYear()`は、以下と同等の互換性関数です `intDiv(toYearWeek(date,3),100)`. - -**例えば** - -``` sql -SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9; -``` - -``` text -┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┐ -│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ -└────────────┴───────────┴───────────┴───────────┘ -``` - -## さて {#now} - -ゼロ引数を受け取り、リクエスト実行のいずれかの時点で現在の時刻を返します。 -この関数は、要求が完了するまでに長い時間がかかった場合でも、定数を返します。 - -## 今日 {#today} - -ゼロ引数を受け取り、リクエスト実行のいずれかの時点で現在の日付を返します。 -同じように ‘toDate(now())’. - -## 昨日 {#yesterday} - -ゼロの引数を受け取り、リクエストの実行のいずれかの時点で、昨日の日付を返します。 -同じように ‘today() - 1’. - -## タイムスロット {#timeslot} - -時間を半分時間に丸めます。 -この機能はyandexに固有です。トラッキングタグがこの量よりも厳密に時間が異なる単一のユーザーの連続したページビューを表示する場合、セッションを二つのセッションに分割す つまり、タプル(タグid、ユーザー id、およびタイムスロット)を使用して、対応するセッションに含まれるページビューを検索できます。 - -## toYYYYMM {#toyyyymm} - -時刻を含む日付または日付を、年と月の数値(yyyy\*100+mm)を含むuint32番号に変換します。 - -## toyyymmdd {#toyyyymmdd} - -時刻を含む日付または日付を、年と月の数値(yyyy\*10000+mm\*100+dd)を含むuint32番号に変換します。 - -## toYYYYMMDDhhmmss {#toyyyymmddhhmmss} - -時刻付きの日付または日付を、年と月の数値を含むuint64番号に変換します(yyyy\*10000000000+mm\*100000000+dd\*1000000+hh\*10000+mm\*100+ss)。 - -## addYears,addMonths,addweks,addDays,addHours,addMinutes,addSeconds,addQuarters {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} - -関数は、日付/日付時刻の間隔を日付/日付時刻に追加してから、日付/日付時刻を返します。 例えば: - -``` sql -WITH - toDate('2018-01-01') AS date, - toDateTime('2018-01-01 00:00:00') AS date_time -SELECT - addYears(date, 1) AS add_years_with_date, - addYears(date_time, 1) AS add_years_with_date_time -``` - -``` text -┌─add_years_with_date─┬─add_years_with_date_time─┐ -│ 2019-01-01 │ 2019-01-01 00:00:00 │ -└─────────────────────┴──────────────────────────┘ -``` - -## subtractYears,subtractMonths,subtractWeeks,subtractDays,subtractHours,subtractMinutes,subtractSeconds,subtractQuarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} - -関数date/datetime間隔をdate/datetimeに減算し、date/datetimeを返します。 例えば: - -``` sql -WITH - toDate('2019-01-01') AS date, - toDateTime('2019-01-01 00:00:00') AS date_time -SELECT - subtractYears(date, 1) AS subtract_years_with_date, - subtractYears(date_time, 1) AS subtract_years_with_date_time -``` - -``` text -┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ -│ 2018-01-01 │ 2018-01-01 00:00:00 │ -└──────────────────────────┴───────────────────────────────┘ -``` - -## dateDiff {#datediff} - -日付または日付時刻値の差を返します。 - -**構文** - -``` sql -dateDiff('unit', startdate, enddate, [timezone]) -``` - -**パラメータ** - -- `unit` — Time unit, in which the returned value is expressed. [文字列](../syntax.md#syntax-string-literal). - - Supported values: - - | unit | - | ---- | - |second | - |minute | - |hour | - |day | - |week | - |month | - |quarter | - |year | - -- `startdate` — The first time value to compare. [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). - -- `enddate` — The second time value to compare. [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). - -- `timezone` — Optional parameter. If specified, it is applied to both `startdate` と `enddate`. 指定されていない場合は、 `startdate` と `enddate` 使用されます。 それらが同じでない場合、結果は不特定です。 - -**戻り値** - -の違い `startdate` と `enddate` で表現 `unit`. - -タイプ: `int`. - -**例えば** - -クエリ: - -``` sql -SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); -``` - -結果: - -``` text -┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ -│ 25 │ -└────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## timeSlots(StartTime,Duration,\[,Size\]) {#timeslotsstarttime-duration-size} - -で始まる時間間隔のために ‘StartTime’ そしてのために継続 ‘Duration’ 秒、この間隔からのポイントからなる時間内のモーメントの配列を返します。 ‘Size’ 数秒で。 ‘Size’ オプションのパラメーターです:既定では定数UInt32を1800に設定します。 -例えば, `timeSlots(toDateTime('2012-01-01 12:20:00'), 600) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. -これは、対応するセッションでページビューを検索するために必要です。 - -## formatDateTime(時間,フォーマット\[,タイムゾーン\]) {#formatdatetime} - -Function formats a Time according given Format string. N.B.: Format is a constant expression, e.g. you can not have multiple formats for single result column. - -形式のサポートされている修飾子: -(“Example” このページを正しく表示するフォーマット結果のための時間 `2018-01-02 22:33:44`) - -| 修飾子 | 説明 | 例えば | -|--------|----------------------------------------------------|------------| -| %C | 年を100で除算し、整数(00から99)に切り捨てられます) | 20 | -| %d | 月の日、ゼロ-パディング(01-31) | 02 | -| %D | %m/%d/%yに相当する短いmm/dd/yy日付 | 01/02/18 | -| %e | 月の日、スペース埋め(1-31) | 2 | -| %F | %Y-%m-%dに相当する短いYYYY-MM-DD日付 | 2018-01-02 | -| %H | 24時間形式(00-23)の時間) | 22 | -| %I | 時間で12h形式(01-12) | 10 | -| %j | 年の日(001-366) | 002 | -| %m | 月を小数(01-12)として指定します) | 01 | -| %M | 分(00-59) | 33 | -| %n | 改行文字(") | | -| %p | AMまたはPMの指定 | PM | -| %R | 24時間HH:MM時間、%Hに相当する:%M | 22:33 | -| %S | 二番目に(00-59) | 44 | -| %t | 水平タブ文字(') | | -| %T | ISO8601時刻フォーマット(HH:MM:SS)、%H:%M:%Sに相当 | 22:33:44 | -| %u | ISO8601月曜日が1(1-7)の数値としての平日) | 2 | -| %V | ISO8601週番号(01-53) | 01 | -| %w | weekday as a decimal number with Sunday as0(0-6) | 2 | -| %y | 年,最後の二つの数字(00-99) | 18 | -| %Y | 年 | 2018 | -| %% | %記号 | % | - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/ja/sql_reference/functions/encoding_functions.md b/docs/ja/sql_reference/functions/encoding_functions.md deleted file mode 100644 index 4f0ce676fb8..00000000000 --- a/docs/ja/sql_reference/functions/encoding_functions.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 52 -toc_title: "\u30A8\u30F3\u30B3\u30FC\u30C9" ---- - -# エンコード関数 {#encoding-functions} - -## 文字 {#char} - -渡された引数の数として長さを持つ文字列を返し、各バイトは対応する引数の値を持ちます。 数値型の複数の引数を受け取ります。 引数の値がuint8データ型の範囲外である場合は、丸めとオーバーフローが可能な状態でuint8に変換されます。 - -**構文** - -``` sql -char(number_1, [number_2, ..., number_n]); -``` - -**パラメータ** - -- `number_1, number_2, ..., number_n` — Numerical arguments interpreted as integers. Types: [Int](../../sql_reference/data_types/int_uint.md), [フロート](../../sql_reference/data_types/float.md). - -**戻り値** - -- 指定されたバイトの文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello -``` - -結果: - -``` text -┌─hello─┐ -│ hello │ -└───────┘ -``` - -を構築できます文字列の任意のエンコードに対応するバイトまでとなります。 utf-8の例を次に示します: - -クエリ: - -``` sql -SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; -``` - -結果: - -``` text -┌─hello──┐ -│ привет │ -└────────┘ -``` - -クエリ: - -``` sql -SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; -``` - -結果: - -``` text -┌─hello─┐ -│ 你好 │ -└───────┘ -``` - -## 六角 {#hex} - -引数の十六進表現を含む文字列を返します。 - -**構文** - -``` sql -hex(arg) -``` - -この関数は大文字を使用しています `A-F` 接頭辞(など)を使用しないでください `0x` または接尾辞(のような `h`). - -整数引数の場合は、六角数字を出力します (“nibbles”)最も重要なものから最も重要なもの(ビッグエンディアンまたは “human readable” 順序)。 最も重要な非ゼロバイト(先行ゼロバイトは省略されています)で始まりますが、先行桁がゼロであっても常に各バイトの両方の桁を出力します。 - -例えば: - -**例えば** - -クエリ: - -``` sql -SELECT hex(1); -``` - -結果: - -``` text -01 -``` - -タイプの値 `Date` と `DateTime` 対応する整数としてフォーマットされます(日付のエポックからの日数と、DateTimeのUnixタイムスタンプの値)。 - -のために `String` と `FixedString` すべてのバイトは、単に二進数として符号化される。 ゼロバイトは省略されません。 - -浮動小数点型と小数型の値は、メモリ内での表現としてエンコードされます。 支援においても少しエンディアン、建築、その符号化されたのでちょっとエンディアンです。※ ゼロ先行/末尾のバイトは省略されません。 - -**パラメータ** - -- `arg` — A value to convert to hexadecimal. Types: [文字列](../../sql_reference/data_types/string.md), [UInt](../../sql_reference/data_types/int_uint.md), [フロート](../../sql_reference/data_types/float.md), [小数](../../sql_reference/data_types/decimal.md), [日付](../../sql_reference/data_types/date.md) または [DateTime](../../sql_reference/data_types/datetime.md). - -**戻り値** - -- 引数の十六進表現を持つ文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); -``` - -結果: - -``` text -┌─hex_presentation─┐ -│ 00007041 │ -│ 00008041 │ -└──────────────────┘ -``` - -クエリ: - -``` sql -SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); -``` - -結果: - -``` text -┌─hex_presentation─┐ -│ 0000000000002E40 │ -│ 0000000000003040 │ -└──────────────────┘ -``` - -## unhex(str)) {#unhexstr} - -任意の数の進数を含む文字列を受け取り、対応するバイトを含む文字列を返します。 十六進数の数字は偶数である必要はありません。 奇数の場合、最後の桁は、00-0fバイトの最下位半分として解釈されます。 引数stringに十六進数以外の桁数が含まれている場合、実装定義の結果が返されます(例外はスローされません)。 -結果を数値に変換したい場合は、 ‘reverse’ と ‘reinterpretAsType’ 機能。 - -## UUIDStringToNum(str)) {#uuidstringtonumstr} - -次の形式の36文字を含む文字列を受け取ります `123e4567-e89b-12d3-a456-426655440000`、およびFixedString(16)のバイトのセットとして返します。 - -## UUIDNumToString(str)) {#uuidnumtostringstr} - -FixedString(16)値を受け取ります。 テキスト形式で36文字を含む文字列を返します。 - -## ビットマスクトリスト(num) {#bitmasktolistnum} - -整数を受け入れます。 合計されたときにソース番号を合計する二つの累乗のリストを含む文字列を返します。 これらは、昇順で、テキスト形式のスペースなしでコンマ区切りです。 - -## ビットマスクアレール(num) {#bitmasktoarraynum} - -整数を受け入れます。 合計されたときにソース番号を合計する二つの累乗のリストを含むuint64数の配列を返します。 配列内の数字は昇順です。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/ja/sql_reference/functions/ext_dict_functions.md b/docs/ja/sql_reference/functions/ext_dict_functions.md deleted file mode 100644 index 8b9299cb524..00000000000 --- a/docs/ja/sql_reference/functions/ext_dict_functions.md +++ /dev/null @@ -1,205 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 58 -toc_title: "\u5916\u90E8\u8F9E\u66F8\u306E\u64CD\u4F5C" ---- - -# 外部辞書を操作するための関数 {#ext_dict_functions} - -情報の接続や設定の外部辞書参照 [外部辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -## dictGet {#dictget} - -外部ディクショナリから値を取得します。 - -``` sql -dictGet('dict_name', 'attr_name', id_expr) -dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**パラメータ** - -- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `attr_name` — Name of the column of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [式](../syntax.md#syntax-expressions) を返す [UInt64](../../sql_reference/data_types/int_uint.md) または [タプル](../../sql_reference/data_types/tuple.md)-辞書構成に応じて値を入力します。 -- `default_value_expr` — Value returned if the dictionary doesn't contain a row with the `id_expr` キー。 [式](../syntax.md#syntax-expressions) に設定されたデータ型の値を返します。 `attr_name` 属性。 - -**戻り値** - -- クリックハウスで属性が正常に解析された場合 [属性のデータ型](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes)、関数は、に対応する辞書属性の値を返します `id_expr`. - -- キーがない場合、対応する `id_expr`、辞書では、その後: - - - `dictGet` returns the content of the `` element specified for the attribute in the dictionary configuration. - - `dictGetOrDefault` returns the value passed as the `default_value_expr` parameter. - -ClickHouseは、属性の値を解析できない場合、または値が属性データ型と一致しない場合に例外をスローします。 - -**例えば** - -テキストファイルの作成 `ext-dict-text.csv` 以下を含む: - -``` text -1,1 -2,2 -``` - -最初の列は次のとおりです `id`、第二の列は `c1`. - -外部ディクショナリの設定: - -``` xml - - - ext-dict-test - - - /path-to/ext-dict-test.csv - CSV - - - - - - - - id - - - c1 - UInt32 - - - - 0 - - -``` - -クエリの実行: - -``` sql -SELECT - dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, - toTypeName(val) AS type -FROM system.numbers -LIMIT 3 -``` - -``` text -┌─val─┬─type───┐ -│ 1 │ UInt32 │ -│ 2 │ UInt32 │ -│ 20 │ UInt32 │ -└─────┴────────┘ -``` - -**また見なさい** - -- [外部辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) - -## dictHas {#dicthas} - -キーが辞書に存在するかどうかを確認します。 - -``` sql -dictHas('dict_name', id_expr) -``` - -**パラメータ** - -- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [式](../syntax.md#syntax-expressions) を返す [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ値。 - -**戻り値** - -- 0、キーがない場合。 -- 1、キーがある場合。 - -タイプ: `UInt8`. - -## 独裁主義体制 {#dictgethierarchy} - -キーのすべての親を含む配列を作成します。 [階層辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md). - -**構文** - -``` sql -dictGetHierarchy('dict_name', key) -``` - -**パラメータ** - -- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `key` — Key value. [式](../syntax.md#syntax-expressions) を返す [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ値。 - -**戻り値** - -- キーの親。 - -タイプ: [配列(uint64)](../../sql_reference/data_types/array.md). - -## ディクティシン {#dictisin} - -辞書内の階層チェーン全体を通じてキーの祖先をチェックします。 - -``` sql -dictIsIn('dict_name', child_id_expr, ancestor_id_expr) -``` - -**パラメータ** - -- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `child_id_expr` — Key to be checked. [式](../syntax.md#syntax-expressions) を返す [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ値。 -- `ancestor_id_expr` — Alleged ancestor of the `child_id_expr` キー。 [式](../syntax.md#syntax-expressions) を返す [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ値。 - -**戻り値** - -- 0,if `child_id_expr` の子ではありません `ancestor_id_expr`. -- 1、場合 `child_id_expr` の子です `ancestor_id_expr` または `child_id_expr` は `ancestor_id_expr`. - -タイプ: `UInt8`. - -## その他の機能 {#ext_dict_functions-other} - -ClickHouseは、辞書構成に関係なく、辞書属性値を特定のデータ型に変換する特殊な関数をサポートしています。 - -機能: - -- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` -- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` -- `dictGetFloat32`, `dictGetFloat64` -- `dictGetDate` -- `dictGetDateTime` -- `dictGetUUID` -- `dictGetString` - -これらの機能はすべて、 `OrDefault` 変更。 例えば, `dictGetDateOrDefault`. - -構文: - -``` sql -dictGet[Type]('dict_name', 'attr_name', id_expr) -dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**パラメータ** - -- `dict_name` — Name of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `attr_name` — Name of the column of the dictionary. [文字列リテラル](../syntax.md#syntax-string-literal). -- `id_expr` — Key value. [式](../syntax.md#syntax-expressions) を返す [UInt64](../../sql_reference/data_types/int_uint.md)-タイプ値。 -- `default_value_expr` — Value which is returned if the dictionary doesn't contain a row with the `id_expr` キー。 [式](../syntax.md#syntax-expressions) に設定されたデータ型の値を返します。 `attr_name` 属性。 - -**戻り値** - -- クリックハウスで属性が正常に解析された場合 [属性のデータ型](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes)、関数は、に対応する辞書属性の値を返します `id_expr`. - -- 要求がない場合 `id_expr` 辞書では、: - - - `dictGet[Type]` returns the content of the `` element specified for the attribute in the dictionary configuration. - - `dictGet[Type]OrDefault` returns the value passed as the `default_value_expr` parameter. - -ClickHouseは、属性の値を解析できない場合、または値が属性データ型と一致しない場合に例外をスローします。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/ja/sql_reference/functions/functions_for_nulls.md b/docs/ja/sql_reference/functions/functions_for_nulls.md deleted file mode 100644 index 655eecd3df2..00000000000 --- a/docs/ja/sql_reference/functions/functions_for_nulls.md +++ /dev/null @@ -1,312 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 63 -toc_title: "\u30CC\u30EB\u53EF\u80FD\u306A\u5F15\u6570\u306E\u64CD\u4F5C" ---- - -# Null可能な集計を操作するための関数 {#functions-for-working-with-nullable-aggregates} - -## isNull {#isnull} - -引数が [NULL](../syntax.md#null). - -``` sql -isNull(x) -``` - -**パラメータ** - -- `x` — A value with a non-compound data type. - -**戻り値** - -- `1` もし `x` は `NULL`. -- `0` もし `x` はない `NULL`. - -**例えば** - -入力テーブル - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -クエリ - -``` sql -SELECT x FROM t_null WHERE isNull(y) -``` - -``` text -┌─x─┐ -│ 1 │ -└───┘ -``` - -## isNotNull {#isnotnull} - -引数が [NULL](../syntax.md#null). - -``` sql -isNotNull(x) -``` - -**パラメータ:** - -- `x` — A value with a non-compound data type. - -**戻り値** - -- `0` もし `x` は `NULL`. -- `1` もし `x` はない `NULL`. - -**例えば** - -入力テーブル - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -クエリ - -``` sql -SELECT x FROM t_null WHERE isNotNull(y) -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## 合体 {#coalesce} - -左から右にチェックするかどうか `NULL` 引数が渡され、最初の非を返します-`NULL` 引数。 - -``` sql -coalesce(x,...) -``` - -**パラメータ:** - -- 非化合物タイプの任意の数のパラメーター。 すべてのパラメータに対応していることが必要となるデータ型になります。 - -**戻り値** - -- 最初の非-`NULL` 引数。 -- `NULL` すべての引数が `NULL`. - -**例えば** - -顧客に連絡する複数の方法を指定する可能性のある連絡先のリストを考えてみましょう。 - -``` text -┌─name─────┬─mail─┬─phone─────┬──icq─┐ -│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ -│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└──────────┴──────┴───────────┴──────┘ -``` - -その `mail` と `phone` フィールドの型はStringですが、 `icq` フィールドは `UInt32`、それはに変換する必要があります `String`. - -コンタクトリストから顧客の最初の利用可能なコンタクトメソッドを取得する: - -``` sql -SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook -``` - -``` text -┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ -│ client 1 │ 123-45-67 │ -│ client 2 │ ᴺᵁᴸᴸ │ -└──────────┴──────────────────────────────────────────────────────┘ -``` - -## ifNull {#ifnull} - -メイン引数がある場合は、代替値を返します `NULL`. - -``` sql -ifNull(x,alt) -``` - -**パラメータ:** - -- `x` — The value to check for `NULL`. -- `alt` — The value that the function returns if `x` は `NULL`. - -**戻り値** - -- を値 `x`,もし `x` はない `NULL`. -- を値 `alt`,もし `x` は `NULL`. - -**例えば** - -``` sql -SELECT ifNull('a', 'b') -``` - -``` text -┌─ifNull('a', 'b')─┐ -│ a │ -└──────────────────┘ -``` - -``` sql -SELECT ifNull(NULL, 'b') -``` - -``` text -┌─ifNull(NULL, 'b')─┐ -│ b │ -└───────────────────┘ -``` - -## nullifname {#nullif} - -を返します `NULL` 引数が等しい場合。 - -``` sql -nullIf(x, y) -``` - -**パラメータ:** - -`x`, `y` — Values for comparison. They must be compatible types, or ClickHouse will generate an exception. - -**戻り値** - -- `NULL` 引数が等しい場合。 -- その `x` 引数が等しくない場合の値。 - -**例えば** - -``` sql -SELECT nullIf(1, 1) -``` - -``` text -┌─nullIf(1, 1)─┐ -│ ᴺᵁᴸᴸ │ -└──────────────┘ -``` - -``` sql -SELECT nullIf(1, 2) -``` - -``` text -┌─nullIf(1, 2)─┐ -│ 1 │ -└──────────────┘ -``` - -## assumeNotNull {#assumenotnull} - -結果はtypeの値になります [Nullable](../../sql_reference/data_types/nullable.md) 非のために- `Nullable` 値がない場合、 `NULL`. - -``` sql -assumeNotNull(x) -``` - -**パラメータ:** - -- `x` — The original value. - -**戻り値** - -- 元の値から非-`Nullable` そうでない場合はタイプします `NULL`. -- のデフォルト値。-`Nullable` 元の値が `NULL`. - -**例えば** - -考慮する `t_null` テーブル。 - -``` sql -SHOW CREATE TABLE t_null -``` - -``` text -┌─statement─────────────────────────────────────────────────────────────────┐ -│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ -└───────────────────────────────────────────────────────────────────────────┘ -``` - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -を適用 `assumeNotNull` に機能 `y` コラム - -``` sql -SELECT assumeNotNull(y) FROM t_null -``` - -``` text -┌─assumeNotNull(y)─┐ -│ 0 │ -│ 3 │ -└──────────────────┘ -``` - -``` sql -SELECT toTypeName(assumeNotNull(y)) FROM t_null -``` - -``` text -┌─toTypeName(assumeNotNull(y))─┐ -│ Int8 │ -│ Int8 │ -└──────────────────────────────┘ -``` - -## toNullable {#tonullable} - -引数の型を次のように変換します `Nullable`. - -``` sql -toNullable(x) -``` - -**パラメータ:** - -- `x` — The value of any non-compound type. - -**戻り値** - -- Aの入力値 `Nullable` タイプ。 - -**例えば** - -``` sql -SELECT toTypeName(10) -``` - -``` text -┌─toTypeName(10)─┐ -│ UInt8 │ -└────────────────┘ -``` - -``` sql -SELECT toTypeName(toNullable(10)) -``` - -``` text -┌─toTypeName(toNullable(10))─┐ -│ Nullable(UInt8) │ -└────────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/ja/sql_reference/functions/geo.md b/docs/ja/sql_reference/functions/geo.md deleted file mode 100644 index c61027f8bcd..00000000000 --- a/docs/ja/sql_reference/functions/geo.md +++ /dev/null @@ -1,510 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 62 -toc_title: "\u5730\u7406\u5EA7\u6A19\u306E\u64CD\u4F5C" ---- - -# 地理座標を操作するための関数 {#functions-for-working-with-geographical-coordinates} - -## グレートサークル距離 {#greatcircledistance} - -を使用して、地球の表面上の二つの点の間の距離を計算します [大円式](https://en.wikipedia.org/wiki/Great-circle_distance). - -``` sql -greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) -``` - -**入力パラメータ** - -- `lon1Deg` — Longitude of the first point in degrees. Range: `[-180°, 180°]`. -- `lat1Deg` — Latitude of the first point in degrees. Range: `[-90°, 90°]`. -- `lon2Deg` — Longitude of the second point in degrees. Range: `[-180°, 180°]`. -- `lat2Deg` — Latitude of the second point in degrees. Range: `[-90°, 90°]`. - -正の値は北緯と東経に対応し、負の値は南緯と西経に対応します。 - -**戻り値** - -メートルで、地球の表面上の二つの点の間の距離。 - -入力パラメーター値が範囲外になったときに例外を生成します。 - -**例えば** - -``` sql -SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) -``` - -``` text -┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ -│ 14132374.194975413 │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## pointInEllipses {#pointinellipses} - -ポイントが楕円の少なくとも一つに属するかどうかをチェックします。 -座標は、デカルト座標系ではジオメトリです。 - -``` sql -pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) -``` - -**入力パラメータ** - -- `x, y` — Coordinates of a point on the plane. -- `xᵢ, yᵢ` — Coordinates of the center of the `i`-番目の省略記号。 -- `aᵢ, bᵢ` — Axes of the `i`-x、y座標の単位で番目の省略記号。 - -入力パラ `2+4⋅n`、どこ `n` 楕円の数です。 - -**戻り値** - -`1` ポイントは、楕円の少なくとも一つの内側にある場合; `0`そうでない場合。 - -**例えば** - -``` sql -SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) -``` - -``` text -┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ -│ 1 │ -└─────────────────────────────────────────────────┘ -``` - -## pointInPolygon {#pointinpolygon} - -るかどうかを判の点に属する多角形の面。 - -``` sql -pointInPolygon((x, y), [(a, b), (c, d) ...], ...) -``` - -**入力値** - -- `(x, y)` — Coordinates of a point on the plane. Data type — [タプル](../../sql_reference/data_types/tuple.md) — A tuple of two numbers. -- `[(a, b), (c, d) ...]` — Polygon vertices. Data type — [配列](../../sql_reference/data_types/array.md). 各頂点は、座標のペアで表されます `(a, b)`. 頂点は、時計回りまたは反時計回りの順序で指定する必要があります。 頂点の最小数は3です。 多角形は一定でなければなりません。 -- この機能は、穴(切り取られた部分)を持つ多角形もサポートします。 この場合、関数の追加の引数を使用してカットアウトセクションを定義するポリゴンを追加します。 この関数は、単純接続以外のポリゴンをサポートしません。 - -**戻り値** - -`1` ポイントがポリゴンの内側にある場合, `0` そうでない場合。 -ポイントがポリゴン境界上にある場合、関数は0または1を返します。 - -**例えば** - -``` sql -SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## geohashEncode {#geohashencode} - -緯度と経度をgeohash-stringとしてエンコードします。http://geohash.org/,https://en.wikipedia.org/wiki/geohash). - -``` sql -geohashEncode(longitude, latitude, [precision]) -``` - -**入力値** - -- 経度-エンコードしたい座標の経度の部分。 範囲の浮遊`[-180°, 180°]` -- latitude-エンコードする座標の緯度部分。 範囲の浮遊 `[-90°, 90°]` -- precision-オプション、結果としてエンコードされる文字列の長さ。 `12`. 範囲の整数 `[1, 12]`. より小さい任意の値 `1` またはより大きい `12` に変換される。 `12`. - -**戻り値** - -- 英数字 `String` エンコードされた座標(base32エンコードアルファベットの修正版が使用されます)。 - -**例えば** - -``` sql -SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res -``` - -``` text -┌─res──────────┐ -│ ezs42d000000 │ -└──────────────┘ -``` - -## geohashDecode {#geohashdecode} - -Geohashでエンコードされた文字列を経度と緯度にデコードします。 - -**入力値** - -- エンコードされた文字列-geohashエンコードされた文字列。 - -**戻り値** - -- (経度、緯度)-2-のタプル `Float64` 経度と緯度の値。 - -**例えば** - -``` sql -SELECT geohashDecode('ezs42') AS res -``` - -``` text -┌─res─────────────────────────────┐ -│ (-5.60302734375,42.60498046875) │ -└─────────────────────────────────┘ -``` - -## geoToH3 {#geotoh3} - -を返します [H3](https://uber.github.io/h3/#/documentation/overview/introduction) 点指数 `(lon, lat)` 指定決断を使って。 - -[H3](https://uber.github.io/h3/#/documentation/overview/introduction) 地理的指標システムであり、地球の表面は六角形のタイルに分割されています。 トップレベルの各六角形は、より小さいものに分割することができます。 - -このインデックスは、主にバケットの場所やその他の地理空間の操作に使用されます。 - -**構文** - -``` sql -geoToH3(lon, lat, resolution) -``` - -**パラメータ** - -- `lon` — Longitude. Type: [Float64](../../sql_reference/data_types/float.md). -- `lat` — Latitude. Type: [Float64](../../sql_reference/data_types/float.md). -- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- 六角形のインデックス番号。 -- エラーの場合は0。 - -タイプ: `UInt64`. - -**例えば** - -クエリ: - -``` sql -SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index -``` - -結果: - -``` text -┌────────────h3Index─┐ -│ 644325524701193974 │ -└────────────────────┘ -``` - -## geohashesInBox {#geohashesinbox} - -与えられたボックスの内側にあり、境界と交差する、与えられた精度のgeohashエンコードされた文字列の配列を返します。 - -**入力値** - -- longitude\_min-最小経度、範囲内の浮動小数点数 `[-180°, 180°]` -- latitude\_min-最小緯度、範囲内の浮動小数点数 `[-90°, 90°]` -- longitude\_max-最高の経度、範囲の浮遊価値 `[-180°, 180°]` -- latitude\_max-最大緯度、範囲内の浮動小数点数 `[-90°, 90°]` -- 精密-geohashの精密, `UInt8` 範囲内 `[1, 12]` - -すべての座標パラメータは同じタイプである必要があります。 `Float32` または `Float64`. - -**戻り値** - -- 提供された領域をカバーするgeohash-ボックスの精度の長い文字列の配列、あなたはアイテムの順序に頼るべきではありません。 -- \[\]-空の配列の場合 *分* の値 *緯度* と *経度* 対応するよりも小さくない *最大* 値。 - -結果の配列が10'000'000項目を超える場合、関数は例外をスローすることに注意してください。 - -**例えば** - -``` sql -SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos -``` - -``` text -┌─thasos──────────────────────────────────────┐ -│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ -└─────────────────────────────────────────────┘ -``` - -## h3GetBaseCell {#h3getbasecell} - -インデックスの基本セル番号を返します。 - -**構文** - -``` sql -h3GetBaseCell(index) -``` - -**パラメータ** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- 六角形ベースセル番号。 タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3GetBaseCell(612916788725809151) as basecell -``` - -結果: - -``` text -┌─basecell─┐ -│ 12 │ -└──────────┘ -``` - -## h3HexAreaM2 {#h3hexaream2} - -与えられた解像度で平方メートルの平均六角形の面積。 - -**構文** - -``` sql -h3HexAreaM2(resolution) -``` - -**パラメータ** - -- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- Area in m². Type: [Float64](../../sql_reference/data_types/float.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3HexAreaM2(13) as area -``` - -結果: - -``` text -┌─area─┐ -│ 43.9 │ -└──────┘ -``` - -## h3IndexesAreNeighbors {#h3indexesareneighbors} - -指定されたh3indexesが近傍であるかどうかを返します。 - -**構文** - -``` sql -h3IndexesAreNeighbors(index1, index2) -``` - -**パラメータ** - -- `index1` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `index2` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- を返します `1` インデックスが隣接している場合, `0` そうでなければ タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3IndexesAreNeighbors(617420388351344639, 617420388352655359) AS n -``` - -結果: - -``` text -┌─n─┐ -│ 1 │ -└───┘ -``` - -## h3ToChildren {#h3tochildren} - -指定したインデックスの子インデックスを持つ配列を返します。 - -**構文** - -``` sql -h3ToChildren(index, resolution) -``` - -**パラメータ** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- 子h3インデックスを持つ配列。 タイプの配列: [UInt64](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3ToChildren(599405990164561919, 6) AS children -``` - -結果: - -``` text -┌─children───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ [603909588852408319,603909588986626047,603909589120843775,603909589255061503,603909589389279231,603909589523496959,603909589657714687] │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## h3親 {#h3toparent} - -を返します(粗)インデックスを含むとして指定されたインデックス. - -**構文** - -``` sql -h3ToParent(index, resolution) -``` - -**パラメータ** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). -- `resolution` — Index resolution. Range: `[0, 15]`. タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- 親のh3インデックス。 タイプ: [UInt64](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3ToParent(599405990164561919, 3) as parent -``` - -結果: - -``` text -┌─────────────parent─┐ -│ 590398848891879423 │ -└────────────────────┘ -``` - -## h3ToString {#h3tostring} - -インデックスのh3index表現を文字列表現に変換します。 - -``` sql -h3ToString(index) -``` - -**パラメータ** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- H3インデックスの文字列表現。 タイプ: [文字列](../../sql_reference/data_types/string.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3ToString(617420388352917503) as h3_string -``` - -結果: - -``` text -┌─h3_string───────┐ -│ 89184926cdbffff │ -└─────────────────┘ -``` - -## stringToH3 {#stringtoh3} - -文字列表現をh3index(uint64)表現に変換します。 - -``` sql -stringToH3(index_str) -``` - -**パラメータ** - -- `index_str` — String representation of the H3 index. Type: [文字列](../../sql_reference/data_types/string.md). - -**戻り値** - -- 六角形のインデックス番号。 エラー時に0を返します。 タイプ: [UInt64](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT stringToH3('89184926cc3ffff') as index -``` - -結果: - -``` text -┌──────────────index─┐ -│ 617420388351344639 │ -└────────────────────┘ -``` - -## h3GetResolution {#h3getresolution} - -インデックスの解像度を返します。 - -**構文** - -``` sql -h3GetResolution(index) -``` - -**パラメータ** - -- `index` — Hexagon index number. Type: [UInt64](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -- インデックスの解決。 範囲: `[0, 15]`. タイプ: [UInt8](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT h3GetResolution(617420388352917503) as res -``` - -結果: - -``` text -┌─res─┐ -│ 9 │ -└─────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/ja/sql_reference/functions/hash_functions.md b/docs/ja/sql_reference/functions/hash_functions.md deleted file mode 100644 index 7b2eb3fc239..00000000000 --- a/docs/ja/sql_reference/functions/hash_functions.md +++ /dev/null @@ -1,446 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 50 -toc_title: "\u30CF\u30C3\u30B7\u30E5" ---- - -# ハッシュ関数 {#hash-functions} - -ハッシュ関数は、要素の決定論的な擬似ランダムシャッフルに使用できます。 - -## ハーフmd5 {#hash-functions-halfmd5} - -[解釈する](../../sql_reference/functions/type_conversion_functions.md#type_conversion_functions-reinterpretAsString) すべての入力パラメーターを文字列として計算します [MD5](https://en.wikipedia.org/wiki/MD5) それぞれのハッシュ値。 次に、ハッシュを結合し、結果の文字列のハッシュの最初の8バイトを取り、それらを次のように解釈します `UInt64` ビッグエンディアンのバイト順。 - -``` sql -halfMD5(par1, ...) -``` - -この関数は比較的遅い(プロセッサコアあたり5万個の短い文字列)。 -を使用することを検討 [サイファッシュ64](#hash_functions-siphash64) 代わりに機能。 - -**パラメータ** - -この関数は、可変個の入力パラメータを受け取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -A [UInt64](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 - -**例えば** - -``` sql -SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type -``` - -``` text -┌────────halfMD5hash─┬─type───┐ -│ 186182704141653334 │ UInt64 │ -└────────────────────┴────────┘ -``` - -## MD5 {#hash_functions-md5} - -文字列からmd5を計算し、結果のバイトセットをfixedstring(16)として返します。 -特にmd5を必要としないが、適切な暗号化128ビットハッシュが必要な場合は、 ‘sipHash128’ 代わりに機能。 -Md5sumユーティリティによる出力と同じ結果を得たい場合は、lower(hex(MD5(s)))を使用します。 - -## サイファッシュ64 {#hash_functions-siphash64} - -64ビットを生成する [サイファッシュ](https://131002.net/siphash/) ハッシュ値。 - -``` sql -sipHash64(par1,...) -``` - -これは暗号化ハッシュ関数です。 それはより速い少なくとも三回働きます [MD5](#hash_functions-md5) 機能。 - -機能 [解釈する](../../sql_reference/functions/type_conversion_functions.md#type_conversion_functions-reinterpretAsString) すべての入力パラメータを文字列として計算し、それぞれのハッシュ値を計算します。 その融合ハッシュにより、次のアルゴリズム: - -1. すべての入力パラメータをハッシュした後、関数はハッシュの配列を取得します。 -2. 関数は、第一及び第二の要素を取り、それらの配列のためのハッシュを計算します。 -3. 次に、関数は、前のステップで計算されたハッシュ値と最初のハッシュ配列の第三の要素を取り、それらの配列のハッシュを計算します。 -4. 最初のハッシュ配列の残りのすべての要素について、前の手順が繰り返されます。 - -**パラメータ** - -この関数は、可変個の入力パラメータを受け取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -A [UInt64](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 - -**例えば** - -``` sql -SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type -``` - -``` text -┌──────────────SipHash─┬─type───┐ -│ 13726873534472839665 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## サイファシー128 {#hash_functions-siphash128} - -文字列からサイファッシュを計算します。 -文字列型引数を受け取ります。 fixedstring(16)を返します。 -Siphash64とは異なり、最終的なxor折りたたみ状態は128ビットまでしか行われません。 - -## cityHash64 {#cityhash64} - -64ビットを生成する [CityHash](https://github.com/google/cityhash) ハッシュ値。 - -``` sql -cityHash64(par1,...) -``` - -これは高速な非暗号化ハッシュ関数です。 文字列パラメーターにはcityhashアルゴリズムを使用し、他のデータ型のパラメーターには実装固有の高速非暗号化ハッシュ関数を使用します。 この関数は、最終的な結果を得るためにcityhashコンビネータを使用します。 - -**パラメータ** - -この関数は、可変個の入力パラメータを受け取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -A [UInt64](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 - -**例** - -呼び出しの例: - -``` sql -SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type -``` - -``` text -┌─────────────CityHash─┬─type───┐ -│ 12072650598913549138 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -次の例は、行順序までの精度でテーブル全体のチェックサムを計算する方法を示しています: - -``` sql -SELECT groupBitXor(cityHash64(*)) FROM table -``` - -## intHash32 {#inthash32} - -任意のタイプの整数から32ビットのハッシュコードを計算します。 -これは、数値の平均品質の比較的高速な非暗号化ハッシュ関数です。 - -## intHash64 {#inthash64} - -任意のタイプの整数から64ビットのハッシュコードを計算します。 -それはinthash32より速く働きます。 平均品質。 - -## SHA1 {#sha1} - -## SHA224 {#sha224} - -## SHA256 {#sha256} - -文字列からsha-1、sha-224、またはsha-256を計算し、結果のバイトセットをfixedstring(20)、fixedstring(28)、またはfixedstring(32)として返します。 -この関数はかなりゆっくりと動作します(sha-1はプロセッサコアあたり約5百万個の短い文字列を処理し、sha-224とsha-256は約2.2百万プロセス)。 -特定のハッシュ関数が必要で選択できない場合にのみ、この関数を使用することをお勧めします。 -このような場合でも、テーブルに値を挿入するときは、selectsに値を適用するのではなく、関数をオフラインで適用して事前計算することをお勧めします。 - -## URLHash(url\[,N\]) {#urlhashurl-n} - -いくつかのタイプの正規化を使用してurlから取得した文字列の高速でまともな品質の非暗号化ハッシュ関数。 -`URLHash(s)` – Calculates a hash from a string without one of the trailing symbols `/`,`?` または `#` 最後に、存在する場合。 -`URLHash(s, N)` – Calculates a hash from a string up to the N level in the URL hierarchy, without one of the trailing symbols `/`,`?` または `#` 最後に、存在する場合。 -レベルはurlhierarchyと同じです。 この機能はyandexに固有です。メトリカ - -## farmHash64 {#farmhash64} - -64ビットを生成する [FarmHash](https://github.com/google/farmhash) ハッシュ値。 - -``` sql -farmHash64(par1, ...) -``` - -この関数は、 `Hash64` すべてからの方法 [利用可能な方法](https://github.com/google/farmhash/blob/master/src/farmhash.h). - -**パラメータ** - -この関数は、可変個の入力パラメータを受け取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -A [UInt64](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 - -**例えば** - -``` sql -SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type -``` - -``` text -┌─────────────FarmHash─┬─type───┐ -│ 17790458267262532859 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## javaHash {#hash_functions-javahash} - -計算 [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) 文字列から。 このハッシュ関数は高速でも良い品質でもありません。 理由はただそれだけに使用する場合もこのアルゴリズムは実用化が始まっており他のシステムとしての計算は、全く同じ働きをします。 - -**構文** - -``` sql -SELECT javaHash(''); -``` - -**戻り値** - -A `Int32` データ型ハッシュ値。 - -**例えば** - -クエリ: - -``` sql -SELECT javaHash('Hello, world!'); -``` - -結果: - -``` text -┌─javaHash('Hello, world!')─┐ -│ -1880044555 │ -└───────────────────────────┘ -``` - -## javaHashUTF16LE {#javahashutf16le} - -計算 [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) 文字列から、UTF-16LEエンコーディングで文字列を表すバイトが含まれていると仮定します。 - -**構文** - -``` sql -javaHashUTF16LE(stringUtf16le) -``` - -**パラメータ** - -- `stringUtf16le` — a string in UTF-16LE encoding. - -**戻り値** - -A `Int32` データ型ハッシュ値。 - -**例えば** - -UTF-16LEでエンコードされた文字列で正しいクエリー。 - -クエリ: - -``` sql -SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) -``` - -結果: - -``` text -┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ -│ 3556498 │ -└──────────────────────────────────────────────────────────────┘ -``` - -## hiveHash {#hash-functions-hivehash} - -計算 `HiveHash` 文字列から。 - -``` sql -SELECT hiveHash(''); -``` - -これはちょうど [JavaHash](#hash_functions-javahash) サインビットをゼロにします。 この関数は、 [Apacheハイブ](https://en.wikipedia.org/wiki/Apache_Hive) 3.0より前のバージョンの場合。 このハッシュ関数は高速でも良い品質でもありません。 理由はただそれだけに使用する場合もこのアルゴリズムは実用化が始まっており他のシステムとしての計算は、全く同じ働きをします。 - -**戻り値** - -A `Int32` データ型ハッシュ値。 - -タイプ: `hiveHash`. - -**例えば** - -クエリ: - -``` sql -SELECT hiveHash('Hello, world!'); -``` - -結果: - -``` text -┌─hiveHash('Hello, world!')─┐ -│ 267439093 │ -└───────────────────────────┘ -``` - -## metroHash64 {#metrohash64} - -64ビットを生成する [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/) ハッシュ値。 - -``` sql -metroHash64(par1, ...) -``` - -**パラメータ** - -この関数は、可変個の入力パラメータを受け取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -A [UInt64](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 - -**例えば** - -``` sql -SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type -``` - -``` text -┌────────────MetroHash─┬─type───┐ -│ 14235658766382344533 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## jumpConsistentHash {#jumpconsistenthash} - -JumpConsistentHashフォームUInt64を計算します。 -UInt64型のキーとバケットの数です。 Int32を返します。 -詳細については、リンク: [JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) - -## murmurHash2\_32,murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} - -を生成する [MurmurHash2](https://github.com/aappleby/smhasher) ハッシュ値。 - -``` sql -murmurHash2_32(par1, ...) -murmurHash2_64(par1, ...) -``` - -**パラメータ** - -どちらの関数も、入力パラメータの可変数を取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -- その `murmurHash2_32` 関数は、ハッシュ値を返します [UInt32](../../sql_reference/data_types/int_uint.md) データ型。 -- その `murmurHash2_64` 関数は、ハッシュ値を返します [UInt64](../../sql_reference/data_types/int_uint.md) データ型。 - -**例えば** - -``` sql -SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type -``` - -``` text -┌──────────MurmurHash2─┬─type───┐ -│ 11832096901709403633 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## murmurHash3\_32,murmurHash3\_64 {#murmurhash3-32-murmurhash3-64} - -を生成する [MurmurHash3](https://github.com/aappleby/smhasher) ハッシュ値。 - -``` sql -murmurHash3_32(par1, ...) -murmurHash3_64(par1, ...) -``` - -**パラメータ** - -どちらの関数も、入力パラメータの可変数を取ります。 パラメー [対応データ型](../../sql_reference/data_types/index.md). - -**戻り値** - -- その `murmurHash3_32` 関数は、 [UInt32](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 -- その `murmurHash3_64` 関数は、 [UInt64](../../sql_reference/data_types/int_uint.md) データ型ハッシュ値。 - -**例えば** - -``` sql -SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3─┬─type───┐ -│ 2152717 │ UInt32 │ -└─────────────┴────────┘ -``` - -## murmurHash3\_128 {#murmurhash3-128} - -128ビットを生成する [MurmurHash3](https://github.com/aappleby/smhasher) ハッシュ値。 - -``` sql -murmurHash3_128( expr ) -``` - -**パラメータ** - -- `expr` — [式](../syntax.md#syntax-expressions) を返す [文字列](../../sql_reference/data_types/string.md)-タイプ値。 - -**戻り値** - -A [FixedString(16)](../../sql_reference/data_types/fixedstring.md) データ型ハッシュ値。 - -**例えば** - -``` sql -SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3──────┬─type────────────┐ -│ 6�1�4"S5KT�~~q │ FixedString(16) │ -└──────────────────┴─────────────────┘ -``` - -## xxHash32,xxHash64 {#hash-functions-xxhash32} - -計算 `xxHash` 文字列から。 これは、二つの味、32および64ビットで提案されています。 - -``` sql -SELECT xxHash32(''); - -OR - -SELECT xxHash64(''); -``` - -**戻り値** - -A `Uint32` または `Uint64` データ型ハッシュ値。 - -タイプ: `xxHash`. - -**例えば** - -クエリ: - -``` sql -SELECT xxHash32('Hello, world!'); -``` - -結果: - -``` text -┌─xxHash32('Hello, world!')─┐ -│ 834093149 │ -└───────────────────────────┘ -``` - -**また見なさい** - -- [xxHash](http://cyan4973.github.io/xxHash/). - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/ja/sql_reference/functions/higher_order_functions.md b/docs/ja/sql_reference/functions/higher_order_functions.md deleted file mode 100644 index 3dac2bd98aa..00000000000 --- a/docs/ja/sql_reference/functions/higher_order_functions.md +++ /dev/null @@ -1,264 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 57 -toc_title: "\u3088\u308A\u9AD8\u3044\u6B21\u6570" ---- - -# 高階関数 {#higher-order-functions} - -## `->` 演算子、ラムダ(params,expr)関数 {#operator-lambdaparams-expr-function} - -Allows describing a lambda function for passing to a higher-order function. The left side of the arrow has a formal parameter, which is any ID, or multiple formal parameters – any IDs in a tuple. The right side of the arrow has an expression that can use these formal parameters, as well as any table columns. - -例: `x -> 2 * x, str -> str != Referer.` - -高階関数は、関数の引数としてラムダ関数のみを受け入れることができます。 - -複数の引数を受け入れるラムダ関数は、高階関数に渡すことができます。 この場合、高次関数は、これらの引数が対応する同一の長さのいくつかの配列を渡されます。 - -いくつかの機能については、 [arrayCount](#higher_order_functions-array-count) または [arraySum](#higher_order_functions-array-count)、最初の引数(ラムダ関数)を省略することができます。 この場合、同一のマッピングが想定されます。 - -以下の関数ではラムダ関数を省略することはできません: - -- [arrayMap](#higher_order_functions-array-map) -- [arrayFilter](#higher_order_functions-array-filter) -- [arrayfillanguage](#higher_order_functions-array-fill) -- [arrayReverseFill](#higher_order_functions-array-reverse-fill) -- [arraySplit](#higher_order_functions-array-split) -- [arrayReverseSplit](#higher_order_functions-array-reverse-split) -- [arrayFirst](#higher_order_functions-array-first) -- [arrayFirstIndex](#higher_order_functions-array-first-index) - -### arrayMap(func, arr1, …) {#higher_order_functions-array-map} - -の元のアプリケーションから取得した配列を返します。 `func` の各要素への機能 `arr` 配列だ - -例: - -``` sql -SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,4,5] │ -└─────────┘ -``` - -次の例は、異なる配列から要素のタプルを作成する方法を示しています: - -``` sql -SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res -``` - -``` text -┌─res─────────────────┐ -│ [(1,4),(2,5),(3,6)] │ -└─────────────────────┘ -``` - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arrayMap` 機能。 - -### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} - -要素のみを含む配列を返します `arr1` そのために `func` 0以外の値を返します。 - -例: - -``` sql -SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res -``` - -``` text -┌─res───────────┐ -│ ['abc World'] │ -└───────────────┘ -``` - -``` sql -SELECT - arrayFilter( - (i, x) -> x LIKE '%World%', - arrayEnumerate(arr), - ['Hello', 'abc World'] AS arr) - AS res -``` - -``` text -┌─res─┐ -│ [2] │ -└─────┘ -``` - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arrayFilter` 機能。 - -### arrayFill(func, arr1, …) {#higher_order_functions-array-fill} - -スキャンスルー `arr1` 最初の要素から最後の要素まで `arr1[i]` によって `arr1[i - 1]` もし `func` 0を返します。 の最初の要素 `arr1` 交換されません。 - -例: - -``` sql -SELECT arrayFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res -``` - -``` text -┌─res──────────────────────────────┐ -│ [1,1,3,11,12,12,12,5,6,14,14,14] │ -└──────────────────────────────────┘ -``` - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arrayFill` 機能。 - -### arrayReverseFill(func, arr1, …) {#higher_order_functions-array-reverse-fill} - -スキャンスルー `arr1` 最後の要素から最初の要素へと置き換えます `arr1[i]` によって `arr1[i + 1]` もし `func` 0を返します。 の最後の要素 `arr1` 交換されません。 - -例: - -``` sql -SELECT arrayReverseFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]) AS res -``` - -``` text -┌─res────────────────────────────────┐ -│ [1,3,3,11,12,5,5,5,6,14,NULL,NULL] │ -└────────────────────────────────────┘ -``` - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arrayReverseFill` 機能。 - -### arraySplit(func, arr1, …) {#higher_order_functions-array-split} - -分割 `arr1` 複数の配列に変換します とき `func` 0以外のものを返すと、配列は要素の左側で分割されます。 配列は最初の要素の前に分割されません。 - -例: - -``` sql -SELECT arraySplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res -``` - -``` text -┌─res─────────────┐ -│ [[1,2,3],[4,5]] │ -└─────────────────┘ -``` - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arraySplit` 機能。 - -### arrayReverseSplit(func, arr1, …) {#higher_order_functions-array-reverse-split} - -分割 `arr1` 複数の配列に変換します とき `func` 0以外のものを返すと、配列は要素の右側で分割されます。 配列は最後の要素の後に分割されません。 - -例: - -``` sql -SELECT arrayReverseSplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res -``` - -``` text -┌─res───────────────┐ -│ [[1],[2,3,4],[5]] │ -└───────────────────┘ -``` - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arraySplit` 機能。 - -### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} - -Funcが0以外を返すarr配列内の要素の数を返します。 もし ‘func’ 指定されていない場合は、配列内の非ゼロ要素の数を返します。 - -### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} - -少なくとも1つの要素がある場合は1を返します ‘arr’ そのために ‘func’ 0以外の値を返します。 それ以外の場合は、0を返します。 - -### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} - -場合は1を返します ‘func’ すべての要素に対して0以外のものを返します ‘arr’. それ以外の場合は、0を返します。 - -### arraySum(\[func,\] arr1, …) {#higher-order-functions-array-sum} - -の合計を返します ‘func’ 値。 関数が省略された場合、それだけで配列要素の合計を返します。 - -### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} - -の最初の要素を返します ‘arr1’ そのための配列 ‘func’ 0以外の値を返します。 - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arrayFirst` 機能。 - -### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} - -最初の要素のインデックスを返します ‘arr1’ そのための配列 ‘func’ 0以外の値を返します。 - -最初の引数(ラムダ関数)を省略することはできないことに注意してください。 `arrayFirstIndex` 機能。 - -### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} - -ソース配列内の要素の部分和の配列(実行中の合計)を返します。 この `func` 関数が指定されると、配列要素の値が合計される前にこの関数によって変換されます。 - -例えば: - -``` sql -SELECT arrayCumSum([1, 1, 1, 1]) AS res -``` - -``` text -┌─res──────────┐ -│ [1, 2, 3, 4] │ -└──────────────┘ -``` - -### ツ環板篠ョツ嘉ッツ偲青ツエツδツ-ツアツイツ-ツエツス) {#arraycumsumnonnegativearr} - -と同じ `arrayCumSum`,ソース配列の要素の部分和の配列を返します(実行中の合計). 異なる `arrayCumSum`、その後、戻り値がゼロ未満の値が含まれている場合、値がゼロで置き換えられ、その後の計算は、ゼロのパラメータで実行されます。 例えば: - -``` sql -SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,0,1] │ -└───────────┘ -``` - -### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} - -の要素をソートした結果として配列を返します `arr1` 昇順で。 この `func` 関数が指定され、ソート順序は関数の結果によって決定されます `func` 配列(配列)の要素に適用されます) - -その [シュワルツ語変換](https://en.wikipedia.org/wiki/Schwartzian_transform) 分類の効率を改善するのに使用されています。 - -例えば: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -の詳細については、 `arraySort` 方法は、を参照してください [配列を操作するための関数](array_functions.md#array_functions-sort) セクション。 - -### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} - -の要素をソートした結果として配列を返します `arr1` 降順で。 この `func` 関数が指定され、ソート順序は関数の結果によって決定されます `func` 配列(配列)の要素に適用されます。 - -例えば: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -の詳細については、 `arrayReverseSort` 方法は、を参照してください [配列を操作するための関数](array_functions.md#array_functions-reverse-sort) セクション。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/ja/sql_reference/functions/in_functions.md b/docs/ja/sql_reference/functions/in_functions.md deleted file mode 100644 index 5f6d09af1f1..00000000000 --- a/docs/ja/sql_reference/functions/in_functions.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 60 -toc_title: "IN\u6F14\u7B97\u5B50\u306E\u5B9F\u88C5" ---- - -# IN演算子を実装するための関数 {#functions-for-implementing-the-in-operator} - -## で,ノッチン,グロバリン,グロバルノチン {#in-functions} - -セクションを見る [演算子の場合](../statements/select.md#select-in-operators). - -## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} - -複数の列をグループ化できる関数。 -For columns with the types T1, T2, …, it returns a Tuple(T1, T2, …) type tuple containing these columns. There is no cost to execute the function. -タプルは、通常、in演算子の引数の中間値として、またはラムダ関数の仮パラメータのリストを作成するために使用されます。 タプルはテーブルに書き込むことはできません。 - -## tupleElement(tuple,n),演算子x.N {#tupleelementtuple-n-operator-x-n} - -タプルから列を取得できる関数。 -‘N’ 1から始まる列インデックスです。 Nは定数でなければなりません。 ‘N’ 定数でなければなりません。 ‘N’ タプルのサイズを超えない厳密なポジティブな整数でなければなりません。 -関数を実行するコストはかかりません。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/ja/sql_reference/functions/index.md b/docs/ja/sql_reference/functions/index.md deleted file mode 100644 index 1094c1857cf..00000000000 --- a/docs/ja/sql_reference/functions/index.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Functions -toc_priority: 32 -toc_title: "\u5C0E\u5165" ---- - -# 機能 {#functions} - -少なくとも\*つのタイプの関数があります-通常の関数(これらは単に呼び出されます “functions”) and aggregate functions. These are completely different concepts. Regular functions work as if they are applied to each row separately (for each row, the result of the function doesn't depend on the other rows). Aggregate functions accumulate a set of values from various rows (i.e. they depend on the entire set of rows). - -このセクションでは、定期的な機能を説明します。 のための集計関数の項をご参照ください “Aggregate functions”. - -\*-その機能の第三のタイプがあります ‘arrayJoin’ テーブルの機能も別々に言及することができます。\* - -## 強力なタイピング {#strong-typing} - -標準sqlとは対照的に、clickhouseは強力な型付けをしています。 言い換えれば、型間の暗黙の変換は行われません。 各関数は、特定のタイプのセットに対して機能します。 これは、時には型変換関数を使用する必要があることを意味します。 - -## 共通部分式の削除 {#common-subexpression-elimination} - -同じast(構文解析の同じレコードまたは同じ結果)を持つクエリ内のすべての式は、同じ値を持つとみなされます。 このような式は連結され、一度実行されます。 この方法では、同一のサブクエリも削除されます。 - -## 結果のタイプ {#types-of-results} - -すべての関数は、結果として単一の戻り値を返します(複数の値ではなく、ゼロの値ではありません)。 結果の型は、通常、値ではなく引数の型によってのみ定義されます。 例外は、tupleelement関数(a.n演算子)とtofixedstring関数です。 - -## 定数 {#constants} - -簡単にするために、特定の関数はいくつかの引数の定数のみで動作します。 たとえば、like演算子のright引数は定数でなければなりません。 -ほとんどすべての関数は定数引数の定数を返します。 例外は、乱数を生成する関数です。 -その ‘now’ 関数は、異なる時間に実行されたクエリに対して異なる値を返しますが、定数は単一のクエリ内でのみ重要であるため、結果は定数と見なされます。 -定数式も定数と見なされます(たとえば、like演算子の右半分は複数の定数から構築できます)。 - -関数は、定数と非定数引数(異なるコードが実行される)のために異なる方法で実装することができます。 しかし、定数と同じ値のみを含む真の列の結果は、互いに一致する必要があります。 - -## ヌル処理 {#null-processing} - -関数の動作は次のとおりです: - -- 関数の引数のうち少なくとも一つが `NULL`、機能結果はまたあります `NULL`. -- 各機能の説明で個別に指定される特別な動作。 のclickhouseソースコードは、これらの機能の `UseDefaultImplementationForNulls=false`. - -## 不変性 {#constancy} - -Functions can't change the values of their arguments – any changes are returned as the result. Thus, the result of calculating separate functions does not depend on the order in which the functions are written in the query. - -## エラー処理 {#error-handling} - -データが無効な場合、一部の関数は例外をスローする可能性があります。 この場合、クエリは取り消され、エラーテキストがクライアントに返されます。 分散処理の場合、いずれかのサーバーで例外が発生すると、他のサーバーもクエリを中止しようとします。 - -## 引数式の評価 {#evaluation-of-argument-expressions} - -ほぼすべてのプログラミング言語の一つの引数が評価される。 これは通常、演算子です `&&`, `||`、と `?:`. -しかし、clickhouseでは、関数(演算子)の引数は常に評価されます。 これは、各行を別々に計算するのではなく、列の全部分が一度に評価されるためです。 - -## 分散クエリ処理のための関数の実行 {#performing-functions-for-distributed-query-processing} - -分散クエリ処理では、できるだけ多くのクエリ処理がリモートサーバーで実行され、その他のステージ(中間結果とそれ以降のすべてのステージ)はリクエスター - -つまり、異なるサーバーで機能を実行できます。 -たとえば、クエリでは `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` - -- もし `distributed_table` は、少なくとも二つのシャード、機能 ‘g’ と ‘h’ リモートサーバー上で実行される。 ‘f’ 要求元サーバーで実行されます。 -- もし `distributed_table` 一つだけシャード、すべてを持っています ‘f’, ‘g’、と ‘h’ 機能は、このシャードのサーバー上で実行されます。 - -関数の結果は、通常、実行されるサーバーに依存しません。 しかし、時にはこれが重要です。 -たとえば、辞書を操作する関数は、実行しているサーバー上に存在する辞書を使用します。 -別の例は、 `hostName` この関数は、実行されているサーバーの名前を返します。 `GROUP BY` aのサーバーによって `SELECT` クエリ。 - -クエリ内の関数がリクエストサーバー上で実行されているが、リモートサーバー上で実行する必要がある場合は、次のようにラップします。 ‘any’ 関数を集めるか、それをキーに追加します `GROUP BY`. - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/ja/sql_reference/functions/introspection.md b/docs/ja/sql_reference/functions/introspection.md deleted file mode 100644 index 78a1c6ae557..00000000000 --- a/docs/ja/sql_reference/functions/introspection.md +++ /dev/null @@ -1,310 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 65 -toc_title: "\u30A4\u30F3\u30C8\u30ED\u30B9\u30DA\u30AF\u30B7\u30E7\u30F3" ---- - -# イントロスペクション関数 {#introspection-functions} - -利用できる表示可能なプラグインで説明してこの章にintrospect [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) と [DWARF](https://en.wikipedia.org/wiki/DWARF) のためのクエリープロファイリング. - -!!! warning "警告" - これらの機能は、が必要となる場合があり安全に配慮し - -イントロスペクション機能を適切に動作させるため: - -- インストール `clickhouse-common-static-dbg` パッケージ。 - -- セットを [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) 1に設定します。 - - For security reasons introspection functions are disabled by default. - -ClickHouseはプロファイラーレポートを保存します [trace\_log](../../operations/system_tables.md#system_tables-trace_log) システムテーブル。 のテーブルプロファイラで設定されます。 - -## アドレスストリンcolor {#addresstoline} - -ClickHouseサーバープロセス内の仮想メモリアドレスを、ClickHouseソースコード内のファイル名と行番号に変換します。 - -公式のclickhouseのパッケージを使用すれば、取付ける必要があります `clickhouse-common-static-dbg` パッケージ。 - -**構文** - -``` sql -addressToLine(address_of_binary_instruction) -``` - -**パラメータ** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**戻り値** - -- コロンで区切られたこのファイル内のソースコードのファイル名と行番号。 - - For example, `/build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.cpp:199`, where `199` is a line number. - -- 関数がデバッグ情報を見つけることができなかった場合、バイナリの名前。 - -- アドレスが有効でない場合は、空の文字列。 - -タイプ: [文字列](../../sql_reference/data_types/string.md). - -**例えば** - -イントロスペクション機能の有効化: - -``` sql -SET allow_introspection_functions=1 -``` - -から最初の文字列を選択する `trace_log` システム表: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-19 -event_time: 2019-11-19 18:57:23 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 421b6855-1858-45a5-8f37-f383409d6d72 -trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] -``` - -その `trace` 分野のスタックトレースを瞬時にサンプリングします。 - -単一のアドレスのソースコードファイル名と行番号を取得する: - -``` sql -SELECT addressToLine(94784076370703) \G -``` - -``` text -Row 1: -────── -addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.cpp:199 -``` - -スタックトレース全体に関数を適用する: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines -FROM system.trace_log -LIMIT 1 -\G -``` - -その [arrayMap](higher_order_functions.md#higher_order_functions-array-map) 機能はの各々の個々の要素を処理することを割り当てます `trace` による配列 `addressToLine` 機能。 この処理の結果は、次のように表示されます。 `trace_source_code_lines` 出力の列。 - -``` text -Row 1: -────── -trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so -/usr/lib/debug/usr/bin/clickhouse -/build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.cpp:199 -/build/obj-x86_64-linux-gnu/../dbms/Common/ThreadPool.h:155 -/usr/include/c++/9/bits/atomic_base.h:551 -/usr/lib/debug/usr/bin/clickhouse -/lib/x86_64-linux-gnu/libpthread-2.27.so -/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -``` - -## addressToSymbol {#addresstosymbol} - -に変換する仮想メモリアドレス内clickhouseサーバプロセスのシンボルからclickhouseオブジェクトファイルです。 - -**構文** - -``` sql -addressToSymbol(address_of_binary_instruction) -``` - -**パラメータ** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**戻り値** - -- ClickHouseオブジェクトファイルからの記号。 -- アドレスが有効でない場合は、空の文字列。 - -タイプ: [文字列](../../sql_reference/data_types/string.md). - -**例えば** - -イントロスペクション機能の有効化: - -``` sql -SET allow_introspection_functions=1 -``` - -から最初の文字列を選択する `trace_log` システム表: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -その `trace` 分野のスタックトレースを瞬時にサンプリングします。 - -単一のアドレスのシンボルを取得する: - -``` sql -SELECT addressToSymbol(94138803686098) \G -``` - -``` text -Row 1: -────── -addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -``` - -スタックトレース全体に関数を適用する: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols -FROM system.trace_log -LIMIT 1 -\G -``` - -その [arrayMap](higher_order_functions.md#higher_order_functions-array-map) 機能はの各々の個々の要素を処理することを割り当てます `trace` による配列 `addressToSymbols` 機能。 この処理の結果は、次のように表示されます。 `trace_symbols` 出力の列。 - -``` text -Row 1: -────── -trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE -_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb -_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb -_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE -_ZN2DB27AggregatingBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB28AsynchronousBlockInputStream9calculateEv -_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data -_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E -_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv -_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E -execute_native_thread_routine -start_thread -clone -``` - -## デマングル {#demangle} - -を使用して取得できるシンボルを変換します。 [addressToSymbol](#addresstosymbol) C++の関数名に関数。 - -**構文** - -``` sql -demangle(symbol) -``` - -**パラメータ** - -- `symbol` ([文字列](../../sql_reference/data_types/string.md)) — Symbol from an object file. - -**戻り値** - -- C++関数の名前。 -- シンボルが有効でない場合は、空の文字列。 - -タイプ: [文字列](../../sql_reference/data_types/string.md). - -**例えば** - -イントロスペクション機能の有効化: - -``` sql -SET allow_introspection_functions=1 -``` - -から最初の文字列を選択する `trace_log` システム表: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -その `trace` 分野のスタックトレースを瞬時にサンプリングします。 - -単一アドレスの関数名の取得: - -``` sql -SELECT demangle(addressToSymbol(94138803686098)) \G -``` - -``` text -Row 1: -────── -demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -``` - -スタックトレース全体に関数を適用する: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions -FROM system.trace_log -LIMIT 1 -\G -``` - -その [arrayMap](higher_order_functions.md#higher_order_functions-array-map) 機能はの各々の個々の要素を処理することを割り当てます `trace` による配列 `demangle` 機能。 この処理の結果は、次のように表示されます。 `trace_functions` 出力の列。 - -``` text -Row 1: -────── -trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const -DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) -DB::AggregatingBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::AsynchronousBlockInputStream::calculate() -std::_Function_handler::_M_invoke(std::_Any_data const&) -ThreadPoolImpl::worker(std::_List_iterator) -ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const -ThreadPoolImpl::worker(std::_List_iterator) -execute_native_thread_routine -start_thread -clone -``` diff --git a/docs/ja/sql_reference/functions/ip_address_functions.md b/docs/ja/sql_reference/functions/ip_address_functions.md deleted file mode 100644 index 1eca3b316fc..00000000000 --- a/docs/ja/sql_reference/functions/ip_address_functions.md +++ /dev/null @@ -1,248 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 55 -toc_title: "IP\u30A2\u30C9\u30EC\u30B9\u306E\u64CD\u4F5C" ---- - -# IPアドレスを操作するための機能 {#functions-for-working-with-ip-addresses} - -## IPv4NumToString(num) {#ipv4numtostringnum} - -UInt32番号を受け取ります。 ビッグエンディアンのIPv4アドレスとして解釈します。 対応するIPv4アドレスをA.B.C.dという形式で含む文字列を返します。 - -## IPv4StringToNum(s) {#ipv4stringtonums} - -IPv4NumToStringの逆関数. IPv4アドレスの形式が無効な場合は、0を返します。 - -## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} - -IPv4NumToStringに似ていますが、最後のオクテットの代わりにxxxを使用します。 - -例えば: - -``` sql -SELECT - IPv4NumToStringClassC(ClientIP) AS k, - count() AS c -FROM test.hits -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─k──────────────┬─────c─┐ -│ 83.149.9.xxx │ 26238 │ -│ 217.118.81.xxx │ 26074 │ -│ 213.87.129.xxx │ 25481 │ -│ 83.149.8.xxx │ 24984 │ -│ 217.118.83.xxx │ 22797 │ -│ 78.25.120.xxx │ 22354 │ -│ 213.87.131.xxx │ 21285 │ -│ 78.25.121.xxx │ 20887 │ -│ 188.162.65.xxx │ 19694 │ -│ 83.149.48.xxx │ 17406 │ -└────────────────┴───────┘ -``` - -使用して以来 ‘xxx’ 非常に珍しいです、これは将来変更されるかもしれません。 このフラグメントの正確なフォーマットに依存しないことをお勧めします。 - -### IPv6NumToString(x) {#ipv6numtostringx} - -バイナリ形式のipv6アドレスを含むfixedstring(16)値を受け入れます。 このアドレスを含む文字列をテキスト形式で返します。 -IPv6にマップされたIPv4アドレスは、::ffff:111.222.33.44の形式で出力されます。 例: - -``` sql -SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr -``` - -``` text -┌─addr─────────┐ -│ 2a02:6b8::11 │ -└──────────────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ -│ 2a02:2168:aaa:bbbb::2 │ 24695 │ -│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ -│ 2a02:6b8:0:fff::ff │ 16389 │ -│ 2a01:4f8:111:6666::2 │ 16016 │ -│ 2a02:2168:888:222::1 │ 15896 │ -│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ -│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ -│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ -│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ -│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ -└─────────────────────────────────────────┴───────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)─┬──────c─┐ -│ ::ffff:94.26.111.111 │ 747440 │ -│ ::ffff:37.143.222.4 │ 529483 │ -│ ::ffff:5.166.111.99 │ 317707 │ -│ ::ffff:46.38.11.77 │ 263086 │ -│ ::ffff:79.105.111.111 │ 186611 │ -│ ::ffff:93.92.111.88 │ 176773 │ -│ ::ffff:84.53.111.33 │ 158709 │ -│ ::ffff:217.118.11.22 │ 154004 │ -│ ::ffff:217.118.11.33 │ 148449 │ -│ ::ffff:217.118.11.44 │ 148243 │ -└────────────────────────────┴────────┘ -``` - -## IPv6StringToNum(s) {#ipv6stringtonums} - -IPv6NumToStringの逆関数. IPv6アドレスの形式が無効な場合は、nullバイトの文字列を返します。 -HEXは大文字または小文字にできます。 - -## IPv4ToIPv6(x) {#ipv4toipv6x} - -を取る `UInt32` 番号 IPv4アドレスとして解釈します。 [ビッグエンディアン](https://en.wikipedia.org/wiki/Endianness). Aを返します `FixedString(16)` バイナリ形式のIPv6アドレスを含む値。 例: - -``` sql -SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr -``` - -``` text -┌─addr───────────────┐ -│ ::ffff:192.168.0.1 │ -└────────────────────┘ -``` - -## cutIPv6(x,bitsToCutForIPv6,bitsToCutForIPv4) {#cutipv6x-bitstocutforipv6-bitstocutforipv4} - -バイナリ形式のipv6アドレスを含むfixedstring(16)値を受け入れます。 テキスト形式で削除された指定されたビット数のアドレスを含む文字列を返します。 例えば: - -``` sql -WITH - IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, - IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 -SELECT - cutIPv6(ipv6, 2, 0), - cutIPv6(ipv4, 0, 2) -``` - -``` text -┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ -│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ -└─────────────────────────────────────┴─────────────────────┘ -``` - -## IPv4CIDRToRange(ipv4,cidr), {#ipv4cidrtorangeipv4-cidr} - -IPv4とUInt8の値を受け取ります。 [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing). 下位のサブネットの範囲と上位の範囲を含むIPv4を持つタプルを返します。 - -``` sql -SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) -``` - -``` text -┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ -│ ('192.168.0.0','192.168.255.255') │ -└────────────────────────────────────────────┘ -``` - -## IPv6CIDRToRange(ipv6,cidr), {#ipv6cidrtorangeipv6-cidr} - -Cidrを含むIPv6およびUInt8値を受け入れます。 IPv6の下位範囲と上位のサブネットを含むタプルを返します。 - -``` sql -SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); -``` - -``` text -┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ -│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ -└────────────────────────────────────────────────────────────────────────┘ -``` - -## toIPv4(文字列) {#toipv4string} - -別名を指定する `IPv4StringToNum()` これはIPv4アドレスの文字列形式をとり、その値を返します。 [IPv4](../../sql_reference/data_types/domains/ipv4.md) 返される値に等しいバイナリです `IPv4StringToNum()`. - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - toTypeName(IPv4StringToNum(IPv4_string)), - toTypeName(toIPv4(IPv4_string)) -``` - -``` text -┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ -│ UInt32 │ IPv4 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - hex(IPv4StringToNum(IPv4_string)), - hex(toIPv4(IPv4_string)) -``` - -``` text -┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ -│ ABE1822D │ ABE1822D │ -└───────────────────────────────────┴──────────────────────────┘ -``` - -## toIPv6(文字列) {#toipv6string} - -別名を指定する `IPv6StringToNum()` これはIPv6アドレスの文字列形式を取り、値をの戻します [IPv6](../../sql_reference/data_types/domains/ipv6.md) 返される値に等しいバイナリです `IPv6StringToNum()`. - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - toTypeName(IPv6StringToNum(IPv6_string)), - toTypeName(toIPv6(IPv6_string)) -``` - -``` text -┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ -│ FixedString(16) │ IPv6 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - hex(IPv6StringToNum(IPv6_string)), - hex(toIPv6(IPv6_string)) -``` - -``` text -┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ -│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ -└───────────────────────────────────┴──────────────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/ja/sql_reference/functions/json_functions.md b/docs/ja/sql_reference/functions/json_functions.md deleted file mode 100644 index f3695a3bab9..00000000000 --- a/docs/ja/sql_reference/functions/json_functions.md +++ /dev/null @@ -1,231 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 56 -toc_title: "JSON\u3067\u306E\u4F5C\u696D." ---- - -# JSONを操作するための関数 {#functions-for-working-with-json} - -Yandexの中。Metrica、JSONで送信したユーザーとしてセッションパラメータ。 このJSONを操作するための特別な関数がいくつかあります。 (ほとんどの場合、JSONsはさらに前処理され、結果の値は処理された形式で別々の列に格納されます。)これらの関数はすべて、JSONができることについての強い前提に基づいていますが、仕事を終わらせるためにできるだけ少なくしようとします。 - -以下の仮定が行われます: - -1. フィールド名(関数の引数)は定数でなければなりません。 -2. フィールド名は何とかcanonicallyで符号化されたjson. 例えば: `visitParamHas('{"abc":"def"}', 'abc') = 1`、しかし `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -3. フィールドは、任意の入れ子レベルで無差別に検索されます。 一致するフィールドが複数ある場合は、最初のオカレンスが使用されます。 -4. JSONには、文字列リテラルの外側にスペース文字はありません。 - -## visitParamHas(パラメータ,名前) {#visitparamhasparams-name} - -フィールドがあるかどうかをチェック ‘name’ 名前だ - -## visitParamExtractUInt(パラメータ,名前) {#visitparamextractuintparams-name} - -指定されたフィールドの値からuint64を解析します ‘name’. これが文字列フィールドの場合、文字列の先頭から数値を解析しようとします。 フィールドが存在しないか、存在するが数値が含まれていない場合は、0を返します。 - -## visitParamExtractInt(パラメータ,名前) {#visitparamextractintparams-name} - -Int64の場合と同じです。 - -## visitParamExtractFloat(パラメーター,名前) {#visitparamextractfloatparams-name} - -Float64の場合と同じです。 - -## visitParamExtractBool(パラメーター,名前) {#visitparamextractboolparams-name} - -True/false値を解析します。 結果はUInt8です。 - -## visitParamExtractRaw(パラメータ,名前) {#visitparamextractrawparams-name} - -セパレータを含むフィールドの値を返します。 - -例: - -``` sql -visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' -visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' -``` - -## visitParamExtractString(パラメーター,名前) {#visitparamextractstringparams-name} - -文字列を二重引用符で解析します。 値はエスケープされません。 エスケープ解除に失敗した場合は、空の文字列を返します。 - -例: - -``` sql -visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' -visitParamExtractString('{"abc":"hello}', 'abc') = '' -``` - -現在、この形式のコードポイントはサポートされていません `\uXXXX\uYYYY` これは、(彼らはCESU-8の代わりにUTF-8に変換されます)基本的な多言語面からではありません。 - -次の関数は、以下に基づいています [simdjson](https://github.com/lemire/simdjson) より複雑なJSON解析要件のために設計。 上記の前提2は依然として適用されます。 - -## isValidJSON(json) {#isvalidjsonjson} - -渡された文字列が有効なjsonであることを確認します。 - -例: - -``` sql -SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 -SELECT isValidJSON('not a json') = 0 -``` - -## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} - -JSONドキュメントに値が存在する場合, `1` は返却されます。 - -値が存在しない場合, `0` は返却されます。 - -例: - -``` sql -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 -``` - -`indices_or_keys` それぞれの引数は、文字列または整数のいずれかになります。 - -- 文字列=アクセスオブジェクトにより、会員に対す。 -- 正の整数=最初からn番目のメンバー/キーにアクセスします。 -- 負の整数=最後からn番目のメンバー/キーにアクセスします。 - -要素の最小インデックスは1です。 したがって、要素0は存在しません。 - -整数を使用して、json配列とjsonオブジェクトの両方にアクセスできます。 - -例えば: - -``` sql -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' -``` - -## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} - -JSON配列またはJSONオブジェクトの長さを返します。 - -値が存在しないか、間違った型を持っている場合, `0` は返却されます。 - -例: - -``` sql -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 -``` - -## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} - -JSON値の型を返します。 - -値が存在しない場合, `Null` は返却されます。 - -例: - -``` sql -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' -``` - -## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} - -## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} - -## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} - -## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} - -JSONを解析し、値を抽出します。 これらの機能と類似 `visitParam` 機能。 - -値が存在しないか、間違った型を持っている場合, `0` は返却されます。 - -例: - -``` sql -SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 -SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 -SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 -``` - -## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} - -JSONを解析し、文字列を抽出します。 この関数は次のようになります `visitParamExtractString` 機能。 - -値が存在しないか、間違った型を持っている場合は、空の文字列が返されます。 - -値はエスケープされません。 エスケープ解除に失敗した場合は、空の文字列を返します。 - -例: - -``` sql -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' -SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' -SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' -``` - -## JSONExtract(json\[, indices\_or\_keys…\], return\_type) {#jsonextractjson-indices-or-keys-return-type} - -JSONを解析し、指定されたClickHouseデータ型の値を抽出します。 - -これは以前の一般化です `JSONExtract` 機能。 -これは -`JSONExtract(..., 'String')` とまったく同じを返します `JSONExtractString()`, -`JSONExtract(..., 'Float64')` とまったく同じを返します `JSONExtractFloat()`. - -例: - -``` sql -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL -SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 -SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' -SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' -``` - -## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} - -値が指定されたclickhouseデータ型のjsonからキーと値のペアを解析します。 - -例えば: - -``` sql -SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; -``` - -## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} - -JSONの一部を返します。 - -パートが存在しないか、間違った型を持っている場合は、空の文字列が返されます。 - -例えば: - -``` sql -SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' -``` - -## JSONExtractArrayRaw(json\[, indices\_or\_keys\]…) {#jsonextractarrayrawjson-indices-or-keys} - -それぞれが未解析の文字列として表されるjson配列の要素を持つ配列を返します。 - -その部分が存在しない場合、または配列でない場合は、空の配列が返されます。 - -例えば: - -``` sql -SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) diff --git a/docs/ja/sql_reference/functions/logical_functions.md b/docs/ja/sql_reference/functions/logical_functions.md deleted file mode 100644 index 7ccc14b8b95..00000000000 --- a/docs/ja/sql_reference/functions/logical_functions.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u8AD6\u7406" ---- - -# 論理関数 {#logical-functions} - -論理関数は任意の数値型を受け入れますが、uint8の数値を0または1に返します。 - -引数としてのゼロが考慮されます “false,” ゼロ以外の値は考慮されますが “true”. - -## and、および演算子 {#and-and-operator} - -## or、OR演算子 {#or-or-operator} - -## not,not演算子 {#not-not-operator} - -## xor {#xor} - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/ja/sql_reference/functions/machine_learning_functions.md b/docs/ja/sql_reference/functions/machine_learning_functions.md deleted file mode 100644 index 9c7bc3df243..00000000000 --- a/docs/ja/sql_reference/functions/machine_learning_functions.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 64 -toc_title: "\u6A5F\u68B0\u5B66\u7FD2\u306E\u6A5F\u80FD" ---- - -# 機械学習の機能 {#machine-learning-functions} - -## evalMLMethod(予測) {#machine_learning_methods-evalmlmethod} - -適合回帰モデルを使用した予測 `evalMLMethod` 機能。 リンクを見る `linearRegression`. - -### 確率的線形回帰 {#stochastic-linear-regression} - -その [stochasticLinearRegression](../../sql_reference/aggregate_functions/reference.md#agg_functions-stochasticlinearregression) 集合関数は,線形モデルとMSE損失関数を用いた確率的勾配降下法を実装する。 使用 `evalMLMethod` 新しいデータを予測する。 - -### 確率論的ロジスティック回帰 {#stochastic-logistic-regression} - -その [stochasticLogisticRegression](../../sql_reference/aggregate_functions/reference.md#agg_functions-stochasticlogisticregression) 集合関数は,二値分類問題に対して確率的勾配降下法を実装する。 使用 `evalMLMethod` 新しいデータを予測する。 diff --git a/docs/ja/sql_reference/functions/math_functions.md b/docs/ja/sql_reference/functions/math_functions.md deleted file mode 100644 index 1376d518913..00000000000 --- a/docs/ja/sql_reference/functions/math_functions.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: "\u6570\u5B66" ---- - -# 数学関数 {#mathematical-functions} - -すべての関数はfloat64番号を返します。 結果の精度は可能な最大精度に近いですが、結果は対応する実数に最も近いマシン表現可能な数値と一致しない場合があります。 - -## e() {#e} - -数値eに近いfloat64数値を返します。 - -## pi() {#pi} - -Returns a Float64 number that is close to the number π. - -## exp(x) {#expx} - -数値引数を受け取り、引数の指数に近いfloat64数値を返します。 - -## ログ(x),ln(x) {#logx-lnx} - -数値引数を受け取り、引数の自然対数に近いfloat64数値を返します。 - -## exp2(x) {#exp2x} - -数値引数を受け取り、float64の数値を2に近づけてxの累乗を返します。 - -## log2(x) {#log2x} - -数値引数を受け取り、引数のバイナリ対数に近いfloat64数値を返します。 - -## exp10(x) {#exp10x} - -数値引数を受け取り、float64の数値をxの累乗に近い10に返します。 - -## log10(x) {#log10x} - -数値引数を受け取り、引数の小数点以下の対数に近いfloat64数値を返します。 - -## sqrt(x) {#sqrtx} - -数値引数を受け取り、引数の平方根に近いfloat64数値を返します。 - -## cbrt(x) {#cbrtx} - -数値引数を受け取り、引数の三次根に近いfloat64数値を返します。 - -## erf(x) {#erfx} - -もし ‘x’ is non-negative, then erf(x / σ√2) 標準偏差を持つ正規分布を持つ確率変数です ‘σ’ 期待値から分離されている値を次の値よりも大きくします ‘x’. - -例(三つのシグマルール): - -``` sql -SELECT erf(3 / sqrt(2)) -``` - -``` text -┌─erf(divide(3, sqrt(2)))─┐ -│ 0.9973002039367398 │ -└─────────────────────────┘ -``` - -## erfc(x) {#erfcx} - -数値引数を受け取り、float64数値を1-erf(x)に近い値に返しますが、大きな値の精度を失うことはありません ‘x’ 値。 - -## lgamma(x) {#lgammax} - -ガンマ関数の対数。 - -## tgamma(x) {#tgammax} - -ガンマ関数。 - -## sin(x) {#sinx} - -サイン。 - -## cos(x) {#cosx} - -コサイン - -## tan(x) {#tanx} - -タンジェント。 - -## asin(x) {#asinx} - -アークの正弦。 - -## acos(x) {#acosx} - -アークコサイン。 - -## atan(x) {#atanx} - -アークタンジェント。 - -## pow(x,y),パワー(x,y) {#powx-y-powerx-y} - -Xに近いFloat64数をyの累乗に返します。 - -## intExp2 {#intexp2} - -数値引数を受け取り、xの累乗に対してuint64の2に近い数値を返します。 - -## intExp10 {#intexp10} - -数値引数を受け取り、xの累乗に近いuint64の数値を10に返します。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/ja/sql_reference/functions/other_functions.md b/docs/ja/sql_reference/functions/other_functions.md deleted file mode 100644 index ae9bb898405..00000000000 --- a/docs/ja/sql_reference/functions/other_functions.md +++ /dev/null @@ -1,1079 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 66 -toc_title: "\u305D\u306E\u4ED6" ---- - -# その他の機能 {#other-functions} - -## ホスト名() {#hostname} - -この関数が実行されたホストの名前を持つ文字列を返します。 分散処理の場合、機能がリモートサーバー上で実行される場合、これはリモートサーバーホストの名前です。 - -## FQDN {#fqdn} - -完全修飾ドメイン名を返します。 - -**構文** - -``` sql -fqdn(); -``` - -この関数は、大文字と小文字を区別しません。 - -**戻り値** - -- 完全修飾ドメイン名の文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT FQDN(); -``` - -結果: - -``` text -┌─FQDN()──────────────────────────┐ -│ clickhouse.ru-central1.internal │ -└─────────────────────────────────┘ -``` - -## ベース名 {#basename} - -最後のスラッシュまたはバックスラッシュの後の文字列の末尾の部分を抽出します。 この関数は、パスからファイル名を抽出するためによく使用されます。 - -``` sql -basename( expr ) -``` - -**パラメータ** - -- `expr` — Expression resulting in a [文字列](../../sql_reference/data_types/string.md) タイプ値。 すべての円記号は、結果の値でエスケープする必要があります。 - -**戻り値** - -以下を含む文字列: - -- 最後のスラッシュまたはバックスラッシュの後の文字列の末尾の部分。 - - If the input string contains a path ending with slash or backslash, for example, `/` or `c:\`, the function returns an empty string. - -- スラッシュまたはバックスラッシュがない場合は、元の文字列。 - -**例えば** - -``` sql -SELECT 'some/long/path/to/file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some\\long\\path\\to\\file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some-file-name' AS a, basename(a) -``` - -``` text -┌─a──────────────┬─basename('some-file-name')─┐ -│ some-file-name │ some-file-name │ -└────────────────┴────────────────────────────┘ -``` - -## visibleWidth(x) {#visiblewidthx} - -テキスト形式(タブ区切り)でコンソールに値を出力するときのおおよその幅を計算します。 -この関数は、システムがpretty形式を実装するために使用します。 - -`NULL` に対応する文字列として表される。 `NULL` で `Pretty` フォーマット。 - -``` sql -SELECT visibleWidth(NULL) -``` - -``` text -┌─visibleWidth(NULL)─┐ -│ 4 │ -└────────────────────┘ -``` - -## toTypeName(x) {#totypenamex} - -渡された引数の型名を含む文字列を返します。 - -もし `NULL` 入力として関数に渡され、その後、それが返されます `Nullable(Nothing)` 内部に対応するタイプ `NULL` ClickHouseでの表現。 - -## ブロックサイズ() {#function-blocksize} - -ブロックのサイズを取得します。 -ClickHouseでは、クエリは常にブロック(列部分のセット)で実行されます。 この関数は、それを呼び出したブロックのサイズを取得することができます。 - -## マテリアライズ(x) {#materializex} - -一つの値だけを含む完全な列に定数を変換します。 -ClickHouseでは、完全な列と定数はメモリ内で異なる方法で表されます。 関数は定数引数と通常の引数(異なるコードが実行される)では異なる動作をしますが、結果はほとんど常に同じです。 この関数は、この動作のデバッグ用です。 - -## ignore(…) {#ignore} - -以下を含む任意の引数を受け取る `NULL`. 常に0を返します。 -ただし、引数はまだ評価されます。 これはベンチマークに使用できます。 - -## スリープ(秒) {#sleepseconds} - -眠る ‘seconds’ 各データブロックの秒。 整数または浮動小数点数を指定できます。 - -## sleepEachRow(秒) {#sleepeachrowseconds} - -眠る ‘seconds’ 各行の秒。 整数または浮動小数点数を指定できます。 - -## currentDatabase() {#currentdatabase} - -現在のデータベースの名前を返します。 -この関数は、データベースを指定する必要があるcreate tableクエリのテーブルエンジンパラメーターで使用できます。 - -## currentUser() {#other-function-currentuser} - -現在のユーザーのログインを返します。 ユーザのログインは、そのクエリを開始し、ケースdistibutedクエリで返されます。 - -``` sql -SELECT currentUser(); -``` - -エイリアス: `user()`, `USER()`. - -**戻り値** - -- 現在のユーザーのログイン。 -- クエリを開始したユーザーのログイン。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT currentUser(); -``` - -結果: - -``` text -┌─currentUser()─┐ -│ default │ -└───────────────┘ -``` - -## isFinite(x) {#isfinitex} - -引数が無限でなくnanでない場合はfloat32とfloat64を受け取り、uint8を1に返します(それ以外の場合は0)。 - -## イシンフィナイト(x) {#isinfinitex} - -引数が無限の場合はfloat32とfloat64を受け取り、uint8を1に戻し、それ以外の場合は0を返します。 nanの場合は0が返されることに注意してください。 - -## ifNotFinite {#ifnotfinite} - -浮動小数点値が有限かどうかをチェックします。 - -**構文** - - ifNotFinite(x,y) - -**パラメータ** - -- `x` — Value to be checked for infinity. Type: [フロート\*](../../sql_reference/data_types/float.md). -- `y` — Fallback value. Type: [フロート\*](../../sql_reference/data_types/float.md). - -**戻り値** - -- `x` もし `x` 有限です。 -- `y` もし `x` 有限ではない。 - -**例えば** - -クエリ: - - SELECT 1/0 as infimum, ifNotFinite(infimum,42) - -結果: - - ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ - │ inf │ 42 │ - └─────────┴───────────────────────────────┘ - -同様の結果を得るには、次のようにします [三項演算子](conditional_functions.md#ternary-operator): `isFinite(x) ? x : y`. - -## isNaN(x) {#isnanx} - -引数がnanの場合はfloat32とfloat64を受け取り、uint8を1に返します。 - -## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} - -データベース名、テーブル名、列名などの定数文字列を受け入れます。 列がある場合はuint8定数式を1に、それ以外の場合は0を返します。 hostnameパラメーターを設定すると、テストはリモートサーバーで実行されます。 -テーブルが存在しない場合、関数は例外をスローします。 -入れ子になったデータ構造内の要素の場合、この関数は列の存在をチェックします。 入れ子になったデータ構造自体の場合、関数は0を返します。 - -## バー {#function-bar} - -ユニコードアート図を作成できます。 - -`bar(x, min, max, width)` に比例する幅を持つバンドを描画します `(x - min)` とに等しい `width` 文字の場合 `x = max`. - -パラメータ: - -- `x` — Size to display. -- `min, max` — Integer constants. The value must fit in `Int64`. -- `width` — Constant, positive integer, can be fractional. - -バンドは、シンボルの第八に精度で描かれています。 - -例えば: - -``` sql -SELECT - toHour(EventTime) AS h, - count() AS c, - bar(c, 0, 600000, 20) AS bar -FROM test.hits -GROUP BY h -ORDER BY h ASC -``` - -``` text -┌──h─┬──────c─┬─bar────────────────┐ -│ 0 │ 292907 │ █████████▋ │ -│ 1 │ 180563 │ ██████ │ -│ 2 │ 114861 │ ███▋ │ -│ 3 │ 85069 │ ██▋ │ -│ 4 │ 68543 │ ██▎ │ -│ 5 │ 78116 │ ██▌ │ -│ 6 │ 113474 │ ███▋ │ -│ 7 │ 170678 │ █████▋ │ -│ 8 │ 278380 │ █████████▎ │ -│ 9 │ 391053 │ █████████████ │ -│ 10 │ 457681 │ ███████████████▎ │ -│ 11 │ 493667 │ ████████████████▍ │ -│ 12 │ 509641 │ ████████████████▊ │ -│ 13 │ 522947 │ █████████████████▍ │ -│ 14 │ 539954 │ █████████████████▊ │ -│ 15 │ 528460 │ █████████████████▌ │ -│ 16 │ 539201 │ █████████████████▊ │ -│ 17 │ 523539 │ █████████████████▍ │ -│ 18 │ 506467 │ ████████████████▊ │ -│ 19 │ 520915 │ █████████████████▎ │ -│ 20 │ 521665 │ █████████████████▍ │ -│ 21 │ 542078 │ ██████████████████ │ -│ 22 │ 493642 │ ████████████████▍ │ -│ 23 │ 400397 │ █████████████▎ │ -└────┴────────┴────────────────────┘ -``` - -## 変換 {#transform} - -いくつかの要素の明示的に定義されたマッピングに従って値を他の要素に変換します。 -この関数には二つの違いがあります: - -### transform(x,array\_from,array\_to,デフォルト) {#transformx-array-from-array-to-default} - -`x` – What to transform. - -`array_from` – Constant array of values for converting. - -`array_to` – Constant array of values to convert the values in ‘from’ に。 - -`default` – Which value to use if ‘x’ 値のいずれにも等しくありません。 ‘from’. - -`array_from` と `array_to` – Arrays of the same size. - -タイプ: - -`transform(T, Array(T), Array(U), U) -> U` - -`T` と `U` 数値、文字列、または日付または日時の型を指定できます。 -同じ文字(tまたはu)が示されている場合、数値型の場合、これらは一致する型ではなく、共通の型を持つ型である可能性があります。 -たとえば、最初の引数はint64型を持つことができ、二番目の引数はarray(uint16)型を持つことができます。 - -この ‘x’ 値は、次のいずれかの要素に等しくなります。 ‘array\_from’ 配列の場合は、既存の要素(同じ番号が付けられています)を返します。 ‘array\_to’ 配列だ それ以外の場合は、 ‘default’. 一致する要素が複数ある場合 ‘array\_from’、それはマッチのいずれかを返します。 - -例えば: - -``` sql -SELECT - transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, - count() AS c -FROM test.hits -WHERE SearchEngineID != 0 -GROUP BY title -ORDER BY c DESC -``` - -``` text -┌─title─────┬──────c─┐ -│ Yandex │ 498635 │ -│ Google │ 229872 │ -│ Other │ 104472 │ -└───────────┴────────┘ -``` - -### トランスフォーム(x,array\_from,array\_to) {#transformx-array-from-array-to} - -最初のバリエーションとは異なります ‘default’ 引数は省略する。 -この ‘x’ 値は、次のいずれかの要素に等しくなります。 ‘array\_from’ 配列の場合は、マッチする要素(同じ番号を付けられた要素)を返します。 ‘array\_to’ 配列だ それ以外の場合は、 ‘x’. - -タイプ: - -`transform(T, Array(T), Array(T)) -> T` - -例えば: - -``` sql -SELECT - transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, - count() AS c -FROM test.hits -GROUP BY domain(Referer) -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -┌─s──────────────┬───────c─┐ -│ │ 2906259 │ -│ www.yandex │ 867767 │ -│ ███████.ru │ 313599 │ -│ mail.yandex.ru │ 107147 │ -│ ██████.ru │ 100355 │ -│ █████████.ru │ 65040 │ -│ news.yandex.ru │ 64515 │ -│ ██████.net │ 59141 │ -│ example.com │ 57316 │ -└────────────────┴─────────┘ -``` - -## formatReadableSize(x) {#formatreadablesizex} - -サイズ(バイト数)を受け入れます。 サフィックス(kib、mibなど)を含む丸められたサイズを返します。)文字列として。 - -例えば: - -``` sql -SELECT - arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, - formatReadableSize(filesize_bytes) AS filesize -``` - -``` text -┌─filesize_bytes─┬─filesize───┐ -│ 1 │ 1.00 B │ -│ 1024 │ 1.00 KiB │ -│ 1048576 │ 1.00 MiB │ -│ 192851925 │ 183.92 MiB │ -└────────────────┴────────────┘ -``` - -## 少なくとも(a,b) {#leasta-b} - -Aとbの最小値を返します。 - -## 最大(a,b) {#greatesta-b} - -Aとbの最大値を返します。 - -## アップタイム() {#uptime} - -サーバーの稼働時間を秒単位で返します。 - -## バージョン() {#version} - -サーバーのバージョンを文字列として返します。 - -## タイムゾーン() {#timezone} - -サーバーのタイムゾーンを返します。 - -## bloknumber {#blocknumber} - -行があるデータブロックのシーケンス番号を返します。 - -## rowNumberInBlock {#function-rownumberinblock} - -データブロック内の行の序数を返します。 異なるデータブロックは常に再計算されます。 - -## rowNumberInAllBlocks() {#rownumberinallblocks} - -データブロック内の行の序数を返します。 この機能のみを考慮した影響のデータブロックとなります。 - -## 隣人 {#neighbor} - -指定された列の現在の行の前または後に来る指定されたオフセットで行へのアクセスを提供するウィンドウ関数。 - -**構文** - -``` sql -neighbor(column, offset[, default_value]) -``` - -関数の結果は、影響を受けるデータブロックと、ブロック内のデータの順序によって異なります。 -ORDER BYを使用してサブクエリを作成し、サブクエリの外部から関数を呼び出すと、期待される結果を得ることができます。 - -**パラメータ** - -- `column` — A column name or scalar expression. -- `offset` — The number of rows forwards or backwards from the current row of `column`. [Int64](../../sql_reference/data_types/int_uint.md). -- `default_value` — Optional. The value to be returned if offset goes beyond the scope of the block. Type of data blocks affected. - -**戻り値** - -- の値 `column` で `offset` 現在の行からの距離 `offset` 値はブロック境界の外側ではありません。 -- のデフォルト値 `column` もし `offset` 値はブロック境界の外側です。 もし `default_value` 与えられ、それが使用されます。 - -型:影響を受けるデータブロックの種類または既定値の種類。 - -**例えば** - -クエリ: - -``` sql -SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; -``` - -結果: - -``` text -┌─number─┬─neighbor(number, 2)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 0 │ -│ 9 │ 0 │ -└────────┴─────────────────────┘ -``` - -クエリ: - -``` sql -SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; -``` - -結果: - -``` text -┌─number─┬─neighbor(number, 2, 999)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 999 │ -│ 9 │ 999 │ -└────────┴──────────────────────────┘ -``` - -この関数は、年間指標の値を計算するために使用できます: - -クエリ: - -``` sql -WITH toDate('2018-01-01') AS start_date -SELECT - toStartOfMonth(start_date + (number * 32)) AS month, - toInt32(month) % 100 AS money, - neighbor(money, -12) AS prev_year, - round(prev_year / money, 2) AS year_over_year -FROM numbers(16) -``` - -結果: - -``` text -┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ -│ 2018-01-01 │ 32 │ 0 │ 0 │ -│ 2018-02-01 │ 63 │ 0 │ 0 │ -│ 2018-03-01 │ 91 │ 0 │ 0 │ -│ 2018-04-01 │ 22 │ 0 │ 0 │ -│ 2018-05-01 │ 52 │ 0 │ 0 │ -│ 2018-06-01 │ 83 │ 0 │ 0 │ -│ 2018-07-01 │ 13 │ 0 │ 0 │ -│ 2018-08-01 │ 44 │ 0 │ 0 │ -│ 2018-09-01 │ 75 │ 0 │ 0 │ -│ 2018-10-01 │ 5 │ 0 │ 0 │ -│ 2018-11-01 │ 36 │ 0 │ 0 │ -│ 2018-12-01 │ 66 │ 0 │ 0 │ -│ 2019-01-01 │ 97 │ 32 │ 0.33 │ -│ 2019-02-01 │ 28 │ 63 │ 2.25 │ -│ 2019-03-01 │ 56 │ 91 │ 1.62 │ -│ 2019-04-01 │ 87 │ 22 │ 0.25 │ -└────────────┴───────┴───────────┴────────────────┘ -``` - -## ランニングダイファレンス(x) {#other_functions-runningdifference} - -Calculates the difference between successive row values ​​in the data block. -最初の行に対して0を返し、後続の各行に対して前の行との差を返します。 - -関数の結果は、影響を受けるデータブロックと、ブロック内のデータの順序によって異なります。 -ORDER BYを使用してサブクエリを作成し、サブクエリの外部から関数を呼び出すと、期待される結果を得ることができます。 - -例えば: - -``` sql -SELECT - EventID, - EventTime, - runningDifference(EventTime) AS delta -FROM -( - SELECT - EventID, - EventTime - FROM events - WHERE EventDate = '2016-11-24' - ORDER BY EventTime ASC - LIMIT 5 -) -``` - -``` text -┌─EventID─┬───────────EventTime─┬─delta─┐ -│ 1106 │ 2016-11-24 00:00:04 │ 0 │ -│ 1107 │ 2016-11-24 00:00:05 │ 1 │ -│ 1108 │ 2016-11-24 00:00:05 │ 0 │ -│ 1109 │ 2016-11-24 00:00:09 │ 4 │ -│ 1110 │ 2016-11-24 00:00:10 │ 1 │ -└─────────┴─────────────────────┴───────┘ -``` - -ご注意-ブロックサイズは結果に影響します。 それぞれの新しいブロックでは、 `runningDifference` 状態がリセットされます。 - -``` sql -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -┌─number─┬─diff─┐ -│ 65536 │ 0 │ -└────────┴──────┘ -``` - -``` sql -set max_block_size=100000 -- default value is 65536! - -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -``` - -## runningDifferenceStartingWithFirstvalue {#runningdifferencestartingwithfirstvalue} - -と同じ [runningDifference](./other_functions.md#other_functions-runningdifference)、差は、最初の行の値であり、最初の行の値を返し、後続の各行は、前の行からの差を返します。 - -## マクナムトストリング(num) {#macnumtostringnum} - -UInt64番号を受け取ります。 ビッグエンディアンのMACアドレスとして解釈します。 対応するMACアドレスをAA:BB:CC:DD:EE:FF形式で含む文字列を返します。 - -## MACStringToNum(s) {#macstringtonums} - -MACNumToStringの逆関数。 MACアドレスに無効な形式がある場合は、0を返します。 - -## MACStringToOUI(s) {#macstringtoouis} - -AA:BB:CC:DD:EE:FF形式のMACアドレスを受け付けます。 最初の三つのオクテットをUInt64の数値として返します。 MACアドレスに無効な形式がある場合は、0を返します。 - -## getSizeOfEnumType {#getsizeofenumtype} - -フィールドの数を返します [列挙型](../../sql_reference/data_types/enum.md). - -``` sql -getSizeOfEnumType(value) -``` - -**パラメータ:** - -- `value` — Value of type `Enum`. - -**戻り値** - -- を持つフィールドの数 `Enum` 入力値。 -- 型が型でない場合は、例外がスローされます `Enum`. - -**例えば** - -``` sql -SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## blockSerializedSize {#blockserializedsize} - -(圧縮を考慮せずに)ディスク上のサイズを返します。 - -``` sql -blockSerializedSize(value[, value[, ...]]) -``` - -**パラメータ:** - -- `value` — Any value. - -**戻り値** - -- 値のブロックのためにディスクに書き込まれるバイト数(圧縮なし)。 - -**例えば** - -``` sql -SELECT blockSerializedSize(maxState(1)) as x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## toColumnTypeName {#tocolumntypename} - -RAM内の列のデータ型を表すクラスの名前を返します。 - -``` sql -toColumnTypeName(value) -``` - -**パラメータ:** - -- `value` — Any type of value. - -**戻り値** - -- を表すために使用されるクラスの名前を持つ文字列 `value` RAMのデータ型。 - -**違いの例`toTypeName ' and ' toColumnTypeName`** - -``` sql -SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime │ -└─────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ Const(UInt32) │ -└───────────────────────────────────────────────────────────┘ -``` - -この例では、 `DateTime` データタイプはメモリに記憶として `Const(UInt32)`. - -## dumpColumnStructure {#dumpcolumnstructure} - -RAM内のデータ構造の詳細な説明を出力します - -``` sql -dumpColumnStructure(value) -``` - -**パラメータ:** - -- `value` — Any type of value. - -**戻り値** - -- を表すために使用される構造体を記述する文字列。 `value` RAMのデータ型。 - -**例えば** - -``` sql -SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) -``` - -``` text -┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime, Const(size = 1, UInt32(size = 1)) │ -└──────────────────────────────────────────────────────────────┘ -``` - -## defaultValueOfArgumentType {#defaultvalueofargumenttype} - -データ型の既定値を出力します。 - -ユーザーが設定したカスタム列の既定値は含まれません。 - -``` sql -defaultValueOfArgumentType(expression) -``` - -**パラメータ:** - -- `expression` — Arbitrary type of value or an expression that results in a value of an arbitrary type. - -**戻り値** - -- `0` 数字のために. -- 文字列の空の文字列。 -- `ᴺᵁᴸᴸ` のために [Nullable](../../sql_reference/data_types/nullable.md). - -**例えば** - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ -│ 0 │ -└─────────────────────────────────────────────┘ -``` - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ -│ ᴺᵁᴸᴸ │ -└───────────────────────────────────────────────────────┘ -``` - -## 複製 {#other-functions-replicate} - -単一の値を持つ配列を作成します。 - -内部実装のために使用される [arrayJoin](array_join.md#functions_arrayjoin). - -``` sql -SELECT replicate(x, arr); -``` - -**パラメータ:** - -- `arr` — Original array. ClickHouse creates a new array of the same length as the original and fills it with the value `x`. -- `x` — The value that the resulting array will be filled with. - -**戻り値** - -値で満たされた配列 `x`. - -タイプ: `Array`. - -**例えば** - -クエリ: - -``` sql -SELECT replicate(1, ['a', 'b', 'c']) -``` - -結果: - -``` text -┌─replicate(1, ['a', 'b', 'c'])─┐ -│ [1,1,1] │ -└───────────────────────────────┘ -``` - -## filesystemAvailable {#filesystemavailable} - -返金額の残存スペースのファイルシステムのファイルのデータベースはあります。 それは常に合計空き領域よりも小さいです ([filesystemFree](#filesystemfree) でもスペースはOS. - -**構文** - -``` sql -filesystemAvailable() -``` - -**戻り値** - -- バイト単位で使用可能な残りのスペースの量。 - -タイプ: [UInt64](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; -``` - -結果: - -``` text -┌─Available space─┬─Type───┐ -│ 30.75 GiB │ UInt64 │ -└─────────────────┴────────┘ -``` - -## filesystemFree {#filesystemfree} - -データベースのファイルがあるファイルシステム上の空き領域の合計を返します。 また見なさい `filesystemAvailable` - -**構文** - -``` sql -filesystemFree() -``` - -**戻り値** - -- バイト単位の空き領域の量。 - -タイプ: [UInt64](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; -``` - -結果: - -``` text -┌─Free space─┬─Type───┐ -│ 32.39 GiB │ UInt64 │ -└────────────┴────────┘ -``` - -## filesystemCapacity {#filesystemcapacity} - -ファイルシステムの容量をバイト単位で返します。 評価のために、 [パス](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) データディレク - -**構文** - -``` sql -filesystemCapacity() -``` - -**戻り値** - -- ファイルシステムの容量情報(バイト単位)。 - -タイプ: [UInt64](../../sql_reference/data_types/int_uint.md). - -**例えば** - -クエリ: - -``` sql -SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" -``` - -結果: - -``` text -┌─Capacity──┬─Type───┐ -│ 39.32 GiB │ UInt64 │ -└───────────┴────────┘ -``` - -## finalizeAggregation {#function-finalizeaggregation} - -集約関数の状態を取ります。 集計結果を返します(ファイナライズされた状態)。 - -## runningAccumulate {#function-runningaccumulate} - -集約関数の状態を取り、値を持つ列を返します,ブロックラインのセットのためにこれらの状態の蓄積の結果であります,最初から現在の行へ.これ -たとえば、集計関数の状態(例:runningaccumulate(uniqstate(userid)))を取り、ブロックの各行について、前のすべての行と現在の行の状態をマージしたときの集計関数の結果を返しま -したがって、関数の結果は、ブロックへのデータの分割とブロック内のデータの順序に依存します。 - -## joinGet {#joinget} - -この関数を使用すると、テーブルからのデータと同じ方法でデータを抽出できます [辞書](../../sql_reference/dictionaries/index.md). - -データの取得 [参加](../../engines/table_engines/special/join.md#creating-a-table) 指定された結合キーを使用するテーブル。 - -サポートされているのは、 `ENGINE = Join(ANY, LEFT, )` 声明。 - -**構文** - -``` sql -joinGet(join_storage_table_name, `value_column`, join_keys) -``` - -**パラメータ** - -- `join_storage_table_name` — an [識別子](../syntax.md#syntax-identifiers) 検索が実行される場所を示します。 識別子は既定のデータベースで検索されます(パラメータを参照 `default_database` の設定ファイル)。 デフォル `USE db_name` またはを指定しデータベースのテーブルのセパレータ `db_name.db_table`、例を参照してください。 -- `value_column` — name of the column of the table that contains required data. -- `join_keys` — list of keys. - -**戻り値** - -キーのリストに対応する値のリストを返します。 - -ソーステーブルに特定のものが存在しない場合 `0` または `null` に基づいて返されます [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls) 設定。 - -詳細について `join_use_nulls` で [結合操作](../../engines/table_engines/special/join.md). - -**例えば** - -入力テーブル: - -``` sql -CREATE DATABASE db_test -CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 -INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) -``` - -``` text -┌─id─┬─val─┐ -│ 4 │ 13 │ -│ 2 │ 12 │ -│ 1 │ 11 │ -└────┴─────┘ -``` - -クエリ: - -``` sql -SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 -``` - -結果: - -``` text -┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ -│ 0 │ -│ 11 │ -│ 12 │ -│ 0 │ -└──────────────────────────────────────────────────┘ -``` - -## modelEvaluate(model\_name, …) {#function-modelevaluate} - -外部モデルを評価します。 -モデル名とモデル引数を受け取ります。 float64を返します。 - -## throwIf(x\[,custom\_message\]) {#throwifx-custom-message} - -引数がゼロ以外の場合は例外をスローします。 -custom\_message-オプションのパラメータです。 - -``` sql -SELECT throwIf(number = 3, 'Too many') FROM numbers(10); -``` - -``` text -↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): -Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. -``` - -## id {#identity} - -引数として使用されたのと同じ値を返します。 デバッグに使用され、試験が可能でャックのクエリーの性能を満たします。 がクエリーの分析のために利用できる可能性指標分析装置が外部サンプリング方式な見てみよう `identity` 機能。 - -**構文** - -``` sql -identity(x) -``` - -**例えば** - -クエリ: - -``` sql -SELECT identity(42) -``` - -結果: - -``` text -┌─identity(42)─┐ -│ 42 │ -└──────────────┘ -``` - -## randomprintableasii {#randomascii} - -のランダムなセットを持つ文字列を生成します [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 印刷可能な文字。 - -**構文** - -``` sql -randomPrintableASCII(length) -``` - -**パラメータ** - -- `length` — Resulting string length. Positive integer. - - If you pass `length < 0`, behavior of the function is undefined. - -**戻り値** - -- のランダムなセットを持つ文字列 [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 印刷可能な文字。 - -タイプ: [文字列](../../sql_reference/data_types/string.md) - -**例えば** - -``` sql -SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 -``` - -``` text -┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ -│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ -│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ -│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ -└────────┴────────────────────────────────┴──────────────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/ja/sql_reference/functions/random_functions.md b/docs/ja/sql_reference/functions/random_functions.md deleted file mode 100644 index d356558481d..00000000000 --- a/docs/ja/sql_reference/functions/random_functions.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 51 -toc_title: "\u64EC\u4F3C\u4E71\u6570\u306E\u751F\u6210" ---- - -# 擬似乱数を生成するための関数 {#functions-for-generating-pseudo-random-numbers} - -擬似乱数の非暗号生成器が使用される。 - -全ての機能を受け入れゼロの引数または一つの引数。 -引数が渡された場合は、任意の型にすることができ、その値は何にも使用されません。 -この引数の唯一の目的は、同じ関数の二つの異なるインスタンスが異なる乱数を持つ異なる列を返すように、共通の部分式の除去を防ぐことです。 - -## ランド {#rand} - -すべてのuint32型の数値に均等に分布する、擬似ランダムなuint32数値を返します。 -線形合同発生器を使用します。 - -## rand64 {#rand64} - -すべてのuint64型の数値に均等に分布する、擬似ランダムなuint64数値を返します。 -線形合同発生器を使用します。 - -## randconstantname {#randconstant} - -値は、異なるブロックのためのものである、擬似ランダムuint32番号を返します。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/ja/sql_reference/functions/rounding_functions.md b/docs/ja/sql_reference/functions/rounding_functions.md deleted file mode 100644 index ab0bc719d5a..00000000000 --- a/docs/ja/sql_reference/functions/rounding_functions.md +++ /dev/null @@ -1,190 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: "\u4E38\u3081" ---- - -# 丸め関数 {#rounding-functions} - -## 床(x\[,N\]) {#floorx-n} - -次の値以下の最大ラウンド数を返します `x`. ラウンド数は1/10Nの倍数、または1/10Nが正確でない場合は適切なデータ型の最も近い数です。 -‘N’ 整数定数、オプションのパラメータです。 デフォルトではゼロで、整数に丸めることを意味します。 -‘N’ 負の可能性があります。 - -例: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` - -`x` 任意の数値型です。 結果は同じタイプの数です。 -整数引数の場合、負の値で丸めるのが理にかなっています `N` 値(非負の場合 `N`、関数は何もしません)。 -丸めによってオーバーフロー(たとえば、floor(-128,-1))が発生した場合は、実装固有の結果が返されます。 - -## ceil(x\[,N\]),ceiling(x\[,N\]) {#ceilx-n-ceilingx-n} - -次の値以上の最小の丸め数を返します `x`. 他のすべての方法では、それはと同じです `floor` 関数(上記参照)。 - -## trunc(x\[,N\]),truncate(x\[,N\]) {#truncx-n-truncatex-n} - -絶対値が以下の最大絶対値を持つラウンド数を返します `x`‘s. In every other way, it is the same as the ’floor’ 関数(上記参照)。 - -## ラウンド(x\[,N\]) {#rounding_functions-round} - -指定した小数点以下の桁数に値を丸めます。 - -この関数は、指定された順序の最も近い番号を返します。 与えられた数が周囲の数と等しい距離を持つ場合、関数は浮動小数点数型に対してバンカーの丸めを使用し、他の数値型に対してゼロから丸めます。 - -``` sql -round(expression [, decimal_places]) -``` - -**パラメータ:** - -- `expression` — A number to be rounded. Can be any [式](../syntax.md#syntax-expressions) 数値を返す [データ型](../../sql_reference/data_types/index.md#data_types). -- `decimal-places` — An integer value. - - もし `decimal-places > 0` 次に、この関数は値を小数点の右側に丸めます。 - - もし `decimal-places < 0` 次に、この関数は値を小数点の左側に丸めます。 - - もし `decimal-places = 0` 次に、この関数は値を整数に丸めます。 この場合、引数は省略できます。 - -**戻り値:** - -入力番号と同じタイプの丸められた数。 - -### 例 {#examples} - -**使用例** - -``` sql -SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 -``` - -``` text -┌───x─┬─round(divide(number, 2))─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -└─────┴──────────────────────────┘ -``` - -**丸めの例** - -最も近い数値に丸めます。 - -``` text -round(3.2, 0) = 3 -round(4.1267, 2) = 4.13 -round(22,-1) = 20 -round(467,-2) = 500 -round(-467,-2) = -500 -``` - -銀行の丸め。 - -``` text -round(3.5) = 4 -round(4.5) = 4 -round(3.55, 1) = 3.6 -round(3.65, 1) = 3.6 -``` - -**また見なさい** - -- [ラウンドバンカー](#roundbankers) - -## ラウンドバンカー {#roundbankers} - -数値を指定した小数点以下の桁数に丸めます。 - -- 丸め番号が二つの数字の中間にある場合、関数はバンカーの丸めを使用します。 - - Banker's rounding is a method of rounding fractional numbers. When the rounding number is halfway between two numbers, it's rounded to the nearest even digit at the specified decimal position. For example: 3.5 rounds up to 4, 2.5 rounds down to 2. - - It's the default rounding method for floating point numbers defined in [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). The [round](#rounding_functions-round) function performs the same rounding for floating point numbers. The `roundBankers` function also rounds integers the same way, for example, `roundBankers(45, -1) = 40`. - -- それ以外の場合、関数は数値を最も近い整数に丸めます。 - -バンカーの丸めを使用すると、丸め数値がこれらの数値の加算または減算の結果に与える影響を減らすことができます。 - -たとえば、異なる丸めの合計1.5、2.5、3.5、4.5: - -- 丸めなし: 1.5 + 2.5 + 3.5 + 4.5 = 12. -- 銀行の丸め: 2 + 2 + 4 + 4 = 12. -- 最も近い整数への丸め: 2 + 3 + 4 + 5 = 14. - -**構文** - -``` sql -roundBankers(expression [, decimal_places]) -``` - -**パラメータ** - -- `expression` — A number to be rounded. Can be any [式](../syntax.md#syntax-expressions) 数値を返す [データ型](../../sql_reference/data_types/index.md#data_types). -- `decimal-places` — Decimal places. An integer number. - - `decimal-places > 0` — The function rounds the number to the given position right of the decimal point. Example: `roundBankers(3.55, 1) = 3.6`. - - `decimal-places < 0` — The function rounds the number to the given position left of the decimal point. Example: `roundBankers(24.55, -1) = 20`. - - `decimal-places = 0` — The function rounds the number to an integer. In this case the argument can be omitted. Example: `roundBankers(2.5) = 2`. - -**戻り値** - -バンカーの丸めメソッドによって丸められた値。 - -### 例 {#examples-1} - -**使用例** - -クエリ: - -``` sql - SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 -``` - -結果: - -``` text -┌───x─┬─b─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -│ 1.5 │ 2 │ -│ 2 │ 2 │ -│ 2.5 │ 2 │ -│ 3 │ 3 │ -│ 3.5 │ 4 │ -│ 4 │ 4 │ -│ 4.5 │ 4 │ -└─────┴───┘ -``` - -**銀行の丸めの例** - -``` text -roundBankers(0.4) = 0 -roundBankers(-3.5) = -4 -roundBankers(4.5) = 4 -roundBankers(3.55, 1) = 3.6 -roundBankers(3.65, 1) = 3.6 -roundBankers(10.35, 1) = 10.4 -roundBankers(10.755, 2) = 11,76 -``` - -**また見なさい** - -- [ラウンド](#rounding_functions-round) - -## roundToExp2(num) {#roundtoexp2num} - -数値を受け取ります。 数値が小さい場合は0を返します。 それ以外の場合は、数値を最も近い(非負の全体)程度に丸めます。 - -## ラウンドデュレーション(num) {#rounddurationnum} - -数値を受け取ります。 数値が小さい場合は0を返します。 それ以外の場合は、数値をセットから数値に切り下げます: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. この機能はyandexに固有です。metricaとセッションの長さに関するレポートを実装するために使用。 - -## roundAge(num) {#roundagenum} - -数値を受け取ります。 数値が18未満の場合、0を返します。 それ以外の場合は、数値をセットから数値に切り下げます: 18, 25, 35, 45, 55. この機能はyandexに固有です。metricaとユーザーの年齢に関するレポートを実装するために使用。 - -## ラウンドダウン(num,arr) {#rounddownnum-arr} - -数値を受け取り、指定した配列内の要素に切り捨てます。 値が下限より小さい場合は、下限が返されます。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/ja/sql_reference/functions/splitting_merging_functions.md b/docs/ja/sql_reference/functions/splitting_merging_functions.md deleted file mode 100644 index 7e21f5a97f3..00000000000 --- a/docs/ja/sql_reference/functions/splitting_merging_functions.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 47 -toc_title: "\u6587\u5B57\u5217\u3068\u914D\u5217\u306E\u5206\u5272\u3068\u30DE\u30FC\ - \u30B8" ---- - -# 文字列と配列の分割とマージのための関数 {#functions-for-splitting-and-merging-strings-and-arrays} - -## splitByChar(セパレータ,s) {#splitbycharseparator-s} - -文字列を、指定した文字で区切った部分文字列に分割します。 定数文字列を使用します `separator` その正確に一つの文字からなる。 -選択した部分文字列の配列を返します。 空の部分文字列は、文字列の先頭または末尾にセパレータがある場合、または複数の連続するセパレータがある場合に選択できます。 - -**構文** - -``` sql -splitByChar(, ) -``` - -**パラメータ** - -- `separator` — The separator which should contain exactly one character. [文字列](../../sql_reference/data_types/string.md). -- `s` — The string to split. [文字列](../../sql_reference/data_types/string.md). - -**戻り値(s)** - -選択した部分文字列の配列を返します。 空の部分文字列は、次の場合に選択できます: - -- 区切り記号は、文字列の先頭または末尾に表示されます; -- 複数の連続した区切り文字があります; -- 元の文字列 `s` 空です。 - -タイプ: [配列](../../sql_reference/data_types/array.md) の [文字列](../../sql_reference/data_types/string.md). - -**例えば** - -``` sql -SELECT splitByChar(',', '1,2,3,abcde') -``` - -``` text -┌─splitByChar(',', '1,2,3,abcde')─┐ -│ ['1','2','3','abcde'] │ -└─────────────────────────────────┘ -``` - -## splitByString(separator,s) {#splitbystringseparator-s} - -文字列を文字列で区切られた部分文字列に分割します。 定数文字列を使用します `separator` 区切り文字として複数の文字が使用されます。 文字列の場合 `separator` 空である場合は、文字列を分割します `s` 単一の文字の配列に変換します。 - -**構文** - -``` sql -splitByString(, ) -``` - -**パラメータ** - -- `separator` — The separator. [文字列](../../sql_reference/data_types/string.md). -- `s` — The string to split. [文字列](../../sql_reference/data_types/string.md). - -**戻り値(s)** - -選択した部分文字列の配列を返します。 空の部分文字列は、次の場合に選択できます: - -タイプ: [配列](../../sql_reference/data_types/array.md) の [文字列](../../sql_reference/data_types/string.md). - -- 空でない区切り文字は、文字列の先頭または末尾に作成されます; -- 複数の連続する空でない区切り記号があります; -- 元の文字列 `s` 区切り記号が空でない間は空です。 - -**例えば** - -``` sql -SELECT splitByString(', ', '1, 2 3, 4,5, abcde') -``` - -``` text -┌─splitByString(', ', '1, 2 3, 4,5, abcde')─┐ -│ ['1','2 3','4,5','abcde'] │ -└───────────────────────────────────────────┘ -``` - -``` sql -SELECT splitByString('', 'abcde') -``` - -``` text -┌─splitByString('', 'abcde')─┐ -│ ['a','b','c','d','e'] │ -└────────────────────────────┘ -``` - -## arrayStringConcat(arr\[,separator\]) {#arraystringconcatarr-separator} - -配列にリストされている文字列を区切り文字と連結します。デフォルトでは空の文字列に設定されています。 -文字列を返します。 - -## alphaTokens(s) {#alphatokenss} - -範囲a-zおよびa-zから連続するバイトの部分文字列を選択します。 - -**例えば** - -``` sql -SELECT alphaTokens('abca1abc') -``` - -``` text -┌─alphaTokens('abca1abc')─┐ -│ ['abca','abc'] │ -└─────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/ja/sql_reference/functions/string_functions.md b/docs/ja/sql_reference/functions/string_functions.md deleted file mode 100644 index 1e7948edf89..00000000000 --- a/docs/ja/sql_reference/functions/string_functions.md +++ /dev/null @@ -1,489 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "\u6587\u5B57\u5217\u306E\u64CD\u4F5C" ---- - -# 文字列を扱うための関数 {#functions-for-working-with-strings} - -## 空 {#empty} - -空の文字列の場合は1、空でない文字列の場合は0を返します。 -結果の型はuint8です。 -文字列が空白またはnullバイトであっても、少なくとも一つのバイトが含まれている場合、文字列は空ではないと見なされます。 -この関数は配列に対しても機能します。 - -## notEmpty {#notempty} - -空の文字列の場合は0、空でない文字列の場合は1を返します。 -結果の型はuint8です。 -この関数は配列に対しても機能します。 - -## 長さ {#length} - -文字列の長さをバイトで返します(コード-ポイントではなく、文字ではありません)。 -結果の型はuint64です。 -この関数は配列に対しても機能します。 - -## lengthUTF8 {#lengthutf8} - -文字列にutf-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、unicodeコードポイント(文字ではない)の文字列の長さを この仮定が満たされない場合、いくつかの結果が返されます(例外はスローされません)。 -結果の型はuint64です。 - -## char\_length,CHAR\_LENGTH {#char-length} - -文字列にutf-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、unicodeコードポイント(文字ではない)の文字列の長さを この仮定が満たされない場合、いくつかの結果が返されます(例外はスローされません)。 -結果の型はuint64です。 - -## character\_length,CHARACTER\_LENGTH {#character-length} - -文字列にutf-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、unicodeコードポイント(文字ではない)の文字列の長さを この仮定が満たされない場合、いくつかの結果が返されます(例外はスローされません)。 -結果の型はuint64です。 - -## lower,lcase {#lower} - -文字列内のasciiラテン文字記号を小文字に変換します。 - -## アッパー,ucase {#upper} - -文字列内のasciiラテン文字記号を大文字に変換します。 - -## lowerUTF8 {#lowerutf8} - -文字列にutf-8でエンコードされたテキストを構成するバイトのセットが含まれていると仮定して、文字列を小文字に変換します。 -それは言語を検出しません。 そのためにトルコに結果が正確に正しい。 -コード-ポイントの大文字と小文字でutf-8バイト-シーケンスの長さが異なる場合、このコード-ポイントでは結果が正しくない可能性があります。 -文字列にutf-8でないバイトのセットが含まれている場合、その動作は未定義です。 - -## upperUTF8 {#upperutf8} - -文字列にutf-8でエンコードされたテキストを構成するバイトのセットが含まれている場合、文字列を大文字に変換します。 -それは言語を検出しません。 そのためにトルコに結果が正確に正しい。 -コード-ポイントの大文字と小文字でutf-8バイト-シーケンスの長さが異なる場合、このコード-ポイントでは結果が正しくない可能性があります。 -文字列にutf-8でないバイトのセットが含まれている場合、その動作は未定義です。 - -## isValidUTF8 {#isvalidutf8} - -バイトのセットが有効なutf-8エンコードの場合は1を返し、それ以外の場合は0を返します。 - -## toValidUTF8 {#tovalidutf8} - -無効なutf-8文字を `�` (U+FFFD)文字。 すべての行で実行されている無効な文字は、置換文字に折りたたまれています。 - -``` sql -toValidUTF8( input_string ) -``` - -パラメータ: - -- input\_string — Any set of bytes represented as the [文字列](../../sql_reference/data_types/string.md) データ型オブジェクト。 - -戻り値:有効なutf-8文字列。 - -**例えば** - -``` sql -SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') -``` - -``` text -┌─toValidUTF8('a����b')─┐ -│ a�b │ -└───────────────────────┘ -``` - -## 繰り返す {#repeat} - -指定した回数だけ文字列を繰り返し、レプリケートされた値を単一の文字列として連結します。 - -**構文** - -``` sql -repeat(s, n) -``` - -**パラメータ** - -- `s` — The string to repeat. [文字列](../../sql_reference/data_types/string.md). -- `n` — The number of times to repeat the string. [UInt](../../sql_reference/data_types/int_uint.md). - -**戻り値** - -文字列を含む単一の文字列 `s` 繰り返す `n` 回。 もし `n` \<1、関数は、空の文字列を返します。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT repeat('abc', 10) -``` - -結果: - -``` text -┌─repeat('abc', 10)──────────────┐ -│ abcabcabcabcabcabcabcabcabcabc │ -└────────────────────────────────┘ -``` - -## 反転 {#reverse} - -文字列を逆にします(バイトのシーケンスとして)。 - -## reverseUTF8 {#reverseutf8} - -文字列にutf-8テキストを表すバイトのセットが含まれていると仮定して、unicodeコードポイントのシーケンスを逆にします。 それ以外の場合は、何か他のことをします(例外はスローされません)。 - -## format(pattern, s0, s1, …) {#format} - -引数にリストされている文字列で定数パターンを書式設定する。 `pattern` 単純なPython形式のパターンです。 書式文字列に含まれる “replacement fields” 中括弧で囲まれています `{}`. 中括弧に含まれていないものは、リテラルテキストと見なされ、出力には変更されません。 リテラルテキストに中かっこ文字を含める必要がある場合は、倍にすることでエスケープできます: `{{ '{{' }}` と `{{ '}}' }}`. フィールド名は数字(ゼロから始まる)または空(それらは結果番号として扱われます)。 - -``` sql -SELECT format('{1} {0} {1}', 'World', 'Hello') -``` - -``` text -┌─format('{1} {0} {1}', 'World', 'Hello')─┐ -│ Hello World Hello │ -└─────────────────────────────────────────┘ -``` - -``` sql -SELECT format('{} {}', 'Hello', 'World') -``` - -``` text -┌─format('{} {}', 'Hello', 'World')─┐ -│ Hello World │ -└───────────────────────────────────┘ -``` - -## concat {#concat} - -引数にリストされている文字列を区切り文字なしで連結します。 - -**構文** - -``` sql -concat(s1, s2, ...) -``` - -**パラメータ** - -String型またはFixedString型の値。 - -**戻り値** - -引数を連結した結果の文字列を返します。 - -引数の値のいずれかがある場合 `NULL`, `concat` を返します `NULL`. - -**例えば** - -クエリ: - -``` sql -SELECT concat('Hello, ', 'World!') -``` - -結果: - -``` text -┌─concat('Hello, ', 'World!')─┐ -│ Hello, World! │ -└─────────────────────────────┘ -``` - -## ツづツつソツづォツづアツ、ツ債。 {#concatassumeinjective} - -と同じ [concat](#concat) の差であることを確認する必要があり `concat(s1, s2, ...) → sn` injectiveは、GROUP BYの最適化に使用されます。 - -関数の名前は次のとおりです “injective” 引数の異なる値に対して常に異なる結果を返す場合。 言い換えれば異なる引数のない利回り同一の結果です。 - -**構文** - -``` sql -concatAssumeInjective(s1, s2, ...) -``` - -**パラメータ** - -String型またはFixedString型の値。 - -**戻り値** - -引数を連結した結果の文字列を返します。 - -引数の値のいずれかがある場合 `NULL`, `concatAssumeInjective` を返します `NULL`. - -**例えば** - -入力テーブル: - -``` sql -CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog; -INSERT INTO key_val VALUES ('Hello, ','World',1), ('Hello, ','World',2), ('Hello, ','World!',3), ('Hello',', World!',2); -SELECT * from key_val; -``` - -``` text -┌─key1────┬─key2─────┬─value─┐ -│ Hello, │ World │ 1 │ -│ Hello, │ World │ 2 │ -│ Hello, │ World! │ 3 │ -│ Hello │ , World! │ 2 │ -└─────────┴──────────┴───────┘ -``` - -クエリ: - -``` sql -SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY concatAssumeInjective(key1, key2) -``` - -結果: - -``` text -┌─concat(key1, key2)─┬─sum(value)─┐ -│ Hello, World! │ 3 │ -│ Hello, World! │ 2 │ -│ Hello, World │ 3 │ -└────────────────────┴────────────┘ -``` - -## サブストリング(s,オフセット,長さ)、中(s,オフセット,長さ)、サブストリング(s,オフセット,長さ) {#substring} - -からのバイトで始まる部分文字列を返します。 ‘offset’ あるインデックス ‘length’ バイト長。 文字の索引付けは、(標準SQLのように)文字から始まります。 その ‘offset’ と ‘length’ 引数は定数である必要があります。 - -## substringUTF8(s,オフセット,長さ) {#substringutf8} - -同じように ‘substring’ しかし、Unicodeコードポイントの場合。 作品は、この文字列が含まれるセットを表すバイトのUTF-8で符号化されます。 この仮定が満たされない場合、いくつかの結果が返されます(例外はスローされません)。 - -## appendTrailingCharIfAbsent(s,c) {#appendtrailingcharifabsent} - -この ‘s’ 文字列は空ではなく、空の文字列を含みません。 ‘c’ 最後の文字は、 ‘c’ 最後に文字。 - -## convertCharset(s,from,to) {#convertcharset} - -文字列を返します ‘s’ それはエンコーディングから変換された ‘from’ でのエンコーディングに ‘to’. - -## base64Encode(s) {#base64encode} - -エンコード ‘s’ base64への文字列 - -## base64Decode(s) {#base64decode} - -Base64エンコードされた文字列のデコード ‘s’ 元の文字列に。 失敗した場合には例外を発生させます。 - -## tryBase64Decode(s) {#trybase64decode} - -Base64Decodeに似ていますが、エラーの場合は空の文字列が返されます。 - -## endsWith(s,suffix) {#endswith} - -指定された接尾辞で終了するかどうかを返します。 文字列が指定された接尾辞で終わる場合は1を返し、それ以外の場合は0を返します。 - -## startsWith(str,プレフィックス) {#startswith} - -1を返しますか否かの文字列の開始を、指定された接頭辞、そうでない場合は0を返します。 - -``` sql -SELECT startsWith('Spider-Man', 'Spi'); -``` - -**戻り値** - -- 1、文字列が指定された接頭辞で始まる場合。 -- 文字列が指定された接頭辞で始まらない場合は0。 - -**例えば** - -クエリ: - -``` sql -SELECT startsWith('Hello, world!', 'He'); -``` - -結果: - -``` text -┌─startsWith('Hello, world!', 'He')─┐ -│ 1 │ -└───────────────────────────────────┘ -``` - -## トリム {#trim} - -文字列の先頭または末尾から指定されたすべての文字を削除します。 -デフォルトでは、文字列の両端から共通の空白(ascii文字32)が連続して出現するすべてを削除します。 - -**構文** - -``` sql -trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) -``` - -**パラメータ** - -- `trim_character` — specified characters for trim. [文字列](../../sql_reference/data_types/string.md). -- `input_string` — string for trim. [文字列](../../sql_reference/data_types/string.md). - -**戻り値** - -先頭および(または)末尾に指定された文字を含まない文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT trim(BOTH ' ()' FROM '( Hello, world! )') -``` - -結果: - -``` text -┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ -│ Hello, world! │ -└───────────────────────────────────────────────┘ -``` - -## trimLeft {#trimleft} - -文字列の先頭から、共通の空白文字(ascii文字32)のすべての連続した出現を削除します。 他の種類の空白文字(タブ、改行なしなど)は削除されません。). - -**構文** - -``` sql -trimLeft(input_string) -``` - -エイリアス: `ltrim(input_string)`. - -**パラメータ** - -- `input_string` — string to trim. [文字列](../../sql_reference/data_types/string.md). - -**戻り値** - -共通の空白をリードしない文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT trimLeft(' Hello, world! ') -``` - -結果: - -``` text -┌─trimLeft(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## trimRight {#trimright} - -文字列の末尾から共通の空白文字(ascii文字32)のすべての連続した出現を削除します。 他の種類の空白文字(タブ、改行なしなど)は削除されません。). - -**構文** - -``` sql -trimRight(input_string) -``` - -エイリアス: `rtrim(input_string)`. - -**パラメータ** - -- `input_string` — string to trim. [文字列](../../sql_reference/data_types/string.md). - -**戻り値** - -共通の空白を末尾に付けない文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT trimRight(' Hello, world! ') -``` - -結果: - -``` text -┌─trimRight(' Hello, world! ')─┐ -│ Hello, world! │ -└──────────────────────────────────────┘ -``` - -## トリンボスcity in california usa {#trimboth} - -文字列の両端から共通の空白文字(ascii文字32)が連続して出現するすべてを削除します。 他の種類の空白文字(タブ、改行なしなど)は削除されません。). - -**構文** - -``` sql -trimBoth(input_string) -``` - -エイリアス: `trim(input_string)`. - -**パラメータ** - -- `input_string` — string to trim. [文字列](../../sql_reference/data_types/string.md). - -**戻り値** - -先頭と末尾の共通の空白を含まない文字列。 - -タイプ: `String`. - -**例えば** - -クエリ: - -``` sql -SELECT trimBoth(' Hello, world! ') -``` - -結果: - -``` text -┌─trimBoth(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## CRC32(s) {#crc32} - -CRC-32-IEEE802.3多項式と初期値を使用して、文字列のCRC32チェックサムを返します `0xffffffff` (zlibの実装)。 - -結果の型はuint32です。 - -## CRC32IEEE(s) {#crc32ieee} - -CRC-32-IEEE802.3多項式を使用して、文字列のCRC32チェックサムを返します。 - -結果の型はuint32です。 - -## CRC64(s) {#crc64} - -CRC-64-ECMA多項式を使用して、文字列のCRC64チェックサムを返します。 - -結果の型はuint64です。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/ja/sql_reference/functions/string_replace_functions.md b/docs/ja/sql_reference/functions/string_replace_functions.md deleted file mode 100644 index 27fe01a9f47..00000000000 --- a/docs/ja/sql_reference/functions/string_replace_functions.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: "\u6587\u5B57\u5217\u3067\u7F6E\u63DB\u3059\u308B\u5834\u5408" ---- - -# 文字列の検索と置換のための関数 {#functions-for-searching-and-replacing-in-strings} - -## replaceOne(干し草の山,パターン,交換) {#replaceonehaystack-pattern-replacement} - -が存在する場合は、その最初のオカレンスを置き換えます。 ‘pattern’ の部分文字列 ‘haystack’ と ‘replacement’ サブストリング。 -以後, ‘pattern’ と ‘replacement’ 定数である必要があります。 - -## replaceAll(干し草の山、パターン、交換)、交換(干し草の山、パターン、交換) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} - -すべての出現を置き換えます。 ‘pattern’ の部分文字列 ‘haystack’ と ‘replacement’ サブストリング。 - -## replaceRegexpOne(haystack,pattern,replacement) {#replaceregexponehaystack-pattern-replacement} - -を使用して交換 ‘pattern’ 正規表現。 Re2正規表現。 -最初のオカレンスのみを置き換えます(存在する場合)。 -パターンは次のように指定できます ‘replacement’. このパタ `\0-\9`. -置換 `\0` 正規表現全体を含みます。 置換 `\1-\9` サブパターンに対応しますnumbers.To を使用 `\` テンプレート内の文字をエスケープします `\`. -また、文字列リテラルには余分なエスケープが必要です。 - -例1. 日付をアメリカ形式に変換する: - -``` sql -SELECT DISTINCT - EventDate, - replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res -FROM test.hits -LIMIT 7 -FORMAT TabSeparated -``` - -``` text -2014-03-17 03/17/2014 -2014-03-18 03/18/2014 -2014-03-19 03/19/2014 -2014-03-20 03/20/2014 -2014-03-21 03/21/2014 -2014-03-22 03/22/2014 -2014-03-23 03/23/2014 -``` - -例2. 文字列を十回コピーする: - -``` sql -SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res -``` - -``` text -┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## replaceRegexpAll(干し草の山,パターン,置換) {#replaceregexpallhaystack-pattern-replacement} - -これは同じことをしますが、すべての出現を置き換えます。 例えば: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res -``` - -``` text -┌─res────────────────────────┐ -│ HHeelllloo,, WWoorrlldd!! │ -└────────────────────────────┘ -``` - -例外として、正規表現が空の部分文字列で処理された場合、置換は複数回行われません。 -例えば: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res -``` - -``` text -┌─res─────────────────┐ -│ here: Hello, World! │ -└─────────────────────┘ -``` - -## regexpQuoteMeta(s) {#regexpquotemetas} - -この関数は、文字列内のいくつかの定義済み文字の前に円記号を追加します。 -定義済み文字: ‘0’, ‘\\’, ‘\|’, ‘(’, ‘)’, ‘^’, ‘$’, ‘.’, ‘\[’, '\]', ‘?’, '\*‘,’+‘,’{‘,’:‘,’-'. -この実装はre2::re2::quotemetaとは若干異なります。 ゼロバイトを\\0の代わりに\\00としてエスケープし、必要な文字だけをエスケープします。 -詳細については、リンク: [RE2](https://github.com/google/re2/blob/master/re2/re2.cc#L473) - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/ja/sql_reference/functions/string_search_functions.md b/docs/ja/sql_reference/functions/string_search_functions.md deleted file mode 100644 index 3487aefdeb5..00000000000 --- a/docs/ja/sql_reference/functions/string_search_functions.md +++ /dev/null @@ -1,379 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: "\u6587\u5B57\u5217\u3092\u691C\u7D22\u3059\u308B\u5834\u5408" ---- - -# 文字列を検索するための関数 {#functions-for-searching-strings} - -これらのすべての機能では、既定で検索では大文字と小文字が区別されます。 あるvariantのための大文字と小文字を区別しません。 - -## 位置(干し草の山、針)、位置(干し草の山、針) {#position} - -1から始まる、文字列内の見つかった部分文字列の位置(バイト)を返します。 - -作品は、この文字列が含まれるセットを表すバイトの単一のバイトの符号化されます。 この仮定が満たされておらず、単一のバイトを使用して文字を表現できない場合、関数は例外をスローせず、予期しない結果を返します。 文字が二つのバイトを使用して表現できる場合は、二つのバイトなどを使用します。 - -大文字と小文字を区別しない検索では、次の関数を使用します [positionCaseInsensitive](#positioncaseinsensitive). - -**構文** - -``` sql -position(haystack, needle) -``` - -エイリアス: `locate(haystack, needle)`. - -**パラメータ** - -- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). - -**戻り値** - -- 部分文字列が見つかった場合、バイト単位で開始位置(1から数えます)。 -- 0、部分文字列が見つからなかった場合。 - -タイプ: `Integer`. - -**例** - -フレーズ “Hello, world!” を含むの設定を表すバイトの単一のバイトの符号化されます。 この関数は、期待される結果を返します: - -クエリ: - -``` sql -SELECT position('Hello, world!', '!') -``` - -結果: - -``` text -┌─position('Hello, world!', '!')─┐ -│ 13 │ -└────────────────────────────────┘ -``` - -ロシア語の同じ句には、単一のバイトを使用して表現できない文字が含まれています。 この関数は、予期しない結果を返します [positionUTF8](#positionutf8) マルチバイトエンコードテキストの機能): - -クエリ: - -``` sql -SELECT position('Привет, мир!', '!') -``` - -結果: - -``` text -┌─position('Привет, мир!', '!')─┐ -│ 21 │ -└───────────────────────────────┘ -``` - -## positionCaseInsensitive {#positioncaseinsensitive} - -同じように [位置](#position) 1から始まる、文字列内の見つかった部分文字列の位置(バイト)を返します。 大文字小文字を区別しない検索には、この関数を使用します。 - -作品は、この文字列が含まれるセットを表すバイトの単一のバイトの符号化されます。 この仮定が満たされておらず、単一のバイトを使用して文字を表現できない場合、関数は例外をスローせず、予期しない結果を返します。 文字が二つのバイトを使用して表現できる場合は、二つのバイトなどを使用します。 - -**構文** - -``` sql -positionCaseInsensitive(haystack, needle) -``` - -**パラメータ** - -- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). - -**戻り値** - -- 部分文字列が見つかった場合、バイト単位で開始位置(1から数えます)。 -- 0、部分文字列が見つからなかった場合。 - -タイプ: `Integer`. - -**例えば** - -クエリ: - -``` sql -SELECT positionCaseInsensitive('Hello, world!', 'hello') -``` - -結果: - -``` text -┌─positionCaseInsensitive('Hello, world!', 'hello')─┐ -│ 1 │ -└───────────────────────────────────────────────────┘ -``` - -## positionUTF8 {#positionutf8} - -文字列内の見つかった部分文字列の位置(unicodeポイント単位)を、1から開始して返します。 - -作品は、この文字列が含まれるセットを表すバイトのutf-8で符号化されます。 この仮定が満たされない場合、関数は例外をスローせず、予期しない結果を返します。 文字が二つのunicodeポイントを使って表現できる場合は、二つのポイントを使います。 - -大文字と小文字を区別しない検索では、次の関数を使用します [位置caseinsensitiveutf8](#positioncaseinsensitiveutf8). - -**構文** - -``` sql -positionUTF8(haystack, needle) -``` - -**パラメータ** - -- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). - -**戻り値** - -- 部分文字列が見つかった場合、unicodeポイントの開始位置(1から数えます)。 -- 0、部分文字列が見つからなかった場合。 - -タイプ: `Integer`. - -**例** - -フレーズ “Hello, world!” ロシア語のUnicodeのポイントを表すシングルポイントで符号化されます。 この関数は、期待される結果を返します: - -クエリ: - -``` sql -SELECT positionUTF8('Привет, мир!', '!') -``` - -結果: - -``` text -┌─positionUTF8('Привет, мир!', '!')─┐ -│ 12 │ -└───────────────────────────────────┘ -``` - -フレーズ “Salut, étudiante!”、どこの文字 `é` 一つの点を使用して表すことができます (`U+00E9`)または二つのポイント (`U+0065U+0301` 関数は、いくつかの予想外の結果を返すことができます: - -手紙のためのクエリ `é`、一つのUnicodeポイントを表している `U+00E9`: - -``` sql -SELECT positionUTF8('Salut, étudiante!', '!') -``` - -結果: - -``` text -┌─positionUTF8('Salut, étudiante!', '!')─┐ -│ 17 │ -└────────────────────────────────────────┘ -``` - -手紙のためのクエリ `é` これは二つのユニコード点を表します `U+0065U+0301`: - -``` sql -SELECT positionUTF8('Salut, étudiante!', '!') -``` - -結果: - -``` text -┌─positionUTF8('Salut, étudiante!', '!')─┐ -│ 18 │ -└────────────────────────────────────────┘ -``` - -## 位置caseinsensitiveutf8 {#positioncaseinsensitiveutf8} - -同じように [positionUTF8](#positionutf8) ただし、大文字と小文字は区別されません。 文字列内の見つかった部分文字列の位置(Unicodeポイント単位)を、1から開始して返します。 - -作品は、この文字列が含まれるセットを表すバイトのutf-8で符号化されます。 この仮定が満たされない場合、関数は例外をスローせず、予期しない結果を返します。 文字が二つのunicodeポイントを使って表現できる場合は、二つのポイントを使います。 - -**構文** - -``` sql -positionCaseInsensitiveUTF8(haystack, needle) -``` - -**パラメータ** - -- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). - -**戻り値** - -- 部分文字列が見つかった場合、unicodeポイントの開始位置(1から数えます)。 -- 0、部分文字列が見つからなかった場合。 - -タイプ: `Integer`. - -**例えば** - -クエリ: - -``` sql -SELECT positionCaseInsensitiveUTF8('Привет, мир!', 'Мир') -``` - -結果: - -``` text -┌─positionCaseInsensitiveUTF8('Привет, мир!', 'Мир')─┐ -│ 9 │ -└────────────────────────────────────────────────────┘ -``` - -## マルチアーチャルポジション {#multisearchallpositions} - -同じように [位置](string_search_functions.md#position) しかし、返す `Array` 文字列内で見つかった対応する部分文字列の位置(バイト単位)。 位置は1から始まる索引付けされます。 - -検索は、文字列のエンコードおよび照合順序に関係なく、バイトのシーケンスで実行されます。 - -- 大文字と小文字を区別しないascii検索では、次の関数を使用します `multiSearchAllPositionsCaseInsensitive`. -- UTF-8で検索する場合は、次の関数を使用します [multiSearchAllPositionsUTF8](#multiSearchAllPositionsUTF8). -- 大文字と小文字を区別しないutf-8検索の場合は、関数multitsearchallpositionscaseinsensitiveutf8を使用します。 - -**構文** - -``` sql -multiSearchAllPositions(haystack, [needle1, needle2, ..., needlen]) -``` - -**パラメータ** - -- `haystack` — string, in which substring will to be searched. [文字列](../syntax.md#syntax-string-literal). -- `needle` — substring to be searched. [文字列](../syntax.md#syntax-string-literal). - -**戻り値** - -- 対応する部分文字列が見つかった場合は1から数え、見つからなかった場合は0のバイト単位の開始位置の配列。 - -**例えば** - -クエリ: - -``` sql -SELECT multiSearchAllPositions('Hello, World!', ['hello', '!', 'world']) -``` - -結果: - -``` text -┌─multiSearchAllPositions('Hello, World!', ['hello', '!', 'world'])─┐ -│ [0,13,0] │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## multiSearchAllPositionsUTF8 {#multiSearchAllPositionsUTF8} - -見る `multiSearchAllPositions`. - -## マルチアーチファーストポジション(干し草の山,\[ニードル1、針2, …, needlen\]) {#multisearchfirstposition} - -同じように `position` しかし、文字列の左端のオフセットを返します `haystack` それは針のいくつかに一致します。 - -大文字と小文字を区別しない検索やutf-8形式の場合は、関数を使用します `multiSearchFirstPositionCaseInsensitive, multiSearchFirstPositionUTF8, multiSearchFirstPositionCaseInsensitiveUTF8`. - -## マルチアーチファーストインデックス(haystack,\[needle1、針2, …, needlen\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} - -インデックスを返す `i` (1から始まる)見つかった最も左の針の私は 文字列の中で `haystack` それ以外の場合は0。 - -大文字と小文字を区別しない検索やutf-8形式の場合は、関数を使用します `multiSearchFirstIndexCaseInsensitive, multiSearchFirstIndexUTF8, multiSearchFirstIndexCaseInsensitiveUTF8`. - -## ツつィツ姪"ツつ"ツ債ツづュツつケツ-faq1、針2, …, needlen\]) {#function-multisearchany} - -少なくとも一つの文字列の針場合、1を返します私は 文字列に一致します `haystack` それ以外の場合は0。 - -大文字と小文字を区別しない検索やutf-8形式の場合は、関数を使用します `multiSearchAnyCaseInsensitive, multiSearchAnyUTF8, multiSearchAnyCaseInsensitiveUTF8`. - -!!! note "メモ" - すべて `multiSearch*` 機能は針の数2よりより少しべきです8 実装仕様のため。 - -## マッチ(干し草の山、パターン) {#matchhaystack-pattern} - -その文字列が `pattern` 正規表現。 A `re2` 正規表現。 その [構文](https://github.com/google/re2/wiki/Syntax) の `re2` 正規表現は、Perl正規表現の構文よりも制限されています。 - -一致しない場合は0、一致する場合は1を返します。 - -バックスラッシュ記号に注意してください (`\`)は、正規表現でエスケープするために使用されます。 同じ記号が文字列リテラルでエスケープするために使用されます。 したがって、正規表現でシンボルをエスケープするには、文字列リテラルに二つの円記号(\\)を記述する必要があります。 - -正規表現は、文字列がバイトのセットであるかのように動作します。 正規表現にnullバイトを含めることはできません。 -パターンが文字列内の部分文字列を検索するには、likeまたは ‘position’、彼らははるかに高速に動作するので。 - -## マルチャチャー(干し草の山、\[パターン1、パターン2, …, patternn\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} - -同じように `match` ただし、正規表現のどれも一致しない場合は0を返し、パターンのいずれかが一致する場合は1を返します。 それは使用します [hyperscan](https://github.com/intel/hyperscan) ライブラリ。 文字列の部分文字列を検索するパターンの場合は、次のように使用する方がよいでしょう `multiSearchAny` それははるかに速く動作するので。 - -!!! note "メモ" - の長さ `haystack` 文字列は2未満でなければなりません32 それ以外の場合は、例外がスローされます。 この制限は、hyperscan APIのために行われます。 - -## インデックスを作成します。1、パターン2, …, patternn\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} - -同じように `multiMatchAny`、しかし、haystackに一致する任意のインデックスを返します。 - -## ツつィツ姪"ツつ"ツ債ツづュツつケツ-ツ篠堕猟ソツ青ソツ仰1、パターン2, …, patternn\]) {#multimatchallindiceshaystack-pattern1-pattern2-patternn} - -同じように `multiMatchAny` しかし、haystackに一致するすべての指標の配列を任意の順序で返します。 - -## マルチフザイマチャニ(干し草の山、距離、\[パターン1、パターン2, …, patternn\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} - -同じように `multiMatchAny` ただし、定数内のhaystackに一致するパターンがある場合は1を返します [距離を編集](https://en.wikipedia.org/wiki/Edit_distance). この機能は実験モードでもあり、非常に遅くなる可能性があります。 詳細については、 [hyperscanマニュアル](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching). - -## インデックスを作成します。1、パターン2, …, patternn\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} - -同じように `multiFuzzyMatchAny` しかし、一定の編集距離内のhaystackに一致する任意のインデックスを返します。 - -## multiFuzzyMatchAllIndices(haystack、距離、\[パターン1、パターン2, …, patternn\]) {#multifuzzymatchallindiceshaystack-distance-pattern1-pattern2-patternn} - -同じように `multiFuzzyMatchAny` しかし、一定の編集距離内のhaystackに一致する任意の順序ですべてのインデックスの配列を返します。 - -!!! note "メモ" - `multiFuzzyMatch*` 関数はUTF-8の正規表現をサポートしておらず、hyperscanの制限により、このような式はバイトとして扱われます。 - -!!! note "メモ" - Hyperscanを使用するすべての機能をオフにするには、設定を使用します `SET allow_hyperscan = 0;`. - -## エキス(干し草の山、パターン) {#extracthaystack-pattern} - -正規表現を使用して文字列の断片を抽出します。 もし ‘haystack’ この ‘pattern’ 正規表現では、空の文字列が返されます。 正規表現にサブパターンが含まれていない場合は、正規表現全体に一致するフラグメントを取ります。 それ以外の場合は、最初のサブパターンに一致するフラグメントを取得します。 - -## extractAll(干し草の山,パターン) {#extractallhaystack-pattern} - -正規表現を使用して、文字列のすべてのフラグメントを抽出します。 もし ‘haystack’ この ‘pattern’ 正規表現では、空の文字列が返されます。 正規表現に対するすべての一致で構成される文字列の配列を返します。 一般に、この動作は、 ‘extract’ 関数(最初のサブパターン、またはサブパターンがない場合は式全体を取ります)。 - -## like(haystack,pattern),haystack LIKEパターン演算子 {#function-like} - -文字列が単純な正規表現に一致するかどうかを調べます。 -正規表現には、メタシンボルを含めることができます `%` と `_`. - -`%` 任意のバイト数(ゼロ文字を含む)を示します。 - -`_` 任意のバイトを示します。 - -バックスラッシュを使う (`\`)メタシンボルをエスケープするため。 の説明でエスケープの注意事項を参照してください。 ‘match’ 機能。 - -次のような正規表現の場合 `%needle%`、コードはより最適であり、高速として動作します `position` 機能。 -その他の正規表現の場合、コードは次のようになります。 ‘match’ 機能。 - -## ノットライク(干し草、パターン)、干し草は、パターン演算子が好きではありません {#function-notlike} - -同じものとして ‘like’、しかし否定的。 - -## ngramDistance(干し草の山,針) {#ngramdistancehaystack-needle} - -間の4グラムの距離を計算します `haystack` と `needle`: counts the symmetric difference between two multisets of 4-grams and normalizes it by the sum of their cardinalities. Returns float number from 0 to 1 – the closer to zero, the more strings are similar to each other. If the constant `needle` または `haystack` 32Kb以上で、例外をスローします。 いくつかの非定数の場合 `haystack` または `needle` 文字列は32Kb以上で、距離は常に一つです。 - -大文字と小文字を区別しない検索やutf-8形式の場合は、関数を使用します `ngramDistanceCaseInsensitive, ngramDistanceUTF8, ngramDistanceCaseInsensitiveUTF8`. - -## ngramSearch(干し草の山,針) {#ngramsearchhaystack-needle} - -と同じ `ngramDistance` しかし、非対称の違いを計算します `needle` と `haystack` – the number of n-grams from needle minus the common number of n-grams normalized by the number of `needle` nグラム。 一つに近いほど、より多くの可能性が高い `needle` にある `haystack`. あいまい文字列検索に便利です。 - -大文字と小文字を区別しない検索やutf-8形式の場合は、関数を使用します `ngramSearchCaseInsensitive, ngramSearchUTF8, ngramSearchCaseInsensitiveUTF8`. - -!!! note "メモ" - For UTF-8 case we use 3-gram distance. All these are not perfectly fair n-gram distances. We use 2-byte hashes to hash n-grams and then calculate the (non-)symmetric difference between these hash tables – collisions may occur. With UTF-8 case-insensitive format we do not use fair `tolower` function – we zero the 5-th bit (starting from zero) of each codepoint byte and first bit of zeroth byte if bytes more than one – this works for Latin and mostly for all Cyrillic letters. - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/ja/sql_reference/functions/type_conversion_functions.md b/docs/ja/sql_reference/functions/type_conversion_functions.md deleted file mode 100644 index b9576df7784..00000000000 --- a/docs/ja/sql_reference/functions/type_conversion_functions.md +++ /dev/null @@ -1,534 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: "\u30BF\u30A4\u30D7\u5909\u63DB" ---- - -# タイプ変換関数 {#type-conversion-functions} - -## 数値変換の一般的な問題 {#numeric-conversion-issues} - -値をあるデータ型から別のデータ型に変換するときは、一般的なケースでは、データの損失につながる危険な操作であることを覚えておく必要があります。 大きいデータ型の値を小さいデータ型にフィットさせる場合、または異なるデータ型の間で値を変換する場合、データ損失が発生する可能性があります。 - -クリックハウスには [C++プログラムと同じ動作](https://en.cppreference.com/w/cpp/language/implicit_conversion). - -## toInt(8/16/32/64) {#toint8163264} - -入力値を次の値に変換します。 [Int](../../sql_reference/data_types/int_uint.md) データ型。 この関数ファミ: - -- `toInt8(expr)` — Results in the `Int8` データ型。 -- `toInt16(expr)` — Results in the `Int16` データ型。 -- `toInt32(expr)` — Results in the `Int32` データ型。 -- `toInt64(expr)` — Results in the `Int64` データ型。 - -**パラメータ** - -- `expr` — [式](../syntax.md#syntax-expressions) 数値または数値の小数表現を含む文字列を返します。 数値のBinary、octal、およびhexadecimal表現はサポートされていません。 先頭のゼロは除去されます。 - -**戻り値** - -の整数値 `Int8`, `Int16`, `Int32`、または `Int64` データ型。 - -関数の使用 [ゼロに向かって丸め](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) つまり、数字の小数桁を切り捨てます。 - -のための機能の動作 [NaNおよびInf](../../sql_reference/data_types/float.md#data_type-float-nan-inf) 引数は未定義です。 覚えておいて [数値変換の問題](#numeric-conversion-issues)、機能を使用する場合。 - -**例えば** - -``` sql -SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) -``` - -``` text -┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ -│ -9223372036854775808 │ 32 │ 16 │ 8 │ -└──────────────────────┴─────────────┴───────────────┴─────────────┘ -``` - -## toInt(8/16/32/64)OrZero {#toint8163264orzero} - -これは、string型の引数をとり、int型にそれを解析しようとします(8 \| 16 \| 32 \| 64). 失敗した場合は0を返します。 - -**例えば** - -``` sql -select toInt64OrZero('123123'), toInt8OrZero('123qwe123') -``` - -``` text -┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ -│ 123123 │ 0 │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toInt(8/16/32/64)OrNull {#toint8163264ornull} - -これは、string型の引数をとり、int型にそれを解析しようとします(8 \| 16 \| 32 \| 64). 失敗した場合はnullを返します。 - -**例えば** - -``` sql -select toInt64OrNull('123123'), toInt8OrNull('123qwe123') -``` - -``` text -┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ -│ 123123 │ ᴺᵁᴸᴸ │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toUInt(8/16/32/64) {#touint8163264} - -入力値を次の値に変換します。 [UInt](../../sql_reference/data_types/int_uint.md) データ型。 この関数ファミ: - -- `toUInt8(expr)` — Results in the `UInt8` データ型。 -- `toUInt16(expr)` — Results in the `UInt16` データ型。 -- `toUInt32(expr)` — Results in the `UInt32` データ型。 -- `toUInt64(expr)` — Results in the `UInt64` データ型。 - -**パラメータ** - -- `expr` — [式](../syntax.md#syntax-expressions) 数値または数値の小数表現を含む文字列を返します。 数値のBinary、octal、およびhexadecimal表現はサポートされていません。 先頭のゼロは除去されます。 - -**戻り値** - -の整数値 `UInt8`, `UInt16`, `UInt32`、または `UInt64` データ型。 - -関数の使用 [ゼロに向かって丸め](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) つまり、数字の小数桁を切り捨てます。 - -負のagrumentsのための関数の動作と [NaNおよびInf](../../sql_reference/data_types/float.md#data_type-float-nan-inf) 引数は未定義です。 負の数の文字列を渡すと、次のようになります `'-32'`、ClickHouseは例外を発生させます。 覚えておいて [数値変換の問題](#numeric-conversion-issues)、機能を使用する場合。 - -**例えば** - -``` sql -SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) -``` - -``` text -┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ -│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ -└─────────────────────┴───────────────┴────────────────┴──────────────┘ -``` - -## toUInt(8/16/32/64)OrZero {#touint8163264orzero} - -## toUInt(8/16/32/64)OrNull {#touint8163264ornull} - -## toFloat(32/64) {#tofloat3264} - -## toFloat(32/64)OrZero {#tofloat3264orzero} - -## toFloat(32/64)OrNull {#tofloat3264ornull} - -## toDate {#todate} - -## toDateOrZero {#todateorzero} - -## toDateOrNull {#todateornull} - -## toDateTime {#todatetime} - -## toDateTimeOrZero {#todatetimeorzero} - -## toDateTimeOrNull {#todatetimeornull} - -## toDecimal(32/64/128) {#todecimal3264128} - -変換 `value` に [小数](../../sql_reference/data_types/decimal.md) 精度の高いデータ型 `S`. その `value` 数値または文字列を指定できます。 その `S` (スケール)パラメータ小数点以下の桁数を指定します。 - -- `toDecimal32(value, S)` -- `toDecimal64(value, S)` -- `toDecimal128(value, S)` - -## toDecimal(32/64/128)OrNull {#todecimal3264128ornull} - -入力文字列をaに変換します [Nullable(小数点(P,S)))](../../sql_reference/data_types/decimal.md) データ型の値。 このファミリの機能など: - -- `toDecimal32OrNull(expr, S)` — Results in `Nullable(Decimal32(S))` データ型。 -- `toDecimal64OrNull(expr, S)` — Results in `Nullable(Decimal64(S))` データ型。 -- `toDecimal128OrNull(expr, S)` — Results in `Nullable(Decimal128(S))` データ型。 - -これらの関数は、次の代わりに使用します `toDecimal*()` を取得したい場合は、 `NULL` 入力値の解析エラーが発生した場合の例外の代わりに値を指定します。 - -**パラメータ** - -- `expr` — [式](../syntax.md#syntax-expressions)、値を返します [文字列](../../sql_reference/data_types/string.md) データ型。 ClickHouseは、小数のテキスト表現を想定しています。 例えば, `'1.111'`. -- `S` — Scale, the number of decimal places in the resulting value. - -**戻り値** - -の値 `Nullable(Decimal(P,S))` データ型。 値は次のとおりです: - -- 数との `S` ClickHouseが入力文字列を数値として解釈する場合、小数点以下の桁数。 -- `NULL` ClickHouseが入力文字列を数値として解釈できない場合、または入力番号に `S` 小数点以下の桁数。 - -**例** - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ -│ -1.11100 │ Nullable(Decimal(9, 5)) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ -│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toDecimal(32/64/128)OrZero {#todecimal3264128orzero} - -入力値を次の値に変換します。 [小数点(p,s))](../../sql_reference/data_types/decimal.md) データ型。 このファミリの機能など: - -- `toDecimal32OrZero( expr, S)` — Results in `Decimal32(S)` データ型。 -- `toDecimal64OrZero( expr, S)` — Results in `Decimal64(S)` データ型。 -- `toDecimal128OrZero( expr, S)` — Results in `Decimal128(S)` データ型。 - -これらの関数は、次の代わりに使用します `toDecimal*()` を取得したい場合は、 `0` 入力値の解析エラーが発生した場合の例外の代わりに値を指定します。 - -**パラメータ** - -- `expr` — [式](../syntax.md#syntax-expressions)、値を返します [文字列](../../sql_reference/data_types/string.md) データ型。 ClickHouseは、小数のテキスト表現を想定しています。 例えば, `'1.111'`. -- `S` — Scale, the number of decimal places in the resulting value. - -**戻り値** - -の値 `Nullable(Decimal(P,S))` データ型。 値は次のとおりです: - -- 数との `S` ClickHouseが入力文字列を数値として解釈する場合、小数点以下の桁数。 -- 0とともに `S` ClickHouseが入力文字列を数値として解釈できない場合、または入力番号に `S` 小数点以下の桁数。 - -**例えば** - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ -│ -1.11100 │ Decimal(9, 5) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ -│ 0.00 │ Decimal(9, 2) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toString {#tostring} - -数値、文字列(固定文字列ではない)、日付、および日付を時刻で変換するための関数。 -これら全ての機能を受け入れを一つの引数。 - -文字列に変換するとき、または文字列から変換するとき、値はtabseparated形式(および他のほとんどすべてのテキスト形式)と同じ規則を使用して書式設定ま 文字列を解析できない場合は、例外がスローされ、要求はキャンセルされます。 - -日付を数値またはその逆に変換する場合、日付はunixエポックの開始からの日数に対応します。 -時刻を含む日付を数値またはその逆に変換する場合、時刻を含む日付は、unixエポックの開始からの秒数に対応します。 - -ToDate/toDateTime関数の日時形式は、次のように定義されています: - -``` text -YYYY-MM-DD -YYYY-MM-DD hh:mm:ss -``` - -例外として、uint32、int32、uint64、またはint64の数値型からdateに変換し、その数値が65536以上の場合、その数値はunixタイムスタンプとして(日数ではなく)解釈さ これにより、一般的な執筆のサポートが可能になります ‘toDate(unix\_timestamp)’ それ以外の場合はエラーになり、より面倒な書き込みが必要になります ‘toDate(toDateTime(unix\_timestamp))’. - -時間を伴う日付と日付の間の変換は、ヌル時間を追加するか、時間を落とすことによって自然な方法で行われます。 - -数値型間の変換は、c++で異なる数値型間の代入と同じ規則を使用します。 - -さらに、datetime引数のtostring関数は、タイムゾーンの名前を含む第二の文字列引数を取ることができます。 例えば: `Asia/Yekaterinburg` この場合、時刻は指定されたタイムゾーンに従ってフォーマットされます。 - -``` sql -SELECT - now() AS now_local, - toString(now(), 'Asia/Yekaterinburg') AS now_yekat -``` - -``` text -┌───────────now_local─┬─now_yekat───────────┐ -│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ -└─────────────────────┴─────────────────────┘ -``` - -また、 `toUnixTimestamp` 機能。 - -## toFixedString(s,N) {#tofixedstrings-n} - -文字列型引数をfixedstring(n)型(固定長nの文字列)に変換します。 nは定数でなければなりません。 -文字列のバイト数がnより少ない場合は、右側にnullバイトが渡されます。 文字列のバイト数がnより多い場合は、例外がスローされます。 - -## tostringクットゼロ(s) {#tostringcuttozeros} - -文字列またはfixedstring引数を受け取ります。 最初のゼロ-バイトで切り捨てられたコンテンツを持つ文字列を返します。 - -例えば: - -``` sql -SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s─────────────┬─s_cut─┐ -│ foo\0\0\0\0\0 │ foo │ -└───────────────┴───────┘ -``` - -``` sql -SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s──────────┬─s_cut─┐ -│ foo\0bar\0 │ foo │ -└────────────┴───────┘ -``` - -## reinterpretAsUInt(8/16/32/64) {#reinterpretasuint8163264} - -## 再解釈(8/16/32/64) {#reinterpretasint8163264} - -## 再解釈(32/64) {#reinterpretasfloat3264} - -## 再解釈アスデート {#reinterpretasdate} - -## タスデータタイムの再解釈 {#reinterpretasdatetime} - -これらの関数は文字列を受け取り、文字列の先頭に置かれたバイトをホスト順(リトルエンディアン)の数値として解釈します。 文字列が十分な長さでない場合、関数は、文字列が必要な数のヌルバイトで埋められているかのように機能します。 文字列が必要以上に長い場合、余分なバイトは無視されます。 日付はunixエポックの開始からの日数として解釈され、時刻付きの日付はunixエポックの開始からの秒数として解釈されます。 - -## 文字列の再解釈 {#type_conversion_functions-reinterpretAsString} - -この関数は、時刻を含む数値または日付または日付を受け取り、対応する値をホスト順(リトルエンディアン)で表すバイトを含む文字列を返します。 nullバイトは、末尾から削除されます。 たとえば、uint32型の値255は、バイト長の文字列です。 - -## 再解釈された文字列 {#reinterpretasfixedstring} - -この関数は、時刻を含む数値または日付または日付を受け取り、対応する値をホスト順(リトルエンディアン)で表すバイトを含むfixedstringを返します。 nullバイトは、末尾から削除されます。 たとえば、uint32型の値255は、バイト長のfixedstringです。 - -## キャスト(x,t) {#type_conversion_function-cast} - -変換 ‘x’ に ‘t’ データ型。 構文CAST(x AS t)もサポートされています。 - -例えば: - -``` sql -SELECT - '2016-06-15 23:00:00' AS timestamp, - CAST(timestamp AS DateTime) AS datetime, - CAST(timestamp AS Date) AS date, - CAST(timestamp, 'String') AS string, - CAST(timestamp, 'FixedString(22)') AS fixed_string -``` - -``` text -┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ -└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ -``` - -FixedString(N)への変換は、String型またはFixedString(N)型の引数に対してのみ機能します。 - -タイプへの変換 [Nullable](../../sql_reference/data_types/nullable.md) そして背部は支えられます。 例えば: - -``` sql -SELECT toTypeName(x) FROM t_null -``` - -``` text -┌─toTypeName(x)─┐ -│ Int8 │ -│ Int8 │ -└───────────────┘ -``` - -``` sql -SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null -``` - -``` text -┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ -│ Nullable(UInt16) │ -│ Nullable(UInt16) │ -└─────────────────────────────────────────┘ -``` - -## toInterval(年/四半期\|月/週\|日/時/分/秒) {#function-tointerval} - -数値型の引数を [間隔](../../sql_reference/data_types/special_data_types/interval.md) データ型。 - -**構文** - -``` sql -toIntervalSecond(number) -toIntervalMinute(number) -toIntervalHour(number) -toIntervalDay(number) -toIntervalWeek(number) -toIntervalMonth(number) -toIntervalQuarter(number) -toIntervalYear(number) -``` - -**パラメータ** - -- `number` — Duration of interval. Positive integer number. - -**戻り値** - -- の値 `Interval` データ型。 - -**例えば** - -``` sql -WITH - toDate('2019-01-01') AS date, - INTERVAL 1 WEEK AS interval_week, - toIntervalWeek(1) AS interval_to_week -SELECT - date + interval_week, - date + interval_to_week -``` - -``` text -┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ -│ 2019-01-08 │ 2019-01-08 │ -└───────────────────────────┴──────────────────────────────┘ -``` - -## parseDateTimeBestEffort {#parsedatetimebesteffort} - -の日付と時刻を変換します。 [文字列](../../sql_reference/data_types/string.md) 表現する [DateTime](../../sql_reference/data_types/datetime.md#data_type-datetime) データ型。 - -関数は解析します [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC1123-5.2.14RFC-822日付と時刻の指定](https://tools.ietf.org/html/rfc1123#page-55)、ClickHouseのと他のいくつかの日付と時刻の形式。 - -**構文** - -``` sql -parseDateTimeBestEffort(time_string [, time_zone]); -``` - -**パラメータ** - -- `time_string` — String containing a date and time to convert. [文字列](../../sql_reference/data_types/string.md). -- `time_zone` — Time zone. The function parses `time_string` タイムゾーンによると。 [文字列](../../sql_reference/data_types/string.md). - -**サポートされている非標準形式** - -- 9を含む文字列。.10桁 [unix timestamp](https://en.wikipedia.org/wiki/Unix_time). -- 日付と時刻コンポーネントを含む文字列: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`、等。 -- 日付を含む文字列で、時間の要素は含まれません: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` など。 -- 日と時間のある文字列: `DD`, `DD hh`, `DD hh:mm`. この場合 `YYYY-MM` として代入される。 `2000-01`. -- タイムゾーンオフセット情報と共に日付と時刻を含む文字列: `YYYY-MM-DD hh:mm:ss ±h:mm`、等。 例えば, `2020-12-12 17:36:00 -5:00`. - -Separatorを持つすべての形式について、この関数は、フルネームまたは月名の最初の三文字で表される月の名前を解析します。 例: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. - -**戻り値** - -- `time_string` に変換される。 `DateTime` データ型。 - -**例** - -クエリ: - -``` sql -SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') -AS parseDateTimeBestEffort; -``` - -結果: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2020-12-12 12:12:57 │ -└─────────────────────────┘ -``` - -クエリ: - -``` sql -SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') -AS parseDateTimeBestEffort -``` - -結果: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2018-08-18 10:22:16 │ -└─────────────────────────┘ -``` - -クエリ: - -``` sql -SELECT parseDateTimeBestEffort('1284101485') -AS parseDateTimeBestEffort -``` - -結果: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2015-07-07 12:04:41 │ -└─────────────────────────┘ -``` - -クエリ: - -``` sql -SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') -AS parseDateTimeBestEffort -``` - -結果: - -``` text -┌─parseDateTimeBestEffort─┐ -│ 2018-12-12 10:12:12 │ -└─────────────────────────┘ -``` - -クエリ: - -``` sql -SELECT parseDateTimeBestEffort('10 20:19') -``` - -結果: - -``` text -┌─parseDateTimeBestEffort('10 20:19')─┐ -│ 2000-01-10 20:19:00 │ -└─────────────────────────────────────┘ -``` - -**また見なさい** - -- \[ISO 8601 announcement by @xkcd\](https://xkcd.com/1179/) -- [RFC 1123](https://tools.ietf.org/html/rfc1123) -- [toDate](#todate) -- [toDateTime](#todatetime) - -## parseDateTimeBestEffortOrNull {#parsedatetimebesteffortornull} - -と同じ [parseDateTimeBestEffort](#parsedatetimebesteffort) ただし、処理できない日付形式が検出された場合はnullを返します。 - -## parseDateTimeBestEffortOrZero {#parsedatetimebesteffortorzero} - -と同じ [parseDateTimeBestEffort](#parsedatetimebesteffort) ただし、処理できない日付形式に遭遇した場合は、日付またはゼロの日時が返されます。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/ja/sql_reference/functions/url_functions.md b/docs/ja/sql_reference/functions/url_functions.md deleted file mode 100644 index a594708354f..00000000000 --- a/docs/ja/sql_reference/functions/url_functions.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 54 -toc_title: "Url\u306E\u64CD\u4F5C" ---- - -# Urlを操作するための関数 {#functions-for-working-with-urls} - -これらの関数はすべてrfcに従いません。 それらは改善された性能のために最大限に簡単である。 - -## URLの一部を抽出する関数 {#functions-that-extract-parts-of-a-url} - -関連する部分がurlに存在しない場合は、空の文字列が返されます。 - -### プロトコル {#protocol} - -URLからプロトコルを抽出します。 - -Examples of typical returned values: http, https, ftp, mailto, tel, magnet… - -### ドメイン {#domain} - -URLからホスト名を抽出します。 - -``` sql -domain(url) -``` - -**パラメータ** - -- `url` — URL. Type: [文字列](../../sql_reference/data_types/string.md). - -URLは、スキームの有無にかかわらず指定できます。 例: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -これらの例では、 `domain` 関数は、次の結果を返します: - -``` text -some.svn-hosting.com -some.svn-hosting.com -yandex.com -``` - -**戻り値** - -- ホスト名。 clickhouseが入力文字列をurlとして解析できる場合。 -- 空の文字列。 clickhouseが入力文字列をurlとして解析できない場合。 - -タイプ: `String`. - -**例えば** - -``` sql -SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ -│ some.svn-hosting.com │ -└────────────────────────────────────────────────────────┘ -``` - -### ドメインウィズなしwww {#domainwithoutwww} - -ドメインを返し、複数のドメインを削除します ‘www.’ それの初めから、存在する場合。 - -### topleveldomaincomment {#topleveldomain} - -URLからトップレベルドメインを抽出します。 - -``` sql -topLevelDomain(url) -``` - -**パラメータ** - -- `url` — URL. Type: [文字列](../../sql_reference/data_types/string.md). - -URLは、スキームの有無にかかわらず指定できます。 例: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -**戻り値** - -- ドメイン名。 clickhouseが入力文字列をurlとして解析できる場合。 -- 空の文字列。 clickhouseが入力文字列をurlとして解析できない場合。 - -タイプ: `String`. - -**例えば** - -``` sql -SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ -│ com │ -└────────────────────────────────────────────────────────────────────┘ -``` - -### 最初のサブドメイン {#firstsignificantsubdomain} - -を返します “first significant subdomain”. これはYandex固有の非標準的な概念です。メトリカ 最初の重要なサブドメインは、セカンドレベルドメインです。 ‘com’, ‘net’, ‘org’、または ‘co’. それ以外の場合は、サードレベルのドメインです。 例えば, `firstSignificantSubdomain (‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’`. のリスト “insignificant” 二次レベルドメインおよびその他の実施内容に変化する可能性があります。 - -### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} - -トップレベルのサブドメインを含むドメインの部分を返します。 “first significant subdomain” (上記の説明を参照)。 - -例えば, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. - -### パス {#path} - -パスを返します。 例えば: `/top/news.html` パスにはクエリ文字列は含まれません。 - -### pathFull {#pathfull} - -上記と同じですが、クエリ文字列とフラグメントを含みます。 例:/トップ/ニュース。html?ページ=2\#コメント - -### クエリ文字列 {#querystring} - -クエリ文字列を返します。 例:ページ=1&lr=213。 query-stringには、最初の疑問符と\#と\#後のすべてが含まれていません。 - -### 断片 {#fragment} - -フラグメント識別子を返します。 fragmentには、最初のハッシュ記号は含まれません。 - -### queryStringAndFragment {#querystringandfragment} - -クエリ文字列とフラグメント識別子を返します。 例:ページ=1\#29390. - -### extractURLParameter(URL,名前) {#extracturlparameterurl-name} - -の値を返します ‘name’ URL内にパラメータが存在する場合。 それ以外の場合は、空の文字列。 この名前のパラメータが多数ある場合は、最初のオカレンスが返されます。 この関数は、パラメータ名が渡された引数とまったく同じ方法でURLにエンコードされるという前提の下で機能します。 - -### extractURLParameters(URL) {#extracturlparametersurl} - -URLパラメータに対応するname=value文字列の配列を返します。 値は決してデコードされません。 - -### extractURLParameterNames(URL) {#extracturlparameternamesurl} - -URLパラメータの名前に対応する名前文字列の配列を返します。 値は決してデコードされません。 - -### URLHierarchy(URL) {#urlhierarchyurl} - -最後に/,?記号で切り捨てられたurlを含む配列を返します。 パスとクエリ文字列で。 連続セパレータ文字として数えます。 カットは、すべての連続した区切り文字の後の位置に作られています。 - -### URLPathHierarchy(URL) {#urlpathhierarchyurl} - -上記と同じですが、結果のプロトコルとホストはありません。 要素(ルート)は含まれません。 例:この関数は、ツリーを実装するために使用されるyandexのurlを報告します。 メトリック。 - -``` text -URLPathHierarchy('https://example.com/browse/CONV-6788') = -[ - '/browse/', - '/browse/CONV-6788' -] -``` - -### decodeURLComponent(URL) {#decodeurlcomponenturl} - -復号化されたurlを返します。 -例えば: - -``` sql -SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; -``` - -``` text -┌─DecodedURL─────────────────────────────┐ -│ http://127.0.0.1:8123/?query=SELECT 1; │ -└────────────────────────────────────────┘ -``` - -## URLの一部を削除する関数。 {#functions-that-remove-part-of-a-url} - -URLに類似したものがない場合、URLは変更されません。 - -### cutWWW {#cutwww} - -一つ以下を削除します ‘www.’ URLのドメインの先頭から、存在する場合。 - -### cutQueryString {#cutquerystring} - -クエリ文字列を削除します。 疑問符も削除されます。 - -### カットフラグメント {#cutfragment} - -フラグメント識別子を削除します。 番号記号も削除されます。 - -### cutQueryStringAndFragment {#cutquerystringandfragment} - -クエリ文字列とフラグメント識別子を削除します。 疑問符と番号記号も削除されます。 - -### cutURLParameter(URL,名前) {#cuturlparameterurl-name} - -削除する ‘name’ URLパラメーターがある場合。 この関数は、パラメータ名が渡された引数とまったく同じ方法でURLにエンコードされるという前提の下で機能します。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/ja/sql_reference/functions/uuid_functions.md b/docs/ja/sql_reference/functions/uuid_functions.md deleted file mode 100644 index 65956e93ddd..00000000000 --- a/docs/ja/sql_reference/functions/uuid_functions.md +++ /dev/null @@ -1,122 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 53 -toc_title: "UUID\u306E\u64CD\u4F5C" ---- - -# UUIDを操作するための関数 {#functions-for-working-with-uuid} - -UUIDを操作するための関数を以下に示します。 - -## generateUUIDv4 {#uuid-function-generate} - -を生成する。 [UUID](../../sql_reference/data_types/uuid.md) の [バージョン4](https://tools.ietf.org/html/rfc4122#section-4.4). - -``` sql -generateUUIDv4() -``` - -**戻り値** - -UUID型の値。 - -**使用例** - -この例では、uuid型の列を使用してテーブルを作成し、テーブルに値を挿入する方法を示します。 - -``` sql -CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog - -INSERT INTO t_uuid SELECT generateUUIDv4() - -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┐ -│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ -└──────────────────────────────────────┘ -``` - -## toUUID(x) {#touuid-x} - -文字列型の値をuuid型に変換します。 - -``` sql -toUUID(String) -``` - -**戻り値** - -UUID型の値。 - -**使用例** - -``` sql -SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid -``` - -``` text -┌─────────────────────────────────uuid─┐ -│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ -└──────────────────────────────────────┘ -``` - -## UUIDStringToNum {#uuidstringtonum} - -次の形式の36文字を含む文字列を受け取ります `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` そして、それをaのバイトのセットとして返します [FixedString(16)](../../sql_reference/data_types/fixedstring.md). - -``` sql -UUIDStringToNum(String) -``` - -**戻り値** - -FixedString(16) - -**使用例** - -``` sql -SELECT - '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, - UUIDStringToNum(uuid) AS bytes -``` - -``` text -┌─uuid─────────────────────────────────┬─bytes────────────┐ -│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ -└──────────────────────────────────────┴──────────────────┘ -``` - -## UUIDNumToString {#uuidnumtostring} - -を受け入れる [FixedString(16)](../../sql_reference/data_types/fixedstring.md) 値、およびテキスト形式で36文字を含む文字列を返します。 - -``` sql -UUIDNumToString(FixedString(16)) -``` - -**戻り値** - -文字列。 - -**使用例** - -``` sql -SELECT - 'a/<@];!~p{jTj={)' AS bytes, - UUIDNumToString(toFixedString(bytes, 16)) AS uuid -``` - -``` text -┌─bytes────────────┬─uuid─────────────────────────────────┐ -│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ -└──────────────────┴──────────────────────────────────────┘ -``` - -## また見なさい {#see-also} - -- [dictGetUUID](ext_dict_functions.md#ext_dict_functions-other) - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/ja/sql_reference/functions/ym_dict_functions.md b/docs/ja/sql_reference/functions/ym_dict_functions.md deleted file mode 100644 index 858ff9aa7a9..00000000000 --- a/docs/ja/sql_reference/functions/ym_dict_functions.md +++ /dev/null @@ -1,156 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 59 -toc_title: "Yandex\u306E\u3067\u306E\u4F5C\u696D\u3002\u30E1\u30C8\u30EA\u30AB\u8F9E\ - \u66F8" ---- - -# Yandexで作業するための機能。メトリカ辞書 {#functions-for-working-with-yandex-metrica-dictionaries} - -以下の機能が機能するためには、サーバー設定はすべてのyandexを取得するためのパスとアドレスを指定する必要があります。メトリカ辞書。 辞書は、これらの関数の最初の呼び出し時にロードされます。 参照リストをロードできない場合は、例外がスローされます。 - -のための情報を参照リストの項をご参照ください “Dictionaries”. - -## 複数のジオベース {#multiple-geobases} - -ClickHouseは、複数の代替ジオベース(地域階層)を同時に使用して、特定の地域が属する国のさまざまな視点をサポートします。 - -その ‘clickhouse-server’ configは、地域階層を持つファイルを指定します::`/opt/geo/regions_hierarchy.txt` - -このファイルのほかに、それはまた、(ファイル拡張子の前に)\_シンボルと名前に追加任意の接尾辞を持っている近くのファイルを検索します。 -たとえば、ファイルも検索します `/opt/geo/regions_hierarchy_ua.txt`、もしあれば。 - -`ua` 辞書キーと呼ばれます。 接尾辞のない辞書の場合、キーは空の文字列です。 - -すべての辞書は実行時に再ロードされます(builtin\_dictionaries\_reload\_interval設定パラメータで定義されているすべての秒数、またはデフォルトで時間が一度)。 ただし、使用可能な辞書のリストは、サーバーの起動時に一度だけ定義されます。 - -All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. -例えば: - -``` sql -regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt -regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt -regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt -``` - -### ツつィツ姪"ツつ"ツ債ツづュツつケツ-faq\]) {#regiontocityid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. - -### regionToArea(id\[,geobase\]) {#regiontoareaid-geobase} - -領域を領域に変換します(ジオベースのタイプ5)。 他のすべての方法では、この関数は次のようになります ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ -│ │ -│ Moscow and Moscow region │ -│ St. Petersburg and Leningrad region │ -│ Belgorod region │ -│ Ivanovsk region │ -│ Kaluga region │ -│ Kostroma region │ -│ Kursk region │ -│ Lipetsk region │ -│ Orlov region │ -│ Ryazan region │ -│ Smolensk region │ -│ Tambov region │ -│ Tver region │ -│ Tula region │ -└──────────────────────────────────────────────────────┘ -``` - -### ツつィツ姪"ツつ"ツ債ツづュツつケツ-ツ篠堕猟ソツ青ソツ仰\]) {#regiontodistrictid-geobase} - -地域を連邦区(ジオベースのタイプ4)に変換します。 他のすべての方法では、この関数は次のようになります ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ -│ │ -│ Central federal district │ -│ Northwest federal district │ -│ South federal district │ -│ North Caucases federal district │ -│ Privolga federal district │ -│ Ural federal district │ -│ Siberian federal district │ -│ Far East federal district │ -│ Scotland │ -│ Faroe Islands │ -│ Flemish region │ -│ Brussels capital region │ -│ Wallonia │ -│ Federation of Bosnia and Herzegovina │ -└──────────────────────────────────────────────────────────┘ -``` - -### ツつィツ姪"ツつ"ツ債ツづュツつケツ-ツつイツ堕環談\]) {#regiontocountryid-geobase} - -地域を国に変換します。 他のすべての方法では、この関数は次のようになります ‘regionToCity’. -例えば: `regionToCountry(toUInt32(213)) = 225` モスクワ(213)をロシア(225)に変換する。 - -### ツつィツ姪"ツつ"ツ債ツづュツつケツ-ツつイツ堕環談\]) {#regiontocontinentid-geobase} - -地域を大陸に変換します。 他のすべての方法では、この関数は次のようになります ‘regionToCity’. -例えば: `regionToContinent(toUInt32(213)) = 10001` モスクワ(213)をユーラシア(10001)に変換する。 - -### regionToTopContinent(\#regiontotopcontinent) {#regiontotopcontinent-regiontotopcontinent} - -リージョンの階層で最上位の大陸を検索します。 - -**構文** - -``` sql -regionToTopContinent(id[, geobase]); -``` - -**パラメータ** - -- `id` — Region ID from the Yandex geobase. [UInt32](../../sql_reference/data_types/int_uint.md). -- `geobase` — Dictionary key. See [複数のジオベース](#multiple-geobases). [文字列](../../sql_reference/data_types/string.md). 任意です。 - -**戻り値** - -- トップレベルの大陸の識別子(後者は地域の階層を登るとき)。 -- 0、何もない場合。 - -タイプ: `UInt32`. - -### ツ環板篠ョツ嘉ッツ偲青エツδツ-ツエツスツ-ツシツ\]) {#regiontopopulationid-geobase} - -地域の人口を取得します。 -人口はgeobaseのファイルに記録することができます。 セクションを見る “External dictionaries”. -リージョンに対して母集団が記録されていない場合は、0を返します。 -Yandex geobaseでは、母集団は子地域に対して記録されますが、親地域に対しては記録されません。 - -### ツつィツ姪"ツつ"ツ債ツづュツつケツ-ツ篠堕猟ソツ青ソツ仰\]) {#regioninlhs-rhs-geobase} - -をチェックする。 ‘lhs’ リージョンは ‘rhs’ 地域。 UInt8が属している場合は1、属していない場合は0を返します。 -The relationship is reflexive – any region also belongs to itself. - -### ツ環板篠ョツ嘉ッツ偲青エツδツ-ツエツスツ-ツシツ\]) {#regionhierarchyid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. -例えば: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. - -### リージョン名(id\[,lang\]) {#regiontonameid-lang} - -Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn't exist, an empty string is returned. - -`ua` と `uk` もうクです。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/ja/sql_reference/index.md b/docs/ja/sql_reference/index.md deleted file mode 100644 index dfa46ab7510..00000000000 --- a/docs/ja/sql_reference/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: SQL Reference -toc_hidden: true -toc_priority: 28 -toc_title: "\u96A0\u3055\u308C\u305F" ---- - -# SQL参照 {#sql-reference} - -- [SELECT](statements/select.md) -- [INSERT INTO](statements/insert_into.md) -- [CREATE](statements/create.md) -- [ALTER](statements/alter.md#query_language_queries_alter) -- [その他の種類のクエリ](statements/misc.md) - -[元の記事](https://clickhouse.tech/docs/en/query_language/) diff --git a/docs/ja/sql_reference/operators.md b/docs/ja/sql_reference/operators.md deleted file mode 100644 index 918c243ceba..00000000000 --- a/docs/ja/sql_reference/operators.md +++ /dev/null @@ -1,278 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u6F14\u7B97\u5B50" ---- - -# 演算子 {#operators} - -すべての演算子は、優先順位と結合性に従って、クエリの解析段階で対応する関数に変換されます。 -演算子のグループは優先順位の順にリストされます(リスト内の高いほど、演算子はその引数に接続されています)。 - -## アクセス事業者 {#access-operators} - -`a[N]` – Access to an element of an array. The `arrayElement(a, N)` 機能。 - -`a.N` – Access to a tuple element. The `tupleElement(a, N)` 機能。 - -## 数値の否定の演算子 {#numeric-negation-operator} - -`-a` – The `negate (a)` 機能。 - -## 乗算演算子と除算演算子 {#multiplication-and-division-operators} - -`a * b` – The `multiply (a, b)` 機能。 - -`a / b` – The `divide(a, b)` 機能。 - -`a % b` – The `modulo(a, b)` 機能。 - -## 加算および減算演算子 {#addition-and-subtraction-operators} - -`a + b` – The `plus(a, b)` 機能。 - -`a - b` – The `minus(a, b)` 機能。 - -## 比較演算子 {#comparison-operators} - -`a = b` – The `equals(a, b)` 機能。 - -`a == b` – The `equals(a, b)` 機能。 - -`a != b` – The `notEquals(a, b)` 機能。 - -`a <> b` – The `notEquals(a, b)` 機能。 - -`a <= b` – The `lessOrEquals(a, b)` 機能。 - -`a >= b` – The `greaterOrEquals(a, b)` 機能。 - -`a < b` – The `less(a, b)` 機能。 - -`a > b` – The `greater(a, b)` 機能。 - -`a LIKE s` – The `like(a, b)` 機能。 - -`a NOT LIKE s` – The `notLike(a, b)` 機能。 - -`a BETWEEN b AND c` – The same as `a >= b AND a <= c`. - -`a NOT BETWEEN b AND c` – The same as `a < b OR a > c`. - -## データセットを操作する演算子 {#operators-for-working-with-data-sets} - -*見る [演算子の場合](statements/select.md#select-in-operators).* - -`a IN ...` – The `in(a, b)` 機能。 - -`a NOT IN ...` – The `notIn(a, b)` 機能。 - -`a GLOBAL IN ...` – The `globalIn(a, b)` 機能。 - -`a GLOBAL NOT IN ...` – The `globalNotIn(a, b)` 機能。 - -## 日付と時刻を操作する演算子 {#operators-datetime} - -### EXTRACT {#operator-extract} - -``` sql -EXTRACT(part FROM date); -``` - -指定した日付からパートを抽出します。 たとえば、指定した日付から月、または時刻から秒を取得できます。 - -その `part` パラメーター取得する日付の部分を指定します。 次の値を使用できます: - -- `DAY` — The day of the month. Possible values: 1–31. -- `MONTH` — The number of a month. Possible values: 1–12. -- `YEAR` — The year. -- `SECOND` — The second. Possible values: 0–59. -- `MINUTE` — The minute. Possible values: 0–59. -- `HOUR` — The hour. Possible values: 0–23. - -その `part` パラ - -その `date` パラメーター処理する日付または時刻を指定します。 どちらか [日付](../sql_reference/data_types/date.md) または [DateTime](../sql_reference/data_types/datetime.md) タイプに対応しています。 - -例: - -``` sql -SELECT EXTRACT(DAY FROM toDate('2017-06-15')); -SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); -SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); -``` - -次の例では、テーブルを作成し、その中に値を挿入します `DateTime` タイプ。 - -``` sql -CREATE TABLE test.Orders -( - OrderId UInt64, - OrderName String, - OrderDate DateTime -) -ENGINE = Log; -``` - -``` sql -INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); -``` - -``` sql -SELECT - toYear(OrderDate) AS OrderYear, - toMonth(OrderDate) AS OrderMonth, - toDayOfMonth(OrderDate) AS OrderDay, - toHour(OrderDate) AS OrderHour, - toMinute(OrderDate) AS OrderMinute, - toSecond(OrderDate) AS OrderSecond -FROM test.Orders; -``` - -``` text -┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ -│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ -└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ -``` - -より多くの例を見ることができる [テスト](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). - -### INTERVAL {#operator-interval} - -を作成します。 [間隔](../sql_reference/data_types/special_data_types/interval.md)-との算術演算で使用されるべきであるタイプ値 [日付](../sql_reference/data_types/date.md) と [DateTime](../sql_reference/data_types/datetime.md)-タイプの値。 - -間隔のタイプ: -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -!!! warning "警告" - 間隔の異なる種類できない。 次のような式は使用できません `INTERVAL 4 DAY 1 HOUR`. たとえば、区間の最小単位が小さいか等しい単位で区間を表します `INTERVAL 25 HOUR`. 以下の例のように、結果としての操作を使用できます。 - -例えば: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -**また見なさい** - -- [間隔](../sql_reference/data_types/special_data_types/interval.md) データ型 -- [toInterval](../sql_reference/functions/type_conversion_functions.md#function-tointerval) 型変換関数 - -## 論理否定演算子 {#logical-negation-operator} - -`NOT a` – The `not(a)` 機能。 - -## 論理and演算子 {#logical-and-operator} - -`a AND b` – The`and(a, b)` 機能。 - -## 論理or演算子 {#logical-or-operator} - -`a OR b` – The `or(a, b)` 機能。 - -## 条件演算子 {#conditional-operator} - -`a ? b : c` – The `if(a, b, c)` 機能。 - -メモ: - -条件演算子は、bとcの値を計算し、条件aが満たされているかどうかをチェックし、対応する値を返します。 もし `b` または `C` は [arrayJoin()](../sql_reference/functions/array_join.md#functions_arrayjoin) この関数は、各行は関係なくレプリケートされます。 “a” 条件。 - -## 条件式 {#operator_case} - -``` sql -CASE [x] - WHEN a THEN b - [WHEN ... THEN ...] - [ELSE c] -END -``` - -もし `x` が指定されたら、 `transform(x, [a, ...], [b, ...], c)` function is used. Otherwise – `multiIf(a, b, ..., c)`. - -がない場合 `ELSE c` 式中の句は、デフォルト値は次のとおりです `NULL`. - -その `transform` 機能は動作しません `NULL`. - -## 連結演算子 {#concatenation-operator} - -`s1 || s2` – The `concat(s1, s2) function.` - -## ラムダ作成演算子 {#lambda-creation-operator} - -`x -> expr` – The `lambda(x, expr) function.` - -次の演算子は、角かっこであるため、優先順位がありません: - -## 配列作成演算子 {#array-creation-operator} - -`[x1, ...]` – The `array(x1, ...) function.` - -## タプル作成演算子 {#tuple-creation-operator} - -`(x1, x2, ...)` – The `tuple(x2, x2, ...) function.` - -## 結合性 {#associativity} - -すべての二項演算子は結合性を残しています。 例えば, `1 + 2 + 3` に変換される。 `plus(plus(1, 2), 3)`. -時にはこれはあなたが期待するように動作しません。 例えば, `SELECT 4 > 2 > 3` 結果は0になります。 - -効率のため、 `and` と `or` 関数は任意の数の引数を受け取ります。 対応する鎖の `AND` と `OR` 演算子は、これらの関数の単一の呼び出しに変換されます。 - -## のチェック `NULL` {#checking-for-null} - -クリックハウスは `IS NULL` と `IS NOT NULL` 演算子。 - -### IS NULL {#operator-is-null} - -- のために [Nullable](../sql_reference/data_types/nullable.md) タイプ値は、 `IS NULL` 演算子の戻り値: - - `1` 値が `NULL`. - - `0` そうでなければ -- その他の値については、 `IS NULL` 演算子は常に戻ります `0`. - - - -``` sql -SELECT x+100 FROM t_null WHERE y IS NULL -``` - -``` text -┌─plus(x, 100)─┐ -│ 101 │ -└──────────────┘ -``` - -### IS NOT NULL {#is-not-null} - -- のために [Nullable](../sql_reference/data_types/nullable.md) タイプ値は、 `IS NOT NULL` 演算子の戻り値: - - `0` 値が `NULL`. - - `1` そうでなければ -- その他の値については、 `IS NOT NULL` 演算子は常に戻ります `1`. - - - -``` sql -SELECT * FROM t_null WHERE y IS NOT NULL -``` - -``` text -┌─x─┬─y─┐ -│ 2 │ 3 │ -└───┴───┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/ja/sql_reference/statements/alter.md b/docs/ja/sql_reference/statements/alter.md deleted file mode 100644 index cbcc66aaf5c..00000000000 --- a/docs/ja/sql_reference/statements/alter.md +++ /dev/null @@ -1,505 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 36 -toc_title: ALTER ---- - -## ALTER {#query_language_queries_alter} - -その `ALTER` クエリーのみ対応して `*MergeTree` テーブルだけでなく、 `Merge`と`Distributed`. クエリに複数のバリエーションがあります。 - -### 列の操作 {#column-manipulations} - -テーブル構造の変更。 - -``` sql -ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... -``` - -クエリで、コンマ区切りのアクションのリストを指定します。 -各アクションは、列に対する操作です。 - -次の操作がサポートされます: - -- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. -- [DROP COLUMN](#alter_drop-column) — Deletes the column. -- [CLEAR COLUMN](#alter_clear-column) — Resets column values. -- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. -- [MODIFY COLUMN](#alter_modify-column) — Changes column's type, default expression and TTL. - -これらの動作については、以下で詳述する。 - -#### ADD COLUMN {#alter_add-column} - -``` sql -ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] -``` - -指定したテーブルに新しい列を追加します `name`, `type`, [`codec`](create.md#codecs) と `default_expr` (セクションを参照 [既定の式](create.md#create-default-values)). - -この `IF NOT EXISTS` 句が含まれている場合、列がすでに存在する場合、クエリはエラーを返しません。 指定した場合 `AFTER name_after` (名前のカラムのカラムを追加したものを指定されたもののリストテーブル列あります。 そうしないと、カラムが追加されるのです。 場合がありますので注意してない方の追加カラムの最初に表示します。 アクションの連鎖のために, `name_after` 前のアクションのいずれかで追加される列の名前を指定できます。 - -列を追加すると、データでアクションを実行せずにテーブル構造が変更されます。 データは後にディスクに表示されません `ALTER`. テーブルから読み取るときに列のデータが欠落している場合は、デフォルト値(デフォルトの式がある場合はデフォルトの式を実行するか、ゼロまたは データパーツをマージした後、ディスク上に列が表示されます [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)). - -このアプローチにより、 `ALTER` 古いデータの量を増やすことなく、即座に照会します。 - -例えば: - -``` sql -ALTER TABLE visits ADD COLUMN browser String AFTER user_id -``` - -#### DROP COLUMN {#alter_drop-column} - -``` sql -DROP COLUMN [IF EXISTS] name -``` - -名前の列を削除します `name`. この `IF EXISTS` 句が指定されている場合、列が存在しない場合、クエリはエラーを返しません。 - -ファイルシステ これはファイル全体を削除するので、クエリはほぼ即座に完了します。 - -例えば: - -``` sql -ALTER TABLE visits DROP COLUMN browser -``` - -#### CLEAR COLUMN {#alter_clear-column} - -``` sql -CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name -``` - -すべてリセットデータ列の指定されたパーティション 詳細設定、パーティションの名前の部 [パーティション式の指定方法](#alter-how-to-specify-part-expr). - -この `IF EXISTS` 句が指定されている場合、列が存在しない場合、クエリはエラーを返しません。 - -例えば: - -``` sql -ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() -``` - -#### COMMENT COLUMN {#alter_comment-column} - -``` sql -COMMENT COLUMN [IF EXISTS] name 'comment' -``` - -列にコメントを追加します。 この `IF EXISTS` 句が指定されている場合、列が存在しない場合、クエリはエラーを返しません。 - -それぞれの列ができています。 列にコメントが既に存在する場合、新しいコメントは前のコメントを上書きします。 - -コメントは `comment_expression` によって返される列 [DESCRIBE TABLE](misc.md#misc-describe-table) クエリ。 - -例えば: - -``` sql -ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' -``` - -#### MODIFY COLUMN {#alter_modify-column} - -``` sql -MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] -``` - -このクエリは、 `name` 列のプロパティ: - -- タイプ - -- 既定の式 - -- TTL - - For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). - -この `IF EXISTS` 句が指定されている場合、列が存在しない場合、クエリはエラーを返しません。 - -タイプを変更すると、値は次のように変換されます。 [toType](../../sql_reference/functions/type_conversion_functions.md) 関数がそれらに適用された。 デフォルトの式だけが変更された場合、クエリは何も複雑ではなく、ほぼ即座に完了します。 - -例えば: - -``` sql -ALTER TABLE visits MODIFY COLUMN browser Array(String) -``` - -Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. - -いくつかの処理段階があります: - -- 変更されたデータを含む一時(新しい)ファイルの準備。 -- 古いファイルの名前を変更する。 -- 一時(新しい)ファイルの名前を古い名前に変更します。 -- 古いファイルを削除する。 - -最初の段階だけに時間がかかります。 この段階で障害が発生した場合、データは変更されません。 -連続したステージのいずれかで障害が発生した場合は、データを手動で復元できます。 古いファイルがファイルシステムから削除されたが、新しいファイルのデータは、ディスクに書き込まれませんでしたし、失われた場合は例外です。 - -その `ALTER` クエリの変更カラムがそのままに再現されています。 指示はZooKeeperに保存され、各レプリカはそれらを適用します。 すべて `ALTER` クエリは同じ順序で実行されます。 クエリは、他のレプリカで適切なアクションが完了するのを待機します。 ただし、レプリケートされたテーブルの列を変更するクエリは中断され、すべてのアクションは非同期に実行されます。 - -#### ALTER Queryの制限 {#alter-query-limitations} - -その `ALTER` クエリを作成および削除個別要素(カラム)をネストしたデータ構造が全体に入れ子データ構造です。 ネストされたデータ構造を追加するには、次のような名前の列を追加します `name.nested_name` そしてタイプ `Array(T)`. ネストされたデータ構造は、ドットの前に同じ接頭辞を持つ名前を持つ複数の配列列列と同等です。 - -主キーまたはサンプリングキーの列の削除はサポートされていません。 `ENGINE` 式)。 主キーに含まれる列の型を変更することは、この変更によってデータが変更されない場合にのみ可能です(たとえば、値を列挙型に追加したり、型を変更 `DateTime` に `UInt32`). - -この `ALTER` クエリは必要なテーブルの変更を行うのに十分ではありません。 [INSERT SELECT](insert_into.md#insert_query_insert-select) クエリを使用してテーブルを切り替えます。 [RENAME](misc.md#misc_operations-rename) 古いテーブルを照会して削除します。 を使用することができ [クリックハウスコピー機](../../operations/utilities/clickhouse-copier.md) に代わるものとして `INSERT SELECT` クエリ。 - -その `ALTER` クエリーのブロックすべてを読み込みと書き込んでいます。 言い換えれば、長い場合 `SELECT` の時に動いています `ALTER` クエリ、 `ALTER` クエリはそれが完了するのを待ちます。 同時に、同じテーブルに対するすべての新しいクエリは、 `ALTER` 走ってる - -データ自体を格納しないテーブルの場合 `Merge` と `Distributed`), `ALTER` テーブル構造を変更するだけで、下位テーブルの構造は変更されません。 たとえば、ALTERを実行している場合 `Distributed` テーブル、また、実行する必要があります `ALTER` テーブルのすべてすることができます。 - -### キー式による操作 {#manipulations-with-key-expressions} - -以下のコマン: - -``` sql -MODIFY ORDER BY new_expression -``` - -それはの表のためにだけ働きます [`MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) ファミリー(含む -[複製された](../../engines/table_engines/mergetree_family/replication.md) テーブル)。 このコマンドは、 -[ソートキー](../../engines/table_engines/mergetree_family/mergetree.md) テーブルの -に `new_expression` (式または式のタプル)。 主キーは同じままです。 - -このコマンドは、メタデータのみを変更するという意味で軽量です。 データ部分のプロパティを保持するには -既存の列を含む式を追加することはできません。 -ソートキーに(列のみが追加されました。 `ADD COLUMN` 同じでコマンド `ALTER` クエリ)。 - -### データスキップインデックスの操作 {#manipulations-with-data-skipping-indices} - -それはの表のためにだけ働きます [`*MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) ファミリー(含む -[複製された](../../engines/table_engines/mergetree_family/replication.md) テーブル)。 次の操作 -利用できます: - -- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` -付加価指数の説明をテーブルメタデータを指すものとします。 - -- `ALTER TABLE [db].name DROP INDEX name` -除去す指標の説明からテーブルメタデータを削除を行指数のファイルからディスク。 - -これらのコマ -また、その複製(同期指標のメタデータを通して飼育係). - -### 制約による操作 {#manipulations-with-constraints} - -るの詳細を参照してください [制約](create.md#constraints) - -次の構文を使用して制約を追加または削除できます: - -``` sql -ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; -ALTER TABLE [db].name DROP CONSTRAINT constraint_name; -``` - -クエリに追加または削除約メタデータの制約からテーブルで、速やかに処理します。 - -制約チェック *実行されません* 既存のデータが追加された場合。 - -変更後の内容の複製のテーブル放送への飼育係で適用されますその他のレプリカ. - -### パーティションとパーツの操作 {#alter_manipulations-with-partitions} - -以下の操作 [パーティシ](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) 利用できます: - -- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` ディレク -- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. -- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` テーブルへのディレクトリ。 -- [REPLACE PARTITION](#alter_replace-partition) -データパーティションをテーブル間でコピーします。 -- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. -- [REPLACE PARTITION](#alter_replace-partition) -コピーするデータを仕切りからテーブルにも置き換え. -- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition) (\#alter\_move\_to\_table-partition)-あるテーブルから別のテーブルにデータパーティションを移動します。 -- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) -パーティション内の指定された列の値をリセットします。 -- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) -リセットの指定された二次インデックス、パーティション -- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. -- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. -- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. - - - -#### デタッチパーティション{\#alter\_detach-partition} {#detach-partition-alter-detach-partition} - -``` sql -ALTER TABLE table_name DETACH PARTITION partition_expr -``` - -指定されたパーティションのすべてのデータを `detached` ディレクトリ。 サーバーのを忘れているのは、一戸建てのデータを分配していない場合は存在します。 サーバーはこのデータについて知りません。 [ATTACH](#alter_attach-partition) クエリ。 - -例えば: - -``` sql -ALTER TABLE visits DETACH PARTITION 201901 -``` - -セクションのpartition expressionの設定についての記事を読む [パーティション式の指定方法](#alter-how-to-specify-part-expr). - -クエリが実行された後、データを使用して必要な操作を行うことができます `detached` directory — delete it from the file system, or just leave it. - -This query is replicated – it moves the data to the `detached` すべての複製のディレクトリ。 このクエリはリーダーレプリカでのみ実行できます。 レプリカがリーダーかどうかを調べるには、以下を実行します `SELECT` にクエリ [システム。レプリカ](../../operations/system_tables.md#system_tables-replicas) テーブル。 また、作ることは容易です `DETACH` クエリはすべてのレプリカ-すべてのレプリカ、例外をスロー以外のリーダーレプリカ. - -#### DROP PARTITION {#alter_drop-partition} - -``` sql -ALTER TABLE table_name DROP PARTITION partition_expr -``` - -削除指定された分割テーブルから. このクエリのタグの仕切りとして休止または消去いたしますデータを完全に約10分です。 - -セクションのpartition expressionの設定についての記事を読む [パーティション式の指定方法](#alter-how-to-specify-part-expr). - -The query is replicated – it deletes data on all replicas. - -#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} - -``` sql -ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr -``` - -指定したパーティショ `detached`. -セクションのパーティション式の設定の詳細 [パーティション式の指定方法](#alter-how-to-specify-part-expr). - -#### ATTACH PARTITION\|PART {#alter_attach-partition} - -``` sql -ALTER TABLE table_name ATTACH PARTITION|PART partition_expr -``` - -テーブルにデータを追加します。 `detached` ディレクトリ。 パーティション全体または別のパートにデータを追加することができます。 例: - -``` sql -ALTER TABLE visits ATTACH PARTITION 201901; -ALTER TABLE visits ATTACH PART 201901_2_2_0; -``` - -セクションのパーティション式の設定の詳細 [パーティション式の指定方法](#alter-how-to-specify-part-expr). - -このクエリは複製されます。 のレプリカ-イニシエータチェックがあるか否かのデータを `detached` ディレクトリ。 データが存在する場合、クエリは整合性をチェックします。 すべてが正しい場合、クエリはデータをテーブルに追加します。 他のすべてのレプリカをダウンロードからデータのレプリカ-イニシエータです。 - -したがって、データを `detached` ディレクトリを使用します。 `ALTER ... ATTACH` すべてのレプリカのテーブルにクエリを追加します。 - -#### ATTACH PARTITION FROM {#alter_attach-partition-from} - -``` sql -ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 -``` - -このクエリは、データパーティションを `table1` に `table2` のexsistingにデータを加えます `table2`. データは削除されないことに注意してください `table1`. - -クエリを正常に実行するには、次の条件を満たす必要があります: - -- 両方のテーブルに同じ構造が必要です。 -- 両方の表に同じパーティション-キーが必要です。 - -#### REPLACE PARTITION {#alter_replace-partition} - -``` sql -ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 -``` - -このクエリは、データパーティションを `table1` に `table2` そしての既存の仕切りを取り替えます `table2`. データは削除されないことに注意してください `table1`. - -クエリを正常に実行するには、次の条件を満たす必要があります: - -- 両方のテーブルに同じ構造が必要です。 -- 両方の表に同じパーティション-キーが必要です。 - -#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} - -``` sql -ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest -``` - -このクエリは、データパーティションを `table_source` に `table_dest` からデータを削除すると `table_source`. - -クエリを正常に実行するには、次の条件を満たす必要があります: - -- 両方のテーブルに同じ構造が必要です。 -- 両方の表に同じパーティション-キーが必要です。 -- 両方のテーブルと同じでなければならエンジンです。 (複製または非レプリケート) -- 両方の表に同じストレージポリシーが必要です。 - -#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} - -``` sql -ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr -``` - -パーティショ この `DEFAULT` このクエリは、指定されたデフォルト値に列の値を設定し、テーブルを作成するときに句が決定された。 - -例えば: - -``` sql -ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 -``` - -#### FREEZE PARTITION {#alter_freeze-partition} - -``` sql -ALTER TABLE table_name FREEZE [PARTITION partition_expr] -``` - -このクエ この `PARTITION` 条項を省略して、クエリーを作成し、バックアップの仕切ります。 - -!!! note "メモ" - バックアップ処理全体は、サーバーを停止せずに実行されます。 - -古いスタイルのテーブルでは、パーティション名のプレフィックスを指定できます(例, ‘2019’)のクエリーを作成し、バックアップのためのすべてに対応する隔壁 セクションのpartition expressionの設定についての記事を読む [パーティション式の指定方法](#alter-how-to-specify-part-expr). - -実行時に、データスナップショットの場合、クエリはテーブルデータへのハードリンクを作成します。 ディレクト `/var/lib/clickhouse/shadow/N/...`、どこ: - -- `/var/lib/clickhouse/` 設定で指定されたClickHouseの作業ディレクトリです。 -- `N` バックアップの増分数です。 - -!!! note "メモ" - 使用する場合 [テーブル内のデータストレージのディスクのセット](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes)、を `shadow/N` ディレクトリが表示される毎にディスクデータを格納する部品と合わせによる `PARTITION` 式。 - -同じディレクトリ構造がバックアップ内に作成されます。 `/var/lib/clickhouse/`. クエリが実行されます ‘chmod’ すべてのファイルについて、それらへの書き込みを禁止。 - -バックアップを作成したら、次のデータをコピーできます `/var/lib/clickhouse/shadow/` リモートサーバーに移動し、ローカルサーバーから削除します。 それに注意しなさい `ALTER t FREEZE PARTITION` クエリは複製されません。 するための地元のバックアップ、現地サーバーです。 - -クエリをバックアップトで最初のでお待ちしておりますので、現在のクエリーに対応するテーブルに仕上げた。 - -`ALTER TABLE t FREEZE PARTITION` コピーのみのデータのないテーブルメタデータを指すものとします。 をバックアップテーブルメタデータ、コピー、ファイル `/var/lib/clickhouse/metadata/database/table.sql` - -バックアップからデータを復元するには: - -1. テーブルが存在しない場合はテーブルを作成します。 クエリを表示するには、を使用します。sqlファイル(置換 `ATTACH` それで `CREATE`). -2. からデータをコピーします `data/database/table/` バックアップの中のディレクトリ `/var/lib/clickhouse/data/database/table/detached/` ディレクトリ。 -3. 走れ。 `ALTER TABLE t ATTACH PARTITION` データをテーブルに追加するクエリ。 - -バックア - -バックアップおよびデータの復元の詳細については、次を参照 [データバック](../../operations/backup.md) セクション。 - -#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} - -``` sql -ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr -``` - -クエリは次のように動作します `CLEAR COLUMN` しかし、列データの代わりに索引をリセットします。 - -#### FETCH PARTITION {#alter_fetch-partition} - -``` sql -ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' -``` - -ダウンロードパーティションから別のサーバーです。 このクエリーだけを再現します。 - -クエリは次の処理を行います: - -1. 指定したシャードからパーティションをダウ で ‘path-in-zookeeper’ ZooKeeperでシャードへのパスを指定する必要があります。 -2. 次に、クエリはダウンロードされたデータを `detached` のディレクトリ `table_name` テーブル。 を使用 [ATTACH PARTITION\|PART](#alter_attach-partition) データをテーブルに追加するためのクエリ。 - -例えば: - -``` sql -ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; -ALTER TABLE users ATTACH PARTITION 201902; -``` - -それに注意: - -- その `ALTER ... FETCH PARTITION` クエリは複製されません。 それはに仕切りを置きます `detached` ディレクト -- その `ALTER TABLE ... ATTACH` クエリが複製されます。 すべてのレプリカにデータを追加します。 データは、次のいずれかのレプリカに追加されます。 `detached` ディレクトリ、および他の人に-近隣のレプリカから。 - -ダウンロードする前に、システムかどうかをチェックすると、パーティションが存在するとテーブル構造。 最も適切なレプリカは、正常なレプリカから自動的に選択されます。 - -クエリは呼び出されますが `ALTER TABLE` テーブル構造は変更されず、テーブルで使用できるデータもすぐには変更されません。 - -#### MOVE PARTITION\|PART {#alter_move-partition} - -別のボリュームまたはディ `MergeTree`-エンジンテーブル。 見る [複数ブロックデバイスを使用したデータ保存](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes). - -``` sql -ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' -``` - -その `ALTER TABLE t MOVE` クエリ: - -- な再現が異なるレプリカで保管。 -- 指定されたディスクまたはボリ また、ストレージポリシーで指定されたデータ移動の条件を適用できない場合は、エラーが返されます。 -- 移動するデータがバックグラウンドプロセスによって既に移動されている場合にエラーを返すことができます。 `ALTER TABLE t MOVE` クエリとして結果データの統合. この場合、ユーザーは追加の操作を行うべきではありません。 - -例えば: - -``` sql -ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' -ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' -``` - -#### パーティション式の設定方法 {#alter-how-to-specify-part-expr} - -パーティション式を指定するには `ALTER ... PARTITION` 異なる方法でクエリ: - -- からの値として `partition` の列 `system.parts` テーブル。 例えば, `ALTER TABLE visits DETACH PARTITION 201901`. -- テーブル列からの式として。 定数と定数式がサポートされています。 例えば, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. -- パーティションidの使用。 パーティションidは、ファイルシステムおよびzookeeper内のパーティションの名前として使用されるパーティションの文字列識別子です(可能であれば、人間が パーティションidを指定する必要があります。 `PARTITION ID` 一重引quotesでの句。 例えば, `ALTER TABLE visits DETACH PARTITION ID '201901'`. -- で [ALTER ATTACH PART](#alter_attach-partition) と [DROP DETACHED PART](#alter_drop-detached) クエリ、パートの名前を指定するには、文字列リテラルを使用します。 `name` の列 [システム。detached\_parts](../../operations/system_tables.md#system_tables-detached_parts) テーブル。 例えば, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. - -ご利用の引用符を指定する場合、パーティションのエントランスは目を引く壁面緑化を表現。 たとえば、 `String` その名前を引用符で指定する必要があります (`'`). のための `Date` と `Int*` タイプ引用符は必要ありません。 - -古いスタイルのテーブルの場合は、パーティションを数値として指定できます `201901` または文字列 `'201901'`. 新しいスタイルのテーブルの構文は、型が厳しくなります(VALUES入力フォーマットのパーサーと同様)。 - -上記のすべてのルールは、 [OPTIMIZE](misc.md#misc_operations-optimize) クエリ。 を指定する場合にのみ分配時の最適化、非仕切られたテーブルセットの表現 `PARTITION tuple()`. 例えば: - -``` sql -OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; -``` - -の例 `ALTER ... PARTITION` クエリはテストで実証されています [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) と [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). - -### テーブルttlによる操作 {#manipulations-with-table-ttl} - -変更することができ [テーブルTTL](../../engines/table_engines/mergetree_family/mergetree.md#mergetree-table-ttl) 次のフォームの要求で: - -``` sql -ALTER TABLE table-name MODIFY TTL ttl-expression -``` - -### ALTERクエリのシンクロニシティ {#synchronicity-of-alter-queries} - -非複製可能なテーブルの場合は、すべて `ALTER` クエリは同期的に実行されます。 のためのreplicatableテーブル、クエリーだけで追加指示のための適切な行動を `ZooKeeper`、そしてアクション自体はできるだけ早く実行されます。 しかし、クエリーが待機するためにこれらの行動は完了するすべてのレプリカ. - -のために `ALTER ... ATTACH|DETACH|DROP` クエリを使用することができます `replication_alter_partitions_sync` 待ちを設定する設定。 -可能な値: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. - -### 突然変異 {#alter-mutations} - -突然変異は、テーブル内の行を変更または削除できるようにするalter query variantです。 標準とは対照的に `UPDATE` と `DELETE` ポイントデータの変更を目的としたクエリ、突然変異は、テーブル内の多くの行を変更する重い操作を目的としています。 のために支えられる `MergeTree` 家族のテーブルエンジンなどのエンジンの複製です。 - -既存のテーブルはそのまま変異可能です(変換は必要ありません)が、最初の変更がテーブルに適用されると、そのメタデータ形式は以前のサーバーバージョンと - -現在使用可能なコマンド: - -``` sql -ALTER TABLE [db.]table DELETE WHERE filter_expr -``` - -その `filter_expr` 型でなければならな `UInt8`. クエリは、この式がゼロ以外の値をとるテーブルの行を削除します。 - -``` sql -ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr -``` - -その `filter_expr` 型でなければならな `UInt8`. このクエリは、指定された列の値を、対応する式の値に更新します。 `filter_expr` ゼロ以外の値をとります。 値は列タイプにキャストされます。 `CAST` オペレーター プライマリキーまたはパーティションキーの計算で使用される列の更新はサポートされません。 - -``` sql -ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name -``` - -クエリを再建の二次指数 `name` パーティション内 `partition_name`. - -一つのクエリを含むことができ複数のコマンドをカンマで区切られています。 - -用\*mergetreeテーブル突然変異の実行による書き換え全体のデータ部品です。 atomicity-部品は準備ができているおよびaとすぐ変異する部品の代わりになりますありません `SELECT` 変異中に実行を開始したクエリには、まだ変更されていない部分のデータと共に既に変更されている部分のデータが表示されます。 - -突然変異は、作成順序によって完全に順序付けられ、その順序で各パートに適用されます。 突然変異が提出される前にテーブルに挿入されたデータは突然変異され、その後に挿入されたデータは突然変異されません。 この変異のないブロックを挿入します。 - -変更クエリは、変更エントリが追加された直後に返されます(レプリケートされたテーブルがzookeeperにある場合、非レプリケートされたテーブルがファイルシス の突然変異体の執行を非同利用システムの概要を設定します。 突然変異の進行状況を追跡するには、 [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) テーブル。 正常に送信された変更は、ClickHouseサーバーが再起動されても引き続き実行されます。 それが提出されると突然変異をロールバックする方法はありませんが、何らかの理由で突然変異が起こった場合、それをキャンセルすることができ [`KILL MUTATION`](misc.md#kill-mutation) クエリ。 - -終了した突然変異のためのエントリはすぐに削除されません(保存されたエントリの数は `finished_mutations_to_keep` ストレージエンジン変数)。 古い変異エントリが削除されます。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/ja/sql_reference/statements/create.md b/docs/ja/sql_reference/statements/create.md deleted file mode 100644 index 95fac55bfc0..00000000000 --- a/docs/ja/sql_reference/statements/create.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 35 -toc_title: CREATE ---- - -# クエリの作成 {#create-queries} - -## CREATE DATABASE {#query-language-create-database} - -データベースの作成。 - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] -``` - -### 句 {#clauses} - -- `IF NOT EXISTS` - - If the `db_name` database already exists, then ClickHouse doesn't create a new database and: - - - Doesn't throw an exception if clause is specified. - - Throws an exception if clause isn't specified. - -- `ON CLUSTER` - - ClickHouse creates the `db_name` database on all the servers of a specified cluster. - -- `ENGINE` - - - [MySQL](../engines/database_engines/mysql.md) - - Allows you to retrieve data from the remote MySQL server. - - By default, ClickHouse uses its own [database engine](../engines/database_engines/index.md). - -## CREATE TABLE {#create-table-query} - -その `CREATE TABLE` クエリには複数の形式を使用できます。 - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], - ... -) ENGINE = engine -``` - -名前の付いた表を作成します ‘name’ で ‘db’ データベースまたは ‘db’ は設定されていない。 ‘engine’ エンジン。 -テーブルの構造は、列の説明のリストです。 た場合の指数については、エンジンとして表示していパラメータテーブルのエンジンです。 - -列の説明は次のとおりです `name type` 最も単純なケースでは。 例えば: `RegionID UInt32`. -デフォルト値に対して式を定義することもできます(下記参照)。 - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] -``` - -別のテーブルと同じ構造のテーブルを作成します。 テーブルに別のエンジンを指定できます。 エンジンが指定されていない場合は、同じエンジンが `db2.name2` テーブル。 - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() -``` - -テーブルを作成しますの構造やデータによって返される [テーブル機能](../table_functions/index.md). - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... -``` - -の結果のような構造を持つテーブルを作成します。 `SELECT` クエリ、 ‘engine’ エンジンは、SELECTからのデータでそれを埋めます。 - -すべての場合において、 `IF NOT EXISTS` テーブルが既に存在する場合、クエリはエラーを返しません。 この場合、クエリは何もしません。 - -後に他の節がある場合もあります `ENGINE` クエリ内の句。 テーブルの作成方法に関する詳細なドキュメントを参照してください [表エンジン](../../engines/table_engines/index.md#table_engines). - -### デフォルト値 {#create-default-values} - -列の説明では、次のいずれかの方法で、既定値の式を指定できます:`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. -例えば: `URLDomain String DEFAULT domain(URL)`. - -デフォルト値の式が定義されていない場合、デフォルト値は数値の場合はゼロに、文字列の場合は空の文字列に、配列の場合は空の配列に設定され `0000-00-00` 日付または `0000-00-00 00:00:00` 時間の日付のため。 Nullはサポートされていません。 - -既定の式が定義されている場合、列の型は省略可能です。 明示的に定義された型がない場合は、既定の式の型が使用されます。 例えば: `EventDate DEFAULT toDate(EventTime)` – the ‘Date’ タイプは ‘EventDate’ コラム - -データ型と既定の式が明示的に定義されている場合、この式は型キャスト関数を使用して指定された型にキャストされます。 例えば: `Hits UInt32 DEFAULT 0` と同じことを意味します `Hits UInt32 DEFAULT toUInt32(0)`. - -Default expressions may be defined as an arbitrary expression from table constants and columns. When creating and changing the table structure, it checks that expressions don't contain loops. For INSERT, it checks that expressions are resolvable – that all columns they can be calculated from have been passed. - -`DEFAULT expr` - -通常のデフォルト値。 insertクエリで対応する列が指定されていない場合は、対応する式を計算して入力します。 - -`MATERIALIZED expr` - -マテリアライズド式。 このような列は、常に計算されるため、insertに指定することはできません。 -列のリストのないinsertの場合、これらの列は考慮されません。 -また、selectクエリでアスタリスクを使用する場合、この列は置換されません。 これは、ダンプが以下を使用して取得した不変量を保持するためです `SELECT *` 列のリストを指定せずにINSERTを使用してテーブルに戻すことができます。 - -`ALIAS expr` - -同義語。 このような列は、テーブルにはまったく格納されません。 -その値はテーブルに挿入することはできず、selectクエリでアスタリスクを使用するときは置換されません。 -クエリの解析中にエイリアスが展開されている場合は、selectで使用できます。 - -ALTER queryを使用して新しい列を追加する場合、これらの列の古いデータは書き込まれません。 代わりに、新しい列の値を持たない古いデータを読み取る場合、式は既定でオンザフライで計算されます。 ただし、式を実行するために、クエリで指定されていない異なる列が必要な場合、これらの列は追加で読み取られますが、必要なデータブロックに対し - -新しい列をテーブルに追加し、後でそのデフォルトの式を変更すると、古いデータに使用される値が変更されます(ディスクに値が格納されていないデー バックグラウンドマージを実行すると、マージパーツのいずれかにない列のデータがマージされたパーツに書き込まれます。 - -入れ子になったデータ構造の要素の既定値を設定することはできません。 - -### 制約 {#constraints} - -列と共に、説明の制約を定義することができます: - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - ... - CONSTRAINT constraint_name_1 CHECK boolean_expr_1, - ... -) ENGINE = engine -``` - -`boolean_expr_1` 任意のブール式でできます。 場合に制約の定義のテーブルのそれぞれチェック毎に行 `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. - -追加大量の制約になる可能性の性能を大 `INSERT` クエリ。 - -### TTL式 {#ttl-expression} - -値の保存時間を定義します。 mergetree-familyテーブルにのみ指定できます。 詳細な説明については、 [列とテーブルのttl](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). - -### 列圧縮コーデック {#codecs} - -デフォルトでは、clickhouseは `lz4` 圧縮方法。 のために `MergeTree`-エンジンファミリでは、デフォルトの圧縮方法を変更できます [圧縮](../../operations/server_configuration_parameters/settings.md#server-settings-compression) サーバー構成のセクション。 また、各列の圧縮方法を定義することもできます。 `CREATE TABLE` クエリ。 - -``` sql -CREATE TABLE codec_example -( - dt Date CODEC(ZSTD), - ts DateTime CODEC(LZ4HC), - float_value Float32 CODEC(NONE), - double_value Float64 CODEC(LZ4HC(9)) - value Float32 CODEC(Delta, ZSTD) -) -ENGINE = -... -``` - -コーデックが指定されている場合、既定のコーデックは適用されません。 コーデックの組合せでのパイプライン、例えば, `CODEC(Delta, ZSTD)`. の選定と大型ブリッジダイオードコーデックの組み合わせますプロジェクト、ベンチマークと同様に記載のAltinity [ClickHouseの効率を改善する新しいエンコーディング](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) 記事。 - -!!! warning "警告" - できない解凍clickhouseデータベースファイルを外部の事のように `lz4`. 代わりに、特別な [clickhouse-コンプレッサー](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) 効用だ - -圧縮できるようになりました以下のテーブルエンジン: - -- [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) 家族 列圧縮コーデックをサポートし、既定の圧縮方法を選択する [圧縮](../../operations/server_configuration_parameters/settings.md#server-settings-compression) 設定。 -- [ログ](../../engines/table_engines/log_family/log_family.md) 家族 使用します `lz4` 圧縮メソッドはデフォルト対応カラムの圧縮コーデック. -- [セット](../../engines/table_engines/special/set.md). 唯一のデフォルトの圧縮をサポート。 -- [参加](../../engines/table_engines/special/join.md). 唯一のデフォルトの圧縮をサポート。 - -ClickHouse支援共通の目的コーデックや専門のコーデック. - -#### 特殊コーデック {#create-query-specialized-codecs} - -これらのコーデックしていただくための圧縮により効果的な利用の特徴データです。 これらのコーデックの一部は、データ自身を圧縮しない。 その代わりに、それらのデータを共通の目的コーデックは、圧縮です。 - -特殊コーデック: - -- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` デルタ値を格納するために使用されます。 `delta_bytes` raw値の最大サイズです。 可能 `delta_bytes` 値:1,2,4,8. のデフォルト値 `delta_bytes` は `sizeof(type)` 1、2、4、または8に等しい場合。 それ以外の場合は1です。 -- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [Gorilla:高速でスケーラブルなメモリ内の時系列データベース](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [Gorilla:高速でスケーラブルなメモリ内の時系列データベース](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` と `DateTime`). アルゴリズムの各ステップで、codecは64値のブロックを取り、64x64ビット行列にそれらを入れ、それを転置し、未使用の値をトリミングし、残りをシーケ 未使用のビットは、圧縮が使用されるデータ部分全体の最大値と最小値の間で異ならないビットです。 - -`DoubleDelta` と `Gorilla` コーデックは、その圧縮アルゴリズムの構成要素としてゴリラTSDBで使用されています。 Gorillaのアプローチは、タイムスタンプで徐々に変化する値のシーケンスがある場合のシナリオで有効です。 タイムスタンプは、 `DoubleDelta` コーデックおよび値はによって効果的に圧縮されます `Gorilla` コーデック。 たとえば、効果的に格納されたテーブルを取得するには、次の構成でテーブルを作成します: - -``` sql -CREATE TABLE codec_example -( - timestamp DateTime CODEC(DoubleDelta), - slow_values Float32 CODEC(Gorilla) -) -ENGINE = MergeTree() -``` - -#### 一般的な目的のコーデック {#create-query-common-purpose-codecs} - -コーデック: - -- `NONE` — No compression. -- `LZ4` — Lossless [データ圧縮](https://github.com/lz4/lz4) 既定で使用されます。 LZ4高速圧縮を適用します。 -- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` 既定のレベルを適用します。 可能なレベル:\[1、12\]。 推奨レベル範囲:\[4、9\]。 -- `ZSTD[(level)]` — [ZSTD圧縮アルゴリズム](https://en.wikipedia.org/wiki/Zstandard) 構成可能を使って `level`. 可能なレベル:\[1、22\]。 デフォルト値:1。 - -圧縮レベルが高い場合は、圧縮回数、繰り返しの解凍などの非対称シナリオに役立ちます。 高いレベルは、より良い圧縮と高いcpu使用率を意味します。 - -## 一時テーブル {#temporary-tables} - -ClickHouseは次の特徴がある一時テーブルを支える: - -- 一時テーブルは、接続が失われた場合など、セッションが終了すると消えます。 -- 一時テーブルはメモリエンジンのみを使用します。 -- 一時テーブルにdbを指定することはできません。 データベースの外部で作成されます。 -- すべてのクラスタサーバー上に分散ddlクエリを使用して一時テーブルを作成することは不可能です `ON CLUSTER`):このテーブルは現在のセッションにのみ存在します。 -- テンポラリテーブルの名前が別のテーブルと同じ場合、クエリでdbを指定せずにテーブル名を指定すると、テンポラリテーブルが使用されます。 -- 分散クエリ処理では、クエリで使用される一時テーブルがリモートサーバーに渡されます。 - -一時テーブルを作成するには、次の構文を使用します: - -``` sql -CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) -``` - -ほとんどの場合、一時テーブルを手動で作成され、外部データを利用するためのクエリに対して、または配布 `(GLOBAL) IN`. 詳細は、該当するセクションを参照してください - -テーブルを使用することは可能です [エンジン=メモリ](../../engines/table_engines/special/memory.md) 一時テーブルの代わりに。 - -## 分散ddlクエリ(on cluster clause) {#distributed-ddl-queries-on-cluster-clause} - -その `CREATE`, `DROP`, `ALTER`、と `RENAME` クエリの支援の分散実行クラスター -たとえば、次のクエリを作成します `all_hits` `Distributed` 各ホストのテーブル `cluster`: - -``` sql -CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) -``` - -これらのクエリを正しく実行するには、各ホストが同じクラスタ定義を持っている必要があります(設定の同期を簡単にするために、zookeeperからの置換 彼らはまた、zookeeperサーバに接続する必要があります。 -クエリのローカルバージョンは、一部のホストが現在利用できない場合でも、最終的にクラスター内の各ホストに実装されます。 単一のホスト内でクエリを実行する順序は保証されます。 - -## CREATE VIEW {#create-view} - -``` sql -CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... -``` - -ビューを作成します。 通常とマテリアライズド:ビューの二つのタイプがあります。 - -通常のビューにはデータは保存されませんが、別のテーブルから読み取るだけです。 言い換えれば、通常のビューは、保存されたクエリに過ぎません。 ビューから読み取る場合、この保存されたクエリはfrom句のサブクエリとして使用されます。 - -たとえば、ビューを作成したとします: - -``` sql -CREATE VIEW view AS SELECT ... -``` - -とクエリを書かれた: - -``` sql -SELECT a, b, c FROM view -``` - -このクエリは、サブクエリの使用と完全に同じです: - -``` sql -SELECT a, b, c FROM (SELECT ...) -``` - -実現の景色でデータ変換に対応する選択を返します。 - -マテリアライズドビューを作成するとき `TO [db].[table]`, you must specify ENGINE – the table engine for storing data. - -マテリアライズドビューを作成するとき `TO [db].[table]`、使用してはならない `POPULATE`. - -SELECTで指定されたテーブルにデータを挿入すると、挿入されたデータの一部がこのSELECTクエリによって変換され、結果がビューに挿入されます。 - -POPULATEを指定すると、作成時に既存のテーブルデータがビューに挿入されます。 `CREATE TABLE ... AS SELECT ...` . そうしないと、クエリーを含み、データを挿入し、表の作成後、作成した。 ビューの作成時にテーブルに挿入されたデータは挿入されないため、POPULATEを使用することはお勧めしません。 - -A `SELECT` クエ `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Note that the corresponding conversions are performed independently on each block of inserted data. For example, if `GROUP BY` が設定され、データは挿入中に集約されるが、挿入されたデータの単一パケット内にのみ存在する。 データはそれ以上集計されません。 例外は、次のようなデータの集計を個別に実行するエンジンを使用する場合です `SummingMergeTree`. - -の実行 `ALTER` クエリを実現眺めなが十分に整備されていないので、いかに不便です。 マテリアライズドビュ `TO [db.]name`、できます `DETACH` ビュー、実行 `ALTER` ターゲットテーブルの場合 `ATTACH` 以前に切り離さ (`DETACH`)ビュー。 - -ビューの外観は、通常のテーブルと同じです。 例えば、それらはの結果にリストされています `SHOW TABLES` クエリ。 - -ビューを削除するための別のクエリはありません。 ビューを削除するには `DROP TABLE`. - -## CREATE DICTIONARY {#create-dictionary-query} - -``` sql -CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] -( - key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - attr1 type2 [DEFAULT|EXPRESSION expr3], - attr2 type2 [DEFAULT|EXPRESSION expr4] -) -PRIMARY KEY key1, key2 -SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) -LAYOUT(LAYOUT_NAME([param_name param_value])) -LIFETIME([MIN val1] MAX val2) -``` - -作成 [外部辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) 与えられると [構造](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md), [ソース](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md), [レイアウト](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md) と [寿命](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md). - -外部辞書構造の属性です。 ディクショナリ属性は、表の列と同様に指定します。 唯一の必須の属性は、そのタイプ、その他すべてのプロパティがデフォルト値がある。 - -辞書に応じて [レイアウト](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md) 一つ以上の属性は、辞書キーとして指定することができます。 - -詳細については、 [外部辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) セクション。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/create/) diff --git a/docs/ja/sql_reference/statements/index.md b/docs/ja/sql_reference/statements/index.md deleted file mode 100644 index a2246679149..00000000000 --- a/docs/ja/sql_reference/statements/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Statements -toc_priority: 31 ---- - - diff --git a/docs/ja/sql_reference/statements/insert_into.md b/docs/ja/sql_reference/statements/insert_into.md deleted file mode 100644 index f9e7922cd77..00000000000 --- a/docs/ja/sql_reference/statements/insert_into.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 34 -toc_title: INSERT INTO ---- - -## INSERT {#insert} - -データの追加。 - -基本的なクエリ形式: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... -``` - -クエリでは、挿入する列のリストを指定できます `[(c1, c2, c3)]`. この場合、残りの列は次のように入力されます: - -- から計算された値 `DEFAULT` テーブル定義で指定された式。 -- ゼロと空の文字列の場合 `DEFAULT` 式は定義されていません。 - -もし [strict\_insert\_defaults=1](../../operations/settings/settings.md)、持っていない列 `DEFAULT` definedは、クエリに一覧表示する必要があります。 - -データは、任意の挿入物に渡すことができます [書式](../../interfaces/formats.md#formats) ClickHouseでサポートされている。 形式は、クエリで明示的に指定する必要があります: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set -``` - -For example, the following query format is identical to the basic version of INSERT … VALUES: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... -``` - -ClickHouseは、データの前にすべてのスペースと改行(存在する場合)を削除します。 クエリを作成するときは、クエリ演算子の後に新しい行にデータを置くことをお勧めします(データがスペースで始まる場合は重要です)。 - -例えば: - -``` sql -INSERT INTO t FORMAT TabSeparated -11 Hello, world! -22 Qwerty -``` - -挿入することができます。データから別のクエリのコマンドラインクライアント、httpインターフェース。 詳細については、以下を参照してください “[界面](../../interfaces/index.md#interfaces)”. - -### 制約 {#constraints} - -テーブルが [制約](create.md#constraints), their expressions will be checked for each row of inserted data. If any of those constraints is not satisfied — server will raise an exception containing constraint name and expression, the query will be stopped. - -### の結果を挿入する `SELECT` {#insert_query_insert-select} - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... -``` - -列は、select句内の位置に応じてマップされます。 ただし、select式とinsertのテーブルの名前は異なる場合があります。 必要に応じて、タイプ鋳造が行われる。 - -値以外のデータ形式では、次のような式に値を設定できません `now()`, `1 + 2`、というように。 この場合、非効率的なコードが実行に使用されるためです。 - -その他のクエリをデータ部品に対応していない: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. -ただし、次の方法で古いデータを削除できます `ALTER TABLE ... DROP PARTITION`. - -`FORMAT` 次の場合、クエリの最後に句を指定する必要があります `SELECT` テーブル関数を含む句 [入力()](../table_functions/input.md). - -### パフォーマン {#performance-considerations} - -`INSERT` 入力データを主キーでソートし、パーティションキーでパーティションに分割します。 た場合のデータを挿入し複数の仕切りは一度で大幅に低減できることの `INSERT` クエリ。 これを避けるには: - -- 一度に100,000行など、かなり大きなバッチでデータを追加します。 -- グループによるデータのパーティション鍵のアップロード前にでclickhouse. - -性能が減少することはありませんが: - -- データはリアルタイムで追加されます。 -- アップロードしたデータとは、通常はソートされました。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/ja/sql_reference/statements/misc.md b/docs/ja/sql_reference/statements/misc.md deleted file mode 100644 index 217f76d6621..00000000000 --- a/docs/ja/sql_reference/statements/misc.md +++ /dev/null @@ -1,252 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u305D\u306E\u4ED6" ---- - -# その他のクエリ {#miscellaneous-queries} - -## ATTACH {#attach} - -このクエリは `CREATE`、しかし - -- 単語の代わりに `CREATE` それは単語を使用します `ATTACH`. -- クエリはディスク上にデータを作成しませんが、データがすでに適切な場所にあるとみなし、テーブルに関する情報をサーバーに追加するだけです。 - 添付クエリを実行すると、サーバーはテーブルの存在を知ることになります。 - -テーブルが以前に分離されていた場合 (`DETACH`)、その構造が知られていることを意味し、構造を定義することなく省略形を使用することができます。 - -``` sql -ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] -``` - -このクエリは、サーバーの起動時に使用されます。 サーバーに店舗のテーブルメタデータとしてファイル `ATTACH` クエリは、起動時に実行されるだけです(サーバー上に明示的に作成されたシステムテーブルは例外です)。 - -## CHECK TABLE {#check-table} - -Trueの場合、ただちにパージを行うデータをテーブルが壊れる可能性があります。 - -``` sql -CHECK TABLE [db.]name -``` - -その `CHECK TABLE` queryは、実際のファイルサイズをサーバーに格納されている期待値と比較します。 ファイルサイズが格納された値と一致しない場合は、データが破損していることを意味します。 このが発生する可能性があります、例えば、システムがクラッシュ時のクエリを実行します。 - -のクエリーの応答を含む `result` 単一行の列。 行に値がのあります -[ブール値](../../sql_reference/data_types/boolean.md) タイプ: - -- 0-テーブル内のデータが破損しています。 -- 1-データは整合性を維持します。 - -その `CHECK TABLE` クエリは以下のテーブルエンジン: - -- [ログ](../../engines/table_engines/log_family/log.md) -- [TinyLog](../../engines/table_engines/log_family/tinylog.md) -- [ストリップログ](../../engines/table_engines/log_family/stripelog.md) -- [マージツリーファミリー](../../engines/table_engines/mergetree_family/mergetree.md) - -これは、テーブルが別のテーブルエンジンの原因となる例外です。 - -からのエンジン `*Log` 家族は失敗の自動データ回復を提供しない。 を使用 `CHECK TABLE` タイムリーにデータ損失を追跡するためのクエリ。 - -のために `MergeTree` 家族のエンジンは、 `CHECK TABLE` クエリを示すステータス確認のための個人データのテーブルに現地サーバーです。 - -**データが破損している場合** - -テーブルが破損している場合は、破損していないデータを別のテーブルにコピーできます。 これを行うには: - -1. 破損したテーブルと同じ構造の新しいテーブルを作成します。 このためクセスしてください `CREATE TABLE AS `. -2. セットを [max\_threads](../../operations/settings/settings.md#settings-max_threads) 単一のスレッドで次のクエリを処理するには、1の値を指定します。 これを行うにはクエリを実行します `SET max_threads = 1`. -3. クエリの実行 `INSERT INTO SELECT * FROM `. この要求にコピーする非破損データからの表-別表に示す。 破損した部分の前のデータのみがコピーされます。 -4. 再起動する `clickhouse-client` リセットするには `max_threads` 値。 - -## DESCRIBE TABLE {#misc-describe-table} - -``` sql -DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -以下を返します `String` タイプ列: - -- `name` — Column name. -- `type`— Column type. -- `default_type` — Clause that is used in [既定の式](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` または `ALIAS`). 既定の式が指定されていない場合、Columnには空の文字列が含まれます。 -- `default_expression` — Value specified in the `DEFAULT` 句。 -- `comment_expression` — Comment text. - -入れ子にされたデータ構造は “expanded” フォーマット。 各列は別々に表示され、名前はドットの後に続きます。 - -## DETACH {#detach} - -に関する情報を削除します。 ‘name’ サーバーからのテーブル。 サーバーはテーブルの存在を知ることをやめます。 - -``` sql -DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -テーブルのデータやメタデータは削除されません。 次のサーバーの起動時に、サーバーはメタデータを読み取り、再度テーブルについて調べます。 -同様に、 “detached” 表はを使用して再付けることができます `ATTACH` クエリ(メタデータが格納されていないシステムテーブルを除く)。 - -ありません `DETACH DATABASE` クエリ。 - -## DROP {#drop} - -このクエ: `DROP DATABASE` と `DROP TABLE`. - -``` sql -DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] -``` - -内部のすべてのテーブルを削除 ‘db’ データベース、その後削除 ‘db’ データベース自体。 -もし `IF EXISTS` データベースが存在しない場合、エラーは返されません。 - -``` sql -DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -テーブルを削除します。 -もし `IF EXISTS` テーブルが存在しない場合、またはデータベースが存在しない場合は、エラーを返しません。 - - DROP DICTIONARY [IF EXISTS] [db.]name - -辞書をdeletsします。 -もし `IF EXISTS` テーブルが存在しない場合、またはデータベースが存在しない場合は、エラーを返しません。 - -## EXISTS {#exists} - -``` sql -EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] -``` - -シングルを返します `UInt8`-単一の値を含むタイプの列 `0` テーブルまたはデータベースが存在しない場合、または `1` 指定されたデータベースにテーブルが存在する場合。 - -## KILL QUERY {#kill-query} - -``` sql -KILL QUERY [ON CLUSTER cluster] - WHERE - [SYNC|ASYNC|TEST] - [FORMAT format] -``` - -現在実行中のクエリを強制的に終了しようとします。 -終了するクエリは、システムから選択されます。プロセステーブルで定義された基準を使用して、 `WHERE` の句 `KILL` クエリ。 - -例: - -``` sql --- Forcibly terminates all queries with the specified query_id: -KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - --- Synchronously terminates all queries run by 'username': -KILL QUERY WHERE user='username' SYNC -``` - -読み取り専用ユーザーは、自分のクエリのみを停止できます。 - -既定では、非同期バージョンのクエリが使用されます (`ASYNC`)、クエリが停止したことの確認を待つことはありません。 - -同期バージョン (`SYNC`)待機のためのすべての問い合わせに対応停止に関する情報を表示し各工程で停止します。 -応答には、 `kill_status` 次の値を取ることができる列: - -1. ‘finished’ – The query was terminated successfully. -2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. -3. The other values ​​explain why the query can't be stopped. - -テストクエリ (`TEST`)ユーザーの権限のみをチェックし、停止するクエリのリストを表示します。 - -## KILL MUTATION {#kill-mutation} - -``` sql -KILL MUTATION [ON CLUSTER cluster] - WHERE - [TEST] - [FORMAT format] -``` - -キャンセルと削除を試みます [突然変異](alter.md#alter-mutations) これは現在実行中です。 取り消すべき突然変異はから選ばれます [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) テーブルのフィルタで指定された `WHERE` の句 `KILL` クエリ。 - -テストクエリ (`TEST`)ユーザーの権限のみをチェックし、停止するクエリのリストを表示します。 - -例: - -``` sql --- Cancel and remove all mutations of the single table: -KILL MUTATION WHERE database = 'default' AND table = 'table' - --- Cancel the specific mutation: -KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' -``` - -The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). - -突然変異によって既に行われた変更はロールバックされません。 - -## OPTIMIZE {#misc_operations-optimize} - -``` sql -OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] -``` - -このクエリを初期化予定外の統合データのパーツを使ったテーブルのテーブルエンジンからの [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) 家族 - -その `OPTMIZE` クエリもサポートされています [MaterializedView](../../engines/table_engines/special/materializedview.md) そして [バッファ](../../engines/table_engines/special/buffer.md) エンジン その他のテーブルエンジンなサポート。 - -とき `OPTIMIZE` とともに使用されます [レプリケートされたmergetree](../../engines/table_engines/mergetree_family/replication.md) テーブルエンジンのファミリ、ClickHouseはマージのためのタスクを作成し、すべてのノードでの実行を待ちます。 `replication_alter_partitions_sync` 設定が有効になっています)。 - -- もし `OPTIMIZE` 何らかの理由でマージを実行せず、クライアントに通知しません。 通知を有効にするには、以下を使用します [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop) 設定。 -- を指定した場合 `PARTITION` 指定したパーティションのみが最適化されます。 [パーティション式の設定方法](alter.md#alter-how-to-specify-part-expr). -- 指定した場合 `FINAL`、最適化は、すべてのデータがすでに一つの部分にある場合でも行われる。 -- 指定した場合 `DEDUPLICATE`、その後、完全に同一の行が重複排除されます(すべての列が比較されます)、それだけでMergeTreeエンジンのために理にかなっています。 - -!!! warning "警告" - `OPTIMIZE` 修正できません “Too many parts” エラー。 - -## RENAME {#misc_operations-rename} - -テーブルの名前を変更します。 - -``` sql -RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] -``` - -すべてのテーブル名変更"グローバルチェンジにおけるロックしなければなりません。 テーブルの名前を変更するのは簡単な操作です。 場合は正しく表示す他のデータベースのテーブルに表示されるようになります。本データベースです。 しかし、そのディレクトリのデータベースに格納してある必要がある同一ファイルシステム(それ以外の場合、エラーを返す。 - -## SET {#query-set} - -``` sql -SET param = value -``` - -割り当て `value` に `param` [設定](../../operations/settings/index.md) 現在のセッションの場合。 変更はできません [サーバー設定](../../operations/server_configuration_parameters/index.md) こっちだ - -また、指定した設定プロファイルのすべての値を単一のクエリで設定することもできます。 - -``` sql -SET profile = 'profile-name-from-the-settings-file' -``` - -詳細については、 [設定](../../operations/settings/settings.md). - -## TRUNCATE {#truncate} - -``` sql -TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -表からすべてのデータを削除します。 ときに句 `IF EXISTS` テーブルが存在しない場合、クエリはエラーを返します。 - -その `TRUNCATE` queryはサポートされていません [ビュー](../../engines/table_engines/special/view.md), [ファイル](../../engines/table_engines/special/file.md), [URL](../../engines/table_engines/special/url.md) と [ヌル](../../engines/table_engines/special/null.md) テーブルエンジン。 - -## USE {#use} - -``` sql -USE db -``` - -セッションの現在のデータベースを設定できます。 -現在のデータベース検索用テーブルの場合はデータベースが明示的に定義されたクエリードの前にテーブルの名前です。 -このクエリできません利用の場合は、httpプロトコルが存在しない概念です。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/ja/sql_reference/statements/select.md b/docs/ja/sql_reference/statements/select.md deleted file mode 100644 index 7775b2f7cdc..00000000000 --- a/docs/ja/sql_reference/statements/select.md +++ /dev/null @@ -1,610 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 33 -toc_title: SELECT ---- - -# クエリ構文の選択 {#select-queries-syntax} - -`SELECT` データ検索を実行します。 - -``` sql -[WITH expr_list|(subquery)] -SELECT [DISTINCT] expr_list -[FROM [db.]table | (subquery) | table_function] [FINAL] -[SAMPLE sample_coeff] -[ARRAY JOIN ...] -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list -[PREWHERE expr] -[WHERE expr] -[GROUP BY expr_list] [WITH TOTALS] -[HAVING expr] -[ORDER BY expr_list] -[LIMIT [offset_value, ]n BY columns] -[LIMIT [n, ]m] -[UNION ALL ...] -[INTO OUTFILE filename] -[FORMAT format] -``` - -SELECT直後の必須の式リストを除き、すべての句はオプションです。 -以下の句は、クエリ実行コンベアとほぼ同じ順序で記述されています。 - -クエリが省略された場合、 `DISTINCT`, `GROUP BY` と `ORDER BY` 句および `IN` と `JOIN` サブクエリでは、クエリはO(1)量のRAMを使用して完全にストリーム処理されます。 -それ以外の場合、適切な制限が指定されていない場合、クエリは大量のramを消費する可能性があります: `max_memory_usage`, `max_rows_to_group_by`, `max_rows_to_sort`, `max_rows_in_distinct`, `max_bytes_in_distinct`, `max_rows_in_set`, `max_bytes_in_set`, `max_rows_in_join`, `max_bytes_in_join`, `max_bytes_before_external_sort`, `max_bytes_before_external_group_by`. 詳細については、以下を参照してください “Settings”. 外部ソート(一時テーブルをディスクに保存する)と外部集約を使用することが可能です。 `The system does not have "merge join"`. - -### With句 {#with-clause} - -このセクション支援のための共通表現 ([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL))、いくつかの制限があります: -1. 再帰的な問合せには対応していない -2. サブクエリがsection内で使用される場合、その結果は正確に一つの行を持つスカラーになります -3. 式の結果はサブクエリでは使用できません -WITH句の式の結果は、SELECT句の中で使用できます。 - -例1:定数式をasとして使用する “variable” - -``` sql -WITH '2019-08-01 15:23:00' as ts_upper_bound -SELECT * -FROM hits -WHERE - EventDate = toDate(ts_upper_bound) AND - EventTime <= ts_upper_bound -``` - -例2:select句の列リストからsum(bytes)式の結果を削除する - -``` sql -WITH sum(bytes) as s -SELECT - formatReadableSize(s), - table -FROM system.parts -GROUP BY table -ORDER BY s -``` - -例3:結果のスカラサブクエリ - -``` sql -/* this example would return TOP 10 of most huge tables */ -WITH - ( - SELECT sum(bytes) - FROM system.parts - WHERE active - ) AS total_disk_usage -SELECT - (sum(bytes) / total_disk_usage) * 100 AS table_disk_usage, - table -FROM system.parts -GROUP BY table -ORDER BY table_disk_usage DESC -LIMIT 10 -``` - -例4:サブクエリでの式の再利用 -サブクエリでの式の現在の使用制限の回避策として、複製することができます。 - -``` sql -WITH ['hello'] AS hello -SELECT - hello, - * -FROM -( - WITH ['hello'] AS hello - SELECT hello -) -``` - -``` text -┌─hello─────┬─hello─────┐ -│ ['hello'] │ ['hello'] │ -└───────────┴───────────┘ -``` - -### FROM句 {#select-from} - -FROM句が省略された場合、データは `system.one` テーブル。 -その `system.one` このテーブルは、他のDbmsで見つかったデュアルテーブルと同じ目的を果たします。 - -その `FROM` 句は、データを読み取るソースを指定します: - -- テーブル -- サブクエリ -- [テーブル機能](../table_functions/index.md) - -`ARRAY JOIN` そして、定期的に `JOIN` また、(下記参照)が含まれていてもよいです。 - -テーブルの代わりに、 `SELECT` サブクエリは、かっこで指定できます。 -標準sqlとは対照的に、サブクエリの後にシノニムを指定する必要はありません。 - -実行をクエリに対して、すべての列をクエリを取り出しに適します。 任意の列は不要のため、外部クエリはスローされ、サブクエリ. -クエリで列がリストされない場合(たとえば, `SELECT count() FROM t`)行の数を計算するために、いくつかの列がテーブルから抽出されます(最小の列が優先されます)。 - -#### 最終修飾子 {#select-from-final} - -が異なる場合は、それぞれの選定からデータをテーブルからの [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)-エンジンファミリー以外 `GraphiteMergeTree`. とき `FINAL` 指定されている場合、ClickHouseは結果を返す前にデータを完全にマージするため、指定されたテーブルエンジンのマージ中に発生するすべてのデータ変換を実行し - -また、: -- [複製された](../../engines/table_engines/mergetree_family/replication.md) のバージョン `MergeTree` エンジン -- [ビュー](../../engines/table_engines/special/view.md), [バッファ](../../engines/table_engines/special/buffer.md), [分散](../../engines/table_engines/special/distributed.md)、と [MaterializedView](../../engines/table_engines/special/materializedview.md) 他のエンジンを操作するエンジンは、それらが上に作成された提供 `MergeTree`-エンジンテーブル。 - -使用するクエリ `FINAL` そうでない類似のクエリと同じくらい速く実行されません。: - -- クエリは単一のスレッドで実行され、クエリの実行中にデータがマージされます。 -- とのクエリ `FINAL` クエリで指定された列に加えて、主キー列を読み取ります。 - -ほとんどの場合、使用を避けます `FINAL`. - -### サンプル句 {#select-sample-clause} - -その `SAMPLE` 句は、近似クエリ処理を可能にします。 - -データサンプリングを有効にすると、すべてのデータに対してクエリは実行されず、特定のデータ(サンプル)に対してのみ実行されます。 たとえば、すべての訪問の統計を計算する必要がある場合は、すべての訪問の1/10分のクエリを実行し、その結果に10を掛けるだけで十分です。 - -近似クエリ処理は、次の場合に役立ちます: - -- 厳密なタイミング要件(\<100ms)がありますが、それらを満たすために追加のハードウェアリソースのコストを正当化できない場合。 -- 生データが正確でない場合、近似は品質を著しく低下させません。 -- ビジネス要件は、おおよその結果(費用対効果のため、または正確な結果をプレミアムユーザーに販売するため)を対象とします。 - -!!! note "メモ" - サンプリングを使用できるのは、次の表のみです [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) テーブル作成時にサンプリング式が指定された場合にのみ [MergeTreeエンジン](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table)). - -データサンプリングの機能を以下に示します: - -- データサンプリングは確定的なメカニズムです。 同じの結果 `SELECT .. SAMPLE` クエリは常に同じです。 -- サンプリン テーブルに単一のサンプリングキーは、サンプルと同じ係数を常に選択と同じサブセットのデータです。 たとえば、ユーザー idのサンプルでは、異なるテーブルのすべてのユーザー idのサブセットが同じ行になります。 これは、サブクエリでサンプルを使用できることを意味します [IN](#select-in-operators) 句。 また、以下を使用してサンプルを結合できます [JOIN](#select-join) 句。 -- サンプリングで読み下からのデータディスク。 サンプリングキーを正しく指定する必要があります。 詳細については、 [MergeTreeテーブルの作成](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). - -のための `SAMPLE` 句次の構文がサポートされています: - -| SAMPLE Clause Syntax | 説明 | -|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `SAMPLE k` | ここに `k` 0から1までの数値です。
クエリが実行される `k` データの割合。 例えば, `SAMPLE 0.1` データの10%に対してクエリを実行します。 [もっと読む](#select-sample-k) | -| `SAMPLE n` | ここに `n` は十分に大きい整数です。
クエリは、少なくとものサンプルで実行されます `n` 行(しかし、これ以上のものではない)。 例えば, `SAMPLE 10000000` 最小10,000,000行に対してクエリを実行します。 [もっと読む](#select-sample-n) | -| `SAMPLE k OFFSET m` | ここに `k` と `m` 0から1までの数字です。
クエリは次のサンプルで実行されます `k` データの割合。 に使用されるデータのサンプルと相殺することにより `m` 分数。 [もっと読む](#select-sample-offset) | - -#### SAMPLE K {#select-sample-k} - -ここに `k` は0から1までの数値です(小数表記と小数表記の両方がサポートされています)。 例えば, `SAMPLE 1/2` または `SAMPLE 0.5`. - -で `SAMPLE k` 句は、サンプルから取られます `k` データの割合。 例を以下に示します: - -``` sql -SELECT - Title, - count() * 10 AS PageViews -FROM hits_distributed -SAMPLE 0.1 -WHERE - CounterID = 34 -GROUP BY Title -ORDER BY PageViews DESC LIMIT 1000 -``` - -この例では、0.1(10%)のデータのサンプルでクエリが実行されます。 集計関数の値は自動的には修正されないので、おおよその結果を得るには値 `count()` 手動で10倍します。 - -#### SAMPLE N {#select-sample-n} - -ここに `n` は十分に大きい整数です。 例えば, `SAMPLE 10000000`. - -この場合、クエリは少なくともサンプルで実行されます `n` 行(しかし、これ以上のものではない)。 例えば, `SAMPLE 10000000` 最小10,000,000行に対してクエリを実行します。 - -データ読み取りのための最小単位は一つの顆粒であるため(そのサイズは `index_granularity` それは、顆粒のサイズよりもはるかに大きいサンプルを設定することは理にかなっています。 - -を使用する場合 `SAMPLE n` 句、データの相対パーセントが処理されたかわからない。 したがって、集計関数に掛ける係数はわかりません。 を使用 `_sample_factor` おおよその結果を得るための仮想列。 - -その `_sample_factor` 列には、動的に計算される相対係数が含まれます。 この列は、次の場合に自動的に作成されます [作成](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table) 指定したサンプリングキーを持つテーブル。 の使用例 `_sample_factor` 列は以下の通りです。 - -テーブルを考えてみましょう `visits` これには、サイト訪問に関する統計情報が含まれます。 最初の例は、ページビューの数を計算する方法を示しています: - -``` sql -SELECT sum(PageViews * _sample_factor) -FROM visits -SAMPLE 10000000 -``` - -次の例では、訪問回数の合計を計算する方法を示します: - -``` sql -SELECT sum(_sample_factor) -FROM visits -SAMPLE 10000000 -``` - -以下の例は、平均セッション期間を計算する方法を示しています。 相対係数を使用して平均値を計算する必要はありません。 - -``` sql -SELECT avg(Duration) -FROM visits -SAMPLE 10000000 -``` - -#### SAMPLE K OFFSET M {#select-sample-offset} - -ここに `k` と `m` は0から1までの数字です。 例を以下に示す。 - -**例1** - -``` sql -SAMPLE 1/10 -``` - -この例では、サンプルはすべてのデータの1/10thです: - -`[++------------]` - -**例2** - -``` sql -SAMPLE 1/10 OFFSET 1/2 -``` - -ここでは、データの後半から10%のサンプルを採取します。 - -`[------++------]` - -### 配列結合句 {#select-array-join-clause} - -実行を許可する `JOIN` 配列または入れ子になったデータ構造。 その意図は、 [arrayJoin](../../sql_reference/functions/array_join.md#functions_arrayjoin) 機能が、その機能はより広いです。 - -``` sql -SELECT -FROM -[LEFT] ARRAY JOIN -[WHERE|PREWHERE ] -... -``` - -単一のみを指定できます `ARRAY JOIN` クエリ内の句。 - -実行時にクエリの実行順序が最適化されます `ARRAY JOIN`. が `ARRAY JOIN` の前に必ず指定する必要があります。 `WHERE/PREWHERE` のいずれかを実行することができます。 `WHERE/PREWHERE` (結果がこの節で必要な場合)、またはそれを完了した後(計算量を減らすため)。 処理順序はクエリオプティマイザによって制御されます。 - -サポートされる種類の `ARRAY JOIN` は以下の通りです: - -- `ARRAY JOIN` -この場合、空の配列は結果に含まれません `JOIN`. -- `LEFT ARRAY JOIN` -結果の `JOIN` 空の配列を含む行を含みます。 空の配列の値は、配列要素タイプのデフォルト値に設定されます(通常は0、空の文字列またはNULL)。 - -以下の例は、以下の使用例を示しています。 `ARRAY JOIN` と `LEFT ARRAY JOIN` 句。 テーブルを作成してみましょう [配列](../../sql_reference/data_types/array.md) 列を入力して値を挿入します: - -``` sql -CREATE TABLE arrays_test -( - s String, - arr Array(UInt8) -) ENGINE = Memory; - -INSERT INTO arrays_test -VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []); -``` - -``` text -┌─s───────────┬─arr─────┐ -│ Hello │ [1,2] │ -│ World │ [3,4,5] │ -│ Goodbye │ [] │ -└─────────────┴─────────┘ -``` - -以下の例では、 `ARRAY JOIN` 句: - -``` sql -SELECT s, arr -FROM arrays_test -ARRAY JOIN arr; -``` - -``` text -┌─s─────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -└───────┴─────┘ -``` - -次の例では、 `LEFT ARRAY JOIN` 句: - -``` sql -SELECT s, arr -FROM arrays_test -LEFT ARRAY JOIN arr; -``` - -``` text -┌─s───────────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -│ Goodbye │ 0 │ -└─────────────┴─────┘ -``` - -#### エイリアスの使用 {#using-aliases} - -配列のエイリアスを指定することができます。 `ARRAY JOIN` 句。 この場合、配列項目はこのエイリアスでアクセスできますが、配列自体は元の名前でアクセスされます。 例えば: - -``` sql -SELECT s, arr, a -FROM arrays_test -ARRAY JOIN arr AS a; -``` - -``` text -┌─s─────┬─arr─────┬─a─┐ -│ Hello │ [1,2] │ 1 │ -│ Hello │ [1,2] │ 2 │ -│ World │ [3,4,5] │ 3 │ -│ World │ [3,4,5] │ 4 │ -│ World │ [3,4,5] │ 5 │ -└───────┴─────────┴───┘ -``` - -別名を使用すると、次の操作を実行できます `ARRAY JOIN` 外部配列を使用する。 例えば: - -``` sql -SELECT s, arr_external -FROM arrays_test -ARRAY JOIN [1, 2, 3] AS arr_external; -``` - -``` text -┌─s───────────┬─arr_external─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ Hello │ 3 │ -│ World │ 1 │ -│ World │ 2 │ -│ World │ 3 │ -│ Goodbye │ 1 │ -│ Goodbye │ 2 │ -│ Goodbye │ 3 │ -└─────────────┴──────────────┘ -``` - -複数の配列をコンマで区切ることができます。 `ARRAY JOIN` 句。 この場合, `JOIN` それらと同時に実行されます(直積ではなく、直積)。 すべての配列は同じサイズでなければなりません。 例えば: - -``` sql -SELECT s, arr, a, num, mapped -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ -│ Hello │ [1,2] │ 1 │ 1 │ 2 │ -│ Hello │ [1,2] │ 2 │ 2 │ 3 │ -│ World │ [3,4,5] │ 3 │ 1 │ 4 │ -│ World │ [3,4,5] │ 4 │ 2 │ 5 │ -│ World │ [3,4,5] │ 5 │ 3 │ 6 │ -└───────┴─────────┴───┴─────┴────────┘ -``` - -以下の例では、 [arrayEnumerate](../../sql_reference/functions/array_functions.md#array_functions-arrayenumerate) 機能: - -``` sql -SELECT s, arr, a, num, arrayEnumerate(arr) -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ -│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ -│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ -│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ -│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ -│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ -└───────┴─────────┴───┴─────┴─────────────────────┘ -``` - -#### 配列の参加入れ子データ構造 {#array-join-with-nested-data-structure} - -`ARRAY`また、"参加"で動作します [入れ子のデータ構造](../../sql_reference/data_types/nested_data_structures/nested.md). 例えば: - -``` sql -CREATE TABLE nested_test -( - s String, - nest Nested( - x UInt8, - y UInt32) -) ENGINE = Memory; - -INSERT INTO nested_test -VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []); -``` - -``` text -┌─s───────┬─nest.x──┬─nest.y─────┐ -│ Hello │ [1,2] │ [10,20] │ -│ World │ [3,4,5] │ [30,40,50] │ -│ Goodbye │ [] │ [] │ -└─────────┴─────────┴────────────┘ -``` - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -ネストされたデータ構造の名前を指定する場合 `ARRAY JOIN`、意味は同じです `ARRAY JOIN` それが構成されているすべての配列要素。 例を以下に示します: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`, `nest.y`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -この変化はまた意味を成している: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─────┐ -│ Hello │ 1 │ [10,20] │ -│ Hello │ 2 │ [10,20] │ -│ World │ 3 │ [30,40,50] │ -│ World │ 4 │ [30,40,50] │ -│ World │ 5 │ [30,40,50] │ -└───────┴────────┴────────────┘ -``` - -エイリアスは、ネストされたデータ構造のために使用することができます。 `JOIN` 結果またはソース配列。 例えば: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest AS n; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ -└───────┴─────┴─────┴─────────┴────────────┘ -``` - -使用例 [arrayEnumerate](../../sql_reference/functions/array_functions.md#array_functions-arrayenumerate) 機能: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num -FROM nested_test -ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ -└───────┴─────┴─────┴─────────┴────────────┴─────┘ -``` - -### JOIN句 {#select-join} - -通常のデータを結合します [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) センス - -!!! info "メモ" - 関連しない [ARRAY JOIN](#select-array-join-clause). - -``` sql -SELECT -FROM -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN -(ON )|(USING ) ... -``` - -テーブル名は次の代わりに指定できます `` と ``. これは、 `SELECT * FROM table` サブクエリは、テーブルが次のものを持つ特殊な場合を除きます。 [参加](../../engines/table_engines/special/join.md) engine – an array prepared for joining. - -#### サポートされる種類の `JOIN` {#select-join-types} - -- `INNER JOIN` (または `JOIN`) -- `LEFT JOIN` (または `LEFT OUTER JOIN`) -- `RIGHT JOIN` (または `RIGHT OUTER JOIN`) -- `FULL JOIN` (または `FULL OUTER JOIN`) -- `CROSS JOIN` (または `,` ) - -標準を参照してください [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) 説明。 - -#### 複数の結合 {#multiple-join} - -クエリを実行すると、clickhouseはマルチテーブル結合を二つのテーブル結合のシーケンスに書き換えます。 たとえば、clickhouseに参加するための四つのテーブルがある場合は、最初と二番目のテーブルを結合し、その結果を三番目のテーブルに結合し、最後のステップで - -クエリが含まれている場合、 `WHERE` 句、ClickHouseはこの句から中間結合を介してプッシュダウンフィルターを試行します。 各中間結合にフィルタを適用できない場合、ClickHouseはすべての結合が完了した後にフィルタを適用します。 - -私たちはお勧め `JOIN ON` または `JOIN USING` クエリを作成するための構文。 例えば: - -``` sql -SELECT * FROM t1 JOIN t2 ON t1.a = t2.a JOIN t3 ON t1.a = t3.a -``` - -テーブルのコンマ区切りリストを使用することができます `FROM` 句。 例えば: - -``` sql -SELECT * FROM t1, t2, t3 WHERE t1.a = t2.a AND t1.a = t3.a -``` - -これらの構文を混在させないでください。 - -ClickHouseはカンマで構文を直接サポートしていないので、使用することはお勧めしません。 このアルゴ `CROSS JOIN` と `INNER JOIN` クエリ処理に進みます。 クエリを書き換えるとき、ClickHouseはパフォーマンスとメモリ消費の最適化を試みます。 デフォルトでは、ClickHouseはコンマを `INNER JOIN` 句と変換 `INNER JOIN` に `CROSS JOIN` アルゴリズムが保証できない場合 `INNER JOIN` 必要なデータを返します。 - -#### 厳密さ {#select-join-strictness} - -- `ALL` — If the right table has several matching rows, ClickHouse creates a [デカルト積](https://en.wikipedia.org/wiki/Cartesian_product) 一致する行から。 これが標準です `JOIN` SQLでの動作。 -- `ANY` — If the right table has several matching rows, only the first one found is joined. If the right table has only one matching row, the results of queries with `ANY` と `ALL` キーワードは同じです。 -- `ASOF` — For joining sequences with a non-exact match. `ASOF JOIN` 以下に使用方法を説明します。 - -**ASOF結合の使用** - -`ASOF JOIN` 完全一致のないレコードを結合する必要がある場合に便利です。 - -テーブルのため `ASOF JOIN` 順序列の列を持つ必要があります。 この列はテーブル内で単独で使用することはできません。: `UInt32`, `UInt64`, `Float32`, `Float64`, `Date`、と `DateTime`. - -構文 `ASOF JOIN ... ON`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF LEFT JOIN table_2 -ON equi_cond AND closest_match_cond -``` - -任意の数の等価条件と正確に最も近い一致条件を使用できます。 例えば, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`. - -最も近い一致でサポートされる条件: `>`, `>=`, `<`, `<=`. - -構文 `ASOF JOIN ... USING`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF JOIN table_2 -USING (equi_column1, ... equi_columnN, asof_column) -``` - -`ASOF JOIN` 使用 `equi_columnX` 平等に参加するための `asof_column` との最も近い試合に参加するための `table_1.asof_column >= table_2.asof_column` 条件。 その `asof_column` 列は常に最後の列です `USING` 句。 - -たとえば、次の表を考えてみます: - -'テキスト -テーブル1テーブル2 - -イベント/ev\_time\|user\_idイベント/ev\_time\|user\_id diff --git a/docs/ja/sql_reference/statements/show.md b/docs/ja/sql_reference/statements/show.md deleted file mode 100644 index a3c564b3522..00000000000 --- a/docs/ja/sql_reference/statements/show.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: SHOW ---- - -# クエリを表示 {#show-queries} - -## SHOW CREATE TABLE {#show-create-table} - -``` sql -SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -シングルを返します `String`-タイプ ‘statement’ column, which contains a single value – the `CREATE` 指定したオブジェク - -## SHOW DATABASES {#show-databases} - -``` sql -SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] -``` - -一覧の全てのデータベースです。 -このクエリは次と同じです `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. - -## SHOW PROCESSLIST {#show-processlist} - -``` sql -SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] -``` - -の内容を出力します [システム。プロセス](../../operations/system_tables.md#system_tables-processes) 現在処理中のクエリのリストを含むテーブル。 `SHOW PROCESSLIST` クエリ。 - -その `SELECT * FROM system.processes` クエリを返しますデータに現在のすべてのクエリ. - -ヒント(コンソールで実行): - -``` bash -$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" -``` - -## SHOW TABLES {#show-tables} - -テーブルのリストを表示します。 - -``` sql -SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -この `FROM` 句が指定されていない場合、クエリは現在のデータベースからテーブルの一覧を返します。 - -あなたは同じ結果を得ることができます `SHOW TABLES` 次の方法でクエリ: - -``` sql -SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**例えば** - -次のクエリは、テーブルのリストから最初の二つの行を選択します。 `system` 名前に含まれるデータベース `co`. - -``` sql -SHOW TABLES FROM system LIKE '%co%' LIMIT 2 -``` - -``` text -┌─name───────────────────────────┐ -│ aggregate_function_combinators │ -│ collations │ -└────────────────────────────────┘ -``` - -## SHOW DICTIONARIES {#show-dictionaries} - -リストをの表示します [外部辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -``` sql -SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -この `FROM` 句が指定されていない場合、クエリは現在のデータベースから辞書のリストを返します。 - -あなたは同じ結果を得ることができます `SHOW DICTIONARIES` 次の方法でクエリ: - -``` sql -SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**例えば** - -次のクエリは、テーブルのリストから最初の二つの行を選択します。 `system` 名前に含まれるデータベース `reg`. - -``` sql -SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 -``` - -``` text -┌─name─────────┐ -│ regions │ -│ region_names │ -└──────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/ja/sql_reference/statements/system.md b/docs/ja/sql_reference/statements/system.md deleted file mode 100644 index a54514da2a3..00000000000 --- a/docs/ja/sql_reference/statements/system.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: SYSTEM ---- - -# システムクエリ {#query-language-system} - -- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) -- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) -- [DROP DNS CACHE](#query_language-system-drop-dns-cache) -- [DROP MARK CACHE](#query_language-system-drop-mark-cache) -- [FLUSH LOGS](#query_language-system-flush_logs) -- [RELOAD CONFIG](#query_language-system-reload-config) -- [SHUTDOWN](#query_language-system-shutdown) -- [KILL](#query_language-system-kill) -- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) -- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) -- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) -- [STOP MERGES](#query_language-system-stop-merges) -- [START MERGES](#query_language-system-start-merges) - -## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} - -前に正常に読み込まれたすべての辞書を再読み込みします。 -デフォルトでは、辞書を取り込みの遅延を参照 [dictionaries\_lazy\_load](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load))、起動時に自動的にロードされるのではなく、dictGet関数を使用して最初のアクセス時に初期化されるか、ENGINE=Dictionaryテーブルから選択されます。 その `SYSTEM RELOAD DICTIONARIES` クエバなどの辞書(ロード). -常に戻る `Ok.` 辞書の更新の結果にかかわらず。 - -## 辞書dictionary\_nameを再読み込み {#query_language-system-reload-dictionary} - -辞書を完全に再読み込みする `dictionary_name` 辞書の状態にかかわらず(LOADED/NOT\_LOADED/FAILED)。 -常に戻る `Ok.` 辞書を更新した結果にかかわらず。 -ディクショナリのステータスは以下のクエリで確認できます。 `system.dictionaries` テーブル。 - -``` sql -SELECT name, status FROM system.dictionaries; -``` - -## DROP DNS CACHE {#query_language-system-drop-dns-cache} - -ClickHouseの内部DNSキャッシュをリセットします。 場合によっては(古いClickHouseバージョンの場合)、インフラストラクチャを変更するとき(別のClickHouseサーバーのIPアドレスまたは辞書で使用されるサーバーを変更する - -より便利な(自動)キャッシュ管理については、"disable\_internal\_dns\_cache,dns\_cache\_update\_periodパラメータ"を参照してください。 - -## DROP MARK CACHE {#query_language-system-drop-mark-cache} - -リセットをマークします。 clickhouseおよび性能試験の開発で使用される。 - -## FLUSH LOGS {#query_language-system-flush_logs} - -Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. - -## RELOAD CONFIG {#query_language-system-reload-config} - -ClickHouse構成を再読み込みします。 設定がZooKeeeperに格納されている場合に使用されます。 - -## SHUTDOWN {#query_language-system-shutdown} - -通常シャットダウンclickhouse(のような `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) - -## KILL {#query_language-system-kill} - -異常終了しclickhouse工程など `kill -9 {$ pid_clickhouse-server}`) - -## 分散テーブルの管理 {#query-language-system-distributed} - -ClickHouse管理 [分散](../../engines/table_engines/special/distributed.md) テーブル。 ユーザーがこれらのテーブルにデータを挿入すると、ClickHouseはまずクラスターノードに送信するデータのキューを作成し、次に非同期に送信します。 キューの処理を管理することができます [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed)、と [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) クエリ。 また、分散データを同期的に挿入することもできます。 `insert_distributed_sync` 設定。 - -### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} - -を無効にした背景データの分布を挿入する際、データを配布します。 - -``` sql -SYSTEM STOP DISTRIBUTED SENDS [db.] -``` - -### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} - -クラスタノードにデータを同期送信するようにclickhouseを強制します。 ノードが使用できない場合、clickhouseは例外をスローし、クエリの実行を停止します。 これは、すべてのノードがオンラインに戻ったときに発生します。 - -``` sql -SYSTEM FLUSH DISTRIBUTED [db.] -``` - -### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} - -を背景データの分布を挿入する際、データを配布します。 - -``` sql -SYSTEM START DISTRIBUTED SENDS [db.] -``` - -### STOP MERGES {#query_language-system-stop-merges} - -提供可能停止を背景に合併したテーブルのmergetree家族: - -``` sql -SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] -``` - -!!! note "メモ" - `DETACH / ATTACH` テーブルは、以前にすべてのMergeTreeテーブルのマージが停止された場合でも、テーブルのバックグラウンドマージを開始します。 - -### START MERGES {#query_language-system-start-merges} - -の提供が開始背景に合併したテーブルのmergetree家族: - -``` sql -SYSTEM START MERGES [[db.]merge_tree_family_table_name] -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/ja/sql_reference/syntax.md b/docs/ja/sql_reference/syntax.md deleted file mode 100644 index a3706c2f855..00000000000 --- a/docs/ja/sql_reference/syntax.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 31 -toc_title: "\u69CB\u6587" ---- - -# 構文 {#syntax} - -システムには、完全なsqlパーサー(再帰的降下パーサー)とデータフォーマットパーサー(高速ストリームパーサー)の二種類のパーサーがあります。 -を除くすべての場合において `INSERT` クエリでは、完全なSQLパーサーのみが使用されます。 -その `INSERT` クエリの両方を使用のパーサ: - -``` sql -INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') -``` - -その `INSERT INTO t VALUES` フラグメントは完全なパーサーとデータによって解析されます `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 高速ストリームパーサーによって解析されます。 データの完全なパーサーをオンにするには、次のコマンドを使用します [input\_format\_values\_interpret\_expressions](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) 設定。 とき `input_format_values_interpret_expressions = 1`、ClickHouseは最初に高速ストリームパーサーで値を解析しようとします。 失敗した場合、ClickHouseはデータの完全なパーサーを使用し、SQLのように扱います [式](#syntax-expressions). - -データには任意の形式を使用できます。 クエリが受信されると、サーバーは以下を計算します [max\_query\_size](../operations/settings/settings.md#settings-max_query_size) RAM内の要求のバイト(デフォルトでは1MB)、残りはストリーム解析されます。 -これはシステムに大きいの問題がないことを意味します `INSERT` MySQLのようなクエリ。 - -を使用する場合 `Values` フォーマット `INSERT` クエリは、データがaの式と同じように解析されるように見えるかもしれません `SELECT` クエリが、これは真実ではありません。 その `Values` 形式は、はるかに限られています。 - -次に、完全なパーサーをカバーします。 情報の形式のパーサは、 [形式](../interfaces/formats.md) セクション。 - -## スペース {#spaces} - -構文構成(クエリの開始と終了を含む)の間には、任意の数のスペースシンボルが存在する可能性があります。 スペースシンボルには、スペース、タブ、改行、cr、フォームフィードがあります。 - -## コメント {#comments} - -SQL形式およびC形式のコメントがサポートされています。 -SQLスタイルのコメント:from `--` ラインの終わりまで。 後のスペース `--` 省略可能です。 -Cスタイルのコメント:from `/*` に `*/`. これらのコメントは複数行にできます。 ここでもスペースは必要ありません。 - -## キーワード {#syntax-keywords} - -キーワードが対応する場合、大文字と小文字は区別されません: - -- SQL標準。 例えば, `SELECT`, `select` と `SeLeCt` すべて有効です。 -- いくつかの一般的なdbms(mysqlまたはpostgres)での実装。 例えば, `DateTime` は同じとして `datetime`. - -データ型名が大文字小文字を区別するかどうかをチェックできます。 `system.data_type_families` テーブル。 - -標準sqlとは対照的に、他のすべてのキーワード(関数名を含む)は **大文字と小文字を区別する**. - -キーワードはこの数は予約されていません(そうとして構文解析キーワードに対応するコンテキスト. 使用する場合 [識別子](#syntax-identifiers) キーワードと同じで、引用符で囲みます。 たとえば、クエリ `SELECT "FROM" FROM table_name` テーブルの場合は有効です。 `table_name` 名前の列があります `"FROM"`. - -## 識別子 {#syntax-identifiers} - -識別子は: - -- クラスターデータベース、テーブル、パーティションおよびカラム名になってしまいます -- 機能。 -- データ型。 -- [式の別名](#syntax-expression_aliases). - -識別子は、引用符または非引用することができます。 非引用符付き識別子を使用することをお勧めします。 - -非引用識別子に一致しなければならなregex `^[a-zA-Z_][0-9a-zA-Z_]*$` とに等しくすることはできません [キーワード](#syntax-keywords). 例: `x, _1, X_y__Z123_.` - -キーワードと同じ識別子を使用する場合、または識別子に他の記号を使用する場合は、二重引用符またはバッククォートを使用して引用符を引用します。, `"id"`, `` `id` ``. - -## リテラル {#literals} - -以下があります:数値、文字列、複合および `NULL` リテラル - -### 数値 {#numeric} - -数値リテラルは解析を試みます: - -- 最初に64ビットの符号付き数値として、 [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul) 機能。 -- 失敗した場合、64ビット符号なしの数値として、 [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) 機能。 -- 失敗した場合は、浮動小数点数として [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) 機能。 -- それ以外の場合は、エラーが返されます。 - -対応する値は、値が収まる最小の型を持ちます。 -たとえば、1は次のように解析されます `UInt8` しかし、256は次のように解析されます `UInt16`. 詳細については、 [データ型](../sql_reference/data_types/index.md). - -例: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. - -### 文字列 {#syntax-string-literal} - -単一引quotesの文字列リテラルのみがサポートされます。 囲まれた文字はバックスラッシュでエスケープできます。 以下のエスケープシーケンスに対応する特殊な値: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. 他のすべての場合において、エスケープシーケンスの形式 `\c`、どこ `c` は任意の文字です。 `c`. つまり、次のシーケンスを使用できます `\'`と`\\`. この値は、 [文字列](../sql_reference/data_types/string.md) タイプ。 - -文字列リテラルでエスケープする必要がある文字の最小セット: `'` と `\`. 単一引quoteは、単一引quoteでエスケープすることができます。 `'It\'s'` と `'It''s'` 等しい。 - -### 化合物 {#compound} - -配列では構文がサポートされます: `[1, 2, 3]` とタプル: `(1, 'Hello, world!', 2)`.. -実際には、これらはリテラルではなく、配列作成演算子とタプル作成演算子を持つ式です。 -配列によって構成された少なくとも一つの項目には、タプル以上あることが必要です。石二鳥の優れものだ。 -タプルに使用のための特別な目的があります `IN` aの句 `SELECT` クエリ。 タプルはクエリの結果として取得できますが、データベースに保存することはできません(ただし、 [メモリ](../engines/table_engines/special/memory.md) テーブル)。 - -### NULL {#null-literal} - -値が欠落していることを示します。 - -を格納するために `NULL` テーブルフィールドでは、テーブルフィールド [Nullable](../sql_reference/data_types/nullable.md) タイプ。 - -データ形式(入力または出力)に応じて), `NULL` 異なる表現を持つことがあります。 詳細については、以下の文書を参照してください [データ形式](../interfaces/formats.md#formats). - -処理には多くの微妙な違いがあります `NULL`. たとえば、比較操作の引数のうちの少なくとも一つが `NULL` この操作の結果も次のようになります `NULL`. 乗算、加算、およびその他の演算についても同様です。 詳細については、各操作のドキュメントを参照してください。 - -クエリでは、以下を確認できます `NULL` を使用して [IS NULL](operators.md#operator-is-null) と [IS NOT NULL](operators.md) 演算子と関連する関数 `isNull` と `isNotNull`. - -## 機能 {#functions} - -関数は、括弧内の引数のリスト(おそらく空)を持つ識別子のように書かれています。 標準sqlとは対照的に、空の引数リストであっても括弧が必要です。 例えば: `now()`. -通常の関数と集計関数があります(セクションを参照 “Aggregate functions”). 一部の集計関数を含むことができ二つのリストの引数ットに固定して使用します。 例えば: `quantile (0.9) (x)`. これらの集計関数が呼び出される “parametric” 関数と最初のリストの引数が呼び出されます “parameters”. パラメータを指定しない集計関数の構文は、通常の関数と同じです。 - -## 演算子 {#operators} - -演算子は、優先度と結合性を考慮して、クエリの解析中に対応する関数に変換されます。 -たとえば、次の式 `1 + 2 * 3 + 4` に変換される。 `plus(plus(1, multiply(2, 3)), 4)`. - -## データ型とデータベ {#data_types-and-database-table-engines} - -のデータ型とテーブルエンジン `CREATE` クエリは、識別子または関数と同じ方法で記述されます。 言い換えれば、それらは括弧内に引数リストを含んでいてもいなくてもよい。 詳細については、以下を参照してください “Data types,” “Table engines,” と “CREATE”. - -## 式の別名 {#syntax-expression_aliases} - -別名は、クエリ内の式のユーザー定義名です。 - -``` sql -expr AS alias -``` - -- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` 使用しない句 `AS` キーワード。 - - For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. - - In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. - -- `expr` — Any expression supported by ClickHouse. - - For example, `SELECT column_name * 2 AS double FROM some_table`. - -- `alias` — Name for `expr`. エイリアスはに従うべきです [識別子](#syntax-identifiers) 構文。 - - For example, `SELECT "table t".column_name FROM table_name AS "table t"`. - -### 使用上の注意 {#notes-on-usage} - -エイリアスは、クエリまたはサブクエリのグローバルであり、任意の式のクエリの任意の部分にエイリアスを定義できます。 例えば, `SELECT (1 AS n) + 2, n`. - -エイリアスは、サブクエリやサブクエリ間では表示されません。 たとえば、クエリの実行中などです `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouseは例外を生成します `Unknown identifier: num`. - -結果列に別名が定義されている場合 `SELECT` サブクエリの句は、これらの列は、外側のクエリで表示されます。 例えば, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. - -列名またはテーブル名と同じ別名には注意してください。 次の例を考えてみましょう: - -``` sql -CREATE TABLE t -( - a Int, - b Int -) -ENGINE = TinyLog() -``` - -``` sql -SELECT - argMax(a, b), - sum(b) AS b -FROM t -``` - -``` text -Received exception from server (version 18.14.17): -Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. -``` - -この例では、テーブルを宣言しました `t` コラムを使って `b`. 次に、データを選択するときに、 `sum(b) AS b` エイリアス としてエイリアスは、グローバルClickHouse置換されているリテラル `b` 式の中で `argMax(a, b)` 式を使って `sum(b)`. この置換によって例外が発生しました。 - -## アスタリスク {#asterisk} - -で `SELECT` クエリー、アスタリスクで置き換え異なるアイコンで表示されます。 詳細については、以下を参照してください “SELECT”. - -## 式 {#syntax-expressions} - -式は、関数、識別子、リテラル、演算子の適用、角かっこ内の式、サブクエリ、またはアスタリスクです。 別名を含めることもできます。 -式のリストは、コンマで区切られた式です。 -関数と演算子は、次に、引数として式を持つことができます。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/syntax/) diff --git a/docs/ja/sql_reference/table_functions/file.md b/docs/ja/sql_reference/table_functions/file.md deleted file mode 100644 index 69b3f7199e7..00000000000 --- a/docs/ja/sql_reference/table_functions/file.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 37 -toc_title: "\u30D5\u30A1\u30A4\u30EB" ---- - -# ファイル {#file} - -ファイルからテーブルを作成します。 この表関数は次のようになります [url](url.md) と [hdfs](hdfs.md) もの。 - -``` sql -file(path, format, structure) -``` - -**入力パラメータ** - -- `path` — The relative path to the file from [user\_files\_path](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-user_files_path). 読み取り専用モードのglobsに続くファイルサポートのパス: `*`, `?`, `{abc,def}` と `{N..M}` どこに `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [書式](../../interfaces/formats.md#formats) ファイルの -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**戻り値** - -指定したファイルにデータを読み書きするための、指定した構造体を持つテーブル。 - -**例えば** - -設定 `user_files_path` そして、ファイルの内容 `test.csv`: - -``` bash -$ grep user_files_path /etc/clickhouse-server/config.xml - /var/lib/clickhouse/user_files/ - -$ cat /var/lib/clickhouse/user_files/test.csv - 1,2,3 - 3,2,1 - 78,43,45 -``` - -テーブルから`test.csv` そしてそれからの最初の二つの行の選択: - -``` sql -SELECT * -FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -``` sql --- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file -SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 -``` - -**パス内のグロブ** - -複数のパスコンポーネン 処理されるためには、ファイルが存在し、パスパターン全体(接尾辞や接頭辞だけでなく)に一致する必要があります。 - -- `*` — Substitutes any number of any characters except `/` 空の文字列を含む。 -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -構造との `{}` に類似していて下さい [遠隔テーブル機能](../../sql_reference/table_functions/remote.md)). - -**例えば** - -1. 次の相対パスを持つ複数のファイルがあるとします: - -- ‘some\_dir/some\_file\_1’ -- ‘some\_dir/some\_file\_2’ -- ‘some\_dir/some\_file\_3’ -- ‘another\_dir/some\_file\_1’ -- ‘another\_dir/some\_file\_2’ -- ‘another\_dir/some\_file\_3’ - -1. これらのファイルの行数を照会します: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. クエリの量の行のすべてのファイルのディレクトリ: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "警告" - ファイルのリストに先行するゼロを持つ数値範囲が含まれている場合は、各桁のために中かっこで囲みます。 `?`. - -**例えば** - -クエリからのデータファイル名 `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## 仮想列 {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**また見なさい** - -- [仮想列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/ja/sql_reference/table_functions/generate.md b/docs/ja/sql_reference/table_functions/generate.md deleted file mode 100644 index 684301061d3..00000000000 --- a/docs/ja/sql_reference/table_functions/generate.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 47 -toc_title: generateRandom ---- - -# generateRandom {#generaterandom} - -をランダムなデータを指定されたschema. -テストテーブルにデータを設定できます。 -テーブルに格納できるすべてのデータ型をサポートします `LowCardinality` と `AggregateFunction`. - -``` sql -generateRandom('name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_string_length'[, 'max_array_length']]]); -``` - -**パラメータ** - -- `name` — Name of corresponding column. -- `TypeName` — Type of corresponding column. -- `limit` — Number of rows to generate. -- `max_array_length` — Maximum array length for all generated arrays. Defaults to `10`. -- `max_string_length` — Maximum string length for all generated strings. Defaults to `10`. -- `random_seed` — Specify random seed manually to produce stable results. If NULL — seed is randomly generated. - -**戻り値** - -テーブルオブジェクトご希望のスキーマ. - -## 使用例 {#usage-example} - -``` sql -SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2); -``` - -``` text -┌─a────────┬────────────d─┬─c──────────────────────────────────────────────────────────────────┐ -│ [77] │ -124167.6723 │ ('2061-04-17 21:59:44.573','3f72f405-ec3e-13c8-44ca-66ef335f7835') │ -│ [32,110] │ -141397.7312 │ ('1979-02-09 03:43:48.526','982486d1-5a5d-a308-e525-7bd8b80ffa73') │ -│ [68] │ -67417.0770 │ ('2080-03-12 14:17:31.269','110425e5-413f-10a6-05ba-fa6b3e929f15') │ -└──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘ -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/generate/) diff --git a/docs/ja/sql_reference/table_functions/hdfs.md b/docs/ja/sql_reference/table_functions/hdfs.md deleted file mode 100644 index 17726208584..00000000000 --- a/docs/ja/sql_reference/table_functions/hdfs.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 45 -toc_title: hdfs ---- - -# hdfs {#hdfs} - -HDFSのファイルからテーブルを作成します。 この表関数は次のようになります [url](url.md) と [ファイル](file.md) もの。 - -``` sql -hdfs(URI, format, structure) -``` - -**入力パラメータ** - -- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` と `{N..M}` どこに `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [書式](../../interfaces/formats.md#formats) ファイルの -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**戻り値** - -指定したファイルにデータを読み書きするための、指定した構造体を持つテーブル。 - -**例えば** - -テーブルから `hdfs://hdfs1:9000/test` そしてそれからの最初の二つの行の選択: - -``` sql -SELECT * -FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -**パス内のグロブ** - -複数のパスコンポーネン 処理されるためには、ファイルが存在し、パスパターン全体(接尾辞や接頭辞だけでなく)に一致する必要があります。 - -- `*` — Substitutes any number of any characters except `/` 空の文字列を含む。 -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -構造との `{}` に類似していて下さい [遠隔テーブル機能](../../sql_reference/table_functions/remote.md)). - -**例えば** - -1. HDFS上に次のUriを持ついくつかのファイルがあるとします: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. これらのファイルの行数を照会します: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. これら二つのディレ: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "警告" - ファイルのリストに先行するゼロを持つ数値範囲が含まれている場合は、各桁のために中かっこで囲みます。 `?`. - -**例えば** - -クエリからのデータファイル名 `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## 仮想列 {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**また見なさい** - -- [仮想列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/ja/sql_reference/table_functions/index.md b/docs/ja/sql_reference/table_functions/index.md deleted file mode 100644 index 508317ffa90..00000000000 --- a/docs/ja/sql_reference/table_functions/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Table Functions -toc_priority: 34 -toc_title: "\u5C0E\u5165" ---- - -# テーブル関数 {#table-functions} - -テーブル機能の方法を構築します。 - -テーブル関数は次の場所で使用できます: - -- [FROM](../statements/select.md#select-from) の句 `SELECT` クエリ。 - - The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. - -- [テーブルを\として作成](../statements/create.md#create-table-query) クエリ。 - - It's one of the methods of creating a table. - -!!! warning "警告" - テーブル関数を使用することはできません。 [allow\_ddl](../../operations/settings/permissions_for_queries.md#settings_allow_ddl) 設定は無効です。 - -| 機能 | 説明 | -|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------| -| [ファイル](file.md) | を作成します。 [ファイル](../../engines/table_engines/special/file.md)-エンジンのテーブル。 | -| [マージ](merge.md) | を作成します。 [マージ](../../engines/table_engines/special/merge.md)-エンジンのテーブル。 | -| [数字](numbers.md) | 単一の列が整数で埋められたテーブルを作成します。 | -| [リモート](remote.md) | へ自由にアクセスできるリモートサーバーを作成することなく [分散](../../engines/table_engines/special/distributed.md)-エンジンのテーブル。 | -| [url](url.md) | を作成します。 [Url](../../engines/table_engines/special/url.md)-エンジンのテーブル。 | -| [mysql](mysql.md) | を作成します。 [MySQL](../../engines/table_engines/integrations/mysql.md)-エンジンのテーブル。 | -| [jdbc](jdbc.md) | を作成します。 [JDBC](../../engines/table_engines/integrations/jdbc.md)-エンジンのテーブル。 | -| [odbc](odbc.md) | を作成します。 [ODBC](../../engines/table_engines/integrations/odbc.md)-エンジンのテーブル。 | -| [hdfs](hdfs.md) | を作成します。 [HDFS](../../engines/table_engines/integrations/hdfs.md)-エンジンのテーブル。 | - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/ja/sql_reference/table_functions/input.md b/docs/ja/sql_reference/table_functions/input.md deleted file mode 100644 index 1fdd93c10a6..00000000000 --- a/docs/ja/sql_reference/table_functions/input.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 46 -toc_title: "\u5165\u529B" ---- - -# 入力 {#input} - -`input(structure)` -テーブル関数に送信されたデータを効果的に変換して挿入できるようにする -別の構造を持つテーブルに与えられた構造を持つサーバー。 - -`structure` -次の形式でサーバーに送信されるデータの構造 `'column1_name column1_type, column2_name column2_type, ...'`. -例えば, `'id UInt32, name String'`. - -この関数は、以下でのみ使用できます `INSERT SELECT` query and only once but otherwiseは通常のテーブル関数のように動作します -(たとえば、サブクエリなどで使用することができます。). - -データを送ることができ、そのような通常の `INSERT` 利用できる照会および渡される [書式](../../interfaces/formats.md#formats) -これは、クエリの最後に指定する必要があります(通常とは異なり `INSERT SELECT`). - -この機能はサーバからデータを受け取clientで同時に変換して -式のリストによると、 `SELECT` ターゲットテーブルに句と挿入します。 一時テーブル -すべての転送されたデータは作成されません。 - -**例** - -- させる `test` テーブルには以下の構造 `(a String, b String)` - とデータで `data.csv` 異なる構造を持っています `(col1 String, col2 Date, col3 Int32)`. 挿入のクエリ - からのデータ `data.csv` に `test` 同時変換のテーブルは次のようになります: - - - -``` bash -$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; -``` - -- もし `data.csv` 同じ構造のデータを含む `test_structure` としてのテーブル `test` そしてこれら二つのクエリが等しい: - - - -``` bash -$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV" -$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV" -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/input/) diff --git a/docs/ja/sql_reference/table_functions/jdbc.md b/docs/ja/sql_reference/table_functions/jdbc.md deleted file mode 100644 index dd32bef2989..00000000000 --- a/docs/ja/sql_reference/table_functions/jdbc.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 43 -toc_title: jdbc ---- - -# jdbc {#table-function-jdbc} - -`jdbc(jdbc_connection_uri, schema, table)` -JDBCドライバ経由で接続されたテーブルを返します。 - -このテーブル関数は、個別の `clickhouse-jdbc-bridge` 実行するプログラム。 -でnullable種類に基づくddlのリモートテーブルが照会される). - -**例** - -``` sql -SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') -``` - -``` sql -SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'schema', 'table') -``` - -``` sql -SELECT * FROM jdbc('datasource://mysql-local', 'schema', 'table') -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/ja/sql_reference/table_functions/merge.md b/docs/ja/sql_reference/table_functions/merge.md deleted file mode 100644 index 7e20c9526d7..00000000000 --- a/docs/ja/sql_reference/table_functions/merge.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 38 -toc_title: "\u30DE\u30FC\u30B8" ---- - -# マージ {#merge} - -`merge(db_name, 'tables_regexp')` – Creates a temporary Merge table. For more information, see the section “Table engines, Merge”. - -テーブル構造は、正規表現に一致する最初のテーブルから取得されます。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/merge/) diff --git a/docs/ja/sql_reference/table_functions/mysql.md b/docs/ja/sql_reference/table_functions/mysql.md deleted file mode 100644 index 2b64b9a1a17..00000000000 --- a/docs/ja/sql_reference/table_functions/mysql.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 42 -toc_title: mysql ---- - -# mysql {#mysql} - -許可 `SELECT` リモートMySQLサーバーに格納されているデータに対して実行されるクエリ。 - -``` sql -mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -**パラメータ** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` へのクエリ `REPLACE INTO`. もし `replace_query=1`、クエリが置き換えられます。 - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` に追加される式 `INSERT` クエリ。 - - Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. - - To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. - -シンプル `WHERE` 次のような句 `=, !=, >, >=, <, <=` 現在、MySQLサーバで実行されています。 - -残りの条件と `LIMIT` サンプリング制約は、MySQLへのクエリが終了した後にのみClickHouseで実行されます。 - -**戻り値** - -元のmysqlテーブルと同じカラムを持つテーブルオブジェクト。 - -## 使用例 {#usage-example} - -MySQLのテーブル: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -ClickHouseからのデータの選択: - -``` sql -SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## また見なさい {#see-also} - -- [その ‘MySQL’ 表エンジン](../../engines/table_engines/integrations/mysql.md) -- [MySQLを外部辞書のソースとして使用する](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/ja/sql_reference/table_functions/numbers.md b/docs/ja/sql_reference/table_functions/numbers.md deleted file mode 100644 index 668e3eee1c8..00000000000 --- a/docs/ja/sql_reference/table_functions/numbers.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 39 -toc_title: "\u6570\u5B57" ---- - -# 数字 {#numbers} - -`numbers(N)` – Returns a table with the single ‘number’ 0からN-1までの整数を含む列(UInt64)。 -`numbers(N, M)` -単一のテーブルを返す ‘number’ nから(N+M-1)までの整数を含む列(UInt64)。 - -に似て `system.numbers` テーブルに使用でき試験および発生連続値, `numbers(N, M)` より有効より `system.numbers`. - -次のクエリは同等です: - -``` sql -SELECT * FROM numbers(10); -SELECT * FROM numbers(0, 10); -SELECT * FROM system.numbers LIMIT 10; -``` - -例: - -``` sql --- Generate a sequence of dates from 2010-01-01 to 2010-12-31 -select toDate('2010-01-01') + number as d FROM numbers(365); -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/numbers/) diff --git a/docs/ja/sql_reference/table_functions/odbc.md b/docs/ja/sql_reference/table_functions/odbc.md deleted file mode 100644 index be43586454c..00000000000 --- a/docs/ja/sql_reference/table_functions/odbc.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 44 -toc_title: odbc ---- - -# odbc {#table-functions-odbc} - -接続されたテーブルを返します。 [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -``` sql -odbc(connection_settings, external_database, external_table) -``` - -パラメータ: - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` ファイル。 -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -ODBC接続を安全に実装するには、ClickHouseは別のプログラムを使用します `clickhouse-odbc-bridge`. ODBCドライバーが直接読み込まれている場合 `clickhouse-server` ドライバの問題でクラッシュのClickHouseサーバーです。 クリックハウスが自動的に起動 `clickhouse-odbc-bridge` それが必要なとき。 ODBCブリッジプログラムは、次のパッケージと同じパッケー `clickhouse-server`. - -のフィールド `NULL` 外部テーブルの値は、基本データ型のデフォルト値に変換されます。 例えば、リモートMySQLテーブル分野の `INT NULL` タイプは0に変換されます(ClickHouseのデフォルト値 `Int32` データ型)。 - -## 使用例 {#usage-example} - -**PpsはインタラクティブのMySQLのインストール目盛** - -この例は、ubuntu linux18.04およびmysql server5.7で確認されています。 - -UnixODBCとMySQL Connectorがインストールされていることを確認します。 - -デフォルトでインストールされた場合、パッケージから),clickhouse開始してユーザー `clickhouse`. したがって、MySQLサーバでこのユーザを作成して設定する必要があります。 - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -次に、接続を設定します `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -チェックでき、接続を使用 `isql` unixODBCインストールからのユーティリティ。 - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -MySQLのテーブル: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -ClickHouseのMySQLテーブルからデータを取得する: - -``` sql -SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ 0 │ 2 │ 0 │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## また見なさい {#see-also} - -- [ODBC外部辞書](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [ODBCテーブルエンジン](../../engines/table_engines/integrations/odbc.md). - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/ja/sql_reference/table_functions/remote.md b/docs/ja/sql_reference/table_functions/remote.md deleted file mode 100644 index 82ccc31d80a..00000000000 --- a/docs/ja/sql_reference/table_functions/remote.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 40 -toc_title: "\u30EA\u30E2\u30FC\u30C8" ---- - -# リモート,remoteSecure {#remote-remotesecure} - -へ自由にアクセスできるリモートサーバーを作成することなく `Distributed` テーブル。 - -署名: - -``` sql -remote('addresses_expr', db, table[, 'user'[, 'password']]) -remote('addresses_expr', db.table[, 'user'[, 'password']]) -``` - -`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port`、またはちょうど `host`. ホストは、サーバー名またはIPv4またはIPv6アドレスとして指定できます。 IPv6アドレスは角かっこで指定します。 ポートは、リモートサーバー上のTCPポートです。 ポートが省略された場合は、以下を使用します `tcp_port` サーバの設定ファイルから(デフォルトでは9000) - -!!! important "重要" - このポートはipv6アドレスに必要です。 - -例: - -``` text -example01-01-1 -example01-01-1:9000 -localhost -127.0.0.1 -[::]:9000 -[2a02:6b8:0:1111::11]:9000 -``` - -複数のアドレスをコンマ区切りにできます。 この場合、clickhouseは分散処理を使用するため、指定されたすべてのアドレス(異なるデータを持つシャードなど)にクエリを送信します。 - -例えば: - -``` text -example01-01-1,example01-02-1 -``` - -式の一部は、中括弧で指定できます。 前の例は次のように書くことができます: - -``` text -example01-0{1,2}-1 -``` - -中括弧は、二つのドット(負でない整数)で区切られた数の範囲を含めることができます。 この場合、範囲はシャードアドレスを生成する値のセットに拡張されます。 最初の数値がゼロから始まる場合、値は同じゼロ整列で形成されます。 前の例は次のように書くことができます: - -``` text -example01-{01..02}-1 -``` - -中括弧の複数のペアがある場合は、対応するセットの直接積が生成されます。 - -中括弧の中のアドレスとアドレスの一部は、パイプ記号(\|)で区切ることができます。 この場合、対応するアドレスのセットはレプリカとして解釈され、クエリは最初の正常なレプリカに送信されます。 ただし、レプリカは、現在設定されている順序で反復されます。 [load\_balancing](../../operations/settings/settings.md) 設定。 - -例えば: - -``` text -example01-{01..02}-{1|2} -``` - -この例では、指定さつする資料をそれぞれ二つのレプリカ. - -生成されるアドレスの数は定数によって制限されます。 今これは1000アドレスです。 - -を使用して `remote` テーブル関数が作成するよりも最適ではない `Distributed` この場合、サーバー接続はすべての要求に対して再確立されるためです。 さらに、ホスト名が設定されている場合、名前は解決され、さまざまなレプリカを操作するときにエラーはカウントされません。 多数のクエリを処理する場合は、常に `Distributed` テーブルは時間に先んじて、使用しないし `remote` テーブル機能。 - -その `remote` テーブル関数は、次の場合に便利です: - -- アクセスの特定のサーバーのためのデータとの比較、デバッグ、テスト実施をしておりました。 -- 研究目的のための様々なclickhouseクラスタ間のクエリ。 -- 手動で行われる頻度の低い分散要求。 -- サーバーのセットが毎回再定義される分散要求。 - -ユーザーが指定されていない場合, `default` 使用される。 -パスワードを指定しない場合は、空のパスワードが使用されます。 - -`remoteSecure` -と同じ `remote` but with secured connection. Default port — [tcp\_port\_secure](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) 設定または9440から。 - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/ja/sql_reference/table_functions/url.md b/docs/ja/sql_reference/table_functions/url.md deleted file mode 100644 index d46c567d402..00000000000 --- a/docs/ja/sql_reference/table_functions/url.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 41 -toc_title: url ---- - -# url {#url} - -`url(URL, format, structure)` -から作成されたテーブルを返します `URL` 与えられると -`format` と `structure`. - -URL-受け入れることができるHTTPまたはHTTPSサーバアドレス `GET` および/または `POST` 要求。 - -書式 - [書式](../../interfaces/formats.md#formats) データの。 - -構造-テーブルの構造 `'UserID UInt64, Name String'` フォーマット。 列の名前と型を決定します。 - -**例えば** - -``` sql --- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format. -SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3 -``` - -[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/url/) diff --git a/docs/ja/whats-new/changelog/2017.md b/docs/ja/whats-new/changelog/2017.md new file mode 100644 index 00000000000..ada7b74e431 --- /dev/null +++ b/docs/ja/whats-new/changelog/2017.md @@ -0,0 +1,268 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 79 +toc_title: '2017' +--- + +### ClickHouseリリース1.1.54327,2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} + +このリリ: + +- 固定バグでレースの条件で接続文字列の構文は以下のようにこのデータが失われます。 この問題は、バージョン1.1.54310および1.1.54318に影響します。 ご利用の場合これらのバージョンとの複製のテーブルを更新することが強く推奨されます。 この問題にログ警告メッセージのように `Part ... from own log doesn't exist.` この問題は、ログにこれらのメッセージが表示されない場合でも関連します。 + +### ClickHouseリリース1.1.54318,2017-11-30 {#clickhouse-release-1-1-54318-2017-11-30} + +このリリ: + +- SummingMergeTreeエンジンでのマージ中の不正な行の削除を修正しました +- 複雑でないMergeTreeエンジンのメモリリークを修正しました +- MergeTreeエンジンの頻繁な挿入による性能低下を修正 +- レプリケーションキューの実行が停止する問題を修正しました +- サーバーログの固定回転とアーカイブ + +### ClickHouseリリース1.1.54310,2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} + +#### 新しい機能: {#new-features} + +- カスタムパーティショニングキーのMergeTree家族のテーブルエンジンです。 +- [カフカ](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) テーブルエンジン。 +- ロードのサポートを追加 [CatBoost](https://catboost.yandex/) モデルとClickHouseに格納されたデータにそれらを適用します。 +- サポートが追加された時間帯と非整数オフセットからのUTCです。 +- 時間間隔での算術演算のサポートが追加されました。 +- Date型とDateTime型の値の範囲は、2105年まで拡張されます。 +- 追加された `CREATE MATERIALIZED VIEW x TO y` query(マテリアライズドビューのデータを格納するための既存のテーブルを指定します)。 +- 追加された `ATTACH TABLE` 引数なしのクエリ。 +- SummingMergeTreeテーブルの-Mapで終わる名前を持つ入れ子になった列の処理ロジックが、sumMap集計関数に抽出されました。 これで、そのような列を明示的に指定できます。 +- IP trie辞書の最大サイズは128Mのエントリに増加します。 +- GetSizeOfEnumType関数を追加しました。 +- SumWithOverflow集計関数を追加しました。 +- Cap'n Proto入力フォーマットのサポートが追加されました。 +- では、今までのカスタマイズの圧縮レベル使用時のzstdアルゴリズムです。 + +#### 下位互換性のない変更: {#backward-incompatible-changes} + +- メモリ以外のエンジンで一時テーブルを作成することはできません。 +- ViewまたはMaterializedViewエンジンでテーブルを明示的に作成することはできません。 +- 中表を作成し、新しいチェックを確認し、サンプリングキー表現が含まれ、その有効なタイプを利用します。 + +#### バグ修正: {#bug-fixes} + +- 分散テーブルに同期的に挿入するときのハングを修正しました。 +- 固定nonatomicの追加および削除のパーツで再現します。 +- マテリアライズドビューに挿入されたデータは、不要な重複排除を受けません。 +- ローカルレプリカが遅れており、リモートレプリカが使用できない分散テーブルに対してクエリを実行しても、エラーは発生しません。 +- ユーザーにはアクセス権限は必要ありません。 `default` 一時テーブルを作成するデータベース。 +- 引数なしで配列型を指定するとクラッシュする問題を修正。 +- 固定hangups時のディスク容量を含むサーバのログします。 +- Unixエポックの最初の週のtoRelativeWeekNum関数のオーバーフローを修正しました。 + +#### ビルドの改善: {#build-improvements} + +- いくつかのサードパーテ + +### ClickHouseリリース1.1.54304,2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} + +#### 新しい機能: {#new-features-1} + +- ネイティブプロトコ `tcp_ssl_port` で `config.xml` ). + +#### バグ修正: {#bug-fixes-1} + +- `ALTER` のための複製のテーブル現しようと走り出しています。 +- 固定波データを読み込むときに設定 `preferred_block_size_bytes=0.` +- の固定クラッシュ `clickhouse-client` 押すとき `Page Down` +- 特定の複雑なクエリの正しい解釈 `GLOBAL IN` と `UNION ALL` +- `FREEZE PARTITION` いつも原子的に動作します。 +- 空のPOST要求は、コード411の応答を返します。 +- 次のような式の修正された解釈エラー `CAST(1 AS Nullable(UInt8)).` +- 読み取り時のエラーを修正 `Array(Nullable(String))` からの列 `MergeTree` テーブル +- 固定表の構文解析時にクエリのように `SELECT dummy AS dummy, dummy AS b` +- ユーザーが無効で正しく更新される `users.xml` +- 実行可能ディクショナリがゼロ以外の応答コードを返すときの正しい処理。 + +### ClickHouseリリース1.1.54292,2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} + +#### 新しい機能: {#new-features-2} + +- 追加された `pointInPolygon` 座標平面上の座標を操作するための関数。 +- 追加された `sumMap` 配列の合計を計算するための集計関数。 `SummingMergeTree`. +- 追加された `trunc` 機能。 丸め関数のパフォーマンスの向上 (`round`, `floor`, `ceil`, `roundToExp2` を正の論理をどのように。 のロジックを変更しました `roundToExp2` 分数と負の数のための関数。 +- ClickHouse実行可能ファイルは、libcのバージョンにあまり依存しません。 同じClickHouse実行可能ファイルは、さまざまなLinuxシステムで実行できます。 コンパイルされたクエリを使用すると、依存関係がまだあります(設定付き `compile = 1` デフォルトでは使用されません)。 +- クエリの動的コンパイルに必要な時間を短縮しました。 + +#### バグ修正: {#bug-fixes-2} + +- 時々生成されるエラーを修正しました `part ... intersects previous part` メッセージと弱いレプリカの一貫性。 +- シャットダウ +- 除去の過剰伐採が回復レプリカ. +- UNION ALL実装のエラーを修正しました。 +- ブロック内の最初の列が配列型である場合に発生したconcat関数のエラーを修正しました。 +- 進行状況がシステムに正しく表示されます。マージテーブル。 + +### ClickHouseリリース1.1.54289,2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} + +#### 新しい機能: {#new-features-3} + +- `SYSTEM` サーバー管理のクエリ: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. +- 配列を操作するための関数を追加しました: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. +- 追加 `root` と `identity` ZooKeeper設定のパラメータ。 これにより、同じZooKeeperクラスター上の個々のユーザーを分離できます。 +- 集計関数の追加 `groupBitAnd`, `groupBitOr`,and `groupBitXor` (互換性のために、彼らはまた、名前の下で利用可能です `BIT_AND`, `BIT_OR`,and `BIT_XOR`). +- 外部の辞書からロード可能でMySQLを指定するソケットのファイルシステム. +- 外部辞書はMySQLからSSL経由でロードできます (`ssl_cert`, `ssl_key`, `ssl_ca` 変数)。 +- 追加された `max_network_bandwidth_for_user` ユーザーごとのクエリの全体的な帯域幅の使用を制限する設定。 +- のサポート `DROP TABLE` 一時テーブルの場合。 +- 読書のサポート `DateTime` Unixタイムスタンプ形式の値 `CSV` と `JSONEachRow` フォーマット。 +- 分散クエリの遅延レプリカは既定で除外されるようになりました(既定のしきい値は5分です)。 +- FIFOロック使用時の変更:変更のクエリーなブ無期限に継続的に走ります。 +- 設定するオプション `umask` 設定ファイルで。 +- クエリのパフォーマンスの向上 `DISTINCT` . + +#### バグ修正: {#bug-fixes-3} + +- ZooKeeperの古いノードを削除するプロセスを改善しました。 以前は、非常に頻繁に挿入された場合に古いノードが削除されなかったことがあり、サーバーのシャットダウンが遅くなりました。 +- ZooKeeperへの接続のホストを選択する際のランダム化を修正しました。 +- レプリカがlocalhostの場合、分散クエリでの遅延レプリカの除外を修正しました。 +- エラーを修正しました。 `ReplicatedMergeTree` テーブルが壊れる恐れがあった後、走行 `ALTER MODIFY` aの要素に対して `Nested` 構造。 +- SELECTクエリの原因となるエラーを修正しました “hang”. +- 分散DDLクエリの改善。 +- クエリを修正しました `CREATE TABLE ... AS `. +- のデッドロックを解決しました。 `ALTER ... CLEAR COLUMN IN PARTITION` クエリ `Buffer` テーブル +- の無効なデフォルト値を修正しました `Enum` s(最小値の代わりに0)を使用する場合 `JSONEachRow` と `TSKV` フォーマット。 +- ディクショナリを使用するとゾンビプロセスの出現を解決 `executable` 出典 +- HEADクエリのsegfaultを修正しました。 + +#### ClickHouseの開発とアセンブルのワークフローの改善: {#improved-workflow-for-developing-and-assembling-clickhouse} + +- 以下を使用できます `pbuilder` ClickHouseを構築する。 +- 以下を使用できます `libc++` 代わりに `libstdc++` Linux上のビルドの場合。 +- 静的コード分析ツールの使用方法を追加: `Coverage`, `clang-tidy`, `cppcheck`. + +#### ご注意ください: {#please-note-when-upgrading} + +- MergeTree設定の既定値が高くなりました `max_bytes_to_merge_at_max_space_in_pool` (マージするデータ部分の最大合計サイズ、バイト単位):100GiBから150GiBに増加しました。 この結果、大型の合併-走行後のサーバグの原因になりの増加に負荷をディスクサブシステムです。 サーバー上で使用可能な空き領域が、実行中のマージの合計量の倍未満である場合、これにより、小さなデータ部分のマージを含む、他のすべてのマージの実行が その結果、INSERTクエリはメッセージで失敗します “Merges are processing significantly slower than inserts.” 使用する `SELECT * FROM system.merges` 状況を監視するためのクエリ。 また点検できます `DiskSpaceReservedForMerge` のメトリック `system.metrics` テーブル、またはグラファイト。 大きなマージが終了すると問題が解決するので、これを修正するために何もする必要はありません。 これが受け入れられない場合は、以前の値を復元することができます。 `max_bytes_to_merge_at_max_space_in_pool` 設定。 これを行うには、 `` configのセクション。xml、セット ``` ``107374182400 ``` サーバーを再起動します。 + +### ClickHouseリリース1.1.54284,2017-08-29 {#clickhouse-release-1-1-54284-2017-08-29} + +- これは以前の1.1.54282リリースのバグ修正リリースです。 ZooKeeperのpartsディレクトリのリークを修正します。 + +### ClickHouseリリース1.1.54282,2017-08-23 {#clickhouse-release-1-1-54282-2017-08-23} + +このリリースには以前のリリース1.1.54276のバグ修正が含まれています: + +- 固定 `DB::Exception: Assertion violation: !_path.empty()` 分散テーブルに挿入するとき。 +- 入力データが';'で始まる場合、RowBinary形式で挿入するときの解析を修正しました。 +- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). + +### ClickHouseリリース1.1.54276,2017-08-16 {#clickhouse-release-1-1-54276-2017-08-16} + +#### 新しい機能: {#new-features-4} + +- SELECTクエリのWITHセクションを追加しました。 クエリの例: `WITH 1+1 AS a SELECT a, a*a` +- すべてのデータがすべてのシャードに保存された後にのみOKが返されます。 これは、insert\_distributed\_sync=1の設定によって有効になります。 +- 16バイト識別子を操作するためのUUIDデータ型を追加しました。 +- Tableauとの互換性のために、CHAR、FLOAT、その他のタイプの別名を追加しました。 +- 時間を数値に変換するための関数toYYYYMM、toYYYYMMDD、およびtoYYYYMMDDhhmmssを追加しました。 +- IPアドレス(ホスト名と共に)を使用して、クラスタ化されたDDLクエリのサーバーを識別できます。 +- 関数内の非定数引数と負のオフセットのサポートが追加されました `substring(str, pos, len).` +- のmax\_sizeパラメータを追加しました。 `groupArray(max_size)(column)` 集計関数、およびその性能を最適化しました。 + +#### 主な変更点: {#main-changes} + +- セキュリティの改善:すべてのサーバーファイルは0640の権限で作成されます( `` 設定パラメータ)。 +- 無効な構文を持つクエリのエラーメッセージの改善。 +- MergeTreeデータの大部分をマージするときのメモリ消費の大幅な削減とパフォーマンスの向上。 +- 置換用のデータマージのパフォーマンスが大幅に向上しましたマージツリーエンジン。 +- 性能向上のための非同期に挿入しますから分散型のテーブルを組み合わせで複数のソースしました。 この機能を有効にするには、distributed\_directory\_monitor\_batch\_inserts=1の設定を使用します。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-1} + +- の集合状態のバイナリ形式を変更しました `groupArray(array_column)` 配列の関数。 + +#### 変更の完全なリスト: {#complete-list-of-changes} + +- 追加された `output_format_json_quote_denormals` json形式でnanおよびinf値を出力できるようにする設定。 +- 最適化したストリーム配置の場合を読み込んで配布します。 +- 値が変更されない場合、設定は読み取り専用モードで構成できます。 +- Preferred\_block\_size\_bytes設定で指定されたブロックサイズの制限を満たすために、MergeTreeエンジンの整数以外の顆粒を取得する機能を追加しました。 のための消費量を削減RAMを増やキャッシュの地域が処理クエリーテーブルの大きい。 +- 次のような式を含むインデックスの効率的な使用 `toStartOfHour(x)` 条件のためのような `toStartOfHour(x) op сonstexpr.` +- MergeTreeエンジンの新しい設定を追加しました(設定のmerge\_treeセクション。xml): + - replicated\_deduplication\_window\_secondsレプリケートされたテーブル内の挿入を重複除外するために許可される秒数を設定します。 + - cleanup\_delay\_periodクリーンアップを開始して古いデータを削除する頻度を設定します。 + - replicated\_can\_become\_leaderは、レプリカがリーダーになるのを防ぐことができます(およびマージの割り当て)。 +- 加速の清掃除時代遅れからのデータの飼育係. +- クラスタ化されたDDLクエリの複数の改善と修正。 特に興味深いのは、クラスタ内のサーバーからの応答を待つ時間を制限する新しい設定distributed\_ddl\_task\_timeoutです。 Ddl要求がすべてのホストで実行されていない場合、応答にはタイムアウトエラーが含まれ、要求は非同期モードで実行されます。 +- サーバーログにおけるスタックトレースの表示の改善。 +- 追加された “none” 圧縮方法の値。 +- Configでは、複数のdictionaries\_configセクションを使用できます。xml。 +- ファイルシステム内のソケットを介してMySQLに接続することは可能です。 +- システム。部品表には、マークのサイズに関する情報をバイト単位で含む新しい列があります。 + +#### バグ修正: {#bug-fixes-4} + +- 布を使ってテーブルは、Mergeテーブル現在は正常に動作するクエリを選択し、条件に `_table` フィールド +- ReplicatedMergeTreeでデータパーツをチェックする際に、まれな競合状態を修正しました。 +- 固定可能凍結 “leader election” サーバーを起動するとき。 +- データソースのローカルレプリカを使用する場合、max\_replica\_delay\_for\_distributed\_queries設定は無視されました。 これは修正されました。 +- 修正された不正な動作 `ALTER TABLE CLEAR COLUMN IN PARTITION` 既存の列以外の列をクリーンアップしようとする場合。 +- 空の配列または文字列を使用している場合、関数multifの例外を修正しました。 +- 固定の過剰なメモリ割当ての場合deserializingネイティブ形式です。 +- トライ辞書の正しくない自動更新を修正しました。 +- SAMPLE使用時にMergeテーブルからGROUP BY句を使用してクエリを実行する場合の例外を修正しました。 +- Distributed\_aggregation\_memory\_efficient=1を使用すると、GROUP BYのクラッシュを修正しました。 +- これで、データベースを指定できます。INとJOINの右側の表。 +- 並列集約に使用されたスレッドが多すぎます。 これは修正されました。 +- どのように修正 “if” 関数はFixedString引数で動作します。 +- 重みが0のシャードに対して、分散テーブルから誤ってworkedを選択します。 これは修正されました。 +- 実行中 `CREATE VIEW IF EXISTS no longer causes crashes.` +- Input\_format\_skip\_unknown\_fields=1が設定され、負の数がある場合の不正な動作を修正しました。 +- の無限ループを固定しました。 `dictGetHierarchy()` 辞書に無効なデータがある場合に機能します。 +- 固定 `Syntax error: unexpected (...)` INまたはJOIN句およびMergeテーブルでサブクエリを使用して分散クエリを実行するときのエラー。 +- 辞書テーブルからのSELECTクエリの誤った解釈を修正しました。 +- 固定された “Cannot mremap” 2億を超える要素を持つIN句とJOIN句で配列を使用するとエラーが発生します。 +- MySQLをソースとする辞書のフェイルオーバーを修正しました。 + +#### ClickHouseの開発とアセンブルのワークフローの改善: {#improved-workflow-for-developing-and-assembling-clickhouse-1} + +- ビルドはArcadiaで組み立てることができます。 +- Gcc7を使用してClickHouseをコンパイルできます。 +- Ccache+distccを使用した並列ビルドは、より高速になりました。 + +### ClickHouseリリース1.1.54245,2017-07-04 {#clickhouse-release-1-1-54245-2017-07-04} + +#### 新しい機能: {#new-features-5} + +- 分散DDL(たとえば, `CREATE TABLE ON CLUSTER`) +- 複製されたクエリ `ALTER TABLE CLEAR COLUMN IN PARTITION.` +- 辞書テーブルのエンジン(テーブル形式の辞書データへのアクセス)。 +- 辞書データベースエンジン(タイプのデータベースに自動的に辞書で使用可能なテーブルを接続外部辞書). +- ソースに要求を送信することで、辞書の更新を確認できます。 +- 修飾された列名 +- 二重引用符を使用した識別子の引用。 +- HTTPイ +- 複製されたテーブルのOPTIMIZEクエリは、リーダーだけでなく実行できます。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-2} + +- グローバルセットを削除。 + +#### マイナーな変更点: {#minor-changes} + +- 今後のアラート実行のログを出力フルスタックトレース. +- 起動時に破損した/余分なデータパーツの数の検証を緩和しました(誤検出が多すぎました)。 + +#### バグ修正: {#bug-fixes-5} + +- 接続不良を修正 “sticking” 分散テーブルに挿入するとき。 +- GLOBAL INは、分散テーブルを参照するMergeテーブルからのクエリに対して機能します。 +- Google Compute Engine仮想マシンで不正なコア数が検出されました。 これは修正されました。 +- キャッシュされた外部辞書の実行可能ソースの動作方法の変更。 +- Null文字を含む文字列の比較を修正しました。 +- Float32主キーフィールドと定数の比較を修正しました。 +- 従来、不正確な見積りのサイズの分野が過度に大きな分配すべき。 +- ALTERを使用してテーブルに追加されたNull許容列を照会するとクラッシュする問題を修正しました。 +- 行数が制限よりも小さい場合、Null許容列でソートするとクラッシュする問題を修正しました。 +- 定数値のみで構成されるORDER BYサブクエリを修正しました。 +- については、従来、複製テーブルが残る無効な状態にした後、失敗した下表に示す。 +- 空の結果を持つスカラーサブクエリのエイリアスは失われなくなりました。 +- コンパイルを使用したクエリは、.soファイルが破損してもエラーで失敗しません。 diff --git a/docs/ja/whats-new/changelog/2018.md b/docs/ja/whats-new/changelog/2018.md new file mode 100644 index 00000000000..d0c28e2b9f5 --- /dev/null +++ b/docs/ja/whats-new/changelog/2018.md @@ -0,0 +1,1063 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 78 +toc_title: '2018' +--- + +## ClickHouseリリース18.16 {#clickhouse-release-18-16} + +### ClickHouseリリース18.16.1、2018年12月21日 {#clickhouse-release-18-16-1-2018-12-21} + +#### バグ修正: {#bug-fixes} + +- ODBCソースで辞書を更新する際に問題が発生するエラーを修正しました。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- 集計関数のJITコンパイルがLowCardinality列で動作するようになりました。 [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) + +#### 改善: {#improvements} + +- 追加された `low_cardinality_allow_in_native_format` 設定(デフォルトで有効)。 無効にすると、LowCardinality列はSELECTクエリでは通常の列に変換され、insertクエリでは通常の列に変換されます。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) + +#### ビルドの改善: {#build-improvements} + +- MacOSとARM上のビルドの修正。 + +### ClickHouseリリース18.16.0,2018-12-14 {#clickhouse-release-18-16-0-2018-12-14} + +#### 新しい機能: {#new-features} + +- `DEFAULT` 式の評価のために欠けるのはデータの読み込みに半構造の入力形式 (`JSONEachRow`, `TSKV`). この機能は、 `insert_sample_with_metadata` 設定。 [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) +- その `ALTER TABLE` クエリには `MODIFY ORDER BY` 表の列を追加または削除するときに並べ替えキーを変更するアクション。 これは、 `MergeTree` このソートキーに基づいてマージするときに追加のタスクを実行するファミリ `SummingMergeTree`, `AggregatingMergeTree`、というように。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) +- のテーブルの場合 `MergeTree` 家族、今別の分類のキーを指定できます (`ORDER BY`)および索引 (`PRIMARY KEY`). ソートキーでのものより長い。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) +- 追加された `hdfs` テーブル関数と `HDFS` テーブルエンジンの輸出入データHDFS. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) +- Base64を操作するための関数を追加しました: `base64Encode`, `base64Decode`, `tryBase64Decode`. [アレクサンドル-クラシェニコフ](https://github.com/ClickHouse/ClickHouse/pull/3350) +- これで、パラメータを使用して、 `uniqCombined` 集計関数(HyperLogLogセルの数を選択します)。 [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) +- 追加された `system.contributors` ClickHouseでコミットを行ったすべての人の名前を含むテーブル。 [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) +- パーティションを省略する機能を追加しました。 `ALTER TABLE ... FREEZE` クエリをバックアップするには、全ての仕切ります。 [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) +- 追加 `dictGet` と `dictGetOrDefault` 戻り値の型を指定する必要のない関数。 タイプは、辞書の説明から自動的に決定されます。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3564) +- これで、テーブルの説明で列のコメントを指定し、次のように変更できます `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) +- 読書はのために支えられる `Join` 単純なキーでテーブルを入力します。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3728) +- これで、オプションを指定できます `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join`,and `join_overflow_mode` を作成するとき `Join` タイプテーブル。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3728) +- 追加された `joinGet` を使用することを可能にする関数 `Join` 辞書のようなテーブルを入力します。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3728) +- 追加された `partition_key`, `sorting_key`, `primary_key`,and `sampling_key` の列 `system.tables` テーブルキーに関する情報を提供するためのテーブル。 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- 追加された `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key`,and `is_in_sampling_key` の列 `system.columns` テーブル。 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- 追加された `min_time` と `max_time` の列 `system.parts` テーブル。 これらの列は、パーティション分割キーが次の式の場合に設定されます `DateTime` 列。 [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) + +#### バグ修正: {#bug-fixes-1} + +- の修正とパフォーマンスの向上 `LowCardinality` データ型。 `GROUP BY` を使用して `LowCardinality(Nullable(...))`. の値を取得する `extremes`. 高次関数の処理。 `LEFT ARRAY JOIN`. 分散 `GROUP BY`. 返される関数 `Array`. の実行 `ORDER BY`. 書き込み先 `Distributed` テーブル(nicelulu)。 のための下位互換性 `INSERT` を実装する古いクライアントからの照会 `Native` プロトコル のサポート `LowCardinality` のために `JOIN`. した場合の性能改善作業を単一のストリームです。 [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) +- どのように修正 `select_sequential_consistency` オプションの作品。 以前は、この設定を有効にすると、新しいパーティションへの書き込み開始後に不完全な結果が返されることがありました。 [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) +- DDLの実行時にデータベースが正しく指定されます `ON CLUSTER` クエリと `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- ビュ [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) +- のバグを修正しました `PREWHERE` と `FINAL` のために `VersionedCollapsingMergeTree`. [7167bfd7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) +- 今すぐ使用できます `KILL QUERY` テーブルがロックされるのを待っているためにまだ開始されていないクエリを取り消す。 [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) +- 時計が真夜中に戻った場合の日付と時刻の計算を修正しました(これはイランで起こり、1981年から1983年までモスクワで起こりました)。 以前は、これにより、時刻が必要以上に早くリセットされ、日付と時刻がテキスト形式で正しく書式設定されなくなりました。 [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) +- いくつかのケースでバグを修正 `VIEW` データベースを省略するサブクエリ。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3521) +- Aから同時に読み取るときの競合状態を修正しました `MATERIALIZED VIEW` と削除a `MATERIALIZED VIEW` 内部を締めないことが原因で `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) +- エラーを修正しました `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) +- 固定クエリ処理時に `compile_expressions` オプションは有効です(デフォルトで有効です)。 次のような非決定性定数式 `now` 機能が展開されなくなりました。 [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) +- 非定数スケール引数を指定するとクラッシュする問題を修正しました。 `toDecimal32/64/128` 機能。 +- で配列を挿入しようとするとエラーを修正しました `NULL` の要素 `Values` 型の列にフォーマットする `Array` なし `Nullable` (もし `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) +- 固定連続エラーログイン `DDLWorker` 飼育係が利用できない場合。 [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) +- の戻り値の型を修正しました `quantile*` からの関数 `Date` と `DateTime` 引数のタイプ。 [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) +- 固定された `WITH` 句式なしで単純な別名を指定する場合。 [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) +- 指定されたサブクエリと修飾された列名を持つクエリの処理を修正しました。 `enable_optimize_predicate_expression` 有効です。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3588) +- エラーを修正しました `Attempt to attach to nullptr thread group` マテリアライズドビューを操作する場合。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) +- 特定の不正な引数を渡すときにクラッシュを修正しました。 `arrayReverse` 機能。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- バッファオーバーフローを修正 `extractURLParameter` 機能。 改善された性能。 ゼロバイトを含む文字列の正しい処理を追加しました。 [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) +- の固定バッファオーバーフロー `lowerUTF8` と `upperUTF8` 機能。 これらの関数を実行する機能を削除しました `FixedString` 引数を入力します。 [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) +- 削除時にまれな競合状態を修正 `MergeTree` テーブル [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) +- から読み取るときに競合状態を修正しました `Buffer` テーブルと同時に実行 `ALTER` または `DROP` ターゲットテーブル上。 [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) +- この場合、segfaultを修正しました。 `max_temporary_non_const_columns` 制限を超えました。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### 改善: {#improvements-1} + +- サーバは、処理された設定ファイルを `/etc/clickhouse-server/` ディレクトリ。 その代り、それはそれらをで救います `preprocessed_configs` 内部ディレクトリ `path`. これは、 `/etc/clickhouse-server/` ディレクトリに書き込みアクセス権がない `clickhouse` セキュリティを向上させるユーザ。 [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) +- その `min_merge_bytes_to_use_direct_io` optionはデフォルトで10GiBに設定されています。 MergeTreeファミリーからテーブルの大部分を形成するマージは、以下で実行されます `O_DIRECT` 過剰なページキャッシュの削除を防止するモード。 [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) +- 非常に多数のテーブルがある場合、サーバーの起動を加速します。 [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) +- 接続プールとHTTPを追加しました `Keep-Alive` レプリカ間の接続の場合。 [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) +- クエリ構文が無効な場合は、 `400 Bad Request` コードは `HTTP` インターフェイス(500返還し上げます。 [31bc680a](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) +- その `join_default_strictness` オプションは `ALL` 互換性のためにデフォルトで。 [120e2cbe](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) +- 削除されたログに `stderr` から `re2` 無効または複雑な正規表現のライブラリ。 [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) +- のために追加 `Kafka` テーブルエンジン:Kafkaからの読み取りを開始する前にサブスクリプションをチェックします。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) +- その `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32`,and `murmurHash3_64` 関数は、任意の数の引数とタプル形式の引数に対して機能します。 [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) +- その `arrayReverse` 関数は現在、配列の任意の型で動作します。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- オプションのパラメータを追加しました。 `timeSlots` 機能。 [キリル-シュヴァコフ](https://github.com/ClickHouse/ClickHouse/pull/3724) +- のために `FULL` と `RIGHT JOIN` は、 `max_block_size` 設定は、右側のテーブルから結合されていないデータのストリームに使用されます。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3699) +- 追加された `--secure` コマンドラインパラメー `clickhouse-benchmark` と `clickhouse-performance-test` TLSを有効にする。 [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) +- 型変換のときの構造a `Buffer` タイプtableがターゲットテーブルの構造と一致しません。 [ヴィタリー-バラノフ](https://github.com/ClickHouse/ClickHouse/pull/3603) +- 追加された `tcp_keep_alive_timeout` オプションをキープアライブパケットの後、運動不足のために指定された時間間隔で出ています。 [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) +- パーティションキーの値の不要なクォートを削除しました。 `system.parts` 単一の列で構成されている場合は表。 [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) +- モジュロ関数は `Date` と `DateTime` データ型。 [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) +- の同義語を追加しました `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR`,and `MID` 機能。 [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) 一部の関数名は、SQL標準との互換性のために大文字と小文字を区別しません。 追加された構文的な砂糖 `SUBSTRING(expr FROM start FOR length)` SQLとの互換性のため。 [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) +- に機能を追加しました `mlock` に対応するメモリページ `clickhouse-server` メモリから強制されないようにする実行可能コード。 この機能は既定で無効になっています。 [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) +- した場合の性能改善からの読み出し `O_DIRECT` (と `min_bytes_to_use_direct_io` オプションが有効)。 [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) +- の改善された性能 `dictGet...OrDefault` 定数キー引数と定数でないデフォルト引数の関数。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3563) +- その `firstSignificantSubdomain` 関数は現在、ドメインを処理します `gov`, `mil`,and `edu`. [イゴール-ハタリス](https://github.com/ClickHouse/ClickHouse/pull/3601) 改善された性能。 [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) +- 起動するためのカスタム環境変数を指定する機能 `clickhouse-server` を使用して `SYS-V init.d` 定義によるスクリプト `CLICKHOUSE_PROGRAM_ENV` で `/etc/default/clickhouse`. + [パヴロ-バシンスキー](https://github.com/ClickHouse/ClickHouse/pull/3612) +- Clickhouse-server initスクリプトの戻りコードを修正します。 [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) +- その `system.metrics` テーブルに今あります `VersionInteger` メトリック、および `system.build_options` 追加された行がある `VERSION_INTEGER` これには、ClickHouseバージョンの数値形式が含まれます。 `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) +- 比較する機能を削除しました `Date` 型番号のようなエラーの可能性を回避 `date = 2018-12-17` 日付の前後の引用符が誤って省略されている場合。 [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) +- のようなステートフル関数の動作を修正しました `rowNumberInAllBlocks`. 以前は、クエリ分析中に開始されたため、一つの数値が大きかった結果を出力していました。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3729) +- もし `force_restore_data` エラーメッセージが表示されます。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3794) + +#### ビルドの改善: {#build-improvements-1} + +- 更新された `jemalloc` 潜在的なメモリリークを修正するライブラリ。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3557) +- プロファイル `jemalloc` はデフォルトで有効になるようにするためのデバッグ構造を作成する環境が整いました [2cc82f5c](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) +- 統合テストを実行する機能を追加しました。 `Docker` システムにインス [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) +- SELECTクエリにfuzz式テストを追加しました。 [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) +- 複数の競合状態を検出するために、機能テストを並行してランダムに実行するコミットのストレステストを追加しました。 [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) +- Dockerイメージでclickhouse-serverを起動する方法を改善しました。 [エルガザル-アフメド](https://github.com/ClickHouse/ClickHouse/pull/3663) +- のためのDocker画像の追加支援のための初期化データベース用のファイルを `/docker-entrypoint-initdb.d` ディレクトリ。 [コンスタンチン-レベデフ](https://github.com/ClickHouse/ClickHouse/pull/3695) +- ARM上のビルドの修正。 [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) + +#### 下位互換性のない変更: {#backward-incompatible-changes} + +- 比較する機能を削除しました `Date` 数字を入力します。 代わりに `toDate('2018-12-18') = 17883` 明示的な型変換を使用する必要があります `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) + +## ClickHouseリリース18.14 {#clickhouse-release-18-14} + +### ClickHouseリリース18.14.19、2018年12月19日 {#clickhouse-release-18-14-19-2018-12-19} + +#### バグ修正: {#bug-fixes-2} + +- ODBCソースで辞書を更新する際に問題が発生するエラーを修正しました。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- DDLの実行時にデータベースが正しく指定されます `ON CLUSTER` クエリ。 [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- この場合、segfaultを修正しました。 `max_temporary_non_const_columns` 制限を超えました。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### ビルドの改善: {#build-improvements-2} + +- ARM上のビルドの修正。 + +### ClickHouseリリース18.14.18,2018-12-04 {#clickhouse-release-18-14-18-2018-12-04} + +#### バグ修正: {#bug-fixes-3} + +- 修正されたエラーで `dictGet...` 型の辞書のための関数 `range`、引数のいずれかが定数であり、他がない場合。 [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) +- メッセ `netlink: '...': attribute type 1 has an invalid length` 印刷するLinuxカーネルのログをとったい何が起こっていただけ新鮮なバージョンのLinuxカーネルです。 [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) +- 関数内の固定segfault `empty` の引数 `FixedString` タイプ。 [ダニエル-ダオ-クアン-ミン](https://github.com/ClickHouse/ClickHouse/pull/3703) +- 固定の過剰なメモリ割り当てが大きな値を示すことを `max_query_size` のメモリチャンク `max_query_size` 一度に事前割り当てされたバイト)。 [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) + +#### ビルドの変更: {#build-changes} + +- 固定の構築をLLVM/Clangライブラリのバージョン7のOSのパッケージ(これらのライブラリを利用しています実行時のクエリを集める [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### ClickHouseリリース18.14.17,2018-11-30 {#clickhouse-release-18-14-17-2018-11-30} + +#### バグ修正: {#bug-fixes-4} + +- ODBCブリッジプロセスがメインサーバープロセスで終了しない場合を修正しました。 [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) +- への固定同期挿入 `Distributed` リモートテーブルの列リストとは異なる列リストを持つテーブル。 [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) +- MergeTreeテーブルをドロップするときにクラッシュする可能性があるまれな競合状態を修正しました。 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- クエリスレッドの作成に失敗した場合のクエリデッドロックを修正しました。 `Resource temporarily unavailable` エラー [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- の修正された解析 `ENGINE` 句とき `CREATE AS table` 構文が使用され、 `ENGINE` の前に句が指定された。 `AS table` (エラーは指定されたエンジンを無視しました)。 [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) + +### ClickHouseリリース18.14.15,2018-11-21 {#clickhouse-release-18-14-15-2018-11-21} + +#### バグ修正: {#bug-fixes-5} + +- 型の列を逆シリアル化している間に、メモリチャンクのサイズが過大評価されました `Array(String)` それはにつながる “Memory limit exceeded” エラー この問題はバージョン18.12.13に登場しました。 [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) + +### ClickHouseリリース18.14.14,2018-11-20 {#clickhouse-release-18-14-14-2018-11-20} + +#### バグ修正: {#bug-fixes-6} + +- 固定 `ON CLUSTER` クエリがクラスタ設定の確保(フラグ ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) + +#### ビルドの変更: {#build-changes-1} + +- 修正された問題(システムからllvm-7、macosの) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### ClickHouseリリース18.14.13,2018-11-08 {#clickhouse-release-18-14-13-2018-11-08} + +#### バグ修正: {#bug-fixes-7} + +- 固定された `Block structure mismatch in MergingSorted stream` エラー [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) +- 固定 `ON CLUSTER` セキュリティで保護された接続がクラスタ設定でオンになっている場合のクエリ `` 旗)。 [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) +- 使用するクエリのエラーを修正しました `SAMPLE`, `PREWHERE` エイリアス列。 [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) +- レアを修正 `unknown compression method` エラー時 `min_bytes_to_use_direct_io` 設定が有効になりました。 [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) + +#### 性能の向上: {#performance-improvements} + +- クエリのパフォーマンス回帰を修正 `GROUP BY` AMD EPYCプロセッサで実行するときのuint16またはDate型の列。 [イゴール-ラップコ](https://github.com/ClickHouse/ClickHouse/pull/3512) +- 長い文字列を処理するクエリのパフォーマンス回帰を修正。 [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) + +#### ビルドの改善: {#build-improvements-3} + +- Arcadiaビルドを簡素化するための改善。 [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) + +### ClickHouseリリース18.14.12,2018-11-02 {#clickhouse-release-18-14-12-2018-11-02} + +#### バグ修正: {#bug-fixes-8} + +- 固定クラッシュに当社では豊富な種類の名前のないサブクエリ. [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) +- 正しくないクエリを生成する修正(空 `WHERE` 句)外部データベースを照会する場合。 [ホティド](https://github.com/ClickHouse/ClickHouse/pull/3477) +- ODBC辞書で誤ったタイムアウト値を使用して修正しました。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) + +### ClickHouseリリース18.14.11、2018年10月29日 {#clickhouse-release-18-14-11-2018-10-29} + +#### バグ修正: {#bug-fixes-9} + +- エラーを修正しました `Block structure mismatch in UNION stream: different number of columns` 制限クエリで。 [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) +- 固定誤差が統合データテーブルを含む配列内の入れ子構造です。 [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) +- 修正された不正確なクエリ結果 `merge_tree_uniform_read_distribution` 設定は無効です(デフォルトで有効です)。 [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) +- ネイティブ形式の分散テーブルへの挿入時のエラーを修正しました。 [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) + +### ClickHouseリリース18.14.10、2018年10月23日 {#clickhouse-release-18-14-10-2018-10-23} + +- その `compile_expressions` 設定(式のJITコンパイル)はデフォルトで無効になっています。 [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) +- その `enable_optimize_predicate_expression` 設定はデフォルトでは無効です。 + +### ClickHouseリリース18.14.9、2018年10月16日 {#clickhouse-release-18-14-9-2018-10-16} + +#### 新しい機能: {#new-features-1} + +- その `WITH CUBE` 修飾子のための `GROUP BY` (代替構文 `GROUP BY CUBE(...)` また利用できます)。 [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) +- 追加された `formatDateTime` 機能。 [アレクサンドル-クラシェニニコフ](https://github.com/ClickHouse/ClickHouse/pull/2770) +- 追加された `JDBC` テーブルエンジンと `jdbc` 表関数(clickhouse-jdbc-bridgeのインストールが必要)。 [アレクサンドル-クラシェニニコフ](https://github.com/ClickHouse/ClickHouse/pull/3210) +- ISO週番号を操作するための機能を追加しました: `toISOWeek`, `toISOYear`, `toStartOfISOYear`,and `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) +- 今すぐ使用できます `Nullable` の列 `MySQL` と `ODBC` テーブル [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- 入れ子になったデータ構造は、 `JSONEachRow` 形式。 追加された `input_format_import_nested_json` 設定。 [ヴェロマン-ユンカン](https://github.com/ClickHouse/ClickHouse/pull/3144) +- 並列処理は多くの人に利用可能です `MATERIALIZED VIEW`sデータを挿入するとき。 を参照。 `parallel_view_processing` 設定。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) +- 追加された `SYSTEM FLUSH LOGS` query(以下のようなシステムテーブルへの強制ログフラッシュ `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) +- これで、事前定義を使用できます `database` と `table` 宣言時のマクロ `Replicated` テーブル [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) +- 読む機能を追加しました `Decimal` 工学表記の値を入力します(十の累乗を示します)。 [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) + +#### 実験的な特徴: {#experimental-features} + +- GROUP BY句の最適化 `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) +- の式の最適化された計算 `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) + +#### 改善: {#improvements-2} + +- クエリのメモリ消費を大幅に削減 `ORDER BY` と `LIMIT`. を参照。 `max_bytes_before_remerge_sort` 設定。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- の不在下で `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` が仮定される。 [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) +- 修飾されたアスタリスクは `JOIN`. [冬張](https://github.com/ClickHouse/ClickHouse/pull/3202) +- その `ODBC` テーブルエンジンは、リモートデータベースのSQL方言で識別子を引用する方法を正しく選択します。 [アレクサンドル-クラシェニニコフ](https://github.com/ClickHouse/ClickHouse/pull/3210) +- その `compile_expressions` デフォルトでは、設定(式のJITコンパイル)が有効です。 +- 固定の挙動を同時に落データベース/テーブルが存在すると作成してデータベースとテーブルのない場合が存在します。 以前は `CREATE DATABASE ... IF NOT EXISTS` クエリが返すエラーメッセージ “File … already exists”、および `CREATE TABLE ... IF NOT EXISTS` と `DROP TABLE IF EXISTS` クエリが返される `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) +- LIKEおよびIN式は、MySQLまたはODBCテーブルからクエリするときに、リモートサーバーに渡されます。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- WHERE句の定数式との比較は、MySQLおよびODBCテーブルからクエリするときにリモートサーバーに渡されます。 以前は、定数との比較のみが渡されました。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- ターミナルの行幅の正しい計算 `Pretty` 象形文字を含む文字列を含む形式。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/3257). +- `ON CLUSTER` に指定することができます `ALTER UPDATE` クエリ。 +- データを読み取るための性能の向上 `JSONEachRow` 形式。 [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) +- の同義語を追加しました `LENGTH` と `CHARACTER_LENGTH` 互換性のための機能。 その `CONCAT` 関数では大文字と小文字が区別されなくなりました。 [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) +- 追加された `TIMESTAMP` の同義語 `DateTime` タイプ。 [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) +- ログ行がクエリに関連していない場合でも、サーバーログにはquery\_id用のスペースが常に確保されています。 それによる解析サーバーテキストログとして第三者ツールです。 +- クエリによるメモリ消費は、次のレベルの整数レベルのギガバイトを超えるとログに記録されます。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- ネイティブプロトコルを使用するクライアントライブラリが誤って送信する列の数が、サーバーがINSERTクエリで想定している数より少ない場合の互換 このシナリオは、clickhouse-cppライブラリを使用する場合に可能でした。 従来、このシナリオのサーバーンダリングする能力があります。 [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) +- ユーザー定義のWHERE式では `clickhouse-copier` これで、aを使うことができます `partition_key` エイリアス(追加フィルタリングによるソーステーブルの分割). これがなければならないときに便利でのパーティショニングスキーマの変化の中で複製、変更するわけです。 [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) +- のワークフロー `Kafka` 高負荷でのデータ読み取り速度を自動的に低下させるために、エンジンがバックグラウンドスレッドプールに移動しました。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- 読書のサポート `Tuple` と `Nested` 次のような構造体の値 `struct` で `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) +- トップレベルドメインの一覧 `firstSignificantSubdomain` 関数にはドメインが含まれます `biz`. [デカシール](https://github.com/ClickHouse/ClickHouse/pull/3219) +- 外部辞書の構成, `null_value` 既定のデータ型の値として解釈されます。 [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) +- のためのサポート `intDiv` と `intDivOrZero` のための機能 `Decimal`. [b48402e8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) +- のためのサポート `Date`, `DateTime`, `UUID`,and `Decimal` のキーとしての型 `sumMap` 集計関数。 [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) +- のためのサポート `Decimal` 外部辞書のデータ型。 [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) +- のためのサポート `Decimal` データ型in `SummingMergeTree` テーブル [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) +- 特殊化を追加 `UUID` で `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) +- 数をの減らしました `open` と `close` システムコール `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) +- A `TRUNCATE TABLE` クエリは任意のレプリカで実行できます(クエリはリーダーレプリカに渡されます)。 [キリル-シュヴァコフ](https://github.com/ClickHouse/ClickHouse/pull/3375) + +#### バグ修正: {#bug-fixes-10} + +- 問題を修正しました `Dictionary` 以下の表 `range_hashed` 辞書。 このエラーは、バージョン18.12.17で発生しました。 [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) +- ロード時のエラーを修正 `range_hashed` 辞書(メッセージ `Unsupported type Nullable (...)`). このエラーは、バージョン18.12.17で発生しました。 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- の修正されたエラー `pointInPolygon` 互いに近くに位置する多数の頂点を有するポリゴンの不正確な計算の蓄積による機能。 [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) +- データパーツをマージした後、結果のパーツのチェックサムが別のレプリカの同じマージの結果と異なる場合、マージの結果が削除され、データパーツが他のレプリカ しかし、データパーツをダウンロードした後、そのパーツが既に存在するというエラーが発生したため、作業セットに追加できませんでした(マージ後にデータパーツが この循環的な試みをダウンロードします。 [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) +- クエリによる総メモリ消費の誤った計算を修正しました(誤った計算のため、 `max_memory_usage_for_all_queries` 設定は不正確に働き、 `MemoryTracking` ミリ規格が誤った値)となります。 このエラーは、バージョン18.12.13で発生しました。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) +- の機能を修正しました `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` このエラーは、バージョン18.12.13で発生しました。 [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) +- のためのデータ構造の固定不要な準備 `JOIN`クエリを開始するサーバー上のs `JOIN` リモートサーバーでのみ実行されます。 [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) +- のバグを修正しました `Kafka` エンジン:データの読み取り開始時に例外の後にデッドロックし、完了時にロック [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- のために `Kafka` テーブル、オプション `schema` パラメータが渡されませんでした。 `Cap'n'Proto` 形式)。 [Vojtech Splichal](https://github.com/ClickHouse/ClickHouse/pull/3150) +- ZooKeeperサーバーの集団に、接続を受け入れるサーバーがあるが、ハンドシェイクに応答せずにすぐに接続を閉じる場合、ClickHouseは別のサーバーに接続することを選択しま 以前は、これはエラーを生成しました `Cannot read all data. Bytes read: 0. Bytes expected: 4.` サーバーが起動できませんでした。 [818cf3a](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) +- ZooKeeperサーバーの集団にDNSクエリがエラーを返すサーバーが含まれている場合、これらのサーバーは無視されます。 [17b8e209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) +- 間の固定型変換 `Date` と `DateTime` にデータを挿入するとき `VALUES` フォーマット(if `input_format_values_interpret_expressions = 1`). 以前は、Unixエポック時間の日数の数値とUnixタイムスタンプの間で変換が行われていたため、予期しない結果になりました。 [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) +- 間の修正型変換 `Decimal` と整数。 [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) +- の修正されたエラー `enable_optimize_predicate_expression` 設定。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3231) +- デフォルト以外のCSV区切り文字が使用されている場合、次のような浮動小数点数を使用したCSV形式の解析エラーを修正しました `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) +- 固定された `arrayCumSumNonNegative` 関数(アキュムレータがゼロより小さい場合、負の値は蓄積されません)。 [アレクセイ-スタドネフ](https://github.com/ClickHouse/ClickHouse/pull/3163) +- 固定方法 `Merge` テーブルはの上に働きます `Distributed` 使用する場合のテーブル `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) +- のバグ修正 `ALTER UPDATE` クエリ。 +- のバグを修正しました `odbc` バージョン18.12で登場したテーブル関数。 [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) +- 集計関数の操作を修正しました `StateArray` コンビネーター [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) +- 分割時にクラッシュを修正しました `Decimal` 値はゼロです。 [69dd6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) +- を使用して操作のための型の固定出力 `Decimal` と整数引数。 [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) +- 中にsegfaultを修正しました `GROUP BY` に `Decimal128`. [3359ba06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) +- その `log_query_threads` 設定(クエリ実行の各スレッドに関するロギング情報)が有効になるようになりました。 `log_queries` オプション(クエリに関するログ情報)は1に設定されます。 以来、 `log_query_threads` オプションはデフォルトで有効になっています。 [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) +- Quantiles集計関数の分散操作のエラーを修正しました(エラーメッセージ `Not found column quantile...`). [292a8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) +- バージョン18.12.17サーバーと古いサーバーのクラスターで同時に作業するときの互換性の問題を修正しました。 固定長と非固定長の両方のGROUP BYキーを持つ分散クエリでは、集計する大量のデータがある場合、返されるデータは必ずしも完全に集計されるとは限りませ [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) +- 置換の処理を修正しました。 `clickhouse-performance-test`、クエリにテストで宣言された置換の一部のみが含まれている場合。 [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) +- 使用時にエラーを修正しました `FINAL` と `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- 使用時にエラーを修正しました `PREWHERE` 中に追加された列の上 `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- の不在のためのチェックを追加しました `arrayJoin` のために `DEFAULT` と `MATERIALIZED` 式。 以前は, `arrayJoin` データ挿入時にエラーが発生しました。 [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) +- の不在のためのチェックを追加しました `arrayJoin` で `PREWHERE` 句。 従来、このようなメッセージ `Size ... doesn't match` または `Unknown compression method` クエリを実行するとき。 [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) +- 最適化の後にまれに発生する可能性のあるsegfaultを修正しました。 [リュイミン-バイトダンス](https://github.com/ClickHouse/ClickHouse/pull/3339) +- へのマイナーな修正 `clickhouse-benchmark`:以前は、クライアント情報はサーバーに送信されていませんでしたが、シャットダウン時や反復回数を制限するために、実行されるクエリの数がより正確 [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) + +#### 下位互換性のない変更: {#backward-incompatible-changes-1} + +- 削除された `allow_experimental_decimal_type` オプション その `Decimal` データ型はデフォルトで使用できます。 [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) + +## ClickHouseリリース18.12 {#clickhouse-release-18-12} + +### ClickHouseリリース18.12.17,2018-09-16 {#clickhouse-release-18-12-17-2018-09-16} + +#### 新しい機能: {#new-features-2} + +- `invalidate_query` (外部ディクショナリを更新する必要があるかどうかをチェックするためのクエリを指定する機能) `clickhouse` 出典 [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) +- 使用する機能を追加しました `UInt*`, `Int*`,and `DateTime` データ型(とともに `Date` aとしてタイプ) `range_hashed` 範囲の境界を定義する外部辞書キー。 さて `NULL` 開いている範囲を指定するために使用できます。 [ヴァシーリー-ネムコフ](https://github.com/ClickHouse/ClickHouse/pull/3123) +- その `Decimal` タイプがサポート `var*` と `stddev*` 集計関数。 [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- その `Decimal` タイプに対応しま数理機能 (`exp`, `sin` など。) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- その `system.part_log` テーブルに今あります `partition_id` 列。 [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### バグ修正: {#bug-fixes-11} + +- `Merge` 今正しく動作します `Distributed` テーブル [冬張](https://github.com/ClickHouse/ClickHouse/pull/3159) +- 非互換性を修正しました。 `glibc` ClickHouseを実行することが不可能になったバージョン) `Ubuntu Precise` と古いバージョン。 非互換性はバージョン18.12.13で発生しました。 [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) +- の修正されたエラー `enable_optimize_predicate_expression` 設定。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3107) +- 18.12.13より前のバージョンのレプリカのクラスターを操作し、新しいバージョンのサーバー上にテーブルの新しいレプリカを同時に作成するときに表示される `Can not clone replica, because the ... updated to new ClickHouse version` これは論理的ですが、起こるべきではありません)。 [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) + +#### 下位互換性のない変更: {#backward-incompatible-changes-2} + +- その `enable_optimize_predicate_expression` オプションはデフォルトで有効化されてると楽観的に). 列名の検索に関連するクエリ分析エラーが発生した場合は、次のように設定します `enable_optimize_predicate_expression` 0にする。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3107) + +### ClickHouseリリース18.12.14,2018-09-13 {#clickhouse-release-18-12-14-2018-09-13} + +#### 新しい機能: {#new-features-3} + +- 追加されたサポート `ALTER UPDATE` クエリ。 [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) +- 追加された `allow_ddl` DDLクエリへのユーザーのアクセスを制限するオプション。 [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) +- 追加された `min_merge_bytes_to_use_direct_io` 選択のための `MergeTree` これにより、マージの合計サイズのしきい値を設定できます(しきい値を超えると、データパートファイルはO\_DIRECTを使用して処理されます)。 [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) +- その `system.merges` システムテーブルには `partition_id` 列。 [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) + +#### 改善 {#improvements-3} + +- 場合のデータ部分を据え置き期間中、突然変異なダウンロードによるレプリカ. [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) +- オートコンプリートは、操作時に設定の名前に使用できます `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) + +#### バグ修正: {#bug-fixes-12} + +- の要素である配列のサイズのチェックを追加しました `Nested` 挿入時に項目を入力します。 [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) +- 外部辞書の更新エラーを修正しました。 `ODBC` ソースと `hashed` ストレージ。 このエラーは、バージョン18.12.13で発生しました。 +- クエリから一時テーブルを作成するときにクラッシュを修正しました。 `IN` 条件だ [冬張](https://github.com/ClickHouse/ClickHouse/pull/3098) +- 配列の集計関数のエラーを修正しました。 `NULL` 要素。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3097) + +### ClickHouseリリース18.12.13,2018-09-10 {#clickhouse-release-18-12-13-2018-09-10} + +#### 新しい機能: {#new-features-4} + +- 追加された `DECIMAL(digits, scale)` データ型 (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). 有効にするには、この設定を使用します `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) +- 新しい `WITH ROLLUP` 修飾子のための `GROUP BY` (代替構文: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) +- JOINを使用したクエリでは、スター文字はSQL標準に準拠して、すべてのテーブルの列のリストに展開されます。 設定することで、古い動作を復元できます `asterisk_left_columns_only` ユーザー設定レベルでは1になります。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2787) +- 表関数との結合のサポートが追加されました。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2907) +- Clickhouse-clientでTabキーを押してオートコンプリートします。 [セルゲイ-シチェルビン](https://github.com/ClickHouse/ClickHouse/pull/2447) +- Clickhouse-clientでCtrl+Cを押すと、入力されたクエリがクリアされます。 [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) +- 追加された `join_default_strictness` 設定(値: `"`, `'any'`, `'all'`). これにより、指定しないでください `ANY` または `ALL` のために `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) +- クエリ処理に関連するサーバログの各行には、クエリIDが表示されます。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- これで、clickhouse-clientでクエリ実行ログを取得できます。 `send_logs_level` 設定)。 分散クエリ処理では、すべてのサーバーからログがカスケードされます。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- その `system.query_log` と `system.processes` (`SHOW PROCESSLIST`)テーブルいに関する情報は、変更されているすべての設定を実行するとき、クエリーの入れ子構造の `Settings` データ)。 追加された `log_query_settings` 設定。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- その `system.query_log` と `system.processes` テーブルには、クエリの実行に参加しているスレッドの数に関する情報が表示されます。 `thread_numbers` 列)。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 追加 `ProfileEvents` ネットワーク経由の読み取りと書き込み、およびディスクへの読み取りと書き込みに費やされた時間、ネットワークエラーの数、およびネットワーク帯域幅が [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 追加 `ProfileEvents`rusageのシステムメトリックを含むカウンター(ユーザースペースでのCPU使用率、カーネル、ページフォールト、およびコンテキストスイッチに関する情報を取得するため [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- その `ProfileEvents` カウンターはグローバルに適用され、クエリごとに、またクエリ実行スレッドごとに適用されます。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 追加された `system.query_thread_log` 各クエリ実行スレッドに関する情報を含むテーブル。 追加された `log_query_threads` 設定。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- その `system.metrics` と `system.events` 表現を内蔵しております。 [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) +- 追加された `arrayEnumerateDense` 機能。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2975) +- 追加された `arrayCumSumNonNegative` と `arrayDifference` 機能。 [アレクセイ-スタドネフ](https://github.com/ClickHouse/ClickHouse/pull/2942) +- 追加された `retention` 集計関数。 [サンディ-リー](https://github.com/ClickHouse/ClickHouse/pull/2887) +- これで、plus演算子を使用して集計関数の状態を追加(マージ)し、集計関数の状態に非負の定数を掛けることができます。 [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) +- MergeTreeファミリ内のテーブルに仮想列があるようになりました `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### 実験的な特徴: {#experimental-features-1} + +- 追加された `LowCardinality(T)` データ型。 このデータ型で自動的に作成さ辞書の値でデータ処理せずに開封の辞書です。 [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) +- JITでコンパイルされた関数のキャッシュと、コンパイル前の使用回数のカウンタを追加しました。 式をJITコンパイルするには、 `compile_expressions` 設定。 [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) + +#### 改善: {#improvements-4} + +- 固定問題の無限の集積レプリケーションログの場合があり捨ててレプリカ. を追加しました効率的な回収モードのためのレプリカとの長期に遅れて波及してきています。 +- の改善された性能 `GROUP BY` それらのいずれかが文字列で、他のものが固定長の場合、複数の集計フィールドを使用します。 +- 使用時のパフォーマンスの向上 `PREWHERE` そして、式の暗黙の転送で `PREWHERE`. +- テキスト形式の解析性能の向上 (`CSV`, `TSV`). [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) +- の性能向上と読書文字列およびアレイバイナリ形式 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2955) +- クエリのパフォーマンスの向上とメモリ消費の削減 `system.tables` と `system.columns` 単一のサーバー上に非常に多数のテーブルがある場合。 [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) +- クエリのストリームが大きい場合のパフォーマンスの問題を修正しました。 `_dl_addr` 関数は `perf top` しかし、サーバーは多くのCPUを使用していません)。 [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) +- 条件はビューにキャストされます `enable_optimize_predicate_expression` 有効になっています)。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2907) +- のための機能の改善 `UUID` データ型。 [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) +- その `UUID` データ型は、-Alchemist辞書でサポートされています。 [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) +- その `visitParamExtractRaw` 関数は、入れ子構造で正しく動作します。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2974) +- ときに `input_format_skip_unknown_fields` オブジェクトフィールドが有効になる `JSONEachRow` フォーマットはスキップされます。 [BlahGeek](https://github.com/ClickHouse/ClickHouse/pull/2958) +- のために `CASE` 条件付きの式を省略できるようになりました `ELSE` これは `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) +- 操作タイムアウトで設定する場合、どの飼育係. [ウリーキー](https://github.com/ClickHouse/ClickHouse/pull/2971) +- のオフセットを指定できます `LIMIT n, m` として `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- を使用することができます `SELECT TOP n` 代替としての構文 `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- システムテーブルに書き込むキューのサイズを増やしたので、 `SystemLog parameter queue is full` エラーは頻繁に発生しません。 +- その `windowFunnel` 集計機能に対応しまイベントが複数の条件です。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2801) +- 重複する列は、 `USING` の句 `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) +- `Pretty` フォーマットの幅による列の配置に制限があります。 使用する `output_format_pretty_max_column_pad_width` 設定。 値が広い場合は、全体が表示されますが、テーブル内の他のセルはあまり広くはありません。 [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) +- その `odbc` 表関数では、データベース/スキーマ名を指定することができます。 [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2885) +- で指定されたユーザ名を使用する機能を追加しました `clickhouse-client` 設定ファイル。 [ウラジミールKozbin](https://github.com/ClickHouse/ClickHouse/pull/2909) +- その `ZooKeeperExceptions` カウンターは三つに分割されています: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions`,and `ZooKeeperOtherExceptions`. +- `ALTER DELETE` クエリの作業を実現します。 +- 追加のランダム化の実行時にスレッドの清掃活動を定期的に `ReplicatedMergeTree` 非常に大きい数がある場合の周期的な負荷スパイクを避けるためにテーブル `ReplicatedMergeTree` テーブル +- のサポート `ATTACH TABLE ... ON CLUSTER` クエリ。 [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) + +#### バグ修正: {#bug-fixes-13} + +- 問題を修正しました `Dictionary` テーブル(スロー `Size of offsets doesn't match size of column` または `Unknown compression method` 例外)。 このバグに登場したバージョン18.10.3. [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) +- マージ時のバグを修正 `CollapsingMergeTree` テーブルの場合、データのパーツは空です(これらの部品の形成時の併合または `ALTER DELETE` すべてのデータが削除された場合)、および `vertical` マージにはアルゴリズムを使用した。 [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) +- 中に競合状態を修正しました `DROP` または `TRUNCATE` のために `Memory` 同時のテーブル `SELECT` サーバーがクラッシュする可能性があります。 このバグはバージョン1.1.54388に登場しました。 [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) +- 挿入時のデータ損失の可能性を修正しました `Replicated` テーブル `Session is expired` エラーが返されます(データ損失は `ReplicatedDataLoss` メートル法)。 このエラーはバージョン1.1.54378で発生しました。 [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) +- 中にsegfaultを修正しました `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) +- カラム名の検索エラーを修正しました。 `WHERE` 式は完全に修飾された列名で構成されます。 `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) +- 固定された “Not found column” サブクエリを持つIN式で構成される単一の列がリモートサーバーから要求された場合に分散クエリを実行するときに発生したエラー。 [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) +- 固定された `Block structure mismatch in UNION stream: different number of columns` シャードの一方がローカルで、他方がそうでない場合に分散クエリで発生したエラー、および移動先の最適化 `PREWHERE` トリガーされます。 [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) +- 固定された `pointInPolygon` 非凸多角形の特定のケースのための関数。 [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) +- 比較時の誤った結果を修正しました `nan` 整数です。 [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) +- のエラーを修正しました。 `zlib-ng` まれにsegfaultにつながる可能性のあるライブラリ。 [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) +- テーブルに挿入するときにメモリリークを修正しました `AggregateFunction` 集計関数の状態が単純でない場合(メモリを別々に割り当てる場合)、および単一の挿入要求が複数の小さなブロックになる場合。 [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) +- 同じを作成および削除するときに競合状態を修正しました `Buffer` または `MergeTree` 同時にテーブル。 +- タプルなどの特定の非自明な型で構成されるタプルを比較するときにsegfaultの可能性を修正しました。 [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) +- 特定の実行時にsegfaultの可能性を修正しました `ON CLUSTER` クエリ。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2960) +- のエラーを修正しました。 `arrayDistinct` 機能のための `Nullable` 配列要素。 [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) +- その `enable_optimize_predicate_expression` オプションが正しく `SELECT *`. [冬張](https://github.com/ClickHouse/ClickHouse/pull/2929) +- ZooKeeperセッションの再初期化時にsegfaultを修正しました。 [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) +- ZooKeeperで作業するときに固定された潜在的なブロック。 +- 修正コードをネストしたデータ構造 `SummingMergeTree`. +- 集計関数の状態にメモリを割り当てる場合、整列が正しく考慮されるため、集計関数の状態を実装するときに整列を必要とする操作を使用するこ [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) + +#### セキュリティ修正: {#security-fix} + +- ODBCデータソースの安全な使用。 ODBCドライバーとの対話は、別の `clickhouse-odbc-bridge` プロセス。 サードパーテ [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) +- ファイルパスの誤った検証を修正しました。 `catBoostPool` テーブル関数。 [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) +- システムテーブルの内容 (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas`,and `replication_queue`)フィルタによると、ユーザーの設定データベースへのアクセス (`allow_databases`). [冬張](https://github.com/ClickHouse/ClickHouse/pull/2856) + +#### 下位互換性のない変更: {#backward-incompatible-changes-3} + +- JOINを使用したクエリでは、スター文字はSQL標準に準拠して、すべてのテーブルの列のリストに展開されます。 設定することで、古い動作を復元できます `asterisk_left_columns_only` ユーザー設定レベルでは1になります。 + +#### ビルドの変更: {#build-changes-2} + +- ほとんどの統合テストはcommitで実行できます。 +- コードスタイルチェックはcommitでも実行できます。 +- その `memcpy` CentOS7/Fedora上でビルドする場合、実装が正しく選択されます。 [エティエンヌ-シャンペイエ](https://github.com/ClickHouse/ClickHouse/pull/2912) +- Clangを使用してビルドする場合、 `-Weverything` は、通常のに加えて、追加されています `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) +- ビルドをデバッグするには `jemalloc` debugオプション。 +- のインタフェースを図書館との交流の飼育係で宣言されていく。 [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) + +## ClickHouseリリース18.10 {#clickhouse-release-18-10} + +### ClickHouseリリース18.10.3,2018-08-13 {#clickhouse-release-18-10-3-2018-08-13} + +#### 新しい機能: {#new-features-5} + +- HTTPSはレプリケーションに使用できます。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) +- 機能を追加しました `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64`,and `murmurHash3_128` 既存のものに加えて `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) +- ClickHouse ODBCドライバーでのNull許容型のサポート (`ODBCDriver2` 出力形式)。 [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) +- のサポート `UUID` キー列で。 + +#### 改善: {#improvements-5} + +- クラスターは、設定ファイルから削除されたときに、サーバーを再起動せずに削除できます。 [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) +- 外部辞書は、設定ファイルから削除されたときに、サーバーを再起動せずに削除できます。 [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) +- 追加 `SETTINGS` のためのサポート `Kafka` テーブルエンジン。 [Alexander Marshalov](https://github.com/ClickHouse/ClickHouse/pull/2781) +- のための改善 `UUID` データ型(まだ完了していない)。 [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) +- マージ後の空の部分のサポート `SummingMergeTree`, `CollapsingMergeTree` と `VersionedCollapsingMergeTree` エンジンだ [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) +- 完了した突然変異の古い記録は削除されます (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) +- 追加された `system.merge_tree_settings` テーブル。 [キリル-シュヴァコフ](https://github.com/ClickHouse/ClickHouse/pull/2841) +- その `system.tables` 表現の依存関係列: `dependencies_database` と `dependencies_table`. [冬張](https://github.com/ClickHouse/ClickHouse/pull/2851) +- 追加された `max_partition_size_to_drop` 設定オプション。 [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) +- 追加された `output_format_json_escape_forward_slashes` オプション [アレクサ](https://github.com/ClickHouse/ClickHouse/pull/2812) +- 追加された `max_fetch_partition_retries_count` 設定。 [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) +- 追加された `prefer_localhost_replica` 設定を無効設定のための現地レプリカや、地元のレプリカな工程間の相互作用 [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) +- その `quantileExact` 集計関数の戻り値 `nan` 空の集計の場合 `Float32` または `Float64` セット [サンディ-リー](https://github.com/ClickHouse/ClickHouse/pull/2855) + +#### バグ修正: {#bug-fixes-14} + +- ODBCの接続文字列パラメータの不要なエスケープを削除し、接続を確立することができなくなりました。 このエラーはバージョン18.6.0で発生しました。 +- 処理のロジックを修正しました `REPLACE PARTITION` 複製キュー内のコマンド。 二つあれば `REPLACE` コマンドと同じパーティション、間違ったロジックが原因の一つの複製のキューは行われなくなります。 [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) +- すべてのデータ部分が空であったときにマージバグを修正しました(マージまたはから形成された部分 `ALTER DELETE` すべてのデータが削除された場合)。 このバグに登場したバージョン18.1.0. [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) +- 同時実行のエラーを修正しました `Set` または `Join`. [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2823) +- 固定された `Block structure mismatch in UNION stream: different number of columns` 発生したエラー `UNION ALL` サブクエリ内のクエリのいずれかが `SELECT` クエリを含む複製のカラム名をとります。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2094) +- MySQLサーバへの接続時に例外が発生した場合のメモリリークを修正しました。 +- クエリエラーの場合に正しくないclickhouseクライアント応答コードを修正しました。 +- DISTINCTを含むマテリアライズドビュ [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) + +#### 下位互換性のない変更 {#backward-incompatible-changes-4} + +- 分散テーブルのCHECK TABLEクエリのサポートを削除しました。 + +#### ビルドの変更: {#build-changes-3} + +- アロケータが置き換えられました: `jemalloc` の代わりに使用されます `tcmalloc`. いくつかのシナリオでは、これは20%までの速度を増加します。 ただし、20%まで減速しているクエリがあります。 一部のシナリオでは、メモリ消費量が約10%削減され、安定性が向上しました。 非常に競争力のある負荷では、ユーザースペースとシステムでのCPU使用率はわずかに増加します。 [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) +- サブモジュールからのlibresslの使用。 [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) +- サブモジュールからのunixodbcの使用。 [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) +- サブモジュールからのmariadb-connector-cの使用。 [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) +- テストデータの可用性に依存する機能テストファイルをリポジトリに追加しました(当分の間、テストデータ自体はありません)。 + +## ClickHouseリリース18.6 {#clickhouse-release-18-6} + +### ClickHouseリリース18.6.0,2018-08-02 {#clickhouse-release-18-6-0-2018-08-02} + +#### 新しい機能: {#new-features-6} + +- JOIN ON構文のON式のサポートが追加されました: + `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` + 式は、AND演算子で結合された等式のチェーンでなければなりません。 等式の各辺は、いずれかのテーブルの列に対する任意の式にすることができます。 完全修飾列名の使用がサポートされています (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`)右のテーブルのために。 [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) +- HTTPSで有効にする必要があります。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) + +#### 改善: {#improvements-6} + +- サーバにパッチ部品のバージョンです。 データのパッチ版コンポーネントが `system.processes` と `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) + +## ClickHouseリリース18.5 {#clickhouse-release-18-5} + +### ClickHouseリリース18.5.1,2018-07-31 {#clickhouse-release-18-5-1-2018-07-31} + +#### 新しい機能: {#new-features-7} + +- ハッシュ関数を追加 `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). + +#### 改善: {#improvements-7} + +- 今すぐ使用することができます `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) 環境変数から設定ファイルの値を設定する属性。 +- 大文字小文字を区別しないバージョンの `coalesce`, `ifNull`,and `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). + +#### バグ修正: {#bug-fixes-15} + +- レプリカの起動時に発生する可能性のあるバグを修正 [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). + +## ClickHouseリリース18.4 {#clickhouse-release-18-4} + +### ClickHouseリリース18.4.0,2018-07-28 {#clickhouse-release-18-4-0-2018-07-28} + +#### 新しい機能: {#new-features-8} + +- 追加システムテーブル: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). +- Aの引数としてテーブルの代わりにテーブル関数を使用する機能を追加しました `remote` または `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). +- のサポート `HTTP Basic` 複製プロトコルでの認証 [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). +- その `has` 関数は現在の配列内の数値を検索できるようになりました `Enum` 値 [マキシム-クリサンフォフ](https://github.com/ClickHouse/ClickHouse/pull/2699). +- 支援のための追加は任意のメッセージセパレータから読み取る際の `Kafka` [アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2701). + +#### 改善: {#improvements-8} + +- その `ALTER TABLE t DELETE WHERE` クエリでは、WHERE条件の影響を受けなかったデータ部分は書き換えられません [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). +- その `use_minimalistic_checksums_in_zookeeper` 選択のための `ReplicatedMergeTree` テーブルはデフォルトで有効です。 この設定は、バージョン1.1.54378、2018-04-16で追加されました。 1.1.54378より古いバージョンはインストールできなくなりました。 +- 実行のサポート `KILL` と `OPTIMIZE` 指定するクエリ `ON CLUSTER` [冬張](https://github.com/ClickHouse/ClickHouse/pull/2689). + +#### バグ修正: {#bug-fixes-16} + +- エラーを修正しました `Column ... is not under an aggregate function and not in GROUP BY` IN式を使用した集計の場合。 このバグに登場したバージョン18.1.0. ([bbdd780b](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) +- のバグを修正しました `windowFunnel aggregate function` [冬張](https://github.com/ClickHouse/ClickHouse/pull/2735). +- のバグを修正しました `anyHeavy` 集計関数 ([a2101df2](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) +- サーバーのクラッシュを修正 `countArray()` 集計関数。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-5} + +- 変数のための `Kafka` エンジンはから変更された `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` に `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. あなたのテーブルが `kafka_schema` または `kafka_num_consumers` メタデータファイルを手動で編集する必要があります `path/metadata/database/table.sql` と追加 `kafka_row_delimiter` 変数との `''` 値。 + +## ClickHouseリリース18.1 {#clickhouse-release-18-1} + +### ClickHouseリリース18.1.0,2018-07-23 {#clickhouse-release-18-1-0-2018-07-23} + +#### 新しい機能: {#new-features-9} + +- のためのサポート `ALTER TABLE t DELETE WHERE` レプリケートされていないMergeTreeテーブルの照会 ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). +- の任意の型のサポート `uniq*` 集計関数のファミリ ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). +- 比較演算子の任意の型のサポート ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). +- その `users.xml` ファイル形式でサブネットマスクを設定できます `10.0.0.1/255.255.255.0`. これは、途中にゼロがあるIPv6ネットワークのマスクを使用する場合に必要です ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). +- 追加された `arrayDistinct` 関数 ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). +- SummingMergeTreeエンジンはAggregateFunction型の列で動作できるようになりました ([コンスタンティン-S-パン](https://github.com/ClickHouse/ClickHouse/pull/2566)). + +#### 改善: {#improvements-9} + +- リリ 最初の部分にはリリース年(西暦、モスクワのタイムゾーン、マイナス2000)が含まれています。 Changelogに別段の記載がない限り、リリースは下位互換性があります。 +- 浮動小数点数から文字列への高速な変換 ([アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2664)). +- 解析エラーのために挿入中にいくつかの行がスキップされた場合(これは `input_allow_errors_num` と `input_allow_errors_ratio` スキップされた行数がサーバーログに書き込まれるようになりました ([レオナルド-セッキ](https://github.com/ClickHouse/ClickHouse/pull/2669)). + +#### バグ修正: {#bug-fixes-17} + +- 一時表のTRUNCATEコマンドを修正しました ([アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2624)). +- 固定アロの飼育係顧客の図書館で発生した場合またはネットワークエラーを読みながら対応 ([c315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). +- Null許容型へのキャスト中のエラーを修正しました ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). +- の誤った結果を修正しました。 `maxIntersection()` 区間の境界が一致したときの関数 ([マイケル-ファーマー](https://github.com/ClickHouse/ClickHouse/pull/2657)). +- 関数引数内のOR式チェーンの正しくない変換を修正しました ([chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). +- 固定性能の劣化を含む質問 `IN (subquery)` 別のサブクエリ内の式 ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). +- バージョンの異なるサーバー間の非互換性を修正しました。 `CAST` 大文字でない関数 ([fe8c4d6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). +- 外部DBMSへのクエリの識別子のクォート不足を追加しました ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). + +#### 下位互換性のない変更: {#backward-incompatible-changes-6} + +- 数値ゼロを含む文字列をDateTimeに変換することはできません。 例: `SELECT toDateTime('0')`. これはまた、 `DateTime DEFAULT '0'` テーブルでは動作しません。 `0` 辞書で。 解決策:交換 `0` と `0000-00-00 00:00:00`. + +## ClickHouseリリース1.1 {#clickhouse-release-1-1} + +### ClickHouseリリース1.1.54394,2018-07-12 {#clickhouse-release-1-1-54394-2018-07-12} + +#### 新しい機能: {#new-features-10} + +- 追加された `histogram` 集計関数 ([ミハイル-スリン](https://github.com/ClickHouse/ClickHouse/pull/2521)). +- さて `OPTIMIZE TABLE ... FINAL` パーティションを指定せずに使用できます `ReplicatedMergeTree` ([アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2600)). + +#### バグ修正: {#bug-fixes-18} + +- レプリケートされたデータを送信およびダウンロードするときに読み取りと書き込みのためのソケットのタイムアウト(秒)が非常に小さくなる問題を修 このエラーはバージョン1.1.54388で発生しました。 +- テーブルに重複したデータブロックを挿入した場合、zookeeperでchrootを使用する際の問題を修正しました。 +- その `has` 関数は現在、Null可能な要素を持つ配列のために正しく動作します ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). +- その `system.tables` テーブルが正しく動作に用いた場合に配布します。 その `metadata_modification_time` と `engine_full` 列は仮想ではありません。 これらの列のみがテーブルから照会された場合に発生するエラーを修正しました。 +- どのように空の固定 `TinyLog` テーブル動作後に挿入し、空データブロック ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). +- その `system.zookeeper` テーブルは、ZooKeeper内のノードの値がNULLの場合に機能します。 + +### ClickHouseリリース1.1.54390,2018-07-06 {#clickhouse-release-1-1-54390-2018-07-06} + +#### 新しい機能: {#new-features-11} + +- クエリを送信できます `multipart/form-data` フォーマット `query` これは、クエリ処理のために外部データも送信される場合に便利です ([オルガ-フボスチコワ](https://github.com/ClickHouse/ClickHouse/pull/2490)). +- CSV形式でデータを読み取るときに、単一引quotesまたは二重引用符の処理を有効または無効にする機能を追加しました。 これは、 `format_csv_allow_single_quotes` と `format_csv_allow_double_quotes` 設定 ([アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2574)). +- さて `OPTIMIZE TABLE ... FINAL` パーティションを指定せずに使用することができます。 `MergeTree` ([アモス鳥](https://github.com/ClickHouse/ClickHouse/pull/2599)). + +#### 改善: {#improvements-10} + +- 性能向上、メモリーの消耗を減らし、正しいメモリ消費の位置姿勢トラッキング用のオペレーターがテーブル-インデックスを使用できる ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). +- データパーツの追加時のチェックサムの冗長チェックを削除しました。 これは、多数のレプリカが存在する場合に重要です。 +- 追加されたサポート `Array(Tuple(...))` の引数 `arrayEnumerateUniq` 関数 ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). +- 追加 `Nullable` のためのサポート `runningDifference` 関数 ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). +- 非常に多数の式が存在する場合のクエリ分析のパフォーマンスの向上 ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). +- 結合のためのデータ部分のより速い選択 `ReplicatedMergeTree` テーブル 飼育係セッションの迅速な回復 ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). +- その `format_version.txt` ファイル `MergeTree` これは、ファイルなしでディレクトリ構造をコピーした後にClickHouseが起動された場合に意味があります ([シプリアン-ハクマン](https://github.com/ClickHouse/ClickHouse/pull/2593)). + +#### バグ修正: {#bug-fixes-19} + +- サーバーを再起動する前に、テーブルのセッションと読み取り専用の状態を回復することが不可能になる可能性があるZooKeeperで作業するときのバグを修正し +- セッションが中断された場合、古いノードが削除されない可能性がZooKeeperで作業するときのバグを修正しました。 +- のエラーを修正しました。 `quantileTDigest` Float引数の関数(このバグはバージョン1.1.54388で導入されました) ([ミハイル-スリン](https://github.com/ClickHouse/ClickHouse/pull/2553)). +- 主キー列が同じサイズの符号付き整数と符号なし整数の間で型を変換するための関数内にある場合、MergeTreeテーブルのインデックスのバグを修正しました ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). +- 以下の場合にsegfaultを修正しました `macros` 使用されますが、設定ファイルには含まれていません ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). +- クライア ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). +- ときに発生したバグを修正しました `use_index_for_in_with_subqueries` 設定が無効になりました。 + +#### セキュリティ修正: {#security-fix-1} + +- MySQLに接続すると、ファイルの送信ができなくなりました (`LOAD DATA LOCAL INFILE`). + +### ClickHouseリリース1.1.54388,2018-06-28 {#clickhouse-release-1-1-54388-2018-06-28} + +#### 新しい機能: {#new-features-12} + +- のためのサポート `ALTER TABLE t DELETE WHERE` 複製されたテーブルのクエリ。 追加された `system.mutations` このタイプのクエリの進行状況を追跡するテーブル。 +- のためのサポート `ALTER TABLE t [REPLACE|ATTACH] PARTITION` \*MergeTreeテーブルのクエリ。 +- のためのサポート `TRUNCATE TABLE` クエリ ([冬張](https://github.com/ClickHouse/ClickHouse/pull/2260)) +- いくつか新しい `SYSTEM` 複製テーブルのクエリ (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). +- MySQLエンジンと対応するテーブル関数を使用してテーブルに書き込む機能を追加しました ([サンディ-リ](https://github.com/ClickHouse/ClickHouse/pull/2294)). +- 追加された `url()` テーブル関数と `URL` 表エンジン ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). +- 追加された `windowFunnel` 集計関数 ([サンディ-リ](https://github.com/ClickHouse/ClickHouse/pull/2352)). +- 新しい `startsWith` と `endsWith` 文字列の関数 ([ヴァディム-プラフティンスキー](https://github.com/ClickHouse/ClickHouse/pull/2429)). +- その `numbers()` テーブル機能することはできなくなるようです指定のオフセット ([冬張](https://github.com/ClickHouse/ClickHouse/pull/2535)). +- パスワード `clickhouse-client` 対話形式で入力できます。 +- サーバログをsyslogに送信できるようになりました ([アレクサンドル-クラシェニコフ](https://github.com/ClickHouse/ClickHouse/pull/2459)). +- 共有ライブラリソースを持つ辞書のログインのサポート ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). +- カスタムCSV区切り文字のサポート ([イワン-ジューコフ](https://github.com/ClickHouse/ClickHouse/pull/2263)) +- 追加された `date_time_input_format` 設定。 この設定を `'best_effort'`、DateTime値は幅広い形式で読み込まれます。 +- 追加された `clickhouse-obfuscator` データ難読化のためのユーティリティ。 使用例:パフォーマンステストで使用されるデータの公開。 + +#### 実験的な特徴: {#experimental-features-2} + +- 計算する機能を追加しました `and` 引数が必要な場所だけ ([アナスタシア-ツァルコワ](https://github.com/ClickHouse/ClickHouse/pull/2272)) +- JITコへのネイティブコードが可能となりますので一部表現 ([pyos](https://github.com/ClickHouse/ClickHouse/pull/2277)). + +#### バグ修正: {#bug-fixes-20} + +- クエリに重複が表示されなくなりました `DISTINCT` と `ORDER BY`. +- クエリ `ARRAY JOIN` と `arrayFilter` 誤った結果が返されなくなりました。 +- ネストされた構造体から配列列を読み取るときのエラーを修正 ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). +- HAVING句のようなクエリを分析する際のエラーを修正しました `HAVING tuple IN (...)`. +- 誤りを修正で解析する場合、クエリを処理するクラウドの場合再帰的別名になります。 +- ReplacingMergeTreeからすべての行をフィルタリングするPREWHEREの条件を読み込むときにエラーを修正しました ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). +- ユーザープロファイルの設定が適用されていない使用時のセッションを行うHTTPのインタフェース。 +- Clickhouse-localのコマンドラインパラメータから設定が適用される方法を修正しました。 +- の飼育係お客様の図書館におけるその使用は、セッションタイムアウトサーバから受信した. +- ZooKeeperクライアントライブラリのバグを修正しました。 +- パーティションキー列の条件を持つクエリのパーツの剪定を修正 ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). +- 後でマージが可能になりました `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). +- ODBCテーブル関数の型マッピングが修正されました ([サンディ-リ](https://github.com/ClickHouse/ClickHouse/pull/2268)). +- 型比較が修正されました `DateTime` タイムゾーンの有無 ([アレクサ](https://github.com/ClickHouse/ClickHouse/pull/2400)). +- 修正された構文解析とフォーマットの `CAST` オペレーター +- 分散テーブルエンジンのマテリアライズドビューへの固定挿入 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). +- からデータを書き込むときに競合状態を修正しました `Kafka` エンジンを実現しの景色 ([ヤンクアン-リュウ](https://github.com/ClickHouse/ClickHouse/pull/2448)). +- Remote()テーブル関数のSSRFを修正しました。 +- の終了動作を修正しました `clickhouse-client` 複数行モードで ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). + +#### 改善: {#improvements-11} + +- 背景の業務を複製のテーブルを用いて行ったスレッドプールの代わりに別のスレッド ([シルヴィウ-カラゲア](https://github.com/ClickHouse/ClickHouse/pull/1722)). +- LZ4圧縮性能が向上しました。 +- 多数の結合およびサブクエリを含むクエリの高速な分析。 +- DNSキャッシュは、ネットワークエラーが多すぎると自動的に更新されます。 +- テーブルに挿入しなくなった場合に生じるの挿入を実現しの景色はできませんので多くの部品です。 +- イベントカウンタの不一致を修正しました `Query`, `SelectQuery`,and `InsertQuery`. +- のような式 `tuple IN (SELECT tuple)` 組の型が一致する場合に許可されます。 +- 複製されたテーブルを持つサーバーは、ZooKeeperを構成していなくても起動できます。 +- 使用可能なCPUコアの数を計算するときに、cgroupの制限が考慮されるようになりました ([アトリ-シャルマ](https://github.com/ClickHouse/ClickHouse/pull/2325)). +- Systemd設定ファイルに設定ディレクトリのchownを追加 ([ミハイル-シリヤエフ](https://github.com/ClickHouse/ClickHouse/pull/2421)). + +#### ビルドの変更: {#build-changes-4} + +- Gcc8コンパイラはビルドに使用できます。 +- サブモジュールからllvmをビルドする機能を追加しました。 +- Librdkafkaライブラリのバージョンがv0.11.4に更新されました。 +- システムlibcpuidライブラリを使用する機能を追加しました。 ライブラリのバージョンが0.4.0に更新されました。 +- Vectorclassライブラリを使用してビルドを修正しました ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). +- Cmakeは、デフォルトでninja用のファイルを生成するようになりました `-G Ninja`). +- Libtermcapの代わりにlibtinfoライブラリを使用する機能を追加しました ([ゲオルギー-コンドラティエフ](https://github.com/ClickHouse/ClickHouse/pull/2519)). +- Fedora Rawhideのヘッダーファイルの競合を修正しました ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). + +#### 下位互換性のない変更: {#backward-incompatible-changes-7} + +- でエスケープ削除 `Vertical` と `Pretty*` フォーマットと削除 `VerticalRaw` 形式。 +- バージョン1.1.54388(またはそれ以降)のサーバーと古いバージョンのサーバーが分散クエリで同時に使用され、クエリには `cast(x, 'Type')` のない式 `AS` キーワードと単語を持っていません `cast` 大文字では、次のようなメッセージで例外がスローされます `Not found column cast(0, 'UInt8') in block`. 解決方法:クラスター全体のサーバーを更新します。 + +### ClickHouseリリース1.1.54385,2018-06-01 {#clickhouse-release-1-1-54385-2018-06-01} + +#### バグ修正: {#bug-fixes-21} + +- 場合によっては飼育係の操作がブロックされるエラーを修正しました。 + +### ClickHouseリリース1.1.54383,2018-05-22 {#clickhouse-release-1-1-54383-2018-05-22} + +#### バグ修正: {#bug-fixes-22} + +- 固定減速のレプリケーションのキューにした場合には多くのレプリカ. + +### ClickHouseリリース1.1.54381,2018-05-14 {#clickhouse-release-1-1-54381-2018-05-14} + +#### バグ修正: {#bug-fixes-23} + +- 固定、ノードの漏洩、飼育係がClickHouse失接続を飼育係サーバーです。 + +### ClickHouseリリース1.1.54380,2018-04-21 {#clickhouse-release-1-1-54380-2018-04-21} + +#### 新しい機能: {#new-features-13} + +- テーブル関数を追加しました `file(path, format, structure)`. からバイトを読み取る例 `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. + +#### 改善: {#improvements-12} + +- サブクエリに包まれて `()` ブラケットをクエリを読む 例えば: `(SELECT 1) UNION ALL (SELECT 1)`. +- シンプル `SELECT` からのクエリ `system.processes` テーブルはに含まれていません `max_concurrent_queries` リミット + +#### バグ修正: {#bug-fixes-24} + +- の修正された不正な動作 `IN` 選択時の演算子 `MATERIALIZED VIEW`. +- 修正フィルタリングパーテーションによるインデックスのように表現 `partition_key_column IN (...)`. +- 実行できない問題を修正 `OPTIMIZE` リーダーレプリカ以外の場合のクエリ `REANAME` テーブル上で行った。 +- 実行時の認証エラーを修正しました `OPTIMIZE` または `ALTER` リーダー以外のレプリカに対するクエリ。 +- 固定凍結の `KILL QUERY`. +- ZooKeeperクライアントライブラリのエラーを修正しました。 `chroot` 接頭辞は、飼育係の設定で使用されます。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-8} + +- 以下のような式のサポートを削除 `(a, b) IN (SELECT (a, b))` (同等の式を使用できます `(a, b) IN (SELECT a, b)`). 以前のリリースでは、これらの式は未定になりました `WHERE` フィルタリングが起こっている。 + +### ClickHouseリリース1.1.54378,2018-04-16 {#clickhouse-release-1-1-54378-2018-04-16} + +#### 新しい機能: {#new-features-14} + +- ログレベルは、サーバーを再起動せずに変更できます。 +- 追加された `SHOW CREATE DATABASE` クエリ。 +- その `query_id` に渡すことができます `clickhouse-client` (エルブルーム) +- 新しい設定: `max_network_bandwidth_for_all_users`. +- 追加されたサポート `ALTER TABLE ... PARTITION ...` のために `MATERIALIZED VIEW`. +- システムテーブルに非圧縮形式のデータパーツのサイズに関する情報を追加しました。 +- 分散テーブルのサーバー間暗号化サポート (`1` のレプリカ設定で ``). +- テーブルレベルの設定 `ReplicatedMergeTree` 飼育係に格納されているデータの量を最小限に抑えるために、家族: : `use_minimalistic_checksums_in_zookeeper = 1` +- の構成 `clickhouse-client` プロンプト 既定では、サーバー名がプロンプトに出力されます。 サーバーの表示名は変更できます。 それはまたで送られます `X-ClickHouse-Display-Name` HTTPヘッダ(キリルShvakov)。 +- 複数のコンマ区切り `topics` に指定することができます。 `Kafka` エンジン(トビアス-アダムソン) +- クエリが停止されたとき `KILL QUERY` または `replace_running_query` クライアントは、 `Query was canceled` 不完全な結果の代わりに例外。 + +#### 改善: {#improvements-13} + +- `ALTER TABLE ... DROP/DETACH PARTITION` クエリは、レプリケーションキューの先頭で実行されます。 +- `SELECT ... FINAL` と `OPTIMIZE ... FINAL` テーブルに単一のデータ部分がある場合でも使用できます。 +- A `query_log` 手動で削除された場合、テーブルはその場で再作成されます(Kirill Shvakov)。 +- その `lengthUTF8` 機能はより速く動きます(zhang2014)。 +- 同期挿入物の改善された性能 `Distributed` テーブル (`insert_distributed_sync = 1`)非常に多数の破片がある場合。 +- サーバは、 `send_timeout` と `receive_timeout` 設定クライアントから求める動きが高まってい接続時にクライアントが適用される逆順にサーバソケットの `send_timeout` に設定される。 `receive_timeout` クライアントから受け取った値、およびその逆)。 +- 非同期挿入のためのより堅牢なクラッシュ回復 `Distributed` テーブル +- の戻り値の型 `countEqual` から変更された関数 `UInt32` に `UInt64` (谢磊). + +#### バグ修正: {#bug-fixes-25} + +- でエラーを修正しました `IN` 式の左側が `Nullable`. +- タプルを使用するときに正しい結果が返されます `IN` タプルコンポーネントの一部がテーブルインデックス内にある場合。 +- その `max_execution_time` 限値が正しく動作と配布します。 +- の合成列のサイズを計算する際のエラーを修正しました。 `system.columns` テーブル。 +- 一時テーブルを作成するときのエラーを修正 `CREATE TEMPORARY TABLE IF NOT EXISTS.` +- 修正されたエラー `StorageKafka` (\#\#2075) +- 固定サーバのクラッシュからでは無効引数の特定の集ます。 +- エラーを修正しました。 `DETACH DATABASE` バックグラウンドタスクの停止から `ReplicatedMergeTree` テーブル +- `Too many parts` 集約されたマテリアライズドビューに挿入すると、状態が発生しにくくなります(\#\#2084)。 +- 置換の後に同じレベルで別の置換が続く必要がある場合、config内の置換の再帰的な処理を修正しました。 +- メタデータファイルの構文を修正しました。 `VIEW` それは次のクエリを使用します `UNION ALL`. +- `SummingMergeTree` が正しく動作のための集計の入れ子データ構造との複合鍵があります。 +- リーダーを選択する際の競合状態の可能性を修正しました `ReplicatedMergeTree` テーブル + +#### ビルドの変更: {#build-changes-5} + +- ビルドのサポート `ninja` 代わりに `make` および使用 `ninja` デフォルトのビルリリースなどで行っています。 +- パッケージ名変更: `clickhouse-server-base` で `clickhouse-common-static`; `clickhouse-server-common` で `clickhouse-server`; `clickhouse-common-dbg` で `clickhouse-common-static-dbg`. インストールするには、 `clickhouse-server clickhouse-client`. 古い名前のパッケージは、下位互換性のためにリポジトリにロードされます。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-9} + +- 配列が左側に指定されている場合、IN式の特別な解釈を削除しました。 以前は、式 `arr IN (set)` と解釈された “at least one `arr` element belongs to the `set`”. 新しいバージョ `arrayExists(x -> x IN (set), arr)`. +- Socketオプションの誤った使用を無効にしました `SO_REUSEPORT` Pocoライブラリでデフォルトで正しく有効になっていません。 Linuxでは、アドレスを同時に指定する理由はもはやないことに注意してください `::` と `0.0.0.0` for listen – use just `::` これにより、IPv4とIPv6の両方で接続をリッスンできます(デフォルトのカーネル設定で)。 以前のバージョンの動作に戻すには、次のように指定します `1` 設定で。 + +### ClickHouseリリース1.1.54370,2018-03-16 {#clickhouse-release-1-1-54370-2018-03-16} + +#### 新しい機能: {#new-features-15} + +- 追加された `system.macros` 設定ファイルが変更されたときのマクロのテーブルと自動更新。 +- 追加された `SYSTEM RELOAD CONFIG` クエリ。 +- 追加された `maxIntersections(left_col, right_col)` 同時に交差する間隔の最大数を返す集計関数 `[left; right]`. その `maxIntersectionsPosition(left, right)` 関数の先頭を返します。 “maximum” インターバル ([マイケル-ファーマー](https://github.com/ClickHouse/ClickHouse/pull/2012)). + +#### 改善: {#improvements-14} + +- Aにデータを挿入するとき `Replicated` 要求の数が少なくなります。 `ZooKeeper` (そして、ユーザレベルのエラーのほとんどは、 `ZooKeeper` ログ)。 +- データセットのエイリアスを作成する機能を追加しました。 例: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. + +#### バグ修正: {#bug-fixes-26} + +- 固定された `Illegal PREWHERE` 場合にはエラーからの読み出しMergeテーブル `Distributed`テーブル +- IPv4のみのDockerコンテナでclickhouse-serverを起動できるようにする修正が追加されました。 +- システムから読み取るときの競合状態を修正 `system.parts_columns tables.` +- 同期挿入時の二重バッファリングを削除しました。 `Distributed` 接続がタイムアウトになった可能性があるテーブル。 +- 使用できないレプリカを開始する前に過度に長い待機を引き起こしたバグを修正 `SELECT` クエリ。 +- 修正された間違った日付 `system.parts` テーブル。 +- それは不可能にデータを挿入するために作られたバグを修正しました `Replicated` テーブルif `chroot` の構成で空ではなかった `ZooKeeper` クラスター。 +- 空の垂直マージアルゴリズムを修正しました `ORDER BY` テーブル。 +- 復元する機能を利用辞書にクエリをリモートテーブルの場合でも、これらの辞書にはない、調査元に確認します。 この機能は、リリース1.1.54362で失われました。 +- のようなクエリの動作を復元しました `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` ときの右側 `IN` リモートを使うべきです `default.table` 地元のものの代わりに。 この動作は、バージョン1.1.54358で壊れていました。 +- 削除された余分なエラーレベルのロギングの `Not found column ... in block`. + +### ClickHouseリリース1.1.54362,2018-03-11 {#clickhouse-release-1-1-54362-2018-03-11} + +#### 新しい機能: {#new-features-16} + +- 集計なし `GROUP BY` 空集合に対して `SELECT count(*) FROM table WHERE 0`)sql標準に準拠して、集計関数のnull値を持つ行で結果を返します。 古い動作を復元する(空の結果を返す)には、次のように設定します `empty_result_for_aggregation_by_empty_set` に1. +- の型変換を追加しました `UNION ALL`. 異なるエイリアス名は `SELECT` の位置 `UNION ALL`、SQL標準に準拠しています。 +- 任意の式は `LIMIT BY` 句。 以前は、次の結果の列のみを使用できました `SELECT`. +- のインデックス `MergeTree` 表は次の場合に使用されます `IN` 主キーの列から式のタプルに適用されます。 例: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` (アナスタシヤ-ツァルコワ) +- 追加された `clickhouse-copier` ツールのコピーとクラスター reshardingデータ(β). +- 一貫性のあるハッシュ関数を追加: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. ものとして使用できshardingキーを減らすため、ネットワークトラフィックの中でその後のreshardings. +- 追加された機能: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. +- 追加された `arrayCumSum` 関数(ハビサンタナ)。 +- 追加された `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero`,and `parseDateTimeBestEffortOrNull` さまざまな形式のテキストを含む文字列からDateTimeを読み取る関数。 +- データは、部分的に(以前のダウンロードよりも指定されたフィールドの値が大きいだけのレコードをロード)更新中に外部の辞書から再ロードすることができま +- 追加された `cluster` テーブル関数。 例: `cluster(cluster_name, db, table)`. その `remote` 表関数は、識別子として指定されている場合、クラスター名を最初の引数として受け入れることができます。 +- その `remote` と `cluster` テーブル関数は `INSERT` クエリ。 +- 追加された `create_table_query` と `engine_full` 仮想カラム `system.tables`テーブル。 その `metadata_modification_time` 列は仮想です。 +- 追加された `data_path` と `metadata_path` 列へ `system.tables`と`system.databases` テーブル、および追加 `path` の列 `system.parts` と `system.parts_columns` テーブル +- のマージに関する追加情報を追加しました。 `system.part_log` テーブル。 +- 任意のパーティショニングキーを使用できます。 `system.query_log` テーブル(キリルShvakov)。 +- その `SHOW TABLES` クエリには一時テーブルも表示されます。 追加された一時テーブルと `is_temporary` 列へ `system.tables` (zhang2014)。 +- 追加 `DROP TEMPORARY TABLE` と `EXISTS TEMPORARY TABLE` クエリ(zhang2014)。 +- のサポート `SHOW CREATE TABLE` 一時テーブルの場合(zhang2014)。 +- 追加された `system_profile` 内部プロセスで使用される設定の構成パラメータ。 +- ロードのサポート `object_id` の属性として `MongoDB` 辞書(パベルLitvinenko)。 +- 読書 `null` 外部ディクショナリのデータをロードする際のデフォルト値として `MongoDB` ソース(パベルLitvinenko)。 +- 読書 `DateTime` の値 `Values` 単一引quotesなしのUnixタイムスタンプからの形式。 +- フェールオーバーは `remote` 一部のレプリカに要求されたテーブルがない場合のテーブル関数。 +- 構成設定は、実行時にコマンドラインで上書きできます `clickhouse-server`. 例: `clickhouse-server -- --logger.level=information`. +- 実装された `empty` aからの関数 `FixedString` 引数:文字列が完全にヌルバイトで構成されている場合、関数は1を返します(zhang2014)。 +- 追加された `listen_try`いくつかのアドレスをリッスンできない場合に、終了せずに少なくとも一方のリッスンアドレスをリッスンするための構成パラメータ(IPv4またはIPv6 +- 追加された `VersionedCollapsingMergeTree` テーブルエンジン。 +- 行および任意の数値型のサポート `library` 辞書ソース。 +- `MergeTree` テーブルは主キーなしで使用できます(指定する必要があります `ORDER BY tuple()`). +- A `Nullable` タイプは `CAST` 非に-`Nullable` 引数が指定されていない場合の型 `NULL`. +- `RENAME TABLE` を実行することができます `VIEW`. +- 追加された `throwIf` 機能。 +- 追加された `odbc_default_field_size` ODBCソースからロードされた値の最大サイズを拡張できます(デフォルトでは1024)。 +- その `system.processes` テーブルと `SHOW PROCESSLIST` 今持って下さい `is_cancelled` と `peak_memory_usage` 列。 + +#### 改善: {#improvements-15} + +- 結果の制限とクォータは、次の中間データには適用されなくなりました `INSERT SELECT` クエリまたは `SELECT` サブクエリー。 +- 以下の偽トリガ `force_restore_data` の状態を確認するとき `Replicated` サーバー起動時のテーブル。 +- 追加された `allow_distributed_ddl` オプション +- 非決定的な関数は、次の式では使用できません `MergeTree` テーブルキー。 +- 置換元のファイル `config.d` ディレク +- の改善された性能 `arrayElement` 要素の一つとして空の配列を持つ定数多次元配列の場合の関数。 例: `[[1], []][x]`. +- サーバの開始に高速化した現在の使用時に設定ファイルの非常に大き換(例えば、非常に大きなリストのIPネットワーク). +- クエリを実行すると、テーブル値関数が一度実行されます。 以前は, `remote` と `mysql` テーブル機能評価を行い、同じクエリを取得するにはテーブル構造からのリモートサーバーです。 +- その `MkDocs` ドキュメントジェネレータを使用します。 +- テーブル列を削除しようとすると `DEFAULT`/`MATERIALIZED` 他の列の式は、例外がスローされます(zhang2014)。 +- テキスト形式の空行を0として解析する機能を追加しました。 `Float` データ型。 この機能は以前は利用可能でしたが、リリース1.1.54342で失われました。 +- `Enum` 値は次の場所で使用できます `min`, `max`, `sum` そして他のある機能。 このような場合、対応する数値を使用します。 この機能は以前は利用可能でしたが、リリース1.1.54337で失われました。 +- 追加 `max_expanded_ast_elements` 再帰的にエイリアスを展開した後にASTのサイズを制限する。 + +#### バグ修正: {#bug-fixes-27} + +- 不要な列がエラーでサブクエリから削除された場合、または次のサブクエリから削除されなかった場合を修正しました `UNION ALL`. +- のためのマージのバグを修正しました `ReplacingMergeTree` テーブル +- 固定同期挿入 `Distributed` テーブル (`insert_distributed_sync = 1`). +- の特定の使用のための固定segfault `FULL` と `RIGHT JOIN` サブクエリに重複する列を持つ。 +- の特定の使用のための固定segfault `replace_running_query` と `KILL QUERY`. +- の順序を修正しました。 `source` と `last_exception` の列 `system.dictionaries` テーブル。 +- ときにバグを修正しました `DROP DATABASE` クエリを削除しなかったファイルとメタデータを指すものとします。 +- 固定された `DROP DATABASE` クエリ `Dictionary` データベース。 +- 低い精密をの固定しました `uniqHLL12` と `uniqCombined` 100万アイテムを超えるカーディナリティのための機能(アレックスBocharov)。 +- 固定の計算の暗黙のデフォルト値が必要な場合には同時に計算デフォルトの明示的な表現 `INSERT` クエリ(zhang2014)。 +- まれなケースを修正しました。 `MergeTree` テーブルが終了できませんでした(chenxing-xc)。 +- クラッシュを修正しました。 `CHECK` クエリ `Distributed` すべてのシャードがローカルの場合のテーブル(chenxing.xc)。 +- 正規表現を使用する関数のパフォーマンスのわずかな回帰を修正しました。 +- 複合式から多次元配列を作成するときのパフォーマンス回帰を修正しました。 +- 余分な原因となるバグを修正しました `FORMAT` に表示されるセクション `.sql` ファイルとメタデータを指すものとします。 +- その原因となったバグを修正しました `max_table_size_to_drop` 削除しようとするときに適用する制限 `MATERIALIZED VIEW` 明示的に指定されたテーブルを見る。 +- 古いクライアントとの非互換性を修正しました(古いクライアントは、時には `DateTime('timezone')` タイプ、彼らは理解していない)。 +- 読み取り時のバグを修正 `Nested` を使用して追加された構造体の列要素 `ALTER` しかし、古いパーティションでは空です。 `PREWHERE`. +- 時の不具合を修正フィルタリングテーブルによる仮想 `_table` クエリの列 `Merge` テーブル +- 使用する際のバグを修正しました `ALIAS` の列 `Distributed` テーブル +- から集計関数を持つクエリの動的コンパイルが不可能になったバグを修正しました `quantile` 家族だ +- 非常にまれなケースで発生したクエリ実行パイプラインの競合状態を修正しました `Merge` 多数のテーブルを持つテーブル、および使用する場合 `GLOBAL` サブクエリー。 +- 異なるサイズの配列を渡すときのクラッシュを修正した。 `arrayReduce` 複数の引数から集計関数を使用する場合の関数。 +- クエリの使用を禁止 `UNION ALL` で `MATERIALIZED VIEW`. +- の初期化中にエラーを修正しました。 `part_log` サーバー起動時のシステムテーブル(デフォルト, `part_log` が無効になっている)。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-10} + +- 削除された `distributed_ddl_allow_replicated_alter` オプション この動作は既定で有効です。 +- 削除された `strict_insert_defaults` 設定。 この機能を使用していた場合は、 `clickhouse-feedback@yandex-team.com`. +- 削除された `UnsortedMergeTree` エンジン + +### ClickHouseリリース1.1.54343,2018-02-05 {#clickhouse-release-1-1-54343-2018-02-05} + +- 追加マクロの支援を定義するためのクラスターの名前を配布DDLお問い合わせのコンストラクタの配布のテーブル: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. +- 今のようなクエリ `SELECT ... FROM table WHERE expr IN (subquery)` を使用して処理されます `table` インデックス +- 処理能の重複を挿入する場合はを再現し、テーブルではなく実行を複製します。 + +### ClickHouseリリース1.1.54342,2018-01-22 {#clickhouse-release-1-1-54342-2018-01-22} + +このリリースには、以前のリリース1.1.54337のバグ修正が含まれています: + +- 1.1.54337の回帰を修正しました:デフォルトのユーザーが読み取り専用アクセス権を持っている場合、サーバーはメッセージでの起動を拒否します `Cannot create database in readonly mode`. +- 1.1.54337の回帰を修正しました:systemdを使用するシステムでは、ログは設定に関係なく常にsyslogに書き込まれます。d. +- 1.1.54337の回帰を修正しました。 +- GraphiteMergeTreeの非決定的な動作を修正しました(ログメッセージで確認できます `Data after merge is not byte-identical to the data on another replicas`). +- なることがある不具合を修正しつ一貫性のない合併後最適なクエリーの複製のテーブル(きめて発見されたログメッセージ `Part ... intersects the previous part`). +- バッファーの表現は正常に動作が実現列の先テーブル(zhang2014). +- NULLの実装のバグを修正しました。 + +### ClickHouseリリース1.1.54337,2018-01-18 {#clickhouse-release-1-1-54337-2018-01-18} + +#### 新しい機能: {#new-features-17} + +- 多次元配列およびタプルの格納のサポートが追加されました (`Tuple` テーブル内のデータ型)。 +- 表関数のサポート `DESCRIBE` と `INSERT` クエリ。 のサブクエリのサポートを追加しました `DESCRIBE`. 例: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. のサポート `INSERT INTO TABLE` に加えて `INSERT INTO`. +- タイムゾーンのサポートの改善。 その `DateTime` データ型には、テキスト形式の解析および書式設定に使用されるタイムゾーンに注釈を付けることができます。 例: `DateTime('Europe/Moscow')`. の関数でタイムゾーンが指定されている場合 `DateTime` 戻り値の型はタイムゾーンを追跡し、値は期待どおりに表示されます。 +- 機能を追加しました `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. その `toRelativeHour`/`Minute`/`Second` 関数はtypeの値を取ることができます `Date` 引数として。 その `now` 関数名では大文字と小文字が区別されます。 +- 追加された `toStartOfFifteenMinutes` 関数(キリルShvakov)。 +- 追加された `clickhouse format` クエリの書式設定ツール。 +- 追加された `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` 形式。 スキーマファイ +- 設定置換のサポートが追加されました (`incl` と `conf.d`)外部の辞書やモデル(パベルYakunin)の構成のために。 +- コラムを追加しましたとの `system.settings` テーブル(キリルShvakov)。 +- 追加された `system.parts_columns` 各データ部分の列サイズに関する情報を含むテーブル `MergeTree` テーブル +- 追加された `system.models` loadedに関する情報を含む表 `CatBoost` 機械学習モデル。 +- 追加された `mysql` と `odbc` テーブル機能および対応 `MySQL` と `ODBC` テーブルエンジン この機能はベータ段階にあります。 +- 型の引数を渡す可能性を追加しました `AggregateFunction` のために `groupArray` 集計関数(集計関数の状態の配列を作成できます)。 +- 削除の制限を様々に組み合わせて集計機能combinators. たとえば、次のようにします `avgForEachIf` 同様に `avgIfForEach` 異なる動作を持つ集計関数。 +- その `-ForEach` 集計関数combinatorは、複数の引数の集計関数の場合に拡張されています。 +- の集計関数のサポートを追加しました `Nullable` 関数が非を返す場合でも引数-`Nullable` 結果(Silviu Carageaの貢献を加えた)。 例: `groupArray`, `groupUniqArray`, `topK`. +- 追加された `max_client_network_bandwidth` のために `clickhouse-client` (キリル-シュヴァコフ) +- を持つユーザー `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). +- サポートが追加された複数の消費者に `Kafka` エンジン の拡張構成オプション `Kafka` (Marek Vavruša). +- 追加された `intExp3` と `intExp4` 機能。 +- 追加された `sumKahan` 集計関数。 +- To\*Number\*OrNull関数を追加しました。\*Number\*は数値型です。 +- 追加されたサポート `WITH` の節 `INSERT SELECT` クエリ(著者:zhang2014)。 +- 設定の追加: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. 特に、これらの設定のためのデータのダウンロードパーツのレプリケーション. を変更する設定できる高速フェイルオーバーの場合はネットワークが過負荷状態で運転されています。 +- 追加されたサポート `ALTER` タイプのテーブルの場合 `Null` (アナスタシヤ-ツァルコワ) +- その `reinterpretAsString` 関数は、メモリ内に連続して格納されているすべてのデータ型に対して拡張されます。 +- 追加された `--silent` のオプション `clickhouse-local` ツール。 これは、stderrでのクエリ実行情報の印刷を抑制します。 +- るためのサポートを追加しました読み値の型 `Date` 月や日を二桁ではなく一桁で指定する形式のテキストから(Amos Bird)。 + +#### パフォーマンスの最適化: {#performance-optimizations} + +- 集計関数のパフォーマンスの向上 `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` 文字列の引数から。 +- 機能の改善された性能 `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. +- 解析と書式設定のパフォーマンスの向上 `Date` と `DateTime` 値をテキスト形式で入力します。 +- 浮動小数点数の解析のパフォーマンスと精度が向上しました。 +- のためのメモリ使用量の低下 `JOIN` 左と右の部分に含まれていない同じ名前の列がある場合 `USING` . +- 集計関数のパフォーマンスの向上 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` 計算の安定性を減らすことにより。 古い関数は名前の下にあります `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. + +#### バグ修正: {#bug-fixes-28} + +- 実行後のデータ重複排除を修正しました。 `DROP` または `DETACH PARTITION` クエリ。 以前のバージョン、パーティションに挿入し、同じデータを再度はありませんが挿入されブロックを考慮した重複している。 +- の誤った解釈につながる可能性のあるバグを修正しました `WHERE` の句 `CREATE MATERIALIZED VIEW` クエリ `POPULATE` . +- を使用する際のバグを修正しました `root_path` のパラメータ `zookeeper_servers` 構成。 +- パスの予期しない結果を修正しました。 `Date` 引数に `toStartOfDay` . +- 固定された `addMonths` と `subtractMonths` の関数と算術演算 `INTERVAL n MONTH` 結果が前年の場合。 +- 追加された不足しているサポート `UUID` のデータ型 `DISTINCT` , `JOIN` ,and `uniq` 集計関数と外部辞書(Evgeniy Ivanov)。 のサポート `UUID` まだ不完全です。 +- 固定 `SummingMergeTree` 行がゼロに加算された場合の動作。 +- のための様々な修正 `Kafka` engine (Marek Vavruša). +- の修正された不正な動作 `Join` テーブルエンジン(アモス鳥)。 +- FreeBSDおよびOS Xでのアロケータの誤った動作を修正 +- その `extractAll` 関数は空の一致をサポートします。 +- の使用をブロックエラーを修正しました `libressl` 代わりに `openssl` . +- 固定された `CREATE TABLE AS SELECT` 一時テーブルからのクエリ。 +- レプリケーションキューの更新の非原因性を修正しました。 このレプリカとの同期までのサーバが再起動してしまいます。 +- で固定可能なオーバーフロー `gcd` , `lcm` と `modulo` (`%` オペレータ)(Maks Skorokhod)。 +- `-preprocessed` 変更後にファイルが作成されます `umask` (`umask` 設定で変更することができます)。 +- パーツのバックグラウンドチェックのバグを修正 (`MergeTreePartChecker` )カスタムパーティションキーを使用する場合 +- タプルの解析を修正しました。 `Tuple` テキスト形式のデータ型)。 +- 互換性のない型に関するエラーメッセージの改善 `multiIf` , `array` そして他のある機能。 +- 再設計されたサポート `Nullable` タイプ。 サーバークラッシュにつながるバグを修正しました。 固定のほぼすべてその他のバグ関連 `NULL` サポート:INSERT SELECTでの誤った型変換、HAVINGおよびPREWHEREでのNullableのサポートが不十分, `join_use_nulls` の引数としてNull可能な型 `OR` オペレータ、等。 +- データ型の内部セマンティクスに関連する様々なバグを修正。 例:の不必要な合計 `Enum` フィールドの入力 `SummingMergeTree` ;の位置合わせ `Enum` タイプ `Pretty` フォーマット等 +- 厳しくチェック可の組み合わせの複合列あります。 +- 非常に大きなパラ `FixedString` データ型。 +- のバグを修正しました `topK` 一般的な場合の集計関数。 +- 集合関数のn-aryバリアントの引数に配列サイズが等しいかどうかのチェックが不足していることを追加しました。 `-Array` コンビネーター +- のバグを修正しました `--pager` のために `clickhouse-client` (著者:ks1322)。 +- の精度を固定しました。 `exp10` 機能。 +- の動作を修正しました。 `visitParamExtract` ドキュメントのよりよい承諾のための機能 +- 固定をした場合クラッシュする不正確なデータ種を指定します。 +- の動作を修正しました `DISTINCT` すべての列が定数である場合。 +- を使用する場合のクエリの書式設定を修正しました。 `tupleElement` タプル要素のインデックスとして複素定数式を持つ関数。 +- のバグを修正しました `Dictionary` 以下の表 `range_hashed` 辞書。 +- の結果に過度の行につながるバグを修正しました `FULL` と `RIGHT JOIN` (アモス鳥)。 +- 固定サーバのクラッシュの作成時に除去の一時ファイル `config.d` ディレクトリの中configしてください。 +- 固定された `SYSTEM DROP DNS CACHE` クエリのキャッシュをフラッシュがアドレスのクラスタノードが更新されません。 +- の動作を修正しました `MATERIALIZED VIEW` 実行後 `DETACH TABLE` for the table under the view (Marek Vavruša). + +#### ビルドの改善: {#build-improvements-4} + +- その `pbuilder` ツールはビルドに使用されます。 ビルドプロセスは、ビルドホスト環境からほぼ完全に独立しています。 +- 単一のビルドは、異なるOSバージョンで使用されます。 パッケージとバイナリは、幅広いLinuxシステムと互換性があります。 +- 追加された `clickhouse-test` パッケージ。 これは、機能テストを実行するために使用できます。 +- ソースtarballをリポジトリに公開できるようになりました。 GitHubを使用せずにビルドを再現するために使用できます。 +- Travis CIとの限定的な統合を追加しました。 Travisのビルド時間に制限があるため、デバッグビルドのみがテストされ、テストの一部が実行されます。 +- 追加されたサポート `Cap'n'Proto` デフォルトのビルドで。 +- ドキュメントソースのフォーマットを `Restricted Text` に `Markdown`. +- 追加されたサポート `systemd` ウラジーミル-スミルノフ これはデフォルトでは無効に設定により不適合一部のOSの画像を有効にすることができます。 +- 動的コード生成の場合, `clang` と `lld` に埋め込まれます `clickhouse` バイナリ それらは呼び出されて `clickhouse clang` と `clickhouse lld` . +- コードからGNU拡張の使用を削除しました。 有効にする `-Wextra` オプション で構築する場合 `clang` 既定値は次のとおりです `libc++` 代わりに `libstdc++`. +- 抽出 `clickhouse_parsers` と `clickhouse_common_io` 様々なツールのビルドを高速化するライブラリ。 + +#### 下位互換性のない変更: {#backward-incompatible-changes-11} + +- マークのフォーマット `Log` 以下を含む型テーブル `Nullable` 下位互換性のない方法で列が変更されました。 これらのテーブルがある場合は、それらを `TinyLog` タイプ前のサーババージョン。 これを行うには、 `ENGINE = Log` と `ENGINE = TinyLog` 対応する `.sql` のファイル `metadata` ディレクトリ。 あなたのテーブルに `Nullable` 列またはテーブルの型がない場合 `Log` 何もする必要はない +- 削除された `experimental_allow_extended_storage_definition_syntax` 設定。 この機能はデフォルトで有効になりました。 +- その `runningIncome` 関数の名前が変更されました `runningDifferenceStartingWithFirstvalue` 混乱を避けるため。 +- 削除された `FROM ARRAY JOIN arr` 配列の結合がテーブルなしでFROMの直後に指定されている場合の構文(Amos Bird)。 +- 削除された `BlockTabSeparated` デモンストレーション目的のみに使用された形式。 +- 集計関数の状態形式を変更しました `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. これらの集計関数の状態をテーブルに格納している場合( `AggregateFunction` データタイプや実現し意見に対応する状態)、書いてくださいclickhouse-feedback@yandex-team.com. +- 集計関数がパラメーターに依存する場合でも、AggregateFunctionデータ型でパラメーターなしで指定できます。 例: `AggregateFunction(quantiles, UInt64)` 代わりに `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. この機能は失われました。 それは文書化されていなかったが、我々は将来のリリースで再びそれをサポートする予定です。 +- Enumデータ型は、min/max集計関数では使用できません。 この能力は次のリリースで返されます。 + +#### ご注意ください: {#please-note-when-upgrading} + +- クラスターでローリング更新を実行すると、一部のレプリカが古いバージョンのClickHouseを実行していて、一部のレプリカが新しいバージョンを実行している時点 `unknown parameter 'shard'` ログに表示されます。 レプリケーションは今後すべてのレプリカクラスターを更新しました。 +- 異なるバージョンのClickHouseがクラスターサーバーで実行されている場合、次の関数を使用する分散クエリの結果が正しくない可能性があります: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. すべてのクラスタノードを更新します。 + +## [2017年の変更履歴](./2017.md#clickhouse-release-1-1-54327-2017-12-21) {#changelog-for-2017} diff --git a/docs/ja/whats-new/changelog/2019.md b/docs/ja/whats-new/changelog/2019.md new file mode 100644 index 00000000000..46802ecc63b --- /dev/null +++ b/docs/ja/whats-new/changelog/2019.md @@ -0,0 +1,2074 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 77 +toc_title: '2019' +--- + +## ClickHouseリリース19.17 {#clickhouse-release-v19-17} + +### ClickHouse Release19.17.6.36,2019年12月27日 {#clickhouse-release-v19-17-6-36-2019-12-27} + +#### バグ修正 {#bug-fix} + +- 固定力バッファオーバーフローして展開す. 悪意のあるユーザーで製作した圧縮データが読み後のバッファです。 この問題は、Yandex情報セキュリティチームのEldar Zaitovによって発見されました。 [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定可能なサーバのクラッシュ (`std::terminate`)サーバーが文字列データ型の値を持つJSONまたはXML形式でデータを送信または書き込むことができない場合(UTF-8検証が必要)、またはBrotliアルゴリズムで結果デー [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Clickhouseからのソースを持つ固定辞書 `VIEW` そのような辞書を読んでもエラーは発生しません `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 固定照合するクライアントホストで許可されhost\_regexp指定されます。xml。 [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- `RENAME TABLE` 分散表現に変更、フォルダが挿入されデータを送信する前に破片. これにより、連続した名前変更の問題が修正されます `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) +- `range_hashed` 外部辞書作成DDLわきの範囲は任意の数値です。 [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([アレサピン](https://github.com/alesapin)) +- 固定 `INSERT INTO table SELECT ... FROM mysql(...)` テーブル関数。 [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) +- で固定segfault `INSERT INTO TABLE FUNCTION file()` 存在しないファイルに挿入中。 この場合、ファイルが作成され、挿入が処理されます。 [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) +- 固定bitmapAnd場合にはエラーに交差に集約ビットマップおよびスカラービットマップ. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([越黄](https://github.com/moon03432)) +- Segfaultを修正しました `EXISTS` クエリが使用されなかった `TABLE` または `DICTIONARY` 修飾子、ちょうどのような `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 関数の戻り値の型を修正しました `rand` と `randConstant` null許容引数の場合。 今すぐ関数は常に戻ります `UInt32` そして決して `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 固定 `DROP DICTIONARY IF EXISTS db.dict` これで例外はスローされません `db` 存在しない [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- さん完全に落ちてしまったがサーバのクラッシュ、サーバへの復元とその負荷で [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) +- 複数のシャードローカルテーブルが存在する場合、分散テーブルの些細なカウントクエリを修正しました。 [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) +- DB::BlockStreamProfileInfo::calculateRowsBeforeLimitでデータレースにつながるバグを修正しました() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([Alexander Kazakov](https://github.com/Akazz)) +- 固定 `ALTER table MOVE part` 指定されたパーツをマージした直後に実行されます。 指定された部分を正しく移動します。 [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- 辞書の式を文字列として指定できるようになりました。 これは、クリックハウス以外のソースからデータを抽出する際に属性の計算に役立ちます。 [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([アレサピン](https://github.com/alesapin)) +- で非常にまれなレースを修正しました `clickhouse-copier` ZXidのオーバーフローのため。 [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([丁翔飛](https://github.com/dingxiangfei2009)) +- クエリが失敗した後(原因に “Too many simultaneous queries” たとえば)外部テーブル情報を読み込まず、 + 次の要求はこの情報を次のクエリの先頭として解釈し、次のようなエラーを引き起こします `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) +- 後のnull逆参照を避ける “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) +- すべてのICUロケールのサポートを復元し、定数式の照合順序を適用し、言語名をシステムに追加する機能を追加します。照合テーブル。 [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([アレサピン](https://github.com/alesapin)) +- 読み取り元のストリームの数 `StorageFile` と `StorageHDFS` メモリ制限を超えないように制限されるようになりました。 [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([アレサピン](https://github.com/alesapin)) +- 固定 `CHECK TABLE` クエリ `*MergeTree` キーのない表。 [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([アレサピン](https://github.com/alesapin)) +- 突然変異がない場合に備えて、部品名から変異番号を削除しました。 これにより古いバージョンとの互換性が向上した。 [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([アレサピン](https://github.com/alesapin)) +- Data\_versionがテーブルの突然変異バージョンより大きいため、添付されている部分で突然変異がスキップされるバグを修正しました。 [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([Zhichang Yu](https://github.com/yuzhichang)) +- を開始サポートしているサーバの冗長部の部品を移動した後、このようなたくさんの装置です。 [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- エラーを修正しました “Sizes of columns doesn’t match” る面が表示される場合があ利用時の集計関数列あります。 [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([ボリス-グランヴォー](https://github.com/bgranvea)) +- これで、LIMIT BYと一緒にWITH TIESを使用する場合に例外がスローされます。 そして今、LIMIT BYでTOPを使用することができます。 [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) +- それが持っている場合 `invalidate_query` これは、以前の更新の試行で更新といくつかの例外を停止しました。 [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([アレサピン](https://github.com/alesapin)) + +### ClickHouse Release19.17.4.11,2019年11月22日 {#clickhouse-release-v19-17-4-11-2019-11-22} + +#### 下位互換性のない変更 {#backward-incompatible-change} + +- 使用カラムの代わりにASTビスカラサブクエリの結果よりよい。 設定 `enable_scalar_subquery_optimization` 19.17に追加され、デフォルトで有効になりました。 繋がるようなエラー [この](https://github.com/ClickHouse/ClickHouse/issues/7851) 以前のバージョンから19.17.2または19.17.3へのアップグレード中。 この設定はデフォルトで無効にで19.17.4、可能からのアップグレード19.16、以前のバージョンなします。 [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([アモス鳥](https://github.com/amosbird)) + +#### 新機能 {#new-feature} + +- DDLクエリで辞書を作成する機能を追加します。 [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([アレサピン](https://github.com/alesapin)) +- 作る `bloom_filter` 索引のサポートのタイプ `LowCardinality` と `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 関数を追加 `isValidJSON` 渡された文字列が有効なjsonであることを確認する。 [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([Vdimir](https://github.com/Vdimir)) +- 実装 `arrayCompact` 関数 [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([メモ](https://github.com/Joeywzr)) +- 作成された関数 `hex` 小数の場合。 このように動作 `hex(reinterpretAsString())` しかし、最後のゼロバイトは削除しません。 [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([ミハイル-コロトフ](https://github.com/millb)) +- 追加 `arrayFill` と `arrayReverseFill` 要素を配列内のそれらの前後の他の要素に置き換える関数。 [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([hcz](https://github.com/hczhcz)) +- 追加 `CRC32IEEE()`/`CRC64()` サポート [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([Azat Khuzhin](https://github.com/azat)) +- 実装 `char` に似た関数 [mysql](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([スンディリ](https://github.com/sundy-li)) +- 追加 `bitmapTransform` 機能。 ビットマップ内の値の配列を別の値の配列に変換し、結果は新しいビットマップになります [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([Zhichang Yu](https://github.com/yuzhichang)) +- 実装 `javaHashUTF16LE()` 関数 [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([アチンバ州](https://github.com/achimbab)) +- 追加 `_shard_num` 分散エンジンの仮想列 [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([Azat Khuzhin](https://github.com/azat)) + +#### 実験的な特徴 {#experimental-feature} + +- 支援のためのプロセッサ(新しいクエリを実行パイプライン) `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) + +#### バグ修正 {#bug-fix-1} + +- で不正な浮動小数点解析を修正 `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) +- 固定レア行き詰まりきれるようにすることがtrace\_logが有効になります。 [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([フィリモノフ](https://github.com/filimonov)) +- 防止のメッセージの複製を制作するカフカテーブルには、MVsの選択からで [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([イワン](https://github.com/abyss7)) +- のサポート `Array(LowCardinality(Nullable(String)))` で `IN`. 解決 [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([アチンバ州](https://github.com/achimbab)) +- の処理を追加 `SQL_TINYINT` と `SQL_BIGINT`、および修正の処理 `SQL_FLOAT` ODBCブリッジのデータソース型。 [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([デニス-グラザチェフ](https://github.com/traceon)) +- 集約を修正 (`avg` および分位数)空の十進数列に対する [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([アンドレイ-コニャエフ](https://github.com/akonyaev90)) +- 修正 `INSERT` との分散に `MATERIALIZED` 列 [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) +- 作る `MOVE PARTITION` 仕事のパーツがあった場合にエントランスは目を引く壁面緑化依存度はさほど高くないものの、保存先ディスクまたは量 [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- ハードリンクが変異中に作成されないバグを修正しました。 `ReplicatedMergeTree` マルチディスク構成で。 [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- 部分全体が変更されず、別のディスクに最適なスペースが見つかっているときに、マージツリー上で突然変異を伴うバグを修正しました [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- とのバグを修正 `keep_free_space_ratio` ディスク構成から読み取られない [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- 修正のバグテーブルのみを含む `Tuple` 複雑なパスを持つ列または列。 修正 [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([アレサピン](https://github.com/alesapin)) +- Max\_memory\_usage制限内のバッファエンジンのメモリを考慮しない [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([Azat Khuzhin](https://github.com/azat)) +- 最終的なマークの使用を修正 `MergeTree` テーブルの順序付け `tuple()`. まれに `Can't adjust last granule` 選択中にエラー。 [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([アントン-ポポフ](https://github.com/CurtizJ)) +- クラッシュや奇妙な例外につながる可能性があり、コンテキスト(例えばjsonの関数)を必要とするアクションで述語を持つ突然変異のバグを修正し [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([アレサピン](https://github.com/alesapin)) +- データベース名とテーブル名の不一致を修正 `data/` と `shadow/` ディレク [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([Alexander Burmak](https://github.com/Alex-Burmak)) +- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. この場合のクラッシュを修正します。 [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 修正 `Not found column in block` 右結合または完全結合で式に結合する場合。 [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 無限ループを修正するもう一つの試み `PrettySpace` 形式 [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([Olga Khvostikova](https://github.com/stavrolia)) +- バグを修正 `concat` すべての引数が `FixedString` 同じサイズの。 [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([アレサピン](https://github.com/alesapin)) +- S3、URL、HDFSストレージを定義する際に1つの引数を使用した場合の例外を修正しました。 [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- クエリを持つビューのInterpreterSelectQueryのスコープを修正しました [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([Azat Khuzhin](https://github.com/azat)) + +#### 改善 {#improvement} + +- `Nullable` ODBC-bridgeによって認識される列とNULL値が正しく処理されます [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 分散送信用の現在のバッチを原子的に書き込む [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([Azat Khuzhin](https://github.com/azat)) +- クエリで列名のテーブルを検出できない場合は、例外をスローします。 [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 追加 `merge_max_block_size` への設定 `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- クエリ `HAVING` そしてなし `GROUP BY` 当グループによる定数です。 だから, `SELECT 1 HAVING 1` 今すぐ結果を返します。 [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([アモス鳥](https://github.com/amosbird)) +- サポート解析 `(X,)` pythonに似たタプルとして。 [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([アモス鳥](https://github.com/amosbird)) +- 作る `range` 関数の動作はpythonicのものとほぼ同じです。 [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([スンディリ](https://github.com/sundy-li)) +- 追加 `constraints` テーブルへの列 `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- Tcpハンドラのためのより良いヌル形式、それが使用することが可能です `select ignore() from table format Null` clickhouse顧客によるperfの測定のため [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([アモス鳥](https://github.com/amosbird)) +- のようなクエリ `CREATE TABLE ... AS (SELECT (1, 2))` 正しく解析されます [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([hcz](https://github.com/hczhcz)) + +#### 性能向上 {#performance-improvement} + +- 短い文字列キーに対する集計のパフォーマンスが向上しました。 [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([Alexander Kuzmenkov](https://github.com/akuzm), [アモス鳥](https://github.com/amosbird)) +- 定数述部が折り畳まれた後に、構文/式分析の別のパスを実行して、潜在的な最適化を取得します。 [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([アモス鳥](https://github.com/amosbird)) +- 記憶域メタ情報を使用して些細なことを評価する `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([アモス鳥](https://github.com/amosbird), [アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ベクトル化処理 `arrayReduce` アグリゲータと同様 `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([アモス鳥](https://github.com/amosbird)) +- の性能のマイナーな改善 `Kafka` 消費 [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([イワン](https://github.com/abyss7)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement} + +- CPUアーキテクチャAARCH64へのクロスコンパイルのサポートを追加。 リファクタリング [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([イワン](https://github.com/abyss7)) +- パッケージビルド時にdarwin-x86\_64およびlinux-aarch64ツールチェーンをマウントされたDockerボリュームに解凍します [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([イワン](https://github.com/abyss7)) +- バイナ [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([イワン](https://github.com/abyss7)) +- MacOS Catalinaのコンパイルエラーを修正 [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([アーネスト-ポレタエフ](https://github.com/ernestp)) +- 一部のリファクタリングのクエリ分析論理分割複雑なクラスの幾つかの簡単なものである。 [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- サブモジュールなしでビルドを修正 [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([プロラー](https://github.com/proller)) +- より良い `add_globs` CMakeファイル内 [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([アモス鳥](https://github.com/amosbird)) +- ハードコードされたパスを削除する `unwind` ターゲット [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([コンスタンチン-ポドシュモク](https://github.com/podshumok)) +- Sslなしでmysql形式を使用できるようにする [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([プロラー](https://github.com/proller)) + +#### その他 {#other} + +- ClickHouse SQL方言のANTLR4文法を追加しました [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +## ClickHouseリリース19.16 {#clickhouse-release-v19-16} + +#### ClickHouseリリース19.16.14.65,2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} + +- 複数の引数(10以上)の三項論理OPsのバッチ計算のバグを修正しました。 [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([Alexander Kazakov](https://github.com/Akazz))このバグ修正はAltinityからの特別な要求によってバージョン19.16にバックポートされました。 + +#### ClickHouseリリース19.16.14.65,2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} + +- 古いCHバージョンとの分散サブクエリの非互換性を修正しました。 修正 [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) + [(tabplubix)](https://github.com/tavplubix) +- 実行するとき `CREATE` クエリー、倍定表現のストレージエンジンの引数です。 空のデータベー 修正 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). また、ローカルアドレスの確認を修正 `ClickHouseDictionarySource`. + [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) +- 今すぐ背景にマージ `*MergeTree` テーブルエンジンの家族の保存-保存政策に大量注文しております。 + [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- データの損失を防ぐ `Kafka` まれに、suffixを読んだ後でコミットする前に例外が発生する場合。 修正 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). 関連: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) + [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(フィリモノフ)](https://github.com/filimonov) +- のを修正した。先サーバを終了しようとした場合に使用/drop `Kafka` テーブル作成されたパラメータ。 修正 [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). 組み込み [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). + [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(フィリモノフ)](https://github.com/filimonov) +- 使用を許可する `MaterializedView` 上記のサブクエリで `Kafka` テーブル + [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([フィリモノフ](https://github.com/filimonov)) + +#### 新機能 {#new-feature-1} + +- 追加 `deduplicate_blocks_in_dependent_materialized_views` マテリアライズドビューを持つテーブルへの冪等挿入の動作を制御するオプション。 この新機能は、Altinityからの特別な要求によってバグ修正リリースに追加されました。 + [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(ユーリーキー)](https://github.com/urykhy) + +### ClickHouse Release19.16.2.2,2019年10月30日 {#clickhouse-release-v19-16-2-2-2019-10-30} + +#### 下位互換性のない変更 {#backward-incompatible-change-1} + +- Count/counIfの不足しているarity検証を追加します。 + [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) + [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([Vdimir](https://github.com/Vdimir)) +- レガシーを削除 `asterisk_left_columns_only` 設定(デフォルトでは無効になっていました)。 + [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([Artem + ズイコフ](https://github.com/4ertus2)) +- フォーマット文字列のためのテンプレートデータの形式は指定のファイルです。 + [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([tavplubix](https://github.com/tavplubix)) + +#### 新機能 {#new-feature-2} + +- UniqCombined64()を導入して、uint\_maxより大きい基数を計算します。 + [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), + [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([Azat + Khuzhin](https://github.com/azat)) +- 支援Bloom filterを指標配列に列あります。 + [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) + ([アチンバ州](https://github.com/achimbab)) +- 関数の追加 `getMacro(name)` それは対応するの値を持つ文字列を返します `` + サーバー構成から. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) + ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- HTTPソースに基づくディクショナリの構成オプションを設定します: `credentials` と + `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([ギヨーム + タッサリー](https://github.com/YiuRULE)) +- 新しいProfileEventの追加 `Merge` これは、起動された背景マージの数をカウントします。 + [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([ミハイル + コロトフ](https://github.com/millb)) +- 完全修飾ドメイン名を返すfullHostName関数を追加します。 + [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) + [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([スンディリ](https://github.com/sundy-li)) +- 関数を追加 `arraySplit` と `arrayReverseSplit` これによって配列を分割する “cut off” + 条件だ それらは時系列の処理で有用である。 + [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([hcz](https://github.com/hczhcz)) +- MultiMatch関数ファミリー内のすべての一致したインデックスの配列を返す新しい関数を追加します。 + [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([ダニラ + クテニン](https://github.com/danlark1)) +- 新規データベースエンジンの追加 `Lazy` これは、多数の小ログを格納するために最適化されています + テーブル [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([ニキータ + ヴァシレフ](https://github.com/nikvas0)) +- ビットマップ列の集計関数groupBitmapAnd,-Or,-Xorを追加します。 [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([Zhichang + ゆう](https://github.com/yuzhichang)) +- Nullを返す集計関数のコンビネータ-OrNullと-OrDefaultを追加します + または集計するものがない場合のデフォルト値。 + [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) + ([hcz](https://github.com/hczhcz)) +- カスタムエスケープをサポートするCustomSeparatedデータ形式の導入 + 区切り文字ルール。 [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([tavplubix](https://github.com/tavplubix)) +- 外部辞書のソースとしてRedisをサポートします。 [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([コムノディ](https://github.com/comunodi), [アントン + ポポフ](https://github.com/CurtizJ)) + +#### バグ修正 {#bug-fix-2} + +- 誤ったクエリ結果を修正 `WHERE IN (SELECT ...)` セクションと `optimize_read_in_order` は + 使用される。 [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([アントン + ポポフ](https://github.com/CurtizJ)) +- プロジェクト外のファイルに依存するMariaDB認証プラグインを無効にしました。 + [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([ユーリー + バラノフ](https://github.com/yurriy)) +- 例外を修正 `Cannot convert column ... because it is constant but values of constants are different in source and result` これは関数が `now()`, `today()`, + `yesterday()`, `randConstant()` 使用されます。 + [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([ニコライ + コチェトフ](https://github.com/KochetovNicolai)) +- TCP keep alive timeoutの代わりにHTTP keep alive timeoutを使用する問題を修正しました。 + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([ヴァシーリー + ネムコフ](https://github.com/Enmk)) +- GroupBitmapOrのセグメンテーションエラーを修正しました(問題 [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). + [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([Zhichang + ゆう](https://github.com/yuzhichang)) +- マテリアライズドビュ + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([イワン](https://github.com/abyss7)) +- 間違って修正 `duration_ms` の値 `system.part_log` テーブル。 それは十回オフでした。 + [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([Vladimir + チェボタレフ](https://github.com/excitoon)) +- 修正を解決するクラッシュライブビューテーブルの再可能なすべてのライブビュー。 + [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) + ([ヴザカズニコフ](https://github.com/vzakaznikov)) +- MergeTreeパーツの最小/最大インデックスでNULL値を正しくシリアル化します。 + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander + クズメンコフ](https://github.com/akuzm)) +- 仮想列を配置しないでください。テーブルの作成時のsqlメタデータ `CREATE TABLE AS`. + [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([イワン](https://github.com/abyss7)) +- 固定の区分断層に `ATTACH PART` クエリ。 + [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) + ([アレサピン](https://github.com/alesapin)) +- サブクエリ内の空と空の最適化によって与えられたいくつかのクエリの誤った結果を修正 + INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([ニコライ + コチェトフ](https://github.com/KochetovNicolai)) +- ライブビューのgetHeader()メソッドでAddressSanitizerエラーを修正しました。 + [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) + ([ヴザカズニコフ](https://github.com/vzakaznikov)) + +#### 改善 {#improvement-1} + +- Queue\_wait\_max\_ms待機が行われた場合にメッセージを追加します。 + [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([Azat + Khuzhin](https://github.com/azat)) +- 作られた設定 `s3_min_upload_part_size` テーブルレベル。 + [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([Vladimir + チェボタレフ](https://github.com/excitoon)) +- StorageFactoryでTTLをチェックします。 [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) + ([スンディリ](https://github.com/sundy-li)) +- 部分マージ結合(最適化)で左側のブロックをスカッシュします。 + [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([Artem + ズイコフ](https://github.com/4ertus2)) +- レプリケートされたテーブルエンジンの突然変異で非決定性関数を許可しないでください。 + レプリカ間に不整合が生じる可能性があります。 + [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([Alexander + カザコフ](https://github.com/Akazz)) +- 無効メモリにトラッカーが変換の例外のスタックトレースを文字列になります。 これは、損失を防ぐことができ + タイプのエラーメッセージの `Memory limit exceeded` サーバー上で、これは `Attempt to read after eof` クライアントの例外。 [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) + ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- その他の形式の改善。 解決 + [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), + [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), + [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), + [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) + [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) + ([tavplubix](https://github.com/tavplubix)) +- ClickHouseは、IN演算子の右側の値を無視します。 + side type. Make it work properly for compound types – Array and Tuple. + [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([Alexander + クズメンコフ](https://github.com/akuzm)) +- ASOF結合の不等式の欠落をサポートします。 以下または等しいvariantとstrictを結合することは可能です + ON構文のASOF列の大きい方と小さい方のバリアント。 + [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([Artem + ズイコフ](https://github.com/4ertus2)) +- 部分マージ結合を最適化します。 [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) + ([アルテム-ズイコフ](https://github.com/4ertus2)) +- UniqCombined関数では98Kを超えるメモリを使用しないでください。 + [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), + [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([Azat + Khuzhin](https://github.com/azat)) +- PartialMergeJoinのディスク上の右側の結合テーブルの部分をフラッシュします(十分でない場合 + メモリ)。 負荷データが必要です。 [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) + ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 性能向上 {#performance-improvement-1} + +- データの重複を避けることにより、const引数でjoinGetを高速化します。 + [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([アモス + 鳥](https://github.com/amosbird)) +- サブクエリが空の場合は、早期に戻ります。 + [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) +- 値のSQL式の解析を最適化します。 + [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) + ([tavplubix](https://github.com/tavplubix)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-1} + +- Mac OSへのクロスコンパイルのための一部の貢献を無効にします。 + [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([イワン](https://github.com/abyss7)) +- Clickhouse\_common\_ioのためのpocoxmlとのリンク不足を追加します。 + [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([Azat + Khuzhin](https://github.com/azat)) +- Clickhouse-testで複数のテストフィルター引数を受け入れます。 + [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([Alexander + クズメンコフ](https://github.com/akuzm)) +- ARM用のmuslおよびjemallocを有効にします。 [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) + ([アモス鳥](https://github.com/amosbird)) +- 追加 `--client-option` パラメータ `clickhouse-test` 追加のパラメータをclientに渡す。 + [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([ニコライ + コチェトフ](https://github.com/KochetovNicolai)) +- Rpmパッケ + [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) + ([フィリモノフ](https://github.com/filimonov)) +- PVSで検出されたエラーを修正しました。 [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([Artem + ズイコフ](https://github.com/4ertus2)) +- ダーウィンのビルドを修正。 [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) + ([イワン](https://github.com/abyss7)) +- glibc2.29の互換性。 [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([アモス + 鳥](https://github.com/amosbird)) +- Dh\_cleanが潜在的なソースファイルに触れないようにします。 + [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([アモス + 鳥](https://github.com/amosbird)) +- Altinity rpmから更新するときに競合を避けるようにしようとします。 + clickhouse-server-commonで。 [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) + ([フィリモノフ](https://github.com/filimonov)) +- 最適なヘッダファイルにより再建. + [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), + [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([Alexander + クズメンコフ](https://github.com/akuzm)) +- 追加の性能試験のための日DateTime. [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([ヴァシーリー + ネムコフ](https://github.com/Enmk)) +- 非決定論的変異を含むいくつかのテストを修正します。 + [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([Alexander + カザコフ](https://github.com/Akazz)) +- CiにMemorySanitizerでビルドを追加します。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) + ([Alexander Kuzmenkov](https://github.com/akuzm)) +- MetricsTransmitterで初期化されていない値の使用を避けます。 + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat + Khuzhin](https://github.com/azat)) +- 固定のいくつかの問題分野によっMemorySanitizer. + [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), + [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([Alexander + クズメンコフ](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) + ([アモス鳥](https://github.com/amosbird)) +- Murmurhash32の未定義の動作を修正しました。 [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([アモス + 鳥](https://github.com/amosbird)) +- StoragesInfoStreamの未定義の動作を修正しました。 [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) + ([tavplubix](https://github.com/tavplubix)) +- 外部データベースエンジン(MySQL、ODBC、JDBC)のための固定定数式の折り畳み。 前に + バージョンは、複数の定数式では機能せず、日付のためにまったく機能していませんでした, + DateTimeとUUID。 この修正 [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) + ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- No\_users\_thread変数にアクセスするときに、ライブビューでThreadSanitizerデータ競合エラーを修正しました。 + [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) + ([ヴザカズニコフ](https://github.com/vzakaznikov)) +- Libcommonのmallocシンボルを取り除く + [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), + [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([アモス + 鳥](https://github.com/amosbird)) +- 追加グローバル旗ENABLE\_LIBRARIES無効化のためのすべての図書館です。 + [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) + ([プロラー](https://github.com/proller)) + +#### コードの消去 {#code-cleanup} + +- 辞書のDDLを準備するために構成リポジトリを一般化します。 [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) + ([アレサピン](https://github.com/alesapin)) +- 任意のセマンティックなし辞書DDLのためのパーサ。 + [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) + ([アレサピン](https://github.com/alesapin)) +- ParserCreateQueryを別の小さなパーサーに分割します。 + [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) + ([アレサピン](https://github.com/alesapin)) +- 外部ディクショナリの近くに小さなリファクタリングと名前変更。 + [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) + ([アレサピン](https://github.com/alesapin)) +- Refactor一部のコードの準備のための役割ベースのアクセス制御です。 [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([ヴィタリ + バラノフ](https://github.com/vitlibar)) +- データベースのいくつかの改善事例コード。 + [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([ニキータ + ヴァシレフ](https://github.com/nikvas0)) +- ハッシュテーブルのfind()およびemplace()メソッドで反復子を使用しないでください。 + [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([Alexander + クズメンコフ](https://github.com/akuzm)) +- パラメータrootが空でない場合のgetMultipleValuesFromConfigを修正しました。 [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) + ([ミハイル-コロトフ](https://github.com/millb)) +- いくつかのコピーペーストを削除します(TemporaryFileとTemporaryFileStream) + [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([Artem + ズイコフ](https://github.com/4ertus2)) +- コードの可読性を少し改善 (`MergeTreeData::getActiveContainingPart`). + [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([Vladimir + チェボタレフ](https://github.com/excitoon)) +- お待ちすべての予定の仕事をローカルオブジェクトの場合 `ThreadPool::schedule(...)` スロー + 例外です。 名前変更 `ThreadPool::schedule(...)` に `ThreadPool::scheduleOrThrowOnError(...)` と + 固定のコメントを明らかな場合にスロー. + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) + ([tavplubix](https://github.com/tavplubix)) + +## ClickHouseリリース19.15 {#clickhouse-release-19-15} + +### ClickHouse Release19.15.4.10,2019年10月31日 {#clickhouse-release-19-15-4-10-2019-10-31} + +#### バグ修正 {#bug-fix-3} + +- SQL\_TINYINTとSQL\_BIGINTの処理を追加し、ODBC BridgeでのSQL\_FLOATデータソース型の処理を修正しました。 + [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([デニス-グラザチェフ](https://github.com/traceon)) +- において一部の部品の上に先ディスクまたはボリュームに移動がありました。 + [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- ODBCブリッジによるnull許容列のNULL値を修正しました。 + [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- マテリアライズ列を持つ分散非ローカルノードへの固定挿入。 + [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) +- 固定関数getMultipleValuesFromConfig。 + [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([ミハイル-コロトフ](https://github.com/millb)) +- TCP keep alive timeoutの代わりにHTTP keep alive timeoutを使用する問題を修正しました。 + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- すべてのジョブが例外で終了するのを待ちます(まれなsegfaultsを修正します)。 + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([tavplubix](https://github.com/tavplubix)) +- カフカテーブルに挿入するときは、MVsにプッシュしないでください。 + [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([イワン](https://github.com/abyss7)) +- 無効メモリにトラッカーのための例外をスタックです。 + [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 外部データベー + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- MetricsTransmitterで初期化されていない値の使用を避けます。 + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat Khuzhin](https://github.com/azat)) +- テスト用のマクロを使用した設定例を追加 ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.15.3.6,2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} + +#### バグ修正 {#bug-fix-4} + +- ハッシュ辞書のbad\_variantを修正しました。 + ([アレサピン](https://github.com/alesapin)) +- 修正のバグと分割詳しくは動画内で、タグは付け部分を返します。 + ([アレサピン](https://github.com/alesapin)) +- 固定時間計算 `MergeTreeData`. + ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- 書き込みが完了した後、明示的にKafkaにコミットします。 + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([イワン](https://github.com/abyss7)) +- MergeTreeパーツの最小/最大インデックスでNULL値を正しくシリアル化します。 + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander Kuzmenkov](https://github.com/akuzm)) + +### ClickHouseリリース19.15.2.2,2019-10-01 {#clickhouse-release-19-15-2-2-2019-10-01} + +#### 新機能 {#new-feature-3} + +- 段階のストレージへのサポート使用数量のためのテーブルMergeTreeエンジンです。 新しいデータをSSDに保存し、古いデータを自動的にHDDに移動することができます。 ([例](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([Igr](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([アレサピン](https://github.com/alesapin)) +- テーブル関数の追加 `input` 入って来るデータを読むため `INSERT SELECT` クエリ。 [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([パラソニック1color](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([アントン-ポポフ](https://github.com/CurtizJ)) +- Aを追加 `sparse_hashed` 辞書レイアウトは、機能的には `hashed` レイアウトが、より効率的なメモリです。 これは、より遅い値の取得を犠牲にして約二倍少ないメモリを使用しています。 [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([Azat Khuzhin](https://github.com/azat)) +- 辞書にアクセスするユーザーのリストを定義する機能を実装します。 のみ接続中のデータベース。 [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- 追加 `LIMIT` オプション `SHOW` クエリ。 [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([フィリップ-マルコフスキー](https://github.com/malkfilipp)) +- 追加 `bitmapSubsetLimit(bitmap, range_start, limit)` 最小の部分集合を返す関数 `limit` より小さくないセット内の値 `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([Zhichang Yu](https://github.com/yuzhichang)) +- 追加 `bitmapMin` と `bitmapMax` 機能。 [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([Zhichang Yu](https://github.com/yuzhichang)) +- 関数を追加 `repeat` 関連する [問題-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([フリン](https://github.com/ucasFL)) + +#### 実験的な特徴 {#experimental-feature-1} + +- 現在のパイプラインを変更しないマージ結合バリアントを実装する(メモリ内)。 結果はマージキーで部分的にソートされます。 セット `partial_merge_join = 1` この機能を使用します。 Merge Joinはまだ開発中です。 [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 追加 `S3` エンジンおよびテーブル機能。 まだ開発中です(認証サポートはまだありません)。 [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) + +#### 改善 {#improvement-2} + +- 全てのメッセージから読み込むカフカを挿入し、原子. これにより、Kafka engineのほぼすべての既知の問題が解決されます。 [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([イワン](https://github.com/abyss7)) +- 分散クエリのフェールオーバーの改善。 回復時間を短くして下さい、またそれは今構成可能で、見ることができます `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 列挙型の数値を直接サポート `IN` セクション \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([dimarub2000](https://github.com/dimarub2000)) +- サポート(オプション、障害者によるデフォルト)のリダイレクトURLに保管します。 [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([maqroll](https://github.com/maqroll)) +- 古いバージョンのクライア [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([フィリップ-マルコフスキー](https://github.com/malkfilipp)) +- 分散テーブルでのデータ送信の最大バックオフスリープ時間制限の削除 [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([Azat Khuzhin](https://github.com/azat)) +- 追加送れるプイベントカウンター)との累積値をグラファイトを表してい これは `` サーバー内 `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([Azat Khuzhin](https://github.com/azat)) +- 自動的にキャストタイプを追加 `T` に `LowCardinality(T)` 型の列にデータを挿入するとき `LowCardinality(T)` HTTP経由でネイティブ形式で。 [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 機能を使用する機能を追加 `hex` 使用しないで `reinterpretAsString` のために `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([ミハイル-コロトフ](https://github.com/millb)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-2} + +- デバッグ情報を使用してclickhouseバイナリにgdb-indexを追加します。 それはの起動時間をスピードアップします `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([アレサピン](https://github.com/alesapin)) +- 使用するパッチを適用されたdpkg-debによるdebパッケージングの高速化 `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([アレサピン](https://github.com/alesapin)) +- セット `enable_fuzzing = 1` すべてのプロジェクトコードのlibfuzzer計測を有効にするには。 [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([キプリゼル](https://github.com/kyprizel)) +- CIに分割ビルド煙テストを追加します。 [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([アレサピン](https://github.com/alesapin)) +- CiにMemorySanitizerでビルドを追加します。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([Alexander Kuzmenkov](https://github.com/akuzm)) +- 置換 `libsparsehash` と `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([Azat Khuzhin](https://github.com/azat)) + +#### バグ修正 {#bug-fix-5} + +- 固定性能の劣化指標分析複雑なテンキーの大きます。 これは\#6924を修正します。 [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- カフカ空のトピックから選択するとsegfaultsの原因となる論理エラーを修正しました。 [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([イワン](https://github.com/abyss7)) +- 早すぎるMySQL接続を修正 `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- 非常に古いLinuxカーネルのサポートを返しました(修正 [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- で可能なデータ損失を修正 `insert select` 入力ストリーム内の空のブロックの場合のクエリ。 \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 機能のための苦境 `АrrayEnumerateUniqRanked` paramsに空の配列がある場合 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([プロラー](https://github.com/proller)) +- 配列結合およびグローバルサブクエリによる複雑なクエリの修正 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([イワン](https://github.com/abyss7)) +- 修正 `Unknown identifier` 複数の結合によるORDER BYおよびGROUP BYのエラー [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定 `MSan` 関数の実行中に警告 `LowCardinality` 引数。 [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) + +#### 下位互換性のない変更 {#backward-incompatible-change-2} + +- 変更直列化形式のビットマップ\*集計機能状態の性能の向上を図ります。 直列化された状態のビットマップからは、以前のバージョン読み込むことができません。 [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([Zhichang Yu](https://github.com/yuzhichang)) + +## ClickHouseリリース19.14 {#clickhouse-release-19-14} + +### ClickHouse Release19.14.7.15,2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} + +#### バグ修正 {#bug-fix-6} + +- このリリースも含む全てのバグ修正から19.11.12.69. +- 19.14以前のバージョンの分散クエリの互換性を修正しました。 この修正 [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.14.6.12,2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} + +#### バグ修正 {#bug-fix-7} + +- 機能のための苦境 `АrrayEnumerateUniqRanked` paramsに空の配列があります。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([プロラー](https://github.com/proller)) +- とクエリ内の固定サブクエリ名 `ARRAY JOIN` と `GLOBAL IN subquery` 別名を持つ。 外部テーブル名が指定されている場合は、副問合せ別名を使用します。 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([イワン](https://github.com/abyss7)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-3} + +- 修正 [フラッピング](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) テスト `00715_fetch_merged_or_mutated_part_zookeeper` 突然変異が適用されるのを待つ必要があるため、シェルスクリプトに書き換えることです。 [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([Alexander Kazakov](https://github.com/Akazz)) +- 機能の固定UBSanおよびMemSanの失敗 `groupUniqArray` emtpy配列の引数を指定します。 それは空の配置によって引き起こされた `PaddedPODArray` へのハッシュテーブルのゼロの細胞でのコンストラクターゼの細胞値ませんでした。 [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([アモス鳥](https://github.com/amosbird)) + +### ClickHouse Release19.14.3.3,2019-09-10 {#clickhouse-release-19-14-3-3-2019-09-10} + +#### 新機能 {#new-feature-4} + +- `WITH FILL` 修飾子のための `ORDER BY`. (の続き [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([アントン-ポポフ](https://github.com/CurtizJ)) +- `WITH TIES` 修飾子のための `LIMIT`. (の続き [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 引用符なしの解析 `NULL` NULLとしてリテラル(設定の場合 `format_csv_unquoted_null_literal_as_null=1`). このフィールドのデータ型がnull許容でない場合(設定の場合)、nullフィールドを既定値で初期化します `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([tavplubix](https://github.com/tavplubix)) +- 表関数のパスでのワイルドカードのサポート `file` と `hdfs`. パスにワイルドカードが含まれる場合、テーブルはreadonlyになります。 使用例: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` と `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([Olga Khvostikova](https://github.com/stavrolia)) +- 新しい `system.metric_log` の値を格納するテーブル `system.events` と `system.metrics` 指定された時間間隔で。 [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ClickHouseテキストログの書き込みを許可する `system.text_log` テーブル。 [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ショー民間のシンボルスタックトレース(ターを通じて構文解析シンボルテーブルのELFファイル). 追加情報ファイルと行番号をスタックトレースの場合のデバッグ情報があります。 高速シンボル名のルックアップインデックスの記号が存在します。 内観のための新しいSQL関数を追加しました: `demangle` と `addressToLine`. 名前変更された関数 `symbolizeAddress` に `addressToSymbol` 一貫性のために。 関数 `addressToSymbol` パフォーマンス上の理由から壊れた名前を返し、適用する必要があります `demangle`. 設定を追加 `allow_introspection_functions` デフォルトではオフになっています。 [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- テーブル関数 `values` (名前は大文字と小文字を区別しません)。 ることができるから読み込む `VALUES` で提案されたリスト [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). 例: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) +- ストレージ設定を変更する機能を追加しました。 構文: `ALTER TABLE MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([アレサピン](https://github.com/alesapin)) +- 孤立した部品の取除くためのサポート。 構文: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([tavplubix](https://github.com/tavplubix)) +- テーブル制約。 挿入時にチェックされるテーブル定義に制約を追加することができます。 [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([グレブ-ノビコフ](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- カスケードマテリアライズドビューのSuppport。 [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([アモス鳥](https://github.com/amosbird)) +- On queryプロファイラのデフォルトでサンプル毎にクエリの実行スレッドだ。 [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 入力形式 `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([akonyaev90](https://github.com/akonyaev90)) +- 二つの新機能を追加しました: `sigmoid` と `tanh` (機械学習アプリケーションに役立ちます)。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 関数 `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` 指定されたトークンがhaystackにあるかどうかを確認する。 トークンは、英数字でないASCII文字(またはhaystackの境界)の間の最大長の部分文字列です。 Tokenは定数文字列である必要があります。 Tokenbf\_v1インデックス特殊化でサポートされます。 [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 新しい機能 `neighbor(value, offset[, default_value])`. データのブロック内の列内の前/次の値に到達することができます。 [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([Alex Krash](https://github.com/alex-krash)) [6685365ab8c5b74f9650492c88a012596eb1b0c6](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341e2e4587a18065c2da1ca888c73389f48ce36c](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov) +- 関数の作成 `currentUser()`、許可されたユーザのログインを返す。 エイリアスを追加 `user()` MySQLとの互換性のため。 [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([Alex Krash](https://github.com/alex-krash)) +- 新しい集計関数 `quantilesExactInclusive` と `quantilesExactExclusive` で提案された [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([dimarub2000](https://github.com/dimarub2000)) +- 関数 `bitmapRange(bitmap, range_begin, range_end)` 指定された範囲を持つ新しいセットを返します。 `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([Zhichang Yu](https://github.com/yuzhichang)) +- 関数 `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` これは、提供された領域をカバーするgeohashボックスの精度の長い文字列の配列を作成します。 [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 挿入クエリのサポートを実装する `Kafka` テーブル [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([イワン](https://github.com/abyss7)) +- 追加されたサポート `_partition` と `_timestamp` カフカエンジンへの仮想列。 [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([イワン](https://github.com/abyss7)) +- から機密データを削除する可能性 `query_log`、サーバーログ、regexpベースのルールを持つプロセスリスト。 [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([フィリモノフ](https://github.com/filimonov)) + +#### 実験的な特徴 {#experimental-feature-2} + +- 入出力データ形式 `Template`. これは、入力と出力のカスタム書式文字列を指定することができます。 [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([tavplubix](https://github.com/tavplubix)) +- の実装 `LIVE VIEW` 最初に提案されたテーブル [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898)、で調製 [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925) で更新されます。 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). 見る [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) 詳細な説明のため。 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([ヴザカズニコフ](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([ヴザカズニコフ](https://github.com/vzakaznikov))なお `LIVE VIEW` 特集は削除される可能性があり、来できます。 + +#### バグ修正 {#bug-fix-8} + +- このリリースには、19.13と19.11のすべてのバグ修正も含まれています。 +- 固定の区分断層のテーブルはスキップ指標および垂直統合などが挙げられる。 [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([アレサピン](https://github.com/alesapin)) +- 非自明な列のデフォルトで列ごとのTTLを修正しました。 以前は強制TTLマージの場合 `OPTIMIZE ... FINAL` クエリー、終了しました値に置き換えられたタイプのデフォルトの代わりにユーザが指定した列のデフォルトする [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 固定カフカメッセージの複製問題が通常のサーバを再起動します。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([イワン](https://github.com/abyss7)) +- カフカメッセージを読み取るときに固定無限ループ。 そうしないと、一部のシナリオで無期限に一時停止されることがあります。 [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([イワン](https://github.com/abyss7)) +- 修正 `Key expression contains comparison between inconvertible types` 例外 `bitmapContains` 機能。 [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([dimarub2000](https://github.com/dimarub2000)) +- 有効でsegfaultを修正 `optimize_skip_unused_shards` シャーディングキーがない [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 固定の間違ったコードに変異のありメモリが破損す アドレスの読み取りで固定segfault `0x14c0` それは同時に起こった可能性があります `DROP TABLE` と `SELECT` から `system.parts` または `system.parts_columns`. 突然変異クエリの準備における競合状態を修正しました。 によるデッドロックを修正 `OPTIMIZE` 変更のようなレプリケートされたテーブルと同時変更操作の。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- MySQLインターフェイスで余分な冗長ロギングを削除 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ブール値の設定を解析する機能を返します ‘true’ と ‘false’ 設定ファイル内。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([アレサピン](https://github.com/alesapin)) +- でクラッシュを修正 `quantile` と `median` 関数オーバー `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- によって返される不完全な結果を修正 `SELECT` クエリ `WHERE` 主キーの条件に浮動小数点型への変換が含まれていました。 これは単調性の誤ったチェックによって引き起こされた `toFloat` 機能。 [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) +- チェック `max_expanded_ast_elements` 突然変異の設定。 後の明確な突然変異 `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([冬張](https://github.com/zhang2014)) +- キー列の結合結果を修正 `join_use_nulls`. 列の既定値の代わりにNullを添付します。 [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 垂直マージと変更とスキップインデックスの修正。 のための修正 `Bad size of marks file` 例外だ [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([アレサピン](https://github.com/alesapin)) +- で珍しいクラッシュを修正 `ALTER MODIFY COLUMN` マージされた/変更された部分のいずれかが空の場合(0行)、垂直マージ) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([アレサピン](https://github.com/alesapin)) +- の変換のバグを修正しました `LowCardinality` タイプ `AggregateFunctionFactory`. この修正 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 間違った動作と可能なsegfaultsを修正 `topK` と `topKWeighted` 集計関数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 安全でないコードを修正 `getIdentifier` 機能。 [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 問題を修正しましたMySQLのワイヤーロを使用すると接続するClickHouse形MySQLクライアント). によるヒープバッファオーバーフロー `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([ユーリー-バラノフ](https://github.com/yurriy)) +- 修正されたメモリリーク `bitmapSubsetInRange` 機能。 [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([Zhichang Yu](https://github.com/yuzhichang)) +- 粒度の変更後に突然変異が実行される珍しいバグを修正しました。 [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([アレサピン](https://github.com/alesapin)) +- きprotobufメッセージの全ての分野でのデフォルトです。 [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- バグを解決する `nullIf` 私達がaを送る場合の機能 `NULL` 第二の引数の引数。 [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- 無限のメモリ消費(メモリリークのように見える)につながる文字列フィールドを持つ複雑なキーキャッシュ辞書で間違ったメモリ割り当て/割り当て解除 バグは、文字列のサイズが八から始まる二の累乗(8、16、32など)だったときに再現します。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([アレサピン](https://github.com/alesapin)) +- 固定Gorillaエンコーディングの小型配列により例外 `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 結合でnull許容できない型を使用できるようにする `join_use_nulls` 有効。 [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 無効にする `Poco::AbstractConfiguration` クエリ内の置換 `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- でデッドロックを回避 `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- を使用して `arrayReduce` 定数引数の場合、segfaultにつながる可能性があります。 [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 後にレプリカが復元された場合に表示される矛盾した部分を修正 `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- 固定ハングイン `JSONExtractRaw` 機能。 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正のバグと誤ったスキップ指数の直列化を行い、その凝集と適応粒度. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([アレサピン](https://github.com/alesapin)) +- 修正 `WITH ROLLUP` と `WITH CUBE` の修飾子 `GROUP BY` 二レベルの集計を使って。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 適応粒度で二次インデックスマークを書くとバグを修正しました。 [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([アレサピン](https://github.com/alesapin)) +- サーバーの起動時に初期化の順序を修正しました。 以来 `StorageMergeTree::background_task_handle` で初期化される。 `startup()` その `MergeTreeBlockOutputStream::write()` 初期化の前に使用しようとする可能性があります。 すぐチェックインの場合は初期化されます。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([イワン](https://github.com/abyss7)) +- エラーで完了した前の読み取り操作からデータバッファをクリアします。 [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([ニコライ](https://github.com/bopohaa)) +- 固定バを適応的粒度を新規作成時のレプリカのための複製\*MergeTreeます。 [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([アレサピン](https://github.com/alesapin)) +- 例外が発生した場合にサーバーの起動時にクラッシュする可能性を修正 `libunwind` 未初期化へのアクセス時の例外中 `ThreadStatus` 構造。 [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) +- でクラッシュを修正 `yandexConsistentHash` 機能。 ファズテストによって発見。 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定の可能性を掛けのクエリがサーバが過負荷状態で運転され、グローバルスレッドプールが近い。 これは、分散クエリが各シャードに接続ごとにスレッドを割り当てるため、多数のシャード(数百)を持つクラスターで発生する可能性が高くなります。 例えば、この問題が再現場クラスターの330の破片が処理を同時30分布します。 この問題は19.2以降のすべてのバージョンに影響します。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- の固定ロジック `arrayEnumerateUniqRanked` 機能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定segfaultデコードする際のシンボル。 [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([アモス鳥](https://github.com/amosbird)) +- キャストの無関係な例外を修正しました `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- の説明の余分な引用を削除しました `system.settings` テーブル。 [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- で可能なデッドロックを回避 `TRUNCATE` 複製されたテーブルの。 [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ソートキーの順に読み取りを修正しました。 [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 修正 `ALTER TABLE ... UPDATE` テーブルのクエリ `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([アレサピン](https://github.com/alesapin)) +- で開かれたバグを修正 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (19.4.0以降)。 列を照会しないときに、MergeTreeテーブル上の分散テーブルへのクエリを再現します (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([アレサピン](https://github.com/alesapin)) +- 符号付き型から符号なし型への整数除算でのオーバーフローを修正。 この動作は、cまたはC++言語(整数昇格規則)とまったく同じで、驚くべきことです。 大きな符号付き数値を大きな符号なし数値に分割する場合、またはその逆に分割する場合は、オーバーフローが可能であることに注意してください(ただし、 の問題が全てのサーバーのバージョン [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- スロットルの最大スリープ時間を制限する場合 `max_execution_speed` または `max_execution_speed_bytes` 設定されています。 固定falseのようなエラー `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 使用に関する問題を修正 `MATERIALIZED` 列とエイリアス `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([アモス鳥](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正 `FormatFactory` プロセッサとして実装されていない入力ストリームの動作。 [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- タイプミスを修正。 [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([アレックス-リンディン](https://github.com/alexryndin)) +- エラーメッセージの入力ミス(is-\>are)。 [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([デニス-ジュラヴレフ](https://github.com/den-crane)) +- Typeにカンマが含まれている場合、stringからの列リストの解析中にエラーが修正されました(この問題は `File`, `URL`, `HDFS` ストレージ) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) + +#### セキュリティ修正 {#security-fix} + +- このリリースも含む全てのバグのセキュリティ修正をか19.13と19.11. +- 固定の可能性に作製したクエリがサーバのクラッシュによるスタックオーバーフローアプリケーションパーサです。 固定の可能性スタックオーバーフローに統合、配布し、テーブルが現実の景色の件本件は、行レベルのセキュリティなサブクエリ. [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 改善 {#improvement-3} + +- のための三項論理の正しい実装 `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([Alexander Kazakov](https://github.com/Akazz)) +- 有効期限が切れたTTLの値と行は、次のように削除されます `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` クエリ。 クエリの追加 `SYSTEM STOP/START TTL MERGES` 可に/を割り当てを合併TTLおよびフィルター終了しました値をすべてが合併。 [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 使用してクライアントのClickHouse履歴ファイルの場所を変更する可能性 `CLICKHOUSE_HISTORY_FILE` env. [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([フィリモノフ](https://github.com/filimonov)) +- 削除 `dry_run` からの旗 `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- サポート `ASOF JOIN` と `ON` セクション [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- よりよい支援をスキップ指数の突然変異およびます。 のサポート `MATERIALIZE/CLEAR INDEX ... IN PARTITION` クエリ。 `UPDATE x = x` recalculatesすべての指標を使用するカラム `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- 許可する `ATTACH` ライブビュー(たとえば、サーバー起動時)に関係なく `allow_experimental_live_view` 設定。 [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- のためのスタックトレースに集まるエリプロファイラに含まれているものも含むスタックフレームが発生するqueryプロファイラです。 [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 今すぐテーブル関数 `values`, `file`, `url`, `hdfs` 別名の列をサポートしています。 [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 例外をスローする場合 `config.d` fileには、設定ファイルとして対応するルート要素がありません。 [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) +- のための例外メッセージに余分な情報を印刷 `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([tavplubix](https://github.com/tavplubix)) +- のシャードを決定するとき `Distributed` 読み取りクエリでカバーされるテーブル `optimize_skip_unused_shards` =1)ClickHouseは今両方からの条件を点検します `prewhere` と `where` select文の句。 [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([Alexander Kazakov](https://github.com/Akazz)) +- 有効 `SIMDJSON` AVX2のないしかしSSE4.2およびPCLMULの指示セットが付いている機械のため。 [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ClickHouseはファイルシステムで `O_DIRECT` 追加のチューニングなしのサポート(ZFSやBtrFSなど)。 [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 最終サブクエリのプッシュダウン述語をサポート。 [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([Tシーズン](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- より良い `JOIN ON` キー抽出 [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 最小の列の選択を最適化する `SELECT count()` クエリ。 [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([アモス鳥](https://github.com/amosbird)) +- 追加 `strict` パラメータin `windowFunnel()`. ときに `strict` は、 `windowFunnel()` 一意の値にのみ条件を適用します。 [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([アチンバ州](https://github.com/achimbab)) +- より安全なインタフェース `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([アヴァシリエフ](https://github.com/avasiliev)) +- オプションの行サイズ `--help` オプションに対応した端末のサイズです。 [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([dimarub2000](https://github.com/dimarub2000)) +- 無効にする “read in order” キーなしの集計の最適化。 [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([アントン-ポポフ](https://github.com/CurtizJ)) +- HTTPステータスコード `INCORRECT_DATA` と `TYPE_MISMATCH` エラーコードをデフォルトから変更 `500 Internal Server Error` に `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([アレクサンドロダン](https://github.com/a-rodin)) +- 結合オブジェクトの移動 `ExpressionAction` に `AnalyzedJoin`. `ExpressionAnalyzer` と `ExpressionAction` 知らない `Join` もう授業だ その論理は `AnalyzedJoin` アイフェイス [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定可能な行き詰まりの分散クエリーの資料はlocalhostでのクエリを送ネットワーク経由で接続します。 [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 複数のテーブルの意味を変更 `RENAME` 可能なデッドロックを避けるため。 [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 書き換えMySQLサーバーの互換性防止への負荷フルパケットペイロードに。 各接続のメモリ消費を約 `2 * DBMS_DEFAULT_BUFFER_SIZE` (読み取り/書き込みバッファ)。 [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([ユーリー-バラノフ](https://github.com/yurriy)) +- クエリセマンティクスについて何も知らなくてもパーサーからAST別名の解釈ロジックを移動します。 [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- もう少し安全な解析 `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `clickhouse-copier`:使用を許可 `where_condition` 設定から `partition_key` エイリアスクエリのためのチェック分配の存在についても同様とすでに使用されただけでデータを読み込むクエリ). [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([プロラー](https://github.com/proller)) +- オプションのメッセージ引数を `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([Vdimir](https://github.com/Vdimir)) +- 挿入データの送信中にサーバー例外が発生し、クライアントでも処理されます。 [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([dimarub2000](https://github.com/dimarub2000)) +- 指標を追加 `DistributedFilesToInsert` その総数のファイルをファイルシステムを送信リモートサーバーに配布します。 この数は、すべてのシャードで合計されます。 [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ほとんどの結合の移動準備ロジックから `ExpressionAction/ExpressionAnalyzer` に `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- ツァンを修正 [警告](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- Linuxの機能の欠如に関するより良い情報メッセージ。 致命的なエラーのログ “fatal” レベルとして迎えることを見 `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ディスクへの一時データのダンプを有効にして、メモリ使用量を制限する場合 `GROUP BY`, `ORDER BY` ディスクの空き容量をチェックしませんでした。 修正は、新しい設定を追加します `min_free_disk_space`、空きディスク領域は、それがしきい値より小さい場合、クエリが停止し、スローされます `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([Weiqing Xu](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- スレッドによる再帰rwlockを削除しました。 スレッドはクエリ間で再利用されるため、意味がありません。 `SELECT` クエリがロックを取得するスレッド、ロックから別のスレッドの出口から。 同時に、最初のスレッドは次のように再利用できます `DROP` クエリ。 これはfalseにつながります “Attempt to acquire exclusive lock recursively” メッセージ [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 分割 `ExpressionAnalyzer.appendJoin()`. 場所を準備する `ExpressionAnalyzer` のために `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 追加 `mysql_native_password` MySQL互換サーバーへの認証プラグイン。 [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([ユーリー-バラノフ](https://github.com/yurriy)) +- より少ない数の `clock_gettime` デバッグ/リリース間のABIの互換性を修正しました。 `Allocator` (重要でない問題)。 [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 移動 `collectUsedColumns` から `ExpressionAnalyzer` に `SyntaxAnalyzer`. `SyntaxAnalyzer` 作る `required_source_columns` 今自体。 [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 設定を追加 `joined_subquery_requires_alias` サブセレクトおよびテーブル関数にエイリアスを要求するには `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 抽出 `GetAggregatesVisitor` クラスから `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- `system.query_log`:データ型の変更 `type` 列へ `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) +- の静的リンク `sha256_password` 認証プラグイン。 [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([ユーリー-バラノフ](https://github.com/yurriy)) +- 設定の余分な依存関係を避ける `compile` 仕事に 以前のバージョンでは、 `cannot open crti.o`, `unable to find library -lc` 等。 [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 悪意のあるレプリカから来る可能性のある入力のより多くの検証。 [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- さて `clickhouse-obfuscator` ファイルは `clickhouse-client` パッケージ。 以前のバージョンでは `clickhouse obfuscator` (空白付き)。 [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([dimarub2000](https://github.com/dimarub2000)) +- 私たちは、異なる順序で少なくとも二つのテーブルを読み取り、いずれかのテーブルにDDL操作を実行する別のクエリを少なくとも二つのクエリを持って 非常に稀なデッドロックを修正しました。 [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加 `os_thread_ids` 列へ `system.processes` と `system.query_log` より良いデバッグの可能性。 [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 以下の場合に発生するPHP mysqlnd拡張バグの回避策 `sha256_password` デフォルトの認証プラグインとして使用されます [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([ユーリー-バラノフ](https://github.com/yurriy)) +- Null許容列が変更された不要な場所を削除します。 [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- デフォルト値の設定 `queue_max_wait_ms` 現在の値(五秒)は意味がありませんので、ゼロにします。 この設定が使用されることはまれです。 設定の追加 `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` と `connection_pool_max_wait_ms` 曖昧さの解消のために。 [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 抽出 `SelectQueryExpressionAnalyzer` から `ExpressionAnalyzer`. 非選択クエリの最後のクエリを保持します。 [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 入力形式と出力形式の重複を削除しました。 [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- ユーザーに上書きを許可する `poll_interval` と `idle_connection_timeout` 接続時の設定。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `MergeTree` 現在、追加オプション `ttl_only_drop_parts` (デフォルトでは無効)部品の部分的な剪定を避けるため、部品内のすべての行が期限切れになったときに完全に削除されます。 [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([セルジ-ウラジキン](https://github.com/svladykin)) +- 型は、set index関数をチェックします。 関数の型が間違っている場合は例外をスローします。 これは、UBSanでファズテストを修正します。 [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) + +#### 性能向上 {#performance-improvement-2} + +- クエリの最適化 `ORDER BY expressions` 句,where `expressions` ソートキーとプレフィックスが一致している `MergeTree` テーブル この最適化は `optimize_read_in_order` 設定。 [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 使用に応じることは、複数のスレッドの中で部品の搭載となります。 [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 実施バッチ変異体の更新に集計機能です。 で与えられる実装になっていると性能です。 [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- を使用して `FastOps` 関数用ライブラリ `exp`, `log`, `sigmoid`, `tanh`. FastOpsはマイケルParakhin(YandexのCTO)から高速ベクトル数学ライブラリです。 の改善された性能 `exp` と `log` 機能6回以上。 機能 `exp` と `log` から `Float32` 引数が返されます `Float32` (以前のバージョンでは、常に戻ります `Float64`). さて `exp(nan)` 返すように `inf`. の結果 `exp` と `log` 関数は、真の答えに最も近いマシン表現可能な数ではないかもしれません。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov))Fastopsを働かせるDanila Kuteninの変形を使用して [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 連続キーの最適化を無効にする `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([akuzm](https://github.com/akuzm)) +- の改善された性能 `simdjson` 図書館によくダイナミックな割り当てる `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- メモリを割り当てるときの障害前のページ `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([akuzm](https://github.com/akuzm)) +- パフォーマンスバグを修正 `Decimal` 比較。 [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-4} + +- 削除コンパイラ(ランタイムテンプレートインスタンス化でいきます。 [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加の性能試験への性能の低下gcc-9により孤立した。 [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- テーブル関数を追加 `numbers_mt` のマルチスレッドバージョンです。 `numbers`. 更新性能試験のハッシュ機能 [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 比較モード `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([dimarub2000](https://github.com/dimarub2000)) +- スタックトレースの印刷に最適です。 また、追加 `SIGPROF` 実行中のスレッドのスタックトレースを出力するデバッグ信号として。 [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 独自のファイル内のすべての関数、パート10。 [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 倍増定数を削除 `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([フィリモノフ](https://github.com/filimonov)) +- 書式設定の変更 `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([akuzm](https://github.com/akuzm)) +- 結合作成のためのより良いサブクエリ `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- (PVS Studioによって見つかった)冗長な条件を削除します。 [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([akuzm](https://github.com/akuzm)) +- 別々のハッシュテーブルインタフェース `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([akuzm](https://github.com/akuzm)) +- 設定のリファクタリング。 [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([アレサピン](https://github.com/alesapin)) +- コメントを追加 `set` インデックス関数。 [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- LinuxのデバッグバージョンでOOMスコアを上げます。 [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([akuzm](https://github.com/akuzm)) +- HDFS HAはデバッグビルドで動作します。 [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([Weiqing Xu](https://github.com/weiqxu)) +- にテストを追加しました `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- カフカ表の複数のマテリアライズドビューのテストを追加します。 [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([イワン](https://github.com/abyss7)) +- より良いビルドスキームを作る。 [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([イワン](https://github.com/abyss7)) +- 固定 `test_external_dictionaries` 非rootユーザーの下で実行された場合の統合。 [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- このバグは、書き込まれたパケットの合計サイズが `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([ユーリー-バラノフ](https://github.com/yurriy)) +- のテストを追加しました `RENAME` テーブル競合状態 [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 設定のデータ競争を避けなさい `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- キャッシュ辞書によるエラー処理の統合テストを追加します。 [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- それは意味がないので、Mac OS上でELFオブジェクトファイルの解析を無効にします。 [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- を試みることchangelog発生装置。 [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加 `-Wshadow` GCCに切り替えます。 [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([クロイツェルクリーク](https://github.com/kreuzerkrieg)) +- 削除された古いコード `mimalloc` サポート。 [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `zlib-ng` x86の機能を決定し、この情報をグローバル変数に保存します。 これは、同時に異なるスレッドによって行われてもよいdefalteInit呼び出しで行われます。 を避けるマルチスレッドに書き込み、図書館で起動します。 [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([akuzm](https://github.com/akuzm)) +- 結合で修正されたバグの回帰テスト [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([バフティヤール-ルジエフ](https://github.com/theruziev)) +- MSanレポートを修正しました。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- TTLテストをフラッピング修正。 [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([アントン-ポポフ](https://github.com/CurtizJ)) +- で修正された偽のデータレース `MergeTreeDataPart::is_frozen` フィールド [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ファズテストのタイムアウトを修正しました。 旧バージョンで簡単にfalse電話を切るクエリ `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- デバッグチェックを追加 `static_cast` 列の。 [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 公式RPMパッケージでのOracle Linuxのサポート。 [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Jsonパーフテストを `once` に `loop` タイプ。 [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- `odbc-bridge.cpp` 定義 `main()` したがって、それは `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([オリヴェイ-デシュ](https://github.com/orivej)) +- クラッシュのテスト `FULL|RIGHT JOIN` 右のテーブルのキーにnullがあります。 [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 念のためにエイリアスの拡張の制限のテストを追加しました。 [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- から切り替え `boost::filesystem` に `std::filesystem` 必要に応じて。 [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加RPMパッケージです。 [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定のテストを追加する `Unknown identifier` 例外 `IN` セクション [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 簡素化 `shared_ptr_helper` が直面する人びとの苦難を理解します。 [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定GorillaとDoubleDeltaコーデックのパフォーマンステストを追加しました。 [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 統合テストの分割 `test_dictionaries` 4つの別々のテストに。 [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- PVS-Studioの警告を修正 `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 使用を許可する `library` ASanと辞書ソース。 [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- PRsのリストから変更履歴を生成するオプションを追加しました。 [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ロック `TinyLog` 読む場合の貯蔵。 [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([akuzm](https://github.com/akuzm)) +- チェックを破symlinks CI. [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- タイムアウトの増加 “stack overflow” 試験で時間がかかる場合にはデバッグ。 [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 二重の空白のチェックを追加しました。 [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正 `new/delete` サニタイザーでビルドするときのメモリ追跡。 追跡は明確ではない。 テストでのメモリ制限の例外のみを防ぎます。 [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- リンク中に未定義のシンボルのチェックを有効にします。 [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([イワン](https://github.com/abyss7)) +- 再構築を避ける `hyperscan` 毎日 [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定されたUBSanのレポート `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- クエリプロファイラは互換性がないため、サニタイザでの使用を許可しないでください。 [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- タイマーで失敗した後に辞書を再ロードするテストを追加します。 [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- で矛盾を修正 `PipelineExecutor::prepareProcessor` 引数の型。 [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 不正なUriのテストを追加しました。 [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- より多くのチェックを追加 `CAST` 機能。 こいつの間にか.ファジィテストです。 [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 追加 `gcc-9` サポートへの `docker/builder` 画像をローカルに作成するコンテナ。 [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([グレブ-ノビコフ](https://github.com/NanoBjorn)) +- 主キーのテスト `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([dimarub2000](https://github.com/dimarub2000)) +- 遅いスタックトレース印刷の影響を修正しました。 [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- クラッシュのテストケースを追加する `groupUniqArray` で固定 [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([akuzm](https://github.com/akuzm)) +- 固定指標変異テスト。 [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- パフォーマンステス [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([akuzm](https://github.com/akuzm)) +- マテリアライズドビューは、疑わしい低い基数タイプに関する設定に関係なく、低い基数タイプで作成できるようになりました。 [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([Olga Khvostikova](https://github.com/stavrolia)) +- 更新されたテスト `send_logs_level` 設定。 [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- Gcc-8.2の下でビルドを修正しました。 [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([マックス-アクメドフ](https://github.com/zlobober)) +- 内部libc++でビルドを修正しました。 [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([イワン](https://github.com/abyss7)) +- 共有ビルドを修正 `rdkafka` ライブラリ [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([イワン](https://github.com/abyss7)) +- Mac OSのビルド(不完全)のための修正。 [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([アレックス-ザイツェフ](https://github.com/alex-zaitsev)) +- 修正 “splitted” ビルド [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- その他のビルド修正: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([アモス鳥](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([vxider](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([イワン](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([プロラー](https://github.com/proller)) + +#### 下位互換性のない変更 {#backward-incompatible-change-3} + +- めったに使用されない表関数を削除 `catBoostPool` そして貯蔵 `CatBoostPool`. を使った場合、このテーブル機能、メールを書いてください `clickhouse-feedback@yandex-team.com`. CatBoost統合は引き続きサポートされることに注意してください。 [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 無効にする `ANY RIGHT JOIN` と `ANY FULL JOIN` デフォルトでは。 セット `any_join_distinct_right_table_keys` それらを有効にする設定。 [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +## ClickHouseリリース19.13 {#clickhouse-release-19-13} + +### ClickHouseリリース19.13.6.51,2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} + +#### バグ修正 {#bug-fix-9} + +- このリリースも含む全てのバグ修正から19.11.12.69. + +### ClickHouseリリース19.13.5.44,2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} + +#### バグ修正 {#bug-fix-10} + +- このリリースには、19.14.6.12のすべてのバグ修正も含まれています。 +- 実行中にテーブルの一貫性のない状態を修正しました `DROP` クエリーのための複製テーブルが飼育係アクセスすることはできません。 [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) +- StorageMergeでのデータレースの修正 [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ソケットから無限のrecvにつながるクエリプロファイラのバグを修正しました。 [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([アレサピン](https://github.com/alesapin)) +- 実行中に過剰なCPU使用率を修正 `JSONExtractRaw` ブール値に対する関数。 [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 修正の回帰が進を実現します。 [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([イワン](https://github.com/abyss7)) +- テーブル関数 `url` この脆弱性により、攻撃者は要求に任意のHTTPヘッダーを挿入することができました。 この問題は [ニキータ-チホミロフ](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 役に立たない修正 `AST` Set indexをチェックインします。 [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- の修正された解析 `AggregateFunction` クエリに埋め込まれた値。 [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([Zhichang Yu](https://github.com/yuzhichang)) +- 修正された間違った動作 `trim` 機能ファミリー。 [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouseリリース19.13.4.32,2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} + +#### バグ修正 {#bug-fix-11} + +- このリリースには、19.11.9.52と19.11.10.54のすべてのバグセキュリティ修正も含まれています。 +- で固定データレース `system.parts` テーブルと `ALTER` クエリ。 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Sampleとprewhereで空の分散テーブルから読み込む場合に、ストリーム内のヘッダーの不一致を修正しました。 [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([Lixiang銭](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 使用時のクラッシュを修正 `IN` タプルを持つサブクエリを持つ句。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- 同じ列名の大文字と小文字を修正 `GLOBAL JOIN ON` セクション [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定したときにクラッシュする場合が鋳造型 `Decimal` それをサポートしていません。 代わりに例外を投げます。 [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- で固定クラッシュ `extractAll()` 機能。 [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- のクエリ変換 `MySQL`, `ODBC`, `JDBC` 表関数が正しく動作するようになった `SELECT WHERE` 複数のクエリ `AND` 式。 [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([dimarub2000](https://github.com/dimarub2000)) +- MySQL8統合のための以前の宣言チェックを追加しました。 [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([ラファエル-ダヴィド-ティノコ](https://github.com/rafaeldtinoco)) + +#### セキュリティ修正 {#security-fix-1} + +- 修二の脆弱性がコーデックに減圧相(悪意のあるユーザーが可能で圧縮データにつながるバッファオーバーフローの減圧). [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +### ClickHouse Release19.13.3.26,2019-08-22 {#clickhouse-release-19-13-3-26-2019-08-22} + +#### バグ修正 {#bug-fix-12} + +- 修正 `ALTER TABLE ... UPDATE` テーブルのクエリ `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([アレサピン](https://github.com/alesapin)) +- タプルを持つサブクエリでin句を使用するときにnpeを修正しました。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- 古いレプリカがアライブ状態になっても、DROP PARTITIONによって削除されたデータパーツが残っている可能性がある問題を修正しました。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- CSVの解析に関する問題を修正 [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) +- システム内の固定データレース。パーツテーブルとALTERクエリ。 この修正 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定の間違ったコードに変異のありメモリが破損す アドレスの読み取りで固定segfault `0x14c0` それは同時に起こった可能性があります `DROP TABLE` と `SELECT` から `system.parts` または `system.parts_columns`. 突然変異クエリの準備における競合状態を修正しました。 によるデッドロックを修正 `OPTIMIZE` 変更のようなレプリケートされたテーブルと同時変更操作の。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定可能なデータ損失の後 `ALTER DELETE` クエリーテーブルとキース。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) + +#### セキュリティ修正 {#security-fix-2} + +- 攻撃者がZooKeeperへの書き込みアクセス権を持ち、ClickHouseが実行されるネットワークから利用可能なカスタムサーバーを実行できる場合、ClickHouseのレプリカとして機能す きものレプリカまでデータを取得すから悪意のあるレプリカで力clickhouse-サーバへの書き込みを任意のパスにファイルシステム. Yandexの情報セキュリティチームEldar Zaitovによって発見されました。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouseリリース19.13.2.19,2019-08-14 {#clickhouse-release-19-13-2-19-2019-08-14} + +#### 新機能 {#new-feature-5} + +- サンプリングプロファイラーに照会です。 [例](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) +- 列のリストを指定できるようにする `COLUMNS('regexp')` のより洗練された変種のように動作する式 `*` アスタリスク [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([ムフリデンタル](https://github.com/mfridental)), ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `CREATE TABLE AS table_function()` 今では可能です [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([dimarub2000](https://github.com/dimarub2000)) +- 確率勾配降下のAdamオプティマイザは、デフォルトでは `stochasticLinearRegression()` と `stochasticLogisticRegression()` 集計機能を示すためのもので、良質なほとんど調整することがあります。 [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([Quid37](https://github.com/Quid37)) +- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([アンディ-ヤン](https://github.com/andyyzh)) +- `RENAME` クエリはすべてのストレージで動作します。 [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([イワン](https://github.com/abyss7)) +- 現在お客様の受信ログからサーバに要求レベルに設定 `send_logs_level` サーバー設定で指定されたログレベルに関係なく。 [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) + +#### 下位互換性のない変更 {#backward-incompatible-change-4} + +- 設定 `input_format_defaults_for_omitted_fields` 既定では有効です。 挿入学の領域において研究が行われてテーブルがこの設定は同じクラスター(設定する必要がありますので前に転じた。 この計算の複雑なデフォルト表現のための省略分野 `JSONEachRow` と `CSV*` フォーマット。 この挙動があるが無視できる性能の差です。 [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([アルテム-ズイコフ](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) + +#### 実験的な特徴 {#experimental-features} + +- 新規クエリ処理パイプライン。 使用 `experimental_use_processors=1` それを有効にするオプション。 あなた自身の悩みのための使用。 [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) + +#### バグ修正 {#bug-fix-13} + +- カフカの統合は、このバージョンで修正されました。 +- 固定 `DoubleDelta` のエンコード `Int64` 大きいのため `DoubleDelta` 値、改善 `DoubleDelta` ランダムデータのエンコード `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- の固定過大評価 `max_rows_to_read` 設定の場合 `merge_tree_uniform_read_distribution` 0に設定されます。 [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 改善 {#improvement-4} + +- 例外をスローする場合 `config.d` fileには、設定ファイルとして対応するルート要素がありません [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) + +#### 性能向上 {#performance-improvement-3} + +- 最適化 `count()`. これで、最小の列が使用されます(可能であれば)。 [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([アモス鳥](https://github.com/amosbird)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-5} + +- パフォーマンステ [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([akuzm](https://github.com/akuzm)) +- 外部でビルドを修正 `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([イワン](https://github.com/abyss7)) +- 共有ビルドを修正 `rdkafka` ライブラリ [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([イワン](https://github.com/abyss7)) + +## ClickHouseリリース19.11 {#clickhouse-release-19-11} + +### ClickHouseリリース19.11.13.74,2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} + +#### バグ修正 {#bug-fix-14} + +- で固定レアクラッシュ `ALTER MODIFY COLUMN` マージ/変更された部分のいずれかが空の場合(0行)に垂直マージします。 [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([アレサピン](https://github.com/alesapin)) +- の手動update `SIMDJSON`. これにより、偽のjson診断メッセージでstderrファイルが氾濫する可能性が修正されます。 [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([Alexander Kazakov](https://github.com/Akazz)) +- とのバグを修正 `mrk` mutationsのファイル拡張子 ([アレサピン](https://github.com/alesapin)) + +### ClickHouse Release19.11.12.69,2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} + +#### バグ修正 {#bug-fix-15} + +- 固定性能の劣化指標分析複雑なテンキーの大きます。 この修正 [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 分散エンジンでテーブルにデータを送信する際に、まれなSIGSEGVを回避 (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([Azat Khuzhin](https://github.com/azat)) +- 修正 `Unknown identifier` 複数の結合を使用します。 この修正 [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +### ClickHouse Release19.11.11.57,2019-09-13 {#clickhouse-release-19-11-11-57-2019-09-13} + +- カフカ空のトピックから選択するとsegfaultsの原因となる論理エラーを修正しました。 [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([イワン](https://github.com/abyss7)) +- 機能のための苦境 `АrrayEnumerateUniqRanked` paramsに空の配列があります。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([プロラー](https://github.com/proller)) + +### ClickHouse Release19.11.10.54,2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} + +#### バグ修正 {#bug-fix-16} + +- い店舗-オフセットカフカメッセージを手動できることを確約できることすべてを一度にすべての仕切り. 潜在的な重複を修正 “one consumer - many partitions” シナリオ [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([イワン](https://github.com/abyss7)) + +### ClickHouse Release19.11.9.52,2019-09-6 {#clickhouse-release-19-11-9-52-2019-09-6} + +- 改善についてはキャッシュを生成する事ができます。 [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 関数のバグを修正しました `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([プロラー](https://github.com/proller)) +- 修正 `JSONExtract` を抽出しながら `Tuple` JSONから。 [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 固定可能なデータ損失の後 `ALTER DELETE` クエリーテーブルとキース。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- 固定性能テスト。 [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 寄木細工:ブール値の列を読んで修正します。 [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正された間違った動作 `nullIf` 定数引数の関数。 [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定カフカメッセージの複製問題が通常のサーバを再起動します。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([イワン](https://github.com/abyss7)) +- 長いときに問題を修正しました `ALTER UPDATE` または `ALTER DELETE` 通常のマージを実行できない場合があります。 利用可能な十分な空きスレッドがない場合、突然変異が実行されないようにします。 [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([tavplubix](https://github.com/tavplubix)) +- 処理中のエラーを修正 “timezone” サーバー設定ファイル内。 [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- カフカのテストを修正します。 [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([イワン](https://github.com/abyss7)) + +#### セキュリティ修正 {#security-fix-3} + +- 攻撃者がZooKeeperへの書き込みアクセス権を持ち、ClickHouseが実行されているネットワークから利用可能なカスタムサーバーを実行できる場合、ClickHouseのレプリカとして機能 きものレプリカまでデータを取得すから悪意のあるレプリカで力clickhouse-サーバへの書き込みを任意のパスにファイルシステム. Yandexの情報セキュリティチームEldar Zaitovによって発見されました。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.11.8.46,2019-08-22 {#clickhouse-release-19-11-8-46-2019-08-22} + +#### バグ修正 {#bug-fix-17} + +- 修正 `ALTER TABLE ... UPDATE` テーブルのクエリ `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([アレサピン](https://github.com/alesapin)) +- タプルを持つサブクエリでin句を使用するときにnpeを修正しました。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- 古いレプリカがアライブ状態になっても、DROP PARTITIONによって削除されたデータパーツが残っている可能性がある問題を修正しました。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- CSVの解析に関する問題を修正 [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) +- システム内の固定データレース。パーツテーブルとALTERクエリ。 この修正 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定の間違ったコードに変異のありメモリが破損す アドレスの読み取りで固定segfault `0x14c0` それは同時に起こった可能性があります `DROP TABLE` と `SELECT` から `system.parts` または `system.parts_columns`. 突然変異クエリの準備における競合状態を修正しました。 によるデッドロックを修正 `OPTIMIZE` 変更のようなレプリケートされたテーブルと同時変更操作の。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.11.7.40,2019-08-14 {#clickhouse-release-19-11-7-40-2019-08-14} + +#### バグ修正 {#bug-fix-18} + +- カフカの統合は、このバージョンで修正されました。 +- 使用するときにsegfaultを修正 `arrayReduce` 定数引数の場合。 [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定 `toFloat()` 単調性。 [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) +- 有効でsegfaultを修正 `optimize_skip_unused_shards` シャーディングキーがない [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([クルティジ](https://github.com/CurtizJ)) +- の固定ロジック `arrayEnumerateUniqRanked` 機能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- MySQLハンドラから余分な冗長ロギングを削除しました。 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 間違った動作と可能なsegfaultsを修正 `topK` と `topKWeighted` 集計関数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([クルティジ](https://github.com/CurtizJ)) +- 仮想列を公開しない `system.columns` テーブル。 これは下位互換性のために必要です。 [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正のバグとメモリの割り当てのための文字列の分野での複合キーキャッシュを辞書で調べました。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([アレサピン](https://github.com/alesapin)) +- 新しいレプリカを作成するときに適応粒度を有効にするバグを修正 `Replicated*MergeTree` テーブル。 [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([アレサピン](https://github.com/alesapin)) +- 修正の無限ループ読み込み時にカフカメッセージ [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([abyss7](https://github.com/abyss7)) +- Sqlパーサーでのスタックオーバーフローによるサーバークラッシュとスタックオーバーフロ `Merge` と `Distributed` テーブル [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定Gorillaエンコードエラーの小型dnaの塩基配列を決定した。 [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Enmk](https://github.com/Enmk)) + +#### 改善 {#improvement-5} + +- ユーザーに上書きを許可する `poll_interval` と `idle_connection_timeout` 接続時の設定。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.11.5.28,2019-08-05 {#clickhouse-release-19-11-5-28-2019-08-05} + +#### バグ修正 {#bug-fix-19} + +- 固定の可能性を掛けクエリの場合はサーバが過負荷状態で運転されています。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- YandexConsistentHash関数のFPEを修正しました。 この修正 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- の変換のバグを修正しました `LowCardinality` タイプ `AggregateFunctionFactory`. この修正 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- の解析を修正 `bool` からの設定 `true` と `false` 設定ファイル内の文字列。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([アレサピン](https://github.com/alesapin)) +- 固定珍しいバグと互換性のないストリームヘッダをクエリー `Distributed` テーブル `MergeTree` テーブルの一部 `WHERE` 移動先 `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([アレサピン](https://github.com/alesapin)) +- 符号付き型から符号なし型への整数除算でのオーバーフローを修正。 この修正 [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 下位互換性のない変更 {#backward-incompatible-change-5} + +- `Kafka` まだ壊れてる + +### ClickHouse Release19.11.4.24,2019-08-01 {#clickhouse-release-19-11-4-24-2019-08-01} + +#### バグ修正 {#bug-fix-20} + +- 適応粒度で二次インデックスマークを書くとバグを修正しました。 [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([アレサピン](https://github.com/alesapin)) +- 修正 `WITH ROLLUP` と `WITH CUBE` の修飾子 `GROUP BY` 二レベルの集計を使って。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 固定ハングイン `JSONExtractRaw` 機能。 固定 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ExternalLoader::reloadOutdated()でsegfaultを修正しました。 [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 固定の場合はサーバが切れることがあり聞くソケットがセットのリスクマネジメントの継続け残ります。 ツつサツつ、ツつ"ツつ、ツつアツづツづツつキツ。 サーバーがエラーを返すことがあります `bad_function_call` 残りのクエリの場合。 [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ODBC、MySQL、ClickHouseおよびHTTP経由で外部辞書の初期読み込みのための更新フィールドに役に立たないと間違った条件を修正しました。 この修正 [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- キャストの無関係な例外を修正しました `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- の非決定的な結果を修正 “uniq” 極端なまれなケースでの集計関数。 このバグはすべてのClickHouseバージョンに存在しました。 [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 私たちは関数に少し高すぎるcidrを設定するとSegfault `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- 固定小さなメモリリークがサーバに捨てる多くの例外から多くの異なるコンテキストを共有します。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定の状態で消費者も一時停止前の契約とな再開します。 [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([イワン](https://github.com/abyss7) 注このカフカを砕このバージョン。 +- エラーで完了した前回の読み取り操作からKafkaデータバッファをクリアする [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([ニコライ](https://github.com/bopohaa) 注このカフカを砕このバージョン。 +- 以来 `StorageMergeTree::background_task_handle` で初期化される。 `startup()` その `MergeTreeBlockOutputStream::write()` 初期化の前に使用しようとする可能性があります。 すぐチェックインの場合は初期化されます。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([イワン](https://github.com/abyss7)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-6} + +- 追加された公式 `rpm` パッケージ。 [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([プロラー](https://github.com/proller)) ([アレサピン](https://github.com/alesapin)) +- ビルド機能の追加 `.rpm` と `.tgz` パッケージ `packager` スクリプト [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([アレサピン](https://github.com/alesapin)) +- の修正 “Arcadia” ビルドシステム。 [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([プロラー](https://github.com/proller)) + +#### 下位互換性のない変更 {#backward-incompatible-change-6} + +- `Kafka` このバージョンでは壊れている。 + +### ClickHouse Release19.11.3.11,2019-07-18 {#clickhouse-release-19-11-3-11-2019-07-18} + +#### 新機能 {#new-feature-6} + +- るためのサポートを追加しました用意します。 [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([Alexander](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `DoubleDelta` と `Gorilla` 列コーデック [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 追加 `os_thread_priority` 制御することを割り当てる設定 “nice” 動的スケジューリング優先度を調整するためにOSが使用するクエリ処理スレッドの値。 それは必要です `CAP_SYS_NICE` 働く機能。 これは [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 実装 `_topic`, `_offset`, `_key` カフカエンジンの列 [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([イワン](https://github.com/abyss7) 注このカフカを砕このバージョン。 +- 集計関数コンビネータの追加 `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([hcz](https://github.com/hczhcz)) +- 集計関数 `groupArrayMovingSum(win_size)(x)` と `groupArrayMovingAvg(win_size)(x)` ウィンドウサイズの制限の有無にかかわらず、移動合計/平均を計算します。 [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([inv2004](https://github.com/inv2004)) +- Synonimを追加 `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([hcz](https://github.com/hczhcz)) +- インターゲートH3機能 `geoToH3` ユーバーから。 [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([レメン-イヴァン](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### バグ修正 {#bug-fix-21} + +- 非同期updateでDNSキャッシュを実装します。 個別のスレッドで解決すべてのホストを更新DNSキャッシュが期間(設定 `dns_cache_update_period`). ホストのipが頻繁に変化するときに役立ちます。 [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([アントン-ポポフ](https://github.com/CurtizJ)) +- でsegfaultを修正 `Delta` 32ビットサイズ未満の値を持つ列に影響を与えるコーデック。 バグを修正ledランダムメモリが破損す [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([アレサピン](https://github.com/alesapin)) +- TTLマージでsegfaultを修正ブロック内の非物理列と。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([アントン-ポポフ](https://github.com/CurtizJ)) +- パーツのチェックで珍しいバグを修正 `LowCardinality` 列。 以前は `checkDataPart` 常に失敗します `LowCardinality` 列。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([アレサピン](https://github.com/alesapin)) +- 回避掛けに接続した場合、サーバスレッドプールを行います。 それはからの接続にとって重要です `remote` 長い接続タイムアウトがある場合、レプリカのないシャードへの表関数または接続。 この修正 [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 定数引数のサポート `evalMLModel` 機能。 この修正 [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ClickHouseがデフォルトのタイムゾーンを `UCT` 代わりに `UTC`. この修正 [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定バッファアンダーフロー `visitParamExtractRaw`. この修正 [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 現在配布中 `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` クエリはリーダーレプリカで直接実行されます。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([アレサピン](https://github.com/alesapin)) +- 修正 `coalesce` のために `ColumnConst` と `ColumnNullable` +関連する変更。 [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- を修正 `ReadBufferFromKafkaConsumer` 新しいメッセージを読み続けるように `commit()` 前に失速したとしても [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([イワン](https://github.com/abyss7)) +- 修正 `FULL` と `RIGHT` 参加時の結果参加 `Nullable` 右のテーブルのキー。 [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 優先度の低いクエリの無限のスリープの可能性のある修正。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- いくつかのクエリがquery\_logに表示されない原因となる競合状態を修正しました `SYSTEM FLUSH LOGS` クエリ。 [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 固定 `heap-use-after-free` 既に削除された複写機オブジェクトを使用しようとする時計によって引き起こされるClusterCopierのASan警告。 [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 間違って修正 `StringRef` 一部の実装によって返されるポインタ `IColumn::deserializeAndInsertFromArena`. このバグは単体テストのみに影響しました。 [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 同じ名前の列をマスクするソースおよび中間配列結合列を防止します。 [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- Mysqlスタイルの識別子を引用してMySQLエンジンにクエリを挿入し、選択を修正しました。 [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([冬張](https://github.com/zhang2014)) +- さて `CHECK TABLE` クエリはMergeTreeエンジンファミリで動作できます。 を返しますチェック状態とメッセージの場合の各部分(またはファイルの場合simplierエンジン) また、壊れた部分のフェッチのバグを修正しました。 [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([アレサピン](https://github.com/alesapin)) +- SPLIT\_SHARED\_LIBRARIESランタイムを修正 [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([ダニラ-クテニン](https://github.com/danlark1)) +- 固定時のタイムゾーンの初期化 `/etc/localtime` のような相対的なシンボリックリンク `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- clickhouse-複写機:シャットダウン時に無料で使用した後に修正 [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([プロラー](https://github.com/proller)) +- 更新 `simdjson`. ゼロバイトのいくつかの無効なJSONsが正常に解析する問題を修正しました。 [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- SystemLogsのシャットダウンを修正 [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([アントン-ポポフ](https://github.com/CurtizJ)) +- Invalidate\_queryの条件が辞書に依存する場合のハングを修正しました。 [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) + +#### 改善 {#improvement-6} + +- クラスター構成で解決不可能なアドレスを許可します。 これらは使用できないと見なされ、接続の試行ごとに解決が試みられます。 これはKubernetesにとって特に便利です。 この修正 [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- アイドル状態のTCP接続を閉じます(既定では一時間のタイムアウト)。 これは、すべてのサーバーに複数の分散テーブルがある大規模なクラスターでは、すべてのサーバーが他のすべてのサーバーとの接続プールを保持でき、クエリの同時実 この修正 [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- より良い品質の `topK` 機能。 新しい要素の重みが大きい場合、最後の要素を削除するようにSavingSpace setの動作を変更しました。 [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- URLの機能と作業領域は今では不完全なUrlなスキーム [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([アレサピン](https://github.com/alesapin)) +- に追加されたチェックサム `system.parts_columns` テーブル。 [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([ニキータ-ミハイロフ](https://github.com/nikitamikhaylov)) +- 追加 `Enum` のためのsynonimとしてのデータ型 `Enum8` または `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([dimarub2000](https://github.com/dimarub2000)) +- のための完全なビット転置の変形 `T64` コーデック。 がより良い圧縮 `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 条件 `startsWith` 機能するまでに使用その有効なタイプを利用します。 この修正 [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) と [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([dimarub2000](https://github.com/dimarub2000)) +- 使用を許可する `clickhouse-copier` クロス-複製クラスタトポロジーを許可する空のデータベースの名前です。 [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([nvartolomei](https://github.com/nvartolomei)) +- 使用 `UTC` システムのデフォルトのタイムゾーンとして `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` サーバーまたはクライアントが起動を拒否しました。 [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 関数内の浮動小数点引数のサポートを返しました `quantileTiming` 下位互換性のため。 [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- エラーメッセージに列がないテーブルを表示します。 [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([イワン](https://github.com/abyss7)) +- さまざまなユーザーが同じquery\_idでクエリを実行できない [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([プロラー](https://github.com/proller)) +- より強固なコードの送信メトリクスをグラファイトを表してい それは長い倍数の間に働きます `RENAME TABLE` 作戦だ [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- よりエラーメッセージが表示されますのでThreadPoolできない予定、タスクを実行します。 この修正 [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- より直感的にngramsearchを反転する [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([ダニラ-クテニン](https://github.com/danlark1)) +- HDFS engine builderでのユーザー解析の追加 [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([akonyaev90](https://github.com/akonyaev90)) +- デフォルト値の更新 `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([アルテム-コノヴァロフ](https://github.com/izebit)) +- 廃止された設定の概念を追加しました。 廃止された設定 `allow_experimental_low_cardinality_type` 効果無しで使用することができます。 [0f15c01c6802f7ce1a1494c12c846be8c98944cd](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov) + +#### 性能向上 {#performance-improvement-4} + +- 増加数の河川から選択するとMergeテーブルにより均一に分布す。 設定を追加 `max_streams_multiplier_for_merge_tables`. この修正 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-7} + +- Clickhouseの異なるバージョンとのクライアントサーバーの相互作用の下位互換性テストを追加します。 [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([アレサピン](https://github.com/alesapin)) +- テスト対象の情報を毎にコミットを引きます。 [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([アレサピン](https://github.com/alesapin)) +- アドレスsanitizerと協力してカスタムアロケータをサポート (`Arena` と `ArenaWithFreeLists`)のよりよいデバッグのため “use-after-free” エラー [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([akuzm](https://github.com/akuzm)) +- に切り替える [LLVM libunwindの実装](https://github.com/llvm-mirror/libunwind) C++例外処理およびスタックトレース印刷の場合 [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([ニキータ-ラプコフ](https://github.com/laplab)) +- からさらに二つの警告を追加-Weverything [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- メモリサニタイザーでClickHouseを構築することができます。 [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- についての固定ubsanレポート `bitTest` fuzzテストの機能。 [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Docker:認証を必要とするClickHouseインスタンスを初期化する可能性を追加しました。 [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([コルビャコフ-アンドレイ](https://github.com/shurshun)) +- Librdkafkaをバージョン1.1.0に更新する [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([イワン](https://github.com/abyss7)) +- 追加グローバルタイムアウトのための統合の試験を無効にし試験ます。 [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([アレサピン](https://github.com/alesapin)) +- いくつかのThreadSanitizerエラーを修正しました。 [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([akuzm](https://github.com/akuzm)) +- その `--no-undefined` オプション力、リンカーをチェックすべての外部の名の存在をリンク 分割ビルドモードでライブラリ間の実際の依存関係を追跡することは非常に便利です。 [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([イワン](https://github.com/abyss7)) +- のための追加された性能試験 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Gcc-7との互換性を修正しました。 [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Gcc-9のサポートが追加されました。 この修正 [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Libunwindが正しくリンクされていない場合のエラーを修正。 [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- PVS-Studioによって発見されたいくつかの警告を修正しました。 [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加された初期サポート `clang-tidy` 静的な検光子。 [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- BSD/Linuxエンディアンマクロの変換( ‘be64toh’ と ‘htobe64’)に相当する。 [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([フー-チェン](https://github.com/fredchenbj)) +- 改善された統合テストガイド。 [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- Macosx+gcc9でのビルドの修正 [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([フィリモノフ](https://github.com/filimonov)) +- AggreAGte-\>aggregateという難しいタイプミスを修正しました。 [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([akuzm](https://github.com/akuzm)) +- Freebsdのビルドを修正 [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([プロラー](https://github.com/proller)) +- 追加リンク実験YouTubeチャンネルサイト [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([イヴァン-ブリンコフ](https://github.com/blinkov)) +- CMake:カバレッジフラグのオプションを追加:WITH\_COVERAGE [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([プロラー](https://github.com/proller)) +- インラインPODArrayの初期サイズを修正しました。 [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([akuzm](https://github.com/akuzm)) +- clickhouse-サーバー.postinst:centos6のos検出を修正 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([プロラー](https://github.com/proller)) +- Arch linuxパッケージの生成を追加。 [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([ウラジーミル-チェボタレフ](https://github.com/excitoon)) +- 共通/設定を分割します。h by libs(dbms) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([プロラー](https://github.com/proller)) +- の修正 “Arcadia” ムの構築 [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([プロラー](https://github.com/proller)) +- 型破りなビルドの修正(gcc9、サブモジュールなし) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([プロラー](https://github.com/proller)) +- バグが発生しやすいことが判明したため、unalignedstoreで明示的な型を必要とする [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([akuzm](https://github.com/akuzm)) +- MacOSのビルドを修正 [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([フィリモノフ](https://github.com/filimonov)) +- より大きなデータセットを持つ新しいJIT機能に関する性能テスト [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- Stress testでのステートフルテストの実行 [12693e568722f11e19859742f56428455501fd2a](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([アレサピン](https://github.com/alesapin)) + +#### 下位互換性のない変更 {#backward-incompatible-change-7} + +- `Kafka` このバージョンでは壊れている。 +- 有効にする `adaptive_index_granularity` =新しいのためのデフォルトで10MB `MergeTree` テーブル バージョン19.11+で新しいMergeTreeテーブルを作成した場合、19.6より前のバージョンへのダウングレードは不可能になります。 [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([アレサピン](https://github.com/alesapin)) +- Yandexのによって使用された古い文書化されていない埋め込み辞書を削除しました。メトリカ 機能 `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` 利用できなくなりました。 ご利用の場合これらの機能は、メールclickhouse-feedback@yandex-team.com. 注:最後の瞬間にしてくれました。 [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +## ClickHouseリリース19.10 {#clickhouse-release-19-10} + +### ClickHouseリリース19.10.1.5,2019-07-12 {#clickhouse-release-19-10-1-5-2019-07-12} + +#### 新機能 {#new-feature-7} + +- 新しい列コーデックの追加: `T64`. (U)IntX/EnumX/Data(Time)/DecimalX列用に作成されました。 これは、一定または小さな範囲の値を持つ列に適しているはずです。 コーデック自体は、再圧縮せずにデータ型を拡大または縮小できます。 [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- データベースエンジ `MySQL` できる全てのテーブルをリモートMySQLサーバー [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([冬張](https://github.com/zhang2014)) +- `bitmapContains` 実装。 それはより速い2xです `bitmapHasAny` の場合、二つのビットマップ一要素となります。 [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([Zhichang Yu](https://github.com/yuzhichang)) +- のサポート `crc32` 関数(MySQLやPHPと同じように動作します)。 ハッシュ関数が必要な場合は使用しないでください。 [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([レメン-イヴァン](https://github.com/BHYCHIK)) +- 実装 `SYSTEM START/STOP DISTRIBUTED SENDS` 非同期挿入を制御するクエリ `Distributed` テーブル [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([冬張](https://github.com/zhang2014)) + +#### バグ修正 {#bug-fix-22} + +- 無視するクエリの実行を制限およびmaxのパーツのサイズの合併に制限が実行中の突然変異. [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 通常のブロックの重複除外(非常にまれ)と重複ブロックの挿入(より頻繁に)につながる可能性のあるバグを修正しました。 [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([アレサピン](https://github.com/alesapin)) +- 機能の修正 `arrayEnumerateUniqRanked` 空の配列を持つ引数の場合 [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([プロラー](https://github.com/proller)) +- な購読カフカ題なく意思をポーリングメッセージ. [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([イワン](https://github.com/abyss7)) +- 設定を行う `join_use_nulls` Nullable内に入ることができない型に対しては効果を得ない [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([Olga Khvostikova](https://github.com/stavrolia)) +- 固定 `Incorrect size of index granularity` エラー [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([コラクスター](https://github.com/coraxster)) +- 小数点変換オーバーフローに浮動小数点を修正 [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([コラクスター](https://github.com/coraxster)) +- フラッシュバッファ `WriteBufferFromHDFS`デストラクタと呼ばれる。 これは書き込みを修正する `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([新東鵬](https://github.com/eejoin)) + +#### 改善 {#improvement-7} + +- 空のセルを扱う `CSV` 設定時のデフォルト値として `input_format_defaults_for_omitted_fields` 有効です。 [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) +- 外部辞書の非ブロック読み込み。 [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- ネットワークタイムアウトできるダイナミックな変化のための既存の接続に従って設定します。 [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([コンスタンチン-ポドシュモク](https://github.com/podshumok)) +- を使用して “public\_suffix\_list” 関数の場合 `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. で用いたハッシュテーブルの生成 `gperf` ファイルから生成されたリスト:https://publicsuffix.org/list/public\_suffix\_list.dat.(たとえば、ドメインを認識します `ac.uk` 非重要として)。 [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- 採用 `IPv6` システムテーブルのデータ型。 `system.processes` と `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- MySQL互換プロトコルとの接続にセッションを使用する。 \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([ユーリー-バラノフ](https://github.com/yurriy)) +- よりサポート `ALTER` クエリ `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([スンディリ](https://github.com/sundy-li)) +- サポート `` セクション `clickhouse-local` 設定ファイル。 [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([プロラー](https://github.com/proller)) +- クエリの実行を許可する `remote` テーブル関数 `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([プロラー](https://github.com/proller)) + +#### 性能向上 {#performance-improvement-5} + +- MergeTree列の最後に最後のマークを書き込む可能性を追加します。 これを避ける無駄を読み込みのためのキーのテーブルデータです。 適応インデックスの粒度が使用されている場合にのみ有効になります。 [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([アレサピン](https://github.com/alesapin)) +- 非常に遅いファイルシステムでのMergeTreeテーブルのパフォーマンスの向上 `stat` シスコール [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定性能の劣化からの読み出しMergeTreeテーブルで導入されたバージョン19.6. 修正\#5631. [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-8} + +- 実装 `TestKeeper` テストに使用されるZooKeeperインタフェースの実装として [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) ([レブシュキン-アレクセイ](https://github.com/alexey-milovidov)) +- これからは `.sql` 試験走行ができるによって切り離されたサーバを並列には、ランダムなデータベースです。 ることができると考えて、追加試験とカスタムサーバー構成は、必ず異なる試験に影響しません。 [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([イワン](https://github.com/abyss7)) +- 削除 `` と `` 性能テストから [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([Olga Khvostikova](https://github.com/stavrolia)) +- 固定 “select\_format” 性能試験のための `Pretty` 形式 [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +## ClickHouseリリース19.9 {#clickhouse-release-19-9} + +### ClickHouseリリース19.9.3.31,2019-07-05 {#clickhouse-release-19-9-3-31-2019-07-05} + +#### バグ修正 {#bug-fix-23} + +- 32ビットサイズ未満の値を持つ列に影響を与えるデルタコーデックでsegfaultを修正しました。 バグを修正ledランダムメモリが破損す [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([アレサピン](https://github.com/alesapin)) +- 低カーディナリティカラムでパーツをチェックする際のまれなバグを修正。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([アレサピン](https://github.com/alesapin)) +- TTLマージでsegfaultを修正ブロック内の非物理列と。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 優先度の低いクエリの潜在的な無限のスリープを修正しました。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ClickHouseがUTCではなくUCTとして既定のタイムゾーンを決定する方法を修正しました。 [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- のを修正した。約の実行の分散DROP/ALTER/QUICK/最適化クラスターに関するお問い合わせフォロワレプリカの前にリーダーレプリカ. これで、リーダーレプリカで直接実行されます。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([アレサピン](https://github.com/alesapin)) +- 固定レースの条件を回避することが可能となり、一部のクエリーのような画面が、表示されないでquery\_logぐにシステムのフラッシュログを返します。 [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 追加の欠落支援のための定数の引数 `evalMLModel` 機能。 [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.9.2.4,2019-06-24 {#clickhouse-release-19-9-2-4-2019-06-24} + +#### 新機能 {#new-feature-8} + +- 冷凍部品に関する情報を印刷する `system.parts` テーブル。 [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([プロラー](https://github.com/proller)) +- お客様のパスワードをclickhouse-クライアント開始tty名が設定されていない場合には引数 [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([プロラー](https://github.com/proller)) +- 実装 `dictGet` と `dictGetOrDefault` Decimal型の関数。 [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 改善 {#improvement-8} + +- Debian init:サービス停止タイムアウトの追加 [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([プロラー](https://github.com/proller)) +- 追加の設定により禁止されるデフォルトテーブルの作成と怪しいタイプLowCardinality [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([Olga Khvostikova](https://github.com/stavrolia)) +- 回帰機能を返却時の重量モデルとして用いられていない状態で機能 `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([Quid37](https://github.com/Quid37)) +- 回帰方法の名前を変更し、改善します。 [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([Quid37](https://github.com/Quid37)) +- 明のインタフェースを文字列が揃. [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([ダニラ-クテニン](https://github.com/danlark1)) + +#### バグ修正 {#bug-fix-24} + +- カフカで潜在的なデータ損失を修正 [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([イワン](https://github.com/abyss7)) +- で潜在的な無限ループを修正 `PrettySpace` 列がゼロで呼び出された場合の書式 [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([Olga Khvostikova](https://github.com/stavrolia)) +- 線形モデルの固定UInt32オーバーフローバグ。 非constモデル引数のeval MLモデルを許可します。 [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- `ALTER TABLE ... DROP INDEX IF EXISTS ...` なる例外を提供される場合指数が存在しない [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([グレブ-ノビコフ](https://github.com/NanoBjorn)) +- でsegfaultを修正 `bitmapHasAny` スカラーサブクエリで [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) +- 固定の場合にはエラー複製を接続プールなリトライを解決するホストでも、DNSキャッシュした。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([アレサピン](https://github.com/alesapin)) +- 固定 `ALTER ... MODIFY TTL` 複製されたマージツリーです [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([アントン-ポポフ](https://github.com/CurtizJ)) +- マテリアライズされた列で分散テーブルに挿入を修正 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) +- Fix悪allocが切り詰め加入の保管 [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([Tシーズン](https://github.com/TCeason)) +- に最近のバージョンのパッケージtzdata一部のファイルsymlinksます。 現在の仕組みを検出するデフォルトのタイムゾーンの故障が考えられ、間違った名前に一部のタイムゾーン. これで、少なくともタイムゾーン名を指定した場合は、TZの内容に強制します。 [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([イワン](https://github.com/abyss7)) +- 合計で一定の針が少なくとも16KBの長さである場合、MultiVolnitskyサーチャーでいくつかの非常にまれなケースを修正します。 このアルゴリズムは、以前の結果を見逃したり上書きしたりすることがあります。 `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([ダニラ-クテニン](https://github.com/danlark1)) +- ExternalData要求の設定でClickHouse設定を使用できなかった場合の問題を修正しました。 また、今のところ、設定 `date_time_input_format` と `low_cardinality_allow_in_native_format` 名前のあいまいさのために使用することはできません(外部データではテーブル形式として解釈でき、クエリでは設定にすることができます)。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([ダニラ-クテニン](https://github.com/danlark1)) +- パーツがZOOKEEPERから落とさずにFSからのみ取り除かれたバグを修正しました。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([アレサピン](https://github.com/alesapin)) +- MySQLプロトコルか [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- DDLクエリ処理中にZNONODEをスキップ [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) +- ミックスを修正 `UNION ALL` 結果列タイプ。 があった場合に矛盾したデータとカラムの種類によ列あります。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 間違った整数に対して例外をスローする `dictGetT` クラッシュの代わりに関数。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- ハッシュ化されたディクショナリのelement\_countとload\_factorが間違っているのを修正 `system.dictionaries` テーブル。 [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-9} + +- 固定ビルドなし `Brotli` HTTP圧縮サポート (`ENABLE_BROTLI=OFF` cmake変数)。 [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([アントン-ユジャニノフ](https://github.com/citrin)) +- 轟音を含める。轟音/轟音としてh。h [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([オリヴェイ-デシュ](https://github.com/orivej)) +- Hyperscanでgcc9の警告を修正しました(#ラインディレクティブは悪です!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([ダニラ-クテニン](https://github.com/danlark1)) +- 全ての場合の警告表gcc-9. いくつかのcontribの問題を修正します。 Gcc9ICEを修正し、bugzillaに提出してください。 [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([ダニラ-クテニン](https://github.com/danlark1)) +- Lldとのリンクを修正 [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 辞書で使用されていない特殊化を削除する [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 向上性能試験のためのフォーマットと構文解析表の異なる種類のファイル [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([Olga Khvostikova](https://github.com/stavrolia)) +- 並列テスト実行の修正 [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([プロラー](https://github.com/proller)) +- Docker:clickhouse-testからconfigsを使用する [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([プロラー](https://github.com/proller)) +- FreeBSD用のコンパイルを修正 [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([プロラー](https://github.com/proller)) +- 更にブースト1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([プロラー](https://github.com/proller)) +- サブモジュールとしてビルドclickhouseを修正 [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([プロラー](https://github.com/proller)) +- JSONExtractパフォーマンステストの改善 [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) + +## ClickHouseリリース19.8 {#clickhouse-release-19-8} + +### ClickHouse Release19.8.3.8,2019-06-11 {#clickhouse-release-19-8-3-8-2019-06-11} + +#### 新しい機能 {#new-features} + +- JSONで動作する関数を追加しました [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([hcz](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 多くの言語に存在するbasename関数と同様の動作を持つ関数basenameを追加します (`os.path.basename` pythonでは, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- 追加 `LIMIT n, m BY` または `LIMIT m OFFSET n BY` LIMIT BY句にnのオフセットを設定する構文。 [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 新しいデータ型を追加 `SimpleAggregateFunction` これにより、軽い集計を持つ列を `AggregatingMergeTree`. これは、次のような単純な関数でのみ使用できます `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([ボリス-グランヴォー](https://github.com/bgranvea)) +- 関数内の非定数引数のサポートが追加されました `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([ダニラ-クテニン](https://github.com/danlark1)) +- 追加された機能 `skewPop`, `skewSamp`, `kurtPop` と `kurtSamp` シーケンスの歪度、サンプルの歪度、尖度、およびサンプルの尖度をそれぞれ計算します。 [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([hcz](https://github.com/hczhcz)) +- サポートの名前変更の操作 `MaterializeView` ストレージ。 [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- MySQL clientを使用してClickHouseに接続できるサーバーを追加しました。 [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([ユーリー-バラノフ](https://github.com/yurriy)) +- 追加 `toDecimal*OrZero` と `toDecimal*OrNull` 機能。 [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 関数の小数点型のサポート: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted`,medianExactWeighted. [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 追加 `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([ダニラ-クテニン](https://github.com/danlark1)) +- 追加 `format` 機能。 引数にリストされた文字列で定数パターン(簡略化されたPython形式パターン)を書式設定します。 [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([ダニラ-クテニン](https://github.com/danlark1)) +- 追加 `system.detached_parts` の分離された部分に関する情報を含む表 `MergeTree` テーブル [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([akuzm](https://github.com/akuzm)) +- 追加 `ngramSearch` 針と干し草の山の非対称差を計算する関数。 [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([ダニラ-クテニン](https://github.com/danlark1)) +- 集計関数インタフェースを用いた基本的な機械学習法(確率的線形回帰とロジスティック回帰)の実装。 モデルの重みを更新するための異なる戦略(単純勾配降下法、運動量の方法、ネステロフ法)を持っています。 にも対応-ミニバッチのカスタムサイズです。 [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([Quid37](https://github.com/Quid37)) +- の実装 `geohashEncode` と `geohashDecode` 機能。 [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 集計関数を追加 `timeSeriesGroupSum` る累積の異なる時系列のサンプルのタイムスタンプなアライメントを実施します。 これは、二つのサンプルタイムスタンプ間の線形補間を使用して、一緒に時系列を合計します。 集計関数を追加 `timeSeriesGroupRateSum`、時系列のレートを計算し、その後、一緒にレートを合計します。 [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([ヤンクアン-リュウ](https://github.com/LiuYangkuan)) +- 追加された機能 `IPv4CIDRtoIPv4Range` と `IPv6CIDRtoIPv6Range` CIDRを使用して、サブネット内のIPの下限と上限を計算します。 [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) +- 有効な設定でHTTPを使用してクエリを送信するときに、X-ClickHouse-Summaryヘッダーを追加します `send_progress_in_http_headers`. X-ClickHouse-Progressの通常の情報と、クエリに挿入された行数やバイト数などの追加情報を返します。 [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([ギヨーム-タッセリー](https://github.com/YiuRULE)) + +#### 改善 {#improvements} + +- 追加 `max_parts_in_total` パーティションキー\#5166の安全でない指定を防ぐMergeTreeファミリのテーブル(デフォルト:100 000)の設定。 [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `clickhouse-obfuscator`:初期シードと列の位置ではなく列名を組み合わせて、個々の列のシードを導出します。 ことを目的として変換するデータセットに複数の関連するテーブル、テーブルはJOINableに設定します。 [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加された機能 `JSONExtractRaw`, `JSONExtractKeyAndValues`. 名前変更された関数 `jsonExtract` に `JSONExtract`. 何かがうまくいかないとき、これらの関数は対応する値を返します。 `NULL`. 変更された関数 `JSONExtract` これで、最後のパラメータから戻り値の型を取得し、nullablesを注入しません。 AVX2命令が利用できない場合にRapidJSONへのフォールバックを実装しました。 Simdjsonライブラリを新しいバージョンに更新しました。 [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- さて `if` と `multiIf` 関数は条件に依存しません `Nullable` しかし、sqlの互換性のためにブランチに依存しています。 [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([ジャン-ウー](https://github.com/janplus)) +- `In` 述語が生成されます `Null` 結果から `Null` のような入力 `Equal` 機能。 [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([ジャン-ウー](https://github.com/janplus)) +- カフカからの行数(flush\_interval/poll\_timeout)ごとに制限時間をチェックします。 これにより、カフカの消費者からの読み取りをより頻繁に中断し、トップレベルのストリームの時間制限を確認することができます [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([イワン](https://github.com/abyss7)) +- バンドルされたSASLとrdkafkaをリンク. SASLスクラム認証の使用を許可する必要があります [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([イワン](https://github.com/abyss7)) +- すべての結合のRowRefListのバッチバージョン。 [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- clickhouse-server:より有益なlistenエラーメッセージ。 [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([プロラー](https://github.com/proller)) +- 機能のためのclickhouse-copierのサポート辞書 `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([プロラー](https://github.com/proller)) +- 新しい設定を追加 `kafka_commit_every_batch` カフカコミット政策を規制する。 + メッセージのすべてのバッチが処理された後、またはブロック全体がストレージに書き込まれた後です。 このトレードオフの関係を失うメッセージやみ表示することを目的としていま倍もいる。 [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([イワン](https://github.com/abyss7)) +- 作る `windowFunnel` 他の符号なし整数型をサポートする。 [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([スンディリ](https://github.com/sundy-li)) +- 仮想列のシャドウを許可する `_table` マージエンジンで。 [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([イワン](https://github.com/abyss7)) +- 作る `sequenceMatch` 集計機能の支援その他の符号なし整数型 [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([スンディリ](https://github.com/sundy-li)) +- より良いエラーメッセージの場合はチェックサムミスマッチは一によるものと考えられるハードウェアです。 [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- チェックすると配下のテーブル支援のためのサンプリング `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([イワン](https://github.com/abyss7)) +- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- MySQLワイヤプロトコルの改善。 形式の名前をMySQLWireに変更しました。 RAIIを使ってRSA\_freeを呼び出す。 コンテキ [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([ユーリー-バラノフ](https://github.com/yurriy)) +- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([プロラー](https://github.com/proller)) +- 分散テーブルへの非同期挿入のクエリ設定を尊重します。 [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([Tシーズン](https://github.com/TCeason)) +- 名前変更された関数 `leastSqr` に `simpleLinearRegression`, `LinearRegression` に `linearRegression`, `LogisticRegression` に `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) + +#### 性能の向上 {#performance-improvements} + +- ALTER MODIFY queryで、複製されていないMergeTreeテーブルの一部の処理を並列化します。 [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([イヴァン-クシュ](https://github.com/IvanKush)) +- 正規表現の抽出における最適化。 [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([ダニラ-クテニン](https://github.com/danlark1)) +- Join onセクションでのみ使用されている場合は、右結合キー列をjoin resultに追加しないでください。 [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 最初の空の応答の後、Kafkaバッファをフリーズします。 それは多数の呼出しをの避けます `ReadBuffer::next()` いくつかの行解析ストリームの空の結果の場合。 [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([イワン](https://github.com/abyss7)) +- `concat` 複数の引数に対する関数の最適化。 [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([ダニラ-クテニン](https://github.com/danlark1)) +- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- LZ4の実装をリファレンスワンでアップグレードして、解凍を高速化します。 [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([ダニラ-クテニン](https://github.com/danlark1)) +- MSD基数ソート(kxsortに基づく)、および部分ソートを実装しました。 [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([エフゲニー-プラウダ](https://github.com/kvinty)) + +#### バグ修正 {#bug-fixes} + +- 結合でプッシュが必要な列を修正 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([冬張](https://github.com/zhang2014)) +- ClickHouseがsystemdによって実行されているときに、コマンドを修正しました `sudo service clickhouse-server forcerestart` 期待通りに動作していませんでした。 [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([プロラー](https://github.com/proller)) +- DataPartsExchangeのhttpエラーコードを修正しました(9009ポートのinterserver httpサーバーは常にエラーであってもコード200を返しました)。 [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([プロラー](https://github.com/proller)) +- MAX\_SMALL\_STRING\_SIZEより長い文字列のSimpleAggregateFunctionを修正 [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([Azat Khuzhin](https://github.com/azat)) +- エラーを修正 `Decimal` に `Nullable(Decimal)` inでの変換。 (異なるスケールを含む)小数点変換への他の小数をサポート。 [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 誤った計算につながるsimdjsonライブラリ内の固定FPU clobbering `uniqHLL` と `uniqCombined` 集計関数と数学関数のような `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- JSON関数でのconst/nonconstの混合ケースの処理を修正しました。 [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 修正 `retention` 機能。 これで、データ行で満たすすべての条件がデータ状態に追加されます。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) +- 結果の種類を修正 `quantileExact` 小数で。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 文書 {#documentation} + +- ドキュメントの翻訳 `CollapsingMergeTree` 中国語に。 [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) +- 翻訳一部のアンダーグラウンドテーブルエンジン。 + [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) + [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) + ([決してリー](https://github.com/neverlee)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements} + +- ありそうな使用後の無料を示すいくつかのサニタイザーレポートを修正します。[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([イワン](https://github.com/abyss7)) +- 移動性能試験の個別のディレクトリが便利です。 [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正誤性能試験までを実施。 [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([アレサピン](https://github.com/alesapin)) +- 追加ツールをチェックサムを計算によるビット切り替えデバッグハードウェアます。 [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- くランナーのスクリプトをより使用できます。 [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([フィリモノフ](https://github.com/filimonov)) +- 追加小さな命令をどう書き込み能力を発揮する。 [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([アレサピン](https://github.com/alesapin)) +- パフォーマンステストでのクエリの作成、入力、削除で置換を行う機能を追加 [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([Olga Khvostikova](https://github.com/stavrolia)) + +## ClickHouseリリース19.7 {#clickhouse-release-19-7} + +### ClickHouseリリース19.7.5.29,2019-07-05 {#clickhouse-release-19-7-5-29-2019-07-05} + +#### バグ修正 {#bug-fix-25} + +- 固定能の回帰一部のクエリを処理するクラウドの場合。 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([冬張](https://github.com/zhang2014)) + +### ClickHouseリリース19.7.5.27,2019-06-09 {#clickhouse-release-19-7-5-27-2019-06-09} + +#### 新しい機能 {#new-features-1} + +- ビットマップ関連の機能を追加 `bitmapHasAny` と `bitmapHasAll` 類似する `hasAny` と `hasAll` 配列の関数。 [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([セルジ-ウラジキン](https://github.com/svladykin)) + +#### バグ修正 {#bug-fixes-1} + +- Segfaultをオンに修正 `minmax` Null値のインデックス。 [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- すべての入力列を必要な出力に応じてLIMITにマークします。 それは修正します ‘Not found column’ 一部の分散クエリでエラー。 [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([コンスタンティン-S-パン](https://github.com/kvap)) +- 修正 “Column ‘0’ already exists” エラー `SELECT .. PREWHERE` デフォルトの列 [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([プロラー](https://github.com/proller)) +- 修正 `ALTER MODIFY TTL` クエリオン `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([アントン-ポポフ](https://github.com/CurtizJ)) +- なクラッシュサーバの場合カフカの消費者が開始されます。 [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([イワン](https://github.com/abyss7)) +- 固定ビットマップ機能を誤った結果です。 [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([アンディ-ヤン](https://github.com/andyyzh)) +- ハッシュ化された辞書のelement\_countを修正(重複を含まない) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) +- 環境変数TZの内容をタイムゾーンの名前として使用します。 すでに正しく検出デフォルトのタイムゾーンもあります。[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([イワン](https://github.com/abyss7)) +- 整数を変換しようとしないでください `dictGetT` それは正しく動作しないため、機能します。 代わりに例外をスローします。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- ExternalData HTTP要求の設定を修正しました。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([ダニラ + クテニン](https://github.com/danlark1)) +- パーツがZOOKEEPERから落とさずにFSからのみ取り除かれたバグを修正しました。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([アレサピン](https://github.com/alesapin)) +- 固定の区分断層に `bitmapHasAny` 機能。 [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) +- 固定の場合にはエラー複製を接続プールなリトライを解決するホストでも、DNSキャッシュした。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([アレサピン](https://github.com/alesapin)) +- 固定 `DROP INDEX IF EXISTS` クエリ。 さて `ALTER TABLE ... DROP INDEX IF EXISTS ...` 指定されたインデックスが存在しない場合、queryは例外を発生させません。 [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([グレブ-ノビコフ](https://github.com/NanoBjorn)) +- 修正unionすべてのスーパータイプ列。 があった場合に矛盾したデータとカラムの種類によ列あります。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- DDLクエリ処理中にZNONODEをスキップします。 前に別のノードがタスクキュー内のznodeを削除すると、 + それを処理しませんでしたが、すでに子のリストを取得し、DDLWorkerスレッドを終了します。 [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) +- 固定挿入配布()テーブルを実現します。 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) + +### ClickHouse Release19.7.3.9,2019-05-30 {#clickhouse-release-19-7-3-9-2019-05-30} + +#### 新しい機能 {#new-features-2} + +- ユーザーが指定できる設定の範囲を制限することができます。 + これらの制約は、ユーザー設定プロファイルで設定できます。 + [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([ヴィタリ + バラノフ](https://github.com/vitlibar)) +- 関数の第二のバージョンを追加します `groupUniqArray` 任意を使って + `max_size` 結果の配列のサイズを制限するパラメーター。 この + 動作は次のようになります `groupArray(max_size)(x)` 機能。 + [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([ギヨーム + タッサリー](https://github.com/YiuRULE)) +- TSVWithNames/CSVWithNames入力ファイル形式の場合、列の順序は次のようになります + ファイ これはによって制御される + `input_format_with_names_use_header` パラメータ。 + [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) + ([Alexander](https://github.com/Akazz)) + +#### バグ修正 {#bug-fixes-2} + +- マージ中にuncompressed\_cache+JOINでクラッシュする(\#5197) + [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([ダニラ + クテニン](https://github.com/danlark1)) +- システムテーブルへのclickhouse-clientクエリのセグメンテーション障害。 \#5066 + [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) + ([イワン](https://github.com/abyss7)) +- KafkaEngineによる重負荷時のデータ損失(\#4736) + [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) + ([イワン](https://github.com/abyss7)) +- UNION ALLを使用してクエリを実行するときに発生する可能性のある非常にまれなデータ競合状態を修正しました。列,システム.テーブル、システム。部品、システム。parts\_tablesまたはマージファミリのテーブルと、関連するテーブルの列の変更を同時に実行します。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 性能の向上 {#performance-improvements-1} + +- 単一の数値列によるソートに基数ソートを使用する `ORDER BY` なし + `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), + [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) + ([エフゲニー-プラウダ](https://github.com/kvinty), + [アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 文書 {#documentation-1} + +- 一部のテーブルエンジンの文書を中国語に翻訳します。 + [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), + [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), + [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) + ([张风啸](https://github.com/AlexZFX)), + [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([しない + リー](https://github.com/neverlee)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-1} + +- UTF-8文字を正しく印刷する `clickhouse-test`. + [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) + ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 常に提案をロードするclickhouse-clientのコマンドラインパラメータを追加 + データ [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) + ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- PVS-Studioの警告の一部を解決します。 + [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) + ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- LZ4の更新 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([ダニラ + クテニン](https://github.com/danlark1)) +- 今後のプル要求\#5030の要件を構築するためにgperfを追加します。 + [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) + ([プロラー](https://github.com/proller)) + +## ClickHouseリリース19.6 {#clickhouse-release-19-6} + +### ClickHouse Release19.6.3.18,2019-06-13 {#clickhouse-release-19-6-3-18-2019-06-13} + +#### バグ修正 {#bug-fixes-3} + +- テーブル関数からのクエリの条件プッシュダウンで修正 `mysql` と `odbc` と対応するテーブルエンジン。 これは#3540と#2384を修正します。 [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Zookeeperのデッドロックを修正しました。 [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([ギスブ1世](https://github.com/github1youlc)) +- CSVで引用符で囲まれた小数を許可します。 [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([アルテム-ズイコフ](https://github.com/4ertus2) +- Float Inf/NaNから小数への変換を禁止します(例外をスローします)。 [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 名前変更クエリのデータ競合を修正しました。 [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([冬張](https://github.com/zhang2014)) +- LFAllocを一時的に無効にします。 LFAllocを使用すると、UncompressedCacheを割り当てる際に多くのMAP\_FAILEDが発生し、結果として負荷の高いサーバーでのクエリのクラッシュにつながる可能性があります。 [cfdba93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([ダニラ-クテニン](https://github.com/danlark1)) + +### ClickHouse Release19.6.2.11,2019-05-13 {#clickhouse-release-19-6-2-11-2019-05-13} + +#### 新しい機能 {#new-features-3} + +- 列および表のTTL式。 [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([アントン-ポポフ](https://github.com/CurtizJ)) +- 追加されたサポート `brotli` HTTPレスポンスの圧縮(Accept-Encoding:br) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([ミハイル](https://github.com/fandyushin)) +- 新しい機能を追加 `isValidUTF8` 確認を行うための設定のバイトが正常にutf-8エンコードされます。 [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([ダニラ-クテニン](https://github.com/danlark1)) +- 新しい負荷分散ポリシーの追加 `first_or_random` 送信されるクエリを最初に指定されたホストの場合は利用できな送信をクエリーダ主催のチャームのボー. クロスレプリケーショントポロジ設定に便利です。 [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([nvartolomei](https://github.com/nvartolomei)) + +#### 実験的な特徴 {#experimental-features-1} + +- 設定を追加 `index_granularity_bytes` MergeTree\*テーブルファミリの(適応インデックス粒度)。 [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([アレサピン](https://github.com/alesapin)) + +#### 改善 {#improvements-1} + +- 関数の非定数引数と負のサイズと長さの引数のサポートが追加されました `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 左結合の右表へのプッシュダウン、右結合の左表へのプッシュダウン、および完全結合の両方の表を無効にします。 これにより、誤った結合結果が修正されます。 [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([イワン](https://github.com/abyss7)) +- `clickhouse-copier`:からの自動アップロードタスク設定 `--task-file` オプション [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([プロラー](https://github.com/proller)) +- 追加の誤字ハンドラに保存工場とテーブル機能の工場です。 [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([ダニラ-クテニン](https://github.com/danlark1)) +- サブクエリなしで複数の結合のためのアスタリスクと修飾アスタリスクをサポート [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- く不カラムのエラーメッセージよりユーザーにも優しい。 [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 性能の向上 {#performance-improvements-2} + +- ASOF結合の大幅な高速化 [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([マルティン-バッカー](https://github.com/Gladdy)) + +#### 下位互換性のない変更 {#backward-incompatible-changes} + +- HTTPヘッダ `Query-Id` に改名されました `X-ClickHouse-Query-Id` 一貫性のために。 [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([ミハイル](https://github.com/fandyushin)) + +#### バグ修正 {#bug-fixes-4} + +- 固定された潜在的なヌルポインタの逆参照 `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([プロラー](https://github.com/proller)) +- 結合+配列結合でクエリのエラーを修正しました [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定掛けの開始にサーバーが辞書により他の辞書を介してデータベースエンジン=辞書で調べました。 [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- Partially fix distributed\_product\_mode = local. It's possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There's not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 潜在的に間違った結果を修正 `SELECT DISTINCT` と `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- UNION ALLを使用してクエリを実行するときに発生する可能性のある非常にまれなデータ競合状態を修正しました。列,システム.テーブル、システム。部品、システム。parts\_tablesまたはマージファミリのテーブルと、関連するテーブルの列の変更を同時に実行します。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-2} + +- 別のホストでclickhouse-serverを実行しているときのテストエラーを修正 [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- clickhouse-test:非tty環境でカラーコントロールシーケンスを無効にします。 [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([アレサピン](https://github.com/alesapin)) +- clickhouse-test:任意のテストデータベースの使用を許可(削除 `test.` それが可能な資格) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([プロラー](https://github.com/proller)) +- Ubsanのエラーを修正 [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- Yandex LFAllocがClickHouseに追加され、markcacheとUncompressedCacheのデータをさまざまな方法で割り当て、segfaultsをより信頼性の高いものにすることができました [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([ダニラ-クテニン](https://github.com/danlark1)) +- バックポートとチェンジログを支援するPython util。 [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([イワン](https://github.com/abyss7)) + +## ClickHouseリリース19.5 {#clickhouse-release-19-5} + +### ClickHouse Release19.5.4.22,2019-05-13 {#clickhouse-release-19-5-4-22-2019-05-13} + +#### バグ修正 {#bug-fixes-5} + +- ビットマップ\*関数でのクラッシュを修正 [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([アンディ-ヤン](https://github.com/andyyzh)) +- UNION ALLを使用してクエリを実行するときに発生する可能性のある非常にまれなデータ競合状態を修正しました。列,システム.テーブル、システム。部品、システム。parts\_tablesまたはマージファミリのテーブルと、関連するテーブルの列の変更を同時に実行します。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正されたエラー `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. このエラーは、LowCardinality列が主キーの一部である場合に発生しました。 \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 保持関数の変更:行が最初の条件とN番目の条件の両方を満たす場合、最初に満たされた条件のみがデータ状態に追加されます。 これで、データ行で満たすすべての条件がデータ状態に追加されます。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) + +### ClickHouse Release19.5.3.8,2019-04-18 {#clickhouse-release-19-5-3-8-2019-04-18} + +#### バグ修正 {#bug-fixes-6} + +- 固定タイプの設定 `max_partitions_per_insert_block` ブール値からUInt64まで。 [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([モハマド-ホセイン-セハヴァト](https://github.com/mhsekhavat)) + +### ClickHouse Release19.5.2.6,2019-04-15 {#clickhouse-release-19-5-2-6-2019-04-15} + +#### 新しい機能 {#new-features-4} + +- [Hyperscan](https://github.com/intel/hyperscan) 複数の正規表現マッチングが追加されました(関数 `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([ダニラ-クテニン](https://github.com/danlark1)) +- `multiSearchFirstPosition` 機能を追加しました。 [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([ダニラ-クテニン](https://github.com/danlark1)) +- の実施を所定の表現フィルター配列です。 [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([イワン](https://github.com/abyss7)) +- 新しいタイプのデータを飛び指標に基づくブル(使用可能 `equal`, `in` と `like` 機能)。 [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- 追加 `ASOF JOIN` これにより、既知の最新の値に結合するクエリを実行できます。 [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([マルティン-バッカー](https://github.com/Gladdy), [アルテム-ズイコフ](https://github.com/4ertus2)) +- 複数の書き換え `COMMA JOIN` に `CROSS JOIN`. その書き換えて `INNER JOIN` 可能であれば。 [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 改善 {#improvement-9} + +- `topK` と `topKWeighted` 今すぐカスタム `loadFactor` (修正の問題 [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([キリルダンシン](https://github.com/kirillDanshin)) +- 使用を許可する `parallel_replicas_count > 1` サンプリングのないテーブルでも(設定は単に無視されます)。 以前のバージョンでは例外につながっていました。 [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([アレクセイ-エリマノフ](https://github.com/digitalist)) +- のサポート `CREATE OR REPLACE VIEW`. 単一のステートメントでビューを作成したり、新しい定義を設定したりできます。 [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([ボリス-グランヴォー](https://github.com/bgranvea)) +- `Buffer` テーブルエンジンに対応しま `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([ヤンクアン-リュウ](https://github.com/LiuYangkuan)) +- 追加能力を開始複製テーブルなしデータを飼育係に `readonly` モード [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([アレサピン](https://github.com/alesapin)) +- Clickhouse-clientのプログレスバーのちらつきを修正しました。 この問題は、使用するときに最も顕著でした `FORMAT Null` ストリーミン [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 関数を無効にすることを許可する `hyperscan` 図書館にユーザー毎に制限潜在的過剰および再資源利用に [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加バージョン番号でログインしてすべてのエラー. [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([プロラー](https://github.com/proller)) +- に制限を追加しました `multiMatch` 文字列に収まるように文字列サイズを必要とする関数 `unsigned int`. また、引数の数の制限を追加しました。 `multiSearch` 機能。 [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([ダニラ-クテニン](https://github.com/danlark1)) +- Hyperscanでのスクラッチ領域とエラー処理の使用が改善されました。 [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([ダニラ-クテニン](https://github.com/danlark1)) +- 塗りつぶし `system.graphite_detentions` のテーブル設定から `*GraphiteMergeTree` エンジンテーブル。 [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- 名前変更 `trigramDistance` への関数 `ngramDistance` とより多くの機能を追加 `CaseInsensitive` と `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([ダニラ-クテニン](https://github.com/danlark1)) +- の改善データを飛び指標を計算します。 [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- 普通に保つ, `DEFAULT`, `MATERIALIZED` と `ALIAS` 単一のリスト内の列(修正の問題 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([アレックス-ザテレピン](https://github.com/ztlpn)) + +#### バグ修正 {#bug-fix-26} + +- 避ける `std::terminate` メモリ割り当てに失敗した場合。 さて `std::bad_alloc` 例外は期待どおりにスローされます。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- バッファからの読み取りを修正capnproto。 時にファイルなロードに成功するHTTP. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ウラジスラフ](https://github.com/smirnov-vs)) +- 修正エラー `Unknown log entry type: 0` 後に `OPTIMIZE TABLE FINAL` クエリ。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([アモス鳥](https://github.com/amosbird)) +- 間違った引数に `hasAny` または `hasAll` 関数はsegfaultにつながる可能性があります。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 実行中にデッドロックが発生する `DROP DATABASE dictionary` クエリ。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- で未定義の動作を修正 `median` と `quantile` 機能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +- 圧縮レベル検出時の修正 `network_compression_method` 小文字で。 V19.1で壊れた。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([プロラー](https://github.com/proller)) +- の固定された無知 `UTC` 設定(修正の問題 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([プロラー](https://github.com/proller)) +- 修正 `histogram` 関数の動作 `Distributed` テーブル [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) +- 固定tsanレポート `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定賛育の報告書の停止によるレースの条件のシステムのログ利用 固定の潜在的利用に停止時part\_logが有効になります。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正再チェック部品 `ReplicatedMergeTreeAlterThread` エラーの場合。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 中間集計関数状態に対する算術演算が、定数引数(サブクエリ結果など)に対して機能していませんでした。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 常にbackquoteカラム名は、メタデータを指すものとします。 それ以外の場合は、列名のテーブルを作成することは不可能です `index` (不正な形式のためサーバーは再起動されません `ATTACH` メタデータ内のクエリ)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- でクラッシュを修正 `ALTER ... MODIFY ORDER BY` に `Distributed` テーブル。 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([Tシーズン](https://github.com/TCeason)) +- でsegfaultを修正 `JOIN ON` 有効にした場合 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([冬張](https://github.com/zhang2014)) +- カフカからprotobufメッセージを消費した後に余分な行を追加するバグを修正しました。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- のクラッシュを修正 `JOIN` null許容ではない列とnull許容の列です。 修正 `NULLs` in右キー in `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定の区分断層に `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([プロラー](https://github.com/proller)) +- で固定された競合状態 `SELECT` から `system.tables` テーブルの名前が変更または同時に変更された場合。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定データが取得データの一部は既に互換性のために残されています。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定珍しいデータレースができ起こすこと `RENAME` MergeTree家族のテーブル。 [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 機能の固定分割の欠陥 `arrayIntersect`. Segmentation faultう場合は関数と呼ばれたとの混合の定数、通常の引数になります。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang銭](https://github.com/fancyqlx)) +- からの固定読み取り `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- でクラッシュを修正 `FULL/RIGHT JOIN` nullable対nullableに参加するとき。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 修正 `No message received` レプリカ間のパーツの取得中は例外です。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([アレサピン](https://github.com/alesapin)) +- 固定 `arrayIntersect` 単一の配列内のいくつかの繰り返し値の場合、関数が間違った結果。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 同時実行の間に競合状態を修正する `ALTER COLUMN` サーバークラッシュにつながる可能性のあるクエリ(問題の修正 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 誤った結果を修正 `FULL/RIGHT JOIN` const列を持つ。 [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- で重複を修正 `GLOBAL JOIN` アスタリスク付き。 [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- でパラメータ控除を修正 `ALTER MODIFY` 列の `CODEC` 列タイプが指定されていない場合。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([アレサピン](https://github.com/alesapin)) +- 関数 `cutQueryStringAndFragment()` と `queryStringAndFragment()` 今正しく動作するとき `URL` フラグメントとクエリを含みません。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 設定時に珍しいバグを修正 `min_bytes_to_use_direct_io` これは、スレッドが列ファイル内で後方にシークする必要があるときに発生します。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([アレサピン](https://github.com/alesapin)) +- 集計関数の誤った引数型を修正 `LowCardinality` 引数(修正の問題 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 間違った名前の修飾を修正 `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 修正機能 `toISOWeek` 1970年の結果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正 `DROP`, `TRUNCATE` と `OPTIMIZE` クエリの重複 `ON CLUSTER` のために `ReplicatedMergeTree*` テーブル家族. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([アレサピン](https://github.com/alesapin)) + +#### 下位互換性のない変更 {#backward-incompatible-change-8} + +- 名前変更の設定 `insert_sample_with_metadata` 設定へ `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 設定を追加 `max_partitions_per_insert_block` (デフォルトでは値100)。 場合に挿入したブロックを含むより多くのパーティション例外がスローされます。 制限を削除する場合は、0に設定します(推奨しません)。 [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 複数検索機能の名前が変更されました (`multiPosition` に `multiSearchAllPositions`, `multiSearch` に `multiSearchAny`, `firstMatch` に `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([ダニラ-クテニン](https://github.com/danlark1)) + +#### 性能向上 {#performance-improvement-6} + +- 多くの針または多くの類似bigramsとのクエリのための約5-10%の検索改善を与え、インラインによってVolnitsky検索を最適化します。 [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([ダニラ-クテニン](https://github.com/danlark1)) +- 設定時のパフォーマンス問題を修正 `use_uncompressed_cache` がゼロより大き登場したときのすべてのデータに含まれる。 [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([アレサピン](https://github.com/alesapin)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-10} + +- デバッグビルドの強化:より詳細なメモリマッピングとASLR。 これによりメモリの揃い踏みのバグの場合には豆やMSanできます。 [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Cmake変数のサポートの追加 `ENABLE_PROTOBUF`, `ENABLE_PARQUET` と `ENABLE_BROTLI` これにより、上記の機能を有効/無効にすることができます(librdkafka、mysqlなどの場合と同じです)。 [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([シルヴィウ-カラゲア](https://github.com/silviucpp)) +- 追加ダイレクトに刷版を出力するプロセス一覧表示およびstacktracesのすべてのスレッドの場合一部のクエリで吊るされているだけなので後の試験です。 [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([アレサピン](https://github.com/alesapin)) +- 再試行の追加 `Connection loss` エラー `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([アレサピン](https://github.com/alesapin)) +- Freebsd build with vagrantをパッケージャスクリプトに追加し、スレッドサニタイザでビルドします。 [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([アレサピン](https://github.com/alesapin)) +- 現在ユーザーのためのパスワードユーザー `'default'` 取付けの間。 [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([プロラー](https://github.com/proller)) +- 警告を抑制する `rdkafka` 図書館 [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Sslなしでビルドできるようにする。 [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([プロラー](https://github.com/proller)) +- カスタムユーザーからclickhouse-serverイメージを起動する方法を追加します。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- Contrib boostを1.69にアップグレードします。 [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([プロラー](https://github.com/proller)) +- 使用を無効にする `mremap` きめにスレッドに指消毒剤. 驚いたことに、TSanは傍受しません `mremap` (それは傍受しますが `mmap`, `munmap`)それは偽陽性につながる。 ステートフルテストでのTSanレポートの修正 [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 追加試験にチェックを使用形式スキーマによHTTPインターフェース。 [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) + +## ClickHouseリリース19.4 {#clickhouse-release-19-4} + +### ClickHouseリリース19.4.4.33,2019-04-17 {#clickhouse-release-19-4-4-33-2019-04-17} + +#### バグ修正 {#bug-fixes-7} + +- 避ける `std::terminate` メモリ割り当てに失敗した場合。 さて `std::bad_alloc` 例外は期待どおりにスローされます。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- バッファからの読み取りを修正capnproto。 時にファイルなロードに成功するHTTP. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ウラジスラフ](https://github.com/smirnov-vs)) +- 修正エラー `Unknown log entry type: 0` 後に `OPTIMIZE TABLE FINAL` クエリ。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([アモス鳥](https://github.com/amosbird)) +- 間違った引数に `hasAny` または `hasAll` 関数はsegfaultにつながる可能性があります。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 実行中にデッドロックが発生する `DROP DATABASE dictionary` クエリ。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- で未定義の動作を修正 `median` と `quantile` 機能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +- 圧縮レベル検出時の修正 `network_compression_method` 小文字で。 V19.1で壊れた。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([プロラー](https://github.com/proller)) +- の固定された無知 `UTC` 設定(修正の問題 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([プロラー](https://github.com/proller)) +- 修正 `histogram` 関数の動作 `Distributed` テーブル [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) +- 固定tsanレポート `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定賛育の報告書の停止によるレースの条件のシステムのログ利用 固定の潜在的利用に停止時part\_logが有効になります。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正再チェック部品 `ReplicatedMergeTreeAlterThread` エラーの場合。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 中間集計関数状態に対する算術演算が、定数引数(サブクエリ結果など)に対して機能していませんでした。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 常にbackquoteカラム名は、メタデータを指すものとします。 それ以外の場合は、列名のテーブルを作成することは不可能です `index` (不正な形式のためサーバーは再起動されません `ATTACH` メタデータ内のクエリ)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- でクラッシュを修正 `ALTER ... MODIFY ORDER BY` に `Distributed` テーブル。 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([Tシーズン](https://github.com/TCeason)) +- でsegfaultを修正 `JOIN ON` 有効にした場合 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([冬張](https://github.com/zhang2014)) +- カフカからprotobufメッセージを消費した後に余分な行を追加するバグを修正しました。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 固定の区分断層に `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([プロラー](https://github.com/proller)) +- で固定された競合状態 `SELECT` から `system.tables` テーブルの名前が変更または同時に変更された場合。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定データが取得データの一部は既に互換性のために残されています。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定珍しいデータレースができ起こすこと `RENAME` MergeTree家族のテーブル。 [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 機能の固定分割の欠陥 `arrayIntersect`. Segmentation faultう場合は関数と呼ばれたとの混合の定数、通常の引数になります。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang銭](https://github.com/fancyqlx)) +- からの固定読み取り `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 修正 `No message received` レプリカ間のパーツの取得中は例外です。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([アレサピン](https://github.com/alesapin)) +- 固定 `arrayIntersect` 単一の配列内のいくつかの繰り返し値の場合、関数が間違った結果。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 同時実行の間に競合状態を修正する `ALTER COLUMN` サーバークラッシュにつながる可能性のあるクエリ(問題の修正 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- でパラメータ控除を修正 `ALTER MODIFY` 列の `CODEC` 列タイプが指定されていない場合。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([アレサピン](https://github.com/alesapin)) +- 関数 `cutQueryStringAndFragment()` と `queryStringAndFragment()` 今正しく動作するとき `URL` フラグメントとクエリを含みません。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 設定時に珍しいバグを修正 `min_bytes_to_use_direct_io` これは、スレッドが列ファイル内で後方にシークする必要があるときに発生します。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([アレサピン](https://github.com/alesapin)) +- 集計関数の誤った引数型を修正 `LowCardinality` 引数(修正の問題 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 修正機能 `toISOWeek` 1970年の結果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正 `DROP`, `TRUNCATE` と `OPTIMIZE` クエリの重複 `ON CLUSTER` のために `ReplicatedMergeTree*` テーブル家族. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([アレサピン](https://github.com/alesapin)) + +#### 改善 {#improvements-2} + +- 普通に保つ, `DEFAULT`, `MATERIALIZED` と `ALIAS` 単一のリスト内の列(修正の問題 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([アレックス-ザテレピン](https://github.com/ztlpn)) + +### ClickHouseリリース19.4.3.11,2019-04-02 {#clickhouse-release-19-4-3-11-2019-04-02} + +#### バグ修正 {#bug-fixes-8} + +- でクラッシュを修正 `FULL/RIGHT JOIN` nullable対nullableに参加するとき。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定の区分断層に `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([プロラー](https://github.com/proller)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-11} + +- カスタムユーザーからclickhouse-serverイメージを起動する方法を追加します。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### ClickHouseリリース19.4.2.7,2019-03-30 {#clickhouse-release-19-4-2-7-2019-03-30} + +#### バグ修正 {#bug-fixes-9} + +- からの固定読み取り `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) + +### ClickHouse Release19.4.1.3,2019-03-19 {#clickhouse-release-19-4-1-3-2019-03-19} + +#### バグ修正 {#bug-fixes-10} + +- 両方を含む固定リモートクエリ `LIMIT BY` と `LIMIT`. 以前は、 `LIMIT BY` と `LIMIT` リモートクエリに使用された, `LIMIT` 前に起こる可能性が `LIMIT BY`、あまりにもろ過結果につながった。 [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([コンスタンティン-S-パン](https://github.com/kvap)) + +### ClickHouseリリース19.4.0.49,2019-03-09 {#clickhouse-release-19-4-0-49-2019-03-09} + +#### 新しい機能 {#new-features-5} + +- 追加されたフルサポート `Protobuf` フォーマット(入力と出力、入れ子になったデータ構造)。 [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 轟音ビットマップとビットマップ関数を追加しました。 [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([アンディ-ヤン](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 寄木細工の形式のサポート。 [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([プロラー](https://github.com/proller)) +- ファジィ文字列の比較のためにN-gram距離を追加しました。 これは、R言語のq-gramメトリックに似ています。 [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([ダニラ-クテニン](https://github.com/danlark1)) +- 結合ルールのための黒鉛rollupから専用の凝集-保持。 [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- 追加 `max_execution_speed` と `max_execution_speed_bytes` リソース使用量を制限する。 追加 `min_execution_speed_bytes` を補完するように設定する `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([冬張](https://github.com/zhang2014)) +- 実装関数 `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov), [kzon](https://github.com/kzon)) +- 追加された機能 `arrayEnumerateDenseRanked` と `arrayEnumerateUniqRanked` (それはのようです `arrayEnumerateUniq` しかし、多次元配列の内部を見るために配列の深さを微調整することができます)。 [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([プロラー](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### バグ修正 {#bug-fixes-11} + +- このリリースには、19.3と19.1のすべてのバグ修正も含まれています。 +- インデックスをスキップするデータのバグを修正しました。 [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- 固定 `set` インデックス `Nullable` と `LowCardinality` 列。 その前に, `set` インデックス `Nullable` または `LowCardinality` 列がエラーにつながった `Data type must be deserialized with multiple streams` 選択中。 [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 完全にupdate\_timeを正しく設定 `executable` 辞書の更新。 [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([テマ-ノヴィコフ](https://github.com/temoon)) +- 19.3で壊れたプログレスバーを修正。 [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([フィリモノフ](https://github.com/filimonov)) +- 特定のケースでは、メモリ領域が縮小されたときにMemoryTrackerの矛盾した値を修正しました。 [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ThreadPoolの未定義の動作を修正しました。 [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- メッセージで非常にまれなクラッシュを修正 `mutex lock failed: Invalid argument` これは、MergeTreeテーブルがSELECTと同時に削除された場合に発生する可能性があります。 [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- ODBCドライバとの互換性 `LowCardinality` データ型。 [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([プロラー](https://github.com/proller)) +- FreeBSD:フィックスアップ `AIOcontextPool: Found io_event with unknown id 0` エラー [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([ウルゴルドビーフ](https://github.com/urgordeadbeef)) +- `system.part_log` 設定に関係なくテーブルが作成されました。 [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 未定義の動作を修正 `dictIsIn` キャッシュ辞書の機能。 [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([アレサピン](https://github.com/alesapin)) +- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- デフォルトでcompile\_expressionsを無効にします。 `llvm` contribはそれをとのテストし、 `clang` と `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([アレサピン](https://github.com/alesapin)) +- 防ぐ `std::terminate` とき `invalidate_query` のために `clickhouse` 外部ディクショナリソースから誤った結果セット(空または複数の行または複数の列)が返されました。 問題を修正しました。 `invalidate_query` に関係なく、五秒ごとに行われました `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- デッドロックを避けなさい時 `invalidate_query` 辞書の場合 `clickhouse` ソースが関与していた `system.dictionaries` テーブルまたは `Dictionaries` データベース(まれなケース)。 [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 空の場所でクロス結合の修正。 [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 関数内の固定segfault “replicate” 定数引数が渡されたとき。 [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 述語オプティマイザでラムダ関数を修正。 [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([冬張](https://github.com/zhang2014)) +- 複数の結合複数の修正。 [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### 改善 {#improvements-3} + +- 右のテーブルの列のセクションの結合のサポートエイリアス。 [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 複数の結合の結果は、サブセレクトで使用する正しい結果名が必要です。 平置き換えエイリアスとソース名ます。 [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 改善プッシュダウンの論理のために参加します。 [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([イワン](https://github.com/abyss7)) + +#### 性能の向上 {#performance-improvements-3} + +- のヒューリスティックの改善 “move to PREWHERE” 最適化。 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 8ビットキーと16ビットキーにHashTableのAPIを使用する適切なルックアップテーブルを使用します。 [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([アモス鳥](https://github.com/amosbird)) +- 文字列比較のパフォーマンスの向上。 [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 分散DDLタスクを処理するメインループが遅くならないように、分散DDLキューを別のスレッドでクリーンアップします。 [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- とき `min_bytes_to_use_direct_io` 読み込むデータサイズが圧縮されたブロックのサイズによって過小評価されることがあるため、すべてのファイルがO\_DIRECTモードで開かれたわけではあ [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-12} + +- Clang-9のサポートが追加されました [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 間違った修正 `__asm__` 指示(再び) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([コンスタンチン-ポドシュモク](https://github.com/podshumok)) +- の設定を指定する機能を追加 `clickhouse-performance-test` コマンドラインから。 [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([アレサピン](https://github.com/alesapin)) +- 統合テストに辞書テストを追加します。 [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([アレサピン](https://github.com/alesapin)) +- 追加のクエリからのベンチマークのサイトを自動化性能試験までを実施。 [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `xxhash.h` これは実装の詳細であり、そのシンボルは名前空間であるため、外部lz4には存在しません `XXH_NAMESPACE` マクロ Lz4が外部の場合、xxHashも外部でなければならず、依存者はそれにリンクする必要があります。 [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([オリヴェイ-デシュ](https://github.com/orivej)) +- ときにケースを修正 `quantileTiming` 集計関数は、負または浮動小数点引数で呼び出すことができます(これは未定義の振る舞いsanitizerでファズテストを修正します)。 [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- スペル誤り訂正。 [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) +- Mac上でコンパイルを修正。 [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- FreeBSDおよび様々な異常なビルド構成のビルド修正。 [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([プロラー](https://github.com/proller)) + +## ClickHouseリリース19.3 {#clickhouse-release-19-3} + +### ClickHouseリリース19.3.9.1,2019-04-02 {#clickhouse-release-19-3-9-1-2019-04-02} + +#### バグ修正 {#bug-fixes-12} + +- でクラッシュを修正 `FULL/RIGHT JOIN` nullable対nullableに参加するとき。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定の区分断層に `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([プロラー](https://github.com/proller)) +- からの固定読み取り `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) + +#### 造り/テスト/包装の改善 {#buildtestingpackaging-improvement-13} + +- カスタムユーザーからclickhouse-serverイメージを起動する方法を追加する [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### ClickHouse Release19.3.7,2019-03-12 {#clickhouse-release-19-3-7-2019-03-12} + +#### バグ修正 {#bug-fixes-13} + +- #3920のエラーを修正しました。 このエラ `Unknown codec family code`, `Cannot seek through file`)とsegfaults。 このバグはバージョン19.1で最初に登場し、19.1.10および19.3.6までのバージョンに存在します。 [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.3.6,2019-03-02 {#clickhouse-release-19-3-6-2019-03-02} + +#### バグ修正 {#bug-fixes-14} + +- スレッドプールに1000を超えるスレッドがある場合, `std::terminate` が起こるためのスレッド終了します。 [Azat Khuzhin](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- これで作成することができます `ReplicatedMergeTree*` テーブルのコメントするカラムなデフォルトテーブルとカラムコーデックなコメントがデフォルトする また、コーデックの比較を修正。 [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([アレサピン](https://github.com/alesapin)) +- 固定時にクラッシュするバグに参加す配列またはタプル. [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- メッセージとclickhouse-コピー機で固定クラッシュ `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定電話を切るサーバー停止の場合は分散DDLsを使用した。 [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 正しくない列番号が10より大きい列のテキスト形式の解析に関するエラーメッセージに表示されました。 [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-3} + +- AVXを有効にした固定ビルド。 [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- コンパイルされているカーネルではなく、既知のバージョンに基づいて拡張会計とIO会計を有効にします。 [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([nvartolomei](https://github.com/nvartolomei)) +- Core\_dumpの設定をスキップできるようにする。size\_limit、リミットセットが失敗した場合はスローの代わりに警告。 [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([プロラー](https://github.com/proller)) +- 削除された `inline` のタグ `void readBinary(...)` で `Field.cpp`. また、マージ冗長 `namespace DB` ブロック [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([hcz](https://github.com/hczhcz)) + +### ClickHouse Release19.3.5,2019-02-21 {#clickhouse-release-19-3-5-2019-02-21} + +#### バグ修正 {#bug-fixes-15} + +- 大規模なhttp挿入クエリ処理のバグを修正しました。 [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([アレサピン](https://github.com/alesapin)) +- 間違った実装のために古いバージョンとの下位互換性を修正しました `send_logs_level` 設定。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- テーブル関数の下位互換性を修正 `remote` 列のコメントで導入。 [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.3.4,2019-02-16 {#clickhouse-release-19-3-4-2019-02-16} + +#### 改善 {#improvements-4} + +- テーブル-インデックスをさせていただく事があり占めのメモリの制限を行うと `ATTACH TABLE` クエリ。 デタッチ後にテーブルをアタッチできない可能性を回避しました。 [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ZooKeeperから受け取った最大文字列と配列サイズの制限を少し上げました。 でも引き続き増加しのサイズ `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` 飼育係に。 [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- すると修理を断念レプリカでも既に膨大な数のノードがそのキューに挿入します [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 必要な引数を一つ追加する `SET` インデックス(格納されている最大行数)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) + +#### バグ修正 {#bug-fixes-16} + +- 固定 `WITH ROLLUP` 単一によるグループの結果 `LowCardinality` キー [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 固定バグの設定指数を落と顆粒が含まれている場合以 `max_rows` 行)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- 多くのFreeBSDビルド修正。 [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([プロラー](https://github.com/proller)) +- 固定エイリアス置換にクエリサブクエリを含む同じエイリアス(発行 [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-4} + +- 実行する機能を追加する `clickhouse-server` docker imageのステートレステストの場合。 [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) + +### ClickHouse Release19.3.3,2019-02-13 {#clickhouse-release-19-3-3-2019-02-13} + +#### 新しい機能 {#new-features-6} + +- 追加された `KILL MUTATION` 何らかの理由で立ち往生している突然変異を除去することを可能にする文。 追加 `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` のフィールド `system.mutations` テーブルやtroubleshooting. [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 集計関数を追加 `entropy` シャノンエントロピーを計算します [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) +- クエリを送信する機能を追加 `INSERT INTO tbl VALUES (....` 分割せずにサーバーに `query` と `data` 部品だ [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([アレサピン](https://github.com/alesapin)) +- の汎用実装 `arrayWithConstant` 機能を追加しました。 [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 実装 `NOT BETWEEN` 比較演算子。 [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([ドミトリー-ナウモフ](https://github.com/nezed)) +- 実装 `sumMapFiltered` 値が合計されるキーの数を制限できるようにするには `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- の追加されたサポート `Nullable` タイプ `mysql` テーブル関数。 [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) +- の任意の定数式のサポート `LIMIT` 句。 [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) +- 追加 `topKWeighted` (符号なし整数)重みを持つ追加の引数を取る集計関数。 [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([アンドリュ](https://github.com/andrewgolman)) +- `StorageJoin` 今すぐサポート `join_any_take_last_row` 同じキーの既存の値を上書きできるようにする設定。 [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([アモス鳥](https://github.com/amosbird) +- 追加された機能 `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 追加 `RowBinaryWithNamesAndTypes` 形式。 [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([オレグ-コズリュク](https://github.com/DarkWanderer)) +- 追加 `IPv4` と `IPv6` データ型。 より効果的な実装 `IPv*` 機能。 [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([ヴァシーリー-ネムコフ](https://github.com/Enmk)) +- 追加された機能 `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 追加 `Protobuf` 出力形式。 [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([ヴィタリー-バラノフ](https://github.com/vitlibar)) +- 追加brotli支援のためのHTTPインタフェースデータインポート(挿入します). [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([ミハイル](https://github.com/fandyushin)) +- 追加ヒントがユーザーを商品につけられたタ関数の名称又は種コマンドラインです。 [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([ダニラ-クテニン](https://github.com/danlark1)) +- 追加 `Query-Id` サーバーのHTTP応答ヘッダーへ。 [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([ミハイル](https://github.com/fandyushin)) + +#### 実験的な特徴 {#experimental-features-2} + +- 追加 `minmax` と `set` データ飛指標MergeTreeテーブルエンジンです。 [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- の変換を追加しました `CROSS JOIN` に `INNER JOIN` 可能であれば。 [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### バグ修正 {#bug-fixes-17} + +- 固定 `Not found column` 重複する列の場合 `JOIN ON` セクション [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 作る `START REPLICATED SENDS` コマ [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) +- 固定集計関数の実行 `Array(LowCardinality)` 引数。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 間違った動作を修正しました `INSERT ... SELECT ... FROM file(...)` クエリとファイルは `CSVWithNames` または `TSVWIthNames` フォーマットと最初のデータ行がありません。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定クラッシュ辞書の再読み込みの場合の辞書をございません。 このバグは19.1.6に登場しました。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([プロラー](https://github.com/proller)) +- 固定 `ALL JOIN` 右の表に重複があります。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 固定分割の欠陥との `use_uncompressed_cache=1` そして、間違った非圧縮サイズの例外。 このバグは19.1.6に登場しました。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([アレサピン](https://github.com/alesapin)) +- 固定 `compile_expressions` 大きな(int16以上の)日付の比較に関するバグ。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([アレサピン](https://github.com/alesapin)) +- テーブル関数から選択するときの無限ループを修正 `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 述語の最適化を一時的に無効にする `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([冬張](https://github.com/zhang2014)) +- 固定 `Illegal instruction` 古いCpuでbase64関数を使用するときにエラーが発生しました。 このエラーは、ClickHouseがgcc-8でコンパイルされたときにのみ再現されます。 [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定 `No message received` TLS接続を介してPostgreSQL ODBCドライバと対話するときのエラー。 MySQL ODBCドライバを使用するときにもsegfaultを修正します。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正された誤った結果とき `Date` と `DateTime` 引数は、条件演算子(関数)の分岐で使用されます `if`). 関数の一般的なケースを追加しました `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ClickHouse辞書は今内読み込みます `clickhouse` プロセス。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定デッドロック時 `SELECT` テーブルから `File` エンジンは後に再試行されました `No such file or directory` エラー [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- から選択したときに修正された競合状態 `system.tables` を与える `table doesn't exist` エラー [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `clickhouse-client` 対話モードで実行された場合、コマンドライン候補のデータをロードしているときに終了時にsegfaultできます。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- バグを修正しました。 `IN` 演算子が誤った結果を生成していた。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 修正されたエラー:データベースがある場合 `Dictionary` localhostからClickHouseソースを持つ辞書がある場合、辞書はロードできません。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定エラー時のシステムログのようにして作成時サーバをシャットダウンしました。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 正しく正しい型を返し、ロックを適切に処理します `joinGet` 機能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([アモス鳥](https://github.com/amosbird)) +- 追加 `sumMapWithOverflow` 機能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- で固定segfault `allow_experimental_multiple_joins_emulation`. [52de2c](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 不正なバグを修正しました `Date` と `DateTime` 比較。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([ヴァレクセイ](https://github.com/valexey)) +- 未定義の動作サニタイザの下で固定ファズテスト:追加されたパラメータ型のチェック `quantile*Weighted` 機能の系列。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 古いデータパーツの削除が失敗する可能性がある場合に、まれな競合状態を修正 `File not found` エラー [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- /Etc/clickhouse-server/configが欠落しているパッケージをインストールする修正。xml。 [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([プロラー](https://github.com/proller)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-5} + +- Debianパッケージ:設定に従って/etc/clickhouse-server/前処理されたリンクを修正します。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([プロラー](https://github.com/proller)) +- FreeBSDのための様々なビルド修正。 [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([プロラー](https://github.com/proller)) +- Perftestでテーブルを作成、記入、ドロップする機能を追加しました。 [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([アレサピン](https://github.com/alesapin)) +- 追加スクリプトチェックを複製します。 [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- パフォーマ [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([アレサピン](https://github.com/alesapin)) +- パッケージはデバッグシンボルとを示唆を設置することができます。 [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- パフォーマンステストのリファクタリング。 より良いロギングと信号処理。 [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([アレサピン](https://github.com/alesapin)) +- 匿名Yandexのにドキュメントを追加しました。メトリカ-データセット [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([アレサピン](https://github.com/alesapin)) +- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 追加docsつのデータセットにs3. [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([アレサピン](https://github.com/alesapin)) +- プル要求の説明から変更履歴を作成するスクリプトを追加しました。 [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 追加人形のモジュールClickHouse. [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([マキシム-フェドトフ](https://github.com/MaxFedotov)) +- 文書化されていない関数のグループのドキュメントを追加しました。 [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([冬張](https://github.com/zhang2014)) +- ARMビルドの修正。 [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([プロラー](https://github.com/proller)) ([プロラー](https://github.com/proller)) +- 辞書テストを実行できるようになりました `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([プロラー](https://github.com/proller)) +- さて `/etc/ssl` SSL証明書の既定のディレクトリとして使用されます。 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 起動時にSSEとAVX命令のチェックを追加しました。 [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([Igr](https://github.com/igron99)) +- Initスクリプトが待つサーバーで開始されます。 [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([プロラー](https://github.com/proller)) + +#### 下位互換性のない変更 {#backward-incompatible-changes-1} + +- 削除 `allow_experimental_low_cardinality_type` 設定。 `LowCardinality` データ型は運用準備が整いました。 [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 削減マークのキャッシュされた、圧縮解除されたキャッシュサイズに従ってメインメニューを開きます。 [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([ロパチン-コンスタンチン](https://github.com/k-lopatin) +- キーワードを追加 `INDEX` で `CREATE TABLE` クエリ。 名前のある列 `index` バッククォートまたは二重引用符で囲む必要があります: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([ニキータ-ヴァシレフ](https://github.com/nikvas0)) +- `sumMap` を推進する結果の型の代わりにオーバーフロー. 古い `sumMap` 動作は次のようにして取得できます `sumMapWithOverflow` 機能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) + +#### 性能の向上 {#performance-improvements-4} + +- `std::sort` に置き換え `pdqsort` なしのクエリの場合 `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([エフゲニー-プラウダ](https://github.com/kvinty)) +- 現在サーバーの再利用にスレッドからグローバルスレッドプールがあります。 この影響性能の一部のコーナー。 [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 改善 {#improvements-5} + +- FreeBSDのAIOサポートを実装しました。 [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([ウルゴルドビーフ](https://github.com/urgordeadbeef)) +- `SELECT * FROM a JOIN b USING a, b` 今すぐ戻る `a` と `b` 左側のテーブルからの列のみ。 [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 許可 `-C` として働く顧客の選択 `-c` オプション [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([ショミンセルゲイ](https://github.com/syominsergey)) +- Nowオプション `--password` 使用せずに値を必要とパスワードからstdin. [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([BSD\_Conqueror](https://github.com/bsd-conqueror)) +- エスケープされていないメタ文字を含む文字列リテラルの強調表示を追加しました `LIKE` 式または正規表現。 [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- クライア [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([nvartolomei](https://github.com/nvartolomei)) +- 現在サーバーの進捗報告書くクライアント接続の待機を開始。 [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([イワン](https://github.com/abyss7)) +- クエリを最適化する理由を持つやや良いメッセージ `optimize_throw_if_noop` 設定を有効にします。 [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- の追加されたサポート `--version` clickhouseサーバーのオプション。 [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([ロパチン-コンスタンチン](https://github.com/k-lopatin)) +- 追加 `--help/-h` オプション `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([ユーリー-バラノフ](https://github.com/yurriy)) +- るためのサポートを追加しましたスカラサブクエリと集計関数の状態ます。 [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([ニコライ-コチェトフ](https://github.com/KochetovNicolai)) +- 向上サーバー停止時間の変更を待ってます。 [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Replicated\_can\_become\_leader設定に関する情報をシステムに追加しました。レプリカがリーダーになろうとしない場合は、レプリカとログの追加。 [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([アレックス-ザテレピン](https://github.com/ztlpn)) + +## ClickHouseリリース19.1 {#clickhouse-release-19-1} + +### ClickHouse Release19.1.14,2019-03-14 {#clickhouse-release-19-1-14-2019-03-14} + +- 修正されたエラー `Column ... queried more than once` これは、 `asterisk_left_columns_only` を使用する場合は1に設定されます `GLOBAL JOIN` と `SELECT *` (まれなケース)。 この問題は19.3以降には存在しません。 [6bac7d8d](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +### ClickHouse Release19.1.13,2019-03-12 {#clickhouse-release-19-1-13-2019-03-12} + +このリリ + +### ClickHouseリリース19.1.10,2019-03-03 {#clickhouse-release-19-1-10-2019-03-03} + +このリリ + +## ClickHouseリリース19.1 {#clickhouse-release-19-1-1} + +### ClickHouse Release19.1.9,2019-02-21 {#clickhouse-release-19-1-9-2019-02-21} + +#### バグ修正 {#bug-fixes-18} + +- 間違った実装のために古いバージョンとの下位互換性を修正しました `send_logs_level` 設定。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- テーブル関数の下位互換性を修正 `remote` 列のコメントで導入。 [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.1.8,2019-02-16 {#clickhouse-release-19-1-8-2019-02-16} + +#### バグ修正 {#bug-fixes-19} + +- /Etc/clickhouse-server/configが欠落しているパッケージをインストールする修正。xml。 [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([プロラー](https://github.com/proller)) + +## ClickHouseリリース19.1 {#clickhouse-release-19-1-2} + +### ClickHouse Release19.1.7,2019-02-15 {#clickhouse-release-19-1-7-2019-02-15} + +#### バグ修正 {#bug-fixes-20} + +- 正しく正しい型を返し、ロックを適切に処理します `joinGet` 機能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([アモス鳥](https://github.com/amosbird)) +- 固定エラー時のシステムログのようにして作成時サーバをシャットダウンしました。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 修正されたエラー:データベースがある場合 `Dictionary` localhostからClickHouseソースを持つ辞書がある場合、辞書はロードできません。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- バグを修正しました。 `IN` 演算子が誤った結果を生成していた。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- `clickhouse-client` 対話モードで実行された場合、コマンドライン候補のデータをロードしているときに終了時にsegfaultできます。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- から選択したときに修正された競合状態 `system.tables` を与える `table doesn't exist` エラー [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定デッドロック時 `SELECT` テーブルから `File` エンジンは後に再試行されました `No such file or directory` エラー [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定問題:地方ClickHouse辞書読み込まれTCPが負荷以内です。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定 `No message received` TLS接続を介してPostgreSQL ODBCドライバと対話するときのエラー。 MySQL ODBCドライバを使用するときにもsegfaultを修正します。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 述語の最適化を一時的に無効にする `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([冬張](https://github.com/zhang2014)) +- テーブル関数から選択するときの無限ループを修正 `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定 `compile_expressions` 大きな(int16以上の)日付の比較に関するバグ。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([アレサピン](https://github.com/alesapin)) +- 固定分割の欠陥との `uncompressed_cache=1` そして、間違った非圧縮サイズの例外。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([アレサピン](https://github.com/alesapin)) +- 固定 `ALL JOIN` 右の表に重複があります。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 間違った動作を修正しました `INSERT ... SELECT ... FROM file(...)` クエリとファイルは `CSVWithNames` または `TSVWIthNames` フォーマットと最初のデータ行がありません。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定集計関数の実行 `Array(LowCardinality)` 引数。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- Debianパッケージ:設定に従って/etc/clickhouse-server/前処理されたリンクを修正します。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([プロラー](https://github.com/proller)) +- 未定義の動作サニタイザの下で固定ファズテスト:追加されたパラメータ型のチェック `quantile*Weighted` 機能の系列。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 作る `START REPLICATED SENDS` コマ [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) +- 固定 `Not found column` セクションの結合で重複する列の場合。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- さて `/etc/ssl` SSL証明書の既定のディレクトリとして使用されます。 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定クラッシュ辞書の再読み込みの場合の辞書をございません。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([プロラー](https://github.com/proller)) +- 不正なバグを修正しました `Date` と `DateTime` 比較。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([ヴァレクセイ](https://github.com/valexey)) +- 修正された誤った結果とき `Date` と `DateTime` 引数は、条件演算子(関数)の分岐で使用されます `if`). 関数の一般的なケースを追加しました `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +### ClickHouse Release19.1.6,2019-01-24 {#clickhouse-release-19-1-6-2019-01-24} + +#### 新しい機能 {#new-features-7} + +- 表の列ごとのカスタム圧縮コーデック。 [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([アレサピン](https://github.com/alesapin), [冬張](https://github.com/zhang2014), [アナトリー](https://github.com/Sindbag)) +- 圧縮コーデックを追加 `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([アレサピン](https://github.com/alesapin)) +- 許可する `ALTER` 圧縮コーデック。 [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([アレサピン](https://github.com/alesapin)) +- 追加された機能 `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` SQL標準の互換性のため。 [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([イヴァン-ブリンコフ](https://github.com/blinkov)) +- 書き込みのサポート `HDFS` テーブルと `hdfs` テーブル関数。 [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([アレサピン](https://github.com/alesapin)) +- Big haystackから複数の定数文字列を検索する機能を追加しました: `multiPosition`, `multiSearch` ,`firstMatch` また `-UTF8`, `-CaseInsensitive`,and `-CaseInsensitiveUTF8` 変種。 [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([ダニラ-クテニン](https://github.com/danlark1)) +- 未使用の破片の剪定 `SELECT` シャーディングキー(設定 `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([グレブ-カンテロフ](https://github.com/kanterov), [イワン](https://github.com/abyss7)) +- 許可 `Kafka` ブロックごとにいくつかの解析エラーを無視するエンジン。 [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([イワン](https://github.com/abyss7)) +- 追加されたサポート `CatBoost` マルチクラスモデルの評価。 関数 `modelEvaluate` マルチクラスモデルのクラスごとの生の予測を持つタプルを返します。 `libcatboostmodel.so` で構築する必要があります [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 追加された機能 `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([ボリス-グランヴォー](https://github.com/bgranvea)) +- ハッシュ機能の追加 `xxHash64` と `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([フィリモノフ](https://github.com/filimonov)) +- 追加 `gccMurmurHash` 同じハッシュシードを使用するハッシュ関数(GCC flavoured Murmur hash) [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([スンディリ](https://github.com/sundy-li)) +- ハッシュ機能の追加 `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([shangshujie365](https://github.com/shangshujie365)) +- テーブル関数を追加 `remoteSecure`. 機能として `remote` しかし、安全な接続を使用します。 [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([プロラー](https://github.com/proller)) + +#### 実験的な特徴 {#experimental-features-3} + +- 複数の結合エミュレーションを追加 (`allow_experimental_multiple_joins_emulation` 設定)。 [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([アルテム-ズイコフ](https://github.com/4ertus2)) + +#### バグ修正 {#bug-fixes-21} + +- 作る `compiled_expression_cache_size` 設定により限定のデフォルトの低メモリを消費する。 [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([アレサピン](https://github.com/alesapin)) +- レプリケートされたテーブルの変更を実行するスレッドと、ZooKeeperから設定を更新するスレッドでハングアップするバグを修正しました。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 分散型変更タスクを実行するときの競合状態を修正しました。 競合状態により、複数のレプリカがタスクを実行しようとし、ZooKeeperエラーで失敗したものを除くすべてのレプリカが発生しました。 [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- ときにバグを修正 `from_zk` zookeeperへの要求がタイムアウトした後、config要素が更新されませんでした。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 修正のバグが間違っているとの接頭辞IPv4サブネットマスクを商品化しました。 [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([アレサピン](https://github.com/alesapin)) +- 固定クラッシュ (`std::terminate`)まれに、リソースの消耗により新しいスレッドが作成できない場合があります。 [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- ときにバグを修正 `remote` inに対して間違った制限が使用された場合の表関数の実行 `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([アレサピン](https://github.com/alesapin)) +- Netlinkソケットの漏れを修正しました。 これらは削除されなかったプールに配置され、現在のすべてのソケットが使用されていたときに新しいスレッドの開始時に新しいソケットが作成 [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 閉じるとバグを修正 `/proc/self/fd` すべてのfdsが読み取られた前のディレクトリ `/proc` フォーク後 `odbc-bridge` サブプロセス [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([アレサピン](https://github.com/alesapin)) +- 主キーの使用文字列の場合にuint単調変換に文字列を修正しました。 [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([冬張](https://github.com/zhang2014)) +- 整数変換関数の単調性の計算エラーを修正しました。 [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- で固定segfault `arrayEnumerateUniq`, `arrayEnumerateDense` いくつかの無効な引数の場合の関数。 [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- StorageMergeでubを修正しました。 [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([アモス鳥](https://github.com/amosbird)) +- 関数内の固定segfault `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定エラー:関数 `round`, `floor`, `trunc`, `ceil` 整数引数と大きな負のスケールで実行すると、偽の結果を返す可能性があります。 [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- によって誘発されるバグを修正 ‘kill query sync’ これはコアダンプにつながります。 [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([マブルディーペッカー](https://github.com/fancyqlx)) +- 空の複製キューの後に長い遅延のバグを修正しました。 [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([アレサピン](https://github.com/alesapin)) +- テーブルに挿入する場合の過剰なメモリ使用量を修正しました `LowCardinality` 主キー。 [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 固定 `LowCardinality` のシリアル化 `Native` 空の配列の場合の書式。 [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- に修正結果が異なる単一LowCardinality数値カラムです。 [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 低カーディナリティキーを持つ特殊化された集計を修正しました `compile` 設定が有効になっています)。 [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 固定ユーザとパスワードを転送のための複製のテーブルのクエリ. [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([アレサピン](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) +- 固定非常に珍しい競合状態とされるようにすることが一覧表の辞書データベースをリロードを生成する事ができます。 [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- に修正が発生した場合の結果を使用したとROLLUPはュールをご用意しております。 [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([サム-チョウ](https://github.com/reflection)) +- クエリの列エイリアスを修正しました。 `JOIN ON` 構文と分散テーブル。 [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([冬張](https://github.com/zhang2014)) +- 内部実装のエラーを修正しました。 `quantileTDigest` (Artem Vakhrushevによって発見された)。 このエラーはClickHouseでは決して発生せず、ClickHouseコードベースをライブラリとして直接使用する人にのみ関連していました。 [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 改善 {#improvements-6} + +- のサポート `IF NOT EXISTS` で `ALTER TABLE ADD COLUMN` と一緒に文 `IF EXISTS` で `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([ボリス-グランヴォー](https://github.com/bgranvea)) +- 関数 `parseDateTimeBestEffort`:形式のサポート `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` と同様。 [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- `CapnProtoInputStream` 今ギザギザの構造をサポート。 [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([稼動に伴Hultgren Van Der Horst](https://github.com/Miniwoffer)) +- ユーザビリティ向上に追加チェックがサーバプロセスからのデータディレクトリはオーナーを想定しています。 できない開始のサーバーからのルートデータが得られない場合には所属非rootユーザーです。 [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([セルゲイ-v-ガルツェフ](https://github.com/sergey-v-galtsev)) +- より良いロジックの確認に必要なカラムの中での分析クエリを処理するクラウドの場合が仲間入り。 [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([アルテム-ズイコフ](https://github.com/4ertus2)) +- 単一のサーバーに多数の分散テーブルがある場合の接続数を減少させました。 [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([冬張](https://github.com/zhang2014)) +- サポートされている合計行 `WITH TOTALS` ODBCドライバのクエリ。 [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([マクシム-コリツキー](https://github.com/nightweb)) +- 使用を許可 `Enum`if関数内の整数としてのs。 [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([イワン](https://github.com/abyss7)) +- 追加 `low_cardinality_allow_in_native_format` 設定。 無効の場合は、使用しないでください `LowCadrinality` 入力 `Native` 形式。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([コチェトヴニコライ](https://github.com/KochetovNicolai)) +- 削除の冗長化物からの集計表現のキャッシュの低メモリ使用量 [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([アレサピン](https://github.com/alesapin)) +- それをチェック追加 `SET send_logs_level = 'value'` クエリーを受け適切な値です。 [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([サビヤニン-マキシム](https://github.com/s-mx)) +- 型変換関数の固定データ型チェック。 [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([冬張](https://github.com/zhang2014)) + +#### 性能の向上 {#performance-improvements-5} + +- MergeTree設定を追加する `use_minimalistic_part_header_in_zookeeper`. 有効になっている場合、複製のテーブル店舗のコンパクト部分のメタデータの一部znode. これは著しく低下するので、飼育係スナップショットサイズ(場合には、あらゆるテーブルのカラム). この設定を有効にすると、サポートされていないバージョンにダウングレードすることはできません。 [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 関数のDFAベースの実装を追加する `sequenceMatch` と `sequenceCount` パターンに時間が含まれていない場合。 [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- 整数シリアル化のパフォーマンス向上。 [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([アモス鳥](https://github.com/amosbird)) +- ゼロ左パディングPODArrayように-1要素は常に有効とゼロになります。 これは、オフセットの分岐のない計算に使用されます。 [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([アモス鳥](https://github.com/amosbird)) +- 元に戻した `jemalloc` 性能低下につながるバージョン。 [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) + +#### 下位互換性のない変更 {#backward-incompatible-changes-2} + +- 文書化されていない機能を削除 `ALTER MODIFY PRIMARY KEY` それはによって取って代わられたので `ALTER MODIFY ORDER BY` コマンド [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([アレックス-ザテレピン](https://github.com/ztlpn)) +- 削除された機能 `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Result of typeでのスカラーサブクエリの使用を禁止する `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([イワン](https://github.com/abyss7)) + +#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-6} + +- PowerPCのサポートを追加 (`ppc64le`)ビルド。 [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([ダニラ-クテニン](https://github.com/danlark1)) +- ステートフル機能テストは、public available datasetで実行されます。 [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 固定エラー時にサーバーはできませんの `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` Dockerまたはsystemd-nspawn内のメッセージ。 [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 更新 `rdkafka` v1.0.0-RC5へのライブラリ。 生のCインタフェースの代わりにcppkafkaを使用しました。 [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([イワン](https://github.com/abyss7)) +- 更新 `mariadb-client` 図書館 ウブサンによって発見された問題の一つを修正しました。 [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- UBSanビルドのいくつかの修正。 [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- UBSanビルドによるテストのコミットごとの実行を追加しました。 +- PVS-Studio static analyzerのコミットごとの実行を追加しました。 +- PVS-Studioで見つかったバグを修正しました。 [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Glibcの互換性の問題を修正しました。 [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Dockerイメージを18.10に移動し、glibc\>=2.28の互換性ファイルを追加します [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([アレサピン](https://github.com/alesapin)) +- 追加環境変数の場合はユーザーを行わないchownディレクトリをサーバー Dockerイメージです。 [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([アレサピン](https://github.com/alesapin)) +- からの警告のほとんどを有効に `-Weverything` クラング 有効 `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- Clang8でのみ使用できるいくつかの警告を追加しました。 [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- リンク先 `libLLVM` 共有リンクを使用する場合、個々のLLVM libに対してではなく。 [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([オリヴェイ-デシュ](https://github.com/orivej)) +- テスト画像のサニタイザー変数を追加しました。 [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([アレサピン](https://github.com/alesapin)) +- `clickhouse-server` debianパッケージは推奨します `libcap2-bin` 使用するパッケージ `setcap` 機能を設定するためのツール。 これは任意です。 [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 改善作成時に固定。 [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([プロラー](https://github.com/proller)) +- ハッシュ関数の性能テストを追加しました。 [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([フィリモノフ](https://github.com/filimonov)) +- 周期ライブラリの依存関係を修正しました。 [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([プロラー](https://github.com/proller)) +- 利用可能なメモリが少ないコンパイルの改善。 [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([プロラー](https://github.com/proller)) +- パフォーマン `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([アレクセイ-ミロヴィドフ](https://github.com/alexey-milovidov)) +- 下のコメントと文字列リテラルのスペルミスを修正しました `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([舞羽(まいは](https://github.com/maiha)) +- コメントの修正タイプミス。 [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([エフゲニー-プラウダ](https://github.com/kvinty)) + +## [2018年の変更履歴](./2018.md#clickhouse-release-18-16) {#changelog-for-2018} diff --git a/docs/ja/whats-new/changelog/index.md b/docs/ja/whats-new/changelog/index.md new file mode 100644 index 00000000000..ac12f2d7e4f --- /dev/null +++ b/docs/ja/whats-new/changelog/index.md @@ -0,0 +1,9 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u5909\u66F4\u5C65\u6B74" +toc_priority: 74 +toc_title: '2020' +--- + +{% include "content/changelog.md" %} diff --git a/docs/ja/whats-new/index.md b/docs/ja/whats-new/index.md new file mode 100644 index 00000000000..f6775abee3c --- /dev/null +++ b/docs/ja/whats-new/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u65B0\u7740\u60C5\u5831" +toc_priority: 72 +--- + + diff --git a/docs/ja/whats-new/roadmap.md b/docs/ja/whats-new/roadmap.md new file mode 100644 index 00000000000..468d4599b8f --- /dev/null +++ b/docs/ja/whats-new/roadmap.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 74 +toc_title: "\u30ED\u30FC\u30C9" +--- + +# ロード {#roadmap} + +## Q1 2020 {#q1-2020} + +- ロールベースのアクセス制御 + +## Q2 2020 {#q2-2020} + +- 外部認証サービスとの統合 +- 資源のプールのためのより精密な分布のクラスター能力とユーザー + +{## [元の記事](https://clickhouse.tech/docs/en/roadmap/) ##} diff --git a/docs/ja/whats-new/security-changelog.md b/docs/ja/whats-new/security-changelog.md new file mode 100644 index 00000000000..d56b465acfa --- /dev/null +++ b/docs/ja/whats-new/security-changelog.md @@ -0,0 +1,76 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 76 +toc_title: "\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u5909\u66F4\u5C65\u6B74" +--- + +## ClickHouseリリース19.14.3.3,2019-09-10で修正 {#fixed-in-clickhouse-release-19-14-3-3-2019-09-10} + +### CVE-2019-15024 {#cve-2019-15024} + +Аn attacker that has write access to ZooKeeper and who ican run a custom server available from the network where ClickHouse runs, can create a custom-built malicious server that will act as a ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from the malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. + +クレジット:Yandexの情報セキュリティチームのEldar Zaitov + +### CVE-2019-16535 {#cve-2019-16535} + +Аn OOB read, OOB write and integer underflow in decompression algorithms can be used to achieve RCE or DoS via native protocol. + +クレジット:Yandexの情報セキュリティチームのEldar Zaitov + +### CVE-2019-16536 {#cve-2019-16536} + +スタックオーバーフローへのDoSによっても実行させることができ、悪意のある認証クライアント + +クレジット:Yandexの情報セキュリティチームのEldar Zaitov + +## ClickHouseリリース19.13.6.1,2019-09-20で修正 {#fixed-in-clickhouse-release-19-13-6-1-2019-09-20} + +### CVE-2019-18657 {#cve-2019-18657} + +テーブル関数 `url` この脆弱性により、攻撃者は要求に任意のHTTPヘッダーを挿入することができました。 + +クレジット: [ニキータ-チホミロフ](https://github.com/NSTikhomirov) + +## ClickHouseリリース18.12.13、2018-09-10で修正されました {#fixed-in-clickhouse-release-18-12-13-2018-09-10} + +### CVE-2018-14672 {#cve-2018-14672} + +機能搭載CatBoostモデルの可路のフォーカストラバーサル読書任意のファイルをエラーメッセージが返されます。 + +クレジット:Yandexの情報セキュリティチームのアンドレイKrasichkov + +## ClickHouseリリース18.10.3、2018-08-13で修正されました {#fixed-in-clickhouse-release-18-10-3-2018-08-13} + +### CVE-2018-14671 {#cve-2018-14671} + +unixODBC許容荷重任意の共有オブジェクトからのファイルシステムにおけるリモートでコードが実行の脆弱性が存在します。 + +クレジット:Yandex情報セキュリティチームのAndrey KrasichkovとEvgeny Sidorov + +## ClickHouseリリース1.1.54388、2018-06-28で修正 {#fixed-in-clickhouse-release-1-1-54388-2018-06-28} + +### CVE-2018-14668 {#cve-2018-14668} + +“remote” テーブル関数で任意のシンボルを許可 “user”, “password” と “default\_database” 分野を横断プロトコルの要求偽造攻撃であった。 + +クレジット:Yandexの情報セキュリティチームのアンドレイKrasichkov + +## ClickHouseリリース1.1.54390、2018-07-06で修正 {#fixed-in-clickhouse-release-1-1-54390-2018-07-06} + +### CVE-2018-14669 {#cve-2018-14669} + +ClickHouse MySQLクライアントがあった “LOAD DATA LOCAL INFILE” 機能が有効のとき、悪意のあるMySQLデータベース読む任意のファイルからの接続ClickHouseサーバーです。 + +クレジット:Yandex情報セキュリティチームのAndrey KrasichkovとEvgeny Sidorov + +## ClickHouseリリース1.1.54131、2017-01-10で修正 {#fixed-in-clickhouse-release-1-1-54131-2017-01-10} + +### CVE-2018-14670 {#cve-2018-14670} + +Debパッケージ内の不適切な構成は、データベースの不正使用につながる可能性があります。 + +クレジット:英国の国立サイバーセキュリティセンター(NCSC) + +{## [元の記事](https://clickhouse.tech/docs/en/security_changelog/) ##} diff --git a/docs/ja/whats_new/changelog/2017.md b/docs/ja/whats_new/changelog/2017.md deleted file mode 100644 index ba53fbcf9d3..00000000000 --- a/docs/ja/whats_new/changelog/2017.md +++ /dev/null @@ -1,268 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 79 -toc_title: '2017' ---- - -### ClickHouseリリース1.1.54327、2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} - -このリリ: - -- 固定バグでレースの条件で接続文字列の構文は以下のようにこのデータが失われます。 この問題はバージョン1.1.54310および1.1.54318に影響します。 ご利用の場合これらのバージョンとの複製のテーブルを更新することが強く推奨されます。 この問題にログ警告メッセージのように `Part ... from own log doesn't exist.` この問題は、これらのメッセージがログに表示されない場合でも関連します。 - -### ClickHouseリリース1.1.54318、2017-11-30 {#clickhouse-release-1-1-54318-2017-11-30} - -このリリ: - -- SummingMergeTreeエンジンのマージ中に誤った行の削除が行われていた問題を修正しました -- 複雑でないmergetreeエンジンのメモリリークを修正しました -- MergeTreeエンジンで頻繁に挿入されるパフォーマンスの低下を修正 -- レプリケーションキューの実行を停止する問題を修正しました -- サーバーログの固定回転とアーカイブ - -### ClickHouseリリース1.1.54310、2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} - -#### 新しい機能: {#new-features} - -- カスタムパーティショニングキーのmergetree家族のテーブルエンジンです。 -- [カフカname](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) テーブルエンジン。 -- 読み込みのサポートを追加 [CatBoost](https://catboost.yandex/) モデルとそれらをClickHouseに格納されたデータに適用する。 -- UTCから非整数オフセットのタイムゾーンのサポートが追加されました。 -- 時間間隔による算術演算のサポートが追加されました。 -- Date型とDateTime型の値の範囲は、2105年に拡張されます。 -- を追加しました `CREATE MATERIALIZED VIEW x TO y` query(マテリアライズドビューのデータを格納するための既存のテーブルを指定します)。 -- を追加しました `ATTACH TABLE` 引数なしのクエリ。 -- SummingMergeTreeテーブルのマップで終わる名前を持つ入れ子になった列の処理ロジックが、sumMap集計関数に抽出されました。 これで、このような列を明示的に指定できます。 -- IP trie辞書の最大サイズは128Mのエントリに増加します。 -- GetSizeOfEnumType関数を追加しました。 -- SumWithOverflow集計関数を追加しました。 -- Cap'n Proto入力形式のサポートが追加されました。 -- では、今までのカスタマイズの圧縮レベル使用時のzstdアルゴリズムです。 - -#### 下位互換性のない変更: {#backward-incompatible-changes} - -- メモリ以外のエンジンを使用して一時テーブルを作成することはできません。 -- ビューまたはmaterializedviewエンジンでテーブルを明示的に作成することはできません。 -- 中表を作成し、新しいチェックを確認し、サンプリングキー表現が含まれ、その有効なタイプを利用します。 - -#### バグ修正: {#bug-fixes} - -- 分散テーブルに同期的に挿入するときのハングアップを修正しました。 -- レプリケートされたテーブル内の部品の追加と削除を修正しました。 -- マテリアライズドビューに挿入されたデータは、不要な重複排除を受けません。 -- ローカルレプリカが遅延し、リモートレプリカが使用できない分散テーブルへのクエリを実行しても、エラーは発生しません。 -- ユーザーにはアクセス許可は必要ありません。 `default` 一時テーブルを作成するデータベース。 -- 固定チを指定する場合は、配列型な論争することができます。 -- 固定hangups時のディスク容量を含むサーバのログします。 -- Unixエポックの最初の週のtoRelativeWeekNum関数のオーバーフローを修正しました。 - -#### ビルドの改善: {#build-improvements} - -- いくつかのサードパーティのライブラリ(特にpoco)が更新され、git submodulesに変換されました。 - -### ClickHouseリリース1.1.54304,2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} - -#### 新しい機能: {#new-features-1} - -- ネイティブプロトコルでのtlsサポート(有効にするには、 `tcp_ssl_port` で `config.xml` ). - -#### バグ修正: {#bug-fixes-1} - -- `ALTER` のための複製のテーブル現しようと走り出しています。 -- 固定波データを読み込むときに設定 `preferred_block_size_bytes=0.` -- の固定クラッシュ `clickhouse-client` 押すとき `Page Down` -- 特定の複雑なクエリの正しい解釈 `GLOBAL IN` と `UNION ALL` -- `FREEZE PARTITION` 常に今原子的に動作します。 -- 空のpost要求は、コード411で応答を返すようになりました。 -- のような式のための固定解釈エラー `CAST(1 AS Nullable(UInt8)).` -- 読み込み時のエラーを修正 `Array(Nullable(String))` からの列 `MergeTree` テーブル。 -- 固定表の構文解析時にクエリのように `SELECT dummy AS dummy, dummy AS b` -- ユーザーは無効で正しく更新されます `users.xml` -- 実行可能ディクショナリがゼロ以外の応答コードを返す場合の正しい処理。 - -### ClickHouseリリース1.1.54292、2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} - -#### 新しい機能: {#new-features-2} - -- を追加しました `pointInPolygon` 座標平面上の座標を操作するための関数。 -- を追加しました `sumMap` 次のような配列の合計を計算するための集約関数 `SummingMergeTree`. -- を追加しました `trunc` 機能。 丸め関数のパフォーマンスの向上 (`round`, `floor`, `ceil`, `roundToExp2` を正の論理をどのように。 のロジックを変更 `roundToExp2` 分数と負の数の関数。 -- ClickHouseの実行可能ファイルはlibcのバージョンにあまり依存しません。 同じClickHouseの実行可能ファイルは、Linuxシステムの多種多様で実行することができます。 コンパイルされたクエリを使用するときにはまだ依存関係があります(設定 `compile = 1` デフォルトでは使用されません)。 -- クエリの動的コンパイルに要する時間を短縮しました。 - -#### バグ修正: {#bug-fixes-2} - -- 時々生成エラーを修正しました `part ... intersects previous part` メッセージとレプリカの一貫性の低下。 -- 固定エラーの原因となったサーバをロックした場合飼育係できなかった時のシャットダウンしました。 -- レプリカの復元時に過剰なログを削除。 -- ユニオンすべての実装でエラーを修正しました。 -- ブロック内の最初の列に配列型がある場合に発生したconcat関数のエラーを修正しました。 -- の進捗を正しく表示されます。テーブルをマージする。 - -### ClickHouseリリース1.1.54289、2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} - -#### 新しい機能: {#new-features-3} - -- `SYSTEM` サーバ管理のクエリ: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. -- 配列を操作するための関数を追加: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. -- 追加 `root` と `identity` ZooKeeper設定のパラメーターです。 これにより、同じZooKeeperクラスター上の個々のユーザーを分離できます。 -- 集計関数の追加 `groupBitAnd`, `groupBitOr`、と `groupBitXor` (互換性のために、それらは名前の下にも利用可能です `BIT_AND`, `BIT_OR`、と `BIT_XOR`). -- 外部の辞書からロード可能でmysqlを指定するソケットのファイルシステム. -- 外部辞書はmysqlからssl経由でロードできます (`ssl_cert`, `ssl_key`, `ssl_ca` パラメータ)。 -- を追加しました `max_network_bandwidth_for_user` ユーザーごとのクエリの全体的な帯域幅の使用を制限する設定。 -- のサポート `DROP TABLE` 一時テーブルの場合。 -- 読書のためのサポート `DateTime` Unixのタイムスタンプ形式の値 `CSV` と `JSONEachRow` フォーマット。 -- 分散クエリの遅延レプリカは、既定で除外されるようになりました(既定のしきい値は5分)。 -- 継続的に実行されるクエリでは、alterクエリが無期限にブロックされることはありません。 -- 設定するオプション `umask` 設定ファイルで。 -- クエリのパフォーマンスの向上 `DISTINCT` . - -#### バグ修正: {#bug-fixes-3} - -- ZooKeeperの古いノードを削除するプロセスを改善しました。 以前は、非常に頻繁な挿入があった場合、古いノードが削除されなかったことがあり、サーバーのシャットダウンが遅くなっていました。 -- ZooKeeperへの接続のためのホストを選択する際に固定ランダム化。 -- レプリカがlocalhostの場合、分散クエリでの遅延レプリカの除外を修正しました。 -- Aのデータ部分エラーを修正しました `ReplicatedMergeTree` テーブ `ALTER MODIFY` aの要素に `Nested` 構造。 -- 選択クエリの原因となるエラーを修正しました “hang”. -- 分散ddlクエリの改善。 -- クエリを修正 `CREATE TABLE ... AS `. -- でデッドロックを解決しました `ALTER ... CLEAR COLUMN IN PARTITION` のためのクエリ `Buffer` テーブル。 -- の無効なデフォルト値を修正しました `Enum` s(最小値の代わりに0)を使用する場合、 `JSONEachRow` と `TSKV` フォーマット。 -- 解決の姿ゾンビプロセスが辞書を使いながら、 `executable` ソース。 -- ヘッドクエリのための固定segfault。 - -#### 改善ワークフローの開発と組み立てclickhouse: {#improved-workflow-for-developing-and-assembling-clickhouse} - -- を使用することができ `pbuilder` ClickHouseを構築する。 -- を使用することができ `libc++` 代わりに `libstdc++` Linux上のビルドの場合。 -- 静的コード分析ツールを使用するための手順を追加: `Coverage`, `clang-tidy`, `cppcheck`. - -#### ご注意ください: {#please-note-when-upgrading} - -- これで、mergetree設定のデフォルト値が大きくなりました `max_bytes_to_merge_at_max_space_in_pool` (マージするデータ部分の最大合計サイズ(バイト単位)):100GiBから150GiBに増加しました。 この結果、大型の合併-走行後のサーバグの原因になりの増加に負荷をディスクサブシステムです。 サーバー上で利用可能な空き領域が、実行中のマージの合計量の倍未満である場合、小さなデータ部分のマージを含め、他のすべてのマージが実行を停止します。 その結果、INSERTクエリはメッセージで失敗します “Merges are processing significantly slower than inserts.” を使用 `SELECT * FROM system.merges` 状況を監視するためのクエリ。 また点検できます `DiskSpaceReservedForMerge` のメトリック `system.metrics` テーブル、またはグラファイト。 大きなマージが完了すると問題は解決するので、これを修正するために何もする必要はありません。 これが受け入れられない場合は、以前の値を復元することができます `max_bytes_to_merge_at_max_space_in_pool` 設定。 これを行うには、 設定のセクション。xml、セット ``` ``107374182400 ``` サーバーを再起動します。 - -### ClickHouseリリース1.1.54284,2017-08-29 {#clickhouse-release-1-1-54284-2017-08-29} - -- これは以前の1.1.54282リリースのバグ修正リリースです。 それはzookeeperの部品ディレクトリに漏れを修正します。 - -### ClickHouseリリース1.1.54282、2017-08-23 {#clickhouse-release-1-1-54282-2017-08-23} - -このリリ: - -- 固定 `DB::Exception: Assertion violation: !_path.empty()` 分散テーブルに挿入するとき。 -- 入力データが';'で始まる場合、rowbinary形式で挿入時の解析を修正しました。 -- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). - -### Clickhouseリリース1.1.54276,2017-08-16 {#clickhouse-release-1-1-54276-2017-08-16} - -#### 新しい機能: {#new-features-4} - -- 選択クエリのセクションでオプションを追加しました。 クエリ例: `WITH 1+1 AS a SELECT a, a*a` -- すべてのデータがすべてのシャードに保存された後にのみ、okが返されます。 これは、insert\_distributed\_sync=1の設定によって有効になります。 -- 16バイトの識別子を扱うためのuuidデータ型を追加しました。 -- タブローとの互換性のためにchar、floatおよび他のタイプのエイリアスを追加しました。 -- 時間を数値に変換する関数toyyyyymm、toyyyymmdd、およびtoyyyymmddhhmmssを追加しました。 -- IPアドレス(ホスト名と共に)を使用して、クラスタ化されたDDLクエリのサーバーを識別できます。 -- 関数内の非定数引数と負のオフセットのサポートが追加されました `substring(str, pos, len).` -- のmax\_sizeパラメーターを追加しました。 `groupArray(max_size)(column)` 集約関数、およびその性能を最適化しました。 - -#### 主な変更点: {#main-changes} - -- セキュリティの改善:すべてのサーバーファイルは0640権限で作成されます(変更できます 設定パラメータ)。 -- 無効な構文のクエリの改善されたエラーメッセージ。 -- 低メモリ消費をとした場合の性能改善の統合大分mergetreeデータです。 -- ReplacingMergeTreeエンジンのデータマージのパフォーマンスが大幅に向上しました。 -- 性能向上のための非同期に挿入しますから分散型のテーブルを組み合わせで複数のソースしました。 この機能を有効にするには、distributed\_directory\_monitor\_batch\_inserts=1という設定を使用します。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-1} - -- の集約状態のバイナリ形式を変更しました `groupArray(array_column)` 配列の関数。 - -#### 変更の完全なリスト: {#complete-list-of-changes} - -- を追加しました `output_format_json_quote_denormals` これにより、nanとinfの値をJSON形式で出力することができます。 -- 最適化したストリーム配置の場合を読み込んで配布します。 -- 値が変更されない場合は、readonlyモードで設定を行うことができます。 -- Preferred\_block\_size\_bytes設定で指定されたブロックサイズの制限を満たすために、MergeTreeエンジンの非整数granules粒を取得する機能を追加しました。 のための消費量を削減RAMを増やキャッシュの地域が処理クエリーテーブルの大きい。 -- 次のような式を含むインデックスの効率的な使用 `toStartOfHour(x)` のような条件の場合 `toStartOfHour(x) op сonstexpr.` -- MergeTreeエンジンの新しい設定(configのmerge\_treeセクション)を追加しました。xml): - - replicated\_deduplication\_window\_secondsは、レプリケートされたテーブルの挿入の重複除外に使用できる秒数を設定します。 - - cleanup\_delay\_periodは、古いデータを削除するためにクリーンアップを開始する頻度を設定します。 - - replicated\_can\_become\_leaderでは、レプリカがリーダーにならないようにすることができます(マージの割り当て)。 -- 加速の清掃除時代遅れからのデータの飼育係. -- クラスタ化されたddlクエリの複数の改善と修正。 特に重要なのは、クラスタ内のサーバーからの応答を待つ時間を制限する新しい設定distributed\_ddl\_task\_timeoutです。 ddl要求がすべてのホストで実行されていない場合、応答にタイムアウトエラーが含まれ、要求は非同期モードで実行されます。 -- サーバーログにおけるスタックトレースの表示の改善。 -- を追加しました “none” 圧縮方法の値。 -- Configで複数のdictionaries\_configセクションを使用できます。xmlだ -- ファイルシステムのソケットを介してmysqlに接続することは可能です。 -- システム。部品表は、新しい列に関する情報はサイズメッセージが表示され、バイトです。 - -#### バグ修正: {#bug-fixes-4} - -- マージテーブルを使用する分散テーブルは、現在の条件と選択クエリのために正しく動作します `_table` フィールド。 -- ReplicatedMergeTreeでデータパーツをチェックする際の競合状態を修正しました。 -- 上の固定可能な凍結 “leader election” サーバーを起動するとき。 -- データソースのローカルレプリカを使用する場合、max\_replica\_delay\_for\_distributed\_queries設定は無視されました。 これは修正されました。 -- の誤った動作を修正しました `ALTER TABLE CLEAR COLUMN IN PARTITION` 既存の列以外の列をクリーンアップしようとした場合。 -- 空の配列または文字列を使用する場合、multif関数の例外を修正しました。 -- 固定の過剰なメモリ割当ての場合deserializingネイティブ形式です。 -- トライ辞書の不正な自動更新を修正しました。 -- 固定の例外実行時にクエリを処理するクラウドの場合、group by節からmergeテーブル使用時のサンプルです。 -- Distributed\_aggregation\_memory\_efficient=1を使用したときにGROUP BYがクラッシュする問題を修正しました。 -- これで、データベースを指定できます。inとjoinの右側にあるテーブル。 -- 並列集約に使用されるスレッドが多すぎます。 これは修正されました。 -- どのように固定 “if” 関数は、FixedString引数で動作します。 -- 重量が0のシャードの分散テーブルから誤って処理されたものを選択します。 これは修正されました。 -- 実行中 `CREATE VIEW IF EXISTS no longer causes crashes.` -- Input\_format\_skip\_unknown\_fields=1が設定され、負の数がある場合の動作が正しくない問題を修正しました。 -- の無限ループを修正しました `dictGetHierarchy()` 辞書に無効なデータがある場合は機能します。 -- 固定 `Syntax error: unexpected (...)` INまたはJOIN句およびMergeテーブル内のサブクエリを使用して分散クエリを実行するときのエラー。 -- 辞書テーブルからの選択クエリの誤った解釈を修正しました。 -- 修正された “Cannot mremap” 2億以上の要素を持つinおよびJOIN句で配列を使用するときにエラーが発生します。 -- ソースとしてmysqlと辞書のフェイルオーバーを修正しました。 - -#### 改善ワークフローの開発と組み立てclickhouse: {#improved-workflow-for-developing-and-assembling-clickhouse-1} - -- ビルドはarcadiaで組み立てることができます。 -- Gcc7を使用してClickHouseをコンパイルできます。 -- Ccache+distccを使用した並列ビルドの方が高速になりました。 - -### ClickHouseリリース1.1.54245,2017-07-04 {#clickhouse-release-1-1-54245-2017-07-04} - -#### 新しい機能: {#new-features-5} - -- 分散ddl(例, `CREATE TABLE ON CLUSTER`) -- 複製されたクエリ `ALTER TABLE CLEAR COLUMN IN PARTITION.` -- エンジンのための辞書のテーブル(アクセスの辞書データの形式で表)。 -- 辞書データベースエンジン(タイプのデータベースに自動的に辞書で使用可能なテーブルを接続外部辞書). -- ソースに要求を送信することによって、辞書の更新を確認できます。 -- 修飾された列名 -- 二重引用符を使用して識別子を引用する。 -- セッションを行うhttpのインタフェース。 -- レプリケートされたテーブルの最適化クエリは、リーダーだけでなく実行できます。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-2} - -- 削除セットグローバル。 - -#### 軽微な変更: {#minor-changes} - -- アラートがトリガーされると、ログは完全なスタックトレースを出力します。 -- 起動時に破損/余分なデータパーツの数の検証を緩和しました(誤検出が多すぎます)。 - -#### バグ修正: {#bug-fixes-5} - -- 接続不良を修正しました “sticking” 分散テーブルに挿入するとき。 -- GLOBAL INは、分散テーブルを参照するMergeテーブルからのクエリに対して機能します。 -- Google Compute Engine仮想マシンでコアの数が正しくないことが検出されました。 これは修正されました。 -- キャッシュされた外部ディクショナリの実行可能ソースの動作の変更 -- ヌル文字を含む文字列の比較を修正しました。 -- 定数を持つfloat32主キーフィールドの比較を修正しました。 -- 従来、不正確な見積りのサイズの分野が過度に大きな分配すべき。 -- ALTERを使用してテーブルに追加されたNull許容列を照会するとクラッシュする問題を修正しました。 -- 行の数が制限よりも小さい場合、null可能な列でソートするとクラッシュする問題を修正しました。 -- 定数値のみで構成されるorder byサブクエリを修正しました。 -- については、従来、複製テーブルが残る無効な状態にした後、失敗した下表に示す。 -- 空の結果を持つスカラーサブクエリのエイリアスは失われなくなりました。 -- .soファイルが破損した場合、コンパイルを使用したクエリはエラーで失敗しません。 diff --git a/docs/ja/whats_new/changelog/2018.md b/docs/ja/whats_new/changelog/2018.md deleted file mode 100644 index be61253c022..00000000000 --- a/docs/ja/whats_new/changelog/2018.md +++ /dev/null @@ -1,1063 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 78 -toc_title: '2018' ---- - -## ClickHouseリリース18.16 {#clickhouse-release-18-16} - -### ClickHouseリリース18.16.1、2018-12-21 {#clickhouse-release-18-16-1-2018-12-21} - -#### バグ修正: {#bug-fixes} - -- ODBCソースで辞書を更新する際の問題を引き起こしたエラーを修正しました。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- 集計関数のjitコンパイルは、lowcardinality列で動作するようになりました。 [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) - -#### 改善: {#improvements} - -- を追加しました `low_cardinality_allow_in_native_format` 設定(デフォルトで有効)。 無効にすると、LowCardinality列はSELECTクエリでは通常の列に変換され、INSERTクエリでは通常の列が必要になります。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) - -#### ビルドの改善: {#build-improvements} - -- MacOSとARM上のビルドの修正。 - -### ClickHouseリリース18.16.0、2018-12-14 {#clickhouse-release-18-16-0-2018-12-14} - -#### 新しい機能: {#new-features} - -- `DEFAULT` 式の評価のために欠けるのはデータの読み込みに半構造の入力形式 (`JSONEachRow`, `TSKV`). この機能は、 `insert_sample_with_metadata` 設定。 [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) -- その `ALTER TABLE` クエリは現在、 `MODIFY ORDER BY` テーブル列を追加または削除するときの並べ替えキーの変更のアクション。 これは、 `MergeTree` 家族を追加タスクの場合はこのソートキー、など `SummingMergeTree`, `AggregatingMergeTree`、というように。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) -- のテーブルのため `MergeTree` これで、別の並べ替えキーを指定できます (`ORDER BY`)および索引 (`PRIMARY KEY`). ソートキーはインデックスよりも長くできます。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) -- を追加しました `hdfs` テーブル機能および `HDFS` テーブルエンジンの輸出入データHDFS. [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) -- Base64での作業のための機能を追加しました: `base64Encode`, `base64Decode`, `tryBase64Decode`. [Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3350) -- これで、パラメータを使用しての精度を設定できます `uniqCombined` 集約関数(HyperLogLogセルの数を選択する)。 [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) -- を追加しました `system.contributors` ClickHouseでコミットを行ったすべてのユーザーの名前を含むテーブル。 [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) -- のパーティションを省略する機能を追加しました `ALTER TABLE ... FREEZE` クエリをバックアップするには、全ての仕切ります。 [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) -- 追加 `dictGet` と `dictGetOrDefault` 戻り値の型を指定する必要のない関数。 タイプは、辞書記述から自動的に決定されます。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3564) -- これで、テーブルの説明で列のコメントを指定し、次の方法で変更できます `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) -- 読書はのために支えられる `Join` 単純なキーで表を入力します。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3728) -- これで、オプションを指定できます `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join`、と `join_overflow_mode` 作成するとき `Join` タイプテーブル。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3728) -- を追加しました `joinGet` を使用できるようにする関数 `Join` 辞書のようにテーブルを入力します。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3728) -- を追加しました `partition_key`, `sorting_key`, `primary_key`、と `sampling_key` に列 `system.tables` テーブルのための情報を提供するテーブル鍵となります。 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- を追加しました `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key`、と `is_in_sampling_key` に列 `system.columns` テーブル。 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- を追加しました `min_time` と `max_time` に列 `system.parts` テーブル。 これらのカラムは人口がパーティショニングキーは表現で構成され `DateTime` 列。 [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) - -#### バグ修正: {#bug-fixes-1} - -- の修正とパフォーマンスの改善 `LowCardinality` データ型。 `GROUP BY` を使用して `LowCardinality(Nullable(...))`. の値を取得する `extremes`. 高階関数の処理。 `LEFT ARRAY JOIN`. 分散 `GROUP BY`. 返される関数 `Array`. の実行 `ORDER BY`. への書き込み `Distributed` テーブル(nicelulu)。 下位互換性のための `INSERT` 実装する古いクライアントからのクエリ `Native` プロトコル のサポート `LowCardinality` のために `JOIN`. した場合の性能改善作業を単一のストリームです。 [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) -- どのように固定 `select_sequential_consistency` オプションの作品。 従来、この設定が可能になり、不完全な結果が返され始めてから書き込み新しいパーティション [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) -- DDL実行時にデータベースが正しく指定されている `ON CLUSTER` クエリと `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- データベースが正しく指定されたサブクエリの中でも色々と用意が必要なもの。 [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) -- でバグを修正しました `PREWHERE` と `FINAL` のために `VersionedCollapsingMergeTree`. [7167bfd7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) -- 今すぐ使用できます `KILL QUERY` テーブルがロックされるのを待っているため、まだ開始されていないクエリを取り消す。 [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) -- クロックが真夜中に戻った場合の日付と時刻の計算を修正しました(これはイランで起こり、1981年から1983年にモスクワで起こりました)。 以前は、これは一日早く必要以上にリセットされる時間につながった、また、テキスト形式での日付と時刻の誤った書式設定を引き起こしました。 [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) -- いくつかのケースで修正されたバグ `VIEW` データベースを省略するサブクエリ。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3521) -- Aから同時に読み取るときの競合状態を修正しました `MATERIALIZED VIEW` を削除する。 `MATERIALIZED VIEW` 内部を締めないことが原因で `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) -- エラーを修正しました `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) -- 固定クエリ処理 `compile_expressions` オプションを有効にすると(このデフォルトで有効です). のような非決定的な定数式 `now` 機能は展開されなくなりました。 [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) -- 非定数スケールの引数を指定するとクラッシュする問題を修正しました `toDecimal32/64/128` 機能。 -- と配列を挿入しようとするとエラーを修正しました `NULL` の要素 `Values` 型の列にフォーマットする `Array` なし `Nullable` (もし `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) -- 固定連続エラーログイン `DDLWorker` ZooKeeperが利用できない場合。 [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) -- の戻り値の型を修正しました `quantile*` からの機能 `Date` と `DateTime` 引数のタイプ。 [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) -- 修正された `WITH` 式のない単純なエイリアスを指定する場合の句。 [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) -- 名前付きサブクエリと修飾された列名を持つクエリの処理を修正しました `enable_optimize_predicate_expression` は有効です。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3588) -- エラーを修正しました `Attempt to attach to nullptr thread group` マテリアライズドビューで作業する場合。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) -- 特定の不正な引数を渡すときにクラッシュを修正しました。 `arrayReverse` 機能。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- のバッファオーバーフローを修正 `extractURLParameter` 機能。 パフォーマンスの向上 ゼロバイトを含む文字列の正しい処理を追加しました。 [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) -- バッファオーバーフローを修正 `lowerUTF8` と `upperUTF8` 機能。 これらの関数を実行する機能を削除しました `FixedString` 型引数。 [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) -- 削除時のレアな競合状態を修正しました `MergeTree` テーブル。 [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) -- から読むときに競合状態を修正しました `Buffer` テーブルと同時に実行 `ALTER` または `DROP` ターゲットテーブルです。 [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) -- 場合は、固定segfault `max_temporary_non_const_columns` 制限を超えました。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### 改善: {#improvements-1} - -- サーバーは、処理された構成ファイルを `/etc/clickhouse-server/` ディレクトリ。 代わりに、それらを保存します `preprocessed_configs` ディレクトリ内 `path`. これはことを意味します `/etc/clickhouse-server/` ディレク `clickhouse` ユーザーが改善されます。 [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) -- その `min_merge_bytes_to_use_direct_io` optionはデフォルトで10GiBに設定されています。 MergeTreeファミリーからテーブルの大部分を形成するマージは、 `O_DIRECT` 過度のページキャッシュの削除を防止するモード。 [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) -- テーブルの非常に多数がある場合に加速サーバーの開始。 [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) -- 接続プールとhttpを追加しました `Keep-Alive` レプリカ間の接続のため。 [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) -- クエリの構文が無効な場合は、 `400 Bad Request` コードは `HTTP` インターフェイス(500返還し上げます。 [31bc680a](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) -- その `join_default_strictness` オプションは `ALL` 互換性のためにデフォルトで。 [120e2cbe](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) -- ログの削除先 `stderr` から `re2` 無効または複雑な正規表現のライブラリ。 [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) -- のために追加 `Kafka` テーブルエンジン:Kafkaからの読み取りを開始する前にサブスクリプションを確認します。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) -- その `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32`、と `murmurHash3_64` 関数は現在、任意の数の引数とタプルの形の引数に対して機能します。 [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) -- その `arrayReverse` 関数は現在、配列の任意のタイプで動作します。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- オプションのパラメーターを追加しました。 `timeSlots` 機能。 [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/3724) -- のために `FULL` と `RIGHT JOIN`、を `max_block_size` 設定は、右のテーブルからの非結合データのストリームに使用されます。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3699) -- を追加しました `--secure` コマンドライン引数in `clickhouse-benchmark` と `clickhouse-performance-test` TLSを有効にする。 [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) -- Aの構造のときの型変換 `Buffer` type tableは、コピー先のテーブルの構造と一致しません。 [Vitaly Baranov](https://github.com/ClickHouse/ClickHouse/pull/3603) -- を追加しました `tcp_keep_alive_timeout` オプションをキープアライブパケットの後、運動不足のために指定された時間間隔で出ています。 [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) -- パーティションキーの値の不要なクォートを削除しました。 `system.parts` テーブルが単一の列で構成されている場合。 [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) -- モジュロ機能はのために働きます `Date` と `DateTime` データ型。 [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) -- の同義語を追加しました `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR`、と `MID` 機能。 [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) いくつかの関数名は、SQL標準との互換性のために大文字と小文字を区別しません。 構文砂糖を追加しました `SUBSTRING(expr FROM start FOR length)` SQLとの互換性のために。 [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) -- に能力を追加しました `mlock` 対応するメモリページ `clickhouse-server` メモリから強制的に解放されないようにするための実行可能コード。 この機能はデフォルトでは無効です。 [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) -- した場合の性能改善からの読み出し `O_DIRECT` (とともに `min_bytes_to_use_direct_io` オプション有効)。 [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) -- の改善された性能 `dictGet...OrDefault` 定数キー引数と非定数既定の引数の関数。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3563) -- その `firstSignificantSubdomain` 関数は現在、ドメインを処理します `gov`, `mil`、と `edu`. [Igor Hatarist](https://github.com/ClickHouse/ClickHouse/pull/3601) パフォーマンスの向上 [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) -- 起動するためのカスタム環境変数を指定する機能 `clickhouse-server` を使用して `SYS-V init.d` 定義によるスクリプト `CLICKHOUSE_PROGRAM_ENV` で `/etc/default/clickhouse`. - [Pavlo Bashynskyi](https://github.com/ClickHouse/ClickHouse/pull/3612) -- Clickhouse-server initスクリプトの戻りコードを修正します。 [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) -- その `system.metrics` テーブルは今持っている `VersionInteger` メトリック、および `system.build_options` 追加された行があります `VERSION_INTEGER` これには、ClickHouseバージョンの数値形式が含まれます。 `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) -- 比較する能力を削除しました `Date` 型番号のようなエラーの可能性を回避 `date = 2018-12-17` 日付の前後の引用符が誤って省略されている場所。 [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) -- のようなステートフルな関数の動作を修正 `rowNumberInAllBlocks`. 彼らは以前に起因するクエリ分析中に開始に一つの数より大きかった結果を出力します。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3729) -- この `force_restore_data` ファイルは削除できません。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3794) - -#### ビルドの改善: {#build-improvements-1} - -- 更新された `jemalloc` 潜在的なメモリリークを修正するライブラリ。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3557) -- プロファイル `jemalloc` ビルドをデバッグするには、既定で有効になります。 [2cc82f5c](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) -- ときにのみ統合テストを実行する機能を追加しました `Docker` は、システムにインス [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) -- 選択クエリでファズ式テストを追加しました。 [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) -- コミットのストレステストを追加しました。 [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) -- Dockerイメージでclickhouse-serverを起動する方法を改善しました。 [Elghazal Ahmed](https://github.com/ClickHouse/ClickHouse/pull/3663) -- のためのdocker画像の追加支援のための初期化データベース用のファイルを `/docker-entrypoint-initdb.d` ディレクトリ。 [コンスタンチン-レベデフ](https://github.com/ClickHouse/ClickHouse/pull/3695) -- ARM上のビルドの修正。 [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) - -#### 下位互換性のない変更: {#backward-incompatible-changes} - -- 比較する能力を削除しました `Date` 数字で入力します。 代わりに `toDate('2018-12-18') = 17883` 明示的な型変換を使用する必要があります `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) - -## ClickHouseリリース18.14 {#clickhouse-release-18-14} - -### ClickHouseリリース18.14.19、2018-12-19 {#clickhouse-release-18-14-19-2018-12-19} - -#### バグ修正: {#bug-fixes-2} - -- ODBCソースで辞書を更新する際の問題を引き起こしたエラーを修正しました。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- DDL実行時にデータベースが正しく指定されている `ON CLUSTER` クエリ。 [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- 場合は、固定segfault `max_temporary_non_const_columns` 制限を超えました。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### ビルドの改善: {#build-improvements-2} - -- ARM上のビルドの修正。 - -### ClickHouseリリース18.14.18、2018-12-04 {#clickhouse-release-18-14-18-2018-12-04} - -#### バグ修正: {#bug-fixes-3} - -- 固定エラーで `dictGet...` タイプの辞書の関数 `range`、引数の一方が定数であり、他方が定数でない場合。 [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) -- メッセー `netlink: '...': attribute type 1 has an invalid length` Linuxカーネルログに印刷するには、linuxカーネルの新鮮なバージョンでのみ起こっていました。 [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) -- 機能の固定segfault `empty` の議論のために `FixedString` タイプ。 [ダニエルダオ-クアン-ミン](https://github.com/ClickHouse/ClickHouse/pull/3703) -- の大きな値を使用して過度のメモリ割り当てを修正 `max_query_size` 設定(メモリチャンクの `max_query_size` バイトは一度に事前に割り当てられました)。 [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) - -#### ビルドの変更: {#build-changes} - -- 固定の構築をllvm/clangライブラリのバージョン7のosのパッケージ(これらのライブラリを利用しています実行時のクエリを集める [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### ClickHouseリリース18.14.17、2018-11-30 {#clickhouse-release-18-14-17-2018-11-30} - -#### バグ修正: {#bug-fixes-4} - -- 固定の場合には、odbc橋工程終了しなかったのサーバーです。 [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) -- に固定同期挿入 `Distributed` リモートテーブルの列リストとは異なる列リストを持つテーブル。 [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) -- MergeTreeテーブルをドロップしたときにクラッシュする稀な競合状態を修正しました。 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- クエリスレッドの作成が失敗した場合のクエリのデッドロックを修正しました `Resource temporarily unavailable` エラー。 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- の固定解析 `ENGINE` ときの句 `CREATE AS table` 構文が使用され、 `ENGINE` の前に句が指定されました。 `AS table` (エラーの結果、指定されたエンジンが無視されました)。 [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) - -### ClickHouseリリース18.14.15、2018-11-21 {#clickhouse-release-18-14-15-2018-11-21} - -#### バグ修正: {#bug-fixes-5} - -- メモリチャンクのサイズは、型の列を逆シリアル化しながら過大評価されました `Array(String)` それはにつながる “Memory limit exceeded” エラー。 この問題はバージョン18.12.13に登場しました。 [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) - -### ClickHouseリリース18.14.14、2018-11-20 {#clickhouse-release-18-14-14-2018-11-20} - -#### バグ修正: {#bug-fixes-6} - -- 固定 `ON CLUSTER` クエリがクラスタ設定の確保(フラグ ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) - -#### ビルドの変更: {#build-changes-1} - -- 問題を修正しました(システムからのllvm-7、macos) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### ClickHouseリリース18.14.13、2018-11-08 {#clickhouse-release-18-14-13-2018-11-08} - -#### バグ修正: {#bug-fixes-7} - -- 修正された `Block structure mismatch in MergingSorted stream` エラー。 [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) -- 固定 `ON CLUSTER` クラスタ設定でセキュリティで保護された接続がオンになっている場合のクエリ `` フラグ)。 [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) -- 使用されるクエリのエラーを修正しました `SAMPLE`, `PREWHERE` とエイリアス列。 [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) -- レアを修正しました `unknown compression method` エラー時 `min_bytes_to_use_direct_io` 設定は有効でした。 [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) - -#### 性能の改善: {#performance-improvements} - -- とクエリの固定パフォーマンス回帰 `GROUP BY` AMD EPYCプロセッサで実行するときのUInt16またはDate型の列の数。 [Igor Lapko](https://github.com/ClickHouse/ClickHouse/pull/3512) -- 長い文字列を処理するクエリのパフォーマン [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) - -#### ビルドの改善: {#build-improvements-3} - -- Arcadiaビルドを簡素化するための改善。 [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) - -### ClickHouseリリース18.14.12、2018-11-02 {#clickhouse-release-18-14-12-2018-11-02} - -#### バグ修正: {#bug-fixes-8} - -- 固定クラッシュに当社では豊富な種類の名前のないサブクエリ. [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) -- 不正なクエリを生成する修正(空の `WHERE` 句)外部データベースを照会するとき。 [ホティッド](https://github.com/ClickHouse/ClickHouse/pull/3477) -- ODBC辞書で間違ったタイムアウト値を使用して修正。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) - -### ClickHouseリリース18.14.11、2018-10-29 {#clickhouse-release-18-14-11-2018-10-29} - -#### バグ修正: {#bug-fixes-9} - -- エラーを修正しました `Block structure mismatch in UNION stream: different number of columns` 制限クエリで。 [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) -- 固定誤差が統合データテーブルを含む配列内の入れ子構造です。 [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) -- 修正された不正なクエリの結果 `merge_tree_uniform_read_distribution` 設定は無効になっています(既定で有効になっています)。 [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) -- ネイティブ形式の分散テーブルへの挿入エラーを修正しました。 [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) - -### ClickHouseリリース18.14.10、2018-10-23 {#clickhouse-release-18-14-10-2018-10-23} - -- その `compile_expressions` 既定では、設定(式のJITコンパイル)は無効になっています。 [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) -- その `enable_optimize_predicate_expression` 設定はデフォルトでは無効です。 - -### ClickHouseリリース18.14.9、2018-10-16 {#clickhouse-release-18-14-9-2018-10-16} - -#### 新しい機能: {#new-features-1} - -- その `WITH CUBE` の修飾子 `GROUP BY` (代替構文 `GROUP BY CUBE(...)` また利用できます)。 [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) -- を追加しました `formatDateTime` 機能。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2770) -- を追加しました `JDBC` テーブルエンジンと `jdbc` 表関数(clickhouse-jdbc-bridgeのインストールが必要) [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) -- ISO週番号を操作するための機能を追加しました: `toISOWeek`, `toISOYear`, `toStartOfISOYear`、と `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) -- 今すぐ使用できます `Nullable` の列 `MySQL` と `ODBC` テーブル。 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- ネストされたデータ構造は、ネストされたオブジェ `JSONEachRow` フォーマット。 を追加しました `input_format_import_nested_json` 設定。 [ベロマン雲館](https://github.com/ClickHouse/ClickHouse/pull/3144) -- 並列処理は、多くの利用可能です `MATERIALIZED VIEW`sデータを挿入するとき。 を見る `parallel_view_processing` 設定。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) -- を追加しました `SYSTEM FLUSH LOGS` クエリ(次のようなシステムテーブルへの強制ログフラッシュ `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) -- これで、事前定義を使用できます `database` と `table` 宣言するときのマクロ `Replicated` テーブル。 [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) -- 読む能力を追加しました `Decimal` 工学表記で値を入力します(十の累乗を示します)。 [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) - -#### 実験の特徴: {#experimental-features} - -- のgroup by句の最適化 `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) -- のための式の最適化された計算 `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) - -#### 改善: {#improvements-2} - -- クエリのメモリ消費量を大幅に削減 `ORDER BY` と `LIMIT`. を見る `max_bytes_before_remerge_sort` 設定。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- の不在で `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` が想定される。 [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) -- 修飾されたアスタリスクは `JOIN`. [冬張](https://github.com/ClickHouse/ClickHouse/pull/3202) -- その `ODBC` テーブルエンジンが正しく選択の方法のために引用識別子のSQL方言のリモートデータベースです。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) -- その `compile_expressions` 既定では、設定(式のJITコンパイル)が有効になっています。 -- 同時drop database/table if existsとcreate database/table if not existsの動作を修正しました。 以前は、 `CREATE DATABASE ... IF NOT EXISTS` クエリが返すエラーメッセージ “File … already exists”、と `CREATE TABLE ... IF NOT EXISTS` と `DROP TABLE IF EXISTS` クエリが返されます `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) -- MYSQLまたはODBCテーブルからクエリを実行するときに、定数の右半分を持つLIKE式がリモートサーバーに渡されます。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- MYSQLおよびODBCテーブルからクエリを実行すると、WHERE句の定数式との比較がリモートサーバーに渡されます。 以前は、定数との比較のみが渡されました。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- 端末の行幅の正しい計算 `Pretty` 象形文字の文字列を含む形式。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/3257). -- `ON CLUSTER` 指定することができるため `ALTER UPDATE` クエリ。 -- 性能向上のためのデータを読み込むには `JSONEachRow` フォーマット。 [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) -- の同義語を追加しました `LENGTH` と `CHARACTER_LENGTH` 互換性のための機能。 その `CONCAT` 関数では、大文字と小文字は区別されなくなりました。 [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) -- を追加しました `TIMESTAMP` の同義語 `DateTime` タイプ。 [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) -- ログ行がクエリに関連していない場合でも、サーバーログには常にquery\_id用に予約された領域があります。 それによる解析サーバーテキストログとして第三者ツールです。 -- クエリによるメモリ消費は、次のレベルの整数のギガバイトを超えるとログに記録されます。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- 追加の互換性モードの場合はライブラリを使用するネイティブプロトコルを送の少ないカラムによる間違い、サーバーの期待に挿入モードです。 このシナリオは、clickhouse-cppライブラリを使用する場合に可能でした。 従来、このシナリオのサーバーンダリングする能力があります。 [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) -- ユーザー定義のwhere式 `clickhouse-copier`、今使用することができ `partition_key` エイリアス(追加フィルタリングによるソーステーブルの分割). これがなければならないときに便利でのパーティショニングスキーマの変化の中で複製、変更するわけです。 [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) -- のワークフロー `Kafka` エンジンとして、バックグラウンドスレッドプールのために自動的に減速のデータを読高ます。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- 読書のためのサポート `Tuple` と `Nested` 以下のような構造体の値 `struct` で `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) -- トップレベルドメインのリスト `firstSignificantSubdomain` 機能の現在のドメイン `biz`. [デカシール](https://github.com/ClickHouse/ClickHouse/pull/3219) -- 外部辞書の設定で, `null_value` デフォルトのデータ型の値として解釈されます。 [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) -- のサポート `intDiv` と `intDivOrZero` 機能のための `Decimal`. [b48402e8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) -- のサポート `Date`, `DateTime`, `UUID`、と `Decimal` のキーとしてタイプします `sumMap` 集計関数。 [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) -- のサポート `Decimal` 外部ディクショナリのデータ型。 [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) -- のサポート `Decimal` データタイプ `SummingMergeTree` テーブル。 [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) -- のための追加された専門分野 `UUID` で `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) -- 数を減らしましたの `open` と `close` システムコールからの読み取り `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) -- A `TRUNCATE TABLE` クエリは任意のレプリカで実行できます(クエリはリーダーレプリカに渡されます)。 [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/3375) - -#### バグ修正: {#bug-fixes-10} - -- との問題を修正しました `Dictionary` テーブルのため `range_hashed` 辞書だ このエラーはバージョン18.12.17で発生しました。 [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) -- ロード時にエラーを修正 `range_hashed` 辞書(メッセージ `Unsupported type Nullable (...)`). このエラーはバージョン18.12.17で発生しました。 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- で修正されたエラー `pointInPolygon` 多数の頂点が互いに近接して配置されているポリゴンの不正確な計算の蓄積による関数。 [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) -- データパーツをマージした後、結果のパーツのチェックサムが別のレプリカで同じマージの結果と異なる場合、マージの結果が削除され、データパーツが別のレプリ しかし、データパーツをダウンロードした後、そのパーツがすでに存在するというエラーのため(マージ後にデータパーツが何らかの遅延で削除されたため)、ワーキング これにより、同じデータを周期的にダウンロードしようとした。 [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) -- クエリによる総メモリ消費の誤った計算を修正しました(誤った計算のために、 `max_memory_usage_for_all_queries` 設定が間違って働いたと `MemoryTracking` メトリックの値が正しくない)。 このエラーはバージョン18.12.13で発生しました。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) -- の機能を修正しました `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` このエラーはバージョン18.12.13で発生しました。 [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) -- のためのデータ構造の固定不要な準備 `JOIN`サーバー上では、クエリを開始するサーバー上の `JOIN` リモートサーバーでのみ実行されます。 [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) -- で修正されたバグ `Kafka` エンジン:データの読み取りを開始するときの例外後のデッドロック、完了時のロック [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- のために `Kafka` テーブル、オプション `schema` のスキー `Cap'n'Proto` フォーマット)。 [Vojtech Splichal](https://github.com/ClickHouse/ClickHouse/pull/3150) -- ZooKeeperサーバーのアンサンブルに、接続を受け入れるがハンドシェイクに応答する代わりにすぐに閉じるサーバーがある場合、ClickHouseは別のサーバーを接続することを 以前は、これはエラーを生成しました `Cannot read all data. Bytes read: 0. Bytes expected: 4.` サーバーは起動できませんでした [8218cf3a](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) -- ZooKeeperサーバーの集合にDNSクエリがエラーを返すサーバーが含まれている場合、これらのサーバーは無視されます。 [17b8e209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) -- 固定型変換の間 `Date` と `DateTime` データを挿入するとき `VALUES` フォーマット(if `input_format_values_interpret_expressions = 1`). 以前は、Unixエポック時間の日数の数値とUnixタイムスタンプの間で変換が行われ、予期しない結果が生じました。 [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) -- 間の補正型変換 `Decimal` そして整数数。 [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) -- で修正されたエラー `enable_optimize_predicate_expression` 設定。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3231) -- デフォルト以外のcsv区切り記号が使用されている場合、浮動小数点数を使用したcsv形式の解析エラーが修正されました `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) -- 修正された `arrayCumSumNonNegative` 関数(アキュムレータがゼロより小さい場合、負の値は累積されません)。 [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/3163) -- 固定方法 `Merge` テーブルの上に動作 `Distributed` 使用する場合のテーブル `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) -- のバグ修正 `ALTER UPDATE` クエリ。 -- で修正されたバグ `odbc` バージョン18.12に登場したテーブル関数。 [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) -- との集計関数の動作を修正しました `StateArray` コンビネーター [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) -- 分割するときにクラッシュを修正 `Decimal` ゼロによる値。 [69dd6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) -- 以下を使用した操作のタイプの固定出力 `Decimal` そして整数引数。 [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) -- 中にsegfaultを修正しました `GROUP BY` に `Decimal128`. [3359ba06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) -- その `log_query_threads` 設定(クエリ実行の各スレッドに関する情報のロギング)は、次の場合にのみ有効になります `log_queries` オプション(照会に関する情報のロギング)は1に設定されます。 ので、 `log_query_threads` このオプションは既定で有効になっています。 [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) -- 分位数集計関数の分散操作におけるエラーを修正しました(エラーメッセージ `Not found column quantile...`). [292a8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) -- 同時にバージョン18.12.17サーバーと古いサーバーのクラスタで作業するときの互換性の問題を修正しました。 固定長および固定長以外のキーを持つ分散クエリの場合、集計するデータが大量にあった場合、返されるデータは常に完全に集計されるとは限りません [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) -- の置換の処理を修正しました。 `clickhouse-performance-test` クエリにテストで宣言された置換の一部のみが含まれている場合。 [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) -- 使用時にエラーが修正されました `FINAL` と `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- 使用時にエラーが修正されました `PREWHERE` 中に追加された列の上に `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- の不在のためのチェックを追加しました `arrayJoin` のために `DEFAULT` と `MATERIALIZED` 式。 以前は, `arrayJoin` データ挿入時にエラーが発生しました。 [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) -- の不在のためのチェックを追加しました `arrayJoin` で `PREWHERE` 句。 以前は、このようなメッセージに `Size ... doesn't match` または `Unknown compression method` クエリを実行するとき。 [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) -- 修正されたsegfaultは、置換された最適化の後にまれに発生する可能性があり、式の中で対応すると等価性評価からチェーン。 [liuyimin-bytedance](https://github.com/ClickHouse/ClickHouse/pull/3339) -- マイナーな訂正への `clickhouse-benchmark` 実行されたクエリの数は、シャットダウン時および反復回数を制限するために、より正確に計算されるようになりました。 [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) - -#### 下位互換性のない変更: {#backward-incompatible-changes-1} - -- 削除された `allow_experimental_decimal_type` オプション。 その `Decimal` データ型は、デフォルトで使用できます。 [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) - -## ClickHouseリリース18.12 {#clickhouse-release-18-12} - -### ClickHouseリリース18.12.17,2018-09-16 {#clickhouse-release-18-12-17-2018-09-16} - -#### 新しい機能: {#new-features-2} - -- `invalidate_query` (外部ディクショナリを更新する必要があるかどうかを確認するクエリを指定する機能)。 `clickhouse` ソース。 [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) -- 使用する機能を追加しました `UInt*`, `Int*`、と `DateTime` データ型(データ型と共に `Date` タイプ)として `range_hashed` 範囲の境界を定義する外部ディクショナリキー。 さて `NULL` 開いている範囲を指定するために使用できます。 [Vasily Nemkov](https://github.com/ClickHouse/ClickHouse/pull/3123) -- その `Decimal` タイプ今サポート `var*` と `stddev*` 集計関数。 [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- その `Decimal` タイプに対応しま数理機能 (`exp`, `sin` というように。) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- その `system.part_log` テーブルは今持っている `partition_id` コラム [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### バグ修正: {#bug-fixes-11} - -- `Merge` 今正しくオンに動作します `Distributed` テーブル。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3159) -- 固定された非互換性(上の不要な依存関係 `glibc` クリックハウスを実行することが不可能になったバージョン) `Ubuntu Precise` と古いバージョン。 この非互換性はバージョン18.12.13で発生しました。 [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) -- で修正されたエラー `enable_optimize_predicate_expression` 設定。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3107) -- 18.12.13より前のバージョンのレプリカのクラスターを操作し、新しいバージョンのテーブルの新しいレプリカをサーバーに作成する際に、下位互換性の問題を `Can not clone replica, because the ... updated to new ClickHouse version` これは論理的ですが、起こるべきではありません)。 [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) - -#### 下位互換性のない変更: {#backward-incompatible-changes-2} - -- その `enable_optimize_predicate_expression` optionはデフォルトで有効になっています(これは楽観的です)。 列名の検索に関連するクエリ分析エラーが発生した場合は、次のように設定します `enable_optimize_predicate_expression` に0. [冬張](https://github.com/ClickHouse/ClickHouse/pull/3107) - -### ClickHouseリリース18.12.14,2018-09-13 {#clickhouse-release-18-12-14-2018-09-13} - -#### 新しい機能: {#new-features-3} - -- のサポートを追加 `ALTER UPDATE` クエリ。 [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) -- を追加しました `allow_ddl` DDLクエリへのユーザーのアクセスを制限するオプション。 [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) -- を追加しました `min_merge_bytes_to_use_direct_io` のための選択 `MergeTree` マージの合計サイズのしきい値を設定することができます(しきい値を超えると、データパーツファイルはO\_DIRECTを使用して処理されます)。 [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) -- その `system.merges` システムテーブルは現在 `partition_id` コラム [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) - -#### 改善 {#improvements-3} - -- 場合のデータ部分を据え置き期間中、突然変異なダウンロードによるレプリカ. [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) -- オートコンプリートは、操作時に設定の名前に使用できます `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) - -#### バグ修正: {#bug-fixes-12} - -- の要素である配列のサイズのチェックを追加しました `Nested` 挿入時にfieldsを入力します。 [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) -- と外部辞書を更新するエラーを修正しました `ODBC` ソースと `hashed` ストレージ。 このエラーはバージョン18.12.13で発生しました。 -- クエリから一時テーブルを作成するときにクラッシュする問題を修正 `IN` 条件。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3098) -- 持つことができる配列の集計関数のエラーを修正しました `NULL` 要素。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/3097) - -### ClickHouseリリース18.12.13,2018-09-10 {#clickhouse-release-18-12-13-2018-09-10} - -#### 新しい機能: {#new-features-4} - -- を追加しました `DECIMAL(digits, scale)` データ型 (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). 有効にするには、次の設定を使用します `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) -- 新しい `WITH ROLLUP` の修飾子 `GROUP BY` (代替構文: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) -- JOINを使用したクエリでは、スター文字はSQL標準に準拠してすべてのテーブルの列のリストに展開されます。 古い動作を復元するには、以下を設定します `asterisk_left_columns_only` ユーザー構成レベルで1に設定します。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2787) -- テーブ [冬張](https://github.com/ClickHouse/ClickHouse/pull/2907) -- Clickhouseクライアントのタブを押してオートコンプリート。 [Sergey Shcherbin](https://github.com/ClickHouse/ClickHouse/pull/2447) -- Clickhouse-client内のCtrl+Cは、入力されたクエリをクリアします。 [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) -- を追加しました `join_default_strictness` 設定(値: `"`, `'any'`, `'all'`). これにより、指定しないでください `ANY` または `ALL` のために `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) -- クエリ処理に関連するサーバーログの各行には、クエリidが表示されます。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- これでclickhouse-clientでクエリ実行ログを取得できるようになりました。 `send_logs_level` 設定)。 分散クエリ処理では、ログはすべてのサーバからカスケード接続されます。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- その `system.query_log` と `system.processes` (`SHOW PROCESSLIST`)クエリを実行するときに変更されたすべての設定に関する情報が表に表示されるようになりました。 `Settings` データ)。 を追加しました `log_query_settings` 設定。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- その `system.query_log` と `system.processes` テーブルには、クエリの実行に参加しているスレッドの数に関する情報が表示されます。 `thread_numbers` 列)。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 追加 `ProfileEvents` ネットワーク上の読み取りと書き込み、およびディスクへの読み取りと書き込みに費やされる時間、ネットワークエラーの数、およびネットワーク帯域幅が [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 追加 `ProfileEvents`rusageのシステムメトリックスを含むカウンター(ユーザー空間のCPU使用率、カーネル、ページフォールト、およびコンテキストスイッチに関する情報を取得できます)、 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- その `ProfileEvents` カウンタは、クエリごとにグローバルに適用され、クエリごとにリソース消費を詳細にプロファイルできるように、クエリ実行スレッドごとに適用され [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- を追加しました `system.query_thread_log` 各クエリ実行スレッドに関する情報を含むテーブル。 を追加しました `log_query_threads` 設定。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- その `system.metrics` と `system.events` 表現を内蔵しております。 [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) -- を追加しました `arrayEnumerateDense` 機能。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2975) -- を追加しました `arrayCumSumNonNegative` と `arrayDifference` 機能。 [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/2942) -- を追加しました `retention` 集計関数。 [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2887) -- これで、プラス演算子を使用して集計関数の状態を追加(マージ)し、集計関数の状態に非負の定数を掛けることができます。 [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) -- MergeTreeファミリーのテーブルに仮想列が追加されました `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### 実験の特徴: {#experimental-features-1} - -- を追加しました `LowCardinality(T)` データ型。 このデー [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) -- JITコンパイルされた関数のキャッシュと、コンパイル前の使用回数のカウンターを追加しました。 式をJITコンパイルするには、 `compile_expressions` 設定。 [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) - -#### 改善: {#improvements-4} - -- 放棄されたレプリカがある場合、複製ログの無制限の蓄積の問題を修正しました。 長いラグを持つレプリカの効果的な復旧モードを追加しました。 -- 改善された性能の `GROUP BY` 複数の集約フィールドがある場合、一方がstringで、他方が固定長の場合。 -- 使用時のパフォーマンスの向上 `PREWHERE` そして、式の暗黙的な転送で `PREWHERE`. -- テキスト形式の解析性能の向上 (`CSV`, `TSV`). [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) -- バイナリ形式での文字列と配列の読み取りパフォーマンスの向上。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2955) -- クエリのパフォーマンスの向上とメモリ消費の削減 `system.tables` と `system.columns` 単一のサーバー上のテーブルの非常に大きな数がある場合。 [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) -- エラーが発生するクエリの大きなストリームの場合のパフォーマンスの問題を修正しました `_dl_addr` 機能は目に見えます `perf top` しかし、サーバーは多くのCPUを使用していません)。 [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) -- 条件はビューにキャストされます(以下の場合 `enable_optimize_predicate_expression` が有効になっている)。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2907) -- の機能の改善 `UUID` データ型。 [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) -- その `UUID` データ型は、-Alchemist辞書でサポートされています。 [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) -- その `visitParamExtractRaw` 関数は入れ子構造で正しく動作します。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2974) -- とき `input_format_skip_unknown_fields` 設定が有効になっています。 `JSONEachRow` フォーマットはスキップされます。 [BlahGeek](https://github.com/ClickHouse/ClickHouse/pull/2958) -- のための `CASE` 条件付きの式を省略できるようになりました `ELSE` に相当します `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) -- ZooKeeperで作業するときに操作タイムアウトを設定できます。 [urykhy](https://github.com/ClickHouse/ClickHouse/pull/2971) -- のオフセットを指定できます `LIMIT n, m` として `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- を使用することができ `SELECT TOP n` 代替としての構文 `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- システムテーブルに書き込むキューのサイズが大きくなるため、 `SystemLog parameter queue is full` エラーは頻繁に発生しません。 -- その `windowFunnel` 集計機能に対応しまイベントが複数の条件です。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2801) -- 重複する列は、 `USING` のための節 `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) -- `Pretty` フォーマットは現在、幅によって列の配置に制限があります。 を使用 `output_format_pretty_max_column_pad_width` 設定。 値が広い場合、それはまだその全体が表示されますが、テーブル内の他のセルが広すぎることはありません。 [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) -- その `odbc` テーブル機能することはできなくなるようです指定のデータベースのスキーマの名前です。 [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2885) -- で指定されたユーザ名を使用する機能を追加しました `clickhouse-client` 設定ファイル。 [Vladimir Kozbin](https://github.com/ClickHouse/ClickHouse/pull/2909) -- その `ZooKeeperExceptions` カウンター分割された三つのカウンター: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions`、と `ZooKeeperOtherExceptions`. -- `ALTER DELETE` クエリはマテリアライズドビュ -- のために定期的に `ReplicatedMergeTree` テーブルは非常に多数があるとき周期的な負荷スパイクを避けるために `ReplicatedMergeTree` テーブル。 -- のサポート `ATTACH TABLE ... ON CLUSTER` クエリ。 [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) - -#### バグ修正: {#bug-fixes-13} - -- との問題を修正しました `Dictionary` テーブル `Size of offsets doesn't match size of column` または `Unknown compression method` 例外)。 このバグはバージョ [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) -- マージ時のバグを修正 `CollapsingMergeTree` データパーツのいずれかが空の場合(これらのパーツはマージ中に形成されます。 `ALTER DELETE` すべてのデータが削除された場合)、 `vertical` マージにはアルゴリズムを使用した。 [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) -- 中に競合状態を修正しました `DROP` または `TRUNCATE` のために `Memory` 同時のテーブル `SELECT` サーバーがクラッシュする可能性があります。 このバグはバージョン1.1.54388に登場しました。 [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) -- 挿入するときにデータが失われる可能性を修正しました `Replicated` テーブルの場合 `Session is expired` エラーが返されるデータ損失を検出することができますの `ReplicatedDataLoss` メトリック)。 このエラーはバージョン1.1.54378で発生しました。 [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) -- 中にセグメントフォールトを修正 `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) -- カラム名を検索する際のエラーを修正しました `WHERE` 式は完全に修飾された列名で構成されます。 `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) -- 修正された “Not found column” サブクエリを持つIN式で構成される単一の列がリモートサーバーから要求された場合に、分散クエリを実行するときに発生したエラーです。 [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) -- 修正された `Block structure mismatch in UNION stream: different number of columns` シャードの一方がローカルで、他方がローカルでない場合に分散クエリに対して発生したエラー、および移動の最適化 `PREWHERE` トリガーされます。 [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) -- 修正された `pointInPolygon` 非凸多角形の特定のケースの関数です。 [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) -- 比較時の誤った結果を修正しました `nan` 整数で。 [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) -- のエラーを修正しました `zlib-ng` まれにsegfaultにつながる可能性のあるライブラリ。 [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) -- テーブルに挿入するときにメモリリークを修正しました `AggregateFunction` 列、集計関数の状態が単純でない場合(メモリを別々に割り当てる)、単一の挿入要求が複数の小さなブロックになる場合。 [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) -- 同じを作成し、削除する際の競合状態を修正しました `Buffer` または `MergeTree` 同時のテーブル。 -- タプルなどの特定の非自明な型で構成されたタプルを比較するときに、segfaultの可能性を修正しました。 [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) -- 特定の実行時にsegfaultの可能性を修正しました `ON CLUSTER` クエリ。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2960) -- のエラーを修正しました `arrayDistinct` 機能のための `Nullable` 配列要素。 [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) -- その `enable_optimize_predicate_expression` オプションは現在、正しく `SELECT *`. [冬張](https://github.com/ClickHouse/ClickHouse/pull/2929) -- ZooKeeperセッションを再初期化するときにsegfaultを修正しました。 [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) -- 固定性ブロックが飼育係. -- 修正コードをネストしたデータ構造 `SummingMergeTree`. -- 集計関数の状態にメモリを割り当てるとき、整列が正しく考慮され、集計関数の状態を実装するときに整列を必要とする操作を使用することがで [chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) - -#### セキュリティ修正: {#security-fix} - -- ODBCデータソースの安全な使用。 ODBCドライバとの対話では、 `clickhouse-odbc-bridge` プロセス。 誤りや第三者ODBCドライバーにな問題となるとサーバの安定性や脆弱性があります。 [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) -- のファイルパスの修正された誤った検証 `catBoostPool` テーブル機能。 [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) -- システムテーブルの内容 (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas`、と `replication_queue`)フィルタによると、ユーザーの設定データベースへのアクセス (`allow_databases`). [冬張](https://github.com/ClickHouse/ClickHouse/pull/2856) - -#### 下位互換性のない変更: {#backward-incompatible-changes-3} - -- JOINを使用したクエリでは、スター文字はSQL標準に準拠してすべてのテーブルの列のリストに展開されます。 古い動作を復元するには、以下を設定します `asterisk_left_columns_only` ユーザー構成レベルで1に設定します。 - -#### ビルドの変更: {#build-changes-2} - -- ほとんどの統合テス -- コードのスタイルチェックによって解決することができます -- その `memcpy` 実装は、CentOS7/Fedoraをビルドするときに正しく選択されます。 [エティエンシャンペティエ](https://github.com/ClickHouse/ClickHouse/pull/2912) -- Clangをビルドに使用するときは、次の警告が表示されます `-Weverything` 通常のものに加えて、追加されています `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) -- ビルドのデバッグには、 `jemalloc` debugオプション。 -- のインタフェースを図書館との交流の飼育係で宣言されていく。 [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) - -## ClickHouseリリース18.10 {#clickhouse-release-18-10} - -### ClickHouseリリース18.10.3、2018-08-13 {#clickhouse-release-18-10-3-2018-08-13} - -#### 新しい機能: {#new-features-5} - -- Httpsは複製に使用できます。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) -- 機能を追加しました `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64`、と `murmurHash3_128` 既存のものに加えて `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) -- ClickHouse ODBCドライバでのNull許容型のサポート (`ODBCDriver2` 出力フォーマット)。 [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) -- のサポート `UUID` キー列に。 - -#### 改善: {#improvements-5} - -- クラスターは、設定ファイルから削除されたときに、サーバーを再起動せずに削除できます。 [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) -- 外部辞書は、設定ファイルから削除されたときにサーバーを再起動せずに削除できます。 [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) -- 追加 `SETTINGS` のサポート `Kafka` テーブルエンジン。 [Alexander Marshalov](https://github.com/ClickHouse/ClickHouse/pull/2781) -- のための改善 `UUID` データ型(まだ完了していない)。 [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) -- の併合の後の空の部品のためのサポート `SummingMergeTree`, `CollapsingMergeTree` と `VersionedCollapsingMergeTree` エンジン [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) -- 完了した変異の古いレコードが削除されます (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) -- を追加しました `system.merge_tree_settings` テーブル。 [Kirill Shvakov](https://github.com/ClickHouse/ClickHouse/pull/2841) -- その `system.tables` 表現の依存関係列: `dependencies_database` と `dependencies_table`. [冬張](https://github.com/ClickHouse/ClickHouse/pull/2851) -- を追加しました `max_partition_size_to_drop` 設定オプション。 [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) -- を追加しました `output_format_json_escape_forward_slashes` オプション。 [Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2812) -- を追加しました `max_fetch_partition_retries_count` 設定。 [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) -- を追加しました `prefer_localhost_replica` ローカルレプリカの設定を無効にし、プロセス間の対話を行わずにローカルレプリカに移動するための設定。 [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) -- その `quantileExact` 集計関数の戻り値 `nan` 空の上の集約の場合 `Float32` または `Float64` セット。 [Sundy Li](https://github.com/ClickHouse/ClickHouse/pull/2855) - -#### バグ修正: {#bug-fixes-14} - -- それは不可能な接続を確立するために作られたodbcの接続文字列パラメータの不要なエスケープを削除しました。 このエラーはバージョン18.6.0で発生しました。 -- 処理のロジックを修正しました `REPLACE PARTITION` 複製キュー内のコマンド。 がある場合は二つ `REPLACE` コマンドと同じパーティション、間違ったロジックが原因の一つの複製のキューは行われなくなります。 [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) -- すべてのデータ部分が空であったときにマージのバグを修正しました(マージまたはから形成された部分 `ALTER DELETE` すべてのデータが削除された場合)。 このバグに登場したバージョン18.1.0. [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) -- 同時実行のエラーを修正しました `Set` または `Join`. [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2823) -- 修正された `Block structure mismatch in UNION stream: different number of columns` のために発生したエラー `UNION ALL` サブクエリ内のクエリのいずれかの場合 `SELECT` クエリを含む複製のカラム名をとります。 [冬張](https://github.com/ClickHouse/ClickHouse/pull/2094) -- MySQLサーバに接続するときに例外が発生した場合、メモリリークを修正しました。 -- クエリエラーの場合に修正された不正なclickhouse-クライアント応答コード。 -- 固定誤動作の実現の景色を含む異なるものとみなされます。 [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) - -#### 下位互換性のない変更 {#backward-incompatible-changes-4} - -- 除去支援のためのチェックテーブルのクエリのために配布します。 - -#### ビルドの変更: {#build-changes-3} - -- アロケータが置き換えられました: `jemalloc` の代りに今使用されます `tcmalloc`. いくつかのシナリオでは、この増加は20%まで高速化します。 しかし、20%まで減速したクエリがあります。 いくつかのシナリオでは、メモリ消費量が約10%削減され、安定性が向上しました。 非常に競争の激しい負荷では、ユーザスペースとシステムでのCPU使用率はわずかに増加します。 [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) -- サブモジュールからのlibresslの使用。 [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) -- サブモジュールからのunixodbcの使用。 [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) -- サブモジュールからのmariadb-connector-cの使用。 [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) -- テストデータの可用性に依存する機能テストファイルをリポジトリに追加しました(当面はテストデータ自体なし)。 - -## ClickHouseリリース18.6 {#clickhouse-release-18-6} - -### ClickHouseリリース18.6.0、2018-08-02 {#clickhouse-release-18-6-0-2018-08-02} - -#### 新しい機能: {#new-features-6} - -- JOIN ON構文のON式のサポートが追加されました: - `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` - 式は、and演算子によって結合された等量の連鎖でなければなりません。 等式の各辺は、いずれかのテーブルの列に対する任意の式にすることができます。 完全修飾列名の使用がサポートされています (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`)右のテーブルのために。 [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) -- HTTPSで有効にする必要があります。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) - -#### 改善: {#improvements-6} - -- サーバにパッチ部品のバージョンです。 データのパッチ版コンポーネントが `system.processes` と `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) - -## ClickHouseリリース18.5 {#clickhouse-release-18-5} - -### ClickHouseリリース18.5.1、2018-07-31 {#clickhouse-release-18-5-1-2018-07-31} - -#### 新しい機能: {#new-features-7} - -- ハッシュ関数を追加しました `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). - -#### 改善: {#improvements-7} - -- 今すぐ使用できます `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) 環境変数から設定ファイルの値を設定する属性。 -- 大文字と小文字を区別しないバージョンの追加 `coalesce`, `ifNull`、と `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). - -#### バグ修正: {#bug-fixes-15} - -- レプリカを起動する際のバグを修正 [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). - -## ClickHouseリリース18.4 {#clickhouse-release-18-4} - -### ClickHouseリリース18.4.0、2018-07-28 {#clickhouse-release-18-4-0-2018-07-28} - -#### 新しい機能: {#new-features-8} - -- 追加されたシステム表: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). -- Aの引数としてテーブルの代わりにテーブル関数を使用する機能を追加しました `remote` または `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). -- のサポート `HTTP Basic` 複製プロトコルでの認証 [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). -- その `has` 関数は、現在の配列の数値を検索することができます `Enum` 値 [Maxim Khrisanfov](https://github.com/ClickHouse/ClickHouse/pull/2699). -- 支援のための追加は任意のメッセージセパレータから読み取る際の `Kafka` [アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2701). - -#### 改善: {#improvements-8} - -- その `ALTER TABLE t DELETE WHERE` WHERE条件の影響を受けないデータ部分は、クエリで書き換えられません [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). -- その `use_minimalistic_checksums_in_zookeeper` のための選択 `ReplicatedMergeTree` テーブルはデフォルトで有効です。 この設定は、バージョン1.1.54378、2018-04-16で追加されました。 1.1.54378より古いバージョンはインストールできなくなりました。 -- 実行のサポート `KILL` と `OPTIMIZE` 指定するクエリ `ON CLUSTER` [冬張](https://github.com/ClickHouse/ClickHouse/pull/2689). - -#### バグ修正: {#bug-fixes-16} - -- エラーを修正しました `Column ... is not under an aggregate function and not in GROUP BY` IN式を使用した集計の場合。 このバグに登場したバージョン18.1.0. ([bbdd780b](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) -- のバグを修正しました `windowFunnel aggregate function` [冬張](https://github.com/ClickHouse/ClickHouse/pull/2735). -- のバグを修正しました `anyHeavy` 集計関数 ([a2101df2](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) -- 固定サーバークラッシュを使用する場合 `countArray()` 集計関数。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-5} - -- 変数のための `Kafka` エンジンは `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` に `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. テーブルが使用する場合 `kafka_schema` または `kafka_num_consumers` メタデータファイルを手動で編集する必要があります `path/metadata/database/table.sql` と追加 `kafka_row_delimiter` 変数との `''` 値。 - -## ClickHouseリリース18.1 {#clickhouse-release-18-1} - -### ClickHouseリリース18.1.0、2018-07-23 {#clickhouse-release-18-1-0-2018-07-23} - -#### 新しい機能: {#new-features-9} - -- のサポート `ALTER TABLE t DELETE WHERE` 非レプリケートされたMergeTreeテーブルのクエリ ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). -- の任意の型のサポート `uniq*` 集約関数のファミリ ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). -- 比較演算子での任意の型のサポート ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). -- その `users.xml` ファイルは、サブネットマス `10.0.0.1/255.255.255.0`. これは、中央にゼロを持つIPv6ネットワークのマスクを使用する場合に必要です ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). -- を追加しました `arrayDistinct` 機能 ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). -- SummingMergeTreeエンジンは、AggregateFunctionタイプの列を処理できるようになりました ([Constantin S.Pan](https://github.com/ClickHouse/ClickHouse/pull/2566)). - -#### 改善: {#improvements-9} - -- リリースバージョンの採番スキーマを変更。 今、最初の部分は、リリースの年(a.d.、モスクワタイムゾーン、マイナス2000)が含まれ、第二の部分は、主要な変更(ほとんどのリリースで増加)のための番号が含ま リリースは、changelogに特に明記されていない限り、後方互換性があります。 -- 浮動小数点数の文字列への変換を高速化 ([アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2664)). -- パースエラーのために挿入中に一部の行がスキップされた場合(これは、 `input_allow_errors_num` と `input_allow_errors_ratio` スキップされた行の数がサーバーログに書き込まれるようになりました ([Leonardo Cecchi](https://github.com/ClickHouse/ClickHouse/pull/2669)). - -#### バグ修正: {#bug-fixes-17} - -- 一時表のtruncateコマンドを修正しました ([アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2624)). -- 固定アロの飼育係顧客の図書館で発生した場合またはネットワークエラーを読みながら対応 ([c315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). -- Nullable型へのキャスト中にエラーが修正されました ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). -- の誤った結果を修正しました `maxIntersection()` 間隔の境界が一致したときの関数 ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2657)). -- 関数引数のor式チェーンの誤った変換を修正しました ([chenxing-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). -- クエリのパフォーマンスの低下を修正 `IN (subquery)` 別のサブクエリ内の式 ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). -- を使用する分散クエリで異なるバージョンを持つサーバー間の非互換性を修正 `CAST` 大文字でない関数 ([fe8c4d6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). -- 外部dbmsへのクエリに対する識別子のクォートの欠落を追加しました ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). - -#### 下位互換性のない変更: {#backward-incompatible-changes-6} - -- 数値ゼロを含む文字列をdatetimeに変換することはできません。 例えば: `SELECT toDateTime('0')`. これはまた、 `DateTime DEFAULT '0'` テーブルでは動作しません。 `0` 辞書で。 解決策:置換 `0` と `0000-00-00 00:00:00`. - -## ClickHouseリリース1.1 {#clickhouse-release-1-1} - -### ClickHouseリリース1.1.54394,2018-07-12 {#clickhouse-release-1-1-54394-2018-07-12} - -#### 新しい機能: {#new-features-10} - -- を追加しました `histogram` 集計関数 ([ミハイル-スリン](https://github.com/ClickHouse/ClickHouse/pull/2521)). -- さて `OPTIMIZE TABLE ... FINAL` パーティションを指定せずに使用できます `ReplicatedMergeTree` ([アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2600)). - -#### バグ修正: {#bug-fixes-18} - -- ネットワークまたはディスクに負荷がある場合に、より大きなパーツをダウンロードすることができなくなった(パーツをダウンロードするための周期的な このエラーはバージョン1.1.54388で発生しました。 -- テーブルに重複データブロックを挿入した場合、zookeeperでchrootを使用する際の問題を修正しました。 -- その `has` Nullable要素を持つ配列の関数が正しく動作するようになりました ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). -- その `system.tables` テーブルが正しく動作に用いた場合に配布します。 その `metadata_modification_time` と `engine_full` 列は現在、非仮想です。 これらの列のみがテーブルから照会された場合に発生するエラーを修正しました。 -- 固定どのように空 `TinyLog` テーブル動作後に挿入し、空データブロック ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). -- その `system.zookeeper` ZooKeeperのノードの値がNULLの場合、テーブルは機能します。 - -### ClickHouseリリース1.1.54390、2018-07-06 {#clickhouse-release-1-1-54390-2018-07-06} - -#### 新しい機能: {#new-features-11} - -- クエリは次の場所で送信できます `multipart/form-data` フォーマット `query` これは、外部データもクエリ処理のために送信される場合に便利です ([Olga Hvostikova](https://github.com/ClickHouse/ClickHouse/pull/2490)). -- CSV形式でデータを読み込むときに、単一引quotesまたは二重引用符の処理を有効または無効にする機能を追加しました。 これを設定することができます `format_csv_allow_single_quotes` と `format_csv_allow_double_quotes` 設定 ([アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2574)). -- さて `OPTIMIZE TABLE ... FINAL` 使用可能を指定せずに、パーティションのための非期待の `MergeTree` ([アモスの鳥](https://github.com/ClickHouse/ClickHouse/pull/2599)). - -#### 改善: {#improvements-10} - -- 性能向上、メモリーの消耗を減らし、正しいメモリ消費の位置姿勢トラッキング用のオペレーターがテーブル-インデックスを使用できる ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). -- データパーツの追加時にチェックサムの冗長チェックを削除しました。 これは、多数のレプリカがある場合に重要です。 -- のサポートを追加 `Array(Tuple(...))` のための議論 `arrayEnumerateUniq` 機能 ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). -- 追加 `Nullable` のサポート `runningDifference` 機能 ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). -- 非常に多数の式がある場合のクエリ分析パフォーマンスが改善されました ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). -- マージのためのデータパーツの高速選択 `ReplicatedMergeTree` テーブル。 ZooKeeperセッションの迅速な復旧 ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). -- その `format_version.txt` ファイル `MergeTree` これは、ファイルなしでディレクトリ構造をコピーした後にClickHouseを起動すると意味があります ([シプリアン-ハックマン](https://github.com/ClickHouse/ClickHouse/pull/2593)). - -#### バグ修正: {#bug-fixes-19} - -- サーバを再起動する前に、それが不可能なセッションとテーブルの読み取り専用状態を回復するために作ることができるzookeeperでの作業のバグを修正し -- セッションが中断された場合、古いノードが削除されないことがzookeeperでの作業時のバグを修正しました。 -- のエラーを修正しました `quantileTDigest` Float引数の関数(このバグはバージョン1.1.54388で導入されました) ([ミハイル-スリン](https://github.com/ClickHouse/ClickHouse/pull/2553)). -- 同じサイズの符号付き整数と符号なし整数の間で型を変換するための関数内に主キー列がある場合、mergetreeテーブルのインデックスのバグを修正しまし ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). -- 固定segfaultの場合 `macros` 使用されますが、設定ファイルにはありません ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). -- デフォル ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). -- ときに発生したバグを修正 `use_index_for_in_with_subqueries` 設定が無効になりました。 - -#### セキュリティ修正: {#security-fix-1} - -- MySQLに接続したときにファイルを送信できなくなりました (`LOAD DATA LOCAL INFILE`). - -### ClickHouseリリース1.1.54388、2018-06-28 {#clickhouse-release-1-1-54388-2018-06-28} - -#### 新しい機能: {#new-features-12} - -- のサポート `ALTER TABLE t DELETE WHERE` クエリーのための複製です。 を追加しました `system.mutations` このタイプのクエリの進行状況を追跡するテーブル。 -- のサポート `ALTER TABLE t [REPLACE|ATTACH] PARTITION` \*MergeTreeテーブルのクエリ。 -- のサポート `TRUNCATE TABLE` クエリ ([冬張](https://github.com/ClickHouse/ClickHouse/pull/2260)) -- 新しいいくつか `SYSTEM` 複製テーブルのクエリ (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). -- MySQLエンジンと対応するテーブル関数を使用してテーブルに書き込む機能を追加しました ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2294)). -- を追加しました `url()` テーブル機能および `URL` 表エンジン ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). -- を追加しました `windowFunnel` 集計関数 ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2352)). -- 新しい `startsWith` と `endsWith` 文字列の関数 ([Vadim Plakhtinsky](https://github.com/ClickHouse/ClickHouse/pull/2429)). -- その `numbers()` テーブル機能することはできなくなるようです指定のオフセット ([冬張](https://github.com/ClickHouse/ClickHouse/pull/2535)). -- パスワードに `clickhouse-client` 対話的に入力できます。 -- サーバログをsyslogに送信できるようになりました ([Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2459)). -- 共有ライブラリソースによる辞書のログインのサポート ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). -- カスタムcsvデリミタのサポート ([Ivan Zhukov](https://github.com/ClickHouse/ClickHouse/pull/2263)) -- を追加しました `date_time_input_format` 設定。 この設定を次のように切り替えると `'best_effort'`、DateTime値は、幅広い形式で読み込まれます。 -- を追加しました `clickhouse-obfuscator` データの難読化のためのユーティリティ。 使用例:パフォーマンステストで使用されるデータの公開。 - -#### 実験の特徴: {#experimental-features-2} - -- 計算する機能を追加しました `and` 引数が必要な場所のみ ([Anastasia Tsarkova](https://github.com/ClickHouse/ClickHouse/pull/2272)) -- JITコへのネイティブコードが可能となりますので一部表現 ([pyosunit description in lists](https://github.com/ClickHouse/ClickHouse/pull/2277)). - -#### バグ修正: {#bug-fixes-20} - -- クエリの重複が表示されなくなりました `DISTINCT` と `ORDER BY`. -- とのクエリ `ARRAY JOIN` と `arrayFilter` もはや間違った結果を返さない。 -- 固定の読み込み時にエラー配列カラムからの入れ子構造 ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). -- HAVING句でクエリを分析する際のエラーを修正しました `HAVING tuple IN (...)`. -- 誤りを修正で解析する場合、クエリを処理するクラウドの場合再帰的別名になります。 -- すべての行をフィルタリングするprewhereの条件でreplacingmergetreeから読み取るときにエラーが修正されました ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). -- ユーザープロファイルの設定が適用されていない使用時のセッションを行うhttpのインタフェース。 -- Clickhouse-localのコマンドラインパラメータから設定を適用する方法を修正しました。 -- の飼育係お客様の図書館におけるその使用は、セッションタイムアウトサーバから受信した. -- バグ修正の飼育係ライブラリとクライアントが待ってサーバの応答のものより長いタイムアウト. -- パーティションキー列の条件を持つクエリのパーツの固定pruning定 ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). -- マージは、後に可能になりました `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). -- ODBCテーブル関数の型マッピングが修正されました ([sundy-li](https://github.com/ClickHouse/ClickHouse/pull/2268)). -- 型の比較が修正されました `DateTime` タイムゾーンの有無にかかわらず ([Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2400)). -- の固定構文解析とフォーマット `CAST` オペレーター -- 分散テーブルエンジンのマテリアライズドビューへの挿入を修正 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). -- からデータを書き込む際の競合状態を修正しました `Kafka` エンジンを実現しの景色 ([楊関劉](https://github.com/ClickHouse/ClickHouse/pull/2448)). -- Remote()テーブル機能のSSRFを修正しました。 -- の固定終了動作 `clickhouse-client` 複数行モード ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). - -#### 改善: {#improvements-11} - -- 背景の業務を複製のテーブルを用いて行ったスレッドプールの代わりに別のスレッド ([Silviu Caragea](https://github.com/ClickHouse/ClickHouse/pull/1722)). -- LZ4圧縮パフォーマンスの向上。 -- 多数の結合およびサブクエリを含むクエリの分析を高速化します。 -- ネットワークエラーが多すぎると、dnsキャッシュが自動的に更新されます。 -- テーブル挿入は、マテリアライズドビューのいずれかに挿入ができない場合、パーツが多すぎるために発生しなくなりました。 -- イベントカウンターの不一致を修正しました `Query`, `SelectQuery`、と `InsertQuery`. -- のような式 `tuple IN (SELECT tuple)` タプルの型が一致する場合は許可されます。 -- サーバーとの複製のテーブルでかかわらず、飼育係の設定. -- 使用可能なcpuコアの数を計算するときに、cgroupの制限が考慮されるようになりました ([Atri Sharma](https://github.com/ClickHouse/ClickHouse/pull/2325)). -- Systemd設定ファイルに設定ディレクトリのchownを追加しました ([Mikhail Shiryaev](https://github.com/ClickHouse/ClickHouse/pull/2421)). - -#### ビルドの変更: {#build-changes-4} - -- Gcc8コンパイラはビルドに使用できます。 -- サブモジュールからllvmを構築する機能を追加しました。 -- Librdkafkaライブラリのバージョンがv0.11.4に更新されました。 -- システムlibcpuidライブラリを使用する機能を追加しました。 ライブラリのバージョンは0.4.0に更新されました。 -- ベクトルクラスライブラリを使用してビルドを修正 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). -- Cmakeはninjaのファイルをデフォルトで生成するようになりました `-G Ninja`). -- Libtermcapの代わりにlibtinfoライブラリを使用する機能を追加しました ([Georgy Kondratiev](https://github.com/ClickHouse/ClickHouse/pull/2519)). -- Fedoraの生皮におけるヘッダファイルの競合を修正しました ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). - -#### 下位互換性のない変更: {#backward-incompatible-changes-7} - -- でエスケープ削除 `Vertical` と `Pretty*` フォーマットおよび削除 `VerticalRaw` フォーマット。 -- バージョン1.1.54388(またはそれより新しい)のサーバーと古いバージョンのサーバーが分散クエリで同時に使用され、クエリに分散クエリが存在する場合 `cast(x, 'Type')` なしの式 `AS` キーワードと単語を持っていません `cast` 大文字では、次のようなメッセージで例外がスローされます `Not found column cast(0, 'UInt8') in block`. 解決方法:クラスター全体のサーバーを更新します。 - -### ClickHouseリリース1.1.54385,2018-06-01 {#clickhouse-release-1-1-54385-2018-06-01} - -#### バグ修正: {#bug-fixes-21} - -- 場合によっては、zookeeperの操作がブロックされるエラーを修正しました。 - -### ClickHouseリリース1.1.54383、2018-05-22 {#clickhouse-release-1-1-54383-2018-05-22} - -#### バグ修正: {#bug-fixes-22} - -- 固定減速のレプリケーションのキューにした場合には多くのレプリカ. - -### ClickHouseリリース1.1.54381,2018-05-14 {#clickhouse-release-1-1-54381-2018-05-14} - -#### バグ修正: {#bug-fixes-23} - -- 固定、ノードの漏洩、飼育係がclickhouse失接続を飼育係サーバーです。 - -### ClickHouseリリース1.1.54380、2018-04-21 {#clickhouse-release-1-1-54380-2018-04-21} - -#### 新しい機能: {#new-features-13} - -- テーブル機能を追加しました `file(path, format, structure)`. バイトを読み取る例 `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. - -#### 改善: {#improvements-12} - -- サブクエリは `()` クエリの可読性を高めるための括弧。 例えば: `(SELECT 1) UNION ALL (SELECT 1)`. -- シンプル `SELECT` からのクエリ `system.processes` テーブルはに含まれていません `max_concurrent_queries` 限界だ - -#### バグ修正: {#bug-fixes-24} - -- の誤った動作を修正しました `IN` から選択するときの演算子 `MATERIALIZED VIEW`. -- 修正フィルタリングパーテーションによるインデックスのように表現 `partition_key_column IN (...)`. -- 実行できない問題を修正 `OPTIMIZE` リーダー以外のレプリカに対するクエリ `REANAME` テーブルの上に行った。 -- 実行時承認エラーを修正しました `OPTIMIZE` または `ALTER` リーダー以外のレプリカに対するクエリ。 -- 固定凍結の `KILL QUERY`. -- ZooKeeperクライアントライブラリのエラーを修正し、ウォッチの喪失、分散DDLキューのフリーズ、およびレプリケーションキューのスローダウンが空でない場合に発生 `chroot` 接頭辞は、ZooKeeperの設定で使用されます。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-8} - -- のような式のサポートを削除 `(a, b) IN (SELECT (a, b))` (同等の式を使用できます `(a, b) IN (SELECT a, b)`). 以前のリリースでは、これらの式は未定につながった `WHERE` フィルタリングが起こっている。 - -### ClickHouseリリース1.1.54378、2018-04-16 {#clickhouse-release-1-1-54378-2018-04-16} - -#### 新しい機能: {#new-features-14} - -- ログレベルは、サーバーを再起動せずに変更できます。 -- を追加しました `SHOW CREATE DATABASE` クエリ。 -- その `query_id` に渡すことができます `clickhouse-client` (elBroom)。 -- 新しい設定: `max_network_bandwidth_for_all_users`. -- のサポートを追加 `ALTER TABLE ... PARTITION ...` のために `MATERIALIZED VIEW`. -- システムテーブルに非圧縮形式のデータパーツのサイズに関する情報を追加しました。 -- サーバ間の暗号化支援のための分散型のテーブル (`1` レプリカの設定で ``). -- のためのテーブルのレベルの設定 `ReplicatedMergeTree` Zookeeperに格納されているデータの量を最小限にするために、家族: : `use_minimalistic_checksums_in_zookeeper = 1` -- の構成 `clickhouse-client` プロンプト 既定では、サーバー名がプロンプトに出力されます。 サーバーの表示名を変更することができます。 それはまたで送られます `X-ClickHouse-Display-Name` HTTPヘッダ(キリルShvakov)。 -- 複数のコンマ区切り `topics` 指定することができる `Kafka` エンジン(トビアスアダムソン) -- クエリが停止した場合 `KILL QUERY` または `replace_running_query` クライアントは、 `Query was canceled` 不完全な結果の代わりに例外。 - -#### 改善: {#improvements-13} - -- `ALTER TABLE ... DROP/DETACH PARTITION` クエリは、レプリケーションキューの先頭で実行されます。 -- `SELECT ... FINAL` と `OPTIMIZE ... FINAL` テーブルに単一のデータ部分がある場合でも使用できます。 -- A `query_log` それは(キリルShvakov)手動で削除された場合、テーブルがその場で再作成されます。 -- その `lengthUTF8` 関数はより速く実行されます(zhang2014)。 -- の同期挿入物の改善された性能 `Distributed` テーブル (`insert_distributed_sync = 1`)破片の非常に大きな数がある場合。 -- サーバーは `send_timeout` と `receive_timeout` クライアントから設定し、クライアントに接続するときにそれらを適用します(逆の順序で適用されます:サーバーソケット `send_timeout` に設定される。 `receive_timeout` クライアントから受け取った値、およびその逆)。 -- 非同期挿入のためのより強い衝突の回復に `Distributed` テーブル。 -- の戻り値の型 `countEqual` 関数の変更元 `UInt32` に `UInt64` (谢磊). - -#### バグ修正: {#bug-fixes-25} - -- とエラーを修正しました `IN` 式の左側が `Nullable`. -- 正しい結果は返される利用時のタプルと `IN` タプルコンポーネントの一部がテーブルインデックスにある場合。 -- その `max_execution_time` limitは現在、分散クエリで正しく動作します。 -- 複合列のサイズを計算する際のエラーを修正しました `system.columns` テーブル。 -- 固定エラーの作成時に一時テーブル `CREATE TEMPORARY TABLE IF NOT EXISTS.` -- 固定エラー `StorageKafka` (\#\#2075) -- 固定サーバのクラッシュからでは無効引数の特定の集ます。 -- エラーを修正しました。 `DETACH DATABASE` バックグラウ `ReplicatedMergeTree` テーブル。 -- `Too many parts` 状態は、集約されたマテリアライズドビュー(\#\#2084)に挿入すると発生する可能性が低くなります。 -- 置換の後に同じレベルの別の置換が必要な場合は、config内の置換の再帰的な処理を修正しました。 -- メタデータファイルの構文を修正しました。 `VIEW` これは次のクエリを使用します `UNION ALL`. -- `SummingMergeTree` が正しく動作のための集計の入れ子データ構造との複合鍵があります。 -- 固定の可能性、レースの条件を選択する際にはリーダー `ReplicatedMergeTree` テーブル。 - -#### ビルドの変更: {#build-changes-5} - -- ビルドのサポート `ninja` 代わりに `make` と用途 `ninja` デフォルトのビルリリースなどで行っています。 -- パッケージ名変更: `clickhouse-server-base` で `clickhouse-common-static`; `clickhouse-server-common` で `clickhouse-server`; `clickhouse-common-dbg` で `clickhouse-common-static-dbg`. インストールするには、 `clickhouse-server clickhouse-client`. 古い名前のパッケージは、下位互換性のためにリポジトリにロードされます。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-9} - -- 削除され、特別の解釈で表現場配列を指定することができます。 以前は、式 `arr IN (set)` として解釈された “at least one `arr` element belongs to the `set`”. 新しいバ `arrayExists(x -> x IN (set), arr)`. -- ソケットオプションの不正な使用を無効にします `SO_REUSEPORT` Pocoライブラリでデフォルトで正しく有効になっていません。 Linuxでは、アドレスを同時に指定する理由はもはやないことに注意してください `::` と `0.0.0.0` for listen – use just `::` これにより、IPv4とIPv6の両方の接続をリッスンすることができます(デフォルトのカーネル設定設定で)。 もできますに帰属する為には、以前のバージョンを指定する `1` 設定で。 - -### ClickHouseリリース1.1.54370、2018-03-16 {#clickhouse-release-1-1-54370-2018-03-16} - -#### 新しい機能: {#new-features-15} - -- を追加しました `system.macros` 設定ファイルが変更されたときのマクロのテーブルと自動更新。 -- を追加しました `SYSTEM RELOAD CONFIG` クエリ。 -- を追加しました `maxIntersections(left_col, right_col)` 同時に交差する区間の最大数を返す集計関数 `[left; right]`. その `maxIntersectionsPosition(left, right)` 関数の先頭を返します “maximum” 間隔。 ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2012)). - -#### 改善: {#improvements-14} - -- Aにデータを挿入するとき `Replicated` テーブルに対する要求が少なくなる。 `ZooKeeper` (ユーザレベルのエラーのほとんどは、 `ZooKeeper` ログ)。 -- データセットのエイリアスを作成する機能を追加しました。 例えば: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. - -#### バグ修正: {#bug-fixes-26} - -- 修正された `Illegal PREWHERE` マージテーブルからの読み取りエラー `Distributed`テーブル。 -- IPv4専用のDockerコンテナでclickhouse-serverを起動できるようにする修正を追加しました。 -- システムか `system.parts_columns tables.` -- に同期挿入中に削除されたダブルバッファリング `Distributed` 接続がタイムアウトする原因となった可能性のあるテーブル。 -- になるバグを修正し過度に長い待ちきレプリカを定めるものであ `SELECT` クエリ。 -- 固定間違った日付で `system.parts` テーブル。 -- それは不可能でデータを挿入するために作られたバグを修正 `Replicated` テーブルの場合 `chroot` した空の構成 `ZooKeeper` クラスター -- 空の垂直統合アルゴリズムを修正しました `ORDER BY` テーブル。 -- リモートテーブルへのクエリでディクショナリを使用する機能を復元しました。 この機能はリリース1.1.54362で失われました。 -- のようなクエリの動作を復元 `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` ときの右側 `IN` リモートを使うべきです `default.table` くます。 この動作られた版1.1.54358. -- の無関係なエラーレベルのログを削除しました `Not found column ... in block`. - -### Clickhouseリリース1.1.54362,2018-03-11 {#clickhouse-release-1-1-54362-2018-03-11} - -#### 新しい機能: {#new-features-16} - -- 集計なし `GROUP BY` 空のセット(以下のような)の場合 `SELECT count(*) FROM table WHERE 0` これで、sql標準に準拠して、集計関数のnull値を持つ行がある結果が返されるようになりました。 古い動作を復元するには(空の結果を返す)、次のように設定します `empty_result_for_aggregation_by_empty_set` 1になります。 -- のための追加された型変換 `UNION ALL`. 異なるエイリアス名は `SELECT` の位置 `UNION ALL` を遵のSQL標準装備。 -- 任意の式がサポートされます `LIMIT BY` 句。 これまでは、以下の結果の列のみを使用することができました `SELECT`. -- の指標 `MergeTree` 表は次の場合に使用されます `IN` 主キーの列からの式のタプルに適用されます。 例えば: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` (アナスタシヤTsarkova)。 -- を追加しました `clickhouse-copier` ツールのコピーとクラスター reshardingデータ(β). -- 一貫性のあるハッシュ機能を追加: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. ものとして使用できshardingキーを減らすため、ネットワークトラフィックの中でその後のreshardings. -- 機能追加: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. -- を追加しました `arrayCumSum` 関数(Javi Santana)。 -- を追加しました `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero`、と `parseDateTimeBestEffortOrNull` さまざまな形式のテキストを含む文字列からDateTimeを読み取る関数。 -- データは、更新中に外部の辞書から部分的にリロードすることができます(前回のダウンロードよりも指定されたフィールドの値が大きいレコードのみをロー -- を追加しました `cluster` テーブル機能。 例えば: `cluster(cluster_name, db, table)`. その `remote` テーブル機能で、クラスター名の最初の引数として、指定された場合は、識別子です。 -- その `remote` と `cluster` テーブル関数は以下で使用できます `INSERT` クエリ。 -- を追加しました `create_table_query` と `engine_full` への仮想列 `system.tables`テーブル。 その `metadata_modification_time` 列は仮想です。 -- を追加しました `data_path` と `metadata_path` 列へ `system.tables`と`system.databases` テーブル、および追加された `path` コラムへの `system.parts` と `system.parts_columns` テーブル。 -- のマージに関する追加情報を追加しました。 `system.part_log` テーブル。 -- 任意のパーティショニングキーを使用できます。 `system.query_log` テーブル(キリルShvakov)。 -- その `SHOW TABLES` クエリの現在も仮設ます。 追加された一時テーブルと `is_temporary` コラムへの `system.tables` (zhang2014)。 -- 追加 `DROP TEMPORARY TABLE` と `EXISTS TEMPORARY TABLE` クエリ(zhang2014)。 -- のサポート `SHOW CREATE TABLE` 一時テーブル(zhang2014)のため。 -- を追加しました `system_profile` 内部プロセスで使用される設定の構成パラメーター。 -- 読み込みのサポート `object_id` 属性として `MongoDB` 辞書(パベルLitvinenko)。 -- 読む `null` 外部ディクショナリのデータを読み込むときのデフォルト値として `MongoDB` ソース(パベルLitvinenko)。 -- 読む `DateTime` の値 `Values` 一重引quotesのないUnixタイムスタンプからの形式。 -- サポート `remote` レプリカの一部が要求されたテーブルが欠落している場合のテーブル関数。 -- 構成設定は、実行時にコマンドラインでオーバーライドできます `clickhouse-server`. 例えば: `clickhouse-server -- --logger.level=information`. -- 実装された `empty` aからの関数 `FixedString` 引数:文字列が完全にヌルバイト(zhang2014)で構成されている場合、関数は1を返します。 -- を追加しました `listen_try`一部のアドレスがリッスンできない場合は、少なくとも一つのリッスンアドレスをリッスンするための設定パラメータ(IPv4またはIPv6のサポートが -- を追加しました `VersionedCollapsingMergeTree` テーブルエンジン。 -- の行と任意の数値型のサポート `library` 辞書ソース。 -- `MergeTree` テーブルは主キーなしで使用できます(指定する必要があります `ORDER BY tuple()`). -- A `Nullable` タイプは `CAST` 非に-`Nullable` 引数が指定されていない場合はtype `NULL`. -- `RENAME TABLE` 以下のために実行できます `VIEW`. -- を追加しました `throwIf` 機能。 -- を追加しました `odbc_default_field_size` ODBCソースからロードされた値の最大サイズを拡張できるオプション(既定では1024)。 -- その `system.processes` テーブルと `SHOW PROCESSLIST` 今すぐ `is_cancelled` と `peak_memory_usage` 列。 - -#### 改善: {#improvements-15} - -- 結果の制限とクォータは、以下の中間データには適用されなくなりました `INSERT SELECT` クエリまたは `SELECT` サブクエリー -- 偽のトリガーが少ない `force_restore_data` 状態をの点検した場合 `Replicated` サーバーの起動時のテーブル。 -- を追加しました `allow_distributed_ddl` オプション。 -- 非決定的関数は、次の式では使用できません `MergeTree` テーブルキー。 -- からの置換を伴うファイル `config.d` ディレクト -- の改善された性能 `arrayElement` 要素の一つとして空の配列を持つ定数多次元配列の場合の関数。 例えば: `[[1], []][x]`. -- サーバの開始に高速化した現在の使用時に設定ファイルの非常に大き換(例えば、非常に大きなリストのipネットワーク). -- クエリを実行する場合、テーブル値関数は一度実行されます。 以前は, `remote` と `mysql` テーブル機能評価を行い、同じクエリを取得するにはテーブル構造からのリモートサーバーです。 -- その `MkDocs` ドキュメントジェネレータを使用します。 -- テーブルの列を削除しようとすると `DEFAULT`/`MATERIALIZED` 他の列の式は、例外がスローされる(zhang2014)。 -- テキスト形式の空行を0の数値として解析する機能を追加しました `Float` データ型。 この機能は以前は利用可能でしたが、リリース1.1.54342で失われました。 -- `Enum` 値は次の場所で使用できます。 `min`, `max`, `sum` といくつかの他の機能。 このような場合は、対応する数値を使用します。 この機能は以前は利用可能でしたが、リリース1.1.54337で失われました。 -- 追加 `max_expanded_ast_elements` 再帰的にエイリアスを展開した後にASTのサイズを制限する。 - -#### バグ修正: {#bug-fixes-27} - -- サブクエリから不要な列が誤って削除された場合、またはサブクエリを含むサブクエリから削除されなかった場合 `UNION ALL`. -- のためのマージのバグを修正しました `ReplacingMergeTree` テーブル。 -- 固定synchronousの挿入 `Distributed` テーブル (`insert_distributed_sync = 1`). -- 特定の用途のための固定segfault `FULL` と `RIGHT JOIN` サブクエリに重複する列がある場合。 -- 特定の用途のための固定segfault `replace_running_query` と `KILL QUERY`. -- の順序を修正しました `source` と `last_exception` の列 `system.dictionaries` テーブル。 -- ときにバグを修正 `DROP DATABASE` クエリを削除しなかったファイルとメタデータを指すものとします。 -- 修正された `DROP DATABASE` のためのクエリ `Dictionary` データベース -- 固定の低精度 `uniqHLL12` と `uniqCombined` 100万のアイテム(アレックスBocharov)より大きな基数のための機能。 -- 固定の計算の暗黙のデフォルト値が必要な場合には同時に計算デフォルトの明示的な表現 `INSERT` クエリ(zhang2014)。 -- まれなケースを修正するときにクエリ `MergeTree` テーブルは終えることができなかった(chenxing-xc)。 -- 実行しているときに発生したクラッシュを修正 `CHECK` のためのクエリ `Distributed` すべてのシャードがローカルの場合はテーブル(chenxing.xc)。 -- 正規表現を使用する関数で、わずかなパフォーマンス回帰を修正しました。 -- 複雑な式から多次元配列を作成する際のパフォーマンスの回帰を修正しました。 -- 余分な原因となるバグを修正しました `FORMAT` に表示されるセクション `.sql` ファイ -- その原因となったバグを修正 `max_table_size_to_drop` 削除しようとするときに適用する制限 `MATERIALIZED VIEW` 明示的に指定されたテーブルを調べる。 -- 古いクライアントとの非互換性を修正しました(古いクライアン `DateTime('timezone')` 彼らは理解していないタイプ)。 -- 読み込み時のバグを修正 `Nested` を使用して追加された構造体の列要素 `ALTER` しかし、これらの列の条件が移動したときに、古いパーティションでは空です `PREWHERE`. -- 時の不具合を修正フィルタリングテーブルによる仮想 `_table` クエリの列 `Merge` テーブル。 -- 使用する際のバグを修正しました `ALIAS` の列 `Distributed` テーブル。 -- から集計関数を持つクエリのための動的コンパイルが不可能になったバグを修正 `quantile` 家族 -- クエリ実行パイプラインの競合状態を修正しました。 `Merge` 多数のテーブルを持つテーブル、および使用時 `GLOBAL` サブクエリー -- に異なるサイズの配列を渡すときにクラッシュを修正 `arrayReduce` 複数の引数から集約関数を使用する場合の関数です。 -- とのクエリの使用を禁止 `UNION ALL` で `MATERIALIZED VIEW`. -- の初期化中にエラーを修正しました `part_log` サーバ起動時のシステムテーブル(デフォルト, `part_log` が無効になっています)。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-10} - -- 削除された `distributed_ddl_allow_replicated_alter` オプション。 この動作は既定で有効になっています。 -- 削除された `strict_insert_defaults` 設定。 この機能を使用している場合は、次のように記述します `clickhouse-feedback@yandex-team.com`. -- 削除された `UnsortedMergeTree` エンジン。 - -### Clickhouseリリース1.1.54343、2018-02-05 {#clickhouse-release-1-1-54343-2018-02-05} - -- 分散ddlクエリおよび分散テーブルのコンストラクタでクラスタ名を定義するためのマクロの追加: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. -- 今のようなクエリ `SELECT ... FROM table WHERE expr IN (subquery)` を使用して処理されます `table` インデックス -- 処理能の重複を挿入する場合はを再現し、テーブルではなく実行を複製します。 - -### Clickhouseリリース1.1.54342、2018-01-22 {#clickhouse-release-1-1-54342-2018-01-22} - -このリリースには、以前のリリース1.1.54337のバグ修正が含まれています: - -- 1.1.54337の回帰を修正しました:デフォルトのユーザーが読み取り専用アクセスを持っている場合、サーバーは、メッセージで起動することを拒否 `Cannot create database in readonly mode`. -- 1.1.54337の回帰を修正しました:systemdを持つシステムでは、設定に関係なく常にsyslogにログが書き込まれます。d -- ドッカー画像で間違ったデフォルト設定:1.1.54337での回帰を修正しました。 -- GraphiteMergeTreeの非決定的動作を修正しました(ログメッセージで見ることができます `Data after merge is not byte-identical to the data on another replicas`). -- なることがある不具合を修正しつ一貫性のない合併後最適なクエリーの複製のテーブル(きめて発見されたログメッセージ `Part ... intersects the previous part`). -- バッファーの表現は正常に動作が実現列の先テーブル(zhang2014). -- NULLの実装のバグを修正しました。 - -### Clickhouseリリース1.1.54337、2018-01-18 {#clickhouse-release-1-1-54337-2018-01-18} - -#### 新しい機能: {#new-features-17} - -- 多次元配列およびタプルの格納に対するサポートが追加されました (`Tuple` テーブル内のデータ型)。 -- テーブル関数のサポート `DESCRIBE` と `INSERT` クエリ。 サブクエリのサポートが追加されました `DESCRIBE`. 例: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. のサポート `INSERT INTO TABLE` に加えて `INSERT INTO`. -- タイムゾーンのサポートの改善。 その `DateTime` データ型は、テキスト形式の解析と書式設定に使用されるタイムゾーンで注釈を付けることができます。 例えば: `DateTime('Europe/Moscow')`. タイムゾーンが指定されている場合 `DateTime` 引数を指定すると、戻り値の型はタイムゾーンを追跡し、値は期待どおりに表示されます。 -- 機能を追加しました `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. その `toRelativeHour`/`Minute`/`Second` 関数はtypeの値を取ることができます `Date` 引数として。 その `now` 関数名は大文字と小文字が区別されます。 -- を追加しました `toStartOfFifteenMinutes` 機能(キリルShvakov)。 -- を追加しました `clickhouse format` ツールのためのフォーマットのクエリ. -- を追加しました `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` フォーマット。 スキーマファイ -- 設定置換のサポートが追加されました (`incl` と `conf.d`)外部辞書やモデル(パベルYakunin)の構成のために。 -- のドキュメントと列を追加しました `system.settings` テーブル(キリルShvakov)。 -- を追加しました `system.parts_columns` 各データ部分の列サイズに関する情報を持つテーブル `MergeTree` テーブル。 -- を追加しました `system.models` loadedに関する情報を含む表 `CatBoost` 機械学習モデル。 -- を追加しました `mysql` と `odbc` テーブル機能と対応 `MySQL` と `ODBC` テーブルエンジン この機能はベータ段階です。 -- 型の引数を渡す可能性を追加しました `AggregateFunction` のための `groupArray` 集計関数(集計関数の状態の配列を作成できます)。 -- 削除の制限を様々に組み合わせて集計機能combinators. たとえば、次のものを使用できます `avgForEachIf` 同様に `avgIfForEach` 集計機能の異なる行動です。 -- その `-ForEach` 集合関数combinatorのは、複数の引数の集約関数の場合に拡張されます。 -- の集計関数のサポートを追加しました `Nullable` 引数をもた場合は、関数が返す非-`Nullable` 結果(Silviu Carageaの貢献を追加しました)。 例えば: `groupArray`, `groupUniqArray`, `topK`. -- を追加しました `max_client_network_bandwidth` のために `clickhouse-client` (キリルShvakov)。 -- ユーザーの `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). -- 複数の消費者を使用するためのサポートを追加 `Kafka` エンジン。 の拡張構成オプション `Kafka` (Marek Vavruša). -- を追加しました `intExp3` と `intExp4` 機能。 -- を追加しました `sumKahan` 集計関数。 -- ここで、\*number\*は数値型です。 -- のサポートを追加 `WITH` aの句 `INSERT SELECT` クエリ(著者:zhang2014)。 -- 追加された設定: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. 特に、これらの設定のためのデータのダウンロードパーツのレプリケーション. を変更する設定できる高速フェイルオーバーの場合はネットワークが過負荷状態で運転されています。 -- のサポートを追加 `ALTER` テーブルの型 `Null` (アナスタシヤTsarkova)。 -- その `reinterpretAsString` 関数は、メモリに連続して格納されているすべてのデータ型に対して拡張されます。 -- を追加しました `--silent` のための選択 `clickhouse-local` ツール。 Stderrでクエリ実行情報を出力しないようにします。 -- Typeの値を読み取るためのサポートを追加 `Date` fromテキストの形式で、月の月または日が二桁(Amos Bird)ではなく一桁の数字を使用して指定されています。 - -#### パフォーマンスの最適化: {#performance-optimizations} - -- 集計関数のパフォーマンスの向上 `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` 文字列引数から。 -- 機能のパフォーマンスの向上 `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. -- 解析と書式設定のパフォーマンスの向上 `Date` と `DateTime` テキスト形式で値を入力します。 -- 浮動小数点数の解析のパフォーマンスと精度が向上しました。 -- メモリ使用量の削減 `JOIN` れた場合、左右のパーツはカラムと同じ名前がつけられていますが含まれない `USING` . -- 集計関数のパフォーマンスの向上 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` 計算の安定性を減らします 古い関数は、名前の下で利用可能です `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. - -#### バグ修正: {#bug-fixes-28} - -- 実行後のデータ重複除外を修正しました `DROP` または `DETACH PARTITION` クエリ。 以前のバージョン、パーティションに挿入し、同じデータを再度はありませんが挿入されブロックを考慮した重複している。 -- の誤った解釈につながる可能性のあるバグを修正しました `WHERE` のための節 `CREATE MATERIALIZED VIEW` とのクエリ `POPULATE` . -- を使用してのバグを修正しました `root_path` のパラメータ `zookeeper_servers` 構成。 -- 固定予期しない結果を渡す `Date` の引数 `toStartOfDay` . -- 修正された `addMonths` と `subtractMonths` 機能および算術のための `INTERVAL n MONTH` 結果は前年を持っている場合には。 -- のためのサポートが不足して追加 `UUID` のデータ型 `DISTINCT` , `JOIN` 、と `uniq` 集計機能-外部辞書(Evgeniyイワノフ). のサポート `UUID` まだ不完全です。 -- 固定 `SummingMergeTree` 行がゼロに加算された場合の動作。 -- のための様々な修正 `Kafka` engine (Marek Vavruša). -- の誤った動作を修正しました `Join` テーブルエンジン(アモス鳥)。 -- 固定の誤ったアロケータの組み合わせによる動作os、os xで動作します。 -- その `extractAll` 機能に対応しま空いる。 -- の使用をブロックエラーを修正しました `libressl` 代わりに `openssl` . -- 修正された `CREATE TABLE AS SELECT` 一時テーブルからのクエリ。 -- 固定非atomicityの更新を複製します。 このレプリカとの同期までのサーバが再起動してしまいます。 -- 固定可能なオーバーフロー `gcd` , `lcm` と `modulo` (`%` 演算子)(Maks Skorokhod). -- `-preprocessed` ファイルは現在、変更後に作成されます `umask` (`umask` 設定で変更することができます)。 -- 部品のバックグラウンドチェックのバグを修正 (`MergeTreePartChecker` カスタムパーティションキーを使用する場合。 -- タプル(の値)の固定解析 `Tuple` テキスト形式のデータ型)。 -- 向上しエラーメッセージとして互換性のない型を渡す `multiIf` , `array` といくつかの他の機能。 -- サポートの再設計 `Nullable` タイプ。 サーバーがクラッシュするバグを修正。 固定に関連する他のほとんどすべてのバグ `NULL` サポート:INSERT SELECTでの型変換が正しくない、HAVINGおよびPREWHEREでのNullableのサポートが不十分, `join_use_nulls` の引数としてNull可能な型 `OR` オペレーター等 -- データ型の内部セマンティクスに関連するさまざまなバグを修正。 例:不要な加算 `Enum` タイプフィールド `SummingMergeTree` ;の整列 `Enum` タイプ `Pretty` フォーマット、等。 -- 複合列の許容される組み合わせを厳密にチェックします。 -- オーバーフローを修正 `FixedString` データ型。 -- のバグを修正しました `topK` ジェネリックケースの集計関数。 -- 集計関数のn-aryバリアントの引数に配列サイズが等しいかどうかのチェックが欠けていることを追加しました `-Array` コンビネータ -- でバグを修正しました `--pager` のために `clickhouse-client` (著者:ks1322)。 -- の精度を修正しました `exp10` 機能。 -- の動作を修正しました `visitParamExtract` 機能により遵守します。 -- 固定をした場合クラッシュする不正確なデータ種を指定します。 -- の動作を修正しました `DISTINCT` すべての列が定数の場合。 -- 使用する場合の固定クエリの書式設定 `tupleElement` タプル要素インデックスとして複素数定数式を持つ関数。 -- でバグを修正しました `Dictionary` テーブルのため `range_hashed` 辞書だ -- の結果に過度の行につながるバグを修正しました `FULL` と `RIGHT JOIN` (アモス鳥)。 -- 固定サーバのクラッシュの作成時に除去の一時ファイル `config.d` ディレクトリの中configしてください。 -- 修正された `SYSTEM DROP DNS CACHE` クエリのキャッシュをフラッシュがアドレスのクラスタノードが更新されません。 -- の動作を修正しました `MATERIALIZED VIEW` 実行後 `DETACH TABLE` for the table under the view (Marek Vavruša). - -#### ビルドの改善: {#build-improvements-4} - -- その `pbuilder` ツールはビルドに使用されます。 ビルドプロセスは、ビルドホスト環境からほぼ完全に独立しています。 -- 単一のビルドは、異なるosバージョンに使用されます。 パッケージおよびバイナリはlinuxシステムの広い範囲と互換性があるようにされた。 -- を追加しました `clickhouse-test` パッケージ。 機能テストの実行に使用できます。 -- ソースtarballをリポジトリに公開できるようになりました。 これは、githubを使用せずにビルドを再現するために使用できます。 -- Travis CIとの限定的な統合が追加されました。 Travisのビルド時間に制限があるため、デバッグビルドのみがテストされ、テストの限られたサブセットが実行されます。 -- のサポートを追加 `Cap'n'Proto` デフォルトのビルドで。 -- ドキュメントソースのフォーマットを `Restricted Text` に `Markdown`. -- のサポートを追加 `systemd` (ウラジミールスミルノフ)。 これはデフォルトでは無効に設定により不適合一部のOSの画像を有効にすることができます。 -- 動的コード生成の場合, `clang` と `lld` に埋め込まれます `clickhouse` バイナリ 彼らはまた、 `clickhouse clang` と `clickhouse lld` . -- コードからgnu拡張の使用を削除しました。 を有効にする `-Wextra` オプション。 ビルドするとき `clang` デフォルトは `libc++` 代わりに `libstdc++`. -- 抽出 `clickhouse_parsers` と `clickhouse_common_io` 図書館を高速ビルドの様々なツールです。 - -#### 下位互換性のない変更: {#backward-incompatible-changes-11} - -- マークの書式 `Log` 以下を含む表を入力します `Nullable` 列は、下位互換性のない方法で変更されました。 これらのテーブルがある場合は、これらのテーブルを `TinyLog` タイプ前のサーババージョン。 これを行うには、 `ENGINE = Log` と `ENGINE = TinyLog` 対応する `.sql` のファイル `metadata` ディレクトリ。 あなたのテーブルに `Nullable` 列またはテーブルの型がそうでない場合 `Log`、その後、あなたは何もする必要はありません。 -- 削除された `experimental_allow_extended_storage_definition_syntax` 設定。 この機能はデフォルトで有効になりました。 -- その `runningIncome` 関数の名前が変更されました `runningDifferenceStartingWithFirstvalue` 混乱を避けるため。 -- 削除された `FROM ARRAY JOIN arr` 配列結合がテーブルなしでFROMの直後に指定されたときの構文(Amos Bird)。 -- 削除された `BlockTabSeparated` デモンストレーション目的でのみ使用された形式。 -- 集計関数の状態フォーマットを変更 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. これらの集計関数の状態をテーブルに格納している場合(以下を使用 `AggregateFunction` 対応する状態のデータ-タイプか具体化された眺めは)、に書きますclickhouse-feedback@yandex-team.com。 -- 集計関数がパラメータに依存している場合でも、aggregatefunctionデータ型でパラメータなしで指定できます。 例えば: `AggregateFunction(quantiles, UInt64)` 代わりに `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. この機能は失われました。 それは文書化されていませんでしたが、我々は将来のリリースで再びそれをサポートする予定。 -- Enumデータ型は、最小/最大集計関数では使用できません。 この能力は、次のリリースで返されます。 - -#### ご注意ください: {#please-note-when-upgrading} - -- クラスター上でローリングアップデートを実行する場合、レプリカの一部が古いバージョンのclickhouseを実行していて、一部のレプリカが新しいバージョンを実行 `unknown parameter 'shard'` ログに表示されます。 レプリケーションは今後すべてのレプリカクラスターを更新しました。 -- 場合により、異なるバージョンのclickhouseにクラスタサーバで分散クエリは以下の関数を使って誤った結果: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. まアップデートすべきであるすべてのクラスタノード。 - -## [2017年の変更履歴](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2017.md) {#changelog-for-2017} diff --git a/docs/ja/whats_new/changelog/2019.md b/docs/ja/whats_new/changelog/2019.md deleted file mode 100644 index 47351882033..00000000000 --- a/docs/ja/whats_new/changelog/2019.md +++ /dev/null @@ -1,2074 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 77 -toc_title: '2019' ---- - -## ClickHouseリリースv19.17 {#clickhouse-release-v19-17} - -### ClickHouseリリースv19.17.6.36,2019-12-27 {#clickhouse-release-v19-17-6-36-2019-12-27} - -#### バグ修正 {#bug-fix} - -- Decompressでバッファオーバーフローの可能性を修正 悪意のあるユーザーで製作した圧縮データが読み後のバッファです。 この問題は、Yandexの情報セキュリティチームのEldar Zaitovによって発見されました。 [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定可能なサーバのクラッシュ (`std::terminate`)サーバーがJsonまたはXML形式で文字列データ型(UTF-8検証が必要)の値を使用してデータを送信または書き込むことができない場合、またはBrotliアルゴリズムま [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クリックハウスからのソースを持つ固定辞書 `VIEW` 今、そのような辞書を読んでもエラーは発生しません `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定照合するクライアントホストで許可されhost\_regexp指定されます。xmlだ [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([Vitaly Baranov](https://github.com/vitlibar)) -- `RENAME TABLE` 分散表現に変更、フォルダが挿入されデータを送信する前に破片. これにより、連続した名前変更の問題が修正されます `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) -- `range_hashed` 外部辞書作成DDLわきの範囲は任意の数値です。 [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([alesapin](https://github.com/alesapin)) -- 固定 `INSERT INTO table SELECT ... FROM mysql(...)` テーブル機能。 [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) -- 固定segfaultで `INSERT INTO TABLE FUNCTION file()` 存在しないファイルに挿入している間。 この場合、ファイルが作成され、insertが処理されます。 [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) -- 集計ビットマップとスカラビットマップとの交差時にビットマップとエラーを修正 [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([越黄](https://github.com/moon03432)) -- 固定segfault時 `EXISTS` クエリが使用されなかった `TABLE` または `DICTIONARY` 修飾子,ちょうどのような `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 関数の戻り値の型を修正 `rand` と `randConstant` nullable引数の場合。 Now関数は常に戻ります `UInt32` そして決して `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定 `DROP DICTIONARY IF EXISTS db.dict` 今は例外をスローしません `db` 存在しない [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([Vitaly Baranov](https://github.com/vitlibar)) -- さん完全に落ちてしまったがサーバのクラッシュ、サーバへの復元とその負荷で [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) -- 複数のシャードローカルテーブルが存在する場合、分散テーブルの簡単なカウントクエリが修正されました。 [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- DB::BlockStreamProfileInfo::calculateRowsBeforeLimitのデータレースにつながるバグを修正しました() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([Alexander Kazakov](https://github.com/Akazz)) -- 固定 `ALTER table MOVE part` 実行直後の統合、指定された部分を引き起こす可動部を、指定された部分に統合します。 今度は、指定された部分を正しく移動します。 [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 辞書の式を文字列として指定できるようになりました。 これは、非clickhouseソースからデータを抽出する際に、それらの式に非clickhouse構文を使用できるため、属性の計算に役立ちます。 [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([alesapin](https://github.com/alesapin)) -- で非常にまれなレースを修正しました `clickhouse-copier` ZXidのオーバーフローのため。 [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([丁象飛](https://github.com/dingxiangfei2009)) -- クエリが失敗した後にバグを修正しました(原因 “Too many simultaneous queries” たとえば、外部テーブル情報を読み込まず、 - 次の要求は、この情報を次のクエリの先頭と解釈し、次のようなエラーを引き起こします `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) -- 後にnull逆参照を避ける “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) -- すべてのicuロケールのサポートを復元し、定数式の照合順序を適用し、システムに言語名を追加する機能を追加します。照合テーブル。 [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([alesapin](https://github.com/alesapin)) -- 読み込み元のストリームの数 `StorageFile` と `StorageHDFS` メモリ制限を超えないように制限されています。 [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([alesapin](https://github.com/alesapin)) -- 固定 `CHECK TABLE` のためのクエリ `*MergeTree` キーのないテーブル。 [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([alesapin](https://github.com/alesapin)) -- 変異がなかった場合には、部分名から突然変異番号を削除しました。 この除去との互換性を高め、古いバージョン. [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([alesapin](https://github.com/alesapin)) -- テーブルバージョンよりもdata\_versionが大きいため、一部のアタッチされたパーツに対して変異がスキップされる不具合を修正した。 [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([Zhichang Yu](https://github.com/yuzhichang)) -- 別のデバイスに移動した後、部品の冗長コピーを使用してサーバーを起動できます。 [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) -- エラーを修正しました “Sizes of columns doesn’t match” これは、集計関数列を使用する場合に表示されます。 [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) -- LIMIT BYと一緒にWITH TIESを使用する場合は、例外がスローされます。 そして今、トップをLIMIT BYで使うことができます。 [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- それが持っている場合 `invalidate_query` これは、以前の更新試行時に更新といくつかの例外を停止しました。 [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([alesapin](https://github.com/alesapin)) - -### ClickHouseリリースv19.17.4.11、2019-11-22 {#clickhouse-release-v19-17-4-11-2019-11-22} - -#### 下位互換性のない変更 {#backward-incompatible-change} - -- 使用カラムの代わりにastビスカラサブクエリの結果よりよい。 設定 `enable_scalar_subquery_optimization` 19.17で追加され、デフォルトで有効になりました。 繋がるようなエラー [この](https://github.com/ClickHouse/ClickHouse/issues/7851) 以前のバージョンから19.17.2または19.17.3にアップグレード中。 この設定はデフォルトで無効にで19.17.4、可能からのアップグレード19.16、以前のバージョンなします。 [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([アモスの鳥](https://github.com/amosbird)) - -#### 新しい機能 {#new-feature} - -- DDLクエリで辞書を作成する機能を追加します。 [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([alesapin](https://github.com/alesapin)) -- 作る `bloom_filter` 索引をサポートするタイプ `LowCardinality` と `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 機能を追加 `isValidJSON` 渡された文字列が有効なjsonであることを確認する。 [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([Vdimir](https://github.com/Vdimir)) -- 実装 `arrayCompact` 機能 [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([メモ](https://github.com/Joeywzr)) -- 作成された機能 `hex` 十進数のため。 それはのように働く `hex(reinterpretAsString())`、しかし、最後のゼロバイトを削除しません。 [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([Mikhail Korotov](https://github.com/millb)) -- 追加 `arrayFill` と `arrayReverseFill` 配列内のそれらの前後の他の要素によって要素を置き換える関数。 [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([hcz](https://github.com/hczhcz)) -- 追加 `CRC32IEEE()`/`CRC64()` サポート [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([Azat Khuzhin](https://github.com/azat)) -- 実装 `char` 関数に似ています。 [mysql](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([sundyli](https://github.com/sundy-li)) -- 追加 `bitmapTransform` 機能。 これは、ビットマップ内の値の配列を別の値の配列に変換し、結果は新しいビットマップになります [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([Zhichang Yu](https://github.com/yuzhichang)) -- 実装 `javaHashUTF16LE()` 機能 [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([achimbabcomment](https://github.com/achimbab)) -- 追加 `_shard_num` 分散エンジンの仮想列 [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([Azat Khuzhin](https://github.com/azat)) - -#### 実験的特徴 {#experimental-feature} - -- 新しいクエリ実行パイプライン)のサポート `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### バグ修正 {#bug-fix-1} - -- 不正な浮動小数点解析の修正 `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) -- Trace\_logが有効になっているときに発生する稀なデッドロックを修正します。 [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([フィリモノフ](https://github.com/filimonov)) -- 防止のメッセージの複製を制作するカフカテーブルには、mvsの選択からで [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([イワン](https://github.com/abyss7)) -- のサポート `Array(LowCardinality(Nullable(String)))` で `IN`. 解決 [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([achimbabcomment](https://github.com/achimbab)) -- の処理を追加 `SQL_TINYINT` と `SQL_BIGINT`、および修正の取り扱い `SQL_FLOAT` ODBCブリッジのデータソースの種類。 [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) -- 集約の修正 (`avg` 空の小数点以下桁数を超えた場合 [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([Andrey Konyaev](https://github.com/akonyaev90)) -- 修正 `INSERT` 分散に `MATERIALIZED` 列 [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) -- 作る `MOVE PARTITION` 仕事のパーツがあった場合にエントランスは目を引く壁面緑化依存度はさほど高くないものの、保存先ディスクまたは量 [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) -- ハードリンクがで突然変異の間に作成されるために失敗したバグを修正 `ReplicatedMergeTree` マルチディスク構成で。 [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 部分全体が変更されず、最高のスペースが別のディスク上に発見されているときmergetreeに変異を持つバグを修正しました [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([Vladimir Chebotarev](https://github.com/excitoon)) -- とのバグを修正 `keep_free_space_ratio` ディスク構成から読み取られない [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([Vladimir Chebotarev](https://github.com/excitoon)) -- テーブルのみを含むバグを修正 `Tuple` 複雑なパスを持つ列または列。 修正 [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([alesapin](https://github.com/alesapin)) -- Max\_memory\_usage制限のバッファエンジンのメモリを考慮しない [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([Azat Khuzhin](https://github.com/azat)) -- で最終的なマークの使用状況を修正 `MergeTree` テーブルの順序付け `tuple()`. まれにそれはに導くことができます `Can't adjust last granule` 選択中にエラー。 [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([アントン-ポポフ](https://github.com/CurtizJ)) -- クラッシュや奇妙な例外につながる可能性があり、コンテキスト(jsonのための例の機能)を必要とするアクションと述語を持っている変異のバグを [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([alesapin](https://github.com/alesapin)) -- データベース名とテーブル名の不一致を修正 `data/` と `shadow/` ディレク [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([Alexander Burmak](https://github.com/Alex-Burmak)) -- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. この場合のクラッシュを修正。 [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正 `Not found column in block` RIGHTまたはFULL JOINでexpressionに参加するとき。 [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([Artem Zuikov](https://github.com/4ertus2)) -- 無限ループを修正するもう一つの試み `PrettySpace` 書式 [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([Olga Khvostikova](https://github.com/stavrolia)) -- バグを修正 `concat` すべての引数が `FixedString` 同じサイズの。 [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([alesapin](https://github.com/alesapin)) -- S3、URLおよびHDFSストレージを定義しながら、1引数を使用した場合の例外を修正しました。 [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([Vladimir Chebotarev](https://github.com/excitoon)) -- クエリでビューのinterpreterselectqueryのスコープを修正 [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([Azat Khuzhin](https://github.com/azat)) - -#### 改善 {#improvement} - -- `Nullable` ODBCブリッジによって正しく処理される列とNULL値 [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([Vasily Nemkov](https://github.com/Enmk)) -- 分散送信の現在のバッチをアトミックに書き込む [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([Azat Khuzhin](https://github.com/azat)) -- クエリで列名のテーブルを検出できない場合は、例外をスローします。 [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `merge_max_block_size` に設定する `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([Artem Zuikov](https://github.com/4ertus2)) -- とのクエリ `HAVING` とせずに `GROUP BY` 当グループによる定数です。 だから, `SELECT 1 HAVING 1` 今すぐ結果を返します。 [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([アモスの鳥](https://github.com/amosbird)) -- サポート解析 `(X,)` pythonに似たタプルとして。 [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([アモスの鳥](https://github.com/amosbird)) -- 作る `range` 関数の振る舞いはpythonicのようなものです。 [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([sundyli](https://github.com/sundy-li)) -- 追加 `constraints` テーブルへの列 `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([Vitaly Baranov](https://github.com/vitlibar)) -- より良いnullの場合形式のtcpハンドラで利用可能 `select ignore() from table format Null` clickhouseによるperfの測定のため-顧客 [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([アモスの鳥](https://github.com/amosbird)) -- のようなクエリ `CREATE TABLE ... AS (SELECT (1, 2))` 正しく解析されます [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([hcz](https://github.com/hczhcz)) - -#### 性能向上 {#performance-improvement} - -- 短い文字列キーに対する集約のパフォーマンスが向上しました。 [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([Alexander Kuzmenkov](https://github.com/akuzm), [アモスの鳥](https://github.com/amosbird)) -- 構文/式分析の別のパスを実行して、定数述部が折り畳まれた後に潜在的な最適化を取得します。 [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([アモスの鳥](https://github.com/amosbird)) -- ストレージメタ情報を使用して簡単に評価する `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([アモスの鳥](https://github.com/amosbird), [alexey-milovidov](https://github.com/alexey-milovidov)) -- ベクトル化処理 `arrayReduce` アグリゲータと同様です `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([アモスの鳥](https://github.com/amosbird)) -- の性能のマイナーな改善 `Kafka` 消費 [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([イワン](https://github.com/abyss7)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement} - -- クロスコンパイルのサポートをcpuアーキテクチャaarch64に追加します。 リファクタリング [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([イワン](https://github.com/abyss7)) -- パッケージのビルド時に、darwin-x86\_64およびlinux-aarch64ツールチェーンをマウントされたdockerボリュームに解凍する [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([イワン](https://github.com/abyss7)) -- 更新docker画像のバイナリーベル [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([イワン](https://github.com/abyss7)) -- MacOSのカタリナの固定コンパイルエラー [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([Ernest Poletaev](https://github.com/ernestp)) -- クエリ分析ロジックのリファクタリング:複雑なクラスを複数の単純なクラスに分割します。 [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([Artem Zuikov](https://github.com/4ertus2)) -- サブモジュールなしでビルドを修正 [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([proller](https://github.com/proller)) -- より良い `add_globs` CMakeファイル内 [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([アモスの鳥](https://github.com/amosbird)) -- ハードコードされたパスの削除 `unwind` ターゲット [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([Konstantin Podshumok](https://github.com/podshumok)) -- Sslなしでmysql形式を使用できるようにする [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([proller](https://github.com/proller)) - -#### その他 {#other} - -- ClickHouse SQLダイアレクトのANTLR4文法を追加 [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## ClickHouseリリースv19.16 {#clickhouse-release-v19-16} - -#### Clickhouseリリースv19.16.14.65,2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} - -- 複数の引数(10以上)の三元論理演算のバッチ計算のバグを修正しました。 [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([Alexander Kazakov](https://github.com/Akazz))このバグ修正は、Altinityからの特別な要求によってバージョン19.16にバックポートされました。 - -#### Clickhouseリリースv19.16.14.65,2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} - -- 古いchバージョンとの分散サブクエリの非互換性を修正しました。 修正 [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) - [(tabplubix)](https://github.com/tavplubix) -- 実行時期 `CREATE` クエリー、倍定表現のストレージエンジンの引数です。 空のデータベース名を現在のデータベ 修正 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). また、ローカルアドレスの確認を修正 `ClickHouseDictionarySource`. - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) -- 今、背景には、マージ `*MergeTree` テーブルエンジンの家族の保存-保存政策に大量注文しております。 - [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) -- データを失うのを防ぐ `Kafka` まれに、接尾辞を読んだ後でコミットする前に例外が発生した場合。 修正 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). 関連: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(フィリモノフ)](https://github.com/filimonov) -- のを修正した。先サーバを終了しようとした場合に使用/drop `Kafka` テーブル作成されたパラメータ。 修正 [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). 組み込み [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(フィリモノフ)](https://github.com/filimonov) -- 使用を許可する `MaterializedView` 上記のサブクエリを使用する `Kafka` テーブル。 - [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([フィリモノフ](https://github.com/filimonov)) - -#### 新しい機能 {#new-feature-1} - -- 追加 `deduplicate_blocks_in_dependent_materialized_views` マテリアライズドビューを持つテーブルへの冪等挿入の動作を制御するオプション。 この新機能は、Altinityからの特別な要求によってbugfixリリースに追加されました。 - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) - -### ClickHouseリリースv19.16.2.2、2019-10-30 {#clickhouse-release-v19-16-2-2-2019-10-30} - -#### 下位互換性のない変更 {#backward-incompatible-change-1} - -- Count/counIfに不足しているアリティ検証を追加します。 - [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) - [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([Vdimir](https://github.com/Vdimir)) -- レガシーを削除 `asterisk_left_columns_only` 設定(デフォルトでは無効になっていました)。 - [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([Artem - Zuikov](https://github.com/4ertus2)) -- フォーマット文字列のためのテンプレートデータの形式は指定のファイルです。 - [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([tavplubix](https://github.com/tavplubix)) - -#### 新しい機能 {#new-feature-2} - -- Uint\_maxより大きい基数を計算するために、uniqCombined64()を導入します。 - [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), - [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([Azat - Khuzhin](https://github.com/azat)) -- 支援bloom filterを指標配列に列あります。 - [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) - ([achimbabcomment](https://github.com/achimbab)) -- 関数を追加する `getMacro(name)` これは、対応する値を持つ文字列を返します `` - サーバー構成から。 [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- HTTPソースに基づいてディクショナリの設定オプションを設定する: `credentials` と - `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([Guillaume - Tassery](https://github.com/YiuRULE)) -- 新しいprofileeventを追加する `Merge` これは、起動された背景のマージの数を数えます。 - [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([ミハイル - Korotov](https://github.com/millb)) -- 完全修飾ドメイン名を返すfullhostname関数を追加します。 - [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) - [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([sundyli](https://github.com/sundy-li)) -- 機能を追加 `arraySplit` と `arrayReverseSplit` これは配列を分割する “cut off” - 条件。 これらは、時系列の処理に役立ちます。 - [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([hcz](https://github.com/hczhcz)) -- マッチしたすべてのインデックスの配列をmultimatchファミリの関数に返す新しい関数を追加します。 - [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([ダニラ - クテニン](https://github.com/danlark1)) -- 新規データベースエンジンの追加 `Lazy` それは多数の小さい丸太を貯えるために最大限に活用されます - テーブル。 [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([ニキータ - Vasilev](https://github.com/nikvas0)) -- ビットマップ列の集計関数groupbitmapand、-または、-xorを追加します。 [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([Zhichang - ゆう](https://github.com/yuzhichang)) -- Nullを返す集計関数combinators-OrNullと-OrDefaultを追加します - または、集計するものがない場合のデフォルト値。 - [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) - ([hcz](https://github.com/hczhcz)) -- カスタ - 区切り文字ルール。 [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([tavplubix](https://github.com/tavplubix)) -- 外部辞書のソースとしてサポートredis。 [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([comunodi](https://github.com/comunodi), [アントン - ポポフ](https://github.com/CurtizJ)) - -#### バグ修正 {#bug-fix-2} - -- 修正誤ったクエリの結果の場合で `WHERE IN (SELECT ...)` セクションと `optimize_read_in_order` は - 使用される。 [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([アントン - ポポフ](https://github.com/CurtizJ)) -- プロジェクトの外のファイルに依存する無効mariadb認証プラグイン、。 - [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([ユーリ - Baranov](https://github.com/yurriy)) -- 例外を修正 `Cannot convert column ... because it is constant but values of constants are different in source and result` これは、関数が `now()`, `today()`, - `yesterday()`, `randConstant()` 使用されます。 - [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([ニコライ - Kochetov](https://github.com/KochetovNicolai)) -- 固定問題のhttp生き生きと保つタイムアウトの代わりにtcpのままにしておくタイムアウト. - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([バシリー - Nemkov](https://github.com/Enmk)) -- GroupBitmapOrのセグメンテーション障害を修正しました(問題 [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). - [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([Zhichang - ゆう](https://github.com/yuzhichang)) -- のための実現の為のためのカフカでとても間近に見ることができすべてのデータが書かれています。 - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([イワン](https://github.com/abyss7)) -- 固定間違った `duration_ms` 値の `system.part_log` テーブル。 それは十回オフだった。 - [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([Vladimir - Chebotarev](https://github.com/excitoon)) -- 修正を解決するクラッシュライブビューテーブルの再可能なすべてのライブビュー。 - [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) - ([vzakaznikov](https://github.com/vzakaznikov)) -- MergeTreeパーツの最小/最大インデックスでNULL値を正しくシリアル化します。 - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- 仮想列を置かないでください。テーブル作成時のsqlメタデータ `CREATE TABLE AS`. - [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([イワン](https://github.com/abyss7)) -- セグメンテーショ `ATTACH PART` クエリ。 - [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) - ([alesapin](https://github.com/alesapin)) -- サブクエリの空と空の最適化によって与えられたいくつかのクエリの間違った結果を修正 - INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([ニコライ - Kochetov](https://github.com/KochetovNicolai)) -- ライブビューのgetheader()メソッドでaddresssanitizerエラーを修正します。 - [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) - ([vzakaznikov](https://github.com/vzakaznikov)) - -#### 改善 {#improvement-1} - -- Queue\_wait\_max\_ms待機が発生した場合にメッセージを追加します。 - [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([Azat - Khuzhin](https://github.com/azat)) -- メイドの設定 `s3_min_upload_part_size` テーブルレベル。 - [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([Vladimir - Chebotarev](https://github.com/excitoon)) -- StorageFactoryでTTLをチェックします。 [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) - ([sundyli](https://github.com/sundy-li)) -- 部分マージ結合(最適化)でスカッシュ左側のブロック。 - [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([Artem - Zuikov](https://github.com/4ertus2)) -- レプリケートされたテーブルエンジンの変異時に非決定論的関数を許可しないでください。 - レプリカ間に不整合が生じる可能性があります。 - [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([Alexander - Kazakov](https://github.com/Akazz)) -- 無効メモリにトラッカーが変換の例外のスタックトレースを文字列になります。 それを防ぐことができ損失 - タイプのエラーメッセージ `Memory limit exceeded` サーバーでは、 `Attempt to read after eof` クライアントの例外。 [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) - ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- その他の形式の改善。 解決 - [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), - [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), - [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), - [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) - [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) - ([tavplubix](https://github.com/tavplubix)) -- ClickHouseは、左側に変換不可能なIN演算子の右側の値を無視します - side type. Make it work properly for compound types – Array and Tuple. - [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- ASOF JOINの欠落した不等式をサポートします。 以下または等しいバリアントと厳密に結合することが可能です - 構文上のASOF列の大きいと少ない変種。 - [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([Artem - Zuikov](https://github.com/4ertus2)) -- 部分マージ結合を最適化します。 [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) - ([Artem Zuikov](https://github.com/4ertus2)) -- 使用しない以上98kのメモリでuniqcombined機能。 - [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), - [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([Azat - Khuzhin](https://github.com/azat)) -- PartialMergeJoinのディスク上の右側の結合テーブルのフラッシュ部分(十分でない場合 - メモリ)。 負荷データが必要です。 [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) - ([Artem Zuikov](https://github.com/4ertus2)) - -#### 性能向上 {#performance-improvement-1} - -- データの重複を避けることによって、joingetをconst引数で高速化します。 - [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([Amos - 鳥](https://github.com/amosbird)) -- サブクエリが空の場合は、earlyを返します。 - [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) -- 値のsql式の解析を最適化します。 - [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) - ([tavplubix](https://github.com/tavplubix)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-1} - -- 無効化あcontribsクロスコンパイルをmac os. - [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([イワン](https://github.com/abyss7)) -- Clickhouse\_common\_ioのPocoXMLとのリンクが見つかりませんを追加します。 - [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([Azat - Khuzhin](https://github.com/azat)) -- Clickhouse-testで複数のテストフィルター引数を受け入れます。 - [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- ARMのmuslとjemallocを有効にします。 [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) - ([アモスの鳥](https://github.com/amosbird)) -- 追加 `--client-option` へのパラメータ `clickhouse-test` ための追加のパラメータです。 - [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([ニコライ - Kochetov](https://github.com/KochetovNicolai)) -- Rpmパッケージのアップグ - [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) - ([フィリモノフ](https://github.com/filimonov)) -- PVSによって検出されたエラーを修正。 [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([Artem - Zuikov](https://github.com/4ertus2)) -- ダーウィンのためのビルドを修正. [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) - ([イワン](https://github.com/abyss7)) -- glibc2.29互換性。 [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([Amos - 鳥](https://github.com/amosbird)) -- Dh\_cleanがソースファイルに触れないようにします。 - [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([Amos - 鳥](https://github.com/amosbird)) -- Altinity rpmから更新するときに競合を避けるようにしてください。 - clickhouse-server-commonにあります。 [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) - ([フィリモノフ](https://github.com/filimonov)) -- 最適なヘッダファイルにより再建. - [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), - [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- 日付と日時のパフォーマンステストを追加する。 [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([バシリー - Nemkov](https://github.com/Enmk)) -- 非決定性の変異を含むいくつかのテストを修正します。 - [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([Alexander - Kazakov](https://github.com/Akazz)) -- CIにMemorySanitizerでビルドを追加します。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) - ([Alexander Kuzmenkov](https://github.com/akuzm)) -- MetricsTransmitterでは、初期化されていない値の使用は避けてください。 - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat - Khuzhin](https://github.com/azat)) -- 固定のいくつかの問題分野によっmemorysanitizer. - [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), - [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([Alexander - Kuzmenkov](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) - ([アモスの鳥](https://github.com/amosbird)) -- Murmurhash32で未定義の動作を修正しました。 [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([Amos - 鳥](https://github.com/amosbird)) -- StoragesInfoStreamの未定義の動作を修正しました。 [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) - ([tavplubix](https://github.com/tavplubix)) -- 外部データベースエンジン(mysql、odbc、jdbc)のために折り畳まれた固定定数式。 前に - バージョンな作業のための複数の定数で表現したで働くすべての日付, - DateTimeおよびUUID。 この修正 [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- No\_users\_thread変数にアクセスする際のライブビューでのThreadSanitizer data raceエラーの修正。 - [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) - ([vzakaznikov](https://github.com/vzakaznikov)) -- Libcommonでmallocシンボルを取り除く - [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), - [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([Amos - 鳥](https://github.com/amosbird)) -- 追加グローバル旗enable\_libraries無効化のためのすべての図書館です。 - [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) - ([proller](https://github.com/proller)) - -#### コードの整理 {#code-cleanup} - -- 構成リポジトリを一般化して、辞書のddlを準備します。 [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) - ([alesapin](https://github.com/alesapin)) -- 任意のセマンティックなしの辞書ddlのパーサー。 - [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) - ([alesapin](https://github.com/alesapin)) -- ParserCreateQueryをさまざまな小さなパーサーに分割します。 - [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) - ([alesapin](https://github.com/alesapin)) -- 小さなリファクタリングと外部辞書の近くに名前を変更します。 - [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) - ([alesapin](https://github.com/alesapin)) -- Refactor一部のコードの準備のための役割ベースのアクセス制御です。 [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([ヴィタリ - Baranov](https://github.com/vitlibar)) -- DatabaseOrdinaryコードのいくつかの改善点。 - [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([ニキータ - Vasilev](https://github.com/nikvas0)) -- ハッシュテーブルのfind()およびemplace()メソッドではイテレータを使用しないでください。 - [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([Alexander - Kuzmenkov](https://github.com/akuzm)) -- パラメータのルートが空でない場合にgetmultiplevaluesfromconfigを修正しました。 [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) - ([Mikhail Korotov](https://github.com/millb)) -- いくつかのコピー&ペーストを削除する(temporaryfileとtemporaryfilestream) - [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([Artem - Zuikov](https://github.com/4ertus2)) -- コードの可読性を少し改善 (`MergeTreeData::getActiveContainingPart`). - [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([Vladimir - Chebotarev](https://github.com/excitoon)) -- お待ちすべての予定の仕事をローカルオブジェクトの場合 `ThreadPool::schedule(...)` 投球 - 例外です。 名前変更 `ThreadPool::schedule(...)` に `ThreadPool::scheduleOrThrowOnError(...)` と - 固定のコメントを明らかな場合にスロー. - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) - ([tavplubix](https://github.com/tavplubix)) - -## ClickHouseリリース19.15 {#clickhouse-release-19-15} - -### ClickHouseリリース19.15.4.10、2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} - -#### バグ修正 {#bug-fix-3} - -- SQL\_TINYINTとSQL\_BIGINTの処理を追加し、ODBCブリッジでSQL\_FLOATデータソース型の処理を修正しました。 - [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) -- 移動パーティショ - [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) -- ODBCブリッジを介してnull可能な列のNULL値を修正しました。 - [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([Vasily Nemkov](https://github.com/Enmk)) -- マテリアライズ列を持つ分散非ローカルノードに固定挿入。 - [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) -- 固定機能getmultiplevaluesfromconfig。 - [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([Mikhail Korotov](https://github.com/millb)) -- 固定問題のhttp生き生きと保つタイムアウトの代わりにtcpのままにしておくタイムアウト. - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([Vasily Nemkov](https://github.com/Enmk)) -- すべてのジョブが例外で終了するのを待ちます(まれなsegfaultsを修正します)。 - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([tavplubix](https://github.com/tavplubix)) -- Kafkaテーブルに挿入するときにMVsにプッシュしないでください。 - [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([イワン](https://github.com/abyss7)) -- 無効メモリにトラッカーのための例外をスタックです。 - [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 外部データベ - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- MetricsTransmitterでは、初期化されていない値の使用は避けてください。 - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat Khuzhin](https://github.com/azat)) -- テスト用のマクロを追加しました例の設定 ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### クリックハウスリリース19.15.3.6,2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} - -#### バグ修正 {#bug-fix-4} - -- ハッシュ化された辞書のbad\_variantを修正しました。 - ([alesapin](https://github.com/alesapin)) -- 修正のバグと分割詳しくは動画内で、タグは付け部分を返します。 - ([alesapin](https://github.com/alesapin)) -- 固定時間の計算 `MergeTreeData`. - ([Vladimir Chebotarev](https://github.com/excitoon)) -- 執筆が確定した後、kafkaに明示的にコミットします。 - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([イワン](https://github.com/abyss7)) -- MergeTreeパーツの最小/最大インデックスでNULL値を正しくシリアル化します。 - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -### クリックハウスリリース19.15.2.2,2019-10-01 {#clickhouse-release-19-15-2-2-2019-10-01} - -#### 新しい機能 {#new-feature-3} - -- 段階のストレージへのサポート使用数量のためのテーブルmergetreeエンジンです。 新鮮なデータをssdに保存し、古いデータを自動的にhddに移動することができます。 ([例えば](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([Igr](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([alesapin](https://github.com/alesapin)) -- テーブル関数の追加 `input` 受信データを読むため `INSERT SELECT` クエリ。 [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([パラソリック1color](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([アントン-ポポフ](https://github.com/CurtizJ)) -- を追加 `sparse_hashed` 辞書のレイアウトは、機能的には `hashed` レイアウトが、より効率的なメモリです。 それはより遅い価値検索の費用でより少ない記憶として二度約使用する。 [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([Azat Khuzhin](https://github.com/azat)) -- 実施能力の定義の一覧をユーザーへのアクセスする事ができます。 使用する現在の接続データベースのみ。 [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 追加 `LIMIT` オプションへ `SHOW` クエリ。 [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([Philipp Malkovsky](https://github.com/malkfilipp)) -- 追加 `bitmapSubsetLimit(bitmap, range_start, limit)` 最小のサブセットを返す関数 `limit` より小さくないセット内の値 `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([Zhichang Yu](https://github.com/yuzhichang)) -- 追加 `bitmapMin` と `bitmapMax` 機能。 [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([Zhichang Yu](https://github.com/yuzhichang)) -- 機能を追加 `repeat` に関連する [問題-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([flynn](https://github.com/ucasFL)) - -#### 実験的特徴 {#experimental-feature-1} - -- 現在のパイプラインを変更しないマージ結合バリアントをメモリに実装します。 結果はマージキーで部分的にソートされます。 セット `partial_merge_join = 1` この機能を使用するには. マージ結合はまだ開発中です。 [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `S3` エンジンおよびテーブル機能。 まだ開発中です(まだ認証サポートはありません)。 [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([Vladimir Chebotarev](https://github.com/excitoon)) - -#### 改善 {#improvement-2} - -- 全てのメッセージから読み込むカフカを挿入し、原子. これは、カフカエンジンのほぼすべての既知の問題を解決します。 [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([イワン](https://github.com/abyss7)) -- 分散クエリのフェイルオーバーの改善。 回復時間を短くして下さい、またそれは今構成され、見ることができます `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([Vasily Nemkov](https://github.com/Enmk)) -- 列挙型の数値を直接サポート `IN` セクション。 \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([ディマルブ2000](https://github.com/dimarub2000)) -- サポート(オプション、障害者によるデフォルト)のリダイレクトurlに保管します。 [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([maqroll](https://github.com/maqroll)) -- 追加情報をメッセージがクライアントよりも古いバージョンを接続するサーバーです。 [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([Philipp Malkovsky](https://github.com/malkfilipp)) -- 分散テーブ [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([Azat Khuzhin](https://github.com/azat)) -- Graphiteに累積値を持つプロファイルイベント(カウンター)を送信する機能を追加。 で有効にすることができ下 `` サーバー内 `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([Azat Khuzhin](https://github.com/azat)) -- 自動キャストタイプの追加 `T` に `LowCardinality(T)` 型の列にデータを挿入している間 `LowCardinality(T)` HTTP経由でネイティブ形式で。 [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 機能を使用する機能を追加する `hex` 使用せずに `reinterpretAsString` のために `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([Mikhail Korotov](https://github.com/millb)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-2} - -- デバッグ情報を含むclickhouseバイナリにgdb-indexを追加します。 それはスピードアップ起動時間の `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([alesapin](https://github.com/alesapin)) -- パッチを当てたdpkg-debを使用してdebパッケージをスピードアップ `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([alesapin](https://github.com/alesapin)) -- セット `enable_fuzzing = 1` すべてのプロジェクトコードのlibfuzzerの計測を有効にするには. [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([kyprizel](https://github.com/kyprizel)) -- CIに分割ビルド煙テストを追加します。 [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([alesapin](https://github.com/alesapin)) -- CIにMemorySanitizerでビルドを追加します。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 置換 `libsparsehash` と `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([Azat Khuzhin](https://github.com/azat)) - -#### バグ修正 {#bug-fix-5} - -- 固定性能の劣化指標分析複雑なテンキーの大きます。 これは#6924を修正します。 [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- カフカ空のトピックから選択する際にsegfaultsを引き起こす論理的なエラーを修正。 [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([イワン](https://github.com/abyss7)) -- あまりにも早いmysql接続を閉じる `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- 非常に古いlinuxカーネルのサポートが返される(fix [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- で可能なデータ損失を修正 `insert select` 入力ストリーム内の空のブロックの場合のクエリ。 \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 関数の修正 `АrrayEnumerateUniqRanked` paramsで空の配列を使用する [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) -- 配列結合とグローバルサブクエリを使用した複雑なクエリの修正 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([イワン](https://github.com/abyss7)) -- 修正 `Unknown identifier` 複数のジョインを持つORDER BYおよびGROUP BYでのエラー [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定 `MSan` 関数の実行中の警告 `LowCardinality` 引数。 [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### 下位互換性のない変更 {#backward-incompatible-change-2} - -- 変更直列化形式のビットマップ\*集計機能状態の性能の向上を図ります。 以前のバージョンのbitmap\*のシリアル化状態は読み取りできません。 [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([Zhichang Yu](https://github.com/yuzhichang)) - -## ClickHouseリリース19.14 {#clickhouse-release-19-14} - -### ClickHouseリリース19.14.7.15,2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} - -#### バグ修正 {#bug-fix-6} - -- このリリースも含む全てのバグ修正から19.11.12.69. -- 19.14以前のバージョン間の分散クエリの互換性を修正しました。 この修正 [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.14.6.12,2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} - -#### バグ修正 {#bug-fix-7} - -- 関数の修正 `АrrayEnumerateUniqRanked` paramsに空の配列があります。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) -- とクエリ内の固定サブクエリ名 `ARRAY JOIN` と `GLOBAL IN subquery` エイリアス付き。 外部テーブル名が指定されている場合は、サブクエリ別名を使用します。 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([イワン](https://github.com/abyss7)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-3} - -- 修正 [フラッピング](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) テスト `00715_fetch_merged_or_mutated_part_zookeeper` それは突然変異が適用されるのを待つ必要があるためです。 [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([Alexander Kazakov](https://github.com/Akazz)) -- 機能の固定ubsanおよびmemsanの失敗 `groupUniqArray` emtpy配列の引数を持つ。 それは空の配置によって引き起こされた `PaddedPODArray` へのハッシュテーブルのゼロの細胞でのコンストラクターゼの細胞値ませんでした。 [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([アモスの鳥](https://github.com/amosbird)) - -### ClickHouseリリース19.14.3.3,2019-09-10 {#clickhouse-release-19-14-3-3-2019-09-10} - -#### 新しい機能 {#new-feature-4} - -- `WITH FILL` の修飾子 `ORDER BY`. (の継続 [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([アントン-ポポフ](https://github.com/CurtizJ)) -- `WITH TIES` の修飾子 `LIMIT`. (の継続 [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([アントン-ポポフ](https://github.com/CurtizJ)) -- パースクォートなし `NULL` リテラルとしてNULL(設定の場合 `format_csv_unquoted_null_literal_as_null=1`). このフィールドのデー `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([tavplubix](https://github.com/tavplubix)) -- テーブル関数のパスのワイルドカードのサポート `file` と `hdfs`. 場合に経路を含むワイルドカード、テーブルが読み取り専用になります。 使用例: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` と `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([Olga Khvostikova](https://github.com/stavrolia)) -- 新しい `system.metric_log` の値を格納するテーブル `system.events` と `system.metrics` 指定時間間隔を使って。 [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ClickHouseテキストログを書き込むことを許可する `system.text_log` テーブル。 [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ショー民間のシンボルスタックトレース(ターを通じて構文解析シンボルテーブルのelfファイル). 追加情報ファイルと行番号をスタックトレースの場合のデバッグ情報があります。 高速シンボル名のルックアップインデックスの記号が存在します。 イントロスペクション用の新しいsql関数を追加: `demangle` と `addressToLine`. 関数の名前を変更 `symbolizeAddress` に `addressToSymbol` 一貫性のために。 機能 `addressToSymbol` パフォーマンス上の理由から、マングルされた名前を返します。 `demangle`. 追加された設定 `allow_introspection_functions` デフォルトではオフになっています。 [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テーブル機能 `values` (名前は大文字と小文字を区別しません)。 それは読むことを可能にする `VALUES` で提案されたリスト [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). 例えば: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([ディマルブ2000](https://github.com/dimarub2000)) -- ストレージの設定を変更する機能を追加しました。 構文: `ALTER TABLE
MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([alesapin](https://github.com/alesapin)) -- 取り外した部品の取り外しをサポート。 構文: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([tavplubix](https://github.com/tavplubix)) -- テーブルの制約。 挿入時にチェックされるテーブル定義に制約を追加することができます。 [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([Gleb Novikov](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 支援のためのカスケード型を実現します。 [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([アモスの鳥](https://github.com/amosbird)) -- On queryプロファイラのデフォルトでサンプル毎にクエリの実行スレッドだ。 [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 入力形式 `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([akonyaev90](https://github.com/akonyaev90)) -- 二つの新機能を追加しました: `sigmoid` と `tanh` (これは機械学習アプリケーションに便利です)。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能 `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` 指定されたトークンがhaystackにあるかどうかを確認する。 トークンは、二つの非英数字ASCII文字(またはhaystackの境界)の間の最大長の部分文字列です。 トークンを入力する必要がある定数文字列になります。 支tokenbf\_v1指数の専門性を高めます。 [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([Vasily Nemkov](https://github.com/Enmk)) -- 新しい機能 `neighbor(value, offset[, default_value])`. データブロック内の列内の前/次の値に到達することができます。 [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([Alex Krash](https://github.com/alex-krash)) [6685365ab8c5b74f9650492c88a012596eb1b0c6](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341e2e4587a18065c2da1ca888c73389f48ce36c](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [Alexey Milovidov](https://github.com/alexey-milovidov) -- 関数の作成 `currentUser()`、承認されたユーザのログインを返す。 エイリアスを追加 `user()` MySQLとの互換性のために。 [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([Alex Krash](https://github.com/alex-krash)) -- 新しい集計関数 `quantilesExactInclusive` と `quantilesExactExclusive` これはで提案されました [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([ディマルブ2000](https://github.com/dimarub2000)) -- 機能 `bitmapRange(bitmap, range_begin, range_end)` これは、指定された範囲の新しいセットを返します( `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([Zhichang Yu](https://github.com/yuzhichang)) -- 機能 `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` 提供された区域をカバーするgeohash箱の精密長い一連の配列を作成するかどれが。 [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([Vasily Nemkov](https://github.com/Enmk)) -- INSERTクエリのサポートを実装する `Kafka` テーブル。 [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([イワン](https://github.com/abyss7)) -- のサポートを追加 `_partition` と `_timestamp` カフカエンジンへの仮想列。 [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([イワン](https://github.com/abyss7)) -- から機密データを削除する可能性 `query_log`、サーバーログ、regexpベースのルールを持つプロセスリスト。 [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([フィリモノフ](https://github.com/filimonov)) - -#### 実験的特徴 {#experimental-feature-2} - -- 入力および出力データ形式 `Template`. これは、入力と出力のカスタム書式文字列を指定することができます。 [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([tavplubix](https://github.com/tavplubix)) -- の実装 `LIVE VIEW` 最初に提案されたテーブル [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898)、準備される [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925)、その後で更新 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). 見る [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) 詳細な説明のため。 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([vzakaznikov](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([vzakaznikov](https://github.com/vzakaznikov))ことに注意 `LIVE VIEW` 特集は削除される可能性があり、来できます。 - -#### バグ修正 {#bug-fix-8} - -- このリリースも含む全てのバグ修正から19.13と19.11. -- 固定の区分断層のテーブルはスキップ指標および垂直統合などが挙げられる。 [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([alesapin](https://github.com/alesapin)) -- 非自明な列のデフォルトで列ごとのttlを修正しました。 以前は、force ttl mergeの場合は次のようになりました `OPTIMIZE ... FINAL` クエリー、終了しました値に置き換えられたタイプのデフォルトの代わりにユーザが指定した列のデフォルトする [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 通常のサーバーの再起動時にkafkaメッセージの重複の問題を修正。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([イワン](https://github.com/abyss7)) -- カフカメッセージを読むときに固定無限ループ。 それ以外の場合は、いくつかのシナリオで無期限に一時停止することがあります。 [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([イワン](https://github.com/abyss7)) -- 修正 `Key expression contains comparison between inconvertible types` での例外 `bitmapContains` 機能。 [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([ディマルブ2000](https://github.com/dimarub2000)) -- 有効にしてsegfaultを修正 `optimize_skip_unused_shards` シャーディングキーがない [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([アントン-ポポフ](https://github.com/CurtizJ)) -- メモリの破損につながる可能性があり、突然変異で間違ったコードを修正. アドレスの読み取りによる固定segfault `0x14c0` それは同時に起こったかもしれない `DROP TABLE` と `SELECT` から `system.parts` または `system.parts_columns`. 突然変異クエリの準備の競合状態を修正しました。 によるデッドロックを修正 `OPTIMIZE` レプリケートされたテーブルと同時変更操作のような変更。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- MySQLインターフェイスで削除された余分な冗長ログ [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- からブール値の設定を解析する機能を返します ‘true’ と ‘false’ 設定ファイルで。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([alesapin](https://github.com/alesapin)) -- でクラッシュを修正 `quantile` と `median` 関数オーバー `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([Artem Zuikov](https://github.com/4ertus2)) -- によって返された可能な不完全な結果を修正 `SELECT` クエリと `WHERE` 主キーの条件には、Float型への変換が含まれていました。 それは単調性の誤ったチェックによって引き起こされた `toFloat` 機能。 [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([ディマルブ2000](https://github.com/dimarub2000)) -- チェック `max_expanded_ast_elements` 突然変異のための設定。 後の明確な突然変異 `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([冬張](https://github.com/zhang2014)) -- と共に使用するときにキー列の結合結果を修正 `join_use_nulls`. 列の既定値の代わりにNullをアタッチします。 [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([Artem Zuikov](https://github.com/4ertus2)) -- 垂直マージと変更とスキップインデックスの修正。 修正のための `Bad size of marks file` 例外だ [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([alesapin](https://github.com/alesapin)) -- でレアクラッシュを修正 `ALTER MODIFY COLUMN` マージ/変更された部分のいずれかが空(0行)のときに垂直マージ) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([alesapin](https://github.com/alesapin)) -- の変換のバグを修正しました `LowCardinality` タイプ `AggregateFunctionFactory`. この修正 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 間違った動作と可能なsegfaultsを修正 `topK` と `topKWeighted` 集計関数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 周りの固定安全でないコード `getIdentifier` 機能。 [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 問題を修正しましたmysqlのワイヤーロを使用すると接続するclickhouse形mysqlクライアント). によって引き起こされる `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([ユーリーバラノフ](https://github.com/yurriy)) -- 固定メモリリーク `bitmapSubsetInRange` 機能。 [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([Zhichang Yu](https://github.com/yuzhichang)) -- 粒度の変更後に突然変異が実行されたときに稀なバグを修正しました。 [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([alesapin](https://github.com/alesapin)) -- きprotobufメッセージの全ての分野でのデフォルトです。 [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([Vitaly Baranov](https://github.com/vitlibar)) -- バグを解決するには `nullIf` 私達がaを送る場合の機能 `NULL` 第二引数の引数。 [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 文字列フィールドを持つ複雑なキーキャッシュ辞書で間違ったメモリ割り当て/割り当て解除を使用して、まれなバグを修正しました(メモリリークのよ バグは、文字列サイズが八(8、16、32、等)から始まる二つの累乗だったときに再現します。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([alesapin](https://github.com/alesapin)) -- 例外を引き起こした小さな配列に固定ゴリラエンコード `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Vasily Nemkov](https://github.com/Enmk)) -- Nullableではない型をJOINsで使用できるようにする `join_use_nulls` 有効。 [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([Artem Zuikov](https://github.com/4ertus2)) -- 無効にする `Poco::AbstractConfiguration` クエリ内での置換 `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- デッドロックを回避 `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- を使用して `arrayReduce` 定数引数の場合、segfaultにつながる可能性があります。 [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- レプリカが後に復元された場合に表示される不整合な部分を修正 `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- 固定こつ `JSONExtractRaw` 機能。 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正のバグと誤ったスキップ指数の直列化を行い、その凝集と適応粒度. [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([alesapin](https://github.com/alesapin)) -- 修正 `WITH ROLLUP` と `WITH CUBE` の修飾子 `GROUP BY` 二レベルの集計。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([アントン-ポポフ](https://github.com/CurtizJ)) -- のを修正した。筆二次指標マーク適応型粒度. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alesapin](https://github.com/alesapin)) -- サーバーの起動中に初期化の順序を修正します。 それ以来 `StorageMergeTree::background_task_handle` で初期化される。 `startup()` その `MergeTreeBlockOutputStream::write()` 初期化の前に使用しようとするかもしれません。 すぐチェックインの場合は初期化されます。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([イワン](https://github.com/abyss7)) -- エラーで完了した前の読み取り操作からデータバッファーをクリアします。 [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([ニコライ](https://github.com/bopohaa)) -- 固定バを適応的粒度を新規作成時のレプリカのための複製\*mergetreeます。 [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([alesapin](https://github.com/alesapin)) -- 例外が発生した場合のサーバーの起動時に可能なクラッシュを修正しました `libunwind` 初期化されていないアクセス時の例外時 `ThreadStatus` 構造。 [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- でクラッシュを修正 `yandexConsistentHash` 機能。 ファズテストによって発見。 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定の可能性を掛けのクエリがサーバが過負荷状態で運転され、グローバルスレッドプールが近い。 これは、分散クエリが各シャードに接続ごとにスレッドを割り当てるため、多数のシャード(数百)を持つクラスターで発生する可能性が高くなります。 たとえば、330個のシャードのクラスターが30個の同時分散クエリを処理している場合、この問題は再現されます。 この問題に影響するすべてのバージョンから19.2. [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定ロジックの `arrayEnumerateUniqRanked` 機能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- シンボルテーブルのデコード時にsegfaultを修正。 [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([アモスの鳥](https://github.com/amosbird)) -- のキャストで修正された無関係な例外 `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- で説明の余分な引用を削除しました `system.settings` テーブル。 [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- デッドロックの回避 `TRUNCATE` 複製されたテーブルの。 [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ソートキーの順に読み取りを修正しました。 [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 修正 `ALTER TABLE ... UPDATE` とテーブルのクエリ `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) -- によって開かバグを修正 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (19.4.0以来)。 列をクエリしない場合は、MergeTreeテーブルを使用して分散テーブルへのクエリを再現します (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([alesapin](https://github.com/alesapin)) -- 固定オーバーフローの整数部署名-タイプを符号なしタイプです。 この動作は、cまたはc++言語(整数昇格ルール)とまったく同じで、驚くかもしれません。 大きな符号付き数を大きな符号なし数に分割する場合、またはその逆の場合にはオーバーフローが可能であることに注意してください(ただし、その場合 の問題が全てのサーバーのバージョン [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- スロットリング時の最大スリープ時間を制限する `max_execution_speed` または `max_execution_speed_bytes` 設定されています。 固定偽のようなエラー `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 使用に関する問題を修正 `MATERIALIZED` の列とエイリアス `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([アモスの鳥](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `FormatFactory` プロセッサとして実装されていない入力ストリームの動作。 [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 修正されたタイプミス。 [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([Alex Ryndin](https://github.com/alexryndin)) -- エラーメッセージのタイプミス(is-\>are)。 [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([Denis Zhuravlev](https://github.com/den-crane)) -- 固定誤差を解析カラムのリストから文字列の場合タイプが含まれるコンマ(この問題に関連する `File`, `URL`, `HDFS` ストレージ) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([ディマルブ2000](https://github.com/dimarub2000)) - -#### セキュリティ修正 {#security-fix} - -- このリリースも含む全てのバグのセキュリティ修正をか19.13と19.11. -- SQLパーサーのスタックオーバーフローによりサーバーがクラッシュする可能性がある問題を修正 固定の可能性スタックオーバーフローに統合、配布し、テーブルが現実の景色の件本件は、行レベルのセキュリティなサブクエリ. [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 改善 {#improvement-3} - -- のための三元論理の正しい実装 `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([Alexander Kazakov](https://github.com/Akazz)) -- これで、ttlの有効期限が切れた値と行が削除されます。 `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` クエリ。 追加されたクエリ `SYSTEM STOP/START TTL MERGES` 可に/を割り当てを合併TTLおよびフィルター終了しました値をすべてが合併。 [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([アントン-ポポフ](https://github.com/CurtizJ)) -- クライアントのclickhouse履歴ファイルの場所を変更する可能性 `CLICKHOUSE_HISTORY_FILE` env [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([フィリモノフ](https://github.com/filimonov)) -- 削除 `dry_run` フラグから `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- サポート `ASOF JOIN` と `ON` セクション。 [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([Artem Zuikov](https://github.com/4ertus2)) -- 突然変異および複製のためのskip索引のよりよいサポート。 のサポート `MATERIALIZE/CLEAR INDEX ... IN PARTITION` クエリ。 `UPDATE x = x` 列を使用するすべてのインデックスの再計算 `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([Nikita Vasilev](https://github.com/nikvas0)) -- 許可する `ATTACH` ライブビュー(たとえば、サーバーの起動時など) `allow_experimental_live_view` 設定。 [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- のためのスタックトレースに集まるエリプロファイラに含まれているものも含むスタックフレームが発生するqueryプロファイラです。 [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Nowテーブル関数 `values`, `file`, `url`, `hdfs` ALIAS列をサポートしている。 [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 次の場合に例外をスローする `config.d` ファイルには、対応するルート要素が設定ファイルとして存在しません。 [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([ディマルブ2000](https://github.com/dimarub2000)) -- 例外メッセージの余分な情報を印刷する `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([tavplubix](https://github.com/tavplubix)) -- Aの破片を決定するとき `Distributed` 読み取りクエリによってカバーされるテーブル(for `optimize_skip_unused_shards` =1)ClickHouseは両方から条件をチェックします `prewhere` と `where` select文の句。 [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([Alexander Kazakov](https://github.com/Akazz)) -- 有効 `SIMDJSON` AVX2のないしかしSSE4.2およびPCLMULの命令セットの機械のため。 [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ClickHouseでファイルシステムな `O_DIRECT` 追加のチューニングなしでサポート(ZFSとBtrFSなど)。 [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 支援を押しであったが,最終的にサブクエリです。 [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([Tcheason](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より良い `JOIN ON` キーの抽出 [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([Artem Zuikov](https://github.com/4ertus2)) -- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 最小の列の選択を最適化する `SELECT count()` クエリ。 [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([アモスの鳥](https://github.com/amosbird)) -- 追加 `strict` パラメータin `windowFunnel()`. とき `strict` は、 `windowFunnel()` 一意の値にのみ条件を適用します。 [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([achimbabcomment](https://github.com/achimbab)) -- より安全なインタフェース `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([avasiliev](https://github.com/avasiliev)) -- オプション行サイズ `--help` オプションに対応した端末のサイズです。 [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([ディマルブ2000](https://github.com/dimarub2000)) -- 無効にする “read in order” キーなしの集約の最適化。 [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([アントン-ポポフ](https://github.com/CurtizJ)) -- のhttpステータスコード `INCORRECT_DATA` と `TYPE_MISMATCH` エラーコードをデフォルトから変更 `500 Internal Server Error` に `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([Alexander Rodin](https://github.com/a-rodin)) -- 結合オブジェクトの移動元 `ExpressionAction` に `AnalyzedJoin`. `ExpressionAnalyzer` と `ExpressionAction` 知らない `Join` もはやクラス。 その論理は `AnalyzedJoin` フェイス [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定可能な行き詰まりの分散クエリーの資料はlocalhostでのクエリを送ネットワーク経由で接続します。 [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 複数のテーブルの意味を変更 `RENAME` 可能なデッドロックを避けるため。 [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 書き換えmysqlサーバーの互換性防止への負荷フルパケットペイロードに。 各接続のメモリ消費量の減少 `2 * DBMS_DEFAULT_BUFFER_SIZE` (読み取り/書き込みバッファ)。 [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([ユーリーバラノフ](https://github.com/yurriy)) -- クエリのセマンティクスについて何も知る必要のないast alias interpreting logicをパーサーから外します。 [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([Artem Zuikov](https://github.com/4ertus2)) -- もう少し安全な構文解析 `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `clickhouse-copier`:使用を許可する `where_condition` 設定から `partition_key` エイリアスクエリのためのチェック分配の存在についても同様とすでに使用されただけでデータを読み込むクエリ). [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([proller](https://github.com/proller)) -- 追加オプションのメッセージ引数 `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([Vdimir](https://github.com/Vdimir)) -- クライアントでも挿入データの送信中にサーバー例外が発生しました。 [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([ディマルブ2000](https://github.com/dimarub2000)) -- メトリックを追加 `DistributedFilesToInsert` その総数のファイルをファイルシステムを送信リモートサーバーに配布します。 数はすべての破片を合計します。 [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ほとんどの結合を準備ロジックから移動する `ExpressionAction/ExpressionAnalyzer` に `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([Artem Zuikov](https://github.com/4ertus2)) -- TSanを修正 [警告](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([Vasily Nemkov](https://github.com/Enmk)) -- Linuxの機能の欠如に関するより良い情報メッセージ。 致命的なエラーのログ記録 “fatal” レベル、それはそれが簡単で見つけることになります `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ディスクへの一時データのダンプを有効にして、使用中のメモリ使用量を制限する場合 `GROUP BY`, `ORDER BY` でかチェックのディスクスペース。 修正は、新しい設定を追加します `min_free_disk_space`、ときに空きディスク領域それ小さいし、しきい値は、クエリが停止し、スローされます `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([Weiqing Xu](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- スレッドによる再帰的なrwlockの削除。 スレッドはクエリ間で再利用されるため、意味がありません。 `SELECT` クエリがロックを取得するスレッド、ロックから別のスレッドの出口から。 同時に、最初のスレッドは次の方法で再利用できます `DROP` クエリ。 これはfalseにつながります “Attempt to acquire exclusive lock recursively” メッセージ [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 分割 `ExpressionAnalyzer.appendJoin()`. 場所を準備する `ExpressionAnalyzer` のために `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `mysql_native_password` MySQLの互換性サーバーへの認証プラグイン。 [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([ユーリーバラノフ](https://github.com/yurriy)) -- より少ない数の `clock_gettime` のデバッグ/リリース間のABIの互換性を修正しました `Allocator` (取るに足りない問題)。 [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 移動 `collectUsedColumns` から `ExpressionAnalyzer` に `SyntaxAnalyzer`. `SyntaxAnalyzer` 作る `required_source_columns` 今自体。 [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([Artem Zuikov](https://github.com/4ertus2)) -- 設定を追加 `joined_subquery_requires_alias` サブセレクトおよびテーブル関数のエイリアスを要求するには `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([Artem Zuikov](https://github.com/4ertus2)) -- 抽出 `GetAggregatesVisitor` クラスから `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([Artem Zuikov](https://github.com/4ertus2)) -- `system.query_log`:データタイプの変更 `type` コラムへの `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- 静的リンクの `sha256_password` 認証プラグイン。 [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([ユーリーバラノフ](https://github.com/yurriy)) -- 設定の余分な依存関係を避ける `compile` 働くため。 以前のバージョンでは `cannot open crti.o`, `unable to find library -lc` など。 [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 悪意のあるレプリカから来る可能性のある入力のより多くの検証。 [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- さて `clickhouse-obfuscator` ファイルは `clickhouse-client` パッケージ。 以前のバージョンでは、 `clickhouse obfuscator` (空白を含む)。 [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([ディマルブ2000](https://github.com/dimarub2000)) -- 固定行き詰まりが少なくとも二つのクエリの読み取り少なくとも二つのテーブルに異なる秩序や他のクエリを実行するddl操作の一つです。 固定も非常に珍しいデッドロックします。 [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `os_thread_ids` コラムへの `system.processes` と `system.query_log` のためのデバッグ可能です。 [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 次の場合に発生するphp mysqlnd拡張バグの回避策 `sha256_password` デフォルトの認証プラグインとして使用されます。 [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([ユーリーバラノフ](https://github.com/yurriy)) -- Nullability列が変更された不要な場所を削除します。 [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([Artem Zuikov](https://github.com/4ertus2)) -- 設定のデフォルト値 `queue_max_wait_ms` 現在の値(五秒)は意味をなさないので、ゼロに。 この設定を使用している場合は、まれな状況があります。 追加された設定 `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` と `connection_pool_max_wait_ms` 曖昧さ回避のために。 [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 抽出 `SelectQueryExpressionAnalyzer` から `ExpressionAnalyzer`. 選択されていないクエリの最後のクエリを保持します。 [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([Artem Zuikov](https://github.com/4ertus2)) -- 重複する入力および出力形式を削除しました。 [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- ユーザーの上書きを許可する `poll_interval` と `idle_connection_timeout` 接続時の設定。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `MergeTree` 現在、追加オプション `ttl_only_drop_parts` (デフォルトでは無効)パーツの部分的な枝刈りを避けるため、パーツ内のすべての行が期限切れになったときに完全に削除されます。 [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([Catalonia\_comarques.Kgm](https://github.com/svladykin)) -- セットインデックス関数の型チェック。 関数が間違った型を持つ場合は例外をスローします。 これはubsanでファズテストを修正します。 [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([Nikita Vasilev](https://github.com/nikvas0)) - -#### 性能向上 {#performance-improvement-2} - -- クエリを最適化する `ORDER BY expressions` 句、どこ `expressions` プレフィックスとソートキーが一致している `MergeTree` テーブル。 この最適化は `optimize_read_in_order` 設定。 [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 使用に応じることは、複数のスレッドの中で部品の搭載となります。 [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 集計関数の状態を更新するバッチバリアントを実装。 で与えられる実装になっていると性能です。 [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- を使用して `FastOps` 関数のライブラリ `exp`, `log`, `sigmoid`, `tanh`. FastOpsはマイケルParakhin(YandexのCTO)からの高速ベクトル数学ライブラリです。 改善された性能の `exp` と `log` 機能6回以上。 を機能 `exp` と `log` から `Float32` 引数戻ります `Float32` (以前のバージョンでは、常に戻ります `Float64`). さて `exp(nan)` 戻る可能性がある `inf`. 結果の `exp` と `log` 関数は、真の答えに最も近いマシン表現可能な番号ではないかもしれません。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([alexey-milovidov](https://github.com/alexey-milovidov))働くfastopsを作るダニラKuteninの変形を使用して [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の連続したキーの最適化を無効にする `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([azerbaijan.kgm](https://github.com/akuzm)) -- 改善された性能の `simdjson` の動的割り当てを取り除くことによって `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([Vitaly Baranov](https://github.com/vitlibar)) -- メモリを割り当てるときの事前フォールトページ `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([azerbaijan.kgm](https://github.com/akuzm)) -- 固定性能のバグを修正 `Decimal` 比較。 [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([Artem Zuikov](https://github.com/4ertus2)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-4} - -- コンパイラ(ランタイムテンプレートのインスタンス化)を削除します。 [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加の性能試験への性能の低下gcc-9により孤立した。 [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テーブル機能を追加 `numbers_mt` のマルチスレッドバージョンです。 `numbers`. 更新性能試験のハッシュ機能 [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 比較モード `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([ディマルブ2000](https://github.com/dimarub2000)) -- スタックトレース印刷のための最善の努力。 また、追加 `SIGPROF` 実行中のスレッドのスタックトレースを出力するデバッグ信号として。 [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 独自のファイル、パート10のすべての機能。 [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 倍精度の定数を削除 `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([フィリモノフ](https://github.com/filimonov)) -- のための書式設定の変更 `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([azerbaijan.kgm](https://github.com/akuzm)) -- Join作成のためのより良いサブクエリ `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([Artem Zuikov](https://github.com/4ertus2)) -- 冗長な条件(pvs studioによって検出された)を削除します。 [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([azerbaijan.kgm](https://github.com/akuzm)) -- 別々のハッシュテーブルインタフェース `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([azerbaijan.kgm](https://github.com/akuzm)) -- 設定のリファクタリング。 [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([alesapin](https://github.com/alesapin)) -- コメントの追加 `set` インデックス関数。 [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([Nikita Vasilev](https://github.com/nikvas0)) -- 増oomスコアデバッグ版プログラムを利用しています。. [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([azerbaijan.kgm](https://github.com/akuzm)) -- HDFS HAはデバッグビルドで動作します。 [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([Weiqing Xu](https://github.com/weiqxu)) -- にテストを追加しました `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Kafkaテーブルのマテリアライズドビューのテストを追加します。 [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([イワン](https://github.com/abyss7)) -- よりよい造りの機構を作りなさい。 [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([イワン](https://github.com/abyss7)) -- 固定 `test_external_dictionaries` 非rootユーザーの下で実行された場合の統合。 [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 書き込まれたパケットの合計サイズが `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([ユーリーバラノフ](https://github.com/yurriy)) -- のテストを追加しました `RENAME` テーブルの競合状態 [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 設定のデータ競争をの避けて下さい `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- キャッ [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([Vitaly Baranov](https://github.com/vitlibar)) -- Mac OSでELFオブジェクトファイルの解析を無効にする。 [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 変更ログジェネレータを改善しようとします。 [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `-Wshadow` GCCに切り替えます。 [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- の廃止されたコードを削除 `mimalloc` ます。 [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `zlib-ng` x86機能を決定し、この情報をグローバル変数に保存します。 これは、異なるスレッドによって同時に行うことができるdefalteInit呼び出しで行われます。 を避けるマルチスレッドに書き込み、図書館で起動します。 [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([azerbaijan.kgm](https://github.com/akuzm)) -- In結合で修正されたバグの回帰テスト [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([Bakhtiyor Ruziev](https://github.com/theruziev)) -- 固定msanレポート。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正フラッピングttlテスト。 [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 固定偽データレースで `MergeTreeDataPart::is_frozen` フィールド。 [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ファズテストでタイムアウトを修正しました。 以前のバージョ `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- デバッグチェックを追加 `static_cast` 列の。 [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 公式のrpmパッケージでのoracle linuxのサポート。 [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- からの変更json perftests `once` に `loop` タイプ。 [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- `odbc-bridge.cpp` 定義 `main()` したがって、それは `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([Orivej Desh](https://github.com/orivej)) -- クラッシュのテスト `FULL|RIGHT JOIN` 右側のテーブルのキーにヌルがあります。 [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([Artem Zuikov](https://github.com/4ertus2)) -- 念のためにエイリアスの拡張の制限のためのテストを追加しました。 [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- から切り替え `boost::filesystem` に `std::filesystem` 適切な場合。 [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加rpmパッケージです。 [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定のテストを追加する `Unknown identifier` での例外 `IN` セクション。 [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([Artem Zuikov](https://github.com/4ertus2)) -- 簡略化 `shared_ptr_helper` 人々はそれを理解困難に直面しているので。 [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定gorillaとdoubledeltaコーデックのパフォーマンステストを追加しました。 [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([Vasily Nemkov](https://github.com/Enmk)) -- 統合テストの分割 `test_dictionaries` 4つの別々のテストに。 [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([Vitaly Baranov](https://github.com/vitlibar)) -- PVS-Studioの警告を修正する `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 使用を許可する `library` ASanの辞書ソース。 [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Prのリストからchangelogを生成するオプションを追加しました。 [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- をロック `TinyLog` 読む場合の貯蔵。 [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([azerbaijan.kgm](https://github.com/akuzm)) -- チェックを破symlinks ci. [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の増加のタイムアウト “stack overflow” デバッグビルドでは長い時間がかかるため、テストします。 [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 二重の空白のチェックを追加しました。 [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `new/delete` メモリ追跡ときビルドで消毒。 追跡は明確ではありません。 テストでのメモリ制限の例外を防止するだけです。 [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([Artem Zuikov](https://github.com/4ertus2)) -- リンク中に未定義のシンボルのチェックを有効にします。 [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([イワン](https://github.com/abyss7)) -- 再構築を避ける `hyperscan` 毎日です。 [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定ubsanレポートで `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 互換性がないため、クエリプロファイラーをサニタイザーで使用することはできません。 [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加試験のためのリロード辞書の後に失敗するタイマー. [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([Vitaly Baranov](https://github.com/vitlibar)) -- 矛盾を修正する `PipelineExecutor::prepareProcessor` 引数の型。 [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 追加の試験のための悪いuriです。 [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より多くのチェックを追加 `CAST` 機能。 こいつの間にか.ファジィテストです。 [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 追加 `gcc-9` サポートへの `docker/builder` ローカルで画像を構築するコンテナ。 [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([Gleb Novikov](https://github.com/NanoBjorn)) -- 主キーのテスト `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([ディマルブ2000](https://github.com/dimarub2000)) -- 固定試験の影響を受けゆっくりとしたスタックトレースの印刷もできます。 [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クラッシュのテストケースを追加する `groupUniqArray` 固定で [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([azerbaijan.kgm](https://github.com/akuzm)) -- 固定インデックス突然変異テスト。 [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([Nikita Vasilev](https://github.com/nikvas0)) -- パフォーマンステス [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([azerbaijan.kgm](https://github.com/akuzm)) -- マテリアライズドビューは、疑わしい低基数タイプに関する設定に関係なく、低基数タイプで作成できるようになりました。 [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([Olga Khvostikova](https://github.com/stavrolia)) -- 更新されたテスト `send_logs_level` 設定。 [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- Gcc-8.2でビルドを修正しました。 [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([Max Akhmedov](https://github.com/zlobober)) -- 内部libc++でビルドを修正しました。 [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([イワン](https://github.com/abyss7)) -- 共有ビルドを修正する `rdkafka` ライブラリ [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([イワン](https://github.com/abyss7)) -- Mac OSビルドの修正(不完全)。 [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([alex-zaitsev](https://github.com/alex-zaitsev)) -- 修正 “splitted” ビルド。 [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- その他のビルドの修正: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([アモスの鳥](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([vxider](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([イワン](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([proller](https://github.com/proller)) - -#### 下位互換性のない変更 {#backward-incompatible-change-3} - -- 削除が使用されることが少なテーブル機能 `catBoostPool` および貯蔵 `CatBoostPool`. このテーブル機能を使用したら、電子メールをに書いて下さい `clickhouse-feedback@yandex-team.com`. CatBoost統合は引き続きサポートされることに注意してください。 [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 無効にする `ANY RIGHT JOIN` と `ANY FULL JOIN` デフォルトでは。 セット `any_join_distinct_right_table_keys` それらを有効にする設定。 [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([Artem Zuikov](https://github.com/4ertus2)) - -## クリックハウスリリース19.13 {#clickhouse-release-19-13} - -### クリックハウスリリース19.13.6.51,2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} - -#### バグ修正 {#bug-fix-9} - -- このリリースも含む全てのバグ修正から19.11.12.69. - -### ClickHouseリリース19.13.5.44、2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} - -#### バグ修正 {#bug-fix-10} - -- このリリースには、19.14.6.12のすべてのバグ修正も含まれています。 -- 実行中のテーブルの一貫性のない状態を修正 `DROP` クエリーのための複製テーブルが飼育係アクセスすることはできません。 [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- StorageMergeでのデータレースの修正 [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ソケットから無限のrecvにつながるクエリプロファイラで導入されたバグを修正。 [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([alesapin](https://github.com/alesapin)) -- 実行中の過度のcpu使用率を修正 `JSONExtractRaw` ブール値に対する関数です。 [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([Vitaly Baranov](https://github.com/vitlibar)) -- マテリアライズドビュ [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([イワン](https://github.com/abyss7)) -- テーブル機能 `url` この脆弱性により、攻撃者が要求に任意のHTTPヘッダーを挿入することができました。 この問題は、 [Nikita Tikhomirov](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 役に立たない修正 `AST` セットの索引のチェックイン。 [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([Nikita Vasilev](https://github.com/nikvas0)) -- の固定解析 `AggregateFunction` クエリに埋め込まれた値。 [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([Zhichang Yu](https://github.com/yuzhichang)) -- 固定間違った動作の `trim` 機能ファミリ。 [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.13.4.32、2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} - -#### バグ修正 {#bug-fix-11} - -- このリリースには、19.11.9.52と19.11.10.54のすべてのバグセキュリティ修正も含まれています。 -- 固定データレースで `system.parts` テーブルと `ALTER` クエリ。 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ストリームのヘッダーの不一致を修正したのは、sampleとprewhereで空の分散テーブルからの読み取りの場合でした。 [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([Lixiang Qian](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 使用して固定クラッシュ `IN` タプルを含むサブクエリを含む句。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- 同じ列名のケースを修正 `GLOBAL JOIN ON` セクション。 [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定したときにクラッシュする場合が鋳造型 `Decimal` それをサポートしていません。 代わりに例外をスロー。 [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([Artem Zuikov](https://github.com/4ertus2)) -- で固定クラッシュ `extractAll()` 機能。 [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([Artem Zuikov](https://github.com/4ertus2)) -- 以下のためのクエリ変換 `MySQL`, `ODBC`, `JDBC` テーブル関数は現在、 `SELECT WHERE` 複数のクエリ `AND` 式。 [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([ディマルブ2000](https://github.com/dimarub2000)) -- MySQL8の統合のための追加された以前の宣言チェック。 [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([ラファエルdavid tinoco](https://github.com/rafaeldtinoco)) - -#### セキュリティ修正 {#security-fix-1} - -- 修二の脆弱性がコーデックに減圧相(悪意のあるユーザーが可能で圧縮データにつながるバッファオーバーフローの減圧). [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([Artem Zuikov](https://github.com/4ertus2)) - -### ClickHouseリリース19.13.3.26、2019-08-22 {#clickhouse-release-19-13-3-26-2019-08-22} - -#### バグ修正 {#bug-fix-12} - -- 修正 `ALTER TABLE ... UPDATE` とテーブルのクエリ `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) -- タプルを持つサブクエリでin句を使用するときにnpeを修正しました。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- 固定問題の場合はュレプリカになり、生存していてデータ部分が撤去されることによります。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- CSVを解析する問題を修正しました [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) -- システム内の固定データレース.パーツテーブルと変更クエリ。 この修正 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- メモリの破損につながる可能性があり、突然変異で間違ったコードを修正. アドレスの読み取りによる固定segfault `0x14c0` それは同時に起こったかもしれない `DROP TABLE` と `SELECT` から `system.parts` または `system.parts_columns`. 突然変異クエリの準備の競合状態を修正しました。 によるデッドロックを修正 `OPTIMIZE` レプリケートされたテーブルと同時変更操作のような変更。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 後に固定可能なデータ損失 `ALTER DELETE` 索引をスキップしてテーブルを照会します。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([Nikita Vasilev](https://github.com/nikvas0)) - -#### セキュリティ修正 {#security-fix-2} - -- 攻撃者は、zookeeperへの書き込みアクセス権を持っており、clickhouseの実行ネットワークから利用できるカスタムサーバーを実行することができる場合,それはclickhouseのレ きものレプリカまでデータを取得すから悪意のあるレプリカで力clickhouse-サーバへの書き込みを任意のパスにファイルシステム. eldar zaitov、yandexの情報セキュリティチームによって発見された。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.13.2.19、2019-08-14 {#clickhouse-release-19-13-2-19-2019-08-14} - -#### 新しい機能 {#new-feature-5} - -- サンプリングプロファイラーに照会です。 [例えば](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) -- 列のリストを指定できるようにする `COLUMNS('regexp')` より洗練された変種のように動作する表現 `*` アスタリスク [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([mfridental](https://github.com/mfridental)), ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `CREATE TABLE AS table_function()` 可能になりました [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([ディマルブ2000](https://github.com/dimarub2000)) -- デフォルトでは、確率的勾配降下のためのadamオプティマイザが `stochasticLinearRegression()` と `stochasticLogisticRegression()` 集計機能を示すためのもので、良質なほとんど調整することがあります。 [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([Quid37](https://github.com/Quid37)) -- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([アンディヤング](https://github.com/andyyzh)) -- `RENAME` 問合せで出てきますが、すべての倉庫. [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([イワン](https://github.com/abyss7)) -- 現在お客様の受信ログからサーバに要求レベルに設定 `send_logs_level` サーバー設定で指定されたログレベルにかかわらず。 [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) - -#### 下位互換性のない変更 {#backward-incompatible-change-4} - -- を設定 `input_format_defaults_for_omitted_fields` デフォルトでは有効です。 分散テーブルの挿入では、この設定をクラスタで同じにする必要があります(更新をロールする前に設定する必要があります)。 省略されたフィールドの複雑な既定の式の計算を有効にします `JSONEachRow` と `CSV*` フォーマット。 この挙動があるが無視できる性能の差です。 [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([Artem Zuikov](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([azerbaijan.kgm](https://github.com/akuzm)) - -#### 実験の特徴 {#experimental-features} - -- 新規クエリ処理パイプライン。 使用 `experimental_use_processors=1` それを有効にするオプション。 あなた自身の悩みのための使用。 [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### バグ修正 {#bug-fix-13} - -- Kafkaの統合は、このバージョンで修正されました。 -- 固定 `DoubleDelta` の符号化 `Int64` 大きいのため `DoubleDelta` 値、改善 `DoubleDelta` ランダムデータのエンコード `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([Vasily Nemkov](https://github.com/Enmk)) -- の固定過大評価 `max_rows_to_read` 設定の場合 `merge_tree_uniform_read_distribution` は0に設定されます。 [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 改善 {#improvement-4} - -- 次の場合に例外をスローする `config.d` ファイルを持っていないので対応するルート要素としての設定ファイル [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([ディマルブ2000](https://github.com/dimarub2000)) - -#### 性能向上 {#performance-improvement-3} - -- 最適化 `count()`. 今では(可能な場合)最小の列を使用しています。 [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([アモスの鳥](https://github.com/amosbird)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-5} - -- パフォーマンステス [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([azerbaijan.kgm](https://github.com/akuzm)) -- 外部でビルドを修正する `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([イワン](https://github.com/abyss7)) -- 共有ビルドを修正する `rdkafka` ライブラリ [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([イワン](https://github.com/abyss7)) - -## ClickHouseリリース19.11 {#clickhouse-release-19-11} - -### ClickHouseリリース19.11.13.74,2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} - -#### バグ修正 {#bug-fix-14} - -- 固定珍しいクラッシュ `ALTER MODIFY COLUMN` そして、マージ/変更された部分のいずれかが空(0行)のときに垂直マージ。 [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([alesapin](https://github.com/alesapin)) -- の手動update `SIMDJSON`. これにより、偽のjson診断メッセージでstderrファイルが氾濫する可能性が修正されます。 [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([Alexander Kazakov](https://github.com/Akazz)) -- とのバグを修正 `mrk` 突然変異のファイル拡張子 ([alesapin](https://github.com/alesapin)) - -### ClickHouseリリース19.11.12.69、2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} - -#### バグ修正 {#bug-fix-15} - -- 固定性能の劣化指標分析複雑なテンキーの大きます。 この修正 [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- を避ける希少sigsegvを送信するデータテーブル分散型エンジン (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([Azat Khuzhin](https://github.com/azat)) -- 修正 `Unknown identifier` 複数の結合を持つ。 この修正 [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) - -### ClickHouseリリース19.11.11.57,2019-09-13 {#clickhouse-release-19-11-11-57-2019-09-13} - -- カフカ空のトピックから選択する際にsegfaultsを引き起こす論理的なエラーを修正。 [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([イワン](https://github.com/abyss7)) -- 関数の修正 `АrrayEnumerateUniqRanked` paramsに空の配列があります。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) - -### ClickHouseリリース19.11.10.54,2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} - -#### バグ修正 {#bug-fix-16} - -- Kafkaメッセージのオフセットを手動で保存すると、すべてのパーティションに対して一度にコミットできます。 潜在的な重複を修正 “one consumer - many partitions” シナリオだ [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([イワン](https://github.com/abyss7)) - -### ClickHouseリリース19.11.9.52,2019-09-6 {#clickhouse-release-19-11-9-52-2019-09-6} - -- キャッ [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([Vitaly Baranov](https://github.com/vitlibar)) -- 機能のバグを修正 `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([proller](https://github.com/proller)) -- 修正 `JSONExtract` 関数を抽出しながら `Tuple` JSONから。 [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([Vitaly Baranov](https://github.com/vitlibar)) -- 後に固定可能なデータ損失 `ALTER DELETE` 索引をスキップしてテーブルを照会します。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([Nikita Vasilev](https://github.com/nikvas0)) -- 固定性能テスト。 [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 寄木細工:ブール値列の読み取りを修正。 [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定間違った動作の `nullIf` 定数引数の関数。 [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([ギヨームタッセリー](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 通常のサーバーの再起動時にkafkaメッセージの重複の問題を修正。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([イワン](https://github.com/abyss7)) -- ときに長い問題を修正しました `ALTER UPDATE` または `ALTER DELETE` 通常のマージが実行されない場合があります。 利用可能な十分な空きスレッドがない場合、突然変異の実行を防ぎます。 [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([tavplubix](https://github.com/tavplubix)) -- 処理によるエラーの修正 “timezone” サーバー構成ファイルで。 [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- カフカのテストを修正。 [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([イワン](https://github.com/abyss7)) - -#### セキュリティ修正 {#security-fix-3} - -- 攻撃者がzookeeperへの書き込みアクセス権を持ち、clickhouseが実行されるネットワークから利用可能なカスタムサーバーを実行できる場合、それはclickhouseレプリカとして きものレプリカまでデータを取得すから悪意のあるレプリカで力clickhouse-サーバへの書き込みを任意のパスにファイルシステム. eldar zaitov、yandexの情報セキュリティチームによって発見された。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.11.8.46,2019-08-22 {#clickhouse-release-19-11-8-46-2019-08-22} - -#### バグ修正 {#bug-fix-17} - -- 修正 `ALTER TABLE ... UPDATE` とテーブルのクエリ `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([alesapin](https://github.com/alesapin)) -- タプルを持つサブクエリでin句を使用するときにnpeを修正しました。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- 固定問題の場合はュレプリカになり、生存していてデータ部分が撤去されることによります。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- CSVを解析する問題を修正しました [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) -- システム内の固定データレース.パーツテーブルと変更クエリ。 この修正 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- メモリの破損につながる可能性があり、突然変異で間違ったコードを修正. アドレスの読み取りによる固定segfault `0x14c0` それは同時に起こったかもしれない `DROP TABLE` と `SELECT` から `system.parts` または `system.parts_columns`. 突然変異クエリの準備の競合状態を修正しました。 によるデッドロックを修正 `OPTIMIZE` レプリケートされたテーブルと同時変更操作のような変更。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.11.7.40,2019-08-14 {#clickhouse-release-19-11-7-40-2019-08-14} - -#### バグ修正 {#bug-fix-18} - -- Kafkaの統合は、このバージョンで修正されました。 -- 使用しているときにsegfaultを修正 `arrayReduce` 定数の引数の場合。 [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定 `toFloat()` 単調性 [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([ディマルブ2000](https://github.com/dimarub2000)) -- 有効にしてsegfaultを修正 `optimize_skip_unused_shards` シャーディングキーがない [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([CurtizJ](https://github.com/CurtizJ)) -- 固定ロジックの `arrayEnumerateUniqRanked` 機能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- MySQLハンドラから余分な冗長ロギングを削除しました。 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 間違った動作と可能なsegfaultsを修正 `topK` と `topKWeighted` 集計関数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([CurtizJ](https://github.com/CurtizJ)) -- 仮想列を公開しないでください `system.columns` テーブル。 これは、下位互換性のために必要です。 [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 複雑なキーキャッシュ辞書の文字列フィールドのメモリ割り当てのバグを修正。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([alesapin](https://github.com/alesapin)) -- Bug Fixとを可能に適応粒度の作成時に新たなレプリカのために `Replicated*MergeTree` テーブル。 [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([alesapin](https://github.com/alesapin)) -- 修正の無限ループ読み込み時にカフカメッセージ [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([abyss7](https://github.com/abyss7)) -- 固定の可能性に作製したクエリがサーバのクラッシュによるスタックオーバーフローアプリケーションのパーサの可能性スタックオーバーフロー `Merge` と `Distributed` テーブル [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定gorillaエンコードエラーの小型dnaの塩基配列を決定した。 [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Enmk](https://github.com/Enmk)) - -#### 改善 {#improvement-5} - -- ユーザーの上書きを許可する `poll_interval` と `idle_connection_timeout` 接続時の設定。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.11.5.28、2019-08-05 {#clickhouse-release-19-11-5-28-2019-08-05} - -#### バグ修正 {#bug-fix-19} - -- 固定の可能性を掛けクエリの場合はサーバが過負荷状態で運転されています。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定fpeにyandexconsistenthashます。 この修正 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の変換のバグを修正しました `LowCardinality` タイプ `AggregateFunctionFactory`. この修正 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 修正の解析 `bool` からの設定 `true` と `false` 構成ファイル内の文字列。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([alesapin](https://github.com/alesapin)) -- クエリの互換性のないストリ `Distributed` テーブルオーバ `MergeTree` テーブルの一部 `WHERE` に移動します `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([alesapin](https://github.com/alesapin)) -- 固定オーバーフローの整数部署名-タイプを符号なしタイプです。 この修正 [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 下位互換性のない変更 {#backward-incompatible-change-5} - -- `Kafka` まだ壊れてる - -### ClickHouseリリース19.11.4.24,2019-08-01 {#clickhouse-release-19-11-4-24-2019-08-01} - -#### バグ修正 {#bug-fix-20} - -- のを修正した。筆二次指標マーク適応型粒度. [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([alesapin](https://github.com/alesapin)) -- 修正 `WITH ROLLUP` と `WITH CUBE` の修飾子 `GROUP BY` 二レベルの集計。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 固定こつ `JSONExtractRaw` 機能。 固定 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ExternalLoader::reloadOutdated()のセグフォルトを修正しました。 [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([Vitaly Baranov](https://github.com/vitlibar)) -- 固定の場合はサーバが切れることがあり聞くソケットがセットのリスクマネジメントの継続け残ります。 ツつィツ姪"ツつ"ツ債ツづュツつケツづ債つアツつソツづァ サーバーがエラーを返す場合があります `bad_function_call` 残りのクエリの場合。 [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ODBC、MySQL、ClickHouseとHTTP経由で外部辞書の初期ロードのための更新フィールド上の固定役に立たないと間違った条件。 この修正 [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- のキャストで修正された無関係な例外 `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 非決定性の結果を修正する “uniq” 極端なまれなケースでの集計関数。 バグはすべてのClickHouseバージョンに存在していました。 [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Segfault私たちは少し高すぎる設定CIDRに機能 `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 固定小さなメモリリークがサーバに捨てる多くの例外から多くの異なるコンテキストを共有します。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定の状態で消費者も一時停止前の契約とな再開します。 [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([イワン](https://github.com/abyss7) 注このカフカを砕このバージョン。 -- エラーで完了した前の読み取り操作からkafkaデータバッファーをクリアします [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([ニコライ](https://github.com/bopohaa) 注このカフカを砕このバージョン。 -- それ以来 `StorageMergeTree::background_task_handle` で初期化される。 `startup()` その `MergeTreeBlockOutputStream::write()` 初期化の前に使用しようとするかもしれません。 すぐチェックインの場合は初期化されます。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([イワン](https://github.com/abyss7)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-6} - -- 追加された公式 `rpm` パッケージ。 [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([proller](https://github.com/proller)) ([alesapin](https://github.com/alesapin)) -- ビルドする機能を追加する `.rpm` と `.tgz` パッケージと `packager` スクリプト [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([alesapin](https://github.com/alesapin)) -- 以下のための修正 “Arcadia” ビルドシステム。 [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([proller](https://github.com/proller)) - -#### 下位互換性のない変更 {#backward-incompatible-change-6} - -- `Kafka` このバージョンでは壊れている。 - -### ClickHouseリリース19.11.3.11,2019-07-18 {#clickhouse-release-19-11-3-11-2019-07-18} - -#### 新しい機能 {#new-feature-6} - -- 準備文のサポートが追加されました。 [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([Alexander](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `DoubleDelta` と `Gorilla` 列コーデック [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([Vasily Nemkov](https://github.com/Enmk)) -- 追加 `os_thread_priority` を制御することを可能にする設定 “nice” OSが動的スケジューリング優先順位を調整するために使用するクエリ処理スレッドの値。 それは必要です `CAP_SYS_NICE` 動作する機能。 これは [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 実装 `_topic`, `_offset`, `_key` カフカエンジンの列 [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([イワン](https://github.com/abyss7) 注このカフカを砕このバージョン。 -- 集計関数コンビネータを追加 `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([hcz](https://github.com/hczhcz)) -- 集計関数 `groupArrayMovingSum(win_size)(x)` と `groupArrayMovingAvg(win_size)(x)`、ウィンドウサイズの制限の有無にかかわらず、移動の合計/平均を計算します。 [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([inv2004](https://github.com/inv2004)) -- Synonimを追加 `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([hcz](https://github.com/hczhcz)) -- インターゲートh3機能 `geoToH3` ユーバーから. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen Ivan](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### バグ修正 {#bug-fix-21} - -- 非同期updateでdnsキャッシュを実装します。 個別のスレッドで解決すべてのホストを更新dnsキャッシュが期間(設定 `dns_cache_update_period`). ホストのipが頻繁に変更されるときに役立ちます。 [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([アントン-ポポフ](https://github.com/CurtizJ)) -- Segfaultを修正する `Delta` 32ビットサイズ未満の値を持つ列に影響を与えるコーデック。 バグはランダムメモリの破損につながった。 [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([alesapin](https://github.com/alesapin)) -- ブロック内の非物理列とttlマージでsegfaultを修正しました。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([アントン-ポポフ](https://github.com/CurtizJ)) -- との部分のチェックでまれなバグを修正 `LowCardinality` コラム 以前は `checkDataPart` 常に `LowCardinality` コラム [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([alesapin](https://github.com/alesapin)) -- 回避掛けに接続した場合、サーバスレッドプールを行います。 それはからの接続のために重要です `remote` 長い接続タイムアウトがある場合、テーブル関数またはレプリカなしのシャードへの接続。 この修正 [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 定数引数のサポート `evalMLModel` 機能。 この修正 [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定に問題がclickhouse判断したデフォルトのタイムゾーンとして `UCT` 代わりに `UTC`. この修正 [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定バッファアンダーフローで `visitParamExtractRaw`. この修正 [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 今すぐ配布 `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` クエリはリーダーレプリカで直接実行されます。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([alesapin](https://github.com/alesapin)) -- 修正 `coalesce` のために `ColumnConst` と `ColumnNullable` +関連する変更。 [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正する `ReadBufferFromKafkaConsumer` なで読む新しいメッセージ `commit()` たとえそれが以前に失速したとしても [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([イワン](https://github.com/abyss7)) -- 修正 `FULL` と `RIGHT` 結合時の結合結果 `Nullable` 右のテーブルのキー。 [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([Artem Zuikov](https://github.com/4ertus2)) -- 優先度の低いクエリの無限スリープの可能性のある修正。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- これにより、いくつかのクエリがquery\_logの後に表示されないことがあります `SYSTEM FLUSH LOGS` クエリ。 [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 固定 `heap-use-after-free` 阿讃注意ClusterCopierによる腕時計を利用するようにしてすでに削除され複写機のオブジェクトです。 [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定間違った `StringRef` の実装によって返されるポインタ `IColumn::deserializeAndInsertFromArena`. このバグは単体テストのみに影響しました。 [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 同じ名前の列をマスクするソースおよび中間配列の結合列を防ぎます。 [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([Artem Zuikov](https://github.com/4ertus2)) -- MySQLスタイル識別子の引用とMySQLエンジンへの挿入と選択クエリを修正しました。 [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([冬張](https://github.com/zhang2014)) -- さて `CHECK TABLE` queryは、MergeTreeエンジンファミリで動作します。 各パート(またはsimplierエンジンの場合はファイル)のチェックステータスとメッセージが返されます。 また、壊れた部分のフェッチのバグを修正しました。 [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([alesapin](https://github.com/alesapin)) -- SPLIT\_SHARED\_LIBRARIESランタイムを修正 [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([Danila Kutenin](https://github.com/danlark1)) -- 固定タイムゾーンの初期化 `/etc/localtime` シンボリックリン `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- clickhouse-コピー機:シャットダウン時に使用-after freeを修正 [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([proller](https://github.com/proller)) -- 更新 `simdjson`. ゼロバイトを持ついくつかの無効なJSONsが正常に解析する問題を修正しました。 [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- SystemLogsのシャットダウンを修正 [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([アントン-ポポフ](https://github.com/CurtizJ)) -- Invalidate\_queryの条件が辞書に依存しているときにハングする問題を修正しました。 [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([Vitaly Baranov](https://github.com/vitlibar)) - -#### 改善 {#improvement-6} - -- クラスター構成で解決できないアドレスを許可します。 彼らは利用できないとみなされ、すべての接続試行で解決しようとします。 これはkubernetesに特に便利です。 この修正 [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- アイドル状態のtcp接続を閉じる(デフォルトでは一時間待ち)。 これは、すべてのサーバーが他のすべてのサーバーへの接続プールを保持する可能性があり、ピーククエリの同時実行の後に接続が停止するためです。 この修正 [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より良い品質の `topK` 機能。 新しい要素の重みが大きい場合、最後の要素を削除するようにSavingSpace設定の動作を変更しました。 [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- URLの機能と作業領域は今では不完全なUrlなスキーム [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([alesapin](https://github.com/alesapin)) -- に追加されたチェックサム `system.parts_columns` テーブル。 [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- 追加 `Enum` synonimとしてのデータ型 `Enum8` または `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([ディマルブ2000](https://github.com/dimarub2000)) -- フルビット転置変異体のための `T64` コーデック。 より良い圧縮につながる可能性がある `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([Artem Zuikov](https://github.com/4ertus2)) -- 条件に `startsWith` 機能は主キーを使用することができます。 この修正 [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) と [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([ディマルブ2000](https://github.com/dimarub2000)) -- 使用を許可する `clickhouse-copier` クロス-複製クラスタトポロジーを許可する空のデータベースの名前です。 [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([nvartolomei](https://github.com/nvartolomei)) -- 使用 `UTC` システム上のデフォルトのタイムゾーンとして `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` 印刷され、サーバまたはクライアン [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 関数の浮動小数点引数のサポートを返しました `quantileTiming` 下位互換性のため。 [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- エラーメッセージの列がないテーブルを表示します。 [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([イワン](https://github.com/abyss7)) -- さまざまなユーザーが同じquery\_idで実行クエリを許可しない [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([proller](https://github.com/proller)) -- より強固なコードの送信メトリクスをグラファイトを表してい それは長い倍数の間に働きます `RENAME TABLE` オペレーション [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- よりエラーメッセージが表示されますのでthreadpoolできない予定、タスクを実行します。 この修正 [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- NgramSearchを反転させると、より直感的になります [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([Danila Kutenin](https://github.com/danlark1)) -- HDFS engine builderでのユーザー解析の追加 [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([akonyaev90](https://github.com/akonyaev90)) -- 更新のデフォルト値 `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([Artem Konovalov](https://github.com/izebit)) -- 廃止された設定の概念を追加しました。 廃止された設定 `allow_experimental_low_cardinality_type` 効果なしで使用することができます。 [0f15c01c6802f7ce1a1494c846be8c98944cd](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [Alexey Milovidov](https://github.com/alexey-milovidov) - -#### 性能向上 {#performance-improvement-4} - -- 増加数の河川から選択するとmergeテーブルにより均一に分布す。 追加された設定 `max_streams_multiplier_for_merge_tables`. この修正 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-7} - -- Clickhouseの異なるバージョンとクライアン [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([alesapin](https://github.com/alesapin)) -- テスト対象の情報を毎にコミットを引きます。 [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([alesapin](https://github.com/alesapin)) -- カスタムアロケータをサポートするaddress sanitizerと連携 (`Arena` と `ArenaWithFreeLists`)より良いデバッグのための “use-after-free” エラー。 [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([azerbaijan.kgm](https://github.com/akuzm)) -- に切り替える [LLVM libunwindの実装](https://github.com/llvm-mirror/libunwind) C++例外処理およびスタックトレース印刷用 [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([Nikita Lapkov](https://github.com/laplab)) -- さらに二つの警告を追加-weverything [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- メモリ消毒剤とclickhouseを構築することができます。 [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定ubsanレポートについて `bitTest` ファズテストの機能。 [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Docker:認証を必要とするClickHouseインスタンスを初期化する可能性を追加しました。 [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([Korviakov Andrey](https://github.com/shurshun)) -- バージョン1.1.0にlibrdkafkaを更新 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([イワン](https://github.com/abyss7)) -- 追加グローバルタイムアウトのための統合の試験を無効にし試験ます。 [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([alesapin](https://github.com/alesapin)) -- いくつかのthreadsanitizerの障害を修正します。 [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([azerbaijan.kgm](https://github.com/akuzm)) -- その `--no-undefined` オプション力、リンカーをチェックすべての外部の名の存在をリンク 分割ビルドモードでライブラリ間の実際の依存関係を追跡することは非常に便利です。 [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([イワン](https://github.com/abyss7)) -- のための追加された性能試験 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Gcc-7との互換性を修正しました。 [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Gcc-9のサポートが追加されました。 この修正 [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Libunwindが正しくリンクできない場合のエラーを修正。 [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- PVS-Studioによって検出されたいくつかの警告を修正しました。 [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加された初期サポート `clang-tidy` 静的な検光子。 [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- BSD/Linuxエンディアンマクロを変換する( ‘be64toh’ と ‘htobe64’)Mac OS Xに相当するもの [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([フーチェン](https://github.com/fredchenbj)) -- 統合テストガイドの改善。 [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Macosx+gcc9でのビルドの修正 [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([フィリモノフ](https://github.com/filimonov)) -- 難しいタイプミスを修正:aggreagte-\>aggregate。 [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([azerbaijan.kgm](https://github.com/akuzm)) -- Freebsdビルドの修正 [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([proller](https://github.com/proller)) -- 追加リンク実験youtubeチャンネルサイト [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([Ivan Blinkov](https://github.com/blinkov)) -- CMake:カバレッジフラグのオプションを追加:WITH\_COVERAGE [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([proller](https://github.com/proller)) -- いくつかのインラインpodarrayの初期サイズを修正。 [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([azerbaijan.kgm](https://github.com/akuzm)) -- clickhouse-サーバー.postinst:centos6のos検出を修正 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([proller](https://github.com/proller)) -- 追加されたアーチlinuxパッケージ生成。 [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 共通/設定を分割します。h by libs(dbms) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([proller](https://github.com/proller)) -- 以下のための修正 “Arcadia” ムの構築 [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([proller](https://github.com/proller)) -- 型にはまらないビルドの修正(gcc9、サブモジュールなし) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([proller](https://github.com/proller)) -- バグが発生しやすいことが証明されているため、unalignedstoreで明示的な型を必要とします [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([azerbaijan.kgm](https://github.com/akuzm)) -- Macosのビルドを修正 [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([フィリモノフ](https://github.com/filimonov)) -- ここで要求されたより大きなデータセットを持つ新しいjit機能に関する性能試験 [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 走行状態での試験はストレステスト [12693e568722f11e19859742f56428455501fd2a](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([alesapin](https://github.com/alesapin)) - -#### 下位互換性のない変更 {#backward-incompatible-change-7} - -- `Kafka` このバージョンでは壊れている。 -- 有効 `adaptive_index_granularity` =新しいのためのデフォルトで10MB `MergeTree` テーブル。 バージョン19.11以降で新しいMergeTreeテーブルを作成した場合、19.6より前のバージョンへのダウングレードは不可能になります。 [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([alesapin](https://github.com/alesapin)) -- Yandexのによって使用された廃止された文書化されていない埋め込まれた辞書を削除。メトリカ を機能 `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` もはや利用できません。 これらの機能を使用している場合は、電子メールをclickhouse-feedback@yandex-team.com。注:最後の瞬間に我々はしばらくの間、これらの機能を維持することを決めました。 [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## ClickHouseリリース19.10 {#clickhouse-release-19-10} - -### クリックハウスリリース19.10.1.5,2019-07-12 {#clickhouse-release-19-10-1-5-2019-07-12} - -#### 新しい機能 {#new-feature-7} - -- 新しい列コーデックを追加: `T64`. (U)IntX/EnumX/Data(Time)/DecimalX列用に作成されます。 定数値または小さい範囲値を持つ列に適しているはずです。 コーデック自体は、拡大または再圧縮せずにデータ型を縮小できます。 [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([Artem Zuikov](https://github.com/4ertus2)) -- データベースエンジ `MySQL` できる全てのテーブルをリモートMySQLサーバー [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([冬張](https://github.com/zhang2014)) -- `bitmapContains` 実装。 それは2xより速いです `bitmapHasAny` 第二のビットマップが一つの要素を含む場合。 [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([Zhichang Yu](https://github.com/yuzhichang)) -- のサポート `crc32` 関数(MySQLやPHPとまったく同じ動作)。 ハッシュ関数が必要な場合は使用しないでください。 [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen Ivan](https://github.com/BHYCHIK)) -- 実装 `SYSTEM START/STOP DISTRIBUTED SENDS` 非同期挿入を制御するクエリ `Distributed` テーブル。 [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([冬張](https://github.com/zhang2014)) - -#### バグ修正 {#bug-fix-22} - -- マージ制限のクエリ実行制限および最大パーツサイズを無視する。 [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 通常のブロックの重複排除(非常にまれ)と重複ブロックの挿入(より頻繁に)につながる可能性のあるバグを修正しました。 [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([alesapin](https://github.com/alesapin)) -- 機能の修正 `arrayEnumerateUniqRanked` 空の配列を持つ引数の場合 [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([proller](https://github.com/proller)) -- な購読カフカ題なく意思をポーリングメッセージ. [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([イワン](https://github.com/abyss7)) -- 設定を行う `join_use_nulls` Nullable内にできない型に対しては何の効果も得られません [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([Olga Khvostikova](https://github.com/stavrolia)) -- 固定 `Incorrect size of index granularity` エラー [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([コラクススター](https://github.com/coraxster)) -- 小数変換オーバーフローを修正 [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([コラクススター](https://github.com/coraxster)) -- フラッシュバッファの場合 `WriteBufferFromHDFS`のデストラクタが呼び出されます。 これにより、 `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([Xindong Peng](https://github.com/eejoin)) - -#### 改善 {#improvement-7} - -- 空のセルを `CSV` としてデフォルト値を設定 `input_format_defaults_for_omitted_fields` は有効です。 [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([azerbaijan.kgm](https://github.com/akuzm)) -- 外部辞書の非ブロッキングロード。 [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([Vitaly Baranov](https://github.com/vitlibar)) -- ネットワークタイムアウトできるダイナミックな変化のための既存の接続に従って設定します。 [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([Konstantin Podshumok](https://github.com/podshumok)) -- を使用して “public\_suffix\_list” 機能のため `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. これは、 `gperf` ファイルから生成されたリスト:https://publicsuffix.org/list/public\_suffix\_list.dat(例えば、今我々はドメインを認識する `ac.uk` 有意ではない)。 [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 採用 `IPv6` システムテーブルのデータ型。 `system.processes` と `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- MySQL互換性プロトコルとの接続にセッションを使用する。 \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([ユーリーバラノフ](https://github.com/yurriy)) -- サポートより `ALTER` クエリ `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([sundyli](https://github.com/sundy-li)) -- サポート `` のセクション `clickhouse-local` 設定ファイル。 [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([proller](https://github.com/proller)) -- クエリの実行を許可する `remote` テーブル機能 `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([proller](https://github.com/proller)) - -#### 性能向上 {#performance-improvement-5} - -- MergeTree列の最後に最後のマークを書き込む可能性を追加します。 これにより、テーブルデータ範囲外のキーの無駄な読み込みを回避できます。 適応インデックスの粒度が使用されている場合にのみ有効になります。 [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([alesapin](https://github.com/alesapin)) -- 非常に遅いファイルシステム上のmergetreeテーブルのパフォーマンスの向上 `stat` シスコール [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定性能の劣化からの読み出しmergetreeテーブルで導入されたバージョン19.6. 修正\#5631. [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-8} - -- 実装 `TestKeeper` テストに使用されるZooKeeperインタフェースの実装として [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([alexey-milovidov](https://github.com/alexey-milovidov)) ([levushkin aleksej](https://github.com/alexey-milovidov)) -- これからは `.sql` 試験走行ができるによって切り離されたサーバを並列には、ランダムなデータベースです。 それらをより速く実行し、カスタムサーバー構成で新しいテストを追加し、異なるテストが互いに影響しないことを確認します。 [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([イワン](https://github.com/abyss7)) -- 削除 `` と `` 性能テストから [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([Olga Khvostikova](https://github.com/stavrolia)) -- 固定 “select\_format” 性能試験のための `Pretty` 形式 [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## クリックハウスリリース19.9 {#clickhouse-release-19-9} - -### クリックハウスリリース19.9.3.31,2019-07-05 {#clickhouse-release-19-9-3-31-2019-07-05} - -#### バグ修正 {#bug-fix-23} - -- 32ビットサイズ未満の値を持つ列に影響を与えるデルタコーデックでsegfaultを修正しました。 バグはランダムメモリの破損につながった。 [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([alesapin](https://github.com/alesapin)) -- LowCardinalityのコラムと部分の点検でまれな虫を修理して下さい。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([alesapin](https://github.com/alesapin)) -- ブロック内の非物理列とttlマージでsegfaultを修正しました。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 低優先度のクエリの潜在的な無限の睡眠を修正しました。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定方法clickhouse判断したデフォルトのタイムゾーンとしてuctの代わりにutcです。 [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- のを修正した。約の実行の分散drop/alter/quick/最適化クラスターに関するお問い合わせフォロワレプリカの前にリーダーレプリカ. 今、彼らはリーダーのレプリカに直接実行されます。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([alesapin](https://github.com/alesapin)) -- 固定レースの条件を回避することが可能となり、一部のクエリーのような画面が、表示されないでquery\_logぐにシステムのフラッシュログを返します。 [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 定数引数のサポートがないことを追加 `evalMLModel` 機能。 [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### クリックハウスリリース19.9.2.4,2019-06-24 {#clickhouse-release-19-9-2-4-2019-06-24} - -#### 新しい機能 {#new-feature-8} - -- 凍結する部品についての印刷物情報 `system.parts` テーブル。 [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([proller](https://github.com/proller)) -- 引数に設定されていない場合は、ttyでclickhouse-client startにクライアントパスワードを尋ねる [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([proller](https://github.com/proller)) -- 実装 `dictGet` と `dictGetOrDefault` 小数タイプの関数。 [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 改善 {#improvement-8} - -- Debian init:サービス停止タイムアウトの追加 [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([proller](https://github.com/proller)) -- 疑わしいタイプのテーブルを作成するには、デフォルトで禁止されている設定を追加します [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([Olga Khvostikova](https://github.com/stavrolia)) -- 回帰機能を返却時の重量モデルとして用いられていない状態で機能 `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([Quid37](https://github.com/Quid37)) -- 回帰方法の名前を変更して改善します。 [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([Quid37](https://github.com/Quid37)) -- 明のインタフェースを文字列が揃. [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([Danila Kutenin](https://github.com/danlark1)) - -#### バグ修正 {#bug-fix-24} - -- カフカの潜在的なデータ損失を修正 [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([イワン](https://github.com/abyss7)) -- 潜在的な無限ループを修正 `PrettySpace` ゼロ列で呼び出されたときの形式 [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([Olga Khvostikova](https://github.com/stavrolia)) -- 線形モデルのuint32オーバーフローバグを修正。 非constモデル引数のeval mlモデルを許可します。 [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- `ALTER TABLE ... DROP INDEX IF EXISTS ...` なる例外を提供される場合指数が存在しない [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([Gleb Novikov](https://github.com/NanoBjorn)) -- セグメントフォールトを修正 `bitmapHasAny` スカラーサブクエリ [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) -- 固定の場合にはエラー複製を接続プールなリトライを解決するホストでも、dnsキャッシュした。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([alesapin](https://github.com/alesapin)) -- 固定 `ALTER ... MODIFY TTL` レプリケートされたマーゲットリーで [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([アントン-ポポフ](https://github.com/CurtizJ)) -- マテリアライズ列を使用して分散テーブルに挿入を修正 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) -- Truncate Joinストレージの割り当ての問題を修正 [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([Tcheason](https://github.com/TCeason)) -- に最近のバージョンのパッケージtzdata一部のファイルsymlinksます。 現在の仕組みを検出するデフォルトのタイムゾーンの故障が考えられ、間違った名前に一部のタイムゾーン. 少なくとも、提供されていれば、タイムゾーン名をtzの内容に強制します。 [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([イワン](https://github.com/abyss7)) -- 一定の針が合計で少なくとも16kbの長さである場合、multivolnitsky searcherでいくつかの非常にまれなケースを修正します。 このアルゴリズムは、以前の結果を見逃したり上書きしたりして、誤った結果につながります `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([Danila Kutenin](https://github.com/danlark1)) -- ExternalData要求の設定でClickHouseの設定を使用できない場合の問題を修正しました。 また、今のところ、設定 `date_time_input_format` と `low_cardinality_allow_in_native_format` 名前のあいまいさのために使用することはできません(外部データではテーブル形式と解釈でき、クエリでは設定にすることができます)。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila Kutenin](https://github.com/danlark1)) -- 部品は飼育係からそれらを落とすことなく、fsからのみ削除されたバグを修正。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([alesapin](https://github.com/alesapin)) -- 削除デバッグログインからmysqlプロトコル [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- DDLクエリ処理中にZNONODEをスキップ [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) -- 修正ミックス `UNION ALL` 結果列の種類。 結果の列のデータ型および列の型が一致しない場合がありました。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) -- 間違った整数の例外をスローする `dictGetT` 機能の代わりにクラッシュ。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) -- ハッシュ化された辞書のための間違ったelement\_countとload\_factorを修正 `system.dictionaries` テーブル。 [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-9} - -- 固定ビルドなし `Brotli` HTTP圧縮のサポート (`ENABLE_BROTLI=OFF` cmake変数)。 [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([Anton Yuzhaninov](https://github.com/citrin)) -- Roaringを含める。轟音/轟音としてh。h [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([Orivej Desh](https://github.com/orivej)) -- ハイパースキャンでgcc9の警告を修正(\#lineディレクティブは悪です!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([Danila Kutenin](https://github.com/danlark1)) -- Gcc-9でコンパイルする際のすべての警告を修正。 いくつかのcontribの問題を修正しました。 Gcc9氷を修正しbugzillaに提出. [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([Danila Kutenin](https://github.com/danlark1)) -- Lldとのリンクを修正 [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 辞書で使用されていない特殊化を削除する [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([Artem Zuikov](https://github.com/4ertus2)) -- 向上性能試験のためのフォーマットと構文解析表の異なる種類のファイル [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([Olga Khvostikova](https://github.com/stavrolia)) -- 並列テスト実行のための修正 [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([proller](https://github.com/proller)) -- Docker:clickhouse-testからconfigsを使う [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([proller](https://github.com/proller)) -- FreeBSD用のコンパイルを修正 [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([proller](https://github.com/proller)) -- Boostを1.70にアップグレード [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([proller](https://github.com/proller)) -- サブモジュールとしてビルドclickhouseを修正 [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([proller](https://github.com/proller)) -- JSONExtractパフォーマンステストの改善 [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([Vitaly Baranov](https://github.com/vitlibar)) - -## ClickHouseリリース19.8 {#clickhouse-release-19-8} - -### ClickHouseリリース19.8.3.8、2019-06-11 {#clickhouse-release-19-8-3-8-2019-06-11} - -#### 新しい機能 {#new-features} - -- JSONで動作する機能を追加しました [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([hcz](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([Vitaly Baranov](https://github.com/vitlibar)) -- 多くの言語に存在するbasename関数と同様の動作を持つ関数basenameを追加します (`os.path.basename` pythonでは, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 追加 `LIMIT n, m BY` または `LIMIT m OFFSET n BY` LIMIT BY句にnのオフセットを設定する構文。 [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 追加された新しいデータ型 `SimpleAggregateFunction` を持つことができます。 `AggregatingMergeTree`. これは、次のような単純な関数でのみ使用できます `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([Boris Granveaud](https://github.com/bgranvea)) -- 関数の非定数引数のサポートが追加されました `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([Danila Kutenin](https://github.com/danlark1)) -- 機能追加 `skewPop`, `skewSamp`, `kurtPop` と `kurtSamp` シーケンスの歪度、標本の歪度、尖度、標本の尖度をそれぞれ計算します。 [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([hcz](https://github.com/hczhcz)) -- 支援の名前変更操作のための `MaterializeView` ストレージ。 [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 追加のサーバで接続するclickhouse mysqlを使用してクライアント [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([ユーリーバラノフ](https://github.com/yurriy)) -- 追加 `toDecimal*OrZero` と `toDecimal*OrNull` 機能。 [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([Artem Zuikov](https://github.com/4ertus2)) -- 機能のサポート十進のタイプ: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted`、medianExactWeighted。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([Danila Kutenin](https://github.com/danlark1)) -- 追加 `format` 機能。 引数にリストされた文字列を含む定数パターン(簡略化されたPython形式のパターン)の書式設定。 [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([Danila Kutenin](https://github.com/danlark1)) -- 追加 `system.detached_parts` テーブルの情報を含む外部 `MergeTree` テーブル。 [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([azerbaijan.kgm](https://github.com/akuzm)) -- 追加 `ngramSearch` 針と干し草の山の間の非対称差を計算する関数。 [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([Danila Kutenin](https://github.com/danlark1)) -- 集約関数インタフェースを使用して、基本的な機械学習方法(確率線形回帰とロジスティック回帰)の実装。 モデルの重みを更新するための戦略が異なります(単純勾配降下、運動量法、nesterov法)。 また注文のサイズのミニバッチを支える。 [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([Quid37](https://github.com/Quid37)) -- の実装 `geohashEncode` と `geohashDecode` 機能。 [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([Vasily Nemkov](https://github.com/Enmk)) -- 集計関数の追加 `timeSeriesGroupSum` る累積の異なる時系列のサンプルのタイムスタンプなアライメントを実施します。 これは、二つのサンプルタイムスタンプ間の線形補間を使用して、一緒に時系列を合計します。 集計関数の追加 `timeSeriesGroupRateSum` これは、時系列のレートを計算し、その後一緒にレートを合計します。 [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([楊関劉](https://github.com/LiuYangkuan)) -- 機能追加 `IPv4CIDRtoIPv4Range` と `IPv6CIDRtoIPv6Range` CIDRを使用してサブネット内のIPの下限と上限を計算する。 [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 有効な設定でhttpを使用してクエリを送信するときにx-clickhouse-summaryヘッダーを追加します `send_progress_in_http_headers`. X-ClickHouse-Progressの通常の情報を返し、クエリに挿入された行数やバイト数などの追加情報を返します。 [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([ギヨームタッセリー](https://github.com/YiuRULE)) - -#### 改善 {#improvements} - -- 追加 `max_parts_in_total` パーティションキー\#5166の安全でない指定を防ぐテーブルのMergeTreeファミリーの設定(デフォルト:100 000)。 [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `clickhouse-obfuscator`:derive種のため、個々のカラムを組み合わせ種の利用が重要であると考えられとカラム名、カラム位置にします。 ことを目的として変換するデータセットに複数の関連するテーブル、テーブルはJOINableに設定します。 [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能追加 `JSONExtractRaw`, `JSONExtractKeyAndValues`. 関数の名前を変更 `jsonExtract` に `JSONExtract`. 何かがうまくいかない場合、これらの関数は対応する値を返します。 `NULL`. 変更された機能 `JSONExtract` 今度は、最後のパラメータから戻り値の型を取得し、nullableを注入しません。 AVX2命令が利用できない場合にRapidJSONにフォールバックを実装しました。 新しいバージョンに更新Simdjsonライブラリ。 [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([Vitaly Baranov](https://github.com/vitlibar)) -- さて `if` と `multiIf` 機能は条件に頼りません `Nullable` しかし、sqlの互換性のためにブランチに依存しています。 [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([建呉](https://github.com/janplus)) -- `In` 述語が生成されます `Null` 結果から `Null` のような入力 `Equal` 機能。 [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([建呉](https://github.com/janplus)) -- Kafkaからの行数ごとの時間制限(flush\_interval/poll\_timeout)をチェックします。 この読みからのカフカの消費者をより頻繁にチェックの時間制限のトップレベルの流れ [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([イワン](https://github.com/abyss7)) -- バンドルsaslとリンクrdkafka. sasl scram認証を使用できるようにする必要があります [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([イワン](https://github.com/abyss7)) -- すべてのジョインのrowreflistのバッチバージョン。 [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([Artem Zuikov](https://github.com/4ertus2)) -- clickhouse-サーバ:より有益なエラーメッセージを聞きます. [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([proller](https://github.com/proller)) -- Clickhouseのサポート辞書-機能のための複写機 `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([proller](https://github.com/proller)) -- 新しい設定を追加 `kafka_commit_every_batch` カフカの政策を規制する。 - ることができる設定のコミットモード:バッチのメッセージの取り扱い、後のブロック全体に書きます。 このトレードオフの関係を失うメッセージやみ表示することを目的としていま倍もいる。 [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([イワン](https://github.com/abyss7)) -- 作る `windowFunnel` 他の符号なし整数型をサポート。 [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([sundyli](https://github.com/sundy-li)) -- 仮想列をシャドウする `_table` マージエンジンで。 [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([イワン](https://github.com/abyss7)) -- 作る `sequenceMatch` 集計関数は、他の符号なし整数型をサポート [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([sundyli](https://github.com/sundy-li)) -- より良いエラーメッセージの場合はチェックサムミスマッチは一によるものと考えられるハードウェアです。 [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- チェックすると配下のテーブル支援のためのサンプリング `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([イワン](https://github.com/abyss7)) -- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- MySQLワイヤプロトコルの改善。 フォーマットの名前をMySQLWireに変更しました。 RAIIをRSA\_freeを呼び出すために使用します。 コンテキス [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([ユーリーバラノフ](https://github.com/yurriy)) -- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([proller](https://github.com/proller)) -- 分散テーブルへの非同期挿入のクエリ設定を考慮します。 [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([Tcheason](https://github.com/TCeason)) -- 関数の名前を変更 `leastSqr` に `simpleLinearRegression`, `LinearRegression` に `linearRegression`, `LogisticRegression` に `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### 性能の改善 {#performance-improvements} - -- ALTER MODIFYクエリの非レプリケートされたMergeTreeテーブルの一部の並列処理。 [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([Ivan Kush](https://github.com/IvanKush)) -- 正規表現の抽出における最適化。 [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([Danila Kutenin](https://github.com/danlark1)) -- 結果を結合するために右結合キー列を追加しないでください。 [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([Artem Zuikov](https://github.com/4ertus2)) -- 最初の空の応答の後にkafkaバッファをフリーズします。 それは多数のinvokationsをの避けます `ReadBuffer::next()` いくつかの行解析ストリームの空の結果。 [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([イワン](https://github.com/abyss7)) -- `concat` 複数の引数の関数の最適化。 [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([Danila Kutenin](https://github.com/danlark1)) -- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([Artem Zuikov](https://github.com/4ertus2)) -- より速い解凍を持つように、lz4実装を参照してアップグレードします。 [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([Danila Kutenin](https://github.com/danlark1)) -- MSD基数ソート(kxsortに基づく)、および部分ソートを実装しました。 [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([Evgenii Pravda](https://github.com/kvinty)) - -#### バグ修正 {#bug-fixes} - -- プッシュが結合で列を必要と修正 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([冬張](https://github.com/zhang2014)) -- バグを修正,clickhouseはsystemdによって実行されると,コマンド `sudo service clickhouse-server forcerestart` 期待通りに動作しませんでした。 [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([proller](https://github.com/proller)) -- (9009ポート上のサーバー間のhttpサーバーは常に偶数エラーで、コード200を返しました)datapartsexchangeのhttpエラーコードを修正します。 [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([proller](https://github.com/proller)) -- MAX\_SMALL\_STRING\_SIZEより長い文字列のSimpleAggregateFunctionを修正しました [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([Azat Khuzhin](https://github.com/azat)) -- のためのエラーを修正 `Decimal` に `Nullable(Decimal)` 変換で。 支援その他数を小数点の変換を含む異なる)を採用。 [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([Artem Zuikov](https://github.com/4ertus2)) -- 間違った計算につながるsimdjsonライブラリ内の固定fpu clobbering `uniqHLL` と `uniqCombined` 次のような集計関数と数学関数 `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- JSON関数でのconst/nonconstの混合ケースの処理を修正しました。 [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([Vitaly Baranov](https://github.com/vitlibar)) -- 修正 `retention` 機能。 これで、データの行を満たすすべての条件がデータの状態に追加されます。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) -- 結果のタイプを修正する `quantileExact` 小数で。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 文書 {#documentation} - -- 以下のための文書を翻訳 `CollapsingMergeTree` 中国語に。 [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) -- テーブルエンジンに関する文書を中国語に翻訳します。 - [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) - [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) - ([決してリー](https://github.com/neverlee)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements} - -- ツづツつ、ツつシツつイツ猟.用ツつュツつセツつウツつ"ツ。[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([イワン](https://github.com/abyss7)) -- 移動性能試験の個別のディレクトリが便利です。 [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- パフォーマンステストの修正 [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([alesapin](https://github.com/alesapin)) -- 追加ツールをチェックサムを計算によるビット切り替えデバッグハードウェアます。 [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- くランナーのスクリプトをより使用できます。 [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([フィリモノフ](https://github.com/filimonov)) -- パフォーマンステス [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([alesapin](https://github.com/alesapin)) -- パフォーマンステストでのクエリの作成、入力、および削除での置換を行う機能を追加 [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([Olga Khvostikova](https://github.com/stavrolia)) - -## クリックハウスリリース19.7 {#clickhouse-release-19-7} - -### ClickHouseリリース19.7.5.29,2019-07-05 {#clickhouse-release-19-7-5-29-2019-07-05} - -#### バグ修正 {#bug-fix-25} - -- 固定能の回帰一部のクエリを処理するクラウドの場合。 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([冬張](https://github.com/zhang2014)) - -### クリックハウスリリース19.7.5.27,2019-06-09 {#clickhouse-release-19-7-5-27-2019-06-09} - -#### 新しい機能 {#new-features-1} - -- ビットマップ関連の機能を追加 `bitmapHasAny` と `bitmapHasAll` に類似した `hasAny` と `hasAll` 配列の関数。 [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([Catalonia\_comarques.Kgm](https://github.com/svladykin)) - -#### バグ修正 {#bug-fixes-1} - -- Segfaultをオンにする `minmax` Null値を持つインデックス。 [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([Nikita Vasilev](https://github.com/nikvas0)) -- LIMITのすべての入力列を必要な出力としてマークします。 それは修正します ‘Not found column’ いくつかの分散クエリのエラー。 [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([Constantin S.Pan](https://github.com/kvap)) -- 修正 “Column ‘0’ already exists” エラーで `SELECT .. PREWHERE` デフォルトの列 [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([proller](https://github.com/proller)) -- 修正 `ALTER MODIFY TTL` 上のクエリ `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([アントン-ポポフ](https://github.com/CurtizJ)) -- Kafkaの消費者が起動に失敗したときにサーバをクラッシュさせないでください。 [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([イワン](https://github.com/abyss7)) -- 固定ビットマップ機能を誤った結果です。 [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([アンディヤング](https://github.com/andyyzh)) -- ハッシュ化された辞書のための修正element\_count(重複を含めないでください) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) -- タイムゾーンの名前として環境変数tzの内容を使用します。 すでに正しく検出デフォルトのタイムゾーンもあります。[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([イワン](https://github.com/abyss7)) -- 整数を変換しようとしないでください `dictGetT` それが正しく動作しないため、機能。 代わりに例外をスローします。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) -- ExternalData HTTP要求の設定を修正しました。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([ダニラ - クテニン](https://github.com/danlark1)) -- 部品は飼育係からそれらを落とすことなく、fsからのみ削除されたバグを修正。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([alesapin](https://github.com/alesapin)) -- セグメンテーショ `bitmapHasAny` 機能。 [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([Zhichang Yu](https://github.com/yuzhichang)) -- 固定の場合にはエラー複製を接続プールなリトライを解決するホストでも、dnsキャッシュした。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([alesapin](https://github.com/alesapin)) -- 固定 `DROP INDEX IF EXISTS` クエリ。 さて `ALTER TABLE ... DROP INDEX IF EXISTS ...` 指定されたインデックスが存在しない場合、queryは例外を発生させません。 [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([Gleb Novikov](https://github.com/NanoBjorn)) -- Union all supertype列を修正しました。 結果の列のデータ型および列の型が一致しない場合がありました。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) -- DDLクエリの処理中にZNONODEをスキップします。 別のノードがタスクキューのznodeを削除する前に、 - それを処理しませんでしたが、すでに子のリストを取得していますが、DDLWorkerスレッドを終了します。 [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) -- マテリアライズドカラムを使用して分散()テーブルに挿入を修正。 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) - -### ClickHouseリリース19.7.3.9,2019-05-30 {#clickhouse-release-19-7-3-9-2019-05-30} - -#### 新しい機能 {#new-features-2} - -- ユーザーが指定できる設定の範囲を制限することができます。 - これらの制約は、ユーザー設定プロファイルで設定できます。 - [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([ヴィタリ - Baranov](https://github.com/vitlibar)) -- 関数の第二のバージョンを追加します `groupUniqArray` 任意を使って - `max_size` 結果の配列のサイズを制限するパラメーター。 この - 動作は次のようになります `groupArray(max_size)(x)` 機能。 - [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([Guillaume - Tassery](https://github.com/YiuRULE)) -- TSVWithNames/CSVWithNames入力ファイル形式の場合、列の順序は次のようになります - ファイルヘッダーから決定。 これは、 - `input_format_with_names_use_header` パラメータ。 - [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) - ([Alexander](https://github.com/Akazz)) - -#### バグ修正 {#bug-fixes-2} - -- マージ中にuncompressed\_cache+joinでクラッシュ(\#5197) - [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([ダニラ - クテニン](https://github.com/danlark1)) -- Segmentation faultにclickhouse-クライアントがクエリーのシステムです。 \#5066 - [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) - ([イワン](https://github.com/abyss7)) -- KafkaEngine経由で重い負荷のデータ損失(#4736) - [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) - ([イワン](https://github.com/abyss7)) -- 固定非常に珍しいデータ競合状態が起こるのを実行する際にクエリとeuのすべての関少なくとも二つから選択します。列、システム。テーブル、システム。部品、システム。マージファミリのparts\_tablesまたはテーブルと、関連するテーブルの列の変更を同時に実行する。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 性能の改善 {#performance-improvements-1} - -- の単一の数値列によるソートに基数ソートを使用します `ORDER BY` なし - `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), - [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) - ([Evgenii Pravda](https://github.com/kvinty), - [alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 文書 {#documentation-1} - -- 翻訳書類の一部のテーブルエンジン。 - [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), - [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), - [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) - ([张风啸](https://github.com/AlexZFX)), - [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([しない - リー](https://github.com/neverlee)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-1} - -- UTF-8文字を正しく印刷する `clickhouse-test`. - [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加コマンドラインパラメータclickhouse-クライアントに常に負荷の提案 - データ。 [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- いくつかのpvs-studioの警告を解決します。 - [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) - ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 更新lz4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([ダニラ - クテニン](https://github.com/danlark1)) -- 今後のプル要求#5030の要件を構築するためにgperfを追加します。 - [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) - ([proller](https://github.com/proller)) - -## ClickHouseリリース19.6 {#clickhouse-release-19-6} - -### クリックハウスリリース19.6.3.18,2019-06-13 {#clickhouse-release-19-6-3-18-2019-06-13} - -#### バグ修正 {#bug-fixes-3} - -- テーブル関数からのクエリの条件プッシュダウンで修正 `mysql` と `odbc` と対応するテーブルエンジン。 これは#3540と#2384を修正します。 [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Zookeeperのデッドロックを修正します。 [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([github1youlcname](https://github.com/github1youlc)) -- CSVで引用小数を許可します。 [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([Artem Zuikov](https://github.com/4ertus2) -- Float Inf/NaNからDecimalsへの変換を禁止します(例外をスローします)。 [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([Artem Zuikov](https://github.com/4ertus2)) -- リネームクエリでデータレースを修正。 [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([冬張](https://github.com/zhang2014)) -- 一時的にlfallocを無効にします。 lfallocの使用は、uncompressedcacheを割り当てる際に多くのmap\_failedにつながり、その結果、高負荷のサーバーでのクエリのクラッシュにつながる可能性があります。 [cfdba93comment](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([Danila Kutenin](https://github.com/danlark1)) - -### ClickHouseリリース19.6.2.11、2019-05-13 {#clickhouse-release-19-6-2-11-2019-05-13} - -#### 新しい機能 {#new-features-3} - -- 列およびテーブルのttl式。 [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([アントン-ポポフ](https://github.com/CurtizJ)) -- のサポートを追加 `brotli` HTTPレスポンスの圧縮(Accept-Encoding:br) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([ミハイル](https://github.com/fandyushin)) -- 新しい機能を追加 `isValidUTF8` バイトのセットが正しくutf-8エンコードされているかどう [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([Danila Kutenin](https://github.com/danlark1)) -- 新しい負荷分散ポリシーの追加 `first_or_random` 送信されるクエリを最初に指定されたホストの場合は利用できな送信をクエリーダ主催のチャームのボー. クロスレプリケーショ [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([nvartolomei](https://github.com/nvartolomei)) - -#### 実験の特徴 {#experimental-features-1} - -- 設定を追加 `index_granularity_bytes` (アダプティブインデックス粒度)MergeTree\*テーブルファミリの場合。 [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([alesapin](https://github.com/alesapin)) - -#### 改善 {#improvements-1} - -- 関数の非定数および負のサイズと長さの引数のサポートが追加されました `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 左結合ではプッシュダウンから右テーブル、右結合では左テーブル、フル結合では両方のテーブルを無効にします。 このおかしくなる問題を修正に入実績もあります。 [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([イワン](https://github.com/abyss7)) -- `clickhouse-copier`:タスク設定の自動アップロード `--task-file` オプション [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([proller](https://github.com/proller)) -- 追加の誤字ハンドラに保存工場とテーブル機能の工場です。 [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([Danila Kutenin](https://github.com/danlark1)) -- サブクエリなしで複数のジョインのアスタリスクと修飾アスタリスクをサポート [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([Artem Zuikov](https://github.com/4ertus2)) -- く不カラムのエラーメッセージよりユーザーにも優しい。 [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 性能の改善 {#performance-improvements-2} - -- ASOF結合の大幅な高速化 [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([Martijn Bakker](https://github.com/Gladdy)) - -#### 下位互換性のない変更 {#backward-incompatible-changes} - -- HTTPヘッダ `Query-Id` に改名された `X-ClickHouse-Query-Id` 一貫性のために。 [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([ミハイル](https://github.com/fandyushin)) - -#### バグ修正 {#bug-fixes-4} - -- 固定された潜在的なnullポインタの逆参照 `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([proller](https://github.com/proller)) -- JOIN+ARRAY JOINによるクエリのエラーを修正 [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定掛けの開始にサーバーが辞書により他の辞書を介してデータベースエンジン=辞書で調べました。 [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([Vitaly Baranov](https://github.com/vitlibar)) -- Partially fix distributed\_product\_mode = local. It's possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There's not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([Artem Zuikov](https://github.com/4ertus2)) -- のための潜在的に間違った結果を修正 `SELECT DISTINCT` と `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定非常に珍しいデータ競合状態が起こるのを実行する際にクエリとeuのすべての関少なくとも二つから選択します。列、システム。テーブル、システム。部品、システム。マージファミリのparts\_tablesまたはテーブルと、関連するテーブルの列の変更を同時に実行する。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-2} - -- 別のホストでclickhouse-serverを実行しているときのテストの失敗を修正 [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([Vasily Nemkov](https://github.com/Enmk)) -- clickhouse-テスト:非tty環境でカラーコントロールシーケンスを無効にします。 [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([alesapin](https://github.com/alesapin)) -- clickhouse-test:任意のテストデータベースの使用を許可する(削除する `test.` それが可能な資格) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([proller](https://github.com/proller)) -- Ubsanエラーの修正 [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([Vitaly Baranov](https://github.com/vitlibar)) -- Yandex LFAllocがClickHouseに追加され、MarkCacheとUncompressedCacheデータをさまざまな方法で割り当てて、より信頼性の高いsegfaultをキャッチしました [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([Danila Kutenin](https://github.com/danlark1)) -- バックポートとチェンジログを支援するためのpython util。 [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([イワン](https://github.com/abyss7)) - -## ClickHouseリリース19.5 {#clickhouse-release-19-5} - -### ClickHouseリリース19.5.4.22、2019-05-13 {#clickhouse-release-19-5-4-22-2019-05-13} - -#### バグ修正 {#bug-fixes-5} - -- ビットマップ\*機能のクラッシュを修正 [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([アンディヤング](https://github.com/andyyzh)) -- 固定非常に珍しいデータ競合状態が起こるのを実行する際にクエリとeuのすべての関少なくとも二つから選択します。列、システム。テーブル、システム。部品、システム。マージファミリのparts\_tablesまたはテーブルと、関連するテーブルの列の変更を同時に実行する。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定エラー `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. このエラーは、LowCardinality列が主キーの一部であった場合に発生しました。 \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 保持機能の変更:行が最初の条件とn番目の条件の両方を満たす場合、最初の満足条件のみがデータ状態に追加されます。 これで、データの行を満たすすべての条件がデータの状態に追加されます。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) - -### ClickHouseリリース19.5.3.8,2019-04-18 {#clickhouse-release-19-5-3-8-2019-04-18} - -#### バグ修正 {#bug-fixes-6} - -- 設定の固定タイプ `max_partitions_per_insert_block` ブール値からUInt64へ。 [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([Mohammad Hostsein Sekhavat](https://github.com/mhsekhavat)) - -### ClickHouseリリース19.5.2.6,2019-04-15 {#clickhouse-release-19-5-2-6-2019-04-15} - -#### 新しい機能 {#new-features-4} - -- [Hyperscan](https://github.com/intel/hyperscan) 複数の正規表現マッチングが追加されました(関数 `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([Danila Kutenin](https://github.com/danlark1)) -- `multiSearchFirstPosition` 機能が追加されました。 [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) -- の実施を所定の表現フィルター配列です。 [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([イワン](https://github.com/abyss7)) -- 新しいタイプのデータを飛び指標に基づくブル(使用可能 `equal`, `in` と `like` 機能)。 [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([Nikita Vasilev](https://github.com/nikvas0)) -- 追加 `ASOF JOIN` これにより、既知の最新の値に結合するクエリを実行できます。 [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([Martijn Bakker](https://github.com/Gladdy), [Artem Zuikov](https://github.com/4ertus2)) -- 複数の書き換え `COMMA JOIN` に `CROSS JOIN`. 次にそれらを書き換える `INNER JOIN` 可能であれば。 [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 改善 {#improvement-9} - -- `topK` と `topKWeighted` 今サポートカスタム `loadFactor` (修正の問題 [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([キリル丹心](https://github.com/kirillDanshin)) -- 使用を許可する `parallel_replicas_count > 1` サンプリングされていないテーブルの場合でも(設定は単に無視されます)。 以前のバージョンでは、例外が発生しました。 [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([Alexey Elymanov](https://github.com/digitalist)) -- のサポート `CREATE OR REPLACE VIEW`. ビューの作成または単一のステートメントでの新しい定義の設定を許可します。 [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([Boris Granveaud](https://github.com/bgranvea)) -- `Buffer` テーブルエンジン `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([楊関劉](https://github.com/LiuYangkuan)) -- Zookeeperのメタデータなしで複製テーブルを開始する機能を追加 `readonly` モード。 [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([alesapin](https://github.com/alesapin)) -- Clickhouse-clientのプログレスバーのフリッカーを修正しました。 この問題は、 `FORMAT Null` ストリーミングクエ [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能を無効にするには `hyperscan` ユーザーごとにライブラリを使用して、過度かつ無制限のリソース使用量を制限します。 [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加バージョン番号でログインしてすべてのエラー. [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([proller](https://github.com/proller)) -- に制限を追加しました `multiMatch` 文字列サイズを必要とする関数 `unsigned int`. また、引数の数の制限を追加しました。 `multiSearch` 機能。 [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([Danila Kutenin](https://github.com/danlark1)) -- 改善の利用をゼロスペースおよびエラー処理にhyperscan. [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([Danila Kutenin](https://github.com/danlark1)) -- 塗りつぶし `system.graphite_detentions` テーブルの設定から `*GraphiteMergeTree` エンジンテーブル。 [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 名前変更 `trigramDistance` 機能への `ngramDistance` と追加より機能で `CaseInsensitive` と `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([Danila Kutenin](https://github.com/danlark1)) -- データスキップインデックス計算の改善。 [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([Nikita Vasilev](https://github.com/nikvas0)) -- 普通に保つ, `DEFAULT`, `MATERIALIZED` と `ALIAS` 単一のリストの列(修正の問題 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) - -#### バグ修正 {#bug-fix-26} - -- 避ける `std::terminate` メモリ割り当てに失敗した場合。 さて `std::bad_alloc` 期待どおりに例外がスローされます。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- バッファからcapnprotoの読み取りを修正します。 時にファイルなロードに成功するhttp. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ウラジスラフ](https://github.com/smirnov-vs)) -- エラーの修正 `Unknown log entry type: 0` 後に `OPTIMIZE TABLE FINAL` クエリ。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([アモスの鳥](https://github.com/amosbird)) -- 間違った引数へ `hasAny` または `hasAll` 関数はsegfaultにつながる可能性があります。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 行き詰まりが発生する恐れがあるとしながら実行 `DROP DATABASE dictionary` クエリ。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 未定義の動作を修正する `median` と `quantile` 機能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) -- ときに圧縮レベル検出を修正 `network_compression_method` 小文字で。 V19.1で壊れた。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) -- の固定無知 `UTC` 設定(修正の問題 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) -- 修正 `histogram` 関数の振る舞い `Distributed` テーブル。 [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) -- 固定tsanレポート `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- システムログ使用時の競合状態によるシャットダウン時のtsanレポートを修正。 part\_logが有効になっているときにシャットダウン時に固定された潜在的な使用後無料。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- パーツの再チェックを修正 `ReplicatedMergeTreeAlterThread` エラーの場合。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 中間集計関数状態に対する算術演算は、定数引数(サブクエリ結果など)に対して機能していませんでした。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 常にメタデータの列名を引用します。 それ以外の場合は、列という名前の表を作成することは不可能です `index` (サーバーは不正な形式のために再起動しません `ATTACH` メタデータ内のクエリ)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- でクラッシュを修正 `ALTER ... MODIFY ORDER BY` に `Distributed` テーブル。 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([Tcheason](https://github.com/TCeason)) -- Segfaultを修正する `JOIN ON` 有効にした場合 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([冬張](https://github.com/zhang2014)) -- カフカからprotobufメッセージを消費した後、余分な行を追加するとバグを修正しました。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([Vitaly Baranov](https://github.com/vitlibar)) -- のクラッシュを修正 `JOIN` nullable列とnullable列ではありません。 修正 `NULLs` 右キーで `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([Artem Zuikov](https://github.com/4ertus2)) -- セグメンテーショ `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- 固定競合状態で `SELECT` から `system.tables` テーブルが同時に名前変更または変更された場合。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 既に廃止されたデータ部分をフェッチする際のデータレースを修正。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 中に発生することができます `RENAME` MergeTree家族のテーブル。 [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能の固定細分化の欠陥 `arrayIntersect`. Segmentation faultう場合は関数と呼ばれたとの混合の定数、通常の引数になります。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang Qian](https://github.com/fancyqlx)) -- 固定読み取りから `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- でクラッシュを修正 `FULL/RIGHT JOIN` 私たちはnullable対nullableではないに参加するとき. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正 `No message received` レプリカ間のパーツの取得中の例外。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([alesapin](https://github.com/alesapin)) -- 固定 `arrayIntersect` 単一の配列のいくつかの繰り返しの値の場合に機能間違った結果。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 同時実行中の競合状態の修正 `ALTER COLUMN` クエリを生み出しうるサーバストレスとソーシャル-サポート問題の修正 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) -- 誤った結果を修正 `FULL/RIGHT JOIN` constの列を持つ。 [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([Artem Zuikov](https://github.com/4ertus2)) -- 重複を修正する `GLOBAL JOIN` アスタリスク付き。 [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正パラメータ控除で `ALTER MODIFY` 列の `CODEC` 列の型が指定されていない場合。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([alesapin](https://github.com/alesapin)) -- 機能 `cutQueryStringAndFragment()` と `queryStringAndFragment()` 今すぐ正しく動作します `URL` くれないのを返します。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([Vitaly Baranov](https://github.com/vitlibar)) -- 設定時にまれなバグを修正 `min_bytes_to_use_direct_io` これは、スレッドが列ファイル内で逆方向にシークする必要があるときに発生します。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([alesapin](https://github.com/alesapin)) -- 集計関数の誤った引数の型を修正する `LowCardinality` 引数(修正の問題 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 間違った名前の修飾を修正 `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正機能 `toISOWeek` 1970年の結果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `DROP`, `TRUNCATE` と `OPTIMIZE` 実行されたときのクエリの重複 `ON CLUSTER` のために `ReplicatedMergeTree*` テーブルの家族。 [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([alesapin](https://github.com/alesapin)) - -#### 下位互換性のない変更 {#backward-incompatible-change-8} - -- 名前変更の設定 `insert_sample_with_metadata` 設定する `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加された設定 `max_partitions_per_insert_block` (デフォルトでは値100)。 場合に挿入したブロックを含むより多くのパーティション例外がスローされます。 制限を削除する場合は0に設定します(推奨されません)。 [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- マルチサーチ機能の名称を変更 (`multiPosition` に `multiSearchAllPositions`, `multiSearch` に `multiSearchAny`, `firstMatch` に `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) - -#### 性能向上 {#performance-improvement-6} - -- 多くの針または多くの同様のbigramsとのクエリのために約5-10%の検索改善を与え、インライン化することによってvolnitsky検索を最適化します。 [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([Danila Kutenin](https://github.com/danlark1)) -- 設定時のパフォーマンス問題を修正 `use_uncompressed_cache` がゼロより大き登場したときのすべてのデータに含まれる。 [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([alesapin](https://github.com/alesapin)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-10} - -- マークキャッシュとインデックスのメモリ保護を追加します。 これによりメモリの揃い踏みのバグの場合には豆やmsanできます。 [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Cmake変数のサポートの追加 `ENABLE_PROTOBUF`, `ENABLE_PARQUET` と `ENABLE_BROTLI` これにより、上記の機能を有効/無効にすることができます(librdkafka、mysqlなどでも同じことができます)。 [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([Silviu Caragea](https://github.com/silviucpp)) -- 追加ダイレクトに刷版を出力するプロセス一覧表示およびstacktracesのすべてのスレッドの場合一部のクエリで吊るされているだけなので後の試験です。 [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([alesapin](https://github.com/alesapin)) -- 再試行の追加 `Connection loss` エラーで `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([alesapin](https://github.com/alesapin)) -- Freebsdのビルドとスレッドのサニタイザを使ったビルドをパッケージャスクリプトに追加します。 [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([alesapin](https://github.com/alesapin)) -- 現在ユーザーのためのパスワードユーザー `'default'` 取付けの間。 [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([proller](https://github.com/proller)) -- の警告を抑制する `rdkafka` ライブラリ。 [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Sslなしで構築する能力を許可します。 [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([proller](https://github.com/proller)) -- カスタムユーザーからclickhouse-serverイメージを起動する方法を追加します。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- Contrib boostを1.69にアップグレードします。 [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([proller](https://github.com/proller)) -- 使用を無効にする `mremap` きめにスレッドに指消毒剤. 驚いたことに、TSanは傍受しません `mremap` (それは傍受しますが `mmap`, `munmap`)それは偽陽性につながります. ステートフルテストで修正TSanレポート。 [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加試験にチェックを使用形式スキーマによhttpインターフェース。 [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([Vitaly Baranov](https://github.com/vitlibar)) - -## クリックハウスリリース19.4 {#clickhouse-release-19-4} - -### ClickHouseリリース19.4.4.33,2019-04-17 {#clickhouse-release-19-4-4-33-2019-04-17} - -#### バグ修正 {#bug-fixes-7} - -- 避ける `std::terminate` メモリ割り当てに失敗した場合。 さて `std::bad_alloc` 期待どおりに例外がスローされます。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- バッファからcapnprotoの読み取りを修正します。 時にファイルなロードに成功するhttp. [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([ウラジスラフ](https://github.com/smirnov-vs)) -- エラーの修正 `Unknown log entry type: 0` 後に `OPTIMIZE TABLE FINAL` クエリ。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([アモスの鳥](https://github.com/amosbird)) -- 間違った引数へ `hasAny` または `hasAll` 関数はsegfaultにつながる可能性があります。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 行き詰まりが発生する恐れがあるとしながら実行 `DROP DATABASE dictionary` クエリ。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 未定義の動作を修正する `median` と `quantile` 機能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) -- ときに圧縮レベル検出を修正 `network_compression_method` 小文字で。 V19.1で壊れた。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) -- の固定無知 `UTC` 設定(修正の問題 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) -- 修正 `histogram` 関数の振る舞い `Distributed` テーブル。 [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) -- 固定tsanレポート `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- システムログ使用時の競合状態によるシャットダウン時のtsanレポートを修正。 part\_logが有効になっているときにシャットダウン時に固定された潜在的な使用後無料。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- パーツの再チェックを修正 `ReplicatedMergeTreeAlterThread` エラーの場合。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 中間集計関数状態に対する算術演算は、定数引数(サブクエリ結果など)に対して機能していませんでした。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 常にメタデータの列名を引用します。 それ以外の場合は、列という名前の表を作成することは不可能です `index` (サーバーは不正な形式のために再起動しません `ATTACH` メタデータ内のクエリ)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- でクラッシュを修正 `ALTER ... MODIFY ORDER BY` に `Distributed` テーブル。 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([Tcheason](https://github.com/TCeason)) -- Segfaultを修正する `JOIN ON` 有効にした場合 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([冬張](https://github.com/zhang2014)) -- カフカからprotobufメッセージを消費した後、余分な行を追加するとバグを修正しました。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([Vitaly Baranov](https://github.com/vitlibar)) -- セグメンテーショ `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- 固定競合状態で `SELECT` から `system.tables` テーブルが同時に名前変更または変更された場合。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 既に廃止されたデータ部分をフェッチする際のデータレースを修正。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 中に発生することができます `RENAME` MergeTree家族のテーブル。 [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能の固定細分化の欠陥 `arrayIntersect`. Segmentation faultう場合は関数と呼ばれたとの混合の定数、通常の引数になります。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([Lixiang Qian](https://github.com/fancyqlx)) -- 固定読み取りから `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 修正 `No message received` レプリカ間のパーツの取得中の例外。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([alesapin](https://github.com/alesapin)) -- 固定 `arrayIntersect` 単一の配列のいくつかの繰り返しの値の場合に機能間違った結果。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 同時実行中の競合状態の修正 `ALTER COLUMN` クエリを生み出しうるサーバストレスとソーシャル-サポート問題の修正 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修正パラメータ控除で `ALTER MODIFY` 列の `CODEC` 列の型が指定されていない場合。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([alesapin](https://github.com/alesapin)) -- 機能 `cutQueryStringAndFragment()` と `queryStringAndFragment()` 今すぐ正しく動作します `URL` くれないのを返します。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([Vitaly Baranov](https://github.com/vitlibar)) -- 設定時にまれなバグを修正 `min_bytes_to_use_direct_io` これは、スレッドが列ファイル内で逆方向にシークする必要があるときに発生します。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([alesapin](https://github.com/alesapin)) -- 集計関数の誤った引数の型を修正する `LowCardinality` 引数(修正の問題 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 修正機能 `toISOWeek` 1970年の結果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `DROP`, `TRUNCATE` と `OPTIMIZE` 実行されたときのクエリの重複 `ON CLUSTER` のために `ReplicatedMergeTree*` テーブルの家族。 [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([alesapin](https://github.com/alesapin)) - -#### 改善 {#improvements-2} - -- 普通に保つ, `DEFAULT`, `MATERIALIZED` と `ALIAS` 単一のリストの列(修正の問題 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) - -### ClickHouseリリース19.4.3.11,2019-04-02 {#clickhouse-release-19-4-3-11-2019-04-02} - -#### バグ修正 {#bug-fixes-8} - -- でクラッシュを修正 `FULL/RIGHT JOIN` 私たちはnullable対nullableではないに参加するとき. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- セグメンテーショ `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-11} - -- カスタムユーザーからclickhouse-serverイメージを起動する方法を追加します。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### クリックハウスリリース19.4.2.7,2019-03-30 {#clickhouse-release-19-4-2-7-2019-03-30} - -#### バグ修正 {#bug-fixes-9} - -- 固定読み取りから `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -### クリックハウスリリース19.4.1.3,2019-03-19 {#clickhouse-release-19-4-1-3-2019-03-19} - -#### バグ修正 {#bug-fixes-10} - -- 両方を含む固定リモートクエリ `LIMIT BY` と `LIMIT`. 以前は、 `LIMIT BY` と `LIMIT` リモートクエリに使用された, `LIMIT` 前に起こる可能性が `LIMIT BY` るもの濾過します。 [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([Constantin S.Pan](https://github.com/kvap)) - -### ClickHouseリリース19.4.0.49,2019-03-09 {#clickhouse-release-19-4-0-49-2019-03-09} - -#### 新しい機能 {#new-features-5} - -- 追加の完全なサポート `Protobuf` フォーマット(入出力、ネストされたデータ構造)。 [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([Vitaly Baranov](https://github.com/vitlibar)) -- ビットマップを追加しました。 [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([アンディヤング](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([Vitaly Baranov](https://github.com/vitlibar)) -- 寄木細工の形式のサポート。 [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([proller](https://github.com/proller)) -- ファジィ文字列の比較のために、n-gram距離が追加されました。 これは、r言語のq-gramメトリックに似ています。 [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([Danila Kutenin](https://github.com/danlark1)) -- 結合ルールのための黒鉛rollupから専用の凝集-保持。 [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 追加 `max_execution_speed` と `max_execution_speed_bytes` リソースの使用を制限する。 追加 `min_execution_speed_bytes` 補完する設定 `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([冬張](https://github.com/zhang2014)) -- 機能実装 `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([alexey-milovidov](https://github.com/alexey-milovidov), [kzon](https://github.com/kzon)) -- 機能追加 `arrayEnumerateDenseRanked` と `arrayEnumerateUniqRanked` (それはのようなものだ `arrayEnumerateUniq` しかし、多次元配列の内部を調べるために配列の深さを微調整することができます)。 [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([proller](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([Artem Zuikov](https://github.com/4ertus2)) - -#### バグ修正 {#bug-fixes-11} - -- このリリースも含む全てのバグ修正から19.3 19.1. -- データスキップインデックスのバグを修正:挿入後の顆粒の順序が間違っていた。 [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([Nikita Vasilev](https://github.com/nikvas0)) -- 固定 `set` インデックス `Nullable` と `LowCardinality` 列。 その前に, `set` 索引とともに `Nullable` または `LowCardinality` 列ledにエラー `Data type must be deserialized with multiple streams` 選択中。 [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 完全にupdate\_timeを正しく設定する `executable` 辞書の更新。 [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([Tema Novikov](https://github.com/temoon)) -- 19.3で壊れたプログレスバーを修正。 [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([フィリモノフ](https://github.com/filimonov)) -- 特定のケースで、メモリ領域をシュリンクしたときのmemorytrackerの値の不一致を修正しました。 [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ThreadPoolでの未定義の動作を修正しました。 [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- メッセージで非常にまれなクラッシュを修正 `mutex lock failed: Invalid argument` これは、MergeTreeテーブルがSELECTと同時に削除されたときに発生する可能性があります。 [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([Alex Zatelepin](https://github.com/ztlpn)) -- ODBCドライバとの互換性 `LowCardinality` データ型。 [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([proller](https://github.com/proller)) -- FreeBSD:Fixup for `AIOcontextPool: Found io_event with unknown id 0` エラー。 [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([urgordeadbeef](https://github.com/urgordeadbeef)) -- `system.part_log` テーブルは構成に関係なく作成されました。 [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 未定義の動作を修正する `dictIsIn` キャッシュ辞書の関数。 [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([alesapin](https://github.com/alesapin)) -- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([Alex Zatelepin](https://github.com/ztlpn)) -- デフォルトでcompile\_expressionsを無効にします。 `llvm` contribはそれをとのテストし、 `clang` と `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([alesapin](https://github.com/alesapin)) -- 防ぐ `std::terminate` とき `invalidate_query` のために `clickhouse` 外部辞書ソースが間違った結果セット(空または複数の行または複数の列)を返しました。 ときに問題を修正しました `invalidate_query` にかかわらず、五秒ごとに実行されました `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ときにデッドロックを避ける `invalidate_query` 辞書のために `clickhouse` ソースが関与していた `system.dictionaries` テーブルまたは `Dictionaries` データベース(まれなケース)。 [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クロスのための修正は、空のwhereに参加します。 [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([Artem Zuikov](https://github.com/4ertus2)) -- 機能の固定segfault “replicate” 定数引数が渡されるとき。 [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定ラムダ機能と述語オプティマイザ. [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([冬張](https://github.com/zhang2014)) -- 複数のフィックスを結合します。 [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 改善 {#improvements-3} - -- 支援のエイリアスに参加でき課右テーブル列あります。 [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([Artem Zuikov](https://github.com/4ertus2)) -- 複数の結合の結果は、サブセレクトで使用される正しい結果名が必要です。 平置き換えエイリアスとソース名ます。 [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([Artem Zuikov](https://github.com/4ertus2)) -- 結合文のプッシュダウンロジックを改善します。 [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([イワン](https://github.com/abyss7)) - -#### 性能の改善 {#performance-improvements-3} - -- 改善されたヒューリスティック “move to PREWHERE” 最適化。 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 8ビットおよび16ビットのキーにhashtableのapiを使用する適切なルックアップテーブルを使用します。 [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([アモスの鳥](https://github.com/amosbird)) -- 文字列比較のパフォーマンスの向上。 [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 分散ddlタスクを処理するメインループが遅くならないように、別のスレッドで分散ddlキューをクリーンアップします。 [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([Alex Zatelepin](https://github.com/ztlpn)) -- とき `min_bytes_to_use_direct_io` 読み込むデータサイズが圧縮されたブロックのサイズによって過小評価されることがあるため、すべてのファイルがO\_DIRECTモードで開かれたわけでは [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-12} - -- Clang-9のサポートを追加 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 間違った修正 `__asm__` 指示(再び) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([Konstantin Podshumok](https://github.com/podshumok)) -- 設定を指定する機能を追加する `clickhouse-performance-test` コマンドラインから。 [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([alesapin](https://github.com/alesapin)) -- 統合テストに辞書テストを追加します。 [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([alesapin](https://github.com/alesapin)) -- 追加のクエリからのベンチマークのサイトを自動化性能試験までを実施。 [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `xxhash.h` それは実装の詳細であり、そのシンボルは次の名前空間であるため、外部lz4には存在しません `XXH_NAMESPACE` マクロ Lz4が外部の場合、xxHashも外部になければならず、扶養家族はそれにリンクする必要があります。 [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([Orivej Desh](https://github.com/orivej)) -- 次の場合にケースを修正 `quantileTiming` 集約関数は、負の引数または浮動小数点引数で呼び出すことができます(これは、未定義の動作消滅器でfuzzテストを修正します)。 [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- スペルエラー訂正。 [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2unit description in lists](https://github.com/sdk2)) -- Macでのコンパイルの修正。 [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([Vitaly Baranov](https://github.com/vitlibar)) -- FreeBSDおよび様々な異常なビルド設定のためのビルドの修正。 [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([proller](https://github.com/proller)) - -## クリックハウスリリース19.3 {#clickhouse-release-19-3} - -### ClickHouseリリース19.3.9.1,2019-04-02 {#clickhouse-release-19-3-9-1-2019-04-02} - -#### バグ修正 {#bug-fixes-12} - -- でクラッシュを修正 `FULL/RIGHT JOIN` 私たちはnullable対nullableではないに参加するとき. [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- セグメンテーショ `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- 固定読み取りから `Array(LowCardinality)` 列に空の配列の長いシーケンスが含まれている場合はまれです。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-13} - -- カスタムユーザーからclickhouse-serverイメージを起動する方法を追加する [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### ClickHouseリリース19.3.7,2019-03-12 {#clickhouse-release-19-3-7-2019-03-12} - -#### バグ修正 {#bug-fixes-13} - -- #3920で修正されたエラー。 このエラ `Unknown codec family code`, `Cannot seek through file` とsegfaults。 このバグはバージョン19.1で最初に登場し、19.1.10および19.3.6までのバージョンに存在します。 [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.3.6,2019-03-02 {#clickhouse-release-19-3-6-2019-03-02} - -#### バグ修正 {#bug-fixes-14} - -- スレッドプールに1000を超えるスレッドがある場合, `std::terminate` が起こるためのスレッド終了します。 [Azat Khuzhin](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 今では作成することが可能です `ReplicatedMergeTree*` コメントとデフォルトのない列のコメントを持つ表。 また、コーデックの比較を修正。 [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([alesapin](https://github.com/alesapin)) -- 配列またはタプルとの結合にクラッシュを修正しました。 [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([Artem Zuikov](https://github.com/4ertus2)) -- メッセージとclickhouse-コピー機で固定クラッシュ `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定電話を切るサーバー停止の場合は分散ddlsを使用した。 [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([Alex Zatelepin](https://github.com/ztlpn)) -- 10より大きい列のテキスト形式の解析に関するエラーメッセージで、誤った列番号が出力されました。 [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-3} - -- AVXを有効にした固定ビルド。 [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- コンパイルされるカーネルの代わりに、既知のバージョンに基づいて拡張会計とio会計を有効にします。 [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([nvartolomei](https://github.com/nvartolomei)) -- Core\_dumpの設定をスキップできるようにします。size\_limit、制限セットが失敗した場合はスローの代わりに警告します。 [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([proller](https://github.com/proller)) -- 削除された `inline` タグの `void readBinary(...)` で `Field.cpp`. また、冗長マージ `namespace DB` ブロック。 [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([hcz](https://github.com/hczhcz)) - -### クリックハウスリリース19.3.5,2019-02-21 {#clickhouse-release-19-3-5-2019-02-21} - -#### バグ修正 {#bug-fixes-15} - -- 大規模なhttp挿入クエリ処理のバグを修正しました。 [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([alesapin](https://github.com/alesapin)) -- の間違った実装による古いバージョンとの固定後方の非互換性 `send_logs_level` 設定。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テーブル機能の後方互換性を修正しました `remote` 列のコメントと共に導入。 [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.3.4,2019-02-16 {#clickhouse-release-19-3-4-2019-02-16} - -#### 改善 {#improvements-4} - -- テーブル-インデックスをさせていただく事があり占めのメモリの制限を行うと `ATTACH TABLE` クエリ。 デタッチされた後にテーブルを添付できない可能性を回避しました。 [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ZooKeeperから受け取った最大文字列と配列サイズの上限をわずかに上げました。 でも引き続き増加しのサイズ `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` 飼育係に。 [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- すでにキューに多数のノードがある場合でも、放棄されたレプリカを修復できます。 [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 必要な引数を一つ追加する `SET` インデックス(最大保存行数)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([Nikita Vasilev](https://github.com/nikvas0)) - -#### バグ修正 {#bug-fixes-16} - -- 固定 `WITH ROLLUP` 単一のグループの結果 `LowCardinality` キー。 [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定バグの設定指数を落と顆粒が含まれている場合以 `max_rows` 行)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([Nikita Vasilev](https://github.com/nikvas0)) -- 多くのfreebsdビルドの修正。 [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([proller](https://github.com/proller)) -- 固定エイリアス置換にクエリサブクエリを含む同じエイリアス(発行 [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([Artem Zuikov](https://github.com/4ertus2)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-4} - -- 実行する機能を追加 `clickhouse-server` dockerイメージのステートレステストの場合。 [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([Vasily Nemkov](https://github.com/Enmk)) - -### クリックハウスリリース19.3.3,2019-02-13 {#clickhouse-release-19-3-3-2019-02-13} - -#### 新しい機能 {#new-features-6} - -- を追加しました `KILL MUTATION` いくつかの理由である突然変異を除去することを可能にする声明。 追加 `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` フィールドに `system.mutations` テーブルやtroubleshooting. [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([Alex Zatelepin](https://github.com/ztlpn)) -- 集計関数の追加 `entropy` シャノンのエントロピーを計算します [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) -- クエリを送信する機能を追加 `INSERT INTO tbl VALUES (....` 分割せずにサーバーに `query` と `data` パーツだ [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([alesapin](https://github.com/alesapin)) -- の一般的な実装 `arrayWithConstant` 機能が追加されました。 [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 実装 `NOT BETWEEN` 比較演算子です。 [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([ドミトリー-ナウモフ](https://github.com/nezed)) -- 実装 `sumMapFiltered` 値が合計されるキーの数を制限できるようにするには `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- のサポートを追加 `Nullable` タイプ `mysql` テーブル機能。 [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) -- 任意の定数式のサポート `LIMIT` 句。 [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) -- 追加 `topKWeighted` (符号なし整数)重みを持つ追加の引数を取る集約関数。 [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([アンドリュー golman](https://github.com/andrewgolman)) -- `StorageJoin` 今サポート `join_any_take_last_row` 同じキーの既存の値を上書きできるようにする設定。 [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([アモスの鳥](https://github.com/amosbird) -- 機能追加 `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([Vitaly Baranov](https://github.com/vitlibar)) -- 追加 `RowBinaryWithNamesAndTypes` フォーマット。 [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([Oleg V.Kozlyuk](https://github.com/DarkWanderer)) -- 追加 `IPv4` と `IPv6` データ型。 より効果的な実装 `IPv*` 機能。 [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([Vasily Nemkov](https://github.com/Enmk)) -- 機能追加 `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([Vitaly Baranov](https://github.com/vitlibar)) -- 追加 `Protobuf` 出力形式。 [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([Vitaly Baranov](https://github.com/vitlibar)) -- 追加brotli支援のためのhttpインタフェースデータインポート(挿入します). [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([ミハイル](https://github.com/fandyushin)) -- ユーザーが関数名にタイプミスをしたり、コマンドラインクライアン [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([Danila Kutenin](https://github.com/danlark1)) -- 追加 `Query-Id` サーバーのHTTP応答ヘッダーへ。 [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([ミハイル](https://github.com/fandyushin)) - -#### 実験の特徴 {#experimental-features-2} - -- 追加 `minmax` と `set` データ飛指標MergeTreeテーブルエンジンです。 [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) -- の追加された変換 `CROSS JOIN` に `INNER JOIN` 可能であれば。 [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([Artem Zuikov](https://github.com/4ertus2)) - -#### バグ修正 {#bug-fixes-17} - -- 固定 `Not found column` 重複する列の場合 `JOIN ON` セクション。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) -- 作る `START REPLICATED SENDS` コマンド開始レプリケート送信。 [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) -- 固定集計関数の実行 `Array(LowCardinality)` 引数。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 修正された間違った行動 `INSERT ... SELECT ... FROM file(...)` クエリとファイルは `CSVWithNames` または `TSVWIthNames` フォーマットと最初のデータ行がありません。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 辞書が利用できない場合辞書リロードに固定クラッシュ。 このバグは19.1.6で登場しました。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) -- 固定 `ALL JOIN` 右のテーブルに重複しています。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定細分化の欠陥との `use_uncompressed_cache=1` そして、間違った非圧縮サイズの例外。 このバグは19.1.6で登場しました。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([alesapin](https://github.com/alesapin)) -- 固定 `compile_expressions` 大きな(int16以上の)日付の比較を伴うバグ。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([alesapin](https://github.com/alesapin)) -- テーブル関数から選択する固定無限ループ `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 述語の最適化を一時的に無効にする `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([冬張](https://github.com/zhang2014)) -- 固定 `Illegal instruction` 古いCpuでbase64関数を使用するときにエラーが発生しました。 このエラーは、ClickHouseがgcc-8でコンパイルされた場合にのみ再現されています。 [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定 `No message received` エラーが発生との交流PostgreSQL ODBCドライバーを通してTLS接続します。 MySQLのODBCドライバを使用する場合にも、segfaultを修正します。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定間違った結果 `Date` と `DateTime` 引数は、条件付き演算子(関数)の分岐で使用されます `if`). 機能のための追加された汎用ケース `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クリックハウス辞書は今内ロード `clickhouse` プロセス。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定デッドロック時 `SELECT` テーブルから `File` エンジンは後に再試行されました `No such file or directory` エラー。 [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定レース条件から選択すると `system.tables` を与える `table doesn't exist` エラー。 [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `clickhouse-client` でsegfault出口がデータを読み込むためのコマンドラインの提案いたインタラクティブモードになります。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 変異の実行が含むバグを修正しました `IN` 演算子は、誤った結果を生成していた。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) -- 固定エラー:データベースがある場合 `Dictionary` エンジン、サーバーの起動時に強制的にロードされるすべての辞書、およびlocalhostからのClickHouseソースを持つ辞書がある場合、辞書はロードできません。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定エラー時のシステムログのようにして作成時サーバをシャットダウンしました。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 正しい型を正しく返し、適切にロックを処理する `joinGet` 機能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([アモスの鳥](https://github.com/amosbird)) -- 追加 `sumMapWithOverflow` 機能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- 固定segfaultと `allow_experimental_multiple_joins_emulation`. [52de2c](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([Artem Zuikov](https://github.com/4ertus2)) -- 間違ったとのバグを修正 `Date` と `DateTime` 比較。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) -- 未定義の動作の下で固定ファズテストサニタイザ:追加されたパラメータの型チェック `quantile*Weighted` 機能の系列。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 古いデータパーツの削除が失敗することがある稀な競合状態を修正しました `File not found` エラー。 [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- /etc/clickhouse-server/configが見つからないインストールパッケージを修正xmlだ [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-5} - -- Debianパッケージ:設定に従って/etc/clickhouse-server/preprocessedリンクを修正します。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) -- FreeBSDのための様々なビルドの修正. [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([proller](https://github.com/proller)) -- Perftestでテーブルを作成、入力、削除する機能を追加しました。 [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([alesapin](https://github.com/alesapin)) -- 重複をチェックするスクリプトを追加しました。 [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- パフォーマンステス [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([alesapin](https://github.com/alesapin)) -- パッケージはデバッグシンボルとを示唆を設置することができます。 [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- パフォーマンステストのリファクタリング。 より良いロギングと信号の処理。 [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([alesapin](https://github.com/alesapin)) -- 匿名のyandexにドキュメントを追加しました。メトリカのデータセット。 [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([alesapin](https://github.com/alesapin)) -- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([Alex Zatelepin](https://github.com/ztlpn)) -- 追加docsつのデータセットにs3. [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([alesapin](https://github.com/alesapin)) -- プル要求の説明からchangelogを作成するスクリプトを追加しました。 [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([KochetovNicolai](https://github.com/KochetovNicolai)) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Clickhouseの人形モジュールを追加しました。 [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([Maxim Fedotov](https://github.com/MaxFedotov)) -- 文書化されていない関数のグループのドキュメントを追加しました。 [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([冬張](https://github.com/zhang2014)) -- ARMビルドの修正。 [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([proller](https://github.com/proller)) ([proller](https://github.com/proller)) -- 辞書テストを実行できるようになりました `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([proller](https://github.com/proller)) -- さて `/etc/ssl` はデフォルトとして使用されると、ディレクトリにSSL証明書 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 開始時にsseおよびavx命令の確認を追加しました。 [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([Igr](https://github.com/igron99)) -- Initスクリプトは開始までサーバを待機します。 [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([proller](https://github.com/proller)) - -#### 下位互換性のない変更 {#backward-incompatible-changes-1} - -- 削除 `allow_experimental_low_cardinality_type` 設定。 `LowCardinality` デー [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 削減マークのキャッシュされた、圧縮解除されたキャッシュサイズに従ってメインメニューを開きます。 [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([ロパチンコンスタンチン](https://github.com/k-lopatin) -- キーワードを追加 `INDEX` で `CREATE TABLE` クエリ。 名前のある列 `index` バッククォートまたは二重引用符で囲む必要があります: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([Nikita Vasilev](https://github.com/nikvas0)) -- `sumMap` を推進する結果の型の代わりにオーバーフロー. 古いの `sumMap` 動作は、以下を使用して取得できます `sumMapWithOverflow` 機能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) - -#### 性能の改善 {#performance-improvements-4} - -- `std::sort` に置き換え `pdqsort` なしのクエリの場合 `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([Evgenii Pravda](https://github.com/kvinty)) -- 現在サーバーの再利用にスレッドからグローバルスレッドプールがあります。 この影響性能の一部のコーナー。 [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 改善 {#improvements-5} - -- FreeBSDのAIOサポートを実装しました。 [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([urgordeadbeef](https://github.com/urgordeadbeef)) -- `SELECT * FROM a JOIN b USING a, b` 今すぐ戻る `a` と `b` 左側のテーブルからの列のみ。 [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([Artem Zuikov](https://github.com/4ertus2)) -- 許可 `-C` オプションクライアントとして `-c` オプション。 [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([syominsergey](https://github.com/syominsergey)) -- Nowオプション `--password` 使用せずに値を必要とパスワードからstdin. [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([BSD\_Conqueror](https://github.com/bsd-conqueror)) -- エスケープされていないメタ文字を含む文字列リテラルで強調表示するようにした `LIKE` 式または正規表現。 [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クライアントソケッ [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([nvartolomei](https://github.com/nvartolomei)) -- 現在サーバーの進捗報告書くクライアント接続の待機を開始。 [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([イワン](https://github.com/abyss7)) -- 最適化クエリの理由がわずかに良いメッセージ `optimize_throw_if_noop` 設定は有効です。 [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- のサポートを追加 `--version` clickhouseサーバーのための選択。 [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([ロパチンコンスタンチン](https://github.com/k-lopatin)) -- 追加 `--help/-h` オプションへ `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([ユーリーバラノフ](https://github.com/yurriy)) -- るためのサポートを追加しましたスカラサブクエリと集計関数の状態ます。 [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 向上サーバー停止時間の変更を待ってます。 [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Replicated\_can\_become\_leader設定に関する情報をsystemに追加しました。レトロギングの場合、レプリカなくなります。 [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([Alex Zatelepin](https://github.com/ztlpn)) - -## クリックハウスリリース19.1 {#clickhouse-release-19-1} - -### ClickHouseリリース19.1.14、2019-03-14 {#clickhouse-release-19-1-14-2019-03-14} - -- 固定エラー `Column ... queried more than once` それは起こるかもしれません設定 `asterisk_left_columns_only` 使用する場合は1に設定します `GLOBAL JOIN` と `SELECT *` (まれなケース)。 この問題は19.3以降には存在しません。 [6bac7d8d](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([Artem Zuikov](https://github.com/4ertus2)) - -### クリックハウスリリース19.1.13,2019-03-12 {#clickhouse-release-19-1-13-2019-03-12} - -このリリースには、19.3.7とまったく同じパッチが含まれています。 - -### ClickHouseリリース19.1.10、2019-03-03 {#clickhouse-release-19-1-10-2019-03-03} - -このリリースには、19.3.6とまったく同じパッチが含まれています。 - -## クリックハウスリリース19.1 {#clickhouse-release-19-1-1} - -### ClickHouseリリース19.1.9,2019-02-21 {#clickhouse-release-19-1-9-2019-02-21} - -#### バグ修正 {#bug-fixes-18} - -- の間違った実装による古いバージョンとの固定後方の非互換性 `send_logs_level` 設定。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テーブル機能の後方互換性を修正しました `remote` 列のコメントと共に導入。 [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### クリックハウスリリース19.1.8,2019-02-16 {#clickhouse-release-19-1-8-2019-02-16} - -#### バグ修正 {#bug-fixes-19} - -- /etc/clickhouse-server/configが見つからないインストールパッケージを修正xmlだ [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) - -## クリックハウスリリース19.1 {#clickhouse-release-19-1-2} - -### クリックハウスリリース19.1.7,2019-02-15 {#clickhouse-release-19-1-7-2019-02-15} - -#### バグ修正 {#bug-fixes-20} - -- 正しい型を正しく返し、適切にロックを処理する `joinGet` 機能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([アモスの鳥](https://github.com/amosbird)) -- 固定エラー時のシステムログのようにして作成時サーバをシャットダウンしました。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定エラー:データベースがある場合 `Dictionary` エンジン、サーバーの起動時に強制的にロードされるすべての辞書、およびlocalhostからのClickHouseソースを持つ辞書がある場合、辞書はロードできません。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 変異の実行が含むバグを修正しました `IN` 演算子は、誤った結果を生成していた。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) -- `clickhouse-client` でsegfault出口がデータを読み込むためのコマンドラインの提案いたインタラクティブモードになります。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定レース条件から選択すると `system.tables` を与える `table doesn't exist` エラー。 [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定デッドロック時 `SELECT` テーブルから `File` エンジンは後に再試行されました `No such file or directory` エラー。 [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定問題:地方clickhouse辞書読み込まれtcpが負荷以内です。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定 `No message received` エラーが発生との交流PostgreSQL ODBCドライバーを通してTLS接続します。 MySQLのODBCドライバを使用する場合にも、segfaultを修正します。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 述語の最適化を一時的に無効にする `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([冬張](https://github.com/zhang2014)) -- テーブル関数から選択する固定無限ループ `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定 `compile_expressions` 大きな(int16以上の)日付の比較を伴うバグ。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([alesapin](https://github.com/alesapin)) -- 固定細分化の欠陥との `uncompressed_cache=1` そして、間違った非圧縮サイズの例外。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([alesapin](https://github.com/alesapin)) -- 固定 `ALL JOIN` 右のテーブルに重複しています。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正された間違った行動 `INSERT ... SELECT ... FROM file(...)` クエリとファイルは `CSVWithNames` または `TSVWIthNames` フォーマットと最初のデータ行がありません。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定集計関数の実行 `Array(LowCardinality)` 引数。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Debianパッケージ:設定に従って/etc/clickhouse-server/preprocessedリンクを修正します。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) -- 未定義の動作の下で固定ファズテストサニタイザ:追加されたパラメータの型チェック `quantile*Weighted` 機能の系列。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 作る `START REPLICATED SENDS` コマンド開始レプリケート送信。 [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([nvartolomei](https://github.com/nvartolomei)) -- 固定 `Not found column` セクションの結合で重複する列の場合。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) -- さて `/etc/ssl` はデフォルトとして使用されると、ディレクトリにSSL証明書 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 辞書が利用できない場合辞書リロードに固定クラッシュ。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) -- 間違ったとのバグを修正 `Date` と `DateTime` 比較。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) -- 固定間違った結果 `Date` と `DateTime` 引数は、条件付き演算子(関数)の分岐で使用されます `if`). 機能のための追加された汎用ケース `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -### ClickHouseリリース19.1.6,2019-01-24 {#clickhouse-release-19-1-6-2019-01-24} - -#### 新しい機能 {#new-features-7} - -- 表の列ごとのカスタム圧縮コーデック。 [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([alesapin](https://github.com/alesapin), [冬張](https://github.com/zhang2014), [アナトリー](https://github.com/Sindbag)) -- 圧縮コーデックを追加 `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([alesapin](https://github.com/alesapin)) -- 許可する `ALTER` 圧縮コーデック。 [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([alesapin](https://github.com/alesapin)) -- 機能追加 `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` SQL標準の互換性のために。 [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([Ivan Blinkov](https://github.com/blinkov)) -- 書き込みのサポート `HDFS` テーブルと `hdfs` テーブル機能。 [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([alesapin](https://github.com/alesapin)) -- 大きな干し草の山から複数の定数文字列を検索する機能を追加しました: `multiPosition`, `multiSearch` ,`firstMatch` また `-UTF8`, `-CaseInsensitive`、と `-CaseInsensitiveUTF8` バリアント。 [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([Danila Kutenin](https://github.com/danlark1)) -- 未使用の破片の切り取ること `SELECT` シャーディングキーによるクエリフィ `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([Gleb Kanterov](https://github.com/kanterov), [イワン](https://github.com/abyss7)) -- 許可 `Kafka` エンジンを無視するいくつかの構文解析誤りのブロックです。 [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([イワン](https://github.com/abyss7)) -- のサポートを追加 `CatBoost` マルチクラスモデルの評価。 機能 `modelEvaluate` マルチクラスモデルのクラスごとの生の予測を持つタプルを返します。 `libcatboostmodel.so` で構築する必要があります [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 機能追加 `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([Boris Granveaud](https://github.com/bgranvea)) -- ハッシュ機能を追加 `xxHash64` と `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([フィリモノフ](https://github.com/filimonov)) -- 追加 `gccMurmurHash` 同じハッシュシードを使用するハッシュ関数(GCC風味のつぶやきハッシュ) [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([sundyli](https://github.com/sundy-li)) -- ハッシュ機能を追加 `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([shangshujie365](https://github.com/shangshujie365)) -- テーブル機能を追加 `remoteSecure`. 機能として動作 `remote` しかし、安全な接続を使用しています。 [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([proller](https://github.com/proller)) - -#### 実験の特徴 {#experimental-features-3} - -- 複数の結合エミュレーションを追加 (`allow_experimental_multiple_joins_emulation` 設定)。 [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([Artem Zuikov](https://github.com/4ertus2)) - -#### バグ修正 {#bug-fixes-21} - -- 作る `compiled_expression_cache_size` 設定により限定のデフォルトの低メモリを消費する。 [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([alesapin](https://github.com/alesapin)) -- レプリケートされたテーブルの変更を実行するスレッドと、zookeeperから設定を更新するスレッドのバグを修正しました。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([Alex Zatelepin](https://github.com/ztlpn)) -- 分散alterタスクを実行する際の競合状態を修正しました。 レース条件以上のレプリカを実行しようとしたところ、すべてのレプリカのものを除く失敗との飼育係エラーになります。 [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([Alex Zatelepin](https://github.com/ztlpn)) -- 次の場合にバグを修正する `from_zk` config要素はないのにリフレッシュした後、求め飼育係わる。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([Alex Zatelepin](https://github.com/ztlpn)) -- IPv4サブネッ [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([alesapin](https://github.com/alesapin)) -- 固定クラッシュ (`std::terminate`)まれに、リソースが枯渇したために新しいスレッドを作成できない場合。 [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ときにバグを修正 `remote` 間違った制限がinに使用されたときのテーブル関数の実行 `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([alesapin](https://github.com/alesapin)) -- Netlinkソケットのリークを修正します。 これらのソケットはプール内に置かれ、削除されることはなく、現在のすべてのソケットが使用されているときに、新しいソケットが新しいスレッド [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([Alex Zatelepin](https://github.com/ztlpn)) -- 閉じるとバグを修正 `/proc/self/fd` すべてのfdsが読み込まれたディレクトリ `/proc` フォーク後 `odbc-bridge` サブプロセス。 [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([alesapin](https://github.com/alesapin)) -- 主キーの使用文字列の場合にはuint単調変換するための固定文字列。 [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([冬張](https://github.com/zhang2014)) -- 整数変換関数の単調性の計算におけるエラーを修正しました。 [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定segfaultで `arrayEnumerateUniq`, `arrayEnumerateDense` いくつかの無効な引数の場合の関数。 [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- StorageMergeでUBを修正. [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([アモスの鳥](https://github.com/amosbird)) -- 機能の固定segfault `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定エラー:機能 `round`, `floor`, `trunc`, `ceil` を返すことが偽の結果が実行される整数の引数と大きな負のです。 [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- によって誘導されるバグを修正 ‘kill query sync’ これはコアダンプにつながります。 [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([muVulDeePecker](https://github.com/fancyqlx)) -- のを修正した。長の遅延の後に空の複製します。 [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([alesapin](https://github.com/alesapin)) -- テーブルに挿入する場合の過度のメモリ使用量を修正しました `LowCardinality` 主キー。 [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 固定 `LowCardinality` のためのシリアル化 `Native` 空の配列の場合の形式。 [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 単一のlowcardinality数値列によってdistinctを使用している間、不正な結果を修正しました。 [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 低カーディナリティキーを使用した特殊な集計を修正しました(以下の場合 `compile` 設定が有効になっています)。 [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 固定ユーザとパスワードを転送のための複製のテーブルのクエリ. [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([alesapin](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) -- 固定非常に珍しい競合状態とされるようにすることが一覧表の辞書データベースをリロードを生成する事ができます。 [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ロールアップまたはcubeで使用されたときの不正な結果を修正しました。 [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([サム-チョウ](https://github.com/reflection)) -- クエリの固定列エイリアス `JOIN ON` 構文と分散テーブル。 [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([冬張](https://github.com/zhang2014)) -- の内部実装における固定エラー `quantileTDigest` (アルテムVakhrushevによって発見)。 このエラーはClickHouseでは決して起こらず、ClickHouseコードベースをライブラリとして直接使用する人にのみ関連していました。 [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 改善 {#improvements-6} - -- のサポート `IF NOT EXISTS` で `ALTER TABLE ADD COLUMN` と一緒に文 `IF EXISTS` で `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([Boris Granveaud](https://github.com/bgranvea)) -- 機能 `parseDateTimeBestEffort`:形式のサポート `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` と似ています。 [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- `CapnProtoInputStream` 今サポートギザギザの構造。 [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) -- ユーザビリティ向上に追加チェックがサーバプロセスからのデータディレクトリはオーナーを想定しています。 できない開始のサーバーからのルートデータが得られない場合には所属非rootユーザーです。 [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([sergey-v-galtsev](https://github.com/sergey-v-galtsev)) -- 結合によるクエリの分析中に必要な列をチェックするロジックの改善。 [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([Artem Zuikov](https://github.com/4ertus2)) -- 単一のサーバーに多数の分散テーブルがある場合の接続数を減らしました。 [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([冬張](https://github.com/zhang2014)) -- サポートされている合計行 `WITH TOTALS` ODBCドライバのクエリ。 [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([Maksim Koritckiy](https://github.com/nightweb)) -- 使用を許可する `Enum`関数の中の整数としてのs。 [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([イワン](https://github.com/abyss7)) -- 追加 `low_cardinality_allow_in_native_format` 設定。 無効の場合は、使用しないでください `LowCadrinality` タイプイン `Native` フォーマット。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 削除の冗長化物からの集計表現のキャッシュの低メモリ使用量 [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([alesapin](https://github.com/alesapin)) -- チェックを追加する `SET send_logs_level = 'value'` クエリーを受け適切な値です。 [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([Sabyanin Maxim](https://github.com/s-mx)) -- タイプ変換関数で固定されたデータ型のチェック。 [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([冬張](https://github.com/zhang2014)) - -#### 性能の改善 {#performance-improvements-5} - -- マージツリー設定の追加 `use_minimalistic_part_header_in_zookeeper`. 有効になっている場合、複製のテーブル店舗のコンパクト部分のメタデータの一部znode. これは著しく低下するので、飼育係スナップショットサイズ(場合には、あらゆるテーブルのカラム). この設定を有効にすると、それをサポートしていないバージョンにダウングレードすることはできません。 [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([Alex Zatelepin](https://github.com/ztlpn)) -- Dfaベースの関数の実装を追加します。 `sequenceMatch` と `sequenceCount` patternに時間が含まれていない場合。 [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- 整数のシリアル化のパフォーマンスの向上。 [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([アモスの鳥](https://github.com/amosbird)) -- Zero left padding PODArrayので、-1要素は常に有効でゼロになります。 これは、オフセットの分岐のない計算に使用されます。 [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([アモスの鳥](https://github.com/amosbird)) -- 元に戻す `jemalloc` パフォーマン [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 下位互換性のない変更 {#backward-incompatible-changes-2} - -- 文書化されていない機能を削除 `ALTER MODIFY PRIMARY KEY` それがによって取って代わられたので `ALTER MODIFY ORDER BY` 司令部 [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([Alex Zatelepin](https://github.com/ztlpn)) -- 削除機能 `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- タイプの結果を持つスカラーサブクエリの使用を禁止する `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([イワン](https://github.com/abyss7)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvements-6} - -- PowerPCのサポートを追加 (`ppc64le`)ビルド. [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([Danila Kutenin](https://github.com/danlark1)) -- ステートフル機能試験を実般に利用可能データセットである。 [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- サーバーが起動できない場合のエラーを修正しました `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` Dockerまたはsystemd-nspawn内のメッセージ。 [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 更新 `rdkafka` v1.0.0-RC5へのライブラリ。 生のCインターフェイスの代わりにcppkafkaを使用します。 [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([イワン](https://github.com/abyss7)) -- 更新 `mariadb-client` ライブラリ。 UBSanで見つかった問題のいずれかを修正しました。 [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- UBSanビルドのいくつかの修正。 [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- UBSanビルドによるテストのコミットごとの実行を追加しました。 -- PVS-Studio static analyzerのコミットごとの実行を追加しました。 -- PVS-Studioによって発見されたバグを修正しました。 [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定glibc互換性の問題。 [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Dockerイメージを18.10に移動し、glibc\>=2.28の互換性ファイルを追加します [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([alesapin](https://github.com/alesapin)) -- 追加環境変数の場合はユーザーを行わないchownディレクトリをサーバー dockerイメージです。 [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([alesapin](https://github.com/alesapin)) -- からの警告のほとんどを有効に `-Weverything` クラングで。 有効 `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 唯一のクラングで利用可能ないくつかのより多くの警告を追加しました8. [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- リンク先 `libLLVM` 共有リンクを使用する場合は、個々のLLVMライブラリではなく。 [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([Orivej Desh](https://github.com/orivej)) -- テスト画像のための追加された消毒剤の変数。 [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([alesapin](https://github.com/alesapin)) -- `clickhouse-server` debianパッケージは `libcap2-bin` 使用するパッケージ `setcap` 機能を設定するためのツール。 これは任意です。 [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 改善されたコンパイル時間、固定includesむ。 [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([proller](https://github.com/proller)) -- ハッシュ関数のパフォーマンステス [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([フィリモノフ](https://github.com/filimonov)) -- 固定巡回ライブラリ依存。 [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([proller](https://github.com/proller)) -- 低利用可能なメモリとコンパイルの改善。 [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([proller](https://github.com/proller)) -- 追加試験スクリプトの再現性能の劣化 `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 下のコメントや文字列リテラルのスペルミスを修正 `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([マイハー](https://github.com/maiha)) -- コメントの誤字を修正しました。 [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([Evgenii Pravda](https://github.com/kvinty)) - -## [2018年の変更履歴](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2018.md) {#changelog-for-2018} diff --git a/docs/ja/whats_new/changelog/index.md b/docs/ja/whats_new/changelog/index.md deleted file mode 100644 index 0d90862ee11..00000000000 --- a/docs/ja/whats_new/changelog/index.md +++ /dev/null @@ -1,668 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: Changelog -toc_priority: 74 -toc_title: '2020' ---- - -## ClickHouseリリースv20.3 {#clickhouse-release-v20-3} - -### ClickHouseリリリースv20.3.4.10,2020-03-20 {#clickhouse-release-v20-3-4-10-2020-03-20} - -#### バグ修正 {#bug-fix} - -- このリリースも含む全てのバグ修正から20.1.8.41 -- 不足している修正 `rows_before_limit_at_least` プロセッサパイプラインを使用したhttpクエリの場合。 この修正 [\#9730](https://github.com/ClickHouse/ClickHouse/issues/9730). [\#9757](https://github.com/ClickHouse/ClickHouse/pull/9757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -### ClickHouseリリリースv20.3.3.6,2020-03-17 {#clickhouse-release-v20-3-3-6-2020-03-17} - -#### バグ修正 {#bug-fix-1} - -- このリリースも含む全てのバグ修正から20.1.7.38 -- ユーザーが以前のバージョンで突然変異を実行した場合、複製が機能しないレプリケーションのバグを修正しました。 この修正 [\#9645](https://github.com/ClickHouse/ClickHouse/issues/9645). [\#9652](https://github.com/ClickHouse/ClickHouse/pull/9652) ([alesapin](https://github.com/alesapin)). こ版20.3後方互換。 -- 設定を追加 `use_compact_format_in_distributed_parts_names` これにより、 `INSERT` へのクエリ `Distributed` よりコンパクトな形式のテーブル。 この修正 [\#9647](https://github.com/ClickHouse/ClickHouse/issues/9647). [\#9653](https://github.com/ClickHouse/ClickHouse/pull/9653) ([alesapin](https://github.com/alesapin)). こ版20.3後方互換。 - -### ClickHouseリリリースv20.3.2.1,2020-03-12 {#clickhouse-release-v20-3-2-1-2020-03-12} - -#### 下位互換性のない変更 {#backward-incompatible-change} - -- 問題を修正しました `file name too long` データを送信するとき `Distributed` 多数のレプリカのテーブル。 レプリカの資格情報がサーバーログに表示される問題を修正しました。 ディスク上のディレクトリ名の形式が `[shard{shard_index}[_replica{replica_index}]]`. [\#8911](https://github.com/ClickHouse/ClickHouse/pull/8911) ([Mikhail Korotov](https://github.com/millb))新しいバージョンにアップグレードした後、古いサーバーのバージョンが新しいディレクトリ形式を認識しないため、手動の介入なしにダウングレードするこ ダウングレードする場合は、対応するディレクトリの名前を手動で古い形式に変更する必要があります。 この変更は、非同期を使用した場合にのみ関連します `INSERT`にs `Distributed` テーブル。 バージョン20.3.3では、新しいフォーマットを徐々に有効にするための設定を紹介します。 -- 変更コマンドのレプリケーションログエントリの形式を変更。 新しいバージョンをイ -- Stacktracesをダンプするシンプルなメモリプロファイラを実装する `system.trace_log` 毎N文字以上のソフト配分を制限 [\#8765](https://github.com/ClickHouse/ClickHouse/pull/8765) ([イワン](https://github.com/abyss7)) [\#9472](https://github.com/ClickHouse/ClickHouse/pull/9472) ([alexey-milovidov](https://github.com/alexey-milovidov))の列 `system.trace_log` から改名されました `timer_type` に `trace_type`. この変更が必要な第三者機関の性能解析およびflamegraph処理ツールです。 -- 内部スレッド番号の代わりにosスレッドidを使用します。 この修正 [\#7477](https://github.com/ClickHouse/ClickHouse/issues/7477) 古い `clickhouse-client` サーバーから送信されるログを受信できない `send_logs_level` これは、構造化ログメッセージの名前と種類が変更されたためです。 一方、異なるサーバーバージョンでは、異なるタイプのログを相互に送信できます。 あなたが使用しないとき `send_logs_level` 設定、あなたは気にしないでください。 [\#8954](https://github.com/ClickHouse/ClickHouse/pull/8954) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 削除 `indexHint` 機能 [\#9542](https://github.com/ClickHouse/ClickHouse/pull/9542) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 削除 `findClusterIndex`, `findClusterValue` 機能。 この修正 [\#8641](https://github.com/ClickHouse/ClickHouse/issues/8641). これらの機能を使用していた場合は、メールを送信します `clickhouse-feedback@yandex-team.com` [\#9543](https://github.com/ClickHouse/ClickHouse/pull/9543) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- これで、列を作成したり、列を追加したりすることはできません `SELECT` 既定の式としてサブクエリ。 [\#9481](https://github.com/ClickHouse/ClickHouse/pull/9481) ([alesapin](https://github.com/alesapin)) -- JOIN内のサブクエリのエイリアスが必要です。 [\#9274](https://github.com/ClickHouse/ClickHouse/pull/9274) ([Artem Zuikov](https://github.com/4ertus2)) -- 改善された `ALTER MODIFY/ADD` クエリロジック。 今はできません `ADD` タイプのない列, `MODIFY` デフォルトの式では、列の型は変更されません。 `MODIFY` 型は既定の式の値を緩めません。 修正 [\#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). [\#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) ([alesapin](https://github.com/alesapin)) -- ログ設定の変更を適用するには、サーバーを再起動する必要があります。 これは、サーバーが削除されたログファイルにログを記録するバグを回避するための一時的な回避策です。 [\#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [\#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- を設定 `experimental_use_processors` デフォルトでは有効です。 この設定をご利用の新しいクエリのパイプライン これは内部リファクタリングであり、目に見える変更は期待していません。 問題が表示される場合は、ゼロをバックアップするように設定します。 [\#8768](https://github.com/ClickHouse/ClickHouse/pull/8768) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 新しい機能 {#new-feature} - -- 追加 `Avro` と `AvroConfluent` 入力/出力形式 [\#8571](https://github.com/ClickHouse/ClickHouse/pull/8571) ([Andrew Onyshchuk](https://github.com/oandrew)) [\#8957](https://github.com/ClickHouse/ClickHouse/pull/8957) ([Andrew Onyshchuk](https://github.com/oandrew)) [\#8717](https://github.com/ClickHouse/ClickHouse/pull/8717) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 期限切れのキーのマルチスレッドおよび非ブロック更新 `cache` 辞書(古いものを読むための任意の許可を持つ)。 [\#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- クエリの追加 `ALTER ... MATERIALIZE TTL`. TTLによって期限切れのデータを強制的に削除し、すべての部分でTTLに関するメタ情報を再計算する突然変異を実行します。 [\#8775](https://github.com/ClickHouse/ClickHouse/pull/8775) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 必要に応じて、hashjoinからmergejoin(ディスク上)に切り替えます [\#9082](https://github.com/ClickHouse/ClickHouse/pull/9082) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `MOVE PARTITION` コマンド `ALTER TABLE` [\#4729](https://github.com/ClickHouse/ClickHouse/issues/4729) [\#6168](https://github.com/ClickHouse/ClickHouse/pull/6168) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 設定ファイルからストレージ設定をリロードする。 [\#8594](https://github.com/ClickHouse/ClickHouse/pull/8594) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 変更できる `storage_policy` あまり豊かではないものに。 [\#8107](https://github.com/ClickHouse/ClickHouse/pull/8107) ([Vladimir Chebotarev](https://github.com/excitoon)) -- S3ストレージとテーブル機能のglobs/wildcardsのサポートを追加しました。 [\#8851](https://github.com/ClickHouse/ClickHouse/pull/8851) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 実装 `bitAnd`, `bitOr`, `bitXor`, `bitNot` のために `FixedString(N)` データ型。 [\#9091](https://github.com/ClickHouse/ClickHouse/pull/9091) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 機能追加 `bitCount`. この修正 [\#8702](https://github.com/ClickHouse/ClickHouse/issues/8702). [\#8708](https://github.com/ClickHouse/ClickHouse/pull/8708) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#8749](https://github.com/ClickHouse/ClickHouse/pull/8749) ([ikopylov](https://github.com/ikopylov)) -- 追加 `generateRandom` テーブル機能をランダム行に指定されたschema. 任意のテストテーブルにデータを設定できます。 [\#8994](https://github.com/ClickHouse/ClickHouse/pull/8994) ([イリヤ-ヤツィシン](https://github.com/qoega)) -- `JSONEachRowFormat` 支援特別の場合オブジェ囲まれたトップレベルの配列になります。 [\#8860](https://github.com/ClickHouse/ClickHouse/pull/8860) ([Kruglov Pavel](https://github.com/Avogar)) -- これで、列を作成することができます `DEFAULT` デフォルトの列に依存する式 `ALIAS` 式。 [\#9489](https://github.com/ClickHouse/ClickHouse/pull/9489) ([alesapin](https://github.com/alesapin)) -- 指定できるようにする `--limit` ソースデータサイズよりも `clickhouse-obfuscator`. データは異なるランダムシードで繰り返されます。 [\#9155](https://github.com/ClickHouse/ClickHouse/pull/9155) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `groupArraySample` 機能(に類似した `groupArray` とreserviorサンプリングアルゴリズムです。 [\#8286](https://github.com/ClickHouse/ClickHouse/pull/8286) ([アモスの鳥](https://github.com/amosbird)) -- これで、更新キューのサイズを監視することができます `cache`/`complex_key_cache` システム指標による辞書。 [\#9413](https://github.com/ClickHouse/ClickHouse/pull/9413) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- CSV出力形式の行区切りとしてCRLFを使用できるようにする `output_format_csv_crlf_end_of_line` は1に設定されます [\#8934](https://github.com/ClickHouse/ClickHouse/pull/8934) [\#8935](https://github.com/ClickHouse/ClickHouse/pull/8935) [\#8963](https://github.com/ClickHouse/ClickHouse/pull/8963) ([Mikhail Korotov](https://github.com/millb)) -- より多くの機能を実装する [H3](https://github.com/uber/h3) API: `h3GetBaseCell`, `h3HexAreaM2`, `h3IndexesAreNeighbors`, `h3ToChildren`, `h3ToString` と `stringToH3` [\#8938](https://github.com/ClickHouse/ClickHouse/pull/8938) ([ニコ-マンデリー](https://github.com/nmandery)) -- 新しい設定を導入: `max_parser_depth` 最大スタックサイズを制御し、大規模な複雑なクエリを許可する。 この修正 [\#6681](https://github.com/ClickHouse/ClickHouse/issues/6681) と [\#7668](https://github.com/ClickHouse/ClickHouse/issues/7668). [\#8647](https://github.com/ClickHouse/ClickHouse/pull/8647) ([Maxim Smirnov](https://github.com/qMBQx8GH)) -- 設定を追加する `force_optimize_skip_unused_shards` 未使用のシャードをスキップできない場合にスローする設定 [\#8805](https://github.com/ClickHouse/ClickHouse/pull/8805) ([Azat Khuzhin](https://github.com/azat)) -- この設定は複数のディスク/量のデータを格納するための送付 `Distributed` エンジン [\#8756](https://github.com/ClickHouse/ClickHouse/pull/8756) ([Azat Khuzhin](https://github.com/azat)) -- 支援の保管方針 (``)一時的なデータを貯えるため。 [\#8750](https://github.com/ClickHouse/ClickHouse/pull/8750) ([Azat Khuzhin](https://github.com/azat)) -- 追加 `X-ClickHouse-Exception-Code` データを送信する前に例外がスローされた場合に設定されるHTTPヘッダー。 これは [\#4971](https://github.com/ClickHouse/ClickHouse/issues/4971). [\#8786](https://github.com/ClickHouse/ClickHouse/pull/8786) ([Mikhail Korotov](https://github.com/millb)) -- 機能追加 `ifNotFinite`. それは単なる統語的な砂糖です: `ifNotFinite(x, y) = isFinite(x) ? x : y`. [\#8710](https://github.com/ClickHouse/ClickHouse/pull/8710) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `last_successful_update_time` コラムの `system.dictionaries` テーブル [\#9394](https://github.com/ClickHouse/ClickHouse/pull/9394) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- 追加 `blockSerializedSize` 機能(圧縮なしのディスク上のサイズ) [\#8952](https://github.com/ClickHouse/ClickHouse/pull/8952) ([Azat Khuzhin](https://github.com/azat)) -- 機能を追加 `moduloOrZero` [\#9358](https://github.com/ClickHouse/ClickHouse/pull/9358) ([hcz](https://github.com/hczhcz)) -- 追加されたシステム表 `system.zeros` と `system.zeros_mt` だけでなく、物語機能 `zeros()` と `zeros_mt()`. テーブル(テーブル機能を含む単一カラム名 `zero` とタイプ `UInt8`. この列にはゼロがあります。 これは、多くの行を生成する最速の方法としてテスト目的に必要です。 この修正 [\#6604](https://github.com/ClickHouse/ClickHouse/issues/6604) [\#9593](https://github.com/ClickHouse/ClickHouse/pull/9593) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### 実験的特徴 {#experimental-feature} - -- 部品の新しいコンパクトな形式を追加 `MergeTree`-すべての列が一つのファイルに格納されている家族のテーブル。 それは小さく、頻繁な挿入物の性能を高めるのを助ける。 古いフォーマット(列ごとに一つのファイル)がwideと呼ばれます。 データ格納形式は設定によって制御 `min_bytes_for_wide_part` と `min_rows_for_wide_part`. [\#8290](https://github.com/ClickHouse/ClickHouse/pull/8290) ([アントン-ポポフ](https://github.com/CurtizJ)) -- S3ストレージのサポート `Log`, `TinyLog` と `StripeLog` テーブル。 [\#8862](https://github.com/ClickHouse/ClickHouse/pull/8862) ([Pavel Kovalenko](https://github.com/Jokser)) - -#### バグ修正 {#bug-fix-2} - -- ログメッセージの不整合な空白を修正しました。 [\#9322](https://github.com/ClickHouse/ClickHouse/pull/9322) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テーブル作成時に、名前のないタプルの配列がネストされた構造としてフラット化されたバグを修正。 [\#8866](https://github.com/ClickHouse/ClickHouse/pull/8866) ([achulkov2comment](https://github.com/achulkov2)) -- ときに問題を修正しました “Too many open files” エラーが発生する恐れがあると多数の場合はファイルのマッチングglobパターン `File` テーブルまたは `file` テーブル機能。 今すぐファイルが遅延開かれます。 この修正 [\#8857](https://github.com/ClickHouse/ClickHouse/issues/8857) [\#8861](https://github.com/ClickHouse/ClickHouse/pull/8861) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- DROP TEMPORARY TABLEは現在、一時テーブルのみを削除します。 [\#8907](https://github.com/ClickHouse/ClickHouse/pull/8907) ([Vitaly Baranov](https://github.com/vitlibar)) -- 削除した旧式の仕切りした時停止のサーバーは取り外し、添付を表示します。 [\#8602](https://github.com/ClickHouse/ClickHouse/pull/8602) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- のためにどのようにデフォルトのディスクを算定し、自由空間から `data` サブディレクトリ。 空き容量が正しく計算されない場合の問題を修正しました。 `data` ディレクト この修正 [\#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) [\#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) ([Mikhail Korotov](https://github.com/millb)) -- カンマ(クロス)は、内部の()に参加することができます。 [\#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) ([Artem Zuikov](https://github.com/4ertus2)) -- WHERE節に演算子のようなものがある場合は、INNER JOINにクロスを書き換えることができます。 [\#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) ([Artem Zuikov](https://github.com/4ertus2)) -- 後に可能な誤った結果を修正 `GROUP BY` 有効に設定 `distributed_aggregation_memory_efficient`. 修正 [\#9134](https://github.com/ClickHouse/ClickHouse/issues/9134). [\#9289](https://github.com/ClickHouse/ClickHouse/pull/9289) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 見つかりキーのカウントとして見るメトリクスのキャッシュを生成する事ができます。 [\#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- レプリケーションプロト [\#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [\#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([alesapin](https://github.com/alesapin)) -- 上の固定レース条件 `queue_task_handle` の起動時に `ReplicatedMergeTree` テーブル。 [\#9552](https://github.com/ClickHouse/ClickHouse/pull/9552) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- その他の通貨 `NOT` で動作しませんでした `SHOW TABLES NOT LIKE` クエリ [\#8727](https://github.com/ClickHouse/ClickHouse/issues/8727) [\#8940](https://github.com/ClickHouse/ClickHouse/pull/8940) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能に範囲チェックを追加しました `h3EdgeLengthM`. このチェッ [\#8945](https://github.com/ClickHouse/ClickHouse/pull/8945) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 複数の引数(10以上)の三元論理演算のバッチ計算のバグを修正しました。 [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([Alexander Kazakov](https://github.com/Akazz)) -- Prewhere最適化のエラーを修正しました。 `Inconsistent number of columns got from MergeTreeRangeReader` 例外だ [\#9024](https://github.com/ClickHouse/ClickHouse/pull/9024) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 予期しない修正 `Timeout exceeded while reading from socket` 例外は、ランダムに起きにセキュア接続前にタイムアウト実を超えた場queryプロファイラが有効になります。 また、追加 `connect_timeout_with_failover_secure_ms` 設定(デフォルトは100ミリ秒)です。 `connect_timeout_with_failover_ms` ただし、セキュアな接続に使用されます(SSLハンドシェイクが通常のTCP接続よりも遅いため) [\#9026](https://github.com/ClickHouse/ClickHouse/pull/9026) ([tavplubix](https://github.com/tavplubix)) -- バグを修正しました。 `parts_to_do=0` と `is_done=0`. [\#9022](https://github.com/ClickHouse/ClickHouse/pull/9022) ([alesapin](https://github.com/alesapin)) -- 新しい任意の結合ロジックを使用する `partial_merge_join` 設定。 それは作ることが可能です `ANY|ALL|SEMI LEFT` と `ALL INNER` との結合 `partial_merge_join=1` 今だ [\#8932](https://github.com/ClickHouse/ClickHouse/pull/8932) ([Artem Zuikov](https://github.com/4ertus2)) -- シャードは、例外をスローするのではなく、イニシエータから取得した設定をシャードのconstaintsにクランプします。 この修正では、別の制約を持つシャードにクエリを送信できます。 [\#9447](https://github.com/ClickHouse/ClickHouse/pull/9447) ([Vitaly Baranov](https://github.com/vitlibar)) -- 固定メモリ管理の問題 `MergeTreeReadPool`. [\#8791](https://github.com/ClickHouse/ClickHouse/pull/8791) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正 `toDecimal*OrNull()` 文字列で呼び出されたときの関数群 `e`. 修正 [\#8312](https://github.com/ClickHouse/ClickHouse/issues/8312) [\#8764](https://github.com/ClickHouse/ClickHouse/pull/8764) ([Artem Zuikov](https://github.com/4ertus2)) -- う `FORMAT Null` クライアントにデータを送信しません。 [\#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- そのタイムスタンプを修正 `LiveViewBlockInputStream` 更新されません。 `LIVE VIEW` 実験的特徴です [\#8644](https://github.com/ClickHouse/ClickHouse/pull/8644) ([vxider](https://github.com/Vxider)) [\#8625](https://github.com/ClickHouse/ClickHouse/pull/8625) ([vxider](https://github.com/Vxider)) -- 固定 `ALTER MODIFY TTL` 古いTTL式を削除することを許さなかった誤った動作。 [\#8422](https://github.com/ClickHouse/ClickHouse/pull/8422) ([Vladimir Chebotarev](https://github.com/excitoon)) -- MergeTreeIndexSet内のUBSanレポートを修正しました。 この修正 [\#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) [\#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の動作を修正しました `match` と `extract` haystackにゼロバイトがある場合の関数。 Haystackが一定の場合、その動作は間違っていました。 この修正 [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Apache Avro3rd-partyライブラリのデストラクターから投げを避けます。 [\#9066](https://github.com/ClickHouse/ClickHouse/pull/9066) ([Andrew Onyshchuk](https://github.com/oandrew)) -- ポーリングされたバッチをコミットしない `Kafka` 部分的には、データの穴につながる可能性があります。 [\#8876](https://github.com/ClickHouse/ClickHouse/pull/8876) ([フィリモノフ](https://github.com/filimonov)) -- 修正 `joinGet` null可能な戻り値の型を指定します。 https://github.com/ClickHouse/ClickHouse/issues/8919 [\#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) ([アモスの鳥](https://github.com/amosbird)) -- 圧縮時にデータの非互換性を修正する `T64` コーデック。 [\#9016](https://github.com/ClickHouse/ClickHouse/pull/9016) ([Artem Zuikov](https://github.com/4ertus2))データ型idの修正 `T64` 影響を受けるバージョンで間違った(de)圧縮につながる圧縮コーデック。 [\#9033](https://github.com/ClickHouse/ClickHouse/pull/9033) ([Artem Zuikov](https://github.com/4ertus2)) -- 設定を追加 `enable_early_constant_folding` 無効にするのである。 [\#9010](https://github.com/ClickHouse/ClickHouse/pull/9010) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正プッシュダウ述語オプティマイザとビューの試験 [\#9011](https://github.com/ClickHouse/ClickHouse/pull/9011) ([冬張](https://github.com/zhang2014)) -- Segfaultを修正する `Merge` から読み取るときに発生する可能性があります `File` ストレージ [\#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) ([tavplubix](https://github.com/tavplubix)) -- ストレージポリシーのチェックを追加 `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE`. そうでない場合はこのデータの一部になり、再起動後の防止ClickHouse。 [\#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) ([Vladimir Chebotarev](https://github.com/excitoon)) -- テーブルにttlが設定されている場合に変更を修正します。 [\#8800](https://github.com/ClickHouse/ClickHouse/pull/8800) ([アントン-ポポフ](https://github.com/CurtizJ)) -- ときに発生する可能性が競合状態を修正 `SYSTEM RELOAD ALL DICTIONARIES` いくつかの辞書が変更/追加/削除されている間に実行されます。 [\#8801](https://github.com/ClickHouse/ClickHouse/pull/8801) ([Vitaly Baranov](https://github.com/vitlibar)) -- 以前のバージョンでは `Memory` データベースエンジ `path` directory (e.g. `/var/lib/clickhouse/`), not in data directory of database (e.g. `/var/lib/clickhouse/db_name`). [\#8753](https://github.com/ClickHouse/ClickHouse/pull/8753) ([tavplubix](https://github.com/tavplubix)) -- デフォル [\#9530](https://github.com/ClickHouse/ClickHouse/pull/9530) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 配列型のbloom\_filterインデックスのnot(has())を修正しました。 [\#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([achimbabcomment](https://github.com/achimbab)) -- テーブルの最初の列を許可する `Log` エンジンは別名である [\#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) ([イワン](https://github.com/abyss7)) -- から読み込み中の範囲の順序を修正 `MergeTree` 一つのスレッドのテーブル。 それは例外につながる可能性があります `MergeTreeRangeReader` または間違ったクエリ結果。 [\#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 作る `reinterpretAsFixedString` 戻るには `FixedString` 代わりに `String`. [\#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) ([Andrew Onyshchuk](https://github.com/oandrew)) -- を避ける非常に珍しい場合には、ユーザーで間違ったエラーメッセージ (`Success` 詳細なエラーの説明の代わりに)。 [\#9457](https://github.com/ClickHouse/ClickHouse/pull/9457) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 使用するとき衝突しないで下さい `Template` 空の行テンプレートを使用した形式。 [\#8785](https://github.com/ClickHouse/ClickHouse/pull/8785) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- システムテーブルのメタデータファイ [\#8653](https://github.com/ClickHouse/ClickHouse/pull/8653) ([tavplubix](https://github.com/tavplubix))修正 [\#8581](https://github.com/ClickHouse/ClickHouse/issues/8581). -- キャッシュ辞書でexception\_ptrのデータレースを修正 [\#8303](https://github.com/ClickHouse/ClickHouse/issues/8303). [\#9379](https://github.com/ClickHouse/ClickHouse/pull/9379) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- クエリの例外をスローしない `ATTACH TABLE IF NOT EXISTS`. 以前は、テーブルが既に存在する場合にスローされました。 `IF NOT EXISTS` 句。 [\#8967](https://github.com/ClickHouse/ClickHouse/pull/8967) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 例外メッセージで行方不明の閉じる括弧を修正しました。 [\#8811](https://github.com/ClickHouse/ClickHouse/pull/8811) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- メッセージの回避 `Possible deadlock avoided` インタラクティブモードでのclickhouse-クライアントの起動時に。 [\#9455](https://github.com/ClickHouse/ClickHouse/pull/9455) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Base64でエンコードされた値の末尾にパディングが不正な形式になる場合がある問題を修正しました。 更新base64ライブラリ。 この修正 [\#9491](https://github.com/ClickHouse/ClickHouse/issues/9491)、閉じます [\#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [\#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- データを失うのを防ぐ `Kafka` まれに、接尾辞を読んだ後でコミットする前に例外が発生した場合。 修正 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378) [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) ([フィリモノフ](https://github.com/filimonov)) -- 固定例外で `DROP TABLE IF EXISTS` [\#8663](https://github.com/ClickHouse/ClickHouse/pull/8663) ([Nikita Vasilev](https://github.com/nikvas0)) -- ユーザーが `ALTER MODIFY SETTING` 古いformatedのため `MergeTree` テーブルエンジン家族。 [\#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([alesapin](https://github.com/alesapin)) -- JSON関連の関数でInt64に収まらないUInt64の数値のサポート。 SIMDJSONをmasterに更新します。 この修正 [\#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) [\#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 非厳密に単調な関数索引が使用されている場合の逆述語の実行を修正しました。 [\#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) ([Alexander Kazakov](https://github.com/Akazz)) -- 折ることを試みてはいけない `IN` 定数の `GROUP BY` [\#8868](https://github.com/ClickHouse/ClickHouse/pull/8868) ([アモスの鳥](https://github.com/amosbird)) -- バグを修正 `ALTER DELETE` インデックスの破損につながる変異。 この修正 [\#9019](https://github.com/ClickHouse/ClickHouse/issues/9019) と [\#8982](https://github.com/ClickHouse/ClickHouse/issues/8982). さらに、非常にまれな競合状態を修正 `ReplicatedMergeTree` `ALTER` クエリ。 [\#9048](https://github.com/ClickHouse/ClickHouse/pull/9048) ([alesapin](https://github.com/alesapin)) -- ときは設定 `compile_expressions` が有効になっている場合は、 `unexpected column` で `LLVMExecutableFunction` 私達が使用する時 `Nullable` タイプ [\#8910](https://github.com/ClickHouse/ClickHouse/pull/8910) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 以下のための複数の修正 `Kafka` エンジン:1)消費者グループのリバランス中に表示された重複を修正します。 2)修正レア ‘holes’ 登場時のデータをポーリングから割と世論調査および為の一部(現在の私たちは常にプロセス/コミット全体のポーリングブロックメッセージ). 3)固定フラッシュによるブロックサイズ(前のみにフラッシングによるタイムアウトした作業と同様に扱う。 4)より契約手続(入力フィードバック. 5)テストをより速く動作させる(デフォルトの間隔とタイムアウト)。 データは以前はブロックサイズでフラッシュされていなかったため(ドキュメントによると)、PRはデフォルト設定でパフォーマンスが低下する可能性 その変更後にパフォーマンスの問題が発生した場合-増加してください `kafka_max_block_size` より大きな値へのテーブル(例えば `CREATE TABLE ...Engine=Kafka ... SETTINGS ... kafka_max_block_size=524288`). 修正 [\#7259](https://github.com/ClickHouse/ClickHouse/issues/7259) [\#8917](https://github.com/ClickHouse/ClickHouse/pull/8917) ([フィリモノフ](https://github.com/filimonov)) -- 修正 `Parameter out of bound` PREWHERE最適化の後のいくつかのクエリの例外。 [\#8914](https://github.com/ClickHouse/ClickHouse/pull/8914) ([Baudouin Giard](https://github.com/bgiard)) -- 関数の引数の混合constの場合を修正しました `arrayZip`. [\#8705](https://github.com/ClickHouse/ClickHouse/pull/8705) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 実行時期 `CREATE` クエリー、倍定表現のストレージエンジンの引数です。 空のデータベース名を現在のデータベ 修正 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492) [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) ([tavplubix](https://github.com/tavplubix)) -- 次のような単純な循環エイリアスを持つ列を作成または追加することはできません `a DEFAULT b, b DEFAULT a`. [\#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([alesapin](https://github.com/alesapin)) -- 元の部分が破損する可能性があるダブル移動のバグを修正しました。 これは、 `ALTER TABLE MOVE` [\#8680](https://github.com/ClickHouse/ClickHouse/pull/8680) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 許可 `interval` バッククォートなしで正しく解析する識別子。 場合でも、クエリを実行できない問題を修正しました。 `interval` 識別子は、バッククォートまたは二重引用符で囲まれています。 この修正 [\#9124](https://github.com/ClickHouse/ClickHouse/issues/9124). [\#9142](https://github.com/ClickHouse/ClickHouse/pull/9142) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定ファズテストとの不正な動作 `bitTestAll`/`bitTestAny` 機能。 [\#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 可能なクラッシュ/間違った行数を修正 `LIMIT n WITH TIES` n行目に等しい行がたくさんあるとき。 [\#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([tavplubix](https://github.com/tavplubix)) -- Enabledで書かれたパーツによる修正 `insert_quorum`. [\#9463](https://github.com/ClickHouse/ClickHouse/pull/9463) ([alesapin](https://github.com/alesapin)) -- の破壊でデータレースを修正 `Poco::HTTPServer`. どこの場合のサーバを起動直ちに停止しております。 [\#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 実行中に誤解を招くエラーメッセージが表示されたバグを修正 `SHOW CREATE TABLE a_table_that_does_not_exist`. [\#8899](https://github.com/ClickHouse/ClickHouse/pull/8899) ([achulkov2comment](https://github.com/achulkov2)) -- 固定 `Parameters are out of bound` 私たちが定数を持っているいくつかのまれなケースでは例外 `SELECT` 私たちが持っているときの句 `ORDER BY` と `LIMIT` 句。 [\#8892](https://github.com/ClickHouse/ClickHouse/pull/8892) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 既に完了した突然変異がステータスを持つことができるとき `is_done=0`. [\#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) ([alesapin](https://github.com/alesapin)) -- 実行を防ぐ `ALTER ADD INDEX` 古い構文のMergeTreeテーブルでは、動作しないためです。 [\#8822](https://github.com/ClickHouse/ClickHouse/pull/8822) ([Mikhail Korotov](https://github.com/millb)) -- サーバーの起動中にテーブルにアクセスしない。 `LIVE VIEW` 依存するので、サーバーは起動できます。 また、削除 `LIVE VIEW` デタッチ時の依存関係 `LIVE VIEW`. `LIVE VIEW` 実験的特徴です [\#8824](https://github.com/ClickHouse/ClickHouse/pull/8824) ([tavplubix](https://github.com/tavplubix)) -- で可能なsegfaultを修正 `MergeTreeRangeReader`,実行中 `PREWHERE`. [\#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 列ttlsによるチェックサムの不一致を修正しました。 [\#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([アントン-ポポフ](https://github.com/CurtizJ)) -- ボリュームが一つしかない場合にttlルールによってパーツがバックグラウンドで移動されないバグを修正しました。 [\#8672](https://github.com/ClickHouse/ClickHouse/pull/8672) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 問題を修正しました `Method createColumn() is not implemented for data type Set`. この修正 [\#7799](https://github.com/ClickHouse/ClickHouse/issues/7799). [\#8674](https://github.com/ClickHouse/ClickHouse/pull/8674) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 今度は、突然変異をより頻繁に確定しようとします。 [\#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([alesapin](https://github.com/alesapin)) -- 修正 `intDiv` マイナス一つの定数による [\#9351](https://github.com/ClickHouse/ClickHouse/pull/9351) ([hcz](https://github.com/hczhcz)) -- 可能な競合状態を修正 `BlockIO`. [\#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- のを修正した。先サーバを終了しようとした場合に使用/drop `Kafka` テーブル作成されたパラメータ。 [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) ([フィリモノフ](https://github.com/filimonov)) -- OSが間違った結果を返す場合の回避策を追加 `timer_create` 機能。 [\#8837](https://github.com/ClickHouse/ClickHouse/pull/8837) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の使用で修正されたエラー `min_marks_for_seek` パラメータ。 固定のエラーメッセージがない場合shardingキーテーブルの配布に努めのスキップ未使用の破片. [\#8908](https://github.com/ClickHouse/ClickHouse/pull/8908) ([Azat Khuzhin](https://github.com/azat)) - -#### 改善 {#improvement} - -- 実装 `ALTER MODIFY/DROP` 以下のための突然変異の上にクエリ `ReplicatedMergeTree*` エンジンファミリー さて `ALTERS` メタデータ更新ステージでのみブロックし、その後はブロックしません。 [\#8701](https://github.com/ClickHouse/ClickHouse/pull/8701) ([alesapin](https://github.com/alesapin)) -- 内部結合にcrossを書き換える機能を追加する `WHERE` シリアル化されていない名前のセクション。 [\#9512](https://github.com/ClickHouse/ClickHouse/pull/9512) ([Artem Zuikov](https://github.com/4ertus2)) -- 作る `SHOW TABLES` と `SHOW DATABASES` クエリは、 `WHERE` 式と `FROM`/`IN` [\#9076](https://github.com/ClickHouse/ClickHouse/pull/9076) ([sundyli](https://github.com/sundy-li)) -- 設定を追加しました `deduplicate_blocks_in_dependent_materialized_views`. [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) ([urykhy](https://github.com/urykhy)) -- 最近の変更後、mysqlクライアントはバイナリ文字列をhexで印刷し始め、読みにくくなりました ([\#9032](https://github.com/ClickHouse/ClickHouse/issues/9032)). ClickHouseの回避策は、文字列の列をUTF-8としてマークすることです。 [\#9079](https://github.com/ClickHouse/ClickHouse/pull/9079) ([ユーリーバラノフ](https://github.com/yurriy)) -- 文字列とfixedstringキーのサポートを追加する `sumMap` [\#8903](https://github.com/ClickHouse/ClickHouse/pull/8903) ([Baudouin Giard](https://github.com/bgiard)) -- SummingMergeTreeマップでの文字列キーのサポート [\#8933](https://github.com/ClickHouse/ClickHouse/pull/8933) ([Baudouin Giard](https://github.com/bgiard)) -- スレッドが例外をスローした場合でも、スレッドプールへのスレッドの信号終端 [\#8736](https://github.com/ClickHouse/ClickHouse/pull/8736) ([丁象飛](https://github.com/dingxiangfei2009)) -- 設定を許可する `query_id` で `clickhouse-benchmark` [\#9416](https://github.com/ClickHouse/ClickHouse/pull/9416) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 奇妙な表現を許可しない `ALTER TABLE ... PARTITION partition` クエリ。 このアドレス [\#7192](https://github.com/ClickHouse/ClickHouse/issues/7192) [\#8835](https://github.com/ClickHouse/ClickHouse/pull/8835) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テーブル `system.table_engines` 機能のサポートに関する情報を提供します `supports_ttl` または `supports_sort_order`). [\#8830](https://github.com/ClickHouse/ClickHouse/pull/8830) ([Max Akhmedov](https://github.com/zlobober)) -- 有効 `system.metric_log` デフォルトでは。 これには、ProfileEventsの値を持つ行が含まれます。 “collect\_interval\_milliseconds” 間隔(デフォルトでは秒)。 テーブルは非常に小さく(通常はメガバイトの順で)、デフォルトでこのデータを収集することは妥当です。 [\#9225](https://github.com/ClickHouse/ClickHouse/pull/9225) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries. Fixes [\#6964](https://github.com/ClickHouse/ClickHouse/issues/6964) [\#8874](https://github.com/ClickHouse/ClickHouse/pull/8874) ([イワン](https://github.com/abyss7)) -- 今すぐ一時的 `LIVE VIEW` によって作成されます `CREATE LIVE VIEW name WITH TIMEOUT [42] ...` 代わりに `CREATE TEMPORARY LIVE VIEW ...` 前の構文は、次の構文と一致していなかったためです `CREATE TEMPORARY TABLE ...` [\#9131](https://github.com/ClickHouse/ClickHouse/pull/9131) ([tavplubix](https://github.com/tavplubix)) -- Text\_logを追加します。行くエントリを制限するレベル構成パラメータ `system.text_log` テーブル [\#8809](https://github.com/ClickHouse/ClickHouse/pull/8809) ([Azat Khuzhin](https://github.com/azat)) -- を入れてダウンロード部にディスク/量によるttlル [\#8598](https://github.com/ClickHouse/ClickHouse/pull/8598) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 外部mysqlディクショナリの場合、mysql接続プールをmutualizeすることができます “share” それらの間で辞書。 このオプションは、MySQLサーバーへの接続数を大幅に削減します。 [\#9409](https://github.com/ClickHouse/ClickHouse/pull/9409) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- 最も近いクエリの実行時間内の変位値を表示する `clickhouse-benchmark` 内挿された値の代わりに出力します。 いくつかのクエリの実行時間に対応する値を表示する方がよいでしょう。 [\#8712](https://github.com/ClickHouse/ClickHouse/pull/8712) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Kafkaにデータを挿入するときにメッセージのキーとタイムスタンプを追加する可能性。 修正 [\#7198](https://github.com/ClickHouse/ClickHouse/issues/7198) [\#8969](https://github.com/ClickHouse/ClickHouse/pull/8969) ([フィリモノフ](https://github.com/filimonov)) -- 場合はサーバはターミナルから、ハイライトのスレッド号、クエリをidでログインを優先する色をします。 ここは改善の可読性の相関のログメッセージのステータスです。 [\#8961](https://github.com/ClickHouse/ClickHouse/pull/8961) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より良い例外のメッセージ読み込み中にテーブル `Ordinary` データベース [\#9527](https://github.com/ClickHouse/ClickHouse/pull/9527) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 実装 `arraySlice` 集約関数の状態を持つ配列の場合。 この修正 [\#9388](https://github.com/ClickHouse/ClickHouse/issues/9388) [\#9391](https://github.com/ClickHouse/ClickHouse/pull/9391) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- IN演算子の右側で定数関数と定数配列を使用できます。 [\#8813](https://github.com/ClickHouse/ClickHouse/pull/8813) ([アントン-ポポフ](https://github.com/CurtizJ)) -- システムのデータを取得している間にzookeeperの例外が発生した場合。レプリカは、別の列に表示します。 これは [\#9137](https://github.com/ClickHouse/ClickHouse/issues/9137) [\#9138](https://github.com/ClickHouse/ClickHouse/pull/9138) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Destroy上のMergeTreeデータ部分を原子的に削除します。 [\#8402](https://github.com/ClickHouse/ClickHouse/pull/8402) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 支援を行レベルのセキュリティ配布します。 [\#8926](https://github.com/ClickHouse/ClickHouse/pull/8926) ([イワン](https://github.com/abyss7)) -- Now we recognize suffix (like KB, KiB…) in settings values. [\#8072](https://github.com/ClickHouse/ClickHouse/pull/8072) ([Mikhail Korotov](https://github.com/millb)) -- 大きな結合の結果を構築しながらメモリ不足を防ぎます。 [\#8637](https://github.com/ClickHouse/ClickHouse/pull/8637) ([Artem Zuikov](https://github.com/4ertus2)) -- インタラクティブモードでの提案にクラスタの名前を追加 `clickhouse-client`. [\#8709](https://github.com/ClickHouse/ClickHouse/pull/8709) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries [\#8820](https://github.com/ClickHouse/ClickHouse/pull/8820) ([イワン](https://github.com/abyss7)) -- 追加された列 `exception_code` で `system.query_log` テーブル。 [\#8770](https://github.com/ClickHouse/ClickHouse/pull/8770) ([Mikhail Korotov](https://github.com/millb)) -- ポート上の有効mysql互換性サーバ `9004` デフォルトのサーバー設定ファイル。 設定の例の固定パスワード生成コマンド。 [\#8771](https://github.com/ClickHouse/ClickHouse/pull/8771) ([ユーリーバラノフ](https://github.com/yurriy)) -- 防止に停止した場合のファイルシステムが読み取り専用になります。 この修正 [\#9094](https://github.com/ClickHouse/ClickHouse/issues/9094) [\#9100](https://github.com/ClickHouse/ClickHouse/pull/9100) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- HTTP POSTクエリで長さが必要な場合は、より良い例外メッセージ。 [\#9453](https://github.com/ClickHouse/ClickHouse/pull/9453) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `_path` と `_file` 仮想列へ `HDFS` と `File` エンジンと `hdfs` と `file` テーブル関数 [\#8489](https://github.com/ClickHouse/ClickHouse/pull/8489) ([Olga Khvostikova](https://github.com/stavrolia)) -- エラーの修正 `Cannot find column` 挿入している間 `MATERIALIZED VIEW` 新しい列がビューの内部テーブルに追加された場合。 [\#8766](https://github.com/ClickHouse/ClickHouse/pull/8766) [\#8788](https://github.com/ClickHouse/ClickHouse/pull/8788) ([vzakaznikov](https://github.com/vzakaznikov)) [\#8788](https://github.com/ClickHouse/ClickHouse/issues/8788) [\#8806](https://github.com/ClickHouse/ClickHouse/pull/8806) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [\#8803](https://github.com/ClickHouse/ClickHouse/pull/8803) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- ネイティブクライアントサーバープロトコルを介して、最終更新後の送信の進行状況を修正(ログなど)。 この問題にのみ一部の第三者ツールを使用するネイティブプロトコルです。 [\#9495](https://github.com/ClickHouse/ClickHouse/pull/9495) ([Azat Khuzhin](https://github.com/azat)) -- 追加システムの指標を追跡する多数のクライアント接続の待機を開始mysqlを使用してプロトコル ([\#9013](https://github.com/ClickHouse/ClickHouse/issues/9013)). [\#9015](https://github.com/ClickHouse/ClickHouse/pull/9015) ([Eugene Klimov](https://github.com/Slach)) -- これからは、httpレスポンスには `X-ClickHouse-Timezone` 同じタイムゾーン値に設定されたヘッダ `SELECT timezone()` 報告する [\#9493](https://github.com/ClickHouse/ClickHouse/pull/9493) ([Denis Glazachev](https://github.com/traceon)) - -#### 性能向上 {#performance-improvement} - -- INとの指標の分析のパフォーマンスを向上させる [\#9261](https://github.com/ClickHouse/ClickHouse/pull/9261) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 論理関数+コードのクリーンアップで、よりシンプルで効率的なコード。 フォローアップへ [\#8718](https://github.com/ClickHouse/ClickHouse/issues/8718) [\#8728](https://github.com/ClickHouse/ClickHouse/pull/8728) ([Alexander Kazakov](https://github.com/Akazz)) -- 全体的なパフォーマンスの向上(5%の範囲で。.200%の影響のクエリをもっと厳しいエイリアシングとc++20特徴です。 [\#9304](https://github.com/ClickHouse/ClickHouse/pull/9304) ([アモスの鳥](https://github.com/amosbird)) -- 比較関数の内部ループのためのより厳密なエイリアシング。 [\#9327](https://github.com/ClickHouse/ClickHouse/pull/9327) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 算術関数の内部ループのより厳密なエイリアシング。 [\#9325](https://github.com/ClickHouse/ClickHouse/pull/9325) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ColumnVector::replicate()の実装は、ColumnConst::convertToFullColumn()が実装されています。 また、定数を具体化する際のテストにも役立ちます。 [\#9293](https://github.com/ClickHouse/ClickHouse/pull/9293) ([Alexander Kazakov](https://github.com/Akazz)) -- 別のマイナーな性能向上へ `ColumnVector::replicate()` (これは `materialize` 機能および高位機能)へのそれ以上の改善 [\#9293](https://github.com/ClickHouse/ClickHouse/issues/9293) [\#9442](https://github.com/ClickHouse/ClickHouse/pull/9442) ([Alexander Kazakov](https://github.com/Akazz)) -- 改善された性能の `stochasticLinearRegression` 集計関数。 このパッチはIntelによって提供されます。 [\#8652](https://github.com/ClickHouse/ClickHouse/pull/8652) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 性能をの改善して下さい `reinterpretAsFixedString` 機能。 [\#9342](https://github.com/ClickHouse/ClickHouse/pull/9342) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ブロックをクライアントに送信しない `Null` フォーマットプロセッサのパイプライン [\#8797](https://github.com/ClickHouse/ClickHouse/pull/8797) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [\#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement} - -- 例外処理は現在、linux用のwindowsサブシステム上で正しく動作します。 見るhttps://github.com/clickhouse-extras/libunwind/pull/3 この修正 [\#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [\#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) -- 置換 `readline` と `replxx` インタラクティブライン編集 `clickhouse-client` [\#8416](https://github.com/ClickHouse/ClickHouse/pull/8416) ([イワン](https://github.com/abyss7)) -- FunctionsComparisonでより良いビルド時間と少ないテンプレートインスタンス化。 [\#9324](https://github.com/ClickHouse/ClickHouse/pull/9324) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- との統合を追加しました `clang-tidy` CIで。 また見なさい [\#6044](https://github.com/ClickHouse/ClickHouse/issues/6044) [\#9566](https://github.com/ClickHouse/ClickHouse/pull/9566) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 今、私たちはリンクを使用して、ciでclickhouse `lld` のために `gcc`. [\#9049](https://github.com/ClickHouse/ClickHouse/pull/9049) ([alesapin](https://github.com/alesapin)) -- するとランダムスレッドのスケジューリングに挿入しな障害の場合 `THREAD_FUZZER_*` 環境変数が設定されます。 これはテストを助ける。 [\#9459](https://github.com/ClickHouse/ClickHouse/pull/9459) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ステートレステストでsecure socketsを有効にす [\#9288](https://github.com/ClickHouse/ClickHouse/pull/9288) ([tavplubix](https://github.com/tavplubix)) -- SPLIT\_SHARED\_LIBRARIES=OFFをより堅牢にする [\#9156](https://github.com/ClickHouse/ClickHouse/pull/9156) ([Azat Khuzhin](https://github.com/azat)) -- 作る “performance\_introspection\_and\_logging” 試験信頼性の高いランダムにサーバーの付かない。 これはCI環境で発生する可能性があります。 また見なさい [\#9515](https://github.com/ClickHouse/ClickHouse/issues/9515) [\#9528](https://github.com/ClickHouse/ClickHouse/pull/9528) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- スタイルチェックでxmlを検証する。 [\#9550](https://github.com/ClickHouse/ClickHouse/pull/9550) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- テストの競合状態を修正 `00738_lock_for_inner_table`. このテストは睡眠に頼った。 [\#9555](https://github.com/ClickHouse/ClickHouse/pull/9555) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 除去性能試験の種類 `once`. このに必要なすべての性能試験の統計比較モード(信頼性の高い). [\#9557](https://github.com/ClickHouse/ClickHouse/pull/9557) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 算術関数のパフォーマンステストを追加。 [\#9326](https://github.com/ClickHouse/ClickHouse/pull/9326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- のための追加された性能試験 `sumMap` と `sumMapWithOverflow` 集計関数。 フォローアップのための [\#8933](https://github.com/ClickHouse/ClickHouse/issues/8933) [\#8947](https://github.com/ClickHouse/ClickHouse/pull/8947) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 確保のスタイルerrorcodesスタイルにチェック。 [\#9370](https://github.com/ClickHouse/ClickHouse/pull/9370) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加スクリプトのための試験。 [\#8796](https://github.com/ClickHouse/ClickHouse/pull/8796) ([alesapin](https://github.com/alesapin)) -- GCC警告を追加する `-Wsuggest-override` すべての場所を見つけて修正するには `override` キーワー [\#8760](https://github.com/ClickHouse/ClickHouse/pull/8760) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- Mac OS Xの下で弱い記号を無視するのは、定義する必要があるためです [\#9538](https://github.com/ClickHouse/ClickHouse/pull/9538) ([削除されたユーザ](https://github.com/ghost)) -- パフォーマンステストでの一部のクエリの実行時間の正規化。 この準備の性能試験との比較モードになります。 [\#9565](https://github.com/ClickHouse/ClickHouse/pull/9565) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クエリテストでpytestをサポートするテストを修正 [\#9062](https://github.com/ClickHouse/ClickHouse/pull/9062) ([イワン](https://github.com/abyss7)) -- をsslの構築とmsan、サーバーな起動時に走行時の状態試験 [\#9531](https://github.com/ClickHouse/ClickHouse/pull/9531) ([tavplubix](https://github.com/tavplubix)) -- テスト結果でのデータベース置換の修正 [\#9384](https://github.com/ClickHouse/ClickHouse/pull/9384) ([イリヤ-ヤツィシン](https://github.com/qoega)) -- の構築に対する修正その他ー [\#9381](https://github.com/ClickHouse/ClickHouse/pull/9381) ([proller](https://github.com/proller)) [\#8755](https://github.com/ClickHouse/ClickHouse/pull/8755) ([proller](https://github.com/proller)) [\#8631](https://github.com/ClickHouse/ClickHouse/pull/8631) ([proller](https://github.com/proller)) -- 追加ディスク部無国籍-と-カバレッジ-テストdocker画像 [\#9213](https://github.com/ClickHouse/ClickHouse/pull/9213) ([Pavel Kovalenko](https://github.com/Jokser)) -- GRPCでビルドするときに、ソースツリー内のファイルを取り除く [\#9588](https://github.com/ClickHouse/ClickHouse/pull/9588) ([アモスの鳥](https://github.com/amosbird)) -- 少し早く構築時間を取り除いsessioncleanerからのコンテキスト sessioncleanerのコードをよりシンプルにする。 [\#9232](https://github.com/ClickHouse/ClickHouse/pull/9232) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Clickhouseテストスクリプトでハングクエリのチェックを更新 [\#8858](https://github.com/ClickHouse/ClickHouse/pull/8858) ([Alexander Kazakov](https://github.com/Akazz)) -- リポジトリか [\#8843](https://github.com/ClickHouse/ClickHouse/pull/8843) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- から数学perftestsの変更タイプ `once` に `loop`. [\#8783](https://github.com/ClickHouse/ClickHouse/pull/8783) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 追加docker画像を構築ィコードのブラウザのhtmlレポート当社のコードベース. [\#8781](https://github.com/ClickHouse/ClickHouse/pull/8781) ([alesapin](https://github.com/alesapin))見る [Woboqコードブラウザ](https://clickhouse.tech/codebrowser/html_report///ClickHouse/dbms/src/index.html) -- MSanの下でいくつかのテストの失敗を抑制. [\#8780](https://github.com/ClickHouse/ClickHouse/pull/8780) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- スピードアップ “exception while insert” テスト。 このテス [\#8711](https://github.com/ClickHouse/ClickHouse/pull/8711) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 更新 `libcxx` と `libcxxabi` マスターに。 準備のために [\#9304](https://github.com/ClickHouse/ClickHouse/issues/9304) [\#9308](https://github.com/ClickHouse/ClickHouse/pull/9308) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- フラッキーテストの修正 `00910_zookeeper_test_alter_compression_codecs`. [\#9525](https://github.com/ClickHouse/ClickHouse/pull/9525) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 清掃は複製リンカのフラグがあります。 リンカーが予期しないシンボルを検索しないことを確認します。 [\#9433](https://github.com/ClickHouse/ClickHouse/pull/9433) ([アモスの鳥](https://github.com/amosbird)) -- 追加 `clickhouse-odbc` テスト画像にドライバ。 これは、独自のODBCドライバを経由してClickHouseとClickHouseの相互作用をテストすることができます。 [\#9348](https://github.com/ClickHouse/ClickHouse/pull/9348) ([フィリモノフ](https://github.com/filimonov)) -- 単体テストでいくつかのバグを修正。 [\#9047](https://github.com/ClickHouse/ClickHouse/pull/9047) ([alesapin](https://github.com/alesapin)) -- 有効 `-Wmissing-include-dirs` CMakeスクリプトエラーの結果として、すべての既存のインクルードを排除するGCC警告 [\#8704](https://github.com/ClickHouse/ClickHouse/pull/8704) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- クエリプ これは [\#9049](https://github.com/ClickHouse/ClickHouse/issues/9049) [\#9144](https://github.com/ClickHouse/ClickHouse/pull/9144) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Opensslを上流のマスターに更新します。 メッセージでTLS接続が失敗する問題を修正しました `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error` と `SSL Exception: error:2400006E:random number generator::error retrieving entropy`. この問題はバージョン20.1に存在していました。 [\#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- サーバーのdockerfileの更新 [\#8893](https://github.com/ClickHouse/ClickHouse/pull/8893) ([Ilya Mazaev](https://github.com/ne-ray)) -- ビルド-gcc-from-sourcesスクリプトのマイナーな修正 [\#8774](https://github.com/ClickHouse/ClickHouse/pull/8774) ([Michael Nacharov](https://github.com/mnach)) -- 置換 `numbers` に `zeros` どこperftestsで `number` 列は使用されません。 これはよりきれいなテスト結果につながります。 [\#9600](https://github.com/ClickHouse/ClickHouse/pull/9600) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定しスタックオーバーフローされる際に問題が起きた場合、利用initializer\_list列コンストラクタ. [\#9367](https://github.com/ClickHouse/ClickHouse/pull/9367) ([削除されたユーザ](https://github.com/ghost)) -- Libdkafkaをv1.3.0にアップグレードします。 バンドル有効 `rdkafka` と `gsasl` Mac OS X上のライブラリ [\#9000](https://github.com/ClickHouse/ClickHouse/pull/9000) ([Andrew Onyshchuk](https://github.com/oandrew)) -- GCC9.2.0でのビルド修正 [\#9306](https://github.com/ClickHouse/ClickHouse/pull/9306) ([vxider](https://github.com/Vxider)) - -## ClickHouseリリースv20.1 {#clickhouse-release-v20-1} - -### ClickHouseリリリースv20.1.8.41,2020-03-20 {#clickhouse-release-v20-1-8-41-2020-03-20} - -#### バグ修正 {#bug-fix-3} - -- 可能永久修正 `Cannot schedule a task` エラー(ハンドルされていない例外が原因で `ParallelAggregatingBlockInputStream::Handler::onFinish/onFinishThread`). この修正 [\#6833](https://github.com/ClickHouse/ClickHouse/issues/6833). [\#9154](https://github.com/ClickHouse/ClickHouse/pull/9154) ([Azat Khuzhin](https://github.com/azat)) -- 過度のメモリ消費を修正 `ALTER` クエリ(突然変異)。 この修正 [\#9533](https://github.com/ClickHouse/ClickHouse/issues/9533) と [\#9670](https://github.com/ClickHouse/ClickHouse/issues/9670). [\#9754](https://github.com/ClickHouse/ClickHouse/pull/9754) ([alesapin](https://github.com/alesapin)) -- 外部辞書のddlにバッククォートのバグを修正しました。 この修正 [\#9619](https://github.com/ClickHouse/ClickHouse/issues/9619). [\#9734](https://github.com/ClickHouse/ClickHouse/pull/9734) ([alesapin](https://github.com/alesapin)) - -### ClickHouseリリリースv20.1.7.38,2020-03-18 {#clickhouse-release-v20-1-7-38-2020-03-18} - -#### バグ修正 {#bug-fix-4} - -- 固定誤った内部関数名のための `sumKahan` と `sumWithOverflow`. 先頭に立って例外がこの機能をリモートます。 [\#9636](https://github.com/ClickHouse/ClickHouse/pull/9636) ([Azat Khuzhin](https://github.com/azat)). この問題はすべてClickHouseのリリースにありました。 -- 許可 `ALTER ON CLUSTER` の `Distributed` 内部レプリケーショ この修正 [\#3268](https://github.com/ClickHouse/ClickHouse/issues/3268). [\#9617](https://github.com/ClickHouse/ClickHouse/pull/9617) ([品生2](https://github.com/shinoi2)). この問題はすべてClickHouseのリリースにありました。 -- 可能な例外を修正 `Size of filter doesn't match size of column` と `Invalid number of rows in Chunk` で `MergeTreeRangeReader`. 実行中に表示される可能性があります `PREWHERE` いくつかのケースでは。 修正 [\#9132](https://github.com/ClickHouse/ClickHouse/issues/9132). [\#9612](https://github.com/ClickHouse/ClickHouse/pull/9612) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 次のような単純な算術式を書くと、タイムゾーンが保持されないという問題を修正しました `time + 1` (次のような表現とは対照的に `time + INTERVAL 1 SECOND`). この修正 [\#5743](https://github.com/ClickHouse/ClickHouse/issues/5743). [\#9323](https://github.com/ClickHouse/ClickHouse/pull/9323) ([alexey-milovidov](https://github.com/alexey-milovidov)). この問題はすべてClickHouseのリリースにありました。 -- 次のような単純な循環エイリアスを持つ列を作成または追加することはできません `a DEFAULT b, b DEFAULT a`. [\#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([alesapin](https://github.com/alesapin)) -- Base64でエンコードされた値の末尾にパディングが不正な形式になる場合がある問題を修正しました。 更新base64ライブラリ。 この修正 [\#9491](https://github.com/ClickHouse/ClickHouse/issues/9491)、閉じます [\#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [\#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の破壊でデータレースを修正 `Poco::HTTPServer`. どこの場合のサーバを起動直ちに停止しております。 [\#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 可能なクラッシュ/間違った行数を修正 `LIMIT n WITH TIES` n行目に等しい行がたくさんあるとき。 [\#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([tavplubix](https://github.com/tavplubix)) -- 列ttlsによるチェックサムの不一致を修正しました。 [\#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([アントン-ポポフ](https://github.com/CurtizJ)) -- ユーザーが `ALTER MODIFY SETTING` 古いformatedのため `MergeTree` テーブルエンジン家族。 [\#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([alesapin](https://github.com/alesapin)) -- 今度は、突然変異をより頻繁に確定しようとします。 [\#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([alesapin](https://github.com/alesapin)) -- レプリケーションプロト [\#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [\#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([alesapin](https://github.com/alesapin)) -- 配列型のbloom\_filterインデックスのnot(has())を修正しました。 [\#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([achimbabcomment](https://github.com/achimbab)) -- の動作を修正しました `match` と `extract` haystackにゼロバイトがある場合の関数。 Haystackが一定の場合、その動作は間違っていました。 この修正 [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([alexey-milovidov](https://github.com/alexey-milovidov)) [\#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-1} - -- 例外処理は現在、linux用のwindowsサブシステム上で正しく動作します。 見るhttps://github.com/clickhouse-extras/libunwind/pull/3 この修正 [\#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [\#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) - -### ClickHouseリリリースv20.1.6.30,2020-03-05 {#clickhouse-release-v20-1-6-30-2020-03-05} - -#### バグ修正 {#bug-fix-5} - -- 圧縮時にデータの非互換性を修正する `T64` コーデック。 - [\#9039](https://github.com/ClickHouse/ClickHouse/pull/9039) [(abyss7)](https://github.com/abyss7) -- 一つのスレッドでmergetreeテーブルから読み込み中の範囲の順序を修正しました。 修正 [\#8964](https://github.com/ClickHouse/ClickHouse/issues/8964). - [\#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) [(CurtizJ)](https://github.com/CurtizJ) -- で可能なsegfaultを修正 `MergeTreeRangeReader`,実行中 `PREWHERE`. 修正 [\#9064](https://github.com/ClickHouse/ClickHouse/issues/9064). - [\#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) [(CurtizJ)](https://github.com/CurtizJ) -- 修正 `reinterpretAsFixedString` 戻るには `FixedString` 代わりに `String`. - [\#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) [(oandrew)](https://github.com/oandrew) -- 修正 `joinGet` null可能な戻り値の型を指定します。 修正 [\#8919](https://github.com/ClickHouse/ClickHouse/issues/8919) - [\#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) [(アモスバード)](https://github.com/amosbird) -- ファズテストとbittestall/bittestany関数の不正な動作を修正しました。 - [\#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) [(アレクセイ-ミロビドフ)](https://github.com/alexey-milovidov) -- Haystackにゼロバイトがある場合、match関数とextract関数の動作を修正しました。 Haystackが一定の場合、その動作は間違っていました。 修正 [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) - [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) [(アレクセイ-ミロビドフ)](https://github.com/alexey-milovidov) -- 非厳密に単調な関数索引が使用されている場合の逆述語の実行を修正しました。 修正 [\#9034](https://github.com/ClickHouse/ClickHouse/issues/9034) - [\#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) [(Akazz)](https://github.com/Akazz) -- 書き換えを許可する `CROSS` に `INNER JOIN` もしあれば `[NOT] LIKE` 演算子in `WHERE` セクション。 修正 [\#9191](https://github.com/ClickHouse/ClickHouse/issues/9191) - [\#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) [(4tus2)](https://github.com/4ertus2) -- ログエンジンを持つテーブルの最初の列をエイリアスにする。 - [\#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) [(abyss7)](https://github.com/abyss7) -- カンマの結合を許可する `IN()` 中に 修正 [\#7314](https://github.com/ClickHouse/ClickHouse/issues/7314). - [\#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) [(4tus2)](https://github.com/4ertus2) -- 改善する `ALTER MODIFY/ADD` クエリロジック。 今はできません `ADD` タイプのない列, `MODIFY` デフォルトの式では、列の型は変更されません。 `MODIFY` 型は既定の式の値を緩めません。 修正 [\#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). - [\#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) [(alesapin)](https://github.com/alesapin) -- 既に行われた変異は、ステータスis\_done=0を持つことができたときに、突然変異の終了を修正。 - [\#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) [(alesapin)](https://github.com/alesapin) -- サポート “Processors” システムのため数字とシステム.numbers\_mt. これはまたバグを修正します `max_execution_time` 尊重されていません。 - [\#7796](https://github.com/ClickHouse/ClickHouse/pull/7796) [(KochetovNicolai)](https://github.com/KochetovNicolai) -- の間違ったカウントを修正 `DictCacheKeysRequestedFound` メトリック。 - [\#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) [(nikitamikhaylov)](https://github.com/nikitamikhaylov) -- ストレージポリシーのチェックを追加 `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE` 合がデータの一部になり、再起動後の防止ClickHouse。 - [\#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) [(エキシーン)](https://github.com/excitoon) -- 固定ubsanレポートで `MergeTreeIndexSet`. この修正 [\#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) - [\#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) [(アレクセイ-ミロビドフ)](https://github.com/alexey-milovidov) -- BlockIOで可能なdataraceを修正. - [\#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) [(KochetovNicolai)](https://github.com/KochetovNicolai) -- のサポート `UInt64` JSON関連の関数のInt64に収まらない数値。 更新 `SIMDJSON` マスターに。 この修正 [\#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) - [\#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) [(アレクセイ-ミロビドフ)](https://github.com/alexey-milovidov) -- 具合を修正しましたが、金額のフリースペースが正しく計算されませんが、データディレクトリに取り付けには別の装置です。 デフォルトのディスクの計算には無料のスペースからデータのサブディレクトリの. この修正 [\#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) - [\#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) [(ミルブ)](https://github.com/millb) -- メッセージでtls接続が失敗する場合の問題を修正しました `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error and SSL Exception: error:2400006E:random number generator::error retrieving entropy.` Opensslを上流のマスターに更新します。 - [\#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) [(アレクセイ-ミロビドフ)](https://github.com/alexey-milovidov) -- 実行時期 `CREATE` クエリー、倍定表現のストレージエンジンの引数です。 空のデータベース名を現在のデータベ 修正 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). また、ClickHouseDictionarySourceのローカルアドレスのチェックを修正しました。 - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) -- Segfaultを修正する `StorageMerge` これは、StorageFileから読み込むときに発生します。 - [\#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) [(tabplubix)](https://github.com/tavplubix) -- データを失うのを防ぐ `Kafka` まれに、接尾辞を読んだ後でコミットする前に例外が発生した場合。 修正 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). 関連: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(フィリモノフ)](https://github.com/filimonov) -- のを修正した。先サーバを終了しようとした場合に使用/drop `Kafka` テーブル作成されたパラメータ。 修正 [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). 組み込み [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(フィリモノフ)](https://github.com/filimonov) - -#### 新しい機能 {#new-feature-1} - -- 追加 `deduplicate_blocks_in_dependent_materialized_views` マテリアライズドビューを持つテーブルへの冪等挿入の動作を制御するオプション。 この新機能は、Altinityからの特別な要求によってbugfixリリースに追加されました。 - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) - -### ClickHouseリリースv20.1.2.4,2020-01-22 {#clickhouse-release-v20-1-2-4-2020-01-22} - -#### 下位互換性のない変更 {#backward-incompatible-change-1} - -- 設定を行う `merge_tree_uniform_read_distribution` 廃止されました。 サーバーはこの設定を認識しますが、効果はありません。 [\#8308](https://github.com/ClickHouse/ClickHouse/pull/8308) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 関数の戻り値の型を変更しました `greatCircleDistance` に `Float32` なぜなら今計算の結果は `Float32`. [\#7993](https://github.com/ClickHouse/ClickHouse/pull/7993) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- これで、クエリパラメータが “escaped” フォーマット。 たとえば、文字列を渡すには `ab` あなたは `a\tb` または `a\b` とそれぞれ, `a%5Ctb` または `a%5C%09b` URLで。 これは、NULLを渡す可能性を追加するために必要です `\N`. この修正 [\#7488](https://github.com/ClickHouse/ClickHouse/issues/7488). [\#8517](https://github.com/ClickHouse/ClickHouse/pull/8517) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 有効 `use_minimalistic_part_header_in_zookeeper` のための設定 `ReplicatedMergeTree` デフォルトでは。 このことを大幅に削減量のデータが保存されて飼育係. この設定はバージョン19.1以降でサポートされており、半年以上問題なく複数のサービスで本番環境で使用されています。 19.1より古いバージョンにダウングレードできる場合は、この設定を無効にします。 [\#6850](https://github.com/ClickHouse/ClickHouse/pull/6850) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- データの飛び設計生産準備、デフォルトで有効です. 設定 `allow_experimental_data_skipping_indices`, `allow_experimental_cross_to_join_conversion` と `allow_experimental_multiple_joins_emulation` 今は時代遅れであり、何もしません。 [\#7974](https://github.com/ClickHouse/ClickHouse/pull/7974) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 新規追加 `ANY JOIN` のための論理 `StorageJoin` と一貫した `JOIN` オペレーション 動作を変更せずにアップグレードするには、 `SETTINGS any_join_distinct_right_table_keys = 1` エンジンにテーブルを追加のメタデータを再現これらのテーブル後のアップグレードを開始します。 [\#8400](https://github.com/ClickHouse/ClickHouse/pull/8400) ([Artem Zuikov](https://github.com/4ertus2)) -- ログ設定の変更を適用するには、サーバーを再起動する必要があります。 これは、サーバーが削除されたログファイルにログを記録するバグを回避するための一時的な回避策です。 [\#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [\#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -#### 新しい機能 {#new-feature-2} - -- パーツパスに関する情報を追加 `system.merges`. [\#8043](https://github.com/ClickHouse/ClickHouse/pull/8043) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 実行する機能を追加 `SYSTEM RELOAD DICTIONARY` でクエリ `ON CLUSTER` モード。 [\#8288](https://github.com/ClickHouse/ClickHouse/pull/8288) ([ギヨームタッセリー](https://github.com/YiuRULE)) -- 実行する機能を追加 `CREATE DICTIONARY` でのクエリ `ON CLUSTER` モード。 [\#8163](https://github.com/ClickHouse/ClickHouse/pull/8163) ([alesapin](https://github.com/alesapin)) -- 今、ユーザーのプロフィール `users.xml` 継承した複数のデータ。 [\#8343](https://github.com/ClickHouse/ClickHouse/pull/8343) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 追加 `system.stack_trace` テーブルで眺めるスタックトレースのすべてのサーバスレッド)。 これは、開発者がサーバーの状態をイントロスペクトするのに便利です。 この修正 [\#7576](https://github.com/ClickHouse/ClickHouse/issues/7576). [\#8344](https://github.com/ClickHouse/ClickHouse/pull/8344) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `DateTime64` 設定可能な秒未満の精度を持つデータ型。 [\#7170](https://github.com/ClickHouse/ClickHouse/pull/7170) ([Vasily Nemkov](https://github.com/Enmk)) -- テーブル関数の追加 `clusterAllReplicas` ることのできるクエリのすべてのノードのクラスター [\#8493](https://github.com/ClickHouse/ClickHouse/pull/8493) ([キラン-スンカリ](https://github.com/kiransunkari)) -- 集計関数の追加 `categoricalInformationValue` これは、離散フィーチャの情報値を計算します。 [\#8117](https://github.com/ClickHouse/ClickHouse/pull/8117) ([hcz](https://github.com/hczhcz)) -- データファイルの解析を高速化 `CSV`, `TSV` と `JSONEachRow` それを並行して行うことによって書式。 [\#7780](https://github.com/ClickHouse/ClickHouse/pull/7780) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 機能を追加 `bankerRound` これは、銀行の丸めを実行します。 [\#8112](https://github.com/ClickHouse/ClickHouse/pull/8112) ([hcz](https://github.com/hczhcz)) -- 地域名の埋め込み辞書でより多くの言語をサポート: ‘ru’, ‘en’, ‘ua’, ‘uk’, ‘by’, ‘kz’, ‘tr’, ‘de’, ‘uz’, ‘lv’, ‘lt’, ‘et’, ‘pt’, ‘he’, ‘vi’. [\#8189](https://github.com/ClickHouse/ClickHouse/pull/8189) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- の一貫性の改善 `ANY JOIN` ロジック。 さて `t1 ANY LEFT JOIN t2` 等しい `t2 ANY RIGHT JOIN t1`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -- 設定を追加 `any_join_distinct_right_table_keys` これは古い動作を可能にします `ANY INNER JOIN`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -- 新規追加 `SEMI` と `ANTI JOIN`. 古い `ANY INNER JOIN` 行動として `SEMI LEFT JOIN`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `Distributed` の形式 `File` エンジンと `file` から読むことを可能にするテーブル機能 `.bin` によって生成されたファイル `Distributed` テーブル。 [\#8535](https://github.com/ClickHouse/ClickHouse/pull/8535) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- オプションのreset column引数を追加する `runningAccumulate` これにより、各新しいキー値の集計結果をリセットできます。 [\#8326](https://github.com/ClickHouse/ClickHouse/pull/8326) ([Sergey Kononenko](https://github.com/kononencheg)) -- PrometheusエンドポイントとしてClickHouseを使用する機能を追加します。 [\#7900](https://github.com/ClickHouse/ClickHouse/pull/7900) ([vdimir](https://github.com/Vdimir)) -- セクションを追加 `` で `config.xml` の制約が許されたアイテムのリモートテーブルエンジンとテーブル機能 `URL`, `S3`, `HDFS`. [\#7154](https://github.com/ClickHouse/ClickHouse/pull/7154) ([Mikhail Korotov](https://github.com/millb)) -- 機能追加 `greatCircleAngle` これは度で球の距離を計算します。 [\#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 地球の半径をh3ライブラリと一致するように変更しました。 [\#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `JSONCompactEachRow` と `JSONCompactEachRowWithNamesAndTypes` 入力と出力の形式。 [\#7841](https://github.com/ClickHouse/ClickHouse/pull/7841) ([Mikhail Korotov](https://github.com/millb)) -- ファイル関連のテーブルエンジンとテーブル関数の機能を追加 (`File`, `S3`, `URL`, `HDFS`)読み書きすることができます `gzip` ファイルに基づく追加のエンジンのパラメータまたはファイル拡張子. [\#7840](https://github.com/ClickHouse/ClickHouse/pull/7840) ([Andrey Bodrov](https://github.com/apbodrov)) -- を追加しました `randomASCII(length)` のランダムなセットを持つ文字列を生成する関数 [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 印刷可能な文字。 [\#8401](https://github.com/ClickHouse/ClickHouse/pull/8401) ([バヨネット](https://github.com/BayoNet)) -- 機能追加 `JSONExtractArrayRaw` これは、解析されていないjson配列要素の配列を返します `JSON` 文字列。 [\#8081](https://github.com/ClickHouse/ClickHouse/pull/8081) ([Oleg Matrokhin](https://github.com/errx)) -- 追加 `arrayZip` 等しい長さの複数の配列をタプルの一つの配列に結合することを可能にする関数。 [\#8149](https://github.com/ClickHouse/ClickHouse/pull/8149) ([冬張](https://github.com/zhang2014)) -- 設定に従ってディスク間でデータを移動する機能を追加 `TTL`-のための式 `*MergeTree` テーブルエンジン家族。 [\#8140](https://github.com/ClickHouse/ClickHouse/pull/8140) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 新しい集計関数を追加 `avgWeighted` 加重平均を計算することができます。 [\#7898](https://github.com/ClickHouse/ClickHouse/pull/7898) ([Andrey Bodrov](https://github.com/apbodrov)) -- デフォルトでは、並列解析が有効になりました `TSV`, `TSKV`, `CSV` と `JSONEachRow` フォーマット。 [\#7894](https://github.com/ClickHouse/ClickHouse/pull/7894) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- からいくつかの地理機能を追加 `H3` ライブラリ: `h3GetResolution`, `h3EdgeAngle`, `h3EdgeLength`, `h3IsValid` と `h3kRing`. [\#8034](https://github.com/ClickHouse/ClickHouse/pull/8034) ([コンスタンチン-マランチェフ](https://github.com/hombit)) -- Brotliのサポートを追加しました (`br` ファイル関連のストレージとテーブルの機能で)圧縮。 この修正 [\#8156](https://github.com/ClickHouse/ClickHouse/issues/8156). [\#8526](https://github.com/ClickHouse/ClickHouse/pull/8526) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加 `groupBit*` のための機能 `SimpleAggregationFunction` タイプ。 [\#8485](https://github.com/ClickHouse/ClickHouse/pull/8485) ([ギヨームタッセリー](https://github.com/YiuRULE)) - -#### バグ修正 {#bug-fix-6} - -- とテーブルの名前の変更を修正 `Distributed` エンジン。 修正の問題 [\#7868](https://github.com/ClickHouse/ClickHouse/issues/7868). [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) -- 今辞書サポート `EXPRESSION` 非ClickHouse SQLダイアレクト内の任意の文字列の属性の場合。 [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([alesapin](https://github.com/alesapin)) -- 壊れた修正 `INSERT SELECT FROM mysql(...)` クエリ。 この修正 [\#8070](https://github.com/ClickHouse/ClickHouse/issues/8070) と [\#7960](https://github.com/ClickHouse/ClickHouse/issues/7960). [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) -- エラーの修正 “Mismatch column sizes” デフォルトを挿入する `Tuple` から `JSONEachRow`. この修正 [\#5653](https://github.com/ClickHouse/ClickHouse/issues/5653). [\#8606](https://github.com/ClickHouse/ClickHouse/pull/8606) ([tavplubix](https://github.com/tavplubix)) -- これで、usingの場合に例外がスローされます `WITH TIES` 一緒に `LIMIT BY`. また、使用する機能を追加 `TOP` と `LIMIT BY`. この修正 [\#7472](https://github.com/ClickHouse/ClickHouse/issues/7472). [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- 新鮮なglibcバージョンからの意図しない依存関係を修正 `clickhouse-odbc-bridge` バイナリ [\#8046](https://github.com/ClickHouse/ClickHouse/pull/8046) ([アモスの鳥](https://github.com/amosbird)) -- のチェック機能のバグを修正 `*MergeTree` エンジンファミリー 最後の顆粒と最後のマーク(最終ではない)に等しい量の行がある場合、今度は失敗しません。 [\#8047](https://github.com/ClickHouse/ClickHouse/pull/8047) ([alesapin](https://github.com/alesapin)) -- に挿入を修正 `Enum*` 後の列 `ALTER` 基になる数値型がテーブル指定された型と等しい場合のクエリです。 この修正 [\#7836](https://github.com/ClickHouse/ClickHouse/issues/7836). [\#7908](https://github.com/ClickHouse/ClickHouse/pull/7908) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 許可される非定数負 “size” 関数の引数 `substring`. それは誤って許可されませんでした。 この修正 [\#4832](https://github.com/ClickHouse/ClickHouse/issues/4832). [\#7703](https://github.com/ClickHouse/ClickHouse/pull/7703) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 引数の数が間違って渡されたときにバグを解析する修正 `(O|J)DBC` テーブルエンジン。 [\#7709](https://github.com/ClickHouse/ClickHouse/pull/7709) ([alesapin](https://github.com/alesapin)) -- Syslogにログを送信するときに、実行中のclickhouseプロセスのコマンド名を使用します。 以前のバージョ [\#8460](https://github.com/ClickHouse/ClickHouse/pull/8460) ([Michael Nacharov](https://github.com/mnach)) -- 許可されたホストの修正チェック `localhost`. このPRでは、 [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241). [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([Vitaly Baranov](https://github.com/vitlibar)) -- でレアクラッシュを修正 `argMin` と `argMax` resultが使用されているときの長い文字列引数の関数 `runningAccumulate` 機能。 この修正 [\#8325](https://github.com/ClickHouse/ClickHouse/issues/8325) [\#8341](https://github.com/ClickHouse/ClickHouse/pull/8341) ([恐竜](https://github.com/769344359)) -- とテーブルのメモリオーバーコミットを修正 `Buffer` エンジン。 [\#8345](https://github.com/ClickHouse/ClickHouse/pull/8345) ([Azat Khuzhin](https://github.com/azat)) -- 取ることができる機能の潜在的なバグを修正 `NULL` 引数の一つとして、非NULLを返します。 [\#8196](https://github.com/ClickHouse/ClickHouse/pull/8196) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より良いメトリクス計算のスレッドプールを対象としたバックグラウンドプロセス `MergeTree` テーブルエンジン。 [\#8194](https://github.com/ClickHouse/ClickHouse/pull/8194) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正機能 `IN` 中 `WHERE` 決が行レベルテーブルフィルターがあります。 修正 [\#6687](https://github.com/ClickHouse/ClickHouse/issues/6687) [\#8357](https://github.com/ClickHouse/ClickHouse/pull/8357) ([イワン](https://github.com/abyss7)) -- これで、設定値の整数値が完全に解析されない場合、例外がスローされます。 [\#7678](https://github.com/ClickHouse/ClickHouse/pull/7678) ([Mikhail Korotov](https://github.com/millb)) -- 複数のローカルシャードを持つ分散テーブルへのクエリで集計関数を使用すると例外が修正されました。 [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- Bloom filterは長さゼロの配列を扱うことができ、冗長な計算を実行しません。 [\#8242](https://github.com/ClickHouse/ClickHouse/pull/8242) ([achimbabcomment](https://github.com/achimbab)) -- クライアン `host_regexp` で指定される `users.xml`. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241) ([Vitaly Baranov](https://github.com/vitlibar)) -- 複数の偽陽性につながるあいまいな列チェックを緩和する `JOIN ON` セクション。 [\#8385](https://github.com/ClickHouse/ClickHouse/pull/8385) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定可能なサーバのクラッシュ (`std::terminate`)サーバーがデータを送信または書き込みできない場合 `JSON` または `XML` の値を持つ形式 `String` データ型(必要なデータ型 `UTF-8` 検証)またはBrotliアルゴリズムまたは他のまれなケースで結果データを圧縮するとき。 この修正 [\#7603](https://github.com/ClickHouse/ClickHouse/issues/7603) [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 競合状態の修正 `StorageDistributedDirectoryMonitor` CIによって発見。 この修正 [\#8364](https://github.com/ClickHouse/ClickHouse/issues/8364). [\#8383](https://github.com/ClickHouse/ClickHouse/pull/8383) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 今、背景には、マージ `*MergeTree` テーブルエンジンの家族の保存-保存政策に大量注文しております。 [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) -- Nowテーブルエンジン `Kafka` で適切に動作します `Native` フォーマット。 この修正 [\#6731](https://github.com/ClickHouse/ClickHouse/issues/6731) [\#7337](https://github.com/ClickHouse/ClickHouse/issues/7337) [\#8003](https://github.com/ClickHouse/ClickHouse/issues/8003). [\#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([フィリモノフ](https://github.com/filimonov)) -- ヘッダーを持つ固定形式(のような `CSVWithNames` テーブルエンジンのEOFについて例外を投げていた `Kafka`. [\#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([フィリモノフ](https://github.com/filimonov)) -- の右側の部分にサブクエリからセットを作るとバグを修正しました `IN` セクション。 この修正 [\#5767](https://github.com/ClickHouse/ClickHouse/issues/5767) と [\#2542](https://github.com/ClickHouse/ClickHouse/issues/2542). [\#7755](https://github.com/ClickHouse/ClickHouse/pull/7755) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- ストレージか `File`. [\#7756](https://github.com/ClickHouse/ClickHouse/pull/7756) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- でファイルの固定読み取り `Parquet` 型の列を含む形式 `list`. [\#8334](https://github.com/ClickHouse/ClickHouse/pull/8334) ([マクスラン](https://github.com/maxulan)) -- エラーの修正 `Not found column` 分散クエリの場合 `PREWHERE` サンプリングキーに依存する条件 `max_parallel_replicas > 1`. [\#7913](https://github.com/ClickHouse/ClickHouse/pull/7913) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- エラーの修正 `Not found column` クエリを使用した場合 `PREWHERE` テーブルのエイリアスに依存し、主キー条件のために結果セットは空でした。 [\#7911](https://github.com/ClickHouse/ClickHouse/pull/7911) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 関数の戻り値の型を修正 `rand` と `randConstant` の場合 `Nullable` 引数。 Now関数は常に戻ります `UInt32` そして決して `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 無効述語プッシュダウンのための `WITH FILL` 式。 この修正 [\#7784](https://github.com/ClickHouse/ClickHouse/issues/7784). [\#7789](https://github.com/ClickHouse/ClickHouse/pull/7789) ([冬張](https://github.com/zhang2014)) -- 固定間違った `count()` 結果のための `SummingMergeTree` とき `FINAL` セクションを使用します。 [\#3280](https://github.com/ClickHouse/ClickHouse/issues/3280) [\#7786](https://github.com/ClickHouse/ClickHouse/pull/7786) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- 固定可能な誤った結果常に機能することができます。 そのためのクエリ機能 `version()`, `uptime()`、等。 サーバーごとに異なる定数値を返します。 この修正 [\#7666](https://github.com/ClickHouse/ClickHouse/issues/7666). [\#7689](https://github.com/ClickHouse/ClickHouse/pull/7689) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 間違った結果につながるプッシュダウン述語の最適化の複雑なバグを修正します。 これにより、プッシュダウン述語の最適化に多くの問題が修正されます。 [\#8503](https://github.com/ClickHouse/ClickHouse/pull/8503) ([冬張](https://github.com/zhang2014)) -- でクラッシュを修正 `CREATE TABLE .. AS dictionary` クエリ。 [\#8508](https://github.com/ClickHouse/ClickHouse/pull/8508) ([Azat Khuzhin](https://github.com/azat)) -- いくつかの改善clickhouse文法で `.g4` ファイル。 [\#8294](https://github.com/ClickHouse/ClickHouse/pull/8294) ([タイヤン-リ](https://github.com/taiyang-li)) -- でクラッシュにつながるバグを修正 `JOIN`エンジン付きテーブル付きs `Join`. この修正 [\#7556](https://github.com/ClickHouse/ClickHouse/issues/7556) [\#8254](https://github.com/ClickHouse/ClickHouse/issues/8254) [\#7915](https://github.com/ClickHouse/ClickHouse/issues/7915) [\#8100](https://github.com/ClickHouse/ClickHouse/issues/8100). [\#8298](https://github.com/ClickHouse/ClickHouse/pull/8298) ([Artem Zuikov](https://github.com/4ertus2)) -- 冗長辞書のリロードを修正 `CREATE DATABASE`. [\#7916](https://github.com/ClickHouse/ClickHouse/pull/7916) ([Azat Khuzhin](https://github.com/azat)) -- 読み込み元のストリームの最大数を制限する `StorageFile` と `StorageHDFS`. 修正https://github.com/ClickHouse/ClickHouse/issues/7650。 [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([alesapin](https://github.com/alesapin)) -- バグを修正 `ALTER ... MODIFY ... CODEC` クエリがユーザーの両方を指定しデフォルトの表現-コーデック. 修正 [8593](https://github.com/ClickHouse/ClickHouse/issues/8593). [\#8614](https://github.com/ClickHouse/ClickHouse/pull/8614) ([alesapin](https://github.com/alesapin)) -- 列のバックグラウンドマージでエラーを修正 `SimpleAggregateFunction(LowCardinality)` タイプ。 [\#8613](https://github.com/ClickHouse/ClickHouse/pull/8613) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定型チェックイン機能 `toDateTime64`. [\#8375](https://github.com/ClickHouse/ClickHouse/pull/8375) ([Vasily Nemkov](https://github.com/Enmk)) -- 今、サーバーがクラッシュしない `LEFT` または `FULL JOIN` と参加エンジンと非サポート `join_use_nulls` 設定。 [\#8479](https://github.com/ClickHouse/ClickHouse/pull/8479) ([Artem Zuikov](https://github.com/4ertus2)) -- さて `DROP DICTIONARY IF EXISTS db.dict` クエリが例外をスローしない場合 `db` 存在しない [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([Vitaly Baranov](https://github.com/vitlibar)) -- テーブル関数のクラッシュの修正 (`file`, `mysql`, `remote`)削除への参照の使用によって引き起こされる `IStorage` オブジェクト。 テーブル関数への挿入時に指定された列の不正な解析を修正しました。 [\#7762](https://github.com/ClickHouse/ClickHouse/pull/7762) ([tavplubix](https://github.com/tavplubix)) -- をネットワークとなる前に `clickhouse-server`. この修正 [\#7507](https://github.com/ClickHouse/ClickHouse/issues/7507). [\#8570](https://github.com/ClickHouse/ClickHouse/pull/8570) ([Zhichang Yu](https://github.com/yuzhichang)) -- 安全な接続のためのタイムアウト処理を修正しました。 この修正 [\#8126](https://github.com/ClickHouse/ClickHouse/issues/8126). [\#8128](https://github.com/ClickHouse/ClickHouse/pull/8128) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `clickhouse-copier`'並行作業者間の冗長な競合。 [\#7816](https://github.com/ClickHouse/ClickHouse/pull/7816) ([丁象飛](https://github.com/dingxiangfei2009)) -- たとえその変異バージョンが現在の変異バージョ [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([Zhichang Yu](https://github.com/yuzhichang)) [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([alesapin](https://github.com/alesapin)) -- の冗長コピーを無視する。 `*MergeTree` 別のディスクに移動してサーバーを再起動した後のデータ部分。 [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) -- でクラッシュを修正 `FULL JOIN` と `LowCardinality` で `JOIN` キー。 [\#8252](https://github.com/ClickHouse/ClickHouse/pull/8252) ([Artem Zuikov](https://github.com/4ertus2)) -- Insertクエリで列名を複数回使用することは禁じられています `INSERT INTO tbl (x, y, x)`. この修正 [\#5465](https://github.com/ClickHouse/ClickHouse/issues/5465), [\#7681](https://github.com/ClickHouse/ClickHouse/issues/7681). [\#7685](https://github.com/ClickHouse/ClickHouse/pull/7685) ([alesapin](https://github.com/alesapin)) -- 検出のためのフォールバックを追加しました(論理cpuコアの数を使用して)未知のcpuのための物理cpuコアの数。 この修正 [\#5239](https://github.com/ClickHouse/ClickHouse/issues/5239). [\#7726](https://github.com/ClickHouse/ClickHouse/pull/7726) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `There's no column` 誤差を実現し、エイリアス列あります。 [\#8210](https://github.com/ClickHouse/ClickHouse/pull/8210) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定断つクラッシュ時 `EXISTS` クエリが使用されなかった `TABLE` または `DICTIONARY` 修飾子。 ただのような `EXISTS t`. この修正 [\#8172](https://github.com/ClickHouse/ClickHouse/issues/8172). このバグはバージョン19.17で導入されました。 [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- エラーでまれなバグを修正 `"Sizes of columns doesn't match"` これは、 `SimpleAggregateFunction` コラム [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) -- 空のユーザーバグを修正 `allow_databases` すべてのデータベース(同じ `allow_dictionaries`). [\#7793](https://github.com/ClickHouse/ClickHouse/pull/7793) ([DeifyTheGod](https://github.com/DeifyTheGod)) -- 固定顧客のクラッシュがサーバーで接続しています。 [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) -- 修正 `ORDER BY` 主キー接頭辞と非主キー接尾辞によるソートの場合の動作。 [\#7759](https://github.com/ClickHouse/ClickHouse/pull/7759) ([アントン-ポポフ](https://github.com/CurtizJ)) -- テーブルに修飾列が存在するかどうかを確認します。 この修正 [\#6836](https://github.com/ClickHouse/ClickHouse/issues/6836). [\#7758](https://github.com/ClickHouse/ClickHouse/pull/7758) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定された動作と `ALTER MOVE` merge finishが指定したスーパーパーを移動した直後に実行されます。 修正 [\#8103](https://github.com/ClickHouse/ClickHouse/issues/8103). [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 使用中のサーバーのクラッシュを修正 `UNION` 異なる数の列を持つ。 修正 [\#7279](https://github.com/ClickHouse/ClickHouse/issues/7279). [\#7929](https://github.com/ClickHouse/ClickHouse/pull/7929) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 固定サイズの結果、部分文字列のための機能 `substr` 負のサイズ。 [\#8589](https://github.com/ClickHouse/ClickHouse/pull/8589) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 今、サーバーは `MergeTree` が足りないときは無料のスレッドの背景プールがあります。 [\#8588](https://github.com/ClickHouse/ClickHouse/pull/8588) ([tavplubix](https://github.com/tavplubix)) -- 書式設定にマイナータイプミスを修正 `UNION ALL` AST. [\#7999](https://github.com/ClickHouse/ClickHouse/pull/7999) ([litao91](https://github.com/litao91)) -- 固定間違ったブルームフィルタの負の数の結果。 この修正 [\#8317](https://github.com/ClickHouse/ClickHouse/issues/8317). [\#8566](https://github.com/ClickHouse/ClickHouse/pull/8566) ([冬張](https://github.com/zhang2014)) -- Decompressでバッファオーバーフローの可能性を修正 悪意のあるユーザーで製作した圧縮データが読み後のバッファです。 この問題は、Yandexの情報セキュリティチームのEldar Zaitovによって発見されました。 [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 整数のオーバーフローのために誤った結果を修正 `arrayIntersect`. [\#7777](https://github.com/ClickHouse/ClickHouse/pull/7777) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- さて `OPTIMIZE TABLE` クエリを待ちませんがオフラインのレプリカを行います。 [\#8314](https://github.com/ClickHouse/ClickHouse/pull/8314) ([javi santana](https://github.com/javisantana)) -- 固定 `ALTER TTL` のためのパーサ `Replicated*MergeTree` テーブル。 [\#8318](https://github.com/ClickHouse/ClickHouse/pull/8318) ([Vladimir Chebotarev](https://github.com/excitoon)) -- サーバとクライアン [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) -- 修正 `bitmapAnd` 機能エラーが交差に集約ビットマップおよびスカラービットマップ. [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([越黄](https://github.com/moon03432)) -- 定義をの精製して下さい `ZXid` バグを修正するZooKeeperプログラマーズガイドによると `clickhouse-cluster-copier`. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([丁象飛](https://github.com/dingxiangfei2009)) -- `odbc` テーブル関数は今 `external_table_functions_use_nulls` 設定。 [\#7506](https://github.com/ClickHouse/ClickHouse/pull/7506) ([Vasily Nemkov](https://github.com/Enmk)) -- 稀なデータレースにつながるバグを修正しました。 [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([Alexander Kazakov](https://github.com/Akazz)) -- さて `SYSTEM RELOAD DICTIONARY` 辞書を完全にリロードし、無視します `update_field`. この修正 [\#7440](https://github.com/ClickHouse/ClickHouse/issues/7440). [\#8037](https://github.com/ClickHouse/ClickHouse/pull/8037) ([Vitaly Baranov](https://github.com/vitlibar)) -- Create queryに辞書が存在するかどうかを確認する機能を追加します。 [\#8032](https://github.com/ClickHouse/ClickHouse/pull/8032) ([alesapin](https://github.com/alesapin)) -- 修正 `Float*` 解析 `Values` フォーマット。 この修正 [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817). [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) -- 私たちはいくつかのバックグ `*MergeTree` テーブルエンジン家族。 [\#7873](https://github.com/ClickHouse/ClickHouse/pull/7873) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 固定クラッシュの統合運用がテーブル `SimpleAggregateFunction(LowCardinality)` コラム この修正 [\#8515](https://github.com/ClickHouse/ClickHouse/issues/8515). [\#8522](https://github.com/ClickHouse/ClickHouse/pull/8522) ([Azat Khuzhin](https://github.com/azat)) -- すべてのicuロケールのサポートを復元し、定数式の照合順序を適用する機能を追加します。 また、言語名を追加する `system.collations` テーブル。 [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([alesapin](https://github.com/alesapin)) -- ゼロ最小限の寿命を持つ外部辞書バグを修正しました (`LIFETIME(MIN 0 MAX N)`, `LIFETIME(N)` バックグラウンドで更新しない。 [\#7983](https://github.com/ClickHouse/ClickHouse/pull/7983) ([alesapin](https://github.com/alesapin)) -- 固定したときにクラッシュする場合が外部辞書でclickhouseソースがサブクエリに返します。 [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- エンジンでテーブル内のファイル拡張子の誤った解析を修正 `URL`. この修正 [\#8157](https://github.com/ClickHouse/ClickHouse/issues/8157). [\#8419](https://github.com/ClickHouse/ClickHouse/pull/8419) ([Andrey Bodrov](https://github.com/apbodrov)) -- 修正 `CHECK TABLE` のためのクエリ `*MergeTree` キーのないテーブル。 修正 [\#7543](https://github.com/ClickHouse/ClickHouse/issues/7543). [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([alesapin](https://github.com/alesapin)) -- 固定変換の `Float64` MySQLのタイプに。 [\#8079](https://github.com/ClickHouse/ClickHouse/pull/8079) ([ユーリーバラノフ](https://github.com/yurriy)) -- 今ればいけない完全に落ちてしまったがサーバのクラッシュ、サーバーへの復元とその負荷ます。 [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) -- テーブル機能のクラッシュを修正 `file` 存在しないファイルに挿入している間。 この場合、ファイルが作成され、insertが処理されます。 [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) -- ときに発生する可能性がまれなデッドロックを修正 `trace_log` 有効になっています。 [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([フィリモノフ](https://github.com/filimonov)) -- ほかに異なるタイプで動作する機能を追加 `Date` で `RangeHashed` DDLクエリから作成された外部ディクショナリ。 修正 [7899](https://github.com/ClickHouse/ClickHouse/issues/7899). [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([alesapin](https://github.com/alesapin)) -- ときの修正クラッシュ `now64()` 別の関数の結果で呼び出されます。 [\#8270](https://github.com/ClickHouse/ClickHouse/pull/8270) ([Vasily Nemkov](https://github.com/Enmk)) -- 固定バグ検出クライアントip接続を通じてmysqlワイヤプロトコルです。 [\#7743](https://github.com/ClickHouse/ClickHouse/pull/7743) ([Dmitry Muzyka](https://github.com/dmitriy-myz)) -- 空の配列の処理を修正 `arraySplit` 機能。 この修正 [\#7708](https://github.com/ClickHouse/ClickHouse/issues/7708). [\#7747](https://github.com/ClickHouse/ClickHouse/pull/7747) ([hcz](https://github.com/hczhcz)) -- ときに問題を修正しました `pid-file` 別のランニングの `clickhouse-server` 削除される可能性があります。 [\#8487](https://github.com/ClickHouse/ClickHouse/pull/8487) ([Weiqing Xu](https://github.com/weiqxu)) -- それが持っている場合 `invalidate_query` これは、以前の更新試行時に更新といくつかの例外を停止しました。 [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([alesapin](https://github.com/alesapin)) -- 関数のエラーを修正しました `arrayReduce` それはにつながる可能性 “double free” そして、集計関数combinatorのエラー `Resample` それはメモリリークの原因となります。 集計関数の追加 `aggThrow`. この関数は、テスト目的で使用できます。 [\#8446](https://github.com/ClickHouse/ClickHouse/pull/8446) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 改善 {#improvement-1} - -- での作業時に改善されたロギング `S3` テーブルエンジン。 [\#8251](https://github.com/ClickHouse/ClickHouse/pull/8251) ([Grigory Pervakov](https://github.com/GrigoryPervakov)) -- 印刷ヘルプメッセージがない場合引数が渡された通話の場合 `clickhouse-local`. この修正 [\#5335](https://github.com/ClickHouse/ClickHouse/issues/5335). [\#8230](https://github.com/ClickHouse/ClickHouse/pull/8230) ([Andrey Nagorny](https://github.com/Melancholic)) -- 設定を追加 `mutations_sync` 待つことができます `ALTER UPDATE/DELETE` 同期クエリ。 [\#8237](https://github.com/ClickHouse/ClickHouse/pull/8237) ([alesapin](https://github.com/alesapin)) -- 相対セットアップを許可する `user_files_path` で `config.xml` (同様の方法で `format_schema_path`). [\#7632](https://github.com/ClickHouse/ClickHouse/pull/7632) ([hcz](https://github.com/hczhcz)) -- 変換関数の不正な型の例外を追加するには `-OrZero` 後置。 [\#7880](https://github.com/ClickHouse/ClickHouse/pull/7880) ([Andrey Konyaev](https://github.com/akonyaev90)) -- 分散クエリでシャードに送信するデータのヘッダーの形式を簡素化します。 [\#8044](https://github.com/ClickHouse/ClickHouse/pull/8044) ([Vitaly Baranov](https://github.com/vitlibar)) -- `Live View` テーブルエンジンリファクタリング。 [\#8519](https://github.com/ClickHouse/ClickHouse/pull/8519) ([vzakaznikov](https://github.com/vzakaznikov)) -- DDLクエリから作成された外部ディクショナリのチェックを追加します。 [\#8127](https://github.com/ClickHouse/ClickHouse/pull/8127) ([alesapin](https://github.com/alesapin)) -- エラーの修正 `Column ... already exists` 使用している間 `FINAL` と `SAMPLE` together, e.g. `select count() from table final sample 1/2`. 修正 [\#5186](https://github.com/ClickHouse/ClickHouse/issues/5186). [\#7907](https://github.com/ClickHouse/ClickHouse/pull/7907) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 今の最初の引数を表 `joinGet` 関数はテーブル識別子にすることができます。 [\#7707](https://github.com/ClickHouse/ClickHouse/pull/7707) ([アモスの鳥](https://github.com/amosbird)) -- 使用を許可する `MaterializedView` 上記のサブクエリを使用する `Kafka` テーブル。 [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([フィリモノフ](https://github.com/filimonov)) -- これで、ディスク間の背景移動がseprateスレッドプールを実行します。 [\#7670](https://github.com/ClickHouse/ClickHouse/pull/7670) ([Vladimir Chebotarev](https://github.com/excitoon)) -- `SYSTEM RELOAD DICTIONARY` 今同期的に実行されます。 [\#8240](https://github.com/ClickHouse/ClickHouse/pull/8240) ([Vitaly Baranov](https://github.com/vitlibar)) -- スタックトレース表示の物理アドレス(オフセットオブジェクトファイルの代わりに仮想メモリのアドレスのオブジェクトファイルが読み込まれ). それは使用をの可能にします `addr2line` binaryが独立した位置でASLRがアクティブな場合。 この修正 [\#8360](https://github.com/ClickHouse/ClickHouse/issues/8360). [\#8387](https://github.com/ClickHouse/ClickHouse/pull/8387) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 行レベルのセキュリ: `
`. 修正 [\#5779](https://github.com/ClickHouse/ClickHouse/issues/5779). [\#8381](https://github.com/ClickHouse/ClickHouse/pull/8381) ([イワン](https://github.com/abyss7)) -- さて `cityHash` 機能で動作することができ `Decimal` と `UUID` タイプ。 修正 [\#5184](https://github.com/ClickHouse/ClickHouse/issues/5184). [\#7693](https://github.com/ClickHouse/ClickHouse/pull/7693) ([Mikhail Korotov](https://github.com/millb)) -- アダプティブ粒度の実装後に廃止されたため、システムログから固定インデックス粒度(1024)が削除されました。 [\#7698](https://github.com/ClickHouse/ClickHouse/pull/7698) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 有効なmysqlサーバーの互換性がclickhouseはめずにボタンを使用します。 [\#7852](https://github.com/ClickHouse/ClickHouse/pull/7852) ([ユーリーバラノフ](https://github.com/yurriy)) -- これにより、バッチ内のデータが破損した場合の詳細なエラーが発生します。 [\#7914](https://github.com/ClickHouse/ClickHouse/pull/7914) ([Azat Khuzhin](https://github.com/azat)) -- サポート `DROP DATABASE`, `DETACH TABLE`, `DROP TABLE` と `ATTACH TABLE` のために `MySQL` データベースエンジ [\#8202](https://github.com/ClickHouse/ClickHouse/pull/8202) ([冬張](https://github.com/zhang2014)) -- S3テーブル機能とテーブルエンジンに認証を追加します。 [\#7623](https://github.com/ClickHouse/ClickHouse/pull/7623) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 追加されたチェックの余分な部品 `MergeTree` 異なるディスクでは、未定義のディスクでデータ部分を見逃さないようにするためです。 [\#8118](https://github.com/ClickHouse/ClickHouse/pull/8118) ([Vladimir Chebotarev](https://github.com/excitoon)) -- を、sslをサポートのためにmacをクライアントとサーバーです。 [\#8297](https://github.com/ClickHouse/ClickHouse/pull/8297) ([イワン](https://github.com/abyss7)) -- 今clickhouseできる作品としてmysql連携サーバを参照https://dev.mysql.com/doc/refman/5.7/en/federated-create-server.html). [\#7717](https://github.com/ClickHouse/ClickHouse/pull/7717) ([Maxim Fedotov](https://github.com/MaxFedotov)) -- `clickhouse-client` 今だけ有効にする `bracketed-paste` マルチクエリがオンで、マルチラインがオフの場合。 この修正(\#7757)\[https://github.com/ClickHouse/ClickHouse/issues/7757\]。 [\#7761](https://github.com/ClickHouse/ClickHouse/pull/7761) ([アモスの鳥](https://github.com/amosbird)) -- サポート `Array(Decimal)` で `if` 機能。 [\#7721](https://github.com/ClickHouse/ClickHouse/pull/7721) ([Artem Zuikov](https://github.com/4ertus2)) -- サポート小数で `arrayDifference`, `arrayCumSum` と `arrayCumSumNegative` 機能。 [\#7724](https://github.com/ClickHouse/ClickHouse/pull/7724) ([Artem Zuikov](https://github.com/4ertus2)) -- 追加 `lifetime` コラムへの `system.dictionaries` テーブル。 [\#6820](https://github.com/ClickHouse/ClickHouse/issues/6820) [\#7727](https://github.com/ClickHouse/ClickHouse/pull/7727) ([kekekekule](https://github.com/kekekekule)) -- 改良されたチェックインのための既存の部品の異なるハードディスク `*MergeTree` テーブルエンジン。 アドレス [\#7660](https://github.com/ClickHouse/ClickHouse/issues/7660). [\#8440](https://github.com/ClickHouse/ClickHouse/pull/8440) ([Vladimir Chebotarev](https://github.com/excitoon)) -- との統合 `AWS SDK` のために `S3` 箱から出してすべてのS3の機能を使用することができます相互作用。 [\#8011](https://github.com/ClickHouse/ClickHouse/pull/8011) ([Pavel Kovalenko](https://github.com/Jokser)) -- サブクエリのサポートが追加されました `Live View` テーブル。 [\#7792](https://github.com/ClickHouse/ClickHouse/pull/7792) ([vzakaznikov](https://github.com/vzakaznikov)) -- 使用のための点検 `Date` または `DateTime` からの列 `TTL` 式は削除されました。 [\#7920](https://github.com/ClickHouse/ClickHouse/pull/7920) ([Vladimir Chebotarev](https://github.com/excitoon)) -- ディスクに関する情報が追加された `system.detached_parts` テーブル。 [\#7833](https://github.com/ClickHouse/ClickHouse/pull/7833) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 今すぐ設定 `max_(table|partition)_size_to_drop` 再起動せずに変更することができます。 [\#7779](https://github.com/ClickHouse/ClickHouse/pull/7779) ([Grigory Pervakov](https://github.com/GrigoryPervakov)) -- エラーメッ ユーザーに以下の行を削除しないように依頼する `Stack trace:`. [\#7897](https://github.com/ClickHouse/ClickHouse/pull/7897) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より良いメッセージを読むら `Kafka` 後の様々な形式のエンジン [\#7935](https://github.com/ClickHouse/ClickHouse/issues/7935). [\#8035](https://github.com/ClickHouse/ClickHouse/pull/8035) ([イワン](https://github.com/abyss7)) -- サポートしていないmysqlクライアントとの互換性の向上 `sha2_password` authプラグイン。 [\#8036](https://github.com/ClickHouse/ClickHouse/pull/8036) ([ユーリーバラノフ](https://github.com/yurriy)) -- 支援の列タイプのmysqlサーバーの互換性. [\#7975](https://github.com/ClickHouse/ClickHouse/pull/7975) ([ユーリーバラノフ](https://github.com/yurriy)) -- 実装 `ORDER BY` 最適化のための `Merge`, `Buffer` と `Materilized View` 下になるとストレージ `MergeTree` テーブル。 [\#8130](https://github.com/ClickHouse/ClickHouse/pull/8130) ([アントン-ポポフ](https://github.com/CurtizJ)) -- 今、私たちは常にposixの実装を使用します `getrandom` 古いカーネル(\<3.17)との互換性を改善する。 [\#7940](https://github.com/ClickHouse/ClickHouse/pull/7940) ([アモスの鳥](https://github.com/amosbird)) -- 移動ttlルールの有効な宛先をよりよくチェックします。 [\#8410](https://github.com/ClickHouse/ClickHouse/pull/8410) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 壊れた挿入のバッチのためのよりよい点検 `Distributed` テーブルエンジン。 [\#7933](https://github.com/ClickHouse/ClickHouse/pull/7933) ([Azat Khuzhin](https://github.com/azat)) -- 将来突然変異が処理されなければならない部品名の配列を持つ列を追加する `system.mutations` テーブル。 [\#8179](https://github.com/ClickHouse/ClickHouse/pull/8179) ([alesapin](https://github.com/alesapin)) -- 並列マージプロセッサのソート最適化。 [\#8552](https://github.com/ClickHouse/ClickHouse/pull/8552) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 設定 `mark_cache_min_lifetime` 今は時代遅れで、何もしません。 以前のバージョンでは、マークキャッシュはメモリ内で `mark_cache_size` 内のデータを収容するために、 `mark_cache_min_lifetime` 秒。 それは、メモリ制約のあるシステムでは特に悪いことです。 このリリースをインストールした後にパフォーマンスが低下する場合は、 `mark_cache_size`. [\#8484](https://github.com/ClickHouse/ClickHouse/pull/8484) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 使用する準備 `tid` どこにでも これは次の場合に必要です [\#7477](https://github.com/ClickHouse/ClickHouse/issues/7477). [\#8276](https://github.com/ClickHouse/ClickHouse/pull/8276) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### 性能向上 {#performance-improvement-1} - -- 性能の最適化、プロセッサのパイプライン [\#7988](https://github.com/ClickHouse/ClickHouse/pull/7988) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 非ブロック更新の有効期限が切れたキーキャッシュの辞書(許可を読古い。 [\#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- クリック `-fno-omit-frame-pointer` 世界的に余裕一するものとする。 [\#8097](https://github.com/ClickHouse/ClickHouse/pull/8097) ([アモスの鳥](https://github.com/amosbird)) -- スピードアップ `greatCircleDistance` それのための性能試験を機能し、加えて下さい。 [\#7307](https://github.com/ClickHouse/ClickHouse/pull/7307) ([Olga Khvostikova](https://github.com/stavrolia)) -- 機能のパフォーマンスの向上 `roundDown`. [\#8465](https://github.com/ClickHouse/ClickHouse/pull/8465) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 改善された性能の `max`, `min`, `argMin`, `argMax` のために `DateTime64` データ型。 [\#8199](https://github.com/ClickHouse/ClickHouse/pull/8199) ([Vasily Nemkov](https://github.com/Enmk)) -- 大きい限界および外的な分類の限界のないまたは分類の改善された性能。 [\#8545](https://github.com/ClickHouse/ClickHouse/pull/8545) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 6回までの浮動小数点数の書式設定のパフォーマンスが向上しました。 [\#8542](https://github.com/ClickHouse/ClickHouse/pull/8542) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 改善された性能の `modulo` 機能。 [\#7750](https://github.com/ClickHouse/ClickHouse/pull/7750) ([アモスの鳥](https://github.com/amosbird)) -- 最適化 `ORDER BY` 単一の列キーとのマージ。 [\#8335](https://github.com/ClickHouse/ClickHouse/pull/8335) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より良い実装 `arrayReduce`, `-Array` と `-State` コンビネーター [\#7710](https://github.com/ClickHouse/ClickHouse/pull/7710) ([アモスの鳥](https://github.com/amosbird)) -- さて `PREWHERE` 少なくとも次のように最適化する必要があります `WHERE`. [\#7769](https://github.com/ClickHouse/ClickHouse/pull/7769) ([アモスの鳥](https://github.com/amosbird)) -- 方法を改善する `round` と `roundBankers` 負の数を扱う。 [\#8229](https://github.com/ClickHouse/ClickHouse/pull/8229) ([hcz](https://github.com/hczhcz)) -- デコード性能の向上 `DoubleDelta` と `Gorilla` 大体30-40%のコーデック。 この修正 [\#7082](https://github.com/ClickHouse/ClickHouse/issues/7082). [\#8019](https://github.com/ClickHouse/ClickHouse/pull/8019) ([Vasily Nemkov](https://github.com/Enmk)) -- 改善された性能の `base64` 関連機能。 [\#8444](https://github.com/ClickHouse/ClickHouse/pull/8444) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 機能を追加しました `geoDistance`. それは類似していますに `greatCircleDistance` しかし、WGS-84楕円体モデルに近似を使用します。 両方の機能のパフォーマンスは同じに近いです。 [\#8086](https://github.com/ClickHouse/ClickHouse/pull/8086) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- より速く `min` と `max` 以下のための集計関数 `Decimal` データ型。 [\#8144](https://github.com/ClickHouse/ClickHouse/pull/8144) ([Artem Zuikov](https://github.com/4ertus2)) -- ベクトル化処理 `arrayReduce`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([アモスの鳥](https://github.com/amosbird)) -- `if` 鎖は今最大限に活用されます `multiIf`. [\#8355](https://github.com/ClickHouse/ClickHouse/pull/8355) ([kamalov-ruslan](https://github.com/kamalov-ruslan)) -- パフォーマンスの回帰の修正 `Kafka` 19.15で導入されたテーブルエンジン。 この修正 [\#7261](https://github.com/ClickHouse/ClickHouse/issues/7261). [\#7935](https://github.com/ClickHouse/ClickHouse/pull/7935) ([フィリモノフ](https://github.com/filimonov)) -- 削除 “pie” コード生成 `gcc` からDebianパッケージの時となります。 [\#8483](https://github.com/ClickHouse/ClickHouse/pull/8483) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- データ形式の並列解析 [\#6553](https://github.com/ClickHouse/ClickHouse/pull/6553) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -- 最適化されたパーサーの有効化 `Values` デフォルトでの式の使用 (`input_format_values_deduce_templates_of_expressions=1`). [\#8231](https://github.com/ClickHouse/ClickHouse/pull/8231) ([tavplubix](https://github.com/tavplubix)) - -#### ビルド/テスト/パッケージの改善 {#buildtestingpackaging-improvement-2} - -- ビルドの修正 `ARM` そして、最小限のモードで。 [\#8304](https://github.com/ClickHouse/ClickHouse/pull/8304) ([proller](https://github.com/proller)) -- 追加取材ファイルのフラッシュ用 `clickhouse-server` std::atexitが呼び出されないとき。 も若干の改善にログイン状態試験。 [\#8267](https://github.com/ClickHouse/ClickHouse/pull/8267) ([alesapin](https://github.com/alesapin)) -- ContribのLLVMライブラリを更新します。 OSパッケージからのLLVMの使用を避けます。 [\#8258](https://github.com/ClickHouse/ClickHouse/pull/8258) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- バンドルする `curl` 完全に静かなビルド。 [\#8232](https://github.com/ClickHouse/ClickHouse/pull/8232) [\#8203](https://github.com/ClickHouse/ClickHouse/pull/8203) ([Pavel Kovalenko](https://github.com/Jokser)) -- いくつかを修正 `MemorySanitizer` 警告。 [\#8235](https://github.com/ClickHouse/ClickHouse/pull/8235) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 使用 `add_warning` と `no_warning` マクロ `CMakeLists.txt`. [\#8604](https://github.com/ClickHouse/ClickHouse/pull/8604) ([イワン](https://github.com/abyss7)) -- Minio S3互換オブジェクトのサポートを追加(https://min.io/)より良い統合テストのために。 [\#7863](https://github.com/ClickHouse/ClickHouse/pull/7863) [\#7875](https://github.com/ClickHouse/ClickHouse/pull/7875) ([Pavel Kovalenko](https://github.com/Jokser)) -- インポート `libc` contribへのヘッダー。 ることができる作をより一貫性のあるさまざまなシステムのみ `x86_64-linux-gnu`). [\#5773](https://github.com/ClickHouse/ClickHouse/pull/5773) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 削除 `-fPIC` いくつかの図書館から。 [\#8464](https://github.com/ClickHouse/ClickHouse/pull/8464) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- クリーン `CMakeLists.txt` カールのため。 見るhttps://github.com/ClickHouse/ClickHouse/pull/8011\#issuecomment-569478910 [\#8459](https://github.com/ClickHouse/ClickHouse/pull/8459) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- サイレント警告 `CapNProto` ライブラリ。 [\#8220](https://github.com/ClickHouse/ClickHouse/pull/8220) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 追加の性能試験のため短い文字列を最適化ハッシュテーブル [\#7679](https://github.com/ClickHouse/ClickHouse/pull/7679) ([アモスの鳥](https://github.com/amosbird)) -- 今clickhouseは上に構築されます `AArch64` たとえ `MADV_FREE` は利用できません。 この修正 [\#8027](https://github.com/ClickHouse/ClickHouse/issues/8027). [\#8243](https://github.com/ClickHouse/ClickHouse/pull/8243) ([アモスの鳥](https://github.com/amosbird)) -- 更新 `zlib-ng` メモリ消毒の問題を修正するには. [\#7182](https://github.com/ClickHouse/ClickHouse/pull/7182) [\#8206](https://github.com/ClickHouse/ClickHouse/pull/8206) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- OSパッケージの使用は非常に脆弱で、通常はまったく動作しないため、Linux以外のシステムで内部MySQLライブラリを有効にします。 この修正 [\#5765](https://github.com/ClickHouse/ClickHouse/issues/5765). [\#8426](https://github.com/ClickHouse/ClickHouse/pull/8426) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定構築システムによっては後に可能 `libc++`. これは [\#8374](https://github.com/ClickHouse/ClickHouse/issues/8374). [\#8380](https://github.com/ClickHouse/ClickHouse/pull/8380) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 作る `Field` 方法によりtype-安全なものがあります。。 [\#7386](https://github.com/ClickHouse/ClickHouse/pull/7386) [\#8209](https://github.com/ClickHouse/ClickHouse/pull/8209) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- に不足しているファイルを追加 `libc-headers` サブモジュール [\#8507](https://github.com/ClickHouse/ClickHouse/pull/8507) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 間違った修正 `JSON` パフォーマンステスト出力の引用。 [\#8497](https://github.com/ClickHouse/ClickHouse/pull/8497) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- スタックトレースが表示されます `std::exception` と `Poco::Exception`. 以前のバージョンでは、 `DB::Exception`. これは診断を改善します。 [\#8501](https://github.com/ClickHouse/ClickHouse/pull/8501) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 移植 `clock_gettime` と `clock_nanosleep` 新しいglibc版のため。 [\#8054](https://github.com/ClickHouse/ClickHouse/pull/8054) ([アモスの鳥](https://github.com/amosbird)) -- 有効 `part_log` 開発者のための例の設定で。 [\#8609](https://github.com/ClickHouse/ClickHouse/pull/8609) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- リロードの非同期の性質を修正 `01036_no_superfluous_dict_reload_on_create_database*`. [\#8111](https://github.com/ClickHouse/ClickHouse/pull/8111) ([Azat Khuzhin](https://github.com/azat)) -- 固定コーデック性能テスト。 [\#8615](https://github.com/ClickHouse/ClickHouse/pull/8615) ([Vasily Nemkov](https://github.com/Enmk)) -- インストールスクリプト `.tgz` それらのビルドとドキュメント。 [\#8612](https://github.com/ClickHouse/ClickHouse/pull/8612) [\#8591](https://github.com/ClickHouse/ClickHouse/pull/8591) ([alesapin](https://github.com/alesapin)) -- 古いものを削除 `ZSTD` テスト(2016年に作成され、ZSTDの1.0バージョンが持っていたバグを再現しました)。 この修正 [\#8618](https://github.com/ClickHouse/ClickHouse/issues/8618). [\#8619](https://github.com/ClickHouse/ClickHouse/pull/8619) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- Mac OSカタリナ上の固定ビルド。 [\#8600](https://github.com/ClickHouse/ClickHouse/pull/8600) ([meo](https://github.com/meob)) -- 増加数行のコーデックの性能試験を果たしますのでご連絡ください [\#8574](https://github.com/ClickHouse/ClickHouse/pull/8574) ([Vasily Nemkov](https://github.com/Enmk)) -- デバッグビルドでは、 `LOGICAL_ERROR` アサーションの失敗としての例外は、気付きやすくなります。 [\#8475](https://github.com/ClickHouse/ClickHouse/pull/8475) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 形式関連のパフォーマンステストをより確定的にします。 [\#8477](https://github.com/ClickHouse/ClickHouse/pull/8477) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 更新 `lz4` メモリを修正するには市民の失敗。 [\#8181](https://github.com/ClickHouse/ClickHouse/pull/8181) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 例外処理で既知のmemorysanitizer false positiveを抑制します。 [\#8182](https://github.com/ClickHouse/ClickHouse/pull/8182) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 更新 `gcc` と `g++` バージョン9へ `build/docker/build.sh` [\#7766](https://github.com/ClickHouse/ClickHouse/pull/7766) ([TLightSky](https://github.com/tlightsky)) -- 追加の性能試験場合試験 `PREWHERE` より悪いです `WHERE`. [\#7768](https://github.com/ClickHouse/ClickHouse/pull/7768) ([アモスの鳥](https://github.com/amosbird)) -- ツつィツ姪"ツつ"ツ債ツづュツつケ [\#8621](https://github.com/ClickHouse/ClickHouse/pull/8621) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- からのデータのmemorysanitizerレポートを避けます `libunwind`. [\#8539](https://github.com/ClickHouse/ClickHouse/pull/8539) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 更新 `libc++` 最新バージョンへ。 [\#8324](https://github.com/ClickHouse/ClickHouse/pull/8324) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ソースからのビルドicuライブラリ。 この修正 [\#6460](https://github.com/ClickHouse/ClickHouse/issues/6460). [\#8219](https://github.com/ClickHouse/ClickHouse/pull/8219) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- から切り替え `libressl` に `openssl`. ClickHouseは、この変更後にTLS1.3とSNIをサポートする必要があります。 この修正 [\#8171](https://github.com/ClickHouse/ClickHouse/issues/8171). [\#8218](https://github.com/ClickHouse/ClickHouse/pull/8218) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 固定ubsanレポートを使用する場合 `chacha20_poly1305` SSLから(接続時に発生するhttps://yandex.ru/)。 [\#8214](https://github.com/ClickHouse/ClickHouse/pull/8214) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- デフォルトのパスワードファイ `.deb` linuxディストリビュート。 [\#8075](https://github.com/ClickHouse/ClickHouse/pull/8075) ([proller](https://github.com/proller)) -- 取得のための改善された表現 `clickhouse-server` PID `clickhouse-test`. [\#8063](https://github.com/ClickHouse/ClickHouse/pull/8063) ([Alexander Kazakov](https://github.com/Akazz)) -- Contrib/googletestをv1.10.0に更新しました。 [\#8587](https://github.com/ClickHouse/ClickHouse/pull/8587) ([Alexander Burmak](https://github.com/Alex-Burmak)) -- 。固定スレッドサニアイナイザレポートで `base64` ライブラリ。 また、このライブラリを最新バージョンに更新しましたが、問題はありません。 この修正 [\#8397](https://github.com/ClickHouse/ClickHouse/issues/8397). [\#8403](https://github.com/ClickHouse/ClickHouse/pull/8403) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 修正 `00600_replace_running_query` プロセッサの場合。 [\#8272](https://github.com/ClickHouse/ClickHouse/pull/8272) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- サポートの削除 `tcmalloc` 作るため `CMakeLists.txt` もっと簡単に [\#8310](https://github.com/ClickHouse/ClickHouse/pull/8310) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- リリースgccは今使用ビルド `libc++` 代わりに `libstdc++`. 最近 `libc++` clangでのみ使用されました。 これにより、ビルド構成の一貫性と移植性が向上します。 [\#8311](https://github.com/ClickHouse/ClickHouse/pull/8311) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- MemorySanitizerでビルドするためのICUライブラリを有効にします。 [\#8222](https://github.com/ClickHouse/ClickHouse/pull/8222) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 抑制する警告から `CapNProto` ライブラリ。 [\#8224](https://github.com/ClickHouse/ClickHouse/pull/8224) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- のためのコードの特別なケースを削除 `tcmalloc` サポートされなくなったからです [\#8225](https://github.com/ClickHouse/ClickHouse/pull/8225) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- CIカバレッジタスクでは、カバレッジレポートを保存できるようにサーバーを正常に終了します。 これは、我々が最近見てきた不完全な報道レポートを修正します。 [\#8142](https://github.com/ClickHouse/ClickHouse/pull/8142) ([alesapin](https://github.com/alesapin)) -- すべてのコーデックのパフォーマ `Float64` と `UInt64` 値。 [\#8349](https://github.com/ClickHouse/ClickHouse/pull/8349) ([Vasily Nemkov](https://github.com/Enmk)) -- `termcap` 非常に非難され、さまざまな問題につながる(f.g.missing “up” 帽子およびエコー `^J` マルチラインの代わりに)。 お願い `terminfo` またはバンドル `ncurses`. [\#7737](https://github.com/ClickHouse/ClickHouse/pull/7737) ([アモスの鳥](https://github.com/amosbird)) -- 修正 `test_storage_s3` 統合テスト。 [\#7734](https://github.com/ClickHouse/ClickHouse/pull/7734) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- サポート `StorageFile(, null)` 挿入をブロックを所定のフォーマットでなくファイルを実際に書き込みます。 これは必要な性能試験までを実施。 [\#8455](https://github.com/ClickHouse/ClickHouse/pull/8455) ([アモスの鳥](https://github.com/amosbird)) -- 追加された引数 `--print-time` テストごとに実行時間を出力する機能テスト。 [\#8001](https://github.com/ClickHouse/ClickHouse/pull/8001) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- にアサートを追加しました `KeyCondition` RPNを評価しながら。 これにより、gcc-9からの警告が修正されます。 [\#8279](https://github.com/ClickHouse/ClickHouse/pull/8279) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- ダンプcmakeのオプションci構造を作成する環境が整いました [\#8273](https://github.com/ClickHouse/ClickHouse/pull/8273) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 一部のfatライブラリのデバッグ情報を生成しません。 [\#8271](https://github.com/ClickHouse/ClickHouse/pull/8271) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 作る `log_to_console.xml` それは対話的であるかどうかにかかわらず、常にstderrにログインします。 [\#8395](https://github.com/ClickHouse/ClickHouse/pull/8395) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 除去も未使用の特徴から `clickhouse-performance-test` ツール。 [\#8555](https://github.com/ClickHouse/ClickHouse/pull/8555) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- 今我々はまた検索する `lld-X` 対応を使って `clang-X` バージョン。 [\#8092](https://github.com/ClickHouse/ClickHouse/pull/8092) ([alesapin](https://github.com/alesapin)) -- 寄木細工のビルドの改善。 [\#8421](https://github.com/ClickHouse/ClickHouse/pull/8421) ([マクスラン](https://github.com/maxulan)) -- より多くのgccの警告 [\#8221](https://github.com/ClickHouse/ClickHouse/pull/8221) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- パッケージアーチlinuxすることはできなくなるようで走clickhouseサーバーになります。 [\#8534](https://github.com/ClickHouse/ClickHouse/pull/8534) ([Vladimir Chebotarev](https://github.com/excitoon)) -- プロセッサでテストを修正。 小さな性能の修正。 [\#7672](https://github.com/ClickHouse/ClickHouse/pull/7672) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -- 更新contrib/protobuf. [\#8256](https://github.com/ClickHouse/ClickHouse/pull/8256) ([Matwey V.Kornilov](https://github.com/matwey)) -- 新年のお祝いとしてc++20への切り替えの準備で。 “May the C++ force be with ClickHouse.” [\#8447](https://github.com/ClickHouse/ClickHouse/pull/8447) ([アモスの鳥](https://github.com/amosbird)) - -#### 実験的特徴 {#experimental-feature-1} - -- 実験的な設定を追加しました `min_bytes_to_use_mmap_io`. ることができるreadビッグファイルのコピーをせずにデータをカーネルを使うこと. の設定が無効になってデフォルトです。 推奨しきい値は、mmap/munmapが遅いため、約64MBです。 [\#8520](https://github.com/ClickHouse/ClickHouse/pull/8520) ([alexey-milovidov](https://github.com/alexey-milovidov)) -- アクセス制御システムの一部としてのクォータの変更。 新しいテーブルを追加 `system.quotas`、新しい機能 `currentQuota`, `currentQuotaKey`、新しいSQL構文 `CREATE QUOTA`, `ALTER QUOTA`, `DROP QUOTA`, `SHOW QUOTA`. [\#7257](https://github.com/ClickHouse/ClickHouse/pull/7257) ([Vitaly Baranov](https://github.com/vitlibar)) -- を飛び未設定警告の代わりに投げることができます。 [\#7653](https://github.com/ClickHouse/ClickHouse/pull/7653) ([Vitaly Baranov](https://github.com/vitlibar)) -- アクセス制御システムの一部としての行ポリシーの変更。 新しいテーブルを追加 `system.row_policies`、新しい機能 `currentRowPolicies()`、新しいSQL構文 `CREATE POLICY`, `ALTER POLICY`, `DROP POLICY`, `SHOW CREATE POLICY`, `SHOW POLICIES`. [\#7808](https://github.com/ClickHouse/ClickHouse/pull/7808) ([Vitaly Baranov](https://github.com/vitlibar)) - -#### セキュリティ修正 {#security-fix} - -- テーブル内のディレクトリ構造を読み取る可能性を修正 `File` テーブルエンジン。 この修正 [\#8536](https://github.com/ClickHouse/ClickHouse/issues/8536). [\#8537](https://github.com/ClickHouse/ClickHouse/pull/8537) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## [2019年の変更履歴](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2019.md) {#changelog-for-2019} diff --git a/docs/ja/whats_new/index.md b/docs/ja/whats_new/index.md deleted file mode 100644 index ac27b70b8bd..00000000000 --- a/docs/ja/whats_new/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_folder_title: What's New -toc_priority: 72 ---- - - diff --git a/docs/ja/whats_new/roadmap.md b/docs/ja/whats_new/roadmap.md deleted file mode 100644 index e64d35b1df3..00000000000 --- a/docs/ja/whats_new/roadmap.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 74 -toc_title: "\u30ED\u30FC\u30C9\u30DE\u30C3\u30D7" ---- - -# ロードマップ {#roadmap} - -## Q1 2020 {#q1-2020} - -- ロールベースのアクセス制御 - -## Q2 2020 {#q2-2020} - -- 外部認証サービスとの統合 -- 資源のプールのためのより精密な分布のクラスター能力とユーザー - -{## [元の記事](https://clickhouse.tech/docs/en/roadmap/) ##} diff --git a/docs/ja/whats_new/security_changelog.md b/docs/ja/whats_new/security_changelog.md deleted file mode 100644 index 6e0bd77e2f9..00000000000 --- a/docs/ja/whats_new/security_changelog.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: d734a8e46ddd7465886ba4133bff743c55190626 -toc_priority: 76 -toc_title: "\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u306E\u5909\u66F4\u5C65\u6B74" ---- - -## ClickHouseリリース19.14.3.3で修正、2019-09-10 {#fixed-in-clickhouse-release-19-14-3-3-2019-09-10} - -### CVE-2019-15024 {#cve-2019-15024} - -Аn attacker that has write access to ZooKeeper and who ican run a custom server available from the network where ClickHouse runs, can create a custom-built malicious server that will act as a ClickHouse replica and register it in ZooKeeper. When another replica will fetch data part from the malicious replica, it can force clickhouse-server to write to arbitrary path on filesystem. - -クレジット:yandex情報セキュリティチームのeldar zaitov - -### CVE-2019-16535 {#cve-2019-16535} - -Аn OOB read, OOB write and integer underflow in decompression algorithms can be used to achieve RCE or DoS via native protocol. - -クレジット:yandex情報セキュリティチームのeldar zaitov - -### CVE-2019-16536 {#cve-2019-16536} - -スタックオーバーフローへのdosによっても実行させることができ、悪意のある認証クライアント - -クレジット:yandex情報セキュリティチームのeldar zaitov - -## クリックハウスリリース19.13.6.1で修正、2019-09-20 {#fixed-in-clickhouse-release-19-13-6-1-2019-09-20} - -### CVE-2019-18657 {#cve-2019-18657} - -テーブル機能 `url` この脆弱性により、攻撃者が要求に任意のHTTPヘッダーを挿入することができました。 - -クレジット: [Nikita Tikhomirov](https://github.com/NSTikhomirov) - -## クリックハウスリリース18.12.13で修正、2018-09-10 {#fixed-in-clickhouse-release-18-12-13-2018-09-10} - -### CVE-2018-14672 {#cve-2018-14672} - -機能搭載catboostモデルの可路のフォーカストラバーサル読書任意のファイルをエラーメッセージが返されます。 - -クレジット:yandexの情報セキュリティチームのandrey krasichkov - -## クリックハウスリリース18.10.3、2018-08-13で修正 {#fixed-in-clickhouse-release-18-10-3-2018-08-13} - -### CVE-2018-14671 {#cve-2018-14671} - -unixODBC許容荷重任意の共有オブジェクトからのファイルシステムにおけるリモートでコードが実行の脆弱性が存在します。 - -クレジット:yandexの情報セキュリティチームのandrey krasichkovとevgeny sidorov - -## クリックハウスリリース1.1.54388で修正、2018-06-28 {#fixed-in-clickhouse-release-1-1-54388-2018-06-28} - -### CVE-2018-14668 {#cve-2018-14668} - -“remote” テーブル関数は、任意のシンボルを “user”, “password” と “default\_database” クロスプロトコル要求偽造攻撃につながったフィールド。 - -クレジット:yandexの情報セキュリティチームのandrey krasichkov - -## クリックハウスリリース1.1.54390、2018-07-06で修正 {#fixed-in-clickhouse-release-1-1-54390-2018-07-06} - -### CVE-2018-14669 {#cve-2018-14669} - -ClickHouse MySQLクライアントは “LOAD DATA LOCAL INFILE” 接続されたClickHouseサーバから任意のファイルを読み取る悪意のあるMySQLデータベー - -クレジット:yandexの情報セキュリティチームのandrey krasichkovとevgeny sidorov - -## クリックハウスリリース1.1.54131、2017-01-10で修正されました {#fixed-in-clickhouse-release-1-1-54131-2017-01-10} - -### CVE-2018-14670 {#cve-2018-14670} - -Debパッケージの不適切な構成は、データベースの不正使用につながる可能性があります。 - -クレジット:英国の国家サイバーセキュリティセンター(ncsc) - -{## [元の記事](https://clickhouse.tech/docs/en/security_changelog/) ##} diff --git a/docs/redirects.txt b/docs/redirects.txt index 1a9455355db..13392e5dce5 100644 --- a/docs/redirects.txt +++ b/docs/redirects.txt @@ -1,49 +1,94 @@ -agg_functions/combinators.md query_language/agg_functions/combinators.md -agg_functions/index.md query_language/agg_functions/index.md -agg_functions/parametric_functions.md query_language/agg_functions/parametric_functions.md -agg_functions/reference.md query_language/agg_functions/reference.md -changelog/2017.md whats_new/changelog/2017.md -changelog/2018.md whats_new/changelog/2018.md -changelog/2019.md whats_new/changelog/2019.md -changelog/index.md whats_new/changelog/index.md -data_types/array.md sql_reference/data_types/array.md -data_types/boolean.md sql_reference/data_types/boolean.md -data_types/date.md sql_reference/data_types/date.md -data_types/datetime.md sql_reference/data_types/datetime.md -data_types/datetime64.md sql_reference/data_types/datetime64.md -data_types/decimal.md sql_reference/data_types/decimal.md -data_types/domains/ipv4.md sql_reference/data_types/domains/ipv4.md -data_types/domains/ipv6.md sql_reference/data_types/domains/ipv6.md -data_types/domains/overview.md sql_reference/data_types/domains/overview.md -data_types/enum.md sql_reference/data_types/enum.md -data_types/fixedstring.md sql_reference/data_types/fixedstring.md -data_types/float.md sql_reference/data_types/float.md -data_types/index.md sql_reference/data_types/index.md -data_types/int_uint.md sql_reference/data_types/int_uint.md -data_types/nested_data_structures/aggregatefunction.md sql_reference/data_types/aggregatefunction.md -data_types/nested_data_structures/index.md sql_reference/data_types/nested_data_structures/index.md -data_types/nested_data_structures/nested.md sql_reference/data_types/nested_data_structures/nested.md -data_types/nullable.md sql_reference/data_types/nullable.md -data_types/special_data_types/expression.md sql_reference/data_types/special_data_types/expression.md -data_types/special_data_types/index.md sql_reference/data_types/special_data_types/index.md -data_types/special_data_types/interval.md sql_reference/data_types/special_data_types/interval.md -data_types/special_data_types/nothing.md sql_reference/data_types/special_data_types/nothing.md -data_types/special_data_types/set.md sql_reference/data_types/special_data_types/set.md -data_types/string.md sql_reference/data_types/string.md -data_types/tuple.md sql_reference/data_types/tuple.md -data_types/uuid.md sql_reference/data_types/uuid.md -database_engines/index.md engines/database_engines/index.md -database_engines/lazy.md engines/database_engines/lazy.md -database_engines/mysql.md engines/database_engines/mysql.md -dicts/external_dicts.md query_language/dicts/external_dicts.md -dicts/external_dicts_dict.md query_language/dicts/external_dicts_dict.md -dicts/external_dicts_dict_layout.md query_language/dicts/external_dicts_dict_layout.md -dicts/external_dicts_dict_lifetime.md query_language/dicts/external_dicts_dict_lifetime.md -dicts/external_dicts_dict_sources.md query_language/dicts/external_dicts_dict_sources.md -dicts/external_dicts_dict_structure.md query_language/dicts/external_dicts_dict_structure.md -dicts/index.md query_language/dicts/index.md -dicts/internal_dicts.md query_language/dicts/internal_dicts.md -extended_roadmap.md whats_new/extended_roadmap.md +agg_functions/combinators.md query-language/agg-functions/combinators.md +agg_functions/index.md query-language/agg-functions/index.md +agg_functions/parametric_functions.md query-language/agg-functions/parametric-functions.md +agg_functions/reference.md query-language/agg-functions/reference.md +changelog/2017.md whats-new/changelog/2017.md +changelog/2018.md whats-new/changelog/2018.md +changelog/2019.md whats-new/changelog/2019.md +changelog/index.md whats-new/changelog/index.md +data_types/array.md sql-reference/data-types/array.md +data_types/boolean.md sql-reference/data-types/boolean.md +data_types/date.md sql-reference/data-types/date.md +data_types/datetime.md sql-reference/data-types/datetime.md +data_types/datetime64.md sql-reference/data-types/datetime64.md +data_types/decimal.md sql-reference/data-types/decimal.md +data_types/domains/ipv4.md sql-reference/data-types/domains/ipv4.md +data_types/domains/ipv6.md sql-reference/data-types/domains/ipv6.md +data_types/domains/overview.md sql-reference/data-types/domains/overview.md +data_types/enum.md sql-reference/data-types/enum.md +data_types/fixedstring.md sql-reference/data-types/fixedstring.md +data_types/float.md sql-reference/data-types/float.md +data_types/index.md sql-reference/data-types/index.md +data_types/int_uint.md sql-reference/data-types/int-uint.md +data_types/nested_data_structures/aggregatefunction.md sql-reference/data-types/aggregatefunction.md +data_types/nested_data_structures/index.md sql-reference/data-types/nested-data-structures/index.md +data_types/nested_data_structures/nested.md sql-reference/data-types/nested-data-structures/nested.md +data_types/nullable.md sql-reference/data-types/nullable.md +data_types/special_data_types/expression.md sql-reference/data-types/special-data-types/expression.md +data_types/special_data_types/index.md sql-reference/data-types/special-data-types/index.md +data_types/special_data_types/interval.md sql-reference/data-types/special-data-types/interval.md +data_types/special_data_types/nothing.md sql-reference/data-types/special-data-types/nothing.md +data_types/special_data_types/set.md sql-reference/data-types/special-data-types/set.md +data_types/string.md sql-reference/data-types/string.md +data_types/tuple.md sql-reference/data-types/tuple.md +data_types/uuid.md sql-reference/data-types/uuid.md +database_engines/index.md engines/database-engines/index.md +database_engines/lazy.md engines/database-engines/lazy.md +database_engines/mysql.md engines/database-engines/mysql.md +development/browse_code.md development/browse-code.md +development/build_cross_arm.md development/build-cross-arm.md +development/build_cross_osx.md development/build-cross-osx.md +development/build_osx.md development/build-osx.md +development/developer_instruction.md development/developer-instruction.md +dicts/external_dicts.md query-language/dicts/external-dicts.md +dicts/external_dicts_dict.md query-language/dicts/external-dicts-dict.md +dicts/external_dicts_dict_layout.md query-language/dicts/external-dicts-dict-layout.md +dicts/external_dicts_dict_lifetime.md query-language/dicts/external-dicts-dict-lifetime.md +dicts/external_dicts_dict_sources.md query-language/dicts/external-dicts-dict-sources.md +dicts/external_dicts_dict_structure.md query-language/dicts/external-dicts-dict-structure.md +dicts/index.md query-language/dicts/index.md +dicts/internal_dicts.md query-language/dicts/internal-dicts.md +engines/database_engines/index.md engines/database-engines/index.md +engines/database_engines/lazy.md engines/database-engines/lazy.md +engines/database_engines/mysql.md engines/database-engines/mysql.md +engines/table_engines/index.md engines/table-engines/index.md +engines/table_engines/integrations/hdfs.md engines/table-engines/integrations/hdfs.md +engines/table_engines/integrations/index.md engines/table-engines/integrations/index.md +engines/table_engines/integrations/jdbc.md engines/table-engines/integrations/jdbc.md +engines/table_engines/integrations/kafka.md engines/table-engines/integrations/kafka.md +engines/table_engines/integrations/mysql.md engines/table-engines/integrations/mysql.md +engines/table_engines/integrations/odbc.md engines/table-engines/integrations/odbc.md +engines/table_engines/log_family/index.md engines/table-engines/log-family/index.md +engines/table_engines/log_family/log.md engines/table-engines/log-family/log.md +engines/table_engines/log_family/log_family.md engines/table-engines/log-family/log-family.md +engines/table_engines/log_family/stripelog.md engines/table-engines/log-family/stripelog.md +engines/table_engines/log_family/tinylog.md engines/table-engines/log-family/tinylog.md +engines/table_engines/mergetree_family/aggregatingmergetree.md engines/table-engines/mergetree-family/aggregatingmergetree.md +engines/table_engines/mergetree_family/collapsingmergetree.md engines/table-engines/mergetree-family/collapsingmergetree.md +engines/table_engines/mergetree_family/custom_partitioning_key.md engines/table-engines/mergetree-family/custom-partitioning-key.md +engines/table_engines/mergetree_family/graphitemergetree.md engines/table-engines/mergetree-family/graphitemergetree.md +engines/table_engines/mergetree_family/index.md engines/table-engines/mergetree-family/index.md +engines/table_engines/mergetree_family/mergetree.md engines/table-engines/mergetree-family/mergetree.md +engines/table_engines/mergetree_family/replacingmergetree.md engines/table-engines/mergetree-family/replacingmergetree.md +engines/table_engines/mergetree_family/replication.md engines/table-engines/mergetree-family/replication.md +engines/table_engines/mergetree_family/summingmergetree.md engines/table-engines/mergetree-family/summingmergetree.md +engines/table_engines/mergetree_family/versionedcollapsingmergetree.md engines/table-engines/mergetree-family/versionedcollapsingmergetree.md +engines/table_engines/special/buffer.md engines/table-engines/special/buffer.md +engines/table_engines/special/dictionary.md engines/table-engines/special/dictionary.md +engines/table_engines/special/distributed.md engines/table-engines/special/distributed.md +engines/table_engines/special/external_data.md engines/table-engines/special/external-data.md +engines/table_engines/special/file.md engines/table-engines/special/file.md +engines/table_engines/special/generate.md engines/table-engines/special/generate.md +engines/table_engines/special/index.md engines/table-engines/special/index.md +engines/table_engines/special/join.md engines/table-engines/special/join.md +engines/table_engines/special/materializedview.md engines/table-engines/special/materializedview.md +engines/table_engines/special/memory.md engines/table-engines/special/memory.md +engines/table_engines/special/merge.md engines/table-engines/special/merge.md +engines/table_engines/special/null.md engines/table-engines/special/null.md +engines/table_engines/special/set.md engines/table-engines/special/set.md +engines/table_engines/special/url.md engines/table-engines/special/url.md +engines/table_engines/special/view.md engines/table-engines/special/view.md +extended_roadmap.md whats-new/extended-roadmap.md formats.md interfaces/formats.md formats/capnproto.md interfaces/formats.md formats/csv.md interfaces/formats.md @@ -68,201 +113,338 @@ formats/values.md interfaces/formats.md formats/vertical.md interfaces/formats.md formats/verticalraw.md interfaces/formats.md formats/xml.md interfaces/formats.md -functions/arithmetic_functions.md query_language/functions/arithmetic_functions.md -functions/array_functions.md query_language/functions/array_functions.md -functions/array_join.md query_language/functions/array_join.md -functions/bit_functions.md query_language/functions/bit_functions.md -functions/bitmap_functions.md query_language/functions/bitmap_functions.md -functions/comparison_functions.md query_language/functions/comparison_functions.md -functions/conditional_functions.md query_language/functions/conditional_functions.md -functions/date_time_functions.md query_language/functions/date_time_functions.md -functions/encoding_functions.md query_language/functions/encoding_functions.md -functions/ext_dict_functions.md query_language/functions/ext_dict_functions.md -functions/hash_functions.md query_language/functions/hash_functions.md -functions/higher_order_functions.md query_language/functions/higher_order_functions.md -functions/in_functions.md query_language/functions/in_functions.md -functions/index.md query_language/functions/index.md -functions/ip_address_functions.md query_language/functions/ip_address_functions.md -functions/json_functions.md query_language/functions/json_functions.md -functions/logical_functions.md query_language/functions/logical_functions.md -functions/math_functions.md query_language/functions/math_functions.md -functions/other_functions.md query_language/functions/other_functions.md -functions/random_functions.md query_language/functions/random_functions.md -functions/rounding_functions.md query_language/functions/rounding_functions.md -functions/splitting_merging_functions.md query_language/functions/splitting_merging_functions.md -functions/string_functions.md query_language/functions/string_functions.md -functions/string_replace_functions.md query_language/functions/string_replace_functions.md -functions/string_search_functions.md query_language/functions/string_search_functions.md -functions/type_conversion_functions.md query_language/functions/type_conversion_functions.md -functions/url_functions.md query_language/functions/url_functions.md -functions/ym_dict_functions.md query_language/functions/ym_dict_functions.md +functions/arithmetic_functions.md query-language/functions/arithmetic-functions.md +functions/array_functions.md query-language/functions/array-functions.md +functions/array_join.md query-language/functions/array-join.md +functions/bit_functions.md query-language/functions/bit-functions.md +functions/bitmap_functions.md query-language/functions/bitmap-functions.md +functions/comparison_functions.md query-language/functions/comparison-functions.md +functions/conditional_functions.md query-language/functions/conditional-functions.md +functions/date_time_functions.md query-language/functions/date-time-functions.md +functions/encoding_functions.md query-language/functions/encoding-functions.md +functions/ext_dict_functions.md query-language/functions/ext-dict-functions.md +functions/hash_functions.md query-language/functions/hash-functions.md +functions/higher_order_functions.md query-language/functions/higher-order-functions.md +functions/in_functions.md query-language/functions/in-functions.md +functions/index.md query-language/functions/index.md +functions/ip_address_functions.md query-language/functions/ip-address-functions.md +functions/json_functions.md query-language/functions/json-functions.md +functions/logical_functions.md query-language/functions/logical-functions.md +functions/math_functions.md query-language/functions/math-functions.md +functions/other_functions.md query-language/functions/other-functions.md +functions/random_functions.md query-language/functions/random-functions.md +functions/rounding_functions.md query-language/functions/rounding-functions.md +functions/splitting_merging_functions.md query-language/functions/splitting-merging-functions.md +functions/string_functions.md query-language/functions/string-functions.md +functions/string_replace_functions.md query-language/functions/string-replace-functions.md +functions/string_search_functions.md query-language/functions/string-search-functions.md +functions/type_conversion_functions.md query-language/functions/type-conversion-functions.md +functions/url_functions.md query-language/functions/url-functions.md +functions/ym_dict_functions.md query-language/functions/ym-dict-functions.md +getting_started/example_datasets/amplab_benchmark.md getting-started/example-datasets/amplab-benchmark.md +getting_started/example_datasets/criteo.md getting-started/example-datasets/criteo.md +getting_started/example_datasets/index.md getting-started/example-datasets/index.md +getting_started/example_datasets/metrica.md getting-started/example-datasets/metrica.md +getting_started/example_datasets/nyc_taxi.md getting-started/example-datasets/nyc-taxi.md +getting_started/example_datasets/ontime.md getting-started/example-datasets/ontime.md +getting_started/example_datasets/star_schema.md getting-started/example-datasets/star-schema.md +getting_started/example_datasets/wikistat.md getting-started/example-datasets/wikistat.md +getting_started/index.md getting-started/index.md +getting_started/install.md getting-started/install.md +getting_started/playground.md getting-started/playground.md +getting_started/tutorial.md getting-started/tutorial.md +guides/apply_catboost_model.md guides/apply-catboost-model.md +images/column_oriented.gif images/column-oriented.gif +images/row_oriented.gif images/row-oriented.gif interfaces/http_interface.md interfaces/http.md -interfaces/third-party_client_libraries.md interfaces/third-party/client_libraries.md +interfaces/third-party/client_libraries.md interfaces/third-party/client-libraries.md +interfaces/third-party_client_libraries.md interfaces/third-party/client-libraries.md interfaces/third-party_gui.md interfaces/third-party/gui.md -introduction/features_considered_disadvantages.md introduction/distinctive_features.md +interfaces/third_party/index.md interfaces/third-party/index.md +introduction/distinctive_features.md introduction/distinctive-features.md +introduction/features_considered_disadvantages.md introduction/distinctive-features.md introduction/possible_silly_questions.md faq/general.md introduction/ya_metrika_task.md introduction/history.md -operations/performance/sampling_query_profiler.md operations/optimizing_performance/sampling_query_profiler.md -operations/server_settings/index.md operations/server_configuration_parameters/index.md -operations/server_settings/settings.md operations/server_configuration_parameters/settings.md -operations/table_engines/aggregatingmergetree.md engines/table_engines/mergetree_family/aggregatingmergetree.md -operations/table_engines/buffer.md engines/table_engines/special/buffer.md -operations/table_engines/collapsingmergetree.md engines/table_engines/mergetree_family/collapsingmergetree.md -operations/table_engines/custom_partitioning_key.md engines/table_engines/mergetree_family/custom_partitioning_key.md -operations/table_engines/dictionary.md engines/table_engines/special/dictionary.md -operations/table_engines/distributed.md engines/table_engines/special/distributed.md -operations/table_engines/external_data.md engines/table_engines/special/external_data.md -operations/table_engines/file.md engines/table_engines/special/file.md -operations/table_engines/generate.md engines/table_engines/special/generate.md -operations/table_engines/graphitemergetree.md engines/table_engines/mergetree_family/graphitemergetree.md -operations/table_engines/hdfs.md engines/table_engines/integrations/hdfs.md -operations/table_engines/index.md engines/table_engines/index.md -operations/table_engines/jdbc.md engines/table_engines/integrations/jdbc.md -operations/table_engines/join.md engines/table_engines/special/join.md -operations/table_engines/kafka.md engines/table_engines/integrations/kafka.md -operations/table_engines/log.md engines/table_engines/log_family/log.md -operations/table_engines/log_family.md engines/table_engines/log_family/log_family.md -operations/table_engines/materializedview.md engines/table_engines/special/materializedview.md -operations/table_engines/memory.md engines/table_engines/special/memory.md -operations/table_engines/merge.md engines/table_engines/special/merge.md -operations/table_engines/mergetree.md engines/table_engines/mergetree_family/mergetree.md -operations/table_engines/mysql.md engines/table_engines/integrations/mysql.md -operations/table_engines/null.md engines/table_engines/special/null.md -operations/table_engines/odbc.md engines/table_engines/integrations/odbc.md -operations/table_engines/replacingmergetree.md engines/table_engines/mergetree_family/replacingmergetree.md -operations/table_engines/replication.md engines/table_engines/mergetree_family/replication.md -operations/table_engines/set.md engines/table_engines/special/set.md -operations/table_engines/stripelog.md engines/table_engines/log_family/stripelog.md -operations/table_engines/summingmergetree.md engines/table_engines/mergetree_family/summingmergetree.md -operations/table_engines/tinylog.md engines/table_engines/log_family/tinylog.md -operations/table_engines/url.md engines/table_engines/special/url.md -operations/table_engines/versionedcollapsingmergetree.md engines/table_engines/mergetree_family/versionedcollapsingmergetree.md -operations/table_engines/view.md engines/table_engines/special/view.md +operations/access_rights.md operations/access-rights.md +operations/configuration_files.md operations/configuration-files.md +operations/optimizing_performance/index.md operations/optimizing-performance/index.md +operations/optimizing_performance/sampling_query_profiler.md operations/optimizing-performance/sampling-query-profiler.md +operations/performance/sampling_query_profiler.md operations/optimizing-performance/sampling-query-profiler.md +operations/performance_test.md operations/performance-test.md +operations/server_configuration_parameters/index.md operations/server-configuration-parameters/index.md +operations/server_configuration_parameters/settings.md operations/server-configuration-parameters/settings.md +operations/server_settings/index.md operations/server-configuration-parameters/index.md +operations/server_settings/settings.md operations/server-configuration-parameters/settings.md +operations/settings/constraints_on_settings.md operations/settings/constraints-on-settings.md +operations/settings/permissions_for_queries.md operations/settings/permissions-for-queries.md +operations/settings/query_complexity.md operations/settings/query-complexity.md +operations/settings/settings_profiles.md operations/settings/settings-profiles.md +operations/settings/settings_users.md operations/settings/settings-users.md +operations/system_tables.md operations/system-tables.md +operations/table_engines/aggregatingmergetree.md engines/table-engines/mergetree-family/aggregatingmergetree.md +operations/table_engines/buffer.md engines/table-engines/special/buffer.md +operations/table_engines/collapsingmergetree.md engines/table-engines/mergetree-family/collapsingmergetree.md +operations/table_engines/custom_partitioning_key.md engines/table-engines/mergetree-family/custom-partitioning-key.md +operations/table_engines/dictionary.md engines/table-engines/special/dictionary.md +operations/table_engines/distributed.md engines/table-engines/special/distributed.md +operations/table_engines/external_data.md engines/table-engines/special/external-data.md +operations/table_engines/file.md engines/table-engines/special/file.md +operations/table_engines/generate.md engines/table-engines/special/generate.md +operations/table_engines/graphitemergetree.md engines/table-engines/mergetree-family/graphitemergetree.md +operations/table_engines/hdfs.md engines/table-engines/integrations/hdfs.md +operations/table_engines/index.md engines/table-engines/index.md +operations/table_engines/jdbc.md engines/table-engines/integrations/jdbc.md +operations/table_engines/join.md engines/table-engines/special/join.md +operations/table_engines/kafka.md engines/table-engines/integrations/kafka.md +operations/table_engines/log.md engines/table-engines/log-family/log.md +operations/table_engines/log_family.md engines/table-engines/log-family/log-family.md +operations/table_engines/materializedview.md engines/table-engines/special/materializedview.md +operations/table_engines/memory.md engines/table-engines/special/memory.md +operations/table_engines/merge.md engines/table-engines/special/merge.md +operations/table_engines/mergetree.md engines/table-engines/mergetree-family/mergetree.md +operations/table_engines/mysql.md engines/table-engines/integrations/mysql.md +operations/table_engines/null.md engines/table-engines/special/null.md +operations/table_engines/odbc.md engines/table-engines/integrations/odbc.md +operations/table_engines/replacingmergetree.md engines/table-engines/mergetree-family/replacingmergetree.md +operations/table_engines/replication.md engines/table-engines/mergetree-family/replication.md +operations/table_engines/set.md engines/table-engines/special/set.md +operations/table_engines/stripelog.md engines/table-engines/log-family/stripelog.md +operations/table_engines/summingmergetree.md engines/table-engines/mergetree-family/summingmergetree.md +operations/table_engines/tinylog.md engines/table-engines/log-family/tinylog.md +operations/table_engines/url.md engines/table-engines/special/url.md +operations/table_engines/versionedcollapsingmergetree.md engines/table-engines/mergetree-family/versionedcollapsingmergetree.md +operations/table_engines/view.md engines/table-engines/special/view.md operations/utils/clickhouse-benchmark.md operations/utilities/clickhouse-benchmark.md operations/utils/clickhouse-copier.md operations/utilities/clickhouse-copier.md operations/utils/clickhouse-local.md operations/utilities/clickhouse-local.md operations/utils/index.md operations/utilities/index.md -query_language/agg_functions/combinators.md sql_reference/aggregate_functions/combinators.md -query_language/agg_functions/index.md sql_reference/aggregate_functions/index.md -query_language/agg_functions/parametric_functions.md sql_reference/aggregate_functions/parametric_functions.md -query_language/agg_functions/reference.md sql_reference/aggregate_functions/reference.md -query_language/alter.md sql_reference/statements/alter.md -query_language/create.md sql_reference/statements/create.md -query_language/dicts/external_dicts.md sql_reference/dictionaries/external_dictionaries/external_dicts.md -query_language/dicts/external_dicts_dict.md sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md -query_language/dicts/external_dicts_dict_hierarchical.md sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md -query_language/dicts/external_dicts_dict_layout.md sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md -query_language/dicts/external_dicts_dict_lifetime.md sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md -query_language/dicts/external_dicts_dict_sources.md sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md -query_language/dicts/external_dicts_dict_structure.md sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md -query_language/dicts/index.md sql_reference/dictionaries/index.md -query_language/dicts/internal_dicts.md sql_reference/dictionaries/internal_dicts.md -query_language/functions/arithmetic_functions.md sql_reference/functions/arithmetic_functions.md -query_language/functions/array_functions.md sql_reference/functions/array_functions.md -query_language/functions/array_join.md sql_reference/functions/array_join.md -query_language/functions/bit_functions.md sql_reference/functions/bit_functions.md -query_language/functions/bitmap_functions.md sql_reference/functions/bitmap_functions.md -query_language/functions/comparison_functions.md sql_reference/functions/comparison_functions.md -query_language/functions/conditional_functions.md sql_reference/functions/conditional_functions.md -query_language/functions/date_time_functions.md sql_reference/functions/date_time_functions.md -query_language/functions/encoding_functions.md sql_reference/functions/encoding_functions.md -query_language/functions/ext_dict_functions.md sql_reference/functions/ext_dict_functions.md -query_language/functions/functions_for_nulls.md sql_reference/functions/functions_for_nulls.md -query_language/functions/geo.md sql_reference/functions/geo.md -query_language/functions/hash_functions.md sql_reference/functions/hash_functions.md -query_language/functions/higher_order_functions.md sql_reference/functions/higher_order_functions.md -query_language/functions/in_functions.md sql_reference/functions/in_functions.md -query_language/functions/index.md sql_reference/functions/index.md -query_language/functions/introspection.md sql_reference/functions/introspection.md -query_language/functions/ip_address_functions.md sql_reference/functions/ip_address_functions.md -query_language/functions/json_functions.md sql_reference/functions/json_functions.md -query_language/functions/logical_functions.md sql_reference/functions/logical_functions.md -query_language/functions/machine_learning_functions.md sql_reference/functions/machine_learning_functions.md -query_language/functions/math_functions.md sql_reference/functions/math_functions.md -query_language/functions/other_functions.md sql_reference/functions/other_functions.md -query_language/functions/random_functions.md sql_reference/functions/random_functions.md -query_language/functions/rounding_functions.md sql_reference/functions/rounding_functions.md -query_language/functions/splitting_merging_functions.md sql_reference/functions/splitting_merging_functions.md -query_language/functions/string_functions.md sql_reference/functions/string_functions.md -query_language/functions/string_replace_functions.md sql_reference/functions/string_replace_functions.md -query_language/functions/string_search_functions.md sql_reference/functions/string_search_functions.md -query_language/functions/type_conversion_functions.md sql_reference/functions/type_conversion_functions.md -query_language/functions/url_functions.md sql_reference/functions/url_functions.md -query_language/functions/uuid_functions.md sql_reference/functions/uuid_functions.md -query_language/functions/ym_dict_functions.md sql_reference/functions/ym_dict_functions.md -query_language/index.md sql_reference/index.md -query_language/insert_into.md sql_reference/statements/insert_into.md -query_language/misc.md sql_reference/statements/misc.md -query_language/operators.md sql_reference/operators.md -query_language/queries.md query_language.md -query_language/select.md sql_reference/statements/select.md -query_language/show.md sql_reference/statements/show.md -query_language/syntax.md sql_reference/syntax.md -query_language/system.md sql_reference/statements/system.md -query_language/table_functions/file.md sql_reference/table_functions/file.md -query_language/table_functions/generate.md sql_reference/table_functions/generate.md -query_language/table_functions/hdfs.md sql_reference/table_functions/hdfs.md -query_language/table_functions/index.md sql_reference/table_functions/index.md -query_language/table_functions/input.md sql_reference/table_functions/input.md -query_language/table_functions/jdbc.md sql_reference/table_functions/jdbc.md -query_language/table_functions/merge.md sql_reference/table_functions/merge.md -query_language/table_functions/mysql.md sql_reference/table_functions/mysql.md -query_language/table_functions/numbers.md sql_reference/table_functions/numbers.md -query_language/table_functions/odbc.md sql_reference/table_functions/odbc.md -query_language/table_functions/remote.md sql_reference/table_functions/remote.md -query_language/table_functions/url.md sql_reference/table_functions/url.md -roadmap.md whats_new/roadmap.md -security_changelog.md whats_new/security_changelog.md -system_tables.md operations/system_tables.md -system_tables/system.asynchronous_metrics.md operations/system_tables.md -system_tables/system.clusters.md operations/system_tables.md -system_tables/system.columns.md operations/system_tables.md -system_tables/system.databases.md operations/system_tables.md -system_tables/system.dictionaries.md operations/system_tables.md -system_tables/system.events.md operations/system_tables.md -system_tables/system.functions.md operations/system_tables.md -system_tables/system.merges.md operations/system_tables.md -system_tables/system.metrics.md operations/system_tables.md -system_tables/system.numbers.md operations/system_tables.md -system_tables/system.numbers_mt.md operations/system_tables.md -system_tables/system.one.md operations/system_tables.md -system_tables/system.parts.md operations/system_tables.md -system_tables/system.processes.md operations/system_tables.md -system_tables/system.replicas.md operations/system_tables.md -system_tables/system.settings.md operations/system_tables.md -system_tables/system.tables.md operations/system_tables.md -system_tables/system.zookeeper.md operations/system_tables.md -table_engines.md operations/table_engines.md -table_engines/aggregatingmergetree.md operations/table_engines/aggregatingmergetree.md -table_engines/buffer.md operations/table_engines/buffer.md -table_engines/collapsingmergetree.md operations/table_engines/collapsingmergetree.md -table_engines/custom_partitioning_key.md operations/table_engines/custom_partitioning_key.md -table_engines/dictionary.md operations/table_engines/dictionary.md -table_engines/distributed.md operations/table_engines/distributed.md -table_engines/external_data.md operations/table_engines/external_data.md -table_engines/file.md operations/table_engines/file.md -table_engines/graphitemergetree.md operations/table_engines/graphitemergetree.md -table_engines/index.md operations/table_engines/index.md -table_engines/join.md operations/table_engines/join.md -table_engines/kafka.md operations/table_engines/kafka.md -table_engines/log.md operations/table_engines/log.md -table_engines/materializedview.md operations/table_engines/materializedview.md -table_engines/memory.md operations/table_engines/memory.md -table_engines/merge.md operations/table_engines/merge.md -table_engines/mergetree.md operations/table_engines/mergetree.md -table_engines/mysql.md operations/table_engines/mysql.md -table_engines/null.md operations/table_engines/null.md -table_engines/replacingmergetree.md operations/table_engines/replacingmergetree.md -table_engines/replication.md operations/table_engines/replication.md -table_engines/set.md operations/table_engines/set.md -table_engines/summingmergetree.md operations/table_engines/summingmergetree.md -table_engines/tinylog.md operations/table_engines/tinylog.md -table_engines/view.md operations/table_engines/view.md -table_functions/file.md query_language/table_functions/file.md -table_functions/index.md query_language/table_functions/index.md -table_functions/merge.md query_language/table_functions/merge.md -table_functions/numbers.md query_language/table_functions/numbers.md -table_functions/remote.md query_language/table_functions/remote.md +query_language/agg_functions/combinators.md sql-reference/aggregate-functions/combinators.md +query_language/agg_functions/index.md sql-reference/aggregate-functions/index.md +query_language/agg_functions/parametric_functions.md sql-reference/aggregate-functions/parametric-functions.md +query_language/agg_functions/reference.md sql-reference/aggregate-functions/reference.md +query_language/alter.md sql-reference/statements/alter.md +query_language/create.md sql-reference/statements/create.md +query_language/dicts/external_dicts.md sql-reference/dictionaries/external-dictionaries/external-dicts.md +query_language/dicts/external_dicts_dict.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md +query_language/dicts/external_dicts_dict_hierarchical.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md +query_language/dicts/external_dicts_dict_layout.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md +query_language/dicts/external_dicts_dict_lifetime.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md +query_language/dicts/external_dicts_dict_sources.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md +query_language/dicts/external_dicts_dict_structure.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md +query_language/dicts/index.md sql-reference/dictionaries/index.md +query_language/dicts/internal_dicts.md sql-reference/dictionaries/internal-dicts.md +query_language/functions/arithmetic_functions.md sql-reference/functions/arithmetic-functions.md +query_language/functions/array_functions.md sql-reference/functions/array-functions.md +query_language/functions/array_join.md sql-reference/functions/array-join.md +query_language/functions/bit_functions.md sql-reference/functions/bit-functions.md +query_language/functions/bitmap_functions.md sql-reference/functions/bitmap-functions.md +query_language/functions/comparison_functions.md sql-reference/functions/comparison-functions.md +query_language/functions/conditional_functions.md sql-reference/functions/conditional-functions.md +query_language/functions/date_time_functions.md sql-reference/functions/date-time-functions.md +query_language/functions/encoding_functions.md sql-reference/functions/encoding-functions.md +query_language/functions/ext_dict_functions.md sql-reference/functions/ext-dict-functions.md +query_language/functions/functions_for_nulls.md sql-reference/functions/functions-for-nulls.md +query_language/functions/geo.md sql-reference/functions/geo.md +query_language/functions/hash_functions.md sql-reference/functions/hash-functions.md +query_language/functions/higher_order_functions.md sql-reference/functions/higher-order-functions.md +query_language/functions/in_functions.md sql-reference/functions/in-functions.md +query_language/functions/index.md sql-reference/functions/index.md +query_language/functions/introspection.md sql-reference/functions/introspection.md +query_language/functions/ip_address_functions.md sql-reference/functions/ip-address-functions.md +query_language/functions/json_functions.md sql-reference/functions/json-functions.md +query_language/functions/logical_functions.md sql-reference/functions/logical-functions.md +query_language/functions/machine_learning_functions.md sql-reference/functions/machine-learning-functions.md +query_language/functions/math_functions.md sql-reference/functions/math-functions.md +query_language/functions/other_functions.md sql-reference/functions/other-functions.md +query_language/functions/random_functions.md sql-reference/functions/random-functions.md +query_language/functions/rounding_functions.md sql-reference/functions/rounding-functions.md +query_language/functions/splitting_merging_functions.md sql-reference/functions/splitting-merging-functions.md +query_language/functions/string_functions.md sql-reference/functions/string-functions.md +query_language/functions/string_replace_functions.md sql-reference/functions/string-replace-functions.md +query_language/functions/string_search_functions.md sql-reference/functions/string-search-functions.md +query_language/functions/type_conversion_functions.md sql-reference/functions/type-conversion-functions.md +query_language/functions/url_functions.md sql-reference/functions/url-functions.md +query_language/functions/uuid_functions.md sql-reference/functions/uuid-functions.md +query_language/functions/ym_dict_functions.md sql-reference/functions/ym-dict-functions.md +query_language/index.md sql-reference/index.md +query_language/insert_into.md sql-reference/statements/insert-into.md +query_language/misc.md sql-reference/statements/misc.md +query_language/operators.md sql-reference/operators.md +query_language/queries.md query-language.md +query_language/select.md sql-reference/statements/select.md +query_language/show.md sql-reference/statements/show.md +query_language/syntax.md sql-reference/syntax.md +query_language/system.md sql-reference/statements/system.md +query_language/table_functions/file.md sql-reference/table-functions/file.md +query_language/table_functions/generate.md sql-reference/table-functions/generate.md +query_language/table_functions/hdfs.md sql-reference/table-functions/hdfs.md +query_language/table_functions/index.md sql-reference/table-functions/index.md +query_language/table_functions/input.md sql-reference/table-functions/input.md +query_language/table_functions/jdbc.md sql-reference/table-functions/jdbc.md +query_language/table_functions/merge.md sql-reference/table-functions/merge.md +query_language/table_functions/mysql.md sql-reference/table-functions/mysql.md +query_language/table_functions/numbers.md sql-reference/table-functions/numbers.md +query_language/table_functions/odbc.md sql-reference/table-functions/odbc.md +query_language/table_functions/remote.md sql-reference/table-functions/remote.md +query_language/table_functions/url.md sql-reference/table-functions/url.md +roadmap.md whats-new/roadmap.md +security_changelog.md whats-new/security-changelog.md +sql_reference/aggregate_functions/combinators.md sql-reference/aggregate-functions/combinators.md +sql_reference/aggregate_functions/index.md sql-reference/aggregate-functions/index.md +sql_reference/aggregate_functions/parametric_functions.md sql-reference/aggregate-functions/parametric-functions.md +sql_reference/aggregate_functions/reference.md sql-reference/aggregate-functions/reference.md +sql_reference/ansi.md sql-reference/ansi.md +sql_reference/data_types/aggregatefunction.md sql-reference/data-types/aggregatefunction.md +sql_reference/data_types/array.md sql-reference/data-types/array.md +sql_reference/data_types/boolean.md sql-reference/data-types/boolean.md +sql_reference/data_types/date.md sql-reference/data-types/date.md +sql_reference/data_types/datetime.md sql-reference/data-types/datetime.md +sql_reference/data_types/datetime64.md sql-reference/data-types/datetime64.md +sql_reference/data_types/decimal.md sql-reference/data-types/decimal.md +sql_reference/data_types/domains/index.md sql-reference/data-types/domains/index.md +sql_reference/data_types/domains/ipv4.md sql-reference/data-types/domains/ipv4.md +sql_reference/data_types/domains/ipv6.md sql-reference/data-types/domains/ipv6.md +sql_reference/data_types/domains/overview.md sql-reference/data-types/domains/overview.md +sql_reference/data_types/enum.md sql-reference/data-types/enum.md +sql_reference/data_types/fixedstring.md sql-reference/data-types/fixedstring.md +sql_reference/data_types/float.md sql-reference/data-types/float.md +sql_reference/data_types/index.md sql-reference/data-types/index.md +sql_reference/data_types/int_uint.md sql-reference/data-types/int-uint.md +sql_reference/data_types/nested_data_structures/index.md sql-reference/data-types/nested-data-structures/index.md +sql_reference/data_types/nested_data_structures/nested.md sql-reference/data-types/nested-data-structures/nested.md +sql_reference/data_types/nullable.md sql-reference/data-types/nullable.md +sql_reference/data_types/simpleaggregatefunction.md sql-reference/data-types/simpleaggregatefunction.md +sql_reference/data_types/special_data_types/expression.md sql-reference/data-types/special-data-types/expression.md +sql_reference/data_types/special_data_types/index.md sql-reference/data-types/special-data-types/index.md +sql_reference/data_types/special_data_types/interval.md sql-reference/data-types/special-data-types/interval.md +sql_reference/data_types/special_data_types/nothing.md sql-reference/data-types/special-data-types/nothing.md +sql_reference/data_types/special_data_types/set.md sql-reference/data-types/special-data-types/set.md +sql_reference/data_types/string.md sql-reference/data-types/string.md +sql_reference/data_types/tuple.md sql-reference/data-types/tuple.md +sql_reference/data_types/uuid.md sql-reference/data-types/uuid.md +sql_reference/dictionaries/external_dictionaries/external_dicts.md sql-reference/dictionaries/external-dictionaries/external-dicts.md +sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md +sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md +sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md +sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md +sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md +sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md +sql_reference/dictionaries/external_dictionaries/index.md sql-reference/dictionaries/external-dictionaries/index.md +sql_reference/dictionaries/index.md sql-reference/dictionaries/index.md +sql_reference/dictionaries/internal_dicts.md sql-reference/dictionaries/internal-dicts.md +sql_reference/functions/arithmetic_functions.md sql-reference/functions/arithmetic-functions.md +sql_reference/functions/array_functions.md sql-reference/functions/array-functions.md +sql_reference/functions/array_join.md sql-reference/functions/array-join.md +sql_reference/functions/bit_functions.md sql-reference/functions/bit-functions.md +sql_reference/functions/bitmap_functions.md sql-reference/functions/bitmap-functions.md +sql_reference/functions/comparison_functions.md sql-reference/functions/comparison-functions.md +sql_reference/functions/conditional_functions.md sql-reference/functions/conditional-functions.md +sql_reference/functions/date_time_functions.md sql-reference/functions/date-time-functions.md +sql_reference/functions/encoding_functions.md sql-reference/functions/encoding-functions.md +sql_reference/functions/ext_dict_functions.md sql-reference/functions/ext-dict-functions.md +sql_reference/functions/functions_for_nulls.md sql-reference/functions/functions-for-nulls.md +sql_reference/functions/geo.md sql-reference/functions/geo.md +sql_reference/functions/hash_functions.md sql-reference/functions/hash-functions.md +sql_reference/functions/higher_order_functions.md sql-reference/functions/higher-order-functions.md +sql_reference/functions/in_functions.md sql-reference/functions/in-functions.md +sql_reference/functions/index.md sql-reference/functions/index.md +sql_reference/functions/introspection.md sql-reference/functions/introspection.md +sql_reference/functions/ip_address_functions.md sql-reference/functions/ip-address-functions.md +sql_reference/functions/json_functions.md sql-reference/functions/json-functions.md +sql_reference/functions/logical_functions.md sql-reference/functions/logical-functions.md +sql_reference/functions/machine_learning_functions.md sql-reference/functions/machine-learning-functions.md +sql_reference/functions/math_functions.md sql-reference/functions/math-functions.md +sql_reference/functions/other_functions.md sql-reference/functions/other-functions.md +sql_reference/functions/random_functions.md sql-reference/functions/random-functions.md +sql_reference/functions/rounding_functions.md sql-reference/functions/rounding-functions.md +sql_reference/functions/splitting_merging_functions.md sql-reference/functions/splitting-merging-functions.md +sql_reference/functions/string_functions.md sql-reference/functions/string-functions.md +sql_reference/functions/string_replace_functions.md sql-reference/functions/string-replace-functions.md +sql_reference/functions/string_search_functions.md sql-reference/functions/string-search-functions.md +sql_reference/functions/type_conversion_functions.md sql-reference/functions/type-conversion-functions.md +sql_reference/functions/url_functions.md sql-reference/functions/url-functions.md +sql_reference/functions/uuid_functions.md sql-reference/functions/uuid-functions.md +sql_reference/functions/ym_dict_functions.md sql-reference/functions/ym-dict-functions.md +sql_reference/index.md sql-reference/index.md +sql_reference/operators.md sql-reference/operators.md +sql_reference/statements/alter.md sql-reference/statements/alter.md +sql_reference/statements/create.md sql-reference/statements/create.md +sql_reference/statements/index.md sql-reference/statements/index.md +sql_reference/statements/insert_into.md sql-reference/statements/insert-into.md +sql_reference/statements/misc.md sql-reference/statements/misc.md +sql_reference/statements/select.md sql-reference/statements/select.md +sql_reference/statements/show.md sql-reference/statements/show.md +sql_reference/statements/system.md sql-reference/statements/system.md +sql_reference/syntax.md sql-reference/syntax.md +sql_reference/table_functions/file.md sql-reference/table-functions/file.md +sql_reference/table_functions/generate.md sql-reference/table-functions/generate.md +sql_reference/table_functions/hdfs.md sql-reference/table-functions/hdfs.md +sql_reference/table_functions/index.md sql-reference/table-functions/index.md +sql_reference/table_functions/input.md sql-reference/table-functions/input.md +sql_reference/table_functions/jdbc.md sql-reference/table-functions/jdbc.md +sql_reference/table_functions/merge.md sql-reference/table-functions/merge.md +sql_reference/table_functions/mysql.md sql-reference/table-functions/mysql.md +sql_reference/table_functions/numbers.md sql-reference/table-functions/numbers.md +sql_reference/table_functions/odbc.md sql-reference/table-functions/odbc.md +sql_reference/table_functions/remote.md sql-reference/table-functions/remote.md +sql_reference/table_functions/url.md sql-reference/table-functions/url.md +system_tables.md operations/system-tables.md +system_tables/system.asynchronous_metrics.md operations/system-tables.md +system_tables/system.clusters.md operations/system-tables.md +system_tables/system.columns.md operations/system-tables.md +system_tables/system.databases.md operations/system-tables.md +system_tables/system.dictionaries.md operations/system-tables.md +system_tables/system.events.md operations/system-tables.md +system_tables/system.functions.md operations/system-tables.md +system_tables/system.merges.md operations/system-tables.md +system_tables/system.metrics.md operations/system-tables.md +system_tables/system.numbers.md operations/system-tables.md +system_tables/system.numbers_mt.md operations/system-tables.md +system_tables/system.one.md operations/system-tables.md +system_tables/system.parts.md operations/system-tables.md +system_tables/system.processes.md operations/system-tables.md +system_tables/system.replicas.md operations/system-tables.md +system_tables/system.settings.md operations/system-tables.md +system_tables/system.tables.md operations/system-tables.md +system_tables/system.zookeeper.md operations/system-tables.md +table_engines.md operations/table-engines.md +table_engines/aggregatingmergetree.md operations/table-engines/aggregatingmergetree.md +table_engines/buffer.md operations/table-engines/buffer.md +table_engines/collapsingmergetree.md operations/table-engines/collapsingmergetree.md +table_engines/custom_partitioning_key.md operations/table-engines/custom-partitioning-key.md +table_engines/dictionary.md operations/table-engines/dictionary.md +table_engines/distributed.md operations/table-engines/distributed.md +table_engines/external_data.md operations/table-engines/external-data.md +table_engines/file.md operations/table-engines/file.md +table_engines/graphitemergetree.md operations/table-engines/graphitemergetree.md +table_engines/index.md operations/table-engines/index.md +table_engines/join.md operations/table-engines/join.md +table_engines/kafka.md operations/table-engines/kafka.md +table_engines/log.md operations/table-engines/log.md +table_engines/materializedview.md operations/table-engines/materializedview.md +table_engines/memory.md operations/table-engines/memory.md +table_engines/merge.md operations/table-engines/merge.md +table_engines/mergetree.md operations/table-engines/mergetree.md +table_engines/mysql.md operations/table-engines/mysql.md +table_engines/null.md operations/table-engines/null.md +table_engines/replacingmergetree.md operations/table-engines/replacingmergetree.md +table_engines/replication.md operations/table-engines/replication.md +table_engines/set.md operations/table-engines/set.md +table_engines/summingmergetree.md operations/table-engines/summingmergetree.md +table_engines/tinylog.md operations/table-engines/tinylog.md +table_engines/view.md operations/table-engines/view.md +table_functions/file.md query-language/table-functions/file.md +table_functions/index.md query-language/table-functions/index.md +table_functions/merge.md query-language/table-functions/merge.md +table_functions/numbers.md query-language/table-functions/numbers.md +table_functions/remote.md query-language/table-functions/remote.md utils.md operations/utils.md utils/clickhouse-copier.md operations/utils/clickhouse-copier.md utils/clickhouse-local.md operations/utils/clickhouse-local.md +whats_new/changelog/2017.md whats-new/changelog/2017.md +whats_new/changelog/2018.md whats-new/changelog/2018.md +whats_new/changelog/2019.md whats-new/changelog/2019.md +whats_new/changelog/index.md whats-new/changelog/index.md +whats_new/index.md whats-new/index.md +whats_new/roadmap.md whats-new/roadmap.md +whats_new/security_changelog.md whats-new/security-changelog.md diff --git a/docs/ru/commercial/cloud.md b/docs/ru/commercial/cloud.md index 9716f4f1cd2..6cbc0e6743b 100644 --- a/docs/ru/commercial/cloud.md +++ b/docs/ru/commercial/cloud.md @@ -7,7 +7,7 @@ [Yandex Managed Service for ClickHouse](https://cloud.yandex.ru/services/managed-clickhouse?utm_source=referrals&utm_medium=clickhouseofficialsite&utm_campaign=link3) предоставляет следующие ключевые возможности: -- Полностью управляемый сервис ZooKeeper для [репликации ClickHouse](../engines/table_engines/mergetree_family/replication.md) +- Полностью управляемый сервис ZooKeeper для [репликации ClickHouse](../engines/table-engines/mergetree-family/replication.md) - Выбор типа хранилища - Реплики в разных зонах доступности - Шифрование и изоляция diff --git a/docs/ru/commercial/index.md b/docs/ru/commercial/index.md index dc78f6f4899..6bc3c781161 100644 --- a/docs/ru/commercial/index.md +++ b/docs/ru/commercial/index.md @@ -1,7 +1,9 @@ --- -toc_folder_title: Коммерческие услуги +toc_folder_title: "\u041A\u043E\u043C\u043C\u0435\u0440\u0447\u0435\u0441\u043A\u0438\ + \u0435 \u0443\u0441\u043B\u0443\u0433\u0438" toc_priority: 70 -toc_title: Коммерческие услуги +toc_title: "\u041A\u043E\u043C\u043C\u0435\u0440\u0447\u0435\u0441\u043A\u0438\u0435\ + \ \u0443\u0441\u043B\u0443\u0433\u0438" --- diff --git a/docs/ru/development/browse_code.md b/docs/ru/development/browse-code.md similarity index 100% rename from docs/ru/development/browse_code.md rename to docs/ru/development/browse-code.md diff --git a/docs/ru/development/build-cross-arm.md b/docs/ru/development/build-cross-arm.md new file mode 120000 index 00000000000..134f128a40c --- /dev/null +++ b/docs/ru/development/build-cross-arm.md @@ -0,0 +1 @@ +../../en/development/build-cross-arm.md \ No newline at end of file diff --git a/docs/ru/development/build-cross-osx.md b/docs/ru/development/build-cross-osx.md new file mode 120000 index 00000000000..bcc10df574c --- /dev/null +++ b/docs/ru/development/build-cross-osx.md @@ -0,0 +1 @@ +../../en/development/build-cross-osx.md \ No newline at end of file diff --git a/docs/ru/development/build-osx.md b/docs/ru/development/build-osx.md new file mode 120000 index 00000000000..8e172b919d8 --- /dev/null +++ b/docs/ru/development/build-osx.md @@ -0,0 +1 @@ +../../en/development/build-osx.md \ No newline at end of file diff --git a/docs/ru/development/build_cross_arm.md b/docs/ru/development/build_cross_arm.md deleted file mode 120000 index 983a9872dc1..00000000000 --- a/docs/ru/development/build_cross_arm.md +++ /dev/null @@ -1 +0,0 @@ -../../en/development/build_cross_arm.md \ No newline at end of file diff --git a/docs/ru/development/build_cross_osx.md b/docs/ru/development/build_cross_osx.md deleted file mode 120000 index 72e64e8631f..00000000000 --- a/docs/ru/development/build_cross_osx.md +++ /dev/null @@ -1 +0,0 @@ -../../en/development/build_cross_osx.md \ No newline at end of file diff --git a/docs/ru/development/build_osx.md b/docs/ru/development/build_osx.md deleted file mode 120000 index f9adaf24584..00000000000 --- a/docs/ru/development/build_osx.md +++ /dev/null @@ -1 +0,0 @@ -../../en/development/build_osx.md \ No newline at end of file diff --git a/docs/ru/development/developer-instruction.md b/docs/ru/development/developer-instruction.md new file mode 100644 index 00000000000..775b156dff5 --- /dev/null +++ b/docs/ru/development/developer-instruction.md @@ -0,0 +1,280 @@ +Сборка ClickHouse поддерживается на Linux, FreeBSD, Mac OS X. + +# Если вы используете Windows {#esli-vy-ispolzuete-windows} + +Если вы используете Windows, вам потребуется создать виртуальную машину с Ubuntu. Для работы с виртуальной машиной, установите VirtualBox. Скачать Ubuntu можно на сайте: https://www.ubuntu.com/\#download Создайте виртуальную машину из полученного образа. Выделите для неё не менее 4 GB оперативной памяти. Для запуска терминала в Ubuntu, найдите в меню программу со словом terminal (gnome-terminal, konsole или что-то в этом роде) или нажмите Ctrl+Alt+T. + +# Если вы используете 32-битную систему {#esli-vy-ispolzuete-32-bitnuiu-sistemu} + +ClickHouse не работает и не собирается на 32-битных системах. Получите доступ к 64-битной системе и продолжайте. + +# Создание репозитория на GitHub {#sozdanie-repozitoriia-na-github} + +Для работы с репозиторием ClickHouse, вам потребуется аккаунт на GitHub. Наверное, он у вас уже есть. + +Если аккаунта нет - зарегистрируйтесь на https://github.com/. Создайте ssh ключи, если их нет, и загрузите публичные ключи на GitHub. Это потребуется для отправки изменений. Для работы с GitHub можно использовать такие же ssh ключи, как и для работы с другими ssh серверами - скорее всего, они уже у вас есть. + +Создайте fork репозитория ClickHouse. Для этого, на странице https://github.com/ClickHouse/ClickHouse нажмите на кнопку «fork» в правом верхнем углу. Вы получите полную копию репозитория ClickHouse на своём аккаунте, которая называется «форк». Процесс разработки состоит в том, чтобы внести нужные изменения в свой форк репозитория, а затем создать «pull request» для принятия изменений в основной репозиторий. + +Для работы с git репозиториями, установите `git`. + +В Ubuntu выполните в терминале: + + sudo apt update + sudo apt install git + +Краткое руководство по использованию Git: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf + +Подробное руководство по использованию Git: https://git-scm.com/book/ru/v2 + +# Клонирование репозитория на рабочую машину {#klonirovanie-repozitoriia-na-rabochuiu-mashinu} + +Затем вам потребуется загрузить исходники для работы на свой компьютер. Это называется «клонирование репозитория», потому что создаёт на вашем компьютере локальную копию репозитория, с которой вы будете работать. + +Выполните в терминале: + + git clone --recursive git@github.com:ClickHouse/ClickHouse.git + cd ClickHouse + +Замените *yandex* на имя вашего аккаунта на GitHub. + +Эта команда создаст директорию ClickHouse, содержащую рабочую копию проекта. + +Необходимо, чтобы путь к рабочей копии не содержал пробелы в именах директорий. Это может привести к проблемам в работе системы сборки. + +Обратите внимание, что репозиторий ClickHouse использует submodules. Так называются ссылки на дополнительные репозитории (например, внешние библиотеки, от которых зависит проект). Это значит, что при клонировании репозитория, следует указывать ключ `--recursive`, как в примере выше. Если репозиторий был клонирован без submodules, то для их скачивания, необходимо выполнить: + + git submodule init + git submodule update + +Проверить наличие submodules можно с помощью команды `git submodule status`. + +Если вы получили сообщение об ошибке: + + Permission denied (publickey). + fatal: Could not read from remote repository. + + Please make sure you have the correct access rights + and the repository exists. + +Как правило это означает, что отсутствуют ssh ключи для соединения с GitHub. Ключи расположены в директории `~/.ssh`. В интерфейсе GitHub, в настройках, необходимо загрузить публичные ключи, чтобы он их понимал. + +Вы также можете клонировать репозиторий по протоколу https: + + git clone https://github.com/ClickHouse/ClickHouse.git + +Этот вариант не подходит для отправки изменений на сервер. Вы можете временно его использовать, а затем добавить ssh ключи и заменить адрес репозитория с помощью команды `git remote`. + +Вы можете также добавить для своего локального репозитория адрес оригинального репозитория Яндекса, чтобы притягивать оттуда обновления: + + git remote add upstream git@github.com:ClickHouse/ClickHouse.git + +После этого, вы сможете добавлять в свой репозиторий обновления из репозитория Яндекса с помощью команды `git pull upstream master`. + +## Работа с сабмодулями Git {#rabota-s-sabmoduliami-git} + +Работа с сабмодулями git может быть достаточно болезненной. Следующие команды позволят содержать их в порядке: + + # ! Каждая команда принимает аргумент --recursive + # Обновить URLs удалённого репозитория для каждого сабмодуля, используется относительно редко + git submodule sync + # Добавить новые сабмодули + git submodule init + # Обновить сабмодули до актуального состояния + git submodule update + # Две последние команды могут быть объединены вместе: + git submodule update --init + +The next commands would help you to reset all submodules to the initial state (!WARING! - any chenges inside will be deleted): +Следующие команды помогут сбросить все сабмодули в изначальное состояние (!ВНИМАНИЕ! - все изменения в сабмодулях будут утеряны): + + # Synchronizes submodules' remote URL with .gitmodules + # Обновить URLs удалённого репозитория для каждого сабмодуля + git submodule sync --recursive + # Обновить существующие модули и добавить отсутствующие + git submodule update --init --recursive + # Удалить все изменения в сабмодуле относительно HEAD + git submodule foreach git reset --hard + # Очистить игнорируемые файлы + git submodule foreach git clean -xfd + # Повторить последние 4 команды для каждого из сабмодулей + git submodule foreach git submodule sync --recursive + git submodule foreach git submodule update --init --recursive + git submodule foreach git submodule foreach git reset --hard + git submodule foreach git submodule foreach git clean -xfd + +# Система сборки {#sistema-sborki} + +ClickHouse использует систему сборки CMake и Ninja. + +CMake - генератор задач сборки. +Ninja - система запуска сборочных задач. + +Для установки на Ubuntu или Debian, Mint, выполните `sudo apt install cmake ninja-build`. + +Для установки на CentOS, RedHat, выполните `sudo yum install cmake ninja-build`. + +Если у вас Arch или Gentoo, то вы сами знаете, как установить CMake. + +Для установки CMake и Ninja на Mac OS X, сначала установите Homebrew, а затем, с помощью него, установите всё остальное. + + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install cmake ninja + +Проверьте версию CMake: `cmake --version`. Если версия меньше 3.3, то установите новую версию с сайта https://cmake.org/download/ + +# Необязательные внешние библиотеки {#neobiazatelnye-vneshnie-biblioteki} + +ClickHouse использует для сборки некоторое количество внешних библиотек. Но ни одну из них не требуется отдельно устанавливать, так как они собираются вместе с ClickHouse, из исходников, которые расположены в submodules. Посмотреть набор этих библиотек можно в директории contrib. + +# Компилятор C++ {#kompiliator-c} + +В качестве компилятора C++ поддерживается GCC начиная с версии 9 или Clang начиная с версии 8. + +Официальные сборки от Яндекса, на данный момент, используют GCC, так как он генерирует слегка более производительный машинный код (разница в среднем до нескольких процентов по нашим бенчмаркам). Clang обычно более удобен для разработки. Впрочем, наша среда continuous integration проверяет около десятка вариантов сборки. + +Для установки GCC под Ubuntu, выполните: `sudo apt install gcc g++`. + +Проверьте версию gcc: `gcc --version`. Если версия меньше 9, то следуйте инструкции: https://clickhouse.tech/docs/ru/development/build/#install-gcc-9. + +Сборка под Mac OS X поддерживается только для компилятора Clang. Чтобы установить его выполните `brew install llvm` + +Если вы решили использовать Clang, вы также можете установить `libc++` и `lld`, если вы знаете, что это такое. При желании, установите `ccache`. + +# Процесс сборки {#protsess-sborki} + +Теперь вы готовы к сборке ClickHouse. Для размещения собранных файлов, рекомендуется создать отдельную директорию build внутри директории ClickHouse: + + mkdir build + cd build + +Вы можете иметь несколько разных директорий (build\_release, build\_debug) для разных вариантов сборки. + +Находясь в директории build, выполните конфигурацию сборки с помощью CMake. +Перед первым запуском необходимо выставить переменные окружения, отвечающие за выбор компилятора (в данном примере это - gcc версии 9). + +Linux: + + export CC=gcc-9 CXX=g++-9 + cmake .. + +Mac OS X: + + export CC=clang CXX=clang++ + cmake .. + +Переменная CC отвечает за компилятор C (сокращение от слов C Compiler), переменная CXX отвечает за выбор компилятора C++ (символ X - это как плюс, но положенный набок, ради того, чтобы превратить его в букву). + +Для более быстрой сборки, можно использовать debug вариант - сборку без оптимизаций. Для этого, укажите параметр `-D CMAKE_BUILD_TYPE=Debug`: + + cmake -D CMAKE_BUILD_TYPE=Debug .. + +Вы можете изменить вариант сборки, выполнив эту команду в директории build. + +Запустите ninja для сборки: + + ninja clickhouse-server clickhouse-client + +В этом примере собираются только нужные в первую очередь программы. + +Если вы хотите собрать все программы (утилиты и тесты), то запустите ninja без параметров: + + ninja + +Для полной сборки требуется около 30 GB свободного места на диске или 15 GB для сборки только основных программ. + +При наличии небольшого количества оперативной памяти на компьютере, следует ограничить количество параллельных задач с помощью параметра `-j`: + + ninja -j 1 clickhouse-server clickhouse-client + +На машинах с 4 GB памяти, рекомендуется указывать значение 1, а если памяти до 8 GB, укажите значение 2. + +Если вы получили сообщение `ninja: error: loading 'build.ninja': No such file or directory`, значит конфигурация сборки прошла с ошибкой и вам необходимо посмотреть на сообщение об ошибке выше. + +В случае успешного запуска, вы увидите прогресс сборки - количество обработанных задач и общее количество задач. + +В процессе сборки могут появится сообщения `libprotobuf WARNING` про protobuf файлы в библиотеке libhdfs2. Это не имеет значения. + +При успешной сборке, вы получите готовый исполняемый файл `ClickHouse/build/programs/clickhouse`: + + ls -l programs/clickhouse + +# Запуск собранной версии ClickHouse {#zapusk-sobrannoi-versii-clickhouse} + +Для запуска сервера из под текущего пользователя, с выводом логов в терминал и с использованием примеров конфигурационных файлов, расположенных в исходниках, перейдите в директорию `ClickHouse/programs/server/` (эта директория находится не в директории build) и выполните: + + ../../../build/programs/clickhouse server + +В этом случае, ClickHouse будет использовать конфигурационные файлы, расположенные в текущей директории. Вы можете запустить `clickhouse server` из любой директории, передав ему путь к конфигурационному файлу в аргументе командной строки `--config-file`. + +Для подключения к ClickHouse с помощью clickhouse-client, в соседнем терминале, зайдите в директорию `ClickHouse/build/programs/` и выполните `clickhouse client`. + +Если вы получили сообщение `Connection refused` на Mac OS X или FreeBSD, то укажите для клиента 127.0.0.1 в качестве имени хоста: + + clickhouse client --host 127.0.0.1 + +Вы можете заменить собранным вами ClickHouse продакшен версию, установленную в системе. Для этого, установите ClickHouse на свою машину по инструкции с официального сайта. Затем выполните: + + sudo service clickhouse-server stop + sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ + sudo service clickhouse-server start + +Обратите внимание, что `clickhouse-client`, `clickhouse-server` и другие, являеются симлинками на общий бинарник `clickhouse`. + +Также вы можете запустить собранный вами ClickHouse с конфигурационным файлом системного ClickHouse: + + sudo service clickhouse-server stop + sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml + +# Среда разработки {#sreda-razrabotki} + +Если вы не знаете, какую среду разработки использовать, то рекомендуется использовать CLion. CLion является платным ПО, но его можно использовать бесплатно в течение пробного периода. Также он бесплатен для учащихся. CLion можно использовать как под Linux, так и под Mac OS X. + +Также в качестве среды разработки, вы можете использовать KDevelop или QTCreator. KDevelop - очень удобная, но нестабильная среда разработки. Если KDevelop вылетает через небольшое время после открытия проекта, вам следует нажать на кнопку «Stop All» как только он открыл список файлов проекта. После этого, KDevelop можно будет использовать. + +В качестве простых редакторов кода можно использовать Sublime Text или Visual Studio Code или Kate (все варианты доступны под Linux). + +На всякий случай заметим, что CLion самостоятельно создаёт свою build директорию, самостоятельно выбирает тип сборки debug по-умолчанию, для конфигурации использует встроенную в CLion версию CMake вместо установленного вами, а для запуска задач использует make вместо ninja. Это нормально, просто имейте это ввиду, чтобы не возникало путаницы. + +# Написание кода {#napisanie-koda} + +Описание архитектуры ClickHouse: https://clickhouse.tech/docs/ru/development/architecture/ + +Стиль кода: https://clickhouse.tech/docs/ru/development/style/ + +Разработка тестов: https://clickhouse.tech/docs/ru/development/tests/ + +Список задач: https://github.com/ClickHouse/ClickHouse/contribute + +# Тестовые данные {#testovye-dannye} + +Разработка ClickHouse часто требует загрузки реалистичных наборов данных. Особенно это важно для тестирования производительности. Специально для вас мы подготовили набор данных, представляющий собой анонимизированные данные Яндекс.Метрики. Загрузка этих данных потребует ещё 3 GB места на диске. Для выполнения большинства задач разработки, загружать эти данные не обязательно. + + sudo apt install wget xz-utils + + wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz + wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz + + xz -v -d hits_v1.tsv.xz + xz -v -d visits_v1.tsv.xz + + clickhouse-client + + CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); + + CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); + + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv + +# Создание Pull Request {#sozdanie-pull-request} + +Откройте свой форк репозитория в интерфейсе GitHub. Если вы вели разработку в бранче, выберите этот бранч. На странице будет доступна кнопка «Pull request». По сути, это означает «создать заявку на принятие моих изменений в основной репозиторий». + +Pull request можно создать, даже если работа над задачей ещё не завершена. В этом случае, добавьте в его название слово «WIP» (work in progress). Название можно будет изменить позже. Это полезно для совместного просмотра и обсуждения изменений, а также для запуска всех имеющихся тестов. Введите краткое описание изменений - впоследствии, оно будет использовано для релизных changelog. + +Тесты будут запущены, как только сотрудники Яндекса поставят для pull request тег «Can be tested». Результаты первых проверок (стиль кода) появятся уже через несколько минут. Результаты сборки появятся примерно через пол часа. Результаты основного набора тестов будут доступны в пределах часа. + +Система подготовит сборки ClickHouse специально для вашего pull request. Для их получения, нажмите на ссылку «Details» у проверки «Clickhouse build check». Там вы сможете найти прямые ссылки на собранные .deb пакеты ClickHouse, которые, при желании, вы даже сможете установить на свои продакшен серверы (если не страшно). + +Вероятнее всего, часть сборок не будет успешной с первого раза. Ведь мы проверяем сборку кода и gcc и clang, а при сборке с помощью clang включаются почти все существующие в природе warnings (всегда с флагом `-Werror`). На той же странице, вы сможете найти логи сборки - вам не обязательно самому собирать ClickHouse всеми возможными способами. diff --git a/docs/ru/development/developer_instruction.md b/docs/ru/development/developer_instruction.md deleted file mode 100644 index 11ac3a73f6e..00000000000 --- a/docs/ru/development/developer_instruction.md +++ /dev/null @@ -1,280 +0,0 @@ -Сборка ClickHouse поддерживается на Linux, FreeBSD, Mac OS X. - -# Если вы используете Windows {#esli-vy-ispolzuete-windows} - -Если вы используете Windows, вам потребуется создать виртуальную машину с Ubuntu. Для работы с виртуальной машиной, установите VirtualBox. Скачать Ubuntu можно на сайте: https://www.ubuntu.com/\#download Создайте виртуальную машину из полученного образа. Выделите для неё не менее 4 GB оперативной памяти. Для запуска терминала в Ubuntu, найдите в меню программу со словом terminal (gnome-terminal, konsole или что-то в этом роде) или нажмите Ctrl+Alt+T. - -# Если вы используете 32-битную систему {#esli-vy-ispolzuete-32-bitnuiu-sistemu} - -ClickHouse не работает и не собирается на 32-битных системах. Получите доступ к 64-битной системе и продолжайте. - -# Создание репозитория на GitHub {#sozdanie-repozitoriia-na-github} - -Для работы с репозиторием ClickHouse, вам потребуется аккаунт на GitHub. Наверное, он у вас уже есть. - -Если аккаунта нет - зарегистрируйтесь на https://github.com/. Создайте ssh ключи, если их нет, и загрузите публичные ключи на GitHub. Это потребуется для отправки изменений. Для работы с GitHub можно использовать такие же ssh ключи, как и для работы с другими ssh серверами - скорее всего, они уже у вас есть. - -Создайте fork репозитория ClickHouse. Для этого, на странице https://github.com/ClickHouse/ClickHouse нажмите на кнопку «fork» в правом верхнем углу. Вы получите полную копию репозитория ClickHouse на своём аккаунте, которая называется «форк». Процесс разработки состоит в том, чтобы внести нужные изменения в свой форк репозитория, а затем создать «pull request» для принятия изменений в основной репозиторий. - -Для работы с git репозиториями, установите `git`. - -В Ubuntu выполните в терминале: - - sudo apt update - sudo apt install git - -Краткое руководство по использованию Git: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf - -Подробное руководство по использованию Git: https://git-scm.com/book/ru/v2 - -# Клонирование репозитория на рабочую машину {#klonirovanie-repozitoriia-na-rabochuiu-mashinu} - -Затем вам потребуется загрузить исходники для работы на свой компьютер. Это называется «клонирование репозитория», потому что создаёт на вашем компьютере локальную копию репозитория, с которой вы будете работать. - -Выполните в терминале: - - git clone --recursive git@github.com:ClickHouse/ClickHouse.git - cd ClickHouse - -Замените *yandex* на имя вашего аккаунта на GitHub. - -Эта команда создаст директорию ClickHouse, содержащую рабочую копию проекта. - -Необходимо, чтобы путь к рабочей копии не содержал пробелы в именах директорий. Это может привести к проблемам в работе системы сборки. - -Обратите внимание, что репозиторий ClickHouse использует submodules. Так называются ссылки на дополнительные репозитории (например, внешние библиотеки, от которых зависит проект). Это значит, что при клонировании репозитория, следует указывать ключ `--recursive`, как в примере выше. Если репозиторий был клонирован без submodules, то для их скачивания, необходимо выполнить: - - git submodule init - git submodule update - -Проверить наличие submodules можно с помощью команды `git submodule status`. - -Если вы получили сообщение об ошибке: - - Permission denied (publickey). - fatal: Could not read from remote repository. - - Please make sure you have the correct access rights - and the repository exists. - -Как правило это означает, что отсутствуют ssh ключи для соединения с GitHub. Ключи расположены в директории `~/.ssh`. В интерфейсе GitHub, в настройках, необходимо загрузить публичные ключи, чтобы он их понимал. - -Вы также можете клонировать репозиторий по протоколу https: - - git clone https://github.com/ClickHouse/ClickHouse.git - -Этот вариант не подходит для отправки изменений на сервер. Вы можете временно его использовать, а затем добавить ssh ключи и заменить адрес репозитория с помощью команды `git remote`. - -Вы можете также добавить для своего локального репозитория адрес оригинального репозитория Яндекса, чтобы притягивать оттуда обновления: - - git remote add upstream git@github.com:ClickHouse/ClickHouse.git - -После этого, вы сможете добавлять в свой репозиторий обновления из репозитория Яндекса с помощью команды `git pull upstream master`. - -## Работа с сабмодулями Git {#rabota-s-sabmoduliami-git} - -Работа с сабмодулями git может быть достаточно болезненной. Следующие команды позволят содержать их в порядке: - - # ! Каждая команда принимает аргумент --recursive - # Обновить URLs удалённого репозитория для каждого сабмодуля, используется относительно редко - git submodule sync - # Добавить новые сабмодули - git submodule init - # Обновить сабмодули до актуального состояния - git submodule update - # Две последние команды могут быть объединены вместе: - git submodule update --init - -The next commands would help you to reset all submodules to the initial state (!WARING! - any chenges inside will be deleted): -Следующие команды помогут сбросить все сабмодули в изначальное состояние (!ВНИМАНИЕ! - все изменения в сабмодулях будут утеряны): - - # Synchronizes submodules' remote URL with .gitmodules - # Обновить URLs удалённого репозитория для каждого сабмодуля - git submodule sync --recursive - # Обновить существующие модули и добавить отсутствующие - git submodule update --init --recursive - # Удалить все изменения в сабмодуле относительно HEAD - git submodule foreach git reset --hard - # Очистить игнорируемые файлы - git submodule foreach git clean -xfd - # Повторить последние 4 команды для каждого из сабмодулей - git submodule foreach git submodule sync --recursive - git submodule foreach git submodule update --init --recursive - git submodule foreach git submodule foreach git reset --hard - git submodule foreach git submodule foreach git clean -xfd - -# Система сборки {#sistema-sborki} - -ClickHouse использует систему сборки CMake и Ninja. - -CMake - генератор задач сборки. -Ninja - система запуска сборочных задач. - -Для установки на Ubuntu или Debian, Mint, выполните `sudo apt install cmake ninja-build`. - -Для установки на CentOS, RedHat, выполните `sudo yum install cmake ninja-build`. - -Если у вас Arch или Gentoo, то вы сами знаете, как установить CMake. - -Для установки CMake и Ninja на Mac OS X, сначала установите Homebrew, а затем, с помощью него, установите всё остальное. - - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew install cmake ninja - -Проверьте версию CMake: `cmake --version`. Если версия меньше 3.3, то установите новую версию с сайта https://cmake.org/download/ - -# Необязательные внешние библиотеки {#neobiazatelnye-vneshnie-biblioteki} - -ClickHouse использует для сборки некоторое количество внешних библиотек. Но ни одну из них не требуется отдельно устанавливать, так как они собираются вместе с ClickHouse, из исходников, которые расположены в submodules. Посмотреть набор этих библиотек можно в директории contrib. - -# Компилятор C++ {#kompiliator-c} - -В качестве компилятора C++ поддерживается GCC начиная с версии 9 или Clang начиная с версии 8. - -Официальные сборки от Яндекса, на данный момент, используют GCC, так как он генерирует слегка более производительный машинный код (разница в среднем до нескольких процентов по нашим бенчмаркам). Clang обычно более удобен для разработки. Впрочем, наша среда continuous integration проверяет около десятка вариантов сборки. - -Для установки GCC под Ubuntu, выполните: `sudo apt install gcc g++`. - -Проверьте версию gcc: `gcc --version`. Если версия меньше 9, то следуйте инструкции: https://clickhouse.tech/docs/en/development/build/\#install-gcc-9 - -Сборка под Mac OS X поддерживается только для компилятора Clang. Чтобы установить его выполните `brew install llvm` - -Если вы решили использовать Clang, вы также можете установить `libc++` и `lld`, если вы знаете, что это такое. При желании, установите `ccache`. - -# Процесс сборки {#protsess-sborki} - -Теперь вы готовы к сборке ClickHouse. Для размещения собранных файлов, рекомендуется создать отдельную директорию build внутри директории ClickHouse: - - mkdir build - cd build - -Вы можете иметь несколько разных директорий (build\_release, build\_debug) для разных вариантов сборки. - -Находясь в директории build, выполните конфигурацию сборки с помощью CMake. -Перед первым запуском необходимо выставить переменные окружения, отвечающие за выбор компилятора (в данном примере это - gcc версии 9). - -Linux: - - export CC=gcc-9 CXX=g++-9 - cmake .. - -Mac OS X: - - export CC=clang CXX=clang++ - cmake .. - -Переменная CC отвечает за компилятор C (сокращение от слов C Compiler), переменная CXX отвечает за выбор компилятора C++ (символ X - это как плюс, но положенный набок, ради того, чтобы превратить его в букву). - -Для более быстрой сборки, можно использовать debug вариант - сборку без оптимизаций. Для этого, укажите параметр `-D CMAKE_BUILD_TYPE=Debug`: - - cmake -D CMAKE_BUILD_TYPE=Debug .. - -Вы можете изменить вариант сборки, выполнив эту команду в директории build. - -Запустите ninja для сборки: - - ninja clickhouse-server clickhouse-client - -В этом примере собираются только нужные в первую очередь программы. - -Если вы хотите собрать все программы (утилиты и тесты), то запустите ninja без параметров: - - ninja - -Для полной сборки требуется около 30 GB свободного места на диске или 15 GB для сборки только основных программ. - -При наличии небольшого количества оперативной памяти на компьютере, следует ограничить количество параллельных задач с помощью параметра `-j`: - - ninja -j 1 clickhouse-server clickhouse-client - -На машинах с 4 GB памяти, рекомендуется указывать значение 1, а если памяти до 8 GB, укажите значение 2. - -Если вы получили сообщение `ninja: error: loading 'build.ninja': No such file or directory`, значит конфигурация сборки прошла с ошибкой и вам необходимо посмотреть на сообщение об ошибке выше. - -В случае успешного запуска, вы увидите прогресс сборки - количество обработанных задач и общее количество задач. - -В процессе сборки могут появится сообщения `libprotobuf WARNING` про protobuf файлы в библиотеке libhdfs2. Это не имеет значения. - -При успешной сборке, вы получите готовый исполняемый файл `ClickHouse/build/programs/clickhouse`: - - ls -l programs/clickhouse - -# Запуск собранной версии ClickHouse {#zapusk-sobrannoi-versii-clickhouse} - -Для запуска сервера из под текущего пользователя, с выводом логов в терминал и с использованием примеров конфигурационных файлов, расположенных в исходниках, перейдите в директорию `ClickHouse/programs/server/` (эта директория находится не в директории build) и выполните: - - ../../../build/programs/clickhouse server - -В этом случае, ClickHouse будет использовать конфигурационные файлы, расположенные в текущей директории. Вы можете запустить `clickhouse server` из любой директории, передав ему путь к конфигурационному файлу в аргументе командной строки `--config-file`. - -Для подключения к ClickHouse с помощью clickhouse-client, в соседнем терминале, зайдите в директорию `ClickHouse/build/programs/` и выполните `clickhouse client`. - -Если вы получили сообщение `Connection refused` на Mac OS X или FreeBSD, то укажите для клиента 127.0.0.1 в качестве имени хоста: - - clickhouse client --host 127.0.0.1 - -Вы можете заменить собранным вами ClickHouse продакшен версию, установленную в системе. Для этого, установите ClickHouse на свою машину по инструкции с официального сайта. Затем выполните: - - sudo service clickhouse-server stop - sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ - sudo service clickhouse-server start - -Обратите внимание, что `clickhouse-client`, `clickhouse-server` и другие, являеются симлинками на общий бинарник `clickhouse`. - -Также вы можете запустить собранный вами ClickHouse с конфигурационным файлом системного ClickHouse: - - sudo service clickhouse-server stop - sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml - -# Среда разработки {#sreda-razrabotki} - -Если вы не знаете, какую среду разработки использовать, то рекомендуется использовать CLion. CLion является платным ПО, но его можно использовать бесплатно в течение пробного периода. Также он бесплатен для учащихся. CLion можно использовать как под Linux, так и под Mac OS X. - -Также в качестве среды разработки, вы можете использовать KDevelop или QTCreator. KDevelop - очень удобная, но нестабильная среда разработки. Если KDevelop вылетает через небольшое время после открытия проекта, вам следует нажать на кнопку «Stop All» как только он открыл список файлов проекта. После этого, KDevelop можно будет использовать. - -В качестве простых редакторов кода можно использовать Sublime Text или Visual Studio Code или Kate (все варианты доступны под Linux). - -На всякий случай заметим, что CLion самостоятельно создаёт свою build директорию, самостоятельно выбирает тип сборки debug по-умолчанию, для конфигурации использует встроенную в CLion версию CMake вместо установленного вами, а для запуска задач использует make вместо ninja. Это нормально, просто имейте это ввиду, чтобы не возникало путаницы. - -# Написание кода {#napisanie-koda} - -Описание архитектуры ClickHouse: https://clickhouse.tech/docs/ru/development/architecture/ - -Стиль кода: https://clickhouse.tech/docs/ru/development/style/ - -Разработка тестов: https://clickhouse.tech/docs/ru/development/tests/ - -Список задач: https://github.com/ClickHouse/ClickHouse/blob/master/tests/instructions/easy\_tasks\_sorted\_ru.md - -# Тестовые данные {#testovye-dannye} - -Разработка ClickHouse часто требует загрузки реалистичных наборов данных. Особенно это важно для тестирования производительности. Специально для вас мы подготовили набор данных, представляющий собой анонимизированные данные Яндекс.Метрики. Загрузка этих данных потребует ещё 3 GB места на диске. Для выполнения большинства задач разработки, загружать эти данные не обязательно. - - sudo apt install wget xz-utils - - wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz - wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz - - xz -v -d hits_v1.tsv.xz - xz -v -d visits_v1.tsv.xz - - clickhouse-client - - CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); - - CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); - - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv - -# Создание Pull Request {#sozdanie-pull-request} - -Откройте свой форк репозитория в интерфейсе GitHub. Если вы вели разработку в бранче, выберите этот бранч. На странице будет доступна кнопка «Pull request». По сути, это означает «создать заявку на принятие моих изменений в основной репозиторий». - -Pull request можно создать, даже если работа над задачей ещё не завершена. В этом случае, добавьте в его название слово «WIP» (work in progress). Название можно будет изменить позже. Это полезно для совместного просмотра и обсуждения изменений, а также для запуска всех имеющихся тестов. Введите краткое описание изменений - впоследствии, оно будет использовано для релизных changelog. - -Тесты будут запущены, как только сотрудники Яндекса поставят для pull request тег «Can be tested». Результаты первых проверок (стиль кода) появятся уже через несколько минут. Результаты сборки появятся примерно через пол часа. Результаты основного набора тестов будут доступны в пределах часа. - -Система подготовит сборки ClickHouse специально для вашего pull request. Для их получения, нажмите на ссылку «Details» у проверки «Clickhouse build check». Там вы сможете найти прямые ссылки на собранные .deb пакеты ClickHouse, которые, при желании, вы даже сможете установить на свои продакшен серверы (если не страшно). - -Вероятнее всего, часть сборок не будет успешной с первого раза. Ведь мы проверяем сборку кода и gcc и clang, а при сборке с помощью clang включаются почти все существующие в природе warnings (всегда с флагом `-Werror`). На той же странице, вы сможете найти логи сборки - вам не обязательно самому собирать ClickHouse всеми возможными способами. diff --git a/docs/ru/development/style.md b/docs/ru/development/style.md index d922e1edd22..b948988d699 100644 --- a/docs/ru/development/style.md +++ b/docs/ru/development/style.md @@ -688,10 +688,77 @@ auto s = std::string{"Hello"}; ## Неиспользуемые возможности языка C++ {#neispolzuemye-vozmozhnosti-iazyka-c} -**1.** Виртуальное наследование не используется. - **2.** Спецификаторы исключений из C++03 не используются. +## Сообщения об ошибках {#error-messages} + +Сообщения об ошибках -- это часть пользовательского интерфейса программы, предназначенная для того, чтобы позволить пользователю: +* замечать ошибочные ситуации, +* понимать их смысл и причины, +* устранять эти ситуации. + +Форма и содержание сообщений об ошибках должны способствовать достижению этих целей. + +Есть два основных вида ошибок: +* пользовательская или системная ошибка, +* внутренняя программная ошибка. + +### Пользовательская ошибка {#error-messages-user-error} + +Такая ошибка вызвана действиями пользователя (неверный синтаксис запроса) или конфигурацией внешних систем (кончилось место на диске). Предполагается, что пользователь может устранить её самостоятельно. Для этого в сообщении об ошибке должна содержаться следующая информация: +* что произошло. Это должно объясняться в пользовательских терминах (`Function pow() is not supported for data type UInt128`), а не загадочными конструкциями из кода (`runtime overload resolution failed in DB::BinaryOperationBuilder::Impl, UInt128, Int8>::kaboongleFastPath()`). +* почему/где/когда -- любой контекст, который помогает отладить проблему. Представьте, как бы её отлаживали вы (программировать и пользоваться отладчиком нельзя). +* что можно предпринять для устранения ошибки. Здесь можно перечислить типичные причины проблемы, настройки, влияющие на это поведение, и так далее. + +Пример нормального сообщения: +``` +No alias for subquery or table function in JOIN (set joined_subquery_requires_alias=0 to disable restriction). +While processing '(SELECT 2 AS a)'. +``` +Сказано что не хватает алиаса, показано, для какой части запроса, и предложена настройка, позволяющая ослабить это требование. + +Пример катастрофически плохого сообщения: +``` +The dictionary is configured incorrectly. +``` +Из него не понятно: +- какой словарь? +- в чём ошибка конфигурации? + +Что может сделать пользователь в такой ситуации: применять внешние отладочные инструменты, спрашивать совета на форумах, гадать на кофейной гуще, и, конечно же, ненавидеть софт, который над ним так издевается. Не нужно издеваться над пользователями, это плохой UX. + + +### Внутренняя программная ошибка {#error-messages-internal-error} + +Такая ошибка вызвана нарушением внутренних инвариантов программы: например, внутренняя функция вызвана с неверными параметрами, не совпадают размеры колонок в блоке, произошло разыменование нулевого указателя, и так далее. Сигналы типа `SIGSEGV` относятся к этой же категории. + +Появление такой ошибки всегда свидетельствует о наличии бага в программе. Пользователь не может исправить такую ошибку самостоятельно, и должен сообщить о ней разработчикам. + +Есть два основных варианта проверки на такие ошибки: +* Исключение с кодом `LOGICAL_ERROR`. Его можно использовать для важных проверок, которые делаются в том числе в релизной сборке. +* `assert`. Такие условия не проверяются в релизной сборке, можно использовать для тяжёлых и опциональных проверок. + +Пример сообщения, у которого должен быть код `LOGICAL_ERROR`: +`Block header is inconsistent with Chunk in ICompicatedProcessor::munge(). It is a bug!` +По каким признакам можно заметить, что здесь говорится о внутренней программной ошибке? +* в сообщении упоминаются внутренние сущности из кода, +* в сообщении написано it's a bug, +* непосредственные действия пользователя не могут исправить эту ошибку. Мы ожидаем, что пользователь зарепортит её как баг, и будем исправлять в коде. + +### Как выбрать код ошибки? {#error-messages-choose} + +Код ошибки предназначен для автоматической обработки некоторых видов ошибок, подобно кодам HTTP. SQL стандартизирует некоторые коды, но на деле ClickHouse не всегда соответствует этим стандартам. Лучше всего выбрать существующий код из `ErrorCodes.cpp`, который больше всего подходит по смыслу. Можно использовать общие коды типа `BAD_ARGUMENTS` или `TYPE_MISMATCH`. Заводить новый код нужно, только если вы чётко понимаете, что вам нужна специальная автоматическая обработка конкретно этой ошибки на клиенте. Для внутренних программных ошибок используется код `LOGICAL_ERROR`. + +### Как добавить новое сообщение об ошибке? {#error-messages-add} + +Когда добавляете сообщение об ошибке: +1. Опишите, что произошло, в пользовательских терминах, а не кусками кода. +2. Добавьте максимум контекста (с чем произошло, когда, почему, и т.д.). +3. Добавьте типичные причины. +4. Добавьте варианты исправления (настройки, ссылки на документацию). +5. Вообразите дальнейшие действия пользователя. Ваше сообщение должно помочь ему решить проблему без использования отладочных инструментов и без чужой помощи. +6. Если сообщение об ошибке не формулируется в пользовательских терминах, и действия пользователя не могут исправить проблему -- это внутренняя программная ошибка, используйте код LOGICAL_ERROR или assert. + ## Платформа {#platforma} **1.** Мы пишем код под конкретные платформы. @@ -706,7 +773,7 @@ auto s = std::string{"Hello"}; **4.** ОС - Linux, Mac OS X или FreeBSD. -**5.** Код пишется под процессоры с архитектурой x86_64, AArch64 и ppc64le. +**5.** Код пишется под процессоры с архитектурой x86\_64, AArch64 и ppc64le. **6.** Используются флаги компиляции `-Wall -Wextra -Werror` и `-Weverything` с некоторыми исключениями. diff --git a/docs/ru/engines/database-engines/index.md b/docs/ru/engines/database-engines/index.md new file mode 100644 index 00000000000..79be85518e2 --- /dev/null +++ b/docs/ru/engines/database-engines/index.md @@ -0,0 +1,9 @@ +# Движки баз данных {#dvizhki-baz-dannykh} + +Движки баз данных обеспечивают работу с таблицами. + +По умолчанию ClickHouse использует собственный движок баз данных, который поддерживает конфигурируемые [движки таблиц](../../engines/database-engines/index.md) и [диалект SQL](../../engines/database-engines/index.md). + +Также можно использовать следующие движки баз данных: + +- [MySQL](mysql.md) diff --git a/docs/ru/engines/database_engines/lazy.md b/docs/ru/engines/database-engines/lazy.md similarity index 100% rename from docs/ru/engines/database_engines/lazy.md rename to docs/ru/engines/database-engines/lazy.md diff --git a/docs/ru/engines/database-engines/mysql.md b/docs/ru/engines/database-engines/mysql.md new file mode 100644 index 00000000000..e293cb6ec77 --- /dev/null +++ b/docs/ru/engines/database-engines/mysql.md @@ -0,0 +1,126 @@ +# MySQL {#mysql} + +Позволяет подключаться к базам данных на удалённом MySQL сервере и выполнять запросы `INSERT` и `SELECT` для обмена данными между ClickHouse и MySQL. + +Движок баз данных `MySQL` транслирует запросы при передаче на сервер MySQL, что позволяет выполнять и другие виды запросов, например `SHOW TABLES` или `SHOW CREATE TABLE`. + +Не поддерживаемые виды запросов: + +- `RENAME` +- `CREATE TABLE` +- `ALTER` + +## Создание базы данных {#sozdanie-bazy-dannykh} + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] +ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') +``` + +**Параметры движка** + +- `host:port` — адрес сервера MySQL. +- `database` — имя базы данных на удалённом сервере. +- `user` — пользователь MySQL. +- `password` — пароль пользователя. + +## Поддержка типов данных {#podderzhka-tipov-dannykh} + +| MySQL | ClickHouse | +|----------------------------------|--------------------------------------------------------| +| UNSIGNED TINYINT | [UInt8](../../engines/database-engines/mysql.md) | +| TINYINT | [Int8](../../engines/database-engines/mysql.md) | +| UNSIGNED SMALLINT | [UInt16](../../engines/database-engines/mysql.md) | +| SMALLINT | [Int16](../../engines/database-engines/mysql.md) | +| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../engines/database-engines/mysql.md) | +| INT, MEDIUMINT | [Int32](../../engines/database-engines/mysql.md) | +| UNSIGNED BIGINT | [UInt64](../../engines/database-engines/mysql.md) | +| BIGINT | [Int64](../../engines/database-engines/mysql.md) | +| FLOAT | [Float32](../../engines/database-engines/mysql.md) | +| DOUBLE | [Float64](../../engines/database-engines/mysql.md) | +| DATE | [Date](../../engines/database-engines/mysql.md) | +| DATETIME, TIMESTAMP | [DateTime](../../engines/database-engines/mysql.md) | +| BINARY | [FixedString](../../engines/database-engines/mysql.md) | + +Все прочие типы данных преобразуются в [String](../../engines/database-engines/mysql.md). + +[Nullable](../../engines/database-engines/mysql.md) поддержан. + +## Примеры использования {#primery-ispolzovaniia} + +Таблица в MySQL: + +``` text +mysql> USE test; +Database changed + +mysql> CREATE TABLE `mysql_table` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `float` FLOAT NOT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from mysql_table; ++--------+-------+ +| int_id | value | ++--------+-------+ +| 1 | 2 | ++--------+-------+ +1 row in set (0,00 sec) +``` + +База данных в ClickHouse, позволяющая обмениваться данными с сервером MySQL: + +``` sql +CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') +``` + +``` sql +SHOW DATABASES +``` + +``` text +┌─name─────┐ +│ default │ +│ mysql_db │ +│ system │ +└──────────┘ +``` + +``` sql +SHOW TABLES FROM mysql_db +``` + +``` text +┌─name─────────┐ +│ mysql_table │ +└──────────────┘ +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +└────────┴───────┘ +``` + +``` sql +INSERT INTO mysql_db.mysql_table VALUES (3,4) +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +│ 3 │ 4 │ +└────────┴───────┘ +``` diff --git a/docs/ru/engines/database_engines/index.md b/docs/ru/engines/database_engines/index.md deleted file mode 100644 index 75086eaf678..00000000000 --- a/docs/ru/engines/database_engines/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Движки баз данных {#dvizhki-baz-dannykh} - -Движки баз данных обеспечивают работу с таблицами. - -По умолчанию ClickHouse использует собственный движок баз данных, который поддерживает конфигурируемые [движки таблиц](../../engines/database_engines/index.md) и [диалект SQL](../../engines/database_engines/index.md). - -Также можно использовать следующие движки баз данных: - -- [MySQL](mysql.md) diff --git a/docs/ru/engines/database_engines/mysql.md b/docs/ru/engines/database_engines/mysql.md deleted file mode 100644 index 1dbcb67e8f1..00000000000 --- a/docs/ru/engines/database_engines/mysql.md +++ /dev/null @@ -1,126 +0,0 @@ -# MySQL {#mysql} - -Позволяет подключаться к базам данных на удалённом MySQL сервере и выполнять запросы `INSERT` и `SELECT` для обмена данными между ClickHouse и MySQL. - -Движок баз данных `MySQL` транслирует запросы при передаче на сервер MySQL, что позволяет выполнять и другие виды запросов, например `SHOW TABLES` или `SHOW CREATE TABLE`. - -Не поддерживаемые виды запросов: - -- `RENAME` -- `CREATE TABLE` -- `ALTER` - -## Создание базы данных {#sozdanie-bazy-dannykh} - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] -ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') -``` - -**Параметры движка** - -- `host:port` — адрес сервера MySQL. -- `database` — имя базы данных на удалённом сервере. -- `user` — пользователь MySQL. -- `password` — пароль пользователя. - -## Поддержка типов данных {#podderzhka-tipov-dannykh} - -| MySQL | ClickHouse | -|----------------------------------|---------------------------------------------| -| UNSIGNED TINYINT | [UInt8](../../engines/database_engines/mysql.md) | -| TINYINT | [Int8](../../engines/database_engines/mysql.md) | -| UNSIGNED SMALLINT | [UInt16](../../engines/database_engines/mysql.md) | -| SMALLINT | [Int16](../../engines/database_engines/mysql.md) | -| UNSIGNED INT, UNSIGNED MEDIUMINT | [UInt32](../../engines/database_engines/mysql.md) | -| INT, MEDIUMINT | [Int32](../../engines/database_engines/mysql.md) | -| UNSIGNED BIGINT | [UInt64](../../engines/database_engines/mysql.md) | -| BIGINT | [Int64](../../engines/database_engines/mysql.md) | -| FLOAT | [Float32](../../engines/database_engines/mysql.md) | -| DOUBLE | [Float64](../../engines/database_engines/mysql.md) | -| DATE | [Date](../../engines/database_engines/mysql.md) | -| DATETIME, TIMESTAMP | [DateTime](../../engines/database_engines/mysql.md) | -| BINARY | [FixedString](../../engines/database_engines/mysql.md) | - -Все прочие типы данных преобразуются в [String](../../engines/database_engines/mysql.md). - -[Nullable](../../engines/database_engines/mysql.md) поддержан. - -## Примеры использования {#primery-ispolzovaniia} - -Таблица в MySQL: - -``` text -mysql> USE test; -Database changed - -mysql> CREATE TABLE `mysql_table` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `float` FLOAT NOT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from mysql_table; -+--------+-------+ -| int_id | value | -+--------+-------+ -| 1 | 2 | -+--------+-------+ -1 row in set (0,00 sec) -``` - -База данных в ClickHouse, позволяющая обмениваться данными с сервером MySQL: - -``` sql -CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') -``` - -``` sql -SHOW DATABASES -``` - -``` text -┌─name─────┐ -│ default │ -│ mysql_db │ -│ system │ -└──────────┘ -``` - -``` sql -SHOW TABLES FROM mysql_db -``` - -``` text -┌─name─────────┐ -│ mysql_table │ -└──────────────┘ -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -└────────┴───────┘ -``` - -``` sql -INSERT INTO mysql_db.mysql_table VALUES (3,4) -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -│ 3 │ 4 │ -└────────┴───────┘ -``` diff --git a/docs/ru/engines/index.md b/docs/ru/engines/index.md index a3d85155cbb..333e65dcb7b 100644 --- a/docs/ru/engines/index.md +++ b/docs/ru/engines/index.md @@ -1,5 +1,5 @@ --- -toc_folder_title: Движки +toc_folder_title: "\u0414\u0432\u0438\u0436\u043A\u0438" toc_priority: 25 --- diff --git a/docs/ru/engines/table-engines/index.md b/docs/ru/engines/table-engines/index.md new file mode 100644 index 00000000000..580ee10250f --- /dev/null +++ b/docs/ru/engines/table-engines/index.md @@ -0,0 +1,76 @@ +# Движки таблиц {#table_engines} + +Движок таблицы (тип таблицы) определяет: + +- Как и где хранятся данные, куда их писать и откуда читать. +- Какие запросы поддерживаются и каким образом. +- Конкурентный доступ к данным. +- Использование индексов, если есть. +- Возможно ли многопоточное выполнение запроса. +- Параметры репликации данных. + +## Семейства движков {#semeistva-dvizhkov} + +### MergeTree {#mergetree} + +Наиболее универсальные и функциональные движки таблиц для задач с высокой загрузкой. Общим свойством этих движков является быстрая вставка данных с последующей фоновой обработкой данных. Движки `*MergeTree` поддерживают репликацию данных (в [Replicated\*](mergetree-family/replication.md#replication) версиях движков), партиционирование, и другие возможности не поддержанные для других движков. + +Движки семейства: + +- [MergeTree](mergetree-family/mergetree.md#mergetree) +- [ReplacingMergeTree](mergetree-family/replacingmergetree.md#replacingmergetree) +- [SummingMergeTree](mergetree-family/summingmergetree.md#summingmergetree) +- [AggregatingMergeTree](mergetree-family/aggregatingmergetree.md#aggregatingmergetree) +- [CollapsingMergeTree](mergetree-family/collapsingmergetree.md#table_engine-collapsingmergetree) +- [VersionedCollapsingMergeTree](mergetree-family/versionedcollapsingmergetree.md#versionedcollapsingmergetree) +- [GraphiteMergeTree](mergetree-family/graphitemergetree.md#graphitemergetree) + +### Log {#log} + +Простые [движки](log-family/index.md) с минимальной функциональностью. Они наиболее эффективны, когда вам нужно быстро записать много небольших таблиц (до примерно 1 миллиона строк) и прочитать их позже целиком. + +Движки семейства: + +- [TinyLog](log-family/tinylog.md#tinylog) +- [StripeLog](log-family/stripelog.md#stripelog) +- [Log](log-family/log.md#log) + +### Движки для интеграции {#dvizhki-dlia-integratsii} + +Движки для связи с другими системами хранения и обработки данных. + +Движки семейства: + +- [Kafka](integrations/kafka.md#kafka) +- [MySQL](integrations/mysql.md#mysql) +- [ODBC](integrations/odbc.md#table-engine-odbc) +- [JDBC](integrations/jdbc.md#table-engine-jdbc) + +### Специальные движки {#spetsialnye-dvizhki} + +Движки семейства: + +- [Distributed](special/distributed.md#distributed) +- [MaterializedView](special/materializedview.md#materializedview) +- [Dictionary](special/dictionary.md#dictionary) +- [Merge](special/merge.md#merge +- [File](special/file.md#file) +- [Null](special/null.md#null) +- [Set](special/set.md#set) +- [Join](special/join.md#join) +- [URL](special/url.md#table_engines-url) +- [View](special/view.md#table_engines-view) +- [Memory](special/memory.md#memory) +- [Buffer](special/buffer.md#buffer) + +## Виртуальные столбцы {#table_engines-virtual_columns} + +Виртуальный столбец — это неотъемлемый атрибут движка таблиц, определенный в исходном коде движка. + +Виртуальные столбцы не надо указывать в запросе `CREATE TABLE` и их не отображаются в результатах запросов `SHOW CREATE TABLE` и `DESCRIBE TABLE`. Также виртуальные столбцы доступны только для чтения, поэтому вы не можете вставлять в них данные. + +Чтобы получить данные из виртуального столбца, необходимо указать его название в запросе `SELECT`. `SELECT *` не отображает данные из виртуальных столбцов. + +При создании таблицы со столбцом, имя которого совпадает с именем одного из виртуальных столбцов таблицы, виртуальный столбец становится недоступным. Не делайте так. Чтобы помочь избежать конфликтов, имена виртуальных столбцов обычно предваряются подчеркиванием. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/) diff --git a/docs/ru/engines/table-engines/integrations/hdfs.md b/docs/ru/engines/table-engines/integrations/hdfs.md new file mode 100644 index 00000000000..698139fa8a3 --- /dev/null +++ b/docs/ru/engines/table-engines/integrations/hdfs.md @@ -0,0 +1,112 @@ +# HDFS {#table_engines-hdfs} + +Управляет данными в HDFS. Данный движок похож на движки [File](../special/file.md#table_engines-file) и [URL](../special/url.md#table_engines-url). + +## Использование движка {#ispolzovanie-dvizhka} + +``` sql +ENGINE = HDFS(URI, format) +``` + +В параметр `URI` нужно передавать полный URI файла в HDFS. +Параметр `format` должен быть таким, который ClickHouse может использовать и в запросах `INSERT`, и в запросах `SELECT`. Полный список поддерживаемых форматов смотрите в разделе [Форматы](../../../interfaces/formats.md#formats). +Часть URI с путем файла может содержать шаблоны. В этом случае таблица может использоваться только для чтения. + +**Пример:** + +**1.** Создадим на сервере таблицу `hdfs_engine_table`: + +``` sql +CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') +``` + +**2.** Заполним файл: + +``` sql +INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) +``` + +**3.** Запросим данные: + +``` sql +SELECT * FROM hdfs_engine_table LIMIT 2 +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Детали реализации {#detali-realizatsii} + +- Поддерживается многопоточное чтение и запись. +- Не поддерживается: + - использование операций `ALTER` и `SELECT...SAMPLE`; + - индексы; + - репликация. + +**Шаблоны в пути** + +Шаблоны могут содержаться в нескольких компонентах пути. Обрабатываются только существующие файлы, название которых целиком удовлетворяет шаблону (не только суффиксом или префиксом). + +- `*` — Заменяет любое количество любых символов кроме `/`, включая отсутствие символов. +- `?` — Заменяет ровно один любой символ. +- `{some_string,another_string,yet_another_one}` — Заменяет любую из строк `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Заменяет любое число в интервале от `N` до `M` включительно (может содержать ведущие нули). + +Конструкция с `{}` аналогична табличной функции [remote](../../../engines/table-engines/integrations/hdfs.md). + +**Пример** + +1. Предположим, у нас есть несколько файлов со следующими URI в HDFS: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. Есть несколько возможностей создать таблицу, состояющую из этих шести файлов: + + + +``` sql +CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') +``` + +Другой способ: + +``` sql +CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') +``` + +Таблица, состоящая из всех файлов в обеих директориях (все файлы должны удовлетворять формату и схеме, указанной в запросе): + +``` sql +CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') +``` + +!!! warning "Warning" + Если список файлов содержит числовые интервалы с ведущими нулями, используйте конструкцию с фигурными скобочками для каждой цифры или используйте `?`. + +**Example** + +Создадим таблицу с именами `file000`, `file001`, … , `file999`: + +``` sql +CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') +``` + +## Виртуальные столбцы {#virtualnye-stolbtsy} + +- `_path` — Путь к файлу. +- `_file` — Имя файла. + +**Смотрите также** + +- [Виртуальные столбцы](index.md#table_engines-virtual_columns) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/hdfs/) diff --git a/docs/ru/engines/table-engines/integrations/index.md b/docs/ru/engines/table-engines/integrations/index.md new file mode 100644 index 00000000000..dd005919ad1 --- /dev/null +++ b/docs/ru/engines/table-engines/integrations/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Integrations +toc_priority: 30 +--- + + diff --git a/docs/ru/engines/table-engines/integrations/jdbc.md b/docs/ru/engines/table-engines/integrations/jdbc.md new file mode 100644 index 00000000000..cded0c51fa0 --- /dev/null +++ b/docs/ru/engines/table-engines/integrations/jdbc.md @@ -0,0 +1,87 @@ +# JDBC {#table-engine-jdbc} + +Позволяет ClickHouse подключаться к внешним базам данных с помощью [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). + +Для реализации соединения по JDBC ClickHouse использует отдельную программу [clickhouse-jdbc-bridge](https://github.com/alex-krash/clickhouse-jdbc-bridge), которая должна запускаться как демон. + +Движок поддерживает тип данных [Nullable](../../../engines/table-engines/integrations/jdbc.md). + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name +ENGINE = JDBC(dbms_uri, external_database, external_table) +``` + +**Параметры движка** + +- `dbms_uri` — URI внешней СУБД. + + Формат: `jdbc:://:/?user=&password=`. + + Пример для MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. + +- `external_database` — база данных во внешней СУБД. + +- `external_table` — таблица в `external_database`. + +## Пример использования {#primer-ispolzovaniia} + +Создадим таблицу в на сервере MySQL с помощью консольного клиента MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++--------+--------------+-------+----------------+ +| int_id | int_nullable | float | float_nullable | ++--------+--------------+-------+----------------+ +| 1 | NULL | 2 | NULL | ++--------+--------------+-------+----------------+ +1 row in set (0,00 sec) +``` + +Создадим таблицу на сервере ClickHouse и получим из неё данные: + +``` sql +CREATE TABLE jdbc_table ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') +``` + +``` sql +DESCRIBE TABLE jdbc_table +``` + +``` text +┌─name───────────────┬─type───────────────┬─default_type─┬─default_expression─┐ +│ int_id │ Int32 │ │ │ +│ int_nullable │ Nullable(Int32) │ │ │ +│ float │ Float32 │ │ │ +│ float_nullable │ Nullable(Float32) │ │ │ +└────────────────────┴────────────────────┴──────────────┴────────────────────┘ +``` + +``` sql +SELECT * +FROM jdbc_table +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## Смотрите также {#smotrite-takzhe} + +- [Табличная функция JDBC](../../../engines/table-engines/integrations/jdbc.md). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/jdbc/) diff --git a/docs/ru/engines/table-engines/integrations/kafka.md b/docs/ru/engines/table-engines/integrations/kafka.md new file mode 100644 index 00000000000..8a79c8556b8 --- /dev/null +++ b/docs/ru/engines/table-engines/integrations/kafka.md @@ -0,0 +1,170 @@ +# Kafka {#kafka} + +Движок работает с [Apache Kafka](http://kafka.apache.org/). + +Kafka позволяет: + +- Публиковать/подписываться на потоки данных. +- Организовать отказоустойчивое хранилище. +- Обрабатывать потоки по мере их появления. + +## Создание таблицы {#table_engine-kafka-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = Kafka() +SETTINGS + kafka_broker_list = 'host:port', + kafka_topic_list = 'topic1,topic2,...', + kafka_group_name = 'group_name', + kafka_format = 'data_format'[,] + [kafka_row_delimiter = 'delimiter_symbol',] + [kafka_schema = '',] + [kafka_num_consumers = N,] + [kafka_skip_broken_messages = N] +``` + +Обязательные параметры: + +- `kafka_broker_list` – перечень брокеров, разделенный запятыми (`localhost:9092`). +- `kafka_topic_list` – перечень необходимых топиков Kafka. +- `kafka_group_name` – группа потребителя Kafka. Отступы для чтения отслеживаются для каждой группы отдельно. Если необходимо, чтобы сообщения не повторялись на кластере, используйте везде одно имя группы. +- `kafka_format` – формат сообщений. Названия форматов должны быть теми же, что можно использовать в секции `FORMAT`, например, `JSONEachRow`. Подробнее читайте в разделе [Форматы](../../../interfaces/formats.md). + +Опциональные параметры: + +- `kafka_row_delimiter` – символ-разделитель записей (строк), которым завершается сообщение. +- `kafka_schema` – опциональный параметр, необходимый, если используется формат, требующий определения схемы. Например, [Cap’n Proto](https://capnproto.org/) требует путь к файлу со схемой и название корневого объекта `schema.capnp:Message`. +- `kafka_num_consumers` – количество потребителей (consumer) на таблицу. По умолчанию: `1`. Укажите больше потребителей, если пропускная способность одного потребителя недостаточна. Общее число потребителей не должно превышать количество партиций в топике, так как на одну партицию может быть назначено не более одного потребителя. +- `kafka_skip_broken_messages` – максимальное количество некорректных сообщений в блоке. Если `kafka_skip_broken_messages = N`, то движок отбрасывает `N` сообщений Кафки, которые не получилось обработать. Одно сообщение в точности соответствует одной записи (строке). Значение по умолчанию – 0. + +Примеры + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + SELECT * FROM queue LIMIT 5; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', + kafka_topic_list = 'topic', + kafka_group_name = 'group1', + kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') + SETTINGS kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; +``` + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот метод в новых проектах. По возможности переключите старые проекты на метод, описанный выше. + +``` sql +Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format + [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) +``` + +
+ +## Описание {#opisanie} + +Полученные сообщения отслеживаются автоматически, поэтому из одной группы каждое сообщение считывается только один раз. Если необходимо получить данные дважды, то создайте копию таблицы с другим именем группы. + +Группы пластичны и синхронизированы на кластере. Например, если есть 10 топиков и 5 копий таблицы в кластере, то в каждую копию попадет по 2 топика. Если количество копий изменится, то распределение топиков по копиям изменится автоматически. Подробно читайте об этом на http://kafka.apache.org/intro. + +Чтение сообщения с помощью `SELECT` не слишком полезно (разве что для отладки), поскольку каждое сообщения может быть прочитано только один раз. Практичнее создавать потоки реального времени с помощью материализованных преставлений. Для этого: + +1. Создайте потребителя Kafka с помощью движка и рассматривайте его как поток данных. +2. Создайте таблицу с необходимой структурой. +3. Создайте материализованное представление, которое преобразует данные от движка и помещает их в ранее созданную таблицу. + +Когда к движку присоединяется материализованное представление (`MATERIALIZED VIEW`), оно начинает в фоновом режиме собирать данные. Это позволяет непрерывно получать сообщения от Kafka и преобразовывать их в необходимый формат с помощью `SELECT`. +Материализованных представлений у одной kafka таблицы может быть сколько угодно, они не считывают данные из таблицы kafka непосредственно, а получают новые записи (блоками), таким образом можно писать в несколько таблиц с разным уровнем детализации (с группировкой - агрегацией и без). + +Пример: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + CREATE TABLE daily ( + day Date, + level String, + total UInt64 + ) ENGINE = SummingMergeTree(day, (day, level), 8192); + + CREATE MATERIALIZED VIEW consumer TO daily + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + FROM queue GROUP BY day, level; + + SELECT level, sum(total) FROM daily GROUP BY level; +``` + +Для улучшения производительности полученные сообщения группируются в блоки размера [max\_insert\_block\_size](../../../operations/settings/settings.md#settings-max_insert_block_size). Если блок не удалось сформировать за [stream\_flush\_interval\_ms](../../../operations/settings/settings.md#stream-flush-interval-ms) миллисекунд, то данные будут сброшены в таблицу независимо от полноты блока. + +Чтобы остановить получение данных топика или изменить логику преобразования, отсоедините материализованное представление: + +``` sql + DETACH TABLE consumer; + ATTACH TABLE consumer; +``` + +Если необходимо изменить целевую таблицу с помощью `ALTER`, то материализованное представление рекомендуется отключить, чтобы избежать несостыковки между целевой таблицей и данными от представления. + +## Конфигурация {#konfiguratsiia} + +Аналогично GraphiteMergeTree, движок Kafka поддерживает расширенную конфигурацию с помощью конфигурационного файла ClickHouse. Существует два конфигурационных ключа, которые можно использовать: глобальный (`kafka`) и по топикам (`kafka_topic_*`). Сначала применяется глобальная конфигурация, затем конфигурация по топикам (если она существует). + +``` xml + + + cgrp + smallest + + + + + 250 + 100000 + +``` + +В документе [librdkafka configuration reference](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) можно увидеть список возможных опций конфигурации. Используйте подчеркивание (`_`) вместо точки в конфигурации ClickHouse. Например, `check.crcs=true` будет соответствовать `true`. + +## Виртуальные столбцы {#virtualnye-stolbtsy} + +- `_topic` — топик Kafka. +- `_key` — ключ сообщения. +- `_offset` — оффсет сообщения. +- `_timestamp` — временная метка сообщения. +- `_partition` — секция топика Kafka. + +**Смотрите также** + +- [Виртуальные столбцы](index.md#table_engines-virtual_columns) +- [background_schedule_pool_size](../../../operations/settings/settings.md#background_schedule_pool_size) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/kafka/) diff --git a/docs/ru/engines/table-engines/integrations/mysql.md b/docs/ru/engines/table-engines/integrations/mysql.md new file mode 100644 index 00000000000..9891fe79959 --- /dev/null +++ b/docs/ru/engines/table-engines/integrations/mysql.md @@ -0,0 +1,98 @@ +# MySQL {#mysql} + +Движок MySQL позволяет выполнять запросы `SELECT` над данными, хранящимися на удалённом MySQL сервере. + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... +) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table-engines/integrations/mysql.md#create-table-query). + +Структура таблицы может отличаться от исходной структуры таблицы MySQL: + +- Имена столбцов должны быть такими же, как в исходной таблице MySQL, но вы можете использовать только некоторые из этих столбцов и в любом порядке. +- Типы столбцов могут отличаться от типов в исходной таблице MySQL. ClickHouse пытается [приводить](../../../engines/table-engines/integrations/mysql.md#type_conversion_function-cast) значения к типам данных ClickHouse. + +**Параметры движка** + +- `host:port` — адрес сервера MySQL. + +- `database` — имя базы данных на удалённом сервере. + +- `table` — имя таблицы на удалённом сервере. + +- `user` — пользователь MySQL. + +- `password` — пароль пользователя. + +- `replace_query` — флаг, отвечающий за преобразование запросов `INSERT INTO` в `REPLACE INTO`. Если `replace_query=1`, то запрос заменяется. + +- `on_duplicate_clause` — выражение `ON DUPLICATE KEY on_duplicate_clause`, добавляемое к запросу `INSERT`. + + Пример: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, где `on_duplicate_clause` это `UPDATE c2 = c2 + 1`. Чтобы узнать какие `on_duplicate_clause` можно использовать с секцией `ON DUPLICATE KEY` обратитесь к [документации MySQL](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html). + + Чтобы указать `on_duplicate_clause` необходимо передать `0` в параметр `replace_query`. Если одновременно передать `replace_query = 1` и `on_duplicate_clause`, то ClickHouse сгенерирует исключение. + +Простые условия `WHERE` такие как `=, !=, >, >=, <, =` выполняются на стороне сервера MySQL. + +Остальные условия и ограничение выборки `LIMIT` будут выполнены в ClickHouse только после выполнения запроса к MySQL. + +## Пример использования {#primer-ispolzovaniia} + +Таблица в MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++--------+--------------+-------+----------------+ +| int_id | int_nullable | float | float_nullable | ++--------+--------------+-------+----------------+ +| 1 | NULL | 2 | NULL | ++--------+--------------+-------+----------------+ +1 row in set (0,00 sec) +``` + +Таблица в ClickHouse, которая получает данные из созданной ранее таблицы MySQL: + +``` sql +CREATE TABLE mysql_table +( + `float_nullable` Nullable(Float32), + `int_id` Int32 +) +ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` sql +SELECT * FROM mysql_table +``` + +``` text +┌─float_nullable─┬─int_id─┐ +│ ᴺᵁᴸᴸ │ 1 │ +└────────────────┴────────┘ +``` + +## Смотрите также {#smotrite-takzhe} + +- [Табличная функция ‘mysql’](../../../engines/table-engines/integrations/mysql.md) +- [Использование MySQL в качестве источника для внешнего словаря](../../../engines/table-engines/integrations/mysql.md#dicts-external_dicts_dict_sources-mysql) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/mysql/) diff --git a/docs/ru/engines/table-engines/integrations/odbc.md b/docs/ru/engines/table-engines/integrations/odbc.md new file mode 100644 index 00000000000..aecdbbf038d --- /dev/null +++ b/docs/ru/engines/table-engines/integrations/odbc.md @@ -0,0 +1,125 @@ +# ODBC {#table-engine-odbc} + +Позволяет ClickHouse подключаться к внешним базам данных с помощью [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +Чтобы использование ODBC было безопасным, ClickHouse использует отдельную программу `clickhouse-odbc-bridge`. Если драйвер ODBC подгружать непосредственно из `clickhouse-server`, то проблемы с драйвером могут привести к аварийной остановке сервера ClickHouse. ClickHouse автоматически запускает `clickhouse-odbc-bridge` по мере необходимости. Программа устанавливается из того же пакета, что и `clickhouse-server`. + +Движок поддерживает тип данных [Nullable](../../../engines/table-engines/integrations/odbc.md). + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1], + name2 [type2], + ... +) +ENGINE = ODBC(connection_settings, external_database, external_table) +``` + +Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table-engines/integrations/odbc.md#create-table-query). + +Структура таблицы может отличаться от структуры исходной таблицы в удалённой СУБД: + +- Имена столбцов должны быть такими же, как в исходной таблице, но вы можете использовать только некоторые из этих столбцов и в любом порядке. +- Типы столбцов могут отличаться от типов аналогичных столбцов в исходной таблице. ClickHouse пытается [приводить](../../../engines/table-engines/integrations/odbc.md#type_conversion_function-cast) значения к типам данных ClickHouse. + +**Параметры движка** + +- `connection_settings` — название секции с настройками соединения в файле `odbc.ini`. +- `external_database` — имя базы данных во внешней СУБД. +- `external_table` — имя таблицы в `external_database`. + +## Пример использования {#primer-ispolzovaniia} + +**Извлечение данных из локальной установки MySQL через ODBC** + +Этот пример проверялся в Ubuntu Linux 18.04 для MySQL server 5.7. + +Убедитесь, что unixODBC и MySQL Connector установлены. + +По умолчанию (если установлен из пакетов) ClickHouse запускается от имени пользователя `clickhouse`. Таким образом, вам нужно создать и настроить этого пользователя на сервере MySQL. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +Теперь настроим соединение в `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +Вы можете проверить соединение с помощью утилиты `isql` из установки unixODBC. + +``` bash +$ isql -v mysqlconn ++---------------------------------------+ +| Connected! | +| | +... +``` + +Таблица в MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++--------+--------------+-------+----------------+ +| int_id | int_nullable | float | float_nullable | ++--------+--------------+-------+----------------+ +| 1 | NULL | 2 | NULL | ++--------+--------------+-------+----------------+ +1 row in set (0,00 sec) +``` + +Таблица в ClickHouse, которая получает данные из таблицы MySQL: + +``` sql +CREATE TABLE odbc_t +( + `int_id` Int32, + `float_nullable` Nullable(Float32) +) +ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') +``` + +``` sql +SELECT * FROM odbc_t +``` + +``` text +┌─int_id─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ +└────────┴────────────────┘ +``` + +## Смотрите также {#smotrite-takzhe} + +- [Внешние словари ODBC](../../../engines/table-engines/integrations/odbc.md#dicts-external_dicts_dict_sources-odbc) +- [Табличная функция odbc](../../../engines/table-engines/integrations/odbc.md) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/odbc/) diff --git a/docs/ru/engines/table-engines/log-family/index.md b/docs/ru/engines/table-engines/log-family/index.md new file mode 100644 index 00000000000..a5d93c4c7c3 --- /dev/null +++ b/docs/ru/engines/table-engines/log-family/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Log Family +toc_priority: 29 +--- + + diff --git a/docs/ru/engines/table-engines/log-family/log-family.md b/docs/ru/engines/table-engines/log-family/log-family.md new file mode 100644 index 00000000000..e5156c95f9e --- /dev/null +++ b/docs/ru/engines/table-engines/log-family/log-family.md @@ -0,0 +1,39 @@ +# Семейство Log {#semeistvo-log} + +Движки разработаны для сценариев, когда необходимо быстро записывать много таблиц с небольшим объёмом данных (менее 1 миллиона строк), а затем читать их целиком. + +Движки семейства: + +- [StripeLog](stripelog.md) +- [Log](log.md) +- [TinyLog](tinylog.md) + +## Общие свойства {#obshchie-svoistva} + +Движки: + +- Хранят данные на диске. + +- Добавляют данные в конец файла при записи. + +- Поддерживают блокировки для конкурентного доступа к данным. + + Во время запросов `INSERT` таблица блокируется, а другие запросы на чтение и запись ожидают разблокировки таблицы. Если запросов на запись данных нет, то можно выполнять любое количество конкуретных запросов на чтение. + +- Не поддерживают операции [мутации](../../../engines/table-engines/log-family/log-family.md#alter-mutations). + +- Не поддерживают индексы. + + Это означает, что запросы `SELECT` не эффективны для выборки диапазонов данных. + +- Записывают данные не атомарно. + + Вы можете получить таблицу с повреждёнными данными, если что-то прервёт операцию записи (например, аварийное завершение работы сервера). + +## Отличия {#otlichiia} + +Движок `TinyLog` самый простой в семье и обеспечивает самые низкие функциональность и эффективность. Движок `TinyLog` не поддерживает параллельного чтения данных в несколько потоков. Движок читает данные медленнее, чем оба других движка с параллельным чтением, и использует почти столько же дескрипторов, сколько и движок `Log`, поскольку хранит каждый столбец в отдельном файле. Его можно использовать в простых сценариях с низкой нагрузкой. + +Движки `Log` и `StripeLog` поддерживают параллельное чтение. При чтении данных, ClickHouse использует множество потоков. Каждый поток обрабатывает отдельный блок данных. Движок `Log` сохраняет каждый столбец таблицы в отдельном файле. Движок `StripeLog` хранит все данные в одном файле. Таким образом, движок `StripeLog` использует меньше дескрипторов в операционной системе, а движок `Log` обеспечивает более эффективное считывание данных. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/log_family/) diff --git a/docs/ru/engines/table-engines/log-family/log.md b/docs/ru/engines/table-engines/log-family/log.md new file mode 100644 index 00000000000..84474b3f40a --- /dev/null +++ b/docs/ru/engines/table-engines/log-family/log.md @@ -0,0 +1,9 @@ +# Log {#log} + +Движок относится к семейству движков Log. Смотрите общие свойства и различия движков в статье [Семейство Log](log-family.md). + +Отличается от [TinyLog](tinylog.md) тем, что вместе с файлами столбцов лежит небольшой файл «засечек». Засечки пишутся на каждый блок данных и содержат смещение - с какого места нужно читать файл, чтобы пропустить заданное количество строк. Это позволяет читать данные из таблицы в несколько потоков. +При конкурентном доступе к данным, чтения могут выполняться одновременно, а записи блокируют чтения и друг друга. +Движок Log не поддерживает индексы. Также, если при записи в таблицу произошёл сбой, то таблица станет битой, и чтения из неё будут возвращать ошибку. Движок Log подходит для временных данных, write-once таблиц, а также для тестовых и демонстрационных целей. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/log/) diff --git a/docs/ru/engines/table-engines/log-family/stripelog.md b/docs/ru/engines/table-engines/log-family/stripelog.md new file mode 100644 index 00000000000..d129cc055da --- /dev/null +++ b/docs/ru/engines/table-engines/log-family/stripelog.md @@ -0,0 +1,88 @@ +# StripeLog {#stripelog} + +Движок относится к семейству движков Log. Смотрите общие свойства и различия движков в статье [Семейство Log](log-family.md). + +Движок разработан для сценариев, когда необходимо записывать много таблиц с небольшим объёмом данных (менее 1 миллиона строк). + +## Создание таблицы {#table_engines-stripelog-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = StripeLog +``` + +Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table-engines/log-family/stripelog.md#create-table-query). + +## Запись данных {#table_engines-stripelog-writing-the-data} + +Движок `StripeLog` хранит все столбцы в одном файле. При каждом запросе `INSERT`, ClickHouse добавляет блок данных в конец файла таблицы, записывая столбцы один за другим. + +Для каждой таблицы ClickHouse записывает файлы: + +- `data.bin` — файл с данными. +- `index.mrk` — файл с метками. Метки содержат смещения для каждого столбца каждого вставленного блока данных. + +Движок `StripeLog` не поддерживает запросы `ALTER UPDATE` и `ALTER DELETE`. + +## Чтение данных {#table_engines-stripelog-reading-the-data} + +Файл с метками позволяет ClickHouse распараллеливать чтение данных. Это означает, что запрос `SELECT` возвращает строки в непредсказуемом порядке. Используйте секцию `ORDER BY` для сортировки строк. + +## Пример использования {#table_engines-stripelog-example-of-use} + +Создание таблицы: + +``` sql +CREATE TABLE stripe_log_table +( + timestamp DateTime, + message_type String, + message String +) +ENGINE = StripeLog +``` + +Вставка данных: + +``` sql +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') +``` + +Мы использовали два запроса `INSERT` для создания двух блоков данных внутри файла `data.bin`. + +ClickHouse использует несколько потоков при выборе данных. Каждый поток считывает отдельный блок данных и возвращает результирующие строки независимо по мере завершения. В результате порядок блоков строк в выходных данных в большинстве случаев не совпадает с порядком тех же блоков во входных данных. Например: + +``` sql +SELECT * FROM stripe_log_table +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +┌───────────timestamp─┬─message_type─┬─message───────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +└─────────────────────┴──────────────┴───────────────────────────┘ +``` + +Сортировка результатов (по умолчанию по возрастанию): + +``` sql +SELECT * FROM stripe_log_table ORDER BY timestamp +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/stripelog/) diff --git a/docs/ru/engines/table-engines/log-family/tinylog.md b/docs/ru/engines/table-engines/log-family/tinylog.md new file mode 100644 index 00000000000..f9374272fbf --- /dev/null +++ b/docs/ru/engines/table-engines/log-family/tinylog.md @@ -0,0 +1,9 @@ +# TinyLog {#tinylog} + +Движок относится к семейству движков Log. Смотрите общие свойства и различия движков в статье [Семейство Log](log-family.md). + +Типичный способ использования этой движка — это write-once: сначала данные один раз записываются, а затем читаются столько раз, сколько это необходимо. Например, можно использовать таблицы с движком `TinyLog` для хранения промежуточных данных, которые обрабатываются небольшими блоками. Учтите, что хранить данные в большом количестве мелких таблиц неэффективно. + +Запросы выполняются в один поток. То есть, этот движок предназначен для сравнительно маленьких таблиц (до 1 000 000 строк). Этот движок таблиц имеет смысл использовать в том случае, когда у вас есть много маленьких таблиц, так как он проще, чем движок [Log](log.md) (требуется открывать меньше файлов). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/tinylog/) diff --git a/docs/ru/engines/table-engines/mergetree-family/aggregatingmergetree.md b/docs/ru/engines/table-engines/mergetree-family/aggregatingmergetree.md new file mode 100644 index 00000000000..3e18f890af7 --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/aggregatingmergetree.md @@ -0,0 +1,95 @@ +# AggregatingMergeTree {#aggregatingmergetree} + +Движок наследует функциональность [MergeTree](mergetree.md#table_engines-mergetree), изменяя логику слияния кусков данных. Все строки с одинаковым первичным ключом (точнее, с одинаковым [ключом сортировки](mergetree.md)) ClickHouse заменяет на одну (в пределах одного куска данных), которая хранит объединение состояний агрегатных функций. + +Таблицы типа `AggregatingMergeTree` могут использоваться для инкрементальной агрегации данных, в том числе, для агрегирующих материализованных представлений. + +Движок обрабатывает все столбцы типа [AggregateFunction](../../../engines/table-engines/mergetree-family/aggregatingmergetree.md). + +Использование `AggregatingMergeTree` оправдано только в том случае, когда это уменьшает количество строк на порядки. + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = AggregatingMergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Описание параметров запроса смотрите в [описании запроса](../../../engines/table-engines/mergetree-family/aggregatingmergetree.md). + +**Секции запроса** + +При создании таблицы `AggregatingMergeTree` используются те же [секции](mergetree.md), что и при создании таблицы `MergeTree`. + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +Все параметры имеют то же значение, что в и `MergeTree`. +
+ +## SELECT/INSERT данных {#selectinsert-dannykh} + +Для вставки данных используйте `INSERT SELECT` с агрегатными `-State`-функциями. + +При выборке данных из таблицы `AggregatingMergeTree`, используйте `GROUP BY` и те же агрегатные функции, что и при вставке данных, но с суффиксом `-Merge`. + +В запросах `SELECT` значения типа `AggregateFunction` выводятся во всех форматах, которые поддерживает ClickHouse, в виде implementation-specific бинарных данных. Если с помощью `SELECT` выполнить дамп данных, например, в формат `TabSeparated`, то потом этот дамп можно загрузить обратно с помощью запроса `INSERT`. + +## Пример агрегирущего материализованного представления {#primer-agregirushchego-materializovannogo-predstavleniia} + +Создаём материализованное представление типа `AggregatingMergeTree`, следящее за таблицей `test.visits`: + +``` sql +CREATE MATERIALIZED VIEW test.basic +ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) +AS SELECT + CounterID, + StartDate, + sumState(Sign) AS Visits, + uniqState(UserID) AS Users +FROM test.visits +GROUP BY CounterID, StartDate; +``` + +Вставляем данные в таблицу `test.visits`: + +``` sql +INSERT INTO test.visits ... +``` + +Данные окажутся и в таблице и в представлении `test.basic`, которое выполнит агрегацию. + +Чтобы получить агрегированные данные, выполним запрос вида `SELECT ... GROUP BY ...` из представления `test.basic`: + +``` sql +SELECT + StartDate, + sumMerge(Visits) AS Visits, + uniqMerge(Users) AS Users +FROM test.basic +GROUP BY StartDate +ORDER BY StartDate; +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/aggregatingmergetree/) diff --git a/docs/ru/engines/table-engines/mergetree-family/collapsingmergetree.md b/docs/ru/engines/table-engines/mergetree-family/collapsingmergetree.md new file mode 100644 index 00000000000..f7bc14cc647 --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/collapsingmergetree.md @@ -0,0 +1,302 @@ +# CollapsingMergeTree {#table_engine-collapsingmergetree} + +Движок наследует функциональность от [MergeTree](mergetree.md) и добавляет в алгоритм слияния кусков данных логику сворачивания (удаления) строк. + +`CollapsingMergeTree` асинхронно удаляет (сворачивает) пары строк, если все поля в ключе сортировки (`ORDER BY`) эквивалентны, за исключением специального поля `Sign`, которое может принимать значения `1` и `-1`. Строки без пары сохраняются. Подробнее смотрите в разделе [Сворачивание (удаление) строк](#table_engine-collapsingmergetree-collapsing). + +Движок может значительно уменьшить объём хранения и, как следствие, повысить эффективность запросов `SELECT`. + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = CollapsingMergeTree(sign) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Подробности про `CREATE TABLE` смотрите в [описании запроса](../../../engines/table-engines/mergetree-family/collapsingmergetree.md). + +**Параметры CollapsingMergeTree** + +- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. + + Тип данных столбца — `Int8`. + +**Секции запроса** + +При создании таблицы с движком `CollapsingMergeTree` используются те же [секции запроса](mergetree.md#table_engine-mergetree-creating-a-table) что и при создании таблицы с движком `MergeTree`. + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) +``` + +Все параметры, кроме `ver` имеют то же значение, что и в `MergeTree`. + +- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. + + Тип данных столбца — `Int8`. + +
+ +## Сворачивание (удаление) строк {#table_engine-collapsingmergetree-collapsing} + +### Данные {#dannye} + +Рассмотрим ситуацию, когда необходимо сохранять постоянно изменяющиеся данные для какого-либо объекта. Кажется логичным иметь одну строку для объекта и обновлять её при любом изменении, однако операция обновления является дорогостоящей и медленной для СУБД, поскольку требует перезаписи данных в хранилище. Если необходимо быстро записать данные, обновление не допустимо, но можно записать изменения объекта последовательно как описано ниже. + +Используйте специальный столбец `Sign`. Если `Sign = 1`, то это означает, что строка является состоянием объекта, назовём её строкой состояния. Если `Sign = -1`, то это означает отмену состояния объекта с теми же атрибутами, назовём её строкой отмены состояния. + +Например, мы хотим рассчитать, сколько страниц проверили пользователи на каком-то сайте и как долго они там находились. В какой-то момент времени мы пишем следующую строку с состоянием действий пользователя: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Через некоторое время мы регистрируем изменение активности пользователя и записываем его следующими двумя строками. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Первая строка отменяет предыдущее состояние объекта (пользователя). Она должен повторять все поля из ключа сортировки для отменённого состояния за исключением `Sign`. + +Вторая строка содержит текущее состояние. + +Поскольку нам нужно только последнее состояние активности пользователя, строки + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +можно удалить, сворачивая (удаляя) устаревшее состояние объекта. `CollapsingMergeTree` выполняет это при слиянии кусков данных. + +Зачем нужны две строки для каждого изменения описано в разделе [Алгоритм](#table_engine-collapsingmergetree-collapsing-algorithm). + +**Особенности подхода** + +1. Программа, которая записывает данные, должна помнить состояние объекта, чтобы иметь возможность отменить его. Строка отмены состояния должна содержать копию полей сортировочного ключа предыдущей строки состояния с противоположным значением `Sign`. Это увеличивает начальный размер хранилища, но позволяет быстро записывать данные. +2. Длинные растущие массивы в Столбцах снижают эффективность работы движка за счёт нагрузки на запись. Чем проще данные, тем выше эффективность. +3. Результаты запроса `SELECT` сильно зависят от согласованности истории изменений объекта. Будьте точны при подготовке данных для вставки. Можно получить непредсказуемые результаты для несогласованных данных, например отрицательные значения для неотрицательных метрик, таких как глубина сеанса. + +### Алгоритм {#table_engine-collapsingmergetree-collapsing-algorithm} + +Во время объединения кусков данных, каждая группа последовательных строк с одинаковым сортировочным ключом (`ORDER BY`) уменьшается до не более чем двух строк, одна из которых имеет `Sign = 1` (строка состояния), а другая строка с `Sign = -1` (строка отмены состояния). Другими словами, записи сворачиваются. + +Для каждого результирующего куска данных ClickHouse сохраняет: + +1. Первую строку отмены состояния и последнюю строку состояния, если количество строк обоих видов совпадает и последняя строка — строка состояния. +2. Последнюю строку состояния, если строк состояния на одну больше, чем строк отмены состояния. +3. Первую строку отмены состояния, если их на одну больше, чем строк состояния. +4. Ни одну из строк во всех остальных случаях. + +Также, если строк состояния как минимум на 2 больше, чем строк отмены состояния, или, наоборот, строк отмены состояния как минимум на 2 больше, чем строк состояния, то слияние продолжается, но ClickHouse трактует подобные ситуации как логическую ошибку и записывает её в лог сервера. Подобная ошибка может возникнуть, если один и тот же блок данных вставлен несколько раз. + +Как видно, от сворачивания не должны меняться результаты расчётов статистик. +Изменения постепенно сворачиваются так, что остаются лишь последнее состояние почти каждого объекта. + +Столбец `Sign` необходим, поскольку алгоритм слияния не гарантирует, что все строки с одинаковым ключом сортировки будут находиться в одном результирующем куске данных и даже на одном физическом сервере. ClickHouse выполняет запросы `SELECT` несколькими потоками, и он не может предсказать порядок строк в результате. Если необходимо получить полностью свёрнутые данные из таблицы `CollapsingMergeTree`, то необходимо агрегирование. + +Для завершения свертывания добавьте в запрос секцию`GROUP BY` и агрегатные функции, которые учитывают знак. Например, для расчета количества используйте `sum(Sign)` вместо`count()`. Чтобы вычислить сумму чего-либо, используйте `sum(Sign * x)` вместо`sum(х)`, и так далее, а также добавьте `HAVING sum(Sign) > 0` . + +Таким образом можно вычислять агрегации `count`, `sum` и `avg`. Если объект имеет хотя бы одно не свёрнутое состояние, то может быть вычислена агрегация `uniq`. Агрегации `min` и `max` невозможно вычислить, поскольку `CollapsingMergeTree` не сохраняет историю значений свернутых состояний. + +Если необходимо выбирать данные без агрегации (например, проверить наличие строк, последние значения которых удовлетворяют некоторым условиям), можно использовать модификатор `FINAL` для секции `FROM`. Это вариант существенно менее эффективен. + +## Пример использования {#primer-ispolzovaniia} + +Исходные данные: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Создание таблицы: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Insertion of the data: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) +``` + +Мы используем два запроса `INSERT` для создания двух различных кусков данных. Если вставить данные одним запросом, ClickHouse создаёт один кусок данных и никогда не будет выполнять слияние. + +Получение данных: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Что мы видим и где сворачивание? + +Двумя запросами `INSERT`, мы создали два куска данных. Запрос `SELECT` был выполнен в 2 потока, и мы получили случайный порядок строк. Сворачивание не произошло, так как слияние кусков данных еще не произошло. ClickHouse объединяет куски данных в неизвестный момент времени, который мы не можем предсказать. + +Таким образом, нам нужна агрегация: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration +FROM UAct +GROUP BY UserID +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +Если нам не нужна агрегация, но мы хотим принудительно выполнить свёртку данных, можно использовать модификатор `FINAL` для секции `FROM`. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Такой способ выбора данных очень неэффективен. Не используйте его для больших таблиц. + +## Пример другого подхода {#primer-drugogo-podkhoda} + +Исходные данные: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ -5 │ -146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Идея состоит в том, что слияния при сворачивании учитывают только ключевые поля, поэтому в отменяющей строке можно указать отрицательные значения, которые нивелируют предыдущую версию записи при суммировании без учета поля Sign. +Для этого подхода необходимо изменить тип данных `PageViews`, `Duration` для хранения отрицательных значений UInt8 -\> Int16. + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews Int16, + Duration Int16, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Тестируем подход: + +``` sql +insert into UAct values(4324182021466249494, 5, 146, 1); +insert into UAct values(4324182021466249494, -5, -146, -1); +insert into UAct values(4324182021466249494, 6, 185, 1); + +select * from UAct final; // старайтесь не использовать final (он подходит только для тестов и маленьких таблиц) +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +``` sql +SELECT + UserID, + sum(PageViews) AS PageViews, + sum(Duration) AS Duration +FROM UAct +GROUP BY UserID +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +``` sql +select count() FROM UAct +``` + +``` text +┌─count()─┐ +│ 3 │ +└─────────┘ +``` + +``` sql +optimize table UAct final; + +select * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/collapsingmergetree/) diff --git a/docs/ru/engines/table-engines/mergetree-family/custom-partitioning-key.md b/docs/ru/engines/table-engines/mergetree-family/custom-partitioning-key.md new file mode 100644 index 00000000000..2e8b946ee8c --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/custom-partitioning-key.md @@ -0,0 +1,126 @@ +# Произвольный ключ партиционирования {#proizvolnyi-kliuch-partitsionirovaniia} + +Партиционирование данных доступно для таблиц семейства [MergeTree](mergetree.md) (включая [реплицированные таблицы](replication.md)). Таблицы [MaterializedView](../special/materializedview.md#materializedview), созданные на основе таблиц MergeTree, также поддерживают партиционирование. + +Партиция – это набор записей в таблице, объединенных по какому-либо критерию. Например, партиция может быть по месяцу, по дню или по типу события. Данные для разных партиций хранятся отдельно. Это позволяет оптимизировать работу с данными, так как при обработке запросов будет использоваться только необходимое подмножество из всевозможных данных. Например, при получении данных за определенный месяц, ClickHouse будет считывать данные только за этот месяц. + +Ключ партиционирования задается при [создании таблицы](mergetree.md#table_engine-mergetree-creating-a-table), в секции `PARTITION BY expr`. Ключ может представлять собой произвольное выражение из столбцов таблицы. Например, чтобы задать партиционирования по месяцам, можно использовать выражение `toYYYYMM(date_column)`: + +``` sql +CREATE TABLE visits +( + VisitDate Date, + Hour UInt8, + ClientID UUID +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(VisitDate) +ORDER BY Hour +``` + +Ключом партиционирования также может быть кортеж из выражений (аналогично [первичному ключу](mergetree.md#primary-keys-and-indexes-in-queries)). Например: + +``` sql +ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) +PARTITION BY (toMonday(StartDate), EventType) +ORDER BY (CounterID, StartDate, intHash32(UserID)); +``` + +В этом примере задано партиционирование по типам событий, произошедших в течение текущей недели. + +Каждая партиция состоит из отдельных фрагментов или так называемых *кусков данных*. Каждый кусок отсортирован по первичному ключу. При вставке данных в таблицу каждая отдельная запись сохраняется в виде отдельного куска. Через некоторое время после вставки (обычно до 10 минут), ClickHouse выполняет в фоновом режиме слияние данных — в результате куски для одной и той же партиции будут объединены в более крупный кусок. + +!!! info "Info" + Не рекомендуется делать слишком гранулированное партиционирование – то есть задавать партиции по столбцу, в котором будет слишком большой разброс значений (речь идет о порядке более тысячи партиций). Это приведет к скоплению большого числа файлов и файловых дескрипторов в системе, что может значительно снизить производительность запросов `SELECT`. + +Чтобы получить набор кусков и партиций таблицы, можно воспользоваться системной таблицей [system.parts](../../../engines/table-engines/mergetree-family/custom-partitioning-key.md#system_tables-parts). В качестве примера рассмотрим таблицу `visits`, в которой задано партиционирование по месяцам. Выполним `SELECT` для таблицы `system.parts`: + +``` sql +SELECT + partition, + name, + active +FROM system.parts +WHERE table = 'visits' +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 1 │ +│ 201902 │ 201902_11_11_0 │ 1 │ +└───────────┴────────────────┴────────┘ +``` + +Столбец `partition` содержит имена всех партиций таблицы. Таблица `visits` из нашего примера содержит две партиции: `201901` и `201902`. Используйте значения из этого столбца в запросах [ALTER … PARTITION](#alter_manipulations-with-partitions). + +Столбец `name` содержит названия кусков партиций. Значения из этого столбца можно использовать в запросах [ALTER ATTACH PART](#alter_attach-partition). + +Столбец `active` отображает состояние куска. `1` означает, что кусок активен; `0` – неактивен. К неактивным можно отнести куски, оставшиеся после слияния данных. Поврежденные куски также отображаются как неактивные. Неактивные куски удаляются приблизительно через 10 минут после того, как было выполнено слияние. + +Рассмотрим детальнее имя первого куска `201901_1_3_1`: + +- `201901` имя партиции; +- `1` – минимальный номер блока данных; +- `3` – максимальный номер блока данных; +- `1` – уровень куска (глубина дерева слияний, которыми этот кусок образован). + +!!! info "Info" + Названия кусков для таблиц старого типа образуются следующим образом: `20190117_20190123_2_2_0` (минимальная дата \_ максимальная дата \_ номер минимального блока \_ номер максимального блока \_ уровень). + +Как видно из примера выше, таблица содержит несколько отдельных кусков для одной и той же партиции (например, куски `201901_1_3_1` и `201901_1_9_2` принадлежат партиции `201901`). Это означает, что эти куски еще не были объединены – в файловой системе они хранятся отдельно. После того как будет выполнено автоматическое слияние данных (выполняется примерно спустя 10 минут после вставки данных), исходные куски будут объединены в один более крупный кусок и помечены как неактивные. + +Вы можете запустить внеочередное слияние данных с помощью запроса [OPTIMIZE](../../../engines/table-engines/mergetree-family/custom-partitioning-key.md#misc_operations-optimize). Пример: + +``` sql +OPTIMIZE TABLE visits PARTITION 201902; +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 0 │ +│ 201902 │ 201902_4_11_2 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 0 │ +│ 201902 │ 201902_11_11_0 │ 0 │ +└───────────┴────────────────┴────────┘ +``` + +Неактивные куски будут удалены примерно через 10 минут после слияния. + +Другой способ посмотреть набор кусков и партиций – зайти в директорию с данными таблицы: `/var/lib/clickhouse/data///`. Например: + +``` bash +/var/lib/clickhouse/data/default/visits$ ls -l +total 40 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached +``` + +‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ и т. д. – это директории кусков партиции. Каждый кусок содержит данные только для соответствующего месяца (таблица в данном примере содержит партиционирование по месяцам). + +Директория `detached` содержит куски, отсоединенные от таблицы с помощью запроса [DETACH](../../../sql-reference/statements/alter.md#alter_detach-partition). Поврежденные куски также попадают в эту директорию – они не удаляются с сервера. + +Сервер не использует куски из директории `detached`. Вы можете в любое время добавлять, удалять, модифицировать данные в директории detached - сервер не будет об этом знать, пока вы не сделаете запрос [ATTACH](../../../engines/table-engines/mergetree-family/custom-partitioning-key.md#alter_attach-partition). + +Следует иметь в виду, что при работающем сервере нельзя вручную изменять набор кусков на файловой системе, так как сервер не будет знать об этом. +Для нереплицируемых таблиц, вы можете это делать при остановленном сервере, однако это не рекомендуется. +Для реплицируемых таблиц, набор кусков нельзя менять в любом случае. + +ClickHouse позволяет производить различные манипуляции с кусками: удалять, копировать из одной таблицы в другую или создавать их резервные копии. Подробнее см. в разделе [Манипуляции с партициями и кусками](../../../engines/table-engines/mergetree-family/custom-partitioning-key.md#alter_manipulations-with-partitions). + +[Оригинальная статья:](https://clickhouse.tech/docs/ru/operations/table_engines/custom_partitioning_key/) diff --git a/docs/ru/engines/table-engines/mergetree-family/graphitemergetree.md b/docs/ru/engines/table-engines/mergetree-family/graphitemergetree.md new file mode 100644 index 00000000000..c38065a6e5d --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/graphitemergetree.md @@ -0,0 +1,169 @@ +# GraphiteMergeTree {#graphitemergetree} + +Движок предназначен для прореживания и агрегирования/усреднения (rollup) данных [Graphite](http://graphite.readthedocs.io/en/latest/index.html). Он может быть интересен разработчикам, которые хотят использовать ClickHouse как хранилище данных для Graphite. + +Если rollup не требуется, то для хранения данных Graphite можно использовать любой движок таблиц ClickHouse, в противном случае используйте `GraphiteMergeTree`. Движок уменьшает объём хранения и повышает эффективность запросов от Graphite. + +Движок наследует свойства от [MergeTree](mergetree.md). + +## Создание таблицы {#creating-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE = GraphiteMergeTree(config_section) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Смотрите описание запроса [CREATE TABLE](../../../engines/table-engines/mergetree-family/graphitemergetree.md#create-table-query). + +В таблице должны быть столбцы для следующих данных: + +- Название метрики (сенсора Graphite). Тип данных: `String`. + +- Время измерения метрики. Тип данных `DateTime`. + +- Значение метрики. Тип данных: любой числовой. + +- Версия метрики. Тип данных: любой числовой. + + ClickHouse сохраняет строки с последней версией или последнюю записанную строку, если версии совпадают. Другие строки удаляются при слиянии кусков данных. + +Имена этих столбцов должны быть заданы в конфигурации rollup. + +**Параметры GraphiteMergeTree** + +- `config_section` — имя раздела в конфигурационном файле, в котором находятся правила rollup. + +**Секции запроса** + +При создании таблицы `GraphiteMergeTree` используются те же [секции](mergetree.md#table_engine-mergetree-creating-a-table) запроса, что и при создании таблицы `MergeTree`. + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + EventDate Date, + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) +``` + +Все параметры, кроме `config_section` имеют то же значение, что в `MergeTree`. + +- `config_section` — имя раздела в конфигурационном файле, в котором находятся правила rollup. + +
+ +## Конфигурация Rollup {#rollup-configuration} + +Настройки прореживания данных задаются параметром [graphite\_rollup](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-graphite) в конфигурации сервера . Имя параметра может быть любым. Можно создать несколько конфигураций и использовать их для разных таблиц. + +Структура конфигурации rollup: + +``` text +required-columns +patterns +``` + +### Требуемые столбцы (required-columns) {#required-columns} + +- `path_column_name` — столбец, в котором хранится название метрики (сенсор Graphite). Значение по умолчанию: `Path`. +- `time_column_name` — столбец, в котором хранится время измерения метрики. Значение по умолчанию: `Time`. +- `value_column_name` — столбец со значением метрики в момент времени, установленный в `time_column_name`. Значение по умолчанию: `Value`. +- `version_column_name` — столбец, в котором хранится версия метрики. Значение по умолчанию: `Timestamp`. + +### Правила (patterns) {#patterns} + +Структура раздела `patterns`: + +``` text +pattern + regexp + function +pattern + regexp + age + precision + ... +pattern + regexp + function + age + precision + ... +pattern + ... +default + function + age + precision + ... +``` + +!!! warning "Внимание" + Правила должны быть строго упорядочены: + + 1. Правила без `function` или `retention`. + 1. Правила одновремено содержащие `function` и `retention`. + 1. Правило `default`. + +При обработке строки ClickHouse проверяет правила в разделе `pattern`. Каждый `pattern` (включая `default`) может содержать параметр агрегации `function`, параметр `retention`, или оба параметра одновременно. Если имя метрики соответствует шаблону `regexp`, то применяются правила `pattern`, в противном случае правило `default`. + +Поля для разделов `pattern` и `default`: + +- `regexp` – шаблон имени метрики. +- `age` – минимальный возраст данных в секундах. +- `precision` – точность определения возраста данных в секундах. Должен быть делителем для 86400 (количество секунд в сутках). +- `function` – имя агрегирующей функции, которую следует применить к данным, чей возраст оказался в интервале `[age, age + precision]`. + +### Пример конфигурации {#configuration-example} + +``` xml + + Version + + click_cost + any + + 0 + 5 + + + 86400 + 60 + + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/graphitemergetree/) diff --git a/docs/ru/engines/table-engines/mergetree-family/index.md b/docs/ru/engines/table-engines/mergetree-family/index.md new file mode 100644 index 00000000000..9e989d807da --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: MergeTree Family +toc_priority: 28 +--- + + diff --git a/docs/ru/engines/table-engines/mergetree-family/mergetree.md b/docs/ru/engines/table-engines/mergetree-family/mergetree.md new file mode 100644 index 00000000000..f9192015188 --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/mergetree.md @@ -0,0 +1,617 @@ +# MergeTree {#table_engines-mergetree} + +Движок `MergeTree`, а также другие движки этого семейства (`*MergeTree`) — это наиболее функциональные движки таблиц ClickHouse. + +Основная идея, заложенная в основу движков семейства `MergeTree` следующая. Когда у вас есть огромное количество данных, которые должны быть вставлены в таблицу, вы должны быстро записать их по частям, а затем объединить части по некоторым правилам в фоновом режиме. Этот метод намного эффективнее, чем постоянная перезапись данных в хранилище при вставке. + +Основные возможности: + +- **Хранит данные, отсортированные по первичному ключу.** Это позволяет создавать разреженный индекс небольшого объёма, который позволяет быстрее находить данные. + +- **Позволяет оперировать партициями, если задан [ключ партиционирования](custom-partitioning-key.md).** ClickHouse поддерживает отдельные операции с партициями, которые работают эффективнее, чем общие операции с этим же результатом над этими же данными. Также, ClickHouse автоматически отсекает данные по партициям там, где ключ партиционирования указан в запросе. Это также увеличивает эффективность выполнения запросов. + +- **Поддерживает репликацию данных.** Для этого используется семейство таблиц `ReplicatedMergeTree`. Подробнее читайте в разделе [Репликация данных](replication.md). + +- **Поддерживает сэмплирование данных.** При необходимости можно задать способ сэмплирования данных в таблице. + +!!! info "Info" + Движок [Merge](../special/merge.md#merge) не относится к семейству `*MergeTree`. + +## Создание таблицы {#table_engine-mergetree-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... + INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, + INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 +) ENGINE = MergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] +[SETTINGS name=value, ...] +``` + +Описание параметров смотрите в [описании запроса CREATE](../../../engines/table-engines/mergetree-family/mergetree.md). + +!!! note "Note" + `INDEX` — экспериментальная возможность, смотрите [Индексы пропуска данных](#table_engine-mergetree-data_skipping-indexes). + +### Секции запроса {#mergetree-query-clauses} + +- `ENGINE` — имя и параметры движка. `ENGINE = MergeTree()`. `MergeTree` не имеет параметров. + +- `PARTITION BY` — [ключ партиционирования](custom-partitioning-key.md). Для партиционирования по месяцам используйте выражение `toYYYYMM(date_column)`, где `date_column` — столбец с датой типа [Date](../../../engines/table-engines/mergetree-family/mergetree.md). В этом случае имена партиций имеют формат `"YYYYMM"`. + +- `ORDER BY` — ключ сортировки. Кортеж столбцов или произвольных выражений. Пример: `ORDER BY (CounterID, EventDate)`. + +- `PRIMARY KEY` — первичный ключ, если он [отличается от ключа сортировки](#pervichnyi-kliuch-otlichnyi-ot-kliucha-sortirovki). По умолчанию первичный ключ совпадает с ключом сортировки (который задаётся секцией `ORDER BY`.) Поэтому в большинстве случаев секцию `PRIMARY KEY` отдельно указывать не нужно. + +- `SAMPLE BY` — выражение для сэмплирования. Если используется выражение для сэмплирования, то первичный ключ должен содержать его. Пример: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. + +- `TTL` — список правил, определяющих длительности хранения строк, а также задающих правила перемещения частей на определённые тома или диски. Выражение должно возвращать столбец `Date` или `DateTime`. Пример: `TTL date + INTERVAL 1 DAY`. + - Тип правила `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` указывает действие, которое будет выполнено с частью, удаление строк (прореживание), перемещение (при выполнении условия для всех строк части) на определённый диск (`TO DISK 'xxx'`) или том (`TO VOLUME 'xxx'`). + - Поведение по умолчанию соответствует удалению строк (`DELETE`). В списке правил может быть указано только одно выражение с поведением `DELETE`. + - Дополнительные сведения смотрите в разделе [TTL для столбцов и таблиц](#table_engine-mergetree-ttl) + +- `SETTINGS` — дополнительные параметры, регулирующие поведение `MergeTree`: + + - `index_granularity` — максимальное количество строк данных между засечками индекса. По умолчанию — 8192. Смотрите [Хранение данных](#mergetree-data-storage). + - `index_granularity_bytes` — максимальный размер гранул данных в байтах. По умолчанию — 10Mb. Чтобы ограничить размер гранул только количеством строк, установите значение 0 (не рекомендовано). Смотрите [Хранение данных](#mergetree-data-storage). + - `enable_mixed_granularity_parts` — включает или выключает переход к ограничению размера гранул с помощью настройки `index_granularity_bytes`. Настройка `index_granularity_bytes` улучшает производительность ClickHouse при выборке данных из таблиц с большими (десятки и сотни мегабайтов) строками. Если у вас есть таблицы с большими строками, можно включить эту настройку, чтобы повысить эффективность запросов `SELECT`. + - `use_minimalistic_part_header_in_zookeeper` — Способ хранения заголовков кусков данных в ZooKeeper. Если `use_minimalistic_part_header_in_zookeeper = 1`, то ZooKeeper хранит меньше данных. Подробнее читайте в [описании настройки](../../../operations/server-configuration-parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) в разделе "Конфигурационные параметры сервера". + - `min_merge_bytes_to_use_direct_io` — минимальный объём данных при слиянии, необходимый для прямого (небуферизованного) чтения/записи (direct I/O) на диск. При слиянии частей данных ClickHouse вычисляет общий объём хранения всех данных, подлежащих слиянию. Если общий объём хранения всех данных для чтения превышает `min_bytes_to_use_direct_io` байт, тогда ClickHouse использует флаг `O_DIRECT` при чтении данных с диска. Если `min_merge_bytes_to_use_direct_io = 0`, тогда прямой ввод-вывод отключен. Значение по умолчанию: `10 * 1024 * 1024 * 1024` байтов. + - `merge_with_ttl_timeout` — минимальное время в секундах перед повторным слиянием с TTL. По умолчанию — 86400 (1 день). + - `write_final_mark` — включает или отключает запись последней засечки индекса в конце куска данных, указывающей за последний байт. По умолчанию — 1. Не отключайте её. + - `merge_max_block_size` — Максимальное количество строк в блоке для операций слияния. Значение по умолчанию: 8192. + - `storage_policy` — политика хранения данных. Смотрите [Хранение данных таблицы на нескольких блочных устройствах](#table_engine-mergetree-multiple-volumes). + +**Пример задания секций** + +``` sql +ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 +``` + +В примере мы устанавливаем партиционирование по месяцам. + +Также мы задаем выражение для сэмплирования в виде хэша по идентификатору посетителя. Это позволяет псевдослучайным образом перемешать данные в таблице для каждого `CounterID` и `EventDate`. Если при выборке данных задать секцию [SAMPLE](../../../engines/table-engines/mergetree-family/mergetree.md#select-sample-clause), то ClickHouse вернёт равномерно-псевдослучайную выборку данных для подмножества посетителей. + +`index_granularity` можно было не указывать, поскольку 8192 — это значение по умолчанию. + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ, описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +**Параметры MergeTree()** + +- `date-column` — имя столбца с типом [Date](../../../engines/table-engines/mergetree-family/mergetree.md). На основе этого столбца ClickHouse автоматически создаёт партиции по месяцам. Имена партиций имеют формат `"YYYYMM"`. +- `sampling_expression` — выражение для сэмплирования. +- `(primary, key)` — первичный ключ. Тип — [Tuple()](../../../engines/table-engines/mergetree-family/mergetree.md) +- `index_granularity` — гранулярность индекса. Число строк данных между «засечками» индекса. Для большинства задач подходит значение 8192. + +**Пример** + +``` sql +MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) +``` + +Движок `MergeTree` сконфигурирован таким же образом, как и в примере выше для основного способа конфигурирования движка. + +
+ +## Хранение данных {#mergetree-data-storage} + +Таблица состоит из *кусков* данных (data parts), отсортированных по первичному ключу. + +При вставке в таблицу создаются отдельные куски данных, каждый из которых лексикографически отсортирован по первичному ключу. Например, если первичный ключ — `(CounterID, Date)`, то данные в куске будут лежать в порядке `CounterID`, а для каждого `CounterID` в порядке `Date`. + +Данные, относящиеся к разным партициям, разбиваются на разные куски. В фоновом режиме ClickHouse выполняет слияния (merge) кусков данных для более эффективного хранения. Куски, относящиеся к разным партициям не объединяются. Механизм слияния не гарантирует, что все строки с одинаковым первичным ключом окажутся в одном куске. + +Каждый кусок данных логически делится на гранулы. Гранула — это минимальный неделимый набор данных, который ClickHouse считывает при выборке данных. ClickHouse не разбивает строки и значения и гранула всегда содержит целое число строк. Первая строка гранулы помечается значением первичного ключа для этой строки (засечка). Для каждого куска данных ClickHouse создаёт файл с засечками (индексный файл). Для каждого столбца, независимо от того, входит он в первичный ключ или нет, ClickHouse также сохраняет эти же засечки. Засечки используются для поиска данных напрямую в файлах столбцов. + +Размер гранул оганичен настройками движка `index_granularity` и `index_granularity_bytes`. Количество строк в грануле лежит в диапазоне `[1, index_granularity]`, в зависимости от размера строк. Размер гранулы может превышать `index_granularity_bytes` в том случае, когда размер единственной строки в грануле превышает значение настройки. В этом случае, размер гранулы равен размеру строки. + +## Первичные ключи и индексы в запросах {#primary-keys-and-indexes-in-queries} + +Рассмотрим первичный ключ — `(CounterID, Date)`. В этом случае сортировку и индекс можно проиллюстрировать следующим образом: + +``` text +Whole data: [-------------------------------------------------------------------------] +CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] +Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] +Marks: | | | | | | | | | | | + a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 +Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 +``` + +Если в запросе к данным указать: + +- `CounterID IN ('a', 'h')`, то сервер читает данные в диапазонах засечек `[0, 3)` и `[6, 8)`. +- `CounterID IN ('a', 'h') AND Date = 3`, то сервер читает данные в диапазонах засечек `[1, 3)` и `[7, 8)`. +- `Date = 3`, то сервер читает данные в диапазоне засечек `[1, 10]`. + +Примеры выше показывают, что использование индекса всегда эффективнее, чем full scan. + +Разреженный индекс допускает чтение лишних строк. При чтении одного диапазона первичного ключа, может быть прочитано до `index_granularity * 2` лишних строк в каждом блоке данных. + +Разреженный индекс почти всегда помещаеся в оперативную память и позволяет работать с очень большим количеством строк в таблицах. + +ClickHouse не требует уникального первичного ключа. Можно вставить много строк с одинаковым первичным ключом. + +### Выбор первичного ключа {#vybor-pervichnogo-kliucha} + +Количество столбцов в первичном ключе не ограничено явным образом. В зависимости от структуры данных в первичный ключ можно включать больше или меньше столбцов. Это может: + +- Увеличить эффективность индекса. + + Пусть первичный ключ — `(a, b)`, тогда добавление ещё одного столбца `c` повысит эффективность, если выполнены условия: + + - Есть запросы с условием на столбец `c`. + - Часто встречаются достаточно длинные (в несколько раз больше `index_granularity`) диапазоны данных с одинаковыми значениями `(a, b)`. Иначе говоря, когда добавление ещё одного столбца позволит пропускать достаточно длинные диапазоны данных. + +- Улучшить сжатие данных. + + ClickHouse сортирует данные по первичному ключу, поэтому чем выше однородность, тем лучше сжатие. + +- Обеспечить дополнительную логику при слиянии кусков данных в движках [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) и [SummingMergeTree](summingmergetree.md). + + В этом случае имеет смысл указать отдельный *ключ сортировки*, отличающийся от первичного ключа. + +Длинный первичный ключ будет негативно влиять на производительность вставки и потребление памяти, однако на производительность ClickHouse при запросах `SELECT` лишние столбцы в первичном ключе не влияют. + +### Первичный ключ, отличный от ключа сортировки {#pervichnyi-kliuch-otlichnyi-ot-kliucha-sortirovki} + +Существует возможность задать первичный ключ (выражение, значения которого будут записаны в индексный файл для +каждой засечки), отличный от ключа сортировки (выражение, по которому будут упорядочены строки в кусках +данных). Кортеж выражения первичного ключа при этом должен быть префиксом кортежа выражения ключа +сортировки. + +Данная возможность особенно полезна при использовании движков [SummingMergeTree](summingmergetree.md) +и [AggregatingMergeTree](aggregatingmergetree.md). В типичном сценарии использования этих движков таблица +содержит столбцы двух типов: *измерения* (dimensions) и *меры* (measures). Типичные запросы агрегируют +значения столбцов-мер с произвольной группировкой и фильтрацией по измерениям. Так как `SummingMergeTree` +и `AggregatingMergeTree` производят фоновую агрегацию строк с одинаковым значением ключа сортировки, приходится +добавлять в него все столбцы-измерения. В результате выражение ключа содержит большой список столбцов, +который приходится постоянно расширять при добавлении новых измерений. + +В этом сценарии имеет смысл оставить в первичном ключе всего несколько столбцов, которые обеспечат эффективную фильтрацию по индексу, а остальные столбцы-измерения добавить в выражение ключа сортировки. + +[ALTER ключа сортировки](../../../engines/table-engines/mergetree-family/mergetree.md) — лёгкая операция, так как при одновременном добавлении нового столбца в таблицу и ключ сортировки не нужно изменять данные кусков (они остаются упорядоченными и по новому выражению ключа). + +### Использование индексов и партиций в запросах {#ispolzovanie-indeksov-i-partitsii-v-zaprosakh} + +Для запросов `SELECT` ClickHouse анализирует возможность использования индекса. Индекс может использоваться, если в секции `WHERE/PREWHERE`, в качестве одного из элементов конъюнкции, или целиком, есть выражение, представляющее операции сравнения на равенства, неравенства, а также `IN` или `LIKE` с фиксированным префиксом, над столбцами или выражениями, входящими в первичный ключ или ключ партиционирования, либо над некоторыми частично монотонными функциями от этих столбцов, а также логические связки над такими выражениями. + +Таким образом, обеспечивается возможность быстро выполнять запросы по одному или многим диапазонам первичного ключа. Например, в указанном примере будут быстро работать запросы для конкретного счётчика; для конкретного счётчика и диапазона дат; для конкретного счётчика и даты, для нескольких счётчиков и диапазона дат и т. п. + +Рассмотрим движок сконфигурированный следующим образом: + +``` sql +ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 +``` + +В этом случае в запросах: + +``` sql +SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 +SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) +SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) +``` + +ClickHouse будет использовать индекс по первичному ключу для отсечения не подходящих данных, а также ключ партиционирования по месяцам для отсечения партиций, которые находятся в не подходящих диапазонах дат. + +Запросы выше показывают, что индекс используется даже для сложных выражений. Чтение из таблицы организовано так, что использование индекса не может быть медленнее, чем full scan. + +В примере ниже индекс не может использоваться. + +``` sql +SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' +``` + +Чтобы проверить, сможет ли ClickHouse использовать индекс при выполнении запроса, используйте настройки [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) и [force\_primary\_key](../../../operations/settings/settings.md#settings-force_primary_key). + +Ключ партиционирования по месяцам обеспечивает чтение только тех блоков данных, которые содержат даты из нужного диапазона. При этом блок данных может содержать данные за многие даты (до целого месяца). В пределах одного блока данные упорядочены по первичному ключу, который может не содержать дату в качестве первого столбца. В связи с этим, при использовании запроса с указанием условия только на дату, но не на префикс первичного ключа, будет читаться данных больше, чем за одну дату. + +### Использование индекса для частично-монотонных первичных ключей {#ispolzovanie-indeksa-dlia-chastichno-monotonnykh-pervichnykh-kliuchei} + +Рассмотрим, например, дни месяца. Они образуют последовательность [монотонную](https://ru.wikipedia.org/wiki/Монотонная_последовательность) в течение одного месяца, но не монотонную на более длительных периодах. Это частично-монотонная последовательность. Если пользователь создаёт таблицу с частично-монотонным первичным ключом, ClickHouse как обычно создаёт разреженный индекс. Когда пользователь выбирает данные из такого рода таблиц, ClickHouse анализирует условия запроса. Если пользователь хочет получить данные между двумя метками индекса, и обе эти метки находятся внутри одного месяца, ClickHouse может использовать индекс в данном конкретном случае, поскольку он может рассчитать расстояние между параметрами запроса и индексными метками. + +ClickHouse не может использовать индекс, если значения первичного ключа в диапазоне параметров запроса не представляют собой монотонную последовательность. В этом случае ClickHouse использует метод полного сканирования. + +ClickHouse использует эту логику не только для последовательностей дней месяца, но и для любого частично-монотонного первичного ключа. + +### Индексы пропуска данных (экспериментальная функциональность) {#table_engine-mergetree-data_skipping-indexes} + +Объявление индексов при определении столбцов в запросе `CREATE`. + +``` sql +INDEX index_name expr TYPE type(...) GRANULARITY granularity_value +``` + +Для таблиц семейства `*MergeTree` можно задать дополнительные индексы в секции столбцов. + +Индексы агрегируют для заданного выражения некоторые данные, а потом при `SELECT` запросе используют для пропуска блоков данных (пропускаемый блок состоит из гранул данных в количестве равном гранулярности данного индекса), на которых секция `WHERE` не может быть выполнена, тем самым уменьшая объём данных читаемых с диска. + +**Пример** + +``` sql +CREATE TABLE table_name +( + u64 UInt64, + i32 Int32, + s String, + ... + INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, + INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 +) ENGINE = MergeTree() +... +``` + +Эти индексы смогут использоваться для оптимизации следующих запросов + +``` sql +SELECT count() FROM table WHERE s < 'z' +SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 +``` + +#### Доступные индексы {#dostupnye-indeksy} + +- `minmax` — Хранит минимум и максимум выражения (если выражение - `tuple`, то для каждого элемента `tuple`), используя их для пропуска блоков аналогично первичному ключу. + +- `set(max_rows)` — Хранит уникальные значения выражения на блоке в количестве не более `max_rows` (если `max_rows = 0`, то ограничений нет), используя их для пропуска блоков, оценивая выполнимость `WHERE` выражения на хранимых данных. + +- `bloom_filter([false_positive])` — [фильтр Блума](https://en.wikipedia.org/wiki/Bloom_filter) для указанных стоблцов. + + Необязательный параметр `false_positive` — это вероятность получения ложноположительного срабатывания. Возможные значения: (0, 1). Значение по умолчанию: 0.025. + + Поддержанные типы данных: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`. + + Фильтром могут пользоваться функции: [equals](../../../engines/table_engines/mergetree_family/mergetree.md), [notEquals](../../../engines/table_engines/mergetree_family/mergetree.md), [in](../../../engines/table_engines/mergetree_family/mergetree.md), [notIn](../../../engines/table_engines/mergetree_family/mergetree.md). + +**Примеры** + +``` sql +INDEX b (u64 * length(str), i32 + f64 * 100, date, str) TYPE minmax GRANULARITY 4 +INDEX b (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 +``` + +#### Поддержка для функций {#functions-support} + +Условия в секции `WHERE` содержат вызовы функций, оперирующих со столбцами. Если столбец - часть индекса, ClickHouse пытается использовать индекс при выполнении функции. Для разных видов индексов, ClickHouse поддерживает различные наборы функций, которые могут использоваться индексами. + +Индекс `set` используется со всеми функциями. Наборы функций для остальных индексов представлены в таблице ниже. + +| Функция (оператор) / Индекс | primary key | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | +|------------------------------------------------------------------------------------------------------------|-------------|--------|-------------|-------------|---------------| +| [equals (=, ==)](../../../sql-reference/functions/comparison-functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notEquals(!=, \<\>)](../../../sql-reference/functions/comparison-functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [like](../../../sql-reference/functions/string-search-functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [notLike](../../../sql-reference/functions/string-search-functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [startsWith](../../../sql-reference/functions/string-functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | +| [endsWith](../../../sql-reference/functions/string-functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | +| [multiSearchAny](../../../sql-reference/functions/string-search-functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | +| [in](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notIn](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [less (\<)](../../../sql-reference/functions/comparison-functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [greater (\>)](../../../sql-reference/functions/comparison-functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [lessOrEquals (\<=)](../../../sql-reference/functions/comparison-functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [greaterOrEquals (\>=)](../../../sql-reference/functions/comparison-functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [empty](../../../sql-reference/functions/array-functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [notEmpty](../../../sql-reference/functions/array-functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | + +Функции с постоянным агрументом, который меньше, чем размер ngram не могут использовать индекс `ngrambf_v1` для оптимизации запроса. + +Фильтры Блума могут иметь ложнопозитивные срабатывания, следовательно индексы `ngrambf_v1`, `tokenbf_v1` и `bloom_filter` невозможно использовать для оптимизации запросов, в которых результат функции предполается false, например: + +- Можно оптимизировать: + - `s LIKE '%test%'` + - `NOT s NOT LIKE '%test%'` + - `s = 1` + - `NOT s != 1` + - `startsWith(s, 'test')` +- Нельзя оптимизировать: + - `NOT s LIKE '%test%'` + - `s NOT LIKE '%test%'` + - `NOT s = 1` + - `s != 1` + - `NOT startsWith(s, 'test')` + +## Конкурентный доступ к данным {#konkurentnyi-dostup-k-dannym} + +Для конкурентного доступа к таблице используется мультиверсионность. То есть, при одновременном чтении и обновлении таблицы, данные будут читаться из набора кусочков, актуального на момент запроса. Длинных блокировок нет. Вставки никак не мешают чтениям. + +Чтения из таблицы автоматически распараллеливаются. + +## TTL для столбцов и таблиц {#table_engine-mergetree-ttl} + +Определяет время жизни значений, а также правила перемещения данных на другой диск или том. + +Секция `TTL` может быть установлена как для всей таблицы, так и для каждого отдельного столбца. Правила `TTL` для таблицы позволяют указать целевые диски или тома для фонового перемещения на них частей данных. + +Выражения должны возвращать тип [Date](../../../engines/table-engines/mergetree-family/mergetree.md) или [DateTime](../../../engines/table-engines/mergetree-family/mergetree.md). + +Для задания времени жизни столбца, например: + +``` sql +TTL time_column +TTL time_column + interval +``` + +Чтобы задать `interval`, используйте операторы [интервала времени](../../../engines/table-engines/mergetree-family/mergetree.md#operators-datetime). + +``` sql +TTL date_time + INTERVAL 1 MONTH +TTL date_time + INTERVAL 15 HOUR +``` + +### TTL столбца {#mergetree-column-ttl} + +Когда срок действия значений в столбце истечет, ClickHouse заменит их значениями по умолчанию для типа данных столбца. Если срок действия всех значений столбцов в части данных истек, ClickHouse удаляет столбец из куска данных в файловой системе. + +Секцию `TTL` нельзя использовать для ключевых столбцов. + +Примеры: + +Создание таблицы с TTL + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int TTL d + INTERVAL 1 MONTH, + b Int TTL d + INTERVAL 1 MONTH, + c String +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d; +``` + +Добавление TTL на колонку существующей таблицы + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 DAY; +``` + +Изменение TTL у колонки + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 MONTH; +``` + +### TTL таблицы {#mergetree-table-ttl} + +Для таблицы можно задать одно выражение для устаревания данных, а также несколько выражений, по срабатывании которых данные переместятся на [некоторый диск или том](#table_engine-mergetree-multiple-volumes). Когда некоторые данные в таблице устаревают, ClickHouse удаляет все соответствующие строки. + +``` sql +TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... +``` + +За каждым TTL выражением может следовать тип действия, которое выполняется после достижения времени, соответствующего результату TTL выражения: + +- `DELETE` - удалить данные (действие по умолчанию); +- `TO DISK 'aaa'` - переместить данные на диск `aaa`; +- `TO VOLUME 'bbb'` - переместить данные на том `bbb`. + +Примеры: + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d +TTL d + INTERVAL 1 MONTH [DELETE], + d + INTERVAL 1 WEEK TO VOLUME 'aaa', + d + INTERVAL 2 WEEK TO DISK 'bbb'; +``` + +Изменение TTL + +``` sql +ALTER TABLE example_table + MODIFY TTL d + INTERVAL 1 DAY; +``` + +**Удаление данных** + +Данные с истекшим TTL удаляются, когда ClickHouse мёржит куски данных. + +Когда ClickHouse видит, что некоторые данные устарели, он выполняет внеплановые мёржи. Для управление частотой подобных мёржей, можно задать настройку `merge_with_ttl_timeout`. Если её значение слишком низкое, придется выполнять много внеплановых мёржей, которые могут начать потреблять значительную долю ресурсов сервера. + +Если вы выполните запрос `SELECT` между слияниями вы можете получить устаревшие данные. Чтобы избежать этого используйте запрос [OPTIMIZE](../../../engines/table-engines/mergetree-family/mergetree.md#misc_operations-optimize) перед `SELECT`. + +## Хранение данных таблицы на нескольких блочных устройствах {#table_engine-mergetree-multiple-volumes} + +### Введение {#vvedenie} + +Движки таблиц семейства `MergeTree` могут хранить данные на нескольких блочных устройствах. Это может оказаться полезным, например, при неявном разделении данных одной таблицы на «горячие» и «холодные». Наиболее свежая часть занимает малый объём и запрашивается регулярно, а большой хвост исторических данных запрашивается редко. При наличии в системе нескольких дисков, «горячая» часть данных может быть размещена на быстрых дисках (например, на NVMe SSD или в памяти), а холодная на более медленных (например, HDD). + +Минимальной перемещаемой единицей для `MergeTree` является кусок данных (data part). Данные одного куска могут находится только на одном диске. Куски могут перемещаться между дисками в фоне, согласно пользовательским настройкам, а также с помощью запросов [ALTER](../../../engines/table-engines/mergetree-family/mergetree.md#alter_move-partition). + +### Термины {#terminy} + +- Диск — примонтированное в файловой системе блочное устройство. +- Диск по умолчанию — диск, на котором находится путь, указанный в конфигурационной настройке сервера [path](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path). +- Том (Volume) — упорядоченный набор равноценных дисков (схоже с [JBOD](https://ru.wikipedia.org/wiki/JBOD)) +- Политика хранения (StoragePolicy) — множество томов с правилами перемещения данных между ними. + +У всех описанных сущностей при создании указываются имена, можно найти в системных таблицах [system.storage\_policies](../../../engines/table-engines/mergetree-family/mergetree.md#system_tables-storage_policies) и [system.disks](../../../engines/table-engines/mergetree-family/mergetree.md#system_tables-disks). Имя политики хранения можно указать в настройке `storage_policy` движков таблиц семейства `MergeTree`. + +### Конфигурация {#table_engine-mergetree-multiple-volumes_configure} + +Диски, тома и политики хранения задаются внутри тега `` в основном файле `config.xml` или в отдельном файле в директории `config.d`. + +Структура конфигурации: + +``` xml + + + + /mnt/fast_ssd/clickhouse/ + + + /mnt/hdd1/clickhouse/ + 10485760 + + + /mnt/hdd2/clickhouse/ + 10485760 + + + ... + + + ... + +``` + +Теги: + +- `` — имя диска. Имена должны быть разными для всех дисков. +- `path` — путь по которому будут храниться данные сервера (каталоги `data` и `shadow`), должен быть терминирован `/`. +- `keep_free_space_bytes` — размер зарезервированного свободного места на диске. + +Порядок задания дисков не имеет значения. + +Общий вид конфигурации политик хранения: + +``` xml + + ... + + + + + disk_name_from_disks_configuration + 1073741824 + + + + + + + 0.2 + + + + + + + + ... + +``` + +Тэги: + +- `policy_name_N` — название политики. Названия политик должны быть уникальны. +- `volume_name_N` — название тома. Названия томов должны быть уникальны. +- `disk` — диск, находящийся внутри тома. +- `max_data_part_size_bytes` — максимальный размер куска данных, который может находится на любом из дисков этого тома. +- `move_factor` — доля свободного места, при превышении которого данные начинают перемещаться на следующий том, если он есть (по умолчанию 0.1). + +Примеры конфигураций: + +``` xml + + ... + + + + + disk1 + disk2 + + + + + + + + fast_ssd + 1073741824 + + + disk1 + + + 0.2 + + + ... + +``` + +В приведенном примере, политика `hdd_in_order` реализует прицип [round-robin](https://ru.wikipedia.org/wiki/Round-robin_(%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC)). Так как в политике есть всего один том (`single`), то все записи производятся на его диски по круговому циклу. Такая политика может быть полезна при наличии в системе нескольких похожих дисков, но при этом не сконфигурирован RAID. Учтите, что каждый отдельный диск ненадёжен и чтобы не потерять важные данные это необходимо скомпенсировать за счет хранения данных в трёх копиях. + +Если система содержит диски различных типов, то может пригодиться политика `moving_from_ssd_to_hdd`. В томе `hot` находится один SSD-диск (`fast_ssd`), а также задается ограничение на максимальный размер куска, который может храниться на этом томе (1GB). Все куски такой таблицы больше 1GB будут записываться сразу на том `cold`, в котором содержится один HDD-диск `disk1`. Также, при заполнении диска `fast_ssd` более чем на 80% данные будут переносится на диск `disk1` фоновым процессом. + +Порядок томов в политиках хранения важен, при достижении условий на переполнение тома данные переносятся на следующий. Порядок дисков в томах так же важен, данные пишутся по очереди на каждый из них. + +После задания конфигурации политик хранения их можно использовать, как настройку при создании таблиц: + +``` sql +CREATE TABLE table_with_non_default_policy ( + EventDate Date, + OrderID UInt64, + BannerID UInt64, + SearchPhrase String +) ENGINE = MergeTree +ORDER BY (OrderID, BannerID) +PARTITION BY toYYYYMM(EventDate) +SETTINGS storage_policy = 'moving_from_ssd_to_hdd' +``` + +По умолчанию используется политика хранения `default` в которой есть один том и один диск, указанный в ``. В данный момент менять политику хранения после создания таблицы нельзя. + +Количество потоков для фоновых перемещений кусков между дисками можно изменить с помощью настройки [background_move_pool_size](../../../operations/settings/settings.md#background_move_pool_size) + +### Особенности работы {#osobennosti-raboty} + +В таблицах `MergeTree` данные попадают на диск несколькими способами: + +- В результате вставки (запрос `INSERT`). +- В фоновых операциях слияний и [мутаций](../../../engines/table-engines/mergetree-family/mergetree.md#alter-mutations). +- При скачивании данных с другой реплики. +- В результате заморозки партиций [ALTER TABLE … FREEZE PARTITION](../../../engines/table-engines/mergetree-family/mergetree.md#alter_freeze-partition). + +Во всех случаях, кроме мутаций и заморозки партиций, при записи куска выбирается том и диск в соответствии с указанной конфигурацией хранилища: + +1. Выбирается первый по порядку том, на котором есть свободное место для записи куска (`unreserved_space > current_part_size`) и который позволяет записывать куски требуемого размера `max_data_part_size_bytes > current_part_size`. +2. Внутри тома выбирается следующий диск после того, на который была предыдущая запись и на котором свободного места больше чем размер куска (`unreserved_space - keep_free_space_bytes > current_part_size`) + +Мутации и запросы заморозки партиций в реализации используют [жесткие ссылки](https://ru.wikipedia.org/wiki/%D0%96%D1%91%D1%81%D1%82%D0%BA%D0%B0%D1%8F_%D1%81%D1%81%D1%8B%D0%BB%D0%BA%D0%B0). Жесткие ссылки между различными дисками не поддерживаются, поэтому в случае таких операций куски размещаются на тех же дисках, что и исходные. + +В фоне куски перемещаются между томами на основе информации о занятом месте (настройка `move_factor`) по порядку, в котором указаны тома в конфигурации. Данные никогда не перемещаются с последнего тома и на первый том. Следить за фоновыми перемещениями можно с помощью системных таблиц [system.part\_log](../../../engines/table-engines/mergetree-family/mergetree.md#system_tables-part-log) (поле `type = MOVE_PART`) и [system.parts](../../../engines/table-engines/mergetree-family/mergetree.md#system_tables-parts) (поля `path` и `disk`). Также подробная информация о перемещениях доступна в логах сервера. +С помощью запроса [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../engines/table-engines/mergetree-family/mergetree.md#alter_move-partition) пользователь может принудительно перенести кусок или партицию с одного раздела на другой. При этом учитываются все ограничения, указанные для фоновых операций. Запрос самостоятельно инициирует процесс перемещения не дожидаясь фоновых операций. В случае недостатка места или неудовлетворения ограничениям пользователь получит сообщение об ошибке. + +Перемещения данных не взаимодействуют с репликацией данных, поэтому на разных репликах одной и той же таблицы могут быть указаны разные политики хранения. + +После выполнения фоновых слияний или мутаций старые куски не удаляются сразу, а через некоторое время (табличная настройка `old_parts_lifetime`). Также они не перемещаются на другие тома или диски, поэтому до момента удаления они продолжают учитываться при подсчёте занятого дискового пространства. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/ru/engines/table-engines/mergetree-family/replacingmergetree.md b/docs/ru/engines/table-engines/mergetree-family/replacingmergetree.md new file mode 100644 index 00000000000..6e3e1224997 --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/replacingmergetree.md @@ -0,0 +1,61 @@ +# ReplacingMergeTree {#replacingmergetree} + +Движок отличается от [MergeTree](mergetree.md#table_engines-mergetree) тем, что выполняет удаление дублирующихся записей с одинаковым значением первичного ключа (точнее, с одинаковым значением [ключа сортировки](mergetree.md)). + +Дедупликация данных производится лишь во время слияний. Слияние происходят в фоне в неизвестный момент времени, на который вы не можете ориентироваться. Некоторая часть данных может остаться необработанной. Хотя вы можете вызвать внеочередное слияние с помощью запроса `OPTIMIZE`, на это не стоит рассчитывать, так как запрос `OPTIMIZE` приводит к чтению и записи большого объёма данных. + +Таким образом, `ReplacingMergeTree` подходит для фоновой чистки дублирующихся данных в целях экономии места, но не даёт гарантии отсутствия дубликатов. + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = ReplacingMergeTree([ver]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Описание параметров запроса смотрите в [описании запроса](../../../engines/table-engines/mergetree-family/replacingmergetree.md). + +**Параметры ReplacingMergeTree** + +- `ver` — столбец с версией, тип `UInt*`, `Date` или `DateTime`. Необязательный параметр. + + При слиянии, из всех строк с одинаковым значением первичного ключа `ReplacingMergeTree` оставляет только одну: + + - Последнюю в выборке, если `ver` не задан. + - С максимальной версией, если `ver` задан. + +**Секции запроса** + +При создании таблицы `ReplacingMergeTree` используются те же [секции](mergetree.md), что и при создании таблицы `MergeTree`. + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) +``` + +Все параметры, кроме `ver` имеют то же значение, что в и `MergeTree`. + +- `ver` — столбец с версией. Необязательный параметр. Описание смотрите выше по тексту. + +
+ +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/replacingmergetree/) diff --git a/docs/ru/engines/table-engines/mergetree-family/replication.md b/docs/ru/engines/table-engines/mergetree-family/replication.md new file mode 100644 index 00000000000..54f390c293e --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/replication.md @@ -0,0 +1,214 @@ +# Репликация данных {#table_engines-replication} + +Репликация поддерживается только для таблиц семейства MergeTree: + +- ReplicatedMergeTree +- ReplicatedSummingMergeTree +- ReplicatedReplacingMergeTree +- ReplicatedAggregatingMergeTree +- ReplicatedCollapsingMergeTree +- ReplicatedVersionedCollapsingMergeTree +- ReplicatedGraphiteMergeTree + +Репликация работает на уровне отдельных таблиц, а не всего сервера. То есть, на сервере могут быть расположены одновременно реплицируемые и не реплицируемые таблицы. + +Репликация не зависит от шардирования. На каждом шарде репликация работает независимо. + +Реплицируются сжатые данные запросов `INSERT`, `ALTER` (см. подробности в описании запроса [ALTER](../../../engines/table-engines/mergetree-family/replication.md#query_language_queries_alter)). + +Запросы `CREATE`, `DROP`, `ATTACH`, `DETACH` и `RENAME` выполняются на одном сервере и не реплицируются: + +- Запрос `CREATE TABLE` создаёт новую реплицируемую таблицу на том сервере, где его выполнили. Если таблица уже существует на других серверах, запрос добавляет новую реплику. +- `DROP TABLE` удаляет реплику, расположенную на том сервере, где выполняется запрос. +- Запрос `RENAME` переименовывает таблицу на одной реплик. Другими словами, реплицируемые таблицы на разных репликах могут называться по-разному. + +ClickHouse хранит метаинформацию о репликах в [Apache ZooKeeper](https://zookeeper.apache.org). Используйте ZooKeeper 3.4.5 или новее. + +Для использовании репликации, установите параметры в секции [zookeeper](../../../operations/server-configuration-parameters/settings.md#server-settings_zookeeper) конфигурации сервера. + +!!! attention "Внимание" + Не пренебрегайте настройками безопасности. ClickHouse поддерживает [ACL схему](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) `digest` подсистемы безопасности ZooKeeper. + +Пример указания адресов кластера ZooKeeper: + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + + example3 + 2181 + + +``` + +Можно указать любой имеющийся у вас ZooKeeper-кластер - система будет использовать в нём одну директорию для своих данных (директория указывается при создании реплицируемой таблицы). + +Если в конфигурационном файле не настроен ZooKeeper, то вы не сможете создать реплицируемые таблицы, а уже имеющиеся реплицируемые таблицы будут доступны в режиме только на чтение. + +При запросах `SELECT`, ZooKeeper не используется, т.е. репликация не влияет на производительность `SELECT` и запросы работают так же быстро, как и для нереплицируемых таблиц. При запросах к распределенным реплицированным таблицам поведение ClickHouse регулируется настройками [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) and [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md). + +При каждом запросе `INSERT`, делается около десятка записей в ZooKeeper в рамках нескольких транзакций. (Чтобы быть более точным, это для каждого вставленного блока данных; запрос INSERT содержит один блок или один блок на `max_insert_block_size = 1048576` строк.) Это приводит к некоторому увеличению задержек при `INSERT`, по сравнению с нереплицируемыми таблицами. Но если придерживаться обычных рекомендаций - вставлять данные пачками не более одного `INSERT` в секунду, то это не составляет проблем. На всём кластере ClickHouse, использующим для координации один кластер ZooKeeper, может быть в совокупности несколько сотен `INSERT` в секунду. Пропускная способность при вставке данных (количество строчек в секунду) такая же высокая, как для нереплицируемых таблиц. + +Для очень больших кластеров, можно использовать разные кластеры ZooKeeper для разных шардов. Впрочем, на кластере Яндекс.Метрики (примерно 300 серверов) такой необходимости не возникает. + +Репликация асинхронная, мульти-мастер. Запросы `INSERT` и `ALTER` можно направлять на любой доступный сервер. Данные вставятся на сервер, где выполнен запрос, а затем скопируются на остальные серверы. В связи с асинхронностью, только что вставленные данные появляются на остальных репликах с небольшой задержкой. Если часть реплик недоступна, данные на них запишутся тогда, когда они станут доступны. Если реплика доступна, то задержка составляет столько времени, сколько требуется для передачи блока сжатых данных по сети. Количество потоков для выполнения фоновых задач можно задать с помощью настройки [background_schedule_pool_size](../../../operations/settings/settings.md#background_schedule_pool_size). + +По умолчанию, запрос INSERT ждёт подтверждения записи только от одной реплики. Если данные были успешно записаны только на одну реплику, и сервер с этой репликой перестал существовать, то записанные данные будут потеряны. Вы можете включить подтверждение записи от нескольких реплик, используя настройку `insert_quorum`. + +Каждый блок данных записывается атомарно. Запрос INSERT разбивается на блоки данных размером до `max_insert_block_size = 1048576` строк. То есть, если в запросе `INSERT` менее 1048576 строк, то он делается атомарно. + +Блоки данных дедуплицируются. При многократной записи одного и того же блока данных (блоков данных одинакового размера, содержащих одни и те же строчки в одном и том же порядке), блок будет записан только один раз. Это сделано для того, чтобы в случае сбоя в сети, когда клиентское приложение не может понять, были ли данные записаны в БД, можно было просто повторить запрос `INSERT`. При этом не имеет значения, на какую реплику будут отправлены INSERT-ы с одинаковыми данными. Запрос `INSERT` идемпотентный. Параметры дедуплицирования регулируются настройками сервера [merge\_tree](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree) + +При репликации, по сети передаются только исходные вставляемые данные. Дальнейшие преобразования данных (слияния) координируются и делаются на всех репликах одинаковым образом. За счёт этого минимизируется использование сети, и благодаря этому, репликация хорошо работает при расположении реплик в разных дата-центрах. (Стоит заметить, что дублирование данных в разных дата-центрах, по сути, является основной задачей репликации). + +Количество реплик одних и тех же данных может быть произвольным. В Яндекс.Метрике в продакшене используется двукратная репликация. На каждом сервере используется RAID-5 или RAID-6, в некоторых случаях RAID-10. Это является сравнительно надёжным и удобным для эксплуатации решением. + +Система следит за синхронностью данных на репликах и умеет восстанавливаться после сбоя. Восстановление после сбоя автоматическое (в случае небольших различий в данных) или полуавтоматическое (когда данные отличаются слишком сильно, что может свидетельствовать об ошибке конфигурации). + +## Создание реплицируемых таблиц {#creating-replicated-tables} + +В начало имени движка таблицы добавляется `Replicated`. Например, `ReplicatedMergeTree`. + +**Параметры Replicated\*MergeTree** + +- `zoo_path` — путь к таблице в ZooKeeper. +- `replica_name` — имя реплики в ZooKeeper. +- `other_parameters` — параметры движка, для которого создаётся реплицированная версия, например, версия для `ReplacingMergeTree`. + + +Пример: + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32, + ver UInt16 +) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', ver) +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +``` + +
+ +Пример в устаревшем синтаксисе + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) +``` + +
+ +Как видно в примере, эти параметры могут содержать подстановки в фигурных скобках. Подставляемые значения достаются из конфигурационного файла, из секции `macros`. Пример: + +``` xml + + 05 + 02 + example05-02-1.yandex.ru + +``` + +Путь к таблице в ZooKeeper должен быть разным для каждой реплицируемой таблицы. В том числе, для таблиц на разных шардах, должны быть разные пути. +В данном случае, путь состоит из следующих частей: + +`/clickhouse/tables/` — общий префикс. Рекомендуется использовать именно его. + +`{layer}-{shard}` — идентификатор шарда. В данном примере он состоит из двух частей, так как на кластере Яндекс.Метрики используется двухуровневое шардирование. Для большинства задач, оставьте только подстановку {shard}, которая будет раскрываться в идентификатор шарда. + +`table_name` - имя узла для таблицы в ZooKeeper. Разумно делать его таким же, как имя таблицы. Оно указывается явно, так как, в отличие от имени таблицы, оно не меняется после запроса RENAME. +*Подсказка*: можно также указать имя базы данных перед `table_name`, например `db_name.table_name` + +Имя реплики — то, что идентифицирует разные реплики одной и той же таблицы. Можно использовать для него имя сервера, как показано в примере. Впрочем, достаточно, чтобы имя было уникально лишь в пределах каждого шарда. + +Можно не использовать подстановки, а указать соответствующие параметры явно. Это может быть удобным для тестирования и при настройке маленьких кластеров. Однако в этом случае нельзя пользоваться распределенными DDL-запросами (`ON CLUSTER`). + +При работе с большими кластерами мы рекомендуем использовать подстановки, они уменьшают вероятность ошибки. + +Выполните запрос `CREATE TABLE` на каждой реплике. Запрос создаёт новую реплицируемую таблицу, или добавляет новую реплику к имеющимся. + +Если вы добавляете новую реплику после того, как таблица на других репликах уже содержит некоторые данные, то после выполнения запроса, данные на новую реплику будут скачаны с других реплик. То есть, новая реплика синхронизирует себя с остальными. + +Для удаления реплики, выполните запрос `DROP TABLE`. При этом, удаляется только одна реплика — расположенная на том сервере, где вы выполняете запрос. + +## Восстановление после сбоя {#vosstanovlenie-posle-sboia} + +Если при старте сервера, недоступен ZooKeeper, реплицируемые таблицы переходят в режим только для чтения. Система будет пытаться периодически установить соединение с ZooKeeper. + +Если при `INSERT` недоступен ZooKeeper, или происходит ошибка при взаимодействии с ним, будет выкинуто исключение. + +При подключении к ZooKeeper, система проверяет соответствие между имеющимся в локальной файловой системе набором данных и ожидаемым набором данных (информация о котором хранится в ZooKeeper). Если имеются небольшие несоответствия, то система устраняет их, синхронизируя данные с реплик. + +Обнаруженные битые куски данных (с файлами несоответствующего размера) или неизвестные куски (куски, записанные в файловую систему, но информация о которых не была записана в ZooKeeper) переносятся в поддиректорию detached (не удаляются). Недостающие куски скачиваются с реплик. + +Стоит заметить, что ClickHouse не делает самостоятельно никаких деструктивных действий типа автоматического удаления большого количества данных. + +При старте сервера (или создании новой сессии с ZooKeeper), проверяется только количество и размеры всех файлов. Если у файлов совпадают размеры, но изменены байты где-то посередине, то это обнаруживается не сразу, а только при попытке их прочитать при каком-либо запросе `SELECT`. Запрос кинет исключение о несоответствующей чексумме или размере сжатого блока. В этом случае, куски данных добавляются в очередь на проверку, и при необходимости, скачиваются с реплик. + +Если обнаруживается, что локальный набор данных слишком сильно отличается от ожидаемого, то срабатывает защитный механизм. Сервер сообщает об этом в лог и отказывается запускаться. Это сделано, так как такой случай может свидетельствовать об ошибке конфигурации - например, если реплика одного шарда была случайно сконфигурирована, как реплика другого шарда. Тем не менее, пороги защитного механизма поставлены довольно низкими, и такая ситуация может возникнуть и при обычном восстановлении после сбоя. В этом случае, восстановление делается полуавтоматически - «по кнопке». + +Для запуска восстановления, создайте в ZooKeeper узел `/path_to_table/replica_name/flags/force_restore_data` с любым содержимым или выполните команду для восстановления всех реплицируемых таблиц: + +``` bash +$ sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data +``` + +Затем запустите сервер. При старте, сервер удалит эти флаги и запустит восстановление. + +## Восстановление в случае потери всех данных {#vosstanovlenie-v-sluchae-poteri-vsekh-dannykh} + +Если на одном из серверов исчезли все данные и метаданные, восстановление делается следующим образом: + +1. Установите на сервер ClickHouse. Корректно пропишите подстановки в конфигурационном файле, отвечающие за идентификатор шарда и реплики, если вы их используете. +2. Если у вас были нереплицируемые таблицы, которые должны быть вручную продублированы на серверах, скопируйте их данные (в директории `/var/lib/clickhouse/data/db_name/table_name/`) с реплики. +3. Скопируйте с реплики определения таблиц, находящиеся в `/var/lib/clickhouse/metadata/`. Если в определениях таблиц, идентификатор шарда или реплики, прописаны в явном виде - исправьте их, чтобы они соответствовали данной реплике. (Альтернативный вариант - запустить сервер и сделать самостоятельно все запросы `ATTACH TABLE`, которые должны были бы быть в соответствующих .sql файлах в `/var/lib/clickhouse/metadata/`.) +4. Создайте в ZooKeeper узел `/path_to_table/replica_name/flags/force_restore_data` с любым содержимым или выполните команду для восстановления всех реплицируемых таблиц: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` + +Затем запустите сервер (перезапустите, если уже запущен). Данные будут скачаны с реплик. + +В качестве альтернативного варианта восстановления, вы можете удалить из ZooKeeper информацию о потерянной реплике (`/path_to_table/replica_name`), и затем создать реплику заново, как написано в разделе [Создание реплицированных таблиц](#creating-replicated-tables) . + +Отсутствует ограничение на использование сетевой полосы при восстановлении. Имейте это ввиду, если восстанавливаете сразу много реплик. + +## Преобразование из MergeTree в ReplicatedMergeTree {#preobrazovanie-iz-mergetree-v-replicatedmergetree} + +Здесь и далее, под `MergeTree` подразумеваются все движки таблиц семейства `MergeTree`, так же для `ReplicatedMergeTree`. + +Если у вас была таблица типа `MergeTree`, репликация которой делалась вручную, вы можете преобразовать её в реплицируемую таблицу. Это может понадобиться лишь в случаях, когда вы уже успели накопить большое количество данных в таблице типа `MergeTree`, а сейчас хотите включить репликацию. + +Если на разных репликах данные отличаются, то сначала синхронизируйте их, либо удалите эти данные на всех репликах кроме одной. + +Переименуйте имеющуюся MergeTree таблицу, затем создайте со старым именем таблицу типа `ReplicatedMergeTree`. +Перенесите данные из старой таблицы в поддиректорию detached в директории с данными новой таблицы (`/var/lib/clickhouse/data/db_name/table_name/`). +Затем добавьте эти куски данных в рабочий набор с помощью выполнения запросов `ALTER TABLE ATTACH PARTITION` на одной из реплик. + +## Преобразование из ReplicatedMergeTree в MergeTree {#preobrazovanie-iz-replicatedmergetree-v-mergetree} + +Создайте таблицу типа MergeTree с другим именем. Перенесите в её директорию с данными все данные из директории с данными таблицы типа `ReplicatedMergeTree`. Затем удалите таблицу типа `ReplicatedMergeTree` и перезапустите сервер. + +Если вы хотите избавиться от таблицы `ReplicatedMergeTree`, не запуская сервер, то + +- удалите соответствующий файл `.sql` в директории с метаданными (`/var/lib/clickhouse/metadata/`); +- удалите соответствующий путь в ZooKeeper (`/path_to_table/replica_name`); + +После этого, вы можете запустить сервер, создать таблицу типа `MergeTree`, перенести данные в её директорию, и перезапустить сервер. + +## Восстановление в случае потери или повреждения метаданных на ZooKeeper кластере {#vosstanovlenie-v-sluchae-poteri-ili-povrezhdeniia-metadannykh-na-zookeeper-klastere} + +Если данные в ZooKeeper оказались утеряны или повреждены, то вы можете сохранить данные, переместив их в нереплицируемую таблицу, как описано в пункте выше. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/replication/) diff --git a/docs/ru/engines/table-engines/mergetree-family/summingmergetree.md b/docs/ru/engines/table-engines/mergetree-family/summingmergetree.md new file mode 100644 index 00000000000..070cd109c30 --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/summingmergetree.md @@ -0,0 +1,134 @@ +# SummingMergeTree {#summingmergetree} + +Движок наследует функциональность [MergeTree](mergetree.md#table_engines-mergetree). Отличие заключается в том, что для таблиц `SummingMergeTree` при слиянии кусков данных ClickHouse все строки с одинаковым первичным ключом (точнее, с одинаковым [ключом сортировки](mergetree.md)) заменяет на одну, которая хранит только суммы значений из столбцов с цифровым типом данных. Если ключ сортировки подобран таким образом, что одному значению ключа соответствует много строк, это значительно уменьшает объём хранения и ускоряет последующую выборку данных. + +Мы рекомендуем использовать движок в паре с `MergeTree`. В `MergeTree` храните полные данные, а `SummingMergeTree` используйте для хранения агрегированных данных, например, при подготовке отчетов. Такой подход позволит не утратить ценные данные из-за неправильно выбранного первичного ключа. + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = SummingMergeTree([columns]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Описание параметров запроса смотрите в [описании запроса](../../../engines/table-engines/mergetree-family/summingmergetree.md). + +**Параметры SummingMergeTree** + +- `columns` — кортеж с именами столбцов, в которых будут суммироваться данные. Необязательный параметр. + Столбцы должны иметь числовой тип и не должны входить в первичный ключ. + + Если `columns` не задан, то ClickHouse суммирует значения во всех столбцах с числовым типом данных, не входящих в первичный ключ. + +**Секции запроса** + +При создании таблицы `SummingMergeTree` используются те же [секции](mergetree.md) запроса, что и при создании таблицы `MergeTree`. + +
+ +Устаревший способ создания таблицы + +!!! attention "Attention" + Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) +``` + +Все параметры, кроме `columns` имеют то же значение, что в и `MergeTree`. + +- `columns` — кортеж с именами столбцов для суммирования данных. Необязательный параметр. Описание смотрите выше по тексту. + +
+ +## Пример использования {#primer-ispolzovaniia} + +Рассмотрим следующую таблицу: + +``` sql +CREATE TABLE summtt +( + key UInt32, + value UInt32 +) +ENGINE = SummingMergeTree() +ORDER BY key +``` + +Добавим в неё данные: + +``` sql +INSERT INTO summtt Values(1,1),(1,2),(2,1) +``` + +ClickHouse может не полностью просуммировать все строки ([смотрите ниже по тексту](#obrabotka-dannykh)), поэтому при запросе мы используем агрегатную функцию `sum` и секцию `GROUP BY`. + +``` sql +SELECT key, sum(value) FROM summtt GROUP BY key +``` + +``` text +┌─key─┬─sum(value)─┐ +│ 2 │ 1 │ +│ 1 │ 3 │ +└─────┴────────────┘ +``` + +## Обработка данных {#obrabotka-dannykh} + +При вставке данных в таблицу они сохраняются как есть. Периодически ClickHouse выполняет слияние вставленных кусков данных и именно в этот момент производится суммирование и замена многих строк с одинаковым первичным ключом на одну для каждого результирующего куска данных. + +ClickHouse может слить куски данных таким образом, что не все строки с одинаковым первичным ключом окажутся в одном финальном куске, т.е. суммирование будет не полным. Поэтому, при выборке данных (`SELECT`) необходимо использовать агрегатную функцию [sum()](../../../engines/table-engines/mergetree-family/summingmergetree.md#agg_function-sum) и секцию `GROUP BY` как описано в примере выше. + +### Общие правила суммирования {#obshchie-pravila-summirovaniia} + +Суммируются значения в столбцах с числовым типом данных. Набор столбцов определяется параметром `columns`. + +Если значения во всех столбцах для суммирования оказались нулевыми, то строчка удаляется. + +Для столбцов, не входящих в первичный ключ и не суммирующихся, выбирается произвольное значение из имеющихся. + +Значения для столбцов, входящих в первичный ключ, не суммируются. + +### Суммирование в столбцах AggregateFunction {#summirovanie-v-stolbtsakh-aggregatefunction} + +Для столбцов типа [AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md#data-type-aggregatefunction) ClickHouse выполняет агрегацию согласно заданной функции, повторяя поведение движка [AggregatingMergeTree](aggregatingmergetree.md). + +### Вложенные структуры {#vlozhennye-struktury} + +Таблица может иметь вложенные структуры данных, которые обрабатываются особым образом. + +Если название вложенной таблицы заканчивается на `Map` и она содержит не менее двух столбцов, удовлетворяющих критериям: + +- первый столбец - числовой `(*Int*, Date, DateTime)` или строковый `(String, FixedString)`, назовем его условно `key`, +- остальные столбцы - арифметические `(*Int*, Float32/64)`, условно `(values...)`, + +то вложенная таблица воспринимается как отображение `key => (values...)` и при слиянии её строк выполняется слияние элементов двух множеств по `key` со сложением соответствующих `(values...)`. + +Примеры: + +``` text +[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] +[(1, 100)] + [(1, 150)] -> [(1, 250)] +[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] +[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] +``` + +При запросе данных используйте функцию [sumMap(key, value)](../../../engines/table-engines/mergetree-family/summingmergetree.md) для агрегации `Map`. + +Для вложенной структуры данных не нужно указывать её столбцы в кортеже столбцов для суммирования. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/summingmergetree/) diff --git a/docs/ru/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md b/docs/ru/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md new file mode 100644 index 00000000000..5dc9589bef5 --- /dev/null +++ b/docs/ru/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md @@ -0,0 +1,231 @@ +# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} + +Движок: + +- Позволяет быстро записывать постоянно изменяющиеся состояния объектов. +- Удаляет старые состояния объектов в фоновом режиме. Это значительно сокращает объём хранения. + +Подробнее читайте в разделе [Collapsing](#table_engines_versionedcollapsingmergetree). + +Движок наследует функциональность от [MergeTree](mergetree.md#table_engines-mergetree) и добавляет в алгоритм слияния кусков данных логику сворачивания (удаления) строк. `VersionedCollapsingMergeTree` предназначен для тех же задач, что и [CollapsingMergeTree](collapsingmergetree.md), но использует другой алгоритм свёртывания, который позволяет вставлять данные в любом порядке в несколько потоков. В частности, столбец `Version` помогает свернуть строки правильно, даже если они вставлены в неправильном порядке. `CollapsingMergeTree` требует строго последовательную вставку данных. + +## Создание таблицы {#sozdanie-tablitsy} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = VersionedCollapsingMergeTree(sign, version) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Подробности про `CREATE TABLE` смотрите в [описании запроса](../../../engines/table-engines/mergetree-family/versionedcollapsingmergetree.md). + +**Параметры движка** + +``` sql +VersionedCollapsingMergeTree(sign, version) +``` + +- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. + + Тип данных столбца должен быть `Int8`. + +- `version` — имя столбца с версией состояния объекта. + + Тип данных столбца должен быть `UInt*`. + +**Секции запроса** + +При создании таблицы `VersionedСollapsingMergeTree` используются те же [секции](mergetree.md) запроса, что и при создании таблицы `MergeTree` . + +
+ +Устаревший способ создания таблицы + +!!! warning "Внимание" + Не используйте этот метод в новых проектах. По возможности переключите старые проекты на метод, описанный выше. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] VersionedCollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign, version) +``` + +Все параметры, за исключением `sign` и `version` имеют то же значение, что и в `MergeTree`. + +- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. + + Тип данных столбца — `Int8`. + +- `version` — имя столбца с версией состояния объекта. + + Тип данных столбца должен быть `UInt*`. + +
+ +## Сворачивание (удаление) строк {#table_engines_versionedcollapsingmergetree} + +### Данные {#dannye} + +Рассмотрим ситуацию, когда необходимо сохранять постоянно изменяющиеся данные для какого-либо объекта. Разумно иметь одну строку для объекта и обновлять эту строку при каждом изменении. Однако операция обновления является дорогостоящей и медленной для СУБД, поскольку требует перезаписи данных в хранилище. Обновление неприемлемо, если требуется быстро записывать данные, но можно записывать изменения в объект последовательно следующим образом. + +Используйте столбец `Sign` при записи строки. Если `Sign = 1`, то это означает, что строка является состоянием объекта, назовём её строкой состояния. Если `Sign = -1`, то это означает отмену состояния объекта с теми же атрибутами, назовём её строкой отмены состояния. Также используйте столбец `Version`, который должен идентифицировать каждое состояние объекта отдельным номером. + +Например, мы хотим рассчитать, сколько страниц пользователи посетили на каком-либо сайте и как долго они там находились. В какой-то момент времени мы записываем следующую строку состояния пользовательской активности: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Через некоторое время мы регистрируем изменение активности пользователя и записываем его следующими двумя строками. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Первая строка отменяет предыдущее состояние объекта (пользователя). Она должна копировать все поля отменяемого состояния за исключением `Sign`. + +Вторая строка содержит текущее состояние. + +Поскольку нам нужно только последнее состояние активности пользователя, строки + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +можно удалить, сворачивая (удаляя) устаревшее состояние объекта. `VersionedCollapsingMergeTree` делает это при слиянии кусков данных. + +Чтобы узнать, зачем нам нужны две строки для каждого изменения, см. раздел [Алгоритм](#table_engines-versionedcollapsingmergetree-algorithm). + +**Примечания по использованию** + +1. Программа, которая записывает данные, должна помнить состояние объекта, чтобы иметь возможность отменить его. Строка отмены состояния должна быть копией предыдущей строки состояния с противоположным значением `Sign`. Это увеличивает начальный размер хранилища, но позволяет быстро записывать данные. +2. Длинные растущие массивы в столбцах снижают эффективность работы движка за счёт нагрузки на запись. Чем проще данные, тем выше эффективность. +3. `SELECT` результаты сильно зависят от согласованности истории изменений объекта. Будьте точны при подготовке данных для вставки. Вы можете получить непредсказуемые результаты с несогласованными данными, такими как отрицательные значения для неотрицательных метрик, таких как глубина сеанса. + +### Алгоритм {#table_engines-versionedcollapsingmergetree-algorithm} + +Когда ClickHouse объединяет куски данных, он удаляет каждую пару строк, которые имеют один и тот же первичный ключ и версию и разный `Sign`. Порядок строк не имеет значения. + +Когда ClickHouse вставляет данные, он упорядочивает строки по первичному ключу. Если столбец `Version` не находится в первичном ключе, ClickHouse добавляет его к первичному ключу неявно как последнее поле и использует для сортировки. + +## Выборка данных {#vyborka-dannykh} + +ClickHouse не гарантирует, что все строки с одинаковым первичным ключом будут находиться в одном результирующем куске данных или даже на одном физическом сервере. Это справедливо как для записи данных, так и для последующего слияния кусков данных. Кроме того, ClickHouse обрабатывает запросы `SELECT` несколькими потоками, и не может предсказать порядок строк в конечной выборке. Это означает, что если необходимо получить полностью «свернутые» данные из таблицы `VersionedCollapsingMergeTree`, то требуется агрегирование. + +Для завершения свертывания добавьте в запрос секцию `GROUP BY` и агрегатные функции, которые учитывают знак. Например, для расчета количества используйте `sum(Sign)` вместо`count()`. Чтобы вычислить сумму чего-либо, используйте `sum(Sign * x)` вместо`sum(х)`, а также добавьте `HAVING sum(Sign) > 0` . + +Таким образом можно вычислять агрегации `count`, `sum` и `avg`. Агрегация `uniq` может вычисляться, если объект имеет хотя бы одно не свернутое состояние. Невозможно вычислить агрегации `min` и `max` поскольку`VersionedCollapsingMergeTree` не сохраняет историю значений для свернутых состояний. + +Если необходимо выбирать данные без агрегации (например, проверить наличие строк, последние значения которых удовлетворяют некоторым условиям), можно использовать модификатор `FINAL` для секции `FROM`. Такой подход неэффективен и не должен использоваться с большими таблицами. + +## Пример использования {#primer-ispolzovaniia} + +Данные для примера: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Создание таблицы: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8, + Version UInt8 +) +ENGINE = VersionedCollapsingMergeTree(Sign, Version) +ORDER BY UserID +``` + +Вставка данных: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) +``` + +Мы используем два запроса `INSERT` для создания двух различных кусков данных. Если мы вставляем данные с помощью одного запроса, ClickHouse создаёт один кусок данных и не будет выполнять слияние. + +Получение данных: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Что мы видим и где сворачивание? +Мы создали два куска данных, используя два запроса `INSERT`. Запрос `SELECT` был выполнен в два потока, и результатом является случайный порядок строк. +Свертывание не произошло, поскольку части данных еще не были объединены. ClickHouse объединяет части данных в неизвестный момент времени, который мы не можем предсказать. + +Поэтому нам нужна агрегация: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration, + Version +FROM UAct +GROUP BY UserID, Version +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 2 │ +└─────────────────────┴───────────┴──────────┴─────────┘ +``` + +Если нам не нужна агрегация, но мы хотим принудительно выполнить свёртку данных, то можно использовать модификатор `FINAL` для секции `FROM`. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Это очень неэффективный способ выбора данных. Не используйте его для больших таблиц. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/ru/engines/table_engines/special/buffer.md b/docs/ru/engines/table-engines/special/buffer.md similarity index 100% rename from docs/ru/engines/table_engines/special/buffer.md rename to docs/ru/engines/table-engines/special/buffer.md diff --git a/docs/ru/engines/table-engines/special/dictionary.md b/docs/ru/engines/table-engines/special/dictionary.md new file mode 100644 index 00000000000..b35c8cecc8f --- /dev/null +++ b/docs/ru/engines/table-engines/special/dictionary.md @@ -0,0 +1,88 @@ +# Dictionary {#dictionary} + +Движок `Dictionary` отображает данные [словаря](../../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) как таблицу ClickHouse. + +Рассмотрим для примера словарь `products` со следующей конфигурацией: + +``` xml + + + products + + +
products
+ DSN=some-db-server + + + + 300 + 360 + + + + + + + product_id + + + title + String + + + + + +``` + +Запрос данных словаря: + +``` sql +SELECT + name, + type, + key, + attribute.names, + attribute.types, + bytes_allocated, + element_count, + source +FROM system.dictionaries +WHERE name = 'products' +``` + +``` text +┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ +│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ +└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ +``` + +В таком виде данные из словаря можно получить при помощи функций [dictGet\*](../../../engines/table-engines/special/dictionary.md#ext_dict_functions). + +Такое представление неудобно, когда нам необходимо получить данные в чистом виде, а также при выполнении операции `JOIN`. Для этих случаев можно использовать движок `Dictionary`, который отобразит данные словаря в таблицу. + +Синтаксис: + +``` sql +CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` +``` + +Пример использования: + +``` sql +create table products (product_id UInt64, title String) Engine = Dictionary(products); +``` + +Проверим что у нас в таблице? + +``` sql +select * from products limit 1; +``` + +``` text +┌────product_id─┬─title───────────┐ +│ 152689 │ Some item │ +└───────────────┴─────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/dictionary/) diff --git a/docs/ru/engines/table-engines/special/distributed.md b/docs/ru/engines/table-engines/special/distributed.md new file mode 100644 index 00000000000..68753a7c217 --- /dev/null +++ b/docs/ru/engines/table-engines/special/distributed.md @@ -0,0 +1,116 @@ +# Distributed {#distributed} + +**Движок Distributed не хранит данные самостоятельно**, а позволяет обрабатывать запросы распределённо, на нескольких серверах. +Чтение автоматически распараллеливается. При чтении будут использованы индексы таблиц на удалённых серверах, если есть. +Движок Distributed принимает параметры: имя кластера в конфигурационном файле сервера, имя удалённой базы данных, имя удалённой таблицы, а также (не обязательно) ключ шардирования. +Пример: + +``` sql +Distributed(logs, default, hits[, sharding_key]) +``` + +данные будут читаться со всех серверов кластера logs, из таблицы default.hits, расположенной на каждом сервере кластера. +Данные не только читаются, но и частично (настолько, насколько это возможно) обрабатываются на удалённых серверах. +Например, при запросе с GROUP BY, данные будут агрегированы на удалённых серверах, промежуточные состояния агрегатных функций будут отправлены на запросивший сервер; затем данные будут доагрегированы. + +Вместо имени базы данных может использоваться константное выражение, возвращающее строку. Например, currentDatabase(). + +logs - имя кластера в конфигурационном файле сервера. + +Кластеры задаются следующим образом: + +``` xml + + + + + 1 + + false + + example01-01-1 + 9000 + + + example01-01-2 + 9000 + + + + 2 + false + + example01-02-1 + 9000 + + + example01-02-2 + 9000 + + + + +``` + +Здесь задан кластер с именем logs, состоящий из двух шардов, каждый из которых состоит из двух реплик. +Шардами называются серверы, содержащие разные части данных (чтобы прочитать все данные, нужно идти на все шарды). +Репликами называются дублирующие серверы (чтобы прочитать данные, можно идти за данными на любую из реплик). + +Имя кластера не должно содержать точки. + +В качестве параметров для каждого сервера указываются `host`, `port` и, не обязательно, `user`, `password`, `secure`, `compression`: +- `host` - адрес удалённого сервера. Может быть указан домен, или IPv4 или IPv6 адрес. В случае указания домена, при старте сервера делается DNS запрос, и результат запоминается на всё время работы сервера. Если DNS запрос неуспешен, то сервер не запускается. Если вы изменяете DNS-запись, перезапустите сервер. +- `port` - TCP-порт для межсерверного взаимодействия (в конфиге - tcp\_port, обычно 9000). Не перепутайте с http\_port. +- `user` - имя пользователя для соединения с удалённым сервером. по умолчанию - default. Этот пользователь должен иметь доступ для соединения с указанным сервером. Доступы настраиваются в файле users.xml, подробнее смотрите в разделе [Права доступа](../../../operations/access-rights.md). +- `password` - пароль для соединения с удалённым сервером, в открытом виде. по умолчанию - пустая строка. +- `secure` - Использовать шифрованное соединение ssl, Обычно используется с портом `port` = 9440. Сервер должен слушать порт `9440` с корректными настройками сертификатов. +- `compression` - Использовать сжатие данных. По умолчанию: true. + +При указании реплик, для каждого из шардов, при чтении, будет выбрана одна из доступных реплик. Можно настроить алгоритм балансировки нагрузки (то есть, предпочтения, на какую из реплик идти) - см. настройку [load\_balancing](../../../operations/settings/settings.md#settings-load_balancing). +Если соединение с сервером не установлено, то будет произведена попытка соединения с небольшим таймаутом. Если соединиться не удалось, то будет выбрана следующая реплика, и так для всех реплик. Если попытка соединения для всех реплик не удалась, то будут снова произведены попытки соединения по кругу, и так несколько раз. +Это работает в пользу отказоустойчивости, хотя и не обеспечивает полную отказоустойчивость: удалённый сервер может принять соединение, но не работать, или плохо работать. + +Можно указать от одного шарда (в таком случае, обработку запроса стоит называть удалённой, а не распределённой) до произвольного количества шардов. В каждом шарде можно указать от одной до произвольного числа реплик. Можно указать разное число реплик для каждого шарда. + +Вы можете прописать сколько угодно кластеров в конфигурации. + +Для просмотра имеющихся кластеров, вы можете использовать системную таблицу system.clusters. + +Движок Distributed позволяет работать с кластером, как с локальным сервером. При этом, кластер является неэластичным: вы должны прописать его конфигурацию в конфигурационный файл сервера (лучше всех серверов кластера). + +Как видно, движок Distributed требует прописывания кластера в конфигурационный файл; кластера из конфигурационного файла обновляются налету, без перезапуска сервера. Если вам необходимо каждый раз отправлять запрос на неизвестный набор шардов и реплик, вы можете не создавать Distributed таблицу, а воспользоваться табличной функцией remote. Смотрите раздел [Табличные функции](../../../engines/table-engines/special/distributed.md). + +Есть два способа записывать данные на кластер: + +Во-первых, вы можете самостоятельно определять, на какие серверы какие данные записывать, и выполнять запись непосредственно на каждый шард. То есть, делать INSERT в те таблицы, на которые «смотрит» распределённая таблица. Это наиболее гибкое решение поскольку вы можете использовать любую схему шардирования, которая может быть нетривиальной из-за требований предметной области. +Также это является наиболее оптимальным решением, так как данные могут записываться на разные шарды полностью независимо. + +Во-вторых, вы можете делать INSERT в Distributed таблицу. В этом случае, таблица будет сама распределять вставляемые данные по серверам. Для того, чтобы писать в Distributed таблицу, у неё должен быть задан ключ шардирования (последний параметр). Также, если шард всего-лишь один, то запись работает и без указания ключа шардирования (так как в этом случае он не имеет смысла). + +У каждого шарда в конфигурационном файле может быть задан «вес» (weight). По умолчанию, вес равен единице. Данные будут распределяться по шардам в количестве, пропорциональном весу шарда. Например, если есть два шарда, и у первого выставлен вес 9, а у второго 10, то на первый будет отправляться 9 / 19 доля строк, а на второй - 10 / 19. + +У каждого шарда в конфигурационном файле может быть указан параметр internal\_replication. + +Если он выставлен в true, то для записи будет выбираться первая живая реплика и данные будут писаться на неё. Этот вариант следует использовать, если Distributed таблица «смотрит» на реплицируемые таблицы. То есть, если таблица, в которую будут записаны данные, будет сама заниматься их репликацией. + +Если он выставлен в false (по умолчанию), то данные будут записываться на все реплики. По сути, это означает, что Distributed таблица занимается репликацией данных самостоятельно. Это хуже, чем использование реплицируемых таблиц, так как не контролируется консистентность реплик, и они со временем будут содержать немного разные данные. + +Для выбора шарда, на который отправляется строка данных, вычисляется выражение шардирования, и берётся его остаток от деления на суммарный вес шардов. Строка отправляется на шард, соответствующий полуинтервалу остатков от prev\_weights до prev\_weights + weight, где prev\_weights - сумма весов шардов с меньшим номером, а weight - вес этого шарда. Например, если есть два шарда, и у первого выставлен вес 9, а у второго 10, то строка будет отправляться на первый шард для остатков из диапазона \[0, 9), а на второй - для остатков из диапазона \[9, 19). + +Выражением шардирование может быть произвольное выражение от констант и столбцов таблицы, возвращающее целое число. Например, вы можете использовать выражение rand() для случайного распределения данных, или UserID - для распределения по остатку от деления идентификатора посетителя (тогда данные одного посетителя будут расположены на одном шарде, что упростит выполнение IN и JOIN по посетителям). Если распределение какого-либо столбца недостаточно равномерное, вы можете обернуть его в хэш функцию: intHash64(UserID). + +Простой остаток от деления является довольно ограниченным решением для шардирования и подходит не для всех случаев. Он подходит для среднего и большого объёма данных (десятки серверов), но не для очень больших объёмов данных (сотни серверов и больше). В последнем случае, лучше использовать схему шардирования, продиктованную требованиями предметной области, и не использовать возможность записи в Distributed таблицы. + +Запросы SELECT отправляются на все шарды, и работают независимо от того, каким образом данные распределены по шардам (они могут быть распределены полностью случайно). При добавлении нового шарда, можно не переносить на него старые данные, а записывать новые данные с большим весом - данные будут распределены слегка неравномерно, но запросы будут работать корректно и достаточно эффективно. + +Беспокоиться о схеме шардирования имеет смысл в следующих случаях: +- используются запросы, требующие соединение данных (IN, JOIN) по определённому ключу - тогда если данные шардированы по этому ключу, то можно использовать локальные IN, JOIN вместо GLOBAL IN, GLOBAL JOIN, что кардинально более эффективно. +- используется большое количество серверов (сотни и больше) и большое количество маленьких запросов (запросы отдельных клиентов - сайтов, рекламодателей, партнёров) - тогда, для того, чтобы маленькие запросы не затрагивали весь кластер, имеет смысл располагать данные одного клиента на одном шарде, или (вариант, который используется в Яндекс.Метрике) сделать двухуровневое шардирование: разбить весь кластер на «слои», где слой может состоять из нескольких шардов; данные для одного клиента располагаются на одном слое, но в один слой можно по мере необходимости добавлять шарды, в рамках которых данные распределены произвольным образом; создаются распределённые таблицы на каждый слой и одна общая распределённая таблица для глобальных запросов. + +Запись данных осуществляется полностью асинхронно. При вставке в таблицу, блок данных сначала записывается в файловую систему. Затем, в фоновом режиме отправляются на удалённые серверы при первой возможности. Период отправки регулируется настройками [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) и [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms). Движок таблиц `Distributed` отправляет каждый файл со вставленными данными отдельно, но можно включить пакетную отправку данных настройкой [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts). Эта настройка улучшает производительность кластера за счет более оптимального использования ресурсов сервера-отправителя и сети. Необходимо проверять, что данные отправлены успешно, для этого проверьте список файлов (данных, ожидающих отправки) в каталоге таблицы `/var/lib/clickhouse/data/database/table/`. Количество потоков для выполнения фоновых задач можно задать с помощью настройки [background_distributed_schedule_pool_size](../../../operations/settings/settings.md#background_distributed_schedule_pool_size). + +Если после INSERT-а в Distributed таблицу, сервер перестал существовать или был грубо перезапущен (например, в следствие аппаратного сбоя), то записанные данные могут быть потеряны. Если в директории таблицы обнаружен повреждённый кусок данных, то он переносится в поддиректорию broken и больше не используется. + +При выставлении опции max\_parallel\_replicas выполнение запроса распараллеливается по всем репликам внутри одного шарда. Подробнее смотрите раздел [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/distributed/) diff --git a/docs/ru/engines/table_engines/special/external_data.md b/docs/ru/engines/table-engines/special/external-data.md similarity index 100% rename from docs/ru/engines/table_engines/special/external_data.md rename to docs/ru/engines/table-engines/special/external-data.md diff --git a/docs/ru/engines/table-engines/special/file.md b/docs/ru/engines/table-engines/special/file.md new file mode 100644 index 00000000000..907988a47aa --- /dev/null +++ b/docs/ru/engines/table-engines/special/file.md @@ -0,0 +1,79 @@ +# File(Format) {#table_engines-file} + +Управляет данными в одном файле на диске в указанном формате. + +Примеры применения: + +- Выгрузка данных из ClickHouse в файл. +- Преобразование данных из одного формата в другой. +- Обновление данных в ClickHouse редактированием файла на диске. + +## Использование движка в сервере ClickHouse {#ispolzovanie-dvizhka-v-servere-clickhouse} + +``` sql +File(Format) +``` + +`Format` должен быть таким, который ClickHouse может использовать и в запросах `INSERT` и в запросах `SELECT`. Полный список поддерживаемых форматов смотрите в разделе [Форматы](../../../interfaces/formats.md#formats). + +Сервер ClickHouse не позволяет указать путь к файлу, с которым будет работать `File`. Используется путь к хранилищу, определенный параметром [path](../../../operations/server-configuration-parameters/settings.md) в конфигурации сервера. + +При создании таблицы с помощью `File(Format)` сервер ClickHouse создает в хранилище каталог с именем таблицы, а после добавления в таблицу данных помещает туда файл `data.Format`. + +Можно вручную создать в хранилище каталог таблицы, поместить туда файл, затем на сервере ClickHouse добавить ([ATTACH](../../../engines/table-engines/special/file.md)) информацию о таблице, соответствующей имени каталога и прочитать из файла данные. + +!!! warning "Warning" + Будьте аккуратны с этой функциональностью, поскольку сервер ClickHouse не отслеживает внешние изменения данных. Если в файл будет производиться запись одновременно со стороны сервера ClickHouse и с внешней стороны, то результат непредсказуем. + +**Пример:** + +**1.** Создадим на сервере таблицу `file_engine_table`: + +``` sql +CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) +``` + +В конфигурации по умолчанию сервер ClickHouse создаст каталог `/var/lib/clickhouse/data/default/file_engine_table`. + +**2.** Вручную создадим файл `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` с содержимым: + +``` bash +$cat data.TabSeparated +one 1 +two 2 +``` + +**3.** Запросим данные: + +``` sql +SELECT * FROM file_engine_table +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Использование движка в Clickhouse-local {#ispolzovanie-dvizhka-v-clickhouse-local} + +В [clickhouse-local](../../../engines/table-engines/special/file.md) движок в качестве параметра принимает не только формат, но и путь к файлу. В том числе можно указать стандартные потоки ввода/вывода цифровым или буквенным обозначением `0` или `stdin`, `1` или `stdout`. + +**Пример:** + +``` bash +$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" +``` + +## Детали реализации {#detali-realizatsii} + +- Поддерживается одновременное выполнение множества запросов `SELECT`, запросы `INSERT` могут выполняться только последовательно. +- Поддерживается создание ещё не существующего файла при запросе `INSERT`. +- Для существующих файлов `INSERT` записывает в конец файла. +- Не поддерживается: + - использование операций `ALTER` и `SELECT...SAMPLE`; + - индексы; + - репликация. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/file/) diff --git a/docs/ru/engines/table-engines/special/generate.md b/docs/ru/engines/table-engines/special/generate.md new file mode 120000 index 00000000000..04af4b109a7 --- /dev/null +++ b/docs/ru/engines/table-engines/special/generate.md @@ -0,0 +1 @@ +../../../../en/engines/table-engines/special/generate.md \ No newline at end of file diff --git a/docs/ru/engines/table-engines/special/index.md b/docs/ru/engines/table-engines/special/index.md new file mode 100644 index 00000000000..b1789f34347 --- /dev/null +++ b/docs/ru/engines/table-engines/special/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Special +toc_priority: 31 +--- + + diff --git a/docs/ru/engines/table-engines/special/join.md b/docs/ru/engines/table-engines/special/join.md new file mode 100644 index 00000000000..a5ed68f0959 --- /dev/null +++ b/docs/ru/engines/table-engines/special/join.md @@ -0,0 +1,104 @@ +# Join {#join} + +Подготовленная структура данных для использования в операциях [JOIN](../../../engines/table-engines/special/join.md#select-join). + +## Создание таблицы {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], +) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) +``` + +Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table-engines/special/join.md#create-table-query). + +**Параметры движка** + +- `join_strictness` – [строгость JOIN](../../../engines/table-engines/special/join.md#select-join-strictness). +- `join_type` – [тип JOIN](../../../engines/table-engines/special/join.md#select-join-types). +- `k1[, k2, ...]` – ключевые столбцы секции `USING` с которыми выполняется операция `JOIN`. + +Вводите параметры `join_strictness` и `join_type` без кавычек, например, `Join(ANY, LEFT, col1)`. Они должны быть такими же как и в той операции `JOIN`, в которой таблица будет использоваться. Если параметры не совпадают, ClickHouse не генерирует исключение и может возвращать неверные данные. + +## Использование таблицы {#ispolzovanie-tablitsy} + +### Пример {#primer} + +Создание левой таблицы: + +``` sql +CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog +``` + +``` sql +INSERT INTO id_val VALUES (1,11)(2,12)(3,13) +``` + +Создание правой таблицы с движком `Join`: + +``` sql +CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) +``` + +``` sql +INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) +``` + +Объединение таблиц: + +``` sql +SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 +``` + +``` text +┌─id─┬─val─┬─id_val_join.val─┐ +│ 1 │ 11 │ 21 │ +│ 2 │ 12 │ ᴺᵁᴸᴸ │ +│ 3 │ 13 │ 23 │ +└────┴─────┴─────────────────┘ +``` + +В качестве альтернативы, можно извлечь данные из таблицы `Join`, указав значение ключа объединения: + +``` sql +SELECT joinGet('id_val_join', 'val', toUInt32(1)) +``` + +``` text +┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ +│ 21 │ +└────────────────────────────────────────────┘ +``` + +### Выборка и вставка данных {#vyborka-i-vstavka-dannykh} + +Для добавления данных в таблицы с движком `Join` используйте запрос `INSERT`. Если таблица создавалась со строгостью `ANY`, то данные с повторяющимися ключами игнорируются. Если задавалась строгость `ALL`, то добавляются все строки. + +Из таблиц нельзя выбрать данные с помощью запроса `SELECT`. Вместо этого, используйте один из следующих методов: + +- Используйте таблицу как правую в секции `JOIN`. +- Используйте функцию [joinGet](../../../engines/table-engines/special/join.md#joinget), которая позволяет извлекать данные из таблицы таким же образом как из словаря. + +### Ограничения и настройки {#join-limitations-and-settings} + +При создании таблицы, применяются следующие параметры : + +- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) +- [max\_rows\_in\_join](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) +- [max\_bytes\_in\_join](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) +- [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) +- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) + +Таблицы с движком `Join` нельзя использовать в операциях `GLOBAL JOIN`. + +Движок `Join` позволяет использовать параметр [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) в запросе `CREATE TABLE`, который также можно использовать в запросе [SELECT](../../../engines/table-engines/special/join.md). Если у вас разные настройки `join_use_nulls`, вы можете получить сообщение об ошибке при объединении таблиц. Это зависит от типа соединения. Когда вы используете функцию [joinGet](../../../engines/table-engines/special/join.md#joinget), вам необходимо использовать один и тот же параметр `join_use_nulls` в запросах `CRATE TABLE` и `SELECT`. + +## Хранение данных {#khranenie-dannykh} + +Данные таблиц `Join` всегда находятся в RAM. При вставке строк в таблицу ClickHouse записывает блоки данных в каталог на диске, чтобы их можно было восстановить при перезапуске сервера. + +При аварийном перезапуске сервера блок данных на диске может быть потерян или повреждён. В последнем случае, может потребоваться вручную удалить файл с повреждёнными данными. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/join/) diff --git a/docs/ru/engines/table-engines/special/materializedview.md b/docs/ru/engines/table-engines/special/materializedview.md new file mode 100644 index 00000000000..08a2b4a3c07 --- /dev/null +++ b/docs/ru/engines/table-engines/special/materializedview.md @@ -0,0 +1,5 @@ +# MaterializedView {#materializedview} + +Используется для реализации материализованных представлений (подробнее см. запрос [CREATE TABLE](../../../engines/table-engines/special/materializedview.md)). Для хранения данных, использует другой движок, который был указан при создании представления. При чтении из таблицы, просто использует этот движок. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/materializedview/) diff --git a/docs/ru/engines/table_engines/special/memory.md b/docs/ru/engines/table-engines/special/memory.md similarity index 100% rename from docs/ru/engines/table_engines/special/memory.md rename to docs/ru/engines/table-engines/special/memory.md diff --git a/docs/ru/engines/table-engines/special/merge.md b/docs/ru/engines/table-engines/special/merge.md new file mode 100644 index 00000000000..4f6e1751591 --- /dev/null +++ b/docs/ru/engines/table-engines/special/merge.md @@ -0,0 +1,63 @@ +# Merge {#merge} + +Движок `Merge` (не путайте с движком `MergeTree`) не хранит данные самостоятельно, а позволяет читать одновременно из произвольного количества других таблиц. +Чтение автоматически распараллеливается. Запись в таблицу не поддерживается. При чтении будут использованы индексы тех таблиц, из которых реально идёт чтение, если они существуют. +Движок `Merge` принимает параметры: имя базы данных и регулярное выражение для таблиц. + +Пример: + +``` sql +Merge(hits, '^WatchLog') +``` + +Данные будут читаться из таблиц в базе `hits`, имена которых соответствуют регулярному выражению ‘`^WatchLog`’. + +Вместо имени базы данных может использоваться константное выражение, возвращающее строку. Например, `currentDatabase()`. + +Регулярные выражения — [re2](https://github.com/google/re2) (поддерживает подмножество PCRE), регистрозависимые. +Смотрите замечание об экранировании в регулярных выражениях в разделе «match». + +При выборе таблиц для чтения, сама `Merge`-таблица не будет выбрана, даже если попадает под регулярное выражение, чтобы не возникло циклов. +Впрочем, вы можете создать две `Merge`-таблицы, которые будут пытаться бесконечно читать данные друг друга, но делать этого не нужно. + +Типичный способ использования движка `Merge` — работа с большим количеством таблиц типа `TinyLog`, как с одной. + +Пример 2: + +Пусть есть старая таблица `WatchLog_old`. Необходимо изменить партиционирование без перемещения данных в новую таблицу `WatchLog_new`. При этом в выборке должны участвовать данные обеих таблиц. + +``` sql +CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree(date, (UserId, EventType), 8192); +INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); + +CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; +INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); + +CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); + +SELECT * +FROM WatchLog +``` + +``` text +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-01 │ 1 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-02 │ 2 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +``` + +## Виртуальные столбцы {#virtualnye-stolbtsy} + +- `_table` — содержит имя таблицы, из которой данные были прочитаны. Тип — [String](../../../engines/table-engines/special/merge.md). + + В секции `WHERE/PREWHERE` можно установить константное условие на столбец `_table` (например, `WHERE _table='xyz'`). В этом случае операции чтения выполняются только для тех таблиц, для которых выполняется условие на значение `_table`, таким образом, столбец `_table` работает как индекс. + +**Смотрите также** + +- [Виртуальные столбцы](index.md#table_engines-virtual_columns) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/merge/) diff --git a/docs/ru/engines/table_engines/special/null.md b/docs/ru/engines/table-engines/special/null.md similarity index 100% rename from docs/ru/engines/table_engines/special/null.md rename to docs/ru/engines/table-engines/special/null.md diff --git a/docs/ru/engines/table_engines/special/set.md b/docs/ru/engines/table-engines/special/set.md similarity index 100% rename from docs/ru/engines/table_engines/special/set.md rename to docs/ru/engines/table-engines/special/set.md diff --git a/docs/ru/engines/table_engines/special/url.md b/docs/ru/engines/table-engines/special/url.md similarity index 100% rename from docs/ru/engines/table_engines/special/url.md rename to docs/ru/engines/table-engines/special/url.md diff --git a/docs/ru/engines/table-engines/special/view.md b/docs/ru/engines/table-engines/special/view.md new file mode 100644 index 00000000000..a732a675d4c --- /dev/null +++ b/docs/ru/engines/table-engines/special/view.md @@ -0,0 +1,5 @@ +# View {#table_engines-view} + +Используется для реализации представлений (подробнее см. запрос `CREATE VIEW`). Не хранит данные, а хранит только указанный запрос `SELECT`. При чтении из таблицы, выполняет его (с удалением из запроса всех ненужных столбцов). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/view/) diff --git a/docs/ru/engines/table_engines/index.md b/docs/ru/engines/table_engines/index.md deleted file mode 100644 index fdf9cd50bf6..00000000000 --- a/docs/ru/engines/table_engines/index.md +++ /dev/null @@ -1,76 +0,0 @@ -# Движки таблиц {#table_engines} - -Движок таблицы (тип таблицы) определяет: - -- Как и где хранятся данные, куда их писать и откуда читать. -- Какие запросы поддерживаются и каким образом. -- Конкурентный доступ к данным. -- Использование индексов, если есть. -- Возможно ли многопоточное выполнение запроса. -- Параметры репликации данных. - -## Семейства движков {#semeistva-dvizhkov} - -### MergeTree {#mergetree} - -Наиболее универсальные и функциональные движки таблиц для задач с высокой загрузкой. Общим свойством этих движков является быстрая вставка данных с последующей фоновой обработкой данных. Движки `*MergeTree` поддерживают репликацию данных (в [Replicated\*](mergetree_family/replication.md) версиях движков), партиционирование, и другие возможности не поддержанные для других движков. - -Движки семейства: - -- [MergeTree](mergetree_family/mergetree.md) -- [ReplacingMergeTree](mergetree_family/replacingmergetree.md) -- [SummingMergeTree](mergetree_family/summingmergetree.md) -- [AggregatingMergeTree](mergetree_family/aggregatingmergetree.md) -- [CollapsingMergeTree](mergetree_family/collapsingmergetree.md) -- [VersionedCollapsingMergeTree](mergetree_family/versionedcollapsingmergetree.md) -- [GraphiteMergeTree](mergetree_family/graphitemergetree.md) - -### Log {#log} - -Простые [движки](log_family/index.md) с минимальной функциональностью. Они наиболее эффективны, когда вам нужно быстро записать много небольших таблиц (до примерно 1 миллиона строк) и прочитать их позже целиком. - -Движки семейства: - -- [TinyLog](log_family/tinylog.md) -- [StripeLog](log_family/stripelog.md) -- [Log](log_family/log.md) - -### Движки для интеграции {#dvizhki-dlia-integratsii} - -Движки для связи с другими системами хранения и обработки данных. - -Движки семейства: - -- [Kafka](integrations/kafka.md) -- [MySQL](integrations/mysql.md) -- [ODBC](integrations/odbc.md) -- [JDBC](integrations/jdbc.md) - -### Специальные движки {#spetsialnye-dvizhki} - -Движки семейства: - -- [Distributed](special/distributed.md) -- [MaterializedView](special/materializedview.md) -- [Dictionary](special/dictionary.md) -- [Merge](special/merge.md) -- [File](special/file.md) -- [Null](special/null.md) -- [Set](special/set.md) -- [Join](special/join.md) -- [URL](special/url.md) -- [View](special/view.md) -- [Memory](special/memory.md) -- [Buffer](special/buffer.md) - -## Виртуальные столбцы {#table_engines-virtual-columns} - -Виртуальный столбец — это неотъемлемый атрибут движка таблиц, определенный в исходном коде движка. - -Виртуальные столбцы не надо указывать в запросе `CREATE TABLE` и их не отображаются в результатах запросов `SHOW CREATE TABLE` и `DESCRIBE TABLE`. Также виртуальные столбцы доступны только для чтения, поэтому вы не можете вставлять в них данные. - -Чтобы получить данные из виртуального столбца, необходимо указать его название в запросе `SELECT`. `SELECT *` не отображает данные из виртуальных столбцов. - -При создании таблицы со столбцом, имя которого совпадает с именем одного из виртуальных столбцов таблицы, виртуальный столбец становится недоступным. Не делайте так. Чтобы помочь избежать конфликтов, имена виртуальных столбцов обычно предваряются подчеркиванием. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/) diff --git a/docs/ru/engines/table_engines/integrations/hdfs.md b/docs/ru/engines/table_engines/integrations/hdfs.md deleted file mode 100644 index 26b97a99f77..00000000000 --- a/docs/ru/engines/table_engines/integrations/hdfs.md +++ /dev/null @@ -1,112 +0,0 @@ -# HDFS {#table_engines-hdfs} - -Управляет данными в HDFS. Данный движок похож на движки [File](../special/file.md) и [URL](../special/url.md). - -## Использование движка {#ispolzovanie-dvizhka} - -``` sql -ENGINE = HDFS(URI, format) -``` - -В параметр `URI` нужно передавать полный URI файла в HDFS. -Параметр `format` должен быть таким, который ClickHouse может использовать и в запросах `INSERT`, и в запросах `SELECT`. Полный список поддерживаемых форматов смотрите в разделе [Форматы](../../../interfaces/formats.md#formats). -Часть URI с путем файла может содержать шаблоны. В этом случае таблица может использоваться только для чтения. - -**Пример:** - -**1.** Создадим на сервере таблицу `hdfs_engine_table`: - -``` sql -CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') -``` - -**2.** Заполним файл: - -``` sql -INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) -``` - -**3.** Запросим данные: - -``` sql -SELECT * FROM hdfs_engine_table LIMIT 2 -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Детали реализации {#detali-realizatsii} - -- Поддерживается многопоточное чтение и запись. -- Не поддерживается: - - использование операций `ALTER` и `SELECT...SAMPLE`; - - индексы; - - репликация. - -**Шаблоны в пути** - -Шаблоны могут содержаться в нескольких компонентах пути. Обрабатываются только существующие файлы, название которых целиком удовлетворяет шаблону (не только суффиксом или префиксом). - -- `*` — Заменяет любое количество любых символов кроме `/`, включая отсутствие символов. -- `?` — Заменяет ровно один любой символ. -- `{some_string,another_string,yet_another_one}` — Заменяет любую из строк `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Заменяет любое число в интервале от `N` до `M` включительно (может содержать ведущие нули). - -Конструкция с `{}` аналогична табличной функции [remote](../../../engines/table_engines/integrations/hdfs.md). - -**Пример** - -1. Предположим, у нас есть несколько файлов со следующими URI в HDFS: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. Есть несколько возможностей создать таблицу, состояющую из этих шести файлов: - - - -``` sql -CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') -``` - -Другой способ: - -``` sql -CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') -``` - -Таблица, состоящая из всех файлов в обеих директориях (все файлы должны удовлетворять формату и схеме, указанной в запросе): - -``` sql -CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') -``` - -!!! warning "Warning" - Если список файлов содержит числовые интервалы с ведущими нулями, используйте конструкцию с фигурными скобочками для каждой цифры или используйте `?`. - -**Example** - -Создадим таблицу с именами `file000`, `file001`, … , `file999`: - -``` sql -CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') -``` - -## Виртуальные столбцы {#virtualnye-stolbtsy} - -- `_path` — Путь к файлу. -- `_file` — Имя файла. - -**Смотрите также** - -- [Виртуальные столбцы](index.md#table_engines-virtual_columns) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/hdfs/) diff --git a/docs/ru/engines/table_engines/integrations/index.md b/docs/ru/engines/table_engines/integrations/index.md deleted file mode 100644 index 716d00cdd98..00000000000 --- a/docs/ru/engines/table_engines/integrations/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Integrations -toc_priority: 30 ---- - diff --git a/docs/ru/engines/table_engines/integrations/jdbc.md b/docs/ru/engines/table_engines/integrations/jdbc.md deleted file mode 100644 index ae461a539be..00000000000 --- a/docs/ru/engines/table_engines/integrations/jdbc.md +++ /dev/null @@ -1,87 +0,0 @@ -# JDBC {#jdbc} - -Позволяет ClickHouse подключаться к внешним базам данных с помощью [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). - -Для реализации соединения по JDBC ClickHouse использует отдельную программу [clickhouse-jdbc-bridge](https://github.com/alex-krash/clickhouse-jdbc-bridge), которая должна запускаться как демон. - -Движок поддерживает тип данных [Nullable](../../../engines/table_engines/integrations/jdbc.md). - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name -ENGINE = JDBC(dbms_uri, external_database, external_table) -``` - -**Параметры движка** - -- `dbms_uri` — URI внешней СУБД. - - Формат: `jdbc:://:/?user=&password=`. - - Пример для MySQL: `jdbc:mysql://localhost:3306/?user=root&password=root`. - -- `external_database` — база данных во внешней СУБД. - -- `external_table` — таблица в `external_database`. - -## Пример использования {#primer-ispolzovaniia} - -Создадим таблицу в на сервере MySQL с помощью консольного клиента MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+--------+--------------+-------+----------------+ -| int_id | int_nullable | float | float_nullable | -+--------+--------------+-------+----------------+ -| 1 | NULL | 2 | NULL | -+--------+--------------+-------+----------------+ -1 row in set (0,00 sec) -``` - -Создадим таблицу на сервере ClickHouse и получим из неё данные: - -``` sql -CREATE TABLE jdbc_table ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') -``` - -``` sql -DESCRIBE TABLE jdbc_table -``` - -``` text -┌─name───────────────┬─type───────────────┬─default_type─┬─default_expression─┐ -│ int_id │ Int32 │ │ │ -│ int_nullable │ Nullable(Int32) │ │ │ -│ float │ Float32 │ │ │ -│ float_nullable │ Nullable(Float32) │ │ │ -└────────────────────┴────────────────────┴──────────────┴────────────────────┘ -``` - -``` sql -SELECT * -FROM jdbc_table -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## Смотрите также {#smotrite-takzhe} - -- [Табличная функция JDBC](../../../engines/table_engines/integrations/jdbc.md). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/jdbc/) diff --git a/docs/ru/engines/table_engines/integrations/kafka.md b/docs/ru/engines/table_engines/integrations/kafka.md deleted file mode 100644 index 80b92d4b290..00000000000 --- a/docs/ru/engines/table_engines/integrations/kafka.md +++ /dev/null @@ -1,169 +0,0 @@ -# Kafka {#kafka} - -Движок работает с [Apache Kafka](http://kafka.apache.org/). - -Kafka позволяет: - -- Публиковать/подписываться на потоки данных. -- Организовать отказоустойчивое хранилище. -- Обрабатывать потоки по мере их появления. - -## Создание таблицы {#table_engine-kafka-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = Kafka() -SETTINGS - kafka_broker_list = 'host:port', - kafka_topic_list = 'topic1,topic2,...', - kafka_group_name = 'group_name', - kafka_format = 'data_format'[,] - [kafka_row_delimiter = 'delimiter_symbol',] - [kafka_schema = '',] - [kafka_num_consumers = N,] - [kafka_skip_broken_messages = N] -``` - -Обязательные параметры: - -- `kafka_broker_list` – перечень брокеров, разделенный запятыми (`localhost:9092`). -- `kafka_topic_list` – перечень необходимых топиков Kafka. -- `kafka_group_name` – группа потребителя Kafka. Отступы для чтения отслеживаются для каждой группы отдельно. Если необходимо, чтобы сообщения не повторялись на кластере, используйте везде одно имя группы. -- `kafka_format` – формат сообщений. Названия форматов должны быть теми же, что можно использовать в секции `FORMAT`, например, `JSONEachRow`. Подробнее читайте в разделе [Форматы](../../../interfaces/formats.md). - -Опциональные параметры: - -- `kafka_row_delimiter` – символ-разделитель записей (строк), которым завершается сообщение. -- `kafka_schema` – опциональный параметр, необходимый, если используется формат, требующий определения схемы. Например, [Cap’n Proto](https://capnproto.org/) требует путь к файлу со схемой и название корневого объекта `schema.capnp:Message`. -- `kafka_num_consumers` – количество потребителей (consumer) на таблицу. По умолчанию: `1`. Укажите больше потребителей, если пропускная способность одного потребителя недостаточна. Общее число потребителей не должно превышать количество партиций в топике, так как на одну партицию может быть назначено не более одного потребителя. -- `kafka_skip_broken_messages` – максимальное количество некорректных сообщений в блоке. Если `kafka_skip_broken_messages = N`, то движок отбрасывает `N` сообщений Кафки, которые не получилось обработать. Одно сообщение в точности соответствует одной записи (строке). Значение по умолчанию – 0. - -Примеры - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - SELECT * FROM queue LIMIT 5; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', - kafka_topic_list = 'topic', - kafka_group_name = 'group1', - kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') - SETTINGS kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; -``` - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот метод в новых проектах. По возможности переключите старые проекты на метод, описанный выше. - -``` sql -Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format - [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) -``` - -
- -## Описание {#opisanie} - -Полученные сообщения отслеживаются автоматически, поэтому из одной группы каждое сообщение считывается только один раз. Если необходимо получить данные дважды, то создайте копию таблицы с другим именем группы. - -Группы пластичны и синхронизированы на кластере. Например, если есть 10 топиков и 5 копий таблицы в кластере, то в каждую копию попадет по 2 топика. Если количество копий изменится, то распределение топиков по копиям изменится автоматически. Подробно читайте об этом на http://kafka.apache.org/intro. - -Чтение сообщения с помощью `SELECT` не слишком полезно (разве что для отладки), поскольку каждое сообщения может быть прочитано только один раз. Практичнее создавать потоки реального времени с помощью материализованных преставлений. Для этого: - -1. Создайте потребителя Kafka с помощью движка и рассматривайте его как поток данных. -2. Создайте таблицу с необходимой структурой. -3. Создайте материализованное представление, которое преобразует данные от движка и помещает их в ранее созданную таблицу. - -Когда к движку присоединяется материализованное представление (`MATERIALIZED VIEW`), оно начинает в фоновом режиме собирать данные. Это позволяет непрерывно получать сообщения от Kafka и преобразовывать их в необходимый формат с помощью `SELECT`. -Материализованных представлений у одной kafka таблицы может быть сколько угодно, они не считывают данные из таблицы kafka непосредственно, а получают новые записи (блоками), таким образом можно писать в несколько таблиц с разным уровнем детализации (с группировкой - агрегацией и без). - -Пример: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - CREATE TABLE daily ( - day Date, - level String, - total UInt64 - ) ENGINE = SummingMergeTree(day, (day, level), 8192); - - CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total - FROM queue GROUP BY day, level; - - SELECT level, sum(total) FROM daily GROUP BY level; -``` - -Для улучшения производительности полученные сообщения группируются в блоки размера [max\_insert\_block\_size](../../../operations/settings/settings.md#settings-max_insert_block_size). Если блок не удалось сформировать за [stream\_flush\_interval\_ms](../../../operations/settings/settings.md) миллисекунд, то данные будут сброшены в таблицу независимо от полноты блока. - -Чтобы остановить получение данных топика или изменить логику преобразования, отсоедините материализованное представление: - -``` sql - DETACH TABLE consumer; - ATTACH TABLE consumer; -``` - -Если необходимо изменить целевую таблицу с помощью `ALTER`, то материализованное представление рекомендуется отключить, чтобы избежать несостыковки между целевой таблицей и данными от представления. - -## Конфигурация {#konfiguratsiia} - -Аналогично GraphiteMergeTree, движок Kafka поддерживает расширенную конфигурацию с помощью конфигурационного файла ClickHouse. Существует два конфигурационных ключа, которые можно использовать: глобальный (`kafka`) и по топикам (`kafka_topic_*`). Сначала применяется глобальная конфигурация, затем конфигурация по топикам (если она существует). - -``` xml - - - cgrp - smallest - - - - - 250 - 100000 - -``` - -В документе [librdkafka configuration reference](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) можно увидеть список возможных опций конфигурации. Используйте подчеркивание (`_`) вместо точки в конфигурации ClickHouse. Например, `check.crcs=true` будет соответствовать `true`. - -## Виртуальные столбцы {#virtualnye-stolbtsy} - -- `_topic` — топик Kafka. -- `_key` — ключ сообщения. -- `_offset` — оффсет сообщения. -- `_timestamp` — временная метка сообщения. -- `_partition` — секция топика Kafka. - -**Смотрите также** - -- [Виртуальные столбцы](index.md#table_engines-virtual_columns) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/kafka/) diff --git a/docs/ru/engines/table_engines/integrations/mysql.md b/docs/ru/engines/table_engines/integrations/mysql.md deleted file mode 100644 index 7260b182c6d..00000000000 --- a/docs/ru/engines/table_engines/integrations/mysql.md +++ /dev/null @@ -1,98 +0,0 @@ -# MySQL {#mysql} - -Движок MySQL позволяет выполнять запросы `SELECT` над данными, хранящимися на удалённом MySQL сервере. - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... -) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table_engines/integrations/mysql.md#create-table-query). - -Структура таблицы может отличаться от исходной структуры таблицы MySQL: - -- Имена столбцов должны быть такими же, как в исходной таблице MySQL, но вы можете использовать только некоторые из этих столбцов и в любом порядке. -- Типы столбцов могут отличаться от типов в исходной таблице MySQL. ClickHouse пытается [приводить](../../../engines/table_engines/integrations/mysql.md#type_conversion_function-cast) значения к типам данных ClickHouse. - -**Параметры движка** - -- `host:port` — адрес сервера MySQL. - -- `database` — имя базы данных на удалённом сервере. - -- `table` — имя таблицы на удалённом сервере. - -- `user` — пользователь MySQL. - -- `password` — пароль пользователя. - -- `replace_query` — флаг, отвечающий за преобразование запросов `INSERT INTO` в `REPLACE INTO`. Если `replace_query=1`, то запрос заменяется. - -- `on_duplicate_clause` — выражение `ON DUPLICATE KEY on_duplicate_clause`, добавляемое к запросу `INSERT`. - - Пример: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, где `on_duplicate_clause` это `UPDATE c2 = c2 + 1`. Чтобы узнать какие `on_duplicate_clause` можно использовать с секцией `ON DUPLICATE KEY` обратитесь к [документации MySQL](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html). - - Чтобы указать `on_duplicate_clause` необходимо передать `0` в параметр `replace_query`. Если одновременно передать `replace_query = 1` и `on_duplicate_clause`, то ClickHouse сгенерирует исключение. - -Простые условия `WHERE` такие как `=, !=, >, >=, <, =` выполняются на стороне сервера MySQL. - -Остальные условия и ограничение выборки `LIMIT` будут выполнены в ClickHouse только после выполнения запроса к MySQL. - -## Пример использования {#primer-ispolzovaniia} - -Таблица в MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+--------+--------------+-------+----------------+ -| int_id | int_nullable | float | float_nullable | -+--------+--------------+-------+----------------+ -| 1 | NULL | 2 | NULL | -+--------+--------------+-------+----------------+ -1 row in set (0,00 sec) -``` - -Таблица в ClickHouse, которая получает данные из созданной ранее таблицы MySQL: - -``` sql -CREATE TABLE mysql_table -( - `float_nullable` Nullable(Float32), - `int_id` Int32 -) -ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` sql -SELECT * FROM mysql_table -``` - -``` text -┌─float_nullable─┬─int_id─┐ -│ ᴺᵁᴸᴸ │ 1 │ -└────────────────┴────────┘ -``` - -## Смотрите также {#smotrite-takzhe} - -- [Табличная функция ‘mysql’](../../../engines/table_engines/integrations/mysql.md) -- [Использование MySQL в качестве источника для внешнего словаря](../../../engines/table_engines/integrations/mysql.md#dicts-external_dicts_dict_sources-mysql) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/mysql/) diff --git a/docs/ru/engines/table_engines/integrations/odbc.md b/docs/ru/engines/table_engines/integrations/odbc.md deleted file mode 100644 index 6124a928315..00000000000 --- a/docs/ru/engines/table_engines/integrations/odbc.md +++ /dev/null @@ -1,125 +0,0 @@ -# ODBC {#table-engine-odbc} - -Позволяет ClickHouse подключаться к внешним базам данных с помощью [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -Чтобы использование ODBC было безопасным, ClickHouse использует отдельную программу `clickhouse-odbc-bridge`. Если драйвер ODBC подгружать непосредственно из `clickhouse-server`, то проблемы с драйвером могут привести к аварийной остановке сервера ClickHouse. ClickHouse автоматически запускает `clickhouse-odbc-bridge` по мере необходимости. Программа устанавливается из того же пакета, что и `clickhouse-server`. - -Движок поддерживает тип данных [Nullable](../../../engines/table_engines/integrations/odbc.md). - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1], - name2 [type2], - ... -) -ENGINE = ODBC(connection_settings, external_database, external_table) -``` - -Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table_engines/integrations/odbc.md#create-table-query). - -Структура таблицы может отличаться от структуры исходной таблицы в удалённой СУБД: - -- Имена столбцов должны быть такими же, как в исходной таблице, но вы можете использовать только некоторые из этих столбцов и в любом порядке. -- Типы столбцов могут отличаться от типов аналогичных столбцов в исходной таблице. ClickHouse пытается [приводить](../../../engines/table_engines/integrations/odbc.md#type_conversion_function-cast) значения к типам данных ClickHouse. - -**Параметры движка** - -- `connection_settings` — название секции с настройками соединения в файле `odbc.ini`. -- `external_database` — имя базы данных во внешней СУБД. -- `external_table` — имя таблицы в `external_database`. - -## Пример использования {#primer-ispolzovaniia} - -**Извлечение данных из локальной установки MySQL через ODBC** - -Этот пример проверялся в Ubuntu Linux 18.04 для MySQL server 5.7. - -Убедитесь, что unixODBC и MySQL Connector установлены. - -По умолчанию (если установлен из пакетов) ClickHouse запускается от имени пользователя `clickhouse`. Таким образом, вам нужно создать и настроить этого пользователя на сервере MySQL. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -Теперь настроим соединение в `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -Вы можете проверить соединение с помощью утилиты `isql` из установки unixODBC. - -``` bash -$ isql -v mysqlconn -+---------------------------------------+ -| Connected! | -| | -... -``` - -Таблица в MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+--------+--------------+-------+----------------+ -| int_id | int_nullable | float | float_nullable | -+--------+--------------+-------+----------------+ -| 1 | NULL | 2 | NULL | -+--------+--------------+-------+----------------+ -1 row in set (0,00 sec) -``` - -Таблица в ClickHouse, которая получает данные из таблицы MySQL: - -``` sql -CREATE TABLE odbc_t -( - `int_id` Int32, - `float_nullable` Nullable(Float32) -) -ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') -``` - -``` sql -SELECT * FROM odbc_t -``` - -``` text -┌─int_id─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ -└────────┴────────────────┘ -``` - -## Смотрите также {#smotrite-takzhe} - -- [Внешние словари ODBC](../../../engines/table_engines/integrations/odbc.md#dicts-external_dicts_dict_sources-odbc) -- [Табличная функция odbc](../../../engines/table_engines/integrations/odbc.md) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/odbc/) diff --git a/docs/ru/engines/table_engines/log_family/index.md b/docs/ru/engines/table_engines/log_family/index.md deleted file mode 100644 index a64371200a6..00000000000 --- a/docs/ru/engines/table_engines/log_family/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Log Family -toc_priority: 29 ---- - diff --git a/docs/ru/engines/table_engines/log_family/log.md b/docs/ru/engines/table_engines/log_family/log.md deleted file mode 100644 index 9f112f3f6b9..00000000000 --- a/docs/ru/engines/table_engines/log_family/log.md +++ /dev/null @@ -1,9 +0,0 @@ -# Log {#log} - -Движок относится к семейству движков Log. Смотрите общие свойства и различия движков в статье [Семейство Log](log_family.md). - -Отличается от [TinyLog](tinylog.md) тем, что вместе с файлами столбцов лежит небольшой файл «засечек». Засечки пишутся на каждый блок данных и содержат смещение - с какого места нужно читать файл, чтобы пропустить заданное количество строк. Это позволяет читать данные из таблицы в несколько потоков. -При конкурентном доступе к данным, чтения могут выполняться одновременно, а записи блокируют чтения и друг друга. -Движок Log не поддерживает индексы. Также, если при записи в таблицу произошёл сбой, то таблица станет битой, и чтения из неё будут возвращать ошибку. Движок Log подходит для временных данных, write-once таблиц, а также для тестовых и демонстрационных целей. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/log/) diff --git a/docs/ru/engines/table_engines/log_family/log_family.md b/docs/ru/engines/table_engines/log_family/log_family.md deleted file mode 100644 index f132c2e8d33..00000000000 --- a/docs/ru/engines/table_engines/log_family/log_family.md +++ /dev/null @@ -1,39 +0,0 @@ -# Семейство Log {#semeistvo-log} - -Движки разработаны для сценариев, когда необходимо быстро записывать много таблиц с небольшим объёмом данных (менее 1 миллиона строк), а затем читать их целиком. - -Движки семейства: - -- [StripeLog](stripelog.md) -- [Log](log.md) -- [TinyLog](tinylog.md) - -## Общие свойства {#obshchie-svoistva} - -Движки: - -- Хранят данные на диске. - -- Добавляют данные в конец файла при записи. - -- Поддерживают блокировки для конкурентного доступа к данным. - - Во время запросов `INSERT` таблица блокируется, а другие запросы на чтение и запись ожидают разблокировки таблицы. Если запросов на запись данных нет, то можно выполнять любое количество конкуретных запросов на чтение. - -- Не поддерживают операции [мутации](../../../engines/table_engines/log_family/log_family.md#alter-mutations). - -- Не поддерживают индексы. - - Это означает, что запросы `SELECT` не эффективны для выборки диапазонов данных. - -- Записывают данные не атомарно. - - Вы можете получить таблицу с повреждёнными данными, если что-то прервёт операцию записи (например, аварийное завершение работы сервера). - -## Отличия {#otlichiia} - -Движок `TinyLog` самый простой в семье и обеспечивает самые низкие функциональность и эффективность. Движок `TinyLog` не поддерживает параллельного чтения данных в несколько потоков. Движок читает данные медленнее, чем оба других движка с параллельным чтением, и использует почти столько же дескрипторов, сколько и движок `Log`, поскольку хранит каждый столбец в отдельном файле. Его можно использовать в простых сценариях с низкой нагрузкой. - -Движки `Log` и `StripeLog` поддерживают параллельное чтение. При чтении данных, ClickHouse использует множество потоков. Каждый поток обрабатывает отдельный блок данных. Движок `Log` сохраняет каждый столбец таблицы в отдельном файле. Движок `StripeLog` хранит все данные в одном файле. Таким образом, движок `StripeLog` использует меньше дескрипторов в операционной системе, а движок `Log` обеспечивает более эффективное считывание данных. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/log_family/) diff --git a/docs/ru/engines/table_engines/log_family/stripelog.md b/docs/ru/engines/table_engines/log_family/stripelog.md deleted file mode 100644 index 4eb4d4620de..00000000000 --- a/docs/ru/engines/table_engines/log_family/stripelog.md +++ /dev/null @@ -1,88 +0,0 @@ -# StripeLog {#stripelog} - -Движок относится к семейству движков Log. Смотрите общие свойства и различия движков в статье [Семейство Log](log_family.md). - -Движок разработан для сценариев, когда необходимо записывать много таблиц с небольшим объёмом данных (менее 1 миллиона строк). - -## Создание таблицы {#table_engines-stripelog-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = StripeLog -``` - -Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table_engines/log_family/stripelog.md#create-table-query). - -## Запись данных {#table_engines-stripelog-writing-the-data} - -Движок `StripeLog` хранит все столбцы в одном файле. При каждом запросе `INSERT`, ClickHouse добавляет блок данных в конец файла таблицы, записывая столбцы один за другим. - -Для каждой таблицы ClickHouse записывает файлы: - -- `data.bin` — файл с данными. -- `index.mrk` — файл с метками. Метки содержат смещения для каждого столбца каждого вставленного блока данных. - -Движок `StripeLog` не поддерживает запросы `ALTER UPDATE` и `ALTER DELETE`. - -## Чтение данных {#table_engines-stripelog-reading-the-data} - -Файл с метками позволяет ClickHouse распараллеливать чтение данных. Это означает, что запрос `SELECT` возвращает строки в непредсказуемом порядке. Используйте секцию `ORDER BY` для сортировки строк. - -## Пример использования {#table_engines-stripelog-example-of-use} - -Создание таблицы: - -``` sql -CREATE TABLE stripe_log_table -( - timestamp DateTime, - message_type String, - message String -) -ENGINE = StripeLog -``` - -Вставка данных: - -``` sql -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') -``` - -Мы использовали два запроса `INSERT` для создания двух блоков данных внутри файла `data.bin`. - -ClickHouse использует несколько потоков при выборе данных. Каждый поток считывает отдельный блок данных и возвращает результирующие строки независимо по мере завершения. В результате порядок блоков строк в выходных данных в большинстве случаев не совпадает с порядком тех же блоков во входных данных. Например: - -``` sql -SELECT * FROM stripe_log_table -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -┌───────────timestamp─┬─message_type─┬─message───────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -└─────────────────────┴──────────────┴───────────────────────────┘ -``` - -Сортировка результатов (по умолчанию по возрастанию): - -``` sql -SELECT * FROM stripe_log_table ORDER BY timestamp -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/stripelog/) diff --git a/docs/ru/engines/table_engines/log_family/tinylog.md b/docs/ru/engines/table_engines/log_family/tinylog.md deleted file mode 100644 index d6dafb63504..00000000000 --- a/docs/ru/engines/table_engines/log_family/tinylog.md +++ /dev/null @@ -1,9 +0,0 @@ -# TinyLog {#tinylog} - -Движок относится к семейству движков Log. Смотрите общие свойства и различия движков в статье [Семейство Log](log_family.md). - -Типичный способ использования этой движка — это write-once: сначала данные один раз записываются, а затем читаются столько раз, сколько это необходимо. Например, можно использовать таблицы с движком `TinyLog` для хранения промежуточных данных, которые обрабатываются небольшими блоками. Учтите, что хранить данные в большом количестве мелких таблиц неэффективно. - -Запросы выполняются в один поток. То есть, этот движок предназначен для сравнительно маленьких таблиц (до 1 000 000 строк). Этот движок таблиц имеет смысл использовать в том случае, когда у вас есть много маленьких таблиц, так как он проще, чем движок [Log](log.md) (требуется открывать меньше файлов). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/tinylog/) diff --git a/docs/ru/engines/table_engines/mergetree_family/aggregatingmergetree.md b/docs/ru/engines/table_engines/mergetree_family/aggregatingmergetree.md deleted file mode 100644 index 8fdf063f569..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/aggregatingmergetree.md +++ /dev/null @@ -1,95 +0,0 @@ -# AggregatingMergeTree {#aggregatingmergetree} - -Движок наследует функциональность [MergeTree](mergetree.md#table_engines-mergetree), изменяя логику слияния кусков данных. Все строки с одинаковым первичным ключом (точнее, с одинаковым [ключом сортировки](mergetree.md)) ClickHouse заменяет на одну (в пределах одного куска данных), которая хранит объединение состояний агрегатных функций. - -Таблицы типа `AggregatingMergeTree` могут использоваться для инкрементальной агрегации данных, в том числе, для агрегирующих материализованных представлений. - -Движок обрабатывает все столбцы типа [AggregateFunction](../../../engines/table_engines/mergetree_family/aggregatingmergetree.md). - -Использование `AggregatingMergeTree` оправдано только в том случае, когда это уменьшает количество строк на порядки. - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = AggregatingMergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Описание параметров запроса смотрите в [описании запроса](../../../engines/table_engines/mergetree_family/aggregatingmergetree.md). - -**Секции запроса** - -При создании таблицы `AggregatingMergeTree` используются те же [секции](mergetree.md), что и при создании таблицы `MergeTree`. - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -Все параметры имеют то же значение, что в и `MergeTree`. -
- -## SELECT/INSERT данных {#selectinsert-dannykh} - -Для вставки данных используйте `INSERT SELECT` с агрегатными `-State`-функциями. - -При выборке данных из таблицы `AggregatingMergeTree`, используйте `GROUP BY` и те же агрегатные функции, что и при вставке данных, но с суффиксом `-Merge`. - -В запросах `SELECT` значения типа `AggregateFunction` выводятся во всех форматах, которые поддерживает ClickHouse, в виде implementation-specific бинарных данных. Если с помощью `SELECT` выполнить дамп данных, например, в формат `TabSeparated`, то потом этот дамп можно загрузить обратно с помощью запроса `INSERT`. - -## Пример агрегирущего материализованного представления {#primer-agregirushchego-materializovannogo-predstavleniia} - -Создаём материализованное представление типа `AggregatingMergeTree`, следящее за таблицей `test.visits`: - -``` sql -CREATE MATERIALIZED VIEW test.basic -ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) -AS SELECT - CounterID, - StartDate, - sumState(Sign) AS Visits, - uniqState(UserID) AS Users -FROM test.visits -GROUP BY CounterID, StartDate; -``` - -Вставляем данные в таблицу `test.visits`: - -``` sql -INSERT INTO test.visits ... -``` - -Данные окажутся и в таблице и в представлении `test.basic`, которое выполнит агрегацию. - -Чтобы получить агрегированные данные, выполним запрос вида `SELECT ... GROUP BY ...` из представления `test.basic`: - -``` sql -SELECT - StartDate, - sumMerge(Visits) AS Visits, - uniqMerge(Users) AS Users -FROM test.basic -GROUP BY StartDate -ORDER BY StartDate; -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/aggregatingmergetree/) diff --git a/docs/ru/engines/table_engines/mergetree_family/collapsingmergetree.md b/docs/ru/engines/table_engines/mergetree_family/collapsingmergetree.md deleted file mode 100644 index 5179ac06fa5..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/collapsingmergetree.md +++ /dev/null @@ -1,305 +0,0 @@ -# CollapsingMergeTree {#table_engine-collapsingmergetree} - -Движок наследует функциональность от [MergeTree](mergetree.md) и добавляет в алгоритм слияния кусков данных логику сворачивания (удаления) строк. - -`CollapsingMergeTree` асинхронно удаляет (сворачивает) пары строк, если все поля в ключе сортировки (`ORDER BY`) эквивалентны, за исключением специального поля `Sign`, которое может принимать значения `1` и `-1`. Строки без пары сохраняются. Подробнее смотрите в разделе [Сворачивание (удаление) строк](#table_engine-collapsingmergetree-collapsing). - -Движок может значительно уменьшить объём хранения и, как следствие, повысить эффективность запросов `SELECT`. - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = CollapsingMergeTree(sign) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Подробности про `CREATE TABLE` смотрите в [описании запроса](../../../engines/table_engines/mergetree_family/collapsingmergetree.md). - -**Параметры CollapsingMergeTree** - -- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. - - Тип данных столбца — `Int8`. - -**Секции запроса** - -При создании таблицы с движком `CollapsingMergeTree` используются те же [секции запроса](mergetree.md#table_engine-mergetree-creating-a-table) что и при создании таблицы с движком `MergeTree`. - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) -``` - -Все параметры, кроме `ver` имеют то же значение, что и в `MergeTree`. - -- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. - - Тип данных столбца — `Int8`. - -
- -## Сворачивание (удаление) строк {#table_engine-collapsingmergetree-collapsing} - -### Данные {#dannye} - -Рассмотрим ситуацию, когда необходимо сохранять постоянно изменяющиеся данные для какого-либо объекта. Кажется логичным иметь одну строку для объекта и обновлять её при любом изменении, однако операция обновления является дорогостоящей и медленной для СУБД, поскольку требует перезаписи данных в хранилище. Если необходимо быстро записать данные, обновление не допустимо, но можно записать изменения объекта последовательно как описано ниже. - -Используйте специальный столбец `Sign`. Если `Sign = 1`, то это означает, что строка является состоянием объекта, назовём её строкой состояния. Если `Sign = -1`, то это означает отмену состояния объекта с теми же атрибутами, назовём её строкой отмены состояния. - -Например, мы хотим рассчитать, сколько страниц проверили пользователи на каком-то сайте и как долго они там находились. В какой-то момент времени мы пишем следующую строку с состоянием действий пользователя: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Через некоторое время мы регистрируем изменение активности пользователя и записываем его следующими двумя строками. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Первая строка отменяет предыдущее состояние объекта (пользователя). Она должен повторять все поля из ключа сортировки для отменённого состояния за исключением `Sign`. - -Вторая строка содержит текущее состояние. - -Поскольку нам нужно только последнее состояние активности пользователя, строки - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -можно удалить, сворачивая (удаляя) устаревшее состояние объекта. `CollapsingMergeTree` выполняет это при слиянии кусков данных. - -Зачем нужны две строки для каждого изменения описано в разделе [Алгоритм](#table_engine-collapsingmergetree-collapsing-algorithm). - -**Особенности подхода** - -1. Программа, которая записывает данные, должна помнить состояние объекта, чтобы иметь возможность отменить его. Строка отмены состояния должна содержать копию полей сортировочного ключа предыдущей строки состояния с противоположным значением `Sign`. Это увеличивает начальный размер хранилища, но позволяет быстро записывать данные. -2. Длинные растущие массивы в Столбцах снижают эффективность работы движка за счёт нагрузки на запись. Чем проще данные, тем выше эффективность. -3. Результаты запроса `SELECT` сильно зависят от согласованности истории изменений объекта. Будьте точны при подготовке данных для вставки. Можно получить непредсказуемые результаты для несогласованных данных, например отрицательные значения для неотрицательных метрик, таких как глубина сеанса. - -### Алгоритм {#table_engine-collapsingmergetree-collapsing-algorithm} - -Во время объединения кусков данных, каждая группа последовательных строк с одинаковым сортировочным ключом (`ORDER BY`) уменьшается до не более чем двух строк, одна из которых имеет `Sign = 1` (строка состояния), а другая строка с `Sign = -1` (строка отмены состояния). Другими словами, записи сворачиваются. - -Для каждого результирующего куска данных ClickHouse сохраняет: - - 1. Первую строку отмены состояния и последнюю строку состояния, если количество строк обоих видов совпадает. - - 2. Последнюю строку состояния, если строк состояния на одну больше, чем строк отмены состояния. - - 3. Первую строку отмены состояния, если их на одну больше, чем строк состояния. - - 4. Ни в одну из строк во всех остальных случаях. - - Слияние продолжается, но ClickHouse рассматривает эту ситуацию как логическую ошибку и записывает её в журнал сервера. Эта ошибка может возникать, если одни и те же данные вставлялись несколько раз. - -Как видно, от сворачивания не должны меняться результаты расчётов статистик. -Изменения постепенно сворачиваются так, что остаются лишь последнее состояние почти каждого объекта. - -Столбец `Sign` необходим, поскольку алгоритм слияния не гарантирует, что все строки с одинаковым ключом сортировки будут находиться в одном результирующем куске данных и даже на одном физическом сервере. ClickHouse выполняет запросы `SELECT` несколькими потоками, и он не может предсказать порядок строк в результате. Если необходимо получить полностью свёрнутые данные из таблицы `CollapsingMergeTree`, то необходимо агрегирование. - -Для завершения свертывания добавьте в запрос секцию`GROUP BY` и агрегатные функции, которые учитывают знак. Например, для расчета количества используйте `sum(Sign)` вместо`count()`. Чтобы вычислить сумму чего-либо, используйте `sum(Sign * x)` вместо`sum(х)`, и так далее, а также добавьте `HAVING sum(Sign) > 0` . - -Таким образом можно вычислять агрегации `count`, `sum` и `avg`. Если объект имеет хотя бы одно не свёрнутое состояние, то может быть вычислена агрегация `uniq`. Агрегации `min` и `max` невозможно вычислить, поскольку `CollapsingMergeTree` не сохраняет историю значений свернутых состояний. - -Если необходимо выбирать данные без агрегации (например, проверить наличие строк, последние значения которых удовлетворяют некоторым условиям), можно использовать модификатор `FINAL` для секции `FROM`. Это вариант существенно менее эффективен. - -## Пример использования {#primer-ispolzovaniia} - -Исходные данные: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Создание таблицы: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Insertion of the data: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) -``` - -Мы используем два запроса `INSERT` для создания двух различных кусков данных. Если вставить данные одним запросом, ClickHouse создаёт один кусок данных и никогда не будет выполнять слияние. - -Получение данных: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Что мы видим и где сворачивание? - -Двумя запросами `INSERT`, мы создали два куска данных. Запрос `SELECT` был выполнен в 2 потока, и мы получили случайный порядок строк. Сворачивание не произошло, так как слияние кусков данных еще не произошло. ClickHouse объединяет куски данных в неизвестный момент времени, который мы не можем предсказать. - -Таким образом, нам нужна агрегация: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration -FROM UAct -GROUP BY UserID -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -Если нам не нужна агрегация, но мы хотим принудительно выполнить свёртку данных, можно использовать модификатор `FINAL` для секции `FROM`. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Такой способ выбора данных очень неэффективен. Не используйте его для больших таблиц. - -## Пример другого подхода {#primer-drugogo-podkhoda} - -Исходные данные: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ -5 │ -146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Идея состоит в том, что слияния при сворачивании учитывают только ключевые поля, поэтому в отменяющей строке можно указать отрицательные значения, которые нивелируют предыдущую версию записи при суммировании без учета поля Sign. -Для этого подхода необходимо изменить тип данных `PageViews`, `Duration` для хранения отрицательных значений UInt8 -\> Int16. - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews Int16, - Duration Int16, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Тестируем подход: - -``` sql -insert into UAct values(4324182021466249494, 5, 146, 1); -insert into UAct values(4324182021466249494, -5, -146, -1); -insert into UAct values(4324182021466249494, 6, 185, 1); - -select * from UAct final; // старайтесь не использовать final (он подходит только для тестов и маленьких таблиц) -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -``` sql -SELECT - UserID, - sum(PageViews) AS PageViews, - sum(Duration) AS Duration -FROM UAct -GROUP BY UserID -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -``` sql -select count() FROM UAct -``` - -``` text -┌─count()─┐ -│ 3 │ -└─────────┘ -``` - -``` sql -optimize table UAct final; - -select * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/collapsingmergetree/) diff --git a/docs/ru/engines/table_engines/mergetree_family/custom_partitioning_key.md b/docs/ru/engines/table_engines/mergetree_family/custom_partitioning_key.md deleted file mode 100644 index 039ab1ba0cf..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/custom_partitioning_key.md +++ /dev/null @@ -1,126 +0,0 @@ -# Произвольный ключ партиционирования {#proizvolnyi-kliuch-partitsionirovaniia} - -Партиционирование данных доступно для таблиц семейства [MergeTree](mergetree.md) (включая [реплицированные таблицы](replication.md)). Таблицы [MaterializedView](../special/materializedview.md), созданные на основе таблиц MergeTree, также поддерживают партиционирование. - -Партиция – это набор записей в таблице, объединенных по какому-либо критерию. Например, партиция может быть по месяцу, по дню или по типу события. Данные для разных партиций хранятся отдельно. Это позволяет оптимизировать работу с данными, так как при обработке запросов будет использоваться только необходимое подмножество из всевозможных данных. Например, при получении данных за определенный месяц, ClickHouse будет считывать данные только за этот месяц. - -Ключ партиционирования задается при [создании таблицы](mergetree.md#table_engine-mergetree-creating-a-table), в секции `PARTITION BY expr`. Ключ может представлять собой произвольное выражение из столбцов таблицы. Например, чтобы задать партиционирования по месяцам, можно использовать выражение `toYYYYMM(date_column)`: - -``` sql -CREATE TABLE visits -( - VisitDate Date, - Hour UInt8, - ClientID UUID -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(VisitDate) -ORDER BY Hour -``` - -Ключом партиционирования также может быть кортеж из выражений (аналогично [первичному ключу](mergetree.md#primary-keys-and-indexes-in-queries)). Например: - -``` sql -ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) -PARTITION BY (toMonday(StartDate), EventType) -ORDER BY (CounterID, StartDate, intHash32(UserID)); -``` - -В этом примере задано партиционирование по типам событий, произошедших в течение текущей недели. - -Каждая партиция состоит из отдельных фрагментов или так называемых *кусков данных*. Каждый кусок отсортирован по первичному ключу. При вставке данных в таблицу каждая отдельная запись сохраняется в виде отдельного куска. Через некоторое время после вставки (обычно до 10 минут), ClickHouse выполняет в фоновом режиме слияние данных — в результате куски для одной и той же партиции будут объединены в более крупный кусок. - -!!! info "Info" - Не рекомендуется делать слишком гранулированное партиционирование – то есть задавать партиции по столбцу, в котором будет слишком большой разброс значений (речь идет о порядке более тысячи партиций). Это приведет к скоплению большого числа файлов и файловых дескрипторов в системе, что может значительно снизить производительность запросов `SELECT`. - -Чтобы получить набор кусков и партиций таблицы, можно воспользоваться системной таблицей [system.parts](../../../engines/table_engines/mergetree_family/custom_partitioning_key.md#system_tables-parts). В качестве примера рассмотрим таблицу `visits`, в которой задано партиционирование по месяцам. Выполним `SELECT` для таблицы `system.parts`: - -``` sql -SELECT - partition, - name, - active -FROM system.parts -WHERE table = 'visits' -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 1 │ -│ 201902 │ 201902_11_11_0 │ 1 │ -└───────────┴────────────────┴────────┘ -``` - -Столбец `partition` содержит имена всех партиций таблицы. Таблица `visits` из нашего примера содержит две партиции: `201901` и `201902`. Используйте значения из этого столбца в запросах [ALTER … PARTITION](#alter_manipulations-with-partitions). - -Столбец `name` содержит названия кусков партиций. Значения из этого столбца можно использовать в запросах [ALTER ATTACH PART](#alter_attach-partition). - -Столбец `active` отображает состояние куска. `1` означает, что кусок активен; `0` – неактивен. К неактивным можно отнести куски, оставшиеся после слияния данных. Поврежденные куски также отображаются как неактивные. Неактивные куски удаляются приблизительно через 10 минут после того, как было выполнено слияние. - -Рассмотрим детальнее имя первого куска `201901_1_3_1`: - -- `201901` имя партиции; -- `1` – минимальный номер блока данных; -- `3` – максимальный номер блока данных; -- `1` – уровень куска (глубина дерева слияний, которыми этот кусок образован). - -!!! info "Info" - Названия кусков для таблиц старого типа образуются следующим образом: `20190117_20190123_2_2_0` (минимальная дата \_ максимальная дата \_ номер минимального блока \_ номер максимального блока \_ уровень). - -Как видно из примера выше, таблица содержит несколько отдельных кусков для одной и той же партиции (например, куски `201901_1_3_1` и `201901_1_9_2` принадлежат партиции `201901`). Это означает, что эти куски еще не были объединены – в файловой системе они хранятся отдельно. После того как будет выполнено автоматическое слияние данных (выполняется примерно спустя 10 минут после вставки данных), исходные куски будут объединены в один более крупный кусок и помечены как неактивные. - -Вы можете запустить внеочередное слияние данных с помощью запроса [OPTIMIZE](../../../engines/table_engines/mergetree_family/custom_partitioning_key.md#misc_operations-optimize). Пример: - -``` sql -OPTIMIZE TABLE visits PARTITION 201902; -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 0 │ -│ 201902 │ 201902_4_11_2 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 0 │ -│ 201902 │ 201902_11_11_0 │ 0 │ -└───────────┴────────────────┴────────┘ -``` - -Неактивные куски будут удалены примерно через 10 минут после слияния. - -Другой способ посмотреть набор кусков и партиций – зайти в директорию с данными таблицы: `/var/lib/clickhouse/data///`. Например: - -``` bash -/var/lib/clickhouse/data/default/visits$ ls -l -total 40 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached -``` - -‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ и т. д. – это директории кусков партиции. Каждый кусок содержит данные только для соответствующего месяца (таблица в данном примере содержит партиционирование по месяцам). - -Директория `detached` содержит куски, отсоединенные от таблицы с помощью запроса [DETACH](#alter_detach-partition). Поврежденные куски также попадают в эту директорию – они не удаляются с сервера. - -Сервер не использует куски из директории `detached`. Вы можете в любое время добавлять, удалять, модифицировать данные в директории detached - сервер не будет об этом знать, пока вы не сделаете запрос [ATTACH](../../../engines/table_engines/mergetree_family/custom_partitioning_key.md#alter_attach-partition). - -Следует иметь в виду, что при работающем сервере нельзя вручную изменять набор кусков на файловой системе, так как сервер не будет знать об этом. -Для нереплицируемых таблиц, вы можете это делать при остановленном сервере, однако это не рекомендуется. -Для реплицируемых таблиц, набор кусков нельзя менять в любом случае. - -ClickHouse позволяет производить различные манипуляции с кусками: удалять, копировать из одной таблицы в другую или создавать их резервные копии. Подробнее см. в разделе [Манипуляции с партициями и кусками](../../../engines/table_engines/mergetree_family/custom_partitioning_key.md#alter_manipulations-with-partitions). - -[Оригинальная статья:](https://clickhouse.tech/docs/ru/operations/table_engines/custom_partitioning_key/) diff --git a/docs/ru/engines/table_engines/mergetree_family/graphitemergetree.md b/docs/ru/engines/table_engines/mergetree_family/graphitemergetree.md deleted file mode 100644 index 305300fc9a5..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/graphitemergetree.md +++ /dev/null @@ -1,169 +0,0 @@ -# GraphiteMergeTree {#graphitemergetree} - -Движок предназначен для прореживания и агрегирования/усреднения (rollup) данных [Graphite](http://graphite.readthedocs.io/en/latest/index.html). Он может быть интересен разработчикам, которые хотят использовать ClickHouse как хранилище данных для Graphite. - -Если rollup не требуется, то для хранения данных Graphite можно использовать любой движок таблиц ClickHouse, в противном случае используйте `GraphiteMergeTree`. Движок уменьшает объём хранения и повышает эффективность запросов от Graphite. - -Движок наследует свойства от [MergeTree](mergetree.md). - -## Создание таблицы {#creating-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE = GraphiteMergeTree(config_section) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Смотрите описание запроса [CREATE TABLE](../../../engines/table_engines/mergetree_family/graphitemergetree.md#create-table-query). - -В таблице должны быть столбцы для следующих данных: - -- Название метрики (сенсора Graphite). Тип данных: `String`. - -- Время измерения метрики. Тип данных `DateTime`. - -- Значение метрики. Тип данных: любой числовой. - -- Версия метрики. Тип данных: любой числовой. - - ClickHouse сохраняет строки с последней версией или последнюю записанную строку, если версии совпадают. Другие строки удаляются при слиянии кусков данных. - -Имена этих столбцов должны быть заданы в конфигурации rollup. - -**Параметры GraphiteMergeTree** - -- `config_section` — имя раздела в конфигурационном файле, в котором находятся правила rollup. - -**Секции запроса** - -При создании таблицы `GraphiteMergeTree` используются те же [секции](mergetree.md#table_engine-mergetree-creating-a-table) запроса, что и при создании таблицы `MergeTree`. - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - EventDate Date, - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) -``` - -Все параметры, кроме `config_section` имеют то же значение, что в `MergeTree`. - -- `config_section` — имя раздела в конфигурационном файле, в котором находятся правила rollup. - -
- -## Конфигурация rollup {#rollup-configuration} - -Настройки прореживания данных задаются параметром [graphite\_rollup](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) в конфигурации сервера . Имя параметра может быть любым. Можно создать несколько конфигураций и использовать их для разных таблиц. - -Структура конфигурации rollup: - -``` text -required-columns -patterns -``` - -### Требуемые столбцы (required-columns) {#required-columns} - -- `path_column_name` — столбец, в котором хранится название метрики (сенсор Graphite). Значение по умолчанию: `Path`. -- `time_column_name` — столбец, в котором хранится время измерения метрики. Значение по умолчанию: `Time`. -- `value_column_name` — столбец со значением метрики в момент времени, установленный в `time_column_name`. Значение по умолчанию: `Value`. -- `version_column_name` — столбец, в котором хранится версия метрики. Значение по умолчанию: `Timestamp`. - -### Правила (patterns) {#patterns} - -Структура раздела `patterns`: - -``` text -pattern - regexp - function -pattern - regexp - age + precision - ... -pattern - regexp - function - age + precision - ... -pattern - ... -default - function - age + precision - ... -``` - -!!! warning "Внимание" - Правила должны быть строго упорядочены: - - 1. Правила без `function` или `retention`. - 1. Правила одновремено содержащие `function` и `retention`. - 1. Правило `default`. - -При обработке строки ClickHouse проверяет правила в разделе `pattern`. Каждый `pattern` (включая `default`) может содержать параметр агрегации `function`, параметр `retention`, или оба параметра одновременно. Если имя метрики соответствует шаблону `regexp`, то применяются правила `pattern`, в противном случае правило `default`. - -Поля для разделов `pattern` и `default`: - -- `regexp` – шаблон имени метрики. -- `age` – минимальный возраст данных в секундах. -- `precision` – точность определения возраста данных в секундах. Должен быть делителем для 86400 (количество секунд в сутках). -- `function` – имя агрегирующей функции, которую следует применить к данным, чей возраст оказался в интервале `[age, age + precision]`. - -### Пример конфигурации {#configuration-example} - -``` xml - - Version - - click_cost - any - - 0 - 5 - - - 86400 - 60 - - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/graphitemergetree/) diff --git a/docs/ru/engines/table_engines/mergetree_family/index.md b/docs/ru/engines/table_engines/mergetree_family/index.md deleted file mode 100644 index 6a23ef23a8e..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: MergeTree Family -toc_priority: 28 ---- - diff --git a/docs/ru/engines/table_engines/mergetree_family/mergetree.md b/docs/ru/engines/table_engines/mergetree_family/mergetree.md deleted file mode 100644 index f67d03ed875..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/mergetree.md +++ /dev/null @@ -1,637 +0,0 @@ -# MergeTree {#table_engines-mergetree} - -Движок `MergeTree`, а также другие движки этого семейства (`*MergeTree`) — это наиболее функциональные движки таблиц ClickHouse. - -Основная идея, заложенная в основу движков семейства `MergeTree` следующая. Когда у вас есть огромное количество данных, которые должны быть вставлены в таблицу, вы должны быстро записать их по частям, а затем объединить части по некоторым правилам в фоновом режиме. Этот метод намного эффективнее, чем постоянная перезапись данных в хранилище при вставке. - -Основные возможности: - -- Хранит данные, отсортированные по первичному ключу. - - Это позволяет создавать разреженный индекс небольшого объёма, который позволяет быстрее находить данные. - -- Позволяет оперировать партициями, если задан [ключ партиционирования](custom_partitioning_key.md). - - ClickHouse поддерживает отдельные операции с партициями, которые работают эффективнее, чем общие операции с этим же результатом над этими же данными. Также, ClickHouse автоматически отсекает данные по партициям там, где ключ партиционирования указан в запросе. Это также увеличивает эффективность выполнения запросов. - -- Поддерживает репликацию данных. - - Для этого используется семейство таблиц `ReplicatedMergeTree`. Подробнее читайте в разделе [Репликация данных](replication.md). - -- Поддерживает сэмплирование данных. - - При необходимости можно задать способ сэмплирования данных в таблице. - -!!! info "Info" - Движок [Merge](../special/merge.md) не относится к семейству `*MergeTree`. - -## Создание таблицы {#table_engine-mergetree-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... - INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, - INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 -) ENGINE = MergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] -[SETTINGS name=value, ...] -``` - -Описание параметров смотрите в [описании запроса CREATE](../../../engines/table_engines/mergetree_family/mergetree.md). - -!!! note "Note" - `INDEX` — экспериментальная возможность, смотрите [Индексы пропуска данных](#table_engine-mergetree-data_skipping-indexes). - -### Секции запроса {#mergetree-query-clauses} - -- `ENGINE` — имя и параметры движка. `ENGINE = MergeTree()`. `MergeTree` не имеет параметров. - -- `PARTITION BY` — [ключ партиционирования](custom_partitioning_key.md). - - Для партиционирования по месяцам используйте выражение `toYYYYMM(date_column)`, где `date_column` — столбец с датой типа [Date](../../../engines/table_engines/mergetree_family/mergetree.md). В этом случае имена партиций имеют формат `"YYYYMM"`. - -- `ORDER BY` — ключ сортировки. - - Кортеж столбцов или произвольных выражений. Пример: `ORDER BY (CounterID, EventDate)`. - -- `PRIMARY KEY` — первичный ключ, если он [отличается от ключа сортировки](#pervichnyi-kliuch-otlichnyi-ot-kliucha-sortirovki). - - По умолчанию первичный ключ совпадает с ключом сортировки (который задаётся секцией `ORDER BY`.) Поэтому в большинстве случаев секцию `PRIMARY KEY` отдельно указывать не нужно. - -- `SAMPLE BY` — выражение для сэмплирования. - - Если используется выражение для сэмплирования, то первичный ключ должен содержать его. Пример: - - `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. - -- `TTL` — список правил, определяющих длительности хранения строк, а также задающих правила перемещения частей на определённые тома или диски. - - Выражение должно возвращать столбец `Date` или `DateTime`. Пример: `TTL date + INTERVAL 1 DAY`. - - Тип правила `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` указывает действие, которое будет выполнено с частью, удаление строк (прореживание), перемещение (при выполнении условия для всех строк части) на определённый диск (`TO DISK 'xxx'`) или том (`TO VOLUME 'xxx'`). Поведение по умолчанию соответствует удалению строк (`DELETE`). В списке правил может быть указано только одно выражение с поведением `DELETE`. - - Дополнительные сведения смотрите в разделе [TTL для столбцов и таблиц](#table_engine-mergetree-ttl) - -- `SETTINGS` — дополнительные параметры, регулирующие поведение `MergeTree`: - - - `index_granularity` — максимальное количество строк данных между засечками индекса. По умолчанию — 8192. Смотрите [Хранение данных](#mergetree-data-storage). - - `index_granularity_bytes` — максимальный размер гранул данных в байтах. По умолчанию — 10Mb. Чтобы ограничить размер гранул только количеством строк, установите значение 0 (не рекомендовано). Смотрите [Хранение данных](#mergetree-data-storage). - - `enable_mixed_granularity_parts` — включает или выключает переход к ограничению размера гранул с помощью настройки `index_granularity_bytes`. До версии 19.11, размер гранул ограничивался только настройкой `index_granularity`. Настройка `index_granularity_bytes` улучшает производительность ClickHouse при выборке данных из таблиц с большими (десятки и сотни мегабайтов) строками. Если у вас есть таблицы с большими строками, можно включить эту настройку, чтобы повысить эффективность запросов `SELECT`. - - `use_minimalistic_part_header_in_zookeeper` — Способ хранения заголовков кусков данных в ZooKeeper. Если `use_minimalistic_part_header_in_zookeeper = 1`, то ZooKeeper хранит меньше данных. Подробнее читайте в [описании настройки](../../../operations/server_configuration_parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) в разделе "Конфигурационные параметры сервера". - - `min_merge_bytes_to_use_direct_io` — минимальный объём данных при слиянии, необходимый для прямого (небуферизованного) чтения/записи (direct I/O) на диск. При слиянии частей данных ClickHouse вычисляет общий объём хранения всех данных, подлежащих слиянию. Если общий объём хранения всех данных для чтения превышает `min_bytes_to_use_direct_io` байт, тогда ClickHouse использует флаг `O_DIRECT` при чтении данных с диска. Если `min_merge_bytes_to_use_direct_io = 0`, тогда прямой ввод-вывод отключен. Значение по умолчанию: `10 * 1024 * 1024 * 1024` байтов. - - - `merge_with_ttl_timeout` — минимальное время в секундах перед повторным слиянием с TTL. По умолчанию — 86400 (1 день). - - `write_final_mark` — включает или отключает запись последней засечки индекса в конце куска данных, указывающей за последний байт. По умолчанию — 1. Не отключайте её. - - `merge_max_block_size` — Максимальное количество строк в блоке для операций слияния. Значение по умолчанию: 8192. - - `storage_policy` — политика хранения данных. Смотрите [Хранение данных таблицы на нескольких блочных устройствах](#table_engine-mergetree-multiple-volumes). - -**Пример задания секций** - -``` sql -ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 -``` - -В примере мы устанавливаем партиционирование по месяцам. - -Также мы задаем выражение для сэмплирования в виде хэша по идентификатору посетителя. Это позволяет псевдослучайным образом перемешать данные в таблице для каждого `CounterID` и `EventDate`. Если при выборке данных задать секцию [SAMPLE](../../../engines/table_engines/mergetree_family/mergetree.md#select-sample-clause), то ClickHouse вернёт равномерно-псевдослучайную выборку данных для подмножества посетителей. - -`index_granularity` можно было не указывать, поскольку 8192 — это значение по умолчанию. - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ, описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -**Параметры MergeTree()** - -- `date-column` — имя столбца с типом [Date](../../../engines/table_engines/mergetree_family/mergetree.md). На основе этого столбца ClickHouse автоматически создаёт партиции по месяцам. Имена партиций имеют формат `"YYYYMM"`. -- `sampling_expression` — выражение для сэмплирования. -- `(primary, key)` — первичный ключ. Тип — [Tuple()](../../../engines/table_engines/mergetree_family/mergetree.md) -- `index_granularity` — гранулярность индекса. Число строк данных между «засечками» индекса. Для большинства задач подходит значение 8192. - -**Пример** - -``` sql -MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) -``` - -Движок `MergeTree` сконфигурирован таким же образом, как и в примере выше для основного способа конфигурирования движка. - -
- -## Хранение данных {#mergetree-data-storage} - -Таблица состоит из *кусков* данных (data parts), отсортированных по первичному ключу. - -При вставке в таблицу создаются отдельные куски данных, каждый из которых лексикографически отсортирован по первичному ключу. Например, если первичный ключ — `(CounterID, Date)`, то данные в куске будут лежать в порядке `CounterID`, а для каждого `CounterID` в порядке `Date`. - -Данные, относящиеся к разным партициям, разбиваются на разные куски. В фоновом режиме ClickHouse выполняет слияния (merge) кусков данных для более эффективного хранения. Куски, относящиеся к разным партициям не объединяются. Механизм слияния не гарантирует, что все строки с одинаковым первичным ключом окажутся в одном куске. - -Каждый кусок данных логически делится на гранулы. Гранула — это минимальный неделимый набор данных, который ClickHouse считывает при выборке данных. ClickHouse не разбивает строки и значения и гранула всегда содержит целое число строк. Первая строка гранулы помечается значением первичного ключа для этой строки (засечка). Для каждого куска данных ClickHouse создаёт файл с засечками (индексный файл). Для каждого столбца, независимо от того, входит он в первичный ключ или нет, ClickHouse также сохраняет эти же засечки. Засечки используются для поиска данных напрямую в файлах столбцов. - -Размер гранул оганичен настройками движка `index_granularity` и `index_granularity_bytes`. Количество строк в грануле лежит в диапазоне `[1, index_granularity]`, в зависимости от размера строк. Размер гранулы может превышать `index_granularity_bytes` в том случае, когда размер единственной строки в грануле превышает значение настройки. В этом случае, размер гранулы равен размеру строки. - -## Первичные ключи и индексы в запросах {#primary-keys-and-indexes-in-queries} - -Рассмотрим первичный ключ — `(CounterID, Date)`. В этом случае сортировку и индекс можно проиллюстрировать следующим образом: - -``` text -Whole data: [-------------------------------------------------------------------------] -CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] -Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] -Marks: | | | | | | | | | | | - a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 -Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 -``` - -Если в запросе к данным указать: - -- `CounterID IN ('a', 'h')`, то сервер читает данные в диапазонах засечек `[0, 3)` и `[6, 8)`. -- `CounterID IN ('a', 'h') AND Date = 3`, то сервер читает данные в диапазонах засечек `[1, 3)` и `[7, 8)`. -- `Date = 3`, то сервер читает данные в диапазоне засечек `[1, 10]`. - -Примеры выше показывают, что использование индекса всегда эффективнее, чем full scan. - -Разреженный индекс допускает чтение лишних строк. При чтении одного диапазона первичного ключа, может быть прочитано до `index_granularity * 2` лишних строк в каждом блоке данных. - -Разреженный индекс почти всегда помещаеся в оперативную память и позволяет работать с очень большим количеством строк в таблицах. - -ClickHouse не требует уникального первичного ключа. Можно вставить много строк с одинаковым первичным ключом. - -### Выбор первичного ключа {#vybor-pervichnogo-kliucha} - -Количество столбцов в первичном ключе не ограничено явным образом. В зависимости от структуры данных в первичный ключ можно включать больше или меньше столбцов. Это может: - -- Увеличить эффективность индекса. - - Пусть первичный ключ — `(a, b)`, тогда добавление ещё одного столбца `c` повысит эффективность, если выполнены условия: - - - Есть запросы с условием на столбец `c`. - - Часто встречаются достаточно длинные (в несколько раз больше `index_granularity`) диапазоны данных с одинаковыми значениями `(a, b)`. Иначе говоря, когда добавление ещё одного столбца позволит пропускать достаточно длинные диапазоны данных. - -- Улучшить сжатие данных. - - ClickHouse сортирует данные по первичному ключу, поэтому чем выше однородность, тем лучше сжатие. - -- Обеспечить дополнительную логику при слиянии кусков данных в движках [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) и [SummingMergeTree](summingmergetree.md). - - В этом случае имеет смысл указать отдельный *ключ сортировки*, отличающийся от первичного ключа. - -Длинный первичный ключ будет негативно влиять на производительность вставки и потребление памяти, однако на производительность ClickHouse при запросах `SELECT` лишние столбцы в первичном ключе не влияют. - -### Первичный ключ, отличный от ключа сортировки {#pervichnyi-kliuch-otlichnyi-ot-kliucha-sortirovki} - -Существует возможность задать первичный ключ (выражение, значения которого будут записаны в индексный файл для -каждой засечки), отличный от ключа сортировки (выражение, по которому будут упорядочены строки в кусках -данных). Кортеж выражения первичного ключа при этом должен быть префиксом кортежа выражения ключа -сортировки. - -Данная возможность особенно полезна при использовании движков [SummingMergeTree](summingmergetree.md) -и [AggregatingMergeTree](aggregatingmergetree.md). В типичном сценарии использования этих движков таблица -содержит столбцы двух типов: *измерения* (dimensions) и *меры* (measures). Типичные запросы агрегируют -значения столбцов-мер с произвольной группировкой и фильтрацией по измерениям. Так как `SummingMergeTree` -и `AggregatingMergeTree` производят фоновую агрегацию строк с одинаковым значением ключа сортировки, приходится -добавлять в него все столбцы-измерения. В результате выражение ключа содержит большой список столбцов, -который приходится постоянно расширять при добавлении новых измерений. - -В этом сценарии имеет смысл оставить в первичном ключе всего несколько столбцов, которые обеспечат эффективную фильтрацию по индексу, а остальные столбцы-измерения добавить в выражение ключа сортировки. - -[ALTER ключа сортировки](../../../engines/table_engines/mergetree_family/mergetree.md) — лёгкая операция, так как при одновременном добавлении нового столбца в таблицу и ключ сортировки не нужно изменять данные кусков (они остаются упорядоченными и по новому выражению ключа). - -### Использование индексов и партиций в запросах {#ispolzovanie-indeksov-i-partitsii-v-zaprosakh} - -Для запросов `SELECT` ClickHouse анализирует возможность использования индекса. Индекс может использоваться, если в секции `WHERE/PREWHERE`, в качестве одного из элементов конъюнкции, или целиком, есть выражение, представляющее операции сравнения на равенства, неравенства, а также `IN` или `LIKE` с фиксированным префиксом, над столбцами или выражениями, входящими в первичный ключ или ключ партиционирования, либо над некоторыми частично монотонными функциями от этих столбцов, а также логические связки над такими выражениями. - -Таким образом, обеспечивается возможность быстро выполнять запросы по одному или многим диапазонам первичного ключа. Например, в указанном примере будут быстро работать запросы для конкретного счётчика; для конкретного счётчика и диапазона дат; для конкретного счётчика и даты, для нескольких счётчиков и диапазона дат и т. п. - -Рассмотрим движок сконфигурированный следующим образом: - -``` sql -ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 -``` - -В этом случае в запросах: - -``` sql -SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 -SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) -SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) -``` - -ClickHouse будет использовать индекс по первичному ключу для отсечения не подходящих данных, а также ключ партиционирования по месяцам для отсечения партиций, которые находятся в не подходящих диапазонах дат. - -Запросы выше показывают, что индекс используется даже для сложных выражений. Чтение из таблицы организовано так, что использование индекса не может быть медленнее, чем full scan. - -В примере ниже индекс не может использоваться. - -``` sql -SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' -``` - -Чтобы проверить, сможет ли ClickHouse использовать индекс при выполнении запроса, используйте настройки [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) и [force\_primary\_key](../../../operations/settings/settings.md#settings-force_primary_key). - -Ключ партиционирования по месяцам обеспечивает чтение только тех блоков данных, которые содержат даты из нужного диапазона. При этом блок данных может содержать данные за многие даты (до целого месяца). В пределах одного блока данные упорядочены по первичному ключу, который может не содержать дату в качестве первого столбца. В связи с этим, при использовании запроса с указанием условия только на дату, но не на префикс первичного ключа, будет читаться данных больше, чем за одну дату. - -### Использование индекса для частично-монотонных первичных ключей {#ispolzovanie-indeksa-dlia-chastichno-monotonnykh-pervichnykh-kliuchei} - -Рассмотрим, например, дни месяца. Они образуют последовательность [монотонную](https://ru.wikipedia.org/wiki/Монотонная_последовательность) в течение одного месяца, но не монотонную на более длительных периодах. Это частично-монотонная последовательность. Если пользователь создаёт таблицу с частично-монотонным первичным ключом, ClickHouse как обычно создаёт разреженный индекс. Когда пользователь выбирает данные из такого рода таблиц, ClickHouse анализирует условия запроса. Если пользователь хочет получить данные между двумя метками индекса, и обе эти метки находятся внутри одного месяца, ClickHouse может использовать индекс в данном конкретном случае, поскольку он может рассчитать расстояние между параметрами запроса и индексными метками. - -ClickHouse не может использовать индекс, если значения первичного ключа в диапазоне параметров запроса не представляют собой монотонную последовательность. В этом случае ClickHouse использует метод полного сканирования. - -ClickHouse использует эту логику не только для последовательностей дней месяца, но и для любого частично-монотонного первичного ключа. - -### Индексы пропуска данных (экспериментальная функциональность) {#table_engine-mergetree-data_skipping-indexes} - -Объявление индексов при определении столбцов в запросе `CREATE`. - -``` sql -INDEX index_name expr TYPE type(...) GRANULARITY granularity_value -``` - -Для таблиц семейства `*MergeTree` можно задать дополнительные индексы в секции столбцов. - -Индексы агрегируют для заданного выражения некоторые данные, а потом при `SELECT` запросе используют для пропуска блоков данных (пропускаемый блок состоит из гранул данных в количестве равном гранулярности данного индекса), на которых секция `WHERE` не может быть выполнена, тем самым уменьшая объём данных читаемых с диска. - -**Пример** - -``` sql -CREATE TABLE table_name -( - u64 UInt64, - i32 Int32, - s String, - ... - INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, - INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 -) ENGINE = MergeTree() -... -``` - -Эти индексы смогут использоваться для оптимизации следующих запросов - -``` sql -SELECT count() FROM table WHERE s < 'z' -SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 -``` - -#### Доступные индексы {#dostupnye-indeksy} - -- `minmax` — Хранит минимум и максимум выражения (если выражение - `tuple`, то для каждого элемента `tuple`), используя их для пропуска блоков аналогично первичному ключу. - -- `set(max_rows)` — Хранит уникальные значения выражения на блоке в количестве не более `max_rows` (если `max_rows = 0`, то ограничений нет), используя их для пропуска блоков, оценивая выполнимость `WHERE` выражения на хранимых данных. - -- `bloom_filter([false_positive])` — [фильтр Блума](https://en.wikipedia.org/wiki/Bloom_filter) для указанных стоблцов. - - Необязательный параметр `false_positive` — это вероятность получения ложноположительного срабатывания. Возможные значения: (0, 1). Значение по умолчанию: 0.025. - - Поддержанные типы данных: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`. - - Фильтром могут пользоваться функции: [equals](../../../engines/table_engines/mergetree_family/mergetree.md), [notEquals](../../../engines/table_engines/mergetree_family/mergetree.md), [in](../../../engines/table_engines/mergetree_family/mergetree.md), [notIn](../../../engines/table_engines/mergetree_family/mergetree.md). - -**Примеры** - -``` sql -INDEX b (u64 * length(str), i32 + f64 * 100, date, str) TYPE minmax GRANULARITY 4 -INDEX b (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 -``` - -#### Поддержка для функций {#podderzhka-dlia-funktsii} - -Условия в секции `WHERE` содержат вызовы функций, оперирующих со столбцами. Если столбец - часть индекса, ClickHouse пытается использовать индекс при выполнении функции. Для разных видов индексов, ClickHouse поддерживает различные наборы функций, которые могут использоваться индексами. - -Индекс `set` используется со всеми функциями. Наборы функций для остальных индексов представлены в таблице ниже. - -| Function (operator) / Index | primary key | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | -|----------------------------------------------------------------------------------------------------------|-------------|--------|-------------|-------------|---------------| -| [equals (=, ==)](../../../engines/table_engines/mergetree_family/mergetree.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notEquals(!=, \<\>)](../../../engines/table_engines/mergetree_family/mergetree.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [like](../../../engines/table_engines/mergetree_family/mergetree.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [notLike](../../../engines/table_engines/mergetree_family/mergetree.md#function-notlike) | ✔ | ✔ | ✔ | ✔ | ✗ | -| [startsWith](../../../engines/table_engines/mergetree_family/mergetree.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | -| [endsWith](../../../engines/table_engines/mergetree_family/mergetree.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | -| [multiSearchAny](../../../engines/table_engines/mergetree_family/mergetree.md#function-multisearchany) | ✗ | ✗ | ✔ | ✔ | ✗ | -| [in](../../../engines/table_engines/mergetree_family/mergetree.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notIn](../../../engines/table_engines/mergetree_family/mergetree.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [less (\<)](../../../engines/table_engines/mergetree_family/mergetree.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [greater (\>)](../../../engines/table_engines/mergetree_family/mergetree.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [lessOrEquals (\<=)](../../../engines/table_engines/mergetree_family/mergetree.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [greaterOrEquals (\>=)](../../../engines/table_engines/mergetree_family/mergetree.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [empty](../../../engines/table_engines/mergetree_family/mergetree.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [notEmpty](../../../engines/table_engines/mergetree_family/mergetree.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | - -Функции с постоянным агрументом, который меньше, чем размер ngram не могут использовать индекс `ngrambf_v1` для оптимизации запроса. - -Фильтры Блума могут иметь ложнопозитивные срабатывания, следовательно индексы `ngrambf_v1`, `tokenbf_v1` и `bloom_filter` невозможно использовать для оптимизации запросов, в которых результат функции предполается false, например: - -- Можно оптимизировать: - - `s LIKE '%test%'` - - `NOT s NOT LIKE '%test%'` - - `s = 1` - - `NOT s != 1` - - `startsWith(s, 'test')` -- Нельзя оптимизировать: - - `NOT s LIKE '%test%'` - - `s NOT LIKE '%test%'` - - `NOT s = 1` - - `s != 1` - - `NOT startsWith(s, 'test')` - -## Конкурентный доступ к данным {#konkurentnyi-dostup-k-dannym} - -Для конкурентного доступа к таблице используется мультиверсионность. То есть, при одновременном чтении и обновлении таблицы, данные будут читаться из набора кусочков, актуального на момент запроса. Длинных блокировок нет. Вставки никак не мешают чтениям. - -Чтения из таблицы автоматически распараллеливаются. - -## TTL для столбцов и таблиц {#table_engine-mergetree-ttl} - -Определяет время жизни значений, а также правила перемещения данных на другой диск или том. - -Секция `TTL` может быть установлена как для всей таблицы, так и для каждого отдельного столбца. Правила `TTL` для таблицы позволяют указать целевые диски или тома для фонового перемещения на них частей данных. - -Выражения должны возвращать тип [Date](../../../engines/table_engines/mergetree_family/mergetree.md) или [DateTime](../../../engines/table_engines/mergetree_family/mergetree.md). - -Для задания времени жизни столбца, например: - -``` sql -TTL time_column -TTL time_column + interval -``` - -Чтобы задать `interval`, используйте операторы [интервала времени](../../../engines/table_engines/mergetree_family/mergetree.md#operators-datetime). - -``` sql -TTL date_time + INTERVAL 1 MONTH -TTL date_time + INTERVAL 15 HOUR -``` - -### TTL столбца {#mergetree-column-ttl} - -Когда срок действия значений в столбце истечет, ClickHouse заменит их значениями по умолчанию для типа данных столбца. Если срок действия всех значений столбцов в части данных истек, ClickHouse удаляет столбец из куска данных в файловой системе. - -Секцию `TTL` нельзя использовать для ключевых столбцов. - -Примеры: - -Создание таблицы с TTL - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int TTL d + INTERVAL 1 MONTH, - b Int TTL d + INTERVAL 1 MONTH, - c String -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d; -``` - -Добавление TTL на колонку существующей таблицы - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 DAY; -``` - -Изменение TTL у колонки - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 MONTH; -``` - -### TTL таблицы {#mergetree-table-ttl} - -Для таблицы можно задать одно выражение для устаревания данных, а также несколько выражений, по срабатывании которых данные переместятся на [некоторый диск или том](#table_engine-mergetree-multiple-volumes). Когда некоторые данные в таблице устаревают, ClickHouse удаляет все соответствующие строки. - -``` sql -TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... -``` - -За каждым TTL выражением может следовать тип действия, которое выполняется после достижения времени, соответствующего результату TTL выражения: - -- `DELETE` - удалить данные (действие по умолчанию); -- `TO DISK 'aaa'` - переместить данные на диск `aaa`; -- `TO VOLUME 'bbb'` - переместить данные на том `bbb`. - -Примеры: - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d -TTL d + INTERVAL 1 MONTH [DELETE], - d + INTERVAL 1 WEEK TO VOLUME 'aaa', - d + INTERVAL 2 WEEK TO DISK 'bbb'; -``` - -Изменение TTL - -``` sql -ALTER TABLE example_table - MODIFY TTL d + INTERVAL 1 DAY; -``` - -**Удаление данных** - -Данные с истекшим TTL удаляются, когда ClickHouse мёржит куски данных. - -Когда ClickHouse видит, что некоторые данные устарели, он выполняет внеплановые мёржи. Для управление частотой подобных мёржей, можно задать настройку [merge\_with\_ttl\_timeout](#mergetree_setting-merge_with_ttl_timeout). Если её значение слишком низкое, придется выполнять много внеплановых мёржей, которые могут начать потреблять значительную долю ресурсов сервера. - -Если вы выполните запрос `SELECT` между слияниями вы можете получить устаревшие данные. Чтобы избежать этого используйте запрос [OPTIMIZE](../../../engines/table_engines/mergetree_family/mergetree.md#misc_operations-optimize) перед `SELECT`. - -## Хранение данных таблицы на нескольких блочных устройствах {#table_engine-mergetree-multiple-volumes} - -### Введение {#vvedenie} - -Движки таблиц семейства `MergeTree` могут хранить данные на нескольких блочных устройствах. Это может оказаться полезным, например, при неявном разделении данных одной таблицы на «горячие» и «холодные». Наиболее свежая часть занимает малый объём и запрашивается регулярно, а большой хвост исторических данных запрашивается редко. При наличии в системе нескольких дисков, «горячая» часть данных может быть размещена на быстрых дисках (например, на NVMe SSD или в памяти), а холодная на более медленных (например, HDD). - -Минимальной перемещаемой единицей для `MergeTree` является кусок данных (data part). Данные одного куска могут находится только на одном диске. Куски могут перемещаться между дисками в фоне, согласно пользовательским настройкам, а также с помощью запросов [ALTER](../../../engines/table_engines/mergetree_family/mergetree.md#alter_move-partition). - -### Термины {#terminy} - -- Диск — примонтированное в файловой системе блочное устройство. -- Диск по умолчанию — диск, на котором находится путь, указанный в конфигурационной настройке сервера [path](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path). -- Том (Volume) — упорядоченный набор равноценных дисков (схоже с [JBOD](https://ru.wikipedia.org/wiki/JBOD)) -- Политика хранения (StoragePolicy) — множество томов с правилами перемещения данных между ними. - -У всех описанных сущностей при создании указываются имена, можно найти в системных таблицах [system.storage\_policies](../../../engines/table_engines/mergetree_family/mergetree.md#system_tables-storage_policies) и [system.disks](../../../engines/table_engines/mergetree_family/mergetree.md#system_tables-disks). Имя политики хранения можно указать в настройке `storage_policy` движков таблиц семейства `MergeTree`. - -### Конфигурация {#table_engine-mergetree-multiple-volumes-configure} - -Диски, тома и политики хранения задаются внутри тега `` в основном файле `config.xml` или в отдельном файле в директории `config.d`. - -Структура конфигурации: - -``` xml - - - - /mnt/fast_ssd/clickhouse/ - - - /mnt/hdd1/clickhouse/ - 10485760 - - - /mnt/hdd2/clickhouse/ - 10485760 - - - ... - - - ... - -``` - -Теги: - -- `` — имя диска. Имена должны быть разными для всех дисков. -- `path` — путь по которому будут храниться данные сервера (каталоги `data` и `shadow`), должен быть терминирован `/`. -- `keep_free_space_bytes` — размер зарезервированного свободного места на диске. - -Порядок задания дисков не имеет значения. - -Общий вид конфигурации политик хранения: - -``` xml - - ... - - - - - disk_name_from_disks_configuration - 1073741824 - - - - - - - 0.2 - - - - - - - - ... - -``` - -Тэги: - -- `policy_name_N` — название политики. Названия политик должны быть уникальны. -- `volume_name_N` — название тома. Названия томов должны быть уникальны. -- `disk` — диск, находящийся внутри тома. -- `max_data_part_size_bytes` — максимальный размер куска данных, который может находится на любом из дисков этого тома. -- `move_factor` — доля свободного места, при превышении которого данные начинают перемещаться на следующий том, если он есть (по умолчанию 0.1). - -Примеры конфигураций: - -``` xml - - ... - - - - - disk1 - disk2 - - - - - - - - fast_ssd - 1073741824 - - - disk1 - - - 0.2 - - - ... - -``` - -В приведенном примере, политика `hdd_in_order` реализует прицип [round-robin](https://ru.wikipedia.org/wiki/Round-robin_(%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC)). Так как в политике есть всего один том (`single`), то все записи производятся на его диски по круговому циклу. Такая политика может быть полезна при наличии в системе нескольких похожих дисков, но при этом не сконфигурирован RAID. Учтите, что каждый отдельный диск ненадёжен и чтобы не потерять важные данные это необходимо скомпенсировать за счет хранения данных в трёх копиях. - -Если система содержит диски различных типов, то может пригодиться политика `moving_from_ssd_to_hdd`. В томе `hot` находится один SSD-диск (`fast_ssd`), а также задается ограничение на максимальный размер куска, который может храниться на этом томе (1GB). Все куски такой таблицы больше 1GB будут записываться сразу на том `cold`, в котором содержится один HDD-диск `disk1`. Также, при заполнении диска `fast_ssd` более чем на 80% данные будут переносится на диск `disk1` фоновым процессом. - -Порядок томов в политиках хранения важен, при достижении условий на переполнение тома данные переносятся на следующий. Порядок дисков в томах так же важен, данные пишутся по очереди на каждый из них. - -После задания конфигурации политик хранения их можно использовать, как настройку при создании таблиц: - -``` sql -CREATE TABLE table_with_non_default_policy ( - EventDate Date, - OrderID UInt64, - BannerID UInt64, - SearchPhrase String -) ENGINE = MergeTree -ORDER BY (OrderID, BannerID) -PARTITION BY toYYYYMM(EventDate) -SETTINGS storage_policy = 'moving_from_ssd_to_hdd' -``` - -По умолчанию используется политика хранения `default` в которой есть один том и один диск, указанный в ``. В данный момент менять политику хранения после создания таблицы нельзя. - -### Особенности работы {#osobennosti-raboty} - -В таблицах `MergeTree` данные попадают на диск несколькими способами: - -- В результате вставки (запрос `INSERT`). -- В фоновых операциях слияний и [мутаций](../../../engines/table_engines/mergetree_family/mergetree.md#alter-mutations). -- При скачивании данных с другой реплики. -- В результате заморозки партиций [ALTER TABLE … FREEZE PARTITION](../../../engines/table_engines/mergetree_family/mergetree.md#alter_freeze-partition). - -Во всех случаях, кроме мутаций и заморозки партиций, при записи куска выбирается том и диск в соответствии с указанной конфигурацией хранилища: - -1. Выбирается первый по порядку том, на котором есть свободное место для записи куска (`unreserved_space > current_part_size`) и который позволяет записывать куски требуемого размера `max_data_part_size_bytes > current_part_size`. -2. Внутри тома выбирается следующий диск после того, на который была предыдущая запись и на котором свободного места больше чем размер куска (`unreserved_space - keep_free_space_bytes > current_part_size`) - -Мутации и запросы заморозки партиций в реализации используют [жесткие ссылки](https://ru.wikipedia.org/wiki/%D0%96%D1%91%D1%81%D1%82%D0%BA%D0%B0%D1%8F_%D1%81%D1%81%D1%8B%D0%BB%D0%BA%D0%B0). Жесткие ссылки между различными дисками не поддерживаются, поэтому в случае таких операций куски размещаются на тех же дисках, что и исходные. - -В фоне куски перемещаются между томами на основе информации о занятом месте (настройка `move_factor`) по порядку, в котором указаны тома в конфигурации. Данные никогда не перемещаются с последнего тома и на первый том. Следить за фоновыми перемещениями можно с помощью системных таблиц [system.part\_log](../../../engines/table_engines/mergetree_family/mergetree.md#system_tables-part-log) (поле `type = MOVE_PART`) и [system.parts](../../../engines/table_engines/mergetree_family/mergetree.md#system_tables-parts) (поля `path` и `disk`). Также подробная информация о перемещениях доступна в логах сервера. -С помощью запроса [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../engines/table_engines/mergetree_family/mergetree.md#alter_move-partition) пользователь может принудительно перенести кусок или партицию с одного раздела на другой. При этом учитываются все ограничения, указанные для фоновых операций. Запрос самостоятельно инициирует процесс перемещения не дожидаясь фоновых операций. В случае недостатка места или неудовлетворения ограничениям пользователь получит сообщение об ошибке. - -Перемещения данных не взаимодействуют с репликацией данных, поэтому на разных репликах одной и той же таблицы могут быть указаны разные политики хранения. - -После выполнения фоновых слияний или мутаций старые куски не удаляются сразу, а через некоторое время (табличная настройка `old_parts_lifetime`). Также они не перемещаются на другие тома или диски, поэтому до момента удаления они продолжают учитываться при подсчёте занятого дискового пространства. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/ru/engines/table_engines/mergetree_family/replacingmergetree.md b/docs/ru/engines/table_engines/mergetree_family/replacingmergetree.md deleted file mode 100644 index 40a1eb1a9c6..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/replacingmergetree.md +++ /dev/null @@ -1,61 +0,0 @@ -# ReplacingMergeTree {#replacingmergetree} - -Движок отличается от [MergeTree](mergetree.md#table_engines-mergetree) тем, что выполняет удаление дублирующихся записей с одинаковым значением первичного ключа (точнее, с одинаковым значением [ключа сортировки](mergetree.md)). - -Дедупликация данных производится лишь во время слияний. Слияние происходят в фоне в неизвестный момент времени, на который вы не можете ориентироваться. Некоторая часть данных может остаться необработанной. Хотя вы можете вызвать внеочередное слияние с помощью запроса `OPTIMIZE`, на это не стоит рассчитывать, так как запрос `OPTIMIZE` приводит к чтению и записи большого объёма данных. - -Таким образом, `ReplacingMergeTree` подходит для фоновой чистки дублирующихся данных в целях экономии места, но не даёт гарантии отсутствия дубликатов. - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = ReplacingMergeTree([ver]) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Описание параметров запроса смотрите в [описании запроса](../../../engines/table_engines/mergetree_family/replacingmergetree.md). - -**Параметры ReplacingMergeTree** - -- `ver` — столбец с версией, тип `UInt*`, `Date` или `DateTime`. Необязательный параметр. - - При слиянии, из всех строк с одинаковым значением первичного ключа `ReplacingMergeTree` оставляет только одну: - - - Последнюю в выборке, если `ver` не задан. - - С максимальной версией, если `ver` задан. - -**Секции запроса** - -При создании таблицы `ReplacingMergeTree` используются те же [секции](mergetree.md), что и при создании таблицы `MergeTree`. - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) -``` - -Все параметры, кроме `ver` имеют то же значение, что в и `MergeTree`. - -- `ver` — столбец с версией. Необязательный параметр. Описание смотрите выше по тексту. - -
- -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/replacingmergetree/) diff --git a/docs/ru/engines/table_engines/mergetree_family/replication.md b/docs/ru/engines/table_engines/mergetree_family/replication.md deleted file mode 100644 index 14a50a2b94b..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/replication.md +++ /dev/null @@ -1,211 +0,0 @@ -# Репликация данных {#table_engines-replication} - -Репликация поддерживается только для таблиц семейства MergeTree: - -- ReplicatedMergeTree -- ReplicatedSummingMergeTree -- ReplicatedReplacingMergeTree -- ReplicatedAggregatingMergeTree -- ReplicatedCollapsingMergeTree -- ReplicatedVersionedCollapsingMergeTree -- ReplicatedGraphiteMergeTree - -Репликация работает на уровне отдельных таблиц, а не всего сервера. То есть, на сервере могут быть расположены одновременно реплицируемые и не реплицируемые таблицы. - -Репликация не зависит от шардирования. На каждом шарде репликация работает независимо. - -Реплицируются сжатые данные запросов `INSERT`, `ALTER` (см. подробности в описании запроса [ALTER](../../../engines/table_engines/mergetree_family/replication.md#query_language_queries_alter)). - -Запросы `CREATE`, `DROP`, `ATTACH`, `DETACH` и `RENAME` выполняются на одном сервере и не реплицируются: - -- Запрос `CREATE TABLE` создаёт новую реплицируемую таблицу на том сервере, где его выполнили. Если таблица уже существует на других серверах, запрос добавляет новую реплику. -- `DROP TABLE` удаляет реплику, расположенную на том сервере, где выполняется запрос. -- Запрос `RENAME` переименовывает таблицу на одной реплик. Другими словами, реплицируемые таблицы на разных репликах могут называться по-разному. - -ClickHouse хранит метаинформацию о репликах в [Apache ZooKeeper](https://zookeeper.apache.org). Используйте ZooKeeper 3.4.5 или новее. - -Для использовании репликации, установите параметры в секции [zookeeper](../../../operations/server_configuration_parameters/settings.md#server-settings_zookeeper) конфигурации сервера. - -!!! attention "Внимание" - Не пренебрегайте настройками безопасности. ClickHouse поддерживает [ACL схему](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) `digest` подсистемы безопасности ZooKeeper. - -Пример указания адресов кластера ZooKeeper: - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - - example3 - 2181 - - -``` - -Можно указать любой имеющийся у вас ZooKeeper-кластер - система будет использовать в нём одну директорию для своих данных (директория указывается при создании реплицируемой таблицы). - -Если в конфигурационном файле не настроен ZooKeeper, то вы не сможете создать реплицируемые таблицы, а уже имеющиеся реплицируемые таблицы будут доступны в режиме только на чтение. - -При запросах `SELECT`, ZooKeeper не используется, т.е. репликация не влияет на производительность `SELECT` и запросы работают так же быстро, как и для нереплицируемых таблиц. При запросах к распределенным реплицированным таблицам поведение ClickHouse регулируется настройками [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) and [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md). - -При каждом запросе `INSERT`, делается около десятка записей в ZooKeeper в рамках нескольких транзакций. (Чтобы быть более точным, это для каждого вставленного блока данных; запрос INSERT содержит один блок или один блок на `max_insert_block_size = 1048576` строк.) Это приводит к некоторому увеличению задержек при `INSERT`, по сравнению с нереплицируемыми таблицами. Но если придерживаться обычных рекомендаций - вставлять данные пачками не более одного `INSERT` в секунду, то это не составляет проблем. На всём кластере ClickHouse, использующим для координации один кластер ZooKeeper, может быть в совокупности несколько сотен `INSERT` в секунду. Пропускная способность при вставке данных (количество строчек в секунду) такая же высокая, как для нереплицируемых таблиц. - -Для очень больших кластеров, можно использовать разные кластеры ZooKeeper для разных шардов. Впрочем, на кластере Яндекс.Метрики (примерно 300 серверов) такой необходимости не возникает. - -Репликация асинхронная, мульти-мастер. Запросы `INSERT` и `ALTER` можно направлять на любой доступный сервер. Данные вставятся на сервер, где выполнен запрос, а затем скопируются на остальные серверы. В связи с асинхронностью, только что вставленные данные появляются на остальных репликах с небольшой задержкой. Если часть реплик недоступна, данные на них запишутся тогда, когда они станут доступны. Если реплика доступна, то задержка составляет столько времени, сколько требуется для передачи блока сжатых данных по сети. - -По умолчанию, запрос INSERT ждёт подтверждения записи только от одной реплики. Если данные были успешно записаны только на одну реплику, и сервер с этой репликой перестал существовать, то записанные данные будут потеряны. Вы можете включить подтверждение записи от нескольких реплик, используя настройку `insert_quorum`. - -Каждый блок данных записывается атомарно. Запрос INSERT разбивается на блоки данных размером до `max_insert_block_size = 1048576` строк. То есть, если в запросе `INSERT` менее 1048576 строк, то он делается атомарно. - -Блоки данных дедуплицируются. При многократной записи одного и того же блока данных (блоков данных одинакового размера, содержащих одни и те же строчки в одном и том же порядке), блок будет записан только один раз. Это сделано для того, чтобы в случае сбоя в сети, когда клиентское приложение не может понять, были ли данные записаны в БД, можно было просто повторить запрос `INSERT`. При этом не имеет значения, на какую реплику будут отправлены INSERT-ы с одинаковыми данными. Запрос `INSERT` идемпотентный. Параметры дедуплицирования регулируются настройками сервера [merge\_tree](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-merge_tree) - -При репликации, по сети передаются только исходные вставляемые данные. Дальнейшие преобразования данных (слияния) координируются и делаются на всех репликах одинаковым образом. За счёт этого минимизируется использование сети, и благодаря этому, репликация хорошо работает при расположении реплик в разных дата-центрах. (Стоит заметить, что дублирование данных в разных дата-центрах, по сути, является основной задачей репликации). - -Количество реплик одних и тех же данных может быть произвольным. В Яндекс.Метрике в продакшене используется двукратная репликация. На каждом сервере используется RAID-5 или RAID-6, в некоторых случаях RAID-10. Это является сравнительно надёжным и удобным для эксплуатации решением. - -Система следит за синхронностью данных на репликах и умеет восстанавливаться после сбоя. Восстановление после сбоя автоматическое (в случае небольших различий в данных) или полуавтоматическое (когда данные отличаются слишком сильно, что может свидетельствовать об ошибке конфигурации). - -## Создание реплицируемых таблиц {#creating-replicated-tables} - -В начало имени движка таблицы добавляется `Replicated`. Например, `ReplicatedMergeTree`. - -**Параметры Replicated\*MergeTree** - -- `zoo_path` — путь к таблице в ZooKeeper. -- `replica_name` — имя реплики в ZooKeeper. - -Пример: - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -``` - -
- -Пример в устаревшем синтаксисе - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) -``` - -
- -Как видно в примере, эти параметры могут содержать подстановки в фигурных скобках. Подставляемые значения достаются из конфигурационного файла, из секции `macros`. Пример: - -``` xml - - 05 - 02 - example05-02-1.yandex.ru - -``` - -Путь к таблице в ZooKeeper должен быть разным для каждой реплицируемой таблицы. В том числе, для таблиц на разных шардах, должны быть разные пути. -В данном случае, путь состоит из следующих частей: - -`/clickhouse/tables/` — общий префикс. Рекомендуется использовать именно его. - -`{layer}-{shard}` — идентификатор шарда. В данном примере он состоит из двух частей, так как на кластере Яндекс.Метрики используется двухуровневое шардирование. Для большинства задач, оставьте только подстановку {shard}, которая будет раскрываться в идентификатор шарда. - -`table_name` - имя узла для таблицы в ZooKeeper. Разумно делать его таким же, как имя таблицы. Оно указывается явно, так как, в отличие от имени таблицы, оно не меняется после запроса RENAME. -*Подсказка*: можно также указать имя базы данных перед `table_name`, например `db_name.table_name` - -Имя реплики — то, что идентифицирует разные реплики одной и той же таблицы. Можно использовать для него имя сервера, как показано в примере. Впрочем, достаточно, чтобы имя было уникально лишь в пределах каждого шарда. - -Можно не использовать подстановки, а указать соответствующие параметры явно. Это может быть удобным для тестирования и при настройке маленьких кластеров. Однако в этом случае нельзя пользоваться распределенными DDL-запросами (`ON CLUSTER`). - -При работе с большими кластерами мы рекомендуем использовать подстановки, они уменьшают вероятность ошибки. - -Выполните запрос `CREATE TABLE` на каждой реплике. Запрос создаёт новую реплицируемую таблицу, или добавляет новую реплику к имеющимся. - -Если вы добавляете новую реплику после того, как таблица на других репликах уже содержит некоторые данные, то после выполнения запроса, данные на новую реплику будут скачаны с других реплик. То есть, новая реплика синхронизирует себя с остальными. - -Для удаления реплики, выполните запрос `DROP TABLE`. При этом, удаляется только одна реплика — расположенная на том сервере, где вы выполняете запрос. - -## Восстановление после сбоя {#vosstanovlenie-posle-sboia} - -Если при старте сервера, недоступен ZooKeeper, реплицируемые таблицы переходят в режим только для чтения. Система будет пытаться периодически установить соединение с ZooKeeper. - -Если при `INSERT` недоступен ZooKeeper, или происходит ошибка при взаимодействии с ним, будет выкинуто исключение. - -При подключении к ZooKeeper, система проверяет соответствие между имеющимся в локальной файловой системе набором данных и ожидаемым набором данных (информация о котором хранится в ZooKeeper). Если имеются небольшие несоответствия, то система устраняет их, синхронизируя данные с реплик. - -Обнаруженные битые куски данных (с файлами несоответствующего размера) или неизвестные куски (куски, записанные в файловую систему, но информация о которых не была записана в ZooKeeper) переносятся в поддиректорию detached (не удаляются). Недостающие куски скачиваются с реплик. - -Стоит заметить, что ClickHouse не делает самостоятельно никаких деструктивных действий типа автоматического удаления большого количества данных. - -При старте сервера (или создании новой сессии с ZooKeeper), проверяется только количество и размеры всех файлов. Если у файлов совпадают размеры, но изменены байты где-то посередине, то это обнаруживается не сразу, а только при попытке их прочитать при каком-либо запросе `SELECT`. Запрос кинет исключение о несоответствующей чексумме или размере сжатого блока. В этом случае, куски данных добавляются в очередь на проверку, и при необходимости, скачиваются с реплик. - -Если обнаруживается, что локальный набор данных слишком сильно отличается от ожидаемого, то срабатывает защитный механизм. Сервер сообщает об этом в лог и отказывается запускаться. Это сделано, так как такой случай может свидетельствовать об ошибке конфигурации - например, если реплика одного шарда была случайно сконфигурирована, как реплика другого шарда. Тем не менее, пороги защитного механизма поставлены довольно низкими, и такая ситуация может возникнуть и при обычном восстановлении после сбоя. В этом случае, восстановление делается полуавтоматически - «по кнопке». - -Для запуска восстановления, создайте в ZooKeeper узел `/path_to_table/replica_name/flags/force_restore_data` с любым содержимым или выполните команду для восстановления всех реплицируемых таблиц: - -``` bash -$ sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data -``` - -Затем запустите сервер. При старте, сервер удалит эти флаги и запустит восстановление. - -## Восстановление в случае потери всех данных {#vosstanovlenie-v-sluchae-poteri-vsekh-dannykh} - -Если на одном из серверов исчезли все данные и метаданные, восстановление делается следующим образом: - -1. Установите на сервер ClickHouse. Корректно пропишите подстановки в конфигурационном файле, отвечающие за идентификатор шарда и реплики, если вы их используете. -2. Если у вас были нереплицируемые таблицы, которые должны быть вручную продублированы на серверах, скопируйте их данные (в директории `/var/lib/clickhouse/data/db_name/table_name/`) с реплики. -3. Скопируйте с реплики определения таблиц, находящиеся в `/var/lib/clickhouse/metadata/`. Если в определениях таблиц, идентификатор шарда или реплики, прописаны в явном виде - исправьте их, чтобы они соответствовали данной реплике. (Альтернативный вариант - запустить сервер и сделать самостоятельно все запросы `ATTACH TABLE`, которые должны были бы быть в соответствующих .sql файлах в `/var/lib/clickhouse/metadata/`.) -4. Создайте в ZooKeeper узел `/path_to_table/replica_name/flags/force_restore_data` с любым содержимым или выполните команду для восстановления всех реплицируемых таблиц: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` - -Затем запустите сервер (перезапустите, если уже запущен). Данные будут скачаны с реплик. - -В качестве альтернативного варианта восстановления, вы можете удалить из ZooKeeper информацию о потерянной реплике (`/path_to_table/replica_name`), и затем создать реплику заново, как написано в разделе [Создание реплицированных таблиц](#creating-replicated-tables) . - -Отсутствует ограничение на использование сетевой полосы при восстановлении. Имейте это ввиду, если восстанавливаете сразу много реплик. - -## Преобразование из MergeTree в ReplicatedMergeTree {#preobrazovanie-iz-mergetree-v-replicatedmergetree} - -Здесь и далее, под `MergeTree` подразумеваются все движки таблиц семейства `MergeTree`, так же для `ReplicatedMergeTree`. - -Если у вас была таблица типа `MergeTree`, репликация которой делалась вручную, вы можете преобразовать её в реплицируемую таблицу. Это может понадобиться лишь в случаях, когда вы уже успели накопить большое количество данных в таблице типа `MergeTree`, а сейчас хотите включить репликацию. - -Если на разных репликах данные отличаются, то сначала синхронизируйте их, либо удалите эти данные на всех репликах кроме одной. - -Переименуйте имеющуюся MergeTree таблицу, затем создайте со старым именем таблицу типа `ReplicatedMergeTree`. -Перенесите данные из старой таблицы в поддиректорию detached в директории с данными новой таблицы (`/var/lib/clickhouse/data/db_name/table_name/`). -Затем добавьте эти куски данных в рабочий набор с помощью выполнения запросов `ALTER TABLE ATTACH PARTITION` на одной из реплик. - -## Преобразование из ReplicatedMergeTree в MergeTree {#preobrazovanie-iz-replicatedmergetree-v-mergetree} - -Создайте таблицу типа MergeTree с другим именем. Перенесите в её директорию с данными все данные из директории с данными таблицы типа `ReplicatedMergeTree`. Затем удалите таблицу типа `ReplicatedMergeTree` и перезапустите сервер. - -Если вы хотите избавиться от таблицы `ReplicatedMergeTree`, не запуская сервер, то - -- удалите соответствующий файл `.sql` в директории с метаданными (`/var/lib/clickhouse/metadata/`); -- удалите соответствующий путь в ZooKeeper (`/path_to_table/replica_name`); - -После этого, вы можете запустить сервер, создать таблицу типа `MergeTree`, перенести данные в её директорию, и перезапустить сервер. - -## Восстановление в случае потери или повреждения метаданных на ZooKeeper кластере {#vosstanovlenie-v-sluchae-poteri-ili-povrezhdeniia-metadannykh-na-zookeeper-klastere} - -Если данные в ZooKeeper оказались утеряны или повреждены, то вы можете сохранить данные, переместив их в нереплицируемую таблицу, как описано в пункте выше. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/replication/) diff --git a/docs/ru/engines/table_engines/mergetree_family/summingmergetree.md b/docs/ru/engines/table_engines/mergetree_family/summingmergetree.md deleted file mode 100644 index b69f58c3dac..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/summingmergetree.md +++ /dev/null @@ -1,134 +0,0 @@ -# SummingMergeTree {#summingmergetree} - -Движок наследует функциональность [MergeTree](mergetree.md#table_engines-mergetree). Отличие заключается в том, что для таблиц `SummingMergeTree` при слиянии кусков данных ClickHouse все строки с одинаковым первичным ключом (точнее, с одинаковым [ключом сортировки](mergetree.md)) заменяет на одну, которая хранит только суммы значений из столбцов с цифровым типом данных. Если ключ сортировки подобран таким образом, что одному значению ключа соответствует много строк, это значительно уменьшает объём хранения и ускоряет последующую выборку данных. - -Мы рекомендуем использовать движок в паре с `MergeTree`. В `MergeTree` храните полные данные, а `SummingMergeTree` используйте для хранения агрегированных данных, например, при подготовке отчетов. Такой подход позволит не утратить ценные данные из-за неправильно выбранного первичного ключа. - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = SummingMergeTree([columns]) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Описание параметров запроса смотрите в [описании запроса](../../../engines/table_engines/mergetree_family/summingmergetree.md). - -**Параметры SummingMergeTree** - -- `columns` — кортеж с именами столбцов, в которых будут суммироваться данные. Необязательный параметр. - Столбцы должны иметь числовой тип и не должны входить в первичный ключ. - - Если `columns` не задан, то ClickHouse суммирует значения во всех столбцах с числовым типом данных, не входящих в первичный ключ. - -**Секции запроса** - -При создании таблицы `SummingMergeTree` используются те же [секции](mergetree.md) запроса, что и при создании таблицы `MergeTree`. - -
- -Устаревший способ создания таблицы - -!!! attention "Attention" - Не используйте этот способ в новых проектах и по возможности переведите старые проекты на способ описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) -``` - -Все параметры, кроме `columns` имеют то же значение, что в и `MergeTree`. - -- `columns` — кортеж с именами столбцов для суммирования данных. Необязательный параметр. Описание смотрите выше по тексту. - -
- -## Пример использования {#primer-ispolzovaniia} - -Рассмотрим следующую таблицу: - -``` sql -CREATE TABLE summtt -( - key UInt32, - value UInt32 -) -ENGINE = SummingMergeTree() -ORDER BY key -``` - -Добавим в неё данные: - -``` sql -INSERT INTO summtt Values(1,1),(1,2),(2,1) -``` - -ClickHouse может не полностью просуммировать все строки ([смотрите ниже по тексту](#obrabotka-dannykh)), поэтому при запросе мы используем агрегатную функцию `sum` и секцию `GROUP BY`. - -``` sql -SELECT key, sum(value) FROM summtt GROUP BY key -``` - -``` text -┌─key─┬─sum(value)─┐ -│ 2 │ 1 │ -│ 1 │ 3 │ -└─────┴────────────┘ -``` - -## Обработка данных {#obrabotka-dannykh} - -При вставке данных в таблицу они сохраняются как есть. Периодически ClickHouse выполняет слияние вставленных кусков данных и именно в этот момент производится суммирование и замена многих строк с одинаковым первичным ключом на одну для каждого результирующего куска данных. - -ClickHouse может слить куски данных таким образом, что не все строки с одинаковым первичным ключом окажутся в одном финальном куске, т.е. суммирование будет не полным. Поэтому, при выборке данных (`SELECT`) необходимо использовать агрегатную функцию [sum()](../../../engines/table_engines/mergetree_family/summingmergetree.md#agg_function-sum) и секцию `GROUP BY` как описано в примере выше. - -### Общие правила суммирования {#obshchie-pravila-summirovaniia} - -Суммируются значения в столбцах с числовым типом данных. Набор столбцов определяется параметром `columns`. - -Если значения во всех столбцах для суммирования оказались нулевыми, то строчка удаляется. - -Для столбцов, не входящих в первичный ключ и не суммирующихся, выбирается произвольное значение из имеющихся. - -Значения для столбцов, входящих в первичный ключ, не суммируются. - -### Суммирование в столбцах AggregateFunction {#summirovanie-v-stolbtsakh-aggregatefunction} - -Для столбцов типа [AggregateFunction](../../../engines/table_engines/mergetree_family/summingmergetree.md#data_type-aggregatefunction) ClickHouse выполняет агрегацию согласно заданной функции, повторяя поведение движка [AggregatingMergeTree](aggregatingmergetree.md). - -### Вложенные структуры {#vlozhennye-struktury} - -Таблица может иметь вложенные структуры данных, которые обрабатываются особым образом. - -Если название вложенной таблицы заканчивается на `Map` и она содержит не менее двух столбцов, удовлетворяющих критериям: - -- первый столбец - числовой `(*Int*, Date, DateTime)`, назовем его условно `key`, -- остальные столбцы - арифметические `(*Int*, Float32/64)`, условно `(values...)`, - -то вложенная таблица воспринимается как отображение `key => (values...)` и при слиянии её строк выполняется слияние элементов двух множеств по `key` со сложением соответствующих `(values...)`. - -Примеры: - -``` text -[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] -[(1, 100)] + [(1, 150)] -> [(1, 250)] -[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] -[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] -``` - -При запросе данных используйте функцию [sumMap(key, value)](../../../engines/table_engines/mergetree_family/summingmergetree.md) для агрегации `Map`. - -Для вложенной структуры данных не нужно указывать её столбцы в кортеже столбцов для суммирования. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/summingmergetree/) diff --git a/docs/ru/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md b/docs/ru/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md deleted file mode 100644 index 90647edd0eb..00000000000 --- a/docs/ru/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md +++ /dev/null @@ -1,231 +0,0 @@ -# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} - -Движок: - -- Позволяет быстро записывать постоянно изменяющиеся состояния объектов. -- Удаляет старые состояния объектов в фоновом режиме. Это значительно сокращает объём хранения. - -Подробнее читайте в разделе [Collapsing](#table_engines_versionedcollapsingmergetree). - -Движок наследует функциональность от [MergeTree](mergetree.md#table_engines-mergetree) и добавляет в алгоритм слияния кусков данных логику сворачивания (удаления) строк. `VersionedCollapsingMergeTree` предназначен для тех же задач, что и [CollapsingMergeTree](collapsingmergetree.md), но использует другой алгоритм свёртывания, который позволяет вставлять данные в любом порядке в несколько потоков. В частности, столбец `Version` помогает свернуть строки правильно, даже если они вставлены в неправильном порядке. `CollapsingMergeTree` требует строго последовательную вставку данных. - -## Создание таблицы {#sozdanie-tablitsy} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = VersionedCollapsingMergeTree(sign, version) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Подробности про `CREATE TABLE` смотрите в [описании запроса](../../../engines/table_engines/mergetree_family/versionedcollapsingmergetree.md). - -**Параметры движка** - -``` sql -VersionedCollapsingMergeTree(sign, version) -``` - -- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. - - Тип данных столбца должен быть `Int8`. - -- `version` — имя столбца с версией состояния объекта. - - Тип данных столбца должен быть `UInt*`. - -**Секции запроса** - -При создании таблицы `VersionedСollapsingMergeTree` используются те же [секции](mergetree.md) запроса, что и при создании таблицы `MergeTree` . - -
- -Устаревший способ создания таблицы - -!!! warning "Внимание" - Не используйте этот метод в новых проектах. По возможности переключите старые проекты на метод, описанный выше. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] VersionedCollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign, version) -``` - -Все параметры, за исключением `sign` и `version` имеют то же значение, что и в `MergeTree`. - -- `sign` — Имя столбца с типом строки: `1` — строка состояния, `-1` — строка отмены состояния. - - Тип данных столбца — `Int8`. - -- `version` — имя столбца с версией состояния объекта. - - Тип данных столбца должен быть `UInt*`. - -
- -## Сворачивание (удаление) строк {#table_engines-versionedcollapsingmergetree} - -### Данные {#dannye} - -Рассмотрим ситуацию, когда необходимо сохранять постоянно изменяющиеся данные для какого-либо объекта. Разумно иметь одну строку для объекта и обновлять эту строку при каждом изменении. Однако операция обновления является дорогостоящей и медленной для СУБД, поскольку требует перезаписи данных в хранилище. Обновление неприемлемо, если требуется быстро записывать данные, но можно записывать изменения в объект последовательно следующим образом. - -Используйте столбец `Sign` при записи строки. Если `Sign = 1`, то это означает, что строка является состоянием объекта, назовём её строкой состояния. Если `Sign = -1`, то это означает отмену состояния объекта с теми же атрибутами, назовём её строкой отмены состояния. Также используйте столбец `Version`, который должен идентифицировать каждое состояние объекта отдельным номером. - -Например, мы хотим рассчитать, сколько страниц пользователи посетили на каком-либо сайте и как долго они там находились. В какой-то момент времени мы записываем следующую строку состояния пользовательской активности: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Через некоторое время мы регистрируем изменение активности пользователя и записываем его следующими двумя строками. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Первая строка отменяет предыдущее состояние объекта (пользователя). Она должна копировать все поля отменяемого состояния за исключением `Sign`. - -Вторая строка содержит текущее состояние. - -Поскольку нам нужно только последнее состояние активности пользователя, строки - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -можно удалить, сворачивая (удаляя) устаревшее состояние объекта. `VersionedCollapsingMergeTree` делает это при слиянии кусков данных. - -Чтобы узнать, зачем нам нужны две строки для каждого изменения, см. раздел [Алгоритм](#table_engines-versionedcollapsingmergetree-algorithm). - -**Примечания по использованию** - -1. Программа, которая записывает данные, должна помнить состояние объекта, чтобы иметь возможность отменить его. Строка отмены состояния должна быть копией предыдущей строки состояния с противоположным значением `Sign`. Это увеличивает начальный размер хранилища, но позволяет быстро записывать данные. -2. Длинные растущие массивы в столбцах снижают эффективность работы движка за счёт нагрузки на запись. Чем проще данные, тем выше эффективность. -3. `SELECT` результаты сильно зависят от согласованности истории изменений объекта. Будьте точны при подготовке данных для вставки. Вы можете получить непредсказуемые результаты с несогласованными данными, такими как отрицательные значения для неотрицательных метрик, таких как глубина сеанса. - -### Алгоритм {#table_engines-versionedcollapsingmergetree-algorithm} - -Когда ClickHouse объединяет куски данных, он удаляет каждую пару строк, которые имеют один и тот же первичный ключ и версию и разный `Sign`. Порядок строк не имеет значения. - -Когда ClickHouse вставляет данные, он упорядочивает строки по первичному ключу. Если столбец `Version` не находится в первичном ключе, ClickHouse добавляет его к первичному ключу неявно как последнее поле и использует для сортировки. - -## Выборка данных {#vyborka-dannykh} - -ClickHouse не гарантирует, что все строки с одинаковым первичным ключом будут находиться в одном результирующем куске данных или даже на одном физическом сервере. Это справедливо как для записи данных, так и для последующего слияния кусков данных. Кроме того, ClickHouse обрабатывает запросы `SELECT` несколькими потоками, и не может предсказать порядок строк в конечной выборке. Это означает, что если необходимо получить полностью «свернутые» данные из таблицы `VersionedCollapsingMergeTree`, то требуется агрегирование. - -Для завершения свертывания добавьте в запрос секцию `GROUP BY` и агрегатные функции, которые учитывают знак. Например, для расчета количества используйте `sum(Sign)` вместо`count()`. Чтобы вычислить сумму чего-либо, используйте `sum(Sign * x)` вместо`sum(х)`, а также добавьте `HAVING sum(Sign) > 0` . - -Таким образом можно вычислять агрегации `count`, `sum` и `avg`. Агрегация `uniq` может вычисляться, если объект имеет хотя бы одно не свернутое состояние. Невозможно вычислить агрегации `min` и `max` поскольку`VersionedCollapsingMergeTree` не сохраняет историю значений для свернутых состояний. - -Если необходимо выбирать данные без агрегации (например, проверить наличие строк, последние значения которых удовлетворяют некоторым условиям), можно использовать модификатор `FINAL` для секции `FROM`. Такой подход неэффективен и не должен использоваться с большими таблицами. - -## Пример использования {#primer-ispolzovaniia} - -Данные для примера: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Создание таблицы: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8, - Version UInt8 -) -ENGINE = VersionedCollapsingMergeTree(Sign, Version) -ORDER BY UserID -``` - -Вставка данных: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) -``` - -Мы используем два запроса `INSERT` для создания двух различных кусков данных. Если мы вставляем данные с помощью одного запроса, ClickHouse создаёт один кусок данных и не будет выполнять слияние. - -Получение данных: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Что мы видим и где сворачивание? -Мы создали два куска данных, используя два запроса `INSERT`. Запрос `SELECT` был выполнен в два потока, и результатом является случайный порядок строк. -Свертывание не произошло, поскольку части данных еще не были объединены. ClickHouse объединяет части данных в неизвестный момент времени, который мы не можем предсказать. - -Поэтому нам нужна агрегация: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration, - Version -FROM UAct -GROUP BY UserID, Version -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 2 │ -└─────────────────────┴───────────┴──────────┴─────────┘ -``` - -Если нам не нужна агрегация, но мы хотим принудительно выполнить свёртку данных, то можно использовать модификатор `FINAL` для секции `FROM`. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Это очень неэффективный способ выбора данных. Не используйте его для больших таблиц. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/ru/engines/table_engines/special/dictionary.md b/docs/ru/engines/table_engines/special/dictionary.md deleted file mode 100644 index fac22b5d2f2..00000000000 --- a/docs/ru/engines/table_engines/special/dictionary.md +++ /dev/null @@ -1,88 +0,0 @@ -# Dictionary {#dictionary} - -Движок `Dictionary` отображает данные [словаря](../../../engines/table_engines/special/dictionary.md) как таблицу ClickHouse. - -Рассмотрим для примера словарь `products` со следующей конфигурацией: - -``` xml - - - products - - -
products
- DSN=some-db-server - - - - 300 - 360 - - - - - - - product_id - - - title - String - - - - - -``` - -Запрос данных словаря: - -``` sql -SELECT - name, - type, - key, - attribute.names, - attribute.types, - bytes_allocated, - element_count, - source -FROM system.dictionaries -WHERE name = 'products' -``` - -``` text -┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ -│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ -└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ -``` - -В таком виде данные из словаря можно получить при помощи функций [dictGet\*](../../../engines/table_engines/special/dictionary.md#ext_dict_functions). - -Такое представление неудобно, когда нам необходимо получить данные в чистом виде, а также при выполнении операции `JOIN`. Для этих случаев можно использовать движок `Dictionary`, который отобразит данные словаря в таблицу. - -Синтаксис: - -``` sql -CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` -``` - -Пример использования: - -``` sql -create table products (product_id UInt64, title String) Engine = Dictionary(products); -``` - -Проверим что у нас в таблице? - -``` sql -select * from products limit 1; -``` - -``` text -┌────product_id─┬─title───────────┐ -│ 152689 │ Some item │ -└───────────────┴─────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/dictionary/) diff --git a/docs/ru/engines/table_engines/special/distributed.md b/docs/ru/engines/table_engines/special/distributed.md deleted file mode 100644 index 9fc7b470f1d..00000000000 --- a/docs/ru/engines/table_engines/special/distributed.md +++ /dev/null @@ -1,116 +0,0 @@ -# Distributed {#distributed} - -**Движок Distributed не хранит данные самостоятельно**, а позволяет обрабатывать запросы распределённо, на нескольких серверах. -Чтение автоматически распараллеливается. При чтении будут использованы индексы таблиц на удалённых серверах, если есть. -Движок Distributed принимает параметры: имя кластера в конфигурационном файле сервера, имя удалённой базы данных, имя удалённой таблицы, а также (не обязательно) ключ шардирования. -Пример: - -``` sql -Distributed(logs, default, hits[, sharding_key]) -``` - -данные будут читаться со всех серверов кластера logs, из таблицы default.hits, расположенной на каждом сервере кластера. -Данные не только читаются, но и частично (настолько, насколько это возможно) обрабатываются на удалённых серверах. -Например, при запросе с GROUP BY, данные будут агрегированы на удалённых серверах, промежуточные состояния агрегатных функций будут отправлены на запросивший сервер; затем данные будут доагрегированы. - -Вместо имени базы данных может использоваться константное выражение, возвращающее строку. Например, currentDatabase(). - -logs - имя кластера в конфигурационном файле сервера. - -Кластеры задаются следующим образом: - -``` xml - - - - - 1 - - false - - example01-01-1 - 9000 - - - example01-01-2 - 9000 - - - - 2 - false - - example01-02-1 - 9000 - - - example01-02-2 - 9000 - - - - -``` - -Здесь задан кластер с именем logs, состоящий из двух шардов, каждый из которых состоит из двух реплик. -Шардами называются серверы, содержащие разные части данных (чтобы прочитать все данные, нужно идти на все шарды). -Репликами называются дублирующие серверы (чтобы прочитать данные, можно идти за данными на любую из реплик). - -Имя кластера не должно содержать точки. - -В качестве параметров для каждого сервера указываются `host`, `port` и, не обязательно, `user`, `password`, `secure`, `compression`: -- `host` - адрес удалённого сервера. Может быть указан домен, или IPv4 или IPv6 адрес. В случае указания домена, при старте сервера делается DNS запрос, и результат запоминается на всё время работы сервера. Если DNS запрос неуспешен, то сервер не запускается. Если вы изменяете DNS-запись, перезапустите сервер. -- `port` - TCP-порт для межсерверного взаимодействия (в конфиге - tcp\_port, обычно 9000). Не перепутайте с http\_port. -- `user` - имя пользователя для соединения с удалённым сервером. по умолчанию - default. Этот пользователь должен иметь доступ для соединения с указанным сервером. Доступы настраиваются в файле users.xml, подробнее смотрите в разделе [Права доступа](../../../operations/access_rights.md). -- `password` - пароль для соединения с удалённым сервером, в открытом виде. по умолчанию - пустая строка. -- `secure` - Использовать шифрованное соединение ssl, Обычно используется с портом `port` = 9440. Сервер должен слушать порт 9440 с корректными настройками сертификатов. -- `compression` - Использовать сжатие данных. По умолчанию: true. - -При указании реплик, для каждого из шардов, при чтении, будет выбрана одна из доступных реплик. Можно настроить алгоритм балансировки нагрузки (то есть, предпочтения, на какую из реплик идти) - см. настройку [load\_balancing](../../../operations/settings/settings.md#settings-load_balancing). -Если соединение с сервером не установлено, то будет произведена попытка соединения с небольшим таймаутом. Если соединиться не удалось, то будет выбрана следующая реплика, и так для всех реплик. Если попытка соединения для всех реплик не удалась, то будут снова произведены попытки соединения по кругу, и так несколько раз. -Это работает в пользу отказоустойчивости, хотя и не обеспечивает полную отказоустойчивость: удалённый сервер может принять соединение, но не работать, или плохо работать. - -Можно указать от одного шарда (в таком случае, обработку запроса стоит называть удалённой, а не распределённой) до произвольного количества шардов. В каждом шарде можно указать от одной до произвольного числа реплик. Можно указать разное число реплик для каждого шарда. - -Вы можете прописать сколько угодно кластеров в конфигурации. - -Для просмотра имеющихся кластеров, вы можете использовать системную таблицу system.clusters. - -Движок Distributed позволяет работать с кластером, как с локальным сервером. При этом, кластер является неэластичным: вы должны прописать его конфигурацию в конфигурационный файл сервера (лучше всех серверов кластера). - -Как видно, движок Distributed требует прописывания кластера в конфигурационный файл; кластера из конфигурационного файла обновляются налету, без перезапуска сервера. Если вам необходимо каждый раз отправлять запрос на неизвестный набор шардов и реплик, вы можете не создавать Distributed таблицу, а воспользоваться табличной функцией remote. Смотрите раздел [Табличные функции](../../../engines/table_engines/special/distributed.md). - -Есть два способа записывать данные на кластер: - -Во-первых, вы можете самостоятельно определять, на какие серверы какие данные записывать, и выполнять запись непосредственно на каждый шард. То есть, делать INSERT в те таблицы, на которые «смотрит» распределённая таблица. Это наиболее гибкое решение поскольку вы можете использовать любую схему шардирования, которая может быть нетривиальной из-за требований предметной области. -Также это является наиболее оптимальным решением, так как данные могут записываться на разные шарды полностью независимо. - -Во-вторых, вы можете делать INSERT в Distributed таблицу. В этом случае, таблица будет сама распределять вставляемые данные по серверам. Для того, чтобы писать в Distributed таблицу, у неё должен быть задан ключ шардирования (последний параметр). Также, если шард всего-лишь один, то запись работает и без указания ключа шардирования (так как в этом случае он не имеет смысла). - -У каждого шарда в конфигурационном файле может быть задан «вес» (weight). По умолчанию, вес равен единице. Данные будут распределяться по шардам в количестве, пропорциональном весу шарда. Например, если есть два шарда, и у первого выставлен вес 9, а у второго 10, то на первый будет отправляться 9 / 19 доля строк, а на второй - 10 / 19. - -У каждого шарда в конфигурационном файле может быть указан параметр internal\_replication. - -Если он выставлен в true, то для записи будет выбираться первая живая реплика и данные будут писаться на неё. Этот вариант следует использовать, если Distributed таблица «смотрит» на реплицируемые таблицы. То есть, если таблица, в которую будут записаны данные, будет сама заниматься их репликацией. - -Если он выставлен в false (по умолчанию), то данные будут записываться на все реплики. По сути, это означает, что Distributed таблица занимается репликацией данных самостоятельно. Это хуже, чем использование реплицируемых таблиц, так как не контролируется консистентность реплик, и они со временем будут содержать немного разные данные. - -Для выбора шарда, на который отправляется строка данных, вычисляется выражение шардирования, и берётся его остаток от деления на суммарный вес шардов. Строка отправляется на шард, соответствующий полуинтервалу остатков от prev\_weights до prev\_weights + weight, где prev\_weights - сумма весов шардов с меньшим номером, а weight - вес этого шарда. Например, если есть два шарда, и у первого выставлен вес 9, а у второго 10, то строка будет отправляться на первый шард для остатков из диапазона \[0, 9), а на второй - для остатков из диапазона \[9, 19). - -Выражением шардирование может быть произвольное выражение от констант и столбцов таблицы, возвращающее целое число. Например, вы можете использовать выражение rand() для случайного распределения данных, или UserID - для распределения по остатку от деления идентификатора посетителя (тогда данные одного посетителя будут расположены на одном шарде, что упростит выполнение IN и JOIN по посетителям). Если распределение какого-либо столбца недостаточно равномерное, вы можете обернуть его в хэш функцию: intHash64(UserID). - -Простой остаток от деления является довольно ограниченным решением для шардирования и подходит не для всех случаев. Он подходит для среднего и большого объёма данных (десятки серверов), но не для очень больших объёмов данных (сотни серверов и больше). В последнем случае, лучше использовать схему шардирования, продиктованную требованиями предметной области, и не использовать возможность записи в Distributed таблицы. - -Запросы SELECT отправляются на все шарды, и работают независимо от того, каким образом данные распределены по шардам (они могут быть распределены полностью случайно). При добавлении нового шарда, можно не переносить на него старые данные, а записывать новые данные с большим весом - данные будут распределены слегка неравномерно, но запросы будут работать корректно и достаточно эффективно. - -Беспокоиться о схеме шардирования имеет смысл в следующих случаях: -- используются запросы, требующие соединение данных (IN, JOIN) по определённому ключу - тогда если данные шардированы по этому ключу, то можно использовать локальные IN, JOIN вместо GLOBAL IN, GLOBAL JOIN, что кардинально более эффективно. -- используется большое количество серверов (сотни и больше) и большое количество маленьких запросов (запросы отдельных клиентов - сайтов, рекламодателей, партнёров) - тогда, для того, чтобы маленькие запросы не затрагивали весь кластер, имеет смысл располагать данные одного клиента на одном шарде, или (вариант, который используется в Яндекс.Метрике) сделать двухуровневое шардирование: разбить весь кластер на «слои», где слой может состоять из нескольких шардов; данные для одного клиента располагаются на одном слое, но в один слой можно по мере необходимости добавлять шарды, в рамках которых данные распределены произвольным образом; создаются распределённые таблицы на каждый слой и одна общая распределённая таблица для глобальных запросов. - -Запись данных осуществляется полностью асинхронно. При вставке в таблицу, блок данных сначала записывается в файловую систему. Затем, в фоновом режиме отправляются на удалённые серверы при первой возможности. Период отправки регулируется настройками [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) и [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms). Движок таблиц `Distributed` отправляет каждый файл со вставленными данными отдельно, но можно включить пакетную отправку данных настройкой [distributed\_directory\_monitor\_batch\_inserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts). Эта настройка улучшает производительность кластера за счет более оптимального использования ресурсов сервера-отправителя и сети. Необходимо проверять, что данные отправлены успешно, для этого проверьте список файлов (данных, ожидающих отправки) в каталоге таблицы `/var/lib/clickhouse/data/database/table/`. - -Если после INSERT-а в Distributed таблицу, сервер перестал существовать или был грубо перезапущен (например, в следствие аппаратного сбоя), то записанные данные могут быть потеряны. Если в директории таблицы обнаружен повреждённый кусок данных, то он переносится в поддиректорию broken и больше не используется. - -При выставлении опции max\_parallel\_replicas выполнение запроса распараллеливается по всем репликам внутри одного шарда. Подробнее смотрите раздел [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/distributed/) diff --git a/docs/ru/engines/table_engines/special/file.md b/docs/ru/engines/table_engines/special/file.md deleted file mode 100644 index 138c2e47b89..00000000000 --- a/docs/ru/engines/table_engines/special/file.md +++ /dev/null @@ -1,79 +0,0 @@ -# File(Format) {#table_engines-file} - -Управляет данными в одном файле на диске в указанном формате. - -Примеры применения: - -- Выгрузка данных из ClickHouse в файл. -- Преобразование данных из одного формата в другой. -- Обновление данных в ClickHouse редактированием файла на диске. - -## Использование движка в сервере ClickHouse {#ispolzovanie-dvizhka-v-servere-clickhouse} - -``` sql -File(Format) -``` - -`Format` должен быть таким, который ClickHouse может использовать и в запросах `INSERT` и в запросах `SELECT`. Полный список поддерживаемых форматов смотрите в разделе [Форматы](../../../interfaces/formats.md#formats). - -Сервер ClickHouse не позволяет указать путь к файлу, с которым будет работать `File`. Используется путь к хранилищу, определенный параметром [path](../../../operations/server_configuration_parameters/settings.md) в конфигурации сервера. - -При создании таблицы с помощью `File(Format)` сервер ClickHouse создает в хранилище каталог с именем таблицы, а после добавления в таблицу данных помещает туда файл `data.Format`. - -Можно вручную создать в хранилище каталог таблицы, поместить туда файл, затем на сервере ClickHouse добавить ([ATTACH](../../../engines/table_engines/special/file.md)) информацию о таблице, соответствующей имени каталога и прочитать из файла данные. - -!!! warning "Warning" - Будьте аккуратны с этой функциональностью, поскольку сервер ClickHouse не отслеживает внешние изменения данных. Если в файл будет производиться запись одновременно со стороны сервера ClickHouse и с внешней стороны, то результат непредсказуем. - -**Пример:** - -**1.** Создадим на сервере таблицу `file_engine_table`: - -``` sql -CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) -``` - -В конфигурации по умолчанию сервер ClickHouse создаст каталог `/var/lib/clickhouse/data/default/file_engine_table`. - -**2.** Вручную создадим файл `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` с содержимым: - -``` bash -$cat data.TabSeparated -one 1 -two 2 -``` - -**3.** Запросим данные: - -``` sql -SELECT * FROM file_engine_table -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Использование движка в clickhouse-local {#ispolzovanie-dvizhka-v-clickhouse-local} - -В [clickhouse-local](../../../engines/table_engines/special/file.md) движок в качестве параметра принимает не только формат, но и путь к файлу. В том числе можно указать стандартные потоки ввода/вывода цифровым или буквенным обозначением `0` или `stdin`, `1` или `stdout`. - -**Пример:** - -``` bash -$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" -``` - -## Детали реализации {#detali-realizatsii} - -- Поддерживается одновременное выполнение множества запросов `SELECT`, запросы `INSERT` могут выполняться только последовательно. -- Поддерживается создание ещё не существующего файла при запросе `INSERT`. -- Для существующих файлов `INSERT` записывает в конец файла. -- Не поддерживается: - - использование операций `ALTER` и `SELECT...SAMPLE`; - - индексы; - - репликация. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/file/) diff --git a/docs/ru/engines/table_engines/special/generate.md b/docs/ru/engines/table_engines/special/generate.md deleted file mode 120000 index 566dc4e5382..00000000000 --- a/docs/ru/engines/table_engines/special/generate.md +++ /dev/null @@ -1 +0,0 @@ -../../../../en/engines/table_engines/special/generate.md \ No newline at end of file diff --git a/docs/ru/engines/table_engines/special/index.md b/docs/ru/engines/table_engines/special/index.md deleted file mode 100644 index 22cebf295c1..00000000000 --- a/docs/ru/engines/table_engines/special/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Special -toc_priority: 31 ---- - diff --git a/docs/ru/engines/table_engines/special/join.md b/docs/ru/engines/table_engines/special/join.md deleted file mode 100644 index 0ca53f34acb..00000000000 --- a/docs/ru/engines/table_engines/special/join.md +++ /dev/null @@ -1,104 +0,0 @@ -# Join {#join} - -Подготовленная структура данных для использования в операциях [JOIN](../../../engines/table_engines/special/join.md#select-join). - -## Создание таблицы {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], -) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) -``` - -Смотрите подробное описание запроса [CREATE TABLE](../../../engines/table_engines/special/join.md#create-table-query). - -**Параметры движка** - -- `join_strictness` – [строгость JOIN](../../../engines/table_engines/special/join.md#select-join-strictness). -- `join_type` – [тип JOIN](../../../engines/table_engines/special/join.md#select-join-types). -- `k1[, k2, ...]` – ключевые столбцы секции `USING` с которыми выполняется операция `JOIN`. - -Вводите параметры `join_strictness` и `join_type` без кавычек, например, `Join(ANY, LEFT, col1)`. Они должны быть такими же как и в той операции `JOIN`, в которой таблица будет использоваться. Если параметры не совпадают, ClickHouse не генерирует исключение и может возвращать неверные данные. - -## Использование таблицы {#ispolzovanie-tablitsy} - -### Пример {#primer} - -Создание левой таблицы: - -``` sql -CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog -``` - -``` sql -INSERT INTO id_val VALUES (1,11)(2,12)(3,13) -``` - -Создание правой таблицы с движком `Join`: - -``` sql -CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) -``` - -``` sql -INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) -``` - -Объединение таблиц: - -``` sql -SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 -``` - -``` text -┌─id─┬─val─┬─id_val_join.val─┐ -│ 1 │ 11 │ 21 │ -│ 2 │ 12 │ ᴺᵁᴸᴸ │ -│ 3 │ 13 │ 23 │ -└────┴─────┴─────────────────┘ -``` - -В качестве альтернативы, можно извлечь данные из таблицы `Join`, указав значение ключа объединения: - -``` sql -SELECT joinGet('id_val_join', 'val', toUInt32(1)) -``` - -``` text -┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ -│ 21 │ -└────────────────────────────────────────────┘ -``` - -### Выборка и вставка данных {#vyborka-i-vstavka-dannykh} - -Для добавления данных в таблицы с движком `Join` используйте запрос `INSERT`. Если таблица создавалась со строгостью `ANY`, то данные с повторяющимися ключами игнорируются. Если задавалась строгость `ALL`, то добавляются все строки. - -Из таблиц нельзя выбрать данные с помощью запроса `SELECT`. Вместо этого, используйте один из следующих методов: - -- Используйте таблицу как правую в секции `JOIN`. -- Используйте функцию [joinGet](../../../engines/table_engines/special/join.md#joinget), которая позволяет извлекать данные из таблицы таким же образом как из словаря. - -### Ограничения и настройки {#join-limitations-and-settings} - -При создании таблицы, применяются следующие параметры : - -- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) -- [max\_rows\_in\_join](../../../operations/settings/query_complexity.md#settings-max_rows_in_join) -- [max\_bytes\_in\_join](../../../operations/settings/query_complexity.md#settings-max_bytes_in_join) -- [join\_overflow\_mode](../../../operations/settings/query_complexity.md#settings-join_overflow_mode) -- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) - -Таблицы с движком `Join` нельзя использовать в операциях `GLOBAL JOIN`. - -Движок `Join` позволяет использовать параметр [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) в запросе `CREATE TABLE`, который также можно использовать в запросе [SELECT](../../../engines/table_engines/special/join.md). Если у вас разные настройки `join_use_nulls`, вы можете получить сообщение об ошибке при объединении таблиц. Это зависит от типа соединения. Когда вы используете функцию [joinGet](../../../engines/table_engines/special/join.md#joinget), вам необходимо использовать один и тот же параметр `join_use_nulls` в запросах `CRATE TABLE` и `SELECT`. - -## Хранение данных {#khranenie-dannykh} - -Данные таблиц `Join` всегда находятся в RAM. При вставке строк в таблицу ClickHouse записывает блоки данных в каталог на диске, чтобы их можно было восстановить при перезапуске сервера. - -При аварийном перезапуске сервера блок данных на диске может быть потерян или повреждён. В последнем случае, может потребоваться вручную удалить файл с повреждёнными данными. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/join/) diff --git a/docs/ru/engines/table_engines/special/materializedview.md b/docs/ru/engines/table_engines/special/materializedview.md deleted file mode 100644 index 2adcdb8df70..00000000000 --- a/docs/ru/engines/table_engines/special/materializedview.md +++ /dev/null @@ -1,5 +0,0 @@ -# MaterializedView {#materializedview} - -Используется для реализации материализованных представлений (подробнее см. запрос [CREATE TABLE](../../../engines/table_engines/special/materializedview.md)). Для хранения данных, использует другой движок, который был указан при создании представления. При чтении из таблицы, просто использует этот движок. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/materializedview/) diff --git a/docs/ru/engines/table_engines/special/merge.md b/docs/ru/engines/table_engines/special/merge.md deleted file mode 100644 index 65dd8dc7a2c..00000000000 --- a/docs/ru/engines/table_engines/special/merge.md +++ /dev/null @@ -1,63 +0,0 @@ -# Merge {#merge} - -Движок `Merge` (не путайте с движком `MergeTree`) не хранит данные самостоятельно, а позволяет читать одновременно из произвольного количества других таблиц. -Чтение автоматически распараллеливается. Запись в таблицу не поддерживается. При чтении будут использованы индексы тех таблиц, из которых реально идёт чтение, если они существуют. -Движок `Merge` принимает параметры: имя базы данных и регулярное выражение для таблиц. - -Пример: - -``` sql -Merge(hits, '^WatchLog') -``` - -Данные будут читаться из таблиц в базе `hits`, имена которых соответствуют регулярному выражению ‘`^WatchLog`’. - -Вместо имени базы данных может использоваться константное выражение, возвращающее строку. Например, `currentDatabase()`. - -Регулярные выражения — [re2](https://github.com/google/re2) (поддерживает подмножество PCRE), регистрозависимые. -Смотрите замечание об экранировании в регулярных выражениях в разделе «match». - -При выборе таблиц для чтения, сама `Merge`-таблица не будет выбрана, даже если попадает под регулярное выражение, чтобы не возникло циклов. -Впрочем, вы можете создать две `Merge`-таблицы, которые будут пытаться бесконечно читать данные друг друга, но делать этого не нужно. - -Типичный способ использования движка `Merge` — работа с большим количеством таблиц типа `TinyLog`, как с одной. - -Пример 2: - -Пусть есть старая таблица `WatchLog_old`. Необходимо изменить партиционирование без перемещения данных в новую таблицу `WatchLog_new`. При этом в выборке должны участвовать данные обеих таблиц. - -``` sql -CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree(date, (UserId, EventType), 8192); -INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); - -CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; -INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); - -CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); - -SELECT * -FROM WatchLog -``` - -``` text -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-01 │ 1 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-02 │ 2 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -``` - -## Виртуальные столбцы {#virtualnye-stolbtsy} - -- `_table` — содержит имя таблицы, из которой данные были прочитаны. Тип — [String](../../../engines/table_engines/special/merge.md). - - В секции `WHERE/PREWHERE` можно установить константное условие на столбец `_table` (например, `WHERE _table='xyz'`). В этом случае операции чтения выполняются только для тех таблиц, для которых выполняется условие на значение `_table`, таким образом, столбец `_table` работает как индекс. - -**Смотрите также** - -- [Виртуальные столбцы](index.md#table_engines-virtual_columns) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/merge/) diff --git a/docs/ru/engines/table_engines/special/view.md b/docs/ru/engines/table_engines/special/view.md deleted file mode 100644 index dc8957326fd..00000000000 --- a/docs/ru/engines/table_engines/special/view.md +++ /dev/null @@ -1,5 +0,0 @@ -# View {#view} - -Используется для реализации представлений (подробнее см. запрос `CREATE VIEW`). Не хранит данные, а хранит только указанный запрос `SELECT`. При чтении из таблицы, выполняет его (с удалением из запроса всех ненужных столбцов). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/table_engines/view/) diff --git a/docs/ru/faq/general.md b/docs/ru/faq/general.md index 5bfe8ea8f2d..4862a069b95 100644 --- a/docs/ru/faq/general.md +++ b/docs/ru/faq/general.md @@ -25,7 +25,7 @@ NLS_LANG=RUSSIAN_RUSSIA.UTF8 ### Секция INTO OUTFILE {#sektsiia-into-outfile} -Добавьте секцию [INTO OUTFILE](../sql_reference/statements/select.md#into-outfile-clause) к своему запросу. +Добавьте секцию [INTO OUTFILE](../sql-reference/statements/select/into-outfile.md#into-outfile-clause) к своему запросу. Например: @@ -33,7 +33,7 @@ NLS_LANG=RUSSIAN_RUSSIA.UTF8 SELECT * FROM table INTO OUTFILE 'file' ``` -По умолчанию, для выдачи данных ClickHouse использует формат [TabSeparated](../interfaces/formats.md#tabseparated). Чтобы выбрать [формат данных](../interfaces/formats.md), используйте [секцию FORMAT](../sql_reference/statements/select.md#format-clause). +По умолчанию, для выдачи данных ClickHouse использует формат [TabSeparated](../interfaces/formats.md#tabseparated). Чтобы выбрать [формат данных](../interfaces/formats.md), используйте [секцию FORMAT](../sql-reference/statements/select/format.md#format-clause). Например: @@ -43,7 +43,7 @@ SELECT * FROM table INTO OUTFILE 'file' FORMAT CSV ### Таблица с движком File {#tablitsa-s-dvizhkom-file} -Смотрите [File](../engines/table_engines/special/file.md). +Смотрите [File](../engines/table-engines/special/file.md). ### Перенаправление в командой строке {#perenapravlenie-v-komandoi-stroke} diff --git a/docs/ru/getting_started/example_datasets/amplab_benchmark.md b/docs/ru/getting-started/example-datasets/amplab-benchmark.md similarity index 100% rename from docs/ru/getting_started/example_datasets/amplab_benchmark.md rename to docs/ru/getting-started/example-datasets/amplab-benchmark.md diff --git a/docs/ru/getting_started/example_datasets/criteo.md b/docs/ru/getting-started/example-datasets/criteo.md similarity index 100% rename from docs/ru/getting_started/example_datasets/criteo.md rename to docs/ru/getting-started/example-datasets/criteo.md diff --git a/docs/ru/getting-started/example-datasets/index.md b/docs/ru/getting-started/example-datasets/index.md new file mode 100644 index 00000000000..c349e369b1d --- /dev/null +++ b/docs/ru/getting-started/example-datasets/index.md @@ -0,0 +1,21 @@ +--- +toc_folder_title: "\u0422\u0435\u0441\u0442\u043E\u0432\u044B\u0435 \u043C\u0430\u0441\ + \u0441\u0438\u0432\u044B \u0434\u0430\u043D\u043D\u044B\u0445" +toc_priority: 12 +toc_title: "\u041E\u0431\u0437\u043E\u0440" +--- + +# Тестовые массивы данных {#testovye-massivy-dannykh} + +Этот раздел описывает как получить тестовые массивы данных и загрузить их в ClickHouse. +Для некоторых тестовых массивов данных также доступны тестовые запросы. + +- [Анонимизированные данные Яндекс.Метрики](metrica.md) +- [Star Schema Benchmark](star-schema.md) +- [WikiStat](wikistat.md) +- [Терабайт логов кликов от Criteo](criteo.md) +- [AMPLab Big Data Benchmark](amplab-benchmark.md) +- [Данные о такси в Нью-Йорке](nyc-taxi.md) +- [OnTime](ontime.md) + +[Оригинальная статья](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/ru/getting_started/example_datasets/metrica.md b/docs/ru/getting-started/example-datasets/metrica.md similarity index 100% rename from docs/ru/getting_started/example_datasets/metrica.md rename to docs/ru/getting-started/example-datasets/metrica.md diff --git a/docs/ru/getting_started/example_datasets/nyc_taxi.md b/docs/ru/getting-started/example-datasets/nyc-taxi.md similarity index 100% rename from docs/ru/getting_started/example_datasets/nyc_taxi.md rename to docs/ru/getting-started/example-datasets/nyc-taxi.md diff --git a/docs/ru/getting_started/example_datasets/ontime.md b/docs/ru/getting-started/example-datasets/ontime.md similarity index 100% rename from docs/ru/getting_started/example_datasets/ontime.md rename to docs/ru/getting-started/example-datasets/ontime.md diff --git a/docs/ru/getting_started/example_datasets/star_schema.md b/docs/ru/getting-started/example-datasets/star-schema.md similarity index 100% rename from docs/ru/getting_started/example_datasets/star_schema.md rename to docs/ru/getting-started/example-datasets/star-schema.md diff --git a/docs/ru/getting_started/example_datasets/wikistat.md b/docs/ru/getting-started/example-datasets/wikistat.md similarity index 100% rename from docs/ru/getting_started/example_datasets/wikistat.md rename to docs/ru/getting-started/example-datasets/wikistat.md diff --git a/docs/ru/getting-started/index.md b/docs/ru/getting-started/index.md new file mode 100644 index 00000000000..b2b292c4725 --- /dev/null +++ b/docs/ru/getting-started/index.md @@ -0,0 +1,18 @@ +--- +toc_folder_title: "\u041D\u0430\u0447\u0430\u043B\u043E \u0440\u0430\u0431\u043E\u0442\ + \u044B" +toc_hidden: true +toc_priority: 8 +toc_title: hidden +--- + +# Начало работы {#nachalo-raboty} + +Если вы новичок в ClickHouse и хотите вживую оценить его производительность, прежде всего нужно пройти через [процесс установки](install.md). + +После этого можно выбрать один из следующих вариантов: + +- [Пройти подробное руководство для начинающих](tutorial.md) +- [Поэкспериментировать с тестовыми наборами данных](example-datasets/ontime.md) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/getting_started/) diff --git a/docs/ru/getting-started/install.md b/docs/ru/getting-started/install.md new file mode 100644 index 00000000000..19943f182d8 --- /dev/null +++ b/docs/ru/getting-started/install.md @@ -0,0 +1,159 @@ +# Установка {#ustanovka} + +## Системные требования {#sistemnye-trebovaniia} + +ClickHouse может работать на любой операционной системе Linux, FreeBSD или Mac OS X с архитектурой процессора x86\_64, AArch64 или PowerPC64LE. + +Предварительно собранные пакеты компилируются для x86\_64 и используют набор инструкций SSE 4.2, поэтому, если не указано иное, его поддержка в используемом процессоре, становится дополнительным требованием к системе. Вот команда, чтобы проверить, поддерживает ли текущий процессор SSE 4.2: + +``` bash +$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" +``` + +Чтобы запустить ClickHouse на процессорах, которые не поддерживают SSE 4.2, либо имеют архитектуру AArch64 или PowerPC64LE, необходимо самостоятельно [собрать ClickHouse из исходного кода](#from-sources) с соответствующими настройками конфигурации. + +## Доступные варианты установки {#dostupnye-varianty-ustanovki} + +### Из DEB пакетов {#install-from-deb-packages} + +Яндекс рекомендует использовать официальные скомпилированные `deb` пакеты для Debian или Ubuntu. Для установки пакетов выполните: + +``` bash +{% include 'install/deb.sh' %} +``` + +Также эти пакеты можно скачать и установить вручную отсюда: https://repo.clickhouse.tech/deb/stable/main/. + +Если вы хотите использовать наиболее свежую версию, замените `stable` на `testing` (рекомендуется для тестовых окружений). + +### Из RPM пакетов {#from-rpm-packages} + +Команда ClickHouse в Яндексе рекомендует использовать официальные предкомпилированные `rpm` пакеты для CentOS, RedHad и всех остальных дистрибутивов Linux, основанных на rpm. + +Сначала нужно подключить официальный репозиторий: + +``` bash +sudo yum install yum-utils +sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG +sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 +``` + +Для использования наиболее свежих версий нужно заменить `stable` на `testing` (рекомендуется для тестовых окружений). Также иногда доступен `prestable`. + +Для, собственно, установки пакетов необходимо выполнить следующие команды: + +``` bash +sudo yum install clickhouse-server clickhouse-client +``` + +Также есть возможность установить пакеты вручную, скачав отсюда: https://repo.clickhouse.tech/rpm/stable/x86\_64. + +### Из Tgz архивов {#from-tgz-archives} + +Команда ClickHouse в Яндексе рекомендует использовать предкомпилированные бинарники из `tgz` архивов для всех дистрибутивов, где невозможна установка `deb` и `rpm` пакетов. + +Интересующую версию архивов можно скачать вручную с помощью `curl` или `wget` из репозитория https://repo.clickhouse.tech/tgz/. +После этого архивы нужно распаковать и воспользоваться скриптами установки. Пример установки самой свежей версии: + +``` bash +export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz + +tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz +sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz +sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-server-$LATEST_VERSION.tgz +sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh +sudo /etc/init.d/clickhouse-server start + +tar -xzvf clickhouse-client-$LATEST_VERSION.tgz +sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh +``` + +Для production окружений рекомендуется использовать последнюю `stable`-версию. Её номер также можно найти на github с на вкладке https://github.com/ClickHouse/ClickHouse/tags c постфиксом `-stable`. + +### Из Docker образа {#from-docker-image} + +Для запуска ClickHouse в Docker нужно следовать инструкции на [Docker Hub](https://hub.docker.com/r/yandex/clickhouse-server/). Внутри образов используются официальные `deb` пакеты. + +### Из исходного кода {#from-sources} + +Для компиляции ClickHouse вручную, используйте инструкцию для [Linux](../development/build.md) или [Mac OS X](../development/build-osx.md). + +Можно скомпилировать пакеты и установить их, либо использовать программы без установки пакетов. Также при ручой сборке можно отключить необходимость поддержки набора инструкций SSE 4.2 или собрать под процессоры архитектуры AArch64. + + Client: programs/clickhouse-client + Server: programs/clickhouse-server + +Для работы собранного вручную сервера необходимо создать директории для данных и метаданных, а также сделать их `chown` для желаемого пользователя. Пути к этим директориям могут быть изменены в конфигурационном файле сервера (src/programs/server/config.xml), по умолчанию используются следующие: + + /opt/clickhouse/data/default/ + /opt/clickhouse/metadata/default/ + +На Gentoo для установки ClickHouse из исходного кода можно использовать просто `emerge clickhouse`. + +## Запуск {#zapusk} + +Для запуска сервера в качестве демона, выполните: + +``` bash +$ sudo service clickhouse-server start +``` + +Смотрите логи в директории `/var/log/clickhouse-server/`. + +Если сервер не стартует, проверьте корректность конфигурации в файле `/etc/clickhouse-server/config.xml` + +Также можно запустить сервер вручную из консоли: + +``` bash +$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml +``` + +При этом, лог будет выводиться в консоль, что удобно для разработки. +Если конфигурационный файл лежит в текущей директории, то указывать параметр `--config-file` не требуется, по умолчанию будет использован файл `./config.xml`. + +После запуска сервера, соединиться с ним можно с помощью клиента командной строки: + +``` bash +$ clickhouse-client +``` + +По умолчанию он соединяется с localhost:9000, от имени пользователя `default` без пароля. Также клиент может быть использован для соединения с удалённым сервером с помощью аргумента `--host`. + +Терминал должен использовать кодировку UTF-8. + +Более подробная информация о клиенте располагается в разделе [«Клиент командной строки»](../interfaces/cli.md). + +Пример проверки работоспособности системы: + +``` bash +$ ./clickhouse-client +ClickHouse client version 0.0.18749. +Connecting to localhost:9000. +Connected to ClickHouse server version 0.0.18749. + +:) SELECT 1 + +SELECT 1 + +┌─1─┐ +│ 1 │ +└───┘ + +1 rows in set. Elapsed: 0.003 sec. + +:) +``` + +**Поздравляем, система работает!** + +Для дальнейших экспериментов можно попробовать загрузить один из тестовых наборов данных или пройти [пошаговое руководство для начинающих](https://clickhouse.tech/tutorial.html). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/getting_started/install/) diff --git a/docs/ru/getting_started/playground.md b/docs/ru/getting-started/playground.md similarity index 100% rename from docs/ru/getting_started/playground.md rename to docs/ru/getting-started/playground.md diff --git a/docs/ru/getting-started/tutorial.md b/docs/ru/getting-started/tutorial.md new file mode 120000 index 00000000000..7af416c9878 --- /dev/null +++ b/docs/ru/getting-started/tutorial.md @@ -0,0 +1 @@ +../../en/getting-started/tutorial.md \ No newline at end of file diff --git a/docs/ru/getting_started/example_datasets/index.md b/docs/ru/getting_started/example_datasets/index.md deleted file mode 100644 index 5fbe0843f4b..00000000000 --- a/docs/ru/getting_started/example_datasets/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -toc_folder_title: Тестовые массивы данных -toc_priority: 12 -toc_title: Обзор ---- -# Тестовые массивы данных - -Этот раздел описывает как получить тестовые массивы данных и загрузить их в ClickHouse. -Для некоторых тестовых массивов данных также доступны тестовые запросы. - -* [Анонимизированные данные Яндекс.Метрики](metrica.md) -* [Star Schema Benchmark](star_schema.md) -* [WikiStat](wikistat.md) -* [Терабайт логов кликов от Criteo](criteo.md) -* [AMPLab Big Data Benchmark](amplab_benchmark.md) -* [Данные о такси в Нью-Йорке](nyc_taxi.md) -* [OnTime](ontime.md) - -[Оригинальная статья](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/ru/getting_started/index.md b/docs/ru/getting_started/index.md deleted file mode 100644 index 7711d6b94ee..00000000000 --- a/docs/ru/getting_started/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -toc_folder_title: Начало работы -toc_hidden: true -toc_priority: 8 -toc_title: hidden ---- - -# Начало работы {#nachalo-raboty} - -Если вы новичок в ClickHouse и хотите вживую оценить его производительность, прежде всего нужно пройти через [процесс установки](install.md). - -После этого можно выбрать один из следующих вариантов: - -- [Пройти подробное руководство для начинающих](tutorial.md) -- [Поэкспериментировать с тестовыми наборами данных](example_datasets/ontime.md) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/getting_started/) diff --git a/docs/ru/getting_started/install.md b/docs/ru/getting_started/install.md deleted file mode 100644 index 9012ae54014..00000000000 --- a/docs/ru/getting_started/install.md +++ /dev/null @@ -1,159 +0,0 @@ -# Установка {#ustanovka} - -## Системные требования {#sistemnye-trebovaniia} - -ClickHouse может работать на любой операционной системе Linux, FreeBSD или Mac OS X с архитектурой процессора x86\_64, AArch64 или PowerPC64LE. - -Предварительно собранные пакеты компилируются для x86\_64 и используют набор инструкций SSE 4.2, поэтому, если не указано иное, его поддержка в используемом процессоре, становится дополнительным требованием к системе. Вот команда, чтобы проверить, поддерживает ли текущий процессор SSE 4.2: - -``` bash -$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" -``` - -Чтобы запустить ClickHouse на процессорах, которые не поддерживают SSE 4.2, либо имеют архитектуру AArch64 или PowerPC64LE, необходимо самостоятельно [собрать ClickHouse из исходного кода](#from-sources) с соответствующими настройками конфигурации. - -## Доступные варианты установки {#dostupnye-varianty-ustanovki} - -### Из DEB пакетов {#install-from-deb-packages} - -Яндекс рекомендует использовать официальные скомпилированные `deb` пакеты для Debian или Ubuntu. Для установки пакетов выполните: - -``` bash -{% include 'install/deb.sh' %} -``` - -Также эти пакеты можно скачать и установить вручную отсюда: https://repo.clickhouse.tech/deb/stable/main/. - -Если вы хотите использовать наиболее свежую версию, замените `stable` на `testing` (рекомендуется для тестовых окружений). - -### Из RPM пакетов {#from-rpm-packages} - -Команда ClickHouse в Яндексе рекомендует использовать официальные предкомпилированные `rpm` пакеты для CentOS, RedHad и всех остальных дистрибутивов Linux, основанных на rpm. - -Сначала нужно подключить официальный репозиторий: - -``` bash -sudo yum install yum-utils -sudo rpm --import https://repo.yandex.ru/clickhouse/CLICKHOUSE-KEY.GPG -sudo yum-config-manager --add-repo https://repo.yandex.ru/clickhouse/rpm/stable/x86_64 -``` - -Для использования наиболее свежих версий нужно заменить `stable` на `testing` (рекомендуется для тестовых окружений). - -Для, собственно, установки пакетов необходимо выполнить следующие команды: - -``` bash -sudo yum install clickhouse-server clickhouse-client -``` - -Также есть возможность установить пакеты вручную, скачав отсюда: https://repo.yandex.ru/clickhouse/rpm/stable/x86\_64. - -### Из Tgz архивов {#from-tgz-archives} - -Команда ClickHouse в Яндексе рекомендует использовать предкомпилированные бинарники из `tgz` архивов для всех дистрибутивов, где невозможна установка `deb` и `rpm` пакетов. - -Интересующую версию архивов можно скачать вручную с помощью `curl` или `wget` из репозитория https://repo.yandex.ru/clickhouse/tgz/. -После этого архивы нужно распаковать и воспользоваться скриптами установки. Пример установки самой свежей версии: - -``` bash -export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` -curl -O https://repo.yandex.ru/clickhouse/tgz/clickhouse-common-static-$LATEST_VERSION.tgz -curl -O https://repo.yandex.ru/clickhouse/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz -curl -O https://repo.yandex.ru/clickhouse/tgz/clickhouse-server-$LATEST_VERSION.tgz -curl -O https://repo.yandex.ru/clickhouse/tgz/clickhouse-client-$LATEST_VERSION.tgz - -tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz -sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz -sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-server-$LATEST_VERSION.tgz -sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh -sudo /etc/init.d/clickhouse-server start - -tar -xzvf clickhouse-client-$LATEST_VERSION.tgz -sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh -``` - -Для production окружений рекомендуется использовать последнюю `stable`-версию. Её номер также можно найти на github с на вкладке https://github.com/ClickHouse/ClickHouse/tags c постфиксом `-stable`. - -### Из Docker образа {#from-docker-image} - -Для запуска ClickHouse в Docker нужно следовать инструкции на [Docker Hub](https://hub.docker.com/r/yandex/clickhouse-server/). Внутри образов используются официальные `deb` пакеты. - -### Из исходного кода {#from-sources} - -Для компиляции ClickHouse вручную, используйте инструкцию для [Linux](../development/build.md) или [Mac OS X](../development/build_osx.md). - -Можно скомпилировать пакеты и установить их, либо использовать программы без установки пакетов. Также при ручой сборке можно отключить необходимость поддержки набора инструкций SSE 4.2 или собрать под процессоры архитектуры AArch64. - - Client: programs/clickhouse-client - Server: programs/clickhouse-server - -Для работы собранного вручную сервера необходимо создать директории для данных и метаданных, а также сделать их `chown` для желаемого пользователя. Пути к этим директориям могут быть изменены в конфигурационном файле сервера (src/programs/server/config.xml), по умолчанию используются следующие: - - /opt/clickhouse/data/default/ - /opt/clickhouse/metadata/default/ - -На Gentoo для установки ClickHouse из исходного кода можно использовать просто `emerge clickhouse`. - -## Запуск {#zapusk} - -Для запуска сервера в качестве демона, выполните: - -``` bash -$ sudo service clickhouse-server start -``` - -Смотрите логи в директории `/var/log/clickhouse-server/`. - -Если сервер не стартует, проверьте корректность конфигурации в файле `/etc/clickhouse-server/config.xml` - -Также можно запустить сервер вручную из консоли: - -``` bash -$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml -``` - -При этом, лог будет выводиться в консоль, что удобно для разработки. -Если конфигурационный файл лежит в текущей директории, то указывать параметр `--config-file` не требуется, по умолчанию будет использован файл `./config.xml`. - -После запуска сервера, соединиться с ним можно с помощью клиента командной строки: - -``` bash -$ clickhouse-client -``` - -По умолчанию он соединяется с localhost:9000, от имени пользователя `default` без пароля. Также клиент может быть использован для соединения с удалённым сервером с помощью аргумента `--host`. - -Терминал должен использовать кодировку UTF-8. - -Более подробная информация о клиенте располагается в разделе [«Клиент командной строки»](../interfaces/cli.md). - -Пример проверки работоспособности системы: - -``` bash -$ ./clickhouse-client -ClickHouse client version 0.0.18749. -Connecting to localhost:9000. -Connected to ClickHouse server version 0.0.18749. - -:) SELECT 1 - -SELECT 1 - -┌─1─┐ -│ 1 │ -└───┘ - -1 rows in set. Elapsed: 0.003 sec. - -:) -``` - -**Поздравляем, система работает!** - -Для дальнейших экспериментов можно попробовать загрузить один из тестовых наборов данных или пройти [пошаговое руководство для начинающих](https://clickhouse.tech/tutorial.html). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/getting_started/install/) diff --git a/docs/ru/getting_started/tutorial.md b/docs/ru/getting_started/tutorial.md deleted file mode 120000 index 8bc40816ab2..00000000000 --- a/docs/ru/getting_started/tutorial.md +++ /dev/null @@ -1 +0,0 @@ -../../en/getting_started/tutorial.md \ No newline at end of file diff --git a/docs/ru/guides/apply-catboost-model.md b/docs/ru/guides/apply-catboost-model.md new file mode 100644 index 00000000000..1de8f013db8 --- /dev/null +++ b/docs/ru/guides/apply-catboost-model.md @@ -0,0 +1,230 @@ +# Применение модели CatBoost в ClickHouse {#applying-catboost-model-in-clickhouse} + +[CatBoost](https://catboost.ai) — открытая программная библиотека разработанная компанией [Яндекс](https://yandex.ru/company/) для машинного обучения, которая использует схему градиентного бустинга. + +С помощью этой инструкции вы научитесь применять предобученные модели в ClickHouse: в результате вы запустите вывод модели из SQL. + +Чтобы применить модель CatBoost в ClickHouse: + +1. [Создайте таблицу](#create-table). +2. [Вставьте данные в таблицу](#insert-data-to-table). +3. [Интегрируйте CatBoost в ClickHouse](#integrate-catboost-into-clickhouse) (Опциональный шаг). +4. [Запустите вывод модели из SQL](#run-model-inference). + +Подробнее об обучении моделей в CatBoost, см. [Обучение и применение моделей](https://catboost.ai/docs/features/training.html#training). + +## Перед началом работы {#prerequisites} + +Если у вас еще нет [Docker](https://docs.docker.com/install/), установите его. + +!!! note "Примечание" + [Docker](https://www.docker.com) – это программная платформа для создания контейнеров, которые изолируют установку CatBoost и ClickHouse от остальной части системы. + +Перед применением модели CatBoost: + +**1.** Скачайте [Docker-образ](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) из реестра: + +``` bash +$ docker pull yandex/tutorial-catboost-clickhouse +``` + +Данный Docker-образ содержит все необходимое для запуска CatBoost и ClickHouse: код, среду выполнения, библиотеки, переменные окружения и файлы конфигурации. + +**2.** Проверьте, что Docker-образ успешно скачался: + +``` bash +$ docker image ls +REPOSITORY TAG IMAGE ID CREATED SIZE +yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB +``` + +**3.** Запустите Docker-контейнер основанный на данном образе: + +``` bash +$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse +``` + +## 1. Создайте таблицу {#create-table} + +Чтобы создать таблицу для обучающей выборки: + +**1.** Запустите клиент ClickHouse: + +``` bash +$ clickhouse client +``` + +!!! note "Примечание" + Сервер ClickHouse уже запущен внутри Docker-контейнера. + +**2.** Создайте таблицу в ClickHouse с помощью следующей команды: + +``` sql +:) CREATE TABLE amazon_train +( + date Date MATERIALIZED today(), + ACTION UInt8, + RESOURCE UInt32, + MGR_ID UInt32, + ROLE_ROLLUP_1 UInt32, + ROLE_ROLLUP_2 UInt32, + ROLE_DEPTNAME UInt32, + ROLE_TITLE UInt32, + ROLE_FAMILY_DESC UInt32, + ROLE_FAMILY UInt32, + ROLE_CODE UInt32 +) +ENGINE = MergeTree ORDER BY date +``` + +**3.** Выйдите из клиента ClickHouse: + +``` sql +:) exit +``` + +## 2. Вставьте данные в таблицу {#insert-data-to-table} + +Чтобы вставить данные: + +**1.** Выполните следующую команду: + +``` bash +$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv +``` + +**2.** Запустите клиент ClickHouse: + +``` bash +$ clickhouse client +``` + +**3.** Проверьте, что данные успешно загрузились: + +``` sql +:) SELECT count() FROM amazon_train + +SELECT count() +FROM amazon_train + ++-count()-+ +| 65538 | ++---------+ +``` + +## 3. Интегрируйте CatBoost в ClickHouse {#integrate-catboost-into-clickhouse} + +!!! note "Примечание" + **Опциональный шаг.** Docker-образ содержит все необходимое для запуска CatBoost и ClickHouse. + +Чтобы интегрировать CatBoost в ClickHouse: + +**1.** Создайте библиотеку для оценки модели. + +Наиболее быстрый способ оценить модель CatBoost — это скомпилировать библиотеку `libcatboostmodel.`. Подробнее о том, как скомпилировать библиотеку, читайте в [документации CatBoost](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). + +**2.** Создайте в любом месте новую директорию с произвольным названием, например `data` и поместите в нее созданную библиотеку. Docker-образ уже содержит библиотеку `data/libcatboostmodel.so`. + +**3.** Создайте в любом месте новую директорию для конфигурации модели с произвольным названием, например `models`. + +**4.** Создайте файл конфигурации модели с произвольным названием, например `models/amazon_model.xml`. + +**5.** Опишите конфигурацию модели: + +``` xml + + + + catboost + + amazon + + /home/catboost/tutorial/catboost_model.bin + + 0 + + +``` + +**6.** Добавьте в конфигурацию ClickHouse путь к CatBoost и конфигурации модели: + +``` xml + +/home/catboost/data/libcatboostmodel.so +/home/catboost/models/*_model.xml +``` + +## 4. Запустите вывод модели из SQL {#run-model-inference} + +Для тестирования модели запустите клиент ClickHouse `$ clickhouse client`. + +Проверьте, что модель работает: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) > 0 AS prediction, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Примечание" + Функция [modelEvaluate](../sql-reference/functions/other-functions.md#function-modelevaluate) возвращает кортежи (tuple) с исходными прогнозами по классам для моделей с несколькими классами. + +Спрогнозируйте вероятность: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1 + exp(-prediction)) AS probability, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Примечание" + Подробнее про функцию [exp()](../sql-reference/functions/math-functions.md). + +Посчитайте логистическую функцию потерь (LogLoss) на всей выборке: + +``` sql +:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss +FROM +( + SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1. + exp(-prediction)) AS prob, + ACTION AS tg + FROM amazon_train +) +``` + +!!! note "Примечание" + Подробнее про функции [avg()](../sql-reference/aggregate-functions/reference.md#agg_function-avg), [log()](../sql-reference/functions/math-functions.md). diff --git a/docs/ru/guides/apply_catboost_model.md b/docs/ru/guides/apply_catboost_model.md deleted file mode 100644 index 2f94753b7f2..00000000000 --- a/docs/ru/guides/apply_catboost_model.md +++ /dev/null @@ -1,230 +0,0 @@ -# Применение модели CatBoost в ClickHouse {#applying-catboost-model-in-clickhouse} - -[CatBoost](https://catboost.ai) — открытая программная библиотека разработанная компанией [Яндекс](https://yandex.ru/company/) для машинного обучения, которая использует схему градиентного бустинга. - -С помощью этой инструкции вы научитесь применять предобученные модели в ClickHouse: в результате вы запустите вывод модели из SQL. - -Чтобы применить модель CatBoost в ClickHouse: - -1. [Создайте таблицу](#create-table). -2. [Вставьте данные в таблицу](#insert-data-to-table). -3. [Интегрируйте CatBoost в ClickHouse](#integrate-catboost-into-clickhouse) (Опциональный шаг). -4. [Запустите вывод модели из SQL](#run-model-inference). - -Подробнее об обучении моделей в CatBoost, см. [Обучение и применение моделей](https://catboost.ai/docs/features/training.html#training). - -## Перед началом работы {#prerequisites} - -Если у вас еще нет [Docker](https://docs.docker.com/install/), установите его. - -!!! note "Примечание" - [Docker](https://www.docker.com) – это программная платформа для создания контейнеров, которые изолируют установку CatBoost и ClickHouse от остальной части системы. - -Перед применением модели CatBoost: - -**1.** Скачайте [Docker-образ](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) из реестра: - -``` bash -$ docker pull yandex/tutorial-catboost-clickhouse -``` - -Данный Docker-образ содержит все необходимое для запуска CatBoost и ClickHouse: код, среду выполнения, библиотеки, переменные окружения и файлы конфигурации. - -**2.** Проверьте, что Docker-образ успешно скачался: - -``` bash -$ docker image ls -REPOSITORY TAG IMAGE ID CREATED SIZE -yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB -``` - -**3.** Запустите Docker-контейнер основанный на данном образе: - -``` bash -$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse -``` - -## 1. Создайте таблицу {#create-table} - -Чтобы создать таблицу для обучающей выборки: - -**1.** Запустите клиент ClickHouse: - -``` bash -$ clickhouse client -``` - -!!! note "Примечание" - Сервер ClickHouse уже запущен внутри Docker-контейнера. - -**2.** Создайте таблицу в ClickHouse с помощью следующей команды: - -``` sql -:) CREATE TABLE amazon_train -( - date Date MATERIALIZED today(), - ACTION UInt8, - RESOURCE UInt32, - MGR_ID UInt32, - ROLE_ROLLUP_1 UInt32, - ROLE_ROLLUP_2 UInt32, - ROLE_DEPTNAME UInt32, - ROLE_TITLE UInt32, - ROLE_FAMILY_DESC UInt32, - ROLE_FAMILY UInt32, - ROLE_CODE UInt32 -) -ENGINE = MergeTree ORDER BY date -``` - -**3.** Выйдите из клиента ClickHouse: - -``` sql -:) exit -``` - -## 2. Вставьте данные в таблицу {#insert-data-to-table} - -Чтобы вставить данные: - -**1.** Выполните следующую команду: - -``` bash -$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv -``` - -**2.** Запустите клиент ClickHouse: - -``` bash -$ clickhouse client -``` - -**3.** Проверьте, что данные успешно загрузились: - -``` sql -:) SELECT count() FROM amazon_train - -SELECT count() -FROM amazon_train - -+-count()-+ -| 65538 | -+---------+ -``` - -## 3. Интегрируйте CatBoost в ClickHouse {#integrate-catboost-into-clickhouse} - -!!! note "Примечание" - **Опциональный шаг.** Docker-образ содержит все необходимое для запуска CatBoost и ClickHouse. - -Чтобы интегрировать CatBoost в ClickHouse: - -**1.** Создайте библиотеку для оценки модели. - -Наиболее быстрый способ оценить модель CatBoost — это скомпилировать библиотеку `libcatboostmodel.`. Подробнее о том, как скомпилировать библиотеку, читайте в [документации CatBoost](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). - -**2.** Создайте в любом месте новую директорию с произвольным названием, например `data` и поместите в нее созданную библиотеку. Docker-образ уже содержит библиотеку `data/libcatboostmodel.so`. - -**3.** Создайте в любом месте новую директорию для конфигурации модели с произвольным названием, например `models`. - -**4.** Создайте файл конфигурации модели с произвольным названием, например `models/amazon_model.xml`. - -**5.** Опишите конфигурацию модели: - -``` xml - - - - catboost - - amazon - - /home/catboost/tutorial/catboost_model.bin - - 0 - - -``` - -**6.** Добавьте в конфигурацию ClickHouse путь к CatBoost и конфигурации модели: - -``` xml - -/home/catboost/data/libcatboostmodel.so -/home/catboost/models/*_model.xml -``` - -## 4. Запустите вывод модели из SQL {#run-model-inference} - -Для тестирования модели запустите клиент ClickHouse `$ clickhouse client`. - -Проверьте, что модель работает: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) > 0 AS prediction, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Примечание" - Функция [modelEvaluate](../sql_reference/functions/other_functions.md#function-modelevaluate) возвращает кортежи (tuple) с исходными прогнозами по классам для моделей с несколькими классами. - -Спрогнозируйте вероятность: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1 + exp(-prediction)) AS probability, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Примечание" - Подробнее про функцию [exp()](../sql_reference/functions/math_functions.md). - -Посчитайте логистическую функцию потерь (LogLoss) на всей выборке: - -``` sql -:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss -FROM -( - SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1. + exp(-prediction)) AS prob, - ACTION AS tg - FROM amazon_train -) -``` - -!!! note "Примечание" - Подробнее про функции [avg()](../sql_reference/aggregate_functions/reference.md#agg_function-avg), [log()](../sql_reference/functions/math_functions.md). diff --git a/docs/ru/guides/index.md b/docs/ru/guides/index.md index 2ba84e9afc2..2c38de275a7 100644 --- a/docs/ru/guides/index.md +++ b/docs/ru/guides/index.md @@ -1,11 +1,11 @@ --- -toc_folder_title: Руководства +toc_folder_title: "\u0420\u0443\u043A\u043E\u0432\u043E\u0434\u0441\u0442\u0432\u0430" toc_priority: 38 -toc_title: Обзор +toc_title: "\u041E\u0431\u0437\u043E\u0440" --- # Руководства {#rukovodstva} Подробные пошаговые инструкции, которые помогут вам решать различные задачи с помощью ClickHouse. -- [Применение модели CatBoost в ClickHouse](apply_catboost_model.md) +- [Применение модели CatBoost в ClickHouse](apply-catboost-model.md) diff --git a/docs/ru/images/column-oriented.gif b/docs/ru/images/column-oriented.gif new file mode 100644 index 00000000000..d5ac7c82848 Binary files /dev/null and b/docs/ru/images/column-oriented.gif differ diff --git a/docs/ru/images/column_oriented.gif b/docs/ru/images/column_oriented.gif deleted file mode 100644 index 15f4b12e697..00000000000 Binary files a/docs/ru/images/column_oriented.gif and /dev/null differ diff --git a/docs/ru/images/row-oriented.gif b/docs/ru/images/row-oriented.gif new file mode 100644 index 00000000000..41395b5693e Binary files /dev/null and b/docs/ru/images/row-oriented.gif differ diff --git a/docs/ru/images/row_oriented.gif b/docs/ru/images/row_oriented.gif deleted file mode 100644 index 53daa20f322..00000000000 Binary files a/docs/ru/images/row_oriented.gif and /dev/null differ diff --git a/docs/ru/index.md b/docs/ru/index.md index e537c240cb6..a7aa80b91d2 100644 --- a/docs/ru/index.md +++ b/docs/ru/index.md @@ -1,6 +1,6 @@ --- toc_priority: 0 -toc_title: Обзор +toc_title: "\u041E\u0431\u0437\u043E\u0440" --- # Что такое ClickHouse {#chto-takoe-clickhouse} @@ -66,11 +66,11 @@ ClickHouse - столбцовая система управления базам **Строковые СУБД** -![Строковые](images/row_oriented.gif#) +![Строковые](images/row-oriented.gif#) **Столбцовые СУБД** -![Столбцовые](images/column_oriented.gif#) +![Столбцовые](images/column-oriented.gif#) Видите разницу? diff --git a/docs/ru/interfaces/cli.md b/docs/ru/interfaces/cli.md index b76e96cc1dc..816b5962280 100644 --- a/docs/ru/interfaces/cli.md +++ b/docs/ru/interfaces/cli.md @@ -2,7 +2,7 @@ ClickHouse предоставляет собственный клиент командной строки: `clickhouse-client`. Клиент поддерживает запуск с аргументами командной строки и с конфигурационными файлами. Подробнее читайте в разделе [Конфигурирование](#interfaces_cli_configuration). -Клиент [устанавливается](../getting_started/index.md) пакетом `clickhouse-client` и запускается командой `clickhouse-client`. +Клиент [устанавливается](../getting-started/index.md) пакетом `clickhouse-client` и запускается командой `clickhouse-client`. ``` bash $ clickhouse-client @@ -88,7 +88,7 @@ clickhouse-client --param_parName="[1, 2]" -q "SELECT * FROM table WHERE a = {p ``` - `name` — идентификатор подстановки. В консольном клиенте его следует использовать как часть имени параметра `--param_ = value`. -- `data type` — [тип данных](../sql_reference/data_types/index.md) значения. Например, структура данных `(integer, ('string', integer))` может иметь тип данных `Tuple(UInt8, Tuple(String, UInt8))` ([целочисленный](../sql_reference/data_types/int_uint.md) тип может быть и другим). +- `data type` — [тип данных](../sql-reference/data-types/index.md) значения. Например, структура данных `(integer, ('string', integer))` может иметь тип данных `Tuple(UInt8, Tuple(String, UInt8))` ([целочисленный](../sql-reference/data-types/int-uint.md) тип может быть и другим). #### Пример {#primer} diff --git a/docs/ru/interfaces/formats.md b/docs/ru/interfaces/formats.md index b1707a55193..822f5543f9b 100644 --- a/docs/ru/interfaces/formats.md +++ b/docs/ru/interfaces/formats.md @@ -99,9 +99,9 @@ world Массивы форматируются в виде списка значений через запятую в квадратных скобках. Элементы массива - числа форматируются как обычно, а даты, даты-с-временем и строки - в одинарных кавычках с такими же правилами экранирования, как указано выше. -[NULL](../sql_reference/syntax.md) форматируется как `\N`. +[NULL](../sql-reference/syntax.md) форматируется как `\N`. -Каждый элемент структуры типа [Nested](../sql_reference/data_types/nested_data_structures/nested.md) представляется как отдельный массив. +Каждый элемент структуры типа [Nested](../sql-reference/data-types/nested-data-structures/nested.md) представляется как отдельный массив. Например: @@ -302,7 +302,7 @@ SearchPhrase=дизайн штор count()=1064 SearchPhrase=баку count()=1000 ``` -[NULL](../sql_reference/syntax.md) форматируется как `\N`. +[NULL](../sql-reference/syntax.md) форматируется как `\N`. ``` sql SELECT * FROM t_null FORMAT TSKV @@ -432,7 +432,7 @@ JSON совместим с JavaScript. Для этого, дополнитель Этот формат подходит только для вывода результата выполнения запроса, но не для парсинга (приёма данных для вставки в таблицу). -ClickHouse поддерживает [NULL](../sql_reference/syntax.md), который при выводе JSON будет отображен как `null`. +ClickHouse поддерживает [NULL](../sql-reference/syntax.md), который при выводе JSON будет отображен как `null`. Смотрите также формат [JSONEachRow](#jsoneachrow) . @@ -507,7 +507,7 @@ ClickHouse игнорирует пробелы между элементами **Обработка пропущенных значений** -ClickHouse заменяет опущенные значения значениями по умолчанию для соответствующих [data types](../sql_reference/data_types/index.md). +ClickHouse заменяет опущенные значения значениями по умолчанию для соответствующих [data types](../sql-reference/data-types/index.md). Если указано `DEFAULT expr`, то ClickHouse использует различные правила подстановки в зависимости от настройки [input\_format\_defaults\_for\_omitted\_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields). @@ -525,7 +525,7 @@ CREATE TABLE IF NOT EXISTS example_table - Если `input_format_defaults_for_omitted_fields = 1`, то значение по умолчанию для `x` равно `0`, а значение по умолчанию `a` равно `x * 2`. !!! note "Предупреждение" - Если `insert_sample_with_metadata = 1`, то при обработке запросов ClickHouse потребляет больше вычислительных ресурсов, чем если `insert_sample_with_metadata = 0`. + Если `input_format_defaults_for_omitted_fields = 1`, то при обработке запросов ClickHouse потребляет больше вычислительных ресурсов, чем если `input_format_defaults_for_omitted_fields = 0`. ### Выборка данных {#vyborka-dannykh} @@ -552,7 +552,7 @@ CREATE TABLE IF NOT EXISTS example_table ### Использование вложенных структур {#jsoneachrow-nested} -Если у вас есть таблица со столбцами типа [Nested](../sql_reference/data_types/nested_data_structures/nested.md), то в неё можно вставить данные из JSON-документа с такой же структурой. Функциональность включается настройкой [input\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json). +Если у вас есть таблица со столбцами типа [Nested](../sql-reference/data-types/nested-data-structures/nested.md), то в неё можно вставить данные из JSON-документа с такой же структурой. Функциональность включается настройкой [input\_format\_import\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json). Например, рассмотрим следующую таблицу: @@ -626,7 +626,7 @@ SELECT * FROM json_each_row_nested Рисуется полная сетка таблицы и, таким образом, каждая строчка занимает две строки в терминале. Каждый блок результата выводится в виде отдельной таблицы. Это нужно, чтобы можно было выводить блоки без буферизации результата (буферизация потребовалась бы, чтобы заранее вычислить видимую ширину всех значений.) -[NULL](../sql_reference/syntax.md) выводится как `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) выводится как `ᴺᵁᴸᴸ`. ``` sql SELECT * FROM t_null @@ -728,7 +728,7 @@ FixedString представлены просто как последовате Array представлены как длина в формате varint (unsigned [LEB128](https://en.wikipedia.org/wiki/LEB128)), а затем элементы массива, подряд. -Для поддержки [NULL](../sql_reference/syntax.md#null-literal) перед каждым значением типа [Nullable](../sql_reference/data_types/nullable.md) следует байт содержащий 1 или 0. Если байт 1, то значение равно NULL, и этот байт интерпретируется как отдельное значение (т.е. после него следует значение следующего поля). Если байт 0, то после байта следует значение поля (не равно NULL). +Для поддержки [NULL](../sql-reference/syntax.md#null-literal) перед каждым значением типа [Nullable](../sql-reference/data-types/nullable.md) следует байт содержащий 1 или 0. Если байт 1, то значение равно NULL, и этот байт интерпретируется как отдельное значение (т.е. после него следует значение следующего поля). Если байт 0, то после байта следует значение поля (не равно NULL). ## RowBinaryWithNamesAndTypes {#rowbinarywithnamesandtypes} @@ -740,7 +740,7 @@ Array представлены как длина в формате varint (unsig ## Values {#data-format-values} -Выводит каждую строку в скобках. Строки разделены запятыми. После последней строки запятой нет. Значения внутри скобок также разделены запятыми. Числа выводятся в десятичном виде без кавычек. Массивы выводятся в квадратных скобках. Строки, даты, даты-с-временем выводятся в кавычках. Правила экранирования и особенности парсинга аналогичны формату [TabSeparated](#tabseparated). При форматировании, лишние пробелы не ставятся, а при парсинге - допустимы и пропускаются (за исключением пробелов внутри значений типа массив, которые недопустимы). [NULL](../sql_reference/syntax.md) представляется как `NULL`. +Выводит каждую строку в скобках. Строки разделены запятыми. После последней строки запятой нет. Значения внутри скобок также разделены запятыми. Числа выводятся в десятичном виде без кавычек. Массивы выводятся в квадратных скобках. Строки, даты, даты-с-временем выводятся в кавычках. Правила экранирования и особенности парсинга аналогичны формату [TabSeparated](#tabseparated). При форматировании, лишние пробелы не ставятся, а при парсинге - допустимы и пропускаются (за исключением пробелов внутри значений типа массив, которые недопустимы). [NULL](../sql-reference/syntax.md) представляется как `NULL`. Минимальный набор символов, которых вам необходимо экранировать при передаче в Values формате: одинарная кавычка и обратный слеш. @@ -750,7 +750,7 @@ Array представлены как длина в формате varint (unsig Выводит каждое значение на отдельной строке, с указанием имени столбца. Формат удобно использовать для вывода одной-нескольких строк, если каждая строка состоит из большого количества столбцов. -[NULL](../sql_reference/syntax.md) выводится как `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) выводится как `ᴺᵁᴸᴸ`. Пример: @@ -928,7 +928,7 @@ message MessageType { ``` ClickHouse попытается найти столбец с именем `x.y.z` (или `x_y_z`, или `X.y_Z` и т.п.). -Вложенные сообщения удобно использовать в качестве соответствия для [вложенной структуры данных](../sql_reference/data_types/nested_data_structures/nested.md). +Вложенные сообщения удобно использовать в качестве соответствия для [вложенной структуры данных](../sql-reference/data-types/nested-data-structures/nested.md). Значения по умолчанию, определённые в схеме `proto2`, например, @@ -940,7 +940,7 @@ message MessageType { } ``` -не применяются; вместо них используются определенные в таблице [значения по умолчанию](../sql_reference/statements/create.md#create-default-values). +не применяются; вместо них используются определенные в таблице [значения по умолчанию](../sql-reference/statements/create.md#create-default-values). ClickHouse пишет и читает сообщения `Protocol Buffers` в формате `length-delimited`. Это означает, что перед каждым сообщением пишется его длина в формате [varint](https://developers.google.com/protocol-buffers/docs/encoding#varints). См. также [как читать и записывать сообщения Protocol Buffers в формате length-delimited в различных языках программирования](https://cwiki.apache.org/confluence/display/GEODE/Delimiting+Protobuf+Messages). @@ -951,25 +951,25 @@ ClickHouse пишет и читает сообщения `Protocol Buffers` в ### Соответствие типов данных {#sootvetstvie-tipov-dannykh} -Таблица ниже содержит поддерживаемые типы данных и их соответствие [типам данных](../sql_reference/data_types/index.md) ClickHouse для запросов `INSERT` и `SELECT`. +Таблица ниже содержит поддерживаемые типы данных и их соответствие [типам данных](../sql-reference/data-types/index.md) ClickHouse для запросов `INSERT` и `SELECT`. | Тип данных Parquet (`INSERT`) | Тип данных ClickHouse | Тип данных Parquet (`SELECT`) | |-------------------------------|-----------------------------------------------------------|-------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | `UINT8` | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | `INT8` | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | `UINT16` | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | `INT16` | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | `UINT32` | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | `INT32` | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | `UINT64` | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | `INT64` | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | `FLOAT` | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | `DOUBLE` | -| `DATE32` | [Date](../sql_reference/data_types/date.md) | `UINT16` | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | `UINT32` | -| `STRING`, `BINARY` | [String](../sql_reference/data_types/string.md) | `STRING` | -| — | [FixedString](../sql_reference/data_types/fixedstring.md) | `STRING` | -| `DECIMAL` | [Decimal](../sql_reference/data_types/decimal.md) | `DECIMAL` | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | `UINT8` | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | `INT8` | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | `UINT16` | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | `INT16` | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | `UINT32` | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | `INT32` | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | `UINT64` | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | `INT64` | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | `FLOAT` | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | `DOUBLE` | +| `DATE32` | [Date](../sql-reference/data-types/date.md) | `UINT16` | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | `UINT32` | +| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | `STRING` | +| — | [FixedString](../sql-reference/data-types/fixedstring.md) | `STRING` | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | `DECIMAL` | ClickHouse поддерживает настраиваемую точность для формата `Decimal`. При обработке запроса `INSERT`, ClickHouse обрабатывает тип данных Parquet `DECIMAL` как `Decimal128`. @@ -991,7 +991,7 @@ $ cat {filename} | clickhouse-client --query="INSERT INTO {some_table} FORMAT Pa $ clickhouse-client --query="SELECT * FROM {some_table} FORMAT Parquet" > {some_file.pq} ``` -Для обмена данными с экосистемой Hadoop можно использовать движки таблиц [HDFS](../engines/table_engines/integrations/hdfs.md). +Для обмена данными с экосистемой Hadoop можно использовать движки таблиц [HDFS](../engines/table-engines/integrations/hdfs.md). ## ORC {#data-format-orc} @@ -999,24 +999,24 @@ $ clickhouse-client --query="SELECT * FROM {some_table} FORMAT Parquet" > {some_ ### Соответствие типов данных {#sootvetstvie-tipov-dannykh-1} -Таблица показывает поддержанные типы данных и их соответствие [типам данных](../sql_reference/data_types/index.md) ClickHouse для запросов `INSERT`. +Таблица показывает поддержанные типы данных и их соответствие [типам данных](../sql-reference/data-types/index.md) ClickHouse для запросов `INSERT`. | Тип данных ORC (`INSERT`) | Тип данных ClickHouse | |---------------------------|-----------------------------------------------------| -| `UINT8`, `BOOL` | [UInt8](../sql_reference/data_types/int_uint.md) | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | -| `UINT16` | [UInt16](../sql_reference/data_types/int_uint.md) | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | -| `UINT32` | [UInt32](../sql_reference/data_types/int_uint.md) | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | -| `UINT64` | [UInt64](../sql_reference/data_types/int_uint.md) | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | -| `DATE32` | [Date](../sql_reference/data_types/date.md) | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | -| `STRING`, `BINARY` | [String](../sql_reference/data_types/string.md) | -| `DECIMAL` | [Decimal](../sql_reference/data_types/decimal.md) | +| `UINT8`, `BOOL` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE32` | [Date](../sql-reference/data-types/date.md) | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | +| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | ClickHouse поддерживает настраиваемую точность для формата `Decimal`. При обработке запроса `INSERT`, ClickHouse обрабатывает тип данных Parquet `DECIMAL` как `Decimal128`. @@ -1032,7 +1032,7 @@ ClickHouse поддерживает настраиваемую точность $ cat filename.orc | clickhouse-client --query="INSERT INTO some_table FORMAT ORC" ``` -Для обмена данных с Hadoop можно использовать [движок таблиц HDFS](../engines/table_engines/integrations/hdfs.md). +Для обмена данных с Hadoop можно использовать [движок таблиц HDFS](../engines/table-engines/integrations/hdfs.md). ## Схема формата {#formatschema} @@ -1045,6 +1045,6 @@ $ cat filename.orc | clickhouse-client --query="INSERT INTO some_table FORMAT OR относительно текущей директории на клиенте. Если клиент используется в [batch режиме](../interfaces/cli.md#cli_usage), то в записи схемы допускается только относительный путь, из соображений безопасности. Если для ввода/вывода данных используется [HTTP-интерфейс](../interfaces/http.md), то файл со схемой должен располагаться на сервере в каталоге, -указанном в параметре [format\_schema\_path](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-format_schema_path) конфигурации сервера. +указанном в параметре [format\_schema\_path](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-format_schema_path) конфигурации сервера. [Оригинальная статья](https://clickhouse.tech/docs/ru/interfaces/formats/) diff --git a/docs/ru/interfaces/http.md b/docs/ru/interfaces/http.md index add57183824..afe38132cc9 100644 --- a/docs/ru/interfaces/http.md +++ b/docs/ru/interfaces/http.md @@ -3,7 +3,7 @@ HTTP интерфейс позволяет использовать ClickHouse на любой платформе, из любого языка программирования. У нас он используется для работы из Java и Perl, а также из shell-скриптов. В других отделах, HTTP интерфейс используется из Perl, Python и Go. HTTP интерфейс более ограничен по сравнению с родным интерфейсом, но является более совместимым. По умолчанию, clickhouse-server слушает HTTP на порту 8123 (это можно изменить в конфиге). -Если запросить GET / без параметров, то вернётся строка заданная с помощью настройки [http\_server\_default\_response](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-http_server_default_response). Значение по умолчанию «Ok.» (с переводом строки на конце). +Если запросить GET / без параметров, то вернётся строка заданная с помощью настройки [http\_server\_default\_response](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-http_server_default_response). Значение по умолчанию «Ok.» (с переводом строки на конце). ``` bash $ curl 'http://localhost:8123/' diff --git a/docs/ru/interfaces/index.md b/docs/ru/interfaces/index.md index be49e640132..ea381c46206 100644 --- a/docs/ru/interfaces/index.md +++ b/docs/ru/interfaces/index.md @@ -1,7 +1,7 @@ --- -toc_folder_title: Интерфейсы +toc_folder_title: "\u0418\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044B" toc_priority: 14 -toc_title: Введение +toc_title: "\u0412\u0432\u0435\u0434\u0435\u043D\u0438\u0435" --- # Интерфейсы {#interfaces} @@ -20,7 +20,7 @@ ClickHouse предоставляет два сетевых интерфейса Существует также широкий спектр сторонних библиотек для работы с ClickHouse: -- [Клиентские библиотеки](third-party/client_libraries.md); +- [Клиентские библиотеки](third-party/client-libraries.md); - [Библиотеки для интеграции](third-party/integrations.md); - [Визуальные интерфейсы](third-party/gui.md). diff --git a/docs/ru/interfaces/mysql.md b/docs/ru/interfaces/mysql.md index d550b430c69..493df82be53 100644 --- a/docs/ru/interfaces/mysql.md +++ b/docs/ru/interfaces/mysql.md @@ -1,6 +1,6 @@ # MySQL-интерфейс {#mysql-interface} -ClickHouse поддерживает взаимодействие по протоколу MySQL. Данная функция включается настройкой [mysql\_port](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-mysql_port) в конфигурационном файле: +ClickHouse поддерживает взаимодействие по протоколу MySQL. Данная функция включается настройкой [mysql\_port](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-mysql_port) в конфигурационном файле: ``` xml 9004 @@ -30,8 +30,8 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` -Для совместимости со всеми клиентами рекомендуется задавать пароль пользователя в конфигурационном файле с помощью двойного хэша [SHA1](../operations/settings/settings_users.md#password_double_sha1_hex). -В случае указания пароля с помощью [SHA256](../operations/settings/settings_users.md#password_sha256_hex) некоторые клиенты не смогут пройти аутентификацию (mysqljs и старые версии стандартного клиента mysql). +Для совместимости со всеми клиентами рекомендуется задавать пароль пользователя в конфигурационном файле с помощью двойного хэша [SHA1](../operations/settings/settings-users.md#password_double_sha1_hex). +В случае указания пароля с помощью [SHA256](../operations/settings/settings-users.md#password_sha256_hex) некоторые клиенты не смогут пройти аутентификацию (mysqljs и старые версии стандартного клиента mysql). Ограничения: diff --git a/docs/ru/interfaces/third-party/client-libraries.md b/docs/ru/interfaces/third-party/client-libraries.md new file mode 100644 index 00000000000..928c1393c26 --- /dev/null +++ b/docs/ru/interfaces/third-party/client-libraries.md @@ -0,0 +1,52 @@ +# Клиентские библиотеки от сторонних разработчиков {#klientskie-biblioteki-ot-storonnikh-razrabotchikov} + +!!! warning "Disclaimer" + Яндекс не поддерживает перечисленные ниже библиотеки и не проводит тщательного тестирования для проверки их качества. + +- Python: + - [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) + - [clickhouse-driver](https://github.com/mymarilyn/clickhouse-driver) + - [clickhouse-client](https://github.com/yurial/clickhouse-client) + - [aiochclient](https://github.com/maximdanilchenko/aiochclient) +- PHP + - [smi2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) + - [8bitov/clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) + - [bozerkins/clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) + - [simpod/clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) + - [seva-code/php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) + - [SeasClick C++ client](https://github.com/SeasX/SeasClick) +- Go + - [clickhouse](https://github.com/kshvakov/clickhouse/) + - [go-clickhouse](https://github.com/roistat/go-clickhouse) + - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) + - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) +- NodeJs + - [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) + - [node-clickhouse](https://github.com/apla/node-clickhouse) +- Perl + - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) + - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) + - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) +- Ruby + - [ClickHouse (Ruby)](https://github.com/shlima/click_house) + - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) +- R + - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) + - [RClickhouse](https://github.com/IMSMWU/RClickhouse) +- Java + - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) +- Scala + - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) +- Kotlin + - [AORM](https://github.com/TanVD/AORM) +- C\# + - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) + - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) + - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) +- Elixir + - [clickhousex](https://github.com/appodeal/clickhousex/) + - [pillar](https://github.com/sofakingworld/pillar) +- Nim + - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/interfaces/third-party/client_libraries/) diff --git a/docs/ru/interfaces/third-party/client_libraries.md b/docs/ru/interfaces/third-party/client_libraries.md deleted file mode 100644 index 27fb3f67512..00000000000 --- a/docs/ru/interfaces/third-party/client_libraries.md +++ /dev/null @@ -1,51 +0,0 @@ -# Клиентские библиотеки от сторонних разработчиков {#klientskie-biblioteki-ot-storonnikh-razrabotchikov} - -!!! warning "Disclaimer" - Яндекс не поддерживает перечисленные ниже библиотеки и не проводит тщательного тестирования для проверки их качества. - -- Python: - - [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) - - [clickhouse-driver](https://github.com/mymarilyn/clickhouse-driver) - - [clickhouse-client](https://github.com/yurial/clickhouse-client) - - [aiochclient](https://github.com/maximdanilchenko/aiochclient) -- PHP - - [smi2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) - - [8bitov/clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) - - [bozerkins/clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) - - [simpod/clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) - - [seva-code/php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) - - [SeasClick C++ client](https://github.com/SeasX/SeasClick) -- Go - - [clickhouse](https://github.com/kshvakov/clickhouse/) - - [go-clickhouse](https://github.com/roistat/go-clickhouse) - - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) - - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) -- NodeJs - - [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) - - [node-clickhouse](https://github.com/apla/node-clickhouse) -- Perl - - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) - - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) - - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) -- Ruby - - [ClickHouse (Ruby)](https://github.com/shlima/click_house) - - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) -- R - - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) - - [RClickhouse](https://github.com/IMSMWU/RClickhouse) -- Java - - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) -- Scala - - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) -- Kotlin - - [AORM](https://github.com/TanVD/AORM) -- C\# - - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) - - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) - - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) -- Elixir - - [clickhousex](https://github.com/appodeal/clickhousex/) -- Nim - - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/interfaces/third-party/client_libraries/) diff --git a/docs/ru/interfaces/third-party/index.md b/docs/ru/interfaces/third-party/index.md index 8e768ad9d8e..db6e4ad0038 100644 --- a/docs/ru/interfaces/third-party/index.md +++ b/docs/ru/interfaces/third-party/index.md @@ -1,5 +1,7 @@ --- -toc_folder_title: От сторонних разработчиков +toc_folder_title: "\u041E\u0442 \u0441\u0442\u043E\u0440\u043E\u043D\u043D\u0438\u0445\ + \ \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u043E\u0432" toc_priority: 24 --- + diff --git a/docs/ru/interfaces/third-party/integrations.md b/docs/ru/interfaces/third-party/integrations.md index d16404e2f27..39449b54df8 100644 --- a/docs/ru/interfaces/third-party/integrations.md +++ b/docs/ru/interfaces/third-party/integrations.md @@ -20,6 +20,7 @@ - Очереди сообщений - [Kafka](https://kafka.apache.org) - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (использует [Go client](https://github.com/ClickHouse/clickhouse-go/)) + - [stream-loader-clickhouse](https://github.com/adform/stream-loader) - Потоковая обработка - [Flink](https://flink.apache.org) - [flink-clickhouse-sink](https://github.com/ivi-ru/flink-clickhouse-sink) @@ -38,7 +39,7 @@ - [graphouse](https://github.com/yandex/graphouse) - [carbon-clickhouse](https://github.com/lomik/carbon-clickhouse) + - [graphite-clickhouse](https://github.com/lomik/graphite-clickhouse) - - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - оптимизирует партиции таблиц [\*GraphiteMergeTree](../../engines/table_engines/mergetree_family/graphitemergetree.md#graphitemergetree) согласно правилам в [конфигурации rollup](../../engines/table_engines/mergetree_family/graphitemergetree.md#rollup-configuration) + - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - оптимизирует партиции таблиц [\*GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md#graphitemergetree) согласно правилам в [конфигурации rollup](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) - [Grafana](https://grafana.com/) - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) - [Prometheus](https://prometheus.io/) @@ -70,7 +71,7 @@ - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (использует [infi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - [pandas](https://pandas.pydata.org) - [pandahouse](https://github.com/kszucs/pandahouse) -- PHP +- PHP - [Doctrine](https://www.doctrine-project.org/) - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) - R @@ -78,7 +79,7 @@ - [RClickhouse](https://github.com/IMSMWU/RClickhouse) (использует [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) - Java - [Hadoop](http://hadoop.apache.org) - - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (использует [JDBC](../../sql_reference/table_functions/jdbc.md)) + - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (использует [JDBC](../../sql-reference/table-functions/jdbc.md)) - Scala - [Akka](https://akka.io) - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) diff --git a/docs/ru/introduction/distinctive-features.md b/docs/ru/introduction/distinctive-features.md new file mode 100644 index 00000000000..98dbe6df134 --- /dev/null +++ b/docs/ru/introduction/distinctive-features.md @@ -0,0 +1,71 @@ +# Отличительные возможности ClickHouse {#otlichitelnye-vozmozhnosti-clickhouse} + +## По-настоящему столбцовая СУБД {#po-nastoiashchemu-stolbtsovaia-subd} + +В по-настоящему столбцовой СУБД рядом со значениями не хранится никаких лишних данных. Например, должны поддерживаться значения постоянной длины, чтобы не хранить рядом со значениями типа «число» их длины. Для примера, миллиард значений типа UInt8 должен действительно занимать в несжатом виде около 1GB, иначе это сильно ударит по эффективности использования CPU. Очень важно хранить данные компактно (без «мусора») в том числе в несжатом виде, так как скорость разжатия (использование CPU) зависит, в основном, от объёма несжатых данных. + +Этот пункт пришлось выделить, так как существуют системы, которые могут хранить значения отдельных столбцов по отдельности, но не могут эффективно выполнять аналитические запросы в силу оптимизации под другой сценарий работы. Примеры: HBase, BigTable, Cassandra, HyperTable. В этих системах вы получите пропускную способность в районе сотен тысяч строк в секунду, но не сотен миллионов строк в секунду. + +Также стоит заметить, что ClickHouse является системой управления базами данных, а не одной базой данных. То есть, ClickHouse позволяет создавать таблицы и базы данных в runtime, загружать данные и выполнять запросы без переконфигурирования и перезапуска сервера. + +## Сжатие данных {#szhatie-dannykh} + +Некоторые столбцовые СУБД (InfiniDB CE, MonetDB) не используют сжатие данных. Однако сжатие данных действительно играет одну из ключевых ролей в демонстрации отличной производительности. + +## Хранение данных на диске {#khranenie-dannykh-na-diske} + +Многие столбцовые СУБД (SAP HANA, Google PowerDrill) могут работать только в оперативной памяти. Такой подход стимулирует выделять больший бюджет на оборудование, чем фактически требуется для анализа в реальном времени. ClickHouse спроектирован для работы на обычных жестких дисках, что обеспечивает низкую стоимость хранения на гигабайт данных, но SSD и дополнительная оперативная память тоже полноценно используются, если доступны. + +## Параллельная обработка запроса на многих процессорных ядрах {#parallelnaia-obrabotka-zaprosa-na-mnogikh-protsessornykh-iadrakh} + +Большие запросы естественным образом распараллеливаются, используя все необходимые ресурсы из доступных на сервере. + +## Распределённая обработка запроса на многих серверах {#raspredelionnaia-obrabotka-zaprosa-na-mnogikh-serverakh} + +Почти все перечисленные ранее столбцовые СУБД не поддерживают распределённую обработку запроса. +В ClickHouse данные могут быть расположены на разных шардах. Каждый шард может представлять собой группу реплик, которые используются для отказоустойчивости. Запрос будет выполнен на всех шардах параллельно. Это делается прозрачно для пользователя. + +## Поддержка SQL {#podderzhka-sql} + +ClickHouse поддерживает декларативный язык запросов на основе SQL и во многих случаях совпадающий с SQL стандартом. +Поддерживаются GROUP BY, ORDER BY, подзапросы в секциях FROM, IN, JOIN, а также скалярные подзапросы. +Зависимые подзапросы и оконные функции не поддерживаются. + +## Векторный движок {#vektornyi-dvizhok} + +Данные не только хранятся по столбцам, но и обрабатываются по векторам - кусочкам столбцов. За счёт этого достигается высокая эффективность по CPU. + +## Обновление данных в реальном времени {#obnovlenie-dannykh-v-realnom-vremeni} + +ClickHouse поддерживает таблицы с первичным ключом. Для того, чтобы можно было быстро выполнять запросы по диапазону первичного ключа, данные инкрементально сортируются с помощью merge дерева. За счёт этого, поддерживается постоянное добавление данных в таблицу. Блокировки при добавлении данных отсутствуют. + +## Наличие индекса {#nalichie-indeksa} + +Физическая сортировка данных по первичному ключу позволяет получать данные для конкретных его значений или их диапазонов с низкими задержками - менее десятков миллисекунд. + +## Подходит для онлайн запросов {#podkhodit-dlia-onlain-zaprosov} + +Низкие задержки позволяют не откладывать выполнение запроса и не подготавливать ответ заранее, а выполнять его именно в момент загрузки страницы пользовательского интерфейса. То есть, в режиме онлайн. + +## Поддержка приближённых вычислений {#podderzhka-priblizhionnykh-vychislenii} + +ClickHouse предоставляет различные способы разменять точность вычислений на производительность: + +1. Система содержит агрегатные функции для приближённого вычисления количества различных значений, медианы и квантилей. +2. Поддерживается возможность выполнить запрос на основе части (выборки) данных и получить приближённый результат. При этом, с диска будет считано пропорционально меньше данных. +3. Поддерживается возможность выполнить агрегацию не для всех ключей, а для ограниченного количества первых попавшихся ключей. При выполнении некоторых условий на распределение ключей в данных, это позволяет получить достаточно точный результат с использованием меньшего количества ресурсов. + +## Репликация данных и поддержка целостности {#replikatsiia-dannykh-i-podderzhka-tselostnosti} + +Используется асинхронная multimaster репликация. После записи на любую доступную реплику, данные распространяются на все остальные реплики в фоне. Система поддерживает полную идентичность данных на разных репликах. Восстановление после большинства сбоев осуществляется автоматически, а в сложных случаях — полуавтоматически. При необходимости, можно [включить кворумную запись](../operations/settings/settings.md) данных. + +Подробнее смотрите раздел [Репликация данных](../engines/table-engines/mergetree-family/replication.md). + +## Особенности, которые могут считаться недостатками {#osobennosti-clickhouse-kotorye-mogut-schitatsia-nedostatkami} + +1. Отсутствие полноценных транзакций. +2. Возможность изменять или удалять ранее записанные данные с низкими задержками и высокой частотой запросов не предоставляется. Есть массовое удаление и изменение данных для очистки более не нужного или соответствия [GDPR](https://gdpr-info.eu). +3. Разреженный индекс делает ClickHouse плохо пригодным для точечных чтений одиночных строк по своим + ключам. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/introduction/distinctive_features/) diff --git a/docs/ru/introduction/distinctive_features.md b/docs/ru/introduction/distinctive_features.md deleted file mode 100644 index 079a0667070..00000000000 --- a/docs/ru/introduction/distinctive_features.md +++ /dev/null @@ -1,71 +0,0 @@ -# Отличительные возможности ClickHouse {#otlichitelnye-vozmozhnosti-clickhouse} - -## По-настоящему столбцовая СУБД {#po-nastoiashchemu-stolbtsovaia-subd} - -В по-настоящему столбцовой СУБД рядом со значениями не хранится никаких лишних данных. Например, должны поддерживаться значения постоянной длины, чтобы не хранить рядом со значениями типа «число» их длины. Для примера, миллиард значений типа UInt8 должен действительно занимать в несжатом виде около 1GB, иначе это сильно ударит по эффективности использования CPU. Очень важно хранить данные компактно (без «мусора») в том числе в несжатом виде, так как скорость разжатия (использование CPU) зависит, в основном, от объёма несжатых данных. - -Этот пункт пришлось выделить, так как существуют системы, которые могут хранить значения отдельных столбцов по отдельности, но не могут эффективно выполнять аналитические запросы в силу оптимизации под другой сценарий работы. Примеры: HBase, BigTable, Cassandra, HyperTable. В этих системах вы получите пропускную способность в районе сотен тысяч строк в секунду, но не сотен миллионов строк в секунду. - -Также стоит заметить, что ClickHouse является системой управления базами данных, а не одной базой данных. То есть, ClickHouse позволяет создавать таблицы и базы данных в runtime, загружать данные и выполнять запросы без переконфигурирования и перезапуска сервера. - -## Сжатие данных {#szhatie-dannykh} - -Некоторые столбцовые СУБД (InfiniDB CE, MonetDB) не используют сжатие данных. Однако сжатие данных действительно играет одну из ключевых ролей в демонстрации отличной производительности. - -## Хранение данных на диске {#khranenie-dannykh-na-diske} - -Многие столбцовые СУБД (SAP HANA, Google PowerDrill) могут работать только в оперативной памяти. Такой подход стимулирует выделять больший бюджет на оборудование, чем фактически требуется для анализа в реальном времени. ClickHouse спроектирован для работы на обычных жестких дисках, что обеспечивает низкую стоимость хранения на гигабайт данных, но SSD и дополнительная оперативная память тоже полноценно используются, если доступны. - -## Параллельная обработка запроса на многих процессорных ядрах {#parallelnaia-obrabotka-zaprosa-na-mnogikh-protsessornykh-iadrakh} - -Большие запросы естественным образом распараллеливаются, используя все необходимые ресурсы из доступных на сервере. - -## Распределённая обработка запроса на многих серверах {#raspredelionnaia-obrabotka-zaprosa-na-mnogikh-serverakh} - -Почти все перечисленные ранее столбцовые СУБД не поддерживают распределённую обработку запроса. -В ClickHouse данные могут быть расположены на разных шардах. Каждый шард может представлять собой группу реплик, которые используются для отказоустойчивости. Запрос будет выполнен на всех шардах параллельно. Это делается прозрачно для пользователя. - -## Поддержка SQL {#podderzhka-sql} - -ClickHouse поддерживает декларативный язык запросов на основе SQL и во многих случаях совпадающий с SQL стандартом. -Поддерживаются GROUP BY, ORDER BY, подзапросы в секциях FROM, IN, JOIN, а также скалярные подзапросы. -Зависимые подзапросы и оконные функции не поддерживаются. - -## Векторный движок {#vektornyi-dvizhok} - -Данные не только хранятся по столбцам, но и обрабатываются по векторам - кусочкам столбцов. За счёт этого достигается высокая эффективность по CPU. - -## Обновление данных в реальном времени {#obnovlenie-dannykh-v-realnom-vremeni} - -ClickHouse поддерживает таблицы с первичным ключом. Для того, чтобы можно было быстро выполнять запросы по диапазону первичного ключа, данные инкрементально сортируются с помощью merge дерева. За счёт этого, поддерживается постоянное добавление данных в таблицу. Блокировки при добавлении данных отсутствуют. - -## Наличие индекса {#nalichie-indeksa} - -Физическая сортировка данных по первичному ключу позволяет получать данные для конкретных его значений или их диапазонов с низкими задержками - менее десятков миллисекунд. - -## Подходит для онлайн запросов {#podkhodit-dlia-onlain-zaprosov} - -Низкие задержки позволяют не откладывать выполнение запроса и не подготавливать ответ заранее, а выполнять его именно в момент загрузки страницы пользовательского интерфейса. То есть, в режиме онлайн. - -## Поддержка приближённых вычислений {#podderzhka-priblizhionnykh-vychislenii} - -ClickHouse предоставляет различные способы разменять точность вычислений на производительность: - -1. Система содержит агрегатные функции для приближённого вычисления количества различных значений, медианы и квантилей. -2. Поддерживается возможность выполнить запрос на основе части (выборки) данных и получить приближённый результат. При этом, с диска будет считано пропорционально меньше данных. -3. Поддерживается возможность выполнить агрегацию не для всех ключей, а для ограниченного количества первых попавшихся ключей. При выполнении некоторых условий на распределение ключей в данных, это позволяет получить достаточно точный результат с использованием меньшего количества ресурсов. - -## Репликация данных и поддержка целостности {#replikatsiia-dannykh-i-podderzhka-tselostnosti} - -Используется асинхронная multimaster репликация. После записи на любую доступную реплику, данные распространяются на все остальные реплики в фоне. Система поддерживает полную идентичность данных на разных репликах. Восстановление после большинства сбоев осуществляется автоматически, а в сложных случаях — полуавтоматически. При необходимости, можно [включить кворумную запись](../operations/settings/settings.md) данных. - -Подробнее смотрите раздел [Репликация данных](../engines/table_engines/mergetree_family/replication.md). - -## Особенности, которые могут считаться недостатками {#osobennosti-clickhouse-kotorye-mogut-schitatsia-nedostatkami} - -1. Отсутствие полноценных транзакций. -2. Возможность изменять или удалять ранее записанные данные с низкими задержками и высокой частотой запросов не предоставляется. Есть массовое удаление и изменение данных для очистки более не нужного или соответствия [GDPR](https://gdpr-info.eu). -3. Разреженный индекс делает ClickHouse плохо пригодным для точечных чтений одиночных строк по своим - ключам. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/introduction/distinctive_features/) diff --git a/docs/ru/introduction/index.md b/docs/ru/introduction/index.md index 5479b37428f..28a8e10e15b 100644 --- a/docs/ru/introduction/index.md +++ b/docs/ru/introduction/index.md @@ -1,5 +1,5 @@ --- -toc_folder_title: Введение +toc_folder_title: "\u0412\u0432\u0435\u0434\u0435\u043D\u0438\u0435" toc_priority: 1 --- diff --git a/docs/ru/introduction/info.md b/docs/ru/introduction/info.md index bd95c825f21..14e517eebae 100644 --- a/docs/ru/introduction/info.md +++ b/docs/ru/introduction/info.md @@ -1,3 +1,7 @@ +--- +toc_priority: 100 +--- + # Информационная поддержка {#informatsionnaia-podderzhka} Информационная поддержка ClickHouse осуществляется на всей территории Российской Федерации без ограничений посредством использования телефонной связи и средств электронной почты на русском языке в круглосуточном режиме: @@ -5,6 +9,4 @@ - Адрес электронной почты: - Телефон: 8-800-250-96-39 (звонки бесплатны из всех регионов России) -

















- [Оригинальная статья](https://clickhouse.tech/docs/ru/introduction/info/) diff --git a/docs/ru/operations/access-rights.md b/docs/ru/operations/access-rights.md new file mode 100644 index 00000000000..99da2550e70 --- /dev/null +++ b/docs/ru/operations/access-rights.md @@ -0,0 +1,143 @@ +# Управление доступом {#access-control} + +ClickHouse поддерживает управление доступом на основе подхода [RBAC](https://ru.wikipedia.org/wiki/Управление_доступом_на_основе_ролей). + +Объекты системы доступа в ClickHouse: + +- [Аккаунт пользователя](#user-account-management) +- [Роль](#role-management) +- [Политика доступа к строкам](#row-policy-management) +- [Профиль настроек](#settings-profiles-management) +- [Квота](#quotas-management) + +Вы можете настроить объекты системы доступа, используя: + +- SQL-ориентированный воркфлоу. + + Функциональность необходимо [включить](#enabling-access-control). + +- [Конфигурационные файлы](configuration-files.md) сервера: `users.xml` и `config.xml`. + +Рекомендуется использовать SQL-воркфлоу. Оба метода конфигурации работают одновременно, поэтому, если для управления доступом вы используете конфигурационные файлы, вы можете плавно перейти на SQL-воркфлоу. + +!!! note "Внимание" + Нельзя одновременно использовать оба метода для управления одним и тем же объектом системы доступа. + + +## Использование {#access-control-usage} + +По умолчанию сервер ClickHouse предоставляет аккаунт пользователя `default`, для которого выключена функция SQL-ориентированного управления доступом, но у него есть все права и разрешения. Аккаунт `default` используется во всех случаях, когда имя пользователя не определено. Например, при входе с клиента или в распределенных запросах. При распределенной обработке запроса `default` используется, если в конфигурации сервера или кластера не указаны свойства [user и password](../engines/table-engines/special/distributed.md). + +Если вы начали пользоваться ClickHouse недавно, попробуйте следующий сценарий: + +1. [Включите](#enabling-access-control) SQL-ориентированное управление доступом для пользователя `default`. +2. Войдите под пользователем `default` и создайте всех необходимых пользователей. Не забудьте создать аккаунт администратора (`GRANT ALL ON *.* WITH GRANT OPTION TO admin_user_account`). +3. [Ограничьте разрешения](settings/permissions-for-queries.md#permissions_for_queries) для пользователя `default` и отключите для него SQL-ориентированное управление доступом. + +### Особенности реализации {#access-control-properties} + +- Вы можете выдавать разрешения на базы данных или таблицы, даже если они не существуют. +- При удалении таблицы все связанные с ней привилегии не отзываются. Если вы затем создадите новую таблицу с таким же именем, все привилегии останутся действительными. Чтобы отозвать привилегии, связанные с удаленной таблицей, необходимо выполнить, например, запрос `REVOKE ALL PRIVILEGES ON db.table FROM ALL`. +- У привилегий нет настроек времени жизни. + +## Аккаунт пользователя {#user-account-management} + +Аккаунт пользователя — это объект системы доступа, позволяющий авторизовать кого-либо в ClickHouse. Аккаунт содержит: + +- Идентификационную информацию. +- [Привилегии](../sql-reference/statements/grant.md#grant-privileges), определяющие область действия запросов, которые могут быть выполнены пользователем. +- Хосты, которые могут подключаться к серверу ClickHouse. +- Назначенные роли и роли по умолчанию. +- Настройки и их ограничения, которые применяются по умолчанию при входе пользователя. +- Присвоенные профили настроек. + +Привилегии присваиваются аккаунту пользователя с помощью запроса [GRANT](../sql-reference/statements/grant.md) или через назначение [ролей](#role-management). Отозвать привилегию можно с помощью запроса [REVOKE](../sql-reference/statements/revoke.md). Чтобы вывести список присвоенных привилегий, используется выражение [SHOW GRANTS](../sql-reference/statements/show.md#show-grants-statement). + +Запросы управления: + +- [CREATE USER](../sql-reference/statements/create.md#create-user-statement) +- [ALTER USER](../sql-reference/statements/alter.md#alter-user-statement) +- [DROP USER](../sql-reference/statements/misc.md#drop-user-statement) +- [SHOW CREATE USER](../sql-reference/statements/show.md#show-create-user-statement) + +### Применение настроек {#access-control-settings-applying} + +Настройки могут быть заданы разными способами: для аккаунта пользователя, для назначенных ему ролей или в профилях настроек. При входе пользователя, если настройка задана для разных объектов системы доступа, значение настройки и ее ограничения применяются в следующем порядке (от высшего приоритета к низшему): + +1. Настройки аккаунта. +2. Настройки ролей по умолчанию для аккаунта. Если настройка задана для нескольких ролей, порядок применения не определен. +3. Настройки из профилей настроек, присвоенных пользователю или его ролям по умолчанию. Если настройка задана в нескольких профилях, порядок применения не определен. +4. Настройки, которые по умолчанию применяются ко всему серверу, или настройки из [профиля по умолчанию](server-configuration-parameters/settings.md#default-profile). + + +## Роль {#role-management} + +Роль — это контейнер объектов системы доступа, которые можно присвоить аккаунту пользователя. + +Роль содержит: + +- [Привилегии](../sql-reference/statements/grant.md#grant-privileges) +- Настройки и ограничения +- Список назначенных ролей + +Запросы управления: + +- [CREATE ROLE](../sql-reference/statements/create.md#create-role-statement) +- [ALTER ROLE](../sql-reference/statements/alter.md#alter-role-statement) +- [DROP ROLE](../sql-reference/statements/misc.md#drop-role-statement) +- [SET ROLE](../sql-reference/statements/misc.md#set-role-statement) +- [SET DEFAULT ROLE](../sql-reference/statements/misc.md#set-default-role-statement) +- [SHOW CREATE ROLE](../sql-reference/statements/show.md#show-create-role-statement) + +Привилегии можно присвоить роли с помощью запроса [GRANT](../sql-reference/statements/grant.md). Для отзыва привилегий у роли ClickHouse предоставляет запрос [REVOKE](../sql-reference/statements/revoke.md). + +## Политика доступа к строкам {#row-policy-management} + +Политика доступа к строкам — это фильтр, определяющий, какие строки доступны пользователю или роли. Политика содержит фильтры для конкретной таблицы, а также список ролей и/или пользователей, которые должны использовать данную политику. + +Запросы управления: + +- [CREATE ROW POLICY](../sql-reference/statements/create.md#create-row-policy-statement) +- [ALTER ROW POLICY](../sql-reference/statements/alter.md#alter-row-policy-statement) +- [DROP ROW POLICY](../sql-reference/statements/misc.md#drop-row-policy-statement) +- [SHOW CREATE ROW POLICY](../sql-reference/statements/show.md#show-create-row-policy-statement) + + +## Профиль настроек {#settings-profiles-management} + +Профиль настроек — это набор [настроек](settings/index.md). Профиль настроек содержит настройки и ограничения, а также список ролей и/или пользователей, по отношению к которым применяется данный профиль. + +Запросы управления: + +- [CREATE SETTINGS PROFILE](../sql-reference/statements/create.md#create-settings-profile-statement) +- [ALTER SETTINGS PROFILE](../sql-reference/statements/alter.md#alter-settings-profile-statement) +- [DROP SETTINGS PROFILE](../sql-reference/statements/misc.md#drop-settings-profile-statement) +- [SHOW CREATE SETTINGS PROFILE](../sql-reference/statements/show.md#show-create-settings-profile-statement) + + +## Квота {#quotas-management} + +Квота ограничивает использование ресурсов. См. [Квоты](quotas.md). + +Квота содержит набор ограничений определенной длительности, а также список ролей и/или пользователей, на которых распространяется данная квота. + +Запросы управления: + +- [CREATE QUOTA](../sql-reference/statements/create.md#create-quota-statement) +- [ALTER QUOTA](../sql-reference/statements/alter.md#alter-quota-statement) +- [DROP QUOTA](../sql-reference/statements/misc.md#drop-quota-statement) +- [SHOW CREATE QUOTA](../sql-reference/statements/show.md#show-create-quota-statement) + + +## Включение SQL-ориентированного управления доступом {#enabling-access-control} + +- Настройте каталог для хранения конфигураций. + + ClickHouse хранит конфигурации объектов системы доступа в каталоге, установленном в конфигурационном параметре сервера [access_control_path](server-configuration-parameters/settings.md#access_control_path). + +- Включите SQL-ориентированное управление доступом как минимум для одного аккаунта. + + По умолчанию управление доступом на основе SQL выключено для всех пользователей. Вам необходимо настроить хотя бы одного пользователя в файле конфигурации `users.xml` и присвоить значение 1 параметру [access_management](settings/settings-users.md#access_management-user-setting). + + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/access_rights/) diff --git a/docs/ru/operations/access_rights.md b/docs/ru/operations/access_rights.md deleted file mode 100644 index 18c2a25377a..00000000000 --- a/docs/ru/operations/access_rights.md +++ /dev/null @@ -1,101 +0,0 @@ -# Права доступа {#prava-dostupa} - -Пользователи и права доступа настраиваются в конфиге пользователей. Обычно это `users.xml`. - -Пользователи прописаны в секции `users`. Рассмотрим фрагмент файла `users.xml`: - -``` xml - - - - - - - - - - - - default - - - default - - - - - - - web - default - - test - - -``` - -Здесь видно объявление двух пользователей - `default` и `web`. Пользователя `web` мы добавили самостоятельно. - -Пользователь `default` выбирается в случаях, когда имя пользователя не передаётся. Также пользователь `default` может использоваться при распределённой обработке запроса - если в конфигурации кластера для сервера не указаны `user` и `password`. (см. раздел о движке [Distributed](../engines/table_engines/special/distributed.md)). - -Пользователь, который используется для обмена информацией между серверами, объединенными в кластер, не должен иметь существенных ограничений или квот - иначе распределённые запросы сломаются. - -Пароль указывается либо в открытом виде (не рекомендуется), либо в виде SHA-256. Хэш не содержит соль. В связи с этим, не следует рассматривать такие пароли, как защиту от потенциального злоумышленника. Скорее, они нужны для защиты от сотрудников. - -Указывается список сетей, из которых разрешён доступ. В этом примере, список сетей для обеих пользователей, загружается из отдельного файла (`/etc/metrika.xml`), содержащего подстановку `networks`. Вот его фрагмент: - -``` xml - - ... - - ::/64 - 203.0.113.0/24 - 2001:DB8::/32 - ... - - -``` - -Можно было бы указать этот список сетей непосредственно в `users.xml`, или в файле в директории `users.d` (подробнее смотрите раздел «[Конфигурационные файлы](configuration_files.md#configuration_files)»). - -В конфиге приведён комментарий, указывающий, как можно открыть доступ отовсюду. - -Для продакшен использования, указывайте только элементы вида `ip` (IP-адреса и их маски), так как использование `host` и `host_regexp` может вызывать лишние задержки. - -Далее указывается используемый профиль настроек пользователя (смотрите раздел «[Профили настроек](settings/settings_profiles.md)»). Вы можете указать профиль по умолчанию - `default`. Профиль может называться как угодно; один и тот же профиль может быть указан для разных пользователей. Наиболее важная вещь, которую вы можете прописать в профиле настроек `readonly=1`, что обеспечивает доступ только на чтение. -Затем указывается используемая квота (смотрите раздел «[Квоты](quotas.md#quotas)»). Вы можете указать квоту по умолчанию — `default`. Она настроена в конфиге по умолчанию так, что только считает использование ресурсов, но никак их не ограничивает. Квота может называться как угодно. Одна и та же квота может быть указана для разных пользователей, в этом случае подсчёт использования ресурсов делается для каждого пользователя по отдельности. - -Также, в необязательном разделе `` можно указать перечень баз, к которым у пользователя будет доступ. По умолчанию пользователю доступны все базы. Можно указать базу данных `default`, в этом случае пользователь получит доступ к базе данных по умолчанию. - -Доступ к БД `system` всегда считается разрешённым (так как эта БД используется для выполнения запросов). - -Пользователь может получить список всех БД и таблиц в них с помощью запросов `SHOW` или системных таблиц, даже если у него нет доступа к отдельным БД. - -Доступ к БД не связан с настройкой [readonly](settings/permissions_for_queries.md#settings_readonly). Невозможно дать полный доступ к одной БД и `readonly` к другой. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/access_rights/) diff --git a/docs/ru/operations/backup.md b/docs/ru/operations/backup.md index 601eaa4d6d9..6badaa7f724 100644 --- a/docs/ru/operations/backup.md +++ b/docs/ru/operations/backup.md @@ -1,6 +1,6 @@ # Резервное копирование данных {#rezervnoe-kopirovanie-dannykh} -[Репликация](../engines/table_engines/mergetree_family/replication.md) обеспечивает защиту от аппаратных сбоев, но не защищает от человеческих ошибок: случайного удаления данных, удаления не той таблицы, которую надо было, или таблицы на не том кластере, а также программных ошибок, которые приводят к неправильной обработке данных или их повреждению. Во многих случаях подобные ошибки влияют на все реплики. ClickHouse имеет встроенные средства защиты для предотвращения некоторых типов ошибок — например, по умолчанию [не получится удалить таблицы \*MergeTree, содержащие более 50 Гб данных, одной командой](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Однако эти средства защиты не охватывают все возможные случаи и могут быть обойдены. +[Репликация](../engines/table-engines/mergetree-family/replication.md) обеспечивает защиту от аппаратных сбоев, но не защищает от человеческих ошибок: случайного удаления данных, удаления не той таблицы, которую надо было, или таблицы на не том кластере, а также программных ошибок, которые приводят к неправильной обработке данных или их повреждению. Во многих случаях подобные ошибки влияют на все реплики. ClickHouse имеет встроенные средства защиты для предотвращения некоторых типов ошибок — например, по умолчанию [не получится удалить таблицы \*MergeTree, содержащие более 50 Гб данных, одной командой](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Однако эти средства защиты не охватывают все возможные случаи и могут быть обойдены. Для того чтобы эффективно уменьшить возможные человеческие ошибки, следует тщательно подготовить стратегию резервного копирования и восстановления данных **заранее**. @@ -15,7 +15,7 @@ ## Снимки файловой системы {#snimki-failovoi-sistemy} -Некоторые локальные файловые системы позволяют делать снимки (например, [ZFS](https://en.wikipedia.org/wiki/ZFS)), но они могут быть не лучшим выбором для обслуживания живых запросов. Возможным решением является создание дополнительных реплик с такой файловой системой и исключение их из [Distributed](../engines/table_engines/special/distributed.md) таблиц, используемых для запросов `SELECT`. Снимки на таких репликах будут недоступны для запросов, изменяющих данные. В качестве бонуса, эти реплики могут иметь особые конфигурации оборудования с большим количеством дисков, подключенных к серверу, что будет экономически эффективным. +Некоторые локальные файловые системы позволяют делать снимки (например, [ZFS](https://en.wikipedia.org/wiki/ZFS)), но они могут быть не лучшим выбором для обслуживания живых запросов. Возможным решением является создание дополнительных реплик с такой файловой системой и исключение их из [Distributed](../engines/table-engines/special/distributed.md) таблиц, используемых для запросов `SELECT`. Снимки на таких репликах будут недоступны для запросов, изменяющих данные. В качестве бонуса, эти реплики могут иметь особые конфигурации оборудования с большим количеством дисков, подключенных к серверу, что будет экономически эффективным. ## clickhouse-copier {#clickhouse-copier} @@ -27,7 +27,7 @@ ClickHouse позволяет использовать запрос `ALTER TABLE ... FREEZE PARTITION ...` для создания локальной копии партиций таблицы. Это реализуется с помощью жестких ссылок (hardlinks) на каталог `/var/lib/clickhouse/shadow/`, поэтому такая копия обычно не занимает дополнительное место на диске для старых данных. Созданные копии файлов не обрабатываются сервером ClickHouse, поэтому вы можете просто оставить их там: у вас будет простая резервная копия, которая не требует дополнительной внешней системы, однако при аппаратных проблемах вы можете утратить и актуальные данные и сохраненную копию. По этой причине, лучше удаленно скопировать их в другое место, а затем удалить локальную копию. Распределенные файловые системы и хранилища объектов по-прежнему являются хорошими вариантами для этого, однако можно использовать и обычные присоединенные файловые серверы с достаточно большой ёмкостью (в этом случае передача будет происходить через сетевую файловую систему или, возможно, [rsync](https://en.wikipedia.org/wiki/Rsync)). -Дополнительные сведения о запросах, связанных с манипуляциями партициями, см. в разделе [ALTER](../sql_reference/statements/alter.md#alter_manipulations-with-partitions). +Дополнительные сведения о запросах, связанных с манипуляциями партициями, см. в разделе [ALTER](../sql-reference/statements/alter.md#alter_manipulations-with-partitions). Для автоматизации этого подхода доступен инструмент от сторонних разработчиков: [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup). diff --git a/docs/ru/operations/configuration-files.md b/docs/ru/operations/configuration-files.md new file mode 100644 index 00000000000..f9c8f3f57a6 --- /dev/null +++ b/docs/ru/operations/configuration-files.md @@ -0,0 +1,46 @@ +# Конфигурационные файлы {#configuration_files} + +Основной конфигурационный файл сервера - `config.xml`. Он расположен в директории `/etc/clickhouse-server/`. + +Отдельные настройки могут быть переопределены в файлах `*.xml` и `*.conf` из директории `config.d` рядом с конфигом. + +У элементов этих конфигурационных файлов могут быть указаны атрибуты `replace` или `remove`. + +Если ни один не указан - объединить содержимое элементов рекурсивно с заменой значений совпадающих детей. + +Если указано `replace` - заменить весь элемент на указанный. + +Если указано `remove` - удалить элемент. + +Также в конфиге могут быть указаны «подстановки». Если у элемента присутствует атрибут `incl`, то в качестве значения будет использована соответствующая подстановка из файла. По умолчанию, путь к файлу с подстановками - `/etc/metrika.xml`. Он может быть изменён в конфигурации сервера в элементе [include\_from](server-configuration-parameters/settings.md#server_configuration_parameters-include_from). Значения подстановок указываются в элементах `/yandex/имя_подстановки` этого файла. Если подстановка, заданная в `incl` отсутствует, то в лог попадает соответствующая запись. Чтобы ClickHouse не писал в лог об отсутствии подстановки, необходимо указать атрибут `optional="true"` (например, настройка [macros](server-configuration-parameters/settings.md)). + +Подстановки могут также выполняться из ZooKeeper. Для этого укажите у элемента атрибут `from_zk = "/path/to/node"`. Значение элемента заменится на содержимое узла `/path/to/node` в ZooKeeper. В ZooKeeper-узел также можно положить целое XML-поддерево, оно будет целиком вставлено в исходный элемент. + +В `config.xml` может быть указан отдельный конфиг с настройками пользователей, профилей и квот. Относительный путь к нему указывается в элементе users\_config. По умолчанию - `users.xml`. Если `users_config` не указан, то настройки пользователей, профилей и квот, указываются непосредственно в `config.xml`. + +Для `users_config` могут также существовать переопределения в файлах из директории `users_config.d` (например, `users.d`) и подстановки. Например, можно иметь по отдельному конфигурационному файлу для каждого пользователя: + +``` bash +$ cat /etc/clickhouse-server/users.d/alice.xml +``` + +``` xml + + + + analytics + + ::/0 + + ... + analytics + + + +``` + +Для каждого конфигурационного файла, сервер при запуске генерирует также файлы `file-preprocessed.xml`. Эти файлы содержат все выполненные подстановки и переопределения, и предназначены для информационных целей. Если в конфигурационных файлах были использованы ZooKeeper-подстановки, но при старте сервера ZooKeeper недоступен, то сервер загрузит конфигурацию из preprocessed-файла. + +Сервер следит за изменениями конфигурационных файлов, а также файлов и ZooKeeper-узлов, которые были использованы при выполнении подстановок и переопределений, и перезагружает настройки пользователей и кластеров на лету. То есть, можно изменять кластера, пользователей и их настройки без перезапуска сервера. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/configuration_files/) diff --git a/docs/ru/operations/configuration_files.md b/docs/ru/operations/configuration_files.md deleted file mode 100644 index 19f7ea9d5db..00000000000 --- a/docs/ru/operations/configuration_files.md +++ /dev/null @@ -1,46 +0,0 @@ -# Конфигурационные файлы {#configuration_files} - -Основной конфигурационный файл сервера - `config.xml`. Он расположен в директории `/etc/clickhouse-server/`. - -Отдельные настройки могут быть переопределены в файлах `*.xml` и `*.conf` из директории `config.d` рядом с конфигом. - -У элементов этих конфигурационных файлов могут быть указаны атрибуты `replace` или `remove`. - -Если ни один не указан - объединить содержимое элементов рекурсивно с заменой значений совпадающих детей. - -Если указано `replace` - заменить весь элемент на указанный. - -Если указано `remove` - удалить элемент. - -Также в конфиге могут быть указаны «подстановки». Если у элемента присутствует атрибут `incl`, то в качестве значения будет использована соответствующая подстановка из файла. По умолчанию, путь к файлу с подстановками - `/etc/metrika.xml`. Он может быть изменён в конфигурации сервера в элементе [include\_from](server_configuration_parameters/settings.md#server_configuration_parameters-include_from). Значения подстановок указываются в элементах `/yandex/имя_подстановки` этого файла. Если подстановка, заданная в `incl` отсутствует, то в лог попадает соответствующая запись. Чтобы ClickHouse не писал в лог об отсутствии подстановки, необходимо указать атрибут `optional="true"` (например, настройка [macros](server_configuration_parameters/settings.md)). - -Подстановки могут также выполняться из ZooKeeper. Для этого укажите у элемента атрибут `from_zk = "/path/to/node"`. Значение элемента заменится на содержимое узла `/path/to/node` в ZooKeeper. В ZooKeeper-узел также можно положить целое XML-поддерево, оно будет целиком вставлено в исходный элемент. - -В `config.xml` может быть указан отдельный конфиг с настройками пользователей, профилей и квот. Относительный путь к нему указывается в элементе users\_config. По умолчанию - `users.xml`. Если `users_config` не указан, то настройки пользователей, профилей и квот, указываются непосредственно в `config.xml`. - -Для `users_config` могут также существовать переопределения в файлах из директории `users_config.d` (например, `users.d`) и подстановки. Например, можно иметь по отдельному конфигурационному файлу для каждого пользователя: - -``` bash -$ cat /etc/clickhouse-server/users.d/alice.xml -``` - -``` xml - - - - analytics - - ::/0 - - ... - analytics - - - -``` - -Для каждого конфигурационного файла, сервер при запуске генерирует также файлы `file-preprocessed.xml`. Эти файлы содержат все выполненные подстановки и переопределения, и предназначены для информационных целей. Если в конфигурационных файлах были использованы ZooKeeper-подстановки, но при старте сервера ZooKeeper недоступен, то сервер загрузит конфигурацию из preprocessed-файла. - -Сервер следит за изменениями конфигурационных файлов, а также файлов и ZooKeeper-узлов, которые были использованы при выполнении подстановок и переопределений, и перезагружает настройки пользователей и кластеров на лету. То есть, можно изменять кластера, пользователей и их настройки без перезапуска сервера. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/configuration_files/) diff --git a/docs/ru/operations/index.md b/docs/ru/operations/index.md index babb22cd8b4..f3f90aec7c3 100644 --- a/docs/ru/operations/index.md +++ b/docs/ru/operations/index.md @@ -1,26 +1,26 @@ --- -toc_folder_title: Эксплуатация +toc_folder_title: "\u042d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u044f" toc_priority: 41 -toc_title: Введение +toc_title: intro --- -# Эксплуатация {#ekspluatatsiia} +# Эксплуатация {#operations} Руководство по эксплуатации ClickHouse состоит из следующих основных разделов: - - [Требования](requirements.md) - - [Мониторинг](monitoring.md) - - [Решение проблем](troubleshooting.md) - - [Советы по эксплуатации](tips.md) - - [Процедура обновления](update.md) - - [Права доступа](access_rights.md) - - [Резервное копирование](backup.md) - - [Конфигурационные файлы](configuration_files.md) - - [Квоты](quotas.md) - - [Системные таблицы](system_tables.md) - - [Конфигурационные параметры сервера](server_configuration_parameters/index.md) - - [Тестирование севреров с помощью ClickHouse](performance_test.md) - - [Настройки](settings/index.md) - - [Утилиты](utils/index.md) +- [Требования](requirements.md) +- [Мониторинг](monitoring.md) +- [Решение проблем](troubleshooting.md) +- [Советы по эксплуатации](tips.md) +- [Процедура обновления](update.md) +- [Права доступа](access-rights.md) +- [Резервное копирование](backup.md) +- [Конфигурационные файлы](configuration-files.md) +- [Квоты](quotas.md) +- [Системные таблицы](system-tables.md) +- [Конфигурационные параметры сервера](server-configuration-parameters/index.md) +- [Тестирование серверов с помощью ClickHouse](performance-test.md) +- [Настройки](settings/index.md#settings) +- [Утилиты](utilities/index.md) [Оригинальная статья](https://clickhouse.tech/docs/ru/operations/) diff --git a/docs/ru/operations/monitoring.md b/docs/ru/operations/monitoring.md index 2629a4da931..3082e6275da 100644 --- a/docs/ru/operations/monitoring.md +++ b/docs/ru/operations/monitoring.md @@ -21,18 +21,18 @@ ClickHouse не отслеживает состояние аппаратных Сервер ClickHouse имеет встроенные инструменты мониторинга. -Для отслеживания событий на сервере используйте логи. Подробнее смотрите в разделе конфигурационного файла [logger](server_configuration_parameters/settings.md#server_configuration_parameters-logger). +Для отслеживания событий на сервере используйте логи. Подробнее смотрите в разделе конфигурационного файла [logger](server-configuration-parameters/settings.md#server_configuration_parameters-logger). ClickHouse собирает: - Различные метрики того, как сервер использует вычислительные ресурсы. - Общую статистику обработки запросов. -Метрики находятся в таблицах [system.metrics](system_tables.md#system_tables-metrics), [system.events](system_tables.md#system_tables-events) и [system.asynchronous\_metrics](system_tables.md#system_tables-asynchronous_metrics). +Метрики находятся в таблицах [system.metrics](system-tables.md#system_tables-metrics), [system.events](system-tables.md#system_tables-events) и [system.asynchronous\_metrics](system-tables.md#system_tables-asynchronous_metrics). -Можно настроить экспорт метрик из ClickHouse в [Graphite](https://github.com/graphite-project). Смотрите секцию [graphite](server_configuration_parameters/settings.md#server_configuration_parameters-graphite) конфигурационного файла ClickHouse. Перед настройкой экспорта метрик необходимо настроить Graphite, как указано в [официальном руководстве](https://graphite.readthedocs.io/en/latest/install.html). +Можно настроить экспорт метрик из ClickHouse в [Graphite](https://github.com/graphite-project). Смотрите секцию [graphite](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) конфигурационного файла ClickHouse. Перед настройкой экспорта метрик необходимо настроить Graphite, как указано в [официальном руководстве](https://graphite.readthedocs.io/en/latest/install.html). -Можно настроить экспорт метрик из ClickHouse в [Prometheus](https://prometheus.io). Смотрите [prometheus](server_configuration_parameters/settings.md#server_configuration_parameters-prometheus) конфигурационного файла ClickHouse. Перед настройкой экспорта метрик необходимо настроить Prometheus, как указано в [официальном руководстве](https://prometheus.io/docs/prometheus/latest/installation/). +Можно настроить экспорт метрик из ClickHouse в [Prometheus](https://prometheus.io). Смотрите [prometheus](server-configuration-parameters/settings.md#server_configuration_parameters-prometheus) конфигурационного файла ClickHouse. Перед настройкой экспорта метрик необходимо настроить Prometheus, как указано в [официальном руководстве](https://prometheus.io/docs/prometheus/latest/installation/). Также, можно отслеживать доступность сервера через HTTP API. Отправьте `HTTP GET` к ресурсу `/ping`. Если сервер доступен, он отвечает `200 OK`. diff --git a/docs/ru/operations/optimizing-performance/index.md b/docs/ru/operations/optimizing-performance/index.md new file mode 100644 index 00000000000..6e6cef109c1 --- /dev/null +++ b/docs/ru/operations/optimizing-performance/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Optimizing Performance +toc_priority: 52 +--- + + diff --git a/docs/ru/operations/optimizing-performance/sampling-query-profiler.md b/docs/ru/operations/optimizing-performance/sampling-query-profiler.md new file mode 120000 index 00000000000..fe5373bfe13 --- /dev/null +++ b/docs/ru/operations/optimizing-performance/sampling-query-profiler.md @@ -0,0 +1 @@ +../../../en/operations/optimizing-performance/sampling-query-profiler.md \ No newline at end of file diff --git a/docs/ru/operations/optimizing_performance/index.md b/docs/ru/operations/optimizing_performance/index.md deleted file mode 100644 index 4f4cbb66d24..00000000000 --- a/docs/ru/operations/optimizing_performance/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Optimizing Performance -toc_priority: 52 ---- - diff --git a/docs/ru/operations/optimizing_performance/sampling_query_profiler.md b/docs/ru/operations/optimizing_performance/sampling_query_profiler.md deleted file mode 120000 index 9f3b57cd086..00000000000 --- a/docs/ru/operations/optimizing_performance/sampling_query_profiler.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/operations/optimizing_performance/sampling_query_profiler.md \ No newline at end of file diff --git a/docs/ru/operations/performance-test.md b/docs/ru/operations/performance-test.md new file mode 120000 index 00000000000..a5b151dc417 --- /dev/null +++ b/docs/ru/operations/performance-test.md @@ -0,0 +1 @@ +../../en/operations/performance-test.md \ No newline at end of file diff --git a/docs/ru/operations/performance_test.md b/docs/ru/operations/performance_test.md deleted file mode 120000 index a74c126c63f..00000000000 --- a/docs/ru/operations/performance_test.md +++ /dev/null @@ -1 +0,0 @@ -../../en/operations/performance_test.md \ No newline at end of file diff --git a/docs/ru/operations/requirements.md b/docs/ru/operations/requirements.md index e6bc2f15e43..459ccf4de25 100644 --- a/docs/ru/operations/requirements.md +++ b/docs/ru/operations/requirements.md @@ -17,9 +17,9 @@ ClickHouse реализует параллельную обработку дан - Сложности запросов. - Объёма данных, обрабатываемых в запросах. -Для расчета объёма RAM необходимо оценить размер промежуточных данных для операций [GROUP BY](../sql_reference/statements/select.md#select-group-by-clause), [DISTINCT](../sql_reference/statements/select.md#select-distinct), [JOIN](../sql_reference/statements/select.md#select-join) а также других операций, которыми вы пользуетесь. +Для расчета объёма RAM необходимо оценить размер промежуточных данных для операций [GROUP BY](../sql-reference/statements/select/group-by.md#select-group-by-clause), [DISTINCT](../sql-reference/statements/select/distinct.md#select-distinct), [JOIN](../sql-reference/statements/select/join.md#select-join) а также других операций, которыми вы пользуетесь. -ClickHouse может использовать внешнюю память для промежуточных данных. Подробнее смотрите в разделе [GROUP BY во внешней памяти](../sql_reference/statements/select.md#select-group-by-in-external-memory). +ClickHouse может использовать внешнюю память для промежуточных данных. Подробнее смотрите в разделе [GROUP BY во внешней памяти](../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory). ## Файл подкачки {#fail-podkachki} @@ -51,4 +51,4 @@ ClickHouse может использовать внешнюю память дл ClickHouse разработан для семейства операционных систем Linux. Рекомендуемый дистрибутив Linux — Ubuntu. В системе должен быть установлен пакет `tzdata`. -ClickHouse может работать и в других семействах операционных систем. Подробнее смотрите разделе документации [Начало работы](../getting_started/index.md). +ClickHouse может работать и в других семействах операционных систем. Подробнее смотрите разделе документации [Начало работы](../getting-started/index.md). diff --git a/docs/ru/operations/server-configuration-parameters/index.md b/docs/ru/operations/server-configuration-parameters/index.md new file mode 100644 index 00000000000..a691fe69fef --- /dev/null +++ b/docs/ru/operations/server-configuration-parameters/index.md @@ -0,0 +1,17 @@ +--- +toc_folder_title: "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435\u0020\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b\u0020\u0441\u0435\u0440\u0432\u0435\u0440\u0430" +toc_priority: 54 +toc_title: "\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435" +--- + +# Конфигурационные параметры сервера {#server-settings} + +Раздел содержит описания настроек сервера, которые не могут изменяться на уровне сессии или запроса. + +Рассмотренные настройки хранятся в файле `config.xml` сервера ClickHouse. + +Прочие настройки описаны в разделе «[Настройки](../settings/index.md#settings)». + +Перед изучением настроек ознакомьтесь с разделом [Конфигурационные файлы](../configuration-files.md#configuration_files), обратите внимание на использование подстановок (атрибуты `incl` и `optional`). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/server_configuration_parameters/) diff --git a/docs/ru/operations/server-configuration-parameters/settings.md b/docs/ru/operations/server-configuration-parameters/settings.md new file mode 100644 index 00000000000..e3c1629a46a --- /dev/null +++ b/docs/ru/operations/server-configuration-parameters/settings.md @@ -0,0 +1,860 @@ +# Конфигурационные параметры сервера {#server-configuration-parameters-reference} + +## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} + +Интервал (в секундах) перезагрузки встроенных словарей. + +ClickHouse перезагружает встроенные словари с заданным интервалом. Это позволяет править словари «на лету» без перезапуска сервера. + +Значение по умолчанию - 3600. + +**Пример** + +``` xml +3600 +``` + +## compression {#compression} + +Настройки компрессии данных. + +!!! warning "Внимание" + Лучше не использовать, если вы только начали работать с ClickHouse. + +Общий вид конфигурации: + +``` xml + + + + + ... + +``` + +Можно сконфигурировать несколько разделов ``. + +Поля блока ``: + +- `min_part_size` - Минимальный размер части таблицы. +- `min_part_size_ratio` - Отношение размера минимальной части таблицы к полному размеру таблицы. +- `method` - Метод сжатия. Возможные значения: `lz4`, `zstd` (экспериментальный). + +ClickHouse проверит условия `min_part_size` и `min_part_size_ratio` и выполнит те блоки `case`, для которых условия совпали. Если ни один `` не подходит, то ClickHouse применит алгоритм сжатия `lz4`. + +**Пример** + +``` xml + + + 10000000000 + 0.01 + zstd + + +``` + +## default\_database {#default-database} + +База данных по умолчанию. + +Перечень баз данных можно получить запросом [SHOW DATABASES](../../operations/server-configuration-parameters/settings.md#show-databases). + +**Пример** + +``` xml +default +``` + +## default\_profile {#default-profile} + +Профиль настроек по умолчанию. + +Профили настроек находятся в файле, указанном в параметре `user_config`. + +**Пример** + +``` xml +default +``` + +## dictionaries\_config {#dictionaries-config} + +Путь к конфигурации внешних словарей. + +Путь: + +- Указывается абсолютным или относительно конфигурационного файла сервера. +- Может содержать wildcard-ы \* и ?. + +Смотрите также «[Внешние словари](../../operations/server-configuration-parameters/settings.md)». + +**Пример** + +``` xml +*_dictionary.xml +``` + +## dictionaries\_lazy\_load {#dictionaries-lazy-load} + +Отложенная загрузка словарей. + +Если `true`, то каждый словарь создаётся при первом использовании. Если словарь не удалось создать, то вызов функции, использующей словарь, сгенерирует исключение. + +Если `false`, то все словари создаются при старте сервера, и в случае ошибки сервер завершает работу. + +По умолчанию - `true`. + +**Пример** + +``` xml +true +``` + +## format\_schema\_path {#server_configuration_parameters-format_schema_path} + +Путь к каталогу со схемами для входных данных. Например со схемами для формата [CapnProto](../../interfaces/formats.md#capnproto). + +**Пример** + +``` xml + + format_schemas/ +``` + +## graphite {#server_configuration_parameters-graphite} + +Отправка данных в [Graphite](https://github.com/graphite-project). + +Настройки: + +- host – Сервер Graphite. +- port – Порт сервера Graphite. +- interval – Период отправки в секундах. +- timeout – Таймаут отправки данных в секундах. +- root\_path – Префикс для ключей. +- metrics – Отправка данных из таблицы [system.metrics](../../operations/server-configuration-parameters/settings.md#system_tables-metrics). +- events – Отправка дельты данных, накопленной за промежуток времени из таблицы [system.events](../../operations/server-configuration-parameters/settings.md#system_tables-events). +- events\_cumulative – Отправка суммарных данных из таблицы [system.events](../../operations/server-configuration-parameters/settings.md#system_tables-events). +- asynchronous\_metrics – Отправка данных из таблицы [system.asynchronous\_metrics](../../operations/server-configuration-parameters/settings.md#system_tables-asynchronous_metrics). + +Можно определить несколько секций ``, например, для передачи различных данных с различной частотой. + +**Пример** + +``` xml + + localhost + 42000 + 0.1 + 60 + one_min + true + true + false + true + +``` + +## graphite\_rollup {#server_configuration_parameters-graphite-rollup} + +Настройка прореживания данных для Graphite. + +Подробнее читайте в разделе [GraphiteMergeTree](../../operations/server-configuration-parameters/settings.md). + +**Пример** + +``` xml + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +## http\_port/https\_port {#http-porthttps-port} + +Порт для обращений к серверу по протоколу HTTP(s). + +Если указан `https_port`, то требуется конфигурирование [openSSL](#server_configuration_parameters-openssl). + +Если указан `http_port`, то настройка openSSL игнорируется, даже если она задана. + +**Пример** + +``` xml +9999 +``` + +## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} + +Страница, показываемая по умолчанию, при обращении к HTTP(s) серверу ClickHouse. +Значение по умолчанию «Ok.» (с переводом строки на конце). + +**Пример** + +Показывает `https://tabix.io/` при обращении к `http://localhost:http_port`. + +``` xml + +
]]> +
+``` + +## include\_from {#server_configuration_parameters-include_from} + +Путь к файлу с подстановками. + +Подробности смотрите в разделе «[Конфигурационный файлы](../configuration-files.md#configuration_files)». + +**Пример** + +``` xml +/etc/metrica.xml +``` + +## interserver\_http\_port {#interserver-http-port} + +Порт для обмена между серверами ClickHouse. + +**Пример** + +``` xml +9009 +``` + +## interserver\_http\_host {#interserver-http-host} + +Имя хоста, которое могут использовать другие серверы для обращения к этому. + +Если не указано, то определяется аналогично команде `hostname -f`. + +Удобно использовать, чтобы отвязаться от конкретного сетевого интерфейса. + +**Пример** + +``` xml +example.yandex.ru +``` + +## interserver\_http\_credentials {#server-settings-interserver-http-credentials} + +Имя пользователя и пароль, использующиеся для аутентификации при [репликации](../../operations/server-configuration-parameters/settings.md) движками Replicated\*. Это имя пользователя и пароль используются только для взаимодействия между репликами кластера и никак не связаны с аутентификацией клиентов ClickHouse. Сервер проверяет совпадение имени и пароля для соединяющихся с ним реплик, а также использует это же имя и пароль для соединения с другими репликами. Соответственно, эти имя и пароль должны быть прописаны одинаковыми для всех реплик кластера. +По умолчанию аутентификация не используется. + +Раздел содержит следующие параметры: + +- `user` — имя пользователя. +- `password` — пароль. + +**Пример конфигурации** + +``` xml + + admin + 222 + +``` + +## keep\_alive\_timeout {#keep-alive-timeout} + +Время в секундах, в течение которого ClickHouse ожидает входящих запросов прежде, чем закрыть соединение. + +**Пример** + +``` xml +3 +``` + +## listen\_host {#server_configuration_parameters-listen_host} + +Ограничение по хостам, с которых может прийти запрос. Если необходимо, чтобы сервер отвечал всем, то надо указать `::`. + +Примеры: + +``` xml +::1 +127.0.0.1 +``` + +## logger {#server_configuration_parameters-logger} + +Настройки логирования. + +Ключи: + +- level - Уровень логирования. Допустимые значения: `trace`, `debug`, `information`, `warning`, `error`. +- log - Файл лога. Содержит все записи согласно `level`. +- errorlog - Файл лога ошибок. +- size - Размер файла. Действует для `log` и `errorlog`. Как только файл достиг размера `size`, ClickHouse архивирует и переименовывает его, а на его месте создает новый файл лога. +- count - Количество заархивированных файлов логов, которые сохраняет ClickHouse. + +**Пример** + +``` xml + + trace + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 10 + +``` + +Также, существует поддержка записи в syslog. Пример конфига: + +``` xml + + 1 + +
syslog.remote:10514
+ myhost.local + LOG_LOCAL6 + syslog +
+
+``` + +Ключи: +- use\_syslog - обязательная настройка, если требуется запись в syslog +- address - хост\[:порт\] демона syslogd. Если не указан, используется локальный +- hostname - опционально, имя хоста, с которого отсылаются логи +- facility - [категория syslog](https://en.wikipedia.org/wiki/Syslog#Facility), +записанная в верхнем регистре, с префиксом «LOG\_»: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` и прочие). +Значения по умолчанию: при указанном `address` - `LOG_USER`, иначе - `LOG_DAEMON` +- format - формат сообщений. Возможные значения - `bsd` и `syslog` + +## macros {#macros} + +Подстановки параметров реплицируемых таблиц. + +Можно не указывать, если реплицируемых таблицы не используются. + +Подробнее смотрите в разделе «[Создание реплицируемых таблиц](../../operations/server-configuration-parameters/settings.md)». + +**Пример** + +``` xml + +``` + +## mark\_cache\_size {#server-mark-cache-size} + +Приблизительный размер (в байтах) кэша засечек, используемых движками таблиц семейства [MergeTree](../../operations/server-configuration-parameters/settings.md). + +Кэш общий для сервера, память выделяется по мере необходимости. + +**Пример** + +``` xml +5368709120 +``` + +## max\_concurrent\_queries {#max-concurrent-queries} + +Максимальное количество одновременно обрабатываемых запросов. + +**Пример** + +``` xml +100 +``` + +## max\_connections {#max-connections} + +Максимальное количество входящих соединений. + +**Пример** + +``` xml +4096 +``` + +## max\_open\_files {#max-open-files} + +Максимальное количество открытых файлов. + +По умолчанию - `maximum`. + +Рекомендуется использовать в Mac OS X, поскольку функция `getrlimit()` возвращает некорректное значение. + +**Пример** + +``` xml +262144 +``` + +## max\_table\_size\_to\_drop {#max-table-size-to-drop} + +Ограничение на удаление таблиц. + +Если размер таблицы семейства [MergeTree](../../operations/server-configuration-parameters/settings.md) превышает `max_table_size_to_drop` (в байтах), то ее нельзя удалить запросом DROP. + +Если таблицу все же необходимо удалить, не перезапуская при этом сервер ClickHouse, то необходимо создать файл `/flags/force_drop_table` и выполнить запрос DROP. + +Значение по умолчанию - 50GB. + +Значение 0 означает, что можно удалять все таблицы без ограничений. + +**Пример** + +``` xml +0 +``` + +## merge\_tree {#server_configuration_parameters-merge_tree} + +Тонкая настройка таблиц семейства [MergeTree](../../operations/server-configuration-parameters/settings.md). + +Подробнее смотрите в заголовочном файле MergeTreeSettings.h. + +**Пример** + +``` xml + + 5 + +``` + +## openSSL {#server_configuration_parameters-openssl} + +Настройки клиента/сервера SSL. + +Поддержку SSL обеспечивает библиотека `libpoco`. Описание интерфейса находится в файле [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) + +Ключи настроек сервера/клиента: + +- privateKeyFile - Путь к файлу с секретным ключом сертификата в формате PEM. Файл может содержать ключ и сертификат одновременно. +- certificateFile - Путь к файлу сертификата клиента/сервера в формате PEM. Можно не указывать, если `privateKeyFile` содержит сертификат. +- caConfig - Путь к файлу или каталогу, которые содержат доверенные корневые сертификаты. +- verificationMode - Способ проверки сертификатов узла. Подробности находятся в описании класса [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h). Допустимые значения: `none`, `relaxed`, `strict`, `once`. +- verificationDepth - Максимальная длина верификационной цепи. Верификация завершится ошибкой, если длина цепи сертификатов превысит установленное значение. +- loadDefaultCAFile - Признак того, что будут использоваться встроенные CA-сертификаты для OpenSSL. Допустимые значения: `true`, `false`. \| +- cipherList - Поддерживаемые OpenSSL-шифры. Например, `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. +- cacheSessions - Включение/выключение кеширования сессии. Использовать обязательно вместе с `sessionIdContext`. Допустимые значения: `true`, `false`. +- sessionIdContext - Уникальный набор произвольных символов, которые сервер добавляет к каждому сгенерированному идентификатору. Длина строки не должна превышать `SSL_MAX_SSL_SESSION_ID_LENGTH`. Рекомендуется к использованию всегда, поскольку позволяет избежать проблем как в случае, если сервер кеширует сессию, так и если клиент затребовал кеширование. По умолчанию `${application.name}`. +- sessionCacheSize - Максимальное количество сессий, которые кэширует сервер. По умолчанию - 1024\*20. 0 - неограниченное количество сессий. +- sessionTimeout - Время кеширования сессии на сервере. +- extendedVerification - Автоматическая расширенная проверка сертификатов после завершении сессии. Допустимые значения: `true`, `false`. +- requireTLSv1 - Требование соединения TLSv1. Допустимые значения: `true`, `false`. +- requireTLSv1\_1 - Требование соединения TLSv1.1. Допустимые значения: `true`, `false`. +- requireTLSv1\_2 - Требование соединения TLSv1.2. Допустимые значения: `true`, `false`. +- fips - Активация режима OpenSSL FIPS. Поддерживается, если версия OpenSSL, с которой собрана библиотека поддерживает fips. +- privateKeyPassphraseHandler - Класс (подкласс PrivateKeyPassphraseHandler)запрашивающий кодовую фразу доступа к секретному ключу. Например, ``, `KeyFileHandler`, `test`, ``. +- invalidCertificateHandler - Класс (подкласс CertificateHandler) для подтверждения не валидных сертификатов. Например, ` ConsoleCertificateHandler `. +- disableProtocols - Запрещенные к использованию протоколы. +- preferServerCiphers - Предпочтение серверных шифров на клиенте. + +**Пример настройки:** + +``` xml + + + + /etc/clickhouse-server/server.crt + /etc/clickhouse-server/server.key + + /etc/clickhouse-server/dhparam.pem + none + true + true + sslv2,sslv3 + true + + + true + true + sslv2,sslv3 + true + + + + RejectCertificateHandler + + + +``` + +## part\_log {#server_configuration_parameters-part-log} + +Логирование событий, связанных с данными типа [MergeTree](../../operations/server-configuration-parameters/settings.md). Например, события добавления или мержа данных. Лог можно использовать для симуляции алгоритмов слияния, чтобы сравнивать их характеристики. Также, можно визуализировать процесс слияния. + +Запросы логируются не в отдельный файл, а в таблицу [system.part\_log](../../operations/server-configuration-parameters/settings.md#system_tables-part-log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже). + +При настройке логирования используются следующие параметры: + +- `database` — имя базы данных; +- `table` — имя таблицы; +- `partition_by` — устанавливает [произвольный ключ партиционирования](../../operations/server-configuration-parameters/settings.md); +- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу. + +**Пример** + +``` xml + + system + part_log
+ toMonday(event_date) + 7500 +
+``` + +## path {#server_configuration_parameters-path} + +Путь к каталогу с данными. + +!!! warning "Обратите внимание" + Завершающий слеш обязателен. + +**Пример** + +``` xml +/var/lib/clickhouse/ +``` + +## prometheus {#server_configuration_parameters-prometheus} + +Опубликовать данные о метриках, для сбора с помощью системы мониторинга [Prometheus](https://prometheus.io). + +Настройки: + +- `endpoint` – путь по которому будет осуществляться экспорт данных метрик по HTTP протоколу для сбора с помощью prometheus. Должен начинаться с ‘/’. +- `port` – порт по которому будет доступен endpoint для сбора метрик. +- `metrics` – флаг для экспорта текущих значений метрик из таблицы [system.metrics](../system-tables.md#system_tables-metrics). +- `events` – флаг для экспорта текущих значений метрик из таблицы [system.events](../system-tables.md#system_tables-events). +- `asynchronous_metrics` – флаг для экспорта текущих значений значения метрик из таблицы [system.asynchronous\_metrics](../system-tables.md#system_tables-asynchronous_metrics). + +**Пример** + +``` xml + + /metrics + 8001 + true + true + true + +``` + +## query\_log {#server_configuration_parameters-query-log} + +Настройка логирования запросов, принятых с настройкой [log\_queries=1](../settings/settings.md). + +Запросы логируются не в отдельный файл, а в системную таблицу [system.query\_log](../../operations/server-configuration-parameters/settings.md#system_tables-query_log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже). + +При настройке логирования используются следующие параметры: + +- `database` — имя базы данных; +- `table` — имя таблицы, куда будет записываться лог; +- `partition_by` — [произвольный ключ партиционирования](../../operations/server-configuration-parameters/settings.md) для таблицы с логами; +- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу. + +Если таблица не существует, то ClickHouse создаст её. Если структура журнала запросов изменилась при обновлении сервера ClickHouse, то таблица со старой структурой переименовывается, а новая таблица создается автоматически. + +**Пример** + +``` xml + + system + query_log
+ toMonday(event_date) + 7500 +
+``` + +## query\_thread\_log {#server_configuration_parameters-query_thread_log} + +Настройка логирования потоков выполнения запросов, принятых с настройкой [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads). + +Запросы логируются не в отдельный файл, а в системную таблицу [system.query\_thread\_log](../../operations/server-configuration-parameters/settings.md#system_tables-query_thread_log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже). + +При настройке логирования используются следующие параметры: + +- `database` — имя базы данных; +- `table` — имя таблицы, куда будет записываться лог; +- `partition_by` — [произвольный ключ партиционирования](../../operations/server-configuration-parameters/settings.md) для таблицы с логами; +- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу. + +Если таблица не существует, то ClickHouse создаст её. Если структура журнала запросов изменилась при обновлении сервера ClickHouse, то таблица со старой структурой переименовывается, а новая таблица создается автоматически. + +**Пример** + +``` xml + + system + query_thread_log
+ toMonday(event_date) + 7500 +
+``` + +## trace\_log {#server_configuration_parameters-trace_log} + +Settings for the [trace\_log](../../operations/server-configuration-parameters/settings.md#system_tables-trace_log) system table operation. + +Parameters: + +- `database` — Database for storing a table. +- `table` — Table name. +- `partition_by` — [Custom partitioning key](../../operations/server-configuration-parameters/settings.md) for a system table. +- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. + +The default server configuration file `config.xml` contains the following settings section: + +``` xml + + system + trace_log
+ toYYYYMM(event_date) + 7500 +
+``` + +## remote\_servers {#server-settings-remote-servers} + +Конфигурация кластеров, которые использует движок таблиц [Distributed](../../operations/server-configuration-parameters/settings.md) и табличная функция `cluster`. + +**Пример** + +``` xml + +``` + +Значение атрибута `incl` смотрите в разделе «[Конфигурационные файлы](../configuration-files.md#configuration_files)». + +**Смотрите также** + +- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) + +## timezone {#server_configuration_parameters-timezone} + +Временная зона сервера. + +Указывается идентификатором IANA в виде часового пояса UTC или географического положения (например, Africa/Abidjan). + +Временная зона необходима при преобразованиях между форматами String и DateTime, которые возникают при выводе полей DateTime в текстовый формат (на экран или в файл) и при получении DateTime из строки. Также, временная зона используется в функциях, которые работают со временем и датой, если они не получили временную зону в параметрах вызова. + +**Пример** + +``` xml +Europe/Moscow +``` + +## tcp\_port {#server_configuration_parameters-tcp_port} + +Порт для взаимодействия с клиентами по протоколу TCP. + +**Пример** + +``` xml +9000 +``` + +## tcp\_port\_secure {#server_configuration_parameters-tcp_port_secure} + +TCP порт для защищённого обмена данными с клиентами. Используйте с настройкой [OpenSSL](#server_configuration_parameters-openssl). + +**Возможные значения** + +Положительное целое число. + +**Значение по умолчанию** + +``` xml +9440 +``` + +## mysql\_port {#server_configuration_parameters-mysql_port} + +Порт для взаимодействия с клиентами по протоколу MySQL. + +Пример + +``` xml +9004 +``` + +## tmp_path {#tmp-path} + +Путь ко временным данным для обработки больших запросов. + +!!! warning "Обратите внимание" + Завершающий слеш обязателен. + +**Пример** + +``` xml +/var/lib/clickhouse/tmp/ +``` +## tmp_policy {#tmp-policy} + +Политика из [storage_configuration](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) для хранения временных файлов. + +Если политика не задана, используется [tmp_path](#tmp-path). В противном случае `tmp_path` игнорируется. + +!!! note "Примечание" + - `move_factor` игнорируется. + - `keep_free_space_bytes` игнорируется. + - `max_data_part_size_bytes` игнорируется. + - В данной политике у вас должен быть ровно один том. + +## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} + +Размер кеша (в байтах) для несжатых данных, используемых движками таблиц семейства [MergeTree](../../operations/server-configuration-parameters/settings.md). + +Кеш единый для сервера. Память выделяется по требованию. Кеш используется в том случае, если включена опция [use\_uncompressed\_cache](../settings/settings.md). + +Несжатый кеш выгодно использовать для очень коротких запросов в отдельных случаях. + +**Пример** + +``` xml +8589934592 +``` + +## user\_files\_path {#server_configuration_parameters-user_files_path} + +Каталог с пользовательскими файлами. Используется в табличной функции [file()](../../operations/server-configuration-parameters/settings.md). + +**Пример** + +``` xml +/var/lib/clickhouse/user_files/ +``` + +## users\_config {#users-config} + +Путь к файлу, который содержит: + +- Конфигурации пользователей. +- Права доступа. +- Профили настроек. +- Настройки квот. + +**Пример** + +``` xml +users.xml +``` + +## zookeeper {#server-settings_zookeeper} + +Содержит параметры, позволяющие ClickHouse взаимодействовать с кластером [ZooKeeper](http://zookeeper.apache.org/). + +ClickHouse использует ZooKeeper для хранения метаданных о репликах при использовании реплицированных таблиц. Если реплицированные таблицы не используются, этот раздел параметров может отсутствовать. + +Раздел содержит следующие параметры: + +- `node` — адрес ноды (сервера) ZooKeeper. Можно сконфигурировать несколько нод. + + Например: + + + +``` xml + + example_host + 2181 + +``` + + Атрибут `index` задает порядок опроса нод при попытках подключиться к кластеру ZooKeeper. + +- `session_timeout` — максимальный таймаут клиентской сессии в миллисекундах. +- `root` — [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes), который используется как корневой для всех znode, которые использует сервер ClickHouse. Необязательный. +- `identity` — пользователь и пароль, которые может потребовать ZooKeeper для доступа к запрошенным znode. Необязательный. + +**Пример конфигурации** + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + 30000 + + /path/to/zookeeper/node + + user:password + +``` + +**Смотрите также** + +- [Репликация](../../engines/table-engines/mergetree-family/replication.md) +- [ZooKeeper Programmer’s Guide](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) + +## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} + +Способ хранения заголовков кусков данных в ZooKeeper. + +Параметр применяется только к семейству таблиц `MergeTree`. Его можно установить: + +- Глобально в разделе [merge\_tree](#server_configuration_parameters-merge_tree) файла `config.xml`. + + ClickHouse использует этот параметр для всех таблиц на сервере. Вы можете изменить настройку в любое время. Существующие таблицы изменяют свое поведение при изменении параметра. + +- Для каждой отдельной таблицы. + + При создании таблицы укажите соответствующую [настройку движка](../../operations/server_configuration_parameters/settings.md#table_engine-mergetree-creating-a-table). Поведение существующей таблицы с установленным параметром не изменяется даже при изменении глобального параметра. + +**Возможные значения** + +- 0 — функциональность выключена. +- 1 — функциональность включена. + +Если `use_minimalistic_part_header_in_zookeeper = 1`, то [реплицированные](../../operations/server-configuration-parameters/settings.md) таблицы хранят заголовки кусков данных в компактном виде, используя только одну `znode`. Если таблица содержит много столбцов, этот метод хранения значительно уменьшает объём данных, хранящихся в Zookeeper. + +!!! attention "Внимание" + После того как вы установили `use_minimalistic_part_header_in_zookeeper = 1`, невозможно откатить ClickHouse до версии, которая не поддерживает этот параметр. Будьте осторожны при обновлении ClickHouse на серверах в кластере. Не обновляйте все серверы сразу. Безопаснее проверять новые версии ClickHouse в тестовой среде или только на некоторых серверах кластера. + + Заголовки частей данных, ранее сохранённые с этим параметром, не могут быть восстановлены в их предыдущем (некомпактном) представлении. + +**Значение по умолчанию**: 0. + +## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} + +Отключает внутренний кеш DNS записей. Используется при эксплуатации ClickHouse в системах +с часто меняющейся инфраструктурой, таких как Kubernetes. + +**Значение по умолчанию**: 0. + +## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} + +Период обновления IP адресов у записей во внутреннем DNS кеше ClickHouse (в секундах). +Обновление выполняется асинхронно, отдельным системным потоком. + +**Значение по умолчанию**: 15. + +**Смотрите также** + +- [background_schedule_pool_size](../settings/settings.md#background_schedule_pool_size) + +## access_control_path {#access_control_path} + +Путь к каталогу, где сервер ClickHouse хранит конфигурации пользователей и ролей, созданные командами SQL. + +Значение по умолчанию: `/var/lib/clickhouse/access/`. + +**Смотрите также** + +- [Управление доступом](../access-rights.md#access-control) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/server_configuration_parameters/settings/) diff --git a/docs/ru/operations/server_configuration_parameters/index.md b/docs/ru/operations/server_configuration_parameters/index.md deleted file mode 100644 index 91deb2973a7..00000000000 --- a/docs/ru/operations/server_configuration_parameters/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# Конфигурационные параметры сервера {#server-settings} - -Раздел содержит описания настроек сервера, которые не могут изменяться на уровне сессии или запроса. - -Рассмотренные настройки хранятся в файле `config.xml` сервера ClickHouse. - -Прочие настройки описаны в разделе «[Настройки](../settings/index.md#settings)». - -Перед изучением настроек ознакомьтесь с разделом [Конфигурационные файлы](../configuration_files.md#configuration_files), обратите внимание на использование подстановок (атрибуты `incl` и `optional`). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/server_configuration_parameters/) diff --git a/docs/ru/operations/server_configuration_parameters/settings.md b/docs/ru/operations/server_configuration_parameters/settings.md deleted file mode 100644 index 0a4c1d52575..00000000000 --- a/docs/ru/operations/server_configuration_parameters/settings.md +++ /dev/null @@ -1,835 +0,0 @@ -# Конфигурационные параметры сервера {#konfiguratsionnye-parametry-servera} - -## builtin\_dictionaries\_reload\_interval {#builtin-dictionaries-reload-interval} - -Интервал (в секундах) перезагрузки встроенных словарей. - -ClickHouse перезагружает встроенные словари с заданным интервалом. Это позволяет править словари «на лету» без перезапуска сервера. - -Значение по умолчанию - 3600. - -**Пример** - -``` xml -3600 -``` - -## compression {#compression} - -Настройки компрессии данных. - -!!! warning "Внимание" - Лучше не использовать, если вы только начали работать с ClickHouse. - -Общий вид конфигурации: - -``` xml - - - - - ... - -``` - -Можно сконфигурировать несколько разделов ``. - -Поля блока ``: - -- `min_part_size` - Минимальный размер части таблицы. -- `min_part_size_ratio` - Отношение размера минимальной части таблицы к полному размеру таблицы. -- `method` - Метод сжатия. Возможные значения: `lz4`, `zstd` (экспериментальный). - -ClickHouse проверит условия `min_part_size` и `min_part_size_ratio` и выполнит те блоки `case`, для которых условия совпали. Если ни один `` не подходит, то ClickHouse применит алгоритм сжатия `lz4`. - -**Пример** - -``` xml - - - 10000000000 - 0.01 - zstd - - -``` - -## default\_database {#default-database} - -База данных по умолчанию. - -Перечень баз данных можно получить запросом [SHOW DATABASES](../../operations/server_configuration_parameters/settings.md#show-databases). - -**Пример** - -``` xml -default -``` - -## default\_profile {#default-profile} - -Профиль настроек по умолчанию. - -Профили настроек находятся в файле, указанном в параметре `user_config`. - -**Пример** - -``` xml -default -``` - -## dictionaries\_config {#dictionaries-config} - -Путь к конфигурации внешних словарей. - -Путь: - -- Указывается абсолютным или относительно конфигурационного файла сервера. -- Может содержать wildcard-ы \* и ?. - -Смотрите также «[Внешние словари](../../operations/server_configuration_parameters/settings.md)». - -**Пример** - -``` xml -*_dictionary.xml -``` - -## dictionaries\_lazy\_load {#dictionaries-lazy-load} - -Отложенная загрузка словарей. - -Если `true`, то каждый словарь создаётся при первом использовании. Если словарь не удалось создать, то вызов функции, использующей словарь, сгенерирует исключение. - -Если `false`, то все словари создаются при старте сервера, и в случае ошибки сервер завершает работу. - -По умолчанию - `true`. - -**Пример** - -``` xml -true -``` - -## format\_schema\_path {#server_configuration_parameters-format_schema_path} - -Путь к каталогу со схемами для входных данных. Например со схемами для формата [CapnProto](../../interfaces/formats.md#capnproto). - -**Пример** - -``` xml - - format_schemas/ -``` - -## graphite {#server_configuration_parameters-graphite} - -Отправка данных в [Graphite](https://github.com/graphite-project). - -Настройки: - -- host – Сервер Graphite. -- port – Порт сервера Graphite. -- interval – Период отправки в секундах. -- timeout – Таймаут отправки данных в секундах. -- root\_path – Префикс для ключей. -- metrics – Отправка данных из таблицы [system.metrics](../../operations/server_configuration_parameters/settings.md#system_tables-metrics). -- events – Отправка дельты данных, накопленной за промежуток времени из таблицы [system.events](../../operations/server_configuration_parameters/settings.md#system_tables-events). -- events\_cumulative – Отправка суммарных данных из таблицы [system.events](../../operations/server_configuration_parameters/settings.md#system_tables-events). -- asynchronous\_metrics – Отправка данных из таблицы [system.asynchronous\_metrics](../../operations/server_configuration_parameters/settings.md#system_tables-asynchronous_metrics). - -Можно определить несколько секций ``, например, для передачи различных данных с различной частотой. - -**Пример** - -``` xml - - localhost - 42000 - 0.1 - 60 - one_min - true - true - false - true - -``` - -## graphite\_rollup {#server_configuration_parameters-graphite-rollup} - -Настройка прореживания данных для Graphite. - -Подробнее читайте в разделе [GraphiteMergeTree](../../operations/server_configuration_parameters/settings.md). - -**Пример** - -``` xml - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -## http\_port/https\_port {#http-porthttps-port} - -Порт для обращений к серверу по протоколу HTTP(s). - -Если указан `https_port`, то требуется конфигурирование [openSSL](#server_configuration_parameters-openssl). - -Если указан `http_port`, то настройка openSSL игнорируется, даже если она задана. - -**Пример** - -``` xml -0000 -``` - -## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} - -Страница, показываемая по умолчанию, при обращении к HTTP(s) серверу ClickHouse. -Значение по умолчанию «Ok.» (с переводом строки на конце). - -**Пример** - -Показывает `https://tabix.io/` при обращении к `http://localhost:http_port`. - -``` xml - -
]]> -
-``` - -## include\_from {#server_configuration_parameters-include_from} - -Путь к файлу с подстановками. - -Подробности смотрите в разделе «[Конфигурационный файлы](../configuration_files.md#configuration_files)». - -**Пример** - -``` xml -/etc/metrica.xml -``` - -## interserver\_http\_port {#interserver-http-port} - -Порт для обмена между серверами ClickHouse. - -**Пример** - -``` xml -9009 -``` - -## interserver\_http\_host {#interserver-http-host} - -Имя хоста, которое могут использовать другие серверы для обращения к этому. - -Если не указано, то определяется аналогично команде `hostname -f`. - -Удобно использовать, чтобы отвязаться от конкретного сетевого интерфейса. - -**Пример** - -``` xml -example.yandex.ru -``` - -## interserver\_http\_credentials {#server-settings-interserver-http-credentials} - -Имя пользователя и пароль, использующиеся для аутентификации при [репликации](../../operations/server_configuration_parameters/settings.md) движками Replicated\*. Это имя пользователя и пароль используются только для взаимодействия между репликами кластера и никак не связаны с аутентификацией клиентов ClickHouse. Сервер проверяет совпадение имени и пароля для соединяющихся с ним реплик, а также использует это же имя и пароль для соединения с другими репликами. Соответственно, эти имя и пароль должны быть прописаны одинаковыми для всех реплик кластера. -По умолчанию аутентификация не используется. - -Раздел содержит следующие параметры: - -- `user` — имя пользователя. -- `password` — пароль. - -**Пример конфигурации** - -``` xml - - admin - 222 - -``` - -## keep\_alive\_timeout {#keep-alive-timeout} - -Время в секундах, в течение которого ClickHouse ожидает входящих запросов прежде, чем закрыть соединение. - -**Пример** - -``` xml -3 -``` - -## listen\_host {#server_configuration_parameters-listen_host} - -Ограничение по хостам, с которых может прийти запрос. Если необходимо, чтобы сервер отвечал всем, то надо указать `::`. - -Примеры: - -``` xml -::1 -127.0.0.1 -``` - -## logger {#server_configuration_parameters-logger} - -Настройки логирования. - -Ключи: - -- level - Уровень логирования. Допустимые значения: `trace`, `debug`, `information`, `warning`, `error`. -- log - Файл лога. Содержит все записи согласно `level`. -- errorlog - Файл лога ошибок. -- size - Размер файла. Действует для `log` и `errorlog`. Как только файл достиг размера `size`, ClickHouse архивирует и переименовывает его, а на его месте создает новый файл лога. -- count - Количество заархивированных файлов логов, которые сохраняет ClickHouse. - -**Пример** - -``` xml - - trace - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 10 - -``` - -Также, существует поддержка записи в syslog. Пример конфига: - -``` xml - - 1 - -
syslog.remote:10514
- myhost.local - LOG_LOCAL6 - syslog -
-
-``` - -Ключи: -- use\_syslog - обязательная настройка, если требуется запись в syslog -- address - хост\[:порт\] демона syslogd. Если не указан, используется локальный -- hostname - опционально, имя хоста, с которого отсылаются логи -- facility - [категория syslog](https://en.wikipedia.org/wiki/Syslog#Facility), -записанная в верхнем регистре, с префиксом «LOG\_»: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` и прочие). -Значения по умолчанию: при указанном `address` - `LOG_USER`, иначе - `LOG_DAEMON` -- format - формат сообщений. Возможные значения - `bsd` и `syslog` - -## macros {#macros} - -Подстановки параметров реплицируемых таблиц. - -Можно не указывать, если реплицируемых таблицы не используются. - -Подробнее смотрите в разделе «[Создание реплицируемых таблиц](../../operations/server_configuration_parameters/settings.md)». - -**Пример** - -``` xml - -``` - -## mark\_cache\_size {#server-mark-cache-size} - -Приблизительный размер (в байтах) кэша засечек, используемых движками таблиц семейства [MergeTree](../../operations/server_configuration_parameters/settings.md). - -Кэш общий для сервера, память выделяется по мере необходимости. - -**Пример** - -``` xml -5368709120 -``` - -## max\_concurrent\_queries {#max-concurrent-queries} - -Максимальное количество одновременно обрабатываемых запросов. - -**Пример** - -``` xml -100 -``` - -## max\_connections {#max-connections} - -Максимальное количество входящих соединений. - -**Пример** - -``` xml -4096 -``` - -## max\_open\_files {#max-open-files} - -Максимальное количество открытых файлов. - -По умолчанию - `maximum`. - -Рекомендуется использовать в Mac OS X, поскольку функция `getrlimit()` возвращает некорректное значение. - -**Пример** - -``` xml -262144 -``` - -## max\_table\_size\_to\_drop {#max-table-size-to-drop} - -Ограничение на удаление таблиц. - -Если размер таблицы семейства [MergeTree](../../operations/server_configuration_parameters/settings.md) превышает `max_table_size_to_drop` (в байтах), то ее нельзя удалить запросом DROP. - -Если таблицу все же необходимо удалить, не перезапуская при этом сервер ClickHouse, то необходимо создать файл `/flags/force_drop_table` и выполнить запрос DROP. - -Значение по умолчанию - 50GB. - -Значение 0 означает, что можно удалять все таблицы без ограничений. - -**Пример** - -``` xml -0 -``` - -## merge\_tree {#server_configuration_parameters-merge_tree} - -Тонкая настройка таблиц семейства [MergeTree](../../operations/server_configuration_parameters/settings.md). - -Подробнее смотрите в заголовочном файле MergeTreeSettings.h. - -**Пример** - -``` xml - - 5 - -``` - -## openSSL {#server_configuration_parameters-openssl} - -Настройки клиента/сервера SSL. - -Поддержку SSL обеспечивает библиотека `libpoco`. Описание интерфейса находится в файле [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) - -Ключи настроек сервера/клиента: - -- privateKeyFile - Путь к файлу с секретным ключом сертификата в формате PEM. Файл может содержать ключ и сертификат одновременно. -- certificateFile - Путь к файлу сертификата клиента/сервера в формате PEM. Можно не указывать, если `privateKeyFile` содержит сертификат. -- caConfig - Путь к файлу или каталогу, которые содержат доверенные корневые сертификаты. -- verificationMode - Способ проверки сертификатов узла. Подробности находятся в описании класса [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h). Допустимые значения: `none`, `relaxed`, `strict`, `once`. -- verificationDepth - Максимальная длина верификационной цепи. Верификация завершится ошибкой, если длина цепи сертификатов превысит установленное значение. -- loadDefaultCAFile - Признак того, что будут использоваться встроенные CA-сертификаты для OpenSSL. Допустимые значения: `true`, `false`. \| -- cipherList - Поддерживаемые OpenSSL-шифры. Например, `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. -- cacheSessions - Включение/выключение кеширования сессии. Использовать обязательно вместе с `sessionIdContext`. Допустимые значения: `true`, `false`. -- sessionIdContext - Уникальный набор произвольных символов, которые сервер добавляет к каждому сгенерированному идентификатору. Длина строки не должна превышать `SSL_MAX_SSL_SESSION_ID_LENGTH`. Рекомендуется к использованию всегда, поскольку позволяет избежать проблем как в случае, если сервер кеширует сессию, так и если клиент затребовал кеширование. По умолчанию `${application.name}`. -- sessionCacheSize - Максимальное количество сессий, которые кэширует сервер. По умолчанию - 1024\*20. 0 - неограниченное количество сессий. -- sessionTimeout - Время кеширования сессии на сервере. -- extendedVerification - Автоматическая расширенная проверка сертификатов после завершении сессии. Допустимые значения: `true`, `false`. -- requireTLSv1 - Требование соединения TLSv1. Допустимые значения: `true`, `false`. -- requireTLSv1\_1 - Требование соединения TLSv1.1. Допустимые значения: `true`, `false`. -- requireTLSv1\_2 - Требование соединения TLSv1.2. Допустимые значения: `true`, `false`. -- fips - Активация режима OpenSSL FIPS. Поддерживается, если версия OpenSSL, с которой собрана библиотека поддерживает fips. -- privateKeyPassphraseHandler - Класс (подкласс PrivateKeyPassphraseHandler)запрашивающий кодовую фразу доступа к секретному ключу. Например, ``, `KeyFileHandler`, `test`, ``. -- invalidCertificateHandler - Класс (подкласс CertificateHandler) для подтверждения не валидных сертификатов. Например, ` ConsoleCertificateHandler `. -- disableProtocols - Запрещенные к использованию протоколы. -- preferServerCiphers - Предпочтение серверных шифров на клиенте. - -**Пример настройки:** - -``` xml - - - - /etc/clickhouse-server/server.crt - /etc/clickhouse-server/server.key - - /etc/clickhouse-server/dhparam.pem - none - true - true - sslv2,sslv3 - true - - - true - true - sslv2,sslv3 - true - - - - RejectCertificateHandler - - - -``` - -## part\_log {#server_configuration_parameters-part-log} - -Логирование событий, связанных с данными типа [MergeTree](../../operations/server_configuration_parameters/settings.md). Например, события добавления или мержа данных. Лог можно использовать для симуляции алгоритмов слияния, чтобы сравнивать их характеристики. Также, можно визуализировать процесс слияния. - -Запросы логируются не в отдельный файл, а в таблицу [system.part\_log](../../operations/server_configuration_parameters/settings.md#system_tables-part-log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже). - -При настройке логирования используются следующие параметры: - -- `database` — имя базы данных; -- `table` — имя таблицы; -- `partition_by` — устанавливает [произвольный ключ партиционирования](../../operations/server_configuration_parameters/settings.md); -- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу. - -**Пример** - -``` xml - - system - part_log
- toMonday(event_date) - 7500 -
-``` - -## path {#server_configuration_parameters-path} - -Путь к каталогу с данными. - -!!! warning "Обратите внимание" - Завершающий слеш обязателен. - -**Пример** - -``` xml -/var/lib/clickhouse/ -``` - -## prometheus {#server_configuration_parameters-prometheus} - -Опубликовать данные о метриках, для сбора с помощью системы мониторинга [Prometheus](https://prometheus.io). - -Настройки: - -- `endpoint` – путь по которому будет осуществляться экспорт данных метрик по HTTP протоколу для сбора с помощью prometheus. Должен начинаться с '/'. -- `port` – порт по которому будет доступен endpoint для сбора метрик. -- `metrics` – флаг для экспорта текущих значений метрик из таблицы [system.metrics](../system_tables.md#system_tables-metrics). -- `events` – флаг для экспорта текущих значений метрик из таблицы [system.events](../system_tables.md#system_tables-events). -- `asynchronous_metrics` – флаг для экспорта текущих значений значения метрик из таблицы [system.asynchronous\_metrics](../system_tables.md#system_tables-asynchronous_metrics). - -**Пример** - -``` xml - - /metrics - 8001 - true - true - true - -``` - -## query\_log {#server_configuration_parameters-query-log} - -Настройка логирования запросов, принятых с настройкой [log\_queries=1](../settings/settings.md). - -Запросы логируются не в отдельный файл, а в системную таблицу [system.query\_log](../../operations/server_configuration_parameters/settings.md#system_tables-query-log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже). - -При настройке логирования используются следующие параметры: - -- `database` — имя базы данных; -- `table` — имя таблицы, куда будет записываться лог; -- `partition_by` — [произвольный ключ партиционирования](../../operations/server_configuration_parameters/settings.md) для таблицы с логами; -- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу. - -Если таблица не существует, то ClickHouse создаст её. Если структура журнала запросов изменилась при обновлении сервера ClickHouse, то таблица со старой структурой переименовывается, а новая таблица создается автоматически. - -**Пример** - -``` xml - - system - query_log
- toMonday(event_date) - 7500 -
-``` - -## query\_thread\_log {#server_configuration_parameters-query-thread-log} - -Настройка логирования потоков выполнения запросов, принятых с настройкой [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads). - -Запросы логируются не в отдельный файл, а в системную таблицу [system.query\_thread\_log](../../operations/server_configuration_parameters/settings.md#system_tables-query-thread-log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже). - -При настройке логирования используются следующие параметры: - -- `database` — имя базы данных; -- `table` — имя таблицы, куда будет записываться лог; -- `partition_by` — [произвольный ключ партиционирования](../../operations/server_configuration_parameters/settings.md) для таблицы с логами; -- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу. - -Если таблица не существует, то ClickHouse создаст её. Если структура журнала запросов изменилась при обновлении сервера ClickHouse, то таблица со старой структурой переименовывается, а новая таблица создается автоматически. - -**Пример** - -``` xml - - system - query_thread_log
- toMonday(event_date) - 7500 -
-``` - -## trace\_log {#server_configuration_parameters-trace_log} - -Settings for the [trace\_log](../../operations/server_configuration_parameters/settings.md#system_tables-trace_log) system table operation. - -Parameters: - -- `database` — Database for storing a table. -- `table` — Table name. -- `partition_by` — [Custom partitioning key](../../operations/server_configuration_parameters/settings.md) for a system table. -- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. - -The default server configuration file `config.xml` contains the following settings section: - -``` xml - - system - trace_log
- toYYYYMM(event_date) - 7500 -
-``` - -## remote\_servers {#server-settings-remote-servers} - -Конфигурация кластеров, которые использует движок таблиц [Distributed](../../operations/server_configuration_parameters/settings.md) и табличная функция `cluster`. - -**Пример** - -``` xml - -``` - -Значение атрибута `incl` смотрите в разделе «[Конфигурационные файлы](../configuration_files.md#configuration_files)». - -**Смотрите также** - -- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) - -## timezone {#server_configuration_parameters-timezone} - -Временная зона сервера. - -Указывается идентификатором IANA в виде часового пояса UTC или географического положения (например, Africa/Abidjan). - -Временная зона необходима при преобразованиях между форматами String и DateTime, которые возникают при выводе полей DateTime в текстовый формат (на экран или в файл) и при получении DateTime из строки. Также, временная зона используется в функциях, которые работают со временем и датой, если они не получили временную зону в параметрах вызова. - -**Пример** - -``` xml -Europe/Moscow -``` - -## tcp\_port {#server_configuration_parameters-tcp_port} - -Порт для взаимодействия с клиентами по протоколу TCP. - -**Пример** - -``` xml -9000 -``` - -## tcp\_port\_secure {#server_configuration_parameters-tcp_port-secure} - -TCP порт для защищённого обмена данными с клиентами. Используйте с настройкой [OpenSSL](#server_configuration_parameters-openssl). - -**Возможные значения** - -Положительное целое число. - -**Значение по умолчанию** - -``` xml -9440 -``` - -## mysql\_port {#server_configuration_parameters-mysql_port} - -Порт для взаимодействия с клиентами по протоколу MySQL. - -Пример - -``` xml -9004 -``` - -## tmp\_path {#tmp-path} - -Путь ко временным данным для обработки больших запросов. - -!!! warning "Обратите внимание" - Завершающий слеш обязателен. - -**Пример** - -``` xml -/var/lib/clickhouse/tmp/ -``` - -## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} - -Размер кеша (в байтах) для несжатых данных, используемых движками таблиц семейства [MergeTree](../../operations/server_configuration_parameters/settings.md). - -Кеш единый для сервера. Память выделяется по требованию. Кеш используется в том случае, если включена опция [use\_uncompressed\_cache](../settings/settings.md). - -Несжатый кеш выгодно использовать для очень коротких запросов в отдельных случаях. - -**Пример** - -``` xml -8589934592 -``` - -## user\_files\_path {#server_configuration_parameters-user_files_path} - -Каталог с пользовательскими файлами. Используется в табличной функции [file()](../../operations/server_configuration_parameters/settings.md). - -**Пример** - -``` xml -/var/lib/clickhouse/user_files/ -``` - -## users\_config {#users-config} - -Путь к файлу, который содержит: - -- Конфигурации пользователей. -- Права доступа. -- Профили настроек. -- Настройки квот. - -**Пример** - -``` xml -users.xml -``` - -## zookeeper {#server-settings_zookeeper} - -Содержит параметры, позволяющие ClickHouse взаимодействовать с кластером [ZooKeeper](http://zookeeper.apache.org/). - -ClickHouse использует ZooKeeper для хранения метаданных о репликах при использовании реплицированных таблиц. Если реплицированные таблицы не используются, этот раздел параметров может отсутствовать. - -Раздел содержит следующие параметры: - -- `node` — адрес ноды (сервера) ZooKeeper. Можно сконфигурировать несколько нод. - - Например: - - - -``` xml - - example_host - 2181 - -``` - - Атрибут `index` задает порядок опроса нод при попытках подключиться к кластеру ZooKeeper. - -- `session_timeout` — максимальный таймаут клиентской сессии в миллисекундах. -- `root` — [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes), который используется как корневой для всех znode, которые использует сервер ClickHouse. Необязательный. -- `identity` — пользователь и пароль, которые может потребовать ZooKeeper для доступа к запрошенным znode. Необязательный. - -**Пример конфигурации** - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - 30000 - - /path/to/zookeeper/node - - user:password - -``` - -**Смотрите также** - -- [Репликация](../../engines/table_engines/mergetree_family/replication.md) -- [ZooKeeper Programmer’s Guide](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) - -## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} - -Способ хранения заголовков кусков данных в ZooKeeper. - -Параметр применяется только к семейству таблиц `MergeTree`. Его можно установить: - -- Глобально в разделе [merge\_tree](#server_configuration_parameters-merge_tree) файла `config.xml`. - - ClickHouse использует этот параметр для всех таблиц на сервере. Вы можете изменить настройку в любое время. Существующие таблицы изменяют свое поведение при изменении параметра. - -- Для каждой отдельной таблицы. - - При создании таблицы укажите соответствующую [настройку движка](../../operations/server_configuration_parameters/settings.md#table_engine-mergetree-creating-a-table). Поведение существующей таблицы с установленным параметром не изменяется даже при изменении глобального параметра. - -**Возможные значения** - -- 0 — функциональность выключена. -- 1 — функциональность включена. - -Если `use_minimalistic_part_header_in_zookeeper = 1`, то [реплицированные](../../operations/server_configuration_parameters/settings.md) таблицы хранят заголовки кусков данных в компактном виде, используя только одну `znode`. Если таблица содержит много столбцов, этот метод хранения значительно уменьшает объём данных, хранящихся в Zookeeper. - -!!! attention "Внимание" - После того как вы установили `use_minimalistic_part_header_in_zookeeper = 1`, невозможно откатить ClickHouse до версии, которая не поддерживает этот параметр. Будьте осторожны при обновлении ClickHouse на серверах в кластере. Не обновляйте все серверы сразу. Безопаснее проверять новые версии ClickHouse в тестовой среде или только на некоторых серверах кластера. - - Заголовки частей данных, ранее сохранённые с этим параметром, не могут быть восстановлены в их предыдущем (некомпактном) представлении. - -**Значение по умолчанию**: 0. - -## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} - -Отключает внутренний кеш DNS записей. Используется при эксплуатации ClickHouse в системах -с часто меняющейся инфраструктурой, таких как Kubernetes. - -**Значение по умолчанию**: 0. - -## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} - -Период обновления IP адресов у записей во внутреннем DNS кеше ClickHouse (в секундах). -Обновление выполняется асинхронно, отдельным системным потоком. - -**Значение по умолчанию**: 15. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/server_configuration_parameters/settings/) diff --git a/docs/ru/operations/settings/constraints-on-settings.md b/docs/ru/operations/settings/constraints-on-settings.md new file mode 100644 index 00000000000..dd324caecc6 --- /dev/null +++ b/docs/ru/operations/settings/constraints-on-settings.md @@ -0,0 +1,69 @@ +# Ограничения на изменение настроек {#constraints-on-settings} + +Ограничения на изменение настроек могут находиться внутри секции `profiles` файла `user.xml` и запрещают пользователю менять некоторые настройки с помощью запроса `SET`. +Выглядит это следующим образом: + +``` xml + + <имя_пользователя> + + <настройка_1> + нижняя_граница + + <настройка_2> + верхняя_граница + + <настройка_3> + нижняя_граница + верхняя_граница + + <настройка_4> + + + + + +``` + +Если пользователь пытается выйти за пределы, установленные этими ограничениями, то кидается исключение и настройка сохраняет прежнее значение. +Поддерживаются три типа ограничений: `min`, `max` и `readonly`. Ограничения `min` и `max` указывают нижнюю и верхнюю границы для числовых настроек и могут использоваться вместе. +Ограничение `readonly` указывает, что пользователь не может менять настройку. + +**Пример:** Пусть файл `users.xml` содержит строки: + +``` xml + + + 10000000000 + 0 + ... + + + 5000000000 + 20000000000 + + + + + + + +``` + +Каждый из следующих запросов кинет исключение: + +``` sql +SET max_memory_usage=20000000001; +SET max_memory_usage=4999999999; +SET force_index_by_date=1; +``` + +``` text +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. +Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. +``` + +**Примечание:** профиль с именем `default` обрабатывается специальным образом: все ограничения на изменение настроек из этого профиля становятся дефолтными и влияют на всех пользователей, кроме тех, где эти ограничения явно переопределены. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/constraints_on_settings/) diff --git a/docs/ru/operations/settings/constraints_on_settings.md b/docs/ru/operations/settings/constraints_on_settings.md deleted file mode 100644 index 71ae9cb3bb4..00000000000 --- a/docs/ru/operations/settings/constraints_on_settings.md +++ /dev/null @@ -1,69 +0,0 @@ -# Ограничения на изменение настроек {#ogranicheniia-na-izmenenie-nastroek} - -Ограничения на изменение настроек могут находиться внутри секции `profiles` файла `user.xml` и запрещают пользователю менять некоторые настройки с помощью запроса `SET`. -Выглядит это следующим образом: - -``` xml - - <имя_пользователя> - - <настройка_1> - нижняя_граница - - <настройка_2> - верхняя_граница - - <настройка_3> - нижняя_граница - верхняя_граница - - <настройка_4> - - - - - -``` - -Если пользователь пытается выйти за пределы, установленные этими ограничениями, то кидается исключение и настройка сохраняет прежнее значение. -Поддерживаются три типа ограничений: `min`, `max` и `readonly`. Ограничения `min` и `max` указывают нижнюю и верхнюю границы для числовых настроек и могут использоваться вместе. -Ограничение `readonly` указывает, что пользователь не может менять настройку. - -**Пример:** Пусть файл `users.xml` содержит строки: - -``` xml - - - 10000000000 - 0 - ... - - - 5000000000 - 20000000000 - - - - - - - -``` - -Каждый из следующих запросов кинет исключение: - -``` sql -SET max_memory_usage=20000000001; -SET max_memory_usage=4999999999; -SET force_index_by_date=1; -``` - -``` text -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. -Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. -``` - -**Примечание:** профиль с именем `default` обрабатывается специальным образом: все ограничения на изменение настроек из этого профиля становятся дефолтными и влияют на всех пользователей, кроме тех, где эти ограничения явно переопределены. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/constraints_on_settings/) diff --git a/docs/ru/operations/settings/index.md b/docs/ru/operations/settings/index.md index f60b7837acc..4acf7bbe67e 100644 --- a/docs/ru/operations/settings/index.md +++ b/docs/ru/operations/settings/index.md @@ -1,23 +1,29 @@ -# Настройки {#settings} +--- +toc_folder_title: "\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435" +toc_priority: 55 +toc_title: "\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438" +--- + +# Настройки {#session-settings-intro} Все настройки, описанные ниже, могут быть заданы несколькими способами. Настройки задаются послойно, т.е. каждый следующий слой перезаписывает предыдущие настройки. Способы задания настроек, упорядоченные по приоритету: -- Настройки в конфигурационном файле сервера `users.xml`. +- Настройки в конфигурационном файле сервера `users.xml`. - Устанавливаются в элементе ``. + Устанавливаются в элементе ``. -- Настройки для сессии. +- Настройки для сессии. - Из консольного клиента ClickHouse в интерактивном режиме отправьте запрос `SET setting=value`. - Аналогично можно использовать ClickHouse-сессии в HTTP-протоколе, для этого необходимо указывать HTTP-параметр `session_id`. + Из консольного клиента ClickHouse в интерактивном режиме отправьте запрос `SET setting=value`. + Аналогично можно использовать ClickHouse-сессии в HTTP-протоколе, для этого необходимо указывать HTTP-параметр `session_id`. -- Настройки для запроса. +- Настройки для запроса. - - При запуске консольного клиента ClickHouse в не интерактивном режиме установите параметр запуска `--setting=value`. - - При использовании HTTP API передавайте cgi-параметры (`URL?setting_1=value&setting_2=value...`). + - При запуске консольного клиента ClickHouse в не интерактивном режиме установите параметр запуска `--setting=value`. + - При использовании HTTP API передавайте cgi-параметры (`URL?setting_1=value&setting_2=value...`). Настройки, которые можно задать только в конфигурационном файле сервера, в разделе не рассматриваются. diff --git a/docs/ru/operations/settings/merge-tree-settings.md b/docs/ru/operations/settings/merge-tree-settings.md new file mode 100644 index 00000000000..c0123cfb5f8 --- /dev/null +++ b/docs/ru/operations/settings/merge-tree-settings.md @@ -0,0 +1,184 @@ +# Настройки MergeTree таблиц {#merge-tree-settings} + +Значения настроек для всех MergeTree таблиц можно посмотреть в таблице `system.merge_tree_settings`, их можно переопределить в `config.xml` в секции `merge_tree`, или задать в секции `SETTINGS` у каждой таблицы. + +Пример переопределения в `config.xml`: + +``` text + + 5 + +``` + +Пример для определения в `SETTINGS` у конкретной таблицы: + +``` sql +CREATE TABLE foo +( + `A` Int64 +) +ENGINE = MergeTree +ORDER BY tuple() +SETTINGS max_suspicious_broken_parts = 500; +``` + +Пример изменения настроек у конкретной таблицы командой `ALTER TABLE ... MODIFY SETTING`: + +``` sql +ALTER TABLE foo + MODIFY SETTING max_suspicious_broken_parts = 100; +``` + +## parts\_to\_throw\_insert {#parts-to-throw-insert} + +Eсли число кусков в партиции превышает значение `parts_to_throw_insert`, INSERT прерывается с исключением `Too many parts (N). Merges are processing significantly slower than inserts`. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 300. + +Для достижения максимальной производительности запросов `SELECT` необходимо минимизировать количество обрабатываемых кусков, см. [Дизайн MergeTree](../../development/architecture.md#merge-tree). + +Можно установить большее значение 600 (1200), это уменьшит вероятность возникновения ошибки `Too many parts`, но в тоже время вы позже обнаружите возможную проблему со слияниями (например, из-за недостатка места на диске) и деградацию производительности `SELECT`. + +## parts\_to\_delay\_insert {#parts-to-delay-insert} + +Eсли число кусков в партиции превышает значение `parts_to_delay_insert`, `INSERT` искусственно замедляется. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 150. + +ClickHouse искусственно выполняет `INSERT` дольше (добавляет ‘sleep’), чтобы фоновый механизм слияния успевал слиять куски быстрее, чем они добавляются. + +## max\_delay\_to\_insert {#max-delay-to-insert} + +Величина в секундах, которая используется для расчета задержки `INSERT`, если число кусков в партиции превышает значение [parts\_to\_delay\_insert](#parts-to-delay-insert). + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 1. + +Величина задержки (в миллисекундах) для `INSERT` вычисляется по формуле: + +``` code +max_k = parts_to_throw_insert - parts_to_delay_insert +k = 1 + parts_count_in_partition - parts_to_delay_insert +delay_milliseconds = pow(max_delay_to_insert * 1000, k / max_k) +``` + +Т.е. если в партиции уже 299 кусков и parts\_to\_throw\_insert = 300, parts\_to\_delay\_insert = 150, max\_delay\_to\_insert = 1, `INSERT` замедлится на `pow( 1 * 1000, (1 + 299 - 150) / (300 - 150) ) = 1000` миллисекунд. + +## max\_parts\_in\_total {#max-parts-in-total} + +Eсли суммарное число активных кусков во всех партициях таблицы превышает значение `max_parts_in_total`, INSERT прерывается с исключением `Too many parts (N)`. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 100000. + +Большое число кусков в таблице снижает производительность запросов ClickHouse и увеличивает время старта ClickHouse. Чаще всего это следствие неправильного дизайна (ошибки при выборе стратегии партиционирования -- слишком мелкие партиции). + +## replicated\_deduplication\_window {#replicated-deduplication-window} + +Количество хеш-сумм последних вставленных блоков, хранящихся в Zookeeper. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 100. + +Команда `Insert` создает один или несколько блоков (кусков). При вставке в Replicated таблицы ClickHouse для [дедупликации вставок](../../engines/table-engines/mergetree-family/replication.md) записывает в Zookeeper хеш-суммы созданных кусков. Но хранятся хеш-суммы не всех кусков, а только последние `replicated_deduplication_window`. Наиболее старые хеш-суммы удаляются из Zookeeper. +Большое число `replicated_deduplication_window` замедляет `Insert`-ы. Хеш-сумма рассчитывается от композиции имен и типов полей, а также данных вставленного куска (потока байт). + +## replicated\_deduplication\_window\_seconds {#replicated-deduplication-window-seconds} + +Число секунд, после которых хеш-суммы вставленных блоков удаляются из Zookeeper. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 604800 (1 неделя). + +Аналогично [replicated_deduplication_window](#replicated-deduplication-window), задает, сколько времени хранить хеш-суммы блоков для дедупликции `Insert`-в. Хеш-суммы старше `replicated_deduplication_window_seconds` удаляются из Zookeeper, даже если их меньше чем `replicated_deduplication_window`. + +## old\_parts\_lifetime {#old-parts-lifetime} + +Время (в секундах) хранения неактивных кусков, для защиты от потери данных при спонтанной перезагрузке сервера или О.С. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 480. + +После слияния нескольких кусков в новый кусок, ClickHouse помечает исходные куски как неактивные и удаляет их после `old_parts_lifetime` секунд. +Неактивные куски удаляются, если они не используются в текущих запросах, т.е. если счетчик ссылок куска – `refcount` равен нулю. + +Неактивные куски удаляются не сразу, потому что при записи нового куска не вызывается `fsync`, т.е. некоторое время новый кусок находится только в оперативной памяти сервера (кеше О.С.). Т.о. при спонтанной перезагрузке сервера новый (смерженный) кусок может быть потерян или испорчен. В этом случае ClickHouse в процессе старта при проверке целостности кусков обнаружит проблему, вернет неактивные куски в список активных и позже заново их смержит. Сломанный кусок в этом случае переименовывается (добавляется префикс broken\_) и перемещается в папку detached. Если проверка целостности не обнаруживает проблем в смерженном куске, то исходные неактивные куски переименовываются (добавляется префикс ignored\_) и перемещаются в папку detached. + +Стандартное значение Linux dirty\_expire\_centisecs - 30 секунд (максимальное время, которое записанные данные хранятся только в оперативной памяти), но при больших нагрузках на дисковую систему, данные могут быть записаны намного позже. Экспериментально было найдено время - 480 секунд, за которое гарантированно новый кусок будет записан на диск. + +## max\_bytes\_to\_merge\_at\_max\_space\_in\_pool {#max-bytes-to-merge-at-max-space-in-pool} + +Максимальный суммарный размер кусков (в байтах) в одном слиянии, при наличии свободных ресурсов в фоновом пуле. +`max_bytes_to_merge_at_max_space_in_pool` -- примерно соответствует максимально возможному размеру куска, созданного автоматическим фоновым слиянием. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 161061273600 (150ГБ). + +Планировщик мержей периодически анализирует размер и количество кусков в партициях, и при достаточном количестве свободных ресурсов в фоновом пуле начинает фоновое слияние. Слияния происходят до тех пор, пока суммарный размер входных кусков не достигнет `max_bytes_to_merge_at_max_space_in_pool`. + +Слияния, инициированные `optimize final`, не учитывают `max_bytes_to_merge_at_max_space_in_pool` и размеры кусков и слияют куски только с учетом наличия ресурсов в фоновом пуле, пока не останется один кусок в партиции. + +## max\_bytes\_to\_merge\_at\_min\_space\_in\_pool {#max-bytes-to-merge-at-min-space-in-pool} + +Максимальный суммарный размер кусков (в байтах) в одном слиянии, при минимальных свободных ресурсах в фоновом пуле. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 1048576 + +`max_bytes_to_merge_at_min_space_in_pool` задает максимальный суммарный размер кусков, для которых можно начать слияние, несмотря на недостаток свободных ресурсов в фоновом пуле (дискового пространства). Это необходимо, чтобы уменьшить количество маленьких кусков и вероятность ошибки `Too many parts`. +Слияния резервируют дисковое пространство, удваивая суммарный размер кусков в слиянии. Таким образом, при малом количестве свободного места на диске может сложится ситуация, что свободное место есть, но оно уже зарезервировано идущими слиянияними, поэтому другие слияния не могут начаться, и количество маленьких кусков в партиции растет с каждым инсертом. + +## merge\_max\_block\_size {#merge-max-block-size} + +Количество строк в блоках, которые читаются из слияемых кусков. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: 8192 + +Слияние читает строки из кусков блоками по `merge_max_block_size` строк, производит слияние и пишет результат в новый кусок. Читаемый блок помещается в оперативную память, т.е. `merge_max_block_size` влияет на размер оперативной памяти, необходимой для слияния. Таким образом, слияния могут потреблять большое количество оперативной памяти для таблиц, хранящих очень большие строки (если средний размер строки 100кб, то при слиянии 10 кусков будет использовано (100кб * 10 * 8192) =~ 8ГБ ОЗУ). Уменьшив `merge_max_block_size`, можно сократить размер оперативной памяти, необходимой для слияния. + +## max\_part\_loading\_threads {#max-part-loading-threads} + +Максимальное количество потоков, которые читают куски при старте ClickHouse. + +Возможные значения: + +- Положительное целое число. + +Значение по умолчанию: auto (количество ядер процессора). + +При старте ClickHouse читает все куски всех таблиц (читает файлы с метаданными кусков), чтобы построить в ОЗУ список всех кусков. В некоторых системах с большим количеством кусков этот процесс может занимать длительное время, и это время можно сократить, увеличив `max_part_loading_threads` (если при этом процессе есть недозагруженность CPU и диска). + +{## [Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/merge-tree-settings/) ##} diff --git a/docs/ru/operations/settings/merge_tree_settings.md b/docs/ru/operations/settings/merge_tree_settings.md deleted file mode 100644 index 5297e359547..00000000000 --- a/docs/ru/operations/settings/merge_tree_settings.md +++ /dev/null @@ -1,96 +0,0 @@ -# Настройки MergeTree таблиц {#merge-tree-settings} - -Значения настроек merge-tree (для всех MergeTree таблиц) можно посмотреть в таблице `system.merge_tree_settings`, их можно переопределить в `config.xml` в секции `merge_tree`, или задать в секции `SETTINGS` у каждой таблицы. - -Пример переопределения в `config.xml`: -```text - - 5 - -``` - -Пример для определения в `SETTINGS` у конкретной таблицы: -```sql -CREATE TABLE foo -( - `A` Int64 -) -ENGINE = MergeTree -ORDER BY tuple() -SETTINGS max_suspicious_broken_parts = 500; -``` - -Пример изменения настроек у конкретной таблицы командой `ALTER TABLE ... MODIFY SETTING`: -```sql -ALTER TABLE foo - MODIFY SETTING max_suspicious_broken_parts = 100; -``` - - -## parts_to_throw_insert {#parts-to-throw-insert} - -Eсли число кусков в партиции превышает значение `parts_to_throw_insert`, INSERT прерывается с исключением `Too many parts (N). Merges are processing significantly slower than inserts`. - -Возможные значения: - -- Положительное целое число. - -Значение по умолчанию: 300. - -Для достижения максимальной производительности запросов `SELECT` необходимо минимизировать количество обрабатываемых кусков, см. [Дизайн MergeTree](../../development/architecture.md#merge-tree). - -Можно установить большее значение 600 (1200), это уменьшит вероятность возникновения ошибки `Too many parts`, но в тоже время вы позже обнаружите возможную проблему со слияниями (например, из-за недостатка места на диске) и деградацию производительности `SELECT`. - - -## parts_to_delay_insert {#parts-to-delay-insert} - -Eсли число кусков в партиции превышает значение `parts_to_delay_insert`, `INSERT` искусственно замедляется. - -Возможные значения: - -- Положительное целое число. - -Значение по умолчанию: 150. - -ClickHouse искусственно выполняет `INSERT` дольше (добавляет 'sleep'), чтобы фоновый механизм слияния успевал слиять куски быстрее, чем они добавляются. - - -## max_delay_to_insert {#max-delay-to-insert} - -Величина в секундах, которая используется для расчета задержки `INSERT`, если число кусков в партиции превышает значение [parts_to_delay_insert](#parts-to-delay-insert). - -Возможные значения: - -- Положительное целое число. - -Значение по умолчанию: 1. - -Величина задержи (в миллисекундах) для `INSERT` вычисляется по формуле: - -```code -max_k = parts_to_throw_insert - parts_to_delay_insert -k = 1 + parts_count_in_partition - parts_to_delay_insert -delay_milliseconds = pow(max_delay_to_insert * 1000, k / max_k) -``` - -Т.е. если в партиции уже 299 кусков и parts_to_throw_insert = 300, parts_to_delay_insert = 150, max_delay_to_insert = 1, `INSERT` замедлится на `pow( 1 * 1000, (1 + 299 - 150) / (300 - 150) ) = 1000` миллисекунд. - -## old_parts_lifetime {#old-parts-lifetime} - -Время (в секундах) хранения неактивных кусков, для защиты от потери данных при спонтанной перезагрузке сервера или О.С. - -Возможные значения: - -- Положительное целое число. - -Значение по умолчанию: 480. - -После слияния нескольких кусков в новый кусок, ClickHouse помечает исходные куски как неактивные и удаляет их после `old_parts_lifetime` секунд. -Неактивные куски удаляются, если они не используются в текущих запросах, т.е. если счетчик ссылок куска -- `refcount` равен нулю. - -Неактивные куски удаляются не сразу, потому что при записи нового куска не вызывается `fsync`, т.е. некоторое время новый кусок находится только в оперативной памяти сервера (кеше О.С.). Т.о. при спонтанной перезагрузке сервера новый (смерженный) кусок может быть потерян или испорчен. В этом случае ClickHouse в процессе старта при проверке целостности кусков обнаружит проблему, вернет неактивные куски в список активных и позже заново их смержит. Сломанный кусок в этом случае переименовывается (добавляется префикс broken_) и перемещается в папку detached. Если проверка целостности не обнаруживает проблем в смерженном куске, то исходные неактивные куски переименовываются (добавляется префикс ignored_) и перемещаются в папку detached. - -Стандартное значение Linux dirty_expire_centisecs - 30 секунд (максимальное время, которое записанные данные хранятся только в оперативной памяти), но при больших нагрузках на дисковую систему, данные могут быть записаны намного позже. Экспериментально было найдено время - 480 секунд, за которое гарантированно новый кусок будет записан на диск. - - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/merge_tree_settings/) diff --git a/docs/ru/operations/settings/permissions-for-queries.md b/docs/ru/operations/settings/permissions-for-queries.md new file mode 100644 index 00000000000..bbc122041de --- /dev/null +++ b/docs/ru/operations/settings/permissions-for-queries.md @@ -0,0 +1,57 @@ +# Разрешения для запросов {#permissions_for_queries} + +Запросы в ClickHouse можно разделить на несколько типов: + +1. Запросы на чтение данных: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. +2. Запросы за запись данных: `INSERT`, `OPTIMIZE`. +3. Запросы на изменение настроек: `SET`, `USE`. +4. [Запросы DDL](https://ru.wikipedia.org/wiki/Data_Definition_Language): `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. +5. `KILL QUERY`. + +Разрешения пользователя по типу запроса регулируются параметрами: + +- [readonly](#settings_readonly) — ограничивает разрешения для всех типов запросов, кроме DDL. +- [allow\_ddl](#settings_allow_ddl) — ограничивает разрешения для DDL запросов. + +`KILL QUERY` выполняется с любыми настройками. + +## readonly {#settings_readonly} + +Ограничивает разрешения для запросов на чтение данных, запись данных и изменение параметров. + +Разделение запросов по типам смотрите по тексту [выше](#permissions_for_queries) по тексту. + +**Возможные значения** + +- 0 — разрешены все запросы. +- 1 — разрешены только запросы на чтение данных. +- 2 — разрешены запросы на чтение данных и изменение настроек. + +После установки `readonly = 1` или `2` пользователь не может изменить настройки `readonly` и `allow_ddl` в текущей сессии. + +При использовании метода `GET` в [HTTP интерфейсе](../../interfaces/http.md#http-interface), `readonly = 1` устанавливается автоматически. Для изменения данных используйте метод `POST`. + +Установка `readonly = 1` запрещает изменение всех настроек. Существует способ запретить изменения только некоторых настроек, см. [ограничения на изменение настроек](constraints-on-settings.md). + +**Значение по умолчанию** + +0 + +## allow\_ddl {#settings_allow_ddl} + +Разрешает/запрещает [DDL](https://ru.wikipedia.org/wiki/Data_Definition_Language) запросы. + +Разделение запросов по типам смотрите по тексту [выше](#permissions_for_queries) по тексту. + +**Возможные значения** + +- 0 — DDL запросы не разрешены. +- 1 — DDL запросы разрешены. + +Если `allow_ddl = 0`, то невозможно выполнить `SET allow_ddl = 1` для текущей сессии. + +**Значение по умолчанию** + +1 + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/permissions_for_queries/) diff --git a/docs/ru/operations/settings/permissions_for_queries.md b/docs/ru/operations/settings/permissions_for_queries.md deleted file mode 100644 index 1b37779422c..00000000000 --- a/docs/ru/operations/settings/permissions_for_queries.md +++ /dev/null @@ -1,57 +0,0 @@ -# Разрешения для запросов {#permissions_for_queries} - -Запросы в ClickHouse можно разделить на несколько типов: - -1. Запросы на чтение данных: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. -2. Запросы за запись данных: `INSERT`, `OPTIMIZE`. -3. Запросы на изменение настроек: `SET`, `USE`. -4. [Запросы DDL](https://ru.wikipedia.org/wiki/Data_Definition_Language): `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. -5. `KILL QUERY`. - -Разрешения пользователя по типу запроса регулируются параметрами: - -- [readonly](#settings_readonly) — ограничивает разрешения для всех типов запросов, кроме DDL. -- [allow\_ddl](#settings_allow_ddl) — ограничивает разрешения для DDL запросов. - -`KILL QUERY` выполняется с любыми настройками. - -## readonly {#settings_readonly} - -Ограничивает разрешения для запросов на чтение данных, запись данных и изменение параметров. - -Разделение запросов по типам смотрите по тексту [выше](#permissions_for_queries) по тексту. - -**Возможные значения** - -- 0 — разрешены все запросы. -- 1 — разрешены только запросы на чтение данных. -- 2 — разрешены запросы на чтение данных и изменение настроек. - -После установки `readonly = 1` или `2` пользователь не может изменить настройки `readonly` и `allow_ddl` в текущей сессии. - -При использовании метода `GET` в [HTTP интерфейсе](../../interfaces/http.md#http_interface), `readonly = 1` устанавливается автоматически. Для изменения данных используйте метод `POST`. - -Установка `readonly = 1` запрещает изменение всех настроек. Существует способ запретить изменения только некоторых настроек, см. [ограничения на изменение настроек](constraints_on_settings.md). - -**Значение по умолчанию** - -0 - -## allow\_ddl {#settings_allow_ddl} - -Разрешает/запрещает [DDL](https://ru.wikipedia.org/wiki/Data_Definition_Language) запросы. - -Разделение запросов по типам смотрите по тексту [выше](#permissions_for_queries) по тексту. - -**Возможные значения** - -- 0 — DDL запросы не разрешены. -- 1 — DDL запросы разрешены. - -Если `allow_ddl = 0`, то невозможно выполнить `SET allow_ddl = 1` для текущей сессии. - -**Значение по умолчанию** - -1 - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/permissions_for_queries/) diff --git a/docs/ru/operations/settings/query-complexity.md b/docs/ru/operations/settings/query-complexity.md new file mode 100644 index 00000000000..651f597c4d2 --- /dev/null +++ b/docs/ru/operations/settings/query-complexity.md @@ -0,0 +1,295 @@ +# Ограничения на сложность запроса {#ogranicheniia-na-slozhnost-zaprosa} + +Ограничения на сложность запроса - часть настроек. +Используются, чтобы обеспечить более безопасное исполнение запросов из пользовательского интерфейса. +Почти все ограничения действуют только на SELECT-ы. +При распределённой обработке запроса, ограничения действуют на каждом сервере по отдельности. + +Ограничения проверяются на каждый блок обработанных данных, а не на каждую строку. В связи с этим, ограничения могут быть превышены на размер блока. + +Ограничения вида «максимальное количество чего-нибудь» могут принимать значение 0, которое обозначает «не ограничено». +Для большинства ограничений также присутствует настройка вида overflow\_mode - что делать, когда ограничение превышено. +Оно может принимать одно из двух значений: `throw` или `break`; а для ограничения на агрегацию (group\_by\_overflow\_mode) есть ещё значение `any`. + +`throw` - кинуть исключение (по умолчанию). + +`break` - прервать выполнение запроса и вернуть неполный результат, как будто исходные данные закончились. + +`any (только для group_by_overflow_mode)` - продолжить агрегацию по ключам, которые успели войти в набор, но не добавлять новые ключи в набор. + +## max\_memory\_usage {#settings_max_memory_usage} + +Максимальный возможный объём оперативной памяти для выполнения запроса на одном сервере. + +В конфигурационном файле по умолчанию, ограничение равно 10 ГБ. + +Настройка не учитывает объём свободной памяти или общий объём памяти на машине. +Ограничение действует на один запрос, в пределах одного сервера. +Текущее потребление памяти для каждого запроса можно посмотреть с помощью `SHOW PROCESSLIST`. +Также отслеживается и выводится в лог пиковое потребление памяти для каждого запроса. + +Потребление памяти не отслеживается для состояний некоторых агрегатных функций. + +Потребление памяти не полностью учитывается для состояний агрегатных функций `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` от аргументов `String` и `Array`. + +Потребление памяти ограничивается также параметрами `max_memory_usage_for_user` и `max_memory_usage_for_all_queries`. + +## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} + +Максимальный возможный объём оперативной памяти для запросов пользователя на одном сервере. + +Значения по умолчанию определены в файле [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). По умолчанию размер не ограничен (`max_memory_usage_for_user = 0`). + +Смотрите также описание настройки [max\_memory\_usage](#settings_max_memory_usage). + +## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} + +Максимальный возможный объём оперативной памяти для всех запросов на одном сервере. + +Значения по умолчанию определены в файле [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). По умолчанию размер не ограничен (`max_memory_usage_for_all_queries = 0`). + +Смотрите также описание настройки [max\_memory\_usage](#settings_max_memory_usage). + +## max\_rows\_to\_read {#max-rows-to-read} + +Следующие ограничения могут проверяться на каждый блок (а не на каждую строку). То есть, ограничения могут быть немного нарушены. +При выполнении запроса в несколько потоков, следующие ограничения действуют в каждом потоке по отдельности. + +Максимальное количество строчек, которое можно прочитать из таблицы при выполнении запроса. + +## max\_bytes\_to\_read {#max-bytes-to-read} + +Максимальное количество байт (несжатых данных), которое можно прочитать из таблицы при выполнении запроса. + +## read\_overflow\_mode {#read-overflow-mode} + +Что делать, когда количество прочитанных данных превысило одно из ограничений: throw или break. По умолчанию: throw. + +## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} + +Максимальное количество уникальных ключей, получаемых в процессе агрегации. Позволяет ограничить потребление оперативки при агрегации. + +## group\_by\_overflow\_mode {#group-by-overflow-mode} + +Что делать, когда количество уникальных ключей при агрегации превысило ограничение: throw, break или any. По умолчанию: throw. +Использование значения any позволяет выполнить GROUP BY приближённо. Качество такого приближённого вычисления сильно зависит от статистических свойств данных. + +## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} + +Включает или отключает выполнение секций `GROUP BY` во внешней памяти. Смотрите [GROUP BY во внешней памяти](../../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory). + +Возможные значения: + +- Максимальный объём RAM (в байтах), который может использовать отдельная операция [GROUP BY](../../sql-reference/statements/select/group-by.md#select-group-by-clause). +- 0 — `GROUP BY` во внешней памяти отключен. + +Значение по умолчанию — 0. + +## max\_rows\_to\_sort {#max-rows-to-sort} + +Максимальное количество строк до сортировки. Позволяет ограничить потребление оперативки при сортировке. + +## max\_bytes\_to\_sort {#max-bytes-to-sort} + +Максимальное количество байт до сортировки. + +## sort\_overflow\_mode {#sort-overflow-mode} + +Что делать, если количество строк, полученное перед сортировкой, превысило одно из ограничений: throw или break. По умолчанию: throw. + +## max\_result\_rows {#setting-max_result_rows} + +Ограничение на количество строк результата. Проверяются также для подзапросов и на удалённых серверах при выполнении части распределённого запроса. + +## max\_result\_bytes {#max-result-bytes} + +Ограничение на количество байт результата. Аналогично. + +## result\_overflow\_mode {#result-overflow-mode} + +Что делать, если объём результата превысил одно из ограничений: throw или break. По умолчанию: throw. + +Использование break по смыслу похоже на LIMIT. Break прерывает выполнение только на уровне блока. Т.е. число строк которые вернет запрос будет больше чем ограничение [max\_result\_rows](#setting-max_result_rows), кратно [max\_block\_size](../settings/settings.md#setting-max_block_size) и зависит от [max\_threads](../settings/settings.md#settings-max_threads). + +Пример: + +``` sql +SET max_threads = 3, max_block_size = 3333; +SET max_result_rows = 3334, result_overflow_mode = 'break'; + +SELECT * +FROM numbers_mt(100000) +FORMAT Null; +``` + +Результат: + +``` text +6666 rows in set. ... +``` + +## max\_execution\_time {#max-execution-time} + +Максимальное время выполнения запроса в секундах. +На данный момент не проверяется при одной из стадий сортировки а также при слиянии и финализации агрегатных функций. + +## timeout\_overflow\_mode {#timeout-overflow-mode} + +Что делать, если запрос выполняется дольше max\_execution\_time: throw или break. По умолчанию: throw. + +## min\_execution\_speed {#min-execution-speed} + +Минимальная скорость выполнения запроса в строчках в секунду. Проверяется на каждый блок данных по истечении timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса оказывается меньше, то кидается исключение. + +## min\_execution\_speed\_bytes {#min-execution-speed-bytes} + +Минимальная скорость выполнения запроса в строках на байт. Он проверяется для каждого блока данных после timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса меньше, исключение. + +## max\_execution\_speed {#max-execution-speed} + +Максимальная скорость выполнения запроса в строках в секунду. Он проверяется для каждого блока данных после timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса выше, скорость будет снижена. + +## max\_execution\_speed\_bytes {#max-execution-speed-bytes} + +Максимальная скорость выполнения запроса в байтах в секунду. Он проверяется для каждого блока данных после timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса выше, скорость будет снижена. + +## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} + +Проверять, что скорость выполнения запроса не слишком низкая (не меньше min\_execution\_speed), после прошествия указанного времени в секундах. + +## max\_columns\_to\_read {#max-columns-to-read} + +Максимальное количество столбцов, которых можно читать из таблицы в одном запросе. Если запрос требует чтения большего количества столбцов - кинуть исключение. + +## max\_temporary\_columns {#max-temporary-columns} + +Максимальное количество временных столбцов, которых необходимо одновременно держать в оперативке, в процессе выполнения запроса, включая константные столбцы. Если временных столбцов оказалось больше - кидается исключение. + +## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} + +То же самое, что и max\_temporary\_columns, но без учёта столбцов-констант. +Стоит заметить, что столбцы-константы довольно часто образуются в процессе выполнения запроса, но расходуют примерно нулевое количество вычислительных ресурсов. + +## max\_subquery\_depth {#max-subquery-depth} + +Максимальная вложенность подзапросов. Если подзапросы более глубокие - кидается исключение. По умолчанию: 100. + +## max\_pipeline\_depth {#max-pipeline-depth} + +Максимальная глубина конвейера выполнения запроса. Соответствует количеству преобразований, которое проходит каждый блок данных в процессе выполнения запроса. Считается в пределах одного сервера. Если глубина конвейера больше - кидается исключение. По умолчанию: 1000. + +## max\_ast\_depth {#max-ast-depth} + +Максимальная вложенность синтаксического дерева запроса. Если превышена - кидается исключение. +На данный момент, проверяются не во время парсинга а уже после парсинга запроса. То есть, во время парсинга может быть создано слишком глубокое синтаксическое дерево, но запрос не будет выполнен. По умолчанию: 1000. + +## max\_ast\_elements {#max-ast-elements} + +Максимальное количество элементов синтаксического дерева запроса. Если превышено - кидается исключение. +Аналогично, проверяется уже после парсинга запроса. По умолчанию: 50 000. + +## max\_rows\_in\_set {#max-rows-in-set} + +Максимальное количество строчек для множества в секции IN, создаваемого из подзапроса. + +## max\_bytes\_in\_set {#max-bytes-in-set} + +Максимальное количество байт (несжатых данных), занимаемое множеством в секции IN, создаваемым из подзапроса. + +## set\_overflow\_mode {#set-overflow-mode} + +Что делать, когда количество данных превысило одно из ограничений: throw или break. По умолчанию: throw. + +## max\_rows\_in\_distinct {#max-rows-in-distinct} + +Максимальное количество различных строчек при использовании DISTINCT. + +## max\_bytes\_in\_distinct {#max-bytes-in-distinct} + +Максимальное количество байт, занимаемых хэш-таблицей, при использовании DISTINCT. + +## distinct\_overflow\_mode {#distinct-overflow-mode} + +Что делать, когда количество данных превысило одно из ограничений: throw или break. По умолчанию: throw. + +## max\_rows\_to\_transfer {#max-rows-to-transfer} + +Максимальное количество строчек, которых можно передать на удалённый сервер или сохранить во временную таблицу, при использовании GLOBAL IN. + +## max\_bytes\_to\_transfer {#max-bytes-to-transfer} + +Максимальное количество байт (несжатых данных), которых можно передать на удалённый сервер или сохранить во временную таблицу, при использовании GLOBAL IN. + +## transfer\_overflow\_mode {#transfer-overflow-mode} + +Что делать, когда количество данных превысило одно из ограничений: throw или break. По умолчанию: throw. + +## max\_rows\_in\_join {#settings-max_rows_in_join} + +Ограничивает количество строк в хэш-таблице, используемой при соединении таблиц. + +Параметр применяется к операциям [SELECT… JOIN](../../sql-reference/statements/select/join.md#select-join) и к движку таблиц [Join](../../engines/table-engines/special/join.md). + +Если запрос содержит несколько `JOIN`, то ClickHouse проверяет значение настройки для каждого промежуточного результата. + +При достижении предела ClickHouse может выполнять различные действия. Используйте настройку [join\_overflow\_mode](#settings-join_overflow_mode) для выбора действия. + +Возможные значения: + +- Положительное целое число. +- 0 — неограниченное количество строк. + +Значение по умолчанию — 0. + +## max\_bytes\_in\_join {#settings-max_bytes_in_join} + +Ограничивает размер (в байтах) хэш-таблицы, используемой при объединении таблиц. + +Параметр применяется к операциям [SELECT… JOIN](../../sql-reference/statements/select/join.md#select-join) и к движку таблиц [Join](../../engines/table-engines/special/join.md). + +Если запрос содержит несколько `JOIN`, то ClickHouse проверяет значение настройки для каждого промежуточного результата. + +При достижении предела ClickHouse может выполнять различные действия. Используйте настройку [join\_overflow\_mode](#settings-join_overflow_mode) для выбора действия. + +Возможные значения: + +- Положительное целое число. +- 0 — контроль памяти отключен. + +Значение по умолчанию — 0. + +## join\_overflow\_mode {#settings-join_overflow_mode} + +Определяет, какое действие ClickHouse выполняет при достижении любого из следующих ограничений для `JOIN`: + +- [max\_bytes\_in\_join](#settings-max_bytes_in_join) +- [max\_rows\_in\_join](#settings-max_rows_in_join) + +Возможные значения: + +- `THROW` — ClickHouse генерирует исключение и прерывает операцию. +- `BREAK` — ClickHouse прерывает операцию, но не генерирует исключение. + +Значение по умолчанию — `THROW`. + +**Смотрите также** + +- [Секция JOIN](../../sql-reference/statements/select/join.md#select-join) +- [Движоy таблиц Join](../../engines/table-engines/special/join.md) + +## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} + +Ограничивает максимальное количество партиций в одном вставленном блоке. + +- Положительное целое число. +- 0 — неограниченное количество разделов. + +Значение по умолчанию: 100. + +**Подробности** + +При вставке данных, ClickHouse вычисляет количество партиций во вставленном блоке. Если число партиций больше, чем `max_partitions_per_insert_block`, ClickHouse генерирует исключение со следующим текстом: + +> «Too many partitions for single INSERT block (more than» + toString(max\_parts) + «). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. Large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).» + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/query_complexity/) diff --git a/docs/ru/operations/settings/query_complexity.md b/docs/ru/operations/settings/query_complexity.md deleted file mode 100644 index 5ad28eed0a8..00000000000 --- a/docs/ru/operations/settings/query_complexity.md +++ /dev/null @@ -1,295 +0,0 @@ -# Ограничения на сложность запроса {#ogranicheniia-na-slozhnost-zaprosa} - -Ограничения на сложность запроса - часть настроек. -Используются, чтобы обеспечить более безопасное исполнение запросов из пользовательского интерфейса. -Почти все ограничения действуют только на SELECT-ы. -При распределённой обработке запроса, ограничения действуют на каждом сервере по отдельности. - -Ограничения проверяются на каждый блок обработанных данных, а не на каждую строку. В связи с этим, ограничения могут быть превышены на размер блока. - -Ограничения вида «максимальное количество чего-нибудь» могут принимать значение 0, которое обозначает «не ограничено». -Для большинства ограничений также присутствует настройка вида overflow\_mode - что делать, когда ограничение превышено. -Оно может принимать одно из двух значений: `throw` или `break`; а для ограничения на агрегацию (group\_by\_overflow\_mode) есть ещё значение `any`. - -`throw` - кинуть исключение (по умолчанию). - -`break` - прервать выполнение запроса и вернуть неполный результат, как будто исходные данные закончились. - -`any (только для group_by_overflow_mode)` - продолжить агрегацию по ключам, которые успели войти в набор, но не добавлять новые ключи в набор. - -## max\_memory\_usage {#settings_max_memory_usage} - -Максимальный возможный объём оперативной памяти для выполнения запроса на одном сервере. - -В конфигурационном файле по умолчанию, ограничение равно 10 ГБ. - -Настройка не учитывает объём свободной памяти или общий объём памяти на машине. -Ограничение действует на один запрос, в пределах одного сервера. -Текущее потребление памяти для каждого запроса можно посмотреть с помощью `SHOW PROCESSLIST`. -Также отслеживается и выводится в лог пиковое потребление памяти для каждого запроса. - -Потребление памяти не отслеживается для состояний некоторых агрегатных функций. - -Потребление памяти не полностью учитывается для состояний агрегатных функций `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` от аргументов `String` и `Array`. - -Потребление памяти ограничивается также параметрами `max_memory_usage_for_user` и `max_memory_usage_for_all_queries`. - -## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} - -Максимальный возможный объём оперативной памяти для запросов пользователя на одном сервере. - -Значения по умолчанию определены в файле [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). По умолчанию размер не ограничен (`max_memory_usage_for_user = 0`). - -Смотрите также описание настройки [max\_memory\_usage](#settings_max_memory_usage). - -## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} - -Максимальный возможный объём оперативной памяти для всех запросов на одном сервере. - -Значения по умолчанию определены в файле [Settings.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). По умолчанию размер не ограничен (`max_memory_usage_for_all_queries = 0`). - -Смотрите также описание настройки [max\_memory\_usage](#settings_max_memory_usage). - -## max\_rows\_to\_read {#max-rows-to-read} - -Следующие ограничения могут проверяться на каждый блок (а не на каждую строку). То есть, ограничения могут быть немного нарушены. -При выполнении запроса в несколько потоков, следующие ограничения действуют в каждом потоке по отдельности. - -Максимальное количество строчек, которое можно прочитать из таблицы при выполнении запроса. - -## max\_bytes\_to\_read {#max-bytes-to-read} - -Максимальное количество байт (несжатых данных), которое можно прочитать из таблицы при выполнении запроса. - -## read\_overflow\_mode {#read-overflow-mode} - -Что делать, когда количество прочитанных данных превысило одно из ограничений: throw или break. По умолчанию: throw. - -## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} - -Максимальное количество уникальных ключей, получаемых в процессе агрегации. Позволяет ограничить потребление оперативки при агрегации. - -## group\_by\_overflow\_mode {#group-by-overflow-mode} - -Что делать, когда количество уникальных ключей при агрегации превысило ограничение: throw, break или any. По умолчанию: throw. -Использование значения any позволяет выполнить GROUP BY приближённо. Качество такого приближённого вычисления сильно зависит от статистических свойств данных. - -## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} - -Включает или отключает выполнение секций `GROUP BY` во внешней памяти. Смотрите [GROUP BY во внешней памяти](../../sql_reference/statements/select.md#select-group-by-in-external-memory). - -Возможные значения: - -- Максимальный объём RAM (в байтах), который может использовать отдельная операция [GROUP BY](../../sql_reference/statements/select.md#select-group-by-clause). -- 0 — `GROUP BY` во внешней памяти отключен. - -Значение по умолчанию — 0. - -## max\_rows\_to\_sort {#max-rows-to-sort} - -Максимальное количество строк до сортировки. Позволяет ограничить потребление оперативки при сортировке. - -## max\_bytes\_to\_sort {#max-bytes-to-sort} - -Максимальное количество байт до сортировки. - -## sort\_overflow\_mode {#sort-overflow-mode} - -Что делать, если количество строк, полученное перед сортировкой, превысило одно из ограничений: throw или break. По умолчанию: throw. - -## max\_result\_rows {#setting-max_result_rows} - -Ограничение на количество строк результата. Проверяются также для подзапросов и на удалённых серверах при выполнении части распределённого запроса. - -## max\_result\_bytes {#max-result-bytes} - -Ограничение на количество байт результата. Аналогично. - -## result\_overflow\_mode {#result-overflow-mode} - -Что делать, если объём результата превысил одно из ограничений: throw или break. По умолчанию: throw. - -Использование break по смыслу похоже на LIMIT. Break прерывает выполнение только на уровне блока. Т.е. число строк которые вернет запрос будет больше чем ограничение [max\_result\_rows](#setting-max_result_rows), кратно [max\_block\_size](settings.md#setting-max_block_size) и зависит от [max\_threads](settings.md#settings-max_threads). - -Пример: - -``` sql -SET max_threads = 3, max_block_size = 3333; -SET max_result_rows = 3334, result_overflow_mode = 'break'; - -SELECT * -FROM numbers_mt(100000) -FORMAT Null; -``` - -Результат: - -``` text -6666 rows in set. ... -``` - -## max\_execution\_time {#max-execution-time} - -Максимальное время выполнения запроса в секундах. -На данный момент не проверяется при одной из стадий сортировки а также при слиянии и финализации агрегатных функций. - -## timeout\_overflow\_mode {#timeout-overflow-mode} - -Что делать, если запрос выполняется дольше max\_execution\_time: throw или break. По умолчанию: throw. - -## min\_execution\_speed {#min-execution-speed} - -Минимальная скорость выполнения запроса в строчках в секунду. Проверяется на каждый блок данных по истечении timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса оказывается меньше, то кидается исключение. - -## min\_execution\_speed\_bytes {#min-execution-speed-bytes} - -Минимальная скорость выполнения запроса в строках на байт. Он проверяется для каждого блока данных после timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса меньше, исключение. - -## max\_execution\_speed {#max-execution-speed} - -Максимальная скорость выполнения запроса в строках в секунду. Он проверяется для каждого блока данных после timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса выше, скорость будет снижена. - -## max\_execution\_speed\_bytes {#max-execution-speed-bytes} - -Максимальная скорость выполнения запроса в байтах в секунду. Он проверяется для каждого блока данных после timeout\_before\_checking\_execution\_speed. Если скорость выполнения запроса выше, скорость будет снижена. - -## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} - -Проверять, что скорость выполнения запроса не слишком низкая (не меньше min\_execution\_speed), после прошествия указанного времени в секундах. - -## max\_columns\_to\_read {#max-columns-to-read} - -Максимальное количество столбцов, которых можно читать из таблицы в одном запросе. Если запрос требует чтения большего количества столбцов - кинуть исключение. - -## max\_temporary\_columns {#max-temporary-columns} - -Максимальное количество временных столбцов, которых необходимо одновременно держать в оперативке, в процессе выполнения запроса, включая константные столбцы. Если временных столбцов оказалось больше - кидается исключение. - -## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} - -То же самое, что и max\_temporary\_columns, но без учёта столбцов-констант. -Стоит заметить, что столбцы-константы довольно часто образуются в процессе выполнения запроса, но расходуют примерно нулевое количество вычислительных ресурсов. - -## max\_subquery\_depth {#max-subquery-depth} - -Максимальная вложенность подзапросов. Если подзапросы более глубокие - кидается исключение. По умолчанию: 100. - -## max\_pipeline\_depth {#max-pipeline-depth} - -Максимальная глубина конвейера выполнения запроса. Соответствует количеству преобразований, которое проходит каждый блок данных в процессе выполнения запроса. Считается в пределах одного сервера. Если глубина конвейера больше - кидается исключение. По умолчанию: 1000. - -## max\_ast\_depth {#max-ast-depth} - -Максимальная вложенность синтаксического дерева запроса. Если превышена - кидается исключение. -На данный момент, проверяются не во время парсинга а уже после парсинга запроса. То есть, во время парсинга может быть создано слишком глубокое синтаксическое дерево, но запрос не будет выполнен. По умолчанию: 1000. - -## max\_ast\_elements {#max-ast-elements} - -Максимальное количество элементов синтаксического дерева запроса. Если превышено - кидается исключение. -Аналогично, проверяется уже после парсинга запроса. По умолчанию: 50 000. - -## max\_rows\_in\_set {#max-rows-in-set} - -Максимальное количество строчек для множества в секции IN, создаваемого из подзапроса. - -## max\_bytes\_in\_set {#max-bytes-in-set} - -Максимальное количество байт (несжатых данных), занимаемое множеством в секции IN, создаваемым из подзапроса. - -## set\_overflow\_mode {#set-overflow-mode} - -Что делать, когда количество данных превысило одно из ограничений: throw или break. По умолчанию: throw. - -## max\_rows\_in\_distinct {#max-rows-in-distinct} - -Максимальное количество различных строчек при использовании DISTINCT. - -## max\_bytes\_in\_distinct {#max-bytes-in-distinct} - -Максимальное количество байт, занимаемых хэш-таблицей, при использовании DISTINCT. - -## distinct\_overflow\_mode {#distinct-overflow-mode} - -Что делать, когда количество данных превысило одно из ограничений: throw или break. По умолчанию: throw. - -## max\_rows\_to\_transfer {#max-rows-to-transfer} - -Максимальное количество строчек, которых можно передать на удалённый сервер или сохранить во временную таблицу, при использовании GLOBAL IN. - -## max\_bytes\_to\_transfer {#max-bytes-to-transfer} - -Максимальное количество байт (несжатых данных), которых можно передать на удалённый сервер или сохранить во временную таблицу, при использовании GLOBAL IN. - -## transfer\_overflow\_mode {#transfer-overflow-mode} - -Что делать, когда количество данных превысило одно из ограничений: throw или break. По умолчанию: throw. - -## max\_rows\_in\_join {#settings-max_rows_in_join} - -Ограничивает количество строк в хэш-таблице, используемой при соединении таблиц. - -Параметр применяется к операциям [SELECT… JOIN](../../sql_reference/statements/select.md#select-join) и к движку таблиц [Join](../../engines/table_engines/special/join.md). - -Если запрос содержит несколько `JOIN`, то ClickHouse проверяет значение настройки для каждого промежуточного результата. - -При достижении предела ClickHouse может выполнять различные действия. Используйте настройку [join\_overflow\_mode](#settings-join_overflow_mode) для выбора действия. - -Возможные значения: - -- Положительное целое число. -- 0 — неограниченное количество строк. - -Значение по умолчанию — 0. - -## max\_bytes\_in\_join {#settings-max_bytes_in_join} - -Ограничивает размер (в байтах) хэш-таблицы, используемой при объединении таблиц. - -Параметр применяется к операциям [SELECT… JOIN](../../sql_reference/statements/select.md#select-join) и к движку таблиц [Join](../../engines/table_engines/special/join.md). - -Если запрос содержит несколько `JOIN`, то ClickHouse проверяет значение настройки для каждого промежуточного результата. - -При достижении предела ClickHouse может выполнять различные действия. Используйте настройку [join\_overflow\_mode](#settings-join_overflow_mode) для выбора действия. - -Возможные значения: - -- Положительное целое число. -- 0 — контроль памяти отключен. - -Значение по умолчанию — 0. - -## join\_overflow\_mode {#settings-join_overflow_mode} - -Определяет, какое действие ClickHouse выполняет при достижении любого из следующих ограничений для `JOIN`: - -- [max\_bytes\_in\_join](#settings-max_bytes_in_join) -- [max\_rows\_in\_join](#settings-max_rows_in_join) - -Возможные значения: - -- `THROW` — ClickHouse генерирует исключение и прерывает операцию. -- `BREAK` — ClickHouse прерывает операцию, но не генерирует исключение. - -Значение по умолчанию — `THROW`. - -**Смотрите также** - -- [Секция JOIN](../../sql_reference/statements/select.md#select-join) -- [Движоy таблиц Join](../../engines/table_engines/special/join.md) - -## max\_partitions\_per\_insert\_block {#max-partitions-per-insert-block} - -Ограничивает максимальное количество партиций в одном вставленном блоке. - -- Положительное целое число. -- 0 — неограниченное количество разделов. - -Значение по умолчанию: 100. - -**Подробности** - -При вставке данных, ClickHouse вычисляет количество партиций во вставленном блоке. Если число партиций больше, чем `max_partitions_per_insert_block`, ClickHouse генерирует исключение со следующим текстом: - -> «Too many partitions for single INSERT block (more than» + toString(max\_parts) + «). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. Large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).» - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/query_complexity/) diff --git a/docs/ru/operations/settings/settings-profiles.md b/docs/ru/operations/settings/settings-profiles.md new file mode 100644 index 00000000000..d1e24490120 --- /dev/null +++ b/docs/ru/operations/settings/settings-profiles.md @@ -0,0 +1,75 @@ +# Профили настроек {#settings-profiles} + +Профиль настроек — это набор настроек, сгруппированных под одним именем. + +!!! note "Информация" + Для управления профилями настроек рекомендуется использовать [SQL-ориентированный воркфлоу](../access-rights.md#access-control), который также поддерживается в ClickHouse. + + +Название профиля может быть любым. Вы можете указать один и тот же профиль для разных пользователей. Самое важное, что можно прописать в профиле — `readonly=1`, это обеспечит доступ только на чтение. + +Профили настроек поддерживают наследование. Это реализуется указанием одной или нескольких настроек `profile` перед остальными настройками, перечисленными в профиле. Если одна настройка указана в нескольких профилях, используется последнее из значений. + +Все настройки профиля можно применить, установив настройку `profile`. + +Пример: + +Установить профиль `web`. + +``` sql +SET profile = 'web' +``` + +Профили настроек объявляются в конфигурационном файле пользователей. Обычно это `users.xml`. + +Пример: + +``` xml + + + + + + 8 + + + + + 1000000000 + 100000000000 + + 1000000 + any + + 1000000 + 1000000000 + + 100000 + 100000000 + break + + 600 + 1000000 + 15 + + 25 + 100 + 50 + + 2 + 25 + 50 + 100 + + 1 + + +``` + +В примере задано два профиля: `default` и `web`. + +Профиль `default` имеет специальное значение — он обязателен и применяется при запуске сервера. Профиль `default` содержит настройки по умолчанию. + +Профиль `web` — обычный профиль, который может быть установлен с помощью запроса `SET` или параметра URL при запросе по HTTP. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings_profiles/) diff --git a/docs/ru/operations/settings/settings-users.md b/docs/ru/operations/settings/settings-users.md new file mode 100644 index 00000000000..95701f0f639 --- /dev/null +++ b/docs/ru/operations/settings/settings-users.md @@ -0,0 +1,160 @@ +# Настройки пользователей {#nastroiki-polzovatelei} + +Раздел `users` конфигурационного файла `user.xml` содержит настройки для пользователей. + +!!! note "Информация" + Для управления пользователями рекомендуется использовать [SQL-ориентированный воркфлоу](../access-rights.md#access-control), который также поддерживается в ClickHouse. + +Структура раздела `users`: + +``` xml + + + + + + + + 0|1 + + + + + profile_name + + default + + + + + expression + + + + + + +``` + +### user\_name/password {#user-namepassword} + +Пароль можно указать в текстовом виде или в виде SHA256 (шестнадцатеричный формат). + +- Чтобы назначить пароль в текстовом виде (**не рекомендуем**), поместите его в элемент `password`. + + Например, `qwerty`. Пароль можно оставить пустым. + + + +- Чтобы назначить пароль в виде SHA256, поместите хэш в элемент `password_sha256_hex`. + + Например, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. + + Пример создания пароля в командной строке: + + ``` + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' + ``` + + Первая строка результата — пароль. Вторая строка — соответствующий ему хэш SHA256. + + + +- Для совместимости с клиентами MySQL, пароль можно задать с помощью двойного хэша SHA1, поместив его в элемент `password_double_sha1_hex`. + + Например, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. + + Пример создания пароля в командной строке: + + ``` + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' + ``` + + Первая строка результата — пароль. Вторая строка — соответствующий ему двойной хэш SHA1. + +### access_management {#access_management-user-setting} + +Включает или выключает SQL-ориентированное [управление доступом](../access-rights.md#access-control) для пользователя. + +Возможные значения: + +- 0 — Выключено. +- 1 — Включено. + +Значение по умолчанию: 0. + +### user\_name/networks {#user-namenetworks} + +Список сетей, из которых пользователь может подключиться к серверу ClickHouse. + +Каждый элемент списка имеет одну из следующих форм: + +- `` — IP-адрес или маска подсети. + + Примеры: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. + +- `` — Имя хоста. + + Пример: `example01.host.ru`. + + Для проверки доступа выполняется DNS-запрос, и все возвращенные IP-адреса сравниваются с адресом клиента. + +- `` — Регулярное выражение для имен хостов. + + Пример, `^example\d\d-\d\d-\d\.host\.ru$` + + Для проверки доступа выполняется [DNS запрос PTR](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) для адреса клиента, а затем применяется заданное регулярное выражение. Затем, для результатов запроса PTR выполняется другой DNS-запрос и все полученные адреса сравниваются с адресом клиента. Рекомендуем завершать регулярное выражение символом $. + +Все результаты DNS-запросов кэшируются до перезапуска сервера. + +**Примеры** + +Чтобы открыть доступ пользователю из любой сети, укажите: + +``` xml +::/0 +``` + +!!! warning "Внимание" + Открывать доступ из любой сети небезопасно, если у вас нет правильно настроенного брандмауэра или сервер не отключен от интернета. + +Чтобы открыть только локальный доступ, укажите: + +``` xml +::1 +127.0.0.1 +``` + +### user\_name/profile {#user-nameprofile} + +Пользователю можно назначить профиль настроек. Профили настроек конфигурируются в отдельной секции файла `users.xml`. Подробнее читайте в разделе [Профили настроек](settings-profiles.md). + +### user\_name/quota {#user-namequota} + +Квотирование позволяет отслеживать или ограничивать использование ресурсов в течение определённого периода времени. Квоты настраиваются в разделе `quotas` конфигурационного файла `users.xml`. + +Пользователю можно назначить квоты. Подробное описание настройки квот смотрите в разделе [Квоты](../quotas.md#quotas). + +### user\_name/databases {#user-namedatabases} + +В этом разделе вы можете ограничить выдачу ClickHouse запросами `SELECT` для конкретного пользователя, таким образом реализуя базовую защиту на уровне строк. + +**Пример** + +Следующая конфигурация задаёт, что пользователь `user1` в результате запросов `SELECT` может получать только те строки `table1`, в которых значение поля `id` равно 1000. + +``` xml + + + + + id = 1000 + + + + +``` + +Элемент `filter` содержать любое выражение, возвращающее значение типа [UInt8](../../sql-reference/data-types/int-uint.md). Обычно он содержит сравнения и логические операторы. Строки `database_name.table1`, для которых фильтр возвращает 0 не выдаются пользователю. Фильтрация несовместима с операциями `PREWHERE` и отключает оптимизацию `WHERE→PREWHERE`. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings_users/) diff --git a/docs/ru/operations/settings/settings.md b/docs/ru/operations/settings/settings.md index 732829494e1..5e34affcaac 100644 --- a/docs/ru/operations/settings/settings.md +++ b/docs/ru/operations/settings/settings.md @@ -1,8 +1,13 @@ -# Настройки {#nastroiki} +--- +toc_priority: 60 +toc_title: Settings +--- + +# Настройки {#settings} ## distributed\_product\_mode {#distributed-product-mode} -Изменяет поведение [распределенных подзапросов](../../sql_reference/statements/select.md). +Изменяет поведение [распределенных подзапросов](../../sql-reference/operators/index.md). ClickHouse применяет настройку в тех случаях, когда запрос содержит произведение распределённых таблиц, т.е. когда запрос к распределенной таблице содержит не-GLOBAL подзапрос к также распределенной таблице. @@ -11,7 +16,7 @@ ClickHouse применяет настройку в тех случаях, ко - Только подзапросы для IN, JOIN. - Только если в секции FROM используется распределённая таблица, содержащая более одного шарда. - Если подзапрос касается распределенной таблицы, содержащей более одного шарда. -- Не используется в случае табличной функции [remote](../../sql_reference/table_functions/remote.md). +- Не используется в случае табличной функции [remote](../../sql-reference/table-functions/remote.md). Возможные значения: @@ -46,7 +51,7 @@ ClickHouse применяет настройку в тех случаях, ко ## fallback\_to\_stale\_replicas\_for\_distributed\_queries {#settings-fallback_to_stale_replicas_for_distributed_queries} -Форсирует запрос в устаревшую реплику в случае, если актуальные данные недоступны. См. [Репликация](../../engines/table_engines/mergetree_family/replication.md). +Форсирует запрос в устаревшую реплику в случае, если актуальные данные недоступны. См. [Репликация](../../engines/table-engines/mergetree-family/replication.md). Из устаревших реплик таблицы ClickHouse выбирает наиболее актуальную. @@ -60,15 +65,15 @@ ClickHouse применяет настройку в тех случаях, ко Работает с таблицами семейства MergeTree. -При `force_index_by_date=1` ClickHouse проверяет, есть ли в запросе условие на ключ даты, которое может использоваться для отсечения диапазонов данных. Если подходящего условия нет - кидается исключение. При этом не проверяется, действительно ли условие уменьшает объём данных для чтения. Например, условие `Date != '2000-01-01'` подходит даже в том случае, когда соответствует всем данным в таблице (т.е. для выполнения запроса требуется full scan). Подробнее про диапазоны данных в таблицах MergeTree читайте в разделе [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +При `force_index_by_date=1` ClickHouse проверяет, есть ли в запросе условие на ключ даты, которое может использоваться для отсечения диапазонов данных. Если подходящего условия нет - кидается исключение. При этом не проверяется, действительно ли условие уменьшает объём данных для чтения. Например, условие `Date != '2000-01-01'` подходит даже в том случае, когда соответствует всем данным в таблице (т.е. для выполнения запроса требуется full scan). Подробнее про диапазоны данных в таблицах MergeTree читайте в разделе [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). -## force\_primary\_key {#settings-force-primary-key} +## force\_primary\_key {#settings-force_primary_key} Запрещает выполнение запросов, если использовать индекс по первичному ключу невозможно. Работает с таблицами семейства MergeTree. -При `force_primary_key=1` ClickHouse проверяет, есть ли в запросе условие на первичный ключ, которое может использоваться для отсечения диапазонов данных. Если подходящего условия нет - кидается исключение. При этом не проверяется, действительно ли условие уменьшает объём данных для чтения. Подробнее про диапазоны данных в таблицах MergeTree читайте в разделе [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +При `force_primary_key=1` ClickHouse проверяет, есть ли в запросе условие на первичный ключ, которое может использоваться для отсечения диапазонов данных. Если подходящего условия нет - кидается исключение. При этом не проверяется, действительно ли условие уменьшает объём данных для чтения. Подробнее про диапазоны данных в таблицах MergeTree читайте в разделе [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## format\_schema {#format-schema} @@ -129,7 +134,7 @@ ClickHouse применяет настройку в тех случаях, ко ## max\_http\_get\_redirects {#setting-max_http_get_redirects} -Ограничивает максимальное количество переходов по редиректам в таблицах с движком [URL](../../engines/table_engines/special/url.md) при выполнении HTTP запросов методом GET. Настройка применяется для обоих типов таблиц: созданных запросом [CREATE TABLE](../../sql_reference/create/#create-table-query) и с помощью табличной функции [url](../../sql_reference/table_functions/url.md). +Ограничивает максимальное количество переходов по редиректам в таблицах с движком [URL](../../engines/table-engines/special/url.md) при выполнении HTTP запросов методом GET. Настройка применяется для обоих типов таблиц: созданных запросом [CREATE TABLE](../../sql_reference/create/#create-table-query) и с помощью табличной функции [url](../../sql-reference/table-functions/url.md). Возможные значения: @@ -165,7 +170,7 @@ ClickHouse применяет настройку в тех случаях, ко ## input\_format\_values\_interpret\_expressions {#settings-input_format_values_interpret_expressions} -Включает или отключает парсер SQL, если потоковый парсер не может проанализировать данные. Этот параметр используется только для формата [Values](../../interfaces/formats.md#data-format-values) при вставке данных. Дополнительные сведения о парсерах читайте в разделе [Синтаксис](../../sql_reference/syntax.md). +Включает или отключает парсер SQL, если потоковый парсер не может проанализировать данные. Этот параметр используется только для формата [Values](../../interfaces/formats.md#data-format-values) при вставке данных. Дополнительные сведения о парсерах читайте в разделе [Синтаксис](../../sql-reference/syntax.md). Возможные значения: @@ -181,7 +186,7 @@ ClickHouse применяет настройку в тех случаях, ко Пример использования: -Вставим значение типа [DateTime](../../sql_reference/data_types/datetime.md) при разных значения настройки. +Вставим значение типа [DateTime](../../sql-reference/data-types/datetime.md) при разных значения настройки. ``` sql SET input_format_values_interpret_expressions = 0; @@ -341,7 +346,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( Выбор парсера для текстового представления дат и времени при обработке входного формата. -Настройка не применяется к [функциям для работы с датой и временем](../../sql_reference/functions/date_time_functions.md). +Настройка не применяется к [функциям для работы с датой и временем](../../sql-reference/functions/date-time-functions.md). Возможные значения: @@ -357,12 +362,12 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( См. также: -- [Тип данных DateTime.](../../sql_reference/data_types/datetime.md) -- [Функции для работы с датой и временем.](../../sql_reference/functions/date_time_functions.md) +- [Тип данных DateTime.](../../sql-reference/data-types/datetime.md) +- [Функции для работы с датой и временем.](../../sql-reference/functions/date-time-functions.md) ## join\_default\_strictness {#settings-join_default_strictness} -Устанавливает строгость по умолчанию для [JOIN](../../sql_reference/statements/select.md#select-join). +Устанавливает строгость по умолчанию для [JOIN](../../sql-reference/statements/select/join.md#select-join). Возможные значения @@ -377,7 +382,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( Изменяет поведение операций, выполняемых со строгостью `ANY`. !!! warning "Внимание" - Настройка применяется только для операций `JOIN`, выполняемых над таблицами с движком [Join](../../engines/table_engines/special/join.md). + Настройка применяется только для операций `JOIN`, выполняемых над таблицами с движком [Join](../../engines/table-engines/special/join.md). Возможные значения: @@ -388,18 +393,18 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( См. также: -- [Секция JOIN](../../sql_reference/statements/select.md#select-join) -- [Движок таблиц Join](../../engines/table_engines/special/join.md) +- [Секция JOIN](../../sql-reference/statements/select/join.md#select-join) +- [Движок таблиц Join](../../engines/table-engines/special/join.md) - [join\_default\_strictness](#settings-join_default_strictness) ## join\_use\_nulls {#join_use_nulls} -Устанавливает тип поведения [JOIN](../../sql_reference/statements/select.md). При объединении таблиц могут появиться пустые ячейки. ClickHouse заполняет их по-разному в зависимости от настроек. +Устанавливает тип поведения [JOIN](../../sql-reference/statements/select/join.md). При объединении таблиц могут появиться пустые ячейки. ClickHouse заполняет их по-разному в зависимости от настроек. Возможные значения - 0 — пустые ячейки заполняются значением по умолчанию соответствующего типа поля. -- 1 — `JOIN` ведёт себя как в стандартном SQL. Тип соответствующего поля преобразуется в [Nullable](../../sql_reference/data_types/nullable.md#data_type-nullable), а пустые ячейки заполняются значениями [NULL](../../sql_reference/syntax.md). +- 1 — `JOIN` ведёт себя как в стандартном SQL. Тип соответствующего поля преобразуется в [Nullable](../../sql-reference/data-types/nullable.md#data_type-nullable), а пустые ячейки заполняются значениями [NULL](../../sql-reference/syntax.md). Значение по умолчанию: 0. @@ -419,7 +424,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( ## merge\_tree\_uniform\_read\_distribution {#setting-merge-tree-uniform-read-distribution} -При чтении из таблиц [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) ClickHouse использует несколько потоков. Этот параметр включает/выключает равномерное распределение заданий по рабочим потокам. Алгоритм равномерного распределения стремится сделать время выполнения всех потоков примерно равным для одного запроса `SELECT`. +При чтении из таблиц [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) ClickHouse использует несколько потоков. Этот параметр включает/выключает равномерное распределение заданий по рабочим потокам. Алгоритм равномерного распределения стремится сделать время выполнения всех потоков примерно равным для одного запроса `SELECT`. Возможные значения: @@ -430,7 +435,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( ## merge\_tree\_min\_rows\_for\_concurrent\_read {#setting-merge-tree-min-rows-for-concurrent-read} -Если количество строк, считываемых из файла таблицы [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) превышает `merge_tree_min_rows_for_concurrent_read`, то ClickHouse пытается выполнить одновременное чтение из этого файла в несколько потоков. +Если количество строк, считываемых из файла таблицы [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) превышает `merge_tree_min_rows_for_concurrent_read`, то ClickHouse пытается выполнить одновременное чтение из этого файла в несколько потоков. Возможные значения: @@ -440,7 +445,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( ## merge\_tree\_min\_bytes\_for\_concurrent\_read {#setting-merge-tree-min-bytes-for-concurrent-read} -Если число байтов, которое должно быть прочитано из одного файла таблицы с движком [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md), превышает значение `merge_tree_min_bytes_for_concurrent_read`, то ClickHouse выполняет одновременное чтение в несколько потоков из этого файла. +Если число байтов, которое должно быть прочитано из одного файла таблицы с движком [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md), превышает значение `merge_tree_min_bytes_for_concurrent_read`, то ClickHouse выполняет одновременное чтение в несколько потоков из этого файла. Возможное значение: @@ -482,7 +487,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( Если требуется прочитать более, чем `merge_tree_max_rows_to_use_cache` строк в одном запросе, ClickHouse не используют кэш несжатых блоков. -Кэш несжатых блоков хранит данные, извлечённые при выполнении запросов. ClickHouse использует этот кэш для ускорения ответов на повторяющиеся небольшие запросы. Настройка защищает кэш от замусоривания запросами, для выполнения которых необходимо извлечь большое количество данных. Настройка сервера [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) определяет размер кэша несжатых блоков. +Кэш несжатых блоков хранит данные, извлечённые при выполнении запросов. ClickHouse использует этот кэш для ускорения ответов на повторяющиеся небольшие запросы. Настройка защищает кэш от замусоривания запросами, для выполнения которых необходимо извлечь большое количество данных. Настройка сервера [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) определяет размер кэша несжатых блоков. Возможные значения: @@ -494,7 +499,7 @@ INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), ( Если требуется прочитать более, чем `merge_tree_max_bytes_to_use_cache` байтов в одном запросе, ClickHouse не используют кэш несжатых блоков. -Кэш несжатых блоков хранит данные, извлечённые при выполнении запросов. ClickHouse использует кэш для ускорения ответов на повторяющиеся небольшие запросы. Настройка защищает кэш от переполнения. Настройка сервера [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) определяет размер кэша несжатых блоков. +Кэш несжатых блоков хранит данные, извлечённые при выполнении запросов. ClickHouse использует кэш для ускорения ответов на повторяющиеся небольшие запросы. Настройка защищает кэш от переполнения. Настройка сервера [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) определяет размер кэша несжатых блоков. Возможное значение: @@ -519,7 +524,7 @@ ClickHouse использует этот параметр при чтении д Установка логирования запроса. -Запросы, переданные в ClickHouse с этой установкой, логируются согласно правилам конфигурационного параметра сервера [query\_log](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-query-log). +Запросы, переданные в ClickHouse с этой установкой, логируются согласно правилам конфигурационного параметра сервера [query\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query-log). Пример: @@ -531,7 +536,7 @@ log_queries=1 Установка логирования информации о потоках выполнения запроса. -Лог информации о потоках выполнения запросов, переданных в ClickHouse с этой установкой, записывается согласно правилам конфигурационного параметра сервера [query\_thread\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log). +Лог информации о потоках выполнения запросов, переданных в ClickHouse с этой установкой, записывается согласно правилам конфигурационного параметра сервера [query\_thread\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log). Пример: @@ -551,31 +556,31 @@ log_query_threads=1 Это значение намного больше, чем `max_block_size`. Это сделано, потому что некоторые движки таблиц (`*MergeTree`) будут на каждый вставляемый блок формировать кусок данных на диске, что является довольно большой сущностью. Также, в таблицах типа `*MergeTree`, данные сортируются при вставке, и достаточно большой размер блока позволяет отсортировать больше данных в оперативке. -## min_insert_block_size_rows {#min-insert-block-size-rows} +## min\_insert\_block\_size\_rows {#min-insert-block-size-rows} Устанавливает минимальное количество строк в блоке, который может быть вставлен в таблицу запросом `INSERT`. Блоки меньшего размера склеиваются в блоки большего размера. Возможные значения: -- Целое положительное число. -- 0 — Склейка блоков выключена. +- Целое положительное число. +- 0 — Склейка блоков выключена. Значение по умолчанию: 1048576. -## min_insert_block_size_bytes {#min-insert-block-size-bytes} +## min\_insert\_block\_size\_bytes {#min-insert-block-size-bytes} Устанавливает минимальное количество байтов в блоке, который может быть вставлен в таблицу запросом `INSERT`. Блоки меньшего размера склеиваются в блоки большего размера. Возможные значения: -- Целое положительное число. -- 0 — Склейка блоков выключена. +- Целое положительное число. +- 0 — Склейка блоков выключена. Значение по умолчанию: 268435456. ## max\_replica\_delay\_for\_distributed\_queries {#settings-max_replica_delay_for_distributed_queries} -Отключает отстающие реплики при распределенных запросах. См. [Репликация](../../engines/table_engines/mergetree_family/replication.md). +Отключает отстающие реплики при распределенных запросах. См. [Репликация](../../engines/table-engines/mergetree-family/replication.md). Устанавливает время в секундах. Если отставание реплики больше установленного значения, то реплика не используется. @@ -583,7 +588,7 @@ log_query_threads=1 Используется при выполнении `SELECT` из распределенной таблицы, которая указывает на реплицированные таблицы. -## max\_threads {#settings-max_threads} +## max_threads {#settings-max_threads} Максимальное количество потоков обработки запроса без учёта потоков для чтения данных с удалённых серверов (смотрите параметр max\_distributed\_connections). @@ -609,7 +614,7 @@ log_query_threads=1 Значение по умолчанию: 0. -Параллельный `INSERT SELECT` действует только в том случае, если часть SELECT выполняется параллельно, см. настройку [max\_threads](#settings-max_threads). +Параллельный `INSERT SELECT` действует только в том случае, если часть SELECT выполняется параллельно, см. настройку [max_threads](#settings-max_threads). Чем больше значение `max_insert_threads`, тем больше потребление оперативной памяти. ## max\_compress\_block\_size {#max-compress-block-size} @@ -620,7 +625,7 @@ log_query_threads=1 ## min\_compress\_block\_size {#min-compress-block-size} -Для таблиц типа [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). В целях уменьшения задержек при обработке запросов, блок сжимается при записи следующей засечки, если его размер не меньше min\_compress\_block\_size. По умолчанию - 65 536. +Для таблиц типа [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). В целях уменьшения задержек при обработке запросов, блок сжимается при записи следующей засечки, если его размер не меньше min\_compress\_block\_size. По умолчанию - 65 536. Реальный размер блока, если несжатых данных меньше max\_compress\_block\_size, будет не меньше этого значения и не меньше объёма данных на одну засечку. @@ -699,7 +704,7 @@ log_query_threads=1 Использовать ли кэш разжатых блоков. Принимает 0 или 1. По умолчанию - 0 (выключено). -Использование кэша несжатых блоков (только для таблиц семейства MergeTree) может существенно сократить задержку и увеличить пропускную способность при работе с большим количеством коротких запросов. Включите эту настройку для пользователей, от которых идут частые короткие запросы. Также обратите внимание на конфигурационный параметр [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) (настраивается только в конфигурационном файле) – размер кэша разжатых блоков. По умолчанию - 8 GiB. Кэш разжатых блоков заполняется по мере надобности, а наиболее невостребованные данные автоматически удаляются. +Использование кэша несжатых блоков (только для таблиц семейства MergeTree) может существенно сократить задержку и увеличить пропускную способность при работе с большим количеством коротких запросов. Включите эту настройку для пользователей, от которых идут частые короткие запросы. Также обратите внимание на конфигурационный параметр [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) (настраивается только в конфигурационном файле) – размер кэша разжатых блоков. По умолчанию - 8 GiB. Кэш разжатых блоков заполняется по мере надобности, а наиболее невостребованные данные автоматически удаляются. Для запросов, читающих хоть немного приличный объём данных (миллион строк и больше), кэш разжатых блоков автоматически выключается, чтобы оставить место для действительно мелких запросов. Поэтому, можно держать настройку `use_uncompressed_cache` всегда выставленной в 1. @@ -733,7 +738,7 @@ ClickHouse поддерживает следующие алгоритмы выб - [In order](#load_balancing-in_order) - [First or random](#load_balancing-first_or_random) -### Random (by default) {#load_balancing-random} +### Random (by Default) {#load_balancing-random} ``` sql load_balancing = random @@ -873,7 +878,7 @@ ClickHouse генерирует исключение - [insert\_quorum\_timeout](#settings-insert_quorum_timeout) - [select\_sequential\_consistency](#settings-select_sequential_consistency) -## insert\_quorum\_timeout {#settings-insert_quorum-timeout} +## insert\_quorum\_timeout {#settings-insert_quorum_timeout} Время ожидания кворумной записи в секундах. Если время прошло, а запись так не состоялась, то ClickHouse сгенерирует исключение и клиент должен повторить запрос на запись того же блока на эту же или любую другую реплику. @@ -915,7 +920,7 @@ ClickHouse генерирует исключение Значение по умолчанию: 1. -По умолчанию блоки, вставляемые в реплицируемые таблицы оператором `INSERT`, дедуплицируются (см. [Репликация данных](../../engines/table_engines/mergetree_family/replication.md)). +По умолчанию блоки, вставляемые в реплицируемые таблицы оператором `INSERT`, дедуплицируются (см. [Репликация данных](../../engines/table-engines/mergetree-family/replication.md)). ## deduplicate\_blocks\_in\_dependent\_materialized\_views {#settings-deduplicate-blocks-in-dependent-materialized-views} @@ -934,15 +939,15 @@ ClickHouse генерирует исключение ## count\_distinct\_implementation {#settings-count_distinct_implementation} -Задаёт, какая из функций `uniq*` используется при выполнении конструкции [COUNT(DISTINCT …)](../../sql_reference/aggregate_functions/reference.md#agg_function-count). +Задаёт, какая из функций `uniq*` используется при выполнении конструкции [COUNT(DISTINCT …)](../../sql-reference/aggregate-functions/reference.md#agg_function-count). Возможные значения: -- [uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq) -- [uniqCombined](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined) -- [uniqCombined64](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined64) -- [uniqHLL12](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqhll12) -- [uniqExact](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqexact) +- [uniq](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq) +- [uniqCombined](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined) +- [uniqCombined64](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined64) +- [uniqHLL12](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqhll12) +- [uniqExact](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqexact) Значение по умолчанию: `uniqExact`. @@ -1020,9 +1025,32 @@ ClickHouse генерирует исключение Значение по умолчанию: 0. +## optimize_skip_unused_shards {#optimize-skip-unused-shards} + +Включает или отключает пропуск неиспользуемых шардов для запросов [SELECT](../../sql-reference/statements/select/index.md) , в которых условие ключа шардирования задано в секции `WHERE/PREWHERE`. Предполагается, что данные распределены с помощью ключа шардирования, в противном случае настройка ничего не делает. + +Возможные значения: + +- 0 — Выключена. +- 1 — Включена. + +Значение по умолчанию: 0 + +## force_optimize_skip_unused_shards {#force-optimize-skip-unused-shards} + +Разрешает или запрещает выполнение запроса, если настройка [optimize_skip_unused_shards](#optimize-skip-unused-shards) включена, а пропуск неиспользуемых шардов невозможен. Если данная настройка включена и пропуск невозможен, ClickHouse генерирует исключение. + +Возможные значения: + +- 0 — Выключена. ClickHouse не генерирует исключение. +- 1 — Включена. Выполнение запроса запрещается, только если у таблицы есть ключ шардирования. +- 2 — Включена. Выполнение запроса запрещается, даже если для таблицы не определен ключ шардирования. + +Значение по умолчанию: 0 + ## optimize\_throw\_if\_noop {#setting-optimize_throw_if_noop} -Включает или отключает генерирование исключения в в случаях, когда запрос [OPTIMIZE](../../sql_reference/statements/misc.md#misc_operations-optimize) не выполняет мёрж. +Включает или отключает генерирование исключения в в случаях, когда запрос [OPTIMIZE](../../sql-reference/statements/misc.md#misc_operations-optimize) не выполняет мёрж. По умолчанию, `OPTIMIZE` завершается успешно и в тех случаях, когда он ничего не сделал. Настройка позволяет отделить подобные случаи и включает генерирование исключения с поясняющим сообщением. @@ -1035,7 +1063,7 @@ ClickHouse генерирует исключение ## distributed\_directory\_monitor\_sleep\_time\_ms {#distributed_directory_monitor_sleep_time_ms} -Основной интервал отправки данных движком таблиц [Distributed](../../engines/table_engines/special/distributed.md). Фактический интервал растёт экспоненциально при возникновении ошибок. +Основной интервал отправки данных движком таблиц [Distributed](../../engines/table-engines/special/distributed.md). Фактический интервал растёт экспоненциально при возникновении ошибок. Возможные значения: @@ -1045,7 +1073,7 @@ ClickHouse генерирует исключение ## distributed\_directory\_monitor\_max\_sleep\_time\_ms {#distributed_directory_monitor_max_sleep_time_ms} -Максимальный интервал отправки данных движком таблиц [Distributed](../../engines/table_engines/special/distributed.md). Ограничивает экпоненциальный рост интервала, установленого настройкой [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms). +Максимальный интервал отправки данных движком таблиц [Distributed](../../engines/table-engines/special/distributed.md). Ограничивает экпоненциальный рост интервала, установленого настройкой [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms). Возможные значения: @@ -1057,7 +1085,7 @@ ClickHouse генерирует исключение Включает/выключает пакетную отправку вставленных данных. -Если пакетная отправка включена, то движок таблиц [Distributed](../../engines/table_engines/special/distributed.md) вместо того, чтобы отправлять каждый файл со вставленными данными по отдельности, старается отправить их все за одну операцию. Пакетная отправка улучшает производительность кластера за счет более оптимального использования ресурсов сервера и сети. +Если пакетная отправка включена, то движок таблиц [Distributed](../../engines/table-engines/special/distributed.md) вместо того, чтобы отправлять каждый файл со вставленными данными по отдельности, старается отправить их все за одну операцию. Пакетная отправка улучшает производительность кластера за счет более оптимального использования ресурсов сервера и сети. Возможные значения: @@ -1083,7 +1111,7 @@ ClickHouse генерирует исключение ## query\_profiler\_real\_time\_period\_ns {#query_profiler_real_time_period_ns} -Sets the period for a real clock timer of the [query profiler](../../operations/optimizing_performance/sampling_query_profiler.md). Real clock timer counts wall-clock time. +Sets the period for a real clock timer of the [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md). Real clock timer counts wall-clock time. Possible values: @@ -1096,17 +1124,17 @@ Possible values: - 0 for turning off the timer. -Type: [UInt64](../../sql_reference/data_types/int_uint.md). +Type: [UInt64](../../sql-reference/data-types/int-uint.md). Default value: 1000000000 nanoseconds (once a second). See also: -- System table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- System table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## query\_profiler\_cpu\_time\_period\_ns {#query_profiler_cpu_time_period_ns} -Sets the period for a CPU clock timer of the [query profiler](../../operations/optimizing_performance/sampling_query_profiler.md). This timer counts only CPU time. +Sets the period for a CPU clock timer of the [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md). This timer counts only CPU time. Possible values: @@ -1119,17 +1147,17 @@ Possible values: - 0 for turning off the timer. -Type: [UInt64](../../sql_reference/data_types/int_uint.md). +Type: [UInt64](../../sql-reference/data-types/int-uint.md). Default value: 1000000000 nanoseconds. See also: -- System table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- System table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## allow\_introspection\_functions {#settings-allow_introspection_functions} -Enables of disables [introspections functions](../../sql_reference/functions/introspection.md) for query profiling. +Enables of disables [introspections functions](../../sql-reference/functions/introspection.md) for query profiling. Possible values: @@ -1140,7 +1168,57 @@ Default value: 0. **See Also** -- [Sampling Query Profiler](../optimizing_performance/sampling_query_profiler.md) -- System table [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- [Sampling Query Profiler](../optimizing-performance/sampling-query-profiler.md) +- System table [trace\_log](../../operations/system-tables.md#system_tables-trace_log) + +## background\_pool\_size {#background_pool_size} + +Задает количество потоков для выполнения фоновых операций в движках таблиц (например, слияния в таблицах c движком [MergeTree](../../engines/table-engines/mergetree-family/index.md)). Настройка применяется при запуске сервера ClickHouse и не может быть изменена во пользовательском сеансе. Настройка позволяет управлять загрузкой процессора и диска. Чем меньше пулл, тем ниже нагрузка на CPU и диск, при этом фоновые процессы замедляются, что может повлиять на скорость выполнения запроса. + +Допустимые значения: + +- Положительное целое число. + +Значение по умолчанию: 16. + +## background_buffer_flush_schedule_pool_size {#background_buffer_flush_schedule_pool_size} + +Задает количество потоков для выполнения фонового сброса данных в таблицах с движком [Buffer](../../engines/table-engines/special/buffer.md). Настройка применяется при запуске сервера ClickHouse и не может быть изменена в пользовательском сеансе. + +Допустимые значения: + +- Положительное целое число. + +Значение по умолчанию: 16. + +## background_move_pool_size {#background_move_pool_size} + +Задает количество потоков для фоновых перемещений кусков между дисками. Работает для таблиц с движком [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes). Настройка применяется при запуске сервера ClickHouse и не может быть изменена в пользовательском сеансе. + +Допустимые значения: + +- Положительное целое число. + +Значение по умолчанию: 8. + +## background_schedule_pool_size {#background_schedule_pool_size} + +Задает количество потоков для выполнения фоновых задач. Работает для [реплицируемых](../../engines/table-engines/mergetree-family/replication.md) таблиц, стримов в [Kafka](../../engines/table-engines/integrations/kafka.md) и обновления IP адресов у записей во внутреннем [DNS кеше](../server-configuration-parameters/settings.md#server-settings-dns-cache-update-period). Настройка применяется при запуске сервера ClickHouse и не может быть изменена в пользовательском сеансе. + +Допустимые значения: + +- Положительное целое число. + +Значение по умолчанию: 16. + +## background_distributed_schedule_pool_size {#background_distributed_schedule_pool_size} + +Задает количество потоков для выполнения фоновых задач. Работает для таблиц с движком [Distributed](../../engines/table-engines/special/distributed.md). Настройка применяется при запуске сервера ClickHouse и не может быть изменена в пользовательском сеансе. + +Допустимые значения: + +- Положительное целое число. + +Значение по умолчанию: 16. [Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings/) diff --git a/docs/ru/operations/settings/settings_profiles.md b/docs/ru/operations/settings/settings_profiles.md deleted file mode 100644 index a0a8b4ba0ba..00000000000 --- a/docs/ru/operations/settings/settings_profiles.md +++ /dev/null @@ -1,64 +0,0 @@ -# Профили настроек {#profili-nastroek} - -Профили настроек - это множество настроек, сгруппированных под одним именем. Для каждого пользователя ClickHouse указывается некоторый профиль. -Все настройки профиля можно применить, установив настройку `profile`. - -Пример: - -Установить профиль `web`. - -``` sql -SET profile = 'web' -``` - -Профили настроек объявляются в конфигурационном файле пользователей. Обычно это `users.xml`. - -Пример: - -``` xml - - - - - - 8 - - - - - 1000000000 - 100000000000 - - 1000000 - any - - 1000000 - 1000000000 - - 100000 - 100000000 - break - - 600 - 1000000 - 15 - - 25 - 100 - 50 - - 2 - 25 - 50 - 100 - - 1 - - -``` - -В примере задано два профиля: `default` и `web`. Профиль `default` имеет специальное значение - он всегда обязан присутствовать и применяется при запуске сервера. То есть, профиль `default` содержит настройки по умолчанию. Профиль `web` - обычный профиль, который может быть установлен с помощью запроса `SET` или с помощью параметра URL при запросе по HTTP. - -Профили настроек могут наследоваться от друг-друга - это реализуется указанием одной или нескольких настроек `profile` перед остальными настройками, перечисленными в профиле. Если одна настройка указана в нескольких профилях, используется последнее из значений. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings_profiles/) diff --git a/docs/ru/operations/settings/settings_users.md b/docs/ru/operations/settings/settings_users.md deleted file mode 100644 index 1719f21a031..00000000000 --- a/docs/ru/operations/settings/settings_users.md +++ /dev/null @@ -1,144 +0,0 @@ -# Настройки пользователей {#nastroiki-polzovatelei} - -Раздел `users` конфигурационного файла `user.xml` содержит настройки для пользователей. - -Структура раздела `users`: - -``` xml - - - - - - - - - - - profile_name - - default - - - - - expression - - - - - - -``` - -### user\_name/password {#user-namepassword} - -Пароль можно указать в текстовом виде или в виде SHA256 (шестнадцатеричный формат). - -- Чтобы назначить пароль в текстовом виде (**не рекомендуем**), поместите его в элемент `password`. - - Например, `qwerty`. Пароль можно оставить пустым. - - - -- Чтобы назначить пароль в виде SHA256, поместите хэш в элемент `password_sha256_hex`. - - Например, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. - - Пример создания пароля в командной строке: - - ``` - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' - ``` - - Первая строка результата — пароль. Вторая строка — соответствующий ему хэш SHA256. - - - -- Для совместимости с клиентами MySQL, пароль можно задать с помощью двойного хэша SHA1, поместив его в элемент `password_double_sha1_hex`. - - Например, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. - - Пример создания пароля в командной строке: - - ``` - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' - ``` - - Первая строка результата — пароль. Вторая строка — соответствующий ему двойной хэш SHA1. - -### user\_name/networks {#user-namenetworks} - -Список сетей, из которых пользователь может подключиться к серверу ClickHouse. - -Каждый элемент списка имеет одну из следующих форм: - -- `` — IP-адрес или маска подсети. - - Примеры: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. - -- `` — Имя хоста. - - Пример: `example01.host.ru`. - - Для проверки доступа выполняется DNS-запрос, и все возвращенные IP-адреса сравниваются с адресом клиента. - -- `` — Регулярное выражение для имен хостов. - - Пример, `^example\d\d-\d\d-\d\.host\.ru$` - - Для проверки доступа выполняется [DNS запрос PTR](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) для адреса клиента, а затем применяется заданное регулярное выражение. Затем, для результатов запроса PTR выполняется другой DNS-запрос и все полученные адреса сравниваются с адресом клиента. Рекомендуем завершать регулярное выражение символом $. - -Все результаты DNS-запросов кэшируются до перезапуска сервера. - -**Примеры** - -Чтобы открыть доступ пользователю из любой сети, укажите: - -``` xml -::/0 -``` - -!!! warning "Внимание" - Открывать доступ из любой сети небезопасно, если у вас нет правильно настроенного брандмауэра или сервер не отключен от интернета. - -Чтобы открыть только локальный доступ, укажите: - -``` xml -::1 -127.0.0.1 -``` - -### user\_name/profile {#user-nameprofile} - -Пользователю можно назначить профиль настроек. Профили настроек конфигурируются в отдельной секции файла `users.xml`. Подробнее читайте в разделе [Профили настроек](settings_profiles.md). - -### user\_name/quota {#user-namequota} - -Квотирование позволяет отслеживать или ограничивать использование ресурсов в течение определённого периода времени. Квоты настраиваются в разделе `quotas` конфигурационного файла `users.xml`. - -Пользователю можно назначить квоты. Подробное описание настройки квот смотрите в разделе [Квоты](../quotas.md#quotas). - -### user\_name/databases {#user-namedatabases} - -В этом разделе вы можете ограничить выдачу ClickHouse запросами `SELECT` для конкретного пользователя, таким образом реализуя базовую защиту на уровне строк. - -**Пример** - -Следующая конфигурация задаёт, что пользователь `user1` в результате запросов `SELECT` может получать только те строки `table1`, в которых значение поля `id` равно 1000. - -``` xml - - - - - id = 1000 - - - - -``` - -Элемент `filter` содержать любое выражение, возвращающее значение типа [UInt8](../../sql_reference/data_types/int_uint.md). Обычно он содержит сравнения и логические операторы. Строки `database_name.table1`, для которых фильтр возвращает 0 не выдаются пользователю. Фильтрация несовместима с операциями `PREWHERE` и отключает оптимизацию `WHERE→PREWHERE`. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings_users/) diff --git a/docs/ru/operations/system-tables.md b/docs/ru/operations/system-tables.md new file mode 100644 index 00000000000..6e57e7a63f3 --- /dev/null +++ b/docs/ru/operations/system-tables.md @@ -0,0 +1,1252 @@ +# Системные таблицы {#system-tables} + + +## Введение {#system-tables-introduction} + +Системные таблицы используются для реализации части функциональности системы, а также предоставляют доступ к информации о работе системы. +Вы не можете удалить системную таблицу (хотя можете сделать DETACH). +Для системных таблиц нет файлов с данными на диске и файлов с метаданными. Сервер создаёт все системные таблицы при старте. +В системные таблицы нельзя записывать данные - можно только читать. +Системные таблицы расположены в базе данных system. + +## system.asynchronous\_metrics {#system_tables-asynchronous_metrics} + +Содержит метрики, которые периодически вычисляются в фоновом режиме. Например, объём используемой оперативной памяти. + +Столбцы: + +- `metric` ([String](../sql-reference/data-types/string.md)) — название метрики. +- `value` ([Float64](../sql-reference/data-types/float.md)) — значение метрики. + +**Пример** + +``` sql +SELECT * FROM system.asynchronous_metrics LIMIT 10 +``` + +``` text +┌─metric──────────────────────────────────┬──────value─┐ +│ jemalloc.background_thread.run_interval │ 0 │ +│ jemalloc.background_thread.num_runs │ 0 │ +│ jemalloc.background_thread.num_threads │ 0 │ +│ jemalloc.retained │ 422551552 │ +│ jemalloc.mapped │ 1682989056 │ +│ jemalloc.resident │ 1656446976 │ +│ jemalloc.metadata_thp │ 0 │ +│ jemalloc.metadata │ 10226856 │ +│ UncompressedCacheCells │ 0 │ +│ MarkCacheFiles │ 0 │ +└─────────────────────────────────────────┴────────────┘ +``` + +**Смотрите также** + +- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. +- [system.metrics](#system_tables-metrics) — таблица с мгновенно вычисляемыми метриками. +- [system.events](#system_tables-events) — таблица с количеством произошедших событий. +- [system.metric\_log](#system_tables-metric_log) — таблица фиксирующая историю значений метрик из `system.metrics` и `system.events`. + +## system.clusters {#system-clusters} + +Содержит информацию о доступных в конфигурационном файле кластерах и серверах, которые в них входят. +Столбцы: + +``` text +cluster String — имя кластера. +shard_num UInt32 — номер шарда в кластере, начиная с 1. +shard_weight UInt32 — относительный вес шарда при записи данных +replica_num UInt32 — номер реплики в шарде, начиная с 1. +host_name String — хост, указанный в конфигурации. +host_address String — IP-адрес хоста, полученный из DNS. +port UInt16 — порт, на который обращаться для соединения с сервером. +user String — имя пользователя, которого использовать для соединения с сервером. +``` + +## system.columns {#system-columns} + +Содержит информацию о столбцах всех таблиц. + +С помощью этой таблицы можно получить информацию аналогично запросу [DESCRIBE TABLE](../sql-reference/statements/misc.md#misc-describe-table), но для многих таблиц сразу. + +Таблица `system.columns` содержит столбцы (тип столбца указан в скобках): + +- `database` (String) — имя базы данных. +- `table` (String) — имя таблицы. +- `name` (String) — имя столбца. +- `type` (String) — тип столбца. +- `default_kind` (String) — тип выражения (`DEFAULT`, `MATERIALIZED`, `ALIAS`) значения по умолчанию, или пустая строка. +- `default_expression` (String) — выражение для значения по умолчанию или пустая строка. +- `data_compressed_bytes` (UInt64) — размер сжатых данных в байтах. +- `data_uncompressed_bytes` (UInt64) — размер распакованных данных в байтах. +- `marks_bytes` (UInt64) — размер засечек в байтах. +- `comment` (String) — комментарий к столбцу или пустая строка. +- `is_in_partition_key` (UInt8) — флаг, показывающий включение столбца в ключ партиционирования. +- `is_in_sorting_key` (UInt8) — флаг, показывающий включение столбца в ключ сортировки. +- `is_in_primary_key` (UInt8) — флаг, показывающий включение столбца в первичный ключ. +- `is_in_sampling_key` (UInt8) — флаг, показывающий включение столбца в ключ выборки. + +## system.contributors {#system-contributors} + +Содержит информацию о контрибьютерах. Контрибьютеры расположены в таблице в случайном порядке. Порядок определяется заново при каждом запросе. + +Столбцы: + +- `name` (String) — Имя контрибьютера (автора коммита) из git log. + +**Пример** + +``` sql +SELECT * FROM system.contributors LIMIT 10 +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +│ Max Vetrov │ +│ LiuYangkuan │ +│ svladykin │ +│ zamulla │ +│ Šimon Podlipský │ +│ BayoNet │ +│ Ilya Khomutov │ +│ Amy Krishnevsky │ +│ Loud_Scream │ +└──────────────────┘ +``` + +Чтобы найти себя в таблице, выполните запрос: + +``` sql +SELECT * FROM system.contributors WHERE name='Olga Khvostikova' +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +└──────────────────┘ +``` + +## system.databases {#system-databases} + +Таблица содержит один столбец name типа String - имя базы данных. +Для каждой базы данных, о которой знает сервер, будет присутствовать соответствующая запись в таблице. +Эта системная таблица используется для реализации запроса `SHOW DATABASES`. + +## system.data_type_families {#system_tables-data_type_families} + +Содержит информацию о поддерживаемых [типах данных](../sql-reference/data-types/). + +Столбцы: + +- `name` ([String](../sql-reference/data-types/string.md)) — имя типа данных. +- `case_insensitive` ([UInt8](../sql-reference/data-types/int-uint.md)) — свойство, которое показывает, зависит ли имя типа данных в запросе от регистра. Например, допустимы и `Date`, и `date`. +- `alias_to` ([String](../sql-reference/data-types/string.md)) — тип данных, для которого `name` является алиасом. + +**Пример** + +``` sql +SELECT * FROM system.data_type_families WHERE alias_to = 'String' +``` + +``` text +┌─name───────┬─case_insensitive─┬─alias_to─┐ +│ LONGBLOB │ 1 │ String │ +│ LONGTEXT │ 1 │ String │ +│ TINYTEXT │ 1 │ String │ +│ TEXT │ 1 │ String │ +│ VARCHAR │ 1 │ String │ +│ MEDIUMBLOB │ 1 │ String │ +│ BLOB │ 1 │ String │ +│ TINYBLOB │ 1 │ String │ +│ CHAR │ 1 │ String │ +│ MEDIUMTEXT │ 1 │ String │ +└────────────┴──────────────────┴──────────┘ +``` + +**See Also** + +- [Синтаксис](../sql-reference/syntax.md) — поддерживаемый SQL синтаксис. + +## system.detached\_parts {#system_tables-detached_parts} + +Содержит информацию об отсоединённых кусках таблиц семейства [MergeTree](../engines/table-engines/mergetree-family/mergetree.md). Столбец `reason` содержит причину, по которой кусок был отсоединён. Для кусов, отсоединённых пользователем, `reason` содержит пустую строку. +Такие куски могут быть присоединены с помощью [ALTER TABLE ATTACH PARTITION\|PART](../sql_reference/alter/#alter_attach-partition). Остальные столбцы описаны в [system.parts](#system_tables-parts). +Если имя куска некорректно, значения некоторых столбцов могут быть `NULL`. Такие куски могут быть удалены с помощью [ALTER TABLE DROP DETACHED PART](../sql_reference/alter/#alter_drop-detached). + +## system.dictionaries {#system_tables-dictionaries} + +Содержит информацию о [внешних словарях](../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +Столбцы: + +- `database` ([String](../sql-reference/data-types/string.md)) — Имя базы данных, в которой находится словарь, созданный с помощью DDL-запроса. Пустая строка для других словарей. +- `name` ([String](../sql-reference/data-types/string.md)) — [Имя словаря](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md). +- `status` ([Enum8](../sql-reference/data-types/enum.md)) — Статус словаря. Возможные значения: + - `NOT_LOADED` — Словарь не загружен, потому что не использовался. + - `LOADED` — Словарь загружен успешно. + - `FAILED` — Словарь не загружен в результате ошибки. + - `LOADING` — Словарь в процессе загрузки. + - `LOADED_AND_RELOADING` — Словарь загружен успешно, сейчас перезагружается (частые причины: запрос [SYSTEM RELOAD DICTIONARY](../sql-reference/statements/system.md#query_language-system-reload-dictionary), таймаут, изменение настроек словаря). + - `FAILED_AND_RELOADING` — Словарь не загружен в результате ошибки, сейчас перезагружается. +- `origin` ([String](../sql-reference/data-types/string.md)) — Путь к конфигурационному файлу, описывающему словарь. +- `type` ([String](../sql-reference/data-types/string.md)) — Тип размещения словаря. [Хранение словарей в памяти](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md). +- `key` — [Тип ключа](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-key): Числовой ключ ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) или Составной ключ ([String](../sql-reference/data-types/string.md)) — строка вида “(тип 1, тип 2, …, тип n)”. +- `attribute.names` ([Array](../sql-reference/data-types/array.md)([String](../sql-reference/data-types/string.md))) — Массив [имен атрибутов](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes), предоставляемых справочником. +- `attribute.types` ([Array](../sql-reference/data-types/array.md)([String](../sql-reference/data-types/string.md))) — Соответствующий массив [типов атрибутов](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes), предоставляемых справочником. +- `bytes_allocated` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Объем оперативной памяти, используемый словарем. +- `query_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Количество запросов с момента загрузки словаря или с момента последней успешной перезагрузки. +- `hit_rate` ([Float64](../sql-reference/data-types/float.md)) — Для cache-словарей — процент закэшированных значений. +- `element_count` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Количество элементов, хранящихся в словаре. +- `load_factor` ([Float64](../sql-reference/data-types/float.md)) — Процент заполнения словаря (для хэшированного словаря — процент заполнения хэш-таблицы). +- `source` ([String](../sql-reference/data-types/string.md)) — Текст, описывающий [источник данных](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md) для словаря. +- `lifetime_min` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Минимальное [время обновления](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) словаря в памяти, по истечении которого Clickhouse попытается перезагрузить словарь (если задано `invalidate_query`, то только если он изменился). Задается в секундах. +- `lifetime_max` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Максимальное [время обновления](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) словаря в памяти, по истечении которого Clickhouse попытается перезагрузить словарь (если задано `invalidate_query`, то только если он изменился). Задается в секундах. +- `loading_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Время начала загрузки словаря. +- `loading_duration` ([Float32](../sql-reference/data-types/float.md)) — Время, затраченное на загрузку словаря. +- `last_exception` ([String](../sql-reference/data-types/string.md)) — Текст ошибки, возникающей при создании или перезагрузке словаря, если словарь не удалось создать. + +**Пример** + +Настройте словарь. + +``` sql +CREATE DICTIONARY dictdb.dict +( + `key` Int64 DEFAULT -1, + `value_default` String DEFAULT 'world', + `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) +LIFETIME(MIN 0 MAX 1) +LAYOUT(FLAT()) +``` + +Убедитесь, что словарь загружен. + +``` sql +SELECT * FROM system.dictionaries +``` + +``` text +┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ +│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ +└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ +``` + +## system.events {#system_tables-events} + +Содержит информацию о количестве событий, произошедших в системе. Например, в таблице можно найти, сколько запросов `SELECT` обработано с момента запуска сервера ClickHouse. + +Столбцы: + +- `event` ([String](../sql-reference/data-types/string.md)) — имя события. +- `value` ([UInt64](../sql-reference/data-types/int-uint.md)) — количество произошедших событий. +- `description` ([String](../sql-reference/data-types/string.md)) — описание события. + +**Пример** + +``` sql +SELECT * FROM system.events LIMIT 5 +``` + +``` text +┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ +│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ +│ FileOpen │ 73 │ Number of files opened. │ +│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ +│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ +└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Смотрите также** + +- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — таблица с периодически вычисляемыми метриками. +- [system.metrics](#system_tables-metrics) — таблица с мгновенно вычисляемыми метриками. +- [system.metric\_log](#system_tables-metric_log) — таблица фиксирующая историю значений метрик из `system.metrics` и `system.events`. +- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. + +## system.functions {#system-functions} + +Содержит информацию об обычных и агрегатных функциях. + +Столбцы: + +- `name` (`String`) – Имя функции. +- `is_aggregate` (`UInt8`) – Признак, является ли функция агрегатной. + +## system.graphite\_retentions {#system-graphite-retentions} + +Содержит информацию о том, какие параметры [graphite\_rollup](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) используются в таблицах с движками [\*GraphiteMergeTree](../engines/table-engines/mergetree-family/graphitemergetree.md). + +Столбцы: + +- `config_name` (String) - Имя параметра, используемого для `graphite_rollup`. +- `regexp` (String) - Шаблон имени метрики. +- `function` (String) - Имя агрегирующей функции. +- `age` (UInt64) - Минимальный возраст данных в секундах. +- `precision` (UInt64) - Точность определения возраста данных в секундах. +- `priority` (UInt16) - Приоритет раздела pattern. +- `is_default` (UInt8) - Является ли раздел pattern дефолтным. +- `Tables.database` (Array(String)) - Массив имён баз данных таблиц, использующих параметр `config_name`. +- `Tables.table` (Array(String)) - Массив имён таблиц, использующих параметр `config_name`. + +## system.merges {#system-merges} + +Содержит информацию о производящихся прямо сейчас слияниях и мутациях кусков для таблиц семейства MergeTree. + +Столбцы: + +- `database String` — Имя базы данных, в которой находится таблица. +- `table String` — Имя таблицы. +- `elapsed Float64` — Время в секундах, прошедшее от начала выполнения слияния. +- `progress Float64` — Доля выполненной работы от 0 до 1. +- `num_parts UInt64` — Количество сливаемых кусков. +- `result_part_name String` — Имя куска, который будет образован в результате слияния. +- `is_mutation UInt8` - Является ли данный процесс мутацией куска. +- `total_size_bytes_compressed UInt64` — Суммарный размер сжатых данных сливаемых кусков. +- `total_size_marks UInt64` — Суммарное количество засечек в сливаемых кусках. +- `bytes_read_uncompressed UInt64` — Количество прочитанных байт, разжатых. +- `rows_read UInt64` — Количество прочитанных строк. +- `bytes_written_uncompressed UInt64` — Количество записанных байт, несжатых. +- `rows_written UInt64` — Количество записанных строк. + +## system.metrics {#system_tables-metrics} + +Содержит метрики, которые могут быть рассчитаны мгновенно или имеют текущее значение. Например, число одновременно обрабатываемых запросов или текущее значение задержки реплики. Эта таблица всегда актуальна. + +Столбцы: + +- `metric` ([String](../sql-reference/data-types/string.md)) — название метрики. +- `value` ([Int64](../sql-reference/data-types/int-uint.md)) — значение метрики. +- `description` ([String](../sql-reference/data-types/string.md)) — описание метрики. + +Список поддержанных метрик смотрите в файле [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp). + +**Пример** + +``` sql +SELECT * FROM system.metrics LIMIT 10 +``` + +``` text +┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 1 │ Number of executing queries │ +│ Merge │ 0 │ Number of executing background merges │ +│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ +│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ +│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ +│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ +│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ +│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ +│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ +│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ +└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Смотрите также** + +- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — таблица с периодически вычисляемыми метриками. +- [system.events](#system_tables-events) — таблица с количеством произошедших событий. +- [system.metric\_log](#system_tables-metric_log) — таблица фиксирующая историю значений метрик из `system.metrics` и `system.events`. +- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. + +## system.metric\_log {#system_tables-metric_log} + +Содержит историю значений метрик из таблиц `system.metrics` и `system.events`, периодически сбрасываемую на диск. +Для включения сбора истории метрик в таблице `system.metric_log` создайте `/etc/clickhouse-server/config.d/metric_log.xml` следующего содержания: + +``` xml + + + system + metric_log
+ 7500 + 1000 +
+
+``` + +**Пример** + +``` sql +SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +event_date: 2020-02-18 +event_time: 2020-02-18 07:15:33 +milliseconds: 554 +ProfileEvent_Query: 0 +ProfileEvent_SelectQuery: 0 +ProfileEvent_InsertQuery: 0 +ProfileEvent_FileOpen: 0 +ProfileEvent_Seek: 0 +ProfileEvent_ReadBufferFromFileDescriptorRead: 1 +ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 +ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 +ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 +ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 +ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 +... +CurrentMetric_Query: 0 +CurrentMetric_Merge: 0 +CurrentMetric_PartMutation: 0 +CurrentMetric_ReplicatedFetch: 0 +CurrentMetric_ReplicatedSend: 0 +CurrentMetric_ReplicatedChecks: 0 +... +``` + +**Смотрите также** + +- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — таблица с периодически вычисляемыми метриками. +- [system.events](#system_tables-events) — таблица с количеством произошедших событий. +- [system.metrics](#system_tables-metrics) — таблица с мгновенно вычисляемыми метриками. +- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. + +## system.numbers {#system-numbers} + +Таблица содержит один столбец с именем number типа UInt64, содержащим почти все натуральные числа, начиная с нуля. +Эту таблицу можно использовать для тестов, а также если вам нужно сделать перебор. +Чтения из этой таблицы не распараллеливаются. + +## system.numbers\_mt {#system-numbers-mt} + +То же самое, что и system.numbers, но чтение распараллеливается. Числа могут возвращаться в произвольном порядке. +Используется для тестов. + +## system.one {#system-one} + +Таблица содержит одну строку с одним столбцом dummy типа UInt8, содержащим значение 0. +Эта таблица используется, если в SELECT запросе не указана секция FROM. +То есть, это - аналог таблицы DUAL, которую можно найти в других СУБД. + +## system.parts {#system_tables-parts} + +Содержит информацию о кусках данных таблиц семейства [MergeTree](../engines/table-engines/mergetree-family/mergetree.md). + +Каждая строка описывает один кусок данных. + +Столбцы: + +- `partition` (`String`) – Имя партиции. Что такое партиция можно узнать из описания запроса [ALTER](../sql-reference/statements/alter.md#query_language_queries_alter). + + Форматы: + + - `YYYYMM` для автоматической схемы партиционирования по месяцам. + - `any_string` при партиционировании вручную. + +- `name` (`String`) – имя куска. + +- `active` (`UInt8`) – признак активности. Если кусок активен, то он используется таблицей, в противном случает он будет удален. Неактивные куски остаются после слияний. + +- `marks` (`UInt64`) – количество засечек. Чтобы получить примерное количество строк в куске, умножьте `marks` на гранулированность индекса (обычно 8192). + +- `rows` (`UInt64`) – количество строк. + +- `bytes_on_disk` (`UInt64`) – общий размер всех файлов кусков данных в байтах. + +- `data_compressed_bytes` (`UInt64`) – общий размер сжатой информации в куске данных. Размер всех дополнительных файлов (например, файлов с засечками) не учитывается. + +- `data_uncompressed_bytes` (`UInt64`) – общий размер распакованной информации куска данных. Размер всех дополнительных файлов (например, файлов с засечками) не учитывается. + +- `marks_bytes` (`UInt64`) – размер файла с засечками. + +- `modification_time` (`DateTime`) – время модификации директории с куском данных. Обычно соответствует времени создания куска. + +- `remove_time` (`DateTime`) – время, когда кусок стал неактивным. + +- `refcount` (`UInt32`) – количество мест, в котором кусок используется. Значение больше 2 говорит о том, что кусок участвует в запросах или в слияниях. + +- `min_date` (`Date`) – минимальное значение ключа даты в куске данных. + +- `max_date` (`Date`) – максимальное значение ключа даты в куске данных. + +- `min_time` (`DateTime`) – минимальное значение даты и времени в куске данных. + +- `max_time`(`DateTime`) – максимальное значение даты и времени в куске данных. + +- `partition_id` (`String`) – ID партиции. + +- `min_block_number` (`UInt64`) – минимальное число кусков, из которых состоит текущий после слияния. + +- `max_block_number` (`UInt64`) – максимальное число кусков, из которых состоит текущий после слияния. + +- `level` (`UInt32`) - глубина дерева слияний. Если слияний не было, то `level=0`. + +- `data_version` (`UInt64`) – число, которое используется для определения того, какие мутации необходимо применить к куску данных (мутации с версией большей, чем `data_version`). + +- `primary_key_bytes_in_memory` (`UInt64`) – объём памяти (в байтах), занимаемой значениями первичных ключей. + +- `primary_key_bytes_in_memory_allocated` (`UInt64`) – объём памяти (в байтах) выделенный для размещения первичных ключей. + +- `is_frozen` (`UInt8`) – Признак, показывающий существование бэкапа партиции. 1, бэкап есть. 0, бэкапа нет. Смотрите раздел [FREEZE PARTITION](../sql-reference/statements/alter.md#alter_freeze-partition). + +- `database` (`String`) – имя базы данных. + +- `table` (`String`) – имя таблицы. + +- `engine` (`String`) – имя движка таблицы, без параметров. + +- `path` (`String`) – абсолютный путь к папке с файлами кусков данных. + +- `disk` (`String`) – имя диска, на котором находится кусок данных. + +- `hash_of_all_files` (`String`) – значение [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) для сжатых файлов. + +- `hash_of_uncompressed_files` (`String`) – значение [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) несжатых файлов (файлы с засечками, первичным ключом и пр.) + +- `uncompressed_hash_of_compressed_files` (`String`) – значение [sipHash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) данных в сжатых файлах как если бы они были разжатыми. + +- `bytes` (`UInt64`) – алиас для `bytes_on_disk`. + +- `marks_size` (`UInt64`) – алиас для `marks_bytes`. + +## system.part\_log {#system_tables-part-log} + +Системная таблица `system.part_log` создается только в том случае, если задана серверная настройка [part\_log](server-configuration-parameters/settings.md#server_configuration_parameters-part-log). + +Содержит информацию о всех событиях, произошедших с [кусками данных](../engines/table-engines/mergetree-family/custom-partitioning-key.md) таблиц семейства [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) (например, события добавления, удаления или слияния данных). + +Столбцы: + +- `event_type` (Enum) — тип события. Столбец может содержать одно из следующих значений: + - `NEW_PART` — вставка нового куска. + - `MERGE_PARTS` — слияние кусков. + - `DOWNLOAD_PART` — загрузка с реплики. + - `REMOVE_PART` — удаление или отсоединение из таблицы с помощью [DETACH PARTITION](../sql-reference/statements/alter.md#alter_detach-partition). + - `MUTATE_PART` — изменение куска. + - `MOVE_PART` — перемещение куска между дисками. +- `event_date` (Date) — дата события. +- `event_time` (DateTime) — время события. +- `duration_ms` (UInt64) — длительность. +- `database` (String) — имя базы данных, в которой находится кусок. +- `table` (String) — имя таблицы, в которой находится кусок. +- `part_name` (String) — имя куска. +- `partition_id` (String) — идентификатор партиции, в которую был добавлен кусок. В столбце будет значение ‘all’, если таблица партициируется по выражению `tuple()`. +- `rows` (UInt64) — число строк в куске. +- `size_in_bytes` (UInt64) — размер куска данных в байтах. +- `merged_from` (Array(String)) — массив имён кусков, из которых образован текущий кусок в результате слияния (также столбец заполняется в случае скачивания уже смерженного куска). +- `bytes_uncompressed` (UInt64) — количество прочитанных разжатых байт. +- `read_rows` (UInt64) — сколько было прочитано строк при слиянии кусков. +- `read_bytes` (UInt64) — сколько было прочитано байт при слиянии кусков. +- `error` (UInt16) — код ошибки, возникшей при текущем событии. +- `exception` (String) — текст ошибки. + +Системная таблица `system.part_log` будет создана после первой вставки данных в таблицу `MergeTree`. + +## system.processes {#system_tables-processes} + +Используется для реализации запроса `SHOW PROCESSLIST`. + +Столбцы: + +- `user` (String) – пользователь, инициировавший запрос. При распределённом выполнении запросы отправляются на удалённые серверы от имени пользователя `default`. Поле содержит имя пользователя для конкретного запроса, а не для запроса, который иницировал этот запрос. +- `address` (String) – IP-адрес, с которого пришёл запрос. При распределённой обработке запроса аналогично. Чтобы определить откуда запрос пришел изначально, необходимо смотреть таблицу `system.processes` на сервере-источнике запроса. +- `elapsed` (Float64) – время в секундах с начала обработки запроса. +- `rows_read` (UInt64) – количество прочитанных строк. При распределённой обработке запроса на сервере-инициаторе запроса представляет собой сумму по всем удалённым серверам. +- `bytes_read` (UInt64) – количество прочитанных из таблиц байт, в несжатом виде. При распределённой обработке запроса на сервере-инициаторе запроса представляет собой сумму по всем удалённым серверам. +- `total_rows_approx` (UInt64) – приблизительная оценка общего количества строк, которые должны быть прочитаны. При распределённой обработке запроса, на сервере-инициаторе запроса, представляет собой сумму по всем удалённым серверам. Может обновляться в процессе выполнения запроса, когда становятся известны новые источники для обработки. +- `memory_usage` (UInt64) – потребление памяти запросом. Может не учитывать некоторые виды выделенной памяти. Смотрите описание настройки [max\_memory\_usage](../operations/settings/query-complexity.md#settings_max_memory_usage). +- `query` (String) – текст запроса. Для запросов `INSERT` не содержит встаявляемые данные. +- `query_id` (String) – идентификатор запроса, если был задан. + +## system.text\_log {#system-tables-text-log} + +Содержит записи логов. Уровень логирования для таблицы может быть ограничен параметром сервера `text_log.level`. + +Столбцы: + +- `event_date` (Date) — Дата создания записи. +- `event_time` (DateTime) — Время создания записи. +- `microseconds` (UInt32) — Время создания записи в микросекундах. +- `thread_name` (String) — Название потока, из которого была сделана запись. +- `thread_id` (UInt64) — Идентификатор потока ОС. +- `level` (Enum8) — Уровень логирования записи. Возможные значения: + - `1` или `'Fatal'`. + - `2` или `'Critical'`. + - `3` или `'Error'`. + - `4` или `'Warning'`. + - `5` или `'Notice'`. + - `6` или `'Information'`. + - `7` или `'Debug'`. + - `8` или `'Trace'`. +- `query_id` (String) — Идентификатор запроса. +- `logger_name` (LowCardinality(String)) — Название логгера (`DDLWorker`). +- `message` (String) — Само тело записи. +- `revision` (UInt32) — Ревизия ClickHouse. +- `source_file` (LowCardinality(String)) — Исходный файл, из которого была сделана запись. +- `source_line` (UInt64) — Исходная строка, из которой была сделана запись. + +## system.query_log {#system_tables-query_log} + +Содержит информацию о выполняемых запросах, например, время начала обработки, продолжительность обработки, сообщения об ошибках. + +!!! note "Внимание" + Таблица не содержит входных данных для запросов `INSERT`. + +Настойки логгирования можно изменить в секции серверной конфигурации [query_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log). + +Можно отключить логгирование настройкой [log_queries = 0](settings/settings.md#settings-log-queries). По-возможности, не отключайте логгирование, поскольку информация из таблицы важна при решении проблем. + +Период сброса данных в таблицу задаётся параметром `flush_interval_milliseconds` в конфигурационной секции [query_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log). Чтобы принудительно записать логи из буффера памяти в таблицу, используйте запрос [SYSTEM FLUSH LOGS](../sql-reference/statements/system.md#query_language-system-flush_logs). + +ClickHouse не удаляет данные из таблица автоматически. Смотрите [Введение](#system-tables-introduction). + +Таблица `system.query_log` содержит информацию о двух видах запросов: + +1. Первоначальные запросы, которые были выполнены непосредственно клиентом. +2. Дочерние запросы, инициированные другими запросами (для выполнения распределенных запросов). Для дочерних запросов информация о первоначальном запросе содержится в столбцах `initial_*`. + +В зависимости от статуса (столбец `type`) каждый запрос создаёт одну или две строки в таблице `query_log`: + +1. Если запрос выполнен успешно, создаются два события типа `QueryStart` и `QueryFinish`. +2. Если во время обработки запроса возникла ошибка, создаются два события с типами `QueryStart` и `ExceptionWhileProcessing`. +3. Если ошибка произошла ещё до запуска запроса, создается одно событие с типом `ExceptionBeforeStart`. + +Столбцы: + +- `type` ([Enum8](../sql-reference/data-types/enum.md)) — тип события, произошедшего при выполнении запроса. Значения: + - `'QueryStart' = 1` — успешное начало выполнения запроса. + - `'QueryFinish' = 2` — успешное завершение выполнения запроса. + - `'ExceptionBeforeStart' = 3` — исключение перед началом обработки запроса. + - `'ExceptionWhileProcessing' = 4` — исключение во время обработки запроса. +- `event_date` ([Date](../sql-reference/data-types/date.md)) — дата начала запроса. +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — время начала запроса. +- `query_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — время начала обработки запроса. +- `query_duration_ms` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — длительность выполнения запроса в миллисекундах. +- `read_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Общее количество строк, считанных из всех таблиц и табличных функций, участвующих в запросе. Включает в себя обычные подзапросы, подзапросы для `IN` и `JOIN`. Для распределенных запросов `read_rows` включает в себя общее количество строк, прочитанных на всех репликах. Каждая реплика передает собственное значение `read_rows`, а сервер-инициатор запроса суммирует все полученные и локальные значения. Объемы кэша не учитываюся. +- `read_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Общее количество байтов, считанных из всех таблиц и табличных функций, участвующих в запросе. Включает в себя обычные подзапросы, подзапросы для `IN` и `JOIN`. Для распределенных запросов `read_bytes` включает в себя общее количество байтов, прочитанных на всех репликах. Каждая реплика передает собственное значение `read_bytes`, а сервер-инициатор запроса суммирует все полученные и локальные значения. Объемы кэша не учитываюся. +- `written_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — количество записанных строк для запросов `INSERT`. Для других запросов, значение столбца 0. +- `written_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — объём записанных данных в байтах для запросов `INSERT`. Для других запросов, значение столбца 0. +- `result_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — количество строк в результате запроса `SELECT` или количество строк в запросе `INSERT`. +- `result_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — объём RAM в байтах, использованный для хранения результата запроса. +- `memory_usage` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — потребление RAM запросом. +- `query` ([String](../sql-reference/data-types/string.md)) — текст запроса. +- `exception` ([String](../sql-reference/data-types/string.md)) — сообщение исключения, если запрос завершился по исключению. +- `exception_code` ([Int32](../sql-reference/data-types/int-uint.md)) — код исключения. +- `stack_trace` ([String](../sql-reference/data-types/string.md)) — [stack trace](https://en.wikipedia.org/wiki/Stack_trace). Пустая строка, если запрос успешно завершен. +- `is_initial_query` ([UInt8](../sql-reference/data-types/int-uint.md)) — вид запроса. Возможные значения: + - 1 — запрос был инициирован клиентом. + - 0 — запрос был инициирован другим запросом при выполнении распределенного запроса. +- `user` ([String](../sql-reference/data-types/string.md)) — пользователь, запустивший текущий запрос. +- `query_id` ([String](../sql-reference/data-types/string.md)) — ID запроса. +- `address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP адрес, с которого пришел запрос. +- `port` ([UInt16](../sql-reference/data-types/int-uint.md)) — порт, с которого клиент сделал запрос +- `initial_user` ([String](../sql-reference/data-types/string.md)) — пользователь, запустивший первоначальный запрос (для распределенных запросов). +- `initial_query_id` ([String](../sql-reference/data-types/string.md)) — ID родительского запроса. +- `initial_address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP адрес, с которого пришел родительский запрос. +- `initial_port` ([UInt16](../sql-reference/data-types/int-uint.md)) — порт, с которого клиент сделал родительский запрос. +- `interface` ([UInt8](../sql-reference/data-types/int-uint.md)) — интерфейс, с которого ушёл запрос. Возможные значения: + - 1 — TCP. + - 2 — HTTP. +- `os_user` ([String](../sql-reference/data-types/string.md)) — имя пользователя операционной системы, который запустил [clickhouse-client](../interfaces/cli.md). +- `client_hostname` ([String](../sql-reference/data-types/string.md)) — имя сервера, с которого присоединился [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. +- `client_name` ([String](../sql-reference/data-types/string.md)) — [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. +- `client_revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ревизия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `client_version_major` ([UInt32](../sql-reference/data-types/int-uint.md)) — старшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `client_version_minor` ([UInt32](../sql-reference/data-types/int-uint.md)) — младшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `client_version_patch` ([UInt32](../sql-reference/data-types/int-uint.md)) — патч [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `http_method` ([UInt8](../sql-reference/data-types/int-uint.md)) — HTTP метод, инициировавший запрос. Возможные значения: + - 0 — запрос запущен с интерфейса TCP. + - 1 — `GET`. + - 2 — `POST`. +- `http_user_agent` ([String](../sql-reference/data-types/string.md)) — HTTP заголовок `UserAgent`. +- `quota_key` ([String](../sql-reference/data-types/string.md)) — «ключ квоты» из настроек [квот](quotas.md) (см. `keyed`). +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ревизия ClickHouse. +- `thread_numbers` ([Array(UInt32)](../sql-reference/data-types/array.md)) — количество потоков, участвующих в обработке запросов. +- `ProfileEvents.Names` ([Array(String)](../sql-reference/data-types/array.md)) — Счетчики для изменения различных метрик. Описание метрик можно получить из таблицы [system.events](#system_tables-events)(\#system\_tables-events +- `ProfileEvents.Values` ([Array(UInt64)](../sql-reference/data-types/array.md)) — метрики, перечисленные в столбце `ProfileEvents.Names`. +- `Settings.Names` ([Array(String)](../sql-reference/data-types/array.md)) — имена настроек, которые меняются, когда клиент выполняет запрос. Чтобы разрешить логирование изменений настроек, установите параметр `log_query_settings` равным 1. +- `Settings.Values` ([Array(String)](../sql-reference/data-types/array.md)) — Значения настроек, которые перечислены в столбце `Settings.Names`. + +**Пример** + +``` sql +SELECT * FROM system.query_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +type: QueryStart +event_date: 2020-05-13 +event_time: 2020-05-13 14:02:28 +query_start_time: 2020-05-13 14:02:28 +query_duration_ms: 0 +read_rows: 0 +read_bytes: 0 +written_rows: 0 +written_bytes: 0 +result_rows: 0 +result_bytes: 0 +memory_usage: 0 +query: SELECT 1 +exception_code: 0 +exception: +stack_trace: +is_initial_query: 1 +user: default +query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +address: ::ffff:127.0.0.1 +port: 57720 +initial_user: default +initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +initial_address: ::ffff:127.0.0.1 +initial_port: 57720 +interface: 1 +os_user: bayonet +client_hostname: clickhouse.ru-central1.internal +client_name: ClickHouse client +client_revision: 54434 +client_version_major: 20 +client_version_minor: 4 +client_version_patch: 1 +http_method: 0 +http_user_agent: +quota_key: +revision: 54434 +thread_ids: [] +ProfileEvents.Names: [] +ProfileEvents.Values: [] +Settings.Names: ['use_uncompressed_cache','load_balancing','log_queries','max_memory_usage'] +Settings.Values: ['0','random','1','10000000000'] + +``` +**Смотрите также** + +- [system.query_thread_log](#system_tables-query_thread_log) — в этой таблице содержится информация о цепочке каждого выполненного запроса. + +## system.query_thread_log {#system_tables-query_thread_log} + +Содержит информацию о потоках, которые выполняют запросы, например, имя потока, время его запуска, продолжительность обработки запроса. + +Чтобы начать логирование: + +1. Настройте параметры [query_thread_log](server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) в конфигурации сервера. +2. Установите значение [log_query_threads](settings/settings.md#settings-log-query-threads) равным 1. + +Интервал сброса данных в таблицу задаётся параметром `flush_interval_milliseconds` в разделе настроек сервера [query_thread_log](server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log). Чтобы принудительно записать логи из буфера памяти в таблицу, используйте запрос [SYSTEM FLUSH LOGS](../sql-reference/statements/system.md#query_language-system-flush_logs). + +ClickHouse не удаляет данные из таблицы автоматически. Подробности в разделе [Введение](#system-tables-introduction). + +Столбцы: + +- `event_date` ([Date](../sql-reference/data-types/date.md)) — дата завершения выполнения запроса потоком. +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — дата и время завершения выполнения запроса потоком. +- `query_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — время начала обработки запроса. +- `query_duration_ms` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — длительность обработки запроса в миллисекундах. +- `read_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — количество прочитанных строк. +- `read_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — количество прочитанных байтов. +- `written_rows` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — количество записанных строк для запросов `INSERT`. Для других запросов, значение столбца 0. +- `written_bytes` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — объём записанных данных в байтах для запросов `INSERT`. Для других запросов, значение столбца 0. +- `memory_usage` ([Int64](../sql-reference/data-types/int-uint.md)) — разница между выделенной и освобождённой памятью в контексте потока. +- `peak_memory_usage` ([Int64](../sql-reference/data-types/int-uint.md)) — максимальная разница между выделенной и освобождённой памятью в контексте потока. +- `thread_name` ([String](../sql-reference/data-types/string.md)) — Имя потока. +- `thread_id` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — tid (ID потока операционной системы). +- `master_thread_id` ([UInt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — tid (ID потока операционной системы) главного потока. +- `query` ([String](../sql-reference/data-types/string.md)) — текст запроса. +- `is_initial_query` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — вид запроса. Возможные значения: + - 1 — запрос был инициирован клиентом. + - 0 — запрос был инициирован другим запросом при распределенном запросе. +- `user` ([String](../sql-reference/data-types/string.md)) — пользователь, запустивший текущий запрос. +- `query_id` ([String](../sql-reference/data-types/string.md)) — ID запроса. +- `address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP адрес, с которого пришел запрос. +- `port` ([UInt16](../sql-reference/data-types/int-uint.md#uint-ranges)) — порт, с которого пришел запрос. +- `initial_user` ([String](../sql-reference/data-types/string.md)) — пользователь, запустивший первоначальный запрос (для распределенных запросов). +- `initial_query_id` ([String](../sql-reference/data-types/string.md)) — ID родительского запроса. +- `initial_address` ([IPv6](../sql-reference/data-types/domains/ipv6.md)) — IP адрес, с которого пришел родительский запрос. +- `initial_port` ([UInt16](../sql-reference/data-types/int-uint.md#uint-ranges)) — порт, пришел родительский запрос. +- `interface` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — интерфейс, с которого ушёл запрос. Возможные значения: + - 1 — TCP. + - 2 — HTTP. +- `os_user` ([String](../sql-reference/data-types/string.md)) — имя пользователя в OS, который запустил [clickhouse-client](../interfaces/cli.md). +- `client_hostname` ([String](../sql-reference/data-types/string.md)) — hostname клиентской машины, с которой присоединился [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. +- `client_name` ([String](../sql-reference/data-types/string.md)) — [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. +- `client_revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ревизия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `client_version_major` ([UInt32](../sql-reference/data-types/int-uint.md)) — старшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `client_version_minor` ([UInt32](../sql-reference/data-types/int-uint.md)) — младшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `client_version_patch` ([UInt32](../sql-reference/data-types/int-uint.md)) — патч [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. +- `http_method` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — HTTP метод, инициировавший запрос. Возможные значения: + - 0 — запрос запущен с интерфейса TCP. + - 1 — `GET`. + - 2 — `POST`. +- `http_user_agent` ([String](../sql-reference/data-types/string.md)) — HTTP заголовок `UserAgent`. +- `quota_key` ([String](../sql-reference/data-types/string.md)) — «ключ квоты» из настроек [квот](quotas.md) (см. `keyed`). +- `revision` ([UInt32](../sql-reference/data-types/int-uint.md)) — ревизия ClickHouse. +- `ProfileEvents.Names` ([Array(String)](../sql-reference/data-types/array.md)) — Счетчики для изменения различных метрик для данного потока. Описание метрик можно получить из таблицы [system.events](#system_tables-events). +- `ProfileEvents.Values` ([Array(UInt64)](../sql-reference/data-types/array.md)) — метрики для данного потока, перечисленные в столбце `ProfileEvents.Names`. + +**Пример** + +``` sql + SELECT * FROM system.query_thread_log LIMIT 1 FORMAT Vertical +``` + +``` text +Row 1: +────── +event_date: 2020-05-13 +event_time: 2020-05-13 14:02:28 +query_start_time: 2020-05-13 14:02:28 +query_duration_ms: 0 +read_rows: 1 +read_bytes: 1 +written_rows: 0 +written_bytes: 0 +memory_usage: 0 +peak_memory_usage: 0 +thread_name: QueryPipelineEx +thread_id: 28952 +master_thread_id: 28924 +query: SELECT 1 +is_initial_query: 1 +user: default +query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +address: ::ffff:127.0.0.1 +port: 57720 +initial_user: default +initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a +initial_address: ::ffff:127.0.0.1 +initial_port: 57720 +interface: 1 +os_user: bayonet +client_hostname: clickhouse.ru-central1.internal +client_name: ClickHouse client +client_revision: 54434 +client_version_major: 20 +client_version_minor: 4 +client_version_patch: 1 +http_method: 0 +http_user_agent: +quota_key: +revision: 54434 +ProfileEvents.Names: ['ContextLock','RealTimeMicroseconds','UserTimeMicroseconds','OSCPUWaitMicroseconds','OSCPUVirtualTimeMicroseconds'] +ProfileEvents.Values: [1,97,81,5,81] +... +``` + +**Смотрите также** + +- [system.query_log](#system_tables-query_log) — описание системной таблицы `query_log`, которая содержит общую информацию о выполненных запросах. + +## system.trace\_log {#system_tables-trace_log} + +Contains stack traces collected by the sampling query profiler. + +ClickHouse creates this table when the [trace\_log](server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) server configuration section is set. Also the [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) and [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) settings should be set. + +To analyze logs, use the `addressToLine`, `addressToSymbol` and `demangle` introspection functions. + +Columns: + +- `event_date`([Date](../sql-reference/data-types/date.md)) — Date of sampling moment. + +- `event_time`([DateTime](../sql-reference/data-types/datetime.md)) — Timestamp of sampling moment. + +- `revision`([UInt32](../sql-reference/data-types/int-uint.md)) — ClickHouse server build revision. + + When connecting to server by `clickhouse-client`, you see the string similar to `Connected to ClickHouse server version 19.18.1 revision 54429.`. This field contains the `revision`, but not the `version` of a server. + +- `timer_type`([Enum8](../sql-reference/data-types/enum.md)) — Timer type: + + - `Real` represents wall-clock time. + - `CPU` represents CPU time. + +- `thread_number`([UInt32](../sql-reference/data-types/int-uint.md)) — Thread identifier. + +- `query_id`([String](../sql-reference/data-types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) system table. + +- `trace`([Array(UInt64)](../sql-reference/data-types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. + +**Example** + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-15 +event_time: 2019-11-15 15:09:38 +revision: 54428 +timer_type: Real +thread_number: 48 +query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 +trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] +``` + +## system.replicas {#system_tables-replicas} + +Содержит информацию и статус для реплицируемых таблиц, расположенных на локальном сервере. +Эту таблицу можно использовать для мониторинга. Таблица содержит по строчке для каждой Replicated\*-таблицы. + +Пример: + +``` sql +SELECT * +FROM system.replicas +WHERE table = 'visits' +FORMAT Vertical +``` + +``` text +Row 1: +────── +database: merge +table: visits +engine: ReplicatedCollapsingMergeTree +is_leader: 1 +can_become_leader: 1 +is_readonly: 0 +is_session_expired: 0 +future_parts: 1 +parts_to_check: 0 +zookeeper_path: /clickhouse/tables/01-06/visits +replica_name: example01-06-1.yandex.ru +replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru +columns_version: 9 +queue_size: 1 +inserts_in_queue: 0 +merges_in_queue: 1 +part_mutations_in_queue: 0 +queue_oldest_time: 2020-02-20 08:34:30 +inserts_oldest_time: 0000-00-00 00:00:00 +merges_oldest_time: 2020-02-20 08:34:30 +part_mutations_oldest_time: 0000-00-00 00:00:00 +oldest_part_to_get: +oldest_part_to_merge_to: 20200220_20284_20840_7 +oldest_part_to_mutate_to: +log_max_index: 596273 +log_pointer: 596274 +last_queue_update: 2020-02-20 08:34:32 +absolute_delay: 0 +total_replicas: 2 +active_replicas: 2 +``` + +Столбцы: + +- `database` (`String`) - имя БД. +- `table` (`String`) - имя таблицы. +- `engine` (`String`) - имя движка таблицы. +- `is_leader` (`UInt8`) - является ли реплика лидером. + В один момент времени, не более одной из реплик является лидером. Лидер отвечает за выбор фоновых слияний, которые следует произвести. + Замечу, что запись можно осуществлять на любую реплику (доступную и имеющую сессию в ZK), независимо от лидерства. +- `can_become_leader` (`UInt8`) - может ли реплика быть выбрана лидером. +- `is_readonly` (`UInt8`) - находится ли реплика в режиме «только для чтения» + Этот режим включается, если в конфиге нет секции с ZK; если при переинициализации сессии в ZK произошла неизвестная ошибка; во время переинициализации сессии с ZK. +- `is_session_expired` (`UInt8`) - истекла ли сессия с ZK. В основном, то же самое, что и `is_readonly`. +- `future_parts` (`UInt32`) - количество кусков с данными, которые появятся в результате INSERT-ов или слияний, которых ещё предстоит сделать +- `parts_to_check` (`UInt32`) - количество кусков с данными в очереди на проверку. Кусок помещается в очередь на проверку, если есть подозрение, что он может быть битым. +- `zookeeper_path` (`String`) - путь к данным таблицы в ZK. +- `replica_name` (`String`) - имя реплики в ZK; разные реплики одной таблицы имеют разное имя. +- `replica_path` (`String`) - путь к данным реплики в ZK. То же самое, что конкатенация zookeeper\_path/replicas/replica\_path. +- `columns_version` (`Int32`) - номер версии структуры таблицы. Обозначает, сколько раз был сделан ALTER. Если на репликах разные версии, значит некоторые реплики сделали ещё не все ALTER-ы. +- `queue_size` (`UInt32`) - размер очереди действий, которые предстоит сделать. К действиям относятся вставки блоков данных, слияния, и некоторые другие действия. Как правило, совпадает с future\_parts. +- `inserts_in_queue` (`UInt32`) - количество вставок блоков данных, которые предстоит сделать. Обычно вставки должны быстро реплицироваться. Если величина большая - значит что-то не так. +- `merges_in_queue` (`UInt32`) - количество слияний, которые предстоит сделать. Бывают длинные слияния - то есть, это значение может быть больше нуля продолжительное время. +- `part_mutations_in_queue` (`UInt32`) - количество мутаций, которые предстоит сделать. +- `queue_oldest_time` (`DateTime`) - если `queue_size` больше 0, показывает, когда была добавлена в очередь самая старая операция. +- `inserts_oldest_time` (`DateTime`) - см. `queue_oldest_time`. +- `merges_oldest_time` (`DateTime`) - см. `queue_oldest_time`. +- `part_mutations_oldest_time` (`DateTime`) - см. `queue_oldest_time`. + +Следующие 4 столбца имеют ненулевое значение только если активна сессия с ZK. + +- `log_max_index` (`UInt64`) - максимальный номер записи в общем логе действий. +- `log_pointer` (`UInt64`) - максимальный номер записи из общего лога действий, которую реплика скопировала в свою очередь для выполнения, плюс единица. Если log\_pointer сильно меньше log\_max\_index, значит что-то не так. +- `last_queue_update` (`DateTime`) - When the queue was updated last time. +- `absolute_delay` (`UInt64`) - How big lag in seconds the current replica has. +- `total_replicas` (`UInt8`) - общее число известных реплик этой таблицы. +- `active_replicas` (`UInt8`) - число реплик этой таблицы, имеющих сессию в ZK; то есть, число работающих реплик. + +Если запрашивать все столбцы, то таблица может работать слегка медленно, так как на каждую строчку делается несколько чтений из ZK. +Если не запрашивать последние 4 столбца (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), то таблица работает быстро. + +Например, так можно проверить, что всё хорошо: + +``` sql +SELECT + database, + table, + is_leader, + is_readonly, + is_session_expired, + future_parts, + parts_to_check, + columns_version, + queue_size, + inserts_in_queue, + merges_in_queue, + log_max_index, + log_pointer, + total_replicas, + active_replicas +FROM system.replicas +WHERE + is_readonly + OR is_session_expired + OR future_parts > 20 + OR parts_to_check > 10 + OR queue_size > 20 + OR inserts_in_queue > 10 + OR log_max_index - log_pointer > 10 + OR total_replicas < 2 + OR active_replicas < total_replicas +``` + +Если этот запрос ничего не возвращает - значит всё хорошо. + +## system.settings {#system-tables-system-settings} + +Содержит информацию о сессионных настройках для текущего пользователя. + +Столбцы: + +- `name` ([String](../sql-reference/data-types/string.md)) — имя настройки. +- `value` ([String](../sql-reference/data-types/string.md)) — значение настройки. +- `changed` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — показывает, изменена ли настройка по отношению к значению по умолчанию. +- `description` ([String](../sql-reference/data-types/string.md)) — краткое описание настройки. +- `min` ([Nullable](../sql-reference/data-types/nullable.md)([String](../sql-reference/data-types/string.md))) — минимальное значение настройки, если задано [ограничение](settings/constraints-on-settings.md#constraints-on-settings). Если нет, то поле содержит [NULL](../sql-reference/syntax.md#null-literal). +- `max` ([Nullable](../sql-reference/data-types/nullable.md)([String](../sql-reference/data-types/string.md))) — максимальное значение настройки, если задано [ограничение](settings/constraints-on-settings.md#constraints-on-settings). Если нет, то поле содержит [NULL](../sql-reference/syntax.md#null-literal). +- `readonly` ([UInt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Показывает, может ли пользователь изменять настройку: + - `0` — Текущий пользователь может изменять настройку. + - `1` — Текущий пользователь не может изменять настройку. + +**Пример** + +Пример показывает как получить информацию о настройках, имена которых содержат `min_i`. + +``` sql +SELECT * +FROM system.settings +WHERE name LIKE '%min_i%' +``` + +``` text +┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ +│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ +``` + +Использование `WHERE changed` может быть полезно, например, если необходимо проверить: + +- Что настройки корректно загрузились из конфигурационного файла и используются. +- Настройки, изменённые в текущей сессии. + + + +``` sql +SELECT * FROM system.settings WHERE changed AND name='load_balancing' +``` + +**Cм. также** + +- [Настройки](settings/index.md#settings) +- [Разрешения для запросов](settings/permissions-for-queries.md#settings_readonly) +- [Ограничения для значений настроек](settings/constraints-on-settings.md) + +## system.table\_engines {#system.table_engines} + +``` text +┌─name───────────────────┬─value───────┬─changed─┐ +│ max_threads │ 8 │ 1 │ +│ use_uncompressed_cache │ 0 │ 1 │ +│ load_balancing │ random │ 1 │ +│ max_memory_usage │ 10000000000 │ 1 │ +└────────────────────────┴─────────────┴─────────┘ +``` + +## system.table\_engines {#system-table-engines} + +Содержит информацию про движки таблиц, поддерживаемые сервером, а также об их возможностях. + +Эта таблица содержит следующие столбцы (тип столбца показан в скобках): + +- `name` (String) — имя движка. +- `supports_settings` (UInt8) — флаг, показывающий поддержку секции `SETTINGS`. +- `supports_skipping_indices` (UInt8) — флаг, показывающий поддержку [индексов пропуска данных](table_engines/mergetree/#table_engine-mergetree-data_skipping-indexes). +- `supports_ttl` (UInt8) — флаг, показывающий поддержку [TTL](table_engines/mergetree/#table_engine-mergetree-ttl). +- `supports_sort_order` (UInt8) — флаг, показывающий поддержку секций `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` и `SAMPLE_BY`. +- `supports_replication` (UInt8) — флаг, показывающий поддержку [репликации](../engines/table-engines/mergetree-family/replication.md). +- `supports_deduplication` (UInt8) — флаг, показывающий наличие в движке дедупликации данных. + +Пример: + +``` sql +SELECT * +FROM system.table_engines +WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') +``` + +``` text +┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ +│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ +│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ +│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ +└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ +``` + +**Смотрите также** + +- [Секции движка](../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) семейства MergeTree +- [Настройки](../engines/table-engines/integrations/kafka.md#table_engine-kafka-creating-a-table) Kafka +- [Настройки](../engines/table-engines/special/join.md#join-limitations-and-settings) Join + +## system.tables {#system-tables} + +Содержит метаданные каждой таблицы, о которой знает сервер. Отсоединённые таблицы не отображаются в `system.tables`. + +Эта таблица содержит следующие столбцы (тип столбца показан в скобках): + +- `database String` — имя базы данных, в которой находится таблица. +- `name` (String) — имя таблицы. +- `engine` (String) — движок таблицы (без параметров). +- `is_temporary` (UInt8) — флаг, указывающий на то, временная это таблица или нет. +- `data_path` (String) — путь к данным таблицы в файловой системе. +- `metadata_path` (String) — путь к табличным метаданным в файловой системе. +- `metadata_modification_time` (DateTime) — время последней модификации табличных метаданных. +- `dependencies_database` (Array(String)) — зависимости базы данных. +- `dependencies_table` (Array(String)) — табличные зависимости (таблицы [MaterializedView](../engines/table-engines/special/materializedview.md), созданные на базе текущей таблицы). +- `create_table_query` (String) — запрос, которым создавалась таблица. +- `engine_full` (String) — параметры табличного движка. +- `partition_key` (String) — ключ партиционирования таблицы. +- `sorting_key` (String) — ключ сортировки таблицы. +- `primary_key` (String) - первичный ключ таблицы. +- `sampling_key` (String) — ключ сэмплирования таблицы. + +Таблица `system.tables` используется при выполнении запроса `SHOW TABLES`. + +## system.zookeeper {#system-zookeeper} + +Таблицы не существует, если ZooKeeper не сконфигурирован. Позволяет читать данные из ZooKeeper кластера, описанного в конфигурации. +В запросе обязательно в секции WHERE должно присутствовать условие на равенство path - путь в ZooKeeper, для детей которого вы хотите получить данные. + +Запрос `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` выведет данные по всем детям узла `/clickhouse`. +Чтобы вывести данные по всем узлам в корне, напишите path = ‘/’. +Если узла, указанного в path не существует, то будет брошено исключение. + +Столбцы: + +- `name String` — Имя узла. +- `path String` — Путь к узлу. +- `value String` — Значение узла. +- `dataLength Int32` — Размер значения. +- `numChildren Int32` — Количество детей. +- `czxid Int64` — Идентификатор транзакции, в которой узел был создан. +- `mzxid Int64` — Идентификатор транзакции, в которой узел был последний раз изменён. +- `pzxid Int64` — Идентификатор транзакции, последний раз удаливший или добавивший детей. +- `ctime DateTime` — Время создания узла. +- `mtime DateTime` — Время последней модификации узла. +- `version Int32` — Версия узла - количество раз, когда узел был изменён. +- `cversion Int32` — Количество добавлений или удалений детей. +- `aversion Int32` — Количество изменений ACL. +- `ephemeralOwner Int64` — Для эфемерных узлов - идентификатор сессии, которая владеет этим узлом. + +Пример: + +``` sql +SELECT * +FROM system.zookeeper +WHERE path = '/clickhouse/tables/01-08/visits/replicas' +FORMAT Vertical +``` + +``` text +Row 1: +────── +name: example01-08-1.yandex.ru +value: +czxid: 932998691229 +mzxid: 932998691229 +ctime: 2015-03-27 16:49:51 +mtime: 2015-03-27 16:49:51 +version: 0 +cversion: 47 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021031383 +path: /clickhouse/tables/01-08/visits/replicas + +Row 2: +────── +name: example01-08-2.yandex.ru +value: +czxid: 933002738135 +mzxid: 933002738135 +ctime: 2015-03-27 16:57:01 +mtime: 2015-03-27 16:57:01 +version: 0 +cversion: 37 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021252247 +path: /clickhouse/tables/01-08/visits/replicas +``` + +## system.mutations {#system_tables-mutations} + +Таблица содержит информацию о ходе выполнения [мутаций](../sql-reference/statements/alter.md#alter-mutations) MergeTree-таблиц. Каждой команде мутации соответствует одна строка. В таблице есть следующие столбцы: + +**database**, **table** - имя БД и таблицы, к которой была применена мутация. + +**mutation\_id** - ID запроса. Для реплицированных таблиц эти ID соответствуют именам записей в директории `/mutations/` в ZooKeeper, для нереплицированных - именам файлов в директории с данными таблицы. + +**command** - Команда мутации (часть запроса после `ALTER TABLE [db.]table`). + +**create\_time** - Время создания мутации. + +**block\_numbers.partition\_id**, **block\_numbers.number** - Nested-столбец. Для мутаций реплицированных таблиц для каждой партиции содержит номер блока, полученный этой мутацией (в каждой партиции будут изменены только куски, содержащие блоки с номерами, меньшими номера, полученного мутацией в этой партиции). Для нереплицированных таблиц нумерация блоков сквозная по партициям, поэтому столбец содержит одну запись с единственным номером блока, полученным мутацией. + +**parts\_to\_do** - Количество кусков таблицы, которые ещё предстоит изменить. + +**is\_done** - Завершена ли мутация. Замечание: даже если `parts_to_do = 0`, для реплицированной таблицы возможна ситуация, когда мутация ещё не завершена из-за долго выполняющейся вставки, которая добавляет данные, которые нужно будет мутировать. + +Если во время мутации какого-либо куска возникли проблемы, заполняются следующие столбцы: + +**latest\_failed\_part** - Имя последнего куска, мутация которого не удалась. + +**latest\_fail\_time** — время последней ошибки мутации. + +**latest\_fail\_reason** — причина последней ошибки мутации. + +## system.disks {#system_tables-disks} + +Cодержит информацию о дисках, заданных в [конфигурации сервера](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Столбцы: + +- `name` ([String](../sql-reference/data-types/string.md)) — имя диска в конфигурации сервера. +- `path` ([String](../sql-reference/data-types/string.md)) — путь к точке монтирования в файловой системе. +- `free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — свободное место на диске в байтах. +- `total_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — объём диска в байтах. +- `keep_free_space` ([UInt64](../sql-reference/data-types/int-uint.md)) — место, которое должно остаться свободным на диске в байтах. Задаётся значением параметра `keep_free_space_bytes` конфигурации дисков. + +## system.storage\_policies {#system_tables-storage_policies} + +Содержит информацию о политиках хранения и томах, заданных в [конфигурации сервера](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Столбцы: + +- `policy_name` ([String](../sql-reference/data-types/string.md)) — имя политики хранения. +- `volume_name` ([String](../sql-reference/data-types/string.md)) — имя тома, который содержится в политике хранения. +- `volume_priority` ([UInt64](../sql-reference/data-types/int-uint.md)) — порядковый номер тома согласно конфигурации. +- `disks` ([Array(String)](../sql-reference/data-types/array.md)) — имена дисков, содержащихся в политике хранения. +- `max_data_part_size` ([UInt64](../sql-reference/data-types/int-uint.md)) — максимальный размер куска данных, который может храниться на дисках тома (0 — без ограничений). +- `move_factor` ([Float64](../sql-reference/data-types/float.md))\` — доля свободного места, при превышении которой данные начинают перемещаться на следующий том. + +Если политика хранения содержит несколько томов, то каждому тому соответствует отдельная запись в таблице. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/system_tables/) diff --git a/docs/ru/operations/system_tables.md b/docs/ru/operations/system_tables.md deleted file mode 100644 index b68aa570f52..00000000000 --- a/docs/ru/operations/system_tables.md +++ /dev/null @@ -1,1170 +0,0 @@ -# Системные таблицы {#sistemnye-tablitsy} - -Системные таблицы используются для реализации части функциональности системы, а также предоставляют доступ к информации о работе системы. -Вы не можете удалить системную таблицу (хотя можете сделать DETACH). -Для системных таблиц нет файлов с данными на диске и файлов с метаданными. Сервер создаёт все системные таблицы при старте. -В системные таблицы нельзя записывать данные - можно только читать. -Системные таблицы расположены в базе данных system. - -## system.asynchronous\_metrics {#system_tables-asynchronous_metrics} - -Содержит метрики, которые периодически вычисляются в фоновом режиме. Например, объём используемой оперативной памяти. - -Столбцы: - -- `metric` ([String](../sql_reference/data_types/string.md)) — название метрики. -- `value` ([Float64](../sql_reference/data_types/float.md)) — значение метрики. - -**Пример** - -``` sql -SELECT * FROM system.asynchronous_metrics LIMIT 10 -``` - -``` text -┌─metric──────────────────────────────────┬──────value─┐ -│ jemalloc.background_thread.run_interval │ 0 │ -│ jemalloc.background_thread.num_runs │ 0 │ -│ jemalloc.background_thread.num_threads │ 0 │ -│ jemalloc.retained │ 422551552 │ -│ jemalloc.mapped │ 1682989056 │ -│ jemalloc.resident │ 1656446976 │ -│ jemalloc.metadata_thp │ 0 │ -│ jemalloc.metadata │ 10226856 │ -│ UncompressedCacheCells │ 0 │ -│ MarkCacheFiles │ 0 │ -└─────────────────────────────────────────┴────────────┘ -``` - -**Смотрите также** - -- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. -- [system.metrics](#system_tables-metrics) — таблица с мгновенно вычисляемыми метриками. -- [system.events](#system_tables-events) — таблица с количеством произошедших событий. -- [system.metric\_log](#system_tables-metric_log) — таблица фиксирующая историю значений метрик из `system.metrics` и `system.events`. - -## system.clusters {#system-clusters} - -Содержит информацию о доступных в конфигурационном файле кластерах и серверах, которые в них входят. -Столбцы: - -``` text -cluster String — имя кластера. -shard_num UInt32 — номер шарда в кластере, начиная с 1. -shard_weight UInt32 — относительный вес шарда при записи данных -replica_num UInt32 — номер реплики в шарде, начиная с 1. -host_name String — хост, указанный в конфигурации. -host_address String — IP-адрес хоста, полученный из DNS. -port UInt16 — порт, на который обращаться для соединения с сервером. -user String — имя пользователя, которого использовать для соединения с сервером. -``` - -## system.columns {#system-columns} - -Содержит информацию о столбцах всех таблиц. - -С помощью этой таблицы можно получить информацию аналогично запросу [DESCRIBE TABLE](../sql_reference/statements/misc.md#misc-describe-table), но для многих таблиц сразу. - -Таблица `system.columns` содержит столбцы (тип столбца указан в скобках): - -- `database` (String) — имя базы данных. -- `table` (String) — имя таблицы. -- `name` (String) — имя столбца. -- `type` (String) — тип столбца. -- `default_kind` (String) — тип выражения (`DEFAULT`, `MATERIALIZED`, `ALIAS`) значения по умолчанию, или пустая строка. -- `default_expression` (String) — выражение для значения по умолчанию или пустая строка. -- `data_compressed_bytes` (UInt64) — размер сжатых данных в байтах. -- `data_uncompressed_bytes` (UInt64) — размер распакованных данных в байтах. -- `marks_bytes` (UInt64) — размер засечек в байтах. -- `comment` (String) — комментарий к столбцу или пустая строка. -- `is_in_partition_key` (UInt8) — флаг, показывающий включение столбца в ключ партиционирования. -- `is_in_sorting_key` (UInt8) — флаг, показывающий включение столбца в ключ сортировки. -- `is_in_primary_key` (UInt8) — флаг, показывающий включение столбца в первичный ключ. -- `is_in_sampling_key` (UInt8) — флаг, показывающий включение столбца в ключ выборки. - -## system.contributors {#system-contributors} - -Содержит информацию о контрибьютерах. Контрибьютеры расположены в таблице в случайном порядке. Порядок определяется заново при каждом запросе. - -Столбцы: - -- `name` (String) — Имя контрибьютера (автора коммита) из git log. - -**Пример** - -``` sql -SELECT * FROM system.contributors LIMIT 10 -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -│ Max Vetrov │ -│ LiuYangkuan │ -│ svladykin │ -│ zamulla │ -│ Šimon Podlipský │ -│ BayoNet │ -│ Ilya Khomutov │ -│ Amy Krishnevsky │ -│ Loud_Scream │ -└──────────────────┘ -``` - -Чтобы найти себя в таблице, выполните запрос: - -``` sql -SELECT * FROM system.contributors WHERE name='Olga Khvostikova' -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -└──────────────────┘ -``` - -## system.databases {#system-databases} - -Таблица содержит один столбец name типа String - имя базы данных. -Для каждой базы данных, о которой знает сервер, будет присутствовать соответствующая запись в таблице. -Эта системная таблица используется для реализации запроса `SHOW DATABASES`. - -## system.detached\_parts {#system_tables-detached_parts} - -Содержит информацию об отсоединённых кусках таблиц семейства [MergeTree](../engines/table_engines/mergetree_family/mergetree.md). Столбец `reason` содержит причину, по которой кусок был отсоединён. Для кусов, отсоединённых пользователем, `reason` содержит пустую строку. -Такие куски могут быть присоединены с помощью [ALTER TABLE ATTACH PARTITION\|PART](../sql_reference/alter/#alter_attach-partition). Остальные столбцы описаны в [system.parts](#system_tables-parts). -Если имя куска некорректно, значения некоторых столбцов могут быть `NULL`. Такие куски могут быть удалены с помощью [ALTER TABLE DROP DETACHED PART](../sql_reference/alter/#alter_drop-detached). - -## system.dictionaries {#system_tables-dictionaries} - -Содержит информацию о [внешних словарях](../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -Столбцы: - -- `database` ([String](../sql_reference/data_types/string.md)) — Имя базы данных, в которой находится словарь, созданный с помощью DDL-запроса. Пустая строка для других словарей. -- `name` ([String](../sql_reference/data_types/string.md)) — [Имя словаря](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md). -- `status` ([Enum8](../sql_reference/data_types/enum.md)) — Статус словаря. Возможные значения: - - `NOT_LOADED` — Словарь не загружен, потому что не использовался. - - `LOADED` — Словарь загружен успешно. - - `FAILED` — Словарь не загружен в результате ошибки. - - `LOADING` — Словарь в процессе загрузки. - - `LOADED_AND_RELOADING` — Словарь загружен успешно, сейчас перезагружается (частые причины: запрос [SYSTEM RELOAD DICTIONARY](../sql_reference/statements/system.md#query_language-system-reload-dictionary), таймаут, изменение настроек словаря). - - `FAILED_AND_RELOADING` — Словарь не загружен в результате ошибки, сейчас перезагружается. -- `origin` ([String](../sql_reference/data_types/string.md)) — Путь к конфигурационному файлу, описывающему словарь. -- `type` ([String](../sql_reference/data_types/string.md)) — Тип размещения словаря. [Хранение словарей в памяти](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md). -- `key` — [Тип ключа](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-key): Числовой ключ ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) или Составной ключ ([String](../sql_reference/data_types/string.md)) — строка вида “(тип 1, тип 2, …, тип n)”. -- `attribute.names` ([Array](../sql_reference/data_types/array.md)([String](../sql_reference/data_types/string.md))) — Массив [имен атрибутов](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes), предоставляемых справочником. -- `attribute.types` ([Array](../sql_reference/data_types/array.md)([String](../sql_reference/data_types/string.md))) — Соответствующий массив [типов атрибутов](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes), предоставляемых справочником. -- `bytes_allocated` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Объем оперативной памяти, используемый словарем. -- `query_count` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Количество запросов с момента загрузки словаря или с момента последней успешной перезагрузки. -- `hit_rate` ([Float64](../sql_reference/data_types/float.md)) — Для cache-словарей — процент закэшированных значений. -- `element_count` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Количество элементов, хранящихся в словаре. -- `load_factor` ([Float64](../sql_reference/data_types/float.md)) — Процент заполнения словаря (для хэшированного словаря — процент заполнения хэш-таблицы). -- `source` ([String](../sql_reference/data_types/string.md)) — Текст, описывающий [источник данных](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md) для словаря. -- `lifetime_min` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Минимальное [время обновления](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md) словаря в памяти, по истечении которого Clickhouse попытается перезагрузить словарь (если задано `invalidate_query`, то только если он изменился). Задается в секундах. -- `lifetime_max` ([UInt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Максимальное [время обновления](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md) словаря в памяти, по истечении которого Clickhouse попытается перезагрузить словарь (если задано `invalidate_query`, то только если он изменился). Задается в секундах. -- `loading_start_time` ([DateTime](../sql_reference/data_types/datetime.md)) — Время начала загрузки словаря. -- `loading_duration` ([Float32](../sql_reference/data_types/float.md)) — Время, затраченное на загрузку словаря. -- `last_exception` ([String](../sql_reference/data_types/string.md)) — Текст ошибки, возникающей при создании или перезагрузке словаря, если словарь не удалось создать. - -**Пример** - -Настройте словарь. - -``` sql -CREATE DICTIONARY dictdb.dict -( - `key` Int64 DEFAULT -1, - `value_default` String DEFAULT 'world', - `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' -) -PRIMARY KEY key -SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) -LIFETIME(MIN 0 MAX 1) -LAYOUT(FLAT()) -``` - -Убедитесь, что словарь загружен. - -``` sql -SELECT * FROM system.dictionaries -``` - -``` text -┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ -│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ -└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ -``` - -## system.events {#system_tables-events} - -Содержит информацию о количестве событий, произошедших в системе. Например, в таблице можно найти, сколько запросов `SELECT` обработано с момента запуска сервера ClickHouse. - -Столбцы: - -- `event` ([String](../sql_reference/data_types/string.md)) — имя события. -- `value` ([UInt64](../sql_reference/data_types/int_uint.md)) — количество произошедших событий. -- `description` ([String](../sql_reference/data_types/string.md)) — описание события. - -**Пример** - -``` sql -SELECT * FROM system.events LIMIT 5 -``` - -``` text -┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ -│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ -│ FileOpen │ 73 │ Number of files opened. │ -│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ -│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ -└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Смотрите также** - -- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — таблица с периодически вычисляемыми метриками. -- [system.metrics](#system_tables-metrics) — таблица с мгновенно вычисляемыми метриками. -- [system.metric\_log](#system_tables-metric_log) — таблица фиксирующая историю значений метрик из `system.metrics` и `system.events`. -- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. - -## system.functions {#system-functions} - -Содержит информацию об обычных и агрегатных функциях. - -Столбцы: - -- `name` (`String`) – Имя функции. -- `is_aggregate` (`UInt8`) – Признак, является ли функция агрегатной. - -## system.graphite\_retentions {#system-graphite-retentions} - -Содержит информацию о том, какие параметры [graphite\_rollup](server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) используются в таблицах с движками [\*GraphiteMergeTree](../engines/table_engines/mergetree_family/graphitemergetree.md). - -Столбцы: - -- `config_name` (String) - Имя параметра, используемого для `graphite_rollup`. -- `regexp` (String) - Шаблон имени метрики. -- `function` (String) - Имя агрегирующей функции. -- `age` (UInt64) - Минимальный возраст данных в секундах. -- `precision` (UInt64) - Точность определения возраста данных в секундах. -- `priority` (UInt16) - Приоритет раздела pattern. -- `is_default` (UInt8) - Является ли раздел pattern дефолтным. -- `Tables.database` (Array(String)) - Массив имён баз данных таблиц, использующих параметр `config_name`. -- `Tables.table` (Array(String)) - Массив имён таблиц, использующих параметр `config_name`. - -## system.merges {#system-merges} - -Содержит информацию о производящихся прямо сейчас слияниях и мутациях кусков для таблиц семейства MergeTree. - -Столбцы: - -- `database String` — Имя базы данных, в которой находится таблица. -- `table String` — Имя таблицы. -- `elapsed Float64` — Время в секундах, прошедшее от начала выполнения слияния. -- `progress Float64` — Доля выполненной работы от 0 до 1. -- `num_parts UInt64` — Количество сливаемых кусков. -- `result_part_name String` — Имя куска, который будет образован в результате слияния. -- `is_mutation UInt8` - Является ли данный процесс мутацией куска. -- `total_size_bytes_compressed UInt64` — Суммарный размер сжатых данных сливаемых кусков. -- `total_size_marks UInt64` — Суммарное количество засечек в сливаемых кусках. -- `bytes_read_uncompressed UInt64` — Количество прочитанных байт, разжатых. -- `rows_read UInt64` — Количество прочитанных строк. -- `bytes_written_uncompressed UInt64` — Количество записанных байт, несжатых. -- `rows_written UInt64` — Количество записанных строк. - -## system.metrics {#system_tables-metrics} - -Содержит метрики, которые могут быть рассчитаны мгновенно или имеют текущее значение. Например, число одновременно обрабатываемых запросов или текущее значение задержки реплики. Эта таблица всегда актуальна. - -Столбцы: - -- `metric` ([String](../sql_reference/data_types/string.md)) — название метрики. -- `value` ([Int64](../sql_reference/data_types/int_uint.md)) — значение метрики. -- `description` ([String](../sql_reference/data_types/string.md)) — описание метрики. - -Список поддержанных метрик смотрите в файле [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp). - -**Пример** - -``` sql -SELECT * FROM system.metrics LIMIT 10 -``` - -``` text -┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 1 │ Number of executing queries │ -│ Merge │ 0 │ Number of executing background merges │ -│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ -│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ -│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ -│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ -│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ -│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ -│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ -│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ -└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Смотрите также** - -- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — таблица с периодически вычисляемыми метриками. -- [system.events](#system_tables-events) — таблица с количеством произошедших событий. -- [system.metric\_log](#system_tables-metric_log) — таблица фиксирующая историю значений метрик из `system.metrics` и `system.events`. -- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. - -## system.metric\_log {#system_tables-metric_log} - -Содержит историю значений метрик из таблиц `system.metrics` и `system.events`, периодически сбрасываемую на диск. -Для включения сбора истории метрик в таблице `system.metric_log` создайте `/etc/clickhouse-server/config.d/metric_log.xml` следующего содержания: - -``` xml - - - system - metric_log
- 7500 - 1000 -
-
-``` - -**Пример** - -``` sql -SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; -``` - -``` text -Row 1: -────── -event_date: 2020-02-18 -event_time: 2020-02-18 07:15:33 -milliseconds: 554 -ProfileEvent_Query: 0 -ProfileEvent_SelectQuery: 0 -ProfileEvent_InsertQuery: 0 -ProfileEvent_FileOpen: 0 -ProfileEvent_Seek: 0 -ProfileEvent_ReadBufferFromFileDescriptorRead: 1 -ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 -ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 -ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 -ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 -ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 -... -CurrentMetric_Query: 0 -CurrentMetric_Merge: 0 -CurrentMetric_PartMutation: 0 -CurrentMetric_ReplicatedFetch: 0 -CurrentMetric_ReplicatedSend: 0 -CurrentMetric_ReplicatedChecks: 0 -... -``` - -**Смотрите также** - -- [system.asynchronous\_metrics](#system_tables-asynchronous_metrics) — таблица с периодически вычисляемыми метриками. -- [system.events](#system_tables-events) — таблица с количеством произошедших событий. -- [system.metrics](#system_tables-metrics) — таблица с мгновенно вычисляемыми метриками. -- [Мониторинг](monitoring.md) — основы мониторинга в ClickHouse. - -## system.numbers {#system-numbers} - -Таблица содержит один столбец с именем number типа UInt64, содержащим почти все натуральные числа, начиная с нуля. -Эту таблицу можно использовать для тестов, а также если вам нужно сделать перебор. -Чтения из этой таблицы не распараллеливаются. - -## system.numbers\_mt {#system-numbers-mt} - -То же самое, что и system.numbers, но чтение распараллеливается. Числа могут возвращаться в произвольном порядке. -Используется для тестов. - -## system.one {#system-one} - -Таблица содержит одну строку с одним столбцом dummy типа UInt8, содержащим значение 0. -Эта таблица используется, если в SELECT запросе не указана секция FROM. -То есть, это - аналог таблицы DUAL, которую можно найти в других СУБД. - -## system.parts {#system_tables-parts} - -Содержит информацию о кусках данных таблиц семейства [MergeTree](../engines/table_engines/mergetree_family/mergetree.md). - -Каждая строка описывает один кусок данных. - -Столбцы: - -- `partition` (`String`) – Имя партиции. Что такое партиция можно узнать из описания запроса [ALTER](../sql_reference/statements/alter.md#sql_reference_queries_alter). - - Форматы: - - - `YYYYMM` для автоматической схемы партиционирования по месяцам. - - `any_string` при партиционировании вручную. - -- `name` (`String`) – имя куска. - -- `active` (`UInt8`) – признак активности. Если кусок активен, то он используется таблицей, в противном случает он будет удален. Неактивные куски остаются после слияний. - -- `marks` (`UInt64`) – количество засечек. Чтобы получить примерное количество строк в куске, умножьте `marks` на гранулированность индекса (обычно 8192). - -- `rows` (`UInt64`) – количество строк. - -- `bytes_on_disk` (`UInt64`) – общий размер всех файлов кусков данных в байтах. - -- `data_compressed_bytes` (`UInt64`) – общий размер сжатой информации в куске данных. Размер всех дополнительных файлов (например, файлов с засечками) не учитывается. - -- `data_uncompressed_bytes` (`UInt64`) – общий размер распакованной информации куска данных. Размер всех дополнительных файлов (например, файлов с засечками) не учитывается. - -- `marks_bytes` (`UInt64`) – размер файла с засечками. - -- `modification_time` (`DateTime`) – время модификации директории с куском данных. Обычно соответствует времени создания куска. - -- `remove_time` (`DateTime`) – время, когда кусок стал неактивным. - -- `refcount` (`UInt32`) – количество мест, в котором кусок используется. Значение больше 2 говорит о том, что кусок участвует в запросах или в слияниях. - -- `min_date` (`Date`) – минимальное значение ключа даты в куске данных. - -- `max_date` (`Date`) – максимальное значение ключа даты в куске данных. - -- `min_time` (`DateTime`) – минимальное значение даты и времени в куске данных. - -- `max_time`(`DateTime`) – максимальное значение даты и времени в куске данных. - -- `partition_id` (`String`) – ID партиции. - -- `min_block_number` (`UInt64`) – минимальное число кусков, из которых состоит текущий после слияния. - -- `max_block_number` (`UInt64`) – максимальное число кусков, из которых состоит текущий после слияния. - -- `level` (`UInt32`) - глубина дерева слияний. Если слияний не было, то `level=0`. - -- `data_version` (`UInt64`) – число, которое используется для определения того, какие мутации необходимо применить к куску данных (мутации с версией большей, чем `data_version`). - -- `primary_key_bytes_in_memory` (`UInt64`) – объём памяти (в байтах), занимаемой значениями первичных ключей. - -- `primary_key_bytes_in_memory_allocated` (`UInt64`) – объём памяти (в байтах) выделенный для размещения первичных ключей. - -- `is_frozen` (`UInt8`) – Признак, показывающий существование бэкапа партиции. 1, бэкап есть. 0, бэкапа нет. Смотрите раздел [FREEZE PARTITION](../sql_reference/statements/alter.md#alter_freeze-partition). - -- `database` (`String`) – имя базы данных. - -- `table` (`String`) – имя таблицы. - -- `engine` (`String`) – имя движка таблицы, без параметров. - -- `path` (`String`) – абсолютный путь к папке с файлами кусков данных. - -- `disk` (`String`) – имя диска, на котором находится кусок данных. - -- `hash_of_all_files` (`String`) – значение [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) для сжатых файлов. - -- `hash_of_uncompressed_files` (`String`) – значение [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) несжатых файлов (файлы с засечками, первичным ключом и пр.) - -- `uncompressed_hash_of_compressed_files` (`String`) – значение [sipHash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) данных в сжатых файлах как если бы они были разжатыми. - -- `bytes` (`UInt64`) – алиас для `bytes_on_disk`. - -- `marks_size` (`UInt64`) – алиас для `marks_bytes`. - -## system.part\_log {#system_tables-part-log} - -Системная таблица `system.part_log` создается только в том случае, если задана серверная настройка [part\_log](server_configuration_parameters/settings.md#server_configuration_parameters-part-log). - -Содержит информацию о всех событиях, произошедших с [кусками данных](../engines/table_engines/mergetree_family/custom_partitioning_key.md) таблиц семейства [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) (например, события добавления, удаления или слияния данных). - -Столбцы: - -- `event_type` (Enum) — тип события. Столбец может содержать одно из следующих значений: - - `NEW_PART` — вставка нового куска. - - `MERGE_PARTS` — слияние кусков. - - `DOWNLOAD_PART` — загрузка с реплики. - - `REMOVE_PART` — удаление или отсоединение из таблицы с помощью [DETACH PARTITION](../sql_reference/statements/alter.md#alter_detach-partition). - - `MUTATE_PART` — изменение куска. - - `MOVE_PART` — перемещение куска между дисками. -- `event_date` (Date) — дата события. -- `event_time` (DateTime) — время события. -- `duration_ms` (UInt64) — длительность. -- `database` (String) — имя базы данных, в которой находится кусок. -- `table` (String) — имя таблицы, в которой находится кусок. -- `part_name` (String) — имя куска. -- `partition_id` (String) — идентификатор партиции, в которую был добавлен кусок. В столбце будет значение ‘all’, если таблица партициируется по выражению `tuple()`. -- `rows` (UInt64) — число строк в куске. -- `size_in_bytes` (UInt64) — размер куска данных в байтах. -- `merged_from` (Array(String)) — массив имён кусков, из которых образован текущий кусок в результате слияния (также столбец заполняется в случае скачивания уже смерженного куска). -- `bytes_uncompressed` (UInt64) — количество прочитанных разжатых байт. -- `read_rows` (UInt64) — сколько было прочитано строк при слиянии кусков. -- `read_bytes` (UInt64) — сколько было прочитано байт при слиянии кусков. -- `error` (UInt16) — код ошибки, возникшей при текущем событии. -- `exception` (String) — текст ошибки. - -Системная таблица `system.part_log` будет создана после первой вставки данных в таблицу `MergeTree`. - -## system.processes {#system_tables-processes} - -Используется для реализации запроса `SHOW PROCESSLIST`. - -Столбцы: - -- `user` (String) – пользователь, инициировавший запрос. При распределённом выполнении запросы отправляются на удалённые серверы от имени пользователя `default`. Поле содержит имя пользователя для конкретного запроса, а не для запроса, который иницировал этот запрос. -- `address` (String) – IP-адрес, с которого пришёл запрос. При распределённой обработке запроса аналогично. Чтобы определить откуда запрос пришел изначально, необходимо смотреть таблицу `system.processes` на сервере-источнике запроса. -- `elapsed` (Float64) – время в секундах с начала обработки запроса. -- `rows_read` (UInt64) – количество прочитанных строк. При распределённой обработке запроса на сервере-инициаторе запроса представляет собой сумму по всем удалённым серверам. -- `bytes_read` (UInt64) – количество прочитанных из таблиц байт, в несжатом виде. При распределённой обработке запроса на сервере-инициаторе запроса представляет собой сумму по всем удалённым серверам. -- `total_rows_approx` (UInt64) – приблизительная оценка общего количества строк, которые должны быть прочитаны. При распределённой обработке запроса, на сервере-инициаторе запроса, представляет собой сумму по всем удалённым серверам. Может обновляться в процессе выполнения запроса, когда становятся известны новые источники для обработки. -- `memory_usage` (UInt64) – потребление памяти запросом. Может не учитывать некоторые виды выделенной памяти. Смотрите описание настройки [max\_memory\_usage](../operations/settings/query_complexity.md#settings_max_memory_usage). -- `query` (String) – текст запроса. Для запросов `INSERT` не содержит встаявляемые данные. -- `query_id` (String) – идентификатор запроса, если был задан. - -## system.query\_log {#system_tables-query_log} - -Содержит информацию о выполнении запросов. Для каждого запроса вы можете увидеть время начала обработки, продолжительность обработки, сообщения об ошибках и другую информацию. - -!!! note "Внимание" - Таблица не содержит входных данных для запросов `INSERT`. - -ClickHouse создаёт таблицу только в том случае, когда установлен конфигурационный параметр сервера [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log). Параметр задаёт правила ведения лога, такие как интервал логирования или имя таблицы, в которую будут логгироваться запросы. - -Чтобы включить логирование, задайте значение параметра [log\_queries](settings/settings.md#settings-log-queries) равным 1. Подробности смотрите в разделе [Настройки](settings/settings.md). - -Таблица `system.query_log` содержит информацию о двух видах запросов: - -1. Первоначальные запросы, которые были выполнены непосредственно клиентом. -2. Дочерние запросы, инициированные другими запросами (для выполнения распределенных запросов). Для дочерних запросов информация о первоначальном запросе содержится в столбцах `initial_*`. - -Столбцы: - -- `type` (`Enum8`) — тип события, произошедшего при выполнении запроса. Значения: - - `'QueryStart' = 1` — успешное начало выполнения запроса. - - `'QueryFinish' = 2` — успешное завершение выполнения запроса. - - `'ExceptionBeforeStart' = 3` — исключение перед началом обработки запроса. - - `'ExceptionWhileProcessing' = 4` — исключение во время обработки запроса. -- `event_date` (Date) — дата начала запроса. -- `event_time` (DateTime) — время начала запроса. -- `query_start_time` (DateTime) — время начала обработки запроса. -- `query_duration_ms` (UInt64) — длительность обработки запроса. -- `read_rows` (UInt64) — количество прочитанных строк. -- `read_bytes` (UInt64) — количество прочитанных байтов. -- `written_rows` (UInt64) — количество записанных строк для запросов `INSERT`. Для других запросов, значение столбца 0. -- `written_bytes` (UInt64) — объём записанных данных в байтах для запросов `INSERT`. Для других запросов, значение столбца 0. -- `result_rows` (UInt64) — количество строк в результате. -- `result_bytes` (UInt64) — объём результата в байтах. -- `memory_usage` (UInt64) — потребление RAM запросом. -- `query` (String) — текст запроса. -- `exception` (String) — сообщение исключения, если запрос завершился по исключению. -- `stack_trace` (String) — трассировка (список функций, последовательно вызванных перед ошибкой). Пустая строка, если запрос успешно завершен. -- `is_initial_query` (UInt8) — вид запроса. Возможные значения: - - 1 — запрос был инициирован клиентом. - - 0 — запрос был инициирован другим запросом при распределенном запросе. -- `user` (String) — пользователь, запустивший текущий запрос. -- `query_id` (String) — ID запроса. -- `address` (IPv6) — IP адрес, с которого пришел запрос. -- `port` (UInt16) — порт, с которого клиент сделал запрос -- `initial_user` (String) — пользователь, запустивший первоначальный запрос (для распределенных запросов). -- `initial_query_id` (String) — ID родительского запроса. -- `initial_address` (IPv6) — IP адрес, с которого пришел родительский запрос. -- `initial_port` (UInt16) — порт, с которого клиент сделал родительский запрос. -- `interface` (UInt8) — интерфейс, с которого ушёл запрос. Возможные значения: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — имя пользователя в OS, который запустил [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — имя сервера, с которого присоединился [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. -- `client_name` (String) — [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. -- `client_revision` (UInt32) — ревизия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `client_version_major` (UInt32) — старшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `client_version_minor` (UInt32) — младшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `client_version_patch` (UInt32) — патч [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `http_method` (UInt8) — HTTP метод, инициировавший запрос. Возможные значения: - - 0 — запрос запущен с интерфейса TCP. - - 1 — `GET`. - - 2 — `POST`. -- `http_user_agent` (String) — HTTP заголовок `UserAgent`. -- `quota_key` (String) — «ключ квоты» из настроек [квот](quotas.md) (см. `keyed`). -- `revision` (UInt32) — ревизия ClickHouse. -- `thread_numbers` (Array(UInt32)) — количество потоков, участвующих в обработке запросов. -- `ProfileEvents.Names` (Array(String)) — Счетчики для изменения различных метрик. Описание метрик можно получить из таблицы [system.events](#system_tables-events)(\#system\_tables-events -- `ProfileEvents.Values` (Array(UInt64)) — метрики, перечисленные в столбце `ProfileEvents.Names`. -- `Settings.Names` (Array(String)) — имена настроек, которые меняются, когда клиент выполняет запрос. Чтобы разрешить логирование изменений настроек, установите параметр `log_query_settings` равным 1. -- `Settings.Values` (Array(String)) — Значения настроек, которые перечислены в столбце `Settings.Names`. - -Каждый запрос создаёт одну или две строки в таблице `query_log`, в зависимости от статуса запроса: - -1. Если запрос выполнен успешно, создаются два события типа 1 и 2 (смотрите столбец `type`). -2. Если во время обработки запроса произошла ошибка, создаются два события с типами 1 и 4. -3. Если ошибка произошла до запуска запроса, создается одно событие с типом 3. - -По умолчанию, строки добавляются в таблицу логирования с интервалом в 7,5 секунд. Можно задать интервал в конфигурационном параметре сервера [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) (смотрите параметр `flush_interval_milliseconds`). Чтобы принудительно записать логи из буффера памяти в таблицу, используйте запрос `SYSTEM FLUSH LOGS`. - -Если таблицу удалить вручную, она пересоздастся автоматически «на лету». При этом все логи на момент удаления таблицы будут удалены. - -!!! note "Примечание" - Срок хранения логов не ограничен. Логи не удаляются из таблицы автоматически. Вам необходимо самостоятельно организовать удаление устаревших логов. - -Можно указать произвольный ключ партиционирования для таблицы `system.query_log` в конфигурации [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) (параметр `partition_by`). - -## system.query\_log {#system_tables-query_log} - -Contains information about execution of queries. For each query, you can see processing start time, duration of processing, error messages and other information. - -!!! note "Note" - The table doesn’t contain input data for `INSERT` queries. - -ClickHouse creates this table only if the [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server parameter is specified. This parameter sets the logging rules, such as the logging interval or the name of the table the queries will be logged in. - -To enable query logging, set the [log\_queries](settings/settings.md#settings-log-queries) parameter to 1. For details, see the [Settings](settings/settings.md) section. - -The `system.query_log` table registers two kinds of queries: - -1. Initial queries that were run directly by the client. -2. Child queries that were initiated by other queries (for distributed query execution). For these types of queries, information about the parent queries is shown in the `initial_*` columns. - -Columns: - -- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: - - `'QueryStart' = 1` — Successful start of query execution. - - `'QueryFinish' = 2` — Successful end of query execution. - - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. - - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. -- `event_date` (Date) — Query starting date. -- `event_time` (DateTime) — Query starting time. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0. -- `written_bytes` (UInt64) — For `INSERT` queries, the number of written bytes. For other queries, the column value is 0. -- `result_rows` (UInt64) — Number of rows in the result. -- `result_bytes` (UInt64) — Number of bytes in the result. -- `memory_usage` (UInt64) — Memory consumption by the query. -- `query` (String) — Query string. -- `exception` (String) — Exception message. -- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS’s username who runs [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-client](../interfaces/cli.md) or another TCP client is run. -- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) or another TCP client name. -- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md) or another TCP client. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) or another TCP client version. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` method was used. - - 2 — `POST` method was used. -- `http_user_agent` (String) — The `UserAgent` header passed in the HTTP request. -- `quota_key` (String) — The «quota key» specified in the [quotas](quotas.md) setting (see `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [system.events](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` column. -- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parameter to 1. -- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` column. - -Each query creates one or two rows in the `query_log` table, depending on the status of the query: - -1. If the query execution is successful, two events with types 1 and 2 are created (see the `type` column). -2. If an error occurred during query processing, two events with types 1 and 4 are created. -3. If an error occurred before launching the query, a single event with type 3 is created. - -By default, logs are added to the table at intervals of 7.5 seconds. You can set this interval in the [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server setting (see the `flush_interval_milliseconds` parameter). To flush the logs forcibly from the memory buffer into the table, use the `SYSTEM FLUSH LOGS` query. - -When the table is deleted manually, it will be automatically created on the fly. Note that all the previous logs will be deleted. - -!!! note "Note" - The storage period for logs is unlimited. Logs aren’t automatically deleted from the table. You need to organize the removal of outdated logs yourself. - -You can specify an arbitrary partitioning key for the `system.query_log` table in the [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) server setting (see the `partition_by` parameter). -\#\# system.query\_thread\_log {\#system\_tables-query-thread-log} - -Содержит информацию о каждом потоке выполняемых запросов. - -ClickHouse создаёт таблицу только в том случае, когда установлен конфигурационный параметр сервера [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log). Параметр задаёт правила ведения лога, такие как интервал логирования или имя таблицы, в которую будут логгироваться запросы. - -Чтобы включить логирование, задайте значение параметра [log\_query\_threads](settings/settings.md#settings-log-query-threads) равным 1. Подробности смотрите в разделе [Настройки](settings/settings.md). - -Столбцы: - -- `event_date` (Date) — дата завершения выполнения запроса потоком. -- `event_time` (DateTime) — дата и время завершения выполнения запроса потоком. -- `query_start_time` (DateTime) — время начала обработки запроса. -- `query_duration_ms` (UInt64) — длительность обработки запроса в миллисекундах. -- `read_rows` (UInt64) — количество прочитанных строк. -- `read_bytes` (UInt64) — количество прочитанных байтов. -- `written_rows` (UInt64) — количество записанных строк для запросов `INSERT`. Для других запросов, значение столбца 0. -- `written_bytes` (UInt64) — объём записанных данных в байтах для запросов `INSERT`. Для других запросов, значение столбца 0. -- `memory_usage` (Int64) — разница между выделенной и освобождённой памятью в контексте потока. -- `peak_memory_usage` (Int64) — максимальная разница между выделенной и освобождённой памятью в контексте потока. -- `thread_name` (String) — Имя потока. -- `thread_id` (UInt64) — tid (ID потока операционной системы). -- `master_thread_id` (UInt64) — tid (ID потока операционной системы) главного потока. -- `query` (String) — текст запроса. -- `is_initial_query` (UInt8) — вид запроса. Возможные значения: - - 1 — запрос был инициирован клиентом. - - 0 — запрос был инициирован другим запросом при распределенном запросе. -- `user` (String) — пользователь, запустивший текущий запрос. -- `query_id` (String) — ID запроса. -- `address` (IPv6) — IP адрес, с которого пришел запрос. -- `port` (UInt16) — порт, с которого пришел запрос. -- `initial_user` (String) — пользователь, запустивший первоначальный запрос (для распределенных запросов). -- `initial_query_id` (String) — ID родительского запроса. -- `initial_address` (IPv6) — IP адрес, с которого пришел родительский запрос. -- `initial_port` (UInt16) — порт, пришел родительский запрос. -- `interface` (UInt8) — интерфейс, с которого ушёл запрос. Возможные значения: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — имя пользователя в OS, который запустил [clickhouse-client](../interfaces/cli.md). -- `client_hostname` (String) — hostname клиентской машины, с которой присоединился [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. -- `client_name` (String) — [clickhouse-client](../interfaces/cli.md) или другой TCP клиент. -- `client_revision` (UInt32) — ревизия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `client_version_major` (UInt32) — старшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `client_version_minor` (UInt32) — младшая версия [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `client_version_patch` (UInt32) — патч [clickhouse-client](../interfaces/cli.md) или другого TCP клиента. -- `http_method` (UInt8) — HTTP метод, инициировавший запрос. Возможные значения: - - 0 — запрос запущен с интерфейса TCP. - - 1 — `GET`. - - 2 — `POST`. -- `http_user_agent` (String) — HTTP заголовок `UserAgent`. -- `quota_key` (String) — «ключ квоты» из настроек [квот](quotas.md) (см. `keyed`). -- `revision` (UInt32) — ревизия ClickHouse. -- `ProfileEvents.Names` (Array(String)) — Счетчики для изменения различных метрик для данного потока. Описание метрик можно получить из таблицы [system.events](#system_tables-events)(\#system\_tables-events -- `ProfileEvents.Values` (Array(UInt64)) — метрики для данного потока, перечисленные в столбце `ProfileEvents.Names`. - -По умолчанию, строки добавляются в таблицу логирования с интервалом в 7,5 секунд. Можно задать интервал в конфигурационном параметре сервера [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) (смотрите параметр `flush_interval_milliseconds`). Чтобы принудительно записать логи из буффера памяти в таблицу, используйте запрос `SYSTEM FLUSH LOGS`. - -Если таблицу удалить вручную, она пересоздастся автоматически «на лету». При этом все логи на момент удаления таблицы будут удалены. - -!!! note "Примечание" - Срок хранения логов не ограничен. Логи не удаляются из таблицы автоматически. Вам необходимо самостоятельно организовать удаление устаревших логов. - -Можно указать произвольный ключ партиционирования для таблицы `system.query_log` в конфигурации [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) (параметр `partition_by`). - -## system.trace\_log {#system_tables-trace_log} - -Contains stack traces collected by the sampling query profiler. - -ClickHouse creates this table when the [trace\_log](server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) server configuration section is set. Also the [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) and [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) settings should be set. - -To analyze logs, use the `addressToLine`, `addressToSymbol` and `demangle` introspection functions. - -Columns: - -- `event_date`([Date](../sql_reference/data_types/date.md)) — Date of sampling moment. - -- `event_time`([DateTime](../sql_reference/data_types/datetime.md)) — Timestamp of sampling moment. - -- `revision`([UInt32](../sql_reference/data_types/int_uint.md)) — ClickHouse server build revision. - - When connecting to server by `clickhouse-client`, you see the string similar to `Connected to ClickHouse server version 19.18.1 revision 54429.`. This field contains the `revision`, but not the `version` of a server. - -- `timer_type`([Enum8](../sql_reference/data_types/enum.md)) — Timer type: - - - `Real` represents wall-clock time. - - `CPU` represents CPU time. - -- `thread_number`([UInt32](../sql_reference/data_types/int_uint.md)) — Thread identifier. - -- `query_id`([String](../sql_reference/data_types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) system table. - -- `trace`([Array(UInt64)](../sql_reference/data_types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. - -**Example** - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-15 -event_time: 2019-11-15 15:09:38 -revision: 54428 -timer_type: Real -thread_number: 48 -query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 -trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] -``` - -## system.replicas {#system_tables-replicas} - -Содержит информацию и статус для реплицируемых таблиц, расположенных на локальном сервере. -Эту таблицу можно использовать для мониторинга. Таблица содержит по строчке для каждой Replicated\*-таблицы. - -Пример: - -``` sql -SELECT * -FROM system.replicas -WHERE table = 'visits' -FORMAT Vertical -``` - -``` text -Row 1: -────── -database: merge -table: visits -engine: ReplicatedCollapsingMergeTree -is_leader: 1 -can_become_leader: 1 -is_readonly: 0 -is_session_expired: 0 -future_parts: 1 -parts_to_check: 0 -zookeeper_path: /clickhouse/tables/01-06/visits -replica_name: example01-06-1.yandex.ru -replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru -columns_version: 9 -queue_size: 1 -inserts_in_queue: 0 -merges_in_queue: 1 -part_mutations_in_queue: 0 -queue_oldest_time: 2020-02-20 08:34:30 -inserts_oldest_time: 0000-00-00 00:00:00 -merges_oldest_time: 2020-02-20 08:34:30 -part_mutations_oldest_time: 0000-00-00 00:00:00 -oldest_part_to_get: -oldest_part_to_merge_to: 20200220_20284_20840_7 -oldest_part_to_mutate_to: -log_max_index: 596273 -log_pointer: 596274 -last_queue_update: 2020-02-20 08:34:32 -absolute_delay: 0 -total_replicas: 2 -active_replicas: 2 -``` - -Столбцы: - -- `database` (`String`) - имя БД. -- `table` (`String`) - имя таблицы. -- `engine` (`String`) - имя движка таблицы. -- `is_leader` (`UInt8`) - является ли реплика лидером. - В один момент времени, не более одной из реплик является лидером. Лидер отвечает за выбор фоновых слияний, которые следует произвести. - Замечу, что запись можно осуществлять на любую реплику (доступную и имеющую сессию в ZK), независимо от лидерства. -- `can_become_leader` (`UInt8`) - может ли реплика быть выбрана лидером. -- `is_readonly` (`UInt8`) - находится ли реплика в режиме «только для чтения» - Этот режим включается, если в конфиге нет секции с ZK; если при переинициализации сессии в ZK произошла неизвестная ошибка; во время переинициализации сессии с ZK. -- `is_session_expired` (`UInt8`) - истекла ли сессия с ZK. В основном, то же самое, что и `is_readonly`. -- `future_parts` (`UInt32`) - количество кусков с данными, которые появятся в результате INSERT-ов или слияний, которых ещё предстоит сделать -- `parts_to_check` (`UInt32`) - количество кусков с данными в очереди на проверку. Кусок помещается в очередь на проверку, если есть подозрение, что он может быть битым. -- `zookeeper_path` (`String`) - путь к данным таблицы в ZK. -- `replica_name` (`String`) - имя реплики в ZK; разные реплики одной таблицы имеют разное имя. -- `replica_path` (`String`) - путь к данным реплики в ZK. То же самое, что конкатенация zookeeper\_path/replicas/replica\_path. -- `columns_version` (`Int32`) - номер версии структуры таблицы. Обозначает, сколько раз был сделан ALTER. Если на репликах разные версии, значит некоторые реплики сделали ещё не все ALTER-ы. -- `queue_size` (`UInt32`) - размер очереди действий, которые предстоит сделать. К действиям относятся вставки блоков данных, слияния, и некоторые другие действия. Как правило, совпадает с future\_parts. -- `inserts_in_queue` (`UInt32`) - количество вставок блоков данных, которые предстоит сделать. Обычно вставки должны быстро реплицироваться. Если величина большая - значит что-то не так. -- `merges_in_queue` (`UInt32`) - количество слияний, которые предстоит сделать. Бывают длинные слияния - то есть, это значение может быть больше нуля продолжительное время. -- `part_mutations_in_queue` (`UInt32`) - количество мутаций, которые предстоит сделать. -- `queue_oldest_time` (`DateTime`) - если `queue_size` больше 0, показывает, когда была добавлена в очередь самая старая операция. -- `inserts_oldest_time` (`DateTime`) - см. `queue_oldest_time`. -- `merges_oldest_time` (`DateTime`) - см. `queue_oldest_time`. -- `part_mutations_oldest_time` (`DateTime`) - см. `queue_oldest_time`. - -Следующие 4 столбца имеют ненулевое значение только если активна сессия с ZK. - -- `log_max_index` (`UInt64`) - максимальный номер записи в общем логе действий. -- `log_pointer` (`UInt64`) - максимальный номер записи из общего лога действий, которую реплика скопировала в свою очередь для выполнения, плюс единица. Если log\_pointer сильно меньше log\_max\_index, значит что-то не так. -- `last_queue_update` (`DateTime`) - When the queue was updated last time. -- `absolute_delay` (`UInt64`) - How big lag in seconds the current replica has. -- `total_replicas` (`UInt8`) - общее число известных реплик этой таблицы. -- `active_replicas` (`UInt8`) - число реплик этой таблицы, имеющих сессию в ZK; то есть, число работающих реплик. - -Если запрашивать все столбцы, то таблица может работать слегка медленно, так как на каждую строчку делается несколько чтений из ZK. -Если не запрашивать последние 4 столбца (log\_max\_index, log\_pointer, total\_replicas, active\_replicas), то таблица работает быстро. - -Например, так можно проверить, что всё хорошо: - -``` sql -SELECT - database, - table, - is_leader, - is_readonly, - is_session_expired, - future_parts, - parts_to_check, - columns_version, - queue_size, - inserts_in_queue, - merges_in_queue, - log_max_index, - log_pointer, - total_replicas, - active_replicas -FROM system.replicas -WHERE - is_readonly - OR is_session_expired - OR future_parts > 20 - OR parts_to_check > 10 - OR queue_size > 20 - OR inserts_in_queue > 10 - OR log_max_index - log_pointer > 10 - OR total_replicas < 2 - OR active_replicas < total_replicas -``` - -Если этот запрос ничего не возвращает - значит всё хорошо. - -## system.settings {#system-tables-system-settings} - -Содержит информацию о сессионных настройках для текущего пользователя. - -Столбцы: - -- `name` ([String](../sql_reference/data_types/string.md)) — имя настройки. -- `value` ([String](../sql_reference/data_types/string.md)) — значение настройки. -- `changed` ([UInt8](../sql_reference/data_types/int_uint.md#uint-ranges)) — показывает, изменена ли настройка по отношению к значению по умолчанию. -- `description` ([String](../sql_reference/data_types/string.md)) — краткое описание настройки. -- `min` ([Nullable](../sql_reference/data_types/nullable.md)([String](../sql_reference/data_types/string.md))) — минимальное значение настройки, если задано [ограничение](settings/constraints_on_settings.md#constraints-on-settings). Если нет, то поле содержит [NULL](../sql_reference/syntax.md#null-literal). -- `max` ([Nullable](../sql_reference/data_types/nullable.md)([String](../sql_reference/data_types/string.md))) — максимальное значение настройки, если задано [ограничение](settings/constraints_on_settings.md#constraints-on-settings). Если нет, то поле содержит [NULL](../sql_reference/syntax.md#null-literal). -- `readonly` ([UInt8](../sql_reference/data_types/int_uint.md#uint-ranges)) — Показывает, может ли пользователь изменять настройку: - - `0` — Текущий пользователь может изменять настройку. - - `1` — Текущий пользователь не может изменять настройку. - -**Пример** - -Пример показывает как получить информацию о настройках, имена которых содержат `min_i`. - -``` sql -SELECT * -FROM system.settings -WHERE name LIKE '%min_i%' -``` - -``` text -┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ -│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ -``` - -Использование `WHERE changed` может быть полезно, например, если необходимо проверить: - -- Что настройки корректно загрузились из конфигурационного файла и используются. -- Настройки, изменённые в текущей сессии. - - - -``` sql -SELECT * FROM system.settings WHERE changed AND name='load_balancing' -``` - -**Cм. также** - -- [Настройки](settings/index.md#settings) -- [Разрешения для запросов](settings/permissions_for_queries.md#settings_readonly) -- [Ограничения для значений настроек](settings/constraints_on_settings.md) - -## system.table\_engines {#system.table_engines} - -``` text -┌─name───────────────────┬─value───────┬─changed─┐ -│ max_threads │ 8 │ 1 │ -│ use_uncompressed_cache │ 0 │ 1 │ -│ load_balancing │ random │ 1 │ -│ max_memory_usage │ 10000000000 │ 1 │ -└────────────────────────┴─────────────┴─────────┘ -``` - -## system.table\_engines {#system-table-engines} - -Содержит информацию про движки таблиц, поддерживаемые сервером, а также об их возможностях. - -Эта таблица содержит следующие столбцы (тип столбца показан в скобках): - -- `name` (String) — имя движка. -- `supports_settings` (UInt8) — флаг, показывающий поддержку секции `SETTINGS`. -- `supports_skipping_indices` (UInt8) — флаг, показывающий поддержку [индексов пропуска данных](table_engines/mergetree/#table_engine-mergetree-data_skipping-indexes). -- `supports_ttl` (UInt8) — флаг, показывающий поддержку [TTL](table_engines/mergetree/#table_engine-mergetree-ttl). -- `supports_sort_order` (UInt8) — флаг, показывающий поддержку секций `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` и `SAMPLE_BY`. -- `supports_replication` (UInt8) — флаг, показвыающий поддержку [репликации](table_engines/replication/). -- `supports_duduplication` (UInt8) — флаг, показывающий наличие в движке дедупликации данных. - -Пример: - -``` sql -SELECT * -FROM system.table_engines -WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') -``` - -``` text -┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ -│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ -│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ -│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ -└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ -``` - -**Смотрите также** - -- [Секции движка](../engines/table_engines/mergetree_family/mergetree.md#mergetree-query-clauses) семейства MergeTree -- [Настройки](../engines/table_engines/integrations/kafka.md#table_engine-kafka-creating-a-table) Kafka -- [Настройки](../engines/table_engines/special/join.md#join-limitations-and-settings) Join - -## system.tables {#system-tables} - -Содержит метаданные каждой таблицы, о которой знает сервер. Отсоединённые таблицы не отображаются в `system.tables`. - -Эта таблица содержит следующие столбцы (тип столбца показан в скобках): - -- `database String` — имя базы данных, в которой находится таблица. -- `name` (String) — имя таблицы. -- `engine` (String) — движок таблицы (без параметров). -- `is_temporary` (UInt8) — флаг, указывающий на то, временная это таблица или нет. -- `data_path` (String) — путь к данным таблицы в файловой системе. -- `metadata_path` (String) — путь к табличным метаданным в файловой системе. -- `metadata_modification_time` (DateTime) — время последней модификации табличных метаданных. -- `dependencies_database` (Array(String)) — зависимости базы данных. -- `dependencies_table` (Array(String)) — табличные зависимости (таблицы [MaterializedView](../engines/table_engines/special/materializedview.md), созданные на базе текущей таблицы). -- `create_table_query` (String) — запрос, которым создавалась таблица. -- `engine_full` (String) — параметры табличного движка. -- `partition_key` (String) — ключ партиционирования таблицы. -- `sorting_key` (String) — ключ сортировки таблицы. -- `primary_key` (String) - первичный ключ таблицы. -- `sampling_key` (String) — ключ сэмплирования таблицы. - -Таблица `system.tables` используется при выполнении запроса `SHOW TABLES`. - -## system.zookeeper {#system-zookeeper} - -Таблицы не существует, если ZooKeeper не сконфигурирован. Позволяет читать данные из ZooKeeper кластера, описанного в конфигурации. -В запросе обязательно в секции WHERE должно присутствовать условие на равенство path - путь в ZooKeeper, для детей которого вы хотите получить данные. - -Запрос `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` выведет данные по всем детям узла `/clickhouse`. -Чтобы вывести данные по всем узлам в корне, напишите path = ‘/’. -Если узла, указанного в path не существует, то будет брошено исключение. - -Столбцы: - -- `name String` — Имя узла. -- `path String` — Путь к узлу. -- `value String` — Значение узла. -- `dataLength Int32` — Размер значения. -- `numChildren Int32` — Количество детей. -- `czxid Int64` — Идентификатор транзакции, в которой узел был создан. -- `mzxid Int64` — Идентификатор транзакции, в которой узел был последний раз изменён. -- `pzxid Int64` — Идентификатор транзакции, последний раз удаливший или добавивший детей. -- `ctime DateTime` — Время создания узла. -- `mtime DateTime` — Время последней модификации узла. -- `version Int32` — Версия узла - количество раз, когда узел был изменён. -- `cversion Int32` — Количество добавлений или удалений детей. -- `aversion Int32` — Количество изменений ACL. -- `ephemeralOwner Int64` — Для эфемерных узлов - идентификатор сессии, которая владеет этим узлом. - -Пример: - -``` sql -SELECT * -FROM system.zookeeper -WHERE path = '/clickhouse/tables/01-08/visits/replicas' -FORMAT Vertical -``` - -``` text -Row 1: -────── -name: example01-08-1.yandex.ru -value: -czxid: 932998691229 -mzxid: 932998691229 -ctime: 2015-03-27 16:49:51 -mtime: 2015-03-27 16:49:51 -version: 0 -cversion: 47 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021031383 -path: /clickhouse/tables/01-08/visits/replicas - -Row 2: -────── -name: example01-08-2.yandex.ru -value: -czxid: 933002738135 -mzxid: 933002738135 -ctime: 2015-03-27 16:57:01 -mtime: 2015-03-27 16:57:01 -version: 0 -cversion: 37 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021252247 -path: /clickhouse/tables/01-08/visits/replicas -``` - -## system.mutations {#system_tables-mutations} - -Таблица содержит информацию о ходе выполнения [мутаций](../sql_reference/statements/alter.md#alter-mutations) MergeTree-таблиц. Каждой команде мутации соответствует одна строка. В таблице есть следующие столбцы: - -**database**, **table** - имя БД и таблицы, к которой была применена мутация. - -**mutation\_id** - ID запроса. Для реплицированных таблиц эти ID соответствуют именам записей в директории `/mutations/` в ZooKeeper, для нереплицированных - именам файлов в директории с данными таблицы. - -**command** - Команда мутации (часть запроса после `ALTER TABLE [db.]table`). - -**create\_time** - Время создания мутации. - -**block\_numbers.partition\_id**, **block\_numbers.number** - Nested-столбец. Для мутаций реплицированных таблиц для каждой партиции содержит номер блока, полученный этой мутацией (в каждой партиции будут изменены только куски, содержащие блоки с номерами, меньшими номера, полученного мутацией в этой партиции). Для нереплицированных таблиц нумерация блоков сквозная по партициям, поэтому столбец содержит одну запись с единственным номером блока, полученным мутацией. - -**parts\_to\_do** - Количество кусков таблицы, которые ещё предстоит изменить. - -**is\_done** - Завершена ли мутация. Замечание: даже если `parts_to_do = 0`, для реплицированной таблицы возможна ситуация, когда мутация ещё не завершена из-за долго выполняющейся вставки, которая добавляет данные, которые нужно будет мутировать. - -Если во время мутации какого-либо куска возникли проблемы, заполняются следующие столбцы: - -**latest\_failed\_part** - Имя последнего куска, мутация которого не удалась. - -**latest\_fail\_time** — время последней ошибки мутации. - -**latest\_fail\_reason** — причина последней ошибки мутации. - -## system.disks {#system_tables-disks} - -Cодержит информацию о дисках, заданных в [конфигурации сервера](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Столбцы: - -- `name` ([String](../sql_reference/data_types/string.md)) — имя диска в конфигурации сервера. -- `path` ([String](../sql_reference/data_types/string.md)) — путь к точке монтирования в файловой системе. -- `free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — свободное место на диске в байтах. -- `total_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — объём диска в байтах. -- `keep_free_space` ([UInt64](../sql_reference/data_types/int_uint.md)) — место, которое должно остаться свободным на диске в байтах. Задаётся значением параметра `keep_free_space_bytes` конфигурации дисков. - -## system.storage\_policies {#system_tables-storage_policies} - -Содержит информацию о политиках хранения и томах, заданных в [конфигурации сервера](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Столбцы: - -- `policy_name` ([String](../sql_reference/data_types/string.md)) — имя политики хранения. -- `volume_name` ([String](../sql_reference/data_types/string.md)) — имя тома, который содержится в политике хранения. -- `volume_priority` ([UInt64](../sql_reference/data_types/int_uint.md)) — порядковый номер тома согласно конфигурации. -- `disks` ([Array(String)](../sql_reference/data_types/array.md)) — имена дисков, содержащихся в политике хранения. -- `max_data_part_size` ([UInt64](../sql_reference/data_types/int_uint.md)) — максимальный размер куска данных, который может храниться на дисках тома (0 — без ограничений). -- `move_factor` ([Float64](../sql_reference/data_types/float.md))\` — доля свободного места, при превышении которой данные начинают перемещаться на следующий том. - -Если политика хранения содержит несколько томов, то каждому тому соответствует отдельная запись в таблице. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/operations/system_tables/) diff --git a/docs/ru/operations/troubleshooting.md b/docs/ru/operations/troubleshooting.md index a045de41ccc..cb86dfef5e8 100644 --- a/docs/ru/operations/troubleshooting.md +++ b/docs/ru/operations/troubleshooting.md @@ -10,7 +10,7 @@ ### Не получается скачать deb-пакеты из репозитория ClickHouse с помощью Apt-get {#ne-poluchaetsia-skachat-deb-pakety-iz-repozitoriia-clickhouse-s-pomoshchiu-apt-get} - Проверьте настройки брандмауэра. -- Если по какой-либо причине вы не можете получить доступ к репозиторию, скачайте пакеты как описано в разделе [Начало работы](../getting_started/index.md) и установите их вручную командой `sudo dpkg -i `. Также, необходим пакет `tzdata`. +- Если по какой-либо причине вы не можете получить доступ к репозиторию, скачайте пакеты как описано в разделе [Начало работы](../getting-started/index.md) и установите их вручную командой `sudo dpkg -i `. Также, необходим пакет `tzdata`. ## Соединение с сервером {#troubleshooting-accepts-no-connections} diff --git a/docs/ru/operations/utilities/clickhouse-copier.md b/docs/ru/operations/utilities/clickhouse-copier.md index 291c36993c6..b05db93b28b 100644 --- a/docs/ru/operations/utilities/clickhouse-copier.md +++ b/docs/ru/operations/utilities/clickhouse-copier.md @@ -19,7 +19,7 @@ Для снижения сетевого трафика рекомендуем запускать `clickhouse-copier` на том же сервере, где находятся исходные данные. -## Запуск clickhouse-copier {#zapusk-clickhouse-copier} +## Запуск Clickhouse-copier {#zapusk-clickhouse-copier} Утилиту следует запускать вручную следующим образом: @@ -36,7 +36,7 @@ $ clickhouse-copier copier --daemon --config zookeeper.xml --task-path /task/pat - `task-upload-force` - Загрузить `task-file` в ZooKeeper даже если уже было загружено. - `base-dir` - путь к логам и вспомогательным файлам. При запуске `clickhouse-copier` создает в `$base-dir` подкаталоги `clickhouse-copier_YYYYMMHHSS_`. Если параметр не указан, то каталоги будут создаваться в каталоге, где `clickhouse-copier` был запущен. -## Формат zookeeper.xml {#format-zookeeper-xml} +## Формат Zookeeper.xml {#format-zookeeper-xml} ``` xml diff --git a/docs/ru/sql-reference/aggregate-functions/combinators.md b/docs/ru/sql-reference/aggregate-functions/combinators.md new file mode 100644 index 00000000000..95264976857 --- /dev/null +++ b/docs/ru/sql-reference/aggregate-functions/combinators.md @@ -0,0 +1,240 @@ +# Комбинаторы агрегатных функций {#aggregate_functions_combinators} + +К имени агрегатной функции может быть приписан некоторый суффикс. При этом, работа агрегатной функции некоторым образом модифицируется. + +## -If {#agg-functions-combinator-if} + +К имени любой агрегатной функции может быть приписан суффикс -If. В этом случае, агрегатная функция принимает ещё один дополнительный аргумент - условие (типа UInt8). Агрегатная функция будет обрабатывать только те строки, для которых условие сработало. Если условие ни разу не сработало - возвращается некоторое значение по умолчанию (обычно - нули, пустые строки). + +Примеры: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` и т. п. + +С помощью условных агрегатных функций, вы можете вычислить агрегаты сразу для нескольких условий, не используя подзапросы и `JOIN`-ы. +Например, в Яндекс.Метрике, условные агрегатные функции используются для реализации функциональности сравнения сегментов. + +## -Array {#array} + +К имени любой агрегатной функции может быть приписан суффикс -Array. В этом случае, агрегатная функция вместо аргументов типов T принимает аргументы типов Array(T) (массивы). Если агрегатная функция принимает несколько аргументов, то это должны быть массивы одинаковых длин. При обработке массивов, агрегатная функция работает, как исходная агрегатная функция по всем элементам массивов. + +Пример 1: `sumArray(arr)` - просуммировать все элементы всех массивов arr. В данном примере можно было бы написать проще: `sum(arraySum(arr))`. + +Пример 2: `uniqArray(arr)` - посчитать количество уникальных элементов всех массивов arr. Это можно было бы сделать проще: `uniq(arrayJoin(arr))`, но не всегда есть возможность добавить arrayJoin в запрос. + +Комбинаторы -If и -Array можно сочетать. При этом, должен сначала идти Array, а потом If. Примеры: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. Из-за такого порядка получается, что аргумент cond не должен быть массивом. + +## -State {#state} + +В случае применения этого комбинатора, агрегатная функция возвращает не готовое значение (например, в случае функции [uniq](reference.md#agg_function-uniq) — количество уникальных значений), а промежуточное состояние агрегации (например, в случае функции `uniq` — хэш-таблицу для расчёта количества уникальных значений), которое имеет тип `AggregateFunction(...)` и может использоваться для дальнейшей обработки или может быть сохранено в таблицу для последующей доагрегации. + +Для работы с промежуточными состояниями предназначены: + +- Движок таблиц [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md). +- Функция [finalizeAggregation](../../sql-reference/aggregate-functions/combinators.md#function-finalizeaggregation). +- Функция [runningAccumulate](../../sql-reference/aggregate-functions/combinators.md#function-runningaccumulate). +- Комбинатор [-Merge](#aggregate_functions_combinators-merge). +- Комбинатор [-MergeState](#aggregate_functions_combinators-mergestate). + +## -Merge {#aggregate_functions_combinators-merge} + +В случае применения этого комбинатора, агрегатная функция будет принимать в качестве аргумента промежуточное состояние агрегации, доагрегировать (объединять вместе) эти состояния, и возвращать готовое значение. + +## -MergeState {#aggregate_functions_combinators-mergestate} + +Выполняет слияние промежуточных состояний агрегации, аналогично комбинатору -Merge, но возвращает не готовое значение, а промежуточное состояние агрегации, аналогично комбинатору -State. + +## -ForEach {#foreach} + +Преобразует агрегатную функцию для таблиц в агрегатную функцию для массивов, которая применяет агрегирование для соответствующих элементов массивов и возвращает массив результатов. Например, `sumForEach` для массивов `[1, 2]`, `[3, 4, 5]` и `[6, 7]` даст результат `[10, 13, 5]`, сложив соответственные элементы массивов. + +## -OrDefault {#agg-functions-combinator-ordefault} + +Изменяет поведение агрегатной функции. + +Если на вход агрегатной функции передан пустой набор данных, то с помощью комбинатора `-OrDefault` функция возвращает значение по умолчанию для соответствующего типа данных. Комбинатор применяется к агрегатным функциям, которые могут принимать пустые входные данные. + +`-OrDefault` можно использовать с другими комбинаторами. + +**Синтаксис** + +``` sql +OrDefault(x) +``` + +**Параметры** + +- `x` — Параметры агрегатной функции. + +**Возращаемые зачения** + +Возвращает значение по умолчанию для соответствующего типа агрегатной функции, если агрегировать нечего. + +Тип данных зависит от используемой агрегатной функции. + +**Пример** + +Запрос: + +``` sql +SELECT avg(number), avgOrDefault(number) FROM numbers(0) +``` + +Результат: + +``` text +┌─avg(number)─┬─avgOrDefault(number)─┐ +│ nan │ 0 │ +└─────────────┴──────────────────────┘ +``` + +Также `-OrDefault` может использоваться с другими комбинаторами. Это полезно, когда агрегатная функция не принимает пустые входные данные. + +Запрос: + +``` sql +SELECT avgOrDefaultIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Результат: + +``` text +┌─avgOrDefaultIf(x, greater(x, 10))─┐ +│ 0.00 │ +└───────────────────────────────────┘ +``` + + +## -OrNull {#agg-functions-combinator-ornull} + +Изменяет поведение агрегатной функции. + +Комбинатор преобразует результат агрегатной функции к типу [Nullable](../data-types/nullable.md). Если агрегатная функция не получает данных на вход, то с комбинатором она возвращает [NULL](../syntax.md#null-literal). + +`-OrNull` может использоваться с другими комбинаторами. + +**Синтаксис** + +``` sql +OrNull(x) +``` + +**Параметры** + +- `x` — Параметры агрегатной функции. + +**Возвращаемые значения** + +- Результат агрегатной функции, преобразованный в тип данных `Nullable`. +- `NULL`, если у агрегатной функции нет входных данных. + +Тип: `Nullable(aggregate function return type)`. + +**Пример** + +Добавьте `-orNull` в конец агрегатной функции. + +Запрос: + +``` sql +SELECT sumOrNull(number), toTypeName(sumOrNull(number)) FROM numbers(10) WHERE number > 10 +``` + +Результат: + +``` text +┌─sumOrNull(number)─┬─toTypeName(sumOrNull(number))─┐ +│ ᴺᵁᴸᴸ │ Nullable(UInt64) │ +└───────────────────┴───────────────────────────────┘ +``` + +Также `-OrNull` может использоваться с другими комбинаторами. Это полезно, когда агрегатная функция не принимает пустые входные данные. + +Запрос: + +``` sql +SELECT avgOrNullIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Результат: + +``` text +┌─avgOrNullIf(x, greater(x, 10))─┐ +│ ᴺᵁᴸᴸ │ +└────────────────────────────────┘ +``` + +## -Resample {#agg-functions-combinator-resample} + +Позволяет поделить данные на группы, а затем по-отдельности агрегирует данные для этих групп. Группы образуются разбиением значений одного из столбцов на интервалы. + +``` sql +Resample(start, end, step)(, resampling_key) +``` + +**Параметры** + +- `start` — начальное значение для интервала значений `resampling_key`. +- `stop` — конечное значение для интервала значений `resampling_key`. Интервал не включает значение `stop` (`[start, stop)`). +- `step` — шаг деления полного интервала на подинтервалы. Функция `aggFunction` выполняется для каждого из подинтервалов независимо. +- `resampling_key` — столбец, значения которого используются для разделения данных на интервалы. +- `aggFunction_params` — параметры `aggFunction`. + +**Возвращаемые значения** + +- Массив результатов `aggFunction` для каждого подинтервала. + +**Пример** + +Рассмотрим таблицу `people` со следующими данными: + +``` text +┌─name───┬─age─┬─wage─┐ +│ John │ 16 │ 10 │ +│ Alice │ 30 │ 15 │ +│ Mary │ 35 │ 8 │ +│ Evelyn │ 48 │ 11.5 │ +│ David │ 62 │ 9.9 │ +│ Brian │ 60 │ 16 │ +└────────┴─────┴──────┘ +``` + +Получим имена людей, чей возраст находится в интервалах `[30,60)` и `[60,75)`. Поскольку мы используем целочисленное представление возраста, то интервалы будут выглядеть как `[30, 59]` и `[60,74]`. + +Чтобы собрать имена в массив, возьмём агрегатную функцию [groupArray](reference.md#agg_function-grouparray). Она принимает один аргумент. В нашем случае, это столбец `name`. Функция `groupArrayResample` должна использовать столбец `age` для агрегирования имён по возрасту. Чтобы определить необходимые интервалы, передадим в функцию `groupArrayResample` аргументы `30, 75, 30`. + +``` sql +SELECT groupArrayResample(30, 75, 30)(name, age) from people +``` + +``` text +┌─groupArrayResample(30, 75, 30)(name, age)─────┐ +│ [['Alice','Mary','Evelyn'],['David','Brian']] │ +└───────────────────────────────────────────────┘ +``` + +Посмотрим на результаты. + +`Jonh` не попал в выдачу, поскольку слишком молод. Остальные распределены согласно заданным возрастным интервалам. + +Теперь посчитаем общее количество людей и их среднюю заработную плату в заданных возрастных интервалах. + +``` sql +SELECT + countResample(30, 75, 30)(name, age) AS amount, + avgResample(30, 75, 30)(wage, age) AS avg_wage +FROM people +``` + +``` text +┌─amount─┬─avg_wage──────────────────┐ +│ [3,2] │ [11.5,12.949999809265137] │ +└────────┴───────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/combinators/) diff --git a/docs/ru/sql-reference/aggregate-functions/index.md b/docs/ru/sql-reference/aggregate-functions/index.md new file mode 100644 index 00000000000..6bdb2a7808d --- /dev/null +++ b/docs/ru/sql-reference/aggregate-functions/index.md @@ -0,0 +1,63 @@ +--- +toc_folder_title: "\u0410\u0433\u0440\u0435\u0433\u0430\u0442\u043D\u044B\u0435 \u0444\ + \u0443\u043D\u043A\u0446\u0438\u0438" +toc_priority: 33 +toc_title: "\u0412\u0432\u0435\u0434\u0435\u043D\u0438\u0435" +--- + +# Агрегатные функции {#aggregate-functions} + +Агрегатные функции работают в [привычном](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) для специалистов по базам данных смысле. + +ClickHouse поддерживает также: + +- [Параметрические агрегатные функции](parametric-functions.md#aggregate_functions_parametric), которые помимо столбцов принимаю и другие параметры. +- [Комбинаторы](combinators.md#aggregate_functions_combinators), которые изменяют поведение агрегатных функций. + +## Обработка NULL {#obrabotka-null} + +При агрегации все `NULL` пропускаются. + +**Примеры** + +Рассмотрим таблицу: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +Выполним суммирование значений в столбце `y`: + +``` sql +SELECT sum(y) FROM t_null_big +``` + +``` text +┌─sum(y)─┐ +│ 7 │ +└────────┘ +``` + +Функция `sum` работает с `NULL` как с `0`. В частности, это означает, что если на вход в функцию подать выборку, где все значения `NULL`, то результат будет `0`, а не `NULL`. + +Теперь с помощью функции `groupArray` сформируем массив из столбца `y`: + +``` sql +SELECT groupArray(y) FROM t_null_big +``` + +``` text +┌─groupArray(y)─┐ +│ [2,2,3] │ +└───────────────┘ +``` + +`groupArray` не включает `NULL` в результирующий массив. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/) diff --git a/docs/ru/sql-reference/aggregate-functions/parametric-functions.md b/docs/ru/sql-reference/aggregate-functions/parametric-functions.md new file mode 100644 index 00000000000..7cc0bdef581 --- /dev/null +++ b/docs/ru/sql-reference/aggregate-functions/parametric-functions.md @@ -0,0 +1,479 @@ +# Параметрические агрегатные функции {#aggregate_functions_parametric} + +Некоторые агрегатные функции могут принимать не только столбцы-аргументы (по которым производится свёртка), но и набор параметров - констант для инициализации. Синтаксис - две пары круглых скобок вместо одной. Первая - для параметров, вторая - для аргументов. + +## histogram {#histogram} + +Рассчитывает адаптивную гистограмму. Не гарантирует точного результата. + + histogram(number_of_bins)(values) + +Функция использует [A Streaming Parallel Decision Tree Algorithm](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). Границы столбцов устанавливаются по мере поступления новых данных в функцию. В общем случае столбцы имею разную ширину. + +**Параметры** + +`number_of_bins` — максимальное количество корзин в гистограмме. Функция автоматически вычисляет количество корзин. Она пытается получить указанное количество корзин, но если не получилось, то в результате корзин будет меньше. +`values` — [выражение](../syntax.md#syntax-expressions), предоставляющее входные значения. + +**Возвращаемые значения** + +- [Массив](../../sql-reference/data-types/array.md) [кортежей](../../sql-reference/data-types/tuple.md) следующего вида: + + ``` + [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] + ``` + + - `lower` — нижняя граница корзины. + - `upper` — верхняя граница корзины. + - `height` — количество значений в корзине. + +**Пример** + +``` sql +SELECT histogram(5)(number + 1) +FROM ( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ +│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +С помощью функции [bar](../../sql-reference/aggregate-functions/parametric-functions.md#function-bar) можно визуализировать гистограмму, например: + +``` sql +WITH histogram(5)(rand() % 100) AS hist +SELECT + arrayJoin(hist).3 AS height, + bar(height, 0, 6, 5) AS bar +FROM +( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─height─┬─bar───┐ +│ 2.125 │ █▋ │ +│ 3.25 │ ██▌ │ +│ 5.625 │ ████▏ │ +│ 5.625 │ ████▏ │ +│ 3.375 │ ██▌ │ +└────────┴───────┘ +``` + +В этом случае необходимо помнить, что границы корзин гистограммы не известны. + +## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} + +Проверяет, содержит ли последовательность событий цепочку, которая соответствует указанному шаблону. + +``` sql +sequenceMatch(pattern)(timestamp, cond1, cond2, ...) +``` + +!!! warning "Предупреждение" + События, произошедшие в одну и ту же секунду, располагаются в последовательности в неопределенном порядке, что может повлиять на результат работы функции. + +**Параметры** + +- `pattern` — строка с шаблоном. Смотрите [Синтаксис шаблонов](#sequence-function-pattern-syntax). + +- `timestamp` — столбец, содержащий метки времени. Типичный тип данных столбца — `Date` или `DateTime`. Также можно использовать любой из поддержанных типов данных [UInt](../../sql-reference/aggregate-functions/parametric-functions.md). + +- `cond1`, `cond2` — условия, описывающие цепочку событий. Тип данных — `UInt8`. Можно использовать до 32 условий. Функция учитывает только те события, которые указаны в условиях. Функция пропускает данные из последовательности, если они не описаны ни в одном из условий. + +**Возвращаемые значения** + +- 1, если цепочка событий, соответствующая шаблону найдена. +- 0, если цепочка событий, соответствующая шаблону не найдена. + +Тип: `UInt8`. + + +**Синтаксис шаблонов** + +- `(?N)` — соответствует условию на позиции `N`. Условия пронумерованы по порядку в диапазоне `[1, 32]`. Например, `(?1)` соответствует условию, заданному параметром `cond1`. + +- `.*` — соответствует любому количеству событий. Для этого элемента шаблона не надо задавать условия. + +- `(?t operator value)` — устанавливает время в секундах, которое должно разделять два события. Например, шаблон `(?1)(?t>1800)(?2)` соответствует событиям, которые произошли более чем через 1800 секунд друг от друга. Между этими событиями может находиться произвольное количество любых событий. Операторы могут быть `>=`, `>`, `<`, `<=`. + +**Примеры** + +Пусть таблица `t` содержит следующие данные: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +└──────┴────────┘ +``` + +Выполним запрос: + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 1 │ +└───────────────────────────────────────────────────────────────────────┘ +``` + +Функция нашла цепочку событий, в которой число 2 следует за числом 1. Число 3 между ними было пропущено, поскольку оно не было использовано ни в одном из условий. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ +│ 0 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +В этом случае функция не может найти цепочку событий, соответствующую шаблону, поскольку событие для числа 3 произошло между 1 и 2. Если бы в этом же случае мы бы проверяли условие на событие для числа 4, то цепочка бы соответствовала шаблону. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ +│ 1 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Смотрите также** + +- [sequenceCount](#function-sequencecount) + +## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} + +Вычисляет количество цепочек событий, соответствующих шаблону. Функция обнаруживает только непересекающиеся цепочки событий. Она начитает искать следующую цепочку только после того, как полностью совпала текущая цепочка событий. + +!!! warning "Предупреждение" + События, произошедшие в одну и ту же секунду, располагаются в последовательности в неопределенном порядке, что может повлиять на результат работы функции. + +``` sql +sequenceCount(pattern)(timestamp, cond1, cond2, ...) +``` + +**Параметры** + +- `pattern` — строка с шаблоном. Смотрите [Синтаксис шаблонов](#sequence-function-pattern-syntax). + +- `timestamp` — столбец, содержащий метки времени. Типичный тип данных столбца — `Date` или `DateTime`. Также можно использовать любой из поддержанных типов данных [UInt](../../sql-reference/aggregate-functions/parametric-functions.md). + +- `cond1`, `cond2` — условия, описывающие цепочку событий. Тип данных — `UInt8`. Можно использовать до 32 условий. Функция учитывает только те события, которые указаны в условиях. Функция пропускает данные из последовательности, если они не описаны ни в одном из условий. + +**Возвращаемое значение** + +- Число непересекающихся цепочек событий, соответствущих шаблону. + +Тип: `UInt64`. + +**Пример** + +Пусть таблица `t` содержит следующие данные: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +│ 4 │ 1 │ +│ 5 │ 3 │ +│ 6 │ 2 │ +└──────┴────────┘ +``` + +Вычислим сколько раз число 2 стоит после числа 1, причем между 1 и 2 могут быть любые числа: + +``` sql +SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 2 │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +**Смотрите также** + +- [sequenceMatch](#function-sequencematch) + +## windowFunnel {#windowfunnel} + +Отыскивает цепочки событий в скользящем окне по времени и вычисляет максимальное количество произошедших событий из цепочки. + +Функция работает по алгоритму: + +- Функция отыскивает данные, на которых срабатывает первое условие из цепочки, и присваивает счетчику событий значение 1. С этого же момента начинается отсчет времени скользящего окна. + +- Если в пределах окна последовательно попадаются события из цепочки, то счетчик увеличивается. Если последовательность событий нарушается, то счетчик не растет. + +- Если в данных оказалось несколько цепочек разной степени завершенности, то функция выдаст только размер самой длинной цепочки. + +**Синтаксис** + +``` sql +windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) +``` + +**Параметры** + +- `window` — ширина скользящего окна по времени в секундах. [UInt](../../sql-reference/aggregate-functions/parametric-functions.md). +- `mode` - необязательный параметр. Если установлено значение `'strict'`, то функция `windowFunnel()` применяет условия только для уникальных значений. +- `timestamp` — имя столбца, содержащего временные отметки. [Date](../../sql-reference/aggregate-functions/parametric-functions.md), [DateTime](../../sql-reference/aggregate-functions/parametric-functions.md#data_type-datetime) и другие параметры с типом `Integer`. В случае хранения меток времени в столбцах с типом `UInt64`, максимально допустимое значение соответствует ограничению для типа `Int64`, т.е. равно `2^63-1`. +- `cond` — условия или данные, описывающие цепочку событий. [UInt8](../../sql-reference/aggregate-functions/parametric-functions.md). + +**Возвращаемое значение** + +Максимальное количество последовательно сработавших условий из цепочки в пределах скользящего окна по времени. Исследуются все цепочки в выборке. + +Тип: `Integer`. + +**Пример** + +Определим, успевает ли пользователь за установленный период выбрать телефон в интернет-магазине, купить его и сделать повторный заказ. + +Зададим следующую цепочку событий: + +1. Пользователь вошел в личный кабинет (`eventID = 1001`). +2. Пользователь ищет телефон (`eventID = 1003, product = 'phone'`). +3. Пользователь сделал заказ (`eventID = 1009`) +4. Пользователь сделал повторный заказ (`eventID = 1010`). + +Входная таблица: + +``` text +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +``` + +Сделаем запрос и узнаем, как далеко пользователь `user_id` смог пройти по цепочке за период в январе-феврале 2019-го года. + +Запрос: + +``` sql +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level + FROM trend + WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC +``` + +## retention {#retention} + +Аналитическая функция, которая показывает, насколько +выдерживаются те или иные условия, например, удержание динамики/уровня [посещаемости сайта](https://yandex.ru/support/partner2/statistics/metrika-visitors-statistics.html?lang=ru). + +Функция принимает набор (от 1 до 32) логических условий, как в [WHERE](../../sql-reference/statements/select/where.md#select-where), и применяет их к заданному набору данных. + +Условия, кроме первого, применяются попарно: результат второго будет истинным, если истинно первое и второе, третьего - если истинно первое и третье и т. д. + +**Синтаксис** + +``` sql +retention(cond1, cond2, ..., cond32) +``` + +**Параметры** + +- `cond` — вычисляемое условие или выражение, которое возвращает `UInt8` результат (1/0). + +**Возвращаемое значение** + +Массив из 1 или 0. + +- 1 — условие выполнено. +- 0 — условие не выполнено. + +Тип: `UInt8`. + +**Пример** + +Рассмотрим пример расчета функции `retention` для определения посещаемости сайта. + +**1.** Создадим таблицу для илюстрации примера. + +``` sql +CREATE TABLE retention_test(date Date, uid Int32)ENGINE = Memory; + +INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); +INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); +INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); +``` + +Входная таблица: + +Запрос: + +``` sql +SELECT * FROM retention_test +``` + +Ответ: + +``` text +┌───────date─┬─uid─┐ +│ 2020-01-01 │ 0 │ +│ 2020-01-01 │ 1 │ +│ 2020-01-01 │ 2 │ +│ 2020-01-01 │ 3 │ +│ 2020-01-01 │ 4 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-02 │ 0 │ +│ 2020-01-02 │ 1 │ +│ 2020-01-02 │ 2 │ +│ 2020-01-02 │ 3 │ +│ 2020-01-02 │ 4 │ +│ 2020-01-02 │ 5 │ +│ 2020-01-02 │ 6 │ +│ 2020-01-02 │ 7 │ +│ 2020-01-02 │ 8 │ +│ 2020-01-02 │ 9 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-03 │ 0 │ +│ 2020-01-03 │ 1 │ +│ 2020-01-03 │ 2 │ +│ 2020-01-03 │ 3 │ +│ 2020-01-03 │ 4 │ +│ 2020-01-03 │ 5 │ +│ 2020-01-03 │ 6 │ +│ 2020-01-03 │ 7 │ +│ 2020-01-03 │ 8 │ +│ 2020-01-03 │ 9 │ +│ 2020-01-03 │ 10 │ +│ 2020-01-03 │ 11 │ +│ 2020-01-03 │ 12 │ +│ 2020-01-03 │ 13 │ +│ 2020-01-03 │ 14 │ +└────────────┴─────┘ +``` + +**2.** Сгруппируем пользователей по уникальному идентификатору `uid` с помощью функции `retention`. + +Запрос: + +``` sql +SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r +FROM retention_test +WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') +GROUP BY uid +ORDER BY uid ASC +``` + +Результат: + +``` text +┌─uid─┬─r───────┐ +│ 0 │ [1,1,1] │ +│ 1 │ [1,1,1] │ +│ 2 │ [1,1,1] │ +│ 3 │ [1,1,1] │ +│ 4 │ [1,1,1] │ +│ 5 │ [0,0,0] │ +│ 6 │ [0,0,0] │ +│ 7 │ [0,0,0] │ +│ 8 │ [0,0,0] │ +│ 9 │ [0,0,0] │ +│ 10 │ [0,0,0] │ +│ 11 │ [0,0,0] │ +│ 12 │ [0,0,0] │ +│ 13 │ [0,0,0] │ +│ 14 │ [0,0,0] │ +└─────┴─────────┘ +``` + +**3.** Рассчитаем количество посещений сайта за день. + +Запрос: + +``` sql +SELECT + sum(r[1]) AS r1, + sum(r[2]) AS r2, + sum(r[3]) AS r3 +FROM +( + SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r + FROM retention_test + WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') + GROUP BY uid +) +``` + +Результат: + +``` text +┌─r1─┬─r2─┬─r3─┐ +│ 5 │ 5 │ 5 │ +└────┴────┴────┘ +``` + +Где: + +- `r1` - количество уникальных посетителей за 2020-01-01 (`cond1`). +- `r2` - количество уникальных посетителей в период между 2020-01-01 и 2020-01-02 (`cond1` и `cond2`). +- `r3` - количество уникальных посетителей в период между 2020-01-01 и 2020-01-03 (`cond1` и `cond3`). + +## uniqUpTo(N)(x) {#uniquptonx} + +Вычисляет количество различных значений аргумента, если оно меньше или равно N. +В случае, если количество различных значений аргумента больше N, возвращает N + 1. + +Рекомендуется использовать для маленьких N - до 10. Максимальное значение N - 100. + +Для состояния агрегатной функции используется количество оперативки равное 1 + N \* размер одного значения байт. +Для строк запоминается не криптографический хэш, имеющий размер 8 байт. То есть, для строк вычисление приближённое. + +Функция также работает для нескольких аргументов. + +Работает максимально быстро за исключением патологических случаев, когда используется большое значение N и количество уникальных значений чуть меньше N. + +Пример применения: + +``` text +Задача: показывать в отчёте только поисковые фразы, по которым было хотя бы 5 уникальных посетителей. +Решение: пишем в запросе GROUP BY SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/parametric_functions/) diff --git a/docs/ru/sql-reference/aggregate-functions/reference.md b/docs/ru/sql-reference/aggregate-functions/reference.md new file mode 100644 index 00000000000..612d073c484 --- /dev/null +++ b/docs/ru/sql-reference/aggregate-functions/reference.md @@ -0,0 +1,1835 @@ +# Справочник функций {#aggregate-functions-reference} + +## count {#agg_function-count} + +Вычисляет количество строк или не NULL значений . + +ClickHouse поддерживает следующие виды синтаксиса для `count`: + +- `count(expr)` или `COUNT(DISTINCT expr)`. +- `count()` или `COUNT(*)`. Синтаксис `count()` специфичен для ClickHouse. + +**Параметры** + +Функция может принимать: + +- Ноль параметров. +- Одно [выражение](../syntax.md#syntax-expressions). + +**Возвращаемое значение** + +- Если функция вызывается без параметров, она вычисляет количество строк. +- Если передаётся [выражение](../syntax.md#syntax-expressions) , то функция вычисляет количество раз, когда выражение возвращает не NULL. Если выражение возвращает значение типа [Nullable](../../sql-reference/data-types/nullable.md), то результат `count` не становится `Nullable`. Функция возвращает 0, если выражение возвращает `NULL` для всех строк. + +В обоих случаях тип возвращаемого значения [UInt64](../../sql-reference/data-types/int-uint.md). + +**Подробности** + +ClickHouse поддерживает синтаксис `COUNT(DISTINCT ...)`. Поведение этой конструкции зависит от настройки [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation). Она определяет, какая из функций [uniq\*](#agg_function-uniq) используется для выполнения операции. По умолчанию — функция [uniqExact](#agg_function-uniqexact). + +Запрос `SELECT count() FROM table` не оптимизирован, поскольку количество записей в таблице не хранится отдельно. Он выбирает небольшой столбец из таблицы и подсчитывает количество значений в нём. + +**Примеры** + +Пример 1: + +``` sql +SELECT count() FROM t +``` + +``` text +┌─count()─┐ +│ 5 │ +└─────────┘ +``` + +Пример 2: + +``` sql +SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' +``` + +``` text +┌─name──────────────────────────┬─value─────┐ +│ count_distinct_implementation │ uniqExact │ +└───────────────────────────────┴───────────┘ +``` + +``` sql +SELECT count(DISTINCT num) FROM t +``` + +``` text +┌─uniqExact(num)─┐ +│ 3 │ +└────────────────┘ +``` + +Этот пример показывает, что `count(DISTINCT num)` выполняется с помощью функции `uniqExact` в соответствии со значением настройки `count_distinct_implementation`. + +## any(x) {#agg_function-any} + +Выбирает первое попавшееся значение. +Порядок выполнения запроса может быть произвольным и даже каждый раз разным, поэтому результат данной функции недетерминирован. +Для получения детерминированного результата, можно использовать функции min или max вместо any. + +В некоторых случаях, вы всё-таки можете рассчитывать на порядок выполнения запроса. Это - случаи, когда SELECT идёт из подзапроса, в котором используется ORDER BY. + +При наличии в запросе `SELECT` секции `GROUP BY` или хотя бы одной агрегатной функции, ClickHouse (в отличие от, например, MySQL) требует, чтобы все выражения в секциях `SELECT`, `HAVING`, `ORDER BY` вычислялись из ключей или из агрегатных функций. То есть, каждый выбираемый из таблицы столбец, должен использоваться либо в ключах, либо внутри агрегатных функций. Чтобы получить поведение, как в MySQL, вы можете поместить остальные столбцы в агрегатную функцию `any`. + +## anyHeavy(x) {#agg_function-anyheavy} + +Выбирает часто встречающееся значение с помощью алгоритма «[heavy hitters](http://www.cs.umd.edu/~samir/498/karp.pdf)». Если существует значение, которое встречается чаще, чем в половине случаев, в каждом потоке выполнения запроса, то возвращается данное значение. В общем случае, результат недетерминирован. + +``` sql +anyHeavy(column) +``` + +**Аргументы** + +- `column` — имя столбца. + +**Пример** + +Возьмём набор данных [OnTime](../../getting-started/example-datasets/ontime.md) и выберем произвольное часто встречающееся значение в столбце `AirlineID`. + +``` sql +SELECT anyHeavy(AirlineID) AS res +FROM ontime +``` + +``` text +┌───res─┐ +│ 19690 │ +└───────┘ +``` + +## anyLast(x) {#anylastx} + +Выбирает последнее попавшееся значение. +Результат так же недетерминирован, как и для функции `any`. + +## groupBitAnd {#groupbitand} + +Применяет побитовое `И` для последовательности чисел. + +``` sql +groupBitAnd(expr) +``` + +**Параметры** + +`expr` – выражение, результат которого имеет тип данных `UInt*`. + +**Возвращаемое значение** + +Значение типа `UInt*`. + +**Пример** + +Тестовые данные: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Запрос: + +``` sql +SELECT groupBitAnd(num) FROM t +``` + +Где `num` — столбец с тестовыми данными. + +Результат: + +``` text +binary decimal +00000100 = 4 +``` + +## groupBitOr {#groupbitor} + +Применяет побитовое `ИЛИ` для последовательности чисел. + +``` sql +groupBitOr(expr) +``` + +**Параметры** + +`expr` – выражение, результат которого имеет тип данных `UInt*`. + +**Возвращаемое значение** + +Значение типа `UInt*`. + +**Пример** + +Тестовые данные: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Запрос: + +``` sql +SELECT groupBitOr(num) FROM t +``` + +Где `num` — столбец с тестовыми данными. + +Результат: + +``` text +binary decimal +01111101 = 125 +``` + +## groupBitXor {#groupbitxor} + +Применяет побитовое `ИСКЛЮЧАЮЩЕЕ ИЛИ` для последовательности чисел. + +``` sql +groupBitXor(expr) +``` + +**Параметры** + +`expr` – выражение, результат которого имеет тип данных `UInt*`. + +**Возвращаемое значение** + +Значение типа `UInt*`. + +**Пример** + +Тестовые данные: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Запрос: + +``` sql +SELECT groupBitXor(num) FROM t +``` + +Где `num` — столбец с тестовыми данными. + +Результат: + +``` text +binary decimal +01101000 = 104 +``` + +## groupBitmap {#groupbitmap} + +Bitmap или агрегатные вычисления для столбца с типом данных `UInt*`, возвращают кардинальность в виде значения типа UInt64, если добавить суффикс -State, то возвращают [объект bitmap](../../sql-reference/aggregate-functions/reference.md). + +``` sql +groupBitmap(expr) +``` + +**Параметры** + +`expr` – выражение, результат которого имеет тип данных `UInt*`. + +**Возвращаемое значение** + +Значение типа `UInt64`. + +**Пример** + +Тестовые данные: + +``` text +UserID +1 +1 +2 +3 +``` + +Запрос: + +``` sql +SELECT groupBitmap(UserID) as num FROM t +``` + +Результат: + +``` text +num +3 +``` + +## min(x) {#agg_function-min} + +Вычисляет минимум. + +## max(x) {#agg_function-max} + +Вычисляет максимум. + +## argMin(arg, val) {#agg-function-argmin} + +Вычисляет значение arg при минимальном значении val. Если есть несколько разных значений arg для минимальных значений val, то выдаётся первое попавшееся из таких значений. + +**Пример:** + +``` text +┌─user─────┬─salary─┐ +│ director │ 5000 │ +│ manager │ 3000 │ +│ worker │ 1000 │ +└──────────┴────────┘ +``` + +``` sql +SELECT argMin(user, salary) FROM salary +``` + +``` text +┌─argMin(user, salary)─┐ +│ worker │ +└──────────────────────┘ +``` + +## argMax(arg, val) {#agg-function-argmax} + +Вычисляет значение arg при максимальном значении val. Если есть несколько разных значений arg для максимальных значений val, то выдаётся первое попавшееся из таких значений. + +## sum(x) {#agg_function-sum} + +Вычисляет сумму. +Работает только для чисел. + +## sumWithOverflow(x) {#agg_function-sumwithoverflow} + +Вычисляет сумму чисел, используя для результата тот же тип данных, что и для входных параметров. Если сумма выйдет за максимальное значение для заданного типа данных, то функция вернёт ошибку. + +Работает только для чисел. + +## sumMap(key, value) {#summapkey-value} + +Производит суммирование массива ‘value’ по соответствующим ключам заданным в массиве ‘key’. +Количество элементов в ‘key’ и ‘value’ должно быть одинаковым для каждой строки, для которой происходит суммирование. +Возвращает кортеж из двух массивов - ключи в отсортированном порядке и значения, просуммированные по соответствующим ключам. + +Пример: + +``` sql +CREATE TABLE sum_map( + date Date, + timeslot DateTime, + statusMap Nested( + status UInt16, + requests UInt64 + ) +) ENGINE = Log; +INSERT INTO sum_map VALUES + ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10]), + ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10]), + ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10]), + ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10]); +SELECT + timeslot, + sumMap(statusMap.status, statusMap.requests) +FROM sum_map +GROUP BY timeslot +``` + +``` text +┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┐ +│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ +│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ +└─────────────────────┴──────────────────────────────────────────────┘ +``` + +## skewPop {#skewpop} + +Вычисляет [коэффициент асимметрии](https://ru.wikipedia.org/wiki/Коэффициент_асимметрии) для последовательности. + +``` sql +skewPop(expr) +``` + +**Параметры** + +`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. + +**Возвращаемое значение** + +Коэффициент асимметрии заданного распределения. Тип — [Float64](../../sql-reference/aggregate-functions/reference.md) + +**Пример** + +``` sql +SELECT skewPop(value) FROM series_with_value_column +``` + +## skewSamp {#skewsamp} + +Вычисляет [выборочный коэффициент асимметрии](https://ru.wikipedia.org/wiki/Статистика_(функция_выборки)) для последовательности. + +Он представляет собой несмещенную оценку асимметрии случайной величины, если переданные значения образуют ее выборку. + +``` sql +skewSamp(expr) +``` + +**Параметры** + +`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. + +**Возвращаемое значение** + +Коэффициент асимметрии заданного распределения. Тип — [Float64](../../sql-reference/aggregate-functions/reference.md). Если `n <= 1` (`n` — размер выборки), тогда функция возвращает `nan`. + +**Пример** + +``` sql +SELECT skewSamp(value) FROM series_with_value_column +``` + +## kurtPop {#kurtpop} + +Вычисляет [коэффициент эксцесса](https://ru.wikipedia.org/wiki/Коэффициент_эксцесса) последовательности. + +``` sql +kurtPop(expr) +``` + +**Параметры** + +`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. + +**Возвращаемое значение** + +Коэффициент эксцесса заданного распределения. Тип — [Float64](../../sql-reference/aggregate-functions/reference.md) + +**Пример** + +``` sql +SELECT kurtPop(value) FROM series_with_value_column +``` + +## kurtSamp {#kurtsamp} + +Вычисляет [выборочный коэффициент эксцесса](https://ru.wikipedia.org/wiki/Статистика_(функция_выборки)) для последовательности. + +Он представляет собой несмещенную оценку эксцесса случайной величины, если переданные значения образуют ее выборку. + +``` sql +kurtSamp(expr) +``` + +**Параметры** + +`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. + +**Возвращаемое значение** + +Коэффициент эксцесса заданного распределения. Тип — [Float64](../../sql-reference/aggregate-functions/reference.md). Если `n <= 1` (`n` — размер выборки), тогда функция возвращает `nan`. + +**Пример** + +``` sql +SELECT kurtSamp(value) FROM series_with_value_column +``` + +## timeSeriesGroupSum(uid, timestamp, value) {#agg-function-timeseriesgroupsum} + +`timeSeriesGroupSum` агрегирует временные ряды в которых не совпадают моменты. +Функция использует линейную интерполяцию между двумя значениями времени, а затем суммирует значения для одного и того же момента (как измеренные так и интерполированные) по всем рядам. + +- `uid` уникальный идентификатор временного ряда, `UInt64`. +- `timestamp` имеет тип `Int64` чтобы можно было учитывать милли и микросекунды. +- `value` представляет собой значение метрики. + +Функция возвращает массив кортежей с парами `(timestamp, aggregated_value)`. + +Временные ряды должны быть отсортированы по возрастанию `timestamp`. + +Пример: + +``` text +┌─uid─┬─timestamp─┬─value─┐ +│ 1 │ 2 │ 0.2 │ +│ 1 │ 7 │ 0.7 │ +│ 1 │ 12 │ 1.2 │ +│ 1 │ 17 │ 1.7 │ +│ 1 │ 25 │ 2.5 │ +│ 2 │ 3 │ 0.6 │ +│ 2 │ 8 │ 1.6 │ +│ 2 │ 12 │ 2.4 │ +│ 2 │ 18 │ 3.6 │ +│ 2 │ 24 │ 4.8 │ +└─────┴───────────┴───────┘ +``` + +``` sql +CREATE TABLE time_series( + uid UInt64, + timestamp Int64, + value Float64 +) ENGINE = Memory; +INSERT INTO time_series VALUES + (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), + (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); + +SELECT timeSeriesGroupSum(uid, timestamp, value) +FROM ( + SELECT * FROM time_series order by timestamp ASC +); +``` + +И результат будет: + +``` text +[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] +``` + +## timeSeriesGroupRateSum(uid, ts, val) {#agg-function-timeseriesgroupratesum} + +Аналогично timeSeriesGroupSum, timeSeriesGroupRateSum будет вычислять производные по timestamp для рядов, а затем суммировать полученные производные для всех рядов для одного значения timestamp. +Также ряды должны быть отсортированы по возрастанию timestamp. + +Для пример из описания timeSeriesGroupSum результат будет следующим: + +``` text +[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] +``` + +## avg(x) {#agg_function-avg} + +Вычисляет среднее. +Работает только для чисел. +Результат всегда Float64. + +## avgWeighted {#avgweighted} + +Вычисляет [среднее арифметическое взвешенное](https://ru.wikipedia.org/wiki/Среднее_арифметическое_взвешенное). + +**Синтаксис** + +``` sql +avgWeighted(x, weight) +``` + +**Параметры** + +- `x` — Значения. [Целые числа](../../sql-reference/aggregate-functions/reference.md) или [числа с плавающей запятой](../../sql-reference/aggregate-functions/reference.md). +- `weight` — Веса отдельных значений. [Целые числа](../../sql-reference/aggregate-functions/reference.md) или [числа с плавающей запятой](../../sql-reference/aggregate-functions/reference.md). + +Типы параметров должны совпадать. + +**Возвращаемое значение** + +- Среднее арифметическое взвешенное. +- `NaN`, если все веса равны 0. + +Тип: [Float64](../../sql-reference/aggregate-functions/reference.md) + +**Пример** + +Запрос: + +``` sql +SELECT avgWeighted(x, w) +FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) +``` + +Результат: + +``` text +┌─avgWeighted(x, weight)─┐ +│ 8 │ +└────────────────────────┘ +``` + +## uniq {#agg_function-uniq} + +Приближённо вычисляет количество различных значений аргумента. + +``` sql +uniq(x[, ...]) +``` + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. + +**Возвращаемое значение** + +- Значение с типом данных [UInt64](../../sql-reference/aggregate-functions/reference.md). + +**Детали реализации** + +Функция: + +- Вычисляет хэш для всех параметров агрегации, а затем использует его в вычислениях. + +- Использует адаптивный алгоритм выборки. В качестве состояния вычисления функция использует выборку хэш-значений элементов размером до 65536. + + Этот алгоритм очень точен и очень эффективен по использованию CPU. Если запрос содержит небольшое количество этих функций, использование `uniq` почти так же эффективно, как и использование других агрегатных функций. + +- Результат детерминирован (не зависит от порядка выполнения запроса). + +Эту функцию рекомендуется использовать практически во всех сценариях. + +**Смотрите также** + +- [uniqCombined](#agg_function-uniqcombined) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined {#agg_function-uniqcombined} + +Приближённо вычисляет количество различных значений аргумента. + +``` sql +uniqCombined(HLL_precision)(x[, ...]) +``` + +Функция `uniqCombined` — это хороший выбор для вычисления количества различных значений. + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. + +`HLL_precision` — это логарифм по основанию 2 от числа ячеек в [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). Необязательный, можно использовать функцию как `uniqCombined (x [,...])`. Для `HLL_precision` значение по умолчанию — 17, что фактически составляет 96 КБ пространства (2^17 ячеек, 6 бит каждая). + +**Возвращаемое значение** + +- Число типа [UInt64](../../sql-reference/aggregate-functions/reference.md). + +**Детали реализации** + +Функция: + +- Вычисляет хэш (64-битный для `String` и 32-битный для всех остальных типов) для всех параметров агрегации, а затем использует его в вычислениях. + +- Используется комбинация трёх алгоритмов: массив, хэш-таблица и HyperLogLog с таблицей коррекции погрешности. + + Для небольшого количества различных значений используется массив. Если размер набора больше, используется хэш-таблица. При дальнейшем увеличении количества значений, используется структура HyperLogLog, имеющая фиксированный размер в памяти. + +- Результат детерминирован (не зависит от порядка выполнения запроса). + +!!! note "Note" + Так как используется 32-битный хэш для не-`String` типов, результат будет иметь очень очень большую ошибку для количества разичных элементов существенно больше `UINT_MAX` (ошибка быстро растёт начиная с нескольких десятков миллиардов различных значений), таким образом в этом случае нужно использовать [uniqCombined64](#agg_function-uniqcombined64) + +По сравнению с функцией [uniq](#agg_function-uniq), `uniqCombined`: + +- Потребляет в несколько раз меньше памяти. +- Вычисляет с в несколько раз более высокой точностью. +- Обычно имеет немного более низкую производительность. В некоторых сценариях `uniqCombined` может показывать более высокую производительность, чем `uniq`, например, в случае распределенных запросов, при которых по сети передаётся большое количество состояний агрегации. + +**Смотрите также** + +- [uniq](#agg_function-uniq) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined64 {#agg_function-uniqcombined64} + +Использует 64-битный хэш для всех типов, в отличие от [uniqCombined](#agg_function-uniqcombined). + +## uniqHLL12 {#agg_function-uniqhll12} + +Вычисляет приблизительное число различных значений аргументов, используя алгоритм [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). + +``` sql +uniqHLL12(x[, ...]) +``` + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. + +**Возвращаемое значение** + +- Значение хэша с типом данных [UInt64](../../sql-reference/aggregate-functions/reference.md). + +**Детали реализации** + +Функция: + +- Вычисляет хэш для всех параметров агрегации, а затем использует его в вычислениях. + +- Использует алгоритм HyperLogLog для аппроксимации числа различных значений аргументов. + + Используется 212 5-битовых ячеек. Размер состояния чуть больше 2.5 КБ. Результат не точный (ошибка до ~10%) для небольших множеств (<10K элементов). Однако для множеств большой кардинальности (10K - 100M) результат довольно точен (ошибка до ~1.6%). Начиная с 100M ошибка оценки будет только расти и для множеств огромной кардинальности (1B+ элементов) функция возвращает результат с очень большой неточностью. + +- Результат детерминирован (не зависит от порядка выполнения запроса). + +Мы не рекомендуем использовать эту функцию. В большинстве случаев используйте функцию [uniq](#agg_function-uniq) или [uniqCombined](#agg_function-uniqcombined). + +**Смотрите также** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqExact](#agg_function-uniqexact) + +## uniqExact {#agg_function-uniqexact} + +Вычисляет точное количество различных значений аргументов. + +``` sql +uniqExact(x[, ...]) +``` + +Функцию `uniqExact` следует использовать, если вам обязательно нужен точный результат. В противном случае используйте функцию [uniq](#agg_function-uniq). + +Функция `uniqExact` расходует больше оперативной памяти, чем функция `uniq`, так как размер состояния неограниченно растёт по мере роста количества различных значений. + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. + +**Смотрите также** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqHLL12](#agg_function-uniqhll12) + +## groupArray(x), groupArray(max\_size)(x) {#agg_function-grouparray} + +Составляет массив из значений аргумента. +Значения в массив могут быть добавлены в любом (недетерминированном) порядке. + +Вторая версия (с параметром `max_size`) ограничивает размер результирующего массива `max_size` элементами. +Например, `groupArray(1)(x)` эквивалентно `[any(x)]`. + +В некоторых случаях, вы всё же можете рассчитывать на порядок выполнения запроса. Это — случаи, когда `SELECT` идёт из подзапроса, в котором используется `ORDER BY`. + +## groupArrayInsertAt {#grouparrayinsertat} + +Вставляет значение в заданную позицию массива. + +**Синтаксис** + +```sql +groupArrayInsertAt(default_x, size)(x, pos); +``` + +Если запрос вставляет вставляется несколько значений в одну и ту же позицию, то функция ведет себя следующим образом: + +- Если запрос выполняется в одном потоке, то используется первое из вставляемых значений. +- Если запрос выполняется в нескольких потоках, то в результирующем массиве может оказаться любое из вставляемых значений. + +**Параметры** + +- `x` — Значение, которое будет вставлено. [Выражение](../syntax.md#syntax-expressions), возвращающее значение одного из [поддерживаемых типов данных](../../sql-reference/data-types/index.md#data_types). +- `pos` — Позиция, в которую вставляется заданный элемент `x`. Нумерация индексов в массиве начинается с нуля. [UInt32](../../sql-reference/data-types/int-uint.md#uint8-uint16-uint32-uint64-int8-int16-int32-int64). +- `default_x` — Значение по умолчанию для подстановки на пустые позиции. Опциональный параметр. [Выражение](../syntax.md#syntax-expressions), возвращающее значение с типом параметра `x`. Если `default_x` не определен, используются [значения по умолчанию](../../sql-reference/statements/create.md#create-default-values). +- `size`— Длина результирующего массива. Опциональный параметр. При использовании этого параметра должно быть указано значение по умолчанию `default_x`. [UInt32](../../sql-reference/data-types/int-uint.md#uint-ranges). + +**Возвращаемое значение** + +- Массив со вставленными значениями. + +Тип: [Array](../../sql-reference/data-types/array.md#data-type-array). + +**Примеры** + +Запрос: + +```sql +SELECT groupArrayInsertAt(toString(number), number * 2) FROM numbers(5); +``` + +Результат: + +```text +┌─groupArrayInsertAt(toString(number), multiply(number, 2))─┐ +│ ['0','','1','','2','','3','','4'] │ +└───────────────────────────────────────────────────────────┘ +``` + +Запрос: + +```sql +SELECT groupArrayInsertAt('-')(toString(number), number * 2) FROM numbers(5); +``` + +Результат: + +```text +┌─groupArrayInsertAt('-')(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2','-','3','-','4'] │ +└────────────────────────────────────────────────────────────────┘ +``` + +Запрос: + +```sql +SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); +``` + +Результат: + +```text +┌─groupArrayInsertAt('-', 5)(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2'] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +Многопоточная вставка элементов в одну позицию. + +Запрос: + +```sql +SELECT groupArrayInsertAt(number, 0) FROM numbers_mt(10) SETTINGS max_block_size = 1; +``` + +В результат этого запроса мы получите случайное целое число в диапазоне `[0,9]`. Например: + +```text +┌─groupArrayInsertAt(number, 0)─┐ +│ [7] │ +└───────────────────────────────┘ +``` + + +## groupArrayMovingSum {#agg_function-grouparraymovingsum} + +Вычисляет скользящую сумму входных значений. + +``` sql +groupArrayMovingSum(numbers_for_summing) +groupArrayMovingSum(window_size)(numbers_for_summing) +``` + +Функция может принимать размер окна в качестве параметра. Если окно не указано, то функция использует размер окна, равный количеству строк в столбце. + +**Параметры** + +- `numbers_for_summing` — [выражение](../syntax.md#syntax-expressions), возвращающее значение числового типа. +- `window_size` — размер окна. + +**Возвращаемые значения** + +- Массив того же размера и типа, что и входные данные. + +**Пример** + +Таблица с исходными данными: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Запросы: + +``` sql +SELECT + groupArrayMovingSum(int) AS I, + groupArrayMovingSum(float) AS F, + groupArrayMovingSum(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingSum(2)(int) AS I, + groupArrayMovingSum(2)(float) AS F, + groupArrayMovingSum(2)(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +## groupArrayMovingAvg {#agg_function-grouparraymovingavg} + +Вычисляет скользящее среднее для входных значений. + + groupArrayMovingAvg(numbers_for_summing) + groupArrayMovingAvg(window_size)(numbers_for_summing) + +Функция может принимать размер окна в качестве параметра. Если окно не указано, то функция использует размер окна, равный количеству строк в столбце. + +**Параметры** + +- `numbers_for_summing` — [выражение](../syntax.md#syntax-expressions), возвращающее значение числового типа. +- `window_size` — размер окна. + +**Возвращаемые значения** + +- Массив того же размера и типа, что и входные данные. + +Функция использует [округление к меньшему по модулю](https://ru.wikipedia.org/wiki/Округление#Методы). Оно усекает десятичные разряды, незначимые для результирующего типа данных. + +**Пример** + +Таблица с исходными данными: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Запросы: + +``` sql +SELECT + groupArrayMovingAvg(int) AS I, + groupArrayMovingAvg(float) AS F, + groupArrayMovingAvg(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ +│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ +└───────────┴─────────────────────────────────────┴───────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingAvg(2)(int) AS I, + groupArrayMovingAvg(2)(float) AS F, + groupArrayMovingAvg(2)(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ +│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ +└───────────┴──────────────────────────────────┴───────────────────────┘ +``` + +## groupUniqArray(x), groupUniqArray(max\_size)(x) {#groupuniqarrayx-groupuniqarraymax-sizex} + +Составляет массив из различных значений аргумента. Расход оперативной памяти такой же, как у функции `uniqExact`. + +Функция `groupUniqArray(max_size)(x)` ограничивает размер результирующего массива до `max_size` элементов. Например, `groupUniqArray(1)(x)` равнозначно `[any(x)]`. + +## quantile {#quantile} + +Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. + +Функция использует алгоритм [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) с размером резервуара до 8192 и случайным генератором чисел для для сэмплирования. Результат не детерминирован. Чтобы получить точную квантиль используйте функцию [quantileExact](#quantileexact). + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantile(level)(expr) +``` + +Алиас: `median`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql-reference/aggregate-functions/reference.md#data_types) или типов [Date](../../sql-reference/aggregate-functions/reference.md), [DateTime](../../sql-reference/aggregate-functions/reference.md). + +**Возвращаемое значение** + +- Приблизительный квантиль заданного уровня. + +Тип: + +- [Float64](../../sql-reference/aggregate-functions/reference.md) для входных данных числового типа. +- [Date](../../sql-reference/aggregate-functions/reference.md), если входные значения имеют тип `Date`. +- [DateTime](../../sql-reference/aggregate-functions/reference.md), если входные значения имеют тип `DateTime`. + +**Пример** + +Входная таблица: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Запрос: + +``` sql +SELECT quantile(val) FROM t +``` + +Результат: + +``` text +┌─quantile(val)─┐ +│ 1.5 │ +└───────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileDeterministic {#quantiledeterministic} + +Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. + +Функция использует алгоритм [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) с размером резервуара до 8192 и детерминированным алгоритмом сэмплирования. Результат детерминирован. Чтобы получить точную квантиль используйте функцию [quantileExact](#quantileexact). + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileDeterministic(level)(expr, determinator) +``` + +Алиас: `medianDeterministic`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql-reference/aggregate-functions/reference.md#data_types) или типов [Date](../../sql-reference/aggregate-functions/reference.md), [DateTime](../../sql-reference/aggregate-functions/reference.md). +- `determinator` — Число, хэш которого используется при сэмплировании в алгоритме reservoir sampling, чтобы сделать результат детерминированным. В качестве детерминатора можно использовать любое определённое положительное число, например, идентификатор пользователя или события. Если одно и то же значение детерминатора попадается в выборке слишком часто, то функция выдаёт некорректный результат. + +**Возвращаемое значение** + +- Приблизительный квантиль заданного уровня. + +Тип: + +- [Float64](../../sql-reference/aggregate-functions/reference.md) для входных данных числового типа. +- [Date](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `Date`. +- [DateTime](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Входная таблица: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Запрос: + +``` sql +SELECT quantileDeterministic(val, 1) FROM t +``` + +Результат: + +``` text +┌─quantileDeterministic(val, 1)─┐ +│ 1.5 │ +└───────────────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileExact {#quantileexact} + +Точно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. + +Чтобы получить точный результат, все переданные значения собираются в массив, который затем частично сортируется. Таким образом, функция потребляет объем памяти `O(n)`, где `n` — количество переданных значений. Для небольшого числа значений эта функция эффективна. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileExact(level)(expr) +``` + +Алиас: `medianExact`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql-reference/aggregate-functions/reference.md#data_types) или типов [Date](../../sql-reference/aggregate-functions/reference.md), [DateTime](../../sql-reference/aggregate-functions/reference.md). + +**Возвращаемое значение** + +- Квантиль заданного уровня. + +Тип: + +- [Float64](../../sql-reference/aggregate-functions/reference.md) для входных данных числового типа. +- [Date](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `Date`. +- [DateTime](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Запрос: + +``` sql +SELECT quantileExact(number) FROM numbers(10) +``` + +Результат: + +``` text +┌─quantileExact(number)─┐ +│ 5 │ +└───────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileExactWeighted {#quantileexactweighted} + +Точно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, учитывая вес каждого её элемента. + +Чтобы получить точный результат, все переданные значения собираются в массив, который затем частично сортируется. Для каждого значения учитывается его вес (количество значений в выборке). В алгоритме используется хэш-таблица. Таким образом, если переданные значения часто повторяются, функция потребляет меньше оперативной памяти, чем [quantileExact](#quantileexact). Эту функцию можно использовать вместо `quantileExact` если указать вес 1. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileExactWeighted(level)(expr, weight) +``` + +Алиас: `medianExactWeighted`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql-reference/aggregate-functions/reference.md#data_types) или типов [Date](../../sql-reference/aggregate-functions/reference.md), [DateTime](../../sql-reference/aggregate-functions/reference.md). +- `weight` — Столбец с весам элементов последовательности. Вес — это количество повторений элемента в последовательности. + +**Возвращаемое значение** + +- Quantile of the specified level. + +Тип: + +- [Float64](../../sql-reference/aggregate-functions/reference.md) для входных данных числового типа. +- [Date](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `Date`. +- [DateTime](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Входная таблица: + +``` text +┌─n─┬─val─┐ +│ 0 │ 3 │ +│ 1 │ 2 │ +│ 2 │ 1 │ +│ 5 │ 4 │ +└───┴─────┘ +``` + +Запрос: + +``` sql +SELECT quantileExactWeighted(n, val) FROM t +``` + +Результат: + +``` text +┌─quantileExactWeighted(n, val)─┐ +│ 1 │ +└───────────────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTiming {#quantiletiming} + +Вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности с детерминированной точностью. + +Результат детерминирован (не зависит от порядка обработки запроса). Функция оптимизирована для работы с последовательностями, описывающими такие распределения, как время загрузки веб-страниц или время отклика бэкенда. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileTiming(level)(expr) +``` + +Алиас: `medianTiming`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). + +- `expr` — [Выражение](../syntax.md#syntax-expressions) над значения столбца, которые возвращают данные типа [Float\*](../../sql-reference/aggregate-functions/reference.md). + + - Если в функцию передать отрицательные значения, то её поведение не определено. + - Если значение больше, чем 30 000 (например, время загрузки страницы превышает 30 секунд), то оно приравнивается к 30 000. + +**Точность** + +Вычисления точны при соблюдении следующих условий: + +- Размер выборки не превышает 5670 элементов. +- Размер выборки превышает 5670 элементов, но значение каждого элемента не больше 1024. + +В противном случае, результат вычисления округляется до ближайшего множителя числа 16. + +!!! note "Примечание" + Для указанного типа последовательностей функция производительнее и точнее, чем [quantile](#quantile). + +**Возвращаемое значение** + +- Квантиль заданного уровня. + +Тип: `Float32`. + +!!! note "Примечания" + Если в функцию `quantileTimingIf` не передать значений, то вернётся [NaN](../../sql-reference/aggregate-functions/reference.md#data_type-float-nan-inf). Это необходимо для отделения подобных случаев от случаев, когда результат 0. Подробности про сортировку `NaN` cмотрите в разделе [Секция ORDER BY](../../sql-reference/statements/select/order-by.md#select-order-by). + +**Пример** + +Входная таблица: + +``` text +┌─response_time─┐ +│ 72 │ +│ 112 │ +│ 126 │ +│ 145 │ +│ 104 │ +│ 242 │ +│ 313 │ +│ 168 │ +│ 108 │ +└───────────────┘ +``` + +Запрос: + +``` sql +SELECT quantileTiming(response_time) FROM t +``` + +Результат: + +``` text +┌─quantileTiming(response_time)─┐ +│ 126 │ +└───────────────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTimingWeighted {#quantiletimingweighted} + +С детерминированной точностью вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, учитывая вес каждого элемента. + +Результат детерминирован (не зависит от порядка обработки запроса). Функция оптимизирована для работы с последовательностями, описывающими такие распределения, как время загрузки веб-страниц или время отклика бэкенда. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileTimingWeighted(level)(expr, weight) +``` + +Алиас: `medianTimingWeighted`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). + +- `expr` — [Выражение](../syntax.md#syntax-expressions) над значения столбца, которые возвращают данные типа [Float\*](../../sql-reference/aggregate-functions/reference.md). + + - Если в функцию передать отрицательные значения, то её поведение не определено. + - Если значение больше, чем 30 000 (например, время загрузки страницы превышает 30 секунд), то оно приравнивается к 30 000. + +- `weight` — Столбец с весам элементов последовательности. Вес — это количество повторений элемента в последовательности. + +**Точность** + +Вычисления точны при соблюдении следующих условий: + +- Размер выборки не превышает 5670 элементов. +- Размер выборки превышает 5670 элементов, но значение каждого элемента не больше 1024. + +В противном случае, результат вычисления округляется до ближайшего множителя числа 16. + +!!! note "Примечание" + Для указанного типа последовательностей функция производительнее и точнее, чем [quantile](#quantile). + +**Возвращаемое значение** + +- Квантиль заданного уровня. + +Тип: `Float32`. + +!!! note "Примечания" + Если в функцию `quantileTimingIf` не передать значений, то вернётся [NaN](../../sql-reference/aggregate-functions/reference.md#data_type-float-nan-inf). Это необходимо для отделения подобных случаев от случаев, когда результат 0. Подробности про сортировку `NaN` cмотрите в разделе [Секция ORDER BY](../../sql-reference/statements/select/order-by.md#select-order-by). + +**Пример** + +Входная таблица: + +``` text +┌─response_time─┬─weight─┐ +│ 68 │ 1 │ +│ 104 │ 2 │ +│ 112 │ 3 │ +│ 126 │ 2 │ +│ 138 │ 1 │ +│ 162 │ 1 │ +└───────────────┴────────┘ +``` + +Запрос: + +``` sql +SELECT quantileTimingWeighted(response_time, weight) FROM t +``` + +Результат: + +``` text +┌─quantileTimingWeighted(response_time, weight)─┐ +│ 112 │ +└───────────────────────────────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTDigest {#quantiletdigest} + +Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, используя алгоритм [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf). + +Максимальная ошибка 1%. Потребление памяти — `log(n)`, где `n` — число значений. Результат не детерминирован и зависит от порядка выполнения запроса. + +Производительность функции ниже, чем производительность функции [quantile](#quantile) или [quantileTiming](#quantiletiming). По соотношению размера состояния к точности вычисления, эта функция значительно превосходит `quantile`. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileTDigest(level)(expr) +``` + +Алиас: `medianTDigest`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql-reference/aggregate-functions/reference.md#data_types) или типов [Date](../../sql-reference/aggregate-functions/reference.md), [DateTime](../../sql-reference/aggregate-functions/reference.md). + +**Возвращаемое значение** + +- Приблизительную квантиль заданного уровня. + +Тип: + +- [Float64](../../sql-reference/aggregate-functions/reference.md) для входных данных числового типа. +- [Date](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `Date`. +- [DateTime](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Запрос: + +``` sql +SELECT quantileTDigest(number) FROM numbers(10) +``` + +Результат: + +``` text +┌─quantileTDigest(number)─┐ +│ 4.5 │ +└─────────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## quantileTDigestWeighted {#quantiletdigestweighted} + +Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, используя алгоритм [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf). Функция учитывает вес каждого элемента последовательности. + +Максимальная ошибка 1%. Потребление памяти — `log(n)`, где `n` — число значений. Результат не детерминирован и зависит от порядка выполнения запроса. + +Производительность функции ниже, чем производительность функции [quantile](#quantile) или [quantileTiming](#quantiletiming). По соотношению размера состояния к точности вычисления, эта функция значительно превосходит `quantile`. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileTDigestWeighted(level)(expr, weight) +``` + +Алиас: `medianTDigest`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql-reference/aggregate-functions/reference.md#data_types) или типов [Date](../../sql-reference/aggregate-functions/reference.md), [DateTime](../../sql-reference/aggregate-functions/reference.md). +- `weight` — Столбец с весам элементов последовательности. Вес — это количество повторений элемента в последовательности. + +**Возвращаемое значение** + +- Приблизительный квантиль заданного уровня. + +Тип: + +- [Float64](../../sql-reference/aggregate-functions/reference.md) для входных данных числового типа. +- [Date](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `Date`. +- [DateTime](../../sql-reference/aggregate-functions/reference.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Запрос: + +``` sql +SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) +``` + +Результат: + +``` text +┌─quantileTDigestWeighted(number, 1)─┐ +│ 4.5 │ +└────────────────────────────────────┘ +``` + +**Смотрите также** + +- [median](#median) +- [quantiles](#quantiles) + +## median {#median} + +Функции `median*` — алиасы для соответствущих функций `quantile*`. Они вычисляют медиану числовой последовательности. + +Functions: + +- `median` — алиас [quantile](#quantile). +- `medianDeterministic` — алиас [quantileDeterministic](#quantiledeterministic). +- `medianExact` — алиас [quantileExact](#quantileexact). +- `medianExactWeighted` — алиас [quantileExactWeighted](#quantileexactweighted). +- `medianTiming` — алиас [quantileTiming](#quantiletiming). +- `medianTimingWeighted` — алиас [quantileTimingWeighted](#quantiletimingweighted). +- `medianTDigest` — алиас [quantileTDigest](#quantiletdigest). +- `medianTDigestWeighted` — алиас [quantileTDigestWeighted](#quantiletdigestweighted). + +**Пример** + +Входная таблица: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Запрос: + +``` sql +SELECT medianDeterministic(val, 1) FROM t +``` + +Результат: + +``` text +┌─medianDeterministic(val, 1)─┐ +│ 1.5 │ +└─────────────────────────────┘ +``` + +## quantiles(level1, level2, …)(x) {#quantiles} + +Для всех quantile-функций, также присутствуют соответствующие quantiles-функции: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. Эти функции за один проход вычисляют все квантили перечисленных уровней и возвращают массив вычисленных значений. + +## varSamp(x) {#varsampx} + +Вычисляет величину `Σ((x - x̅)^2) / (n - 1)`, где `n` - размер выборки, `x̅`- среднее значение `x`. + +Она представляет собой несмещённую оценку дисперсии случайной величины, если переданные в функцию значения являются выборкой этой случайной величины. + +Возвращает `Float64`. В случае, когда `n <= 1`, возвращается `+∞`. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `varSampStable`. Она работает медленнее, но обеспечиват меньшую вычислительную ошибку. + +## varPop(x) {#varpopx} + +Вычисляет величину `Σ((x - x̅)^2) / n`, где `n` - размер выборки, `x̅`- среднее значение `x`. + +То есть, дисперсию для множества значений. Возвращает `Float64`. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `varPopStable`. Она работает медленнее, но обеспечивает меньшую вычислительную ошибку. + +## stddevSamp(x) {#stddevsampx} + +Результат равен квадратному корню от `varSamp(x)`. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `stddevSampStable`. Она работает медленнее, но обеспечивает меньшую вычислительную ошибку. + +## stddevPop(x) {#stddevpopx} + +Результат равен квадратному корню от `varPop(x)`. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `stddevPopStable`. Она работает медленнее, но обеспечивает меньшую вычислительную ошибку. + + +## topK(N)(column) {#topkncolumn} + +Возвращает массив наиболее часто встречающихся значений в указанном столбце. Результирующий массив упорядочен по убыванию частоты значения (не по самим значениям). + +Реализует [Filtered Space-Saving](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) алгоритм для анализа TopK, на основе reduce-and-combine алгоритма из методики [Parallel Space Saving](https://arxiv.org/pdf/1401.0702.pdf). + +``` sql +topK(N)(column) +``` + +Функция не дает гарантированного результата. В некоторых ситуациях могут возникать ошибки, и функция возвращает частые, но не наиболее частые значения. + +Рекомендуем использовать значения `N < 10`, при больших `N` снижается производительность. Максимально возможное значение `N = 65536`. + +**Аргументы** + +- ‘N’ - Количество значений. +- ‘x’ – Столбец. + +**Пример** + +Возьмём набор данных [OnTime](../../getting-started/example-datasets/ontime.md) и выберем 3 наиболее часто встречающихся значения в столбце `AirlineID`. + +``` sql +SELECT topK(3)(AirlineID) AS res +FROM ontime +``` + +``` text +┌─res─────────────────┐ +│ [19393,19790,19805] │ +└─────────────────────┘ +``` + +## topKWeighted {#topkweighted} + +Аналогична `topK`, но дополнительно принимает положительный целочисленный параметр `weight`. Каждое значение учитывается `weight` раз при расчёте частоты. + +**Синтаксис** + +``` sql +topKWeighted(N)(x, weight) +``` + +**Параметры** + +- `N` — Количество элементов для выдачи. + +**Аргументы** + +- `x` – значение. +- `weight` — вес. [UInt8](../../sql-reference/aggregate-functions/reference.md). + +**Возвращаемое значение** + +Возвращает массив значений с максимально приближенной суммой весов. + +**Пример** + +Запрос: + +``` sql +SELECT topKWeighted(10)(number, number) FROM numbers(1000) +``` + +Результат: + +``` text +┌─topKWeighted(10)(number, number)──────────┐ +│ [999,998,997,996,995,994,993,992,991,990] │ +└───────────────────────────────────────────┘ +``` + +## covarSamp(x, y) {#covarsampx-y} + +Вычисляет величину `Σ((x - x̅)(y - y̅)) / (n - 1)`. + +Возвращает Float64. В случае, когда `n <= 1`, возвращается +∞. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `covarSampStable`. Она работает медленнее, но обеспечивает меньшую вычислительную ошибку. + +## covarPop(x, y) {#covarpopx-y} + +Вычисляет величину `Σ((x - x̅)(y - y̅)) / n`. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `covarPopStable`. Она работает медленнее, но обеспечивает меньшую вычислительную ошибку. + + +## corr(x, y) {#corrx-y} + +Вычисляет коэффициент корреляции Пирсона: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. + +!!! note "Примечание" + Функция использует вычислительно неустойчивый алгоритм. Если для ваших расчётов необходима [вычислительная устойчивость](https://ru.wikipedia.org/wiki/Вычислительная_устойчивость), используйте функцию `corrStable`. Она работает медленнее, но обеспечивает меньшую вычислительную ошибку. + +## simpleLinearRegression {#simplelinearregression} + +Выполняет простую (одномерную) линейную регрессию. + +``` sql +simpleLinearRegression(x, y) +``` + +Параметры: + +- `x` — столбец со значениями зависимой переменной. +- `y` — столбец со значениями наблюдаемой переменной. + +Возвращаемые значения: + +Константы `(a, b)` результирующей прямой `y = a*x + b`. + +**Примеры** + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ +│ (1,0) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ +│ (1,3) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## stochasticLinearRegression {#agg_functions-stochasticlinearregression} + +Функция реализует стохастическую линейную регрессию. Поддерживает пользовательские параметры для скорости обучения, коэффициента регуляризации L2, размера mini-batch и имеет несколько методов обновления весов ([Adam](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (по умолчанию), [simple SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [Momentum](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). + +### Параметры {#agg_functions-stochasticlinearregression-parameters} + +Есть 4 настраиваемых параметра. Они передаются в функцию последовательно, однако не обязательно указывать все, используются значения по умолчанию, однако хорошая модель требует некоторой настройки параметров. + +``` text +stochasticLinearRegression(1.0, 1.0, 10, 'SGD') +``` + +1. Скорость обучения — коэффициент длины шага, при выполнении градиентного спуска. Слишком большая скорость обучения может привести к бесконечным весам модели. По умолчанию `0.00001`. +2. Коэффициент регуляризации l2. Помогает предотвратить подгонку. По умолчанию `0.1`. +3. Размер mini-batch задаёт количество элементов, чьи градиенты будут вычислены и просуммированы при выполнении одного шага градиентного спуска. Чистый стохастический спуск использует один элемент, однако использование mini-batch (около 10 элементов) делает градиентные шаги более стабильными. По умолчанию `15`. +4. Метод обновления весов, можно выбрать один из следующих: `Adam` (по умолчанию), `SGD`, `Momentum`, `Nesterov`. `Momentum` и `Nesterov` более требовательные к вычислительным ресурсам и памяти, однако они имеют высокую скорость схождения и устойчивости методов стохастического градиента. + +### Использование {#agg_functions-stochasticlinearregression-usage} + +`stochasticLinearRegression` используется на двух этапах: построение модели и предсказание новых данных. Чтобы построить модель и сохранить её состояние для дальнейшего использования, мы используем комбинатор `-State`. +Для прогнозирования мы используем функцию [evalMLMethod](../functions/machine-learning-functions.md#machine_learning_methods-evalmlmethod), которая принимает в качестве аргументов состояние и свойства для прогнозирования. + + + +**1.** Построение модели + +Пример запроса: + +``` sql +CREATE TABLE IF NOT EXISTS train_data +( + param1 Float64, + param2 Float64, + target Float64 +) ENGINE = Memory; + +CREATE TABLE your_model ENGINE = Memory AS SELECT +stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) +AS state FROM train_data; +``` + +Здесь нам также нужно вставить данные в таблицу `train_data`. Количество параметров не фиксировано, оно зависит только от количества аргументов, перешедших в `linearRegressionState`. Все они должны быть числовыми значениями. +Обратите внимание, что столбец с целевым значением (которое мы хотели бы научиться предсказывать) вставляется в качестве первого аргумента. + +**2.** Прогнозирование + +После сохранения состояния в таблице мы можем использовать его несколько раз для прогнозирования или смёржить с другими состояниями и создать новые, улучшенные модели. + +``` sql +WITH (SELECT state FROM your_model) AS model SELECT +evalMLMethod(model, param1, param2) FROM test_data +``` + +Запрос возвращает столбец прогнозируемых значений. Обратите внимание, что первый аргумент `evalMLMethod` это объект `AggregateFunctionState`, далее идут столбцы свойств. + +`test_data` — это таблица, подобная `train_data`, но при этом может не содержать целевое значение. + +### Примечания {#agg_functions-stochasticlinearregression-notes} + +1. Объединить две модели можно следующим запросом: + + + + ``` sql + SELECT state1 + state2 FROM your_models + ``` + +где таблица `your_models` содержит обе модели. Запрос вернёт новый объект `AggregateFunctionState`. + +1. Пользователь может получать веса созданной модели для своих целей без сохранения модели, если не использовать комбинатор `-State`. + + + + ``` sql + SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data + ``` + +Подобный запрос строит модель и возвращает её веса, отвечающие параметрам моделей и смещение. Таким образом, в приведенном выше примере запрос вернет столбец с тремя значениями. + +**Смотрите также** + +- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) +- [Отличие линейной от логистической регрессии.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} + +Функция реализует стохастическую логистическую регрессию. Её можно использовать для задачи бинарной классификации, функция поддерживает те же пользовательские параметры, что и stochasticLinearRegression и работает таким же образом. + +### Параметры {#agg_functions-stochasticlogisticregression-parameters} + +Параметры те же, что и в stochasticLinearRegression: +`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. +Смотрите раздел [parameters](#agg_functions-stochasticlinearregression-parameters). + +``` text +stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') +``` + +1. Построение модели + + + +Смотрите раздел `Построение модели` в описании [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) . + + Прогнозируемые метки должны быть в диапазоне \[-1, 1\]. + +1. Прогнозирование + + + +Используя сохраненное состояние, можно предсказать вероятность наличия у объекта метки `1`. + + ``` sql + WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) FROM test_data + ``` + +Запрос возвращает столбец вероятностей. Обратите внимание, что первый аргумент `evalMLMethod` это объект `AggregateFunctionState`, далее идут столбцы свойств. + +Мы также можем установить границу вероятности, которая присваивает элементам различные метки. + + ``` sql + SELECT ans < 1.1 AND ans > 0.5 FROM + (WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) AS ans FROM test_data) + ``` + +Тогда результатом будут метки. + +`test_data` — это таблица, подобная `train_data`, но при этом может не содержать целевое значение. + +**Смотрите также** + +- [stochasticLinearRegression](#agg_functions-stochasticlinearregression) +- [Отличие линейной от логистической регрессии](https://moredez.ru/q/51225972/) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/reference/) diff --git a/docs/ru/sql-reference/ansi.md b/docs/ru/sql-reference/ansi.md new file mode 120000 index 00000000000..3cf6bffed67 --- /dev/null +++ b/docs/ru/sql-reference/ansi.md @@ -0,0 +1 @@ +../../en/sql-reference/ansi.md \ No newline at end of file diff --git a/docs/ru/sql-reference/data-types/aggregatefunction.md b/docs/ru/sql-reference/data-types/aggregatefunction.md new file mode 100644 index 00000000000..c6680197966 --- /dev/null +++ b/docs/ru/sql-reference/data-types/aggregatefunction.md @@ -0,0 +1,63 @@ +# AggregateFunction {#data-type-aggregatefunction} + +Промежуточное состояние агрегатной функции. Чтобы его получить, используются агрегатные функции с суффиксом `-State`. Чтобы в дальнейшем получить агрегированные данные необходимо использовать те же агрегатные функции с суффиксом `-Merge`. + +`AggregateFunction(name, types\_of\_arguments…)` — параметрический тип данных. + +**Параметры** + +- Имя агрегатной функции. + + Для параметрических агрегатных функций указываются также их параметры. + +- Типы аргументов агрегатной функции. + +**Пример** + +``` sql +CREATE TABLE t +( + column1 AggregateFunction(uniq, UInt64), + column2 AggregateFunction(anyIf, String, UInt8), + column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) +) ENGINE = ... +``` + +[uniq](../../sql-reference/data-types/aggregatefunction.md#agg_function-uniq), anyIf ([any](../../sql-reference/data-types/aggregatefunction.md#agg_function-any)+[If](../../sql-reference/data-types/aggregatefunction.md#agg-functions-combinator-if)) и [quantiles](../../sql-reference/data-types/aggregatefunction.md) — агрегатные функции, поддержанные в ClickHouse. + +## Особенности использования {#osobennosti-ispolzovaniia} + +### Вставка данных {#vstavka-dannykh} + +Для вставки данных используйте `INSERT SELECT` с агрегатными `-State`-функциями. + +**Примеры функций** + +``` sql +uniqState(UserID) +quantilesState(0.5, 0.9)(SendTiming) +``` + +В отличие от соответствующих функций `uniq` и `quantiles`, `-State`-функциями возвращают не готовое значение, а состояние. То есть, значение типа `AggregateFunction`. + +В запросах `SELECT` значения типа `AggregateFunction` выводятся во всех форматах, которые поддерживает ClickHouse, в виде implementation-specific бинарных данных. Если с помощью `SELECT` выполнить дамп данных, например, в формат `TabSeparated`, то потом этот дамп можно загрузить обратно с помощью запроса `INSERT`. + +### Выборка данных {#vyborka-dannykh} + +При выборке данных из таблицы `AggregatingMergeTree`, используйте `GROUP BY` и те же агрегатные функции, что и при вставке данных, но с суффиксом `-Merge`. + +Агрегатная функция с суффиксом `-Merge` берёт множество состояний, объединяет их, и возвращает результат полной агрегации данных. + +Например, следующие два запроса возвращают один и тот же результат: + +``` sql +SELECT uniq(UserID) FROM table + +SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) +``` + +## Пример использования {#primer-ispolzovaniia} + +Смотрите в описании движка [AggregatingMergeTree](../../sql-reference/data-types/aggregatefunction.md). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/ru/sql-reference/data-types/array.md b/docs/ru/sql-reference/data-types/array.md new file mode 100644 index 00000000000..09973d8162c --- /dev/null +++ b/docs/ru/sql-reference/data-types/array.md @@ -0,0 +1,72 @@ +# Array(T) {#data-type-array} + +Массив из элементов типа `T`. + +`T` может любым, в том числе, массивом. Таким образом поддержаны многомерные массивы. + +## Создание массива {#sozdanie-massiva} + +Массив можно создать с помощью функции: + +``` sql +array(T) +``` + +Также можно использовать квадратные скобки + +``` sql +[] +``` + +Пример создания массива: + +``` sql +SELECT array(1, 2) AS x, toTypeName(x) +``` + +``` text +┌─x─────┬─toTypeName(array(1, 2))─┐ +│ [1,2] │ Array(UInt8) │ +└───────┴─────────────────────────┘ +``` + +``` sql +SELECT [1, 2] AS x, toTypeName(x) +``` + +``` text +┌─x─────┬─toTypeName([1, 2])─┐ +│ [1,2] │ Array(UInt8) │ +└───────┴────────────────────┘ +``` + +## Особенности работы с типами данных {#osobennosti-raboty-s-tipami-dannykh} + +При создании массива «на лету» ClickHouse автоматически определяет тип аргументов как наиболее узкий тип данных, в котором можно хранить все перечисленные аргументы. Если среди аргументов есть [NULL](../../sql-reference/data-types/array.md#null-literal) или аргумент типа [Nullable](nullable.md#data_type-nullable), то тип элементов массива — [Nullable](nullable.md). + +Если ClickHouse не смог подобрать тип данных, то он сгенерирует исключение. Это произойдёт, например, при попытке создать массив одновременно со строками и числами `SELECT array(1, 'a')`. + +Примеры автоматического определения типа данных: + +``` sql +SELECT array(1, 2, NULL) AS x, toTypeName(x) +``` + +``` text +┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ +│ [1,2,NULL] │ Array(Nullable(UInt8)) │ +└────────────┴───────────────────────────────┘ +``` + +Если попытаться создать массив из несовместимых типов данных, то ClickHouse выбросит исключение: + +``` sql +SELECT array(1, 'a') +``` + +``` text +Received exception from server (version 1.1.54388): +Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/array/) diff --git a/docs/ru/sql_reference/data_types/boolean.md b/docs/ru/sql-reference/data-types/boolean.md similarity index 100% rename from docs/ru/sql_reference/data_types/boolean.md rename to docs/ru/sql-reference/data-types/boolean.md diff --git a/docs/ru/sql_reference/data_types/date.md b/docs/ru/sql-reference/data-types/date.md similarity index 100% rename from docs/ru/sql_reference/data_types/date.md rename to docs/ru/sql-reference/data-types/date.md diff --git a/docs/ru/sql-reference/data-types/datetime.md b/docs/ru/sql-reference/data-types/datetime.md new file mode 100644 index 00000000000..e7c3d8c24f1 --- /dev/null +++ b/docs/ru/sql-reference/data-types/datetime.md @@ -0,0 +1,122 @@ +# DateTime {#data_type-datetime} + +Позволяет хранить момент времени, который может быть представлен как календарная дата и время. + +Синтаксис: + +``` sql +DateTime([timezone]) +``` + +Диапазон значений: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. + +Точность: 1 секунда. + +## Использование {#ispolzovanie} + +Момент времени сохраняется как [Unix timestamp](https://ru.wikipedia.org/wiki/Unix-%D0%B2%D1%80%D0%B5%D0%BC%D1%8F), независимо от часового пояса и переходов на летнее/зимнее время. Дополнительно, тип `DateTime` позволяет хранить часовой пояс, единый для всей колонки, который влияет на то, как будут отображаться значения типа `DateTime` в текстовом виде и как будут парситься значения заданные в виде строк (‘2020-01-01 05:00:01’). Часовой пояс не хранится в строках таблицы (выборки), а хранится в метаданных колонки. +Список поддерживаемых временных зон можно найти в [IANA Time Zone Database](https://www.iana.org/time-zones). +Пакет `tzdata`, содержащий [базу данных часовых поясов IANA](https://www.iana.org/time-zones), должен быть установлен в системе. Используйте команду `timedatectl list-timezones` для получения списка часовых поясов, известных локальной системе. + +Часовой пояс для столбца типа `DateTime` можно в явном виде установить при создании таблицы. Если часовой пояс не установлен, то ClickHouse использует значение параметра [timezone](../../sql-reference/data-types/datetime.md#server_configuration_parameters-timezone), установленное в конфигурации сервера или в настройках операционной системы на момент запуска сервера. + +Консольный клиент ClickHouse по умолчанию использует часовой пояс сервера, если для значения `DateTime` часовой пояс не был задан в явном виде при инициализации типа данных. Чтобы использовать часовой пояс клиента, запустите [clickhouse-client](../../interfaces/cli.md) с параметром `--use_client_time_zone`. + +ClickHouse отображает значения типа `DateTime` в формате `YYYY-MM-DD hh:mm:ss`. Отображение можно поменять с помощью функции [formatDateTime](../../sql-reference/data-types/datetime.md#formatdatetime). + +При вставке данных в ClickHouse, можно использовать различные форматы даты и времени в зависимости от значения настройки [date\_time\_input\_format](../../operations/settings/settings.md#settings-date_time_input_format). + +## Примеры {#primery} + +**1.** Создание таблицы с столбцом типа `DateTime` и вставка данных в неё: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime('Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog; +``` + +``` sql +INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); +``` + +``` sql +SELECT * FROM dt; +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00 │ 1 │ +│ 2019-01-01 00:00:00 │ 2 │ +└─────────────────────┴──────────┘ +``` + +- При вставке даты-времени как целого числа, оно трактуется как Unix Timestamp (UTC). Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`. Однако, столбец `timestamp` имеет тип `DateTime('Europe/Moscow (UTC+3)')`, так что при выводе в виде строки время отобразится как `2019-01-01 03:00:00`. +- При вставке даты-времени в виде строки, время трактуется соответственно часовому поясу установленному для колонки. `'2019-01-01 00:00:00'` трактуется как время по Москве (и в базу сохраняется `1546290000`) + +**2.** Фильтрация по значениям даты-времени + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00 │ 2 │ +└─────────────────────┴──────────┘ +``` + +Фильтровать по колонке типа `DateTime` можно, указывая строковое значение в фильтре `WHERE`. Конвертация будет выполнена автоматически: + +``` sql +SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' +``` + +``` text +┌───────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00 │ 1 │ +└─────────────────────┴──────────┘ +``` + +**3.** Получение часового пояса для колонки типа `DateTime`: + +``` sql +SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────column─┬─x─────────────────────────┐ +│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ +└─────────────────────┴───────────────────────────┘ +``` + +**4.** Конвертация часовых поясов + +``` sql +SELECT +toDateTime(timestamp, 'Europe/London') as lon_time, +toDateTime(timestamp, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────lon_time──┬────────────mos_time─┐ +│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ +│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ +└─────────────────────┴─────────────────────┘ +``` + +## See Also {#see-also} + +- [Функции преобразования типов](../../sql-reference/data-types/datetime.md) +- [Функции для работы с датой и временем](../../sql-reference/data-types/datetime.md) +- [Функции для работы с массивами](../../sql-reference/data-types/datetime.md) +- [Настройка `date_time_input_format`](../../operations/settings/settings.md#settings-date_time_input_format) +- [Конфигурационный параметр сервера `timezone`](../../sql-reference/data-types/datetime.md#server_configuration_parameters-timezone) +- [Операторы для работы с датой и временем](../../sql-reference/data-types/datetime.md#operators-datetime) +- [Тип данных `Date`](date.md) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/datetime/) diff --git a/docs/ru/sql-reference/data-types/datetime64.md b/docs/ru/sql-reference/data-types/datetime64.md new file mode 100644 index 00000000000..bc9394276ee --- /dev/null +++ b/docs/ru/sql-reference/data-types/datetime64.md @@ -0,0 +1,97 @@ +# DateTime64 {#data_type-datetime64} + +Позволяет хранить момент времени, который может быть представлен как календарная дата и время, с заданной суб-секундной точностью. + +Размер тика/точность: 10-precision секунд, где precision - целочисленный параметр типа. + +Синтаксис: + +``` sql +DateTime64(precision, [timezone]) +``` + +Данные хранятся в виде количества ‘тиков’, прошедших с момента начала эпохи (1970-01-01 00:00:00 UTC), в Int64. Размер тика определяется параметром precision. Дополнительно, тип `DateTime64` позволяет хранить часовой пояс, единый для всей колонки, который влияет на то, как будут отображаться значения типа `DateTime64` в текстовом виде и как будут парситься значения заданные в виде строк (‘2020-01-01 05:00:01.000’). Часовой пояс не хранится в строках таблицы (выборки), а хранится в метаданных колонки. Подробнее см. [DateTime](datetime.md). + +## Пример {#primer} + +**1.** Создание таблицы с столбцом типа `DateTime64` и вставка данных в неё: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime64(3, 'Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog +``` + +``` sql +INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) +``` + +``` sql +SELECT * FROM dt +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00.000 │ 1 │ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +- При вставке даты-времени как числа (аналогично ‘Unix timestamp’), время трактуется как UTC. Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`. Однако, столбец `timestamp` имеет тип `DateTime('Europe/Moscow (UTC+3)')`, так что при выводе в виде строки время отобразится как `2019-01-01 03:00:00`. +- При вставке даты-времени в виде строки, время трактуется соответственно часовому поясу установленному для колонки. `'2019-01-01 00:00:00'` трактуется как время по Москве (и в базу сохраняется `'2018-12-31 21:00:00'` в виде Unix Timestamp) + +**2.** Фильтрация по значениям даты-времени + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +В отличие от типа `DateTime`, `DateTime64` не конвертируется из строк автоматически + +**3.** Получение часового пояса для значения типа `DateTime64`: + +``` sql +SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────────column─┬─x──────────────────────────────┐ +│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ +└─────────────────────────┴────────────────────────────────┘ +``` + +**4.** Конвертация часовых поясов + +``` sql +SELECT +toDateTime64(timestamp, 3, 'Europe/London') as lon_time, +toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────────lon_time──┬────────────────mos_time─┐ +│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ +│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ +└─────────────────────────┴─────────────────────────┘ +``` + +## See Also {#see-also} + +- [Функции преобразования типов](../../sql-reference/data-types/datetime64.md) +- [Функции для работы с датой и временем](../../sql-reference/data-types/datetime64.md) +- [Функции для работы с массивами](../../sql-reference/data-types/datetime64.md) +- [Настройка `date_time_input_format`](../../operations/settings/settings.md#settings-date_time_input_format) +- [Конфигурационный параметр сервера `timezone`](../../sql-reference/data-types/datetime64.md#server_configuration_parameters-timezone) +- [Операторы для работы с датой и временем](../../sql-reference/data-types/datetime64.md#operators-datetime) +- [Тип данных `Date`](date.md) +- [Тип данных `DateTime`](datetime.md) diff --git a/docs/ru/sql-reference/data-types/decimal.md b/docs/ru/sql-reference/data-types/decimal.md new file mode 100644 index 00000000000..f7d51c97552 --- /dev/null +++ b/docs/ru/sql-reference/data-types/decimal.md @@ -0,0 +1,102 @@ +# Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} + +Знаковые дробные числа с сохранением точности операций сложения, умножения и вычитания. Для деления осуществляется отбрасывание (не округление) знаков, не попадающих в младший десятичный разряд. + +## Параметры {#parametry} + +- P - precision. Значение из диапазона \[ 1 : 38 \]. Определяет, сколько десятичных знаков (с учетом дробной части) может содержать число. +- S - scale. Значение из диапазона \[ 0 : P \]. Определяет, сколько десятичных знаков содержится в дробной части числа. + +В зависимости от параметра P Decimal(P, S) является синонимом: +- P из \[ 1 : 9 \] - для Decimal32(S) +- P из \[ 10 : 18 \] - для Decimal64(S) +- P из \[ 19 : 38 \] - для Decimal128(S) + +## Диапазоны Decimal {#diapazony-decimal} + +- Decimal32(S) - ( -1 \* 10^(9 - S), 1 \* 10^(9 - S) ) +- Decimal64(S) - ( -1 \* 10^(18 - S), 1 \* 10^(18 - S) ) +- Decimal128(S) - ( -1 \* 10^(38 - S), 1 \* 10^(38 - S) ) + +Например, Decimal32(4) содержит числа от -99999.9999 до 99999.9999 c шагом 0.0001. + +## Внутреннее представление {#vnutrennee-predstavlenie} + +Внутри данные представляются как знаковые целые числа, соответсвующей разрядности. Реальные диапазоны, хранящиеся в ячейках памяти несколько больше заявленных. Заявленные диапазоны Decimal проверяются только при вводе числа из строкового представления. +Поскольку современные CPU не поддерживают 128-битные числа, операции над Decimal128 эмулируются программно. Decimal128 работает в разы медленней чем Decimal32/Decimal64. + +## Операции и типы результата {#operatsii-i-tipy-rezultata} + +Результат операции между двумя Decimal расширяется до большего типа (независимо от порядка аргументов). + +- `Decimal64(S1) Decimal32(S2) -> Decimal64(S)` +- `Decimal128(S1) Decimal32(S2) -> Decimal128(S)` +- `Decimal128(S1) Decimal64(S2) -> Decimal128(S)` + +Для размера дробной части (scale) результата действуют следующие правила: + +- сложение, вычитание: S = max(S1, S2). +- умножение: S = S1 + S2. +- деление: S = S1. + +При операциях между Decimal и целыми числами результатом является Decimal, аналогичный аргументу. + +Операции между Decimal и Float32/64 не определены. Для осуществления таких операций нужно явно привести один из аргументов функциями: toDecimal32, toDecimal64, toDecimal128, или toFloat32, toFloat64. Это сделано из двух соображений. Во-первых, результат операции будет с потерей точности. Во-вторых, преобразование типа - дорогая операция, из-за ее наличия пользовательский запрос может работать в несколько раз дольше. + +Часть функций над Decimal возвращают Float64 (например, var, stddev). Для некоторых из них промежуточные операции проходят в Decimal. +Для таких функций результат над одинаковыми данными во Float64 и Decimal может отличаться, несмотря на одинаковый тип результата. + +## Проверка переполнений {#proverka-perepolnenii} + +При выполнении операций над типом Decimal могут происходить целочисленные переполнения. Лишняя дробная часть отбрасывается (не округляется). Лишняя целочисленная часть приводит к исключению. + +``` sql +SELECT toDecimal32(2, 4) AS x, x / 3 +``` + +``` text +┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ +│ 2.0000 │ 0.6666 │ +└────────┴──────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32(4.2, 8) AS x, x * x +``` + +``` text +DB::Exception: Scale is out of bounds. +``` + +``` sql +SELECT toDecimal32(4.2, 8) AS x, 6 * x +``` + +``` text +DB::Exception: Decimal math overflow. +``` + +Проверка переполнения приводит к замедлению операций. При уверенности, что типа результата хватит для его записи проверку переполнения можно отключить настройкой decimal\_check\_overflow. В этом случае при переполнении вернется неверное значение: + +``` sql +SET decimal_check_overflow = 0; +SELECT toDecimal32(4.2, 8) AS x, 6 * x +``` + +``` text +┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ +│ 4.20000000 │ -17.74967296 │ +└────────────┴──────────────────────────────────┘ +``` + +Переполнения происходят не только на арифметических операциях, но и на операциях сравнения. Отключать проверку стоит только при полной уверенности в корректности результата: + +``` sql +SELECT toDecimal32(1, 8) < 100 +``` + +``` text +DB::Exception: Can't compare. +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/decimal/) diff --git a/docs/ru/sql-reference/data-types/domains/index.md b/docs/ru/sql-reference/data-types/domains/index.md new file mode 100644 index 00000000000..ddcb5b21d82 --- /dev/null +++ b/docs/ru/sql-reference/data-types/domains/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: Domains +toc_priority: 56 +--- + + diff --git a/docs/ru/sql_reference/data_types/domains/ipv4.md b/docs/ru/sql-reference/data-types/domains/ipv4.md similarity index 100% rename from docs/ru/sql_reference/data_types/domains/ipv4.md rename to docs/ru/sql-reference/data-types/domains/ipv4.md diff --git a/docs/ru/sql_reference/data_types/domains/ipv6.md b/docs/ru/sql-reference/data-types/domains/ipv6.md similarity index 100% rename from docs/ru/sql_reference/data_types/domains/ipv6.md rename to docs/ru/sql-reference/data-types/domains/ipv6.md diff --git a/docs/ru/sql_reference/data_types/domains/overview.md b/docs/ru/sql-reference/data-types/domains/overview.md similarity index 100% rename from docs/ru/sql_reference/data_types/domains/overview.md rename to docs/ru/sql-reference/data-types/domains/overview.md diff --git a/docs/ru/sql-reference/data-types/enum.md b/docs/ru/sql-reference/data-types/enum.md new file mode 100644 index 00000000000..792c82f7410 --- /dev/null +++ b/docs/ru/sql-reference/data-types/enum.md @@ -0,0 +1,124 @@ +# Enum {#enum} + +Перечисляемый тип данных, содержащий именованные значения. + +Именованные значения задаются парами `'string' = integer`. ClickHouse хранит только числа, но допускает операции над ними с помощью заданных имён. + +ClickHouse поддерживает: + +- 8-битный `Enum`. Может содержать до 256 значений, пронумерованных в диапазоне `[-128, 127]`. +- 16-битный `Enum`. Может содержать до 65536 значений, пронумерованных в диапазоне `[-32768, 32767]`. + +ClickHouse автоматически выбирает размерность `Enum` при вставке данных. Чтобы точно понимать размер хранимых данных можно использовать типы `Enum8` или `Enum16`. + +## Примеры использования {#primery-ispolzovaniia} + +Создадим таблицу со столбцом типа `Enum8('hello' = 1, 'world' = 2)`. + +``` sql +CREATE TABLE t_enum +( + x Enum('hello' = 1, 'world' = 2) +) +ENGINE = TinyLog +``` + +В столбец `x` можно сохранять только значения, перечисленные при определении типа, т.е. `'hello'` или `'world'`. Если вы попытаетесь сохранить любое другое значение, ClickHouse сгенерирует исключение. ClickHouse автоматически выберет размерность 8-bit для этого `Enum`. + +``` sql +INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') +``` + +``` text +Ok. +``` + +``` sql +insert into t_enum values('a') +``` + +``` text +Exception on client: +Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) +``` + +При запросе данных из таблицы ClickHouse выдаст строковые значения из `Enum`. + +``` sql +SELECT * FROM t_enum +``` + +``` text +┌─x─────┐ +│ hello │ +│ world │ +│ hello │ +└───────┘ +``` + +Если необходимо увидеть цифровые эквиваленты строкам, то необходимо привести тип `Enum` к целочисленному. + +``` sql +SELECT CAST(x AS Int8) FROM t_enum +``` + +``` text +┌─CAST(x, 'Int8')─┐ +│ 1 │ +│ 2 │ +│ 1 │ +└─────────────────┘ +``` + +Чтобы создать значение типа `Enum` в запросе, также необходимо использовать функцию `CAST`. + +``` sql +SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) +``` + +``` text +┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ +│ Enum8('a' = 1, 'b' = 2) │ +└─────────────────────────────────────────────────────┘ +``` + +## Общие правила и особенности использования {#obshchie-pravila-i-osobennosti-ispolzovaniia} + +Для каждого из значений прописывается число в диапазоне `-128 .. 127` для `Enum8` или в диапазоне `-32768 .. 32767` для `Enum16`. Все строки должны быть разными, числа - тоже. Разрешена пустая строка. При указании такого типа (в определении таблицы), числа могут идти не подряд и в произвольном порядке. При этом, порядок не имеет значения. + +Ни строка, ни цифровое значение в `Enum` не могут быть [NULL](../../sql-reference/syntax.md#null-literal). + +`Enum` может быть передан в тип [Nullable](nullable.md). Таким образом, если создать таблицу запросом + +``` sql +CREATE TABLE t_enum_nullable +( + x Nullable( Enum8('hello' = 1, 'world' = 2) ) +) +ENGINE = TinyLog +``` + +, то в ней можно будет хранить не только `'hello'` и `'world'`, но и `NULL`. + +``` sql +INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) +``` + +В оперативке столбец типа `Enum` представлен так же, как `Int8` или `Int16` соответствующими числовыми значениями. +При чтении в текстовом виде, парсит значение как строку и ищет соответствующую строку из множества значений Enum-а. Если не находит - кидается исключение. +При записи в текстовом виде, записывает значение как соответствующую строку. Если в данных столбца есть мусор - числа не из допустимого множества, то кидается исключение. При чтении и записи в бинарном виде, оно осуществляется так же, как для типов данных Int8, Int16. +Неявное значение по умолчанию - это значение с минимальным номером. + +При `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` и т. п., Enum-ы ведут себя так же, как соответствующие числа. Например, при ORDER BY они сортируются по числовым значениям. Функции сравнения на равенство и сравнения на отношение порядка двух Enum-ов работают с Enum-ами так же, как с числами. + +Сравнивать Enum с числом нельзя. Можно сравнивать Enum с константной строкой - при этом, для строки ищется соответствующее значение Enum-а; если не находится - кидается исключение. Поддерживается оператор IN, где слева стоит Enum, а справа - множество строк. В этом случае, строки рассматриваются как значения соответствующего Enum-а. + +Большинство операций с числами и со строками не имеет смысла и не работают для Enum-ов: например, к Enum-у нельзя прибавить число. +Для Enum-а естественным образом определяется функция `toString`, которая возвращает его строковое значение. + +Также для Enum-а определяются функции `toT`, где T - числовой тип. При совпадении T с типом столбца Enum-а, преобразование работает бесплатно. +При ALTER, есть возможность бесплатно изменить тип Enum-а, если меняется только множество значений. При этом, можно добавлять новые значения; можно удалять старые значения (это безопасно только если они ни разу не использовались, так как это не проверяется). В качестве «защиты от дурака», нельзя менять числовые значения у имеющихся строк - в этом случае, кидается исключение. + +При ALTER, есть возможность поменять Enum8 на Enum16 и обратно - так же, как можно поменять Int8 на Int16. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/enum/) diff --git a/docs/ru/sql-reference/data-types/fixedstring.md b/docs/ru/sql-reference/data-types/fixedstring.md new file mode 100644 index 00000000000..1d801bb6e92 --- /dev/null +++ b/docs/ru/sql-reference/data-types/fixedstring.md @@ -0,0 +1,56 @@ +# FixedString {#fixedstring} + +Строка фиксированной длины `N` байт (не символов, не кодовых точек). + +Чтобы объявить столбец типа `FixedString`, используйте следующий синтаксис: + +``` sql + FixedString(N) +``` + +Где `N` — натуральное число. + +Тип `FixedString` эффективен, когда данные имеют длину ровно `N` байт. Во всех остальных случаях использование FixedString может привести к снижению эффективности. + +Примеры значений, которые можно эффективно хранить в столбцах типа `FixedString`: + +- Двоичное представление IP-адреса (`FixedString(16)` для IPv6). +- Коды языков (ru\_RU, en\_US … ). +- Коды валют (USD, RUB … ). +- Двоичное представление хэшей (`FixedString(16)` для MD5, `FixedString(32)` для SHA256). + +Для хранения значений UUID используйте тип данных [UUID](uuid.md). + +При вставке данных, ClickHouse: + +- Дополняет строку нулевыми байтами, если строка содержит меньше байтов, чем `N`. +- Генерирует исключение `Too large value for FixedString(N)`, если строка содержит более `N` байт. + +При выборе данных ClickHouse не обрезает нулевые байты в конце строки. Если вы используете секцию `WHERE`, то необходимо добавлять нулевые байты вручную, чтобы ClickHouse смог сопоставить выражение из фильтра значению `FixedString`. Следующий пример показывает, как использовать секцию `WHERE` с `FixedString`. + +Рассмотрим следующую таблицу с единственным столбцом типа `FixedString(2)`: + +``` text +┌─name──┐ +│ b │ +└───────┘ +``` + +Запрос `SELECT * FROM FixedStringTable WHERE a = 'b'` не возвращает необходимых данных. Необходимо дополнить шаблон фильтра нулевыми байтами. + +``` sql +SELECT * FROM FixedStringTable +WHERE a = 'b\0' +``` + +``` text +┌─a─┐ +│ b │ +└───┘ +``` + +Это поведение отличается от поведения MySQL для типа `CHAR`, где строки дополняются пробелами, а пробелы перед выводом вырезаются. + +Обратите внимание, что длина значения `FixedString(N)` постоянна. Функция [length](../../sql-reference/data-types/fixedstring.md#array_functions-length) возвращает `N` даже если значение `FixedString(N)` заполнено только нулевыми байтами, однако функция [empty](../../sql-reference/data-types/fixedstring.md#empty) в этом же случае возвращает `1`. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/fixedstring/) diff --git a/docs/ru/sql_reference/data_types/float.md b/docs/ru/sql-reference/data-types/float.md similarity index 100% rename from docs/ru/sql_reference/data_types/float.md rename to docs/ru/sql-reference/data-types/float.md diff --git a/docs/ru/sql-reference/data-types/index.md b/docs/ru/sql-reference/data-types/index.md new file mode 100644 index 00000000000..65bce13a1a4 --- /dev/null +++ b/docs/ru/sql-reference/data-types/index.md @@ -0,0 +1,14 @@ +--- +toc_folder_title: "\u0422\u0438\u043F\u044B \u0434\u0430\u043D\u043D\u044B\u0445" +toc_priority: 37 +toc_title: "\u0412\u0432\u0435\u0434\u0435\u043D\u0438\u0435" +--- + +# Типы данных {#data_types} + +ClickHouse может сохранять в ячейках таблиц данные различных типов. + +Зависимость имен типов данных от регистра можно проверить в системной таблице [system.data_type_families](../../operations/system-tables.md#system_tables-data_type_families). + +Раздел содержит описания поддерживаемых типов данных и специфику их использования и/или реализации, если таковые имеются. +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/) diff --git a/docs/ru/sql-reference/data-types/int-uint.md b/docs/ru/sql-reference/data-types/int-uint.md new file mode 100644 index 00000000000..f885c3f7dba --- /dev/null +++ b/docs/ru/sql-reference/data-types/int-uint.md @@ -0,0 +1,19 @@ +# UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} + +Целые числа фиксированной длины, без знака или со знаком. + +## Диапазоны Int {#int-ranges} + +- Int8 - \[ -128 : 127 \] +- Int16 - \[ -32768 : 32767 \] +- Int32 - \[ -2147483648 : 2147483647 \] +- Int64 - \[ -9223372036854775808 : 9223372036854775807 \] + +## Диапазоны Uint {#uint-ranges} + +- UInt8 - \[ 0 : 255 \] +- UInt16 - \[ 0 : 65535 \] +- UInt32 - \[ 0 : 4294967295 \] +- UInt64 - \[ 0 : 18446744073709551615 \] + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/int_uint/) diff --git a/docs/ru/sql_reference/data_types/nested_data_structures/index.md b/docs/ru/sql-reference/data-types/nested-data-structures/index.md similarity index 100% rename from docs/ru/sql_reference/data_types/nested_data_structures/index.md rename to docs/ru/sql-reference/data-types/nested-data-structures/index.md diff --git a/docs/ru/sql_reference/data_types/nested_data_structures/nested.md b/docs/ru/sql-reference/data-types/nested-data-structures/nested.md similarity index 100% rename from docs/ru/sql_reference/data_types/nested_data_structures/nested.md rename to docs/ru/sql-reference/data-types/nested-data-structures/nested.md diff --git a/docs/ru/sql-reference/data-types/nullable.md b/docs/ru/sql-reference/data-types/nullable.md new file mode 100644 index 00000000000..5ed99469750 --- /dev/null +++ b/docs/ru/sql-reference/data-types/nullable.md @@ -0,0 +1,46 @@ +# Nullable(TypeName) {#data_type-nullable} + +Позволяет работать как со значением типа `TypeName` так и с отсутствием этого значения ([NULL](../../sql-reference/data-types/nullable.md)) в одной и той же переменной, в том числе хранить `NULL` в таблицах вместе со значения типа `TypeName`. Например, в столбце типа `Nullable(Int8)` можно хранить значения типа `Int8`, а в тех строках, где значения нет, будет храниться `NULL`. + +В качестве `TypeName` нельзя использовать составные типы данных [Array](array.md#data-type-array) и [Tuple](tuple.md). Составные типы данных могут содержать значения типа `Nullable`, например `Array(Nullable(Int8))`. + +Поле типа `Nullable` нельзя включать в индексы. + +`NULL` — значение по умолчанию для типа `Nullable`, если в конфигурации сервера ClickHouse не указано иное. + +## Особенности хранения {#osobennosti-khraneniia} + +Для хранения значения типа `Nullable` ClickHouse использует: + +- Отдельный файл с масками `NULL` (далее маска). +- Непосредственно файл со значениями. + +Маска определяет, что лежит в ячейке данных: `NULL` или значение. + +В случае, когда маска указывает, что в ячейке хранится `NULL`, в файле значений хранится значение по умолчанию для типа данных. Т.е. если, например, поле имеет тип `Nullable(Int8)`, то ячейка будет хранить значение по умолчанию для `Int8`. Эта особенность увеличивает размер хранилища. + +!!! info "Info" + Почти всегда использование `Nullable` снижает производительность, учитывайте это при проектировании своих баз. + +## Пример использования {#primer-ispolzovaniia} + +``` sql +CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog +``` + +``` sql +INSERT INTO t_null VALUES (1, NULL), (2, 3) +``` + +``` sql +SELECT x + y from t_null +``` + +``` text +┌─plus(x, y)─┐ +│ ᴺᵁᴸᴸ │ +│ 5 │ +└────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/nullable/) diff --git a/docs/ru/sql-reference/data-types/simpleaggregatefunction.md b/docs/ru/sql-reference/data-types/simpleaggregatefunction.md new file mode 120000 index 00000000000..76a7ef3b802 --- /dev/null +++ b/docs/ru/sql-reference/data-types/simpleaggregatefunction.md @@ -0,0 +1 @@ +../../../en/sql-reference/data-types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/ru/sql_reference/data_types/special_data_types/expression.md b/docs/ru/sql-reference/data-types/special-data-types/expression.md similarity index 100% rename from docs/ru/sql_reference/data_types/special_data_types/expression.md rename to docs/ru/sql-reference/data-types/special-data-types/expression.md diff --git a/docs/ru/sql_reference/data_types/special_data_types/index.md b/docs/ru/sql-reference/data-types/special-data-types/index.md similarity index 100% rename from docs/ru/sql_reference/data_types/special_data_types/index.md rename to docs/ru/sql-reference/data-types/special-data-types/index.md diff --git a/docs/ru/sql-reference/data-types/special-data-types/interval.md b/docs/ru/sql-reference/data-types/special-data-types/interval.md new file mode 100644 index 00000000000..8a4ace179a6 --- /dev/null +++ b/docs/ru/sql-reference/data-types/special-data-types/interval.md @@ -0,0 +1,78 @@ +# Interval {#data-type-interval} + +Семейство типов данных, представляющих интервалы дат и времени. Оператор [INTERVAL](../../../sql-reference/data-types/special-data-types/interval.md#operator-interval) возвращает значения этих типов. + +!!! warning "Внимание" + Нельзя использовать типы данных `Interval` для хранения данных в таблице. + +Структура: + +- Интервал времени в виде положительного целого числа. +- Тип интервала. + +Поддержанные типы интервалов: + +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +Каждому типу интервала соответствует отдельный тип данных. Например, тип данных `IntervalDay` соответствует интервалу `DAY`: + +``` sql +SELECT toTypeName(INTERVAL 4 DAY) +``` + +``` text +┌─toTypeName(toIntervalDay(4))─┐ +│ IntervalDay │ +└──────────────────────────────┘ +``` + +## Использование {#data-type-interval-usage-remarks} + +Значения типов `Interval` можно использовать в арифметических операциях со значениями типов [Date](../../../sql-reference/data-types/special-data-types/interval.md) и [DateTime](../../../sql-reference/data-types/special-data-types/interval.md). Например, можно добавить 4 дня к текущей дате: + +``` sql +SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY +``` + +``` text +┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ +│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ +└─────────────────────┴───────────────────────────────┘ +``` + +Нельзя объединять интервалы различных типов. Нельзя использовать интервалы вида `4 DAY 1 HOUR`. Вместо этого выражайте интервал в единицах меньших или равных минимальной единице интервала, например, интервал «1 день и 1 час» можно выразить как `25 HOUR` или `90000 SECOND`. + +Арифметические операции со значениями типов `Interval` не доступны, однако можно последовательно добавлять различные интервалы к значениям типов `Date` и `DateTime`. Например: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +Следующий запрос приведёт к генерированию исключения: + +``` sql +select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) +``` + +``` text +Received exception from server (version 19.14.1): +Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. +``` + +## Смотрите также {#smotrite-takzhe} + +- Оператор[INTERVAL](../../../sql-reference/data-types/special-data-types/interval.md#operator-interval) +- Функция приведения типа [toInterval](../../../sql-reference/data-types/special-data-types/interval.md#function-tointerval) diff --git a/docs/ru/sql-reference/data-types/special-data-types/nothing.md b/docs/ru/sql-reference/data-types/special-data-types/nothing.md new file mode 100644 index 00000000000..9644f102522 --- /dev/null +++ b/docs/ru/sql-reference/data-types/special-data-types/nothing.md @@ -0,0 +1,17 @@ +# Nothing {#nothing} + +Этот тип данных предназначен только для того, чтобы представлять [NULL](../../../sql-reference/data-types/special-data-types/nothing.md), т.е. отсутствие значения. + +Невозможно создать значение типа `Nothing`, поэтому он используется там, где значение не подразумевается. Например, `NULL` записывается как `Nullable(Nothing)` ([Nullable](../../../sql-reference/data-types/special-data-types/nothing.md) — это тип данных, позволяющий хранить `NULL` в таблицах). Также тип `Nothing` используется для обозначения пустых массивов: + +``` sql +SELECT toTypeName(Array()) +``` + +``` text +┌─toTypeName(array())─┐ +│ Array(Nothing) │ +└─────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/special_data_types/nothing/) diff --git a/docs/ru/sql_reference/data_types/special_data_types/set.md b/docs/ru/sql-reference/data-types/special-data-types/set.md similarity index 100% rename from docs/ru/sql_reference/data_types/special_data_types/set.md rename to docs/ru/sql-reference/data-types/special-data-types/set.md diff --git a/docs/ru/sql_reference/data_types/string.md b/docs/ru/sql-reference/data-types/string.md similarity index 100% rename from docs/ru/sql_reference/data_types/string.md rename to docs/ru/sql-reference/data-types/string.md diff --git a/docs/ru/sql-reference/data-types/tuple.md b/docs/ru/sql-reference/data-types/tuple.md new file mode 100644 index 00000000000..566a582eb95 --- /dev/null +++ b/docs/ru/sql-reference/data-types/tuple.md @@ -0,0 +1,45 @@ +# Tuple(T1, T2, …) {#tuplet1-t2} + +Кортеж из элементов любого [типа](index.md#data_types). Элементы кортежа могут быть одного или разных типов. + +Кортежи используются для временной группировки столбцов. Столбцы могут группироваться при использовании выражения IN в запросе, а также для указания нескольких формальных параметров лямбда-функций. Подробнее смотрите разделы [Операторы IN](../../sql-reference/data-types/tuple.md), [Функции высшего порядка](../../sql-reference/functions/higher-order-functions.md#higher-order-functions). + +Кортежи могут быть результатом запроса. В этом случае, в текстовых форматах кроме JSON, значения выводятся в круглых скобках через запятую. В форматах JSON, кортежи выводятся в виде массивов (в квадратных скобках). + +## Создание кортежа {#sozdanie-kortezha} + +Кортеж можно создать с помощью функции + +``` sql +tuple(T1, T2, ...) +``` + +Пример создания кортежа: + +``` sql +SELECT tuple(1,'a') AS x, toTypeName(x) +``` + +``` text +┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ +│ (1,'a') │ Tuple(UInt8, String) │ +└─────────┴───────────────────────────┘ +``` + +## Особенности работы с типами данных {#osobennosti-raboty-s-tipami-dannykh} + +При создании кортежа «на лету» ClickHouse автоматически определяет тип каждого аргументов как минимальный из типов, который может сохранить значение аргумента. Если аргумент — [NULL](../../sql-reference/data-types/tuple.md#null-literal), то тип элемента кортежа — [Nullable](nullable.md). + +Пример автоматического определения типа данных: + +``` sql +SELECT tuple(1,NULL) AS x, toTypeName(x) +``` + +``` text +┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ +│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ +└──────────┴─────────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/tuple/) diff --git a/docs/ru/sql-reference/data-types/uuid.md b/docs/ru/sql-reference/data-types/uuid.md new file mode 100644 index 00000000000..9d667a50526 --- /dev/null +++ b/docs/ru/sql-reference/data-types/uuid.md @@ -0,0 +1,72 @@ +# UUID {#uuid-data-type} + +Универсальный уникальный идентификатор (UUID) - это 16-байтовое число, используемое для идентификации записей. Подробнее про UUID читайте на [Википедии](https://en.wikipedia.org/wiki/Universally_unique_identifier). + +Пример UUID значения представлен ниже: + +``` text +61f0c404-5cb3-11e7-907b-a6006ad3dba0 +``` + +Если при вставке новой записи значение для UUID-колонки не указано, UUID идентификатор будет заполнен нулями: + +``` text +00000000-0000-0000-0000-000000000000 +``` + +## Как сгенерировать UUID {#kak-sgenerirovat-uuid} + +Для генерации UUID-значений предназначена функция [generateUUIDv4](../../sql-reference/data-types/uuid.md). + +## Примеры использования {#primery-ispolzovaniia} + +Ниже представлены примеры работы с UUID. + +**Пример 1** + +Этот пример демонстрирует, как создать таблицу с UUID-колонкой и добавить в нее сгенерированный UUID. + +``` sql +CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog +``` + +``` sql +INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +└──────────────────────────────────────┴───────────┘ +``` + +**Пример 2** + +В этом примере, при добавлении записи в таблицу значение для UUID-колонки не задано. UUID будет заполнен нулями. + +``` sql +INSERT INTO t_uuid (y) VALUES ('Example 2') +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ +└──────────────────────────────────────┴───────────┘ +``` + +## Ограничения {#ogranicheniia} + +Тип данных UUID можно использовать только с функциями, которые поддерживаются типом данных [String](string.md) (например, [min](../../sql-reference/data-types/uuid.md#agg_function-min), [max](../../sql-reference/data-types/uuid.md#agg_function-max), и [count](../../sql-reference/data-types/uuid.md#agg_function-count)). + +Тип данных UUID не поддерживается арифметическими операциями (например, [abs](../../sql-reference/data-types/uuid.md#arithm_func-abs)) или агрегатными функциями, такими как [sum](../../sql-reference/data-types/uuid.md#agg_function-sum) и [avg](../../sql-reference/data-types/uuid.md#agg_function-avg). + +[Original article](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md new file mode 100644 index 00000000000..1f09eb28d2e --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md @@ -0,0 +1,63 @@ +# Иерархические словари {#ierarkhicheskie-slovari} + +ClickHouse поддерживает иерархические словари с [числовыми ключом](external-dicts-dict-structure.md#ext_dict-numeric-key). + +Рассмотрим следующую структуру: + +``` text +0 (Common parent) +│ +├── 1 (Russia) +│ │ +│ └── 2 (Moscow) +│ │ +│ └── 3 (Center) +│ +└── 4 (Great Britain) + │ + └── 5 (London) +``` + +Эту иерархию можно выразить в виде следующей таблицы-словаря. + +| region\_id | parent\_region | region\_name | +|------------|----------------|---------------| +| 1 | 0 | Russia | +| 2 | 1 | Moscow | +| 3 | 2 | Center | +| 4 | 0 | Great Britain | +| 5 | 4 | London | + +Таблица содержит столбец `parent_region`, содержащий ключ ближайшего предка для текущего элемента. + +ClickHouse поддерживает свойство [hierarchical](external-dicts-dict-structure.md#hierarchical-dict-attr) для атрибутов [внешнего словаря](index.md). Это свойство позволяет конфигурировать словари, подобные описанному выше. + +С помощью функции [dictGetHierarchy](../../../sql-reference/functions/ext-dict-functions.md#dictgethierarchy) можно получить цепочку предков элемента. + +Структура словаря для нашего примера может выглядеть следующим образом: + +``` xml + + + + region_id + + + + parent_region + UInt64 + 0 + true + + + + region_name + String + + + + + +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md new file mode 100644 index 00000000000..368da949dc8 --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -0,0 +1,397 @@ +# Хранение словарей в памяти {#dicts-external-dicts-dict-layout} + +Словари можно размещать в памяти множеством способов. + +Рекомендуем [flat](#flat), [hashed](#dicts-external_dicts_dict_layout-hashed) и [complex\_key\_hashed](#complex-key-hashed). Скорость обработки словарей при этом максимальна. + +Размещение с кэшированием не рекомендуется использовать из-за потенциально низкой производительности и сложностей в подборе оптимальных параметров. Читайте об этом подробнее в разделе «[cache](#cache)». + +Повысить производительность словарей можно следующими способами: + +- Вызывать функцию для работы со словарём после `GROUP BY`. +- Помечать извлекаемые атрибуты как инъективные. Атрибут называется инъективным, если разным ключам соответствуют разные значения атрибута. Тогда при использовании в `GROUP BY` функции, достающей значение атрибута по ключу, эта функция автоматически выносится из `GROUP BY`. + +При ошибках работы со словарями ClickHouse генерирует исключения. Например, в следующих ситуациях: + +- При обращении к словарю, который не удалось загрузить. +- При ошибке запроса к `cached`-словарю. + +Список внешних словарей и их статус можно посмотреть в таблице `system.dictionaries`. + +Общий вид конфигурации: + +``` xml + + + ... + + + + + + ... + + +``` + +Соответствущий [DDL-запрос](../../statements/create.md#create-dictionary-query): + +``` sql +CREATE DICTIONARY (...) +... +LAYOUT(LAYOUT_TYPE(param value)) -- layout settings +... +``` + +## Способы размещения словарей в памяти {#sposoby-razmeshcheniia-slovarei-v-pamiati} + +- [flat](#flat) +- [hashed](#dicts-external_dicts_dict_layout-hashed) +- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) +- [cache](#cache) +- [direct](#direct) +- [range\_hashed](#range-hashed) +- [complex\_key\_hashed](#complex-key-hashed) +- [complex\_key\_cache](#complex-key-cache) +- [complex\_key\_direct](#complex-key-direct) +- [ip\_trie](#ip-trie) + +### flat {#flat} + +Словарь полностью хранится в оперативной памяти в виде плоских массивов. Объём памяти, занимаемой словарём пропорционален размеру самого большого по размеру ключа. + +Ключ словаря имеет тип `UInt64` и его величина ограничена 500 000. Если при создании словаря обнаружен ключ больше, то ClickHouse бросает исключение и не создает словарь. + +Поддерживаются все виды источников. При обновлении, данные (из файла, из таблицы) читаются целиком. + +Это метод обеспечивает максимальную производительность среди всех доступных способов размещения словаря. + +Пример конфигурации: + +``` xml + + + +``` + +или + +``` sql +LAYOUT(FLAT()) +``` + +### hashed {#dicts-external_dicts_dict_layout-hashed} + +Словарь полностью хранится в оперативной памяти в виде хэш-таблиц. Словарь может содержать произвольное количество элементов с произвольными идентификаторами. На практике, количество ключей может достигать десятков миллионов элементов. + +Поддерживаются все виды источников. При обновлении, данные (из файла, из таблицы) читаются целиком. + +Пример конфигурации: + +``` xml + + + +``` + +или + +``` sql +LAYOUT(HASHED()) +``` + +### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} + +Аналогичен `hashed`, но при этом занимает меньше места в памяти и генерирует более высокую загрузку CPU. + +Пример конфигурации: + +``` xml + + + +``` + +или + +``` sql +LAYOUT(SPARSE_HASHED()) +``` + +### complex\_key\_hashed {#complex-key-hashed} + +Тип размещения предназначен для использования с составными [ключами](external-dicts-dict-structure.md). Аналогичен `hashed`. + +Пример конфигурации: + +``` xml + + + +``` + +или + +``` sql +LAYOUT(COMPLEX_KEY_HASHED()) +``` + +### range\_hashed {#range-hashed} + +Словарь хранится в оперативной памяти в виде хэш-таблицы с упорядоченным массивом диапазонов и соответствующих им значений. + +Этот способ размещения работает также как и hashed и позволяет дополнительно к ключу использовать дипазоны по дате/времени (произвольному числовому типу). + +Пример: таблица содержит скидки для каждого рекламодателя в виде: + +``` text ++---------------+---------------------+-------------------+--------+ +| advertiser id | discount start date | discount end date | amount | ++===============+=====================+===================+========+ +| 123 | 2015-01-01 | 2015-01-15 | 0.15 | ++---------------+---------------------+-------------------+--------+ +| 123 | 2015-01-16 | 2015-01-31 | 0.25 | ++---------------+---------------------+-------------------+--------+ +| 456 | 2015-01-01 | 2015-01-15 | 0.05 | ++---------------+---------------------+-------------------+--------+ +``` + +Чтобы использовать выборку по диапазонам дат, необходимо в [structure](external-dicts-dict-structure.md) определить элементы `range_min`, `range_max`. В этих элементах должны присутствовать элементы `name` и `type` (если `type` не указан, будет использован тип по умолчанию – Date). `type` может быть любым численным типом (Date/DateTime/UInt64/Int32/др.). + +Пример: + +``` xml + + + Id + + + first + Date + + + last + Date + + ... +``` + +или + +``` sql +CREATE DICTIONARY somedict ( + id UInt64, + first Date, + last Date +) +PRIMARY KEY id +LAYOUT(RANGE_HASHED()) +RANGE(MIN first MAX last) +``` + +Для работы с такими словарями в функцию `dictGetT` необходимо передавать дополнительный аргумент, для которого подбирается диапазон: + + dictGetT('dict_name', 'attr_name', id, date) + +Функция возвращает значение для заданных `id` и диапазона дат, в который входит переданная дата. + +Особенности алгоритма: + +- Если не найден `id` или для найденного `id` не найден диапазон, то возвращается значение по умолчанию для словаря. +- Если есть перекрывающиеся диапазоны, то можно использовать любой подходящий. +- Если граница диапазона `NULL` или некорректная дата (1900-01-01, 2039-01-01), то диапазон считается открытым. Диапазон может быть открытым с обеих сторон. + +Пример конфигурации: + +``` xml + + + + ... + + + + + + + + Abcdef + + + StartTimeStamp + UInt64 + + + EndTimeStamp + UInt64 + + + XXXType + String + + + + + + +``` + +или + +``` sql +CREATE DICTIONARY somedict( + Abcdef UInt64, + StartTimeStamp UInt64, + EndTimeStamp UInt64, + XXXType String DEFAULT '' +) +PRIMARY KEY Abcdef +RANGE(MIN StartTimeStamp MAX EndTimeStamp) +``` + +### cache {#cache} + +Словарь хранится в кэше, состоящем из фиксированного количества ячеек. Ячейки содержат часто используемые элементы. + +При поиске в словаре сначала просматривается кэш. На каждый блок данных, все не найденные в кэше или устаревшие ключи запрашиваются у источника с помощью `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. Затем, полученные данные записываются в кэш. + +Для cache-словарей может быть задано время устаревания [lifetime](external-dicts-dict-lifetime.md) данных в кэше. Если от загрузки данных в ячейке прошло больше времени, чем `lifetime`, то значение не используется, и будет запрошено заново при следующей необходимости его использовать. + +Это наименее эффективный из всех способов размещения словарей. Скорость работы кэша очень сильно зависит от правильности настройки и сценария использования. Словарь типа cache показывает высокую производительность лишь при достаточно больших hit rate-ах (рекомендуется 99% и выше). Посмотреть средний hit rate можно в таблице `system.dictionaries`. + +Чтобы увеличить производительность кэша, используйте подзапрос с `LIMIT`, а снаружи вызывайте функцию со словарём. + +Поддерживаются [источники](external-dicts-dict-sources.md): MySQL, ClickHouse, executable, HTTP. + +Пример настройки: + +``` xml + + + + 1000000000 + + +``` + +или + +``` sql +LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) +``` + +Укажите достаточно большой размер кэша. Количество ячеек следует подобрать экспериментальным путём: + +1. Выставить некоторое значение. +2. Запросами добиться полной заполненности кэша. +3. Оценить потребление оперативной памяти с помощью таблицы `system.dictionaries`. +4. Увеличивать/уменьшать количество ячеек до получения требуемого расхода оперативной памяти. + +!!! warning "Warning" + Не используйте в качестве источника ClickHouse, поскольку он медленно обрабатывает запросы со случайным чтением. + +### complex\_key\_cache {#complex-key-cache} + +Тип размещения предназначен для использования с составными [ключами](external-dicts-dict-structure.md). Аналогичен `cache`. + +### direct {#direct} + +Словарь не хранит данные локально и взаимодействует с источником непосредственно в момент запроса. + +Ключ словаря имеет тип `UInt64`. + +Поддерживаются все виды [источников](external-dicts-dict-sources.md), кроме локальных файлов. + +Пример конфигурации: + +``` xml + + + +``` + +или + +``` sql +LAYOUT(DIRECT()) +``` + +### complex\_key\_direct {#complex-key-direct} + +Тип размещения предназначен для использования с составными [ключами](external-dicts-dict-structure.md). Аналогичен `direct`. + +### ip\_trie {#ip-trie} + +Тип размещения предназначен для сопоставления префиксов сети (IP адресов) с метаданными, такими как ASN. + +Пример: таблица содержит префиксы сети и соответствующие им номера AS и коды стран: + +``` text + +-----------------+-------+--------+ + | prefix | asn | cca2 | + +=================+=======+========+ + | 202.79.32.0/20 | 17501 | NP | + +-----------------+-------+--------+ + | 2620:0:870::/48 | 3856 | US | + +-----------------+-------+--------+ + | 2a02:6b8:1::/48 | 13238 | RU | + +-----------------+-------+--------+ + | 2001:db8::/32 | 65536 | ZZ | + +-----------------+-------+--------+ +``` + +При использовании такого макета структура должна иметь составной ключ. + +Пример: + +``` xml + + + + prefix + String + + + + asn + UInt32 + + + + cca2 + String + ?? + + ... +``` + +или + +``` sql +CREATE DICTIONARY somedict ( + prefix String, + asn UInt32, + cca2 String DEFAULT '??' +) +PRIMARY KEY prefix +``` + +Этот ключ должен иметь только один атрибут типа `String`, содержащий допустимый префикс IP. Другие типы еще не поддерживаются. + +Для запросов необходимо использовать те же функции (`dictGetT` с кортежем), что и для словарей с составными ключами: + +``` sql +dictGetT('dict_name', 'attr_name', tuple(ip)) +``` + +Функция принимает либо `UInt32` для IPv4, либо `FixedString(16)` для IPv6: + +``` sql +dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) +``` + +Никакие другие типы не поддерживаются. Функция возвращает атрибут для префикса, соответствующего данному IP-адресу. Если есть перекрывающиеся префиксы, возвращается наиболее специфический. + +Данные хранятся в побитовом дереве (`trie`), он должен полностью помещаться в оперативной памяти. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md new file mode 100644 index 00000000000..2f287795296 --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md @@ -0,0 +1,81 @@ +# Обновление словарей {#obnovlenie-slovarei} + +ClickHouse периодически обновляет словари. Интервал обновления для полностью загружаемых словарей и интервал инвалидации для кэшируемых словарей определяется в теге `` в секундах. + +Обновление словарей (кроме загрузки при первом использовании) не блокирует запросы - во время обновления используется старая версия словаря. Если при обновлении возникнет ошибка, то ошибка пишется в лог сервера, а запросы продолжат использовать старую версию словарей. + +Пример настройки: + +``` xml + + ... + 300 + ... + +``` + +или + +``` sql +CREATE DICTIONARY (...) +... +LIFETIME(300) +... +``` + +Настройка `0` запрещает обновление словарей. + +Можно задать интервал, внутри которого ClickHouse равномерно-случайно выберет время для обновления. Это необходимо для распределения нагрузки на источник словаря при обновлении на большом количестве серверов. + +Пример настройки: + +``` xml + + ... + + 300 + 360 + + ... + +``` + +или + +``` sql +LIFETIME(MIN 300 MAX 360) +``` + +При обновлении словарей сервер ClickHouse применяет различную логику в зависимости от типа [источника](external-dicts-dict-sources.md): + +> - У текстового файла проверяется время модификации. Если время изменилось по отношению к запомненному ранее, то словарь обновляется. +> - Для таблиц типа MyISAM, время модификации проверяется запросом `SHOW TABLE STATUS`. +> - Словари из других источников по умолчанию обновляются каждый раз. + +Для источников MySQL (InnoDB), ODBC и ClickHouse можно настроить запрос, который позволит обновлять словари только в случае их фактического изменения, а не каждый раз. Чтобы это сделать необходимо выполнить следующие условия/действия: + +> - В таблице словаря должно быть поле, которое гарантированно изменяется при обновлении данных в источнике. +> - В настройках источника указывается запрос, который получает изменяющееся поле. Результат запроса сервер ClickHouse интерпретирует как строку и если эта строка изменилась по отношению к предыдущему состоянию, то словарь обновляется. Запрос следует указывать в поле `` настроек [источника](external-dicts-dict-sources.md). + +Пример настройки: + +``` xml + + ... + + ... + SELECT update_time FROM dictionary_source where id = 1 + + ... + +``` + +или + +``` sql +... +SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) +... +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md new file mode 100644 index 00000000000..e5b20f3960c --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md @@ -0,0 +1,615 @@ +# Источники внешних словарей {#dicts-external-dicts-dict-sources} + +Внешний словарь можно подключить из множества источников. + +Общий вид XML-конфигурации: + +``` xml + + + ... + + + + + + ... + + ... + +``` + +Аналогичный [DDL-запрос](../../statements/create.md#create-dictionary-query): + +``` sql +CREATE DICTIONARY dict_name (...) +... +SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration +... +``` + +Источник настраивается в разделе `source`. + +Для типов источников [Локальный файл](#dicts-external_dicts_dict_sources-local_file), [Исполняемый файл](#dicts-external_dicts_dict_sources-executable), [HTTP(s)](#dicts-external_dicts_dict_sources-http), [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) +доступны дополнительные настройки: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + + 0 + + +``` + +или + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +SETTINGS(format_csv_allow_single_quotes = 0) +``` + +Типы источников (`source_type`): + +- [Локальный файл](#dicts-external_dicts_dict_sources-local_file) +- [Исполняемый файл](#dicts-external_dicts_dict_sources-executable) +- [HTTP(s)](#dicts-external_dicts_dict_sources-http) +- СУБД: + - [ODBC](#dicts-external_dicts_dict_sources-odbc) + - [MySQL](#dicts-external_dicts_dict_sources-mysql) + - [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) + - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) + - [Redis](#dicts-external_dicts_dict_sources-redis) + +## Локальный файл {#dicts-external_dicts_dict_sources-local_file} + +Пример настройки: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + +``` + +или + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +Поля настройки: + +- `path` — Абсолютный путь к файлу. +- `format` — Формат файла. Поддерживаются все форматы, описанные в разделе «[Форматы](../../../interfaces/formats.md#formats)». + +## Исполняемый файл {#dicts-external_dicts_dict_sources-executable} + +Работа с исполняемым файлом зависит от [размещения словаря в памяти](external-dicts-dict-layout.md). Если тип размещения словаря `cache` и `complex_key_cache`, то ClickHouse запрашивает необходимые ключи, отправляя запрос в `STDIN` исполняемого файла. + +Пример настройки: + +``` xml + + + cat /opt/dictionaries/os.tsv + TabSeparated + + +``` + +или + +``` sql +SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +Поля настройки: + +- `command` — Абсолютный путь к исполняемому файлу или имя файла (если каталог программы прописан в `PATH`). +- `format` — Формат файла. Поддерживаются все форматы, описанные в разделе «[Форматы](../../../interfaces/formats.md#formats)». + +## HTTP(s) {#dicts-external_dicts_dict_sources-http} + +Работа с HTTP(s) сервером зависит от [размещения словаря в памяти](external-dicts-dict-layout.md). Если тип размещения словаря `cache` и `complex_key_cache`, то ClickHouse запрашивает необходимые ключи, отправляя запрос методом `POST`. + +Пример настройки: + +``` xml + + + http://[::1]/os.tsv + TabSeparated + + user + password + + +
+ API-KEY + key +
+
+
+ +``` + +или + +``` sql +SOURCE(HTTP( + url 'http://[::1]/os.tsv' + format 'TabSeparated' + credentials(user 'user' password 'password') + headers(header(name 'API-KEY' value 'key')) +)) +``` + +Чтобы ClickHouse смог обратиться к HTTPS-ресурсу, необходимо [настроить openSSL](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-openssl) в конфигурации сервера. + +Поля настройки: + +- `url` — URL источника. +- `format` — Формат файла. Поддерживаются все форматы, описанные в разделе «[Форматы](../../../interfaces/formats.md#formats)». + +## ODBC {#dicts-external_dicts_dict_sources-odbc} + +Этим способом можно подключить любую базу данных, имеющую ODBC драйвер. + +Пример настройки: + +``` xml + + + DatabaseName + ShemaName.TableName
+ DSN=some_parameters + SQL_QUERY +
+ +``` + +или + +``` sql +SOURCE(ODBC( + db 'DatabaseName' + table 'SchemaName.TableName' + connection_string 'DSN=some_parameters' + invalidate_query 'SQL_QUERY' +)) +``` + +Поля настройки: + +- `db` — имя базы данных. Не указывать, если имя базы задано в параметрах. ``. +- `table` — имя таблицы и схемы, если она есть. +- `connection_string` — строка соединения. +- `invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external-dicts-dict-lifetime.md). + +ClickHouse получает от ODBC-драйвера информацию о квотировании и квотирует настройки в запросах к драйверу, поэтому имя таблицы нужно указывать в соответствии с регистром имени таблицы в базе данных. + +Если у вас есть проблемы с кодировками при использовании Oracle, ознакомьтесь с соответствующим разделом [FAQ](../../../faq/general.md#oracle-odbc-encodings). + +### Выявленная уязвимость в функционировании ODBC словарей {#vyiavlennaia-uiazvimost-v-funktsionirovanii-odbc-slovarei} + +!!! attention "Attention" + При соединении с базой данных через ODBC можно заменить параметр соединения `Servername`. В этом случае, значения `USERNAME` и `PASSWORD` из `odbc.ini` отправляются на удаленный сервер и могут быть скомпрометированы. + +**Пример небезопасного использования** + +Сконфигурируем unixODBC для работы с PostgreSQL. Содержимое `/etc/odbc.ini`: + +``` text +[gregtest] +Driver = /usr/lib/psqlodbca.so +Servername = localhost +PORT = 5432 +DATABASE = test_db +#OPTION = 3 +USERNAME = test +PASSWORD = test +``` + +Если выполнить запрос вида: + +``` sql +SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); +``` + +то ODBC драйвер отправит значения `USERNAME` и `PASSWORD` из `odbc.ini` на `some-server.com`. + +### Пример подключения PostgreSQL {#primer-podkliucheniia-postgresql} + +ОС Ubuntu. + +Установка unixODBC и ODBC-драйвера для PostgreSQL: : + +``` bash +$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql +``` + +Настройка `/etc/odbc.ini` (или `~/.odbc.ini`): + +``` text + [DEFAULT] + Driver = myconnection + + [myconnection] + Description = PostgreSQL connection to my_db + Driver = PostgreSQL Unicode + Database = my_db + Servername = 127.0.0.1 + UserName = username + Password = password + Port = 5432 + Protocol = 9.3 + ReadOnly = No + RowVersioning = No + ShowSystemTables = No + ConnSettings = +``` + +Конфигурация словаря в ClickHouse: + +``` xml + + + table_name + + + + + DSN=myconnection + postgresql_table
+
+ + + 300 + 360 + + + + + + + id + + + some_column + UInt64 + 0 + + +
+
+``` + +или + +``` sql +CREATE DICTIONARY table_name ( + id UInt64, + some_column UInt64 DEFAULT 0 +) +PRIMARY KEY id +SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) +LAYOUT(HASHED()) +LIFETIME(MIN 300 MAX 360) + +Может понадобиться в `odbc.ini` указать полный путь до библиотеки с драйвером `DRIVER=/usr/local/lib/psqlodbcw.so`. + +### Пример подключения MS SQL Server + +ОС Ubuntu. + +Установка драйвера: : + +```bash +$ sudo apt-get install tdsodbc freetds-bin sqsh +``` + +Настройка драйвера: : + +``` bash + $ cat /etc/freetds/freetds.conf + ... + + [MSSQL] + host = 192.168.56.101 + port = 1433 + tds version = 7.0 + client charset = UTF-8 + + $ cat /etc/odbcinst.ini + ... + + [FreeTDS] + Description = FreeTDS + Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so + Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so + FileUsage = 1 + UsageCount = 5 + + $ cat ~/.odbc.ini + ... + + [MSSQL] + Description = FreeTDS + Driver = FreeTDS + Servername = MSSQL + Database = test + UID = test + PWD = test + Port = 1433 +``` + +Настройка словаря в ClickHouse: + +``` xml + + + test + + + dict
+ DSN=MSSQL;UID=test;PWD=test +
+ + + + 300 + 360 + + + + + + + + + k + + + s + String + + + +
+
+``` + +или + +``` sql +CREATE DICTIONARY test ( + k UInt64, + s String DEFAULT '' +) +PRIMARY KEY k +SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) +LAYOUT(FLAT()) +LIFETIME(MIN 300 MAX 360) +``` + +## СУБД {#subd} + +### MySQL {#dicts-external_dicts_dict_sources-mysql} + +Пример настройки: + +``` xml + + + 3306 + clickhouse + qwerty + + example01-1 + 1 + + + example01-2 + 1 + + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +или + +``` sql +SOURCE(MYSQL( + port 3306 + user 'clickhouse' + password 'qwerty' + replica(host 'example01-1' priority 1) + replica(host 'example01-2' priority 1) + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +Поля настройки: + +- `port` — порт сервера MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри ``). + +- `user` — имя пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри ``). + +- `password` — пароль пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри ``). + +- `replica` — блок конфигурации реплики. Блоков может быть несколько. + + - `replica/host` — хост MySQL. + - `replica/priority` — приоритет реплики. При попытке соединения ClickHouse обходит реплики в соответствии с приоритетом. Чем меньше цифра, тем выше приоритет. + +- `db` — имя базы данных. + +- `table` — имя таблицы. + +- `where` — условие выбора. Синтаксис условия совпадает с синтаксисом секции `WHERE` в MySQL, например, `id > 10 AND id < 20`. Необязательный параметр. + +- `invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external-dicts-dict-lifetime.md). + +MySQL можно подключить на локальном хосте через сокеты, для этого необходимо задать `host` и `socket`. + +Пример настройки: + +``` xml + + + localhost + /path/to/socket/file.sock + clickhouse + qwerty + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +или + +``` sql +SOURCE(MYSQL( + host 'localhost' + socket '/path/to/socket/file.sock' + user 'clickhouse' + password 'qwerty' + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +### ClickHouse {#dicts-external_dicts_dict_sources-clickhouse} + +Пример настройки: + +``` xml + + + example01-01-1 + 9000 + default + + default + ids
+ id=10 +
+ +``` + +или + +``` sql +SOURCE(CLICKHOUSE( + host 'example01-01-1' + port 9000 + user 'default' + password '' + db 'default' + table 'ids' + where 'id=10' +)) +``` + +Поля настройки: + +- `host` — хост ClickHouse. Если host локальный, то запрос выполняется без сетевого взаимодействия. Чтобы повысить отказоустойчивость решения, можно создать таблицу типа [Distributed](../../../engines/table-engines/special/distributed.md) и прописать её в дальнейших настройках. +- `port` — порт сервера ClickHouse. +- `user` — имя пользователя ClickHouse. +- `password` — пароль пользователя ClickHouse. +- `db` — имя базы данных. +- `table` — имя таблицы. +- `where` — условие выбора. Может отсутствовать. +- `invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external-dicts-dict-lifetime.md). + +### MongoDB {#dicts-external_dicts_dict_sources-mongodb} + +Пример настройки: + +``` xml + + + localhost + 27017 + + + test + dictionary_source + + +``` + +или + +``` sql +SOURCE(MONGO( + host 'localhost' + port 27017 + user '' + password '' + db 'test' + collection 'dictionary_source' +)) +``` + +Поля настройки: + +- `host` — хост MongoDB. +- `port` — порт сервера MongoDB. +- `user` — имя пользователя MongoDB. +- `password` — пароль пользователя MongoDB. +- `db` — имя базы данных. +- `collection` — имя коллекции. + +### Redis {#dicts-external_dicts_dict_sources-redis} + +Пример настройки: + +``` xml + + + localhost + 6379 + simple + 0 + + +``` + +или + +``` sql +SOURCE(REDIS( + host 'localhost' + port 6379 + storage_type 'simple' + db_index 0 +)) +``` + +Поля настройки: + +- `host` – хост Redis. +- `port` – порт сервера Redis. +- `storage_type` – способ хранения ключей. Необходимо использовать `simple` для источников с одним столбцом ключей, `hash_map` – для источников с двумя столбцами ключей. Источники с более, чем двумя столбцами ключей, не поддерживаются. Может отсутствовать, значение по умолчанию `simple`. +- `db_index` – номер базы данных. Может отсутствовать, значение по умолчанию 0. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md new file mode 100644 index 00000000000..4c3b4eb22e4 --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md @@ -0,0 +1,167 @@ +# Ключ и поля словаря {#kliuch-i-polia-slovaria} + +Секция `` описывает ключ словаря и поля, доступные для запросов. + +Описание в формате XML: + +``` xml + + + + Id + + + + + + + ... + + + +``` + +Атрибуты описываются элементами: + +- `` — [столбец с ключом](external-dicts-dict-structure.md#ext_dict_structure-key). +- `` — [столбец данных](external-dicts-dict-structure.md#ext_dict_structure-attributes). Можно задать несколько атрибутов. + +Создание словаря запросом: + +``` sql +CREATE DICTIONARY dict_name ( + Id UInt64, + -- attributes +) +PRIMARY KEY Id +... +``` + +Атрибуты задаются в теле запроса: + +- `PRIMARY KEY` — [столбец с ключом](external-dicts-dict-structure.md#ext_dict_structure-key) +- `AttrName AttrType` — [столбец данных](external-dicts-dict-structure.md#ext_dict_structure-attributes). Можно задать несколько столбцов. + +## Ключ {#ext_dict_structure-key} + +ClickHouse поддерживает следующие виды ключей: + +- Числовой ключ. `UInt64`. Описывается в теге `` или ключевым словом `PRIMARY KEY`. +- Составной ключ. Набор значений разного типа. Описывается в теге `` или ключевым словом `PRIMARY KEY`. + +Структура может содержать либо `` либо ``. DDL-запрос может содержать только `PRIMARY KEY`. + +!!! warning "Обратите внимание" + Ключ не надо дополнительно описывать в атрибутах. + +### Числовой ключ {#ext_dict-numeric-key} + +Тип: `UInt64`. + +Пример конфигурации: + +``` xml + + Id + +``` + +Поля конфигурации: + +- `name` — имя столбца с ключами. + +Для DDL-запроса: + +``` sql +CREATE DICTIONARY ( + Id UInt64, + ... +) +PRIMARY KEY Id +... +``` + +- `PRIMARY KEY` – имя столбца с ключами. + +### Составной ключ {#sostavnoi-kliuch} + +Ключом может быть кортеж (`tuple`) из полей произвольных типов. В этом случае [layout](external-dicts-dict-layout.md) должен быть `complex_key_hashed` или `complex_key_cache`. + +!!! tip "Совет" + Составной ключ может состоять из одного элемента. Это даёт возможность использовать в качестве ключа, например, строку. + +Структура ключа задаётся в элементе ``. Поля ключа задаются в том же формате, что и [атрибуты](external-dicts-dict-structure.md) словаря. Пример: + +``` xml + + + + field1 + String + + + field2 + UInt32 + + ... + +... +``` + +или + +``` sql +CREATE DICTIONARY ( + field1 String, + field2 String + ... +) +PRIMARY KEY field1, field2 +... +``` + +При запросе в функции `dictGet*` в качестве ключа передаётся кортеж. Пример: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. + +## Атрибуты {#ext_dict_structure-attributes} + +Пример конфигурации: + +``` xml + + ... + + Name + ClickHouseDataType + + rand64() + true + true + true + + +``` + +или + +``` sql +CREATE DICTIONARY somename ( + Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID +) +``` + +Поля конфигурации: + +| Тег | Описание | Обязательный | +|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| +| `name` | Имя столбца. | Да | +| `type` | Тип данных ClickHouse.
ClickHouse пытается привести значение из словаря к заданному типу данных. Например, в случае MySQL, в таблице-источнике поле может быть `TEXT`, `VARCHAR`, `BLOB`, но загружено может быть как `String`. [Nullable](../../../sql-reference/data-types/nullable.md) не поддерживается. | Да | +| `null_value` | Значение по умолчанию для несуществующего элемента.
В примере это пустая строка. Нельзя указать значение `NULL`. | Да | +| `expression` | [Выражение](../../syntax.md#syntax-expressions), которое ClickHouse выполняет со значением.
Выражением может быть имя столбца в удаленной SQL базе. Таким образом, вы можете использовать его для создания псевдонима удаленного столбца.

Значение по умолчанию: нет выражения. | Нет | +| `hierarchical` | Если `true`, то атрибут содержит ключ предка для текущего элемента. Смотрите [Иерархические словари](external-dicts-dict-hierarchical.md).

Default value: `false`. | No | +| `is_object_id` | Признак того, что запрос выполняется к документу MongoDB по `ObjectID`.

Значение по умолчанию: `false`. | Нет | + +## Смотрите также {#smotrite-takzhe} + +- [Функции для работы с внешними словарями](../../../sql-reference/functions/ext-dict-functions.md). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md new file mode 100644 index 00000000000..a7d3394864b --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md @@ -0,0 +1,46 @@ +# Настройка внешнего словаря {#dicts-external-dicts-dict} + +XML-конфигурация словаря имеет следующую структуру: + +``` xml + + dict_name + + + + + + + + + + + + + + + + + +``` + +Соответствующий [DDL-запрос](../../statements/create.md#create-dictionary-query) имеет следующий вид: + +``` sql +CREATE DICTIONARY dict_name +( + ... -- attributes +) +PRIMARY KEY ... -- complex or single key configuration +SOURCE(...) -- Source configuration +LAYOUT(...) -- Memory layout configuration +LIFETIME(...) -- Lifetime of dictionary in memory +``` + +- `name` — Идентификатор, под которым словарь будет доступен для использования. Используйте символы `[a-zA-Z0-9_\-]`. +- [source](external-dicts-dict-sources.md) — Источник словаря. +- [layout](external-dicts-dict-layout.md) — Размещение словаря в памяти. +- [structure](external-dicts-dict-structure.md) — Структура словаря. Ключ и атрибуты, которые можно получить по ключу. +- [lifetime](external-dicts-dict-lifetime.md) — Периодичность обновления словарей. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts.md new file mode 100644 index 00000000000..80f717dfe93 --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts.md @@ -0,0 +1,58 @@ +# Внешние словари {#dicts-external-dicts} + +Существует возможность подключать собственные словари из различных источников данных. Источником данных для словаря может быть локальный текстовый/исполняемый файл, HTTP(s) ресурс или другая СУБД. Подробнее смотрите в разделе «[Источники внешних словарей](external-dicts-dict-sources.md)». + +ClickHouse: +- Полностью или частично хранит словари в оперативной памяти. +- Периодически обновляет их и динамически подгружает отсутствующие значения. +- Позволяет создавать внешние словари с помощью xml-файлов или [DDL-запросов](../../statements/create.md#create-dictionary-query). + +Конфигурация внешних словарей может находится в одном или нескольких xml-файлах. Путь к конфигурации указывается в параметре [dictionaries\_config](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_config). + +Словари могут загружаться при старте сервера или при первом использовании, в зависимости от настройки [dictionaries\_lazy\_load](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load). + +Системная таблица [system.dictionaries](../../../operations/system-tables.md#system_tables-dictionaries) содержит информацию о словарях, сконфигурированных на сервере. Для каждого словаря там можно найти: + +- Статус словаря. +- Конфигурационные параметры. +- Метрики, наподобие количества занятой словарём RAM или количества запросов к словарю с момента его успешной загрузки. + +Конфигурационный файл словарей имеет вид: + +``` xml + + Необязательный элемент с любым содержимым. Игнорируется сервером ClickHouse. + + + /etc/metrika.xml + + + + + + + ... + + + + + +``` + +В одном файле можно [сконфигурировать](external-dicts-dict.md) произвольное количество словарей. + +Если вы создаёте внешние словари [DDL-запросами](../../statements/create.md#create-dictionary-query), то не задавайте конфигурацию словаря в конфигурации сервера. + +!!! attention "Внимание" + Можно преобразовывать значения по небольшому словарю, описав его в запросе `SELECT` (см. функцию [transform](../../../sql-reference/functions/other-functions.md)). Эта функциональность не связана с внешними словарями. + +## Смотрите также {#ext-dicts-see-also} + +- [Настройка внешнего словаря](external-dicts-dict.md) +- [Хранение словарей в памяти](external-dicts-dict-layout.md) +- [Обновление словарей](external-dicts-dict-lifetime.md) +- [Источники внешних словарей](external-dicts-dict-sources.md) +- [Ключ и поля словаря](external-dicts-dict-structure.md) +- [Функции для работы с внешними словарями](../../../sql-reference/functions/ext-dict-functions.md) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts/) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/index.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/index.md new file mode 100644 index 00000000000..4098ac38060 --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: External Dictionaries +toc_priority: 37 +--- + + diff --git a/docs/ru/sql-reference/dictionaries/index.md b/docs/ru/sql-reference/dictionaries/index.md new file mode 100644 index 00000000000..8625a29b1e1 --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/index.md @@ -0,0 +1,14 @@ +# Словари {#slovari} + +Словарь — это отображение (`ключ -> атрибуты`), которое удобно использовать для различного вида справочников. + +ClickHouse поддерживает специальные функции для работы со словарями, которые можно использовать в запросах. Проще и эффективнее использовать словари с помощью функций, чем `JOIN` с таблицами-справочниками. + +В словаре нельзя хранить значения [NULL](../../sql-reference/syntax.md#null-literal). + +ClickHouse поддерживает: + +- [Встроенные словари](internal-dicts.md#internal_dicts) со специфическим [набором функций](../../sql-reference/dictionaries/external-dictionaries/index.md). +- [Подключаемые (внешние) словари](external-dictionaries/external-dicts.md#dicts-external-dicts) с [набором функций](../../sql-reference/dictionaries/external-dictionaries/index.md). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/) diff --git a/docs/ru/sql-reference/dictionaries/internal-dicts.md b/docs/ru/sql-reference/dictionaries/internal-dicts.md new file mode 100644 index 00000000000..0e8e7c82a6e --- /dev/null +++ b/docs/ru/sql-reference/dictionaries/internal-dicts.md @@ -0,0 +1,48 @@ +# Встроенные словари {#internal_dicts} + +ClickHouse содержит встроенную возможность работы с геобазой. + +Это позволяет: + +- для идентификатора региона получить его имя на нужном языке; +- по идентификатору региона получить идентификатор города, области, федерального округа, страны, континента; +- проверить, что один регион входит в другой; +- получить цепочку родительских регионов. + +Все функции поддерживают «транслокальность», то есть возможность использовать одновременно разные точки зрения на принадлежность регионов. Подробнее смотрите в разделе «Функции для работы со словарями Яндекс.Метрики». + +В пакете по умолчанию, встроенные словари выключены. +Для включения, раскомментируйте параметры `path_to_regions_hierarchy_file` и `path_to_regions_names_files` в конфигурационном файле сервера. + +Геобаза загружается из текстовых файлов. + +Положите файлы `regions_hierarchy*.txt` в директорию `path_to_regions_hierarchy_file`. Этот конфигурационный параметр должен содержать путь к файлу `regions_hierarchy.txt` (иерархия регионов по умолчанию), а другие файлы (`regions_hierarchy_ua.txt`) должны находиться рядом в той же директории. + +Положите файлы `regions_names_*.txt` в директорию `path_to_regions_names_files`. + +Также вы можете создать эти файлы самостоятельно. Формат файлов такой: + +`regions_hierarchy*.txt`: TabSeparated (без заголовка), столбцы: + +- идентификатор региона (`UInt32`); +- идентификатор родительского региона (`UInt32`); +- тип региона (`UInt8`): 1 - континент, 3 - страна, 4 - федеральный округ, 5 - область, 6 - город; остальные типы не имеют значения; +- население (`UInt32`) - не обязательный столбец. + +`regions_names_*.txt`: TabSeparated (без заголовка), столбцы: + +- идентификатор региона (`UInt32`); +- имя региона (`String`) - не может содержать табы или переводы строк, даже экранированные. + +Для хранения в оперативке используется плоский массив. Поэтому, идентификаторы не должны быть больше миллиона. + +Словари могут обновляться без перезапуска сервера. Но набор доступных словарей не обновляется. +Для обновления проверяется время модификации файлов; если файл изменился, то словарь будет обновлён. +Периодичность проверки настраивается конфигурационным параметром `builtin_dictionaries_reload_interval`. +Обновление словарей (кроме загрузки при первом использовании) не блокирует запросы - во время обновления запросы используют старую версию словарей. Если при обновлении возникнет ошибка, то ошибка пишется в лог сервера, а запросы продолжат использовать старую версию словарей. + +Рекомендуется периодически обновлять словари с геобазой. При обновлении, генерируйте новые файлы, записывая их в отдельное место, а только когда всё готово - переименовывайте в файлы, которые использует сервер. + +Также имеются функции для работы с идентификаторами операционных систем и поисковых систем Яндекс.Метрики, пользоваться которыми не нужно. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/internal_dicts/) diff --git a/docs/ru/sql-reference/functions/arithmetic-functions.md b/docs/ru/sql-reference/functions/arithmetic-functions.md new file mode 100644 index 00000000000..8513737f025 --- /dev/null +++ b/docs/ru/sql-reference/functions/arithmetic-functions.md @@ -0,0 +1,81 @@ +# Арифметические функции {#arifmeticheskie-funktsii} + +Для всех арифметических функций, тип результата вычисляется, как минимальный числовой тип, который может вместить результат, если такой тип есть. Минимум берётся одновременно по числу бит, знаковости и «плавучести». Если бит не хватает, то берётся тип максимальной битности. + +Пример: + +``` sql +SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) +``` + +``` text +┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ +│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ +└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ +``` + +Арифметические функции работают для любой пары типов из UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, Float64. + +Переполнение производится также, как в C++. + +## plus(a, b), оператор a + b {#plusa-b-operator-a-b} + +Вычисляет сумму чисел. +Также можно складывать целые числа с датой и датой-с-временем. В случае даты, прибавление целого числа означает прибавление соответствующего количества дней. В случае даты-с-временем - прибавление соответствующего количества секунд. + +## minus(a, b), оператор a - b {#minusa-b-operator-a-b} + +Вычисляет разность чисел. Результат всегда имеет знаковый тип. + +Также можно вычитать целые числа из даты и даты-с-временем. Смысл аналогичен - смотрите выше для plus. + +## multiply(a, b), оператор a \* b {#multiplya-b-operator-a-b} + +Вычисляет произведение чисел. + +## divide(a, b), оператор a / b {#dividea-b-operator-a-b} + +Вычисляет частное чисел. Тип результата всегда является типом с плавающей запятой. +То есть, деление не целочисленное. Для целочисленного деления, используйте функцию intDiv. +При делении на ноль получится inf, -inf или nan. + +## intDiv(a, b) {#intdiva-b} + +Вычисляет частное чисел. Деление целочисленное, с округлением вниз (по абсолютному значению). +При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. + +## intDivOrZero(a, b) {#intdivorzeroa-b} + +Отличается от intDiv тем, что при делении на ноль или при делении минимального отрицательного числа на минус единицу, возвращается ноль. + +## modulo(a, b), оператор a % b {#modulo} + +Вычисляет остаток от деления. +Если аргументы - числа с плавающей запятой, то они предварительно преобразуются в целые числа, путём отбрасывания дробной части. +Берётся остаток в том же смысле, как это делается в C++. По факту, для отрицательных чисел, используется truncated division. +При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. + +## moduloOrZero(a, b) {#modulo-or-zero} + +В отличие от [modulo](#modulo), возвращает ноль при делении на ноль. + +## negate(a), оператор -a {#negatea-operator-a} + +Вычисляет число, обратное по знаку. Результат всегда имеет знаковый тип. + +## abs(a) {#arithm_func-abs} + +Вычисляет абсолютное значение для числа a. То есть, если a \< 0, то возвращает -a. +Для беззнаковых типов ничего не делает. Для чисел типа целых со знаком, возвращает число беззнакового типа. + +## gcd(a, b) {#gcda-b} + +Вычисляет наибольший общий делитель чисел. +При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. + +## lcm(a, b) {#lcma-b} + +Вычисляет наименьшее общее кратное чисел. +При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/arithmetic_functions/) diff --git a/docs/ru/sql-reference/functions/array-functions.md b/docs/ru/sql-reference/functions/array-functions.md new file mode 100644 index 00000000000..71b6bda47d0 --- /dev/null +++ b/docs/ru/sql-reference/functions/array-functions.md @@ -0,0 +1,972 @@ +# Функции по работе с массивами {#funktsii-po-rabote-s-massivami} + +## empty {#function-empty} + +Возвращает 1 для пустого массива, и 0 для непустого массива. +Тип результата - UInt8. +Функция также работает для строк. + +## notEmpty {#function-notempty} + +Возвращает 0 для пустого массива, и 1 для непустого массива. +Тип результата - UInt8. +Функция также работает для строк. + +## length {#array_functions-length} + +Возвращает количество элементов в массиве. +Тип результата - UInt64. +Функция также работает для строк. + +## emptyArrayUInt8, emptyArrayUInt16, emptyArrayUInt32, emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} + +## emptyArrayInt8, emptyArrayInt16, emptyArrayInt32, emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} + +## emptyArrayFloat32, emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} + +## emptyArrayDate, emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} + +## emptyArrayString {#emptyarraystring} + +Принимает ноль аргументов и возвращает пустой массив соответствующего типа. + +## emptyArrayToSingle {#emptyarraytosingle} + +Принимает пустой массив и возвращает массив из одного элемента, равного значению по умолчанию. + +## range(N) {#rangen} + +Возвращает массив чисел от 0 до N-1. +На всякий случай, если на блок данных, создаются массивы суммарной длины больше 100 000 000 элементов, то кидается исключение. + +## array(x1, …), оператор \[x1, …\] {#arrayx1-operator-x1} + +Создаёт массив из аргументов функции. +Аргументы должны быть константами и иметь типы, для которых есть наименьший общий тип. Должен быть передан хотя бы один аргумент, так как иначе непонятно, какого типа создавать массив. То есть, с помощью этой функции невозможно создать пустой массив (для этого используйте функции emptyArray\*, описанные выше). +Возвращает результат типа Array(T), где T - наименьший общий тип от переданных аргументов. + +## arrayConcat {#arrayconcat} + +Объединяет массивы, переданные в качестве аргументов. + +``` sql +arrayConcat(arrays) +``` + +**Параметры** + +- `arrays` – произвольное количество элементов типа [Array](../../sql-reference/functions/array-functions.md) + **Пример** + + + +``` sql +SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res +``` + +``` text +┌─res───────────┐ +│ [1,2,3,4,5,6] │ +└───────────────┘ +``` + +## arrayElement(arr, n), operator arr\[n\] {#arrayelementarr-n-operator-arrn} + +Достаёт элемент с индексом n из массива arr. n должен быть любым целочисленным типом. +Индексы в массиве начинаются с единицы. +Поддерживаются отрицательные индексы. В этом случае, будет выбран соответствующий по номеру элемент с конца. Например, arr\[-1\] - последний элемент массива. + +Если индекс выходит за границы массива, то возвращается некоторое значение по умолчанию (0 для чисел, пустая строка для строк и т. п.), кроме случая с неконстантным массивом и константным индексом 0 (в этом случае будет ошибка `Array indices are 1-based`). + +## has(arr, elem) {#hasarr-elem} + +Проверяет наличие элемента elem в массиве arr. +Возвращает 0, если элемента в массиве нет, или 1, если есть. + +`NULL` обрабатывается как значение. + +``` sql +SELECT has([1, 2, NULL], NULL) +``` + +``` text +┌─has([1, 2, NULL], NULL)─┐ +│ 1 │ +└─────────────────────────┘ +``` + +## hasAll {#hasall} + +Проверяет, является ли один массив подмножеством другого. + +``` sql +hasAll(set, subset) +``` + +**Параметры** + +- `set` – массив любого типа с набором элементов. +- `subset` – массив любого типа со значениями, которые проверяются на вхождение в `set`. + +**Возвращаемые значения** + +- `1`, если `set` содержит все элементы из `subset`. +- `0`, в противном случае. + +**Особенности** + +- Пустой массив является подмножеством любого массива. +- `NULL` обрабатывается как значение. +- Порядок значений в обоих массивах не имеет значения. + +**Примеры** + +`SELECT hasAll([], [])` возвращает 1. + +`SELECT hasAll([1, Null], [Null])` возвращает 1. + +`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` возвращает 1. + +`SELECT hasAll(['a', 'b'], ['a'])` возвращает 1. + +`SELECT hasAll([1], ['a'])` возвращает 0. + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` возвращает 0. + +## hasAny {#hasany} + +Проверяет, имеют ли два массива хотя бы один общий элемент. + +``` sql +hasAny(array1, array2) +``` + +**Параметры** + +- `array1` – массив любого типа с набором элементов. +- `array2` – массив любого типа с набором элементов. + +**Возвращаемые значения** + +- `1`, если `array1` и `array2` имеют хотя бы один одинаковый элемент. +- `0`, в противном случае. + +**Особенности** + +- `NULL` обрабатывается как значение. +- Порядок значений в обоих массивах не имеет значения. + +**Примеры** + +`SELECT hasAny([1], [])` возвращает `0`. + +`SELECT hasAny([Null], [Null, 1])` возвращает `1`. + +`SELECT hasAny([-128, 1., 512], [1])` возвращает `1`. + +`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` возвращает `0`. + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` возвращает `1`. + +## indexOf(arr, x) {#indexofarr-x} + +Возвращает индекс первого элемента x (начиная с 1), если он есть в массиве, или 0, если его нет. + +Пример: + +``` sql +SELECT indexOf([1, 3, NULL, NULL], NULL) +``` + +``` text +┌─indexOf([1, 3, NULL, NULL], NULL)─┐ +│ 3 │ +└───────────────────────────────────┘ +``` + +Элементы, равные `NULL`, обрабатываются как обычные значения. + +## countEqual(arr, x) {#countequalarr-x} + +Возвращает количество элементов массива, равных x. Эквивалентно arrayCount(elem -\> elem = x, arr). + +`NULL` обрабатывается как значение. + +Пример: + +``` sql +SELECT countEqual([1, 2, NULL, NULL], NULL) +``` + +``` text +┌─countEqual([1, 2, NULL, NULL], NULL)─┐ +│ 2 │ +└──────────────────────────────────────┘ +``` + +## arrayEnumerate(arr) {#array_functions-arrayenumerate} + +Возвращает массив \[1, 2, 3, …, length(arr)\] + +Эта функция обычно используется совместно с ARRAY JOIN. Она позволяет, после применения ARRAY JOIN, посчитать что-либо только один раз для каждого массива. Пример: + +``` sql +SELECT + count() AS Reaches, + countIf(num = 1) AS Hits +FROM test.hits +ARRAY JOIN + GoalsReached, + arrayEnumerate(GoalsReached) AS num +WHERE CounterID = 160656 +LIMIT 10 +``` + +``` text +┌─Reaches─┬──Hits─┐ +│ 95606 │ 31406 │ +└─────────┴───────┘ +``` + +В этом примере, Reaches - число достижений целей (строк, получившихся после применения ARRAY JOIN), а Hits - число хитов (строк, которые были до ARRAY JOIN). В данном случае, тот же результат можно получить проще: + +``` sql +SELECT + sum(length(GoalsReached)) AS Reaches, + count() AS Hits +FROM test.hits +WHERE (CounterID = 160656) AND notEmpty(GoalsReached) +``` + +``` text +┌─Reaches─┬──Hits─┐ +│ 95606 │ 31406 │ +└─────────┴───────┘ +``` + +Также эта функция может быть использована в функциях высшего порядка. Например, с её помощью можно достать индексы массива для элементов, удовлетворяющих некоторому условию. + +## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} + +Возвращает массив, такого же размера, как исходный, где для каждого элемента указано, какой он по счету среди элементов с таким же значением. +Например: arrayEnumerateUniq(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. + +Эта функция полезна при использовании ARRAY JOIN и агрегации по элементам массива. +Пример: + +``` sql +SELECT + Goals.ID AS GoalID, + sum(Sign) AS Reaches, + sumIf(Sign, num = 1) AS Visits +FROM test.visits +ARRAY JOIN + Goals, + arrayEnumerateUniq(Goals.ID) AS num +WHERE CounterID = 160656 +GROUP BY GoalID +ORDER BY Reaches DESC +LIMIT 10 +``` + +``` text +┌──GoalID─┬─Reaches─┬─Visits─┐ +│ 53225 │ 3214 │ 1097 │ +│ 2825062 │ 3188 │ 1097 │ +│ 56600 │ 2803 │ 488 │ +│ 1989037 │ 2401 │ 365 │ +│ 2830064 │ 2396 │ 910 │ +│ 1113562 │ 2372 │ 373 │ +│ 3270895 │ 2262 │ 812 │ +│ 1084657 │ 2262 │ 345 │ +│ 56599 │ 2260 │ 799 │ +│ 3271094 │ 2256 │ 812 │ +└─────────┴─────────┴────────┘ +``` + +В этом примере, для каждого идентификатора цели, посчитано количество достижений целей (каждый элемент вложенной структуры данных Goals является достижением целей) и количество визитов. Если бы не было ARRAY JOIN, мы бы считали количество визитов как sum(Sign). Но в данном случае, строчки были размножены по вложенной структуре Goals, и чтобы после этого учесть каждый визит один раз, мы поставили условие на значение функции arrayEnumerateUniq(Goals.ID). + +Функция arrayEnumerateUniq может принимать несколько аргументов - массивов одинаковых размеров. В этом случае, уникальность считается для кортежей элементов на одинаковых позициях всех массивов. + +``` sql +SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res +``` + +``` text +┌─res───────────┐ +│ [1,2,1,1,2,1] │ +└───────────────┘ +``` + +Это нужно при использовании ARRAY JOIN с вложенной структурой данных и затем агрегации по нескольким элементам этой структуры. + +## arrayPopBack {#arraypopback} + +Удаляет последний элемент из массива. + +``` sql +arrayPopBack(array) +``` + +**Параметры** + +- `array` - Массив. + +**Пример** + +``` sql +SELECT arrayPopBack([1, 2, 3]) AS res +``` + +text + + ┌─res───┐ + │ [1,2] │ + └───────┘ + +## arrayPopFront {#arraypopfront} + +Удаляет первый элемент из массива. + +``` sql +arrayPopFront(array) +``` + +**Параметры** + +- `array` - Массив. + +**Пример** + +``` sql +SELECT arrayPopFront([1, 2, 3]) AS res +``` + +``` text +┌─res───┐ +│ [2,3] │ +└───────┘ +``` + +## arrayPushBack {#arraypushback} + +Добавляет один элемент в конец массива. + +``` sql +arrayPushBack(array, single_value) +``` + +**Параметры** + +- `array` - Массив. +- `single_value` - Одиночное значение. В массив с числам можно добавить только числа, в массив со строками только строки. При добавлении чисел ClickHouse автоматически приводит тип `single_value` к типу данных массива. Подробнее о типах данных в ClickHouse читайте в разделе «[Типы данных](../../sql-reference/functions/array-functions.md#data_types)». Может быть равно `NULL`. Функция добавит элемент `NULL` в массив, а тип элементов массива преобразует в `Nullable`. + +**Пример** + +``` sql +SELECT arrayPushBack(['a'], 'b') AS res +``` + +``` text +┌─res───────┐ +│ ['a','b'] │ +└───────────┘ +``` + +## arrayPushFront {#arraypushfront} + +Добавляет один элемент в начало массива. + +``` sql +arrayPushFront(array, single_value) +``` + +**Параметры** + +- `array` - Массив. +- `single_value` - Одиночное значение. В массив с числам можно добавить только числа, в массив со строками только строки. При добавлении чисел ClickHouse автоматически приводит тип `single_value` к типу данных массива. Подробнее о типах данных в ClickHouse читайте в разделе «[Типы данных](../../sql-reference/functions/array-functions.md#data_types)». Может быть равно `NULL`. Функция добавит элемент `NULL` в массив, а тип элементов массива преобразует в `Nullable`. + +**Пример** + +``` sql +SELECT arrayPushFront(['b'], 'a') AS res +``` + +``` text +┌─res───────┐ +│ ['a','b'] │ +└───────────┘ +``` + +## arrayResize {#arrayresize} + +Изменяет длину массива. + +``` sql +arrayResize(array, size[, extender]) +``` + +**Параметры** + +- `array` — массив. +- `size` — необходимая длина массива. + - Если `size` меньше изначального размера массива, то массив обрезается справа. + - Если `size` больше изначального размера массива, массив дополняется справа значениями `extender` или значениями по умолчанию для типа данных элементов массива. +- `extender` — значение для дополнения массива. Может быть `NULL`. + +**Возвращаемое значение:** + +Массив длины `size`. + +**Примеры вызовов** + +``` sql +SELECT arrayResize([1], 3) +``` + +``` text +┌─arrayResize([1], 3)─┐ +│ [1,0,0] │ +└─────────────────────┘ +``` + +``` sql +SELECT arrayResize([1], 3, NULL) +``` + +``` text +┌─arrayResize([1], 3, NULL)─┐ +│ [1,NULL,NULL] │ +└───────────────────────────┘ +``` + +## arraySlice {#arrayslice} + +Возвращает срез массива. + +``` sql +arraySlice(array, offset[, length]) +``` + +**Параметры** + +- `array` - Массив данных. +- `offset` - Отступ от края массива. Положительное значение - отступ слева, отрицательное значение - отступ справа. Отсчет элементов массива начинается с 1. +- `length` - Длина необходимого среза. Если указать отрицательное значение, то функция вернёт открытый срез `[offset, array_length - length)`. Если не указать значение, то функция вернёт срез `[offset, the_end_of_array]`. + +**Пример** + +``` sql +SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res +``` + +``` text +┌─res────────┐ +│ [2,NULL,4] │ +└────────────┘ +``` + +Элементы массива равные `NULL` обрабатываются как обычные значения. + +## arraySort(\[func,\] arr, …) {#array_functions-sort} + +Возвращает массив `arr`, отсортированный в восходящем порядке. Если задана функция `func`, то порядок сортировки определяется результатом применения этой функции на элементы массива `arr`. Если `func` принимает несколько аргументов, то в функцию `arraySort` нужно передавать несколько массивов, которые будут соответствовать аргументам функции `func`. Подробные примеры рассмотрены в конце описания `arraySort`. + +Пример сортировки целочисленных значений: + +``` sql +SELECT arraySort([1, 3, 3, 0]) +``` + +``` text +┌─arraySort([1, 3, 3, 0])─┐ +│ [0,1,3,3] │ +└─────────────────────────┘ +``` + +Пример сортировки строковых значений: + +``` sql +SELECT arraySort(['hello', 'world', '!']) +``` + +``` text +┌─arraySort(['hello', 'world', '!'])─┐ +│ ['!','hello','world'] │ +└────────────────────────────────────┘ +``` + +Значения `NULL`, `NaN` и `Inf` сортируются по следующему принципу: + +``` sql +SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); +``` + +``` text +┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ +│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────────────────────────┘ +``` + +- Значения `-Inf` идут в начале массива. +- Значения `NULL` идут в конце массива. +- Значения `NaN` идут перед `NULL`. +- Значения `Inf` идут перед `NaN`. + +Функция `arraySort` является [функцией высшего порядка](higher-order-functions.md) — в качестве первого аргумента ей можно передать лямбда-функцию. В этом случае порядок сортировки определяется результатом применения лямбда-функции на элементы массива. + +Рассмотрим пример: + +``` sql +SELECT arraySort((x) -> -x, [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [3,2,1] │ +└─────────┘ +``` + +Для каждого элемента исходного массива лямбда-функция возвращает ключ сортировки, то есть \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Так как `arraySort` сортирует элементы в порядке возрастания ключей, результат будет \[3, 2, 1\]. Как можно заметить, функция `x –> -x` устанавливает [обратный порядок сортировки](#array_functions-reverse-sort). + +Лямбда-функция может принимать несколько аргументов. В этом случае, в функцию `arraySort` нужно передавать несколько массивов, которые будут соответствовать аргументам лямбда-функции (массивы должны быть одинаковой длины). Следует иметь в виду, что результат будет содержать элементы только из первого массива; элементы из всех последующих массивов будут задавать ключи сортировки. Например: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res────────────────┐ +│ ['world', 'hello'] │ +└────────────────────┘ +``` + +Элементы, указанные во втором массиве (\[2,1\]), определяют ключ сортировки для элементов из исходного массива (\[‘hello’, ‘world’\]), то есть \[‘hello’ –\> 2, ‘world’ –\> 1\]. Так как лямбда-функция не использует `x`, элементы исходного массива не влияют на порядок сортировки. Таким образом, ‘hello’ будет вторым элементом в отсортированном массиве, а ‘world’ — первым. + +Ниже приведены другие примеры. + +``` sql +SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; +``` + +``` text +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +``` sql +SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +!!! note "Примечание" + Для улучшения эффективности сортировки применяется [преобразование Шварца](https://ru.wikipedia.org/wiki/%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5_%D0%A8%D0%B2%D0%B0%D1%80%D1%86%D0%B0). + +## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} + +Возвращает массив `arr`, отсортированный в нисходящем порядке. Если указана функция `func`, то массив `arr` сначала сортируется в порядке, который определяется функцией `func`, а затем отсортированный массив переворачивается. Если функция `func` принимает несколько аргументов, то в функцию `arrayReverseSort` необходимо передавать несколько массивов, которые будут соответствовать аргументам функции `func`. Подробные примеры рассмотрены в конце описания функции `arrayReverseSort`. + +Пример сортировки целочисленных значений: + +``` sql +SELECT arrayReverseSort([1, 3, 3, 0]); +``` + +``` text +┌─arrayReverseSort([1, 3, 3, 0])─┐ +│ [3,3,1,0] │ +└────────────────────────────────┘ +``` + +Пример сортировки строковых значений: + +``` sql +SELECT arrayReverseSort(['hello', 'world', '!']); +``` + +``` text +┌─arrayReverseSort(['hello', 'world', '!'])─┐ +│ ['world','hello','!'] │ +└───────────────────────────────────────────┘ +``` + +Значения `NULL`, `NaN` и `Inf` сортируются в следующем порядке: + +``` sql +SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; +``` + +``` text +┌─res───────────────────────────────────┐ +│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────┘ +``` + +- Значения `Inf` идут в начале массива. +- Значения `NULL` идут в конце массива. +- Значения `NaN` идут перед `NULL`. +- Значения `-Inf` идут перед `NaN`. + +Функция `arrayReverseSort` является [функцией высшего порядка](higher-order-functions.md). Вы можете передать ей в качестве первого аргумента лямбда-функцию. Например: + +``` sql +SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [1,2,3] │ +└─────────┘ +``` + +В этом примере, порядок сортировки устанавливается следующим образом: + +1. Сначала исходный массив (\[1, 2, 3\]) сортируется в том порядке, который определяется лямбда-функцией. Результатом будет массив \[3, 2, 1\]. +2. Массив, который был получен на предыдущем шаге, переворачивается. То есть, получается массив \[1, 2, 3\]. + +Лямбда-функция может принимать на вход несколько аргументов. В этом случае, в функцию `arrayReverseSort` нужно передавать несколько массивов, которые будут соответствовать аргументам лямбда-функции (массивы должны быть одинаковой длины). Следует иметь в виду, что результат будет содержать элементы только из первого массива; элементы из всех последующих массивов будут определять ключи сортировки. Например: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +В этом примере, массив сортируется следующим образом: + +1. Сначала массив сортируется в том порядке, который определяется лямбда-функцией. Элементы, указанные во втором массиве (\[2,1\]), определяют ключи сортировки соответствующих элементов из исходного массива (\[‘hello’, ‘world’\]). То есть, будет массив \[‘world’, ‘hello’\]. +2. Массив, который был отсортирован на предыдущем шаге, переворачивается. Получается массив \[‘hello’, ‘world’\]. + +Ниже приведены ещё примеры. + +``` sql +SELECT arrayReverseSort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; +``` + +``` text +┌─res─────┐ +│ [0,1,2] │ +└─────────┘ +``` + +``` sql +SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; +``` + +``` text +┌─res─────┐ +│ [4,3,5] │ +└─────────┘ +``` + +## arrayUniq(arr, …) {#array-functions-arrayuniq} + +Если передан один аргумент, считает количество разных элементов в массиве. +Если передано несколько аргументов, считает количество разных кортежей из элементов на соответствующих позициях в нескольких массивах. + +Если необходимо получить список уникальных элементов массива, можно воспользоваться arrayReduce(‘groupUniqArray’, arr). + +## arrayJoin(arr) {#array-functions-arrayjoin} + +Особенная функция. Смотрите раздел [«Функция arrayJoin»](array-join.md#functions_arrayjoin). + +## arrayDifference {#arraydifference} + +Вычисляет разность между соседними элементами массива. Возвращает массив, где первым элементом будет 0, вторым – разность `a[1] - a[0]` и т. д. Тип элементов результирующего массива определяется правилами вывода типов при вычитании (напр. `UInt8` - `UInt8` = `Int16`). + +**Синтаксис** + +``` sql +arrayDifference(array) +``` + +**Параметры** + +- `array` – [Массив](https://clickhouse.yandex/docs/ru/data_types/array/). + +**Возвращаемое значение** + +Возвращает массив разностей между соседними элементами. + +**Пример** + +Запрос: + +``` sql +SELECT arrayDifference([1, 2, 3, 4]) +``` + +Ответ: + +``` text +┌─arrayDifference([1, 2, 3, 4])─┐ +│ [0,1,1,1] │ +└───────────────────────────────┘ +``` + +Пример переполнения из-за результирующего типа `Int64`: + +Запрос: + +``` sql +SELECT arrayDifference([0, 10000000000000000000]) +``` + +Ответ: + +``` text +┌─arrayDifference([0, 10000000000000000000])─┐ +│ [0,-8446744073709551616] │ +└────────────────────────────────────────────┘ +``` + +## arrayDistinct {#arraydistinct} + +Принимает массив, возвращает массив, содержащий уникальные элементы. + +**Синтаксис** + +``` sql +arrayDistinct(array) +``` + +**Параметры** + +- `array` – [Массив](https://clickhouse.yandex/docs/ru/data_types/array/). + +**Возвращаемое значение** + +Возвращает массив, содержащий только уникальные элементы исходного массива. + +**Пример** + +Запрос: + +``` sql +SELECT arrayDistinct([1, 2, 2, 3, 1]) +``` + +Ответ: + +``` text +┌─arrayDistinct([1, 2, 2, 3, 1])─┐ +│ [1,2,3] │ +└────────────────────────────────┘ +``` + +## arrayEnumerateDense(arr) {#array_functions-arrayenumeratedense} + +Возвращает массив того же размера, что и исходный массив, с индексами исходного массива, указывающими, где каждый элемент впервые появляется в исходном массиве. + +Пример: + +``` sql +SELECT arrayEnumerateDense([10, 20, 10, 30]) +``` + +``` text +┌─arrayEnumerateDense([10, 20, 10, 30])─┐ +│ [1,2,1,3] │ +└───────────────────────────────────────┘ +``` + +## arrayIntersect(arr) {#array-functions-arrayintersect} + +Принимает несколько массивов, возвращает массив с элементами, присутствующими во всех исходных массивах. Элементы на выходе следуют в порядке следования в первом массиве. + +Пример: + +``` sql +SELECT + arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, + arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect +``` + +``` text +┌─no_intersect─┬─intersect─┐ +│ [] │ [1] │ +└──────────────┴───────────┘ +``` + +## arrayReduce(agg\_func, arr1, …) {#array-functions-arrayreduce} + +Применяет агрегатную функцию к элементам массива и возвращает ее результат. Имя агрегирующей функции передается как строка в одинарных кавычках `'max'`, `'sum'`. При использовании параметрических агрегатных функций, параметр указывается после имени функции в круглых скобках `'uniqUpTo(6)'`. + +Пример: + +``` sql +SELECT arrayReduce('max', [1, 2, 3]) +``` + +``` text +┌─arrayReduce('max', [1, 2, 3])─┐ +│ 3 │ +└───────────────────────────────┘ +``` + +Если агрегатная функция имеет несколько аргументов, то эту функцию можно применять к нескольким массивам одинакового размера. + +Пример: + +``` sql +SELECT arrayReduce('maxIf', [3, 5], [1, 0]) +``` + +``` text +┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ +│ 3 │ +└──────────────────────────────────────┘ +``` + +Пример с параметрической агрегатной функцией: + +``` sql +SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) +``` + +``` text +┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ +│ 4 │ +└─────────────────────────────────────────────────────────────┘ +``` + +## arrayReverse(arr) {#arrayreverse} + +Возвращает массив того же размера, что и исходный массив, содержащий элементы в обратном порядке. + +Пример: + +``` sql +SELECT arrayReverse([1, 2, 3]) +``` + +``` text +┌─arrayReverse([1, 2, 3])─┐ +│ [3,2,1] │ +└─────────────────────────┘ +``` + +## reverse(arr) {#array-functions-reverse} + +Синоним для [«arrayReverse»](#arrayreverse) + +## arrayFlatten {#arrayflatten} + +Преобразует массив массивов в плоский массив. + +Функция: + +- Оперирует с массивами любой вложенности. +- Не изменяет массив, если он уже плоский. + +Результирующий массив содержит все элементы исходных массивов. + +**Синтаксис** + +``` sql +flatten(array_of_arrays) +``` + +Синоним: `flatten`. + +**Параметры** + +- `array_of_arrays` — [Массивов](../../sql-reference/functions/array-functions.md) массивов. Например, `[[1,2,3], [4,5]]`. + +**Примеры** + +``` sql +SELECT flatten([[[1]], [[2], [3]]]) +``` + +``` text +┌─flatten(array(array([1]), array([2], [3])))─┐ +│ [1,2,3] │ +└─────────────────────────────────────────────┘ +``` + +## arrayCompact {#arraycompact} + +Удаляет дубликаты из массива. Порядок результирующих значений определяется порядком в исходном массиве. + +**Синтаксис** + +``` sql +arrayCompact(arr) +``` + +**Параметры** + +`arr` — [Массив](../../sql-reference/functions/array-functions.md) для обхода. + +**Возвращаемое значение** + +Массив без дубликатов. + +Тип: `Array`. + +**Пример** + +Запрос: + +``` sql +SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) +``` + +Ответ: + +``` text +┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ +│ [1,nan,nan,2,3] │ +└────────────────────────────────────────────┘ +``` + +## arrayZip {#arrayzip} + +Объединяет несколько массивов в один. Результирующий массив содержит соответственные элементы исходных массивов, сгруппированные в кортежи в указанном порядке аргументов. + +**Синтаксис** + +``` sql +arrayZip(arr1, arr2, ..., arrN) +``` + +**Параметры** + +- `arrN` — [Массив](../data-types/array.md). + +Функция принимает любое количество массивов, которые могут быть различных типов. Все массивы должны иметь одинаковую длину. + +**Возвращаемое значение** + +- Массив с элементами исходных массивов, сгруппированными в [кортежи](../data-types/tuple.md). Типы данных в кортежах соответствуют типам данных входных массивов и следуют в том же порядке, в котором переданы массивы. + +Тип: [Массив](../data-types/array.md). + +**Пример** + +Запрос: + +``` sql +SELECT arrayZip(['a', 'b', 'c'], [5, 2, 1]) +``` + +Ответ: + +``` text +┌─arrayZip(['a', 'b', 'c'], [5, 2, 1])─┐ +│ [('a',5),('b',2),('c',1)] │ +└──────────────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/array_functions/) diff --git a/docs/ru/sql-reference/functions/array-join.md b/docs/ru/sql-reference/functions/array-join.md new file mode 100644 index 00000000000..afbc7bfe3e8 --- /dev/null +++ b/docs/ru/sql-reference/functions/array-join.md @@ -0,0 +1,30 @@ +# Функция ArrayJoin {#functions_arrayjoin} + +Это совсем необычная функция. + +Обычные функции не изменяют множество строк, а лишь изменяют значения в каждой строке (map). +Агрегатные функции выполняют свёртку множества строк (fold, reduce). +Функция arrayJoin выполняет размножение каждой строки в множество строк (unfold). + +Функция принимает в качестве аргумента массив, и размножает исходную строку в несколько строк - по числу элементов массива. +Все значения в столбцах просто копируются, кроме значения в столбце с применением этой функции - он заменяется на соответствующее значение массива. + +В запросе может быть использовано несколько функций `arrayJoin`. В этом случае, соответствующее преобразование делается несколько раз. + +Обратите внимание на синтаксис ARRAY JOIN в запросе SELECT, который предоставляет более широкие возможности. + +Пример: + +``` sql +SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src +``` + +``` text +┌─dst─┬─\'Hello\'─┬─src─────┐ +│ 1 │ Hello │ [1,2,3] │ +│ 2 │ Hello │ [1,2,3] │ +│ 3 │ Hello │ [1,2,3] │ +└─────┴───────────┴─────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/array_join/) diff --git a/docs/ru/sql-reference/functions/bit-functions.md b/docs/ru/sql-reference/functions/bit-functions.md new file mode 100644 index 00000000000..9d78dd861e9 --- /dev/null +++ b/docs/ru/sql-reference/functions/bit-functions.md @@ -0,0 +1,238 @@ +# Битовые функции {#bitovye-funktsii} + +Битовые функции работают для любой пары типов из UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, Float64. + +Тип результата - целое число, битность которого равна максимальной битности аргументов. Если хотя бы один аргумент знаковый, то результат - знаковое число. Если аргумент - число с плавающей запятой - оно приводится к Int64. + +## bitAnd(a, b) {#bitanda-b} + +## bitOr(a, b) {#bitora-b} + +## bitXor(a, b) {#bitxora-b} + +## bitNot(a) {#bitnota} + +## bitShiftLeft(a, b) {#bitshiftlefta-b} + +## bitShiftRight(a, b) {#bitshiftrighta-b} + +## bitTest {#bittest} + +Принимает любое целое число и конвертирует его в [двоичное число](https://en.wikipedia.org/wiki/Binary_number), возвращает значение бита в указанной позиции. Отсчет начинается с 0 справа налево. + +**Синтаксис** + +``` sql +SELECT bitTest(number, index) +``` + +**Параметры** + +- `number` – целое число. +- `index` – position of bit. + +**Возвращаемое значение** + +Возвращает значение бита в указанной позиции. + +Тип: `UInt8`. + +**Пример** + +Например, число 43 в двоичной системе счисления равно: 101011. + +Запрос: + +``` sql +SELECT bitTest(43, 1) +``` + +Ответ: + +``` text +┌─bitTest(43, 1)─┐ +│ 1 │ +└────────────────┘ +``` + +Другой пример: + +Запрос: + +``` sql +SELECT bitTest(43, 2) +``` + +Ответ: + +``` text +┌─bitTest(43, 2)─┐ +│ 0 │ +└────────────────┘ +``` + +## bitTestAll {#bittestall} + +Возвращает результат [логической конъюнкции](https://en.wikipedia.org/wiki/Logical_conjunction) (оператор AND) всех битов в указанных позициях. Отсчет начинается с 0 справа налево. + +Бинарная конъюнкция: + +0 AND 0 = 0 +0 AND 1 = 0 +1 AND 0 = 0 +1 AND 1 = 1 + +**Синтаксис** + +``` sql +SELECT bitTestAll(number, index1, index2, index3, index4, ...) +``` + +**Параметры** + +- `number` – целое число. +- `index1`, `index2`, `index3`, `index4` – позиция бита. Например, конъюнкция для набора позиций `index1`, `index2`, `index3`, `index4` является истинной, если все его позиции истинны `index1` ⋀ `index2` ⋀ `index3` ⋀ `index4`. + +**Возвращаемое значение** + +Возвращает результат логической конъюнкции. + +Тип: `UInt8`. + +**Пример** + +Например, число 43 в двоичной системе счисления равно: 101011. + +Запрос: + +``` sql +SELECT bitTestAll(43, 0, 1, 3, 5) +``` + +Ответ: + +``` text +┌─bitTestAll(43, 0, 1, 3, 5)─┐ +│ 1 │ +└────────────────────────────┘ +``` + +Другой пример: + +Запрос: + +``` sql +SELECT bitTestAll(43, 0, 1, 3, 5, 2) +``` + +Ответ: + +``` text +┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ +│ 0 │ +└───────────────────────────────┘ +``` + +## bitTestAny {#bittestany} + +Возвращает результат [логической дизъюнкции](https://en.wikipedia.org/wiki/Logical_disjunction) (оператор OR) всех битов в указанных позициях. Отсчет начинается с 0 справа налево. + +Бинарная дизъюнкция: + +0 OR 0 = 0 +0 OR 1 = 1 +1 OR 0 = 1 +1 OR 1 = 1 + +**Синтаксис** + +``` sql +SELECT bitTestAny(number, index1, index2, index3, index4, ...) +``` + +**Параметры** + +- `number` – целое число. +- `index1`, `index2`, `index3`, `index4` – позиции бита. + +**Возвращаемое значение** + +Возвращает результат логической дизъюнкции. + +Тип: `UInt8`. + +**Пример** + +Например, число 43 в двоичной системе счисления равно: 101011. + +Запрос: + +``` sql +SELECT bitTestAny(43, 0, 2) +``` + +Ответ: + +``` text +┌─bitTestAny(43, 0, 2)─┐ +│ 1 │ +└──────────────────────┘ +``` + +Другой пример: + +Запрос: + +``` sql +SELECT bitTestAny(43, 4, 2) +``` + +Ответ: + +``` text +┌─bitTestAny(43, 4, 2)─┐ +│ 0 │ +└──────────────────────┘ +``` + +## bitCount {#bitcount} + +Подсчитывает количество равных единице бит в числе. + +**Синтаксис** + +``` sql +bitCount(x) +``` + +**Параметры** + +- `x` — [Целое число](../../sql-reference/functions/bit-functions.md) или [число с плавающей запятой](../../sql-reference/functions/bit-functions.md). Функция использует представление числа в памяти, что позволяет поддержать числа с плавающей запятой. + +**Возвращаемое значение** + +- Количество равных единице бит во входном числе. + +Функция не преобразует входное значение в более крупный тип ([sign extension](https://en.wikipedia.org/wiki/Sign_extension)). Поэтому, например, `bitCount(toUInt8(-1)) = 8`. + +Тип: `UInt8`. + +**Пример** + +Возьмём к примеру число 333. Его бинарное представление — 0000000101001101. + +Запрос: + +``` sql +SELECT bitCount(333) +``` + +Результат: + +``` text +┌─bitCount(100)─┐ +│ 5 │ +└───────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/bit_functions/) diff --git a/docs/ru/sql-reference/functions/bitmap-functions.md b/docs/ru/sql-reference/functions/bitmap-functions.md new file mode 100644 index 00000000000..c91725c7a39 --- /dev/null +++ b/docs/ru/sql-reference/functions/bitmap-functions.md @@ -0,0 +1,393 @@ +# Функции для битмапов {#funktsii-dlia-bitmapov} + +## bitmapBuild {#bitmap_functions-bitmapbuild} + +Создаёт битовый массив из массива целочисленных значений. + +``` sql +bitmapBuild(array) +``` + +**Параметры** + +- `array` – массив типа `UInt*`. + +**Пример** + +``` sql +SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) +``` + +``` text +┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ +│  │ AggregateFunction(groupBitmap, UInt8) │ +└─────┴──────────────────────────────────────────────┘ +``` + +## bitmapToArray {#bitmaptoarray} + +Преобразует битовый массив в массив целочисленных значений. + +``` sql +bitmapToArray(bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + +``` text +┌─res─────────┐ +│ [1,2,3,4,5] │ +└─────────────┘ +``` + +## bitmapSubsetLimit {#bitmapsubsetlimit} + +Создает подмножество битмапа с n элементами, расположенными между `range_start` и `cardinality_limit`. + +**Синтаксис** + +``` sql +bitmapSubsetLimit(bitmap, range_start, cardinality_limit) +``` + +**Параметры** + +- `bitmap` – Битмап. [Bitmap object](#bitmap_functions-bitmapbuild). +- `range_start` – Начальная точка подмножества. [UInt32](../../sql-reference/functions/bitmap-functions.md). +- `cardinality_limit` – Верхний предел подмножества. [UInt32](../../sql-reference/functions/bitmap-functions.md). + +**Возвращаемое значение** + +Подмножество битмапа. + +Тип: `Bitmap object`. + +**Пример** + +Запрос: + +``` sql +SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + +Ответ: + +``` text +┌─res───────────────────────┐ +│ [30,31,32,33,100,200,500] │ +└───────────────────────────┘ +``` + +## bitmapContains {#bitmap_functions-bitmapcontains} + +Проверяет вхождение элемента в битовый массив. + +``` sql +bitmapContains(haystack, needle) +``` + +**Параметры** + +- `haystack` – [объект Bitmap](#bitmap_functions-bitmapbuild), в котором функция ищет значение. +- `needle` – значение, которое функция ищет. Тип — [UInt32](../../sql-reference/functions/bitmap-functions.md). + +**Возвращаемые значения** + +- 0 — если в `haystack` нет `needle`. +- 1 — если в `haystack` есть `needle`. + +Тип — `UInt8`. + +**Пример** + +``` sql +SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapHasAny {#bitmaphasany} + +Проверяет, имеют ли два битовых массива хотя бы один общий элемент. + +``` sql +bitmapHasAny(bitmap1, bitmap2) +``` + +Если вы уверены, что `bitmap2` содержит строго один элемент, используйте функцию [bitmapContains](#bitmap_functions-bitmapcontains). Она работает эффективнее. + +**Параметры** + +- `bitmap*` – массив любого типа с набором элементов. + +**Возвращаемые значения** + +- `1`, если `bitmap1` и `bitmap2` имеют хотя бы один одинаковый элемент. +- `0`, в противном случае. + +**Пример** + +``` sql +SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapHasAll {#bitmaphasall} + +Аналогично функции `hasAll(array, array)` возвращает 1 если первый битовый массив содержит все элементы второго, 0 в противном случае. +Если второй аргумент является пустым битовым массивом, то возвращает 1. + +``` sql +bitmapHasAll(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + +``` text +┌─res─┐ +│ 0 │ +└─────┘ +``` + +## bitmapAnd {#bitmapand} + +Логическое И для двух битовых массивов. Результат — новый битовый массив. + +``` sql +bitmapAnd(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res─┐ +│ [3] │ +└─────┘ +``` + +## bitmapOr {#bitmapor} + +Логическое ИЛИ для двух битовых массивов. Результат — новый битовый массив. + +``` sql +bitmapOr(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res─────────┐ +│ [1,2,3,4,5] │ +└─────────────┘ +``` + +## bitmapXor {#bitmapxor} + +Логическое исключающее ИЛИ для двух битовых массивов. Результат — новый битовый массив. + +``` sql +bitmapXor(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res───────┐ +│ [1,2,4,5] │ +└───────────┘ +``` + +## bitmapAndnot {#bitmapandnot} + +Логическое отрицание И для двух битовых массивов. Результат — новый битовый массив. + +``` sql +bitmapAndnot(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + +``` text +┌─res───┐ +│ [1,2] │ +└───────┘ +``` + +## bitmapCardinality {#bitmapcardinality} + +Возвращает кардинальность битового массива в виде значения типа `UInt64`. + +``` sql +bitmapCardinality(bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + +``` text +┌─res─┐ +│ 5 │ +└─────┘ +``` + +## bitmapAndCardinality {#bitmapandcardinality} + +Выполняет логическое И и возвращает кардинальность (`UInt64`) результирующего битового массива. + +``` sql +bitmapAndCardinality(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapOrCardinality {#bitmaporcardinality} + +Выполняет логическое ИЛИ и возвращает кардинальность (`UInt64`) результирующего битового массива. + +``` sql +bitmapOrCardinality(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 5 │ +└─────┘ +``` + +## bitmapXorCardinality {#bitmapxorcardinality} + +Выполняет логическое исключающее ИЛИ и возвращает кардинальность (`UInt64`) результирующего битового массива. + +``` sql +bitmapXorCardinality(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 4 │ +└─────┘ +``` + +## bitmapAndnotCardinality {#bitmapandnotcardinality} + +Выполняет логическое отрицание И и возвращает кардинальность (`UInt64`) результирующего битового массива. + +``` sql +bitmapAndnotCardinality(bitmap,bitmap) +``` + +**Параметры** + +- `bitmap` – битовый массив. + +**Пример** + +``` sql +SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + +``` text +┌─res─┐ +│ 2 │ +└─────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/bitmap_functions/) diff --git a/docs/ru/sql-reference/functions/comparison-functions.md b/docs/ru/sql-reference/functions/comparison-functions.md new file mode 100644 index 00000000000..9b921d6fe55 --- /dev/null +++ b/docs/ru/sql-reference/functions/comparison-functions.md @@ -0,0 +1,32 @@ +# Функции сравнения {#funktsii-sravneniia} + +Функции сравнения возвращают всегда 0 или 1 (UInt8). + +Сравнивать можно следующие типы: + +- числа; +- строки и фиксированные строки; +- даты; +- даты-с-временем; + +внутри каждой группы, но не из разных групп. + +Например, вы не можете сравнить дату со строкой. Надо использовать функцию преобразования строки в дату или наоборот. + +Строки сравниваются побайтово. Более короткая строка меньше всех строк, начинающихся с неё и содержащих ещё хотя бы один символ. + +Замечание. До версии 1.1.54134 сравнение знаковых и беззнаковых целых чисел производилось также, как в C++. То есть, вы могли получить неверный результат в таких случаях: SELECT 9223372036854775807 \> -1. С версии 1.1.54134 поведение изменилось и стало математически корректным. + +## equals, оператор a = b и a == b {#function-equals} + +## notEquals, оператор a != b и a `<>` b {#function-notequals} + +## less, оператор `<` {#function-less} + +## greater, оператор `>` {#function-greater} + +## lessOrEquals, оператор `<=` {#function-lessorequals} + +## greaterOrEquals, оператор `>=` {#function-greaterorequals} + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/comparison_functions/) diff --git a/docs/ru/sql-reference/functions/conditional-functions.md b/docs/ru/sql-reference/functions/conditional-functions.md new file mode 100644 index 00000000000..7efb6f7bfc5 --- /dev/null +++ b/docs/ru/sql-reference/functions/conditional-functions.md @@ -0,0 +1,109 @@ +# Условные функции {#uslovnye-funktsii} + +## if {#if} + +Условное выражение. В отличии от большинства систем, ClickHouse всегда считает оба выражения `then` и `else`. + +**Синтаксис** + +``` sql +SELECT if(cond, then, else) +``` + +Если условие `cond` не равно нулю, то возвращается результат выражения `then`. Если условие `cond` равно нулю или является NULL, то результат выражения `then` пропускается и возвращается результат выражения `else`. + +**Параметры** + +- `cond` – Условие, которое может быть равно 0 или нет. Может быть [UInt8](../../sql-reference/functions/conditional-functions.md) или `NULL`. +- `then` - Возвращается результат выражения, если условие `cond` истинно. +- `else` - Возвращается результат выражения, если условие `cond` ложно. + +**Возвращаемые значения** + +Функция выполняет выражения `then` или `else` и возвращает его результат, в зависимости от того, было ли условие `cond` равно нулю или нет. + +**Пример** + +Запрос: + +``` sql +SELECT if(1, plus(2, 2), plus(2, 6)) +``` + +Ответ: + +``` text +┌─plus(2, 2)─┐ +│ 4 │ +└────────────┘ +``` + +Запрос: + +``` sql +SELECT if(0, plus(2, 2), plus(2, 6)) +``` + +Ответ: + +``` text +┌─plus(2, 6)─┐ +│ 8 │ +└────────────┘ +``` + +## Тернарный оператор {#ternary-operator} + +Работает так же, как функция `if`. + +Синтаксис: `cond ? then : else` + +Возвращает `then`, если `cond` верно (больше нуля), в остальных случаях возвращает `else`. + +- `cond` должно быть типа `UInt8`, `then` и `else` должны относиться к наименьшему общему типу. + +- `then` и `else` могут быть `NULL`. + +**Смотрите также** + +- [ifNotFinite](other-functions.md#ifnotfinite). + +## multiIf {#multiif} + +Позволяет более компактно записать оператор [CASE](../operators/index.md#operator_case) в запросе. + + multiIf(cond_1, then_1, cond_2, then_2...else) + +**Параметры** + +- `cond_N` — Условие, при выполнении которого функция вернёт `then_N`. +- `then_N` — Результат функции при выполнении. +- `else` — Результат функции, если ни одно из условий не выполнено. + +Функция принимает `2N+1` параметров. + +**Возвращаемые значения** + +Функция возвращает одно из значений `then_N` или `else`, в зависимости от условий `cond_N`. + +**Пример** + +Рассмотрим таблицу + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +Выполним запрос `SELECT multiIf(isNull(y), x, y < 3, y, NULL) FROM t_null`. Результат: + +``` text +┌─multiIf(isNull(y), x, less(y, 3), y, NULL)─┐ +│ 1 │ +│ ᴺᵁᴸᴸ │ +└────────────────────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/conditional_functions/) diff --git a/docs/ru/sql-reference/functions/date-time-functions.md b/docs/ru/sql-reference/functions/date-time-functions.md new file mode 100644 index 00000000000..ecd9c760fbc --- /dev/null +++ b/docs/ru/sql-reference/functions/date-time-functions.md @@ -0,0 +1,290 @@ +# Функции для работы с датами и временем {#funktsii-dlia-raboty-s-datami-i-vremenem} + +Поддержка часовых поясов + +Все функции по работе с датой и временем, для которых это имеет смысл, могут принимать второй, необязательный аргумент - имя часового пояса. Пример: Asia/Yekaterinburg. В этом случае, они используют не локальный часовой пояс (по умолчанию), а указанный. + +``` sql +SELECT + toDateTime('2016-06-15 23:00:00') AS time, + toDate(time) AS date_local, + toDate(time, 'Asia/Yekaterinburg') AS date_yekat, + toString(time, 'US/Samoa') AS time_samoa +``` + +``` text +┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ +│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ +└─────────────────────┴────────────┴────────────┴─────────────────────┘ +``` + +Поддерживаются только часовые пояса, отличающиеся от UTC на целое число часов. + +## toYear {#toyear} + +Переводит дату или дату-с-временем в число типа UInt16, содержащее номер года (AD). + +## toMonth {#tomonth} + +Переводит дату или дату-с-временем в число типа UInt8, содержащее номер месяца (1-12). + +## toDayOfMonth {#todayofmonth} + +Переводит дату или дату-с-временем в число типа UInt8, содержащее номер дня в месяце (1-31). + +## toDayOfWeek {#todayofweek} + +Переводит дату или дату-с-временем в число типа UInt8, содержащее номер дня в неделе (понедельник - 1, воскресенье - 7). + +## toHour {#tohour} + +Переводит дату-с-временем в число типа UInt8, содержащее номер часа в сутках (0-23). +Функция исходит из допущения, что перевод стрелок вперёд, если осуществляется, то на час, в два часа ночи, а перевод стрелок назад, если осуществляется, то на час, в три часа ночи (что, в общем, не верно - даже в Москве два раза перевод стрелок был осуществлён в другое время). + +## toMinute {#tominute} + +Переводит дату-с-временем в число типа UInt8, содержащее номер минуты в часе (0-59). + +## toSecond {#tosecond} + +Переводит дату-с-временем в число типа UInt8, содержащее номер секунды в минуте (0-59). +Секунды координации не учитываются. + +## toUnixTimestamp {#to-unix-timestamp} + +For DateTime argument: converts value to its internal numeric representation (Unix Timestamp). +For String argument: parse datetime from string according to the timezone (optional second argument, server timezone is used by default) and returns the corresponding unix timestamp. +For Date argument: the behaviour is unspecified. + +**Syntax** + +``` sql +toUnixTimestamp(datetime) +toUnixTimestamp(str, [timezone]) +``` + +**Returned value** + +- Returns the unix timestamp. + +Type: `UInt32`. + +**Example** + +Query: + +``` sql +SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp +``` + +Result: + +``` text +┌─unix_timestamp─┐ +│ 1509836867 │ +└────────────────┘ +``` + +## toStartOfYear {#tostartofyear} + +Округляет дату или дату-с-временем вниз до первого дня года. +Возвращается дата. + +## toStartOfQuarter {#tostartofquarter} + +Округляет дату или дату-с-временем вниз до первого дня квартала. +Первый день квартала - это одно из 1 января, 1 апреля, 1 июля, 1 октября. +Возвращается дата. + +## toStartOfMonth {#tostartofmonth} + +Округляет дату или дату-с-временем вниз до первого дня месяца. +Возвращается дата. + +!!! attention "Attention" + Возвращаемое значение для некорректных дат зависит от реализации. ClickHouse может вернуть нулевую дату, выбросить исключение, или выполнить «естественное» перетекание дат между месяцами. + +## toMonday {#tomonday} + +Округляет дату или дату-с-временем вниз до ближайшего понедельника. +Возвращается дата. + +## toStartOfDay {#tostartofday} + +Округляет дату-с-временем вниз до начала дня. Возвращается дата-с-временем. + +## toStartOfHour {#tostartofhour} + +Округляет дату-с-временем вниз до начала часа. + +## toStartOfMinute {#tostartofminute} + +Округляет дату-с-временем вниз до начала минуты. + +## toStartOfFiveMinute {#tostartoffiveminute} + +Округляет дату-с-временем вниз до начала пятиминутного интервала. + +## toStartOfTenMinutes {#tostartoftenminutes} + +Округляет дату-с-временем вниз до начала десятиминутного интервала. + +## toStartOfFifteenMinutes {#tostartoffifteenminutes} + +Округляет дату-с-временем вниз до начала пятнадцатиминутного интервала. + +## toStartOfInterval(time\_or\_data, INTERVAL x unit \[, time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} + +Обобщение остальных функций `toStartOf*`. Например, +`toStartOfInterval(t, INTERVAL 1 year)` возвращает то же самое, что и `toStartOfYear(t)`, +`toStartOfInterval(t, INTERVAL 1 month)` возвращает то же самое, что и `toStartOfMonth(t)`, +`toStartOfInterval(t, INTERVAL 1 day)` возвращает то же самое, что и `toStartOfDay(t)`, +`toStartOfInterval(t, INTERVAL 15 minute)` возвращает то же самое, что и `toStartOfFifteenMinutes(t)`, и т.п. + +## toTime {#totime} + +Переводит дату-с-временем на некоторую фиксированную дату, сохраняя при этом время. + +## toRelativeYearNum {#torelativeyearnum} + +Переводит дату-с-временем или дату в номер года, начиная с некоторого фиксированного момента в прошлом. + +## toRelativeMonthNum {#torelativemonthnum} + +Переводит дату-с-временем или дату в номер месяца, начиная с некоторого фиксированного момента в прошлом. + +## toRelativeWeekNum {#torelativeweeknum} + +Переводит дату-с-временем или дату в номер недели, начиная с некоторого фиксированного момента в прошлом. + +## toRelativeDayNum {#torelativedaynum} + +Переводит дату-с-временем или дату в номер дня, начиная с некоторого фиксированного момента в прошлом. + +## toRelativeHourNum {#torelativehournum} + +Переводит дату-с-временем в номер часа, начиная с некоторого фиксированного момента в прошлом. + +## toRelativeMinuteNum {#torelativeminutenum} + +Переводит дату-с-временем в номер минуты, начиная с некоторого фиксированного момента в прошлом. + +## toRelativeSecondNum {#torelativesecondnum} + +Переводит дату-с-временем в номер секунды, начиная с некоторого фиксированного момента в прошлом. + +## now {#now} + +Принимает ноль аргументов и возвращает текущее время на один из моментов выполнения запроса. +Функция возвращает константу, даже если запрос выполнялся долго. + +## today {#today} + +Принимает ноль аргументов и возвращает текущую дату на один из моментов выполнения запроса. +То же самое, что toDate(now()) + +## yesterday {#yesterday} + +Принимает ноль аргументов и возвращает вчерашнюю дату на один из моментов выполнения запроса. +Делает то же самое, что today() - 1. + +## dateDiff {#datediff} + +Вычисляет разницу между двумя значениями дат с временем. + +**Синтаксис** + +``` sql +dateDiff('unit', startdate, enddate, [timezone]) +``` + +**Параметры** + +- `unit` — Единица измерения времени, в которой будет вычислена разница между `startdate` и `enddate`. [String](../syntax.md#syntax-string-literal). + + Поддерживаемые значения: + + | unit | + | ------ | + |second | + |minute | + |hour | + |day | + |week | + |month | + |quarter | + |year | + +- `startdate` — Первая дата. [Date](../../sql-reference/functions/date-time-functions.md) или [DateTime](../../sql-reference/functions/date-time-functions.md). + +- `enddate` — Вторая дата. [Date](../../sql-reference/functions/date-time-functions.md) или [DateTime](../../sql-reference/functions/date-time-functions.md). + +- `timezone` — Опциональный параметр. Если определен, применяется к обоим значениям: `startdate` и `enddate`. Если не определен, используются часовые пояса `startdate` и `enddate`. Если часовые пояса не совпадают, вернется неожидаемый результат. + +**Возвращаемое значение** + +Разница между `startdate` и `enddate`, выраженная в `unit`. + +Тип: `int`. + +**Пример** + +Запрос: + +``` sql +SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); +``` + +Ответ: + +``` text +┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ +│ 25 │ +└────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## timeSlot {#timeslot} + +Округляет время до получаса. +Эта функция является специфичной для Яндекс.Метрики, так как пол часа - минимальное время, для которого, если соседние по времени хиты одного посетителя на одном счётчике отстоят друг от друга строго более, чем на это время, визит может быть разбит на два визита. То есть, кортежи (номер счётчика, идентификатор посетителя, тайм-слот) могут использоваться для поиска хитов, входящий в соответствующий визит. + +## timeSlots(StartTime, Duration,\[, Size\]) {#timeslotsstarttime-duration-size} + +Для интервала времени, начинающегося в ‘StartTime’ и продолжающегося ‘Duration’ секунд, возвращает массив моментов времени, состоящий из округлений вниз до ‘Size’ точек в секундах из этого интервала. ‘Size’ - необязательный параметр, константный UInt32, по умолчанию равен 1800. + +Например, `timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600)) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. +Это нужно для поиска хитов, входящих в соответствующий визит. + +## formatDateTime(Time, Format\[, Timezone\]) {#formatdatetime} + +Функция преобразования даты-с-временем в String согласно заданному шаблону. Важно - шаблон является константным выражением, т.е. невозможно использование разных шаблонов в одной колонке. + +Поддерживаемые модификаторы в шаблоне Format: +(колонка «Пример» показана для времени `2018-01-02 22:33:44`) + +| Модификатор | Описание | Пример | +|-------------|----------------------------------------------------------------------|------------| +| %C | номер года, поделённый на 100 (00-99) | 20 | +| %d | день месяца, с ведущим нулём (01-31) | 02 | +| %D | короткая запись %m/%d/%y | 01/02/18 | +| %e | день месяца, с ведущим пробелом ( 1-31) | 2 | +| %F | короткая запись %Y-%m-%d | 2018-01-02 | +| %H | час в 24-часовом формате (00-23) | 22 | +| %I | час в 12-часовом формате (01-12) | 10 | +| %j | номер дня в году, с ведущими нулями (001-366) | 002 | +| %m | месяц, с ведущим нулём (01-12) | 01 | +| %M | минуты, с ведущим нулём (00-59) | 33 | +| %n | символ переноса строки (‘’) | | +| %p | обозначения AM или PM | PM | +| %R | короткая запись %H:%M | 22:33 | +| %S | секунды, с ведущими нулями (00-59) | 44 | +| %t | символ табуляции (’) | | +| %T | формат времени ISO 8601, одинаковый с %H:%M:%S | 22:33:44 | +| %u | номер дня недели согласно ISO 8601, понедельник - 1, воскресенье - 7 | 2 | +| %V | номер недели согласно ISO 8601 (01-53) | 01 | +| %w | номер дня недели, начиная с воскресенья (0-6) | 2 | +| %y | год, последние 2 цифры (00-99) | 18 | +| %Y | год, 4 цифры | 2018 | +| %% | символ % | % | + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/date_time_functions/) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md new file mode 100644 index 00000000000..b8ea481364d --- /dev/null +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -0,0 +1,168 @@ +# Функции кодирования {#funktsii-kodirovaniia} + +## char {#char} + +Возвращает строку, длина которой равна числу переданных аргументов, и каждый байт имеет значение соответствующего аргумента. Принимает несколько числовых аргументов. Если значение аргумента выходит за диапазон UInt8 (0..255), то оно преобразуется в UInt8 с возможным округлением и переполнением. + +**Синтаксис** + +``` sql +char(number_1, [number_2, ..., number_n]); +``` + +**Параметры** + +- `number_1, number_2, ..., number_n` — Числовые аргументы, которые интерпретируются как целые числа. Типы: [Int](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/functions/encoding-functions.md). + +**Возвращаемое значение** + +- строка из соответствующих байт. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello +``` + +Ответ: + +``` text +┌─hello─┐ +│ hello │ +└───────┘ +``` + +Вы можете создать строку в произвольной кодировке, передав соответствующие байты. Пример для UTF-8: + +Запрос: + +``` sql +SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; +``` + +Ответ: + +``` text +┌─hello──┐ +│ привет │ +└────────┘ +``` + +Запрос: + +``` sql +SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; +``` + +Ответ: + +``` text +┌─hello─┐ +│ 你好 │ +└───────┘ +``` + +## hex {#hex} + +Returns a string containing the argument’s hexadecimal representation. + +**Syntax** + +``` sql +hex(arg) +``` + +The function is using uppercase letters `A-F` and not using any prefixes (like `0x`) or suffixes (like `h`). + +For integer arguments, it prints hex digits («nibbles») from the most significant to least significant (big endian or «human readable» order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints both digits of every byte even if leading digit is zero. + +Example: + +**Example** + +Query: + +``` sql +SELECT hex(1); +``` + +Result: + +``` text +01 +``` + +Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). + +For `String` and `FixedString`, all bytes are simply encoded as two hexadecimal numbers. Zero bytes are not omitted. + +Values of floating point and Decimal types are encoded as their representation in memory. As we support little endian architecture, they are encoded in little endian. Zero leading/trailing bytes are not omitted. + +**Parameters** + +- `arg` — A value to convert to hexadecimal. Types: [String](../../sql-reference/functions/encoding-functions.md), [UInt](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/functions/encoding-functions.md), [Decimal](../../sql-reference/functions/encoding-functions.md), [Date](../../sql-reference/functions/encoding-functions.md) or [DateTime](../../sql-reference/functions/encoding-functions.md). + +**Returned value** + +- A string with the hexadecimal representation of the argument. + +Type: `String`. + +**Example** + +Query: + +``` sql +SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); +``` + +Result: + +``` text +┌─hex_presentation─┐ +│ 00007041 │ +│ 00008041 │ +└──────────────────┘ +``` + +Query: + +``` sql +SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); +``` + +Result: + +``` text +┌─hex_presentation─┐ +│ 0000000000002E40 │ +│ 0000000000003040 │ +└──────────────────┘ +``` + +## unhex(str) {#unhexstr} + +Accepts a string containing any number of hexadecimal digits, and returns a string containing the corresponding bytes. Supports both uppercase and lowercase letters A-F. The number of hexadecimal digits does not have to be even. If it is odd, the last digit is interpreted as the least significant half of the 00-0F byte. If the argument string contains anything other than hexadecimal digits, some implementation-defined result is returned (an exception isn’t thrown). +If you want to convert the result to a number, you can use the ‘reverse’ and ‘reinterpretAsType’ functions. + +## UUIDStringToNum(str) {#uuidstringtonumstr} + +Принимает строку, содержащую 36 символов в формате `123e4567-e89b-12d3-a456-426655440000`, и возвращает в виде набора байт в FixedString(16). + +## UUIDNumToString(str) {#uuidnumtostringstr} + +Принимает значение типа FixedString(16). Возвращает строку из 36 символов в текстовом виде. + +## bitmaskToList(num) {#bitmasktolistnum} + +Принимает целое число. Возвращает строку, содержащую список степеней двойки, в сумме дающих исходное число; по возрастанию, в текстовом виде, через запятую, без пробелов. + +## bitmaskToArray(num) {#bitmasktoarraynum} + +Принимает целое число. Возвращает массив чисел типа UInt64, содержащий степени двойки, в сумме дающих исходное число; числа в массиве идут по возрастанию. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/encoding_functions/) diff --git a/docs/ru/sql-reference/functions/ext-dict-functions.md b/docs/ru/sql-reference/functions/ext-dict-functions.md new file mode 100644 index 00000000000..a260ec1e16e --- /dev/null +++ b/docs/ru/sql-reference/functions/ext-dict-functions.md @@ -0,0 +1,196 @@ +# Функции для работы с внешними словарями {#ext_dict_functions} + +Информацию о подключении и настройке внешних словарей смотрите в разделе [Внешние словари](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +## dictGet {#dictget} + +Извлекает значение из внешнего словаря. + +``` sql +dictGet('dict_name', 'attr_name', id_expr) +dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) +``` + +**Параметры** + +- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `attr_name` — имя столбца словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `id_expr` — значение ключа словаря. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql-reference/functions/ext-dict-functions.md) или [Tuple](../../sql-reference/functions/ext-dict-functions.md) в зависимости от конфигурации словаря. +- `default_value_expr` — значение, возвращаемое в том случае, когда словарь не содержит строки с заданным ключом `id_expr`. [Выражение](../syntax.md#syntax-expressions) возвращающее значение с типом данных, сконфигурированным для атрибута `attr_name`. + +**Возвращаемое значение** + +- Значение атрибута, соответствующее ключу `id_expr`, если ClickHouse смог привести это значение к [заданному типу данных](../../sql-reference/functions/ext-dict-functions.md#ext_dict_structure-attributes). + +- Если ключа, соответствующего `id_expr` в словаре нет, то: + + - `dictGet` возвращает содержимое элемента ``, указанного для атрибута в конфигурации словаря. + - `dictGetOrDefault` возвращает атрибут `default_value_expr`. + +Если значение атрибута не удалось обработать или оно не соответствует типу данных атрибута, то ClickHouse генерирует исключение. + +**Пример** + +Создадим текстовый файл `ext-dict-text.csv` со следующим содержимым: + +``` text +1,1 +2,2 +``` + +Первый столбец — `id`, второй столбец — `c1`. + +Настройка внешнего словаря: + +``` xml + + + ext-dict-test + + + /path-to/ext-dict-test.csv + CSV + + + + + + + + id + + + c1 + UInt32 + + + + 0 + + +``` + +Выполним запрос: + +``` sql +SELECT + dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, + toTypeName(val) AS type +FROM system.numbers +LIMIT 3 +``` + +``` text +┌─val─┬─type───┐ +│ 1 │ UInt32 │ +│ 2 │ UInt32 │ +│ 20 │ UInt32 │ +└─────┴────────┘ +``` + +**Смотрите также** + +- [Внешние словари](../../sql-reference/functions/ext-dict-functions.md) + +## dictHas {#dicthas} + +Проверяет, присутствует ли запись с указанным ключом в словаре. + +``` sql +dictHas('dict_name', id) +``` + +**Параметры** + +- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `id_expr` — значение ключа словаря. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql-reference/functions/ext-dict-functions.md). + +**Возвращаемое значение** + +- 0, если ключа нет. +- 1, если ключ есть. + +Тип — `UInt8`. + +## dictGetHierarchy {#dictgethierarchy} + +Создаёт массив, содержащий цепочку предков для заданного ключа в [иерархическом словаре](../dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md). + +**Синтаксис** + +``` sql +dictGetHierarchy('dict_name', key) +``` + +**Параметры** + +- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `key` — значение ключа. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql-reference/functions/ext-dict-functions.md). + +**Возвращаемое значение** + +- Цепочка предков заданного ключа. + +Type: [Array(UInt64)](../../sql-reference/functions/ext-dict-functions.md). + +## dictIsIn {#dictisin} + +Проверяет предка ключа по всей иерархической цепочке словаря. + +`dictIsIn ('dict_name', child_id_expr, ancestor_id_expr)` + +**Параметры** + +- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `child_id_expr` — ключ для проверки. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql-reference/functions/ext-dict-functions.md). +- `ancestor_id_expr` — предполагаемый предок ключа `child_id_expr`. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql-reference/functions/ext-dict-functions.md). + +**Возвращаемое значение** + +- 0, если `child_id_expr` — не дочерний элемент `ancestor_id_expr`. +- 1, если `child_id_expr` — дочерний элемент `ancestor_id_expr` или если `child_id_expr` и есть `ancestor_id_expr`. + +Тип — `UInt8`. + +## Прочие функции {#ext_dict_functions-other} + +ClickHouse поддерживает специализированные функции, которые приводят значения атрибутов словаря к определённому типу данных независимо от конфигурации словаря. + +Функции: + +- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` +- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` +- `dictGetFloat32`, `dictGetFloat64` +- `dictGetDate` +- `dictGetDateTime` +- `dictGetUUID` +- `dictGetString` + +Все эти функции можно использовать с модификатором `OrDefault`. Например, `dictGetDateOrDefault`. + +Синтаксис: + +``` sql +dictGet[Type]('dict_name', 'attr_name', id_expr) +dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) +``` + +**Параметры** + +- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `attr_name` — имя столбца словаря. [Строковый литерал](../syntax.md#syntax-string-literal). +- `id_expr` — значение ключа словаря. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql-reference/functions/ext-dict-functions.md). +- `default_value_expr` — значение, возвращаемое в том случае, когда словарь не содержит строки с заданным ключом `id_expr`. [Выражение](../syntax.md#syntax-expressions) возвращающее значение с типом данных, сконфигурированным для атрибута `attr_name`. + +**Возвращаемое значение** + +- Если ClickHouse успешно обработал атрибут в соответствии с [заданным типом данных](../../sql-reference/functions/ext-dict-functions.md#ext_dict_structure-attributes), то функции возвращают значение атрибута, соответствующее ключу `id_expr`. + +- Если запрошенного `id_expr` нет в словаре, то: + + - `dictGet[Type]` возвращает содержимое элемента ``, указанного для атрибута в конфигурации словаря. + - `dictGet[Type]OrDefault` возвращает аргумент `default_value_expr`. + +Если значение атрибута не удалось обработать или оно не соответствует типу данных атрибута, то ClickHouse генерирует исключение. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/ext_dict_functions/) diff --git a/docs/ru/sql-reference/functions/functions-for-nulls.md b/docs/ru/sql-reference/functions/functions-for-nulls.md new file mode 100644 index 00000000000..5fbfb4bd27b --- /dev/null +++ b/docs/ru/sql-reference/functions/functions-for-nulls.md @@ -0,0 +1,305 @@ +# Функции для работы с Nullable-аргументами {#funktsii-dlia-raboty-s-nullable-argumentami} + +## isNull {#isnull} + +Проверяет является ли аргумент [NULL](../../sql-reference/syntax.md#null-literal). + +``` sql +isNull(x) +``` + +**Параметры** + +- `x` — значение с не составным типом данных. + +**Возвращаемое значение** + +- `1`, если `x` — `NULL`. +- `0`, если `x` — не `NULL`. + +**Пример** + +Входная таблица + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +Запрос + +``` sql +SELECT x FROM t_null WHERE isNull(y) +``` + +``` text +┌─x─┐ +│ 1 │ +└───┘ +``` + +## isNotNull {#isnotnull} + +Проверяет не является ли аргумент [NULL](../../sql-reference/syntax.md#null-literal). + +``` sql +isNotNull(x) +``` + +**Параметры** + +- `x` — значение с не составным типом данных. + +**Возвращаемое значение** + +- `0`, если `x` — `NULL`. +- `1`, если `x` — не `NULL`. + +**Пример** + +Входная таблица + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +Запрос + +``` sql +SELECT x FROM t_null WHERE isNotNull(y) +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## coalesce {#coalesce} + +Последовательно слева-направо проверяет являются ли переданные аргументы `NULL` и возвращает первый не `NULL`. + +``` sql +coalesce(x,...) +``` + +**Параметры** + +- Произвольное количество параметров не составного типа. Все параметры должны быть совместимы по типу данных. + +**Возвращаемые значения** + +- Первый не `NULL` аргумент. +- `NULL`, если все аргументы — `NULL`. + +**Пример** + +Рассмотрим адресную книгу, в которой может быть указано несколько способов связи с клиентом. + +``` text +┌─name─────┬─mail─┬─phone─────┬──icq─┐ +│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ +│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ +└──────────┴──────┴───────────┴──────┘ +``` + +Поля `mail` и `phone` имеют тип String, а поле `icq` — `UInt32`, его необходимо будет преобразовать в `String`. + +Получим из адресной книги первый доступный способ связаться с клиентом: + +``` sql +SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook +``` + +``` text +┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ +│ client 1 │ 123-45-67 │ +│ client 2 │ ᴺᵁᴸᴸ │ +└──────────┴──────────────────────────────────────────────────────┘ +``` + +## ifNull {#ifnull} + +Возвращает альтернативное значение, если основной аргумент — `NULL`. + +``` sql +ifNull(x,alt) +``` + +**Параметры** + +- `x` — значение для проверки на `NULL`, +- `alt` — значение, которое функция вернёт, если `x` — `NULL`. + +**Возвращаемые значения** + +- Значение `x`, если `x` — не `NULL`. +- Значение `alt`, если `x` — `NULL`. + +**Пример** + +``` sql +SELECT ifNull('a', 'b') +``` + +``` text +┌─ifNull('a', 'b')─┐ +│ a │ +└──────────────────┘ +``` + +``` sql +SELECT ifNull(NULL, 'b') +``` + +``` text +┌─ifNull(NULL, 'b')─┐ +│ b │ +└───────────────────┘ +``` + +## nullIf {#nullif} + +Возвращает `NULL`, если аргументы равны. + +``` sql +nullIf(x, y) +``` + +**Параметры** + +`x`, `y` — значения для сравнивания. Они должны быть совместимых типов, иначе ClickHouse сгенерирует исключение. + +**Возвращаемые значения** + +- `NULL`, если аргументы равны. +- Значение `x`, если аргументы не равны. + +**Пример** + +``` sql +SELECT nullIf(1, 1) +``` + +``` text +┌─nullIf(1, 1)─┐ +│ ᴺᵁᴸᴸ │ +└──────────────┘ +``` + +``` sql +SELECT nullIf(1, 2) +``` + +``` text +┌─nullIf(1, 2)─┐ +│ 1 │ +└──────────────┘ +``` + +## assumeNotNull {#assumenotnull} + +Приводит значение типа [Nullable](../../sql-reference/functions/functions-for-nulls.md) к не `Nullable`, если значение не `NULL`. + +``` sql +assumeNotNull(x) +``` + +**Параметры** + +- `x` — исходное значение. + +**Возвращаемые значения** + +- Исходное значение с не `Nullable` типом, если оно — не `NULL`. +- Значение по умолчанию для не `Nullable` типа, если исходное значение — `NULL`. + +**Пример** + +Рассмотрим таблицу `t_null`. + +``` sql +SHOW CREATE TABLE t_null +``` + +``` text +┌─statement─────────────────────────────────────────────────────────────────┐ +│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ +└───────────────────────────────────────────────────────────────────────────┘ +``` + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 3 │ +└───┴──────┘ +``` + +Применим функцию `assumeNotNull` к столбцу `y`. + +``` sql +SELECT assumeNotNull(y) FROM t_null +``` + +``` text +┌─assumeNotNull(y)─┐ +│ 0 │ +│ 3 │ +└──────────────────┘ +``` + +``` sql +SELECT toTypeName(assumeNotNull(y)) FROM t_null +``` + +``` text +┌─toTypeName(assumeNotNull(y))─┐ +│ Int8 │ +│ Int8 │ +└──────────────────────────────┘ +``` + +## toNullable {#tonullable} + +Преобразует тип аргумента к `Nullable`. + +``` sql +toNullable(x) +``` + +**Параметры** + +- `x` — значение произвольного не составного типа. + +**Возвращаемое значение** + +- Входное значение с типом не `Nullable`. + +**Пример** + +``` sql +SELECT toTypeName(10) +``` + +``` text +┌─toTypeName(10)─┐ +│ UInt8 │ +└────────────────┘ +``` + +``` sql +SELECT toTypeName(toNullable(10)) +``` + +``` text +┌─toTypeName(toNullable(10))─┐ +│ Nullable(UInt8) │ +└────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/functions_for_nulls/) diff --git a/docs/ru/sql-reference/functions/geo.md b/docs/ru/sql-reference/functions/geo.md new file mode 100644 index 00000000000..45c30b3c2cd --- /dev/null +++ b/docs/ru/sql-reference/functions/geo.md @@ -0,0 +1,385 @@ +# Функции для работы с географическими координатами {#funktsii-dlia-raboty-s-geograficheskimi-koordinatami} + +## greatCircleDistance {#greatcircledistance} + +Вычисляет расстояние между двумя точками на поверхности Земли по [формуле большого круга](https://en.wikipedia.org/wiki/Great-circle_distance). + +``` sql +greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) +``` + +**Входные параметры** + +- `lon1Deg` — долгота первой точки в градусах. Диапазон — `[-180°, 180°]`. +- `lat1Deg` — широта первой точки в градусах. Диапазон — `[-90°, 90°]`. +- `lon2Deg` — долгота второй точки в градусах. Диапазон — `[-180°, 180°]`. +- `lat2Deg` — широта второй точки в градусах. Диапазон — `[-90°, 90°]`. + +Положительные значения соответствуют северной широте и восточной долготе, отрицательные — южной широте и западной долготе. + +**Возвращаемое значение** + +Расстояние между двумя точками на поверхности Земли в метрах. + +Генерирует исключение, когда значения входных параметров выходят за границы диапазонов. + +**Пример** + +``` sql +SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) +``` + +``` text +┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ +│ 14132374.194975413 │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## greatCircleAngle {#greatcircleangle} + +Вычисляет угловое расстояние на сфере по [формуле большого круга](https://en.wikipedia.org/wiki/Great-circle_distance). + +``` sql +greatCircleAngle(lon1Deg, lat1Deg, lon2Deg, lat2Deg) +``` + +**Входные параметры** + +- `lon1Deg` — долгота первой точки в градусах. +- `lat1Deg` — широта первой точки в градусах. +- `lon2Deg` — долгота второй точки в градусах. +- `lat2Deg` — широта второй точки в градусах. + +**Возвращаемое значение** + +Длина дуги большого круга между двумя точками в градусах. + +**Пример** + +``` sql +SELECT greatCircleAngle(0, 0, 45, 0) AS arc +``` + +``` text +┌─arc─┐ +│ 45 │ +└─────┘ +``` + +## pointInEllipses {#pointinellipses} + +Проверяет, принадлежит ли точка хотя бы одному из эллипсов. +Координаты — геометрические в декартовой системе координат. + + pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) + +**Входные параметры** + +- `x, y` — координаты точки на плоскости. +- `xᵢ, yᵢ` — координаты центра `i`-го эллипса. +- `aᵢ, bᵢ` — полуоси `i`-го эллипса (в единицах измерения координат x,y). + +Входных параметров должно быть `2+4⋅n`, где `n` — количество эллипсов. + +**Возвращаемые значения** + +`1`, если точка внутри хотя бы одного из эллипсов, `0`, если нет. + +**Пример** + +``` sql +SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) +``` + +``` text +┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ +│ 1 │ +└─────────────────────────────────────────────────┘ +``` + +## pointInPolygon {#pointinpolygon} + +Проверяет, принадлежит ли точка многоугольнику на плоскости. + +``` sql +pointInPolygon((x, y), [(a, b), (c, d) ...], ...) +``` + +**Входные значения** + +- `(x, y)` — координаты точки на плоскости. Тип данных — [Tuple](../../sql-reference/functions/geo.md) — кортеж из двух чисел. +- `[(a, b), (c, d) ...]` — вершины многоугольника. Тип данных — [Array](../../sql-reference/functions/geo.md). Каждая вершина представлена парой координат `(a, b)`. Вершины следует указывать в порядке обхода по или против часовой стрелки. Минимальное количество вершин — 3. Многоугольник должен быть константным. +- функция поддерживает также многоугольники с дырками (вырезанными кусками). Для этого случая, добавьте многоугольники, описывающие вырезанные куски, дополнительными аргументами функции. Функция не поддерживает не односвязные многоугольники. + +**Возвращаемые значения** + +`1`, если точка внутри многоугольника, `0`, если нет. +Если точка находится на границе многоугольника, функция может возвращать как 0, так и 1. + +**Пример** + +``` sql +SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## geohashEncode {#geohashencode} + +Кодирует широту и долготу в строку geohash, смотрите http://geohash.org/, https://en.wikipedia.org/wiki/Geohash. + +``` sql +geohashEncode(longitude, latitude, [precision]) +``` + +**Входные значения** + +- longitude — долгота. Диапазон — `[-180°, 180°].` +- latitude — широта. Диапазон — `[-90°, 90°].` +- precision — длина результирующей строки, по умолчанию `12`. Опционально. Целое число в диапазоне `[1, 12]`. Любое значение меньше, чем `1` или больше `12` автоматически преобразуются в `12`. + +**Возвращаемые значения** + +- Строка с координатой, закодированной модифицированной версией алфавита base32. + +**Пример** + +``` sql +SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res +``` + +``` text +┌─res──────────┐ +│ ezs42d000000 │ +└──────────────┘ +``` + +## geohashDecode {#geohashdecode} + +Декодирует любую строку, закодированную в geohash, на долготу и широту. + +``` sql +geohashDecode(geohash_string) +``` + +**Входные значения** + +- `geohash_string` — строка, содержащая geohash. + +**Возвращаемые значения** + +- `(longitude, latitude)` — широта и долгота. Кортеж из двух значений типа `Float64`. + +**Пример** + +``` sql +SELECT geohashDecode('ezs42') AS res +``` + +``` text +┌─res─────────────────────────────┐ +│ (-5.60302734375,42.60498046875) │ +└─────────────────────────────────┘ +``` + +## h3IsValid {#h3isvalid} + +Проверяет корректность H3-индекса. + +``` sql +h3IsValid(h3index) +``` + +**Входные значения** + +- `h3index` — идентификатор шестиугольника. Тип данных — [UInt64](../../sql-reference/functions/geo.md). + +**Возвращаемые значения** + +- 0 — число не является H3-индексом +- 1 — число является H3-индексом + +Тип — [UInt8](../../sql-reference/functions/geo.md). + +**Пример** + +``` sql +SELECT h3IsValid(630814730351855103) as h3IsValid +``` + +``` text +┌─h3IsValid─┐ +│ 1 │ +└───────────┘ +``` + +## h3GetResolution {#h3getresolution} + +Извлекает разрешение H3-индекса. + +``` sql +h3GetResolution(h3index) +``` + +**Входные значения** + +- `h3index` — идентификатор шестиугольника. Тип данных — [UInt64](../../sql-reference/functions/geo.md). + +**Возвращаемые значения** + +- Разрешение сетки, от 0 до 15. +- Для несуществующего идентификатора может быть возвращено произвольное значение, используйте [h3IsValid](#h3isvalid) для проверки идентификаторов + +Тип — [UInt8](../../sql-reference/functions/geo.md). + +**Пример** + +``` sql +SELECT h3GetResolution(639821929606596015) as resolution +``` + +``` text +┌─resolution─┐ +│ 14 │ +└────────────┘ +``` + +## h3EdgeAngle {#h3edgeangle} + +Информирует о среднем размере стороны шестигранника H3 в градусах + +``` sql +h3EdgeAngle(resolution) +``` + +**Входные значения** + +- `resolution` — требуемое разрешение индекса. Тип данных — [UInt8](../../sql-reference/functions/geo.md). Диапазон возможных значений — `[0, 15]`. + +**Возвращаемые значения** + +Средняя длина стороны многоугольника H3 в градусах, тип — [Float64](../../sql-reference/functions/geo.md). + +**Пример** + +``` sql +SELECT h3EdgeAngle(10) as edgeAngle +``` + +``` text +┌─────────h3EdgeAngle(10)─┐ +│ 0.0005927224846720883 │ +└───────────────────────┘ +``` + +## h3EdgeLengthM {#h3edgelengthm} + +Информирует о среднем размере стороны шестигранника H3 в метрах + +``` sql +h3EdgeLengthM(resolution) +``` + +**Входные значения** + +- `resolution` — требуемое разрешение индекса. Тип данных — [UInt8](../../sql-reference/functions/geo.md). Диапазон возможных значений — `[0, 15]`. + +**Возвращаемые значения** + +Средняя длина стороны многоугольника H3 в метрах, тип — [Float64](../../sql-reference/functions/geo.md). + +**Пример** + +``` sql +SELECT h3EdgeLengthM(15) as edgeLengthM +``` + +``` text +┌─edgeLengthM─┐ +│ 0.509713273 │ +└─────────────┘ +``` + +## geoToH3 {#geotoh3} + +Возвращает H3 индекс точки `(lon, lat)` с заданным разрешением. + +[H3](https://uber.github.io/h3/#/documentation/overview/introduction) - это географическая система индексации, в которой поверхность Земли разделена на ровные шестиугольные плитки. Эта система иерархична, то есть каждый шестиугольник на верхнем уровне может быть разбит на семь еще более мелких и так далее. + +H3 индекс используется в основном для определения местоположения с помощью карт и других геопространственных манипуляций. + +**Синтаксис** + +``` sql +geoToH3(lon, lat, resolution) +``` + +**Параметры** + +- `lon` — географическая долгота. Тип данных — [Float64](../../sql-reference/functions/geo.md). +- `lat` — географическая широта. Тип данных — [Float64](../../sql-reference/functions/geo.md). +- `resolution` — требуемое разрешение индекса. Тип данных — [UInt8](../../sql-reference/functions/geo.md). Диапазон возможных значений — `[0, 15]`. + +**Возвращаемые значения** + +- Порядковый номер шестиугольника. +- 0 в случае ошибки. + +Тип — [UInt64](../../sql-reference/functions/geo.md). + +**Пример** + +Запрос: + +``` sql +SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index +``` + +Ответ: + +``` text +┌────────────h3Index─┐ +│ 644325524701193974 │ +└────────────────────┘ +``` + +## h3kRing {#h3kring} + +Возвращает H3-индексы шестиугольников в радиусе `k` от данного в произвольном порядке + +``` sql +h3kRing(h3index, k) +``` + +**Входные значения** + +- `h3index` — идентификатор шестиугольника. Тип данных — [UInt64](../../sql-reference/functions/geo.md). +- `k` — радиус. Тип данных — [целое число](../../sql-reference/functions/geo.md) + +**Возвращаемые значения** + +[Массив](../../sql-reference/functions/geo.md) из H3-индексов типа [UInt64](../../sql-reference/functions/geo.md). + +**Пример** + +``` sql +SELECT arrayJoin(h3kRing(644325529233966508, 1)) AS h3index +``` + +``` text +┌────────────h3index─┐ +│ 644325529233966508 │ +│ 644325529233966497 │ +│ 644325529233966510 │ +│ 644325529233966504 │ +│ 644325529233966509 │ +│ 644325529233966355 │ +│ 644325529233966354 │ +└────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/geo/) diff --git a/docs/ru/sql-reference/functions/hash-functions.md b/docs/ru/sql-reference/functions/hash-functions.md new file mode 100644 index 00000000000..682f1410cc6 --- /dev/null +++ b/docs/ru/sql-reference/functions/hash-functions.md @@ -0,0 +1,479 @@ +# Функции хэширования {#funktsii-kheshirovaniia} + +Функции хэширования могут использоваться для детерминированного псевдослучайного разбрасывания элементов. + +## halfMD5 {#hash-functions-halfmd5} + +[Интерпретирует](../../sql-reference/functions/hash-functions.md#type_conversion_functions-reinterpretAsString) все входные параметры как строки и вычисляет хэш [MD5](https://ru.wikipedia.org/wiki/MD5) для каждой из них. Затем объединяет хэши, берет первые 8 байт хэша результирующей строки и интерпретирует их как значение типа `UInt64` с big-endian порядком байтов. + +``` sql +halfMD5(par1, ...) +``` + +Функция относительно медленная (5 миллионов коротких строк в секунду на ядро процессора). +По возможности, используйте функцию [sipHash64](#hash_functions-siphash64) вместо неё. + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +Значение хэша с типом данных [UInt64](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type +``` + +``` text +┌────────halfMD5hash─┬─type───┐ +│ 186182704141653334 │ UInt64 │ +└────────────────────┴────────┘ +``` + +## MD5 {#hash_functions-md5} + +Вычисляет MD5 от строки и возвращает полученный набор байт в виде FixedString(16). +Если вам не нужен конкретно MD5, а нужен неплохой криптографический 128-битный хэш, то используйте вместо этого функцию sipHash128. +Если вы хотите получить такой же результат, как выдаёт утилита md5sum, напишите lower(hex(MD5(s))). + +## sipHash64 {#hash_functions-siphash64} + +Генерирует 64-х битное значение [SipHash](https://131002.net/siphash/). + +``` sql +sipHash64(par1,...) +``` + +Это криптографическая хэш-функция. Она работает по крайней мере в три раза быстрее, чем функция [MD5](#hash_functions-md5). + +Функция [интерпретирует](../../sql-reference/functions/hash-functions.md#type_conversion_functions-reinterpretAsString) все входные параметры как строки и вычисляет хэш MD5 для каждой из них. Затем комбинирует хэши по следующему алгоритму. + +1. После хэширования всех входных параметров функция получает массив хэшей. +2. Функция принимает первый и второй элементы и вычисляет хэш для массива из них. +3. Затем функция принимает хэш-значение, вычисленное на предыдущем шаге, и третий элемент исходного хэш-массива, и вычисляет хэш для массива из них. +4. Предыдущий шаг повторяется для всех остальных элементов исходного хэш-массива. + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +Значение хэша с типом данных [UInt64](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type +``` + +``` text +┌──────────────SipHash─┬─type───┐ +│ 13726873534472839665 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## sipHash128 {#hash_functions-siphash128} + +Вычисляет SipHash от строки. +Принимает аргумент типа String. Возвращает FixedString(16). +Отличается от sipHash64 тем, что финальный xor-folding состояния делается только до 128 бит. + +## cityHash64 {#cityhash64} + +Генерирует 64-х битное значение [CityHash](https://github.com/google/cityhash). + +``` sql +cityHash64(par1,...) +``` + +Это не криптографическая хэш-функция. Она использует CityHash алгоритм для строковых параметров и зависящую от реализации быструю некриптографическую хэш-функцию для параметров с другими типами данных. Функция использует комбинатор CityHash для получения конечных результатов. + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +Значение хэша с типом данных [UInt64](../../sql-reference/functions/hash-functions.md). + +**Примеры** + +Пример вызова: + +``` sql +SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type +``` + +``` text +┌─────────────CityHash─┬─type───┐ +│ 12072650598913549138 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +А вот так вы можете вычислить чексумму всей таблицы с точностью до порядка строк: + +``` sql +SELECT groupBitXor(cityHash64(*)) FROM table +``` + +## intHash32 {#inthash32} + +Вычисляет 32-битный хэш-код от целого числа любого типа. +Это сравнительно быстрая не криптографическая хэш-функция среднего качества для чисел. + +## intHash64 {#inthash64} + +Вычисляет 64-битный хэш-код от целого числа любого типа. +Работает быстрее, чем intHash32. Качество среднее. + +## SHA1 {#sha1} + +## SHA224 {#sha224} + +## SHA256 {#sha256} + +Вычисляет SHA-1, SHA-224, SHA-256 от строки и возвращает полученный набор байт в виде FixedString(20), FixedString(28), FixedString(32). +Функция работает достаточно медленно (SHA-1 - примерно 5 миллионов коротких строк в секунду на одном процессорном ядре, SHA-224 и SHA-256 - примерно 2.2 миллионов). +Рекомендуется использовать эти функции лишь в тех случаях, когда вам нужна конкретная хэш-функция и вы не можете её выбрать. +Даже в этих случаях, рекомендуется применять функцию оффлайн - заранее вычисляя значения при вставке в таблицу, вместо того, чтобы применять её при SELECT-ах. + +## URLHash(url\[, N\]) {#urlhashurl-n} + +Быстрая не криптографическая хэш-функция неплохого качества для строки, полученной из URL путём некоторой нормализации. +`URLHash(s)` - вычислить хэш от строки без одного завершающего символа `/`, `?` или `#` на конце, если там такой есть. +`URLHash(s, N)` - вычислить хэш от строки до N-го уровня в иерархии URL, без одного завершающего символа `/`, `?` или `#` на конце, если там такой есть. +Уровни аналогичные URLHierarchy. Функция специфична для Яндекс.Метрики. + +## farmHash64 {#farmhash64} + +Генерирует 64-х битное значение [FarmHash](https://github.com/google/farmhash). + +``` sql +farmHash64(par1, ...) +``` + +Из всех [доступных методов](https://github.com/google/farmhash/blob/master/src/farmhash.h) функция использует `Hash64`. + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +Значение хэша с типом данных [UInt64](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type +``` + +``` text +┌─────────────FarmHash─┬─type───┐ +│ 17790458267262532859 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## javaHash {#hash_functions-javahash} + +Вычисляет [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) от строки. `JavaHash` не отличается ни скоростью, ни качеством, поэтому эту функцию следует считать устаревшей. Используйте эту функцию, если вам необходимо получить значение хэша по такому же алгоритму. + +``` sql +SELECT javaHash(''); +``` + +**Возвращаемое значение** + +Хэш-значение типа `Int32`. + +Тип: `javaHash`. + +**Пример** + +Запрос: + +``` sql +SELECT javaHash('Hello, world!'); +``` + +Ответ: + +``` text +┌─javaHash('Hello, world!')─┐ +│ -1880044555 │ +└───────────────────────────┘ +``` + +## javaHashUTF16LE {#javahashutf16le} + +Вычисляет [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) от строки, при допущении, что строка представлена в кодировке `UTF-16LE`. + +**Синтаксис** + +``` sql +javaHashUTF16LE(stringUtf16le) +``` + +**Параметры** + +- `stringUtf16le` — строка в `UTF-16LE`. + +**Возвращаемое значение** + +Хэш-значение типа `Int32`. + +Тип: `javaHash`. + +**Пример** + +Верный запрос для строки кодированной в `UTF-16LE`. + +Запрос: + +``` sql +SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) +``` + +Ответ: + +``` text +┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ +│ 3556498 │ +└──────────────────────────────────────────────────────────────┘ +``` + +## hiveHash {#hash-functions-hivehash} + +Вычисляет `HiveHash` от строки. + +``` sql +SELECT hiveHash(''); +``` + +`HiveHash` — это результат [JavaHash](#hash_functions-javahash) с обнулённым битом знака числа. Функция используется в [Apache Hive](https://en.wikipedia.org/wiki/Apache_Hive) вплоть до версии 3.0. + +**Возвращаемое значение** + +Хэш-значение типа `Int32`. + +Тип: `hiveHash`. + +**Пример** + +Запрос: + +``` sql +SELECT hiveHash('Hello, world!'); +``` + +Ответ: + +``` text +┌─hiveHash('Hello, world!')─┐ +│ 267439093 │ +└───────────────────────────┘ +``` + +## metroHash64 {#metrohash64} + +Генерирует 64-х битное значение [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/). + +``` sql +metroHash64(par1, ...) +``` + +**Параметры** + +Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +Значение хэша с типом данных [UInt64](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type +``` + +``` text +┌────────────MetroHash─┬─type───┐ +│ 14235658766382344533 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## jumpConsistentHash {#jumpconsistenthash} + +Вычисляет JumpConsistentHash от значения типа UInt64. +Имеет два параметра: ключ типа UInt64 и количество бакетов. Возвращает значение типа Int32. +Дополнительные сведения смотрите по ссылке: [JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) + +## murmurHash2\_32, murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} + +Генерирует значение [MurmurHash2](https://github.com/aappleby/smhasher). + +``` sql +murmurHash2_32(par1, ...) +murmurHash2_64(par1, ...) +``` + +**Параметры** + +Обе функции принимают переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +- Функция `murmurHash2_32` возвращает значение типа [UInt32](../../sql-reference/functions/hash-functions.md). +- Функция `murmurHash2_64` возвращает значение типа [UInt64](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type +``` + +``` text +┌──────────MurmurHash2─┬─type───┐ +│ 11832096901709403633 │ UInt64 │ +└──────────────────────┴────────┘ +``` + +## gccMurmurHash {#gccmurmurhash} + +Вычисляет 64-битное значение [MurmurHash2](https://github.com/aappleby/smhasher), используя те же hash seed, что и [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191). + +**Синтаксис** + +``` sql +gccMurmurHash(par1, ...); +``` + +**Параметры** + +- `par1, ...` — Переменное число параметров. Каждый параметр может быть любого из [поддерживаемых типов данных](../../sql-reference/data-types/index.md). + +**Возвращаемое значение** + +- Вычисленный хэш-код. + +Тип: [UInt64](../../sql-reference/data-types/int-uint.md). + +**Примеры** + +Запрос: + +``` sql +SELECT + gccMurmurHash(1, 2, 3) AS res1, + gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 +``` + +Результат: + +``` text +┌─────────────────res1─┬────────────────res2─┐ +│ 12384823029245979431 │ 1188926775431157506 │ +└──────────────────────┴─────────────────────┘ +``` + +## murmurHash3\_32, murmurHash3\_64 {#murmurhash3-32-murmurhash3-64} + +Генерирует значение [MurmurHash3](https://github.com/aappleby/smhasher). + +``` sql +murmurHash3_32(par1, ...) +murmurHash3_64(par1, ...) +``` + +**Параметры** + +Обе функции принимают переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +- Функция `murmurHash3_32` возвращает значение типа [UInt32](../../sql-reference/functions/hash-functions.md). +- Функция `murmurHash3_64` возвращает значение типа [UInt64](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type +``` + +``` text +┌─MurmurHash3─┬─type───┐ +│ 2152717 │ UInt32 │ +└─────────────┴────────┘ +``` + +## murmurHash3\_128 {#murmurhash3-128} + +Генерирует значение [MurmurHash3](https://github.com/aappleby/smhasher). + +``` sql +murmurHash3_128( expr ) +``` + +**Параметры** + +- `expr` — [выражение](../syntax.md#syntax-expressions) возвращающее значение типа[String](../../sql-reference/functions/hash-functions.md). + +**Возвращаемое значение** + +Хэш-значение типа [FixedString(16)](../../sql-reference/functions/hash-functions.md). + +**Пример** + +``` sql +SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type +``` + +``` text +┌─MurmurHash3──────┬─type────────────┐ +│ 6�1�4"S5KT�~~q │ FixedString(16) │ +└──────────────────┴─────────────────┘ +``` + +## xxHash32, xxHash64 {#hash-functions-xxhash32-xxhash64} + +Вычисляет `xxHash` от строки. Предлагается в двух вариантах: 32 и 64 бита. + +``` sql +SELECT xxHash32(''); + +OR + +SELECT xxHash64(''); +``` + +**Возвращаемое значение** + +Хэш-значение типа `Uint32` или `Uint64`. + +Тип: `xxHash`. + +**Пример** + +Запрос: + +``` sql +SELECT xxHash32('Hello, world!'); +``` + +Ответ: + +``` text +┌─xxHash32('Hello, world!')─┐ +│ 834093149 │ +└───────────────────────────┘ +``` + +**Смотрите также** + +- [xxHash](http://cyan4973.github.io/xxHash/). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/hash_functions/) diff --git a/docs/ru/sql-reference/functions/higher-order-functions.md b/docs/ru/sql-reference/functions/higher-order-functions.md new file mode 100644 index 00000000000..cd3dee5b1a7 --- /dev/null +++ b/docs/ru/sql-reference/functions/higher-order-functions.md @@ -0,0 +1,167 @@ +# Функции высшего порядка {#higher-order-functions} + +## Оператор `->`, функция lambda(params, expr) {#operator-funktsiia-lambdaparams-expr} + +Позволяет описать лямбда-функцию для передачи в функцию высшего порядка. Слева от стрелочки стоит формальный параметр - произвольный идентификатор, или несколько формальных параметров - произвольные идентификаторы в кортеже. Справа от стрелочки стоит выражение, в котором могут использоваться эти формальные параметры, а также любые столбцы таблицы. + +Примеры: `x -> 2 * x, str -> str != Referer.` + +Функции высшего порядка, в качестве своего функционального аргумента могут принимать только лямбда-функции. + +В функции высшего порядка может быть передана лямбда-функция, принимающая несколько аргументов. В этом случае, в функцию высшего порядка передаётся несколько массивов одинаковых длин, которым эти аргументы будут соответствовать. + +Для некоторых функций, например [arrayCount](#higher_order_functions-array-count) или [arraySum](#higher_order_functions-array-sum), первый аргумент (лямбда-функция) может отсутствовать. В этом случае, подразумевается тождественное отображение. + +Для функций, перечисленных ниже, лямбда-функцию должна быть указана всегда: + +- [arrayMap](#higher_order_functions-array-map) +- [arrayFilter](#higher_order_functions-array-filter) +- [arrayFirst](#higher_order_functions-array-first) +- [arrayFirstIndex](#higher_order_functions-array-first-index) + +### arrayMap(func, arr1, …) {#higher_order_functions-array-map} + +Вернуть массив, полученный на основе результатов применения функции `func` к каждому элементу массива `arr`. + +Примеры: + +``` sql +SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; +``` + +``` text +┌─res─────┐ +│ [3,4,5] │ +└─────────┘ +``` + +Следующий пример показывает, как создать кортежи из элементов разных массивов: + +``` sql +SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res +``` + +``` text +┌─res─────────────────┐ +│ [(1,4),(2,5),(3,6)] │ +└─────────────────────┘ +``` + +Обратите внимание, что у функции `arrayMap` первый аргумент (лямбда-функция) не может быть опущен. + +### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} + +Вернуть массив, содержащий только те элементы массива `arr1`, для которых функция `func` возвращает не 0. + +Примеры: + +``` sql +SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res +``` + +``` text +┌─res───────────┐ +│ ['abc World'] │ +└───────────────┘ +``` + +``` sql +SELECT + arrayFilter( + (i, x) -> x LIKE '%World%', + arrayEnumerate(arr), + ['Hello', 'abc World'] AS arr) + AS res +``` + +``` text +┌─res─┐ +│ [2] │ +└─────┘ +``` + +Обратите внимание, что у функции `arrayFilter` первый аргумент (лямбда-функция) не может быть опущен. + +### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} + +Вернуть количество элементов массива `arr`, для которых функция func возвращает не 0. Если func не указана - вернуть количество ненулевых элементов массива. + +### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} + +Вернуть 1, если существует хотя бы один элемент массива `arr`, для которого функция func возвращает не 0. Иначе вернуть 0. + +### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} + +Вернуть 1, если для всех элементов массива `arr`, функция `func` возвращает не 0. Иначе вернуть 0. + +### arraySum(\[func,\] arr1, …) {#higher_order_functions-array-sum} + +Вернуть сумму значений функции `func`. Если функция не указана - просто вернуть сумму элементов массива. + +### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} + +Вернуть первый элемент массива `arr1`, для которого функция func возвращает не 0. + +Обратите внимание, что у функции `arrayFirst` первый аргумент (лямбда-функция) не может быть опущен. + +### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} + +Вернуть индекс первого элемента массива `arr1`, для которого функция func возвращает не 0. + +Обратите внимание, что у функции `arrayFirstFilter` первый аргумент (лямбда-функция) не может быть опущен. + +### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} + +Возвращает массив из частичных сумм элементов исходного массива (сумма с накоплением). Если указана функция `func`, то значения элементов массива преобразуются этой функцией перед суммированием. + +Пример: + +``` sql +SELECT arrayCumSum([1, 1, 1, 1]) AS res +``` + +``` text +┌─res──────────┐ +│ [1, 2, 3, 4] │ +└──────────────┘ +``` + +### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} + +Возвращает отсортированный в восходящем порядке массив `arr1`. Если задана функция `func`, то порядок сортировки определяется результатом применения функции `func` на элементы массива (массивов). + +Для улучшения эффективности сортировки применяется [Преобразование Шварца](https://ru.wikipedia.org/wiki/%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5_%D0%A8%D0%B2%D0%B0%D1%80%D1%86%D0%B0). + +Пример: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); +``` + +``` text +┌─res────────────────┐ +│ ['world', 'hello'] │ +└────────────────────┘ +``` + +Подробная информация о методе `arraySort` приведена в разделе [Функции по работе с массивами](array-functions.md#array_functions-sort). + +### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} + +Возвращает отсортированный в нисходящем порядке массив `arr1`. Если задана функция `func`, то порядок сортировки определяется результатом применения функции `func` на элементы массива (массивов). + +Пример: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` text +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +Подробная информация о методе `arrayReverseSort` приведена в разделе [Функции по работе с массивами](array-functions.md#array_functions-reverse-sort). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/higher_order_functions/) diff --git a/docs/ru/sql-reference/functions/in-functions.md b/docs/ru/sql-reference/functions/in-functions.md new file mode 100644 index 00000000000..679fcbccc21 --- /dev/null +++ b/docs/ru/sql-reference/functions/in-functions.md @@ -0,0 +1,19 @@ +# Функции для реализации оператора IN {#funktsii-dlia-realizatsii-operatora-in} + +## in, notIn, globalIn, globalNotIn {#in-functions} + +Смотрите раздел [Операторы IN](../operators/in.md#select-in-operators). + +## tuple(x, y, …), оператор (x, y, …) {#tuplex-y-operator-x-y} + +Функция, позволяющая сгруппировать несколько столбцов. +Для столбцов, имеющих типы T1, T2, … возвращает кортеж типа Tuple(T1, T2, …), содержащий эти столбцы. Выполнение функции ничего не стоит. +Кортежи обычно используются как промежуточное значение в качестве аргумента операторов IN, или для создания списка формальных параметров лямбда-функций. Кортежи не могут быть записаны в таблицу. + +## tupleElement(tuple, n), оператор x.N {#tupleelementtuple-n-operator-x-n} + +Функция, позволяющая достать столбец из кортежа. +N - индекс столбца начиная с 1. N должно быть константой. N должно быть целым строго положительным числом не большим размера кортежа. +Выполнение функции ничего не стоит. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/in_functions/) diff --git a/docs/ru/sql-reference/functions/index.md b/docs/ru/sql-reference/functions/index.md new file mode 100644 index 00000000000..06d3d892cf9 --- /dev/null +++ b/docs/ru/sql-reference/functions/index.md @@ -0,0 +1,65 @@ +# Функции {#funktsii} + +Функции бывают как минимум\* двух видов - обычные функции (называются просто, функциями) и агрегатные функции. Это совершенно разные вещи. Обычные функции работают так, как будто применяются к каждой строке по отдельности (для каждой строки, результат вычисления функции не зависит от других строк). Агрегатные функции аккумулируют множество значений из разных строк (то есть, зависят от целого множества строк). + +В этом разделе речь пойдёт об обычных функциях. Для агрегатных функций, смотрите раздел «Агрегатные функции». + +\* - есть ещё третий вид функций, к которым относится функция arrayJoin; также можно отдельно иметь ввиду табличные функции.\* + +## Строгая типизация {#strogaia-tipizatsiia} + +В ClickHouse, в отличие от стандартного SQL, типизация является строгой. То есть, не производится неявных преобразований между типами. Все функции работают для определённого набора типов. Это значит, что иногда вам придётся использовать функции преобразования типов. + +## Склейка одинаковых выражений {#common-subexpression-elimination} + +Все выражения в запросе, имеющие одинаковые AST (одинаковую запись или одинаковый результат синтаксического разбора), считаются имеющими одинаковые значения. Такие выражения склеиваются и исполняются один раз. Одинаковые подзапросы тоже склеиваются. + +## Типы результата {#tipy-rezultata} + +Все функции возвращают одно (не несколько, не ноль) значение в качестве результата. Тип результата обычно определяется только типами аргументов, но не значениями аргументов. Исключение - функция tupleElement (оператор a.N), а также функция toFixedString. + +## Константы {#konstanty} + +Для простоты, некоторые функции могут работать только с константами в качестве некоторых аргументов. Например, правый аргумент оператора LIKE должен быть константой. +Почти все функции возвращают константу для константных аргументов. Исключение - функции генерации случайных чисел. +Функция now возвращает разные значения для запросов, выполненных в разное время, но результат считается константой, так как константность важна лишь в пределах одного запроса. +Константное выражение также считается константой (например, правую часть оператора LIKE можно сконструировать из нескольких констант). + +Функции могут быть по-разному реализованы для константных и не константных аргументов (выполняется разный код). Но результат работы для константы и полноценного столбца, содержащего только одно такое же значение, должен совпадать. + +## Обработка NULL {#obrabotka-null} + +Функции имеют следующие виды поведения: + +- Если хотя бы один из аргументов функции — `NULL`, то результат функции тоже `NULL`. +- Специальное поведение, указанное в описании каждой функции отдельно. В исходном коде ClickHouse такие функции можно определить по свойству `UseDefaultImplementationForNulls=false`. + +## Неизменяемость {#neizmeniaemost} + +Функции не могут поменять значения своих аргументов - любые изменения возвращаются в качестве результата. Соответственно, от порядка записи функций в запросе, результат вычислений отдельных функций не зависит. + +## Обработка ошибок {#obrabotka-oshibok} + +Некоторые функции могут кидать исключения в случае ошибочных данных. В этом случае, выполнение запроса прерывается, и текст ошибки выводится клиенту. При распределённой обработке запроса, при возникновении исключения на одном из серверов, на другие серверы пытается отправиться просьба тоже прервать выполнение запроса. + +## Вычисление выражений-аргументов {#vychislenie-vyrazhenii-argumentov} + +В почти всех языках программирования, для некоторых операторов может не вычисляться один из аргументов. Обычно - для операторов `&&`, `||`, `?:`. +Но в ClickHouse, аргументы функций (операторов) вычисляются всегда. Это связано с тем, что вычисления производятся не по отдельности для каждой строки, а сразу для целых кусочков столбцов. + +## Выполнение функций при распределённой обработке запроса {#vypolnenie-funktsii-pri-raspredelionnoi-obrabotke-zaprosa} + +При распределённой обработке запроса, как можно большая часть стадий выполнения запроса производится на удалённых серверах, а оставшиеся стадии (слияние промежуточных результатов и всё, что дальше) - на сервере-инициаторе запроса. + +Это значит, что выполнение функций может производиться на разных серверах. +Например, в запросе `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` +- если `distributed_table` имеет хотя бы два шарда, то функции g и h выполняются на удалённых серверах, а функция f - на сервере-инициаторе запроса; +- если `distributed_table` имеет только один шард, то все функции f, g, h выполняются на сервере этого шарда. + +Обычно результат выполнения функции не зависит от того, на каком сервере её выполнить. Но иногда это довольно важно. +Например, функции, работающие со словарями, будут использовать словарь, присутствующий на том сервере, на котором они выполняются. +Другой пример - функция `hostName` вернёт имя сервера, на котором она выполняется, и это можно использовать для служебных целей - чтобы в запросе `SELECT` сделать `GROUP BY` по серверам. + +Если функция в запросе выполняется на сервере-инициаторе запроса, а вам нужно, чтобы она выполнялась на удалённых серверах, вы можете обернуть её в агрегатную функцию any или добавить в ключ в `GROUP BY`. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/) diff --git a/docs/ru/sql-reference/functions/introspection.md b/docs/ru/sql-reference/functions/introspection.md new file mode 100644 index 00000000000..23ccf3fd855 --- /dev/null +++ b/docs/ru/sql-reference/functions/introspection.md @@ -0,0 +1,303 @@ +# Функции интроспекции {#introspection-functions} + +Функции из этого раздела могут использоваться для интроспекции [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) и [DWARF](https://en.wikipedia.org/wiki/DWARF) в целях профилирования запросов. + +!!! warning "Предупреждение" + Эти функции выполняются медленно и могут приводить к нежелательным последствиям в плане безопасности. + +Для правильной работы функций интроспекции: + +- Установите пакет `clickhouse-common-static-dbg`. + +- Установите настройку [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) в 1. + +Из соображений безопасности данные функции отключены по умолчанию. + +ClickHouse сохраняет отчеты профилировщика в [журнал трассировки](../../operations/system-tables.md#system_tables-trace_log) в системной таблице. Убедитесь, что таблица и профилировщик настроены правильно. + +## addresssToLine {#addresstoline} + +Преобразует адрес виртуальной памяти внутри процесса сервера ClickHouse в имя файла и номер строки в исходном коде ClickHouse. + +Если вы используете официальные пакеты ClickHouse, вам необходимо установить следующий пакеты: `clickhouse-common-static-dbg`. + +**Синтаксис** + +``` sql +addressToLine(address_of_binary_instruction) +``` + +**Параметры** + +- `address_of_binary_instruction` ([Тип UInt64](../../sql-reference/functions/introspection.md))- Адрес инструкции в запущенном процессе. + +**Возвращаемое значение** + +- Имя файла исходного кода и номер строки в этом файле разделяются двоеточием. + + Например, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, где `199` — номер строки. + +- Имя бинарного файла, если функция не может найти отладочную информацию. + +- Пустая строка, если адрес не является допустимым. + +Тип: [String](../../sql-reference/functions/introspection.md). + +**Пример** + +Включение функций самоанализа: + +``` sql +SET allow_introspection_functions=1 +``` + +Выбор первой строки из списка `trace_log` системная таблица: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-19 +event_time: 2019-11-19 18:57:23 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 421b6855-1858-45a5-8f37-f383409d6d72 +trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] +``` + +То `trace` поле содержит трассировку стека в момент выборки. + +Получение имени файла исходного кода и номера строки для одного адреса: + +``` sql +SELECT addressToLine(94784076370703) \G +``` + +``` text +Row 1: +────── +addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +``` + +Применение функции ко всему стектрейсу: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines +FROM system.trace_log +LIMIT 1 +\G +``` + +Функция [arrayMap](higher-order-functions.md#higher_order_functions-array-map) позволяет обрабатывать каждый отдельный элемент массива `trace` с помощью функции `addressToLine`. Результат этой обработки вы видите в виде `trace_source_code_lines` колонки выходных данных. + +``` text +Row 1: +────── +trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so +/usr/lib/debug/usr/bin/clickhouse +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 +/usr/include/c++/9/bits/atomic_base.h:551 +/usr/lib/debug/usr/bin/clickhouse +/lib/x86_64-linux-gnu/libpthread-2.27.so +/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 +``` + +## addressToSymbol {#addresstosymbol} + +Преобразует адрес виртуальной памяти внутри серверного процесса ClickHouse в символ из объектных файлов ClickHouse. + +**Синтаксис** + +``` sql +addressToSymbol(address_of_binary_instruction) +``` + +**Параметры** + +- `address_of_binary_instruction` ([Тип uint64](../../sql-reference/functions/introspection.md)) — Адрес инструкции в запущенном процессе. + +**Возвращаемое значение** + +- Символ из объектных файлов ClickHouse. +- Пустая строка, если адрес не является допустимым. + +Тип: [String](../../sql-reference/functions/introspection.md). + +**Пример** + +Включение функций самоанализа: + +``` sql +SET allow_introspection_functions=1 +``` + +Выбор первой строки из списка `trace_log` системная таблица: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +То `trace` поле содержит трассировку стека в момент выборки. + +Получение символа для одного адреса: + +``` sql +SELECT addressToSymbol(94138803686098) \G +``` + +``` text +Row 1: +────── +addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +``` + +Применение функции ко всей трассировке стека: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols +FROM system.trace_log +LIMIT 1 +\G +``` + +То [arrayMap](higher-order-functions.md#higher_order_functions-array-map) функция позволяет обрабатывать каждый отдельный элемент системы. `trace` массив по типу `addressToSymbols` функция. Результат этой обработки вы видите в виде `trace_symbols` колонка выходных данных. + +``` text +Row 1: +────── +trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE +_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb +_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb +_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE +_ZN2DB27AggregatingBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB28AsynchronousBlockInputStream9calculateEv +_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data +_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E +_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv +_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E +execute_native_thread_routine +start_thread +clone +``` + +## demangle {#demangle} + +Преобразует символ, который вы можете получить с помощью [addressstosymbol](#addresstosymbol) функция имя функции C++. + +**Синтаксис** + +``` sql +demangle(symbol) +``` + +**Параметры** + +- `symbol` ([Строка](../../sql-reference/functions/introspection.md)) - Символ из объектного файла. + +**Возвращаемое значение** + +- Имя функции C++. +- Пустая строка, если символ не является допустимым. + +Тип: [Строка](../../sql-reference/functions/introspection.md). + +**Пример** + +Включение функций самоанализа: + +``` sql +SET allow_introspection_functions=1 +``` + +Выбор первой строки из списка `trace_log` системная таблица: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +То `trace` поле содержит трассировку стека в момент выборки. + +Получение имени функции для одного адреса: + +``` sql +SELECT demangle(addressToSymbol(94138803686098)) \G +``` + +``` text +Row 1: +────── +demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +``` + +Применение функции ко всему стектрейсу: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions +FROM system.trace_log +LIMIT 1 +\G +``` + +Функция [arrayMap](higher-order-functions.md#higher_order_functions-array-map) позволяет обрабатывать каждый отдельный элемент массива `trace` с помощью функции `demangle`. + +``` text +Row 1: +────── +trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const +DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) +DB::AggregatingBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::AsynchronousBlockInputStream::calculate() +std::_Function_handler::_M_invoke(std::_Any_data const&) +ThreadPoolImpl::worker(std::_List_iterator) +ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const +ThreadPoolImpl::worker(std::_List_iterator) +execute_native_thread_routine +start_thread +clone +``` diff --git a/docs/ru/sql-reference/functions/ip-address-functions.md b/docs/ru/sql-reference/functions/ip-address-functions.md new file mode 100644 index 00000000000..6dd5a68adc5 --- /dev/null +++ b/docs/ru/sql-reference/functions/ip-address-functions.md @@ -0,0 +1,241 @@ +# Функции для работы с IP-адресами {#funktsii-dlia-raboty-s-ip-adresami} + +## IPv4NumToString(num) {#ipv4numtostringnum} + +Принимает число типа UInt32. Интерпретирует его, как IPv4-адрес в big endian. Возвращает строку, содержащую соответствующий IPv4-адрес в формате A.B.C.D (числа в десятичной форме через точки). + +## IPv4StringToNum(s) {#ipv4stringtonums} + +Функция, обратная к IPv4NumToString. Если IPv4 адрес в неправильном формате, то возвращает 0. + +## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} + +Похоже на IPv4NumToString, но вместо последнего октета используется xxx. + +Пример: + +``` sql +SELECT + IPv4NumToStringClassC(ClientIP) AS k, + count() AS c +FROM test.hits +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─k──────────────┬─────c─┐ +│ 83.149.9.xxx │ 26238 │ +│ 217.118.81.xxx │ 26074 │ +│ 213.87.129.xxx │ 25481 │ +│ 83.149.8.xxx │ 24984 │ +│ 217.118.83.xxx │ 22797 │ +│ 78.25.120.xxx │ 22354 │ +│ 213.87.131.xxx │ 21285 │ +│ 78.25.121.xxx │ 20887 │ +│ 188.162.65.xxx │ 19694 │ +│ 83.149.48.xxx │ 17406 │ +└────────────────┴───────┘ +``` + +В связи с тем, что использование xxx весьма необычно, это может быть изменено в дальнейшем. Вам не следует полагаться на конкретный вид этого фрагмента. + +### IPv6NumToString(x) {#ipv6numtostringx} + +Принимает значение типа FixedString(16), содержащее IPv6-адрес в бинарном виде. Возвращает строку, содержащую этот адрес в текстовом виде. +IPv6-mapped IPv4 адреса выводится в формате ::ffff:111.222.33.44. Примеры: + +``` sql +SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr +``` + +``` text +┌─addr─────────┐ +│ 2a02:6b8::11 │ +└──────────────┘ +``` + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ +│ 2a02:2168:aaa:bbbb::2 │ 24695 │ +│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ +│ 2a02:6b8:0:fff::ff │ 16389 │ +│ 2a01:4f8:111:6666::2 │ 16016 │ +│ 2a02:2168:888:222::1 │ 15896 │ +│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ +│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ +│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ +│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ +│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ +└─────────────────────────────────────────┴───────┘ +``` + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + +``` text +┌─IPv6NumToString(ClientIP6)─┬──────c─┐ +│ ::ffff:94.26.111.111 │ 747440 │ +│ ::ffff:37.143.222.4 │ 529483 │ +│ ::ffff:5.166.111.99 │ 317707 │ +│ ::ffff:46.38.11.77 │ 263086 │ +│ ::ffff:79.105.111.111 │ 186611 │ +│ ::ffff:93.92.111.88 │ 176773 │ +│ ::ffff:84.53.111.33 │ 158709 │ +│ ::ffff:217.118.11.22 │ 154004 │ +│ ::ffff:217.118.11.33 │ 148449 │ +│ ::ffff:217.118.11.44 │ 148243 │ +└────────────────────────────┴────────┘ +``` + +## IPv6StringToNum(s) {#ipv6stringtonums} + +Функция, обратная к IPv6NumToString. Если IPv6 адрес в неправильном формате, то возвращает строку из нулевых байт. +HEX может быть в любом регистре. + +## IPv4ToIPv6(x) {#ipv4toipv6x} + +Принимает число типа `UInt32`. Интерпретирует его, как IPv4-адрес в [big endian](https://en.wikipedia.org/wiki/Endianness). Возвращает значение `FixedString(16)`, содержащее адрес IPv6 в двоичном формате. Примеры: + +``` sql +SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr +``` + +``` text +┌─addr───────────────┐ +│ ::ffff:192.168.0.1 │ +└────────────────────┘ +``` + +## cutIPv6(x, bitsToCutForIPv6, bitsToCutForIPv4) {#cutipv6x-bitstocutforipv6-bitstocutforipv4} + +Принимает значение типа FixedString(16), содержащее IPv6-адрес в бинарном виде. Возвращает строку, содержащую адрес из указанного количества битов, удаленных в текстовом формате. Например: + +``` sql +WITH + IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, + IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 +SELECT + cutIPv6(ipv6, 2, 0), + cutIPv6(ipv4, 0, 2) +``` + +``` text +┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ +│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ +└─────────────────────────────────────┴─────────────────────┘ +``` + +## IPv4CIDRToRange(ipv4, Cidr), {#ipv4cidrtorangeipv4-cidr} + +Принимает на вход IPv4 и значение `UInt8`, содержащее [CIDR](https://ru.wikipedia.org/wiki/Бесклассовая_адресация). Возвращает кортеж с двумя IPv4, содержащими нижний и более высокий диапазон подсети. + +``` sql +SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) +``` + +``` text +┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ +│ ('192.168.0.0','192.168.255.255') │ +└────────────────────────────────────────────┘ +``` + +## IPv6CIDRToRange(ipv6, Cidr), {#ipv6cidrtorangeipv6-cidr} + +Принимает на вход IPv6 и значение `UInt8`, содержащее CIDR. Возвращает кортеж с двумя IPv6, содержащими нижний и более высокий диапазон подсети. + +``` sql +SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32) +``` + +``` text +┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ +│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ +└────────────────────────────────────────────────────────────────────────┘ +``` + +## toIPv4(string) {#toipv4string} + +Псевдоним функции `IPv4StringToNum()` которая принимает строку с адресом IPv4 и возвращает значение типа [IPv4](../../sql-reference/functions/ip-address-functions.md), которое равно значению, возвращаемому функцией `IPv4StringToNum()`. + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + toTypeName(IPv4StringToNum(IPv4_string)), + toTypeName(toIPv4(IPv4_string)) +``` + +``` text +┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ +│ UInt32 │ IPv4 │ +└──────────────────────────────────────────┴─────────────────────────────────┘ +``` + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + hex(IPv4StringToNum(IPv4_string)), + hex(toIPv4(IPv4_string)) +``` + +``` text +┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ +│ ABE1822D │ ABE1822D │ +└───────────────────────────────────┴──────────────────────────┘ +``` + +## toIPv6(string) {#toipv6string} + +Псевдоним функции `IPv6StringToNum()` которая принимает строку с адресом IPv6 и возвращает значение типа [IPv6](../../sql-reference/functions/ip-address-functions.md), которое равно значению, возвращаемому функцией `IPv6StringToNum()`. + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + toTypeName(IPv6StringToNum(IPv6_string)), + toTypeName(toIPv6(IPv6_string)) +``` + +``` text +┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ +│ FixedString(16) │ IPv6 │ +└──────────────────────────────────────────┴─────────────────────────────────┘ +``` + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + hex(IPv6StringToNum(IPv6_string)), + hex(toIPv6(IPv6_string)) +``` + +``` text +┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ +│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ +└───────────────────────────────────┴──────────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/ip_address_functions/) diff --git a/docs/ru/sql-reference/functions/json-functions.md b/docs/ru/sql-reference/functions/json-functions.md new file mode 100644 index 00000000000..1079702e709 --- /dev/null +++ b/docs/ru/sql-reference/functions/json-functions.md @@ -0,0 +1,292 @@ +# Функции для работы с JSON {#funktsii-dlia-raboty-s-json} + +В Яндекс.Метрике пользователями передаётся JSON в качестве параметров визитов. Для работы с таким JSON-ом, реализованы некоторые функции. (Хотя в большинстве случаев, JSON-ы дополнительно обрабатываются заранее, и полученные значения кладутся в отдельные столбцы в уже обработанном виде.) Все эти функции исходят из сильных допущений о том, каким может быть JSON, и при этом стараются почти ничего не делать. + +Делаются следующие допущения: + +1. Имя поля (аргумент функции) должно быть константой; +2. Считается, что имя поля в JSON-е закодировано некоторым каноническим образом. Например, `visitParamHas('{"abc":"def"}', 'abc') = 1`, но `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` +3. Поля ищутся на любом уровне вложенности, без разбора. Если есть несколько подходящих полей - берётся первое. +4. В JSON-е нет пробельных символов вне строковых литералов. + +## visitParamHas(params, name) {#visitparamhasparams-name} + +Проверить наличие поля с именем name. + +## visitParamExtractUInt(params, name) {#visitparamextractuintparams-name} + +Распарсить UInt64 из значения поля с именем name. Если поле строковое - попытаться распарсить число из начала строки. Если такого поля нет, или если оно есть, но содержит не число, то вернуть 0. + +## visitParamExtractInt(params, name) {#visitparamextractintparams-name} + +Аналогично для Int64. + +## visitParamExtractFloat(params, name) {#visitparamextractfloatparams-name} + +Аналогично для Float64. + +## visitParamExtractBool(params, name) {#visitparamextractboolparams-name} + +Распарсить значение true/false. Результат - UInt8. + +## visitParamExtractRaw(params, name) {#visitparamextractrawparams-name} + +Вернуть значение поля, включая разделители. + +Примеры: + +``` sql +visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' +visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' +``` + +## visitParamExtractString(params, name) {#visitparamextractstringparams-name} + +Распарсить строку в двойных кавычках. У значения убирается экранирование. Если убрать экранированные символы не удалось, то возвращается пустая строка. + +Примеры: + +``` sql +visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' +visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' +visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' +visitParamExtractString('{"abc":"hello}', 'abc') = '' +``` + +На данный момент, не поддерживаются записанные в формате `\uXXXX\uYYYY` кодовые точки не из basic multilingual plane (они переводятся не в UTF-8, а в CESU-8). + +Следующие функции используют [simdjson](https://github.com/lemire/simdjson) который разработан под более сложные требования для разбора JSON. Упомянутое выше предположение 2 по-прежнему применимо. + +## isValidJSON(json) {#isvalidjsonjson} + +Проверяет, является ли переданная строка валидным json значением. + +Примеры: + +``` sql +SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 +SELECT isValidJSON('not a json') = 0 +``` + +## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} + +Если значение существует в документе JSON, то возвращается `1`. + +Если значение не существует, то возвращается `0`. + +Примеры: + +``` sql +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 +``` + +`indices_or_keys` — это список из нуля или более аргументов каждый из них может быть либо строкой либо целым числом. + +- Строка — это доступ к объекту по ключу. +- Положительное целое число — это доступ к n-му члену/ключу с начала. +- Отрицательное целое число — это доступ к n-му члену/ключу с конца. + +Адресация элементов по индексу начинается с 1, следовательно элемент 0 не существует. + +Вы можете использовать целые числа, чтобы адресовать как массивы JSON, так и JSON-объекты. + +Примеры: + +``` sql +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' +SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' +``` + +## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} + +Возвращает длину массива JSON или объекта JSON. + +Если значение не существует или имеет неверный тип, то возвращается `0`. + +Примеры: + +``` sql +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 +``` + +## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} + +Возвращает тип значения JSON. + +Если значение не существует, то возвращается `Null`. + +Примеры: + +``` sql +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' +``` + +## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} + +## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} + +## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} + +## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} + +Парсит JSON и извлекает значение. Эти функции аналогичны функциям `visitParam`. + +Если значение не существует или имеет неверный тип, то возвращается `0`. + +Примеры: + +``` sql +SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 +SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 +SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 +``` + +## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} + +Парсит JSON и извлекает строку. Эта функция аналогична функции `visitParamExtractString`. + +Если значение не существует или имеет неверный тип, то возвращается пустая строка. + +У значения убирается экранирование. Если убрать экранированные символы не удалось, то возвращается пустая строка. + +Примеры: + +``` sql +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' +SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' +SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' +SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' +SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' +``` + +## JSONExtract(json\[, indices\_or\_keys…\], Return\_type) {#jsonextractjson-indices-or-keys-return-type} + +Парсит JSON и извлекает значение с заданным типом данных. + +Это обобщение предыдущих функций `JSONExtract`. +Это означает +`JSONExtract(..., 'String')` выдает такой же результат, как `JSONExtractString()`, +`JSONExtract(..., 'Float64')` выдает такой же результат, как `JSONExtractFloat()`. + +Примеры: + +``` sql +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL +SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 +SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' +SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' +``` + +## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], Value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} + +Разбор пар ключ-значение из JSON, где значение имеет тип данных ClickHouse. + +Пример: + +``` sql +SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; +``` + +## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} + +Возвращает часть JSON в виде строки, содержащей неразобранную подстроку. + +Если значение не существует, то возвращается пустая строка. + +Пример: + +``` sql +SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' +``` + +## JSONExtractArrayRaw(json\[, indices\_or\_keys\]…) {#jsonextractarrayrawjson-indices-or-keys} + +Возвращает массив из элементов JSON массива, каждый из которых представлен в виде строки с неразобранными подстроками из JSON. + +Если значение не существует или не является массивом, то возвращается пустой массив. + +Пример: + +``` sql +SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' +``` + +## JSONExtractKeysAndValuesRaw {#json-extract-keys-and-values-raw} + +Извлекает необработанные данные из объекта JSON. + +**Синтаксис** + +``` sql +JSONExtractKeysAndValuesRaw(json[, p, a, t, h]) +``` + +**Параметры** + +- `json` — [Строка](../data-types/string.md), содержащая валидный JSON. +- `p, a, t, h` — Индексы или ключи, разделенные запятыми, которые указывают путь к внутреннему полю во вложенном объекте JSON. Каждый аргумент может быть либо [строкой](../data-types/string.md) для получения поля по ключу, либо [целым числом](../data-types/int-uint.md) для получения N-го поля (индексирование начинается с 1, отрицательные числа используются для отсчета с конца). Если параметр не задан, весь JSON парсится как объект верхнего уровня. Необязательный параметр. + +**Возвращаемые значения** + +- Массив с кортежами `('key', 'value')`. Члены кортежа — строки. + +- Пустой массив, если заданный объект не существует или входные данные не валидный JSON. + +Тип: Type: [Array](../data-types/array.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md), [String](../data-types/string.md)). +. + +**Примеры** + +Запрос: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}') +``` + +Ответ: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}')─┐ +│ [('a','[-100,200]'),('b','{"c":{"d":"hello","f":"world"}}')] │ +└──────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b') +``` + +Ответ: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b')─┐ +│ [('c','{"d":"hello","f":"world"}')] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c') +``` + +Ответ: + +``` text +┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c')─┐ +│ [('d','"hello"'),('f','"world"')] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/json_functions/) diff --git a/docs/ru/sql_reference/functions/logical_functions.md b/docs/ru/sql-reference/functions/logical-functions.md similarity index 100% rename from docs/ru/sql_reference/functions/logical_functions.md rename to docs/ru/sql-reference/functions/logical-functions.md diff --git a/docs/ru/sql-reference/functions/machine-learning-functions.md b/docs/ru/sql-reference/functions/machine-learning-functions.md new file mode 100644 index 00000000000..11d6c0f7230 --- /dev/null +++ b/docs/ru/sql-reference/functions/machine-learning-functions.md @@ -0,0 +1,13 @@ +# Функции машинного обучения {#funktsii-mashinnogo-obucheniia} + +## evalMLMethod (prediction) {#machine_learning_methods-evalmlmethod} + +Предсказание с использованием подобранных регрессионных моделей. + +### Stochastic Linear Regression {#stochastic-linear-regression} + +Агрегатная функция [stochasticLinearRegression](../../sql-reference/functions/machine-learning-functions.md#agg_functions-stochasticlinearregression) реализует стохастический градиентный спуск, использую линейную модель и функцию потерь MSE. + +### Stochastic Logistic Regression {#stochastic-logistic-regression} + +Агрегатная функция [stochasticLogisticRegression](../../sql-reference/functions/machine-learning-functions.md#agg_functions-stochasticlogisticregression) реализует стохастический градиентный спуск для задачи бинарной классификации. diff --git a/docs/ru/sql_reference/functions/math_functions.md b/docs/ru/sql-reference/functions/math-functions.md similarity index 100% rename from docs/ru/sql_reference/functions/math_functions.md rename to docs/ru/sql-reference/functions/math-functions.md diff --git a/docs/ru/sql-reference/functions/other-functions.md b/docs/ru/sql-reference/functions/other-functions.md new file mode 100644 index 00000000000..2c715cd15a5 --- /dev/null +++ b/docs/ru/sql-reference/functions/other-functions.md @@ -0,0 +1,1156 @@ +# Прочие функции {#prochie-funktsii} + +## hostName() {#hostname} + +Возвращает строку - имя хоста, на котором эта функция была выполнена. При распределённой обработке запроса, это будет имя хоста удалённого сервера, если функция выполняется на удалённом сервере. + +## getMacro {#getmacro} + +Возвращает именованное значение из секции [macros](../../operations/server-configuration-parameters/settings.md#macros) конфигурации сервера. + +**Синтаксис** + +```sql +getMacro(name); +``` + +**Параметры** + +- `name` — Имя, которое необходимо получить из секции `macros`. [String](../../sql-reference/data-types/string.md#string). + +**Возвращаемое значение** + +- Значение по указанному имени. + +Тип: [String](../../sql-reference/data-types/string.md). + +**Пример** + +Пример секции `macros` в конфигурационном файле сервера: + +```xml + + Value + +``` + +Запрос: + +```sql +SELECT getMacro('test'); +``` + +Результат: + +```text +┌─getMacro('test')─┐ +│ Value │ +└──────────────────┘ +``` + +Альтернативный способ получения значения: + +```sql +SELECT * FROM system.macros +WHERE macro = 'test' +``` + +```text +┌─macro─┬─substitution─┐ +│ test │ Value │ +└───────┴──────────────┘ +``` + + +## FQDN {#fqdn} + +Возвращает полное имя домена. + +**Синтаксис** + +``` sql +fqdn(); +``` + +Эта функция регистронезависимая. + +**Возвращаемое значение** + +- Полное имя домена. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT FQDN(); +``` + +Ответ: + +``` text +┌─FQDN()──────────────────────────┐ +│ clickhouse.ru-central1.internal │ +└─────────────────────────────────┘ +``` + +## basename {#basename} + +Извлекает конечную часть строки после последнего слэша или бэкслэша. Функция часто используется для извлечения имени файла из пути. + +``` sql +basename( expr ) +``` + +**Параметры** + +- `expr` — Выражение, возвращающее значение типа [String](../../sql-reference/functions/other-functions.md). В результирующем значении все бэкслэши должны быть экранированы. + +**Возвращаемое значение** + +Строка, содержащая: + +- Конечную часть строки после последнего слэша или бэкслэша. + + Если входная строка содержит путь, заканчивающийся слэшем или бэкслэшем, например, `/` или `с:\`, функция возвращает пустую строку. + +- Исходная строка, если нет слэша или бэкслэша. + +**Пример** + +``` sql +SELECT 'some/long/path/to/file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some\\long\\path\\to\\file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some-file-name' AS a, basename(a) +``` + +``` text +┌─a──────────────┬─basename('some-file-name')─┐ +│ some-file-name │ some-file-name │ +└────────────────┴────────────────────────────┘ +``` + +## visibleWidth(x) {#visiblewidthx} + +Вычисляет приблизительную ширину при выводе значения в текстовом (tab-separated) виде на консоль. +Функция используется системой для реализации Pretty форматов. + +`NULL` представляется как строка, соответствующая отображению `NULL` в форматах `Pretty`. + +``` sql +SELECT visibleWidth(NULL) +``` + +``` text +┌─visibleWidth(NULL)─┐ +│ 4 │ +└────────────────────┘ +``` + +## toTypeName(x) {#totypenamex} + +Возвращает строку, содержащую имя типа переданного аргумента. + +Если на вход функции передать `NULL`, то она вернёт тип `Nullable(Nothing)`, что соответствует внутреннему представлению `NULL` в ClickHouse. + +## blockSize() {#function-blocksize} + +Получить размер блока. +В ClickHouse выполнение запроса всегда идёт по блокам (наборам кусочков столбцов). Функция позволяет получить размер блока, для которого её вызвали. + +## materialize(x) {#materializex} + +Превращает константу в полноценный столбец, содержащий только одно значение. +В ClickHouse полноценные столбцы и константы представлены в памяти по-разному. Функции по-разному работают для аргументов-констант и обычных аргументов (выполняется разный код), хотя результат почти всегда должен быть одинаковым. Эта функция предназначена для отладки такого поведения. + +## ignore(…) {#ignore} + +Принимает любые аргументы, в т.ч. `NULL`, всегда возвращает 0. +При этом, аргумент всё равно вычисляется. Это может использоваться для бенчмарков. + +## sleep(seconds) {#sleepseconds} + +Спит seconds секунд на каждый блок данных. Можно указать как целое число, так и число с плавающей запятой. + +## currentDatabase() {#currentdatabase} + +Возвращает имя текущей базы данных. +Эта функция может использоваться в параметрах движка таблицы в запросе CREATE TABLE там, где нужно указать базу данных. + +## currentUser() {#other-function-currentuser} + +Возвращает логин текущего пользователя. При распределенном запросе, возвращается имя пользователя, инициировавшего запрос. + +``` sql +SELECT currentUser(); +``` + +Алиас: `user()`, `USER()`. + +**Возвращаемые значения** + +- Логин текущего пользователя. +- При распределенном запросе — логин пользователя, инициировавшего запрос. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT currentUser(); +``` + +Ответ: + +``` text +┌─currentUser()─┐ +│ default │ +└───────────────┘ +``` + +## isConstant {#is-constant} + +Проверяет, является ли аргумент константным выражением. + +Константное выражение — это выражение, результат которого известен на момент анализа запроса (до его выполнения). Например, выражения над [литералами](../syntax.md#literals) являются константными. + +Используется в целях разработки, отладки или демонстрирования. + +**Синтаксис** + +``` sql +isConstant(x) +``` + +**Параметры** + +- `x` — Выражение для проверки. + +**Возвращаемые значения** + +- `1` — Выражение `x` является константным. +- `0` — Выражение `x` не является константным. + +Тип: [UInt8](../data-types/int-uint.md). + +**Примеры** + +Запрос: + +```sql +SELECT isConstant(x + 1) FROM (SELECT 43 AS x) +``` + +Результат: + +```text +┌─isConstant(plus(x, 1))─┐ +│ 1 │ +└────────────────────────┘ +``` + +Запрос: + +```sql +WITH 3.14 AS pi SELECT isConstant(cos(pi)) +``` + +Результат: + +```text +┌─isConstant(cos(pi))─┐ +│ 1 │ +└─────────────────────┘ +``` + +Запрос: + +```sql +SELECT isConstant(number) FROM numbers(1) +``` + +Результат: + +```text +┌─isConstant(number)─┐ +│ 0 │ +└────────────────────┘ +``` + +## isFinite(x) {#isfinitex} + +Принимает Float32 или Float64 и возвращает UInt8, равный 1, если аргумент не бесконечный и не NaN, иначе 0. + +## ifNotFinite {#ifnotfinite} + +Проверяет, является ли значение дробного числа с плавающей точкой конечным. + +**Синтаксис** + + ifNotFinite(x,y) + +**Параметры** + +- `x` — Значение, которое нужно проверить на бесконечность. Тип: [Float\*](../../sql-reference/functions/other-functions.md). +- `y` — Запасное значение. Тип: [Float\*](../../sql-reference/functions/other-functions.md). + +**Возвращаемые значения** + +- `x`, если `x` принимает конечное значение. +- `y`, если`x` принимает не конечное значение. + +**Пример** + +Запрос: + + SELECT 1/0 as infimum, ifNotFinite(infimum,42) + +Результат: + + ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ + │ inf │ 42 │ + └─────────┴───────────────────────────────┘ + +Аналогичный результат можно получить с помощью [тернарного оператора](conditional-functions.md#ternary-operator) `isFinite(x) ? x : y`. + +## isInfinite(x) {#isinfinitex} + +Принимает Float32 или Float64 и возвращает UInt8, равный 1, если аргумент бесконечный, иначе 0. Отметим, что в случае NaN возвращается 0. + +## isNaN(x) {#isnanx} + +Принимает Float32 или Float64 и возвращает UInt8, равный 1, если аргумент является NaN, иначе 0. + +## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} + +Принимает константные строки - имя базы данных, имя таблицы и название столбца. Возвращает константное выражение типа UInt8, равное 1, +если есть столбец, иначе 0. Если задан параметр hostname, проверка будет выполнена на удалённом сервере. +Функция кидает исключение, если таблица не существует. +Для элементов вложенной структуры данных функция проверяет существование столбца. Для самой же вложенной структуры данных функция возвращает 0. + +## bar {#function-bar} + +Позволяет построить unicode-art диаграмму. + +`bar(x, min, max, width)` рисует полосу ширины пропорциональной `(x - min)` и равной `width` символов при `x = max`. + +Параметры: + +- `x` — Величина для отображения. +- `min, max` — Целочисленные константы, значение должно помещаться в `Int64`. +- `width` — Константа, положительное число, может быть дробным. + +Полоса рисуется с точностью до одной восьмой символа. + +Пример: + +``` sql +SELECT + toHour(EventTime) AS h, + count() AS c, + bar(c, 0, 600000, 20) AS bar +FROM test.hits +GROUP BY h +ORDER BY h ASC +``` + +``` text +┌──h─┬──────c─┬─bar────────────────┐ +│ 0 │ 292907 │ █████████▋ │ +│ 1 │ 180563 │ ██████ │ +│ 2 │ 114861 │ ███▋ │ +│ 3 │ 85069 │ ██▋ │ +│ 4 │ 68543 │ ██▎ │ +│ 5 │ 78116 │ ██▌ │ +│ 6 │ 113474 │ ███▋ │ +│ 7 │ 170678 │ █████▋ │ +│ 8 │ 278380 │ █████████▎ │ +│ 9 │ 391053 │ █████████████ │ +│ 10 │ 457681 │ ███████████████▎ │ +│ 11 │ 493667 │ ████████████████▍ │ +│ 12 │ 509641 │ ████████████████▊ │ +│ 13 │ 522947 │ █████████████████▍ │ +│ 14 │ 539954 │ █████████████████▊ │ +│ 15 │ 528460 │ █████████████████▌ │ +│ 16 │ 539201 │ █████████████████▊ │ +│ 17 │ 523539 │ █████████████████▍ │ +│ 18 │ 506467 │ ████████████████▊ │ +│ 19 │ 520915 │ █████████████████▎ │ +│ 20 │ 521665 │ █████████████████▍ │ +│ 21 │ 542078 │ ██████████████████ │ +│ 22 │ 493642 │ ████████████████▍ │ +│ 23 │ 400397 │ █████████████▎ │ +└────┴────────┴────────────────────┘ +``` + +## transform {#transform} + +Преобразовать значение согласно явно указанному отображению одних элементов на другие. +Имеется два варианта функции: + +### transform(x, array\_from, array\_to, default) {#transformx-array-from-array-to-default} + +`x` - что преобразовывать. + +`array_from` - константный массив значений для преобразования. + +`array_to` - константный массив значений, в которые должны быть преобразованы значения из from. + +`default` - какое значение использовать, если x не равен ни одному из значений во from. + +`array_from` и `array_to` - массивы одинаковых размеров. + +Типы: + +`transform(T, Array(T), Array(U), U) -> U` + +`T` и `U` - могут быть числовыми, строковыми, или Date или DateTime типами. +При этом, где обозначена одна и та же буква (T или U), могут быть, в случае числовых типов, не совпадающие типы, а типы, для которых есть общий тип. +Например, первый аргумент может иметь тип Int64, а второй - Array(UInt16). + +Если значение x равно одному из элементов массива array\_from, то возвращает соответствующий (такой же по номеру) элемент массива array\_to; иначе возвращает default. Если имеется несколько совпадающих элементов в array\_from, то возвращает какой-нибудь из соответствующих. + +Пример: + +``` sql +SELECT + transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, + count() AS c +FROM test.hits +WHERE SearchEngineID != 0 +GROUP BY title +ORDER BY c DESC +``` + +``` text +┌─title─────┬──────c─┐ +│ Yandex │ 498635 │ +│ Google │ 229872 │ +│ Other │ 104472 │ +└───────────┴────────┘ +``` + +### transform(x, array\_from, array\_to) {#transformx-array-from-array-to} + +Отличается от первого варианта отсутствующим аргументом default. +Если значение x равно одному из элементов массива array\_from, то возвращает соответствующий (такой же по номеру) элемент массива array\_to; иначе возвращает x. + +Типы: + +`transform(T, Array(T), Array(T)) -> T` + +Пример: + +``` sql +SELECT + transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, + count() AS c +FROM test.hits +GROUP BY domain(Referer) +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +┌─s──────────────┬───────c─┐ +│ │ 2906259 │ +│ www.yandex │ 867767 │ +│ ███████.ru │ 313599 │ +│ mail.yandex.ru │ 107147 │ +│ ██████.ru │ 100355 │ +│ █████████.ru │ 65040 │ +│ news.yandex.ru │ 64515 │ +│ ██████.net │ 59141 │ +│ example.com │ 57316 │ +└────────────────┴─────────┘ +``` + +## formatReadableSize(x) {#formatreadablesizex} + +Принимает размер (число байт). Возвращает округленный размер с суффиксом (KiB, MiB и т.д.) в виде строки. + +Пример: + +``` sql +SELECT + arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, + formatReadableSize(filesize_bytes) AS filesize +``` + +``` text +┌─filesize_bytes─┬─filesize───┐ +│ 1 │ 1.00 B │ +│ 1024 │ 1.00 KiB │ +│ 1048576 │ 1.00 MiB │ +│ 192851925 │ 183.92 MiB │ +└────────────────┴────────────┘ +``` + +## least(a, b) {#leasta-b} + +Возвращает наименьшее значение из a и b. + +## greatest(a, b) {#greatesta-b} + +Возвращает наибольшее значение из a и b. + +## uptime() {#uptime} + +Возвращает аптайм сервера в секундах. + +## version() {#version} + +Возвращает версию сервера в виде строки. + +## rowNumberInBlock {#function-rownumberinblock} + +Возвращает порядковый номер строки в блоке данных. Для каждого блока данных нумерация начинается с 0. + +## rowNumberInAllBlocks() {#rownumberinallblocks} + +Возвращает порядковый номер строки в блоке данных. Функция учитывает только задействованные блоки данных. + +## neighbor {#neighbor} + +Функция позволяет получить доступ к значению в колонке `column`, находящемуся на смещении `offset` относительно текущей строки. Является частичной реализацией [оконных функций](https://en.wikipedia.org/wiki/SQL_window_function) `LEAD()` и `LAG()`. + +**Синтаксис** + +``` sql +neighbor(column, offset[, default_value]) +``` + +Результат функции зависит от затронутых блоков данных и порядка данных в блоке. Если сделать подзапрос с ORDER BY и вызывать функцию извне подзапроса, можно будет получить ожидаемый результат. + +**Параметры** + +- `column` — Имя столбца или скалярное выражение. +- `offset` - Смещение от текущей строки `column`. [Int64](../../sql-reference/functions/other-functions.md). +- `default_value` - Опциональный параметр. Значение, которое будет возвращено, если смещение выходит за пределы блока данных. + +**Возвращаемое значение** + +- Значение `column` в смещении от текущей строки, если значение `offset` не выходит за пределы блока. +- Значение по умолчанию для `column`, если значение `offset` выходит за пределы блока данных. Если передан параметр `default_value`, то значение берется из него. + +Тип: зависит от данных в `column` или переданного значения по умолчанию в `default_value`. + +**Пример** + +Запрос: + +``` sql +SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; +``` + +Ответ: + +``` text +┌─number─┬─neighbor(number, 2)─┐ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +│ 4 │ 6 │ +│ 5 │ 7 │ +│ 6 │ 8 │ +│ 7 │ 9 │ +│ 8 │ 0 │ +│ 9 │ 0 │ +└────────┴─────────────────────┘ +``` + +Запрос: + +``` sql +SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; +``` + +Ответ: + +``` text +┌─number─┬─neighbor(number, 2, 999)─┐ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +│ 4 │ 6 │ +│ 5 │ 7 │ +│ 6 │ 8 │ +│ 7 │ 9 │ +│ 8 │ 999 │ +│ 9 │ 999 │ +└────────┴──────────────────────────┘ +``` + +Эта функция может использоваться для оценки year-over-year значение показателя: + +Запрос: + +``` sql +WITH toDate('2018-01-01') AS start_date +SELECT + toStartOfMonth(start_date + (number * 32)) AS month, + toInt32(month) % 100 AS money, + neighbor(money, -12) AS prev_year, + round(prev_year / money, 2) AS year_over_year +FROM numbers(16) +``` + +Ответ: + +``` text +┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ +│ 2018-01-01 │ 32 │ 0 │ 0 │ +│ 2018-02-01 │ 63 │ 0 │ 0 │ +│ 2018-03-01 │ 91 │ 0 │ 0 │ +│ 2018-04-01 │ 22 │ 0 │ 0 │ +│ 2018-05-01 │ 52 │ 0 │ 0 │ +│ 2018-06-01 │ 83 │ 0 │ 0 │ +│ 2018-07-01 │ 13 │ 0 │ 0 │ +│ 2018-08-01 │ 44 │ 0 │ 0 │ +│ 2018-09-01 │ 75 │ 0 │ 0 │ +│ 2018-10-01 │ 5 │ 0 │ 0 │ +│ 2018-11-01 │ 36 │ 0 │ 0 │ +│ 2018-12-01 │ 66 │ 0 │ 0 │ +│ 2019-01-01 │ 97 │ 32 │ 0.33 │ +│ 2019-02-01 │ 28 │ 63 │ 2.25 │ +│ 2019-03-01 │ 56 │ 91 │ 1.62 │ +│ 2019-04-01 │ 87 │ 22 │ 0.25 │ +└────────────┴───────┴───────────┴────────────────┘ +``` + +## runningDifference(x) {#runningdifferencex} + +Считает разницу между последовательными значениями строк в блоке данных. +Возвращает 0 для первой строки и разницу с предыдущей строкой для каждой последующей строки. + +Результат функции зависит от затронутых блоков данных и порядка данных в блоке. +Если сделать подзапрос с ORDER BY и вызывать функцию извне подзапроса, можно будет получить ожидаемый результат. + +Пример: + +``` sql +SELECT + EventID, + EventTime, + runningDifference(EventTime) AS delta +FROM +( + SELECT + EventID, + EventTime + FROM events + WHERE EventDate = '2016-11-24' + ORDER BY EventTime ASC + LIMIT 5 +) +``` + +``` text +┌─EventID─┬───────────EventTime─┬─delta─┐ +│ 1106 │ 2016-11-24 00:00:04 │ 0 │ +│ 1107 │ 2016-11-24 00:00:05 │ 1 │ +│ 1108 │ 2016-11-24 00:00:05 │ 0 │ +│ 1109 │ 2016-11-24 00:00:09 │ 4 │ +│ 1110 │ 2016-11-24 00:00:10 │ 1 │ +└─────────┴─────────────────────┴───────┘ +``` + +Обратите внимание — размер блока влияет на результат. С каждым новым блоком состояние `runningDifference` сбрасывается. + +``` sql +SELECT + number, + runningDifference(number + 1) AS diff +FROM numbers(100000) +WHERE diff != 1 +``` + +``` text +┌─number─┬─diff─┐ +│ 0 │ 0 │ +└────────┴──────┘ +┌─number─┬─diff─┐ +│ 65536 │ 0 │ +└────────┴──────┘ +``` + + set max_block_size=100000 -- по умолчанию 65536! + + SELECT + number, + runningDifference(number + 1) AS diff + FROM numbers(100000) + WHERE diff != 1 + +``` text +┌─number─┬─diff─┐ +│ 0 │ 0 │ +└────────┴──────┘ +``` + +## runningDifferenceStartingWithFirstValue {#runningdifferencestartingwithfirstvalue} + +То же, что и \[runningDifference\] (./other\_functions.md \# other\_functions-runningdifference), но в первой строке возвращается значение первой строки, а не ноль. + +## MACNumToString(num) {#macnumtostringnum} + +Принимает число типа UInt64. Интерпретирует его, как MAC-адрес в big endian. Возвращает строку, содержащую соответствующий MAC-адрес в формате AA:BB:CC:DD:EE:FF (числа в шестнадцатеричной форме через двоеточие). + +## MACStringToNum(s) {#macstringtonums} + +Функция, обратная к MACNumToString. Если MAC адрес в неправильном формате, то возвращает 0. + +## MACStringToOUI(s) {#macstringtoouis} + +Принимает MAC адрес в формате AA:BB:CC:DD:EE:FF (числа в шестнадцатеричной форме через двоеточие). Возвращает первые три октета как число в формате UInt64. Если MAC адрес в неправильном формате, то возвращает 0. + +## getSizeOfEnumType {#getsizeofenumtype} + +Возвращает количество полей в [Enum](../../sql-reference/functions/other-functions.md). + +``` sql +getSizeOfEnumType(value) +``` + +**Параметры** + +- `value` — Значение типа `Enum`. + +**Возвращаемые значения** + +- Количество полей входного значения типа `Enum`. +- Исключение, если тип не `Enum`. + +**Пример** + +``` sql +SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x +``` + +``` text +┌─x─┐ +│ 2 │ +└───┘ +``` + +## toColumnTypeName {#tocolumntypename} + +Возвращает имя класса, которым представлен тип данных столбца в оперативной памяти. + +``` sql +toColumnTypeName(value) +``` + +**Параметры** + +- `value` — Значение произвольного типа. + +**Возвращаемые значения** + +- Строка с именем класса, который используется для представления типа данных `value` в оперативной памяти. + +**Пример разницы между `toTypeName` и `toColumnTypeName`** + +``` sql +SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) +``` + +``` text +┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ DateTime │ +└─────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) +``` + +``` text +┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ Const(UInt32) │ +└───────────────────────────────────────────────────────────┘ +``` + +В примере видно, что тип данных `DateTime` хранится в памяти как `Const(UInt32)`. + +## dumpColumnStructure {#dumpcolumnstructure} + +Выводит развернутое описание структур данных в оперативной памяти + +``` sql +dumpColumnStructure(value) +``` + +**Параметры** + +- `value` — Значение произвольного типа. + +**Возвращаемые значения** + +- Строка с описанием структуры, которая используется для представления типа данных `value` в оперативной памяти. + +**Пример** + +``` sql +SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) +``` + +``` text +┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ +│ DateTime, Const(size = 1, UInt32(size = 1)) │ +└──────────────────────────────────────────────────────────────┘ +``` + +## defaultValueOfArgumentType {#defaultvalueofargumenttype} + +Выводит значение по умолчанию для типа данных. + +Не учитывает значения по умолчанию для столбцов, заданные пользователем. + +``` sql +defaultValueOfArgumentType(expression) +``` + +**Параметры** + +- `expression` — Значение произвольного типа или выражение, результатом которого является значение произвольного типа. + +**Возвращаемые значения** + +- `0` для чисел; +- Пустая строка для строк; +- `ᴺᵁᴸᴸ` для [Nullable](../../sql-reference/functions/other-functions.md). + +**Пример** + +``` sql +SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) +``` + +``` text +┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ +│ 0 │ +└─────────────────────────────────────────────┘ +``` + +``` sql +SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) +``` + +``` text +┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ +│ ᴺᵁᴸᴸ │ +└───────────────────────────────────────────────────────┘ +``` + +## replicate {#other-functions-replicate} + +Создает массив, заполненный одним значением. + +Используется для внутренней реализации [arrayJoin](array-join.md#functions_arrayjoin). + +``` sql +SELECT replicate(x, arr); +``` + +**Параметры** + +- `arr` — Исходный массив. ClickHouse создаёт новый массив такой же длины как исходный и заполняет его значением `x`. +- `x` — Значение, которым будет заполнен результирующий массив. + +**Возвращаемое значение** + +Массив, заполненный значением `x`. + +Тип: `Array`. + +**Пример** + +Запрос: + +``` sql +SELECT replicate(1, ['a', 'b', 'c']); +``` + +Ответ: + +``` text +┌─replicate(1, ['a', 'b', 'c'])─┐ +│ [1,1,1] │ +└───────────────────────────────┘ +``` + +## filesystemAvailable {#filesystemavailable} + +Возвращает объём доступного для записи данных места на файловой системе. Он всегда меньше общего свободного места ([filesystemFree](#filesystemfree)), потому что некоторое пространство зарезервировано для нужд операционной системы. + +**Синтаксис** + +``` sql +filesystemAvailable() +``` + +**Возвращаемое значение** + +- Объём доступного для записи данных места в байтах. + +Тип: [UInt64](../../sql-reference/functions/other-functions.md). + +**Пример** + +Запрос: + +``` sql +SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; +``` + +Ответ: + +``` text +┌─Available space─┬─Type───┐ +│ 30.75 GiB │ UInt64 │ +└─────────────────┴────────┘ +``` + +## filesystemFree {#filesystemfree} + +Возвращает объём свободного места на файловой системе. Смотрите также `filesystemAvailable`. + +**Синтаксис** + +``` sql +filesystemFree() +``` + +**Возвращаемое значение** + +- Объем свободного места в байтах. + +Тип: [UInt64](../../sql-reference/functions/other-functions.md). + +**Пример** + +Запрос: + +``` sql +SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; +``` + +Ответ: + +``` text +┌─Free space─┬─Type───┐ +│ 32.39 GiB │ UInt64 │ +└────────────┴────────┘ +``` + +## filesystemCapacity {#filesystemcapacity} + +Возвращает информацию о ёмкости файловой системы в байтах. Для оценки должен быть настроен [путь](../../sql-reference/functions/other-functions.md#server_configuration_parameters-path) к каталогу с данными. + +**Синтаксис** + +``` sql +filesystemCapacity() +``` + +**Возвращаемое значение** + +- Информация о ёмкости файловой системы в байтах. + +Тип: [UInt64](../../sql-reference/functions/other-functions.md). + +**Пример** + +Запрос: + +``` sql +SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" +``` + +Ответ: + +``` text +┌─Capacity──┬─Type───┐ +│ 39.32 GiB │ UInt64 │ +└───────────┴────────┘ +``` + +## finalizeAggregation {#function-finalizeaggregation} + +Принимает состояние агрегатной функции. Возвращает результат агрегирования. + +## runningAccumulate {#function-runningaccumulate} + +Принимает на вход состояния агрегатной функции и возвращает столбец со значениями, которые представляют собой результат мёржа этих состояний для выборки строк из блока от первой до текущей строки. Например, принимает состояние агрегатной функции (например, `runningAccumulate(uniqState(UserID))`), и для каждой строки блока возвращает результат агрегатной функции после мёржа состояний функции для всех предыдущих строк и текущей. Таким образом, результат зависит от разбиения данных по блокам и от порядка данных в блоке. + +## joinGet {#joinget} + +Функция позволяет извлекать данные из таблицы таким же образом как из [словаря](../../sql-reference/functions/other-functions.md). + +Получает данные из таблиц [Join](../../sql-reference/functions/other-functions.md#creating-a-table) по ключу. + +Поддерживаются только таблицы, созданные с `ENGINE = Join(ANY, LEFT, )`. + +**Синтаксис** + +``` sql +joinGet(join_storage_table_name, `value_column`, join_keys) +``` + +**Параметры** + +- `join_storage_table_name` — [идентификатор](../syntax.md#syntax-identifiers), который указывает, откуда производится выборка данных. Поиск по идентификатору осуществляется в базе данных по умолчанию (см. конфигурацию `default_database`). Чтобы переопределить базу данных по умолчанию, используйте команду `USE db_name`, или укажите базу данных и таблицу через разделитель `db_name.db_table`, см. пример. +- `value_column` — столбец, из которого нужно произвести выборку данных. +- `join_keys` — список ключей, по которым производится выборка данных. + +**Возвращаемое значение** + +Возвращает значение по списку ключей. + +Если значения не существует в исходной таблице, вернется `0` или `null` в соответствии с настройками [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls). + +Подробнее о настройке `join_use_nulls` в [операциях Join](../../sql-reference/functions/other-functions.md). + +**Пример** + +Входная таблица: + +``` sql +CREATE DATABASE db_test +CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 +INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) +``` + +``` text +┌─id─┬─val─┐ +│ 4 │ 13 │ +│ 2 │ 12 │ +│ 1 │ 11 │ +└────┴─────┘ +``` + +Запрос: + +``` sql +SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 +``` + +Результат: + +``` text +┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ +│ 0 │ +│ 11 │ +│ 12 │ +│ 0 │ +└──────────────────────────────────────────────────┘ +``` + +## modelEvaluate(model\_name, …) {#function-modelevaluate} + +Оценивает внешнюю модель. + +Принимает на вход имя и аргументы модели. Возвращает Float64. + +## throwIf(x\[, custom\_message\]) {#throwifx-custom-message} + +Бросает исключение, если аргумент не равен нулю. +custom\_message - необязательный параметр, константная строка, задает текст сообщения об ошибке. + +``` sql +SELECT throwIf(number = 3, 'Too many') FROM numbers(10); +``` + +``` text +↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): +Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. +``` + +## identity {#identity} + +Возвращает свой аргумент. Используется для отладки и тестирования, позволяет отменить использование индекса, и получить результат и производительность полного сканирования таблицы. Это работает, потому что оптимизатор запросов не может «заглянуть» внутрь функции `identity`. + +**Синтаксис** + +``` sql +identity(x) +``` + +**Пример** + +Query: + +``` sql +SELECT identity(42) +``` + +Результат: + +``` text +┌─identity(42)─┐ +│ 42 │ +└──────────────┘ +``` + +## randomPrintableASCII {#randomascii} + +Генерирует строку со случайным набором печатных символов [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters). + +**Синтаксис** + +``` sql +randomPrintableASCII(length) +``` + +**Параметры** + +- `length` — Длина результирующей строки. Положительное целое число. + + Если передать `length < 0`, то поведение функции не определено. + +**Возвращаемое значение** + +- Строка со случайным набором печатных символов [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters). + +Тип: [String](../../sql-reference/functions/other-functions.md) + +**Пример** + +``` sql +SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 +``` + +``` text +┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ +│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ +│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ +│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ +└────────┴────────────────────────────────┴──────────────────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/other_functions/) diff --git a/docs/ru/sql-reference/functions/random-functions.md b/docs/ru/sql-reference/functions/random-functions.md new file mode 100644 index 00000000000..b425505b69d --- /dev/null +++ b/docs/ru/sql-reference/functions/random-functions.md @@ -0,0 +1,58 @@ +# Функции генерации псевдослучайных чисел {#functions-for-generating-pseudo-random-numbers} + +Используются не криптографические генераторы псевдослучайных чисел. + +Все функции принимают ноль аргументов или один аргумент. +В случае, если передан аргумент - он может быть любого типа, и его значение никак не используется. +Этот аргумент нужен только для того, чтобы предотвратить склейку одинаковых выражений - чтобы две разные записи одной функции возвращали разные столбцы, с разными случайными числами. + +## rand {#rand} + +Возвращает псевдослучайное число типа UInt32, равномерно распределённое среди всех чисел типа UInt32. +Используется linear congruential generator. + +## rand64 {#rand64} + +Возвращает псевдослучайное число типа UInt64, равномерно распределённое среди всех чисел типа UInt64. +Используется linear congruential generator. + +## randConstant {#randconstant} + +Создает константный столбец с псевдослучайным значением. + +**Синтаксис** + +``` sql +randConstant([x]) +``` + +**Параметры** + +- `x` — [Выражение](../syntax.md#syntax-expressions), возвращающее значение одного из [поддерживаемых типов данных](../data-types/index.md#data_types). Значение используется, чтобы избежать [склейки одинаковых выражений](index.md#common-subexpression-elimination), если функция вызывается несколько раз в одном запросе. Необязательный параметр. + +**Возвращаемое значение** + +- Псевдослучайное число. + +Тип: [UInt32](../data-types/int-uint.md). + +**Пример** + +Запрос: + +``` sql +SELECT rand(), rand(1), rand(number), randConstant(), randConstant(1), randConstant(number) +FROM numbers(3) +``` + +Результат: + +``` text +┌─────rand()─┬────rand(1)─┬─rand(number)─┬─randConstant()─┬─randConstant(1)─┬─randConstant(number)─┐ +│ 3047369878 │ 4132449925 │ 4044508545 │ 2740811946 │ 4229401477 │ 1924032898 │ +│ 2938880146 │ 1267722397 │ 4154983056 │ 2740811946 │ 4229401477 │ 1924032898 │ +│ 956619638 │ 4238287282 │ 1104342490 │ 2740811946 │ 4229401477 │ 1924032898 │ +└────────────┴────────────┴──────────────┴────────────────┴─────────────────┴──────────────────────┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/random_functions/) diff --git a/docs/ru/sql-reference/functions/rounding-functions.md b/docs/ru/sql-reference/functions/rounding-functions.md new file mode 100644 index 00000000000..c643bccf3e2 --- /dev/null +++ b/docs/ru/sql-reference/functions/rounding-functions.md @@ -0,0 +1,175 @@ +# Функции округления {#funktsii-okrugleniia} + +## floor(x\[, N\]) {#floorx-n} + +Возвращает наибольшее круглое число, которое меньше или равно, чем x. +Круглым называется число, кратное 1 / 10N или ближайшее к нему число соответствующего типа данных, если 1 / 10N не представимо точно. +N - целочисленная константа, не обязательный параметр. По умолчанию - ноль, что означает - округлять до целого числа. +N может быть отрицательным. + +Примеры: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` + +`x` - любой числовой тип. Результат - число того же типа. +Для целочисленных аргументов имеет смысл округление с отрицательным значением N (для неотрицательных N, функция ничего не делает). +В случае переполнения при округлении (например, floor(-128, -1)), возвращается implementation specific результат. + +## ceil(x\[, N\]) {#ceilx-n} + +Возвращает наименьшее круглое число, которое больше или равно, чем x. +В остальном, аналогично функции floor, см. выше. + +## round(x\[, N\]) {#rounding_functions-round} + +Округляет значение до указанного десятичного разряда. + +Функция возвращает ближайшее значение указанного порядка. В случае, когда заданное число равноудалено от чисел необходимого порядка, функция возвращает то из них, которое имеет ближайшую чётную цифру (банковское округление). + +``` sql +round(expression [, decimal_places]) +``` + +**Параметры:** + +- `expression` — Число для округления. Может быть любым [выражением](../syntax.md#syntax-expressions), возвращающим числовой [тип данных](../../sql-reference/functions/rounding-functions.md#data_types). +- `decimal-places` — Целое значение. + - Если `decimal-places > 0`, то функция округляет значение справа от запятой. + - Если `decimal-places < 0` то функция округляет значение слева от запятой. + - Если `decimal-places = 0`, то функция округляет значение до целого. В этом случае аргумент можно опустить. + +**Возвращаемое значение:** + +Округлённое значение того же типа, что и входящее. + +### Примеры {#primery} + +**Пример использования** + +``` sql +SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 +``` + +``` text +┌───x─┬─round(divide(number, 2))─┐ +│ 0 │ 0 │ +│ 0.5 │ 0 │ +│ 1 │ 1 │ +└─────┴──────────────────────────┘ +``` + +**Примеры округления** + +Округление до ближайшего числа. + +``` text +round(3.2, 0) = 3 +round(4.1267, 2) = 4.13 +round(22,-1) = 20 +round(467,-2) = 500 +round(-467,-2) = -500 +``` + +Банковское округление. + +``` text +round(3.5) = 4 +round(4.5) = 4 +round(3.55, 1) = 3.6 +round(3.65, 1) = 3.6 +``` + +**Смотрите также** + +- [roundBankers](#roundbankers) + +## roundBankers {#roundbankers} + +Округляет число до указанного десятичного разряда. + +- Если округляемое число равноудалено от соседних чисел, то используется банковское округление. + + Банковское округление (англ. banker's rounding) — метод округления дробных чисел. Если округляемое число равноудалено от соседних чисел, то оно округляется до ближайшей чётной цифры заданного десятичного разряда. К примеру, 3,5 округляется до 4, а 2,5 до 2. + + Этот метод округления, используемый по умолчанию для чисел с плавающей запятой, определён в стандарте [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). Функция [round](#rounding_functions-round) также округляет числа с плавающей запятой по этому методу. Функция `roundBankers` округляет не только числа с плавающей запятой, но и целые числа методом банковского округления, например, `roundBankers(45, -1) = 40`. + +- В других случаях функция округляет к ближайшему целому. + +Банковское округление позволяет уменьшить влияние округления чисел на результат суммирования или вычитания этих чисел. + +Пример суммирования чисел 1.5, 2.5, 3.5 и 4.5 с различным округлением: + +- Без округления: 1.5 + 2.5 + 3.5 + 4.5 = 12. +- Банковское округление: 2 + 2 + 4 + 4 = 12. +- Округление до ближайшего целого: 2 + 3 + 4 + 5 = 14. + +**Синтаксис** + +``` sql +roundBankers(expression [, decimal_places]) +``` + +**Параметры** + +- `expression` — Число для округления. Может быть любым [выражением](../syntax.md#syntax-expressions), возвращающим числовой [тип данных](../../sql-reference/functions/rounding-functions.md#data_types). +- `decimal-places` — Десятичный разряд. Целое число. + - `decimal-places > 0` — Функция округляет значение выражения до ближайшего чётного числа на соответствующей позиции справа от запятой. Например, `roundBankers(3.55, 1) = 3.6`. + - `decimal-places < 0` — Функция округляет значение выражения до ближайшего чётного числа на соответствующей позиции слева от запятой. Например, `roundBankers(24.55, -1) = 20`. + - `decimal-places = 0` — Функция округляет значение до целого. В этом случае аргумент можно не передавать. Например, `roundBankers(2.5) = 2`. + +**Возвращаемое значение** + +Округлённое значение по методу банковского округления. + +**Пример использования** + +Запрос: + +``` sql + SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 +``` + +Результат: + +``` text +┌───x─┬─b─┐ +│ 0 │ 0 │ +│ 0.5 │ 0 │ +│ 1 │ 1 │ +│ 1.5 │ 2 │ +│ 2 │ 2 │ +│ 2.5 │ 2 │ +│ 3 │ 3 │ +│ 3.5 │ 4 │ +│ 4 │ 4 │ +│ 4.5 │ 4 │ +└─────┴───┘ +``` + +**Примеры банковского округления** + +``` text +roundBankers(0.4) = 0 +roundBankers(-3.5) = -4 +roundBankers(4.5) = 4 +roundBankers(3.55, 1) = 3.6 +roundBankers(3.65, 1) = 3.6 +roundBankers(10.35, 1) = 10.4 +roundBankers(10.755, 2) = 11,76 +``` + +**Смотрите также** + +- [round](#rounding_functions-round) + +## roundToExp2(num) {#roundtoexp2num} + +Принимает число. Если число меньше единицы - возвращает 0. Иначе округляет число вниз до ближайшей (целой неотрицательной) степени двух. + +## roundDuration(num) {#rounddurationnum} + +Принимает число. Если число меньше единицы - возвращает 0. Иначе округляет число вниз до чисел из набора: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. Эта функция специфична для Яндекс.Метрики и предназначена для реализации отчёта по длительности визита. + +## roundAge(num) {#roundagenum} + +Принимает число. Если число меньше 18 - возвращает 0. Иначе округляет число вниз до чисел из набора: 18, 25, 35, 45, 55. Эта функция специфична для Яндекс.Метрики и предназначена для реализации отчёта по возрасту посетителей. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/rounding_functions/) diff --git a/docs/ru/sql_reference/functions/splitting_merging_functions.md b/docs/ru/sql-reference/functions/splitting-merging-functions.md similarity index 100% rename from docs/ru/sql_reference/functions/splitting_merging_functions.md rename to docs/ru/sql-reference/functions/splitting-merging-functions.md diff --git a/docs/ru/sql-reference/functions/string-functions.md b/docs/ru/sql-reference/functions/string-functions.md new file mode 100644 index 00000000000..a9e254f215b --- /dev/null +++ b/docs/ru/sql-reference/functions/string-functions.md @@ -0,0 +1,482 @@ +# Функции для работы со строками {#funktsii-dlia-raboty-so-strokami} + +## empty {#empty} + +Возвращает 1 для пустой строки, и 0 для непустой строки. +Тип результата — UInt8. +Строка считается непустой, если содержит хотя бы один байт, пусть даже это пробел или нулевой байт. +Функция также работает для массивов. + +## notEmpty {#notempty} + +Возвращает 0 для пустой строки, и 1 для непустой строки. +Тип результата — UInt8. +Функция также работает для массивов. + +## length {#length} + +Возвращает длину строки в байтах (не символах, не кодовых точках). +Тип результата — UInt64. +Функция также работает для массивов. + +## lengthUTF8 {#lengthutf8} + +Возвращает длину строки в кодовых точках Unicode (не символах), при допущении, что строка содержит набор байтов, являющийся текстом в кодировке UTF-8. Если допущение не выполнено, то возвращает какой-нибудь результат (не кидает исключение). +Тип результата — UInt64. + +## char\_length, CHAR\_LENGTH {#char-length} + +Возвращает длину строки в кодовых точках Unicode (не символах), при допущении, что строка содержит набор байтов, являющийся текстом в кодировке UTF-8. Если допущение не выполнено, возвращает какой-нибудь результат (не кидает исключение). +Тип результата — UInt64. + +## character\_length, CHARACTER\_LENGTH {#character-length} + +Возвращает длину строки в кодовых точках Unicode (не символах), при допущении, что строка содержит набор байтов, являющийся текстом в кодировке UTF-8. Если допущение не выполнено, возвращает какой-нибудь результат (не кидает исключение). +Тип результата — UInt64. + +## lower, lcase {#lower} + +Переводит ASCII-символы латиницы в строке в нижний регистр. + +## upper, ucase {#upper} + +Переводит ASCII-символы латиницы в строке в верхний регистр. + +## lowerUTF8 {#lowerutf8} + +Переводит строку в нижний регистр, при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. +Не учитывает язык. То есть, для турецкого языка, результат может быть не совсем верным. +Если длина UTF-8 последовательности байтов различна для верхнего и нижнего регистра кодовой точки, то для этой кодовой точки результат работы может быть некорректным. +Если строка содержит набор байтов, не являющийся UTF-8, то поведение не определено. + +## upperUTF8 {#upperutf8} + +Переводит строку в верхний регистр, при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. +Не учитывает язык. То есть, для турецкого языка, результат может быть не совсем верным. +Если длина UTF-8 последовательности байтов различна для верхнего и нижнего регистра кодовой точки, то для этой кодовой точки, результат работы может быть некорректным. +Если строка содержит набор байтов, не являющийся UTF-8, то поведение не определено. + +## isValidUTF8 {#isvalidutf8} + +Возвращает 1, если набор байтов является корректным в кодировке UTF-8, 0 иначе. + +## toValidUTF8 {#tovalidutf8} + +Заменяет некорректные символы UTF-8 на символ `�` (U+FFFD). Все идущие подряд некорректные символы схлопываются в один заменяющий символ. + +``` sql +toValidUTF8( input_string ) +``` + +Параметры: + +- input\_string — произвольный набор байтов, представленный как объект типа [String](../../sql-reference/functions/string-functions.md). + +Возвращаемое значение: Корректная строка UTF-8. + +**Пример** + +``` sql +SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') +``` + +``` text +┌─toValidUTF8('a����b')─┐ +│ a�b │ +└───────────────────────┘ +``` + +## repeat {#repeat} + +Повторяет строку определенное количество раз и объединяет повторяемые значения в одну строку. + +**Синтаксис** + +``` sql +repeat(s, n) +``` + +**Параметры** + +- `s` — Строка для повторения. [String](../../sql-reference/functions/string-functions.md). +- `n` — Количество повторов. [UInt](../../sql-reference/functions/string-functions.md). + +**Возвращаемое значение** + +Строка, состоящая из повторений `n` раз исходной строки `s`. Если `n` \< 1, то функция вернет пустую строку. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT repeat('abc', 10) +``` + +Ответ: + +``` text +┌─repeat('abc', 10)──────────────┐ +│ abcabcabcabcabcabcabcabcabcabc │ +└────────────────────────────────┘ +``` + +## reverse {#reverse} + +Разворачивает строку (как последовательность байтов). + +## reverseUTF8 {#reverseutf8} + +Разворачивает последовательность кодовых точек Unicode, при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. Иначе — что-то делает (не кидает исключение). + +## format(pattern, s0, s1, …) {#format} + +Форматирует константный шаблон со строками, перечисленными в аргументах. `pattern` — упрощенная версия шаблона в языке Python. Шаблон содержит «заменяющие поля», которые окружены фигурными скобками `{}`. Всё, что не содержится в скобках, интерпретируется как обычный текст и просто копируется. Если нужно использовать символ фигурной скобки, можно экранировать двойной скобкой `{{ '{{' }}` или `{{ '}}' }}`. Имя полей могут быть числами (нумерация с нуля) или пустыми (тогда они интерпретируются как последовательные числа). + +``` sql +SELECT format('{1} {0} {1}', 'World', 'Hello') +``` + +``` text +┌─format('{1} {0} {1}', 'World', 'Hello')─┐ +│ Hello World Hello │ +└─────────────────────────────────────────┘ +``` + +``` sql +SELECT format('{} {}', 'Hello', 'World') +``` + +``` text +┌─format('{} {}', 'Hello', 'World')─┐ +│ Hello World │ +└───────────────────────────────────┘ +``` + +## concat {#concat} + +Склеивает строки, переданные в аргументы, в одну строку без разделителей. + +**Cинтаксис** + +``` sql +concat(s1, s2, ...) +``` + +**Параметры** + +Значения типа String или FixedString. + +**Возвращаемое значение** + +Возвращает строку, полученную в результате склейки аргументов. + +Если любой из аргументов имеет значение `NULL`, `concat` возвращает значение `NULL`. + +**Пример** + +Запрос: + +``` sql +SELECT concat('Hello, ', 'World!') +``` + +Ответ: + +``` text +┌─concat('Hello, ', 'World!')─┐ +│ Hello, World! │ +└─────────────────────────────┘ +``` + +## concatAssumeInjective {#concatassumeinjective} + +Аналогична [concat](#concat). Разница заключается в том, что вам нужно убедиться, что `concat(s1, s2, ...) → sn` является инъективным, так как это предположение будет использоваться для оптимизации GROUP BY. + +Функция называется «инъективной», если она возвращает разные значения для разных аргументов. Или, иными словами, функция никогда не выдаёт одно и то же значение, если аргументы разные. + +**Синтаксис** + +``` sql +concatAssumeInjective(s1, s2, ...) +``` + +**Параметры** + +Значения типа String или FixedString. + +**Возвращаемые значения** + +Возвращает строку, полученную в результате объединения аргументов. + +Если любой из аргументов имеет значение `NULL`, `concatAssumeInjective` возвращает значение `NULL`. + +**Пример** + +Вводная таблица: + +``` sql +CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog +INSERT INTO key_val VALUES ('Hello, ','World',1)('Hello, ','World',2)('Hello, ','World!',3)('Hello',', World!',2) +SELECT * from key_val +``` + +``` text +┌─key1────┬─key2─────┬─value─┐ +│ Hello, │ World │ 1 │ +│ Hello, │ World │ 2 │ +│ Hello, │ World! │ 3 │ +│ Hello │ , World! │ 2 │ +└─────────┴──────────┴───────┘ +``` + +Запрос: + +``` sql +SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY (key1, key2) +``` + +Ответ: + +``` text +┌─concat(key1, key2)─┬─sum(value)─┐ +│ Hello, World! │ 3 │ +│ Hello, World! │ 2 │ +│ Hello, World │ 3 │ +└────────────────────┴────────────┘ +``` + +## substring(s, offset, length), mid(s, offset, length), substr(s, offset, length) {#substring} + +Возвращает подстроку, начиная с байта по индексу offset, длины length байт. Индексация символов — начиная с единицы (как в стандартном SQL). Аргументы offset и length должны быть константами. + +## substringUTF8(s, offset, length) {#substringutf8} + +Так же, как substring, но для кодовых точек Unicode. Работает при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. Если допущение не выполнено, то возвращает какой-нибудь результат (не кидает исключение). + +## appendTrailingCharIfAbsent(s, c) {#appendtrailingcharifabsent} + +Если строка s непустая и не содержит символ c на конце, то добавляет символ c в конец. + +## convertCharset(s, from, to) {#convertcharset} + +Возвращает сконвертированную из кодировки from в кодировку to строку s. + +## base64Encode(s) {#base64encode} + +Производит кодирование строки s в base64-представление. + +## base64Decode(s) {#base64decode} + +Декодирует base64-представление s в исходную строку. При невозможности декодирования выбрасывает исключение + +## tryBase64Decode(s) {#trybase64decode} + +Функционал аналогичен base64Decode, но при невозможности декодирования возвращает пустую строку. + +## endsWith(s, suffix) {#endswith} + +Возвращает 1, если строка завершается указанным суффиксом, и 0 в противном случае. + +## startsWith(str, prefix) {#startswith} + +Возвращает 1, если строка начинается указанным префиксом, в противном случае 0. + +``` sql +SELECT startsWith('Spider-Man', 'Spi'); +``` + +**Возвращаемые значения** + +- 1, если строка начинается указанным префиксом. +- 0, если строка не начинается указанным префиксом. + +**Пример** + +Запрос: + +``` sql +SELECT startsWith('Hello, world!', 'He'); +``` + +Ответ: + +``` text +┌─startsWith('Hello, world!', 'He')─┐ +│ 1 │ +└───────────────────────────────────┘ +``` + +## trim {#trim} + +Удаляет все указанные символы с начала или окончания строки. +По умолчанию удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с обоих концов строки. + +**Синтаксис** + +``` sql +trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) +``` + +**Параметры** + +- `trim_character` — один или несколько символов, подлежащие удалению. [String](../../sql-reference/functions/string-functions.md). +- `input_string` — строка для обрезки. [String](../../sql-reference/functions/string-functions.md). + +**Возвращаемое значение** + +Исходную строку после обрезки с левого и (или) правого концов строки. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT trim(BOTH ' ()' FROM '( Hello, world! )') +``` + +Ответ: + +``` text +┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ +│ Hello, world! │ +└───────────────────────────────────────────────┘ +``` + +## trimLeft {#trimleft} + +Удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с левого конца строки. Не удаляет другие виды пробелов (табуляция, пробел без разрыва и т. д.). + +**Синтаксис** + +``` sql +trimLeft(input_string) +``` + +Алиас: `ltrim(input_string)`. + +**Параметры** + +- `input_string` — строка для обрезки. [String](../../sql-reference/functions/string-functions.md). + +**Возвращаемое значение** + +Исходную строку без общих пробельных символов слева. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT trimLeft(' Hello, world! ') +``` + +Ответ: + +``` text +┌─trimLeft(' Hello, world! ')─┐ +│ Hello, world! │ +└─────────────────────────────────────┘ +``` + +## trimRight {#trimright} + +Удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с правого конца строки. Не удаляет другие виды пробелов (табуляция, пробел без разрыва и т. д.). + +**Синтаксис** + +``` sql +trimRight(input_string) +``` + +Алиас: `rtrim(input_string)`. + +**Параметры** + +- `input_string` — строка для обрезки. [String](../../sql-reference/functions/string-functions.md). + +**Возвращаемое значение** + +Исходную строку без общих пробельных символов справа. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT trimRight(' Hello, world! ') +``` + +Ответ: + +``` text +┌─trimRight(' Hello, world! ')─┐ +│ Hello, world! │ +└──────────────────────────────────────┘ +``` + +## trimBoth {#trimboth} + +Удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с обоих концов строки. Не удаляет другие виды пробелов (табуляция, пробел без разрыва и т. д.). + +**Синтаксис** + +``` sql +trimBoth(input_string) +``` + +Алиас: `trim(input_string)`. + +**Параметры** + +- `input_string` — строка для обрезки. [String](../../sql-reference/functions/string-functions.md). + +**Возвращаемое значение** + +Исходную строку без общих пробельных символов с обоих концов строки. + +Тип: `String`. + +**Пример** + +Запрос: + +``` sql +SELECT trimBoth(' Hello, world! ') +``` + +Ответ: + +``` text +┌─trimBoth(' Hello, world! ')─┐ +│ Hello, world! │ +└─────────────────────────────────────┘ +``` + +## CRC32(s) {#crc32} + +Возвращает чексумму CRC32 данной строки, используется CRC-32-IEEE 802.3 многочлен и начальным значением `0xffffffff` (т.к. используется реализация из zlib). + +Тип результата — UInt32. + +## CRC32IEEE(s) {#crc32ieee} + +Возвращает чексумму CRC32 данной строки, используется CRC-32-IEEE 802.3 многочлен. + +Тип результата — UInt32. + +## CRC64(s) {#crc64} + +Возвращает чексумму CRC64 данной строки, используется CRC-64-ECMA многочлен. + +Тип результата — UInt64. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/string_functions/) diff --git a/docs/ru/sql_reference/functions/string_replace_functions.md b/docs/ru/sql-reference/functions/string-replace-functions.md similarity index 100% rename from docs/ru/sql_reference/functions/string_replace_functions.md rename to docs/ru/sql-reference/functions/string-replace-functions.md diff --git a/docs/ru/sql_reference/functions/string_search_functions.md b/docs/ru/sql-reference/functions/string-search-functions.md similarity index 100% rename from docs/ru/sql_reference/functions/string_search_functions.md rename to docs/ru/sql-reference/functions/string-search-functions.md diff --git a/docs/ru/sql-reference/functions/type-conversion-functions.md b/docs/ru/sql-reference/functions/type-conversion-functions.md new file mode 100644 index 00000000000..41ded78055c --- /dev/null +++ b/docs/ru/sql-reference/functions/type-conversion-functions.md @@ -0,0 +1,516 @@ +# Функции преобразования типов {#funktsii-preobrazovaniia-tipov} + +## Общие проблемы преобразования чисел {#numeric-conversion-issues} + +При преобразовании значения из одного типа в другой необходимо помнить, что в общем случае это небезопасная операция, которая может привести к потере данных. Потеря данных может произойти при попытке сконвертировать тип данных значения от большего к меньшему или при конвертировании между различными классами типов данных. + +Поведение ClickHouse при конвертировании похоже на [поведение C++ программ](https://en.cppreference.com/w/cpp/language/implicit_conversion). + +## toInt(8\|16\|32\|64) {#toint8163264} + +Преобразует входное значение к типу [Int](../../sql-reference/functions/type-conversion-functions.md). Семейство функций включает: + +- `toInt8(expr)` — возвращает значение типа `Int8`. +- `toInt16(expr)` — возвращает значение типа `Int16`. +- `toInt32(expr)` — возвращает значение типа `Int32`. +- `toInt64(expr)` — возвращает значение типа `Int64`. + +**Параметры** + +- `expr` — [выражение](../syntax.md#syntax-expressions) возвращающее число или строку с десятичным представление числа. Бинарное, восьмеричное и шестнадцатеричное представление числа не поддержаны. Ведущие нули обрезаются. + +**Возвращаемое значение** + +Целое число типа `Int8`, `Int16`, `Int32` или `Int64`. + +Функции используют [округление к нулю](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero), т.е. обрезают дробную часть числа. + +Поведение функций для аргументов [NaN и Inf](../../sql-reference/functions/type-conversion-functions.md#data_type-float-nan-inf) не определено. При использовании функций помните о возможных проблемах при [преобразовании чисел](#numeric-conversion-issues). + +**Пример** + +``` sql +SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) +``` + +``` text +┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ +│ -9223372036854775808 │ 32 │ 16 │ 8 │ +└──────────────────────┴─────────────┴───────────────┴─────────────┘ +``` + +## toInt(8\|16\|32\|64)OrZero {#toint8163264orzero} + +Принимает аргумент типа String и пытается его распарсить в Int(8\|16\|32\|64). Если не удалось - возвращает 0. + +**Пример** + +``` sql +select toInt64OrZero('123123'), toInt8OrZero('123qwe123') +``` + +``` text +┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ +│ 123123 │ 0 │ +└─────────────────────────┴───────────────────────────┘ +``` + +## toInt(8\|16\|32\|64)OrNull {#toint8163264ornull} + +Принимает аргумент типа String и пытается его распарсить в Int(8\|16\|32\|64). Если не удалось - возвращает NULL. + +**Пример** + +``` sql +select toInt64OrNull('123123'), toInt8OrNull('123qwe123') +``` + +``` text +┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ +│ 123123 │ ᴺᵁᴸᴸ │ +└─────────────────────────┴───────────────────────────┘ +``` + +## toUInt(8\|16\|32\|64) {#touint8163264} + +Преобраует входное значение к типу [UInt](../../sql-reference/functions/type-conversion-functions.md). Семейство функций включает: + +- `toUInt8(expr)` — возвращает значение типа `UInt8`. +- `toUInt16(expr)` — возвращает значение типа `UInt16`. +- `toUInt32(expr)` — возвращает значение типа `UInt32`. +- `toUInt64(expr)` — возвращает значение типа `UInt64`. + +**Параметры** + +- `expr` — [выражение](../syntax.md#syntax-expressions) возвращающее число или строку с десятичным представление числа. Бинарное, восьмеричное и шестнадцатеричное представление числа не поддержаны. Ведущие нули обрезаются. + +**Возвращаемое значение** + +Целое число типа `UInt8`, `UInt16`, `UInt32` или `UInt64`. + +Функции используют [округление к нулю](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero), т.е. обрезают дробную часть числа. + +Поведение функций для аргументов [NaN и Inf](../../sql-reference/functions/type-conversion-functions.md#data_type-float-nan-inf) не определено. Если передать строку, содержащую отрицательное число, например `'-32'`, ClickHouse генерирует исключение. При использовании функций помните о возможных проблемах при [преобразовании чисел](#numeric-conversion-issues). + +**Пример** + +``` sql +SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) +``` + +``` text +┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ +│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ +└─────────────────────┴───────────────┴────────────────┴──────────────┘ +``` + +## toUInt(8\|16\|32\|64)OrZero {#touint8163264orzero} + +## toUInt(8\|16\|32\|64)OrNull {#touint8163264ornull} + +## toFloat(32\|64) {#tofloat3264} + +## toFloat(32\|64)OrZero {#tofloat3264orzero} + +## toFloat(32\|64)OrNull {#tofloat3264ornull} + +## toDate {#todate} + +## toDateOrZero {#todateorzero} + +## toDateOrNull {#todateornull} + +## toDateTime {#todatetime} + +## toDateTimeOrZero {#todatetimeorzero} + +## toDateTimeOrNull {#todatetimeornull} + +## toDecimal(32\|64\|128) {#todecimal3264128} + +Преобразует `value` к типу данных [Decimal](../../sql-reference/functions/type-conversion-functions.md) с точностью `S`. `value` может быть числом или строкой. Параметр `S` (scale) задаёт число десятичных знаков. + +- `toDecimal32(value, S)` +- `toDecimal64(value, S)` +- `toDecimal128(value, S)` + +## toDecimal(32\|64\|128)OrNull {#todecimal3264128ornull} + +Преобразует входную строку в значение с типом данных [Nullable (Decimal (P, S))](../../sql-reference/functions/type-conversion-functions.md). Семейство функций включает в себя: + +- `toDecimal32OrNull(expr, S)` — Возвращает значение типа `Nullable(Decimal32(S))`. +- `toDecimal64OrNull(expr, S)` — Возвращает значение типа `Nullable(Decimal64(S))`. +- `toDecimal128OrNull(expr, S)` — Возвращает значение типа `Nullable(Decimal128(S))`. + +Эти функции следует использовать вместо функций `toDecimal*()`, если при ошибке обработки входного значения вы хотите получать `NULL` вместо исключения. + +**Параметры** + +- `expr` — [выражение](../syntax.md#syntax-expressions), возвращающее значение типа [String](../../sql-reference/functions/type-conversion-functions.md). ClickHouse ожидает текстовое представление десятичного числа. Например, `'1.111'`. +- `S` — количество десятичных знаков в результирующем значении. + +**Возвращаемое значение** + +Значение типа `Nullable(Decimal(P,S))`. Значение содержит: + +- Число с `S` десятичными знаками, если ClickHouse распознал число во входной строке. +- `NULL`, если ClickHouse не смог распознать число во входной строке или входное число содержит больше чем `S` десятичных знаков. + +**Примеры** + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ +│ -1.11100 │ Nullable(Decimal(9, 5)) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ +│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toDecimal(32\|64\|128)OrZero {#todecimal3264128orzero} + +Преобразует тип входного значения в [Decimal (P, S)](../../sql-reference/functions/type-conversion-functions.md). Семейство функций включает в себя: + +- `toDecimal32OrZero( expr, S)` — возвращает значение типа `Decimal32(S)`. +- `toDecimal64OrZero( expr, S)` — возвращает значение типа `Decimal64(S)`. +- `toDecimal128OrZero( expr, S)` — возвращает значение типа `Decimal128(S)`. + +Эти функции следует использовать вместо функций `toDecimal*()`, если при ошибке обработки входного значения вы хотите получать `0` вместо исключения. + +**Параметры** + +- `expr` — [выражение](../syntax.md#syntax-expressions), возвращающее значение типа [String](../../sql-reference/functions/type-conversion-functions.md). ClickHouse ожидает текстовое представление десятичного числа. Например, `'1.111'`. +- `S` — количество десятичных знаков в результирующем значении. + +**Возвращаемое значение** + +Значение типа `Nullable(Decimal(P,S))`. `P` равно числовой части имени функции. Например, для функции `toDecimal32OrZero`, `P = 32`. Значение содержит: + +- Число с `S` десятичными знаками, если ClickHouse распознал число во входной строке. +- 0 c `S` десятичными знаками, если ClickHouse не смог распознать число во входной строке или входное число содержит больше чем `S` десятичных знаков. + +**Пример** + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ +│ -1.11100 │ Decimal(9, 5) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ +│ 0.00 │ Decimal(9, 2) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toString {#tostring} + +Функции преобразования между числами, строками (но не фиксированными строками), датами и датами-с-временем. +Все эти функции принимают один аргумент. + +При преобразовании в строку или из строки, производится форматирование или парсинг значения по тем же правилам, что и для формата TabSeparated (и почти всех остальных текстовых форматов). Если распарсить строку не удаётся - кидается исключение и выполнение запроса прерывается. + +При преобразовании даты в число или наоборот, дате соответствует число дней от начала unix эпохи. +При преобразовании даты-с-временем в число или наоборот, дате-с-временем соответствует число секунд от начала unix эпохи. + +Форматы даты и даты-с-временем для функций toDate/toDateTime определены следующим образом: + +``` text +YYYY-MM-DD +YYYY-MM-DD hh:mm:ss +``` + +В качестве исключения, если делается преобразование из числа типа UInt32, Int32, UInt64, Int64 в Date, и если число больше или равно 65536, то число рассматривается как unix timestamp (а не как число дней) и округляется до даты. Это позволяет поддержать распространённый случай, когда пишут toDate(unix\_timestamp), что иначе было бы ошибкой и требовало бы написания более громоздкого toDate(toDateTime(unix\_timestamp)) + +Преобразование между датой и датой-с-временем производится естественным образом: добавлением нулевого времени или отбрасыванием времени. + +Преобразование между числовыми типами производится по тем же правилам, что и присваивание между разными числовыми типами в C++. + +Дополнительно, функция toString от аргумента типа DateTime может принимать второй аргумент String - имя тайм-зоны. Пример: `Asia/Yekaterinburg` В этом случае, форматирование времени производится согласно указанной тайм-зоне. + +``` sql +SELECT + now() AS now_local, + toString(now(), 'Asia/Yekaterinburg') AS now_yekat +``` + +``` text +┌───────────now_local─┬─now_yekat───────────┐ +│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ +└─────────────────────┴─────────────────────┘ +``` + +Также смотрите функцию `toUnixTimestamp`. + +## toFixedString(s, N) {#tofixedstrings-n} + +Преобразует аргумент типа String в тип FixedString(N) (строку фиксированной длины N). N должно быть константой. +Если строка имеет меньше байт, чем N, то она дополняется нулевыми байтами справа. Если строка имеет больше байт, чем N - кидается исключение. + +## toStringCutToZero(s) {#tostringcuttozeros} + +Принимает аргумент типа String или FixedString. Возвращает String, вырезая содержимое строки до первого найденного нулевого байта. + +Пример: + +``` sql +SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut +``` + +``` text +┌─s─────────────┬─s_cut─┐ +│ foo\0\0\0\0\0 │ foo │ +└───────────────┴───────┘ +``` + +``` sql +SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut +``` + +``` text +┌─s──────────┬─s_cut─┐ +│ foo\0bar\0 │ foo │ +└────────────┴───────┘ +``` + +## reinterpretAsUInt(8\|16\|32\|64) {#reinterpretasuint8163264} + +## reinterpretAsInt(8\|16\|32\|64) {#reinterpretasint8163264} + +## reinterpretAsFloat(32\|64) {#reinterpretasfloat3264} + +## reinterpretAsDate {#reinterpretasdate} + +## reinterpretAsDateTime {#reinterpretasdatetime} + +Функции принимают строку и интерпретируют байты, расположенные в начале строки, как число в host order (little endian). Если строка имеет недостаточную длину, то функции работают так, как будто строка дополнена необходимым количеством нулевых байт. Если строка длиннее, чем нужно, то лишние байты игнорируются. Дата интерпретируется, как число дней с начала unix-эпохи, а дата-с-временем - как число секунд с начала unix-эпохи. + +## reinterpretAsString {#type_conversion_functions-reinterpretAsString} + +Функция принимает число или дату или дату-с-временем и возвращает строку, содержащую байты, представляющие соответствующее значение в host order (little endian). При этом, отбрасываются нулевые байты с конца. Например, значение 255 типа UInt32 будет строкой длины 1 байт. + +## CAST(x, T) {#type_conversion_function-cast} + +Преобразует x в тип данных t. +Поддерживается также синтаксис CAST(x AS t). + +Пример: + +``` sql +SELECT + '2016-06-15 23:00:00' AS timestamp, + CAST(timestamp AS DateTime) AS datetime, + CAST(timestamp AS Date) AS date, + CAST(timestamp, 'String') AS string, + CAST(timestamp, 'FixedString(22)') AS fixed_string +``` + +``` text +┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ +│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ +└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ +``` + +Преобразование в FixedString(N) работает только для аргументов типа String или FixedString(N). + +Поддержано преобразование к типу [Nullable](../../sql-reference/functions/type-conversion-functions.md) и обратно. Пример: + +``` sql +SELECT toTypeName(x) FROM t_null +``` + +``` text +┌─toTypeName(x)─┐ +│ Int8 │ +│ Int8 │ +└───────────────┘ +``` + +``` sql +SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null +``` + +``` text +┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ +│ Nullable(UInt16) │ +│ Nullable(UInt16) │ +└─────────────────────────────────────────┘ +``` + +## toInterval(Year\|Quarter\|Month\|Week\|Day\|Hour\|Minute\|Second) {#function-tointerval} + +Приводит аргумент из числового типа данных к типу данных [IntervalType](../../sql-reference/data-types/special-data-types/interval.md). + +**Синтаксис** + +``` sql +toIntervalSecond(number) +toIntervalMinute(number) +toIntervalHour(number) +toIntervalDay(number) +toIntervalWeek(number) +toIntervalMonth(number) +toIntervalQuarter(number) +toIntervalYear(number) +``` + +**Параметры** + +- `number` — длительность интервала. Положительное целое число. + +**Возвращаемые значения** + +- Значение с типом данных `Interval`. + +**Пример** + +``` sql +WITH + toDate('2019-01-01') AS date, + INTERVAL 1 WEEK AS interval_week, + toIntervalWeek(1) AS interval_to_week +SELECT + date + interval_week, + date + interval_to_week +``` + +``` text +┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ +│ 2019-01-08 │ 2019-01-08 │ +└───────────────────────────┴──────────────────────────────┘ +``` + +## parseDateTimeBestEffort {#parsedatetimebesteffort} + +Преобразует дату и время в [строковом](../../sql-reference/functions/type-conversion-functions.md) представлении к типу данных [DateTime](../../sql-reference/functions/type-conversion-functions.md#data_type-datetime). + +Функция распознаёт форматы [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55), формат даты времени ClickHouse’s а также некоторые другие форматы. + +**Синтаксис** + +``` sql +parseDateTimeBestEffort(time_string[, time_zone]); +``` + +**Параметры** + +- `time_string` — строка, содержащая дату и время для преобразования. [String](../../sql-reference/functions/type-conversion-functions.md). +- `time_zone` — часовой пояс. Функция анализирует `time_string` в соответствии с заданным часовым поясом. [String](../../sql-reference/functions/type-conversion-functions.md). + +**Поддерживаемые нестандартные форматы** + +- [Unix timestamp](https://ru.wikipedia.org/wiki/Unix-время) в строковом представлении. 9 или 10 символов. +- Строка с датой и временем: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`, etc. +- Строка с датой, но без времени: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` и т.д. +- Строка с временем, и с днём: `DD`, `DD hh`, `DD hh:mm`. В этом случае `YYYY-MM` принимается равным `2000-01`. +- Строка, содержащая дату и время вместе с информацией о часовом поясе: `YYYY-MM-DD hh:mm:ss ±h:mm`, и т.д. Например, `2020-12-12 17:36:00 -5:00`. + +Для всех форматов с разделителями функция распознаёт названия месяцев, выраженных в виде полного англоязычного имени месяца или в виде первых трёх символов имени месяца. Примеры: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. + +**Возвращаемое значение** + +- `time_string` преобразованная к типу данных `DateTime`. + +**Примеры** + +Запрос: + +``` sql +SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') +AS parseDateTimeBestEffort; +``` + +Результат: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2020-12-12 12:12:57 │ +└─────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') +AS parseDateTimeBestEffort +``` + +Результат: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-08-18 10:22:16 │ +└─────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT parseDateTimeBestEffort('1284101485') +AS parseDateTimeBestEffort +``` + +Результат: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2015-07-07 12:04:41 │ +└─────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') +AS parseDateTimeBestEffort +``` + +Результат: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-12-12 10:12:12 │ +└─────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT parseDateTimeBestEffort('10 20:19') +``` + +Результат: + +``` text +┌─parseDateTimeBestEffort('10 20:19')─┐ +│ 2000-01-10 20:19:00 │ +└─────────────────────────────────────┘ +``` + +**См. также** + +- \[Информация о формате ISO 8601 от @xkcd\](https://xkcd.com/1179/) +- [RFC 1123](https://tools.ietf.org/html/rfc1123) +- [toDate](#todate) +- [toDateTime](#todatetime) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/type_conversion_functions/) diff --git a/docs/ru/sql-reference/functions/url-functions.md b/docs/ru/sql-reference/functions/url-functions.md new file mode 100644 index 00000000000..6d749f6f143 --- /dev/null +++ b/docs/ru/sql-reference/functions/url-functions.md @@ -0,0 +1,201 @@ +# Функции для работы с URL {#funktsii-dlia-raboty-s-url} + +Все функции работают не по RFC - то есть, максимально упрощены ради производительности. + +## Функции, извлекающие часть URL-а {#funktsii-izvlekaiushchie-chast-url-a} + +Если в URL-е нет ничего похожего, то возвращается пустая строка. + +### protocol {#protocol} + +Возвращает протокол. Примеры: http, ftp, mailto, magnet… + +### domain {#domain} + +Извлекает имя хоста из URL. + +``` sql +domain(url) +``` + +**Параметры** + +- `url` — URL. Тип — [String](../../sql-reference/functions/url-functions.md). + +URL может быть указан со схемой или без неё. Примеры: + +``` text +svn+ssh://some.svn-hosting.com:80/repo/trunk +some.svn-hosting.com:80/repo/trunk +https://yandex.com/time/ +``` + +Для указанных примеров функция `domain` возвращает следующие результаты: + +``` text +some.svn-hosting.com +some.svn-hosting.com +yandex.com +``` + +**Возвращаемые значения** + +- Имя хоста. Если ClickHouse может распарсить входную строку как URL. +- Пустая строка. Если ClickHouse не может распарсить входную строку как URL. + +Тип — `String`. + +**Пример** + +``` sql +SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') +``` + +``` text +┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ +│ some.svn-hosting.com │ +└────────────────────────────────────────────────────────┘ +``` + +### domainWithoutWWW {#domainwithoutwww} + +Возвращает домен, удалив префикс ‘www.’, если он присутствовал. + +### topLevelDomain {#topleveldomain} + +Извлекает домен верхнего уровня из URL. + +``` sql +topLevelDomain(url) +``` + +**Параметры** + +- `url` — URL. Тип — [String](../../sql-reference/functions/url-functions.md). + +URL может быть указан со схемой или без неё. Примеры: + +``` text +svn+ssh://some.svn-hosting.com:80/repo/trunk +some.svn-hosting.com:80/repo/trunk +https://yandex.com/time/ +``` + +**Возвращаемые значения** + +- Имя домена. Если ClickHouse может распарсить входную строку как URL. +- Пустая строка. Если ClickHouse не может распарсить входную строку как URL. + +Тип — `String`. + +**Пример** + +``` sql +SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') +``` + +``` text +┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ +│ com │ +└────────────────────────────────────────────────────────────────────┘ +``` + +### firstSignificantSubdomain {#firstsignificantsubdomain} + +Возвращает «первый существенный поддомен». Это понятие является нестандартным и специфично для Яндекс.Метрики. Первый существенный поддомен - это домен второго уровня, если он не равен одному из com, net, org, co, или домен третьего уровня, иначе. Например, firstSignificantSubdomain(‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain(‘https://news.yandex.com.tr/’) = ‘yandex’. Список «несущественных» доменов второго уровня и другие детали реализации могут изменяться в будущем. + +### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} + +Возвращает часть домена, включающую поддомены верхнего уровня до «первого существенного поддомена» (см. выше). + +Например, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. + +### path {#path} + +Возвращает путь. Пример: `/top/news.html` Путь не включает в себя query string. + +### pathFull {#pathfull} + +То же самое, но включая query string и fragment. Пример: /top/news.html?page=2\#comments + +### queryString {#querystring} + +Возвращает query-string. Пример: page=1&lr=213. query-string не включает в себя начальный знак вопроса, а также \# и всё, что после \#. + +### fragment {#fragment} + +Возвращает fragment identifier. fragment не включает в себя начальный символ решётки. + +### queryStringAndFragment {#querystringandfragment} + +Возвращает query string и fragment identifier. Пример: страница=1\#29390. + +### extractURLParameter(URL, name) {#extracturlparameterurl-name} + +Возвращает значение параметра name в URL, если такой есть; или пустую строку, иначе; если параметров с таким именем много - вернуть первый попавшийся. Функция работает при допущении, что имя параметра закодировано в URL в точности таким же образом, что и в переданном аргументе. + +### extractURLParameters(URL) {#extracturlparametersurl} + +Возвращает массив строк вида name=value, соответствующих параметрам URL. Значения никак не декодируются. + +### extractURLParameterNames(URL) {#extracturlparameternamesurl} + +Возвращает массив строк вида name, соответствующих именам параметров URL. Значения никак не декодируются. + +### URLHierarchy(URL) {#urlhierarchyurl} + +Возвращает массив, содержащий URL, обрезанный с конца по символам /, ? в пути и query-string. Подряд идущие символы-разделители считаются за один. Резка производится в позиции после всех подряд идущих символов-разделителей. Пример: + +### URLPathHierarchy(URL) {#urlpathhierarchyurl} + +То же самое, но без протокола и хоста в результате. Элемент / (корень) не включается. Пример: +Функция используется для реализации древовидных отчётов по URL в Яндекс.Метрике. + +``` text +URLPathHierarchy('https://example.com/browse/CONV-6788') = +[ + '/browse/', + '/browse/CONV-6788' +] +``` + +### decodeURLComponent(URL) {#decodeurlcomponenturl} + +Возвращает декодированный URL. +Пример: + +``` sql +SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; +``` + +``` text +┌─DecodedURL─────────────────────────────┐ +│ http://127.0.0.1:8123/?query=SELECT 1; │ +└────────────────────────────────────────┘ +``` + +## Функции, удаляющие часть из URL-а {#funktsii-udaliaiushchie-chast-iz-url-a} + +Если в URL-е нет ничего похожего, то URL остаётся без изменений. + +### cutWWW {#cutwww} + +Удаляет не более одного ‘www.’ с начала домена URL-а, если есть. + +### cutQueryString {#cutquerystring} + +Удаляет query string. Знак вопроса тоже удаляется. + +### cutFragment {#cutfragment} + +Удаляет fragment identifier. Символ решётки тоже удаляется. + +### cutQueryStringAndFragment {#cutquerystringandfragment} + +Удаляет query string и fragment identifier. Знак вопроса и символ решётки тоже удаляются. + +### cutURLParameter(URL, name) {#cuturlparameterurl-name} + +Удаляет параметр URL с именем name, если такой есть. Функция работает при допущении, что имя параметра закодировано в URL в точности таким же образом, что и в переданном аргументе. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/url_functions/) diff --git a/docs/ru/sql-reference/functions/uuid-functions.md b/docs/ru/sql-reference/functions/uuid-functions.md new file mode 100644 index 00000000000..b2b567c6a06 --- /dev/null +++ b/docs/ru/sql-reference/functions/uuid-functions.md @@ -0,0 +1,114 @@ +# Функции для работы с UUID {#funktsii-dlia-raboty-s-uuid} + +## generateUUIDv4 {#uuid-function-generate} + +Генерирует идентификатор [UUID версии 4](https://tools.ietf.org/html/rfc4122#section-4.4). + +``` sql +generateUUIDv4() +``` + +**Возвращаемое значение** + +Значение типа [UUID](../../sql-reference/functions/uuid-functions.md). + +**Пример использования** + +Этот пример демонстрирует, как создать таблицу с UUID-колонкой и добавить в нее сгенерированный UUID. + +``` sql +CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog + +INSERT INTO t_uuid SELECT generateUUIDv4() + +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┐ +│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ +└──────────────────────────────────────┘ +``` + +## toUUID (x) {#touuid-x} + +Преобразует значение типа String в тип UUID. + +``` sql +toUUID(String) +``` + +**Возвращаемое значение** + +Значение типа UUID. + +**Пример использования** + +``` sql +SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid +``` + +``` text +┌─────────────────────────────────uuid─┐ +│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ +└──────────────────────────────────────┘ +``` + +## UUIDStringToNum {#uuidstringtonum} + +Принимает строку, содержащую 36 символов в формате `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, и возвращает в виде набора байт в [FixedString(16)](../../sql-reference/functions/uuid-functions.md). + +``` sql +UUIDStringToNum(String) +``` + +**Возвращаемое значение** + +FixedString(16) + +**Пример использования** + +``` sql +SELECT + '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, + UUIDStringToNum(uuid) AS bytes +``` + +``` text +┌─uuid─────────────────────────────────┬─bytes────────────┐ +│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ +└──────────────────────────────────────┴──────────────────┘ +``` + +## UUIDNumToString {#uuidnumtostring} + +Принимает значение типа [FixedString(16)](../../sql-reference/functions/uuid-functions.md). Возвращает строку из 36 символов в текстовом виде. + +``` sql +UUIDNumToString(FixedString(16)) +``` + +**Возвращаемое значение** + +Значение типа String. + +**Пример использования** + +``` sql +SELECT + 'a/<@];!~p{jTj={)' AS bytes, + UUIDNumToString(toFixedString(bytes, 16)) AS uuid +``` + +``` text +┌─bytes────────────┬─uuid─────────────────────────────────┐ +│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ +└──────────────────┴──────────────────────────────────────┘ +``` + +## См. также: {#sm-takzhe} + +- [dictGetUUID](ext-dict-functions.md) +- [dictGetUUIDOrDefault](ext-dict-functions.md) + +[Original article](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/ru/sql-reference/functions/ym-dict-functions.md b/docs/ru/sql-reference/functions/ym-dict-functions.md new file mode 100644 index 00000000000..74be04e9ba3 --- /dev/null +++ b/docs/ru/sql-reference/functions/ym-dict-functions.md @@ -0,0 +1,149 @@ +# Функции для работы со словарями Яндекс.Метрики {#ym-dict-functions} + +Чтобы указанные ниже функции работали, в конфиге сервера должны быть указаны пути и адреса для получения всех словарей Яндекс.Метрики. Словари загружаются при первом вызове любой из этих функций. Если справочники не удаётся загрузить - будет выкинуто исключение. + +О том, как создать справочники, смотрите в разделе «Словари». + +## Множественные геобазы {#multiple-geobases} + +ClickHouse поддерживает работу одновременно с несколькими альтернативными геобазами (иерархиями регионов), для того чтобы можно было поддержать разные точки зрения о принадлежности регионов странам. + +В конфиге clickhouse-server указывается файл с иерархией регионов: +`/opt/geo/regions_hierarchy.txt` + +Кроме указанного файла, рядом ищутся файлы, к имени которых (до расширения) добавлен символ \_ и какой угодно суффикс. +Например, также найдётся файл `/opt/geo/regions_hierarchy_ua.txt`, если такой есть. + +`ua` называется ключом словаря. Для словаря без суффикса, ключ является пустой строкой. + +Все словари перезагружаются в рантайме (раз в количество секунд, заданное в конфигурационном параметре builtin\_dictionaries\_reload\_interval, по умолчанию - раз в час), но перечень доступных словарей определяется один раз, при старте сервера. + +Во все функции по работе с регионами, в конце добавлен один необязательный аргумент - ключ словаря. Далее он обозначен как geobase. +Пример: + +``` text +regionToCountry(RegionID) - использует словарь по умолчанию: /opt/geo/regions_hierarchy.txt; +regionToCountry(RegionID, '') - использует словарь по умолчанию: /opt/geo/regions_hierarchy.txt; +regionToCountry(RegionID, 'ua') - использует словарь для ключа ua: /opt/geo/regions_hierarchy_ua.txt; +``` + +### regionToCity(id\[, geobase\]) {#regiontocityid-geobase} + +Принимает число типа UInt32 - идентификатор региона из геобазы Яндекса. Если регион является городом или входит в некоторый город, то возвращает идентификатор региона - соответствующего города. Иначе возвращает 0. + +### regionToArea(id\[, geobase\]) {#regiontoareaid-geobase} + +Переводит регион в область (тип в геобазе - 5). В остальном, аналогично функции regionToCity. + +``` sql +SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + +``` text +┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ +│ │ +│ Москва и Московская область │ +│ Санкт-Петербург и Ленинградская область │ +│ Белгородская область │ +│ Ивановская область │ +│ Калужская область │ +│ Костромская область │ +│ Курская область │ +│ Липецкая область │ +│ Орловская область │ +│ Рязанская область │ +│ Смоленская область │ +│ Тамбовская область │ +│ Тверская область │ +│ Тульская область │ +└──────────────────────────────────────────────────────┘ +``` + +### regionToDistrict(id\[, geobase\]) {#regiontodistrictid-geobase} + +Переводит регион в федеральный округ (тип в геобазе - 4). В остальном, аналогично функции regionToCity. + +``` sql +SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + +``` text +┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ +│ │ +│ Центральный федеральный округ │ +│ Северо-Западный федеральный округ │ +│ Южный федеральный округ │ +│ Северо-Кавказский федеральный округ │ +│ Приволжский федеральный округ │ +│ Уральский федеральный округ │ +│ Сибирский федеральный округ │ +│ Дальневосточный федеральный округ │ +│ Шотландия │ +│ Фарерские острова │ +│ Фламандский регион │ +│ Брюссельский столичный регион │ +│ Валлония │ +│ Федерация Боснии и Герцеговины │ +└──────────────────────────────────────────────────────────┘ +``` + +### regionToCountry(id\[, geobase\]) {#regiontocountryid-geobase} + +Переводит регион в страну. В остальном, аналогично функции regionToCity. +Пример: `regionToCountry(toUInt32(213)) = 225` - преобразовали Москву (213) в Россию (225). + +### regionToContinent(id\[, geobase\]) {#regiontocontinentid-geobase} + +Переводит регион в континент. В остальном, аналогично функции regionToCity. +Пример: `regionToContinent(toUInt32(213)) = 10001` - преобразовали Москву (213) в Евразию (10001). + +### regionToTopContinent (\#regiontotopcontinent) {#regiontotopcontinent-regiontotopcontinent} + +Находит для региона верхний в иерархии континент. + +**Синтаксис** + +``` sql +regionToTopContinent(id[, geobase]); +``` + +**Параметры** + +- `id` — Идентификатор региона из геобазы Яндекса. [UInt32](../../sql-reference/functions/ym-dict-functions.md). +- `geobase` — Ключ словаря. Смотрите [Множественные геобазы](#multiple-geobases). [String](../../sql-reference/functions/ym-dict-functions.md). Опциональный параметр. + +**Возвращаемое значение** + +- Идентификатор континента верхнего уровня (последний при подъеме по иерархии регионов). +- 0, если его нет. + +Тип: `UInt32`. + +### regionToPopulation(id\[, geobase\]) {#regiontopopulationid-geobase} + +Получает население для региона. +Население может быть прописано в файлах с геобазой. Смотрите в разделе «Встроенные словари». +Если для региона не прописано население, возвращается 0. +В геобазе Яндекса, население может быть прописано для дочерних регионов, но не прописано для родительских. + +### regionIn(lhs, rhs\[, geobase\]) {#regioninlhs-rhs-geobase} + +Проверяет принадлежность региона lhs региону rhs. Возвращает число типа UInt8, равное 1, если принадлежит и 0, если не принадлежит. +Отношение рефлексивное - любой регион принадлежит также самому себе. + +### regionHierarchy(id\[, geobase\]) {#regionhierarchyid-geobase} + +Принимает число типа UInt32 - идентификатор региона из геобазы Яндекса. Возвращает массив идентификаторов регионов, состоящий из переданного региона и всех родителей по цепочке. +Пример: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. + +### regionToName(id\[, lang\]) {#regiontonameid-lang} + +Принимает число типа UInt32 - идентификатор региона из геобазы Яндекса. Вторым аргументом может быть передана строка - название языка. Поддерживаются языки ru, en, ua, uk, by, kz, tr. Если второй аргумент отсутствует - используется язык ru. Если язык не поддерживается - кидается исключение. Возвращает строку - название региона на соответствующем языке. Если региона с указанным идентификатором не существует - возвращается пустая строка. + +`ua` и `uk` обозначают одно и то же - украинский язык. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/ym_dict_functions/) diff --git a/docs/ru/sql-reference/index.md b/docs/ru/sql-reference/index.md new file mode 100644 index 00000000000..ea611e75995 --- /dev/null +++ b/docs/ru/sql-reference/index.md @@ -0,0 +1,16 @@ +--- +toc_folder_title: "\u0421\u043F\u0440\u0430\u0432\u043A\u0430 \u043F\u043E SQL" +toc_hidden: true +toc_priority: 28 +toc_title: hidden +--- + +# Справка по SQL {#spravka-po-sql} + +- [SELECT](statements/select/index.md) +- [INSERT INTO](statements/insert-into.md) +- [CREATE](statements/create.md) +- [ALTER](statements/alter.md#query_language_queries_alter) +- [Прочие виды запросов](statements/misc.md) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/) diff --git a/docs/ru/sql-reference/operators/in.md b/docs/ru/sql-reference/operators/in.md new file mode 120000 index 00000000000..3a2feda2f61 --- /dev/null +++ b/docs/ru/sql-reference/operators/in.md @@ -0,0 +1 @@ +../../../en/sql-reference/operators/in.md \ No newline at end of file diff --git a/docs/ru/sql-reference/operators/index.md b/docs/ru/sql-reference/operators/index.md new file mode 100644 index 00000000000..ef4d1ae048e --- /dev/null +++ b/docs/ru/sql-reference/operators/index.md @@ -0,0 +1,271 @@ +# Операторы {#operatory} + +Все операторы преобразуются в соответствующие функции на этапе парсинга запроса, с учётом их приоритетов и ассоциативности. +Далее будут перечислены группы операторов в порядке их приоритета (чем выше, тем раньше оператор связывается со своими аргументами). + +## Операторы доступа {#operatory-dostupa} + +`a[N]` - доступ к элементу массива, функция `arrayElement(a, N)`. + +`a.N` - доступ к элементу кортежа, функция `tupleElement(a, N)`. + +## Оператор числового отрицания {#operator-chislovogo-otritsaniia} + +`-a` - функция `negate(a)`. + +## Операторы умножения и деления {#operatory-umnozheniia-i-deleniia} + +`a * b` - функция `multiply(a, b)` + +`a / b` - функция `divide(a, b)` + +`a % b` - функция `modulo(a, b)` + +## Операторы сложения и вычитания {#operatory-slozheniia-i-vychitaniia} + +`a + b` - функция `plus(a, b)` + +`a - b` - функция `minus(a, b)` + +## Операторы сравнения {#operatory-sravneniia} + +`a = b` - функция `equals(a, b)` + +`a == b` - функция `equals(a, b)` + +`a != b` - функция `notEquals(a, b)` + +`a <> b` - функция `notEquals(a, b)` + +`a <= b` - функция `lessOrEquals(a, b)` + +`a >= b` - функция `greaterOrEquals(a, b)` + +`a < b` - функция `less(a, b)` + +`a > b` - функция `greater(a, b)` + +`a LIKE s` - функция `like(a, b)` + +`a NOT LIKE s` - функция `notLike(a, b)` + +`a BETWEEN b AND c` - равнозначно `a >= b AND a <= c` + +`a NOT BETWEEN b AND c` - равнозначно `a < b OR a > c` + +## Операторы для работы с множествами {#operatory-dlia-raboty-s-mnozhestvami} + +*Смотрите раздел [Операторы IN](../../sql-reference/operators/in.md#select-in-operators).* + +`a IN ...` - функция `in(a, b)` + +`a NOT IN ...` - функция `notIn(a, b)` + +`a GLOBAL IN ...` - функция `globalIn(a, b)` + +`a GLOBAL NOT IN ...` - функция `globalNotIn(a, b)` + +## Оператор для работы с датами и временем {#operators-datetime} + +### EXTRACT {#extract} + +``` sql +EXTRACT(part FROM date); +``` + +Позволяет извлечь отдельные части из переданной даты. Например, можно получить месяц из даты, или минуты из времени. + +В параметре `part` указывается, какой фрагмент даты нужно получить. Доступные значения: + +- `DAY` — День. Возможные значения: 1–31. +- `MONTH` — Номер месяца. Возможные значения: 1–12. +- `YEAR` — Год. +- `SECOND` — Секунда. Возможные значения: 0–59. +- `MINUTE` — Минута. Возможные значения: 0–59. +- `HOUR` — Час. Возможные значения: 0–23. + +Эти значения могут быть указаны также в нижнем регистре (`day`, `month`). + +В параметре `date` указывается исходная дата. Поддерживаются типы [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md). + +Примеры: + +``` sql +SELECT EXTRACT(DAY FROM toDate('2017-06-15')); +SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); +SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); +``` + +В следующем примере создадим таблицу и добавим в неё значение с типом `DateTime`. + +``` sql +CREATE TABLE test.Orders +( + OrderId UInt64, + OrderName String, + OrderDate DateTime +) +ENGINE = Log; +``` + +``` sql +INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); +``` + +``` sql +SELECT + toYear(OrderDate) AS OrderYear, + toMonth(OrderDate) AS OrderMonth, + toDayOfMonth(OrderDate) AS OrderDay, + toHour(OrderDate) AS OrderHour, + toMinute(OrderDate) AS OrderMinute, + toSecond(OrderDate) AS OrderSecond +FROM test.Orders; +``` + +``` text +┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ +│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ +└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ +``` + +Больше примеров приведено в [тестах](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). + +### INTERVAL {#operator-interval} + +Создаёт значение типа [Interval](../../sql-reference/operators/index.md) которое должно использоваться в арифметических операциях со значениями типов [Date](../../sql-reference/operators/index.md) и [DateTime](../../sql-reference/operators/index.md). + +Типы интервалов: +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +!!! warning "Внимание" + Интервалы различных типов нельзя объединять. Нельзя использовать выражения вида `INTERVAL 4 DAY 1 HOUR`. Вместо этого интервалы можно выразить в единицах меньших или равных наименьшей единице интервала, Например, `INTERVAL 25 HOUR`. Также можно выполнять последовательные операции как показано в примере ниже. + +Пример: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +**Смотрите также** + +- Тип данных [Interval](../../sql-reference/operators/index.md) +- Функции преобразования типов [toInterval](../../sql-reference/operators/index.md#function-tointerval) + +## Оператор логического отрицания {#operator-logicheskogo-otritsaniia} + +`NOT a` - функция `not(a)` + +## Оператор логического ‘И’ {#operator-logicheskogo-i} + +`a AND b` - функция `and(a, b)` + +## Оператор логического ‘ИЛИ’ {#operator-logicheskogo-ili} + +`a OR b` - функция `or(a, b)` + +## Условный оператор {#uslovnyi-operator} + +`a ? b : c` - функция `if(a, b, c)` + +Примечание: + +Условный оператор сначала вычисляет значения b и c, затем проверяет выполнение условия a, и только после этого возвращает соответствующее значение. Если в качестве b или с выступает функция [arrayJoin()](../../sql-reference/operators/index.md#functions_arrayjoin), то размножение каждой строки произойдет вне зависимости от условия а. + +## Условное выражение {#operator_case} + +``` sql +CASE [x] + WHEN a THEN b + [WHEN ... THEN ...] + [ELSE c] +END +``` + +В случае указания `x` - функция `transform(x, [a, ...], [b, ...], c)`. Иначе — `multiIf(a, b, ..., c)`. +При отсутствии секции `ELSE c`, значением по умолчанию будет `NULL`. + +!!! note "Примечание" + Функция `transform` не умеет работать с `NULL`. + +## Оператор склеивания строк {#operator-skleivaniia-strok} + +`s1 || s2` - функция `concat(s1, s2)` + +## Оператор создания лямбда-выражения {#operator-sozdaniia-liambda-vyrazheniia} + +`x -> expr` - функция `lambda(x, expr)` + +Следующие операторы не имеют приоритета, так как представляют собой скобки: + +## Оператор создания массива {#operator-sozdaniia-massiva} + +`[x1, ...]` - функция `array(x1, ...)` + +## Оператор создания кортежа {#operator-sozdaniia-kortezha} + +`(x1, x2, ...)` - функция `tuple(x2, x2, ...)` + +## Ассоциативность {#assotsiativnost} + +Все бинарные операторы имеют левую ассоциативность. Например, `1 + 2 + 3` преобразуется в `plus(plus(1, 2), 3)`. +Иногда это работает не так, как ожидается. Например, `SELECT 4 > 3 > 2` выдаст 0. + +Для эффективности, реализованы функции `and` и `or`, принимающие произвольное количество аргументов. Соответствующие цепочки операторов `AND` и `OR`, преобразуются в один вызов этих функций. + +## Проверка на `NULL` {#proverka-na-null} + +ClickHouse поддерживает операторы `IS NULL` и `IS NOT NULL`. + +### IS NULL {#operator-is-null} + +- Для значений типа [Nullable](../../sql-reference/operators/index.md) оператор `IS NULL` возвращает: + - `1`, если значение — `NULL`. + - `0` в обратном случае. +- Для прочих значений оператор `IS NULL` всегда возвращает `0`. + + + +``` sql +SELECT x+100 FROM t_null WHERE y IS NULL +``` + +``` text +┌─plus(x, 100)─┐ +│ 101 │ +└──────────────┘ +``` + +### IS NOT NULL {#is-not-null} + +- Для значений типа [Nullable](../../sql-reference/operators/index.md) оператор `IS NOT NULL` возвращает: + - `0`, если значение — `NULL`. + - `1`, в обратном случае. +- Для прочих значений оператор `IS NOT NULL` всегда возвращает `1`. + + + +``` sql +SELECT * FROM t_null WHERE y IS NOT NULL +``` + +``` text +┌─x─┬─y─┐ +│ 2 │ 3 │ +└───┴───┘ +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/operators/) diff --git a/docs/ru/sql-reference/statements/alter.md b/docs/ru/sql-reference/statements/alter.md new file mode 100644 index 00000000000..1cf061c174f --- /dev/null +++ b/docs/ru/sql-reference/statements/alter.md @@ -0,0 +1,611 @@ +--- +toc_priority: 36 +toc_title: ALTER +--- + +## ALTER {#query_language_queries_alter} + +Запрос `ALTER` поддерживается только для таблиц типа `*MergeTree`, а также `Merge` и `Distributed`. Запрос имеет несколько вариантов. + +### Манипуляции со столбцами {#manipuliatsii-so-stolbtsami} + +Изменение структуры таблицы. + +``` sql +ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... +``` + +В запросе указывается список из одного или более действий через запятую. +Каждое действие — операция над столбцом. + +Существуют следующие действия: + +- [ADD COLUMN](#alter_add-column) — добавляет столбец в таблицу; +- [DROP COLUMN](#alter_drop-column) — удаляет столбец; +- [CLEAR COLUMN](#alter_clear-column) — сбрасывает все значения в столбце для заданной партиции; +- [COMMENT COLUMN](#alter_comment-column) — добавляет комментарий к столбцу; +- [MODIFY COLUMN](#alter_modify-column) — изменяет тип столбца, выражение для значения по умолчанию и TTL. + +Подробное описание для каждого действия приведено ниже. + +#### ADD COLUMN {#alter_add-column} + +``` sql +ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] +``` + +Добавляет в таблицу новый столбец с именем `name`, типом `type`, [кодеком](create.md#codecs) `codec` и выражением для умолчания `default_expr` (смотрите раздел [Значения по умолчанию](create.md#create-default-values)). + +Если указано `IF NOT EXISTS`, запрос не будет возвращать ошибку, если столбец уже существует. Если указано `AFTER name_after` (имя другого столбца), то столбец добавляется (в список столбцов таблицы) после указанного. Иначе, столбец добавляется в конец таблицы. Обратите внимание, ClickHouse не позволяет добавлять столбцы в начало таблицы. Для цепочки действий, `name_after` может быть именем столбца, который добавляется в одном из предыдущих действий. + +Добавление столбца всего лишь меняет структуру таблицы, и не производит никаких действий с данными - соответствующие данные не появляются на диске после ALTER-а. При чтении из таблицы, если для какого-либо столбца отсутствуют данные, то он заполняется значениями по умолчанию (выполняя выражение по умолчанию, если такое есть, или нулями, пустыми строками). Также, столбец появляется на диске при слиянии кусков данных (см. [MergeTree](../../sql-reference/statements/alter.md)). + +Такая схема позволяет добиться мгновенной работы запроса `ALTER` и отсутствия необходимости увеличивать объём старых данных. + +Пример: + +``` sql +ALTER TABLE visits ADD COLUMN browser String AFTER user_id +``` + +#### DROP COLUMN {#alter_drop-column} + +``` sql +DROP COLUMN [IF EXISTS] name +``` + +Удаляет столбец с именем `name`. Если указано `IF EXISTS`, запрос не будет возвращать ошибку, если столбца не существует. + +Запрос удаляет данные из файловой системы. Так как это представляет собой удаление целых файлов, запрос выполняется почти мгновенно. + +Пример: + +``` sql +ALTER TABLE visits DROP COLUMN browser +``` + +#### CLEAR COLUMN {#alter_clear-column} + +``` sql +CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name +``` + +Сбрасывает все значения в столбце для заданной партиции. Если указано `IF EXISTS`, запрос не будет возвращать ошибку, если столбца не существует. + +Как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +Пример: + +``` sql +ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() +``` + +#### COMMENT COLUMN {#alter_comment-column} + +``` sql +COMMENT COLUMN [IF EXISTS] name 'Text comment' +``` + +Добавляет комментарий к таблице. Если указано `IF EXISTS`, запрос не будет возвращать ошибку, если столбца не существует. + +Каждый столбец может содержать только один комментарий. При выполнении запроса существующий комментарий заменяется на новый. + +Посмотреть комментарии можно в столбце `comment_expression` из запроса [DESCRIBE TABLE](misc.md#misc-describe-table). + +Пример: + +``` sql +ALTER TABLE visits COMMENT COLUMN browser 'Столбец показывает, из каких браузеров пользователи заходили на сайт.' +``` + +#### MODIFY COLUMN {#alter_modify-column} + +``` sql +MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] +``` + +Запрос изменяет следующие свойства столбца `name`: + +- Тип + +- Значение по умолчанию + +- TTL + + Примеры изменения TTL столбца смотрите в разделе [TTL столбца](../../sql_reference/statements/alter.md#mergetree-column-ttl). + +Если указано `IF EXISTS`, запрос не возвращает ошибку, если столбца не существует. + +При изменении типа, значения преобразуются так, как если бы к ним была применена функция [toType](../../sql-reference/statements/alter.md). Если изменяется только выражение для умолчания, запрос не делает никакой сложной работы и выполняется мгновенно. + +Пример запроса: + +``` sql +ALTER TABLE visits MODIFY COLUMN browser Array(String) +``` + +Изменение типа столбца - это единственное действие, которое выполняет сложную работу - меняет содержимое файлов с данными. Для больших таблиц, выполнение может занять длительное время. + +Выполнение производится в несколько стадий: + +- подготовка временных (новых) файлов с изменёнными данными; +- переименование старых файлов; +- переименование временных (новых) файлов в старые; +- удаление старых файлов. + +Из них, длительной является только первая стадия. Если на этой стадии возникнет сбой, то данные не поменяются. +Если на одной из следующих стадий возникнет сбой, то данные будет можно восстановить вручную. За исключением случаев, когда старые файлы удалены из файловой системы, а данные для новых файлов не доехали на диск и потеряны. + +Запрос `ALTER` на изменение столбцов реплицируется. Соответствующие инструкции сохраняются в ZooKeeper, и затем каждая реплика их применяет. Все запросы `ALTER` выполняются в одном и том же порядке. Запрос ждёт выполнения соответствующих действий на всех репликах. Но при этом, запрос на изменение столбцов в реплицируемой таблице можно прервать, и все действия будут осуществлены асинхронно. + +#### Ограничения запроса ALTER {#ogranicheniia-zaprosa-alter} + +Запрос `ALTER` позволяет создавать и удалять отдельные элементы (столбцы) вложенных структур данных, но не вложенные структуры данных целиком. Для добавления вложенной структуры данных, вы можете добавить столбцы с именем вида `name.nested_name` и типом `Array(T)` - вложенная структура данных полностью эквивалентна нескольким столбцам-массивам с именем, имеющим одинаковый префикс до точки. + +Отсутствует возможность удалять столбцы, входящие в первичный ключ или ключ для сэмплирования (в общем, входящие в выражение `ENGINE`). Изменение типа у столбцов, входящих в первичный ключ возможно только в том случае, если это изменение не приводит к изменению данных (например, разрешено добавление значения в Enum или изменение типа с `DateTime` на `UInt32`). + +Если возможностей запроса `ALTER` не хватает для нужного изменения таблицы, вы можете создать новую таблицу, скопировать туда данные с помощью запроса [INSERT SELECT](insert-into.md#insert_query_insert-select), затем поменять таблицы местами с помощью запроса [RENAME](misc.md#misc_operations-rename), и удалить старую таблицу. В качестве альтернативы для запроса `INSERT SELECT`, можно использовать инструмент [clickhouse-copier](../../sql-reference/statements/alter.md). + +Запрос `ALTER` блокирует все чтения и записи для таблицы. То есть, если на момент запроса `ALTER`, выполнялся долгий `SELECT`, то запрос `ALTER` сначала дождётся его выполнения. И в это время, все новые запросы к той же таблице, будут ждать, пока завершится этот `ALTER`. + +Для таблиц, которые не хранят данные самостоятельно (типа [Merge](../../sql-reference/statements/alter.md) и [Distributed](../../sql-reference/statements/alter.md)), `ALTER` всего лишь меняет структуру таблицы, но не меняет структуру подчинённых таблиц. Для примера, при ALTER-е таблицы типа `Distributed`, вам также потребуется выполнить запрос `ALTER` для таблиц на всех удалённых серверах. + +### Манипуляции с ключевыми выражениями таблиц {#manipuliatsii-s-kliuchevymi-vyrazheniiami-tablits} + +Поддерживается операция: + +``` sql +MODIFY ORDER BY new_expression +``` + +Работает только для таблиц семейства [`MergeTree`](../../sql-reference/statements/alter.md) (в том числе [реплицированных](../../sql-reference/statements/alter.md)). После выполнения запроса +[ключ сортировки](../../sql-reference/statements/alter.md) таблицы +заменяется на `new_expression` (выражение или кортеж выражений). Первичный ключ при этом остаётся прежним. + +Операция затрагивает только метаданные. Чтобы сохранить свойство упорядоченности кусков данных по ключу +сортировки, разрешено добавлять в ключ только новые столбцы (т.е. столбцы, добавляемые командой `ADD COLUMN` +в том же запросе `ALTER`), у которых нет выражения по умолчанию. + +### Манипуляции с индексами {#manipuliatsii-s-indeksami} + +Добавить или удалить индекс можно с помощью операций + +``` sql +ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value [AFTER name] +ALTER TABLE [db].name DROP INDEX name +``` + +Поддерживается только таблицами семейства `*MergeTree`. + +Команда `ADD INDEX` добавляет описание индексов в метаданные, а `DROP INDEX` удаляет индекс из метаданных и стирает файлы индекса с диска, поэтому они легковесные и работают мгновенно. + +Если индекс появился в метаданных, то он начнет считаться в последующих слияниях и записях в таблицу, а не сразу после выполнения операции `ALTER`. + +Запрос на изменение индексов реплицируется, сохраняя новые метаданные в ZooKeeper и применяя изменения на всех репликах. + +### Манипуляции с ограничениями (constraints) {#manipuliatsii-s-ogranicheniiami-constraints} + +Про ограничения подробнее написано [тут](create.md#constraints). + +Добавить или удалить ограничение можно с помощью запросов + +``` sql +ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; +ALTER TABLE [db].name DROP CONSTRAINT constraint_name; +``` + +Запросы выполняют добавление или удаление метаданных об ограничениях таблицы `[db].name`, поэтому выполняются мнгновенно. + +Если ограничение появилось для непустой таблицы, то *проверка ограничения для имеющихся данных не производится*. + +Запрос на изменение ограничений для Replicated таблиц реплицируется, сохраняя новые метаданные в ZooKeeper и применяя изменения на всех репликах. + +### Манипуляции с партициями и кусками {#alter_manipulations-with-partitions} + +Для работы с [партициями](../../sql-reference/statements/alter.md) доступны следующие операции: + +- [DETACH PARTITION](#alter_detach-partition) — перенести партицию в директорию `detached`; +- [DROP PARTITION](#alter_drop-partition) — удалить партицию; +- [ATTACH PARTITION\|PART](#alter_attach-partition) — добавить партицию/кусок в таблицу из директории `detached`; +- [ATTACH PARTITION FROM](#alter_attach-partition-from) — скопировать партицию из другой таблицы; +- [REPLACE PARTITION](#alter_replace-partition) — скопировать партицию из другой таблицы с заменой; +- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition) — переместить партицию в другую таблицу; +- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) — удалить все значения в столбце для заданной партиции; +- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) — очистить построенные вторичные индексы для заданной партиции; +- [FREEZE PARTITION](#alter_freeze-partition) — создать резервную копию партиции; +- [FETCH PARTITION](#alter_fetch-partition) — скачать партицию с другого сервера; +- [MOVE PARTITION\|PART](#alter_move-partition) — переместить партицию/кускок на другой диск или том. + +#### DETACH PARTITION {#alter_detach-partition} + +``` sql +ALTER TABLE table_name DETACH PARTITION partition_expr +``` + +Перемещает заданную партицию в директорию `detached`. Сервер не будет знать об этой партиции до тех пор, пока вы не выполните запрос [ATTACH](#alter_attach-partition). + +Пример: + +``` sql +ALTER TABLE visits DETACH PARTITION 201901 +``` + +Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +После того как запрос будет выполнен, вы сможете производить любые операции с данными в директории `detached`. Например, можно удалить их из файловой системы. + +Запрос реплицируется — данные будут перенесены в директорию `detached` и забыты на всех репликах. Обратите внимание, запрос может быть отправлен только на реплику-лидер. Чтобы узнать, является ли реплика лидером, выполните запрос `SELECT` к системной таблице [system.replicas](../../operations/system-tables.md#system_tables-replicas). Либо можно выполнить запрос `DETACH` на всех репликах — тогда на всех репликах, кроме реплики-лидера, запрос вернет ошибку. + +#### DROP PARTITION {#alter_drop-partition} + +``` sql +ALTER TABLE table_name DROP PARTITION partition_expr +``` + +Удаляет партицию. Партиция помечается как неактивная и будет полностью удалена примерно через 10 минут. + +Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +Запрос реплицируется — данные будут удалены на всех репликах. + +#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} + +``` sql +ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr +``` + +Удаляет из `detached` кусок или все куски, принадлежащие партиции. +Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +#### ATTACH PARTITION\|PART {#alter_attach-partition} + +``` sql +ALTER TABLE table_name ATTACH PARTITION|PART partition_expr +``` + +Добавляет данные в таблицу из директории `detached`. Можно добавить данные как для целой партиции, так и для отдельного куска. Примеры: + +``` sql +ALTER TABLE visits ATTACH PARTITION 201901; +ALTER TABLE visits ATTACH PART 201901_2_2_0; +``` + +Как корректно задать имя партиции или куска, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +Этот запрос реплицируется. Реплика-иницатор проверяет, есть ли данные в директории `detached`. Если данные есть, то запрос проверяет их целостность. В случае успеха данные добавляются в таблицу. Все остальные реплики загружают данные с реплики-инициатора запроса. + +Это означает, что вы можете разместить данные в директории `detached` на одной реплике и с помощью запроса `ALTER ... ATTACH` добавить их в таблицу на всех репликах. + +#### ATTACH PARTITION FROM {#alter_attach-partition-from} + +``` sql +ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 +``` + +Копирует партицию из таблицы `table1` в таблицу `table2` и добавляет к существующим данным `table2`. Данные из `table1` не удаляются. + +Следует иметь в виду: + +- Таблицы должны иметь одинаковую структуру. +- Для таблиц должен быть задан одинаковый ключ партиционирования. + +Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +#### REPLACE PARTITION {#alter_replace-partition} + +``` sql +ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 +``` + +Копирует партицию из таблицы `table1` в таблицу `table2` с заменой существующих данных в `table2`. Данные из `table1` не удаляются. + +Следует иметь в виду: + +- Таблицы должны иметь одинаковую структуру. +- Для таблиц должен быть задан одинаковый ключ партиционирования. + +Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} + +``` sql +ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest +``` + +Перемещает партицию из таблицы `table_source` в таблицу `table_dest` (добавляет к существующим данным в `table_dest`) с удалением данных из таблицы `table_source`. + +Следует иметь в виду: + +- Таблицы должны иметь одинаковую структуру. +- Для таблиц должен быть задан одинаковый ключ партиционирования. +- Движки таблиц должны быть одинакового семейства (реплицированные или нереплицированные). +- Для таблиц должна быть задана одинаковая политика хранения. + +#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} + +``` sql +ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr +``` + +Сбрасывает все значения в столбце для заданной партиции. Если для столбца определено значение по умолчанию (в секции `DEFAULT`), то будет выставлено это значение. + +Пример: + +``` sql +ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 +``` + +#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} + +``` sql +ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr +``` + +Работает как `CLEAR COLUMN`, но сбрасывает индексы вместо данных в столбцах. + +#### FREEZE PARTITION {#alter_freeze-partition} + +``` sql +ALTER TABLE table_name FREEZE [PARTITION partition_expr] +``` + +Создаёт резервную копию для заданной партиции. Если выражение `PARTITION` опущено, резервные копии будут созданы для всех партиций. + +!!! note "Примечание" + Создание резервной копии не требует остановки сервера. + +Для таблиц старого стиля имя партиций можно задавать в виде префикса (например, ‘2019’). В этом случае резервные копии будут созданы для всех соответствующих партиций. Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). + +Запрос делает следующее — для текущего состояния таблицы он формирует жесткие ссылки на данные в этой таблице. Ссылки размещаются в директории `/var/lib/clickhouse/shadow/N/...`, где: + +- `/var/lib/clickhouse/` — рабочая директория ClickHouse, заданная в конфигурационном файле; +- `N` — инкрементальный номер резервной копии. + +!!! note "Примечание" + При использовании [нескольких дисков для хранения данных таблицы](../../sql-reference/statements/alter.md#table_engine-mergetree-multiple-volumes) директория `shadow/N` появляется на каждом из дисков, на которых были куски, попавшие под выражение `PARTITION`. + +Структура директорий внутри резервной копии такая же, как внутри `/var/lib/clickhouse/`. Запрос выполнит ‘chmod’ для всех файлов, запрещая запись в них. + +Обратите внимание, запрос `ALTER TABLE t FREEZE PARTITION` не реплицируется. Он создает резервную копию только на локальном сервере. После создания резервной копии данные из `/var/lib/clickhouse/shadow/` можно скопировать на удалённый сервер, а локальную копию удалить. + +Резервная копия создается почти мгновенно (однако сначала запрос дожидается завершения всех запросов, которые выполняются для соответствующей таблицы). + +`ALTER TABLE t FREEZE PARTITION` копирует только данные, но не метаданные таблицы. Чтобы сделать резервную копию метаданных таблицы, скопируйте файл `/var/lib/clickhouse/metadata/database/table.sql` + +Чтобы восстановить данные из резервной копии, выполните следующее: + +1. Создайте таблицу, если она ещё не существует. Запрос на создание можно взять из .sql файла (замените в нём `ATTACH` на `CREATE`). +2. Скопируйте данные из директории `data/database/table/` внутри резервной копии в директорию `/var/lib/clickhouse/data/database/table/detached/`. +3. С помощью запросов `ALTER TABLE t ATTACH PARTITION` добавьте данные в таблицу. + +Восстановление данных из резервной копии не требует остановки сервера. + +Подробнее о резервном копировании и восстановлении данных читайте в разделе [Резервное копирование данных](../../operations/backup.md). + +#### FETCH PARTITION {#alter_fetch-partition} + +``` sql +ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' +``` + +Загружает партицию с другого сервера. Этот запрос работает только для реплицированных таблиц. + +Запрос выполняет следующее: + +1. Загружает партицию с указанного шарда. Путь к шарду задается в секции `FROM` (‘path-in-zookeeper’). Обратите внимание, нужно задавать путь к шарду в ZooKeeper. +2. Помещает загруженные данные в директорию `detached` таблицы `table_name`. Чтобы прикрепить эти данные к таблице, используйте запрос [ATTACH PARTITION\|PART](#alter_attach-partition). + +Например: + +``` sql +ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; +ALTER TABLE users ATTACH PARTITION 201902; +``` + +Следует иметь в виду: + +- Запрос `ALTER TABLE t FETCH PARTITION` не реплицируется. Он загружает партицию в директорию `detached` только на локальном сервере. +- Запрос `ALTER TABLE t ATTACH` реплицируется — он добавляет данные в таблицу сразу на всех репликах. На одной из реплик данные будут добавлены из директории `detached`, а на других — из соседних реплик. + +Перед загрузкой данных система проверяет, существует ли партиция и совпадает ли её структура со структурой таблицы. При этом автоматически выбирается наиболее актуальная реплика среди всех живых реплик. + +Несмотря на то что запрос называется `ALTER TABLE`, он не изменяет структуру таблицы и не изменяет сразу доступные данные в таблице. + +#### MOVE PARTITION\|PART {#alter_move-partition} + +Перемещает партицию или кусок данных на другой том или диск для таблиц с движком `MergeTree`. Смотрите [Хранение данных таблицы на нескольких блочных устройствах](../../sql-reference/statements/alter.md#table_engine-mergetree-multiple-volumes). + +``` sql +ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' +``` + +Запрос `ALTER TABLE t MOVE`: + +- Не реплицируется, т.к. на разных репликах могут быть различные конфигурации политик хранения. +- Возвращает ошибку, если указан несконфигурированный том или диск. Ошибка также возвращается в случае невыполнения условий перемещения данных, которые указаны в конфигурации политики хранения. +- Может возвращать ошибку в случае, когда перемещаемые данные уже оказались перемещены в результате фонового процесса, конкурентного запроса `ALTER TABLE t MOVE` или как часть результата фоновой операции слияния. В данном случае никаких дополнительных действий от пользователя не требуется. + +Примеры: + +``` sql +ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' +ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' +``` + +#### Как задавать имя партиции в запросах ALTER {#alter-how-to-specify-part-expr} + +Чтобы задать нужную партицию в запросах `ALTER ... PARTITION`, можно использовать: + +- Имя партиции. Посмотреть имя партиции можно в столбце `partition` системной таблицы [system.parts](../../operations/system-tables.md#system_tables-parts). Например, `ALTER TABLE visits DETACH PARTITION 201901`. +- Произвольное выражение из столбцов исходной таблицы. Также поддерживаются константы и константные выражения. Например, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. +- Строковый идентификатор партиции. Идентификатор партиции используется для именования кусков партиции на файловой системе и в ZooKeeper. В запросах `ALTER` идентификатор партиции нужно указывать в секции `PARTITION ID`, в одинарных кавычках. Например, `ALTER TABLE visits DETACH PARTITION ID '201901'`. +- Для запросов [ATTACH PART](#alter_attach-partition) и [DROP DETACHED PART](#alter_drop-detached): чтобы задать имя куска партиции, используйте строковой литерал со значением из столбца `name` системной таблицы [system.detached\_parts](../../operations/system-tables.md#system_tables-detached_parts). Например, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. + +Использование кавычек в имени партиций зависит от типа данных столбца, по которому задано партиционирование. Например, для столбца с типом `String` имя партиции необходимо указывать в кавычках (одинарных). Для типов `Date` и `Int*` кавычки указывать не нужно. + +Замечание: для таблиц старого стиля партицию можно указывать и как число `201901`, и как строку `'201901'`. Синтаксис для таблиц нового типа более строг к типам (аналогично парсеру входного формата VALUES). + +Правила, сформулированные выше, актуальны также для запросов [OPTIMIZE](misc.md#misc_operations-optimize). Чтобы указать единственную партицию непартиционированной таблицы, укажите `PARTITION tuple()`. Например: + +``` sql +OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; +``` + +Примеры запросов `ALTER ... PARTITION` можно посмотреть в тестах: [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) и [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). + +### Манипуляции с TTL таблицы {#manipuliatsii-s-ttl-tablitsy} + +Вы можете изменить [TTL для таблицы](../../sql-reference/statements/alter.md#mergetree-table-ttl) запросом следующего вида: + +``` sql +ALTER TABLE table-name MODIFY TTL ttl-expression +``` + +### Синхронность запросов ALTER {#sinkhronnost-zaprosov-alter} + +Для нереплицируемых таблиц, все запросы `ALTER` выполняются синхронно. Для реплицируемых таблиц, запрос всего лишь добавляет инструкцию по соответствующим действиям в `ZooKeeper`, а сами действия осуществляются при первой возможности. Но при этом, запрос может ждать завершения выполнения этих действий на всех репликах. + +Для запросов `ALTER ... ATTACH|DETACH|DROP` можно настроить ожидание, с помощью настройки `replication_alter_partitions_sync`. +Возможные значения: `0` - не ждать, `1` - ждать выполнения только у себя (по умолчанию), `2` - ждать всех. + +### Мутации {#alter-mutations} + +Мутации - разновидность запроса ALTER, позволяющая изменять или удалять данные в таблице. В отличие от стандартных запросов `DELETE` и `UPDATE`, рассчитанных на точечное изменение данных, область применения мутаций - достаточно тяжёлые изменения, затрагивающие много строк в таблице. Поддержана для движков таблиц семейства `MergeTree`, в том числе для движков с репликацией. + +Конвертировать существующие таблицы для работы с мутациями не нужно. Но после применения первой мутации формат данных таблицы становится несовместимым с предыдущими версиями и откатиться на предыдущую версию уже не получится. + +На данный момент доступны команды: + +``` sql +ALTER TABLE [db.]table DELETE WHERE filter_expr +``` + +Выражение `filter_expr` должно иметь тип `UInt8`. Запрос удаляет строки таблицы, для которых это выражение принимает ненулевое значение. + +``` sql +ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr +``` + +Выражение `filter_expr` должно иметь тип `UInt8`. Запрос изменяет значение указанных столбцов на вычисленное значение соответствующих выражений в каждой строке, для которой `filter_expr` принимает ненулевое значение. Вычисленные значения преобразуются к типу столбца с помощью оператора `CAST`. Изменение столбцов, которые используются при вычислении первичного ключа или ключа партиционирования, не поддерживается. + +``` sql +ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name +``` + +Команда перестроит вторичный индекс `name` для партиции `partition_name`. + +В одном запросе можно указать несколько команд через запятую. + +Для \*MergeTree-таблиц мутации выполняются, перезаписывая данные по кускам (parts). При этом атомарности нет — куски заменяются на помутированные по мере выполнения и запрос `SELECT`, заданный во время выполнения мутации, увидит данные как из измененных кусков, так и из кусков, которые еще не были изменены. + +Мутации линейно упорядочены между собой и накладываются на каждый кусок в порядке добавления. Мутации также упорядочены со вставками - гарантируется, что данные, вставленные в таблицу до начала выполнения запроса мутации, будут изменены, а данные, вставленные после окончания запроса мутации, изменены не будут. При этом мутации никак не блокируют вставки. + +Запрос завершается немедленно после добавления информации о мутации (для реплицированных таблиц - в ZooKeeper, для нереплицированных - на файловую систему). Сама мутация выполняется асинхронно, используя настройки системного профиля. Следить за ходом её выполнения можно по таблице [`system.mutations`](../../operations/system-tables.md#system_tables-mutations). Добавленные мутации будут выполняться до конца даже в случае перезапуска серверов ClickHouse. Откатить мутацию после её добавления нельзя, но если мутация по какой-то причине не может выполниться до конца, её можно остановить с помощью запроса [`KILL MUTATION`](misc.md#kill-mutation-statement). + +Записи о последних выполненных мутациях удаляются не сразу (количество сохраняемых мутаций определяется параметром движка таблиц `finished_mutations_to_keep`). Более старые записи удаляются. + +## ALTER USER {#alter-user-statement} + +Изменяет аккаунт пользователя ClickHouse. + +### Синтаксис {#alter-user-syntax} + +``` sql +ALTER USER [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}] + [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### Описание {#alter-user-dscr} + +Для выполнения `ALTER USER` необходима привилегия [ALTER USER](grant.md#grant-access-management). + +### Примеры {#alter-user-examples} + +Установить ролями по умолчанию роли, назначенные пользователю: + +``` sql +ALTER USER user DEFAULT ROLE role1, role2 +``` + +Если роли не были назначены пользователю, ClickHouse выбрасывает исключение. + +Установить ролями по умолчанию все роли, назначенные пользователю: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +Если роль будет впоследствии назначена пользователю, она автоматически станет ролью по умолчанию. + +Установить ролями по умолчанию все назначенные пользователю роли кроме `role1` и `role2`: + +``` sql +ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2 +``` + + +## ALTER ROLE {#alter-role-statement} + +Изменяет роль. + +### Синтаксис {#alter-role-syntax} + +``` sql +ALTER ROLE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + + +## ALTER ROW POLICY {#alter-row-policy-statement} + +Изменяет политику доступа к строкам. + +### Синтаксис {#alter-row-policy-syntax} + +``` sql +ALTER [ROW] POLICY [IF EXISTS] name [ON CLUSTER cluster_name] ON [database.]table + [RENAME TO new_name] + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING {condition | NONE}][,...] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + + +## ALTER QUOTA {#alter-quota-statement} + +Изменяет квоту. + +### Синтаксис {#alter-quota-syntax} + +``` sql +ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + + +## ALTER SETTINGS PROFILE {#alter-settings-profile-statement} + +Изменяет профили настроек. + +### Синтаксис {#alter-settings-profile-syntax} + +``` sql +ALTER SETTINGS PROFILE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + + + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/alter/) diff --git a/docs/ru/sql-reference/statements/create.md b/docs/ru/sql-reference/statements/create.md new file mode 100644 index 00000000000..70544c57dfd --- /dev/null +++ b/docs/ru/sql-reference/statements/create.md @@ -0,0 +1,507 @@ +--- +toc_priority: 35 +toc_title: CREATE +--- + +## CREATE DATABASE {#query-language-create-database} + +Создает базу данных. + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] +``` + +### Секции {#sektsii} + +- `IF NOT EXISTS` + + Если база данных с именем `db_name` уже существует, то ClickHouse не создаёт базу данных и: + - Не генерирует исключение, если секция указана. + - Генерирует исключение, если секция не указана. + +- `ON CLUSTER` + + ClickHouse создаёт базу данных `db_name` на всех серверах указанного кластера. + +- `ENGINE` + + - [MySQL](../../sql_reference/statements/create.md) + + Позволяет получать данные с удаленного сервера MySQL. + + По умолчанию ClickHouse использует собственный [движок баз данных](../../sql_reference/statements/create.md). + +## CREATE TABLE {#create-table-query} + +Запрос `CREATE TABLE` может иметь несколько форм. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], + ... +) ENGINE = engine +``` + +Создаёт таблицу с именем name в БД db или текущей БД, если db не указана, со структурой, указанной в скобках, и движком engine. +Структура таблицы представляет список описаний столбцов. Индексы, если поддерживаются движком, указываются в качестве параметров для движка таблицы. + +Описание столбца, это `name type`, в простейшем случае. Пример: `RegionID UInt32`. +Также могут быть указаны выражения для значений по умолчанию - смотрите ниже. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] +``` + +Создаёт таблицу с такой же структурой, как другая таблица. Можно указать другой движок для таблицы. Если движок не указан, то будет выбран такой же движок, как у таблицы `db2.name2`. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() +``` + +Создаёт таблицу с такой же структурой и данными, как результат соответствующей табличной функцией. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... +``` + +Создаёт таблицу со структурой, как результат запроса `SELECT`, с движком engine, и заполняет её данными из SELECT-а. + +Во всех случаях, если указано `IF NOT EXISTS`, то запрос не будет возвращать ошибку, если таблица уже существует. В этом случае, запрос будет ничего не делать. + +После секции `ENGINE` в запросе могут использоваться и другие секции в зависимости от движка. Подробную документацию по созданию таблиц смотрите в описаниях [движков таблиц](../../sql-reference/statements/create.md#table_engines). + +### Значения по умолчанию {#create-default-values} + +В описании столбца, может быть указано выражение для значения по умолчанию, одного из следующих видов: +`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. +Пример: `URLDomain String DEFAULT domain(URL)`. + +Если выражение для значения по умолчанию не указано, то в качестве значений по умолчанию будут использоваться нули для чисел, пустые строки для строк, пустые массивы для массивов, а также `0000-00-00` для дат и `0000-00-00 00:00:00` для дат с временем. NULL-ы не поддерживаются. + +В случае, если указано выражение по умолчанию, то указание типа столбца не обязательно. При отсутствии явно указанного типа, будет использован тип выражения по умолчанию. Пример: `EventDate DEFAULT toDate(EventTime)` - для столбца EventDate будет использован тип Date. + +При наличии явно указанного типа данных и выражения по умолчанию, это выражение будет приводиться к указанному типу с использованием функций приведения типа. Пример: `Hits UInt32 DEFAULT 0` - имеет такой же смысл, как `Hits UInt32 DEFAULT toUInt32(0)`. + +В качестве выражения для умолчания, может быть указано произвольное выражение от констант и столбцов таблицы. При создании и изменении структуры таблицы, проверяется, что выражения не содержат циклов. При INSERT-е проверяется разрешимость выражений - что все столбцы, из которых их можно вычислить, переданы. + +`DEFAULT expr` + +Обычное значение по умолчанию. Если в запросе INSERT не указан соответствующий столбец, то он будет заполнен путём вычисления соответствующего выражения. + +`MATERIALIZED expr` + +Материализованное выражение. Такой столбец не может быть указан при INSERT, то есть, он всегда вычисляется. +При INSERT без указания списка столбцов, такие столбцы не рассматриваются. +Также этот столбец не подставляется при использовании звёздочки в запросе SELECT. Это необходимо, чтобы сохранить инвариант, что дамп, полученный путём `SELECT *`, можно вставить обратно в таблицу INSERT-ом без указания списка столбцов. + +`ALIAS expr` + +Синоним. Такой столбец вообще не хранится в таблице. +Его значения не могут быть вставлены в таблицу, он не подставляется при использовании звёздочки в запросе SELECT. +Он может быть использован в SELECT-ах - в таком случае, во время разбора запроса, алиас раскрывается. + +При добавлении новых столбцов с помощью запроса ALTER, старые данные для этих столбцов не записываются. Вместо этого, при чтении старых данных, для которых отсутствуют значения новых столбцов, выполняется вычисление выражений по умолчанию на лету. При этом, если выполнение выражения требует использования других столбцов, не указанных в запросе, то эти столбцы будут дополнительно прочитаны, но только для тех блоков данных, для которых это необходимо. + +Если добавить в таблицу новый столбец, а через некоторое время изменить его выражение по умолчанию, то используемые значения для старых данных (для данных, где значения не хранились на диске) поменяются. Также заметим, что при выполнении фоновых слияний, данные для столбцов, отсутствующих в одном из сливаемых кусков, записываются в объединённый кусок. + +Отсутствует возможность задать значения по умолчанию для элементов вложенных структур данных. + +### Ограничения (constraints) {#constraints} + +Наряду с объявлением столбцов можно объявить ограничения на значения в столбцах таблицы: + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + ... + CONSTRAINT constraint_name_1 CHECK boolean_expr_1, + ... +) ENGINE = engine +``` + +`boolean_expr_1` может быть любым булевым выражением, состоящим из операторов сравнения или функций. При наличии одного или нескольких ограничений в момент вставки данных выражения ограничений будут проверяться на истинность для каждой вставляемой строки данных. В случае, если в теле INSERT запроса придут некорректные данные — клиент получит исключение с описанием нарушенного ограничения. + +Добавление большого числа ограничений может негативно повлиять на производительность `INSERT` запросов. + +### Выражение для TTL {#vyrazhenie-dlia-ttl} + +Определяет время хранения значений. Может быть указано только для таблиц семейства MergeTree. Подробнее смотрите в [TTL для столбцов и таблиц](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). + +### Кодеки сжатия столбцов {#codecs} + +По умолчанию, ClickHouse применяет к столбцу метод сжатия, определённый в [конфигурации сервера](../../sql-reference/statements/create.md#compression). Кроме этого, можно задать метод сжатия для каждого отдельного столбца в запросе `CREATE TABLE`. + +``` sql +CREATE TABLE codec_example +( + dt Date CODEC(ZSTD), + ts DateTime CODEC(LZ4HC), + float_value Float32 CODEC(NONE), + double_value Float64 CODEC(LZ4HC(9)) + value Float32 CODEC(Delta, ZSTD) +) +ENGINE = +... +``` + +Если задать кодек для столбца, то кодек по умолчанию не применяется. Кодеки можно последовательно комбинировать, например, `CODEC(Delta, ZSTD)`. Чтобы выбрать наиболее подходящую для вашего проекта комбинацию кодеков, необходимо провести сравнительные тесты, подобные тем, что описаны в статье Altinity [New Encodings to Improve ClickHouse Efficiency](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse). + +!!! warning "Предупреждение" + Нельзя распаковать базу данных ClickHouse с помощью сторонних утилит наподобие `lz4`. Необходимо использовать специальную утилиту [clickhouse-compressor](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor). + +Сжатие поддерживается для следующих движков таблиц: + +- [MergeTree family](../../sql-reference/statements/create.md) +- [Log family](../../sql-reference/statements/create.md) +- [Set](../../sql-reference/statements/create.md) +- [Join](../../sql-reference/statements/create.md) + +ClickHouse поддерживает кодеки общего назначения и специализированные кодеки. + +#### Специализированные кодеки {#create-query-specialized-codecs} + +Эти кодеки разработаны для того, чтобы, используя особенности данных сделать сжатие более эффективным. Некоторые из этих кодеков не сжимают данные самостоятельно. Они готовят данные для кодеков общего назначения, которые сжимают подготовленные данные эффективнее, чем неподготовленные. + +Специализированные кодеки: + +- `Delta(delta_bytes)` — Метод, в котором исходные значения заменяются разностью двух соседних значений, за исключением первого значения, которое остаётся неизменным. Для хранения разниц используется до `delta_bytes`, т.е. `delta_bytes` — это максимальный размер исходных данных. Возможные значения `delta_bytes`: 1, 2, 4, 8. Значение по умолчанию для `delta_bytes` равно `sizeof(type)`, если результат 1, 2, 4, or 8. Во всех других случаях — 1. +- `DoubleDelta` — Вычисляется разницу от разниц и сохраняет её в компакном бинарном виде. Оптимальная степень сжатия достигается для монотонных последовательностей с постоянным шагом, наподобие временных рядов. Можно использовать с любым типом данных фиксированного размера. Реализует алгоритм, используемый в TSDB Gorilla, поддерживает 64-битные типы данных. Использует 1 дополнительный бит для 32-байтовых значений: 5-битные префиксы вместо 4-битных префиксов. Подробнее читайте в разделе «Compressing Time Stamps» документа [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `Gorilla` — Вычисляет XOR между текущим и предыдущим значением и записывает результат в компактной бинарной форме. Еффективно сохраняет ряды медленно изменяющихся чисел с плавающей запятой, поскольку наилучший коэффициент сжатия достигается, если соседние значения одинаковые. Реализует алгоритм, используемый в TSDB Gorilla, адаптируя его для работы с 64-битными значениями. Подробнее читайте в разделе «Compressing Values» документа [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `T64` — Метод сжатия который обрезает неиспользуемые старшие биты целочисленных значений (включая `Enum`, `Date` и `DateTime`). На каждом шаге алгоритма, кодек помещает блок из 64 значений в матрицу 64✕64, транспонирует её, обрезает неиспользуемые биты, а то, что осталось возвращает в виде последовательности. Неиспользуемые биты, это биты, которые не изменяются от минимального к максимальному на всём диапазоне значений куска данных. + +Кодеки `DoubleDelta` и `Gorilla` используются в TSDB Gorilla как компоненты алгоритма сжатия. Подход Gorilla эффективен в сценариях, когда данные представляют собой медленно изменяющиеся во времени величины. Метки времени эффективно сжимаются кодеком `DoubleDelta`, а значения кодеком `Gorilla`. Например, чтобы создать эффективно хранящуюся таблицу, используйте следующую конфигурацию: + +``` sql +CREATE TABLE codec_example +( + timestamp DateTime CODEC(DoubleDelta), + slow_values Float32 CODEC(Gorilla) +) +ENGINE = MergeTree() +``` + +#### Кодеки общего назначения {#create-query-common-purpose-codecs} + +Кодеки: + +- `NONE` — без сжатия. +- `LZ4` — [алгоритм сжатия без потерь](https://github.com/lz4/lz4) используемый по умолчанию. Применяет быстрое сжатие LZ4. +- `LZ4HC[(level)]` — алгоритм LZ4 HC (high compression) с настраиваемым уровнем сжатия. Уровень по умолчанию — 9. Настройка `level <= 0` устанавливает уровень сжания по умолчанию. Возможные уровни сжатия: \[1, 12\]. Рекомендуемый диапазон уровней: \[4, 9\]. +- `ZSTD[(level)]` — [алгоритм сжатия ZSTD](https://en.wikipedia.org/wiki/Zstandard) с настраиваемым уровнем сжатия `level`. Возможные уровни сжатия: \[1, 22\]. Уровень сжатия по умолчанию: 1. + +Высокие уровни сжатия полезны для ассимметричных сценариев, подобных «один раз сжал, много раз распаковал». Высокие уровни сжатия подразумеваю лучшее сжатие, но большее использование CPU. + +## Временные таблицы {#vremennye-tablitsy} + +ClickHouse поддерживает временные таблицы со следующими характеристиками: + +- Временные таблицы исчезают после завершения сессии, в том числе при обрыве соединения. +- Временная таблица использует только модуль памяти. +- Невозможно указать базу данных для временной таблицы. Она создается вне баз данных. +- Невозможно создать временную таблицу распределнным DDL запросом на всех серверах кластера (с опцией `ON CLUSTER`): такая таблица существует только в рамках существующей сессии. +- Если временная таблица имеет то же имя, что и некоторая другая, то, при упоминании в запросе без указания БД, будет использована временная таблица. +- При распределённой обработке запроса, используемые в запросе временные таблицы, передаются на удалённые серверы. + +Чтобы создать временную таблицу, используйте следующий синтаксис: + +``` sql +CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) +``` + +В большинстве случаев, временные таблицы создаются не вручную, а при использовании внешних данных для запроса, или при распределённом `(GLOBAL) IN`. Подробнее см. соответствующие разделы + +Вместо временных можно использовать обычные таблицы с [ENGINE = Memory](../../sql-reference/statements/create.md). + +## Распределенные DDL запросы (секция ON CLUSTER) {#raspredelennye-ddl-zaprosy-sektsiia-on-cluster} + +Запросы `CREATE`, `DROP`, `ALTER`, `RENAME` поддерживают возможность распределенного выполнения на кластере. +Например, следующий запрос создает распределенную (Distributed) таблицу `all_hits` на каждом хосте в `cluster`: + +``` sql +CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) +``` + +Для корректного выполнения таких запросов необходимо на каждом хосте иметь одинаковое определение кластера (для упрощения синхронизации конфигов можете использовать подстановки из ZooKeeper). Также необходимо подключение к ZooKeeper серверам. +Локальная версия запроса в конечном итоге будет выполнена на каждом хосте кластера, даже если некоторые хосты в данный момент не доступны. Гарантируется упорядоченность выполнения запросов в рамках одного хоста. + +## CREATE VIEW {#create-view} + +``` sql +CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... +``` + +Создаёт представление. Представления бывают двух видов - обычные и материализованные (MATERIALIZED). + +Обычные представления не хранят никаких данных, а всего лишь производят чтение из другой таблицы. То есть, обычное представление - не более чем сохранённый запрос. При чтении из представления, этот сохранённый запрос, используется в качестве подзапроса в секции FROM. + +Для примера, пусть вы создали представление: + +``` sql +CREATE VIEW view AS SELECT ... +``` + +и написали запрос: + +``` sql +SELECT a, b, c FROM view +``` + +Этот запрос полностью эквивалентен использованию подзапроса: + +``` sql +SELECT a, b, c FROM (SELECT ...) +``` + +Материализованные (MATERIALIZED) представления хранят данные, преобразованные соответствующим запросом SELECT. + +При создании материализованного представления без использования `TO [db].[table]`, нужно обязательно указать ENGINE - движок таблицы для хранения данных. + +При создании материализованного представления с испольованием `TO [db].[table]`, нельзя указывать `POPULATE` + +Материализованное представление устроено следующим образом: при вставке данных в таблицу, указанную в SELECT-е, кусок вставляемых данных преобразуется этим запросом SELECT, и полученный результат вставляется в представление. + +Если указано POPULATE, то при создании представления, в него будут вставлены имеющиеся данные таблицы, как если бы был сделан запрос `CREATE TABLE ... AS SELECT ...` . Иначе, представление будет содержать только данные, вставляемые в таблицу после создания представления. Не рекомендуется использовать POPULATE, так как вставляемые в таблицу данные во время создания представления, не попадут в него. + +Запрос `SELECT` может содержать `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Следует иметь ввиду, что соответствующие преобразования будут выполняться независимо, на каждый блок вставляемых данных. Например, при наличии `GROUP BY`, данные будут агрегироваться при вставке, но только в рамках одной пачки вставляемых данных. Далее, данные не будут доагрегированы. Исключение - использование ENGINE, производящего агрегацию данных самостоятельно, например, `SummingMergeTree`. + +Недоработано выполнение запросов `ALTER` над материализованными представлениями, поэтому они могут быть неудобными для использования. Если материализованное представление использует конструкцию `TO [db.]name`, то можно выполнить `DETACH` представления, `ALTER` для целевой таблицы и последующий `ATTACH` ранее отсоединенного (`DETACH`) представления. + +Представления выглядят так же, как обычные таблицы. Например, они перечисляются в результате запроса `SHOW TABLES`. + +Отсутствует отдельный запрос для удаления представлений. Чтобы удалить представление, следует использовать `DROP TABLE`. + +## CREATE DICTIONARY {#create-dictionary-query} + +``` sql +CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] +( + key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + attr1 type2 [DEFAULT|EXPRESSION expr3], + attr2 type2 [DEFAULT|EXPRESSION expr4] +) +PRIMARY KEY key1, key2 +SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) +LAYOUT(LAYOUT_NAME([param_name param_value])) +LIFETIME([MIN val1] MAX val2) +``` + +Создаёт [внешний словарь](../../sql-reference/statements/create.md) с заданной [структурой](../../sql-reference/statements/create.md), [источником](../../sql-reference/statements/create.md), [способом размещения в памяти](../../sql-reference/statements/create.md) и [периодом обновления](../../sql-reference/statements/create.md). + +Структура внешнего словаря состоит из атрибутов. Атрибуты словаря задаются как столбцы таблицы. Единственным обязательным свойством атрибута является его тип, все остальные свойства могут иметь значения по умолчанию. + +В зависимости от [способа размещения словаря в памяти](../../sql-reference/statements/create.md), ключами словаря могут быть один и более атрибутов. + +Смотрите [Внешние словари](../../sql-reference/statements/create.md). + +## CREATE USER {#create-user-statement} + +Создает [аккаунт пользователя](../../operations/access-rights.md#user-account-management). + +### Синтаксис {#create-user-syntax} + +```sql +CREATE USER [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [IDENTIFIED [WITH {NO_PASSWORD|PLAINTEXT_PASSWORD|SHA256_PASSWORD|SHA256_HASH|DOUBLE_SHA1_PASSWORD|DOUBLE_SHA1_HASH}] BY {'password'|'hash'}] + [HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...]] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +#### Идентификация + +Существует несколько способов идентификации пользователя: + +- `IDENTIFIED WITH no_password` +- `IDENTIFIED WITH plaintext_password BY 'qwerty'` +- `IDENTIFIED WITH sha256_password BY 'qwerty'` or `IDENTIFIED BY 'password'` +- `IDENTIFIED WITH sha256_hash BY 'hash'` +- `IDENTIFIED WITH double_sha1_password BY 'qwerty'` +- `IDENTIFIED WITH double_sha1_hash BY 'hash'` + +#### Пользовательский хост + +Пользовательский хост — это хост, с которого можно установить соединение с сервером ClickHouse. Хост задается в секции `HOST` следующими способами: + +- `HOST IP 'ip_address_or_subnetwork'` — Пользователь может подключиться к серверу ClickHouse только с указанного IP-адреса или [подсети](https://ru.wikipedia.org/wiki/Подсеть). Примеры: `HOST IP '192.168.0.0/16'`, `HOST IP '2001:DB8::/32'`. При использовании в эксплуатации указывайте только элементы `HOST IP` (IP-адреса и маски подсети), так как использование `host` и `host_regexp` может привести к дополнительной задержке. +- `HOST ANY` — Пользователь может подключиться с любого хоста. Используется по умолчанию. +- `HOST LOCAL` — Пользователь может подключиться только локально. +- `HOST NAME 'fqdn'` — Хост задается через FQDN. Например, `HOST NAME 'mysite.com'`. +- `HOST NAME REGEXP 'regexp'` — Позволяет использовать регулярные выражения [pcre](http://www.pcre.org/), чтобы задать хосты. Например, `HOST NAME REGEXP '.*\.mysite\.com'`. +- `HOST LIKE 'template'` — Позволяет использовать оператор [LIKE](../functions/string-search-functions.md#function-like) для фильтрации хостов. Например, `HOST LIKE '%'` эквивалентен `HOST ANY`; `HOST LIKE '%.mysite.com'` разрешает подключение со всех хостов в домене `mysite.com`. + +Также, чтобы задать хост, вы можете использовать `@` вместе с именем пользователя. Примеры: + +- `CREATE USER mira@'127.0.0.1'` — Эквивалентно `HOST IP`. +- `CREATE USER mira@'localhost'` — Эквивалентно `HOST LOCAL`. +- `CREATE USER mira@'192.168.%.%'` — Эквивалентно `HOST LIKE`. + +!!! info "Внимание" + ClickHouse трактует конструкцию `user_name@'address'` как имя пользователя целиком. То есть технически вы можете создать несколько пользователей с одинаковыми `user_name`, но разными частями конструкции после `@`, но лучше так не делать. + + +### Примеры {#create-user-examples} + + +Создать аккаунт `mira`, защищенный паролем `qwerty`: + +```sql +CREATE USER mira HOST IP '127.0.0.1' IDENTIFIED WITH sha256_password BY 'qwerty' +``` + +Пользователь `mira` должен запустить клиентское приложение на хосте, где запущен ClickHouse. + +Создать аккаунт `john`, назначить на него роли, сделать данные роли ролями по умолчанию: + +``` sql +CREATE USER john DEFAULT ROLE role1, role2 +``` + +Создать аккаунт `john` и установить ролями по умолчанию все его будущие роли: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +Когда роль будет назначена аккаунту `john`, она автоматически станет ролью по умолчанию. + +Создать аккаунт `john` и установить ролями по умолчанию все его будущие роли, кроме `role1` и `role2`: + +``` sql +ALTER USER john DEFAULT ROLE ALL EXCEPT role1, role2 +``` + + +## CREATE ROLE {#create-role-statement} + +Создает [роль](../../operations/access-rights.md#role-management). + +### Синтаксис {#create-role-syntax} + +```sql +CREATE ROLE [IF NOT EXISTS | OR REPLACE] name + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### Описание {#create-role-description} + +Роль — это набор [привилегий](grant.md#grant-privileges). Пользователь, которому назначена роль, получает все привилегии этой роли. + +Одному пользователю можно назначить несколько ролей. Пользователи могут применять назначенные роли в произвольных комбинациях с помощью выражения [SET ROLE](misc.md#set-role-statement). Конечный объем привилегий — это комбинация всех привилегий всех примененных ролей. Если у пользователя имеются привилегии, присвоенные его аккаунту напрямую, они также прибавляются к привилегиям, присвоенным через роли. + +Роли по умолчанию применяются при входе пользователя в систему. Установить роли по умолчанию можно с помощью выражений [SET DEFAULT ROLE](misc.md#set-default-role-statement) или [ALTER USER](alter.md#alter-user-statement). + +Для отзыва роли используется выражение [REVOKE](revoke.md). + +Для удаления роли используется выражение [DROP ROLE](misc.md#drop-role-statement). Удаленная роль автоматически отзывается у всех пользователей, которым была назначена. + +### Примеры {#create-role-examples} + +```sql +CREATE ROLE accountant; +GRANT SELECT ON db.* TO accountant; +``` + +Такая последовательность запросов создаст роль `accountant`, у которой есть привилегия на чтение из базы данных `accounting`. + +Назначить роль `accountant` аккаунту `mira`: + +```sql +GRANT accountant TO mira; +``` + +После назначения роли пользователь может ее применить и выполнять разрешенные ей запросы. Например: + +```sql +SET ROLE accountant; +SELECT * FROM db.*; +``` + +## CREATE ROW POLICY {#create-row-policy-statement} + +Создает [фильтр для строк](../../operations/access-rights.md#row-policy-management), которые пользователь может прочесть из таблицы. + +### Синтаксис {#create-row-policy-syntax} + +``` sql +CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE] policy_name [ON CLUSTER cluster_name] ON [db.]table + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING condition] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +#### Секция AS {#create-row-policy-as} + +С помощью данной секции можно создать политику разрешения или ограничения. + +Политика разрешения предоставляет доступ к строкам. Разрешительные политики, которые применяются к одной таблице, объединяются с помощью логического оператора `OR`. Политики являются разрешительными по умолчанию. + +Политика ограничения запрещает доступ к строкам. Ограничительные политики, которые применяются к одной таблице, объединяются логическим оператором `AND`. + +Ограничительные политики применяются к строкам, прошедшим фильтр разрешительной политики. Если вы не зададите разрешительные политики, пользователь не сможет обращаться ни к каким строкам из таблицы. + +#### Секция TO {#create-row-policy-to} + +В секции `TO` вы можете перечислить как роли, так и пользователей. Например, `CREATE ROW POLICY ... TO accountant, john@localhost`. + +Ключевым словом `ALL` обозначаются все пользователи, включая текущего. Ключевые слова `ALL EXCEPT` позволяют исключить пользователей из списка всех пользователей. Например, `CREATE ROW POLICY ... TO ALL EXCEPT accountant, john@localhost` + +### Примеры + +- `CREATE ROW POLICY filter ON mydb.mytable FOR SELECT USING a<1000 TO accountant, john@localhost` +- `CREATE ROW POLICY filter ON mydb.mytable FOR SELECT USING a<1000 TO ALL EXCEPT mira` + + +## CREATE QUOTA {#create-quota-statement} + +Создает [квоту](../../operations/access-rights.md#quotas-management), которая может быть присвоена пользователю или роли. + +### Синтаксис {#create-quota-syntax} + +``` sql +CREATE QUOTA [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +### Пример {#create-quota-example} + +Ограничить максимальное количество запросов для текущего пользователя до 123 запросов каждые 15 месяцев: + +``` sql +CREATE QUOTA qA FOR INTERVAL 15 MONTH MAX QUERIES 123 TO CURRENT_USER +``` + + +## CREATE SETTINGS PROFILE {#create-settings-profile-statement} + +Создает [профиль настроек](../../operations/access-rights.md#settings-profiles-management), который может быть присвоен пользователю или роли. + +### Синтаксис {#create-settings-profile-syntax} + +``` sql +CREATE SETTINGS PROFILE [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + +### Пример {#create-settings-profile-syntax} + +Создать профиль настроек `max_memory_usage_profile`, который содержит значение и ограничения для настройки `max_memory_usage`. Присвоить профиль пользователю `robin`: + +``` sql +CREATE SETTINGS PROFILE max_memory_usage_profile SETTINGS max_memory_usage = 100000001 MIN 90000000 MAX 110000000 TO robin +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/create/) diff --git a/docs/ru/sql-reference/statements/grant.md b/docs/ru/sql-reference/statements/grant.md new file mode 100644 index 00000000000..a328975ec12 --- /dev/null +++ b/docs/ru/sql-reference/statements/grant.md @@ -0,0 +1,479 @@ +# GRANT + +- Присваивает [привилегии](#grant-privileges) пользователям или ролям ClickHouse. +- Назначает роли пользователям или другим ролям. + +Отозвать привилегию можно с помощью выражения [REVOKE](revoke.md). Чтобы вывести список присвоенных привилегий, воспользуйтесь выражением [SHOW GRANTS](show.md#show-grants-statement). + +## Синтаксис присвоения привилегий {#grant-privigele-syntax} + +```sql +GRANT [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*} TO {user | role | CURRENT_USER} [,...] [WITH GRANT OPTION] +``` + +- `privilege` — Тип привилегии +- `role` — Роль пользователя ClickHouse. +- `user` — Пользователь ClickHouse. + +`WITH GRANT OPTION` разрешает пользователю или роли выполнять запрос `GRANT`. Пользователь может выдавать только те привилегии, которые есть у него, той же или меньшей области действий. + + +## Синтаксис назначения ролей {#assign-role-syntax} + +```sql +GRANT [ON CLUSTER cluster_name] role [,...] TO {user | another_role | CURRENT_USER} [,...] [WITH ADMIN OPTION] +``` + +- `role` — Роль пользователя ClickHouse. +- `user` — Пользователь ClickHouse. + +`WITH ADMIN OPTION` присваивает привилегию [ADMIN OPTION](#admin-option-privilege) пользователю или роли. + +## Использование {#grant-usage} + +Для использования `GRANT` пользователь должен иметь привилегию `GRANT OPTION`. Пользователь может выдавать привилегии только внутри области действий назначенных ему самому привилегий. + +Например, администратор выдал привилегию пользователю `john`: + +```sql +GRANT SELECT(x,y) ON db.table TO john WITH GRANT OPTION +``` + +Это означает, что пользователю `john` разрешено выполнять: + +- `SELECT x,y FROM db.table`. +- `SELECT x FROM db.table`. +- `SELECT y FROM db.table`. + +`john` не может выполнить `SELECT z FROM db.table` или `SELECT * FROM db.table`. После обработки данных запросов ClickHouse ничего не вернет — даже `x` или `y`. Единственное исключение — если таблица содержит только столбцы `x` и `y`. В таком случае ClickHouse вернет все данные. + +Также у `john` есть привилегия `GRANT OPTION`. `john` может выдать другим пользователям привилегии той же или меньшей области действий из тех, которые есть у него. + +При присвоении привилегий допускается использовать астериск (`*`) вместо имени таблицы или базы данных. Например, запрос `GRANT SELECT ON db.* TO john` позволит пользователю `john` выполнять `SELECT` над всеми таблицам в базе данных `db`. Также вы можете опускать имя базы данных. В таком случае привилегии позволят совершать операции над текущей базой данных. Например, запрос `GRANT SELECT ON * TO john` выдаст привилегию на выполнение `SELECT` над всеми таблицами в текущей базе данных; `GRANT SELECT ON mytable TO john` — только над таблицей `mytable` в текущей базе данных. + +Доступ к базе данных `system` разрешен всегда (данная база данных используется при обработке запросов). + +Вы можете присвоить несколько привилегий нескольким пользователям в одном запросе. Запрос `GRANT SELECT, INSERT ON *.* TO john, robin` позволит пользователям `john` и `robin` выполнять `INSERT` и `SELECT` над всеми таблицами всех баз данных на сервере. + + +## Привилегии {#grant-privileges} + +Привилегия — это разрешение на выполнение определенного типа запросов. + +Привилегии имеют иерархическую структуру. Набор разрешенных запросов зависит от области действия привилегии. + +Иерархия привилегий: + +- [SELECT](#grant-select) +- [INSERT](#grant-insert) +- [ALTER](#grant-alter) + - `ALTER TABLE` + - `ALTER UPDATE` + - `ALTER DELETE` + - `ALTER COLUMN` + - `ALTER ADD COLUMN` + - `ALTER DROP COLUMN` + - `ALTER MODIFY COLUMN` + - `ALTER COMMENT COLUMN` + - `ALTER CLEAR COLUMN` + - `ALTER RENAME COLUMN` + - `ALTER INDEX` + - `ALTER ORDER BY` + - `ALTER ADD INDEX` + - `ALTER DROP INDEX` + - `ALTER MATERIALIZE INDEX` + - `ALTER CLEAR INDEX` + - `ALTER CONSTRAINT` + - `ALTER ADD CONSTRAINT` + - `ALTER DROP CONSTRAINT` + - `ALTER TTL` + - `ALTER MATERIALIZE TTL` + - `ALTER SETTINGS` + - `ALTER MOVE PARTITION` + - `ALTER FETCH PARTITION` + - `ALTER FREEZE PARTITION` + - `ALTER VIEW` + - `ALTER VIEW REFRESH ` + - `ALTER VIEW MODIFY QUERY` +- [CREATE](#grant-create) + - `CREATE DATABASE` + - `CREATE TABLE` + - `CREATE VIEW` + - `CREATE DICTIONARY` + - `CREATE TEMPORARY TABLE` +- [DROP](#grant-drop) + - `DROP DATABASE` + - `DROP TABLE` + - `DROP VIEW` + - `DROP DICTIONARY` +- [TRUNCATE](#grant-truncate) +- [OPTIMIZE](#grant-optimize) +- [SHOW](#grant-show) + - `SHOW DATABASES` + - `SHOW TABLES` + - `SHOW COLUMNS` + - `SHOW DICTIONARIES` +- [KILL QUERY](#grant-kill-query) +- [ACCESS MANAGEMENT](#grant-access-management) + - `CREATE USER` + - `ALTER USER` + - `DROP USER` + - `CREATE ROLE` + - `ALTER ROLE` + - `DROP ROLE` + - `CREATE ROW POLICY` + - `ALTER ROW POLICY` + - `DROP ROW POLICY` + - `CREATE QUOTA` + - `ALTER QUOTA` + - `DROP QUOTA` + - `CREATE SETTINGS PROFILE` + - `ALTER SETTINGS PROFILE` + - `DROP SETTINGS PROFILE` + - `SHOW ACCESS` + - `SHOW_USERS` + - `SHOW_ROLES` + - `SHOW_ROW_POLICIES` + - `SHOW_QUOTAS` + - `SHOW_SETTINGS_PROFILES` + - `ROLE ADMIN` +- [SYSTEM](#grant-system) + - `SYSTEM SHUTDOWN` + - `SYSTEM DROP CACHE` + - `SYSTEM DROP DNS CACHE` + - `SYSTEM DROP MARK CACHE` + - `SYSTEM DROP UNCOMPRESSED CACHE` + - `SYSTEM RELOAD` + - `SYSTEM RELOAD CONFIG` + - `SYSTEM RELOAD DICTIONARY` + - `SYSTEM RELOAD EMBEDDED DICTIONARIES` + - `SYSTEM MERGES` + - `SYSTEM TTL MERGES` + - `SYSTEM FETCHES` + - `SYSTEM MOVES` + - `SYSTEM SENDS` + - `SYSTEM DISTRIBUTED SENDS` + - `SYSTEM REPLICATED SENDS` + - `SYSTEM REPLICATION QUEUES` + - `SYSTEM SYNC REPLICA` + - `SYSTEM RESTART REPLICA` + - `SYSTEM FLUSH` + - `SYSTEM FLUSH DISTRIBUTED` + - `SYSTEM FLUSH LOGS` +- [INTROSPECTION](#grant-introspection) + - `addressToLine` + - `addressToSymbol` + - `demangle` +- [SOURCES](#grant-sources) + - `FILE` + - `URL` + - `REMOTE` + - `YSQL` + - `ODBC` + - `JDBC` + - `HDFS` + - `S3` +- [dictGet](#grant-dictget) + +Примеры того, как трактуется данная иерархия: + +- Привилегия `ALTER` включает все остальные `ALTER*` привилегии. +- `ALTER CONSTRAINT` включает `ALTER ADD CONSTRAINT` и `ALTER DROP CONSTRAINT`. + +Привилегии применяются на разных уровнях. Уровень определяет синтаксис присваивания привилегии. + +Уровни (от низшего к высшему): + +- `COLUMN` — Привилегия присваивается для столбца, таблицы, базы данных или глобально. +- `TABLE` — Привилегия присваивается для таблицы, базы данных или глобально. +- `VIEW` — Привилегия присваивается для представления, базы данных или глобально. +- `DICTIONARY` — Привилегия присваивается для словаря, базы данных или глобально. +- `DATABASE` — Привилегия присваивается для базы данных или глобально. +- `GLOBAL` — Привилегия присваивается только глобально. +- `GROUP` — Группирует привилегии разных уровней. При присвоении привилегии уровня `GROUP` присваиваются только привилегии из группы в соответствии с используемым синтаксисом. + +Примеры допустимого синтаксиса: + +- `GRANT SELECT(x) ON db.table TO user` +- `GRANT SELECT ON db.* TO user` + +Примеры недопустимого синтаксиса: + +- `GRANT CREATE USER(x) ON db.table TO user` +- `GRANT CREATE USER ON db.* TO user` + +Специальная привилегия [ALL](#grant-all) присваивает все привилегии пользователю или роли. + +По умолчанию пользователь или роль не имеют привилегий. + +Отсутствие привилегий у пользователя или роли отображается как привилегия [NONE](#grant-none). + +Выполнение некоторых запросов требует определенного набора привилегий. Например, чтобы выполнить запрос [RENAME](misc.md#misc_operations-rename), нужны следующие привилегии: `SELECT`, `CREATE TABLE`, `INSERT` и `DROP TABLE`. + + +### SELECT {#grant-select} + +Разрешает выполнять запросы [SELECT](select/index.md). + +Уровень: `COLUMN`. + +**Описание** + +Пользователь с данной привилегией может выполнять запросы `SELECT` над определенными столбцами из определенной таблицы и базы данных. При включении в запрос других столбцов запрос ничего не вернет. + +Рассмотрим следующую привилегию: + +```sql +GRANT SELECT(x,y) ON db.table TO john +``` + +Данная привилегия позволяет пользователю `john` выполнять выборку данных из столбцов `x` и/или `y` в `db.table`, например, `SELECT x FROM db.table`. `john` не может выполнить `SELECT z FROM db.table` или `SELECT * FROM db.table`. После обработки данных запросов ClickHouse ничего не вернет — даже `x` или `y`. Единственное исключение — если таблица содержит только столбцы `x` и `y`. В таком случае ClickHouse вернет все данные. + +### INSERT {#grant-insert} + +Разрешает выполнять запросы [INSERT](insert-into.md). + +Уровень: `COLUMN`. + +**Описание** + +Пользователь с данной привилегией может выполнять запросы `INSERT` над определенными столбцами из определенной таблицы и базы данных. При включении в запрос других столбцов запрос не добавит никаких данных. + +**Пример** + +```sql +GRANT INSERT(x,y) ON db.table TO john +``` + +Присвоенная привилегия позволит пользователю `john` вставить данные в столбцы `x` и/или `y` в `db.table`. + +### ALTER {#grant-alter} + +Разрешает выполнять запросы [ALTER](alter.md) в соответствии со следующей иерархией привилегий: + +- `ALTER`. Уровень: `COLUMN`. + - `ALTER TABLE`. Уровень: `GROUP` + - `ALTER UPDATE`. Уровень: `COLUMN`. Алиасы: `UPDATE` + - `ALTER DELETE`. Уровень: `COLUMN`. Алиасы: `DELETE` + - `ALTER COLUMN`. Уровень: `GROUP` + - `ALTER ADD COLUMN`. Уровень: `COLUMN`. Алиасы: `ADD COLUMN` + - `ALTER DROP COLUMN`. Уровень: `COLUMN`. Алиасы: `DROP COLUMN` + - `ALTER MODIFY COLUMN`. Уровень: `COLUMN`. Алиасы: `MODIFY COLUMN` + - `ALTER COMMENT COLUMN`. Уровень: `COLUMN`. Алиасы: `COMMENT COLUMN` + - `ALTER CLEAR COLUMN`. Уровень: `COLUMN`. Алиасы: `CLEAR COLUMN` + - `ALTER RENAME COLUMN`. Уровень: `COLUMN`. Алиасы: `RENAME COLUMN` + - `ALTER INDEX`. Уровень: `GROUP`. Алиасы: `INDEX` + - `ALTER ORDER BY`. Уровень: `TABLE`. Алиасы: `ALTER MODIFY ORDER BY`, `MODIFY ORDER BY` + - `ALTER ADD INDEX`. Уровень: `TABLE`. Алиасы: `ADD INDEX` + - `ALTER DROP INDEX`. Уровень: `TABLE`. Алиасы: `DROP INDEX` + - `ALTER MATERIALIZE INDEX`. Уровень: `TABLE`. Алиасы: `MATERIALIZE INDEX` + - `ALTER CLEAR INDEX`. Уровень: `TABLE`. Алиасы: `CLEAR INDEX` + - `ALTER CONSTRAINT`. Уровень: `GROUP`. Алиасы: `CONSTRAINT` + - `ALTER ADD CONSTRAINT`. Уровень: `TABLE`. Алиасы: `ADD CONSTRAINT` + - `ALTER DROP CONSTRAINT`. Уровень: `TABLE`. Алиасы: `DROP CONSTRAINT` + - `ALTER TTL`. Уровень: `TABLE`. Алиасы: `ALTER MODIFY TTL`, `MODIFY TTL` + - `ALTER MATERIALIZE TTL`. Уровень: `TABLE`. Алиасы: `MATERIALIZE TTL` + - `ALTER SETTINGS`. Уровень: `TABLE`. Алиасы: `ALTER SETTING`, `ALTER MODIFY SETTING`, `MODIFY SETTING` + - `ALTER MOVE PARTITION`. Уровень: `TABLE`. Алиасы: `ALTER MOVE PART`, `MOVE PARTITION`, `MOVE PART` + - `ALTER FETCH PARTITION`. Уровень: `TABLE`. Алиасы: `FETCH PARTITION` + - `ALTER FREEZE PARTITION`. Уровень: `TABLE`. Алиасы: `FREEZE PARTITION` + - `ALTER VIEW` Уровень: `GROUP` + - `ALTER VIEW REFRESH `. Уровень: `VIEW`. Алиасы: `ALTER LIVE VIEW REFRESH`, `REFRESH VIEW` + - `ALTER VIEW MODIFY QUERY`. Уровень: `VIEW`. Алиасы: `ALTER TABLE MODIFY QUERY` + +Примеры того, как трактуется данная иерархия: + +- Привилегия `ALTER` включает все остальные `ALTER*` привилегии. +- `ALTER CONSTRAINT` включает `ALTER ADD CONSTRAINT` и `ALTER DROP CONSTRAINT`. + +**Дополнительно** + +- Привилегия `MODIFY SETTING` позволяет изменять настройки движков таблиц. Не влияет на настройки или конфигурационные параметры сервера. +- Операция `ATTACH` требует наличие привилегии [CREATE](#grant-create). +- Операция `DETACH` требует наличие привилегии [DROP](#grant-drop). +- Для остановки мутации с помощью [KILL MUTATION](misc.md#kill-mutation-statement), необходима привилегия на выполнение данной мутации. Например, чтобы остановить запрос `ALTER UPDATE`, необходима одна из привилегий: `ALTER UPDATE`, `ALTER TABLE` или `ALTER`. + +### CREATE {#grant-create} + +Разрешает выполнять DDL-запросы [CREATE](create.md) и [ATTACH](misc.md#attach) в соответствии со следующей иерархией привилегий: + +- `CREATE`. Уровень: `GROUP` + - `CREATE DATABASE`. Уровень: `DATABASE` + - `CREATE TABLE`. Уровень: `TABLE` + - `CREATE VIEW`. Уровень: `VIEW` + - `CREATE DICTIONARY`. Уровень: `DICTIONARY` + - `CREATE TEMPORARY TABLE`. Уровень: `GLOBAL` + +**Дополнительно** + +- Для удаления созданной таблицы пользователю необходима привилегия [DROP](#grant-drop). + +### DROP {#grant-drop} + +Разрешает выполнять запросы [DROP](misc.md#drop) и [DETACH](misc.md#detach-statement) в соответствии со следующей иерархией привилегий: + +- `DROP`. Уровень: + - `DROP DATABASE`. Уровень: `DATABASE` + - `DROP TABLE`. Уровень: `TABLE` + - `DROP VIEW`. Уровень: `VIEW` + - `DROP DICTIONARY`. Уровень: `DICTIONARY` + + +### TRUNCATE {#grant-truncate} + +Разрешает выполнять запросы [TRUNCATE](misc.md#truncate-statement). + +Уровень: `TABLE`. + +### OPTIMIZE {#grant-optimize} + +Разрешает выполнять запросы [OPTIMIZE TABLE](misc.md#misc_operations-optimize). + +Уровень: `TABLE`. + +### SHOW {#grant-show} + +Разрешает выполнять запросы `SHOW`, `DESCRIBE`, `USE` и `EXISTS` в соответствии со следующей иерархией привилегий: + +- `SHOW`. Уровень: `GROUP` + - `SHOW DATABASES`. Уровень: `DATABASE`. Разрешает выполнять запросы `SHOW DATABASES`, `SHOW CREATE DATABASE`, `USE `. + - `SHOW TABLES`. Уровень: `TABLE`. Разрешает выполнять запросы `SHOW TABLES`, `EXISTS `, `CHECK
`. + - `SHOW COLUMNS`. Уровень: `COLUMN`. Разрешает выполнять запросы `SHOW CREATE TABLE`, `DESCRIBE`. + - `SHOW DICTIONARIES`. Уровень: `DICTIONARY`. Разрешает выполнять запросы `SHOW DICTIONARIES`, `SHOW CREATE DICTIONARY`, `EXISTS `. + +**Дополнительно** + +У пользователя есть привилегия `SHOW`, если ему присвоена любая другая привилегия по отношению к определенной таблице, словарю или базе данных. + + +### KILL QUERY {#grant-kill-query} + +Разрешает выполнять запросы [KILL](misc.md#kill-query-statement) в соответствии со следующей иерархией привилегий: + +Уровень: `GLOBAL`. + +**Дополнительно** + +`KILL QUERY` позволяет пользователю останавливать запросы других пользователей. + + +### ACCESS MANAGEMENT {#grant-access-management} + +Разрешает пользователю выполнять запросы на управление пользователями, ролями и политиками доступа к строкам. + +- `ACCESS MANAGEMENT`. Уровень: `GROUP` + - `CREATE USER`. Уровень: `GLOBAL` + - `ALTER USER`. Уровень: `GLOBAL` + - `DROP USER`. Уровень: `GLOBAL` + - `CREATE ROLE`. Уровень: `GLOBAL` + - `ALTER ROLE`. Уровень: `GLOBAL` + - `DROP ROLE`. Уровень: `GLOBAL` + - `ROLE ADMIN`. Уровень: `GLOBAL` + - `CREATE ROW POLICY`. Уровень: `GLOBAL`. Алиасы: `CREATE POLICY` + - `ALTER ROW POLICY`. Уровень: `GLOBAL`. Алиасы: `ALTER POLICY` + - `DROP ROW POLICY`. Уровень: `GLOBAL`. Алиасы: `DROP POLICY` + - `CREATE QUOTA`. Уровень: `GLOBAL` + - `ALTER QUOTA`. Уровень: `GLOBAL` + - `DROP QUOTA`. Уровень: `GLOBAL` + - `CREATE SETTINGS PROFILE`. Уровень: `GLOBAL`. Алиасы: `CREATE PROFILE` + - `ALTER SETTINGS PROFILE`. Уровень: `GLOBAL`. Алиасы: `ALTER PROFILE` + - `DROP SETTINGS PROFILE`. Уровень: `GLOBAL`. Алиасы: `DROP PROFILE` + - `SHOW ACCESS`. Уровень: `GROUP` + - `SHOW_USERS`. Уровень: `GLOBAL`. Алиасы: `SHOW CREATE USER` + - `SHOW_ROLES`. Уровень: `GLOBAL`. Алиасы: `SHOW CREATE ROLE` + - `SHOW_ROW_POLICIES`. Уровень: `GLOBAL`. Алиасы: `SHOW POLICIES`, `SHOW CREATE ROW POLICY`, `SHOW CREATE POLICY` + - `SHOW_QUOTAS`. Уровень: `GLOBAL`. Алиасы: `SHOW CREATE QUOTA` + - `SHOW_SETTINGS_PROFILES`. Уровень: `GLOBAL`. Алиасы: `SHOW PROFILES`, `SHOW CREATE SETTINGS PROFILE`, `SHOW CREATE PROFILE` + +Привилегия `ROLE ADMIN` разрешает пользователю назначать и отзывать любые роли, включая те, которые не назначены пользователю с опцией администратора. + +### SYSTEM {#grant-system} + +Разрешает выполнять запросы [SYSTEM](system.md) в соответствии со следующей иерархией привилегий: + +- `SYSTEM`. Уровень: `GROUP` + - `SYSTEM SHUTDOWN`. Уровень: `GLOBAL`. Алиасы: `SYSTEM KILL`, `SHUTDOWN` + - `SYSTEM DROP CACHE`. Алиасы: `DROP CACHE` + - `SYSTEM DROP DNS CACHE`. Уровень: `GLOBAL`. Алиасы: `SYSTEM DROP DNS`, `DROP DNS CACHE`, `DROP DNS` + - `SYSTEM DROP MARK CACHE`. Уровень: `GLOBAL`. Алиасы: `SYSTEM DROP MARK`, `DROP MARK CACHE`, `DROP MARKS` + - `SYSTEM DROP UNCOMPRESSED CACHE`. Уровень: `GLOBAL`. Алиасы: `SYSTEM DROP UNCOMPRESSED`, `DROP UNCOMPRESSED CACHE`, `DROP UNCOMPRESSED` + - `SYSTEM RELOAD`. Уровень: `GROUP` + - `SYSTEM RELOAD CONFIG`. Уровень: `GLOBAL`. Алиасы: `RELOAD CONFIG` + - `SYSTEM RELOAD DICTIONARY`. Уровень: `GLOBAL`. Алиасы: `SYSTEM RELOAD DICTIONARIES`, `RELOAD DICTIONARY`, `RELOAD DICTIONARIES` + - `SYSTEM RELOAD EMBEDDED DICTIONARIES`. Уровень: `GLOBAL`. Алиасы: `RELOAD EMBEDDED DICTIONARIES` + - `SYSTEM MERGES`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP MERGES`, `SYSTEM START MERGES`, `STOP MERGES`, `START MERGES` + - `SYSTEM TTL MERGES`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP TTL MERGES`, `SYSTEM START TTL MERGES`, `STOP TTL MERGES`, `START TTL MERGES` + - `SYSTEM FETCHES`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP FETCHES`, `SYSTEM START FETCHES`, `STOP FETCHES`, `START FETCHES` + - `SYSTEM MOVES`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP MOVES`, `SYSTEM START MOVES`, `STOP MOVES`, `START MOVES` + - `SYSTEM SENDS`. Уровень: `GROUP`. Алиасы: `SYSTEM STOP SENDS`, `SYSTEM START SENDS`, `STOP SENDS`, `START SENDS` + - `SYSTEM DISTRIBUTED SENDS`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP DISTRIBUTED SENDS`, `SYSTEM START DISTRIBUTED SENDS`, `STOP DISTRIBUTED SENDS`, `START DISTRIBUTED SENDS` + - `SYSTEM REPLICATED SENDS`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP REPLICATED SENDS`, `SYSTEM START REPLICATED SENDS`, `STOP REPLICATED SENDS`, `START REPLICATED SENDS` + - `SYSTEM REPLICATION QUEUES`. Уровень: `TABLE`. Алиасы: `SYSTEM STOP REPLICATION QUEUES`, `SYSTEM START REPLICATION QUEUES`, `STOP REPLICATION QUEUES`, `START REPLICATION QUEUES` + - `SYSTEM SYNC REPLICA`. Уровень: `TABLE`. Алиасы: `SYNC REPLICA` + - `SYSTEM RESTART REPLICA`. Уровень: `TABLE`. Алиасы: `RESTART REPLICA` + - `SYSTEM FLUSH`. Уровень: `GROUP` + - `SYSTEM FLUSH DISTRIBUTED`. Уровень: `TABLE`. Алиасы: `FLUSH DISTRIBUTED` + - `SYSTEM FLUSH LOGS`. Уровень: `GLOBAL`. Алиасы: `FLUSH LOGS` + +Привилегия `SYSTEM RELOAD EMBEDDED DICTIONARIES` имплицитно присваивается привилегией `SYSTEM RELOAD DICTIONARY ON *.*`. + + +### INTROSPECTION {#grant-introspection} + +Разрешает использовать функции [интроспекции](../../operations/optimizing-performance/sampling-query-profiler.md). + +- `INTROSPECTION`. Уровень: `GROUP`. Алиасы: `INTROSPECTION FUNCTIONS` + - `addressToLine`. Уровень: `GLOBAL` + - `addressToSymbol`. Уровень: `GLOBAL` + - `demangle`. Уровень: `GLOBAL` + + +### SOURCES {#grant-sources} + +Разрешает использовать внешние источники данных. Применяется к [движкам таблиц](../../engines/table-engines/index.md) и [табличным функциям](../table-functions/index.md#table-functions). + +- `SOURCES`. Уровень: `GROUP` + - `FILE`. Уровень: `GLOBAL` + - `URL`. Уровень: `GLOBAL` + - `REMOTE`. Уровень: `GLOBAL` + - `YSQL`. Уровень: `GLOBAL` + - `ODBC`. Уровень: `GLOBAL` + - `JDBC`. Уровень: `GLOBAL` + - `HDFS`. Уровень: `GLOBAL` + - `S3`. Уровень: `GLOBAL` + +Привилегия `SOURCES` разрешает использование всех источников. Также вы можете присвоить привилегию для каждого источника отдельно. Для использования источников необходимы дополнительные привилегии. + +Примеры: + +- Чтобы создать таблицу с [движком MySQL](../../engines/table-engines/integrations/mysql.md), необходимы привилегии `CREATE TABLE (ON db.table_name)` и `MYSQL`. +- Чтобы использовать [табличную функцию mysql](../table-functions/mysql.md), необходимы привилегии `CREATE TEMPORARY TABLE` и `MYSQL`. + +### dictGet {#grant-dictget} + +- `dictGet`. Алиасы: `dictHas`, `dictGetHierarchy`, `dictIsIn` + +Разрешает вызывать функции [dictGet](../functions/ext-dict-functions.md#dictget), [dictHas](../functions/ext-dict-functions.md#dicthas), [dictGetHierarchy](../functions/ext-dict-functions.md#dictgethierarchy), [dictIsIn](../functions/ext-dict-functions.md#dictisin). + +Уровень: `DICTIONARY`. + +**Примеры** + +- `GRANT dictGet ON mydb.mydictionary TO john` +- `GRANT dictGet ON mydictionary TO john` + +### ALL {#grant-all} + +Присваивает пользователю или роли все привилегии на объект с регулируемым доступом. + + +### NONE {#grant-none} + +Не присваивает никаких привилегий. + + +### ADMIN OPTION {#admin-option-privilege} + +Привилегия `ADMIN OPTION` разрешает пользователю назначать свои роли другому пользователю. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/grant/) diff --git a/docs/ru/sql-reference/statements/index.md b/docs/ru/sql-reference/statements/index.md new file mode 100644 index 00000000000..4dad718d721 --- /dev/null +++ b/docs/ru/sql-reference/statements/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: "\u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u044F" +toc_priority: 31 +--- + + diff --git a/docs/ru/sql-reference/statements/insert-into.md b/docs/ru/sql-reference/statements/insert-into.md new file mode 100644 index 00000000000..e8cea2db739 --- /dev/null +++ b/docs/ru/sql-reference/statements/insert-into.md @@ -0,0 +1,79 @@ +--- +toc_priority: 34 +toc_title: INSERT INTO +--- + +## INSERT {#insert} + +Добавление данных. + +Базовый формат запроса: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... +``` + +В запросе можно указать список столбцов для вставки `[(c1, c2, c3)]`. В этом случае, в остальные столбцы записываются: + +- Значения, вычисляемые из `DEFAULT` выражений, указанных в определении таблицы. +- Нули и пустые строки, если `DEFAULT` не определены. + +Если [strict\_insert\_defaults=1](../../operations/settings/settings.md), то столбцы, для которых не определены `DEFAULT`, необходимо перечислить в запросе. + +В INSERT можно передавать данные любого [формата](../../interfaces/formats.md#formats), который поддерживает ClickHouse. Для этого формат необходимо указать в запросе в явном виде: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set +``` + +Например, следующий формат запроса идентичен базовому варианту INSERT … VALUES: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... +``` + +ClickHouse отсекает все пробелы и один перенос строки (если он есть) перед данными. Рекомендуем при формировании запроса переносить данные на новую строку после операторов запроса (это важно, если данные начинаются с пробелов). + +Пример: + +``` sql +INSERT INTO t FORMAT TabSeparated +11 Hello, world! +22 Qwerty +``` + +С помощью консольного клиента или HTTP интерфейса можно вставлять данные отдельно от запроса. Как это сделать, читайте в разделе «[Интерфейсы](../../interfaces/index.md#interfaces)». + +### Ограничения (constraints) {#ogranicheniia-constraints} + +Если в таблице объявлены [ограничения](create.md#constraints), то их выполнимость будет проверена для каждой вставляемой строки. Если для хотя бы одной строки ограничения не будут выполнены, запрос будет остановлен. + +### Вставка результатов `SELECT` {#insert_query_insert-select} + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... +``` + +Соответствие столбцов определяется их позицией в секции SELECT. При этом, их имена в выражении SELECT и в таблице для INSERT, могут отличаться. При необходимости выполняется приведение типов данных, эквивалентное соответствующему оператору CAST. + +Все форматы данных кроме Values не позволяют использовать в качестве значений выражения, такие как `now()`, `1 + 2` и подобные. Формат Values позволяет ограниченно использовать выражения, но это не рекомендуется, так как в этом случае для их выполнения используется неэффективный вариант кода. + +Не поддерживаются другие запросы на модификацию части данных: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. +Вы можете удалять старые данные с помощью запроса `ALTER TABLE ... DROP PARTITION`. + +Для табличной функции [input()](../table-functions/input.md) после секции `SELECT` должна следовать +секция `FORMAT`. + +### Замечания о производительности {#zamechaniia-o-proizvoditelnosti} + +`INSERT` сортирует входящие данные по первичному ключу и разбивает их на партиции по ключу партиционирования. Если вы вставляете данные в несколько партиций одновременно, то это может значительно снизить производительность запроса `INSERT`. Чтобы избежать этого: + +- Добавляйте данные достаточно большими пачками. Например, по 100 000 строк. +- Группируйте данные по ключу партиционирования самостоятельно перед загрузкой в ClickHouse. + +Снижения производительности не будет, если: + +- Данные поступают в режиме реального времени. +- Вы загружаете данные, которые как правило отсортированы по времени. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/insert_into/) diff --git a/docs/ru/sql-reference/statements/misc.md b/docs/ru/sql-reference/statements/misc.md new file mode 100644 index 00000000000..77f9570ae47 --- /dev/null +++ b/docs/ru/sql-reference/statements/misc.md @@ -0,0 +1,347 @@ +# Прочие виды запросов {#prochie-vidy-zaprosov} + +## ATTACH {#attach} + +Запрос полностью аналогичен запросу `CREATE`, но: + +- вместо слова `CREATE` используется слово `ATTACH`; +- запрос не создаёт данные на диске, а предполагает, что данные уже лежат в соответствующих местах, и всего лишь добавляет информацию о таблице на сервер. После выполнения запроса `ATTACH` сервер будет знать о существовании таблицы. + +Если таблица перед этим была отсоединена (`DETACH`), т.е. её структура известна, можно использовать сокращенную форму записи без определения структуры. + +``` sql +ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] +``` + +Этот запрос используется при старте сервера. Сервер хранит метаданные таблиц в виде файлов с запросами `ATTACH`, которые он просто исполняет при запуске (за исключением системных таблиц, которые явно создаются на сервере). + +## CHECK TABLE {#check-table} + +Проверяет таблицу на повреждение данных. + +``` sql +CHECK TABLE [db.]name +``` + +Запрос `CHECK TABLE` сравнивает текущие размеры файлов (в которых хранятся данные из колонок) с ожидаемыми значениями. Если значения не совпадают, данные в таблице считаются поврежденными. Искажение возможно, например, из-за сбоя при записи данных. + +Ответ содержит колонку `result`, содержащую одну строку с типом [Boolean](../../sql-reference/data-types/boolean.md). Допустимые значения: + +- 0 - данные в таблице повреждены; +- 1 - данные не повреждены. + +Запрос `CHECK TABLE` поддерживает следующие движки таблиц: + +- [Log](../../engines/table-engines/log-family/log.md) +- [TinyLog](../../engines/table-engines/log-family/tinylog.md) +- [StripeLog](../../engines/table-engines/log-family/stripelog.md) +- [Семейство MergeTree](../../engines/table-engines/mergetree-family/index.md) + +При попытке выполнить запрос с таблицами с другими табличными движками, ClickHouse генерирует исключение. + +В движках `*Log` не предусмотрено автоматическое восстановление данных после сбоя. Используйте запрос `CHECK TABLE`, чтобы своевременно выявлять повреждение данных. + +Для движков из семейства `MergeTree` запрос `CHECK TABLE` показывает статус проверки для каждого отдельного куска данных таблицы на локальном сервере. + +**Что делать, если данные повреждены** + +В этом случае можно скопировать оставшиеся неповрежденные данные в другую таблицу. Для этого: + +1. Создайте новую таблицу с такой же структурой, как у поврежденной таблицы. Для этого выполните запрос `CREATE TABLE AS `. +2. Установите значение параметра [max\_threads](../../operations/settings/settings.md#settings-max_threads) в 1. Это нужно для того, чтобы выполнить следующий запрос в одном потоке. Установить значение параметра можно через запрос: `SET max_threads = 1`. +3. Выполните запрос `INSERT INTO SELECT * FROM `. В результате неповрежденные данные будут скопированы в другую таблицу. Обратите внимание, будут скопированы только те данные, которые следуют до поврежденного участка. +4. Перезапустите `clickhouse-client`, чтобы вернуть предыдущее значение параметра `max_threads`. + +## DESCRIBE TABLE {#misc-describe-table} + +``` sql +DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +Возвращает описание столбцов таблицы. + +Результат запроса содержит столбцы (все столбцы имеют тип String): + +- `name` — имя столбца таблицы; +- `type`— тип столбца; +- `default_type` — в каком виде задано [выражение для значения по умолчанию](create.md#create-default-values): `DEFAULT`, `MATERIALIZED` или `ALIAS`. Столбец содержит пустую строку, если значение по умолчанию не задано. +- `default_expression` — значение, заданное в секции `DEFAULT`; +- `comment_expression` — комментарий к столбцу. + +Вложенные структуры данных выводятся в «развёрнутом» виде. То есть, каждый столбец - по отдельности, с именем через точку. + +## DETACH {#detach-statement} + +Удаляет из сервера информацию о таблице name. Сервер перестаёт знать о существовании таблицы. + +``` sql +DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +Но ни данные, ни метаданные таблицы не удаляются. При следующем запуске сервера, сервер прочитает метаданные и снова узнает о таблице. +Также, «отцепленную» таблицу можно прицепить заново запросом `ATTACH` (за исключением системных таблиц, для которых метаданные не хранятся). + +Запроса `DETACH DATABASE` нет. + +## DROP {#drop} + +Запрос имеет два вида: `DROP DATABASE` и `DROP TABLE`. + +``` sql +DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] +``` + +``` sql +DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +Удаляет таблицу. +Если указано `IF EXISTS` - не выдавать ошибку, если таблица не существует или база данных не существует. + +## DROP USER {#drop-user-statement} + +Удаляет пользователя. + +### Синтаксис {#drop-user-syntax} + +```sql +DROP USER [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + + +## DROP ROLE {#drop-role-statement} + +Удаляет роль. + +При удалении роль отзывается у всех объектов системы доступа, которым она присвоена. + +### Синтаксис {#drop-role-syntax} + +```sql +DROP ROLE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROW POLICY {#drop-row-policy-statement} + +Удаляет политику доступа к строкам. + +При удалении политика отзывается у всех объектов системы доступа, которым она присвоена. + +### Синтаксис {#drop-row-policy-syntax} + +``` sql +DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] +``` + + +## DROP QUOTA {#drop-quota-statement} + +Удаляет квоту. + +При удалении квота отзывается у всех объектов системы доступа, которым она присвоена. + +### Синтаксис {#drop-quota-syntax} + +``` sql +DROP QUOTA [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + + +## DROP SETTINGS PROFILE {#drop-settings-profile-statement} + +Удаляет профиль настроек. + +При удалении профиль отзывается у всех объектов системы доступа, которым он присвоен. + +### Синтаксис {#drop-settings-profile-syntax} + +``` sql +DROP [SETTINGS] PROFILE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + + +## EXISTS {#exists} + +``` sql +EXISTS [TEMPORARY] TABLE [db.]name [INTO OUTFILE filename] [FORMAT format] +``` + +Возвращает один столбец типа `UInt8`, содержащий одно значение - `0`, если таблицы или БД не существует и `1`, если таблица в указанной БД существует. + +## KILL QUERY {#kill-query-statement} + +``` sql +KILL QUERY [ON CLUSTER cluster] + WHERE + [SYNC|ASYNC|TEST] + [FORMAT format] +``` + +Пытается принудительно остановить исполняющиеся в данный момент запросы. +Запросы для принудительной остановки выбираются из таблицы system.processes с помощью условия, указанного в секции `WHERE` запроса `KILL`. + +Примеры + +``` sql +-- Принудительно останавливает все запросы с указанным query_id: +KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' + +-- Синхронно останавливает все запросы пользователя 'username': +KILL QUERY WHERE user='username' SYNC +``` + +Readonly-пользователи могут останавливать только свои запросы. + +По умолчанию используется асинхронный вариант запроса (`ASYNC`), который не дожидается подтверждения остановки запросов. + +Синхронный вариант (`SYNC`) ожидает остановки всех запросов и построчно выводит информацию о процессах по ходу их остановки. +Ответ содержит колонку `kill_status`, которая может принимать следующие значения: + +1. ‘finished’ - запрос был успешно остановлен; +2. ‘waiting’ - запросу отправлен сигнал завершения, ожидается его остановка; +3. остальные значения описывают причину невозможности остановки запроса. + +Тестовый вариант запроса (`TEST`) только проверяет права пользователя и выводит список запросов для остановки. + +## KILL MUTATION {#kill-mutation-statement} + +``` sql +KILL MUTATION [ON CLUSTER cluster] + WHERE + [TEST] + [FORMAT format] +``` + +Пытается остановить выполняющиеся в данные момент [мутации](alter.md#alter-mutations). Мутации для остановки выбираются из таблицы [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) с помощью условия, указанного в секции `WHERE` запроса `KILL`. + +Тестовый вариант запроса (`TEST`) только проверяет права пользователя и выводит список запросов для остановки. + +Примеры: + +``` sql +-- Останавливает все мутации одной таблицы: +KILL MUTATION WHERE database = 'default' AND table = 'table' + +-- Останавливает конкретную мутацию: +KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' +``` + +Запрос полезен в случаях, когда мутация не может выполниться до конца (например, если функция в запросе мутации бросает исключение на данных таблицы). + +Данные, уже изменённые мутацией, остаются в таблице (отката на старую версию данных не происходит). + +## OPTIMIZE {#misc_operations-optimize} + +``` sql +OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] +``` + +Запрос пытается запустить внеплановый мёрж кусков данных для таблиц семейства [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). Другие движки таблиц не поддерживаются. + +Если `OPTIMIZE` применяется к таблицам семейства [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md), ClickHouse создаёт задачу на мёрж и ожидает её исполнения на всех узлах (если активирована настройка `replication_alter_partitions_sync`). + +- Если `OPTIMIZE` не выполняет мёрж по любой причине, ClickHouse не оповещает об этом клиента. Чтобы включить оповещения, используйте настройку [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop). +- Если указать `PARTITION`, то оптимизация выполняется только для указанной партиции. [Как задавать имя партиции в запросах](alter.md#alter-how-to-specify-part-expr). +- Если указать `FINAL`, то оптимизация выполняется даже в том случае, если все данные уже лежат в одном куске. +- Если указать `DEDUPLICATE`, то произойдет схлопывание полностью одинаковых строк (сравниваются значения во всех колонках), имеет смысл только для движка MergeTree. + +!!! warning "Внимание" + Запрос `OPTIMIZE` не может устранить причину появления ошибки «Too many parts». + +## RENAME {#misc_operations-rename} + +Переименовывает одну или несколько таблиц. + +``` sql +RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] +``` + +Переименовывание таблицы является лёгкой операцией. Если вы указали после `TO` другую базу данных, то таблица будет перенесена в эту базу данных. При этом, директории с базами данных должны быть расположены в одной файловой системе (иначе возвращается ошибка). В случае переименования нескольких таблиц в одном запросе — это неатомарная операция, может выполнится частично, запросы в других сессиях могут получить ошибку `Table ... doesn't exist...`. + +## SET {#query-set} + +``` sql +SET param = value +``` + +Устанавливает значение `value` для [настройки](../../operations/settings/index.md) `param` в текущей сессии. [Конфигурационные параметры сервера](../../operations/server-configuration-parameters/settings.md) нельзя изменить подобным образом. + +Можно одним запросом установить все настройки из заданного профиля настроек. + +``` sql +SET profile = 'profile-name-from-the-settings-file' +``` + +Подробности смотрите в разделе [Настройки](../../operations/settings/settings.md). + +## SET ROLE {#set-role-statement} + +Активирует роли для текущего пользователя. + +### Синтаксис {#set-role-syntax} + +``` sql +SET ROLE {DEFAULT | NONE | role [,...] | ALL | ALL EXCEPT role [,...]} +``` + +## SET DEFAULT ROLE {#set-default-role-statement} + +Устанавливает роли по умолчанию для пользователя. + +Роли по умолчанию активируются автоматически при входе пользователя. Ролями по умолчанию могут быть установлены только ранее назначенные роли. Если роль не назначена пользователю, ClickHouse выбрасывает исключение. + + +### Синтаксис {#set-default-role-syntax} + +``` sql +SET DEFAULT ROLE {NONE | role [,...] | ALL | ALL EXCEPT role [,...]} TO {user|CURRENT_USER} [,...] +``` + + +### Примеры {#set-default-role-examples} + +Установить несколько ролей по умолчанию для пользователя: + +``` sql +SET DEFAULT ROLE role1, role2, ... TO user +``` + +Установить ролями по умолчанию все назначенные пользователю роли: + +``` sql +SET DEFAULT ROLE ALL TO user +``` + +Удалить роли по умолчанию для пользователя: + +``` sql +SET DEFAULT ROLE NONE TO user +``` + +Установить ролями по умолчанию все назначенные пользователю роли за исключением указанных: + +```sql +SET DEFAULT ROLE ALL EXCEPT role1, role2 TO user +``` + +## TRUNCATE {#truncate-statement} + +``` sql +TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +Удаляет все данные из таблицы. Если условие `IF EXISTS` не указано, запрос вернет ошибку, если таблицы не существует. + +Запрос `TRUNCATE` не поддерживается для следующих движков: [View](../../engines/table-engines/special/view.md), [File](../../engines/table-engines/special/file.md), [URL](../../engines/table-engines/special/url.md) и [Null](../../engines/table-engines/special/null.md). + +## USE {#use} + +``` sql +USE db +``` + +Позволяет установить текущую базу данных для сессии. +Текущая база данных используется для поиска таблиц, если база данных не указана в запросе явно через точку перед именем таблицы. +При использовании HTTP протокола запрос не может быть выполнен, так как понятия сессии не существует. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/misc/) diff --git a/docs/ru/sql-reference/statements/revoke.md b/docs/ru/sql-reference/statements/revoke.md new file mode 100644 index 00000000000..1d2928bb76e --- /dev/null +++ b/docs/ru/sql-reference/statements/revoke.md @@ -0,0 +1,43 @@ +# REVOKE + +Отзывает привилегии у пользователей или ролей. + +## Синтаксис {#revoke-syntax} + +**Отзыв привилегий у пользователей** + +``` sql +REVOKE [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*} FROM {user | CURRENT_USER} [,...] | ALL | ALL EXCEPT {user | CURRENT_USER} [,...] +``` + +**Отзыв ролей у пользователей** + +``` sql +REVOKE [ON CLUSTER cluster_name] [ADMIN OPTION FOR] role [,...] FROM {user | role | CURRENT_USER} [,...] | ALL | ALL EXCEPT {user_name | role_name | CURRENT_USER} [,...] +``` + +## Описание {#revoke-description} + +Для отзыва привилегий можно использовать привилегию более широкой области действия. Например, если у пользователя есть привилегия `SELECT (x,y)`, администратор может отозвать ее с помощью одного из запросов: `REVOKE SELECT(x,y) ...`, `REVOKE SELECT * ...` или даже `REVOKE ALL PRIVILEGES ...`. + +### Частичный отзыв {#partial-revokes-dscr} + +Вы можете отозвать часть привилегии. Например, если у пользователя есть привилегия `SELECT *.*`, вы можете отозвать привилегию на чтение данных из какой-то таблицы или базы данных. + +## Примеры {#revoke-example} + +Присвоить пользователю `john` привилегию на `SELECT` из всех баз данных кроме `accounts`: + +``` sql +GRANT SELECT ON *.* TO john; +REVOKE SELECT ON accounts.* FROM john; +``` + +Присвоить пользователю `mira` привилегию на `SELECT` из всех столбцов таблицы `accounts.staff` кроме столбца `wage`: + +``` sql +GRANT SELECT ON accounts.staff TO mira; +REVOKE SELECT(wage) ON accounts.staff FROM mira; +``` + +[Оригинальная статья](https://clickhouse.tech/docs/en/operations/settings/settings/) diff --git a/docs/ru/sql-reference/statements/select/array-join.md b/docs/ru/sql-reference/statements/select/array-join.md new file mode 100644 index 00000000000..f8f11ba1b17 --- /dev/null +++ b/docs/ru/sql-reference/statements/select/array-join.md @@ -0,0 +1,277 @@ +# Секция ARRAY JOIN {#select-array-join-clause} + +Типовая операция для таблиц, содержащих столбец-массив — произвести новую таблицу, которая будет иметь столбец с каждым отдельным элементом массивов из изначального столбца, в то время как значения других столбцов дублируются. Это основной сценарий использования секции `ARRAY JOIN`. + +Название этой секции происходит от того, что эту операцию можно рассматривать как исполняющий `JOIN` с массивом или вложенной структурой данных. Цель использования похожа на функцию [arrayJoin](../../functions/array-join.md#functions_arrayjoin), но функциональность секции шире. + +Синтаксис: + +``` sql +SELECT +FROM +[LEFT] ARRAY JOIN +[WHERE|PREWHERE ] +... +``` + +Вы можете указать только одну секцию `ARRAY JOIN` в `SELECT` запросе. + +Поддерживаемые виды `ARRAY JOIN` перечислены ниже: + +- `ARRAY JOIN` - В базовом случае пустые массивы не включаются в результат. +- `LEFT ARRAY JOIN` - Результат содержит строки с пустыми массивами. Значение для пустого массива устанавливается равным значению по умолчанию для типа элемента массива (обычно 0, пустая строка или NULL). + +## Базовые примеры ARRAY JOIN {#basic-array-join-examples} + +Приведенные ниже примеры демонстрируют использование `ARRAY JOIN` и `LEFT ARRAY JOIN`. Cоздадим таблицу с колонкой типа данных [Array](../../../sql-reference/data-types/array.md) и вставим в него значения: + +``` sql +CREATE TABLE arrays_test +( + s String, + arr Array(UInt8) +) ENGINE = Memory; + +INSERT INTO arrays_test +VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []); +``` + +``` text +┌─s───────────┬─arr─────┐ +│ Hello │ [1,2] │ +│ World │ [3,4,5] │ +│ Goodbye │ [] │ +└─────────────┴─────────┘ +``` + +В приведенном ниже примере используется секция `ARRAY JOIN`: + +``` sql +SELECT s, arr +FROM arrays_test +ARRAY JOIN arr; +``` + +``` text +┌─s─────┬─arr─┐ +│ Hello │ 1 │ +│ Hello │ 2 │ +│ World │ 3 │ +│ World │ 4 │ +│ World │ 5 │ +└───────┴─────┘ +``` + +В следующем примере используется `LEFT ARRAY JOIN`: + +``` sql +SELECT s, arr +FROM arrays_test +LEFT ARRAY JOIN arr; +``` + +``` text +┌─s───────────┬─arr─┐ +│ Hello │ 1 │ +│ Hello │ 2 │ +│ World │ 3 │ +│ World │ 4 │ +│ World │ 5 │ +│ Goodbye │ 0 │ +└─────────────┴─────┘ +``` + +## Использование алиасов {#using-aliases} + +В секции `ARRAY JOIN` может быть указан алиас для массива. В этом случае элемент массива доступен по этому алиас, а сам массив доступен по исходному имени. Пример: + +``` sql +SELECT s, arr, a +FROM arrays_test +ARRAY JOIN arr AS a; +``` + +``` text +┌─s─────┬─arr─────┬─a─┐ +│ Hello │ [1,2] │ 1 │ +│ Hello │ [1,2] │ 2 │ +│ World │ [3,4,5] │ 3 │ +│ World │ [3,4,5] │ 4 │ +│ World │ [3,4,5] │ 5 │ +└───────┴─────────┴───┘ +``` + +Используя псевдонимы, вы можете выполнять `ARRAY JOIN` с внешними массивами. Например: + +``` sql +SELECT s, arr_external +FROM arrays_test +ARRAY JOIN [1, 2, 3] AS arr_external; +``` + +``` text +┌─s───────────┬─arr_external─┐ +│ Hello │ 1 │ +│ Hello │ 2 │ +│ Hello │ 3 │ +│ World │ 1 │ +│ World │ 2 │ +│ World │ 3 │ +│ Goodbye │ 1 │ +│ Goodbye │ 2 │ +│ Goodbye │ 3 │ +└─────────────┴──────────────┘ +``` + +Несколько массивов могут быть перечислены через запятую в секции `ARRAY JOIN`. В этом случае, `JOIN` выполняется с ними одновременно (прямая сумма, а не декартово произведение). Обратите внимание, что все массивы должны иметь одинаковый размер. Пример: + +``` sql +SELECT s, arr, a, num, mapped +FROM arrays_test +ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped; +``` + +``` text +┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ +│ Hello │ [1,2] │ 1 │ 1 │ 2 │ +│ Hello │ [1,2] │ 2 │ 2 │ 3 │ +│ World │ [3,4,5] │ 3 │ 1 │ 4 │ +│ World │ [3,4,5] │ 4 │ 2 │ 5 │ +│ World │ [3,4,5] │ 5 │ 3 │ 6 │ +└───────┴─────────┴───┴─────┴────────┘ +``` + +В приведенном ниже примере используется функция [arrayEnumerate](../../../sql-reference/functions/array-functions.md#array_functions-arrayenumerate): + +``` sql +SELECT s, arr, a, num, arrayEnumerate(arr) +FROM arrays_test +ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; +``` + +``` text +┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ +│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ +│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ +│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ +│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ +│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ +└───────┴─────────┴───┴─────┴─────────────────────┘ +``` + +## ARRAY JOIN со вложенной структурой данных {#array-join-with-nested-data-structure} + +`ARRAY JOIN` также работает с [вложенными структурами данных](../../../sql-reference/data-types/nested-data-structures/nested.md): + +``` sql +CREATE TABLE nested_test +( + s String, + nest Nested( + x UInt8, + y UInt32) +) ENGINE = Memory; + +INSERT INTO nested_test +VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []); +``` + +``` text +┌─s───────┬─nest.x──┬─nest.y─────┐ +│ Hello │ [1,2] │ [10,20] │ +│ World │ [3,4,5] │ [30,40,50] │ +│ Goodbye │ [] │ [] │ +└─────────┴─────────┴────────────┘ +``` + +``` sql +SELECT s, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN nest; +``` + +``` text +┌─s─────┬─nest.x─┬─nest.y─┐ +│ Hello │ 1 │ 10 │ +│ Hello │ 2 │ 20 │ +│ World │ 3 │ 30 │ +│ World │ 4 │ 40 │ +│ World │ 5 │ 50 │ +└───────┴────────┴────────┘ +``` + +При указании имен вложенных структур данных в `ARRAY JOIN`, секция работает так же, как и `ARRAY JOIN` со всеми элементами массива, из которых он состоит. Примеры приведены ниже: + +``` sql +SELECT s, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN `nest.x`, `nest.y`; +``` + +``` text +┌─s─────┬─nest.x─┬─nest.y─┐ +│ Hello │ 1 │ 10 │ +│ Hello │ 2 │ 20 │ +│ World │ 3 │ 30 │ +│ World │ 4 │ 40 │ +│ World │ 5 │ 50 │ +└───────┴────────┴────────┘ +``` + +Такая вариация также возможна: + +``` sql +SELECT s, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN `nest.x`; +``` + +``` text +┌─s─────┬─nest.x─┬─nest.y─────┐ +│ Hello │ 1 │ [10,20] │ +│ Hello │ 2 │ [10,20] │ +│ World │ 3 │ [30,40,50] │ +│ World │ 4 │ [30,40,50] │ +│ World │ 5 │ [30,40,50] │ +└───────┴────────┴────────────┘ +``` + +Алиас для вложенной структуры данных можно использовать, чтобы выбрать как результат JOIN-а, так и исходный массив. Пример: + +``` sql +SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` +FROM nested_test +ARRAY JOIN nest AS n; +``` + +``` text +┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ +│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ +│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ +│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ +│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ +│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ +└───────┴─────┴─────┴─────────┴────────────┘ +``` + +Пример использования функции [arrayEnumerate](../../../sql-reference/functions/array-functions.md#array_functions-arrayenumerate): + +``` sql +SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num +FROM nested_test +ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; +``` + +``` text +┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ +│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ +│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ +│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ +│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ +│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ +└───────┴─────┴─────┴─────────┴────────────┴─────┘ +``` + +## Детали реализации {#implementation-details} + +Хотя секция `ARRAY JOIN` всегда должна быть указана перед [WHERE](where.md)/[PREWHERE](prewhere.md), технически они могут быть выполнены в любом порядке, если только результат `ARRAY JOIN` используется для фильтрации. Порядок обработки контролируется оптимизатором запросов. diff --git a/docs/ru/sql-reference/statements/select/distinct.md b/docs/ru/sql-reference/statements/select/distinct.md new file mode 100644 index 00000000000..62e2e25b7e5 --- /dev/null +++ b/docs/ru/sql-reference/statements/select/distinct.md @@ -0,0 +1,58 @@ +# Секция DISTINCT {#select-distinct} + +Если указан `SELECT DISTINCT`, то в результате запроса останутся только уникальные строки. Таким образом, из всех наборов полностью совпадающих строк в результате останется только одна строка. + +## Обработк NULL {#null-processing} + +`DISTINCT` работает с [NULL](../../syntax.md#null-literal) как-будто `NULL` — обычное значение и `NULL==NULL`. Другими словами, в результате `DISTINCT`, различные комбинации с `NULL` встретятся только один раз. Это отличается от обработки `NULL` в большинстве других контекстов. + +## Альтернативы {#alternatives} + +Такой же результат можно получить, применив секцию [GROUP BY](group-by.md) для того же набора значений, которые указан в секции `SELECT`, без использования каких-либо агрегатных функций. Но есть от `GROUP BY` несколько отличий: + +- `DISTINCT` может применяться вместе с `GROUP BY`. +- Когда секция [ORDER BY](order-by.md) опущена, а секция [LIMIT](limit.md) присутствует, запрос прекращает выполнение сразу после считывания необходимого количества различных строк. +- Блоки данных выводятся по мере их обработки, не дожидаясь завершения выполнения всего запроса. + +## Ограничения {#limitations} + +`DISTINCT` не поддерживается, если `SELECT` имеет по крайней мере один столбец-массив. + +## Примеры {#examples} + +ClickHouse поддерживает использование секций `DISTINCT` и `ORDER BY` для разных столбцов в одном запросе. Секция `DISTINCT` выполняется до секции `ORDER BY`. + +Таблица для примера: + +``` text +┌─a─┬─b─┐ +│ 2 │ 1 │ +│ 1 │ 2 │ +│ 3 │ 3 │ +│ 2 │ 4 │ +└───┴───┘ +``` + +При выборе данных с помощью `SELECT DISTINCT a FROM t1 ORDER BY b ASC`, мы получаем следующий результат: + +``` text +┌─a─┐ +│ 2 │ +│ 1 │ +│ 3 │ +└───┘ +``` + +Если мы изменим направление сортировки `SELECT DISTINCT a FROM t1 ORDER BY b DESC`, мы получаем следующий результат: + +``` text +┌─a─┐ +│ 3 │ +│ 1 │ +│ 2 │ +└───┘ +``` + +Ряд `2, 4` был разрезан перед сортировкой. + +Учитывайте эту специфику при разработке запросов. diff --git a/docs/ru/sql-reference/statements/select/format.md b/docs/ru/sql-reference/statements/select/format.md new file mode 100644 index 00000000000..dad0ef0d62c --- /dev/null +++ b/docs/ru/sql-reference/statements/select/format.md @@ -0,0 +1,13 @@ +# Секция FORMAT {#format-clause} + +ClickHouse поддерживает широкий спектр [форматов сериализации](../../../interfaces/formats.md) это может быть использовано, в частности, для результатов запросов. Существует несколько способов выбора формата для `SELECT`, один из них заключается в том, чтобы указать `FORMAT format` в конце запроса, чтобы получить результирующие данные в любом конкретном формате. + +Определенный формат может использоваться для удобства, интеграции с другими системами или для повышения производительности. + +## Формат по умолчанию {#default-format} + +Если `FORMAT` предложение опущено, используется формат по умолчанию, который зависит как от настроек, так и от интерфейса, используемого для доступа к серверу ClickHouse. Для [HTTP интерфейса](../../../interfaces/http.md) и [клиента командной строки](../../../interfaces/cli.md) в пакетном режиме, формат по умолчанию — `TabSeparated`. Для клиента командной строки в интерактивном режиме по умолчанию используется формат `PrettyCompact` (он производит компактные человекочитаемые таблицы). + +## Детали реализации {#implementation-details} + +При использовании клиента командной строки данные всегда передаются по сети во внутреннем эффективном формате (`Native`). Клиент самостоятельно интерпретирует `FORMAT` предложение запроса и форматирует сами данные (тем самым освобождая сеть и сервер от дополнительной нагрузки). diff --git a/docs/ru/sql-reference/statements/select/from.md b/docs/ru/sql-reference/statements/select/from.md new file mode 100644 index 00000000000..ac0ab1dcd3f --- /dev/null +++ b/docs/ru/sql-reference/statements/select/from.md @@ -0,0 +1,40 @@ +# Секция FROM {#select-from} + +В секции `FROM` указывается источник, из которого будут читаться данные: + +- [Таблица](../../../engines/table-engines/index.md) +- [Подзапрос](index.md) {## TODO: better link ##} +- [Табличная функция](../../table-functions/index.md#table-functions) + +Секция [JOIN](join.md) и [ARRAY JOIN](array-join.md) могут быть использованы для расширения функциональных возможностей секции `FROM`. + +Подзапрос — дополнительный `SELECT` запрос, который может быть указан в круглых скобках внутри секции `FROM`. + +Секция `FROM` может содержать несколько источников данных, указанных через запятую, что эквивалентно выполнению [CROSS JOIN](join.md) на них. + +## Модификатор FINAL {#select-from-final} + +Если в запросе используется модификатор `FINAL`, то ClickHouse полностью мёржит данные перед выдачей результата, таким образом выполняя все преобразования данных, которые производятся движком таблиц при мёржах. + +Он применим при выборе данных из таблиц, использующих [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)- семейство движков (кроме `GraphiteMergeTree`). Также поддерживается для: + +- [Replicated](../../../engines/table-engines/mergetree-family/replication.md) варианты исполнения `MergeTree` движков. +- [View](../../../engines/table-engines/special/view.md), [Buffer](../../../engines/table-engines/special/buffer.md), [Distributed](../../../engines/table-engines/special/distributed.md), и [MaterializedView](../../../engines/table-engines/special/materializedview.md), которые работают поверх других движков, если они созданы для таблиц с движками семейства `MergeTree`. + +### Недостатки {#drawbacks} + +Запросы, которые используют `FINAL` выполняются не так быстро, как аналогичные запросы без него, потому что: + +- Запрос выполняется в одном потоке, и данные мёржатся во время выполнения запроса. +- Запросы с модификатором `FINAL` читают столбцы первичного ключа в дополнение к столбцам, используемым в запросе. + +**В большинстве случаев избегайте использования `FINAL`.** Общий подход заключается в использовании агрегирующих запросов, которые предполагают, что фоновые процессы движков семейства `MergeTree` ещё не случились (например, сами отбрасывают дубликаты). {## TODO: examples ##} + +## Детали реализации {#implementation-details} + +Если секция `FROM` опущена, данные будут считываться из таблицы `system.one`. +Таблица `system.one` содержит ровно одну строку. + +Для выполнения запроса, из соответствующей таблицы, вынимаются все столбцы, перечисленные в запросе. Из подзапросов выкидываются столбцы, не нужные для внешнего запроса. + +Если в запросе не перечислено ни одного столбца (например, `SELECT count() FROM t)`, то из таблицы всё равно вынимается один какой-нибудь столбец (предпочитается самый маленький), для того, чтобы можно было посчитать количество строк. diff --git a/docs/ru/sql-reference/statements/select/group-by.md b/docs/ru/sql-reference/statements/select/group-by.md new file mode 100644 index 00000000000..f68a8547f13 --- /dev/null +++ b/docs/ru/sql-reference/statements/select/group-by.md @@ -0,0 +1,119 @@ +# Секция GROUP BY {#select-group-by-clause} + +Секция `GROUP BY` переключает `SELECT` запрос в режим агрегации, который работает следующим образом: + +- Секция `GROUP BY` содержит список выражений (или одно выражение, которое считается списком длины один). Этот список действует как «ключ группировки», в то время как каждое отдельное выражение будет называться «ключевым выражением». +- Все выражения в секциях [SELECT](index.md), [HAVING](having.md), и [ORDER BY](order-by.md) статьи **должны** быть вычисленными на основе ключевых выражений **или** на [агрегатных функций](../../../sql-reference/aggregate-functions/index.md) над неключевыми выражениями (включая столбцы). Другими словами, каждый столбец, выбранный из таблицы, должен использоваться либо в ключевом выражении, либо внутри агрегатной функции, но не в обоих. +- В результате агрегирования `SELECT` запрос будет содержать столько строк, сколько было уникальных значений ключа группировки в исходной таблице. Обычно агрегация значительно уменьшает количество строк, часто на порядки, но не обязательно: количество строк остается неизменным, если все исходные значения ключа группировки ценности были различны. + +!!! note "Примечание" + Есть ещё один способ запустить агрегацию по таблице. Если запрос содержит столбцы исходной таблицы только внутри агрегатных функций, то `GROUP BY` секцию можно опустить, и предполагается агрегирование по пустому набору ключей. Такие запросы всегда возвращают ровно одну строку. + +## Обработка NULL {#null-processing} + +При агрегации ClickHouse интерпретирует [NULL](../../syntax.md#null-literal) как обычное значение, то есть `NULL==NULL`. Это отличается от обработки `NULL` в большинстве других контекстов. + +Предположим, что у вас есть эта таблица: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +Запрос `SELECT sum(x), y FROM t_null_big GROUP BY y` выведет: + +``` text +┌─sum(x)─┬────y─┐ +│ 4 │ 2 │ +│ 3 │ 3 │ +│ 5 │ ᴺᵁᴸᴸ │ +└────────┴──────┘ +``` + +Видно, что `GROUP BY` для `У = NULL` просуммировал `x`, как будто `NULL` — это значение. + +Если в `GROUP BY` передать несколько ключей, то в результате мы получим все комбинации выборки, как если бы `NULL` был конкретным значением. + +## Модификатор WITH TOTALS {#with-totals-modifier} + +Если указан модификатор `WITH TOTALS`, то будет посчитана ещё одна строчка, в которой в столбцах-ключах будут содержаться значения по умолчанию (нули, пустые строки), а в столбцах агрегатных функций - значения, посчитанные по всем строкам («тотальные» значения). + +Этот дополнительный ряд выводится только в форматах `JSON*`, `TabSeparated*`, и `Pretty*`, отдельно от других строк: + +- В `JSON*` форматах, эта строка выводится как отдельное поле ‘totals’. +- В `TabSeparated*` форматах, строка идет после основного результата, через дополнительную пустую строку (после остальных данных). +- В `Pretty*` форматах, строка выводится в виде отдельной таблицы после основного результата. +- В других форматах она не доступна. + +При использовании секции [HAVING](having.md) поведение `WITH TOTALS` контролируется настройкой `totals_mode`. + +### Настройка обработки итогов {#configuring-totals-processing} + +По умолчанию `totals_mode = 'before_having'`. В этом случае totals считается по всем строчкам, включая непрошедших через HAVING и max\_rows\_to\_group\_by. + +Остальные варианты учитывают в totals только строчки, прошедшие через HAVING, и имеют разное поведение при наличии настройки `max_rows_to_group_by` и `group_by_overflow_mode = 'any'`. + +`after_having_exclusive` - не учитывать строчки, не прошедшие `max_rows_to_group_by`. То есть в totals попадёт меньше или столько же строчек, чем если бы `max_rows_to_group_by` не было. + +`after_having_inclusive` - учитывать в totals все строчки, не прошедшие max\_rows\_to\_group\_by. То есть в totals попадёт больше или столько же строчек, чем если бы `max_rows_to_group_by` не было. + +`after_having_auto` - считать долю строчек, прошедших через HAVING. Если она больше некоторого значения (по умолчанию - 50%), то включить все строчки, не прошедшие max\_rows\_to\_group\_by в totals, иначе - не включить. + +`totals_auto_threshold` - по умолчанию 0.5. Коэффициент для работы `after_having_auto`. + +Если `max_rows_to_group_by` и `group_by_overflow_mode = 'any'` не используются, то все варианты вида `after_having` не отличаются, и вы можете использовать любой из них, например, `after_having_auto`. + +Вы можете использовать `WITH TOTALS` в подзапросах, включая подзапросы в секции [JOIN](join.md) (в этом случае соответствующие тотальные значения будут соединены). + +## Примеры {#examples} + +Пример: + +``` sql +SELECT + count(), + median(FetchTiming > 60 ? 60 : FetchTiming), + count() - sum(Refresh) +FROM hits +``` + +Но, в отличие от стандартного SQL, если в таблице нет строк (вообще нет или после фильтрации с помощью WHERE), в качестве результата возвращается пустой результат, а не результат из одной строки, содержащий «начальные» значения агрегатных функций. + +В отличие от MySQL (и в соответствии со стандартом SQL), вы не можете получить какое-нибудь значение некоторого столбца, не входящего в ключ или агрегатную функцию (за исключением константных выражений). Для обхода этого вы можете воспользоваться агрегатной функцией any (получить первое попавшееся значение) или min/max. + +Пример: + +``` sql +SELECT + domainWithoutWWW(URL) AS domain, + count(), + any(Title) AS title -- getting the first occurred page header for each domain. +FROM hits +GROUP BY domain +``` + +GROUP BY вычисляет для каждого встретившегося различного значения ключей, набор значений агрегатных функций. + +Не поддерживается GROUP BY по столбцам-массивам. + +Не поддерживается указание констант в качестве аргументов агрегатных функций. Пример: `sum(1)`. Вместо этого, вы можете избавиться от констант. Пример: `count()`. + +## Детали реализации {#implementation-details} + +Агрегация является одной из наиболее важных возможностей столбцовых СУБД, и поэтому её реализация является одной из наиболее сильно оптимизированных частей ClickHouse. По умолчанию агрегирование выполняется в памяти с помощью хэш-таблицы. Она имеет более 40 специализаций, которые выбираются автоматически в зависимости от типов данных ключа группировки. + +### Группировка во внешней памяти {#select-group-by-in-external-memory} + +Можно включить сброс временных данных на диск, чтобы ограничить потребление оперативной памяти при выполнении `GROUP BY`. +Настройка [max\_bytes\_before\_external\_group\_by](../../../operations/settings/settings.md#settings-max_bytes_before_external_group_by) определяет пороговое значение потребления RAM, по достижении которого временные данные `GROUP BY` сбрасываются в файловую систему. Если равно 0 (по умолчанию) - значит выключено. + +При использовании `max_bytes_before_external_group_by`, рекомендуем выставить `max_memory_usage` приблизительно в два раза больше. Это следует сделать, потому что агрегация выполняется в две стадии: чтение и формирование промежуточных данных (1) и слияние промежуточных данных (2). Сброс данных на файловую систему может производиться только на стадии 1. Если сброса временных данных не было, то на стадии 2 может потребляться до такого же объёма памяти, как на стадии 1. + +Например, если [max\_memory\_usage](../../../operations/settings/settings.md#settings_max_memory_usage) было выставлено в 10000000000, и вы хотите использовать внешнюю агрегацию, то имеет смысл выставить `max_bytes_before_external_group_by` в 10000000000, а `max_memory_usage` в 20000000000. При срабатывании внешней агрегации (если был хотя бы один сброс временных данных в файловую систему) максимальное потребление оперативки будет лишь чуть-чуть больше `max_bytes_before_external_group_by`. + +При распределённой обработке запроса внешняя агрегация производится на удалённых серверах. Для того чтобы на сервере-инициаторе запроса использовалось немного оперативки, нужно выставить настройку `distributed_aggregation_memory_efficient` в 1. diff --git a/docs/ru/sql-reference/statements/select/having.md b/docs/ru/sql-reference/statements/select/having.md new file mode 100644 index 00000000000..83f58c5566f --- /dev/null +++ b/docs/ru/sql-reference/statements/select/having.md @@ -0,0 +1,9 @@ +# Секция HAVING {#having-clause} + +Позволяет фильтровать результаты агрегации, полученные с помощью [GROUP BY](group-by.md). Разница с [WHERE](where.md) в том, что `WHERE` выполняется перед агрегацией, в то время как `HAVING` выполняется после него. + +Из секции `HAVING` можно ссылаться на результаты агреации из секции `SELECT` по их алиасу. Также секция `HAVING` может фильтровать по результатам дополнительных агрегатов, которые не возвращаются в результатах запроса. + +## Ограничения {#limitations} + +`HAVING` нельзя использовать, если агрегация не выполняется. Вместо этого можно использовать `WHERE`. diff --git a/docs/ru/sql-reference/statements/select/index.md b/docs/ru/sql-reference/statements/select/index.md new file mode 100644 index 00000000000..fb7c130983b --- /dev/null +++ b/docs/ru/sql-reference/statements/select/index.md @@ -0,0 +1,162 @@ +--- +toc_priority: 33 +toc_title: SELECT +--- + +# Синтаксис запросов SELECT {#select-queries-syntax} + +`SELECT` выполняет получение данных. + +``` sql +[WITH expr_list|(subquery)] +SELECT [DISTINCT] expr_list +[FROM [db.]table | (subquery) | table_function] [FINAL] +[SAMPLE sample_coeff] +[ARRAY JOIN ...] +[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list +[PREWHERE expr] +[WHERE expr] +[GROUP BY expr_list] [WITH TOTALS] +[HAVING expr] +[ORDER BY expr_list] +[LIMIT [offset_value, ]n BY columns] +[LIMIT [n, ]m] +[UNION ALL ...] +[INTO OUTFILE filename] +[FORMAT format] +``` + +Все секции являются необязательными, за исключением списка выражений сразу после `SELECT`, о котором более подробно будет рассказано [ниже](#select-clause). + +Особенности каждой необязательной секции рассматриваются в отдельных разделах, которые перечислены в том же порядке, в каком они выполняются: + +- [Секция WITH](with.md) +- [Секция FROM](from.md) +- [Секция SAMPLE](sample.md) +- [Секция JOIN](join.md) +- [Секция PREWHERE](prewhere.md) +- [Секция WHERE](where.md) +- [Секция GROUP BY](group-by.md) +- [Секция LIMIT BY](limit-by.md) +- [Секция HAVING](having.md) +- [Секция SELECT](#select-clause) +- [Секция DISTINCT](distinct.md) +- [Секция LIMIT](limit.md) +- [Секция UNION ALL](union-all.md) +- [Секция INTO OUTFILE](into-outfile.md) +- [Секция FORMAT](format.md) + +## Секция SELECT {#select-clause} + +[Выражения](../../syntax.md#syntax-expressions) указанные в секции `SELECT` анализируются после завершения всех вычислений из секций, описанных выше. Вернее, анализируются выражения, стоящие над агрегатными функциями, если есть агрегатные функции. +Сами агрегатные функции и то, что под ними, вычисляются при агрегации (`GROUP BY`). Эти выражения работают так, как будто применяются к отдельным строкам результата. + +Если в результат необходимо включить все столбцы, используйте символ звёздочка (`*`). Например, `SELECT * FROM ...`. + +Чтобы включить в результат несколько столбцов, выбрав их имена с помощью регулярных выражений [re2](https://en.wikipedia.org/wiki/RE2_(software)), используйте выражение `COLUMNS`. + +``` sql +COLUMNS('regexp') +``` + +Например, рассмотрим таблицу: + +``` sql +CREATE TABLE default.col_names (aa Int8, ab Int8, bc Int8) ENGINE = TinyLog +``` + +Следующий запрос выбирает данные из всех столбцов, содержащих в имени символ `a`. + +``` sql +SELECT COLUMNS('a') FROM col_names +``` + +``` text +┌─aa─┬─ab─┐ +│ 1 │ 1 │ +└────┴────┘ +``` + +Выбранные стоблцы возвращаются не в алфавитном порядке. + +В запросе можно использовать несколько выражений `COLUMNS`, а также вызывать над ними функции. + +Например: + +``` sql +SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names +``` + +``` text +┌─aa─┬─ab─┬─bc─┬─toTypeName(bc)─┐ +│ 1 │ 1 │ 1 │ Int8 │ +└────┴────┴────┴────────────────┘ +``` + +Каждый столбец, возвращённый выражением `COLUMNS`, передаётся в функцию отдельным аргументом. Также можно передавать и другие аргументы, если функция их поддерживаем. Аккуратно используйте функции. Если функция не поддерживает переданное количество аргументов, то ClickHouse генерирует исключение. + +Например: + +``` sql +SELECT COLUMNS('a') + COLUMNS('c') FROM col_names +``` + +``` text +Received exception from server (version 19.14.1): +Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of arguments for function plus doesn't match: passed 3, should be 2. +``` + +В этом примере, `COLUMNS('a')` возвращает два столбца: `aa` и `ab`. `COLUMNS('c')` возвращает столбец `bc`. Оператор `+` не работает с тремя аргументами, поэтому ClickHouse генерирует исключение с соответствущим сообщением. + +Столбцы, которые возвращаются выражением `COLUMNS` могут быть разных типов. Если `COLUMNS` не возвращает ни одного столбца и это единственное выражение в запросе `SELECT`, то ClickHouse генерирует исключение. + +### Звёздочка {#asterisk} + +В любом месте запроса, вместо выражения, может стоять звёздочка. При анализе запроса звёздочка раскрывается в список всех столбцов таблицы (за исключением `MATERIALIZED` и `ALIAS` столбцов). Есть лишь немного случаев, когда оправдано использовать звёздочку: + +- при создании дампа таблицы; +- для таблиц, содержащих всего несколько столбцов - например, системных таблиц; +- для получения информации о том, какие столбцы есть в таблице; в этом случае, укажите `LIMIT 1`. Но лучше используйте запрос `DESC TABLE`; +- при наличии сильной фильтрации по небольшому количеству столбцов с помощью `PREWHERE`; +- в подзапросах (так как из подзапросов выкидываются столбцы, не нужные для внешнего запроса). + +В других случаях использование звёздочки является издевательством над системой, так как вместо преимуществ столбцовой СУБД вы получаете недостатки. То есть использовать звёздочку не рекомендуется. + +### Экстремальные значения {#extreme-values} + +Вы можете получить в дополнение к результату также минимальные и максимальные значения по столбцам результата. Для этого выставите настройку **extremes** в 1. Минимумы и максимумы считаются для числовых типов, дат, дат-с-временем. Для остальных столбцов будут выведены значения по умолчанию. + +Вычисляются дополнительные две строчки - минимумы и максимумы, соответственно. Эти две дополнительные строки выводятся в [форматах](../../../interfaces/formats.md) `JSON*`, `TabSeparated*`, и `Pretty*` отдельно от остальных строчек. В остальных форматах они не выводится. + +Во форматах `JSON*`, экстремальные значения выводятся отдельным полем ‘extremes’. В форматах `TabSeparated*`, строка выводится после основного результата и после ‘totals’ если есть. Перед ней (после остальных данных) вставляется пустая строка. В форматах `Pretty*`, строка выводится отдельной таблицей после основного результата и после `totals` если есть. + +Экстремальные значения вычисляются для строк перед `LIMIT`, но после `LIMIT BY`. Однако при использовании `LIMIT offset, size`, строки перед `offset` включаются в `extremes`. В потоковых запросах, в результате может учитываться также небольшое количество строчек, прошедших `LIMIT`. + +### Замечания {#notes} + +Вы можете использовать синонимы (алиасы `AS`) в любом месте запроса. + +В секциях `GROUP BY`, `ORDER BY`, в отличие от диалекта MySQL, и в соответствии со стандартным SQL, не поддерживаются позиционные аргументы. +Например, если вы напишите `GROUP BY 1, 2` - то это будет воспринято, как группировка по константам (то есть, агрегация всех строк в одну). + + +## Детали реализации {#implementation-details} + +Если в запросе отсутствуют секции `DISTINCT`, `GROUP BY`, `ORDER BY`, подзапросы в `IN` и `JOIN`, то запрос будет обработан полностью потоково, с использованием O(1) количества оперативки. +Иначе запрос может съесть много оперативки, если не указаны подходящие ограничения: + +- `max_memory_usage` +- `max_rows_to_group_by` +- `max_rows_to_sort` +- `max_rows_in_distinct` +- `max_bytes_in_distinct` +- `max_rows_in_set` +- `max_bytes_in_set` +- `max_rows_in_join` +- `max_bytes_in_join` +- `max_bytes_before_external_sort` +- `max_bytes_before_external_group_by` + +Подробнее смотрите в разделе «Настройки». Присутствует возможность использовать внешнюю сортировку (с сохранением временных данных на диск) и внешнюю агрегацию. + +{## [Оригинальная статья](https://clickhouse.tech/docs/en/sql-reference/statements/select/) ##} diff --git a/docs/ru/sql-reference/statements/select/into-outfile.md b/docs/ru/sql-reference/statements/select/into-outfile.md new file mode 100644 index 00000000000..8f0126068d1 --- /dev/null +++ b/docs/ru/sql-reference/statements/select/into-outfile.md @@ -0,0 +1,9 @@ +# Секция INTO OUTFILE {#into-outfile-clause} + +Чтобы перенаправить вывод `SELECT` запроса в указанный файл на стороне клиента, добавьте к нему секцию `INTO OUTFILE filename` (где filenam — строковый литерал). + +## Детали реализации {#implementation-details} + +- Эта функция доступна только в следующих интерфейсах: [клиент командной строки](../../../interfaces/cli.md) и [clickhouse-local](../../../operations/utilities/clickhouse-local.md). Таким образом, запрос, отправленный через [HTTP интерфейс](../../../interfaces/http.md) вернет ошибку. +- Запрос завершится ошибкой, если файл с тем же именем уже существует. +- По умолчанию используется [выходной формат](../../../interfaces/formats.md) `TabSeparated` (как в пакетном режиме клиента командной строки). diff --git a/docs/ru/sql-reference/statements/select/join.md b/docs/ru/sql-reference/statements/select/join.md new file mode 100644 index 00000000000..60f391d888b --- /dev/null +++ b/docs/ru/sql-reference/statements/select/join.md @@ -0,0 +1,187 @@ +# Секция JOIN {#select-join} + +Join создаёт новую таблицу путем объединения столбцов из одной или нескольких таблиц с использованием общих для каждой из них значений. Это обычная операция в базах данных с поддержкой SQL, которая соответствует join из [реляционной алгебры](https://en.wikipedia.org/wiki/Relational_algebra#Joins_and_join-like_operators). Частный случай соединения одной таблицы часто называют «self-join». + +Синтаксис: + +``` sql +SELECT +FROM +[GLOBAL] [ANY|ALL|ASOF] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER|SEMI|ANTI] JOIN +(ON )|(USING ) ... +``` + +Выражения из секции `ON` и столбцы из секции `USING` называется «ключами соединения». Если не указано иное, при присоединение создаётся [Декартово произведение](https://en.wikipedia.org/wiki/Cartesian_product) из строк с совпадающими значениями ключей соединения, что может привести к получению результатов с гораздо большим количеством строк, чем исходные таблицы. + +## Поддерживаемые типы соединения {#select-join-types} + +Весе типы из стандартого [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) поддерживаются: + +- `INNER JOIN`, возвращаются только совпадающие строки. +- `LEFT OUTER JOIN`, не совпадающие строки из левой таблицы возвращаются в дополнение к совпадающим строкам. +- `RIGHT OUTER JOIN`, не совпадающие строки из правой таблицы возвращаются в дополнение к совпадающим строкам. +- `FULL OUTER JOIN`, не совпадающие строки из обеих таблиц возвращаются в дополнение к совпадающим строкам. +- `CROSS JOIN`, производит декартово произведение таблиц целиком, ключи соединения не указываются. + +Без указания типа `JOIN` подразумевается `INNER`. Ключевое слово `OUTER` можно опускать. Альтернативным синтаксисом для `CROSS JOIN` является ли указание нескольких таблиц, разделённых запятыми, в [секции FROM](from.md). + +Дополнительные типы соединений, доступные в ClickHouse: + +- `LEFT SEMI JOIN` и `RIGHT SEMI JOIN`, белый список по ключам соединения, не производит декартово произведение. +- `LEFT ANTI JOIN` и `RIGHT ANTI JOIN`, черный список по ключам соединения, не производит декартово произведение. + +## Строгость {#select-join-strictness} + +Изменяет способ сопоставления по ключам соединения: + +- `ALL` — стандартное поведение `JOIN` в SQL, как описано выше. По умолчанию. +- `ANY` — Частично (для противоположных сторон `LEFT` и `RIGHT`) или полностью (для `INNER` и `FULL`) отключает декартово произведение для стандартых видов `JOIN`. +- `ASOF` — Для соединения последовательностей по нечеткому совпадению. Использование `ASOF JOIN` описано ниже. + +!!! note "Примечание" + Значение строгости по умолчанию может быть переопределено с помощью настройки [join\_default\_strictness](../../../operations/settings/settings.md#settings-join_default_strictness). + +### Использование ASOF JOIN {#asof-join-usage} + +`ASOF JOIN` применим в том случае, когда необходимо объединять записи, которые не имеют точного совпадения. + +Таблицы для `ASOF JOIN` должны иметь столбец с отсортированной последовательностью. Этот столбец не может быть единственным в таблице и должен быть одного из типов: `UInt32`, `UInt64`, `Float32`, `Float64`, `Date` и `DateTime`. + +Синтаксис `ASOF JOIN ... ON`: + +``` sql +SELECT expressions_list +FROM table_1 +ASOF LEFT JOIN table_2 +ON equi_cond AND closest_match_cond +``` + +Можно использовать произвольное количество условий равенства и одно условие на ближайшее совпадение. Например, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`. + +Условия, поддержанные для проверки на ближайшее совпадение: `>`, `>=`, `<`, `<=`. + +Синтаксис `ASOF JOIN ... USING`: + +``` sql +SELECT expressions_list +FROM table_1 +ASOF JOIN table_2 +USING (equi_column1, ... equi_columnN, asof_column) +``` + +Для слияния по равенству `ASOF JOIN` использует `equi_columnX`, а для слияния по ближайшему совпадению использует `asof_column` с условием `table_1.asof_column >= table_2.asof_column`. Столбец `asof_column` должен быть последним в секции `USING`. + +Например, рассмотрим следующие таблицы: + + table_1 table_2 + event | ev_time | user_id event | ev_time | user_id + ----------|---------|---------- ----------|---------|---------- + ... ... + event_1_1 | 12:00 | 42 event_2_1 | 11:59 | 42 + ... event_2_2 | 12:30 | 42 + event_1_2 | 13:00 | 42 event_2_3 | 13:00 | 42 + ... ... + +`ASOF JOIN` принимает метку времени пользовательского события из `table_1` и находит такое событие в `table_2` метка времени которого наиболее близка к метке времени события из `table_1` в соответствии с условием на ближайшее совпадение. При этом столбец `user_id` используется для объединения по равенству, а столбец `ev_time` для объединения по ближайшему совпадению. В нашем примере `event_1_1` может быть объединено с `event_2_1`, `event_1_2` может быть объединено с `event_2_3`, а `event_2_2` не объединяется. + +!!! note "Примечание" + `ASOF JOIN` не поддержан для движка таблиц [Join](../../../engines/table-engines/special/join.md). + +Чтобы задать значение строгости по умолчанию, используйте сессионный параметр [join\_default\_strictness](../../../operations/settings/settings.md#settings-join_default_strictness). + +#### Распределённый join {#global-join} + +Есть два пути для выполнения соединения с участием распределённых таблиц: + +- При использовании обычного `JOIN` , запрос отправляется на удалённые серверы. На каждом из них выполняются подзапросы для формирования «правой» таблицы, и с этой таблицей выполняется соединение. То есть, «правая» таблица формируется на каждом сервере отдельно. +- При использовании `GLOBAL ... JOIN`, сначала сервер-инициатор запроса запускает подзапрос для вычисления правой таблицы. Эта временная таблица передаётся на каждый удалённый сервер, и на них выполняются запросы с использованием переданных временных данных. + +Будьте аккуратны при использовании `GLOBAL`. За дополнительной информацией обращайтесь в раздел [Распределенные подзапросы](#select-distributed-subqueries). + +## Рекомендации по использованию {#usage-recommendations} + +### Обработка пустых ячеек и NULL {#processing-of-empty-or-null-cells} + +При соединении таблиц могут появляться пустые ячейки. Настройка [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) определяет, как ClickHouse заполняет эти ячейки. + +Если ключами `JOIN` выступают поля типа [Nullable](../../../sql-reference/data-types/nullable.md), то строки, где хотя бы один из ключей имеет значение [NULL](../../../sql-reference/syntax.md#null-literal), не соединяются. + +### Синтаксис {#syntax} + +Требуется, чтобы столбцы, указанные в `USING`, назывались одинаково в обоих подзапросах, а остальные столбцы - по-разному. Изменить имена столбцов в подзапросах можно с помощью синонимов. + +В секции `USING` указывается один или несколько столбцов для соединения, что обозначает условие на равенство этих столбцов. Список столбцов задаётся без скобок. Более сложные условия соединения не поддерживаются. + +### Ограничения cинтаксиса {#syntax-limitations} + +Для множественных секций `JOIN` в одном запросе `SELECT`: + +- Получение всех столбцов через `*` возможно только при объединении таблиц, но не подзапросов. +- Секция `PREWHERE` недоступна. + +Для секций `ON`, `WHERE` и `GROUP BY`: + +- Нельзя использовать произвольные выражения в секциях `ON`, `WHERE`, и `GROUP BY`, однако можно определить выражение в секции `SELECT` и затем использовать его через алиас в других секциях. + +### Производительность {#performance} + +При запуске `JOIN`, отсутствует оптимизация порядка выполнения по отношению к другим стадиям запроса. Соединение (поиск в «правой» таблице) выполняется до фильтрации в `WHERE` и до агрегации. Чтобы явно задать порядок вычислений, рекомендуется выполнять `JOIN` подзапроса с подзапросом. + +Каждый раз для выполнения запроса с одинаковым `JOIN`, подзапрос выполняется заново — результат не кэшируется. Это можно избежать, используя специальный движок таблиц [Join](../../../engines/table-engines/special/join.md), представляющий собой подготовленное множество для соединения, которое всегда находится в оперативке. + +В некоторых случаях это более эффективно использовать [IN](../../operators/in.md) вместо `JOIN`. + +Если `JOIN` необходим для соединения с таблицами измерений (dimension tables - сравнительно небольшие таблицы, которые содержат свойства измерений - например, имена для рекламных кампаний), то использование `JOIN` может быть не очень удобным из-за громоздкости синтаксиса, а также из-за того, что правая таблица читается заново при каждом запросе. Специально для таких случаев существует функциональность «Внешние словари», которую следует использовать вместо `JOIN`. Дополнительные сведения смотрите в разделе «Внешние словари». + + +### Ограничения по памяти {#memory-limitations} + +По умолчанию ClickHouse использует алгоритм [hash join](https://en.wikipedia.org/wiki/Hash_join). ClickHouse берет `` и создает для него хэш-таблицу в оперативной памяти. После некоторого порога потребления памяти ClickHouse переходит к алгоритму merge join. + +- [max\_rows\_in\_join](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) — ограничивает количество строк в хэш-таблице. +- [max\_bytes\_in\_join](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) — ограничивает размер хэш-таблицы. + +По достижении любого из этих ограничений, ClickHouse действует в соответствии с настройкой [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode). + +## Примеры {#examples} + +Пример: + +``` sql +SELECT + CounterID, + hits, + visits +FROM +( + SELECT + CounterID, + count() AS hits + FROM test.hits + GROUP BY CounterID +) ANY LEFT JOIN +( + SELECT + CounterID, + sum(Sign) AS visits + FROM test.visits + GROUP BY CounterID +) USING CounterID +ORDER BY hits DESC +LIMIT 10 +``` + +``` text +┌─CounterID─┬───hits─┬─visits─┐ +│ 1143050 │ 523264 │ 13665 │ +│ 731962 │ 475698 │ 102716 │ +│ 722545 │ 337212 │ 108187 │ +│ 722889 │ 252197 │ 10547 │ +│ 2237260 │ 196036 │ 9522 │ +│ 23057320 │ 147211 │ 7689 │ +│ 722818 │ 90109 │ 17847 │ +│ 48221 │ 85379 │ 4652 │ +│ 19762435 │ 77807 │ 7026 │ +│ 722884 │ 77492 │ 11056 │ +└───────────┴────────┴────────┘ +``` diff --git a/docs/ru/sql-reference/statements/select/limit-by.md b/docs/ru/sql-reference/statements/select/limit-by.md new file mode 100644 index 00000000000..ea5d467ae4f --- /dev/null +++ b/docs/ru/sql-reference/statements/select/limit-by.md @@ -0,0 +1,69 @@ +# Секция LIMIT BY {#limit-by-clause} + +Запрос с секцией `LIMIT n BY expressions` выбирает первые `n` строк для каждого отличного значения `expressions`. Ключ `LIMIT BY` может содержать любое количество [выражений](../../syntax.md#syntax-expressions). + +ClickHouse поддерживает следующий синтаксис: + +- `LIMIT [offset_value, ]n BY expressions` +- `LIMIT n OFFSET offset_value BY expressions` + +Во время обработки запроса, ClickHouse выбирает данные, упорядоченные по ключу сортировки. Ключ сортировки задаётся явно в секции [ORDER BY](order-by.md#select-order-by) или неявно в свойствах движка таблицы. Затем ClickHouse применяет `LIMIT n BY expressions` и возвращает первые `n` для каждой отличной комбинации `expressions`. Если указан `OFFSET`, то для каждого блока данных, который принадлежит отдельной комбинации `expressions`, ClickHouse отступает `offset_value` строк от начала блока и возвращает не более `n`. Если `offset_value` больше, чем количество строк в блоке данных, ClickHouse не возвращает ни одной строки. + +`LIMIT BY` не связана с секцией `LIMIT`. Их можно использовать в одном запросе. + +## Примеры + +Образец таблицы: + +``` sql +CREATE TABLE limit_by(id Int, val Int) ENGINE = Memory; +INSERT INTO limit_by values(1, 10), (1, 11), (1, 12), (2, 20), (2, 21); +``` + +Запросы: + +``` sql +SELECT * FROM limit_by ORDER BY id, val LIMIT 2 BY id +``` + +``` text +┌─id─┬─val─┐ +│ 1 │ 10 │ +│ 1 │ 11 │ +│ 2 │ 20 │ +│ 2 │ 21 │ +└────┴─────┘ +``` + +``` sql +SELECT * FROM limit_by ORDER BY id, val LIMIT 1, 2 BY id +``` + +``` text +┌─id─┬─val─┐ +│ 1 │ 11 │ +│ 1 │ 12 │ +│ 2 │ 21 │ +└────┴─────┘ +``` + +Запрос `SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` возвращает такой же результат. + +Следующий запрос выбирает топ 5 рефереров для каждой пары `domain, device_type`, но не более 100 строк (`LIMIT n BY + LIMIT`). + +``` sql +SELECT + domainWithoutWWW(URL) AS domain, + domainWithoutWWW(REFERRER_URL) AS referrer, + device_type, + count() cnt +FROM hits +GROUP BY domain, referrer, device_type +ORDER BY cnt DESC +LIMIT 5 BY domain, device_type +LIMIT 100 +``` + +Запрос выберет топ 5 рефереров для каждой пары `domain, device_type`, но не более 100 строк (`LIMIT n BY + LIMIT`). + +`LIMIT n BY` работает с [NULL](../../syntax.md#null-literal) как если бы это было конкретное значение. Т.е. в результате запроса пользователь получит все комбинации полей, указанных в `BY`. diff --git a/docs/ru/sql-reference/statements/select/limit.md b/docs/ru/sql-reference/statements/select/limit.md new file mode 100644 index 00000000000..5c68c22d548 --- /dev/null +++ b/docs/ru/sql-reference/statements/select/limit.md @@ -0,0 +1,9 @@ +# Секция LIMIT {#limit-clause} + +`LIMIT m` позволяет выбрать из результата первые `m` строк. + +`LIMIT n, m` позволяет выбрать из результата первые `m` строк после пропуска первых `n` строк. Синтаксис `LIMIT m OFFSET n` также поддерживается. + +`n` и `m` должны быть неотрицательными целыми числами. + +При отсутствии секции [ORDER BY](order-by.md), однозначно сортирующей результат, результат может быть произвольным и может являться недетерминированным. diff --git a/docs/ru/sql-reference/statements/select/order-by.md b/docs/ru/sql-reference/statements/select/order-by.md new file mode 100644 index 00000000000..83b704cec8f --- /dev/null +++ b/docs/ru/sql-reference/statements/select/order-by.md @@ -0,0 +1,68 @@ +# Секция ORDER BY {#select-order-by} + +Секция `ORDER BY` содержит список выражений, к каждому из которых также может быть приписано `DESC` или `ASC` (направление сортировки). Если ничего не приписано - это аналогично приписыванию `ASC`. `ASC` - сортировка по возрастанию, `DESC` - сортировка по убыванию. Обозначение направления сортировки действует на одно выражение, а не на весь список. Пример: `ORDER BY Visits DESC, SearchPhrase` + +Строки, для которых список выражений, по которым производится сортировка, принимает одинаковые значения, выводятся в произвольном порядке, который может быть также недетерминированным (каждый раз разным). +Если секция ORDER BY отсутствует, то, аналогично, порядок, в котором идут строки, не определён, и может быть недетерминированным. + +## Сортировка специальных значений {#sorting-of-special-values} + +Существует два подхода к участию `NaN` и `NULL` в порядке сортировки: + +- По умолчанию или с модификатором `NULLS LAST`: сначала остальные значения, затем `NaN`, затем `NULL`. +- С модификатором `NULLS FIRST`: сначала `NULL`, затем `NaN`, затем другие значения. + +### Пример {#example} + +Для таблицы + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 2 │ 2 │ +│ 1 │ nan │ +│ 2 │ 2 │ +│ 3 │ 4 │ +│ 5 │ 6 │ +│ 6 │ nan │ +│ 7 │ ᴺᵁᴸᴸ │ +│ 6 │ 7 │ +│ 8 │ 9 │ +└───┴──────┘ +``` + +Выполнение запроса `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` получить: + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +│ 7 │ ᴺᵁᴸᴸ │ +│ 1 │ nan │ +│ 6 │ nan │ +│ 2 │ 2 │ +│ 2 │ 2 │ +│ 3 │ 4 │ +│ 5 │ 6 │ +│ 6 │ 7 │ +│ 8 │ 9 │ +└───┴──────┘ +``` + +При сортировке чисел с плавающей запятой NaNs отделяются от других значений. Независимо от порядка сортировки, NaNs приходят в конце. Другими словами, при восходящей сортировке они помещаются так, как будто они больше всех остальных чисел, а при нисходящей сортировке они помещаются так, как будто они меньше остальных. + +## Поддержка collation {#collation-support} + +Для сортировки по значениям типа String есть возможность указать collation (сравнение). Пример: `ORDER BY SearchPhrase COLLATE 'tr'` - для сортировки по поисковой фразе, по возрастанию, с учётом турецкого алфавита, регистронезависимо, при допущении, что строки в кодировке UTF-8. `COLLATE` может быть указан или не указан для каждого выражения в ORDER BY независимо. Если есть `ASC` или `DESC`, то `COLLATE` указывается после них. При использовании `COLLATE` сортировка всегда регистронезависима. + +Рекомендуется использовать `COLLATE` только для окончательной сортировки небольшого количества строк, так как производительность сортировки с указанием `COLLATE` меньше, чем обычной сортировки по байтам. + +## Деталь реализации {#implementation-details} + +Если кроме `ORDER BY` указан также не слишком большой [LIMIT](limit.md), то расходуется меньше оперативки. Иначе расходуется количество памяти, пропорциональное количеству данных для сортировки. При распределённой обработке запроса, если отсутствует [GROUP BY](group-by.md), сортировка частично делается на удалённых серверах, а на сервере-инициаторе запроса производится слияние результатов. Таким образом, при распределённой сортировке, может сортироваться объём данных, превышающий размер памяти на одном сервере. + +Существует возможность выполнять сортировку во внешней памяти (с созданием временных файлов на диске), если оперативной памяти не хватает. Для этого предназначена настройка `max_bytes_before_external_sort`. Если она выставлена в 0 (по умолчанию), то внешняя сортировка выключена. Если она включена, то при достижении объёмом данных для сортировки указанного количества байт, накопленные данные будут отсортированы и сброшены во временный файл. После того, как все данные будут прочитаны, будет произведено слияние всех сортированных файлов и выдача результата. Файлы записываются в директорию `/var/lib/clickhouse/tmp/` (по умолчанию, может быть изменено с помощью параметра `tmp_path`) в конфиге. + +На выполнение запроса может расходоваться больше памяти, чем `max_bytes_before_external_sort`. Поэтому, значение этой настройки должно быть существенно меньше, чем `max_memory_usage`. Для примера, если на вашем сервере 128 GB оперативки, и вам нужно выполнить один запрос, то выставите `max_memory_usage` в 100 GB, а `max_bytes_before_external_sort` в 80 GB. + +Внешняя сортировка работает существенно менее эффективно, чем сортировка в оперативке. + diff --git a/docs/ru/sql-reference/statements/select/prewhere.md b/docs/ru/sql-reference/statements/select/prewhere.md new file mode 100644 index 00000000000..1c8595d8e0c --- /dev/null +++ b/docs/ru/sql-reference/statements/select/prewhere.md @@ -0,0 +1,17 @@ +# Секция PREWHERE {#prewhere-clause} + +Prewhere — это оптимизация для более эффективного применения фильтрации. Она включена по умолчанию, даже если секция `PREWHERE` явно не указана. В этом случае работает автоматическое перемещение части выражения из [WHERE](where.md) до стадии prewhere. Роль секции `PREWHERE` только для управления этой оптимизацией, если вы думаете, что знаете, как сделать перемещение условия лучше, чем это происходит по умолчанию. + +При оптимизации prewhere сначала читываются только те столбцы, которые необходимы для выполнения выражения prewhere. Затем читаются другие столбцы, необходимые для выполнения остальной части запроса, но только те блоки, в которых находится выражение prewhere «верно» по крайней мере для некоторых рядов. Если есть много блоков, где выражение prewhere «ложно» для всех строк и для выражения prewhere требуется меньше столбцов, чем для других частей запроса, это часто позволяет считывать гораздо меньше данных с диска для выполнения запроса. + +## Управление prewhere вручную {#controlling-prewhere-manually} + +`PREWHERE` имеет смысл использовать, если есть условия фильтрации, которые использует меньшинство столбцов из тех, что есть в запросе, но достаточно сильно фильтрует данные. Таким образом, сокращается количество читаемых данных. + +В запрос может быть одновременно указано и `PREWHERE` и `WHERE`. В этом случае, `PREWHERE` предшествует `WHERE`. + +Если значение параметра `optimize_move_to_prewhere` равно 0, эвристика по автоматическому перемещнию части выражений из `WHERE` к `PREWHERE` отключается. + +## Ограничения {#limitations} + +`PREWHERE` поддерживается только табличными движками из семейства `*MergeTree`. diff --git a/docs/ru/sql-reference/statements/select/sample.md b/docs/ru/sql-reference/statements/select/sample.md new file mode 100644 index 00000000000..ca6b49c9ad6 --- /dev/null +++ b/docs/ru/sql-reference/statements/select/sample.md @@ -0,0 +1,113 @@ +# Секция SAMPLE {#select-sample-clause} + +Секция `SAMPLE` позволяет выполнять запросы приближённо. Например, чтобы посчитать статистику по всем визитам, можно обработать 1/10 всех визитов и результат домножить на 10. + +Сэмплирование имеет смысл, когда: + +1. Точность результата не важна, например, для оценочных расчетов. +2. Возможности аппаратной части не позволяют соответствовать строгим критериям. Например, время ответа должно быть \<100 мс. При этом точность расчета имеет более низкий приоритет. +3. Точность результата участвует в бизнес-модели сервиса. Например, пользователи с бесплатной подпиской на сервис могут получать отчеты с меньшей точностью, чем пользователи с премиум подпиской. + +!!! note "Внимание" + Не стоит использовать сэмплирование в тех задачах, где важна точность расчетов. Например, при работе с финансовыми отчетами. + +Свойства сэмплирования: + +- Сэмплирование работает детерминированно. При многократном выполнении одного и того же запроса `SELECT .. SAMPLE`, результат всегда будет одинаковым. +- Сэмплирование поддерживает консистентность для разных таблиц. Имеется в виду, что для таблиц с одним и тем же ключом сэмплирования, подмножество данных в выборках будет одинаковым (выборки при этом должны быть сформированы для одинаковой доли данных). Например, выборка по идентификаторам посетителей выберет из разных таблиц строки с одинаковым подмножеством всех возможных идентификаторов. Это свойство позволяет использовать выборки в подзапросах в секции [IN](../../operators/in.md#select-in-operators), а также объединять выборки с помощью [JOIN](join.md#select-join). +- Сэмплирование позволяет читать меньше данных с диска. Обратите внимание, для этого необходимо корректно указать ключ сэмплирования. Подробнее см. в разделе [Создание таблицы MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). + +Сэмплирование поддерживается только таблицами семейства [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) и только в том случае, если для таблиц был указан ключ сэмплирования (выражение, на основе которого должна производиться выборка). Подробнее см. в разделе [Создание таблиц MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). + +Выражение `SAMPLE` в запросе можно задать следующими способами: + +| Способ задания SAMPLE | Описание | +|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `SAMPLE k` | Здесь `k` – это дробное число в интервале от 0 до 1.
Запрос будет выполнен по `k` доле данных. Например, если указано `SAMPLE 1/10`, то запрос будет выполнен для выборки из 1/10 данных. [Подробнее](#select-sample-k) | +| `SAMPLE n` | Здесь `n` – это достаточно большое целое число.
Запрос будет выполнен для выборки, состоящей из не менее чем `n` строк. Например, если указано `SAMPLE 10000000`, то запрос будет выполнен для не менее чем 10,000,000 строк. [Подробнее](#select-sample-n) | +| `SAMPLE k OFFSET m` | Здесь `k` и `m` – числа от 0 до 1.
Запрос будет выполнен по `k` доле данных. При этом выборка будет сформирована со смещением на `m` долю. [Подробнее](#select-sample-offset) | + +## SAMPLE k {#select-sample-k} + +Здесь `k` – число в интервале от 0 до 1. Поддерживается как дробная, так и десятичная форма записи. Например, `SAMPLE 1/2` или `SAMPLE 0.5`. + +Если задано выражение `SAMPLE k`, запрос будет выполнен для `k` доли данных. Рассмотрим пример: + +``` sql +SELECT + Title, + count() * 10 AS PageViews +FROM hits_distributed +SAMPLE 0.1 +WHERE + CounterID = 34 +GROUP BY Title +ORDER BY PageViews DESC LIMIT 1000 +``` + +В этом примере запрос выполняется по выборке из 0.1 (10%) данных. Значения агрегатных функций не корректируются автоматически, поэтому чтобы получить приближённый результат, значение `count()` нужно вручную умножить на 10. + +Выборка с указанием относительного коэффициента является «согласованной»: для таблиц с одним и тем же ключом сэмплирования, выборка с одинаковой относительной долей всегда будет составлять одно и то же подмножество данных. То есть выборка из разных таблиц, на разных серверах, в разное время, формируется одинаковым образом. + +## SAMPLE n {#select-sample-n} + +Здесь `n` – это достаточно большое целое число. Например, `SAMPLE 10000000`. + +Если задано выражение `SAMPLE n`, запрос будет выполнен для выборки из не менее `n` строк (но не значительно больше этого значения). Например, если задать `SAMPLE 10000000`, в выборку попадут не менее 10,000,000 строк. + +!!! note "Примечание" + Следует иметь в виду, что `n` должно быть достаточно большим числом. Так как минимальной единицей данных для чтения является одна гранула (её размер задаётся настройкой `index_granularity` для таблицы), имеет смысл создавать выборки, размер которых существенно превосходит размер гранулы. + +При выполнении `SAMPLE n` коэффициент сэмплирования заранее неизвестен (то есть нет информации о том, относительно какого количества данных будет сформирована выборка). Чтобы узнать коэффициент сэмплирования, используйте столбец `_sample_factor`. + +Виртуальный столбец `_sample_factor` автоматически создается в тех таблицах, для которых задано выражение `SAMPLE BY` (подробнее см. в разделе [Создание таблицы MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)). В столбце содержится коэффициент сэмплирования для таблицы – он рассчитывается динамически по мере добавления данных в таблицу. Ниже приведены примеры использования столбца `_sample_factor`. + +Предположим, у нас есть таблица, в которой ведется статистика посещений сайта. Пример ниже показывает, как рассчитать суммарное число просмотров: + +``` sql +SELECT sum(PageViews * _sample_factor) +FROM visits +SAMPLE 10000000 +``` + +Следующий пример показывает, как посчитать общее число визитов: + +``` sql +SELECT sum(_sample_factor) +FROM visits +SAMPLE 10000000 +``` + +В примере ниже рассчитывается среднее время на сайте. Обратите внимание, при расчете средних значений, умножать результат на коэффициент сэмплирования не нужно. + +``` sql +SELECT avg(Duration) +FROM visits +SAMPLE 10000000 +``` + +## SAMPLE k OFFSET m {#select-sample-offset} + +Здесь `k` и `m` – числа в интервале от 0 до 1. Например, `SAMPLE 0.1 OFFSET 0.5`. Поддерживается как дробная, так и десятичная форма записи. + +При задании `SAMPLE k OFFSET m`, выборка будет сформирована из `k` доли данных со смещением на долю `m`. Примеры приведены ниже. + +**Пример 1** + +``` sql +SAMPLE 1/10 +``` + +В этом примере выборка будет сформирована по 1/10 доле всех данных: + +`[++------------------]` + +**Пример 2** + +``` sql +SAMPLE 1/10 OFFSET 1/2 +``` + +Здесь выборка, которая состоит из 1/10 доли данных, взята из второй половины данных. + +`[----------++--------]` diff --git a/docs/ru/sql-reference/statements/select/union-all.md b/docs/ru/sql-reference/statements/select/union-all.md new file mode 100644 index 00000000000..bffd667fa1d --- /dev/null +++ b/docs/ru/sql-reference/statements/select/union-all.md @@ -0,0 +1,30 @@ +# Секция UNION ALL {#union-all-clause} + +Вы можете использовать `UNION ALL` чтобы объединить любое количество `SELECT` запросы путем расширения их результатов. Пример: + +``` sql +SELECT CounterID, 1 AS table, toInt64(count()) AS c + FROM test.hits + GROUP BY CounterID + +UNION ALL + +SELECT CounterID, 2 AS table, sum(Sign) AS c + FROM test.visits + GROUP BY CounterID + HAVING c > 0 +``` + +Результирующие столбцы сопоставляются по их индексу (порядку внутри `SELECT`). Если имена столбцов не совпадают, то имена для конечного результата берутся из первого запроса. + +При объединении выполняет приведение типов. Например, если два запроса имеют одно и то же поле с не-`Nullable` и `Nullable` совместимыми типами, полученные в результате `UNION ALL` данные будут иметь `Nullable` тип. + +Запросы, которые являются частью `UNION ALL` не могут быть заключен в круглые скобки. [ORDER BY](order-by.md) и [LIMIT](limit.md) применяются к отдельным запросам, а не к конечному результату. Если вам нужно применить преобразование к конечному результату, вы можете разместить все объединенные с помощью `UNION ALL` запросы в подзапрос в секции [FROM](from.md). + +## Ограничения {#limitations} + +Поддерживается только `UNION ALL`. Обычный `UNION` (`UNION DISTINCT`) не поддерживается. Если вам это нужно `UNION DISTINCT`, вы можете написать `SELECT DISTINCT` из подзапроса, содержащего `UNION ALL`. + +## Детали реализации {#implementation-details} + +Запросы, которые являются частью `UNION ALL` выполняются параллельно, и их результаты могут быть смешаны вместе. diff --git a/docs/ru/sql-reference/statements/select/where.md b/docs/ru/sql-reference/statements/select/where.md new file mode 100644 index 00000000000..63d081db43d --- /dev/null +++ b/docs/ru/sql-reference/statements/select/where.md @@ -0,0 +1,25 @@ +# Секция WHERE {#select-where} + +Позволяет задать выражение, которое ClickHouse использует для фильтрации данных перед всеми другими действиями в запросе кроме выражений, содержащихся в секции [PREWHERE](prewhere.md#prewhere-clause). Обычно, это выражение с логическими операторами. + +Результат выражения должен иметь тип `UInt8`. + +ClickHouse использует в выражении индексы, если это позволяет [движок таблицы](../../../engines/table-engines/index.md). + +Если в секции необходимо проверить [NULL](../../../sql-reference/syntax.md#null-literal), то используйте операторы [IS NULL](../../operators/index.md#operator-is-null) и [IS NOT NULL](../../operators/index.md#is-not-null), а также соответствующие функции `isNull` и `isNotNull`. В противном случае выражение будет считаться всегда не выполненным. + +Пример проверки на `NULL`: + +``` sql +SELECT * FROM t_null WHERE y IS NULL +``` + +``` text +┌─x─┬────y─┐ +│ 1 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +!!! note "Примечание" + Существует оптимизация фильтрации под названием [prewhere](prewhere.md). + diff --git a/docs/ru/sql-reference/statements/select/with.md b/docs/ru/sql-reference/statements/select/with.md new file mode 100644 index 00000000000..a5be733866f --- /dev/null +++ b/docs/ru/sql-reference/statements/select/with.md @@ -0,0 +1,76 @@ +# Секция WITH {#sektsiia-with} + +Данная секция представляет собой [Common Table Expressions](https://ru.wikipedia.org/wiki/Иерархические_и_рекурсивные_запросы_в_SQL), то есть позволяет использовать результаты выражений из секции `WITH` в остальной части `SELECT` запроса. + +### Ограничения + +1. Рекурсивные запросы не поддерживаются +2. Если в качестве выражения используется подзапрос, то результат должен содержать ровно одну строку +3. Результаты выражений нельзя переиспользовать во вложенных запросах +В дальнейшем, результаты выражений можно использовать в секции SELECT. + +### Примеры + +**Пример 1:** Использование константного выражения как «переменной» + +``` sql +WITH '2019-08-01 15:23:00' as ts_upper_bound +SELECT * +FROM hits +WHERE + EventDate = toDate(ts_upper_bound) AND + EventTime <= ts_upper_bound +``` + +**Пример 2:** Выкидывание выражения sum(bytes) из списка колонок в SELECT + +``` sql +WITH sum(bytes) as s +SELECT + formatReadableSize(s), + table +FROM system.parts +GROUP BY table +ORDER BY s +``` + +**Пример 3:** Использование результатов скалярного подзапроса + +``` sql +/* запрос покажет TOP 10 самых больших таблиц */ +WITH + ( + SELECT sum(bytes) + FROM system.parts + WHERE active + ) AS total_disk_usage +SELECT + (sum(bytes) / total_disk_usage) * 100 AS table_disk_usage, + table +FROM system.parts +GROUP BY table +ORDER BY table_disk_usage DESC +LIMIT 10 +``` + +**Пример 4:** Переиспользование выражения + +В настоящий момент, переиспользование выражения из секции WITH внутри подзапроса возможно только через дублирование. + +``` sql +WITH ['hello'] AS hello +SELECT + hello, + * +FROM +( + WITH ['hello'] AS hello + SELECT hello +) +``` + +``` text +┌─hello─────┬─hello─────┐ +│ ['hello'] │ ['hello'] │ +└───────────┴───────────┘ +``` diff --git a/docs/ru/sql-reference/statements/show.md b/docs/ru/sql-reference/statements/show.md new file mode 100644 index 00000000000..72180435b9c --- /dev/null +++ b/docs/ru/sql-reference/statements/show.md @@ -0,0 +1,172 @@ +# SHOW Queries {#show-queries} + +## SHOW CREATE TABLE {#show-create-table} + +``` sql +SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +Возвращает один столбец типа `String` с именем statement, содержащий одно значение — запрос `CREATE TABLE`, с помощью которого был создан указанный объект. + +## SHOW DATABASES {#show-databases} + +``` sql +SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] +``` + +Выводит список всех баз данных. +Запрос полностью аналогичен запросу `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. + +## SHOW PROCESSLIST {#show-processlist} + +``` sql +SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] +``` + +Выводит содержимое таблицы [system.processes](../../operations/system-tables.md#system_tables-processes), которая содержит список запросов, выполняющихся в данный момент времени, кроме самих запросов `SHOW PROCESSLIST`. + +Запрос `SELECT * FROM system.processes` возвращает данные обо всех текущих запросах. + +Полезный совет (выполните в консоли): + +``` bash +$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" +``` + +## SHOW TABLES {#show-tables} + +Выводит список таблиц. + +``` sql +SHOW [TEMPORARY] TABLES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +Если секция `FROM` не используется, то запрос возвращает список таблиц из текущей базы данных. + +Результат, идентичный тому, что выдаёт запрос `SHOW TABLES` можно получить также запросом следующего вида: + +``` sql +SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**Пример** + +Следующий запрос выбирает первые две строки из списка таблиц в базе данных `system`, чьи имена содержат `co`. + +``` sql +SHOW TABLES FROM system LIKE '%co%' LIMIT 2 +``` + +``` text +┌─name───────────────────────────┐ +│ aggregate_function_combinators │ +│ collations │ +└────────────────────────────────┘ +``` + +## SHOW DICTIONARIES {#show-dictionaries} + +Выводит список [внешних словарей](../../sql-reference/statements/show.md). + +``` sql +SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +Если секция `FROM` не указана, запрос возвращает список словарей из текущей базы данных. + +Аналогичный результат можно получить следующим запросом: + +``` sql +SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**Example** + +Запрос выводит первые две стоки из списка таблиц в базе данных `system`, имена которых содержат `reg`. + +``` sql +SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 +``` + +``` text +┌─name─────────┐ +│ regions │ +│ region_names │ +└──────────────┘ +``` + + + +## SHOW GRANTS {#show-grants-statement} + +Выводит привилегии пользователя. + +### Синтаксис {#show-grants-syntax} + +``` sql +SHOW GRANTS [FOR user] +``` + +Если пользователь не задан, запрос возвращает привилегии текущего пользователя. + + + +## SHOW CREATE USER {#show-create-user-statement} + +Выводит параметры, использованные при [создании пользователя](create.md#create-user-statement). + +`SHOW CREATE USER` не возвращает пароль пользователя. + +### Синтаксис {#show-create-user-syntax} + +``` sql +SHOW CREATE USER [name | CURRENT_USER] +``` + + + +## SHOW CREATE ROLE {#show-create-role-statement} + +Выводит параметры, использованные при [создании роли](create.md#create-role-statement). + +### Синтаксис {#show-create-role-syntax} + +``` sql +SHOW CREATE ROLE name +``` + + + +## SHOW CREATE ROW POLICY {#show-create-row-policy-statement} + +Выводит параметры, использованные при [создании политики доступа к строкам](create.md#create-row-policy-statement). + +### Синтаксис {#show-create-row-policy-syntax} + +```sql +SHOW CREATE [ROW] POLICY name ON [database.]table +``` + + +## SHOW CREATE QUOTA {#show-create-quota-statement} + +Выводит параметры, использованные при [создании квоты](create.md#create-quota-statement). + +### Синтаксис {#show-create-row-policy-syntax} + +```sql +SHOW CREATE QUOTA [name | CURRENT] +``` + + +## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile-statement} + +Выводит параметры, использованные при [создании профиля настроек](create.md#create-settings-profile-statement). + +### Синтаксис {#show-create-row-policy-syntax} + +```sql +SHOW CREATE [SETTINGS] PROFILE name +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/show/) diff --git a/docs/ru/sql-reference/statements/system.md b/docs/ru/sql-reference/statements/system.md new file mode 100644 index 00000000000..1b66fa039d9 --- /dev/null +++ b/docs/ru/sql-reference/statements/system.md @@ -0,0 +1,247 @@ +# Запросы SYSTEM {#query-language-system} + +- [RELOAD EMBEDDED DICTIONARIES](#query_language-system-reload-emdedded-dictionaries) +- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) +- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) +- [DROP DNS CACHE](#query_language-system-drop-dns-cache) +- [DROP MARK CACHE](#query_language-system-drop-mark-cache) +- [DROP UNCOMPRESSED CACHE](#query_language-system-drop-uncompressed-cache) +- [DROP COMPILED EXPRESSION CACHE](#query_language-system-drop-compiled-expression-cache) +- [FLUSH LOGS](#query_language-system-flush_logs) +- [RELOAD CONFIG](#query_language-system-reload-config) +- [SHUTDOWN](#query_language-system-shutdown) +- [KILL](#query_language-system-kill) +- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) +- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) +- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) +- [STOP MERGES](#query_language-system-stop-merges) +- [START MERGES](#query_language-system-start-merges) +- [STOP TTL MERGES](#query_language-stop-ttl-merges) +- [START TTL MERGES](#query_language-start-ttl-merges) +- [STOP MOVES](#query_language-stop-moves) +- [START MOVES](#query_language-start-moves) +- [STOP FETCHES](#query_language-system-stop-fetches) +- [START FETCHES](#query_language-system-start-fetches) +- [STOP REPLICATED SENDS](#query_language-system-start-replicated-sends) +- [START REPLICATED SENDS](#query_language-system-start-replicated-sends) +- [STOP REPLICATION QUEUES](#query_language-system-stop-replication-queues) +- [START REPLICATION QUEUES](#query_language-system-start-replication-queues) +- [SYNC REPLICA](#query_language-system-sync-replica) +- [RESTART REPLICA](#query_language-system-restart-replica) +- [RESTART REPLICAS](#query_language-system-restart-replicas) + +## RELOAD EMBEDDED DICTIONARIES] {#query_language-system-reload-emdedded-dictionaries} +Перегружет все [Встроенные словари](../dictionaries/internal-dicts.md). +По умолчанию встроенные словари выключены. +Всегда возвращает `Ok.`, вне зависимости от результата обновления встроенных словарей. + +## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} + +Перегружает все словари, которые были успешно загружены до этого. +По умолчанию включена ленивая загрузка [dictionaries\_lazy\_load](../../sql-reference/statements/system.md#dictionaries-lazy-load), поэтому словари не загружаются автоматически при старте, а только при первом обращении через dictGet или SELECT к ENGINE=Dictionary. После этого такие словари (LOADED) будут перегружаться командой `system reload dictionaries`. +Всегда возвращает `Ok.`, вне зависимости от результата обновления словарей. + +## RELOAD DICTIONARY Dictionary\_name {#query_language-system-reload-dictionary} + +Полностью перегружает словарь `dictionary_name`, вне зависимости от состояния словаря (LOADED/NOT\_LOADED/FAILED). +Всегда возвращает `Ok.`, вне зависимости от результата обновления словаря. +Состояние словаря можно проверить запросом к `system.dictionaries`. + +``` sql +SELECT name, status FROM system.dictionaries; +``` + +## DROP DNS CACHE {#query_language-system-drop-dns-cache} + +Сбрасывает внутренний DNS кеш ClickHouse. Иногда (для старых версий ClickHouse) необходимо использовать эту команду при изменении инфраструктуры (смене IP адреса у другого ClickHouse сервера или сервера, используемого словарями). + +Для более удобного (автоматического) управления кешем см. параметры disable\_internal\_dns\_cache, dns\_cache\_update\_period. + +## DROP MARK CACHE {#query_language-system-drop-mark-cache} + +Сбрасывает кеш «засечек» (`mark cache`). Используется при разработке ClickHouse и тестах производительности. + +## DROP UNCOMPRESSED CACHE {#query_language-system-drop-uncompressed-cache} + +Сбрасывает кеш не сжатых данных. Используется при разработке ClickHouse и тестах производительности. +Для управления кешем не сжатых данных используйте следующие настройки уровня сервера [uncompressed_cache_size](../../operations/server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) и настройки уровня запрос/пользователь/профиль [use_uncompressed_cache](../../operations/settings/settings.md#setting-use_uncompressed_cache) + + +## DROP COMPILED EXPRESSION CACHE {#query_language-system-drop-compiled-expression-cache} +Сбрасывает кеш скомпилированных выражений. Используется при разработке ClickHouse и тестах производительности. +Компилированные выражения используются когда включена настройка уровня запрос/пользователь/профиль [compile](../../operations/settings/settings.md#compile) + +## FLUSH LOGS {#query_language-system-flush_logs} + +Записывает буферы логов в системные таблицы (например system.query\_log). Позволяет не ждать 7.5 секунд при отладке. + +## RELOAD CONFIG {#query_language-system-reload-config} + +Перечитывает конфигурацию настроек ClickHouse. Используется при хранении конфигурации в zookeeeper. + +## SHUTDOWN {#query_language-system-shutdown} + +Штатно завершает работу ClickHouse (аналог `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) + +## KILL {#query_language-system-kill} + +Аварийно завершает работу ClickHouse (аналог `kill -9 {$pid_clickhouse-server}`) + +## Управление распределёнными таблицами {#query-language-system-distributed} + +ClickHouse может оперировать [распределёнными](../../sql-reference/statements/system.md) таблицами. Когда пользователь вставляет данные в эти таблицы, ClickHouse сначала формирует очередь из данных, которые должны быть отправлены на узлы кластера, а затем асинхронно отправляет подготовленные данные. Вы можете управлять очередью с помощью запросов [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) и [FLUSH DISTRIBUTED](#query_language-system-flush-distributed). Также есть возможность синхронно вставлять распределенные данные с помощью настройки `insert_distributed_sync`. + +### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} + +Отключает фоновую отправку при вставке данных в распределённые таблицы. + +``` sql +SYSTEM STOP DISTRIBUTED SENDS [db.] +``` + +### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} + +В синхронном режиме отправляет все данные на узлы кластера. Если какие-либо узлы недоступны, ClickHouse генерирует исключение и останавливает выполнение запроса. Такой запрос можно повторять до успешного завершения, что будет означать возвращение связанности с остальными узлами кластера. + +``` sql +SYSTEM FLUSH DISTRIBUTED [db.] +``` + +### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} + +Включает фоновую отправку при вставке данных в распределенные таблицы. + +``` sql +SYSTEM START DISTRIBUTED SENDS [db.] +``` + +## Managing MergeTree Tables {#query-language-system-mergetree} + +ClickHouse может управлять фоновыми процессами в [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) таблицах. + +### STOP MERGES {#query_language-system-stop-merges} + +Позволяет остановить фоновые мержи для таблиц семейства MergeTree: + +``` sql +SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] +``` + +!!! note "Note" + `DETACH / ATTACH` таблицы восстанавливает фоновые мержи для этой таблицы (даже в случае отключения фоновых мержей для всех таблиц семейства MergeTree до `DETACH`). + +### START MERGES {#query_language-system-start-merges} + +Включает фоновые мержи для таблиц семейства MergeTree: + +``` sql +SYSTEM START MERGES [[db.]merge_tree_family_table_name] +``` + +### STOP TTL MERGES {#query_language-stop-ttl-merges} + +Позволяет остановить фоновые процессы удаления старых данных основанные на [выражениях TTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) для таблиц семейства MergeTree: +Возвращает `Ok.` даже если указана несуществующая таблица или таблица имеет тип отличный от MergeTree. Возвращает ошибку если указана не существующая база данных: + +``` sql +SYSTEM STOP TTL MERGES [[db.]merge_tree_family_table_name] +``` + +### START TTL MERGES {#query_language-start-ttl-merges} + +Запускает фоновые процессы удаления старых данных основанные на [выражениях TTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) для таблиц семейства MergeTree: +Возвращает `Ok.` даже если указана несуществующая таблица или таблица имеет тип отличный от MergeTree. Возвращает ошибку если указана не существующая база данных: + +``` sql +SYSTEM START TTL MERGES [[db.]merge_tree_family_table_name] +``` + +### STOP MOVES {#query_language-stop-moves} + +Позволяет остановить фоновые процессы переноса данных основанные [табличных выражениях TTL с использованием TO VOLUME или TO DISK](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) for tables in the MergeTree family: +Возвращает `Ok.` даже если указана несуществующая таблица или таблица имеет тип отличный от MergeTree. Возвращает ошибку если указана не существующая база данных: + +``` sql +SYSTEM STOP MOVES [[db.]merge_tree_family_table_name] +``` + +### START MOVES {#query_language-start-moves} + +Запускает фоновые процессы переноса данных основанные [табличных выражениях TTL с использованием TO VOLUME или TO DISK](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) for tables in the MergeTree family: +Возвращает `Ok.` даже если указана несуществующая таблица или таблица имеет тип отличный от MergeTree. Возвращает ошибку если указана не существующая база данных: + +``` sql +SYSTEM STOP MOVES [[db.]merge_tree_family_table_name] +``` + +## Managing ReplicatedMergeTree Tables {#query-language-system-replicated} + +ClickHouse может управлять фоновыми процессами связанными c репликацией в таблицах семейства [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replacingmergetree.md). + +### STOP FETCHES {#query_language-system-stop-fetches} +Позволяет остановить фоновые процессы синхронизации новыми вставленными кусками данных с другими репликами в кластере для таблиц семейства `ReplicatedMergeTree`: +Всегда возвращает `Ok.` вне зависимости от типа таблицы и даже если таблица или база данных не существет. + +``` sql +SYSTEM STOP FETCHES [[db.]replicated_merge_tree_family_table_name] +``` + +### START FETCHES {#query_language-system-start-fetches} +Позволяет запустить фоновые процессы синхронизации новыми вставленными кусками данных с другими репликами в кластере для таблиц семейства `ReplicatedMergeTree`: +Всегда возвращает `Ok.` вне зависимости от типа таблицы и даже если таблица или база данных не существет. + +``` sql +SYSTEM START FETCHES [[db.]replicated_merge_tree_family_table_name] +``` + +### STOP REPLICATED SENDS {#query_language-system-start-replicated-sends} +Позволяет остановить фоновые процессы отсылки новых вставленных кусков данных другим репликам в кластере для таблиц семейства `ReplicatedMergeTree`: + +``` sql +SYSTEM STOP REPLICATED SENDS [[db.]replicated_merge_tree_family_table_name] +``` + +### START REPLICATED SENDS {#query_language-system-start-replicated-sends} +Позволяет запустить фоновые процессы отсылки новых вставленных кусков данных другим репликам в кластере для таблиц семейства `ReplicatedMergeTree`: + +``` sql +SYSTEM START REPLICATED SENDS [[db.]replicated_merge_tree_family_table_name] +``` + +### STOP REPLICATION QUEUES {#query_language-system-stop-replication-queues} +Останавливает фоновые процессы разбора заданий из очереди репликации которая хранится в Zookeeper для таблиц семейства `ReplicatedMergeTree`. Возможные типы заданий - merges, fetches, mutation, DDL запросы с ON CLUSTER: + +``` sql +SYSTEM STOP REPLICATION QUEUES [[db.]replicated_merge_tree_family_table_name] +``` + +### START REPLICATION QUEUES {#query_language-system-start-replication-queues} +Запускает фоновые процессы разбора заданий из очереди репликации которая хранится в Zookeeper для таблиц семейства `ReplicatedMergeTree`. Возможные типы заданий - merges, fetches, mutation, DDL запросы с ON CLUSTER: + +``` sql +SYSTEM START REPLICATION QUEUES [[db.]replicated_merge_tree_family_table_name] +``` + +### SYNC REPLICA {#query_language-system-sync-replica} +Ждет когда таблица семейства `ReplicatedMergeTree` будет синхронизирована с другими репликами в кластере, будет работать до достижения `receive_timeout`, если синхронизация для таблицы отключена в настоящий момент времени: + +``` sql +SYSTEM SYNC REPLICA [db.]replicated_merge_tree_family_table_name +``` + +### RESTART REPLICA {#query_language-system-restart-replica} +Реинициализация состояния Zookeeper сессий для таблицы семейства `ReplicatedMergeTree`, сравнивает текущее состояние с тем что хранится в Zookeeper как источник правды и добавляет задачи Zookeeper очередь если необходимо +Инициализация очереди репликации на основе данных ZooKeeper, происходит так же как при attach table. На короткое время таблица станет недоступной для любых операций. + +``` sql +SYSTEM RESTART QUEUES [db.]replicated_merge_tree_family_table_name +``` + +### RESTART REPLICAS {#query_language-system-restart-replicas} +Реинициализация состояния Zookeeper сессий для всех `ReplicatedMergeTree` таблиц, сравнивает текущее состояние с тем что хранится в Zookeeper как источник правды и добавляет задачи Zookeeper очередь если необходимо + +``` sql +SYSTEM RESTART QUEUES [db.]replicated_merge_tree_family_table_name +``` + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/system/) diff --git a/docs/ru/sql-reference/syntax.md b/docs/ru/sql-reference/syntax.md new file mode 100644 index 00000000000..41a9c012b71 --- /dev/null +++ b/docs/ru/sql-reference/syntax.md @@ -0,0 +1,179 @@ +# Синтаксис {#sintaksis} + +В системе есть два вида парсеров: полноценный парсер SQL (recursive descent parser) и парсер форматов данных (быстрый потоковый парсер). +Во всех случаях кроме запроса INSERT, используется только полноценный парсер SQL. +В запросе INSERT используется оба парсера: + +``` sql +INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') +``` + +Фрагмент `INSERT INTO t VALUES` парсится полноценным парсером, а данные `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` - быстрым потоковым парсером. +Данные могут иметь любой формат. При получении запроса, сервер заранее считывает в оперативку не более `max_query_size` байт запроса (по умолчанию, 1МБ), а всё остальное обрабатывается потоково. +Таким образом, в системе нет проблем с большими INSERT запросами, как в MySQL. + +При использовании формата Values в INSERT запросе может сложиться иллюзия, что данные парсятся также, как выражения в запросе SELECT, но это не так. Формат Values гораздо более ограничен. + +Далее пойдёт речь о полноценном парсере. О парсерах форматов, смотри раздел «Форматы». + +## Пробелы {#probely} + +Между синтаксическими конструкциями (в том числе, в начале и конце запроса) может быть расположено произвольное количество пробельных символов. К пробельным символам относятся пробел, таб, перевод строки, CR, form feed. + +## Комментарии {#kommentarii} + +Поддерживаются комментарии в SQL-стиле и C-стиле. +Комментарии в SQL-стиле: от `--` до конца строки. Пробел после `--` может не ставиться. +Комментарии в C-стиле: от `/*` до `*/`. Такие комментарии могут быть многострочными. Пробелы тоже не обязательны. + +## Ключевые слова {#syntax-keywords} + +Ключевые слова не зависят от регистра, если они соответствуют: + +- Стандарту SQL. Например, применение любого из вариантов `SELECT`, `select` или `SeLeCt` не вызовет ошибки. +- Реализации в некоторых популярных DBMS (MySQL или Postgres). Например, `DateTime` и `datetime`. + +Зависимость от регистра для имён типов данных можно проверить в таблице [system.data_type_families](../operations/system-tables.md#system_tables-data_type_families). + +В отличие от стандарта SQL, все остальные ключевые слова, включая названия функций зависят от регистра. + +Ключевые слова не зарезервированы (а всего лишь парсятся как ключевые слова в соответствующем контексте). Если вы используете [идентификаторы](#syntax-identifiers), совпадающие с ключевыми словами, заключите их в кавычки. Например, запрос `SELECT "FROM" FROM table_name` валиден, если таблица `table_name` имеет столбец с именем `"FROM"`. + +## Идентификаторы {#syntax-identifiers} + +Идентификаторы: + +- Имена кластеров, баз данных, таблиц, разделов и столбцов; +- Функции; +- Типы данных; +- [Синонимы выражений](#syntax-expression_aliases). + +Некоторые идентификаторы нужно указывать в кавычках (например, идентификаторы с пробелами). Прочие идентификаторы можно указывать без кавычек. Рекомендуется использовать идентификаторы, не требующие кавычек. + +Идентификаторы не требующие кавычек соответствуют регулярному выражению `^[a-zA-Z_][0-9a-zA-Z_]*$` и не могут совпадать с [ключевыми словами](#syntax-keywords). Примеры: `x, _1, X_y__Z123_.` + +Если вы хотите использовать идентификаторы, совпадающие с ключевыми словами, или использовать в идентификаторах символы, не входящие в регулярное выражение, заключите их в двойные или обратные кавычки, например, `"id"`, `` `id` ``. + +## Литералы {#literals} + +Существуют: числовые, строковые, составные литералы и `NULL`. + +### Числовые {#chislovye} + +Числовой литерал пытается распарситься: + +- Сначала как знаковое 64-разрядное число, функцией [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul). +- Если не получилось, то как беззнаковое 64-разрядное число, функцией [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol). +- Если не получилось, то как число с плавающей запятой, функцией [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof). +- Иначе — ошибка. + +Соответствующее значение будет иметь тип минимального размера, который вмещает значение. +Например, 1 парсится как `UInt8`, а 256 как `UInt16`. Подробнее о типах данных читайте в разделе [Типы данных](../sql-reference/syntax.md). + +Примеры: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. + +### Строковые {#syntax-string-literal} + +Поддерживаются только строковые литералы в одинарных кавычках. Символы внутри могут быть экранированы с помощью обратного слеша. Следующие escape-последовательности имеют соответствующее специальное значение: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. Во всех остальных случаях, последовательности вида `\c`, где `c` — любой символ, преобразуется в `c` . Таким образом, могут быть использованы последовательности `\'` и `\\`. Значение будет иметь тип [String](../sql-reference/syntax.md). + +Минимальный набор символов, которых вам необходимо экранировать в строковых литералах: `'` и `\`. Одинарная кавычка может быть экранирована одинарной кавычкой, литералы `'It\'s'` и `'It''s'` эквивалентны. + +### Составные {#sostavnye} + +Поддерживаются конструкции для массивов: `[1, 2, 3]` и кортежей: `(1, 'Hello, world!', 2)`. +На самом деле, это вовсе не литералы, а выражение с оператором создания массива и оператором создания кортежа, соответственно. +Массив должен состоять хотя бы из одного элемента, а кортеж - хотя бы из двух. +Кортежи носят служебное значение для использования в секции `IN` запроса `SELECT`. Кортежи могут быть получены как результат запроса, но они не могут быть сохранены в базе данных (за исключением таблицы [Memory](../sql-reference/syntax.md).) + +### NULL {#null-literal} + +Обозначает, что значение отсутствует. + +Чтобы в поле таблицы можно было хранить `NULL`, оно должно быть типа [Nullable](../sql-reference/syntax.md). + +В зависимости от формата данных (входных или выходных) `NULL` может иметь различное представление. Подробнее смотрите в документации для [форматов данных](../interfaces/formats.md#formats). + +При обработке `NULL` есть множество особенностей. Например, если хотя бы один из аргументов операции сравнения — `NULL`, то результатом такой операции тоже будет `NULL`. Этим же свойством обладают операции умножения, сложения и пр. Подробнее читайте в документации на каждую операцию. + +В запросах можно проверить `NULL` с помощью операторов [IS NULL](operators/index.md#operator-is-null) и [IS NOT NULL](operators/index.md), а также соответствующих функций `isNull` и `isNotNull`. + +## Функции {#funktsii} + +Функции записываются как идентификатор со списком аргументов (возможно, пустым) в скобках. В отличие от стандартного SQL, даже в случае пустого списка аргументов, скобки обязательны. Пример: `now()`. +Бывают обычные и агрегатные функции (смотрите раздел «Агрегатные функции»). Некоторые агрегатные функции могут содержать два списка аргументов в круглых скобках. Пример: `quantile(0.9)(x)`. Такие агрегатные функции называются «параметрическими», а первый список аргументов называется «параметрами». Синтаксис агрегатных функций без параметров ничем не отличается от обычных функций. + +## Операторы {#operatory} + +Операторы преобразуются в соответствующие им функции во время парсинга запроса, с учётом их приоритета и ассоциативности. +Например, выражение `1 + 2 * 3 + 4` преобразуется в `plus(plus(1, multiply(2, 3)), 4)`. + +## Типы данных и движки таблиц {#tipy-dannykh-i-dvizhki-tablits} + +Типы данных и движки таблиц в запросе `CREATE` записываются также, как идентификаторы или также как функции. То есть, могут содержать или не содержать список аргументов в круглых скобках. Подробнее смотрите разделы «Типы данных», «Движки таблиц», «CREATE». + +## Синонимы выражений {#syntax-expression_aliases} + +Синоним — это пользовательское имя выражения в запросе. + +``` sql +expr AS alias +``` + +- `AS` — ключевое слово для определения синонимов. Можно определить синоним для имени таблицы или столбца в секции `SELECT` без использования ключевого слова `AS` . + + Например, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. + + В функции [CAST](sql_reference/syntax.md#type_conversion_function-cast), ключевое слово `AS` имеет другое значение. Смотрите описание функции. + +- `expr` — любое выражение, которое поддерживает ClickHouse. + + Например, `SELECT column_name * 2 AS double FROM some_table`. + +- `alias` — имя для `выражения`. Синонимы должны соответствовать синтаксису [идентификаторов](#syntax-identifiers). + + Например, `SELECT "table t".column_name FROM table_name AS "table t"`. + +### Примечания по использованию {#primechaniia-po-ispolzovaniiu} + +Синонимы являются глобальными для запроса или подзапроса, и вы можете определить синоним в любой части запроса для любого выражения. Например, `SELECT (1 AS n) + 2, n`. + +Синонимы не передаются в подзапросы и между подзапросами. Например, при выполнении запроса `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouse сгенерирует исключение `Unknown identifier: num`. + +Если синоним определен для результирующих столбцов в секции `SELECT` вложенного запроса, то эти столбцы отображаются во внешнем запросе. Например, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. + +Будьте осторожны с синонимами, совпадающими с именами столбцов или таблиц. Рассмотрим следующий пример: + +``` sql +CREATE TABLE t +( + a Int, + b Int +) +ENGINE = TinyLog() +``` + +``` sql +SELECT + argMax(a, b), + sum(b) AS b +FROM t +``` + +``` text +Received exception from server (version 18.14.17): +Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. +``` + +В этом примере мы объявили таблицу `t` со столбцом `b`. Затем, при выборе данных, мы определили синоним `sum(b) AS b`. Поскольку синонимы глобальные, то ClickHouse заменил литерал `b` в выражении `argMax(a, b)` выражением `sum(b)`. Эта замена вызвала исключение. + +## Звёздочка {#zviozdochka} + +В запросе `SELECT`, вместо выражения может стоять звёздочка. Подробнее смотрите раздел «SELECT». + +## Выражения {#syntax-expressions} + +Выражение представляет собой функцию, идентификатор, литерал, применение оператора, выражение в скобках, подзапрос, звёздочку. А также может содержать синоним. +Список выражений - одно выражение или несколько выражений через запятую. +Функции и операторы, в свою очередь, в качестве аргументов, могут иметь произвольные выражения. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/syntax/) diff --git a/docs/ru/sql-reference/table-functions/file.md b/docs/ru/sql-reference/table-functions/file.md new file mode 100644 index 00000000000..103ff34753c --- /dev/null +++ b/docs/ru/sql-reference/table-functions/file.md @@ -0,0 +1,107 @@ +# file {#file} + +Создаёт таблицу из файла. Данная табличная функция похожа на табличные функции [file](file.md) и [hdfs](hdfs.md). + +``` sql +file(path, format, structure) +``` + +**Входные параметры** + +- `path` — относительный путь до файла от [user\_files\_path](../../sql-reference/table-functions/file.md#server_configuration_parameters-user_files_path). Путь к файлу поддерживает следующие шаблоны в режиме доступа только для чтения `*`, `?`, `{abc,def}` и `{N..M}`, где `N`, `M` — числа, \``'abc', 'def'` — строки. +- `format` — [формат](../../interfaces/formats.md#formats) файла. +- `structure` — структура таблицы. Формат `'colunmn1_name column1_ype, column2_name column2_type, ...'`. + +**Возвращаемое значение** + +Таблица с указанной структурой, предназначенная для чтения или записи данных в указанном файле. + +**Пример** + +Настройка `user_files_path` и содержимое файла `test.csv`: + +``` bash +$ grep user_files_path /etc/clickhouse-server/config.xml + /var/lib/clickhouse/user_files/ + +$ cat /var/lib/clickhouse/user_files/test.csv + 1,2,3 + 3,2,1 + 78,43,45 +``` + +Таблица из `test.csv` и выборка первых двух строк из неё: + +``` sql +SELECT * +FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +Шаблоны могут содержаться в нескольких компонентах пути. Обрабатываются только существующие файлы, название которых целиком удовлетворяет шаблону (не только суффиксом или префиксом). + +- `*` — Заменяет любое количество любых символов кроме `/`, включая отсутствие символов. +- `?` — Заменяет ровно один любой символ. +- `{some_string,another_string,yet_another_one}` — Заменяет любую из строк `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Заменяет любое число в интервале от `N` до `M` включительно (может содержать ведущие нули). + +Конструкция с `{}` аналогична табличной функции [remote](remote.md). + +**Пример** + +1. Предположим у нас есть несколько файлов со следующими относительными путями: + +- ‘some\_dir/some\_file\_1’ +- ‘some\_dir/some\_file\_2’ +- ‘some\_dir/some\_file\_3’ +- ‘another\_dir/some\_file\_1’ +- ‘another\_dir/some\_file\_2’ +- ‘another\_dir/some\_file\_3’ + +1. Запросим количество строк в этих файлах: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. Запросим количество строк во всех файлах этих двух директорий: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "Warning" + Если ваш список файлов содержит интервал с ведущими нулями, используйте конструкцию с фигурными скобками для каждой цифры по отдельности или используйте `?`. + +**Пример** + +Запрос данных из файлов с именами `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## Виртуальные столбцы {#virtualnye-stolbtsy} + +- `_path` — Путь к файлу. +- `_file` — Имя файла. + +**Смотрите также** + +- [Виртуальные столбцы](index.md#table_engines-virtual_columns) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/file/) diff --git a/docs/ru/sql_reference/table_functions/generate.md b/docs/ru/sql-reference/table-functions/generate.md similarity index 100% rename from docs/ru/sql_reference/table_functions/generate.md rename to docs/ru/sql-reference/table-functions/generate.md diff --git a/docs/ru/sql_reference/table_functions/hdfs.md b/docs/ru/sql-reference/table-functions/hdfs.md similarity index 100% rename from docs/ru/sql_reference/table_functions/hdfs.md rename to docs/ru/sql-reference/table-functions/hdfs.md diff --git a/docs/ru/sql-reference/table-functions/index.md b/docs/ru/sql-reference/table-functions/index.md new file mode 100644 index 00000000000..6e09dd4e41c --- /dev/null +++ b/docs/ru/sql-reference/table-functions/index.md @@ -0,0 +1,37 @@ +--- +toc_folder_title: "\u0422\u0430\u0431\u043B\u0438\u0447\u043D\u044B\u0435 \u0444\u0443\ + \u043D\u043A\u0446\u0438\u0438" +toc_priority: 34 +toc_title: "\u0412\u0432\u0435\u0434\u0435\u043D\u0438\u0435" +--- + +# Табличные функции {#table-functions} + +Табличные функции — это метод создания таблиц. + +Табличные функции можно использовать в: + +- Секции [FROM](../statements/select/from.md#select-from) запроса `SELECT`. + + Это способ создания временной таблицы, которая доступна только в текущем запросе. + +- Запросе [CREATE TABLE AS \](../statements/create.md#create-table-query). + + Это один из методов создания таблицы. + +!!! warning "Предупреждение" + Если настройка [allow\_ddl](../../operations/settings/permissions-for-queries.md#settings_allow_ddl) выключена, то использовать табличные функции невозможно. + +| Функция | Описание | +|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------| +| [file](file.md) | Создаёт таблицу с движком [File](../../sql-reference/table-functions/index.md). | +| [merge](merge.md) | Создаёт таблицу с движком [Merge](../../sql-reference/table-functions/index.md). | +| [numbers](numbers.md) | Создаёт таблицу с единственным столбцом, заполненным целыми числами. | +| [remote](remote.md) | Предоставляет доступ к удалённым серверам, не создавая таблицу с движком [Distributed](../../sql-reference/table-functions/index.md). | +| [url](url.md) | Создаёт таблицу с движком [Url](../../sql-reference/table-functions/index.md). | +| [mysql](mysql.md) | Создаёт таблицу с движком [MySQL](../../sql-reference/table-functions/index.md). | +| [jdbc](jdbc.md) | Создаёт таблицу с дижком [JDBC](../../sql-reference/table-functions/index.md). | +| [odbc](odbc.md) | Создаёт таблицу с движком [ODBC](../../sql-reference/table-functions/index.md). | +| [hdfs](hdfs.md) | Создаёт таблицу с движком [HDFS](../../sql-reference/table-functions/index.md). | + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/) diff --git a/docs/ru/sql_reference/table_functions/input.md b/docs/ru/sql-reference/table-functions/input.md similarity index 100% rename from docs/ru/sql_reference/table_functions/input.md rename to docs/ru/sql-reference/table-functions/input.md diff --git a/docs/ru/sql_reference/table_functions/jdbc.md b/docs/ru/sql-reference/table-functions/jdbc.md similarity index 100% rename from docs/ru/sql_reference/table_functions/jdbc.md rename to docs/ru/sql-reference/table-functions/jdbc.md diff --git a/docs/ru/sql_reference/table_functions/merge.md b/docs/ru/sql-reference/table-functions/merge.md similarity index 100% rename from docs/ru/sql_reference/table_functions/merge.md rename to docs/ru/sql-reference/table-functions/merge.md diff --git a/docs/ru/sql-reference/table-functions/mysql.md b/docs/ru/sql-reference/table-functions/mysql.md new file mode 100644 index 00000000000..99d82022df4 --- /dev/null +++ b/docs/ru/sql-reference/table-functions/mysql.md @@ -0,0 +1,79 @@ +# mysql {#mysql} + +Позволяет выполнять запросы `SELECT` над данными, хранящимися на удалённом MySQL сервере. + +``` sql +mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +**Параметры** + +- `host:port` — адрес сервера MySQL. + +- `database` — имя базы данных на удалённом сервере. + +- `table` — имя таблицы на удалённом сервере. + +- `user` — пользователь MySQL. + +- `password` — пароль пользователя. + +- `replace_query` — флаг, отвечающий за преобразование запросов `INSERT INTO` в `REPLACE INTO`. Если `replace_query=1`, то запрос заменяется. + +- `on_duplicate_clause` — выражение `ON DUPLICATE KEY on_duplicate_clause`, добавляемое в запрос `INSERT`. + + Пример: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, где `on_duplicate_clause` это `UPDATE c2 = c2 + 1`. Чтобы узнать какие `on_duplicate_clause` можно использовать с секцией `ON DUPLICATE KEY` обратитесь к документации MySQL. + + Чтобы указать `'on_duplicate_clause'` необходимо передать `0` в параметр `replace_query`. Если одновременно передать `replace_query = 1` и `'on_duplicate_clause'`, то ClickHouse сгенерирует исключение. + +Простые условия `WHERE` такие как `=, !=, >, >=, <, =` выполняются на стороне сервера MySQL. + +Остальные условия и ограничение выборки `LIMIT` будут выполнены в ClickHouse только после выполнения запроса к MySQL. + +**Возвращаемое значение** + +Объект таблицы с теми же столбцами, что и в исходной таблице MySQL. + +## Пример использования {#primer-ispolzovaniia} + +Таблица в MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++--------+--------------+-------+----------------+ +| int_id | int_nullable | float | float_nullable | ++--------+--------------+-------+----------------+ +| 1 | NULL | 2 | NULL | ++--------+--------------+-------+----------------+ +1 row in set (0,00 sec) +``` + +Получение данных в ClickHouse: + +``` sql +SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## Смотрите также {#smotrite-takzhe} + +- [Движок таблиц ‘MySQL’](../../sql-reference/table-functions/mysql.md) +- [Использование MySQL как источника данных для внешнего словаря](../../sql-reference/table-functions/mysql.md#dicts-external_dicts_dict_sources-mysql) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/mysql/) diff --git a/docs/ru/sql_reference/table_functions/numbers.md b/docs/ru/sql-reference/table-functions/numbers.md similarity index 100% rename from docs/ru/sql_reference/table_functions/numbers.md rename to docs/ru/sql-reference/table-functions/numbers.md diff --git a/docs/ru/sql-reference/table-functions/odbc.md b/docs/ru/sql-reference/table-functions/odbc.md new file mode 100644 index 00000000000..38da5066cbd --- /dev/null +++ b/docs/ru/sql-reference/table-functions/odbc.md @@ -0,0 +1,101 @@ +# odbc {#table-functions-odbc} + +Возвращает таблицу, подключенную через [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +``` sql +odbc(connection_settings, external_database, external_table) +``` + +Параметры: + +- `connection_settings` — название секции с настройками соединения в файле `odbc.ini`. +- `external_database` — имя базы данных во внешней СУБД. +- `external_table` — имя таблицы в `external_database`. + +Чтобы использование ODBC было безопасным, ClickHouse использует отдельную программу `clickhouse-odbc-bridge`. Если драйвер ODBC подгружать непосредственно из `clickhouse-server`, то проблемы с драйвером могут привести к аварийной остановке сервера ClickHouse. ClickHouse автоматически запускает `clickhouse-odbc-bridge` по мере необходимости. Программа устанавливается из того же пакета, что и `clickhouse-server`. + +Поля из внешней таблицы со значениями `NULL` получают значение по умолчанию для базового типа данных. Например, если поле в удалённой таблице MySQL имеет тип `INT NULL` оно сконвертируется в 0 (значение по умолчанию для типа данных ClickHouse `Int32`). + +## Пример использования {#primer-ispolzovaniia} + +**Получение данных из локальной установки MySQL через ODBC** + +Этот пример проверялся в Ubuntu Linux 18.04 для MySQL server 5.7. + +Убедитесь, что unixODBC и MySQL Connector установлены. + +По умолчанию (если установлен из пакетов) ClickHouse запускается от имени пользователя `clickhouse`. Таким образом, вам нужно создать и настроить этого пользователя на сервере MySQL. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +Теперь настроим соединение в `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +Вы можете проверить соединение с помощью утилиты `isql` из установки unixODBC. + +``` bash +$ isql -v mysqlconn ++---------------------------------------+ +| Connected! | +| | +... +``` + +Таблица в MySQL: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++--------+--------------+-------+----------------+ +| int_id | int_nullable | float | float_nullable | ++--------+--------------+-------+----------------+ +| 1 | NULL | 2 | NULL | ++--------+--------------+-------+----------------+ +1 row in set (0,00 sec) +``` + +Получение данных из таблицы MySQL в ClickHouse: + +``` sql +SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ 0 │ 2 │ 0 │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## Смотрите также {#smotrite-takzhe} + +- [Внешние словари ODBC](../../sql-reference/table-functions/odbc.md#dicts-external_dicts_dict_sources-odbc) +- [Движок таблиц ODBC](../../sql-reference/table-functions/odbc.md). + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/jdbc/) diff --git a/docs/ru/sql-reference/table-functions/remote.md b/docs/ru/sql-reference/table-functions/remote.md new file mode 100644 index 00000000000..55c602d4bbf --- /dev/null +++ b/docs/ru/sql-reference/table-functions/remote.md @@ -0,0 +1,76 @@ +# remote, remoteSecure {#remote-remotesecure} + +Позволяет обратиться к удалённым серверам без создания таблицы типа `Distributed`. + +Сигнатуры: + +``` sql +remote('addresses_expr', db, table[, 'user'[, 'password']]) +remote('addresses_expr', db.table[, 'user'[, 'password']]) +``` + +`addresses_expr` - выражение, генерирующее адреса удалённых серверов. Это может быть просто один адрес сервера. Адрес сервера - это `хост:порт`, или только `хост`. Хост может быть указан в виде имени сервера, или в виде IPv4 или IPv6 адреса. IPv6 адрес указывается в квадратных скобках. Порт - TCP-порт удалённого сервера. Если порт не указан, используется `tcp_port` из конфигурационного файла сервера (по умолчанию - 9000). + +!!! important "Важно" + С IPv6-адресом обязательно нужно указывать порт. + +Примеры: + +``` text +example01-01-1 +example01-01-1:9000 +localhost +127.0.0.1 +[::]:9000 +[2a02:6b8:0:1111::11]:9000 +``` + +Адреса можно указать через запятую, в этом случае ClickHouse обработает запрос как распределённый, т.е. отправит его по всем указанным адресам как на шарды с разными данными. + +Пример: + +``` text +example01-01-1,example01-02-1 +``` + +Часть выражения может быть указана в фигурных скобках. Предыдущий пример может быть записан следующим образом: + +``` text +example01-0{1,2}-1 +``` + +В фигурных скобках может быть указан диапазон (неотрицательных целых) чисел через две точки. В этом случае, диапазон раскрывается в множество значений, генерирующих адреса шардов. Если запись первого числа начинается с нуля, то значения формируются с таким же выравниванием нулями. Предыдущий пример может быть записан следующим образом: + +``` text +example01-{01..02}-1 +``` + +При наличии нескольких пар фигурных скобок, генерируется прямое произведение соответствующих множеств. + +Адреса или их фрагменты в фигурных скобках можно указать через символ \|. В этом случае, соответствующие множества адресов понимаются как реплики - запрос будет отправлен на первую живую реплику. При этом, реплики перебираются в порядке, согласно текущей настройке [load\_balancing](../../operations/settings/settings.md). + +Пример: + +``` text +example01-{01..02}-{1|2} +``` + +В этом примере указано два шарда, в каждом из которых имеется две реплики. + +Количество генерируемых адресов ограничено константой - сейчас это 1000 штук. + +Использование табличной функции `remote` менее оптимально, чем создание таблицы типа `Distributed`, так как в этом случае, соединения с серверами устанавливаются заново при каждом запросе, в случае задания имён хостов, делается резолвинг имён, а также не ведётся подсчёт ошибок при работе с разными репликами. При обработке большого количества запросов, всегда создавайте `Distributed` таблицу заранее, не используйте табличную функцию `remote`. + +Табличная функция `remote` может быть полезна для следующих случаях: + +- обращение на конкретный сервер в целях сравнения данных, отладки и тестирования; +- запросы между разными кластерами ClickHouse в целях исследований; +- нечастых распределённых запросов, задаваемых вручную; +- распределённых запросов, где набор серверов определяется каждый раз заново. + +Если пользователь не задан,то используется `default`. +Если пароль не задан, то используется пустой пароль. + +`remoteSecure` - аналогично функции `remote`, но с соединением по шифрованному каналу. Порт по умолчанию - `tcp_port_secure` из конфига или 9440. + +[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/remote/) diff --git a/docs/ru/sql_reference/table_functions/url.md b/docs/ru/sql-reference/table-functions/url.md similarity index 100% rename from docs/ru/sql_reference/table_functions/url.md rename to docs/ru/sql-reference/table-functions/url.md diff --git a/docs/ru/sql_reference/aggregate_functions/combinators.md b/docs/ru/sql_reference/aggregate_functions/combinators.md deleted file mode 100644 index e4295f0d76e..00000000000 --- a/docs/ru/sql_reference/aggregate_functions/combinators.md +++ /dev/null @@ -1,116 +0,0 @@ -# Комбинаторы агрегатных функций {#aggregate_functions_combinators} - -К имени агрегатной функции может быть приписан некоторый суффикс. При этом, работа агрегатной функции некоторым образом модифицируется. - -## -If {#agg-functions-combinator-if} - -К имени любой агрегатной функции может быть приписан суффикс -If. В этом случае, агрегатная функция принимает ещё один дополнительный аргумент - условие (типа UInt8). Агрегатная функция будет обрабатывать только те строки, для которых условие сработало. Если условие ни разу не сработало - возвращается некоторое значение по умолчанию (обычно - нули, пустые строки). - -Примеры: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` и т. п. - -С помощью условных агрегатных функций, вы можете вычислить агрегаты сразу для нескольких условий, не используя подзапросы и `JOIN`-ы. -Например, в Яндекс.Метрике, условные агрегатные функции используются для реализации функциональности сравнения сегментов. - -## -Array {#array} - -К имени любой агрегатной функции может быть приписан суффикс -Array. В этом случае, агрегатная функция вместо аргументов типов T принимает аргументы типов Array(T) (массивы). Если агрегатная функция принимает несколько аргументов, то это должны быть массивы одинаковых длин. При обработке массивов, агрегатная функция работает, как исходная агрегатная функция по всем элементам массивов. - -Пример 1: `sumArray(arr)` - просуммировать все элементы всех массивов arr. В данном примере можно было бы написать проще: `sum(arraySum(arr))`. - -Пример 2: `uniqArray(arr)` - посчитать количество уникальных элементов всех массивов arr. Это можно было бы сделать проще: `uniq(arrayJoin(arr))`, но не всегда есть возможность добавить arrayJoin в запрос. - -Комбинаторы -If и -Array можно сочетать. При этом, должен сначала идти Array, а потом If. Примеры: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. Из-за такого порядка получается, что аргумент cond не должен быть массивом. - -## -State {#state} - -В случае применения этого комбинатора, агрегатная функция возвращает не готовое значение (например, в случае функции [uniq](reference.md#agg_function-uniq) — количество уникальных значений), а промежуточное состояние агрегации (например, в случае функции `uniq` — хэш-таблицу для расчёта количества уникальных значений), которое имеет тип `AggregateFunction(...)` и может использоваться для дальнейшей обработки или может быть сохранено в таблицу для последующей доагрегации. - -Для работы с промежуточными состояниями предназначены: - -- Движок таблиц [AggregatingMergeTree](../../engines/table_engines/mergetree_family/aggregatingmergetree.md). -- Функция [finalizeAggregation](../../sql_reference/aggregate_functions/combinators.md#function-finalizeaggregation). -- Функция [runningAccumulate](../../sql_reference/aggregate_functions/combinators.md#function-runningaccumulate). -- Комбинатор [-Merge](#aggregate_functions_combinators_merge). -- Комбинатор [-MergeState](#aggregate_functions_combinators_mergestate). - -## -Merge {#aggregate_functions_combinators-merge} - -В случае применения этого комбинатора, агрегатная функция будет принимать в качестве аргумента промежуточное состояние агрегации, доагрегировать (объединять вместе) эти состояния, и возвращать готовое значение. - -## -MergeState {#aggregate_functions_combinators-mergestate} - -Выполняет слияние промежуточных состояний агрегации, аналогично комбинатору -Merge, но возвращает не готовое значение, а промежуточное состояние агрегации, аналогично комбинатору -State. - -## -ForEach {#foreach} - -Преобразует агрегатную функцию для таблиц в агрегатную функцию для массивов, которая применяет агрегирование для соответствующих элементов массивов и возвращает массив результатов. Например, `sumForEach` для массивов `[1, 2]`, `[3, 4, 5]` и `[6, 7]` даст результат `[10, 13, 5]`, сложив соответственные элементы массивов. - -## -Resample {#agg-functions-combinator-resample} - -Позволяет поделить данные на группы, а затем по-отдельности агрегирует данные для этих групп. Группы образуются разбиением значений одного из столбцов на интервалы. - -``` sql -Resample(start, end, step)(, resampling_key) -``` - -**Параметры** - -- `start` — начальное значение для интервала значений `resampling_key`. -- `stop` — конечное значение для интервала значений `resampling_key`. Интервал не включает значение `stop` (`[start, stop)`). -- `step` — шаг деления полного интервала на подинтервалы. Функция `aggFunction` выполняется для каждого из подинтервалов независимо. -- `resampling_key` — столбец, значения которого используются для разделения данных на интервалы. -- `aggFunction_params` — параметры `aggFunction`. - -**Возвращаемые значения** - -- Массив результатов `aggFunction` для каждого подинтервала. - -**Пример** - -Рассмотрим таблицу `people` со следующими данными: - -``` text -┌─name───┬─age─┬─wage─┐ -│ John │ 16 │ 10 │ -│ Alice │ 30 │ 15 │ -│ Mary │ 35 │ 8 │ -│ Evelyn │ 48 │ 11.5 │ -│ David │ 62 │ 9.9 │ -│ Brian │ 60 │ 16 │ -└────────┴─────┴──────┘ -``` - -Получим имена людей, чей возраст находится в интервалах `[30,60)` и `[60,75)`. Поскольку мы используем целочисленное представление возраста, то интервалы будут выглядеть как `[30, 59]` и `[60,74]`. - -Чтобы собрать имена в массив, возьмём агрегатную функцию [groupArray](reference.md#agg_function-grouparray). Она принимает один аргумент. В нашем случае, это столбец `name`. Функция `groupArrayResample` должна использовать столбец `age` для агрегирования имён по возрасту. Чтобы определить необходимые интервалы, передадим в функцию `groupArrayResample` аргументы `30, 75, 30`. - -``` sql -SELECT groupArrayResample(30, 75, 30)(name, age) from people -``` - -``` text -┌─groupArrayResample(30, 75, 30)(name, age)─────┐ -│ [['Alice','Mary','Evelyn'],['David','Brian']] │ -└───────────────────────────────────────────────┘ -``` - -Посмотрим на результаты. - -`Jonh` не попал в выдачу, поскольку слишком молод. Остальные распределены согласно заданным возрастным интервалам. - -Теперь посчитаем общее количество людей и их среднюю заработную плату в заданных возрастных интервалах. - -``` sql -SELECT - countResample(30, 75, 30)(name, age) AS amount, - avgResample(30, 75, 30)(wage, age) AS avg_wage -FROM people -``` - -``` text -┌─amount─┬─avg_wage──────────────────┐ -│ [3,2] │ [11.5,12.949999809265137] │ -└────────┴───────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/combinators/) diff --git a/docs/ru/sql_reference/aggregate_functions/index.md b/docs/ru/sql_reference/aggregate_functions/index.md deleted file mode 100644 index d28e105f6fc..00000000000 --- a/docs/ru/sql_reference/aggregate_functions/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -toc_folder_title: Агрегатные функции -toc_priority: 33 -toc_title: Введение ---- - -# Агрегатные функции {#aggregate-functions} - -Агрегатные функции работают в [привычном](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) для специалистов по базам данных смысле. - -ClickHouse поддерживает также: - -- [Параметрические агрегатные функции](parametric_functions.md#aggregate_functions_parametric), которые помимо столбцов принимаю и другие параметры. -- [Комбинаторы](combinators.md#aggregate_functions_combinators), которые изменяют поведение агрегатных функций. - -## Обработка NULL {#obrabotka-null} - -При агрегации все `NULL` пропускаются. - -**Примеры** - -Рассмотрим таблицу: - -``` text -┌─x─┬────y─┐ -│ 1 │ 2 │ -│ 2 │ ᴺᵁᴸᴸ │ -│ 3 │ 2 │ -│ 3 │ 3 │ -│ 3 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -Выполним суммирование значений в столбце `y`: - -``` sql -SELECT sum(y) FROM t_null_big -``` - -``` text -┌─sum(y)─┐ -│ 7 │ -└────────┘ -``` - -Функция `sum` работает с `NULL` как с `0`. В частности, это означает, что если на вход в функцию подать выборку, где все значения `NULL`, то результат будет `0`, а не `NULL`. - -Теперь с помощью функции `groupArray` сформируем массив из столбца `y`: - -``` sql -SELECT groupArray(y) FROM t_null_big -``` - -``` text -┌─groupArray(y)─┐ -│ [2,2,3] │ -└───────────────┘ -``` - -`groupArray` не включает `NULL` в результирующий массив. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/) diff --git a/docs/ru/sql_reference/aggregate_functions/parametric_functions.md b/docs/ru/sql_reference/aggregate_functions/parametric_functions.md deleted file mode 100644 index 70430d21eae..00000000000 --- a/docs/ru/sql_reference/aggregate_functions/parametric_functions.md +++ /dev/null @@ -1,479 +0,0 @@ -# Параметрические агрегатные функции {#aggregate_functions_parametric} - -Некоторые агрегатные функции могут принимать не только столбцы-аргументы (по которым производится свёртка), но и набор параметров - констант для инициализации. Синтаксис - две пары круглых скобок вместо одной. Первая - для параметров, вторая - для аргументов. - -## histogram {#histogram} - -Рассчитывает адаптивную гистограмму. Не гарантирует точного результата. - - histogram(number_of_bins)(values) - -Функция использует [A Streaming Parallel Decision Tree Algorithm](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). Границы столбцов устанавливаются по мере поступления новых данных в функцию. В общем случае столбцы имею разную ширину. - -**Параметры** - -`number_of_bins` — максимальное количество корзин в гистограмме. Функция автоматически вычисляет количество корзин. Она пытается получить указанное количество корзин, но если не получилось, то в результате корзин будет меньше. -`values` — [выражение](../syntax.md#syntax-expressions), предоставляющее входные значения. - -**Возвращаемые значения** - -- [Массив](../../sql_reference/data_types/array.md) [кортежей](../../sql_reference/data_types/tuple.md) следующего вида: - - ``` - [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] - ``` - - - `lower` — нижняя граница корзины. - - `upper` — верхняя граница корзины. - - `height` — количество значений в корзине. - -**Пример** - -``` sql -SELECT histogram(5)(number + 1) -FROM ( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ -│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -С помощью функции [bar](../../sql_reference/aggregate_functions/parametric_functions.md#function-bar) можно визуализировать гистограмму, например: - -``` sql -WITH histogram(5)(rand() % 100) AS hist -SELECT - arrayJoin(hist).3 AS height, - bar(height, 0, 6, 5) AS bar -FROM -( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─height─┬─bar───┐ -│ 2.125 │ █▋ │ -│ 3.25 │ ██▌ │ -│ 5.625 │ ████▏ │ -│ 5.625 │ ████▏ │ -│ 3.375 │ ██▌ │ -└────────┴───────┘ -``` - -В этом случае необходимо помнить, что границы корзин гистограммы не известны. - -## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} - -Проверяет, содержит ли последовательность событий цепочку, которая соответствует указанному шаблону. - -``` sql -sequenceMatch(pattern)(timestamp, cond1, cond2, ...) -``` - -!!! warning "Предупреждение" - События, произошедшие в одну и ту же секунду, располагаются в последовательности в неопределенном порядке, что может повлиять на результат работы функции. - -**Параметры** - -- `pattern` — строка с шаблоном. Смотрите [Синтаксис шаблонов](#sequence-function-pattern-syntax). - -- `timestamp` — столбец, содержащий метки времени. Типичный тип данных столбца — `Date` или `DateTime`. Также можно использовать любой из поддержанных типов данных [UInt](../../sql_reference/aggregate_functions/parametric_functions.md). - -- `cond1`, `cond2` — условия, описывающие цепочку событий. Тип данных — `UInt8`. Можно использовать до 32 условий. Функция учитывает только те события, которые указаны в условиях. Функция пропускает данные из последовательности, если они не описаны ни в одном из условий. - -**Возвращаемые значения** - -- 1, если цепочка событий, соответствующая шаблону найдена. -- 0, если цепочка событий, соответствующая шаблону не найдена. - -Тип: `UInt8`. - - -**Синтаксис шаблонов** - -- `(?N)` — соответствует условию на позиции `N`. Условия пронумерованы по порядку в диапазоне `[1, 32]`. Например, `(?1)` соответствует условию, заданному параметром `cond1`. - -- `.*` — соответствует любому количеству событий. Для этого элемента шаблона не надо задавать условия. - -- `(?t operator value)` — устанавливает время в секундах, которое должно разделять два события. Например, шаблон `(?1)(?t>1800)(?2)` соответствует событиям, которые произошли более чем через 1800 секунд друг от друга. Между этими событиями может находиться произвольное количество любых событий. Операторы могут быть `>=`, `>`, `<`, `<=`. - -**Примеры** - -Пусть таблица `t` содержит следующие данные: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -└──────┴────────┘ -``` - -Выполним запрос: - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 1 │ -└───────────────────────────────────────────────────────────────────────┘ -``` - -Функция нашла цепочку событий, в которой число 2 следует за числом 1. Число 3 между ними было пропущено, поскольку оно не было использовано ни в одном из условий. - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ -│ 0 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -В этом случае функция не может найти цепочку событий, соответствующую шаблону, поскольку событие для числа 3 произошло между 1 и 2. Если бы в этом же случае мы бы проверяли условие на событие для числа 4, то цепочка бы соответствовала шаблону. - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ -│ 1 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Смотрите также** - -- [sequenceCount](#function-sequencecount) - -## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} - -Вычисляет количество цепочек событий, соответствующих шаблону. Функция обнаруживает только непересекающиеся цепочки событий. Она начитает искать следующую цепочку только после того, как полностью совпала текущая цепочка событий. - -!!! warning "Предупреждение" - События, произошедшие в одну и ту же секунду, располагаются в последовательности в неопределенном порядке, что может повлиять на результат работы функции. - -``` sql -sequenceCount(pattern)(timestamp, cond1, cond2, ...) -``` - -**Параметры** - -- `pattern` — строка с шаблоном. Смотрите [Синтаксис шаблонов](#sequence-function-pattern-syntax). - -- `timestamp` — столбец, содержащий метки времени. Типичный тип данных столбца — `Date` или `DateTime`. Также можно использовать любой из поддержанных типов данных [UInt](../../sql_reference/aggregate_functions/parametric_functions.md). - -- `cond1`, `cond2` — условия, описывающие цепочку событий. Тип данных — `UInt8`. Можно использовать до 32 условий. Функция учитывает только те события, которые указаны в условиях. Функция пропускает данные из последовательности, если они не описаны ни в одном из условий. - -**Возвращаемое значение** - -- Число непересекающихся цепочек событий, соответствущих шаблону. - -Тип: `UInt64`. - -**Пример** - -Пусть таблица `t` содержит следующие данные: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -│ 4 │ 1 │ -│ 5 │ 3 │ -│ 6 │ 2 │ -└──────┴────────┘ -``` - -Вычислим сколько раз число 2 стоит после числа 1, причем между 1 и 2 могут быть любые числа: - -``` sql -SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 2 │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -**Смотрите также** - -- [sequenceMatch](#function-sequencematch) - -## windowFunnel {#windowfunnel} - -Отыскивает цепочки событий в скользящем окне по времени и вычисляет максимальное количество произошедших событий из цепочки. - -Функция работает по алгоритму: - -- Функция отыскивает данные, на которых срабатывает первое условие из цепочки, и присваивает счетчику событий значение 1. С этого же момента начинается отсчет времени скользящего окна. - -- Если в пределах окна последовательно попадаются события из цепочки, то счетчик увеличивается. Если последовательность событий нарушается, то счетчик не растет. - -- Если в данных оказалось несколько цепочек разной степени завершенности, то функция выдаст только размер самой длинной цепочки. - -**Синтаксис** - -``` sql -windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) -``` - -**Параметры** - -- `window` — ширина скользящего окна по времени в секундах. [UInt](../../sql_reference/aggregate_functions/parametric_functions.md). -- `mode` - необязательный параметр. Если установлено значение `'strict'`, то функция `windowFunnel()` применяет условия только для уникальных значений. -- `timestamp` — имя столбца, содержащего временные отметки. [Date](../../sql_reference/aggregate_functions/parametric_functions.md), [DateTime](../../sql_reference/aggregate_functions/parametric_functions.md#data_type-datetime) и другие параметры с типом `Integer`. В случае хранения меток времени в столбцах с типом `UInt64`, максимально допустимое значение соответствует ограничению для типа `Int64`, т.е. равно `2^63-1`. -- `cond` — условия или данные, описывающие цепочку событий. [UInt8](../../sql_reference/aggregate_functions/parametric_functions.md). - -**Возвращаемое значение** - -Максимальное количество последовательно сработавших условий из цепочки в пределах скользящего окна по времени. Исследуются все цепочки в выборке. - -Тип: `Integer`. - -**Пример** - -Определим, успевает ли пользователь за установленный период выбрать телефон в интернет-магазине, купить его и сделать повторный заказ. - -Зададим следующую цепочку событий: - -1. Пользователь вошел в личный кабинет (`eventID = 1001`). -2. Пользователь ищет телефон (`eventID = 1003, product = 'phone'`). -3. Пользователь сделал заказ (`eventID = 1009`) -4. Пользователь сделал повторный заказ (`eventID = 1010`). - -Входная таблица: - -``` text -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -``` - -Сделаем запрос и узнаем, как далеко пользователь `user_id` смог пройти по цепочке за период в январе-феврале 2019-го года. - -Запрос: - -``` sql -SELECT - level, - count() AS c -FROM -( - SELECT - user_id, - windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level - FROM trend - WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') - GROUP BY user_id -) -GROUP BY level -ORDER BY level ASC -``` - -## retention {#retention} - -Аналитическая функция, которая показывает, насколько -выдерживаются те или иные условия, например, удержание динамики/уровня [посещаемости сайта](https://yandex.ru/support/partner2/statistics/metrika-visitors-statistics.html?lang=ru). - -Функция принимает набор (от 1 до 32) логических условий, как в [WHERE](../../sql_reference/statements/select.md#select-where), и применяет их к заданному набору данных. - -Условия, кроме первого, применяются попарно: результат второго будет истинным, если истинно первое и второе, третьего - если истинно первое и третье и т. д. - -**Синтаксис** - -``` sql -retention(cond1, cond2, ..., cond32) -``` - -**Параметры** - -- `cond` — вычисляемое условие или выражение, которое возвращает `UInt8` результат (1/0). - -**Возвращаемое значение** - -Массив из 1 или 0. - -- 1 — условие выполнено. -- 0 — условие не выполнено. - -Тип: `UInt8`. - -**Пример** - -Рассмотрим пример расчета функции `retention` для определения посещаемости сайта. - -**1.** Создадим таблицу для илюстрации примера. - -``` sql -CREATE TABLE retention_test(date Date, uid Int32)ENGINE = Memory; - -INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); -INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); -INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); -``` - -Входная таблица: - -Запрос: - -``` sql -SELECT * FROM retention_test -``` - -Ответ: - -``` text -┌───────date─┬─uid─┐ -│ 2020-01-01 │ 0 │ -│ 2020-01-01 │ 1 │ -│ 2020-01-01 │ 2 │ -│ 2020-01-01 │ 3 │ -│ 2020-01-01 │ 4 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-02 │ 0 │ -│ 2020-01-02 │ 1 │ -│ 2020-01-02 │ 2 │ -│ 2020-01-02 │ 3 │ -│ 2020-01-02 │ 4 │ -│ 2020-01-02 │ 5 │ -│ 2020-01-02 │ 6 │ -│ 2020-01-02 │ 7 │ -│ 2020-01-02 │ 8 │ -│ 2020-01-02 │ 9 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-03 │ 0 │ -│ 2020-01-03 │ 1 │ -│ 2020-01-03 │ 2 │ -│ 2020-01-03 │ 3 │ -│ 2020-01-03 │ 4 │ -│ 2020-01-03 │ 5 │ -│ 2020-01-03 │ 6 │ -│ 2020-01-03 │ 7 │ -│ 2020-01-03 │ 8 │ -│ 2020-01-03 │ 9 │ -│ 2020-01-03 │ 10 │ -│ 2020-01-03 │ 11 │ -│ 2020-01-03 │ 12 │ -│ 2020-01-03 │ 13 │ -│ 2020-01-03 │ 14 │ -└────────────┴─────┘ -``` - -**2.** Сгруппируем пользователей по уникальному идентификатору `uid` с помощью функции `retention`. - -Запрос: - -``` sql -SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r -FROM retention_test -WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') -GROUP BY uid -ORDER BY uid ASC -``` - -Результат: - -``` text -┌─uid─┬─r───────┐ -│ 0 │ [1,1,1] │ -│ 1 │ [1,1,1] │ -│ 2 │ [1,1,1] │ -│ 3 │ [1,1,1] │ -│ 4 │ [1,1,1] │ -│ 5 │ [0,0,0] │ -│ 6 │ [0,0,0] │ -│ 7 │ [0,0,0] │ -│ 8 │ [0,0,0] │ -│ 9 │ [0,0,0] │ -│ 10 │ [0,0,0] │ -│ 11 │ [0,0,0] │ -│ 12 │ [0,0,0] │ -│ 13 │ [0,0,0] │ -│ 14 │ [0,0,0] │ -└─────┴─────────┘ -``` - -**3.** Рассчитаем количество посещений сайта за день. - -Запрос: - -``` sql -SELECT - sum(r[1]) AS r1, - sum(r[2]) AS r2, - sum(r[3]) AS r3 -FROM -( - SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r - FROM retention_test - WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') - GROUP BY uid -) -``` - -Результат: - -``` text -┌─r1─┬─r2─┬─r3─┐ -│ 5 │ 5 │ 5 │ -└────┴────┴────┘ -``` - -Где: - -- `r1` - количество уникальных посетителей за 2020-01-01 (`cond1`). -- `r2` - количество уникальных посетителей в период между 2020-01-01 и 2020-01-02 (`cond1` и `cond2`). -- `r3` - количество уникальных посетителей в период между 2020-01-01 и 2020-01-03 (`cond1` и `cond3`). - -## uniqUpTo(N)(x) {#uniquptonx} - -Вычисляет количество различных значений аргумента, если оно меньше или равно N. -В случае, если количество различных значений аргумента больше N, возвращает N + 1. - -Рекомендуется использовать для маленьких N - до 10. Максимальное значение N - 100. - -Для состояния агрегатной функции используется количество оперативки равное 1 + N \* размер одного значения байт. -Для строк запоминается не криптографический хэш, имеющий размер 8 байт. То есть, для строк вычисление приближённое. - -Функция также работает для нескольких аргументов. - -Работает максимально быстро за исключением патологических случаев, когда используется большое значение N и количество уникальных значений чуть меньше N. - -Пример применения: - -``` text -Задача: показывать в отчёте только поисковые фразы, по которым было хотя бы 5 уникальных посетителей. -Решение: пишем в запросе GROUP BY SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/parametric_functions/) diff --git a/docs/ru/sql_reference/aggregate_functions/reference.md b/docs/ru/sql_reference/aggregate_functions/reference.md deleted file mode 100644 index b84e92ef7a8..00000000000 --- a/docs/ru/sql_reference/aggregate_functions/reference.md +++ /dev/null @@ -1,1739 +0,0 @@ -# Справочник функций {#spravochnik-funktsii} - -## count {#agg_function-count} - -Вычисляет количество строк или не NULL значений . - -ClickHouse поддерживает следующие виды синтаксиса для `count`: - -- `count(expr)` или `COUNT(DISTINCT expr)`. -- `count()` или `COUNT(*)`. Синтаксис `count()` специфичен для ClickHouse. - -**Параметры** - -Функция может принимать: - -- Ноль параметров. -- Одно [выражение](../syntax.md#syntax-expressions). - -**Возвращаемое значение** - -- Если функция вызывается без параметров, она вычисляет количество строк. -- Если передаётся [выражение](../syntax.md#syntax-expressions) , то функция вычисляет количество раз, когда выражение возвращает не NULL. Если выражение возвращает значение типа [Nullable](../../sql_reference/data_types/nullable.md), то результат `count` не становится `Nullable`. Функция возвращает 0, если выражение возвращает `NULL` для всех строк. - -В обоих случаях тип возвращаемого значения [UInt64](../../sql_reference/data_types/int_uint.md). - -**Подробности** - -ClickHouse поддерживает синтаксис `COUNT(DISTINCT ...)`. Поведение этой конструкции зависит от настройки [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation). Она определяет, какая из функций [uniq\*](#agg_function-uniq) используется для выполнения операции. По умолчанию — функция [uniqExact](#agg_function-uniqexact). - -Запрос `SELECT count() FROM table` не оптимизирован, поскольку количество записей в таблице не хранится отдельно. Он выбирает небольшой столбец из таблицы и подсчитывает количество значений в нём. - -**Примеры** - -Пример 1: - -``` sql -SELECT count() FROM t -``` - -``` text -┌─count()─┐ -│ 5 │ -└─────────┘ -``` - -Пример 2: - -``` sql -SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' -``` - -``` text -┌─name──────────────────────────┬─value─────┐ -│ count_distinct_implementation │ uniqExact │ -└───────────────────────────────┴───────────┘ -``` - -``` sql -SELECT count(DISTINCT num) FROM t -``` - -``` text -┌─uniqExact(num)─┐ -│ 3 │ -└────────────────┘ -``` - -Этот пример показывает, что `count(DISTINCT num)` выполняется с помощью функции `uniqExact` в соответствии со значением настройки `count_distinct_implementation`. - -## any(x) {#agg_function-any} - -Выбирает первое попавшееся значение. -Порядок выполнения запроса может быть произвольным и даже каждый раз разным, поэтому результат данной функции недетерминирован. -Для получения детерминированного результата, можно использовать функции min или max вместо any. - -В некоторых случаях, вы всё-таки можете рассчитывать на порядок выполнения запроса. Это - случаи, когда SELECT идёт из подзапроса, в котором используется ORDER BY. - -При наличии в запросе `SELECT` секции `GROUP BY` или хотя бы одной агрегатной функции, ClickHouse (в отличие от, например, MySQL) требует, чтобы все выражения в секциях `SELECT`, `HAVING`, `ORDER BY` вычислялись из ключей или из агрегатных функций. То есть, каждый выбираемый из таблицы столбец, должен использоваться либо в ключах, либо внутри агрегатных функций. Чтобы получить поведение, как в MySQL, вы можете поместить остальные столбцы в агрегатную функцию `any`. - -## anyHeavy(x) {#agg_function-anyheavy} - -Выбирает часто встречающееся значение с помощью алгоритма «[heavy hitters](http://www.cs.umd.edu/~samir/498/karp.pdf)». Если существует значение, которое встречается чаще, чем в половине случаев, в каждом потоке выполнения запроса, то возвращается данное значение. В общем случае, результат недетерминирован. - -``` sql -anyHeavy(column) -``` - -**Аргументы** - -- `column` — имя столбца. - -**Пример** - -Возьмём набор данных [OnTime](../../getting_started/example_datasets/ontime.md) и выберем произвольное часто встречающееся значение в столбце `AirlineID`. - -``` sql -SELECT anyHeavy(AirlineID) AS res -FROM ontime -``` - -``` text -┌───res─┐ -│ 19690 │ -└───────┘ -``` - -## anyLast(x) {#agg_function-anylast} - -Выбирает последнее попавшееся значение. -Результат так же недетерминирован, как и для функции `any`. - -## groupBitAnd {#groupbitand} - -Применяет побитовое `И` для последовательности чисел. - -``` sql -groupBitAnd(expr) -``` - -**Параметры** - -`expr` – выражение, результат которого имеет тип данных `UInt*`. - -**Возвращаемое значение** - -Значение типа `UInt*`. - -**Пример** - -Тестовые данные: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -Запрос: - -``` sql -SELECT groupBitAnd(num) FROM t -``` - -Где `num` — столбец с тестовыми данными. - -Результат: - -``` text -binary decimal -00000100 = 4 -``` - -## groupBitOr {#groupbitor} - -Применяет побитовое `ИЛИ` для последовательности чисел. - -``` sql -groupBitOr(expr) -``` - -**Параметры** - -`expr` – выражение, результат которого имеет тип данных `UInt*`. - -**Возвращаемое значение** - -Значение типа `UInt*`. - -**Пример** - -Тестовые данные: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -Запрос: - -``` sql -SELECT groupBitOr(num) FROM t -``` - -Где `num` — столбец с тестовыми данными. - -Результат: - -``` text -binary decimal -01111101 = 125 -``` - -## groupBitXor {#groupbitxor} - -Применяет побитовое `ИСКЛЮЧАЮЩЕЕ ИЛИ` для последовательности чисел. - -``` sql -groupBitXor(expr) -``` - -**Параметры** - -`expr` – выражение, результат которого имеет тип данных `UInt*`. - -**Возвращаемое значение** - -Значение типа `UInt*`. - -**Пример** - -Тестовые данные: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -Запрос: - -``` sql -SELECT groupBitXor(num) FROM t -``` - -Где `num` — столбец с тестовыми данными. - -Результат: - -``` text -binary decimal -01101000 = 104 -``` - -## groupBitmap {#groupbitmap} - -Bitmap или агрегатные вычисления для столбца с типом данных `UInt*`, возвращают кардинальность в виде значения типа UInt64, если добавить суффикс -State, то возвращают [объект bitmap](../../sql_reference/aggregate_functions/reference.md). - -``` sql -groupBitmap(expr) -``` - -**Параметры** - -`expr` – выражение, результат которого имеет тип данных `UInt*`. - -**Возвращаемое значение** - -Значение типа `UInt64`. - -**Пример** - -Тестовые данные: - -``` text -UserID -1 -1 -2 -3 -``` - -Запрос: - -``` sql -SELECT groupBitmap(UserID) as num FROM t -``` - -Результат: - -``` text -num -3 -``` - -## min(x) {#agg_function-min} - -Вычисляет минимум. - -## max(x) {#agg_function-max} - -Вычисляет максимум. - -## argMin(arg, val) {#agg-function-argmin} - -Вычисляет значение arg при минимальном значении val. Если есть несколько разных значений arg для минимальных значений val, то выдаётся первое попавшееся из таких значений. - -**Пример:** - -``` text -┌─user─────┬─salary─┐ -│ director │ 5000 │ -│ manager │ 3000 │ -│ worker │ 1000 │ -└──────────┴────────┘ -``` - -``` sql -SELECT argMin(user, salary) FROM salary -``` - -``` text -┌─argMin(user, salary)─┐ -│ worker │ -└──────────────────────┘ -``` - -## argMax(arg, val) {#agg-function-argmax} - -Вычисляет значение arg при максимальном значении val. Если есть несколько разных значений arg для максимальных значений val, то выдаётся первое попавшееся из таких значений. - -## sum(x) {#agg_function-sum} - -Вычисляет сумму. -Работает только для чисел. - -## sumWithOverflow(x) {#agg_function-sumwithoverflow} - -Вычисляет сумму чисел, используя для результата тот же тип данных, что и для входных параметров. Если сумма выйдет за максимальное значение для заданного типа данных, то функция вернёт ошибку. - -Работает только для чисел. - -## sumMap(key, value) {#summapkey-value} - -Производит суммирование массива ‘value’ по соответствующим ключам заданным в массиве ‘key’. -Количество элементов в ‘key’ и ‘value’ должно быть одинаковым для каждой строки, для которой происходит суммирование. -Возвращает кортеж из двух массивов - ключи в отсортированном порядке и значения, просуммированные по соответствующим ключам. - -Пример: - -``` sql -CREATE TABLE sum_map( - date Date, - timeslot DateTime, - statusMap Nested( - status UInt16, - requests UInt64 - ) -) ENGINE = Log; -INSERT INTO sum_map VALUES - ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10]); -SELECT - timeslot, - sumMap(statusMap.status, statusMap.requests) -FROM sum_map -GROUP BY timeslot -``` - -``` text -┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┐ -│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ -│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ -└─────────────────────┴──────────────────────────────────────────────┘ -``` - -## skewPop {#skewpop} - -Вычисляет [коэффициент асимметрии](https://ru.wikipedia.org/wiki/Коэффициент_асимметрии) для последовательности. - -``` sql -skewPop(expr) -``` - -**Параметры** - -`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. - -**Возвращаемое значение** - -Коэффициент асимметрии заданного распределения. Тип — [Float64](../../sql_reference/aggregate_functions/reference.md) - -**Пример** - -``` sql -SELECT skewPop(value) FROM series_with_value_column -``` - -## skewSamp {#skewsamp} - -Вычисляет [выборочный коэффициент асимметрии](https://ru.wikipedia.org/wiki/Статистика_(функция_выборки)) для последовательности. - -Он представляет собой несмещенную оценку асимметрии случайной величины, если переданные значения образуют ее выборку. - -``` sql -skewSamp(expr) -``` - -**Параметры** - -`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. - -**Возвращаемое значение** - -Коэффициент асимметрии заданного распределения. Тип — [Float64](../../sql_reference/aggregate_functions/reference.md). Если `n <= 1` (`n` — размер выборки), тогда функция возвращает `nan`. - -**Пример** - -``` sql -SELECT skewSamp(value) FROM series_with_value_column -``` - -## kurtPop {#kurtpop} - -Вычисляет [коэффициент эксцесса](https://ru.wikipedia.org/wiki/Коэффициент_эксцесса) последовательности. - -``` sql -kurtPop(expr) -``` - -**Параметры** - -`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. - -**Возвращаемое значение** - -Коэффициент эксцесса заданного распределения. Тип — [Float64](../../sql_reference/aggregate_functions/reference.md) - -**Пример** - -``` sql -SELECT kurtPop(value) FROM series_with_value_column -``` - -## kurtSamp {#kurtsamp} - -Вычисляет [выборочный коэффициент эксцесса](https://ru.wikipedia.org/wiki/Статистика_(функция_выборки)) для последовательности. - -Он представляет собой несмещенную оценку эксцесса случайной величины, если переданные значения образуют ее выборку. - -``` sql -kurtSamp(expr) -``` - -**Параметры** - -`expr` — [Выражение](../syntax.md#syntax-expressions), возвращающее число. - -**Возвращаемое значение** - -Коэффициент эксцесса заданного распределения. Тип — [Float64](../../sql_reference/aggregate_functions/reference.md). Если `n <= 1` (`n` — размер выборки), тогда функция возвращает `nan`. - -**Пример** - -``` sql -SELECT kurtSamp(value) FROM series_with_value_column -``` - -## timeSeriesGroupSum(uid, timestamp, value) {#agg-function-timeseriesgroupsum} - -`timeSeriesGroupSum` агрегирует временные ряды в которых не совпадают моменты. -Функция использует линейную интерполяцию между двумя значениями времени, а затем суммирует значения для одного и того же момента (как измеренные так и интерполированные) по всем рядам. - -- `uid` уникальный идентификатор временного ряда, `UInt64`. -- `timestamp` имеет тип `Int64` чтобы можно было учитывать милли и микросекунды. -- `value` представляет собой значение метрики. - -Функция возвращает массив кортежей с парами `(timestamp, aggregated_value)`. - -Временные ряды должны быть отсортированы по возрастанию `timestamp`. - -Пример: - -``` text -┌─uid─┬─timestamp─┬─value─┐ -│ 1 │ 2 │ 0.2 │ -│ 1 │ 7 │ 0.7 │ -│ 1 │ 12 │ 1.2 │ -│ 1 │ 17 │ 1.7 │ -│ 1 │ 25 │ 2.5 │ -│ 2 │ 3 │ 0.6 │ -│ 2 │ 8 │ 1.6 │ -│ 2 │ 12 │ 2.4 │ -│ 2 │ 18 │ 3.6 │ -│ 2 │ 24 │ 4.8 │ -└─────┴───────────┴───────┘ -``` - -``` sql -CREATE TABLE time_series( - uid UInt64, - timestamp Int64, - value Float64 -) ENGINE = Memory; -INSERT INTO time_series VALUES - (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), - (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); - -SELECT timeSeriesGroupSum(uid, timestamp, value) -FROM ( - SELECT * FROM time_series order by timestamp ASC -); -``` - -И результат будет: - -``` text -[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] -``` - -## timeSeriesGroupRateSum(uid, ts, val) {#agg-function-timeseriesgroupratesum} - -Аналогично timeSeriesGroupSum, timeSeriesGroupRateSum будет вычислять производные по timestamp для рядов, а затем суммировать полученные производные для всех рядов для одного значения timestamp. -Также ряды должны быть отсортированы по возрастанию timestamp. - -Для пример из описания timeSeriesGroupSum результат будет следующим: - -``` text -[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] -``` - -## avg(x) {#agg_function-avg} - -Вычисляет среднее. -Работает только для чисел. -Результат всегда Float64. - - -## avgWeighted {#avgweighted} - -Вычисляет [среднее арифметическое взвешенное](https://ru.wikipedia.org/wiki/Среднее_арифметическое_взвешенное). - -**Синтаксис** - -```sql -avgWeighted(x, weight) -``` - -**Параметры** - -- `x` — Значения. [Целые числа](../../sql_reference/aggregate_functions/reference.md) или [числа с плавающей запятой](../../sql_reference/aggregate_functions/reference.md). -- `weight` — Веса отдельных значений. [Целые числа](../../sql_reference/aggregate_functions/reference.md) или [числа с плавающей запятой](../../sql_reference/aggregate_functions/reference.md). - -Типы параметров должны совпадать. - -**Возвращаемое значение** - -- Среднее арифметическое взвешенное. -- `NaN`, если все веса равны 0. - -Тип: [Float64](../../sql_reference/aggregate_functions/reference.md) - -**Пример** - -Запрос: - -```sql -SELECT avgWeighted(x, w) -FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) -``` - -Результат: - -```text -┌─avgWeighted(x, weight)─┐ -│ 8 │ -└────────────────────────┘ -``` - - -## uniq {#agg_function-uniq} - -Приближённо вычисляет количество различных значений аргумента. - -``` sql -uniq(x[, ...]) -``` - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. - -**Возвращаемое значение** - -- Значение с типом данных [UInt64](../../sql_reference/aggregate_functions/reference.md). - -**Детали реализации** - -Функция: - -- Вычисляет хэш для всех параметров агрегации, а затем использует его в вычислениях. - -- Использует адаптивный алгоритм выборки. В качестве состояния вычисления функция использует выборку хэш-значений элементов размером до 65536. - - Этот алгоритм очень точен и очень эффективен по использованию CPU. Если запрос содержит небольшое количество этих функций, использование `uniq` почти так же эффективно, как и использование других агрегатных функций. - -- Результат детерминирован (не зависит от порядка выполнения запроса). - -Эту функцию рекомендуется использовать практически во всех сценариях. - -**Смотрите также** - -- [uniqCombined](#agg_function-uniqcombined) -- [uniqCombined64](#agg_function-uniqcombined64) -- [uniqHLL12](#agg_function-uniqhll12) -- [uniqExact](#agg_function-uniqexact) - -## uniqCombined {#agg_function-uniqcombined} - -Приближённо вычисляет количество различных значений аргумента. - -``` sql -uniqCombined(HLL_precision)(x[, ...]) -``` - -Функция `uniqCombined` — это хороший выбор для вычисления количества различных значений. - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. - -`HLL_precision` — это логарифм по основанию 2 от числа ячеек в [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). Необязательный, можно использовать функцию как `uniqCombined (x [,...])`. Для `HLL_precision` значение по умолчанию — 17, что фактически составляет 96 КБ пространства (2^17 ячеек, 6 бит каждая). - -**Возвращаемое значение** - -- Число типа [UInt64](../../sql_reference/aggregate_functions/reference.md). - -**Детали реализации** - -Функция: - -- Вычисляет хэш (64-битный для `String` и 32-битный для всех остальных типов) для всех параметров агрегации, а затем использует его в вычислениях. - -- Используется комбинация трёх алгоритмов: массив, хэш-таблица и HyperLogLog с таблицей коррекции погрешности. - - Для небольшого количества различных значений используется массив. Если размер набора больше, используется хэш-таблица. При дальнейшем увеличении количества значений, используется структура HyperLogLog, имеющая фиксированный размер в памяти. - -- Результат детерминирован (не зависит от порядка выполнения запроса). - -!!! note "Note" - Так как используется 32-битный хэш для не-`String` типов, результат будет иметь очень очень большую ошибку для количества разичных элементов существенно больше `UINT_MAX` (ошибка быстро растёт начиная с нескольких десятков миллиардов различных значений), таким образом в этом случае нужно использовать [uniqCombined64](#agg_function-uniqcombined64) - -По сравнению с функцией [uniq](#agg_function-uniq), `uniqCombined`: - -- Потребляет в несколько раз меньше памяти. -- Вычисляет с в несколько раз более высокой точностью. -- Обычно имеет немного более низкую производительность. В некоторых сценариях `uniqCombined` может показывать более высокую производительность, чем `uniq`, например, в случае распределенных запросов, при которых по сети передаётся большое количество состояний агрегации. - -**Смотрите также** - -- [uniq](#agg_function-uniq) -- [uniqCombined64](#agg_function-uniqcombined64) -- [uniqHLL12](#agg_function-uniqhll12) -- [uniqExact](#agg_function-uniqexact) - -## uniqCombined64 {#agg_function-uniqcombined64} - -Использует 64-битный хэш для всех типов, в отличие от [uniqCombined](#agg_function-uniqcombined). - -## uniqHLL12 {#agg_function-uniqhll12} - -Вычисляет приблизительное число различных значений аргументов, используя алгоритм [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). - -``` sql -uniqHLL12(x[, ...]) -``` - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. - -**Возвращаемое значение** - -- Значение хэша с типом данных [UInt64](../../sql_reference/aggregate_functions/reference.md). - -**Детали реализации** - -Функция: - -- Вычисляет хэш для всех параметров агрегации, а затем использует его в вычислениях. - -- Использует алгоритм HyperLogLog для аппроксимации числа различных значений аргументов. - - Используется 212 5-битовых ячеек. Размер состояния чуть больше 2.5 КБ. Результат не точный (ошибка до ~10%) для небольших множеств (<10K элементов). Однако для множеств большой кардинальности (10K - 100M) результат довольно точен (ошибка до ~1.6%). Начиная с 100M ошибка оценки будет только расти и для множеств огромной кардинальности (1B+ элементов) функция возвращает результат с очень большой неточностью. - -- Результат детерминирован (не зависит от порядка выполнения запроса). - -Мы не рекомендуем использовать эту функцию. В большинстве случаев используйте функцию [uniq](#agg_function-uniq) или [uniqCombined](#agg_function-uniqcombined). - -**Смотрите также** - -- [uniq](#agg_function-uniq) -- [uniqCombined](#agg_function-uniqcombined) -- [uniqExact](#agg_function-uniqexact) - -## uniqExact {#agg_function-uniqexact} - -Вычисляет точное количество различных значений аргументов. - -``` sql -uniqExact(x[, ...]) -``` - -Функцию `uniqExact` следует использовать, если вам обязательно нужен точный результат. В противном случае используйте функцию [uniq](#agg_function-uniq). - -Функция `uniqExact` расходует больше оперативной памяти, чем функция `uniq`, так как размер состояния неограниченно растёт по мере роста количества различных значений. - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть числовых типов, а также `Tuple`, `Array`, `Date`, `DateTime`, `String`. - -**Смотрите также** - -- [uniq](#agg_function-uniq) -- [uniqCombined](#agg_function-uniqcombined) -- [uniqHLL12](#agg_function-uniqhll12) - -## groupArray(x), groupArray(max\_size)(x) {#agg_function-grouparray} - -Составляет массив из значений аргумента. -Значения в массив могут быть добавлены в любом (недетерминированном) порядке. - -Вторая версия (с параметром `max_size`) ограничивает размер результирующего массива `max_size` элементами. -Например, `groupArray(1)(x)` эквивалентно `[any(x)]`. - -В некоторых случаях, вы всё же можете рассчитывать на порядок выполнения запроса. Это — случаи, когда `SELECT` идёт из подзапроса, в котором используется `ORDER BY`. - -## groupArrayInsertAt(value, position) {#grouparrayinsertatvalue-position} - -Вставляет в массив значение в заданную позицию. - -!!! note "Примечание" - Эта функция использует нумерацию массивов с нуля, в отличие от принятой в SQL нумерации с единицы. - -Принимает на вход значение и позицию. Если на одну и ту же позицию вставляется несколько значений, в результирующем массиве может оказаться любое (первое в случае однопоточного выполнения). Если в позицию не вставляется ни одного значения, то позиции присваивается значение по умолчанию. - -Опциональные параметры: - -- Значение по умолчанию для подстановки на пустые позиции. -- Длина результирующего массива. Например, если вы хотите получать массивы одинакового размера для всех агрегатных ключей. При использовании этого параметра значение по умолчанию задавать обязательно. - -## groupArrayMovingSum {#agg_function-grouparraymovingsum} - -Вычисляет скользящую сумму входных значений. - -``` sql -groupArrayMovingSum(numbers_for_summing) -groupArrayMovingSum(window_size)(numbers_for_summing) -``` - -Функция может принимать размер окна в качестве параметра. Если окно не указано, то функция использует размер окна, равный количеству строк в столбце. - -**Параметры** - -- `numbers_for_summing` — [выражение](../syntax.md#syntax-expressions), возвращающее значение числового типа. -- `window_size` — размер окна. - -**Возвращаемые значения** - -- Массив того же размера и типа, что и входные данные. - -**Пример** - -Таблица с исходными данными: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -Запросы: - -``` sql -SELECT - groupArrayMovingSum(int) AS I, - groupArrayMovingSum(float) AS F, - groupArrayMovingSum(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingSum(2)(int) AS I, - groupArrayMovingSum(2)(float) AS F, - groupArrayMovingSum(2)(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -## groupArrayMovingAvg {#agg_function-grouparraymovingavg} - -Вычисляет скользящее среднее для входных значений. - - groupArrayMovingAvg(numbers_for_summing) - groupArrayMovingAvg(window_size)(numbers_for_summing) - -Функция может принимать размер окна в качестве параметра. Если окно не указано, то функция использует размер окна, равный количеству строк в столбце. - -**Параметры** - -- `numbers_for_summing` — [выражение](../syntax.md#syntax-expressions), возвращающее значение числового типа. -- `window_size` — размер окна. - -**Возвращаемые значения** - -- Массив того же размера и типа, что и входные данные. - -Функция использует [округление к меньшему по модулю](https://ru.wikipedia.org/wiki/Округление#Методы). Оно усекает десятичные разряды, незначимые для результирующего типа данных. - -**Пример** - -Таблица с исходными данными: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -Запросы: - -``` sql -SELECT - groupArrayMovingAvg(int) AS I, - groupArrayMovingAvg(float) AS F, - groupArrayMovingAvg(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ -│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ -└───────────┴─────────────────────────────────────┴───────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingAvg(2)(int) AS I, - groupArrayMovingAvg(2)(float) AS F, - groupArrayMovingAvg(2)(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ -│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ -└───────────┴──────────────────────────────────┴───────────────────────┘ -``` - -## groupUniqArray(x), groupUniqArray(max\_size)(x) {#groupuniqarrayx-groupuniqarraymax-sizex} - -Составляет массив из различных значений аргумента. Расход оперативной памяти такой же, как у функции `uniqExact`. - -Функция `groupUniqArray(max_size)(x)` ограничивает размер результирующего массива до `max_size` элементов. Например, `groupUniqArray(1)(x)` равнозначно `[any(x)]`. - -## quantile {#quantile} - -Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. - -Функция использует алгоритм [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) с размером резервуара до 8192 и случайным генератором чисел для для сэмплирования. Результат не детерминирован. Чтобы получить точную квантиль используйте функцию [quantileExact](#quantileexact). - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantile(level)(expr) -``` - -Алиас: `median`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql_reference/aggregate_functions/reference.md#data_types) или типов [Date](../../sql_reference/aggregate_functions/reference.md), [DateTime](../../sql_reference/aggregate_functions/reference.md). - -**Возвращаемое значение** - -- Приблизительный квантиль заданного уровня. - -Тип: - -- [Float64](../../sql_reference/aggregate_functions/reference.md) для входных данных числового типа. -- [Date](../../sql_reference/aggregate_functions/reference.md), если входные значения имеют тип `Date`. -- [DateTime](../../sql_reference/aggregate_functions/reference.md), если входные значения имеют тип `DateTime`. - -**Пример** - -Входная таблица: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -Запрос: - -``` sql -SELECT quantile(val) FROM t -``` - -Результат: - -``` text -┌─quantile(val)─┐ -│ 1.5 │ -└───────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileDeterministic {#quantiledeterministic} - -Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. - -Функция использует алгоритм [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) с размером резервуара до 8192 и детерминированным алгоритмом сэмплирования. Результат детерминирован. Чтобы получить точную квантиль используйте функцию [quantileExact](#quantileexact). - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileDeterministic(level)(expr, determinator) -``` - -Алиас: `medianDeterministic`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql_reference/aggregate_functions/reference.md#data_types) или типов [Date](../../sql_reference/aggregate_functions/reference.md), [DateTime](../../sql_reference/aggregate_functions/reference.md). -- `determinator` — Число, хэш которого используется при сэмплировании в алгоритме reservoir sampling, чтобы сделать результат детерминированным. В качестве детерминатора можно использовать любое определённое положительное число, например, идентификатор пользователя или события. Если одно и то же значение детерминатора попадается в выборке слишком часто, то функция выдаёт некорректный результат. - -**Возвращаемое значение** - -- Приблизительный квантиль заданного уровня. - -Тип: - -- [Float64](../../sql_reference/aggregate_functions/reference.md) для входных данных числового типа. -- [Date](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `Date`. -- [DateTime](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `DateTime`. - -**Пример** - -Входная таблица: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -Запрос: - -``` sql -SELECT quantileDeterministic(val, 1) FROM t -``` - -Результат: - -``` text -┌─quantileDeterministic(val, 1)─┐ -│ 1.5 │ -└───────────────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileExact {#quantileexact} - -Точно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. - -Чтобы получить точный результат, все переданные значения собираются в массив, который затем частично сортируется. Таким образом, функция потребляет объем памяти `O(n)`, где `n` — количество переданных значений. Для небольшого числа значений эта функция эффективна. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileExact(level)(expr) -``` - -Алиас: `medianExact`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql_reference/aggregate_functions/reference.md#data_types) или типов [Date](../../sql_reference/aggregate_functions/reference.md), [DateTime](../../sql_reference/aggregate_functions/reference.md). - -**Возвращаемое значение** - -- Квантиль заданного уровня. - -Тип: - -- [Float64](../../sql_reference/aggregate_functions/reference.md) для входных данных числового типа. -- [Date](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `Date`. -- [DateTime](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `DateTime`. - -**Пример** - -Запрос: - -``` sql -SELECT quantileExact(number) FROM numbers(10) -``` - -Результат: - -``` text -┌─quantileExact(number)─┐ -│ 5 │ -└───────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileExactWeighted {#quantileexactweighted} - -Точно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, учитывая вес каждого её элемента. - -Чтобы получить точный результат, все переданные значения собираются в массив, который затем частично сортируется. Для каждого значения учитывается его вес (количество значений в выборке). В алгоритме используется хэш-таблица. Таким образом, если переданные значения часто повторяются, функция потребляет меньше оперативной памяти, чем [quantileExact](#quantileexact). Эту функцию можно использовать вместо `quantileExact` если указать вес 1. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileExactWeighted(level)(expr, weight) -``` - -Алиас: `medianExactWeighted`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql_reference/aggregate_functions/reference.md#data_types) или типов [Date](../../sql_reference/aggregate_functions/reference.md), [DateTime](../../sql_reference/aggregate_functions/reference.md). -- `weight` — Столбец с весам элементов последовательности. Вес — это количество повторений элемента в последовательности. - -**Возвращаемое значение** - -- Quantile of the specified level. - -Тип: - -- [Float64](../../sql_reference/aggregate_functions/reference.md) для входных данных числового типа. -- [Date](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `Date`. -- [DateTime](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `DateTime`. - -**Пример** - -Входная таблица: - -``` text -┌─n─┬─val─┐ -│ 0 │ 3 │ -│ 1 │ 2 │ -│ 2 │ 1 │ -│ 5 │ 4 │ -└───┴─────┘ -``` - -Запрос: - -``` sql -SELECT quantileExactWeighted(n, val) FROM t -``` - -Результат: - -``` text -┌─quantileExactWeighted(n, val)─┐ -│ 1 │ -└───────────────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileTiming {#quantiletiming} - -Вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности с детерминированной точностью. - -Результат детерминирован (не зависит от порядка обработки запроса). Функция оптимизирована для работы с последовательностями, описывающими такие распределения, как время загрузки веб-страниц или время отклика бэкенда. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileTiming(level)(expr) -``` - -Алиас: `medianTiming`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). - -- `expr` — [Выражение](../syntax.md#syntax-expressions) над значения столбца, которые возвращают данные типа [Float\*](../../sql_reference/aggregate_functions/reference.md). - - - Если в функцию передать отрицательные значения, то её поведение не определено. - - Если значение больше, чем 30 000 (например, время загрузки страницы превышает 30 секунд), то оно приравнивается к 30 000. - -**Точность** - -Вычисления точны при соблюдении следующих условий: - -- Размер выборки не превышает 5670 элементов. -- Размер выборки превышает 5670 элементов, но значение каждого элемента не больше 1024. - -В противном случае, результат вычисления округляется до ближайшего множителя числа 16. - -!!! note "Примечание" - Для указанного типа последовательностей функция производительнее и точнее, чем [quantile](#quantile). - -**Возвращаемое значение** - -- Квантиль заданного уровня. - -Тип: `Float32`. - -!!! note "Примечания" - Если в функцию `quantileTimingIf` не передать значений, то вернётся [NaN](../../sql_reference/aggregate_functions/reference.md#data_type-float-nan-inf). Это необходимо для отделения подобных случаев от случаев, когда результат 0. Подробности про сортировку `NaN` cмотрите в разделе [Секция ORDER BY](../../sql_reference/statements/select.md#select-order-by). - -**Пример** - -Входная таблица: - -``` text -┌─response_time─┐ -│ 72 │ -│ 112 │ -│ 126 │ -│ 145 │ -│ 104 │ -│ 242 │ -│ 313 │ -│ 168 │ -│ 108 │ -└───────────────┘ -``` - -Запрос: - -``` sql -SELECT quantileTiming(response_time) FROM t -``` - -Результат: - -``` text -┌─quantileTiming(response_time)─┐ -│ 126 │ -└───────────────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileTimingWeighted {#quantiletimingweighted} - -С детерминированной точностью вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, учитывая вес каждого элемента. - -Результат детерминирован (не зависит от порядка обработки запроса). Функция оптимизирована для работы с последовательностями, описывающими такие распределения, как время загрузки веб-страниц или время отклика бэкенда. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileTimingWeighted(level)(expr, weight) -``` - -Алиас: `medianTimingWeighted`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). - -- `expr` — [Выражение](../syntax.md#syntax-expressions) над значения столбца, которые возвращают данные типа [Float\*](../../sql_reference/aggregate_functions/reference.md). - - - Если в функцию передать отрицательные значения, то её поведение не определено. - - Если значение больше, чем 30 000 (например, время загрузки страницы превышает 30 секунд), то оно приравнивается к 30 000. - -- `weight` — Столбец с весам элементов последовательности. Вес — это количество повторений элемента в последовательности. - -**Точность** - -Вычисления точны при соблюдении следующих условий: - -- Размер выборки не превышает 5670 элементов. -- Размер выборки превышает 5670 элементов, но значение каждого элемента не больше 1024. - -В противном случае, результат вычисления округляется до ближайшего множителя числа 16. - -!!! note "Примечание" - Для указанного типа последовательностей функция производительнее и точнее, чем [quantile](#quantile). - -**Возвращаемое значение** - -- Квантиль заданного уровня. - -Тип: `Float32`. - -!!! note "Примечания" - Если в функцию `quantileTimingIf` не передать значений, то вернётся [NaN](../../sql_reference/aggregate_functions/reference.md#data_type-float-nan-inf). Это необходимо для отделения подобных случаев от случаев, когда результат 0. Подробности про сортировку `NaN` cмотрите в разделе [Секция ORDER BY](../../sql_reference/statements/select.md#select-order-by). - -**Пример** - -Входная таблица: - -``` text -┌─response_time─┬─weight─┐ -│ 68 │ 1 │ -│ 104 │ 2 │ -│ 112 │ 3 │ -│ 126 │ 2 │ -│ 138 │ 1 │ -│ 162 │ 1 │ -└───────────────┴────────┘ -``` - -Запрос: - -``` sql -SELECT quantileTimingWeighted(response_time, weight) FROM t -``` - -Результат: - -``` text -┌─quantileTimingWeighted(response_time, weight)─┐ -│ 112 │ -└───────────────────────────────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileTDigest {#quantiletdigest} - -Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, используя алгоритм [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf). - -Максимальная ошибка 1%. Потребление памяти — `log(n)`, где `n` — число значений. Результат не детерминирован и зависит от порядка выполнения запроса. - -Производительность функции ниже, чем производительность функции [quantile](#quantile) или [quantileTiming](#quantiletiming). По соотношению размера состояния к точности вычисления, эта функция значительно превосходит `quantile`. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileTDigest(level)(expr) -``` - -Алиас: `medianTDigest`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql_reference/aggregate_functions/reference.md#data_types) или типов [Date](../../sql_reference/aggregate_functions/reference.md), [DateTime](../../sql_reference/aggregate_functions/reference.md). - -**Возвращаемое значение** - -- Приблизительную квантиль заданного уровня. - -Тип: - -- [Float64](../../sql_reference/aggregate_functions/reference.md) для входных данных числового типа. -- [Date](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `Date`. -- [DateTime](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `DateTime`. - -**Пример** - -Запрос: - -``` sql -SELECT quantileTDigest(number) FROM numbers(10) -``` - -Результат: - -``` text -┌─quantileTDigest(number)─┐ -│ 4.5 │ -└─────────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## quantileTDigestWeighted {#quantiletdigestweighted} - -Приблизительно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности, используя алгоритм [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf). Функция учитывает вес каждого элемента последовательности. - -Максимальная ошибка 1%. Потребление памяти — `log(n)`, где `n` — число значений. Результат не детерминирован и зависит от порядка выполнения запроса. - -Производительность функции ниже, чем производительность функции [quantile](#quantile) или [quantileTiming](#quantiletiming). По соотношению размера состояния к точности вычисления, эта функция значительно превосходит `quantile`. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileTDigestWeighted(level)(expr, weight) -``` - -Алиас: `medianTDigest`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../sql_reference/aggregate_functions/reference.md#data_types) или типов [Date](../../sql_reference/aggregate_functions/reference.md), [DateTime](../../sql_reference/aggregate_functions/reference.md). -- `weight` — Столбец с весам элементов последовательности. Вес — это количество повторений элемента в последовательности. - -**Возвращаемое значение** - -- Приблизительный квантиль заданного уровня. - -Тип: - -- [Float64](../../sql_reference/aggregate_functions/reference.md) для входных данных числового типа. -- [Date](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `Date`. -- [DateTime](../../sql_reference/aggregate_functions/reference.md) если входные значения имеют тип `DateTime`. - -**Пример** - -Запрос: - -``` sql -SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) -``` - -Результат: - -``` text -┌─quantileTDigestWeighted(number, 1)─┐ -│ 4.5 │ -└────────────────────────────────────┘ -``` - -**Смотрите также** - -- [median](#median) -- [quantiles](#quantiles) - -## median {#median} - -Функции `median*` — алиасы для соответствущих функций `quantile*`. Они вычисляют медиану числовой последовательности. - -Functions: - -- `median` — алиас [quantile](#quantile). -- `medianDeterministic` — алиас [quantileDeterministic](#quantiledeterministic). -- `medianExact` — алиас [quantileExact](#quantileexact). -- `medianExactWeighted` — алиас [quantileExactWeighted](#quantileexactweighted). -- `medianTiming` — алиас [quantileTiming](#quantiletiming). -- `medianTimingWeighted` — алиас [quantileTimingWeighted](#quantiletimingweighted). -- `medianTDigest` — алиас [quantileTDigest](#quantiletdigest). -- `medianTDigestWeighted` — алиас [quantileTDigestWeighted](#quantiletdigestweighted). - -**Пример** - -Входная таблица: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -Запрос: - -``` sql -SELECT medianDeterministic(val, 1) FROM t -``` - -Результат: - -``` text -┌─medianDeterministic(val, 1)─┐ -│ 1.5 │ -└─────────────────────────────┘ -``` - -## quantiles(level1, level2, …)(x) {#quantiles} - -Для всех quantile-функций, также присутствуют соответствующие quantiles-функции: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. Эти функции за один проход вычисляют все квантили перечисленных уровней и возвращают массив вычисленных значений. - -## varSamp(x) {#varsampx} - -Вычисляет величину `Σ((x - x̅)^2) / (n - 1)`, где `n` - размер выборки, `x̅`- среднее значение `x`. - -Она представляет собой несмещённую оценку дисперсии случайной величины, если переданные в функцию значения являются выборкой этой случайной величины. - -Возвращает `Float64`. В случае, когда `n <= 1`, возвращается `+∞`. - -## varPop(x) {#varpopx} - -Вычисляет величину `Σ((x - x̅)^2) / n`, где `n` - размер выборки, `x̅`- среднее значение `x`. - -То есть, дисперсию для множества значений. Возвращает `Float64`. - -## stddevSamp(x) {#stddevsampx} - -Результат равен квадратному корню от `varSamp(x)`. - -## stddevPop(x) {#stddevpopx} - -Результат равен квадратному корню от `varPop(x)`. - -## topK(N)(column) {#topkncolumn} - -Возвращает массив наиболее часто встречающихся значений в указанном столбце. Результирующий массив упорядочен по убыванию частоты значения (не по самим значениям). - -Реализует [Filtered Space-Saving](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) алгоритм для анализа TopK, на основе reduce-and-combine алгоритма из методики [Parallel Space Saving](https://arxiv.org/pdf/1401.0702.pdf). - -``` sql -topK(N)(column) -``` - -Функция не дает гарантированного результата. В некоторых ситуациях могут возникать ошибки, и функция возвращает частые, но не наиболее частые значения. - -Рекомендуем использовать значения `N < 10`, при больших `N` снижается производительность. Максимально возможное значение `N = 65536`. - -**Аргументы** - -- ‘N’ - Количество значений. -- ‘x’ – Столбец. - -**Пример** - -Возьмём набор данных [OnTime](../../getting_started/example_datasets/ontime.md) и выберем 3 наиболее часто встречающихся значения в столбце `AirlineID`. - -``` sql -SELECT topK(3)(AirlineID) AS res -FROM ontime -``` - -``` text -┌─res─────────────────┐ -│ [19393,19790,19805] │ -└─────────────────────┘ -``` - -## topKWeighted {#topkweighted} - -Аналогична `topK`, но дополнительно принимает положительный целочисленный параметр `weight`. Каждое значение учитывается `weight` раз при расчёте частоты. - -**Синтаксис** - -``` sql -topKWeighted(N)(x, weight) -``` - -**Параметры** - -- `N` — Количество элементов для выдачи. - -**Аргументы** - -- `x` – значение. -- `weight` — вес. [UInt8](../../sql_reference/aggregate_functions/reference.md). - -**Возвращаемое значение** - -Возвращает массив значений с максимально приближенной суммой весов. - -**Пример** - -Запрос: - -``` sql -SELECT topKWeighted(10)(number, number) FROM numbers(1000) -``` - -Результат: - -``` text -┌─topKWeighted(10)(number, number)──────────┐ -│ [999,998,997,996,995,994,993,992,991,990] │ -└───────────────────────────────────────────┘ -``` - -## covarSamp(x, y) {#covarsampx-y} - -Вычисляет величину `Σ((x - x̅)(y - y̅)) / (n - 1)`. - -Возвращает Float64. В случае, когда `n <= 1`, возвращается +∞. - -## covarPop(x, y) {#covarpopx-y} - -Вычисляет величину `Σ((x - x̅)(y - y̅)) / n`. - -## corr(x, y) {#corrx-y} - -Вычисляет коэффициент корреляции Пирсона: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. - -## simpleLinearRegression {#simplelinearregression} - -Выполняет простую (одномерную) линейную регрессию. - -``` sql -simpleLinearRegression(x, y) -``` - -Параметры: - -- `x` — столбец со значениями зависимой переменной. -- `y` — столбец со значениями наблюдаемой переменной. - -Возвращаемые значения: - -Константы `(a, b)` результирующей прямой `y = a*x + b`. - -**Примеры** - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ -│ (1,0) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ -│ (1,3) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## stochasticLinearRegression {#agg_functions-stochasticlinearregression} - -Функция реализует стохастическую линейную регрессию. Поддерживает пользовательские параметры для скорости обучения, коэффициента регуляризации L2, размера mini-batch и имеет несколько методов обновления весов ([Adam](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (по умолчанию), [simple SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [Momentum](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). - -### Параметры {#agg_functions-stochasticlinearregression-parameters} - -Есть 4 настраиваемых параметра. Они передаются в функцию последовательно, однако не обязательно указывать все, используются значения по умолчанию, однако хорошая модель требует некоторой настройки параметров. - -``` text -stochasticLinearRegression(1.0, 1.0, 10, 'SGD') -``` - -1. Скорость обучения — коэффициент длины шага, при выполнении градиентного спуска. Слишком большая скорость обучения может привести к бесконечным весам модели. По умолчанию `0.00001`. -2. Коэффициент регуляризации l2. Помогает предотвратить подгонку. По умолчанию `0.1`. -3. Размер mini-batch задаёт количество элементов, чьи градиенты будут вычислены и просуммированы при выполнении одного шага градиентного спуска. Чистый стохастический спуск использует один элемент, однако использование mini-batch (около 10 элементов) делает градиентные шаги более стабильными. По умолчанию `15`. -4. Метод обновления весов, можно выбрать один из следующих: `Adam` (по умолчанию), `SGD`, `Momentum`, `Nesterov`. `Momentum` и `Nesterov` более требовательные к вычислительным ресурсам и памяти, однако они имеют высокую скорость схождения и устойчивости методов стохастического градиента. - -### Использование {#agg_functions-stochasticlinearregression-usage} - -`stochasticLinearRegression` используется на двух этапах: построение модели и предсказание новых данных. Чтобы построить модель и сохранить её состояние для дальнейшего использования, мы используем комбинатор `-State`. -Для прогнозирования мы используем функцию [evalMLMethod](../functions/machine_learning_functions.md#machine_learning_methods-evalmlmethod), которая принимает в качестве аргументов состояние и свойства для прогнозирования. - - - -**1.** Построение модели - -Пример запроса: - -``` sql -CREATE TABLE IF NOT EXISTS train_data -( - param1 Float64, - param2 Float64, - target Float64 -) ENGINE = Memory; - -CREATE TABLE your_model ENGINE = Memory AS SELECT -stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) -AS state FROM train_data; -``` - -Здесь нам также нужно вставить данные в таблицу `train_data`. Количество параметров не фиксировано, оно зависит только от количества аргументов, перешедших в `linearRegressionState`. Все они должны быть числовыми значениями. -Обратите внимание, что столбец с целевым значением (которое мы хотели бы научиться предсказывать) вставляется в качестве первого аргумента. - -**2.** Прогнозирование - -После сохранения состояния в таблице мы можем использовать его несколько раз для прогнозирования или смёржить с другими состояниями и создать новые, улучшенные модели. - -``` sql -WITH (SELECT state FROM your_model) AS model SELECT -evalMLMethod(model, param1, param2) FROM test_data -``` - -Запрос возвращает столбец прогнозируемых значений. Обратите внимание, что первый аргумент `evalMLMethod` это объект `AggregateFunctionState`, далее идут столбцы свойств. - -`test_data` — это таблица, подобная `train_data`, но при этом может не содержать целевое значение. - -### Примечания {#agg_functions-stochasticlinearregression-notes} - -1. Объединить две модели можно следующим запросом: - - - - ``` sql - SELECT state1 + state2 FROM your_models - ``` - - где таблица `your_models` содержит обе модели. Запрос вернёт новый объект `AggregateFunctionState`. - -1. Пользователь может получать веса созданной модели для своих целей без сохранения модели, если не использовать комбинатор `-State`. - - - - ``` sql - SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data - ``` - - Подобный запрос строит модель и возвращает её веса, отвечающие параметрам моделей и смещение. Таким образом, в приведенном выше примере запрос вернет столбец с тремя значениями. - -**Смотрите также** - -- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) -- [Отличие линейной от логистической регрессии.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} - -Функция реализует стохастическую логистическую регрессию. Её можно использовать для задачи бинарной классификации, функция поддерживает те же пользовательские параметры, что и stochasticLinearRegression и работает таким же образом. - -### Параметры {#agg_functions-stochasticlogisticregression-parameters} - -Параметры те же, что и в stochasticLinearRegression: -`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. -Смотрите раздел [parameters](#agg_functions-stochasticlinearregression-parameters). - -``` text -stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') -``` - -1. Построение модели - - - - Смотрите раздел `Построение модели` в описании [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) . - - Прогнозируемые метки должны быть в диапазоне \[-1, 1\]. - -1. Прогнозирование - - - - Используя сохраненное состояние, можно предсказать вероятность наличия у объекта метки `1`. - - ``` sql - WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) FROM test_data - ``` - - Запрос возвращает столбец вероятностей. Обратите внимание, что первый аргумент `evalMLMethod` это объект `AggregateFunctionState`, далее идут столбцы свойств. - - Мы также можем установить границу вероятности, которая присваивает элементам различные метки. - - ``` sql - SELECT ans < 1.1 AND ans > 0.5 FROM - (WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) AS ans FROM test_data) - ``` - - Тогда результатом будут метки. - - `test_data` — это таблица, подобная `train_data`, но при этом может не содержать целевое значение. - -**Смотрите также** - -- [stochasticLinearRegression](#agg_functions-stochasticlinearregression) -- [Отличие линейной от логистической регрессии](https://moredez.ru/q/51225972/) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/agg_functions/reference/) diff --git a/docs/ru/sql_reference/ansi.md b/docs/ru/sql_reference/ansi.md deleted file mode 120000 index ee0f9c8cb7e..00000000000 --- a/docs/ru/sql_reference/ansi.md +++ /dev/null @@ -1 +0,0 @@ -../../en/sql_reference/ansi.md \ No newline at end of file diff --git a/docs/ru/sql_reference/data_types/aggregatefunction.md b/docs/ru/sql_reference/data_types/aggregatefunction.md deleted file mode 100644 index d7ee1211845..00000000000 --- a/docs/ru/sql_reference/data_types/aggregatefunction.md +++ /dev/null @@ -1,63 +0,0 @@ -# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} - -Промежуточное состояние агрегатной функции. Чтобы его получить, используются агрегатные функции с суффиксом `-State`. Чтобы в дальнейшем получить агрегированные данные необходимо использовать те же агрегатные функции с суффиксом `-Merge`. - -`AggregateFunction` — параметрический тип данных. - -**Параметры** - -- Имя агрегатной функции. - - Для параметрических агрегатных функций указываются также их параметры. - -- Типы аргументов агрегатной функции. - -**Пример** - -``` sql -CREATE TABLE t -( - column1 AggregateFunction(uniq, UInt64), - column2 AggregateFunction(anyIf, String, UInt8), - column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) -) ENGINE = ... -``` - -[uniq](../../sql_reference/data_types/aggregatefunction.md#agg_function-uniq), anyIf ([any](../../sql_reference/data_types/aggregatefunction.md#agg_function-any)+[If](../../sql_reference/data_types/aggregatefunction.md#agg-functions-combinator-if)) и [quantiles](../../sql_reference/data_types/aggregatefunction.md) — агрегатные функции, поддержанные в ClickHouse. - -## Особенности использования {#osobennosti-ispolzovaniia} - -### Вставка данных {#vstavka-dannykh} - -Для вставки данных используйте `INSERT SELECT` с агрегатными `-State`-функциями. - -**Примеры функций** - -``` sql -uniqState(UserID) -quantilesState(0.5, 0.9)(SendTiming) -``` - -В отличие от соответствующих функций `uniq` и `quantiles`, `-State`-функциями возвращают не готовое значение, а состояние. То есть, значение типа `AggregateFunction`. - -В запросах `SELECT` значения типа `AggregateFunction` выводятся во всех форматах, которые поддерживает ClickHouse, в виде implementation-specific бинарных данных. Если с помощью `SELECT` выполнить дамп данных, например, в формат `TabSeparated`, то потом этот дамп можно загрузить обратно с помощью запроса `INSERT`. - -### Выборка данных {#vyborka-dannykh} - -При выборке данных из таблицы `AggregatingMergeTree`, используйте `GROUP BY` и те же агрегатные функции, что и при вставке данных, но с суффиксом `-Merge`. - -Агрегатная функция с суффиксом `-Merge` берёт множество состояний, объединяет их, и возвращает результат полной агрегации данных. - -Например, следующие два запроса возвращают один и тот же результат: - -``` sql -SELECT uniq(UserID) FROM table - -SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) -``` - -## Пример использования {#primer-ispolzovaniia} - -Смотрите в описании движка [AggregatingMergeTree](../../sql_reference/data_types/aggregatefunction.md). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/ru/sql_reference/data_types/array.md b/docs/ru/sql_reference/data_types/array.md deleted file mode 100644 index acc2e4940d0..00000000000 --- a/docs/ru/sql_reference/data_types/array.md +++ /dev/null @@ -1,72 +0,0 @@ -# Array(T) {#data-type-array} - -Массив из элементов типа `T`. - -`T` может любым, в том числе, массивом. Таким образом поддержаны многомерные массивы. - -## Создание массива {#sozdanie-massiva} - -Массив можно создать с помощью функции: - -``` sql -array(T) -``` - -Также можно использовать квадратные скобки - -``` sql -[] -``` - -Пример создания массива: - -``` sql -SELECT array(1, 2) AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName(array(1, 2))─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴─────────────────────────┘ -``` - -``` sql -SELECT [1, 2] AS x, toTypeName(x) -``` - -``` text -┌─x─────┬─toTypeName([1, 2])─┐ -│ [1,2] │ Array(UInt8) │ -└───────┴────────────────────┘ -``` - -## Особенности работы с типами данных {#osobennosti-raboty-s-tipami-dannykh} - -При создании массива «на лету» ClickHouse автоматически определяет тип аргументов как наиболее узкий тип данных, в котором можно хранить все перечисленные аргументы. Если среди аргументов есть [NULL](../../sql_reference/data_types/array.md#null-literal) или аргумент типа [Nullable](nullable.md#data_type-nullable), то тип элементов массива — [Nullable](nullable.md). - -Если ClickHouse не смог подобрать тип данных, то он сгенерирует исключение. Это произойдёт, например, при попытке создать массив одновременно со строками и числами `SELECT array(1, 'a')`. - -Примеры автоматического определения типа данных: - -``` sql -SELECT array(1, 2, NULL) AS x, toTypeName(x) -``` - -``` text -┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ -│ [1,2,NULL] │ Array(Nullable(UInt8)) │ -└────────────┴───────────────────────────────┘ -``` - -Если попытаться создать массив из несовместимых типов данных, то ClickHouse выбросит исключение: - -``` sql -SELECT array(1, 'a') -``` - -``` text -Received exception from server (version 1.1.54388): -Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/array/) diff --git a/docs/ru/sql_reference/data_types/datetime.md b/docs/ru/sql_reference/data_types/datetime.md deleted file mode 100644 index e52ca549907..00000000000 --- a/docs/ru/sql_reference/data_types/datetime.md +++ /dev/null @@ -1,122 +0,0 @@ -# DateTime {#data_type-datetime} - -Позволяет хранить момент времени, который может быть представлен как календарная дата и время. - -Синтаксис: - -``` sql -DateTime([timezone]) -``` - -Диапазон значений: \[1970-01-01 00:00:00, 2105-12-31 23:59:59\]. - -Точность: 1 секунда. - -## Использование {#ispolzovanie} - -Момент времени сохраняется как [Unix timestamp](https://ru.wikipedia.org/wiki/Unix-%D0%B2%D1%80%D0%B5%D0%BC%D1%8F), независимо от часового пояса и переходов на летнее/зимнее время. Дополнительно, тип `DateTime` позволяет хранить часовой пояс, единый для всей колонки, который влияет на то, как будут отображаться значения типа `DateTime` в текстовом виде и как будут парситься значения заданные в виде строк (‘2020-01-01 05:00:01’). Часовой пояс не хранится в строках таблицы (выборки), а хранится в метаданных колонки. -Список поддерживаемых временных зон можно найти в [IANA Time Zone Database](https://www.iana.org/time-zones). -Пакет `tzdata`, содержащий [базу данных часовых поясов IANA](https://www.iana.org/time-zones), должен быть установлен в системе. Используйте команду `timedatectl list-timezones` для получения списка часовых поясов, известных локальной системе. - -Часовой пояс для столбца типа `DateTime` можно в явном виде установить при создании таблицы. Если часовой пояс не установлен, то ClickHouse использует значение параметра [timezone](../../sql_reference/data_types/datetime.md#server_configuration_parameters-timezone), установленное в конфигурации сервера или в настройках операционной системы на момент запуска сервера. - -Консольный клиент ClickHouse по умолчанию использует часовой пояс сервера, если для значения `DateTime` часовой пояс не был задан в явном виде при инициализации типа данных. Чтобы использовать часовой пояс клиента, запустите [clickhouse-client](../../interfaces/cli.md) с параметром `--use_client_time_zone`. - -ClickHouse отображает значения типа `DateTime` в формате `YYYY-MM-DD hh:mm:ss`. Отображение можно поменять с помощью функции [formatDateTime](../../sql_reference/data_types/datetime.md#formatdatetime). - -При вставке данных в ClickHouse, можно использовать различные форматы даты и времени в зависимости от значения настройки [date\_time\_input\_format](../../operations/settings/settings.md#settings-date_time_input_format). - -## Примеры {#primery} - -**1.** Создание таблицы с столбцом типа `DateTime` и вставка данных в неё: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime('Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog; -``` - -``` sql -INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2); -``` - -``` sql -SELECT * FROM dt; -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -- При вставке даты-времени как целого числа, оно трактуется как Unix Timestamp (UTC). Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`. Однако, столбец `timestamp` имеет тип `DateTime('Europe/Moscow (UTC+3)')`, так что при выводе в виде строки время отобразится как `2019-01-01 03:00:00`. -- При вставке даты-времени в виде строки, время трактуется соответственно часовому поясу установленному для колонки. `'2019-01-01 00:00:00'` трактуется как время по Москве (и в базу сохраняется `1546290000`) - -**2.** Фильтрация по значениям даты-времени - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow') -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00 │ 2 │ -└─────────────────────┴──────────┘ -``` - -Фильтровать по колонке типа `DateTime` можно, указывая строковое значение в фильтре `WHERE`. Конвертация будет выполнена автоматически: - -``` sql -SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' -``` - -``` text -┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00 │ 1 │ -└─────────────────────┴──────────┘ -``` - -**3.** Получение часового пояса для колонки типа `DateTime`: - -``` sql -SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────column─┬─x─────────────────────────┐ -│ 2019-10-16 04:12:04 │ DateTime('Europe/Moscow') │ -└─────────────────────┴───────────────────────────┘ -``` - -**4.** Конвертация часовых поясов - -``` sql -SELECT -toDateTime(timestamp, 'Europe/London') as lon_time, -toDateTime(timestamp, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────lon_time──┬────────────mos_time─┐ -│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │ -│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │ -└─────────────────────┴─────────────────────┘ -``` - -## See Also {#see-also} - -- [Функции преобразования типов](../../sql_reference/data_types/datetime.md) -- [Функции для работы с датой и временем](../../sql_reference/data_types/datetime.md) -- [Функции для работы с массивами](../../sql_reference/data_types/datetime.md) -- [Настройка `date_time_input_format`](../../operations/settings/settings.md#settings-date_time_input_format) -- [Конфигурационный параметр сервера `timezone`](../../sql_reference/data_types/datetime.md#server_configuration_parameters-timezone) -- [Операторы для работы с датой и временем](../../sql_reference/data_types/datetime.md#operators-datetime) -- [Тип данных `Date`](date.md) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/datetime/) diff --git a/docs/ru/sql_reference/data_types/datetime64.md b/docs/ru/sql_reference/data_types/datetime64.md deleted file mode 100644 index 9e126885058..00000000000 --- a/docs/ru/sql_reference/data_types/datetime64.md +++ /dev/null @@ -1,97 +0,0 @@ -# DateTime64 {#data_type-datetime64} - -Позволяет хранить момент времени, который может быть представлен как календарная дата и время, с заданной суб-секундной точностью. - -Размер тика/точность: 10-precision секунд, где precision - целочисленный параметр типа. - -Синтаксис: - -``` sql -DateTime64(precision, [timezone]) -``` - -Данные хранятся в виде количества ‘тиков’, прошедших с момента начала эпохи (1970-01-01 00:00:00 UTC), в Int64. Размер тика определяется параметром precision. Дополнительно, тип `DateTime64` позволяет хранить часовой пояс, единый для всей колонки, который влияет на то, как будут отображаться значения типа `DateTime64` в текстовом виде и как будут парситься значения заданные в виде строк (‘2020-01-01 05:00:01.000’). Часовой пояс не хранится в строках таблицы (выборки), а хранится в метаданных колонки. Подробнее см. [DateTime](datetime.md). - -## Пример {#primer} - -**1.** Создание таблицы с столбцом типа `DateTime64` и вставка данных в неё: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime64(3, 'Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog -``` - -``` sql -INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) -``` - -``` sql -SELECT * FROM dt -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00.000 │ 1 │ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -- При вставке даты-времени как числа (аналогично ‘Unix timestamp’), время трактуется как UTC. Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`. Однако, столбец `timestamp` имеет тип `DateTime('Europe/Moscow (UTC+3)')`, так что при выводе в виде строки время отобразится как `2019-01-01 03:00:00`. -- При вставке даты-времени в виде строки, время трактуется соответственно часовому поясу установленному для колонки. `'2019-01-01 00:00:00'` трактуется как время по Москве (и в базу сохраняется `'2018-12-31 21:00:00'` в виде Unix Timestamp) - -**2.** Фильтрация по значениям даты-времени - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -В отличие от типа `DateTime`, `DateTime64` не конвертируется из строк автоматически - -**3.** Получение часового пояса для значения типа `DateTime64`: - -``` sql -SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────────column─┬─x──────────────────────────────┐ -│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ -└─────────────────────────┴────────────────────────────────┘ -``` - -**4.** Конвертация часовых поясов - -``` sql -SELECT -toDateTime64(timestamp, 3, 'Europe/London') as lon_time, -toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────────lon_time──┬────────────────mos_time─┐ -│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ -│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ -└─────────────────────────┴─────────────────────────┘ -``` - -## See Also {#see-also} - -- [Функции преобразования типов](../../sql_reference/data_types/datetime64.md) -- [Функции для работы с датой и временем](../../sql_reference/data_types/datetime64.md) -- [Функции для работы с массивами](../../sql_reference/data_types/datetime64.md) -- [Настройка `date_time_input_format`](../../operations/settings/settings.md#settings-date_time_input_format) -- [Конфигурационный параметр сервера `timezone`](../../sql_reference/data_types/datetime64.md#server_configuration_parameters-timezone) -- [Операторы для работы с датой и временем](../../sql_reference/data_types/datetime64.md#operators-datetime) -- [Тип данных `Date`](date.md) -- [Тип данных `DateTime`](datetime.md) diff --git a/docs/ru/sql_reference/data_types/decimal.md b/docs/ru/sql_reference/data_types/decimal.md deleted file mode 100644 index 8975406bf4b..00000000000 --- a/docs/ru/sql_reference/data_types/decimal.md +++ /dev/null @@ -1,102 +0,0 @@ -# Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} - -Знаковые дробные числа с сохранением точности операций сложения, умножения и вычитания. Для деления осуществляется отбрасывание (не округление) знаков, не попадающих в младший десятичный разряд. - -## Параметры {#parametry} - -- P - precision. Значение из диапазона \[ 1 : 38 \]. Определяет, сколько десятичных знаков (с учетом дробной части) может содержать число. -- S - scale. Значение из диапазона \[ 0 : P \]. Определяет, сколько десятичных знаков содержится в дробной части числа. - -В зависимости от параметра P Decimal(P, S) является синонимом: -- P из \[ 1 : 9 \] - для Decimal32(S) -- P из \[ 10 : 18 \] - для Decimal64(S) -- P из \[ 19 : 38 \] - для Decimal128(S) - -## Диапазоны Decimal {#diapazony-decimal} - -- Decimal32(S) - ( -1 \* 10^(9 - S), 1 \* 10^(9 - S) ) -- Decimal64(S) - ( -1 \* 10^(18 - S), 1 \* 10^(18 - S) ) -- Decimal128(S) - ( -1 \* 10^(38 - S), 1 \* 10^(38 - S) ) - -Например, Decimal32(4) содержит числа от -99999.9999 до 99999.9999 c шагом 0.0001. - -## Внутреннее представление {#vnutrennee-predstavlenie} - -Внутри данные представляются как знаковые целые числа, соответсвующей разрядности. Реальные диапазоны, хранящиеся в ячейках памяти несколько больше заявленных. Заявленные диапазоны Decimal проверяются только при вводе числа из строкового представления. -Поскольку современные CPU не поддерживают 128-битные числа, операции над Decimal128 эмулируются программно. Decimal128 работает в разы медленней чем Decimal32/Decimal64. - -## Операции и типы результата {#operatsii-i-tipy-rezultata} - -Результат операции между двумя Decimal расширяется до большего типа (независимо от порядка аргументов). - -- Decimal64(S1) Decimal32(S2) -\> Decimal64(S) -- Decimal128(S1) Decimal32(S2) -\> Decimal128(S) -- Decimal128(S1) Decimal64(S2) -\> Decimal128(S) - -Для размера дробной части (scale) результата действуют следующие правила: - -- сложение, вычитание: S = max(S1, S2). -- умножение: S = S1 + S2. -- деление: S = S1. - -При операциях между Decimal и целыми числами результатом является Decimal, аналогичный аргументу. - -Операции между Decimal и Float32/64 не определены. Для осуществления таких операций нужно явно привести один из аргументов функциями: toDecimal32, toDecimal64, toDecimal128, или toFloat32, toFloat64. Это сделано из двух соображений. Во-первых, результат операции будет с потерей точности. Во-вторых, преобразование типа - дорогая операция, из-за ее наличия пользовательский запрос может работать в несколько раз дольше. - -Часть функций над Decimal возвращают Float64 (например, var, stddev). Для некоторых из них промежуточные операции проходят в Decimal. -Для таких функций результат над одинаковыми данными во Float64 и Decimal может отличаться, несмотря на одинаковый тип результата. - -## Проверка переполнений {#proverka-perepolnenii} - -При выполнении операций над типом Decimal могут происходить целочисленные переполнения. Лишняя дробная часть отбрасывается (не округляется). Лишняя целочисленная часть приводит к исключению. - -``` sql -SELECT toDecimal32(2, 4) AS x, x / 3 -``` - -``` text -┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ -│ 2.0000 │ 0.6666 │ -└────────┴──────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, x * x -``` - -``` text -DB::Exception: Scale is out of bounds. -``` - -``` sql -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -DB::Exception: Decimal math overflow. -``` - -Проверка переполнения приводит к замедлению операций. При уверенности, что типа результата хватит для его записи проверку переполнения можно отключить настройкой decimal\_check\_overflow. В этом случае при переполнении вернется неверное значение: - -``` sql -SET decimal_check_overflow = 0; -SELECT toDecimal32(4.2, 8) AS x, 6 * x -``` - -``` text -┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ -│ 4.20000000 │ -17.74967296 │ -└────────────┴──────────────────────────────────┘ -``` - -Переполнения происходят не только на арифметических операциях, но и на операциях сравнения. Отключать проверку стоит только при полной уверенности в корректности результата: - -``` sql -SELECT toDecimal32(1, 8) < 100 -``` - -``` text -DB::Exception: Can't compare. -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/decimal/) diff --git a/docs/ru/sql_reference/data_types/domains/index.md b/docs/ru/sql_reference/data_types/domains/index.md deleted file mode 100644 index d4496cf8d5b..00000000000 --- a/docs/ru/sql_reference/data_types/domains/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Domains -toc_priority: 56 ---- - diff --git a/docs/ru/sql_reference/data_types/enum.md b/docs/ru/sql_reference/data_types/enum.md deleted file mode 100644 index 58f2a4b188e..00000000000 --- a/docs/ru/sql_reference/data_types/enum.md +++ /dev/null @@ -1,124 +0,0 @@ -# Enum {#enum} - -Перечисляемый тип данных, содержащий именованные значения. - -Именованные значения задаются парами `'string' = integer`. ClickHouse хранит только числа, но допускает операции над ними с помощью заданных имён. - -ClickHouse поддерживает: - -- 8-битный `Enum`. Может содержать до 256 значений, пронумерованных в диапазоне `[-128, 127]`. -- 16-битный `Enum`. Может содержать до 65536 значений, пронумерованных в диапазоне `[-32768, 32767]`. - -ClickHouse автоматически выбирает размерность `Enum` при вставке данных. Чтобы точно понимать размер хранимых данных можно использовать типы `Enum8` или `Enum16`. - -## Примеры использования {#primery-ispolzovaniia} - -Создадим таблицу со столбцом типа `Enum8('hello' = 1, 'world' = 2)`. - -``` sql -CREATE TABLE t_enum -( - x Enum('hello' = 1, 'world' = 2) -) -ENGINE = TinyLog -``` - -В столбец `x` можно сохранять только значения, перечисленные при определении типа, т.е. `'hello'` или `'world'`. Если вы попытаетесь сохранить любое другое значение, ClickHouse сгенерирует исключение. ClickHouse автоматически выберет размерность 8-bit для этого `Enum`. - -``` sql -INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') -``` - -``` text -Ok. -``` - -``` sql -insert into t_enum values('a') -``` - -``` text -Exception on client: -Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) -``` - -При запросе данных из таблицы ClickHouse выдаст строковые значения из `Enum`. - -``` sql -SELECT * FROM t_enum -``` - -``` text -┌─x─────┐ -│ hello │ -│ world │ -│ hello │ -└───────┘ -``` - -Если необходимо увидеть цифровые эквиваленты строкам, то необходимо привести тип `Enum` к целочисленному. - -``` sql -SELECT CAST(x AS Int8) FROM t_enum -``` - -``` text -┌─CAST(x, 'Int8')─┐ -│ 1 │ -│ 2 │ -│ 1 │ -└─────────────────┘ -``` - -Чтобы создать значение типа `Enum` в запросе, также необходимо использовать функцию `CAST`. - -``` sql -SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) -``` - -``` text -┌─toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)'))─┐ -│ Enum8('a' = 1, 'b' = 2) │ -└─────────────────────────────────────────────────────┘ -``` - -## Общие правила и особенности использования {#obshchie-pravila-i-osobennosti-ispolzovaniia} - -Для каждого из значений прописывается число в диапазоне `-128 .. 127` для `Enum8` или в диапазоне `-32768 .. 32767` для `Enum16`. Все строки должны быть разными, числа - тоже. Разрешена пустая строка. При указании такого типа (в определении таблицы), числа могут идти не подряд и в произвольном порядке. При этом, порядок не имеет значения. - -Ни строка, ни цифровое значение в `Enum` не могут быть [NULL](../../sql_reference/syntax.md#null-literal). - -`Enum` может быть передан в тип [Nullable](nullable.md). Таким образом, если создать таблицу запросом - -``` sql -CREATE TABLE t_enum_nullable -( - x Nullable( Enum8('hello' = 1, 'world' = 2) ) -) -ENGINE = TinyLog -``` - -, то в ней можно будет хранить не только `'hello'` и `'world'`, но и `NULL`. - -``` sql -INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) -``` - -В оперативке столбец типа `Enum` представлен так же, как `Int8` или `Int16` соответствующими числовыми значениями. -При чтении в текстовом виде, парсит значение как строку и ищет соответствующую строку из множества значений Enum-а. Если не находит - кидается исключение. -При записи в текстовом виде, записывает значение как соответствующую строку. Если в данных столбца есть мусор - числа не из допустимого множества, то кидается исключение. При чтении и записи в бинарном виде, оно осуществляется так же, как для типов данных Int8, Int16. -Неявное значение по умолчанию - это значение с минимальным номером. - -При `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT` и т. п., Enum-ы ведут себя так же, как соответствующие числа. Например, при ORDER BY они сортируются по числовым значениям. Функции сравнения на равенство и сравнения на отношение порядка двух Enum-ов работают с Enum-ами так же, как с числами. - -Сравнивать Enum с числом нельзя. Можно сравнивать Enum с константной строкой - при этом, для строки ищется соответствующее значение Enum-а; если не находится - кидается исключение. Поддерживается оператор IN, где слева стоит Enum, а справа - множество строк. В этом случае, строки рассматриваются как значения соответствующего Enum-а. - -Большинство операций с числами и со строками не имеет смысла и не работают для Enum-ов: например, к Enum-у нельзя прибавить число. -Для Enum-а естественным образом определяется функция `toString`, которая возвращает его строковое значение. - -Также для Enum-а определяются функции `toT`, где T - числовой тип. При совпадении T с типом столбца Enum-а, преобразование работает бесплатно. -При ALTER, есть возможность бесплатно изменить тип Enum-а, если меняется только множество значений. При этом, можно добавлять новые значения; можно удалять старые значения (это безопасно только если они ни разу не использовались, так как это не проверяется). В качестве «защиты от дурака», нельзя менять числовые значения у имеющихся строк - в этом случае, кидается исключение. - -При ALTER, есть возможность поменять Enum8 на Enum16 и обратно - так же, как можно поменять Int8 на Int16. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/enum/) diff --git a/docs/ru/sql_reference/data_types/fixedstring.md b/docs/ru/sql_reference/data_types/fixedstring.md deleted file mode 100644 index 7e2fdd5d525..00000000000 --- a/docs/ru/sql_reference/data_types/fixedstring.md +++ /dev/null @@ -1,56 +0,0 @@ -# FixedString {#fixedstring} - -Строка фиксированной длины `N` байт (не символов, не кодовых точек). - -Чтобы объявить столбец типа `FixedString`, используйте следующий синтаксис: - -``` sql - FixedString(N) -``` - -Где `N` — натуральное число. - -Тип `FixedString` эффективен, когда данные имеют длину ровно `N` байт. Во всех остальных случаях использование FixedString может привести к снижению эффективности. - -Примеры значений, которые можно эффективно хранить в столбцах типа `FixedString`: - -- Двоичное представление IP-адреса (`FixedString(16)` для IPv6). -- Коды языков (ru\_RU, en\_US … ). -- Коды валют (USD, RUB … ). -- Двоичное представление хэшей (`FixedString(16)` для MD5, `FixedString(32)` для SHA256). - -Для хранения значений UUID используйте тип данных [UUID](uuid.md). - -При вставке данных, ClickHouse: - -- Дополняет строку нулевыми байтами, если строка содержит меньше байтов, чем `N`. -- Генерирует исключение `Too large value for FixedString(N)`, если строка содержит более `N` байт. - -При выборе данных ClickHouse не обрезает нулевые байты в конце строки. Если вы используете секцию `WHERE`, то необходимо добавлять нулевые байты вручную, чтобы ClickHouse смог сопоставить выражение из фильтра значению `FixedString`. Следующий пример показывает, как использовать секцию `WHERE` с `FixedString`. - -Рассмотрим следующую таблицу с единственным столбцом типа `FixedString(2)`: - -``` text -┌─name──┐ -│ b │ -└───────┘ -``` - -Запрос `SELECT * FROM FixedStringTable WHERE a = 'b'` не возвращает необходимых данных. Необходимо дополнить шаблон фильтра нулевыми байтами. - -``` sql -SELECT * FROM FixedStringTable -WHERE a = 'b\0' -``` - -``` text -┌─a─┐ -│ b │ -└───┘ -``` - -Это поведение отличается от поведения MySQL для типа `CHAR`, где строки дополняются пробелами, а пробелы перед выводом вырезаются. - -Обратите внимание, что длина значения `FixedString(N)` постоянна. Функция [length](../../sql_reference/data_types/fixedstring.md#array_functions-length) возвращает `N` даже если значение `FixedString(N)` заполнено только нулевыми байтами, однако функция [empty](../../sql_reference/data_types/fixedstring.md#empty) в этом же случае возвращает `1`. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/fixedstring/) diff --git a/docs/ru/sql_reference/data_types/index.md b/docs/ru/sql_reference/data_types/index.md deleted file mode 100644 index 1fd52b9bf9e..00000000000 --- a/docs/ru/sql_reference/data_types/index.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -toc_folder_title: Типы данных -toc_priority: 37 -toc_title: Введение ---- - -# Типы данных {#data_types} - -ClickHouse может сохранять в ячейках таблиц данные различных типов. - -Раздел содержит описания поддерживаемых типов данных и специфику их использования и/или реализации, если таковые имеются. -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/) diff --git a/docs/ru/sql_reference/data_types/int_uint.md b/docs/ru/sql_reference/data_types/int_uint.md deleted file mode 100644 index 417e05db626..00000000000 --- a/docs/ru/sql_reference/data_types/int_uint.md +++ /dev/null @@ -1,19 +0,0 @@ -# UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} - -Целые числа фиксированной длины, без знака или со знаком. - -## Диапазоны Int {#diapazony-int} - -- Int8 - \[ -128 : 127 \] -- Int16 - \[ -32768 : 32767 \] -- Int32 - \[ -2147483648 : 2147483647 \] -- Int64 - \[ -9223372036854775808 : 9223372036854775807 \] - -## Диапазоны Uint {#diapazony-uint} - -- UInt8 - \[ 0 : 255 \] -- UInt16 - \[ 0 : 65535 \] -- UInt32 - \[ 0 : 4294967295 \] -- UInt64 - \[ 0 : 18446744073709551615 \] - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/int_uint/) diff --git a/docs/ru/sql_reference/data_types/nullable.md b/docs/ru/sql_reference/data_types/nullable.md deleted file mode 100644 index dfbd0fb0512..00000000000 --- a/docs/ru/sql_reference/data_types/nullable.md +++ /dev/null @@ -1,46 +0,0 @@ -# Nullable(TypeName) {#data_type-nullable} - -Позволяет работать как со значением типа `TypeName` так и с отсутствием этого значения ([NULL](../../sql_reference/data_types/nullable.md)) в одной и той же переменной, в том числе хранить `NULL` в таблицах вместе со значения типа `TypeName`. Например, в столбце типа `Nullable(Int8)` можно хранить значения типа `Int8`, а в тех строках, где значения нет, будет храниться `NULL`. - -В качестве `TypeName` нельзя использовать составные типы данных [Array](array.md#data_type-array) и [Tuple](tuple.md). Составные типы данных могут содержать значения типа `Nullable`, например `Array(Nullable(Int8))`. - -Поле типа `Nullable` нельзя включать в индексы. - -`NULL` — значение по умолчанию для типа `Nullable`, если в конфигурации сервера ClickHouse не указано иное. - -## Особенности хранения {#osobennosti-khraneniia} - -Для хранения значения типа `Nullable` ClickHouse использует: - -- Отдельный файл с масками `NULL` (далее маска). -- Непосредственно файл со значениями. - -Маска определяет, что лежит в ячейке данных: `NULL` или значение. - -В случае, когда маска указывает, что в ячейке хранится `NULL`, в файле значений хранится значение по умолчанию для типа данных. Т.е. если, например, поле имеет тип `Nullable(Int8)`, то ячейка будет хранить значение по умолчанию для `Int8`. Эта особенность увеличивает размер хранилища. - -!!! info "Info" - Почти всегда использование `Nullable` снижает производительность, учитывайте это при проектировании своих баз. - -## Пример использования {#primer-ispolzovaniia} - -``` sql -CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog -``` - -``` sql -INSERT INTO t_null VALUES (1, NULL), (2, 3) -``` - -``` sql -SELECT x + y from t_null -``` - -``` text -┌─plus(x, y)─┐ -│ ᴺᵁᴸᴸ │ -│ 5 │ -└────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/nullable/) diff --git a/docs/ru/sql_reference/data_types/simpleaggregatefunction.md b/docs/ru/sql_reference/data_types/simpleaggregatefunction.md deleted file mode 120000 index 02fad64d50e..00000000000 --- a/docs/ru/sql_reference/data_types/simpleaggregatefunction.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/sql_reference/data_types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/ru/sql_reference/data_types/special_data_types/interval.md b/docs/ru/sql_reference/data_types/special_data_types/interval.md deleted file mode 100644 index 1721b8631ad..00000000000 --- a/docs/ru/sql_reference/data_types/special_data_types/interval.md +++ /dev/null @@ -1,78 +0,0 @@ -# Interval {#data-type-interval} - -Семейство типов данных, представляющих интервалы дат и времени. Оператор [INTERVAL](../../../sql_reference/data_types/special_data_types/interval.md#operator-interval) возвращает значения этих типов. - -!!! warning "Внимание" - Нельзя использовать типы данных `Interval` для хранения данных в таблице. - -Структура: - -- Интервал времени в виде положительного целого числа. -- Тип интервала. - -Поддержанные типы интервалов: - -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -Каждому типу интервала соответствует отдельный тип данных. Например, тип данных `IntervalDay` соответствует интервалу `DAY`: - -``` sql -SELECT toTypeName(INTERVAL 4 DAY) -``` - -``` text -┌─toTypeName(toIntervalDay(4))─┐ -│ IntervalDay │ -└──────────────────────────────┘ -``` - -## Использование {#data-type-interval-usage-remarks} - -Значения типов `Interval` можно использовать в арифметических операциях со значениями типов [Date](../../../sql_reference/data_types/special_data_types/interval.md) и [DateTime](../../../sql_reference/data_types/special_data_types/interval.md). Например, можно добавить 4 дня к текущей дате: - -``` sql -SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY -``` - -``` text -┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ -│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ -└─────────────────────┴───────────────────────────────┘ -``` - -Нельзя объединять интервалы различных типов. Нельзя использовать интервалы вида `4 DAY 1 HOUR`. Вместо этого выражайте интервал в единицах меньших или равных минимальной единице интервала, например, интервал «1 день и 1 час» можно выразить как `25 HOUR` или `90000 SECOND`. - -Арифметические операции со значениями типов `Interval` не доступны, однако можно последовательно добавлять различные интервалы к значениям типов `Date` и `DateTime`. Например: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -Следующий запрос приведёт к генерированию исключения: - -``` sql -select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) -``` - -``` text -Received exception from server (version 19.14.1): -Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. -``` - -## Смотрите также {#smotrite-takzhe} - -- Оператор[INTERVAL](../../../sql_reference/data_types/special_data_types/interval.md#operator-interval) -- Функция приведения типа [toInterval](../../../sql_reference/data_types/special_data_types/interval.md#function-tointerval) diff --git a/docs/ru/sql_reference/data_types/special_data_types/nothing.md b/docs/ru/sql_reference/data_types/special_data_types/nothing.md deleted file mode 100644 index c23de847077..00000000000 --- a/docs/ru/sql_reference/data_types/special_data_types/nothing.md +++ /dev/null @@ -1,17 +0,0 @@ -# Nothing {#nothing} - -Этот тип данных предназначен только для того, чтобы представлять [NULL](../../../sql_reference/data_types/special_data_types/nothing.md), т.е. отсутствие значения. - -Невозможно создать значение типа `Nothing`, поэтому он используется там, где значение не подразумевается. Например, `NULL` записывается как `Nullable(Nothing)` ([Nullable](../../../sql_reference/data_types/special_data_types/nothing.md) — это тип данных, позволяющий хранить `NULL` в таблицах). Также тип `Nothing` используется для обозначения пустых массивов: - -``` sql -SELECT toTypeName(Array()) -``` - -``` text -┌─toTypeName(array())─┐ -│ Array(Nothing) │ -└─────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/special_data_types/nothing/) diff --git a/docs/ru/sql_reference/data_types/tuple.md b/docs/ru/sql_reference/data_types/tuple.md deleted file mode 100644 index e8f5f335278..00000000000 --- a/docs/ru/sql_reference/data_types/tuple.md +++ /dev/null @@ -1,45 +0,0 @@ -# Tuple(T1, T2, …) {#tuplet1-t2} - -Кортеж из элементов любого [типа](index.md#data_types). Элементы кортежа могут быть одного или разных типов. - -Кортежи используются для временной группировки столбцов. Столбцы могут группироваться при использовании выражения IN в запросе, а также для указания нескольких формальных параметров лямбда-функций. Подробнее смотрите разделы [Операторы IN](../../sql_reference/data_types/tuple.md), [Функции высшего порядка](../../sql_reference/data_types/tuple.md#higher_order_functions). - -Кортежи могут быть результатом запроса. В этом случае, в текстовых форматах кроме JSON, значения выводятся в круглых скобках через запятую. В форматах JSON, кортежи выводятся в виде массивов (в квадратных скобках). - -## Создание кортежа {#sozdanie-kortezha} - -Кортеж можно создать с помощью функции - -``` sql -tuple(T1, T2, ...) -``` - -Пример создания кортежа: - -``` sql -SELECT tuple(1,'a') AS x, toTypeName(x) -``` - -``` text -┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ -│ (1,'a') │ Tuple(UInt8, String) │ -└─────────┴───────────────────────────┘ -``` - -## Особенности работы с типами данных {#osobennosti-raboty-s-tipami-dannykh} - -При создании кортежа «на лету» ClickHouse автоматически определяет тип каждого аргументов как минимальный из типов, который может сохранить значение аргумента. Если аргумент — [NULL](../../sql_reference/data_types/tuple.md#null-literal), то тип элемента кортежа — [Nullable](nullable.md). - -Пример автоматического определения типа данных: - -``` sql -SELECT tuple(1,NULL) AS x, toTypeName(x) -``` - -``` text -┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ -│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ -└──────────┴─────────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/tuple/) diff --git a/docs/ru/sql_reference/data_types/uuid.md b/docs/ru/sql_reference/data_types/uuid.md deleted file mode 100644 index d62ec22eecb..00000000000 --- a/docs/ru/sql_reference/data_types/uuid.md +++ /dev/null @@ -1,72 +0,0 @@ -# UUID {#uuid-data-type} - -Универсальный уникальный идентификатор (UUID) - это 16-байтовое число, используемое для идентификации записей. Подробнее про UUID читайте на [Википедии](https://en.wikipedia.org/wiki/Universally_unique_identifier). - -Пример UUID значения представлен ниже: - -``` text -61f0c404-5cb3-11e7-907b-a6006ad3dba0 -``` - -Если при вставке новой записи значение для UUID-колонки не указано, UUID идентификатор будет заполнен нулями: - -``` text -00000000-0000-0000-0000-000000000000 -``` - -## Как сгенерировать UUID {#kak-sgenerirovat-uuid} - -Для генерации UUID-значений предназначена функция [generateUUIDv4](../../sql_reference/data_types/uuid.md). - -## Примеры использования {#primery-ispolzovaniia} - -Ниже представлены примеры работы с UUID. - -**Пример 1** - -Этот пример демонстрирует, как создать таблицу с UUID-колонкой и добавить в нее сгенерированный UUID. - -``` sql -CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog -``` - -``` sql -INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -└──────────────────────────────────────┴───────────┘ -``` - -**Пример 2** - -В этом примере, при добавлении записи в таблицу значение для UUID-колонки не задано. UUID будет заполнен нулями. - -``` sql -INSERT INTO t_uuid (y) VALUES ('Example 2') -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ -└──────────────────────────────────────┴───────────┘ -``` - -## Ограничения {#ogranicheniia} - -Тип данных UUID можно использовать только с функциями, которые поддерживаются типом данных [String](string.md) (например, [min](../../sql_reference/data_types/uuid.md#agg_function-min), [max](../../sql_reference/data_types/uuid.md#agg_function-max), и [count](../../sql_reference/data_types/uuid.md#agg_function-count)). - -Тип данных UUID не поддерживается арифметическими операциями (например, [abs](../../sql_reference/data_types/uuid.md#arithm_func-abs)) или агрегатными функциями, такими как [sum](../../sql_reference/data_types/uuid.md#agg_function-sum) и [avg](../../sql_reference/data_types/uuid.md#agg_function-avg). - -[Original article](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts.md deleted file mode 100644 index 4929e571758..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts.md +++ /dev/null @@ -1,52 +0,0 @@ -# Внешние словари {#dicts-external-dicts} - -Существует возможность подключать собственные словари из различных источников данных. Источником данных для словаря может быть локальный текстовый/исполняемый файл, HTTP(s) ресурс или другая СУБД. Подробнее смотрите в разделе «[Источники внешних словарей](external_dicts_dict_sources.md)». - -ClickHouse: -- Полностью или частично хранит словари в оперативной памяти. -- Периодически обновляет их и динамически подгружает отсутствующие значения. -- Позволяет создавать внешние словари с помощью xml-файлов или [DDL-запросов](../../../sql_reference/statements/create.md#create-dictionary-query). - -Конфигурация внешних словарей может находится в одном или нескольких xml-файлах. Путь к конфигурации указывается в параметре [dictionaries\_config](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -Словари могут загружаться при старте сервера или при первом использовании, в зависимости от настройки [dictionaries\_lazy\_load](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -Конфигурационный файл словарей имеет вид: - -``` xml - - Необязательный элемент с любым содержимым. Игнорируется сервером ClickHouse. - - - /etc/metrika.xml - - - - - - - ... - - - - - -``` - -В одном файле можно [сконфигурировать](external_dicts_dict.md) произвольное количество словарей. - -Если вы создаёте внешние словари [DDL-запросами](../../../sql_reference/statements/create.md#create-dictionary-query), то не задавайте конфигурацию словаря в конфигурации сервера. - -!!! attention "Внимание" - Можно преобразовывать значения по небольшому словарю, описав его в запросе `SELECT` (см. функцию [transform](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md)). Эта функциональность не связана с внешними словарями. - -## Смотрите также {#ext-dicts-see-also} - -- [Настройка внешнего словаря](external_dicts_dict.md) -- [Хранение словарей в памяти](external_dicts_dict_layout.md) -- [Обновление словарей](external_dicts_dict_lifetime.md) -- [Источники внешних словарей](external_dicts_dict_sources.md) -- [Ключ и поля словаря](external_dicts_dict_structure.md) -- [Функции для работы с внешними словарями](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md#ext_dict_functions) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md deleted file mode 100644 index 2e3068882bf..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md +++ /dev/null @@ -1,46 +0,0 @@ -# Настройка внешнего словаря {#dicts-external-dicts-dict} - -XML-конфигурация словаря имеет следующую структуру: - -``` xml - - dict_name - - - - - - - - - - - - - - - - - -``` - -Соответствующий [DDL-запрос](../../../sql_reference/statements/create.md#create-dictionary-query) имеет следующий вид: - -``` sql -CREATE DICTIONARY dict_name -( - ... -- attributes -) -PRIMARY KEY ... -- complex or single key configuration -SOURCE(...) -- Source configuration -LAYOUT(...) -- Memory layout configuration -LIFETIME(...) -- Lifetime of dictionary in memory -``` - -- `name` — Идентификатор, под которым словарь будет доступен для использования. Используйте символы `[a-zA-Z0-9_\-]`. -- [source](external_dicts_dict_sources.md) — Источник словаря. -- [layout](external_dicts_dict_layout.md) — Размещение словаря в памяти. -- [structure](external_dicts_dict_structure.md) — Структура словаря. Ключ и атрибуты, которые можно получить по ключу. -- [lifetime](external_dicts_dict_lifetime.md) — Периодичность обновления словарей. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md deleted file mode 100644 index ef9b79c0444..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md +++ /dev/null @@ -1,63 +0,0 @@ -# Иерархические словари {#ierarkhicheskie-slovari} - -ClickHouse поддерживает иерархические словари с [числовыми ключом](external_dicts_dict_structure.md#ext_dict-numeric-key). - -Рассмотрим следующую структуру: - -``` text -0 (Common parent) -│ -├── 1 (Russia) -│ │ -│ └── 2 (Moscow) -│ │ -│ └── 3 (Center) -│ -└── 4 (Great Britain) - │ - └── 5 (London) -``` - -Эту иерархию можно выразить в виде следующей таблицы-словаря. - -| region\_id | parent\_region | region\_name | -|------------|----------------|---------------| -| 1 | 0 | Russia | -| 2 | 1 | Moscow | -| 3 | 2 | Center | -| 4 | 0 | Great Britain | -| 5 | 4 | London | - -Таблица содержит столбец `parent_region`, содержащий ключ ближайшего предка для текущего элемента. - -ClickHouse поддерживает свойство [hierarchical](external_dicts_dict_structure.md#hierarchical-dict-attr) для атрибутов [внешнего словаря](index.md). Это свойство позволяет конфигурировать словари, подобные описанному выше. - -С помощью функции [dictGetHierarchy](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md#dictgethierarchy) можно получить цепочку предков элемента. - -Структура словаря для нашего примера может выглядеть следующим образом: - -``` xml - - - - region_id - - - - parent_region - UInt64 - 0 - true - - - - region_name - String - - - - - -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md deleted file mode 100644 index 898fe45b15a..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md +++ /dev/null @@ -1,369 +0,0 @@ -# Хранение словарей в памяти {#dicts-external-dicts-dict-layout} - -Словари можно размещать в памяти множеством способов. - -Рекомендуем [flat](#flat), [hashed](#hashed) и [complex\_key\_hashed](#complex-key-hashed). Скорость обработки словарей при этом максимальна. - -Размещение с кэшированием не рекомендуется использовать из-за потенциально низкой производительности и сложностей в подборе оптимальных параметров. Читайте об этом подробнее в разделе «[cache](#cache)». - -Повысить производительность словарей можно следующими способами: - -- Вызывать функцию для работы со словарём после `GROUP BY`. -- Помечать извлекаемые атрибуты как инъективные. Атрибут называется инъективным, если разным ключам соответствуют разные значения атрибута. Тогда при использовании в `GROUP BY` функции, достающей значение атрибута по ключу, эта функция автоматически выносится из `GROUP BY`. - -При ошибках работы со словарями ClickHouse генерирует исключения. Например, в следующих ситуациях: - -- При обращении к словарю, который не удалось загрузить. -- При ошибке запроса к `cached`-словарю. - -Список внешних словарей и их статус можно посмотреть в таблице `system.dictionaries`. - -Общий вид конфигурации: - -``` xml - - - ... - - - - - - ... - - -``` - -Соответствущий [DDL-запрос](../../../sql_reference/statements/create.md#create-dictionary-query): - -``` sql -CREATE DICTIONARY (...) -... -LAYOUT(LAYOUT_TYPE(param value)) -- layout settings -... -``` - -## Способы размещения словарей в памяти {#sposoby-razmeshcheniia-slovarei-v-pamiati} - -- [flat](#flat) -- [hashed](#hashed) -- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) -- [cache](#cache) -- [range\_hashed](#range-hashed) -- [complex\_key\_hashed](#complex-key-hashed) -- [complex\_key\_cache](#complex-key-cache) -- [ip\_trie](#ip-trie) - -### flat {#flat} - -Словарь полностью хранится в оперативной памяти в виде плоских массивов. Объём памяти, занимаемой словарём пропорционален размеру самого большого по размеру ключа. - -Ключ словаря имеет тип `UInt64` и его величина ограничена 500 000. Если при создании словаря обнаружен ключ больше, то ClickHouse бросает исключение и не создает словарь. - -Поддерживаются все виды источников. При обновлении, данные (из файла, из таблицы) читаются целиком. - -Это метод обеспечивает максимальную производительность среди всех доступных способов размещения словаря. - -Пример конфигурации: - -``` xml - - - -``` - -или - -``` sql -LAYOUT(FLAT()) -``` - -### hashed {#hashed} - -Словарь полностью хранится в оперативной памяти в виде хэш-таблиц. Словарь может содержать произвольное количество элементов с произвольными идентификаторами. На практике, количество ключей может достигать десятков миллионов элементов. - -Поддерживаются все виды источников. При обновлении, данные (из файла, из таблицы) читаются целиком. - -Пример конфигурации: - -``` xml - - - -``` - -или - -``` sql -LAYOUT(HASHED()) -``` - -### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} - -Аналогичен `hashed`, но при этом занимает меньше места в памяти и генерирует более высокую загрузку CPU. - -Пример конфигурации: - -``` xml - - - -``` - -или - -``` sql -LAYOUT(SPARSE_HASHED()) -``` - -### complex\_key\_hashed {#complex-key-hashed} - -Тип размещения предназначен для использования с составными [ключами](external_dicts_dict_structure.md). Аналогичен `hashed`. - -Пример конфигурации: - -``` xml - - - -``` - -или - -``` sql -LAYOUT(COMPLEX_KEY_HASHED()) -``` - -### range\_hashed {#range-hashed} - -Словарь хранится в оперативной памяти в виде хэш-таблицы с упорядоченным массивом диапазонов и соответствующих им значений. - -Этот способ размещения работает также как и hashed и позволяет дополнительно к ключу использовать дипазоны по дате/времени (произвольному числовому типу). - -Пример: таблица содержит скидки для каждого рекламодателя в виде: - -``` text -+---------------+---------------------+-------------------+--------+ -| advertiser id | discount start date | discount end date | amount | -+===============+=====================+===================+========+ -| 123 | 2015-01-01 | 2015-01-15 | 0.15 | -+---------------+---------------------+-------------------+--------+ -| 123 | 2015-01-16 | 2015-01-31 | 0.25 | -+---------------+---------------------+-------------------+--------+ -| 456 | 2015-01-01 | 2015-01-15 | 0.05 | -+---------------+---------------------+-------------------+--------+ -``` - -Чтобы использовать выборку по диапазонам дат, необходимо в [structure](external_dicts_dict_structure.md) определить элементы `range_min`, `range_max`. В этих элементах должны присутствовать элементы `name` и `type` (если `type` не указан, будет использован тип по умолчанию – Date). `type` может быть любым численным типом (Date/DateTime/UInt64/Int32/др.). - -Пример: - -``` xml - - - Id - - - first - Date - - - last - Date - - ... -``` - -или - -``` sql -CREATE DICTIONARY somedict ( - id UInt64, - first Date, - last Date -) -PRIMARY KEY id -LAYOUT(RANGE_HASHED()) -RANGE(MIN first MAX last) -``` - -Для работы с такими словарями в функцию `dictGetT` необходимо передавать дополнительный аргумент, для которого подбирается диапазон: - - dictGetT('dict_name', 'attr_name', id, date) - -Функция возвращает значение для заданных `id` и диапазона дат, в который входит переданная дата. - -Особенности алгоритма: - -- Если не найден `id` или для найденного `id` не найден диапазон, то возвращается значение по умолчанию для словаря. -- Если есть перекрывающиеся диапазоны, то можно использовать любой подходящий. -- Если граница диапазона `NULL` или некорректная дата (1900-01-01, 2039-01-01), то диапазон считается открытым. Диапазон может быть открытым с обеих сторон. - -Пример конфигурации: - -``` xml - - - - ... - - - - - - - - Abcdef - - - StartTimeStamp - UInt64 - - - EndTimeStamp - UInt64 - - - XXXType - String - - - - - - -``` - -или - -``` sql -CREATE DICTIONARY somedict( - Abcdef UInt64, - StartTimeStamp UInt64, - EndTimeStamp UInt64, - XXXType String DEFAULT '' -) -PRIMARY KEY Abcdef -RANGE(MIN StartTimeStamp MAX EndTimeStamp) -``` - -### cache {#cache} - -Словарь хранится в кэше, состоящем из фиксированного количества ячеек. Ячейки содержат часто используемые элементы. - -При поиске в словаре сначала просматривается кэш. На каждый блок данных, все не найденные в кэше или устаревшие ключи запрашиваются у источника с помощью `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. Затем, полученные данные записываются в кэш. - -Для cache-словарей может быть задано время устаревания [lifetime](external_dicts_dict_lifetime.md) данных в кэше. Если от загрузки данных в ячейке прошло больше времени, чем `lifetime`, то значение не используется, и будет запрошено заново при следующей необходимости его использовать. - -Это наименее эффективный из всех способов размещения словарей. Скорость работы кэша очень сильно зависит от правильности настройки и сценария использования. Словарь типа cache показывает высокую производительность лишь при достаточно больших hit rate-ах (рекомендуется 99% и выше). Посмотреть средний hit rate можно в таблице `system.dictionaries`. - -Чтобы увеличить производительность кэша, используйте подзапрос с `LIMIT`, а снаружи вызывайте функцию со словарём. - -Поддерживаются [источники](external_dicts_dict_sources.md): MySQL, ClickHouse, executable, HTTP. - -Пример настройки: - -``` xml - - - - 1000000000 - - -``` - -или - -``` sql -LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) -``` - -Укажите достаточно большой размер кэша. Количество ячеек следует подобрать экспериментальным путём: - -1. Выставить некоторое значение. -2. Запросами добиться полной заполненности кэша. -3. Оценить потребление оперативной памяти с помощью таблицы `system.dictionaries`. -4. Увеличивать/уменьшать количество ячеек до получения требуемого расхода оперативной памяти. - -!!! warning "Warning" - Не используйте в качестве источника ClickHouse, поскольку он медленно обрабатывает запросы со случайным чтением. - -### complex\_key\_cache {#complex-key-cache} - -Тип размещения предназначен для использования с составными [ключами](external_dicts_dict_structure.md). Аналогичен `cache`. - -### ip\_trie {#ip-trie} - -Тип размещения предназначен для сопоставления префиксов сети (IP адресов) с метаданными, такими как ASN. - -Пример: таблица содержит префиксы сети и соответствующие им номера AS и коды стран: - -``` text - +-----------------+-------+--------+ - | prefix | asn | cca2 | - +=================+=======+========+ - | 202.79.32.0/20 | 17501 | NP | - +-----------------+-------+--------+ - | 2620:0:870::/48 | 3856 | US | - +-----------------+-------+--------+ - | 2a02:6b8:1::/48 | 13238 | RU | - +-----------------+-------+--------+ - | 2001:db8::/32 | 65536 | ZZ | - +-----------------+-------+--------+ -``` - -При использовании такого макета структура должна иметь составной ключ. - -Пример: - -``` xml - - - - prefix - String - - - - asn - UInt32 - - - - cca2 - String - ?? - - ... -``` - -или - -``` sql -CREATE DICTIONARY somedict ( - prefix String, - asn UInt32, - cca2 String DEFAULT '??' -) -PRIMARY KEY prefix -``` - -Этот ключ должен иметь только один атрибут типа `String`, содержащий допустимый префикс IP. Другие типы еще не поддерживаются. - -Для запросов необходимо использовать те же функции (`dictGetT` с кортежем), что и для словарей с составными ключами: - -``` sql -dictGetT('dict_name', 'attr_name', tuple(ip)) -``` - -Функция принимает либо `UInt32` для IPv4, либо `FixedString(16)` для IPv6: - -``` sql -dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) -``` - -Никакие другие типы не поддерживаются. Функция возвращает атрибут для префикса, соответствующего данному IP-адресу. Если есть перекрывающиеся префиксы, возвращается наиболее специфический. - -Данные хранятся в побитовом дереве (`trie`), он должен полностью помещаться в оперативной памяти. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md deleted file mode 100644 index e886a3e7ef6..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md +++ /dev/null @@ -1,81 +0,0 @@ -# Обновление словарей {#obnovlenie-slovarei} - -ClickHouse периодически обновляет словари. Интервал обновления для полностью загружаемых словарей и интервал инвалидации для кэшируемых словарей определяется в теге `` в секундах. - -Обновление словарей (кроме загрузки при первом использовании) не блокирует запросы - во время обновления используется старая версия словаря. Если при обновлении возникнет ошибка, то ошибка пишется в лог сервера, а запросы продолжат использовать старую версию словарей. - -Пример настройки: - -``` xml - - ... - 300 - ... - -``` - -или - -``` sql -CREATE DICTIONARY (...) -... -LIFETIME(300) -... -``` - -Настройка `0` запрещает обновление словарей. - -Можно задать интервал, внутри которого ClickHouse равномерно-случайно выберет время для обновления. Это необходимо для распределения нагрузки на источник словаря при обновлении на большом количестве серверов. - -Пример настройки: - -``` xml - - ... - - 300 - 360 - - ... - -``` - -или - -``` sql -LIFETIME(MIN 300 MAX 360) -``` - -При обновлении словарей сервер ClickHouse применяет различную логику в зависимости от типа [источника](external_dicts_dict_sources.md): - -> - У текстового файла проверяется время модификации. Если время изменилось по отношению к запомненному ранее, то словарь обновляется. -> - Для таблиц типа MyISAM, время модификации проверяется запросом `SHOW TABLE STATUS`. -> - Словари из других источников по умолчанию обновляются каждый раз. - -Для источников MySQL (InnoDB), ODBC и ClickHouse можно настроить запрос, который позволит обновлять словари только в случае их фактического изменения, а не каждый раз. Чтобы это сделать необходимо выполнить следующие условия/действия: - -> - В таблице словаря должно быть поле, которое гарантированно изменяется при обновлении данных в источнике. -> - В настройках источника указывается запрос, который получает изменяющееся поле. Результат запроса сервер ClickHouse интерпретирует как строку и если эта строка изменилась по отношению к предыдущему состоянию, то словарь обновляется. Запрос следует указывать в поле `` настроек [источника](external_dicts_dict_sources.md). - -Пример настройки: - -``` xml - - ... - - ... - SELECT update_time FROM dictionary_source where id = 1 - - ... - -``` - -или - -``` sql -... -SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) -... -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md deleted file mode 100644 index ae3bb57fae7..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md +++ /dev/null @@ -1,613 +0,0 @@ -# Источники внешних словарей {#dicts-external-dicts-dict-sources} - -Внешний словарь можно подключить из множества источников. - -Общий вид XML-конфигурации: - -``` xml - - - ... - - - - - - ... - - ... - -``` - -Аналогичный [DDL-запрос](../../../sql_reference/statements/create.md#create-dictionary-query): - -``` sql -CREATE DICTIONARY dict_name (...) -... -SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration -... -``` - -Источник настраивается в разделе `source`. - -Для типов источников [Локальный файл](#dicts-external_dicts_dict_sources-local_file), [Исполняемый файл](#dicts-external_dicts_dict_sources-executable), [HTTP(s)](#dicts-external_dicts_dict_sources-http), [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) -доступны дополнительные настройки: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - - 0 - - -``` -или -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -SETTINGS(format_csv_allow_single_quotes = 0) -``` - -Типы источников (`source_type`): - -- [Локальный файл](#dicts-external_dicts_dict_sources-local_file) -- [Исполняемый файл](#dicts-external_dicts_dict_sources-executable) -- [HTTP(s)](#dicts-external_dicts_dict_sources-http) -- СУБД: - - [ODBC](#dicts-external_dicts_dict_sources-odbc) - - [MySQL](#dicts-external_dicts_dict_sources-mysql) - - [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) - - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) - - [Redis](#dicts-external_dicts_dict_sources-redis) - -## Локальный файл {#dicts-external_dicts_dict_sources-local_file} - -Пример настройки: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - -``` - -или - -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -Поля настройки: - -- `path` — Абсолютный путь к файлу. -- `format` — Формат файла. Поддерживаются все форматы, описанные в разделе «[Форматы](../../../interfaces/formats.md#formats)». - -## Исполняемый файл {#dicts-external_dicts_dict_sources-executable} - -Работа с исполняемым файлом зависит от [размещения словаря в памяти](external_dicts_dict_layout.md). Если тип размещения словаря `cache` и `complex_key_cache`, то ClickHouse запрашивает необходимые ключи, отправляя запрос в `STDIN` исполняемого файла. - -Пример настройки: - -``` xml - - - cat /opt/dictionaries/os.tsv - TabSeparated - - -``` - -или - -``` sql -SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -Поля настройки: - -- `command` — Абсолютный путь к исполняемому файлу или имя файла (если каталог программы прописан в `PATH`). -- `format` — Формат файла. Поддерживаются все форматы, описанные в разделе «[Форматы](../../../interfaces/formats.md#formats)». - -## HTTP(s) {#dicts-external_dicts_dict_sources-http} - -Работа с HTTP(s) сервером зависит от [размещения словаря в памяти](external_dicts_dict_layout.md). Если тип размещения словаря `cache` и `complex_key_cache`, то ClickHouse запрашивает необходимые ключи, отправляя запрос методом `POST`. - -Пример настройки: - -``` xml - - - http://[::1]/os.tsv - TabSeparated - - user - password - - -
- API-KEY - key -
-
-
- -``` - -или - -``` sql -SOURCE(HTTP( - url 'http://[::1]/os.tsv' - format 'TabSeparated' - credentials(user 'user' password 'password') - headers(header(name 'API-KEY' value 'key')) -)) -``` - -Чтобы ClickHouse смог обратиться к HTTPS-ресурсу, необходимо [настроить openSSL](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md) в конфигурации сервера. - -Поля настройки: - -- `url` — URL источника. -- `format` — Формат файла. Поддерживаются все форматы, описанные в разделе «[Форматы](../../../interfaces/formats.md#formats)». - -## ODBC {#dicts-external_dicts_dict_sources-odbc} - -Этим способом можно подключить любую базу данных, имеющую ODBC драйвер. - -Пример настройки: - -``` xml - - - DatabaseName -
ShemaName.TableName
- DSN=some_parameters - SQL_QUERY - - -``` - -или - -``` sql -SOURCE(ODBC( - db 'DatabaseName' - table 'SchemaName.TableName' - connection_string 'DSN=some_parameters' - invalidate_query 'SQL_QUERY' -)) -``` - -Поля настройки: - -- `db` — имя базы данных. Не указывать, если имя базы задано в параметрах. ``. -- `table` — имя таблицы и схемы, если она есть. -- `connection_string` — строка соединения. -- `invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external_dicts_dict_lifetime.md). - -ClickHouse получает от ODBC-драйвера информацию о квотировании и квотирует настройки в запросах к драйверу, поэтому имя таблицы нужно указывать в соответствии с регистром имени таблицы в базе данных. - -Если у вас есть проблемы с кодировками при использовании Oracle, ознакомьтесь с соответствующим разделом [FAQ](../../../faq/general.md#oracle-odbc-encodings). - -### Выявленная уязвимость в функционировании ODBC словарей {#vyiavlennaia-uiazvimost-v-funktsionirovanii-odbc-slovarei} - -!!! attention "Attention" - При соединении с базой данных через ODBC можно заменить параметр соединения `Servername`. В этом случае, значения `USERNAME` и `PASSWORD` из `odbc.ini` отправляются на удаленный сервер и могут быть скомпрометированы. - -**Пример небезопасного использования** - -Сконфигурируем unixODBC для работы с PostgreSQL. Содержимое `/etc/odbc.ini`: - -``` text -[gregtest] -Driver = /usr/lib/psqlodbca.so -Servername = localhost -PORT = 5432 -DATABASE = test_db -#OPTION = 3 -USERNAME = test -PASSWORD = test -``` - -Если выполнить запрос вида: - -``` sql -SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); -``` - -то ODBC драйвер отправит значения `USERNAME` и `PASSWORD` из `odbc.ini` на `some-server.com`. - -### Пример подключения PostgreSQL {#primer-podkliucheniia-postgresql} - -ОС Ubuntu. - -Установка unixODBC и ODBC-драйвера для PostgreSQL: : - -``` bash -$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql -``` - -Настройка `/etc/odbc.ini` (или `~/.odbc.ini`): - -``` text - [DEFAULT] - Driver = myconnection - - [myconnection] - Description = PostgreSQL connection to my_db - Driver = PostgreSQL Unicode - Database = my_db - Servername = 127.0.0.1 - UserName = username - Password = password - Port = 5432 - Protocol = 9.3 - ReadOnly = No - RowVersioning = No - ShowSystemTables = No - ConnSettings = -``` - -Конфигурация словаря в ClickHouse: - -``` xml - - - table_name - - - - - DSN=myconnection - postgresql_table
-
- - - 300 - 360 - - - - - - - id - - - some_column - UInt64 - 0 - - -
-
-``` - -или - -``` sql -CREATE DICTIONARY table_name ( - id UInt64, - some_column UInt64 DEFAULT 0 -) -PRIMARY KEY id -SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) -LAYOUT(HASHED()) -LIFETIME(MIN 300 MAX 360) - -Может понадобиться в `odbc.ini` указать полный путь до библиотеки с драйвером `DRIVER=/usr/local/lib/psqlodbcw.so`. - -### Пример подключения MS SQL Server - -ОС Ubuntu. - -Установка драйвера: : - -```bash -$ sudo apt-get install tdsodbc freetds-bin sqsh -``` - -Настройка драйвера: : - -``` bash - $ cat /etc/freetds/freetds.conf - ... - - [MSSQL] - host = 192.168.56.101 - port = 1433 - tds version = 7.0 - client charset = UTF-8 - - $ cat /etc/odbcinst.ini - ... - - [FreeTDS] - Description = FreeTDS - Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so - Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so - FileUsage = 1 - UsageCount = 5 - - $ cat ~/.odbc.ini - ... - - [MSSQL] - Description = FreeTDS - Driver = FreeTDS - Servername = MSSQL - Database = test - UID = test - PWD = test - Port = 1433 -``` - -Настройка словаря в ClickHouse: - -``` xml - - - test - - - dict
- DSN=MSSQL;UID=test;PWD=test -
- - - - 300 - 360 - - - - - - - - - k - - - s - String - - - -
-
-``` - -или - -``` sql -CREATE DICTIONARY test ( - k UInt64, - s String DEFAULT '' -) -PRIMARY KEY k -SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) -LAYOUT(FLAT()) -LIFETIME(MIN 300 MAX 360) -``` - -## СУБД {#subd} - -### MySQL {#dicts-external_dicts_dict_sources-mysql} - -Пример настройки: - -``` xml - - - 3306 - clickhouse - qwerty - - example01-1 - 1 - - - example01-2 - 1 - - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -или - -``` sql -SOURCE(MYSQL( - port 3306 - user 'clickhouse' - password 'qwerty' - replica(host 'example01-1' priority 1) - replica(host 'example01-2' priority 1) - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -Поля настройки: - -- `port` — порт сервера MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри ``). - -- `user` — имя пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри ``). - -- `password` — пароль пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри ``). - -- `replica` — блок конфигурации реплики. Блоков может быть несколько. - - - `replica/host` — хост MySQL. - - `replica/priority` — приоритет реплики. При попытке соединения ClickHouse обходит реплики в соответствии с приоритетом. Чем меньше цифра, тем выше приоритет. - -- `db` — имя базы данных. - -- `table` — имя таблицы. - -- `where` — условие выбора. Синтаксис условия совпадает с синтаксисом секции `WHERE` в MySQL, например, `id > 10 AND id < 20`. Необязательный параметр. - -- `invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external_dicts_dict_lifetime.md). - -MySQL можно подключить на локальном хосте через сокеты, для этого необходимо задать `host` и `socket`. - -Пример настройки: - -``` xml - - - localhost - /path/to/socket/file.sock - clickhouse - qwerty - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -или - -``` sql -SOURCE(MYSQL( - host 'localhost' - socket '/path/to/socket/file.sock' - user 'clickhouse' - password 'qwerty' - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -### ClickHouse {#dicts-external_dicts_dict_sources-clickhouse} - -Пример настройки: - -``` xml - - - example01-01-1 - 9000 - default - - default - ids
- id=10 -
- -``` - -или - -``` sql -SOURCE(CLICKHOUSE( - host 'example01-01-1' - port 9000 - user 'default' - password '' - db 'default' - table 'ids' - where 'id=10' -)) -``` - -Поля настройки: - -- `host` — хост ClickHouse. Если host локальный, то запрос выполняется без сетевого взаимодействия. Чтобы повысить отказоустойчивость решения, можно создать таблицу типа [Distributed](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md) и прописать её в дальнейших настройках. -- `port` — порт сервера ClickHouse. -- `user` — имя пользователя ClickHouse. -- `password` — пароль пользователя ClickHouse. -- `db` — имя базы данных. -- `table` — имя таблицы. -- `where` — условие выбора. Может отсутствовать. -- `invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external_dicts_dict_lifetime.md). - -### MongoDB {#dicts-external_dicts_dict_sources-mongodb} - -Пример настройки: - -``` xml - - - localhost - 27017 - - - test - dictionary_source - - -``` - -или - -``` sql -SOURCE(MONGO( - host 'localhost' - port 27017 - user '' - password '' - db 'test' - collection 'dictionary_source' -)) -``` - -Поля настройки: - -- `host` — хост MongoDB. -- `port` — порт сервера MongoDB. -- `user` — имя пользователя MongoDB. -- `password` — пароль пользователя MongoDB. -- `db` — имя базы данных. -- `collection` — имя коллекции. - -### Redis {#dicts-external_dicts_dict_sources-redis} - -Пример настройки: - -``` xml - - - localhost - 6379 - simple - 0 - - -``` - -или - -``` sql -SOURCE(REDIS( - host 'localhost' - port 6379 - storage_type 'simple' - db_index 0 -)) -``` - -Поля настройки: - -- `host` – хост Redis. -- `port` – порт сервера Redis. -- `storage_type` – способ хранения ключей. Необходимо использовать `simple` для источников с одним столбцом ключей, `hash_map` – для источников с двумя столбцами ключей. Источники с более, чем двумя столбцами ключей, не поддерживаются. Может отсутствовать, значение по умолчанию `simple`. -- `db_index` – номер базы данных. Может отсутствовать, значение по умолчанию 0. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md deleted file mode 100644 index f83b7657b54..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md +++ /dev/null @@ -1,167 +0,0 @@ -# Ключ и поля словаря {#kliuch-i-polia-slovaria} - -Секция `` описывает ключ словаря и поля, доступные для запросов. - -Описание в формате XML: - -``` xml - - - - Id - - - - - - - ... - - - -``` - -Атрибуты описываются элементами: - -- `` — [столбец с ключом](external_dicts_dict_structure.md#ext_dict_structure-key). -- `` — [столбец данных](external_dicts_dict_structure.md#ext_dict_structure-attributes). Можно задать несколько атрибутов. - -Создание словаря запросом: - -``` sql -CREATE DICTIONARY dict_name ( - Id UInt64, - -- attributes -) -PRIMARY KEY Id -... -``` - -Атрибуты задаются в теле запроса: - -- `PRIMARY KEY` — [столбец с ключом](external_dicts_dict_structure.md#ext_dict_structure-key) -- `AttrName AttrType` — [столбец данных](external_dicts_dict_structure.md#ext_dict_structure-attributes). Можно задать несколько столбцов. - -## Ключ {#ext_dict_structure-key} - -ClickHouse поддерживает следующие виды ключей: - -- Числовой ключ. `UInt64`. Описывается в теге `` или ключевым словом `PRIMARY KEY`. -- Составной ключ. Набор значений разного типа. Описывается в теге `` или ключевым словом `PRIMARY KEY`. - -Структура может содержать либо `` либо ``. DDL-запрос может содержать только `PRIMARY KEY`. - -!!! warning "Обратите внимание" - Ключ не надо дополнительно описывать в атрибутах. - -### Числовой ключ {#ext_dict-numeric-key} - -Тип: `UInt64`. - -Пример конфигурации: - -``` xml - - Id - -``` - -Поля конфигурации: - -- `name` — имя столбца с ключами. - -Для DDL-запроса: - -``` sql -CREATE DICTIONARY ( - Id UInt64, - ... -) -PRIMARY KEY Id -... -``` - -- `PRIMARY KEY` – имя столбца с ключами. - -### Составной ключ {#sostavnoi-kliuch} - -Ключом может быть кортеж (`tuple`) из полей произвольных типов. В этом случае [layout](external_dicts_dict_layout.md) должен быть `complex_key_hashed` или `complex_key_cache`. - -!!! tip "Совет" - Составной ключ может состоять из одного элемента. Это даёт возможность использовать в качестве ключа, например, строку. - -Структура ключа задаётся в элементе ``. Поля ключа задаются в том же формате, что и [атрибуты](external_dicts_dict_structure.md) словаря. Пример: - -``` xml - - - - field1 - String - - - field2 - UInt32 - - ... - -... -``` - -или - -``` sql -CREATE DICTIONARY ( - field1 String, - field2 String - ... -) -PRIMARY KEY field1, field2 -... -``` - -При запросе в функции `dictGet*` в качестве ключа передаётся кортеж. Пример: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. - -## Атрибуты {#ext_dict_structure-attributes} - -Пример конфигурации: - -``` xml - - ... - - Name - ClickHouseDataType - - rand64() - true - true - true - - -``` - -или - -``` sql -CREATE DICTIONARY somename ( - Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID -) -``` - -Поля конфигурации: - -| Тег | Описание | Обязательный | -|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| -| `name` | Имя столбца. | Да | -| `type` | Тип данных ClickHouse.
ClickHouse пытается привести значение из словаря к заданному типу данных. Например, в случае MySQL, в таблице-источнике поле может быть `TEXT`, `VARCHAR`, `BLOB`, но загружено может быть как `String`. [Nullable](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md) не поддерживается. | Да | -| `null_value` | Значение по умолчанию для несуществующего элемента.
В примере это пустая строка. Нельзя указать значение `NULL`. | Да | -| `expression` | [Выражение](../../syntax.md#syntax-expressions), которое ClickHouse выполняет со значением.
Выражением может быть имя столбца в удаленной SQL базе. Таким образом, вы можете использовать его для создания псевдонима удаленного столбца.

Значение по умолчанию: нет выражения. | Нет | -| `hierarchical` | Если `true`, то атрибут содержит ключ предка для текущего элемента. Смотрите [Иерархические словари](external_dicts_dict_hierarchical.md).

Default value: `false`. | No | -| `is_object_id` | Признак того, что запрос выполняется к документу MongoDB по `ObjectID`.

Значение по умолчанию: `false`. | Нет | - -## Смотрите также {#smotrite-takzhe} - -- [Функции для работы с внешними словарями](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/ru/sql_reference/dictionaries/external_dictionaries/index.md b/docs/ru/sql_reference/dictionaries/external_dictionaries/index.md deleted file mode 100644 index 9af8b4f2f12..00000000000 --- a/docs/ru/sql_reference/dictionaries/external_dictionaries/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: External Dictionaries -toc_priority: 37 ---- - diff --git a/docs/ru/sql_reference/dictionaries/index.md b/docs/ru/sql_reference/dictionaries/index.md deleted file mode 100644 index e876b92c9bf..00000000000 --- a/docs/ru/sql_reference/dictionaries/index.md +++ /dev/null @@ -1,14 +0,0 @@ -# Словари {#slovari} - -Словарь — это отображение (`ключ -> атрибуты`), которое удобно использовать для различного вида справочников. - -ClickHouse поддерживает специальные функции для работы со словарями, которые можно использовать в запросах. Проще и эффективнее использовать словари с помощью функций, чем `JOIN` с таблицами-справочниками. - -В словаре нельзя хранить значения [NULL](../syntax.md#null). - -ClickHouse поддерживает: - -- [Встроенные словари](internal_dicts.md#internal_dicts) со специфическим [набором функций](../../sql_reference/dictionaries/external_dictionaries/index.md). -- [Подключаемые (внешние) словари](external_dictionaries/external_dicts.md) с [набором функций](../../sql_reference/dictionaries/external_dictionaries/index.md). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/) diff --git a/docs/ru/sql_reference/dictionaries/internal_dicts.md b/docs/ru/sql_reference/dictionaries/internal_dicts.md deleted file mode 100644 index 2b93c4e3b7f..00000000000 --- a/docs/ru/sql_reference/dictionaries/internal_dicts.md +++ /dev/null @@ -1,48 +0,0 @@ -# Встроенные словари {#internal_dicts} - -ClickHouse содержит встроенную возможность работы с геобазой. - -Это позволяет: - -- для идентификатора региона получить его имя на нужном языке; -- по идентификатору региона получить идентификатор города, области, федерального округа, страны, континента; -- проверить, что один регион входит в другой; -- получить цепочку родительских регионов. - -Все функции поддерживают «транслокальность», то есть возможность использовать одновременно разные точки зрения на принадлежность регионов. Подробнее смотрите в разделе «Функции для работы со словарями Яндекс.Метрики». - -В пакете по умолчанию, встроенные словари выключены. -Для включения, раскомментируйте параметры `path_to_regions_hierarchy_file` и `path_to_regions_names_files` в конфигурационном файле сервера. - -Геобаза загружается из текстовых файлов. - -Положите файлы `regions_hierarchy*.txt` в директорию `path_to_regions_hierarchy_file`. Этот конфигурационный параметр должен содержать путь к файлу `regions_hierarchy.txt` (иерархия регионов по умолчанию), а другие файлы (`regions_hierarchy_ua.txt`) должны находиться рядом в той же директории. - -Положите файлы `regions_names_*.txt` в директорию `path_to_regions_names_files`. - -Также вы можете создать эти файлы самостоятельно. Формат файлов такой: - -`regions_hierarchy*.txt`: TabSeparated (без заголовка), столбцы: - -- идентификатор региона (`UInt32`); -- идентификатор родительского региона (`UInt32`); -- тип региона (`UInt8`): 1 - континент, 3 - страна, 4 - федеральный округ, 5 - область, 6 - город; остальные типы не имеют значения; -- население (`UInt32`) - не обязательный столбец. - -`regions_names_*.txt`: TabSeparated (без заголовка), столбцы: - -- идентификатор региона (`UInt32`); -- имя региона (`String`) - не может содержать табы или переводы строк, даже экранированные. - -Для хранения в оперативке используется плоский массив. Поэтому, идентификаторы не должны быть больше миллиона. - -Словари могут обновляться без перезапуска сервера. Но набор доступных словарей не обновляется. -Для обновления проверяется время модификации файлов; если файл изменился, то словарь будет обновлён. -Периодичность проверки настраивается конфигурационным параметром `builtin_dictionaries_reload_interval`. -Обновление словарей (кроме загрузки при первом использовании) не блокирует запросы - во время обновления запросы используют старую версию словарей. Если при обновлении возникнет ошибка, то ошибка пишется в лог сервера, а запросы продолжат использовать старую версию словарей. - -Рекомендуется периодически обновлять словари с геобазой. При обновлении, генерируйте новые файлы, записывая их в отдельное место, а только когда всё готово - переименовывайте в файлы, которые использует сервер. - -Также имеются функции для работы с идентификаторами операционных систем и поисковых систем Яндекс.Метрики, пользоваться которыми не нужно. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/dicts/internal_dicts/) diff --git a/docs/ru/sql_reference/functions/arithmetic_functions.md b/docs/ru/sql_reference/functions/arithmetic_functions.md deleted file mode 100644 index 85c597143fd..00000000000 --- a/docs/ru/sql_reference/functions/arithmetic_functions.md +++ /dev/null @@ -1,77 +0,0 @@ -# Арифметические функции {#arifmeticheskie-funktsii} - -Для всех арифметических функций, тип результата вычисляется, как минимальный числовой тип, который может вместить результат, если такой тип есть. Минимум берётся одновременно по числу бит, знаковости и «плавучести». Если бит не хватает, то берётся тип максимальной битности. - -Пример: - -``` sql -SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) -``` - -``` text -┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ -│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ -└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ -``` - -Арифметические функции работают для любой пары типов из UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, Float64. - -Переполнение производится также, как в C++. - -## plus(a, b), оператор a + b {#plusa-b-operator-a-b} - -Вычисляет сумму чисел. -Также можно складывать целые числа с датой и датой-с-временем. В случае даты, прибавление целого числа означает прибавление соответствующего количества дней. В случае даты-с-временем - прибавление соответствующего количества секунд. - -## minus(a, b), оператор a - b {#minusa-b-operator-a-b} - -Вычисляет разность чисел. Результат всегда имеет знаковый тип. - -Также можно вычитать целые числа из даты и даты-с-временем. Смысл аналогичен - смотрите выше для plus. - -## multiply(a, b), оператор a \* b {#multiplya-b-operator-a-b} - -Вычисляет произведение чисел. - -## divide(a, b), оператор a / b {#dividea-b-operator-a-b} - -Вычисляет частное чисел. Тип результата всегда является типом с плавающей запятой. -То есть, деление не целочисленное. Для целочисленного деления, используйте функцию intDiv. -При делении на ноль получится inf, -inf или nan. - -## intDiv(a, b) {#intdiva-b} - -Вычисляет частное чисел. Деление целочисленное, с округлением вниз (по абсолютному значению). -При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. - -## intDivOrZero(a, b) {#intdivorzeroa-b} - -Отличается от intDiv тем, что при делении на ноль или при делении минимального отрицательного числа на минус единицу, возвращается ноль. - -## modulo(a, b), оператор a % b {#moduloa-b-operator-a-b} - -Вычисляет остаток от деления. -Если аргументы - числа с плавающей запятой, то они предварительно преобразуются в целые числа, путём отбрасывания дробной части. -Берётся остаток в том же смысле, как это делается в C++. По факту, для отрицательных чисел, используется truncated division. -При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. - -## negate(a), оператор -a {#negatea-operator-a} - -Вычисляет число, обратное по знаку. Результат всегда имеет знаковый тип. - -## abs(a) {#arithm_func-abs} - -Вычисляет абсолютное значение для числа a. То есть, если a \< 0, то возвращает -a. -Для беззнаковых типов ничего не делает. Для чисел типа целых со знаком, возвращает число беззнакового типа. - -## gcd(a, b) {#gcda-b} - -Вычисляет наибольший общий делитель чисел. -При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. - -## lcm(a, b) {#lcma-b} - -Вычисляет наименьшее общее кратное чисел. -При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/arithmetic_functions/) diff --git a/docs/ru/sql_reference/functions/array_functions.md b/docs/ru/sql_reference/functions/array_functions.md deleted file mode 100644 index 82a6ceea001..00000000000 --- a/docs/ru/sql_reference/functions/array_functions.md +++ /dev/null @@ -1,972 +0,0 @@ -# Функции по работе с массивами {#funktsii-po-rabote-s-massivami} - -## empty {#function-empty} - -Возвращает 1 для пустого массива, и 0 для непустого массива. -Тип результата - UInt8. -Функция также работает для строк. - -## notEmpty {#function-notempty} - -Возвращает 0 для пустого массива, и 1 для непустого массива. -Тип результата - UInt8. -Функция также работает для строк. - -## length {#array_functions-length} - -Возвращает количество элементов в массиве. -Тип результата - UInt64. -Функция также работает для строк. - -## emptyArrayUInt8, emptyArrayUInt16, emptyArrayUInt32, emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} - -## emptyArrayInt8, emptyArrayInt16, emptyArrayInt32, emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} - -## emptyArrayFloat32, emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} - -## emptyArrayDate, emptyArrayDateTime {#emptyarraydate-emptyarraydatetime} - -## emptyArrayString {#emptyarraystring} - -Принимает ноль аргументов и возвращает пустой массив соответствующего типа. - -## emptyArrayToSingle {#emptyarraytosingle} - -Принимает пустой массив и возвращает массив из одного элемента, равного значению по умолчанию. - -## range(N) {#rangen} - -Возвращает массив чисел от 0 до N-1. -На всякий случай, если на блок данных, создаются массивы суммарной длины больше 100 000 000 элементов, то кидается исключение. - -## array(x1, …), оператор \[x1, …\] {#arrayx1-operator-x1} - -Создаёт массив из аргументов функции. -Аргументы должны быть константами и иметь типы, для которых есть наименьший общий тип. Должен быть передан хотя бы один аргумент, так как иначе непонятно, какого типа создавать массив. То есть, с помощью этой функции невозможно создать пустой массив (для этого используйте функции emptyArray\*, описанные выше). -Возвращает результат типа Array(T), где T - наименьший общий тип от переданных аргументов. - -## arrayConcat {#arrayconcat} - -Объединяет массивы, переданные в качестве аргументов. - -``` sql -arrayConcat(arrays) -``` - -**Параметры** - -- `arrays` – произвольное количество элементов типа [Array](../../sql_reference/functions/array_functions.md) - **Пример** - - - -``` sql -SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,3,4,5,6] │ -└───────────────┘ -``` - -## arrayElement(arr, n), operator arr\[n\] {#arrayelementarr-n-operator-arrn} - -Достаёт элемент с индексом n из массива arr. n должен быть любым целочисленным типом. -Индексы в массиве начинаются с единицы. -Поддерживаются отрицательные индексы. В этом случае, будет выбран соответствующий по номеру элемент с конца. Например, arr\[-1\] - последний элемент массива. - -Если индекс выходит за границы массива, то возвращается некоторое значение по умолчанию (0 для чисел, пустая строка для строк и т. п.), кроме случая с неконстантным массивом и константным индексом 0 (в этом случае будет ошибка `Array indices are 1-based`). - -## has(arr, elem) {#hasarr-elem} - -Проверяет наличие элемента elem в массиве arr. -Возвращает 0, если элемента в массиве нет, или 1, если есть. - -`NULL` обрабатывается как значение. - -``` sql -SELECT has([1, 2, NULL], NULL) -``` - -``` text -┌─has([1, 2, NULL], NULL)─┐ -│ 1 │ -└─────────────────────────┘ -``` - -## hasAll {#hasall} - -Проверяет, является ли один массив подмножеством другого. - -``` sql -hasAll(set, subset) -``` - -**Параметры** - -- `set` – массив любого типа с набором элементов. -- `subset` – массив любого типа со значениями, которые проверяются на вхождение в `set`. - -**Возвращаемые значения** - -- `1`, если `set` содержит все элементы из `subset`. -- `0`, в противном случае. - -**Особенности** - -- Пустой массив является подмножеством любого массива. -- `NULL` обрабатывается как значение. -- Порядок значений в обоих массивах не имеет значения. - -**Примеры** - -`SELECT hasAll([], [])` возвращает 1. - -`SELECT hasAll([1, Null], [Null])` возвращает 1. - -`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` возвращает 1. - -`SELECT hasAll(['a', 'b'], ['a'])` возвращает 1. - -`SELECT hasAll([1], ['a'])` возвращает 0. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` возвращает 0. - -## hasAny {#hasany} - -Проверяет, имеют ли два массива хотя бы один общий элемент. - -``` sql -hasAny(array1, array2) -``` - -**Параметры** - -- `array1` – массив любого типа с набором элементов. -- `array2` – массив любого типа с набором элементов. - -**Возвращаемые значения** - -- `1`, если `array1` и `array2` имеют хотя бы один одинаковый элемент. -- `0`, в противном случае. - -**Особенности** - -- `NULL` обрабатывается как значение. -- Порядок значений в обоих массивах не имеет значения. - -**Примеры** - -`SELECT hasAny([1], [])` возвращает `0`. - -`SELECT hasAny([Null], [Null, 1])` возвращает `1`. - -`SELECT hasAny([-128, 1., 512], [1])` возвращает `1`. - -`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` возвращает `0`. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` возвращает `1`. - -## indexOf(arr, x) {#indexofarr-x} - -Возвращает индекс первого элемента x (начиная с 1), если он есть в массиве, или 0, если его нет. - -Пример: - -``` sql -SELECT indexOf([1, 3, NULL, NULL], NULL) -``` - -``` text -┌─indexOf([1, 3, NULL, NULL], NULL)─┐ -│ 3 │ -└───────────────────────────────────┘ -``` - -Элементы, равные `NULL`, обрабатываются как обычные значения. - -## countEqual(arr, x) {#countequalarr-x} - -Возвращает количество элементов массива, равных x. Эквивалентно arrayCount(elem -\> elem = x, arr). - -`NULL` обрабатывается как значение. - -Пример: - -``` sql -SELECT countEqual([1, 2, NULL, NULL], NULL) -``` - -``` text -┌─countEqual([1, 2, NULL, NULL], NULL)─┐ -│ 2 │ -└──────────────────────────────────────┘ -``` - -## arrayEnumerate(arr) {#array_functions-arrayenumerate} - -Возвращает массив \[1, 2, 3, …, length(arr)\] - -Эта функция обычно используется совместно с ARRAY JOIN. Она позволяет, после применения ARRAY JOIN, посчитать что-либо только один раз для каждого массива. Пример: - -``` sql -SELECT - count() AS Reaches, - countIf(num = 1) AS Hits -FROM test.hits -ARRAY JOIN - GoalsReached, - arrayEnumerate(GoalsReached) AS num -WHERE CounterID = 160656 -LIMIT 10 -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -В этом примере, Reaches - число достижений целей (строк, получившихся после применения ARRAY JOIN), а Hits - число хитов (строк, которые были до ARRAY JOIN). В данном случае, тот же результат можно получить проще: - -``` sql -SELECT - sum(length(GoalsReached)) AS Reaches, - count() AS Hits -FROM test.hits -WHERE (CounterID = 160656) AND notEmpty(GoalsReached) -``` - -``` text -┌─Reaches─┬──Hits─┐ -│ 95606 │ 31406 │ -└─────────┴───────┘ -``` - -Также эта функция может быть использована в функциях высшего порядка. Например, с её помощью можно достать индексы массива для элементов, удовлетворяющих некоторому условию. - -## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} - -Возвращает массив, такого же размера, как исходный, где для каждого элемента указано, какой он по счету среди элементов с таким же значением. -Например: arrayEnumerateUniq(\[10, 20, 10, 30\]) = \[1, 1, 2, 1\]. - -Эта функция полезна при использовании ARRAY JOIN и агрегации по элементам массива. -Пример: - -``` sql -SELECT - Goals.ID AS GoalID, - sum(Sign) AS Reaches, - sumIf(Sign, num = 1) AS Visits -FROM test.visits -ARRAY JOIN - Goals, - arrayEnumerateUniq(Goals.ID) AS num -WHERE CounterID = 160656 -GROUP BY GoalID -ORDER BY Reaches DESC -LIMIT 10 -``` - -``` text -┌──GoalID─┬─Reaches─┬─Visits─┐ -│ 53225 │ 3214 │ 1097 │ -│ 2825062 │ 3188 │ 1097 │ -│ 56600 │ 2803 │ 488 │ -│ 1989037 │ 2401 │ 365 │ -│ 2830064 │ 2396 │ 910 │ -│ 1113562 │ 2372 │ 373 │ -│ 3270895 │ 2262 │ 812 │ -│ 1084657 │ 2262 │ 345 │ -│ 56599 │ 2260 │ 799 │ -│ 3271094 │ 2256 │ 812 │ -└─────────┴─────────┴────────┘ -``` - -В этом примере, для каждого идентификатора цели, посчитано количество достижений целей (каждый элемент вложенной структуры данных Goals является достижением целей) и количество визитов. Если бы не было ARRAY JOIN, мы бы считали количество визитов как sum(Sign). Но в данном случае, строчки были размножены по вложенной структуре Goals, и чтобы после этого учесть каждый визит один раз, мы поставили условие на значение функции arrayEnumerateUniq(Goals.ID). - -Функция arrayEnumerateUniq может принимать несколько аргументов - массивов одинаковых размеров. В этом случае, уникальность считается для кортежей элементов на одинаковых позициях всех массивов. - -``` sql -SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res -``` - -``` text -┌─res───────────┐ -│ [1,2,1,1,2,1] │ -└───────────────┘ -``` - -Это нужно при использовании ARRAY JOIN с вложенной структурой данных и затем агрегации по нескольким элементам этой структуры. - -## arrayPopBack {#arraypopback} - -Удаляет последний элемент из массива. - -``` sql -arrayPopBack(array) -``` - -**Параметры** - -- `array` - Массив. - -**Пример** - -``` sql -SELECT arrayPopBack([1, 2, 3]) AS res -``` - -text - - ┌─res───┐ - │ [1,2] │ - └───────┘ - -## arrayPopFront {#arraypopfront} - -Удаляет первый элемент из массива. - -``` sql -arrayPopFront(array) -``` - -**Параметры** - -- `array` - Массив. - -**Пример** - -``` sql -SELECT arrayPopFront([1, 2, 3]) AS res -``` - -``` text -┌─res───┐ -│ [2,3] │ -└───────┘ -``` - -## arrayPushBack {#arraypushback} - -Добавляет один элемент в конец массива. - -``` sql -arrayPushBack(array, single_value) -``` - -**Параметры** - -- `array` - Массив. -- `single_value` - Одиночное значение. В массив с числам можно добавить только числа, в массив со строками только строки. При добавлении чисел ClickHouse автоматически приводит тип `single_value` к типу данных массива. Подробнее о типах данных в ClickHouse читайте в разделе «[Типы данных](../../sql_reference/functions/array_functions.md#data_types)». Может быть равно `NULL`. Функция добавит элемент `NULL` в массив, а тип элементов массива преобразует в `Nullable`. - -**Пример** - -``` sql -SELECT arrayPushBack(['a'], 'b') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## arrayPushFront {#arraypushfront} - -Добавляет один элемент в начало массива. - -``` sql -arrayPushFront(array, single_value) -``` - -**Параметры** - -- `array` - Массив. -- `single_value` - Одиночное значение. В массив с числам можно добавить только числа, в массив со строками только строки. При добавлении чисел ClickHouse автоматически приводит тип `single_value` к типу данных массива. Подробнее о типах данных в ClickHouse читайте в разделе «[Типы данных](../../sql_reference/functions/array_functions.md#data_types)». Может быть равно `NULL`. Функция добавит элемент `NULL` в массив, а тип элементов массива преобразует в `Nullable`. - -**Пример** - -``` sql -SELECT arrayPushFront(['b'], 'a') AS res -``` - -``` text -┌─res───────┐ -│ ['a','b'] │ -└───────────┘ -``` - -## arrayResize {#arrayresize} - -Изменяет длину массива. - -``` sql -arrayResize(array, size[, extender]) -``` - -**Параметры** - -- `array` — массив. -- `size` — необходимая длина массива. - - Если `size` меньше изначального размера массива, то массив обрезается справа. - - Если `size` больше изначального размера массива, массив дополняется справа значениями `extender` или значениями по умолчанию для типа данных элементов массива. -- `extender` — значение для дополнения массива. Может быть `NULL`. - -**Возвращаемое значение:** - -Массив длины `size`. - -**Примеры вызовов** - -``` sql -SELECT arrayResize([1], 3) -``` - -``` text -┌─arrayResize([1], 3)─┐ -│ [1,0,0] │ -└─────────────────────┘ -``` - -``` sql -SELECT arrayResize([1], 3, NULL) -``` - -``` text -┌─arrayResize([1], 3, NULL)─┐ -│ [1,NULL,NULL] │ -└───────────────────────────┘ -``` - -## arraySlice {#arrayslice} - -Возвращает срез массива. - -``` sql -arraySlice(array, offset[, length]) -``` - -**Параметры** - -- `array` - Массив данных. -- `offset` - Отступ от края массива. Положительное значение - отступ слева, отрицательное значение - отступ справа. Отсчет элементов массива начинается с 1. -- `length` - Длина необходимого среза. Если указать отрицательное значение, то функция вернёт открытый срез `[offset, array_length - length)`. Если не указать значение, то функция вернёт срез `[offset, the_end_of_array]`. - -**Пример** - -``` sql -SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res -``` - -``` text -┌─res────────┐ -│ [2,NULL,4] │ -└────────────┘ -``` - -Элементы массива равные `NULL` обрабатываются как обычные значения. - -## arraySort(\[func,\] arr, …) {#array_functions-sort} - -Возвращает массив `arr`, отсортированный в восходящем порядке. Если задана функция `func`, то порядок сортировки определяется результатом применения этой функции на элементы массива `arr`. Если `func` принимает несколько аргументов, то в функцию `arraySort` нужно передавать несколько массивов, которые будут соответствовать аргументам функции `func`. Подробные примеры рассмотрены в конце описания `arraySort`. - -Пример сортировки целочисленных значений: - -``` sql -SELECT arraySort([1, 3, 3, 0]) -``` - -``` text -┌─arraySort([1, 3, 3, 0])─┐ -│ [0,1,3,3] │ -└─────────────────────────┘ -``` - -Пример сортировки строковых значений: - -``` sql -SELECT arraySort(['hello', 'world', '!']) -``` - -``` text -┌─arraySort(['hello', 'world', '!'])─┐ -│ ['!','hello','world'] │ -└────────────────────────────────────┘ -``` - -Значения `NULL`, `NaN` и `Inf` сортируются по следующему принципу: - -``` sql -SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); -``` - -``` text -┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ -│ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────────────────────────┘ -``` - -- Значения `-Inf` идут в начале массива. -- Значения `NULL` идут в конце массива. -- Значения `NaN` идут перед `NULL`. -- Значения `Inf` идут перед `NaN`. - -Функция `arraySort` является [функцией высшего порядка](higher_order_functions.md) — в качестве первого аргумента ей можно передать лямбда-функцию. В этом случае порядок сортировки определяется результатом применения лямбда-функции на элементы массива. - -Рассмотрим пример: - -``` sql -SELECT arraySort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,2,1] │ -└─────────┘ -``` - -Для каждого элемента исходного массива лямбда-функция возвращает ключ сортировки, то есть \[1 –\> -1, 2 –\> -2, 3 –\> -3\]. Так как `arraySort` сортирует элементы в порядке возрастания ключей, результат будет \[3, 2, 1\]. Как можно заметить, функция `x –> -x` устанавливает [обратный порядок сортировки](#array_functions-reverse-sort). - -Лямбда-функция может принимать несколько аргументов. В этом случае, в функцию `arraySort` нужно передавать несколько массивов, которые будут соответствовать аргументам лямбда-функции (массивы должны быть одинаковой длины). Следует иметь в виду, что результат будет содержать элементы только из первого массива; элементы из всех последующих массивов будут задавать ключи сортировки. Например: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -Элементы, указанные во втором массиве (\[2,1\]), определяют ключ сортировки для элементов из исходного массива (\[‘hello’, ‘world’\]), то есть \[‘hello’ –\> 2, ‘world’ –\> 1\]. Так как лямбда-функция не использует `x`, элементы исходного массива не влияют на порядок сортировки. Таким образом, ‘hello’ будет вторым элементом в отсортированном массиве, а ‘world’ — первым. - -Ниже приведены другие примеры. - -``` sql -SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -``` sql -SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -!!! note "Примечание" - Для улучшения эффективности сортировки применяется [преобразование Шварца](https://ru.wikipedia.org/wiki/%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5_%D0%A8%D0%B2%D0%B0%D1%80%D1%86%D0%B0). - -## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} - -Возвращает массив `arr`, отсортированный в нисходящем порядке. Если указана функция `func`, то массив `arr` сначала сортируется в порядке, который определяется функцией `func`, а затем отсортированный массив переворачивается. Если функция `func` принимает несколько аргументов, то в функцию `arrayReverseSort` необходимо передавать несколько массивов, которые будут соответствовать аргументам функции `func`. Подробные примеры рассмотрены в конце описания функции `arrayReverseSort`. - -Пример сортировки целочисленных значений: - -``` sql -SELECT arrayReverseSort([1, 3, 3, 0]); -``` - -``` text -┌─arrayReverseSort([1, 3, 3, 0])─┐ -│ [3,3,1,0] │ -└────────────────────────────────┘ -``` - -Пример сортировки строковых значений: - -``` sql -SELECT arrayReverseSort(['hello', 'world', '!']); -``` - -``` text -┌─arrayReverseSort(['hello', 'world', '!'])─┐ -│ ['world','hello','!'] │ -└───────────────────────────────────────────┘ -``` - -Значения `NULL`, `NaN` и `Inf` сортируются в следующем порядке: - -``` sql -SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; -``` - -``` text -┌─res───────────────────────────────────┐ -│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────┘ -``` - -- Значения `Inf` идут в начале массива. -- Значения `NULL` идут в конце массива. -- Значения `NaN` идут перед `NULL`. -- Значения `-Inf` идут перед `NaN`. - -Функция `arrayReverseSort` является [функцией высшего порядка](higher_order_functions.md). Вы можете передать ей в качестве первого аргумента лямбда-функцию. Например: - -``` sql -SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [1,2,3] │ -└─────────┘ -``` - -В этом примере, порядок сортировки устанавливается следующим образом: - -1. Сначала исходный массив (\[1, 2, 3\]) сортируется в том порядке, который определяется лямбда-функцией. Результатом будет массив \[3, 2, 1\]. -2. Массив, который был получен на предыдущем шаге, переворачивается. То есть, получается массив \[1, 2, 3\]. - -Лямбда-функция может принимать на вход несколько аргументов. В этом случае, в функцию `arrayReverseSort` нужно передавать несколько массивов, которые будут соответствовать аргументам лямбда-функции (массивы должны быть одинаковой длины). Следует иметь в виду, что результат будет содержать элементы только из первого массива; элементы из всех последующих массивов будут определять ключи сортировки. Например: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -В этом примере, массив сортируется следующим образом: - -1. Сначала массив сортируется в том порядке, который определяется лямбда-функцией. Элементы, указанные во втором массиве (\[2,1\]), определяют ключи сортировки соответствующих элементов из исходного массива (\[‘hello’, ‘world’\]). То есть, будет массив \[‘world’, ‘hello’\]. -2. Массив, который был отсортирован на предыдущем шаге, переворачивается. Получается массив \[‘hello’, ‘world’\]. - -Ниже приведены ещё примеры. - -``` sql -SELECT arrayReverseSort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; -``` - -``` text -┌─res─────┐ -│ [0,1,2] │ -└─────────┘ -``` - -``` sql -SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; -``` - -``` text -┌─res─────┐ -│ [4,3,5] │ -└─────────┘ -``` - -## arrayUniq(arr, …) {#array-functions-arrayuniq} - -Если передан один аргумент, считает количество разных элементов в массиве. -Если передано несколько аргументов, считает количество разных кортежей из элементов на соответствующих позициях в нескольких массивах. - -Если необходимо получить список уникальных элементов массива, можно воспользоваться arrayReduce(‘groupUniqArray’, arr). - -## arrayJoin(arr) {#array-functions-arrayjoin} - -Особенная функция. Смотрите раздел [«Функция arrayJoin»](array_join.md#functions_arrayjoin). - -## arrayDifference {#arraydifference} - -Вычисляет разность между соседними элементами массива. Возвращает массив, где первым элементом будет 0, вторым – разность `a[1] - a[0]` и т. д. Тип элементов результирующего массива определяется правилами вывода типов при вычитании (напр. `UInt8` - `UInt8` = `Int16`). - -**Синтаксис** - -``` sql -arrayDifference(array) -``` - -**Параметры** - -- `array` – [Массив](https://clickhouse.yandex/docs/ru/data_types/array/). - -**Возвращаемое значение** - -Возвращает массив разностей между соседними элементами. - -**Пример** - -Запрос: - -``` sql -SELECT arrayDifference([1, 2, 3, 4]) -``` - -Ответ: - -``` text -┌─arrayDifference([1, 2, 3, 4])─┐ -│ [0,1,1,1] │ -└───────────────────────────────┘ -``` - -Пример переполнения из-за результирующего типа `Int64`: - -Запрос: - -``` sql -SELECT arrayDifference([0, 10000000000000000000]) -``` - -Ответ: - -``` text -┌─arrayDifference([0, 10000000000000000000])─┐ -│ [0,-8446744073709551616] │ -└────────────────────────────────────────────┘ -``` - -## arrayDistinct {#arraydistinct} - -Принимает массив, возвращает массив, содержащий уникальные элементы. - -**Синтаксис** - -``` sql -arrayDistinct(array) -``` - -**Параметры** - -- `array` – [Массив](https://clickhouse.yandex/docs/ru/data_types/array/). - -**Возвращаемое значение** - -Возвращает массив, содержащий только уникальные элементы исходного массива. - -**Пример** - -Запрос: - -``` sql -SELECT arrayDistinct([1, 2, 2, 3, 1]) -``` - -Ответ: - -``` text -┌─arrayDistinct([1, 2, 2, 3, 1])─┐ -│ [1,2,3] │ -└────────────────────────────────┘ -``` - -## arrayEnumerateDense(arr) {#array_functions-arrayenumeratedense} - -Возвращает массив того же размера, что и исходный массив, с индексами исходного массива, указывающими, где каждый элемент впервые появляется в исходном массиве. - -Пример: - -``` sql -SELECT arrayEnumerateDense([10, 20, 10, 30]) -``` - -``` text -┌─arrayEnumerateDense([10, 20, 10, 30])─┐ -│ [1,2,1,3] │ -└───────────────────────────────────────┘ -``` - -## arrayIntersect(arr) {#array-functions-arrayintersect} - -Принимает несколько массивов, возвращает массив с элементами, присутствующими во всех исходных массивах. Элементы на выходе следуют в порядке следования в первом массиве. - -Пример: - -``` sql -SELECT - arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, - arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect -``` - -``` text -┌─no_intersect─┬─intersect─┐ -│ [] │ [1] │ -└──────────────┴───────────┘ -``` - -## arrayReduce(agg\_func, arr1, …) {#array-functions-arrayreduce} - -Применяет агрегатную функцию к элементам массива и возвращает ее результат. Имя агрегирующей функции передается как строка в одинарных кавычках `'max'`, `'sum'`. При использовании параметрических агрегатных функций, параметр указывается после имени функции в круглых скобках `'uniqUpTo(6)'`. - -Пример: - -``` sql -SELECT arrayReduce('max', [1, 2, 3]) -``` - -``` text -┌─arrayReduce('max', [1, 2, 3])─┐ -│ 3 │ -└───────────────────────────────┘ -``` - -Если агрегатная функция имеет несколько аргументов, то эту функцию можно применять к нескольким массивам одинакового размера. - -Пример: - -``` sql -SELECT arrayReduce('maxIf', [3, 5], [1, 0]) -``` - -``` text -┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ -│ 3 │ -└──────────────────────────────────────┘ -``` - -Пример с параметрической агрегатной функцией: - -``` sql -SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -``` - -``` text -┌─arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])─┐ -│ 4 │ -└─────────────────────────────────────────────────────────────┘ -``` - -## arrayReverse(arr) {#array_functions-arrayreverse} - -Возвращает массив того же размера, что и исходный массив, содержащий элементы в обратном порядке. - -Пример: - -``` sql -SELECT arrayReverse([1, 2, 3]) -``` - -``` text -┌─arrayReverse([1, 2, 3])─┐ -│ [3,2,1] │ -└─────────────────────────┘ -``` - -## reverse(arr) {#array-functions-reverse} - -Синоним для [«arrayReverse»](#array_functions-arrayreverse) - -## arrayFlatten {#arrayflatten} - -Преобразует массив массивов в плоский массив. - -Функция: - -- Оперирует с массивами любой вложенности. -- Не изменяет массив, если он уже плоский. - -Результирующий массив содержит все элементы исходных массивов. - -**Синтаксис** - -``` sql -flatten(array_of_arrays) -``` - -Синоним: `flatten`. - -**Параметры** - -- `array_of_arrays` — [Массивов](../../sql_reference/functions/array_functions.md) массивов. Например, `[[1,2,3], [4,5]]`. - -**Примеры** - -``` sql -SELECT flatten([[[1]], [[2], [3]]]) -``` - -``` text -┌─flatten(array(array([1]), array([2], [3])))─┐ -│ [1,2,3] │ -└─────────────────────────────────────────────┘ -``` - -## arrayCompact {#arraycompact} - -Удаляет дубликаты из массива. Порядок результирующих значений определяется порядком в исходном массиве. - -**Синтаксис** - -``` sql -arrayCompact(arr) -``` - -**Параметры** - -`arr` — [Массив](../../sql_reference/functions/array_functions.md) для обхода. - -**Возвращаемое значение** - -Массив без дубликатов. - -Тип: `Array`. - -**Пример** - -Запрос: - -``` sql -SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]) -``` - -Ответ: - -``` text -┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐ -│ [1,nan,nan,2,3] │ -└────────────────────────────────────────────┘ -``` - -## arrayZip {#arrayzip} - -Объединяет несколько массивов в один. Результирующий массив содержит соответственные элементы исходных массивов, сгруппированные в кортежи в указанном порядке аргументов. - -**Синтаксис** - -``` sql -arrayZip(arr1, arr2, ..., arrN) -``` - -**Параметры** - -- `arrN` — [Массив](../data_types/array.md). - -Функция принимает любое количество массивов, которые могут быть различных типов. Все массивы должны иметь одинаковую длину. - -**Возвращаемое значение** - -- Массив с элементами исходных массивов, сгруппированными в [кортежи](../data_types/tuple.md). Типы данных в кортежах соответствуют типам данных входных массивов и следуют в том же порядке, в котором переданы массивы. - -Тип: [Массив](../data_types/array.md). - -**Пример** - -Запрос: - -``` sql -SELECT arrayZip(['a', 'b', 'c'], [5, 2, 1]) -``` - -Ответ: - -``` text -┌─arrayZip(['a', 'b', 'c'], [5, 2, 1])─┐ -│ [('a',5),('b',2),('c',1)] │ -└──────────────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/array_functions/) diff --git a/docs/ru/sql_reference/functions/array_join.md b/docs/ru/sql_reference/functions/array_join.md deleted file mode 100644 index 4298eea89e6..00000000000 --- a/docs/ru/sql_reference/functions/array_join.md +++ /dev/null @@ -1,30 +0,0 @@ -# Функция arrayJoin {#functions_arrayjoin} - -Это совсем необычная функция. - -Обычные функции не изменяют множество строк, а лишь изменяют значения в каждой строке (map). -Агрегатные функции выполняют свёртку множества строк (fold, reduce). -Функция arrayJoin выполняет размножение каждой строки в множество строк (unfold). - -Функция принимает в качестве аргумента массив, и размножает исходную строку в несколько строк - по числу элементов массива. -Все значения в столбцах просто копируются, кроме значения в столбце с применением этой функции - он заменяется на соответствующее значение массива. - -В запросе может быть использовано несколько функций `arrayJoin`. В этом случае, соответствующее преобразование делается несколько раз. - -Обратите внимание на синтаксис ARRAY JOIN в запросе SELECT, который предоставляет более широкие возможности. - -Пример: - -``` sql -SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src -``` - -``` text -┌─dst─┬─\'Hello\'─┬─src─────┐ -│ 1 │ Hello │ [1,2,3] │ -│ 2 │ Hello │ [1,2,3] │ -│ 3 │ Hello │ [1,2,3] │ -└─────┴───────────┴─────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/array_join/) diff --git a/docs/ru/sql_reference/functions/bit_functions.md b/docs/ru/sql_reference/functions/bit_functions.md deleted file mode 100644 index 09eb9d17bc2..00000000000 --- a/docs/ru/sql_reference/functions/bit_functions.md +++ /dev/null @@ -1,238 +0,0 @@ -# Битовые функции {#bitovye-funktsii} - -Битовые функции работают для любой пары типов из UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, Float64. - -Тип результата - целое число, битность которого равна максимальной битности аргументов. Если хотя бы один аргумент знаковый, то результат - знаковое число. Если аргумент - число с плавающей запятой - оно приводится к Int64. - -## bitAnd(a, b) {#bitanda-b} - -## bitOr(a, b) {#bitora-b} - -## bitXor(a, b) {#bitxora-b} - -## bitNot(a) {#bitnota} - -## bitShiftLeft(a, b) {#bitshiftlefta-b} - -## bitShiftRight(a, b) {#bitshiftrighta-b} - -## bitTest {#bittest} - -Принимает любое целое число и конвертирует его в [двоичное число](https://en.wikipedia.org/wiki/Binary_number), возвращает значение бита в указанной позиции. Отсчет начинается с 0 справа налево. - -**Синтаксис** - -``` sql -SELECT bitTest(number, index) -``` - -**Параметры** - -- `number` – целое число. -- `index` – position of bit. - -**Возвращаемое значение** - -Возвращает значение бита в указанной позиции. - -Тип: `UInt8`. - -**Пример** - -Например, число 43 в двоичной системе счисления равно: 101011. - -Запрос: - -``` sql -SELECT bitTest(43, 1) -``` - -Ответ: - -``` text -┌─bitTest(43, 1)─┐ -│ 1 │ -└────────────────┘ -``` - -Другой пример: - -Запрос: - -``` sql -SELECT bitTest(43, 2) -``` - -Ответ: - -``` text -┌─bitTest(43, 2)─┐ -│ 0 │ -└────────────────┘ -``` - -## bitTestAll {#bittestall} - -Возвращает результат [логической конъюнкции](https://en.wikipedia.org/wiki/Logical_conjunction) (оператор AND) всех битов в указанных позициях. Отсчет начинается с 0 справа налево. - -Бинарная конъюнкция: - -0 AND 0 = 0 -0 AND 1 = 0 -1 AND 0 = 0 -1 AND 1 = 1 - -**Синтаксис** - -``` sql -SELECT bitTestAll(number, index1, index2, index3, index4, ...) -``` - -**Параметры** - -- `number` – целое число. -- `index1`, `index2`, `index3`, `index4` – позиция бита. Например, конъюнкция для набора позиций `index1`, `index2`, `index3`, `index4` является истинной, если все его позиции истинны `index1` ⋀ `index2` ⋀ `index3` ⋀ `index4`. - -**Возвращаемое значение** - -Возвращает результат логической конъюнкции. - -Тип: `UInt8`. - -**Пример** - -Например, число 43 в двоичной системе счисления равно: 101011. - -Запрос: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5) -``` - -Ответ: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5)─┐ -│ 1 │ -└────────────────────────────┘ -``` - -Другой пример: - -Запрос: - -``` sql -SELECT bitTestAll(43, 0, 1, 3, 5, 2) -``` - -Ответ: - -``` text -┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ -│ 0 │ -└───────────────────────────────┘ -``` - -## bitTestAny {#bittestany} - -Возвращает результат [логической дизъюнкции](https://en.wikipedia.org/wiki/Logical_disjunction) (оператор OR) всех битов в указанных позициях. Отсчет начинается с 0 справа налево. - -Бинарная дизъюнкция: - -0 OR 0 = 0 -0 OR 1 = 1 -1 OR 0 = 1 -1 OR 1 = 1 - -**Синтаксис** - -``` sql -SELECT bitTestAny(number, index1, index2, index3, index4, ...) -``` - -**Параметры** - -- `number` – целое число. -- `index1`, `index2`, `index3`, `index4` – позиции бита. - -**Возвращаемое значение** - -Возвращает результат логической дизъюнкции. - -Тип: `UInt8`. - -**Пример** - -Например, число 43 в двоичной системе счисления равно: 101011. - -Запрос: - -``` sql -SELECT bitTestAny(43, 0, 2) -``` - -Ответ: - -``` text -┌─bitTestAny(43, 0, 2)─┐ -│ 1 │ -└──────────────────────┘ -``` - -Другой пример: - -Запрос: - -``` sql -SELECT bitTestAny(43, 4, 2) -``` - -Ответ: - -``` text -┌─bitTestAny(43, 4, 2)─┐ -│ 0 │ -└──────────────────────┘ -``` - -## bitCount {#bitcount} - -Подсчитывает количество равных единице бит в числе. - -**Синтаксис** - -```sql -bitCount(x) -``` - -**Параметры** - -- `x` — [Целое число](../../sql_reference/functions/bit_functions.md) или [число с плавающей запятой](../../sql_reference/functions/bit_functions.md). Функция использует представление числа в памяти, что позволяет поддержать числа с плавающей запятой. - -**Возвращаемое значение** - -- Количество равных единице бит во входном числе. - -Функция не преобразует входное значение в более крупный тип ([sign extension](https://en.wikipedia.org/wiki/Sign_extension)). Поэтому, например, `bitCount(toUInt8(-1)) = 8`. - -Тип: `UInt8`. - -**Пример** - -Возьмём к примеру число 333. Его бинарное представление — 0000000101001101. - -Запрос: - -```sql -SELECT bitCount(333) -``` - -Результат: - -```text -┌─bitCount(100)─┐ -│ 5 │ -└───────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/bit_functions/) diff --git a/docs/ru/sql_reference/functions/bitmap_functions.md b/docs/ru/sql_reference/functions/bitmap_functions.md deleted file mode 100644 index 0a6288498be..00000000000 --- a/docs/ru/sql_reference/functions/bitmap_functions.md +++ /dev/null @@ -1,393 +0,0 @@ -# Функции для битмапов {#funktsii-dlia-bitmapov} - -## bitmapBuild {#bitmap_functions-bitmapbuild} - -Создаёт битовый массив из массива целочисленных значений. - -``` sql -bitmapBuild(array) -``` - -**Параметры** - -- `array` – массив типа `UInt*`. - -**Пример** - -``` sql -SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res) -``` - -``` text -┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ -│  │ AggregateFunction(groupBitmap, UInt8) │ -└─────┴──────────────────────────────────────────────┘ -``` - -## bitmapToArray {#bitmaptoarray} - -Преобразует битовый массив в массив целочисленных значений. - -``` sql -bitmapToArray(bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## bitmapSubsetLimit {#bitmapsubsetlimit} - -Создает подмножество битмапа с n элементами, расположенными между `range_start` и `cardinality_limit`. - -**Синтаксис** - -``` sql -bitmapSubsetLimit(bitmap, range_start, cardinality_limit) -``` - -**Параметры** - -- `bitmap` – Битмап. [Bitmap object](#bitmap_functions-bitmapbuild). -- `range_start` – Начальная точка подмножества. [UInt32](../../sql_reference/functions/bitmap_functions.md). -- `cardinality_limit` – Верхний предел подмножества. [UInt32](../../sql_reference/functions/bitmap_functions.md). - -**Возвращаемое значение** - -Подмножество битмапа. - -Тип: `Bitmap object`. - -**Пример** - -Запрос: - -``` sql -SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - -Ответ: - -``` text -┌─res───────────────────────┐ -│ [30,31,32,33,100,200,500] │ -└───────────────────────────┘ -``` - -## bitmapContains {#bitmap_functions-bitmapcontains} - -Проверяет вхождение элемента в битовый массив. - -``` sql -bitmapContains(haystack, needle) -``` - -**Параметры** - -- `haystack` – [объект Bitmap](#bitmap_functions-bitmapbuild), в котором функция ищет значение. -- `needle` – значение, которое функция ищет. Тип — [UInt32](../../sql_reference/functions/bitmap_functions.md). - -**Возвращаемые значения** - -- 0 — если в `haystack` нет `needle`. -- 1 — если в `haystack` есть `needle`. - -Тип — `UInt8`. - -**Пример** - -``` sql -SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAny {#bitmaphasany} - -Проверяет, имеют ли два битовых массива хотя бы один общий элемент. - -``` sql -bitmapHasAny(bitmap1, bitmap2) -``` - -Если вы уверены, что `bitmap2` содержит строго один элемент, используйте функцию [bitmapContains](#bitmap_functions-bitmapcontains). Она работает эффективнее. - -**Параметры** - -- `bitmap*` – массив любого типа с набором элементов. - -**Возвращаемые значения** - -- `1`, если `bitmap1` и `bitmap2` имеют хотя бы один одинаковый элемент. -- `0`, в противном случае. - -**Пример** - -``` sql -SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAll {#bitmaphasall} - -Аналогично функции `hasAll(array, array)` возвращает 1 если первый битовый массив содержит все элементы второго, 0 в противном случае. -Если второй аргумент является пустым битовым массивом, то возвращает 1. - -``` sql -bitmapHasAll(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - -``` text -┌─res─┐ -│ 0 │ -└─────┘ -``` - -## bitmapAnd {#bitmapand} - -Логическое И для двух битовых массивов. Результат — новый битовый массив. - -``` sql -bitmapAnd(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─┐ -│ [3] │ -└─────┘ -``` - -## bitmapOr {#bitmapor} - -Логическое ИЛИ для двух битовых массивов. Результат — новый битовый массив. - -``` sql -bitmapOr(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ -``` - -## bitmapXor {#bitmapxor} - -Логическое исключающее ИЛИ для двух битовых массивов. Результат — новый битовый массив. - -``` sql -bitmapXor(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───────┐ -│ [1,2,4,5] │ -└───────────┘ -``` - -## bitmapAndnot {#bitmapandnot} - -Логическое отрицание И для двух битовых массивов. Результат — новый битовый массив. - -``` sql -bitmapAndnot(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - -``` text -┌─res───┐ -│ [1,2] │ -└───────┘ -``` - -## bitmapCardinality {#bitmapcardinality} - -Возвращает кардинальность битового массива в виде значения типа `UInt64`. - -``` sql -bitmapCardinality(bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## bitmapAndCardinality {#bitmapandcardinality} - -Выполняет логическое И и возвращает кардинальность (`UInt64`) результирующего битового массива. - -``` sql -bitmapAndCardinality(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapOrCardinality {#bitmaporcardinality} - -Выполняет логическое ИЛИ и возвращает кардинальность (`UInt64`) результирующего битового массива. - -``` sql -bitmapOrCardinality(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 5 │ -└─────┘ -``` - -## bitmapXorCardinality {#bitmapxorcardinality} - -Выполняет логическое исключающее ИЛИ и возвращает кардинальность (`UInt64`) результирующего битового массива. - -``` sql -bitmapXorCardinality(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 4 │ -└─────┘ -``` - -## bitmapAndnotCardinality {#bitmapandnotcardinality} - -Выполняет логическое отрицание И и возвращает кардинальность (`UInt64`) результирующего битового массива. - -``` sql -bitmapAndnotCardinality(bitmap,bitmap) -``` - -**Параметры** - -- `bitmap` – битовый массив. - -**Пример** - -``` sql -SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - -``` text -┌─res─┐ -│ 2 │ -└─────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/bitmap_functions/) diff --git a/docs/ru/sql_reference/functions/comparison_functions.md b/docs/ru/sql_reference/functions/comparison_functions.md deleted file mode 100644 index 16ae7ee4cae..00000000000 --- a/docs/ru/sql_reference/functions/comparison_functions.md +++ /dev/null @@ -1,32 +0,0 @@ -# Функции сравнения {#funktsii-sravneniia} - -Функции сравнения возвращают всегда 0 или 1 (UInt8). - -Сравнивать можно следующие типы: - -- числа; -- строки и фиксированные строки; -- даты; -- даты-с-временем; - -внутри каждой группы, но не из разных групп. - -Например, вы не можете сравнить дату со строкой. Надо использовать функцию преобразования строки в дату или наоборот. - -Строки сравниваются побайтово. Более короткая строка меньше всех строк, начинающихся с неё и содержащих ещё хотя бы один символ. - -Замечание. До версии 1.1.54134 сравнение знаковых и беззнаковых целых чисел производилось также, как в C++. То есть, вы могли получить неверный результат в таких случаях: SELECT 9223372036854775807 \> -1. С версии 1.1.54134 поведение изменилось и стало математически корректным. - -## equals, оператор a = b и a == b {#function-equals} - -## notEquals, оператор a != b и a `<>` b {#function-notequals} - -## less, оператор `<` {#function-less} - -## greater, оператор `>` {#function-greater} - -## lessOrEquals, оператор `<=` {#function-lessorequals} - -## greaterOrEquals, оператор `>=` {#function-greaterorequals} - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/comparison_functions/) diff --git a/docs/ru/sql_reference/functions/conditional_functions.md b/docs/ru/sql_reference/functions/conditional_functions.md deleted file mode 100644 index f3c57aac38b..00000000000 --- a/docs/ru/sql_reference/functions/conditional_functions.md +++ /dev/null @@ -1,109 +0,0 @@ -# Условные функции {#uslovnye-funktsii} - -## if {#if} - -Условное выражение. В отличии от большинства систем, ClickHouse всегда считает оба выражения `then` и `else`. - -**Синтаксис** - -``` sql -SELECT if(cond, then, else) -``` - -Если условие `cond` не равно нулю, то возвращается результат выражения `then`. Если условие `cond` равно нулю или является NULL, то результат выражения `then` пропускается и возвращается результат выражения `else`. - -**Параметры** - -- `cond` – Условие, которое может быть равно 0 или нет. Может быть [UInt8](../../sql_reference/functions/conditional_functions.md) или `NULL`. -- `then` - Возвращается результат выражения, если условие `cond` истинно. -- `else` - Возвращается результат выражения, если условие `cond` ложно. - -**Возвращаемые значения** - -Функция выполняет выражения `then` или `else` и возвращает его результат, в зависимости от того, было ли условие `cond` равно нулю или нет. - -**Пример** - -Запрос: - -``` sql -SELECT if(1, plus(2, 2), plus(2, 6)) -``` - -Ответ: - -``` text -┌─plus(2, 2)─┐ -│ 4 │ -└────────────┘ -``` - -Запрос: - -``` sql -SELECT if(0, plus(2, 2), plus(2, 6)) -``` - -Ответ: - -``` text -┌─plus(2, 6)─┐ -│ 8 │ -└────────────┘ -``` - -## Тернарный оператор {#ternary-operator} - -Работает так же, как функция `if`. - -Синтаксис: `cond ? then : else` - -Возвращает `then`, если `cond` верно (больше нуля), в остальных случаях возвращает `else`. - -- `cond` должно быть типа `UInt8`, `then` и `else` должны относиться к наименьшему общему типу. - -- `then` и `else` могут быть `NULL`. - -**Смотрите также** - -- [ifNotFinite](other_functions.md#ifnotfinite). - -## multiIf {#multiif} - -Позволяет более компактно записать оператор [CASE](../operators.md#operator_case) в запросе. - - multiIf(cond_1, then_1, cond_2, then_2...else) - -**Параметры** - -- `cond_N` — Условие, при выполнении которого функция вернёт `then_N`. -- `then_N` — Результат функции при выполнении. -- `else` — Результат функции, если ни одно из условий не выполнено. - -Функция принимает `2N+1` параметров. - -**Возвращаемые значения** - -Функция возвращает одно из значений `then_N` или `else`, в зависимости от условий `cond_N`. - -**Пример** - -Рассмотрим таблицу - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Выполним запрос `SELECT multiIf(isNull(y), x, y < 3, y, NULL) FROM t_null`. Результат: - -``` text -┌─multiIf(isNull(y), x, less(y, 3), y, NULL)─┐ -│ 1 │ -│ ᴺᵁᴸᴸ │ -└────────────────────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/conditional_functions/) diff --git a/docs/ru/sql_reference/functions/date_time_functions.md b/docs/ru/sql_reference/functions/date_time_functions.md deleted file mode 100644 index 9f2f5b8afd2..00000000000 --- a/docs/ru/sql_reference/functions/date_time_functions.md +++ /dev/null @@ -1,290 +0,0 @@ -# Функции для работы с датами и временем {#funktsii-dlia-raboty-s-datami-i-vremenem} - -Поддержка часовых поясов - -Все функции по работе с датой и временем, для которых это имеет смысл, могут принимать второй, необязательный аргумент - имя часового пояса. Пример: Asia/Yekaterinburg. В этом случае, они используют не локальный часовой пояс (по умолчанию), а указанный. - -``` sql -SELECT - toDateTime('2016-06-15 23:00:00') AS time, - toDate(time) AS date_local, - toDate(time, 'Asia/Yekaterinburg') AS date_yekat, - toString(time, 'US/Samoa') AS time_samoa -``` - -``` text -┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ -└─────────────────────┴────────────┴────────────┴─────────────────────┘ -``` - -Поддерживаются только часовые пояса, отличающиеся от UTC на целое число часов. - -## toYear {#toyear} - -Переводит дату или дату-с-временем в число типа UInt16, содержащее номер года (AD). - -## toMonth {#tomonth} - -Переводит дату или дату-с-временем в число типа UInt8, содержащее номер месяца (1-12). - -## toDayOfMonth {#todayofmonth} - -Переводит дату или дату-с-временем в число типа UInt8, содержащее номер дня в месяце (1-31). - -## toDayOfWeek {#todayofweek} - -Переводит дату или дату-с-временем в число типа UInt8, содержащее номер дня в неделе (понедельник - 1, воскресенье - 7). - -## toHour {#tohour} - -Переводит дату-с-временем в число типа UInt8, содержащее номер часа в сутках (0-23). -Функция исходит из допущения, что перевод стрелок вперёд, если осуществляется, то на час, в два часа ночи, а перевод стрелок назад, если осуществляется, то на час, в три часа ночи (что, в общем, не верно - даже в Москве два раза перевод стрелок был осуществлён в другое время). - -## toMinute {#tominute} - -Переводит дату-с-временем в число типа UInt8, содержащее номер минуты в часе (0-59). - -## toSecond {#tosecond} - -Переводит дату-с-временем в число типа UInt8, содержащее номер секунды в минуте (0-59). -Секунды координации не учитываются. - -## toUnixTimestamp {#to-unix-timestamp} - -For DateTime argument: converts value to its internal numeric representation (Unix Timestamp). -For String argument: parse datetime from string according to the timezone (optional second argument, server timezone is used by default) and returns the corresponding unix timestamp. -For Date argument: the behaviour is unspecified. - -**Syntax** - -``` sql -toUnixTimestamp(datetime) -toUnixTimestamp(str, [timezone]) -``` - -**Returned value** - -- Returns the unix timestamp. - -Type: `UInt32`. - -**Example** - -Query: - -``` sql -SELECT toUnixTimestamp('2017-11-05 08:07:47', 'Asia/Tokyo') AS unix_timestamp -``` - -Result: - -``` text -┌─unix_timestamp─┐ -│ 1509836867 │ -└────────────────┘ -``` - -## toStartOfYear {#tostartofyear} - -Округляет дату или дату-с-временем вниз до первого дня года. -Возвращается дата. - -## toStartOfQuarter {#tostartofquarter} - -Округляет дату или дату-с-временем вниз до первого дня квартала. -Первый день квартала - это одно из 1 января, 1 апреля, 1 июля, 1 октября. -Возвращается дата. - -## toStartOfMonth {#tostartofmonth} - -Округляет дату или дату-с-временем вниз до первого дня месяца. -Возвращается дата. - -!!! attention "Attention" - Возвращаемое значение для некорректных дат зависит от реализации. ClickHouse может вернуть нулевую дату, выбросить исключение, или выполнить «естественное» перетекание дат между месяцами. - -## toMonday {#tomonday} - -Округляет дату или дату-с-временем вниз до ближайшего понедельника. -Возвращается дата. - -## toStartOfDay {#tostartofday} - -Округляет дату-с-временем вниз до начала дня. Возвращается дата-с-временем. - -## toStartOfHour {#tostartofhour} - -Округляет дату-с-временем вниз до начала часа. - -## toStartOfMinute {#tostartofminute} - -Округляет дату-с-временем вниз до начала минуты. - -## toStartOfFiveMinute {#tostartoffiveminute} - -Округляет дату-с-временем вниз до начала пятиминутного интервала. - -## toStartOfTenMinutes {#tostartoftenminutes} - -Округляет дату-с-временем вниз до начала десятиминутного интервала. - -## toStartOfFifteenMinutes {#tostartoffifteenminutes} - -Округляет дату-с-временем вниз до начала пятнадцатиминутного интервала. - -## toStartOfInterval(time\_or\_data, INTERVAL x unit \[, time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} - -Обобщение остальных функций `toStartOf*`. Например, -`toStartOfInterval(t, INTERVAL 1 year)` возвращает то же самое, что и `toStartOfYear(t)`, -`toStartOfInterval(t, INTERVAL 1 month)` возвращает то же самое, что и `toStartOfMonth(t)`, -`toStartOfInterval(t, INTERVAL 1 day)` возвращает то же самое, что и `toStartOfDay(t)`, -`toStartOfInterval(t, INTERVAL 15 minute)` возвращает то же самое, что и `toStartOfFifteenMinutes(t)`, и т.п. - -## toTime {#totime} - -Переводит дату-с-временем на некоторую фиксированную дату, сохраняя при этом время. - -## toRelativeYearNum {#torelativeyearnum} - -Переводит дату-с-временем или дату в номер года, начиная с некоторого фиксированного момента в прошлом. - -## toRelativeMonthNum {#torelativemonthnum} - -Переводит дату-с-временем или дату в номер месяца, начиная с некоторого фиксированного момента в прошлом. - -## toRelativeWeekNum {#torelativeweeknum} - -Переводит дату-с-временем или дату в номер недели, начиная с некоторого фиксированного момента в прошлом. - -## toRelativeDayNum {#torelativedaynum} - -Переводит дату-с-временем или дату в номер дня, начиная с некоторого фиксированного момента в прошлом. - -## toRelativeHourNum {#torelativehournum} - -Переводит дату-с-временем в номер часа, начиная с некоторого фиксированного момента в прошлом. - -## toRelativeMinuteNum {#torelativeminutenum} - -Переводит дату-с-временем в номер минуты, начиная с некоторого фиксированного момента в прошлом. - -## toRelativeSecondNum {#torelativesecondnum} - -Переводит дату-с-временем в номер секунды, начиная с некоторого фиксированного момента в прошлом. - -## now {#now} - -Принимает ноль аргументов и возвращает текущее время на один из моментов выполнения запроса. -Функция возвращает константу, даже если запрос выполнялся долго. - -## today {#today} - -Принимает ноль аргументов и возвращает текущую дату на один из моментов выполнения запроса. -То же самое, что toDate(now()) - -## yesterday {#yesterday} - -Принимает ноль аргументов и возвращает вчерашнюю дату на один из моментов выполнения запроса. -Делает то же самое, что today() - 1. - -## dateDiff {#datediff} - -Вычисляет разницу между двумя значениями дат с временем. - -**Синтаксис** - -``` sql -dateDiff('unit', startdate, enddate, [timezone]) -``` - -**Параметры** - -- `unit` — Единица измерения времени, в которой будет вычислена разница между `startdate` и `enddate`. [String](../syntax.md#syntax-string-literal). - - Поддерживаемые значения: - - | unit | - | ------ | - |second | - |minute | - |hour | - |day | - |week | - |month | - |quarter | - |year | - -- `startdate` — Первая дата. [Date](../../sql_reference/functions/date_time_functions.md) или [DateTime](../../sql_reference/functions/date_time_functions.md). - -- `enddate` — Вторая дата. [Date](../../sql_reference/functions/date_time_functions.md) или [DateTime](../../sql_reference/functions/date_time_functions.md). - -- `timezone` — Опциональный параметр. Если определен, применяется к обоим значениям: `startdate` и `enddate`. Если не определен, используются часовые пояса `startdate` и `enddate`. Если часовые пояса не совпадают, вернется неожидаемый результат. - -**Возвращаемое значение** - -Разница между `startdate` и `enddate`, выраженная в `unit`. - -Тип: `int`. - -**Пример** - -Запрос: - -``` sql -SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); -``` - -Ответ: - -``` text -┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ -│ 25 │ -└────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -## timeSlot {#timeslot} - -Округляет время до получаса. -Эта функция является специфичной для Яндекс.Метрики, так как пол часа - минимальное время, для которого, если соседние по времени хиты одного посетителя на одном счётчике отстоят друг от друга строго более, чем на это время, визит может быть разбит на два визита. То есть, кортежи (номер счётчика, идентификатор посетителя, тайм-слот) могут использоваться для поиска хитов, входящий в соответствующий визит. - -## timeSlots(StartTime, Duration,\[, Size\]) {#timeslotsstarttime-duration-size} - -Для интервала времени, начинающегося в ‘StartTime’ и продолжающегося ‘Duration’ секунд, возвращает массив моментов времени, состоящий из округлений вниз до ‘Size’ точек в секундах из этого интервала. ‘Size’ - необязательный параметр, константный UInt32, по умолчанию равен 1800. - -Например, `timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600)) = [toDateTime('2012-01-01 12:00:00'), toDateTime('2012-01-01 12:30:00')]`. -Это нужно для поиска хитов, входящих в соответствующий визит. - -## formatDateTime(Time, Format\[, Timezone\]) {#formatdatetime} - -Функция преобразования даты-с-временем в String согласно заданному шаблону. Важно - шаблон является константным выражением, т.е. невозможно использование разных шаблонов в одной колонке. - -Поддерживаемые модификаторы в шаблоне Format: -(колонка «Пример» показана для времени `2018-01-02 22:33:44`) - -| Модификатор | Описание | Пример | -|-------------|----------------------------------------------------------------------|------------| -| %C | номер года, поделённый на 100 (00-99) | 20 | -| %d | день месяца, с ведущим нулём (01-31) | 02 | -| %D | короткая запись %m/%d/%y | 01/02/18 | -| %e | день месяца, с ведущим пробелом ( 1-31) | 2 | -| %F | короткая запись %Y-%m-%d | 2018-01-02 | -| %H | час в 24-часовом формате (00-23) | 22 | -| %I | час в 12-часовом формате (01-12) | 10 | -| %j | номер дня в году, с ведущими нулями (001-366) | 002 | -| %m | месяц, с ведущим нулём (01-12) | 01 | -| %M | минуты, с ведущим нулём (00-59) | 33 | -| %n | символ переноса строки (‘’) | | -| %p | обозначения AM или PM | PM | -| %R | короткая запись %H:%M | 22:33 | -| %S | секунды, с ведущими нулями (00-59) | 44 | -| %t | символ табуляции (’) | | -| %T | формат времени ISO 8601, одинаковый с %H:%M:%S | 22:33:44 | -| %u | номер дня недели согласно ISO 8601, понедельник - 1, воскресенье - 7 | 2 | -| %V | номер недели согласно ISO 8601 (01-53) | 01 | -| %w | номер дня недели, начиная с воскресенья (0-6) | 2 | -| %y | год, последние 2 цифры (00-99) | 18 | -| %Y | год, 4 цифры | 2018 | -| %% | символ % | % | - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/date_time_functions/) diff --git a/docs/ru/sql_reference/functions/encoding_functions.md b/docs/ru/sql_reference/functions/encoding_functions.md deleted file mode 100644 index b4c4716d9c7..00000000000 --- a/docs/ru/sql_reference/functions/encoding_functions.md +++ /dev/null @@ -1,168 +0,0 @@ -# Функции кодирования {#funktsii-kodirovaniia} - -## char {#char} - -Возвращает строку, длина которой равна числу переданных аргументов, и каждый байт имеет значение соответствующего аргумента. Принимает несколько числовых аргументов. Если значение аргумента выходит за диапазон UInt8 (0..255), то оно преобразуется в UInt8 с возможным округлением и переполнением. - -**Синтаксис** - -``` sql -char(number_1, [number_2, ..., number_n]); -``` - -**Параметры** - -- `number_1, number_2, ..., number_n` — Числовые аргументы, которые интерпретируются как целые числа. Типы: [Int](../../sql_reference/functions/encoding_functions.md), [Float](../../sql_reference/functions/encoding_functions.md). - -**Возвращаемое значение** - -- строка из соответствующих байт. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello -``` - -Ответ: - -``` text -┌─hello─┐ -│ hello │ -└───────┘ -``` - -Вы можете создать строку в произвольной кодировке, передав соответствующие байты. Пример для UTF-8: - -Запрос: - -``` sql -SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; -``` - -Ответ: - -``` text -┌─hello──┐ -│ привет │ -└────────┘ -``` - -Запрос: - -``` sql -SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; -``` - -Ответ: - -``` text -┌─hello─┐ -│ 你好 │ -└───────┘ -``` - -## hex {#hex} - -Returns a string containing the argument’s hexadecimal representation. - -**Syntax** - -``` sql -hex(arg) -``` - -The function is using uppercase letters `A-F` and not using any prefixes (like `0x`) or suffixes (like `h`). - -For integer arguments, it prints hex digits («nibbles») from the most significant to least significant (big endian or «human readable» order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints both digits of every byte even if leading digit is zero. - -Example: - -**Example** - -Query: - -``` sql -SELECT hex(1); -``` - -Result: - -``` text -01 -``` - -Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). - -For `String` and `FixedString`, all bytes are simply encoded as two hexadecimal numbers. Zero bytes are not omitted. - -Values of floating point and Decimal types are encoded as their representation in memory. As we support little endian architecture, they are encoded in little endian. Zero leading/trailing bytes are not omitted. - -**Parameters** - -- `arg` — A value to convert to hexadecimal. Types: [String](../../sql_reference/functions/encoding_functions.md), [UInt](../../sql_reference/functions/encoding_functions.md), [Float](../../sql_reference/functions/encoding_functions.md), [Decimal](../../sql_reference/functions/encoding_functions.md), [Date](../../sql_reference/functions/encoding_functions.md) or [DateTime](../../sql_reference/functions/encoding_functions.md). - -**Returned value** - -- A string with the hexadecimal representation of the argument. - -Type: `String`. - -**Example** - -Query: - -``` sql -SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); -``` - -Result: - -``` text -┌─hex_presentation─┐ -│ 00007041 │ -│ 00008041 │ -└──────────────────┘ -``` - -Query: - -``` sql -SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); -``` - -Result: - -``` text -┌─hex_presentation─┐ -│ 0000000000002E40 │ -│ 0000000000003040 │ -└──────────────────┘ -``` - -## unhex(str) {#unhexstr} - -Accepts a string containing any number of hexadecimal digits, and returns a string containing the corresponding bytes. Supports both uppercase and lowercase letters A-F. The number of hexadecimal digits does not have to be even. If it is odd, the last digit is interpreted as the least significant half of the 00-0F byte. If the argument string contains anything other than hexadecimal digits, some implementation-defined result is returned (an exception isn’t thrown). -If you want to convert the result to a number, you can use the ‘reverse’ and ‘reinterpretAsType’ functions. - -## UUIDStringToNum(str) {#uuidstringtonumstr} - -Принимает строку, содержащую 36 символов в формате `123e4567-e89b-12d3-a456-426655440000`, и возвращает в виде набора байт в FixedString(16). - -## UUIDNumToString(str) {#uuidnumtostringstr} - -Принимает значение типа FixedString(16). Возвращает строку из 36 символов в текстовом виде. - -## bitmaskToList(num) {#bitmasktolistnum} - -Принимает целое число. Возвращает строку, содержащую список степеней двойки, в сумме дающих исходное число; по возрастанию, в текстовом виде, через запятую, без пробелов. - -## bitmaskToArray(num) {#bitmasktoarraynum} - -Принимает целое число. Возвращает массив чисел типа UInt64, содержащий степени двойки, в сумме дающих исходное число; числа в массиве идут по возрастанию. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/encoding_functions/) diff --git a/docs/ru/sql_reference/functions/ext_dict_functions.md b/docs/ru/sql_reference/functions/ext_dict_functions.md deleted file mode 100644 index 1a1d383e4bb..00000000000 --- a/docs/ru/sql_reference/functions/ext_dict_functions.md +++ /dev/null @@ -1,196 +0,0 @@ -# Функции для работы с внешними словарями {#ext_dict_functions} - -Информацию о подключении и настройке внешних словарей смотрите в разделе [Внешние словари](../../sql_reference/functions/ext_dict_functions.md). - -## dictGet {#dictget} - -Извлекает значение из внешнего словаря. - -``` sql -dictGet('dict_name', 'attr_name', id_expr) -dictGetOrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**Параметры** - -- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `attr_name` — имя столбца словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `id_expr` — значение ключа словаря. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql_reference/functions/ext_dict_functions.md) или [Tuple](../../sql_reference/functions/ext_dict_functions.md) в зависимости от конфигурации словаря. -- `default_value_expr` — значение, возвращаемое в том случае, когда словарь не содержит строки с заданным ключом `id_expr`. [Выражение](../syntax.md#syntax-expressions) возвращающее значение с типом данных, сконфигурированным для атрибута `attr_name`. - -**Возвращаемое значение** - -- Значение атрибута, соответствующее ключу `id_expr`, если ClickHouse смог привести это значение к [заданному типу данных](../../sql_reference/functions/ext_dict_functions.md#ext_dict_structure-attributes). - -- Если ключа, соответствующего `id_expr` в словаре нет, то: - - - `dictGet` возвращает содержимое элемента ``, указанного для атрибута в конфигурации словаря. - - `dictGetOrDefault` возвращает атрибут `default_value_expr`. - -Если значение атрибута не удалось обработать или оно не соответствует типу данных атрибута, то ClickHouse генерирует исключение. - -**Пример** - -Создадим текстовый файл `ext-dict-text.csv` со следующим содержимым: - -``` text -1,1 -2,2 -``` - -Первый столбец — `id`, второй столбец — `c1`. - -Настройка внешнего словаря: - -``` xml - - - ext-dict-test - - - /path-to/ext-dict-test.csv - CSV - - - - - - - - id - - - c1 - UInt32 - - - - 0 - - -``` - -Выполним запрос: - -``` sql -SELECT - dictGetOrDefault('ext-dict-test', 'c1', number + 1, toUInt32(number * 10)) AS val, - toTypeName(val) AS type -FROM system.numbers -LIMIT 3 -``` - -``` text -┌─val─┬─type───┐ -│ 1 │ UInt32 │ -│ 2 │ UInt32 │ -│ 20 │ UInt32 │ -└─────┴────────┘ -``` - -**Смотрите также** - -- [Внешние словари](../../sql_reference/functions/ext_dict_functions.md) - -## dictHas {#dicthas} - -Проверяет, присутствует ли запись с указанным ключом в словаре. - -``` sql -dictHas('dict_name', id) -``` - -**Параметры** - -- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `id_expr` — значение ключа словаря. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql_reference/functions/ext_dict_functions.md). - -**Возвращаемое значение** - -- 0, если ключа нет. -- 1, если ключ есть. - -Тип — `UInt8`. - -## dictGetHierarchy {#dictgethierarchy} - -Создаёт массив, содержащий цепочку предков для заданного ключа в [иерархическом словаре](../dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md). - -**Синтаксис** - -``` sql -dictGetHierarchy('dict_name', key) -``` - -**Параметры** - -- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `key` — значение ключа. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql_reference/functions/ext_dict_functions.md). - -**Возвращаемое значение** - -- Цепочка предков заданного ключа. - -Type: [Array(UInt64)](../../sql_reference/functions/ext_dict_functions.md). - -## dictIsIn {#dictisin} - -Проверяет предка ключа по всей иерархической цепочке словаря. - -`dictIsIn ('dict_name', child_id_expr, ancestor_id_expr)` - -**Параметры** - -- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `child_id_expr` — ключ для проверки. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql_reference/functions/ext_dict_functions.md). -- `ancestor_id_expr` — предполагаемый предок ключа `child_id_expr`. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql_reference/functions/ext_dict_functions.md). - -**Возвращаемое значение** - -- 0, если `child_id_expr` — не дочерний элемент `ancestor_id_expr`. -- 1, если `child_id_expr` — дочерний элемент `ancestor_id_expr` или если `child_id_expr` и есть `ancestor_id_expr`. - -Тип — `UInt8`. - -## Прочие функции {#ext_dict_functions-other} - -ClickHouse поддерживает специализированные функции, которые приводят значения атрибутов словаря к определённому типу данных независимо от конфигурации словаря. - -Функции: - -- `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` -- `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` -- `dictGetFloat32`, `dictGetFloat64` -- `dictGetDate` -- `dictGetDateTime` -- `dictGetUUID` -- `dictGetString` - -Все эти функции можно использовать с модификатором `OrDefault`. Например, `dictGetDateOrDefault`. - -Синтаксис: - -``` sql -dictGet[Type]('dict_name', 'attr_name', id_expr) -dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) -``` - -**Параметры** - -- `dict_name` — имя словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `attr_name` — имя столбца словаря. [Строковый литерал](../syntax.md#syntax-string-literal). -- `id_expr` — значение ключа словаря. [Выражение](../syntax.md#syntax-expressions), возвращающее значение типа [UInt64](../../sql_reference/functions/ext_dict_functions.md). -- `default_value_expr` — значение, возвращаемое в том случае, когда словарь не содержит строки с заданным ключом `id_expr`. [Выражение](../syntax.md#syntax-expressions) возвращающее значение с типом данных, сконфигурированным для атрибута `attr_name`. - -**Возвращаемое значение** - -- Если ClickHouse успешно обработал атрибут в соответствии с [заданным типом данных](../../sql_reference/functions/ext_dict_functions.md#ext_dict_structure-attributes), то функции возвращают значение атрибута, соответствующее ключу `id_expr`. - -- Если запрошенного `id_expr` нет в словаре, то: - - - `dictGet[Type]` возвращает содержимое элемента ``, указанного для атрибута в конфигурации словаря. - - `dictGet[Type]OrDefault` возвращает аргумент `default_value_expr`. - -Если значение атрибута не удалось обработать или оно не соответствует типу данных атрибута, то ClickHouse генерирует исключение. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/ext_dict_functions/) diff --git a/docs/ru/sql_reference/functions/functions_for_nulls.md b/docs/ru/sql_reference/functions/functions_for_nulls.md deleted file mode 100644 index 0d07cbeb62d..00000000000 --- a/docs/ru/sql_reference/functions/functions_for_nulls.md +++ /dev/null @@ -1,305 +0,0 @@ -# Функции для работы с Nullable-аргументами {#funktsii-dlia-raboty-s-nullable-argumentami} - -## isNull {#isnull} - -Проверяет является ли аргумент [NULL](../syntax.md#null). - -``` sql -isNull(x) -``` - -**Параметры** - -- `x` — значение с не составным типом данных. - -**Возвращаемое значение** - -- `1`, если `x` — `NULL`. -- `0`, если `x` — не `NULL`. - -**Пример** - -Входная таблица - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Запрос - -``` sql -SELECT x FROM t_null WHERE isNull(y) -``` - -``` text -┌─x─┐ -│ 1 │ -└───┘ -``` - -## isNotNull {#isnotnull} - -Проверяет не является ли аргумент [NULL](../syntax.md#null). - -``` sql -isNotNull(x) -``` - -**Параметры** - -- `x` — значение с не составным типом данных. - -**Возвращаемое значение** - -- `0`, если `x` — `NULL`. -- `1`, если `x` — не `NULL`. - -**Пример** - -Входная таблица - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Запрос - -``` sql -SELECT x FROM t_null WHERE isNotNull(y) -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## coalesce {#coalesce} - -Последовательно слева-направо проверяет являются ли переданные аргументы `NULL` и возвращает первый не `NULL`. - -``` sql -coalesce(x,...) -``` - -**Параметры** - -- Произвольное количество параметров не составного типа. Все параметры должны быть совместимы по типу данных. - -**Возвращаемые значения** - -- Первый не `NULL` аргумент. -- `NULL`, если все аргументы — `NULL`. - -**Пример** - -Рассмотрим адресную книгу, в которой может быть указано несколько способов связи с клиентом. - -``` text -┌─name─────┬─mail─┬─phone─────┬──icq─┐ -│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ -│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└──────────┴──────┴───────────┴──────┘ -``` - -Поля `mail` и `phone` имеют тип String, а поле `icq` — `UInt32`, его необходимо будет преобразовать в `String`. - -Получим из адресной книги первый доступный способ связаться с клиентом: - -``` sql -SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook -``` - -``` text -┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ -│ client 1 │ 123-45-67 │ -│ client 2 │ ᴺᵁᴸᴸ │ -└──────────┴──────────────────────────────────────────────────────┘ -``` - -## ifNull {#ifnull} - -Возвращает альтернативное значение, если основной аргумент — `NULL`. - -``` sql -ifNull(x,alt) -``` - -**Параметры** - -- `x` — значение для проверки на `NULL`, -- `alt` — значение, которое функция вернёт, если `x` — `NULL`. - -**Возвращаемые значения** - -- Значение `x`, если `x` — не `NULL`. -- Значение `alt`, если `x` — `NULL`. - -**Пример** - -``` sql -SELECT ifNull('a', 'b') -``` - -``` text -┌─ifNull('a', 'b')─┐ -│ a │ -└──────────────────┘ -``` - -``` sql -SELECT ifNull(NULL, 'b') -``` - -``` text -┌─ifNull(NULL, 'b')─┐ -│ b │ -└───────────────────┘ -``` - -## nullIf {#nullif} - -Возвращает `NULL`, если аргументы равны. - -``` sql -nullIf(x, y) -``` - -**Параметры** - -`x`, `y` — значения для сравнивания. Они должны быть совместимых типов, иначе ClickHouse сгенерирует исключение. - -**Возвращаемые значения** - -- `NULL`, если аргументы равны. -- Значение `x`, если аргументы не равны. - -**Пример** - -``` sql -SELECT nullIf(1, 1) -``` - -``` text -┌─nullIf(1, 1)─┐ -│ ᴺᵁᴸᴸ │ -└──────────────┘ -``` - -``` sql -SELECT nullIf(1, 2) -``` - -``` text -┌─nullIf(1, 2)─┐ -│ 1 │ -└──────────────┘ -``` - -## assumeNotNull {#assumenotnull} - -Приводит значение типа [Nullable](../../sql_reference/functions/functions_for_nulls.md) к не `Nullable`, если значение не `NULL`. - -``` sql -assumeNotNull(x) -``` - -**Параметры** - -- `x` — исходное значение. - -**Возвращаемые значения** - -- Исходное значение с не `Nullable` типом, если оно — не `NULL`. -- Значение по умолчанию для не `Nullable` типа, если исходное значение — `NULL`. - -**Пример** - -Рассмотрим таблицу `t_null`. - -``` sql -SHOW CREATE TABLE t_null -``` - -``` text -┌─statement─────────────────────────────────────────────────────────────────┐ -│ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ -└───────────────────────────────────────────────────────────────────────────┘ -``` - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -Применим функцию `assumeNotNull` к столбцу `y`. - -``` sql -SELECT assumeNotNull(y) FROM t_null -``` - -``` text -┌─assumeNotNull(y)─┐ -│ 0 │ -│ 3 │ -└──────────────────┘ -``` - -``` sql -SELECT toTypeName(assumeNotNull(y)) FROM t_null -``` - -``` text -┌─toTypeName(assumeNotNull(y))─┐ -│ Int8 │ -│ Int8 │ -└──────────────────────────────┘ -``` - -## toNullable {#tonullable} - -Преобразует тип аргумента к `Nullable`. - -``` sql -toNullable(x) -``` - -**Параметры** - -- `x` — значение произвольного не составного типа. - -**Возвращаемое значение** - -- Входное значение с типом не `Nullable`. - -**Пример** - -``` sql -SELECT toTypeName(10) -``` - -``` text -┌─toTypeName(10)─┐ -│ UInt8 │ -└────────────────┘ -``` - -``` sql -SELECT toTypeName(toNullable(10)) -``` - -``` text -┌─toTypeName(toNullable(10))─┐ -│ Nullable(UInt8) │ -└────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/functions_for_nulls/) diff --git a/docs/ru/sql_reference/functions/geo.md b/docs/ru/sql_reference/functions/geo.md deleted file mode 100644 index db51ac05166..00000000000 --- a/docs/ru/sql_reference/functions/geo.md +++ /dev/null @@ -1,385 +0,0 @@ -# Функции для работы с географическими координатами {#funktsii-dlia-raboty-s-geograficheskimi-koordinatami} - -## greatCircleDistance {#greatcircledistance} - -Вычисляет расстояние между двумя точками на поверхности Земли по [формуле большого круга](https://en.wikipedia.org/wiki/Great-circle_distance). - -``` sql -greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) -``` - -**Входные параметры** - -- `lon1Deg` — долгота первой точки в градусах. Диапазон — `[-180°, 180°]`. -- `lat1Deg` — широта первой точки в градусах. Диапазон — `[-90°, 90°]`. -- `lon2Deg` — долгота второй точки в градусах. Диапазон — `[-180°, 180°]`. -- `lat2Deg` — широта второй точки в градусах. Диапазон — `[-90°, 90°]`. - -Положительные значения соответствуют северной широте и восточной долготе, отрицательные — южной широте и западной долготе. - -**Возвращаемое значение** - -Расстояние между двумя точками на поверхности Земли в метрах. - -Генерирует исключение, когда значения входных параметров выходят за границы диапазонов. - -**Пример** - -``` sql -SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) -``` - -``` text -┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ -│ 14132374.194975413 │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## greatCircleAngle {#greatcircleangle} - -Вычисляет угловое расстояние на сфере по [формуле большого круга](https://en.wikipedia.org/wiki/Great-circle_distance). - -``` sql -greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) -``` - -**Входные параметры** - -- `lon1Deg` — долгота первой точки в градусах. -- `lat1Deg` — широта первой точки в градусах. -- `lon2Deg` — долгота второй точки в градусах. -- `lat2Deg` — широта второй точки в градусах. - -**Возвращаемое значение** - -Длина дуги большого круга между двумя точками в градусах. - -**Пример** - -``` sql -SELECT greatCircleAngle(0, 0, 45, 0) AS arc -``` - -``` text -┌─arc─┐ -│ 45 │ -└─────┘ -``` - -## pointInEllipses {#pointinellipses} - -Проверяет, принадлежит ли точка хотя бы одному из эллипсов. -Координаты — геометрические в декартовой системе координат. - - pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) - -**Входные параметры** - -- `x, y` — координаты точки на плоскости. -- `xᵢ, yᵢ` — координаты центра `i`-го эллипса. -- `aᵢ, bᵢ` — полуоси `i`-го эллипса (в единицах измерения координат x,y). - -Входных параметров должно быть `2+4⋅n`, где `n` — количество эллипсов. - -**Возвращаемые значения** - -`1`, если точка внутри хотя бы одного из эллипсов, `0`, если нет. - -**Пример** - -``` sql -SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) -``` - -``` text -┌─pointInEllipses(10., 10., 10., 9.1, 1., 0.9999)─┐ -│ 1 │ -└─────────────────────────────────────────────────┘ -``` - -## pointInPolygon {#pointinpolygon} - -Проверяет, принадлежит ли точка многоугольнику на плоскости. - -``` sql -pointInPolygon((x, y), [(a, b), (c, d) ...], ...) -``` - -**Входные значения** - -- `(x, y)` — координаты точки на плоскости. Тип данных — [Tuple](../../sql_reference/functions/geo.md) — кортеж из двух чисел. -- `[(a, b), (c, d) ...]` — вершины многоугольника. Тип данных — [Array](../../sql_reference/functions/geo.md). Каждая вершина представлена парой координат `(a, b)`. Вершины следует указывать в порядке обхода по или против часовой стрелки. Минимальное количество вершин — 3. Многоугольник должен быть константным. -- функция поддерживает также многоугольники с дырками (вырезанными кусками). Для этого случая, добавьте многоугольники, описывающие вырезанные куски, дополнительными аргументами функции. Функция не поддерживает не односвязные многоугольники. - -**Возвращаемые значения** - -`1`, если точка внутри многоугольника, `0`, если нет. -Если точка находится на границе многоугольника, функция может возвращать как 0, так и 1. - -**Пример** - -``` sql -SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## geohashEncode {#geohashencode} - -Кодирует широту и долготу в строку geohash, смотрите http://geohash.org/, https://en.wikipedia.org/wiki/Geohash. - -``` sql -geohashEncode(longitude, latitude, [precision]) -``` - -**Входные значения** - -- longitude — долгота. Диапазон — `[-180°, 180°].` -- latitude — широта. Диапазон — `[-90°, 90°].` -- precision — длина результирующей строки, по умолчанию `12`. Опционально. Целое число в диапазоне `[1, 12]`. Любое значение меньше, чем `1` или больше `12` автоматически преобразуются в `12`. - -**Возвращаемые значения** - -- Строка с координатой, закодированной модифицированной версией алфавита base32. - -**Пример** - -``` sql -SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res -``` - -``` text -┌─res──────────┐ -│ ezs42d000000 │ -└──────────────┘ -``` - -## geohashDecode {#geohashdecode} - -Декодирует любую строку, закодированную в geohash, на долготу и широту. - -``` sql -geohashDecode(geohash_string) -``` - -**Входные значения** - -- `geohash_string` — строка, содержащая geohash. - -**Возвращаемые значения** - -- `(longitude, latitude)` — широта и долгота. Кортеж из двух значений типа `Float64`. - -**Пример** - -``` sql -SELECT geohashDecode('ezs42') AS res -``` - -``` text -┌─res─────────────────────────────┐ -│ (-5.60302734375,42.60498046875) │ -└─────────────────────────────────┘ -``` - -## h3IsValid {#h3isvalid} - -Проверяет корректность H3-индекса. - -``` sql -h3IsValid(h3index) -``` - -**Входные значения** - -- `h3index` — идентификатор шестиугольника. Тип данных — [UInt64](../../sql_reference/functions/geo.md). - -**Возвращаемые значения** - -- 0 — число не является H3-индексом -- 1 — число является H3-индексом - -Тип — [UInt8](../../sql_reference/functions/geo.md). - -**Пример** - -``` sql -SELECT h3IsValid(630814730351855103) as h3IsValid -``` - -``` text -┌─h3IsValid─┐ -│ 1 │ -└───────────┘ -``` - -## h3GetResolution {#h3getresolution} - -Извлекает разрешение H3-индекса. - -``` sql -h3GetResolution(h3index) -``` - -**Входные значения** - -- `h3index` — идентификатор шестиугольника. Тип данных — [UInt64](../../sql_reference/functions/geo.md). - -**Возвращаемые значения** - -- Разрешение сетки, от 0 до 15. -- Для несуществующего идентификатора может быть возвращено произвольное значение, используйте [h3IsValid](#h3isvalid) для проверки идентификаторов - -Тип — [UInt8](../../sql_reference/functions/geo.md). - -**Пример** - -``` sql -SELECT h3GetResolution(639821929606596015) as resolution -``` - -``` text -┌─resolution─┐ -│ 14 │ -└────────────┘ -``` - -## h3EdgeAngle {#h3edgeangle} - -Информирует о среднем размере стороны шестигранника H3 в градусах - -``` sql -h3EdgeAngle(resolution) -``` - -**Входные значения** - -- `resolution` — требуемое разрешение индекса. Тип данных — [UInt8](../../sql_reference/functions/geo.md). Диапазон возможных значений — `[0, 15]`. - -**Возвращаемые значения** - -Средняя длина стороны многоугольника H3 в градусах, тип — [Float64](../../sql_reference/functions/geo.md). - -**Пример** - -``` sql -SELECT h3EdgeAngle(10) as edgeAngle -``` - -``` text -┌─────────h3EdgeAngle(10)─┐ -│ 0.0005927224846720883 │ -└───────────────────────┘ -``` - -## h3EdgeLengthM {#h3edgelengthm} - -Информирует о среднем размере стороны шестигранника H3 в метрах - -``` sql -h3EdgeLengthM(resolution) -``` - -**Входные значения** - -- `resolution` — требуемое разрешение индекса. Тип данных — [UInt8](../../sql_reference/functions/geo.md). Диапазон возможных значений — `[0, 15]`. - -**Возвращаемые значения** - -Средняя длина стороны многоугольника H3 в метрах, тип — [Float64](../../sql_reference/functions/geo.md). - -**Пример** - -``` sql -SELECT h3EdgeLengthM(15) as edgeLengthM -``` - -``` text -┌─edgeLengthM─┐ -│ 0.509713273 │ -└─────────────┘ -``` - -## geoToH3 {#geotoh3} - -Возвращает H3 индекс точки `(lon, lat)` с заданным разрешением. - -[H3](https://uber.github.io/h3/#/documentation/overview/introduction) - это географическая система индексации, в которой поверхность Земли разделена на ровные шестиугольные плитки. Эта система иерархична, то есть каждый шестиугольник на верхнем уровне может быть разбит на семь еще более мелких и так далее. - -H3 индекс используется в основном для определения местоположения с помощью карт и других геопространственных манипуляций. - -**Синтаксис** - -``` sql -geoToH3(lon, lat, resolution) -``` - -**Параметры** - -- `lon` — географическая долгота. Тип данных — [Float64](../../sql_reference/functions/geo.md). -- `lat` — географическая широта. Тип данных — [Float64](../../sql_reference/functions/geo.md). -- `resolution` — требуемое разрешение индекса. Тип данных — [UInt8](../../sql_reference/functions/geo.md). Диапазон возможных значений — `[0, 15]`. - -**Возвращаемые значения** - -- Порядковый номер шестиугольника. -- 0 в случае ошибки. - -Тип — [UInt64](../../sql_reference/functions/geo.md). - -**Пример** - -Запрос: - -``` sql -SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index -``` - -Ответ: - -``` text -┌────────────h3Index─┐ -│ 644325524701193974 │ -└────────────────────┘ -``` - -## h3kRing {#h3kring} - -Возвращает H3-индексы шестиугольников в радиусе `k` от данного в произвольном порядке - -``` sql -h3kRing(h3index, k) -``` - -**Входные значения** - -- `h3index` — идентификатор шестиугольника. Тип данных — [UInt64](../../sql_reference/functions/geo.md). -- `k` — радиус. Тип данных — [целое число](../../sql_reference/functions/geo.md) - -**Возвращаемые значения** - -[Массив](../../sql_reference/functions/geo.md) из H3-индексов типа [UInt64](../../sql_reference/functions/geo.md). - -**Пример** - -``` sql -SELECT arrayJoin(h3kRing(644325529233966508, 1)) AS h3index -``` - -``` text -┌────────────h3index─┐ -│ 644325529233966508 │ -│ 644325529233966497 │ -│ 644325529233966510 │ -│ 644325529233966504 │ -│ 644325529233966509 │ -│ 644325529233966355 │ -│ 644325529233966354 │ -└────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/geo/) diff --git a/docs/ru/sql_reference/functions/hash_functions.md b/docs/ru/sql_reference/functions/hash_functions.md deleted file mode 100644 index 9dcd67ba35f..00000000000 --- a/docs/ru/sql_reference/functions/hash_functions.md +++ /dev/null @@ -1,479 +0,0 @@ -# Функции хэширования {#funktsii-kheshirovaniia} - -Функции хэширования могут использоваться для детерминированного псевдослучайного разбрасывания элементов. - -## halfMD5 {#hash-functions-halfmd5} - -[Интерпретирует](../../sql_reference/functions/hash_functions.md#type_conversion_functions-reinterpretAsString) все входные параметры как строки и вычисляет хэш [MD5](https://ru.wikipedia.org/wiki/MD5) для каждой из них. Затем объединяет хэши, берет первые 8 байт хэша результирующей строки и интерпретирует их как значение типа `UInt64` с big-endian порядком байтов. - -``` sql -halfMD5(par1, ...) -``` - -Функция относительно медленная (5 миллионов коротких строк в секунду на ядро процессора). -По возможности, используйте функцию [sipHash64](#hash_functions-siphash64) вместо неё. - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -Значение хэша с типом данных [UInt64](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type -``` - -``` text -┌────────halfMD5hash─┬─type───┐ -│ 186182704141653334 │ UInt64 │ -└────────────────────┴────────┘ -``` - -## MD5 {#hash_functions-md5} - -Вычисляет MD5 от строки и возвращает полученный набор байт в виде FixedString(16). -Если вам не нужен конкретно MD5, а нужен неплохой криптографический 128-битный хэш, то используйте вместо этого функцию sipHash128. -Если вы хотите получить такой же результат, как выдаёт утилита md5sum, напишите lower(hex(MD5(s))). - -## sipHash64 {#hash_functions-siphash64} - -Генерирует 64-х битное значение [SipHash](https://131002.net/siphash/). - -``` sql -sipHash64(par1,...) -``` - -Это криптографическая хэш-функция. Она работает по крайней мере в три раза быстрее, чем функция [MD5](#hash_functions-md5). - -Функция [интерпретирует](../../sql_reference/functions/hash_functions.md#type_conversion_functions-reinterpretAsString) все входные параметры как строки и вычисляет хэш MD5 для каждой из них. Затем комбинирует хэши по следующему алгоритму. - -1. После хэширования всех входных параметров функция получает массив хэшей. -2. Функция принимает первый и второй элементы и вычисляет хэш для массива из них. -3. Затем функция принимает хэш-значение, вычисленное на предыдущем шаге, и третий элемент исходного хэш-массива, и вычисляет хэш для массива из них. -4. Предыдущий шаг повторяется для всех остальных элементов исходного хэш-массива. - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -Значение хэша с типом данных [UInt64](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type -``` - -``` text -┌──────────────SipHash─┬─type───┐ -│ 13726873534472839665 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## sipHash128 {#hash_functions-siphash128} - -Вычисляет SipHash от строки. -Принимает аргумент типа String. Возвращает FixedString(16). -Отличается от sipHash64 тем, что финальный xor-folding состояния делается только до 128 бит. - -## cityHash64 {#cityhash64} - -Генерирует 64-х битное значение [CityHash](https://github.com/google/cityhash). - -``` sql -cityHash64(par1,...) -``` - -Это не криптографическая хэш-функция. Она использует CityHash алгоритм для строковых параметров и зависящую от реализации быструю некриптографическую хэш-функцию для параметров с другими типами данных. Функция использует комбинатор CityHash для получения конечных результатов. - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -Значение хэша с типом данных [UInt64](../../sql_reference/functions/hash_functions.md). - -**Примеры** - -Пример вызова: - -``` sql -SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type -``` - -``` text -┌─────────────CityHash─┬─type───┐ -│ 12072650598913549138 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -А вот так вы можете вычислить чексумму всей таблицы с точностью до порядка строк: - -``` sql -SELECT groupBitXor(cityHash64(*)) FROM table -``` - -## intHash32 {#inthash32} - -Вычисляет 32-битный хэш-код от целого числа любого типа. -Это сравнительно быстрая не криптографическая хэш-функция среднего качества для чисел. - -## intHash64 {#inthash64} - -Вычисляет 64-битный хэш-код от целого числа любого типа. -Работает быстрее, чем intHash32. Качество среднее. - -## SHA1 {#sha1} - -## SHA224 {#sha224} - -## SHA256 {#sha256} - -Вычисляет SHA-1, SHA-224, SHA-256 от строки и возвращает полученный набор байт в виде FixedString(20), FixedString(28), FixedString(32). -Функция работает достаточно медленно (SHA-1 - примерно 5 миллионов коротких строк в секунду на одном процессорном ядре, SHA-224 и SHA-256 - примерно 2.2 миллионов). -Рекомендуется использовать эти функции лишь в тех случаях, когда вам нужна конкретная хэш-функция и вы не можете её выбрать. -Даже в этих случаях, рекомендуется применять функцию оффлайн - заранее вычисляя значения при вставке в таблицу, вместо того, чтобы применять её при SELECT-ах. - -## URLHash(url\[, N\]) {#urlhashurl-n} - -Быстрая не криптографическая хэш-функция неплохого качества для строки, полученной из URL путём некоторой нормализации. -`URLHash(s)` - вычислить хэш от строки без одного завершающего символа `/`, `?` или `#` на конце, если там такой есть. -`URLHash(s, N)` - вычислить хэш от строки до N-го уровня в иерархии URL, без одного завершающего символа `/`, `?` или `#` на конце, если там такой есть. -Уровни аналогичные URLHierarchy. Функция специфична для Яндекс.Метрики. - -## farmHash64 {#farmhash64} - -Генерирует 64-х битное значение [FarmHash](https://github.com/google/farmhash). - -``` sql -farmHash64(par1, ...) -``` - -Из всех [доступных методов](https://github.com/google/farmhash/blob/master/src/farmhash.h) функция использует `Hash64`. - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -Значение хэша с типом данных [UInt64](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type -``` - -``` text -┌─────────────FarmHash─┬─type───┐ -│ 17790458267262532859 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## javaHash {#hash_functions-javahash} - -Вычисляет [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) от строки. `JavaHash` не отличается ни скоростью, ни качеством, поэтому эту функцию следует считать устаревшей. Используйте эту функцию, если вам необходимо получить значение хэша по такому же алгоритму. - -``` sql -SELECT javaHash(''); -``` - -**Возвращаемое значение** - -Хэш-значение типа `Int32`. - -Тип: `javaHash`. - -**Пример** - -Запрос: - -``` sql -SELECT javaHash('Hello, world!'); -``` - -Ответ: - -``` text -┌─javaHash('Hello, world!')─┐ -│ -1880044555 │ -└───────────────────────────┘ -``` - -## javaHashUTF16LE {#javahashutf16le} - -Вычисляет [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) от строки, при допущении, что строка представлена в кодировке `UTF-16LE`. - -**Синтаксис** - -``` sql -javaHashUTF16LE(stringUtf16le) -``` - -**Параметры** - -- `stringUtf16le` — строка в `UTF-16LE`. - -**Возвращаемое значение** - -Хэш-значение типа `Int32`. - -Тип: `javaHash`. - -**Пример** - -Верный запрос для строки кодированной в `UTF-16LE`. - -Запрос: - -``` sql -SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')) -``` - -Ответ: - -``` text -┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ -│ 3556498 │ -└──────────────────────────────────────────────────────────────┘ -``` - -## hiveHash {#hash-functions-hivehash} - -Вычисляет `HiveHash` от строки. - -``` sql -SELECT hiveHash(''); -``` - -`HiveHash` — это результат [JavaHash](#hash_functions-javahash) с обнулённым битом знака числа. Функция используется в [Apache Hive](https://en.wikipedia.org/wiki/Apache_Hive) вплоть до версии 3.0. - -**Возвращаемое значение** - -Хэш-значение типа `Int32`. - -Тип: `hiveHash`. - -**Пример** - -Запрос: - -``` sql -SELECT hiveHash('Hello, world!'); -``` - -Ответ: - -``` text -┌─hiveHash('Hello, world!')─┐ -│ 267439093 │ -└───────────────────────────┘ -``` - -## metroHash64 {#metrohash64} - -Генерирует 64-х битное значение [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/). - -``` sql -metroHash64(par1, ...) -``` - -**Параметры** - -Функция принимает переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -Значение хэша с типом данных [UInt64](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type -``` - -``` text -┌────────────MetroHash─┬─type───┐ -│ 14235658766382344533 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## jumpConsistentHash {#jumpconsistenthash} - -Вычисляет JumpConsistentHash от значения типа UInt64. -Имеет два параметра: ключ типа UInt64 и количество бакетов. Возвращает значение типа Int32. -Дополнительные сведения смотрите по ссылке: [JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) - -## murmurHash2\_32, murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} - -Генерирует значение [MurmurHash2](https://github.com/aappleby/smhasher). - -``` sql -murmurHash2_32(par1, ...) -murmurHash2_64(par1, ...) -``` - -**Параметры** - -Обе функции принимают переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -- Функция `murmurHash2_32` возвращает значение типа [UInt32](../../sql_reference/functions/hash_functions.md). -- Функция `murmurHash2_64` возвращает значение типа [UInt64](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type -``` - -``` text -┌──────────MurmurHash2─┬─type───┐ -│ 11832096901709403633 │ UInt64 │ -└──────────────────────┴────────┘ -``` - -## gccMurmurHash {#gccmurmurhash} - -Вычисляет 64-битное значение [MurmurHash2](https://github.com/aappleby/smhasher), используя те же hash seed, что и [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191). - -**Синтаксис** - -```sql -gccMurmurHash(par1, ...); -``` - -**Параметры** - -- `par1, ...` — Переменное число параметров. Каждый параметр может быть любого из [поддерживаемых типов данных](../../sql_reference/data_types/index.md). - -**Возвращаемое значение** - -- Вычисленный хэш-код. - -Тип: [UInt64](../../sql_reference/data_types/int_uint.md). - -**Примеры** - -Запрос: - -```sql -SELECT - gccMurmurHash(1, 2, 3) AS res1, - gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 -``` - -Результат: - -``` text -┌─────────────────res1─┬────────────────res2─┐ -│ 12384823029245979431 │ 1188926775431157506 │ -└──────────────────────┴─────────────────────┘ -``` - -## murmurHash3\_32, murmurHash3\_64 {#murmurhash3-32-murmurhash3-64} - -Генерирует значение [MurmurHash3](https://github.com/aappleby/smhasher). - -``` sql -murmurHash3_32(par1, ...) -murmurHash3_64(par1, ...) -``` - -**Параметры** - -Обе функции принимают переменное число входных параметров. Параметры могут быть любого [поддерживаемого типа данных](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -- Функция `murmurHash3_32` возвращает значение типа [UInt32](../../sql_reference/functions/hash_functions.md). -- Функция `murmurHash3_64` возвращает значение типа [UInt64](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3─┬─type───┐ -│ 2152717 │ UInt32 │ -└─────────────┴────────┘ -``` - -## murmurHash3\_128 {#murmurhash3-128} - -Генерирует значение [MurmurHash3](https://github.com/aappleby/smhasher). - -``` sql -murmurHash3_128( expr ) -``` - -**Параметры** - -- `expr` — [выражение](../syntax.md#syntax-expressions) возвращающее значение типа[String](../../sql_reference/functions/hash_functions.md). - -**Возвращаемое значение** - -Хэш-значение типа [FixedString(16)](../../sql_reference/functions/hash_functions.md). - -**Пример** - -``` sql -SELECT murmurHash3_128('example_string') AS MurmurHash3, toTypeName(MurmurHash3) AS type -``` - -``` text -┌─MurmurHash3──────┬─type────────────┐ -│ 6�1�4"S5KT�~~q │ FixedString(16) │ -└──────────────────┴─────────────────┘ -``` - -## xxHash32, xxHash64 {#hash-functions-xxhash32-xxhash64} - -Вычисляет `xxHash` от строки. Предлагается в двух вариантах: 32 и 64 бита. - -``` sql -SELECT xxHash32(''); - -OR - -SELECT xxHash64(''); -``` - -**Возвращаемое значение** - -Хэш-значение типа `Uint32` или `Uint64`. - -Тип: `xxHash`. - -**Пример** - -Запрос: - -``` sql -SELECT xxHash32('Hello, world!'); -``` - -Ответ: - -``` text -┌─xxHash32('Hello, world!')─┐ -│ 834093149 │ -└───────────────────────────┘ -``` - -**Смотрите также** - -- [xxHash](http://cyan4973.github.io/xxHash/). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/hash_functions/) diff --git a/docs/ru/sql_reference/functions/higher_order_functions.md b/docs/ru/sql_reference/functions/higher_order_functions.md deleted file mode 100644 index d6eb09f4353..00000000000 --- a/docs/ru/sql_reference/functions/higher_order_functions.md +++ /dev/null @@ -1,167 +0,0 @@ -# Функции высшего порядка {#higher-order-functions} - -## Оператор `->`, функция lambda(params, expr) {#operator-funktsiia-lambdaparams-expr} - -Позволяет описать лямбда-функцию для передачи в функцию высшего порядка. Слева от стрелочки стоит формальный параметр - произвольный идентификатор, или несколько формальных параметров - произвольные идентификаторы в кортеже. Справа от стрелочки стоит выражение, в котором могут использоваться эти формальные параметры, а также любые столбцы таблицы. - -Примеры: `x -> 2 * x, str -> str != Referer.` - -Функции высшего порядка, в качестве своего функционального аргумента могут принимать только лямбда-функции. - -В функции высшего порядка может быть передана лямбда-функция, принимающая несколько аргументов. В этом случае, в функцию высшего порядка передаётся несколько массивов одинаковых длин, которым эти аргументы будут соответствовать. - -Для некоторых функций, например [arrayCount](#higher_order_functions-array-count) или [arraySum](#higher_order_functions-array-sum), первый аргумент (лямбда-функция) может отсутствовать. В этом случае, подразумевается тождественное отображение. - -Для функций, перечисленных ниже, лямбда-функцию должна быть указана всегда: - -- [arrayMap](#higher_order_functions-array-map) -- [arrayFilter](#higher_order_functions-array-filter) -- [arrayFirst](#higher_order_functions-array-first) -- [arrayFirstIndex](#higher_order_functions-array-first-index) - -### arrayMap(func, arr1, …) {#higher_order_functions-array-map} - -Вернуть массив, полученный на основе результатов применения функции `func` к каждому элементу массива `arr`. - -Примеры: - -``` sql -SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; -``` - -``` text -┌─res─────┐ -│ [3,4,5] │ -└─────────┘ -``` - -Следующий пример показывает, как создать кортежи из элементов разных массивов: - -``` sql -SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res -``` - -``` text -┌─res─────────────────┐ -│ [(1,4),(2,5),(3,6)] │ -└─────────────────────┘ -``` - -Обратите внимание, что у функции `arrayMap` первый аргумент (лямбда-функция) не может быть опущен. - -### arrayFilter(func, arr1, …) {#higher_order_functions-array-filter} - -Вернуть массив, содержащий только те элементы массива `arr1`, для которых функция `func` возвращает не 0. - -Примеры: - -``` sql -SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res -``` - -``` text -┌─res───────────┐ -│ ['abc World'] │ -└───────────────┘ -``` - -``` sql -SELECT - arrayFilter( - (i, x) -> x LIKE '%World%', - arrayEnumerate(arr), - ['Hello', 'abc World'] AS arr) - AS res -``` - -``` text -┌─res─┐ -│ [2] │ -└─────┘ -``` - -Обратите внимание, что у функции `arrayFilter` первый аргумент (лямбда-функция) не может быть опущен. - -### arrayCount(\[func,\] arr1, …) {#higher_order_functions-array-count} - -Вернуть количество элементов массива `arr`, для которых функция func возвращает не 0. Если func не указана - вернуть количество ненулевых элементов массива. - -### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} - -Вернуть 1, если существует хотя бы один элемент массива `arr`, для которого функция func возвращает не 0. Иначе вернуть 0. - -### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} - -Вернуть 1, если для всех элементов массива `arr`, функция `func` возвращает не 0. Иначе вернуть 0. - -### arraySum(\[func,\] arr1, …) {#higher-order-functions-array-sum} - -Вернуть сумму значений функции `func`. Если функция не указана - просто вернуть сумму элементов массива. - -### arrayFirst(func, arr1, …) {#higher_order_functions-array-first} - -Вернуть первый элемент массива `arr1`, для которого функция func возвращает не 0. - -Обратите внимание, что у функции `arrayFirst` первый аргумент (лямбда-функция) не может быть опущен. - -### arrayFirstIndex(func, arr1, …) {#higher_order_functions-array-first-index} - -Вернуть индекс первого элемента массива `arr1`, для которого функция func возвращает не 0. - -Обратите внимание, что у функции `arrayFirstFilter` первый аргумент (лямбда-функция) не может быть опущен. - -### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} - -Возвращает массив из частичных сумм элементов исходного массива (сумма с накоплением). Если указана функция `func`, то значения элементов массива преобразуются этой функцией перед суммированием. - -Пример: - -``` sql -SELECT arrayCumSum([1, 1, 1, 1]) AS res -``` - -``` text -┌─res──────────┐ -│ [1, 2, 3, 4] │ -└──────────────┘ -``` - -### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} - -Возвращает отсортированный в восходящем порядке массив `arr1`. Если задана функция `func`, то порядок сортировки определяется результатом применения функции `func` на элементы массива (массивов). - -Для улучшения эффективности сортировки применяется [Преобразование Шварца](https://ru.wikipedia.org/wiki/%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5_%D0%A8%D0%B2%D0%B0%D1%80%D1%86%D0%B0). - -Пример: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); -``` - -``` text -┌─res────────────────┐ -│ ['world', 'hello'] │ -└────────────────────┘ -``` - -Подробная информация о методе `arraySort` приведена в разделе [Функции по работе с массивами](array_functions.md#array_functions-sort). - -### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} - -Возвращает отсортированный в нисходящем порядке массив `arr1`. Если задана функция `func`, то порядок сортировки определяется результатом применения функции `func` на элементы массива (массивов). - -Пример: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` text -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -Подробная информация о методе `arrayReverseSort` приведена в разделе [Функции по работе с массивами](array_functions.md#array_functions-reverse-sort). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/higher_order_functions/) diff --git a/docs/ru/sql_reference/functions/in_functions.md b/docs/ru/sql_reference/functions/in_functions.md deleted file mode 100644 index a5cdb1dc217..00000000000 --- a/docs/ru/sql_reference/functions/in_functions.md +++ /dev/null @@ -1,19 +0,0 @@ -# Функции для реализации оператора IN. {#funktsii-dlia-realizatsii-operatora-in} - -## in, notIn, globalIn, globalNotIn {#in-functions} - -Смотрите раздел [Операторы IN](../statements/select.md#select-in-operators). - -## tuple(x, y, …), оператор (x, y, …) {#tuplex-y-operator-x-y} - -Функция, позволяющая сгруппировать несколько столбцов. -Для столбцов, имеющих типы T1, T2, … возвращает кортеж типа Tuple(T1, T2, …), содержащий эти столбцы. Выполнение функции ничего не стоит. -Кортежи обычно используются как промежуточное значение в качестве аргумента операторов IN, или для создания списка формальных параметров лямбда-функций. Кортежи не могут быть записаны в таблицу. - -## tupleElement(tuple, n), оператор x.N {#tupleelementtuple-n-operator-x-n} - -Функция, позволяющая достать столбец из кортежа. -N - индекс столбца начиная с 1. N должно быть константой. N должно быть целым строго положительным числом не большим размера кортежа. -Выполнение функции ничего не стоит. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/in_functions/) diff --git a/docs/ru/sql_reference/functions/index.md b/docs/ru/sql_reference/functions/index.md deleted file mode 100644 index 1f7d736f691..00000000000 --- a/docs/ru/sql_reference/functions/index.md +++ /dev/null @@ -1,65 +0,0 @@ -# Функции {#funktsii} - -Функции бывают как минимум\* двух видов - обычные функции (называются просто, функциями) и агрегатные функции. Это совершенно разные вещи. Обычные функции работают так, как будто применяются к каждой строке по отдельности (для каждой строки, результат вычисления функции не зависит от других строк). Агрегатные функции аккумулируют множество значений из разных строк (то есть, зависят от целого множества строк). - -В этом разделе речь пойдёт об обычных функциях. Для агрегатных функций, смотрите раздел «Агрегатные функции». - -\* - есть ещё третий вид функций, к которым относится функция arrayJoin; также можно отдельно иметь ввиду табличные функции.\* - -## Строгая типизация {#strogaia-tipizatsiia} - -В ClickHouse, в отличие от стандартного SQL, типизация является строгой. То есть, не производится неявных преобразований между типами. Все функции работают для определённого набора типов. Это значит, что иногда вам придётся использовать функции преобразования типов. - -## Склейка одинаковых выражений {#skleika-odinakovykh-vyrazhenii} - -Все выражения в запросе, имеющие одинаковые AST (одинаковую запись или одинаковый результат синтаксического разбора), считаются имеющими одинаковые значения. Такие выражения склеиваются и исполняются один раз. Одинаковые подзапросы тоже склеиваются. - -## Типы результата {#tipy-rezultata} - -Все функции возвращают одно (не несколько, не ноль) значение в качестве результата. Тип результата обычно определяется только типами аргументов, но не значениями аргументов. Исключение - функция tupleElement (оператор a.N), а также функция toFixedString. - -## Константы {#konstanty} - -Для простоты, некоторые функции могут работать только с константами в качестве некоторых аргументов. Например, правый аргумент оператора LIKE должен быть константой. -Почти все функции возвращают константу для константных аргументов. Исключение - функции генерации случайных чисел. -Функция now возвращает разные значения для запросов, выполненных в разное время, но результат считается константой, так как константность важна лишь в пределах одного запроса. -Константное выражение также считается константой (например, правую часть оператора LIKE можно сконструировать из нескольких констант). - -Функции могут быть по-разному реализованы для константных и не константных аргументов (выполняется разный код). Но результат работы для константы и полноценного столбца, содержащего только одно такое же значение, должен совпадать. - -## Обработка NULL {#obrabotka-null} - -Функции имеют следующие виды поведения: - -- Если хотя бы один из аргументов функции — `NULL`, то результат функции тоже `NULL`. -- Специальное поведение, указанное в описании каждой функции отдельно. В исходном коде ClickHouse такие функции можно определить по свойству `UseDefaultImplementationForNulls=false`. - -## Неизменяемость {#neizmeniaemost} - -Функции не могут поменять значения своих аргументов - любые изменения возвращаются в качестве результата. Соответственно, от порядка записи функций в запросе, результат вычислений отдельных функций не зависит. - -## Обработка ошибок {#obrabotka-oshibok} - -Некоторые функции могут кидать исключения в случае ошибочных данных. В этом случае, выполнение запроса прерывается, и текст ошибки выводится клиенту. При распределённой обработке запроса, при возникновении исключения на одном из серверов, на другие серверы пытается отправиться просьба тоже прервать выполнение запроса. - -## Вычисление выражений-аргументов {#vychislenie-vyrazhenii-argumentov} - -В почти всех языках программирования, для некоторых операторов может не вычисляться один из аргументов. Обычно - для операторов `&&`, `||`, `?:`. -Но в ClickHouse, аргументы функций (операторов) вычисляются всегда. Это связано с тем, что вычисления производятся не по отдельности для каждой строки, а сразу для целых кусочков столбцов. - -## Выполнение функций при распределённой обработке запроса {#vypolnenie-funktsii-pri-raspredelionnoi-obrabotke-zaprosa} - -При распределённой обработке запроса, как можно большая часть стадий выполнения запроса производится на удалённых серверах, а оставшиеся стадии (слияние промежуточных результатов и всё, что дальше) - на сервере-инициаторе запроса. - -Это значит, что выполнение функций может производиться на разных серверах. -Например, в запросе `SELECT f(sum(g(x))) FROM distributed_table GROUP BY h(y),` -- если `distributed_table` имеет хотя бы два шарда, то функции g и h выполняются на удалённых серверах, а функция f - на сервере-инициаторе запроса; -- если `distributed_table` имеет только один шард, то все функции f, g, h выполняются на сервере этого шарда. - -Обычно результат выполнения функции не зависит от того, на каком сервере её выполнить. Но иногда это довольно важно. -Например, функции, работающие со словарями, будут использовать словарь, присутствующий на том сервере, на котором они выполняются. -Другой пример - функция `hostName` вернёт имя сервера, на котором она выполняется, и это можно использовать для служебных целей - чтобы в запросе `SELECT` сделать `GROUP BY` по серверам. - -Если функция в запросе выполняется на сервере-инициаторе запроса, а вам нужно, чтобы она выполнялась на удалённых серверах, вы можете обернуть её в агрегатную функцию any или добавить в ключ в `GROUP BY`. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/) diff --git a/docs/ru/sql_reference/functions/introspection.md b/docs/ru/sql_reference/functions/introspection.md deleted file mode 100644 index 41ffb114e09..00000000000 --- a/docs/ru/sql_reference/functions/introspection.md +++ /dev/null @@ -1,303 +0,0 @@ -# Функции интроспекции {#introspection-functions} - -Функции из этого раздела могут использоваться для интроспекции [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) и [DWARF](https://en.wikipedia.org/wiki/DWARF) в целях профилирования запросов. - -!!! warning "Предупреждение" - Эти функции выполняются медленно и могут приводить к нежелательным последствиям в плане безопасности. - -Для правильной работы функций интроспекции: - -- Установите пакет `clickhouse-common-static-dbg`. - -- Установите настройку [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) в 1. - -Из соображений безопасности данные функции отключены по умолчанию. - -ClickHouse сохраняет отчеты профилировщика в [журнал трассировки](../../operations/system_tables.md#system_tables-trace_log) в системной таблице. Убедитесь, что таблица и профилировщик настроены правильно. - -## addresssToLine {#addresstoline} - -Преобразует адрес виртуальной памяти внутри процесса сервера ClickHouse в имя файла и номер строки в исходном коде ClickHouse. - -Если вы используете официальные пакеты ClickHouse, вам необходимо установить следующий пакеты: `clickhouse-common-static-dbg`. - -**Синтаксис** - -``` sql -addressToLine(address_of_binary_instruction) -``` - -**Параметры** - -- `address_of_binary_instruction` ([Тип UInt64](../../sql_reference/functions/introspection.md))- Адрес инструкции в запущенном процессе. - -**Возвращаемое значение** - -- Имя файла исходного кода и номер строки в этом файле разделяются двоеточием. - - Например, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, где `199` — номер строки. - -- Имя бинарного файла, если функция не может найти отладочную информацию. - -- Пустая строка, если адрес не является допустимым. - -Тип: [String](../../sql_reference/functions/introspection.md). - -**Пример** - -Включение функций самоанализа: - -``` sql -SET allow_introspection_functions=1 -``` - -Выбор первой строки из списка `trace_log` системная таблица: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-19 -event_time: 2019-11-19 18:57:23 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 421b6855-1858-45a5-8f37-f383409d6d72 -trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] -``` - -То `trace` поле содержит трассировку стека в момент выборки. - -Получение имени файла исходного кода и номера строки для одного адреса: - -``` sql -SELECT addressToLine(94784076370703) \G -``` - -``` text -Row 1: -────── -addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -``` - -Применение функции ко всему стектрейсу: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines -FROM system.trace_log -LIMIT 1 -\G -``` - -Функция [arrayMap](higher_order_functions.md#higher_order_functions-array-map) позволяет обрабатывать каждый отдельный элемент массива `trace` с помощью функции `addressToLine`. Результат этой обработки вы видите в виде `trace_source_code_lines` колонки выходных данных. - -``` text -Row 1: -────── -trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so -/usr/lib/debug/usr/bin/clickhouse -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 -/usr/include/c++/9/bits/atomic_base.h:551 -/usr/lib/debug/usr/bin/clickhouse -/lib/x86_64-linux-gnu/libpthread-2.27.so -/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -``` - -## addressToSymbol {#addresstosymbol} - -Преобразует адрес виртуальной памяти внутри серверного процесса ClickHouse в символ из объектных файлов ClickHouse. - -**Синтаксис** - -``` sql -addressToSymbol(address_of_binary_instruction) -``` - -**Параметры** - -- `address_of_binary_instruction` ([Тип uint64](../../sql_reference/functions/introspection.md)) — Адрес инструкции в запущенном процессе. - -**Возвращаемое значение** - -- Символ из объектных файлов ClickHouse. -- Пустая строка, если адрес не является допустимым. - -Тип: [String](../../sql_reference/functions/introspection.md). - -**Пример** - -Включение функций самоанализа: - -``` sql -SET allow_introspection_functions=1 -``` - -Выбор первой строки из списка `trace_log` системная таблица: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -То `trace` поле содержит трассировку стека в момент выборки. - -Получение символа для одного адреса: - -``` sql -SELECT addressToSymbol(94138803686098) \G -``` - -``` text -Row 1: -────── -addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -``` - -Применение функции ко всей трассировке стека: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols -FROM system.trace_log -LIMIT 1 -\G -``` - -То [arrayMap](higher_order_functions.md#higher_order_functions-array-map) функция позволяет обрабатывать каждый отдельный элемент системы. `trace` массив по типу `addressToSymbols` функция. Результат этой обработки вы видите в виде `trace_symbols` колонка выходных данных. - -``` text -Row 1: -────── -trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE -_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb -_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb -_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE -_ZN2DB27AggregatingBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB28AsynchronousBlockInputStream9calculateEv -_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data -_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E -_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv -_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E -execute_native_thread_routine -start_thread -clone -``` - -## demangle {#demangle} - -Преобразует символ, который вы можете получить с помощью [addressstosymbol](#addresstosymbol) функция имя функции C++. - -**Синтаксис** - -``` sql -demangle(symbol) -``` - -**Параметры** - -- `symbol` ([Строка](../../sql_reference/functions/introspection.md)) - Символ из объектного файла. - -**Возвращаемое значение** - -- Имя функции C++. -- Пустая строка, если символ не является допустимым. - -Тип: [Строка](../../sql_reference/functions/introspection.md). - -**Пример** - -Включение функций самоанализа: - -``` sql -SET allow_introspection_functions=1 -``` - -Выбор первой строки из списка `trace_log` системная таблица: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -То `trace` поле содержит трассировку стека в момент выборки. - -Получение имени функции для одного адреса: - -``` sql -SELECT demangle(addressToSymbol(94138803686098)) \G -``` - -``` text -Row 1: -────── -demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -``` - -Применение функции ко всему стектрейсу: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions -FROM system.trace_log -LIMIT 1 -\G -``` - -Функция [arrayMap](higher_order_functions.md#higher_order_functions-array-map) позволяет обрабатывать каждый отдельный элемент массива `trace` с помощью функции `demangle`. - -``` text -Row 1: -────── -trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const -DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) -DB::AggregatingBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::AsynchronousBlockInputStream::calculate() -std::_Function_handler::_M_invoke(std::_Any_data const&) -ThreadPoolImpl::worker(std::_List_iterator) -ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const -ThreadPoolImpl::worker(std::_List_iterator) -execute_native_thread_routine -start_thread -clone -``` diff --git a/docs/ru/sql_reference/functions/ip_address_functions.md b/docs/ru/sql_reference/functions/ip_address_functions.md deleted file mode 100644 index 57485f6a812..00000000000 --- a/docs/ru/sql_reference/functions/ip_address_functions.md +++ /dev/null @@ -1,241 +0,0 @@ -# Функции для работы с IP-адресами {#funktsii-dlia-raboty-s-ip-adresami} - -## IPv4NumToString(num) {#ipv4numtostringnum} - -Принимает число типа UInt32. Интерпретирует его, как IPv4-адрес в big endian. Возвращает строку, содержащую соответствующий IPv4-адрес в формате A.B.C.D (числа в десятичной форме через точки). - -## IPv4StringToNum(s) {#ipv4stringtonums} - -Функция, обратная к IPv4NumToString. Если IPv4 адрес в неправильном формате, то возвращает 0. - -## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} - -Похоже на IPv4NumToString, но вместо последнего октета используется xxx. - -Пример: - -``` sql -SELECT - IPv4NumToStringClassC(ClientIP) AS k, - count() AS c -FROM test.hits -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─k──────────────┬─────c─┐ -│ 83.149.9.xxx │ 26238 │ -│ 217.118.81.xxx │ 26074 │ -│ 213.87.129.xxx │ 25481 │ -│ 83.149.8.xxx │ 24984 │ -│ 217.118.83.xxx │ 22797 │ -│ 78.25.120.xxx │ 22354 │ -│ 213.87.131.xxx │ 21285 │ -│ 78.25.121.xxx │ 20887 │ -│ 188.162.65.xxx │ 19694 │ -│ 83.149.48.xxx │ 17406 │ -└────────────────┴───────┘ -``` - -В связи с тем, что использование xxx весьма необычно, это может быть изменено в дальнейшем. Вам не следует полагаться на конкретный вид этого фрагмента. - -### IPv6NumToString(x) {#ipv6numtostringx} - -Принимает значение типа FixedString(16), содержащее IPv6-адрес в бинарном виде. Возвращает строку, содержащую этот адрес в текстовом виде. -IPv6-mapped IPv4 адреса выводится в формате ::ffff:111.222.33.44. Примеры: - -``` sql -SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr -``` - -``` text -┌─addr─────────┐ -│ 2a02:6b8::11 │ -└──────────────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ -│ 2a02:2168:aaa:bbbb::2 │ 24695 │ -│ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ -│ 2a02:6b8:0:fff::ff │ 16389 │ -│ 2a01:4f8:111:6666::2 │ 16016 │ -│ 2a02:2168:888:222::1 │ 15896 │ -│ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ -│ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ -│ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ -│ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ -│ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ -└─────────────────────────────────────────┴───────┘ -``` - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - -``` text -┌─IPv6NumToString(ClientIP6)─┬──────c─┐ -│ ::ffff:94.26.111.111 │ 747440 │ -│ ::ffff:37.143.222.4 │ 529483 │ -│ ::ffff:5.166.111.99 │ 317707 │ -│ ::ffff:46.38.11.77 │ 263086 │ -│ ::ffff:79.105.111.111 │ 186611 │ -│ ::ffff:93.92.111.88 │ 176773 │ -│ ::ffff:84.53.111.33 │ 158709 │ -│ ::ffff:217.118.11.22 │ 154004 │ -│ ::ffff:217.118.11.33 │ 148449 │ -│ ::ffff:217.118.11.44 │ 148243 │ -└────────────────────────────┴────────┘ -``` - -## IPv6StringToNum(s) {#ipv6stringtonums} - -Функция, обратная к IPv6NumToString. Если IPv6 адрес в неправильном формате, то возвращает строку из нулевых байт. -HEX может быть в любом регистре. - -## IPv4ToIPv6(x) {#ipv4toipv6x} - -Принимает число типа `UInt32`. Интерпретирует его, как IPv4-адрес в [big endian](https://en.wikipedia.org/wiki/Endianness). Возвращает значение `FixedString(16)`, содержащее адрес IPv6 в двоичном формате. Примеры: - -``` sql -SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr -``` - -``` text -┌─addr───────────────┐ -│ ::ffff:192.168.0.1 │ -└────────────────────┘ -``` - -## cutIPv6(x, bitsToCutForIPv6, bitsToCutForIPv4) {#cutipv6x-bitstocutforipv6-bitstocutforipv4} - -Принимает значение типа FixedString(16), содержащее IPv6-адрес в бинарном виде. Возвращает строку, содержащую адрес из указанного количества битов, удаленных в текстовом формате. Например: - -``` sql -WITH - IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, - IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 -SELECT - cutIPv6(ipv6, 2, 0), - cutIPv6(ipv4, 0, 2) -``` - -``` text -┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ -│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ -└─────────────────────────────────────┴─────────────────────┘ -``` - -## IPv4CIDRToRange(ipv4, cidr), {#ipv4cidrtorangeipv4-cidr} - -Принимает на вход IPv4 и значение `UInt8`, содержащее [CIDR](https://ru.wikipedia.org/wiki/Бесклассовая_адресация). Возвращает кортеж с двумя IPv4, содержащими нижний и более высокий диапазон подсети. - -``` sql -SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) -``` - -``` text -┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ -│ ('192.168.0.0','192.168.255.255') │ -└────────────────────────────────────────────┘ -``` - -## IPv6CIDRToRange(ipv6, cidr), {#ipv6cidrtorangeipv6-cidr} - -Принимает на вход IPv6 и значение `UInt8`, содержащее CIDR. Возвращает кортеж с двумя IPv6, содержащими нижний и более высокий диапазон подсети. - -``` sql -SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32) -``` - -``` text -┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ -│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ -└────────────────────────────────────────────────────────────────────────┘ -``` - -## toIPv4(string) {#toipv4string} - -Псевдоним функции `IPv4StringToNum()` которая принимает строку с адресом IPv4 и возвращает значение типа [IPv4](../../sql_reference/functions/ip_address_functions.md), которое равно значению, возвращаемому функцией `IPv4StringToNum()`. - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - toTypeName(IPv4StringToNum(IPv4_string)), - toTypeName(toIPv4(IPv4_string)) -``` - -``` text -┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ -│ UInt32 │ IPv4 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - hex(IPv4StringToNum(IPv4_string)), - hex(toIPv4(IPv4_string)) -``` - -``` text -┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ -│ ABE1822D │ ABE1822D │ -└───────────────────────────────────┴──────────────────────────┘ -``` - -## toIPv6(string) {#toipv6string} - -Псевдоним функции `IPv6StringToNum()` которая принимает строку с адресом IPv6 и возвращает значение типа [IPv6](../../sql_reference/functions/ip_address_functions.md), которое равно значению, возвращаемому функцией `IPv6StringToNum()`. - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - toTypeName(IPv6StringToNum(IPv6_string)), - toTypeName(toIPv6(IPv6_string)) -``` - -``` text -┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ -│ FixedString(16) │ IPv6 │ -└──────────────────────────────────────────┴─────────────────────────────────┘ -``` - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - hex(IPv6StringToNum(IPv6_string)), - hex(toIPv6(IPv6_string)) -``` - -``` text -┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ -│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ -└───────────────────────────────────┴──────────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/ip_address_functions/) diff --git a/docs/ru/sql_reference/functions/json_functions.md b/docs/ru/sql_reference/functions/json_functions.md deleted file mode 100644 index 290fa911e6c..00000000000 --- a/docs/ru/sql_reference/functions/json_functions.md +++ /dev/null @@ -1,224 +0,0 @@ -# Функции для работы с JSON. {#funktsii-dlia-raboty-s-json} - -В Яндекс.Метрике пользователями передаётся JSON в качестве параметров визитов. Для работы с таким JSON-ом, реализованы некоторые функции. (Хотя в большинстве случаев, JSON-ы дополнительно обрабатываются заранее, и полученные значения кладутся в отдельные столбцы в уже обработанном виде.) Все эти функции исходят из сильных допущений о том, каким может быть JSON, и при этом стараются почти ничего не делать. - -Делаются следующие допущения: - -1. Имя поля (аргумент функции) должно быть константой; -2. Считается, что имя поля в JSON-е закодировано некоторым каноническим образом. Например, `visitParamHas('{"abc":"def"}', 'abc') = 1`, но `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -3. Поля ищутся на любом уровне вложенности, без разбора. Если есть несколько подходящих полей - берётся первое. -4. В JSON-е нет пробельных символов вне строковых литералов. - -## visitParamHas(params, name) {#visitparamhasparams-name} - -Проверить наличие поля с именем name. - -## visitParamExtractUInt(params, name) {#visitparamextractuintparams-name} - -Распарсить UInt64 из значения поля с именем name. Если поле строковое - попытаться распарсить число из начала строки. Если такого поля нет, или если оно есть, но содержит не число, то вернуть 0. - -## visitParamExtractInt(params, name) {#visitparamextractintparams-name} - -Аналогично для Int64. - -## visitParamExtractFloat(params, name) {#visitparamextractfloatparams-name} - -Аналогично для Float64. - -## visitParamExtractBool(params, name) {#visitparamextractboolparams-name} - -Распарсить значение true/false. Результат - UInt8. - -## visitParamExtractRaw(params, name) {#visitparamextractrawparams-name} - -Вернуть значение поля, включая разделители. - -Примеры: - -``` sql -visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' -visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' -``` - -## visitParamExtractString(params, name) {#visitparamextractstringparams-name} - -Распарсить строку в двойных кавычках. У значения убирается экранирование. Если убрать экранированные символы не удалось, то возвращается пустая строка. - -Примеры: - -``` sql -visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' -visitParamExtractString('{"abc":"hello}', 'abc') = '' -``` - -На данный момент, не поддерживаются записанные в формате `\uXXXX\uYYYY` кодовые точки не из basic multilingual plane (они переводятся не в UTF-8, а в CESU-8). - -Следующие функции используют [simdjson](https://github.com/lemire/simdjson) который разработан под более сложные требования для разбора JSON. Упомянутое выше предположение 2 по-прежнему применимо. - -## isValidJSON(json) {#isvalidjsonjson} - -Проверяет, является ли переданная строка валидным json значением. - -Примеры: - -``` sql -SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 -SELECT isValidJSON('not a json') = 0 -``` - -## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} - -Если значение существует в документе JSON, то возвращается `1`. - -Если значение не существует, то возвращается `0`. - -Примеры: - -``` sql -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 -``` - -`indices_or_keys` — это список из нуля или более аргументов каждый из них может быть либо строкой либо целым числом. - -- Строка — это доступ к объекту по ключу. -- Положительное целое число — это доступ к n-му члену/ключу с начала. -- Отрицательное целое число — это доступ к n-му члену/ключу с конца. - -Адресация элементов по индексу начинается с 1, следовательно элемент 0 не существует. - -Вы можете использовать целые числа, чтобы адресовать как массивы JSON, так и JSON-объекты. - -Примеры: - -``` sql -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' -``` - -## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} - -Возвращает длину массива JSON или объекта JSON. - -Если значение не существует или имеет неверный тип, то возвращается `0`. - -Примеры: - -``` sql -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 -``` - -## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} - -Возвращает тип значения JSON. - -Если значение не существует, то возвращается `Null`. - -Примеры: - -``` sql -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' -``` - -## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} - -## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} - -## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} - -## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} - -Парсит JSON и извлекает значение. Эти функции аналогичны функциям `visitParam`. - -Если значение не существует или имеет неверный тип, то возвращается `0`. - -Примеры: - -``` sql -SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 -SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 -SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 -``` - -## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} - -Парсит JSON и извлекает строку. Эта функция аналогична функции `visitParamExtractString`. - -Если значение не существует или имеет неверный тип, то возвращается пустая строка. - -У значения убирается экранирование. Если убрать экранированные символы не удалось, то возвращается пустая строка. - -Примеры: - -``` sql -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' -SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' -SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' -``` - -## JSONExtract(json\[, indices\_or\_keys…\], return\_type) {#jsonextractjson-indices-or-keys-return-type} - -Парсит JSON и извлекает значение с заданным типом данных. - -Это обобщение предыдущих функций `JSONExtract`. -Это означает -`JSONExtract(..., 'String')` выдает такой же результат, как `JSONExtractString()`, -`JSONExtract(..., 'Float64')` выдает такой же результат, как `JSONExtractFloat()`. - -Примеры: - -``` sql -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL -SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 -SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' -SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' -``` - -## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} - -Разбор пар ключ-значение из JSON, где значение имеет тип данных ClickHouse. - -Пример: - -``` sql -SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; -``` - -## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} - -Возвращает часть JSON в виде строки, содержащей неразобранную подстроку. - -Если значение не существует, то возвращается пустая строка. - -Пример: - -``` sql -SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' -``` - -## JSONExtractArrayRaw(json\[, indices\_or\_keys\]…) {#jsonextractarrayrawjson-indices-or-keys} - -Возвращает массив из элементов JSON массива, каждый из которых представлен в виде строки с неразобранными подстроками из JSON. - -Если значение не существует или не является массивом, то возвращается пустой массив. - -Пример: - -``` sql -SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']' -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/json_functions/) diff --git a/docs/ru/sql_reference/functions/machine_learning_functions.md b/docs/ru/sql_reference/functions/machine_learning_functions.md deleted file mode 100644 index c5dd27d96af..00000000000 --- a/docs/ru/sql_reference/functions/machine_learning_functions.md +++ /dev/null @@ -1,13 +0,0 @@ -# Функции машинного обучения {#funktsii-mashinnogo-obucheniia} - -## evalMLMethod (prediction) {#machine_learning_methods-evalmlmethod} - -Предсказание с использованием подобранных регрессионных моделей. - -### Stochastic Linear Regression {#stochastic-linear-regression} - -Агрегатная функция [stochasticLinearRegression](../../sql_reference/functions/machine_learning_functions.md#agg_functions-stochasticlinearregression) реализует стохастический градиентный спуск, использую линейную модель и функцию потерь MSE. - -### Stochastic Logistic Regression {#stochastic-logistic-regression} - -Агрегатная функция [stochasticLogisticRegression](../../sql_reference/functions/machine_learning_functions.md#agg_functions-stochasticlogisticregression) реализует стохастический градиентный спуск для задачи бинарной классификации. diff --git a/docs/ru/sql_reference/functions/other_functions.md b/docs/ru/sql_reference/functions/other_functions.md deleted file mode 100644 index a0568cb262e..00000000000 --- a/docs/ru/sql_reference/functions/other_functions.md +++ /dev/null @@ -1,1029 +0,0 @@ -# Прочие функции {#prochie-funktsii} - -## hostName() {#hostname} - -Возвращает строку - имя хоста, на котором эта функция была выполнена. При распределённой обработке запроса, это будет имя хоста удалённого сервера, если функция выполняется на удалённом сервере. - -## FQDN {#fqdn} - -Возвращает полное имя домена. - -**Синтаксис** - -``` sql -fqdn(); -``` - -Эта функция регистронезависимая. - -**Возвращаемое значение** - -- Полное имя домена. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT FQDN(); -``` - -Ответ: - -``` text -┌─FQDN()──────────────────────────┐ -│ clickhouse.ru-central1.internal │ -└─────────────────────────────────┘ -``` - -## basename {#basename} - -Извлекает конечную часть строки после последнего слэша или бэкслэша. Функция часто используется для извлечения имени файла из пути. - -``` sql -basename( expr ) -``` - -**Параметры** - -- `expr` — Выражение, возвращающее значение типа [String](../../sql_reference/functions/other_functions.md). В результирующем значении все бэкслэши должны быть экранированы. - -**Возвращаемое значение** - -Строка, содержащая: - -- Конечную часть строки после последнего слэша или бэкслэша. - - Если входная строка содержит путь, заканчивающийся слэшем или бэкслэшем, например, `/` или `с:\`, функция возвращает пустую строку. - -- Исходная строка, если нет слэша или бэкслэша. - -**Пример** - -``` sql -SELECT 'some/long/path/to/file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some\\long\\path\\to\\file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some-file-name' AS a, basename(a) -``` - -``` text -┌─a──────────────┬─basename('some-file-name')─┐ -│ some-file-name │ some-file-name │ -└────────────────┴────────────────────────────┘ -``` - -## visibleWidth(x) {#visiblewidthx} - -Вычисляет приблизительную ширину при выводе значения в текстовом (tab-separated) виде на консоль. -Функция используется системой для реализации Pretty форматов. - -`NULL` представляется как строка, соответствующая отображению `NULL` в форматах `Pretty`. - -``` sql -SELECT visibleWidth(NULL) -``` - -``` text -┌─visibleWidth(NULL)─┐ -│ 4 │ -└────────────────────┘ -``` - -## toTypeName(x) {#totypenamex} - -Возвращает строку, содержащую имя типа переданного аргумента. - -Если на вход функции передать `NULL`, то она вернёт тип `Nullable(Nothing)`, что соответствует внутреннему представлению `NULL` в ClickHouse. - -## blockSize() {#function-blocksize} - -Получить размер блока. -В ClickHouse выполнение запроса всегда идёт по блокам (наборам кусочков столбцов). Функция позволяет получить размер блока, для которого её вызвали. - -## materialize(x) {#materializex} - -Превращает константу в полноценный столбец, содержащий только одно значение. -В ClickHouse полноценные столбцы и константы представлены в памяти по-разному. Функции по-разному работают для аргументов-констант и обычных аргументов (выполняется разный код), хотя результат почти всегда должен быть одинаковым. Эта функция предназначена для отладки такого поведения. - -## ignore(…) {#ignore} - -Принимает любые аргументы, в т.ч. `NULL`, всегда возвращает 0. -При этом, аргумент всё равно вычисляется. Это может использоваться для бенчмарков. - -## sleep(seconds) {#sleepseconds} - -Спит seconds секунд на каждый блок данных. Можно указать как целое число, так и число с плавающей запятой. - -## currentDatabase() {#currentdatabase} - -Возвращает имя текущей базы данных. -Эта функция может использоваться в параметрах движка таблицы в запросе CREATE TABLE там, где нужно указать базу данных. - -## currentUser() {#other-function-currentuser} - -Возвращает логин текущего пользователя. При распределенном запросе, возвращается имя пользователя, инициировавшего запрос. - -``` sql -SELECT currentUser(); -``` - -Алиас: `user()`, `USER()`. - -**Возвращаемые значения** - -- Логин текущего пользователя. -- При распределенном запросе — логин пользователя, инициировавшего запрос. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT currentUser(); -``` - -Ответ: - -``` text -┌─currentUser()─┐ -│ default │ -└───────────────┘ -``` - -## isFinite(x) {#isfinitex} - -Принимает Float32 или Float64 и возвращает UInt8, равный 1, если аргумент не бесконечный и не NaN, иначе 0. - -## ifNotFinite {#ifnotfinite} - -Проверяет, является ли значение дробного числа с плавающей точкой конечным. - -**Синтаксис** - - ifNotFinite(x,y) - -**Параметры** - -- `x` — Значение, которое нужно проверить на бесконечность. Тип: [Float\*](../../sql_reference/functions/other_functions.md). -- `y` — Запасное значение. Тип: [Float\*](../../sql_reference/functions/other_functions.md). - -**Возвращаемые значения** - -- `x`, если `x` принимает конечное значение. -- `y`, если`x` принимает не конечное значение. - -**Пример** - -Запрос: - - SELECT 1/0 as infimum, ifNotFinite(infimum,42) - -Результат: - - ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ - │ inf │ 42 │ - └─────────┴───────────────────────────────┘ - -Аналогичный результат можно получить с помощью [тернарного оператора](conditional_functions.md#ternary-operator) `isFinite(x) ? x : y`. - -## isInfinite(x) {#isinfinitex} - -Принимает Float32 или Float64 и возвращает UInt8, равный 1, если аргумент бесконечный, иначе 0. Отметим, что в случае NaN возвращается 0. - -## isNaN(x) {#isnanx} - -Принимает Float32 или Float64 и возвращает UInt8, равный 1, если аргумент является NaN, иначе 0. - -## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} - -Принимает константные строки - имя базы данных, имя таблицы и название столбца. Возвращает константное выражение типа UInt8, равное 1, -если есть столбец, иначе 0. Если задан параметр hostname, проверка будет выполнена на удалённом сервере. -Функция кидает исключение, если таблица не существует. -Для элементов вложенной структуры данных функция проверяет существование столбца. Для самой же вложенной структуры данных функция возвращает 0. - -## bar {#function-bar} - -Позволяет построить unicode-art диаграмму. - -`bar(x, min, max, width)` рисует полосу ширины пропорциональной `(x - min)` и равной `width` символов при `x = max`. - -Параметры: - -- `x` — Величина для отображения. -- `min, max` — Целочисленные константы, значение должно помещаться в `Int64`. -- `width` — Константа, положительное число, может быть дробным. - -Полоса рисуется с точностью до одной восьмой символа. - -Пример: - -``` sql -SELECT - toHour(EventTime) AS h, - count() AS c, - bar(c, 0, 600000, 20) AS bar -FROM test.hits -GROUP BY h -ORDER BY h ASC -``` - -``` text -┌──h─┬──────c─┬─bar────────────────┐ -│ 0 │ 292907 │ █████████▋ │ -│ 1 │ 180563 │ ██████ │ -│ 2 │ 114861 │ ███▋ │ -│ 3 │ 85069 │ ██▋ │ -│ 4 │ 68543 │ ██▎ │ -│ 5 │ 78116 │ ██▌ │ -│ 6 │ 113474 │ ███▋ │ -│ 7 │ 170678 │ █████▋ │ -│ 8 │ 278380 │ █████████▎ │ -│ 9 │ 391053 │ █████████████ │ -│ 10 │ 457681 │ ███████████████▎ │ -│ 11 │ 493667 │ ████████████████▍ │ -│ 12 │ 509641 │ ████████████████▊ │ -│ 13 │ 522947 │ █████████████████▍ │ -│ 14 │ 539954 │ █████████████████▊ │ -│ 15 │ 528460 │ █████████████████▌ │ -│ 16 │ 539201 │ █████████████████▊ │ -│ 17 │ 523539 │ █████████████████▍ │ -│ 18 │ 506467 │ ████████████████▊ │ -│ 19 │ 520915 │ █████████████████▎ │ -│ 20 │ 521665 │ █████████████████▍ │ -│ 21 │ 542078 │ ██████████████████ │ -│ 22 │ 493642 │ ████████████████▍ │ -│ 23 │ 400397 │ █████████████▎ │ -└────┴────────┴────────────────────┘ -``` - -## transform {#transform} - -Преобразовать значение согласно явно указанному отображению одних элементов на другие. -Имеется два варианта функции: - -### transform(x, array\_from, array\_to, default) {#transformx-array-from-array-to-default} - -`x` - что преобразовывать. - -`array_from` - константный массив значений для преобразования. - -`array_to` - константный массив значений, в которые должны быть преобразованы значения из from. - -`default` - какое значение использовать, если x не равен ни одному из значений во from. - -`array_from` и `array_to` - массивы одинаковых размеров. - -Типы: - -`transform(T, Array(T), Array(U), U) -> U` - -`T` и `U` - могут быть числовыми, строковыми, или Date или DateTime типами. -При этом, где обозначена одна и та же буква (T или U), могут быть, в случае числовых типов, не совпадающие типы, а типы, для которых есть общий тип. -Например, первый аргумент может иметь тип Int64, а второй - Array(UInt16). - -Если значение x равно одному из элементов массива array\_from, то возвращает соответствующий (такой же по номеру) элемент массива array\_to; иначе возвращает default. Если имеется несколько совпадающих элементов в array\_from, то возвращает какой-нибудь из соответствующих. - -Пример: - -``` sql -SELECT - transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, - count() AS c -FROM test.hits -WHERE SearchEngineID != 0 -GROUP BY title -ORDER BY c DESC -``` - -``` text -┌─title─────┬──────c─┐ -│ Yandex │ 498635 │ -│ Google │ 229872 │ -│ Other │ 104472 │ -└───────────┴────────┘ -``` - -### transform(x, array\_from, array\_to) {#transformx-array-from-array-to} - -Отличается от первого варианта отсутствующим аргументом default. -Если значение x равно одному из элементов массива array\_from, то возвращает соответствующий (такой же по номеру) элемент массива array\_to; иначе возвращает x. - -Типы: - -`transform(T, Array(T), Array(T)) -> T` - -Пример: - -``` sql -SELECT - transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, - count() AS c -FROM test.hits -GROUP BY domain(Referer) -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -┌─s──────────────┬───────c─┐ -│ │ 2906259 │ -│ www.yandex │ 867767 │ -│ ███████.ru │ 313599 │ -│ mail.yandex.ru │ 107147 │ -│ ██████.ru │ 100355 │ -│ █████████.ru │ 65040 │ -│ news.yandex.ru │ 64515 │ -│ ██████.net │ 59141 │ -│ example.com │ 57316 │ -└────────────────┴─────────┘ -``` - -## formatReadableSize(x) {#formatreadablesizex} - -Принимает размер (число байт). Возвращает округленный размер с суффиксом (KiB, MiB и т.д.) в виде строки. - -Пример: - -``` sql -SELECT - arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, - formatReadableSize(filesize_bytes) AS filesize -``` - -``` text -┌─filesize_bytes─┬─filesize───┐ -│ 1 │ 1.00 B │ -│ 1024 │ 1.00 KiB │ -│ 1048576 │ 1.00 MiB │ -│ 192851925 │ 183.92 MiB │ -└────────────────┴────────────┘ -``` - -## least(a, b) {#leasta-b} - -Возвращает наименьшее значение из a и b. - -## greatest(a, b) {#greatesta-b} - -Возвращает наибольшее значение из a и b. - -## uptime() {#uptime} - -Возвращает аптайм сервера в секундах. - -## version() {#version} - -Возвращает версию сервера в виде строки. - -## rowNumberInBlock {#function-rownumberinblock} - -Возвращает порядковый номер строки в блоке данных. Для каждого блока данных нумерация начинается с 0. - -## rowNumberInAllBlocks() {#rownumberinallblocks} - -Возвращает порядковый номер строки в блоке данных. Функция учитывает только задействованные блоки данных. - -## neighbor {#neighbor} - -Функция позволяет получить доступ к значению в колонке `column`, находящемуся на смещении `offset` относительно текущей строки. Является частичной реализацией [оконных функций](https://en.wikipedia.org/wiki/SQL_window_function) `LEAD()` и `LAG()`. - -**Синтаксис** - -``` sql -neighbor(column, offset[, default_value]) -``` - -Результат функции зависит от затронутых блоков данных и порядка данных в блоке. Если сделать подзапрос с ORDER BY и вызывать функцию извне подзапроса, можно будет получить ожидаемый результат. - -**Параметры** - -- `column` — Имя столбца или скалярное выражение. -- `offset` - Смещение от текущей строки `column`. [Int64](../../sql_reference/functions/other_functions.md). -- `default_value` - Опциональный параметр. Значение, которое будет возвращено, если смещение выходит за пределы блока данных. - -**Возвращаемое значение** - -- Значение `column` в смещении от текущей строки, если значение `offset` не выходит за пределы блока. -- Значение по умолчанию для `column`, если значение `offset` выходит за пределы блока данных. Если передан параметр `default_value`, то значение берется из него. - -Тип: зависит от данных в `column` или переданного значения по умолчанию в `default_value`. - -**Пример** - -Запрос: - -``` sql -SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10; -``` - -Ответ: - -``` text -┌─number─┬─neighbor(number, 2)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 0 │ -│ 9 │ 0 │ -└────────┴─────────────────────┘ -``` - -Запрос: - -``` sql -SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; -``` - -Ответ: - -``` text -┌─number─┬─neighbor(number, 2, 999)─┐ -│ 0 │ 2 │ -│ 1 │ 3 │ -│ 2 │ 4 │ -│ 3 │ 5 │ -│ 4 │ 6 │ -│ 5 │ 7 │ -│ 6 │ 8 │ -│ 7 │ 9 │ -│ 8 │ 999 │ -│ 9 │ 999 │ -└────────┴──────────────────────────┘ -``` - -Эта функция может использоваться для оценки year-over-year значение показателя: - -Запрос: - -``` sql -WITH toDate('2018-01-01') AS start_date -SELECT - toStartOfMonth(start_date + (number * 32)) AS month, - toInt32(month) % 100 AS money, - neighbor(money, -12) AS prev_year, - round(prev_year / money, 2) AS year_over_year -FROM numbers(16) -``` - -Ответ: - -``` text -┌──────month─┬─money─┬─prev_year─┬─year_over_year─┐ -│ 2018-01-01 │ 32 │ 0 │ 0 │ -│ 2018-02-01 │ 63 │ 0 │ 0 │ -│ 2018-03-01 │ 91 │ 0 │ 0 │ -│ 2018-04-01 │ 22 │ 0 │ 0 │ -│ 2018-05-01 │ 52 │ 0 │ 0 │ -│ 2018-06-01 │ 83 │ 0 │ 0 │ -│ 2018-07-01 │ 13 │ 0 │ 0 │ -│ 2018-08-01 │ 44 │ 0 │ 0 │ -│ 2018-09-01 │ 75 │ 0 │ 0 │ -│ 2018-10-01 │ 5 │ 0 │ 0 │ -│ 2018-11-01 │ 36 │ 0 │ 0 │ -│ 2018-12-01 │ 66 │ 0 │ 0 │ -│ 2019-01-01 │ 97 │ 32 │ 0.33 │ -│ 2019-02-01 │ 28 │ 63 │ 2.25 │ -│ 2019-03-01 │ 56 │ 91 │ 1.62 │ -│ 2019-04-01 │ 87 │ 22 │ 0.25 │ -└────────────┴───────┴───────────┴────────────────┘ -``` - -## runningDifference(x) {#runningdifferencex} - -Считает разницу между последовательными значениями строк в блоке данных. -Возвращает 0 для первой строки и разницу с предыдущей строкой для каждой последующей строки. - -Результат функции зависит от затронутых блоков данных и порядка данных в блоке. -Если сделать подзапрос с ORDER BY и вызывать функцию извне подзапроса, можно будет получить ожидаемый результат. - -Пример: - -``` sql -SELECT - EventID, - EventTime, - runningDifference(EventTime) AS delta -FROM -( - SELECT - EventID, - EventTime - FROM events - WHERE EventDate = '2016-11-24' - ORDER BY EventTime ASC - LIMIT 5 -) -``` - -``` text -┌─EventID─┬───────────EventTime─┬─delta─┐ -│ 1106 │ 2016-11-24 00:00:04 │ 0 │ -│ 1107 │ 2016-11-24 00:00:05 │ 1 │ -│ 1108 │ 2016-11-24 00:00:05 │ 0 │ -│ 1109 │ 2016-11-24 00:00:09 │ 4 │ -│ 1110 │ 2016-11-24 00:00:10 │ 1 │ -└─────────┴─────────────────────┴───────┘ -``` - -Обратите внимание — размер блока влияет на результат. С каждым новым блоком состояние `runningDifference` сбрасывается. - -``` sql -SELECT - number, - runningDifference(number + 1) AS diff -FROM numbers(100000) -WHERE diff != 1 -``` - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -┌─number─┬─diff─┐ -│ 65536 │ 0 │ -└────────┴──────┘ -``` - - set max_block_size=100000 -- по умолчанию 65536! - - SELECT - number, - runningDifference(number + 1) AS diff - FROM numbers(100000) - WHERE diff != 1 - -``` text -┌─number─┬─diff─┐ -│ 0 │ 0 │ -└────────┴──────┘ -``` - -## runningDifferenceStartingWithFirstValue {#runningdifferencestartingwithfirstvalue} - -То же, что и \[runningDifference\] (./other\_functions.md \# other\_functions-runningdifference), но в первой строке возвращается значение первой строки, а не ноль. - -## MACNumToString(num) {#macnumtostringnum} - -Принимает число типа UInt64. Интерпретирует его, как MAC-адрес в big endian. Возвращает строку, содержащую соответствующий MAC-адрес в формате AA:BB:CC:DD:EE:FF (числа в шестнадцатеричной форме через двоеточие). - -## MACStringToNum(s) {#macstringtonums} - -Функция, обратная к MACNumToString. Если MAC адрес в неправильном формате, то возвращает 0. - -## MACStringToOUI(s) {#macstringtoouis} - -Принимает MAC адрес в формате AA:BB:CC:DD:EE:FF (числа в шестнадцатеричной форме через двоеточие). Возвращает первые три октета как число в формате UInt64. Если MAC адрес в неправильном формате, то возвращает 0. - -## getSizeOfEnumType {#getsizeofenumtype} - -Возвращает количество полей в [Enum](../../sql_reference/functions/other_functions.md). - -``` sql -getSizeOfEnumType(value) -``` - -**Параметры** - -- `value` — Значение типа `Enum`. - -**Возвращаемые значения** - -- Количество полей входного значения типа `Enum`. -- Исключение, если тип не `Enum`. - -**Пример** - -``` sql -SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x -``` - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -## toColumnTypeName {#tocolumntypename} - -Возвращает имя класса, которым представлен тип данных столбца в оперативной памяти. - -``` sql -toColumnTypeName(value) -``` - -**Параметры** - -- `value` — Значение произвольного типа. - -**Возвращаемые значения** - -- Строка с именем класса, который используется для представления типа данных `value` в оперативной памяти. - -**Пример разницы между `toTypeName` и `toColumnTypeName`** - -``` sql -SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime │ -└─────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) -``` - -``` text -┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ Const(UInt32) │ -└───────────────────────────────────────────────────────────┘ -``` - -В примере видно, что тип данных `DateTime` хранится в памяти как `Const(UInt32)`. - -## dumpColumnStructure {#dumpcolumnstructure} - -Выводит развернутое описание структур данных в оперативной памяти - -``` sql -dumpColumnStructure(value) -``` - -**Параметры** - -- `value` — Значение произвольного типа. - -**Возвращаемые значения** - -- Строка с описанием структуры, которая используется для представления типа данных `value` в оперативной памяти. - -**Пример** - -``` sql -SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) -``` - -``` text -┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ -│ DateTime, Const(size = 1, UInt32(size = 1)) │ -└──────────────────────────────────────────────────────────────┘ -``` - -## defaultValueOfArgumentType {#defaultvalueofargumenttype} - -Выводит значение по умолчанию для типа данных. - -Не учитывает значения по умолчанию для столбцов, заданные пользователем. - -``` sql -defaultValueOfArgumentType(expression) -``` - -**Параметры** - -- `expression` — Значение произвольного типа или выражение, результатом которого является значение произвольного типа. - -**Возвращаемые значения** - -- `0` для чисел; -- Пустая строка для строк; -- `ᴺᵁᴸᴸ` для [Nullable](../../sql_reference/functions/other_functions.md). - -**Пример** - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ -│ 0 │ -└─────────────────────────────────────────────┘ -``` - -``` sql -SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) -``` - -``` text -┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ -│ ᴺᵁᴸᴸ │ -└───────────────────────────────────────────────────────┘ -``` - -## replicate {#other-functions-replicate} - -Создает массив, заполненный одним значением. - -Используется для внутренней реализации [arrayJoin](array_join.md#functions_arrayjoin). - -``` sql -SELECT replicate(x, arr); -``` - -**Параметры** - -- `arr` — Исходный массив. ClickHouse создаёт новый массив такой же длины как исходный и заполняет его значением `x`. -- `x` — Значение, которым будет заполнен результирующий массив. - -**Возвращаемое значение** - -Массив, заполненный значением `x`. - -Тип: `Array`. - -**Пример** - -Запрос: - -``` sql -SELECT replicate(1, ['a', 'b', 'c']); -``` - -Ответ: - -``` text -┌─replicate(1, ['a', 'b', 'c'])─┐ -│ [1,1,1] │ -└───────────────────────────────┘ -``` - -## filesystemAvailable {#filesystemavailable} - -Возвращает объём доступного для записи данных места на файловой системе. Он всегда меньше общего свободного места ([filesystemFree](#filesystemfree)), потому что некоторое пространство зарезервировано для нужд операционной системы. - -**Синтаксис** - -``` sql -filesystemAvailable() -``` - -**Возвращаемое значение** - -- Объём доступного для записи данных места в байтах. - -Тип: [UInt64](../../sql_reference/functions/other_functions.md). - -**Пример** - -Запрос: - -``` sql -SELECT formatReadableSize(filesystemAvailable()) AS "Available space", toTypeName(filesystemAvailable()) AS "Type"; -``` - -Ответ: - -``` text -┌─Available space─┬─Type───┐ -│ 30.75 GiB │ UInt64 │ -└─────────────────┴────────┘ -``` - -## filesystemFree {#filesystemfree} - -Возвращает объём свободного места на файловой системе. Смотрите также `filesystemAvailable`. - -**Синтаксис** - -``` sql -filesystemFree() -``` - -**Возвращаемое значение** - -- Объем свободного места в байтах. - -Тип: [UInt64](../../sql_reference/functions/other_functions.md). - -**Пример** - -Запрос: - -``` sql -SELECT formatReadableSize(filesystemFree()) AS "Free space", toTypeName(filesystemFree()) AS "Type"; -``` - -Ответ: - -``` text -┌─Free space─┬─Type───┐ -│ 32.39 GiB │ UInt64 │ -└────────────┴────────┘ -``` - -## filesystemCapacity {#filesystemcapacity} - -Возвращает информацию о ёмкости файловой системы в байтах. Для оценки должен быть настроен [путь](../../sql_reference/functions/other_functions.md#server_configuration_parameters-path) к каталогу с данными. - -**Синтаксис** - -``` sql -filesystemCapacity() -``` - -**Возвращаемое значение** - -- Информация о ёмкости файловой системы в байтах. - -Тип: [UInt64](../../sql_reference/functions/other_functions.md). - -**Пример** - -Запрос: - -``` sql -SELECT formatReadableSize(filesystemCapacity()) AS "Capacity", toTypeName(filesystemCapacity()) AS "Type" -``` - -Ответ: - -``` text -┌─Capacity──┬─Type───┐ -│ 39.32 GiB │ UInt64 │ -└───────────┴────────┘ -``` - -## finalizeAggregation {#function-finalizeaggregation} - -Принимает состояние агрегатной функции. Возвращает результат агрегирования. - -## runningAccumulate {#function-runningaccumulate} - -Принимает на вход состояния агрегатной функции и возвращает столбец со значениями, которые представляют собой результат мёржа этих состояний для выборки строк из блока от первой до текущей строки. Например, принимает состояние агрегатной функции (например, `runningAccumulate(uniqState(UserID))`), и для каждой строки блока возвращает результат агрегатной функции после мёржа состояний функции для всех предыдущих строк и текущей. Таким образом, результат зависит от разбиения данных по блокам и от порядка данных в блоке. - -## joinGet {#joinget} - -Функция позволяет извлекать данные из таблицы таким же образом как из [словаря](../../sql_reference/functions/other_functions.md). - -Получает данные из таблиц [Join](../../sql_reference/functions/other_functions.md#creating-a-table) по ключу. - -Поддерживаются только таблицы, созданные с `ENGINE = Join(ANY, LEFT, )`. - -**Синтаксис** - -``` sql -joinGet(join_storage_table_name, `value_column`, join_keys) -``` - -**Параметры** - -- `join_storage_table_name` — [идентификатор](../syntax.md#syntax-identifiers), который указывает, откуда производится выборка данных. Поиск по идентификатору осуществляется в базе данных по умолчанию (см. конфигурацию `default_database`). Чтобы переопределить базу данных по умолчанию, используйте команду `USE db_name`, или укажите базу данных и таблицу через разделитель `db_name.db_table`, см. пример. -- `value_column` — столбец, из которого нужно произвести выборку данных. -- `join_keys` — список ключей, по которым производится выборка данных. - -**Возвращаемое значение** - -Возвращает значение по списку ключей. - -Если значения не существует в исходной таблице, вернется `0` или `null` в соответствии с настройками [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls). - -Подробнее о настройке `join_use_nulls` в [операциях Join](../../sql_reference/functions/other_functions.md). - -**Пример** - -Входная таблица: - -``` sql -CREATE DATABASE db_test -CREATE TABLE db_test.id_val(`id` UInt32, `val` UInt32) ENGINE = Join(ANY, LEFT, id) SETTINGS join_use_nulls = 1 -INSERT INTO db_test.id_val VALUES (1,11)(2,12)(4,13) -``` - -``` text -┌─id─┬─val─┐ -│ 4 │ 13 │ -│ 2 │ 12 │ -│ 1 │ 11 │ -└────┴─────┘ -``` - -Запрос: - -``` sql -SELECT joinGet(db_test.id_val,'val',toUInt32(number)) from numbers(4) SETTINGS join_use_nulls = 1 -``` - -Результат: - -``` text -┌─joinGet(db_test.id_val, 'val', toUInt32(number))─┐ -│ 0 │ -│ 11 │ -│ 12 │ -│ 0 │ -└──────────────────────────────────────────────────┘ -``` - -## modelEvaluate(model\_name, …) {#function-modelevaluate} - -Оценивает внешнюю модель. - -Принимает на вход имя и аргументы модели. Возвращает Float64. - -## throwIf(x\[, custom\_message\]) {#throwifx-custom-message} - -Бросает исключение, если аргумент не равен нулю. -custom\_message - необязательный параметр, константная строка, задает текст сообщения об ошибке. - -``` sql -SELECT throwIf(number = 3, 'Too many') FROM numbers(10); -``` - -``` text -↙ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Received exception from server (version 19.14.1): -Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. -``` - -## identity {#identity} - -Возвращает свой аргумент. Используется для отладки и тестирования, позволяет отменить использование индекса, и получить результат и производительность полного сканирования таблицы. Это работает, потому что оптимизатор запросов не может «заглянуть» внутрь функции `identity`. - -**Синтаксис** - -``` sql -identity(x) -``` - -**Пример** - -Query: - -``` sql -SELECT identity(42) -``` - -Результат: - -``` text -┌─identity(42)─┐ -│ 42 │ -└──────────────┘ -``` - -## randomPrintableASCII {#randomascii} - -Генерирует строку со случайным набором печатных символов [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters). - -**Синтаксис** - -``` sql -randomPrintableASCII(length) -``` - -**Параметры** - -- `length` — Длина результирующей строки. Положительное целое число. - - Если передать `length < 0`, то поведение функции не определено. - -**Возвращаемое значение** - -- Строка со случайным набором печатных символов [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters). - -Тип: [String](../../sql_reference/functions/other_functions.md) - -**Пример** - -``` sql -SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3 -``` - -``` text -┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐ -│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │ -│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │ -│ 2 │ /"+<"wUTh:=LjJ Vm!c&hI*m#XTfzz │ 30 │ -└────────┴────────────────────────────────┴──────────────────────────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/other_functions/) diff --git a/docs/ru/sql_reference/functions/random_functions.md b/docs/ru/sql_reference/functions/random_functions.md deleted file mode 100644 index b6ce2b178ee..00000000000 --- a/docs/ru/sql_reference/functions/random_functions.md +++ /dev/null @@ -1,19 +0,0 @@ -# Функции генерации псевдослучайных чисел {#funktsii-generatsii-psevdosluchainykh-chisel} - -Используются не криптографические генераторы псевдослучайных чисел. - -Все функции принимают ноль аргументов или один аргумент. -В случае, если передан аргумент - он может быть любого типа, и его значение никак не используется. -Этот аргумент нужен только для того, чтобы предотвратить склейку одинаковых выражений - чтобы две разные записи одной функции возвращали разные столбцы, с разными случайными числами. - -## rand {#rand} - -Возвращает псевдослучайное число типа UInt32, равномерно распределённое среди всех чисел типа UInt32. -Используется linear congruential generator. - -## rand64 {#rand64} - -Возвращает псевдослучайное число типа UInt64, равномерно распределённое среди всех чисел типа UInt64. -Используется linear congruential generator. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/random_functions/) diff --git a/docs/ru/sql_reference/functions/rounding_functions.md b/docs/ru/sql_reference/functions/rounding_functions.md deleted file mode 100644 index 9e7947c109d..00000000000 --- a/docs/ru/sql_reference/functions/rounding_functions.md +++ /dev/null @@ -1,175 +0,0 @@ -# Функции округления {#funktsii-okrugleniia} - -## floor(x\[, N\]) {#floorx-n} - -Возвращает наибольшее круглое число, которое меньше или равно, чем x. -Круглым называется число, кратное 1 / 10N или ближайшее к нему число соответствующего типа данных, если 1 / 10N не представимо точно. -N - целочисленная константа, не обязательный параметр. По умолчанию - ноль, что означает - округлять до целого числа. -N может быть отрицательным. - -Примеры: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` - -`x` - любой числовой тип. Результат - число того же типа. -Для целочисленных аргументов имеет смысл округление с отрицательным значением N (для неотрицательных N, функция ничего не делает). -В случае переполнения при округлении (например, floor(-128, -1)), возвращается implementation specific результат. - -## ceil(x\[, N\]) {#ceilx-n} - -Возвращает наименьшее круглое число, которое больше или равно, чем x. -В остальном, аналогично функции floor, см. выше. - -## round(x\[, N\]) {#rounding_functions-round} - -Округляет значение до указанного десятичного разряда. - -Функция возвращает ближайшее значение указанного порядка. В случае, когда заданное число равноудалено от чисел необходимого порядка, функция возвращает то из них, которое имеет ближайшую чётную цифру (банковское округление). - -``` sql -round(expression [, decimal_places]) -``` - -**Параметры:** - -- `expression` — Число для округления. Может быть любым [выражением](../syntax.md#syntax-expressions), возвращающим числовой [тип данных](../../sql_reference/functions/rounding_functions.md#data_types). -- `decimal-places` — Целое значение. - - Если `decimal-places > 0`, то функция округляет значение справа от запятой. - - Если `decimal-places < 0` то функция округляет значение слева от запятой. - - Если `decimal-places = 0`, то функция округляет значение до целого. В этом случае аргумент можно опустить. - -**Возвращаемое значение:** - -Округлённое значение того же типа, что и входящее. - -### Примеры {#primery} - -**Пример использования** - -``` sql -SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 -``` - -``` text -┌───x─┬─round(divide(number, 2))─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -└─────┴──────────────────────────┘ -``` - -**Примеры округления** - -Округление до ближайшего числа. - -``` text -round(3.2, 0) = 3 -round(4.1267, 2) = 4.13 -round(22,-1) = 20 -round(467,-2) = 500 -round(-467,-2) = -500 -``` - -Банковское округление. - -``` text -round(3.5) = 4 -round(4.5) = 4 -round(3.55, 1) = 3.6 -round(3.65, 1) = 3.6 -``` - -**Смотрите также** - -- [roundBankers](#roundbankers) - -## roundBankers {#roundbankers} - -Округляет число до указанного десятичного разряда. - -- Если округляемое число равноудалено от соседних чисел, то используется банковское округление. - - Банковское округление (англ. banker's rounding) — метод округления дробных чисел. Если округляемое число равноудалено от соседних чисел, то оно округляется до ближайшей чётной цифры заданного десятичного разряда. К примеру, 3,5 округляется до 4, а 2,5 до 2. - - Этот метод округления, используемый по умолчанию для чисел с плавающей запятой, определён в стандарте [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest). Функция [round](#rounding_functions-round) также округляет числа с плавающей запятой по этому методу. Функция `roundBankers` округляет не только числа с плавающей запятой, но и целые числа методом банковского округления, например, `roundBankers(45, -1) = 40`. - -- В других случаях функция округляет к ближайшему целому. - -Банковское округление позволяет уменьшить влияние округления чисел на результат суммирования или вычитания этих чисел. - -Пример суммирования чисел 1.5, 2.5, 3.5 и 4.5 с различным округлением: - -- Без округления: 1.5 + 2.5 + 3.5 + 4.5 = 12. -- Банковское округление: 2 + 2 + 4 + 4 = 12. -- Округление до ближайшего целого: 2 + 3 + 4 + 5 = 14. - -**Синтаксис** - -``` sql -roundBankers(expression [, decimal_places]) -``` - -**Параметры** - -- `expression` — Число для округления. Может быть любым [выражением](../syntax.md#syntax-expressions), возвращающим числовой [тип данных](../../sql_reference/functions/rounding_functions.md#data_types). -- `decimal-places` — Десятичный разряд. Целое число. - - `decimal-places > 0` — Функция округляет значение выражения до ближайшего чётного числа на соответствующей позиции справа от запятой. Например, `roundBankers(3.55, 1) = 3.6`. - - `decimal-places < 0` — Функция округляет значение выражения до ближайшего чётного числа на соответствующей позиции слева от запятой. Например, `roundBankers(24.55, -1) = 20`. - - `decimal-places = 0` — Функция округляет значение до целого. В этом случае аргумент можно не передавать. Например, `roundBankers(2.5) = 2`. - -**Возвращаемое значение** - -Округлённое значение по методу банковского округления. - -**Пример использования** - -Запрос: - -``` sql - SELECT number / 2 AS x, roundBankers(x, 0) AS b fROM system.numbers limit 10 -``` - -Результат: - -``` text -┌───x─┬─b─┐ -│ 0 │ 0 │ -│ 0.5 │ 0 │ -│ 1 │ 1 │ -│ 1.5 │ 2 │ -│ 2 │ 2 │ -│ 2.5 │ 2 │ -│ 3 │ 3 │ -│ 3.5 │ 4 │ -│ 4 │ 4 │ -│ 4.5 │ 4 │ -└─────┴───┘ -``` - -**Примеры банковского округления** - -``` text -roundBankers(0.4) = 0 -roundBankers(-3.5) = -4 -roundBankers(4.5) = 4 -roundBankers(3.55, 1) = 3.6 -roundBankers(3.65, 1) = 3.6 -roundBankers(10.35, 1) = 10.4 -roundBankers(10.755, 2) = 11,76 -``` - -**Смотрите также** - -- [round](#rounding_functions-round) - -## roundToExp2(num) {#roundtoexp2num} - -Принимает число. Если число меньше единицы - возвращает 0. Иначе округляет число вниз до ближайшей (целой неотрицательной) степени двух. - -## roundDuration(num) {#rounddurationnum} - -Принимает число. Если число меньше единицы - возвращает 0. Иначе округляет число вниз до чисел из набора: 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000. Эта функция специфична для Яндекс.Метрики и предназначена для реализации отчёта по длительности визита. - -## roundAge(num) {#roundagenum} - -Принимает число. Если число меньше 18 - возвращает 0. Иначе округляет число вниз до чисел из набора: 18, 25, 35, 45, 55. Эта функция специфична для Яндекс.Метрики и предназначена для реализации отчёта по возрасту посетителей. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/rounding_functions/) diff --git a/docs/ru/sql_reference/functions/string_functions.md b/docs/ru/sql_reference/functions/string_functions.md deleted file mode 100644 index 5c51ad7c73c..00000000000 --- a/docs/ru/sql_reference/functions/string_functions.md +++ /dev/null @@ -1,482 +0,0 @@ -# Функции для работы со строками {#funktsii-dlia-raboty-so-strokami} - -## empty {#empty} - -Возвращает 1 для пустой строки, и 0 для непустой строки. -Тип результата — UInt8. -Строка считается непустой, если содержит хотя бы один байт, пусть даже это пробел или нулевой байт. -Функция также работает для массивов. - -## notEmpty {#notempty} - -Возвращает 0 для пустой строки, и 1 для непустой строки. -Тип результата — UInt8. -Функция также работает для массивов. - -## length {#length} - -Возвращает длину строки в байтах (не символах, не кодовых точках). -Тип результата — UInt64. -Функция также работает для массивов. - -## lengthUTF8 {#lengthutf8} - -Возвращает длину строки в кодовых точках Unicode (не символах), при допущении, что строка содержит набор байтов, являющийся текстом в кодировке UTF-8. Если допущение не выполнено, то возвращает какой-нибудь результат (не кидает исключение). -Тип результата — UInt64. - -## char\_length, CHAR\_LENGTH {#char-length} - -Возвращает длину строки в кодовых точках Unicode (не символах), при допущении, что строка содержит набор байтов, являющийся текстом в кодировке UTF-8. Если допущение не выполнено, возвращает какой-нибудь результат (не кидает исключение). -Тип результата — UInt64. - -## character\_length, CHARACTER\_LENGTH {#character-length} - -Возвращает длину строки в кодовых точках Unicode (не символах), при допущении, что строка содержит набор байтов, являющийся текстом в кодировке UTF-8. Если допущение не выполнено, возвращает какой-нибудь результат (не кидает исключение). -Тип результата — UInt64. - -## lower, lcase {#lower} - -Переводит ASCII-символы латиницы в строке в нижний регистр. - -## upper, ucase {#upper} - -Переводит ASCII-символы латиницы в строке в верхний регистр. - -## lowerUTF8 {#lowerutf8} - -Переводит строку в нижний регистр, при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. -Не учитывает язык. То есть, для турецкого языка, результат может быть не совсем верным. -Если длина UTF-8 последовательности байтов различна для верхнего и нижнего регистра кодовой точки, то для этой кодовой точки результат работы может быть некорректным. -Если строка содержит набор байтов, не являющийся UTF-8, то поведение не определено. - -## upperUTF8 {#upperutf8} - -Переводит строку в верхний регистр, при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. -Не учитывает язык. То есть, для турецкого языка, результат может быть не совсем верным. -Если длина UTF-8 последовательности байтов различна для верхнего и нижнего регистра кодовой точки, то для этой кодовой точки, результат работы может быть некорректным. -Если строка содержит набор байтов, не являющийся UTF-8, то поведение не определено. - -## isValidUTF8 {#isvalidutf8} - -Возвращает 1, если набор байтов является корректным в кодировке UTF-8, 0 иначе. - -## toValidUTF8 {#tovalidutf8} - -Заменяет некорректные символы UTF-8 на символ `�` (U+FFFD). Все идущие подряд некорректные символы схлопываются в один заменяющий символ. - -``` sql -toValidUTF8( input_string ) -``` - -Параметры: - -- input\_string — произвольный набор байтов, представленный как объект типа [String](../../sql_reference/functions/string_functions.md). - -Возвращаемое значение: Корректная строка UTF-8. - -**Пример** - -``` sql -SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') -``` - -``` text -┌─toValidUTF8('a����b')─┐ -│ a�b │ -└───────────────────────┘ -``` - -## repeat {#repeat} - -Повторяет строку определенное количество раз и объединяет повторяемые значения в одну строку. - -**Синтаксис** - -``` sql -repeat(s, n) -``` - -**Параметры** - -- `s` — Строка для повторения. [String](../../sql_reference/functions/string_functions.md). -- `n` — Количество повторов. [UInt](../../sql_reference/functions/string_functions.md). - -**Возвращаемое значение** - -Строка, состоящая из повторений `n` раз исходной строки `s`. Если `n` \< 1, то функция вернет пустую строку. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT repeat('abc', 10) -``` - -Ответ: - -``` text -┌─repeat('abc', 10)──────────────┐ -│ abcabcabcabcabcabcabcabcabcabc │ -└────────────────────────────────┘ -``` - -## reverse {#reverse} - -Разворачивает строку (как последовательность байтов). - -## reverseUTF8 {#reverseutf8} - -Разворачивает последовательность кодовых точек Unicode, при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. Иначе — что-то делает (не кидает исключение). - -## format(pattern, s0, s1, …) {#format} - -Форматирует константный шаблон со строками, перечисленными в аргументах. `pattern` — упрощенная версия шаблона в языке Python. Шаблон содержит «заменяющие поля», которые окружены фигурными скобками `{}`. Всё, что не содержится в скобках, интерпретируется как обычный текст и просто копируется. Если нужно использовать символ фигурной скобки, можно экранировать двойной скобкой `{{ '{{' }}` или `{{ '}}' }}`. Имя полей могут быть числами (нумерация с нуля) или пустыми (тогда они интерпретируются как последовательные числа). - -``` sql -SELECT format('{1} {0} {1}', 'World', 'Hello') -``` - -``` text -┌─format('{1} {0} {1}', 'World', 'Hello')─┐ -│ Hello World Hello │ -└─────────────────────────────────────────┘ -``` - -``` sql -SELECT format('{} {}', 'Hello', 'World') -``` - -``` text -┌─format('{} {}', 'Hello', 'World')─┐ -│ Hello World │ -└───────────────────────────────────┘ -``` - -## concat {#concat} - -Склеивает строки, переданные в аргументы, в одну строку без разделителей. - -**Cинтаксис** - -``` sql -concat(s1, s2, ...) -``` - -**Параметры** - -Значения типа String или FixedString. - -**Возвращаемое значение** - -Возвращает строку, полученную в результате склейки аргументов. - -Если любой из аргументов имеет значение `NULL`, `concat` возвращает значение `NULL`. - -**Пример** - -Запрос: - -``` sql -SELECT concat('Hello, ', 'World!') -``` - -Ответ: - -``` text -┌─concat('Hello, ', 'World!')─┐ -│ Hello, World! │ -└─────────────────────────────┘ -``` - -## concatAssumeInjective {#concatassumeinjective} - -Аналогична [concat](#concat). Разница заключается в том, что вам нужно убедиться, что `concat(s1, s2, ...) → sn` является инъективным, так как это предположение будет использоваться для оптимизации GROUP BY. - -Функция называется «инъективной», если она возвращает разные значения для разных аргументов. Или, иными словами, функция никогда не выдаёт одно и то же значение, если аргументы разные. - -**Синтаксис** - -``` sql -concatAssumeInjective(s1, s2, ...) -``` - -**Параметры** - -Значения типа String или FixedString. - -**Возвращаемые значения** - -Возвращает строку, полученную в результате объединения аргументов. - -Если любой из аргументов имеет значение `NULL`, `concatAssumeInjective` возвращает значение `NULL`. - -**Пример** - -Вводная таблица: - -``` sql -CREATE TABLE key_val(`key1` String, `key2` String, `value` UInt32) ENGINE = TinyLog -INSERT INTO key_val VALUES ('Hello, ','World',1)('Hello, ','World',2)('Hello, ','World!',3)('Hello',', World!',2) -SELECT * from key_val -``` - -``` text -┌─key1────┬─key2─────┬─value─┐ -│ Hello, │ World │ 1 │ -│ Hello, │ World │ 2 │ -│ Hello, │ World! │ 3 │ -│ Hello │ , World! │ 2 │ -└─────────┴──────────┴───────┘ -``` - -Запрос: - -``` sql -SELECT concat(key1, key2), sum(value) FROM key_val GROUP BY (key1, key2) -``` - -Ответ: - -``` text -┌─concat(key1, key2)─┬─sum(value)─┐ -│ Hello, World! │ 3 │ -│ Hello, World! │ 2 │ -│ Hello, World │ 3 │ -└────────────────────┴────────────┘ -``` - -## substring(s, offset, length), mid(s, offset, length), substr(s, offset, length) {#substring} - -Возвращает подстроку, начиная с байта по индексу offset, длины length байт. Индексация символов — начиная с единицы (как в стандартном SQL). Аргументы offset и length должны быть константами. - -## substringUTF8(s, offset, length) {#substringutf8} - -Так же, как substring, но для кодовых точек Unicode. Работает при допущении, что строка содержит набор байтов, представляющий текст в кодировке UTF-8. Если допущение не выполнено, то возвращает какой-нибудь результат (не кидает исключение). - -## appendTrailingCharIfAbsent(s, c) {#appendtrailingcharifabsent} - -Если строка s непустая и не содержит символ c на конце, то добавляет символ c в конец. - -## convertCharset(s, from, to) {#convertcharset} - -Возвращает сконвертированную из кодировки from в кодировку to строку s. - -## base64Encode(s) {#base64encode} - -Производит кодирование строки s в base64-представление. - -## base64Decode(s) {#base64decode} - -Декодирует base64-представление s в исходную строку. При невозможности декодирования выбрасывает исключение - -## tryBase64Decode(s) {#trybase64decode} - -Функционал аналогичен base64Decode, но при невозможности декодирования возвращает пустую строку. - -## endsWith(s, suffix) {#endswith} - -Возвращает 1, если строка завершается указанным суффиксом, и 0 в противном случае. - -## startsWith(str, prefix) {#startswith} - -Возвращает 1, если строка начинается указанным префиксом, в противном случае 0. - -``` sql -SELECT startsWith('Spider-Man', 'Spi'); -``` - -**Возвращаемые значения** - -- 1, если строка начинается указанным префиксом. -- 0, если строка не начинается указанным префиксом. - -**Пример** - -Запрос: - -``` sql -SELECT startsWith('Hello, world!', 'He'); -``` - -Ответ: - -``` text -┌─startsWith('Hello, world!', 'He')─┐ -│ 1 │ -└───────────────────────────────────┘ -``` - -## trim {#trim} - -Удаляет все указанные символы с начала или окончания строки. -По умолчанию удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с обоих концов строки. - -**Синтаксис** - -``` sql -trim([[LEADING|TRAILING|BOTH] trim_character FROM] input_string) -``` - -**Параметры** - -- `trim_character` — один или несколько символов, подлежащие удалению. [String](../../sql_reference/functions/string_functions.md). -- `input_string` — строка для обрезки. [String](../../sql_reference/functions/string_functions.md). - -**Возвращаемое значение** - -Исходную строку после обрезки с левого и (или) правого концов строки. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT trim(BOTH ' ()' FROM '( Hello, world! )') -``` - -Ответ: - -``` text -┌─trim(BOTH ' ()' FROM '( Hello, world! )')─┐ -│ Hello, world! │ -└───────────────────────────────────────────────┘ -``` - -## trimLeft {#trimleft} - -Удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с левого конца строки. Не удаляет другие виды пробелов (табуляция, пробел без разрыва и т. д.). - -**Синтаксис** - -``` sql -trimLeft(input_string) -``` - -Алиас: `ltrim(input_string)`. - -**Параметры** - -- `input_string` — строка для обрезки. [String](../../sql_reference/functions/string_functions.md). - -**Возвращаемое значение** - -Исходную строку без общих пробельных символов слева. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT trimLeft(' Hello, world! ') -``` - -Ответ: - -``` text -┌─trimLeft(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## trimRight {#trimright} - -Удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с правого конца строки. Не удаляет другие виды пробелов (табуляция, пробел без разрыва и т. д.). - -**Синтаксис** - -``` sql -trimRight(input_string) -``` - -Алиас: `rtrim(input_string)`. - -**Параметры** - -- `input_string` — строка для обрезки. [String](../../sql_reference/functions/string_functions.md). - -**Возвращаемое значение** - -Исходную строку без общих пробельных символов справа. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT trimRight(' Hello, world! ') -``` - -Ответ: - -``` text -┌─trimRight(' Hello, world! ')─┐ -│ Hello, world! │ -└──────────────────────────────────────┘ -``` - -## trimBoth {#trimboth} - -Удаляет все последовательные вхождения обычных пробелов (32 символ ASCII) с обоих концов строки. Не удаляет другие виды пробелов (табуляция, пробел без разрыва и т. д.). - -**Синтаксис** - -``` sql -trimBoth(input_string) -``` - -Алиас: `trim(input_string)`. - -**Параметры** - -- `input_string` — строка для обрезки. [String](../../sql_reference/functions/string_functions.md). - -**Возвращаемое значение** - -Исходную строку без общих пробельных символов с обоих концов строки. - -Тип: `String`. - -**Пример** - -Запрос: - -``` sql -SELECT trimBoth(' Hello, world! ') -``` - -Ответ: - -``` text -┌─trimBoth(' Hello, world! ')─┐ -│ Hello, world! │ -└─────────────────────────────────────┘ -``` - -## CRC32(s) {#crc32} - -Возвращает чексумму CRC32 данной строки, используется CRC-32-IEEE 802.3 многочлен и начальным значением `0xffffffff` (т.к. используется реализация из zlib). - -Тип результата — UInt32. - -## CRC32IEEE(s) {#crc32ieee} - -Возвращает чексумму CRC32 данной строки, используется CRC-32-IEEE 802.3 многочлен. - -Тип результата — UInt32. - -## CRC64(s) {#crc64} - -Возвращает чексумму CRC64 данной строки, используется CRC-64-ECMA многочлен. - -Тип результата — UInt64. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/string_functions/) diff --git a/docs/ru/sql_reference/functions/type_conversion_functions.md b/docs/ru/sql_reference/functions/type_conversion_functions.md deleted file mode 100644 index be4de7e7c89..00000000000 --- a/docs/ru/sql_reference/functions/type_conversion_functions.md +++ /dev/null @@ -1,518 +0,0 @@ -# Функции преобразования типов {#funktsii-preobrazovaniia-tipov} - -## Общие проблемы преобразования чисел {#numeric-conversion-issues} - -При преобразовании значения из одного типа в другой необходимо помнить, что в общем случае это небезопасная операция, которая может привести к потере данных. Потеря данных может произойти при попытке сконвертировать тип данных значения от большего к меньшему или при конвертировании между различными классами типов данных. - -Поведение ClickHouse при конвертировании похоже на [поведение C++ программ](https://en.cppreference.com/w/cpp/language/implicit_conversion). - -## toInt(8\|16\|32\|64) {#toint8163264} - -Преобразует входное значение к типу [Int](../../sql_reference/functions/type_conversion_functions.md). Семейство функций включает: - -- `toInt8(expr)` — возвращает значение типа `Int8`. -- `toInt16(expr)` — возвращает значение типа `Int16`. -- `toInt32(expr)` — возвращает значение типа `Int32`. -- `toInt64(expr)` — возвращает значение типа `Int64`. - -**Параметры** - -- `expr` — [выражение](../syntax.md#syntax-expressions) возвращающее число или строку с десятичным представление числа. Бинарное, восьмеричное и шестнадцатеричное представление числа не поддержаны. Ведущие нули обрезаются. - -**Возвращаемое значение** - -Целое число типа `Int8`, `Int16`, `Int32` или `Int64`. - -Функции используют [округление к нулю](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero), т.е. обрезают дробную часть числа. - -Поведение функций для аргументов [NaN и Inf](../../sql_reference/functions/type_conversion_functions.md#data_type-float-nan-inf) не определено. При использовании функций помните о возможных проблемах при [преобразовании чисел](#numeric-conversion-issues). - -**Пример** - -``` sql -SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) -``` - -``` text -┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ -│ -9223372036854775808 │ 32 │ 16 │ 8 │ -└──────────────────────┴─────────────┴───────────────┴─────────────┘ -``` - -## toInt(8\|16\|32\|64)OrZero {#toint8163264orzero} - -Принимает аргумент типа String и пытается его распарсить в Int(8\|16\|32\|64). Если не удалось - возвращает 0. - -**Пример** - -``` sql -select toInt64OrZero('123123'), toInt8OrZero('123qwe123') -``` - -``` text -┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ -│ 123123 │ 0 │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toInt(8\|16\|32\|64)OrNull {#toint8163264ornull} - -Принимает аргумент типа String и пытается его распарсить в Int(8\|16\|32\|64). Если не удалось - возвращает NULL. - -**Пример** - -``` sql -select toInt64OrNull('123123'), toInt8OrNull('123qwe123') -``` - -``` text -┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ -│ 123123 │ ᴺᵁᴸᴸ │ -└─────────────────────────┴───────────────────────────┘ -``` - -## toUInt(8\|16\|32\|64) {#touint8163264} - -Преобраует входное значение к типу [UInt](../../sql_reference/functions/type_conversion_functions.md). Семейство функций включает: - -- `toUInt8(expr)` — возвращает значение типа `UInt8`. -- `toUInt16(expr)` — возвращает значение типа `UInt16`. -- `toUInt32(expr)` — возвращает значение типа `UInt32`. -- `toUInt64(expr)` — возвращает значение типа `UInt64`. - -**Параметры** - -- `expr` — [выражение](../syntax.md#syntax-expressions) возвращающее число или строку с десятичным представление числа. Бинарное, восьмеричное и шестнадцатеричное представление числа не поддержаны. Ведущие нули обрезаются. - -**Возвращаемое значение** - -Целое число типа `UInt8`, `UInt16`, `UInt32` или `UInt64`. - -Функции используют [округление к нулю](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero), т.е. обрезают дробную часть числа. - -Поведение функций для аргументов [NaN и Inf](../../sql_reference/functions/type_conversion_functions.md#data_type-float-nan-inf) не определено. Если передать строку, содержащую отрицательное число, например `'-32'`, ClickHouse генерирует исключение. При использовании функций помните о возможных проблемах при [преобразовании чисел](#numeric-conversion-issues). - -**Пример** - -``` sql -SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) -``` - -``` text -┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ -│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ -└─────────────────────┴───────────────┴────────────────┴──────────────┘ -``` - -## toUInt(8\|16\|32\|64)OrZero {#touint8163264orzero} - -## toUInt(8\|16\|32\|64)OrNull {#touint8163264ornull} - -## toFloat(32\|64) {#tofloat3264} - -## toFloat(32\|64)OrZero {#tofloat3264orzero} - -## toFloat(32\|64)OrNull {#tofloat3264ornull} - -## toDate {#todate} - -## toDateOrZero {#todateorzero} - -## toDateOrNull {#todateornull} - -## toDateTime {#todatetime} - -## toDateTimeOrZero {#todatetimeorzero} - -## toDateTimeOrNull {#todatetimeornull} - -## toDecimal(32\|64\|128) {#todecimal3264128} - -Преобразует `value` к типу данных [Decimal](../../sql_reference/functions/type_conversion_functions.md) с точностью `S`. `value` может быть числом или строкой. Параметр `S` (scale) задаёт число десятичных знаков. - -- `toDecimal32(value, S)` -- `toDecimal64(value, S)` -- `toDecimal128(value, S)` - -## toDecimal(32\|64\|128)OrNull {#todecimal3264128ornull} - -Преобразует входную строку в значение с типом данных [Nullable (Decimal (P, S))](../../sql_reference/functions/type_conversion_functions.md). Семейство функций включает в себя: - -- `toDecimal32OrNull(expr, S)` — Возвращает значение типа `Nullable(Decimal32(S))`. -- `toDecimal64OrNull(expr, S)` — Возвращает значение типа `Nullable(Decimal64(S))`. -- `toDecimal128OrNull(expr, S)` — Возвращает значение типа `Nullable(Decimal128(S))`. - -Эти функции следует использовать вместо функций `toDecimal*()`, если при ошибке обработки входного значения вы хотите получать `NULL` вместо исключения. - -**Параметры** - -- `expr` — [выражение](../syntax.md#syntax-expressions), возвращающее значение типа [String](../../sql_reference/functions/type_conversion_functions.md). ClickHouse ожидает текстовое представление десятичного числа. Например, `'1.111'`. -- `S` — количество десятичных знаков в результирующем значении. - -**Возвращаемое значение** - -Значение типа `Nullable(Decimal(P,S))`. Значение содержит: - -- Число с `S` десятичными знаками, если ClickHouse распознал число во входной строке. -- `NULL`, если ClickHouse не смог распознать число во входной строке или входное число содержит больше чем `S` десятичных знаков. - -**Примеры** - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ -│ -1.11100 │ Nullable(Decimal(9, 5)) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ -│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toDecimal(32\|64\|128)OrZero {#todecimal3264128orzero} - -Преобразует тип входного значения в [Decimal (P, S)](../../sql_reference/functions/type_conversion_functions.md). Семейство функций включает в себя: - -- `toDecimal32OrZero( expr, S)` — возвращает значение типа `Decimal32(S)`. -- `toDecimal64OrZero( expr, S)` — возвращает значение типа `Decimal64(S)`. -- `toDecimal128OrZero( expr, S)` — возвращает значение типа `Decimal128(S)`. - -Эти функции следует использовать вместо функций `toDecimal*()`, если при ошибке обработки входного значения вы хотите получать `0` вместо исключения. - -**Параметры** - -- `expr` — [выражение](../syntax.md#syntax-expressions), возвращающее значение типа [String](../../sql_reference/functions/type_conversion_functions.md). ClickHouse ожидает текстовое представление десятичного числа. Например, `'1.111'`. -- `S` — количество десятичных знаков в результирующем значении. - -**Возвращаемое значение** - -Значение типа `Nullable(Decimal(P,S))`. `P` равно числовой части имени функции. Например, для функции `toDecimal32OrZero`, `P = 32`. Значение содержит: - -- Число с `S` десятичными знаками, если ClickHouse распознал число во входной строке. -- 0 c `S` десятичными знаками, если ClickHouse не смог распознать число во входной строке или входное число содержит больше чем `S` десятичных знаков. - -**Пример** - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) -``` - -``` text -┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ -│ -1.11100 │ Decimal(9, 5) │ -└──────────┴────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) -``` - -``` text -┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ -│ 0.00 │ Decimal(9, 2) │ -└──────┴────────────────────────────────────────────────────┘ -``` - -## toString {#tostring} - -Функции преобразования между числами, строками (но не фиксированными строками), датами и датами-с-временем. -Все эти функции принимают один аргумент. - -При преобразовании в строку или из строки, производится форматирование или парсинг значения по тем же правилам, что и для формата TabSeparated (и почти всех остальных текстовых форматов). Если распарсить строку не удаётся - кидается исключение и выполнение запроса прерывается. - -При преобразовании даты в число или наоборот, дате соответствует число дней от начала unix эпохи. -При преобразовании даты-с-временем в число или наоборот, дате-с-временем соответствует число секунд от начала unix эпохи. - -Форматы даты и даты-с-временем для функций toDate/toDateTime определены следующим образом: - -``` text -YYYY-MM-DD -YYYY-MM-DD hh:mm:ss -``` - -В качестве исключения, если делается преобразование из числа типа UInt32, Int32, UInt64, Int64 в Date, и если число больше или равно 65536, то число рассматривается как unix timestamp (а не как число дней) и округляется до даты. Это позволяет поддержать распространённый случай, когда пишут toDate(unix\_timestamp), что иначе было бы ошибкой и требовало бы написания более громоздкого toDate(toDateTime(unix\_timestamp)) - -Преобразование между датой и датой-с-временем производится естественным образом: добавлением нулевого времени или отбрасыванием времени. - -Преобразование между числовыми типами производится по тем же правилам, что и присваивание между разными числовыми типами в C++. - -Дополнительно, функция toString от аргумента типа DateTime может принимать второй аргумент String - имя тайм-зоны. Пример: `Asia/Yekaterinburg` В этом случае, форматирование времени производится согласно указанной тайм-зоне. - -``` sql -SELECT - now() AS now_local, - toString(now(), 'Asia/Yekaterinburg') AS now_yekat -``` - -``` text -┌───────────now_local─┬─now_yekat───────────┐ -│ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ -└─────────────────────┴─────────────────────┘ -``` - -Также смотрите функцию `toUnixTimestamp`. - -## toFixedString(s, N) {#tofixedstrings-n} - -Преобразует аргумент типа String в тип FixedString(N) (строку фиксированной длины N). N должно быть константой. -Если строка имеет меньше байт, чем N, то она дополняется нулевыми байтами справа. Если строка имеет больше байт, чем N - кидается исключение. - -## toStringCutToZero(s) {#tostringcuttozeros} - -Принимает аргумент типа String или FixedString. Возвращает String, вырезая содержимое строки до первого найденного нулевого байта. - -Пример: - -``` sql -SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s─────────────┬─s_cut─┐ -│ foo\0\0\0\0\0 │ foo │ -└───────────────┴───────┘ -``` - -``` sql -SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut -``` - -``` text -┌─s──────────┬─s_cut─┐ -│ foo\0bar\0 │ foo │ -└────────────┴───────┘ -``` - -## reinterpretAsUInt(8\|16\|32\|64) {#reinterpretasuint8163264} - -## reinterpretAsInt(8\|16\|32\|64) {#reinterpretasint8163264} - -## reinterpretAsFloat(32\|64) {#reinterpretasfloat3264} - -## reinterpretAsDate {#reinterpretasdate} - -## reinterpretAsDateTime {#reinterpretasdatetime} - -Функции принимают строку и интерпретируют байты, расположенные в начале строки, как число в host order (little endian). Если строка имеет недостаточную длину, то функции работают так, как будто строка дополнена необходимым количеством нулевых байт. Если строка длиннее, чем нужно, то лишние байты игнорируются. Дата интерпретируется, как число дней с начала unix-эпохи, а дата-с-временем - как число секунд с начала unix-эпохи. - -## reinterpretAsString {#type_conversion_functions-reinterpretAsString} - -Функция принимает число или дату или дату-с-временем и возвращает строку, содержащую байты, представляющие соответствующее значение в host order (little endian). При этом, отбрасываются нулевые байты с конца. Например, значение 255 типа UInt32 будет строкой длины 1 байт. - -## CAST(x, t) {#type_conversion_function-cast} - -Преобразует x в тип данных t. -Поддерживается также синтаксис CAST(x AS t). - -Пример: - -``` sql -SELECT - '2016-06-15 23:00:00' AS timestamp, - CAST(timestamp AS DateTime) AS datetime, - CAST(timestamp AS Date) AS date, - CAST(timestamp, 'String') AS string, - CAST(timestamp, 'FixedString(22)') AS fixed_string -``` - -``` text -┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ -│ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ -└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ -``` - -Преобразование в FixedString(N) работает только для аргументов типа String или FixedString(N). - -Поддержано преобразование к типу [Nullable](../../sql_reference/functions/type_conversion_functions.md) и обратно. Пример: - -``` sql -SELECT toTypeName(x) FROM t_null -``` - -``` text -┌─toTypeName(x)─┐ -│ Int8 │ -│ Int8 │ -└───────────────┘ -``` - -``` sql -SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null -``` - -``` text -┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ -│ Nullable(UInt16) │ -│ Nullable(UInt16) │ -└─────────────────────────────────────────┘ -``` - -## toInterval(Year\|Quarter\|Month\|Week\|Day\|Hour\|Minute\|Second) {#function-tointerval} - -Приводит аргумент из числового типа данных к типу данных [IntervalType](../../sql_reference/functions/type_conversion_functions.md). - -**Синтаксис** - -``` sql -toIntervalSecond(number) -toIntervalMinute(number) -toIntervalHour(number) -toIntervalDay(number) -toIntervalWeek(number) -toIntervalMonth(number) -toIntervalQuarter(number) -toIntervalYear(number) -``` - -**Параметры** - -- `number` — длительность интервала. Положительное целое число. - -**Возвращаемые значения** - -- Значение с типом данных `Interval`. - -**Пример** - -``` sql -WITH - toDate('2019-01-01') AS date, - INTERVAL 1 WEEK AS interval_week, - toIntervalWeek(1) AS interval_to_week -SELECT - date + interval_week, - date + interval_to_week -``` - -``` text -┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ -│ 2019-01-08 │ 2019-01-08 │ -└───────────────────────────┴──────────────────────────────┘ -``` - -## parseDateTimeBestEffort {#parsedatetimebesteffort} - -Преобразует дату и время в [строковом](../../sql_reference/functions/type_conversion_functions.md) представлении к типу данных [DateTime](../../sql_reference/functions/type_conversion_functions.md#data_type-datetime). - -Функция распознаёт форматы [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55), формат даты времени ClickHouse's а также некоторые другие форматы. - -**Синтаксис** - -```sql -parseDateTimeBestEffort(time_string[, time_zone]); -``` - -**Параметры** - -- `time_string` — строка, содержащая дату и время для преобразования. [String](../../sql_reference/functions/type_conversion_functions.md). -- `time_zone` — часовой пояс. Функция анализирует `time_string` в соответствии с заданным часовым поясом. [String](../../sql_reference/functions/type_conversion_functions.md). - -**Поддерживаемые нестандартные форматы** - -- [Unix timestamp](https://ru.wikipedia.org/wiki/Unix-время) в строковом представлении. 9 или 10 символов. -- Строка с датой и временем: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`, etc. -- Строка с датой, но без времени: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` и т.д. -- Строка с временем, и с днём: `DD`, `DD hh`, `DD hh:mm`. В этом случае `YYYY-MM` принимается равным `2000-01`. -- Строка, содержащая дату и время вместе с информацией о часовом поясе: `YYYY-MM-DD hh:mm:ss ±h:mm`, и т.д. Например, `2020-12-12 17:36:00 -5:00`. - -Для всех форматов с разделителями функция распознаёт названия месяцев, выраженных в виде полного англоязычного имени месяца или в виде первых трёх символов имени месяца. Примеры: `24/DEC/18`, `24-Dec-18`, `01-September-2018`. - - -**Возвращаемое значение** - -- `time_string` преобразованная к типу данных `DateTime`. - -**Примеры** - -Запрос: - -```sql -SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') -AS parseDateTimeBestEffort; -``` - -Результат: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2020-12-12 12:12:57 │ -└─────────────────────────┘ -``` - -Запрос: - -```sql -SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') -AS parseDateTimeBestEffort -``` - -Результат: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2018-08-18 10:22:16 │ -└─────────────────────────┘ -``` - -Запрос: - -```sql -SELECT parseDateTimeBestEffort('1284101485') -AS parseDateTimeBestEffort -``` - -Результат: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2015-07-07 12:04:41 │ -└─────────────────────────┘ -``` - -Запрос: - -```sql -SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') -AS parseDateTimeBestEffort -``` - -Результат: - -```text -┌─parseDateTimeBestEffort─┐ -│ 2018-12-12 10:12:12 │ -└─────────────────────────┘ -``` - -Запрос: - -```sql -SELECT parseDateTimeBestEffort('10 20:19') -``` - -Результат: - -```text -┌─parseDateTimeBestEffort('10 20:19')─┐ -│ 2000-01-10 20:19:00 │ -└─────────────────────────────────────┘ -``` - -**См. также** - -- [Информация о формате ISO 8601 от @xkcd](https://xkcd.com/1179/) -- [RFC 1123](https://tools.ietf.org/html/rfc1123) -- [toDate](#todate) -- [toDateTime](#todatetime) - - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/type_conversion_functions/) diff --git a/docs/ru/sql_reference/functions/url_functions.md b/docs/ru/sql_reference/functions/url_functions.md deleted file mode 100644 index f024cfdcfd9..00000000000 --- a/docs/ru/sql_reference/functions/url_functions.md +++ /dev/null @@ -1,201 +0,0 @@ -# Функции для работы с URL {#funktsii-dlia-raboty-s-url} - -Все функции работают не по RFC - то есть, максимально упрощены ради производительности. - -## Функции, извлекающие часть URL-а. {#funktsii-izvlekaiushchie-chast-url-a} - -Если в URL-е нет ничего похожего, то возвращается пустая строка. - -### protocol {#protocol} - -Возвращает протокол. Примеры: http, ftp, mailto, magnet… - -### domain {#domain} - -Извлекает имя хоста из URL. - -``` sql -domain(url) -``` - -**Параметры** - -- `url` — URL. Тип — [String](../../sql_reference/functions/url_functions.md). - -URL может быть указан со схемой или без неё. Примеры: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -Для указанных примеров функция `domain` возвращает следующие результаты: - -``` text -some.svn-hosting.com -some.svn-hosting.com -yandex.com -``` - -**Возвращаемые значения** - -- Имя хоста. Если ClickHouse может распарсить входную строку как URL. -- Пустая строка. Если ClickHouse не может распарсить входную строку как URL. - -Тип — `String`. - -**Пример** - -``` sql -SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐ -│ some.svn-hosting.com │ -└────────────────────────────────────────────────────────┘ -``` - -### domainWithoutWWW {#domainwithoutwww} - -Возвращает домен, удалив префикс ‘www.’, если он присутствовал. - -### topLevelDomain {#topleveldomain} - -Извлекает домен верхнего уровня из URL. - -``` sql -topLevelDomain(url) -``` - -**Параметры** - -- `url` — URL. Тип — [String](../../sql_reference/functions/url_functions.md). - -URL может быть указан со схемой или без неё. Примеры: - -``` text -svn+ssh://some.svn-hosting.com:80/repo/trunk -some.svn-hosting.com:80/repo/trunk -https://yandex.com/time/ -``` - -**Возвращаемые значения** - -- Имя домена. Если ClickHouse может распарсить входную строку как URL. -- Пустая строка. Если ClickHouse не может распарсить входную строку как URL. - -Тип — `String`. - -**Пример** - -``` sql -SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk') -``` - -``` text -┌─topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk')─┐ -│ com │ -└────────────────────────────────────────────────────────────────────┘ -``` - -### firstSignificantSubdomain {#firstsignificantsubdomain} - -Возвращает «первый существенный поддомен». Это понятие является нестандартным и специфично для Яндекс.Метрики. Первый существенный поддомен - это домен второго уровня, если он не равен одному из com, net, org, co, или домен третьего уровня, иначе. Например, firstSignificantSubdomain(‘https://news.yandex.ru/’) = ‘yandex’, firstSignificantSubdomain(‘https://news.yandex.com.tr/’) = ‘yandex’. Список «несущественных» доменов второго уровня и другие детали реализации могут изменяться в будущем. - -### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} - -Возвращает часть домена, включающую поддомены верхнего уровня до «первого существенного поддомена» (см. выше). - -Например, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. - -### path {#path} - -Возвращает путь. Пример: `/top/news.html` Путь не включает в себя query string. - -### pathFull {#pathfull} - -То же самое, но включая query string и fragment. Пример: /top/news.html?page=2\#comments - -### queryString {#querystring} - -Возвращает query-string. Пример: page=1&lr=213. query-string не включает в себя начальный знак вопроса, а также \# и всё, что после \#. - -### fragment {#fragment} - -Возвращает fragment identifier. fragment не включает в себя начальный символ решётки. - -### queryStringAndFragment {#querystringandfragment} - -Возвращает query string и fragment identifier. Пример: страница=1\#29390. - -### extractURLParameter(URL, name) {#extracturlparameterurl-name} - -Возвращает значение параметра name в URL, если такой есть; или пустую строку, иначе; если параметров с таким именем много - вернуть первый попавшийся. Функция работает при допущении, что имя параметра закодировано в URL в точности таким же образом, что и в переданном аргументе. - -### extractURLParameters(URL) {#extracturlparametersurl} - -Возвращает массив строк вида name=value, соответствующих параметрам URL. Значения никак не декодируются. - -### extractURLParameterNames(URL) {#extracturlparameternamesurl} - -Возвращает массив строк вида name, соответствующих именам параметров URL. Значения никак не декодируются. - -### URLHierarchy(URL) {#urlhierarchyurl} - -Возвращает массив, содержащий URL, обрезанный с конца по символам /, ? в пути и query-string. Подряд идущие символы-разделители считаются за один. Резка производится в позиции после всех подряд идущих символов-разделителей. Пример: - -### URLPathHierarchy(URL) {#urlpathhierarchyurl} - -То же самое, но без протокола и хоста в результате. Элемент / (корень) не включается. Пример: -Функция используется для реализации древовидных отчётов по URL в Яндекс.Метрике. - -``` text -URLPathHierarchy('https://example.com/browse/CONV-6788') = -[ - '/browse/', - '/browse/CONV-6788' -] -``` - -### decodeURLComponent(URL) {#decodeurlcomponenturl} - -Возвращает декодированный URL. -Пример: - -``` sql -SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; -``` - -``` text -┌─DecodedURL─────────────────────────────┐ -│ http://127.0.0.1:8123/?query=SELECT 1; │ -└────────────────────────────────────────┘ -``` - -## Функции, удаляющие часть из URL-а {#funktsii-udaliaiushchie-chast-iz-url-a} - -Если в URL-е нет ничего похожего, то URL остаётся без изменений. - -### cutWWW {#cutwww} - -Удаляет не более одного ‘www.’ с начала домена URL-а, если есть. - -### cutQueryString {#cutquerystring} - -Удаляет query string. Знак вопроса тоже удаляется. - -### cutFragment {#cutfragment} - -Удаляет fragment identifier. Символ решётки тоже удаляется. - -### cutQueryStringAndFragment {#cutquerystringandfragment} - -Удаляет query string и fragment identifier. Знак вопроса и символ решётки тоже удаляются. - -### cutURLParameter(URL, name) {#cuturlparameterurl-name} - -Удаляет параметр URL с именем name, если такой есть. Функция работает при допущении, что имя параметра закодировано в URL в точности таким же образом, что и в переданном аргументе. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/url_functions/) diff --git a/docs/ru/sql_reference/functions/uuid_functions.md b/docs/ru/sql_reference/functions/uuid_functions.md deleted file mode 100644 index 960e2b10e80..00000000000 --- a/docs/ru/sql_reference/functions/uuid_functions.md +++ /dev/null @@ -1,114 +0,0 @@ -# Функции для работы с UUID {#funktsii-dlia-raboty-s-uuid} - -## generateUUIDv4 {#uuid-function-generate} - -Генерирует идентификатор [UUID версии 4](https://tools.ietf.org/html/rfc4122#section-4.4). - -``` sql -generateUUIDv4() -``` - -**Возвращаемое значение** - -Значение типа [UUID](../../sql_reference/functions/uuid_functions.md). - -**Пример использования** - -Этот пример демонстрирует, как создать таблицу с UUID-колонкой и добавить в нее сгенерированный UUID. - -``` sql -CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog - -INSERT INTO t_uuid SELECT generateUUIDv4() - -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┐ -│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ -└──────────────────────────────────────┘ -``` - -## toUUID (x) {#touuid-x} - -Преобразует значение типа String в тип UUID. - -``` sql -toUUID(String) -``` - -**Возвращаемое значение** - -Значение типа UUID. - -**Пример использования** - -``` sql -SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid -``` - -``` text -┌─────────────────────────────────uuid─┐ -│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ -└──────────────────────────────────────┘ -``` - -## UUIDStringToNum {#uuidstringtonum} - -Принимает строку, содержащую 36 символов в формате `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, и возвращает в виде набора байт в [FixedString(16)](../../sql_reference/functions/uuid_functions.md). - -``` sql -UUIDStringToNum(String) -``` - -**Возвращаемое значение** - -FixedString(16) - -**Пример использования** - -``` sql -SELECT - '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, - UUIDStringToNum(uuid) AS bytes -``` - -``` text -┌─uuid─────────────────────────────────┬─bytes────────────┐ -│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ -└──────────────────────────────────────┴──────────────────┘ -``` - -## UUIDNumToString {#uuidnumtostring} - -Принимает значение типа [FixedString(16)](../../sql_reference/functions/uuid_functions.md). Возвращает строку из 36 символов в текстовом виде. - -``` sql -UUIDNumToString(FixedString(16)) -``` - -**Возвращаемое значение** - -Значение типа String. - -**Пример использования** - -``` sql -SELECT - 'a/<@];!~p{jTj={)' AS bytes, - UUIDNumToString(toFixedString(bytes, 16)) AS uuid -``` - -``` text -┌─bytes────────────┬─uuid─────────────────────────────────┐ -│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ -└──────────────────┴──────────────────────────────────────┘ -``` - -## См. также: {#sm-takzhe} - -- [dictGetUUID](ext_dict_functions.md) -- [dictGetUUIDOrDefault](ext_dict_functions.md) - -[Original article](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/ru/sql_reference/functions/ym_dict_functions.md b/docs/ru/sql_reference/functions/ym_dict_functions.md deleted file mode 100644 index 5d7aece88b9..00000000000 --- a/docs/ru/sql_reference/functions/ym_dict_functions.md +++ /dev/null @@ -1,149 +0,0 @@ -# Функции для работы со словарями Яндекс.Метрики {#ym-dict-functions} - -Чтобы указанные ниже функции работали, в конфиге сервера должны быть указаны пути и адреса для получения всех словарей Яндекс.Метрики. Словари загружаются при первом вызове любой из этих функций. Если справочники не удаётся загрузить - будет выкинуто исключение. - -О том, как создать справочники, смотрите в разделе «Словари». - -## Множественные геобазы {#mnozhestvennye-geobazy} - -ClickHouse поддерживает работу одновременно с несколькими альтернативными геобазами (иерархиями регионов), для того чтобы можно было поддержать разные точки зрения о принадлежности регионов странам. - -В конфиге clickhouse-server указывается файл с иерархией регионов: -`/opt/geo/regions_hierarchy.txt` - -Кроме указанного файла, рядом ищутся файлы, к имени которых (до расширения) добавлен символ \_ и какой угодно суффикс. -Например, также найдётся файл `/opt/geo/regions_hierarchy_ua.txt`, если такой есть. - -`ua` называется ключом словаря. Для словаря без суффикса, ключ является пустой строкой. - -Все словари перезагружаются в рантайме (раз в количество секунд, заданное в конфигурационном параметре builtin\_dictionaries\_reload\_interval, по умолчанию - раз в час), но перечень доступных словарей определяется один раз, при старте сервера. - -Во все функции по работе с регионами, в конце добавлен один необязательный аргумент - ключ словаря. Далее он обозначен как geobase. -Пример: - -``` text -regionToCountry(RegionID) - использует словарь по умолчанию: /opt/geo/regions_hierarchy.txt; -regionToCountry(RegionID, '') - использует словарь по умолчанию: /opt/geo/regions_hierarchy.txt; -regionToCountry(RegionID, 'ua') - использует словарь для ключа ua: /opt/geo/regions_hierarchy_ua.txt; -``` - -### regionToCity(id\[, geobase\]) {#regiontocityid-geobase} - -Принимает число типа UInt32 - идентификатор региона из геобазы Яндекса. Если регион является городом или входит в некоторый город, то возвращает идентификатор региона - соответствующего города. Иначе возвращает 0. - -### regionToArea(id\[, geobase\]) {#regiontoareaid-geobase} - -Переводит регион в область (тип в геобазе - 5). В остальном, аналогично функции regionToCity. - -``` sql -SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ -│ │ -│ Москва и Московская область │ -│ Санкт-Петербург и Ленинградская область │ -│ Белгородская область │ -│ Ивановская область │ -│ Калужская область │ -│ Костромская область │ -│ Курская область │ -│ Липецкая область │ -│ Орловская область │ -│ Рязанская область │ -│ Смоленская область │ -│ Тамбовская область │ -│ Тверская область │ -│ Тульская область │ -└──────────────────────────────────────────────────────┘ -``` - -### regionToDistrict(id\[, geobase\]) {#regiontodistrictid-geobase} - -Переводит регион в федеральный округ (тип в геобазе - 4). В остальном, аналогично функции regionToCity. - -``` sql -SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - -``` text -┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ -│ │ -│ Центральный федеральный округ │ -│ Северо-Западный федеральный округ │ -│ Южный федеральный округ │ -│ Северо-Кавказский федеральный округ │ -│ Приволжский федеральный округ │ -│ Уральский федеральный округ │ -│ Сибирский федеральный округ │ -│ Дальневосточный федеральный округ │ -│ Шотландия │ -│ Фарерские острова │ -│ Фламандский регион │ -│ Брюссельский столичный регион │ -│ Валлония │ -│ Федерация Боснии и Герцеговины │ -└──────────────────────────────────────────────────────────┘ -``` - -### regionToCountry(id\[, geobase\]) {#regiontocountryid-geobase} - -Переводит регион в страну. В остальном, аналогично функции regionToCity. -Пример: `regionToCountry(toUInt32(213)) = 225` - преобразовали Москву (213) в Россию (225). - -### regionToContinent(id\[, geobase\]) {#regiontocontinentid-geobase} - -Переводит регион в континент. В остальном, аналогично функции regionToCity. -Пример: `regionToContinent(toUInt32(213)) = 10001` - преобразовали Москву (213) в Евразию (10001). - -### regionToTopContinent (#regiontotopcontinent) - -Находит для региона верхний в иерархии континент. - -**Синтаксис** - -```sql -regionToTopContinent(id[, geobase]); -``` - -**Параметры** - -- `id` — Идентификатор региона из геобазы Яндекса. [UInt32](../../sql_reference/functions/ym_dict_functions.md). -- `geobase` — Ключ словаря. Смотрите [Множественные геобазы](#multiple-geobases). [String](../../sql_reference/functions/ym_dict_functions.md). Опциональный параметр. - -**Возвращаемое значение** - -- Идентификатор континента верхнего уровня (последний при подъеме по иерархии регионов). -- 0, если его нет. - -Тип: `UInt32`. - -### regionToPopulation(id\[, geobase\]) {#regiontopopulationid-geobase} - -Получает население для региона. -Население может быть прописано в файлах с геобазой. Смотрите в разделе «Встроенные словари». -Если для региона не прописано население, возвращается 0. -В геобазе Яндекса, население может быть прописано для дочерних регионов, но не прописано для родительских. - -### regionIn(lhs, rhs\[, geobase\]) {#regioninlhs-rhs-geobase} - -Проверяет принадлежность региона lhs региону rhs. Возвращает число типа UInt8, равное 1, если принадлежит и 0, если не принадлежит. -Отношение рефлексивное - любой регион принадлежит также самому себе. - -### regionHierarchy(id\[, geobase\]) {#regionhierarchyid-geobase} - -Принимает число типа UInt32 - идентификатор региона из геобазы Яндекса. Возвращает массив идентификаторов регионов, состоящий из переданного региона и всех родителей по цепочке. -Пример: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. - -### regionToName(id\[, lang\]) {#regiontonameid-lang} - -Принимает число типа UInt32 - идентификатор региона из геобазы Яндекса. Вторым аргументом может быть передана строка - название языка. Поддерживаются языки ru, en, ua, uk, by, kz, tr. Если второй аргумент отсутствует - используется язык ru. Если язык не поддерживается - кидается исключение. Возвращает строку - название региона на соответствующем языке. Если региона с указанным идентификатором не существует - возвращается пустая строка. - -`ua` и `uk` обозначают одно и то же - украинский язык. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/ym_dict_functions/) diff --git a/docs/ru/sql_reference/index.md b/docs/ru/sql_reference/index.md deleted file mode 100644 index ca21b0df3ed..00000000000 --- a/docs/ru/sql_reference/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -toc_folder_title: Справка по SQL -toc_hidden: true -toc_priority: 28 -toc_title: hidden ---- - -# Справка по SQL {#spravka-po-sql} - -- [SELECT](statements/select.md) -- [INSERT INTO](statements/insert_into.md) -- [CREATE](statements/create.md) -- [ALTER](statements/alter.md) -- [Прочие виды запросов](statements/misc.md) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/) diff --git a/docs/ru/sql_reference/operators.md b/docs/ru/sql_reference/operators.md deleted file mode 100644 index 2cff1ad6aed..00000000000 --- a/docs/ru/sql_reference/operators.md +++ /dev/null @@ -1,271 +0,0 @@ -# Операторы {#operatory} - -Все операторы преобразуются в соответствующие функции на этапе парсинга запроса, с учётом их приоритетов и ассоциативности. -Далее будут перечислены группы операторов в порядке их приоритета (чем выше, тем раньше оператор связывается со своими аргументами). - -## Операторы доступа {#operatory-dostupa} - -`a[N]` - доступ к элементу массива, функция `arrayElement(a, N)`. - -`a.N` - доступ к элементу кортежа, функция `tupleElement(a, N)`. - -## Оператор числового отрицания {#operator-chislovogo-otritsaniia} - -`-a` - функция `negate(a)`. - -## Операторы умножения и деления {#operatory-umnozheniia-i-deleniia} - -`a * b` - функция `multiply(a, b)` - -`a / b` - функция `divide(a, b)` - -`a % b` - функция `modulo(a, b)` - -## Операторы сложения и вычитания {#operatory-slozheniia-i-vychitaniia} - -`a + b` - функция `plus(a, b)` - -`a - b` - функция `minus(a, b)` - -## Операторы сравнения {#operatory-sravneniia} - -`a = b` - функция `equals(a, b)` - -`a == b` - функция `equals(a, b)` - -`a != b` - функция `notEquals(a, b)` - -`a <> b` - функция `notEquals(a, b)` - -`a <= b` - функция `lessOrEquals(a, b)` - -`a >= b` - функция `greaterOrEquals(a, b)` - -`a < b` - функция `less(a, b)` - -`a > b` - функция `greater(a, b)` - -`a LIKE s` - функция `like(a, b)` - -`a NOT LIKE s` - функция `notLike(a, b)` - -`a BETWEEN b AND c` - равнозначно `a >= b AND a <= c` - -`a NOT BETWEEN b AND c` - равнозначно `a < b OR a > c` - -## Операторы для работы с множествами {#operatory-dlia-raboty-s-mnozhestvami} - -*Смотрите раздел [Операторы IN](../sql_reference/statements/select.md#select-in-operators).* - -`a IN ...` - функция `in(a, b)` - -`a NOT IN ...` - функция `notIn(a, b)` - -`a GLOBAL IN ...` - функция `globalIn(a, b)` - -`a GLOBAL NOT IN ...` - функция `globalNotIn(a, b)` - -## Оператор для работы с датами и временем {#operators-datetime} - -### EXTRACT {#extract} - -``` sql -EXTRACT(part FROM date); -``` - -Позволяет извлечь отдельные части из переданной даты. Например, можно получить месяц из даты, или минуты из времени. - -В параметре `part` указывается, какой фрагмент даты нужно получить. Доступные значения: - -- `DAY` — День. Возможные значения: 1–31. -- `MONTH` — Номер месяца. Возможные значения: 1–12. -- `YEAR` — Год. -- `SECOND` — Секунда. Возможные значения: 0–59. -- `MINUTE` — Минута. Возможные значения: 0–59. -- `HOUR` — Час. Возможные значения: 0–23. - -Эти значения могут быть указаны также в нижнем регистре (`day`, `month`). - -В параметре `date` указывается исходная дата. Поддерживаются типы [Date](../sql_reference/data_types/date.md) и [DateTime](../sql_reference/data_types/datetime.md). - -Примеры: - -``` sql -SELECT EXTRACT(DAY FROM toDate('2017-06-15')); -SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); -SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); -``` - -В следующем примере создадим таблицу и добавим в неё значение с типом `DateTime`. - -``` sql -CREATE TABLE test.Orders -( - OrderId UInt64, - OrderName String, - OrderDate DateTime -) -ENGINE = Log; -``` - -``` sql -INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); -``` - -``` sql -SELECT - toYear(OrderDate) AS OrderYear, - toMonth(OrderDate) AS OrderMonth, - toDayOfMonth(OrderDate) AS OrderDay, - toHour(OrderDate) AS OrderHour, - toMinute(OrderDate) AS OrderMinute, - toSecond(OrderDate) AS OrderSecond -FROM test.Orders; -``` - -``` text -┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ -│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ -└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ -``` - -Больше примеров приведено в [тестах](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). - -### INTERVAL {#operator-interval} - -Создаёт значение типа [Interval](../sql_reference/operators.md) которое должно использоваться в арифметических операциях со значениями типов [Date](../sql_reference/operators.md) и [DateTime](../sql_reference/operators.md). - -Типы интервалов: -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -!!! warning "Внимание" - Интервалы различных типов нельзя объединять. Нельзя использовать выражения вида `INTERVAL 4 DAY 1 HOUR`. Вместо этого интервалы можно выразить в единицах меньших или равных наименьшей единице интервала, Например, `INTERVAL 25 HOUR`. Также можно выполнять последовательные операции как показано в примере ниже. - -Пример: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -**Смотрите также** - -- Тип данных [Interval](../sql_reference/operators.md) -- Функции преобразования типов [toInterval](../sql_reference/operators.md#function-tointerval) - -## Оператор логического отрицания {#operator-logicheskogo-otritsaniia} - -`NOT a` - функция `not(a)` - -## Оператор логического ‘И’ {#operator-logicheskogo-i} - -`a AND b` - функция `and(a, b)` - -## Оператор логического ‘ИЛИ’ {#operator-logicheskogo-ili} - -`a OR b` - функция `or(a, b)` - -## Условный оператор {#uslovnyi-operator} - -`a ? b : c` - функция `if(a, b, c)` - -Примечание: - -Условный оператор сначала вычисляет значения b и c, затем проверяет выполнение условия a, и только после этого возвращает соответствующее значение. Если в качестве b или с выступает функция [arrayJoin()](../sql_reference/operators.md#functions_arrayjoin), то размножение каждой строки произойдет вне зависимости от условия а. - -## Условное выражение {#operator_case} - -``` sql -CASE [x] - WHEN a THEN b - [WHEN ... THEN ...] - [ELSE c] -END -``` - -В случае указания `x` - функция `transform(x, [a, ...], [b, ...], c)`. Иначе — `multiIf(a, b, ..., c)`. -При отсутствии секции `ELSE c`, значением по умолчанию будет `NULL`. - -!!! note "Примечание" - Функция `transform` не умеет работать с `NULL`. - -## Оператор склеивания строк {#operator-skleivaniia-strok} - -`s1 || s2` - функция `concat(s1, s2)` - -## Оператор создания лямбда-выражения {#operator-sozdaniia-liambda-vyrazheniia} - -`x -> expr` - функция `lambda(x, expr)` - -Следующие операторы не имеют приоритета, так как представляют собой скобки: - -## Оператор создания массива {#operator-sozdaniia-massiva} - -`[x1, ...]` - функция `array(x1, ...)` - -## Оператор создания кортежа {#operator-sozdaniia-kortezha} - -`(x1, x2, ...)` - функция `tuple(x2, x2, ...)` - -## Ассоциативность {#assotsiativnost} - -Все бинарные операторы имеют левую ассоциативность. Например, `1 + 2 + 3` преобразуется в `plus(plus(1, 2), 3)`. -Иногда это работает не так, как ожидается. Например, `SELECT 4 > 3 > 2` выдаст 0. - -Для эффективности, реализованы функции `and` и `or`, принимающие произвольное количество аргументов. Соответствующие цепочки операторов `AND` и `OR`, преобразуются в один вызов этих функций. - -## Проверка на `NULL` {#proverka-na-null} - -ClickHouse поддерживает операторы `IS NULL` и `IS NOT NULL`. - -### IS NULL {#operator-is-null} - -- Для значений типа [Nullable](../sql_reference/operators.md) оператор `IS NULL` возвращает: - - `1`, если значение — `NULL`. - - `0` в обратном случае. -- Для прочих значений оператор `IS NULL` всегда возвращает `0`. - - - -``` sql -SELECT x+100 FROM t_null WHERE y IS NULL -``` - -``` text -┌─plus(x, 100)─┐ -│ 101 │ -└──────────────┘ -``` - -### IS NOT NULL {#is-not-null} - -- Для значений типа [Nullable](../sql_reference/operators.md) оператор `IS NOT NULL` возвращает: - - `0`, если значение — `NULL`. - - `1`, в обратном случае. -- Для прочих значений оператор `IS NOT NULL` всегда возвращает `1`. - - - -``` sql -SELECT * FROM t_null WHERE y IS NOT NULL -``` - -``` text -┌─x─┬─y─┐ -│ 2 │ 3 │ -└───┴───┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/operators/) diff --git a/docs/ru/sql_reference/statements/alter.md b/docs/ru/sql_reference/statements/alter.md deleted file mode 100644 index 5c08d68623e..00000000000 --- a/docs/ru/sql_reference/statements/alter.md +++ /dev/null @@ -1,505 +0,0 @@ ---- -toc_priority: 36 -toc_title: ALTER ---- - -## ALTER {#query_language_queries_alter} - -Запрос `ALTER` поддерживается только для таблиц типа `*MergeTree`, а также `Merge` и `Distributed`. Запрос имеет несколько вариантов. - -### Манипуляции со столбцами {#manipuliatsii-so-stolbtsami} - -Изменение структуры таблицы. - -``` sql -ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... -``` - -В запросе указывается список из одного или более действий через запятую. -Каждое действие — операция над столбцом. - -Существуют следующие действия: - -- [ADD COLUMN](#alter_add-column) — добавляет столбец в таблицу; -- [DROP COLUMN](#alter_drop-column) — удаляет столбец; -- [CLEAR COLUMN](#alter_clear-column) — сбрасывает все значения в столбце для заданной партиции; -- [COMMENT COLUMN](#alter_comment-column) — добавляет комментарий к столбцу; -- [MODIFY COLUMN](#alter_modify-column) — изменяет тип столбца, выражение для значения по умолчанию и TTL. - -Подробное описание для каждого действия приведено ниже. - -#### ADD COLUMN {#alter_add-column} - -``` sql -ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] -``` - -Добавляет в таблицу новый столбец с именем `name`, типом `type`, [кодеком](create.md#codecs) `codec` и выражением для умолчания `default_expr` (смотрите раздел [Значения по умолчанию](create.md#create-default-values)). - -Если указано `IF NOT EXISTS`, запрос не будет возвращать ошибку, если столбец уже существует. Если указано `AFTER name_after` (имя другого столбца), то столбец добавляется (в список столбцов таблицы) после указанного. Иначе, столбец добавляется в конец таблицы. Обратите внимание, ClickHouse не позволяет добавлять столбцы в начало таблицы. Для цепочки действий, `name_after` может быть именем столбца, который добавляется в одном из предыдущих действий. - -Добавление столбца всего лишь меняет структуру таблицы, и не производит никаких действий с данными - соответствующие данные не появляются на диске после ALTER-а. При чтении из таблицы, если для какого-либо столбца отсутствуют данные, то он заполняется значениями по умолчанию (выполняя выражение по умолчанию, если такое есть, или нулями, пустыми строками). Также, столбец появляется на диске при слиянии кусков данных (см. [MergeTree](../../sql_reference/statements/alter.md)). - -Такая схема позволяет добиться мгновенной работы запроса `ALTER` и отсутствия необходимости увеличивать объём старых данных. - -Пример: - -``` sql -ALTER TABLE visits ADD COLUMN browser String AFTER user_id -``` - -#### DROP COLUMN {#alter_drop-column} - -``` sql -DROP COLUMN [IF EXISTS] name -``` - -Удаляет столбец с именем `name`. Если указано `IF EXISTS`, запрос не будет возвращать ошибку, если столбца не существует. - -Запрос удаляет данные из файловой системы. Так как это представляет собой удаление целых файлов, запрос выполняется почти мгновенно. - -Пример: - -``` sql -ALTER TABLE visits DROP COLUMN browser -``` - -#### CLEAR COLUMN {#alter_clear-column} - -``` sql -CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name -``` - -Сбрасывает все значения в столбце для заданной партиции. Если указано `IF EXISTS`, запрос не будет возвращать ошибку, если столбца не существует. - -Как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -Пример: - -``` sql -ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() -``` - -#### COMMENT COLUMN {#alter_comment-column} - -``` sql -COMMENT COLUMN [IF EXISTS] name 'Text comment' -``` - -Добавляет комментарий к таблице. Если указано `IF EXISTS`, запрос не будет возвращать ошибку, если столбца не существует. - -Каждый столбец может содержать только один комментарий. При выполнении запроса существующий комментарий заменяется на новый. - -Посмотреть комментарии можно в столбце `comment_expression` из запроса [DESCRIBE TABLE](misc.md#misc-describe-table). - -Пример: - -``` sql -ALTER TABLE visits COMMENT COLUMN browser 'Столбец показывает, из каких браузеров пользователи заходили на сайт.' -``` - -#### MODIFY COLUMN {#alter_modify-column} - -``` sql -MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] -``` - -Запрос изменяет следующие свойства столбца `name`: - -- Тип - -- Значение по умолчанию - -- TTL - - Примеры изменения TTL столбца смотрите в разделе [TTL столбца](../../sql_reference/statements/alter.md#mergetree-column-ttl). - -Если указано `IF EXISTS`, запрос не возвращает ошибку, если столбца не существует. - -При изменении типа, значения преобразуются так, как если бы к ним была применена функция [toType](../../sql_reference/statements/alter.md). Если изменяется только выражение для умолчания, запрос не делает никакой сложной работы и выполняется мгновенно. - -Пример запроса: - -``` sql -ALTER TABLE visits MODIFY COLUMN browser Array(String) -``` - -Изменение типа столбца - это единственное действие, которое выполняет сложную работу - меняет содержимое файлов с данными. Для больших таблиц, выполнение может занять длительное время. - -Выполнение производится в несколько стадий: - -- подготовка временных (новых) файлов с изменёнными данными; -- переименование старых файлов; -- переименование временных (новых) файлов в старые; -- удаление старых файлов. - -Из них, длительной является только первая стадия. Если на этой стадии возникнет сбой, то данные не поменяются. -Если на одной из следующих стадий возникнет сбой, то данные будет можно восстановить вручную. За исключением случаев, когда старые файлы удалены из файловой системы, а данные для новых файлов не доехали на диск и потеряны. - -Запрос `ALTER` на изменение столбцов реплицируется. Соответствующие инструкции сохраняются в ZooKeeper, и затем каждая реплика их применяет. Все запросы `ALTER` выполняются в одном и том же порядке. Запрос ждёт выполнения соответствующих действий на всех репликах. Но при этом, запрос на изменение столбцов в реплицируемой таблице можно прервать, и все действия будут осуществлены асинхронно. - -#### Ограничения запроса ALTER {#ogranicheniia-zaprosa-alter} - -Запрос `ALTER` позволяет создавать и удалять отдельные элементы (столбцы) вложенных структур данных, но не вложенные структуры данных целиком. Для добавления вложенной структуры данных, вы можете добавить столбцы с именем вида `name.nested_name` и типом `Array(T)` - вложенная структура данных полностью эквивалентна нескольким столбцам-массивам с именем, имеющим одинаковый префикс до точки. - -Отсутствует возможность удалять столбцы, входящие в первичный ключ или ключ для сэмплирования (в общем, входящие в выражение `ENGINE`). Изменение типа у столбцов, входящих в первичный ключ возможно только в том случае, если это изменение не приводит к изменению данных (например, разрешено добавление значения в Enum или изменение типа с `DateTime` на `UInt32`). - -Если возможностей запроса `ALTER` не хватает для нужного изменения таблицы, вы можете создать новую таблицу, скопировать туда данные с помощью запроса [INSERT SELECT](insert_into.md#insert_query_insert-select), затем поменять таблицы местами с помощью запроса [RENAME](misc.md#misc_operations-rename), и удалить старую таблицу. В качестве альтернативы для запроса `INSERT SELECT`, можно использовать инструмент [clickhouse-copier](../../sql_reference/statements/alter.md). - -Запрос `ALTER` блокирует все чтения и записи для таблицы. То есть, если на момент запроса `ALTER`, выполнялся долгий `SELECT`, то запрос `ALTER` сначала дождётся его выполнения. И в это время, все новые запросы к той же таблице, будут ждать, пока завершится этот `ALTER`. - -Для таблиц, которые не хранят данные самостоятельно (типа [Merge](../../sql_reference/statements/alter.md) и [Distributed](../../sql_reference/statements/alter.md)), `ALTER` всего лишь меняет структуру таблицы, но не меняет структуру подчинённых таблиц. Для примера, при ALTER-е таблицы типа `Distributed`, вам также потребуется выполнить запрос `ALTER` для таблиц на всех удалённых серверах. - -### Манипуляции с ключевыми выражениями таблиц {#manipuliatsii-s-kliuchevymi-vyrazheniiami-tablits} - -Поддерживается операция: - -``` sql -MODIFY ORDER BY new_expression -``` - -Работает только для таблиц семейства [`MergeTree`](../../sql_reference/statements/alter.md) (в том числе [реплицированных](../../sql_reference/statements/alter.md)). После выполнения запроса -[ключ сортировки](../../sql_reference/statements/alter.md) таблицы -заменяется на `new_expression` (выражение или кортеж выражений). Первичный ключ при этом остаётся прежним. - -Операция затрагивает только метаданные. Чтобы сохранить свойство упорядоченности кусков данных по ключу -сортировки, разрешено добавлять в ключ только новые столбцы (т.е. столбцы, добавляемые командой `ADD COLUMN` -в том же запросе `ALTER`), у которых нет выражения по умолчанию. - -### Манипуляции с индексами {#manipuliatsii-s-indeksami} - -Добавить или удалить индекс можно с помощью операций - -``` sql -ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value [AFTER name] -ALTER TABLE [db].name DROP INDEX name -``` - -Поддерживается только таблицами семейства `*MergeTree`. - -Команда `ADD INDEX` добавляет описание индексов в метаданные, а `DROP INDEX` удаляет индекс из метаданных и стирает файлы индекса с диска, поэтому они легковесные и работают мгновенно. - -Если индекс появился в метаданных, то он начнет считаться в последующих слияниях и записях в таблицу, а не сразу после выполнения операции `ALTER`. - -Запрос на изменение индексов реплицируется, сохраняя новые метаданные в ZooKeeper и применяя изменения на всех репликах. - -### Манипуляции с ограничениями (constraints) {#manipuliatsii-s-ogranicheniiami-constraints} - -Про ограничения подробнее написано [тут](create.md#constraints). - -Добавить или удалить ограничение можно с помощью запросов - -``` sql -ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; -ALTER TABLE [db].name DROP CONSTRAINT constraint_name; -``` - -Запросы выполняют добавление или удаление метаданных об ограничениях таблицы `[db].name`, поэтому выполняются мнгновенно. - -Если ограничение появилось для непустой таблицы, то *проверка ограничения для имеющихся данных не производится*. - -Запрос на изменение ограничений для Replicated таблиц реплицируется, сохраняя новые метаданные в ZooKeeper и применяя изменения на всех репликах. - -### Манипуляции с партициями и кусками {#alter_manipulations-with-partitions} - -Для работы с [партициями](../../sql_reference/statements/alter.md) доступны следующие операции: - -- [DETACH PARTITION](#alter_detach-partition) – перенести партицию в директорию `detached`; -- [DROP PARTITION](#alter_drop-partition) – удалить партицию; -- [ATTACH PARTITION\|PART](#alter_attach-partition) – добавить партицию/кусок в таблицу из директории `detached`; -- [ATTACH PARTITION FROM](#alter_attach-partition-from) – скопировать партицию из другой таблицы; -- [REPLACE PARTITION](#alter_replace-partition) – скопировать партицию из другой таблицы с заменой; -- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition) (\#alter\_move\_to\_table-partition) - переместить партицию в другую таблицу; -- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) – удалить все значения в столбце для заданной партиции; -- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) - очистить построенные вторичные индексы для заданной партиции; -- [FREEZE PARTITION](#alter_freeze-partition) – создать резервную копию партиции; -- [FETCH PARTITION](#alter_fetch-partition) – скачать партицию с другого сервера; -- [MOVE PARTITION\|PART](#alter_move-partition) – переместить партицию/кускок на другой диск или том. - -#### DETACH PARTITION {#alter_detach-partition} - -``` sql -ALTER TABLE table_name DETACH PARTITION partition_expr -``` - -Перемещает заданную партицию в директорию `detached`. Сервер не будет знать об этой партиции до тех пор, пока вы не выполните запрос [ATTACH](#alter_attach-partition). - -Пример: - -``` sql -ALTER TABLE visits DETACH PARTITION 201901 -``` - -Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -После того как запрос будет выполнен, вы сможете производить любые операции с данными в директории `detached`. Например, можно удалить их из файловой системы. - -Запрос реплицируется — данные будут перенесены в директорию `detached` и забыты на всех репликах. Обратите внимание, запрос может быть отправлен только на реплику-лидер. Чтобы узнать, является ли реплика лидером, выполните запрос `SELECT` к системной таблице [system.replicas](../../operations/system_tables.md#system_tables-replicas). Либо можно выполнить запрос `DETACH` на всех репликах — тогда на всех репликах, кроме реплики-лидера, запрос вернет ошибку. - -#### DROP PARTITION {#alter_drop-partition} - -``` sql -ALTER TABLE table_name DROP PARTITION partition_expr -``` - -Удаляет партицию. Партиция помечается как неактивная и будет полностью удалена примерно через 10 минут. - -Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -Запрос реплицируется — данные будут удалены на всех репликах. - -#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} - -``` sql -ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr -``` - -Удаляет из `detached` кусок или все куски, принадлежащие партиции. -Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -#### ATTACH PARTITION\|PART {#alter_attach-partition} - -``` sql -ALTER TABLE table_name ATTACH PARTITION|PART partition_expr -``` - -Добавляет данные в таблицу из директории `detached`. Можно добавить данные как для целой партиции, так и для отдельного куска. Примеры: - -``` sql -ALTER TABLE visits ATTACH PARTITION 201901; -ALTER TABLE visits ATTACH PART 201901_2_2_0; -``` - -Как корректно задать имя партиции или куска, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -Этот запрос реплицируется. Реплика-иницатор проверяет, есть ли данные в директории `detached`. Если данные есть, то запрос проверяет их целостность. В случае успеха данные добавляются в таблицу. Все остальные реплики загружают данные с реплики-инициатора запроса. - -Это означает, что вы можете разместить данные в директории `detached` на одной реплике и с помощью запроса `ALTER ... ATTACH` добавить их в таблицу на всех репликах. - -#### ATTACH PARTITION FROM {#alter_attach-partition-from} - -``` sql -ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 -``` - -Копирует партицию из таблицы `table1` в таблицу `table2` и добавляет к существующим данным `table2`. Данные из `table1` не удаляются. - -Следует иметь в виду: - -- Таблицы должны иметь одинаковую структуру. -- Для таблиц должен быть задан одинаковый ключ партиционирования. - -Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -#### REPLACE PARTITION {#alter_replace-partition} - -``` sql -ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 -``` - -Копирует партицию из таблицы `table1` в таблицу `table2` с заменой существующих данных в `table2`. Данные из `table1` не удаляются. - -Следует иметь в виду: - -- Таблицы должны иметь одинаковую структуру. -- Для таблиц должен быть задан одинаковый ключ партиционирования. - -Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} - -``` sql -ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest -``` - -Перемещает партицию из таблицы `table_source` в таблицу `table_dest` (добавляет к существующим данным в `table_dest`), с удалением данных из таблицы `table_source`. - -Следует иметь в виду: - -- Таблицы должны иметь одинаковую структуру. -- Для таблиц должен быть задан одинаковый ключ партиционирования. - -#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} - -``` sql -ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr -``` - -Сбрасывает все значения в столбце для заданной партиции. Если для столбца определено значение по умолчанию (в секции `DEFAULT`), то будет выставлено это значение. - -Пример: - -``` sql -ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 -``` - -#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} - -``` sql -ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr -``` - -Работает как `CLEAR COLUMN`, но сбрасывает индексы вместо данных в столбцах. - -#### FREEZE PARTITION {#alter_freeze-partition} - -``` sql -ALTER TABLE table_name FREEZE [PARTITION partition_expr] -``` - -Создаёт резервную копию для заданной партиции. Если выражение `PARTITION` опущено, резервные копии будут созданы для всех партиций. - -!!! note "Примечание" - Создание резервной копии не требует остановки сервера. - -Для таблиц старого стиля имя партиций можно задавать в виде префикса (например, ‘2019’). В этом случае резервные копии будут созданы для всех соответствующих партиций. Подробнее о том, как корректно задать имя партиции, см. в разделе [Как задавать имя партиции в запросах ALTER](#alter-how-to-specify-part-expr). - -Запрос делает следующее — для текущего состояния таблицы он формирует жесткие ссылки на данные в этой таблице. Ссылки размещаются в директории `/var/lib/clickhouse/shadow/N/...`, где: - -- `/var/lib/clickhouse/` — рабочая директория ClickHouse, заданная в конфигурационном файле; -- `N` — инкрементальный номер резервной копии. - -!!! note "Примечание" - При использовании [нескольких дисков для хранения данных таблицы](../../sql_reference/statements/alter.md#table_engine-mergetree-multiple-volumes) директория `shadow/N` появляется на каждом из дисков, на которых были куски, попавшие под выражение `PARTITION`. - -Структура директорий внутри резервной копии такая же, как внутри `/var/lib/clickhouse/`. Запрос выполнит ‘chmod’ для всех файлов, запрещая запись в них. - -Обратите внимание, запрос `ALTER TABLE t FREEZE PARTITION` не реплицируется. Он создает резервную копию только на локальном сервере. После создания резервной копии данные из `/var/lib/clickhouse/shadow/` можно скопировать на удалённый сервер, а локальную копию удалить. - -Резервная копия создается почти мгновенно (однако сначала запрос дожидается завершения всех запросов, которые выполняются для соответствующей таблицы). - -`ALTER TABLE t FREEZE PARTITION` копирует только данные, но не метаданные таблицы. Чтобы сделать резервную копию метаданных таблицы, скопируйте файл `/var/lib/clickhouse/metadata/database/table.sql` - -Чтобы восстановить данные из резервной копии, выполните следующее: - -1. Создайте таблицу, если она ещё не существует. Запрос на создание можно взять из .sql файла (замените в нём `ATTACH` на `CREATE`). -2. Скопируйте данные из директории `data/database/table/` внутри резервной копии в директорию `/var/lib/clickhouse/data/database/table/detached/`. -3. С помощью запросов `ALTER TABLE t ATTACH PARTITION` добавьте данные в таблицу. - -Восстановление данных из резервной копии не требует остановки сервера. - -Подробнее о резервном копировании и восстановлении данных читайте в разделе [Резервное копирование данных](../../operations/backup.md). - -#### FETCH PARTITION {#alter_fetch-partition} - -``` sql -ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' -``` - -Загружает партицию с другого сервера. Этот запрос работает только для реплицированных таблиц. - -Запрос выполняет следующее: - -1. Загружает партицию с указанного шарда. Путь к шарду задается в секции `FROM` (‘path-in-zookeeper’). Обратите внимание, нужно задавать путь к шарду в ZooKeeper. -2. Помещает загруженные данные в директорию `detached` таблицы `table_name`. Чтобы прикрепить эти данные к таблице, используйте запрос [ATTACH PARTITION\|PART](#alter_attach-partition). - -Например: - -``` sql -ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; -ALTER TABLE users ATTACH PARTITION 201902; -``` - -Следует иметь в виду: - -- Запрос `ALTER TABLE t FETCH PARTITION` не реплицируется. Он загружает партицию в директорию `detached` только на локальном сервере. -- Запрос `ALTER TABLE t ATTACH` реплицируется — он добавляет данные в таблицу сразу на всех репликах. На одной из реплик данные будут добавлены из директории `detached`, а на других — из соседних реплик. - -Перед загрузкой данных система проверяет, существует ли партиция и совпадает ли её структура со структурой таблицы. При этом автоматически выбирается наиболее актуальная реплика среди всех живых реплик. - -Несмотря на то что запрос называется `ALTER TABLE`, он не изменяет структуру таблицы и не изменяет сразу доступные данные в таблице. - -#### MOVE PARTITION\|PART {#alter_move-partition} - -Перемещает партицию или кусок данных на другой том или диск для таблиц с движком `MergeTree`. Смотрите [Хранение данных таблицы на нескольких блочных устройствах](../../sql_reference/statements/alter.md#table_engine-mergetree-multiple-volumes). - -``` sql -ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' -``` - -Запрос `ALTER TABLE t MOVE`: - -- Не реплицируется, т.к. на разных репликах могут быть различные конфигурации политик хранения. -- Возвращает ошибку, если указан несконфигурированный том или диск. Ошибка также возвращается в случае невыполнения условий перемещения данных, которые указаны в конфигурации политики хранения. -- Может возвращать ошибку в случае, когда перемещаемые данные уже оказались перемещены в результате фонового процесса, конкурентного запроса `ALTER TABLE t MOVE` или как часть результата фоновой операции слияния. В данном случае никаких дополнительных действий от пользователя не требуется. - -Примеры: - -``` sql -ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' -ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' -``` - -#### Как задавать имя партиции в запросах ALTER {#alter-how-to-specify-part-expr} - -Чтобы задать нужную партицию в запросах `ALTER ... PARTITION`, можно использовать: - -- Имя партиции. Посмотреть имя партиции можно в столбце `partition` системной таблицы [system.parts](../../operations/system_tables.md#system_tables-parts). Например, `ALTER TABLE visits DETACH PARTITION 201901`. -- Произвольное выражение из столбцов исходной таблицы. Также поддерживаются константы и константные выражения. Например, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. -- Строковый идентификатор партиции. Идентификатор партиции используется для именования кусков партиции на файловой системе и в ZooKeeper. В запросах `ALTER` идентификатор партиции нужно указывать в секции `PARTITION ID`, в одинарных кавычках. Например, `ALTER TABLE visits DETACH PARTITION ID '201901'`. -- Для запросов [ATTACH PART](#alter_attach-partition) и [DROP DETACHED PART](#alter_drop-detached): чтобы задать имя куска партиции, используйте строковой литерал со значением из столбца `name` системной таблицы [system.detached\_parts](../../operations/system_tables.md#system_tables-detached_parts). Например, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. - -Использование кавычек в имени партиций зависит от типа данных столбца, по которому задано партиционирование. Например, для столбца с типом `String` имя партиции необходимо указывать в кавычках (одинарных). Для типов `Date` и `Int*` кавычки указывать не нужно. - -Замечание: для таблиц старого стиля партицию можно указывать и как число `201901`, и как строку `'201901'`. Синтаксис для таблиц нового типа более строг к типам (аналогично парсеру входного формата VALUES). - -Правила, сформулированные выше, актуальны также для запросов [OPTIMIZE](misc.md#misc_operations-optimize). Чтобы указать единственную партицию непартиционированной таблицы, укажите `PARTITION tuple()`. Например: - -``` sql -OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; -``` - -Примеры запросов `ALTER ... PARTITION` можно посмотреть в тестах: [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) и [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). - -### Манипуляции с TTL таблицы {#manipuliatsii-s-ttl-tablitsy} - -Вы можете изменить [TTL для таблицы](../../sql_reference/statements/alter.md#mergetree-table-ttl) запросом следующего вида: - -``` sql -ALTER TABLE table-name MODIFY TTL ttl-expression -``` - -### Синхронность запросов ALTER {#sinkhronnost-zaprosov-alter} - -Для нереплицируемых таблиц, все запросы `ALTER` выполняются синхронно. Для реплицируемых таблиц, запрос всего лишь добавляет инструкцию по соответствующим действиям в `ZooKeeper`, а сами действия осуществляются при первой возможности. Но при этом, запрос может ждать завершения выполнения этих действий на всех репликах. - -Для запросов `ALTER ... ATTACH|DETACH|DROP` можно настроить ожидание, с помощью настройки `replication_alter_partitions_sync`. -Возможные значения: `0` - не ждать, `1` - ждать выполнения только у себя (по умолчанию), `2` - ждать всех. - -### Мутации {#alter-mutations} - -Мутации - разновидность запроса ALTER, позволяющая изменять или удалять данные в таблице. В отличие от стандартных запросов `DELETE` и `UPDATE`, рассчитанных на точечное изменение данных, область применения мутаций - достаточно тяжёлые изменения, затрагивающие много строк в таблице. Поддержана для движков таблиц семейства `MergeTree`, в том числе для движков с репликацией. - -Конвертировать существующие таблицы для работы с мутациями не нужно. Но после применения первой мутации формат данных таблицы становится несовместимым с предыдущими версиями и откатиться на предыдущую версию уже не получится. - -На данный момент доступны команды: - -``` sql -ALTER TABLE [db.]table DELETE WHERE filter_expr -``` - -Выражение `filter_expr` должно иметь тип `UInt8`. Запрос удаляет строки таблицы, для которых это выражение принимает ненулевое значение. - -``` sql -ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr -``` - -Выражение `filter_expr` должно иметь тип `UInt8`. Запрос изменяет значение указанных столбцов на вычисленное значение соответствующих выражений в каждой строке, для которой `filter_expr` принимает ненулевое значение. Вычисленные значения преобразуются к типу столбца с помощью оператора `CAST`. Изменение столбцов, которые используются при вычислении первичного ключа или ключа партиционирования, не поддерживается. - -``` sql -ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name -``` - -Команда перестроит вторичный индекс `name` для партиции `partition_name`. - -В одном запросе можно указать несколько команд через запятую. - -Для \*MergeTree-таблиц мутации выполняются, перезаписывая данные по кускам (parts). При этом атомарности нет — куски заменяются на помутированные по мере выполнения и запрос `SELECT`, заданный во время выполнения мутации, увидит данные как из измененных кусков, так и из кусков, которые еще не были изменены. - -Мутации линейно упорядочены между собой и накладываются на каждый кусок в порядке добавления. Мутации также упорядочены со вставками - гарантируется, что данные, вставленные в таблицу до начала выполнения запроса мутации, будут изменены, а данные, вставленные после окончания запроса мутации, изменены не будут. При этом мутации никак не блокируют вставки. - -Запрос завершается немедленно после добавления информации о мутации (для реплицированных таблиц - в ZooKeeper, для нереплицированных - на файловую систему). Сама мутация выполняется асинхронно, используя настройки системного профиля. Следить за ходом её выполнения можно по таблице [`system.mutations`](../../operations/system_tables.md#system_tables-mutations). Добавленные мутации будут выполняться до конца даже в случае перезапуска серверов ClickHouse. Откатить мутацию после её добавления нельзя, но если мутация по какой-то причине не может выполниться до конца, её можно остановить с помощью запроса [`KILL MUTATION`](misc.md#kill-mutation). - -Записи о последних выполненных мутациях удаляются не сразу (количество сохраняемых мутаций определяется параметром движка таблиц `finished_mutations_to_keep`). Более старые записи удаляются. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/alter/) diff --git a/docs/ru/sql_reference/statements/create.md b/docs/ru/sql_reference/statements/create.md deleted file mode 100644 index e09877d3495..00000000000 --- a/docs/ru/sql_reference/statements/create.md +++ /dev/null @@ -1,305 +0,0 @@ ---- -toc_priority: 35 -toc_title: CREATE ---- - -## CREATE DATABASE {#query-language-create-database} - -Создает базу данных. - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] -``` - -### Секции {#sektsii} - -- `IF NOT EXISTS` - - Если база данных с именем `db_name` уже существует, то ClickHouse не создаёт базу данных и: - - Не генерирует исключение, если секция указана. - - Генерирует исключение, если секция не указана. - -- `ON CLUSTER` - - ClickHouse создаёт базу данных `db_name` на всех серверах указанного кластера. - -- `ENGINE` - - - [MySQL](../../sql_reference/statements/create.md) - - Позволяет получать данные с удаленного сервера MySQL. - - По умолчанию ClickHouse использует собственный [движок баз данных](../../sql_reference/statements/create.md). - -## CREATE TABLE {#create-table-query} - -Запрос `CREATE TABLE` может иметь несколько форм. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [compression_codec] [TTL expr2], - ... -) ENGINE = engine -``` - -Создаёт таблицу с именем name в БД db или текущей БД, если db не указана, со структурой, указанной в скобках, и движком engine. -Структура таблицы представляет список описаний столбцов. Индексы, если поддерживаются движком, указываются в качестве параметров для движка таблицы. - -Описание столбца, это `name type`, в простейшем случае. Пример: `RegionID UInt32`. -Также могут быть указаны выражения для значений по умолчанию - смотрите ниже. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] -``` - -Создаёт таблицу с такой же структурой, как другая таблица. Можно указать другой движок для таблицы. Если движок не указан, то будет выбран такой же движок, как у таблицы `db2.name2`. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() -``` - -Создаёт таблицу с такой же структурой и данными, как результат соответствующей табличной функцией. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... -``` - -Создаёт таблицу со структурой, как результат запроса `SELECT`, с движком engine, и заполняет её данными из SELECT-а. - -Во всех случаях, если указано `IF NOT EXISTS`, то запрос не будет возвращать ошибку, если таблица уже существует. В этом случае, запрос будет ничего не делать. - -После секции `ENGINE` в запросе могут использоваться и другие секции в зависимости от движка. Подробную документацию по созданию таблиц смотрите в описаниях [движков таблиц](../../sql_reference/statements/create.md#table_engines). - -### Значения по умолчанию {#create-default-values} - -В описании столбца, может быть указано выражение для значения по умолчанию, одного из следующих видов: -`DEFAULT expr`, `MATERIALIZED expr`, `ALIAS expr`. -Пример: `URLDomain String DEFAULT domain(URL)`. - -Если выражение для значения по умолчанию не указано, то в качестве значений по умолчанию будут использоваться нули для чисел, пустые строки для строк, пустые массивы для массивов, а также `0000-00-00` для дат и `0000-00-00 00:00:00` для дат с временем. NULL-ы не поддерживаются. - -В случае, если указано выражение по умолчанию, то указание типа столбца не обязательно. При отсутствии явно указанного типа, будет использован тип выражения по умолчанию. Пример: `EventDate DEFAULT toDate(EventTime)` - для столбца EventDate будет использован тип Date. - -При наличии явно указанного типа данных и выражения по умолчанию, это выражение будет приводиться к указанному типу с использованием функций приведения типа. Пример: `Hits UInt32 DEFAULT 0` - имеет такой же смысл, как `Hits UInt32 DEFAULT toUInt32(0)`. - -В качестве выражения для умолчания, может быть указано произвольное выражение от констант и столбцов таблицы. При создании и изменении структуры таблицы, проверяется, что выражения не содержат циклов. При INSERT-е проверяется разрешимость выражений - что все столбцы, из которых их можно вычислить, переданы. - -`DEFAULT expr` - -Обычное значение по умолчанию. Если в запросе INSERT не указан соответствующий столбец, то он будет заполнен путём вычисления соответствующего выражения. - -`MATERIALIZED expr` - -Материализованное выражение. Такой столбец не может быть указан при INSERT, то есть, он всегда вычисляется. -При INSERT без указания списка столбцов, такие столбцы не рассматриваются. -Также этот столбец не подставляется при использовании звёздочки в запросе SELECT. Это необходимо, чтобы сохранить инвариант, что дамп, полученный путём `SELECT *`, можно вставить обратно в таблицу INSERT-ом без указания списка столбцов. - -`ALIAS expr` - -Синоним. Такой столбец вообще не хранится в таблице. -Его значения не могут быть вставлены в таблицу, он не подставляется при использовании звёздочки в запросе SELECT. -Он может быть использован в SELECT-ах - в таком случае, во время разбора запроса, алиас раскрывается. - -При добавлении новых столбцов с помощью запроса ALTER, старые данные для этих столбцов не записываются. Вместо этого, при чтении старых данных, для которых отсутствуют значения новых столбцов, выполняется вычисление выражений по умолчанию на лету. При этом, если выполнение выражения требует использования других столбцов, не указанных в запросе, то эти столбцы будут дополнительно прочитаны, но только для тех блоков данных, для которых это необходимо. - -Если добавить в таблицу новый столбец, а через некоторое время изменить его выражение по умолчанию, то используемые значения для старых данных (для данных, где значения не хранились на диске) поменяются. Также заметим, что при выполнении фоновых слияний, данные для столбцов, отсутствующих в одном из сливаемых кусков, записываются в объединённый кусок. - -Отсутствует возможность задать значения по умолчанию для элементов вложенных структур данных. - -### Ограничения (constraints) {#constraints} - -Наряду с объявлением столбцов можно объявить ограничения на значения в столбцах таблицы: - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - ... - CONSTRAINT constraint_name_1 CHECK boolean_expr_1, - ... -) ENGINE = engine -``` - -`boolean_expr_1` может быть любым булевым выражением, состоящим из операторов сравнения или функций. При наличии одного или нескольких ограничений в момент вставки данных выражения ограничений будут проверяться на истинность для каждой вставляемой строки данных. В случае, если в теле INSERT запроса придут некорректные данные — клиент получит исключение с описанием нарушенного ограничения. - -Добавление большого числа ограничений может негативно повлиять на производительность `INSERT` запросов. - -### Выражение для TTL {#vyrazhenie-dlia-ttl} - -Определяет время хранения значений. Может быть указано только для таблиц семейства MergeTree. Подробнее смотрите в [TTL для столбцов и таблиц](../../sql_reference/statements/create.md#table_engine-mergetree-ttl). - -### Кодеки сжатия столбцов {#codecs} - -По умолчанию, ClickHouse применяет к столбцу метод сжатия, определённый в [конфигурации сервера](../../sql_reference/statements/create.md#compression). Кроме этого, можно задать метод сжатия для каждого отдельного столбца в запросе `CREATE TABLE`. - -``` sql -CREATE TABLE codec_example -( - dt Date CODEC(ZSTD), - ts DateTime CODEC(LZ4HC), - float_value Float32 CODEC(NONE), - double_value Float64 CODEC(LZ4HC(9)) - value Float32 CODEC(Delta, ZSTD) -) -ENGINE = -... -``` - -Если задать кодек для столбца, то кодек по умолчанию не применяется. Кодеки можно последовательно комбинировать, например, `CODEC(Delta, ZSTD)`. Чтобы выбрать наиболее подходящую для вашего проекта комбинацию кодеков, необходимо провести сравнительные тесты, подобные тем, что описаны в статье Altinity [New Encodings to Improve ClickHouse Efficiency](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse). - -!!! warning "Предупреждение" - Нельзя распаковать базу данных ClickHouse с помощью сторонних утилит наподобие `lz4`. Необходимо использовать специальную утилиту [clickhouse-compressor](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor). - -Сжатие поддерживается для следующих движков таблиц: - -- [MergeTree family](../../sql_reference/statements/create.md) -- [Log family](../../sql_reference/statements/create.md) -- [Set](../../sql_reference/statements/create.md) -- [Join](../../sql_reference/statements/create.md) - -ClickHouse поддерживает кодеки общего назначения и специализированные кодеки. - -#### Специализированные кодеки {#create-query-specialized-codecs} - -Эти кодеки разработаны для того, чтобы, используя особенности данных сделать сжатие более эффективным. Некоторые из этих кодеков не сжимают данные самостоятельно. Они готовят данные для кодеков общего назначения, которые сжимают подготовленные данные эффективнее, чем неподготовленные. - -Специализированные кодеки: - -- `Delta(delta_bytes)` — Метод, в котором исходные значения заменяются разностью двух соседних значений, за исключением первого значения, которое остаётся неизменным. Для хранения разниц используется до `delta_bytes`, т.е. `delta_bytes` — это максимальный размер исходных данных. Возможные значения `delta_bytes`: 1, 2, 4, 8. Значение по умолчанию для `delta_bytes` равно `sizeof(type)`, если результат 1, 2, 4, or 8. Во всех других случаях — 1. -- `DoubleDelta` — Вычисляется разницу от разниц и сохраняет её в компакном бинарном виде. Оптимальная степень сжатия достигается для монотонных последовательностей с постоянным шагом, наподобие временных рядов. Можно использовать с любым типом данных фиксированного размера. Реализует алгоритм, используемый в TSDB Gorilla, поддерживает 64-битные типы данных. Использует 1 дополнительный бит для 32-байтовых значений: 5-битные префиксы вместо 4-битных префиксов. Подробнее читайте в разделе «Compressing Time Stamps» документа [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `Gorilla` — Вычисляет XOR между текущим и предыдущим значением и записывает результат в компактной бинарной форме. Еффективно сохраняет ряды медленно изменяющихся чисел с плавающей запятой, поскольку наилучший коэффициент сжатия достигается, если соседние значения одинаковые. Реализует алгоритм, используемый в TSDB Gorilla, адаптируя его для работы с 64-битными значениями. Подробнее читайте в разделе «Compressing Values» документа [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `T64` — Метод сжатия который обрезает неиспользуемые старшие биты целочисленных значений (включая `Enum`, `Date` и `DateTime`). На каждом шаге алгоритма, кодек помещает блок из 64 значений в матрицу 64✕64, транспонирует её, обрезает неиспользуемые биты, а то, что осталось возвращает в виде последовательности. Неиспользуемые биты, это биты, которые не изменяются от минимального к максимальному на всём диапазоне значений куска данных. - -Кодеки `DoubleDelta` и `Gorilla` используются в TSDB Gorilla как компоненты алгоритма сжатия. Подход Gorilla эффективен в сценариях, когда данные представляют собой медленно изменяющиеся во времени величины. Метки времени эффективно сжимаются кодеком `DoubleDelta`, а значения кодеком `Gorilla`. Например, чтобы создать эффективно хранящуюся таблицу, используйте следующую конфигурацию: - -``` sql -CREATE TABLE codec_example -( - timestamp DateTime CODEC(DoubleDelta), - slow_values Float32 CODEC(Gorilla) -) -ENGINE = MergeTree() -``` - -#### Кодеки общего назначения {#create-query-common-purpose-codecs} - -Кодеки: - -- `NONE` — без сжатия. -- `LZ4` — [алгоритм сжатия без потерь](https://github.com/lz4/lz4) используемый по умолчанию. Применяет быстрое сжатие LZ4. -- `LZ4HC[(level)]` — алгоритм LZ4 HC (high compression) с настраиваемым уровнем сжатия. Уровень по умолчанию — 9. Настройка `level <= 0` устанавливает уровень сжания по умолчанию. Возможные уровни сжатия: \[1, 12\]. Рекомендуемый диапазон уровней: \[4, 9\]. -- `ZSTD[(level)]` — [алгоритм сжатия ZSTD](https://en.wikipedia.org/wiki/Zstandard) с настраиваемым уровнем сжатия `level`. Возможные уровни сжатия: \[1, 22\]. Уровень сжатия по умолчанию: 1. - -Высокие уровни сжатия полезны для ассимметричных сценариев, подобных «один раз сжал, много раз распаковал». Высокие уровни сжатия подразумеваю лучшее сжатие, но большее использование CPU. - -## Временные таблицы {#vremennye-tablitsy} - -ClickHouse поддерживает временные таблицы со следующими характеристиками: - -- Временные таблицы исчезают после завершения сессии, в том числе при обрыве соединения. -- Временная таблица использует только модуль памяти. -- Невозможно указать базу данных для временной таблицы. Она создается вне баз данных. -- Невозможно создать временную таблицу распределнным DDL запросом на всех серверах кластера (с опцией `ON CLUSTER`): такая таблица существует только в рамках существующей сессии. -- Если временная таблица имеет то же имя, что и некоторая другая, то, при упоминании в запросе без указания БД, будет использована временная таблица. -- При распределённой обработке запроса, используемые в запросе временные таблицы, передаются на удалённые серверы. - -Чтобы создать временную таблицу, используйте следующий синтаксис: - -``` sql -CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) -``` - -В большинстве случаев, временные таблицы создаются не вручную, а при использовании внешних данных для запроса, или при распределённом `(GLOBAL) IN`. Подробнее см. соответствующие разделы - -Вместо временных можно использовать обычные таблицы с [ENGINE = Memory](../../sql_reference/statements/create.md). - -## Распределенные DDL запросы (секция ON CLUSTER) {#raspredelennye-ddl-zaprosy-sektsiia-on-cluster} - -Запросы `CREATE`, `DROP`, `ALTER`, `RENAME` поддерживают возможность распределенного выполнения на кластере. -Например, следующий запрос создает распределенную (Distributed) таблицу `all_hits` на каждом хосте в `cluster`: - -``` sql -CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) -``` - -Для корректного выполнения таких запросов необходимо на каждом хосте иметь одинаковое определение кластера (для упрощения синхронизации конфигов можете использовать подстановки из ZooKeeper). Также необходимо подключение к ZooKeeper серверам. -Локальная версия запроса в конечном итоге будет выполнена на каждом хосте кластера, даже если некоторые хосты в данный момент не доступны. Гарантируется упорядоченность выполнения запросов в рамках одного хоста. - -## CREATE VIEW {#create-view} - -``` sql -CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... -``` - -Создаёт представление. Представления бывают двух видов - обычные и материализованные (MATERIALIZED). - -Обычные представления не хранят никаких данных, а всего лишь производят чтение из другой таблицы. То есть, обычное представление - не более чем сохранённый запрос. При чтении из представления, этот сохранённый запрос, используется в качестве подзапроса в секции FROM. - -Для примера, пусть вы создали представление: - -``` sql -CREATE VIEW view AS SELECT ... -``` - -и написали запрос: - -``` sql -SELECT a, b, c FROM view -``` - -Этот запрос полностью эквивалентен использованию подзапроса: - -``` sql -SELECT a, b, c FROM (SELECT ...) -``` - -Материализованные (MATERIALIZED) представления хранят данные, преобразованные соответствующим запросом SELECT. - -При создании материализованного представления без использования `TO [db].[table]`, нужно обязательно указать ENGINE - движок таблицы для хранения данных. - -При создании материализованного представления с испольованием `TO [db].[table]`, нельзя указывать `POPULATE` - -Материализованное представление устроено следующим образом: при вставке данных в таблицу, указанную в SELECT-е, кусок вставляемых данных преобразуется этим запросом SELECT, и полученный результат вставляется в представление. - -Если указано POPULATE, то при создании представления, в него будут вставлены имеющиеся данные таблицы, как если бы был сделан запрос `CREATE TABLE ... AS SELECT ...` . Иначе, представление будет содержать только данные, вставляемые в таблицу после создания представления. Не рекомендуется использовать POPULATE, так как вставляемые в таблицу данные во время создания представления, не попадут в него. - -Запрос `SELECT` может содержать `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`… Следует иметь ввиду, что соответствующие преобразования будут выполняться независимо, на каждый блок вставляемых данных. Например, при наличии `GROUP BY`, данные будут агрегироваться при вставке, но только в рамках одной пачки вставляемых данных. Далее, данные не будут доагрегированы. Исключение - использование ENGINE, производящего агрегацию данных самостоятельно, например, `SummingMergeTree`. - -Недоработано выполнение запросов `ALTER` над материализованными представлениями, поэтому они могут быть неудобными для использования. Если материализованное представление использует конструкцию `TO [db.]name`, то можно выполнить `DETACH` представления, `ALTER` для целевой таблицы и последующий `ATTACH` ранее отсоединенного (`DETACH`) представления. - -Представления выглядят так же, как обычные таблицы. Например, они перечисляются в результате запроса `SHOW TABLES`. - -Отсутствует отдельный запрос для удаления представлений. Чтобы удалить представление, следует использовать `DROP TABLE`. - -## CREATE DICTIONARY {#create-dictionary-query} - -``` sql -CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] -( - key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - attr1 type2 [DEFAULT|EXPRESSION expr3], - attr2 type2 [DEFAULT|EXPRESSION expr4] -) -PRIMARY KEY key1, key2 -SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) -LAYOUT(LAYOUT_NAME([param_name param_value])) -LIFETIME([MIN val1] MAX val2) -``` - -Создаёт [внешний словарь](../../sql_reference/statements/create.md) с заданной [структурой](../../sql_reference/statements/create.md), [источником](../../sql_reference/statements/create.md), [способом размещения в памяти](../../sql_reference/statements/create.md) и [периодом обновления](../../sql_reference/statements/create.md). - -Структура внешнего словаря состоит из атрибутов. Атрибуты словаря задаются как столбцы таблицы. Единственным обязательным свойством атрибута является его тип, все остальные свойства могут иметь значения по умолчанию. - -В зависимости от [способа размещения словаря в памяти](../../sql_reference/statements/create.md), ключами словаря могут быть один и более атрибутов. - -Смотрите [Внешние словари](../../sql_reference/statements/create.md). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/create/) diff --git a/docs/ru/sql_reference/statements/index.md b/docs/ru/sql_reference/statements/index.md deleted file mode 100644 index 5b461b73c92..00000000000 --- a/docs/ru/sql_reference/statements/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -toc_folder_title: Выражения -toc_priority: 31 ---- - diff --git a/docs/ru/sql_reference/statements/insert_into.md b/docs/ru/sql_reference/statements/insert_into.md deleted file mode 100644 index e9c80466a58..00000000000 --- a/docs/ru/sql_reference/statements/insert_into.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -toc_priority: 34 -toc_title: INSERT INTO ---- - -## INSERT {#insert} - -Добавление данных. - -Базовый формат запроса: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... -``` - -В запросе можно указать список столбцов для вставки `[(c1, c2, c3)]`. В этом случае, в остальные столбцы записываются: - -- Значения, вычисляемые из `DEFAULT` выражений, указанных в определении таблицы. -- Нули и пустые строки, если `DEFAULT` не определены. - -Если [strict\_insert\_defaults=1](../../operations/settings/settings.md), то столбцы, для которых не определены `DEFAULT`, необходимо перечислить в запросе. - -В INSERT можно передавать данные любого [формата](../../interfaces/formats.md#formats), который поддерживает ClickHouse. Для этого формат необходимо указать в запросе в явном виде: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set -``` - -Например, следующий формат запроса идентичен базовому варианту INSERT … VALUES: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... -``` - -ClickHouse отсекает все пробелы и один перенос строки (если он есть) перед данными. Рекомендуем при формировании запроса переносить данные на новую строку после операторов запроса (это важно, если данные начинаются с пробелов). - -Пример: - -``` sql -INSERT INTO t FORMAT TabSeparated -11 Hello, world! -22 Qwerty -``` - -С помощью консольного клиента или HTTP интерфейса можно вставлять данные отдельно от запроса. Как это сделать, читайте в разделе «[Интерфейсы](../../interfaces/index.md#interfaces)». - -### Ограничения (constraints) {#ogranicheniia-constraints} - -Если в таблице объявлены [ограничения](create.md#constraints), то их выполнимость будет проверена для каждой вставляемой строки. Если для хотя бы одной строки ограничения не будут выполнены, запрос будет остановлен. - -### Вставка результатов `SELECT` {#insert_query_insert-select} - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... -``` - -Соответствие столбцов определяется их позицией в секции SELECT. При этом, их имена в выражении SELECT и в таблице для INSERT, могут отличаться. При необходимости выполняется приведение типов данных, эквивалентное соответствующему оператору CAST. - -Все форматы данных кроме Values не позволяют использовать в качестве значений выражения, такие как `now()`, `1 + 2` и подобные. Формат Values позволяет ограниченно использовать выражения, но это не рекомендуется, так как в этом случае для их выполнения используется неэффективный вариант кода. - -Не поддерживаются другие запросы на модификацию части данных: `UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`. -Вы можете удалять старые данные с помощью запроса `ALTER TABLE ... DROP PARTITION`. - -Для табличной функции [input()](../table_functions/input.md) после секции `SELECT` должна следовать -секция `FORMAT`. - -### Замечания о производительности {#zamechaniia-o-proizvoditelnosti} - -`INSERT` сортирует входящие данные по первичному ключу и разбивает их на партиции по ключу партиционирования. Если вы вставляете данные в несколько партиций одновременно, то это может значительно снизить производительность запроса `INSERT`. Чтобы избежать этого: - -- Добавляйте данные достаточно большими пачками. Например, по 100 000 строк. -- Группируйте данные по ключу партиционирования самостоятельно перед загрузкой в ClickHouse. - -Снижения производительности не будет, если: - -- Данные поступают в режиме реального времени. -- Вы загружаете данные, которые как правило отсортированы по времени. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/insert_into/) diff --git a/docs/ru/sql_reference/statements/misc.md b/docs/ru/sql_reference/statements/misc.md deleted file mode 100644 index d8278534d46..00000000000 --- a/docs/ru/sql_reference/statements/misc.md +++ /dev/null @@ -1,238 +0,0 @@ -# Прочие виды запросов {#prochie-vidy-zaprosov} - -## ATTACH {#attach} - -Запрос полностью аналогичен запросу `CREATE`, но: - -- вместо слова `CREATE` используется слово `ATTACH`; -- запрос не создаёт данные на диске, а предполагает, что данные уже лежат в соответствующих местах, и всего лишь добавляет информацию о таблице на сервер. После выполнения запроса `ATTACH` сервер будет знать о существовании таблицы. - -Если таблица перед этим была отсоединена (`DETACH`), т.е. её структура известна, можно использовать сокращенную форму записи без определения структуры. - -``` sql -ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] -``` - -Этот запрос используется при старте сервера. Сервер хранит метаданные таблиц в виде файлов с запросами `ATTACH`, которые он просто исполняет при запуске (за исключением системных таблиц, которые явно создаются на сервере). - -## CHECK TABLE {#check-table} - -Проверяет таблицу на повреждение данных. - -``` sql -CHECK TABLE [db.]name -``` - -Запрос `CHECK TABLE` сравнивает текущие размеры файлов (в которых хранятся данные из колонок) с ожидаемыми значениями. Если значения не совпадают, данные в таблице считаются поврежденными. Искажение возможно, например, из-за сбоя при записи данных. - -Ответ содержит колонку `result`, содержащую одну строку с типом [Boolean](../../sql_reference/data_types/boolean.md). Допустимые значения: - -- 0 - данные в таблице повреждены; -- 1 - данные не повреждены. - -Запрос `CHECK TABLE` поддерживает следующие движки таблиц: - -- [Log](../../engines/table_engines/log_family/log.md) -- [TinyLog](../../engines/table_engines/log_family/tinylog.md) -- [StripeLog](../../engines/table_engines/log_family/stripelog.md) -- [Семейство MergeTree](../../engines/table_engines/mergetree_family/index.md) - -При попытке выполнить запрос с таблицами с другими табличными движками, ClickHouse генерирует исключение. - -В движках `*Log` не предусмотрено автоматическое восстановление данных после сбоя. Используйте запрос `CHECK TABLE`, чтобы своевременно выявлять повреждение данных. - -Для движков из семейства `MergeTree` запрос `CHECK TABLE` показывает статус проверки для каждого отдельного куска данных таблицы на локальном сервере. - -**Что делать, если данные повреждены** - -В этом случае можно скопировать оставшиеся неповрежденные данные в другую таблицу. Для этого: - -1. Создайте новую таблицу с такой же структурой, как у поврежденной таблицы. Для этого выполните запрос `CREATE TABLE AS `. -2. Установите значение параметра [max\_threads](../../operations/settings/settings.md#settings-max_threads) в 1. Это нужно для того, чтобы выполнить следующий запрос в одном потоке. Установить значение параметра можно через запрос: `SET max_threads = 1`. -3. Выполните запрос `INSERT INTO SELECT * FROM `. В результате неповрежденные данные будут скопированы в другую таблицу. Обратите внимание, будут скопированы только те данные, которые следуют до поврежденного участка. -4. Перезапустите `clickhouse-client`, чтобы вернуть предыдущее значение параметра `max_threads`. - -## DESCRIBE TABLE {#misc-describe-table} - -``` sql -DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -Возвращает описание столбцов таблицы. - -Результат запроса содержит столбцы (все столбцы имеют тип String): - -- `name` — имя столбца таблицы; -- `type`— тип столбца; -- `default_type` — в каком виде задано [выражение для значения по умолчанию](create.md#create-default-values): `DEFAULT`, `MATERIALIZED` или `ALIAS`. Столбец содержит пустую строку, если значение по умолчанию не задано. -- `default_expression` — значение, заданное в секции `DEFAULT`; -- `comment_expression` — комментарий к столбцу. - -Вложенные структуры данных выводятся в «развёрнутом» виде. То есть, каждый столбец - по отдельности, с именем через точку. - -## DETACH {#detach} - -Удаляет из сервера информацию о таблице name. Сервер перестаёт знать о существовании таблицы. - -``` sql -DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -Но ни данные, ни метаданные таблицы не удаляются. При следующем запуске сервера, сервер прочитает метаданные и снова узнает о таблице. -Также, «отцепленную» таблицу можно прицепить заново запросом `ATTACH` (за исключением системных таблиц, для которых метаданные не хранятся). - -Запроса `DETACH DATABASE` нет. - -## DROP {#drop} - -Запрос имеет два вида: `DROP DATABASE` и `DROP TABLE`. - -``` sql -DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] -``` - -Удаляет все таблицы внутри базы данных db, а затем саму базу данных db. -Если указано `IF EXISTS` - не выдавать ошибку, если база данных не существует. - -``` sql -DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -Удаляет таблицу. -Если указано `IF EXISTS` - не выдавать ошибку, если таблица не существует или база данных не существует. - -## EXISTS {#exists} - -``` sql -EXISTS [TEMPORARY] TABLE [db.]name [INTO OUTFILE filename] [FORMAT format] -``` - -Возвращает один столбец типа `UInt8`, содержащий одно значение - `0`, если таблицы или БД не существует и `1`, если таблица в указанной БД существует. - -## KILL QUERY {#kill-query} - -``` sql -KILL QUERY [ON CLUSTER cluster] - WHERE - [SYNC|ASYNC|TEST] - [FORMAT format] -``` - -Пытается принудительно остановить исполняющиеся в данный момент запросы. -Запросы для принудительной остановки выбираются из таблицы system.processes с помощью условия, указанного в секции `WHERE` запроса `KILL`. - -Примеры - -``` sql --- Принудительно останавливает все запросы с указанным query_id: -KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - --- Синхронно останавливает все запросы пользователя 'username': -KILL QUERY WHERE user='username' SYNC -``` - -Readonly-пользователи могут останавливать только свои запросы. - -По умолчанию используется асинхронный вариант запроса (`ASYNC`), который не дожидается подтверждения остановки запросов. - -Синхронный вариант (`SYNC`) ожидает остановки всех запросов и построчно выводит информацию о процессах по ходу их остановки. -Ответ содержит колонку `kill_status`, которая может принимать следующие значения: - -1. ‘finished’ - запрос был успешно остановлен; -2. ‘waiting’ - запросу отправлен сигнал завершения, ожидается его остановка; -3. остальные значения описывают причину невозможности остановки запроса. - -Тестовый вариант запроса (`TEST`) только проверяет права пользователя и выводит список запросов для остановки. - -## KILL MUTATION {#kill-mutation} - -``` sql -KILL MUTATION [ON CLUSTER cluster] - WHERE - [TEST] - [FORMAT format] -``` - -Пытается остановить выполняющиеся в данные момент [мутации](alter.md#alter-mutations). Мутации для остановки выбираются из таблицы [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) с помощью условия, указанного в секции `WHERE` запроса `KILL`. - -Тестовый вариант запроса (`TEST`) только проверяет права пользователя и выводит список запросов для остановки. - -Примеры: - -``` sql --- Останавливает все мутации одной таблицы: -KILL MUTATION WHERE database = 'default' AND table = 'table' - --- Останавливает конкретную мутацию: -KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' -``` - -Запрос полезен в случаях, когда мутация не может выполниться до конца (например, если функция в запросе мутации бросает исключение на данных таблицы). - -Данные, уже изменённые мутацией, остаются в таблице (отката на старую версию данных не происходит). - -## OPTIMIZE {#misc_operations-optimize} - -``` sql -OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] -``` - -Запрос пытается запустить внеплановый мёрж кусков данных для таблиц семейства [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). Другие движки таблиц не поддерживаются. - -Если `OPTIMIZE` применяется к таблицам семейства [ReplicatedMergeTree](../../engines/table_engines/mergetree_family/replication.md), ClickHouse создаёт задачу на мёрж и ожидает её исполнения на всех узлах (если активирована настройка `replication_alter_partitions_sync`). - -- Если `OPTIMIZE` не выполняет мёрж по любой причине, ClickHouse не оповещает об этом клиента. Чтобы включить оповещения, используйте настройку [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop). -- Если указать `PARTITION`, то оптимизация выполняется только для указанной партиции. [Как задавать имя партиции в запросах](alter.md#alter-how-to-specify-part-expr). -- Если указать `FINAL`, то оптимизация выполняется даже в том случае, если все данные уже лежат в одном куске. -- Если указать `DEDUPLICATE`, то произойдет схлопывание полностью одинаковых строк (сравниваются значения во всех колонках), имеет смысл только для движка MergeTree. - -!!! warning "Внимание" - Запрос `OPTIMIZE` не может устранить причину появления ошибки «Too many parts». - -## RENAME {#misc_operations-rename} - -Переименовывает одну или несколько таблиц. - -``` sql -RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] -``` - -Все таблицы переименовываются под глобальной блокировкой. Переименовывание таблицы является лёгкой операцией. Если вы указали после TO другую базу данных, то таблица будет перенесена в эту базу данных. При этом, директории с базами данных должны быть расположены в одной файловой системе (иначе возвращается ошибка). - -## SET {#query-set} - -``` sql -SET param = value -``` - -Устанавливает значение `value` для [настройки](../../operations/settings/index.md) `param` в текущей сессии. [Конфигурационные параметры сервера](../../operations/server_configuration_parameters/settings.md) нельзя изменить подобным образом. - -Можно одним запросом установить все настройки из заданного профиля настроек. - -``` sql -SET profile = 'profile-name-from-the-settings-file' -``` - -Подробности смотрите в разделе [Настройки](../../operations/settings/settings.md). - -## TRUNCATE {#truncate} - -``` sql -TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -Удаляет все данные из таблицы. Если условие `IF EXISTS` не указано, запрос вернет ошибку, если таблицы не существует. - -Запрос `TRUNCATE` не поддерживается для следующих движков: [View](../../engines/table_engines/special/view.md), [File](../../engines/table_engines/special/file.md), [URL](../../engines/table_engines/special/url.md) и [Null](../../engines/table_engines/special/null.md). - -## USE {#use} - -``` sql -USE db -``` - -Позволяет установить текущую базу данных для сессии. -Текущая база данных используется для поиска таблиц, если база данных не указана в запросе явно через точку перед именем таблицы. -При использовании HTTP протокола запрос не может быть выполнен, так как понятия сессии не существует. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/misc/) diff --git a/docs/ru/sql_reference/statements/select.md b/docs/ru/sql_reference/statements/select.md deleted file mode 100644 index 2ceeb3489c2..00000000000 --- a/docs/ru/sql_reference/statements/select.md +++ /dev/null @@ -1,1406 +0,0 @@ ---- -toc_priority: 33 -toc_title: SELECT ---- - -# Синтаксис запросов SELECT {#sintaksis-zaprosov-select} - -`SELECT` осуществляет выборку данных. - -``` sql -[WITH expr_list|(subquery)] -SELECT [DISTINCT] expr_list -[FROM [db.]table | (subquery) | table_function] [FINAL] -[SAMPLE sample_coeff] -[ARRAY JOIN ...] -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list -[PREWHERE expr] -[WHERE expr] -[GROUP BY expr_list] [WITH TOTALS] -[HAVING expr] -[ORDER BY expr_list] -[LIMIT [offset_value, ]n BY columns] -[LIMIT [n, ]m] -[UNION ALL ...] -[INTO OUTFILE filename] -[FORMAT format] -``` - -Все секции, кроме списка выражений сразу после SELECT, являются необязательными. -Ниже секции будут описаны в порядке, почти соответствующем конвейеру выполнения запроса. - -Если в запросе отсутствуют секции `DISTINCT`, `GROUP BY`, `ORDER BY`, подзапросы в `IN` и `JOIN`, то запрос будет обработан полностью потоково, с использованием O(1) количества оперативки. -Иначе запрос может съесть много оперативки, если не указаны подходящие ограничения `max_memory_usage`, `max_rows_to_group_by`, `max_rows_to_sort`, `max_rows_in_distinct`, `max_bytes_in_distinct`, `max_rows_in_set`, `max_bytes_in_set`, `max_rows_in_join`, `max_bytes_in_join`, `max_bytes_before_external_sort`, `max_bytes_before_external_group_by`. Подробнее смотрите в разделе «Настройки». Присутствует возможность использовать внешнюю сортировку (с сохранением временных данных на диск) и внешнюю агрегацию. `Merge join` в системе нет. - -### Секция WITH {#sektsiia-with} - -Данная секция представляет собой [CTE](https://ru.wikipedia.org/wiki/Иерархические_и_рекурсивные_запросы_в_SQL), с рядом ограничений: -1. Рекурсивные запросы не поддерживаются -2. Если в качестве выражения используется подзапрос, то результат должен содержать ровно одну строку -3. Результаты выражений нельзя переиспользовать во вложенных запросах -В дальнейшем, результаты выражений можно использовать в секции SELECT. - -Пример 1: Использование константного выражения как «переменной» - -``` sql -WITH '2019-08-01 15:23:00' as ts_upper_bound -SELECT * -FROM hits -WHERE - EventDate = toDate(ts_upper_bound) AND - EventTime <= ts_upper_bound -``` - -Пример 2: Выкидывание выражения sum(bytes) из списка колонок в SELECT - -``` sql -WITH sum(bytes) as s -SELECT - formatReadableSize(s), - table -FROM system.parts -GROUP BY table -ORDER BY s -``` - -Пример 3: Использование результатов скалярного подзапроса - -``` sql -/* запрос покажет TOP 10 самых больших таблиц */ -WITH - ( - SELECT sum(bytes) - FROM system.parts - WHERE active - ) AS total_disk_usage -SELECT - (sum(bytes) / total_disk_usage) * 100 AS table_disk_usage, - table -FROM system.parts -GROUP BY table -ORDER BY table_disk_usage DESC -LIMIT 10 -``` - -Пример 4: Переиспользование выражения -В настоящий момент, переиспользование выражения из секции WITH внутри подзапроса возможно только через дублирование. - -``` sql -WITH ['hello'] AS hello -SELECT - hello, - * -FROM -( - WITH ['hello'] AS hello - SELECT hello -) -``` - -``` text -┌─hello─────┬─hello─────┐ -│ ['hello'] │ ['hello'] │ -└───────────┴───────────┘ -``` - -### Секция FROM {#select-from} - -Если секция FROM отсутствует, то данные будут читаться из таблицы `system.one`. -Таблица `system.one` содержит ровно одну строку (то есть, эта таблица выполняет такую же роль, как таблица DUAL, которую можно найти в других СУБД). - -Cекция `FROM` определяет источник данных: - -- Таблица -- Подзапрос -- [Табличная функция](../../sql_reference/statements/select.md) - -Также могут присутствовать `ARRAY JOIN` и обычный `JOIN` (смотрите ниже). - -Вместо таблицы, может быть указан подзапрос `SELECT` в скобках. -В отличие от стандартного SQL, после подзапроса не обязательно указывать его синоним. - -Для выполнения запроса, из соответствующей таблицы, вынимаются все столбцы, перечисленные в запросе. Из подзапросов выкидываются столбцы, не нужные для внешнего запроса. -Если в запросе не перечислено ни одного столбца (например, `SELECT count() FROM t`), то из таблицы всё равно вынимается один какой-нибудь столбец (предпочитается самый маленький), для того, чтобы можно было посчитать количество строк. - -Модификатор `FINAL` может быть использован в запросе `SELECT` из таблиц семейства [MergeTree](../../engines/table_engines/mergetree_family/index.md). При указании `FINAL`, данные будут выбираться полностью «домерженными». Стоит учитывать, что использование `FINAL` приводит к чтению также столбцов, относящихся к первичному ключу. Также, запрос будет выполняться в один поток, и при выполнении запроса будет выполняться слияние данных. Это приводит к тому, что при использовании `FINAL`, запрос выполняется медленнее. В большинстве случаев, следует избегать использования `FINAL`. -Модификатор `FINAL` может быть использован для всех таблиц семейства `MergeTree`, которые производят преобразования данных в процессе фоновых слияний (кроме GraphiteMergeTree). - -#### FINAL Modifier {#select-from-final} - -Применим при выборке данных из таблиц с движками таблиц семейства [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)), кроме `GraphiteMergeTree`. Если в запросе используется `FINAL`, то ClickHouse полностью мёржит данные перед выдачей результата, таким образом выполняя все преобразования данных, которые производятся движком таблиц при мёржах. - -Также поддержан для движков: - -- [Replicated](../../engines/table_engines/mergetree_family/replication.md)-версий `MergeTree`. -- [View](../../engines/table_engines/special/view.md), [Buffer](../../engines/table_engines/special/buffer.md), [Distributed](../../engines/table_engines/special/distributed.md), и [MaterializedView](../../engines/table_engines/special/materializedview.md), которые работают поверх других движков, если они созданы для таблиц с движками семейства `MergeTree`. - -Запросы, использующие `FINAL` исполняются медленнее аналогичных запросов без `FINAL`, поскольку: - -- Запрос исполняется в один поток и данные мёржатся в процессе выполнения. -- Запросы с модификатором `FINAL` дополнительно к столбцам, указанным в запросе, читают столбцы первичного ключа. - -По возможности не используйте модификатор `FINAL`. - -### Секция SAMPLE {#select-sample-clause} - -Секция `SAMPLE` позволяет выполнять запросы приближённо. Например, чтобы посчитать статистику по всем визитам, можно обработать 1/10 всех визитов и результат домножить на 10. - -Сэмплирование имеет смысл, когда: - -1. Точность результата не важна, например, для оценочных расчетов. -2. Возможности аппаратной части не позволяют соответствовать строгим критериям. Например, время ответа должно быть \<100 мс. При этом точность расчета имеет более низкий приоритет. -3. Точность результата участвует в бизнес-модели сервиса. Например, пользователи с бесплатной подпиской на сервис могут получать отчеты с меньшей точностью, чем пользователи с премиум подпиской. - -!!! note "Внимание" - Не стоит использовать сэмплирование в тех задачах, где важна точность расчетов. Например, при работе с финансовыми отчетами. - -Свойства сэмплирования: - -- Сэмплирование работает детерминированно. При многократном выполнении одного и того же запроса `SELECT .. SAMPLE`, результат всегда будет одинаковым. -- Сэмплирование поддерживает консистентность для разных таблиц. Имеется в виду, что для таблиц с одним и тем же ключом сэмплирования, подмножество данных в выборках будет одинаковым (выборки при этом должны быть сформированы для одинаковой доли данных). Например, выборка по идентификаторам посетителей выберет из разных таблиц строки с одинаковым подмножеством всех возможных идентификаторов. Это свойство позволяет использовать выборки в подзапросах в секции [IN](#select-in-operators), а также объединять выборки с помощью [JOIN](#select-join). -- Сэмплирование позволяет читать меньше данных с диска. Обратите внимание, для этого необходимо корректно указать ключ сэмплирования. Подробнее см. в разделе [Создание таблицы MergeTree](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). - -Сэмплирование поддерживается только таблицами семейства [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table) и только в том случае, если для таблиц был указан ключ сэмплирования (выражение, на основе которого должна производиться выборка). Подробнее см. в разделе [Создание таблиц MergeTree](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). - -Выражение `SAMPLE` в запросе можно задать следующими способами: - -| Способ задания SAMPLE | Описание | -|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `SAMPLE k` | Здесь `k` – это дробное число в интервале от 0 до 1.
Запрос будет выполнен по `k` доле данных. Например, если указано `SAMPLE 1/10`, то запрос будет выполнен для выборки из 1/10 данных. [Подробнее](#select-sample-k) | -| `SAMPLE n` | Здесь `n` – это достаточно большое целое число.
Запрос будет выполнен для выборки, состоящей из не менее чем `n` строк. Например, если указано `SAMPLE 10000000`, то запрос будет выполнен для не менее чем 10,000,000 строк. [Подробнее](#select-sample-n) | -| `SAMPLE k OFFSET m` | Здесь `k` и `m` – числа от 0 до 1.
Запрос будет выполнен по `k` доле данных. При этом выборка будет сформирована со смещением на `m` долю. [Подробнее](#select-sample-offset) | - -#### SAMPLE k {#select-sample-k} - -Здесь `k` – число в интервале от 0 до 1. Поддерживается как дробная, так и десятичная форма записи. Например, `SAMPLE 1/2` или `SAMPLE 0.5`. - -Если задано выражение `SAMPLE k`, запрос будет выполнен для `k` доли данных. Рассмотрим пример: - -``` sql -SELECT - Title, - count() * 10 AS PageViews -FROM hits_distributed -SAMPLE 0.1 -WHERE - CounterID = 34 -GROUP BY Title -ORDER BY PageViews DESC LIMIT 1000 -``` - -В этом примере запрос выполняется по выборке из 0.1 (10%) данных. Значения агрегатных функций не корректируются автоматически, поэтому чтобы получить приближённый результат, значение `count()` нужно вручную умножить на 10. - -Выборка с указанием относительного коэффициента является «согласованной»: для таблиц с одним и тем же ключом сэмплирования, выборка с одинаковой относительной долей всегда будет составлять одно и то же подмножество данных. То есть выборка из разных таблиц, на разных серверах, в разное время, формируется одинаковым образом. - -#### SAMPLE n {#select-sample-n} - -Здесь `n` – это достаточно большое целое число. Например, `SAMPLE 10000000`. - -Если задано выражение `SAMPLE n`, запрос будет выполнен для выборки из не менее `n` строк (но не значительно больше этого значения). Например, если задать `SAMPLE 10000000`, в выборку попадут не менее 10,000,000 строк. - -!!! note "Примечание" - Следует иметь в виду, что `n` должно быть достаточно большим числом. Так как минимальной единицей данных для чтения является одна гранула (её размер задаётся настройкой `index_granularity` для таблицы), имеет смысл создавать выборки, размер которых существенно превосходит размер гранулы. - -При выполнении `SAMPLE n` коэффициент сэмплирования заранее неизвестен (то есть нет информации о том, относительно какого количества данных будет сформирована выборка). Чтобы узнать коэффициент сэмплирования, используйте столбец `_sample_factor`. - -Виртуальный столбец `_sample_factor` автоматически создается в тех таблицах, для которых задано выражение `SAMPLE BY` (подробнее см. в разделе [Создание таблицы MergeTree](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table)). В столбце содержится коэффициент сэмплирования для таблицы – он рассчитывается динамически по мере добавления данных в таблицу. Ниже приведены примеры использования столбца `_sample_factor`. - -Предположим, у нас есть таблица, в которой ведется статистика посещений сайта. Пример ниже показывает, как рассчитать суммарное число просмотров: - -``` sql -SELECT sum(PageViews * _sample_factor) -FROM visits -SAMPLE 10000000 -``` - -Следующий пример показывает, как посчитать общее число визитов: - -``` sql -SELECT sum(_sample_factor) -FROM visits -SAMPLE 10000000 -``` - -В примере ниже рассчитывается среднее время на сайте. Обратите внимание, при расчете средних значений, умножать результат на коэффициент сэмплирования не нужно. - -``` sql -SELECT avg(Duration) -FROM visits -SAMPLE 10000000 -``` - -#### SAMPLE k OFFSET m {#select-sample-offset} - -Здесь `k` и `m` – числа в интервале от 0 до 1. Например, `SAMPLE 0.1 OFFSET 0.5`. Поддерживается как дробная, так и десятичная форма записи. - -При задании `SAMPLE k OFFSET m`, выборка будет сформирована из `k` доли данных со смещением на долю `m`. Примеры приведены ниже. - -**Пример 1** - -``` sql -SAMPLE 1/10 -``` - -В этом примере выборка будет сформирована по 1/10 доле всех данных: - -`[++------------------]` - -**Пример 2** - -``` sql -SAMPLE 1/10 OFFSET 1/2 -``` - -Здесь выборка, которая состоит из 1/10 доли данных, взята из второй половины данных. - -`[----------++--------]` - -### Секция ARRAY JOIN {#select-array-join-clause} - -Позволяет выполнить `JOIN` с массивом или вложенной структурой данных. Смысл похож на функцию [arrayJoin](../../sql_reference/statements/select.md#functions_arrayjoin), но функциональность более широкая. - -``` sql -SELECT -FROM -[LEFT] ARRAY JOIN -[WHERE|PREWHERE ] -... -``` - -В запросе может быть указано не более одной секции `ARRAY JOIN`. - -При использовании `ARRAY JOIN`, порядок выполнения запроса оптимизируется. Несмотря на то что секция `ARRAY JOIN` всегда указывается перед выражением `WHERE / PREWHERE`, преобразование `JOIN` может быть выполнено как до выполнения выражения `WHERE / PREWHERE` (если результат необходим в этом выражении), так и после (чтобы уменьшить объём расчетов). Порядок обработки контролируется оптимизатором запросов. - -Секция `ARRAY JOIN` поддерживает следующие формы записи: - -- `ARRAY JOIN` — в этом случае результат `JOIN` не будет содержать пустые массивы; -- `LEFT ARRAY JOIN` — пустые массивы попадут в результат выполнения `JOIN`. В качестве значения для пустых массивов устанавливается значение по умолчанию. Обычно это 0, пустая строка или NULL, в зависимости от типа элементов массива. - -Рассмотрим примеры использования `ARRAY JOIN` и `LEFT ARRAY JOIN`. Для начала создадим таблицу, содержащую столбец с типом [Array](../../sql_reference/statements/select.md), и добавим в него значение: - -``` sql -CREATE TABLE arrays_test -( - s String, - arr Array(UInt8) -) ENGINE = Memory; - -INSERT INTO arrays_test -VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []); -``` - -``` text -┌─s───────────┬─arr─────┐ -│ Hello │ [1,2] │ -│ World │ [3,4,5] │ -│ Goodbye │ [] │ -└─────────────┴─────────┘ -``` - -В примере ниже используется `ARRAY JOIN`: - -``` sql -SELECT s, arr -FROM arrays_test -ARRAY JOIN arr; -``` - -``` text -┌─s─────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -└───────┴─────┘ -``` - -Следующий пример использует `LEFT ARRAY JOIN`: - -``` sql -SELECT s, arr -FROM arrays_test -LEFT ARRAY JOIN arr; -``` - -``` text -┌─s───────────┬─arr─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ World │ 3 │ -│ World │ 4 │ -│ World │ 5 │ -│ Goodbye │ 0 │ -└─────────────┴─────┘ -``` - -#### Использование алиасов {#ispolzovanie-aliasov} - -Для массива в секции `ARRAY JOIN` может быть указан алиас. В этом случае, элемент массива будет доступен под этим алиасом, а сам массив — под исходным именем. Пример: - -``` sql -SELECT s, arr, a -FROM arrays_test -ARRAY JOIN arr AS a; -``` - -``` text -┌─s─────┬─arr─────┬─a─┐ -│ Hello │ [1,2] │ 1 │ -│ Hello │ [1,2] │ 2 │ -│ World │ [3,4,5] │ 3 │ -│ World │ [3,4,5] │ 4 │ -│ World │ [3,4,5] │ 5 │ -└───────┴─────────┴───┘ -``` - -Используя алиасы, можно выполнять `JOIN` с внешними массивами: - -``` sql -SELECT s, arr_external -FROM arrays_test -ARRAY JOIN [1, 2, 3] AS arr_external; -``` - -``` text -┌─s───────────┬─arr_external─┐ -│ Hello │ 1 │ -│ Hello │ 2 │ -│ Hello │ 3 │ -│ World │ 1 │ -│ World │ 2 │ -│ World │ 3 │ -│ Goodbye │ 1 │ -│ Goodbye │ 2 │ -│ Goodbye │ 3 │ -└─────────────┴──────────────┘ -``` - -В секции `ARRAY JOIN` можно указать через запятую сразу несколько массивов. В этом случае, `JOIN` делается с ними одновременно (прямая сумма, а не прямое произведение). Обратите внимание, массивы должны быть одинаковых размеров. Примеры: - -``` sql -SELECT s, arr, a, num, mapped -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ -│ Hello │ [1,2] │ 1 │ 1 │ 2 │ -│ Hello │ [1,2] │ 2 │ 2 │ 3 │ -│ World │ [3,4,5] │ 3 │ 1 │ 4 │ -│ World │ [3,4,5] │ 4 │ 2 │ 5 │ -│ World │ [3,4,5] │ 5 │ 3 │ 6 │ -└───────┴─────────┴───┴─────┴────────┘ -``` - -В примере ниже используется функция [arrayEnumerate](../../sql_reference/statements/select.md#array_functions-arrayenumerate): - -``` sql -SELECT s, arr, a, num, arrayEnumerate(arr) -FROM arrays_test -ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; -``` - -``` text -┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ -│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ -│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ -│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ -│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ -│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ -└───────┴─────────┴───┴─────┴─────────────────────┘ -``` - -#### ARRAY JOIN с вложенными структурами данных {#array-join-s-vlozhennymi-strukturami-dannykh} - -`ARRAY JOIN` также работает с [вложенными структурами данных](../../sql_reference/statements/select.md). Пример: - -``` sql -CREATE TABLE nested_test -( - s String, - nest Nested( - x UInt8, - y UInt32) -) ENGINE = Memory; - -INSERT INTO nested_test -VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []); -``` - -``` text -┌─s───────┬─nest.x──┬─nest.y─────┐ -│ Hello │ [1,2] │ [10,20] │ -│ World │ [3,4,5] │ [30,40,50] │ -│ Goodbye │ [] │ [] │ -└─────────┴─────────┴────────────┘ -``` - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -При указании имени вложенной структуры данных в `ARRAY JOIN`, смысл такой же, как `ARRAY JOIN` со всеми элементами-массивами, из которых она состоит. Пример: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`, `nest.y`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─┐ -│ Hello │ 1 │ 10 │ -│ Hello │ 2 │ 20 │ -│ World │ 3 │ 30 │ -│ World │ 4 │ 40 │ -│ World │ 5 │ 50 │ -└───────┴────────┴────────┘ -``` - -Такой вариант тоже имеет смысл: - -``` sql -SELECT s, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN `nest.x`; -``` - -``` text -┌─s─────┬─nest.x─┬─nest.y─────┐ -│ Hello │ 1 │ [10,20] │ -│ Hello │ 2 │ [10,20] │ -│ World │ 3 │ [30,40,50] │ -│ World │ 4 │ [30,40,50] │ -│ World │ 5 │ [30,40,50] │ -└───────┴────────┴────────────┘ -``` - -Алиас для вложенной структуры данных можно использовать, чтобы выбрать как результат `JOIN`-а, так и исходный массив. Пример: - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` -FROM nested_test -ARRAY JOIN nest AS n; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ -└───────┴─────┴─────┴─────────┴────────────┘ -``` - -Пример использования функции [arrayEnumerate](../../sql_reference/statements/select.md#array_functions-arrayenumerate): - -``` sql -SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num -FROM nested_test -ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; -``` - -``` text -┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ -│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ -│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ -│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ -│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ -│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ -└───────┴─────┴─────┴─────────┴────────────┴─────┘ -``` - -### Секция JOIN {#select-join} - -Соединяет данные в привычном для [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) смысле. - -!!! info "Примечание" - Не связана с функциональностью [ARRAY JOIN](#select-array-join-clause). - -``` sql -SELECT -FROM -[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN -(ON )|(USING ) ... -``` - -Вместо `` и `` можно указать имена таблиц. Это эквивалентно подзапросу `SELECT * FROM table`, за исключением особого случая таблицы с движком [Join](../../sql_reference/statements/select.md) – массива, подготовленного для присоединения. - -#### Поддерживаемые типы `JOIN` {#select-join-types} - -- `INNER JOIN` (or `JOIN`) -- `LEFT JOIN` (or `LEFT OUTER JOIN`) -- `RIGHT JOIN` (or `RIGHT OUTER JOIN`) -- `FULL JOIN` (or `FULL OUTER JOIN`) -- `CROSS JOIN` (or `,` ) - -Смотрите описание стандартного [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)). - -#### Множественный JOIN {#mnozhestvennyi-join} - -При выполнении запросов, ClickHouse перезаписывает множественный `JOIN` как комбинацию двух-табличных объединений и обрабатывает их последовательно. Например, если необходимо объединить четыре таблицы, ClickHouse объединяет первую и вторую таблицы, затем соединяет результат с третьей, а затем с четвертой. - -Если запрос содержит секцию `WHERE`, ClickHouse пытается пробросить фильтры из этой секции в промежуточный `JOIN`. Если он не может пробросить фильтр в каждый промежуточный `JOIN`, ClickHouse применяет фильтры после того, как все `JOIN` будут выполнены. - -Для создания запросов мы рекомендуем использовать синтаксис `JOIN ON` или `JOIN USING`. Например: - -``` sql -SELECT * FROM t1 JOIN t2 ON t1.a = t2.a JOIN t3 ON t1.a = t3.a -``` - -В секции `FROM` вы можете использовать разделенные запятыми списки таблиц для объединения. Например: - -``` sql -SELECT * FROM t1, t2, t3 WHERE t1.a = t2.a AND t1.a = t3.a -``` - -Не смешивайте синтаксисы. - -ClickHouse не поддерживает синтаксис с запятыми напрямую и мы не рекомендуем его использовать. Алгоритм пытается переписать запрос с помощью секций `CROSS JOIN` и `INNER JOIN` и затем продолжает его выполнение. При переписывании запроса, ClickHouse пытается оптимизировать производительность и потребление памяти. По умолчанию, ClickHouse трактует запятые как `INNER JOIN` и конвертирует их в `CROSS JOIN` когда не может гарантировать, что `INNER JOIN` возвращает запрошенные данные. - -#### Строгость {#select-join-strictness} - -- `ALL` — если правая таблица содержит несколько подходящих строк, то ClickHouse выполняет их [декартово произведение](https://ru.wikipedia.org/wiki/Прямое_произведение). Это стандартное поведение `JOIN` в SQL. -- `ANY` — если в правой таблице несколько соответствующих строк, то присоединяется только первая найденная. Если в правой таблице есть только одна подходящая строка, то результаты `ANY` и `ALL` совпадают. -- `ASOF` — для объединения последовательностей с нечётким совпадением. `ASOF JOIN` описан ниже по тексту. - -**Использование ASOF JOIN** - -`ASOF JOIN` применим в том случае, когда необходимо объединять записи, которые не имеют точного совпадения. - -Таблицы для `ASOF JOIN` должны иметь столбец с отсортированной последовательностью. Этот столбец не может быть единственным в таблице и должен быть одного из типов: `UInt32`, `UInt64`, `Float32`, `Float64`, `Date` и `DateTime`. - -Синтаксис `ASOF JOIN ... ON`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF LEFT JOIN table_2 -ON equi_cond AND closest_match_cond -``` - -Можно использовать произвольное количество условий равенства и одно условие на ближайшее совпадение. Например, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`. - -Условия, поддержанные для проверки на ближайшее совпадение: `>`, `>=`, `<`, `<=`. - -Синтаксис `ASOF JOIN ... USING`: - -``` sql -SELECT expressions_list -FROM table_1 -ASOF JOIN table_2 -USING (equi_column1, ... equi_columnN, asof_column) -``` - -Для слияния по равенству `ASOF JOIN` использует `equi_columnX`, а для слияния по ближайшему совпадению использует `asof_column` с условием `table_1.asof_column >= table_2.asof_column`. Столбец `asof_column` должен быть последним в секции `USING`. - -Например, рассмотрим следующие таблицы: - - table_1 table_2 - event | ev_time | user_id event | ev_time | user_id - ----------|---------|---------- ----------|---------|---------- - ... ... - event_1_1 | 12:00 | 42 event_2_1 | 11:59 | 42 - ... event_2_2 | 12:30 | 42 - event_1_2 | 13:00 | 42 event_2_3 | 13:00 | 42 - ... ... - -`ASOF JOIN` принимает метку времени пользовательского события из `table_1` и находит такое событие в `table_2` метка времени которого наиболее близка к метке времени события из `table_1` в соответствии с условием на ближайшее совпадение. При этом столбец `user_id` используется для объединения по равенству, а столбец `ev_time` для объединения по ближайшему совпадению. В нашем примере `event_1_1` может быть объединено с `event_2_1`, `event_1_2` может быть объединено с `event_2_3`, а `event_2_2` не объединяется. - -!!! note "Примечание" - `ASOF JOIN` не поддержан для движка таблиц [Join](../../sql_reference/statements/select.md). - -Чтобы задать значение строгости по умолчанию, используйте сессионный параметр [join\_default\_strictness](../../operations/settings/settings.md#settings-join_default_strictness). - -#### GLOBAL JOIN {#global-join} - -При использовании обычного `JOIN` , запрос отправляется на удалённые серверы. На каждом из них выполняются подзапросы для формирования «правой» таблицы, и с этой таблицей выполняется соединение. То есть, «правая» таблица формируется на каждом сервере отдельно. - -При использовании `GLOBAL ... JOIN`, сначала сервер-инициатор запроса запускает подзапрос для вычисления правой таблицы. Эта временная таблица передаётся на каждый удалённый сервер, и на них выполняются запросы с использованием переданных временных данных. - -Будьте аккуратны при использовании `GLOBAL` . За дополнительной информацией обращайтесь в раздел [Распределенные подзапросы](#select-distributed-subqueries). - -**Советы по использованию** - -Из подзапроса удаляются все столбцы, ненужные для `JOIN`. - -При запуске `JOIN`, отсутствует оптимизация порядка выполнения по отношению к другим стадиям запроса. Соединение (поиск в «правой» таблице) выполняется до фильтрации в `WHERE` и до агрегации. Чтобы явно задать порядок вычислений, рекомендуется выполнять `JOIN` подзапроса с подзапросом. - -Пример: - -``` sql -SELECT - CounterID, - hits, - visits -FROM -( - SELECT - CounterID, - count() AS hits - FROM test.hits - GROUP BY CounterID -) ANY LEFT JOIN -( - SELECT - CounterID, - sum(Sign) AS visits - FROM test.visits - GROUP BY CounterID -) USING CounterID -ORDER BY hits DESC -LIMIT 10 -``` - -``` text -┌─CounterID─┬───hits─┬─visits─┐ -│ 1143050 │ 523264 │ 13665 │ -│ 731962 │ 475698 │ 102716 │ -│ 722545 │ 337212 │ 108187 │ -│ 722889 │ 252197 │ 10547 │ -│ 2237260 │ 196036 │ 9522 │ -│ 23057320 │ 147211 │ 7689 │ -│ 722818 │ 90109 │ 17847 │ -│ 48221 │ 85379 │ 4652 │ -│ 19762435 │ 77807 │ 7026 │ -│ 722884 │ 77492 │ 11056 │ -└───────────┴────────┴────────┘ -``` - -У подзапросов нет возможности задать имена и нет возможности их использовать для того, чтобы сослаться на столбец из конкретного подзапроса. -Требуется, чтобы столбцы, указанные в `USING`, назывались одинаково в обоих подзапросах, а остальные столбцы - по-разному. Изменить имена столбцов в подзапросах можно с помощью синонимов (в примере используются синонимы hits и visits). - -В секции `USING` указывается один или несколько столбцов для соединения, что обозначает условие на равенство этих столбцов. Список столбцов задаётся без скобок. Более сложные условия соединения не поддерживаются. - -«Правая» таблица (результат подзапроса) располагается в оперативной памяти. Если её не хватает, вы не сможете выполнить `JOIN`. - -Каждый раз для выполнения запроса с одинаковым `JOIN`, подзапрос выполняется заново — результат не кэшируется. Это можно избежать, используя специальный движок таблиц [Join](../../engines/table_engines/special/join.md), представляющий собой подготовленное множество для соединения, которое всегда находится в оперативке. - -В некоторых случаях более эффективно использовать `IN` вместо `JOIN`. -Среди разных типов `JOIN`, наиболее эффективен `ANY LEFT JOIN`, следующий по эффективности `ANY INNER JOIN`. Наименее эффективны `ALL LEFT JOIN` и `ALL INNER JOIN`. - -Если `JOIN` необходим для соединения с таблицами измерений (dimension tables - сравнительно небольшие таблицы, которые содержат свойства измерений - например, имена для рекламных кампаний), то использование `JOIN` может быть не очень удобным из-за громоздкости синтаксиса, а также из-за того, что правая таблица читается заново при каждом запросе. Специально для таких случаев существует функциональность «Внешние словари», которую следует использовать вместо `JOIN`. Дополнительные сведения смотрите в разделе [Внешние словари](../../sql_reference/statements/select.md). - -**Ограничения по памяти** - -ClickHouse использует алгоритм [hash join](https://en.wikipedia.org/wiki/Hash_join). ClickHouse принимает `` и создает для него хэш-таблицу в RAM. Чтобы ограничить потребление памяти операцией `JOIN`, используйте следующие параметры: - -- [max\_rows\_in\_join](../../operations/settings/query_complexity.md#settings-max_rows_in_join) — ограничивает количество строк в хэш-таблице. -- [max\_bytes\_in\_join](../../operations/settings/query_complexity.md#settings-max_bytes_in_join) — ограничивает размер хэш-таблицы. - -По достижении любого из этих ограничений, ClickHouse действует в соответствии с настройкой [join\_overflow\_mode](../../operations/settings/query_complexity.md#settings-join_overflow_mode). - -#### Обработка пустых ячеек и NULL {#obrabotka-pustykh-iacheek-i-null} - -При слиянии таблиц могут появляться пустые ячейки. То, каким образом ClickHouse заполняет эти ячейки, определяется настройкой [join\_use\_nulls](../../operations/settings/settings.md#join_use_nulls). - -Если ключами `JOIN` выступают поля типа [Nullable](../../sql_reference/statements/select.md), то строки, где хотя бы один из ключей имеет значение [NULL](../syntax.md#null-literal), не соединяются. - -#### Ограничения синтаксиса {#ogranicheniia-sintaksisa} - -Для множественных секций `JOIN` в одном запросе `SELECT`: - -- Получение всех столбцов через `*` возможно только при объединении таблиц, но не подзапросов. -- Секция `PREWHERE` недоступна. - -Для секций `ON`, `WHERE` и `GROUP BY`: - -- Нельзя использовать произвольные выражения в секциях `ON`, `WHERE`, и `GROUP BY`, однако можно определить выражение в секции `SELECT` и затем использовать его через алиас в других секциях. - -### Секция WHERE {#select-where} - -Позволяет задать выражение, которое ClickHouse использует для фильтрации данных перед всеми другими действиями в запросе кроме выражений, содержащихся в секции [PREWHERE](#select-prewhere). Обычно, это выражение с логическими операторами. - -Результат выражения должен иметь тип `UInt8`. - -ClickHouse использует в выражении индексы, если это позволяет [движок таблицы](../../sql_reference/statements/select.md). - -Если в секции необходимо проверить [NULL](../syntax.md#null-literal), то используйте операторы [IS NULL](../operators.md#operator-is-null) и [IS NOT NULL](../operators.md#is-not-null), а также соответствующие функции `isNull` и `isNotNull`. В противном случае выражение будет считаться всегда не выполненным. - -Пример проверки на `NULL`: - -``` sql -SELECT * FROM t_null WHERE y IS NULL -``` - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -### Секция PREWHERE {#select-prewhere} - -Имеет такой же смысл, как и секция [WHERE](#select-where). Отличие состоит в том, какие данные читаются из таблицы. -При использовании `PREWHERE`, из таблицы сначала читаются только столбцы, необходимые для выполнения `PREWHERE`. Затем читаются остальные столбцы, нужные для выполнения запроса, но из них только те блоки, в которых выражение в `PREWHERE` истинное. - -`PREWHERE` имеет смысл использовать, если есть условия фильтрации, которые использует меньшинство столбцов из тех, что есть в запросе, но достаточно сильно фильтрует данные. Таким образом, сокращается количество читаемых данных. - -Например, полезно писать `PREWHERE` для запросов, которые вынимают много столбцов, но в которых фильтрация производится лишь по нескольким столбцам. - -`PREWHERE` поддерживается только таблицами семейства `*MergeTree`. - -В запросе могут быть одновременно указаны секции `PREWHERE` и `WHERE`. В этом случае, `PREWHERE` идёт перед `WHERE`. - -Если настройка `optimize_move_to_prewhere` выставлена в `1`, то при отсутствии `PREWHERE`, система будет автоматически переносить части выражений из `WHERE` в `PREWHERE` согласно некоторой эвристике. - -### Секция GROUP BY {#select-group-by-clause} - -Это одна из наиболее важных частей СУБД. - -Секция GROUP BY, если есть, должна содержать список выражений. Каждое выражение далее будем называть «ключом». -При этом, все выражения в секциях SELECT, HAVING, ORDER BY, должны вычисляться из ключей или из агрегатных функций. То есть, каждый выбираемый из таблицы столбец, должен использоваться либо в ключах, либо внутри агрегатных функций. - -Если запрос содержит столбцы таблицы только внутри агрегатных функций, то секция GROUP BY может не указываться, и подразумевается агрегация по пустому набору ключей. - -Пример: - -``` sql -SELECT - count(), - median(FetchTiming > 60 ? 60 : FetchTiming), - count() - sum(Refresh) -FROM hits -``` - -Но, в отличие от стандартного SQL, если в таблице нет строк (вообще нет или после фильтрации с помощью WHERE), в качестве результата возвращается пустой результат, а не результат из одной строки, содержащий «начальные» значения агрегатных функций. - -В отличие от MySQL (и в соответствии со стандартом SQL), вы не можете получить какое-нибудь значение некоторого столбца, не входящего в ключ или агрегатную функцию (за исключением константных выражений). Для обхода этого вы можете воспользоваться агрегатной функцией any (получить первое попавшееся значение) или min/max. - -Пример: - -``` sql -SELECT - domainWithoutWWW(URL) AS domain, - count(), - any(Title) AS title -- getting the first occurred page header for each domain. -FROM hits -GROUP BY domain -``` - -GROUP BY вычисляет для каждого встретившегося различного значения ключей, набор значений агрегатных функций. - -Не поддерживается GROUP BY по столбцам-массивам. - -Не поддерживается указание констант в качестве аргументов агрегатных функций. Пример: sum(1). Вместо этого, вы можете избавиться от констант. Пример: `count()`. - -#### Обработка NULL {#obrabotka-null} - -При группировке, ClickHouse рассматривает [NULL](../syntax.md) как значение, причём `NULL=NULL`. - -Рассмотрим, что это значит на примере. - -Пусть есть таблица: - -``` text -┌─x─┬────y─┐ -│ 1 │ 2 │ -│ 2 │ ᴺᵁᴸᴸ │ -│ 3 │ 2 │ -│ 3 │ 3 │ -│ 3 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -В результате запроса `SELECT sum(x), y FROM t_null_big GROUP BY y` мы получим: - -``` text -┌─sum(x)─┬────y─┐ -│ 4 │ 2 │ -│ 3 │ 3 │ -│ 5 │ ᴺᵁᴸᴸ │ -└────────┴──────┘ -``` - -Видно, что `GROUP BY` для `У = NULL` просуммировал `x`, как будто `NULL` — это значение. - -Если в `GROUP BY` передать несколько ключей, то в результате мы получим все комбинации выборки, как если бы `NULL` был конкретным значением. - -#### Модификатор WITH TOTALS {#modifikator-with-totals} - -Если указан модификатор WITH TOTALS, то будет посчитана ещё одна строчка, в которой в столбцах-ключах будут содержаться значения по умолчанию (нули, пустые строки), а в столбцах агрегатных функций - значения, посчитанные по всем строкам («тотальные» значения). - -Эта дополнительная строчка выводится в форматах JSON\*, TabSeparated\*, Pretty\* отдельно от остальных строчек. В остальных форматах эта строчка не выводится. - -В форматах JSON\* строчка выводится отдельным полем totals. В форматах TabSeparated\* строчка выводится после основного результата, и перед ней (после остальных данных) вставляется пустая строка. В форматах Pretty\* строчка выводится отдельной табличкой после основного результата. - -`WITH TOTALS` может выполняться по-разному при наличии HAVING. Поведение зависит от настройки totals\_mode. -По умолчанию `totals_mode = 'before_having'`. В этом случае totals считается по всем строчкам, включая непрошедших через HAVING и max\_rows\_to\_group\_by. - -Остальные варианты учитывают в totals только строчки, прошедшие через HAVING, и имеют разное поведение при наличии настройки `max_rows_to_group_by` и `group_by_overflow_mode = 'any'`. - -`after_having_exclusive` - не учитывать строчки, не прошедшие `max_rows_to_group_by`. То есть в totals попадёт меньше или столько же строчек, чем если бы `max_rows_to_group_by` не было. - -`after_having_inclusive` - учитывать в totals все строчки, не прошедшие max\_rows\_to\_group\_by. То есть в totals попадёт больше или столько же строчек, чем если бы `max_rows_to_group_by` не было. - -`after_having_auto` - считать долю строчек, прошедших через HAVING. Если она больше некоторого значения (по умолчанию - 50%), то включить все строчки, не прошедшие max\_rows\_to\_group\_by в totals, иначе - не включить. - -`totals_auto_threshold` - по умолчанию 0.5. Коэффициент для работы `after_having_auto`. - -Если `max_rows_to_group_by` и `group_by_overflow_mode = 'any'` не используются, то все варианты вида `after_having` не отличаются, и вы можете использовать любой из них, например, `after_having_auto`. - -Вы можете использовать WITH TOTALS в подзапросах, включая подзапросы в секции JOIN (в этом случае соответствующие тотальные значения будут соединены). - -#### GROUP BY во внешней памяти {#select-group-by-in-external-memory} - -Можно включить сброс временных данных на диск, чтобы ограничить потребление оперативной памяти при выполнении `GROUP BY`. -Настройка [max\_bytes\_before\_external\_group\_by](../../operations/settings/settings.md#settings-max_bytes_before_external_group_by) определяет пороговое значение потребления RAM, по достижении которого временные данные `GROUP BY` сбрасываются в файловую систему. Если равно 0 (по умолчанию) - значит выключено. - -При использовании `max_bytes_before_external_group_by`, рекомендуем выставить `max_memory_usage` приблизительно в два раза больше. Это следует сделать, потому что агрегация выполняется в две стадии: чтение и формирование промежуточных данных (1) и слияние промежуточных данных (2). Сброс данных на файловую систему может производиться только на стадии 1. Если сброса временных данных не было, то на стадии 2 может потребляться до такого же объёма памяти, как на стадии 1. - -Например, если [max\_memory\_usage](../../operations/settings/settings.md#settings_max_memory_usage) было выставлено в 10000000000, и вы хотите использовать внешнюю агрегацию, то имеет смысл выставить `max_bytes_before_external_group_by` в 10000000000, а max\_memory\_usage в 20000000000. При срабатывании внешней агрегации (если был хотя бы один сброс временных данных в файловую систему) максимальное потребление оперативки будет лишь чуть-чуть больше `max_bytes_before_external_group_by`. - -При распределённой обработке запроса внешняя агрегация производится на удалённых серверах. Для того чтобы на сервере-инициаторе запроса использовалось немного оперативки, нужно выставить настройку `distributed_aggregation_memory_efficient` в 1. - -При слиянии данных, сброшенных на диск, а также при слиянии результатов с удалённых серверов, при включенной настройке `distributed_aggregation_memory_efficient`, потребляется до `1/256 * the_number_of_threads` количество потоков от общего объёма оперативки. - -При включенной внешней агрегации, если данных было меньше `max_bytes_before_external_group_by` (то есть сброса данных не было), то запрос работает так же быстро, как без внешней агрегации. Если же какие-то временные данные были сброшены, то время выполнения будет в несколько раз больше (примерно в три раза). - -Если есть `ORDER BY` с `LIMIT` после `GROUP BY`, то объём потребляемой RAM будет зависеть от объёма данных в `LIMIT`, а не во всей таблице. Однако, если `ORDER BY` используется без `LIMIT`, не забудьте включить внешнюю сортировку (`max_bytes_before_external_sort`). - -### Секция LIMIT BY {#sektsiia-limit-by} - -Запрос с секцией `LIMIT n BY expressions` выбирает первые `n` строк для каждого отличного значения `expressions`. Ключ `LIMIT BY` может содержать любое количество [выражений](../syntax.md#syntax-expressions). - -ClickHouse поддерживает следующий синтаксис: - -- `LIMIT [offset_value, ]n BY expressions` -- `LIMIT n OFFSET offset_value BY expressions` - -Во время обработки запроса, ClickHouse выбирает данные, упорядоченные по ключу сортировки. Ключ сортировки задаётся явно в секции [ORDER BY](#select-order-by) или неявно в свойствах движка таблицы. Затем ClickHouse применяет `LIMIT n BY expressions` и возвращает первые `n` для каждой отличной комбинации `expressions`. Если указан `OFFSET`, то для каждого блока данных, который принадлежит отдельной комбинации `expressions`, ClickHouse отступает `offset_value` строк от начала блока и возвращает не более `n`. Если `offset_value` больше, чем количество строк в блоке данных, ClickHouse не возвращает ни одной строки. - -`LIMIT BY` не связана с секцией `LIMIT`. Их можно использовать в одном запросе. - -**Примеры** - -Образец таблицы: - -``` sql -CREATE TABLE limit_by(id Int, val Int) ENGINE = Memory; -INSERT INTO limit_by values(1, 10), (1, 11), (1, 12), (2, 20), (2, 21); -``` - -Запросы: - -``` sql -SELECT * FROM limit_by ORDER BY id, val LIMIT 2 BY id -``` - -``` text -┌─id─┬─val─┐ -│ 1 │ 10 │ -│ 1 │ 11 │ -│ 2 │ 20 │ -│ 2 │ 21 │ -└────┴─────┘ -``` - -``` sql -SELECT * FROM limit_by ORDER BY id, val LIMIT 1, 2 BY id -``` - -``` text -┌─id─┬─val─┐ -│ 1 │ 11 │ -│ 1 │ 12 │ -│ 2 │ 21 │ -└────┴─────┘ -``` - -Запрос `SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` возвращает такой же результат. - -Следующий запрос выбирает топ 5 рефереров для каждой пары `domain, device_type`, но не более 100 строк (`LIMIT n BY + LIMIT`). - -``` sql -SELECT - domainWithoutWWW(URL) AS domain, - domainWithoutWWW(REFERRER_URL) AS referrer, - device_type, - count() cnt -FROM hits -GROUP BY domain, referrer, device_type -ORDER BY cnt DESC -LIMIT 5 BY domain, device_type -LIMIT 100 -``` - -Запрос выберет топ 5 рефереров для каждой пары `domain, device_type`, но не более 100 строк (`LIMIT n BY + LIMIT`). - -`LIMIT n BY` работает с [NULL](../syntax.md) как если бы это было конкретное значение. Т.е. в результате запроса пользователь получит все комбинации полей, указанных в `BY`. - -### Секция HAVING {#sektsiia-having} - -Позволяет отфильтровать результат, полученный после GROUP BY, аналогично секции WHERE. -WHERE и HAVING отличаются тем, что WHERE выполняется до агрегации (GROUP BY), а HAVING - после. -Если агрегации не производится, то HAVING использовать нельзя. - -### Секция ORDER BY {#select-order-by} - -Секция ORDER BY содержит список выражений, к каждому из которых также может быть приписано DESC или ASC (направление сортировки). Если ничего не приписано - это аналогично приписыванию ASC. ASC - сортировка по возрастанию, DESC - сортировка по убыванию. Обозначение направления сортировки действует на одно выражение, а не на весь список. Пример: `ORDER BY Visits DESC, SearchPhrase` - -Для сортировки по значениям типа String есть возможность указать collation (сравнение). Пример: `ORDER BY SearchPhrase COLLATE 'tr'` - для сортировки по поисковой фразе, по возрастанию, с учётом турецкого алфавита, регистронезависимо, при допущении, что строки в кодировке UTF-8. COLLATE может быть указан или не указан для каждого выражения в ORDER BY независимо. Если есть ASC или DESC, то COLLATE указывается после них. При использовании COLLATE сортировка всегда регистронезависима. - -Рекомендуется использовать COLLATE только для окончательной сортировки небольшого количества строк, так как производительность сортировки с указанием COLLATE меньше, чем обычной сортировки по байтам. - -Строки, для которых список выражений, по которым производится сортировка, принимает одинаковые значения, выводятся в произвольном порядке, который может быть также недетерминированным (каждый раз разным). -Если секция ORDER BY отсутствует, то, аналогично, порядок, в котором идут строки, не определён, и может быть недетерминированным. - -Порядок сортировки `NaN` и `NULL`: - -- С модификатором `NULLS FIRST` — Сначала `NULL`, затем `NaN`, затем остальные значения. -- С модификатором `NULLS LAST` — Сначала значения, затем `NaN`, затем `NULL`. -- По умолчанию — Как с модификатором `NULLS LAST`. - -Пример: - -Для таблицы - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 2 │ -│ 1 │ nan │ -│ 2 │ 2 │ -│ 3 │ 4 │ -│ 5 │ 6 │ -│ 6 │ nan │ -│ 7 │ ᴺᵁᴸᴸ │ -│ 6 │ 7 │ -│ 8 │ 9 │ -└───┴──────┘ -``` - -Выполним запрос `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST`, получим: - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 7 │ ᴺᵁᴸᴸ │ -│ 1 │ nan │ -│ 6 │ nan │ -│ 2 │ 2 │ -│ 2 │ 2 │ -│ 3 │ 4 │ -│ 5 │ 6 │ -│ 6 │ 7 │ -│ 8 │ 9 │ -└───┴──────┘ -``` - -Если кроме ORDER BY указан также не слишком большой LIMIT, то расходуется меньше оперативки. Иначе расходуется количество памяти, пропорциональное количеству данных для сортировки. При распределённой обработке запроса, если отсутствует GROUP BY, сортировка частично делается на удалённых серверах, а на сервере-инициаторе запроса производится слияние результатов. Таким образом, при распределённой сортировке, может сортироваться объём данных, превышающий размер памяти на одном сервере. - -Существует возможность выполнять сортировку во внешней памяти (с созданием временных файлов на диске), если оперативной памяти не хватает. Для этого предназначена настройка `max_bytes_before_external_sort`. Если она выставлена в 0 (по умолчанию), то внешняя сортировка выключена. Если она включена, то при достижении объёмом данных для сортировки указанного количества байт, накопленные данные будут отсортированы и сброшены во временный файл. После того, как все данные будут прочитаны, будет произведено слияние всех сортированных файлов и выдача результата. Файлы записываются в директорию /var/lib/clickhouse/tmp/ (по умолчанию, может быть изменено с помощью параметра tmp\_path) в конфиге. - -На выполнение запроса может расходоваться больше памяти, чем max\_bytes\_before\_external\_sort. Поэтому, значение этой настройки должно быть существенно меньше, чем max\_memory\_usage. Для примера, если на вашем сервере 128 GB оперативки, и вам нужно выполнить один запрос, то выставите max\_memory\_usage в 100 GB, а max\_bytes\_before\_external\_sort в 80 GB. - -Внешняя сортировка работает существенно менее эффективно, чем сортировка в оперативке. - -### Секция SELECT {#select-select} - -[Выражения](../syntax.md#syntax-expressions) указанные в секции `SELECT` анализируются после завершения всех вычислений из секций, описанных выше. Вернее, анализируются выражения, стоящие над агрегатными функциями, если есть агрегатные функции. -Сами агрегатные функции и то, что под ними, вычисляются при агрегации (`GROUP BY`). Эти выражения работают так, как будто применяются к отдельным строкам результата. - -Если в результат необходимо включить все столбцы, используйте символ звёздочка (`*`). Например, `SELECT * FROM ...`. - -Чтобы включить в результат несколько столбцов, выбрав их имена с помощью регулярных выражений [re2](https://en.wikipedia.org/wiki/RE2_(software)), используйте выражение `COLUMNS`. - -``` sql -COLUMNS('regexp') -``` - -Например, рассмотрим таблицу: - -``` sql -CREATE TABLE default.col_names (aa Int8, ab Int8, bc Int8) ENGINE = TinyLog -``` - -Следующий запрос выбирает данные из всех столбцов, содержащих в имени символ `a`. - -``` sql -SELECT COLUMNS('a') FROM col_names -``` - -``` text -┌─aa─┬─ab─┐ -│ 1 │ 1 │ -└────┴────┘ -``` - -Выбранные стоблцы возвращаются не в алфавитном порядке. - -В запросе можно использовать несколько выражений `COLUMNS`, а также вызывать над ними функции. - -Например: - -``` sql -SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names -``` - -``` text -┌─aa─┬─ab─┬─bc─┬─toTypeName(bc)─┐ -│ 1 │ 1 │ 1 │ Int8 │ -└────┴────┴────┴────────────────┘ -``` - -Каждый столбец, возвращённый выражением `COLUMNS`, передаётся в функцию отдельным аргументом. Также можно передавать и другие аргументы, если функция их поддерживаем. Аккуратно используйте функции. Если функция не поддерживает переданное количество аргументов, то ClickHouse генерирует исключение. - -Например: - -``` sql -SELECT COLUMNS('a') + COLUMNS('c') FROM col_names -``` - -``` text -Received exception from server (version 19.14.1): -Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of arguments for function plus doesn't match: passed 3, should be 2. -``` - -В этом примере, `COLUMNS('a')` возвращает два столбца: `aa` и `ab`. `COLUMNS('c')` возвращает столбец `bc`. Оператор `+` не работает с тремя аргументами, поэтому ClickHouse генерирует исключение с соответствущим сообщением. - -Столбцы, которые возвращаются выражением `COLUMNS` могут быть разных типов. Если `COLUMNS` не возвращает ни одного столбца и это единственное выражение в запросе `SELECT`, то ClickHouse генерирует исключение. - -### Секция DISTINCT {#select-distinct} - -Если указано `DISTINCT`, то из всех множеств полностью совпадающих строк результата, будет оставляться только одна строка. -Результат выполнения будет таким же, как если указано `GROUP BY` по всем указанным полям в `SELECT` и не указаны агрегатные функции. Но имеется несколько отличий от `GROUP BY`: - -- `DISTINCT` может применяться совместно с `GROUP BY`; -- при отсутствии `ORDER BY` и наличии `LIMIT`, запрос прекратит выполнение сразу после того, как будет прочитано необходимое количество различных строк - в этом случае использование DISTINCT существенно более оптимально; -- блоки данных будут выдаваться по мере их обработки, не дожидаясь выполнения всего запроса. - -`DISTINCT` не поддерживается, если в `SELECT` присутствует хотя бы один столбец типа массив. - -`DISTINCT` работает с [NULL](../syntax.md) как если бы `NULL` был конкретным значением, причём `NULL=NULL`. Т.е. в результате `DISTINCT` разные комбинации с `NULL` встретятся только по одному разу. - -ClickHouse поддерживает использование в одном запросе секций `DISTINCT` и `ORDER BY` для разных столбцов. Секция `DISTINCT` исполняется перед секцией `ORDER BY`. - -Таблица для примера: - -``` text -┌─a─┬─b─┐ -│ 2 │ 1 │ -│ 1 │ 2 │ -│ 3 │ 3 │ -│ 2 │ 4 │ -└───┴───┘ -``` - -При выборке данных запросом `SELECT DISTINCT a FROM t1 ORDER BY b ASC`, мы получаем следующий результат: - -``` text -┌─a─┐ -│ 2 │ -│ 1 │ -│ 3 │ -└───┘ -``` - -Если изменить направление сортировки `SELECT DISTINCT a FROM t1 ORDER BY b DESC`, то результат получается следующий: - -``` text -┌─a─┐ -│ 3 │ -│ 1 │ -│ 2 │ -└───┘ -``` - -Строка `2, 4` была удалена перед сортировкой. - -Учитывайте эту особенность реализации при программировании запросов. - -### Секция LIMIT {#sektsiia-limit} - -`LIMIT m` позволяет выбрать из результата первые `m` строк. - -`LIMIT n, m` позволяет выбрать из результата первые `m` строк после пропуска первых `n` строк. Синтаксис `LIMIT m OFFSET n` также поддерживается. - -`n` и `m` должны быть неотрицательными целыми числами. - -При отсутствии секции `ORDER BY`, однозначно сортирующей результат, результат может быть произвольным и может являться недетерминированным. - -### Секция UNION ALL {#sektsiia-union-all} - -Произвольное количество запросов может быть объединено с помощью `UNION ALL`. Пример: - -``` sql -SELECT CounterID, 1 AS table, toInt64(count()) AS c - FROM test.hits - GROUP BY CounterID - -UNION ALL - -SELECT CounterID, 2 AS table, sum(Sign) AS c - FROM test.visits - GROUP BY CounterID - HAVING c > 0 -``` - -Поддерживается только `UNION ALL`. Обычный `UNION` (`UNION DISTINCT`) не поддерживается. Если вам нужен `UNION DISTINCT`, то вы можете написать `SELECT DISTINCT` из подзапроса, содержащего `UNION ALL`. - -Запросы - части `UNION ALL` могут выполняться параллельно, и их результаты могут возвращаться вперемешку. - -Структура результатов (количество и типы столбцов) у запросов должна совпадать. Но имена столбцов могут отличаться. В этом случае, имена столбцов для общего результата будут взяты из первого запроса. При объединении выполняется приведение типов. Например, если в двух объединяемых запросах одно и тоже поле имеет типы не-`Nullable` и `Nullable` от совместимого типа, то в результате `UNION ALL` получим поле типа `Nullable`. - -Запросы - части `UNION ALL` нельзя заключить в скобки. `ORDER BY` и `LIMIT` применяются к отдельным запросам, а не к общему результату. Если вам нужно применить какое-либо преобразование к общему результату, то вы можете разместить все запросы с `UNION ALL` в подзапросе в секции `FROM`. - -### Секция INTO OUTFILE {#into-outfile-clause} - -При указании `INTO OUTFILE filename` (где filename - строковый литерал), результат запроса будет сохранён в файл filename. -В отличие от MySQL, файл создаётся на стороне клиента. Если файл с таким именем уже существует, это приведёт к ошибке. -Функциональность доступна в клиенте командной строки и clickhouse-local (попытка выполнить запрос с INTO OUTFILE через HTTP интерфейс приведёт к ошибке). - -Формат вывода по умолчанию - TabSeparated, как и в не интерактивном режиме клиента командной строки. - -### Секция FORMAT {#format-clause} - -При указании FORMAT format вы можете получить данные в любом указанном формате. -Это может использоваться для удобства или для создания дампов. -Подробнее смотрите раздел «Форматы». -Если секция FORMAT отсутствует, то используется формат по умолчанию, который зависит от используемого интерфейса для доступа к БД и от настроек. Для HTTP интерфейса, а также для клиента командной строки, используемого в batch-режиме, по умолчанию используется формат TabSeparated. Для клиента командной строки, используемого в интерактивном режиме, по умолчанию используется формат PrettyCompact (прикольные таблички, компактные). - -При использовании клиента командной строки данные на клиент передаются во внутреннем эффективном формате. При этом клиент самостоятельно интерпретирует секцию FORMAT запроса и форматирует данные на своей стороне (снимая нагрузку на сеть и сервер). - -### Операторы IN {#select-in-operators} - -Операторы `IN`, `NOT IN`, `GLOBAL IN`, `GLOBAL NOT IN` рассматриваются отдельно, так как их функциональность достаточно богатая. - -В качестве левой части оператора, может присутствовать как один столбец, так и кортеж. - -Примеры: - -``` sql -SELECT UserID IN (123, 456) FROM ... -SELECT (CounterID, UserID) IN ((34, 123), (101500, 456)) FROM ... -``` - -Если слева стоит один столбец, входящий в индекс, а справа - множество констант, то при выполнении запроса, система воспользуется индексом. - -Не перечисляйте слишком большое количество значений (миллионы) явно. Если множество большое - лучше загрузить его во временную таблицу (например, смотрите раздел «Внешние данные для обработки запроса»), и затем воспользоваться подзапросом. - -В качестве правой части оператора может быть множество константных выражений, множество кортежей с константными выражениями (показано в примерах выше), а также имя таблицы или подзапрос SELECT в скобках. - -Если в качестве правой части оператора указано имя таблицы (например, `UserID IN users`), то это эквивалентно подзапросу `UserID IN (SELECT * FROM users)`. Это используется при работе с внешними данными, отправляемым вместе с запросом. Например, вместе с запросом может быть отправлено множество идентификаторов посетителей, загруженное во временную таблицу users, по которому следует выполнить фильтрацию. - -Если в качестве правой части оператора, указано имя таблицы, имеющий движок Set (подготовленное множество, постоянно находящееся в оперативке), то множество не будет создаваться заново при каждом запросе. - -В подзапросе может быть указано более одного столбца для фильтрации кортежей. -Пример: - -``` sql -SELECT (CounterID, UserID) IN (SELECT CounterID, UserID FROM ...) FROM ... -``` - -Типы столбцов слева и справа оператора IN, должны совпадать. - -Оператор IN и подзапрос могут встречаться в любой части запроса, в том числе в агрегатных и лямбда функциях. -Пример: - -``` sql -SELECT - EventDate, - avg(UserID IN - ( - SELECT UserID - FROM test.hits - WHERE EventDate = toDate('2014-03-17') - )) AS ratio -FROM test.hits -GROUP BY EventDate -ORDER BY EventDate ASC -``` - -``` text -┌──EventDate─┬────ratio─┐ -│ 2014-03-17 │ 1 │ -│ 2014-03-18 │ 0.807696 │ -│ 2014-03-19 │ 0.755406 │ -│ 2014-03-20 │ 0.723218 │ -│ 2014-03-21 │ 0.697021 │ -│ 2014-03-22 │ 0.647851 │ -│ 2014-03-23 │ 0.648416 │ -└────────────┴──────────┘ -``` - -за каждый день после 17 марта считаем долю хитов, сделанных посетителями, которые заходили на сайт 17 марта. -Подзапрос в секции IN на одном сервере всегда выполняется только один раз. Зависимых подзапросов не существует. - -#### Обработка NULL {#obrabotka-null-1} - -При обработке запроса оператор IN будет считать, что результат операции с [NULL](../syntax.md) всегда равен `0`, независимо от того, находится `NULL` в правой или левой части оператора. Значения `NULL` не входят ни в какое множество, не соответствуют друг другу и не могут сравниваться. - -Рассмотрим для примера таблицу `t_null`: - -``` text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ -``` - -При выполнении запроса `SELECT x FROM t_null WHERE y IN (NULL,3)` получим следующий результат: - -``` text -┌─x─┐ -│ 2 │ -└───┘ -``` - -Видно, что строка, в которой `y = NULL`, выброшена из результатов запроса. Это произошло потому, что ClickHouse не может решить входит ли `NULL` в множество `(NULL,3)`, возвращает результат операции `0`, а `SELECT` выбрасывает эту строку из финальной выдачи. - -``` sql -SELECT y IN (NULL, 3) -FROM t_null -``` - -``` text -┌─in(y, tuple(NULL, 3))─┐ -│ 0 │ -│ 1 │ -└───────────────────────┘ -``` - -#### Распределённые подзапросы {#select-distributed-subqueries} - -Существует два варианта IN-ов с подзапросами (аналогично для JOIN-ов): обычный `IN` / `JOIN` и `GLOBAL IN` / `GLOBAL JOIN`. Они отличаются способом выполнения при распределённой обработке запроса. - -!!! attention "Attention" - Помните, что алгоритмы, описанные ниже, могут работать иначе в зависимости от [настройки](../../operations/settings/settings.md) `distributed_product_mode`. - -При использовании обычного IN-а, запрос отправляется на удалённые серверы, и на каждом из них выполняются подзапросы в секциях `IN` / `JOIN`. - -При использовании `GLOBAL IN` / `GLOBAL JOIN-а`, сначала выполняются все подзапросы для `GLOBAL IN` / `GLOBAL JOIN-ов`, и результаты складываются во временные таблицы. Затем эти временные таблицы передаются на каждый удалённый сервер, и на них выполняются запросы, с использованием этих переданных временных данных. - -Если запрос не распределённый, используйте обычный `IN` / `JOIN`. - -Следует быть внимательным при использовании подзапросов в секции `IN` / `JOIN` в случае распределённой обработки запроса. - -Рассмотрим это на примерах. Пусть на каждом сервере кластера есть обычная таблица **local\_table**. Пусть также есть таблица **distributed\_table** типа **Distributed**, которая смотрит на все серверы кластера. - -При запросе к распределённой таблице **distributed\_table**, запрос будет отправлен на все удалённые серверы, и на них будет выполнен с использованием таблицы **local\_table**. - -Например, запрос - -``` sql -SELECT uniq(UserID) FROM distributed_table -``` - -будет отправлен на все удалённые серверы в виде - -``` sql -SELECT uniq(UserID) FROM local_table -``` - -, выполнен параллельно на каждом из них до стадии, позволяющей объединить промежуточные результаты; затем промежуточные результаты вернутся на сервер-инициатор запроса, будут на нём объединены, и финальный результат будет отправлен клиенту. - -Теперь рассмотрим запрос с IN-ом: - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) -``` - -- расчёт пересечения аудиторий двух сайтов. - -Этот запрос будет отправлен на все удалённые серверы в виде - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) -``` - -То есть, множество в секции IN будет собрано на каждом сервере независимо, только по тем данным, которые есть локально на каждом из серверов. - -Это будет работать правильно и оптимально, если вы предусмотрели такой случай, и раскладываете данные по серверам кластера таким образом, чтобы данные одного UserID-а лежали только на одном сервере. В таком случае все необходимые данные будут присутствовать на каждом сервере локально. В противном случае результат будет посчитан неточно. Назовём этот вариант запроса «локальный IN». - -Чтобы исправить работу запроса, когда данные размазаны по серверам кластера произвольным образом, можно было бы указать **distributed\_table** внутри подзапроса. Запрос будет выглядеть так: - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -Этот запрос будет отправлен на все удалённые серверы в виде - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -На каждом удалённом сервере начнёт выполняться подзапрос. Так как в подзапросе используется распределённая таблица, то подзапрос будет, на каждом удалённом сервере, снова отправлен на каждый удалённый сервер, в виде - -``` sql -SELECT UserID FROM local_table WHERE CounterID = 34 -``` - -Например, если у вас кластер из 100 серверов, то выполнение всего запроса потребует 10 000 элементарных запросов, что, как правило, является неприемлемым. - -В таких случаях всегда следует использовать GLOBAL IN вместо IN. Рассмотрим его работу для запроса - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID GLOBAL IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -На сервере-инициаторе запроса будет выполнен подзапрос - -``` sql -SELECT UserID FROM distributed_table WHERE CounterID = 34 -``` - -, и результат будет сложен во временную таблицу в оперативке. Затем запрос будет отправлен на каждый удалённый сервер в виде - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID GLOBAL IN _data1 -``` - -, и вместе с запросом, на каждый удалённый сервер будет отправлена временная таблица `_data1` (имя временной таблицы - implementation defined). - -Это гораздо более оптимально, чем при использовании обычного IN. Но при этом, следует помнить о нескольких вещах: - -1. При создании временной таблицы данные не уникализируются. Чтобы уменьшить объём передаваемых по сети данных, укажите в подзапросе DISTINCT (для обычного IN-а этого делать не нужно). -2. Временная таблица будет передана на все удалённые серверы. Передача не учитывает топологию сети. Например, если 10 удалённых серверов расположены в удалённом относительно сервера-инициатора запроса дата-центре, то по каналу в удалённый дата-центр данные будет переданы 10 раз. Старайтесь не использовать большие множества при использовании GLOBAL IN. -3. При передаче данных на удалённые серверы не настраивается ограничение использования сетевой полосы. Вы можете перегрузить сеть. -4. Старайтесь распределять данные по серверам так, чтобы в GLOBAL IN-ах не было частой необходимости. -5. Если в GLOBAL IN есть частая необходимость, то спланируйте размещение кластера ClickHouse таким образом, чтобы в каждом дата-центре была хотя бы одна реплика каждого шарда, и среди них была быстрая сеть - чтобы запрос целиком можно было бы выполнить, передавая данные в пределах одного дата-центра. - -В секции `GLOBAL IN` также имеет смысл указывать локальную таблицу - в случае, если эта локальная таблица есть только на сервере-инициаторе запроса, и вы хотите воспользоваться данными из неё на удалённых серверах. - -### Экстремальные значения {#ekstremalnye-znacheniia} - -Вы можете получить в дополнение к результату также минимальные и максимальные значения по столбцам результата. Для этого выставите настройку **extremes** в 1. Минимумы и максимумы считаются для числовых типов, дат, дат-с-временем. Для остальных столбцов будут выведены значения по умолчанию. - -Вычисляются дополнительные две строчки - минимумы и максимумы, соответственно. Эти две дополнительные строки выводятся в [форматах](../../interfaces/formats.md) `JSON*`, `TabSeparated*`, и `Pretty*` отдельно от остальных строчек. В остальных форматах они не выводится. - -Во форматах `JSON*`, экстремальные значения выводятся отдельным полем ‘extremes’. В форматах `TabSeparated*`, строка выводится после основного результата и после ‘totals’ если есть. Перед ней (после остальных данных) вставляется пустая строка. В форматах `Pretty*`, строка выводится отдельной таблицей после основного результата и после `totals` если есть. - -Экстремальные значения вычисляются для строк перед `LIMIT`, но после `LIMIT BY`. Однако при использовании `LIMIT offset, size`, строки перед `offset` включаются в `extremes`. В потоковых запросах, в результате может учитываться также небольшое количество строчек, прошедших `LIMIT`. - -### Замечания {#zamechaniia} - -В секциях `GROUP BY`, `ORDER BY`, в отличие от диалекта MySQL, и в соответствии со стандартным SQL, не поддерживаются позиционные аргументы. -Например, если вы напишите `GROUP BY 1, 2` - то это будет воспринято, как группировка по константам (то есть, агрегация всех строк в одну). - -Вы можете использовать синонимы (алиасы `AS`) в любом месте запроса. - -В любом месте запроса, вместо выражения, может стоять звёздочка. При анализе запроса звёздочка раскрывается в список всех столбцов таблицы (за исключением `MATERIALIZED` и `ALIAS` столбцов). Есть лишь немного случаев, когда оправдано использовать звёздочку: - -- при создании дампа таблицы; -- для таблиц, содержащих всего несколько столбцов - например, системных таблиц; -- для получения информации о том, какие столбцы есть в таблице; в этом случае, укажите `LIMIT 1`. Но лучше используйте запрос `DESC TABLE`; -- при наличии сильной фильтрации по небольшому количеству столбцов с помощью `PREWHERE`; -- в подзапросах (так как из подзапросов выкидываются столбцы, не нужные для внешнего запроса). - -В других случаях использование звёздочки является издевательством над системой, так как вместо преимуществ столбцовой СУБД вы получаете недостатки. То есть использовать звёздочку не рекомендуется. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/select/) diff --git a/docs/ru/sql_reference/statements/show.md b/docs/ru/sql_reference/statements/show.md deleted file mode 100644 index 545301d6166..00000000000 --- a/docs/ru/sql_reference/statements/show.md +++ /dev/null @@ -1,98 +0,0 @@ -# SHOW Queries {#show-queries} - -## SHOW CREATE TABLE {#show-create-table} - -``` sql -SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -Возвращает один столбец типа `String` с именем statement, содержащий одно значение — запрос `CREATE TABLE`, с помощью которого был создан указанный объект. - -## SHOW DATABASES {#show-databases} - -``` sql -SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] -``` - -Выводит список всех баз данных. -Запрос полностью аналогичен запросу `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. - -## SHOW PROCESSLIST {#show-processlist} - -``` sql -SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] -``` - -Выводит содержимое таблицы [system.processes](../../operations/system_tables.md#system_tables-processes), которая содержит список запросов, выполняющихся в данный момент времени, кроме самих запросов `SHOW PROCESSLIST`. - -Запрос `SELECT * FROM system.processes` возвращает данные обо всех текущих запросах. - -Полезный совет (выполните в консоли): - -``` bash -$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" -``` - -## SHOW TABLES {#show-tables} - -Выводит список таблиц. - -``` sql -SHOW [TEMPORARY] TABLES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -Если секция `FROM` не используется, то запрос возвращает список таблиц из текущей базы данных. - -Результат, идентичный тому, что выдаёт запрос `SHOW TABLES` можно получить также запросом следующего вида: - -``` sql -SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**Пример** - -Следующий запрос выбирает первые две строки из списка таблиц в базе данных `system`, чьи имена содержат `co`. - -``` sql -SHOW TABLES FROM system LIKE '%co%' LIMIT 2 -``` - -``` text -┌─name───────────────────────────┐ -│ aggregate_function_combinators │ -│ collations │ -└────────────────────────────────┘ -``` - -## SHOW DICTIONARIES {#show-dictionaries} - -Выводит список [внешних словарей](../../sql_reference/statements/show.md). - -``` sql -SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -Если секция `FROM` не указана, запрос возвращает список словарей из текущей базы данных. - -Аналогичный результат можно получить следующим запросом: - -``` sql -SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**Example** - -Запрос выводит первые две стоки из списка таблиц в базе данных `system`, имена которых содержат `reg`. - -``` sql -SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 -``` - -``` text -┌─name─────────┐ -│ regions │ -│ region_names │ -└──────────────┘ -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/show/) diff --git a/docs/ru/sql_reference/statements/system.md b/docs/ru/sql_reference/statements/system.md deleted file mode 100644 index 2a4acd15e7f..00000000000 --- a/docs/ru/sql_reference/statements/system.md +++ /dev/null @@ -1,106 +0,0 @@ -# Запросы SYSTEM {#query-language-system} - -- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) -- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) -- [DROP DNS CACHE](#query_language-system-drop-dns-cache) -- [DROP MARK CACHE](#query_language-system-drop-mark-cache) -- [FLUSH LOGS](#query_language-system-flush_logs) -- [RELOAD CONFIG](#query_language-system-reload-config) -- [SHUTDOWN](#query_language-system-shutdown) -- [KILL](#query_language-system-kill) -- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) -- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) -- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) -- [STOP MERGES](#query_language-system-stop-merges) -- [START MERGES](#query_language-system-start-merges) - -## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} - -Перегружает все словари, которые были успешно загружены до этого. -По умолчанию включена ленивая загрузка [dictionaries\_lazy\_load](../../sql_reference/statements/system.md#dictionaries-lazy-load), поэтому словари не загружаются автоматически при старте, а только при первом обращении через dictGet или SELECT к ENGINE=Dictionary. После этого такие словари (LOADED) будут перегружаться командой `system reload dictionaries`. -Всегда возвращает `Ok.`, вне зависимости от результата обновления словарей. - -## RELOAD DICTIONARY dictionary\_name {#query_language-system-reload-dictionary} - -Полностью перегружает словарь `dictionary_name`, вне зависимости от состояния словаря (LOADED/NOT\_LOADED/FAILED). -Всегда возвращает `Ok.`, вне зависимости от результата обновления словаря. -Состояние словаря можно проверить запросом к `system.dictionaries`. - -``` sql -SELECT name, status FROM system.dictionaries; -``` - -## DROP DNS CACHE {#query_language-system-drop-dns-cache} - -Сбрасывает внутренний DNS кеш ClickHouse. Иногда (для старых версий ClickHouse) необходимо использовать эту команду при изменении инфраструктуры (смене IP адреса у другого ClickHouse сервера или сервера, используемого словарями). - -Для более удобного (автоматического) управления кешем см. параметры disable\_internal\_dns\_cache, dns\_cache\_update\_period. - -## DROP MARK CACHE {#query_language-system-drop-mark-cache} - -Сбрасывает кеш «засечек» (`mark cache`). Используется при разработке ClickHouse и тестах производительности. - -## FLUSH LOGS {#query_language-system-flush_logs} - -Записывает буферы логов в системные таблицы (например system.query\_log). Позволяет не ждать 7.5 секунд при отладке. - -## RELOAD CONFIG {#query_language-system-reload-config} - -Перечитывает конфигурацию настроек ClickHouse. Используется при хранении конфигурации в zookeeeper. - -## SHUTDOWN {#query_language-system-shutdown} - -Штатно завершает работу ClickHouse (аналог `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) - -## KILL {#query_language-system-kill} - -Аварийно завершает работу ClickHouse (аналог `kill -9 {$pid_clickhouse-server}`) - -## Управление распределёнными таблицами {#query-language-system-distributed} - -ClickHouse может оперировать [распределёнными](../../sql_reference/statements/system.md) таблицами. Когда пользователь вставляет данные в эти таблицы, ClickHouse сначала формирует очередь из данных, которые должны быть отправлены на узлы кластера, а затем асинхронно отправляет подготовленные данные. Вы можете управлять очередью с помощью запросов [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) и [FLUSH DISTRIBUTED](#query_language-system-flush-distributed). Также есть возможность синхронно вставлять распределенные данные с помощью настройки `insert_distributed_sync`. - -### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} - -Отключает фоновую отправку при вставке данных в распределённые таблицы. - -``` sql -SYSTEM STOP DISTRIBUTED SENDS [db.] -``` - -### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} - -В синхронном режиме отправляет все данные на узлы кластера. Если какие-либо узлы недоступны, ClickHouse генерирует исключение и останавливает выполнение запроса. Такой запрос можно повторять до успешного завершения, что будет означать возвращение связанности с остальными узлами кластера. - -``` sql -SYSTEM FLUSH DISTRIBUTED [db.] -``` - -### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} - -Включает фоновую отправку при вставке данных в распределенные таблицы. - -``` sql -SYSTEM START DISTRIBUTED SENDS [db.] -``` - -### STOP MERGES {#query_language-system-stop-merges} - -Позволяет остановить фоновые мержи для таблиц семейства MergeTree: - -``` sql -SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] -``` - -!!! note "Note" - `DETACH / ATTACH` таблицы восстанавливает фоновые мержи для этой таблицы (даже в случае отключения фоновых мержей для всех таблиц семейства MergeTree до `DETACH`). - -### START MERGES {#query_language-system-start-merges} - -Включает фоновые мержи для таблиц семейства MergeTree: - -``` sql -SYSTEM START MERGES [[db.]merge_tree_family_table_name] -``` - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/system/) diff --git a/docs/ru/sql_reference/syntax.md b/docs/ru/sql_reference/syntax.md deleted file mode 100644 index b9576e48a59..00000000000 --- a/docs/ru/sql_reference/syntax.md +++ /dev/null @@ -1,179 +0,0 @@ -# Синтаксис {#sintaksis} - -В системе есть два вида парсеров: полноценный парсер SQL (recursive descent parser) и парсер форматов данных (быстрый потоковый парсер). -Во всех случаях кроме запроса INSERT, используется только полноценный парсер SQL. -В запросе INSERT используется оба парсера: - -``` sql -INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') -``` - -Фрагмент `INSERT INTO t VALUES` парсится полноценным парсером, а данные `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` - быстрым потоковым парсером. -Данные могут иметь любой формат. При получении запроса, сервер заранее считывает в оперативку не более `max_query_size` байт запроса (по умолчанию, 1МБ), а всё остальное обрабатывается потоково. -Таким образом, в системе нет проблем с большими INSERT запросами, как в MySQL. - -При использовании формата Values в INSERT запросе может сложиться иллюзия, что данные парсятся также, как выражения в запросе SELECT, но это не так. Формат Values гораздо более ограничен. - -Далее пойдёт речь о полноценном парсере. О парсерах форматов, смотри раздел «Форматы». - -## Пробелы {#probely} - -Между синтаксическими конструкциями (в том числе, в начале и конце запроса) может быть расположено произвольное количество пробельных символов. К пробельным символам относятся пробел, таб, перевод строки, CR, form feed. - -## Комментарии {#kommentarii} - -Поддерживаются комментарии в SQL-стиле и C-стиле. -Комментарии в SQL-стиле: от `--` до конца строки. Пробел после `--` может не ставиться. -Комментарии в C-стиле: от `/*` до `*/`. Такие комментарии могут быть многострочными. Пробелы тоже не обязательны. - -## Ключевые слова {#syntax-keywords} - -Ключевые слова не зависят от регистра, если они соответствуют: - -- Стандарту SQL. Например, применение любого из вариантов `SELECT`, `select` или `SeLeCt` не вызовет ошибки. -- Реализации в некоторых популярных DBMS (MySQL или Postgres). Например, `DateTime` и `datetime`. - -Зависимость от регистра для имён типов данных можно проверить в таблице `system.data_type_families`. - -В отличие от стандарта SQL, все остальные ключевые слова, включая названия функций зависят от регистра. - -Ключевые слова не зарезервированы (а всего лишь парсятся как ключевые слова в соответствующем контексте). Если вы используете [идентификаторы](#syntax-identifiers), совпадающие с ключевыми словами, заключите их в кавычки. Например, запрос `SELECT "FROM" FROM table_name` валиден, если таблица `table_name` имеет столбец с именем `"FROM"`. - -## Идентификаторы {#syntax-identifiers} - -Идентификаторы: - -- Имена кластеров, баз данных, таблиц, разделов и столбцов; -- Функции; -- Типы данных; -- [Синонимы выражений](#syntax-expression_aliases). - -Некоторые идентификаторы нужно указывать в кавычках (например, идентификаторы с пробелами). Прочие идентификаторы можно указывать без кавычек. Рекомендуется использовать идентификаторы, не требующие кавычек. - -Идентификаторы не требующие кавычек соответствуют регулярному выражению `^[a-zA-Z_][0-9a-zA-Z_]*$` и не могут совпадать с [ключевыми словами](#syntax-keywords). Примеры: `x, _1, X_y__Z123_.` - -Если вы хотите использовать идентификаторы, совпадающие с ключевыми словами, или использовать в идентификаторах символы, не входящие в регулярное выражение, заключите их в двойные или обратные кавычки, например, `"id"`, `` `id` ``. - -## Литералы {#literaly} - -Существуют: числовые, строковые, составные литералы и `NULL`. - -### Числовые {#chislovye} - -Числовой литерал пытается распарситься: - -- Сначала как знаковое 64-разрядное число, функцией [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul). -- Если не получилось, то как беззнаковое 64-разрядное число, функцией [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol). -- Если не получилось, то как число с плавающей запятой, функцией [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof). -- Иначе — ошибка. - -Соответствующее значение будет иметь тип минимального размера, который вмещает значение. -Например, 1 парсится как `UInt8`, а 256 как `UInt16`. Подробнее о типах данных читайте в разделе [Типы данных](../sql_reference/syntax.md). - -Примеры: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. - -### Строковые {#syntax-string-literal} - -Поддерживаются только строковые литералы в одинарных кавычках. Символы внутри могут быть экранированы с помощью обратного слеша. Следующие escape-последовательности имеют соответствующее специальное значение: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. Во всех остальных случаях, последовательности вида `\c`, где `c` — любой символ, преобразуется в `c` . Таким образом, могут быть использованы последовательности `\'` и `\\`. Значение будет иметь тип [String](../sql_reference/syntax.md). - -Минимальный набор символов, которых вам необходимо экранировать в строковых литералах: `'` и `\`. Одинарная кавычка может быть экранирована одинарной кавычкой, литералы `'It\'s'` и `'It''s'` эквивалентны. - -### Составные {#sostavnye} - -Поддерживаются конструкции для массивов: `[1, 2, 3]` и кортежей: `(1, 'Hello, world!', 2)`. -На самом деле, это вовсе не литералы, а выражение с оператором создания массива и оператором создания кортежа, соответственно. -Массив должен состоять хотя бы из одного элемента, а кортеж - хотя бы из двух. -Кортежи носят служебное значение для использования в секции `IN` запроса `SELECT`. Кортежи могут быть получены как результат запроса, но они не могут быть сохранены в базе данных (за исключением таблицы [Memory](../sql_reference/syntax.md).) - -### NULL {#null-literal} - -Обозначает, что значение отсутствует. - -Чтобы в поле таблицы можно было хранить `NULL`, оно должно быть типа [Nullable](../sql_reference/syntax.md). - -В зависимости от формата данных (входных или выходных) `NULL` может иметь различное представление. Подробнее смотрите в документации для [форматов данных](../interfaces/formats.md#formats). - -При обработке `NULL` есть множество особенностей. Например, если хотя бы один из аргументов операции сравнения — `NULL`, то результатом такой операции тоже будет `NULL`. Этим же свойством обладают операции умножения, сложения и пр. Подробнее читайте в документации на каждую операцию. - -В запросах можно проверить `NULL` с помощью операторов [IS NULL](operators.md#operator-is-null) и [IS NOT NULL](operators.md), а также соответствующих функций `isNull` и `isNotNull`. - -## Функции {#funktsii} - -Функции записываются как идентификатор со списком аргументов (возможно, пустым) в скобках. В отличие от стандартного SQL, даже в случае пустого списка аргументов, скобки обязательны. Пример: `now()`. -Бывают обычные и агрегатные функции (смотрите раздел «Агрегатные функции»). Некоторые агрегатные функции могут содержать два списка аргументов в круглых скобках. Пример: `quantile(0.9)(x)`. Такие агрегатные функции называются «параметрическими», а первый список аргументов называется «параметрами». Синтаксис агрегатных функций без параметров ничем не отличается от обычных функций. - -## Операторы {#operatory} - -Операторы преобразуются в соответствующие им функции во время парсинга запроса, с учётом их приоритета и ассоциативности. -Например, выражение `1 + 2 * 3 + 4` преобразуется в `plus(plus(1, multiply(2, 3)), 4)`. - -## Типы данных и движки таблиц {#tipy-dannykh-i-dvizhki-tablits} - -Типы данных и движки таблиц в запросе `CREATE` записываются также, как идентификаторы или также как функции. То есть, могут содержать или не содержать список аргументов в круглых скобках. Подробнее смотрите разделы «Типы данных», «Движки таблиц», «CREATE». - -## Синонимы выражений {#syntax-expression_aliases} - -Синоним — это пользовательское имя выражения в запросе. - -``` sql -expr AS alias -``` - -- `AS` — ключевое слово для определения синонимов. Можно определить синоним для имени таблицы или столбца в секции `SELECT` без использования ключевого слова `AS` . - - Например, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. - - В функции [CAST](sql_reference/syntax.md#type_conversion_function-cast), ключевое слово `AS` имеет другое значение. Смотрите описание функции. - -- `expr` — любое выражение, которое поддерживает ClickHouse. - - Например, `SELECT column_name * 2 AS double FROM some_table`. - -- `alias` — имя для `выражения`. Синонимы должны соответствовать синтаксису [идентификаторов](#syntax-identifiers). - - Например, `SELECT "table t".column_name FROM table_name AS "table t"`. - -### Примечания по использованию {#primechaniia-po-ispolzovaniiu} - -Синонимы являются глобальными для запроса или подзапроса, и вы можете определить синоним в любой части запроса для любого выражения. Например, `SELECT (1 AS n) + 2, n`. - -Синонимы не передаются в подзапросы и между подзапросами. Например, при выполнении запроса `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouse сгенерирует исключение `Unknown identifier: num`. - -Если синоним определен для результирующих столбцов в секции `SELECT` вложенного запроса, то эти столбцы отображаются во внешнем запросе. Например, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. - -Будьте осторожны с синонимами, совпадающими с именами столбцов или таблиц. Рассмотрим следующий пример: - -``` sql -CREATE TABLE t -( - a Int, - b Int -) -ENGINE = TinyLog() -``` - -``` sql -SELECT - argMax(a, b), - sum(b) AS b -FROM t -``` - -``` text -Received exception from server (version 18.14.17): -Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. -``` - -В этом примере мы объявили таблицу `t` со столбцом `b`. Затем, при выборе данных, мы определили синоним `sum(b) AS b`. Поскольку синонимы глобальные, то ClickHouse заменил литерал `b` в выражении `argMax(a, b)` выражением `sum(b)`. Эта замена вызвала исключение. - -## Звёздочка {#zviozdochka} - -В запросе `SELECT`, вместо выражения может стоять звёздочка. Подробнее смотрите раздел «SELECT». - -## Выражения {#syntax-expressions} - -Выражение представляет собой функцию, идентификатор, литерал, применение оператора, выражение в скобках, подзапрос, звёздочку. А также может содержать синоним. -Список выражений - одно выражение или несколько выражений через запятую. -Функции и операторы, в свою очередь, в качестве аргументов, могут иметь произвольные выражения. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/syntax/) diff --git a/docs/ru/sql_reference/table_functions/file.md b/docs/ru/sql_reference/table_functions/file.md deleted file mode 100644 index e0da3ddc15f..00000000000 --- a/docs/ru/sql_reference/table_functions/file.md +++ /dev/null @@ -1,107 +0,0 @@ -# file {#file} - -Создаёт таблицу из файла. Данная табличная функция похожа на табличные функции [file](file.md) и [hdfs](hdfs.md). - -``` sql -file(path, format, structure) -``` - -**Входные параметры** - -- `path` — относительный путь до файла от [user\_files\_path](../../sql_reference/table_functions/file.md#server_configuration_parameters-user_files_path). Путь к файлу поддерживает следующие шаблоны в режиме доступа только для чтения `*`, `?`, `{abc,def}` и `{N..M}`, где `N`, `M` — числа, \``'abc', 'def'` — строки. -- `format` — [формат](../../interfaces/formats.md#formats) файла. -- `structure` — структура таблицы. Формат `'colunmn1_name column1_ype, column2_name column2_type, ...'`. - -**Возвращаемое значение** - -Таблица с указанной структурой, предназначенная для чтения или записи данных в указанном файле. - -**Пример** - -Настройка `user_files_path` и содержимое файла `test.csv`: - -``` bash -$ grep user_files_path /etc/clickhouse-server/config.xml - /var/lib/clickhouse/user_files/ - -$ cat /var/lib/clickhouse/user_files/test.csv - 1,2,3 - 3,2,1 - 78,43,45 -``` - -Таблица из `test.csv` и выборка первых двух строк из неё: - -``` sql -SELECT * -FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -Шаблоны могут содержаться в нескольких компонентах пути. Обрабатываются только существующие файлы, название которых целиком удовлетворяет шаблону (не только суффиксом или префиксом). - -- `*` — Заменяет любое количество любых символов кроме `/`, включая отсутствие символов. -- `?` — Заменяет ровно один любой символ. -- `{some_string,another_string,yet_another_one}` — Заменяет любую из строк `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Заменяет любое число в интервале от `N` до `M` включительно (может содержать ведущие нули). - -Конструкция с `{}` аналогична табличной функции [remote](remote.md). - -**Пример** - -1. Предположим у нас есть несколько файлов со следующими относительными путями: - -- ‘some\_dir/some\_file\_1’ -- ‘some\_dir/some\_file\_2’ -- ‘some\_dir/some\_file\_3’ -- ‘another\_dir/some\_file\_1’ -- ‘another\_dir/some\_file\_2’ -- ‘another\_dir/some\_file\_3’ - -1. Запросим количество строк в этих файлах: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. Запросим количество строк во всех файлах этих двух директорий: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "Warning" - Если ваш список файлов содержит интервал с ведущими нулями, используйте конструкцию с фигурными скобками для каждой цифры по отдельности или используйте `?`. - -**Пример** - -Запрос данных из файлов с именами `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## Виртуальные столбцы {#virtualnye-stolbtsy} - -- `_path` — Путь к файлу. -- `_file` — Имя файла. - -**Смотрите также** - -- [Виртуальные столбцы](index.md#table_engines-virtual_columns) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/file/) diff --git a/docs/ru/sql_reference/table_functions/index.md b/docs/ru/sql_reference/table_functions/index.md deleted file mode 100644 index 70c701d1713..00000000000 --- a/docs/ru/sql_reference/table_functions/index.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -toc_folder_title: Табличные функции -toc_priority: 34 -toc_title: Введение ---- - -# Табличные функции {#tablichnye-funktsii} - -Табличные функции — это метод создания таблиц. - -Табличные функции можно использовать в: - -- Секции [FROM](../statements/select.md#select-from) запроса `SELECT`. - - Это способ создания временной таблицы, которая доступна только в текущем запросе. - -- Запросе [CREATE TABLE AS \](../statements/create.md#create-table-query). - - Это один из методов создания таблицы. - -!!! warning "Предупреждение" - Если настройка [allow\_ddl](../../operations/settings/permissions_for_queries.md#settings_allow_ddl) выключена, то использовать табличные функции невозможно. - -| Функция | Описание | -|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------| -| [file](file.md) | Создаёт таблицу с движком [File](../../sql_reference/table_functions/index.md). | -| [merge](merge.md) | Создаёт таблицу с движком [Merge](../../sql_reference/table_functions/index.md). | -| [numbers](numbers.md) | Создаёт таблицу с единственным столбцом, заполненным целыми числами. | -| [remote](remote.md) | Предоставляет доступ к удалённым серверам, не создавая таблицу с движком [Distributed](../../sql_reference/table_functions/index.md). | -| [url](url.md) | Создаёт таблицу с движком [Url](../../sql_reference/table_functions/index.md). | -| [mysql](mysql.md) | Создаёт таблицу с движком [MySQL](../../sql_reference/table_functions/index.md). | -| [jdbc](jdbc.md) | Создаёт таблицу с дижком [JDBC](../../sql_reference/table_functions/index.md). | -| [odbc](odbc.md) | Создаёт таблицу с движком [ODBC](../../sql_reference/table_functions/index.md). | -| [hdfs](hdfs.md) | Создаёт таблицу с движком [HDFS](../../sql_reference/table_functions/index.md). | - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/) diff --git a/docs/ru/sql_reference/table_functions/mysql.md b/docs/ru/sql_reference/table_functions/mysql.md deleted file mode 100644 index a26f89ced2f..00000000000 --- a/docs/ru/sql_reference/table_functions/mysql.md +++ /dev/null @@ -1,79 +0,0 @@ -# mysql {#mysql} - -Позволяет выполнять запросы `SELECT` над данными, хранящимися на удалённом MySQL сервере. - -``` sql -mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -**Параметры** - -- `host:port` — адрес сервера MySQL. - -- `database` — имя базы данных на удалённом сервере. - -- `table` — имя таблицы на удалённом сервере. - -- `user` — пользователь MySQL. - -- `password` — пароль пользователя. - -- `replace_query` — флаг, отвечающий за преобразование запросов `INSERT INTO` в `REPLACE INTO`. Если `replace_query=1`, то запрос заменяется. - -- `on_duplicate_clause` — выражение `ON DUPLICATE KEY on_duplicate_clause`, добавляемое в запрос `INSERT`. - - Пример: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, где `on_duplicate_clause` это `UPDATE c2 = c2 + 1`. Чтобы узнать какие `on_duplicate_clause` можно использовать с секцией `ON DUPLICATE KEY` обратитесь к документации MySQL. - - Чтобы указать `'on_duplicate_clause'` необходимо передать `0` в параметр `replace_query`. Если одновременно передать `replace_query = 1` и `'on_duplicate_clause'`, то ClickHouse сгенерирует исключение. - -Простые условия `WHERE` такие как `=, !=, >, >=, <, =` выполняются на стороне сервера MySQL. - -Остальные условия и ограничение выборки `LIMIT` будут выполнены в ClickHouse только после выполнения запроса к MySQL. - -**Возвращаемое значение** - -Объект таблицы с теми же столбцами, что и в исходной таблице MySQL. - -## Пример использования {#primer-ispolzovaniia} - -Таблица в MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+--------+--------------+-------+----------------+ -| int_id | int_nullable | float | float_nullable | -+--------+--------------+-------+----------------+ -| 1 | NULL | 2 | NULL | -+--------+--------------+-------+----------------+ -1 row in set (0,00 sec) -``` - -Получение данных в ClickHouse: - -``` sql -SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## Смотрите также {#smotrite-takzhe} - -- [Движок таблиц ‘MySQL’](../../sql_reference/table_functions/mysql.md) -- [Использование MySQL как источника данных для внешнего словаря](../../sql_reference/table_functions/mysql.md#dicts-external_dicts_dict_sources-mysql) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/mysql/) diff --git a/docs/ru/sql_reference/table_functions/odbc.md b/docs/ru/sql_reference/table_functions/odbc.md deleted file mode 100644 index 0d277b2b26d..00000000000 --- a/docs/ru/sql_reference/table_functions/odbc.md +++ /dev/null @@ -1,101 +0,0 @@ -# odbc {#table-functions-odbc} - -Возвращает таблицу, подключенную через [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -``` sql -odbc(connection_settings, external_database, external_table) -``` - -Параметры: - -- `connection_settings` — название секции с настройками соединения в файле `odbc.ini`. -- `external_database` — имя базы данных во внешней СУБД. -- `external_table` — имя таблицы в `external_database`. - -Чтобы использование ODBC было безопасным, ClickHouse использует отдельную программу `clickhouse-odbc-bridge`. Если драйвер ODBC подгружать непосредственно из `clickhouse-server`, то проблемы с драйвером могут привести к аварийной остановке сервера ClickHouse. ClickHouse автоматически запускает `clickhouse-odbc-bridge` по мере необходимости. Программа устанавливается из того же пакета, что и `clickhouse-server`. - -Поля из внешней таблицы со значениями `NULL` получают значение по умолчанию для базового типа данных. Например, если поле в удалённой таблице MySQL имеет тип `INT NULL` оно сконвертируется в 0 (значение по умолчанию для типа данных ClickHouse `Int32`). - -## Пример использования {#primer-ispolzovaniia} - -**Получение данных из локальной установки MySQL через ODBC** - -Этот пример проверялся в Ubuntu Linux 18.04 для MySQL server 5.7. - -Убедитесь, что unixODBC и MySQL Connector установлены. - -По умолчанию (если установлен из пакетов) ClickHouse запускается от имени пользователя `clickhouse`. Таким образом, вам нужно создать и настроить этого пользователя на сервере MySQL. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -Теперь настроим соединение в `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -Вы можете проверить соединение с помощью утилиты `isql` из установки unixODBC. - -``` bash -$ isql -v mysqlconn -+---------------------------------------+ -| Connected! | -| | -... -``` - -Таблица в MySQL: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+--------+--------------+-------+----------------+ -| int_id | int_nullable | float | float_nullable | -+--------+--------------+-------+----------------+ -| 1 | NULL | 2 | NULL | -+--------+--------------+-------+----------------+ -1 row in set (0,00 sec) -``` - -Получение данных из таблицы MySQL в ClickHouse: - -``` sql -SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ 0 │ 2 │ 0 │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## Смотрите также {#smotrite-takzhe} - -- [Внешние словари ODBC](../../sql_reference/table_functions/odbc.md#dicts-external_dicts_dict_sources-odbc) -- [Движок таблиц ODBC](../../sql_reference/table_functions/odbc.md). - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/jdbc/) diff --git a/docs/ru/sql_reference/table_functions/remote.md b/docs/ru/sql_reference/table_functions/remote.md deleted file mode 100644 index 9c504f36690..00000000000 --- a/docs/ru/sql_reference/table_functions/remote.md +++ /dev/null @@ -1,76 +0,0 @@ -# remote, remoteSecure {#remote-remotesecure} - -Позволяет обратиться к удалённым серверам без создания таблицы типа `Distributed`. - -Сигнатуры: - -``` sql -remote('addresses_expr', db, table[, 'user'[, 'password']]) -remote('addresses_expr', db.table[, 'user'[, 'password']]) -``` - -`addresses_expr` - выражение, генерирующее адреса удалённых серверов. Это может быть просто один адрес сервера. Адрес сервера - это `хост:порт`, или только `хост`. Хост может быть указан в виде имени сервера, или в виде IPv4 или IPv6 адреса. IPv6 адрес указывается в квадратных скобках. Порт - TCP-порт удалённого сервера. Если порт не указан, используется `tcp_port` из конфигурационного файла сервера (по умолчанию - 9000). - -!!! important "Важно" - С IPv6-адресом обязательно нужно указывать порт. - -Примеры: - -``` text -example01-01-1 -example01-01-1:9000 -localhost -127.0.0.1 -[::]:9000 -[2a02:6b8:0:1111::11]:9000 -``` - -Адреса можно указать через запятую, в этом случае ClickHouse обработает запрос как распределённый, т.е. отправит его по всем указанным адресам как на шарды с разными данными. - -Пример: - -``` text -example01-01-1,example01-02-1 -``` - -Часть выражения может быть указана в фигурных скобках. Предыдущий пример может быть записан следующим образом: - -``` text -example01-0{1,2}-1 -``` - -В фигурных скобках может быть указан диапазон (неотрицательных целых) чисел через две точки. В этом случае, диапазон раскрывается в множество значений, генерирующих адреса шардов. Если запись первого числа начинается с нуля, то значения формируются с таким же выравниванием нулями. Предыдущий пример может быть записан следующим образом: - -``` text -example01-{01..02}-1 -``` - -При наличии нескольких пар фигурных скобок, генерируется прямое произведение соответствующих множеств. - -Адреса или их фрагменты в фигурных скобках можно указать через символ \|. В этом случае, соответствующие множества адресов понимаются как реплики - запрос будет отправлен на первую живую реплику. При этом, реплики перебираются в порядке, согласно текущей настройке [load\_balancing](../../operations/settings/settings.md). - -Пример: - -``` text -example01-{01..02}-{1|2} -``` - -В этом примере указано два шарда, в каждом из которых имеется две реплики. - -Количество генерируемых адресов ограничено константой - сейчас это 1000 штук. - -Использование табличной функции `remote` менее оптимально, чем создание таблицы типа `Distributed`, так как в этом случае, соединения с серверами устанавливаются заново при каждом запросе, в случае задания имён хостов, делается резолвинг имён, а также не ведётся подсчёт ошибок при работе с разными репликами. При обработке большого количества запросов, всегда создавайте `Distributed` таблицу заранее, не используйте табличную функцию `remote`. - -Табличная функция `remote` может быть полезна для следующих случаях: - -- обращение на конкретный сервер в целях сравнения данных, отладки и тестирования; -- запросы между разными кластерами ClickHouse в целях исследований; -- нечастых распределённых запросов, задаваемых вручную; -- распределённых запросов, где набор серверов определяется каждый раз заново. - -Если пользователь не задан,то используется `default`. -Если пароль не задан, то используется пустой пароль. - -`remoteSecure` - аналогично функции `remote`, но с соединением по шифрованному каналу. Порт по умолчанию - `tcp_port_secure` из конфига или 9440. - -[Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/table_functions/remote/) diff --git a/docs/ru/whats-new/changelog/2017.md b/docs/ru/whats-new/changelog/2017.md new file mode 120000 index 00000000000..d581cbbb422 --- /dev/null +++ b/docs/ru/whats-new/changelog/2017.md @@ -0,0 +1 @@ +../../../en/whats-new/changelog/2017.md \ No newline at end of file diff --git a/docs/ru/whats-new/changelog/2018.md b/docs/ru/whats-new/changelog/2018.md new file mode 120000 index 00000000000..22874fcae85 --- /dev/null +++ b/docs/ru/whats-new/changelog/2018.md @@ -0,0 +1 @@ +../../../en/whats-new/changelog/2018.md \ No newline at end of file diff --git a/docs/ru/whats-new/changelog/2019.md b/docs/ru/whats-new/changelog/2019.md new file mode 120000 index 00000000000..0f3f095f8a1 --- /dev/null +++ b/docs/ru/whats-new/changelog/2019.md @@ -0,0 +1 @@ +../../../en/whats-new/changelog/2019.md \ No newline at end of file diff --git a/docs/ru/whats-new/changelog/index.md b/docs/ru/whats-new/changelog/index.md new file mode 100644 index 00000000000..c13441a8bd5 --- /dev/null +++ b/docs/ru/whats-new/changelog/index.md @@ -0,0 +1,7 @@ +--- +toc_folder_title: Changelog +toc_priority: 74 +toc_title: '2020' +--- + +{% include "content/changelog.md" %} diff --git a/docs/ru/whats-new/extended-roadmap.md b/docs/ru/whats-new/extended-roadmap.md new file mode 100644 index 00000000000..20ebe28fe5b --- /dev/null +++ b/docs/ru/whats-new/extended-roadmap.md @@ -0,0 +1,1990 @@ +# Планы разработки ClickHouse 2020 {#plany-razrabotki-clickhouse-2020} + +Здесь собраны важные задачи на 2020 год. Многие из них присутствуют в GitHub Issues. Данный текст следует рассматривать как рабочий черновик со сводкой и кратким описанием задач, ссылками и материалами для быстрого доступа на одной странице. Классификация задач условная. + +Так как ClickHouse - open-source продукт, мы хотим, чтобы рабочий процесс был также максимально открытым. В связи с этим, вам следует ожидать наличия на данной странице несколько большего количества деталей описания рабочего процесса, чем вы могли бы предположить - настолько близко, насколько рабочий процесс видят разработчики. Так как неотъемлимой частью процесса разработки является исправление недостатков продукта и улучшение качества кода, на данной странице вы найдёте весьма подробные описания таких деталей. Для других open-source продуктов такой подход к разработке обычно нехарактерен. Благодаря тому, что для каждой задачи указаны её зависимости, вы сможете понять, какие подготовительные работы требуются, что позволяет более точно понимать сроки реализации. + +## 1. Хранение данных, индексация {#khranenie-dannykh-indeksatsiia} + +### 1.1. Индексы по z-Order curve, normalized z-Order curve {#indeksy-po-z-order-curve-normalized-z-order-curve} + +[\#6286](https://github.com/ClickHouse/ClickHouse/pull/6286) + +Задача также относится к категории «17. Работа с географическими данными», так как geoHash - это частный случай z-Order curve. +Также связана с задачей 24.27 для нечёткого поиска полудубликатов строк, так как позволит индексировать min-hash. +Задача «normalized z-Order curve» в перспективе может быть полезна для БК и Метрики, так как позволяет смешивать OrderID и PageID и избежать дублирования данных. +В задаче также вводится способ индексации путём обращения функции нескольких аргументов на интервале, что имеет смысл для дальнейшего развития. + +[Андрей Чулков](https://github.com/achulkov2), ВШЭ. + +### 1.2. + Wait-free каталог баз данных {#wait-free-katalog-baz-dannykh} + +Q2. Делает [Александр Токмаков](https://github.com/tavplubix), первый рабочий вариант в декабре 2019. Нужно для DataLens и Яндекс.Метрики. + +Манипуляции с каталогом баз данных: запросы CREATE TABLE, DROP TABLE, RENAME TABLE и DATABASE, требуют синхронизации с помощью блокировок. Эта синхронизация становится весьма сложной, так как на неё полагается много внутренних структур данных. + +Предлагается реализовать альтернативный подход, в котором таблицы и базы данных являются всего лишь ссылками на persistent объекты. Подробное описание задачи: [\#6787](https://github.com/ClickHouse/ClickHouse/issues/6787) + +Upd. Сделана крупная часть задачи, но ориентироваться стоит уже на Q2. +Upd. Pull request готов для мержа. +Upd. Попало 20.4. Доступно под флагом allow_experimental_database_atomic. + +### 1.3. Неблокирующие ALTER {#neblokiruiushchie-alter} + +Q1. И полностью immutable куски. Делает [Александр Сапин](https://github.com/alesapin). Готов приступить к задаче в конце ноября 2019. Нужно для Яндекс.Метрики. + +Upd. Большая часть задачи реализована и добавлена в master. Есть незначительные технические долги. Остаётся реализация неблокирующего изменения метаданных таблицы. + +### 1.4. + Нетранзитивные ALTER столбцов {#netranzitivnye-alter-stolbtsov} + +Требует 1.3. Будет делать [Александр Сапин](https://github.com/alesapin). Ура, сделано. + +### 1.5. + ALTER RENAME COLUMN {#alter-rename-column} + +[\#6861](https://github.com/ClickHouse/ClickHouse/issues/6861) + +Требует 1.3. Будет делать [Александр Сапин](https://github.com/alesapin). + +### 1.6. + Полиморфные куски данных {#polimorfnye-kuski-dannykh} + +Компактные куски - Q1, куски в оперативке Q1/Q2 - пункт 1.7. + +Компактные куски реализованы, ещё не включены по-умолчанию. Первым шагом включаем по-умолчанию для системных таблиц. + +Upd. Включено для системных таблиц. + +Делает [Антон Попов](https://github.com/CurtizJ), первый рабочий вариант в декабре. Пререквизит чтобы снизить сложность мелких INSERT, что в свою очередь нужно для 1.12, иначе задача 1.12 не сможет нормально работать. Особенно нужно для Яндекс.Облака. + +Данные в таблицах типа MergeTree в ClickHouse хранятся в виде набора независимых «кусков». Внутри куска, каждый столбец, а также индекс, хранится в отдельных файлах. Это сделано для возможности быстрых манипуляций со столбцами (пример - запрос ALTER DROP COLUMN). При вставке данных (INSERT), создаётся новый кусок. Для таблиц с большим количеством столбцов, запросы INSERT с маленьким количеством строк являются неэффективными, так как требуют создания большого количества файлов в файловой системе. Это является врождённой особенностью ClickHouse - одной из первой проблем, с которыми сталкиваются пользователи. Пользователям приходится буферизовывать данные и собирать их в более крупные пачки перед вставкой в ClickHouse. + +Для смягчения эффекта от этой проблемы, в ClickHouse существуют таблицы типа Buffer. Они накапливают данные в оперативке перед записью в другую таблицу. Впрочем, таблицы Buffer не являются полноценным решением проблемы из-за: - наличия блокировок при вставке; - переупорядочивание вставляемых данных; - неатомарность перекладывания данных из Buffer в результирующую таблицу. + +Вместо этого предлагается разрешить кускам таблиц типа MergeTree располагать данные в разных форматах. А именно: - в оперативной памяти; - на диске со всеми столбцами в одном файле; - на диске со столбцами в отдельных файлах: в зависимости от размера куска и прошедшего времени. Для размещения кусков в оперативной памяти, придётся также реализовать опциональную поддержку write-ahead log с настраиваемыми правилами по сбросу на диск. Это позволит избавиться от проблем с мелкими вставками для MergeTree таблиц. Для ReplicatedMergeTree таблиц, это решит проблему лишь частично. + +### 1.7. Буферизация и WAL в MergeTree {#buferizatsiia-i-wal-v-mergetree} + +Требует 1.6. Антон Попов. Задача взята в работу. Q2. +Есть pull request. + +### 1.8. + Перенос между разделами по TTL {#perenos-mezhdu-razdelami-po-ttl} + +Делает [Владимир Чеботарёв](https://github.com/excitoon), Altinity. Декабрь 2019. + +Q1. Закоммичено, но есть технический долг, который исправляется сейчас. +Готово. Нет, не готово - там всё ещё технический долг. + +### 1.9. + Использование TTL для прореживания данных {#ispolzovanie-ttl-dlia-prorezhivaniia-dannykh} + +Будет делать Сорокин Николай, ВШЭ и Яндекс. +Upd. Есть pull request. Upd. Сделано. + +Сейчас пользователь может задать в таблице выражение, которое определяет, сколько времени хранятся данные. Обычно это выражение задаётся относительно значения столбца с датой - например: удалять данные через три месяца. https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/\#table_engine-mergetree-ttl + +Это может быть задано для всей таблицы (тогда строки целиком удаляются после указанного времени) или для отдельных столбцов (тогда данные столбца физически удаляются с диска, а строки в таблице остаются; при чтении значений столбца, они читаются как значения по-умолчанию). + +Но пользователи также хотят более продвинутый вариант этой функциональности: не удалять строки или столбцы целиком, а прореживать их - оставлять меньшее количество строк. + +И тут есть несколько вариантов: +1. По прошествии времени, оставлять каждую N-ую строку. +2. По прошествии времени, выполнять агрегацию данных, заменяя значения некоторых столбцов на значения агрегатных функций от множества значений в нескольких строках. + +Пункт 1 не представляет интереса, так как уже реализован с помощью TTL выражений для удаления данных. В качестве этого выражения можно прописать, например, `cityHash64(*) % 10 = 0 ? now() : event_time + INTERVAL 3 MONTH`. Правда как-то неудобно получается. + +А вот пункт 2 требуется продумать. Не очевидно даже, какой лучше использовать синтаксис для этого при создании таблицы. Но мы придумаем - сразу видно несколько вариантов. + +Частный случай такой задачи уже есть в https://clickhouse.tech/docs/ru/operations/table_engines/graphitemergetree/ Но это было сделано для конкретной задачи. А надо обобщить. + +### 1.10. Пережатие старых данных в фоне {#perezhatie-starykh-dannykh-v-fone} + +Будет делать Кирилл Барухов, ВШЭ, экспериментальная реализация к весне 2020. Нужно для Яндекс.Метрики. + +Алгоритмы сжатия типа LZ77 позволяют потратить больше времени на сжатие данных, чтобы сжать данные сильнее, но при этом без проигрыша по скорости разжатия данных. В частности, этим свойством обладает LZ4 и ZSTD, которые используются в ClickHouse. Это позволяет использовать свободные ресурсы CPU, когда сервер не нагружен, для пережатия данных, чтобы данные занимали меньше места на дисках, и при этом сохранить или даже улучшить скорость обработки запросов. + +В то же время, ClickHouse обычно используется для «импульсного» сценария нагрузки. Запрос от пользователя обрабатывается максимально быстро, используя все ресурсы CPU, но в среднем по времени, сервер недостаточно нагружен. + +Предлагается добавить в ClickHouse настройки по пережатию данных и фоновые потоки, выполняющие эту задачу. + +### 1.11. + Виртуальная файловая система {#virtualnaia-failovaia-sistema} + +На VFS переведены Log, TinyLog, StripeLog, а также MergeTree, что доказывает состоятельность реализации. + +Нужно для Яндекс.Облака. Делает Александр, Яндекс.Облако. + +ClickHouse использует для хранения данных локальную файловую систему. Существует сценарий работы, в котором размещение старых (архивных) данных было бы выгодно на удалённой файловой системе. Если файловая система POSIX совместимая, то это не составляет проблем: ClickHouse успешно работает с Ceph, GlusterFS, MooseFS. Также востребованным является сценарий использования S3 (из-за доступности в облаке) или HDFS (для интеграции с Hadoop). Но эти файловые системы не являются POSIX совместимыми. Хотя для них существуют FUSE драйверы, но скорость работы сильно страдает и поддержка неполная. + +ClickHouse использует небольшое подмножество функций ФС, но в то же время, и некоторые специфические части: симлинки и хардлинки, O\_DIRECT. Предлагается выделить всё взаимодействие с файловой системой в отдельный интерфейс. + +### 1.12. Экспериментальная реализация VFS поверх S3 и HDFS {#eksperimentalnaia-realizatsiia-vfs-poverkh-s3-i-hdfs} + +Q2. + +Нужно для Яндекс.Облака. Требует 1.11. Желательно 1.6 и 1.18. +Делает Александр, Яндекс.Облако (сначала часть для S3), а также Олег Ершов, ВШЭ и Яндекс. + +Upd. Олег будет делать только часть про HDFS. +Upd. Реализация поверх S3 является рабочей на уровне PoC. + +### 1.13. + Ускорение запросов с FINAL {#uskorenie-zaprosov-s-final} + +Требует 2.1. Делает [Николай Кочетов](https://github.com/KochetovNicolai). Нужно для Яндекс.Метрики. Q2. +Upd: PR [#10463](https://github.com/ClickHouse/ClickHouse/pull/10463) + +### 1.14. Не писать столбцы, полностью состоящие из нулей {#ne-pisat-stolbtsy-polnostiu-sostoiashchie-iz-nulei} + +Антон Попов. Q2. +В очереди. Простая задача, является небольшим пререквизитом для потенциальной поддержки полуструктурированных данных. + +### 1.15. Возможность иметь разный первичный ключ в разных кусках {#vozmozhnost-imet-raznyi-pervichnyi-kliuch-v-raznykh-kuskakh} + +Сложная задача, только после 1.3. + +### 1.16. Несколько физических представлений для одного куска данных {#neskolko-fizicheskikh-predstavlenii-dlia-odnogo-kuska-dannykh} + +Сложная задача, только после 1.3 и 1.6. Позволяет компенсировать 21.20. + +### 1.17. Несколько сортировок для одной таблицы {#neskolko-sortirovok-dlia-odnoi-tablitsy} + +Сложная задача, только после 1.3 и 1.6. + +### 1.18. Отдельное хранение файлов кусков {#otdelnoe-khranenie-failov-kuskov} + +Требует 1.3 и 1.6. Полная замена hard links на sym links, что будет лучше для 1.12. + + +## 2. Крупные рефакторинги {#krupnye-refaktoringi} + +Для обоснования необходимости смотрите ссылки в описании других задач. + +### 2.1. Переделка конвейера выполнения запросов на Processors {#peredelka-konveiera-vypolneniia-zaprosov-na-processors} + +Делает [Николай Кочетов](https://github.com/KochetovNicolai). Финальная стадия разработки. Включение по-умолчанию в конце декабря 2019. Удаление старого кода в начале 2020. + +Upd. На данный момент исправляются проблемы с регрессиями производительности в отдельных случаях. Кажется, что все проблемы исправлены. +Включение по-умолчанию в Q1, но остаётся вторая часть задачи по корректному выделению async части. + +Upd. Включили по-умолчанию. Удаление старого кода не раньше, чем после первого релиза, в котором это включено по-умолчанию и всё ещё можно выключить обратно. + +Upd. Уже есть первый релиз, в котором это включено по-умолчанию. + +Upd. Всё ещё ждём удаление старого кода, которое должно случиться после релиза 20.4. + +### 2.2. Инфраструктура событий/метрик/ограничений/квот/трассировки {#infrastruktura-sobytiimetrikogranicheniikvottrassirovki} + +В очереди. https://gist.github.com/alexey-milovidov/d62d73222d83b9319dc519cbb13aeff6 + +### 2.3. Перенос столбцового ser/de из DataType в Column {#perenos-stolbtsovogo-serde-iz-datatype-v-column} + +В очереди. Антон Попов. + +### 2.4. Перевод LowCardinality из DataType в Column. Добавление ColumnSparse {#perevod-lowcardinality-iz-datatype-v-column-dobavlenie-columnsparse} + +Требует 2.3. + +### 2.5. Версионирование состояний агрегатных функций {#versionirovanie-sostoianii-agregatnykh-funktsii} + +В очереди. + +### 2.6. Правая часть IN как тип данных. Выполнение IN в виде скалярного подзапроса {#pravaia-chast-in-kak-tip-dannykh-vypolnenie-in-v-vide-skaliarnogo-podzaprosa} + +Требует 2.1. + +### 2.7. Нормализация Context {#normalizatsiia-context} + +В очереди. Нужно для YQL. + +Александр Токмаков исправил множество проблем с использованием Context и сейчас переносит каталог БД наружу. + +Upd. Каталог БД вынесен из Context. +Upd. SharedContext вынесен из Context. + +### 2.8. Декларативный парсер запросов {#deklarativnyi-parser-zaprosov} + +Средний приоритет. Нужно для YQL. + +Upd. В очереди. Иван Лежанкин. + +### 2.9. + Логгировние в format-стиле {#loggirovnie-v-format-stile} + +[#6049](https://github.com/ClickHouse/ClickHouse/issues/6049#issuecomment-570836998) + +Сделано. + +### 2.10. Запрашивать у таблиц не столбцы, а срезы {#zaprashivat-u-tablits-ne-stolbtsy-a-srezy} + +В очереди. + +### 2.11. Разбирательство и нормализация функциональности для bitmap {#razbiratelstvo-i-normalizatsiia-funktsionalnosti-dlia-bitmap} + +В очереди. + +### 2.12. Декларативные сигнатуры функций {#deklarativnye-signatury-funktsii} + +[\#3775](https://github.com/ClickHouse/ClickHouse/pull/3775) + +Задачу делает Алексей Миловидов. Прогресс 50% и разработка временно приостановлена. + +Upd. Разработка всё ещё приостановлена. + +### 2.13. Каждая функция в отдельном файле {#kazhdaia-funktsiia-v-otdelnom-faile} + +Задачу делает Алексей Миловидов. Прогресс 80%. Потребуется помощь других разработчиков. + +Upd. Поползновения наблюдаются. + +### 2.14. Все функции с состоянием переделать на FunctionBuilder {#vse-funktsii-s-sostoianiem-peredelat-na-functionbuilder} + +Долг [Николай Кочетов](https://github.com/KochetovNicolai). Сейчас код находится в переходном состоянии, что неприемлемо. + +### 2.15. Функция subscribe для IStorage {#funktsiia-subscribe-dlia-istorage} + +Для нормализации работы materialized views поверх Merge, Distributed, Kafka. + + +## 3. Документация {#dokumentatsiia} + +Здесь задачи только по инфраструктуре документации. + +### 3.1. Перенос документации по функциям в код {#perenos-dokumentatsii-po-funktsiiam-v-kod} + +Требует 2.12 и 2.13. Хотим в Q2, средний приоритет. + +### 3.2. Перенос однородных частей документации в код {#perenos-odnorodnykh-chastei-dokumentatsii-v-kod} + +Требует 3.1. + +### + 3.3. Исправить катастрофически отвратительно неприемлемый поиск по документации {#ispravit-katastroficheski-otvratitelno-nepriemlemyi-poisk-po-dokumentatsii} + +[Иван Блинков](https://github.com/blinkov/) - очень хороший человек. Сам сайт документации основан на технологиях, не удовлетворяющих требованиям задачи, и эти технологии трудно исправить. Задачу будет делать первый встретившийся нам frontend разработчик, которого мы сможем заставить это сделать. + +Upd. Иван Блинков сделал эту задачу путём замены треш-технологий на нормальные. + +### 3.4. + Добавить японский язык в документацию {#dobavit-iaponskii-iazyk-v-dokumentatsiiu} + +Эту задачу сделает [Иван Блинков](https://github.com/blinkov/), до конца декабря 2019. Сделано. + + +## 4. Сетевое взаимодействие {#setevoe-vzaimodeistvie} + +### 4.1. Уменьшение числа потоков при распределённых запросах {#umenshenie-chisla-potokov-pri-raspredelionnykh-zaprosakh} + +Весна 2020. Upd. Есть прототип. Upd. Он не работает. Upd. Человек отказался от задачи, теперь сроки не определены. + +### 4.2. Спекулятивное выполнение запросов на нескольких репликах {#spekuliativnoe-vypolnenie-zaprosov-na-neskolkikh-replikakh} + +Нужно для Яндекс.Метрики. Требует 4.1. + +Если распределённый запрос затрагивает большое количество серверов, то время выполнения запросов часто становится большим из-за tail latencies - случайных редких замедлений отдельных серверов. Эту проблему можно избежать, отправляя один и тот же запрос сразу на несколько реплик, и используя данные с наиболее быстрой. + +Задача скрывает в себе много тонкостей, связанных с обработкой стадий выполнения запроса (соединение, обмен handshake, отправка запроса, получение заголовка результата, получение пакетов прогресса, получение данных), правильной возможностью настройки таймаутов, правильной отменой запросов. + +Сейчас для распределённых запросов используется по потоку на соединение. Это позволяет хорошо распараллелить вычисления над полученными данными и утилизировать сеть, но становится сильно избыточным для больших кластеров. Для примера, создание 1000 потоков для чтения данных из 1000 серверов кластера - лишь расходует ресурсы и увеличивает время выполнения запроса. Вместо этого необходимо использовать количество потоков не большее количества процессорных ядер, и мультиплексировать в одном потоке общение с серверами. Реализация нетривиальна, так как мультиплексировать необходимо каждую стадию общения по сети, включая установку соединения и обмен handshake. + +Upd. Сейчас обсуждается, как сделать другую задачу вместо этой. + +### 4.3. Ограничение числа одновременных скачиваний с реплик {#ogranichenie-chisla-odnovremennykh-skachivanii-s-replik} + +Изначально делал Олег Алексеенков, но пока решение не готово, хотя там не так уж много доделывать. + +### 4.4. Ограничение сетевой полосы при репликации {#ogranichenie-setevoi-polosy-pri-replikatsii} + +Нужно для Метрики. + +### 4.5. Возможность продолжить передачу куска данных при репликации после сбоя {#vozmozhnost-prodolzhit-peredachu-kuska-dannykh-pri-replikatsii-posle-sboia} + +### 4.6. p2p передача для GLOBAL подзапросов {#p2p-peredacha-dlia-global-podzaprosov} + +### 4.7. Ленивая загрузка множеств для IN и JOIN с помощью k/v запросов {#lenivaia-zagruzka-mnozhestv-dlia-in-i-join-s-pomoshchiu-kv-zaprosov} + +### 4.8. Разделить background pool для fetch и merge {#razdelit-background-pool-dlia-fetch-i-merge} + +В очереди. Исправить проблему, что восстанавливающаяся реплика перестаёт мержить. Частично компенсируется 4.3. + + +## 5. Операции {#operatsii} + +### 5.1. + Разделение задач на более мелкие куски в clickhouse-copier {#razdelenie-zadach-na-bolee-melkie-kuski-v-clickhouse-copier} + +[\#9075](https://github.com/ClickHouse/ClickHouse/pull/9075) +Q1. Нужно для Метрики, в очереди. Никита Михайлов. + +Upd. Задача на финальной стадии разработки. +Upd. Сделано. Эффективность работы под вопросом. Есть варианты, как сделать лучше. + +### 5.2. + Автонастройка лимита на оперативку и размера кэшей {#avtonastroika-limita-na-operativku-i-razmera-keshei} + +### 5.3. + Встроенная ручка для Prometheus {#vstroennaia-ruchka-dlia-prometheus} + +Сделано. https://github.com/Vdimir + +### 5.4. Opt-in сообщать в клиенте, если вышла новая версия {#opt-in-soobshchat-v-kliente-esli-vyshla-novaia-versiia} + +Есть поползновения. + +### 5.5. + LTS релизы {#lts-relizy} + +Требует 7.5. Задачу хочет Метрика, Облако, БК, Маркет и Altinity. Первой LTS версией уже стала версия 19.14. +Метрика, БК, Маркет, Altinity уже используют более свежие версии чем LTS. +Upd. Появилась вторая версия LTS - 20.3. + + +## 6. Инструментирование {#instrumentirovanie} + +### 6.1. + Исправления сэмплирующего профайлера запросов {#ispravleniia-sempliruiushchego-profailera-zaprosov} + +Михаил Филимонов, Altinity. Ноябрь 2019. Сделано. +Осталось ещё проверить работоспособность профайлера в первом потоке (что важно для INSERT). Иван Лежанкин. Q1. Сделано. + +### 6.2. + Добавление memory profiler {#dobavlenie-memory-profiler} + +[\#6387](https://github.com/ClickHouse/ClickHouse/issues/6387) + +Сравнительно простая задача, но только для опытных разработчиков. Нужна всем. Иван Лежанкин. Q1. Сделано. + +### 6.3. + Учёт оперативки total расширить не только на запросы {#uchiot-operativki-total-rasshirit-ne-tolko-na-zaprosy} + +Исправление долгоживущей проблемы с дрифтом учёта оперативки. Нужна для Метрики и БК. + +### 6.4. Поддержка perf events как метрик запроса {#podderzhka-perf-events-kak-metrik-zaprosa} + +Делает Андрей Скобцов, ВШЭ. + +В Linux существует возможность получать в программе информацию о счётчиках производительности и событиях, относящихся к CPU и ядру ОС. Подробнее смотрите `man perf_event_open`. Предлагается добавить эти метрики в ClickHouse для инструментирования запросов. + +Есть прототип. + +### 6.5. Эксперименты с LLVM X-Ray {#eksperimenty-s-llvm-x-ray} + +Требует 2.2. + +### 6.6. + Стек трейс для любых исключений {#stek-treis-dlia-liubykh-iskliuchenii} + +Сейчас есть стек трейс для почти всех, но не всех исключений. Требует 7.4. + +### 6.7. + Таблица system.stack\_trace {#tablitsa-system-stack-trace} + +Сравнительно простая задача, но только для опытных разработчиков. + +### 6.8. Таблица system.crashes {#tablitsa-system-crashes} + +Сравнительно простая задача, но только для опытных разработчиков. + +### 6.9. Отправлять информацию клиенту, если сервер падает по сигналу {#otpravliat-informatsiiu-klientu-esli-server-padaet-po-signalu} + +### 6.10. Сбор общих системных метрик {#sbor-obshchikh-sistemnykh-metrik} + + +## 7. Сопровождение разработки {#soprovozhdenie-razrabotki} + +### 7.1. + ICU в submodules {#icu-v-submodules} + +Добавление в submodules также нужно для Аркадии (7.26). + +### 7.2. + LLVM в submodules {#llvm-v-submodules} + +Сделал Алексей Миловидов. + +### 7.3. + Обновление Poco {#obnovlenie-poco} + +Алексанр Кузьменков. + +### 7.4. + Включить libc++, libc++-abi при сборке с gcc {#vkliuchit-libc-libc-abi-pri-sborke-s-gcc} + +Сейчас включено только при сборке с clang, но продакшен сборка использует gcc. +Требует 7.2 и, возможно, 7.1 (только в случае новой версии ICU). + +### 7.5. + Начать публиковать LTS релизы {#nachat-publikovat-lts-relizy} + +[Александр Сапин](https://github.com/alesapin). + +### 7.6. + Правильный статистический тест для comparison mode в clickhouse-performance-test {#pravilnyi-statisticheskii-test-dlia-comparison-mode-v-clickhouse-performance-test} + +Задачу начал делать Дмитрий Рубашкин (ВШЭ). Сейчас продолжает [Александр Кузьменков](https://github.com/akuzm). Сделано, работает в CI. Долгое время не были определены надёжные критерии для результата теста. Сейчас проблема решена, но остались не решёнными некоторые вопросы. + +### 7.7. + Доделать тесты под MSan {#dodelat-testy-pod-msan} + +Уже есть ASan, TSan, UBSan. Не хватает тестов под MSan. Они уже добавлены в CI, но не проходят. +[Александр Кузьменков](https://github.com/akuzm) и [Александр Токмаков](https://github.com/tavplubix). + +Upd. Задача всё ещё медленно тащится. +Upd. Доделал Алексей Миловидов. + +### 7.8. + Добавить clang-tidy {#dobavit-clang-tidy} + +Уже есть PVS-Studio. Мы очень довольны, но этого недостаточно. + +Upd. Алексей Миловидов. Добавлено некоторое множество проверок, но нужно рассмотреть все проверки подряд и добавить всё, что можно. +Upd. Рассмотрели все проверки подряд. + +### 7.9. + Проверки на стиль имён с помощью clang-tidy {#proverki-na-stil-imion-s-pomoshchiu-clang-tidy} + +Сделано. Только в .cpp файлах и только для имён локальных переменных. Остальное слишком сложно. + +### 7.10. Включение UBSan и MSan в интеграционных тестах {#vkliuchenie-ubsan-i-msan-v-integratsionnykh-testakh} + +UBSan включен в функциональных тестах, но не включен в интеграционных тестах. Требует 7.7. + +### 7.11. + Включение \*San в unit тестах {#vkliuchenie-san-v-unit-testakh} + +У нас мало unit тестов по сравнению с функциональными тестами и их использование не обязательно. Но они всё-равно важны и нет причин не запускать их под всеми видами sanitizers. + +Илья Яцишин. Сделано. + +### 7.12. Показывать тестовое покрытие нового кода в PR {#pokazyvat-testovoe-pokrytie-novogo-koda-v-pr} + +Пока есть просто показ тестового покрытия всего кода. + +### 7.13. + Включение аналога -Weverything в gcc {#vkliuchenie-analoga-weverything-v-gcc} + +Мы используем -Wall -Wextra -Weverything -Werror. +При сборке с clang, -Weverything уже включено. Но в gcc есть уникальные warning-и, отсутствующие в clang. +Сделал Wolf Kreuzerkrieg. + +### 7.14. + Альтернатива для readline и libedit {#alternativa-dlia-readline-i-libedit} + +Подключение replxx вместо readline сделал Иван Лежанкин. + +Есть технический долг с лицензиями файлов консорциума Unicode. +Есть технический долг с работой \G в multiline режиме. + +### 7.14.1. Улучшение возможностей интерактивного режима clickhouse-client {#uluchshenie-vozmozhnostei-interaktivnogo-rezhima-clickhouse-client} + +Тагир Кускаров, ВШЭ. + +Upd. В рамках данной задачи добавляем подстветку синтаксиса и исправление проблем со вставкой больших запросов. + +Для ввода запросов в интерактивном режиме в клиенте командной строки clickhouse-client использовалась библиотека readline или libedit. + +Библиотеки readline и libedit обладает следующими недостатками: +- (исправлено в новых версиях readline) Очень низкая производительность вставки больших кусков текста. Вставка каждого следующего символа имеет сложность O(n = количество предыдущих символов) и при вставке 1 МБ текста, скорость падает до десятков байт в секунду. +- Крайне сложно или невозможно реализовать подсветку синтаксиса по мере набора текста, а также autocomplete без нажатия дополнительных клавиш для вызова. +- Лицензия GPL (для readline) препятствует её включению в кодовую базу продукта. +- Плохо работает навигация по истории, если история вкючает запросы, не помещающиеся на экран. +- История сохраняется лишь при завершении работы клиента. +- При параллельной работе нескольких клиентов с одним файлом истории, сохраняется история только одного из клиентов. +- Плохо работает история для многострочных запросов. +- Излишняя экономия пересылаемых данных, что часто приводит к остаткам мусора в терминале. + +Кроме того, имеются следующие сложно достижимые достоинства: +- Поддержка right-to-left текста; +- Поддержка editrc конфигураций. + +В качестве альтернатив можно рассмотреть следующие варианты: +- Linenoise от Salvatore Sanfilippo. Достоинства: простота и компактность кода; высокая скорость работы. Недостатки: отсутствует поддержка Unicode; отсутствует автоматический перенос текста, что затрудняет работу с многострочными запросами. +- Linenoise с патчами для поддержки Unicode. Недостаток: теряется преимущество по скорости работы. +- Fish shell. Не является библиотекой, но представляет собой отличный пример, как можно реализовать подстветку синтаксиса и удобный autocomplete. Поддерживает Unicode, но работает весьма медленно. +- Python Prompt Toolkit. Не является подходящим решением для интеграции в C++ проект. Хорошие возможности по подсветке синтаксиса и autocomplete. + +Вместо этого предлагается в качестве примера изучить прототип текстового редактора Kilo: https://viewsourcecode.org/snaptoken/kilo/ и реализовать всю необходимую функциональность. + +### 7.15. + Замена libressl обратно на openssl {#zamena-libressl-obratno-na-openssl} + +Поводом использования libressl послужило желание нашего хорошего друга из известной компании несколько лет назад. Но сейчас ситуация состоит в том, что openssl продолжает развиваться, а libressl не особо, и можно спокойно менять обратно. + +Нужно для Яндекс.Облака для поддержки TLS 1.3. + +### 7.16. + tzdata внутри бинарника {#tzdata-vnutri-binarnika} + +Как в Аркадии, fallback на системные. + +### 7.17. + Доделать tgz пакеты {#dodelat-tgz-pakety} + +Уже давно собираются универсальные tgz пакеты, но по нелепой случайности из них исчез install скрипт. +[Александр Сапин](https://github.com/alesapin). Может делегировать эту задачу кому угодно. +Upd. Сделано всё кроме инструкции на сайте. Для этого требуется создать директории testing/stable/prestable на repo.yandex.ru. Внезапно оказалось, что человек, отвечающий за это, в отпуске, и он не отвечает на вопрос, кто его заместитель. Q1. + +### 7.18. + Доделать бинарники под Mac {#dodelat-binarniki-pod-mac} + +Уже есть автосборка бинарников под Mac на каждый коммит и PR, но с недостатками. +[Иван Лежанкин](https://github.com/abyss7). Требует 7.1, 7.2. Рекомендуется 7.14. Сейчас не хватает по крайней мере SSL и ICU. Нужно для Яндекс.Облака. +Upd. Сделано SSL. Ориентируемся в Q1, но приоритет средний и может потеряться. + +### 7.18.1. Поместить ссылку на собранные бинарники под Mac на сайт {#pomestit-ssylku-na-sobrannye-binarniki-pod-mac-na-sait} + +Сейчас людям приходится делать несколько кликов, чтобы их скачать. +[Иван Лежанкин](https://github.com/abyss7) или [Александр Сапин](https://github.com/alesapin). + +### 7.19. + Доделать (проверить) автосборку под AArch64 {#dodelat-proverit-avtosborku-pod-aarch64} + +https://github.com/ClickHouse/ClickHouse/issues/8027\#issuecomment-566670282 +Проверили на настоящем сервере Huawei, а также в специальном Docker контейнере, который содержит внутри qemu-user-static. +Также можно проверить на Cavium, на Raspberry Pi а также на твоём Android телефоне. + +### 7.20. + Автосборка для FreeBSD x86\_64 {#avtosborka-dlia-freebsd-x86-64} + +[Иван Лежанкин](https://github.com/abyss7). + +Upd. В процессе реализации, есть pull request. +Upd. Есть сборки, [пример](https://clickhouse-builds.s3.yandex.net/0/2cb4c91c0286b774534fcbe80e5ef8835a74a83a/report.html) +Всё ещё нет инструкции на сайте! + +### 7.21. Автосборка для Linux ppc64 {#avtosborka-dlia-linux-ppc64} + +[Иван Лежанкин](https://github.com/abyss7). +Как-то медленно тащится. + +### 7.22. Дэшборд для pull requests {#deshbord-dlia-pull-requests} + +Дарья Петрова, УрФУ. + +Рабочий прототип: https://pulls-dashboard-demo.herokuapp.com/dashboard/ClickHouse/ClickHouse + +Над ClickHouse одновременно работает большое количество разработчиков, которые оформляют свои изменения в виде pull requests. Когда непомерженных pull requests много, то возникает сложность с организацией работы - непонятно, на какой pull request смотреть в первую очередь. + +Предлагается реализовать простое одностраничное веб-приложение, в котором отображается список pull requests со следующей информацией: +- размер diff - количество изменённых строк; +- как давно было последнее обновление; +- типы изменённых файлов: C++, документация, скрипты сборки; +- наличие добавленных тестов; +- есть ли описание для changelog; +- изменены ли submodules; +- был ли разрешён запуск проверок CI; +- статусы проверок CI; +- количество approve от ревьюеров; + +Статусы проверок - наиболее важная часть. Так как для каждого PR выполняется несколько десятков проверок и наиболее медленные работают до нескольких часов, придётся: +- отображать сразу все проверки для каждого PR в виде красивой разноцветной матрицы с информацией по наведению мыши; +- отсортировать проверки по важности: например, если у внешнего разработчика проходят все проверки кроме стиля кода, то мы можем взять это в работу сами; +- если для предыдущего коммита проверка была завершена, а для последнего коммита ещё только идёт - то можно отображать в таблице статус предыдущей проверки более блёклым цветом. + +Предлагается реализовать несколько вариантов сортировок. Очевидное - по времени обновления, более интересно - некое ранжирование с целью выяснить, «что лучше взять в работу прямо сейчас». + +Похожие продукты уже есть, например: http://prs.mozilla.io/yandex:ClickHouse К сожалению, этот продукт заброшен, да и делает не совсем то, что нужно. По своему усмотрению, можно взять из него что-нибудь полезное. + +### 7.23. Функции для fuzzing {#funktsii-dlia-fuzzing} + +Андрей Некрашевич, ВШЭ. + +Fuzzing тестирование - это тестирование случайными данными. Мы рассмотрим несколько подходов к этой задачи: + +1. Добавление в SQL диалект ClickHouse функций для генерации случайных данных (пример - случайные бинарные строки заданной длины, случайные валидные UTF-8 строки) и «порчи» данных (например, поменять значения случайных бит с заданной частотой). Это будет использовано для тестирования SQL-функций ClickHouse. + +Можно добавить функции: +`randomString(length)` +`randomFixedString(length)` +- строка заданной длины с равномерно распределёнными случайными байтами; +`randomStringASCII(length)` +`randomStringUTF8(length)` + +`fuzzBits(s, inverse_probability)` - изменить каждый бит строки на противоположный с заданной вероятностью; +`fuzzBytes(s, inverse_probability)` - изменить каждый байт строки на равномерно случайный с заданной вероятностью; + +У каждой функции опциональный аргумент против склейки одинаковых выражений в запросе. + +Также можно сделать функции с детерминированным генератором случайных чисел (аргументом передаётся seed) для воспроизводимости тестовых кейсов. + +Upd. Сергей Штыков сделал функцию `randomPrintableASCII`. +Upd. Илья Яцишин сделал табличную функцию `generateRandom`. +Upd. Эльдар Заитов добавляет OSS Fuzz. +Upd. Сделаны randomString, randomFixedString. + +### 7.24. Fuzzing лексера и парсера запросов; кодеков и форматов {#fuzzing-leksera-i-parsera-zaprosov-kodekov-i-formatov} + +Андрей Некрашевич, ВШЭ. + +Продолжение 7.23. + +1. Использование AFL или LibFuzzer для тестирования отдельных частей кодовой базы ClickHouse. + +2. Генерация и выполнение случайных синтаксически корректных запросов на случайных данных. + +### 7.25. + Синхронизация релизов в Аркадию {#sinkhronizatsiia-relizov-v-arkadiiu} + +Изначально занимался Олег Алексеенков. Сейчас он перешёл работать в дружественный отдел, но обещает продолжать синхронизацию. +Затем, возможно, [Иван Лежанкин](https://github.com/abyss7). Но сейчас приостановлено, так как Максим из YT должен исправить регрессию производительности в анализе индекса. + +Максим из YT сказал, что сделает это после нового года. +Максим из YT сказал, что «мы планируем в январе добиться». +Максим сейчас занимается собираемостью YT с новой версией ClickHouse. + +Нужно для CHYT и YQL. + +Upd: Все патчи Максима отправлены в master. Задача взята в работу. +Upd: Задача в процессе реализации. Синхронизироваться будет master. Делает [Иван Лежанкин](https://github.com/abyss7) +Upd: Есть собирающийся прототип, но сборка как будто ещё не в trunk Аркадии. +Upd: Добавлено в Аркадию, но не все файлы (не побайтово). + +### 7.26. + Побайтовая идентичность репозитория с Аркадией {#pobaitovaia-identichnost-repozitoriia-s-arkadiei} + +Команда DevTools. Прогресс по задаче под вопросом. +Upd. Готово (все директории кроме contrib). + +### 7.27. Запуск автотестов в Аркадии {#zapusk-avtotestov-v-arkadii} + +Требует 7.26. Коллеги начали делать, есть результат. + +### 7.29. Опции clickhouse install, stop, start вместо postinst, init.d, systemd скриптов {#optsii-clickhouse-install-stop-start-vmesto-postinst-init-d-systemd-skriptov} + +Низкий приоритет. + +### 7.30. Возможность переключения бинарных файлов на продакшене без выкладки пакетов {#vozmozhnost-perekliucheniia-binarnykh-failov-na-prodakshene-bez-vykladki-paketov} + +Низкий приоритет. + +### 7.31. Зеркалирование нагрузки между серверами {#zerkalirovanie-nagruzki-mezhdu-serverami} + +В очереди. Нужно для Яндекс.Метрики. + +### 7.32. Обфускация продакшен запросов {#obfuskatsiia-prodakshen-zaprosov} + +Роман Ильговский. Нужно для Яндекс.Метрики. +Есть pull request, почти готово: https://github.com/ClickHouse/ClickHouse/pull/10973 + +Имея SQL запрос, требуется вывести структуру таблиц, на которых этот запрос будет выполнен, и заполнить эти таблицы случайными данными, такими, что результат этого запроса зависит от выбора подмножества данных. + +Для примера, если есть запрос `SELECT SearchPhrase, count(*) FROM table WHERE CounterID = 34 AND SearchPhrase LIKE '%ClickHouse%'`, то мы можем сделать вывод, что CounterID имеет числовой тип, а SearchPhrase - строковый. Заполнить таблицу данными, на которых отдельные условия `CounterID = 34` и `SearchPhrase LIKE '%ClickHouse%'` для некоторых строк выполнены, а для некоторых строк не выполнены. + +Обфускация запросов: имея секретные запросы и структуру таблиц, заменить имена полей и константы, чтобы запросы можно было использовать в качестве публично доступных тестов. + +### 7.33. Выкладывать патч релизы в репозиторий автоматически {#vykladyvat-patch-relizy-v-repozitorii-avtomaticheski} + +В очереди. Иван Лежанкин. +Отсутствует прогресс. + +### 7.34. Бэкпортировать bugfix автоматически {#bekportirovat-bugfix-avtomaticheski} + +В очереди. Иван Лежанкин. +Отсутствует прогресс. + +### 7.35. Начальные правила для авто-merge {#nachalnye-pravila-dlia-avto-merge} + +Зелёные проверки и два ревью. +[Александр Сапин](https://github.com/alesapin). Может делегировать эту задачу кому угодно. + +### 7.36. Понятие доверенных контрибьюторов {#poniatie-doverennykh-kontribiutorov} + +Контрибьюторы, у которых есть 5 померженных PR. Для их новых PR автотесты запускаются сразу. +[Александр Сапин](https://github.com/alesapin). Может делегировать эту задачу кому угодно. +Сейчас добавляем некоторых доверенных контрибьюторов в ручном режиме. + +### 7.37. Разобраться с repo.yandex.ru {#razobratsia-s-repo-yandex-ru} + +Есть жалобы на скорость загрузки и неудобство maintenance, operations, visibility. + +Upd. Иван Блинков настроил CDN repo.clickhouse.tech, что решает проблему с доступностью зарубежом. +Вопрос с operations, visibility пока актуален. + + +## 8. Интеграция с внешними системами {#integratsiia-s-vneshnimi-sistemami} + +### 8.1. Поддержка ALTER MODIFY SETTING для Kafka {#podderzhka-alter-modify-setting-dlia-kafka} + +Также - возможность указать все настройки форматов в Kafka. + +Altinity. Никто не делает эту задачу. + +### 8.2. Поддержка Mongo Atlas URI {#podderzhka-mongo-atlas-uri} + +[Александр Кузьменков](https://github.com/akuzm). +Upd. Задача взята в работу. + +### 8.3. + Доработки globs (правильная поддержка диапазонов, уменьшение числа одновременных stream-ов) {#dorabotki-globs-pravilnaia-podderzhka-diapazonov-umenshenie-chisla-odnovremennykh-stream-ov} + +[Ольга Хвостикова](https://github.com/stavrolia). + +Уменьшение числа stream-ов сделано, а вот правильная поддержка диапазонов - нет. Будем надеяться на Q1/Q2. Сделано. + +### 8.4. Унификация File, HDFS, S3 под URL {#unifikatsiia-file-hdfs-s3-pod-url} + +### 8.5. + Аутентификация в S3 {#autentifikatsiia-v-s3} + +[Владимир Чеботарёв](https://github.com/excitoon), Altinity. + +### 8.6. Kerberos аутентификация для HDFS и Kafka {#kerberos-autentifikatsiia-dlia-hdfs-i-kafka} + +Андрей Коняев, ArenaData. Он куда-то пропал. + +### 8.7. + Исправление мелочи HDFS на очень старых ядрах Linux {#ispravlenie-melochi-hdfs-na-ochen-starykh-iadrakh-linux} + +В ядрах 2.6 отсутствует один системный вызов, который библиотека hdfs3 использует без необходимости. +Сделал Amos Bird. + +### 8.8. + Поддержка виртуальных столбцов с именем файла и путём {#podderzhka-virtualnykh-stolbtsov-s-imenem-faila-i-putiom} + +[Ольга Хвостикова](https://github.com/stavrolia). + +### 8.9. + Поддержка сжатых файлов (gz, bz) на чтение и запись {#podderzhka-szhatykh-failov-gz-bz-na-chtenie-i-zapis} + +Сделал [Andrey Bodrov](https://github.com/apbodrov) + +### 8.10. Запись в табличную функцию ODBC {#zapis-v-tablichnuiu-funktsiiu-odbc} + +Артемий Бобровский, ВШЭ +Есть pull request. + +### 8.11. Движок таблиц для чтения из Mongo {#dvizhok-tablits-dlia-chteniia-iz-mongo} + +Артемий Бобровский, ВШЭ +Есть pull request. + +### 8.12. Пропуск столбцов в форматах Parquet, ORC {#propusk-stolbtsov-v-formatakh-parquet-orc} + +Артемий Бобровский, ВШЭ или другой человек. + +### 8.13. Поддержка массивов в Parquet, ORC {#podderzhka-massivov-v-parquet-orc} + +Артемий Бобровский, ВШЭ + +### 8.14. Запись данных в ORC {#zapis-dannykh-v-orc} + +Возможно, Андрей Коняев, ArenaData (зависит от желания). + +### 8.15. Запись данных в CapNProto {#zapis-dannykh-v-capnproto} + +### 8.16. + Поддержка формата Avro {#podderzhka-formata-avro} + +Andrew Onyshchuk. Есть pull request. Q1. Сделано. + +Формат Apache Avro является компактным структурированным построчным бинарным форматом данных с внешней схемой. Этот формат часто используется совместно с Kafka и поддержка его в качестве одного из форматов ввода-вывода в ClickHouse является востребованной пользователями. + +### 8.16.1. + Поддержка формата JSONEachRow, засунутого в массив {#podderzhka-formata-jsoneachrow-zasunutogo-v-massiv} + +Павел Круглов, ВШЭ и Яндекс. Есть pull request. + +### 8.16.2. - Поддержка формата Thrift {#podderzhka-formata-thrift} + +Павел Круглов, ВШЭ и Яндекс. Задача отменена. + +### 8.16.3. + Поддержка формата MsgPack {#podderzhka-formata-msgpack} + +Павел Круглов, ВШЭ и Яндекс. +Задача взята в работу. + +Upd. Почти готово - есть лишь небольшой технический долг. + +### 8.16.4. + Формат Regexp {#format-regexp} + +Павел Круглов, ВШЭ и Яндекс. +Есть pull request. Готово. + +### 8.17. ClickHouse как MySQL реплика {#clickhouse-kak-mysql-replika} + +Ильяс Адюгамов, ВШЭ. +Upd. Задачу внезапно почти сделал другой человек. + +Реализовать возможность подписаться на row-based репликацию MySQL и сохранять полученные данные в CollapsingMergeTree или ReplacingMergeTree таблицы. Сторонние решения для этой задачи уже существуют: https://www.altinity.com/blog/2018/6/30/realtime-mysql-clickhouse-replication-in-practice Также существует стороннее решение для PostgreSQL: https://github.com/mkabilov/pg2ch + +Встроенная в ClickHouse возможность работать в качестве реплики MySQL даст преимущества для дальнейшего развития. + +### 8.18. + ClickHouse как Federated MySQL {#clickhouse-kak-federated-mysql} + +Maxim Fedotov, Wargaming + Yuri Baranov, Яндекс. + +### 8.19. Интеграция с RabbitMQ {#integratsiia-s-rabbitmq} + +Ксения Сумарокова, ВШЭ. + +В ClickHouse часто используется потоковый импорт данных из распределённой очереди. Наиболее популярно использование совместно с Kafka. Эта возможность уже есть. + +Следующей по востребованности является система очередей RabbitMQ. Её поддержка в ClickHouse отсутствует. + +Есть pull request в процессе разработки. + +### 8.20. Интеграция с SQS {#integratsiia-s-sqs} + +Низкий приоритет. + +### 8.21. Поддержка произвольного количества языков для имён регионов {#podderzhka-proizvolnogo-kolichestva-iazykov-dlia-imion-regionov} + +Нужно для БК. Декабрь 2019. +В декабре для БК сделан минимальный вариант этой задачи. +Максимальный вариант, вроде, никому не нужен. +Upd. Всё ещё кажется, что задача не нужна. + +### 8.22. Поддержка синтаксиса для переменных в стиле MySQL {#podderzhka-sintaksisa-dlia-peremennykh-v-stile-mysql} + +При парсинге запроса преобразовывать синтаксис вида `@@version_full` в вызов функции `getGlobalVariable('version_full')`. Поддержать популярные MySQL переменные. Может быть поможет Юрий Баранов, если будет энтузиазм. + +Upd. Юрий Баранов работает в Google, там запрещено разрабатывать ClickHouse. + +### 8.23. Подписка для импорта обновляемых и ротируемых логов в ФС {#podpiska-dlia-importa-obnovliaemykh-i-rotiruemykh-logov-v-fs} + +Желательно 2.15. + + +## 9. Безопасность {#bezopasnost} + +### 9.1. + Ограничение на хосты в запросах ко внешним системам {#ogranichenie-na-khosty-v-zaprosakh-ko-vneshnim-sistemam} + +Михаил Коротов. + +### 9.2. Преднастроенные именованные соединения к внешним БД {#prednastroennye-imenovannye-soedineniia-k-vneshnim-bd} + +Валерий Батурин, ВШЭ. + +ClickHouse предоставляет возможность обратиться к внешней базе данных из языка запросов. Это реализовано в виде табличных функций. В параметрах к табличной функции указывается адрес удалённой базы данных (хост, порт), а также аутентификационные данные (имя пользователя, пароль). Аутентификационные данные указываются в запросе в открытом виде и, таким образом, попадают в историю запросов и в логи, что компрометирует безопасность системы. + +Вместо этого предлагается описывать необходимые данные в конфигурационном файле сервера или в отдельном сервисе и ссылаться на них по именам. + +### 9.3. + Поддержка TLS для ZooKeeper {#podderzhka-tls-dlia-zookeeper} + +[\#10174](https://github.com/ClickHouse/ClickHouse/issues/10174) + +Есть pull request. + + +## 10. Внешние словари {#vneshnie-slovari} + +### 10.1. + Исправление зависания в библиотеке доступа к YT {#ispravlenie-zavisaniia-v-biblioteke-dostupa-k-yt} + +Библиотека для доступа к YT не переживает учения. +Нужно для БК и Метрики. Поиск причин - [Александр Сапин](https://github.com/alesapin). Дальшейшее исправление возможно на стороне YT. + +Цитата: «Оказывается для YT-клиента зависания на несколько минут это нормально. Убрал внутренние ретраи, снизил таймауты. Однозначно станет лучше». + +### 10.2. + Исправление SIGILL в библиотеке доступа к YT {#ispravlenie-sigill-v-biblioteke-dostupa-k-yt} + +Код YT использует SIGILL вместо abort. Это, опять же, происходит при учениях. +Нужно для БК и Метрики. Поиск причин - [Александр Сапин](https://github.com/alesapin). Дальшейшее исправление возможно на стороне YT. + +Upd. Одну причину устранили, но ещё что-то неизвестное осталось. +Upd. Нас заставляют переписать эту библиотеку с одного API на другое, так как старое внезапно устарело. Кажется, что переписывание случайно исправит все проблемы. +Upd. Ура, нашли причину и исправили. + +### 10.3. Возможность чтения данных из статических таблиц в YT словарях {#vozmozhnost-chteniia-dannykh-iz-staticheskikh-tablits-v-yt-slovariakh} + +Нужно для БК и Метрики. + +### 10.4. Словарь из YDB (KikiMR) {#slovar-iz-ydb-kikimr} + +Нужно для Метрики, а делать будет таинственный незнакомец из команды KikiMR (под вопросом). Таинственный незнакомец не подтверждает, что он будет делать эту задачу. + +### 10.5. Закрытие соединений и уменьшение числа соединений для MySQL и ODBC {#zakrytie-soedinenii-i-umenshenie-chisla-soedinenii-dlia-mysql-i-odbc} + +Нужно для Метрики. + +Для MySQL сделал Clément Rodriguez. + +### 10.6. Словари из Cassandra и Couchbase {#slovari-iz-cassandra-i-couchbase} + +### 10.7. Поддержка Nullable в словарях {#podderzhka-nullable-v-slovariakh} + +Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. + +### 10.8. Поддержка массивов в словарях {#podderzhka-massivov-v-slovariakh} + +Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. + +### 10.9. - Уменьшение блокировок для cache словарей за счёт одновременных запросов одного и того же {#umenshenie-blokirovok-dlia-cache-slovarei-za-schiot-odnovremennykh-zaprosov-odnogo-i-togo-zhe} + +Заменено в пользу 10.10, 10.11. + +### 10.10. + Возможность использования старых значений из cache словаря пока они перезапрашиваются {#vozmozhnost-ispolzovaniia-starykh-znachenii-iz-cache-slovaria-poka-oni-perezaprashivaiutsia} + +Никита Михайлов. Q1. Нужно для БК и Метрики. + +### 10.11. + Возможность исключительно асинхронных запросов в cache словарях {#vozmozhnost-iskliuchitelno-asinkhronnykh-zaprosov-v-cache-slovariakh} + +Никита Михайлов. Q1. Нужно для БК и Метрики. Требует 10.10. + +### 10.12. Layout direct для словарей {#layout-direct-dlia-slovarei} + +Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. +Приступили к этой задаче. +Готов direct, есть pull request complex_key_direct. + +### 10.13. Использование Join как generic layout для словарей {#ispolzovanie-join-kak-generic-layout-dlia-slovarei} + +Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. + +### 10.14. Поддержка всех типов в функции transform {#podderzhka-vsekh-tipov-v-funktsii-transform} + +### 10.15. Использование словарей как специализированного layout для Join {#ispolzovanie-slovarei-kak-spetsializirovannogo-layout-dlia-join} + +### 10.16. Словари на локальном SSD {#slovari-na-lokalnom-ssd} + +Никита Васильев, ВШЭ и Яндекс. Есть pull request. + +Реализовать в ClickHouse специализированный движок таблиц, подходящий для быстрых key-value запросов и оптимизированный для расположения данных на SSD. Это может быть: реализация на основе RocksDB; сериализованные RowBinary данные с индексом в оперативке; секретная очень эффективная структура данных, о которой я расскажу. + +Использовать эту структуру данных как отдельный вид словарей, как источник для cache словарей или как дополнительный уровень кэширования для cache словарей. + +Upd. Задача в финальной стадии готовности. + +### 10.17. Локальный дамп состояния словаря для быстрого старта сервера {#lokalnyi-damp-sostoianiia-slovaria-dlia-bystrogo-starta-servera} + +### 10.18. Таблица Join или словарь на удалённом сервере как key-value БД для cache словаря {#tablitsa-join-ili-slovar-na-udalionnom-servere-kak-key-value-bd-dlia-cache-slovaria} + +### 10.19. Возможность зарегистрировать некоторые функции, использующие словари, под пользовательскими именами {#vozmozhnost-zaregistrirovat-nekotorye-funktsii-ispolzuiushchie-slovari-pod-polzovatelskimi-imenami} + + +## 11. Интерфейсы {#interfeisy} + +### 11.1. Вставка состояний агрегатных функций в виде кортежа аргументов или массива кортежей аргументов {#vstavka-sostoianii-agregatnykh-funktsii-v-vide-kortezha-argumentov-ili-massiva-kortezhei-argumentov} + +### 11.2. Возможность использовать движок JDBC из коробки {#vozmozhnost-ispolzovat-dvizhok-jdbc-iz-korobki} + +Нужно разобраться, как упаковывать Java в статический бинарник, возможно AppImage. Или предоставить максимально простую инструкцию по установке jdbc-bridge. Может быть будет заинтересован Александр Крашенинников, Badoo, так как он разработал jdbc-bridge. + +Upd. Александр Крашенинников перешёл в другую компанию и больше не занимается этим. + +### 11.3. + Интеграционные тесты ODBC драйвера путём подключения ClickHouse к самому себе через ODBC {#integratsionnye-testy-odbc-draivera-putiom-podkliucheniia-clickhouse-k-samomu-sebe-cherez-odbc} + +Михаил Филимонов, Altinity. Готово. + +### 11.4. Исправление упячек с типами Date и Decimal в clickhouse-cpp {#ispravlenie-upiachek-s-tipami-date-i-decimal-v-clickhouse-cpp} + +### 11.5. Поддержка TLS в clickhouse-cpp {#podderzhka-tls-v-clickhouse-cpp} + +А знаете ли вы, что библиотеку clickhouse-cpp разрабатывал один хороший человек в свободное время? + +### 11.6. Интеграционные тесты clickhouse-cpp {#integratsionnye-testy-clickhouse-cpp} + +### 11.7. Интерактивный режим работы программы clickhouse-local {#interaktivnyi-rezhim-raboty-programmy-clickhouse-local} + +### 11.8. Поддержка протокола PostgreSQL {#podderzhka-protokola-postgresql} + +Элбакян Мовсес Андраникович, ВШЭ. + +В ClickHouse в прошлом году добавили поддержку wire-протокола MySQL. PostgreSQL, так же как MySQL, использует несложный протокол общения между клиентом и сервером, но свой собственный. Поддержка этого протокола является востребованной и откроет новые возможности для ClickHouse. + +Задача в процессе разработки. +Задача в финальной стадии разработки. + +### 11.9. + Доработки ODBC драйвера {#dorabotki-odbc-draivera} + +Денис Глазачев, Altinity. Хороший прогресс по этой задаче. + +### 11.10. + Преднастроенные HTTP handlers для запросов {#prednastroennye-http-handlers-dlia-zaprosov} + +zhang2014, есть pull request. + +Возможность описать в конфигурационном файле handler (путь в URL) для HTTP запросов к серверу, которому соответствует некоторый параметризованный запрос. Пользователь может вызвать этот обработчик и не должен передавать SQL запрос. + + +## 12. Управление пользователями и доступом {#upravlenie-polzovateliami-i-dostupom} + +### 12.1. + Role Based Access Control {#role-based-access-control} + +[Виталий Баранов](https://github.com/vitlibar). Финальная стадия разработки, рабочая версия в начале апреля 2019. +Q2. Сейчас сделаны все интерфейсы в коде и запросы, но не сделаны варианты хранения прав кроме прототипа. +Upd. Сделано хранение прав. До готового к использованию состояния осталось несколько доработок. + +### 12.2. + Управление пользователями и правами доступа с помощью SQL запросов {#upravlenie-polzovateliami-i-pravami-dostupa-s-pomoshchiu-sql-zaprosov} + +[Виталий Баранов](https://github.com/vitlibar). Финальная стадия разработки, рабочая версия в декабре 2019. +Q1. Сделано управление правами полностью, но не реализовано их хранение, см. 12.1. + +### 12.3. Подключение справочника пользователей и прав доступа из LDAP {#podkliuchenie-spravochnika-polzovatelei-i-prav-dostupa-iz-ldap} + +Аутентификация через LDAP - Денис Глазачев. +[Виталий Баранов](https://github.com/vitlibar) и Денис Глазачев, Altinity. Требует 12.1. +Q2. + +### 12.4. Подключение IDM системы Яндекса как справочника пользователей и прав доступа {#podkliuchenie-idm-sistemy-iandeksa-kak-spravochnika-polzovatelei-i-prav-dostupa} + +Пока низкий приоритет. Нужно для Метрики. Требует 12.3. + +### 12.5. Pluggable аутентификация с помощью Kerberos (возможно, подключение GSASL) {#pluggable-autentifikatsiia-s-pomoshchiu-kerberos-vozmozhno-podkliuchenie-gsasl} + +[Виталий Баранов](https://github.com/vitlibar) и Денис Глазачев, Altinity. Требует 12.1. + +### 12.6. + Информация о пользователях и квотах в системной таблице {#informatsiia-o-polzovateliakh-i-kvotakh-v-sistemnoi-tablitse} + +[Виталий Баранов](https://github.com/vitlibar). Требует 12.1. +Есть pull request. Q2. Готово. + + +## 13. Разделение ресурсов, multi-tenancy {#razdelenie-resursov-multi-tenancy} + +### 13.1. Overcommit запросов по памяти и вытеснение {#overcommit-zaprosov-po-pamiati-i-vytesnenie} + +Требует 2.1. Способ реализации обсуждается. + +### 13.2. Общий конвейер выполнения на сервер {#obshchii-konveier-vypolneniia-na-server} + +Требует 2.1. [Николай Кочетов](https://github.com/KochetovNicolai). + +### 13.3. Пулы ресурсов {#puly-resursov} + +Требует 13.2 или сможем сделать более неудобную реализацию раньше. +Обсуждается вариант неудобной реализации. Пока средний приоритет, целимся на Q1/Q2. +Вариант реализации выбрал Александр Казаков. +Upd. Не уследили, и задачу стали обсуждать менеджеры. +Upd. Задачу смотрит Александр Казаков. + + +## 14. Диалект SQL {#dialekt-sql} + +### 14.1. Исправление семантики CAST для Nullable {#ispravlenie-semantiki-cast-dlia-nullable} + +Нужно для DataLens. А также для внедрения в BI инструмент Looker. +Павел Потёмкин, ВШЭ. + +### 14.2. Поддержка WITH для подзапросов {#podderzhka-with-dlia-podzaprosov} + +### 14.3. Поддержка подстановок для множеств в правой части IN {#podderzhka-podstanovok-dlia-mnozhestv-v-pravoi-chasti-in} + +### 14.4. Поддержка подстановок для идентификаторов (имён) в SQL запросе {#podderzhka-podstanovok-dlia-identifikatorov-imion-v-sql-zaprose} + +zhang2014 + +### 14.5. + Поддержка задания множества как массива в правой части секции IN {#podderzhka-zadaniia-mnozhestva-kak-massiva-v-pravoi-chasti-sektsii-in} + +Василий Немков, Altinity, делал эту задачу, но забросил её в пользу других задач. +В результате, сейчас доделывает Антон Попов. + +### 14.6. Глобальный scope для WITH {#globalnyi-scope-dlia-with} + +Павел Потёмкин, ВШЭ. + +### 14.7. Nullable для WITH ROLLUP, WITH CUBE, WITH TOTALS {#nullable-dlia-with-rollup-with-cube-with-totals} + +Павел Потёмкин, ВШЭ. + +Простая задача. + +### 14.8. Модификаторы DISTINCT, ORDER BY для агрегатных функций {#modifikatory-distinct-order-by-dlia-agregatnykh-funktsii} + +В ClickHouse поддерживается вычисление COUNT(DISTINCT x). Предлагается добавить возможность использования модификатора DISTINCT для всех агрегатных функций. Например, AVG(DISTINCT x) - вычислить среднее значение для всех различных значений x. Под вопросом вариант, в котором фильтрация уникальных значений выполняется по одному выражению, а агрегация по другому. + +Результат некоторых агрегатных функций зависит от порядка данных. Предлагается реализовать модификатор ORDER BY, задающий порядок явно. Пример: groupArray(x ORDER BY y, z). + +Upd. Есть pull request на DISTINCT. + +### 14.9. Поддержка запроса EXPLAIN {#podderzhka-zaprosa-explain} + +Требует 2.1. [Николай Кочетов](https://github.com/KochetovNicolai). + +### 14.10. arrayReduce как функция высшего порядка {#arrayreduce-kak-funktsiia-vysshego-poriadka} + +### 14.11. Функции для grouping sets {#funktsii-dlia-grouping-sets} + +### 14.12. Функции обработки временных рядов {#funktsii-obrabotki-vremennykh-riadov} + +Сложная задача, так как вводит новый класс функций и требует его обработку в оптимизаторе запросов. + +В time-series СУБД нужны функции, которые зависят от последовательности значений. Или даже от последовательности значений и их меток времени. Примеры: moving average, exponential smoothing, derivative, Holt-Winters forecast. Вычисление таких функций поддерживается в ClickHouse лишь частично. Так, ClickHouse поддерживает тип данных «массив» и позволяет реализовать эти функции как функции, принимающие массивы. Но гораздо удобнее для пользователя было бы иметь возможность применить такие функции к таблице (промежуточному результату запроса после сортировки). + +Это требует введение нового класса функций (помимо обычных и агрегатных функций) - такие функции будут иметь в коде ClickHouse свой собственный интерфейс, и их вычисление придётся отдельно учитывать в конвейере выполнения запросов. Для примера, вычисление обычных функций тривиально распараллеливается по процессорным ядрам и по серверам; вычисление агрегатных функций распараллеливается с некоторыми особенностями (работа с промежуточными состояниями вычислений, операция merge); а для функций по обработке временных рядов этот вопрос остаётся открытым - возможно, их придётся вычислять на одном сервере и в одном потоке. + +### 14.13. Применимость функций высшего порядка для кортежей и Nested {#primenimost-funktsii-vysshego-poriadka-dlia-kortezhei-i-nested} + +### 14.14. Неявные преобразования типов констант {#neiavnye-preobrazovaniia-tipov-konstant} + +Требует 2.12. + +### 14.15. Неявные преобразования типов под настройкой {#neiavnye-preobrazovaniia-tipov-pod-nastroikoi} + +Требует 2.12. Для внедрения в BI инструмент Looker. + +### 14.16. Синонимы для функций из MySQL {#sinonimy-dlia-funktsii-iz-mysql} + +### 14.17. + Ввести понятие stateful функций {#vvesti-poniatie-stateful-funktsii} + +zhang2014. +Для runningDifference, neighbour - их учёт в оптимизаторе запросов. +В интерфейсе уже сделано. Надо проверить, что учитывается в нужных местах (например, что работает predicate pushdown сквозь ORDER BY, если таких функций нет). + +### 14.18. UNION DISTINCT и возможность включить его по-умолчанию {#union-distinct-i-vozmozhnost-vkliuchit-ego-po-umolchaniiu} + +Павел Потёмкин, ВШЭ. +Для BI систем. + +### 14.19. Совместимость парсера типов данных с SQL {#sovmestimost-parsera-tipov-dannykh-s-sql} + +Павел Потёмкин, ВШЭ. +Для BI систем. + +### 14.20. Позиционные аргументы для GROUP BY и ORDER BY {#pozitsionnye-argumenty-dlia-group-by-i-order-by} + +Павел Потёмкин, ВШЭ. +Тривиально и используется многими системами, но не входит в стандарт SQL. + +### 14.21. Приведение типов для IN (подзапрос) и для JOIN {#privedenie-tipov-dlia-in-podzapros-i-dlia-join} + + +## 15. Улучшение поддержки JOIN {#uluchshenie-podderzhki-join} + +### 15.1. + Доведение merge JOIN до продакшена {#dovedenie-merge-join-do-prodakshena} + +Артём Зуйков. Сейчас merge JOIN включается вручную опцией и всегда замедляет запросы. Хотим, чтобы он замедлял запросы только когда это неизбежно. +Кстати, смысл merge JOIN появляется только совместно с 15.2 и 15.3. +Q1. Сделали адаптивный вариант, но вроде он что-то всё-ещё замедляет. +Задача сделана, но всё работает слишком медленно. + +### 15.1.1. Алгоритм two-level merge JOIN {#algoritm-two-level-merge-join} + +Александр Кузьменков. В очереди. + +### 15.1.2. Тестирование реализации JOIN в Greenplum {#testirovanie-realizatsii-join-v-greenplum} + +В очереди. + +### 15.2. Прокидывание условий в OUTER JOIN {#prokidyvanie-uslovii-v-outer-join} + +Возможно, Артём Зуйков, но задача ещё не продумана до конца. Возможно, требует 2.1. + +### 15.3. Логический вывод для цепочек вида ON t1.x = t2.y WHERE t1.x = 10 {#logicheskii-vyvod-dlia-tsepochek-vida-on-t1-x-t2-y-where-t1-x-10} + +Возможно, Артём Зуйков. Для полноценной работы 15.2. + +### 15.4. Distributed JOIN с помощью перераспределения данных {#distributed-join-s-pomoshchiu-pereraspredeleniia-dannykh} + +Артём Зуйков. + +### 15.5. Использование ключа таблицы для оптимизации merge JOIN {#ispolzovanie-kliucha-tablitsy-dlia-optimizatsii-merge-join} + +### 15.6. + SEMI и ANTI JOIN {#semi-i-anti-join} + +Артём Зуйков. + + +## 16. Типы данных и функции {#tipy-dannykh-i-funktsii} + +### 16.1. + DateTime64 {#datetime64} + +Василий Немков, Altinity, декабрь 2019. + +### 16.2. Тип данных для JSON {#tip-dannykh-dlia-json} + +zhang2014 + +Есть PR, в процессе ревью. + +### 16.3. Поддержка неконстантных аргументов с регулярными выражениями в функциях {#podderzhka-nekonstantnykh-argumentov-s-reguliarnymi-vyrazheniiami-v-funktsiiakh} + +Данила Кутенин, но только после секретного изменения в работе. +Upd. Секретного изменения в работе не будет, задачу будет делать другой человек. + +### 16.4. Функция rowNumberForKey {#funktsiia-rownumberforkey} + +### 16.5. Функции для XML и HTML escape {#funktsii-dlia-xml-i-html-escape} + +### 16.6. Функции нормализации и хэширования SQL запросов {#funktsii-normalizatsii-i-kheshirovaniia-sql-zaprosov} + + +## 17. Работа с географическими данными {#rabota-s-geograficheskimi-dannymi} + +### 17.1. Гео-словари для определения региона по координатам {#geo-slovari-dlia-opredeleniia-regiona-po-koordinatam} + +[Андрей Чулков](https://github.com/achulkov2), Антон Кваша, Артур Петуховский, ВШЭ. +Будет основано на коде от Арслана Урташева. + +ClickHouse не является geospatial СУБД. Тем не менее, в ClickHouse есть несколько функций для таких задач. Например, функция `pointInPolygon` позволяет быстро проверить попадание точек в полигон на плоскости. При этом, полигон задаётся в явном виде и должен быть константным для вызова функции (то есть - проверяется принадлежность многих точек одному полигону). Эта функциональность нужна, например, для рекламного таргетинга мобильных устройств по координатам. + +Похожая, но более сложная задача, которую ClickHouse пока не умеет решать - определение полигона среди множества полигонов, в которые попадают точки. Для примера: определение района города по географическим координатам. Для решения этой задачи нужно будет реализовать поддержку словарей с полигонами, в которых данные проиндексированы для быстрого поиска. + +Upd. Андрей сделал прототип интерфейса и реализацию-заглушку внутри него. +Upd. Андрей сделал прототип более оптимальной структуры данных. +Upd. Есть обнадёживающие результаты. + +### 17.2. GIS типы данных и операции {#gis-tipy-dannykh-i-operatsii} + +Алексей Коряков, Алексей Илюхов, ВШЭ, Яндекс.Карты. + +Реализовать в ClickHouse типы данных для задач обработки геоинформационных данных: Point, Line, MultiLine, Polygon и операции над ними - проверка вхождения, пересечения. Вариантом минимум будет реализация этих операций в евклидовой системе координат. Дополнительно - на сфере и WGS84. + +### 17.3. + Ускорение greatCircleDistance {#uskorenie-greatcircledistance} + +[Ольга Хвостикова](https://github.com/stavrolia), основано на коде Андрея Аксёнова, получено разрешение на использование кода. + +### 17.4. Ускорение geohash с помощью библиотеки из Аркадии {#uskorenie-geohash-s-pomoshchiu-biblioteki-iz-arkadii} + +Получено одобрение от руководства. + +### 17.5. + Проверки в функции pointInPolygon {#proverki-v-funktsii-pointinpolygon} + +Сейчас функция тихо не работает в случае полигонов с самопересечениями, надо кидать исключение. + + +## 18. Машинное обучение и статистика {#mashinnoe-obuchenie-i-statistika} + +### 18.1. Инкрементальная кластеризация данных {#inkrementalnaia-klasterizatsiia-dannykh} + +Александр Кожихов, Максим Кузнецов. Обнаружена фундаментальная проблема в реализации, доделывает предположительно [Николай Кочетов](https://github.com/KochetovNicolai). Он может делегировать задачу кому угодно. + +Исправление фундаментальной проблемы - есть PR. + +### 18.2. Агрегатные функции для статистических тестов {#agregatnye-funktsii-dlia-statisticheskikh-testov} + +Артём Цыганов, Руденский Константин Игоревич, Семёнов Денис, ВШЭ. + +Предлагается реализовать в ClickHouse статистические тесты (Analysis of Variance, тесты нормальности распределения и т. п.) в виде агрегатных функций. Пример: `welchTTest(value, sample_idx)`. + +Сделали прототип одного теста, есть pull request. + +### 18.3. Инфраструктура для тренировки моделей в ClickHouse {#infrastruktura-dlia-trenirovki-modelei-v-clickhouse} + +В очереди. + + +## 19. Улучшение работы кластера {#uluchshenie-raboty-klastera} + +### 19.1. Параллельные кворумные вставки без линеаризуемости {#parallelnye-kvorumnye-vstavki-bez-linearizuemosti} + +Александра Латышева, ВШЭ и Яндекс. + +Репликация данных в ClickHouse по-умолчанию является асинхронной без выделенного мастера. Это значит, что клиент, осуществляющий вставку данных, получает успешный ответ после того, как данные попали на один сервер; репликация данных по остальным серверам осуществляется в другой момент времени. Это ненадёжно, потому что допускает потерю только что вставленных данных при потере лишь одного сервера. + +Для решения этой проблемы, в ClickHouse есть возможность включить «кворумную» вставку. Это значит, что клиент, осуществляющий вставку данных, получает успешный ответ после того, как данные попали на несколько (кворум) серверов. Обеспечивается линеаризуемость: клиент, получает успешный ответ после того, как данные попали на несколько реплик, *которые содержат все предыдущие данные, вставленные с кворумом* (такие реплики можно называть «синхронными»), и при запросе SELECT можно выставить настройку, разрешающую только чтение с синхронных реплик. + +Если бы свойства линеаризуемости не было, то для трёх серверов A, B, C, значения кворума = 2, и для трёх вставок данных 1, 2, 3, возможна ситуация, что первая вставка прошла на серверы A и B, вторая прошла на серверы B и C, а третья - на серверы A и C, и теперь ни один из серверов не содержит полный набор данных 1, 2, 3. + +Как ни странно, такое свойство не нужно большинству пользователей. Оно запрещает параллельно выполняющиеся вставки. А пользователи хотят вставлять данные надёжно (на более чем одну реплику), но не важно, в каком порядке. Предлагается сделать опцию, которая отключает линеаризуемость. + +Иногда пользователь хочет реализовать кворумную вставку вручную: просто соединиться с несколькими репликами и вставть на них одинаковые данные (чтобы обеспечить надёжную вставку, не ориентируясь на то, как работает механизм репликации). Сейчас ожидания пользователя не оправдываются. В ClickHouse есть механизм дедупликации для обеспечения идемпотентности вставок. Вторая вставка с такими же данными (пусть даже на другую реплику) будет проигнорирована. Надо сделать так, чтобы вместо этого, вставка одинаковых данных на другую реплику, имела такой же эффект, как если бы эти данные были получены с помощью механизма репликации. + +### 19.2. Подключение Etcd или Consul как альтернативы ZooKeeper {#podkliuchenie-etcd-ili-consul-kak-alternativy-zookeeper} + +Алексей Лёвушкин, ВШЭ и Яндекс. + +Для координации реплик в ClickHouse используется ZooKeeper. Многие пользователи ClickHouse хотели бы иметь возможность использовать для координации некоторые другие системы вместо ZooKeeper. Рассматриваемыми вариантами таких систем являются Etcd, Consul, FoundationDB. Это весьма проблематично, так как эти системы существенно отличаются по интерфейсам и возможностям. Тем не менее, для того, чтобы эта задача стала возможной, в ClickHouse обобщён интерфейс взаимодействия с ZooKeeper, и теперь на его место можно подставлять другие реализации. + +В прошлом году, Алексей добавил модельную реализацию (mock) интерфейса ZooKeeper для тестирования. Сейчас предлагается сделать реализацию поверх Etcd, а также расширить возможности тестовой реализации. + +Upd. Алексей сделал какой-то вариант, но борется с тем, что ничего не работает. +Upd. Есть pull request на начальной стадии. + +### 19.3. Подключение YT Cypress или YDB как альтернативы ZooKeeper {#podkliuchenie-yt-cypress-ili-ydb-kak-alternativy-zookeeper} + +Hold. Полезно для заказчиков внутри Яндекса, но есть риски. Эту задачу никто не будет делать. + +### 19.4. internal\_replication = ‘auto’ {#internal-replication-auto} + +### 19.5. Реплицируемые базы данных {#replitsiruemye-bazy-dannykh} + +В очереди, возможно Валерий Батурин, ВШЭ. + +Репликация в ClickHouse работает на уровне отдельных таблиц. Это является очень гибким решением: на одном сервере одна из таблиц может быть не реплицирована, другая иметь двухкратную репликацию, а третья - реплицирована по всем серверам. Но если все таблицы в базе данных реплицированы одинаковым образом. то это затрудняет управление кластером. Например, при восстановлени сервера, требуется отдельно создавать реплику для каждой таблицы. + +Предлагается реализовать «движок баз данных», который осуществляет репликацию метаданных (множество имеющихся таблиц и лог DDL операций над ними: CREATE, DROP, RENAME, ALTER). Пользователь сможет создать реплицируемую базу данных; при её создании или восстановлении на другом сервере, все реплицируемые таблицы будут созданы автоматически. + +### 19.6. Одновременный выбор кусков для слияния многими репликами, отказ от leader election в ZK {#odnovremennyi-vybor-kuskov-dlia-sliianiia-mnogimi-replikami-otkaz-ot-leader-election-v-zk} + +Обсуждается. Возможно, будет делать Александр Сапин. + +### 19.7. Возможность записи данных при недоступности ZK и отказ от линейного порядка кусков в большинстве случаев {#vozmozhnost-zapisi-dannykh-pri-nedostupnosti-zk-i-otkaz-ot-lineinogo-poriadka-kuskov-v-bolshinstve-sluchaev} + +### 19.8. Отказ от хранения в ZK множества кусков для каждой реплики отдельно {#otkaz-ot-khraneniia-v-zk-mnozhestva-kuskov-dlia-kazhdoi-repliki-otdelno} + +### 19.9. Отказ от хранения в ZK лога вставок и мержей. Обмен данными о кусках напрямую {#otkaz-ot-khraneniia-v-zk-loga-vstavok-i-merzhei-obmen-dannymi-o-kuskakh-napriamuiu} + +Три задачи выше обсуждаются, есть варианты. + +### 19.10. Облачные таблицы {#oblachnye-tablitsy} + +Требует 1.6, 19.1, 19.6, 19.7, 19.8, 19.9. + +## 20. Мутации данных {#mutatsii-dannykh} + +Пока все задачи по точечным UPDATE/DELETE имеют низкий приоритет, но ожидаем взять в работу в середине 2020. + +### 20.1. Поддержка DELETE путём запоминания множества затронутых кусков и ключей {#podderzhka-delete-putiom-zapominaniia-mnozhestva-zatronutykh-kuskov-i-kliuchei} + +### 20.2. Поддержка DELETE путём преобразования множества ключей в множество row\_numbers на реплике, столбца флагов и индекса по диапазонам {#podderzhka-delete-putiom-preobrazovaniia-mnozhestva-kliuchei-v-mnozhestvo-row-numbers-na-replike-stolbtsa-flagov-i-indeksa-po-diapazonam} + +### 20.3. Поддержка ленивых DELETE путём запоминания выражений и преобразования к множеству ключей в фоне {#podderzhka-lenivykh-delete-putiom-zapominaniia-vyrazhenii-i-preobrazovaniia-k-mnozhestvu-kliuchei-v-fone} + +### 20.4. Поддержка UPDATE с помощью преобразования в DELETE и вставок {#podderzhka-update-s-pomoshchiu-preobrazovaniia-v-delete-i-vstavok} + + +## 21. Оптимизации производительности {#optimizatsii-proizvoditelnosti} + +### 21.1. + Параллельный парсинг форматов {#parallelnyi-parsing-formatov} + +Начинал Олег Ершов, доделывает Никита Михайлов, помогает [Александр Кузьменков](https://github.com/akuzm). Готово. + +### 21.1.1. Избавление от лишнего копирования при параллельном парсинге форматов, если возможен mmap файла целиком {#izbavlenie-ot-lishnego-kopirovaniia-pri-parallelnom-parsinge-formatov-esli-vozmozhen-mmap-faila-tselikom} + +### 21.2. Параллельное форматирование форматов {#parallelnoe-formatirovanie-formatov} + +После 21.1, предположительно Никита Михайлов. Задача сильно проще чем 21.1. + +### 21.3. + Исправление низкой производительности анализа индекса в случае большого множества в секции IN {#ispravlenie-nizkoi-proizvoditelnosti-analiza-indeksa-v-sluchae-bolshogo-mnozhestva-v-sektsii-in} + +Нужно всем (Zen, БК, DataLens, TestEnv…). Антон Попов, Q1/Q2. + +Upd. Антон делает эту задачу. Большая часть уже реализована. + +### 21.4. Использование ORDER BY ключа для оптимизации GROUP BY и DISTINCT {#ispolzovanie-order-by-kliucha-dlia-optimizatsii-group-by-i-distinct} + +Дмитрий Рубашкин, ВШЭ. Помогает Антон Попов. + +Если таблица имеет ключ сортировки, то возможно эффективное чтение упорядоченных данных. Если запрос содержит операцию GROUP BY, содержащую по крайней мере префикс от ключа сортировки таблицы, либо инъективные функции от него, то возможно более эффективное выполнение GROUP BY: промежуточный результат агрегации финализируется и отправляется клиенту как только в потоке данных при чтении из таблицы встретился следующий ключ. + +Аналогичную оптимизацию следует реализовать для DISTINCT и LIMIT BY. + +В прошлом году, аналогичное решение сделали для операции ORDER BY. + +Upd. Есть pull request для GROUP BY. Приличные результаты. + +### 21.5. + Распараллеливание INSERT при INSERT SELECT, если это необходимо {#rasparallelivanie-insert-pri-insert-select-esli-eto-neobkhodimo} + +[Vxider](https://github.com/Vxider), ICT +Есть pull request. + +### 21.6. Уменьшение числа потоков для SELECT в случае тривиального INSERT SELECT {#umenshenie-chisla-potokov-dlia-select-v-sluchae-trivialnogo-insert-select} + +### 21.7. Кэш результатов запросов {#kesh-rezultatov-zaprosov} + +[Achimbab](https://github.com/achimbab). +Есть pull request. Но это не совсем то. + +### 21.8. Взаимная интеграция аллокатора и кэша {#vzaimnaia-integratsiia-allokatora-i-kesha} + +Михаил Кот, ВШЭ. Задача сложная и рискованная. + +Для выделения памяти, аллокаторы запрашивают её у операционной системы (`mmap`). Это возможно только для достаточно крупных кусков памяти является довольно медленной операцией. Поэтому, современные аллокаторы кэшируют крупные куски памяти в программе. При вызове free, кусок памяти, как правило, не отдаётся ОС, а остаётся для последующего переиспользования. Для выделения мелких кусков памяти, крупные куски разбиваются с помощью специальных структур данных (free-list, heap, bitmap). Для уменьшения contention в многопоточных программах, эти структуры также делаются thread-локальными. + +Часто в программе есть кэши некоторых данных. Например - кэш данных после разжатия, использующийся чтобы сэкономить на повторных запросах одних и тех же данных. При вытеснении из кэша, блок данных освобождается (`free`) и данные, бывшие в кэше, становятся недоступными для переиспользования. Но если принимать во внимание то, как работает аллокатор памяти, то оказывается, что после освобождения памяти, данные всё ещё остаются доступными в программе. И если этот кусок памяти не будет выделен аллокатором снова, его можно было бы продолжить использовать в качестве кэша. Иными словами, в программе есть domain-specific кэш, а аллокатор имеет свой кэш, и они не знают друг о друге. + +Для domain-specific кэшей (как например, кэш разжатых данных) выгодно, чтобы они использовали как можно больший объём свободной памяти. Но в этом случае, памяти может не хватить для других структур данных в программе. Если аллокатор памяти знает про кэш, то выделение памяти можно было бы делать путём вытеснения данных из кэша. + +### 21.8.1. Отдельный аллокатор для кэшей с ASLR {#otdelnyi-allokator-dlia-keshei-s-aslr} + +В прошлом году задачу пытался сделать Данила Кутенин с помощью lfalloc из Аркадии и mimalloc из Microsoft, но оба решения не были квалифицированы для использования в продакшене. Успешная реализация задачи 21.8 отменит необходимость в этой задаче, поэтому холд. + +### 21.9. Исправить push-down выражений с помощью Processors {#ispravit-push-down-vyrazhenii-s-pomoshchiu-processors} + +[Николай Кочетов](https://github.com/KochetovNicolai). Требует 2.1. + +### 21.10. + Улучшение эвристики PREWHERE {#uluchshenie-evristiki-prewhere} + +Amos Bird. + +### 21.11. Peephole оптимизации запросов {#peephole-optimizatsii-zaprosov} + +Руслан Камалов, Михаил Малафеев, Виктор Гришанин, ВШЭ + +Реализовать в ClickHouse оптимизации запросов, основанные на упрощении отдельных небольших кусков выражений (так называемые «peephole» оптимизации). Примеры: +- Замена цепочек if на multiIf. +- Удаление min/max/any-агрегатов от выражений от ключей GROUP BY. +- Вынесение арифметических операций из агрегатных функций; +- Вынесение любых функций наружу any, anyLast. +- При GROUP BY по transform или if по строкам, замена строк на Enum. + +Сделана замена цепочек if на multiIf, но внезапно оказалось, что это является не оптимизацией, а наоборот. + +### 21.12. Алгебраические оптимизации запросов {#algebraicheskie-optimizatsii-zaprosov} + +Руслан Камалов, Михаил Малафеев, Виктор Гришанин, ВШЭ + +Реализовать в ClickHouse оптимизации запросов, основанные на алгебраических свойствах функций. Примеры: +- Обращение инъективных функций в сравнениях на равенство. +- Вынесение инъективных функцию наружу uniq. +- Удаление монотонных функций из ORDER BY. +- Удаление избыточных выражений из ORDER BY. +- Удаление из GROUP BY функций от других ключей GROUP BY. +- Удаление дублирующихся DISTINCT, ORDER BY из подзапросов. + +Несколько оптимизаций есть в PR. + +### 21.13. Fusion агрегатных функций {#fusion-agregatnykh-funktsii} + +После или совместно с 21.11. + +### 21.14. Оптимизация запросов с помощью constraints {#optimizatsiia-zaprosov-s-pomoshchiu-constraints} + +Constraints позволяют задать выражение, истинность которого проверяется при вставке данных в таблицу. Предположение о том, что выражение истинно, может использоваться и для оптимизации запросов. Например, встретив в запросе точно такое же выражение, можно заменить его на константу 1. + +Если выражение содержит равенство, то встретив в запросе одну из частей равенства, её можно заменить на другую часть равенства, если это сделает проще чтение данных или вычисление выражения. Например, задан constraint: `URLDomain = domain(URL)`. Значит, выражение `domain(URL)` можно заменить на `URLDomain`. + +### 21.15. Многоступенчатое чтение данных вместо PREWHERE {#mnogostupenchatoe-chtenie-dannykh-vmesto-prewhere} + +Требует 2.1 и 21.10. + +### 21.16. Оптимизация GROUP BY с большим количеством агрегатных функций путём вычисления в два прохода {#optimizatsiia-group-by-s-bolshim-kolichestvom-agregatnykh-funktsii-putiom-vychisleniia-v-dva-prokhoda} + +Нужно для БК. + +### 21.17. Оптимизация GROUP BY при наличии ORDER BY по тем же ключам с LIMIT {#optimizatsiia-group-by-pri-nalichii-order-by-po-tem-zhe-kliucham-s-limit} + +Нужно для БК. + +### 21.18. Внутренняя параллелизация мержа больших состояний агрегатных функций {#vnutrenniaia-parallelizatsiia-merzha-bolshikh-sostoianii-agregatnykh-funktsii} + +### 21.19. Оптимизация сортировки {#optimizatsiia-sortirovki} + +Василий Морозов, Арслан Гумеров, Альберт Кидрачев, ВШЭ. +В прошлом году задачу начинал делать другой человек, но не добился достаточного прогресса. + ++ 1. Оптимизация top sort. + +В ClickHouse используется неоптимальный вариант top sort. Суть его в том, что из каждого блока достаётся top N записей, а затем, все блоки мержатся. Но доставание top N записей у каждого следующего блока бессмысленно, если мы знаем, что из них в глобальный top N войдёт меньше. Конечно нужно реализовать вариацию на тему priority queue (heap) с быстрым пропуском целых блоков, если ни одна строка не попадёт в накопленный top. + ++ 2. Рекурсивный вариант сортировки по кортежам. + +Для сортировки по кортежам используется обычная сортировка с компаратором, который в цикле по элементам кортежа делает виртуальные вызовы `IColumn::compareAt`. Это неоптимально - как из-за короткого цикла по неизвестному в compile-time количеству элементов, так и из-за виртуальных вызовов. Чтобы обойтись без виртуальных вызовов, есть метод `IColumn::getPermutation`. Он используется в случае сортировки по одному столбцу. Есть вариант, что в случае сортировки по кортежу, что-то похожее тоже можно применить… например, сделать метод `updatePermutation`, принимающий аргументы offset и limit, и допереставляющий перестановку в диапазоне значений, в которых предыдущий столбец имел равные значения. + +3. RadixSort для сортировки. + +Один наш знакомый начал делать задачу по попытке использования RadixSort для сортировки столбцов. Был сделан вариант indirect сортировки (для `getPermutation`), но не оптимизирован до конца - есть лишние ненужные перекладывания элементов. Для того, чтобы его оптимизировать, придётся добавить немного шаблонной магии (на последнем шаге что-то не копировать, вместо перекладывания индексов - складывать их в готовое место). Также этот человек добавил метод MSD Radix Sort для реализации radix partial sort. Но даже не проверил производительность. + +Наиболее содержательная часть задачи может состоять в применении Radix Sort для сортировки кортежей, расположенных в оперативке в виде Structure Of Arrays неизвестного в compile-time размера. Это может работать хуже, чем то, что описано в пункте 2… Но попробовать не помешает. + +4. Three-way comparison sort. + +Виртуальный метод `compareAt` возвращает -1, 0, 1. Но алгоритмы сортировки сравнениями обычно рассчитаны на `operator<` и не могут получить преимущества от three-way comparison. А можно ли написать так, чтобы преимущество было? + +5. pdq partial sort + +Хороший алгоритм сортировки сравнениями `pdqsort` не имеет варианта partial sort. Заметим, что на практике, почти все сортировки в запросах ClickHouse являются partial\_sort, так как `ORDER BY` почти всегда идёт с `LIMIT`. Кстати, Данила Кутенин уже попробовал это и показал, что в тривиальном случае преимущества нет. Но не очевидно, что нельзя сделать лучше. + +### 21.20. Использование материализованных представлений для оптимизации запросов {#ispolzovanie-materializovannykh-predstavlenii-dlia-optimizatsii-zaprosov} + +В ByteDance есть готовая реализация, но они её боятся из-за, возможно, низкого качества кода. + +### 21.21. + Чтение больших файлов с помощью mmap {#chtenie-bolshikh-failov-s-pomoshchiu-mmap} + +Сделан вариант, но достаточно топорный. Без тестирования в продакшене включать по-умолчанию нельзя. + +### 21.22. Userspace page cache {#userspace-page-cache} + +Требует 21.8. + +### 21.23. Ускорение работы с вторичными индексами {#uskorenie-raboty-s-vtorichnymi-indeksami} + +zhang2014. +Есть pull request. + + +## 22. Долги и недоделанные возможности {#dolgi-i-nedodelannye-vozmozhnosti} + +### 22.1. + Исправление неработающих таймаутов, если используется TLS {#ispravlenie-nerabotaiushchikh-taimautov-esli-ispolzuetsia-tls} + +Нужно для Яндекс.Облака. Сделал Алексей Миловидов. + +### 22.2. + Убрать возможность изменить настройки в native протоколе в случае readonly {#ubrat-vozmozhnost-izmenit-nastroiki-v-native-protokole-v-sluchae-readonly} + +N.Vartolomei. + +### 22.3. + Защита от абсурдно заданных пользователем кодеков {#zashchita-ot-absurdno-zadannykh-polzovatelem-kodekov} + +### 22.4. + Исправление оставшихся deadlocks в табличных RWLock-ах {#ispravlenie-ostavshikhsia-deadlocks-v-tablichnykh-rwlock-akh} + +Александр Казаков. Нужно для Яндекс.Метрики и Datalens. Задача постепенно тащится и исправлениями в соседних местах стала менее актуальна. +В Q1 будет сделана или отменена с учётом 1.2. и 1.3. +Upd. Добавили таймауты. + +### 22.5. + Исправление редких срабатываний TSan в stress тестах в CI {#ispravlenie-redkikh-srabatyvanii-tsan-v-stress-testakh-v-ci} + +Александр Казаков сделал эту задачу. + +### 22.6. + Изменение только DEFAULT в ALTER TABLE может поменять тип столбца {#izmenenie-tolko-default-v-alter-table-mozhet-pomeniat-tip-stolbtsa} + +Александр Сапин сделал эту задачу. + +### 22.7. + Row-Level Security не работает в случае наличия в запросе IN подзапросов {#row-level-security-ne-rabotaet-v-sluchae-nalichiia-v-zaprose-in-podzaprosov} + +Нужно для Метрики. Иван Лежанкин. + +### 22.8. + Исправить десериализацию параметров для параметризованных запросов {#ispravit-deserializatsiiu-parametrov-dlia-parametrizovannykh-zaprosov} + +Хотел исправить Василий Немков, Altinity, но есть маленькие затруднения, наверное переделает Алексей Миловидов. + +### 22.9. Разобраться с десериализацией массивов со значениями по-умолчанию в Protobuf формате в случае protobuf 3 {#razobratsia-s-deserializatsiei-massivov-so-znacheniiami-po-umolchaniiu-v-protobuf-formate-v-sluchae-protobuf-3} + +[Виталий Баранов](https://github.com/vitlibar). Возможно, это - фундаментальная проблема и следует её только документировать. +Кажется, отменяем, но пока ещё не всё ясно. + +### 22.10. + Исправление дрифта при отслеживании потребления памяти запросами {#ispravlenie-drifta-pri-otslezhivanii-potrebleniia-pamiati-zaprosami} + +Требует 6.3., но можно улучшить отдельными хаками. Нужно Метрике и БК. + +### 22.11. + Более простая ser/de настроек запросов {#bolee-prostaia-serde-nastroek-zaprosov} + +И пропуск неизвестных настроек. Важно для Метрики для упрощения апгрейда без изменения конфига. +[Виталий Баранов](https://github.com/vitlibar), готово. + +### 22.12. + Исправление низкой производительности чтения из Kafka {#ispravlenie-nizkoi-proizvoditelnosti-chteniia-iz-kafka} + +Для ClickHouse нехарактерно наличие кода, обладающего столь низкой производительностью. Практики разработки не подразумевают, что такой код должен попасть в продакшен без надлежащего тестирования производительности. + +Изначально было назначено на [Ивана Лежанкина](https://github.com/abyss7), но по неизвестной причине было не сделано в течение нескольких месяцев. +Сделал Михаил Филимонов, Altinity. + +### 22.13. + Посмотреть, почему не работают некоторые collations {#posmotret-pochemu-ne-rabotaiut-nekotorye-collations} + +Изначально было назначено на [Ивана Лежанкина](https://github.com/abyss7), но в результате сделал Александр Сапин. + +### 22.14. + Посмотреть, почему не работает StorageSet для MergeTree таблиц при некоторых условиях {#posmotret-pochemu-ne-rabotaet-storageset-dlia-mergetree-tablits-pri-nekotorykh-usloviiakh} + +Вроде бы сделал Никита Михайлов - проверить существующие issues на эту тему. + +### 22.15. Нормализация коммитов в Kafka и идемпотентности операций {#normalizatsiia-kommitov-v-kafka-i-idempotentnosti-operatsii} + +Altinity. + +### 22.16. + Исправление низкой производительности кодека DoubleDelta {#ispravlenie-nizkoi-proizvoditelnosti-kodeka-doubledelta} + +Василий Немков, Altinity - в процессе. +Можно считать, что сделано, хотя отсутствие SIMD оптимизаций для variable length кодеков - это ужасно. + +### 22.17. Консистентно работающий POPULATE для MaterializedView {#konsistentno-rabotaiushchii-populate-dlia-materializedview} + +### 22.18. Исправление заметного падения производительности форматов после добавления доменов типов {#ispravlenie-zametnogo-padeniia-proizvoditelnosti-formatov-posle-dobavleniia-domenov-tipov} + +Василий Немков, Altinity. + +### 22.19. + Одновременное использование SAMPLE и PREWHERE {#odnovremennoe-ispolzovanie-sample-i-prewhere} + +Нужно для Метрики. [Николай Кочетов](https://github.com/KochetovNicolai), ноябрь 2019. + +### 22.20. + Неправильная работа PREWHERE при некоторых условиях {#nepravilnaia-rabota-prewhere-pri-nekotorykh-usloviiakh} + +[Николай Кочетов](https://github.com/KochetovNicolai), декабрь 2019. + +### 22.21. + Неправильное поведение DateTime в районе начала unix epoch {#nepravilnoe-povedenie-datetime-v-raione-nachala-unix-epoch} + +Алексей Миловидов. + +### 22.22. Nullable в функции transform и в CASE по множеству значений {#nullable-v-funktsii-transform-i-v-case-po-mnozhestvu-znachenii} + +После 10.14. + +[\#7237](https://github.com/ClickHouse/ClickHouse/issues/7237) +[\#2655](https://github.com/ClickHouse/ClickHouse/issues/2655) + +### 22.23. Правильная обработка Nullable в функциях, которые кидают исключение на default значении: modulo, intDiv {#pravilnaia-obrabotka-nullable-v-funktsiiakh-kotorye-kidaiut-iskliuchenie-na-default-znachenii-modulo-intdiv} + +### 22.24. Излишняя фильтрация ODBC connection string {#izlishniaia-filtratsiia-odbc-connection-string} + +Нужно для Метрики. Алексей Миловидов. + +### 22.25. Избавиться от библиотеки btrie {#izbavitsia-ot-biblioteki-btrie} + +Алексей Миловидов. Низкий приоритет. + +### 22.26. Плохая производительность quantileTDigest {#plokhaia-proizvoditelnost-quantiletdigest} + +[\#2668](https://github.com/ClickHouse/ClickHouse/issues/2668) + +Алексей Миловидов или будет переназначено. + +### 22.27. Проверить несколько PR, которые были закрыты zhang2014 и sundy-li {#proverit-neskolko-pr-kotorye-byli-zakryty-zhang2014-i-sundy-li} + +Алексей Миловидов. + +### 22.28. Изучить и исправить поведение работы с Kafka при ребалансировке {#izuchit-i-ispravit-povedenie-raboty-s-kafka-pri-rebalansirovke} + +Altinity. + +### 22.29. + Уязвимость DDL для словарей executable {#uiazvimost-ddl-dlia-slovarei-executable} + +[Александр Сапин](https://github.com/alesapin) + + +## 23. Default Festival {#default-festival} + +### 23.1. + Включение minimalistic\_part\_header в ZooKeeper {#vkliuchenie-minimalistic-part-header-v-zookeeper} + +Сильно уменьшает объём данных в ZooKeeper. Уже год в продакшене в Яндекс.Метрике. +Алексей Миловидов, ноябрь 2019. + +### 23.2. Включение distributed\_aggregation\_memory\_efficient {#vkliuchenie-distributed-aggregation-memory-efficient} + +Есть риски меньшей производительности лёгких запросов, хотя производительность тяжёлых запросов всегда увеличивается. + +### 23.3. Включение min\_bytes\_to\_external\_sort и min\_bytes\_to\_external\_group\_by {#vkliuchenie-min-bytes-to-external-sort-i-min-bytes-to-external-group-by} + +Желательно 5.2. и 13.1. + +### 23.4. Включение синхронной записи в Distributed таблицы по-умолчанию {#vkliuchenie-sinkhronnoi-zapisi-v-distributed-tablitsy-po-umolchaniiu} + +Есть гипотеза, что плохо работает на очень больших кластерах. + +### 23.5. Включение compile\_expressions {#vkliuchenie-compile-expressions} + +Требует 7.2. Задачу изначально на 99% сделал Денис Скоробогатов, ВШЭ и Яндекс. Остальной процент доделывал Алексей Миловидов, а затем [Александр Сапин](https://github.com/alesapin). + +### 23.6. Включение учёта порядка столбцов в CSV {#vkliuchenie-uchiota-poriadka-stolbtsov-v-csv} + +Просто аккуратно включить. + +### 23.7. Включение NULL as Default в CSV {#vkliuchenie-null-as-default-v-csv} + +Просто аккуратно включить. + +### 23.8. + Включение оптимизации VALUES {#vkliuchenie-optimizatsii-values} + +Просто аккуратно включить. + +### 23.9. + Включение Processors {#vkliuchenie-processors} + +Q1. [Николай Кочетов](https://github.com/KochetovNicolai). + +### 23.10. Включение mlock бинарника {#vkliuchenie-mlock-binarnika} + +Возможность mlock бинарника сделал Олег Алексеенков [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) +. Поможет, когда на серверах кроме ClickHouse работает много посторонних программ (мы иногда называем их в шутку «треш-программами»). + + +## 24. Экспериментальные задачи {#eksperimentalnye-zadachi} + +### 24.1. Веб-интерфейс для просмотра состояния кластера и профилирования запросов {#veb-interfeis-dlia-prosmotra-sostoianiia-klastera-i-profilirovaniia-zaprosov} + +Антон Мамонов, УрФУ, Яндекс. + +Внутри ClickHouse есть богатые возможности по интроспекции и профилированию. Эти возможности доступны через системные таблицы и использовать их приходится путём формулирования SQL запросов. Это неудобно. + +Вместо этого предлагается сделать, чтобы ClickHouse отдавал HTML страницу, реализующую интерактивный web-интерфейс со следующими возможностями: +- отображение состояния кластеров (какие кластеры известны, статус каждого сервера); +- графики нагрузки текущего сервера или выбранного сервера кластера; +- обновляемый список запросов; +- просмотр лога запросов с наиболее востребованными фильтрациями по одной кнопке; +- просмотр лога на кластере, например - последние ошибки; +- просмотр метрик использования ресурсов, flame graph и pprof-граф для выбранных запросов; +- отчёт по использованию кластера (пример: количество ядер CPU по пользователям за сегодня). + +### 24.2. Экспериментальные алгоритмы сжатия {#eksperimentalnye-algoritmy-szhatiia} + +ClickHouse поддерживает LZ4 и ZSTD для сжатия данных. Эти алгоритмы являются парето-оптимальными по соотношению скорости и коэффициентам сжатия среди достаточно известных. Тем не менее, существуют менее известные алгоритмы сжатия, которые могут превзойти их по какому-либо критерию. Из потенциально более быстрых по сравнимом коэффициенте сжатия: Lizard, LZSSE, density. Из более сильных: bsc и csc. Необходимо изучить эти алгоритмы, добавить их поддержку в ClickHouse и исследовать их работу на тестовых датасетах. + +### 24.3. Экспериментальные кодеки {#eksperimentalnye-kodeki} + +Вероника Фалчикова, Лада Торчик, ВШЭ. + +Существуют специализированные алгоритмы кодирования числовых последовательностей: Group VarInt, MaskedVByte, PFOR. Необходимо изучить наиболее эффективные реализации этих алгоритмов. Примеры вы сможете найти на https://github.com/lemire и https://github.com/powturbo/ а также https://github.com/schizofreny/middle-out + +Внедрить их в ClickHouse в виде кодеков и изучить их работу на тестовых датасетах. + +### 24.4. Шифрование в ClickHouse на уровне VFS {#shifrovanie-v-clickhouse-na-urovne-vfs} + +Данные в ClickHouse хранятся без шифрования. При наличии доступа к дискам, злоумышленник может прочитать данные. Предлагается реализовать два подхода к шифрованию: + +1. Шифрование на уровне VFS. + +Обсуждаются детали реализации. Q3/Q4. + +### 24.5. Поддержка функций шифрования для отдельных значений {#podderzhka-funktsii-shifrovaniia-dlia-otdelnykh-znachenii} + +Смотрите также 24.5. + +2. Шифрование отдельных значений. + Для этого требуется реализовать функции шифрования и расшифрования, доступные из SQL. Для шифрования реализовать возможность добавления нужного количества случайных бит для исключения одинаковых зашифрованных значений на одинаковых данных. Это позволит реализовать возможность «забывания» данных без удаления строк таблицы: можно шифровать данные разных клиентов разными ключами, и для того, чтобы забыть данные одного клиента, потребуется всего лишь удалить ключ. + +Будет делать Василий Немков, Altinity + +### 24.6. Userspace RAID {#userspace-raid} + +Глеб Новиков, ВШЭ. + +RAID позволяет одновременно увеличить надёжность хранения данных на дисках и увеличить скорость работы дискового массива. Обычно RAID настраивается с помощью встроенных возможностей ядра Linux (mdraid) или с помощью hardware контроллера. У этого есть следующие ограничения: + +1. Иногда (в облачной инфраструктуре некоторых компаний) сервер предоставляется с отдельными дисками, подмонтированными в виде отдельных разделов (JBOD), без возможности создания RAID. + +2. В ClickHouse для обеспечения избыточности обычно используется репликация между серверами. Но при восстановлении одного из дисков RAID не используются данные с реплик, а в случае отказа одного из дисков в RAID-0, приходится передавать с реплики все данные, а не только данные, соответствующие одному из дисков. Это происходит, потому что RAID не интегрирован в ClickHouse и «не знает» про его особенности. + +3. Отсутствуют продвинутые варианты обеспечения избыточности, как например, LRC. + +Для преодоления этих ограничений, предлагается реализовать в ClickHouse встроенный алгоритм расположения данных на дисках. + +### 24.7. Вероятностные структуры данных для фильтрации по подзапросам {#veroiatnostnye-struktury-dannykh-dlia-filtratsii-po-podzaprosam} + +Рузель Ибрагимов, ВШЭ и Яндекс. + +Частой задачей является выполнение запроса с фильтрацией по множеству, полученному по подзапросу. Пример: найти пользователей, которые заходили на сайт сегодня и заходили неделю назад. Это выражается в виде запроса: `SELECT UserID FROM table WHERE EventDate = today() AND UserID IN (SELECT ...)`. При выполнении этого запроса, сначала выполняется подзапрос в правой части `IN` и формируется хэш-таблица в оперативке; затем эта хэш-таблица используется для фильтрации. + +Иногда объём данных достаточно большой, и хэш-таблица не помещается в оперативку. В этом случае можно рассмотреть в качестве варианта приближённый рассчёт: найти пользователей, которые заходили на сайт сегодня и наверное заходили неделю назад. Для этого можно вместо хэш-таблицы использовать Bloom Filter. Другая задача: найти пользователей, которые встречались, скорее всего, не менее некоторого количества раз. Для этого можно использовать Counting Bloom Filter. Также следует изучить структуры данных Quotient Filter и Cuckoo Filer, а ещё - секретный алгоритм Chaotic Map от Андрея Плахова. + +Предлагается реализовать это в языке запросов ClickHouse с помощью специального синтаксиса, например `x IN BLOOM FILTER (n, m) (SELECT ...)`. + +### 24.8. Специализация векторизованного кода для AVX/AVX2/AVX512 и ARM NEON {#spetsializatsiia-vektorizovannogo-koda-dlia-avxavx2avx512-i-arm-neon} + +[\#1017](https://github.com/ClickHouse/ClickHouse/issues/1017) + +Дмитрий Ковальков, ВШЭ и Яндекс. + +Подавляющее большинство кода ClickHouse написана для x86\_64 с набором инструкций до SSE 4.2 включительно. Лишь отдельные редкие функции поддерживают AVX/AVX2/AVX512 с динамической диспетчеризацией. + +В первой части задачи, следует добавить в ClickHouse реализации некоторых примитивов, оптимизированные под более новый набор инструкций. Например, AVX2 реализацию генератора случайных чисел pcg: https://github.com/lemire/simdpcg + +Во второй части задачи, предлагается адаптировать существующие куски кода, использующие SSE intrinsics на AVX/AVX2 и сравнить производительность. Также рассматривается оптимизация под ARM NEON. + +### 24.9. Общий подход к CPU dispatching в фабрике функций {#obshchii-podkhod-k-cpu-dispatching-v-fabrike-funktsii} + +Дмитрий Ковальков, ВШЭ и Яндекс. + +Продолжение 24.8. + +Upd. Есть pull request. + +### 24.10. Поддержка типов half/bfloat16/unum {#podderzhka-tipov-halfbfloat16unum} + +[\#7657](https://github.com/ClickHouse/ClickHouse/issues/7657) + +Рустам Гусейн-заде, ВШЭ. + +### 24.11. User Defined Functions {#user-defined-functions} + +Игорь Минеев, ВШЭ. + +ClickHouse предоставляет достаточно богатый набор встроенных функций языка запросов, но не позволяет пользователю добавлять свои функции без редактировния исходников и перекомпиляции системы. Это мотивировано следующими потенциальными проблемами: + +1. ClickHouse является array-oriented системой, и все функции внутри кода принимают для обработки целые массивы, а не отдельные значения. Это усложняет внутренний интерфейс и делает его менее удобным для пользователя. +2. Предоставление возможности подключения UDF в виде shared библиотек, потребовало бы фиксировать этот интерфейс или поддерживать обратную совместимость, тогда как мы бы хотели, при разработке ClickHouse, менять этот интерфейс по своему усмотрению без оглядки. +3. Сложность внутренних структур данных повышает вероятность ошибок типа buffer overflow и повреждения памяти, что сильно затруднит сопровождение ClickHouse с пользовательскими функциями. + +Тем не менее, можно выбрать более аккуратный подход, избегающий непосредственной линковки с shared библиотеками. + +Сначала можно реализовать поддержку UDF в виде выражений, составленных из простых функций ClickHouse. В ClickHouse есть встроенная кодогенерация на LLVM, что позволит таким функциям работать весьма эффективно. Но этот подход весьма ограничен и поэтому не является исчерпывающим. + +Затем предлагается реализовать поддержку UDF в виде исходников на C++, которые компилируются в runtime, с использованием заголовочных файлов ClickHouse. Требование компиляции из исходников вместо shared библиотек, позволит ослабить необходимость в поддержке совместимости ABI. + +Для безопасности, потребуется исследовать возможность размещения буферов данных в shared memory для выполнения UDF в отдельных процессах с изоляцией по памяти. Возможно, для этого пригодится интеграция с Apache Arrow. + +Также рассматривается возможность написания UDF на Rust, а также использование Web Assembly. Отдельно можно рассмотреть подключение NumPy и R и других технологий, которые предоставляют операции над целыми массивами. + +### 24.12. GPU offloading {#gpu-offloading} + +Риск состоит в том, что даже известные GPU базы, такие как OmniSci, работают медленнее, чем ClickHouse. +Преимущество возможно только на полной сортировке и JOIN. +Алексей Соловей, nVidia и Рита Коннова, ВШЭ. + +В компании nVidia сделали прототип offloading вычисления GROUP BY с некоторыми из агрегатных функций в ClickHouse и обещат предоставить исходники в публичный доступ для дальнейшего развития. Предлагается изучить этот прототип и расширить его применимость для более широкого сценария использования. В качестве альтернативы, предлагается изучить исходные коды системы `OmniSci` или `Alenka` или библиотеку `CUB` https://nvlabs.github.io/cub/ и применить некоторые из алгоритмов в ClickHouse. + +Upd. В компании nVidia выложили прототип, теперь нужна интеграция в систему сборки. +Upd. Интеграция в систему сборки - Иван Лежанкин. +Upd. Есть прототип bitonic sort. +Upd. Прототип bitonic sort помержен, но целесообразность под вопросом (он работает медленнее). +Наверное надо будет подержать и удалить. + +### 24.13. Stream запросы {#stream-zaprosy} + +Пререквизит для ClickHouse как CEP-системы. + +### 24.14. Window функции {#window-funktsii} + +[\#1469](https://github.com/ClickHouse/ClickHouse/issues/1469) + +Требует 2.1. + +### 24.15. Поддержка полуструктурированных данных {#podderzhka-polustrukturirovannykh-dannykh} + +Требует 1.14 и 2.10. + +### 24.16. Улучшение эвристики слияний {#uluchshenie-evristiki-sliianii} + +В прошлом году исследование по этой задаче сделал Егор Соловьёв, ВШЭ и Яндекс.Такси. Его исследование показало, что алгоритм нельзя существенно улучшить путём изменения параметров. Но исследование лажовое, так как рассмотрен только уже использующийся алгоритм. То есть, задача остаётся открытой. + +### 24.17. Экспериментальные способы ускорения параллельного GROUP BY {#eksperimentalnye-sposoby-uskoreniia-parallelnogo-group-by} + +Максим Серебряков + +Задача в работе. +Upd. Достигнуты обнадёживающие результаты. + +### 24.18. Не TCP протокол передачи файлов при репликации {#ne-tcp-protokol-peredachi-failov-pri-replikatsii} + +### 24.19. Промежуточное состояние GROUP BY как структура данных для key-value доступа {#promezhutochnoe-sostoianie-group-by-kak-struktura-dannykh-dlia-key-value-dostupa} + +### 24.20. Short-circuit вычисления некоторых выражений {#short-circuit-vychisleniia-nekotorykh-vyrazhenii} + +Два года назад задачу попробовала сделать Анастасия Царькова, ВШЭ и Яндекс, но реализация получилась слишком неудобной и её удалили. + +### 24.21. Реализация в ClickHouse протокола распределённого консенсуса {#realizatsiia-v-clickhouse-protokola-raspredelionnogo-konsensusa} + +Имеет смысл только после 19.2. + +### 24.22. Вывод типов по блоку данных. Вывод формата данных по примеру {#vyvod-tipov-po-bloku-dannykh-vyvod-formata-dannykh-po-primeru} + +Задача отложена. + +ClickHouse является строго типизированной системой. Для того, чтобы прочитать данные в каком либо формате (например, CSV), требуется заранее указать типы данных. Если при чтении формата выясняется, что данные не могут быть прочитаны в рамках заданных типов, то кидается исключение. + +ClickHouse также может использоваться для быстрой аналитики по локальным файлам, без загрузки их в базу данных (программа `clickhouse-local`). В этом случае, его использование может заменить `awk`, `sed`, `grep`. Но остаётся неудобство - необходимость указания типов данных. + +Предлагается реализовать функциональность вывода типов по первому блоку данных путём применения эвристик и постепенного расширения типов. + +Другая экспериментальная задача - реализация эвристик для обработки данных в неизвестном построчном текстовом формате. Детектирование CSV, TSV, JSON, детектирование разделителей и форматов значений. + +### 24.23. Минимальная поддержка транзакций для множества вставок/чтений {#minimalnaia-podderzhka-tranzaktsii-dlia-mnozhestva-vstavokchtenii} + +Максим Кузнецов, ВШЭ. + +Таблицы типа MergeTree состоят из набора независимых неизменяемых «кусков» данных. При вставках данных (INSERT), формируются новые куски. При модификациях данных (слияние кусков), формируются новые куски, а старые - становятся неактивными и перестают использоваться следующими запросами. Чтение данных (SELECT) производится из снэпшота множества кусков на некоторый момент времени. Таким образом, чтения и вставки не блокируют друг друга. + +Если же выполняется несколько запросов SELECT, то чтение данных может осуществляться из снэпшотов по состоянию на несколько разных моментов времени и быть неконсистентным. Пример: пользователю отображается отчёт из нескольких графиков и таблиц, но из-за того, что между разными запросами, данные успели обновиться, отображаемые данные не соответствуют друг другу. + +Пример с другой стороны - пользователь хочет осуществить несколько вставок (INSERT) в одну или несколько таблиц, но так, чтобы данные появились в них атомарно с точки зрения других запросов (SELECT). + +Для решения этих проблем, предлагается ввести глобальные метки времени для кусков данных (сейчас уже есть инкрементальные номера кусков, но они выделяются в рамках одной таблицы). Первым шагом сделаем эти метки времени в рамках сервера. Вторым шагом сделаем метки времени в рамках всех серверов, но неточные на основе локальных часов. Третьим шагом сделаем метки времени, выдаваемые сервисом координации. + +### 24.24. Реализация алгоритмов differential privacy {#realizatsiia-algoritmov-differential-privacy} + +[\#6874](https://github.com/ClickHouse/ClickHouse/issues/6874) + +Артём Вишняков, ВШЭ. + +### 24.25. Интеграция в ClickHouse функциональности обработки HTTP User Agent {#integratsiia-v-clickhouse-funktsionalnosti-obrabotki-http-user-agent} + +[\#157](https://github.com/ClickHouse/ClickHouse/issues/157) +Есть хороший код в Яндекс.Метрике. Получено согласие от руководства. +Михаил Филитов, ВШЭ. +Upd. Есть pull request. Нужно ещё чистить код библиотеки. + +### 24.26. Поддержка open tracing или аналогов {#podderzhka-open-tracing-ili-analogov} + +[\#5182](https://github.com/ClickHouse/ClickHouse/issues/5182) + +Александр Кожихов, ВШЭ и Яндекс.YT. +Upd. Есть pull request с прототипом. + +### 24.27. Реализация алгоритмов min-hash, sim-hash для нечёткого поиска полудубликатов {#realizatsiia-algoritmov-min-hash-sim-hash-dlia-nechiotkogo-poiska-poludublikatov} + +[\#7649](https://github.com/ClickHouse/ClickHouse/pull/7649) + +ucasFL, ICT. + +Алгоритмы min-hash и sim-hash позволяют вычислить для текста несколько хэш-значений таких, что при небольшом изменении текста, по крайней мере один из хэшей не меняется. Вычисления можно реализовать на n-грамах и словарных шинглах. Предлагается добавить поддержку этих алгоритмов в виде функций в ClickHouse и изучить их применимость для задачи нечёткого поиска полудубликатов. + +Есть pull request, есть что доделывать. + +### 24.28. Другой sketch для квантилей {#drugoi-sketch-dlia-kvantilei} + +Похоже на quantileTiming, но с логарифмическими корзинами. См. DDSketch. + +### 24.29. Поддержка Arrow Flight {#podderzhka-arrow-flight} + +[\#7554](https://github.com/ClickHouse/ClickHouse/issues/7554) + +Жанна Зосимова, ВШЭ. +Upd. Пока поддержали Arrow как формат ввода-вывода. + +### 24.30. ClickHouse как графовая СУБД {#clickhouse-kak-grafovaia-subd} + +Amos Bird, но его решение слишком громоздкое и пока не open-source. + +### 24.31. Кореллированные подзапросы {#korellirovannye-podzaprosy} + +Перепиcывание в JOIN. Не раньше 21.11, 21.12, 21.9. Низкий приоритет. + +### 24.32. Поддержка GRPC {#podderzhka-grpc} + +Мария Конькова, ВШЭ и Яндекс. +Также смотрите 24.29. + +В ClickHouse есть два основных протокола: родной протокол общения между серверами и HTTP/1.1 протокол. HTTP/1.1 протокол удобен для работы из самых разных языков программирования, но, в отличие от родного протокола, не поддерживает двусторонний обмен информацией во время запроса: +- передачу информации о прогрессе во время выполнения запроса; +- передачу логов во время выполнения запроса; +- отмену выполнения запроса в тот момент как данные ещё не начали передаваться; + +Рассматривается вариант - поддержка GRPC в ClickHouse. Здесь есть неочевидные моменты, такие как - эффективная передача массивов данных в column-oriented формате - насколько удобно будет обернуть это в GRPC. + +Задача в работе, есть pull request. [#10136](https://github.com/ClickHouse/ClickHouse/pull/10136) + + +## 25. DevRel {#devrel} + +### 25.1. + Перевод инструкции для начинающих разработчиков {#perevod-instruktsii-dlia-nachinaiushchikh-razrabotchikov} + +Александр Казаков, ноябрь 2019. + +### 25.2. + Вычитка и выкладка статьи про обфускацию данных на английском {#vychitka-i-vykladka-stati-pro-obfuskatsiiu-dannykh-na-angliiskom} + +Эми, Александр Казаков, Алексей Миловидов, Q1. +Готово к выкладке. + +### 25.3. Подготовка статьи «Секреты оптимизации производительности ClickHouse» {#podgotovka-stati-sekrety-optimizatsii-proizvoditelnosti-clickhouse} + +Алексей Миловидов, Леонид. + +### 25.4. Подготовка статьи «Профайлер запросов: трудный путь» {#podgotovka-stati-profailer-zaprosov-trudnyi-put} + +Алексей Миловидов, Леонид. + +### 25.5. Подготовка статьи «Тестирование ClickHouse, которое мы заслужили» {#podgotovka-stati-testirovanie-clickhouse-kotoroe-my-zasluzhili} + +### 25.6. Перевод этих статей на английский {#perevod-etikh-statei-na-angliiskii} + +Требует 25.3, 25.4, 25.5. Эми + +### 25.7. Перевод статьи Данилы Кутенина на английский {#perevod-stati-danily-kutenina-na-angliiskii} + +Эми + +### 25.8. + Выступление keynote на BDTC {#vystuplenie-keynote-na-bdtc} + +Алексей Миловидов + +### 25.9. Подготовка докладчиков: khvostikao, ilezhankin, nikitamikhailov, akuzm и другие {#podgotovka-dokladchikov-khvostikao-ilezhankin-nikitamikhailov-akuzm-i-drugie} + +[Ольга Хвостикова](https://github.com/stavrolia), [Иван Лежанкин](https://github.com/abyss7), Никита Михайлов, [Александр Кузьменков](https://github.com/akuzm), Артём Зуйков. +Уже готовые докладчики: Алексей Миловидов, [Николай Кочетов](https://github.com/KochetovNicolai), [Александр Сапин](https://github.com/alesapin). +Получаем минимум 8 докладчиков в 2020 году. + +### 25.10. Митапы в России и Беларуси: Москва x2 + митап для разработчиков или хакатон, Санкт-Петербург, Минск, Нижний Новгород, Екатеринбург, Новосибирск и/или Академгородок, Иннополис или Казань {#mitapy-v-rossii-i-belarusi-moskva-x2-mitap-dlia-razrabotchikov-ili-khakaton-sankt-peterburg-minsk-nizhnii-novgorod-ekaterinburg-novosibirsk-iili-akademgorodok-innopolis-ili-kazan} + +Екатерина - организация. Upd. Проведено два онлайн митапа на русском и два на английском. + +### 25.11. Митапы зарубежные: восток США (Нью Йорк, возможно Raleigh), возможно северо-запад (Сиэтл), Китай (Пекин снова, возможно митап для разработчиков или хакатон), Лондон {#mitapy-zarubezhnye-vostok-ssha-niu-iork-vozmozhno-raleigh-vozmozhno-severo-zapad-sietl-kitai-pekin-snova-vozmozhno-mitap-dlia-razrabotchikov-ili-khakaton-london} + +[Иван Блинков](https://github.com/blinkov/) - организация. Две штуки в США запланированы. Upd. Два митапа в США и один в Европе проведены. + +### 25.12. Статья «научная» - про устройство хранения данных и индексов или whitepaper по архитектуре. Есть вариант подать на VLDB {#statia-nauchnaia-pro-ustroistvo-khraneniia-dannykh-i-indeksov-ili-whitepaper-po-arkhitekture-est-variant-podat-na-vldb} + +Низкий приоритет. Алексей Миловидов. + +### 25.13. Участие во всех мероприятиях Яндекса, которые связаны с разработкой бэкенда, C++ разработкой или с базами данных, возможно участие в DevRel мероприятиях {#uchastie-vo-vsekh-meropriiatiiakh-iandeksa-kotorye-sviazany-s-razrabotkoi-bekenda-c-razrabotkoi-ili-s-bazami-dannykh-vozmozhno-uchastie-v-devrel-meropriiatiiakh} + +Алексей Миловидов и все подготовленные докладчики + +### 25.14. Конференции в России: все HighLoad, возможно CodeFest, DUMP или UWDC, возможно C++ Russia {#konferentsii-v-rossii-vse-highload-vozmozhno-codefest-dump-ili-uwdc-vozmozhno-c-russia} + +Алексей Миловидов и все подготовленные докладчики. +Upd. Есть Saint HighLoad online. + +### 25.15. Конференции зарубежные: Percona, DataOps, попытка попасть на более крупные {#konferentsii-zarubezhnye-percona-dataops-popytka-popast-na-bolee-krupnye} + +Алексей Миловидов и все подготовленные докладчики + +### 25.16. Сайт play.clickhouse {#sait-play-clickhouse} + +Цель состоит в реализации сайта, на котором можно попробовать задавать произвольные запросы к временному экземпляру ClickHouse и изучать его поведение. Из похожих проектов можно отметить: [Compiler Explorer](https://godbolt.org/), http://ideone.com/, [SQLFiddle](http://sqlfiddle.com/), [DB-Fiddle](https://www.db-fiddle.com/). + +С помощью такого сайта можно решать следующие задачи: +- ознакомление с языком запросов ClickHouse; +- демонстрация примеров из документации; +- демонстрация скорости работы на тестовых датасетах; +- сравнение поведения разных версий ClickHouse друг с другом; +- демонстрация неожиданного поведения или багов; + +Требуется проработать вопрос безопасности и изоляции инстансов (поднятие в контейнерах с ограничениями по сети), подключение тестовых датасетов с помощью copy-on-write файловой системы; органичения ресурсов. + +Есть минимальный прототип. Сделал Илья Яцишин. Этот прототип не позволяет делиться ссылками на результаты запросов. + +### 25.17. Взаимодействие с ВУЗами: ВШЭ, УрФУ, ICT Beijing {#vzaimodeistvie-s-vuzami-vshe-urfu-ict-beijing} + +Алексей Миловидов и вся группа разработки. +Благодаря Robert Hodges добавлен CMU. + +### 25.18. - Лекция в ШАД {#lektsiia-v-shad} + +Алексей Миловидов + +### 25.19. - Участие в курсе разработки на C++ в ШАД {#uchastie-v-kurse-razrabotki-na-c-v-shad} + +### 25.20. Ещё одно сравнение производительности аналитических СУБД {#eshchio-odno-sravnenie-proizvoditelnosti-analiticheskikh-subd} + +Матвей Бубнов, УрФУ + +Существуют мало известные специализированные СУБД, способные конкурировать с ClickHouse по скорости обработки некоторых классов запросов. Пример: `TDEngine` и `DolphinDB`, `VictoriaMetrics`, а также `Apache Doris` и `LocustDB`. Предлагается изучить и классифицировать архитектурные особенности этих систем - их особенности и преимущества. Установить эти системы, загрузить тестовые данные, изучить производительность. Проанализировать, за счёт чего достигаются преимущества. + +Upd. Есть поползновения с TDEngine. + +### 25.21. Повторное награждение контрибьюторов в Китае {#povtornoe-nagrazhdenie-kontribiutorov-v-kitae} + +### 25.22. On-site помощь с ClickHouse компаниям в дни рядом с мероприятиями {#on-site-pomoshch-s-clickhouse-kompaniiam-v-dni-riadom-s-meropriiatiiami} + +[Иван Блинков](https://github.com/blinkov/) - организация. Провёл мероприятие для турецкой компании. +Upd. On-site заменяется на Online. + +### 25.23. Новый мерч для ClickHouse {#novyi-merch-dlia-clickhouse} + +### 25.24. Конкурсы bughunter или оптимизации кода на C++ {#konkursy-bughunter-ili-optimizatsii-koda-na-c} + +Проведение конкурсов должно начинаться для сотрудников Яндекса, пока нет согласования. + +### 25.25. Семинары для потенциальных клиентов Яндекс.Облака {#seminary-dlia-potentsialnykh-klientov-iandeks-oblaka} + +По мере необходимости. Алексей Миловидов, организация - Яндекс.Облако. + +### 25.26. - Участие в GSoC {#uchastie-v-gsoc} + +Андрей Бородин пытается уговорить нас участвовать, но пока загружены задачей 25.17. + +UPD: не участвуем. + +### 25.27. + Обновить сайт ClickHouse {#obnovit-sait-clickhouse} + +Иван Блинков. Нет рисков. Нужно для Яндекс.Облака. Upd. Сделано. diff --git a/docs/ru/whats-new/index.md b/docs/ru/whats-new/index.md new file mode 100644 index 00000000000..a8c908088d0 --- /dev/null +++ b/docs/ru/whats-new/index.md @@ -0,0 +1,6 @@ +--- +toc_folder_title: "\u0427\u0442\u043E \u043D\u043E\u0432\u043E\u0433\u043E?" +toc_priority: 72 +--- + + diff --git a/docs/ru/whats-new/roadmap.md b/docs/ru/whats-new/roadmap.md new file mode 120000 index 00000000000..2c383b2ad5d --- /dev/null +++ b/docs/ru/whats-new/roadmap.md @@ -0,0 +1 @@ +../../en/whats-new/roadmap.md \ No newline at end of file diff --git a/docs/ru/whats-new/security-changelog.md b/docs/ru/whats-new/security-changelog.md new file mode 100644 index 00000000000..4a799a29649 --- /dev/null +++ b/docs/ru/whats-new/security-changelog.md @@ -0,0 +1,71 @@ +# Security Changelog {#security-changelog} + +## Исправлено в релизе 19.14.3.3, 2019-09-10 {#ispravleno-v-relize-19-14-3-3-2019-09-10} + +### CVE-2019-15024 {#cve-2019-15024} + +Злоумышленник с доступом на запись к ZooKeeper и возможностью запустить собственный сервер в сети доступной ClickHouse может создать вредоносный сервер, который будет вести себя как реплика ClickHouse и зарегистрируется в ZooKeeper. В процессе репликации вредоносный сервер может указать любой путь на файловой системе в который будут записаны данные. + +Обнаружено благодаря: Эльдару Заитову из Службы Информационной Безопасности Яндекса + +### CVE-2019-16535 {#cve-2019-16535} + +Интерфейс декомпрессии позволял совершать OOB чтения и записи данных в памяти, а также переполнение целочисленных переменных, что могло приводить к отказу в обслуживании. Также потенциально могло использоваьтся для удаленного выполнения кода. + +Обнаружено благодаря: Эльдару Заитову из Службы Информационной Безопасности Яндекса + +### CVE-2019-16536 {#cve-2019-16536} + +Аутентифицированный клиент злоумышленника имел возможность вызвать переполнение стека, что могло привести к отказу в обслуживании. + +Обнаружено благодаря: Эльдару Заитову из Службы Информационной Безопасности Яндекса + +## Исправлено в релизе 19.13.6.1 от 20 сентября 2019 {#ispravleno-v-relize-19-13-6-1-ot-20-sentiabria-2019} + +### CVE-2019-18657 {#cve-2019-18657} + +Уязвимость в табличной функции `url` позволяла злоумышленнику добавлять произвольные HTTP-заголовки в запрос. + +Обнаружено благодаря: [Никите Тихомирову](https://github.com/NSTikhomirov) + +## Исправлено в релизе 18.12.13 от 10 сентября 2018 {#ispravleno-v-relize-18-12-13-ot-10-sentiabria-2018} + +### CVE-2018-14672 {#cve-2018-14672} + +Функция для загрузки CatBoost моделей некорректно обрабатывала пути к файлам, что позволяло читать произвольные локальные файлы на сервере Clickhouse через сообщения об ошибках. + +Обнаружено благодаря: Андрею Красичкову из Службы Информационной Безопасности Яндекса + +## Исправлено в релизе 18.10.3 от 13 августа 2018 {#ispravleno-v-relize-18-10-3-ot-13-avgusta-2018} + +### CVE-2018-14671 {#cve-2018-14671} + +unixODBC позволял указать путь для подключения произвольного shared object в качестве драйвера базы данных, что приводило к возможности выполнить произвольный код на сервере ClickHouse. + +Обнаружено благодаря: Андрею Красичкову и Евгению Сидорову из Службы Информационной Безопасности Яндекса + +## Исправлено в релизе 1.1.54388 от 28 июня 2018 {#ispravleno-v-relize-1-1-54388-ot-28-iiunia-2018} + +### CVE-2018-14668 {#cve-2018-14668} + +Табличная функция «remote» допускала произвольные символы в полях «user», «password» и «default\_database», что позволяло производить атаки класса Cross Protocol Request Forgery. + +Обнаружено благодаря: Андрею Красичкову из Службы Информационной Безопасности Яндекса + +## Исправлено в релизе 1.1.54390 от 6 июля 2018 {#ispravleno-v-relize-1-1-54390-ot-6-iiulia-2018} + +### CVE-2018-14669 {#cve-2018-14669} + +В ClickHouse MySQL клиенте была включена функциональность «LOAD DATA LOCAL INFILE», что позволяло получать доступ на чтение к произвольным файлам на сервере, где запущен ClickHouse. + +Обнаружено благодаря: Андрею Красичкову и Евгению Сидорову из Службы Информационной Безопасности Яндекса + +## Исправлено в релизе 1.1.54131 от 10 января 2017 {#ispravleno-v-relize-1-1-54131-ot-10-ianvaria-2017} + +### CVE-2018-14670 {#cve-2018-14670} + +Некорректная конфигурация в deb пакете могла привести к неавторизованному доступу к базе данных. + +Обнаружено благодаря: the UK’s National Cyber Security Centre (NCSC) + +{## [Оригинальная статья](https://clickhouse.tech/docs/ru/security_changelog/) ##} diff --git a/docs/ru/whats_new/changelog/2017.md b/docs/ru/whats_new/changelog/2017.md deleted file mode 120000 index a098eddf1d8..00000000000 --- a/docs/ru/whats_new/changelog/2017.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/whats_new/changelog/2017.md \ No newline at end of file diff --git a/docs/ru/whats_new/changelog/2018.md b/docs/ru/whats_new/changelog/2018.md deleted file mode 120000 index 124fb19e175..00000000000 --- a/docs/ru/whats_new/changelog/2018.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/whats_new/changelog/2018.md \ No newline at end of file diff --git a/docs/ru/whats_new/changelog/2019.md b/docs/ru/whats_new/changelog/2019.md deleted file mode 120000 index 740d1edd238..00000000000 --- a/docs/ru/whats_new/changelog/2019.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/whats_new/changelog/2019.md \ No newline at end of file diff --git a/docs/ru/whats_new/changelog/index.md b/docs/ru/whats_new/changelog/index.md deleted file mode 100644 index 969e71fbf42..00000000000 --- a/docs/ru/whats_new/changelog/index.md +++ /dev/null @@ -1,650 +0,0 @@ ---- -toc_folder_title: Changelog -toc_priority: 74 -toc_title: '2020' ---- - -## ClickHouse release v20.3 - -### ClickHouse release v20.3.4.10, 2020-03-20 - -#### Bug Fix -* This release also contains all bug fixes from 20.1.8.41 -* Fix missing `rows_before_limit_at_least` for queries over http (with processors pipeline). This fixes [#9730](https://github.com/ClickHouse/ClickHouse/issues/9730). [#9757](https://github.com/ClickHouse/ClickHouse/pull/9757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - - -### ClickHouse release v20.3.3.6, 2020-03-17 - -#### Bug Fix -* This release also contains all bug fixes from 20.1.7.38 -* Fix bug in a replication that doesn't allow replication to work if the user has executed mutations on the previous version. This fixes [#9645](https://github.com/ClickHouse/ClickHouse/issues/9645). [#9652](https://github.com/ClickHouse/ClickHouse/pull/9652) ([alesapin](https://github.com/alesapin)). It makes version 20.3 backward compatible again. -* Add setting `use_compact_format_in_distributed_parts_names` which allows to write files for `INSERT` queries into `Distributed` table with more compact format. This fixes [#9647](https://github.com/ClickHouse/ClickHouse/issues/9647). [#9653](https://github.com/ClickHouse/ClickHouse/pull/9653) ([alesapin](https://github.com/alesapin)). It makes version 20.3 backward compatible again. - -### ClickHouse release v20.3.2.1, 2020-03-12 - -#### Backward Incompatible Change - -* Fixed the issue `file name too long` when sending data for `Distributed` tables for a large number of replicas. Fixed the issue that replica credentials were exposed in the server log. The format of directory name on disk was changed to `[shard{shard_index}[_replica{replica_index}]]`. [#8911](https://github.com/ClickHouse/ClickHouse/pull/8911) ([Mikhail Korotov](https://github.com/millb)) After you upgrade to the new version, you will not be able to downgrade without manual intervention, because old server version does not recognize the new directory format. If you want to downgrade, you have to manually rename the corresponding directories to the old format. This change is relevant only if you have used asynchronous `INSERT`s to `Distributed` tables. In the version 20.3.3 we will introduce a setting that will allow you to enable the new format gradually. -* Changed the format of replication log entries for mutation commands. You have to wait for old mutations to process before installing the new version. -* Implement simple memory profiler that dumps stacktraces to `system.trace_log` every N bytes over soft allocation limit [#8765](https://github.com/ClickHouse/ClickHouse/pull/8765) ([Ivan](https://github.com/abyss7)) [#9472](https://github.com/ClickHouse/ClickHouse/pull/9472) ([alexey-milovidov](https://github.com/alexey-milovidov)) The column of `system.trace_log` was renamed from `timer_type` to `trace_type`. This will require changes in third-party performance analysis and flamegraph processing tools. -* Use OS thread id everywhere instead of internal thread number. This fixes [#7477](https://github.com/ClickHouse/ClickHouse/issues/7477) Old `clickhouse-client` cannot receive logs that are send from the server when the setting `send_logs_level` is enabled, because the names and types of the structured log messages were changed. On the other hand, different server versions can send logs with different types to each other. When you don't use the `send_logs_level` setting, you should not care. [#8954](https://github.com/ClickHouse/ClickHouse/pull/8954) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Remove `indexHint` function [#9542](https://github.com/ClickHouse/ClickHouse/pull/9542) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Remove `findClusterIndex`, `findClusterValue` functions. This fixes [#8641](https://github.com/ClickHouse/ClickHouse/issues/8641). If you were using these functions, send an email to `clickhouse-feedback@yandex-team.com` [#9543](https://github.com/ClickHouse/ClickHouse/pull/9543) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Now it's not allowed to create columns or add columns with `SELECT` subquery as default expression. [#9481](https://github.com/ClickHouse/ClickHouse/pull/9481) ([alesapin](https://github.com/alesapin)) -* Require aliases for subqueries in JOIN. [#9274](https://github.com/ClickHouse/ClickHouse/pull/9274) ([Artem Zuikov](https://github.com/4ertus2)) -* Improved `ALTER MODIFY/ADD` queries logic. Now you cannot `ADD` column without type, `MODIFY` default expression doesn't change type of column and `MODIFY` type doesn't loose default expression value. Fixes [#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). [#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) ([alesapin](https://github.com/alesapin)) -* Require server to be restarted to apply the changes in logging configuration. This is a temporary workaround to avoid the bug where the server logs to a deleted log file (see [#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* The setting `experimental_use_processors` is enabled by default. This setting enables usage of the new query pipeline. This is internal refactoring and we expect no visible changes. If you will see any issues, set it to back zero. [#8768](https://github.com/ClickHouse/ClickHouse/pull/8768) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### New Feature -* Add `Avro` and `AvroConfluent` input/output formats [#8571](https://github.com/ClickHouse/ClickHouse/pull/8571) ([Andrew Onyshchuk](https://github.com/oandrew)) [#8957](https://github.com/ClickHouse/ClickHouse/pull/8957) ([Andrew Onyshchuk](https://github.com/oandrew)) [#8717](https://github.com/ClickHouse/ClickHouse/pull/8717) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Multi-threaded and non-blocking updates of expired keys in `cache` dictionaries (with optional permission to read old ones). [#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Add query `ALTER ... MATERIALIZE TTL`. It runs mutation that forces to remove expired data by TTL and recalculates meta-information about TTL in all parts. [#8775](https://github.com/ClickHouse/ClickHouse/pull/8775) ([Anton Popov](https://github.com/CurtizJ)) -* Switch from HashJoin to MergeJoin (on disk) if needed [#9082](https://github.com/ClickHouse/ClickHouse/pull/9082) ([Artem Zuikov](https://github.com/4ertus2)) -* Added `MOVE PARTITION` command for `ALTER TABLE` [#4729](https://github.com/ClickHouse/ClickHouse/issues/4729) [#6168](https://github.com/ClickHouse/ClickHouse/pull/6168) ([Guillaume Tassery](https://github.com/YiuRULE)) -* Reloading storage configuration from configuration file on the fly. [#8594](https://github.com/ClickHouse/ClickHouse/pull/8594) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Allowed to change `storage_policy` to not less rich one. [#8107](https://github.com/ClickHouse/ClickHouse/pull/8107) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Added support for globs/wildcards for S3 storage and table function. [#8851](https://github.com/ClickHouse/ClickHouse/pull/8851) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Implement `bitAnd`, `bitOr`, `bitXor`, `bitNot` for `FixedString(N)` datatype. [#9091](https://github.com/ClickHouse/ClickHouse/pull/9091) ([Guillaume Tassery](https://github.com/YiuRULE)) -* Added function `bitCount`. This fixes [#8702](https://github.com/ClickHouse/ClickHouse/issues/8702). [#8708](https://github.com/ClickHouse/ClickHouse/pull/8708) ([alexey-milovidov](https://github.com/alexey-milovidov)) [#8749](https://github.com/ClickHouse/ClickHouse/pull/8749) ([ikopylov](https://github.com/ikopylov)) -* Add `generateRandom` table function to generate random rows with given schema. Allows to populate arbitrary test table with data. [#8994](https://github.com/ClickHouse/ClickHouse/pull/8994) ([Ilya Yatsishin](https://github.com/qoega)) -* `JSONEachRowFormat`: support special case when objects enclosed in top-level array. [#8860](https://github.com/ClickHouse/ClickHouse/pull/8860) ([Kruglov Pavel](https://github.com/Avogar)) -* Now it's possible to create a column with `DEFAULT` expression which depends on a column with default `ALIAS` expression. [#9489](https://github.com/ClickHouse/ClickHouse/pull/9489) ([alesapin](https://github.com/alesapin)) -* Allow to specify `--limit` more than the source data size in `clickhouse-obfuscator`. The data will repeat itself with different random seed. [#9155](https://github.com/ClickHouse/ClickHouse/pull/9155) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added `groupArraySample` function (similar to `groupArray`) with reservior sampling algorithm. [#8286](https://github.com/ClickHouse/ClickHouse/pull/8286) ([Amos Bird](https://github.com/amosbird)) -* Now you can monitor the size of update queue in `cache`/`complex_key_cache` dictionaries via system metrics. [#9413](https://github.com/ClickHouse/ClickHouse/pull/9413) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Allow to use CRLF as a line separator in CSV output format with setting `output_format_csv_crlf_end_of_line` is set to 1 [#8934](https://github.com/ClickHouse/ClickHouse/pull/8934) [#8935](https://github.com/ClickHouse/ClickHouse/pull/8935) [#8963](https://github.com/ClickHouse/ClickHouse/pull/8963) ([Mikhail Korotov](https://github.com/millb)) -* Implement more functions of the [H3](https://github.com/uber/h3) API: `h3GetBaseCell`, `h3HexAreaM2`, `h3IndexesAreNeighbors`, `h3ToChildren`, `h3ToString` and `stringToH3` [#8938](https://github.com/ClickHouse/ClickHouse/pull/8938) ([Nico Mandery](https://github.com/nmandery)) -* New setting introduced: `max_parser_depth` to control maximum stack size and allow large complex queries. This fixes [#6681](https://github.com/ClickHouse/ClickHouse/issues/6681) and [#7668](https://github.com/ClickHouse/ClickHouse/issues/7668). [#8647](https://github.com/ClickHouse/ClickHouse/pull/8647) ([Maxim Smirnov](https://github.com/qMBQx8GH)) -* Add a setting `force_optimize_skip_unused_shards` setting to throw if skipping of unused shards is not possible [#8805](https://github.com/ClickHouse/ClickHouse/pull/8805) ([Azat Khuzhin](https://github.com/azat)) -* Allow to configure multiple disks/volumes for storing data for send in `Distributed` engine [#8756](https://github.com/ClickHouse/ClickHouse/pull/8756) ([Azat Khuzhin](https://github.com/azat)) -* Support storage policy (``) for storing temporary data. [#8750](https://github.com/ClickHouse/ClickHouse/pull/8750) ([Azat Khuzhin](https://github.com/azat)) -* Added `X-ClickHouse-Exception-Code` HTTP header that is set if exception was thrown before sending data. This implements [#4971](https://github.com/ClickHouse/ClickHouse/issues/4971). [#8786](https://github.com/ClickHouse/ClickHouse/pull/8786) ([Mikhail Korotov](https://github.com/millb)) -* Added function `ifNotFinite`. It is just a syntactic sugar: `ifNotFinite(x, y) = isFinite(x) ? x : y`. [#8710](https://github.com/ClickHouse/ClickHouse/pull/8710) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added `last_successful_update_time` column in `system.dictionaries` table [#9394](https://github.com/ClickHouse/ClickHouse/pull/9394) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Add `blockSerializedSize` function (size on disk without compression) [#8952](https://github.com/ClickHouse/ClickHouse/pull/8952) ([Azat Khuzhin](https://github.com/azat)) -* Add function `moduloOrZero` [#9358](https://github.com/ClickHouse/ClickHouse/pull/9358) ([hcz](https://github.com/hczhcz)) -* Added system tables `system.zeros` and `system.zeros_mt` as well as tale functions `zeros()` and `zeros_mt()`. Tables (and table functions) contain single column with name `zero` and type `UInt8`. This column contains zeros. It is needed for test purposes as the fastest method to generate many rows. This fixes [#6604](https://github.com/ClickHouse/ClickHouse/issues/6604) [#9593](https://github.com/ClickHouse/ClickHouse/pull/9593) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - -#### Experimental Feature -* Add new compact format of parts in `MergeTree`-family tables in which all columns are stored in one file. It helps to increase performance of small and frequent inserts. The old format (one file per column) is now called wide. Data storing format is controlled by settings `min_bytes_for_wide_part` and `min_rows_for_wide_part`. [#8290](https://github.com/ClickHouse/ClickHouse/pull/8290) ([Anton Popov](https://github.com/CurtizJ)) -* Support for S3 storage for `Log`, `TinyLog` and `StripeLog` tables. [#8862](https://github.com/ClickHouse/ClickHouse/pull/8862) ([Pavel Kovalenko](https://github.com/Jokser)) - -#### Bug Fix -* Fixed inconsistent whitespaces in log messages. [#9322](https://github.com/ClickHouse/ClickHouse/pull/9322) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix bug in which arrays of unnamed tuples were flattened as Nested structures on table creation. [#8866](https://github.com/ClickHouse/ClickHouse/pull/8866) ([achulkov2](https://github.com/achulkov2)) -* Fixed the issue when "Too many open files" error may happen if there are too many files matching glob pattern in `File` table or `file` table function. Now files are opened lazily. This fixes [#8857](https://github.com/ClickHouse/ClickHouse/issues/8857) [#8861](https://github.com/ClickHouse/ClickHouse/pull/8861) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* DROP TEMPORARY TABLE now drops only temporary table. [#8907](https://github.com/ClickHouse/ClickHouse/pull/8907) ([Vitaly Baranov](https://github.com/vitlibar)) -* Remove outdated partition when we shutdown the server or DETACH/ATTACH a table. [#8602](https://github.com/ClickHouse/ClickHouse/pull/8602) ([Guillaume Tassery](https://github.com/YiuRULE)) -* For how the default disk calculates the free space from `data` subdirectory. Fixed the issue when the amount of free space is not calculated correctly if the `data` directory is mounted to a separate device (rare case). This fixes [#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) [#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) ([Mikhail Korotov](https://github.com/millb)) -* Allow comma (cross) join with IN () inside. [#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) ([Artem Zuikov](https://github.com/4ertus2)) -* Allow to rewrite CROSS to INNER JOIN if there's [NOT] LIKE operator in WHERE section. [#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) ([Artem Zuikov](https://github.com/4ertus2)) -* Fix possible incorrect result after `GROUP BY` with enabled setting `distributed_aggregation_memory_efficient`. Fixes [#9134](https://github.com/ClickHouse/ClickHouse/issues/9134). [#9289](https://github.com/ClickHouse/ClickHouse/pull/9289) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Found keys were counted as missed in metrics of cache dictionaries. [#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Fix replication protocol incompatibility introduced in [#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([alesapin](https://github.com/alesapin)) -* Fixed race condition on `queue_task_handle` at the startup of `ReplicatedMergeTree` tables. [#9552](https://github.com/ClickHouse/ClickHouse/pull/9552) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* The token `NOT` didn't work in `SHOW TABLES NOT LIKE` query [#8727](https://github.com/ClickHouse/ClickHouse/issues/8727) [#8940](https://github.com/ClickHouse/ClickHouse/pull/8940) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added range check to function `h3EdgeLengthM`. Without this check, buffer overflow is possible. [#8945](https://github.com/ClickHouse/ClickHouse/pull/8945) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed up a bug in batched calculations of ternary logical OPs on multiple arguments (more than 10). [#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([Alexander Kazakov](https://github.com/Akazz)) -* Fix error of PREWHERE optimization, which could lead to segfaults or `Inconsistent number of columns got from MergeTreeRangeReader` exception. [#9024](https://github.com/ClickHouse/ClickHouse/pull/9024) ([Anton Popov](https://github.com/CurtizJ)) -* Fix unexpected `Timeout exceeded while reading from socket` exception, which randomly happens on secure connection before timeout actually exceeded and when query profiler is enabled. Also add `connect_timeout_with_failover_secure_ms` settings (default 100ms), which is similar to `connect_timeout_with_failover_ms`, but is used for secure connections (because SSL handshake is slower, than ordinary TCP connection) [#9026](https://github.com/ClickHouse/ClickHouse/pull/9026) ([tavplubix](https://github.com/tavplubix)) -* Fix bug with mutations finalization, when mutation may hang in state with `parts_to_do=0` and `is_done=0`. [#9022](https://github.com/ClickHouse/ClickHouse/pull/9022) ([alesapin](https://github.com/alesapin)) -* Use new ANY JOIN logic with `partial_merge_join` setting. It's possible to make `ANY|ALL|SEMI LEFT` and `ALL INNER` joins with `partial_merge_join=1` now. [#8932](https://github.com/ClickHouse/ClickHouse/pull/8932) ([Artem Zuikov](https://github.com/4ertus2)) -* Shard now clamps the settings got from the initiator to the shard's constaints instead of throwing an exception. This fix allows to send queries to a shard with another constraints. [#9447](https://github.com/ClickHouse/ClickHouse/pull/9447) ([Vitaly Baranov](https://github.com/vitlibar)) -* Fixed memory management problem in `MergeTreeReadPool`. [#8791](https://github.com/ClickHouse/ClickHouse/pull/8791) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix `toDecimal*OrNull()` functions family when called with string `e`. Fixes [#8312](https://github.com/ClickHouse/ClickHouse/issues/8312) [#8764](https://github.com/ClickHouse/ClickHouse/pull/8764) ([Artem Zuikov](https://github.com/4ertus2)) -* Make sure that `FORMAT Null` sends no data to the client. [#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Fix bug that timestamp in `LiveViewBlockInputStream` will not updated. `LIVE VIEW` is an experimental feature. [#8644](https://github.com/ClickHouse/ClickHouse/pull/8644) ([vxider](https://github.com/Vxider)) [#8625](https://github.com/ClickHouse/ClickHouse/pull/8625) ([vxider](https://github.com/Vxider)) -* Fixed `ALTER MODIFY TTL` wrong behavior which did not allow to delete old TTL expressions. [#8422](https://github.com/ClickHouse/ClickHouse/pull/8422) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fixed UBSan report in MergeTreeIndexSet. This fixes [#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) [#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed the behaviour of `match` and `extract` functions when haystack has zero bytes. The behaviour was wrong when haystack was constant. This fixes [#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([alexey-milovidov](https://github.com/alexey-milovidov)) [#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Avoid throwing from destructor in Apache Avro 3rd-party library. [#9066](https://github.com/ClickHouse/ClickHouse/pull/9066) ([Andrew Onyshchuk](https://github.com/oandrew)) -* Don't commit a batch polled from `Kafka` partially as it can lead to holes in data. [#8876](https://github.com/ClickHouse/ClickHouse/pull/8876) ([filimonov](https://github.com/filimonov)) -* Fix `joinGet` with nullable return types. https://github.com/ClickHouse/ClickHouse/issues/8919 [#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) ([Amos Bird](https://github.com/amosbird)) -* Fix data incompatibility when compressed with `T64` codec. [#9016](https://github.com/ClickHouse/ClickHouse/pull/9016) ([Artem Zuikov](https://github.com/4ertus2)) Fix data type ids in `T64` compression codec that leads to wrong (de)compression in affected versions. [#9033](https://github.com/ClickHouse/ClickHouse/pull/9033) ([Artem Zuikov](https://github.com/4ertus2)) -* Add setting `enable_early_constant_folding` and disable it in some cases that leads to errors. [#9010](https://github.com/ClickHouse/ClickHouse/pull/9010) ([Artem Zuikov](https://github.com/4ertus2)) -* Fix pushdown predicate optimizer with VIEW and enable the test [#9011](https://github.com/ClickHouse/ClickHouse/pull/9011) ([Winter Zhang](https://github.com/zhang2014)) -* Fix segfault in `Merge` tables, that can happen when reading from `File` storages [#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) ([tavplubix](https://github.com/tavplubix)) -* Added a check for storage policy in `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE`. Otherwise it could make data of part inaccessible after restart and prevent ClickHouse to start. [#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix alters if there is TTL set for table. [#8800](https://github.com/ClickHouse/ClickHouse/pull/8800) ([Anton Popov](https://github.com/CurtizJ)) -* Fix race condition that can happen when `SYSTEM RELOAD ALL DICTIONARIES` is executed while some dictionary is being modified/added/removed. [#8801](https://github.com/ClickHouse/ClickHouse/pull/8801) ([Vitaly Baranov](https://github.com/vitlibar)) -* In previous versions `Memory` database engine use empty data path, so tables are created in `path` directory (e.g. `/var/lib/clickhouse/`), not in data directory of database (e.g. `/var/lib/clickhouse/db_name`). [#8753](https://github.com/ClickHouse/ClickHouse/pull/8753) ([tavplubix](https://github.com/tavplubix)) -* Fixed wrong log messages about missing default disk or policy. [#9530](https://github.com/ClickHouse/ClickHouse/pull/9530) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix not(has()) for the bloom_filter index of array types. [#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([achimbab](https://github.com/achimbab)) -* Allow first column(s) in a table with `Log` engine be an alias [#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) ([Ivan](https://github.com/abyss7)) -* Fix order of ranges while reading from `MergeTree` table in one thread. It could lead to exceptions from `MergeTreeRangeReader` or wrong query results. [#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) ([Anton Popov](https://github.com/CurtizJ)) -* Make `reinterpretAsFixedString` to return `FixedString` instead of `String`. [#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) ([Andrew Onyshchuk](https://github.com/oandrew)) -* Avoid extremely rare cases when the user can get wrong error message (`Success` instead of detailed error description). [#9457](https://github.com/ClickHouse/ClickHouse/pull/9457) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Do not crash when using `Template` format with empty row template. [#8785](https://github.com/ClickHouse/ClickHouse/pull/8785) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Metadata files for system tables could be created in wrong place [#8653](https://github.com/ClickHouse/ClickHouse/pull/8653) ([tavplubix](https://github.com/tavplubix)) Fixes [#8581](https://github.com/ClickHouse/ClickHouse/issues/8581). -* Fix data race on exception_ptr in cache dictionary [#8303](https://github.com/ClickHouse/ClickHouse/issues/8303). [#9379](https://github.com/ClickHouse/ClickHouse/pull/9379) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Do not throw an exception for query `ATTACH TABLE IF NOT EXISTS`. Previously it was thrown if table already exists, despite the `IF NOT EXISTS` clause. [#8967](https://github.com/ClickHouse/ClickHouse/pull/8967) ([Anton Popov](https://github.com/CurtizJ)) -* Fixed missing closing paren in exception message. [#8811](https://github.com/ClickHouse/ClickHouse/pull/8811) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Avoid message `Possible deadlock avoided` at the startup of clickhouse-client in interactive mode. [#9455](https://github.com/ClickHouse/ClickHouse/pull/9455) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed the issue when padding at the end of base64 encoded value can be malformed. Update base64 library. This fixes [#9491](https://github.com/ClickHouse/ClickHouse/issues/9491), closes [#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Prevent losing data in `Kafka` in rare cases when exception happens after reading suffix but before commit. Fixes [#9378](https://github.com/ClickHouse/ClickHouse/issues/9378) [#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) ([filimonov](https://github.com/filimonov)) -* Fixed exception in `DROP TABLE IF EXISTS` [#8663](https://github.com/ClickHouse/ClickHouse/pull/8663) ([Nikita Vasilev](https://github.com/nikvas0)) -* Fix crash when a user tries to `ALTER MODIFY SETTING` for old-formated `MergeTree` table engines family. [#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([alesapin](https://github.com/alesapin)) -* Support for UInt64 numbers that don't fit in Int64 in JSON-related functions. Update SIMDJSON to master. This fixes [#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) [#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed execution of inversed predicates when non-strictly monotinic functional index is used. [#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) ([Alexander Kazakov](https://github.com/Akazz)) -* Don't try to fold `IN` constant in `GROUP BY` [#8868](https://github.com/ClickHouse/ClickHouse/pull/8868) ([Amos Bird](https://github.com/amosbird)) -* Fix bug in `ALTER DELETE` mutations which leads to index corruption. This fixes [#9019](https://github.com/ClickHouse/ClickHouse/issues/9019) and [#8982](https://github.com/ClickHouse/ClickHouse/issues/8982). Additionally fix extremely rare race conditions in `ReplicatedMergeTree` `ALTER` queries. [#9048](https://github.com/ClickHouse/ClickHouse/pull/9048) ([alesapin](https://github.com/alesapin)) -* When the setting `compile_expressions` is enabled, you can get `unexpected column` in `LLVMExecutableFunction` when we use `Nullable` type [#8910](https://github.com/ClickHouse/ClickHouse/pull/8910) ([Guillaume Tassery](https://github.com/YiuRULE)) -* Multiple fixes for `Kafka` engine: 1) fix duplicates that were appearing during consumer group rebalance. 2) Fix rare 'holes' appeared when data were polled from several partitions with one poll and committed partially (now we always process / commit the whole polled block of messages). 3) Fix flushes by block size (before that only flushing by timeout was working properly). 4) better subscription procedure (with assignment feedback). 5) Make tests work faster (with default intervals and timeouts). Due to the fact that data was not flushed by block size before (as it should according to documentation), that PR may lead to some performance degradation with default settings (due to more often & tinier flushes which are less optimal). If you encounter the performance issue after that change - please increase `kafka_max_block_size` in the table to the bigger value ( for example `CREATE TABLE ...Engine=Kafka ... SETTINGS ... kafka_max_block_size=524288`). Fixes [#7259](https://github.com/ClickHouse/ClickHouse/issues/7259) [#8917](https://github.com/ClickHouse/ClickHouse/pull/8917) ([filimonov](https://github.com/filimonov)) -* Fix `Parameter out of bound` exception in some queries after PREWHERE optimizations. [#8914](https://github.com/ClickHouse/ClickHouse/pull/8914) ([Baudouin Giard](https://github.com/bgiard)) -* Fixed the case of mixed-constness of arguments of function `arrayZip`. [#8705](https://github.com/ClickHouse/ClickHouse/pull/8705) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* When executing `CREATE` query, fold constant expressions in storage engine arguments. Replace empty database name with current database. Fixes [#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [#3492](https://github.com/ClickHouse/ClickHouse/issues/3492) [#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) ([tavplubix](https://github.com/tavplubix)) -* Now it's not possible to create or add columns with simple cyclic aliases like `a DEFAULT b, b DEFAULT a`. [#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([alesapin](https://github.com/alesapin)) -* Fixed a bug with double move which may corrupt original part. This is relevant if you use `ALTER TABLE MOVE` [#8680](https://github.com/ClickHouse/ClickHouse/pull/8680) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Allow `interval` identifier to correctly parse without backticks. Fixed issue when a query cannot be executed even if the `interval` identifier is enclosed in backticks or double quotes. This fixes [#9124](https://github.com/ClickHouse/ClickHouse/issues/9124). [#9142](https://github.com/ClickHouse/ClickHouse/pull/9142) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed fuzz test and incorrect behaviour of `bitTestAll`/`bitTestAny` functions. [#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix possible crash/wrong number of rows in `LIMIT n WITH TIES` when there are a lot of rows equal to n'th row. [#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([tavplubix](https://github.com/tavplubix)) -* Fix mutations with parts written with enabled `insert_quorum`. [#9463](https://github.com/ClickHouse/ClickHouse/pull/9463) ([alesapin](https://github.com/alesapin)) -* Fix data race at destruction of `Poco::HTTPServer`. It could happen when server is started and immediately shut down. [#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([Anton Popov](https://github.com/CurtizJ)) -* Fix bug in which a misleading error message was shown when running `SHOW CREATE TABLE a_table_that_does_not_exist`. [#8899](https://github.com/ClickHouse/ClickHouse/pull/8899) ([achulkov2](https://github.com/achulkov2)) -* Fixed `Parameters are out of bound` exception in some rare cases when we have a constant in the `SELECT` clause when we have an `ORDER BY` and a `LIMIT` clause. [#8892](https://github.com/ClickHouse/ClickHouse/pull/8892) ([Guillaume Tassery](https://github.com/YiuRULE)) -* Fix mutations finalization, when already done mutation can have status `is_done=0`. [#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) ([alesapin](https://github.com/alesapin)) -* Prevent from executing `ALTER ADD INDEX` for MergeTree tables with old syntax, because it doesn't work. [#8822](https://github.com/ClickHouse/ClickHouse/pull/8822) ([Mikhail Korotov](https://github.com/millb)) -* During server startup do not access table, which `LIVE VIEW` depends on, so server will be able to start. Also remove `LIVE VIEW` dependencies when detaching `LIVE VIEW`. `LIVE VIEW` is an experimental feature. [#8824](https://github.com/ClickHouse/ClickHouse/pull/8824) ([tavplubix](https://github.com/tavplubix)) -* Fix possible segfault in `MergeTreeRangeReader`, while executing `PREWHERE`. [#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) ([Anton Popov](https://github.com/CurtizJ)) -* Fix possible mismatched checksums with column TTLs. [#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([Anton Popov](https://github.com/CurtizJ)) -* Fixed a bug when parts were not being moved in background by TTL rules in case when there is only one volume. [#8672](https://github.com/ClickHouse/ClickHouse/pull/8672) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fixed the issue `Method createColumn() is not implemented for data type Set`. This fixes [#7799](https://github.com/ClickHouse/ClickHouse/issues/7799). [#8674](https://github.com/ClickHouse/ClickHouse/pull/8674) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Now we will try finalize mutations more frequently. [#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([alesapin](https://github.com/alesapin)) -* Fix `intDiv` by minus one constant [#9351](https://github.com/ClickHouse/ClickHouse/pull/9351) ([hcz](https://github.com/hczhcz)) -* Fix possible race condition in `BlockIO`. [#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix bug leading to server termination when trying to use / drop `Kafka` table created with wrong parameters. [#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) ([filimonov](https://github.com/filimonov)) -* Added workaround if OS returns wrong result for `timer_create` function. [#8837](https://github.com/ClickHouse/ClickHouse/pull/8837) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed error in usage of `min_marks_for_seek` parameter. Fixed the error message when there is no sharding key in Distributed table and we try to skip unused shards. [#8908](https://github.com/ClickHouse/ClickHouse/pull/8908) ([Azat Khuzhin](https://github.com/azat)) - -#### Improvement -* Implement `ALTER MODIFY/DROP` queries on top of mutations for `ReplicatedMergeTree*` engines family. Now `ALTERS` blocks only at the metadata update stage, and don't block after that. [#8701](https://github.com/ClickHouse/ClickHouse/pull/8701) ([alesapin](https://github.com/alesapin)) -* Add ability to rewrite CROSS to INNER JOINs with `WHERE` section containing unqialified names. [#9512](https://github.com/ClickHouse/ClickHouse/pull/9512) ([Artem Zuikov](https://github.com/4ertus2)) -* Make `SHOW TABLES` and `SHOW DATABASES` queries support the `WHERE` expressions and `FROM`/`IN` [#9076](https://github.com/ClickHouse/ClickHouse/pull/9076) ([sundyli](https://github.com/sundy-li)) -* Added a setting `deduplicate_blocks_in_dependent_materialized_views`. [#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) ([urykhy](https://github.com/urykhy)) -* After recent changes MySQL client started to print binary strings in hex thereby making them not readable ([#9032](https://github.com/ClickHouse/ClickHouse/issues/9032)). The workaround in ClickHouse is to mark string columns as UTF-8, which is not always, but usually the case. [#9079](https://github.com/ClickHouse/ClickHouse/pull/9079) ([Yuriy Baranov](https://github.com/yurriy)) -* Add support of String and FixedString keys for `sumMap` [#8903](https://github.com/ClickHouse/ClickHouse/pull/8903) ([Baudouin Giard](https://github.com/bgiard)) -* Support string keys in SummingMergeTree maps [#8933](https://github.com/ClickHouse/ClickHouse/pull/8933) ([Baudouin Giard](https://github.com/bgiard)) -* Signal termination of thread to the thread pool even if the thread has thrown exception [#8736](https://github.com/ClickHouse/ClickHouse/pull/8736) ([Ding Xiang Fei](https://github.com/dingxiangfei2009)) -* Allow to set `query_id` in `clickhouse-benchmark` [#9416](https://github.com/ClickHouse/ClickHouse/pull/9416) ([Anton Popov](https://github.com/CurtizJ)) -* Don't allow strange expressions in `ALTER TABLE ... PARTITION partition` query. This addresses [#7192](https://github.com/ClickHouse/ClickHouse/issues/7192) [#8835](https://github.com/ClickHouse/ClickHouse/pull/8835) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* The table `system.table_engines` now provides information about feature support (like `supports_ttl` or `supports_sort_order`). [#8830](https://github.com/ClickHouse/ClickHouse/pull/8830) ([Max Akhmedov](https://github.com/zlobober)) -* Enable `system.metric_log` by default. It will contain rows with values of ProfileEvents, CurrentMetrics collected with "collect_interval_milliseconds" interval (one second by default). The table is very small (usually in order of megabytes) and collecting this data by default is reasonable. [#9225](https://github.com/ClickHouse/ClickHouse/pull/9225) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries. Fixes [#6964](https://github.com/ClickHouse/ClickHouse/issues/6964) [#8874](https://github.com/ClickHouse/ClickHouse/pull/8874) ([Ivan](https://github.com/abyss7)) -* Now temporary `LIVE VIEW` is created by `CREATE LIVE VIEW name WITH TIMEOUT [42] ...` instead of `CREATE TEMPORARY LIVE VIEW ...`, because the previous syntax was not consistent with `CREATE TEMPORARY TABLE ...` [#9131](https://github.com/ClickHouse/ClickHouse/pull/9131) ([tavplubix](https://github.com/tavplubix)) -* Add text_log.level configuration parameter to limit entries that goes to `system.text_log` table [#8809](https://github.com/ClickHouse/ClickHouse/pull/8809) ([Azat Khuzhin](https://github.com/azat)) -* Allow to put downloaded part to a disks/volumes according to TTL rules [#8598](https://github.com/ClickHouse/ClickHouse/pull/8598) ([Vladimir Chebotarev](https://github.com/excitoon)) -* For external MySQL dictionaries, allow to mutualize MySQL connection pool to "share" them among dictionaries. This option significantly reduces the number of connections to MySQL servers. [#9409](https://github.com/ClickHouse/ClickHouse/pull/9409) ([Clément Rodriguez](https://github.com/clemrodriguez)) -* Show nearest query execution time for quantiles in `clickhouse-benchmark` output instead of interpolated values. It's better to show values that correspond to the execution time of some queries. [#8712](https://github.com/ClickHouse/ClickHouse/pull/8712) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Possibility to add key & timestamp for the message when inserting data to Kafka. Fixes [#7198](https://github.com/ClickHouse/ClickHouse/issues/7198) [#8969](https://github.com/ClickHouse/ClickHouse/pull/8969) ([filimonov](https://github.com/filimonov)) -* If server is run from terminal, highlight thread number, query id and log priority by colors. This is for improved readability of correlated log messages for developers. [#8961](https://github.com/ClickHouse/ClickHouse/pull/8961) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Better exception message while loading tables for `Ordinary` database. [#9527](https://github.com/ClickHouse/ClickHouse/pull/9527) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Implement `arraySlice` for arrays with aggregate function states. This fixes [#9388](https://github.com/ClickHouse/ClickHouse/issues/9388) [#9391](https://github.com/ClickHouse/ClickHouse/pull/9391) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Allow constant functions and constant arrays to be used on the right side of IN operator. [#8813](https://github.com/ClickHouse/ClickHouse/pull/8813) ([Anton Popov](https://github.com/CurtizJ)) -* If zookeeper exception has happened while fetching data for system.replicas, display it in a separate column. This implements [#9137](https://github.com/ClickHouse/ClickHouse/issues/9137) [#9138](https://github.com/ClickHouse/ClickHouse/pull/9138) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Atomically remove MergeTree data parts on destroy. [#8402](https://github.com/ClickHouse/ClickHouse/pull/8402) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Support row-level security for Distributed tables. [#8926](https://github.com/ClickHouse/ClickHouse/pull/8926) ([Ivan](https://github.com/abyss7)) -* Now we recognize suffix (like KB, KiB...) in settings values. [#8072](https://github.com/ClickHouse/ClickHouse/pull/8072) ([Mikhail Korotov](https://github.com/millb)) -* Prevent out of memory while constructing result of a large JOIN. [#8637](https://github.com/ClickHouse/ClickHouse/pull/8637) ([Artem Zuikov](https://github.com/4ertus2)) -* Added names of clusters to suggestions in interactive mode in `clickhouse-client`. [#8709](https://github.com/ClickHouse/ClickHouse/pull/8709) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries [#8820](https://github.com/ClickHouse/ClickHouse/pull/8820) ([Ivan](https://github.com/abyss7)) -* Added column `exception_code` in `system.query_log` table. [#8770](https://github.com/ClickHouse/ClickHouse/pull/8770) ([Mikhail Korotov](https://github.com/millb)) -* Enabled MySQL compatibility server on port `9004` in the default server configuration file. Fixed password generation command in the example in configuration. [#8771](https://github.com/ClickHouse/ClickHouse/pull/8771) ([Yuriy Baranov](https://github.com/yurriy)) -* Prevent abort on shutdown if the filesystem is readonly. This fixes [#9094](https://github.com/ClickHouse/ClickHouse/issues/9094) [#9100](https://github.com/ClickHouse/ClickHouse/pull/9100) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Better exception message when length is required in HTTP POST query. [#9453](https://github.com/ClickHouse/ClickHouse/pull/9453) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Add `_path` and `_file` virtual columns to `HDFS` and `File` engines and `hdfs` and `file` table functions [#8489](https://github.com/ClickHouse/ClickHouse/pull/8489) ([Olga Khvostikova](https://github.com/stavrolia)) -* Fix error `Cannot find column` while inserting into `MATERIALIZED VIEW` in case if new column was added to view's internal table. [#8766](https://github.com/ClickHouse/ClickHouse/pull/8766) [#8788](https://github.com/ClickHouse/ClickHouse/pull/8788) ([vzakaznikov](https://github.com/vzakaznikov)) [#8788](https://github.com/ClickHouse/ClickHouse/issues/8788) [#8806](https://github.com/ClickHouse/ClickHouse/pull/8806) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [#8803](https://github.com/ClickHouse/ClickHouse/pull/8803) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix progress over native client-server protocol, by send progress after final update (like logs). This may be relevant only to some third-party tools that are using native protocol. [#9495](https://github.com/ClickHouse/ClickHouse/pull/9495) ([Azat Khuzhin](https://github.com/azat)) -* Add a system metric tracking the number of client connections using MySQL protocol ([#9013](https://github.com/ClickHouse/ClickHouse/issues/9013)). [#9015](https://github.com/ClickHouse/ClickHouse/pull/9015) ([Eugene Klimov](https://github.com/Slach)) -* From now on, HTTP responses will have `X-ClickHouse-Timezone` header set to the same timezone value that `SELECT timezone()` would report. [#9493](https://github.com/ClickHouse/ClickHouse/pull/9493) ([Denis Glazachev](https://github.com/traceon)) - -#### Performance Improvement -* Improve performance of analysing index with IN [#9261](https://github.com/ClickHouse/ClickHouse/pull/9261) ([Anton Popov](https://github.com/CurtizJ)) -* Simpler and more efficient code in Logical Functions + code cleanups. A followup to [#8718](https://github.com/ClickHouse/ClickHouse/issues/8718) [#8728](https://github.com/ClickHouse/ClickHouse/pull/8728) ([Alexander Kazakov](https://github.com/Akazz)) -* Overall performance improvement (in range of 5%..200% for affected queries) by ensuring even more strict aliasing with C++20 features. [#9304](https://github.com/ClickHouse/ClickHouse/pull/9304) ([Amos Bird](https://github.com/amosbird)) -* More strict aliasing for inner loops of comparison functions. [#9327](https://github.com/ClickHouse/ClickHouse/pull/9327) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* More strict aliasing for inner loops of arithmetic functions. [#9325](https://github.com/ClickHouse/ClickHouse/pull/9325) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* A ~3 times faster implementation for ColumnVector::replicate(), via which ColumnConst::convertToFullColumn() is implemented. Also will be useful in tests when materializing constants. [#9293](https://github.com/ClickHouse/ClickHouse/pull/9293) ([Alexander Kazakov](https://github.com/Akazz)) -* Another minor performance improvement to `ColumnVector::replicate()` (this speeds up the `materialize` function and higher order functions) an even further improvement to [#9293](https://github.com/ClickHouse/ClickHouse/issues/9293) [#9442](https://github.com/ClickHouse/ClickHouse/pull/9442) ([Alexander Kazakov](https://github.com/Akazz)) -* Improved performance of `stochasticLinearRegression` aggregate function. This patch is contributed by Intel. [#8652](https://github.com/ClickHouse/ClickHouse/pull/8652) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Improve performance of `reinterpretAsFixedString` function. [#9342](https://github.com/ClickHouse/ClickHouse/pull/9342) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Do not send blocks to client for `Null` format in processors pipeline. [#8797](https://github.com/ClickHouse/ClickHouse/pull/8797) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) [#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -#### Build/Testing/Packaging Improvement -* Exception handling now works correctly on Windows Subsystem for Linux. See https://github.com/ClickHouse-Extras/libunwind/pull/3 This fixes [#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) -* Replace `readline` with `replxx` for interactive line editing in `clickhouse-client` [#8416](https://github.com/ClickHouse/ClickHouse/pull/8416) ([Ivan](https://github.com/abyss7)) -* Better build time and less template instantiations in FunctionsComparison. [#9324](https://github.com/ClickHouse/ClickHouse/pull/9324) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added integration with `clang-tidy` in CI. See also [#6044](https://github.com/ClickHouse/ClickHouse/issues/6044) [#9566](https://github.com/ClickHouse/ClickHouse/pull/9566) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Now we link ClickHouse in CI using `lld` even for `gcc`. [#9049](https://github.com/ClickHouse/ClickHouse/pull/9049) ([alesapin](https://github.com/alesapin)) -* Allow to randomize thread scheduling and insert glitches when `THREAD_FUZZER_*` environment variables are set. This helps testing. [#9459](https://github.com/ClickHouse/ClickHouse/pull/9459) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Enable secure sockets in stateless tests [#9288](https://github.com/ClickHouse/ClickHouse/pull/9288) ([tavplubix](https://github.com/tavplubix)) -* Make SPLIT_SHARED_LIBRARIES=OFF more robust [#9156](https://github.com/ClickHouse/ClickHouse/pull/9156) ([Azat Khuzhin](https://github.com/azat)) -* Make "performance_introspection_and_logging" test reliable to random server stuck. This may happen in CI environment. See also [#9515](https://github.com/ClickHouse/ClickHouse/issues/9515) [#9528](https://github.com/ClickHouse/ClickHouse/pull/9528) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Validate XML in style check. [#9550](https://github.com/ClickHouse/ClickHouse/pull/9550) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed race condition in test `00738_lock_for_inner_table`. This test relied on sleep. [#9555](https://github.com/ClickHouse/ClickHouse/pull/9555) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Remove performance tests of type `once`. This is needed to run all performance tests in statistical comparison mode (more reliable). [#9557](https://github.com/ClickHouse/ClickHouse/pull/9557) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added performance test for arithmetic functions. [#9326](https://github.com/ClickHouse/ClickHouse/pull/9326) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added performance test for `sumMap` and `sumMapWithOverflow` aggregate functions. Follow-up for [#8933](https://github.com/ClickHouse/ClickHouse/issues/8933) [#8947](https://github.com/ClickHouse/ClickHouse/pull/8947) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Ensure style of ErrorCodes by style check. [#9370](https://github.com/ClickHouse/ClickHouse/pull/9370) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Add script for tests history. [#8796](https://github.com/ClickHouse/ClickHouse/pull/8796) ([alesapin](https://github.com/alesapin)) -* Add GCC warning `-Wsuggest-override` to locate and fix all places where `override` keyword must be used. [#8760](https://github.com/ClickHouse/ClickHouse/pull/8760) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -* Ignore weak symbol under Mac OS X because it must be defined [#9538](https://github.com/ClickHouse/ClickHouse/pull/9538) ([Deleted user](https://github.com/ghost)) -* Normalize running time of some queries in performance tests. This is done in preparation to run all the performance tests in comparison mode. [#9565](https://github.com/ClickHouse/ClickHouse/pull/9565) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix some tests to support pytest with query tests [#9062](https://github.com/ClickHouse/ClickHouse/pull/9062) ([Ivan](https://github.com/abyss7)) -* Enable SSL in build with MSan, so server will not fail at startup when running stateless tests [#9531](https://github.com/ClickHouse/ClickHouse/pull/9531) ([tavplubix](https://github.com/tavplubix)) -* Fix database substitution in test results [#9384](https://github.com/ClickHouse/ClickHouse/pull/9384) ([Ilya Yatsishin](https://github.com/qoega)) -* Build fixes for miscellaneous platforms [#9381](https://github.com/ClickHouse/ClickHouse/pull/9381) ([proller](https://github.com/proller)) [#8755](https://github.com/ClickHouse/ClickHouse/pull/8755) ([proller](https://github.com/proller)) [#8631](https://github.com/ClickHouse/ClickHouse/pull/8631) ([proller](https://github.com/proller)) -* Added disks section to stateless-with-coverage test docker image [#9213](https://github.com/ClickHouse/ClickHouse/pull/9213) ([Pavel Kovalenko](https://github.com/Jokser)) -* Get rid of in-source-tree files when building with GRPC [#9588](https://github.com/ClickHouse/ClickHouse/pull/9588) ([Amos Bird](https://github.com/amosbird)) -* Slightly faster build time by removing SessionCleaner from Context. Make the code of SessionCleaner more simple. [#9232](https://github.com/ClickHouse/ClickHouse/pull/9232) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Updated checking for hung queries in clickhouse-test script [#8858](https://github.com/ClickHouse/ClickHouse/pull/8858) ([Alexander Kazakov](https://github.com/Akazz)) -* Removed some useless files from repository. [#8843](https://github.com/ClickHouse/ClickHouse/pull/8843) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Changed type of math perftests from `once` to `loop`. [#8783](https://github.com/ClickHouse/ClickHouse/pull/8783) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Add docker image which allows to build interactive code browser HTML report for our codebase. [#8781](https://github.com/ClickHouse/ClickHouse/pull/8781) ([alesapin](https://github.com/alesapin)) See [Woboq Code Browser](https://clickhouse.tech/codebrowser/html_report///ClickHouse/dbms/src/index.html) -* Suppress some test failures under MSan. [#8780](https://github.com/ClickHouse/ClickHouse/pull/8780) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Speedup "exception while insert" test. This test often time out in debug-with-coverage build. [#8711](https://github.com/ClickHouse/ClickHouse/pull/8711) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Updated `libcxx` and `libcxxabi` to master. In preparation to [#9304](https://github.com/ClickHouse/ClickHouse/issues/9304) [#9308](https://github.com/ClickHouse/ClickHouse/pull/9308) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix flacky test `00910_zookeeper_test_alter_compression_codecs`. [#9525](https://github.com/ClickHouse/ClickHouse/pull/9525) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Clean up duplicated linker flags. Make sure the linker won't look up an unexpected symbol. [#9433](https://github.com/ClickHouse/ClickHouse/pull/9433) ([Amos Bird](https://github.com/amosbird)) -* Add `clickhouse-odbc` driver into test images. This allows to test interaction of ClickHouse with ClickHouse via its own ODBC driver. [#9348](https://github.com/ClickHouse/ClickHouse/pull/9348) ([filimonov](https://github.com/filimonov)) -* Fix several bugs in unit tests. [#9047](https://github.com/ClickHouse/ClickHouse/pull/9047) ([alesapin](https://github.com/alesapin)) -* Enable `-Wmissing-include-dirs` GCC warning to eliminate all non-existing includes - mostly as a result of CMake scripting errors [#8704](https://github.com/ClickHouse/ClickHouse/pull/8704) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -* Describe reasons if query profiler cannot work. This is intended for [#9049](https://github.com/ClickHouse/ClickHouse/issues/9049) [#9144](https://github.com/ClickHouse/ClickHouse/pull/9144) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Update OpenSSL to upstream master. Fixed the issue when TLS connections may fail with the message `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error` and `SSL Exception: error:2400006E:random number generator::error retrieving entropy`. The issue was present in version 20.1. [#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Update Dockerfile for server [#8893](https://github.com/ClickHouse/ClickHouse/pull/8893) ([Ilya Mazaev](https://github.com/ne-ray)) -* Minor fixes in build-gcc-from-sources script [#8774](https://github.com/ClickHouse/ClickHouse/pull/8774) ([Michael Nacharov](https://github.com/mnach)) -* Replace `numbers` to `zeros` in perftests where `number` column is not used. This will lead to more clean test results. [#9600](https://github.com/ClickHouse/ClickHouse/pull/9600) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix stack overflow issue when using initializer_list in Column constructors. [#9367](https://github.com/ClickHouse/ClickHouse/pull/9367) ([Deleted user](https://github.com/ghost)) -* Upgrade librdkafka to v1.3.0. Enable bundled `rdkafka` and `gsasl` libraries on Mac OS X. [#9000](https://github.com/ClickHouse/ClickHouse/pull/9000) ([Andrew Onyshchuk](https://github.com/oandrew)) -* build fix on GCC 9.2.0 [#9306](https://github.com/ClickHouse/ClickHouse/pull/9306) ([vxider](https://github.com/Vxider)) - - -## ClickHouse release v20.1 - -### ClickHouse release v20.1.8.41, 2020-03-20 - -#### Bug Fix -* Fix possible permanent `Cannot schedule a task` error (due to unhandled exception in `ParallelAggregatingBlockInputStream::Handler::onFinish/onFinishThread`). This fixes [#6833](https://github.com/ClickHouse/ClickHouse/issues/6833). [#9154](https://github.com/ClickHouse/ClickHouse/pull/9154) ([Azat Khuzhin](https://github.com/azat)) -* Fix excessive memory consumption in `ALTER` queries (mutations). This fixes [#9533](https://github.com/ClickHouse/ClickHouse/issues/9533) and [#9670](https://github.com/ClickHouse/ClickHouse/issues/9670). [#9754](https://github.com/ClickHouse/ClickHouse/pull/9754) ([alesapin](https://github.com/alesapin)) -* Fix bug in backquoting in external dictionaries DDL. This fixes [#9619](https://github.com/ClickHouse/ClickHouse/issues/9619). [#9734](https://github.com/ClickHouse/ClickHouse/pull/9734) ([alesapin](https://github.com/alesapin)) - -### ClickHouse release v20.1.7.38, 2020-03-18 - -#### Bug Fix -* Fixed incorrect internal function names for `sumKahan` and `sumWithOverflow`. I lead to exception while using this functions in remote queries. [#9636](https://github.com/ClickHouse/ClickHouse/pull/9636) ([Azat Khuzhin](https://github.com/azat)). This issue was in all ClickHouse releases. -* Allow `ALTER ON CLUSTER` of `Distributed` tables with internal replication. This fixes [#3268](https://github.com/ClickHouse/ClickHouse/issues/3268). [#9617](https://github.com/ClickHouse/ClickHouse/pull/9617) ([shinoi2](https://github.com/shinoi2)). This issue was in all ClickHouse releases. -* Fix possible exceptions `Size of filter doesn't match size of column` and `Invalid number of rows in Chunk` in `MergeTreeRangeReader`. They could appear while executing `PREWHERE` in some cases. Fixes [#9132](https://github.com/ClickHouse/ClickHouse/issues/9132). [#9612](https://github.com/ClickHouse/ClickHouse/pull/9612) ([Anton Popov](https://github.com/CurtizJ)) -* Fixed the issue: timezone was not preserved if you write a simple arithmetic expression like `time + 1` (in contrast to an expression like `time + INTERVAL 1 SECOND`). This fixes [#5743](https://github.com/ClickHouse/ClickHouse/issues/5743). [#9323](https://github.com/ClickHouse/ClickHouse/pull/9323) ([alexey-milovidov](https://github.com/alexey-milovidov)). This issue was in all ClickHouse releases. -* Now it's not possible to create or add columns with simple cyclic aliases like `a DEFAULT b, b DEFAULT a`. [#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([alesapin](https://github.com/alesapin)) -* Fixed the issue when padding at the end of base64 encoded value can be malformed. Update base64 library. This fixes [#9491](https://github.com/ClickHouse/ClickHouse/issues/9491), closes [#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix data race at destruction of `Poco::HTTPServer`. It could happen when server is started and immediately shut down. [#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([Anton Popov](https://github.com/CurtizJ)) -* Fix possible crash/wrong number of rows in `LIMIT n WITH TIES` when there are a lot of rows equal to n'th row. [#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([tavplubix](https://github.com/tavplubix)) -* Fix possible mismatched checksums with column TTLs. [#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([Anton Popov](https://github.com/CurtizJ)) -* Fix crash when a user tries to `ALTER MODIFY SETTING` for old-formated `MergeTree` table engines family. [#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([alesapin](https://github.com/alesapin)) -* Now we will try finalize mutations more frequently. [#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([alesapin](https://github.com/alesapin)) -* Fix replication protocol incompatibility introduced in [#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([alesapin](https://github.com/alesapin)) -* Fix not(has()) for the bloom_filter index of array types. [#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([achimbab](https://github.com/achimbab)) -* Fixed the behaviour of `match` and `extract` functions when haystack has zero bytes. The behaviour was wrong when haystack was constant. This fixes [#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([alexey-milovidov](https://github.com/alexey-milovidov)) [#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Build/Testing/Packaging Improvement - -* Exception handling now works correctly on Windows Subsystem for Linux. See https://github.com/ClickHouse-Extras/libunwind/pull/3 This fixes [#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) - - -### ClickHouse release v20.1.6.30, 2020-03-05 - -#### Bug Fix - -* Fix data incompatibility when compressed with `T64` codec. -[#9039](https://github.com/ClickHouse/ClickHouse/pull/9039) [(abyss7)](https://github.com/abyss7) -* Fix order of ranges while reading from MergeTree table in one thread. Fixes [#8964](https://github.com/ClickHouse/ClickHouse/issues/8964). -[#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) [(CurtizJ)](https://github.com/CurtizJ) -* Fix possible segfault in `MergeTreeRangeReader`, while executing `PREWHERE`. Fixes [#9064](https://github.com/ClickHouse/ClickHouse/issues/9064). -[#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) [(CurtizJ)](https://github.com/CurtizJ) -* Fix `reinterpretAsFixedString` to return `FixedString` instead of `String`. -[#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) [(oandrew)](https://github.com/oandrew) -* Fix `joinGet` with nullable return types. Fixes [#8919](https://github.com/ClickHouse/ClickHouse/issues/8919) -[#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) [(amosbird)](https://github.com/amosbird) -* Fix fuzz test and incorrect behaviour of bitTestAll/bitTestAny functions. -[#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) [(alexey-milovidov)](https://github.com/alexey-milovidov) -* Fix the behaviour of match and extract functions when haystack has zero bytes. The behaviour was wrong when haystack was constant. Fixes [#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) -[#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) [(alexey-milovidov)](https://github.com/alexey-milovidov) -* Fixed execution of inversed predicates when non-strictly monotinic functional index is used. Fixes [#9034](https://github.com/ClickHouse/ClickHouse/issues/9034) -[#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) [(Akazz)](https://github.com/Akazz) -* Allow to rewrite `CROSS` to `INNER JOIN` if there's `[NOT] LIKE` operator in `WHERE` section. Fixes [#9191](https://github.com/ClickHouse/ClickHouse/issues/9191) -[#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) [(4ertus2)](https://github.com/4ertus2) -* Allow first column(s) in a table with Log engine be an alias. -[#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) [(abyss7)](https://github.com/abyss7) -* Allow comma join with `IN()` inside. Fixes [#7314](https://github.com/ClickHouse/ClickHouse/issues/7314). -[#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) [(4ertus2)](https://github.com/4ertus2) -* Improve `ALTER MODIFY/ADD` queries logic. Now you cannot `ADD` column without type, `MODIFY` default expression doesn't change type of column and `MODIFY` type doesn't loose default expression value. Fixes [#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). -[#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) [(alesapin)](https://github.com/alesapin) -* Fix mutations finalization, when already done mutation can have status is_done=0. -[#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) [(alesapin)](https://github.com/alesapin) -* Support "Processors" pipeline for system.numbers and system.numbers_mt. This also fixes the bug when `max_execution_time` is not respected. -[#7796](https://github.com/ClickHouse/ClickHouse/pull/7796) [(KochetovNicolai)](https://github.com/KochetovNicolai) -* Fix wrong counting of `DictCacheKeysRequestedFound` metric. -[#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) [(nikitamikhaylov)](https://github.com/nikitamikhaylov) -* Added a check for storage policy in `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE` which otherwise could make data of part inaccessible after restart and prevent ClickHouse to start. -[#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) [(excitoon)](https://github.com/excitoon) -* Fixed UBSan report in `MergeTreeIndexSet`. This fixes [#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) -[#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) [(alexey-milovidov)](https://github.com/alexey-milovidov) -* Fix possible datarace in BlockIO. -[#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) [(KochetovNicolai)](https://github.com/KochetovNicolai) -* Support for `UInt64` numbers that don't fit in Int64 in JSON-related functions. Update `SIMDJSON` to master. This fixes [#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) -[#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) [(alexey-milovidov)](https://github.com/alexey-milovidov) -* Fix the issue when the amount of free space is not calculated correctly if the data directory is mounted to a separate device. For default disk calculate the free space from data subdirectory. This fixes [#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) -[#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) [(millb)](https://github.com/millb) -* Fix the issue when TLS connections may fail with the message `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error and SSL Exception: error:2400006E:random number generator::error retrieving entropy.` Update OpenSSL to upstream master. -[#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) [(alexey-milovidov)](https://github.com/alexey-milovidov) -* When executing `CREATE` query, fold constant expressions in storage engine arguments. Replace empty database name with current database. Fixes [#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). Also fix check for local address in ClickHouseDictionarySource. -[#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) -* Fix segfault in `StorageMerge`, which can happen when reading from StorageFile. -[#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) [(tabplubix)](https://github.com/tavplubix) -* Prevent losing data in `Kafka` in rare cases when exception happens after reading suffix but before commit. Fixes [#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). Related: [#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) -[#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(filimonov)](https://github.com/filimonov) -* Fix bug leading to server termination when trying to use / drop `Kafka` table created with wrong parameters. Fixes [#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). Incorporates [#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). -[#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(filimonov)](https://github.com/filimonov) - -#### New Feature -* Add `deduplicate_blocks_in_dependent_materialized_views` option to control the behaviour of idempotent inserts into tables with materialized views. This new feature was added to the bugfix release by a special request from Altinity. -[#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) - -### ClickHouse release v20.1.2.4, 2020-01-22 - -#### Backward Incompatible Change -* Make the setting `merge_tree_uniform_read_distribution` obsolete. The server still recognizes this setting but it has no effect. [#8308](https://github.com/ClickHouse/ClickHouse/pull/8308) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Changed return type of the function `greatCircleDistance` to `Float32` because now the result of calculation is `Float32`. [#7993](https://github.com/ClickHouse/ClickHouse/pull/7993) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Now it's expected that query parameters are represented in "escaped" format. For example, to pass string `ab` you have to write `a\tb` or `a\b` and respectively, `a%5Ctb` or `a%5C%09b` in URL. This is needed to add the possibility to pass NULL as `\N`. This fixes [#7488](https://github.com/ClickHouse/ClickHouse/issues/7488). [#8517](https://github.com/ClickHouse/ClickHouse/pull/8517) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Enable `use_minimalistic_part_header_in_zookeeper` setting for `ReplicatedMergeTree` by default. This will significantly reduce amount of data stored in ZooKeeper. This setting is supported since version 19.1 and we already use it in production in multiple services without any issues for more than half a year. Disable this setting if you have a chance to downgrade to versions older than 19.1. [#6850](https://github.com/ClickHouse/ClickHouse/pull/6850) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Data skipping indices are production ready and enabled by default. The settings `allow_experimental_data_skipping_indices`, `allow_experimental_cross_to_join_conversion` and `allow_experimental_multiple_joins_emulation` are now obsolete and do nothing. [#7974](https://github.com/ClickHouse/ClickHouse/pull/7974) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Add new `ANY JOIN` logic for `StorageJoin` consistent with `JOIN` operation. To upgrade without changes in behaviour you need add `SETTINGS any_join_distinct_right_table_keys = 1` to Engine Join tables metadata or recreate these tables after upgrade. [#8400](https://github.com/ClickHouse/ClickHouse/pull/8400) ([Artem Zuikov](https://github.com/4ertus2)) -* Require server to be restarted to apply the changes in logging configuration. This is a temporary workaround to avoid the bug where the server logs to a deleted log file (see [#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -#### New Feature -* Added information about part paths to `system.merges`. [#8043](https://github.com/ClickHouse/ClickHouse/pull/8043) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Add ability to execute `SYSTEM RELOAD DICTIONARY` query in `ON CLUSTER` mode. [#8288](https://github.com/ClickHouse/ClickHouse/pull/8288) ([Guillaume Tassery](https://github.com/YiuRULE)) -* Add ability to execute `CREATE DICTIONARY` queries in `ON CLUSTER` mode. [#8163](https://github.com/ClickHouse/ClickHouse/pull/8163) ([alesapin](https://github.com/alesapin)) -* Now user's profile in `users.xml` can inherit multiple profiles. [#8343](https://github.com/ClickHouse/ClickHouse/pull/8343) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -* Added `system.stack_trace` table that allows to look at stack traces of all server threads. This is useful for developers to introspect server state. This fixes [#7576](https://github.com/ClickHouse/ClickHouse/issues/7576). [#8344](https://github.com/ClickHouse/ClickHouse/pull/8344) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Add `DateTime64` datatype with configurable sub-second precision. [#7170](https://github.com/ClickHouse/ClickHouse/pull/7170) ([Vasily Nemkov](https://github.com/Enmk)) -* Add table function `clusterAllReplicas` which allows to query all the nodes in the cluster. [#8493](https://github.com/ClickHouse/ClickHouse/pull/8493) ([kiran sunkari](https://github.com/kiransunkari)) -* Add aggregate function `categoricalInformationValue` which calculates the information value of a discrete feature. [#8117](https://github.com/ClickHouse/ClickHouse/pull/8117) ([hcz](https://github.com/hczhcz)) -* Speed up parsing of data files in `CSV`, `TSV` and `JSONEachRow` format by doing it in parallel. [#7780](https://github.com/ClickHouse/ClickHouse/pull/7780) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Add function `bankerRound` which performs banker's rounding. [#8112](https://github.com/ClickHouse/ClickHouse/pull/8112) ([hcz](https://github.com/hczhcz)) -* Support more languages in embedded dictionary for region names: 'ru', 'en', 'ua', 'uk', 'by', 'kz', 'tr', 'de', 'uz', 'lv', 'lt', 'et', 'pt', 'he', 'vi'. [#8189](https://github.com/ClickHouse/ClickHouse/pull/8189) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Improvements in consistency of `ANY JOIN` logic. Now `t1 ANY LEFT JOIN t2` equals `t2 ANY RIGHT JOIN t1`. [#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -* Add setting `any_join_distinct_right_table_keys` which enables old behaviour for `ANY INNER JOIN`. [#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -* Add new `SEMI` and `ANTI JOIN`. Old `ANY INNER JOIN` behaviour now available as `SEMI LEFT JOIN`. [#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -* Added `Distributed` format for `File` engine and `file` table function which allows to read from `.bin` files generated by asynchronous inserts into `Distributed` table. [#8535](https://github.com/ClickHouse/ClickHouse/pull/8535) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Add optional reset column argument for `runningAccumulate` which allows to reset aggregation results for each new key value. [#8326](https://github.com/ClickHouse/ClickHouse/pull/8326) ([Sergey Kononenko](https://github.com/kononencheg)) -* Add ability to use ClickHouse as Prometheus endpoint. [#7900](https://github.com/ClickHouse/ClickHouse/pull/7900) ([vdimir](https://github.com/Vdimir)) -* Add section `` in `config.xml` which restricts allowed hosts for remote table engines and table functions `URL`, `S3`, `HDFS`. [#7154](https://github.com/ClickHouse/ClickHouse/pull/7154) ([Mikhail Korotov](https://github.com/millb)) -* Added function `greatCircleAngle` which calculates the distance on a sphere in degrees. [#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Changed Earth radius to be consistent with H3 library. [#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added `JSONCompactEachRow` and `JSONCompactEachRowWithNamesAndTypes` formats for input and output. [#7841](https://github.com/ClickHouse/ClickHouse/pull/7841) ([Mikhail Korotov](https://github.com/millb)) -* Added feature for file-related table engines and table functions (`File`, `S3`, `URL`, `HDFS`) which allows to read and write `gzip` files based on additional engine parameter or file extension. [#7840](https://github.com/ClickHouse/ClickHouse/pull/7840) ([Andrey Bodrov](https://github.com/apbodrov)) -* Added the `randomASCII(length)` function, generating a string with a random set of [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) printable characters. [#8401](https://github.com/ClickHouse/ClickHouse/pull/8401) ([BayoNet](https://github.com/BayoNet)) -* Added function `JSONExtractArrayRaw` which returns an array on unparsed json array elements from `JSON` string. [#8081](https://github.com/ClickHouse/ClickHouse/pull/8081) ([Oleg Matrokhin](https://github.com/errx)) -* Add `arrayZip` function which allows to combine multiple arrays of equal lengths into one array of tuples. [#8149](https://github.com/ClickHouse/ClickHouse/pull/8149) ([Winter Zhang](https://github.com/zhang2014)) -* Add ability to move data between disks according to configured `TTL`-expressions for `*MergeTree` table engines family. [#8140](https://github.com/ClickHouse/ClickHouse/pull/8140) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Added new aggregate function `avgWeighted` which allows to calculate weighted average. [#7898](https://github.com/ClickHouse/ClickHouse/pull/7898) ([Andrey Bodrov](https://github.com/apbodrov)) -* Now parallel parsing is enabled by default for `TSV`, `TSKV`, `CSV` and `JSONEachRow` formats. [#7894](https://github.com/ClickHouse/ClickHouse/pull/7894) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Add several geo functions from `H3` library: `h3GetResolution`, `h3EdgeAngle`, `h3EdgeLength`, `h3IsValid` and `h3kRing`. [#8034](https://github.com/ClickHouse/ClickHouse/pull/8034) ([Konstantin Malanchev](https://github.com/hombit)) -* Added support for brotli (`br`) compression in file-related storages and table functions. This fixes [#8156](https://github.com/ClickHouse/ClickHouse/issues/8156). [#8526](https://github.com/ClickHouse/ClickHouse/pull/8526) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Add `groupBit*` functions for the `SimpleAggregationFunction` type. [#8485](https://github.com/ClickHouse/ClickHouse/pull/8485) ([Guillaume Tassery](https://github.com/YiuRULE)) - -#### Bug Fix -* Fix rename of tables with `Distributed` engine. Fixes issue [#7868](https://github.com/ClickHouse/ClickHouse/issues/7868). [#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) -* Now dictionaries support `EXPRESSION` for attributes in arbitrary string in non-ClickHouse SQL dialect. [#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([alesapin](https://github.com/alesapin)) -* Fix broken `INSERT SELECT FROM mysql(...)` query. This fixes [#8070](https://github.com/ClickHouse/ClickHouse/issues/8070) and [#7960](https://github.com/ClickHouse/ClickHouse/issues/7960). [#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) -* Fix error "Mismatch column sizes" when inserting default `Tuple` from `JSONEachRow`. This fixes [#5653](https://github.com/ClickHouse/ClickHouse/issues/5653). [#8606](https://github.com/ClickHouse/ClickHouse/pull/8606) ([tavplubix](https://github.com/tavplubix)) -* Now an exception will be thrown in case of using `WITH TIES` alongside `LIMIT BY`. Also add ability to use `TOP` with `LIMIT BY`. This fixes [#7472](https://github.com/ClickHouse/ClickHouse/issues/7472). [#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Fix unintendent dependency from fresh glibc version in `clickhouse-odbc-bridge` binary. [#8046](https://github.com/ClickHouse/ClickHouse/pull/8046) ([Amos Bird](https://github.com/amosbird)) -* Fix bug in check function of `*MergeTree` engines family. Now it doesn't fail in case when we have equal amount of rows in last granule and last mark (non-final). [#8047](https://github.com/ClickHouse/ClickHouse/pull/8047) ([alesapin](https://github.com/alesapin)) -* Fix insert into `Enum*` columns after `ALTER` query, when underlying numeric type is equal to table specified type. This fixes [#7836](https://github.com/ClickHouse/ClickHouse/issues/7836). [#7908](https://github.com/ClickHouse/ClickHouse/pull/7908) ([Anton Popov](https://github.com/CurtizJ)) -* Allowed non-constant negative "size" argument for function `substring`. It was not allowed by mistake. This fixes [#4832](https://github.com/ClickHouse/ClickHouse/issues/4832). [#7703](https://github.com/ClickHouse/ClickHouse/pull/7703) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix parsing bug when wrong number of arguments passed to `(O|J)DBC` table engine. [#7709](https://github.com/ClickHouse/ClickHouse/pull/7709) ([alesapin](https://github.com/alesapin)) -* Using command name of the running clickhouse process when sending logs to syslog. In previous versions, empty string was used instead of command name. [#8460](https://github.com/ClickHouse/ClickHouse/pull/8460) ([Michael Nacharov](https://github.com/mnach)) -* Fix check of allowed hosts for `localhost`. This PR fixes the solution provided in [#8241](https://github.com/ClickHouse/ClickHouse/pull/8241). [#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([Vitaly Baranov](https://github.com/vitlibar)) -* Fix rare crash in `argMin` and `argMax` functions for long string arguments, when result is used in `runningAccumulate` function. This fixes [#8325](https://github.com/ClickHouse/ClickHouse/issues/8325) [#8341](https://github.com/ClickHouse/ClickHouse/pull/8341) ([dinosaur](https://github.com/769344359)) -* Fix memory overcommit for tables with `Buffer` engine. [#8345](https://github.com/ClickHouse/ClickHouse/pull/8345) ([Azat Khuzhin](https://github.com/azat)) -* Fixed potential bug in functions that can take `NULL` as one of the arguments and return non-NULL. [#8196](https://github.com/ClickHouse/ClickHouse/pull/8196) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Better metrics calculations in thread pool for background processes for `MergeTree` table engines. [#8194](https://github.com/ClickHouse/ClickHouse/pull/8194) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix function `IN` inside `WHERE` statement when row-level table filter is present. Fixes [#6687](https://github.com/ClickHouse/ClickHouse/issues/6687) [#8357](https://github.com/ClickHouse/ClickHouse/pull/8357) ([Ivan](https://github.com/abyss7)) -* Now an exception is thrown if the integral value is not parsed completely for settings values. [#7678](https://github.com/ClickHouse/ClickHouse/pull/7678) ([Mikhail Korotov](https://github.com/millb)) -* Fix exception when aggregate function is used in query to distributed table with more than two local shards. [#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -* Now bloom filter can handle zero length arrays and doesn't perform redundant calculations. [#8242](https://github.com/ClickHouse/ClickHouse/pull/8242) ([achimbab](https://github.com/achimbab)) -* Fixed checking if a client host is allowed by matching the client host to `host_regexp` specified in `users.xml`. [#8241](https://github.com/ClickHouse/ClickHouse/pull/8241) ([Vitaly Baranov](https://github.com/vitlibar)) -* Relax ambiguous column check that leads to false positives in multiple `JOIN ON` section. [#8385](https://github.com/ClickHouse/ClickHouse/pull/8385) ([Artem Zuikov](https://github.com/4ertus2)) -* Fixed possible server crash (`std::terminate`) when the server cannot send or write data in `JSON` or `XML` format with values of `String` data type (that require `UTF-8` validation) or when compressing result data with Brotli algorithm or in some other rare cases. This fixes [#7603](https://github.com/ClickHouse/ClickHouse/issues/7603) [#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix race condition in `StorageDistributedDirectoryMonitor` found by CI. This fixes [#8364](https://github.com/ClickHouse/ClickHouse/issues/8364). [#8383](https://github.com/ClickHouse/ClickHouse/pull/8383) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Now background merges in `*MergeTree` table engines family preserve storage policy volume order more accurately. [#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Now table engine `Kafka` works properly with `Native` format. This fixes [#6731](https://github.com/ClickHouse/ClickHouse/issues/6731) [#7337](https://github.com/ClickHouse/ClickHouse/issues/7337) [#8003](https://github.com/ClickHouse/ClickHouse/issues/8003). [#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([filimonov](https://github.com/filimonov)) -* Fixed formats with headers (like `CSVWithNames`) which were throwing exception about EOF for table engine `Kafka`. [#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([filimonov](https://github.com/filimonov)) -* Fixed a bug with making set from subquery in right part of `IN` section. This fixes [#5767](https://github.com/ClickHouse/ClickHouse/issues/5767) and [#2542](https://github.com/ClickHouse/ClickHouse/issues/2542). [#7755](https://github.com/ClickHouse/ClickHouse/pull/7755) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Fix possible crash while reading from storage `File`. [#7756](https://github.com/ClickHouse/ClickHouse/pull/7756) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fixed reading of the files in `Parquet` format containing columns of type `list`. [#8334](https://github.com/ClickHouse/ClickHouse/pull/8334) ([maxulan](https://github.com/maxulan)) -* Fix error `Not found column` for distributed queries with `PREWHERE` condition dependent on sampling key if `max_parallel_replicas > 1`. [#7913](https://github.com/ClickHouse/ClickHouse/pull/7913) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix error `Not found column` if query used `PREWHERE` dependent on table's alias and the result set was empty because of primary key condition. [#7911](https://github.com/ClickHouse/ClickHouse/pull/7911) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fixed return type for functions `rand` and `randConstant` in case of `Nullable` argument. Now functions always return `UInt32` and never `Nullable(UInt32)`. [#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Disabled predicate push-down for `WITH FILL` expression. This fixes [#7784](https://github.com/ClickHouse/ClickHouse/issues/7784). [#7789](https://github.com/ClickHouse/ClickHouse/pull/7789) ([Winter Zhang](https://github.com/zhang2014)) -* Fixed incorrect `count()` result for `SummingMergeTree` when `FINAL` section is used. [#3280](https://github.com/ClickHouse/ClickHouse/issues/3280) [#7786](https://github.com/ClickHouse/ClickHouse/pull/7786) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Fix possible incorrect result for constant functions from remote servers. It happened for queries with functions like `version()`, `uptime()`, etc. which returns different constant values for different servers. This fixes [#7666](https://github.com/ClickHouse/ClickHouse/issues/7666). [#7689](https://github.com/ClickHouse/ClickHouse/pull/7689) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix complicated bug in push-down predicate optimization which leads to wrong results. This fixes a lot of issues on push-down predicate optimization. [#8503](https://github.com/ClickHouse/ClickHouse/pull/8503) ([Winter Zhang](https://github.com/zhang2014)) -* Fix crash in `CREATE TABLE .. AS dictionary` query. [#8508](https://github.com/ClickHouse/ClickHouse/pull/8508) ([Azat Khuzhin](https://github.com/azat)) -* Several improvements ClickHouse grammar in `.g4` file. [#8294](https://github.com/ClickHouse/ClickHouse/pull/8294) ([taiyang-li](https://github.com/taiyang-li)) -* Fix bug that leads to crashes in `JOIN`s with tables with engine `Join`. This fixes [#7556](https://github.com/ClickHouse/ClickHouse/issues/7556) [#8254](https://github.com/ClickHouse/ClickHouse/issues/8254) [#7915](https://github.com/ClickHouse/ClickHouse/issues/7915) [#8100](https://github.com/ClickHouse/ClickHouse/issues/8100). [#8298](https://github.com/ClickHouse/ClickHouse/pull/8298) ([Artem Zuikov](https://github.com/4ertus2)) -* Fix redundant dictionaries reload on `CREATE DATABASE`. [#7916](https://github.com/ClickHouse/ClickHouse/pull/7916) ([Azat Khuzhin](https://github.com/azat)) -* Limit maximum number of streams for read from `StorageFile` and `StorageHDFS`. Fixes https://github.com/ClickHouse/ClickHouse/issues/7650. [#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([alesapin](https://github.com/alesapin)) -* Fix bug in `ALTER ... MODIFY ... CODEC` query, when user specify both default expression and codec. Fixes [8593](https://github.com/ClickHouse/ClickHouse/issues/8593). [#8614](https://github.com/ClickHouse/ClickHouse/pull/8614) ([alesapin](https://github.com/alesapin)) -* Fix error in background merge of columns with `SimpleAggregateFunction(LowCardinality)` type. [#8613](https://github.com/ClickHouse/ClickHouse/pull/8613) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fixed type check in function `toDateTime64`. [#8375](https://github.com/ClickHouse/ClickHouse/pull/8375) ([Vasily Nemkov](https://github.com/Enmk)) -* Now server do not crash on `LEFT` or `FULL JOIN` with and Join engine and unsupported `join_use_nulls` settings. [#8479](https://github.com/ClickHouse/ClickHouse/pull/8479) ([Artem Zuikov](https://github.com/4ertus2)) -* Now `DROP DICTIONARY IF EXISTS db.dict` query doesn't throw exception if `db` doesn't exist. [#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([Vitaly Baranov](https://github.com/vitlibar)) -* Fix possible crashes in table functions (`file`, `mysql`, `remote`) caused by usage of reference to removed `IStorage` object. Fix incorrect parsing of columns specified at insertion into table function. [#7762](https://github.com/ClickHouse/ClickHouse/pull/7762) ([tavplubix](https://github.com/tavplubix)) -* Ensure network be up before starting `clickhouse-server`. This fixes [#7507](https://github.com/ClickHouse/ClickHouse/issues/7507). [#8570](https://github.com/ClickHouse/ClickHouse/pull/8570) ([Zhichang Yu](https://github.com/yuzhichang)) -* Fix timeouts handling for secure connections, so queries doesn't hang indefenitely. This fixes [#8126](https://github.com/ClickHouse/ClickHouse/issues/8126). [#8128](https://github.com/ClickHouse/ClickHouse/pull/8128) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix `clickhouse-copier`'s redundant contention between concurrent workers. [#7816](https://github.com/ClickHouse/ClickHouse/pull/7816) ([Ding Xiang Fei](https://github.com/dingxiangfei2009)) -* Now mutations doesn't skip attached parts, even if their mutation version were larger than current mutation version. [#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([Zhichang Yu](https://github.com/yuzhichang)) [#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([alesapin](https://github.com/alesapin)) -* Ignore redundant copies of `*MergeTree` data parts after move to another disk and server restart. [#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix crash in `FULL JOIN` with `LowCardinality` in `JOIN` key. [#8252](https://github.com/ClickHouse/ClickHouse/pull/8252) ([Artem Zuikov](https://github.com/4ertus2)) -* Forbidden to use column name more than once in insert query like `INSERT INTO tbl (x, y, x)`. This fixes [#5465](https://github.com/ClickHouse/ClickHouse/issues/5465), [#7681](https://github.com/ClickHouse/ClickHouse/issues/7681). [#7685](https://github.com/ClickHouse/ClickHouse/pull/7685) ([alesapin](https://github.com/alesapin)) -* Added fallback for detection the number of physical CPU cores for unknown CPUs (using the number of logical CPU cores). This fixes [#5239](https://github.com/ClickHouse/ClickHouse/issues/5239). [#7726](https://github.com/ClickHouse/ClickHouse/pull/7726) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix `There's no column` error for materialized and alias columns. [#8210](https://github.com/ClickHouse/ClickHouse/pull/8210) ([Artem Zuikov](https://github.com/4ertus2)) -* Fixed sever crash when `EXISTS` query was used without `TABLE` or `DICTIONARY` qualifier. Just like `EXISTS t`. This fixes [#8172](https://github.com/ClickHouse/ClickHouse/issues/8172). This bug was introduced in version 19.17. [#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix rare bug with error `"Sizes of columns doesn't match"` that might appear when using `SimpleAggregateFunction` column. [#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) -* Fix bug where user with empty `allow_databases` got access to all databases (and same for `allow_dictionaries`). [#7793](https://github.com/ClickHouse/ClickHouse/pull/7793) ([DeifyTheGod](https://github.com/DeifyTheGod)) -* Fix client crash when server already disconnected from client. [#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) -* Fix `ORDER BY` behaviour in case of sorting by primary key prefix and non primary key suffix. [#7759](https://github.com/ClickHouse/ClickHouse/pull/7759) ([Anton Popov](https://github.com/CurtizJ)) -* Check if qualified column present in the table. This fixes [#6836](https://github.com/ClickHouse/ClickHouse/issues/6836). [#7758](https://github.com/ClickHouse/ClickHouse/pull/7758) ([Artem Zuikov](https://github.com/4ertus2)) -* Fixed behavior with `ALTER MOVE` ran immediately after merge finish moves superpart of specified. Fixes [#8103](https://github.com/ClickHouse/ClickHouse/issues/8103). [#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix possible server crash while using `UNION` with different number of columns. Fixes [#7279](https://github.com/ClickHouse/ClickHouse/issues/7279). [#7929](https://github.com/ClickHouse/ClickHouse/pull/7929) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix size of result substring for function `substr` with negative size. [#8589](https://github.com/ClickHouse/ClickHouse/pull/8589) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Now server does not execute part mutation in `MergeTree` if there are not enough free threads in background pool. [#8588](https://github.com/ClickHouse/ClickHouse/pull/8588) ([tavplubix](https://github.com/tavplubix)) -* Fix a minor typo on formatting `UNION ALL` AST. [#7999](https://github.com/ClickHouse/ClickHouse/pull/7999) ([litao91](https://github.com/litao91)) -* Fixed incorrect bloom filter results for negative numbers. This fixes [#8317](https://github.com/ClickHouse/ClickHouse/issues/8317). [#8566](https://github.com/ClickHouse/ClickHouse/pull/8566) ([Winter Zhang](https://github.com/zhang2014)) -* Fixed potential buffer overflow in decompress. Malicious user can pass fabricated compressed data that will cause read after buffer. This issue was found by Eldar Zaitov from Yandex information security team. [#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix incorrect result because of integers overflow in `arrayIntersect`. [#7777](https://github.com/ClickHouse/ClickHouse/pull/7777) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Now `OPTIMIZE TABLE` query will not wait for offline replicas to perform the operation. [#8314](https://github.com/ClickHouse/ClickHouse/pull/8314) ([javi santana](https://github.com/javisantana)) -* Fixed `ALTER TTL` parser for `Replicated*MergeTree` tables. [#8318](https://github.com/ClickHouse/ClickHouse/pull/8318) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix communication between server and client, so server read temporary tables info after query failure. [#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) -* Fix `bitmapAnd` function error when intersecting an aggregated bitmap and a scalar bitmap. [#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([Yue Huang](https://github.com/moon03432)) -* Refine the definition of `ZXid` according to the ZooKeeper Programmer's Guide which fixes bug in `clickhouse-cluster-copier`. [#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([Ding Xiang Fei](https://github.com/dingxiangfei2009)) -* `odbc` table function now respects `external_table_functions_use_nulls` setting. [#7506](https://github.com/ClickHouse/ClickHouse/pull/7506) ([Vasily Nemkov](https://github.com/Enmk)) -* Fixed bug that lead to a rare data race. [#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([Alexander Kazakov](https://github.com/Akazz)) -* Now `SYSTEM RELOAD DICTIONARY` reloads a dictionary completely, ignoring `update_field`. This fixes [#7440](https://github.com/ClickHouse/ClickHouse/issues/7440). [#8037](https://github.com/ClickHouse/ClickHouse/pull/8037) ([Vitaly Baranov](https://github.com/vitlibar)) -* Add ability to check if dictionary exists in create query. [#8032](https://github.com/ClickHouse/ClickHouse/pull/8032) ([alesapin](https://github.com/alesapin)) -* Fix `Float*` parsing in `Values` format. This fixes [#7817](https://github.com/ClickHouse/ClickHouse/issues/7817). [#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) -* Fix crash when we cannot reserve space in some background operations of `*MergeTree` table engines family. [#7873](https://github.com/ClickHouse/ClickHouse/pull/7873) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix crash of merge operation when table contains `SimpleAggregateFunction(LowCardinality)` column. This fixes [#8515](https://github.com/ClickHouse/ClickHouse/issues/8515). [#8522](https://github.com/ClickHouse/ClickHouse/pull/8522) ([Azat Khuzhin](https://github.com/azat)) -* Restore support of all ICU locales and add the ability to apply collations for constant expressions. Also add language name to `system.collations` table. [#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([alesapin](https://github.com/alesapin)) -* Fix bug when external dictionaries with zero minimal lifetime (`LIFETIME(MIN 0 MAX N)`, `LIFETIME(N)`) don't update in background. [#7983](https://github.com/ClickHouse/ClickHouse/pull/7983) ([alesapin](https://github.com/alesapin)) -* Fix crash when external dictionary with ClickHouse source has subquery in query. [#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Fix incorrect parsing of file extension in table with engine `URL`. This fixes [#8157](https://github.com/ClickHouse/ClickHouse/issues/8157). [#8419](https://github.com/ClickHouse/ClickHouse/pull/8419) ([Andrey Bodrov](https://github.com/apbodrov)) -* Fix `CHECK TABLE` query for `*MergeTree` tables without key. Fixes [#7543](https://github.com/ClickHouse/ClickHouse/issues/7543). [#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([alesapin](https://github.com/alesapin)) -* Fixed conversion of `Float64` to MySQL type. [#8079](https://github.com/ClickHouse/ClickHouse/pull/8079) ([Yuriy Baranov](https://github.com/yurriy)) -* Now if table was not completely dropped because of server crash, server will try to restore and load it. [#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) -* Fixed crash in table function `file` while inserting into file that doesn't exist. Now in this case file would be created and then insert would be processed. [#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) -* Fix rare deadlock which can happen when `trace_log` is in enabled. [#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([filimonov](https://github.com/filimonov)) -* Add ability to work with different types besides `Date` in `RangeHashed` external dictionary created from DDL query. Fixes [7899](https://github.com/ClickHouse/ClickHouse/issues/7899). [#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([alesapin](https://github.com/alesapin)) -* Fixes crash when `now64()` is called with result of another function. [#8270](https://github.com/ClickHouse/ClickHouse/pull/8270) ([Vasily Nemkov](https://github.com/Enmk)) -* Fixed bug with detecting client IP for connections through mysql wire protocol. [#7743](https://github.com/ClickHouse/ClickHouse/pull/7743) ([Dmitry Muzyka](https://github.com/dmitriy-myz)) -* Fix empty array handling in `arraySplit` function. This fixes [#7708](https://github.com/ClickHouse/ClickHouse/issues/7708). [#7747](https://github.com/ClickHouse/ClickHouse/pull/7747) ([hcz](https://github.com/hczhcz)) -* Fixed the issue when `pid-file` of another running `clickhouse-server` may be deleted. [#8487](https://github.com/ClickHouse/ClickHouse/pull/8487) ([Weiqing Xu](https://github.com/weiqxu)) -* Fix dictionary reload if it has `invalidate_query`, which stopped updates and some exception on previous update tries. [#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([alesapin](https://github.com/alesapin)) -* Fixed error in function `arrayReduce` that may lead to "double free" and error in aggregate function combinator `Resample` that may lead to memory leak. Added aggregate function `aggThrow`. This function can be used for testing purposes. [#8446](https://github.com/ClickHouse/ClickHouse/pull/8446) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Improvement -* Improved logging when working with `S3` table engine. [#8251](https://github.com/ClickHouse/ClickHouse/pull/8251) ([Grigory Pervakov](https://github.com/GrigoryPervakov)) -* Printed help message when no arguments are passed when calling `clickhouse-local`. This fixes [#5335](https://github.com/ClickHouse/ClickHouse/issues/5335). [#8230](https://github.com/ClickHouse/ClickHouse/pull/8230) ([Andrey Nagorny](https://github.com/Melancholic)) -* Add setting `mutations_sync` which allows to wait `ALTER UPDATE/DELETE` queries synchronously. [#8237](https://github.com/ClickHouse/ClickHouse/pull/8237) ([alesapin](https://github.com/alesapin)) -* Allow to set up relative `user_files_path` in `config.xml` (in the way similar to `format_schema_path`). [#7632](https://github.com/ClickHouse/ClickHouse/pull/7632) ([hcz](https://github.com/hczhcz)) -* Add exception for illegal types for conversion functions with `-OrZero` postfix. [#7880](https://github.com/ClickHouse/ClickHouse/pull/7880) ([Andrey Konyaev](https://github.com/akonyaev90)) -* Simplify format of the header of data sending to a shard in a distributed query. [#8044](https://github.com/ClickHouse/ClickHouse/pull/8044) ([Vitaly Baranov](https://github.com/vitlibar)) -* `Live View` table engine refactoring. [#8519](https://github.com/ClickHouse/ClickHouse/pull/8519) ([vzakaznikov](https://github.com/vzakaznikov)) -* Add additional checks for external dictionaries created from DDL-queries. [#8127](https://github.com/ClickHouse/ClickHouse/pull/8127) ([alesapin](https://github.com/alesapin)) -* Fix error `Column ... already exists` while using `FINAL` and `SAMPLE` together, e.g. `select count() from table final sample 1/2`. Fixes [#5186](https://github.com/ClickHouse/ClickHouse/issues/5186). [#7907](https://github.com/ClickHouse/ClickHouse/pull/7907) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Now table the first argument of `joinGet` function can be table indentifier. [#7707](https://github.com/ClickHouse/ClickHouse/pull/7707) ([Amos Bird](https://github.com/amosbird)) -* Allow using `MaterializedView` with subqueries above `Kafka` tables. [#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([filimonov](https://github.com/filimonov)) -* Now background moves between disks run it the seprate thread pool. [#7670](https://github.com/ClickHouse/ClickHouse/pull/7670) ([Vladimir Chebotarev](https://github.com/excitoon)) -* `SYSTEM RELOAD DICTIONARY` now executes synchronously. [#8240](https://github.com/ClickHouse/ClickHouse/pull/8240) ([Vitaly Baranov](https://github.com/vitlibar)) -* Stack traces now display physical addresses (offsets in object file) instead of virtual memory addresses (where the object file was loaded). That allows the use of `addr2line` when binary is position independent and ASLR is active. This fixes [#8360](https://github.com/ClickHouse/ClickHouse/issues/8360). [#8387](https://github.com/ClickHouse/ClickHouse/pull/8387) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Support new syntax for row-level security filters: `…
`. Fixes [#5779](https://github.com/ClickHouse/ClickHouse/issues/5779). [#8381](https://github.com/ClickHouse/ClickHouse/pull/8381) ([Ivan](https://github.com/abyss7)) -* Now `cityHash` function can work with `Decimal` and `UUID` types. Fixes [#5184](https://github.com/ClickHouse/ClickHouse/issues/5184). [#7693](https://github.com/ClickHouse/ClickHouse/pull/7693) ([Mikhail Korotov](https://github.com/millb)) -* Removed fixed index granularity (it was 1024) from system logs because it's obsolete after implementation of adaptive granularity. [#7698](https://github.com/ClickHouse/ClickHouse/pull/7698) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Enabled MySQL compatibility server when ClickHouse is compiled without SSL. [#7852](https://github.com/ClickHouse/ClickHouse/pull/7852) ([Yuriy Baranov](https://github.com/yurriy)) -* Now server checksums distributed batches, which gives more verbose errors in case of corrupted data in batch. [#7914](https://github.com/ClickHouse/ClickHouse/pull/7914) ([Azat Khuzhin](https://github.com/azat)) -* Support `DROP DATABASE`, `DETACH TABLE`, `DROP TABLE` and `ATTACH TABLE` for `MySQL` database engine. [#8202](https://github.com/ClickHouse/ClickHouse/pull/8202) ([Winter Zhang](https://github.com/zhang2014)) -* Add authentication in S3 table function and table engine. [#7623](https://github.com/ClickHouse/ClickHouse/pull/7623) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Added check for extra parts of `MergeTree` at different disks, in order to not allow to miss data parts at undefined disks. [#8118](https://github.com/ClickHouse/ClickHouse/pull/8118) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Enable SSL support for Mac client and server. [#8297](https://github.com/ClickHouse/ClickHouse/pull/8297) ([Ivan](https://github.com/abyss7)) -* Now ClickHouse can work as MySQL federated server (see https://dev.mysql.com/doc/refman/5.7/en/federated-create-server.html). [#7717](https://github.com/ClickHouse/ClickHouse/pull/7717) ([Maxim Fedotov](https://github.com/MaxFedotov)) -* `clickhouse-client` now only enable `bracketed-paste` when multiquery is on and multiline is off. This fixes (#7757)[https://github.com/ClickHouse/ClickHouse/issues/7757]. [#7761](https://github.com/ClickHouse/ClickHouse/pull/7761) ([Amos Bird](https://github.com/amosbird)) -* Support `Array(Decimal)` in `if` function. [#7721](https://github.com/ClickHouse/ClickHouse/pull/7721) ([Artem Zuikov](https://github.com/4ertus2)) -* Support Decimals in `arrayDifference`, `arrayCumSum` and `arrayCumSumNegative` functions. [#7724](https://github.com/ClickHouse/ClickHouse/pull/7724) ([Artem Zuikov](https://github.com/4ertus2)) -* Added `lifetime` column to `system.dictionaries` table. [#6820](https://github.com/ClickHouse/ClickHouse/issues/6820) [#7727](https://github.com/ClickHouse/ClickHouse/pull/7727) ([kekekekule](https://github.com/kekekekule)) -* Improved check for existing parts on different disks for `*MergeTree` table engines. Addresses [#7660](https://github.com/ClickHouse/ClickHouse/issues/7660). [#8440](https://github.com/ClickHouse/ClickHouse/pull/8440) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Integration with `AWS SDK` for `S3` interactions which allows to use all S3 features out of the box. [#8011](https://github.com/ClickHouse/ClickHouse/pull/8011) ([Pavel Kovalenko](https://github.com/Jokser)) -* Added support for subqueries in `Live View` tables. [#7792](https://github.com/ClickHouse/ClickHouse/pull/7792) ([vzakaznikov](https://github.com/vzakaznikov)) -* Check for using `Date` or `DateTime` column from `TTL` expressions was removed. [#7920](https://github.com/ClickHouse/ClickHouse/pull/7920) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Information about disk was added to `system.detached_parts` table. [#7833](https://github.com/ClickHouse/ClickHouse/pull/7833) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Now settings `max_(table|partition)_size_to_drop` can be changed without a restart. [#7779](https://github.com/ClickHouse/ClickHouse/pull/7779) ([Grigory Pervakov](https://github.com/GrigoryPervakov)) -* Slightly better usability of error messages. Ask user not to remove the lines below `Stack trace:`. [#7897](https://github.com/ClickHouse/ClickHouse/pull/7897) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Better reading messages from `Kafka` engine in various formats after [#7935](https://github.com/ClickHouse/ClickHouse/issues/7935). [#8035](https://github.com/ClickHouse/ClickHouse/pull/8035) ([Ivan](https://github.com/abyss7)) -* Better compatibility with MySQL clients which don't support `sha2_password` auth plugin. [#8036](https://github.com/ClickHouse/ClickHouse/pull/8036) ([Yuriy Baranov](https://github.com/yurriy)) -* Support more column types in MySQL compatibility server. [#7975](https://github.com/ClickHouse/ClickHouse/pull/7975) ([Yuriy Baranov](https://github.com/yurriy)) -* Implement `ORDER BY` optimization for `Merge`, `Buffer` and `Materilized View` storages with underlying `MergeTree` tables. [#8130](https://github.com/ClickHouse/ClickHouse/pull/8130) ([Anton Popov](https://github.com/CurtizJ)) -* Now we always use POSIX implementation of `getrandom` to have better compatibility with old kernels (< 3.17). [#7940](https://github.com/ClickHouse/ClickHouse/pull/7940) ([Amos Bird](https://github.com/amosbird)) -* Better check for valid destination in a move TTL rule. [#8410](https://github.com/ClickHouse/ClickHouse/pull/8410) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Better checks for broken insert batches for `Distributed` table engine. [#7933](https://github.com/ClickHouse/ClickHouse/pull/7933) ([Azat Khuzhin](https://github.com/azat)) -* Add column with array of parts name which mutations must process in future to `system.mutations` table. [#8179](https://github.com/ClickHouse/ClickHouse/pull/8179) ([alesapin](https://github.com/alesapin)) -* Parallel merge sort optimization for processors. [#8552](https://github.com/ClickHouse/ClickHouse/pull/8552) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* The settings `mark_cache_min_lifetime` is now obsolete and does nothing. In previous versions, mark cache can grow in memory larger than `mark_cache_size` to accomodate data within `mark_cache_min_lifetime` seconds. That was leading to confusion and higher memory usage than expected, that is especially bad on memory constrained systems. If you will see performance degradation after installing this release, you should increase the `mark_cache_size`. [#8484](https://github.com/ClickHouse/ClickHouse/pull/8484) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Preparation to use `tid` everywhere. This is needed for [#7477](https://github.com/ClickHouse/ClickHouse/issues/7477). [#8276](https://github.com/ClickHouse/ClickHouse/pull/8276) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -#### Performance Improvement -* Performance optimizations in processors pipeline. [#7988](https://github.com/ClickHouse/ClickHouse/pull/7988) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Non-blocking updates of expired keys in cache dictionaries (with permission to read old ones). [#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Compile ClickHouse without `-fno-omit-frame-pointer` globally to spare one more register. [#8097](https://github.com/ClickHouse/ClickHouse/pull/8097) ([Amos Bird](https://github.com/amosbird)) -* Speedup `greatCircleDistance` function and add performance tests for it. [#7307](https://github.com/ClickHouse/ClickHouse/pull/7307) ([Olga Khvostikova](https://github.com/stavrolia)) -* Improved performance of function `roundDown`. [#8465](https://github.com/ClickHouse/ClickHouse/pull/8465) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Improved performance of `max`, `min`, `argMin`, `argMax` for `DateTime64` data type. [#8199](https://github.com/ClickHouse/ClickHouse/pull/8199) ([Vasily Nemkov](https://github.com/Enmk)) -* Improved performance of sorting without a limit or with big limit and external sorting. [#8545](https://github.com/ClickHouse/ClickHouse/pull/8545) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Improved performance of formatting floating point numbers up to 6 times. [#8542](https://github.com/ClickHouse/ClickHouse/pull/8542) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Improved performance of `modulo` function. [#7750](https://github.com/ClickHouse/ClickHouse/pull/7750) ([Amos Bird](https://github.com/amosbird)) -* Optimized `ORDER BY` and merging with single column key. [#8335](https://github.com/ClickHouse/ClickHouse/pull/8335) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Better implementation for `arrayReduce`, `-Array` and `-State` combinators. [#7710](https://github.com/ClickHouse/ClickHouse/pull/7710) ([Amos Bird](https://github.com/amosbird)) -* Now `PREWHERE` should be optimized to be at least as efficient as `WHERE`. [#7769](https://github.com/ClickHouse/ClickHouse/pull/7769) ([Amos Bird](https://github.com/amosbird)) -* Improve the way `round` and `roundBankers` handling negative numbers. [#8229](https://github.com/ClickHouse/ClickHouse/pull/8229) ([hcz](https://github.com/hczhcz)) -* Improved decoding performance of `DoubleDelta` and `Gorilla` codecs by roughly 30-40%. This fixes [#7082](https://github.com/ClickHouse/ClickHouse/issues/7082). [#8019](https://github.com/ClickHouse/ClickHouse/pull/8019) ([Vasily Nemkov](https://github.com/Enmk)) -* Improved performance of `base64` related functions. [#8444](https://github.com/ClickHouse/ClickHouse/pull/8444) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Added a function `geoDistance`. It is similar to `greatCircleDistance` but uses approximation to WGS-84 ellipsoid model. The performance of both functions are near the same. [#8086](https://github.com/ClickHouse/ClickHouse/pull/8086) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Faster `min` and `max` aggregation functions for `Decimal` data type. [#8144](https://github.com/ClickHouse/ClickHouse/pull/8144) ([Artem Zuikov](https://github.com/4ertus2)) -* Vectorize processing `arrayReduce`. [#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([Amos Bird](https://github.com/amosbird)) -* `if` chains are now optimized as `multiIf`. [#8355](https://github.com/ClickHouse/ClickHouse/pull/8355) ([kamalov-ruslan](https://github.com/kamalov-ruslan)) -* Fix performance regression of `Kafka` table engine introduced in 19.15. This fixes [#7261](https://github.com/ClickHouse/ClickHouse/issues/7261). [#7935](https://github.com/ClickHouse/ClickHouse/pull/7935) ([filimonov](https://github.com/filimonov)) -* Removed "pie" code generation that `gcc` from Debian packages occasionally brings by default. [#8483](https://github.com/ClickHouse/ClickHouse/pull/8483) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Parallel parsing data formats [#6553](https://github.com/ClickHouse/ClickHouse/pull/6553) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)) -* Enable optimized parser of `Values` with expressions by default (`input_format_values_deduce_templates_of_expressions=1`). [#8231](https://github.com/ClickHouse/ClickHouse/pull/8231) ([tavplubix](https://github.com/tavplubix)) - -#### Build/Testing/Packaging Improvement -* Build fixes for `ARM` and in minimal mode. [#8304](https://github.com/ClickHouse/ClickHouse/pull/8304) ([proller](https://github.com/proller)) -* Add coverage file flush for `clickhouse-server` when std::atexit is not called. Also slightly improved logging in stateless tests with coverage. [#8267](https://github.com/ClickHouse/ClickHouse/pull/8267) ([alesapin](https://github.com/alesapin)) -* Update LLVM library in contrib. Avoid using LLVM from OS packages. [#8258](https://github.com/ClickHouse/ClickHouse/pull/8258) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Make bundled `curl` build fully quiet. [#8232](https://github.com/ClickHouse/ClickHouse/pull/8232) [#8203](https://github.com/ClickHouse/ClickHouse/pull/8203) ([Pavel Kovalenko](https://github.com/Jokser)) -* Fix some `MemorySanitizer` warnings. [#8235](https://github.com/ClickHouse/ClickHouse/pull/8235) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Use `add_warning` and `no_warning` macros in `CMakeLists.txt`. [#8604](https://github.com/ClickHouse/ClickHouse/pull/8604) ([Ivan](https://github.com/abyss7)) -* Add support of Minio S3 Compatible object (https://min.io/) for better integration tests. [#7863](https://github.com/ClickHouse/ClickHouse/pull/7863) [#7875](https://github.com/ClickHouse/ClickHouse/pull/7875) ([Pavel Kovalenko](https://github.com/Jokser)) -* Imported `libc` headers to contrib. It allows to make builds more consistent across various systems (only for `x86_64-linux-gnu`). [#5773](https://github.com/ClickHouse/ClickHouse/pull/5773) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Remove `-fPIC` from some libraries. [#8464](https://github.com/ClickHouse/ClickHouse/pull/8464) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Clean `CMakeLists.txt` for curl. See https://github.com/ClickHouse/ClickHouse/pull/8011#issuecomment-569478910 [#8459](https://github.com/ClickHouse/ClickHouse/pull/8459) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Silent warnings in `CapNProto` library. [#8220](https://github.com/ClickHouse/ClickHouse/pull/8220) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Add performance tests for short string optimized hash tables. [#7679](https://github.com/ClickHouse/ClickHouse/pull/7679) ([Amos Bird](https://github.com/amosbird)) -* Now ClickHouse will build on `AArch64` even if `MADV_FREE` is not available. This fixes [#8027](https://github.com/ClickHouse/ClickHouse/issues/8027). [#8243](https://github.com/ClickHouse/ClickHouse/pull/8243) ([Amos Bird](https://github.com/amosbird)) -* Update `zlib-ng` to fix memory sanitizer problems. [#7182](https://github.com/ClickHouse/ClickHouse/pull/7182) [#8206](https://github.com/ClickHouse/ClickHouse/pull/8206) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Enable internal MySQL library on non-Linux system, because usage of OS packages is very fragile and usually doesn't work at all. This fixes [#5765](https://github.com/ClickHouse/ClickHouse/issues/5765). [#8426](https://github.com/ClickHouse/ClickHouse/pull/8426) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed build on some systems after enabling `libc++`. This supersedes [#8374](https://github.com/ClickHouse/ClickHouse/issues/8374). [#8380](https://github.com/ClickHouse/ClickHouse/pull/8380) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Make `Field` methods more type-safe to find more errors. [#7386](https://github.com/ClickHouse/ClickHouse/pull/7386) [#8209](https://github.com/ClickHouse/ClickHouse/pull/8209) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Added missing files to the `libc-headers` submodule. [#8507](https://github.com/ClickHouse/ClickHouse/pull/8507) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix wrong `JSON` quoting in performance test output. [#8497](https://github.com/ClickHouse/ClickHouse/pull/8497) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Now stack trace is displayed for `std::exception` and `Poco::Exception`. In previous versions it was available only for `DB::Exception`. This improves diagnostics. [#8501](https://github.com/ClickHouse/ClickHouse/pull/8501) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Porting `clock_gettime` and `clock_nanosleep` for fresh glibc versions. [#8054](https://github.com/ClickHouse/ClickHouse/pull/8054) ([Amos Bird](https://github.com/amosbird)) -* Enable `part_log` in example config for developers. [#8609](https://github.com/ClickHouse/ClickHouse/pull/8609) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix async nature of reload in `01036_no_superfluous_dict_reload_on_create_database*`. [#8111](https://github.com/ClickHouse/ClickHouse/pull/8111) ([Azat Khuzhin](https://github.com/azat)) -* Fixed codec performance tests. [#8615](https://github.com/ClickHouse/ClickHouse/pull/8615) ([Vasily Nemkov](https://github.com/Enmk)) -* Add install scripts for `.tgz` build and documentation for them. [#8612](https://github.com/ClickHouse/ClickHouse/pull/8612) [#8591](https://github.com/ClickHouse/ClickHouse/pull/8591) ([alesapin](https://github.com/alesapin)) -* Removed old `ZSTD` test (it was created in year 2016 to reproduce the bug that pre 1.0 version of ZSTD has had). This fixes [#8618](https://github.com/ClickHouse/ClickHouse/issues/8618). [#8619](https://github.com/ClickHouse/ClickHouse/pull/8619) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed build on Mac OS Catalina. [#8600](https://github.com/ClickHouse/ClickHouse/pull/8600) ([meo](https://github.com/meob)) -* Increased number of rows in codec performance tests to make results noticeable. [#8574](https://github.com/ClickHouse/ClickHouse/pull/8574) ([Vasily Nemkov](https://github.com/Enmk)) -* In debug builds, treat `LOGICAL_ERROR` exceptions as assertion failures, so that they are easier to notice. [#8475](https://github.com/ClickHouse/ClickHouse/pull/8475) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Make formats-related performance test more deterministic. [#8477](https://github.com/ClickHouse/ClickHouse/pull/8477) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Update `lz4` to fix a MemorySanitizer failure. [#8181](https://github.com/ClickHouse/ClickHouse/pull/8181) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Suppress a known MemorySanitizer false positive in exception handling. [#8182](https://github.com/ClickHouse/ClickHouse/pull/8182) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Update `gcc` and `g++` to version 9 in `build/docker/build.sh` [#7766](https://github.com/ClickHouse/ClickHouse/pull/7766) ([TLightSky](https://github.com/tlightsky)) -* Add performance test case to test that `PREWHERE` is worse than `WHERE`. [#7768](https://github.com/ClickHouse/ClickHouse/pull/7768) ([Amos Bird](https://github.com/amosbird)) -* Progress towards fixing one flacky test. [#8621](https://github.com/ClickHouse/ClickHouse/pull/8621) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Avoid MemorySanitizer report for data from `libunwind`. [#8539](https://github.com/ClickHouse/ClickHouse/pull/8539) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Updated `libc++` to the latest version. [#8324](https://github.com/ClickHouse/ClickHouse/pull/8324) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Build ICU library from sources. This fixes [#6460](https://github.com/ClickHouse/ClickHouse/issues/6460). [#8219](https://github.com/ClickHouse/ClickHouse/pull/8219) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Switched from `libressl` to `openssl`. ClickHouse should support TLS 1.3 and SNI after this change. This fixes [#8171](https://github.com/ClickHouse/ClickHouse/issues/8171). [#8218](https://github.com/ClickHouse/ClickHouse/pull/8218) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fixed UBSan report when using `chacha20_poly1305` from SSL (happens on connect to https://yandex.ru/). [#8214](https://github.com/ClickHouse/ClickHouse/pull/8214) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix mode of default password file for `.deb` linux distros. [#8075](https://github.com/ClickHouse/ClickHouse/pull/8075) ([proller](https://github.com/proller)) -* Improved expression for getting `clickhouse-server` PID in `clickhouse-test`. [#8063](https://github.com/ClickHouse/ClickHouse/pull/8063) ([Alexander Kazakov](https://github.com/Akazz)) -* Updated contrib/googletest to v1.10.0. [#8587](https://github.com/ClickHouse/ClickHouse/pull/8587) ([Alexander Burmak](https://github.com/Alex-Burmak)) -* Fixed ThreadSaninitizer report in `base64` library. Also updated this library to the latest version, but it doesn't matter. This fixes [#8397](https://github.com/ClickHouse/ClickHouse/issues/8397). [#8403](https://github.com/ClickHouse/ClickHouse/pull/8403) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Fix `00600_replace_running_query` for processors. [#8272](https://github.com/ClickHouse/ClickHouse/pull/8272) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Remove support for `tcmalloc` to make `CMakeLists.txt` simpler. [#8310](https://github.com/ClickHouse/ClickHouse/pull/8310) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Release gcc builds now use `libc++` instead of `libstdc++`. Recently `libc++` was used only with clang. This will improve consistency of build configurations and portability. [#8311](https://github.com/ClickHouse/ClickHouse/pull/8311) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Enable ICU library for build with MemorySanitizer. [#8222](https://github.com/ClickHouse/ClickHouse/pull/8222) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Suppress warnings from `CapNProto` library. [#8224](https://github.com/ClickHouse/ClickHouse/pull/8224) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Removed special cases of code for `tcmalloc`, because it's no longer supported. [#8225](https://github.com/ClickHouse/ClickHouse/pull/8225) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* In CI coverage task, kill the server gracefully to allow it to save the coverage report. This fixes incomplete coverage reports we've been seeing lately. [#8142](https://github.com/ClickHouse/ClickHouse/pull/8142) ([alesapin](https://github.com/alesapin)) -* Performance tests for all codecs against `Float64` and `UInt64` values. [#8349](https://github.com/ClickHouse/ClickHouse/pull/8349) ([Vasily Nemkov](https://github.com/Enmk)) -* `termcap` is very much deprecated and lead to various problems (f.g. missing "up" cap and echoing `^J` instead of multi line) . Favor `terminfo` or bundled `ncurses`. [#7737](https://github.com/ClickHouse/ClickHouse/pull/7737) ([Amos Bird](https://github.com/amosbird)) -* Fix `test_storage_s3` integration test. [#7734](https://github.com/ClickHouse/ClickHouse/pull/7734) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Support `StorageFile(, null) ` to insert block into given format file without actually write to disk. This is required for performance tests. [#8455](https://github.com/ClickHouse/ClickHouse/pull/8455) ([Amos Bird](https://github.com/amosbird)) -* Added argument `--print-time` to functional tests which prints execution time per test. [#8001](https://github.com/ClickHouse/ClickHouse/pull/8001) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Added asserts to `KeyCondition` while evaluating RPN. This will fix warning from gcc-9. [#8279](https://github.com/ClickHouse/ClickHouse/pull/8279) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Dump cmake options in CI builds. [#8273](https://github.com/ClickHouse/ClickHouse/pull/8273) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Don't generate debug info for some fat libraries. [#8271](https://github.com/ClickHouse/ClickHouse/pull/8271) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Make `log_to_console.xml` always log to stderr, regardless of is it interactive or not. [#8395](https://github.com/ClickHouse/ClickHouse/pull/8395) ([Alexander Kuzmenkov](https://github.com/akuzm)) -* Removed some unused features from `clickhouse-performance-test` tool. [#8555](https://github.com/ClickHouse/ClickHouse/pull/8555) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Now we will also search for `lld-X` with corresponding `clang-X` version. [#8092](https://github.com/ClickHouse/ClickHouse/pull/8092) ([alesapin](https://github.com/alesapin)) -* Parquet build improvement. [#8421](https://github.com/ClickHouse/ClickHouse/pull/8421) ([maxulan](https://github.com/maxulan)) -* More GCC warnings [#8221](https://github.com/ClickHouse/ClickHouse/pull/8221) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -* Package for Arch Linux now allows to run ClickHouse server, and not only client. [#8534](https://github.com/ClickHouse/ClickHouse/pull/8534) ([Vladimir Chebotarev](https://github.com/excitoon)) -* Fix test with processors. Tiny performance fixes. [#7672](https://github.com/ClickHouse/ClickHouse/pull/7672) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) -* Update contrib/protobuf. [#8256](https://github.com/ClickHouse/ClickHouse/pull/8256) ([Matwey V. Kornilov](https://github.com/matwey)) -* In preparation of switching to c++20 as a new year celebration. "May the C++ force be with ClickHouse." [#8447](https://github.com/ClickHouse/ClickHouse/pull/8447) ([Amos Bird](https://github.com/amosbird)) - -#### Experimental Feature -* Added experimental setting `min_bytes_to_use_mmap_io`. It allows to read big files without copying data from kernel to userspace. The setting is disabled by default. Recommended threshold is about 64 MB, because mmap/munmap is slow. [#8520](https://github.com/ClickHouse/ClickHouse/pull/8520) ([alexey-milovidov](https://github.com/alexey-milovidov)) -* Reworked quotas as a part of access control system. Added new table `system.quotas`, new functions `currentQuota`, `currentQuotaKey`, new SQL syntax `CREATE QUOTA`, `ALTER QUOTA`, `DROP QUOTA`, `SHOW QUOTA`. [#7257](https://github.com/ClickHouse/ClickHouse/pull/7257) ([Vitaly Baranov](https://github.com/vitlibar)) -* Allow skipping unknown settings with warnings instead of throwing exceptions. [#7653](https://github.com/ClickHouse/ClickHouse/pull/7653) ([Vitaly Baranov](https://github.com/vitlibar)) -* Reworked row policies as a part of access control system. Added new table `system.row_policies`, new function `currentRowPolicies()`, new SQL syntax `CREATE POLICY`, `ALTER POLICY`, `DROP POLICY`, `SHOW CREATE POLICY`, `SHOW POLICIES`. [#7808](https://github.com/ClickHouse/ClickHouse/pull/7808) ([Vitaly Baranov](https://github.com/vitlibar)) - -#### Security Fix -* Fixed the possibility of reading directories structure in tables with `File` table engine. This fixes [#8536](https://github.com/ClickHouse/ClickHouse/issues/8536). [#8537](https://github.com/ClickHouse/ClickHouse/pull/8537) ([alexey-milovidov](https://github.com/alexey-milovidov)) - -## [Changelog for 2019](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2019.md) diff --git a/docs/ru/whats_new/extended_roadmap.md b/docs/ru/whats_new/extended_roadmap.md deleted file mode 100644 index 12668b74ef4..00000000000 --- a/docs/ru/whats_new/extended_roadmap.md +++ /dev/null @@ -1,1950 +0,0 @@ -# Планы разработки ClickHouse 2020. {#plany-razrabotki-clickhouse-2020} - -Здесь собраны важные задачи на 2020 год. Многие из них присутствуют в GitHub Issues. Данный текст следует рассматривать как рабочий черновик со сводкой и кратким описанием задач, ссылками и материалами для быстрого доступа на одной странице. Классификация задач условная. - -Так как ClickHouse - open-source продукт, мы хотим, чтобы рабочий процесс был также максимально открытым. В связи с этим, вам следует ожидать наличия на данной странице несколько большего количества деталей описания рабочего процесса, чем вы могли бы предположить - настолько близко, насколько рабочий процесс видят разработчики. Так как неотъемлимой частью процесса разработки является исправление недостатков продукта и улучшение качества кода, на данной странице вы найдёте весьма подробные описания таких деталей. Для других open-source продуктов такой подход к разработке обычно нехарактерен. Благодаря тому, что для каждой задачи указаны её зависимости, вы сможете понять, какие подготовительные работы требуются, что позволяет более точно понимать сроки реализации. - -## 1. Хранение данных, индексация. {#khranenie-dannykh-indeksatsiia} - -### 1.1. Индексы по z-Order curve, normalized z-Order curve. {#indeksy-po-z-order-curve-normalized-z-order-curve} - -[\#6286](https://github.com/ClickHouse/ClickHouse/pull/6286) - -Задача также относится к категории «17. Работа с географическими данными», так как geoHash - это частный случай z-Order curve. -Также связана с задачей 24.27 для нечёткого поиска полудубликатов строк, так как позволит индексировать min-hash. -Задача «normalized z-Order curve» в перспективе может быть полезна для БК и Метрики, так как позволяет смешивать OrderID и PageID и избежать дублирования данных. -В задаче также вводится способ индексации путём обращения функции нескольких аргументов на интервале, что имеет смысл для дальнейшего развития. - -[Андрей Чулков](https://github.com/achulkov2), ВШЭ. - -### 1.2. Wait-free каталог баз данных. {#wait-free-katalog-baz-dannykh} - -Q2. Делает [Александр Токмаков](https://github.com/tavplubix), первый рабочий вариант в декабре 2019. Нужно для DataLens и Яндекс.Метрики. - -Манипуляции с каталогом баз данных: запросы CREATE TABLE, DROP TABLE, RENAME TABLE и DATABASE, требуют синхронизации с помощью блокировок. Эта синхронизация становится весьма сложной, так как на неё полагается много внутренних структур данных. - -Предлагается реализовать альтернативный подход, в котором таблицы и базы данных являются всего лишь ссылками на persistent объекты. Подробное описание задачи: [\#6787](https://github.com/ClickHouse/ClickHouse/issues/6787) - -Upd. Сделана крупная часть задачи, но ориентироваться стоит уже на Q2. -Upd. Pull request готов для мержа. - -### 1.3. Неблокирующие ALTER. {#neblokiruiushchie-alter} - -Q1. И полностью immutable куски. Делает [Александр Сапин](https://github.com/alesapin). Готов приступить к задаче в конце ноября 2019. Нужно для Яндекс.Метрики. - -Upd. Большая часть задачи реализована и добавлена в master. Есть незначительные технические долги. Остаётся реализация неблокирующего изменения метаданных таблицы. - -### 1.4. + Нетранзитивные ALTER столбцов. {#netranzitivnye-alter-stolbtsov} - -Требует 1.3. Будет делать [Александр Сапин](https://github.com/alesapin). Ура, сделано. - -### 1.5. + ALTER RENAME COLUMN. {#alter-rename-column} - -[\#6861](https://github.com/ClickHouse/ClickHouse/issues/6861) - -Требует 1.3. Будет делать [Александр Сапин](https://github.com/alesapin). - -### 1.6. + Полиморфные куски данных. {#polimorfnye-kuski-dannykh} - -Компактные куски - Q1, куски в оперативке Q1/Q2 - пункт 1.7. - -Компактные куски реализованы, ещё не включены по-умолчанию. Первым шагом включаем по-умолчанию для системных таблиц. - -Upd. Включено для системных таблиц. - -Делает [Антон Попов](https://github.com/CurtizJ), первый рабочий вариант в декабре. Пререквизит чтобы снизить сложность мелких INSERT, что в свою очередь нужно для 1.12, иначе задача 1.12 не сможет нормально работать. Особенно нужно для Яндекс.Облака. - -Данные в таблицах типа MergeTree в ClickHouse хранятся в виде набора независимых «кусков». Внутри куска, каждый столбец, а также индекс, хранится в отдельных файлах. Это сделано для возможности быстрых манипуляций со столбцами (пример - запрос ALTER DROP COLUMN). При вставке данных (INSERT), создаётся новый кусок. Для таблиц с большим количеством столбцов, запросы INSERT с маленьким количеством строк являются неэффективными, так как требуют создания большого количества файлов в файловой системе. Это является врождённой особенностью ClickHouse - одной из первой проблем, с которыми сталкиваются пользователи. Пользователям приходится буферизовывать данные и собирать их в более крупные пачки перед вставкой в ClickHouse. - -Для смягчения эффекта от этой проблемы, в ClickHouse существуют таблицы типа Buffer. Они накапливают данные в оперативке перед записью в другую таблицу. Впрочем, таблицы Buffer не являются полноценным решением проблемы из-за: - наличия блокировок при вставке; - переупорядочивание вставляемых данных; - неатомарность перекладывания данных из Buffer в результирующую таблицу. - -Вместо этого предлагается разрешить кускам таблиц типа MergeTree располагать данные в разных форматах. А именно: - в оперативной памяти; - на диске со всеми столбцами в одном файле; - на диске со столбцами в отдельных файлах: в зависимости от размера куска и прошедшего времени. Для размещения кусков в оперативной памяти, придётся также реализовать опциональную поддержку write-ahead log с настраиваемыми правилами по сбросу на диск. Это позволит избавиться от проблем с мелкими вставками для MergeTree таблиц. Для ReplicatedMergeTree таблиц, это решит проблему лишь частично. - -### 1.7. Буферизация и WAL в MergeTree. {#buferizatsiia-i-wal-v-mergetree} - -Требует 1.6. Антон Попов. Задача взята в работу. Q2. - -### 1.8. + Перенос между разделами по TTL. {#perenos-mezhdu-razdelami-po-ttl} - -Делает [Владимир Чеботарёв](https://github.com/excitoon), Altinity. Декабрь 2019. - -Q1. Закоммичено, но есть технический долг, который исправляется сейчас. -Готово. - -### 1.9. Использование TTL для прореживания данных. {#ispolzovanie-ttl-dlia-prorezhivaniia-dannykh} - -Будет делать Сорокин Николай, ВШЭ и Яндекс. - -Сейчас пользователь может задать в таблице выражение, которое определяет, сколько времени хранятся данные. Обычно это выражение задаётся относительно значения столбца с датой - например: удалять данные через три месяца. https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/\#table_engine-mergetree-ttl - -Это может быть задано для всей таблицы (тогда строки целиком удаляются после указанного времени) или для отдельных столбцов (тогда данные столбца физически удаляются с диска, а строки в таблице остаются; при чтении значений столбца, они читаются как значения по-умолчанию). - -Но пользователи также хотят более продвинутый вариант этой функциональности: не удалять строки или столбцы целиком, а прореживать их - оставлять меньшее количество строк. - -И тут есть несколько вариантов: -1. По прошествии времени, оставлять каждую N-ую строку. -2. По прошествии времени, выполнять агрегацию данных, заменяя значения некоторых столбцов на значения агрегатных функций от множества значений в нескольких строках. - -Пункт 1 не представляет интереса, так как уже реализован с помощью TTL выражений для удаления данных. В качестве этого выражения можно прописать, например, `cityHash64(*) % 10 = 0 ? now() : event_time + INTERVAL 3 MONTH`. Правда как-то неудобно получается. - -А вот пункт 2 требуется продумать. Не очевидно даже, какой лучше использовать синтаксис для этого при создании таблицы. Но мы придумаем - сразу видно несколько вариантов. - -Частный случай такой задачи уже есть в https://clickhouse.tech/docs/ru/operations/table_engines/graphitemergetree/ Но это было сделано для конкретной задачи. А надо обобщить. - -### 1.10. Пережатие старых данных в фоне. {#perezhatie-starykh-dannykh-v-fone} - -Будет делать Кирилл Барухов, ВШЭ, экспериментальная реализация к весне 2020. Нужно для Яндекс.Метрики. - -Алгоритмы сжатия типа LZ77 позволяют потратить больше времени на сжатие данных, чтобы сжать данные сильнее, но при этом без проигрыша по скорости разжатия данных. В частности, этим свойством обладает LZ4 и ZSTD, которые используются в ClickHouse. Это позволяет использовать свободные ресурсы CPU, когда сервер не нагружен, для пережатия данных, чтобы данные занимали меньше места на дисках, и при этом сохранить или даже улучшить скорость обработки запросов. - -В то же время, ClickHouse обычно используется для «импульсного» сценария нагрузки. Запрос от пользователя обрабатывается максимально быстро, используя все ресурсы CPU, но в среднем по времени, сервер недостаточно нагружен. - -Предлагается добавить в ClickHouse настройки по пережатию данных и фоновые потоки, выполняющие эту задачу. - -### 1.11. + Виртуальная файловая система. {#virtualnaia-failovaia-sistema} - -На VFS переведены Log, TinyLog, StripeLog, а также MergeTree, что доказывает состоятельность реализации. - -Нужно для Яндекс.Облака. Делает Александр, Яндекс.Облако. - -ClickHouse использует для хранения данных локальную файловую систему. Существует сценарий работы, в котором размещение старых (архивных) данных было бы выгодно на удалённой файловой системе. Если файловая система POSIX совместимая, то это не составляет проблем: ClickHouse успешно работает с Ceph, GlusterFS, MooseFS. Также востребованным является сценарий использования S3 (из-за доступности в облаке) или HDFS (для интеграции с Hadoop). Но эти файловые системы не являются POSIX совместимыми. Хотя для них существуют FUSE драйверы, но скорость работы сильно страдает и поддержка неполная. - -ClickHouse использует небольшое подмножество функций ФС, но в то же время, и некоторые специфические части: симлинки и хардлинки, O_DIRECT. Предлагается выделить всё взаимодействие с файловой системой в отдельный интерфейс. - -### 1.12. Экспериментальная реализация VFS поверх S3 и HDFS. {#eksperimentalnaia-realizatsiia-vfs-poverkh-s3-i-hdfs} - -Q2. - -Нужно для Яндекс.Облака. Требует 1.11. Желательно 1.6 и 1.18. -Делает Александр, Яндекс.Облако (сначала часть для S3), а также Олег Ершов, ВШЭ и Яндекс. - -Upd. Олег будет делать только часть про HDFS. - -Upd. Реализация поверх S3 является рабочей на уровне PoC. - -### 1.13. Ускорение запросов с FINAL. {#uskorenie-zaprosov-s-final} - -Требует 2.1. Делает [Николай Кочетов](https://github.com/KochetovNicolai). Нужно для Яндекс.Метрики. Q2. - -### 1.14. Не писать столбцы, полностью состоящие из нулей. {#ne-pisat-stolbtsy-polnostiu-sostoiashchie-iz-nulei} - -Антон Попов. Q2. -В очереди. Простая задача, является небольшим пререквизитом для потенциальной поддержки полуструктурированных данных. - -### 1.15. Возможность иметь разный первичный ключ в разных кусках. {#vozmozhnost-imet-raznyi-pervichnyi-kliuch-v-raznykh-kuskakh} - -Сложная задача, только после 1.3. - -### 1.16. Несколько физических представлений для одного куска данных. {#neskolko-fizicheskikh-predstavlenii-dlia-odnogo-kuska-dannykh} - -Сложная задача, только после 1.3 и 1.6. Позволяет компенсировать 21.20. - -### 1.17. Несколько сортировок для одной таблицы. {#neskolko-sortirovok-dlia-odnoi-tablitsy} - -Сложная задача, только после 1.3 и 1.6. - -### 1.18. Отдельное хранение файлов кусков. {#otdelnoe-khranenie-failov-kuskov} - -Требует 1.3 и 1.6. Полная замена hard links на sym links, что будет лучше для 1.12. - - -## 2. Крупные рефакторинги. {#krupnye-refaktoringi} - -Для обоснования необходимости смотрите ссылки в описании других задач. - -### 2.1. Переделка конвейера выполнения запросов на Processors. {#peredelka-konveiera-vypolneniia-zaprosov-na-processors} - -Делает [Николай Кочетов](https://github.com/KochetovNicolai). Финальная стадия разработки. Включение по-умолчанию в конце декабря 2019. Удаление старого кода в начале 2020. - -Upd. На данный момент исправляются проблемы с регрессиями производительности в отдельных случаях. Кажется, что все проблемы исправлены. -Включение по-умолчанию в Q1, но остаётся вторая часть задачи по корректному выделению async части. - -Upd. Включили по-умолчанию. Удаление старого кода не раньше, чем после первого релиза, в котором это включено по-умолчанию и всё ещё можно выключить обратно. - -Upd. Уже есть первый релиз, в котором это включено по-умолчанию. - -Upd. Всё ещё ждём удаление старого кода, которое должно случиться после релиза 20.4. - -### 2.2. Инфраструктура событий/метрик/ограничений/квот/трассировки. {#infrastruktura-sobytiimetrikogranicheniikvottrassirovki} - -В очереди. https://gist.github.com/alexey-milovidov/d62d73222d83b9319dc519cbb13aeff6 - -### 2.3. Перенос столбцового ser/de из DataType в Column. {#perenos-stolbtsovogo-serde-iz-datatype-v-column} - -В очереди. - -### 2.4. Перевод LowCardinality из DataType в Column. Добавление ColumnSparse. {#perevod-lowcardinality-iz-datatype-v-column-dobavlenie-columnsparse} - -Требует 2.3. - -### 2.5. Версионирование состояний агрегатных функций. {#versionirovanie-sostoianii-agregatnykh-funktsii} - -В очереди. - -### 2.6. Правая часть IN как тип данных. Выполнение IN в виде скалярного подзапроса. {#pravaia-chast-in-kak-tip-dannykh-vypolnenie-in-v-vide-skaliarnogo-podzaprosa} - -Требует 2.1. - -### 2.7. Нормализация Context. {#normalizatsiia-context} - -В очереди. Нужно для YQL. - -Александр Токмаков исправил множество проблем с использованием Context и сейчас переносит каталог БД наружу. - -Upd. Каталог БД вынесен из Context. -Upd. SharedContext вынесен из Context. - -### 2.8. Декларативный парсер запросов. {#deklarativnyi-parser-zaprosov} - -Средний приоритет. Нужно для YQL. - -Upd. В очереди. Иван Лежанкин. - -### 2.9. Логгировние в format-стиле. {#loggirovnie-v-format-stile} - -Делает [Иван Лежанкин](https://github.com/abyss7). Низкий приоритет. -[\#6049](https://github.com/ClickHouse/ClickHouse/issues/6049#issuecomment-570836998) - -### 2.10. Запрашивать у таблиц не столбцы, а срезы. {#zaprashivat-u-tablits-ne-stolbtsy-a-srezy} - -В очереди. - -### 2.11. Разбирательство и нормализация функциональности для bitmap. {#razbiratelstvo-i-normalizatsiia-funktsionalnosti-dlia-bitmap} - -В очереди. - -### 2.12. Декларативные сигнатуры функций. {#deklarativnye-signatury-funktsii} - -[\#3775](https://github.com/ClickHouse/ClickHouse/pull/3775) - -Задачу делает Алексей Миловидов. Прогресс 50% и разработка временно приостановлена. - -Upd. Разработка всё ещё приостановлена. - -### 2.13. Каждая функция в отдельном файле. {#kazhdaia-funktsiia-v-otdelnom-faile} - -Задачу делает Алексей Миловидов. Прогресс 80%. Потребуется помощь других разработчиков. - -Upd. Поползновения наблюдаются. - -### 2.14. Все функции с состоянием переделать на FunctionBuilder. {#vse-funktsii-s-sostoianiem-peredelat-na-functionbuilder} - -Долг [Николай Кочетов](https://github.com/KochetovNicolai). Сейчас код находится в переходном состоянии, что неприемлемо. - -### 2.15. Функция subscribe для IStorage. {#funktsiia-subscribe-dlia-istorage} - -Для нормализации работы materialized views поверх Merge, Distributed, Kafka. - - -## 3. Документация. {#dokumentatsiia} - -Здесь задачи только по инфраструктуре документации. - -### 3.1. Перенос документации по функциям в код. {#perenos-dokumentatsii-po-funktsiiam-v-kod} - -Требует 2.12 и 2.13. Хотим в Q2, средний приоритет. - -### 3.2. Перенос однородных частей документации в код. {#perenos-odnorodnykh-chastei-dokumentatsii-v-kod} - -Требует 3.1. - -### + 3.3. Исправить катастрофически отвратительно неприемлемый поиск по документации. {#ispravit-katastroficheski-otvratitelno-nepriemlemyi-poisk-po-dokumentatsii} - -[Иван Блинков](https://github.com/blinkov/) - очень хороший человек. Сам сайт документации основан на технологиях, не удовлетворяющих требованиям задачи, и эти технологии трудно исправить. Задачу будет делать первый встретившийся нам frontend разработчик, которого мы сможем заставить это сделать. - -Upd. Иван Блинков сделал эту задачу путём замены треш-технологий на нормальные. - -### 3.4. + Добавить японский язык в документацию. {#dobavit-iaponskii-iazyk-v-dokumentatsiiu} - -Эту задачу сделает [Иван Блинков](https://github.com/blinkov/), до конца декабря 2019. Сделано. - - -## 4. Сетевое взаимодействие. {#setevoe-vzaimodeistvie} - -### 4.1. Уменьшение числа потоков при распределённых запросах. {#umenshenie-chisla-potokov-pri-raspredelionnykh-zaprosakh} - -Весна 2020. Upd. Есть прототип. Upd. Он не работает. Upd. Человек отказался от задачи, теперь сроки не определены. - -### 4.2. Спекулятивное выполнение запросов на нескольких репликах. {#spekuliativnoe-vypolnenie-zaprosov-na-neskolkikh-replikakh} - -Нужно для Яндекс.Метрики. Требует 4.1. - -Если распределённый запрос затрагивает большое количество серверов, то время выполнения запросов часто становится большим из-за tail latencies - случайных редких замедлений отдельных серверов. Эту проблему можно избежать, отправляя один и тот же запрос сразу на несколько реплик, и используя данные с наиболее быстрой. - -Задача скрывает в себе много тонкостей, связанных с обработкой стадий выполнения запроса (соединение, обмен handshake, отправка запроса, получение заголовка результата, получение пакетов прогресса, получение данных), правильной возможностью настройки таймаутов, правильной отменой запросов. - -Сейчас для распределённых запросов используется по потоку на соединение. Это позволяет хорошо распараллелить вычисления над полученными данными и утилизировать сеть, но становится сильно избыточным для больших кластеров. Для примера, создание 1000 потоков для чтения данных из 1000 серверов кластера - лишь расходует ресурсы и увеличивает время выполнения запроса. Вместо этого необходимо использовать количество потоков не большее количества процессорных ядер, и мультиплексировать в одном потоке общение с серверами. Реализация нетривиальна, так как мультиплексировать необходимо каждую стадию общения по сети, включая установку соединения и обмен handshake. - -Upd. Сейчас обсуждается, как сделать другую задачу вместо этой. - -### 4.3. Ограничение числа одновременных скачиваний с реплик. {#ogranichenie-chisla-odnovremennykh-skachivanii-s-replik} - -Дмитрий Григорьев, ВШЭ. -Изначально делал Олег Алексеенков, но пока решение не готово, хотя там не так уж много доделывать. - -### 4.4. Ограничение сетевой полосы при репликации. {#ogranichenie-setevoi-polosy-pri-replikatsii} - -Дмитрий Григорьев, ВШЭ. Нужно для Метрики. - -### 4.5. Возможность продолжить передачу куска данных при репликации после сбоя. {#vozmozhnost-prodolzhit-peredachu-kuska-dannykh-pri-replikatsii-posle-sboia} - -Дмитрий Григорьев, ВШЭ. - -### 4.6. p2p передача для GLOBAL подзапросов. {#p2p-peredacha-dlia-global-podzaprosov} - -### 4.7. Ленивая загрузка множеств для IN и JOIN с помощью k/v запросов. {#lenivaia-zagruzka-mnozhestv-dlia-in-i-join-s-pomoshchiu-kv-zaprosov} - -### 4.8. Разделить background pool для fetch и merge. {#razdelit-background-pool-dlia-fetch-i-merge} - -Дмитрий Григорьев, ВШЭ. -В очереди. Исправить проблему, что восстанавливающаяся реплика перестаёт мержить. Частично компенсируется 4.3. - - -## 5. Операции. {#operatsii} - -### 5.1. + Разделение задач на более мелкие куски в clickhouse-copier. {#razdelenie-zadach-na-bolee-melkie-kuski-v-clickhouse-copier} - -[\#9075](https://github.com/ClickHouse/ClickHouse/pull/9075) -Q1. Нужно для Метрики, в очереди. Никита Михайлов. - -Upd. Задача на финальной стадии разработки. -Upd. Сделано. Эффективность работы под вопросом. Есть варианты, как сделать лучше. - -### 5.2. Автонастройка лимита на оперативку и размера кэшей. {#avtonastroika-limita-na-operativku-i-razmera-keshei} - -### 5.3. + Встроенная ручка для Prometheus. {#vstroennaia-ruchka-dlia-prometheus} - -Сделано. https://github.com/Vdimir - -### 5.4. Opt-in сообщать в клиенте, если вышла новая версия. {#opt-in-soobshchat-v-kliente-esli-vyshla-novaia-versiia} - -### 5.5. + LTS релизы. {#lts-relizy} - -Требует 7.5. Задачу хочет Метрика, Облако, БК, Маркет и Altinity. Первой LTS версией уже стала версия 19.14. -Метрика, БК, Маркет, Altinity уже используют более свежие версии чем LTS. -Upd. Появилась вторая версия LTS - 20.3. - - -## 6. Инструментирование. {#instrumentirovanie} - -### 6.1. + Исправления сэмплирующего профайлера запросов. {#ispravleniia-sempliruiushchego-profailera-zaprosov} - -Михаил Филимонов, Altinity. Ноябрь 2019. Сделано. -Осталось ещё проверить работоспособность профайлера в первом потоке (что важно для INSERT). Иван Лежанкин. Q1. Сделано. - -### 6.2. + Добавление memory profiler. {#dobavlenie-memory-profiler} - -[\#6387](https://github.com/ClickHouse/ClickHouse/issues/6387) - -Сравнительно простая задача, но только для опытных разработчиков. Нужна всем. Иван Лежанкин. Q1. Сделано. - -### 6.3. + Учёт оперативки total расширить не только на запросы. {#uchiot-operativki-total-rasshirit-ne-tolko-na-zaprosy} - -Исправление долгоживущей проблемы с дрифтом учёта оперативки. Нужна для Метрики и БК. - -### 6.4. Поддержка perf events как метрик запроса. {#podderzhka-perf-events-kak-metrik-zaprosa} - -Делает Андрей Скобцов, ВШЭ. - -В Linux существует возможность получать в программе информацию о счётчиках производительности и событиях, относящихся к CPU и ядру ОС. Подробнее смотрите `man perf_event_open`. Предлагается добавить эти метрики в ClickHouse для инструментирования запросов. - -Есть прототип. - -### 6.5. Эксперименты с LLVM X-Ray. {#eksperimenty-s-llvm-x-ray} - -Требует 2.2. - -### 6.6. + Стек трейс для любых исключений. {#stek-treis-dlia-liubykh-iskliuchenii} - -Сейчас есть стек трейс для почти всех, но не всех исключений. Требует 7.4. - -### 6.7. + Таблица system.stack_trace. {#tablitsa-system-stack-trace} - -Сравнительно простая задача, но только для опытных разработчиков. - -### 6.8. Таблица system.crashes. {#tablitsa-system-crashes} - -Сравнительно простая задача, но только для опытных разработчиков. - -### 6.9. Отправлять информацию клиенту, если сервер падает по сигналу. {#otpravliat-informatsiiu-klientu-esli-server-padaet-po-signalu} - -### 6.10. Сбор общих системных метрик. {#sbor-obshchikh-sistemnykh-metrik} - - -## 7. Сопровождение разработки. {#soprovozhdenie-razrabotki} - -### 7.1. + ICU в submodules. {#icu-v-submodules} - -Добавление в submodules также нужно для Аркадии (7.26). - -### 7.2. + LLVM в submodules. {#llvm-v-submodules} - -Сделал Алексей Миловидов. - -### 7.3. + Обновление Poco. {#obnovlenie-poco} - -Алексанр Кузьменков. - -### 7.4. + Включить libc++, libc++-abi при сборке с gcc. {#vkliuchit-libc-libc-abi-pri-sborke-s-gcc} - -Сейчас включено только при сборке с clang, но продакшен сборка использует gcc. -Требует 7.2 и, возможно, 7.1 (только в случае новой версии ICU). - -### 7.5. + Начать публиковать LTS релизы. {#nachat-publikovat-lts-relizy} - -[Александр Сапин](https://github.com/alesapin). - -### 7.6. + Правильный статистический тест для comparison mode в clickhouse-performance-test. {#pravilnyi-statisticheskii-test-dlia-comparison-mode-v-clickhouse-performance-test} - -Задачу начал делать Дмитрий Рубашкин (ВШЭ). Сейчас продолжает [Александр Кузьменков](https://github.com/akuzm). Сделано, работает в CI. - -### 7.7. Доделать тесты под MSan. {#dodelat-testy-pod-msan} - -Уже есть ASan, TSan, UBSan. Не хватает тестов под MSan. Они уже добавлены в CI, но не проходят. -[Александр Кузьменков](https://github.com/akuzm) и [Александр Токмаков](https://github.com/tavplubix). - -Upd. Задача всё ещё медленно тащится. - -### 7.8. + Добавить clang-tidy. {#dobavit-clang-tidy} - -Уже есть PVS-Studio. Мы очень довольны, но этого недостаточно. - -Upd. Алексей Миловидов. Добавлено некоторое множество проверок, но нужно рассмотреть все проверки подряд и добавить всё, что можно. -Upd. Рассмотрели все проверки подряд. - -### 7.9. + Проверки на стиль имён с помощью clang-tidy. {#proverki-na-stil-imion-s-pomoshchiu-clang-tidy} - -Сделано. Только в .cpp файлах и только для имён локальных переменных. Остальное слишком сложно. - -### 7.10. Включение UBSan и MSan в интеграционных тестах. {#vkliuchenie-ubsan-i-msan-v-integratsionnykh-testakh} - -UBSan включен в функциональных тестах, но не включен в интеграционных тестах. Требует 7.7. - -### 7.11. Включение \*San в unit тестах. {#vkliuchenie-san-v-unit-testakh} - -У нас мало unit тестов по сравнению с функциональными тестами и их использование не обязательно. Но они всё-равно важны и нет причин не запускать их под всеми видами sanitizers. - -Илья Яцишин. - -### 7.12. Показывать тестовое покрытие нового кода в PR. {#pokazyvat-testovoe-pokrytie-novogo-koda-v-pr} - -Пока есть просто показ тестового покрытия всего кода. - -### 7.13. + Включение аналога -Weverything в gcc. {#vkliuchenie-analoga-weverything-v-gcc} - -Мы используем -Wall -Wextra -Weverything -Werror. -При сборке с clang, -Weverything уже включено. Но в gcc есть уникальные warning-и, отсутствующие в clang. -Сделал Wolf Kreuzerkrieg. - -### 7.14. + Альтернатива для readline и libedit. {#alternativa-dlia-readline-i-libedit} - -Подключение replxx вместо readline сделал Иван Лежанкин. - -Есть технический долг с лицензиями файлов консорциума Unicode. - -### 7.14.1. Улучшение возможностей интерактивного режима clickhouse-client. {#uluchshenie-vozmozhnostei-interaktivnogo-rezhima-clickhouse-client} - -Тагир Кускаров, ВШЭ. - -Upd. В рамках данной задачи добавляем подстветку синтаксиса и исправление проблем со вставкой больших запросов. - -Для ввода запросов в интерактивном режиме в клиенте командной строки clickhouse-client использовалась библиотека readline или libedit. - -Библиотеки readline и libedit обладает следующими недостатками: -- (исправлено в новых версиях readline) Очень низкая производительность вставки больших кусков текста. Вставка каждого следующего символа имеет сложность O(n = количество предыдущих символов) и при вставке 1 МБ текста, скорость падает до десятков байт в секунду. -- Крайне сложно или невозможно реализовать подсветку синтаксиса по мере набора текста, а также autocomplete без нажатия дополнительных клавиш для вызова. -- Лицензия GPL (для readline) препятствует её включению в кодовую базу продукта. -- Плохо работает навигация по истории, если история вкючает запросы, не помещающиеся на экран. -- История сохраняется лишь при завершении работы клиента. -- При параллельной работе нескольких клиентов с одним файлом истории, сохраняется история только одного из клиентов. -- Плохо работает история для многострочных запросов. -- Излишняя экономия пересылаемых данных, что часто приводит к остаткам мусора в терминале. - -Кроме того, имеются следующие сложно достижимые достоинства: -- Поддержка right-to-left текста; -- Поддержка editrc конфигураций. - -В качестве альтернатив можно рассмотреть следующие варианты: -- Linenoise от Salvatore Sanfilippo. Достоинства: простота и компактность кода; высокая скорость работы. Недостатки: отсутствует поддержка Unicode; отсутствует автоматический перенос текста, что затрудняет работу с многострочными запросами. -- Linenoise с патчами для поддержки Unicode. Недостаток: теряется преимущество по скорости работы. -- Fish shell. Не является библиотекой, но представляет собой отличный пример, как можно реализовать подстветку синтаксиса и удобный autocomplete. Поддерживает Unicode, но работает весьма медленно. -- Python Prompt Toolkit. Не является подходящим решением для интеграции в C++ проект. Хорошие возможности по подсветке синтаксиса и autocomplete. - -Вместо этого предлагается в качестве примера изучить прототип текстового редактора Kilo: https://viewsourcecode.org/snaptoken/kilo/ и реализовать всю необходимую функциональность. - -### 7.15. + Замена libressl обратно на openssl. {#zamena-libressl-obratno-na-openssl} - -Поводом использования libressl послужило желание нашего хорошего друга из известной компании несколько лет назад. Но сейчас ситуация состоит в том, что openssl продолжает развиваться, а libressl не особо, и можно спокойно менять обратно. - -Нужно для Яндекс.Облака для поддержки TLS 1.3. - -### 7.16. + tzdata внутри бинарника. {#tzdata-vnutri-binarnika} - -Как в Аркадии, fallback на системные. - -### 7.17. + Доделать tgz пакеты. {#dodelat-tgz-pakety} - -Уже давно собираются универсальные tgz пакеты, но по нелепой случайности из них исчез install скрипт. -[Александр Сапин](https://github.com/alesapin). Может делегировать эту задачу кому угодно. -Upd. Сделано всё кроме инструкции на сайте. Для этого требуется создать директории testing/stable/prestable на repo.yandex.ru. Внезапно оказалось, что человек, отвечающий за это, в отпуске, и он не отвечает на вопрос, кто его заместитель. Q1. - -### 7.18. + Доделать бинарники под Mac. {#dodelat-binarniki-pod-mac} - -Уже есть автосборка бинарников под Mac на каждый коммит и PR, но с недостатками. -[Иван Лежанкин](https://github.com/abyss7). Требует 7.1, 7.2. Рекомендуется 7.14. Сейчас не хватает по крайней мере SSL и ICU. Нужно для Яндекс.Облака. -Upd. Сделано SSL. Ориентируемся в Q1, но приоритет средний и может потеряться. - -### 7.18.1. Поместить ссылку на собранные бинарники под Mac на сайт. {#pomestit-ssylku-na-sobrannye-binarniki-pod-mac-na-sait} - -Сейчас людям приходится делать несколько кликов, чтобы их скачать. -[Иван Лежанкин](https://github.com/abyss7) или [Александр Сапин](https://github.com/alesapin). - -### 7.19. + Доделать (проверить) автосборку под AArch64. {#dodelat-proverit-avtosborku-pod-aarch64} - -https://github.com/ClickHouse/ClickHouse/issues/8027\#issuecomment-566670282 -Проверили на настоящем сервере Huawei, а также в специальном Docker контейнере, который содержит внутри qemu-user-static. -Также можно проверить на Cavium, на Raspberry Pi а также на твоём Android телефоне. - -### 7.20. Автосборка для FreeBSD x86_64. {#avtosborka-dlia-freebsd-x86-64} - -[Иван Лежанкин](https://github.com/abyss7). - -Upd. В процессе реализации, есть pull request. - -### 7.21. Автосборка для Linux ppc64. {#avtosborka-dlia-linux-ppc64} - -[Иван Лежанкин](https://github.com/abyss7). - -### 7.22. Дэшборд для pull requests. {#deshbord-dlia-pull-requests} - -Дарья Петрова, УрФУ. - -Над ClickHouse одновременно работает большое количество разработчиков, которые оформляют свои изменения в виде pull requests. Когда непомерженных pull requests много, то возникает сложность с организацией работы - непонятно, на какой pull request смотреть в первую очередь. - -Предлагается реализовать простое одностраничное веб-приложение, в котором отображается список pull requests со следующей информацией: -- размер diff - количество изменённых строк; -- как давно было последнее обновление; -- типы изменённых файлов: C++, документация, скрипты сборки; -- наличие добавленных тестов; -- есть ли описание для changelog; -- изменены ли submodules; -- был ли разрешён запуск проверок CI; -- статусы проверок CI; -- количество approve от ревьюеров; - -Статусы проверок - наиболее важная часть. Так как для каждого PR выполняется несколько десятков проверок и наиболее медленные работают до нескольких часов, придётся: -- отображать сразу все проверки для каждого PR в виде красивой разноцветной матрицы с информацией по наведению мыши; -- отсортировать проверки по важности: например, если у внешнего разработчика проходят все проверки кроме стиля кода, то мы можем взять это в работу сами; -- если для предыдущего коммита проверка была завершена, а для последнего коммита ещё только идёт - то можно отображать в таблице статус предыдущей проверки более блёклым цветом. - -Предлагается реализовать несколько вариантов сортировок. Очевидное - по времени обновления, более интересно - некое ранжирование с целью выяснить, «что лучше взять в работу прямо сейчас». - -Похожие продукты уже есть, например: http://prs.mozilla.io/yandex:ClickHouse К сожалению, этот продукт заброшен, да и делает не совсем то, что нужно. По своему усмотрению, можно взять из него что-нибудь полезное. - -### 7.23. Функции для fuzzing. {#funktsii-dlia-fuzzing} - -Андрей Некрашевич, ВШЭ. - -Fuzzing тестирование - это тестирование случайными данными. Мы рассмотрим несколько подходов к этой задачи: - -1. Добавление в SQL диалект ClickHouse функций для генерации случайных данных (пример - случайные бинарные строки заданной длины, случайные валидные UTF-8 строки) и «порчи» данных (например, поменять значения случайных бит с заданной частотой). Это будет использовано для тестирования SQL-функций ClickHouse. - -Можно добавить функции: -`randomString(length)` -`randomFixedString(length)` -- строка заданной длины с равномерно распределёнными случайными байтами; -`randomStringASCII(length)` -`randomStringUTF8(length)` - -`fuzzBits(s, inverse_probability)` - изменить каждый бит строки на противоположный с заданной вероятностью; -`fuzzBytes(s, inverse_probability)` - изменить каждый байт строки на равномерно случайный с заданной вероятностью; - -У каждой функции опциональный аргумент против склейки одинаковых выражений в запросе. - -Также можно сделать функции с детерминированным генератором случайных чисел (аргументом передаётся seed) для воспроизводимости тестовых кейсов. - -Upd. Сергей Штыков сделал функцию `randomPrintableASCII`. -Upd. Илья Яцишин сделал табличную функцию `generateRandom`. -Upd. Эльдар Заитов добавляет OSS Fuzz. - -### 7.24. Fuzzing лексера и парсера запросов; кодеков и форматов. {#fuzzing-leksera-i-parsera-zaprosov-kodekov-i-formatov} - -Андрей Некрашевич, ВШЭ. - -Продолжение 7.23. - -1. Использование AFL или LibFuzzer для тестирования отдельных частей кодовой базы ClickHouse. - -2. Генерация и выполнение случайных синтаксически корректных запросов на случайных данных. - -### 7.25. + Синхронизация релизов в Аркадию. {#sinkhronizatsiia-relizov-v-arkadiiu} - -Изначально занимался Олег Алексеенков. Сейчас он перешёл работать в дружественный отдел, но обещает продолжать синхронизацию. -Затем, возможно, [Иван Лежанкин](https://github.com/abyss7). Но сейчас приостановлено, так как Максим из YT должен исправить регрессию производительности в анализе индекса. - -Максим из YT сказал, что сделает это после нового года. -Максим из YT сказал, что «мы планируем в январе добиться». -Максим сейчас занимается собираемостью YT с новой версией ClickHouse. - -Нужно для CHYT и YQL. - -Upd: Все патчи Максима отправлены в master. Задача взята в работу. -Upd: Задача в процессе реализации. Синхронизироваться будет master. Делает [Иван Лежанкин](https://github.com/abyss7) -Upd: Есть собирающийся прототип, но сборка как будто ещё не в trunk Аркадии. -Upd: Добавлено в Аркадию, но не все файлы (не побайтово). - -### 7.26. Побайтовая идентичность репозитория с Аркадией. {#pobaitovaia-identichnost-repozitoriia-s-arkadiei} - -Команда DevTools. Прогресс по задаче под вопросом. - -### 7.27. Запуск автотестов в Аркадии. {#zapusk-avtotestov-v-arkadii} - -Требует 7.26. Коллеги начали делать, есть результат. - -### 7.29. Опции clickhouse install, stop, start вместо postinst, init.d, systemd скриптов. {#optsii-clickhouse-install-stop-start-vmesto-postinst-init-d-systemd-skriptov} - -Низкий приоритет. - -### 7.30. Возможность переключения бинарных файлов на продакшене без выкладки пакетов. {#vozmozhnost-perekliucheniia-binarnykh-failov-na-prodakshene-bez-vykladki-paketov} - -Низкий приоритет. - -### 7.31. Зеркалирование нагрузки между серверами. {#zerkalirovanie-nagruzki-mezhdu-serverami} - -В очереди. Нужно для Яндекс.Метрики. - -### 7.32. Обфускация продакшен запросов. {#obfuskatsiia-prodakshen-zaprosov} - -Роман Ильговский. Нужно для Яндекс.Метрики. - -Имея SQL запрос, требуется вывести структуру таблиц, на которых этот запрос будет выполнен, и заполнить эти таблицы случайными данными, такими, что результат этого запроса зависит от выбора подмножества данных. - -Для примера, если есть запрос `SELECT SearchPhrase, count(*) FROM table WHERE CounterID = 34 AND SearchPhrase LIKE '%ClickHouse%'`, то мы можем сделать вывод, что CounterID имеет числовой тип, а SearchPhrase - строковый. Заполнить таблицу данными, на которых отдельные условия `CounterID = 34` и `SearchPhrase LIKE '%ClickHouse%'` для некоторых строк выполнены, а для некоторых строк не выполнены. - -Обфускация запросов: имея секретные запросы и структуру таблиц, заменить имена полей и константы, чтобы запросы можно было использовать в качестве публично доступных тестов. - -### 7.33. Выкладывать патч релизы в репозиторий автоматически. {#vykladyvat-patch-relizy-v-repozitorii-avtomaticheski} - -В очереди. Иван Лежанкин. - -### 7.34. Бэкпортировать bugfix автоматически. {#bekportirovat-bugfix-avtomaticheski} - -В очереди. Иван Лежанкин. - -### 7.35. Начальные правила для авто-merge. {#nachalnye-pravila-dlia-avto-merge} - -Зелёные проверки и два ревью. -[Александр Сапин](https://github.com/alesapin). Может делегировать эту задачу кому угодно. - -### 7.36. Понятие доверенных контрибьюторов. {#poniatie-doverennykh-kontribiutorov} - -Контрибьюторы, у которых есть 5 померженных PR. Для их новых PR автотесты запускаются сразу. -[Александр Сапин](https://github.com/alesapin). Может делегировать эту задачу кому угодно. -Сейчас добавляем некоторых доверенных контрибьюторов в ручном режиме. - -### 7.37. Разобраться с repo.yandex.ru. {#razobratsia-s-repo-yandex-ru} - -Есть жалобы на скорость загрузки и неудобство maintenance, operations, visibility. - -Upd. Иван Блинков настроил CDN repo.clickhouse.tech, что решает проблему с доступностью зарубежом. -Вопрос с operations, visibility пока актуален. - - -## 8. Интеграция с внешними системами. {#integratsiia-s-vneshnimi-sistemami} - -### 8.1. Поддержка ALTER MODIFY SETTING для Kafka. {#podderzhka-alter-modify-setting-dlia-kafka} - -Также - возможность указать все настройки форматов в Kafka. - -Altinity. Никто не делает эту задачу. - -### 8.2. Поддержка Mongo Atlas URI. {#podderzhka-mongo-atlas-uri} - -[Александр Кузьменков](https://github.com/akuzm). - -### 8.3. + Доработки globs (правильная поддержка диапазонов, уменьшение числа одновременных stream-ов). {#dorabotki-globs-pravilnaia-podderzhka-diapazonov-umenshenie-chisla-odnovremennykh-stream-ov} - -[Ольга Хвостикова](https://github.com/stavrolia). - -Уменьшение числа stream-ов сделано, а вот правильная поддержка диапазонов - нет. Будем надеяться на Q1/Q2. Сделано. - -### 8.4. Унификация File, HDFS, S3 под URL. {#unifikatsiia-file-hdfs-s3-pod-url} - -### 8.5. + Аутентификация в S3. {#autentifikatsiia-v-s3} - -[Владимир Чеботарёв](https://github.com/excitoon), Altinity. - -### 8.6. Kerberos аутентификация для HDFS и Kafka. {#kerberos-autentifikatsiia-dlia-hdfs-i-kafka} - -Андрей Коняев, ArenaData. Он куда-то пропал. - -### 8.7. + Исправление мелочи HDFS на очень старых ядрах Linux. {#ispravlenie-melochi-hdfs-na-ochen-starykh-iadrakh-linux} - -В ядрах 2.6 отсутствует один системный вызов, который библиотека hdfs3 использует без необходимости. -Сделал Amos Bird. - -### 8.8. + Поддержка виртуальных столбцов с именем файла и путём. {#podderzhka-virtualnykh-stolbtsov-s-imenem-faila-i-putiom} - -[Ольга Хвостикова](https://github.com/stavrolia). - -### 8.9. + Поддержка сжатых файлов (gz, bz) на чтение и запись. {#podderzhka-szhatykh-failov-gz-bz-na-chtenie-i-zapis} - -Сделал [Andrey Bodrov](https://github.com/apbodrov) - -### 8.10. Запись в табличную функцию ODBC. {#zapis-v-tablichnuiu-funktsiiu-odbc} - -Артемий Бобровский, ВШЭ - -### 8.11. Движок таблиц для чтения из Mongo. {#dvizhok-tablits-dlia-chteniia-iz-mongo} - -Артемий Бобровский, ВШЭ - -### 8.12. Пропуск столбцов в форматах Parquet, ORC. {#propusk-stolbtsov-v-formatakh-parquet-orc} - -Артемий Бобровский, ВШЭ - -### 8.13. Поддержка массивов в Parquet, ORC. {#podderzhka-massivov-v-parquet-orc} - -Артемий Бобровский, ВШЭ - -### 8.14. Запись данных в ORC. {#zapis-dannykh-v-orc} - -Возможно, Андрей Коняев, ArenaData (зависит от желания). - -### 8.15. Запись данных в CapNProto. {#zapis-dannykh-v-capnproto} - -### 8.16. + Поддержка формата Avro. {#podderzhka-formata-avro} - -Andrew Onyshchuk. Есть pull request. Q1. Сделано. - -Формат Apache Avro является компактным структурированным построчным бинарным форматом данных с внешней схемой. Этот формат часто используется совместно с Kafka и поддержка его в качестве одного из форматов ввода-вывода в ClickHouse является востребованной пользователями. - -### 8.16.1. + Поддержка формата JSONEachRow, засунутого в массив. {#podderzhka-formata-jsoneachrow-zasunutogo-v-massiv} - -Павел Круглов, ВШЭ и Яндекс. Есть pull request. - -### 8.16.2. - Поддержка формата Thrift. {#podderzhka-formata-thrift} - -Павел Круглов, ВШЭ и Яндекс. Задача отменена. - -### 8.16.3. + Поддержка формата MsgPack. {#podderzhka-formata-msgpack} - -Павел Круглов, ВШЭ и Яндекс. -Задача взята в работу. - -Upd. Почти готово - есть лишь небольшой технический долг. - -### 8.16.4. + Формат Regexp. {#format-regexp} - -Павел Круглов, ВШЭ и Яндекс. -Есть pull request. Готово. - -### 8.17. ClickHouse как MySQL реплика. {#clickhouse-kak-mysql-replika} - -Ильяс Адюгамов, ВШЭ. - -Реализовать возможность подписаться на row-based репликацию MySQL и сохранять полученные данные в CollapsingMergeTree или ReplacingMergeTree таблицы. Сторонние решения для этой задачи уже существуют: https://www.altinity.com/blog/2018/6/30/realtime-mysql-clickhouse-replication-in-practice Также существует стороннее решение для PostgreSQL: https://github.com/mkabilov/pg2ch - -Встроенная в ClickHouse возможность работать в качестве реплики MySQL даст преимущества для дальнейшего развития. - -### 8.18. + ClickHouse как Federated MySQL. {#clickhouse-kak-federated-mysql} - -Maxim Fedotov, Wargaming + Yuri Baranov, Яндекс. - -### 8.19. Интеграция с RabbitMQ. {#integratsiia-s-rabbitmq} - -Ксения Сумарокова, ВШЭ. - -В ClickHouse часто используется потоковый импорт данных из распределённой очереди. Наиболее популярно использование совместно с Kafka. Эта возможность уже есть. - -Следующей по востребованности является система очередей RabbitMQ. Её поддержка в ClickHouse отсутствует. - -Есть pull request в процессе разработки. - -### 8.20. Интеграция с SQS. {#integratsiia-s-sqs} - -Низкий приоритет. - -### 8.21. Поддержка произвольного количества языков для имён регионов. {#podderzhka-proizvolnogo-kolichestva-iazykov-dlia-imion-regionov} - -Нужно для БК. Декабрь 2019. -В декабре для БК сделан минимальный вариант этой задачи. -Максимальный вариант, вроде, никому не нужен. -Upd. Всё ещё кажется, что задача не нужна. - -### 8.22. Поддержка синтаксиса для переменных в стиле MySQL. {#podderzhka-sintaksisa-dlia-peremennykh-v-stile-mysql} - -При парсинге запроса преобразовывать синтаксис вида `@@version_full` в вызов функции `getGlobalVariable('version_full')`. Поддержать популярные MySQL переменные. Может быть поможет Юрий Баранов, если будет энтузиазм. - -Upd. Юрий Баранов работает в Google, там запрещено разрабатывать ClickHouse. - -### 8.23. Подписка для импорта обновляемых и ротируемых логов в ФС. {#podpiska-dlia-importa-obnovliaemykh-i-rotiruemykh-logov-v-fs} - -Желательно 2.15. - - -## 9. Безопасность. {#bezopasnost} - -### 9.1. + Ограничение на хосты в запросах ко внешним системам. {#ogranichenie-na-khosty-v-zaprosakh-ko-vneshnim-sistemam} - -Михаил Коротов. - -### 9.2. Преднастроенные именованные соединения к внешним БД. {#prednastroennye-imenovannye-soedineniia-k-vneshnim-bd} - -Валерий Батурин, ВШЭ. - -ClickHouse предоставляет возможность обратиться к внешней базе данных из языка запросов. Это реализовано в виде табличных функций. В параметрах к табличной функции указывается адрес удалённой базы данных (хост, порт), а также аутентификационные данные (имя пользователя, пароль). Аутентификационные данные указываются в запросе в открытом виде и, таким образом, попадают в историю запросов и в логи, что компрометирует безопасность системы. - -Вместо этого предлагается описывать необходимые данные в конфигурационном файле сервера или в отдельном сервисе и ссылаться на них по именам. - -### 9.3. + Поддержка TLS для ZooKeeper. {#podderzhka-tls-dlia-zookeeper} - -[#10174](https://github.com/ClickHouse/ClickHouse/issues/10174) - -Есть pull request. - - -## 10. Внешние словари. {#vneshnie-slovari} - -### 10.1. + Исправление зависания в библиотеке доступа к YT. {#ispravlenie-zavisaniia-v-biblioteke-dostupa-k-yt} - -Библиотека для доступа к YT не переживает учения. -Нужно для БК и Метрики. Поиск причин - [Александр Сапин](https://github.com/alesapin). Дальшейшее исправление возможно на стороне YT. - -Цитата: «Оказывается для YT-клиента зависания на несколько минут это нормально. Убрал внутренние ретраи, снизил таймауты. Однозначно станет лучше». - -### 10.2. Исправление SIGILL в библиотеке доступа к YT. {#ispravlenie-sigill-v-biblioteke-dostupa-k-yt} - -Код YT использует SIGILL вместо abort. Это, опять же, происходит при учениях. -Нужно для БК и Метрики. Поиск причин - [Александр Сапин](https://github.com/alesapin). Дальшейшее исправление возможно на стороне YT. - -Upd. Одну причину устранили, но ещё что-то неизвестное осталось. -Upd. Нас заставляют переписать эту библиотеку с одного API на другое, так как старое внезапно устарело. Кажется, что переписывание случайно исправит все проблемы. - -### 10.3. Возможность чтения данных из статических таблиц в YT словарях. {#vozmozhnost-chteniia-dannykh-iz-staticheskikh-tablits-v-yt-slovariakh} - -Нужно для БК и Метрики. - -### 10.4. Словарь из YDB (KikiMR). {#slovar-iz-ydb-kikimr} - -Нужно для Метрики, а делать будет таинственный незнакомец из команды KikiMR (под вопросом). Таинственный незнакомец не подтверждает, что он будет делать эту задачу. - -### 10.5. Закрытие соединений и уменьшение числа соединений для MySQL и ODBC. {#zakrytie-soedinenii-i-umenshenie-chisla-soedinenii-dlia-mysql-i-odbc} - -Нужно для Метрики. - -Для MySQL сделал Clément Rodriguez. - -### 10.6. Словари из Cassandra и Couchbase. {#slovari-iz-cassandra-i-couchbase} - -### 10.7. Поддержка Nullable в словарях. {#podderzhka-nullable-v-slovariakh} - -Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. - -### 10.8. Поддержка массивов в словарях. {#podderzhka-massivov-v-slovariakh} - -Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. - -### 10.9. - Уменьшение блокировок для cache словарей за счёт одновременных запросов одного и того же. {#umenshenie-blokirovok-dlia-cache-slovarei-za-schiot-odnovremennykh-zaprosov-odnogo-i-togo-zhe} - -Заменено в пользу 10.10, 10.11. - -### 10.10. + Возможность использования старых значений из cache словаря пока они перезапрашиваются. {#vozmozhnost-ispolzovaniia-starykh-znachenii-iz-cache-slovaria-poka-oni-perezaprashivaiutsia} - -Никита Михайлов. Q1. Нужно для БК и Метрики. - -### 10.11. + Возможность исключительно асинхронных запросов в cache словарях. {#vozmozhnost-iskliuchitelno-asinkhronnykh-zaprosov-v-cache-slovariakh} - -Никита Михайлов. Q1. Нужно для БК и Метрики. Требует 10.10. - -### 10.12. Layout direct для словарей. {#layout-direct-dlia-slovarei} - -Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. -Приступили к этой задаче. - -### 10.13. Использование Join как generic layout для словарей. {#ispolzovanie-join-kak-generic-layout-dlia-slovarei} - -Артём Стрельцов, Николай Дегтеринский, Наталия Михненко, ВШЭ. - -### 10.14. Поддержка всех типов в функции transform. {#podderzhka-vsekh-tipov-v-funktsii-transform} - -### 10.15. Использование словарей как специализированного layout для Join. {#ispolzovanie-slovarei-kak-spetsializirovannogo-layout-dlia-join} - -### 10.16. Словари на локальном SSD. {#slovari-na-lokalnom-ssd} - -Никита Васильев, ВШЭ и Яндекс. Есть pull request. - -Реализовать в ClickHouse специализированный движок таблиц, подходящий для быстрых key-value запросов и оптимизированный для расположения данных на SSD. Это может быть: реализация на основе RocksDB; сериализованные RowBinary данные с индексом в оперативке; секретная очень эффективная структура данных, о которой я расскажу. - -Использовать эту структуру данных как отдельный вид словарей, как источник для cache словарей или как дополнительный уровень кэширования для cache словарей. - -### 10.17. Локальный дамп состояния словаря для быстрого старта сервера. {#lokalnyi-damp-sostoianiia-slovaria-dlia-bystrogo-starta-servera} - -### 10.18. Таблица Join или словарь на удалённом сервере как key-value БД для cache словаря. {#tablitsa-join-ili-slovar-na-udalionnom-servere-kak-key-value-bd-dlia-cache-slovaria} - -### 10.19. Возможность зарегистрировать некоторые функции, использующие словари, под пользовательскими именами. {#vozmozhnost-zaregistrirovat-nekotorye-funktsii-ispolzuiushchie-slovari-pod-polzovatelskimi-imenami} - - -## 11. Интерфейсы. {#interfeisy} - -### 11.1. Вставка состояний агрегатных функций в виде кортежа аргументов или массива кортежей аргументов. {#vstavka-sostoianii-agregatnykh-funktsii-v-vide-kortezha-argumentov-ili-massiva-kortezhei-argumentov} - -### 11.2. Возможность использовать движок JDBC из коробки. {#vozmozhnost-ispolzovat-dvizhok-jdbc-iz-korobki} - -Нужно разобраться, как упаковывать Java в статический бинарник, возможно AppImage. Или предоставить максимально простую инструкцию по установке jdbc-bridge. Может быть будет заинтересован Александр Крашенинников, Badoo, так как он разработал jdbc-bridge. - -Upd. Александр Крашенинников перешёл в другую компанию и больше не занимается этим. - -### 11.3. + Интеграционные тесты ODBC драйвера путём подключения ClickHouse к самому себе через ODBC. {#integratsionnye-testy-odbc-draivera-putiom-podkliucheniia-clickhouse-k-samomu-sebe-cherez-odbc} - -Михаил Филимонов, Altinity. Готово. - -### 11.4. Исправление упячек с типами Date и Decimal в clickhouse-cpp. {#ispravlenie-upiachek-s-tipami-date-i-decimal-v-clickhouse-cpp} - -### 11.5. Поддержка TLS в clickhouse-cpp. {#podderzhka-tls-v-clickhouse-cpp} - -А знаете ли вы, что библиотеку clickhouse-cpp разрабатывал один хороший человек в свободное время? - -### 11.6. Интеграционные тесты clickhouse-cpp. {#integratsionnye-testy-clickhouse-cpp} - -### 11.7. Интерактивный режим работы программы clickhouse-local. {#interaktivnyi-rezhim-raboty-programmy-clickhouse-local} - -### 11.8. Поддержка протокола PostgreSQL. {#podderzhka-protokola-postgresql} - -Элбакян Мовсес Андраникович, ВШЭ. - -В ClickHouse в прошлом году добавили поддержку wire-протокола MySQL. PostgreSQL, так же как MySQL, использует несложный протокол общения между клиентом и сервером, но свой собственный. Поддержка этого протокола является востребованной и откроет новые возможности для ClickHouse. - -Задача в процессе разработки. - -### 11.9. + Доработки ODBC драйвера. {#dorabotki-odbc-draivera} - -Денис Глазачев, Altinity. Хороший прогресс по этой задаче. - -### 11.10. Преднастроенные HTTP handlers для запросов. {#prednastroennye-http-handlers-dlia-zaprosov} - -zhang2014, есть pull request. - -Возможность описать в конфигурационном файле handler (путь в URL) для HTTP запросов к серверу, которому соответствует некоторый параметризованный запрос. Пользователь может вызвать этот обработчик и не должен передавать SQL запрос. - - -## 12. Управление пользователями и доступом. {#upravlenie-polzovateliami-i-dostupom} - -### 12.1. + Role Based Access Control. {#role-based-access-control} - -[Виталий Баранов](https://github.com/vitlibar). Финальная стадия разработки, рабочая версия в начале апреля 2019. -Q2. Сейчас сделаны все интерфейсы в коде и запросы, но не сделаны варианты хранения прав кроме прототипа. -Upd. Сделано хранение прав. До готового к использованию состояния осталось несколько доработок. - -### 12.2. + Управление пользователями и правами доступа с помощью SQL запросов. {#upravlenie-polzovateliami-i-pravami-dostupa-s-pomoshchiu-sql-zaprosov} - -[Виталий Баранов](https://github.com/vitlibar). Финальная стадия разработки, рабочая версия в декабре 2019. -Q1. Сделано управление правами полностью, но не реализовано их хранение, см. 12.1. - -### 12.3. Подключение справочника пользователей и прав доступа из LDAP. {#podkliuchenie-spravochnika-polzovatelei-i-prav-dostupa-iz-ldap} - -[Виталий Баранов](https://github.com/vitlibar). Требует 12.1. -Q2. - -### 12.4. Подключение IDM системы Яндекса как справочника пользователей и прав доступа. {#podkliuchenie-idm-sistemy-iandeksa-kak-spravochnika-polzovatelei-i-prav-dostupa} - -Пока низкий приоритет. Нужно для Метрики. Требует 12.3. - -### 12.5. Pluggable аутентификация с помощью Kerberos (возможно, подключение GSASL). {#pluggable-autentifikatsiia-s-pomoshchiu-kerberos-vozmozhno-podkliuchenie-gsasl} - -[Виталий Баранов](https://github.com/vitlibar). Требует 12.1. - -### 12.6. Информация о пользователях и квотах в системной таблице. {#informatsiia-o-polzovateliakh-i-kvotakh-v-sistemnoi-tablitse} - -[Виталий Баранов](https://github.com/vitlibar). Требует 12.1. -Есть pull request. Q2. - - -## 13. Разделение ресурсов, multi-tenancy. {#razdelenie-resursov-multi-tenancy} - -### 13.1. Overcommit запросов по памяти и вытеснение. {#overcommit-zaprosov-po-pamiati-i-vytesnenie} - -Требует 2.1. Способ реализации обсуждается. - -### 13.2. Общий конвейер выполнения на сервер. {#obshchii-konveier-vypolneniia-na-server} - -Требует 2.1. [Николай Кочетов](https://github.com/KochetovNicolai). - -### 13.3. Пулы ресурсов. {#puly-resursov} - -Требует 13.2 или сможем сделать более неудобную реализацию раньше. -Обсуждается вариант неудобной реализации. Пока средний приоритет, целимся на Q1/Q2. -Вариант реализации выбрал Александр Казаков. -Upd. Не уследили, и задачу стали обсуждать менеджеры. - - -## 14. Диалект SQL. {#dialekt-sql} - -### 14.1. Исправление семантики CAST для Nullable. {#ispravlenie-semantiki-cast-dlia-nullable} - -Нужно для DataLens. А также для внедрения в BI инструмент Looker. -Павел Потёмкин, ВШЭ. - -### 14.2. Поддержка WITH для подзапросов. {#podderzhka-with-dlia-podzaprosov} - -### 14.3. Поддержка подстановок для множеств в правой части IN. {#podderzhka-podstanovok-dlia-mnozhestv-v-pravoi-chasti-in} - -### 14.4. Поддержка подстановок для идентификаторов (имён) в SQL запросе. {#podderzhka-podstanovok-dlia-identifikatorov-imion-v-sql-zaprose} - -zhang2014 - -### 14.5. + Поддержка задания множества как массива в правой части секции IN. {#podderzhka-zadaniia-mnozhestva-kak-massiva-v-pravoi-chasti-sektsii-in} - -Василий Немков, Altinity, делал эту задачу, но забросил её в пользу других задач. -В результате, сейчас доделывает Антон Попов. - -### 14.6. Глобальный scope для WITH. {#globalnyi-scope-dlia-with} - -Павел Потёмкин, ВШЭ. - -### 14.7. Nullable для WITH ROLLUP, WITH CUBE, WITH TOTALS. {#nullable-dlia-with-rollup-with-cube-with-totals} - -Павел Потёмкин, ВШЭ. - -Простая задача. - -### 14.8. Модификаторы DISTINCT, ORDER BY для агрегатных функций. {#modifikatory-distinct-order-by-dlia-agregatnykh-funktsii} - -В ClickHouse поддерживается вычисление COUNT(DISTINCT x). Предлагается добавить возможность использования модификатора DISTINCT для всех агрегатных функций. Например, AVG(DISTINCT x) - вычислить среднее значение для всех различных значений x. Под вопросом вариант, в котором фильтрация уникальных значений выполняется по одному выражению, а агрегация по другому. - -Результат некоторых агрегатных функций зависит от порядка данных. Предлагается реализовать модификатор ORDER BY, задающий порядок явно. Пример: groupArray(x ORDER BY y, z). - -### 14.9. Поддержка запроса EXPLAIN. {#podderzhka-zaprosa-explain} - -Требует 2.1. [Николай Кочетов](https://github.com/KochetovNicolai). - -### 14.10. arrayReduce как функция высшего порядка. {#arrayreduce-kak-funktsiia-vysshego-poriadka} - -### 14.11. Функции для grouping sets. {#funktsii-dlia-grouping-sets} - -### 14.12. Функции обработки временных рядов. {#funktsii-obrabotki-vremennykh-riadov} - -Сложная задача, так как вводит новый класс функций и требует его обработку в оптимизаторе запросов. - -В time-series СУБД нужны функции, которые зависят от последовательности значений. Или даже от последовательности значений и их меток времени. Примеры: moving average, exponential smoothing, derivative, Holt-Winters forecast. Вычисление таких функций поддерживается в ClickHouse лишь частично. Так, ClickHouse поддерживает тип данных «массив» и позволяет реализовать эти функции как функции, принимающие массивы. Но гораздо удобнее для пользователя было бы иметь возможность применить такие функции к таблице (промежуточному результату запроса после сортировки). - -Это требует введение нового класса функций (помимо обычных и агрегатных функций) - такие функции будут иметь в коде ClickHouse свой собственный интерфейс, и их вычисление придётся отдельно учитывать в конвейере выполнения запросов. Для примера, вычисление обычных функций тривиально распараллеливается по процессорным ядрам и по серверам; вычисление агрегатных функций распараллеливается с некоторыми особенностями (работа с промежуточными состояниями вычислений, операция merge); а для функций по обработке временных рядов этот вопрос остаётся открытым - возможно, их придётся вычислять на одном сервере и в одном потоке. - -### 14.13. Применимость функций высшего порядка для кортежей и Nested. {#primenimost-funktsii-vysshego-poriadka-dlia-kortezhei-i-nested} - -### 14.14. Неявные преобразования типов констант. {#neiavnye-preobrazovaniia-tipov-konstant} - -Требует 2.12. - -### 14.15. Неявные преобразования типов под настройкой. {#neiavnye-preobrazovaniia-tipov-pod-nastroikoi} - -Требует 2.12. Для внедрения в BI инструмент Looker. - -### 14.16. Синонимы для функций из MySQL. {#sinonimy-dlia-funktsii-iz-mysql} - -### 14.17. + Ввести понятие stateful функций. {#vvesti-poniatie-stateful-funktsii} - -zhang2014. -Для runningDifference, neighbour - их учёт в оптимизаторе запросов. -В интерфейсе уже сделано. Надо проверить, что учитывается в нужных местах (например, что работает predicate pushdown сквозь ORDER BY, если таких функций нет). - -### 14.18. UNION DISTINCT и возможность включить его по-умолчанию. {#union-distinct-i-vozmozhnost-vkliuchit-ego-po-umolchaniiu} - -Павел Потёмкин, ВШЭ. -Для BI систем. - -### 14.19. Совместимость парсера типов данных с SQL. {#sovmestimost-parsera-tipov-dannykh-s-sql} - -Павел Потёмкин, ВШЭ. -Для BI систем. - -### 14.20. Позиционные аргументы для GROUP BY и ORDER BY. {#pozitsionnye-argumenty-dlia-group-by-i-order-by} - -Павел Потёмкин, ВШЭ. -Тривиально и используется многими системами, но не входит в стандарт SQL. - -### 14.21. Приведение типов для IN (подзапрос) и для JOIN. {#privedenie-tipov-dlia-in-podzapros-i-dlia-join} - -Павел Потёмкин, ВШЭ. - - -## 15. Улучшение поддержки JOIN. {#uluchshenie-podderzhki-join} - -### 15.1. + Доведение merge JOIN до продакшена. {#dovedenie-merge-join-do-prodakshena} - -Артём Зуйков. Сейчас merge JOIN включается вручную опцией и всегда замедляет запросы. Хотим, чтобы он замедлял запросы только когда это неизбежно. -Кстати, смысл merge JOIN появляется только совместно с 15.2 и 15.3. -Q1. Сделали адаптивный вариант, но вроде он что-то всё-ещё замедляет. -Задача сделана, но всё работает слишком медленно. - -### 15.1.1. Алгоритм two-level merge JOIN. {#algoritm-two-level-merge-join} - -Александр Кузьменков. В очереди. - -### 15.1.2. Тестирование реализации JOIN в Greenplum. {#testirovanie-realizatsii-join-v-greenplum} - -В очереди. - -### 15.2. Прокидывание условий в OUTER JOIN. {#prokidyvanie-uslovii-v-outer-join} - -Возможно, Артём Зуйков, но задача ещё не продумана до конца. Возможно, требует 2.1. - -### 15.3. Логический вывод для цепочек вида ON t1.x = t2.y WHERE t1.x = 10 {#logicheskii-vyvod-dlia-tsepochek-vida-on-t1-x-t2-y-where-t1-x-10} - -Возможно, Артём Зуйков. Для полноценной работы 15.2. - -### 15.4. Distributed JOIN с помощью перераспределения данных. {#distributed-join-s-pomoshchiu-pereraspredeleniia-dannykh} - -Артём Зуйков. - -### 15.5. Использование ключа таблицы для оптимизации merge JOIN. {#ispolzovanie-kliucha-tablitsy-dlia-optimizatsii-merge-join} - -### 15.6. + SEMI и ANTI JOIN. {#semi-i-anti-join} - -Артём Зуйков. - - -## 16. Типы данных и функции. {#tipy-dannykh-i-funktsii} - -### 16.1. + DateTime64. {#datetime64} - -Василий Немков, Altinity, декабрь 2019. - -### 16.2. Тип данных для JSON. {#tip-dannykh-dlia-json} - -zhang2014 - -Есть PR, в процессе ревью. - -### 16.3. Поддержка неконстантных аргументов с регулярными выражениями в функциях. {#podderzhka-nekonstantnykh-argumentov-s-reguliarnymi-vyrazheniiami-v-funktsiiakh} - -Данила Кутенин, но только после секретного изменения в работе. -Upd. Секретного изменения в работе не будет, задачу будет делать другой человек. - -### 16.4. Функция rowNumberForKey. {#funktsiia-rownumberforkey} - -### 16.5. Функции для XML и HTML escape. {#funktsii-dlia-xml-i-html-escape} - -### 16.6. Функции нормализации и хэширования SQL запросов. {#funktsii-normalizatsii-i-kheshirovaniia-sql-zaprosov} - - -## 17. Работа с географическими данными. {#rabota-s-geograficheskimi-dannymi} - -### 17.1. Гео-словари для определения региона по координатам. {#geo-slovari-dlia-opredeleniia-regiona-po-koordinatam} - -[Андрей Чулков](https://github.com/achulkov2), Антон Кваша, Артур Петуховский, ВШЭ. -Будет основано на коде от Арслана Урташева. - -ClickHouse не является geospatial СУБД. Тем не менее, в ClickHouse есть несколько функций для таких задач. Например, функция `pointInPolygon` позволяет быстро проверить попадание точек в полигон на плоскости. При этом, полигон задаётся в явном виде и должен быть константным для вызова функции (то есть - проверяется принадлежность многих точек одному полигону). Эта функциональность нужна, например, для рекламного таргетинга мобильных устройств по координатам. - -Похожая, но более сложная задача, которую ClickHouse пока не умеет решать - определение полигона среди множества полигонов, в которые попадают точки. Для примера: определение района города по географическим координатам. Для решения этой задачи нужно будет реализовать поддержку словарей с полигонами, в которых данные проиндексированы для быстрого поиска. - -Upd. Андрей сделал прототип интерфейса и реализацию-заглушку внутри него. -Upd. Андрей сделал прототип более оптимальной структуры данных. - -### 17.2. GIS типы данных и операции. {#gis-tipy-dannykh-i-operatsii} - -Алексей Коряков, Алексей Илюхов, ВШЭ, Яндекс.Карты. - -Реализовать в ClickHouse типы данных для задач обработки геоинформационных данных: Point, Line, MultiLine, Polygon и операции над ними - проверка вхождения, пересечения. Вариантом минимум будет реализация этих операций в евклидовой системе координат. Дополнительно - на сфере и WGS84. - -### 17.3. + Ускорение greatCircleDistance. {#uskorenie-greatcircledistance} - -[Ольга Хвостикова](https://github.com/stavrolia), основано на коде Андрея Аксёнова, получено разрешение на использование кода. - -### 17.4. Ускорение geohash с помощью библиотеки из Аркадии. {#uskorenie-geohash-s-pomoshchiu-biblioteki-iz-arkadii} - -Предположительно, [Андрей Чулков](https://github.com/achulkov2). Получено одобрение от руководства. - -### 17.5. + Проверки в функции pointInPolygon. {#proverki-v-funktsii-pointinpolygon} - -Сейчас функция тихо не работает в случае полигонов с самопересечениями, надо кидать исключение. - - -## 18. Машинное обучение и статистика. {#mashinnoe-obuchenie-i-statistika} - -### 18.1. Инкрементальная кластеризация данных. {#inkrementalnaia-klasterizatsiia-dannykh} - -Александр Кожихов, Максим Кузнецов. Обнаружена фундаментальная проблема в реализации, доделывает предположительно [Николай Кочетов](https://github.com/KochetovNicolai). Он может делегировать задачу кому угодно. - -Исправление фундаментальной проблемы - есть PR. - -### 18.2. Агрегатные функции для статистических тестов. {#agregatnye-funktsii-dlia-statisticheskikh-testov} - -Артём Цыганов, Руденский Константин Игоревич, Семёнов Денис, ВШЭ. - -Предлагается реализовать в ClickHouse статистические тесты (Analysis of Variance, тесты нормальности распределения и т. п.) в виде агрегатных функций. Пример: `welchTTest(value, sample_idx)`. - -Сделали прототип одного теста, есть pull request. - -### 18.3. Инфраструктура для тренировки моделей в ClickHouse. {#infrastruktura-dlia-trenirovki-modelei-v-clickhouse} - -В очереди. - - -## 19. Улучшение работы кластера. {#uluchshenie-raboty-klastera} - -### 19.1. Параллельные кворумные вставки без линеаризуемости. {#parallelnye-kvorumnye-vstavki-bez-linearizuemosti} - -Александра Латышева, ВШЭ и Яндекс. - -Репликация данных в ClickHouse по-умолчанию является асинхронной без выделенного мастера. Это значит, что клиент, осуществляющий вставку данных, получает успешный ответ после того, как данные попали на один сервер; репликация данных по остальным серверам осуществляется в другой момент времени. Это ненадёжно, потому что допускает потерю только что вставленных данных при потере лишь одного сервера. - -Для решения этой проблемы, в ClickHouse есть возможность включить «кворумную» вставку. Это значит, что клиент, осуществляющий вставку данных, получает успешный ответ после того, как данные попали на несколько (кворум) серверов. Обеспечивается линеаризуемость: клиент, получает успешный ответ после того, как данные попали на несколько реплик, *которые содержат все предыдущие данные, вставленные с кворумом* (такие реплики можно называть «синхронными»), и при запросе SELECT можно выставить настройку, разрешающую только чтение с синхронных реплик. - -Если бы свойства линеаризуемости не было, то для трёх серверов A, B, C, значения кворума = 2, и для трёх вставок данных 1, 2, 3, возможна ситуация, что первая вставка прошла на серверы A и B, вторая прошла на серверы B и C, а третья - на серверы A и C, и теперь ни один из серверов не содержит полный набор данных 1, 2, 3. - -Как ни странно, такое свойство не нужно большинству пользователей. Оно запрещает параллельно выполняющиеся вставки. А пользователи хотят вставлять данные надёжно (на более чем одну реплику), но не важно, в каком порядке. Предлагается сделать опцию, которая отключает линеаризуемость. - -Иногда пользователь хочет реализовать кворумную вставку вручную: просто соединиться с несколькими репликами и вставть на них одинаковые данные (чтобы обеспечить надёжную вставку, не ориентируясь на то, как работает механизм репликации). Сейчас ожидания пользователя не оправдываются. В ClickHouse есть механизм дедупликации для обеспечения идемпотентности вставок. Вторая вставка с такими же данными (пусть даже на другую реплику) будет проигнорирована. Надо сделать так, чтобы вместо этого, вставка одинаковых данных на другую реплику, имела такой же эффект, как если бы эти данные были получены с помощью механизма репликации. - -### 19.2. Подключение Etcd или Consul как альтернативы ZooKeeper. {#podkliuchenie-etcd-ili-consul-kak-alternativy-zookeeper} - -Алексей Лёвушкин, ВШЭ и Яндекс. - -Для координации реплик в ClickHouse используется ZooKeeper. Многие пользователи ClickHouse хотели бы иметь возможность использовать для координации некоторые другие системы вместо ZooKeeper. Рассматриваемыми вариантами таких систем являются Etcd, Consul, FoundationDB. Это весьма проблематично, так как эти системы существенно отличаются по интерфейсам и возможностям. Тем не менее, для того, чтобы эта задача стала возможной, в ClickHouse обобщён интерфейс взаимодействия с ZooKeeper, и теперь на его место можно подставлять другие реализации. - -В прошлом году, Алексей добавил модельную реализацию (mock) интерфейса ZooKeeper для тестирования. Сейчас предлагается сделать реализацию поверх Etcd, а также расширить возможности тестовой реализации. - -Upd. Алексей сделал какой-то вариант, но борется с тем, что ничего не работает. -Upd. Есть pull request на начальной стадии. - -### 19.3. Подключение YT Cypress или YDB как альтернативы ZooKeeper. {#podkliuchenie-yt-cypress-ili-ydb-kak-alternativy-zookeeper} - -Hold. Полезно для заказчиков внутри Яндекса, но есть риски. Эту задачу никто не будет делать. - -### 19.4. internal_replication = ‘auto’. {#internal-replication-auto} - -### 19.5. Реплицируемые базы данных. {#replitsiruemye-bazy-dannykh} - -В очереди, возможно Валерий Батурин, ВШЭ. - -Репликация в ClickHouse работает на уровне отдельных таблиц. Это является очень гибким решением: на одном сервере одна из таблиц может быть не реплицирована, другая иметь двухкратную репликацию, а третья - реплицирована по всем серверам. Но если все таблицы в базе данных реплицированы одинаковым образом. то это затрудняет управление кластером. Например, при восстановлени сервера, требуется отдельно создавать реплику для каждой таблицы. - -Предлагается реализовать «движок баз данных», который осуществляет репликацию метаданных (множество имеющихся таблиц и лог DDL операций над ними: CREATE, DROP, RENAME, ALTER). Пользователь сможет создать реплицируемую базу данных; при её создании или восстановлении на другом сервере, все реплицируемые таблицы будут созданы автоматически. - -### 19.6. Одновременный выбор кусков для слияния многими репликами, отказ от leader election в ZK. {#odnovremennyi-vybor-kuskov-dlia-sliianiia-mnogimi-replikami-otkaz-ot-leader-election-v-zk} - -Обсуждается. Возможно, будет делать Александр Сапин. - -### 19.7. Возможность записи данных при недоступности ZK и отказ от линейного порядка кусков в большинстве случаев. {#vozmozhnost-zapisi-dannykh-pri-nedostupnosti-zk-i-otkaz-ot-lineinogo-poriadka-kuskov-v-bolshinstve-sluchaev} - -### 19.8. Отказ от хранения в ZK множества кусков для каждой реплики отдельно. {#otkaz-ot-khraneniia-v-zk-mnozhestva-kuskov-dlia-kazhdoi-repliki-otdelno} - -### 19.9. Отказ от хранения в ZK лога вставок и мержей. Обмен данными о кусках напрямую. {#otkaz-ot-khraneniia-v-zk-loga-vstavok-i-merzhei-obmen-dannymi-o-kuskakh-napriamuiu} - -Три задачи выше обсуждаются, есть варианты. - -### 19.10. Облачные таблицы. {#oblachnye-tablitsy} - -Требует 1.6, 19.1, 19.6, 19.7, 19.8, 19.9. - - -## 20. Мутации данных. {#mutatsii-dannykh} - -Пока все задачи по точечным UPDATE/DELETE имеют низкий приоритет, но ожидаем взять в работу в середине 2020. - -### 20.1. Поддержка DELETE путём запоминания множества затронутых кусков и ключей. {#podderzhka-delete-putiom-zapominaniia-mnozhestva-zatronutykh-kuskov-i-kliuchei} - -### 20.2. Поддержка DELETE путём преобразования множества ключей в множество row_numbers на реплике, столбца флагов и индекса по диапазонам. {#podderzhka-delete-putiom-preobrazovaniia-mnozhestva-kliuchei-v-mnozhestvo-row-numbers-na-replike-stolbtsa-flagov-i-indeksa-po-diapazonam} - -### 20.3. Поддержка ленивых DELETE путём запоминания выражений и преобразования к множеству ключей в фоне. {#podderzhka-lenivykh-delete-putiom-zapominaniia-vyrazhenii-i-preobrazovaniia-k-mnozhestvu-kliuchei-v-fone} - -### 20.4. Поддержка UPDATE с помощью преобразования в DELETE и вставок. {#podderzhka-update-s-pomoshchiu-preobrazovaniia-v-delete-i-vstavok} - - -## 21. Оптимизации производительности. {#optimizatsii-proizvoditelnosti} - -### 21.1. + Параллельный парсинг форматов. {#parallelnyi-parsing-formatov} - -Начинал Олег Ершов, доделывает Никита Михайлов, помогает [Александр Кузьменков](https://github.com/akuzm). Готово. - -### 21.1.1. Избавление от лишнего копирования при параллельном парсинге форматов, если возможен mmap файла целиком. {#izbavlenie-ot-lishnego-kopirovaniia-pri-parallelnom-parsinge-formatov-esli-vozmozhen-mmap-faila-tselikom} - -### 21.2. Параллельное форматирование форматов. {#parallelnoe-formatirovanie-formatov} - -После 21.1, предположительно Никита Михайлов. Задача сильно проще чем 21.1. - -### 21.3. + Исправление низкой производительности анализа индекса в случае большого множества в секции IN. {#ispravlenie-nizkoi-proizvoditelnosti-analiza-indeksa-v-sluchae-bolshogo-mnozhestva-v-sektsii-in} - -Нужно всем (Zen, БК, DataLens, TestEnv…). Антон Попов, Q1/Q2. - -Upd. Антон делает эту задачу. Большая часть уже реализована. - -### 21.4. Использование ORDER BY ключа для оптимизации GROUP BY и DISTINCT. {#ispolzovanie-order-by-kliucha-dlia-optimizatsii-group-by-i-distinct} - -Дмитрий Рубашкин, ВШЭ. Помогает Антон Попов. - -Если таблица имеет ключ сортировки, то возможно эффективное чтение упорядоченных данных. Если запрос содержит операцию GROUP BY, содержащую по крайней мере префикс от ключа сортировки таблицы, либо инъективные функции от него, то возможно более эффективное выполнение GROUP BY: промежуточный результат агрегации финализируется и отправляется клиенту как только в потоке данных при чтении из таблицы встретился следующий ключ. - -Аналогичную оптимизацию следует реализовать для DISTINCT и LIMIT BY. - -В прошлом году, аналогичное решение сделали для операции ORDER BY. - -### 21.5. + Распараллеливание INSERT при INSERT SELECT, если это необходимо. {#rasparallelivanie-insert-pri-insert-select-esli-eto-neobkhodimo} - -[Vxider](https://github.com/Vxider), ICT -Есть pull request. - -### 21.6. Уменьшение числа потоков для SELECT в случае тривиального INSERT SELECT. {#umenshenie-chisla-potokov-dlia-select-v-sluchae-trivialnogo-insert-select} - -### 21.7. Кэш результатов запросов. {#kesh-rezultatov-zaprosov} - -[Achimbab](https://github.com/achimbab). -Есть pull request. Но это не совсем то. - -### 21.8. Взаимная интеграция аллокатора и кэша. {#vzaimnaia-integratsiia-allokatora-i-kesha} - -Михаил Кот, ВШЭ. Задача сложная и рискованная. - -Для выделения памяти, аллокаторы запрашивают её у операционной системы (`mmap`). Это возможно только для достаточно крупных кусков памяти является довольно медленной операцией. Поэтому, современные аллокаторы кэшируют крупные куски памяти в программе. При вызове free, кусок памяти, как правило, не отдаётся ОС, а остаётся для последующего переиспользования. Для выделения мелких кусков памяти, крупные куски разбиваются с помощью специальных структур данных (free-list, heap, bitmap). Для уменьшения contention в многопоточных программах, эти структуры также делаются thread-локальными. - -Часто в программе есть кэши некоторых данных. Например - кэш данных после разжатия, использующийся чтобы сэкономить на повторных запросах одних и тех же данных. При вытеснении из кэша, блок данных освобождается (`free`) и данные, бывшие в кэше, становятся недоступными для переиспользования. Но если принимать во внимание то, как работает аллокатор памяти, то оказывается, что после освобождения памяти, данные всё ещё остаются доступными в программе. И если этот кусок памяти не будет выделен аллокатором снова, его можно было бы продолжить использовать в качестве кэша. Иными словами, в программе есть domain-specific кэш, а аллокатор имеет свой кэш, и они не знают друг о друге. - -Для domain-specific кэшей (как например, кэш разжатых данных) выгодно, чтобы они использовали как можно больший объём свободной памяти. Но в этом случае, памяти может не хватить для других структур данных в программе. Если аллокатор памяти знает про кэш, то выделение памяти можно было бы делать путём вытеснения данных из кэша. - -### 21.8.1. Отдельный аллокатор для кэшей с ASLR. {#otdelnyi-allokator-dlia-keshei-s-aslr} - -В прошлом году задачу пытался сделать Данила Кутенин с помощью lfalloc из Аркадии и mimalloc из Microsoft, но оба решения не были квалифицированы для использования в продакшене. Успешная реализация задачи 21.8 отменит необходимость в этой задаче, поэтому холд. - -### 21.9. Исправить push-down выражений с помощью Processors. {#ispravit-push-down-vyrazhenii-s-pomoshchiu-processors} - -[Николай Кочетов](https://github.com/KochetovNicolai). Требует 2.1. - -### 21.10. + Улучшение эвристики PREWHERE. {#uluchshenie-evristiki-prewhere} - -Amos Bird. - -### 21.11. Peephole оптимизации запросов. {#peephole-optimizatsii-zaprosov} - -Руслан Камалов, Михаил Малафеев, Виктор Гришанин, ВШЭ - -Реализовать в ClickHouse оптимизации запросов, основанные на упрощении отдельных небольших кусков выражений (так называемые «peephole» оптимизации). Примеры: -- Замена цепочек if на multiIf. -- Удаление min/max/any-агрегатов от выражений от ключей GROUP BY. -- Вынесение арифметических операций из агрегатных функций; -- Вынесение любых функций наружу any, anyLast. -- При GROUP BY по transform или if по строкам, замена строк на Enum. - -Сделана замена цепочек if на multiIf, но внезапно оказалось, что это является не оптимизацией, а наоборот. - -### 21.12. Алгебраические оптимизации запросов. {#algebraicheskie-optimizatsii-zaprosov} - -Руслан Камалов, Михаил Малафеев, Виктор Гришанин, ВШЭ - -Реализовать в ClickHouse оптимизации запросов, основанные на алгебраических свойствах функций. Примеры: -- Обращение инъективных функций в сравнениях на равенство. -- Вынесение инъективных функцию наружу uniq. -- Удаление монотонных функций из ORDER BY. -- Удаление избыточных выражений из ORDER BY. -- Удаление из GROUP BY функций от других ключей GROUP BY. -- Удаление дублирующихся DISTINCT, ORDER BY из подзапросов. - -Несколько оптимизаций есть в PR. - -### 21.13. Fusion агрегатных функций. {#fusion-agregatnykh-funktsii} - -После или совместно с 21.11. - -### 21.14. Оптимизация запросов с помощью constraints. {#optimizatsiia-zaprosov-s-pomoshchiu-constraints} - -Constraints позволяют задать выражение, истинность которого проверяется при вставке данных в таблицу. Предположение о том, что выражение истинно, может использоваться и для оптимизации запросов. Например, встретив в запросе точно такое же выражение, можно заменить его на константу 1. - -Если выражение содержит равенство, то встретив в запросе одну из частей равенства, её можно заменить на другую часть равенства, если это сделает проще чтение данных или вычисление выражения. Например, задан constraint: `URLDomain = domain(URL)`. Значит, выражение `domain(URL)` можно заменить на `URLDomain`. - -### 21.15. Многоступенчатое чтение данных вместо PREWHERE. {#mnogostupenchatoe-chtenie-dannykh-vmesto-prewhere} - -Требует 2.1 и 21.10. - -### 21.16. Оптимизация GROUP BY с большим количеством агрегатных функций путём вычисления в два прохода. {#optimizatsiia-group-by-s-bolshim-kolichestvom-agregatnykh-funktsii-putiom-vychisleniia-v-dva-prokhoda} - -Нужно для БК. - -### 21.17. Оптимизация GROUP BY при наличии ORDER BY по тем же ключам с LIMIT. {#optimizatsiia-group-by-pri-nalichii-order-by-po-tem-zhe-kliucham-s-limit} - -Нужно для БК. - -### 21.18. Внутренняя параллелизация мержа больших состояний агрегатных функций. {#vnutrenniaia-parallelizatsiia-merzha-bolshikh-sostoianii-agregatnykh-funktsii} - -### 21.19. Оптимизация сортировки. {#optimizatsiia-sortirovki} - -Василий Морозов, Арслан Гумеров, Альберт Кидрачев, ВШЭ. -В прошлом году задачу начинал делать другой человек, но не добился достаточного прогресса. - -1. Оптимизация top sort. - -В ClickHouse используется неоптимальный вариант top sort. Суть его в том, что из каждого блока достаётся top N записей, а затем, все блоки мержатся. Но доставание top N записей у каждого следующего блока бессмысленно, если мы знаем, что из них в глобальный top N войдёт меньше. Конечно нужно реализовать вариацию на тему priority queue (heap) с быстрым пропуском целых блоков, если ни одна строка не попадёт в накопленный top. - -2. Рекурсивный вариант сортировки по кортежам. - -Для сортировки по кортежам используется обычная сортировка с компаратором, который в цикле по элементам кортежа делает виртуальные вызовы `IColumn::compareAt`. Это неоптимально - как из-за короткого цикла по неизвестному в compile-time количеству элементов, так и из-за виртуальных вызовов. Чтобы обойтись без виртуальных вызовов, есть метод `IColumn::getPermutation`. Он используется в случае сортировки по одному столбцу. Есть вариант, что в случае сортировки по кортежу, что-то похожее тоже можно применить… например, сделать метод `updatePermutation`, принимающий аргументы offset и limit, и допереставляющий перестановку в диапазоне значений, в которых предыдущий столбец имел равные значения. - -3. RadixSort для сортировки. - -Один наш знакомый начал делать задачу по попытке использования RadixSort для сортировки столбцов. Был сделан вариант indirect сортировки (для `getPermutation`), но не оптимизирован до конца - есть лишние ненужные перекладывания элементов. Для того, чтобы его оптимизировать, придётся добавить немного шаблонной магии (на последнем шаге что-то не копировать, вместо перекладывания индексов - складывать их в готовое место). Также этот человек добавил метод MSD Radix Sort для реализации radix partial sort. Но даже не проверил производительность. - -Наиболее содержательная часть задачи может состоять в применении Radix Sort для сортировки кортежей, расположенных в оперативке в виде Structure Of Arrays неизвестного в compile-time размера. Это может работать хуже, чем то, что описано в пункте 2… Но попробовать не помешает. - -4. Three-way comparison sort. - -Виртуальный метод `compareAt` возвращает -1, 0, 1. Но алгоритмы сортировки сравнениями обычно рассчитаны на `operator<` и не могут получить преимущества от three-way comparison. А можно ли написать так, чтобы преимущество было? - -5. pdq partial sort - -Хороший алгоритм сортировки сравнениями `pdqsort` не имеет варианта partial sort. Заметим, что на практике, почти все сортировки в запросах ClickHouse являются partial_sort, так как `ORDER BY` почти всегда идёт с `LIMIT`. Кстати, Данила Кутенин уже попробовал это и показал, что в тривиальном случае преимущества нет. Но не очевидно, что нельзя сделать лучше. - -### 21.20. Использование материализованных представлений для оптимизации запросов. {#ispolzovanie-materializovannykh-predstavlenii-dlia-optimizatsii-zaprosov} - -В ByteDance есть готовая реализация, но они её боятся из-за, возможно, низкого качества кода. - -### 21.21. + Чтение больших файлов с помощью mmap. {#chtenie-bolshikh-failov-s-pomoshchiu-mmap} - -Сделан вариант, но достаточно топорный. Без тестирования в продакшене включать по-умолчанию нельзя. - -### 21.22. Userspace page cache. {#userspace-page-cache} - -Требует 21.8. - -### 21.23. Ускорение работы с вторичными индексами. {#uskorenie-raboty-s-vtorichnymi-indeksami} - -zhang2014. -Есть pull request. - - -## 22. Долги и недоделанные возможности. {#dolgi-i-nedodelannye-vozmozhnosti} - -### 22.1. + Исправление неработающих таймаутов, если используется TLS. {#ispravlenie-nerabotaiushchikh-taimautov-esli-ispolzuetsia-tls} - -Нужно для Яндекс.Облака. Сделал Алексей Миловидов. - -### 22.2. + Убрать возможность изменить настройки в native протоколе в случае readonly. {#ubrat-vozmozhnost-izmenit-nastroiki-v-native-protokole-v-sluchae-readonly} - -N.Vartolomei. - -### 22.3. Защита от абсурдно заданных пользователем кодеков. {#zashchita-ot-absurdno-zadannykh-polzovatelem-kodekov} - -### 22.4. + Исправление оставшихся deadlocks в табличных RWLock-ах. {#ispravlenie-ostavshikhsia-deadlocks-v-tablichnykh-rwlock-akh} - -Александр Казаков. Нужно для Яндекс.Метрики и Datalens. Задача постепенно тащится и исправлениями в соседних местах стала менее актуальна. -В Q1 будет сделана или отменена с учётом 1.2. и 1.3. -Upd. Добавили таймауты. - -### 22.5. + Исправление редких срабатываний TSan в stress тестах в CI. {#ispravlenie-redkikh-srabatyvanii-tsan-v-stress-testakh-v-ci} - -Александр Казаков сделал эту задачу. - -### 22.6. + Изменение только DEFAULT в ALTER TABLE может поменять тип столбца. {#izmenenie-tolko-default-v-alter-table-mozhet-pomeniat-tip-stolbtsa} - -Александр Сапин сделал эту задачу. - -### 22.7. + Row-Level Security не работает в случае наличия в запросе IN подзапросов. {#row-level-security-ne-rabotaet-v-sluchae-nalichiia-v-zaprose-in-podzaprosov} - -Нужно для Метрики. Иван Лежанкин. - -### 22.8. + Исправить десериализацию параметров для параметризованных запросов. {#ispravit-deserializatsiiu-parametrov-dlia-parametrizovannykh-zaprosov} - -Хотел исправить Василий Немков, Altinity, но есть маленькие затруднения, наверное переделает Алексей Миловидов. - -### 22.9. Разобраться с десериализацией массивов со значениями по-умолчанию в Protobuf формате в случае protobuf 3. {#razobratsia-s-deserializatsiei-massivov-so-znacheniiami-po-umolchaniiu-v-protobuf-formate-v-sluchae-protobuf-3} - -[Виталий Баранов](https://github.com/vitlibar). Возможно, это - фундаментальная проблема и следует её только документировать. -Кажется, отменяем, но пока ещё не всё ясно. - -### 22.10. + Исправление дрифта при отслеживании потребления памяти запросами. {#ispravlenie-drifta-pri-otslezhivanii-potrebleniia-pamiati-zaprosami} - -Требует 6.3., но можно улучшить отдельными хаками. Нужно Метрике и БК. - -### 22.11. + Более простая ser/de настроек запросов. {#bolee-prostaia-serde-nastroek-zaprosov} - -И пропуск неизвестных настроек. Важно для Метрики для упрощения апгрейда без изменения конфига. -[Виталий Баранов](https://github.com/vitlibar), готово. - -### 22.12. + Исправление низкой производительности чтения из Kafka. {#ispravlenie-nizkoi-proizvoditelnosti-chteniia-iz-kafka} - -Для ClickHouse нехарактерно наличие кода, обладающего столь низкой производительностью. Практики разработки не подразумевают, что такой код должен попасть в продакшен без надлежащего тестирования производительности. - -Изначально было назначено на [Ивана Лежанкина](https://github.com/abyss7), но по неизвестной причине было не сделано в течение нескольких месяцев. -Сделал Михаил Филимонов, Altinity. - -### 22.13. + Посмотреть, почему не работают некоторые collations. {#posmotret-pochemu-ne-rabotaiut-nekotorye-collations} - -Изначально было назначено на [Ивана Лежанкина](https://github.com/abyss7), но в результате сделал Александр Сапин. - -### 22.14. + Посмотреть, почему не работает StorageSet для MergeTree таблиц при некоторых условиях. {#posmotret-pochemu-ne-rabotaet-storageset-dlia-mergetree-tablits-pri-nekotorykh-usloviiakh} - -Вроде бы сделал Никита Михайлов - проверить существующие issues на эту тему. - -### 22.15. Нормализация коммитов в Kafka и идемпотентности операций. {#normalizatsiia-kommitov-v-kafka-i-idempotentnosti-operatsii} - -Altinity. - -### 22.16. + Исправление низкой производительности кодека DoubleDelta. {#ispravlenie-nizkoi-proizvoditelnosti-kodeka-doubledelta} - -Василий Немков, Altinity - в процессе. -Можно считать, что сделано, хотя отсутствие SIMD оптимизаций для variable length кодеков - это ужасно. - -### 22.17. Консистентно работающий POPULATE для MaterializedView. {#konsistentno-rabotaiushchii-populate-dlia-materializedview} - -### 22.18. Исправление заметного падения производительности форматов после добавления доменов типов. {#ispravlenie-zametnogo-padeniia-proizvoditelnosti-formatov-posle-dobavleniia-domenov-tipov} - -Василий Немков, Altinity. - -### 22.19. + Одновременное использование SAMPLE и PREWHERE. {#odnovremennoe-ispolzovanie-sample-i-prewhere} - -Нужно для Метрики. [Николай Кочетов](https://github.com/KochetovNicolai), ноябрь 2019. - -### 22.20. + Неправильная работа PREWHERE при некоторых условиях. {#nepravilnaia-rabota-prewhere-pri-nekotorykh-usloviiakh} - -[Николай Кочетов](https://github.com/KochetovNicolai), декабрь 2019. - -### 22.21. + Неправильное поведение DateTime в районе начала unix epoch. {#nepravilnoe-povedenie-datetime-v-raione-nachala-unix-epoch} - -Алексей Миловидов. - -### 22.22. Nullable в функции transform и в CASE по множеству значений. {#nullable-v-funktsii-transform-i-v-case-po-mnozhestvu-znachenii} - -После 10.14. - -[\#7237](https://github.com/ClickHouse/ClickHouse/issues/7237) -[\#2655](https://github.com/ClickHouse/ClickHouse/issues/2655) - -### 22.23. Правильная обработка Nullable в функциях, которые кидают исключение на default значении: modulo, intDiv. {#pravilnaia-obrabotka-nullable-v-funktsiiakh-kotorye-kidaiut-iskliuchenie-na-default-znachenii-modulo-intdiv} - -### 22.24. Излишняя фильтрация ODBC connection string. {#izlishniaia-filtratsiia-odbc-connection-string} - -Нужно для Метрики. Алексей Миловидов. - -### 22.25. Избавиться от библиотеки btrie. {#izbavitsia-ot-biblioteki-btrie} - -Алексей Миловидов. Низкий приоритет. - -### 22.26. Плохая производительность quantileTDigest. {#plokhaia-proizvoditelnost-quantiletdigest} - -[\#2668](https://github.com/ClickHouse/ClickHouse/issues/2668) - -Алексей Миловидов или будет переназначено. - -### 22.27. Проверить несколько PR, которые были закрыты zhang2014 и sundy-li. {#proverit-neskolko-pr-kotorye-byli-zakryty-zhang2014-i-sundy-li} - -Алексей Миловидов. - -### 22.28. Изучить и исправить поведение работы с Kafka при ребалансировке. {#izuchit-i-ispravit-povedenie-raboty-s-kafka-pri-rebalansirovke} - -Altinity. - -### 22.29. + Уязвимость DDL для словарей executable. {#uiazvimost-ddl-dlia-slovarei-executable} - -[Александр Сапин](https://github.com/alesapin) - - -## 23. Default Festival. {#default-festival} - -### 23.1. + Включение minimalistic_part_header в ZooKeeper. {#vkliuchenie-minimalistic-part-header-v-zookeeper} - -Сильно уменьшает объём данных в ZooKeeper. Уже год в продакшене в Яндекс.Метрике. -Алексей Миловидов, ноябрь 2019. - -### 23.2. Включение distributed_aggregation_memory_efficient. {#vkliuchenie-distributed-aggregation-memory-efficient} - -Есть риски меньшей производительности лёгких запросов, хотя производительность тяжёлых запросов всегда увеличивается. - -### 23.3. Включение min_bytes_to_external_sort и min_bytes_to_external_group_by. {#vkliuchenie-min-bytes-to-external-sort-i-min-bytes-to-external-group-by} - -Желательно 5.2. и 13.1. - -### 23.4. Включение синхронной записи в Distributed таблицы по-умолчанию. {#vkliuchenie-sinkhronnoi-zapisi-v-distributed-tablitsy-po-umolchaniiu} - -Есть гипотеза, что плохо работает на очень больших кластерах. - -### 23.5. Включение compile_expressions. {#vkliuchenie-compile-expressions} - -Требует 7.2. Задачу изначально на 99% сделал Денис Скоробогатов, ВШЭ и Яндекс. Остальной процент доделывал Алексей Миловидов, а затем [Александр Сапин](https://github.com/alesapin). - -### 23.6. Включение учёта порядка столбцов в CSV. {#vkliuchenie-uchiota-poriadka-stolbtsov-v-csv} - -Просто аккуратно включить. - -### 23.7. Включение NULL as Default в CSV. {#vkliuchenie-null-as-default-v-csv} - -Просто аккуратно включить. - -### 23.8. + Включение оптимизации VALUES. {#vkliuchenie-optimizatsii-values} - -Просто аккуратно включить. - -### 23.9. + Включение Processors. {#vkliuchenie-processors} - -Q1. [Николай Кочетов](https://github.com/KochetovNicolai). - -### 23.10. Включение mlock бинарника. {#vkliuchenie-mlock-binarnika} - -Возможность mlock бинарника сделал Олег Алексеенков [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) -. Поможет, когда на серверах кроме ClickHouse работает много посторонних программ (мы иногда называем их в шутку «треш-программами»). - - -## 24. Экспериментальные задачи. {#eksperimentalnye-zadachi} - -### 24.1. Веб-интерфейс для просмотра состояния кластера и профилирования запросов. {#veb-interfeis-dlia-prosmotra-sostoianiia-klastera-i-profilirovaniia-zaprosov} - -Антон Мамонов, УрФУ, Яндекс. - -Внутри ClickHouse есть богатые возможности по интроспекции и профилированию. Эти возможности доступны через системные таблицы и использовать их приходится путём формулирования SQL запросов. Это неудобно. - -Вместо этого предлагается сделать, чтобы ClickHouse отдавал HTML страницу, реализующую интерактивный web-интерфейс со следующими возможностями: -- отображение состояния кластеров (какие кластеры известны, статус каждого сервера); -- графики нагрузки текущего сервера или выбранного сервера кластера; -- обновляемый список запросов; -- просмотр лога запросов с наиболее востребованными фильтрациями по одной кнопке; -- просмотр лога на кластере, например - последние ошибки; -- просмотр метрик использования ресурсов, flame graph и pprof-граф для выбранных запросов; -- отчёт по использованию кластера (пример: количество ядер CPU по пользователям за сегодня). - -### 24.2. Экспериментальные алгоритмы сжатия. {#eksperimentalnye-algoritmy-szhatiia} - -ClickHouse поддерживает LZ4 и ZSTD для сжатия данных. Эти алгоритмы являются парето-оптимальными по соотношению скорости и коэффициентам сжатия среди достаточно известных. Тем не менее, существуют менее известные алгоритмы сжатия, которые могут превзойти их по какому-либо критерию. Из потенциально более быстрых по сравнимом коэффициенте сжатия: Lizard, LZSSE, density. Из более сильных: bsc и csc. Необходимо изучить эти алгоритмы, добавить их поддержку в ClickHouse и исследовать их работу на тестовых датасетах. - -### 24.3. Экспериментальные кодеки. {#eksperimentalnye-kodeki} - -Вероника Фалчикова, Лада Торчик, ВШЭ. - -Существуют специализированные алгоритмы кодирования числовых последовательностей: Group VarInt, MaskedVByte, PFOR. Необходимо изучить наиболее эффективные реализации этих алгоритмов. Примеры вы сможете найти на https://github.com/lemire и https://github.com/powturbo/ а также https://github.com/schizofreny/middle-out - -Внедрить их в ClickHouse в виде кодеков и изучить их работу на тестовых датасетах. - -### 24.4. Шифрование в ClickHouse на уровне VFS. {#shifrovanie-v-clickhouse-na-urovne-vfs} - -Данные в ClickHouse хранятся без шифрования. При наличии доступа к дискам, злоумышленник может прочитать данные. Предлагается реализовать два подхода к шифрованию: - -1. Шифрование на уровне VFS. - -Обсуждаются детали реализации. Q3/Q4. - -### 24.5. Поддержка функций шифрования для отдельных значений. {#podderzhka-funktsii-shifrovaniia-dlia-otdelnykh-znachenii} - -Смотрите также 24.5. - -2. Шифрование отдельных значений. - Для этого требуется реализовать функции шифрования и расшифрования, доступные из SQL. Для шифрования реализовать возможность добавления нужного количества случайных бит для исключения одинаковых зашифрованных значений на одинаковых данных. Это позволит реализовать возможность «забывания» данных без удаления строк таблицы: можно шифровать данные разных клиентов разными ключами, и для того, чтобы забыть данные одного клиента, потребуется всего лишь удалить ключ. - -### 24.6. Userspace RAID. {#userspace-raid} - -Глеб Новиков, ВШЭ. - -RAID позволяет одновременно увеличить надёжность хранения данных на дисках и увеличить скорость работы дискового массива. Обычно RAID настраивается с помощью встроенных возможностей ядра Linux (mdraid) или с помощью hardware контроллера. У этого есть следующие ограничения: - -1. Иногда (в облачной инфраструктуре некоторых компаний) сервер предоставляется с отдельными дисками, подмонтированными в виде отдельных разделов (JBOD), без возможности создания RAID. - -2. В ClickHouse для обеспечения избыточности обычно используется репликация между серверами. Но при восстановлении одного из дисков RAID не используются данные с реплик, а в случае отказа одного из дисков в RAID-0, приходится передавать с реплики все данные, а не только данные, соответствующие одному из дисков. Это происходит, потому что RAID не интегрирован в ClickHouse и «не знает» про его особенности. - -3. Отсутствуют продвинутые варианты обеспечения избыточности, как например, LRC. - -Для преодоления этих ограничений, предлагается реализовать в ClickHouse встроенный алгоритм расположения данных на дисках. - -### 24.7. Вероятностные структуры данных для фильтрации по подзапросам. {#veroiatnostnye-struktury-dannykh-dlia-filtratsii-po-podzaprosam} - -Рузель Ибрагимов, ВШЭ и Яндекс. - -Частой задачей является выполнение запроса с фильтрацией по множеству, полученному по подзапросу. Пример: найти пользователей, которые заходили на сайт сегодня и заходили неделю назад. Это выражается в виде запроса: `SELECT UserID FROM table WHERE EventDate = today() AND UserID IN (SELECT ...)`. При выполнении этого запроса, сначала выполняется подзапрос в правой части `IN` и формируется хэш-таблица в оперативке; затем эта хэш-таблица используется для фильтрации. - -Иногда объём данных достаточно большой, и хэш-таблица не помещается в оперативку. В этом случае можно рассмотреть в качестве варианта приближённый рассчёт: найти пользователей, которые заходили на сайт сегодня и наверное заходили неделю назад. Для этого можно вместо хэш-таблицы использовать Bloom Filter. Другая задача: найти пользователей, которые встречались, скорее всего, не менее некоторого количества раз. Для этого можно использовать Counting Bloom Filter. Также следует изучить структуры данных Quotient Filter и Cuckoo Filer, а ещё - секретный алгоритм Chaotic Map от Андрея Плахова. - -Предлагается реализовать это в языке запросов ClickHouse с помощью специального синтаксиса, например `x IN BLOOM FILTER (n, m) (SELECT ...)`. - -### 24.8. Специализация векторизованного кода для AVX/AVX2/AVX512 и ARM NEON. {#spetsializatsiia-vektorizovannogo-koda-dlia-avxavx2avx512-i-arm-neon} - -[\#1017](https://github.com/ClickHouse/ClickHouse/issues/1017) - -Дмитрий Ковальков, ВШЭ и Яндекс. - -Подавляющее большинство кода ClickHouse написана для x86_64 с набором инструкций до SSE 4.2 включительно. Лишь отдельные редкие функции поддерживают AVX/AVX2/AVX512 с динамической диспетчеризацией. - -В первой части задачи, следует добавить в ClickHouse реализации некоторых примитивов, оптимизированные под более новый набор инструкций. Например, AVX2 реализацию генератора случайных чисел pcg: https://github.com/lemire/simdpcg - -Во второй части задачи, предлагается адаптировать существующие куски кода, использующие SSE intrinsics на AVX/AVX2 и сравнить производительность. Также рассматривается оптимизация под ARM NEON. - -### 24.9. Общий подход к CPU dispatching в фабрике функций. {#obshchii-podkhod-k-cpu-dispatching-v-fabrike-funktsii} - -Дмитрий Ковальков, ВШЭ и Яндекс. - -Продолжение 24.8. - -Upd. Есть pull request. - -### 24.10. Поддержка типов half/bfloat16/unum. {#podderzhka-tipov-halfbfloat16unum} - -[\#7657](https://github.com/ClickHouse/ClickHouse/issues/7657) - -Рустам Гусейн-заде, ВШЭ. - -### 24.11. User Defined Functions. {#user-defined-functions} - -Игорь Минеев, ВШЭ. - -ClickHouse предоставляет достаточно богатый набор встроенных функций языка запросов, но не позволяет пользователю добавлять свои функции без редактировния исходников и перекомпиляции системы. Это мотивировано следующими потенциальными проблемами: - -1. ClickHouse является array-oriented системой, и все функции внутри кода принимают для обработки целые массивы, а не отдельные значения. Это усложняет внутренний интерфейс и делает его менее удобным для пользователя. -2. Предоставление возможности подключения UDF в виде shared библиотек, потребовало бы фиксировать этот интерфейс или поддерживать обратную совместимость, тогда как мы бы хотели, при разработке ClickHouse, менять этот интерфейс по своему усмотрению без оглядки. -3. Сложность внутренних структур данных повышает вероятность ошибок типа buffer overflow и повреждения памяти, что сильно затруднит сопровождение ClickHouse с пользовательскими функциями. - -Тем не менее, можно выбрать более аккуратный подход, избегающий непосредственной линковки с shared библиотеками. - -Сначала можно реализовать поддержку UDF в виде выражений, составленных из простых функций ClickHouse. В ClickHouse есть встроенная кодогенерация на LLVM, что позволит таким функциям работать весьма эффективно. Но этот подход весьма ограничен и поэтому не является исчерпывающим. - -Затем предлагается реализовать поддержку UDF в виде исходников на C++, которые компилируются в runtime, с использованием заголовочных файлов ClickHouse. Требование компиляции из исходников вместо shared библиотек, позволит ослабить необходимость в поддержке совместимости ABI. - -Для безопасности, потребуется исследовать возможность размещения буферов данных в shared memory для выполнения UDF в отдельных процессах с изоляцией по памяти. Возможно, для этого пригодится интеграция с Apache Arrow. - -Также рассматривается возможность написания UDF на Rust, а также использование Web Assembly. Отдельно можно рассмотреть подключение NumPy и R и других технологий, которые предоставляют операции над целыми массивами. - -### 24.12. GPU offloading. {#gpu-offloading} - -Риск состоит в том, что даже известные GPU базы, такие как OmniSci, работают медленнее, чем ClickHouse. -Преимущество возможно только на полной сортировке и JOIN. -Алексей Соловей, nVidia и Рита Коннова, ВШЭ. - -В компании nVidia сделали прототип offloading вычисления GROUP BY с некоторыми из агрегатных функций в ClickHouse и обещат предоставить исходники в публичный доступ для дальнейшего развития. Предлагается изучить этот прототип и расширить его применимость для более широкого сценария использования. В качестве альтернативы, предлагается изучить исходные коды системы `OmniSci` или `Alenka` или библиотеку `CUB` https://nvlabs.github.io/cub/ и применить некоторые из алгоритмов в ClickHouse. - -Upd. В компании nVidia выложили прототип, теперь нужна интеграция в систему сборки. -Upd. Интеграция в систему сборки - Иван Лежанкин. -Upd. Есть прототип bitonic sort. - -### 24.13. Stream запросы. {#stream-zaprosy} - -Пререквизит для ClickHouse как CEP-системы. - -### 24.14. Window функции. {#window-funktsii} - -[\#1469](https://github.com/ClickHouse/ClickHouse/issues/1469) - -Требует 2.1. - -### 24.15. Поддержка полуструктурированных данных. {#podderzhka-polustrukturirovannykh-dannykh} - -Требует 1.14 и 2.10. - -### 24.16. Улучшение эвристики слияний. {#uluchshenie-evristiki-sliianii} - -В прошлом году исследование по этой задаче сделал Егор Соловьёв, ВШЭ и Яндекс.Такси. Его исследование показало, что алгоритм нельзя существенно улучшить путём изменения параметров. Но исследование лажовое, так как рассмотрен только уже использующийся алгоритм. То есть, задача остаётся открытой. - -### 24.17. Экспериментальные способы ускорения параллельного GROUP BY. {#eksperimentalnye-sposoby-uskoreniia-parallelnogo-group-by} - -Максим Серебряков - -Задача в работе. - -### 24.18. Не TCP протокол передачи файлов при репликации. {#ne-tcp-protokol-peredachi-failov-pri-replikatsii} - -### 24.19. Промежуточное состояние GROUP BY как структура данных для key-value доступа. {#promezhutochnoe-sostoianie-group-by-kak-struktura-dannykh-dlia-key-value-dostupa} - -### 24.20. Short-circuit вычисления некоторых выражений. {#short-circuit-vychisleniia-nekotorykh-vyrazhenii} - -Два года назад задачу попробовала сделать Анастасия Царькова, ВШЭ и Яндекс, но реализация получилась слишком неудобной и её удалили. - -### 24.21. Реализация в ClickHouse протокола распределённого консенсуса. {#realizatsiia-v-clickhouse-protokola-raspredelionnogo-konsensusa} - -Имеет смысл только после 19.2. - -### 24.22. Вывод типов по блоку данных. Вывод формата данных по примеру. {#vyvod-tipov-po-bloku-dannykh-vyvod-formata-dannykh-po-primeru} - -Задача отложена. - -ClickHouse является строго типизированной системой. Для того, чтобы прочитать данные в каком либо формате (например, CSV), требуется заранее указать типы данных. Если при чтении формата выясняется, что данные не могут быть прочитаны в рамках заданных типов, то кидается исключение. - -ClickHouse также может использоваться для быстрой аналитики по локальным файлам, без загрузки их в базу данных (программа `clickhouse-local`). В этом случае, его использование может заменить `awk`, `sed`, `grep`. Но остаётся неудобство - необходимость указания типов данных. - -Предлагается реализовать функциональность вывода типов по первому блоку данных путём применения эвристик и постепенного расширения типов. - -Другая экспериментальная задача - реализация эвристик для обработки данных в неизвестном построчном текстовом формате. Детектирование CSV, TSV, JSON, детектирование разделителей и форматов значений. - -### 24.23. Минимальная поддержка транзакций для множества вставок/чтений. {#minimalnaia-podderzhka-tranzaktsii-dlia-mnozhestva-vstavokchtenii} - -Максим Кузнецов, ВШЭ. - -Таблицы типа MergeTree состоят из набора независимых неизменяемых «кусков» данных. При вставках данных (INSERT), формируются новые куски. При модификациях данных (слияние кусков), формируются новые куски, а старые - становятся неактивными и перестают использоваться следующими запросами. Чтение данных (SELECT) производится из снэпшота множества кусков на некоторый момент времени. Таким образом, чтения и вставки не блокируют друг друга. - -Если же выполняется несколько запросов SELECT, то чтение данных может осуществляться из снэпшотов по состоянию на несколько разных моментов времени и быть неконсистентным. Пример: пользователю отображается отчёт из нескольких графиков и таблиц, но из-за того, что между разными запросами, данные успели обновиться, отображаемые данные не соответствуют друг другу. - -Пример с другой стороны - пользователь хочет осуществить несколько вставок (INSERT) в одну или несколько таблиц, но так, чтобы данные появились в них атомарно с точки зрения других запросов (SELECT). - -Для решения этих проблем, предлагается ввести глобальные метки времени для кусков данных (сейчас уже есть инкрементальные номера кусков, но они выделяются в рамках одной таблицы). Первым шагом сделаем эти метки времени в рамках сервера. Вторым шагом сделаем метки времени в рамках всех серверов, но неточные на основе локальных часов. Третьим шагом сделаем метки времени, выдаваемые сервисом координации. - -### 24.24. Реализация алгоритмов differential privacy. {#realizatsiia-algoritmov-differential-privacy} - -[\#6874](https://github.com/ClickHouse/ClickHouse/issues/6874) - -Артём Вишняков, ВШЭ. - -### 24.25. Интеграция в ClickHouse функциональности обработки HTTP User Agent. {#integratsiia-v-clickhouse-funktsionalnosti-obrabotki-http-user-agent} - -[\#157](https://github.com/ClickHouse/ClickHouse/issues/157) -Есть хороший код в Яндекс.Метрике. Получено согласие от руководства. -Михаил Филитов, ВШЭ. - -### 24.26. Поддержка open tracing или аналогов. {#podderzhka-open-tracing-ili-analogov} - -[\#5182](https://github.com/ClickHouse/ClickHouse/issues/5182) - -Александр Кожихов, ВШЭ и Яндекс.YT. - -### 24.27. Реализация алгоритмов min-hash, sim-hash для нечёткого поиска полудубликатов. {#realizatsiia-algoritmov-min-hash-sim-hash-dlia-nechiotkogo-poiska-poludublikatov} - -[\#7649](https://github.com/ClickHouse/ClickHouse/pull/7649) - -ucasFL, ICT. - -Алгоритмы min-hash и sim-hash позволяют вычислить для текста несколько хэш-значений таких, что при небольшом изменении текста, по крайней мере один из хэшей не меняется. Вычисления можно реализовать на n-грамах и словарных шинглах. Предлагается добавить поддержку этих алгоритмов в виде функций в ClickHouse и изучить их применимость для задачи нечёткого поиска полудубликатов. - -Есть pull request, есть что доделывать. - -### 24.28. Другой sketch для квантилей. {#drugoi-sketch-dlia-kvantilei} - -Похоже на quantileTiming, но с логарифмическими корзинами. См. DDSketch. - -### 24.29. Поддержка Arrow Flight. {#podderzhka-arrow-flight} - -[\#7554](https://github.com/ClickHouse/ClickHouse/issues/7554) - -Жанна Зосимова, ВШЭ. - -### 24.30. ClickHouse как графовая СУБД. {#clickhouse-kak-grafovaia-subd} - -Amos Bird, но его решение слишком громоздкое и пока не open-source. - -### 24.31. Кореллированные подзапросы. {#korellirovannye-podzaprosy} - -Перепиcывание в JOIN. Не раньше 21.11, 21.12, 21.9. Низкий приоритет. - -### 24.32. Поддержка GRPC. {#podderzhka-grpc} - -Мария Конькова, ВШЭ и Яндекс. -Также смотрите 24.29. - -В ClickHouse есть два основных протокола: родной протокол общения между серверами и HTTP/1.1 протокол. HTTP/1.1 протокол удобен для работы из самых разных языков программирования, но, в отличие от родного протокола, не поддерживает двусторонний обмен информацией во время запроса: -- передачу информации о прогрессе во время выполнения запроса; -- передачу логов во время выполнения запроса; -- отмену выполнения запроса в тот момент как данные ещё не начали передаваться; - -Рассматривается вариант - поддержка GRPC в ClickHouse. Здесь есть неочевидные моменты, такие как - эффективная передача массивов данных в column-oriented формате - насколько удобно будет обернуть это в GRPC. - -Задача в работе, есть pull request. - -## 25. DevRel {#devrel} - -### 25.1. + Перевод инструкции для начинающих разработчиков. {#perevod-instruktsii-dlia-nachinaiushchikh-razrabotchikov} - -Александр Казаков, ноябрь 2019. - -### 25.2. + Вычитка и выкладка статьи про обфускацию данных на английском. {#vychitka-i-vykladka-stati-pro-obfuskatsiiu-dannykh-na-angliiskom} - -Эми, Александр Казаков, Алексей Миловидов, Q1. -Готово к выкладке. - -### 25.3. Подготовка статьи «Секреты оптимизации производительности ClickHouse». {#podgotovka-stati-sekrety-optimizatsii-proizvoditelnosti-clickhouse} - -Алексей Миловидов, Леонид. - -### 25.4. Подготовка статьи «Профайлер запросов: трудный путь». {#podgotovka-stati-profailer-zaprosov-trudnyi-put} - -Алексей Миловидов, Леонид. - -### 25.5. Подготовка статьи «Тестирование ClickHouse, которое мы заслужили». {#podgotovka-stati-testirovanie-clickhouse-kotoroe-my-zasluzhili} - -### 25.6. Перевод этих статей на английский. {#perevod-etikh-statei-na-angliiskii} - -Требует 25.3, 25.4, 25.5. Эми - -### 25.7. Перевод статьи Данилы Кутенина на английский. {#perevod-stati-danily-kutenina-na-angliiskii} - -Эми - -### 25.8. + Выступление keynote на BDTC. {#vystuplenie-keynote-na-bdtc} - -Алексей Миловидов - -### 25.9. Подготовка докладчиков: khvostikao, ilezhankin, nikitamikhailov, akuzm и другие. {#podgotovka-dokladchikov-khvostikao-ilezhankin-nikitamikhailov-akuzm-i-drugie} - -[Ольга Хвостикова](https://github.com/stavrolia), [Иван Лежанкин](https://github.com/abyss7), Никита Михайлов, [Александр Кузьменков](https://github.com/akuzm), Артём Зуйков. -Уже готовые докладчики: Алексей Миловидов, [Николай Кочетов](https://github.com/KochetovNicolai), [Александр Сапин](https://github.com/alesapin). -Получаем минимум 8 докладчиков в 2020 году. - -### 25.10. Митапы в России и Беларуси: Москва x2 + митап для разработчиков или хакатон, Санкт-Петербург, Минск, Нижний Новгород, Екатеринбург, Новосибирск и/или Академгородок, Иннополис или Казань. {#mitapy-v-rossii-i-belarusi-moskva-x2-mitap-dlia-razrabotchikov-ili-khakaton-sankt-peterburg-minsk-nizhnii-novgorod-ekaterinburg-novosibirsk-iili-akademgorodok-innopolis-ili-kazan} - -Екатерина - организация. Upd. Проведено два онлайн митапа на русском. - -### 25.11. Митапы зарубежные: восток США (Нью Йорк, возможно Raleigh), возможно северо-запад (Сиэтл), Китай (Пекин снова, возможно митап для разработчиков или хакатон), Лондон. {#mitapy-zarubezhnye-vostok-ssha-niu-iork-vozmozhno-raleigh-vozmozhno-severo-zapad-sietl-kitai-pekin-snova-vozmozhno-mitap-dlia-razrabotchikov-ili-khakaton-london} - -[Иван Блинков](https://github.com/blinkov/) - организация. Две штуки в США запланированы. Upd. Два митапа в США и один в Европе проведены. - -### 25.12. Статья «научная» - про устройство хранения данных и индексов или whitepaper по архитектуре. Есть вариант подать на VLDB. {#statia-nauchnaia-pro-ustroistvo-khraneniia-dannykh-i-indeksov-ili-whitepaper-po-arkhitekture-est-variant-podat-na-vldb} - -Низкий приоритет. Алексей Миловидов. - -### 25.13. Участие во всех мероприятиях Яндекса, которые связаны с разработкой бэкенда, C++ разработкой или с базами данных, возможно участие в DevRel мероприятиях. {#uchastie-vo-vsekh-meropriiatiiakh-iandeksa-kotorye-sviazany-s-razrabotkoi-bekenda-c-razrabotkoi-ili-s-bazami-dannykh-vozmozhno-uchastie-v-devrel-meropriiatiiakh} - -Алексей Миловидов и все подготовленные докладчики - -### 25.14. Конференции в России: все HighLoad, возможно CodeFest, DUMP или UWDC, возможно C++ Russia. {#konferentsii-v-rossii-vse-highload-vozmozhno-codefest-dump-ili-uwdc-vozmozhno-c-russia} - -Алексей Миловидов и все подготовленные докладчики. -Upd. Есть Saint HighLoad online. - -### 25.15. Конференции зарубежные: Percona, DataOps, попытка попасть на более крупные. {#konferentsii-zarubezhnye-percona-dataops-popytka-popast-na-bolee-krupnye} - -Алексей Миловидов и все подготовленные докладчики - -### 25.16. Сайт play.clickhouse. {#sait-play-clickhouse} - -Цель состоит в реализации сайта, на котором можно попробовать задавать произвольные запросы к временному экземпляру ClickHouse и изучать его поведение. Из похожих проектов можно отметить: [Compiler Explorer](https://godbolt.org/), http://ideone.com/, [SQLFiddle](http://sqlfiddle.com/), [DB-Fiddle](https://www.db-fiddle.com/). - -С помощью такого сайта можно решать следующие задачи: -- ознакомление с языком запросов ClickHouse; -- демонстрация примеров из документации; -- демонстрация скорости работы на тестовых датасетах; -- сравнение поведения разных версий ClickHouse друг с другом; -- демонстрация неожиданного поведения или багов; - -Требуется проработать вопрос безопасности и изоляции инстансов (поднятие в контейнерах с ограничениями по сети), подключение тестовых датасетов с помощью copy-on-write файловой системы; органичения ресурсов. - -Есть минимальный прототип. Сделал Илья Яцишин. Этот прототип не позволяет делиться ссылками на результаты запросов. - -### 25.17. Взаимодействие с ВУЗами: ВШЭ, УрФУ, ICT Beijing. {#vzaimodeistvie-s-vuzami-vshe-urfu-ict-beijing} - -Алексей Миловидов и вся группа разработки - -### 25.18. - Лекция в ШАД. {#lektsiia-v-shad} - -Алексей Миловидов - -### 25.19. Участие в курсе разработки на C++ в ШАД. {#uchastie-v-kurse-razrabotki-na-c-v-shad} - -### 25.20. Ещё одно сравнение производительности аналитических СУБД. {#eshchio-odno-sravnenie-proizvoditelnosti-analiticheskikh-subd} - -Матвей Бубнов, УрФУ - -Существуют мало известные специализированные СУБД, способные конкурировать с ClickHouse по скорости обработки некоторых классов запросов. Пример: `TDEngine` и `DolphinDB`, `VictoriaMetrics`, а также `Apache Doris` и `LocustDB`. Предлагается изучить и классифицировать архитектурные особенности этих систем - их особенности и преимущества. Установить эти системы, загрузить тестовые данные, изучить производительность. Проанализировать, за счёт чего достигаются преимущества. - -### 25.21. Повторное награждение контрибьюторов в Китае. {#povtornoe-nagrazhdenie-kontribiutorov-v-kitae} - -### 25.22. On-site помощь с ClickHouse компаниям в дни рядом с мероприятиями. {#on-site-pomoshch-s-clickhouse-kompaniiam-v-dni-riadom-s-meropriiatiiami} - -[Иван Блинков](https://github.com/blinkov/) - организация. Проверил мероприятие для турецкой компании. - -### 25.23. Новый мерч для ClickHouse. {#novyi-merch-dlia-clickhouse} - -### 25.24. Конкурсы bughunter или оптимизации кода на C++. {#konkursy-bughunter-ili-optimizatsii-koda-na-c} - -Проведение конкурсов должно начинаться для сотрудников Яндекса, пока нет согласования. - -### 25.25. Семинары для потенциальных клиентов Яндекс.Облака. {#seminary-dlia-potentsialnykh-klientov-iandeks-oblaka} - -По мере необходимости. Алексей Миловидов, организация - Яндекс.Облако. - -### 25.26. - Участие в GSoC. {#uchastie-v-gsoc} - -Андрей Бородин пытается уговорить нас участвовать, но пока загружены задачей 25.17. - -UPD: не участвуем. - -### 25.27. + Обновить сайт ClickHouse. {#obnovit-sait-clickhouse} - -Иван Блинков. Нет рисков. Нужно для Яндекс.Облака. Upd. Сделано. diff --git a/docs/ru/whats_new/index.md b/docs/ru/whats_new/index.md deleted file mode 100644 index b97b3623a9e..00000000000 --- a/docs/ru/whats_new/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -toc_folder_title: Что нового? -toc_priority: 72 ---- - - diff --git a/docs/ru/whats_new/roadmap.md b/docs/ru/whats_new/roadmap.md deleted file mode 120000 index 5ef0ebdb1bb..00000000000 --- a/docs/ru/whats_new/roadmap.md +++ /dev/null @@ -1 +0,0 @@ -../../en/whats_new/roadmap.md \ No newline at end of file diff --git a/docs/ru/whats_new/security_changelog.md b/docs/ru/whats_new/security_changelog.md deleted file mode 100644 index 9a2dab8ba14..00000000000 --- a/docs/ru/whats_new/security_changelog.md +++ /dev/null @@ -1,71 +0,0 @@ -# Security Changelog - -## Исправлено в релизе 19.14.3.3, 2019-09-10 {#ispravleno-v-relize-19-14-3-3-2019-09-10} - -### CVE-2019-15024 {#cve-2019-15024} - -Злоумышленник с доступом на запись к ZooKeeper и возможностью запустить собственный сервер в сети доступной ClickHouse может создать вредоносный сервер, который будет вести себя как реплика ClickHouse и зарегистрируется в ZooKeeper. В процессе репликации вредоносный сервер может указать любой путь на файловой системе в который будут записаны данные. - -Обнаружено благодаря: Эльдару Заитову из Службы Информационной Безопасности Яндекса - -### CVE-2019-16535 {#cve-2019-16535} - -Интерфейс декомпрессии позволял совершать OOB чтения и записи данных в памяти, а также переполнение целочисленных переменных, что могло приводить к отказу в обслуживании. Также потенциально могло использоваьтся для удаленного выполнения кода. - -Обнаружено благодаря: Эльдару Заитову из Службы Информационной Безопасности Яндекса - -### CVE-2019-16536 {#cve-2019-16536} - -Аутентифицированный клиент злоумышленника имел возможность вызвать переполнение стека, что могло привести к отказу в обслуживании. - -Обнаружено благодаря: Эльдару Заитову из Службы Информационной Безопасности Яндекса - -## Исправлено в релизе 19.13.6.1 от 20 сентября 2019 {#ispravleno-v-relize-19-13-6-1-ot-20-sentiabria-2019} - -### CVE-2019-18657 {#cve-2019-18657} - -Уязвимость в табличной функции `url` позволяла злоумышленнику добавлять произвольные HTTP-заголовки в запрос. - -Обнаружено благодаря: [Никите Тихомирову](https://github.com/NSTikhomirov) - -## Исправлено в релизе 18.12.13 от 10 сентября 2018 {#ispravleno-v-relize-18-12-13-ot-10-sentiabria-2018} - -### CVE-2018-14672 {#cve-2018-14672} - -Функция для загрузки CatBoost моделей некорректно обрабатывала пути к файлам, что позволяло читать произвольные локальные файлы на сервере Clickhouse через сообщения об ошибках. - -Обнаружено благодаря: Андрею Красичкову из Службы Информационной Безопасности Яндекса - -## Исправлено в релизе 18.10.3 от 13 августа 2018 {#ispravleno-v-relize-18-10-3-ot-13-avgusta-2018} - -### CVE-2018-14671 {#cve-2018-14671} - -unixODBC позволял указать путь для подключения произвольного shared object в качестве драйвера базы данных, что приводило к возможности выполнить произвольный код на сервере ClickHouse. - -Обнаружено благодаря: Андрею Красичкову и Евгению Сидорову из Службы Информационной Безопасности Яндекса - -## Исправлено в релизе 1.1.54388 от 28 июня 2018 {#ispravleno-v-relize-1-1-54388-ot-28-iiunia-2018} - -### CVE-2018-14668 {#cve-2018-14668} - -Табличная функция «remote» допускала произвольные символы в полях «user», «password» и «default\_database», что позволяло производить атаки класса Cross Protocol Request Forgery. - -Обнаружено благодаря: Андрею Красичкову из Службы Информационной Безопасности Яндекса - -## Исправлено в релизе 1.1.54390 от 6 июля 2018 {#ispravleno-v-relize-1-1-54390-ot-6-iiulia-2018} - -### CVE-2018-14669 {#cve-2018-14669} - -В ClickHouse MySQL клиенте была включена функциональность «LOAD DATA LOCAL INFILE», что позволяло получать доступ на чтение к произвольным файлам на сервере, где запущен ClickHouse. - -Обнаружено благодаря: Андрею Красичкову и Евгению Сидорову из Службы Информационной Безопасности Яндекса - -## Исправлено в релизе 1.1.54131 от 10 января 2017 {#ispravleno-v-relize-1-1-54131-ot-10-ianvaria-2017} - -### CVE-2018-14670 {#cve-2018-14670} - -Некорректная конфигурация в deb пакете могла привести к неавторизованному доступу к базе данных. - -Обнаружено благодаря: the UK’s National Cyber Security Centre (NCSC) - -{## [Оригинальная статья](https://clickhouse.tech/docs/ru/security_changelog/) ##} diff --git a/docs/tools/amp.py b/docs/tools/amp.py new file mode 100644 index 00000000000..ec2484405cd --- /dev/null +++ b/docs/tools/amp.py @@ -0,0 +1,101 @@ +import logging +import os +import subprocess + +import bs4 +import cssmin +import jinja2 +import mkdocs.commands.build + +import mdx_clickhouse +import test +import util +import website + + +def prepare_amp_html(lang, args, root, site_temp, main_site_dir): + src_path = root + src_index = os.path.join(src_path, 'index.html') + rel_path = os.path.relpath(src_path, site_temp) + dst_path = os.path.join(main_site_dir, rel_path, 'amp') + dst_index = os.path.join(dst_path, 'index.html') + + logging.debug(f'Generating AMP version for {rel_path} ({lang})') + os.makedirs(dst_path) + with open(src_index, 'r') as f: + content = f.read() + css_in = ' '.join(website.get_css_in(args)) + command = f"purifycss --min {css_in} '{src_index}'" + logging.debug(command) + inline_css = subprocess.check_output(command, shell=True).decode('utf-8') + inline_css = inline_css.replace('!important', '').replace('/*!', '/*') + inline_css = cssmin.cssmin(inline_css) + content = content.replace('CUSTOM_CSS_PLACEHOLDER', inline_css) + + with open(dst_index, 'w') as f: + f.write(content) + + return dst_index + + +def build_amp(lang, args, cfg): + # AMP docs: https://amp.dev/documentation/ + logging.info(f'Building AMP version for {lang}') + with util.temp_dir() as site_temp: + extra = cfg.data['extra'] + main_site_dir = cfg.data['site_dir'] + extra['is_amp'] = True + cfg.load_dict({ + 'site_dir': site_temp, + 'extra': extra + }) + + try: + mkdocs.commands.build.build(cfg) + except jinja2.exceptions.TemplateError: + if not args.version_prefix: + raise + mdx_clickhouse.PatchedMacrosPlugin.disabled = True + mkdocs.commands.build.build(cfg) + + paths = [] + for root, _, filenames in os.walk(site_temp): + if 'index.html' in filenames: + paths.append(prepare_amp_html(lang, args, root, site_temp, main_site_dir)) + test.test_amp(paths, lang) + logging.info(f'Finished building AMP version for {lang}') + + +def html_to_amp(content): + soup = bs4.BeautifulSoup( + content, + features='html.parser' + ) + + for tag in soup.find_all(): + if tag.attrs.get('id') == 'tostring': + tag.attrs['id'] = '_tostring' + if tag.name == 'img': + tag.name = 'amp-img' + tag.attrs['layout'] = 'responsive' + src = tag.attrs['src'] + if not (src.startswith('/') or src.startswith('http')): + tag.attrs['src'] = f'../{src}' + if not tag.attrs.get('width'): + tag.attrs['width'] = '640' + if not tag.attrs.get('height'): + tag.attrs['height'] = '320' + elif tag.name == 'a': + href = tag.attrs.get('href') + if href: + if not (href.startswith('/') or href.startswith('http')): + if '#' in href: + href, anchor = href.split('#') + else: + anchor = None + href = f'../{href}amp/' + if anchor: + href = f'{href}#{anchor}' + tag.attrs['href'] = href + content = str(soup) + return website.minify_html(content) diff --git a/docs/tools/build.py b/docs/tools/build.py index 2f7279ea07b..95e887f046f 100755 --- a/docs/tools/build.py +++ b/docs/tools/build.py @@ -9,19 +9,21 @@ import subprocess import sys import time -import bs4 import jinja2 import livereload import markdown.util +import nav # monkey patches mkdocs + from mkdocs import config from mkdocs import exceptions -from mkdocs.commands import build as mkdocs_build - -from concatenate import concatenate +import mkdocs.commands.build +import amp import mdx_clickhouse -import nav + +import redirects +import single_page import test import util import website @@ -56,17 +58,6 @@ def build_for_lang(lang, args): 'custom_dir': os.path.join(os.path.dirname(__file__), '..', args.theme_dir), 'language': lang, 'direction': 'rtl' if lang == 'fa' else 'ltr', - # TODO: cleanup - 'feature': { - 'tabs': False - }, - 'palette': { - 'primary': 'white', - 'accent': 'white' - }, - 'font': False, - 'logo': 'images/logo.svg', - 'favicon': 'assets/images/favicon.ico', 'static_templates': ['404.html'], 'extra': { 'now': int(time.mktime(datetime.datetime.now().timetuple())) # TODO better way to avoid caching @@ -127,11 +118,12 @@ def build_for_lang(lang, args): if args.htmlproofer: plugins.append('htmlproofer') + website_url = 'https://clickhouse.tech' site_name = site_names.get(lang, site_names['en']) % args.version_prefix site_name = site_name.replace(' ', ' ') raw_config = dict( site_name=site_name, - site_url=f'https://clickhouse.tech/docs/{lang}/', + site_url=f'{website_url}/docs/{lang}/', docs_dir=os.path.join(args.docs_dir, lang), site_dir=site_dir, strict=not args.version_prefix, @@ -143,17 +135,20 @@ def build_for_lang(lang, args): edit_uri=f'edit/master/docs/{lang}', markdown_extensions=markdown_extensions, plugins=plugins, - extra={ - 'stable_releases': args.stable_releases, - 'version_prefix': args.version_prefix, - 'single_page': False, - 'rev': args.rev, - 'rev_short': args.rev_short, - 'rev_url': args.rev_url, - 'events': args.events, - 'languages': languages, - 'includes_dir': os.path.join(os.path.dirname(__file__), '..', '_includes') - } + extra=dict( + now=datetime.datetime.now().isoformat(), + stable_releases=args.stable_releases, + version_prefix=args.version_prefix, + single_page=False, + rev=args.rev, + rev_short=args.rev_short, + rev_url=args.rev_url, + website_url=website_url, + events=args.events, + languages=languages, + includes_dir=os.path.join(os.path.dirname(__file__), '..', '_includes'), + is_amp=False + ) ) if os.path.exists(config_path): @@ -163,16 +158,20 @@ def build_for_lang(lang, args): cfg = config.load_config(**raw_config) - try: - mkdocs_build.build(cfg) - except jinja2.exceptions.TemplateError: - if not args.version_prefix: - raise - mdx_clickhouse.PatchedMacrosPlugin.disabled = True - mkdocs_build.build(cfg) + if not args.skip_multi_page: + try: + mkdocs.commands.build.build(cfg) + except jinja2.exceptions.TemplateError: + if not args.version_prefix: + raise + mdx_clickhouse.PatchedMacrosPlugin.disabled = True + mkdocs.commands.build.build(cfg) + + if not (args.skip_amp or args.version_prefix): + amp.build_amp(lang, args, cfg) if not args.skip_single_page: - build_single_page_version(lang, args, raw_config.get('nav'), cfg) + single_page.build_single_page_version(lang, args, raw_config.get('nav'), cfg) mdx_clickhouse.PatchedMacrosPlugin.disabled = False @@ -182,171 +181,13 @@ def build_for_lang(lang, args): raise SystemExit('\n' + str(e)) -def build_single_page_version(lang, args, nav, cfg): - logging.info(f'Building single page version for {lang}') - os.environ['SINGLE_PAGE'] = '1' - extra = cfg.data['extra'] - extra['single_page'] = True - - with util.autoremoved_file(os.path.join(args.docs_dir, lang, 'single.md')) as single_md: - concatenate(lang, args.docs_dir, single_md, nav) - - with util.temp_dir() as site_temp: - with util.temp_dir() as docs_temp: - docs_src_lang = os.path.join(args.docs_dir, lang) - docs_temp_lang = os.path.join(docs_temp, lang) - shutil.copytree(docs_src_lang, docs_temp_lang) - for root, _, filenames in os.walk(docs_temp_lang): - for filename in filenames: - if filename != 'single.md' and filename.endswith('.md'): - os.unlink(os.path.join(root, filename)) - - cfg.load_dict({ - 'docs_dir': docs_temp_lang, - 'site_dir': site_temp, - 'extra': extra, - 'nav': [ - {cfg.data.get('site_name'): 'single.md'} - ] - }) - - mkdocs_build.build(cfg) - - if args.version_prefix: - single_page_output_path = os.path.join(args.docs_dir, args.docs_output_dir, args.version_prefix, lang, 'single') - else: - single_page_output_path = os.path.join(args.docs_dir, args.docs_output_dir, lang, 'single') - - if os.path.exists(single_page_output_path): - shutil.rmtree(single_page_output_path) - - shutil.copytree( - os.path.join(site_temp, 'single'), - single_page_output_path - ) - - single_page_index_html = os.path.join(single_page_output_path, 'index.html') - single_page_content_js = os.path.join(single_page_output_path, 'content.js') - with open(single_page_index_html, 'r') as f: - sp_prefix, sp_js, sp_suffix = f.read().split('') - with open(single_page_index_html, 'w') as f: - f.write(sp_prefix) - f.write(sp_suffix) - with open(single_page_content_js, 'w') as f: - if args.minify: - import jsmin - sp_js = jsmin.jsmin(sp_js) - f.write(sp_js) - - logging.info(f'Re-building single page for {lang} pdf/test') - with util.temp_dir() as test_dir: - extra['single_page'] = False - cfg.load_dict({ - 'docs_dir': docs_temp_lang, - 'site_dir': test_dir, - 'extra': extra, - 'nav': [ - {cfg.data.get('site_name'): 'single.md'} - ] - }) - mkdocs_build.build(cfg) - - css_in = ' '.join(website.get_css_in(args)) - js_in = ' '.join(website.get_js_in(args)) - subprocess.check_call(f'cat {css_in} > {test_dir}/css/base.css', shell=True) - subprocess.check_call(f'cat {js_in} > {test_dir}/js/base.js', shell=True) - if args.save_raw_single_page: - shutil.copytree(test_dir, args.save_raw_single_page) - - if not args.version_prefix: # maybe enable in future - logging.info(f'Running tests for {lang}') - test.test_single_page( - os.path.join(test_dir, 'single', 'index.html'), lang) - - if not args.skip_pdf: - single_page_index_html = os.path.join(test_dir, 'single', 'index.html') - single_page_pdf = os.path.abspath( - os.path.join(single_page_output_path, f'clickhouse_{lang}.pdf') - ) - - with open(single_page_index_html, 'r') as f: - soup = bs4.BeautifulSoup( - f.read(), - features='html.parser' - ) - soup_prefix = f'file://{test_dir}' - for img in soup.findAll('img'): - if img['src'].startswith('/'): - img['src'] = soup_prefix + img['src'] - for script in soup.findAll('script'): - script['src'] = soup_prefix + script['src'].split('?', 1)[0] - for link in soup.findAll('link'): - link['href'] = soup_prefix + link['href'].split('?', 1)[0] - - with open(single_page_index_html, 'w') as f: - f.write(str(soup)) - - create_pdf_command = [ - 'wkhtmltopdf', - '--print-media-type', - '--log-level', 'warn', - single_page_index_html, single_page_pdf - ] - - logging.info(' '.join(create_pdf_command)) - subprocess.check_call(' '.join(create_pdf_command), shell=True) - - logging.info(f'Finished building single page version for {lang}') - - -def write_redirect_html(out_path, to_url): - out_dir = os.path.dirname(out_path) - try: - os.makedirs(out_dir) - except OSError: - pass - with open(out_path, 'w') as f: - f.write(f''' - - - - - - - Page Redirection - - - If you are not redirected automatically, follow this link. - -''') - - -def build_redirect_html(args, from_path, to_path): - for lang in args.lang.split(','): - out_path = os.path.join(args.docs_output_dir, lang, from_path.replace('.md', '/index.html')) - version_prefix = f'/{args.version_prefix}/' if args.version_prefix else '/' - target_path = to_path.replace('.md', '/') - to_url = f'/docs{version_prefix}{lang}/{target_path}' - to_url = to_url.strip() - write_redirect_html(out_path, to_url) - - -def build_redirects(args): - with open(os.path.join(args.docs_dir, 'redirects.txt'), 'r') as f: - for line in f: - from_path, to_path = line.split(' ', 1) - build_redirect_html(args, from_path, to_path) - - def build_docs(args): tasks = [] for lang in args.lang.split(','): if lang: tasks.append((lang, args,)) util.run_function_in_parallel(build_for_lang, tasks, threads=False) - build_redirects(args) + redirects.build_redirects(args) def build(args): @@ -356,6 +197,8 @@ def build(args): if not args.skip_website: website.build_website(args) + test.test_templates(args.website_dir) + build_docs(args) from github import build_releases @@ -364,19 +207,7 @@ def build(args): if not args.skip_website: website.process_benchmark_results(args) website.minify_website(args) - - for static_redirect in [ - ('benchmark.html', '/benchmark/dbms/'), - ('benchmark_hardware.html', '/benchmark/hardware/'), - ('tutorial.html', '/docs/en/getting_started/tutorial/',), - ('reference_en.html', '/docs/en/single/', ), - ('reference_ru.html', '/docs/ru/single/',), - ('docs/index.html', '/docs/en/',), - ]: - write_redirect_html( - os.path.join(args.output_dir, static_redirect[0]), - static_redirect[1] - ) + redirects.build_static_redirects(args) if __name__ == '__main__': @@ -391,11 +222,16 @@ if __name__ == '__main__': arg_parser.add_argument('--enable-stable-releases', action='store_true') arg_parser.add_argument('--stable-releases-limit', type=int, default='4') arg_parser.add_argument('--lts-releases-limit', type=int, default='2') + arg_parser.add_argument('--nav-limit', type=int, default='0') arg_parser.add_argument('--version-prefix', type=str, default='') arg_parser.add_argument('--is-stable-release', action='store_true') + arg_parser.add_argument('--skip-multi-page', action='store_true') arg_parser.add_argument('--skip-single-page', action='store_true') + arg_parser.add_argument('--skip-amp', action='store_true') arg_parser.add_argument('--skip-pdf', action='store_true') arg_parser.add_argument('--skip-website', action='store_true') + arg_parser.add_argument('--skip-git-log', action='store_true') + arg_parser.add_argument('--test-only', action='store_true') arg_parser.add_argument('--minify', action='store_true') arg_parser.add_argument('--htmlproofer', action='store_true') arg_parser.add_argument('--no-docs-macros', action='store_true') @@ -421,6 +257,15 @@ if __name__ == '__main__': args.rev_url = f'https://github.com/ClickHouse/ClickHouse/commit/{args.rev}' args.events = get_events(args) + if args.test_only: + args.skip_multi_page = True + args.skip_website = True + args.skip_pdf = True + args.skip_amp = True + + if args.skip_git_log or args.skip_amp: + mdx_clickhouse.PatchedMacrosPlugin.skip_git_log = True + from build import build build(args) diff --git a/docs/tools/concatenate.py b/docs/tools/concatenate.py deleted file mode 100755 index 6906f0c05c2..00000000000 --- a/docs/tools/concatenate.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- - -import logging -import re -import os - -import yaml - - -def recursive_values(item): - if isinstance(item, dict): - for _, value in item.items(): - yield from recursive_values(value) - elif isinstance(item, list): - for value in item: - yield from recursive_values(value) - elif isinstance(item, str): - yield item - - -def concatenate(lang, docs_path, single_page_file, nav): - lang_path = os.path.join(docs_path, lang) - az_re = re.compile(r'[a-z]') - - proj_config = f'{docs_path}/toc_{lang}.yml' - if os.path.exists(proj_config): - with open(proj_config) as cfg_file: - nav = yaml.full_load(cfg_file.read())['nav'] - files_to_concatenate = list(recursive_values(nav)) - files_count = len(files_to_concatenate) - logging.info(f'{files_count} files will be concatenated into single md-file for {lang}.') - logging.debug('Concatenating: ' + ', '.join(files_to_concatenate)) - assert files_count > 0, f'Empty single-page for {lang}' - - for path in files_to_concatenate: - if path.endswith('introduction/info.md'): - continue - try: - with open(os.path.join(lang_path, path)) as f: - anchors = set() - tmp_path = path.replace('/index.md', '/').replace('.md', '/') - prefixes = ['', '../', '../../', '../../../'] - parts = tmp_path.split('/') - anchors.add(parts[-2] + '/') - anchors.add('/'.join(parts[1:])) - - for part in parts[0:-2] if len(parts) > 2 else parts: - for prefix in prefixes: - anchor = prefix + tmp_path - if anchor: - anchors.add(anchor) - anchors.add('../' + anchor) - anchors.add('../../' + anchor) - tmp_path = tmp_path.replace(part, '..') - - for anchor in anchors: - if re.search(az_re, anchor): - single_page_file.write('' % anchor) - - single_page_file.write('\n') - - in_metadata = False - for l in f: - if l.startswith('---'): - in_metadata = not in_metadata - if l.startswith('#'): - l = '#' + l - if not in_metadata: - single_page_file.write(l) - except IOError as e: - logging.warning(str(e)) - - single_page_file.flush() diff --git a/docs/tools/github.py b/docs/tools/github.py index abe41cc79fe..8e6b5ac4ba1 100644 --- a/docs/tools/github.py +++ b/docs/tools/github.py @@ -13,7 +13,7 @@ import util def yield_candidates(): for page in range(1, 100): - url = 'https://api.github.com/repos/ClickHouse/ClickHouse/tags?per_page=100&page=%d' % page + url = f'https://api.github.com/repos/ClickHouse/ClickHouse/tags?per_page=100&page={page}' for candidate in requests.get(url).json(): yield candidate diff --git a/docs/tools/make_links.sh b/docs/tools/make_links.sh index 2a27990f445..743d4eebf16 100755 --- a/docs/tools/make_links.sh +++ b/docs/tools/make_links.sh @@ -2,23 +2,21 @@ # Fixes missing documentation in other languages # by putting relative symbolic links to the original doc file. -# This is to be run from root of language directory, like "docs/en". + +BASE_DIR=$(dirname $(readlink -f $0)) function do_make_links() { + set -x langs=(en es zh fr ru ja tr fa) src_file="$1" for lang in "${langs[@]}" do - # replacing "/./" with / - dst_file="../${lang}${src_file}" - dst_file="${dst_file/\/\.\//\/}" - dst_file="${dst_file/${lang}\./${lang}}" - + dst_file="${src_file/\/en\///${lang}/}" mkdir -p $(dirname "${dst_file}") ln -sr "${src_file}" "${dst_file}" 2>/dev/null done } export -f do_make_links -find . -iname '*.md' -exec /bin/bash -c 'do_make_links "{}"' \; +find "${BASE_DIR}/../en" -iname '*.md' -exec /bin/bash -c 'do_make_links "{}"' \; diff --git a/docs/tools/mdx_clickhouse.py b/docs/tools/mdx_clickhouse.py index ea75a495018..393658be2d7 100755 --- a/docs/tools/mdx_clickhouse.py +++ b/docs/tools/mdx_clickhouse.py @@ -2,7 +2,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import datetime import os +import subprocess import jinja2 import markdown.inlinepatterns @@ -12,6 +14,9 @@ import macros.plugin import slugify as slugify_impl +import amp +import website + class ClickHouseLinkMixin(object): @@ -81,6 +86,7 @@ def get_translations(dirname, lang): class PatchedMacrosPlugin(macros.plugin.MacrosPlugin): disabled = False + skip_git_log = False def on_config(self, config): super(PatchedMacrosPlugin, self).on_config(config) @@ -101,6 +107,8 @@ class PatchedMacrosPlugin(macros.plugin.MacrosPlugin): ) chunk_size = 10240 env.filters['chunks'] = lambda line: [line[i:i+chunk_size] for i in range(0, len(line), chunk_size)] + env.filters['html_to_amp'] = amp.html_to_amp + env.filters['adjust_markdown_html'] = website.adjust_markdown_html return env def render(self, markdown): @@ -109,6 +117,38 @@ class PatchedMacrosPlugin(macros.plugin.MacrosPlugin): else: return markdown + def on_page_markdown(self, markdown, page, config, files): + markdown = super(PatchedMacrosPlugin, self).on_page_markdown(markdown, page, config, files) + + if os.path.islink(page.file.abs_src_path): + lang = config.data['theme']['language'] + page.canonical_url = page.canonical_url.replace(f'/{lang}/', '/en/', 1) + + if config.data['extra'].get('version_prefix') or config.data['extra'].get('single_page'): + return markdown + if self.skip_git_log: + return markdown + src_path = page.file.abs_src_path + try: + git_log = subprocess.check_output(f'git log --follow --date=iso8601 "{src_path}"', shell=True) + except subprocess.CalledProcessError: + return markdown + max_date = None + min_date = None + for line in git_log.decode('utf-8').split('\n'): + if line.startswith('Date:'): + line = line.replace('Date:', '').strip().replace(' ', 'T', 1).replace(' ', '') + current_date = datetime.datetime.fromisoformat(line[:-2] + ':' + line[-2:]) + if (not max_date) or current_date > max_date: + max_date = current_date + if (not min_date) or current_date < min_date: + min_date = current_date + if min_date: + page.meta['published_date'] = min_date + if max_date: + page.meta['modified_date'] = max_date + return markdown + def render_impl(self, markdown): md_template = self.env.from_string(markdown) return md_template.render(**self.variables) diff --git a/docs/tools/nav.py b/docs/tools/nav.py index fe11b21d8e7..3c4fd304bd3 100644 --- a/docs/tools/nav.py +++ b/docs/tools/nav.py @@ -2,6 +2,8 @@ import collections import logging import os +import mkdocs.structure.nav + import util @@ -12,7 +14,7 @@ def find_first_header(content): return no_hash.split('{', 1)[0].strip() -def build_nav_entry(root): +def build_nav_entry(root, args): if root.endswith('images'): return None, None, None result_items = [] @@ -21,7 +23,7 @@ def build_nav_entry(root): for filename in os.listdir(root): path = os.path.join(root, filename) if os.path.isdir(path): - prio, title, payload = build_nav_entry(path) + prio, title, payload = build_nav_entry(path, args) if title and payload: result_items.append((prio, title, payload)) elif filename.endswith('.md'): @@ -37,6 +39,8 @@ def build_nav_entry(root): logging.debug(f'Nav entry: {prio}, {title}, {path}') if not content.strip(): title = 'hidden' + if args.nav_limit and len(result_items) >= args.nav_limit: + break result_items.append((prio, title, path)) result_items = sorted(result_items, key=lambda x: (x[0], x[1])) result = collections.OrderedDict([(item[1], item[2]) for item in result_items]) @@ -45,7 +49,7 @@ def build_nav_entry(root): def build_nav(lang, args): docs_dir = os.path.join(args.docs_dir, lang) - _, _, nav = build_nav_entry(docs_dir) + _, _, nav = build_nav_entry(docs_dir, args) result = [] index_key = None for key, value in nav.items(): @@ -54,9 +58,51 @@ def build_nav(lang, args): index_key = key continue result.append({key: value}) + if args.nav_limit and len(result) >= args.nav_limit: + break if index_key: key = list(result[0].keys())[0] result[0][key][index_key] = 'index.md' result[0][key].move_to_end(index_key, last=False) print('result', result) return result + + +def _custom_get_navigation(files, config): + nav_config = config['nav'] or mkdocs.structure.nav.nest_paths(f.src_path for f in files.documentation_pages()) + items = mkdocs.structure.nav._data_to_navigation(nav_config, files, config) + if not isinstance(items, list): + items = [items] + + pages = mkdocs.structure.nav._get_by_type(items, mkdocs.structure.nav.Page) + + mkdocs.structure.nav._add_previous_and_next_links(pages) + mkdocs.structure.nav._add_parent_links(items) + + missing_from_config = [file for file in files.documentation_pages() if file.page is None] + if missing_from_config: + files._files = [file for file in files._files if file not in missing_from_config] + + links = mkdocs.structure.nav._get_by_type(items, mkdocs.structure.nav.Link) + for link in links: + scheme, netloc, path, params, query, fragment = mkdocs.structure.nav.urlparse(link.url) + if scheme or netloc: + mkdocs.structure.nav.log.debug( + "An external link to '{}' is included in " + "the 'nav' configuration.".format(link.url) + ) + elif link.url.startswith('/'): + mkdocs.structure.nav.log.debug( + "An absolute path to '{}' is included in the 'nav' configuration, " + "which presumably points to an external resource.".format(link.url) + ) + else: + msg = ( + "A relative path to '{}' is included in the 'nav' configuration, " + "which is not found in the documentation files".format(link.url) + ) + mkdocs.structure.nav.log.warning(msg) + return mkdocs.structure.nav.Navigation(items, pages) + + +mkdocs.structure.nav.get_navigation = _custom_get_navigation diff --git a/docs/tools/redirects.py b/docs/tools/redirects.py new file mode 100644 index 00000000000..fc4d60aaf5a --- /dev/null +++ b/docs/tools/redirects.py @@ -0,0 +1,60 @@ +import os + + +def write_redirect_html(out_path, to_url): + out_dir = os.path.dirname(out_path) + try: + os.makedirs(out_dir) + except OSError: + pass + with open(out_path, 'w') as f: + f.write(f''' + + + + + + + Page Redirection + + + If you are not redirected automatically, follow this link. + +''') + + +def build_redirect_html(args, from_path, to_path): + for lang in args.lang.split(','): + out_path = os.path.join( + args.docs_output_dir, lang, + from_path.replace('/index.md', '/index.html').replace('.md', '/index.html') + ) + version_prefix = f'/{args.version_prefix}/' if args.version_prefix else '/' + target_path = to_path.replace('/index.md', '/').replace('.md', '/') + to_url = f'/docs{version_prefix}{lang}/{target_path}' + to_url = to_url.strip() + write_redirect_html(out_path, to_url) + + +def build_redirects(args): + with open(os.path.join(args.docs_dir, 'redirects.txt'), 'r') as f: + for line in f: + from_path, to_path = line.split(' ', 1) + build_redirect_html(args, from_path, to_path) + + +def build_static_redirects(args): + for static_redirect in [ + ('benchmark.html', '/benchmark/dbms/'), + ('benchmark_hardware.html', '/benchmark/hardware/'), + ('tutorial.html', '/docs/en/getting_started/tutorial/',), + ('reference_en.html', '/docs/en/single/', ), + ('reference_ru.html', '/docs/ru/single/',), + ('docs/index.html', '/docs/en/',), + ]: + write_redirect_html( + os.path.join(args.output_dir, static_redirect[0]), + static_redirect[1] + ) diff --git a/docs/tools/release.sh b/docs/tools/release.sh index 8c61d16966f..ff3d2971e6e 100755 --- a/docs/tools/release.sh +++ b/docs/tools/release.sh @@ -44,7 +44,7 @@ then if [[ ! -z "${CLOUDFLARE_TOKEN}" ]] then sleep 1m - git diff --stat="9999,9999" --diff-filter=M HEAD~1 | grep '|' | awk '$1 ~ /\.html$/ { if ($3>4) { url="https://clickhouse.tech/"$1; sub(/\/index.html/, "/", url); print "\""url"\""; }}' | split -l 25 /dev/stdin PURGE + git diff --stat="9999,9999" --diff-filter=M HEAD~1 | grep '|' | awk '$1 ~ /\.html$/ { if ($3>8) { url="https://content.clickhouse.tech/"$1; sub(/\/index.html/, "/", url); print "\""url"\""; }}' | split -l 25 /dev/stdin PURGE for FILENAME in $(ls PURGE*) do POST_DATA=$(cat "${FILENAME}" | sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}' | awk '{print "{\"files\":["$0"]}";}') diff --git a/docs/tools/requirements.txt b/docs/tools/requirements.txt index 06f07f62fd1..570dcf0aaf2 100644 --- a/docs/tools/requirements.txt +++ b/docs/tools/requirements.txt @@ -1,8 +1,8 @@ Babel==2.8.0 backports-abc==0.5 backports.functools-lru-cache==1.6.1 -beautifulsoup4==4.9.0 -certifi==2020.4.5.1 +beautifulsoup4==4.9.1 +certifi==2020.4.5.2 chardet==3.0.4 click==7.1.2 closure==20191111 @@ -13,16 +13,16 @@ idna==2.9 Jinja2==2.11.2 jinja2-highlight==0.6.1 jsmin==2.2.2 -livereload==2.6.1 +livereload==2.6.2 Markdown==3.2.1 MarkupSafe==1.1.1 -mkdocs==1.1 +mkdocs==1.1.2 mkdocs-htmlproofer-plugin==0.0.3 -mkdocs-macros-plugin==0.4.6 +mkdocs-macros-plugin==0.4.9 nltk==3.5 nose==1.3.7 -protobuf==3.11.3 -numpy==1.18.3 +protobuf==3.12.2 +numpy==1.18.5 Pygments==2.5.2 pymdown-extensions==7.1 python-slugify==1.2.6 @@ -30,8 +30,8 @@ PyYAML==5.3.1 repackage==0.7.3 requests==2.23.0 singledispatch==3.4.0.3 -six==1.14.0 -soupsieve==2.0 +six==1.15.0 +soupsieve==2.0.1 termcolor==1.1.0 tornado==5.1.1 Unidecode==1.1.1 diff --git a/docs/tools/single_page.py b/docs/tools/single_page.py new file mode 100644 index 00000000000..b074cd42329 --- /dev/null +++ b/docs/tools/single_page.py @@ -0,0 +1,200 @@ +import logging +import os +import re +import shutil +import subprocess +import yaml + +import bs4 +import mkdocs.commands.build + +import test +import util +import website + + +def recursive_values(item): + if isinstance(item, dict): + for _, value in item.items(): + yield from recursive_values(value) + elif isinstance(item, list): + for value in item: + yield from recursive_values(value) + elif isinstance(item, str): + yield item + + +def concatenate(lang, docs_path, single_page_file, nav): + lang_path = os.path.join(docs_path, lang) + az_re = re.compile(r'[a-z]') + + proj_config = f'{docs_path}/toc_{lang}.yml' + if os.path.exists(proj_config): + with open(proj_config) as cfg_file: + nav = yaml.full_load(cfg_file.read())['nav'] + files_to_concatenate = list(recursive_values(nav)) + files_count = len(files_to_concatenate) + logging.info(f'{files_count} files will be concatenated into single md-file for {lang}.') + logging.debug('Concatenating: ' + ', '.join(files_to_concatenate)) + assert files_count > 0, f'Empty single-page for {lang}' + + for path in files_to_concatenate: + if path.endswith('introduction/info.md'): + continue + try: + with open(os.path.join(lang_path, path)) as f: + anchors = set() + tmp_path = path.replace('/index.md', '/').replace('.md', '/') + prefixes = ['', '../', '../../', '../../../'] + parts = tmp_path.split('/') + anchors.add(parts[-2] + '/') + anchors.add('/'.join(parts[1:])) + + for part in parts[0:-2] if len(parts) > 2 else parts: + for prefix in prefixes: + anchor = prefix + tmp_path + if anchor: + anchors.add(anchor) + anchors.add('../' + anchor) + anchors.add('../../' + anchor) + tmp_path = tmp_path.replace(part, '..') + + for anchor in anchors: + if re.search(az_re, anchor): + single_page_file.write('' % anchor) + + single_page_file.write('\n') + + in_metadata = False + for l in f: + if l.startswith('---'): + in_metadata = not in_metadata + if l.startswith('#'): + l = '#' + l + if not in_metadata: + single_page_file.write(l) + except IOError as e: + logging.warning(str(e)) + + single_page_file.flush() + + +def build_single_page_version(lang, args, nav, cfg): + logging.info(f'Building single page version for {lang}') + os.environ['SINGLE_PAGE'] = '1' + extra = cfg.data['extra'] + extra['single_page'] = True + extra['is_amp'] = False + + with util.autoremoved_file(os.path.join(args.docs_dir, lang, 'single.md')) as single_md: + concatenate(lang, args.docs_dir, single_md, nav) + + with util.temp_dir() as site_temp: + with util.temp_dir() as docs_temp: + docs_src_lang = os.path.join(args.docs_dir, lang) + docs_temp_lang = os.path.join(docs_temp, lang) + shutil.copytree(docs_src_lang, docs_temp_lang) + for root, _, filenames in os.walk(docs_temp_lang): + for filename in filenames: + if filename != 'single.md' and filename.endswith('.md'): + os.unlink(os.path.join(root, filename)) + + cfg.load_dict({ + 'docs_dir': docs_temp_lang, + 'site_dir': site_temp, + 'extra': extra, + 'nav': [ + {cfg.data.get('site_name'): 'single.md'} + ] + }) + + if not args.test_only: + mkdocs.commands.build.build(cfg) + + if args.version_prefix: + single_page_output_path = os.path.join(args.docs_dir, args.docs_output_dir, args.version_prefix, lang, 'single') + else: + single_page_output_path = os.path.join(args.docs_dir, args.docs_output_dir, lang, 'single') + + if os.path.exists(single_page_output_path): + shutil.rmtree(single_page_output_path) + + shutil.copytree( + os.path.join(site_temp, 'single'), + single_page_output_path + ) + + single_page_index_html = os.path.join(single_page_output_path, 'index.html') + single_page_content_js = os.path.join(single_page_output_path, 'content.js') + with open(single_page_index_html, 'r') as f: + sp_prefix, sp_js, sp_suffix = f.read().split('') + with open(single_page_index_html, 'w') as f: + f.write(sp_prefix) + f.write(sp_suffix) + with open(single_page_content_js, 'w') as f: + if args.minify: + import jsmin + sp_js = jsmin.jsmin(sp_js) + f.write(sp_js) + + logging.info(f'Re-building single page for {lang} pdf/test') + with util.temp_dir() as test_dir: + extra['single_page'] = False + cfg.load_dict({ + 'docs_dir': docs_temp_lang, + 'site_dir': test_dir, + 'extra': extra, + 'nav': [ + {cfg.data.get('site_name'): 'single.md'} + ] + }) + mkdocs.commands.build.build(cfg) + + css_in = ' '.join(website.get_css_in(args)) + js_in = ' '.join(website.get_js_in(args)) + subprocess.check_call(f'cat {css_in} > {test_dir}/css/base.css', shell=True) + subprocess.check_call(f'cat {js_in} > {test_dir}/js/base.js', shell=True) + if args.save_raw_single_page: + shutil.copytree(test_dir, args.save_raw_single_page) + + if not args.version_prefix: # maybe enable in future + logging.info(f'Running tests for {lang}') + test.test_single_page( + os.path.join(test_dir, 'single', 'index.html'), lang) + + if not args.skip_pdf: + single_page_index_html = os.path.join(test_dir, 'single', 'index.html') + single_page_pdf = os.path.abspath( + os.path.join(single_page_output_path, f'clickhouse_{lang}.pdf') + ) + + with open(single_page_index_html, 'r') as f: + soup = bs4.BeautifulSoup( + f.read(), + features='html.parser' + ) + soup_prefix = f'file://{test_dir}' + for img in soup.findAll('img'): + if img['src'].startswith('/'): + img['src'] = soup_prefix + img['src'] + for script in soup.findAll('script'): + script_src = script.get('src') + if script_src: + script['src'] = soup_prefix + script_src.split('?', 1)[0] + for link in soup.findAll('link'): + link['href'] = soup_prefix + link['href'].split('?', 1)[0] + + with open(single_page_index_html, 'w') as f: + f.write(str(soup)) + + create_pdf_command = [ + 'wkhtmltopdf', + '--print-media-type', + '--log-level', 'warn', + single_page_index_html, single_page_pdf + ] + + logging.info(' '.join(create_pdf_command)) + subprocess.check_call(' '.join(create_pdf_command), shell=True) + + logging.info(f'Finished building single page version for {lang}') diff --git a/docs/tools/test.py b/docs/tools/test.py index 69cf26a3219..5c0cf4b799d 100755 --- a/docs/tools/test.py +++ b/docs/tools/test.py @@ -2,10 +2,66 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals import logging +import os import sys import bs4 +import logging +import os +import subprocess + +import bs4 + + +def test_amp(paths, lang): + try: + # Get latest amp validator version + subprocess.check_call('amphtml-validator --help', + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + shell=True) + except subprocess.CalledProcessError: + subprocess.check_call('npm i -g amphtml-validator', stderr=subprocess.DEVNULL, shell=True) + + paths = ' '.join(paths) + command = f'amphtml-validator {paths}' + try: + subprocess.check_output(command, shell=True).decode('utf-8') + except subprocess.CalledProcessError: + logging.error(f'Invalid AMP for {lang}') + raise + + +def test_template(template_path): + if template_path.endswith('amp.html'): + # Inline CSS/JS is ok for AMP pages + return + + logging.debug(f'Running tests for {template_path} template') + with open(template_path, 'r') as f: + soup = bs4.BeautifulSoup( + f, + features='html.parser' + ) + for tag in soup.find_all(): + style_attr = tag.attrs.get('style') + assert not style_attr, f'Inline CSS is prohibited, found {style_attr} in {template_path}' + + if tag.name == 'script': + if tag.attrs.get('type') == 'application/ld+json': + continue + for content in tag.contents: + assert not content, f'Inline JavaScript is prohibited, found "{content}" in {template_path}' + + +def test_templates(base_dir): + logging.info('Running tests for templates') + for root, _, filenames in os.walk(base_dir): + for filename in filenames: + if filename.endswith('.html'): + test_template(os.path.join(root, filename)) + def test_single_page(input_path, lang): with open(input_path) as f: @@ -35,9 +91,12 @@ def test_single_page(input_path, lang): if duplicate_anchor_points: logging.warning('Found %d duplicate anchor points' % duplicate_anchor_points) - if lang == 'en' and links_to_nowhere: - logging.warning(f'Found {links_to_nowhere} links to nowhere') - # TODO: restore sys.exit(1) + if links_to_nowhere: + if lang == 'en': # TODO: check all languages again + logging.error(f'Found {links_to_nowhere} links to nowhere in {lang}') + sys.exit(1) + else: + logging.warning(f'Found {links_to_nowhere} links to nowhere in {lang}') if len(anchor_points) <= 10: logging.error('Html parsing is probably broken') diff --git a/docs/tools/translate/filter.py b/docs/tools/translate/filter.py index b5424f20921..fe421381700 100755 --- a/docs/tools/translate/filter.py +++ b/docs/tools/translate/filter.py @@ -160,16 +160,9 @@ def translate_filter(key, value, _format, _): attempts = 10 if '#' in href: href, anchor = href.split('#', 1) - - if filename: - while attempts and not os.path.exists(href): - href = f'../{href}' - attempts -= 1 if anchor: href = f'{href}#{anchor}' - - if attempts: - value[2][0] = href + value[2][0] = href return cls(*value) elif key == 'Header': if value[1][0].islower() and '_' not in value[1][0]: # Preserve some manually specified anchors diff --git a/docs/tools/translate/requirements.txt b/docs/tools/translate/requirements.txt index 3c212ee8bc2..0c9d44a346e 100644 --- a/docs/tools/translate/requirements.txt +++ b/docs/tools/translate/requirements.txt @@ -1,5 +1,5 @@ Babel==2.8.0 -certifi==2020.4.5.1 +certifi==2020.4.5.2 chardet==3.0.4 googletrans==2.4.0 idna==2.9 diff --git a/docs/tools/translate/translate.py b/docs/tools/translate/translate.py index 759e5b849d2..6486a8cbcc7 100755 --- a/docs/tools/translate/translate.py +++ b/docs/tools/translate/translate.py @@ -2,6 +2,7 @@ import os import random +import re import sys import time import urllib.parse @@ -15,11 +16,12 @@ import typograph_ru translator = googletrans.Translator() default_target_language = os.environ.get('TARGET_LANGUAGE', 'ru') +curly_braces_re = re.compile('({[^}]+})') is_yandex = os.environ.get('YANDEX') is not None -def translate(text, target_language=None): +def translate_impl(text, target_language=None): target_language = target_language or default_target_language if target_language == 'en': return text @@ -46,6 +48,16 @@ def translate(text, target_language=None): return translator.translate(text, target_language).text +def translate(text, target_language=None): + result = [] + for part in re.split(curly_braces_re, text): + if part.startswith('{') and part.endswith('}'): + result.append(part) + else: + result.append(translate_impl(part, target_language=target_language)) + return ''.join(result) + + def translate_toc(root, lang): global is_yandex is_yandex = True diff --git a/docs/tools/translate/update-all-machine-translated.sh b/docs/tools/translate/update-all-machine-translated.sh new file mode 100755 index 00000000000..fae2aae787f --- /dev/null +++ b/docs/tools/translate/update-all-machine-translated.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +BASE_DIR=$(dirname $(readlink -f $0)) + +function translate() { + set -x + LANGUAGE=$1 + DOCS_ROOT="${BASE_DIR}/../../" + REV="$(git rev-parse HEAD)" + for FILENAME in $(find "${DOCS_ROOT}${LANGUAGE}" -name "*.md" -type f) + do + HAS_MT_TAG=$(grep -c "machine_translated: true" "${FILENAME}") + IS_UP_TO_DATE=$(grep -c "machine_translated_rev: \"${REV}\"" "${FILENAME}") + if [ "${HAS_MT_TAG}" -eq "1" ] && [ "${IS_UP_TO_DATE}" -eq "0" ] + then + set -e + EN_FILENAME=${FILENAME/\/${LANGUAGE}\///en/} + rm "${FILENAME}" || true + cp "${EN_FILENAME}" "${FILENAME}" + DEBUG=1 SLEEP=1 ${BASE_DIR}/replace-with-translation.sh ${LANGUAGE} "${FILENAME}" + set +e + fi + done +} +export BASE_DIR +export -f translate +parallel translate ::: es fr zh ja fa tr diff --git a/docs/tools/website.py b/docs/tools/website.py index 6227790d49e..ed950bd06e3 100644 --- a/docs/tools/website.py +++ b/docs/tools/website.py @@ -1,10 +1,13 @@ +import concurrent.futures import hashlib import json import logging import os import shutil import subprocess +import sys +import bs4 import closure import cssmin import htmlmin @@ -14,6 +17,63 @@ import jsmin import mdx_clickhouse +def adjust_markdown_html(content): + soup = bs4.BeautifulSoup( + content, + features='html.parser' + ) + for a in soup.find_all('a'): + a_class = a.attrs.get('class') + if a_class and 'headerlink' in a_class: + a.string = '\xa0' + for details in soup.find_all('details'): + for summary in details.find_all('summary'): + if summary.parent != details: + summary.extract() + details.insert(0, summary) + for div in soup.find_all('div'): + div_class = div.attrs.get('class') + is_admonition = div_class and 'admonition' in div.attrs.get('class') + if is_admonition: + for a in div.find_all('a'): + a_class = a.attrs.get('class') + if a_class: + a.attrs['class'] = a_class + ['alert-link'] + else: + a.attrs['class'] = 'alert-link' + for p in div.find_all('p'): + p_class = p.attrs.get('class') + if is_admonition and p_class and ('admonition-title' in p_class): + p.attrs['class'] = p_class + ['alert-heading', 'display-6', 'mb-2'] + if is_admonition: + div.attrs['role'] = 'alert' + if ('info' in div_class) or ('note' in div_class): + mode = 'alert-primary' + elif ('attention' in div_class) or ('warning' in div_class): + mode = 'alert-warning' + elif 'important' in div_class: + mode = 'alert-danger' + elif 'tip' in div_class: + mode = 'alert-info' + else: + mode = 'alert-secondary' + div.attrs['class'] = div_class + ['alert', 'pb-0', 'mb-4', mode] + + return str(soup) + + +def minify_html(content): + return htmlmin.minify(content, + remove_comments=False, + remove_empty_space=True, + remove_all_empty_space=False, + reduce_empty_attributes=True, + reduce_boolean_attributes=False, + remove_optional_attribute_quotes=True, + convert_charrefs=False, + keep_pre=True) + + def build_website(args): logging.info('Building website') env = jinja2.Environment( @@ -40,6 +100,7 @@ def build_website(args): '*.md', '*.sh', '*.css', + '*.json', 'js/*.js', 'build', 'docs', @@ -82,9 +143,10 @@ def get_css_in(args): def get_js_in(args): return [ - f"'{args.website_dir}/js/jquery-3.4.1.js'", + f"'{args.website_dir}/js/jquery.js'", f"'{args.website_dir}/js/popper.js'", f"'{args.website_dir}/js/bootstrap.js'", + f"'{args.website_dir}/js/sentry.js'", f"'{args.website_dir}/js/base.js'", f"'{args.website_dir}/js/index.js'", f"'{args.website_dir}/js/docsearch.js'", @@ -92,6 +154,28 @@ def get_js_in(args): ] +def minify_file(path, css_digest, js_digest): + if not ( + path.endswith('.html') or + path.endswith('.css') + ): + return + + logging.info('Minifying %s', path) + with open(path, 'rb') as f: + content = f.read().decode('utf-8') + if path.endswith('.html'): + content = minify_html(content) + content = content.replace('base.css?css_digest', f'base.css?{css_digest}') + content = content.replace('base.js?js_digest', f'base.js?{js_digest}') + elif path.endswith('.css'): + content = cssmin.cssmin(content) + elif path.endswith('.js'): + content = jsmin.jsmin(content) + with open(path, 'wb') as f: + f.write(content.encode('utf-8')) + + def minify_website(args): css_in = ' '.join(get_css_in(args)) css_out = f'{args.output_dir}/css/base.css' @@ -120,6 +204,10 @@ def minify_website(args): logging.info(closure_args) if closure.run(*closure_args): raise RuntimeError('failed to run closure compiler') + with open(js_out, 'r') as f: + js_content = jsmin.jsmin(f.read()) + with open(js_out, 'w') as f: + f.write(js_content) else: js_in = ' '.join(js_in) @@ -133,28 +221,17 @@ def minify_website(args): if args.minify: logging.info('Minifying website') - for root, _, filenames in os.walk(args.output_dir): - for filename in filenames: - path = os.path.join(root, filename) - if not ( - filename.endswith('.html') or - filename.endswith('.css') - ): - continue - - logging.info('Minifying %s', path) - with open(path, 'rb') as f: - content = f.read().decode('utf-8') - if filename.endswith('.html'): - content = htmlmin.minify(content, remove_empty_space=False) - content = content.replace('base.css?css_digest', f'base.css?{css_digest}') - content = content.replace('base.js?js_digest', f'base.js?{js_digest}') - elif filename.endswith('.css'): - content = cssmin.cssmin(content) - elif filename.endswith('.js'): - content = jsmin.jsmin(content) - with open(path, 'wb') as f: - f.write(content.encode('utf-8')) + with concurrent.futures.ThreadPoolExecutor() as executor: + futures = [] + for root, _, filenames in os.walk(args.output_dir): + for filename in filenames: + path = os.path.join(root, filename) + futures.append(executor.submit(minify_file, path, css_digest, js_digest)) + for future in futures: + exc = future.exception() + if exc: + logging.error(exc) + sys.exit(1) def process_benchmark_results(args): diff --git a/docs/tr/commercial/cloud.md b/docs/tr/commercial/cloud.md index f20656cc428..42ad0db7c26 100644 --- a/docs/tr/commercial/cloud.md +++ b/docs/tr/commercial/cloud.md @@ -1,6 +1,8 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 1 +toc_title: Bulut --- # ClickHouse Bulut Servis Sağlayıcıları {#clickhouse-cloud-service-providers} @@ -12,7 +14,7 @@ machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 [Yandex Clickhouse için yönetilen hizmet](https://cloud.yandex.com/services/managed-clickhouse?utm_source=referrals&utm_medium=clickhouseofficialsite&utm_campaign=link3) aşağıdaki temel özellikleri sağlar: -- İçin tamamen yönetilen ZooKeeper hizmeti [ClickHouse çoğaltma](../engines/table_engines/mergetree_family/replication.md) +- İçin tamamen yönetilen ZooKeeper hizmeti [ClickHouse çoğaltma](../engines/table-engines/mergetree-family/replication.md) - Çoklu depolama tipi seçenekleri - Farklı kullanılabilirlik bölgelerinde yinelemeler - Şifreleme ve izolasyon diff --git a/docs/tr/commercial/index.md b/docs/tr/commercial/index.md index 104a3427146..4f01c90970c 100644 --- a/docs/tr/commercial/index.md +++ b/docs/tr/commercial/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Ticari toc_priority: 70 toc_title: Ticari diff --git a/docs/tr/development/architecture.md b/docs/tr/development/architecture.md index 4713c2e5409..37b5060e91e 100644 --- a/docs/tr/development/architecture.md +++ b/docs/tr/development/architecture.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 62 toc_title: "ClickHouse mimarisine genel bak\u0131\u015F" --- @@ -41,7 +41,7 @@ Sütunlar üzerinde çeşitli işlevler kullanarak genel, verimli olmayan bir ş `IDataType` çeşitli veri formatları için yardımcı yöntemlere sahiptir. Örnekler, Olası Alıntı ile bir değeri serileştirmek, json için bir değeri serileştirmek ve XML formatının bir parçası olarak bir değeri serileştirmek için kullanılan yöntemlerdir. Veri formatlarına doğrudan yazışma yoktur. Örneğin, farklı veri biçimleri `Pretty` ve `TabSeparated` aynı kullanabilirsiniz `serializeTextEscaped` hel methodper yöntemi `IDataType` Arabirim. -## Blok {#block} +## Engel {#block} A `Block` bellekteki bir tablonun bir alt kümesini (yığın) temsil eden bir kapsayıcıdır. Bu sadece üçlü bir dizi: `(IColumn, IDataType, column name)`. Sorgu yürütme sırasında veri tarafından işlenir `Block`s. Eğer bir `Block`(bu yaptığımız verileri `IColumn` nesne), biz onun türü hakkında bilgi var (içinde `IDataType`) bu bize bu sütunla nasıl başa çıkacağımızı söyler ve sütun adına sahibiz. Tablodan orijinal sütun adı veya hesaplamaların geçici sonuçlarını almak için atanan bazı yapay ad olabilir. @@ -122,9 +122,9 @@ Sıradan fonksiyonlar ve toplam fonksiyonlar vardır. Toplama işlevleri için b Ordinary functions don't change the number of rows – they work as if they are processing each row independently. In fact, functions are not called for individual rows, but for `Block`'s vectorized sorgu yürütme uygulamak için veri. -Gibi bazı çeşitli fonksiyonlar vardır [blockSize](../sql_reference/functions/other_functions.md#function-blocksize), [rowNumberİnBlock](../sql_reference/functions/other_functions.md#function-rownumberinblock), ve [runningAccumulate](../sql_reference/functions/other_functions.md#function-runningaccumulate), blok işlemeyi istismar eden ve satırların bağımsızlığını ihlal eden. +Gibi bazı çeşitli fonksiyonlar vardır [blockSize](../sql-reference/functions/other-functions.md#function-blocksize), [rowNumberİnBlock](../sql-reference/functions/other-functions.md#function-rownumberinblock), ve [runningAccumulate](../sql-reference/functions/other-functions.md#function-runningaccumulate), blok işlemeyi istismar eden ve satırların bağımsızlığını ihlal eden. -Clickhouse'un güçlü yazımı var, bu yüzden örtük tür dönüşümü yok. Bir işlev belirli bir tür kombinasyonunu desteklemiyorsa, bir istisna atar. Ancak, birçok farklı tür kombinasyonu için işlevler çalışabilir (aşırı yüklenebilir). Örneğin, `plus` fonksiyonu (uygulamak için `+` operatör) sayısal türlerin herhangi bir kombinasyonu için çalışır: `UInt8` + `Float32`, `UInt16` + `Int8` ve bu yüzden. Ayrıca, bazı variadic işlevleri gibi bağımsız değişkenlerin herhangi bir sayıda kabul edebilir `concat` işlev. +Clickhouse'un güçlü yazımı var, bu yüzden örtük tür dönüşümü yok. Bir işlev belirli bir tür kombinasyonunu desteklemiyorsa, bir istisna atar. Ancak, birçok farklı tür kombinasyonu için işlevler çalışabilir (aşırı yüklenebilir). Örneğin, `plus` fonksiyonu (uygulamak için `+` operatör) sayısal türlerin herhangi bir kombinasyonu için çalışır: `UInt8` + `Float32`, `UInt16` + `Int8` ve bu yüzden. Ayrıca, bazı variadic işlevleri gibi bağımsız değişkenlerin herhangi bir sayıda kabul edebilir `concat` İşlev. Bir işlev açıkça desteklenen veri türlerini gönderir ve desteklenen çünkü bir işlev uygulamak biraz rahatsız edici olabilir `IColumns`. Örneğin, `plus` işlev, sayısal türlerin ve sabit veya sabit olmayan sol ve sağ bağımsız değişkenlerin her birleşimi için bir C++ şablonunun örneklendirilmesiyle oluşturulan koda sahiptir. diff --git a/docs/tr/development/browse-code.md b/docs/tr/development/browse-code.md new file mode 100644 index 00000000000..a4b6a90020e --- /dev/null +++ b/docs/tr/development/browse-code.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "Kaynak Koduna G\xF6zat" +--- + +# ClickHouse Kaynak Koduna Göz Atın {#browse-clickhouse-source-code} + +Kullanabilirsiniz **Woboq** online kod tarayıcı mevcut [burada](https://clickhouse.tech/codebrowser/html_report/ClickHouse/src/index.html). Bu kod navigasyon ve semantik vurgulama, arama ve indeksleme sağlar. Kod anlık görüntüsü günlük olarak güncellenir. + +Ayrıca, kaynaklara göz atabilirsiniz [GitHub](https://github.com/ClickHouse/ClickHouse) herzamanki. + +IDE'NİN ne kullanacağı ile ilgileniyorsanız, CLion, QT Creator, vs Code ve KDevelop (uyarılar ile) öneririz. Herhangi bir favori IDE kullanabilirsiniz. Vim ve Emacs da sayılır. diff --git a/docs/tr/development/browse_code.md b/docs/tr/development/browse_code.md deleted file mode 100644 index dacebf01050..00000000000 --- a/docs/tr/development/browse_code.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 63 -toc_title: "ClickHouse Kaynak Koduna G\xF6z At\u0131n" ---- - -# ClickHouse Kaynak Koduna Göz Atın {#browse-clickhouse-source-code} - -Kullanabilirsiniz **Woboq** online kod tarayıcı mevcut [burada](https://clickhouse.tech/codebrowser/html_report///ClickHouse/src/index.html). Bu kod navigasyon ve semantik vurgulama, arama ve indeksleme sağlar. Kod anlık görüntüsü günlük olarak güncellenir. - -Ayrıca, kaynaklara göz atabilirsiniz [GitHub](https://github.com/ClickHouse/ClickHouse) herzamanki. - -IDE'NİN ne kullanacağı ile ilgileniyorsanız, CLion, QT Creator, vs Code ve KDevelop (uyarılar ile) öneririz. Herhangi bir favori IDE kullanabilirsiniz. Vim ve Emacs da sayılır. diff --git a/docs/tr/development/build-cross-arm.md b/docs/tr/development/build-cross-arm.md new file mode 100644 index 00000000000..f0a283bfd98 --- /dev/null +++ b/docs/tr/development/build-cross-arm.md @@ -0,0 +1,43 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 67 +toc_title: "AARCH64 (ARM64) i\xE7in Linux'ta ClickHouse nas\u0131l olu\u015Fturulur)" +--- + +# AARCH64 (ARM64) mimarisi için Linux'ta ClickHouse nasıl oluşturulur {#how-to-build-clickhouse-on-linux-for-aarch64-arm64-architecture} + +Bu, Linux makineniz olduğunda ve onu oluşturmak için kullanmak istediğinizde geçerlidir `clickhouse` AARCH64 CPU mimarisi ile başka bir Linux makinede çalışacak ikili. Bu, Linux sunucularında çalışan sürekli entegrasyon kontrolleri için tasarlanmıştır. + +AARCH64 için çapraz yapı, [Inşa talimatları](build.md) önce onları takip et. + +# Clang-8'i Yükle {#install-clang-8} + +Yönergeleri izleyin https://apt.llvm.org / Ubuntu veya Debian kurulumunuz için. +Örneğin, Ubuntu Bionic'te aşağıdaki komutları kullanabilirsiniz: + +``` bash +echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee /etc/apt/sources.list.d/llvm.list +sudo apt-get update +sudo apt-get install clang-8 +``` + +# Çapraz Derleme Araç Setini Yükle {#install-cross-compilation-toolset} + +``` bash +cd ClickHouse +mkdir -p build-aarch64/cmake/toolchain/linux-aarch64 +wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en' -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz +tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build-aarch64/cmake/toolchain/linux-aarch64 --strip-components=1 +``` + +# ClickHouse İnşa {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-arm64 +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake +ninja -C build-arm64 +``` + +Ortaya çıkan ikili, yalnızca AARCH64 CPU mimarisi ile Linux'ta çalışacaktır. diff --git a/docs/tr/development/build-cross-osx.md b/docs/tr/development/build-cross-osx.md new file mode 100644 index 00000000000..1c9e28746c1 --- /dev/null +++ b/docs/tr/development/build-cross-osx.md @@ -0,0 +1,64 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 66 +toc_title: "Mac OS X i\xE7in Linux'ta ClickHouse nas\u0131l olu\u015Fturulur" +--- + +# Mac OS X için Linux'ta ClickHouse nasıl oluşturulur {#how-to-build-clickhouse-on-linux-for-mac-os-x} + +Bu, Linux makineniz olduğunda ve onu oluşturmak için kullanmak istediğinizde geçerlidir `clickhouse` OS X üzerinde çalışacak ikili. bu, Linux sunucularında çalışan sürekli entegrasyon kontrolleri için tasarlanmıştır. Clickhouse'u doğrudan Mac OS X'te oluşturmak istiyorsanız, devam edin [başka bir talimat](build-osx.md). + +Mac OS X için çapraz yapı, [Inşa talimatları](build.md) önce onları takip et. + +# Clang-8'i Yükle {#install-clang-8} + +Yönergeleri izleyin https://apt.llvm.org / Ubuntu veya Debian kurulumunuz için. +Örneğin biyonik için komutlar gibidir: + +``` bash +sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list +sudo apt-get install clang-8 +``` + +# Çapraz Derleme Araç Setini Yükle {#install-cross-compilation-toolset} + +Yüklediğimiz yolu hatırlayalım `cctools` olarak $ {CCTOOLS} + +``` bash +mkdir ${CCTOOLS} + +git clone https://github.com/tpoechtrager/apple-libtapi.git +cd apple-libtapi +INSTALLPREFIX=${CCTOOLS} ./build.sh +./install.sh +cd .. + +git clone https://github.com/tpoechtrager/cctools-port.git +cd cctools-port/cctools +./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin +make install +``` + +Ayrıca, MacOS X SDK'YI çalışma ağacına indirmemiz gerekiyor. + +``` bash +cd ClickHouse +wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' +mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 +tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 +``` + +# ClickHouse İnşa {#build-clickhouse} + +``` bash +cd ClickHouse +mkdir build-osx +CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ + -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ + -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ + -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld +ninja -C build-osx +``` + +Ortaya çıkan ikili bir Mach-O yürütülebilir biçimine sahip olacak ve Linux üzerinde çalıştırılamaz. diff --git a/docs/tr/development/build-osx.md b/docs/tr/development/build-osx.md new file mode 100644 index 00000000000..f8cecc46c3c --- /dev/null +++ b/docs/tr/development/build-osx.md @@ -0,0 +1,93 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 65 +toc_title: "Mac OS X \xFCzerinde ClickHouse nas\u0131l olu\u015Fturulur" +--- + +# Mac OS X üzerinde ClickHouse nasıl oluşturulur {#how-to-build-clickhouse-on-mac-os-x} + +Build Mac OS X 10.15 (Catalina) üzerinde çalışmalıdır) + +## Homebrew Yüklemek {#install-homebrew} + +``` bash +$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +## Gerekli derleyicileri, araçları ve kitaplıkları yükleyin {#install-required-compilers-tools-and-libraries} + +``` bash +$ brew install cmake ninja libtool gettext +``` + +## Checkout ClickHouse Kaynakları {#checkout-clickhouse-sources} + +``` bash +$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git +``` + +veya + +``` bash +$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git + +$ cd ClickHouse +``` + +## ClickHouse İnşa {#build-clickhouse} + +``` bash +$ mkdir build +$ cd build +$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` +$ ninja +$ cd .. +``` + +## Uyarılar {#caveats} + +Clickhouse-server çalıştırmak istiyorsanız, sistemin maxfiles değişken artırmak için emin olun. + +!!! info "Not" + Sudo kullanmanız gerekecek. + +Bunu yapmak için aşağıdaki dosyayı oluşturun: + +/ Kütüphane / LaunchDaemons / sınırı.maxfiles.plist: + +``` xml + + + + + Label + limit.maxfiles + ProgramArguments + + launchctl + limit + maxfiles + 524288 + 524288 + + RunAtLoad + + ServiceIPC + + + +``` + +Aşağıdaki komutu çalıştırın: + +``` bash +$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist +``` + +Başlatmak. + +Çalışıp çalışmadığını kontrol etmek için şunları kullanabilirsiniz `ulimit -n` komut. + +[Orijinal makale](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/tr/development/build.md b/docs/tr/development/build.md index 3a3cda15f1b..18ef2cd66ae 100644 --- a/docs/tr/development/build.md +++ b/docs/tr/development/build.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 64 toc_title: "Linux \xFCzerinde ClickHouse nas\u0131l olu\u015Fturulur" --- diff --git a/docs/tr/development/build_cross_arm.md b/docs/tr/development/build_cross_arm.md deleted file mode 100644 index d0d18162d6f..00000000000 --- a/docs/tr/development/build_cross_arm.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 67 -toc_title: "AARCH64 (ARM64) i\xE7in Linux'ta ClickHouse nas\u0131l olu\u015Fturulur)" ---- - -# AARCH64 (ARM64) mimarisi için Linux'ta ClickHouse nasıl oluşturulur {#how-to-build-clickhouse-on-linux-for-aarch64-arm64-architecture} - -Bu, Linux makineniz olduğunda ve onu oluşturmak için kullanmak istediğinizde geçerlidir `clickhouse` AARCH64 CPU mimarisi ile başka bir Linux makinede çalışacak ikili. Bu, Linux sunucularında çalışan sürekli entegrasyon kontrolleri için tasarlanmıştır. - -AARCH64 için çapraz yapı, [Inşa talimatları](build.md) önce onları takip et. - -# Clang-8'i Yükle {#install-clang-8} - -Yönergeleri izleyin https://apt.llvm.org / Ubuntu veya Debian kurulumunuz için. -Örneğin, Ubuntu Bionic'te aşağıdaki komutları kullanabilirsiniz: - -``` bash -echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee /etc/apt/sources.list.d/llvm.list -sudo apt-get update -sudo apt-get install clang-8 -``` - -# Çapraz Derleme Araç Setini Yükle {#install-cross-compilation-toolset} - -``` bash -cd ClickHouse -mkdir -p build-aarch64/cmake/toolchain/linux-aarch64 -wget 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en' -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C build-aarch64/cmake/toolchain/linux-aarch64 --strip-components=1 -``` - -# ClickHouse İnşa {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-arm64 -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake -ninja -C build-arm64 -``` - -Ortaya çıkan ikili, yalnızca AARCH64 CPU mimarisi ile Linux'ta çalışacaktır. diff --git a/docs/tr/development/build_cross_osx.md b/docs/tr/development/build_cross_osx.md deleted file mode 100644 index 2001ad985e2..00000000000 --- a/docs/tr/development/build_cross_osx.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 66 -toc_title: "Mac OS X i\xE7in Linux'ta ClickHouse nas\u0131l olu\u015Fturulur" ---- - -# Mac OS X için Linux'ta ClickHouse nasıl oluşturulur {#how-to-build-clickhouse-on-linux-for-mac-os-x} - -Bu, Linux makineniz olduğunda ve onu oluşturmak için kullanmak istediğinizde geçerlidir `clickhouse` OS X üzerinde çalışacak ikili. bu, Linux sunucularında çalışan sürekli entegrasyon kontrolleri için tasarlanmıştır. Clickhouse'u doğrudan Mac OS X'te oluşturmak istiyorsanız, devam edin [başka bir talimat](build_osx.md). - -Mac OS X için çapraz yapı, [Inşa talimatları](build.md) önce onları takip et. - -# Clang-8'i Yükle {#install-clang-8} - -Yönergeleri izleyin https://apt.llvm.org / Ubuntu veya Debian kurulumunuz için. -Örneğin biyonik için komutlar gibidir: - -``` bash -sudo echo "deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list -sudo apt-get install clang-8 -``` - -# Çapraz Derleme Araç Setini Yükle {#install-cross-compilation-toolset} - -Yüklediğimiz yolu hatırlayalım `cctools` olarak $ {CCTOOLS} - -``` bash -mkdir ${CCTOOLS} - -git clone https://github.com/tpoechtrager/apple-libtapi.git -cd apple-libtapi -INSTALLPREFIX=${CCTOOLS} ./build.sh -./install.sh -cd .. - -git clone https://github.com/tpoechtrager/cctools-port.git -cd cctools-port/cctools -./configure --prefix=${CCTOOLS} --with-libtapi=${CCTOOLS} --target=x86_64-apple-darwin -make install -``` - -Ayrıca, MacOS X SDK'YI çalışma ağacına indirmemiz gerekiyor. - -``` bash -cd ClickHouse -wget 'https://github.com/phracker/MacOSX-SDKs/releases/download/10.14-beta4/MacOSX10.14.sdk.tar.xz' -mkdir -p build-darwin/cmake/toolchain/darwin-x86_64 -tar xJf MacOSX10.14.sdk.tar.xz -C build-darwin/cmake/toolchain/darwin-x86_64 --strip-components=1 -``` - -# ClickHouse İnşa {#build-clickhouse} - -``` bash -cd ClickHouse -mkdir build-osx -CC=clang-8 CXX=clang++-8 cmake . -Bbuild-osx -DCMAKE_TOOLCHAIN_FILE=cmake/darwin/toolchain-x86_64.cmake \ - -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ar \ - -DCMAKE_RANLIB:FILEPATH=${CCTOOLS}/bin/x86_64-apple-darwin-ranlib \ - -DLINKER_NAME=${CCTOOLS}/bin/x86_64-apple-darwin-ld -ninja -C build-osx -``` - -Ortaya çıkan ikili bir Mach-O yürütülebilir biçimine sahip olacak ve Linux üzerinde çalıştırılamaz. diff --git a/docs/tr/development/build_osx.md b/docs/tr/development/build_osx.md deleted file mode 100644 index af750725070..00000000000 --- a/docs/tr/development/build_osx.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 65 -toc_title: "Mac OS X \xFCzerinde ClickHouse nas\u0131l olu\u015Fturulur" ---- - -# Mac OS X üzerinde ClickHouse nasıl oluşturulur {#how-to-build-clickhouse-on-mac-os-x} - -Build Mac OS X 10.15 (Catalina) üzerinde çalışmalıdır) - -## Homebrew Yüklemek {#install-homebrew} - -``` bash -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` - -## Gerekli derleyicileri, araçları ve kitaplıkları yükleyin {#install-required-compilers-tools-and-libraries} - -``` bash -$ brew install cmake ninja libtool gettext -``` - -## Checkout ClickHouse Kaynakları {#checkout-clickhouse-sources} - -``` bash -$ git clone --recursive git@github.com:ClickHouse/ClickHouse.git -``` - -veya - -``` bash -$ git clone --recursive https://github.com/ClickHouse/ClickHouse.git - -$ cd ClickHouse -``` - -## ClickHouse İnşa {#build-clickhouse} - -``` bash -$ mkdir build -$ cd build -$ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` -$ ninja -$ cd .. -``` - -## Uyarılar {#caveats} - -Clickhouse-server çalıştırmak istiyorsanız, sistemin maxfiles değişken artırmak için emin olun. - -!!! info "Not" - Sudo kullanmanız gerekecek. - -Bunu yapmak için aşağıdaki dosyayı oluşturun: - -/ Kütüphane / LaunchDaemons / sınırı.maxfiles.plist: - -``` xml - - - - - Label - limit.maxfiles - ProgramArguments - - launchctl - limit - maxfiles - 524288 - 524288 - - RunAtLoad - - ServiceIPC - - - -``` - -Aşağıdaki komutu çalıştırın: - -``` bash -$ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist -``` - -Başlatmak. - -Çalışıp çalışmadığını kontrol etmek için şunları kullanabilirsiniz `ulimit -n` komut. - -[Orijinal makale](https://clickhouse.tech/docs/en/development/build_osx/) diff --git a/docs/tr/development/contrib.md b/docs/tr/development/contrib.md index 7f09d9bc49b..de254f992dc 100644 --- a/docs/tr/development/contrib.md +++ b/docs/tr/development/contrib.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 70 toc_title: "Kullan\u0131lan \xDC\xE7\xFCnc\xFC Taraf K\xFCt\xFCphaneleri" --- diff --git a/docs/tr/development/developer-instruction.md b/docs/tr/development/developer-instruction.md new file mode 100644 index 00000000000..0ca5f9cdd63 --- /dev/null +++ b/docs/tr/development/developer-instruction.md @@ -0,0 +1,287 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "Acemi ClickHouse Geli\u015Ftirici Talimat" +--- + +ClickHouse binası Linux, FreeBSD ve Mac OS X üzerinde desteklenmektedir. + +# Windows Kullanıyorsanız {#if-you-use-windows} + +Windows kullanıyorsanız, Ubuntu ile bir sanal makine oluşturmanız gerekir. Bir sanal makine ile çalışmaya başlamak için VirtualBox yükleyin. UB :unt :u'yu web sitesinden indirebilirsiniz: https://www.ubuntu.com/\#download. lütfen indirilen görüntüden bir sanal makine oluşturun (bunun için en az 4GB RAM ayırmalısınız). Ubuntu'da bir komut satırı terminali çalıştırmak için lütfen kelimeyi içeren bir program bulun “terminal” adına (gnome-terminal, konsole vb.)) veya sadece Ctrl+Alt+T tuşlarına basın. + +# 32 bit sistem kullanıyorsanız {#if-you-use-a-32-bit-system} + +ClickHouse çalışamaz veya 32-bit bir sistem üzerinde oluşturun. 64-bit bir sisteme erişim kazanmanız gerekir ve okumaya devam edebilirsiniz. + +# Github'da bir depo oluşturma {#creating-a-repository-on-github} + +ClickHouse repository ile çalışmaya başlamak için bir GitHub hesabına ihtiyacınız olacaktır. + +Muhtemelen zaten bir tane var, ama yapmazsanız, lütfen kayıt olun https://github.com. SSH anahtarlarınız yoksa, bunları üretmeli ve daha sonra Github'a yüklemelisiniz. Bu yamalar üzerinden göndermek için gereklidir. Diğer SSH sunucularıyla kullandığınız aynı SSH anahtarlarını kullanmak da mümkündür - muhtemelen zaten bunlara sahipsiniz. + +ClickHouse deposunun bir çatalı oluşturun. Bunu yapmak için lütfen tıklayın “fork” sağ üst köşedeki düğme https://github.com/ClickHouse/ClickHouse. bu hesabınıza ClickHouse / ClickHouse kendi kopyasını çatal olacaktır. + +Geliştirme süreci ilk ClickHouse sizin çatal içine amaçlanan değişiklikleri işlemekle ve daha sonra bir oluşturma oluşur “pull request” bu değişikliklerin ana depoya kabul edilmesi için (ClickHouse/ClickHouse). + +Git depoları ile çalışmak için lütfen yükleyin `git`. + +Bunu Ubuntu'da yapmak için komut satırı terminalinde çalışırsınız: + + sudo apt update + sudo apt install git + +Git kullanımı ile ilgili kısa bir el kitabı burada bulunabilir: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf. +Git ile ilgili ayrıntılı bir el kitabı için bkz. https://git-scm.com/book/en/v2. + +# Geliştirme Makinenize bir depo klonlama {#cloning-a-repository-to-your-development-machine} + +Ardından, kaynak dosyaları çalışma makinenize indirmeniz gerekir. Bu denir “to clone a repository” çünkü çalışma makinenizde deponun yerel bir kopyasını oluşturur. + +Komut satırında terminal Çalıştır: + + git clone --recursive git@github.com:your_github_username/ClickHouse.git + cd ClickHouse + +Not: lütfen, yerine *your\_github\_username* uygun olanı ile! + +Bu komut bir dizin oluşturacaktır `ClickHouse` projenin çalışma kopyasını içeren. + +Yapı sistemini çalıştırmakla ilgili sorunlara yol açabileceğinden, çalışma dizininin yolunun hiçbir boşluk içermemesi önemlidir. + +ClickHouse deposunun kullandığını lütfen unutmayın `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` yukarıdaki örnekte olduğu gibi bayrak. Depo alt modüller olmadan klonlanmışsa, bunları indirmek için aşağıdakileri çalıştırmanız gerekir: + + git submodule init + git submodule update + +Komutu ile durumunu kontrol edebilirsiniz: `git submodule status`. + +Aşağıdaki hata iletisini alırsanız: + + Permission denied (publickey). + fatal: Could not read from remote repository. + + Please make sure you have the correct access rights + and the repository exists. + +Genellikle Github'a bağlanmak için SSH anahtarlarının eksik olduğu anlamına gelir. Bu anahtarlar normalde `~/.ssh`. SSH anahtarlarının kabul edilmesi için bunları GitHub kullanıcı arayüzünün ayarlar bölümüne yüklemeniz gerekir. + +Depoyu https protokolü aracılığıyla da klonlayabilirsiniz: + + git clone https://github.com/ClickHouse/ClickHouse.git + +Ancak bu, değişikliklerinizi sunucuya göndermenize izin vermez. Yine de geçici olarak kullanabilir ve SSH anahtarlarını daha sonra deponun uzak adresini değiştirerek ekleyebilirsiniz `git remote` komut. + +Oradan güncellemeleri çekmek için orijinal ClickHouse repo'nun adresini yerel deponuza da ekleyebilirsiniz: + + git remote add upstream git@github.com:ClickHouse/ClickHouse.git + +Başarıyla bu komutu çalıştırdıktan sonra çalıştırarak ana ClickHouse repo güncellemeleri çekmek mümkün olacak `git pull upstream master`. + +## Alt modüllerle çalışma {#working-with-submodules} + +Git'teki alt modüllerle çalışmak acı verici olabilir. Sonraki komutlar onu yönetmeye yardımcı olacaktır: + + # ! each command accepts --recursive + # Update remote URLs for submodules. Barely rare case + git submodule sync + # Add new submodules + git submodule init + # Update existing submodules to the current state + git submodule update + # Two last commands could be merged together + git submodule update --init + +Bir sonraki komutlar, tüm alt modülleri başlangıç durumuna sıfırlamanıza yardımcı olacaktır (!UYARI! - herhangi bir değişiklik içinde silinecektir): + + # Synchronizes submodules' remote URL with .gitmodules + git submodule sync --recursive + # Update the registered submodules with initialize not yet initialized + git submodule update --init --recursive + # Reset all changes done after HEAD + git submodule foreach git reset --hard + # Clean files from .gitignore + git submodule foreach git clean -xfd + # Repeat last 4 commands for all submodule + git submodule foreach git submodule sync --recursive + git submodule foreach git submodule update --init --recursive + git submodule foreach git submodule foreach git reset --hard + git submodule foreach git submodule foreach git clean -xfd + +# Yapı Sistemi {#build-system} + +ClickHouse bina için Cmake ve Ninja kullanır. + +Cmake-ninja dosyaları (yapı görevleri) üretebilir bir meta-yapı sistemi. +Ninja-bu cmake oluşturulan görevleri yürütmek için kullanılan hıza odaklanarak daha küçük bir yapı sistemi. + +Ubuntu, Debian veya Mint run'a yüklemek için `sudo apt install cmake ninja-build`. + +Centos'ta, RedHat koşusu `sudo yum install cmake ninja-build`. + +Arch veya Gentoo kullanıyorsanız, muhtemelen cmake'i nasıl kuracağınızı kendiniz biliyorsunuz. + +Mac OS X üzerinde cmake ve Ninja yüklemek için ilk homebrew yüklemek ve daha sonra demlemek yoluyla her şeyi yüklemek: + + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install cmake ninja + +Ardından, cmake sürümünü kontrol edin: `cmake --version`. 3.3'ün altındaysa, web sitesinden daha yeni bir sürüm yüklemelisiniz: https://cmake.org/download/. + +# İsteğe Bağlı Harici Kütüphaneler {#optional-external-libraries} + +ClickHouse, bina için birkaç dış kütüphane kullanır. Alt modüllerde bulunan kaynaklardan ClickHouse ile birlikte oluşturuldukları için hepsinin ayrı olarak kurulması gerekmez. Listeyi kontrol edebilirsiniz `contrib`. + +# C++ Derleyici {#c-compiler} + +Derleyiciler gcc sürüm 9 ve Clang sürüm 8 veya üzeri başlayarak ClickHouse bina için desteklenmektedir. + +Resmi Yandex şu anda GCC'Yİ kullanıyor çünkü biraz daha iyi performansa sahip makine kodu üretiyor (kriterlerimize göre yüzde birkaçına kadar bir fark yaratıyor). Ve Clang genellikle geliştirme için daha uygundur. Yine de, sürekli entegrasyon (CI) platformumuz yaklaşık bir düzine yapı kombinasyonunu denetler. + +Ubuntu run GCC yüklemek için: `sudo apt install gcc g++` + +Gcc sürümünü kontrol edin: `gcc --version`. 9'un altındaysa, buradaki talimatları izleyin: https://clickhouse.tech/docs/tr/development/build/#install-gcc-9. + +Mac OS X build sadece Clang için desteklenir. Sadece koş `brew install llvm` + +Eğer Clang kullanmaya karar verirseniz, ayrıca yükleyebilirsiniz `libc++` ve `lld` eğer ne olduğunu biliyorsan. Kullanım `ccache` ayrıca tavsiye edilir. + +# İnşaat Süreci {#the-building-process} + +Artık ClickHouse oluşturmaya hazır olduğunuza göre ayrı bir dizin oluşturmanızı öneririz `build` için `ClickHouse` bu, tüm yapı eserlerini içerecek: + + mkdir build + cd build + +Birkaç farklı dizine (build\_release, build\_debug, vb.) sahip olabilirsiniz.) farklı yapı türleri için. + +İçinde iken `build` dizin, cmake çalıştırarak yapı yapılandırın. İlk çalıştırmadan önce, derleyici belirten ortam değişkenlerini tanımlamanız gerekir (bu örnekte sürüm 9 gcc derleyicisi). + +Linux: + + export CC=gcc-9 CXX=g++-9 + cmake .. + +Mac OS X: + + export CC=clang CXX=clang++ + cmake .. + +Bu `CC` değişken C için derleyiciyi belirtir (C derleyicisi için kısa) ve `CXX` değişken, hangi C++ derleyicisinin bina için kullanılacağını bildirir. + +Daha hızlı bir yapı için, `debug` yapı türü-hiçbir optimizasyonları ile bir yapı. Bunun için aşağıdaki parametreyi sağlayın `-D CMAKE_BUILD_TYPE=Debug`: + + cmake -D CMAKE_BUILD_TYPE=Debug .. + +Bu komutu çalıştırarak yapı türünü değiştirebilirsiniz. `build` dizin. + +İnşa etmek için ninja çalıştırın: + + ninja clickhouse-server clickhouse-client + +Bu örnekte yalnızca gerekli ikili dosyalar oluşturulacaktır. + +Tüm ikili dosyaları (Yardımcı Programlar ve testler) oluşturmanız gerekiyorsa, ninja'yı parametre olmadan çalıştırmalısınız: + + ninja + +Tam yapı, ana ikili dosyaları oluşturmak için yaklaşık 30GB boş disk alanı veya 15GB gerektirir. + +Yapı makinesinde büyük miktarda RAM mevcut olduğunda, paralel olarak çalışan yapı görevlerinin sayısını sınırlamanız gerekir `-j` param: + + ninja -j 1 clickhouse-server clickhouse-client + +4GB RAM'Lİ makinelerde, 8GB RAM için 1 belirtmeniz önerilir `-j 2` tavsiye edilir. + +Mesajı alırsanız: `ninja: error: loading 'build.ninja': No such file or directory` bu, bir yapı yapılandırması oluşturmanın başarısız olduğu ve yukarıdaki mesajı incelemeniz gerektiği anlamına gelir. + +Bina işleminin başarılı bir şekilde başlatılmasının ardından, yapı ilerlemesini görürsünüz-işlenmiş görevlerin sayısı ve toplam görev sayısı. + +Libhdfs2 kütüphanesinde protobuf dosyaları hakkında mesajlar oluştururken `libprotobuf WARNING` ortaya çıkabilir. Hiçbir şeyi etkilemezler ve göz ardı edilmeleri güvenlidir. + +Başarılı bir yapı üzerine yürütülebilir bir dosya alırsınız `ClickHouse//programs/clickhouse`: + + ls -l programs/clickhouse + +# Clickhouse'un yerleşik yürütülebilir dosyasını çalıştırma {#running-the-built-executable-of-clickhouse} + +Sunucuyu geçerli kullanıcı altında çalıştırmak için aşağıdakilere gitmeniz gerekir `ClickHouse/programs/server/` (dışında bulunan `build`) ve koş: + + ../../build/programs/clickhouse server + +Bu durumda, ClickHouse geçerli dizinde bulunan yapılandırma dosyalarını kullanır. Koş youabilirsiniz `clickhouse server` komut satırı parametresi olarak bir yapılandırma dosyasının yolunu belirten herhangi bir dizinden `--config-file`. + +Başka bir terminalde clickhouse-client ile Clickhouse'a bağlanmak için `ClickHouse/build/programs/` ve koş `clickhouse client`. + +Eğer alırsanız `Connection refused` Mac OS X veya Freebsd'de mesaj, ana bilgisayar adresi 127.0.0.1 belirtmeyi deneyin: + + clickhouse client --host 127.0.0.1 + +Sisteminizde yüklü olan ClickHouse binary'nin üretim sürümünü özel olarak oluşturulmuş ClickHouse binaryinizle değiştirebilirsiniz. Bunu yapmak için resmi web sitesinden talimatları izleyerek Makinenize ClickHouse yükleyin. Ardından, aşağıdakileri çalıştırın: + + sudo service clickhouse-server stop + sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ + sudo service clickhouse-server start + +Not thate that `clickhouse-client`, `clickhouse-server` ve diğerleri yaygın olarak paylaşılan sembolik bağlardır `clickhouse` ikilik. + +Ayrıca sisteminizde yüklü ClickHouse paketinden yapılandırma dosyası ile özel inşa ClickHouse ikili çalıştırabilirsiniz: + + sudo service clickhouse-server stop + sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml + +# IDE (entegre geliştirme ortamı) {#ide-integrated-development-environment} + +Hangi IDE kullanmak bilmiyorsanız, clion kullanmanızı öneririz. CLion ticari bir yazılımdır, ancak 30 günlük ücretsiz deneme süresi sunar. Öğrenciler için de ücretsizdir. CLion Linux ve Mac OS X hem de kullanılabilir. + +KDevelop ve QTCreator, ClickHouse geliştirmek için bir IDE'NİN diğer harika alternatifleridir. KDevelop kararsız olmasına rağmen çok kullanışlı bir IDE olarak geliyor. KDevelop projeyi açtıktan sonra bir süre sonra çökerse, tıklamanız gerekir “Stop All” proje dosyalarının listesini açar açmaz düğme. Bunu yaptıktan sonra KDevelop ile çalışmak iyi olmalıdır. + +Basit kod editörleri olarak, Yüce metin veya Visual Studio kodunu veya Kate'i (hepsi Linux'ta kullanılabilir) kullanabilirsiniz. + +Her ihtimale karşı, Clion'un yarattığını belirtmek gerekir `build` kendi başına yol, aynı zamanda kendi seçtikleri `debug` yapı türü için, yapılandırma için Clion'da tanımlanan ve sizin tarafınızdan yüklenmeyen bir cmake sürümünü kullanır ve son olarak CLion kullanacaktır `make` yerine yapı görevlerini çalıştırmak için `ninja`. Bu normal bir davranıştır, sadece karışıklığı önlemek için bunu aklınızda bulundurun. + +# Kod Yazma {#writing-code} + +Açıklaması ClickHouse mimarisi burada bulabilirsiniz: https://clickhouse.tech / doscs/TR / development / Arch /it /ec /ture/ + +Kod stili Kılavuzu: https://clickhouse.tech / doscs / TR / development / style/ + +Yazma testleri: https://clickhouse.teknoloji / doscs / TR / geliştirme / testler/ + +Görevlerin listesi: https://github.com/ClickHouse/ClickHouse/contribute + +# Test Verileri {#test-data} + +Clickhouse'un geliştirilmesi genellikle gerçekçi veri kümelerinin yüklenmesini gerektirir. Performans testi için özellikle önemlidir. Yandex'ten özel olarak hazırlanmış anonim veri setimiz var.Metrica. Ayrıca bazı 3GB boş disk alanı gerektirir. Bu verilerin geliştirme görevlerinin çoğunu gerçekleştirmek için gerekli olmadığını unutmayın. + + sudo apt install wget xz-utils + + wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz + wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz + + xz -v -d hits_v1.tsv.xz + xz -v -d visits_v1.tsv.xz + + clickhouse-client + + CREATE DATABASE IF NOT EXISTS test + + CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); + + CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); + + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv + clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv + +# Çekme İsteği Oluşturma {#creating-pull-request} + +Github'un kullanıcı arayüzünde çatal deposuna gidin. Bir dalda gelişiyorsanız, o Dalı seçmeniz gerekir. Bir olacak “Pull request” ekranda bulunan düğme. Özünde, bu demektir “create a request for accepting my changes into the main repository”. + +Çalışma henüz tamamlanmamış olsa bile bir çekme isteği oluşturulabilir. Bu durumda lütfen kelimeyi koyun “WIP” (devam eden çalışma) başlığın başında, daha sonra değiştirilebilir. Bu, kooperatif Gözden geçirme ve değişikliklerin tartışılması ve mevcut tüm testlerin çalıştırılması için kullanışlıdır. Değişikliklerinizin kısa bir açıklamasını sağlamanız önemlidir, daha sonra sürüm değişiklikleri oluşturmak için kullanılacaktır. + +Yandex çalışanları PR'NİZİ bir etiketle etiketlediğinde testler başlayacaktır “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. + +Sistem, çekme isteğiniz için ayrı ayrı ClickHouse ikili yapıları hazırlayacaktır. Bu yapıları almak için tıklayın “Details” yanındaki bağlantı “ClickHouse build check” çekler listesinde giriş. Orada inşa doğrudan bağlantılar bulacaksınız .eğer üretim sunucularında bile dağıtabilirsiniz ClickHouse DEB paketleri (eğer hiçbir korku varsa). + +Büyük olasılıkla bazı yapılar ilk kez başarısız olur. Bunun nedeni, hem gcc hem de clang ile, hemen hemen tüm mevcut uyarılarla (her zaman `-Werror` bayrak) clang için etkin. Aynı sayfada, tüm yapı günlüklerini bulabilirsiniz, böylece tüm olası yollarla ClickHouse oluşturmak zorunda kalmazsınız. diff --git a/docs/tr/development/developer_instruction.md b/docs/tr/development/developer_instruction.md deleted file mode 100644 index f9984d9bf20..00000000000 --- a/docs/tr/development/developer_instruction.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 61 -toc_title: "Acemi ClickHouse Geli\u015Ftirici Talimat" ---- - -ClickHouse binası Linux, FreeBSD ve Mac OS X üzerinde desteklenmektedir. - -# Windows Kullanıyorsanız {#if-you-use-windows} - -Windows kullanıyorsanız, Ubuntu ile bir sanal makine oluşturmanız gerekir. Bir sanal makine ile çalışmaya başlamak için VirtualBox yükleyin. UB :unt :u'yu web sitesinden indirebilirsiniz: https://www.ubuntu.com/\#download. lütfen indirilen görüntüden bir sanal makine oluşturun (bunun için en az 4GB RAM ayırmalısınız). Ubuntu'da bir komut satırı terminali çalıştırmak için lütfen kelimeyi içeren bir program bulun “terminal” adına (gnome-terminal, konsole vb.)) veya sadece Ctrl+Alt+T tuşlarına basın. - -# 32 bit sistem kullanıyorsanız {#if-you-use-a-32-bit-system} - -ClickHouse çalışamaz veya 32-bit bir sistem üzerinde oluşturun. 64-bit bir sisteme erişim kazanmanız gerekir ve okumaya devam edebilirsiniz. - -# Github'da bir depo oluşturma {#creating-a-repository-on-github} - -ClickHouse repository ile çalışmaya başlamak için bir GitHub hesabına ihtiyacınız olacaktır. - -Muhtemelen zaten bir tane var, ama yapmazsanız, lütfen kayıt olun https://github.com. SSH anahtarlarınız yoksa, bunları üretmeli ve daha sonra Github'a yüklemelisiniz. Bu yamalar üzerinden göndermek için gereklidir. Diğer SSH sunucularıyla kullandığınız aynı SSH anahtarlarını kullanmak da mümkündür - muhtemelen zaten bunlara sahipsiniz. - -ClickHouse deposunun bir çatalı oluşturun. Bunu yapmak için lütfen tıklayın “fork” sağ üst köşedeki düğme https://github.com/ClickHouse/ClickHouse. bu hesabınıza ClickHouse / ClickHouse kendi kopyasını çatal olacaktır. - -Geliştirme süreci ilk ClickHouse sizin çatal içine amaçlanan değişiklikleri işlemekle ve daha sonra bir oluşturma oluşur “pull request” bu değişikliklerin ana depoya kabul edilmesi için (ClickHouse/ClickHouse). - -Git depoları ile çalışmak için lütfen yükleyin `git`. - -Bunu Ubuntu'da yapmak için komut satırı terminalinde çalışırsınız: - - sudo apt update - sudo apt install git - -Git kullanımı ile ilgili kısa bir el kitabı burada bulunabilir: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf. -Git ile ilgili ayrıntılı bir el kitabı için bkz. https://git-scm.com/book/en/v2. - -# Geliştirme Makinenize bir depo klonlama {#cloning-a-repository-to-your-development-machine} - -Ardından, kaynak dosyaları çalışma makinenize indirmeniz gerekir. Bu denir “to clone a repository” çünkü çalışma makinenizde deponun yerel bir kopyasını oluşturur. - -Komut satırında terminal Çalıştır: - - git clone --recursive git@guthub.com:your_github_username/ClickHouse.git - cd ClickHouse - -Not: lütfen, yerine *your\_github\_username* uygun olanı ile! - -Bu komut bir dizin oluşturacaktır `ClickHouse` projenin çalışma kopyasını içeren. - -Yapı sistemini çalıştırmakla ilgili sorunlara yol açabileceğinden, çalışma dizininin yolunun hiçbir boşluk içermemesi önemlidir. - -ClickHouse deposunun kullandığını lütfen unutmayın `submodules`. That is what the references to additional repositories are called (i.e. external libraries on which the project depends). It means that when cloning the repository you need to specify the `--recursive` yukarıdaki örnekte olduğu gibi bayrak. Depo alt modüller olmadan klonlanmışsa, bunları indirmek için aşağıdakileri çalıştırmanız gerekir: - - git submodule init - git submodule update - -Komutu ile durumunu kontrol edebilirsiniz: `git submodule status`. - -Aşağıdaki hata iletisini alırsanız: - - Permission denied (publickey). - fatal: Could not read from remote repository. - - Please make sure you have the correct access rights - and the repository exists. - -Genellikle Github'a bağlanmak için SSH anahtarlarının eksik olduğu anlamına gelir. Bu anahtarlar normalde `~/.ssh`. SSH anahtarlarının kabul edilmesi için bunları GitHub kullanıcı arayüzünün ayarlar bölümüne yüklemeniz gerekir. - -Depoyu https protokolü aracılığıyla da klonlayabilirsiniz: - - git clone https://github.com/ClickHouse/ClickHouse.git - -Ancak bu, değişikliklerinizi sunucuya göndermenize izin vermez. Yine de geçici olarak kullanabilir ve SSH anahtarlarını daha sonra deponun uzak adresini değiştirerek ekleyebilirsiniz `git remote` komut. - -Oradan güncellemeleri çekmek için orijinal ClickHouse repo'nun adresini yerel deponuza da ekleyebilirsiniz: - - git remote add upstream git@github.com:ClickHouse/ClickHouse.git - -Başarıyla bu komutu çalıştırdıktan sonra çalıştırarak ana ClickHouse repo güncellemeleri çekmek mümkün olacak `git pull upstream master`. - -## Alt modüllerle çalışma {#working-with-submodules} - -Git'teki alt modüllerle çalışmak acı verici olabilir. Sonraki komutlar onu yönetmeye yardımcı olacaktır: - - # ! each command accepts --recursive - # Update remote URLs for submodules. Barely rare case - git submodule sync - # Add new submodules - git submodule init - # Update existing submodules to the current state - git submodule update - # Two last commands could be merged together - git submodule update --init - -Bir sonraki komutlar, tüm alt modülleri başlangıç durumuna sıfırlamanıza yardımcı olacaktır (!UYARI! - herhangi bir değişiklik içinde silinecektir): - - # Synchronizes submodules' remote URL with .gitmodules - git submodule sync --recursive - # Update the registered submodules with initialize not yet initialized - git submodule update --init --recursive - # Reset all changes done after HEAD - git submodule foreach git reset --hard - # Clean files from .gitignore - git submodule foreach git clean -xfd - # Repeat last 4 commands for all submodule - git submodule foreach git submodule sync --recursive - git submodule foreach git submodule update --init --recursive - git submodule foreach git submodule foreach git reset --hard - git submodule foreach git submodule foreach git clean -xfd - -# Yapı Sistemi {#build-system} - -ClickHouse bina için Cmake ve Ninja kullanır. - -Cmake-ninja dosyaları (yapı görevleri) üretebilir bir meta-yapı sistemi. -Ninja-bu cmake oluşturulan görevleri yürütmek için kullanılan hıza odaklanarak daha küçük bir yapı sistemi. - -Ubuntu, Debian veya Mint run'a yüklemek için `sudo apt install cmake ninja-build`. - -Centos'ta, RedHat koşusu `sudo yum install cmake ninja-build`. - -Arch veya Gentoo kullanıyorsanız, muhtemelen cmake'i nasıl kuracağınızı kendiniz biliyorsunuz. - -Mac OS X üzerinde cmake ve Ninja yüklemek için ilk homebrew yüklemek ve daha sonra demlemek yoluyla her şeyi yüklemek: - - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew install cmake ninja - -Ardından, cmake sürümünü kontrol edin: `cmake --version`. 3.3'ün altındaysa, web sitesinden daha yeni bir sürüm yüklemelisiniz: https://cmake.org/download/. - -# İsteğe Bağlı Harici Kütüphaneler {#optional-external-libraries} - -ClickHouse, bina için birkaç dış kütüphane kullanır. Alt modüllerde bulunan kaynaklardan ClickHouse ile birlikte oluşturuldukları için hepsinin ayrı olarak kurulması gerekmez. Listeyi kontrol edebilirsiniz `contrib`. - -# C++ Derleyici {#c-compiler} - -Derleyiciler gcc sürüm 9 ve Clang sürüm 8 veya üzeri başlayarak ClickHouse bina için desteklenmektedir. - -Resmi Yandex şu anda GCC'Yİ kullanıyor çünkü biraz daha iyi performansa sahip makine kodu üretiyor (kriterlerimize göre yüzde birkaçına kadar bir fark yaratıyor). Ve Clang genellikle geliştirme için daha uygundur. Yine de, sürekli entegrasyon (CI) platformumuz yaklaşık bir düzine yapı kombinasyonunu denetler. - -Ubuntu run GCC yüklemek için: `sudo apt install gcc g++` - -Gcc sürümünü kontrol edin: `gcc --version`. 9'un altındaysa, buradaki talimatları izleyin: https://clickhouse.tech / docs/TR/development / build / \#ınstall-gcc-9. - -Mac OS X build sadece Clang için desteklenir. Sadece koş `brew install llvm` - -Eğer Clang kullanmaya karar verirseniz, ayrıca yükleyebilirsiniz `libc++` ve `lld` eğer ne olduğunu biliyorsan. Kullanım `ccache` ayrıca tavsiye edilir. - -# İnşaat Süreci {#the-building-process} - -Artık ClickHouse oluşturmaya hazır olduğunuza göre ayrı bir dizin oluşturmanızı öneririz `build` için `ClickHouse` bu, tüm yapı eserlerini içerecek: - - mkdir build - cd build - -Birkaç farklı dizine (build\_release, build\_debug, vb.) sahip olabilirsiniz.) farklı yapı türleri için. - -İçinde iken `build` dizin, cmake çalıştırarak yapı yapılandırın. İlk çalıştırmadan önce, derleyici belirten ortam değişkenlerini tanımlamanız gerekir (bu örnekte sürüm 9 gcc derleyicisi). - -Linux: - - export CC=gcc-9 CXX=g++-9 - cmake .. - -Mac OS X: - - export CC=clang CXX=clang++ - cmake .. - -Bu `CC` değişken C için derleyiciyi belirtir (C derleyicisi için kısa) ve `CXX` değişken, hangi C++ derleyicisinin bina için kullanılacağını bildirir. - -Daha hızlı bir yapı için, `debug` yapı türü-hiçbir optimizasyonları ile bir yapı. Bunun için aşağıdaki parametreyi sağlayın `-D CMAKE_BUILD_TYPE=Debug`: - - cmake -D CMAKE_BUILD_TYPE=Debug .. - -Bu komutu çalıştırarak yapı türünü değiştirebilirsiniz. `build` dizin. - -İnşa etmek için ninja çalıştırın: - - ninja clickhouse-server clickhouse-client - -Bu örnekte yalnızca gerekli ikili dosyalar oluşturulacaktır. - -Tüm ikili dosyaları (Yardımcı Programlar ve testler) oluşturmanız gerekiyorsa, ninja'yı parametre olmadan çalıştırmalısınız: - - ninja - -Tam yapı, ana ikili dosyaları oluşturmak için yaklaşık 30GB boş disk alanı veya 15GB gerektirir. - -Yapı makinesinde büyük miktarda RAM mevcut olduğunda, paralel olarak çalışan yapı görevlerinin sayısını sınırlamanız gerekir `-j` param: - - ninja -j 1 clickhouse-server clickhouse-client - -4GB RAM'Lİ makinelerde, 8GB RAM için 1 belirtmeniz önerilir `-j 2` tavsiye edilir. - -Mesajı alırsanız: `ninja: error: loading 'build.ninja': No such file or directory` bu, bir yapı yapılandırması oluşturmanın başarısız olduğu ve yukarıdaki mesajı incelemeniz gerektiği anlamına gelir. - -Bina işleminin başarılı bir şekilde başlatılmasının ardından, yapı ilerlemesini görürsünüz-işlenmiş görevlerin sayısı ve toplam görev sayısı. - -Libhdfs2 kütüphanesinde protobuf dosyaları hakkında mesajlar oluştururken `libprotobuf WARNING` ortaya çıkabilir. Hiçbir şeyi etkilemezler ve göz ardı edilmeleri güvenlidir. - -Başarılı bir yapı üzerine yürütülebilir bir dosya alırsınız `ClickHouse//programs/clickhouse`: - - ls -l programs/clickhouse - -# Clickhouse'un yerleşik yürütülebilir dosyasını çalıştırma {#running-the-built-executable-of-clickhouse} - -Sunucuyu geçerli kullanıcı altında çalıştırmak için aşağıdakilere gitmeniz gerekir `ClickHouse/programs/server/` (dışında bulunan `build`) ve koş: - - ../../../build/programs/clickhouse server - -Bu durumda, ClickHouse geçerli dizinde bulunan yapılandırma dosyalarını kullanır. Koş youabilirsiniz `clickhouse server` komut satırı parametresi olarak bir yapılandırma dosyasının yolunu belirten herhangi bir dizinden `--config-file`. - -Başka bir terminalde clickhouse-client ile Clickhouse'a bağlanmak için `ClickHouse/build/programs/` ve koş `clickhouse client`. - -Eğer alırsanız `Connection refused` Mac OS X veya Freebsd'de mesaj, ana bilgisayar adresi 127.0.0.1 belirtmeyi deneyin: - - clickhouse client --host 127.0.0.1 - -Sisteminizde yüklü olan ClickHouse binary'nin üretim sürümünü özel olarak oluşturulmuş ClickHouse binaryinizle değiştirebilirsiniz. Bunu yapmak için resmi web sitesinden talimatları izleyerek Makinenize ClickHouse yükleyin. Ardından, aşağıdakileri çalıştırın: - - sudo service clickhouse-server stop - sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ - sudo service clickhouse-server start - -Not thate that `clickhouse-client`, `clickhouse-server` ve diğerleri yaygın olarak paylaşılan sembolik bağlardır `clickhouse` ikilik. - -Ayrıca sisteminizde yüklü ClickHouse paketinden yapılandırma dosyası ile özel inşa ClickHouse ikili çalıştırabilirsiniz: - - sudo service clickhouse-server stop - sudo -u clickhouse ClickHouse/build/programs/clickhouse server --config-file /etc/clickhouse-server/config.xml - -# IDE (entegre geliştirme ortamı) {#ide-integrated-development-environment} - -Hangi IDE kullanmak bilmiyorsanız, clion kullanmanızı öneririz. CLion ticari bir yazılımdır, ancak 30 günlük ücretsiz deneme süresi sunar. Öğrenciler için de ücretsizdir. CLion Linux ve Mac OS X hem de kullanılabilir. - -KDevelop ve QTCreator, ClickHouse geliştirmek için bir IDE'NİN diğer harika alternatifleridir. KDevelop kararsız olmasına rağmen çok kullanışlı bir IDE olarak geliyor. KDevelop projeyi açtıktan sonra bir süre sonra çökerse, tıklamanız gerekir “Stop All” proje dosyalarının listesini açar açmaz düğme. Bunu yaptıktan sonra KDevelop ile çalışmak iyi olmalıdır. - -Basit kod editörleri olarak, Yüce metin veya Visual Studio kodunu veya Kate'i (hepsi Linux'ta kullanılabilir) kullanabilirsiniz. - -Her ihtimale karşı, Clion'un yarattığını belirtmek gerekir `build` kendi başına yol, aynı zamanda kendi seçtikleri `debug` yapı türü için, yapılandırma için Clion'da tanımlanan ve sizin tarafınızdan yüklenmeyen bir cmake sürümünü kullanır ve son olarak CLion kullanacaktır `make` yerine yapı görevlerini çalıştırmak için `ninja`. Bu normal bir davranıştır, sadece karışıklığı önlemek için bunu aklınızda bulundurun. - -# Kod Yazma {#writing-code} - -Açıklaması ClickHouse mimarisi burada bulabilirsiniz: https://clickhouse.tech / doscs/TR / development / Arch /it /ec /ture/ - -Kod stili Kılavuzu: https://clickhouse.tech / doscs / TR / development / style/ - -Yazma testleri: https://clickhouse.teknoloji / doscs / TR / geliştirme / testler/ - -Görevlerin listesi: https://github.com/ClickHouse/ClickHouse/blob/master/testsructions/easy\_tasks\_sorted\_en.md - -# Test Verileri {#test-data} - -Clickhouse'un geliştirilmesi genellikle gerçekçi veri kümelerinin yüklenmesini gerektirir. Performans testi için özellikle önemlidir. Yandex'ten özel olarak hazırlanmış anonim veri setimiz var.Metrica. Ayrıca bazı 3GB boş disk alanı gerektirir. Bu verilerin geliştirme görevlerinin çoğunu gerçekleştirmek için gerekli olmadığını unutmayın. - - sudo apt install wget xz-utils - - wget https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz - wget https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz - - xz -v -d hits_v1.tsv.xz - xz -v -d visits_v1.tsv.xz - - clickhouse-client - - CREATE TABLE test.hits ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID), EventTime); - - CREATE TABLE test.visits ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), `Goals.ID` Array(UInt32), `Goals.Serial` Array(UInt32), `Goals.EventTime` Array(DateTime), `Goals.Price` Array(Int64), `Goals.OrderID` Array(String), `Goals.CurrencyID` Array(UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, `TraficSource.ID` Array(Int8), `TraficSource.SearchEngineID` Array(UInt16), `TraficSource.AdvEngineID` Array(UInt8), `TraficSource.PlaceID` Array(UInt16), `TraficSource.SocialSourceNetworkID` Array(UInt8), `TraficSource.Domain` Array(String), `TraficSource.SearchPhrase` Array(String), `TraficSource.SocialSourcePage` Array(String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `Market.Type` Array(UInt8), `Market.GoalID` Array(UInt32), `Market.OrderID` Array(String), `Market.OrderPrice` Array(Int64), `Market.PP` Array(UInt32), `Market.DirectPlaceID` Array(UInt32), `Market.DirectOrderID` Array(UInt32), `Market.DirectBannerID` Array(UInt32), `Market.GoodID` Array(String), `Market.GoodName` Array(String), `Market.GoodQuantity` Array(Int32), `Market.GoodPrice` Array(Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) SAMPLE BY intHash32(UserID) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID); - - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.hits FORMAT TSV" < hits_v1.tsv - clickhouse-client --max_insert_block_size 100000 --query "INSERT INTO test.visits FORMAT TSV" < visits_v1.tsv - -# Çekme İsteği Oluşturma {#creating-pull-request} - -Github'un kullanıcı arayüzünde çatal deposuna gidin. Bir dalda gelişiyorsanız, o Dalı seçmeniz gerekir. Bir olacak “Pull request” ekranda bulunan düğme. Özünde, bu demektir “create a request for accepting my changes into the main repository”. - -Çalışma henüz tamamlanmamış olsa bile bir çekme isteği oluşturulabilir. Bu durumda lütfen kelimeyi koyun “WIP” (devam eden çalışma) başlığın başında, daha sonra değiştirilebilir. Bu, kooperatif Gözden geçirme ve değişikliklerin tartışılması ve mevcut tüm testlerin çalıştırılması için kullanışlıdır. Değişikliklerinizin kısa bir açıklamasını sağlamanız önemlidir, daha sonra sürüm değişiklikleri oluşturmak için kullanılacaktır. - -Yandex çalışanları PR'NİZİ bir etiketle etiketlediğinde testler başlayacaktır “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour. - -Sistem, çekme isteğiniz için ayrı ayrı ClickHouse ikili yapıları hazırlayacaktır. Bu yapıları almak için tıklayın “Details” yanındaki bağlantı “ClickHouse build check” çekler listesinde giriş. Orada inşa doğrudan bağlantılar bulacaksınız .eğer üretim sunucularında bile dağıtabilirsiniz ClickHouse DEB paketleri (eğer hiçbir korku varsa). - -Büyük olasılıkla bazı yapılar ilk kez başarısız olur. Bunun nedeni, hem gcc hem de clang ile, hemen hemen tüm mevcut uyarılarla (her zaman `-Werror` bayrak) clang için etkin. Aynı sayfada, tüm yapı günlüklerini bulabilirsiniz, böylece tüm olası yollarla ClickHouse oluşturmak zorunda kalmazsınız. diff --git a/docs/tr/development/index.md b/docs/tr/development/index.md index fdd4c0c0805..ef972914d46 100644 --- a/docs/tr/development/index.md +++ b/docs/tr/development/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: "Geli\u015Fme" toc_hidden: true toc_priority: 58 diff --git a/docs/tr/development/style.md b/docs/tr/development/style.md index 713f95cf053..3e8f5960d64 100644 --- a/docs/tr/development/style.md +++ b/docs/tr/development/style.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 68 toc_title: "C++ kodu nas\u0131l yaz\u0131l\u0131r" --- @@ -88,7 +88,7 @@ Gerekirse, operatör bir sonraki satıra sarılabilir. Bu durumda, önündeki of **11.** Tekli operatörleri ayırmak için boşluk kullanmayın (`--`, `++`, `*`, `&`, …) from the argument. -**12.** Virgülden sonra bir boşluk koyun, ancak ondan önce değil. Aynı kural, bir içindeki noktalı virgül için de geçerlidir `for` ifade. +**12.** Virgülden sonra bir boşluk koyun, ancak ondan önce değil. Aynı kural, bir içindeki noktalı virgül için de geçerlidir `for` İfade. **13.** Ayırmak için boşluk kullanmayın `[]` operatör. @@ -662,7 +662,7 @@ Kullan... `DB/IO` kütüphane yerine. Görmek `DateLUT` kitaplık. -**22.** içermek. +**22.** İçermek. Her zaman kullanın `#pragma once` korumaları dahil etmek yerine. diff --git a/docs/tr/development/tests.md b/docs/tr/development/tests.md index 1d39c24da5f..b2b9d83fe7a 100644 --- a/docs/tr/development/tests.md +++ b/docs/tr/development/tests.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 69 toc_title: "ClickHouse testleri nas\u0131l \xE7al\u0131\u015Ft\u0131r\u0131l\u0131\ r" @@ -200,13 +200,23 @@ Hata ayıklama sürümü `jemalloc` hata ayıklama oluşturmak için kullanılı ## Fuzzing {#fuzzing} -Rastgele SQL sorguları oluşturmak ve sunucunun ölmediğini kontrol etmek için basit fuzz testi kullanıyoruz. Fuzz testi Adres dezenfektanı ile yapılır. İçinde bulabilirsiniz `00746_sql_fuzzy.pl`. Bu test sürekli olarak (gece ve daha uzun) çalıştırılmalıdır. +ClickHouse fuzzing hem kullanılarak uygulanmaktadır [libFuzzer](https://llvm.org/docs/LibFuzzer.html) ve rastgele SQL sorguları. +Tüm fuzz testleri sanitizers (Adres ve tanımsız) ile yapılmalıdır. -Aralık 2018 itibariyle, hala kütüphane kodunun izole fuzz testini kullanmıyoruz. +LibFuzzer kütüphane kodu izole fuzz testi için kullanılır. Fuzzers test kodunun bir parçası olarak uygulanır ve “\_fuzzer” adı postfixes. +Fuzzer örneği bulunabilir `src/Parsers/tests/lexer_fuzzer.cpp`. LibFuzzer özgü yapılandırmalar, sözlükler ve corpus saklanır `tests/fuzz`. +Kullanıcı girişini işleyen her işlevsellik için fuzz testleri yazmanızı öneririz. + +Fuzzers varsayılan olarak oluşturulmaz. Hem fuzzers inşa etmek `-DENABLE_FUZZING=1` ve `-DENABLE_TESTS=1` seçenekler ayarlanmalıdır. +Fuzzers oluştururken Jemalloc'u devre dışı bırakmanızı öneririz. ClickHouse fuzzing'i entegre etmek için kullanılan yapılandırma +Google OSS-Fuzz bulunabilir `docker/fuzz`. + +Ayrıca rastgele SQL sorguları oluşturmak ve sunucunun bunları çalıştırarak ölmediğini kontrol etmek için basit fuzz testi kullanıyoruz. +İçinde bulabilirsiniz `00746_sql_fuzzy.pl`. Bu test sürekli olarak (gece ve daha uzun) çalıştırılmalıdır. ## Güvenlik Denetimi {#security-audit} -Yandex Bulut departmanından insanlar, güvenlik açısından ClickHouse yeteneklerine bazı temel genel bakışlar yaparlar. +Yandex Güvenlik ekibinden insanlar güvenlik açısından ClickHouse yetenekleri bazı temel bakış yapmak. ## Statik Analizörler {#static-analyzers} diff --git a/docs/tr/engines/database-engines/index.md b/docs/tr/engines/database-engines/index.md new file mode 100644 index 00000000000..e15ae0f3365 --- /dev/null +++ b/docs/tr/engines/database-engines/index.md @@ -0,0 +1,21 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Veritaban\u0131 Motorlar\u0131" +toc_priority: 27 +toc_title: "Giri\u015F" +--- + +# Veritabanı Motorları {#database-engines} + +Veritabanı motorları, tablolarla çalışmanıza izin verir. + +Varsayılan olarak, ClickHouse yapılandırılabilir sağlayan yerel veritabanı altyapısını kullanır [masa motorları](../../engines/table-engines/index.md) ve bir [SQL lehçesi](../../sql-reference/syntax.md). + +Aşağıdaki veritabanı altyapılarını da kullanabilirsiniz: + +- [MySQL](mysql.md) + +- [Tembel](lazy.md) + +[Orijinal makale](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/tr/engines/database-engines/lazy.md b/docs/tr/engines/database-engines/lazy.md new file mode 100644 index 00000000000..41226c320de --- /dev/null +++ b/docs/tr/engines/database-engines/lazy.md @@ -0,0 +1,18 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: Tembel +--- + +# Tembel {#lazy} + +Tabloları yalnızca RAM'de tutar `expiration_time_in_seconds` son erişimden saniyeler sonra. Sadece \* Log tabloları ile kullanılabilir. + +Erişimler arasında uzun bir zaman aralığı olan birçok küçük \* günlük tablosunu saklamak için optimize edilmiştir. + +## Veritabanı oluşturma {#creating-a-database} + + CREATE DATABASE testlazy ENGINE = Lazy(expiration_time_in_seconds); + +[Orijinal makale](https://clickhouse.tech/docs/en/database_engines/lazy/) diff --git a/docs/tr/engines/database-engines/mysql.md b/docs/tr/engines/database-engines/mysql.md new file mode 100644 index 00000000000..2120add59aa --- /dev/null +++ b/docs/tr/engines/database-engines/mysql.md @@ -0,0 +1,135 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 30 +toc_title: MySQL +--- + +# MySQL {#mysql} + +Uzak bir MySQL sunucusunda veritabanlarına bağlanmak ve gerçekleştirmek için izin verir `INSERT` ve `SELECT` ClickHouse ve MySQL arasında veri alışverişi için sorgular. + +Bu `MySQL` veritabanı motoru sorguları MySQL sunucusuna çevirir, böylece aşağıdaki gibi işlemleri gerçekleştirebilirsiniz `SHOW TABLES` veya `SHOW CREATE TABLE`. + +Aşağıdaki sorguları gerçekleştiremiyor: + +- `RENAME` +- `CREATE TABLE` +- `ALTER` + +## Veritabanı oluşturma {#creating-a-database} + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] +ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') +``` + +**Motor Parametreleri** + +- `host:port` — MySQL server address. +- `database` — Remote database name. +- `user` — MySQL user. +- `password` — User password. + +## Veri Türleri Desteği {#data_types-support} + +| MySQL | ClickHouse | +|----------------------------------|--------------------------------------------------------------| +| UNSIGNED TINYINT | [Uİnt8](../../sql-reference/data-types/int-uint.md) | +| TINYINT | [Int8](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED SMALLINT | [Uınt16](../../sql-reference/data-types/int-uint.md) | +| SMALLINT | [Int16](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED INT, UNSIGNED MEDIUMINT | [Uİnt32](../../sql-reference/data-types/int-uint.md) | +| INT, MEDIUMINT | [Int32](../../sql-reference/data-types/int-uint.md) | +| UNSIGNED BIGINT | [Uİnt64](../../sql-reference/data-types/int-uint.md) | +| BIGINT | [Int64](../../sql-reference/data-types/int-uint.md) | +| FLOAT | [Float32](../../sql-reference/data-types/float.md) | +| DOUBLE | [Float64](../../sql-reference/data-types/float.md) | +| DATE | [Tarihli](../../sql-reference/data-types/date.md) | +| DATETIME, TIMESTAMP | [DateTime](../../sql-reference/data-types/datetime.md) | +| BINARY | [FixedString](../../sql-reference/data-types/fixedstring.md) | + +Diğer tüm MySQL veri türleri dönüştürülür [Dize](../../sql-reference/data-types/string.md). + +[Nullable](../../sql-reference/data-types/nullable.md) desteklenir. + +## Kullanım örnekleri {#examples-of-use} + +MySQL tablo: + +``` text +mysql> USE test; +Database changed + +mysql> CREATE TABLE `mysql_table` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `float` FLOAT NOT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from mysql_table; ++------+-----+ +| int_id | value | ++------+-----+ +| 1 | 2 | ++------+-----+ +1 row in set (0,00 sec) +``` + +Clickhouse'daki veritabanı, MySQL sunucusu ile veri alışverişi: + +``` sql +CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') +``` + +``` sql +SHOW DATABASES +``` + +``` text +┌─name─────┐ +│ default │ +│ mysql_db │ +│ system │ +└──────────┘ +``` + +``` sql +SHOW TABLES FROM mysql_db +``` + +``` text +┌─name─────────┐ +│ mysql_table │ +└──────────────┘ +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +└────────┴───────┘ +``` + +``` sql +INSERT INTO mysql_db.mysql_table VALUES (3,4) +``` + +``` sql +SELECT * FROM mysql_db.mysql_table +``` + +``` text +┌─int_id─┬─value─┐ +│ 1 │ 2 │ +│ 3 │ 4 │ +└────────┴───────┘ +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/tr/engines/database_engines/index.md b/docs/tr/engines/database_engines/index.md deleted file mode 100644 index c0e0bea8ab5..00000000000 --- a/docs/tr/engines/database_engines/index.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "Veritaban\u0131 Motorlar\u0131" -toc_priority: 27 -toc_title: "Giri\u015F" ---- - -# Veritabanı Motorları {#database-engines} - -Veritabanı motorları, tablolarla çalışmanıza izin verir. - -Varsayılan olarak, ClickHouse yapılandırılabilir sağlayan yerel veritabanı altyapısını kullanır [masa motorları](../../engines/table_engines/index.md) ve bir [SQL lehçesi](../../sql_reference/syntax.md). - -Aşağıdaki veritabanı altyapılarını da kullanabilirsiniz: - -- [MySQL](mysql.md) - -- [Tembel](lazy.md) - -[Orijinal makale](https://clickhouse.tech/docs/en/database_engines/) diff --git a/docs/tr/engines/database_engines/lazy.md b/docs/tr/engines/database_engines/lazy.md deleted file mode 100644 index 85436fdc164..00000000000 --- a/docs/tr/engines/database_engines/lazy.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 31 -toc_title: Tembel ---- - -# Tembel {#lazy} - -Tabloları yalnızca RAM'de tutar `expiration_time_in_seconds` son erişimden saniyeler sonra. Sadece \* Log tabloları ile kullanılabilir. - -Erişimler arasında uzun bir zaman aralığı olan birçok küçük \* günlük tablosunu saklamak için optimize edilmiştir. - -## Veritabanı oluşturma {#creating-a-database} - - CREATE DATABASE testlazy ENGINE = Lazy(expiration_time_in_seconds); - -[Orijinal makale](https://clickhouse.tech/docs/en/database_engines/lazy/) diff --git a/docs/tr/engines/database_engines/mysql.md b/docs/tr/engines/database_engines/mysql.md deleted file mode 100644 index 974515ab655..00000000000 --- a/docs/tr/engines/database_engines/mysql.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 30 -toc_title: MySQL ---- - -# MySQL {#mysql} - -Uzak bir MySQL sunucusunda veritabanlarına bağlanmak ve gerçekleştirmek için izin verir `INSERT` ve `SELECT` ClickHouse ve MySQL arasında veri alışverişi için sorgular. - -Bu `MySQL` veritabanı motoru sorguları MySQL sunucusuna çevirir, böylece aşağıdaki gibi işlemleri gerçekleştirebilirsiniz `SHOW TABLES` veya `SHOW CREATE TABLE`. - -Aşağıdaki sorguları gerçekleştiremiyor: - -- `RENAME` -- `CREATE TABLE` -- `ALTER` - -## Veritabanı oluşturma {#creating-a-database} - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] -ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') -``` - -**Motor Parametreleri** - -- `host:port` — MySQL server address. -- `database` — Remote database name. -- `user` — MySQL user. -- `password` — User password. - -## Veri Türleri Desteği {#data_types-support} - -| MySQL | ClickHouse | -|----------------------------------|--------------------------------------------------------------| -| UNSIGNED TINYINT | [Uİnt8](../../sql_reference/data_types/int_uint.md) | -| TINYINT | [Int8](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED SMALLINT | [Uınt16](../../sql_reference/data_types/int_uint.md) | -| SMALLINT | [Int16](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED INT, UNSIGNED MEDIUMINT | [Uİnt32](../../sql_reference/data_types/int_uint.md) | -| INT, MEDIUMINT | [Int32](../../sql_reference/data_types/int_uint.md) | -| UNSIGNED BIGINT | [Uİnt64](../../sql_reference/data_types/int_uint.md) | -| BIGINT | [Int64](../../sql_reference/data_types/int_uint.md) | -| FLOAT | [Float32](../../sql_reference/data_types/float.md) | -| DOUBLE | [Float64](../../sql_reference/data_types/float.md) | -| DATE | [Tarihli](../../sql_reference/data_types/date.md) | -| DATETIME, TIMESTAMP | [DateTime](../../sql_reference/data_types/datetime.md) | -| BINARY | [FixedString](../../sql_reference/data_types/fixedstring.md) | - -Diğer tüm MySQL veri türleri dönüştürülür [Dize](../../sql_reference/data_types/string.md). - -[Nullable](../../sql_reference/data_types/nullable.md) desteklenir. - -## Kullanım Örnekleri {#examples-of-use} - -MySQL tablo: - -``` text -mysql> USE test; -Database changed - -mysql> CREATE TABLE `mysql_table` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `float` FLOAT NOT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into mysql_table (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from mysql_table; -+------+-----+ -| int_id | value | -+------+-----+ -| 1 | 2 | -+------+-----+ -1 row in set (0,00 sec) -``` - -Clickhouse'daki veritabanı, MySQL sunucusu ile veri alışverişi: - -``` sql -CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') -``` - -``` sql -SHOW DATABASES -``` - -``` text -┌─name─────┐ -│ default │ -│ mysql_db │ -│ system │ -└──────────┘ -``` - -``` sql -SHOW TABLES FROM mysql_db -``` - -``` text -┌─name─────────┐ -│ mysql_table │ -└──────────────┘ -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -└────────┴───────┘ -``` - -``` sql -INSERT INTO mysql_db.mysql_table VALUES (3,4) -``` - -``` sql -SELECT * FROM mysql_db.mysql_table -``` - -``` text -┌─int_id─┬─value─┐ -│ 1 │ 2 │ -│ 3 │ 4 │ -└────────┴───────┘ -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/database_engines/mysql/) diff --git a/docs/tr/engines/index.md b/docs/tr/engines/index.md index 48004afa1c8..221dc87bdfb 100644 --- a/docs/tr/engines/index.md +++ b/docs/tr/engines/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Motorlar toc_priority: 25 --- diff --git a/docs/tr/engines/table-engines/index.md b/docs/tr/engines/table-engines/index.md new file mode 100644 index 00000000000..01a447dbc6c --- /dev/null +++ b/docs/tr/engines/table-engines/index.md @@ -0,0 +1,85 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Masa Motorlar\u0131" +toc_priority: 26 +toc_title: "Giri\u015F" +--- + +# Masa Motorları {#table_engines} + +Tablo motoru (tablo türü) belirler: + +- Verilerin nasıl ve nerede depolandığı, nereye yazılacağı ve nereden okunacağı. +- Hangi sorgular desteklenir ve nasıl. +- Eşzamanlı veri erişimi. +- Varsa indeks uselerin kullanımı. +- Çok iş parçacıklı istek yürütme mümkün olup olmadığı. +- Veri çoğaltma parametreleri. + +## Motor Aileleri {#engine-families} + +### MergeTree {#mergetree} + +Yüksek yük görevleri için en evrensel ve fonksiyonel masa motorları. Bu motorlar tarafından paylaşılan özellik, sonraki arka plan veri işleme ile hızlı veri ekleme ' dir. `MergeTree` aile motorları destek veri çoğaltma (ile [Çoğaltıyordu\*](mergetree-family/replication.md#table_engines-replication) sürümleri), bölümleme ve diğer özellikler diğer motorlarda desteklenmez. + +Ailede motorlar: + +- [MergeTree](mergetree-family/mergetree.md#mergetree) +- [ReplacingMergeTree](mergetree-family/replacingmergetree.md#replacingmergetree) +- [SummingMergeTree](mergetree-family/summingmergetree.md#summingmergetree) +- [AggregatingMergeTree](mergetree-family/aggregatingmergetree.md#aggregatingmergetree) +- [CollapsingMergeTree](mergetree-family/collapsingmergetree.md#table_engine-collapsingmergetree) +- [VersionedCollapsingMergeTree](mergetree-family/versionedcollapsingmergetree.md#versionedcollapsingmergetree) +- [Graphıtemergetree](mergetree-family/graphitemergetree.md#graphitemergetree) + +### Günlük {#log} + +Hafiflik [motorlar](log-family/index.md) minimum işlevsellik ile. Birçok küçük tabloyu (yaklaşık 1 milyon satıra kadar) hızlı bir şekilde yazmanız ve daha sonra bir bütün olarak okumanız gerektiğinde en etkili olanlardır. + +Ailede motorlar: + +- [TinyLog](log-family/tinylog.md#tinylog) +- [StripeLog](log-family/stripelog.md#stripelog) +- [Günlük](log-family/log.md#log) + +### Entegrasyon Motorları {#integration-engines} + +Diğer veri depolama ve işleme sistemleri ile iletişim kurmak için motorlar. + +Ailede motorlar: + +- [Kafka](integrations/kafka.md#kafka) +- [MySQL](integrations/mysql.md#mysql) +- [ODBC](integrations/odbc.md#table-engine-odbc) +- [JDBC](integrations/jdbc.md#table-engine-jdbc) +- [HDFS](integrations/hdfs.md#hdfs) + +### Özel Motorlar {#special-engines} + +Ailede motorlar: + +- [Dağılı](special/distributed.md#distributed) +- [MaterializedView](special/materializedview.md#materializedview) +- [Sözlük](special/dictionary.md#dictionary) +- \[Mer \]ge\] (spec /ial / mer \#ge. md\#mer \#ge +- [Dosya](special/file.md#file) +- [Boş](special/null.md#null) +- [Koymak](special/set.md#set) +- [Katmak](special/join.md#join) +- [URL](special/url.md#table_engines-url) +- [Görünüm](special/view.md#table_engines-view) +- [Hafıza](special/memory.md#memory) +- [Arabellek](special/buffer.md#buffer) + +## Sanal Sütunlar {#table_engines-virtual_columns} + +Sanal sütun, motor kaynak kodunda tanımlanan ayrılmaz bir tablo altyapısı özniteliğidir. + +Sanal sütunları belirtmemelisiniz `CREATE TABLE` sorgula ve onları göremezsin `SHOW CREATE TABLE` ve `DESCRIBE TABLE` sorgu sonuçları. Sanal sütunlar da salt okunur, bu nedenle sanal sütunlara veri ekleyemezsiniz. + +Sanal bir sütundan veri seçmek için, adını `SELECT` sorgu. `SELECT *` sanal sütunlardan değerler döndürmez. + +Tablo sanal sütunlarından biriyle aynı ada sahip bir sütuna sahip bir tablo oluşturursanız, sanal sütuna erişilemez hale gelir. Bunu yapmayı önermiyoruz. Çakışmaları önlemek için, sanal sütun adları genellikle bir alt çizgi ile öneki. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/tr/engines/table-engines/integrations/hdfs.md b/docs/tr/engines/table-engines/integrations/hdfs.md new file mode 100644 index 00000000000..a69d717f0e4 --- /dev/null +++ b/docs/tr/engines/table-engines/integrations/hdfs.md @@ -0,0 +1,123 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: HDFS +--- + +# HDFS {#table_engines-hdfs} + +Bu motor ile entegrasyon sağlar [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) üzerinde veri Yönet allowingilmesine izin vererek ekosist dataem [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)ClickHouse aracılığıyla. Bu motor benzer +to the [Dosya](../special/file.md#table_engines-file) ve [URL](../special/url.md#table_engines-url) motorlar, ancak hadoop özgü özellikleri sağlar. + +## Kullanma {#usage} + +``` sql +ENGINE = HDFS(URI, format) +``` + +Bu `URI` parametre, HDFS'DEKİ tüm dosya URI'SIDIR. +Bu `format` parametre kullanılabilir dosya biçimlerinden birini belirtir. Gerçekleştirmek +`SELECT` sorgular, biçim giriş için desteklenmeli ve gerçekleştirmek için +`INSERT` queries – for output. The available formats are listed in the +[Biçimliler](../../../interfaces/formats.md#formats) bölme. +Yol kısmı `URI` globs içerebilir. Bu durumda tablo salt okunur olurdu. + +**Örnek:** + +**1.** Set up the `hdfs_engine_table` Tablo: + +``` sql +CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') +``` + +**2.** Fil filel file: + +``` sql +INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) +``` + +**3.** Verileri sorgula: + +``` sql +SELECT * FROM hdfs_engine_table LIMIT 2 +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Uygulama Detayları {#implementation-details} + +- Okuma ve yazma paralel olabilir +- Desteklenmiyor: + - `ALTER` ve `SELECT...SAMPLE` harekat. + - Dizinler. + - Çoğalma. + +**Yolda Globs** + +Birden çok yol bileşenleri globs olabilir. İşlenmek için dosya var olmalı ve tüm yol deseniyle eşleşmelidir. Sırasında dosyaların listelen ofmesini belirler `SELECT` (not at `CREATE` an). + +- `*` — Substitutes any number of any characters except `/` boş dize dahil. +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +İle yapılar `{}` benzer olan [uzak](../../../sql-reference/table-functions/remote.md) tablo işlevi. + +**Örnek** + +1. HDFS'DE aşağıdaki Urı'lerle TSV formatında birkaç dosyamız olduğunu varsayalım: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. Altı dosyadan oluşan bir tablo oluşturmanın birkaç yolu vardır: + + + +``` sql +CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') +``` + +Başka bir yol: + +``` sql +CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') +``` + +Tablo, her iki dizindeki tüm dosyalardan oluşur (tüm dosyalar, sorguda açıklanan biçimi ve şemayı karşılamalıdır): + +``` sql +CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') +``` + +!!! warning "Uyarıcı" + Dosyaların listelenmesi, önde gelen sıfırlarla sayı aralıkları içeriyorsa, her basamak için parantez içeren yapıyı ayrı ayrı kullanın veya kullanın `?`. + +**Örnek** + +Adlı dosyaları içeren tablo oluşturma `file000`, `file001`, … , `file999`: + +``` sql +CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') +``` + +## Sanal Sütunlar {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**Ayrıca Bakınız** + +- [Sanal sütunlar](../index.md#table_engines-virtual_columns) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/tr/engines/table-engines/integrations/index.md b/docs/tr/engines/table-engines/integrations/index.md new file mode 100644 index 00000000000..937532c247d --- /dev/null +++ b/docs/tr/engines/table-engines/integrations/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: Entegrasyonlar +toc_priority: 30 +--- + + diff --git a/docs/tr/engines/table-engines/integrations/jdbc.md b/docs/tr/engines/table-engines/integrations/jdbc.md new file mode 100644 index 00000000000..76deb938047 --- /dev/null +++ b/docs/tr/engines/table-engines/integrations/jdbc.md @@ -0,0 +1,90 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: JDBC +--- + +# JDBC {#table-engine-jdbc} + +ClickHouse üzerinden harici veritabanlarına bağlanmak için izin verir [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). + +JDBC bağlantısını uygulamak için ClickHouse ayrı programı kullanır [clickhouse-JDBC-köprü](https://github.com/alex-krash/clickhouse-jdbc-bridge) bu bir daemon olarak çalışmalıdır. + +Bu motor destekler [Nullable](../../../sql-reference/data-types/nullable.md) veri türü. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name +( + columns list... +) +ENGINE = JDBC(dbms_uri, external_database, external_table) +``` + +**Motor Parametreleri** + +- `dbms_uri` — URI of an external DBMS. + + Biçimli: `jdbc:://:/?user=&password=`. + MySQL örneği: `jdbc:mysql://localhost:3306/?user=root&password=root`. + +- `external_database` — Database in an external DBMS. + +- `external_table` — Name of the table in `external_database`. + +## Kullanım Örneği {#usage-example} + +Doğrudan konsol istemcisine bağlanarak MySQL sunucusunda bir tablo oluşturma: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +ClickHouse Server'da bir tablo oluşturma ve ondan veri seçme: + +``` sql +CREATE TABLE jdbc_table +( + `int_id` Int32, + `int_nullable` Nullable(Int32), + `float` Float32, + `float_nullable` Nullable(Float32) +) +ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') +``` + +``` sql +SELECT * +FROM jdbc_table +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## Ayrıca Bakınız {#see-also} + +- [JDBC tablo işlevi](../../../sql-reference/table-functions/jdbc.md). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/tr/engines/table-engines/integrations/kafka.md b/docs/tr/engines/table-engines/integrations/kafka.md new file mode 100644 index 00000000000..d74711b21e4 --- /dev/null +++ b/docs/tr/engines/table-engines/integrations/kafka.md @@ -0,0 +1,180 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: Kafka +--- + +# Kafka {#kafka} + +Bu motor ile çalışır [Apache Kafka](http://kafka.apache.org/). + +Kafka sağlar: + +- Veri akışlarını yayınlayın veya abone olun. +- Hataya dayanıklı depolama düzenlemek. +- Kullanılabilir hale geldikçe akışları işleyin. + +## Tablo oluşturma {#table_engine-kafka-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = Kafka() +SETTINGS + kafka_broker_list = 'host:port', + kafka_topic_list = 'topic1,topic2,...', + kafka_group_name = 'group_name', + kafka_format = 'data_format'[,] + [kafka_row_delimiter = 'delimiter_symbol',] + [kafka_schema = '',] + [kafka_num_consumers = N,] + [kafka_max_block_size = 0,] + [kafka_skip_broken_messages = N,] + [kafka_commit_every_batch = 0] +``` + +Gerekli parametreler: + +- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). +- `kafka_topic_list` – A list of Kafka topics. +- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don't want messages to be duplicated in the cluster, use the same group name everywhere. +- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` fonksiyon gibi `JSONEachRow`. Daha fazla bilgi için, bkz: [Biçimliler](../../../interfaces/formats.md) bölme. + +İsteğe bağlı parametreler: + +- `kafka_row_delimiter` – Delimiter character, which ends the message. +- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap'n Proto](https://capnproto.org/) şema dosyasının yolunu ve kök adını gerektirir `schema.capnp:Message` nesne. +- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Bir tüketicinin verimi yetersizse daha fazla tüketici belirtin. Bölüm başına yalnızca bir tüketici atanabileceğinden, toplam tüketici sayısı konudaki bölüm sayısını geçmemelidir. +- `kafka_max_block_size` - Anket için maksimum toplu iş boyutu (mesajlarda) (varsayılan: `max_block_size`). +- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. Eğer `kafka_skip_broken_messages = N` sonra motor atlar *N* Ayrıştırılamayan Kafka iletileri (bir ileti bir veri satırına eşittir). +- `kafka_commit_every_batch` - Bütün bir blok yazdıktan sonra tek bir taahhüt yerine tüketilen ve işlenen her toplu işlemi gerçekleştirin (varsayılan: `0`). + +Örnekler: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + SELECT * FROM queue LIMIT 5; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', + kafka_topic_list = 'topic', + kafka_group_name = 'group1', + kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; + + CREATE TABLE queue2 ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') + SETTINGS kafka_format = 'JSONEachRow', + kafka_num_consumers = 4; +``` + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın. Mümkünse, eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format + [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) +``` + +
+ +## Açıklama {#description} + +Teslim edilen mesajlar otomatik olarak izlenir, bu nedenle bir gruptaki her mesaj yalnızca bir kez sayılır. Verileri iki kez almak istiyorsanız, tablonun başka bir grup adıyla bir kopyasını oluşturun. + +Gruplar esnek ve kümede senkronize edilir. Örneğin, bir kümede 10 konu ve bir tablonun 5 kopyası varsa, her kopya 2 konu alır. Kopya sayısı değişirse, konular kopyalar arasında otomatik olarak yeniden dağıtılır. Bu konuda daha fazla bilgi edinin http://kafka.apache.org/intro. + +`SELECT` mesajları okumak için özellikle yararlı değildir (hata ayıklama hariç), çünkü her mesaj yalnızca bir kez okunabilir. Hayata görünümler kullanarak gerçek zamanlı iş parçacıkları oluşturmak daha pratiktir. Bunu yapmak için : + +1. Bir Kafka tüketici oluşturmak için motoru kullanın ve bir veri akışı düşünün. +2. İstenen yapıya sahip bir tablo oluşturun. +3. Verileri motordan dönüştüren ve daha önce oluşturulmuş bir tabloya koyan materyalleştirilmiş bir görünüm oluşturun. + +Ne zaman `MATERIALIZED VIEW` motora katılır, arka planda veri toplamaya başlar. Bu, kafka'dan sürekli olarak mesaj almanızı ve bunları kullanarak gerekli biçime dönüştürmenizi sağlar `SELECT`. +Bir kafka tablosu istediğiniz kadar materialized görüşe sahip olabilir, kafka tablosundan doğrudan veri okumazlar, ancak yeni kayıtlar (bloklar halinde) alırlar, bu şekilde farklı ayrıntı seviyesine sahip birkaç tabloya yazabilirsiniz (gruplama-toplama ve olmadan). + +Örnek: + +``` sql + CREATE TABLE queue ( + timestamp UInt64, + level String, + message String + ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); + + CREATE TABLE daily ( + day Date, + level String, + total UInt64 + ) ENGINE = SummingMergeTree(day, (day, level), 8192); + + CREATE MATERIALIZED VIEW consumer TO daily + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + FROM queue GROUP BY day, level; + + SELECT level, sum(total) FROM daily GROUP BY level; +``` + +Performansı artırmak için, alınan iletiler bloklar halinde gruplandırılır [max\_ınsert\_block\_size](../../../operations/server-configuration-parameters/settings.md#settings-max_insert_block_size). İçinde blok oluş ifma ifdıysa [stream\_flush\_interval\_ms](../../../operations/server-configuration-parameters/settings.md) milisaniye, veri blok bütünlüğü ne olursa olsun tabloya temizlendi. + +Konu verilerini almayı durdurmak veya dönüşüm mantığını değiştirmek için, hayata geçirilmiş görünümü ayırın: + +``` sql + DETACH TABLE consumer; + ATTACH TABLE consumer; +``` + +Kullanarak hedef tabloyu değiştirmek istiyorsanız `ALTER` hedef tablo ile görünümdeki veriler arasındaki tutarsızlıkları önlemek için malzeme görünümünü devre dışı bırakmanızı öneririz. + +## Yapılandırma {#configuration} + +GraphiteMergeTree benzer şekilde, Kafka motoru ClickHouse yapılandırma dosyasını kullanarak genişletilmiş yapılandırmayı destekler. Kullanabileceğiniz iki yapılandırma anahtarı vardır: global (`kafka`) ve konu düzeyinde (`kafka_*`). Genel yapılandırma önce uygulanır ve sonra konu düzeyinde yapılandırma uygulanır (varsa). + +``` xml + + + cgrp + smallest + + + + + 250 + 100000 + +``` + +Olası yapılandırma seçeneklerinin listesi için bkz. [librdkafka yapılandırma referansı](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Alt çizgiyi kullan (`_`) ClickHouse yapılandırmasında bir nokta yerine. Mesela, `check.crcs=true` olacak `true`. + +## Sanal Sütunlar {#virtual-columns} + +- `_topic` — Kafka topic. +- `_key` — Key of the message. +- `_offset` — Offset of the message. +- `_timestamp` — Timestamp of the message. +- `_partition` — Partition of Kafka topic. + +**Ayrıca Bakınız** + +- [Sanal sütunlar](../index.md#table_engines-virtual_columns) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/tr/engines/table-engines/integrations/mysql.md b/docs/tr/engines/table-engines/integrations/mysql.md new file mode 100644 index 00000000000..6f490a26b48 --- /dev/null +++ b/docs/tr/engines/table-engines/integrations/mysql.md @@ -0,0 +1,105 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: MySQL +--- + +# Mysql {#mysql} + +MySQL motoru gerçekleştirmek için izin verir `SELECT` uzak bir MySQL sunucusunda depolanan veriler üzerinde sorgular. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... +) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +Ayrıntılı bir açıklamasını görmek [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) sorgu. + +Tablo yapısı orijinal MySQL tablo yapısından farklı olabilir: + +- Sütun adları orijinal MySQL tablosundaki ile aynı olmalıdır, ancak bu sütunların sadece bazılarını ve herhangi bir sırada kullanabilirsiniz. +- Sütun türleri orijinal MySQL tablosundakilerden farklı olabilir. ClickHouse çalışır [döküm](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) ClickHouse veri türleri için değerler. + +**Motor Parametreleri** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` için sorgular `REPLACE INTO`. Eğer `replace_query=1`, sorgu değiştirilir. + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` eklenen ifade `INSERT` sorgu. + + Örnek: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, nere `on_duplicate_clause` oluyor `UPDATE c2 = c2 + 1`. Görmek [MySQL dökü documentationmanları](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) bulmak için hangi `on_duplicate_clause` ile kullanabilirsiniz `ON DUPLICATE KEY` yan. + + Belirtmek `on_duplicate_clause` sen geçmek gerekir `0` to the `replace_query` parametre. Aynı anda geçerseniz `replace_query = 1` ve `on_duplicate_clause`, ClickHouse bir özel durum oluşturur. + +Basit `WHERE` gibi maddeler `=, !=, >, >=, <, <=` MySQL sunucusunda yürütülür. + +Geri kalan şartlar ve `LIMIT` örnekleme kısıtlaması, yalnızca MySQL sorgusu bittikten sonra Clickhouse'da yürütülür. + +## Kullanım Örneği {#usage-example} + +MySQL tablo: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Clickhouse'daki tablo, yukarıda oluşturulan MySQL tablosundan veri alma: + +``` sql +CREATE TABLE mysql_table +( + `float_nullable` Nullable(Float32), + `int_id` Int32 +) +ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` sql +SELECT * FROM mysql_table +``` + +``` text +┌─float_nullable─┬─int_id─┐ +│ ᴺᵁᴸᴸ │ 1 │ +└────────────────┴────────┘ +``` + +## Ayrıca Bakınız {#see-also} + +- [Bu ‘mysql’ tablo fonksiyonu](../../../sql-reference/table-functions/mysql.md) +- [Harici sözlük kaynağı olarak MySQL kullanma](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/tr/engines/table-engines/integrations/odbc.md b/docs/tr/engines/table-engines/integrations/odbc.md new file mode 100644 index 00000000000..1c3208f0e5d --- /dev/null +++ b/docs/tr/engines/table-engines/integrations/odbc.md @@ -0,0 +1,132 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: ODBC +--- + +# ODBC {#table-engine-odbc} + +ClickHouse üzerinden harici veritabanlarına bağlanmak için izin verir [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +ODBC bağlantılarını güvenli bir şekilde uygulamak için ClickHouse ayrı bir program kullanır `clickhouse-odbc-bridge`. ODBC sürücüsü doğrudan yüklenmişse `clickhouse-server`, sürücü sorunları ClickHouse sunucu çökmesine neden olabilir. ClickHouse otomatik olarak başlar `clickhouse-odbc-bridge` gerekli olduğunda. ODBC Köprüsü programı aynı paketten yüklenir `clickhouse-server`. + +Bu motor destekler [Nullable](../../../sql-reference/data-types/nullable.md) veri türü. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1], + name2 [type2], + ... +) +ENGINE = ODBC(connection_settings, external_database, external_table) +``` + +Ayrıntılı bir açıklamasını görmek [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) sorgu. + +Tablo yapısı kaynak tablo yapısından farklı olabilir: + +- Sütun adları kaynak tablodaki ile aynı olmalıdır, ancak yalnızca bu sütunlardan bazılarını ve herhangi bir sırada kullanabilirsiniz. +- Sütun türleri kaynak tablodakilerden farklı olabilir. ClickHouse çalışır [döküm](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) ClickHouse veri türleri için değerler. + +**Motor Parametreleri** + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` Dosya. +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +## Kullanım Örneği {#usage-example} + +**ODBC üzerinden yerel MySQL kurulumundan veri alma** + +Bu örnek Ubuntu Linux 18.04 ve MySQL server 5.7 için kontrol edilir. + +UnixODBC ve MySQL Connector yüklü olduğundan emin olun. + +Varsayılan olarak (paketlerden yüklüyse), ClickHouse kullanıcı olarak başlar `clickhouse`. Bu nedenle, bu kullanıcıyı MySQL sunucusunda oluşturmanız ve yapılandırmanız gerekir. + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +Sonra bağlantıyı yapılandırın `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +Kullanarak bağlantıyı kontrol edebilirsiniz `isql` unixodbc yüklemesinden yardımcı program. + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +MySQL tablo: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +Clickhouse'daki tablo, MySQL tablosundan veri alma: + +``` sql +CREATE TABLE odbc_t +( + `int_id` Int32, + `float_nullable` Nullable(Float32) +) +ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') +``` + +``` sql +SELECT * FROM odbc_t +``` + +``` text +┌─int_id─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ +└────────┴────────────────┘ +``` + +## Ayrıca Bakınız {#see-also} + +- [ODBC harici sözlükler](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [ODBC tablo işlevi](../../../sql-reference/table-functions/odbc.md) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/tr/engines/table-engines/log-family/index.md b/docs/tr/engines/table-engines/log-family/index.md new file mode 100644 index 00000000000..39bc7c21f51 --- /dev/null +++ b/docs/tr/engines/table-engines/log-family/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "G\xFCnl\xFCk Aile" +toc_priority: 29 +--- + + diff --git a/docs/tr/engines/table-engines/log-family/log-family.md b/docs/tr/engines/table-engines/log-family/log-family.md new file mode 100644 index 00000000000..074f9363e9f --- /dev/null +++ b/docs/tr/engines/table-engines/log-family/log-family.md @@ -0,0 +1,46 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "Giri\u015F" +--- + +# Log Engine Ailesi {#log-engine-family} + +Bu motorlar, birçok küçük tabloyu (yaklaşık 1 milyon satıra kadar) hızlı bir şekilde yazmanız ve daha sonra bir bütün olarak okumanız gerektiğinde senaryolar için geliştirilmiştir. + +Ailenin motorları: + +- [StripeLog](stripelog.md) +- [Günlük](log.md) +- [TinyLog](tinylog.md) + +## Ortak Özellikler {#common-properties} + +Motorlar: + +- Verileri bir diskte saklayın. + +- Yazarken dosyanın sonuna veri ekleyin. + +- Eşzamanlı veri erişimi için destek kilitleri. + + Sırasında `INSERT` sorgular, tablo kilitlenir ve veri okumak ve yazmak için diğer sorgular hem tablonun kilidini açmak için bekler. Veri yazma sorguları varsa, herhangi bir sayıda veri okuma sorguları aynı anda gerçekleştirilebilir. + +- Destek yok [mutasyon](../../../sql-reference/statements/alter.md#alter-mutations) harekat. + +- Dizinleri desteklemez. + + Bu demektir ki `SELECT` veri aralıkları için sorgular verimli değildir. + +- Atomik veri yazmayın. + + Bir şey yazma işlemini bozarsa, örneğin anormal sunucu kapatma gibi bozuk verilerle bir tablo alabilirsiniz. + +## Farklılıklar {#differences} + +Bu `TinyLog` motor, ailenin en basitidir ve en fakir işlevselliği ve en düşük verimliliği sağlar. Bu `TinyLog` motor, birkaç iş parçacığı tarafından paralel veri okumayı desteklemez. Paralel okumayı destekleyen ailedeki diğer motorlardan daha yavaş veri okur ve neredeyse birçok tanımlayıcı kullanır `Log` motor, her sütunu ayrı bir dosyada sakladığı için. Basit düşük yük senaryolarında kullanın. + +Bu `Log` ve `StripeLog` motorlar paralel veri okumayı destekler. Veri okurken, ClickHouse birden çok iş parçacığı kullanır. Her iş parçacığı ayrı bir veri bloğu işler. Bu `Log` engine, tablonun her sütunu için ayrı bir dosya kullanır. `StripeLog` tüm verileri tek bir dosyada saklar. Sonuç olarak, `StripeLog` motor işletim sisteminde daha az tanımlayıcı kullanır, ancak `Log` motor veri okurken daha yüksek verimlilik sağlar. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/tr/engines/table-engines/log-family/log.md b/docs/tr/engines/table-engines/log-family/log.md new file mode 100644 index 00000000000..cdebf76515e --- /dev/null +++ b/docs/tr/engines/table-engines/log-family/log.md @@ -0,0 +1,16 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: "G\xFCnl\xFCk" +--- + +# Günlük {#log} + +Motor günlük motorları ailesine aittir. Günlük motorlarının ortak özelliklerini ve farklılıklarını görün [Log Engine Ailesi](log-family.md) Makale. + +Log differsar differsit fromma [TinyLog](tinylog.md) bu küçük bir dosyada “marks” sütun dosyaları ile bulunur. Bu işaretler her veri bloğuna yazılır ve belirtilen satır sayısını atlamak için dosyayı okumaya nereden başlayacağınızı gösteren uzaklıklar içerir. Bu, tablo verilerini birden çok iş parçacığında okumayı mümkün kılar. +Eşzamanlı veri erişimi için, okuma işlemleri aynı anda gerçekleştirilebilirken, yazma işlemleri okur ve birbirlerini engeller. +Günlük altyapısı dizinleri desteklemez. Benzer şekilde, bir tabloya yazma başarısız olursa, tablo bozulur ve Okuma bir hata döndürür. Günlük altyapısı, geçici veriler, bir kez yazma tabloları ve sınama veya gösteri amaçları için uygundur. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/tr/engines/table-engines/log-family/stripelog.md b/docs/tr/engines/table-engines/log-family/stripelog.md new file mode 100644 index 00000000000..038c6c28569 --- /dev/null +++ b/docs/tr/engines/table-engines/log-family/stripelog.md @@ -0,0 +1,95 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: StripeLog +--- + +# Stripelog {#stripelog} + +Bu motor günlük motor ailesine aittir. Günlük motorlarının ortak özelliklerini ve farklılıklarını görün [Log Engine Ailesi](log-family.md) Makale. + +Az miktarda veri içeren (1 milyondan az satır) birçok tablo yazmanız gerektiğinde, bu altyapıyı senaryolarda kullanın. + +## Tablo oluşturma {#table_engines-stripelog-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = StripeLog +``` + +Ayrıntılı açıklamasına bakın [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) sorgu. + +## Veri yazma {#table_engines-stripelog-writing-the-data} + +Bu `StripeLog` motor tüm sütunları tek bir dosyada saklar. Her biri için `INSERT` sorgu, ClickHouse veri bloğunu bir tablo dosyasının sonuna ekler, sütunları tek tek yazar. + +Her tablo için ClickHouse dosyaları yazar: + +- `data.bin` — Data file. +- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. + +Bu `StripeLog` motor desteklemiyor `ALTER UPDATE` ve `ALTER DELETE` harekat. + +## Verileri okuma {#table_engines-stripelog-reading-the-data} + +İşaretli dosya, Clickhouse'un verilerin okunmasını paralelleştirmesine izin verir. Bu demektir `SELECT` sorgu satırları öngörülemeyen bir sırayla döndürür. Kullan... `ORDER BY` satırları sıralamak için yan tümce. + +## Kullanım örneği {#table_engines-stripelog-example-of-use} + +Tablo oluşturma: + +``` sql +CREATE TABLE stripe_log_table +( + timestamp DateTime, + message_type String, + message String +) +ENGINE = StripeLog +``` + +Veri ekleme: + +``` sql +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') +INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') +``` + +İki kullandık `INSERT` içinde iki veri bloğu oluşturmak için sorgular `data.bin` Dosya. + +ClickHouse veri seçerken birden çok iş parçacığı kullanır. Her iş parçacığı ayrı bir veri bloğu okur ve sonuç olarak satırları bağımsız olarak döndürür. Sonuç olarak, çıktıdaki satır bloklarının sırası, çoğu durumda girişteki aynı blokların sırasına uymuyor. Mesela: + +``` sql +SELECT * FROM stripe_log_table +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +┌───────────timestamp─┬─message_type─┬─message───────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +└─────────────────────┴──────────────┴───────────────────────────┘ +``` + +Sonuçları sıralama (varsayılan olarak artan sipariş): + +``` sql +SELECT * FROM stripe_log_table ORDER BY timestamp +``` + +``` text +┌───────────timestamp─┬─message_type─┬─message────────────────────┐ +│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ +│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ +│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ +└─────────────────────┴──────────────┴────────────────────────────┘ +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/tr/engines/table-engines/log-family/tinylog.md b/docs/tr/engines/table-engines/log-family/tinylog.md new file mode 100644 index 00000000000..6975e6e127c --- /dev/null +++ b/docs/tr/engines/table-engines/log-family/tinylog.md @@ -0,0 +1,16 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: TinyLog +--- + +# TinyLog {#tinylog} + +Motor log engine ailesine aittir. Görmek [Log Engine Ailesi](log-family.md) günlük motorlarının ortak özellikleri ve farklılıkları için. + +Bu tablo motoru genellikle write-once yöntemi ile kullanılır: verileri bir kez yazın, ardından gerektiği kadar okuyun. Örneğin, kullanabilirsiniz `TinyLog`- küçük gruplar halinde işlenen Ara veriler için tablolar yazın. Çok sayıda küçük tabloda veri depolamanın verimsiz olduğunu unutmayın. + +Sorgular tek bir akışta yürütülür. Başka bir deyişle, bu motor nispeten küçük tablolar için tasarlanmıştır (yaklaşık 1.000.000 satıra kadar). Çok sayıda küçük tablonuz varsa, bu tablo motorunu kullanmak mantıklıdır, çünkü [Günlük](log.md) motor (daha az dosya açılması gerekir). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/tr/engines/table-engines/mergetree-family/aggregatingmergetree.md b/docs/tr/engines/table-engines/mergetree-family/aggregatingmergetree.md new file mode 100644 index 00000000000..f2e94f7f707 --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/aggregatingmergetree.md @@ -0,0 +1,105 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: AggregatingMergeTree +--- + +# Aggregatingmergetree {#aggregatingmergetree} + +Motor devralır [MergeTree](mergetree.md#table_engines-mergetree), veri parçaları birleştirme mantığı değiştirme. ClickHouse, tüm satırları aynı birincil anahtarla değiştirir (veya daha doğru olarak, aynı [sıralama anahtarı](mergetree.md)) tek bir satırla (bir veri parçası içinde), toplama işlevlerinin durumlarının bir kombinasyonunu saklar. + +Kullanabilirsiniz `AggregatingMergeTree` artımlı veri toplama, toplanan materialized görünümleri de dahil olmak üzere tablolar. + +Motor, tüm sütunları aşağıdaki türlerle işler: + +- [AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) +- [SimpleAggregateFunction](../../../sql-reference/data-types/simpleaggregatefunction.md) + +Kullanmak uygundur `AggregatingMergeTree` siparişlere göre satır sayısını azaltırsa. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = AggregatingMergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[TTL expr] +[SETTINGS name=value, ...] +``` + +İstek parametrelerinin açıklaması için bkz. [istek açıklaması](../../../sql-reference/statements/create.md). + +**Sorgu yan tümceleri** + +Oluştururken bir `AggregatingMergeTree` tablo aynı [yanlar](mergetree.md) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +Tüm parametreler, aşağıdaki gibi aynı anlama sahiptir `MergeTree`. +
+ +## Seç ve Ekle {#select-and-insert} + +Veri eklemek için şunları kullanın [INSERT SELECT](../../../sql-reference/statements/insert-into.md) agrega-Devlet-fonksiyonları ile sorgu. +Veri seçerken `AggregatingMergeTree` tablo kullanın `GROUP BY` yan tümce ve veri eklerken aynı toplama işlevleri, ancak kullanarak `-Merge` sonek. + +Sonuç inlarında `SELECT` sorgu, değerleri `AggregateFunction` türü, Tüm ClickHouse çıktı biçimleri için uygulamaya özgü ikili gösterime sahiptir. Örneğin, veri dökümü, `TabSeparated` ile format `SELECT` sorgu daha sonra bu dökümü kullanarak geri yüklenebilir `INSERT` sorgu. + +## Toplu bir Somutlaştırılmış Görünüm örneği {#example-of-an-aggregated-materialized-view} + +`AggregatingMergeTree` saatler hayata görünüm `test.visits` Tablo: + +``` sql +CREATE MATERIALIZED VIEW test.basic +ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) +AS SELECT + CounterID, + StartDate, + sumState(Sign) AS Visits, + uniqState(UserID) AS Users +FROM test.visits +GROUP BY CounterID, StartDate; +``` + +Veri ekleme `test.visits` Tablo. + +``` sql +INSERT INTO test.visits ... +``` + +Veriler hem tablo hem de görünümde eklenir `test.basic` toplama işlemini gerçekleştir .ecektir. + +Toplanan verileri almak için, aşağıdaki gibi bir sorgu yürütmemiz gerekir `SELECT ... GROUP BY ...` görünüm fromden `test.basic`: + +``` sql +SELECT + StartDate, + sumMerge(Visits) AS Visits, + uniqMerge(Users) AS Users +FROM test.basic +GROUP BY StartDate +ORDER BY StartDate; +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/tr/engines/table-engines/mergetree-family/collapsingmergetree.md b/docs/tr/engines/table-engines/mergetree-family/collapsingmergetree.md new file mode 100644 index 00000000000..a1d5d6738ef --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/collapsingmergetree.md @@ -0,0 +1,306 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: CollapsingMergeTree +--- + +# CollapsingMergeTree {#table_engine-collapsingmergetree} + +Motor devralır [MergeTree](mergetree.md) ve veri parçaları birleştirme algoritmasına çöken satırların mantığını ekler. + +`CollapsingMergeTree` sıralama anahtarındaki tüm alanlar zaman uyumsuz olarak siler (daraltır) satır çiftleri (`ORDER BY`) belirli alan hariç eşdeğerdir `Sign` hangi olabilir `1` ve `-1` değerler. Çift olmayan satırlar tutulur. Daha fazla bilgi için bkz: [Çökme](#table_engine-collapsingmergetree-collapsing) belgenin bölümü. + +Motor depolama hacmini önemli ölçüde azaltabilir ve `SELECT` sonuç olarak sorgu. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = CollapsingMergeTree(sign) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Sorgu parametrelerinin açıklaması için bkz. [sorgu açıklaması](../../../sql-reference/statements/create.md). + +**CollapsingMergeTree Parametreleri** + +- `sign` — Name of the column with the type of row: `1` is a “state” satır, `-1` is a “cancel” satır. + + Column data type — `Int8`. + +**Sorgu yan tümceleri** + +Oluştururken bir `CollapsingMergeTree` tablo, aynı [sorgu yan tümceleri](mergetree.md#table_engine-mergetree-creating-a-table) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) +``` + +Hariç tüm parametreler `sign` içinde olduğu gibi aynı anlama sahip `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` — “state” satır, `-1` — “cancel” satır. + + Column Data Type — `Int8`. + +
+ +## Çökme {#table_engine-collapsingmergetree-collapsing} + +### Veriler {#data} + +Bazı nesneler için sürekli değişen verileri kaydetmeniz gereken durumu düşünün. Bir nesne için bir satıra sahip olmak ve herhangi bir değişiklikte güncellemek mantıklı geliyor, ancak güncelleme işlemi dbms için pahalı ve yavaş çünkü depolama alanındaki verilerin yeniden yazılmasını gerektiriyor. Verileri hızlı bir şekilde yazmanız gerekiyorsa, güncelleme kabul edilemez, ancak bir nesnenin değişikliklerini sırayla aşağıdaki gibi yazabilirsiniz. + +Belirli sütunu kullanın `Sign`. Eğer `Sign = 1` bu, satırın bir nesnenin durumu olduğu anlamına gelir, diyelim ki “state” satır. Eğer `Sign = -1` aynı özelliklere sahip bir nesnenin durumunun iptali anlamına gelir, diyelim ki “cancel” satır. + +Örneğin, kullanıcıların bazı sitelerde ne kadar sayfa kontrol ettiğini ve ne kadar süre orada olduklarını hesaplamak istiyoruz. Bir anda kullanıcı etkinliği durumu ile aşağıdaki satırı yazıyoruz: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Bir an sonra kullanıcı aktivitesinin değişikliğini kaydedip aşağıdaki iki satırla yazıyoruz. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +İlk satır, nesnenin (kullanıcı) önceki durumunu iptal eder. İptal edilen durumun sıralama anahtar alanlarını kopyalamalıdır `Sign`. + +İkinci satır geçerli durumu içerir. + +Sadece kullanıcı etkinliğinin son durumuna ihtiyacımız olduğu için, satırlar + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +bir nesnenin geçersiz (eski) durumunu daraltarak silinebilir. `CollapsingMergeTree` veri parçalarının birleştirilmesi sırasında bunu yapar. + +Neden her değişiklik için 2 satıra ihtiyacımız var [Algoritma](#table_engine-collapsingmergetree-collapsing-algorithm) paragraf. + +**Bu yaklaşımın kendine özgü özellikleri** + +1. Verileri yazan program, iptal edebilmek için bir nesnenin durumunu hatırlamalıdır. “Cancel” dize, sıralama anahtar alanlarının kopyalarını içermelidir. “state” dize ve tersi `Sign`. Bu depolama başlangıç boyutunu artırır ama hızlı bir şekilde veri yazmak için izin verir. +2. Sütunlardaki uzun büyüyen diziler, yazma yükü nedeniyle motorun verimliliğini azaltır. Daha basit veriler, verimlilik o kadar yüksek olur. +3. Bu `SELECT` sonuçlara itiraz değişiklikler tarihin tutarlılık bağlıdır. Ekleme için veri hazırlarken doğru olun. Tutarsız verilerde öngörülemeyen sonuçlar elde edebilirsiniz, örneğin, oturum derinliği gibi negatif olmayan metrikler için negatif değerler. + +### Algoritma {#table_engine-collapsingmergetree-collapsing-algorithm} + +ClickHouse veri parçalarını birleştirdiğinde, her ardışık satır grubu aynı sıralama anahtarıyla (`ORDER BY`) en fazla iki satır reduceda indir isgen ,ir, biri `Sign = 1` (“state” satır) ve başka bir `Sign = -1` (“cancel” satır). Başka bir deyişle, girişler çöker. + +Elde edilen her veri parçası için ClickHouse kaydeder: + +1. Birincilik “cancel” ve son “state” satır sayısı ise “state” ve “cancel” satırlar eşleşir ve son satır bir “state” satır. +2. Son “state” satır, daha varsa “state” satırlar daha “cancel” satırlar. +3. Birincilik “cancel” satır, daha varsa “cancel” satırlar daha “state” satırlar. +4. Diğer tüm durumlarda satırların hiçbiri. + +Ayrıca en az 2 tane daha olduğunda “state” satırlar daha “cancel” satırlar veya en az 2 tane daha “cancel” r rowsows th thenen “state” satırlar, birleştirme devam eder, ancak ClickHouse bu durumu mantıksal bir hata olarak değerlendirir ve sunucu günlüğüne kaydeder. Aynı veriler birden çok kez eklendiğinde, bu hata oluşabilir. + +Bu nedenle, çöken istatistik hesaplama sonuçlarını değiştirmemelidir. +Değişiklikler yavaş yavaş çöktü, böylece sonunda hemen hemen her nesnenin sadece son durumu kaldı. + +Bu `Sign` birleştirme algoritması, aynı sıralama anahtarına sahip tüm satırların aynı sonuçtaki veri bölümünde ve hatta aynı fiziksel sunucuda olacağını garanti etmediğinden gereklidir. ClickHouse süreci `SELECT` birden çok iş parçacığına sahip sorgular ve sonuçtaki satırların sırasını tahmin edemez. Tamamen almak için bir ihtiyaç varsa toplama gereklidir “collapsed” veri `CollapsingMergeTree` Tablo. + +Daraltmayı sonuçlandırmak için bir sorgu yazın `GROUP BY` yan tümce ve işareti için hesap toplama işlevleri. Örneğin, miktarı hesaplamak için kullanın `sum(Sign)` yerine `count()`. Bir şeyin toplamını hesaplamak için şunları kullanın `sum(Sign * x)` yerine `sum(x)`, ve böylece, ve ayrıca ekleyin `HAVING sum(Sign) > 0`. + +Toplanan `count`, `sum` ve `avg` bu şekilde hesaplanmış olabilir. Toplanan `uniq` bir nesnenin en az bir durumu çökmüş değilse hesaplanabilir. Toplanan `min` ve `max` hesaplan becauseamadı çünkü `CollapsingMergeTree` daraltılmış durumların değerleri geçmişini kaydetmez. + +Toplama olmadan veri ayıklamanız gerekiyorsa (örneğin, en yeni değerleri belirli koşullarla eşleşen satırların mevcut olup olmadığını kontrol etmek için) `FINAL` değiştirici için `FROM` yan. Bu yaklaşım önemli ölçüde daha az etkilidir. + +## Kullanım örneği {#example-of-use} + +Örnek veriler: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Tablonun oluşturulması: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Veri ekleme: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) +``` + +Biz iki kullanın `INSERT` iki farklı veri parçası oluşturmak için sorgular. Verileri bir sorgu ile eklersek ClickHouse bir veri parçası oluşturur ve hiç bir birleştirme gerçekleştirmez. + +Veri alma: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Ne görüyoruz ve nerede çöküyor? + +İki ile `INSERT` sorgular, 2 Veri parçası oluşturduk. Bu `SELECT` sorgu 2 iş parçacığında yapıldı ve rastgele bir satır sırası aldık. Veri parçalarının henüz birleştirilmediği için çökme gerçekleşmedi. ClickHouse biz tahmin edemez bilinmeyen bir anda veri kısmını birleştirir. + +Böylece toplama ihtiyacımız var: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration +FROM UAct +GROUP BY UserID +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +Toplamaya ihtiyacımız yoksa ve çökmeyi zorlamak istiyorsak, şunları kullanabiliriz `FINAL` değiştirici için `FROM` yan. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Verileri seçmenin bu yolu çok verimsizdir. Büyük masalar için kullanmayın. + +## Başka bir yaklaşım örneği {#example-of-another-approach} + +Örnek veriler: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ +│ 4324182021466249494 │ -5 │ -146 │ -1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +Fikir, birleştirmelerin yalnızca anahtar alanları hesaba katmasıdır. Ve içinde “Cancel” satır işareti sütununu kullanmadan toplanırken satırın önceki sürümünü eşitleyen negatif değerleri belirtebiliriz. Bu yaklaşım için veri türünü değiştirmek gerekir `PageViews`,`Duration` uint8 -\> Int16 negatif değerlerini saklamak için. + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews Int16, + Duration Int16, + Sign Int8 +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID +``` + +Yaklaşımı test edelim: + +``` sql +insert into UAct values(4324182021466249494, 5, 146, 1); +insert into UAct values(4324182021466249494, -5, -146, -1); +insert into UAct values(4324182021466249494, 6, 185, 1); + +select * from UAct final; // avoid using final in production (just for a test or small tables) +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +``` sql +SELECT + UserID, + sum(PageViews) AS PageViews, + sum(Duration) AS Duration +FROM UAct +GROUP BY UserID +```text +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +``` sqk +select count() FROM UAct +``` + +``` text +┌─count()─┐ +│ 3 │ +└─────────┘ +``` + +``` sql +optimize table UAct final; + +select * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┘ +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/tr/engines/table-engines/mergetree-family/custom-partitioning-key.md b/docs/tr/engines/table-engines/mergetree-family/custom-partitioning-key.md new file mode 100644 index 00000000000..9dba2ac627e --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/custom-partitioning-key.md @@ -0,0 +1,127 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 32 +toc_title: "\xD6zel B\xF6l\xFCmleme Anahtar\u0131" +--- + +# Özel Bölümleme Anahtarı {#custom-partitioning-key} + +Bölümleme için kullanılabilir [MergeTree](mergetree.md) aile tabloları (dahil [çoğaltıyordu](replication.md) Tablolar). [Hayata görünümler](../special/materializedview.md#materializedview) MergeTree tablolarına dayanarak bölümlemeyi de destekler. + +Bir bölüm, bir tablodaki kayıtların belirtilen bir kritere göre mantıksal bir birleşimidir. Bir bölümü, ay, gün veya olay türü gibi rasgele bir ölçütle ayarlayabilirsiniz. Bu verilerin manipülasyonlarını basitleştirmek için her bölüm ayrı ayrı saklanır. Verilere erişirken, ClickHouse mümkün olan en küçük bölüm alt kümesini kullanır. + +Bölüm belirtilen `PARTITION BY expr` fık whenra ne zaman [tablo oluşturma](mergetree.md#table_engine-mergetree-creating-a-table). Bölüm anahtarı tablo sütunlarından herhangi bir ifade olabilir. Örneğin, aya göre bölümleme belirtmek için ifadeyi kullanın `toYYYYMM(date_column)`: + +``` sql +CREATE TABLE visits +( + VisitDate Date, + Hour UInt8, + ClientID UUID +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(VisitDate) +ORDER BY Hour; +``` + +Bölüm anahtarı ayrıca bir ifade kümesi olabilir ( [birincil anahtar](mergetree.md#primary-keys-and-indexes-in-queries)). Mesela: + +``` sql +ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) +PARTITION BY (toMonday(StartDate), EventType) +ORDER BY (CounterID, StartDate, intHash32(UserID)); +``` + +Bu örnekte, bölümlemeyi geçerli hafta boyunca meydana gelen olay türlerine göre ayarladık. + +Bir tabloya yeni veri eklerken, bu veriler birincil anahtara göre sıralanmış ayrı bir parça (yığın) olarak depolanır. Taktıktan 10-15 dakika sonra, aynı bölümün parçaları tüm parçaya birleştirilir. + +!!! info "Bilgin" + Birleştirme yalnızca bölümleme ifadesi için aynı değere sahip veri parçaları için çalışır. Bu demektir **aşırı granüler bölümler yapmamalısınız** (yaklaşık binden fazla bölüm). Aksi takdirde, `SELECT` sorgu, dosya sistemindeki ve açık dosya tanımlayıcılarındaki makul olmayan sayıda dosya nedeniyle yetersiz performans gösterir. + +Kullan... [sistem.parçalar](../../../operations/system-tables.md#system_tables-parts) tablo tablo parçaları ve bölümleri görüntülemek için. Örneğin, bir var varsayalım `visits` aya göre bölümleme ile tablo. Hadi gerçekleştirelim `SELECT` sorgu için `system.parts` Tablo: + +``` sql +SELECT + partition, + name, + active +FROM system.parts +WHERE table = 'visits' +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 1 │ +│ 201902 │ 201902_11_11_0 │ 1 │ +└───────────┴────────────────┴────────┘ +``` + +Bu `partition` sütun bölümlerin adlarını içerir. Bu örnekte iki bölüm vardır: `201901` ve `201902`. Bölüm adını belirtmek için bu sütun değerini kullanabilirsiniz [ALTER … PARTITION](#alter_manipulations-with-partitions) sorgular. + +Bu `name` sütun, bölüm veri parçalarının adlarını içerir. Bölümün adını belirtmek için bu sütunu kullanabilirsiniz. [ALTER ATTACH PART](#alter_attach-partition) sorgu. + +İlk bölümün adını kıralım: `201901_1_3_1`: + +- `201901` bölüm adıdır. +- `1` en az veri bloğu sayısıdır. +- `3` veri bloğunun maksimum sayısıdır. +- `1` yığın düzeyidir (oluşturduğu birleştirme ağacının derinliği). + +!!! info "Bilgin" + Eski tip tabloların parçaları adı vardır: `20190117_20190123_2_2_0` (minimum tarih - maksimum tarih - minimum blok numarası - maksimum blok numarası - seviye). + +Bu `active` sütun, parçanın durumunu gösterir. `1` aktif istir; `0` etkin değil. Etkin olmayan parçalar, örneğin, daha büyük bir parçaya birleştirildikten sonra kalan kaynak parçalarıdır. Bozuk veri parçaları da etkin olarak gösterilir. + +Örnekte gördüğünüz gibi, aynı bölümün birkaç ayrı parçası vardır (örneğin, `201901_1_3_1` ve `201901_1_9_2`). Bu, bu parçaların henüz birleştirilmediği anlamına gelir. ClickHouse, eklendikten yaklaşık 15 dakika sonra eklenen veri parçalarını periyodik olarak birleştirir. Buna ek olarak, kullanarak zamanlanmış olmayan birleştirme gerçekleştirebilirsiniz [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) sorgu. Örnek: + +``` sql +OPTIMIZE TABLE visits PARTITION 201902; +``` + +``` text +┌─partition─┬─name───────────┬─active─┐ +│ 201901 │ 201901_1_3_1 │ 0 │ +│ 201901 │ 201901_1_9_2 │ 1 │ +│ 201901 │ 201901_8_8_0 │ 0 │ +│ 201901 │ 201901_9_9_0 │ 0 │ +│ 201902 │ 201902_4_6_1 │ 0 │ +│ 201902 │ 201902_4_11_2 │ 1 │ +│ 201902 │ 201902_10_10_0 │ 0 │ +│ 201902 │ 201902_11_11_0 │ 0 │ +└───────────┴────────────────┴────────┘ +``` + +Etkin olmayan parçalar birleştirildikten yaklaşık 10 dakika sonra silinecektir. + +Bir parça ve bölüm kümesini görüntülemenin başka bir yolu da tablonun dizinine gitmektir: `/var/lib/clickhouse/data///`. Mesela: + +``` bash +/var/lib/clickhouse/data/default/visits$ ls -l +total 40 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 +drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached +``` + +Klasör ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ ve böylece parçaların dizinleri vardır. Her bölüm karşılık gelen bir bölümle ilgilidir ve yalnızca belirli bir ay için veri içerir (Bu örnekteki tabloda aylara göre bölümleme vardır). + +Bu `detached` dizin kullanarak tablodan ayrılmış parçaları içerir [DETACH](../../../sql-reference/statements/alter.md#alter_detach-partition) sorgu. Bozuk parçalar da silinmek yerine bu dizine taşınır. Sunucu parçaları kullanmaz `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql-reference/statements/alter.md#alter_attach-partition) sorgu. + +İşletim sunucusunda, sunucu bunu bilmediğinden, dosya sistemindeki parça kümesini veya verilerini el ile değiştiremeyeceğinizi unutmayın. Çoğaltılmamış tablolar için, sunucu durdurulduğunda bunu yapabilirsiniz, ancak önerilmez. Çoğaltılmış tablolar için, parça kümesi her durumda değiştirilemez. + +ClickHouse, bölümlerle işlemleri gerçekleştirmenize izin verir: bunları silin, bir tablodan diğerine kopyalayın veya bir yedek oluşturun. Bölümdeki tüm işlemlerin listesine bakın [Bölümler ve parçalar ile manipülasyonlar](../../../sql-reference/statements/alter.md#alter_manipulations-with-partitions). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/tr/engines/table-engines/mergetree-family/graphitemergetree.md b/docs/tr/engines/table-engines/mergetree-family/graphitemergetree.md new file mode 100644 index 00000000000..3fa7ed529af --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/graphitemergetree.md @@ -0,0 +1,174 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "Graph\u0131temergetree" +--- + +# Graphıtemergetree {#graphitemergetree} + +Bu motor inceltme ve toplama/ortalama (toplaması) için tasarlanmıştır) [Grafit](http://graphite.readthedocs.io/en/latest/index.html) veriler. Clickhouse'u Grafit için bir veri deposu olarak kullanmak isteyen geliştiriciler için yararlı olabilir. + +Toplamaya ihtiyacınız yoksa Grafit verilerini depolamak için herhangi bir ClickHouse tablo motorunu kullanabilirsiniz, ancak bir toplamaya ihtiyacınız varsa `GraphiteMergeTree`. Motor, depolama hacmini azaltır ve grafitten gelen sorguların verimliliğini arttırır. + +Motor özellikleri devralır [MergeTree](mergetree.md). + +## Tablo oluşturma {#creating-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE = GraphiteMergeTree(config_section) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Ayrıntılı bir açıklamasını görmek [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) sorgu. + +Grafit verileri için bir tablo aşağıdaki veriler için aşağıdaki sütunlara sahip olmalıdır: + +- Metrik adı (Grafit sensörü). Veri türü: `String`. + +- Metrik ölçme zamanı. Veri türü: `DateTime`. + +- Metrik değeri. Veri türü: herhangi bir sayısal. + +- Metrik sürümü. Veri türü: herhangi bir sayısal. + + ClickHouse en yüksek sürümü veya sürümleri aynı ise son yazılan satırları kaydeder. Veri parçalarının birleştirilmesi sırasında diğer satırlar silinir. + +Bu sütunların adları toplaması yapılandırmasında ayarlanmalıdır. + +**Graphıtemergetree parametreleri** + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +**Sorgu yan tümceleri** + +Oluştururken bir `GraphiteMergeTree` tablo, aynı [yanlar](mergetree.md#table_engine-mergetree-creating-a-table) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + EventDate Date, + Path String, + Time DateTime, + Value , + Version + ... +) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) +``` + +Hariç tüm parametreler `config_section` içinde olduğu gibi aynı anlama sahip `MergeTree`. + +- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. + +
+ +## Toplaması Yapılandırması {#rollup-configuration} + +Toplaması için ayarları tarafından tanımlanan [graphite\_rollup](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-graphite) sunucu yapılandırmasında parametre. Parametrenin adı herhangi biri olabilir. Birkaç yapılandırma oluşturabilir ve bunları farklı tablolar için kullanabilirsiniz. + +Toplaması yapılandırma yapısı: + + required-columns + patterns + +### Gerekli Sütunlar {#required-columns} + +- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. +- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. +- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Varsayılan değer: `Value`. +- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. + +### Desenler {#patterns} + +Bu yapı `patterns` bölme: + +``` text +pattern + regexp + function +pattern + regexp + age + precision + ... +pattern + regexp + function + age + precision + ... +pattern + ... +default + function + age + precision + ... +``` + +!!! warning "Dikkat" + Desenler kesinlikle sipariş edilmelidir: + + 1. Patterns without `function` or `retention`. + 1. Patterns with both `function` and `retention`. + 1. Pattern `default`. + +Bir satır işlerken, ClickHouse kuralları denetler `pattern` bölmeler. Tüm `pattern` (içeren `default`) bölümler içerebilir `function` toplama için parametre, `retention` parametreler veya her ikisi. Metrik adı eşleşirse `regexp` gelen kuralları `pattern` bölüm (veya bölümler) uygulanır; aksi takdirde, kurallar `default` bölüm kullanılır. + +Alanlar için `pattern` ve `default` bölmeler: + +- `regexp`– A pattern for the metric name. +- `age` – The minimum age of the data in seconds. +- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). +- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. + +### Yapılandırma Örneği {#configuration-example} + +``` xml + + Version + + click_cost + any + + 0 + 5 + + + 86400 + 60 + + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/tr/engines/table-engines/mergetree-family/index.md b/docs/tr/engines/table-engines/mergetree-family/index.md new file mode 100644 index 00000000000..912eecc10f7 --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: MergeTree Ailesi +toc_priority: 28 +--- + + diff --git a/docs/tr/engines/table-engines/mergetree-family/mergetree.md b/docs/tr/engines/table-engines/mergetree-family/mergetree.md new file mode 100644 index 00000000000..4065b5fdcbd --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/mergetree.md @@ -0,0 +1,654 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 30 +toc_title: MergeTree +--- + +# MergeTree {#table_engines-mergetree} + +Bu `MergeTree` bu ailenin motoru ve diğer motorları (`*MergeTree`) en sağlam ClickHouse masa motorlarıdır. + +Motor inlarda `MergeTree` aile, bir tabloya çok büyük miktarda veri eklemek için tasarlanmıştır. Veriler hızlı bir şekilde tabloya kısmen yazılır, daha sonra parçaları arka planda birleştirmek için kurallar uygulanır. Bu yöntem, ınsert sırasında depolama alanındaki verileri sürekli olarak yeniden yazmaktan çok daha etkilidir. + +Ana özellikler: + +- Birincil anahtara göre sıralanmış verileri saklar. + + Bu, verileri daha hızlı bulmanıza yardımcı olan küçük bir seyrek dizin oluşturmanıza olanak sağlar. + +- Bölümler eğer kullanılabilir [bölümleme anahtarı](custom-partitioning-key.md) belirt .ilmektedir. + + ClickHouse, aynı sonuçla aynı veriler üzerindeki genel işlemlerden daha etkili olan bölümlerle belirli işlemleri destekler. ClickHouse, bölümleme anahtarının sorguda belirtildiği bölüm verilerini de otomatik olarak keser. Bu da sorgu performansını artırır. + +- Veri çoğaltma desteği. + + The family of `ReplicatedMergeTree` tablolar veri çoğaltma sağlar. Daha fazla bilgi için, bkz. [Veri çoğaltma](replication.md). + +- Veri örnekleme desteği. + + Gerekirse, tabloda veri örnekleme yöntemini ayarlayabilirsiniz. + +!!! info "Bilgin" + Bu [Birleştirmek](../special/merge.md#merge) motor ait değil `*MergeTree` aile. + +## Tablo oluşturma {#table_engine-mergetree-creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], + ... + INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, + INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 +) ENGINE = MergeTree() +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] +[SETTINGS name=value, ...] +``` + +Parametrelerin açıklaması için bkz. [Sorgu açıklaması oluştur](../../../sql-reference/statements/create.md). + +!!! note "Not" + `INDEX` deneysel bir özelliktir, bkz [Veri Atlama Dizinleri](#table_engine-mergetree-data_skipping-indexes). + +### Sorgu Yan Tümceleri {#mergetree-query-clauses} + +- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. Bu `MergeTree` motor parametreleri yok. + +- `PARTITION BY` — The [bölümleme anahtarı](custom-partitioning-key.md). + + Aylara göre bölümleme için `toYYYYMM(date_column)` ifade, nerede `date_column` türün tarihi olan bir sütun mu [Tarihli](../../../sql-reference/data-types/date.md). Burada bölüm isimleri var `"YYYYMM"` biçimli. + +- `ORDER BY` — The sorting key. + + Sütun veya keyfi ifadeler bir tuple. Örnek: `ORDER BY (CounterID, EventDate)`. + +- `PRIMARY KEY` — The primary key if it [sıralama anahtarından farklıdır](#choosing-a-primary-key-that-differs-from-the-sorting-key). + + Varsayılan olarak, birincil anahtar sıralama anahtarıyla aynıdır (bu anahtar tarafından belirtilir). `ORDER BY` yan). Bu nedenle çoğu durumda ayrı bir belirtmek gereksizdir `PRIMARY KEY` yan. + +- `SAMPLE BY` — An expression for sampling. + + Bir örnekleme ifadesi kullanılırsa, birincil anahtar onu içermelidir. Örnek: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. + +- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [diskler ve birimler arasında](#table_engine-mergetree-multiple-volumes). + + İfade bir olmalıdır `Date` veya `DateTime` sonuç olarak sütun. Örnek: + `TTL date + INTERVAL 1 DAY` + + Kuralın türü `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` ifade tatmin edildiyse (geçerli zamana ulaşırsa) parça ile yapılacak bir eylemi belirtir: süresi dolmuş satırların kaldırılması, bir parçanın (bir parçadaki tüm satırlar için ifade tatmin edildiyse) belirtilen diske taşınması (`TO DISK 'xxx'`) veya hacim (`TO VOLUME 'xxx'`). Kuralın varsayılan türü kaldırma (`DELETE`). Birden fazla kural listesi belirtilebilir, ancak birden fazla olmamalıdır `DELETE` kural. + + Daha fazla ayrıntı için bkz. [Sütunlar ve tablolar için TTL](#table_engine-mergetree-ttl) + +- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: + + - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Veri Depolama](#mergetree-data-storage). + - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Veri Depolama](#mergetree-data-storage). + - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` ayar. 19.11 sürümünden önce, sadece `index_granularity` granül boyutunu kısıtlamak için ayar. Bu `index_granularity_bytes` büyük satırlar (onlarca ve megabayt yüzlerce) ile tablolardan veri seçerken ayarı ClickHouse performansını artırır. Büyük satırlara sahip tablolarınız varsa, tabloların verimliliğini artırmak için bu ayarı etkinleştirebilirsiniz. `SELECT` sorgular. + - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, daha sonra ZooKeeper daha az veri depolar. Daha fazla bilgi için, bkz: [ayar açıklaması](../../../operations/server-configuration-parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) içinde “Server configuration parameters”. + - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` bayt, ClickHouse okur ve doğrudan I/O arabirimi kullanarak depolama diskine veri yazar (`O_DIRECT` seçenek). Eğer `min_merge_bytes_to_use_direct_io = 0`, sonra doğrudan g / Ç devre dışı bırakılır. Varsayılan değer: `10 * 1024 * 1024 * 1024` baytlar. + + - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). + - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don't turn it off. + - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. + - `storage_policy` — Storage policy. See [Veri depolama için birden fazla blok cihazı kullanma](#table_engine-mergetree-multiple-volumes). + +**Bölüm ayarı örneği** + +``` sql +ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 +``` + +Örnekte, aylara göre bölümleme ayarladık. + +Biz de kullanıcı kimliği ile karma olarak örnekleme için bir ifade ayarlayın. Bu, her biri için tablodaki verileri pseudorandomize etmenizi sağlar `CounterID` ve `EventDate`. Tanım yoularsanız bir [SAMPLE](../../../sql-reference/statements/select/sample.md#select-sample-clause) yan tümcesi verileri seçerken, ClickHouse kullanıcıların bir alt kümesi için eşit pseudorandom veri örneği döndürür. + +Bu `index_granularity` 8192 varsayılan değer olduğundan ayarı atlanabilir. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın. Mümkünse, eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) +``` + +**MergeTree () Parametreleri** + +- `date-column` — The name of a column of the [Tarihli](../../../sql-reference/data-types/date.md) tür. ClickHouse otomatik olarak bu sütuna göre ay bölümleri oluşturur. Bölüm adları `"YYYYMM"` biçimli. +- `sampling_expression` — An expression for sampling. +- `(primary, key)` — Primary key. Type: [Demet()](../../../sql-reference/data-types/tuple.md) +- `index_granularity` — The granularity of an index. The number of data rows between the “marks” bir dizinin. 8192 değeri çoğu görev için uygundur. + +**Örnek** + +``` sql +MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) +``` + +Bu `MergeTree` motor, Ana motor yapılandırma yöntemi için yukarıdaki örnekte olduğu gibi yapılandırılır. +
+ +## Veri Depolama {#mergetree-data-storage} + +Bir tabloda birincil anahtar tarafından sıralanmış verileri bölümden oluşmaktadır. + +Veri bir tabloya eklendiğinde, ayrı veri parçaları oluşturulur ve bunların her biri birincil anahtara göre lexicographically sıralanır. Örneğin, birincil anahtar `(CounterID, Date)`, parçadaki veriler şu şekilde sıralanır `CounterID` ve içinde her `CounterID` tarafından sipariş edilir `Date`. + +Farklı bölümlere ait veriler farklı parçalara ayrılır. Arka planda, ClickHouse daha verimli depolama için veri parçalarını birleştirir. Farklı bölümlere ait parçalar birleştirilmez. Birleştirme mekanizması, aynı birincil anahtara sahip tüm satırların aynı veri bölümünde olacağını garanti etmez. + +Her veri parçası mantıksal olarak granüllere ayrılmıştır. Bir granül, Clickhouse'un veri seçerken okuduğu en küçük bölünmez veri kümesidir. ClickHouse satırları veya değerleri bölmez, bu nedenle her granül her zaman bir tamsayı satır içerir. Bir granülün ilk satırı, satır için birincil anahtarın değeri ile işaretlenir. Her veri bölümü için ClickHouse işaretleri depolayan bir dizin dosyası oluşturur. Her sütun için, birincil anahtarda olsun ya da olmasın, ClickHouse aynı işaretleri de saklar. Bu işaretler, verileri doğrudan sütun dosyalarında bulmanızı sağlar. + +Granül boyutu ile sınırlıdır `index_granularity` ve `index_granularity_bytes` tablo motorunun ayarları. Bir granüldeki satır sayısı `[1, index_granularity]` Aralık, satırların boyutuna bağlı olarak. Bir granülün boyutu aşabilir `index_granularity_bytes` tek bir satırın boyutu ayarın değerinden büyükse. Bu durumda, granülün boyutu satırın boyutuna eşittir. + +## Sorgularda birincil anahtarlar ve dizinler {#primary-keys-and-indexes-in-queries} + +Tak thee the `(CounterID, Date)` örnek olarak birincil anahtar. Bu durumda, sıralama ve dizin aşağıdaki gibi gösterilebilir: + + Whole data: [---------------------------------------------] + CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] + Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] + Marks: | | | | | | | | | | | + a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 + Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 + +Veri sorgusu belirtirse: + +- `CounterID in ('a', 'h')`, sunucu işaretleri aralıklarında verileri okur `[0, 3)` ve `[6, 8)`. +- `CounterID IN ('a', 'h') AND Date = 3`, sunucu işaretleri aralıklarında verileri okur `[1, 3)` ve `[7, 8)`. +- `Date = 3`, sunucu işaretleri aralığında veri okur `[1, 10]`. + +Yukarıdaki örnekler, her zaman bir dizin tam taramadan daha etkili olduğunu göstermektedir. + +Seyrek bir dizin, ekstra verilerin okunmasına izin verir. Birincil anahtarın tek bir aralığını okurken, `index_granularity * 2` her veri bloğundaki ekstra satırlar okunabilir. + +Seyrek dizinler, çok sayıda tablo satırı ile çalışmanıza izin verir, çünkü çoğu durumda, bu tür dizinler bilgisayarın RAM'İNE sığar. + +ClickHouse benzersiz bir birincil anahtar gerektirmez. Aynı birincil anahtar ile birden çok satır ekleyebilirsiniz. + +### Birincil anahtar seçme {#selecting-the-primary-key} + +Birincil anahtardaki sütun sayısı açıkça sınırlı değildir. Veri yapısına bağlı olarak, birincil anahtara daha fazla veya daha az sütun ekleyebilirsiniz. Bu Mayıs: + +- Bir dizin performansını artırın. + + Birincil anahtar ise `(a, b)`, sonra başka bir sütun ekleyerek `c` aşağıdaki koşullar yerine getirilirse performansı artıracaktır: + + - Sütun üzerinde bir koşulu olan sorgular var `c`. + - Uzun veri aralıkları (birkaç kat daha uzun `index_granularity`) için aynı değer withlerle `(a, b)` yaygındır. Başka bir deyişle, başka bir sütun eklerken oldukça uzun veri aralıklarını atlamanıza izin verir. + +- Veri sıkıştırmasını geliştirin. + + ClickHouse verileri birincil anahtarla sıralar, bu nedenle tutarlılık ne kadar yüksek olursa sıkıştırma o kadar iyi olur. + +- Veri parçalarını birleştirirken ek mantık sağlayın [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) ve [SummingMergeTree](summingmergetree.md) motorlar. + + Bu durumda belirtmek mantıklı *sıralama anahtarı* bu birincil anahtardan farklıdır. + +Uzun bir birincil anahtar, ekleme performansını ve bellek tüketimini olumsuz yönde etkiler, ancak birincil anahtardaki ek sütunlar, ClickHouse performansını etkilemez `SELECT` sorgular. + +### Sıralama anahtarından farklı bir birincil anahtar seçme {#choosing-a-primary-key-that-differs-from-the-sorting-key} + +Sıralama anahtarından (veri bölümlerindeki satırları sıralamak için bir ifade) farklı bir birincil anahtar (her işaret için dizin dosyasında yazılan değerlere sahip bir ifade) belirtmek mümkündür. Bu durumda, birincil anahtar ifadesi tuple, sıralama anahtarı ifadesi tuple'ın bir öneki olmalıdır. + +Bu özellik kullanırken yararlıdır [SummingMergeTree](summingmergetree.md) ve +[AggregatingMergeTree](aggregatingmergetree.md) masa motorları. Bu motorları kullanırken yaygın bir durumda, tablonun iki tür sütunu vardır: *boyutlar* ve *ölçümler*. Tipik sorgular, rasgele ölçü sütunlarının değerlerini toplar `GROUP BY` ve boyutlara göre filtreleme. Çünkü SummingMergeTree ve AggregatingMergeTree sıralama anahtarının aynı değere sahip satırları toplamak, tüm boyutları eklemek doğaldır. Sonuç olarak, anahtar ifadesi uzun bir sütun listesinden oluşur ve bu liste yeni eklenen boyutlarla sık sık güncelleştirilmelidir. + +Bu durumda, birincil anahtarda verimli Aralık taramaları sağlayacak ve kalan boyut sütunlarını sıralama anahtarı kümesine ekleyecek yalnızca birkaç sütun bırakmak mantıklıdır. + +[ALTER](../../../sql-reference/statements/alter.md) yeni bir sütun aynı anda tabloya ve sıralama anahtarı eklendiğinde, varolan veri parçaları değiştirilmesi gerekmez, çünkü sıralama anahtarının hafif bir işlemdir. Eski sıralama anahtarı yeni sıralama anahtarının bir öneki olduğundan ve yeni eklenen sütunda veri olmadığından, veriler tablo değişikliği anında hem eski hem de yeni sıralama anahtarlarına göre sıralanır. + +### Sorgularda dizin ve bölümlerin kullanımı {#use-of-indexes-and-partitions-in-queries} + +İçin `SELECT` sorgular, ClickHouse bir dizin kullanılabilir olup olmadığını analiz eder. Eğer bir dizin kullanılabilir `WHERE/PREWHERE` yan tümce, bir eşitlik veya eşitsizlik karşılaştırma işlemini temsil eden bir ifadeye (bağlantı öğelerinden biri olarak veya tamamen) sahiptir veya varsa `IN` veya `LIKE` sütun veya birincil anahtar veya bölümleme anahtar veya bu sütunların belirli kısmen tekrarlayan işlevleri veya bu ifadelerin mantıksal ilişkileri olan ifadeler üzerinde sabit bir önek ile. + +Bu nedenle, birincil anahtarın bir veya daha fazla aralığındaki sorguları hızlı bir şekilde çalıştırmak mümkündür. Bu örnekte, belirli bir izleme etiketi, belirli bir etiket ve tarih aralığı, belirli bir etiket ve tarih için, tarih aralığına sahip birden çok etiket için vb. çalıştırıldığında sorgular hızlı olacaktır. + +Aşağıdaki gibi yapılandırılmış motora bakalım: + + ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 + +Bu durumda, sorgularda: + +``` sql +SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 +SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) +SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) +``` + +ClickHouse, uygun olmayan verileri kırpmak için birincil anahtar dizinini ve uygun olmayan tarih aralıklarındaki bölümleri kırpmak için aylık bölümleme anahtarını kullanır. + +Yukarıdaki sorgular, dizinin karmaşık ifadeler için bile kullanıldığını göstermektedir. Tablodan okuma, dizini kullanarak tam taramadan daha yavaş olamayacak şekilde düzenlenmiştir. + +Aşağıdaki örnekte, dizin kullanılamaz. + +``` sql +SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' +``` + +Clickhouse'un bir sorgu çalıştırırken dizini kullanıp kullanamayacağını kontrol etmek için ayarları kullanın [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) ve [force\_primary\_key](../../../operations/settings/settings.md). + +Aylara göre bölümleme anahtarı, yalnızca uygun aralıktaki tarihleri içeren veri bloklarını okumanıza izin verir. Bu durumda, veri bloğu birçok tarih için veri içerebilir (bir aya kadar). Bir blok içinde veriler, ilk sütun olarak tarihi içermeyen birincil anahtara göre sıralanır. Bu nedenle, birincil anahtar önekini belirtmeyen yalnızca bir tarih koşulu ile bir sorgu kullanarak tek bir tarih için okunacak daha fazla veri neden olur. + +### Kısmen monotonik birincil anahtarlar için Endeks kullanımı {#use-of-index-for-partially-monotonic-primary-keys} + +Örneğin, Ayın günlerini düşünün. Onlar formu bir [monotonik dizisi](https://en.wikipedia.org/wiki/Monotonic_function) bir ay boyunca, ancak daha uzun süreler için monotonik değil. Bu kısmen monotonik bir dizidir. Bir kullanıcı kısmen monoton birincil anahtar ile tablo oluşturursa, ClickHouse her zamanki gibi seyrek bir dizin oluşturur. Bir kullanıcı bu tür bir tablodan veri seçtiğinde, ClickHouse sorgu koşullarını analiz eder. Kullanıcı, dizinin iki işareti arasında veri almak isterse ve bu işaretlerin her ikisi de bir ay içinde düşerse, ClickHouse bu özel durumda dizini kullanabilir, çünkü sorgu parametreleri ile dizin işaretleri arasındaki mesafeyi hesaplayabilir. + +Sorgu parametresi aralığındaki birincil anahtarın değerleri monotonik bir sırayı temsil etmiyorsa, ClickHouse bir dizin kullanamaz. Bu durumda, ClickHouse Tam Tarama yöntemini kullanır. + +ClickHouse bu mantığı yalnızca ay dizilerinin günleri için değil, kısmen monotonik bir diziyi temsil eden herhangi bir birincil anahtar için kullanır. + +### Veri atlama indeksleri (deneysel) {#table_engine-mergetree-data_skipping-indexes} + +Dizin bildirimi sütunlar bölümünde `CREATE` sorgu. + +``` sql +INDEX index_name expr TYPE type(...) GRANULARITY granularity_value +``` + +Tablolar için `*MergeTree` aile, veri atlama endeksleri belirtilebilir. + +Bu endeksler, bloklarda belirtilen ifade hakkında bazı bilgileri toplar ve bunlardan oluşur `granularity_value` granüller (granül boyutu kullanılarak belirtilir `index_granularity` tablo motoru ayarı). Daha sonra bu agregalar `SELECT` büyük veri bloklarını atlayarak diskten okunacak veri miktarını azaltmak için sorgular `where` sorgu tatmin edilemez. + +**Örnek** + +``` sql +CREATE TABLE table_name +( + u64 UInt64, + i32 Int32, + s String, + ... + INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, + INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 +) ENGINE = MergeTree() +... +``` + +Örneğin endeksleri aşağıdaki sorgularda diskten okunacak veri miktarını azaltmak için ClickHouse tarafından kullanılabilir: + +``` sql +SELECT count() FROM table WHERE s < 'z' +SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 +``` + +#### Mevcut Endeks türleri {#available-types-of-indices} + +- `minmax` + + Belirtilen ifad (eyi saklar (ifad (enin `tuple`, sonra her eleman için aşırı depolar `tuple`), birincil anahtar gibi veri bloklarını atlamak için saklanan bilgileri kullanır. + +- `set(max_rows)` + + Belirtilen ifadenin benzersiz değerlerini depolar (en fazla `max_rows` satırlar, `max_rows=0` Anlamına geliyor “no limits”). Kontrol etmek için değerleri kullanır `WHERE` ifade, bir veri bloğu üzerinde tatmin edilemez değildir. + +- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Mağazalar a [Blo filterom filtre](https://en.wikipedia.org/wiki/Bloom_filter) bu, bir veri bloğundaki tüm ngramları içerir. Sadece dizeleri ile çalışır. Optimizasyonu için kullanılabilir `equals`, `like` ve `in` ifadeler. + + - `n` — ngram size, + - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). + - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. + - `random_seed` — The seed for Bloom filter hash functions. + +- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` + + Olarak aynı `ngrambf_v1`, ancak ngrams yerine simgeleri saklar. Belirteçler alfasayısal olmayan karakterlerle ayrılmış dizilerdir. + +- `bloom_filter([false_positive])` — Stores a [Blo filterom filtre](https://en.wikipedia.org/wiki/Bloom_filter) belirtilen sütunlar için. + + Opsiyonel `false_positive` parametre, filtreden yanlış pozitif yanıt alma olasılığıdır. Olası değerler: (0, 1). Varsayılan değer: 0.025. + + Desteklenen veri türleri: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. + + Aşağıdaki işlevleri kullanabilirsiniz: [eşitlikler](../../../sql-reference/functions/comparison-functions.md), [notEquals](../../../sql-reference/functions/comparison-functions.md), [içinde](../../../sql-reference/functions/in-functions.md), [notİn](../../../sql-reference/functions/in-functions.md), [var](../../../sql-reference/functions/array-functions.md). + + + +``` sql +INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 +INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 +INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 +``` + +#### Fonksiyonları Destek {#functions-support} + +Koşulları `WHERE` yan tümcesi, sütunlarla çalışan işlevlerin çağrılarını içerir. Sütun bir dizinin bir parçasıysa, ClickHouse işlevleri gerçekleştirirken bu dizini kullanmaya çalışır. ClickHouse, dizinleri kullanmak için farklı işlev alt kümelerini destekler. + +Bu `set` dizin tüm fonksiyonları ile kullanılabilir. Diğer dizinler için işlev alt kümeleri aşağıdaki tabloda gösterilmiştir. + +| Fonksiyon (operatör) / dizin | birincil anahtar | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | +|------------------------------------------------------------------------------------------------------------|------------------|--------|-------------|-------------|---------------| +| [eşitlikler (=, ==)](../../../sql-reference/functions/comparison-functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notEquals(!=, \<\>)](../../../sql-reference/functions/comparison-functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [hoşlanmak](../../../sql-reference/functions/string-search-functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [notLike](../../../sql-reference/functions/string-search-functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | +| [startsWith](../../../sql-reference/functions/string-functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | +| [endsWith](../../../sql-reference/functions/string-functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | +| [multiSearchAny](../../../sql-reference/functions/string-search-functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | +| [içinde](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notİn](../../../sql-reference/functions/in-functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | +| [daha az (\<)](../../../sql-reference/functions/comparison-functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [büyük (\>)](../../../sql-reference/functions/comparison-functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [lessOrEquals (\<=)](../../../sql-reference/functions/comparison-functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [greaterOrEquals (\>=)](../../../sql-reference/functions/comparison-functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [boş](../../../sql-reference/functions/array-functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| [notEmpty](../../../sql-reference/functions/array-functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | +| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | + +Ngram boyutundan daha az olan sabit bir argümana sahip işlevler tarafından kullanılamaz `ngrambf_v1` sorgu optimizasyonu için. + +Bloom filtreleri yanlış pozitif eşleşmelere sahip olabilir, bu yüzden `ngrambf_v1`, `tokenbf_v1`, ve `bloom_filter` dizinler, örneğin bir işlevin sonucunun false olması beklenen sorguları en iyi duruma getirmek için kullanılamaz: + +- Optimize edilebilir: + - `s LIKE '%test%'` + - `NOT s NOT LIKE '%test%'` + - `s = 1` + - `NOT s != 1` + - `startsWith(s, 'test')` +- Optimize edilemez: + - `NOT s LIKE '%test%'` + - `s NOT LIKE '%test%'` + - `NOT s = 1` + - `s != 1` + - `NOT startsWith(s, 'test')` + +## Eşzamanlı Veri Erişimi {#concurrent-data-access} + +Eşzamanlı tablo erişimi için çoklu sürüm kullanıyoruz. Başka bir deyişle, bir tablo aynı anda okunup güncelleştirildiğinde, sorgu sırasında geçerli olan bir parça kümesinden veri okunur. Uzun kilitler yok. Ekler okuma işlemlerinin yoluna girmez. + +Bir tablodan okuma otomatik olarak paralelleştirilir. + +## Sütunlar ve tablolar için TTL {#table_engine-mergetree-ttl} + +Değerlerin ömrünü belirler. + +Bu `TTL` yan tümcesi tüm tablo ve her sütun için ayarlanabilir. Tablo düzeyinde TTL ayrıca diskler ve birimler arasında otomatik veri taşıma mantığını belirtebilirsiniz. + +İfadeleri değerlendirmek gerekir [Tarihli](../../../sql-reference/data-types/date.md) veya [DateTime](../../../sql-reference/data-types/datetime.md) veri türü. + +Örnek: + +``` sql +TTL time_column +TTL time_column + interval +``` + +Tanımlamak `interval`, kullanma [zaman aralığı](../../../sql-reference/operators/index.md#operators-datetime) operatörler. + +``` sql +TTL date_time + INTERVAL 1 MONTH +TTL date_time + INTERVAL 15 HOUR +``` + +### Sütun TTL {#mergetree-column-ttl} + +Sütundaki değerler sona erdiğinde, ClickHouse bunları sütun veri türü için varsayılan değerlerle değiştirir. Veri bölümündeki tüm sütun değerleri sona ererse, ClickHouse bu sütunu bir dosya sistemindeki veri bölümünden siler. + +Bu `TTL` yan tümcesi anahtar sütunlar için kullanılamaz. + +Örnekler: + +TTL ile tablo oluşturma + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int TTL d + INTERVAL 1 MONTH, + b Int TTL d + INTERVAL 1 MONTH, + c String +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d; +``` + +Varolan bir tablonun sütununa TTL ekleme + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 DAY; +``` + +Sütun TTL değiştirme + +``` sql +ALTER TABLE example_table + MODIFY COLUMN + c String TTL d + INTERVAL 1 MONTH; +``` + +### Tablo TTL {#mergetree-table-ttl} + +Tablo, süresi dolmuş satırların kaldırılması için bir ifadeye ve parçaların arasında otomatik olarak taşınması için birden fazla ifadeye sahip olabilir [diskler veya birimler](#table_engine-mergetree-multiple-volumes). Tablodaki satırların süresi dolduğunda, ClickHouse ilgili tüm satırları siler. Parça taşıma özelliği için, bir parçanın tüm satırları hareket ifadesi ölçütlerini karşılaması gerekir. + +``` sql +TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... +``` + +TTL kuralı türü her TTL ifadesini takip edebilir. İfade tatmin edildikten sonra yapılacak bir eylemi etkiler (şimdiki zamana ulaşır): + +- `DELETE` - süresi dolmuş satırları sil (varsayılan eylem); +- `TO DISK 'aaa'` - parçayı diske taşı `aaa`; +- `TO VOLUME 'bbb'` - parçayı diske taşı `bbb`. + +Örnekler: + +TTL ile tablo oluşturma + +``` sql +CREATE TABLE example_table +( + d DateTime, + a Int +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(d) +ORDER BY d +TTL d + INTERVAL 1 MONTH [DELETE], + d + INTERVAL 1 WEEK TO VOLUME 'aaa', + d + INTERVAL 2 WEEK TO DISK 'bbb'; +``` + +Tablonun TTL değiştirme + +``` sql +ALTER TABLE example_table + MODIFY TTL d + INTERVAL 1 DAY; +``` + +**Verileri Kaldırma** + +ClickHouse veri parçalarını birleştirdiğinde süresi dolmuş bir TTL ile veri kaldırılır. + +ClickHouse, verilerin süresi dolduğunu gördüğünde, zamanlama dışı bir birleştirme gerçekleştirir. Bu tür birleştirmelerin sıklığını kontrol etmek için şunları ayarlayabilirsiniz `merge_with_ttl_timeout`. Değer çok düşükse, çok fazla kaynak tüketebilecek birçok zamanlama dışı birleştirme gerçekleştirir. + +Gerçekleştir theirseniz `SELECT` birleştirme arasında sorgu, süresi dolmuş veri alabilirsiniz. Bunu önlemek için, [OPTIMIZE](../../../sql-reference/statements/misc.md#misc_operations-optimize) önce sorgu `SELECT`. + +## Veri depolama için birden fazla blok cihazı kullanma {#table_engine-mergetree-multiple-volumes} + +### Giriş {#introduction} + +`MergeTree` aile tablo motorları birden fazla blok cihazlarda veri saklayabilirsiniz. Örneğin, belirli bir tablonun verileri örtük olarak bölündüğünde yararlı olabilir “hot” ve “cold”. En son veriler düzenli olarak talep edilir, ancak yalnızca az miktarda alan gerektirir. Aksine, yağ kuyruklu tarihsel veriler nadiren talep edilir. Birkaç disk varsa, “hot” veriler hızlı disklerde (örneğin, NVMe SSD'ler veya bellekte) bulunabilir; “cold” veri-nispeten yavaş olanlar (örneğin, HDD). + +Veri kısmı için minimum hareketli birimdir `MergeTree`- motor masaları. Bir parçaya ait veriler bir diskte saklanır. Veri parçaları arka planda diskler arasında (kullanıcı ayarlarına göre) ve aynı zamanda [ALTER](../../../sql-reference/statements/alter.md#alter_move-partition) sorgular. + +### Şartlar {#terms} + +- Disk — Block device mounted to the filesystem. +- Default disk — Disk that stores the path specified in the [yol](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-path) sunucu ayarı. +- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). +- Storage policy — Set of volumes and the rules for moving data between them. + +Açıklanan varlıklara verilen isimler sistem tablolarında bulunabilir, [sistem.storage\_policies](../../../operations/system-tables.md#system_tables-storage_policies) ve [sistem.diskler](../../../operations/system-tables.md#system_tables-disks). Bir tablo için yapılandırılmış depolama ilkelerinden birini uygulamak için `storage_policy` ayarı `MergeTree`- motor aile tabloları. + +### Yapılandırma {#table_engine-mergetree-multiple-volumes_configure} + +Diskler, birimler ve depolama politikaları içinde bildirilmelidir `` ana dosyada ya etiket `config.xml` veya farklı bir dosyada `config.d` dizin. + +Yapılandırma yapısı: + +``` xml + + + + /mnt/fast_ssd/clickhouse/ + + + /mnt/hdd1/clickhouse/ + 10485760 + + + /mnt/hdd2/clickhouse/ + 10485760 + + + ... + + + ... + +``` + +Etiketler: + +- `` — Disk name. Names must be different for all disks. +- `path` — path under which a server will store data (`data` ve `shadow` klasörler) ile Sonlandır shouldılmalıdır ‘/’. +- `keep_free_space_bytes` — the amount of free disk space to be reserved. + +Disk tanımının sırası önemli değildir. + +Depolama ilkeleri yapılandırma biçimlendirme: + +``` xml + + ... + + + + + disk_name_from_disks_configuration + 1073741824 + + + + + + + 0.2 + + + + + + + + ... + +``` + +Etiketler: + +- `policy_name_N` — Policy name. Policy names must be unique. +- `volume_name_N` — Volume name. Volume names must be unique. +- `disk` — a disk within a volume. +- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume's disks. +- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). + +Cofiguration örnekleri: + +``` xml + + ... + + + + + disk1 + disk2 + + + + + + + + fast_ssd + 1073741824 + + + disk1 + + + 0.2 + + + ... + +``` + +Verilen örnekte, `hdd_in_order` politika uygular [Ro -und-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) yaklaşmak. Böylece bu politika yalnızca bir birim tanımlar (`single`), veri parçaları tüm disklerinde dairesel sırayla saklanır. Bu tür bir politika, sisteme birkaç benzer disk takılıysa, ancak RAID yapılandırılmamışsa oldukça yararlı olabilir. Her bir disk sürücüsünün güvenilir olmadığını ve bunu 3 veya daha fazla çoğaltma faktörü ile telafi etmek isteyebileceğinizi unutmayın. + +Sistemde farklı türde diskler varsa, `moving_from_ssd_to_hdd` politika yerine kullanılabilir. Birim `hot` bir SSD disk oluşur (`fast_ssd`) ve bu birimde saklanabilecek bir parçanın maksimum boyutu 1GB. Tüm parçaları ile boyutu daha büyük 1 GB üzerinde doğrudan saklanır `cold` bir HDD diski içeren birim `disk1`. +Ayrıca, bir kez disk `fast_ssd` 80'den fazla % tarafından doldurulur, veri transfer edilecektir `disk1` bir arka plan işlemi ile. + +Depolama ilkesi içindeki birim numaralandırma sırası önemlidir. Bir birim aşırı doldurulduktan sonra, veriler bir sonrakine taşınır. Disk numaralandırma sırası da önemlidir, çünkü veriler sırayla depolanır. + +Bir tablo oluştururken, yapılandırılmış depolama ilkelerinden birini ona uygulayabilirsiniz: + +``` sql +CREATE TABLE table_with_non_default_policy ( + EventDate Date, + OrderID UInt64, + BannerID UInt64, + SearchPhrase String +) ENGINE = MergeTree +ORDER BY (OrderID, BannerID) +PARTITION BY toYYYYMM(EventDate) +SETTINGS storage_policy = 'moving_from_ssd_to_hdd' +``` + +Bu `default` depolama ilkesi, Yalnızca verilen bir diskten oluşan yalnızca bir birim kullanmayı ima eder ``. Bir tablo oluşturulduktan sonra, depolama ilkesi değiştirilemez. + +### Ayrıntı {#details} + +Bu durumda `MergeTree` tablolar, veriler diske farklı şekillerde giriyor: + +- Bir ekleme sonucunda (`INSERT` sorgu). +- Arka plan birleştirmeleri sırasında ve [mutasyonlar](../../../sql-reference/statements/alter.md#alter-mutations). +- Başka bir kopyadan indirirken. +- Bölüm Don ofması sonucu [ALTER TABLE … FREEZE PARTITION](../../../sql-reference/statements/alter.md#alter_freeze-partition). + +Mutasyonlar ve bölüm dondurma hariç tüm bu durumlarda, bir parça verilen depolama politikasına göre bir birim ve bir diskte saklanır: + +1. Bir parçayı depolamak için yeterli disk alanına sahip olan ilk birim (tanım sırasına göre) (`unreserved_space > current_part_size`) ve belirli bir boyuttaki parçaların saklanmasına izin verir (`max_data_part_size_bytes > current_part_size`) seçilir. +2. Bu birimde, önceki veri yığınını depolamak için kullanılan ve parça boyutundan daha fazla boş alana sahip olan diski izleyen disk seçilir (`unreserved_space - keep_free_space_bytes > current_part_size`). + +Kap hoodut underun altında, [sabit linkler](https://en.wikipedia.org/wiki/Hard_link). Farklı diskler arasındaki sabit bağlantılar desteklenmez, bu nedenle bu gibi durumlarda ortaya çıkan parçalar ilk disklerle aynı disklerde saklanır. + +Arka planda, parçalar boş alan miktarına göre hacimler arasında taşınır (`move_factor` parametre) sırasına göre birimler yapılandırma dosyasında beyan edilir. +Veriler asla sonuncudan ve birincisine aktarılmaz. Bir sistem tabloları kullanabilirsiniz [sistem.part\_log](../../../operations/system-tables.md#system_tables-part-log) (alan `type = MOVE_PART`) ve [sistem.parçalar](../../../operations/system-tables.md#system_tables-parts) (alanlar `path` ve `disk`) arka plan hareketlerini izlemek için. Ayrıca, ayrıntılı bilgi sunucu günlüklerinde bulunabilir. + +Kullanıcı, sorguyu kullanarak bir bölümü veya bölümü bir birimden diğerine taşımaya zorlayabilir [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql-reference/statements/alter.md#alter_move-partition), arka plan işlemleri için tüm kısıtlamalar dikkate alınır. Sorgu, kendi başına bir hareket başlatır ve tamamlanması için arka plan işlemleri beklemez. Yeterli boş alan yoksa veya gerekli koşullardan herhangi biri karşılanmazsa kullanıcı bir hata mesajı alır. + +Veri taşıma veri çoğaltma ile müdahale etmez. Bu nedenle, farklı depolama ilkeleri aynı tablo için farklı yinelemeler üzerinde belirtilebilir. + +Arka plan birleşimlerinin ve mutasyonlarının tamamlanmasından sonra, eski parçalar yalnızca belirli bir süre sonra çıkarılır (`old_parts_lifetime`). +Bu süre zarfında, diğer birimlere veya disklere taşınmazlar. Bu nedenle, parçalar nihayet çıkarılıncaya kadar, işgal edilen disk alanının değerlendirilmesi için hala dikkate alınır. + +[Orijinal makale](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/tr/engines/table-engines/mergetree-family/replacingmergetree.md b/docs/tr/engines/table-engines/mergetree-family/replacingmergetree.md new file mode 100644 index 00000000000..a24c84e9a16 --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/replacingmergetree.md @@ -0,0 +1,69 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: ReplacingMergeTree +--- + +# ReplacingMergeTree {#replacingmergetree} + +Motor farklıdır [MergeTree](mergetree.md#table_engines-mergetree) aynı birincil anahtar değerine sahip yinelenen girdileri kaldırır (veya daha doğru bir şekilde, aynı [sıralama anahtarı](mergetree.md) değer). + +Veri tekilleştirme yalnızca birleştirme sırasında oluşur. Birleştirme, arka planda bilinmeyen bir zamanda gerçekleşir, bu nedenle bunu planlayamazsınız. Bazı veriler işlenmemiş kalabilir. Kullanarak programsız bir birleştirme çalıştırabilirsiniz, ancak `OPTIMIZE` sorgu, kullanmaya güvenmeyin, çünkü `OPTIMIZE` sorgu büyük miktarda veri okuyacak ve yazacaktır. + +Böyle, `ReplacingMergeTree` yerden tasarruf etmek için arka planda yinelenen verileri temizlemek için uygundur, ancak kopyaların yokluğunu garanti etmez. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = ReplacingMergeTree([ver]) +[PARTITION BY expr] +[ORDER BY expr] +[PRIMARY KEY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +İstek parametrelerinin açıklaması için bkz. [istek açıklaması](../../../sql-reference/statements/create.md). + +**ReplacingMergeTree Parametreleri** + +- `ver` — column with version. Type `UInt*`, `Date` veya `DateTime`. İsteğe bağlı parametre. + + Birleş whenirken, `ReplacingMergeTree` aynı birincil anahtara sahip tüm satırlardan sadece bir tane bırakır: + + - Seç inimde son, eğer `ver` set değil. + - Maksimum sürümü ile, eğer `ver` belirtilen. + +**Sorgu yan tümceleri** + +Oluştururken bir `ReplacingMergeTree` tablo aynı [yanlar](mergetree.md) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) +``` + +Hariç tüm parametreler `ver` içinde olduğu gibi aynı anlama sahip `MergeTree`. + +- `ver` - sürümü ile sütun. İsteğe bağlı parametre. Bir açıklama için yukarıdaki metne bakın. + +
+ +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/tr/engines/table-engines/mergetree-family/replication.md b/docs/tr/engines/table-engines/mergetree-family/replication.md new file mode 100644 index 00000000000..108ddf42d7f --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/replication.md @@ -0,0 +1,218 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "Veri \xC7o\u011Faltma" +--- + +# Veri Çoğaltma {#table_engines-replication} + +Çoğaltma yalnızca mergetree ailesindeki tablolar için desteklenir: + +- ReplicatedMergeTree +- ReplicatedSummingMergeTree +- ReplicatedReplacingMergeTree +- ReplicatedAggregatingMergeTree +- ReplicatedCollapsingMergeTree +- ReplicatedVersionedCollapsingMergetree +- ReplicatedGraphiteMergeTree + +Çoğaltma, tüm sunucu değil, tek bir tablo düzeyinde çalışır. Bir sunucu hem çoğaltılmış hem de çoğaltılmamış tabloları aynı anda depolayabilir. + +Çoğaltma, parçaya bağlı değildir. Her parçanın kendi bağımsız çoğaltması vardır. + +İçin sıkıştırılmış veri `INSERT` ve `ALTER` sorgular çoğaltılır (daha fazla bilgi için bkz. [ALTER](../../../sql-reference/statements/alter.md#query_language_queries_alter)). + +`CREATE`, `DROP`, `ATTACH`, `DETACH` ve `RENAME` sorgular tek bir sunucuda yürütülür ve çoğaltılmaz: + +- Bu `CREATE TABLE` sorgu sorgu çalıştırıldığı sunucuda yeni bir replicatable tablo oluşturur. Bu tablo diğer sunucularda zaten varsa, yeni bir yineleme ekler. +- Bu `DROP TABLE` sorgu, sorgunun çalıştırıldığı sunucuda bulunan yinelemeyi siler. +- Bu `RENAME` sorgu yinelemeler birinde tabloyu yeniden adlandırır. Başka bir deyişle, çoğaltılmış tablolar farklı yinelemeler üzerinde farklı adlara sahip olabilir. + +ClickHouse kullanır [Apache ZooKeeper](https://zookeeper.apache.org) kopyaları meta bilgilerini saklamak için. ZooKeeper sürüm 3.4.5 veya daha yeni kullanın. + +Çoğaltma kullanmak için, parametreleri [zookeeper](../../../operations/server-configuration-parameters/settings.md#server-settings_zookeeper) sunucu yapılandırma bölümü. + +!!! attention "Dikkat" + Güvenlik ayarını ihmal etmeyin. ClickHouse destekler `digest` [ACLL şeması](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) ZooKeeper Güvenlik alt sisteminin. + +ZooKeeper kümesinin adreslerini ayarlama örneği: + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + + example3 + 2181 + + +``` + +Varolan herhangi bir ZooKeeper kümesini belirtebilirsiniz ve sistem kendi verileri için bir dizin kullanır (replicatable tablo oluştururken dizin belirtilir). + +Zookeeper yapılandırma dosyasında ayarlanmamışsa, çoğaltılmış tablolar oluşturamazsınız ve varolan çoğaltılmış tablolar salt okunur olacaktır. + +ZooKeeper kullanılmaz `SELECT` çoğaltma performansını etkilemez çünkü sorgular `SELECT` ve sorgular, çoğaltılmamış tablolar için yaptıkları kadar hızlı çalışır. Dağıtılmış çoğaltılmış tabloları sorgularken, ClickHouse davranışı ayarlar tarafından denetlenir [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) ve [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). + +Her biri için `INSERT` sorgu, yaklaşık on girişleri zookeeper birkaç işlemler aracılığıyla eklenir. (Daha kesin olmak gerekirse, bu eklenen her veri bloğu içindir; bir ekleme sorgusu her bir blok veya bir blok içerir `max_insert_block_size = 1048576` satırlar.) Bu, biraz daha uzun gecikmelere yol açar `INSERT` çoğaltılmamış tablolarla karşılaştırıldığında. Ancak, birden fazla olmayan gruplar halinde veri eklemek için önerileri izlerseniz `INSERT` saniyede, herhangi bir sorun yaratmaz. Bir ZooKeeper kümesini koordine etmek için kullanılan tüm ClickHouse kümesinin toplam birkaç yüzü vardır `INSERTs` saniyede. Veri eklerindeki verim (saniyede satır sayısı), çoğaltılmamış veriler için olduğu kadar yüksektir. + +Çok büyük kümeler için, farklı kırıklar için farklı ZooKeeper kümelerini kullanabilirsiniz. Ancak, bu Yandex'de gerekli değildir.Metrica küme (yaklaşık 300 sunucu). + +Çoğaltma zaman uyumsuz ve çok ana. `INSERT` sorgular (yanı sıra `ALTER`) mevcut herhangi bir sunucuya gönderilebilir. Veri sorgu çalıştırıldığı sunucuda eklenir ve sonra diğer sunuculara kopyalanır. Zaman uyumsuz olduğundan, son eklenen veriler bazı gecikme ile diğer yinelemeler görünür. Yinelemelerin bir kısmı mevcut değilse, veriler kullanılabilir olduklarında yazılır. Bir çoğaltma varsa, gecikme, sıkıştırılmış veri bloğunu ağ üzerinden aktarmak için gereken süredir. + +Varsayılan olarak, bir INSERT sorgusu yalnızca bir yinelemeden veri yazma onayı bekler. Verileri başarıyla yalnızca bir yineleme için yazılmıştır ve bu yineleme ile sunucu varolmaya sona erer, depolanan veriler kaybolur. Birden çok yinelemeden veri yazma onayını almayı etkinleştirmek için `insert_quorum` seçenek. + +Her veri bloğu atomik olarak yazılır. Ekle sorgusu kadar bloklara ayrılmıştır `max_insert_block_size = 1048576` satırlar. Diğer bir deyişle, `INSERT` sorgu 1048576 satırdan daha az, atomik olarak yapılır. + +Veri blokları tekilleştirilmiştir. Aynı veri bloğunun (aynı sırayla aynı satırları içeren aynı boyuttaki veri blokları) birden fazla yazımı için, blok yalnızca bir kez yazılır. Bunun nedeni, istemci uygulaması verilerin DB'YE yazılıp yazılmadığını bilmediğinde ağ arızaları durumunda, `INSERT` sorgu sadece tekrar edilebilir. Hangi çoğaltma eklerinin aynı verilerle gönderildiği önemli değildir. `INSERTs` idempotent vardır. Tekilleştirme parametreleri tarafından kontrol edilir [merge\_tree](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree) sunucu ayarları. + +Çoğaltma sırasında, yalnızca eklenecek kaynak veriler ağ üzerinden aktarılır. Daha fazla veri dönüşümü (birleştirme), tüm kopyalarda aynı şekilde koordine edilir ve gerçekleştirilir. Bu, ağ kullanımını en aza indirir; bu, çoğaltmaların farklı veri merkezlerinde bulunduğu zaman çoğaltmanın iyi çalıştığı anlamına gelir. (Farklı veri merkezlerinde çoğaltmanın çoğaltmanın ana hedefi olduğunu unutmayın .) + +Aynı verilerin çoğaltmaları herhangi bir sayıda olabilir. Üye.Metrica üretimde çift çoğaltma kullanır. Her sunucu, bazı durumlarda RAID-5 veya RAID-6 ve RAID-10 kullanır. Bu nispeten güvenilir ve kullanışlı bir çözümdür. + +Sistem, yinelemelerdeki veri senkronizasyonunu izler ve bir hatadan sonra kurtarabilir. Yük devretme otomatik (verilerde küçük farklılıklar için) veya yarı otomatik (veriler çok fazla farklılık gösterdiğinde, bu da bir yapılandırma hatasını gösterebilir). + +## Çoğaltılmış Tablolar Oluşturma {#creating-replicated-tables} + +Bu `Replicated` önek tablo motoru adına eklenir. Mesela:`ReplicatedMergeTree`. + +**Çoğaltılan \* MergeTree parametreleri** + +- `zoo_path` — The path to the table in ZooKeeper. +- `replica_name` — The replica name in ZooKeeper. + +Örnek: + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +``` + +
+ +Kullanımdan kaldırılmış sözdizimi örneği + +``` sql +CREATE TABLE table_name +( + EventDate DateTime, + CounterID UInt32, + UserID UInt32 +) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) +``` + +
+ +Örnekte gösterildiği gibi, bu parametreler kıvırcık köşeli ayraçlarda ikameler içerebilir. İkame edilen değerler ‘macros’ yapılandırma dosyasının bölümü. Örnek: + +``` xml + + 05 + 02 + example05-02-1.yandex.ru + +``` + +Zookeeper tablonun yolunu her çoğaltılmış tablo için benzersiz olmalıdır. Farklı parçalardaki tabloların farklı yolları olmalıdır. +Bu durumda, yol aşağıdaki parçalardan oluşur: + +`/clickhouse/tables/` ortak önek. Tam olarak bunu kullanmanızı öneririz. + +`{layer}-{shard}` shard tanımlayıcısıdır. Bu örnekte Yandex'den beri iki bölümden oluşmaktadır.Metrica küme iki seviyeli sharding kullanır. Çoğu görev için, yalnızca shard tanımlayıcısına genişletilecek olan {shard} ikamesini bırakabilirsiniz. + +`table_name` ZooKeeper tablo için düğüm adıdır. Tablo adı ile aynı yapmak için iyi bir fikirdir. Açıkça tanımlanır, çünkü tablo adının aksine, bir yeniden adlandırma sorgusundan sonra değişmez. +*HINT*: önüne bir veritabanı adı ekleyebilirsiniz `table_name` ayrıca. E. g. `db_name.table_name` + +Çoğaltma adı, aynı tablonun farklı yinelemelerini tanımlar. Örnekte olduğu gibi bunun için sunucu adını kullanabilirsiniz. Adın sadece her parça içinde benzersiz olması gerekir. + +Değiştirmeleri kullanmak yerine parametreleri açıkça tanımlayabilirsiniz. Bu, test etmek ve küçük kümeleri yapılandırmak için uygun olabilir. Ancak, dağıtılmış DDL sorguları kullanamazsınız (`ON CLUSTER` bu durumda). + +Büyük kümelerle çalışırken, hata olasılığını azalttıkları için değiştirmeleri kullanmanızı öneririz. + +Run the `CREATE TABLE` her yineleme üzerinde sorgu. Bu sorgu, yeni bir çoğaltılmış tablo oluşturur veya varolan bir yeni bir yineleme ekler. + +Tablo zaten diğer yinelemeler üzerinde bazı veriler içerdikten sonra yeni bir yineleme eklerseniz, verileri diğer yinelemeler için yeni bir sorgu çalıştırdıktan sonra kopyalanır. Başka bir deyişle, yeni çoğaltma kendisini diğerleriyle eşitler. + +Bir yineleme silmek için çalıştırın `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. + +## Arızalardan Sonra Kurtarma {#recovery-after-failures} + +Bir sunucu başlatıldığında ZooKeeper kullanılamıyorsa, çoğaltılmış tablolar salt okunur moda geçer. Sistem periyodik olarak ZooKeeper bağlanmaya çalışır. + +ZooKeeper sırasında kullanılamıyorsa bir `INSERT`, veya ZooKeeper ile etkileşimde bulunurken bir hata oluşur, bir istisna atılır. + +ZooKeeper bağlandıktan sonra, sistem yerel dosya sistemindeki veri kümesinin beklenen veri kümesiyle eşleşip eşleşmediğini kontrol eder (ZooKeeper bu bilgileri saklar). Küçük tutarsızlıklar varsa, sistem verileri kopyalarla senkronize ederek bunları çözer. + +Sistem bozuk veri parçalarını (yanlış dosya boyutu ile) veya tanınmayan parçaları (dosya sistemine yazılmış ancak Zookeeper'da kaydedilmemiş parçalar) tespit ederse, bunları `detached` alt dizin (silinmez). Eksik parçalar kopyalardan kopyalanır. + +Clickhouse'un büyük miktarda veriyi otomatik olarak silme gibi yıkıcı eylemler gerçekleştirmediğini unutmayın. + +Sunucu başlatıldığında (veya ZooKeeper ile yeni bir oturum kurduğunda), yalnızca tüm dosyaların miktarını ve boyutlarını kontrol eder. Dosya boyutları eşleşirse, ancak bayt ortasında bir yerde değiştirilmişse, bu hemen algılanmaz, ancak yalnızca bir dosya için verileri okumaya çalışırken algılanmaz. `SELECT` sorgu. Sorgu, eşleşen olmayan bir sağlama toplamı veya sıkıştırılmış bir bloğun boyutu hakkında bir özel durum atar. Bu durumda, veri parçaları doğrulama kuyruğuna eklenir ve gerekirse kopyalardan kopyalanır. + +Yerel veri kümesi beklenenden çok fazla farklıysa, bir güvenlik mekanizması tetiklenir. Sunucu bunu günlüğe girer ve başlatmayı reddeder. Bunun nedeni, bu durumda, bir parçadaki bir kopya yanlışlıkla farklı bir parçadaki bir kopya gibi yapılandırılmışsa gibi bir yapılandırma hatası gösterebilir. Ancak, bu mekanizma için eşikleri oldukça düşük ayarlanır ve bu durum normal hata kurtarma sırasında ortaya çıkabilir. Bu durumda, veriler yarı otomatik olarak geri yüklenir “pushing a button”. + +Kurtarma işlemini başlatmak için düğümü oluşturun `/path_to_table/replica_name/flags/force_restore_data` herhangi bir içerik ile ZooKeeper veya tüm çoğaltılmış tabloları geri yüklemek için komutu çalıştırın: + +``` bash +sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data +``` + +Sunucuyu yeniden başlatın. Başlangıçta, sunucu bu bayrakları siler ve kurtarma işlemini başlatır. + +## Tam Veri Kaybından Sonra Kurtarma {#recovery-after-complete-data-loss} + +Tüm veriler ve meta veriler sunuculardan birinden kaybolduysa, kurtarma için şu adımları izleyin: + +1. Clickhouse'u sunucuya yükleyin. Bunları kullanırsanız, shard tanımlayıcısı ve yinelemeleri içeren yapılandırma dosyasında doğru değiştirmelerin tanımlayın. +2. Sunucularda el ile çoğaltılması gereken yinelenmemiş tablolar varsa, verilerini bir kopyadan kopyalayın (dizinde `/var/lib/clickhouse/data/db_name/table_name/`). +3. Bulunan tablo tanım copylarını kopyala `/var/lib/clickhouse/metadata/` bir kopyadan. Tablo tanımlarında bir parça veya çoğaltma tanımlayıcısı açıkça tanımlanmışsa, bu kopyaya karşılık gelecek şekilde düzeltin. (Alternatif olarak, sunucuyu başlatın ve tüm `ATTACH TABLE` içinde olması gereken sorgular .sql dosyaları `/var/lib/clickhouse/metadata/`.) +4. Kurtarma işlemini başlatmak için ZooKeeper düğümünü oluşturun `/path_to_table/replica_name/flags/force_restore_data` herhangi bir içerikle veya tüm çoğaltılmış tabloları geri yüklemek için komutu çalıştırın: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` + +Ardından sunucuyu başlatın (zaten çalışıyorsa yeniden başlatın). Veriler kopyalardan indirilecektir. + +Alternatif bir kurtarma seçeneği zookeeper kayıp yineleme hakkında bilgi silmektir (`/path_to_table/replica_name`), daha sonra açıklandığı gibi yinelemeyi tekrar oluşturun “[Çoğaltılmış tablolar oluşturma](#creating-replicated-tables)”. + +Kurtarma sırasında ağ bant genişliği üzerinde herhangi bir kısıtlama yoktur. Aynı anda birçok yinelemeyi geri yüklüyorsanız bunu aklınızda bulundurun. + +## Mergetree'den Replicatedmergetree'ye dönüştürme {#converting-from-mergetree-to-replicatedmergetree} + +Terimi kullanıyoruz `MergeTree` tüm tablo motorlarına başvurmak için `MergeTree family` için aynı `ReplicatedMergeTree`. + +Eğer olsaydı bir `MergeTree` el ile çoğaltılmış tablo, çoğaltılmış bir tabloya dönüştürebilirsiniz. Zaten büyük miktarda veri topladıysanız bunu yapmanız gerekebilir. `MergeTree` tablo ve şimdi çoğaltmayı etkinleştirmek istiyorsunuz. + +Veriler çeşitli yinelemelerde farklılık gösteriyorsa, önce onu eşitleyin veya bu verileri biri dışındaki tüm yinelemelerde silin. + +Varolan MergeTree tablosunu yeniden adlandırın, sonra bir `ReplicatedMergeTree` eski adı olan tablo. +Eski tablodan veri taşıma `detached` yeni tablo verileri ile dizin içindeki alt dizin (`/var/lib/clickhouse/data/db_name/table_name/`). +Sonra koş `ALTER TABLE ATTACH PARTITION` bu veri parçalarını çalışma kümesine eklemek için yinelemelerden birinde. + +## Replicatedmergetree'den Mergetree'ye dönüştürme {#converting-from-replicatedmergetree-to-mergetree} + +Farklı bir adla bir MergeTree tablosu oluşturun. İle dizinden tüm verileri taşıyın `ReplicatedMergeTree` yeni tablonun veri dizinine tablo verileri. Sonra Sil `ReplicatedMergeTree` tablo ve sunucuyu yeniden başlatın. + +Eğer bir kurtulmak istiyorsanız `ReplicatedMergeTree` sunucu başlatmadan tablo: + +- İlgili sil `.sql` meta veri dizinindeki dosya (`/var/lib/clickhouse/metadata/`). +- ZooKeeper ilgili yolu silin (`/path_to_table/replica_name`). + +Bundan sonra, sunucuyu başlatabilir, bir `MergeTree` tablo, verileri kendi dizinine taşıyın ve sonra sunucuyu yeniden başlatın. + +## Zookeeper kümesindeki meta veriler kaybolduğunda veya zarar gördüğünde kurtarma {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} + +ZooKeeper içindeki veriler kaybolduysa veya hasar gördüyse, verileri yukarıda açıklandığı gibi yinelenmemiş bir tabloya taşıyarak kaydedebilirsiniz. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/tr/engines/table-engines/mergetree-family/summingmergetree.md b/docs/tr/engines/table-engines/mergetree-family/summingmergetree.md new file mode 100644 index 00000000000..3092339658c --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/summingmergetree.md @@ -0,0 +1,141 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: SummingMergeTree +--- + +# SummingMergeTree {#summingmergetree} + +Motor devralır [MergeTree](mergetree.md#table_engines-mergetree). Fark, veri parçalarını birleştirirken `SummingMergeTree` tablolar ClickHouse tüm satırları aynı birincil anahtarla değiştirir (veya daha doğru olarak, aynı [sıralama anahtarı](mergetree.md)) sayısal veri türüne sahip sütunlar için özetlenen değerleri içeren bir satır ile. Sıralama anahtarı, tek bir anahtar değeri çok sayıda satıra karşılık gelecek şekilde oluşturulursa, bu, depolama birimini önemli ölçüde azaltır ve veri seçimini hızlandırır. + +Motoru birlikte kullanmanızı öneririz `MergeTree`. Mağaza tam veri `MergeTree` tablo ve kullanım `SummingMergeTree` örneğin, rapor hazırlarken toplu veri depolamak için. Böyle bir yaklaşım, yanlış oluşturulmuş bir birincil anahtar nedeniyle değerli verileri kaybetmenizi önleyecektir. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = SummingMergeTree([columns]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +İstek parametrelerinin açıklaması için bkz. [istek açıklaması](../../../sql-reference/statements/create.md). + +**SummingMergeTree parametreleri** + +- `columns` - değerlerin özetleneceği sütunların adlarına sahip bir tuple. İsteğe bağlı parametre. + Sütunlar sayısal tipte olmalı ve birincil anahtarda olmamalıdır. + + Eğer `columns` belirtilmemiş, ClickHouse birincil anahtarda olmayan bir sayısal veri türü ile tüm sütunlardaki değerleri özetler. + +**Sorgu yan tümceleri** + +Oluştururken bir `SummingMergeTree` tablo aynı [yanlar](mergetree.md) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) +``` + +Hariç tüm parametreler `columns` içinde olduğu gibi aynı anlama sahip `MergeTree`. + +- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. + +
+ +## Kullanım Örneği {#usage-example} + +Aşağıdaki tabloyu düşünün: + +``` sql +CREATE TABLE summtt +( + key UInt32, + value UInt32 +) +ENGINE = SummingMergeTree() +ORDER BY key +``` + +Veri Ekle: + +``` sql +INSERT INTO summtt Values(1,1),(1,2),(2,1) +``` + +ClickHouse tüm satırları tamamen toplayabilir ([aşağıya bakın](#data-processing)), bu yüzden bir toplama işlevi kullanıyoruz `sum` ve `GROUP BY` sorguda yan tümcesi. + +``` sql +SELECT key, sum(value) FROM summtt GROUP BY key +``` + +``` text +┌─key─┬─sum(value)─┐ +│ 2 │ 1 │ +│ 1 │ 3 │ +└─────┴────────────┘ +``` + +## Veri İşleme {#data-processing} + +Veriler bir tabloya eklendiğinde, bunlar olduğu gibi kaydedilir. ClickHouse, verilerin eklenen bölümlerini periyodik olarak birleştirir ve bu, aynı birincil anahtara sahip satırların toplandığı ve sonuçta elde edilen her veri parçası için bir tane ile değiştirildiği zamandır. + +ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) bir toplama fonksiyonu [toplam()](../../../sql-reference/aggregate-functions/reference.md#agg_function-sum) ve `GROUP BY` yukarıdaki örnekte açıklandığı gibi yan tümcesi bir sorguda kullanılmalıdır. + +### Toplama için ortak kurallar {#common-rules-for-summation} + +Sayısal veri türüne sahip sütunlardaki değerler özetlenir. Sütun kümesi parametre tarafından tanımlanır `columns`. + +Değerler toplamı için tüm sütunlarda 0 ise, satır silinir. + +Sütun birincil anahtarda değilse ve özetlenmezse, mevcut olanlardan rasgele bir değer seçilir. + +Değerler, birincil anahtardaki sütunlar için özetlenmez. + +### Aggregatefunction Sütunlarındaki toplama {#the-summation-in-the-aggregatefunction-columns} + +Sütunlar için [AggregateFunction türü](../../../sql-reference/data-types/aggregatefunction.md) ClickHouse olarak davranır [AggregatingMergeTree](aggregatingmergetree.md) işleve göre motor toplama. + +### İç İçe Yapılar {#nested-structures} + +Tablo, özel bir şekilde işlenen iç içe geçmiş veri yapılarına sahip olabilir. + +İç içe geçmiş bir tablonun adı ile bitiyorsa `Map` ve aşağıdaki kriterleri karşılayan en az iki sütun içerir: + +- ilk sütun sayısal `(*Int*, Date, DateTime)` veya bir dize `(String, FixedString)` hadi diyelim `key`, +- diğer sütunlar aritmetik `(*Int*, Float32/64)` hadi diyelim `(values...)`, + +sonra bu iç içe geçmiş tablo bir eşleme olarak yorumlanır `key => (values...)` ve satırlarını birleştirirken, iki veri kümesinin öğeleri şu şekilde birleştirilir `key` karşılık gelen bir toplamı ile `(values...)`. + +Örnekler: + +``` text +[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] +[(1, 100)] + [(1, 150)] -> [(1, 250)] +[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] +[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] +``` + +Veri isterken, [sumMap (anahtar, değer)](../../../sql-reference/aggregate-functions/reference.md) toplama fonksiyonu `Map`. + +İç içe geçmiş veri yapısı için, sütunlarının toplamı için sütun kümesinde belirtmeniz gerekmez. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/tr/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md b/docs/tr/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md new file mode 100644 index 00000000000..966b6b1a7d4 --- /dev/null +++ b/docs/tr/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md @@ -0,0 +1,238 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: VersionedCollapsingMergeTree +--- + +# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} + +Bu motor: + +- Sürekli değişen nesne durumlarının hızlı yazılmasını sağlar. +- Arka planda eski nesne durumlarını siler. Bu, depolama hacmini önemli ölçüde azaltır. + +Bölümüne bakınız [Çökme](#table_engines_versionedcollapsingmergetree) ayrıntılar için. + +Motor devralır [MergeTree](mergetree.md#table_engines-mergetree) ve veri parçalarını birleştirmek için algoritmaya satırları daraltmak için mantığı ekler. `VersionedCollapsingMergeTree` aynı amaca hizmet eder [CollapsingMergeTree](collapsingmergetree.md) ancak, verilerin birden çok iş parçacığıyla herhangi bir sıraya yerleştirilmesine izin veren farklı bir çökme algoritması kullanır. Özellikle, `Version` sütun, yanlış sıraya yerleştirilmiş olsalar bile satırları düzgün bir şekilde daraltmaya yardımcı olur. Tersine, `CollapsingMergeTree` sadece kesinlikle ardışık ekleme sağlar. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = VersionedCollapsingMergeTree(sign, version) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +Sorgu parametrelerinin açıklaması için bkz: [sorgu açıklaması](../../../sql-reference/statements/create.md). + +**Motor Parametreleri** + +``` sql +VersionedCollapsingMergeTree(sign, version) +``` + +- `sign` — Name of the column with the type of row: `1` is a “state” satır, `-1` is a “cancel” satır. + + Sütun veri türü olmalıdır `Int8`. + +- `version` — Name of the column with the version of the object state. + + Sütun veri türü olmalıdır `UInt*`. + +**Sorgu Yan Tümceleri** + +Oluştururken bir `VersionedCollapsingMergeTree` tablo, aynı [yanlar](mergetree.md) oluşturul aurken gerekli `MergeTree` Tablo. + +
+ +Bir tablo oluşturmak için kullanımdan kaldırılan yöntem + +!!! attention "Dikkat" + Bu yöntemi yeni projelerde kullanmayın. Mümkünse, eski projeleri yukarıda açıklanan yönteme geçin. + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] VersionedCollapsingMergeTree(date-column [, samp#table_engines_versionedcollapsingmergetreeling_expression], (primary, key), index_granularity, sign, version) +``` + +Dışındaki tüm parametreler `sign` ve `version` içinde olduğu gibi aynı anlama sahip `MergeTree`. + +- `sign` — Name of the column with the type of row: `1` is a “state” satır, `-1` is a “cancel” satır. + + Column Data Type — `Int8`. + +- `version` — Name of the column with the version of the object state. + + Sütun veri türü olmalıdır `UInt*`. + +
+ +## Çökme {#table_engines_versionedcollapsingmergetree} + +### Veriler {#data} + +Bazı nesneler için sürekli değişen verileri kaydetmeniz gereken bir durumu düşünün. Bir nesne için bir satıra sahip olmak ve değişiklikler olduğunda satırı güncellemek mantıklıdır. Ancak, depolama alanındaki verileri yeniden yazmayı gerektirdiğinden, güncelleştirme işlemi bir DBMS için pahalı ve yavaştır. Verileri hızlı bir şekilde yazmanız gerekiyorsa güncelleştirme kabul edilemez, ancak değişiklikleri bir nesneye sırayla aşağıdaki gibi yazabilirsiniz. + +Kullan... `Sign` satır yazarken sütun. Eğer `Sign = 1` bu, satırın bir nesnenin durumu olduğu anlamına gelir (diyelim “state” satır). Eğer `Sign = -1` aynı özelliklere sahip bir nesnenin durumunun iptal edildiğini gösterir (buna “cancel” satır). Ayrıca kullanın `Version` bir nesnenin her durumunu ayrı bir sayı ile tanımlaması gereken sütun. + +Örneğin, kullanıcıların bazı sitede kaç sayfa ziyaret ettiğini ve ne kadar süre orada olduklarını hesaplamak istiyoruz. Bir noktada, kullanıcı etkinliği durumu ile aşağıdaki satırı yazıyoruz: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Bir noktada daha sonra kullanıcı aktivitesinin değişikliğini kaydediyoruz ve aşağıdaki iki satırla yazıyoruz. + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +İlk satır, nesnenin (kullanıcı) önceki durumunu iptal eder. Dışında iptal edilen Devletin tüm alanlarını kopya shouldlama shouldlıdır `Sign`. + +İkinci satır geçerli durumu içerir. + +Sadece kullanıcı etkinliğinin son durumuna ihtiyacımız olduğundan, satırlar + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +nesnenin geçersiz (eski) durumunu daraltarak silinebilir. `VersionedCollapsingMergeTree` veri parçalarını birleştirirken bunu yapar. + +Her değişiklik için neden iki satıra ihtiyacımız olduğunu bulmak için bkz. [Algoritma](#table_engines-versionedcollapsingmergetree-algorithm). + +**Kullanımı ile ilgili notlar** + +1. Verileri yazan program, iptal etmek için bir nesnenin durumunu hatırlamalıdır. Bu “cancel” dize bir kopyası olmalıdır “state” tersi ile dize `Sign`. Bu, ilk depolama boyutunu arttırır, ancak verileri hızlı bir şekilde yazmanıza izin verir. +2. Sütunlardaki uzun büyüyen diziler, yazma yükü nedeniyle motorun verimliliğini azaltır. Daha basit veri, daha iyi verim. +3. `SELECT` sonuçlara itiraz değişiklikleri tarihinin tutarlılık bağlıdır. Ekleme için veri hazırlarken doğru olun. Oturum derinliği gibi negatif olmayan metrikler için negatif değerler gibi tutarsız verilerle öngörülemeyen sonuçlar alabilirsiniz. + +### Algoritma {#table_engines-versionedcollapsingmergetree-algorithm} + +ClickHouse veri parçalarını birleştirdiğinde, aynı birincil anahtar ve sürüm ve farklı olan her satır çiftini siler `Sign`. Satırların sırası önemli değil. + +ClickHouse veri eklediğinde, satırları birincil anahtarla sipariş eder. Eğer... `Version` sütun birincil anahtarda değil, ClickHouse onu birincil anahtara örtük olarak son alan olarak ekler ve sipariş vermek için kullanır. + +## Veri Seçme {#selecting-data} + +ClickHouse, aynı birincil anahtara sahip tüm satırların aynı sonuçtaki veri bölümünde veya hatta aynı fiziksel sunucuda olacağını garanti etmez. Bu, hem verileri yazmak hem de veri parçalarının daha sonra birleştirilmesi için geçerlidir. Ayrıca, ClickHouse süreçleri `SELECT` birden çok iş parçacıklarıyla sorgular ve sonuçtaki satırların sırasını tahmin edemez. Bu tamamen almak için bir ihtiyaç varsa toplama gerekli olduğu anlamına gelir “collapsed” bir veri `VersionedCollapsingMergeTree` Tablo. + +Daraltmayı sonuçlandırmak için, bir sorgu ile bir sorgu yazın `GROUP BY` yan tümce ve işareti için hesap toplama işlevleri. Örneğin, miktarı hesaplamak için kullanın `sum(Sign)` yerine `count()`. Bir şeyin toplamını hesaplamak için şunları kullanın `sum(Sign * x)` yerine `sum(x)` ve Ekle `HAVING sum(Sign) > 0`. + +Toplanan `count`, `sum` ve `avg` bu şekilde hesaplanabilir. Toplanan `uniq` bir nesnenin en az bir daraltılmamış durumu varsa hesaplanabilir. Toplanan `min` ve `max` hesaplan becauseamaz çünkü `VersionedCollapsingMergeTree` çökmüş durumların değerlerinin geçmişini kaydetmez. + +İle verileri ayıklamak gerekiyorsa “collapsing” ancak toplama olmadan (örneğin, en yeni değerleri belirli koşullarla eşleşen satırların mevcut olup olmadığını kontrol etmek için) `FINAL` değiştirici için `FROM` yan. Bu yaklaşım verimsizdir ve büyük tablolarla kullanılmamalıdır. + +## Kullanım örneği {#example-of-use} + +Örnek veriler: + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Tablo oluşturma: + +``` sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8, + Version UInt8 +) +ENGINE = VersionedCollapsingMergeTree(Sign, Version) +ORDER BY UserID +``` + +Veri ekleme: + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) +``` + +``` sql +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) +``` + +Biz iki kullanın `INSERT` iki farklı veri parçası oluşturmak için sorgular. Verileri tek bir sorgu ile eklersek, ClickHouse bir veri parçası oluşturur ve hiçbir zaman birleştirme gerçekleştirmez. + +Veri alma: + +``` sql +SELECT * FROM UAct +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Burada ne görüyoruz ve çökmüş parçalar nerede? +İki veri parçasını iki kullanarak oluşturduk `INSERT` sorgular. Bu `SELECT` sorgu iki iş parçacığında gerçekleştirildi ve sonuç rastgele bir satır sırasıdır. +Veri bölümleri henüz birleştirilmediği için çökme gerçekleşmedi. ClickHouse biz tahmin edemez zaman içinde bilinmeyen bir noktada veri parçalarını birleştirir. + +Bu yüzden toplamaya ihtiyacımız var: + +``` sql +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration, + Version +FROM UAct +GROUP BY UserID, Version +HAVING sum(Sign) > 0 +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 2 │ +└─────────────────────┴───────────┴──────────┴─────────┘ +``` + +Toplamaya ihtiyacımız yoksa ve çökmeyi zorlamak istiyorsak, `FINAL` değiştirici için `FROM` yan. + +``` sql +SELECT * FROM UAct FINAL +``` + +``` text +┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ +│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ +└─────────────────────┴───────────┴──────────┴──────┴─────────┘ +``` + +Bu, verileri seçmek için çok verimsiz bir yoldur. Büyük tablolar için kullanmayın. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/tr/engines/table-engines/special/buffer.md b/docs/tr/engines/table-engines/special/buffer.md new file mode 100644 index 00000000000..1770738db00 --- /dev/null +++ b/docs/tr/engines/table-engines/special/buffer.md @@ -0,0 +1,71 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: Arabellek +--- + +# Arabellek {#buffer} + +RAM'de yazmak için verileri tamponlar, periyodik olarak başka bir tabloya temizler. Okuma işlemi sırasında veri arabellekten ve diğer tablodan aynı anda okunur. + +``` sql +Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) +``` + +Motor parametreleri: + +- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. +- `table` – Table to flush data to. +- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` bağımsız tamponların. Önerilen değer: 16. +- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, ve `max_bytes` – Conditions for flushing data from the buffer. + +Veri arabellekten temizlendi ve hedef tabloya yazılır eğer tüm `min*` koşulları veya en az bir `max*` koşul karşı arelanır. + +- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. +- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. +- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. + +Yazma işlemi sırasında veri bir `num_layers` rastgele tampon sayısı. Veya, eklenecek veri kısmı yeterince büyükse (daha büyük `max_rows` veya `max_bytes`), arabelleği atlayarak doğrudan hedef tabloya yazılır. + +Verilerin yıkanması için koşullar, her biri için ayrı ayrı hesaplanır. `num_layers` arabellekler. Örneğin, `num_layers = 16` ve `max_bytes = 100000000`, maksimum RAM tüketimi 1,6 GB'DİR. + +Örnek: + +``` sql +CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) +``` + +Oluşturma Bir ‘merge.hits\_buffer’ ile aynı yapıya sahip tablo ‘merge.hits’ ve Tampon motorunu kullanarak. Bu tabloya yazarken, veriler RAM'de arabelleğe alınır ve daha sonra ‘merge.hits’ Tablo. 16 tamponlar oluşturulur. 100 saniye geçti veya bir milyon satır yazılmış veya 100 MB veri yazılmıştır; ya da aynı anda 10 saniye geçti ve 10.000 satır ve 10 MB veri yazılmıştır, bunların her veri temizlendi. Örneğin, sadece bir satır yazılmışsa, 100 saniye sonra ne olursa olsun, yıkanacaktır. Ancak, birçok satır yazılmışsa, veriler daha erken temizlenecektir. + +Sunucu DROP TABLE veya DETACH TABLE ile durdurulduğunda, arabellek verileri de hedef tabloya temizlendi. + +Veritabanı ve tablo adı için tek tırnak içinde boş dizeleri ayarlayabilirsiniz. Bu, bir hedef tablonun yokluğunu gösterir. Bu durumda, Veri Temizleme koşullarına ulaşıldığında, arabellek basitçe temizlenir. Bu, bir veri penceresini bellekte tutmak için yararlı olabilir. + +Bir arabellek tablosundan okurken, veriler hem arabellekten hem de hedef tablodan (varsa) işlenir. +Arabellek tabloları bir dizin desteklemediğini unutmayın. Başka bir deyişle, arabellekteki veriler tamamen taranır, bu da büyük arabellekler için yavaş olabilir. (Alt tablodaki veriler için, desteklediği dizin kullanılacaktır.) + +Arabellek tablosundaki sütun kümesi, alt tablodaki sütun kümesiyle eşleşmiyorsa, her iki tabloda da bulunan sütunların bir alt kümesi eklenir. + +Türleri arabellek tablo ve alt tablo sütunlarından biri için eşleşmiyorsa, sunucu günlüğüne bir hata iletisi girilir ve arabellek temizlenir. +Arabellek temizlendiğinde alt tablo yoksa aynı şey olur. + +Eğer bağımlı bir tablo ve Tampon tablo için ALTER çalıştırmak gerekiyorsa, ilk Tampon tablo silme, alt tablo için ALTER çalışan, sonra tekrar Tampon tablo oluşturma öneririz. + +Sunucu anormal şekilde yeniden başlatılırsa, arabellekteki veriler kaybolur. + +Son ve örnek arabellek tabloları için düzgün çalışmıyor. Bu koşullar hedef tabloya geçirilir, ancak arabellekte veri işlemek için kullanılmaz. Bu özellikler gerekiyorsa, hedef tablodan okurken yalnızca yazma için arabellek tablosunu kullanmanızı öneririz. + +Bir arabelleğe veri eklerken, arabelleklerden biri kilitlenir. Bir okuma işlemi aynı anda tablodan gerçekleştiriliyor, bu gecikmelere neden olur. + +Bir arabellek tablosuna eklenen veriler, alt tabloda farklı bir sırada ve farklı bloklarda sonuçlanabilir. Bu nedenle, bir arabellek tablo CollapsingMergeTree doğru yazmak için kullanmak zordur. Sorunları önlemek için şunları ayarlayabilirsiniz ‘num\_layers’ 1'e. + +Hedef tablo yinelenirse, bir arabellek tablosuna yazarken yinelenmiş tabloların bazı beklenen özellikleri kaybolur. Satır ve veri parçaları boyutlarda sipariş için rasgele değişiklikler veri çoğaltma güvenilir olması mümkün olmadığını ifade eden çalışma, kapanmasına neden ‘exactly once’ çoğaltılan tablolara yazın. + +Bu dezavantajlardan dolayı, nadir durumlarda yalnızca bir arabellek tablosu kullanmanızı önerebiliriz. + +Bir arabellek tablosu, bir zaman birimi üzerinden çok sayıda sunucudan çok fazla ekleme alındığında kullanılır ve ekleme işleminden önce veri arabelleğe alınamaz, bu da eklerin yeterince hızlı çalışamayacağı anlamına gelir. + +Arabellek tabloları için bile, her seferinde bir satır veri eklemek mantıklı olmadığını unutmayın. Bu, yalnızca saniyede birkaç bin satırlık bir hız üretirken, daha büyük veri blokları eklemek saniyede bir milyondan fazla satır üretebilir (bölüme bakın “Performance”). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/tr/engines/table-engines/special/dictionary.md b/docs/tr/engines/table-engines/special/dictionary.md new file mode 100644 index 00000000000..987bcf8e1c1 --- /dev/null +++ b/docs/tr/engines/table-engines/special/dictionary.md @@ -0,0 +1,97 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 35 +toc_title: "S\xF6zl\xFCk" +--- + +# Sözlük {#dictionary} + +Bu `Dictionary` motor görüntüler [sözlük](../../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) bir ClickHouse tablo olarak veri. + +Örnek olarak, bir sözlük düşünün `products` aşağıdaki yapılandırma ile: + +``` xml + + + products + + +
products
+ DSN=some-db-server + + + + 300 + 360 + + + + + + + product_id + + + title + String + + + + + +``` + +Sözlük verilerini sorgula: + +``` sql +SELECT + name, + type, + key, + attribute.names, + attribute.types, + bytes_allocated, + element_count, + source +FROM system.dictionaries +WHERE name = 'products' +``` + +``` text +┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ +│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ +└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ +``` + +Kullanabilirsiniz [dictGet\*](../../../sql-reference/functions/ext-dict-functions.md#ext_dict_functions) sözlük verilerini bu formatta almak için işlev. + +Bu görünüm, ham veri almanız gerektiğinde veya bir `JOIN` operasyon. Bu durumlar için şunları kullanabilirsiniz `Dictionary` bir tabloda sözlük verilerini görüntüleyen motor. + +Sözdizimi: + +``` sql +CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` +``` + +Kullanım örneği: + +``` sql +create table products (product_id UInt64, title String) Engine = Dictionary(products); +``` + + Ok + +Masada ne olduğuna bir bak. + +``` sql +select * from products limit 1; +``` + +``` text +┌────product_id─┬─title───────────┐ +│ 152689 │ Some item │ +└───────────────┴─────────────────┘ +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/tr/engines/table-engines/special/distributed.md b/docs/tr/engines/table-engines/special/distributed.md new file mode 100644 index 00000000000..d4ea832194b --- /dev/null +++ b/docs/tr/engines/table-engines/special/distributed.md @@ -0,0 +1,152 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 33 +toc_title: "Da\u011F\u0131l\u0131" +--- + +# Dağılı {#distributed} + +**Dağıtılmış altyapısı olan tablolar kendileri tarafından herhangi bir veri depolamaz**, ancak birden çok sunucuda dağıtılmış sorgu işleme izin verir. +Okuma otomatik olarak paralelleştirilir. Bir okuma sırasında, varsa uzak sunucularda tablo dizinleri kullanılır. + +Dağıtılmış motor parametreleri kabul eder: + +- sunucunun yapılandırma dosyasındaki küme adı + +- uzak veritabanı adı + +- uzak bir tablonun adı + +- (isteğe bağlı olarak) sharding anahtarı + +- (isteğe bağlı olarak) ilke adı, zaman uyumsuz göndermek için geçici dosyaları depolamak için kullanılacaktır + + Ayrıca bakınız: + + - `insert_distributed_sync` ayar + - [MergeTree](../mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) örnekler için + +Örnek: + +``` sql +Distributed(logs, default, hits[, sharding_key[, policy_name]]) +``` + +Veri tüm sunuculardan okunacak ‘logs’ küme, varsayılan değerden.kümedeki her sunucuda bulunan hits tablosu. +Veriler yalnızca okunmakla kalmaz, aynı zamanda uzak sunucularda kısmen işlenir (bunun mümkün olduğu ölçüde). +Örneğin, GROUP BY ile bir sorgu için uzak sunucularda veri toplanır ve toplama işlevlerinin Ara durumları istek sahibi sunucuya gönderilir. Daha sonra veriler daha fazla toplanacaktır. + +Veritabanı adı yerine, bir dize döndüren sabit bir ifade kullanabilirsiniz. Örneğin: currentDatabase (). + +logs – The cluster name in the server's config file. + +Kümeler şöyle ayarlanır: + +``` xml + + + + + 1 + + false + + example01-01-1 + 9000 + + + example01-01-2 + 9000 + + + + 2 + false + + example01-02-1 + 9000 + + + example01-02-2 + 1 + 9440 + + + + +``` + +Burada bir küme adı ile tanımlanır ‘logs’ bu, her biri iki kopya içeren iki parçadan oluşur. +Kırıklar, verilerin farklı bölümlerini içeren sunuculara başvurur (tüm verileri okumak için tüm kırıklara erişmeniz gerekir). +Yinelemeler sunucuları çoğaltılıyor (tüm verileri okumak için, yinelemelerden herhangi birinde verilere erişebilirsiniz). + +Küme adları nokta içermemelidir. + +Parametre `host`, `port` ve isteğe bağlı olarak `user`, `password`, `secure`, `compression` her sunucu için belirtilir: +- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. +- `port` – The TCP port for messenger activity (‘tcp\_port’ yapılandırmada, genellikle 9000 olarak ayarlanır). Http\_port ile karıştırmayın. +- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Erişim hakları](../../../operations/access-rights.md). +- `password` – The password for connecting to a remote server (not masked). Default value: empty string. +- `secure` - Bağlantı için ssl kullanın, genellikle de tanımlamanız gerekir `port` = 9440. Sunucu dinlem shouldeli `9440` ve doğru sertifikalara sahip. +- `compression` - Kullanım veri sıkıştırma. Varsayılan değer: true. + +When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [dengeleme](../../../operations/settings/settings.md#settings-load_balancing) ayar. +Sunucu ile bağlantı kurulmamışsa, kısa bir zaman aşımı ile bağlanma girişimi olacaktır. Bağlantı başarısız olursa, sonraki yineleme seçilir ve benzeri tüm yinelemeler için. Bağlantı girişimi tüm yinelemeler için başarısız olursa, girişimi aynı şekilde, birkaç kez tekrarlanır. +Bu esneklik lehine çalışır, ancak tam hataya dayanıklılık sağlamaz: uzak bir sunucu bağlantıyı kabul edebilir, ancak çalışmayabilir veya kötü çalışabilir. + +Parçalardan yalnızca birini belirtebilirsiniz (bu durumda, sorgu işleme dağıtılmış yerine uzak olarak adlandırılmalıdır) veya herhangi bir sayıda parçaya kadar. Her parçada, bir ila herhangi bir sayıda yinelemeyi belirtebilirsiniz. Her parça için farklı sayıda çoğaltma belirtebilirsiniz. + +Yapılandırmada istediğiniz kadar küme belirtebilirsiniz. + +Kümelerinizi görüntülemek için ‘system.clusters’ Tablo. + +Dağıtılmış motor, yerel bir sunucu gibi bir küme ile çalışmaya izin verir. Ancak, küme uzatılamaz: yapılandırmasını sunucu yapılandırma dosyasına yazmanız gerekir (tüm kümenin sunucuları için daha da iyisi). + +The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the ‘remote’ bunun yerine tablo işlevi. Bölümüne bakınız [Tablo fonksiyonları](../../../sql-reference/table-functions/index.md). + +Bir kümeye veri yazmak için iki yöntem vardır: + +İlk olarak, hangi sunucuların hangi verileri yazacağını ve her bir parçaya doğrudan yazmayı gerçekleştireceğini tanımlayabilirsiniz. Başka bir deyişle, dağıtılmış tablo içinde INSERT gerçekleştirmek “looks at”. Bu, konu alanının gereklilikleri nedeniyle önemsiz olmayan herhangi bir sharding şemasını kullanabileceğiniz için en esnek çözümdür. Bu aynı zamanda en uygun çözümdür, çünkü veriler farklı parçalara tamamen bağımsız olarak yazılabilir. + +İkinci olarak, dağıtılmış bir tabloda ekleme gerçekleştirebilirsiniz. Bu durumda, tablo eklenen verileri sunucuların kendisine dağıtacaktır. Dağıtılmış bir tabloya yazmak için, bir sharding anahtar kümesi (son parametre) olmalıdır. Ek olarak, yalnızca bir parça varsa, yazma işlemi sharding anahtarını belirtmeden çalışır, çünkü bu durumda hiçbir şey ifade etmez. + +Her parça yapılandırma dosyasında tanımlanan bir ağırlığa sahip olabilir. Varsayılan olarak, ağırlık bir eşittir. Veriler, parça ağırlığı ile orantılı miktarda parçalara dağıtılır. Örneğin, iki parça varsa ve birincisi 9'luk bir ağırlığa sahipse, ikincisi 10'luk bir ağırlığa sahipse, ilk satırların 9 / 19 parçası gönderilir ve ikincisi 10 / 19 gönderilir. + +Her shard olabilir ‘internal\_replication’ yapılandırma dosyasında tanımlanan parametre. + +Bu parametre şu şekilde ayarlanırsa ‘true’, yazma işlemi ilk sağlıklı yinelemeyi seçer ve ona veri yazar. Dağıtılmış tablo ise bu alternatifi kullanın “looks at” çoğaltılan tablolar. Başka bir deyişle, verilerin yazılacağı tablo kendilerini çoğaltacaktır. + +Olarak ayarlan ifmışsa ‘false’ (varsayılan), veriler tüm kopyalara yazılır. Özünde, bu, dağıtılmış tablonun verilerin kendisini çoğalttığı anlamına gelir. Bu, çoğaltılmış tabloları kullanmaktan daha kötüdür, çünkü kopyaların tutarlılığı denetlenmez ve zamanla biraz farklı veriler içerirler. + +Bir veri satırının gönderildiği parçayı seçmek için, parçalama ifadesi analiz edilir ve kalan kısmı, parçaların toplam ağırlığına bölünmesinden alınır. Satır, kalanların yarı aralığına karşılık gelen parçaya gönderilir. ‘prev\_weight’ -e doğru ‘prev\_weights + weight’, nere ‘prev\_weights’ en küçük sayıya sahip parçaların toplam ağırlığı ve ‘weight’ bu parçanın ağırlığı. Örneğin, iki parça varsa ve birincisi 9'luk bir ağırlığa sahipse, ikincisi 10'luk bir ağırlığa sahipse, satır \[0, 9) aralığından kalanlar için ilk parçaya ve ikincisine \[9, 19) aralığından kalanlar için gönderilecektir. + +Sharding ifadesi, bir tamsayı döndüren sabitler ve tablo sütunlarından herhangi bir ifade olabilir. Örneğin, ifadeyi kullanabilirsiniz ‘rand()’ verilerin rastgele dağılımı için veya ‘UserID’ kullanıcının kimliğinin bölünmesinden kalanın dağıtımı için (daha sonra tek bir kullanıcının verileri, kullanıcılar tarafından çalışmayı ve katılmayı basitleştiren tek bir parçada bulunur). Sütunlardan biri yeterince eşit olarak dağıtılmazsa, onu bir karma işleve sarabilirsiniz: ınthash64(Userıd). + +Bölüm'den basit bir hatırlatma, sharding için sınırlı bir çözümdür ve her zaman uygun değildir. Orta ve büyük hacimlerde veri (düzinelerce sunucu) için çalışır, ancak çok büyük hacimlerde veri (yüzlerce sunucu veya daha fazla) için değildir. İkinci durumda, dağıtılmış tablolarda girdileri kullanmak yerine konu alanı tarafından gerekli olan sharding şemasını kullanın. + +SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. + +Aşağıdaki durumlarda sharding şeması hakkında endişelenmelisiniz: + +- Belirli bir anahtar tarafından veri (veya birleştirme) birleştirme gerektiren sorgular kullanılır. Veriler bu anahtar tarafından parçalanırsa, GLOBAL IN veya GLOBAL JOİN yerine local IN veya JOİN kullanabilirsiniz, bu da çok daha etkilidir. +- Çok sayıda küçük Sorgu ile çok sayıda sunucu (yüzlerce veya daha fazla) kullanılır (bireysel müşterilerin sorguları - web siteleri, reklamverenler veya ortaklar). Küçük sorguların tüm kümeyi etkilememesi için, tek bir istemci için tek bir parça üzerinde veri bulmak mantıklıdır. Alternatif olarak, Yandex'te yaptığımız gibi.Metrica, iki seviyeli sharding kurabilirsiniz: tüm kümeyi bölün “layers”, bir katmanın birden fazla parçadan oluşabileceği yer. Tek bir istemci için veriler tek bir katmanda bulunur, ancak kırıklar gerektiğinde bir katmana eklenebilir ve veriler rastgele dağıtılır. Her katman için dağıtılmış tablolar oluşturulur ve genel sorgular için tek bir paylaşılan dağıtılmış tablo oluşturulur. + +Veriler zaman uyumsuz olarak yazılır. Tabloya eklendiğinde, veri bloğu sadece yerel dosya sistemine yazılır. Veriler en kısa sürede arka planda uzak sunuculara gönderilir. Veri gönderme süresi tarafından yönetilir [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) ve [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) ayarlar. Bu `Distributed` motor ayrı ayrı eklenen verilerle her dosyayı gönderir, ancak toplu dosya gönderme etkinleştirebilirsiniz [distributed\_directory\_monitor\_batch\_ınserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) ayar. Bu ayar, yerel sunucu ve ağ kaynaklarını daha iyi kullanarak küme performansını artırır. Tablo dizinindeki dosyaların listesini (gönderilmeyi bekleyen veriler) kontrol ederek verilerin başarıyla gönderilip gönderilmediğini kontrol etmelisiniz: `/var/lib/clickhouse/data/database/table/`. + +Sunucu varlığını durdurdu veya (örneğin, bir aygıt arızasından sonra) dağıtılmış bir tabloya bir ekleme sonra kaba bir yeniden başlatma vardı, eklenen veriler kaybolabilir. Tablo dizininde bozuk bir veri parçası tespit edilirse, ‘broken’ alt dizin ve artık kullanılmıyor. + +Max\_parallel\_replicas seçeneği etkinleştirildiğinde, sorgu işleme tek bir parça içindeki tüm yinelemeler arasında paralelleştirilir. Daha fazla bilgi için bölüme bakın [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). + +## Sanal Sütunlar {#virtual-columns} + +- `_shard_num` — Contains the `shard_num` (itibaren `system.clusters`). Tür: [Uİnt32](../../../sql-reference/data-types/int-uint.md). + +!!! note "Not" + Beri [`remote`](../../../sql-reference/table-functions/remote.md)/`cluster` tablo işlevleri DAHİLİ olarak aynı dağıtılmış altyapının geçici örneğini oluşturur, `_shard_num` de kullanılabilir. + +**Ayrıca Bakınız** + +- [Sanal sütunlar](index.md#table_engines-virtual_columns) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/tr/engines/table-engines/special/external-data.md b/docs/tr/engines/table-engines/special/external-data.md new file mode 100644 index 00000000000..3dc7863c1b3 --- /dev/null +++ b/docs/tr/engines/table-engines/special/external-data.md @@ -0,0 +1,68 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 34 +toc_title: "D\u0131\u015F veri" +--- + +# Sorgu işleme için harici veriler {#external-data-for-query-processing} + +ClickHouse bir sunucu bir SELECT sorgusu ile birlikte bir sorgu işlemek için gerekli olan verileri gönderme sağlar. Bu veriler geçici bir tabloya konur (bölüme bakın “Temporary tables”) ve sorguda kullanılabilir (örneğin, işleçlerde). + +Örneğin, önemli kullanıcı tanımlayıcılarına sahip bir metin dosyanız varsa, bu listeyi süzme kullanan bir sorgu ile birlikte sunucuya yükleyebilirsiniz. + +Büyük hacimli dış verilerle birden fazla sorgu çalıştırmanız gerekiyorsa, bu özelliği kullanmayın. Verileri vaktinden önce DB'YE yüklemek daha iyidir. + +Harici veriler komut satırı istemcisi (etkileşimli olmayan modda) veya HTTP arabirimi kullanılarak yüklenebilir. + +Komut satırı istemcisinde, formatta bir parametreler bölümü belirtebilirsiniz + +``` bash +--external --file=... [--name=...] [--format=...] [--types=...|--structure=...] +``` + +İletilen tablo sayısı için bunun gibi birden çok bölümünüz olabilir. + +**–external** – Marks the beginning of a clause. +**–file** – Path to the file with the table dump, or -, which refers to stdin. +Stdın'den yalnızca tek bir tablo alınabilir. + +Aşağıdaki parametreler isteğe bağlıdır: **–name**– Name of the table. If omitted, \_data is used. +**–format** – Data format in the file. If omitted, TabSeparated is used. + +Aşağıdaki parametrelerden biri gereklidir:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … +**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Sütun adlarını ve türlerini tanımlar. + +Belirtilen dosyalar ‘file’ belirtilen biçimde ayrıştırılır ‘format’, belirtilen veri türlerini kullanarak ‘types’ veya ‘structure’. Tablo sunucuya yüklenecek ve orada adı ile geçici bir tablo olarak erişilebilir ‘name’. + +Örnekler: + +``` bash +$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 +849897 +$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +HTTP arabirimini kullanırken, dış veriler çok parçalı/form veri biçiminde geçirilir. Her tablo ayrı bir dosya olarak iletilir. Tablo adı dosya adından alınır. Bu ‘query\_string’ parametreleri geçirilir ‘name\_format’, ‘name\_types’, ve ‘name\_structure’, nere ‘name’ bu parametreler karşılık gelen tablonun adıdır. Parametrelerin anlamı, komut satırı istemcisini kullanırken olduğu gibi aynıdır. + +Örnek: + +``` bash +$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv + +$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' +/bin/sh 20 +/bin/false 5 +/bin/bash 4 +/usr/sbin/nologin 1 +/bin/sync 1 +``` + +Dağıtılmış sorgu işleme için geçici tablolar tüm uzak sunuculara gönderilir. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/tr/engines/table-engines/special/file.md b/docs/tr/engines/table-engines/special/file.md new file mode 100644 index 00000000000..4d3d99c2cf3 --- /dev/null +++ b/docs/tr/engines/table-engines/special/file.md @@ -0,0 +1,90 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: Dosya +--- + +# Dosya {#table_engines-file} + +Dosya tablosu altyapısı, verileri desteklenen dosyalardan birinde tutar [Dosya +biçimliler](../../../interfaces/formats.md#formats) (TabSeparated, yerli, vb.). + +Kullanım örnekleri: + +- Clickhouse'dan dosyaya veri aktarımı. +- Verileri bir biçimden diğerine dönüştürün. +- Bir diskte bir dosya düzenleme yoluyla ClickHouse veri güncelleme. + +## ClickHouse sunucusunda kullanım {#usage-in-clickhouse-server} + +``` sql +File(Format) +``` + +Bu `Format` parametre kullanılabilir dosya biçimlerinden birini belirtir. Gerçekleştirmek +`SELECT` sorgular, biçim giriş için desteklenmeli ve gerçekleştirmek için +`INSERT` queries – for output. The available formats are listed in the +[Biçimliler](../../../interfaces/formats.md#formats) bölme. + +ClickHouse dosya sistemi yolunu belirtmek için izin vermiyor`File`. Tarafından tanımlanan klasörü kullan willacaktır [yol](../../../operations/server-configuration-parameters/settings.md) sunucu yapılandırmasında ayarlama. + +Kullanarak tablo oluştururken `File(Format)` bu klasörde boş bir alt dizin oluşturur. Veri o tabloya yazıldığında, içine konur `data.Format` bu alt dizinde dosya. + +Bu alt klasörü ve dosyayı sunucu dosya sisteminde el ile oluşturabilir ve sonra [ATTACH](../../../sql-reference/statements/misc.md) eşleşen ada sahip tablo bilgilerine, böylece bu dosyadan veri sorgulayabilirsiniz. + +!!! warning "Uyarıcı" + Bu işlevselliğe dikkat edin, çünkü ClickHouse bu tür dosyalarda harici değişiklikleri izlemez. ClickHouse ve ClickHouse dışında eşzamanlı yazma sonucu tanımsızdır. + +**Örnek:** + +**1.** Set up the `file_engine_table` Tablo: + +``` sql +CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) +``` + +Varsayılan olarak ClickHouse klasör oluşturur `/var/lib/clickhouse/data/default/file_engine_table`. + +**2.** El ile oluştur `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` içerme: + +``` bash +$ cat data.TabSeparated +one 1 +two 2 +``` + +**3.** Verileri sorgula: + +``` sql +SELECT * FROM file_engine_table +``` + +``` text +┌─name─┬─value─┐ +│ one │ 1 │ +│ two │ 2 │ +└──────┴───────┘ +``` + +## Clickhouse'da kullanım-yerel {#usage-in-clickhouse-local} + +İçinde [clickhouse-yerel](../../../operations/utilities/clickhouse-local.md) Dosya motoru ek olarak dosya yolunu kabul eder `Format`. Varsayılan giriş / çıkış akışları gibi sayısal veya insan tarafından okunabilir isimler kullanılarak belirtilebilir `0` veya `stdin`, `1` veya `stdout`. +**Örnek:** + +``` bash +$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" +``` + +## Uygulama Detayları {#details-of-implementation} + +- Çoklu `SELECT` sorgular aynı anda yapılabilir, ancak `INSERT` sorgular birbirini bekler. +- Tarafından yeni dosya oluşturma desteklenen `INSERT` sorgu. +- Dosya varsa, `INSERT` içinde yeni değerler ekler. +- Desteklenmiyor: + - `ALTER` + - `SELECT ... SAMPLE` + - Dizinler + - Çoğalma + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/tr/engines/table-engines/special/generate.md b/docs/tr/engines/table-engines/special/generate.md new file mode 100644 index 00000000000..4147fd00647 --- /dev/null +++ b/docs/tr/engines/table-engines/special/generate.md @@ -0,0 +1,61 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: GenerateRandom +--- + +# Generaterandom {#table_engines-generate} + +GenerateRandom tablo motoru, verilen tablo şeması için rasgele veri üretir. + +Kullanım örnekleri: + +- Tekrarlanabilir büyük tabloyu doldurmak için testte kullanın. +- Fuzzing testleri için rastgele girdi oluşturun. + +## ClickHouse sunucusunda kullanım {#usage-in-clickhouse-server} + +``` sql +ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) +``` + +Bu `max_array_length` ve `max_string_length` parametreler tüm maksimum uzunluğu belirtin +oluşturulan verilerde dizi sütunları ve dizeleri. + +Tablo motoru oluşturmak yalnızca destekler `SELECT` sorgular. + +Tüm destekler [Veri türleri](../../../sql-reference/data-types/index.md) dışında bir tabloda saklanabilir `LowCardinality` ve `AggregateFunction`. + +**Örnek:** + +**1.** Set up the `generate_engine_table` Tablo: + +``` sql +CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) +``` + +**2.** Verileri sorgula: + +``` sql +SELECT * FROM generate_engine_table LIMIT 3 +``` + +``` text +┌─name─┬──────value─┐ +│ c4xJ │ 1412771199 │ +│ r │ 1791099446 │ +│ 7#$ │ 124312908 │ +└──────┴────────────┘ +``` + +## Uygulama Detayları {#details-of-implementation} + +- Desteklenmiyor: + - `ALTER` + - `SELECT ... SAMPLE` + - `INSERT` + - Dizinler + - Çoğalma + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/tr/engines/table-engines/special/index.md b/docs/tr/engines/table-engines/special/index.md new file mode 100644 index 00000000000..641135eb1ce --- /dev/null +++ b/docs/tr/engines/table-engines/special/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\xD6zellikli" +toc_priority: 31 +--- + + diff --git a/docs/tr/engines/table-engines/special/join.md b/docs/tr/engines/table-engines/special/join.md new file mode 100644 index 00000000000..bc9182d9823 --- /dev/null +++ b/docs/tr/engines/table-engines/special/join.md @@ -0,0 +1,111 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: Katmak +--- + +# Katmak {#join} + +Kullanılmak üzere hazırlanmış veri yapısı [JOIN](../../../sql-reference/statements/select/join.md#select-join) harekat. + +## Tablo oluşturma {#creating-a-table} + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], +) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) +``` + +Ayrıntılı açıklamasına bakın [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) sorgu. + +**Motor Parametreleri** + +- `join_strictness` – [Katılık katılın](../../../sql-reference/statements/select/join.md#select-join-strictness). +- `join_type` – [Birleştirme türü](../../../sql-reference/statements/select/join.md#select-join-types). +- `k1[, k2, ...]` – Key columns from the `USING` fık thera: `JOIN` işlemi yapılmamaktadır. + +Girmek `join_strictness` ve `join_type` tırnak işaretleri olmadan parametreler, örneğin, `Join(ANY, LEFT, col1)`. Onlar eşleşmelidir `JOIN` tablo için kullanılacak işlem. Parametreler eşleşmezse, ClickHouse bir istisna atmaz ve yanlış veri döndürebilir. + +## Tablo Kullanımı {#table-usage} + +### Örnek {#example} + +Sol taraftaki tablo oluşturma: + +``` sql +CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog +``` + +``` sql +INSERT INTO id_val VALUES (1,11)(2,12)(3,13) +``` + +Sağ tarafı oluşturma `Join` Tablo: + +``` sql +CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) +``` + +``` sql +INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) +``` + +Tabloları birleştirme: + +``` sql +SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 +``` + +``` text +┌─id─┬─val─┬─id_val_join.val─┐ +│ 1 │ 11 │ 21 │ +│ 2 │ 12 │ ᴺᵁᴸᴸ │ +│ 3 │ 13 │ 23 │ +└────┴─────┴─────────────────┘ +``` + +Alternatif olarak, veri alabilirsiniz `Join` tablo, birleştirme anahtarı değerini belirterek: + +``` sql +SELECT joinGet('id_val_join', 'val', toUInt32(1)) +``` + +``` text +┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ +│ 21 │ +└────────────────────────────────────────────┘ +``` + +### Veri seçme ve ekleme {#selecting-and-inserting-data} + +Kullanabilirsiniz `INSERT` veri eklemek için sorgular `Join`- motor masaları. Tablo ile oluşturulmuş ise `ANY` katılık, yinelenen anahtarlar için veriler göz ardı edilir. İle... `ALL` katılık, tüm satırlar eklenir. + +Gerçekleştir aemezsiniz `SELECT` doğrudan tablodan sorgulayın. Bunun yerine, aşağıdaki yöntemlerden birini kullanın: + +- Tabloyu sağ tarafa yerleştirin. `JOIN` yan. +- Call the [joinGet](../../../sql-reference/functions/other-functions.md#joinget) tablodan bir sözlükten aynı şekilde veri ayıklamanızı sağlayan işlev. + +### Sınırlamalar ve Ayarlar {#join-limitations-and-settings} + +Bir tablo oluştururken aşağıdaki ayarlar uygulanır: + +- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) +- [max\_rows\_in\_join](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) +- [max\_bytes\_in\_join](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) +- [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) +- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) + +Bu `Join`- motor tabloları kullanılamaz `GLOBAL JOIN` harekat. + +Bu `Join`- motor kullanımına izin verir [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) ayarı `CREATE TABLE` deyim. Ve [SELECT](../../../sql-reference/statements/select/index.md) sorgu kullanımına izin verir `join_use_nulls` çok. Eğer farklı varsa `join_use_nulls` ayarlar, tablo birleştirme bir hata alabilirsiniz. Bu katılmak türüne bağlıdır. Kullandığınızda [joinGet](../../../sql-reference/functions/other-functions.md#joinget) fonksiyonu, aynı kullanmak zorunda `join_use_nulls` ayarı `CRATE TABLE` ve `SELECT` deyimler. + +## Veri Depolama {#data-storage} + +`Join` tablo verileri her zaman RAM'de bulunur. Bir tabloya satır eklerken, sunucu yeniden başlatıldığında geri yüklenebilir, böylece ClickHouse disk üzerindeki dizine veri bloklarını yazar. + +Sunucu yanlış yeniden başlatılırsa, diskteki veri bloğu kaybolabilir veya zarar görebilir. Bu durumda, dosyayı hasarlı verilerle el ile silmeniz gerekebilir. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/tr/engines/table-engines/special/materializedview.md b/docs/tr/engines/table-engines/special/materializedview.md new file mode 100644 index 00000000000..485b5ae7d14 --- /dev/null +++ b/docs/tr/engines/table-engines/special/materializedview.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: MaterializedView +--- + +# Materializedview {#materializedview} + +Somut görünümler uygulamak için kullanılır (Daha fazla bilgi için bkz . [CREATE TABLE](../../../sql-reference/statements/create.md)). Verileri depolamak için, görünümü oluştururken belirtilen farklı bir motor kullanır. Bir tablodan okurken, sadece bu motoru kullanır. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/tr/engines/table-engines/special/memory.md b/docs/tr/engines/table-engines/special/memory.md new file mode 100644 index 00000000000..3c88cade274 --- /dev/null +++ b/docs/tr/engines/table-engines/special/memory.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "Haf\u0131za" +--- + +# Hafıza {#memory} + +Bellek altyapısı verileri RAM, sıkıştırılmamış biçimde depolar. Veri okunduğunda alınan tam olarak aynı biçimde saklanır. Başka bir deyişle, bu tablodan okuma tamamen ücretsizdir. +Eşzamanlı veri erişimi senkronize edilir. Kilitler kısa: okuma ve yazma işlemleri birbirini engellemez. +Dizinler desteklenmiyor. Okuma paralelleştirilmiştir. +Basit sorgularda maksimum üretkenliğe (10 GB/sn'den fazla) ulaşılır, çünkü diskten okuma, açma veya veri serisini kaldırma yoktur. (Birçok durumda MergeTree motorunun verimliliğinin neredeyse yüksek olduğunu unutmamalıyız.) +Bir sunucu yeniden başlatılırken, veri tablodan kaybolur ve tablo boş olur. +Normalde, bu tablo motorunu kullanmak haklı değildir. Bununla birlikte, testler ve nispeten az sayıda satırda (yaklaşık 100.000.000'a kadar) maksimum hızın gerekli olduğu görevler için kullanılabilir. + +Bellek motoru, harici sorgu verilerine sahip geçici tablolar için sistem tarafından kullanılır (bkz. “External data for processing a query”) ve GLOBAL In uygulanması için (bkz. “IN operators”). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/tr/engines/table-engines/special/merge.md b/docs/tr/engines/table-engines/special/merge.md new file mode 100644 index 00000000000..a707954c13f --- /dev/null +++ b/docs/tr/engines/table-engines/special/merge.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: "Birle\u015Ftirmek" +--- + +# Birleştirmek {#merge} + +Bu `Merge` motor (ile karıştırılmamalıdır `MergeTree`) verileri kendisi saklamaz, ancak aynı anda herhangi bir sayıda başka tablodan okumaya izin verir. +Okuma otomatik olarak paralelleştirilir. Bir tabloya yazma desteklenmiyor. Okurken, gerçekten okunmakta olan tabloların dizinleri varsa kullanılır. +Bu `Merge` motor parametreleri kabul eder: veritabanı adı ve tablolar için düzenli ifade. + +Örnek: + +``` sql +Merge(hits, '^WatchLog') +``` + +Veri tablolardan okunacak `hits` düzenli ifadeyle eşleşen adlara sahip veritabanı ‘`^WatchLog`’. + +Veritabanı adı yerine, bir dize döndüren sabit bir ifade kullanabilirsiniz. Mesela, `currentDatabase()`. + +Regular expressions — [re2](https://github.com/google/re2) (pcre bir alt kümesini destekler), büyük / küçük harf duyarlı. +Düzenli ifadelerde kaçan sembollerle ilgili notlara bakın “match” bölme. + +Okumak için tabloları seçerken, `Merge` regex ile eşleşse bile tablonun kendisi seçilmeyecektir. Bu döngülerden kaçınmaktır. +İki tane oluşturmak mümkündür `Merge` sonsuza kadar birbirlerinin verilerini okumaya çalışacak tablolar, ancak bu iyi bir fikir değil. + +Kullanmak için tipik bir yol `Merge` motor çok sayıda çalışma içindir `TinyLog` tablolar tek bir tablo ile sanki. + +Örnek 2: + +Diyelim ki eski bir tablonuz (WatchLog\_old) var ve verileri yeni bir tabloya (WatchLog\_new) taşımadan bölümlemeyi değiştirmeye karar verdiniz ve her iki tablodaki verileri görmeniz gerekiyor. + +``` sql +CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree(date, (UserId, EventType), 8192); +INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); + +CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) +ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; +INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); + +CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); + +SELECT * +FROM WatchLog +``` + +``` text +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-01 │ 1 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ +│ 2018-01-02 │ 2 │ hit │ 3 │ +└────────────┴────────┴───────────┴─────┘ +``` + +## Sanal Sütunlar {#virtual-columns} + +- `_table` — Contains the name of the table from which data was read. Type: [Dize](../../../sql-reference/data-types/string.md). + + Sabit koşulları ayarlayabilirsiniz `_table` in the `WHERE/PREWHERE` fıkra (sı (örneğin, `WHERE _table='xyz'`). Bu durumda, okuma işlemi yalnızca koşulun açık olduğu tablolar için gerçekleştirilir `_table` memnun olduğunu, bu yüzden `_table` sütun bir dizin görevi görür. + +**Ayrıca Bakınız** + +- [Sanal sütunlar](index.md#table_engines-virtual_columns) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/tr/engines/table-engines/special/null.md b/docs/tr/engines/table-engines/special/null.md new file mode 100644 index 00000000000..da7e38eddf0 --- /dev/null +++ b/docs/tr/engines/table-engines/special/null.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "Bo\u015F" +--- + +# Boş {#null} + +Boş bir tabloya yazarken, veri yoksayılır. Boş bir tablodan okurken, yanıt boştur. + +Ancak, boş bir tablo üzerinde materialized bir görünüm oluşturabilirsiniz. Böylece tabloya yazılan veriler görünümde sona erecek. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/tr/engines/table-engines/special/set.md b/docs/tr/engines/table-engines/special/set.md new file mode 100644 index 00000000000..151f98e5c54 --- /dev/null +++ b/docs/tr/engines/table-engines/special/set.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: Koymak +--- + +# Koymak {#set} + +Her zaman RAM olan bir veri kümesi. In operatörünün sağ tarafında kullanılmak üzere tasarlanmıştır (bölüme bakın “IN operators”). + +Tabloya veri eklemek için INSERT kullanabilirsiniz. Veri kümesine yeni öğeler eklenirken, yinelenenler göz ardı edilir. +Ancak tablodan seçim yapamazsınız. Verileri almak için tek yol, IN operatörünün sağ yarısında kullanmaktır. + +Veri her zaman RAM yer almaktadır. INSERT için, eklenen veri blokları da diskteki tabloların dizinine yazılır. Sunucuyu başlatırken, bu veriler RAM'e yüklenir. Başka bir deyişle, yeniden başlattıktan sonra veriler yerinde kalır. + +Kaba bir sunucu yeniden başlatma için diskteki veri bloğu kaybolabilir veya zarar görebilir. İkinci durumda, dosyayı hasarlı verilerle el ile silmeniz gerekebilir. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/tr/engines/table-engines/special/url.md b/docs/tr/engines/table-engines/special/url.md new file mode 100644 index 00000000000..2632f1e5046 --- /dev/null +++ b/docs/tr/engines/table-engines/special/url.md @@ -0,0 +1,82 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: URL +--- + +# URL (URL, Biçim) {#table_engines-url} + +Uzak bir HTTP/HTTPS sunucusundaki verileri yönetir. Bu motor benzer +to the [Dosya](file.md) motor. + +## ClickHouse sunucusunda motoru kullanma {#using-the-engine-in-the-clickhouse-server} + +Bu `format` Clickhouse'un kullanabileceği bir tane olmalı +`SELECT` sorgular ve gerekirse `INSERTs`. Desteklenen formatların tam listesi için bkz. +[Biçimliler](../../../interfaces/formats.md#formats). + +Bu `URL` tekdüzen bir kaynak Bulucu yapısına uygun olmalıdır. Belirtilen URL bir sunucuya işaret etmelidir +bu HTTP veya HTTPS kullanır. Bu herhangi bir gerektirmez +sunucudan yanıt almak için ek başlıklar. + +`INSERT` ve `SELECT` sorgular dönüştürülür `POST` ve `GET` istemler, +sırasıyla. İşleme için `POST` istekleri, uzak sunucu desteklemesi gerekir +[Yığınlı aktarım kodlaması](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). + +Kullanarak HTTP get yönlendirme şerbetçiotu sayısını sınırlayabilirsiniz [max\_http\_get\_redirects](../../../operations/settings/settings.md#setting-max_http_get_redirects) ayar. + +**Örnek:** + +**1.** Create a `url_engine_table` sunucuda tablo : + +``` sql +CREATE TABLE url_engine_table (word String, value UInt64) +ENGINE=URL('http://127.0.0.1:12345/', CSV) +``` + +**2.** Standart Python 3 araçlarını kullanarak temel bir HTTP Sunucusu oluşturun ve +Başlat: + +``` python3 +from http.server import BaseHTTPRequestHandler, HTTPServer + +class CSVHTTPServer(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header('Content-type', 'text/csv') + self.end_headers() + + self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) + +if __name__ == "__main__": + server_address = ('127.0.0.1', 12345) + HTTPServer(server_address, CSVHTTPServer).serve_forever() +``` + +``` bash +$ python3 server.py +``` + +**3.** Veri iste: + +``` sql +SELECT * FROM url_engine_table +``` + +``` text +┌─word──┬─value─┐ +│ Hello │ 1 │ +│ World │ 2 │ +└───────┴───────┘ +``` + +## Uygulama Detayları {#details-of-implementation} + +- Okuma ve yazma paralel olabilir +- Desteklenmiyor: + - `ALTER` ve `SELECT...SAMPLE` harekat. + - Dizinler. + - Çoğalma. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/tr/engines/table-engines/special/view.md b/docs/tr/engines/table-engines/special/view.md new file mode 100644 index 00000000000..294477824a3 --- /dev/null +++ b/docs/tr/engines/table-engines/special/view.md @@ -0,0 +1,12 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "G\xF6r\xFCn\xFCm" +--- + +# Görünüm {#table_engines-view} + +Görünümler uygulamak için kullanılır (Daha fazla bilgi için bkz. `CREATE VIEW query`). Verileri saklamaz, ancak yalnızca belirtilen `SELECT` sorgu. Bir tablodan okurken, bu sorguyu çalıştırır (ve gereksiz tüm sütunları sorgudan siler). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/tr/engines/table_engines/index.md b/docs/tr/engines/table_engines/index.md deleted file mode 100644 index fad3823453c..00000000000 --- a/docs/tr/engines/table_engines/index.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "Masa Motorlar\u0131" -toc_priority: 26 -toc_title: "Giri\u015F" ---- - -# Masa Motorları {#table_engines} - -Tablo motoru (tablo türü) belirler: - -- Verilerin nasıl ve nerede depolandığı, nereye yazılacağı ve nereden okunacağı. -- Hangi sorgular desteklenir ve nasıl. -- Eşzamanlı veri erişimi. -- Varsa indeks uselerin kullanımı. -- Çok iş parçacıklı istek yürütme mümkün olup olmadığı. -- Veri çoğaltma parametreleri. - -## Motor Aileleri {#engine-families} - -### MergeTree {#mergetree} - -Yüksek yük görevleri için en evrensel ve fonksiyonel masa motorları. Bu motorlar tarafından paylaşılan özellik, sonraki arka plan veri işleme ile hızlı veri ekleme ' dir. `MergeTree` aile motorları destek veri çoğaltma (ile [Çoğaltıyordu\*](mergetree_family/replication.md) sürümleri), bölümleme ve diğer özellikler diğer motorlarda desteklenmez. - -Ailede motorlar: - -- [MergeTree](mergetree_family/mergetree.md) -- [ReplacingMergeTree](mergetree_family/replacingmergetree.md) -- [SummingMergeTree](mergetree_family/summingmergetree.md) -- [AggregatingMergeTree](mergetree_family/aggregatingmergetree.md) -- [CollapsingMergeTree](mergetree_family/collapsingmergetree.md) -- [VersionedCollapsingMergeTree](mergetree_family/versionedcollapsingmergetree.md) -- [Graphıtemergetree](mergetree_family/graphitemergetree.md) - -### Günlük {#log} - -Hafiflik [motorlar](log_family/index.md) minimum işlevsellik ile. Birçok küçük tabloyu (yaklaşık 1 milyon satıra kadar) hızlı bir şekilde yazmanız ve daha sonra bir bütün olarak okumanız gerektiğinde en etkili olanlardır. - -Ailede motorlar: - -- [TinyLog](log_family/tinylog.md) -- [StripeLog](log_family/stripelog.md) -- [Günlük](log_family/log.md) - -### Entegrasyon Motorları {#integration-engines} - -Diğer veri depolama ve işleme sistemleri ile iletişim kurmak için motorlar. - -Ailede motorlar: - -- [Kafka](integrations/kafka.md) -- [MySQL](integrations/mysql.md) -- [ODBC](integrations/odbc.md) -- [JDBC](integrations/jdbc.md) -- [HDFS](integrations/hdfs.md) - -### Özel Motorlar {#special-engines} - -Ailede motorlar: - -- [Dağılı](special/distributed.md) -- [MaterializedView](special/materializedview.md) -- [Sözlük](special/dictionary.md) -- [Birleştirmek](special/merge.md) -- [Dosya](special/file.md) -- [Boş](special/null.md) -- [Koymak](special/set.md) -- [Katmak](special/join.md) -- [URL](special/url.md) -- [Görünüm](special/view.md) -- [Bellek](special/memory.md) -- [Arabellek](special/buffer.md) - -## Sanal Sütunlar {#table_engines-virtual-columns} - -Sanal sütun, motor kaynak kodunda tanımlanan ayrılmaz bir tablo altyapısı özniteliğidir. - -Sanal sütunları belirtmemelisiniz `CREATE TABLE` sorgula ve onları göremezsin `SHOW CREATE TABLE` ve `DESCRIBE TABLE` sorgu sonuçları. Sanal sütunlar da salt okunur, bu nedenle sanal sütunlara veri ekleyemezsiniz. - -Sanal bir sütundan veri seçmek için, adını `SELECT` sorgu. `SELECT *` sanal sütunlardan değerler döndürmez. - -Tablo sanal sütunlarından biriyle aynı ada sahip bir sütuna sahip bir tablo oluşturursanız, sanal sütuna erişilemez hale gelir. Bunu yapmayı önermiyoruz. Çakışmaları önlemek için, sanal sütun adları genellikle bir alt çizgi ile öneki. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/) diff --git a/docs/tr/engines/table_engines/integrations/hdfs.md b/docs/tr/engines/table_engines/integrations/hdfs.md deleted file mode 100644 index 42e1e31b80f..00000000000 --- a/docs/tr/engines/table_engines/integrations/hdfs.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 36 -toc_title: HDFS ---- - -# HDFS {#table_engines-hdfs} - -Bu motor ile entegrasyon sağlar [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) üzerinde veri Yönet allowingilmesine izin vererek ekosist dataem [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)ClickHouse aracılığıyla. Bu motor benzer -to the [Dosya](../special/file.md) ve [URL](../special/url.md) motorlar, ancak hadoop özgü özellikleri sağlar. - -## Kullanma {#usage} - -``` sql -ENGINE = HDFS(URI, format) -``` - -Bu `URI` parametre, HDFS'DEKİ tüm dosya URI'SIDIR. -Bu `format` parametre kullanılabilir dosya biçimlerinden birini belirtir. Gerçekleştirmek -`SELECT` sorgular, biçim giriş için desteklenmeli ve gerçekleştirmek için -`INSERT` queries – for output. The available formats are listed in the -[Biçimliler](../../../interfaces/formats.md#formats) bölme. -Yol kısmı `URI` globs içerebilir. Bu durumda tablo salt okunur olurdu. - -**Örnek:** - -**1.** Set up the `hdfs_engine_table` Tablo: - -``` sql -CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV') -``` - -**2.** Fil filel file: - -``` sql -INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3) -``` - -**3.** Verileri sorgula: - -``` sql -SELECT * FROM hdfs_engine_table LIMIT 2 -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Uygulama Detayları {#implementation-details} - -- Okuma ve yazma paralel olabilir -- Desteklenmiyor: - - `ALTER` ve `SELECT...SAMPLE` harekat. - - Dizinler. - - Çoğalma. - -**Yolda Globs** - -Birden çok yol bileşenleri globs olabilir. İşlenmek için dosya var olmalı ve tüm yol deseniyle eşleşmelidir. Sırasında dosyaların listelen ofmesini belirler `SELECT` (not at `CREATE` an). - -- `*` — Substitutes any number of any characters except `/` boş dize dahil. -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -İle yapılar `{}` benzer olan [uzak](../../../sql_reference/table_functions/remote.md) tablo işlevi. - -**Örnek** - -1. HDFS'DE aşağıdaki Urı'lerle TSV formatında birkaç dosyamız olduğunu varsayalım: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. Altı dosyadan oluşan bir tablo oluşturmanın birkaç yolu vardır: - - - -``` sql -CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') -``` - -Başka bir yol: - -``` sql -CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') -``` - -Tablo, her iki dizindeki tüm dosyalardan oluşur (tüm dosyalar, sorguda açıklanan biçimi ve şemayı karşılamalıdır): - -``` sql -CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV') -``` - -!!! warning "Uyarıcı" - Dosyaların listelenmesi, önde gelen sıfırlarla sayı aralıkları içeriyorsa, her basamak için parantez içeren yapıyı ayrı ayrı kullanın veya kullanın `?`. - -**Örnek** - -Adlı dosyaları içeren tablo oluşturma `file000`, `file001`, … , `file999`: - -``` sql -CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') -``` - -## Sanal Sütunlar {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**Ayrıca Bakınız** - -- [Sanal sütunlar](../index.md#table_engines-virtual_columns) - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/hdfs/) diff --git a/docs/tr/engines/table_engines/integrations/index.md b/docs/tr/engines/table_engines/integrations/index.md deleted file mode 100644 index 608fc900e62..00000000000 --- a/docs/tr/engines/table_engines/integrations/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: Entegrasyonlar -toc_priority: 30 ---- - - diff --git a/docs/tr/engines/table_engines/integrations/jdbc.md b/docs/tr/engines/table_engines/integrations/jdbc.md deleted file mode 100644 index 08196116cf8..00000000000 --- a/docs/tr/engines/table_engines/integrations/jdbc.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 34 -toc_title: JDBC ---- - -# JDBC {#table-engine-jdbc} - -ClickHouse üzerinden harici veritabanlarına bağlanmak için izin verir [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity). - -JDBC bağlantısını uygulamak için ClickHouse ayrı programı kullanır [clickhouse-JDBC-köprü](https://github.com/alex-krash/clickhouse-jdbc-bridge) bu bir daemon olarak çalışmalıdır. - -Bu motor destekler [Nullable](../../../sql_reference/data_types/nullable.md) veri türü. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name -( - columns list... -) -ENGINE = JDBC(dbms_uri, external_database, external_table) -``` - -**Motor Parametreleri** - -- `dbms_uri` — URI of an external DBMS. - - Biçimli: `jdbc:://:/?user=&password=`. - MySQL örneği: `jdbc:mysql://localhost:3306/?user=root&password=root`. - -- `external_database` — Database in an external DBMS. - -- `external_table` — Name of the table in `external_database`. - -## Kullanım Örneği {#usage-example} - -Doğrudan konsol istemcisine bağlanarak MySQL sunucusunda bir tablo oluşturma: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -ClickHouse Server'da bir tablo oluşturma ve ondan veri seçme: - -``` sql -CREATE TABLE jdbc_table -( - `int_id` Int32, - `int_nullable` Nullable(Int32), - `float` Float32, - `float_nullable` Nullable(Float32) -) -ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test') -``` - -``` sql -SELECT * -FROM jdbc_table -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## Ayrıca Bakınız {#see-also} - -- [JDBC tablo işlevi](../../../sql_reference/table_functions/jdbc.md). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) diff --git a/docs/tr/engines/table_engines/integrations/kafka.md b/docs/tr/engines/table_engines/integrations/kafka.md deleted file mode 100644 index e66894ed4ac..00000000000 --- a/docs/tr/engines/table_engines/integrations/kafka.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 32 -toc_title: Kafka ---- - -# Kafka {#kafka} - -Bu motor ile çalışır [Apache Kafka](http://kafka.apache.org/). - -Kafka sağlar: - -- Veri akışlarını yayınlayın veya abone olun. -- Hataya dayanıklı depolama düzenlemek. -- Kullanılabilir hale geldikçe akışları işleyin. - -## Tablo oluşturma {#table_engine-kafka-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = Kafka() -SETTINGS - kafka_broker_list = 'host:port', - kafka_topic_list = 'topic1,topic2,...', - kafka_group_name = 'group_name', - kafka_format = 'data_format'[,] - [kafka_row_delimiter = 'delimiter_symbol',] - [kafka_schema = '',] - [kafka_num_consumers = N,] - [kafka_skip_broken_messages = N] -``` - -Gerekli parametreler: - -- `kafka_broker_list` – A comma-separated list of brokers (for example, `localhost:9092`). -- `kafka_topic_list` – A list of Kafka topics. -- `kafka_group_name` – A group of Kafka consumers. Reading margins are tracked for each group separately. If you don't want messages to be duplicated in the cluster, use the same group name everywhere. -- `kafka_format` – Message format. Uses the same notation as the SQL `FORMAT` fonksiyon gibi `JSONEachRow`. Daha fazla bilgi için, bkz: [Biçimliler](../../../interfaces/formats.md) bölme. - -İsteğe bağlı parametreler: - -- `kafka_row_delimiter` – Delimiter character, which ends the message. -- `kafka_schema` – Parameter that must be used if the format requires a schema definition. For example, [Cap'n Proto](https://capnproto.org/) şema dosyasının yolunu ve kök adını gerektirir `schema.capnp:Message` nesne. -- `kafka_num_consumers` – The number of consumers per table. Default: `1`. Bir tüketicinin verimi yetersizse daha fazla tüketici belirtin. Bölüm başına yalnızca bir tüketici atanabileceğinden, toplam tüketici sayısı konudaki bölüm sayısını geçmemelidir. -- `kafka_skip_broken_messages` – Kafka message parser tolerance to schema-incompatible messages per block. Default: `0`. Eğer `kafka_skip_broken_messages = N` sonra motor atlar *N* Ayrıştırılamayan Kafka iletileri (bir ileti bir veri satırına eşittir). - -Örnekler: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - SELECT * FROM queue LIMIT 5; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka SETTINGS kafka_broker_list = 'localhost:9092', - kafka_topic_list = 'topic', - kafka_group_name = 'group1', - kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; - - CREATE TABLE queue2 ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1') - SETTINGS kafka_format = 'JSONEachRow', - kafka_num_consumers = 4; -``` - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın. Mümkünse, eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format - [, kafka_row_delimiter, kafka_schema, kafka_num_consumers, kafka_skip_broken_messages]) -``` - -
- -## Açıklama {#description} - -Teslim edilen mesajlar otomatik olarak izlenir, bu nedenle bir gruptaki her mesaj yalnızca bir kez sayılır. Verileri iki kez almak istiyorsanız, tablonun başka bir grup adıyla bir kopyasını oluşturun. - -Gruplar esnek ve kümede senkronize edilir. Örneğin, bir kümede 10 konu ve bir tablonun 5 kopyası varsa, her kopya 2 konu alır. Kopya sayısı değişirse, konular kopyalar arasında otomatik olarak yeniden dağıtılır. Bu konuda daha fazla bilgi edinin http://kafka.apache.org/intro. - -`SELECT` mesajları okumak için özellikle yararlı değildir (hata ayıklama hariç), çünkü her mesaj yalnızca bir kez okunabilir. Hayata görünümler kullanarak gerçek zamanlı iş parçacıkları oluşturmak daha pratiktir. Bunu yapmak için : - -1. Bir Kafka tüketici oluşturmak için motoru kullanın ve bir veri akışı düşünün. -2. İstenen yapıya sahip bir tablo oluşturun. -3. Verileri motordan dönüştüren ve daha önce oluşturulmuş bir tabloya koyan materyalleştirilmiş bir görünüm oluşturun. - -Ne zaman `MATERIALIZED VIEW` motora katılır, arka planda veri toplamaya başlar. Bu, kafka'dan sürekli olarak mesaj almanızı ve bunları kullanarak gerekli biçime dönüştürmenizi sağlar `SELECT`. -Bir kafka tablosu istediğiniz kadar materialized görüşe sahip olabilir, kafka tablosundan doğrudan veri okumazlar, ancak yeni kayıtlar (bloklar halinde) alırlar, bu şekilde farklı ayrıntı seviyesine sahip birkaç tabloya yazabilirsiniz (gruplama-toplama ve olmadan). - -Örnek: - -``` sql - CREATE TABLE queue ( - timestamp UInt64, - level String, - message String - ) ENGINE = Kafka('localhost:9092', 'topic', 'group1', 'JSONEachRow'); - - CREATE TABLE daily ( - day Date, - level String, - total UInt64 - ) ENGINE = SummingMergeTree(day, (day, level), 8192); - - CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total - FROM queue GROUP BY day, level; - - SELECT level, sum(total) FROM daily GROUP BY level; -``` - -Performansı artırmak için, alınan iletiler bloklar halinde gruplandırılır [max\_ınsert\_block\_size](../../../operations/server_configuration_parameters/settings.md#settings-max_insert_block_size). İçinde blok oluş ifma ifdıysa [stream\_flush\_interval\_ms](../../../operations/server_configuration_parameters/settings.md) milisaniye, veri blok bütünlüğü ne olursa olsun tabloya temizlendi. - -Konu verilerini almayı durdurmak veya dönüşüm mantığını değiştirmek için, hayata geçirilmiş görünümü ayırın: - -``` sql - DETACH TABLE consumer; - ATTACH TABLE consumer; -``` - -Kullanarak hedef tabloyu değiştirmek istiyorsanız `ALTER` hedef tablo ile görünümdeki veriler arasındaki tutarsızlıkları önlemek için malzeme görünümünü devre dışı bırakmanızı öneririz. - -## Yapılandırma {#configuration} - -GraphiteMergeTree benzer şekilde, Kafka motoru ClickHouse yapılandırma dosyasını kullanarak genişletilmiş yapılandırmayı destekler. Kullanabileceğiniz iki yapılandırma anahtarı vardır: global (`kafka`) ve konu düzeyinde (`kafka_*`). Genel yapılandırma önce uygulanır ve sonra konu düzeyinde yapılandırma uygulanır (varsa). - -``` xml - - - cgrp - smallest - - - - - 250 - 100000 - -``` - -Olası yapılandırma seçeneklerinin listesi için bkz. [librdkafka yapılandırma referansı](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Alt çizgiyi kullan (`_`) ClickHouse yapılandırmasında bir nokta yerine. Mesela, `check.crcs=true` olacak `true`. - -## Sanal Sütunlar {#virtual-columns} - -- `_topic` — Kafka topic. -- `_key` — Key of the message. -- `_offset` — Offset of the message. -- `_timestamp` — Timestamp of the message. -- `_partition` — Partition of Kafka topic. - -**Ayrıca Bakınız** - -- [Sanal sütunlar](../index.md#table_engines-virtual_columns) - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/kafka/) diff --git a/docs/tr/engines/table_engines/integrations/mysql.md b/docs/tr/engines/table_engines/integrations/mysql.md deleted file mode 100644 index f6c811465e6..00000000000 --- a/docs/tr/engines/table_engines/integrations/mysql.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 33 -toc_title: MySQL ---- - -# Mysql {#mysql} - -MySQL motoru gerçekleştirmek için izin verir `SELECT` uzak bir MySQL sunucusunda depolanan veriler üzerinde sorgular. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... -) ENGINE = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -Ayrıntılı bir açıklamasını görmek [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) sorgu. - -Tablo yapısı orijinal MySQL tablo yapısından farklı olabilir: - -- Sütun adları orijinal MySQL tablosundaki ile aynı olmalıdır, ancak bu sütunların sadece bazılarını ve herhangi bir sırada kullanabilirsiniz. -- Sütun türleri orijinal MySQL tablosundakilerden farklı olabilir. ClickHouse çalışır [döküm](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) ClickHouse veri türleri için değerler. - -**Motor Parametreleri** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` için sorgular `REPLACE INTO`. Eğer `replace_query=1`, sorgu değiştirilir. - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` eklenen ifade `INSERT` sorgu. - - Örnek: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, nere `on_duplicate_clause` oluyor `UPDATE c2 = c2 + 1`. Görmek [MySQL dökü documentationmanları](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) bulmak için hangi `on_duplicate_clause` ile kullanabilirsiniz `ON DUPLICATE KEY` yan. - - Belirtmek `on_duplicate_clause` sen geçmek gerekir `0` to the `replace_query` parametre. Aynı anda geçerseniz `replace_query = 1` ve `on_duplicate_clause`, ClickHouse bir özel durum oluşturur. - -Basit `WHERE` gibi maddeler `=, !=, >, >=, <, <=` MySQL sunucusunda yürütülür. - -Geri kalan şartlar ve `LIMIT` örnekleme kısıtlaması, yalnızca MySQL sorgusu bittikten sonra Clickhouse'da yürütülür. - -## Kullanım Örneği {#usage-example} - -MySQL tablo: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Clickhouse'daki tablo, yukarıda oluşturulan MySQL tablosundan veri alma: - -``` sql -CREATE TABLE mysql_table -( - `float_nullable` Nullable(Float32), - `int_id` Int32 -) -ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` sql -SELECT * FROM mysql_table -``` - -``` text -┌─float_nullable─┬─int_id─┐ -│ ᴺᵁᴸᴸ │ 1 │ -└────────────────┴────────┘ -``` - -## Ayrıca Bakınız {#see-also} - -- [Bu ‘mysql’ tablo fonksiyonu](../../../sql_reference/table_functions/mysql.md) -- [Harici sözlük kaynağı olarak MySQL kullanma](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/mysql/) diff --git a/docs/tr/engines/table_engines/integrations/odbc.md b/docs/tr/engines/table_engines/integrations/odbc.md deleted file mode 100644 index 86ded26587a..00000000000 --- a/docs/tr/engines/table_engines/integrations/odbc.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 35 -toc_title: ODBC ---- - -# ODBC {#table-engine-odbc} - -ClickHouse üzerinden harici veritabanlarına bağlanmak için izin verir [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -ODBC bağlantılarını güvenli bir şekilde uygulamak için ClickHouse ayrı bir program kullanır `clickhouse-odbc-bridge`. ODBC sürücüsü doğrudan yüklenmişse `clickhouse-server`, sürücü sorunları ClickHouse sunucu çökmesine neden olabilir. ClickHouse otomatik olarak başlar `clickhouse-odbc-bridge` gerekli olduğunda. ODBC Köprüsü programı aynı paketten yüklenir `clickhouse-server`. - -Bu motor destekler [Nullable](../../../sql_reference/data_types/nullable.md) veri türü. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1], - name2 [type2], - ... -) -ENGINE = ODBC(connection_settings, external_database, external_table) -``` - -Ayrıntılı bir açıklamasını görmek [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) sorgu. - -Tablo yapısı kaynak tablo yapısından farklı olabilir: - -- Sütun adları kaynak tablodaki ile aynı olmalıdır, ancak yalnızca bu sütunlardan bazılarını ve herhangi bir sırada kullanabilirsiniz. -- Sütun türleri kaynak tablodakilerden farklı olabilir. ClickHouse çalışır [döküm](../../../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) ClickHouse veri türleri için değerler. - -**Motor Parametreleri** - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` Dosya. -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -## Kullanım Örneği {#usage-example} - -**ODBC üzerinden yerel MySQL kurulumundan veri alma** - -Bu örnek Ubuntu Linux 18.04 ve MySQL server 5.7 için kontrol edilir. - -UnixODBC ve MySQL Connector yüklü olduğundan emin olun. - -Varsayılan olarak (paketlerden yüklüyse), ClickHouse kullanıcı olarak başlar `clickhouse`. Bu nedenle, bu kullanıcıyı MySQL sunucusunda oluşturmanız ve yapılandırmanız gerekir. - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -Sonra bağlantıyı yapılandırın `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -Kullanarak bağlantıyı kontrol edebilirsiniz `isql` unixodbc yüklemesinden yardımcı program. - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -MySQL tablo: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -Clickhouse'daki tablo, MySQL tablosundan veri alma: - -``` sql -CREATE TABLE odbc_t -( - `int_id` Int32, - `float_nullable` Nullable(Float32) -) -ENGINE = ODBC('DSN=mysqlconn', 'test', 'test') -``` - -``` sql -SELECT * FROM odbc_t -``` - -``` text -┌─int_id─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ -└────────┴────────────────┘ -``` - -## Ayrıca Bakınız {#see-also} - -- [ODBC harici sözlükler](../../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [ODBC tablo işlevi](../../../sql_reference/table_functions/odbc.md) - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/odbc/) diff --git a/docs/tr/engines/table_engines/log_family/index.md b/docs/tr/engines/table_engines/log_family/index.md deleted file mode 100644 index 062087a5874..00000000000 --- a/docs/tr/engines/table_engines/log_family/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "G\xFCnl\xFCk Aile" -toc_priority: 29 ---- - - diff --git a/docs/tr/engines/table_engines/log_family/log.md b/docs/tr/engines/table_engines/log_family/log.md deleted file mode 100644 index ca1f8c4c1f4..00000000000 --- a/docs/tr/engines/table_engines/log_family/log.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 33 -toc_title: "G\xFCnl\xFCk" ---- - -# Günlük {#log} - -Motor günlük motorları ailesine aittir. Günlük motorlarının ortak özelliklerini ve farklılıklarını görün [Log Engine Ailesi](log_family.md) makale. - -Log differsar differsit fromma [TinyLog](tinylog.md) bu küçük bir dosyada “marks” sütun dosyaları ile bulunur. Bu işaretler her veri bloğuna yazılır ve belirtilen satır sayısını atlamak için dosyayı okumaya nereden başlayacağınızı gösteren uzaklıklar içerir. Bu, tablo verilerini birden çok iş parçacığında okumayı mümkün kılar. -Eşzamanlı veri erişimi için, okuma işlemleri aynı anda gerçekleştirilebilirken, yazma işlemleri okur ve birbirlerini engeller. -Günlük altyapısı dizinleri desteklemez. Benzer şekilde, bir tabloya yazma başarısız olursa, tablo bozulur ve Okuma bir hata döndürür. Günlük altyapısı, geçici veriler, bir kez yazma tabloları ve sınama veya gösteri amaçları için uygundur. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/log/) diff --git a/docs/tr/engines/table_engines/log_family/log_family.md b/docs/tr/engines/table_engines/log_family/log_family.md deleted file mode 100644 index 2a954c60def..00000000000 --- a/docs/tr/engines/table_engines/log_family/log_family.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 31 -toc_title: "Giri\u015F" ---- - -# Log Engine Ailesi {#log-engine-family} - -Bu motorlar, birçok küçük tabloyu (yaklaşık 1 milyon satıra kadar) hızlı bir şekilde yazmanız ve daha sonra bir bütün olarak okumanız gerektiğinde senaryolar için geliştirilmiştir. - -Ailenin motorları: - -- [StripeLog](stripelog.md) -- [Günlük](log.md) -- [TinyLog](tinylog.md) - -## Ortak Özellikler {#common-properties} - -Motorlar: - -- Verileri bir diskte saklayın. - -- Yazarken dosyanın sonuna veri ekleyin. - -- Eşzamanlı veri erişimi için destek kilitleri. - - Sırasında `INSERT` sorgular, tablo kilitlenir ve veri okumak ve yazmak için diğer sorgular hem tablonun kilidini açmak için bekler. Veri yazma sorguları varsa, herhangi bir sayıda veri okuma sorguları aynı anda gerçekleştirilebilir. - -- Destek yok [mutasyon](../../../sql_reference/statements/alter.md#alter-mutations) harekat. - -- Dizinleri desteklemez. - - Bu demektir ki `SELECT` veri aralıkları için sorgular verimli değildir. - -- Atomik veri yazmayın. - - Bir şey yazma işlemini bozarsa, örneğin anormal sunucu kapatma gibi bozuk verilerle bir tablo alabilirsiniz. - -## Farklılıklar {#differences} - -Bu `TinyLog` motor, ailenin en basitidir ve en fakir işlevselliği ve en düşük verimliliği sağlar. Bu `TinyLog` motor, birkaç iş parçacığı tarafından paralel veri okumayı desteklemez. Paralel okumayı destekleyen ailedeki diğer motorlardan daha yavaş veri okur ve neredeyse birçok tanımlayıcı kullanır `Log` motor, her sütunu ayrı bir dosyada sakladığı için. Basit düşük yük senaryolarında kullanın. - -Bu `Log` ve `StripeLog` motorlar paralel veri okumayı destekler. Veri okurken, ClickHouse birden çok iş parçacığı kullanır. Her iş parçacığı ayrı bir veri bloğu işler. Bu `Log` engine, tablonun her sütunu için ayrı bir dosya kullanır. `StripeLog` tüm verileri tek bir dosyada saklar. Sonuç olarak, `StripeLog` motor işletim sisteminde daha az tanımlayıcı kullanır, ancak `Log` motor veri okurken daha yüksek verimlilik sağlar. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/log_family/) diff --git a/docs/tr/engines/table_engines/log_family/stripelog.md b/docs/tr/engines/table_engines/log_family/stripelog.md deleted file mode 100644 index 1ff251c3ee0..00000000000 --- a/docs/tr/engines/table_engines/log_family/stripelog.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 32 -toc_title: StripeLog ---- - -# Stripelog {#stripelog} - -Bu motor günlük motor ailesine aittir. Günlük motorlarının ortak özelliklerini ve farklılıklarını görün [Log Engine Ailesi](log_family.md) makale. - -Az miktarda veri içeren (1 milyondan az satır) birçok tablo yazmanız gerektiğinde, bu altyapıyı senaryolarda kullanın. - -## Tablo oluşturma {#table_engines-stripelog-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = StripeLog -``` - -Ayrıntılı açıklamasına bakın [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) sorgu. - -## Veri yazma {#table_engines-stripelog-writing-the-data} - -Bu `StripeLog` motor tüm sütunları tek bir dosyada saklar. Her biri için `INSERT` sorgu, ClickHouse veri bloğunu bir tablo dosyasının sonuna ekler, sütunları tek tek yazar. - -Her tablo için ClickHouse dosyaları yazar: - -- `data.bin` — Data file. -- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted. - -Bu `StripeLog` motor desteklemiyor `ALTER UPDATE` ve `ALTER DELETE` harekat. - -## Verileri okuma {#table_engines-stripelog-reading-the-data} - -İşaretli dosya, Clickhouse'un verilerin okunmasını paralelleştirmesine izin verir. Bu demektir `SELECT` sorgu satırları öngörülemeyen bir sırayla döndürür. Kullan... `ORDER BY` satırları sıralamak için yan tümce. - -## Kullanım Örneği {#table_engines-stripelog-example-of-use} - -Tablo oluşturma: - -``` sql -CREATE TABLE stripe_log_table -( - timestamp DateTime, - message_type String, - message String -) -ENGINE = StripeLog -``` - -Veri ekleme: - -``` sql -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message') -INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') -``` - -İki kullandık `INSERT` içinde iki veri bloğu oluşturmak için sorgular `data.bin` Dosya. - -ClickHouse veri seçerken birden çok iş parçacığı kullanır. Her iş parçacığı ayrı bir veri bloğu okur ve sonuç olarak satırları bağımsız olarak döndürür. Sonuç olarak, çıktıdaki satır bloklarının sırası, çoğu durumda girişteki aynı blokların sırasına uymuyor. Mesela: - -``` sql -SELECT * FROM stripe_log_table -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -┌───────────timestamp─┬─message_type─┬─message───────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -└─────────────────────┴──────────────┴───────────────────────────┘ -``` - -Sonuçları sıralama (varsayılan olarak artan sipariş): - -``` sql -SELECT * FROM stripe_log_table ORDER BY timestamp -``` - -``` text -┌───────────timestamp─┬─message_type─┬─message────────────────────┐ -│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │ -│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │ -│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │ -└─────────────────────┴──────────────┴────────────────────────────┘ -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/stripelog/) diff --git a/docs/tr/engines/table_engines/log_family/tinylog.md b/docs/tr/engines/table_engines/log_family/tinylog.md deleted file mode 100644 index e4eccf220b1..00000000000 --- a/docs/tr/engines/table_engines/log_family/tinylog.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 34 -toc_title: TinyLog ---- - -# TinyLog {#tinylog} - -Motor log engine ailesine aittir. Görmek [Log Engine Ailesi](log_family.md) günlük motorlarının ortak özellikleri ve farklılıkları için. - -Bu tablo motoru genellikle write-once yöntemi ile kullanılır: verileri bir kez yazın, ardından gerektiği kadar okuyun. Örneğin, kullanabilirsiniz `TinyLog`- küçük gruplar halinde işlenen Ara veriler için tablolar yazın. Çok sayıda küçük tabloda veri depolamanın verimsiz olduğunu unutmayın. - -Sorgular tek bir akışta yürütülür. Başka bir deyişle, bu motor nispeten küçük tablolar için tasarlanmıştır (yaklaşık 1.000.000 satıra kadar). Çok sayıda küçük tablonuz varsa, bu tablo motorunu kullanmak mantıklıdır, çünkü [Günlük](log.md) motor (daha az dosya açılması gerekir). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/tinylog/) diff --git a/docs/tr/engines/table_engines/mergetree_family/aggregatingmergetree.md b/docs/tr/engines/table_engines/mergetree_family/aggregatingmergetree.md deleted file mode 100644 index 8034be02969..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/aggregatingmergetree.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 35 -toc_title: AggregatingMergeTree ---- - -# Aggregatingmergetree {#aggregatingmergetree} - -Motor devralır [MergeTree](mergetree.md#table_engines-mergetree), veri parçaları birleştirme mantığı değiştirme. ClickHouse, tüm satırları aynı birincil anahtarla değiştirir (veya daha doğru olarak, aynı [sıralama anahtarı](mergetree.md)) tek bir satırla (bir veri parçası içinde), toplama işlevlerinin durumlarının bir kombinasyonunu saklar. - -Kullanabilirsiniz `AggregatingMergeTree` artımlı veri toplama, toplanan materialized görünümleri de dahil olmak üzere tablolar. - -Motor tüm sütunları ile işler [AggregateFunction](../../../sql_reference/data_types/aggregatefunction.md) tür. - -Kullanmak uygundur `AggregatingMergeTree` siparişlere göre satır sayısını azaltırsa. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = AggregatingMergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[TTL expr] -[SETTINGS name=value, ...] -``` - -İstek parametrelerinin açıklaması için bkz. [istek açıklaması](../../../sql_reference/statements/create.md). - -**Sorgu yan tümceleri** - -Oluştururken bir `AggregatingMergeTree` tablo aynı [yanlar](mergetree.md) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] AggregatingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -Tüm parametreler, aşağıdaki gibi aynı anlama sahiptir `MergeTree`. -
- -## Seç ve Ekle {#select-and-insert} - -Veri eklemek için şunları kullanın [INSERT SELECT](../../../sql_reference/statements/insert_into.md) agrega-Devlet-fonksiyonları ile sorgu. -Veri seçerken `AggregatingMergeTree` tablo kullanın `GROUP BY` yan tümce ve veri eklerken aynı toplama işlevleri, ancak kullanarak `-Merge` sonek. - -Sonuç inlarında `SELECT` sorgu, değerleri `AggregateFunction` türü, Tüm ClickHouse çıktı biçimleri için uygulamaya özgü ikili gösterime sahiptir. Örneğin, veri dökümü, `TabSeparated` ile format `SELECT` sorgu daha sonra bu dökümü kullanarak geri yüklenebilir `INSERT` sorgu. - -## Toplu bir Somutlaştırılmış Görünüm örneği {#example-of-an-aggregated-materialized-view} - -`AggregatingMergeTree` saatler hayata görünüm `test.visits` Tablo: - -``` sql -CREATE MATERIALIZED VIEW test.basic -ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate) -AS SELECT - CounterID, - StartDate, - sumState(Sign) AS Visits, - uniqState(UserID) AS Users -FROM test.visits -GROUP BY CounterID, StartDate; -``` - -Veri ekleme `test.visits` Tablo. - -``` sql -INSERT INTO test.visits ... -``` - -Veriler hem tablo hem de görünümde eklenir `test.basic` toplama işlemini gerçekleştir .ecektir. - -Toplanan verileri almak için, aşağıdaki gibi bir sorgu yürütmemiz gerekir `SELECT ... GROUP BY ...` görünüm fromden `test.basic`: - -``` sql -SELECT - StartDate, - sumMerge(Visits) AS Visits, - uniqMerge(Users) AS Users -FROM test.basic -GROUP BY StartDate -ORDER BY StartDate; -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/aggregatingmergetree/) diff --git a/docs/tr/engines/table_engines/mergetree_family/collapsingmergetree.md b/docs/tr/engines/table_engines/mergetree_family/collapsingmergetree.md deleted file mode 100644 index 3ef53846f32..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/collapsingmergetree.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 36 -toc_title: CollapsingMergeTree ---- - -# CollapsingMergeTree {#table_engine-collapsingmergetree} - -Motor devralır [MergeTree](mergetree.md) ve veri parçaları birleştirme algoritmasına çöken satırların mantığını ekler. - -`CollapsingMergeTree` sıralama anahtarındaki tüm alanlar zaman uyumsuz olarak siler (daraltır) satır çiftleri (`ORDER BY`) belirli alan hariç eşdeğerdir `Sign` hangi olabilir `1` ve `-1` değerler. Çift olmayan satırlar tutulur. Daha fazla bilgi için bkz: [Çökme](#table_engine-collapsingmergetree-collapsing) belgenin bölümü. - -Motor depolama hacmini önemli ölçüde azaltabilir ve `SELECT` sonuç olarak sorgu. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = CollapsingMergeTree(sign) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Sorgu parametrelerinin açıklaması için bkz. [sorgu açıklaması](../../../sql_reference/statements/create.md). - -**CollapsingMergeTree Parametreleri** - -- `sign` — Name of the column with the type of row: `1` is a “state” satır, `-1` is a “cancel” satır. - - Column data type — `Int8`. - -**Sorgu yan tümceleri** - -Oluştururken bir `CollapsingMergeTree` tablo, aynı [sorgu yan tümceleri](mergetree.md#table_engine-mergetree-creating-a-table) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign) -``` - -Hariç tüm parametreler `sign` içinde olduğu gibi aynı anlama sahip `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` — “state” satır, `-1` — “cancel” satır. - - Column Data Type — `Int8`. - -
- -## Çökme {#table_engine-collapsingmergetree-collapsing} - -### Veriler {#data} - -Bazı nesneler için sürekli değişen verileri kaydetmeniz gereken durumu düşünün. Bir nesne için bir satıra sahip olmak ve herhangi bir değişiklikte güncellemek mantıklı geliyor, ancak güncelleme işlemi dbms için pahalı ve yavaş çünkü depolama alanındaki verilerin yeniden yazılmasını gerektiriyor. Verileri hızlı bir şekilde yazmanız gerekiyorsa, güncelleme kabul edilemez, ancak bir nesnenin değişikliklerini sırayla aşağıdaki gibi yazabilirsiniz. - -Belirli sütunu kullanın `Sign`. Eğer `Sign = 1` bu, satırın bir nesnenin durumu olduğu anlamına gelir, diyelim ki “state” satır. Eğer `Sign = -1` aynı özelliklere sahip bir nesnenin durumunun iptali anlamına gelir, diyelim ki “cancel” satır. - -Örneğin, kullanıcıların bazı sitelerde ne kadar sayfa kontrol ettiğini ve ne kadar süre orada olduklarını hesaplamak istiyoruz. Bir anda kullanıcı etkinliği durumu ile aşağıdaki satırı yazıyoruz: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Bir an sonra kullanıcı aktivitesinin değişikliğini kaydedip aşağıdaki iki satırla yazıyoruz. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -İlk satır, nesnenin (kullanıcı) önceki durumunu iptal eder. İptal edilen durumun sıralama anahtar alanlarını kopyalamalıdır `Sign`. - -İkinci satır geçerli durumu içerir. - -Sadece kullanıcı etkinliğinin son durumuna ihtiyacımız olduğu için, satırlar - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -bir nesnenin geçersiz (eski) durumunu daraltarak silinebilir. `CollapsingMergeTree` veri parçalarının birleştirilmesi sırasında bunu yapar. - -Neden her değişiklik için 2 satıra ihtiyacımız var [Algoritma](#table_engine-collapsingmergetree-collapsing-algorithm) paragraf. - -**Bu yaklaşımın kendine özgü özellikleri** - -1. Verileri yazan program, iptal edebilmek için bir nesnenin durumunu hatırlamalıdır. “Cancel” dize, sıralama anahtar alanlarının kopyalarını içermelidir. “state” dize ve tersi `Sign`. Bu depolama başlangıç boyutunu artırır ama hızlı bir şekilde veri yazmak için izin verir. -2. Sütunlardaki uzun büyüyen diziler, yazma yükü nedeniyle motorun verimliliğini azaltır. Daha basit veriler, verimlilik o kadar yüksek olur. -3. Bu `SELECT` sonuçlara itiraz değişiklikler tarihin tutarlılık bağlıdır. Ekleme için veri hazırlarken doğru olun. Tutarsız verilerde öngörülemeyen sonuçlar elde edebilirsiniz, örneğin, oturum derinliği gibi negatif olmayan metrikler için negatif değerler. - -### Algoritma {#table_engine-collapsingmergetree-collapsing-algorithm} - -ClickHouse veri parçalarını birleştirdiğinde, her ardışık satır grubu aynı sıralama anahtarıyla (`ORDER BY`) en fazla iki satır reduceda indir isgen ,ir, biri `Sign = 1` (“state” satır) ve başka bir `Sign = -1` (“cancel” satır). Başka bir deyişle, girişler çöker. - -Elde edilen her veri parçası için ClickHouse kaydeder: - -1. Birincilik “cancel” ve son “state” satır sayısı ise “state” ve “cancel” satırlar eşleşir ve son satır bir “state” satır. - -2. Son “state” satır, daha varsa “state” satırlar daha “cancel” satırlar. - -3. Birincilik “cancel” satır, daha varsa “cancel” satırlar daha “state” satırlar. - -4. Diğer tüm durumlarda satırların hiçbiri. - -Ayrıca en az 2 tane daha olduğunda “state” satırlar daha “cancel” satırlar veya en az 2 tane daha “cancel” r rowsows th thenen “state” satırlar, birleştirme devam eder, ancak ClickHouse bu durumu mantıksal bir hata olarak değerlendirir ve sunucu günlüğüne kaydeder. Aynı veriler birden çok kez eklendiğinde, bu hata oluşabilir. - -Bu nedenle, çöken istatistik hesaplama sonuçlarını değiştirmemelidir. -Değişiklikler yavaş yavaş çöktü, böylece sonunda hemen hemen her nesnenin sadece son durumu kaldı. - -Bu `Sign` birleştirme algoritması, aynı sıralama anahtarına sahip tüm satırların aynı sonuçtaki veri bölümünde ve hatta aynı fiziksel sunucuda olacağını garanti etmediğinden gereklidir. ClickHouse süreci `SELECT` birden çok iş parçacığına sahip sorgular ve sonuçtaki satırların sırasını tahmin edemez. Tamamen almak için bir ihtiyaç varsa toplama gereklidir “collapsed” veri `CollapsingMergeTree` Tablo. - -Daraltmayı sonuçlandırmak için bir sorgu yazın `GROUP BY` yan tümce ve işareti için hesap toplama işlevleri. Örneğin, miktarı hesaplamak için kullanın `sum(Sign)` yerine `count()`. Bir şeyin toplamını hesaplamak için şunları kullanın `sum(Sign * x)` yerine `sum(x)`, ve böylece, ve ayrıca ekleyin `HAVING sum(Sign) > 0`. - -Toplanan `count`, `sum` ve `avg` bu şekilde hesaplanmış olabilir. Toplanan `uniq` bir nesnenin en az bir durumu çökmüş değilse hesaplanabilir. Toplanan `min` ve `max` hesaplan becauseamadı çünkü `CollapsingMergeTree` daraltılmış durumların değerleri geçmişini kaydetmez. - -Toplama olmadan veri ayıklamanız gerekiyorsa (örneğin, en yeni değerleri belirli koşullarla eşleşen satırların mevcut olup olmadığını kontrol etmek için) `FINAL` değiştirici için `FROM` yan. Bu yaklaşım önemli ölçüde daha az etkilidir. - -## Kullanım Örneği {#example-of-use} - -Örnek veriler: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Tablonun oluşturulması: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Veri ekleme: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) -``` - -Biz iki kullanın `INSERT` iki farklı veri parçası oluşturmak için sorgular. Verileri bir sorgu ile eklersek ClickHouse bir veri parçası oluşturur ve hiç bir birleştirme gerçekleştirmez. - -Veri alma: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Ne görüyoruz ve nerede çöküyor? - -İki ile `INSERT` sorgular, 2 Veri parçası oluşturduk. Bu `SELECT` sorgu 2 iş parçacığında yapıldı ve rastgele bir satır sırası aldık. Veri parçalarının henüz birleştirilmediği için çökme gerçekleşmedi. ClickHouse biz tahmin edemez bilinmeyen bir anda veri kısmını birleştirir. - -Böylece toplama ihtiyacımız var: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration -FROM UAct -GROUP BY UserID -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -Toplamaya ihtiyacımız yoksa ve çökmeyi zorlamak istiyorsak, şunları kullanabiliriz `FINAL` değiştirici için `FROM` yan. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Verileri seçmenin bu yolu çok verimsizdir. Büyük masalar için kullanmayın. - -## Başka Bir Yaklaşım Örneği {#example-of-another-approach} - -Örnek veriler: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ -│ 4324182021466249494 │ -5 │ -146 │ -1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -Fikir, birleştirmelerin yalnızca anahtar alanları hesaba katmasıdır. Ve içinde “Cancel” satır işareti sütununu kullanmadan toplanırken satırın önceki sürümünü eşitleyen negatif değerleri belirtebiliriz. Bu yaklaşım için veri türünü değiştirmek gerekir `PageViews`,`Duration` uint8 -\> Int16 negatif değerlerini saklamak için. - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews Int16, - Duration Int16, - Sign Int8 -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID -``` - -Yaklaşımı test edelim: - -``` sql -insert into UAct values(4324182021466249494, 5, 146, 1); -insert into UAct values(4324182021466249494, -5, -146, -1); -insert into UAct values(4324182021466249494, 6, 185, 1); - -select * from UAct final; // avoid using final in production (just for a test or small tables) -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -``` sql -SELECT - UserID, - sum(PageViews) AS PageViews, - sum(Duration) AS Duration -FROM UAct -GROUP BY UserID -```text -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -``` sqk -select count() FROM UAct -``` - -``` text -┌─count()─┐ -│ 3 │ -└─────────┘ -``` - -``` sql -optimize table UAct final; - -select * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┘ -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/collapsingmergetree/) diff --git a/docs/tr/engines/table_engines/mergetree_family/custom_partitioning_key.md b/docs/tr/engines/table_engines/mergetree_family/custom_partitioning_key.md deleted file mode 100644 index ba09aa08cbb..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/custom_partitioning_key.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 32 -toc_title: "\xD6zel B\xF6l\xFCmleme Anahtar\u0131" ---- - -# Özel Bölümleme Anahtarı {#custom-partitioning-key} - -Bölümleme için kullanılabilir [MergeTree](mergetree.md) aile tabloları (dahil [çoğaltıyordu](replication.md) Tablolar). [Hayata görünümler](../special/materializedview.md) MergeTree tablolarına dayanarak bölümlemeyi de destekler. - -Bir bölüm, bir tablodaki kayıtların belirtilen bir kritere göre mantıksal bir birleşimidir. Bir bölümü, ay, gün veya olay türü gibi rasgele bir ölçütle ayarlayabilirsiniz. Bu verilerin manipülasyonlarını basitleştirmek için her bölüm ayrı ayrı saklanır. Verilere erişirken, ClickHouse mümkün olan en küçük bölüm alt kümesini kullanır. - -Bölüm belirtilen `PARTITION BY expr` fık whenra ne zaman [tablo oluşturma](mergetree.md#table_engine-mergetree-creating-a-table). Bölüm anahtarı tablo sütunlarından herhangi bir ifade olabilir. Örneğin, aya göre bölümleme belirtmek için ifadeyi kullanın `toYYYYMM(date_column)`: - -``` sql -CREATE TABLE visits -( - VisitDate Date, - Hour UInt8, - ClientID UUID -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(VisitDate) -ORDER BY Hour; -``` - -Bölüm anahtarı ayrıca bir ifade kümesi olabilir ( [birincil anahtar](mergetree.md#primary-keys-and-indexes-in-queries)). Mesela: - -``` sql -ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/name', 'replica1', Sign) -PARTITION BY (toMonday(StartDate), EventType) -ORDER BY (CounterID, StartDate, intHash32(UserID)); -``` - -Bu örnekte, bölümlemeyi geçerli hafta boyunca meydana gelen olay türlerine göre ayarladık. - -Bir tabloya yeni veri eklerken, bu veriler birincil anahtara göre sıralanmış ayrı bir parça (yığın) olarak depolanır. Taktıktan 10-15 dakika sonra, aynı bölümün parçaları tüm parçaya birleştirilir. - -!!! info "Bilgin" - Birleştirme yalnızca bölümleme ifadesi için aynı değere sahip veri parçaları için çalışır. Bu demektir **aşırı granüler bölümler yapmamalısınız** (yaklaşık binden fazla bölüm). Aksi takdirde, `SELECT` sorgu, dosya sistemindeki ve açık dosya tanımlayıcılarındaki makul olmayan sayıda dosya nedeniyle yetersiz performans gösterir. - -Kullan... [sistem.parçalar](../../../operations/system_tables.md#system_tables-parts) tablo tablo parçaları ve bölümleri görüntülemek için. Örneğin, bir var varsayalım `visits` aya göre bölümleme ile tablo. Hadi gerçekleştirelim `SELECT` sorgu için `system.parts` Tablo: - -``` sql -SELECT - partition, - name, - active -FROM system.parts -WHERE table = 'visits' -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 1 │ -│ 201902 │ 201902_11_11_0 │ 1 │ -└───────────┴────────────────┴────────┘ -``` - -Bu `partition` sütun bölümlerin adlarını içerir. Bu örnekte iki bölüm vardır: `201901` ve `201902`. Bölüm adını belirtmek için bu sütun değerini kullanabilirsiniz [ALTER … PARTITION](#alter_manipulations-with-partitions) sorgular. - -Bu `name` sütun, bölüm veri parçalarının adlarını içerir. Bölümün adını belirtmek için bu sütunu kullanabilirsiniz. [ALTER ATTACH PART](#alter_attach-partition) sorgu. - -İlk bölümün adını kıralım: `201901_1_3_1`: - -- `201901` bölüm adıdır. -- `1` en az veri bloğu sayısıdır. -- `3` veri bloğunun maksimum sayısıdır. -- `1` yığın düzeyidir (oluşturduğu birleştirme ağacının derinliği). - -!!! info "Bilgin" - Eski tip tabloların parçaları adı vardır: `20190117_20190123_2_2_0` (minimum tarih - maksimum tarih - minimum blok numarası - maksimum blok numarası - seviye). - -Bu `active` sütun, parçanın durumunu gösterir. `1` aktif istir; `0` etkin değil. Etkin olmayan parçalar, örneğin, daha büyük bir parçaya birleştirildikten sonra kalan kaynak parçalarıdır. Bozuk veri parçaları da etkin olarak gösterilir. - -Örnekte gördüğünüz gibi, aynı bölümün birkaç ayrı parçası vardır (örneğin, `201901_1_3_1` ve `201901_1_9_2`). Bu, bu parçaların henüz birleştirilmediği anlamına gelir. ClickHouse, eklendikten yaklaşık 15 dakika sonra eklenen veri parçalarını periyodik olarak birleştirir. Buna ek olarak, kullanarak zamanlanmış olmayan birleştirme gerçekleştirebilirsiniz [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) sorgu. Örnek: - -``` sql -OPTIMIZE TABLE visits PARTITION 201902; -``` - -``` text -┌─partition─┬─name───────────┬─active─┐ -│ 201901 │ 201901_1_3_1 │ 0 │ -│ 201901 │ 201901_1_9_2 │ 1 │ -│ 201901 │ 201901_8_8_0 │ 0 │ -│ 201901 │ 201901_9_9_0 │ 0 │ -│ 201902 │ 201902_4_6_1 │ 0 │ -│ 201902 │ 201902_4_11_2 │ 1 │ -│ 201902 │ 201902_10_10_0 │ 0 │ -│ 201902 │ 201902_11_11_0 │ 0 │ -└───────────┴────────────────┴────────┘ -``` - -Etkin olmayan parçalar birleştirildikten yaklaşık 10 dakika sonra silinecektir. - -Bir parça ve bölüm kümesini görüntülemenin başka bir yolu da tablonun dizinine gitmektir: `/var/lib/clickhouse/data///`. Mesela: - -``` bash -/var/lib/clickhouse/data/default/visits$ ls -l -total 40 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 201901_1_3_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201901_1_9_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_8_8_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 15:52 201901_9_9_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_10_10_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:17 201902_11_11_0 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 16:19 201902_4_11_2 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 -drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached -``` - -Klasör ‘201901\_1\_1\_0’, ‘201901\_1\_7\_1’ ve böylece parçaların dizinleri vardır. Her bölüm karşılık gelen bir bölümle ilgilidir ve yalnızca belirli bir ay için veri içerir (Bu örnekteki tabloda aylara göre bölümleme vardır). - -Bu `detached` dizin kullanarak tablodan ayrılmış parçaları içerir [DETACH](#alter_detach-partition) sorgu. Bozuk parçalar da silinmek yerine bu dizine taşınır. Sunucu parçaları kullanmaz `detached` directory. You can add, delete, or modify the data in this directory at any time – the server will not know about this until you run the [ATTACH](../../../sql_reference/statements/alter.md#alter_attach-partition) sorgu. - -İşletim sunucusunda, sunucu bunu bilmediğinden, dosya sistemindeki parça kümesini veya verilerini el ile değiştiremeyeceğinizi unutmayın. Çoğaltılmamış tablolar için, sunucu durdurulduğunda bunu yapabilirsiniz, ancak önerilmez. Çoğaltılmış tablolar için, parça kümesi her durumda değiştirilemez. - -ClickHouse, bölümlerle işlemleri gerçekleştirmenize izin verir: bunları silin, bir tablodan diğerine kopyalayın veya bir yedek oluşturun. Bölümdeki tüm işlemlerin listesine bakın [Bölümler ve parçalar ile manipülasyonlar](../../../sql_reference/statements/alter.md#alter_manipulations-with-partitions). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/custom_partitioning_key/) diff --git a/docs/tr/engines/table_engines/mergetree_family/graphitemergetree.md b/docs/tr/engines/table_engines/mergetree_family/graphitemergetree.md deleted file mode 100644 index 5d4a349631b..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/graphitemergetree.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 38 -toc_title: "Graph\u0131temergetree" ---- - -# Graphıtemergetree {#graphitemergetree} - -Bu motor inceltme ve toplama/ortalama (toplaması) için tasarlanmıştır) [Grafit](http://graphite.readthedocs.io/en/latest/index.html) veriler. Clickhouse'u Grafit için bir veri deposu olarak kullanmak isteyen geliştiriciler için yararlı olabilir. - -Toplamaya ihtiyacınız yoksa Grafit verilerini depolamak için herhangi bir ClickHouse tablo motorunu kullanabilirsiniz, ancak bir toplamaya ihtiyacınız varsa `GraphiteMergeTree`. Motor, depolama hacmini azaltır ve grafitten gelen sorguların verimliliğini arttırır. - -Motor özellikleri devralır [MergeTree](mergetree.md). - -## Tablo oluşturma {#creating-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE = GraphiteMergeTree(config_section) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Ayrıntılı bir açıklamasını görmek [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) sorgu. - -Grafit verileri için bir tablo aşağıdaki veriler için aşağıdaki sütunlara sahip olmalıdır: - -- Metrik adı (Grafit sensörü). Veri türü: `String`. - -- Metrik ölçme zamanı. Veri türü: `DateTime`. - -- Metrik değeri. Veri türü: herhangi bir sayısal. - -- Metrik sürümü. Veri türü: herhangi bir sayısal. - - ClickHouse en yüksek sürümü veya sürümleri aynı ise son yazılan satırları kaydeder. Veri parçalarının birleştirilmesi sırasında diğer satırlar silinir. - -Bu sütunların adları toplaması yapılandırmasında ayarlanmalıdır. - -**Graphıtemergetree parametreleri** - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -**Sorgu yan tümceleri** - -Oluştururken bir `GraphiteMergeTree` tablo, aynı [yanlar](mergetree.md#table_engine-mergetree-creating-a-table) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - EventDate Date, - Path String, - Time DateTime, - Value , - Version - ... -) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) -``` - -Hariç tüm parametreler `config_section` içinde olduğu gibi aynı anlama sahip `MergeTree`. - -- `config_section` — Name of the section in the configuration file, where are the rules of rollup set. - -
- -## Toplaması Yapılandırması {#rollup-configuration} - -Toplaması için ayarları tarafından tanımlanan [graphite\_rollup](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) sunucu yapılandırmasında parametre. Parametrenin adı herhangi biri olabilir. Birkaç yapılandırma oluşturabilir ve bunları farklı tablolar için kullanabilirsiniz. - -Toplaması yapılandırma yapısı: - - required-columns - patterns - -### Gerekli Sütunlar {#required-columns} - -- `path_column_name` — The name of the column storing the metric name (Graphite sensor). Default value: `Path`. -- `time_column_name` — The name of the column storing the time of measuring the metric. Default value: `Time`. -- `value_column_name` — The name of the column storing the value of the metric at the time set in `time_column_name`. Varsayılan değer: `Value`. -- `version_column_name` — The name of the column storing the version of the metric. Default value: `Timestamp`. - -### Desenler {#patterns} - -Bu yapı `patterns` bölme: - -``` text -pattern - regexp - function -pattern - regexp - age + precision - ... -pattern - regexp - function - age + precision - ... -pattern - ... -default - function - age + precision - ... -``` - -!!! warning "Dikkat" - Desenler kesinlikle sipariş edilmelidir: - - 1. Patterns without `function` or `retention`. - 1. Patterns with both `function` and `retention`. - 1. Pattern `default`. - -Bir satır işlerken, ClickHouse kuralları denetler `pattern` bölmeler. Tüm `pattern` (içeren `default`) bölümler içerebilir `function` toplama için parametre, `retention` parametreler veya her ikisi. Metrik adı eşleşirse `regexp` gelen kuralları `pattern` bölüm (veya bölümler) uygulanır; aksi takdirde, kurallar `default` bölüm kullanılır. - -Alanlar için `pattern` ve `default` bölmeler: - -- `regexp`– A pattern for the metric name. -- `age` – The minimum age of the data in seconds. -- `precision`– How precisely to define the age of the data in seconds. Should be a divisor for 86400 (seconds in a day). -- `function` – The name of the aggregating function to apply to data whose age falls within the range `[age, age + precision]`. - -### Yapılandırma Örneği {#configuration-example} - -``` xml - - Version - - click_cost - any - - 0 - 5 - - - 86400 - 60 - - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/graphitemergetree/) diff --git a/docs/tr/engines/table_engines/mergetree_family/index.md b/docs/tr/engines/table_engines/mergetree_family/index.md deleted file mode 100644 index e722564f4dd..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: MergeTree Ailesi -toc_priority: 28 ---- - - diff --git a/docs/tr/engines/table_engines/mergetree_family/mergetree.md b/docs/tr/engines/table_engines/mergetree_family/mergetree.md deleted file mode 100644 index 5adb6c2b038..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/mergetree.md +++ /dev/null @@ -1,654 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 30 -toc_title: MergeTree ---- - -# MergeTree {#table_engines-mergetree} - -Bu `MergeTree` bu ailenin motoru ve diğer motorları (`*MergeTree`) en sağlam ClickHouse masa motorlarıdır. - -Motor inlarda `MergeTree` aile, bir tabloya çok büyük miktarda veri eklemek için tasarlanmıştır. Veriler hızlı bir şekilde tabloya kısmen yazılır, daha sonra parçaları arka planda birleştirmek için kurallar uygulanır. Bu yöntem, ınsert sırasında depolama alanındaki verileri sürekli olarak yeniden yazmaktan çok daha etkilidir. - -Ana özellikler: - -- Birincil anahtara göre sıralanmış verileri saklar. - - Bu, verileri daha hızlı bulmanıza yardımcı olan küçük bir seyrek dizin oluşturmanıza olanak sağlar. - -- Bölümler eğer kullanılabilir [bölümleme anahtarı](custom_partitioning_key.md) belirt .ilmektedir. - - ClickHouse, aynı sonuçla aynı veriler üzerindeki genel işlemlerden daha etkili olan bölümlerle belirli işlemleri destekler. ClickHouse, bölümleme anahtarının sorguda belirtildiği bölüm verilerini de otomatik olarak keser. Bu da sorgu performansını artırır. - -- Veri çoğaltma desteği. - - The family of `ReplicatedMergeTree` tablolar veri çoğaltma sağlar. Daha fazla bilgi için, bkz. [Veri çoğaltma](replication.md). - -- Veri örnekleme desteği. - - Gerekirse, tabloda veri örnekleme yöntemini ayarlayabilirsiniz. - -!!! info "Bilgin" - Bu [Birleştirmek](../special/merge.md) motor ait değil `*MergeTree` aile. - -## Tablo oluşturma {#table_engine-mergetree-creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], - ... - INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1, - INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2 -) ENGINE = MergeTree() -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] -[SETTINGS name=value, ...] -``` - -Parametrelerin açıklaması için bkz. [Sorgu açıklaması oluştur](../../../sql_reference/statements/create.md). - -!!! note "Not" - `INDEX` deneysel bir özelliktir, bkz [Veri Atlama Dizinleri](#table_engine-mergetree-data_skipping-indexes). - -### Sorgu Yan Tümceleri {#mergetree-query-clauses} - -- `ENGINE` — Name and parameters of the engine. `ENGINE = MergeTree()`. Bu `MergeTree` motor parametreleri yok. - -- `PARTITION BY` — The [bölümleme anahtarı](custom_partitioning_key.md). - - Aylara göre bölümleme için `toYYYYMM(date_column)` ifade, nerede `date_column` türün tarihi olan bir sütun mu [Tarihli](../../../sql_reference/data_types/date.md). Burada bölüm isimleri var `"YYYYMM"` biçimli. - -- `ORDER BY` — The sorting key. - - Sütun veya keyfi ifadeler bir tuple. Örnek: `ORDER BY (CounterID, EventDate)`. - -- `PRIMARY KEY` — The primary key if it [sıralama anahtarından farklıdır](mergetree.md). - - Varsayılan olarak, birincil anahtar sıralama anahtarıyla aynıdır (bu anahtar tarafından belirtilir). `ORDER BY` yan). Bu nedenle çoğu durumda ayrı bir belirtmek gereksizdir `PRIMARY KEY` yan. - -- `SAMPLE BY` — An expression for sampling. - - Bir örnekleme ifadesi kullanılırsa, birincil anahtar onu içermelidir. Örnek: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`. - -- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [diskler ve birimler arasında](#table_engine-mergetree-multiple-volumes). - - İfade bir olmalıdır `Date` veya `DateTime` sonuç olarak sütun. Örnek: - `TTL date + INTERVAL 1 DAY` - - Kuralın türü `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` ifade tatmin edildiyse (geçerli zamana ulaşırsa) parça ile yapılacak bir eylemi belirtir: süresi dolmuş satırların kaldırılması, bir parçanın (bir parçadaki tüm satırlar için ifade tatmin edildiyse) belirtilen diske taşınması (`TO DISK 'xxx'`) veya hacim (`TO VOLUME 'xxx'`). Kuralın varsayılan türü kaldırma (`DELETE`). Birden fazla kural listesi belirtilebilir, ancak birden fazla olmamalıdır `DELETE` kural. - - Daha fazla ayrıntı için bkz. [Sütunlar ve tablolar için TTL](#table_engine-mergetree-ttl) - -- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`: - - - `index_granularity` — Maximum number of data rows between the marks of an index. Default value: 8192. See [Veri Depolama](#mergetree-data-storage). - - `index_granularity_bytes` — Maximum size of data granules in bytes. Default value: 10Mb. To restrict the granule size only by number of rows, set to 0 (not recommended). See [Veri Depolama](#mergetree-data-storage). - - `enable_mixed_granularity_parts` — Enables or disables transitioning to control the granule size with the `index_granularity_bytes` ayar. 19.11 sürümünden önce, sadece `index_granularity` granül boyutunu kısıtlamak için ayar. Bu `index_granularity_bytes` büyük satırlar (onlarca ve megabayt yüzlerce) ile tablolardan veri seçerken ayarı ClickHouse performansını artırır. Büyük satırlara sahip tablolarınız varsa, tabloların verimliliğini artırmak için bu ayarı etkinleştirebilirsiniz. `SELECT` sorgular. - - `use_minimalistic_part_header_in_zookeeper` — Storage method of the data parts headers in ZooKeeper. If `use_minimalistic_part_header_in_zookeeper=1`, daha sonra ZooKeeper daha az veri depolar. Daha fazla bilgi için, bkz: [ayar açıklaması](../../../operations/server_configuration_parameters/settings.md#server-settings-use_minimalistic_part_header_in_zookeeper) içinde “Server configuration parameters”. - - `min_merge_bytes_to_use_direct_io` — The minimum data volume for merge operation that is required for using direct I/O access to the storage disk. When merging data parts, ClickHouse calculates the total storage volume of all the data to be merged. If the volume exceeds `min_merge_bytes_to_use_direct_io` bayt, ClickHouse okur ve doğrudan I/O arabirimi kullanarak depolama diskine veri yazar (`O_DIRECT` seçenek). Eğer `min_merge_bytes_to_use_direct_io = 0`, sonra doğrudan g / Ç devre dışı bırakılır. Varsayılan değer: `10 * 1024 * 1024 * 1024` baytlar. - - - `merge_with_ttl_timeout` — Minimum delay in seconds before repeating a merge with TTL. Default value: 86400 (1 day). - - `write_final_mark` — Enables or disables writing the final index mark at the end of data part (after the last byte). Default value: 1. Don't turn it off. - - `merge_max_block_size` — Maximum number of rows in block for merge operations. Default value: 8192. - - `storage_policy` — Storage policy. See [Veri depolama için birden fazla blok cihazı kullanma](#table_engine-mergetree-multiple-volumes). - -**Bölüm ayarı örneği** - -``` sql -ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 -``` - -Örnekte, aylara göre bölümleme ayarladık. - -Biz de kullanıcı kimliği ile karma olarak örnekleme için bir ifade ayarlayın. Bu, her biri için tablodaki verileri pseudorandomize etmenizi sağlar `CounterID` ve `EventDate`. Tanım yoularsanız bir [SAMPLE](../../../sql_reference/statements/select.md#select-sample-clause) yan tümcesi verileri seçerken, ClickHouse kullanıcıların bir alt kümesi için eşit pseudorandom veri örneği döndürür. - -Bu `index_granularity` 8192 varsayılan değer olduğundan ayarı atlanabilir. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın. Mümkünse, eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] MergeTree(date-column [, sampling_expression], (primary, key), index_granularity) -``` - -**MergeTree () Parametreleri** - -- `date-column` — The name of a column of the [Tarihli](../../../sql_reference/data_types/date.md) tür. ClickHouse otomatik olarak bu sütuna göre ay bölümleri oluşturur. Bölüm adları `"YYYYMM"` biçimli. -- `sampling_expression` — An expression for sampling. -- `(primary, key)` — Primary key. Type: [Demet()](../../../sql_reference/data_types/tuple.md) -- `index_granularity` — The granularity of an index. The number of data rows between the “marks” bir dizinin. 8192 değeri çoğu görev için uygundur. - -**Örnek** - -``` sql -MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) -``` - -Bu `MergeTree` motor, Ana motor yapılandırma yöntemi için yukarıdaki örnekte olduğu gibi yapılandırılır. -
- -## Veri Depolama {#mergetree-data-storage} - -Bir tabloda birincil anahtar tarafından sıralanmış verileri bölümden oluşmaktadır. - -Veri bir tabloya eklendiğinde, ayrı veri parçaları oluşturulur ve bunların her biri birincil anahtara göre lexicographically sıralanır. Örneğin, birincil anahtar `(CounterID, Date)`, parçadaki veriler şu şekilde sıralanır `CounterID` ve içinde her `CounterID` tarafından sipariş edilir `Date`. - -Farklı bölümlere ait veriler farklı parçalara ayrılır. Arka planda, ClickHouse daha verimli depolama için veri parçalarını birleştirir. Farklı bölümlere ait parçalar birleştirilmez. Birleştirme mekanizması, aynı birincil anahtara sahip tüm satırların aynı veri bölümünde olacağını garanti etmez. - -Her veri parçası mantıksal olarak granüllere ayrılmıştır. Bir granül, Clickhouse'un veri seçerken okuduğu en küçük bölünmez veri kümesidir. ClickHouse satırları veya değerleri bölmez, bu nedenle her granül her zaman bir tamsayı satır içerir. Bir granülün ilk satırı, satır için birincil anahtarın değeri ile işaretlenir. Her veri bölümü için ClickHouse işaretleri depolayan bir dizin dosyası oluşturur. Her sütun için, birincil anahtarda olsun ya da olmasın, ClickHouse aynı işaretleri de saklar. Bu işaretler, verileri doğrudan sütun dosyalarında bulmanızı sağlar. - -Granül boyutu ile sınırlıdır `index_granularity` ve `index_granularity_bytes` tablo motorunun ayarları. Bir granüldeki satır sayısı `[1, index_granularity]` Aralık, satırların boyutuna bağlı olarak. Bir granülün boyutu aşabilir `index_granularity_bytes` tek bir satırın boyutu ayarın değerinden büyükse. Bu durumda, granülün boyutu satırın boyutuna eşittir. - -## Sorgularda birincil anahtarlar ve dizinler {#primary-keys-and-indexes-in-queries} - -Tak thee the `(CounterID, Date)` örnek olarak birincil anahtar. Bu durumda, sıralama ve dizin aşağıdaki gibi gösterilebilir: - - Whole data: [---------------------------------------------] - CounterID: [aaaaaaaaaaaaaaaaaabbbbcdeeeeeeeeeeeeefgggggggghhhhhhhhhiiiiiiiiikllllllll] - Date: [1111111222222233331233211111222222333211111112122222223111112223311122333] - Marks: | | | | | | | | | | | - a,1 a,2 a,3 b,3 e,2 e,3 g,1 h,2 i,1 i,3 l,3 - Marks numbers: 0 1 2 3 4 5 6 7 8 9 10 - -Veri sorgusu belirtirse: - -- `CounterID in ('a', 'h')`, sunucu işaretleri aralıklarında verileri okur `[0, 3)` ve `[6, 8)`. -- `CounterID IN ('a', 'h') AND Date = 3`, sunucu işaretleri aralıklarında verileri okur `[1, 3)` ve `[7, 8)`. -- `Date = 3`, sunucu işaretleri aralığında veri okur `[1, 10]`. - -Yukarıdaki örnekler, her zaman bir dizin tam taramadan daha etkili olduğunu göstermektedir. - -Seyrek bir dizin, ekstra verilerin okunmasına izin verir. Birincil anahtarın tek bir aralığını okurken, `index_granularity * 2` her veri bloğundaki ekstra satırlar okunabilir. - -Seyrek dizinler, çok sayıda tablo satırı ile çalışmanıza izin verir, çünkü çoğu durumda, bu tür dizinler bilgisayarın RAM'İNE sığar. - -ClickHouse benzersiz bir birincil anahtar gerektirmez. Aynı birincil anahtar ile birden çok satır ekleyebilirsiniz. - -### Birincil anahtar seçme {#selecting-the-primary-key} - -Birincil anahtardaki sütun sayısı açıkça sınırlı değildir. Veri yapısına bağlı olarak, birincil anahtara daha fazla veya daha az sütun ekleyebilirsiniz. Bu Mayıs: - -- Bir dizin performansını artırın. - - Birincil anahtar ise `(a, b)`, sonra başka bir sütun ekleyerek `c` aşağıdaki koşullar yerine getirilirse performansı artıracaktır: - - - Sütun üzerinde bir koşulu olan sorgular var `c`. - - Uzun veri aralıkları (birkaç kat daha uzun `index_granularity`) için aynı değer withlerle `(a, b)` yaygındır. Başka bir deyişle, başka bir sütun eklerken oldukça uzun veri aralıklarını atlamanıza izin verir. - -- Veri sıkıştırmasını geliştirin. - - ClickHouse verileri birincil anahtarla sıralar, bu nedenle tutarlılık ne kadar yüksek olursa sıkıştırma o kadar iyi olur. - -- Veri parçalarını birleştirirken ek mantık sağlayın [CollapsingMergeTree](collapsingmergetree.md#table_engine-collapsingmergetree) ve [SummingMergeTree](summingmergetree.md) motorlar. - - Bu durumda belirtmek mantıklı *sıralama anahtarı* bu birincil anahtardan farklıdır. - -Uzun bir birincil anahtar, ekleme performansını ve bellek tüketimini olumsuz yönde etkiler, ancak birincil anahtardaki ek sütunlar, ClickHouse performansını etkilemez `SELECT` sorgular. - -### Sıralama anahtarından farklı bir birincil anahtar seçme {#choosing-a-primary-key-that-differs-from-the-sorting-key} - -Sıralama anahtarından (veri bölümlerindeki satırları sıralamak için bir ifade) farklı bir birincil anahtar (her işaret için dizin dosyasında yazılan değerlere sahip bir ifade) belirtmek mümkündür. Bu durumda, birincil anahtar ifadesi tuple, sıralama anahtarı ifadesi tuple'ın bir öneki olmalıdır. - -Bu özellik kullanırken yararlıdır [SummingMergeTree](summingmergetree.md) ve -[AggregatingMergeTree](aggregatingmergetree.md) masa motorları. Bu motorları kullanırken yaygın bir durumda, tablonun iki tür sütunu vardır: *boyutlular* ve *ölçümler*. Tipik sorgular, rasgele ölçü sütunlarının değerlerini toplar `GROUP BY` ve boyutlara göre filtreleme. Çünkü SummingMergeTree ve AggregatingMergeTree sıralama anahtarının aynı değere sahip satırları toplamak, tüm boyutları eklemek doğaldır. Sonuç olarak, anahtar ifadesi uzun bir sütun listesinden oluşur ve bu liste yeni eklenen boyutlarla sık sık güncelleştirilmelidir. - -Bu durumda, birincil anahtarda verimli Aralık taramaları sağlayacak ve kalan boyut sütunlarını sıralama anahtarı kümesine ekleyecek yalnızca birkaç sütun bırakmak mantıklıdır. - -[ALTER](../../../sql_reference/statements/alter.md) yeni bir sütun aynı anda tabloya ve sıralama anahtarı eklendiğinde, varolan veri parçaları değiştirilmesi gerekmez, çünkü sıralama anahtarının hafif bir işlemdir. Eski sıralama anahtarı yeni sıralama anahtarının bir öneki olduğundan ve yeni eklenen sütunda veri olmadığından, veriler tablo değişikliği anında hem eski hem de yeni sıralama anahtarlarına göre sıralanır. - -### Sorgularda dizin ve bölümlerin kullanımı {#use-of-indexes-and-partitions-in-queries} - -İçin `SELECT` sorgular, ClickHouse bir dizin kullanılabilir olup olmadığını analiz eder. Eğer bir dizin kullanılabilir `WHERE/PREWHERE` yan tümce, bir eşitlik veya eşitsizlik karşılaştırma işlemini temsil eden bir ifadeye (bağlantı öğelerinden biri olarak veya tamamen) sahiptir veya varsa `IN` veya `LIKE` sütun veya birincil anahtar veya bölümleme anahtar veya bu sütunların belirli kısmen tekrarlayan işlevleri veya bu ifadelerin mantıksal ilişkileri olan ifadeler üzerinde sabit bir önek ile. - -Bu nedenle, birincil anahtarın bir veya daha fazla aralığındaki sorguları hızlı bir şekilde çalıştırmak mümkündür. Bu örnekte, belirli bir izleme etiketi, belirli bir etiket ve tarih aralığı, belirli bir etiket ve tarih için, tarih aralığına sahip birden çok etiket için vb. çalıştırıldığında sorgular hızlı olacaktır. - -Aşağıdaki gibi yapılandırılmış motora bakalım: - - ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 - -Bu durumda, sorgularda: - -``` sql -SELECT count() FROM table WHERE EventDate = toDate(now()) AND CounterID = 34 -SELECT count() FROM table WHERE EventDate = toDate(now()) AND (CounterID = 34 OR CounterID = 42) -SELECT count() FROM table WHERE ((EventDate >= toDate('2014-01-01') AND EventDate <= toDate('2014-01-31')) OR EventDate = toDate('2014-05-01')) AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) -``` - -ClickHouse, uygun olmayan verileri kırpmak için birincil anahtar dizinini ve uygun olmayan tarih aralıklarındaki bölümleri kırpmak için aylık bölümleme anahtarını kullanır. - -Yukarıdaki sorgular, dizinin karmaşık ifadeler için bile kullanıldığını göstermektedir. Tablodan okuma, dizini kullanarak tam taramadan daha yavaş olamayacak şekilde düzenlenmiştir. - -Aşağıdaki örnekte, dizin kullanılamaz. - -``` sql -SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' -``` - -Clickhouse'un bir sorgu çalıştırırken dizini kullanıp kullanamayacağını kontrol etmek için ayarları kullanın [force\_index\_by\_date](../../../operations/settings/settings.md#settings-force_index_by_date) ve [force\_primary\_key](../../../operations/settings/settings.md). - -Aylara göre bölümleme anahtarı, yalnızca uygun aralıktaki tarihleri içeren veri bloklarını okumanıza izin verir. Bu durumda, veri bloğu birçok tarih için veri içerebilir (bir aya kadar). Bir blok içinde veriler, ilk sütun olarak tarihi içermeyen birincil anahtara göre sıralanır. Bu nedenle, birincil anahtar önekini belirtmeyen yalnızca bir tarih koşulu ile bir sorgu kullanarak tek bir tarih için okunacak daha fazla veri neden olur. - -### Kısmen monotonik birincil anahtarlar için Endeks kullanımı {#use-of-index-for-partially-monotonic-primary-keys} - -Örneğin, Ayın günlerini düşünün. Onlar formu bir [monotonik dizisi](https://en.wikipedia.org/wiki/Monotonic_function) bir ay boyunca, ancak daha uzun süreler için monotonik değil. Bu kısmen monotonik bir dizidir. Bir kullanıcı kısmen monoton birincil anahtar ile tablo oluşturursa, ClickHouse her zamanki gibi seyrek bir dizin oluşturur. Bir kullanıcı bu tür bir tablodan veri seçtiğinde, ClickHouse sorgu koşullarını analiz eder. Kullanıcı, dizinin iki işareti arasında veri almak isterse ve bu işaretlerin her ikisi de bir ay içinde düşerse, ClickHouse bu özel durumda dizini kullanabilir, çünkü sorgu parametreleri ile dizin işaretleri arasındaki mesafeyi hesaplayabilir. - -Sorgu parametresi aralığındaki birincil anahtarın değerleri monotonik bir sırayı temsil etmiyorsa, ClickHouse bir dizin kullanamaz. Bu durumda, ClickHouse Tam Tarama yöntemini kullanır. - -ClickHouse bu mantığı yalnızca ay dizilerinin günleri için değil, kısmen monotonik bir diziyi temsil eden herhangi bir birincil anahtar için kullanır. - -### Veri atlama indeksleri (deneysel) {#table_engine-mergetree-data_skipping-indexes} - -Dizin bildirimi sütunlar bölümünde `CREATE` sorgu. - -``` sql -INDEX index_name expr TYPE type(...) GRANULARITY granularity_value -``` - -Tablolar için `*MergeTree` aile, veri atlama endeksleri belirtilebilir. - -Bu endeksler, bloklarda belirtilen ifade hakkında bazı bilgileri toplar ve bunlardan oluşur `granularity_value` granüller (granül boyutu kullanılarak belirtilir `index_granularity` tablo motoru ayarı). Daha sonra bu agregalar `SELECT` büyük veri bloklarını atlayarak diskten okunacak veri miktarını azaltmak için sorgular `where` sorgu tatmin edilemez. - -**Örnek** - -``` sql -CREATE TABLE table_name -( - u64 UInt64, - i32 Int32, - s String, - ... - INDEX a (u64 * i32, s) TYPE minmax GRANULARITY 3, - INDEX b (u64 * length(s)) TYPE set(1000) GRANULARITY 4 -) ENGINE = MergeTree() -... -``` - -Örneğin endeksleri aşağıdaki sorgularda diskten okunacak veri miktarını azaltmak için ClickHouse tarafından kullanılabilir: - -``` sql -SELECT count() FROM table WHERE s < 'z' -SELECT count() FROM table WHERE u64 * i32 == 10 AND u64 * length(s) >= 1234 -``` - -#### Mevcut Endeks Türleri {#available-types-of-indices} - -- `minmax` - - Belirtilen ifad (eyi saklar (ifad (enin `tuple`, sonra her eleman için aşırı depolar `tuple`), birincil anahtar gibi veri bloklarını atlamak için saklanan bilgileri kullanır. - -- `set(max_rows)` - - Belirtilen ifadenin benzersiz değerlerini depolar (en fazla `max_rows` satırlar, `max_rows=0` anlama “no limits”). Kontrol etmek için değerleri kullanır `WHERE` ifade, bir veri bloğu üzerinde tatmin edilemez değildir. - -- `ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Mağazalar a [Blo filterom filtre](https://en.wikipedia.org/wiki/Bloom_filter) bu, bir veri bloğundaki tüm ngramları içerir. Sadece dizeleri ile çalışır. Optimizasyonu için kullanılabilir `equals`, `like` ve `in` ifadeler. - - - `n` — ngram size, - - `size_of_bloom_filter_in_bytes` — Bloom filter size in bytes (you can use large values here, for example, 256 or 512, because it can be compressed well). - - `number_of_hash_functions` — The number of hash functions used in the Bloom filter. - - `random_seed` — The seed for Bloom filter hash functions. - -- `tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` - - Olarak aynı `ngrambf_v1`, ancak ngrams yerine simgeleri saklar. Belirteçler alfasayısal olmayan karakterlerle ayrılmış dizilerdir. - -- `bloom_filter([false_positive])` — Stores a [Blo filterom filtre](https://en.wikipedia.org/wiki/Bloom_filter) belirtilen sütunlar için. - - Opsiyonel `false_positive` parametre, filtreden yanlış pozitif yanıt alma olasılığıdır. Olası değerler: (0, 1). Varsayılan değer: 0.025. - - Desteklenen veri türleri: `Int*`, `UInt*`, `Float*`, `Enum`, `Date`, `DateTime`, `String`, `FixedString`, `Array`, `LowCardinality`, `Nullable`. - - Aşağıdaki işlevleri kullanabilirsiniz: [eşitlikler](../../../sql_reference/functions/comparison_functions.md), [notEquals](../../../sql_reference/functions/comparison_functions.md), [içinde](../../../sql_reference/functions/in_functions.md), [notİn](../../../sql_reference/functions/in_functions.md), [var](../../../sql_reference/functions/array_functions.md). - - - -``` sql -INDEX sample_index (u64 * length(s)) TYPE minmax GRANULARITY 4 -INDEX sample_index2 (u64 * length(str), i32 + f64 * 100, date, str) TYPE set(100) GRANULARITY 4 -INDEX sample_index3 (lower(str), str) TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4 -``` - -#### Fonksiyonları Destek {#functions-support} - -Koşulları `WHERE` yan tümcesi, sütunlarla çalışan işlevlerin çağrılarını içerir. Sütun bir dizinin bir parçasıysa, ClickHouse işlevleri gerçekleştirirken bu dizini kullanmaya çalışır. ClickHouse, dizinleri kullanmak için farklı işlev alt kümelerini destekler. - -Bu `set` dizin tüm fonksiyonları ile kullanılabilir. Diğer dizinler için işlev alt kümeleri aşağıdaki tabloda gösterilmiştir. - -| Fonksiyon (operatör) / dizin | birincil anahtar | minmax | ngrambf\_v1 | tokenbf\_v1 | bloom\_filter | -|------------------------------------------------------------------------------------------------------------|------------------|--------|-------------|-------------|---------------| -| [eşitlikler (=, ==)](../../../sql_reference/functions/comparison_functions.md#function-equals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notEquals(!=, \<\>)](../../../sql_reference/functions/comparison_functions.md#function-notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [hoşlanmak](../../../sql_reference/functions/string_search_functions.md#function-like) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [notLike](../../../sql_reference/functions/string_search_functions.md#function-notlike) | ✔ | ✔ | ✔ | ✗ | ✗ | -| [startsWith](../../../sql_reference/functions/string_functions.md#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | -| [endsWith](../../../sql_reference/functions/string_functions.md#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | -| [multiSearchAny](../../../sql_reference/functions/string_search_functions.md#function-multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | -| [içinde](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notİn](../../../sql_reference/functions/in_functions.md#in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | -| [daha az (\<)](../../../sql_reference/functions/comparison_functions.md#function-less) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [büyük (\>)](../../../sql_reference/functions/comparison_functions.md#function-greater) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [lessOrEquals (\<=)](../../../sql_reference/functions/comparison_functions.md#function-lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [greaterOrEquals (\>=)](../../../sql_reference/functions/comparison_functions.md#function-greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [boş](../../../sql_reference/functions/array_functions.md#function-empty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| [notEmpty](../../../sql_reference/functions/array_functions.md#function-notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | -| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | - -Ngram boyutundan daha az olan sabit bir argümana sahip işlevler tarafından kullanılamaz `ngrambf_v1` sorgu optimizasyonu için. - -Bloom filtreleri yanlış pozitif eşleşmelere sahip olabilir, bu yüzden `ngrambf_v1`, `tokenbf_v1`, ve `bloom_filter` dizinler, örneğin bir işlevin sonucunun false olması beklenen sorguları en iyi duruma getirmek için kullanılamaz: - -- Optimize edilebilir: - - `s LIKE '%test%'` - - `NOT s NOT LIKE '%test%'` - - `s = 1` - - `NOT s != 1` - - `startsWith(s, 'test')` -- Optimize edilemez: - - `NOT s LIKE '%test%'` - - `s NOT LIKE '%test%'` - - `NOT s = 1` - - `s != 1` - - `NOT startsWith(s, 'test')` - -## Eşzamanlı Veri Erişimi {#concurrent-data-access} - -Eşzamanlı tablo erişimi için çoklu sürüm kullanıyoruz. Başka bir deyişle, bir tablo aynı anda okunup güncelleştirildiğinde, sorgu sırasında geçerli olan bir parça kümesinden veri okunur. Uzun kilitler yok. Ekler okuma işlemlerinin yoluna girmez. - -Bir tablodan okuma otomatik olarak paralelleştirilir. - -## Sütunlar ve tablolar için TTL {#table_engine-mergetree-ttl} - -Değerlerin ömrünü belirler. - -Bu `TTL` yan tümcesi tüm tablo ve her sütun için ayarlanabilir. Tablo düzeyinde TTL ayrıca diskler ve birimler arasında otomatik veri taşıma mantığını belirtebilirsiniz. - -İfadeleri değerlendirmek gerekir [Tarihli](../../../sql_reference/data_types/date.md) veya [DateTime](../../../sql_reference/data_types/datetime.md) veri türü. - -Örnek: - -``` sql -TTL time_column -TTL time_column + interval -``` - -Tanımlamak `interval`, kullanma [zaman aralığı](../../../sql_reference/operators.md#operators-datetime) operatörler. - -``` sql -TTL date_time + INTERVAL 1 MONTH -TTL date_time + INTERVAL 15 HOUR -``` - -### Sütun TTL {#mergetree-column-ttl} - -Sütundaki değerler sona erdiğinde, ClickHouse bunları sütun veri türü için varsayılan değerlerle değiştirir. Veri bölümündeki tüm sütun değerleri sona ererse, ClickHouse bu sütunu bir dosya sistemindeki veri bölümünden siler. - -Bu `TTL` yan tümcesi anahtar sütunlar için kullanılamaz. - -Örnekler: - -TTL ile tablo oluşturma - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int TTL d + INTERVAL 1 MONTH, - b Int TTL d + INTERVAL 1 MONTH, - c String -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d; -``` - -Varolan bir tablonun sütununa TTL ekleme - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 DAY; -``` - -Sütun TTL değiştirme - -``` sql -ALTER TABLE example_table - MODIFY COLUMN - c String TTL d + INTERVAL 1 MONTH; -``` - -### Tablo TTL {#mergetree-table-ttl} - -Tablo, süresi dolmuş satırların kaldırılması için bir ifadeye ve parçaların arasında otomatik olarak taşınması için birden fazla ifadeye sahip olabilir [diskler veya birimler](#table_engine-mergetree-multiple-volumes). Tablodaki satırların süresi dolduğunda, ClickHouse ilgili tüm satırları siler. Parça taşıma özelliği için, bir parçanın tüm satırları hareket ifadesi ölçütlerini karşılaması gerekir. - -``` sql -TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ... -``` - -TTL kuralı türü her TTL ifadesini takip edebilir. İfade tatmin edildikten sonra yapılacak bir eylemi etkiler (şimdiki zamana ulaşır): - -- `DELETE` - süresi dolmuş satırları sil (varsayılan eylem); -- `TO DISK 'aaa'` - parçayı diske taşı `aaa`; -- `TO VOLUME 'bbb'` - parçayı diske taşı `bbb`. - -Örnekler: - -TTL ile tablo oluşturma - -``` sql -CREATE TABLE example_table -( - d DateTime, - a Int -) -ENGINE = MergeTree -PARTITION BY toYYYYMM(d) -ORDER BY d -TTL d + INTERVAL 1 MONTH [DELETE], - d + INTERVAL 1 WEEK TO VOLUME 'aaa', - d + INTERVAL 2 WEEK TO DISK 'bbb'; -``` - -Tablonun TTL değiştirme - -``` sql -ALTER TABLE example_table - MODIFY TTL d + INTERVAL 1 DAY; -``` - -**Verileri Kaldırma** - -ClickHouse veri parçalarını birleştirdiğinde süresi dolmuş bir TTL ile veri kaldırılır. - -ClickHouse, verilerin süresi dolduğunu gördüğünde, zamanlama dışı bir birleştirme gerçekleştirir. Bu tür birleştirmelerin sıklığını kontrol etmek için şunları ayarlayabilirsiniz [merge\_with\_ttl\_timeout](#mergetree_setting-merge_with_ttl_timeout). Değer çok düşükse, çok fazla kaynak tüketebilecek birçok zamanlama dışı birleştirme gerçekleştirir. - -Gerçekleştir theirseniz `SELECT` birleştirme arasında sorgu, süresi dolmuş veri alabilirsiniz. Bunu önlemek için, [OPTIMIZE](../../../sql_reference/statements/misc.md#misc_operations-optimize) önce sorgu `SELECT`. - -## Veri Depolama İçin Birden Fazla Blok Cihazı Kullanma {#table_engine-mergetree-multiple-volumes} - -### Giriş {#introduction} - -`MergeTree` aile tablo motorları birden fazla blok cihazlarda veri saklayabilirsiniz. Örneğin, belirli bir tablonun verileri örtük olarak bölündüğünde yararlı olabilir “hot” ve “cold”. En son veriler düzenli olarak talep edilir, ancak yalnızca az miktarda alan gerektirir. Aksine, yağ kuyruklu tarihsel veriler nadiren talep edilir. Birkaç disk varsa, “hot” veriler hızlı disklerde (örneğin, NVMe SSD'ler veya bellekte) bulunabilir; “cold” veri-nispeten yavaş olanlar (örneğin, HDD). - -Veri kısmı için minimum hareketli birimdir `MergeTree`- motor masaları. Bir parçaya ait veriler bir diskte saklanır. Veri parçaları arka planda diskler arasında (kullanıcı ayarlarına göre) ve aynı zamanda [ALTER](../../../sql_reference/statements/alter.md#alter_move-partition) sorgular. - -### Şartlar {#terms} - -- Disk — Block device mounted to the filesystem. -- Default disk — Disk that stores the path specified in the [yol](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-path) sunucu ayarı. -- Volume — Ordered set of equal disks (similar to [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures)). -- Storage policy — Set of volumes and the rules for moving data between them. - -Açıklanan varlıklara verilen isimler sistem tablolarında bulunabilir, [sistem.storage\_policies](../../../operations/system_tables.md#system_tables-storage_policies) ve [sistem.diskler](../../../operations/system_tables.md#system_tables-disks). Bir tablo için yapılandırılmış depolama ilkelerinden birini uygulamak için `storage_policy` ayarı `MergeTree`- motor aile tabloları. - -### Yapılandırma {#table_engine-mergetree-multiple-volumes-configure} - -Diskler, birimler ve depolama politikaları içinde bildirilmelidir `` ana dosyada ya etiket `config.xml` veya farklı bir dosyada `config.d` dizin. - -Yapılandırma yapısı: - -``` xml - - - - /mnt/fast_ssd/clickhouse/ - - - /mnt/hdd1/clickhouse/ - 10485760 - - - /mnt/hdd2/clickhouse/ - 10485760 - - - ... - - - ... - -``` - -Etiketler: - -- `` — Disk name. Names must be different for all disks. -- `path` — path under which a server will store data (`data` ve `shadow` klasörler) ile Sonlandır shouldılmalıdır ‘/’. -- `keep_free_space_bytes` — the amount of free disk space to be reserved. - -Disk tanımının sırası önemli değildir. - -Depolama ilkeleri yapılandırma biçimlendirme: - -``` xml - - ... - - - - - disk_name_from_disks_configuration - 1073741824 - - - - - - - 0.2 - - - - - - - - ... - -``` - -Etiketler: - -- `policy_name_N` — Policy name. Policy names must be unique. -- `volume_name_N` — Volume name. Volume names must be unique. -- `disk` — a disk within a volume. -- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume's disks. -- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1). - -Cofiguration örnekleri: - -``` xml - - ... - - - - - disk1 - disk2 - - - - - - - - fast_ssd - 1073741824 - - - disk1 - - - 0.2 - - - ... - -``` - -Verilen örnekte, `hdd_in_order` politika uygular [Ro -und-robin](https://en.wikipedia.org/wiki/Round-robin_scheduling) yaklaşma. Böylece bu politika yalnızca bir birim tanımlar (`single`), veri parçaları tüm disklerinde dairesel sırayla saklanır. Bu tür bir politika, sisteme birkaç benzer disk takılıysa, ancak RAID yapılandırılmamışsa oldukça yararlı olabilir. Her bir disk sürücüsünün güvenilir olmadığını ve bunu 3 veya daha fazla çoğaltma faktörü ile telafi etmek isteyebileceğinizi unutmayın. - -Sistemde farklı türde diskler varsa, `moving_from_ssd_to_hdd` politika yerine kullanılabilir. Birim `hot` bir SSD disk oluşur (`fast_ssd`) ve bu birimde saklanabilecek bir parçanın maksimum boyutu 1GB. Tüm parçaları ile boyutu daha büyük 1 GB üzerinde doğrudan saklanır `cold` bir HDD diski içeren birim `disk1`. -Ayrıca, bir kez disk `fast_ssd` 80'den fazla % tarafından doldurulur, veri transfer edilecektir `disk1` bir arka plan işlemi ile. - -Depolama ilkesi içindeki birim numaralandırma sırası önemlidir. Bir birim aşırı doldurulduktan sonra, veriler bir sonrakine taşınır. Disk numaralandırma sırası da önemlidir, çünkü veriler sırayla depolanır. - -Bir tablo oluştururken, yapılandırılmış depolama ilkelerinden birini ona uygulayabilirsiniz: - -``` sql -CREATE TABLE table_with_non_default_policy ( - EventDate Date, - OrderID UInt64, - BannerID UInt64, - SearchPhrase String -) ENGINE = MergeTree -ORDER BY (OrderID, BannerID) -PARTITION BY toYYYYMM(EventDate) -SETTINGS storage_policy = 'moving_from_ssd_to_hdd' -``` - -Bu `default` depolama ilkesi, Yalnızca verilen bir diskten oluşan yalnızca bir birim kullanmayı ima eder ``. Bir tablo oluşturulduktan sonra, depolama ilkesi değiştirilemez. - -### Ayrıntı {#details} - -Bu durumda `MergeTree` tablolar, veriler diske farklı şekillerde giriyor: - -- Bir ekleme sonucunda (`INSERT` sorgu). -- Arka plan birleştirmeleri sırasında ve [mutasyonlar](../../../sql_reference/statements/alter.md#alter-mutations). -- Başka bir kopyadan indirirken. -- Bölüm Don ofması sonucu [ALTER TABLE … FREEZE PARTITION](../../../sql_reference/statements/alter.md#alter_freeze-partition). - -Mutasyonlar ve bölüm dondurma hariç tüm bu durumlarda, bir parça verilen depolama politikasına göre bir birim ve bir diskte saklanır: - -1. Bir parçayı depolamak için yeterli disk alanına sahip olan ilk birim (tanım sırasına göre) (`unreserved_space > current_part_size`) ve belirli bir boyuttaki parçaların saklanmasına izin verir (`max_data_part_size_bytes > current_part_size`) seçilir. -2. Bu birimde, önceki veri yığınını depolamak için kullanılan ve parça boyutundan daha fazla boş alana sahip olan diski izleyen disk seçilir (`unreserved_space - keep_free_space_bytes > current_part_size`). - -Kap hoodut underun altında, [sabit linkler](https://en.wikipedia.org/wiki/Hard_link). Farklı diskler arasındaki sabit bağlantılar desteklenmez, bu nedenle bu gibi durumlarda ortaya çıkan parçalar ilk disklerle aynı disklerde saklanır. - -Arka planda, parçalar boş alan miktarına göre hacimler arasında taşınır (`move_factor` parametre) sırasına göre birimler yapılandırma dosyasında beyan edilir. -Veriler asla sonuncudan ve birincisine aktarılmaz. Bir sistem tabloları kullanabilirsiniz [sistem.part\_log](../../../operations/system_tables.md#system_tables-part-log) (alan `type = MOVE_PART`) ve [sistem.parçalar](../../../operations/system_tables.md#system_tables-parts) (alanlar `path` ve `disk`) arka plan hareketlerini izlemek için. Ayrıca, ayrıntılı bilgi sunucu günlüklerinde bulunabilir. - -Kullanıcı, sorguyu kullanarak bir bölümü veya bölümü bir birimden diğerine taşımaya zorlayabilir [ALTER TABLE … MOVE PART\|PARTITION … TO VOLUME\|DISK …](../../../sql_reference/statements/alter.md#alter_move-partition), arka plan işlemleri için tüm kısıtlamalar dikkate alınır. Sorgu, kendi başına bir hareket başlatır ve tamamlanması için arka plan işlemleri beklemez. Yeterli boş alan yoksa veya gerekli koşullardan herhangi biri karşılanmazsa kullanıcı bir hata mesajı alır. - -Veri taşıma veri çoğaltma ile müdahale etmez. Bu nedenle, farklı depolama ilkeleri aynı tablo için farklı yinelemeler üzerinde belirtilebilir. - -Arka plan birleşimlerinin ve mutasyonlarının tamamlanmasından sonra, eski parçalar yalnızca belirli bir süre sonra çıkarılır (`old_parts_lifetime`). -Bu süre zarfında, diğer birimlere veya disklere taşınmazlar. Bu nedenle, parçalar nihayet çıkarılıncaya kadar, işgal edilen disk alanının değerlendirilmesi için hala dikkate alınır. - -[Orijinal makale](https://clickhouse.tech/docs/ru/operations/table_engines/mergetree/) diff --git a/docs/tr/engines/table_engines/mergetree_family/replacingmergetree.md b/docs/tr/engines/table_engines/mergetree_family/replacingmergetree.md deleted file mode 100644 index baf2fc98b07..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/replacingmergetree.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 33 -toc_title: ReplacingMergeTree ---- - -# ReplacingMergeTree {#replacingmergetree} - -Motor farklıdır [MergeTree](mergetree.md#table_engines-mergetree) aynı birincil anahtar değerine sahip yinelenen girdileri kaldırır (veya daha doğru bir şekilde, aynı [sıralama anahtarı](mergetree.md) değer). - -Veri tekilleştirme yalnızca birleştirme sırasında oluşur. Birleştirme, arka planda bilinmeyen bir zamanda gerçekleşir, bu nedenle bunu planlayamazsınız. Bazı veriler işlenmemiş kalabilir. Kullanarak programsız bir birleştirme çalıştırabilirsiniz, ancak `OPTIMIZE` sorgu, kullanmaya güvenmeyin, çünkü `OPTIMIZE` sorgu büyük miktarda veri okuyacak ve yazacaktır. - -Böyle, `ReplacingMergeTree` yerden tasarruf etmek için arka planda yinelenen verileri temizlemek için uygundur, ancak kopyaların yokluğunu garanti etmez. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = ReplacingMergeTree([ver]) -[PARTITION BY expr] -[ORDER BY expr] -[PRIMARY KEY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -İstek parametrelerinin açıklaması için bkz. [istek açıklaması](../../../sql_reference/statements/create.md). - -**ReplacingMergeTree Parametreleri** - -- `ver` — column with version. Type `UInt*`, `Date` veya `DateTime`. İsteğe bağlı parametre. - - Birleş whenirken, `ReplacingMergeTree` aynı birincil anahtara sahip tüm satırlardan sadece bir tane bırakır: - - - Seç inimde son, eğer `ver` set değil. - - Maksimum sürümü ile, eğer `ver` belirtilen. - -**Sorgu yan tümceleri** - -Oluştururken bir `ReplacingMergeTree` tablo aynı [yanlar](mergetree.md) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) -``` - -Hariç tüm parametreler `ver` içinde olduğu gibi aynı anlama sahip `MergeTree`. - -- `ver` - sürümü ile sütun. İsteğe bağlı parametre. Bir açıklama için yukarıdaki metne bakın. - -
- -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/replacingmergetree/) diff --git a/docs/tr/engines/table_engines/mergetree_family/replication.md b/docs/tr/engines/table_engines/mergetree_family/replication.md deleted file mode 100644 index e9890c2652f..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/replication.md +++ /dev/null @@ -1,218 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 31 -toc_title: "Veri \xC7o\u011Faltma" ---- - -# Veri Çoğaltma {#table_engines-replication} - -Çoğaltma yalnızca mergetree ailesindeki tablolar için desteklenir: - -- ReplicatedMergeTree -- ReplicatedSummingMergeTree -- ReplicatedReplacingMergeTree -- ReplicatedAggregatingMergeTree -- ReplicatedCollapsingMergeTree -- ReplicatedVersionedCollapsingMergetree -- ReplicatedGraphiteMergeTree - -Çoğaltma, tüm sunucu değil, tek bir tablo düzeyinde çalışır. Bir sunucu hem çoğaltılmış hem de çoğaltılmamış tabloları aynı anda depolayabilir. - -Çoğaltma, parçaya bağlı değildir. Her parçanın kendi bağımsız çoğaltması vardır. - -İçin sıkıştırılmış veri `INSERT` ve `ALTER` sorgular çoğaltılır (daha fazla bilgi için bkz. [ALTER](../../../sql_reference/statements/alter.md#query_language_queries_alter)). - -`CREATE`, `DROP`, `ATTACH`, `DETACH` ve `RENAME` sorgular tek bir sunucuda yürütülür ve çoğaltılmaz: - -- Bu `CREATE TABLE` sorgu sorgu çalıştırıldığı sunucuda yeni bir replicatable tablo oluşturur. Bu tablo diğer sunucularda zaten varsa, yeni bir yineleme ekler. -- Bu `DROP TABLE` sorgu, sorgunun çalıştırıldığı sunucuda bulunan yinelemeyi siler. -- Bu `RENAME` sorgu yinelemeler birinde tabloyu yeniden adlandırır. Başka bir deyişle, çoğaltılmış tablolar farklı yinelemeler üzerinde farklı adlara sahip olabilir. - -ClickHouse kullanır [Apache ZooKeeper](https://zookeeper.apache.org) kopyaları meta bilgilerini saklamak için. ZooKeeper sürüm 3.4.5 veya daha yeni kullanın. - -Çoğaltma kullanmak için, parametreleri [zookeeper](../../../operations/server_configuration_parameters/settings.md#server-settings_zookeeper) sunucu yapılandırma bölümü. - -!!! attention "Dikkat" - Güvenlik ayarını ihmal etmeyin. ClickHouse destekler `digest` [ACLL şeması](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) ZooKeeper Güvenlik alt sisteminin. - -ZooKeeper kümesinin adreslerini ayarlama örneği: - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - - example3 - 2181 - - -``` - -Varolan herhangi bir ZooKeeper kümesini belirtebilirsiniz ve sistem kendi verileri için bir dizin kullanır (replicatable tablo oluştururken dizin belirtilir). - -Zookeeper yapılandırma dosyasında ayarlanmamışsa, çoğaltılmış tablolar oluşturamazsınız ve varolan çoğaltılmış tablolar salt okunur olacaktır. - -ZooKeeper kullanılmaz `SELECT` çoğaltma performansını etkilemez çünkü sorgular `SELECT` ve sorgular, çoğaltılmamış tablolar için yaptıkları kadar hızlı çalışır. Dağıtılmış çoğaltılmış tabloları sorgularken, ClickHouse davranışı ayarlar tarafından denetlenir [max\_replica\_delay\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-max_replica_delay_for_distributed_queries) ve [fallback\_to\_stale\_replicas\_for\_distributed\_queries](../../../operations/settings/settings.md#settings-fallback_to_stale_replicas_for_distributed_queries). - -Her biri için `INSERT` sorgu, yaklaşık on girişleri zookeeper birkaç işlemler aracılığıyla eklenir. (Daha kesin olmak gerekirse, bu eklenen her veri bloğu içindir; bir ekleme sorgusu her bir blok veya bir blok içerir `max_insert_block_size = 1048576` satırlar.) Bu, biraz daha uzun gecikmelere yol açar `INSERT` çoğaltılmamış tablolarla karşılaştırıldığında. Ancak, birden fazla olmayan gruplar halinde veri eklemek için önerileri izlerseniz `INSERT` saniyede, herhangi bir sorun yaratmaz. Bir ZooKeeper kümesini koordine etmek için kullanılan tüm ClickHouse kümesinin toplam birkaç yüzü vardır `INSERTs` saniyede. Veri eklerindeki verim (saniyede satır sayısı), çoğaltılmamış veriler için olduğu kadar yüksektir. - -Çok büyük kümeler için, farklı kırıklar için farklı ZooKeeper kümelerini kullanabilirsiniz. Ancak, bu Yandex'de gerekli değildir.Metrica küme (yaklaşık 300 sunucu). - -Çoğaltma zaman uyumsuz ve çok ana. `INSERT` sorgular (yanı sıra `ALTER`) mevcut herhangi bir sunucuya gönderilebilir. Veri sorgu çalıştırıldığı sunucuda eklenir ve sonra diğer sunuculara kopyalanır. Zaman uyumsuz olduğundan, son eklenen veriler bazı gecikme ile diğer yinelemeler görünür. Yinelemelerin bir kısmı mevcut değilse, veriler kullanılabilir olduklarında yazılır. Bir çoğaltma varsa, gecikme, sıkıştırılmış veri bloğunu ağ üzerinden aktarmak için gereken süredir. - -Varsayılan olarak, bir INSERT sorgusu yalnızca bir yinelemeden veri yazma onayı bekler. Verileri başarıyla yalnızca bir yineleme için yazılmıştır ve bu yineleme ile sunucu varolmaya sona erer, depolanan veriler kaybolur. Birden çok yinelemeden veri yazma onayını almayı etkinleştirmek için `insert_quorum` seçenek. - -Her veri bloğu atomik olarak yazılır. Ekle sorgusu kadar bloklara ayrılmıştır `max_insert_block_size = 1048576` satırlar. Diğer bir deyişle, `INSERT` sorgu 1048576 satırdan daha az, atomik olarak yapılır. - -Veri blokları tekilleştirilmiştir. Aynı veri bloğunun (aynı sırayla aynı satırları içeren aynı boyuttaki veri blokları) birden fazla yazımı için, blok yalnızca bir kez yazılır. Bunun nedeni, istemci uygulaması verilerin DB'YE yazılıp yazılmadığını bilmediğinde ağ arızaları durumunda, `INSERT` sorgu sadece tekrar edilebilir. Hangi çoğaltma eklerinin aynı verilerle gönderildiği önemli değildir. `INSERTs` idempotent vardır. Tekilleştirme parametreleri tarafından kontrol edilir [merge\_tree](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-merge_tree) sunucu ayarları. - -Çoğaltma sırasında, yalnızca eklenecek kaynak veriler ağ üzerinden aktarılır. Daha fazla veri dönüşümü (birleştirme), tüm kopyalarda aynı şekilde koordine edilir ve gerçekleştirilir. Bu, ağ kullanımını en aza indirir; bu, çoğaltmaların farklı veri merkezlerinde bulunduğu zaman çoğaltmanın iyi çalıştığı anlamına gelir. (Farklı veri merkezlerinde çoğaltmanın çoğaltmanın ana hedefi olduğunu unutmayın .) - -Aynı verilerin çoğaltmaları herhangi bir sayıda olabilir. Üye.Metrica üretimde çift çoğaltma kullanır. Her sunucu, bazı durumlarda RAID-5 veya RAID-6 ve RAID-10 kullanır. Bu nispeten güvenilir ve kullanışlı bir çözümdür. - -Sistem, yinelemelerdeki veri senkronizasyonunu izler ve bir hatadan sonra kurtarabilir. Yük devretme otomatik (verilerde küçük farklılıklar için) veya yarı otomatik (veriler çok fazla farklılık gösterdiğinde, bu da bir yapılandırma hatasını gösterebilir). - -## Çoğaltılmış Tablolar Oluşturma {#creating-replicated-tables} - -Bu `Replicated` önek tablo motoru adına eklenir. Mesela:`ReplicatedMergeTree`. - -**Çoğaltılan \* MergeTree parametreleri** - -- `zoo_path` — The path to the table in ZooKeeper. -- `replica_name` — The replica name in ZooKeeper. - -Örnek: - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}') -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -``` - -
- -Kullanımdan kaldırılmış sözdizimi örneği - -``` sql -CREATE TABLE table_name -( - EventDate DateTime, - CounterID UInt32, - UserID UInt32 -) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192) -``` - -
- -Örnekte gösterildiği gibi, bu parametreler kıvırcık köşeli ayraçlarda ikameler içerebilir. İkame edilen değerler ‘macros’ yapılandırma dosyasının bölümü. Örnek: - -``` xml - - 05 - 02 - example05-02-1.yandex.ru - -``` - -Zookeeper tablonun yolunu her çoğaltılmış tablo için benzersiz olmalıdır. Farklı parçalardaki tabloların farklı yolları olmalıdır. -Bu durumda, yol aşağıdaki parçalardan oluşur: - -`/clickhouse/tables/` ortak önek. Tam olarak bunu kullanmanızı öneririz. - -`{layer}-{shard}` shard tanımlayıcısıdır. Bu örnekte Yandex'den beri iki bölümden oluşmaktadır.Metrica küme iki seviyeli sharding kullanır. Çoğu görev için, yalnızca shard tanımlayıcısına genişletilecek olan {shard} ikamesini bırakabilirsiniz. - -`table_name` ZooKeeper tablo için düğüm adıdır. Tablo adı ile aynı yapmak için iyi bir fikirdir. Açıkça tanımlanır, çünkü tablo adının aksine, bir yeniden adlandırma sorgusundan sonra değişmez. -*HINT*: önüne bir veritabanı adı ekleyebilirsiniz `table_name` yanında. E. g. `db_name.table_name` - -Çoğaltma adı, aynı tablonun farklı yinelemelerini tanımlar. Örnekte olduğu gibi bunun için sunucu adını kullanabilirsiniz. Adın sadece her parça içinde benzersiz olması gerekir. - -Değiştirmeleri kullanmak yerine parametreleri açıkça tanımlayabilirsiniz. Bu, test etmek ve küçük kümeleri yapılandırmak için uygun olabilir. Ancak, dağıtılmış DDL sorguları kullanamazsınız (`ON CLUSTER` bu durumda). - -Büyük kümelerle çalışırken, hata olasılığını azalttıkları için değiştirmeleri kullanmanızı öneririz. - -Run the `CREATE TABLE` her yineleme üzerinde sorgu. Bu sorgu, yeni bir çoğaltılmış tablo oluşturur veya varolan bir yeni bir yineleme ekler. - -Tablo zaten diğer yinelemeler üzerinde bazı veriler içerdikten sonra yeni bir yineleme eklerseniz, verileri diğer yinelemeler için yeni bir sorgu çalıştırdıktan sonra kopyalanır. Başka bir deyişle, yeni çoğaltma kendisini diğerleriyle eşitler. - -Bir yineleme silmek için çalıştırın `DROP TABLE`. However, only one replica is deleted – the one that resides on the server where you run the query. - -## Arızalardan Sonra Kurtarma {#recovery-after-failures} - -Bir sunucu başlatıldığında ZooKeeper kullanılamıyorsa, çoğaltılmış tablolar salt okunur moda geçer. Sistem periyodik olarak ZooKeeper bağlanmaya çalışır. - -ZooKeeper sırasında kullanılamıyorsa bir `INSERT`, veya ZooKeeper ile etkileşimde bulunurken bir hata oluşur, bir istisna atılır. - -ZooKeeper bağlandıktan sonra, sistem yerel dosya sistemindeki veri kümesinin beklenen veri kümesiyle eşleşip eşleşmediğini kontrol eder (ZooKeeper bu bilgileri saklar). Küçük tutarsızlıklar varsa, sistem verileri kopyalarla senkronize ederek bunları çözer. - -Sistem bozuk veri parçalarını (yanlış dosya boyutu ile) veya tanınmayan parçaları (dosya sistemine yazılmış ancak Zookeeper'da kaydedilmemiş parçalar) tespit ederse, bunları `detached` alt dizin (silinmez). Eksik parçalar kopyalardan kopyalanır. - -Clickhouse'un büyük miktarda veriyi otomatik olarak silme gibi yıkıcı eylemler gerçekleştirmediğini unutmayın. - -Sunucu başlatıldığında (veya ZooKeeper ile yeni bir oturum kurduğunda), yalnızca tüm dosyaların miktarını ve boyutlarını kontrol eder. Dosya boyutları eşleşirse, ancak bayt ortasında bir yerde değiştirilmişse, bu hemen algılanmaz, ancak yalnızca bir dosya için verileri okumaya çalışırken algılanmaz. `SELECT` sorgu. Sorgu, eşleşen olmayan bir sağlama toplamı veya sıkıştırılmış bir bloğun boyutu hakkında bir özel durum atar. Bu durumda, veri parçaları doğrulama kuyruğuna eklenir ve gerekirse kopyalardan kopyalanır. - -Yerel veri kümesi beklenenden çok fazla farklıysa, bir güvenlik mekanizması tetiklenir. Sunucu bunu günlüğe girer ve başlatmayı reddeder. Bunun nedeni, bu durumda, bir parçadaki bir kopya yanlışlıkla farklı bir parçadaki bir kopya gibi yapılandırılmışsa gibi bir yapılandırma hatası gösterebilir. Ancak, bu mekanizma için eşikleri oldukça düşük ayarlanır ve bu durum normal hata kurtarma sırasında ortaya çıkabilir. Bu durumda, veriler yarı otomatik olarak geri yüklenir “pushing a button”. - -Kurtarma işlemini başlatmak için düğümü oluşturun `/path_to_table/replica_name/flags/force_restore_data` herhangi bir içerik ile ZooKeeper veya tüm çoğaltılmış tabloları geri yüklemek için komutu çalıştırın: - -``` bash -sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data -``` - -Sunucuyu yeniden başlatın. Başlangıçta, sunucu bu bayrakları siler ve kurtarma işlemini başlatır. - -## Tam Veri Kaybından Sonra Kurtarma {#recovery-after-complete-data-loss} - -Tüm veriler ve meta veriler sunuculardan birinden kaybolduysa, kurtarma için şu adımları izleyin: - -1. Clickhouse'u sunucuya yükleyin. Bunları kullanırsanız, shard tanımlayıcısı ve yinelemeleri içeren yapılandırma dosyasında doğru değiştirmelerin tanımlayın. -2. Sunucularda el ile çoğaltılması gereken yinelenmemiş tablolar varsa, verilerini bir kopyadan kopyalayın (dizinde `/var/lib/clickhouse/data/db_name/table_name/`). -3. Bulunan tablo tanım copylarını kopyala `/var/lib/clickhouse/metadata/` bir kopyadan. Tablo tanımlarında bir parça veya çoğaltma tanımlayıcısı açıkça tanımlanmışsa, bu kopyaya karşılık gelecek şekilde düzeltin. (Alternatif olarak, sunucuyu başlatın ve tüm `ATTACH TABLE` içinde olması gereken sorgular .sql dosyaları `/var/lib/clickhouse/metadata/`.) -4. Kurtarma işlemini başlatmak için ZooKeeper düğümünü oluşturun `/path_to_table/replica_name/flags/force_restore_data` herhangi bir içerikle veya tüm çoğaltılmış tabloları geri yüklemek için komutu çalıştırın: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` - -Ardından sunucuyu başlatın (zaten çalışıyorsa yeniden başlatın). Veriler kopyalardan indirilecektir. - -Alternatif bir kurtarma seçeneği zookeeper kayıp yineleme hakkında bilgi silmektir (`/path_to_table/replica_name`), daha sonra açıklandığı gibi yinelemeyi tekrar oluşturun “[Çoğaltılmış tablolar oluşturma](#creating-replicated-tables)”. - -Kurtarma sırasında ağ bant genişliği üzerinde herhangi bir kısıtlama yoktur. Aynı anda birçok yinelemeyi geri yüklüyorsanız bunu aklınızda bulundurun. - -## Mergetree'den Replicatedmergetree'ye Dönüştürme {#converting-from-mergetree-to-replicatedmergetree} - -Terimi kullanıyoruz `MergeTree` tüm tablo motorlarına başvurmak için `MergeTree family` için aynı `ReplicatedMergeTree`. - -Eğer olsaydı bir `MergeTree` el ile çoğaltılmış tablo, çoğaltılmış bir tabloya dönüştürebilirsiniz. Zaten büyük miktarda veri topladıysanız bunu yapmanız gerekebilir. `MergeTree` tablo ve şimdi çoğaltmayı etkinleştirmek istiyorsunuz. - -Veriler çeşitli yinelemelerde farklılık gösteriyorsa, önce onu eşitleyin veya bu verileri biri dışındaki tüm yinelemelerde silin. - -Varolan MergeTree tablosunu yeniden adlandırın, sonra bir `ReplicatedMergeTree` eski adı olan tablo. -Eski tablodan veri taşıma `detached` yeni tablo verileri ile dizin içindeki alt dizin (`/var/lib/clickhouse/data/db_name/table_name/`). -Sonra koş `ALTER TABLE ATTACH PARTITION` bu veri parçalarını çalışma kümesine eklemek için yinelemelerden birinde. - -## Replicatedmergetree'den Mergetree'ye Dönüştürme {#converting-from-replicatedmergetree-to-mergetree} - -Farklı bir adla bir MergeTree tablosu oluşturun. İle dizinden tüm verileri taşıyın `ReplicatedMergeTree` yeni tablonun veri dizinine tablo verileri. Sonra Sil `ReplicatedMergeTree` tablo ve sunucuyu yeniden başlatın. - -Eğer bir kurtulmak istiyorsanız `ReplicatedMergeTree` sunucu başlatmadan tablo: - -- İlgili sil `.sql` meta veri dizinindeki dosya (`/var/lib/clickhouse/metadata/`). -- ZooKeeper ilgili yolu silin (`/path_to_table/replica_name`). - -Bundan sonra, sunucuyu başlatabilir, bir `MergeTree` tablo, verileri kendi dizinine taşıyın ve sonra sunucuyu yeniden başlatın. - -## Zookeeper kümesindeki meta veriler kaybolduğunda veya zarar gördüğünde kurtarma {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} - -ZooKeeper içindeki veriler kaybolduysa veya hasar gördüyse, verileri yukarıda açıklandığı gibi yinelenmemiş bir tabloya taşıyarak kaydedebilirsiniz. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/replication/) diff --git a/docs/tr/engines/table_engines/mergetree_family/summingmergetree.md b/docs/tr/engines/table_engines/mergetree_family/summingmergetree.md deleted file mode 100644 index 15a58064ab4..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/summingmergetree.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 34 -toc_title: SummingMergeTree ---- - -# SummingMergeTree {#summingmergetree} - -Motor devralır [MergeTree](mergetree.md#table_engines-mergetree). Fark, veri parçalarını birleştirirken `SummingMergeTree` tablolar ClickHouse tüm satırları aynı birincil anahtarla değiştirir (veya daha doğru olarak, aynı [sıralama anahtarı](mergetree.md)) sayısal veri türüne sahip sütunlar için özetlenen değerleri içeren bir satır ile. Sıralama anahtarı, tek bir anahtar değeri çok sayıda satıra karşılık gelecek şekilde oluşturulursa, bu, depolama birimini önemli ölçüde azaltır ve veri seçimini hızlandırır. - -Motoru birlikte kullanmanızı öneririz `MergeTree`. Mağaza tam veri `MergeTree` tablo ve kullanım `SummingMergeTree` örneğin, rapor hazırlarken toplu veri depolamak için. Böyle bir yaklaşım, yanlış oluşturulmuş bir birincil anahtar nedeniyle değerli verileri kaybetmenizi önleyecektir. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = SummingMergeTree([columns]) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -İstek parametrelerinin açıklaması için bkz. [istek açıklaması](../../../sql_reference/statements/create.md). - -**SummingMergeTree parametreleri** - -- `columns` - değerlerin özetleneceği sütunların adlarına sahip bir tuple. İsteğe bağlı parametre. - Sütunlar sayısal tipte olmalı ve birincil anahtarda olmamalıdır. - - Eğer `columns` belirtilmemiş, ClickHouse birincil anahtarda olmayan bir sayısal veri türü ile tüm sütunlardaki değerleri özetler. - -**Sorgu yan tümceleri** - -Oluştururken bir `SummingMergeTree` tablo aynı [yanlar](mergetree.md) oluşturul ,urken olduğu gibi gerekli `MergeTree` Tablo. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın ve mümkünse eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) -``` - -Hariç tüm parametreler `columns` içinde olduğu gibi aynı anlama sahip `MergeTree`. - -- `columns` — tuple with names of columns values of which will be summarized. Optional parameter. For a description, see the text above. - -
- -## Kullanım Örneği {#usage-example} - -Aşağıdaki tabloyu düşünün: - -``` sql -CREATE TABLE summtt -( - key UInt32, - value UInt32 -) -ENGINE = SummingMergeTree() -ORDER BY key -``` - -Veri Ekle: - -``` sql -INSERT INTO summtt Values(1,1),(1,2),(2,1) -``` - -ClickHouse tüm satırları tamamen toplayabilir ([aşağıya bakın](#data-processing)), bu yüzden bir toplama işlevi kullanıyoruz `sum` ve `GROUP BY` sorguda yan tümcesi. - -``` sql -SELECT key, sum(value) FROM summtt GROUP BY key -``` - -``` text -┌─key─┬─sum(value)─┐ -│ 2 │ 1 │ -│ 1 │ 3 │ -└─────┴────────────┘ -``` - -## Veri İşleme {#data-processing} - -Veriler bir tabloya eklendiğinde, bunlar olduğu gibi kaydedilir. ClickHouse, verilerin eklenen bölümlerini periyodik olarak birleştirir ve bu, aynı birincil anahtara sahip satırların toplandığı ve sonuçta elde edilen her veri parçası için bir tane ile değiştirildiği zamandır. - -ClickHouse can merge the data parts so that different resulting parts of data cat consist rows with the same primary key, i.e. the summation will be incomplete. Therefore (`SELECT`) bir toplama fonksiyonu [toplam()](../../../sql_reference/aggregate_functions/reference.md#agg_function-sum) ve `GROUP BY` yukarıdaki örnekte açıklandığı gibi yan tümcesi bir sorguda kullanılmalıdır. - -### Toplama İçin Ortak Kurallar {#common-rules-for-summation} - -Sayısal veri türüne sahip sütunlardaki değerler özetlenir. Sütun kümesi parametre tarafından tanımlanır `columns`. - -Değerler toplamı için tüm sütunlarda 0 ise, satır silinir. - -Sütun birincil anahtarda değilse ve özetlenmezse, mevcut olanlardan rasgele bir değer seçilir. - -Değerler, birincil anahtardaki sütunlar için özetlenmez. - -### Aggregatefunction Sütunlarındaki toplama {#the-summation-in-the-aggregatefunction-columns} - -Sütunlar için [AggregateFunction türü](../../../sql_reference/data_types/aggregatefunction.md) ClickHouse olarak davranır [AggregatingMergeTree](aggregatingmergetree.md) işleve göre motor toplama. - -### İç İçe Yapılar {#nested-structures} - -Tablo, özel bir şekilde işlenen iç içe geçmiş veri yapılarına sahip olabilir. - -İç içe geçmiş bir tablonun adı ile bitiyorsa `Map` ve aşağıdaki kriterleri karşılayan en az iki sütun içerir: - -- ilk sütun sayısal `(*Int*, Date, DateTime)` veya bir dize `(String, FixedString)` hadi diyelim `key`, -- diğer sütunlar aritmetik `(*Int*, Float32/64)` hadi diyelim `(values...)`, - -sonra bu iç içe geçmiş tablo bir eşleme olarak yorumlanır `key => (values...)` ve satırlarını birleştirirken, iki veri kümesinin öğeleri şu şekilde birleştirilir `key` karşılık gelen bir toplamı ile `(values...)`. - -Örnekler: - -``` text -[(1, 100)] + [(2, 150)] -> [(1, 100), (2, 150)] -[(1, 100)] + [(1, 150)] -> [(1, 250)] -[(1, 100)] + [(1, 150), (2, 150)] -> [(1, 250), (2, 150)] -[(1, 100), (2, 150)] + [(1, -100)] -> [(2, 150)] -``` - -Veri isterken, [sumMap (anahtar, değer)](../../../sql_reference/aggregate_functions/reference.md) toplama fonksiyonu `Map`. - -İç içe geçmiş veri yapısı için, sütunlarının toplamı için sütun kümesinde belirtmeniz gerekmez. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/summingmergetree/) diff --git a/docs/tr/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md b/docs/tr/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md deleted file mode 100644 index b9adb381783..00000000000 --- a/docs/tr/engines/table_engines/mergetree_family/versionedcollapsingmergetree.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 37 -toc_title: VersionedCollapsingMergeTree ---- - -# VersionedCollapsingMergeTree {#versionedcollapsingmergetree} - -Bu motor: - -- Sürekli değişen nesne durumlarının hızlı yazılmasını sağlar. -- Arka planda eski nesne durumlarını siler. Bu, depolama hacmini önemli ölçüde azaltır. - -Bölümüne bakınız [Çökme](#table_engines_versionedcollapsingmergetree) ayrıntılar için. - -Motor devralır [MergeTree](mergetree.md#table_engines-mergetree) ve veri parçalarını birleştirmek için algoritmaya satırları daraltmak için mantığı ekler. `VersionedCollapsingMergeTree` aynı amaca hizmet eder [CollapsingMergeTree](collapsingmergetree.md) ancak, verilerin birden çok iş parçacığıyla herhangi bir sıraya yerleştirilmesine izin veren farklı bir çökme algoritması kullanır. Özellikle, `Version` sütun, yanlış sıraya yerleştirilmiş olsalar bile satırları düzgün bir şekilde daraltmaya yardımcı olur. Tersine, `CollapsingMergeTree` sadece kesinlikle ardışık ekleme sağlar. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = VersionedCollapsingMergeTree(sign, version) -[PARTITION BY expr] -[ORDER BY expr] -[SAMPLE BY expr] -[SETTINGS name=value, ...] -``` - -Sorgu parametrelerinin açıklaması için bkz: [sorgu açıklaması](../../../sql_reference/statements/create.md). - -**Motor Parametreleri** - -``` sql -VersionedCollapsingMergeTree(sign, version) -``` - -- `sign` — Name of the column with the type of row: `1` is a “state” satır, `-1` is a “cancel” satır. - - Sütun veri türü olmalıdır `Int8`. - -- `version` — Name of the column with the version of the object state. - - Sütun veri türü olmalıdır `UInt*`. - -**Sorgu Yan Tümceleri** - -Oluştururken bir `VersionedCollapsingMergeTree` tablo, aynı [yanlar](mergetree.md) oluşturul aurken gerekli `MergeTree` Tablo. - -
- -Bir tablo oluşturmak için kullanımdan kaldırılan yöntem - -!!! attention "Dikkat" - Bu yöntemi yeni projelerde kullanmayın. Mümkünse, eski projeleri yukarıda açıklanan yönteme geçin. - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE [=] VersionedCollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, sign, version) -``` - -Dışındaki tüm parametreler `sign` ve `version` içinde olduğu gibi aynı anlama sahip `MergeTree`. - -- `sign` — Name of the column with the type of row: `1` is a “state” satır, `-1` is a “cancel” satır. - - Column Data Type — `Int8`. - -- `version` — Name of the column with the version of the object state. - - Sütun veri türü olmalıdır `UInt*`. - -
- -## Çökme {#table_engines-versionedcollapsingmergetree} - -### Veriler {#data} - -Bazı nesneler için sürekli değişen verileri kaydetmeniz gereken bir durumu düşünün. Bir nesne için bir satıra sahip olmak ve değişiklikler olduğunda satırı güncellemek mantıklıdır. Ancak, depolama alanındaki verileri yeniden yazmayı gerektirdiğinden, güncelleştirme işlemi bir DBMS için pahalı ve yavaştır. Verileri hızlı bir şekilde yazmanız gerekiyorsa güncelleştirme kabul edilemez, ancak değişiklikleri bir nesneye sırayla aşağıdaki gibi yazabilirsiniz. - -Kullan... `Sign` satır yazarken sütun. Eğer `Sign = 1` bu, satırın bir nesnenin durumu olduğu anlamına gelir (diyelim “state” satır). Eğer `Sign = -1` aynı özelliklere sahip bir nesnenin durumunun iptal edildiğini gösterir (buna “cancel” satır). Ayrıca kullanın `Version` bir nesnenin her durumunu ayrı bir sayı ile tanımlaması gereken sütun. - -Örneğin, kullanıcıların bazı sitede kaç sayfa ziyaret ettiğini ve ne kadar süre orada olduklarını hesaplamak istiyoruz. Bir noktada, kullanıcı etkinliği durumu ile aşağıdaki satırı yazıyoruz: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Bir noktada daha sonra kullanıcı aktivitesinin değişikliğini kaydediyoruz ve aşağıdaki iki satırla yazıyoruz. - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -İlk satır, nesnenin (kullanıcı) önceki durumunu iptal eder. Dışında iptal edilen Devletin tüm alanlarını kopya shouldlama shouldlıdır `Sign`. - -İkinci satır geçerli durumu içerir. - -Sadece kullanıcı etkinliğinin son durumuna ihtiyacımız olduğundan, satırlar - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -nesnenin geçersiz (eski) durumunu daraltarak silinebilir. `VersionedCollapsingMergeTree` veri parçalarını birleştirirken bunu yapar. - -Her değişiklik için neden iki satıra ihtiyacımız olduğunu bulmak için bkz. [Algoritma](#table_engines-versionedcollapsingmergetree-algorithm). - -**Kullanımı ile ilgili notlar** - -1. Verileri yazan program, iptal etmek için bir nesnenin durumunu hatırlamalıdır. Bu “cancel” dize bir kopyası olmalıdır “state” tersi ile dize `Sign`. Bu, ilk depolama boyutunu arttırır, ancak verileri hızlı bir şekilde yazmanıza izin verir. -2. Sütunlardaki uzun büyüyen diziler, yazma yükü nedeniyle motorun verimliliğini azaltır. Daha basit veri, daha iyi verim. -3. `SELECT` sonuçlara itiraz değişiklikleri tarihinin tutarlılık bağlıdır. Ekleme için veri hazırlarken doğru olun. Oturum derinliği gibi negatif olmayan metrikler için negatif değerler gibi tutarsız verilerle öngörülemeyen sonuçlar alabilirsiniz. - -### Algoritma {#table_engines-versionedcollapsingmergetree-algorithm} - -ClickHouse veri parçalarını birleştirdiğinde, aynı birincil anahtar ve sürüm ve farklı olan her satır çiftini siler `Sign`. Satırların sırası önemli değil. - -ClickHouse veri eklediğinde, satırları birincil anahtarla sipariş eder. Eğer... `Version` sütun birincil anahtarda değil, ClickHouse onu birincil anahtara örtük olarak son alan olarak ekler ve sipariş vermek için kullanır. - -## Veri Seçme {#selecting-data} - -ClickHouse, aynı birincil anahtara sahip tüm satırların aynı sonuçtaki veri bölümünde veya hatta aynı fiziksel sunucuda olacağını garanti etmez. Bu, hem verileri yazmak hem de veri parçalarının daha sonra birleştirilmesi için geçerlidir. Ayrıca, ClickHouse süreçleri `SELECT` birden çok iş parçacıklarıyla sorgular ve sonuçtaki satırların sırasını tahmin edemez. Bu tamamen almak için bir ihtiyaç varsa toplama gerekli olduğu anlamına gelir “collapsed” bir veri `VersionedCollapsingMergeTree` Tablo. - -Daraltmayı sonuçlandırmak için, bir sorgu ile bir sorgu yazın `GROUP BY` yan tümce ve işareti için hesap toplama işlevleri. Örneğin, miktarı hesaplamak için kullanın `sum(Sign)` yerine `count()`. Bir şeyin toplamını hesaplamak için şunları kullanın `sum(Sign * x)` yerine `sum(x)` ve Ekle `HAVING sum(Sign) > 0`. - -Toplanan `count`, `sum` ve `avg` bu şekilde hesaplanabilir. Toplanan `uniq` bir nesnenin en az bir daraltılmamış durumu varsa hesaplanabilir. Toplanan `min` ve `max` hesaplan becauseamaz çünkü `VersionedCollapsingMergeTree` çökmüş durumların değerlerinin geçmişini kaydetmez. - -İle verileri ayıklamak gerekiyorsa “collapsing” ancak toplama olmadan (örneğin, en yeni değerleri belirli koşullarla eşleşen satırların mevcut olup olmadığını kontrol etmek için) `FINAL` değiştirici için `FROM` yan. Bu yaklaşım verimsizdir ve büyük tablolarla kullanılmamalıdır. - -## Kullanım Örneği {#example-of-use} - -Örnek veriler: - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 | -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 | -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 | -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Tablo oluşturma: - -``` sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8, - Version UInt8 -) -ENGINE = VersionedCollapsingMergeTree(Sign, Version) -ORDER BY UserID -``` - -Veri ekleme: - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) -``` - -``` sql -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) -``` - -Biz iki kullanın `INSERT` iki farklı veri parçası oluşturmak için sorgular. Verileri tek bir sorgu ile eklersek, ClickHouse bir veri parçası oluşturur ve hiçbir zaman birleştirme gerçekleştirmez. - -Veri alma: - -``` sql -SELECT * FROM UAct -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ 1 │ 1 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 5 │ 146 │ -1 │ 1 │ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Burada ne görüyoruz ve çökmüş parçalar nerede? -İki veri parçasını iki kullanarak oluşturduk `INSERT` sorgular. Bu `SELECT` sorgu iki iş parçacığında gerçekleştirildi ve sonuç rastgele bir satır sırasıdır. -Veri bölümleri henüz birleştirilmediği için çökme gerçekleşmedi. ClickHouse biz tahmin edemez zaman içinde bilinmeyen bir noktada veri parçalarını birleştirir. - -Bu yüzden toplamaya ihtiyacımız var: - -``` sql -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration, - Version -FROM UAct -GROUP BY UserID, Version -HAVING sum(Sign) > 0 -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 2 │ -└─────────────────────┴───────────┴──────────┴─────────┘ -``` - -Toplamaya ihtiyacımız yoksa ve çökmeyi zorlamak istiyorsak, `FINAL` değiştirici için `FROM` yan. - -``` sql -SELECT * FROM UAct FINAL -``` - -``` text -┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ -│ 4324182021466249494 │ 6 │ 185 │ 1 │ 2 │ -└─────────────────────┴───────────┴──────────┴──────┴─────────┘ -``` - -Bu, verileri seçmek için çok verimsiz bir yoldur. Büyük tablolar için kullanmayın. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/versionedcollapsingmergetree/) diff --git a/docs/tr/engines/table_engines/special/buffer.md b/docs/tr/engines/table_engines/special/buffer.md deleted file mode 100644 index fa53822ab2b..00000000000 --- a/docs/tr/engines/table_engines/special/buffer.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 45 -toc_title: Arabellek ---- - -# Arabellek {#buffer} - -RAM'de yazmak için verileri tamponlar, periyodik olarak başka bir tabloya temizler. Okuma işlemi sırasında veri arabellekten ve diğer tablodan aynı anda okunur. - -``` sql -Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes) -``` - -Motor parametreleri: - -- `database` – Database name. Instead of the database name, you can use a constant expression that returns a string. -- `table` – Table to flush data to. -- `num_layers` – Parallelism layer. Physically, the table will be represented as `num_layers` bağımsız tamponların. Önerilen değer: 16. -- `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, ve `max_bytes` – Conditions for flushing data from the buffer. - -Veri arabellekten temizlendi ve hedef tabloya yazılır eğer tüm `min*` koşulları veya en az bir `max*` koşul karşı arelanır. - -- `min_time`, `max_time` – Condition for the time in seconds from the moment of the first write to the buffer. -- `min_rows`, `max_rows` – Condition for the number of rows in the buffer. -- `min_bytes`, `max_bytes` – Condition for the number of bytes in the buffer. - -Yazma işlemi sırasında veri bir `num_layers` rastgele tampon sayısı. Veya, eklenecek veri kısmı yeterince büyükse (daha büyük `max_rows` veya `max_bytes`), arabelleği atlayarak doğrudan hedef tabloya yazılır. - -Verilerin yıkanması için koşullar, her biri için ayrı ayrı hesaplanır. `num_layers` arabellekler. Örneğin, `num_layers = 16` ve `max_bytes = 100000000`, maksimum RAM tüketimi 1,6 GB'DİR. - -Örnek: - -``` sql -CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000) -``` - -Oluşturma Bir ‘merge.hits\_buffer’ ile aynı yapıya sahip tablo ‘merge.hits’ ve Tampon motorunu kullanarak. Bu tabloya yazarken, veriler RAM'de arabelleğe alınır ve daha sonra ‘merge.hits’ Tablo. 16 tamponlar oluşturulur. 100 saniye geçti veya bir milyon satır yazılmış veya 100 MB veri yazılmıştır; ya da aynı anda 10 saniye geçti ve 10.000 satır ve 10 MB veri yazılmıştır, bunların her veri temizlendi. Örneğin, sadece bir satır yazılmışsa, 100 saniye sonra ne olursa olsun, yıkanacaktır. Ancak, birçok satır yazılmışsa, veriler daha erken temizlenecektir. - -Sunucu DROP TABLE veya DETACH TABLE ile durdurulduğunda, arabellek verileri de hedef tabloya temizlendi. - -Veritabanı ve tablo adı için tek tırnak içinde boş dizeleri ayarlayabilirsiniz. Bu, bir hedef tablonun yokluğunu gösterir. Bu durumda, Veri Temizleme koşullarına ulaşıldığında, arabellek basitçe temizlenir. Bu, bir veri penceresini bellekte tutmak için yararlı olabilir. - -Bir arabellek tablosundan okurken, veriler hem arabellekten hem de hedef tablodan (varsa) işlenir. -Arabellek tabloları bir dizin desteklemediğini unutmayın. Başka bir deyişle, arabellekteki veriler tamamen taranır, bu da büyük arabellekler için yavaş olabilir. (Alt tablodaki veriler için, desteklediği dizin kullanılacaktır.) - -Arabellek tablosundaki sütun kümesi, alt tablodaki sütun kümesiyle eşleşmiyorsa, her iki tabloda da bulunan sütunların bir alt kümesi eklenir. - -Türleri arabellek tablo ve alt tablo sütunlarından biri için eşleşmiyorsa, sunucu günlüğüne bir hata iletisi girilir ve arabellek temizlenir. -Arabellek temizlendiğinde alt tablo yoksa aynı şey olur. - -Eğer bağımlı bir tablo ve Tampon tablo için ALTER çalıştırmak gerekiyorsa, ilk Tampon tablo silme, alt tablo için ALTER çalışan, sonra tekrar Tampon tablo oluşturma öneririz. - -Sunucu anormal şekilde yeniden başlatılırsa, arabellekteki veriler kaybolur. - -Son ve örnek arabellek tabloları için düzgün çalışmıyor. Bu koşullar hedef tabloya geçirilir, ancak arabellekte veri işlemek için kullanılmaz. Bu özellikler gerekiyorsa, hedef tablodan okurken yalnızca yazma için arabellek tablosunu kullanmanızı öneririz. - -Bir arabelleğe veri eklerken, arabelleklerden biri kilitlenir. Bir okuma işlemi aynı anda tablodan gerçekleştiriliyor, bu gecikmelere neden olur. - -Bir arabellek tablosuna eklenen veriler, alt tabloda farklı bir sırada ve farklı bloklarda sonuçlanabilir. Bu nedenle, bir arabellek tablo CollapsingMergeTree doğru yazmak için kullanmak zordur. Sorunları önlemek için şunları ayarlayabilirsiniz ‘num\_layers’ 1'e. - -Hedef tablo yinelenirse, bir arabellek tablosuna yazarken yinelenmiş tabloların bazı beklenen özellikleri kaybolur. Satır ve veri parçaları boyutlarda sipariş için rasgele değişiklikler veri çoğaltma güvenilir olması mümkün olmadığını ifade eden çalışma, kapanmasına neden ‘exactly once’ çoğaltılan tablolara yazın. - -Bu dezavantajlardan dolayı, nadir durumlarda yalnızca bir arabellek tablosu kullanmanızı önerebiliriz. - -Bir arabellek tablosu, bir zaman birimi üzerinden çok sayıda sunucudan çok fazla ekleme alındığında kullanılır ve ekleme işleminden önce veri arabelleğe alınamaz, bu da eklerin yeterince hızlı çalışamayacağı anlamına gelir. - -Arabellek tabloları için bile, her seferinde bir satır veri eklemek mantıklı olmadığını unutmayın. Bu, yalnızca saniyede birkaç bin satırlık bir hız üretirken, daha büyük veri blokları eklemek saniyede bir milyondan fazla satır üretebilir (bölüme bakın “Performance”). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/buffer/) diff --git a/docs/tr/engines/table_engines/special/dictionary.md b/docs/tr/engines/table_engines/special/dictionary.md deleted file mode 100644 index ce02429a31f..00000000000 --- a/docs/tr/engines/table_engines/special/dictionary.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 35 -toc_title: "S\xF6zl\xFCk" ---- - -# Sözlük {#dictionary} - -Bu `Dictionary` motor görüntüler [sözlük](../../../sql_reference/dictionaries/external_dictionaries/external_dicts.md) bir ClickHouse tablo olarak veri. - -Örnek olarak, bir sözlük düşünün `products` aşağıdaki yapılandırma ile: - -``` xml - - - products - - -
products
- DSN=some-db-server - - - - 300 - 360 - - - - - - - product_id - - - title - String - - - - - -``` - -Sözlük verilerini sorgula: - -``` sql -SELECT - name, - type, - key, - attribute.names, - attribute.types, - bytes_allocated, - element_count, - source -FROM system.dictionaries -WHERE name = 'products' -``` - -``` text -┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐ -│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │ -└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘ -``` - -Kullanabilirsiniz [dictGet\*](../../../sql_reference/functions/ext_dict_functions.md#ext_dict_functions) sözlük verilerini bu formatta almak için işlev. - -Bu görünüm, ham veri almanız gerektiğinde veya bir `JOIN` işleyiş. Bu durumlar için şunları kullanabilirsiniz `Dictionary` bir tabloda sözlük verilerini görüntüleyen motor. - -Sözdizimi: - -``` sql -CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` -``` - -Kullanım örneği: - -``` sql -create table products (product_id UInt64, title String) Engine = Dictionary(products); -``` - - Ok - -Masada ne olduğuna bir bak. - -``` sql -select * from products limit 1; -``` - -``` text -┌────product_id─┬─title───────────┐ -│ 152689 │ Some item │ -└───────────────┴─────────────────┘ -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/dictionary/) diff --git a/docs/tr/engines/table_engines/special/distributed.md b/docs/tr/engines/table_engines/special/distributed.md deleted file mode 100644 index 28cb0e0855d..00000000000 --- a/docs/tr/engines/table_engines/special/distributed.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 33 -toc_title: "Da\u011F\u0131l\u0131" ---- - -# Dağılı {#distributed} - -**Dağıtılmış altyapısı olan tablolar kendileri tarafından herhangi bir veri depolamaz**, ancak birden çok sunucuda dağıtılmış sorgu işleme izin verir. -Okuma otomatik olarak paralelleştirilir. Bir okuma sırasında, varsa uzak sunucularda tablo dizinleri kullanılır. - -Dağıtılmış motor parametreleri kabul eder: - -- sunucunun yapılandırma dosyasındaki küme adı - -- uzak veritabanı adı - -- uzak bir tablonun adı - -- (isteğe bağlı olarak) sharding anahtarı - -- (isteğe bağlı olarak) ilke adı, zaman uyumsuz göndermek için geçici dosyaları depolamak için kullanılacaktır - - Ayrıca bakınız: - - - `insert_distributed_sync` ayar - - [MergeTree](../mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) örnekler için - -Örnek: - -``` sql -Distributed(logs, default, hits[, sharding_key[, policy_name]]) -``` - -Veri tüm sunuculardan okunacak ‘logs’ küme, varsayılan değerden.kümedeki her sunucuda bulunan hits tablosu. -Veriler yalnızca okunmakla kalmaz, aynı zamanda uzak sunucularda kısmen işlenir (bunun mümkün olduğu ölçüde). -Örneğin, GROUP BY ile bir sorgu için uzak sunucularda veri toplanır ve toplama işlevlerinin Ara durumları istek sahibi sunucuya gönderilir. Daha sonra veriler daha fazla toplanacaktır. - -Veritabanı adı yerine, bir dize döndüren sabit bir ifade kullanabilirsiniz. Örneğin: currentDatabase (). - -logs – The cluster name in the server's config file. - -Kümeler şöyle ayarlanır: - -``` xml - - - - - 1 - - false - - example01-01-1 - 9000 - - - example01-01-2 - 9000 - - - - 2 - false - - example01-02-1 - 9000 - - - example01-02-2 - 1 - 9440 - - - - -``` - -Burada bir küme adı ile tanımlanır ‘logs’ bu, her biri iki kopya içeren iki parçadan oluşur. -Kırıklar, verilerin farklı bölümlerini içeren sunuculara başvurur (tüm verileri okumak için tüm kırıklara erişmeniz gerekir). -Yinelemeler sunucuları çoğaltılıyor (tüm verileri okumak için, yinelemelerden herhangi birinde verilere erişebilirsiniz). - -Küme adları nokta içermemelidir. - -Parametre `host`, `port` ve isteğe bağlı olarak `user`, `password`, `secure`, `compression` her sunucu için belirtilir: -- `host` – The address of the remote server. You can use either the domain or the IPv4 or IPv6 address. If you specify the domain, the server makes a DNS request when it starts, and the result is stored as long as the server is running. If the DNS request fails, the server doesn't start. If you change the DNS record, restart the server. -- `port` – The TCP port for messenger activity (‘tcp\_port’ yapılandırmada, genellikle 9000 olarak ayarlanır). Http\_port ile karıştırmayın. -- `user` – Name of the user for connecting to a remote server. Default value: default. This user must have access to connect to the specified server. Access is configured in the users.xml file. For more information, see the section [Erişim hakları](../../../operations/access_rights.md). -- `password` – The password for connecting to a remote server (not masked). Default value: empty string. -- `secure` - Bağlantı için ssl kullanın, genellikle de tanımlamanız gerekir `port` = 9440. Sunucu dinlem shouldeli 9440 ve doğru sertifikalara sahip. -- `compression` - Kullanım veri sıkıştırma. Varsayılan değer: true. - -When specifying replicas, one of the available replicas will be selected for each of the shards when reading. You can configure the algorithm for load balancing (the preference for which replica to access) – see the [dengeleme](../../../operations/settings/settings.md#settings-load_balancing) ayar. -Sunucu ile bağlantı kurulmamışsa, kısa bir zaman aşımı ile bağlanma girişimi olacaktır. Bağlantı başarısız olursa, sonraki yineleme seçilir ve benzeri tüm yinelemeler için. Bağlantı girişimi tüm yinelemeler için başarısız olursa, girişimi aynı şekilde, birkaç kez tekrarlanır. -Bu esneklik lehine çalışır, ancak tam hataya dayanıklılık sağlamaz: uzak bir sunucu bağlantıyı kabul edebilir, ancak çalışmayabilir veya kötü çalışabilir. - -Parçalardan yalnızca birini belirtebilirsiniz (bu durumda, sorgu işleme dağıtılmış yerine uzak olarak adlandırılmalıdır) veya herhangi bir sayıda parçaya kadar. Her parçada, bir ila herhangi bir sayıda yinelemeyi belirtebilirsiniz. Her parça için farklı sayıda çoğaltma belirtebilirsiniz. - -Yapılandırmada istediğiniz kadar küme belirtebilirsiniz. - -Kümelerinizi görüntülemek için ‘system.clusters’ Tablo. - -Dağıtılmış motor, yerel bir sunucu gibi bir küme ile çalışmaya izin verir. Ancak, küme uzatılamaz: yapılandırmasını sunucu yapılandırma dosyasına yazmanız gerekir (tüm kümenin sunucuları için daha da iyisi). - -The Distributed engine requires writing clusters to the config file. Clusters from the config file are updated on the fly, without restarting the server. If you need to send a query to an unknown set of shards and replicas each time, you don't need to create a Distributed table – use the ‘remote’ bunun yerine tablo işlevi. Bölümüne bakınız [Tablo fonksiyonları](../../../sql_reference/table_functions/index.md). - -Bir kümeye veri yazmak için iki yöntem vardır: - -İlk olarak, hangi sunucuların hangi verileri yazacağını ve her bir parçaya doğrudan yazmayı gerçekleştireceğini tanımlayabilirsiniz. Başka bir deyişle, dağıtılmış tablo içinde INSERT gerçekleştirmek “looks at”. Bu, konu alanının gereklilikleri nedeniyle önemsiz olmayan herhangi bir sharding şemasını kullanabileceğiniz için en esnek çözümdür. Bu aynı zamanda en uygun çözümdür, çünkü veriler farklı parçalara tamamen bağımsız olarak yazılabilir. - -İkinci olarak, dağıtılmış bir tabloda ekleme gerçekleştirebilirsiniz. Bu durumda, tablo eklenen verileri sunucuların kendisine dağıtacaktır. Dağıtılmış bir tabloya yazmak için, bir sharding anahtar kümesi (son parametre) olmalıdır. Ek olarak, yalnızca bir parça varsa, yazma işlemi sharding anahtarını belirtmeden çalışır, çünkü bu durumda hiçbir şey ifade etmez. - -Her parça yapılandırma dosyasında tanımlanan bir ağırlığa sahip olabilir. Varsayılan olarak, ağırlık bir eşittir. Veriler, parça ağırlığı ile orantılı miktarda parçalara dağıtılır. Örneğin, iki parça varsa ve birincisi 9'luk bir ağırlığa sahipse, ikincisi 10'luk bir ağırlığa sahipse, ilk satırların 9 / 19 parçası gönderilir ve ikincisi 10 / 19 gönderilir. - -Her shard olabilir ‘internal\_replication’ yapılandırma dosyasında tanımlanan parametre. - -Bu parametre şu şekilde ayarlanırsa ‘true’, yazma işlemi ilk sağlıklı yinelemeyi seçer ve ona veri yazar. Dağıtılmış tablo ise bu alternatifi kullanın “looks at” çoğaltılan tablolar. Başka bir deyişle, verilerin yazılacağı tablo kendilerini çoğaltacaktır. - -Olarak ayarlan ifmışsa ‘false’ (varsayılan), veriler tüm kopyalara yazılır. Özünde, bu, dağıtılmış tablonun verilerin kendisini çoğalttığı anlamına gelir. Bu, çoğaltılmış tabloları kullanmaktan daha kötüdür, çünkü kopyaların tutarlılığı denetlenmez ve zamanla biraz farklı veriler içerirler. - -Bir veri satırının gönderildiği parçayı seçmek için, parçalama ifadesi analiz edilir ve kalan kısmı, parçaların toplam ağırlığına bölünmesinden alınır. Satır, kalanların yarı aralığına karşılık gelen parçaya gönderilir. ‘prev\_weight’ -e doğru ‘prev\_weights + weight’, nere ‘prev\_weights’ en küçük sayıya sahip parçaların toplam ağırlığı ve ‘weight’ bu parçanın ağırlığı. Örneğin, iki parça varsa ve birincisi 9'luk bir ağırlığa sahipse, ikincisi 10'luk bir ağırlığa sahipse, satır \[0, 9) aralığından kalanlar için ilk parçaya ve ikincisine \[9, 19) aralığından kalanlar için gönderilecektir. - -Sharding ifadesi, bir tamsayı döndüren sabitler ve tablo sütunlarından herhangi bir ifade olabilir. Örneğin, ifadeyi kullanabilirsiniz ‘rand()’ verilerin rastgele dağılımı için veya ‘UserID’ kullanıcının kimliğinin bölünmesinden kalanın dağıtımı için (daha sonra tek bir kullanıcının verileri, kullanıcılar tarafından çalışmayı ve katılmayı basitleştiren tek bir parçada bulunur). Sütunlardan biri yeterince eşit olarak dağıtılmazsa, onu bir karma işleve sarabilirsiniz: ınthash64(Userıd). - -Bölüm'den basit bir hatırlatma, sharding için sınırlı bir çözümdür ve her zaman uygun değildir. Orta ve büyük hacimlerde veri (düzinelerce sunucu) için çalışır, ancak çok büyük hacimlerde veri (yüzlerce sunucu veya daha fazla) için değildir. İkinci durumda, dağıtılmış tablolarda girdileri kullanmak yerine konu alanı tarafından gerekli olan sharding şemasını kullanın. - -SELECT queries are sent to all the shards and work regardless of how data is distributed across the shards (they can be distributed completely randomly). When you add a new shard, you don't have to transfer the old data to it. You can write new data with a heavier weight – the data will be distributed slightly unevenly, but queries will work correctly and efficiently. - -Aşağıdaki durumlarda sharding şeması hakkında endişelenmelisiniz: - -- Belirli bir anahtar tarafından veri (veya birleştirme) birleştirme gerektiren sorgular kullanılır. Veriler bu anahtar tarafından parçalanırsa, GLOBAL IN veya GLOBAL JOİN yerine local IN veya JOİN kullanabilirsiniz, bu da çok daha etkilidir. -- Çok sayıda küçük Sorgu ile çok sayıda sunucu (yüzlerce veya daha fazla) kullanılır (bireysel müşterilerin sorguları - web siteleri, reklamverenler veya ortaklar). Küçük sorguların tüm kümeyi etkilememesi için, tek bir istemci için tek bir parça üzerinde veri bulmak mantıklıdır. Alternatif olarak, Yandex'te yaptığımız gibi.Metrica, iki seviyeli sharding kurabilirsiniz: tüm kümeyi bölün “layers”, bir katmanın birden fazla parçadan oluşabileceği yer. Tek bir istemci için veriler tek bir katmanda bulunur, ancak kırıklar gerektiğinde bir katmana eklenebilir ve veriler rastgele dağıtılır. Her katman için dağıtılmış tablolar oluşturulur ve genel sorgular için tek bir paylaşılan dağıtılmış tablo oluşturulur. - -Veriler zaman uyumsuz olarak yazılır. Tabloya eklendiğinde, veri bloğu sadece yerel dosya sistemine yazılır. Veriler en kısa sürede arka planda uzak sunuculara gönderilir. Veri gönderme süresi tarafından yönetilir [distributed\_directory\_monitor\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_sleep_time_ms) ve [distributed\_directory\_monitor\_max\_sleep\_time\_ms](../../../operations/settings/settings.md#distributed_directory_monitor_max_sleep_time_ms) ayarlar. Bu `Distributed` motor ayrı ayrı eklenen verilerle her dosyayı gönderir, ancak toplu dosya gönderme etkinleştirebilirsiniz [distributed\_directory\_monitor\_batch\_ınserts](../../../operations/settings/settings.md#distributed_directory_monitor_batch_inserts) ayar. Bu ayar, yerel sunucu ve ağ kaynaklarını daha iyi kullanarak küme performansını artırır. Tablo dizinindeki dosyaların listesini (gönderilmeyi bekleyen veriler) kontrol ederek verilerin başarıyla gönderilip gönderilmediğini kontrol etmelisiniz: `/var/lib/clickhouse/data/database/table/`. - -Sunucu varlığını durdurdu veya (örneğin, bir aygıt arızasından sonra) dağıtılmış bir tabloya bir ekleme sonra kaba bir yeniden başlatma vardı, eklenen veriler kaybolabilir. Tablo dizininde bozuk bir veri parçası tespit edilirse, ‘broken’ alt dizin ve artık kullanılmıyor. - -Max\_parallel\_replicas seçeneği etkinleştirildiğinde, sorgu işleme tek bir parça içindeki tüm yinelemeler arasında paralelleştirilir. Daha fazla bilgi için bölüme bakın [max\_parallel\_replicas](../../../operations/settings/settings.md#settings-max_parallel_replicas). - -## Sanal Sütunlar {#virtual-columns} - -- `_shard_num` — Contains the `shard_num` (itibaren `system.clusters`). Tür: [Uİnt32](../../../sql_reference/data_types/int_uint.md). - -!!! note "Not" - Beri [`remote`](../../../sql_reference/table_functions/remote.md)/`cluster` tablo işlevleri DAHİLİ olarak aynı dağıtılmış altyapının geçici örneğini oluşturur, `_shard_num` de kullanılabilir. - -**Ayrıca Bakınız** - -- [Sanal sütunlar](index.md#table_engines-virtual_columns) - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/distributed/) diff --git a/docs/tr/engines/table_engines/special/external_data.md b/docs/tr/engines/table_engines/special/external_data.md deleted file mode 100644 index 123b2dbdf0e..00000000000 --- a/docs/tr/engines/table_engines/special/external_data.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 34 -toc_title: "D\u0131\u015F veri" ---- - -# Sorgu işleme için harici veriler {#external-data-for-query-processing} - -ClickHouse bir sunucu bir SELECT sorgusu ile birlikte bir sorgu işlemek için gerekli olan verileri gönderme sağlar. Bu veriler geçici bir tabloya konur (bölüme bakın “Temporary tables”) ve sorguda kullanılabilir (örneğin, işleçlerde). - -Örneğin, önemli kullanıcı tanımlayıcılarına sahip bir metin dosyanız varsa, bu listeyi süzme kullanan bir sorgu ile birlikte sunucuya yükleyebilirsiniz. - -Büyük hacimli dış verilerle birden fazla sorgu çalıştırmanız gerekiyorsa, bu özelliği kullanmayın. Verileri vaktinden önce DB'YE yüklemek daha iyidir. - -Harici veriler komut satırı istemcisi (etkileşimli olmayan modda) veya HTTP arabirimi kullanılarak yüklenebilir. - -Komut satırı istemcisinde, formatta bir parametreler bölümü belirtebilirsiniz - -``` bash ---external --file=... [--name=...] [--format=...] [--types=...|--structure=...] -``` - -İletilen tablo sayısı için bunun gibi birden çok bölümünüz olabilir. - -**–external** – Marks the beginning of a clause. -**–file** – Path to the file with the table dump, or -, which refers to stdin. -Stdın'den yalnızca tek bir tablo alınabilir. - -Aşağıdaki parametreler isteğe bağlıdır: **–name**– Name of the table. If omitted, \_data is used. -**–format** – Data format in the file. If omitted, TabSeparated is used. - -Aşağıdaki parametrelerden biri gereklidir:**–types** – A list of comma-separated column types. For example: `UInt64,String`. The columns will be named \_1, \_2, … -**–structure**– The table structure in the format`UserID UInt64`, `URL String`. Sütun adlarını ve türlerini tanımlar. - -Belirtilen dosyalar ‘file’ belirtilen biçimde ayrıştırılır ‘format’, belirtilen veri türlerini kullanarak ‘types’ veya ‘structure’. Tablo sunucuya yüklenecek ve orada adı ile geçici bir tablo olarak erişilebilir ‘name’. - -Örnekler: - -``` bash -$ echo -ne "1\n2\n3\n" | clickhouse-client --query="SELECT count() FROM test.visits WHERE TraficSourceID IN _data" --external --file=- --types=Int8 -849897 -$ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -HTTP arabirimini kullanırken, dış veriler çok parçalı/form veri biçiminde geçirilir. Her tablo ayrı bir dosya olarak iletilir. Tablo adı dosya adından alınır. Bu ‘query\_string’ parametreleri geçirilir ‘name\_format’, ‘name\_types’, ve ‘name\_structure’, nere ‘name’ bu parametreler karşılık gelen tablonun adıdır. Parametrelerin anlamı, komut satırı istemcisini kullanırken olduğu gibi aynıdır. - -Örnek: - -``` bash -$ cat /etc/passwd | sed 's/:/\t/g' > passwd.tsv - -$ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+count()+AS+c+FROM+passwd+GROUP+BY+shell+ORDER+BY+c+DESC&passwd_structure=login+String,+unused+String,+uid+UInt16,+gid+UInt16,+comment+String,+home+String,+shell+String' -/bin/sh 20 -/bin/false 5 -/bin/bash 4 -/usr/sbin/nologin 1 -/bin/sync 1 -``` - -Dağıtılmış sorgu işleme için geçici tablolar tüm uzak sunuculara gönderilir. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/external_data/) diff --git a/docs/tr/engines/table_engines/special/file.md b/docs/tr/engines/table_engines/special/file.md deleted file mode 100644 index c132d1dd5a4..00000000000 --- a/docs/tr/engines/table_engines/special/file.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 37 -toc_title: Dosya ---- - -# Dosya {#table_engines-file} - -Dosya tablosu altyapısı, verileri desteklenen dosyalardan birinde tutar [Dosya -biçimliler](../../../interfaces/formats.md#formats) (TabSeparated, yerli, vb.). - -Kullanım örnekleri: - -- Clickhouse'dan dosyaya veri aktarımı. -- Verileri bir biçimden diğerine dönüştürün. -- Bir diskte bir dosya düzenleme yoluyla ClickHouse veri güncelleme. - -## ClickHouse Sunucusunda Kullanım {#usage-in-clickhouse-server} - -``` sql -File(Format) -``` - -Bu `Format` parametre kullanılabilir dosya biçimlerinden birini belirtir. Gerçekleştirmek -`SELECT` sorgular, biçim giriş için desteklenmeli ve gerçekleştirmek için -`INSERT` queries – for output. The available formats are listed in the -[Biçimliler](../../../interfaces/formats.md#formats) bölme. - -ClickHouse dosya sistemi yolunu belirtmek için izin vermiyor`File`. Tarafından tanımlanan klasörü kullan willacaktır [yol](../../../operations/server_configuration_parameters/settings.md) sunucu yapılandırmasında ayarlama. - -Kullanarak tablo oluştururken `File(Format)` bu klasörde boş bir alt dizin oluşturur. Veri o tabloya yazıldığında, içine konur `data.Format` bu alt dizinde dosya. - -Bu alt klasörü ve dosyayı sunucu dosya sisteminde el ile oluşturabilir ve sonra [ATTACH](../../../sql_reference/statements/misc.md) eşleşen ada sahip tablo bilgilerine, böylece bu dosyadan veri sorgulayabilirsiniz. - -!!! warning "Uyarıcı" - Bu işlevselliğe dikkat edin, çünkü ClickHouse bu tür dosyalarda harici değişiklikleri izlemez. ClickHouse ve ClickHouse dışında eşzamanlı yazma sonucu tanımsızdır. - -**Örnek:** - -**1.** Set up the `file_engine_table` Tablo: - -``` sql -CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) -``` - -Varsayılan olarak ClickHouse klasör oluşturur `/var/lib/clickhouse/data/default/file_engine_table`. - -**2.** El ile oluştur `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` içerme: - -``` bash -$ cat data.TabSeparated -one 1 -two 2 -``` - -**3.** Verileri sorgula: - -``` sql -SELECT * FROM file_engine_table -``` - -``` text -┌─name─┬─value─┐ -│ one │ 1 │ -│ two │ 2 │ -└──────┴───────┘ -``` - -## Clickhouse'da kullanım-yerel {#usage-in-clickhouse-local} - -İçinde [clickhouse-yerel](../../../operations/utilities/clickhouse-local.md) Dosya motoru ek olarak dosya yolunu kabul eder `Format`. Varsayılan giriş / çıkış akışları gibi sayısal veya insan tarafından okunabilir isimler kullanılarak belirtilebilir `0` veya `stdin`, `1` veya `stdout`. -**Örnek:** - -``` bash -$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table" -``` - -## Uygulama Detayları {#details-of-implementation} - -- Çoklu `SELECT` sorgular aynı anda yapılabilir, ancak `INSERT` sorgular birbirini bekler. -- Tarafından yeni dosya oluşturma desteklenen `INSERT` sorgu. -- Dosya varsa, `INSERT` içinde yeni değerler ekler. -- Desteklenmiyor: - - `ALTER` - - `SELECT ... SAMPLE` - - Dizinler - - Çoğalma - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/file/) diff --git a/docs/tr/engines/table_engines/special/generate.md b/docs/tr/engines/table_engines/special/generate.md deleted file mode 100644 index 01d2534441e..00000000000 --- a/docs/tr/engines/table_engines/special/generate.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 46 -toc_title: GenerateRandom ---- - -# Generaterandom {#table_engines-generate} - -GenerateRandom tablo motoru, verilen tablo şeması için rasgele veri üretir. - -Kullanım örnekleri: - -- Tekrarlanabilir büyük tabloyu doldurmak için testte kullanın. -- Fuzzing testleri için rastgele girdi oluşturun. - -## ClickHouse Sunucusunda Kullanım {#usage-in-clickhouse-server} - -``` sql -ENGINE = GenerateRandom(random_seed, max_string_length, max_array_length) -``` - -Bu `max_array_length` ve `max_string_length` parametreler tüm maksimum uzunluğu belirtin -oluşturulan verilerde dizi sütunları ve dizeleri. - -Tablo motoru oluşturmak yalnızca destekler `SELECT` sorgular. - -Tüm destekler [Veri türleri](../../../sql_reference/data_types/index.md) dışında bir tabloda saklanabilir `LowCardinality` ve `AggregateFunction`. - -**Örnek:** - -**1.** Set up the `generate_engine_table` Tablo: - -``` sql -CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3) -``` - -**2.** Verileri sorgula: - -``` sql -SELECT * FROM generate_engine_table LIMIT 3 -``` - -``` text -┌─name─┬──────value─┐ -│ c4xJ │ 1412771199 │ -│ r │ 1791099446 │ -│ 7#$ │ 124312908 │ -└──────┴────────────┘ -``` - -## Uygulama Detayları {#details-of-implementation} - -- Desteklenmiyor: - - `ALTER` - - `SELECT ... SAMPLE` - - `INSERT` - - Dizinler - - Çoğalma - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/generate/) diff --git a/docs/tr/engines/table_engines/special/index.md b/docs/tr/engines/table_engines/special/index.md deleted file mode 100644 index 2e754a86bc8..00000000000 --- a/docs/tr/engines/table_engines/special/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "\xD6zellikli" -toc_priority: 31 ---- - - diff --git a/docs/tr/engines/table_engines/special/join.md b/docs/tr/engines/table_engines/special/join.md deleted file mode 100644 index 2fa786148e0..00000000000 --- a/docs/tr/engines/table_engines/special/join.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 40 -toc_title: Katmak ---- - -# Katmak {#join} - -Kullanılmak üzere hazırlanmış veri yapısı [JOIN](../../../sql_reference/statements/select.md#select-join) harekat. - -## Tablo oluşturma {#creating-a-table} - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], -) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) -``` - -Ayrıntılı açıklamasına bakın [CREATE TABLE](../../../sql_reference/statements/create.md#create-table-query) sorgu. - -**Motor Parametreleri** - -- `join_strictness` – [Katılık katılın](../../../sql_reference/statements/select.md#select-join-strictness). -- `join_type` – [Birleştirme türü](../../../sql_reference/statements/select.md#select-join-types). -- `k1[, k2, ...]` – Key columns from the `USING` fık thera: `JOIN` işlemi yapılmamaktadır. - -Girmek `join_strictness` ve `join_type` tırnak işaretleri olmadan parametreler, örneğin, `Join(ANY, LEFT, col1)`. Onlar eşleşmelidir `JOIN` tablo için kullanılacak işlem. Parametreler eşleşmezse, ClickHouse bir istisna atmaz ve yanlış veri döndürebilir. - -## Tablo Kullanımı {#table-usage} - -### Örnek {#example} - -Sol taraftaki tablo oluşturma: - -``` sql -CREATE TABLE id_val(`id` UInt32, `val` UInt32) ENGINE = TinyLog -``` - -``` sql -INSERT INTO id_val VALUES (1,11)(2,12)(3,13) -``` - -Sağ tarafı oluşturma `Join` Tablo: - -``` sql -CREATE TABLE id_val_join(`id` UInt32, `val` UInt8) ENGINE = Join(ANY, LEFT, id) -``` - -``` sql -INSERT INTO id_val_join VALUES (1,21)(1,22)(3,23) -``` - -Tabloları birleştirme: - -``` sql -SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id) SETTINGS join_use_nulls = 1 -``` - -``` text -┌─id─┬─val─┬─id_val_join.val─┐ -│ 1 │ 11 │ 21 │ -│ 2 │ 12 │ ᴺᵁᴸᴸ │ -│ 3 │ 13 │ 23 │ -└────┴─────┴─────────────────┘ -``` - -Alternatif olarak, veri alabilirsiniz `Join` tablo, birleştirme anahtarı değerini belirterek: - -``` sql -SELECT joinGet('id_val_join', 'val', toUInt32(1)) -``` - -``` text -┌─joinGet('id_val_join', 'val', toUInt32(1))─┐ -│ 21 │ -└────────────────────────────────────────────┘ -``` - -### Veri seçme ve ekleme {#selecting-and-inserting-data} - -Kullanabilirsiniz `INSERT` veri eklemek için sorgular `Join`- motor masaları. Tablo ile oluşturulmuş ise `ANY` katılık, yinelenen anahtarlar için veriler göz ardı edilir. İle... `ALL` katılık, tüm satırlar eklenir. - -Gerçekleştir aemezsiniz `SELECT` doğrudan tablodan sorgulayın. Bunun yerine, aşağıdaki yöntemlerden birini kullanın: - -- Tabloyu sağ tarafa yerleştirin. `JOIN` yan. -- Call the [joinGet](../../../sql_reference/functions/other_functions.md#joinget) tablodan bir sözlükten aynı şekilde veri ayıklamanızı sağlayan işlev. - -### Sınırlamalar ve Ayarlar {#join-limitations-and-settings} - -Bir tablo oluştururken aşağıdaki ayarlar uygulanır: - -- [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) -- [max\_rows\_in\_join](../../../operations/settings/query_complexity.md#settings-max_rows_in_join) -- [max\_bytes\_in\_join](../../../operations/settings/query_complexity.md#settings-max_bytes_in_join) -- [join\_overflow\_mode](../../../operations/settings/query_complexity.md#settings-join_overflow_mode) -- [join\_any\_take\_last\_row](../../../operations/settings/settings.md#settings-join_any_take_last_row) - -Bu `Join`- motor tabloları kullanılamaz `GLOBAL JOIN` harekat. - -Bu `Join`- motor kullanımına izin verir [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) ayarı `CREATE TABLE` deyim. Ve [SELECT](../../../sql_reference/statements/select.md) sorgu kullanımına izin verir `join_use_nulls` çok. Eğer farklı varsa `join_use_nulls` ayarlar, tablo birleştirme bir hata alabilirsiniz. Bu katılmak türüne bağlıdır. Kullandığınızda [joinGet](../../../sql_reference/functions/other_functions.md#joinget) fonksiyonu, aynı kullanmak zorunda `join_use_nulls` ayarı `CRATE TABLE` ve `SELECT` deyimler. - -## Veri Depolama {#data-storage} - -`Join` tablo verileri her zaman RAM'de bulunur. Bir tabloya satır eklerken, sunucu yeniden başlatıldığında geri yüklenebilir, böylece ClickHouse disk üzerindeki dizine veri bloklarını yazar. - -Sunucu yanlış yeniden başlatılırsa, diskteki veri bloğu kaybolabilir veya zarar görebilir. Bu durumda, dosyayı hasarlı verilerle el ile silmeniz gerekebilir. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/join/) diff --git a/docs/tr/engines/table_engines/special/materializedview.md b/docs/tr/engines/table_engines/special/materializedview.md deleted file mode 100644 index 23e7d3122eb..00000000000 --- a/docs/tr/engines/table_engines/special/materializedview.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 43 -toc_title: MaterializedView ---- - -# Materializedview {#materializedview} - -Somut görünümler uygulamak için kullanılır (Daha fazla bilgi için bkz . [CREATE TABLE](../../../sql_reference/statements/create.md)). Verileri depolamak için, görünümü oluştururken belirtilen farklı bir motor kullanır. Bir tablodan okurken, sadece bu motoru kullanır. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/materializedview/) diff --git a/docs/tr/engines/table_engines/special/memory.md b/docs/tr/engines/table_engines/special/memory.md deleted file mode 100644 index a5f985ff5e2..00000000000 --- a/docs/tr/engines/table_engines/special/memory.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 44 -toc_title: Bellek ---- - -# Bellek {#memory} - -Bellek altyapısı verileri RAM, sıkıştırılmamış biçimde depolar. Veri okunduğunda alınan tam olarak aynı biçimde saklanır. Başka bir deyişle, bu tablodan okuma tamamen ücretsizdir. -Eşzamanlı veri erişimi senkronize edilir. Kilitler kısa: okuma ve yazma işlemleri birbirini engellemez. -Dizinler desteklenmiyor. Okuma paralelleştirilmiştir. -Basit sorgularda maksimum üretkenliğe (10 GB/sn'den fazla) ulaşılır, çünkü diskten okuma, açma veya veri serisini kaldırma yoktur. (Birçok durumda MergeTree motorunun verimliliğinin neredeyse yüksek olduğunu unutmamalıyız.) -Bir sunucu yeniden başlatılırken, veri tablodan kaybolur ve tablo boş olur. -Normalde, bu tablo motorunu kullanmak haklı değildir. Bununla birlikte, testler ve nispeten az sayıda satırda (yaklaşık 100.000.000'a kadar) maksimum hızın gerekli olduğu görevler için kullanılabilir. - -Bellek motoru, harici sorgu verilerine sahip geçici tablolar için sistem tarafından kullanılır (bkz. “External data for processing a query”) ve GLOBAL In uygulanması için (bkz. “IN operators”). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/memory/) diff --git a/docs/tr/engines/table_engines/special/merge.md b/docs/tr/engines/table_engines/special/merge.md deleted file mode 100644 index bd4150e1afb..00000000000 --- a/docs/tr/engines/table_engines/special/merge.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 36 -toc_title: "Birle\u015Ftirmek" ---- - -# Birleştirmek {#merge} - -Bu `Merge` motor (ile karıştırılmamalıdır `MergeTree`) verileri kendisi saklamaz, ancak aynı anda herhangi bir sayıda başka tablodan okumaya izin verir. -Okuma otomatik olarak paralelleştirilir. Bir tabloya yazma desteklenmiyor. Okurken, gerçekten okunmakta olan tabloların dizinleri varsa kullanılır. -Bu `Merge` motor parametreleri kabul eder: veritabanı adı ve tablolar için düzenli ifade. - -Örnek: - -``` sql -Merge(hits, '^WatchLog') -``` - -Veri tablolardan okunacak `hits` düzenli ifadeyle eşleşen adlara sahip veritabanı ‘`^WatchLog`’. - -Veritabanı adı yerine, bir dize döndüren sabit bir ifade kullanabilirsiniz. Mesela, `currentDatabase()`. - -Regular expressions — [re2](https://github.com/google/re2) (pcre bir alt kümesini destekler), büyük / küçük harf duyarlı. -Düzenli ifadelerde kaçan sembollerle ilgili notlara bakın “match” bölme. - -Okumak için tabloları seçerken, `Merge` regex ile eşleşse bile tablonun kendisi seçilmeyecektir. Bu döngülerden kaçınmaktır. -İki tane oluşturmak mümkündür `Merge` sonsuza kadar birbirlerinin verilerini okumaya çalışacak tablolar, ancak bu iyi bir fikir değil. - -Kullanmak için tipik bir yol `Merge` motor çok sayıda çalışma içindir `TinyLog` tablolar tek bir tablo ile sanki. - -Örnek 2: - -Diyelim ki eski bir tablonuz (WatchLog\_old) var ve verileri yeni bir tabloya (WatchLog\_new) taşımadan bölümlemeyi değiştirmeye karar verdiniz ve her iki tablodaki verileri görmeniz gerekiyor. - -``` sql -CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree(date, (UserId, EventType), 8192); -INSERT INTO WatchLog_old VALUES ('2018-01-01', 1, 'hit', 3); - -CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) -ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; -INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); - -CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); - -SELECT * -FROM WatchLog -``` - -``` text -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-01 │ 1 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-02 │ 2 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -``` - -## Sanal Sütunlar {#virtual-columns} - -- `_table` — Contains the name of the table from which data was read. Type: [Dize](../../../sql_reference/data_types/string.md). - - Sabit koşulları ayarlayabilirsiniz `_table` in the `WHERE/PREWHERE` fıkra (sı (örneğin, `WHERE _table='xyz'`). Bu durumda, okuma işlemi yalnızca koşulun açık olduğu tablolar için gerçekleştirilir `_table` memnun olduğunu, bu yüzden `_table` sütun bir dizin görevi görür. - -**Ayrıca Bakınız** - -- [Sanal sütunlar](index.md#table_engines-virtual_columns) - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/merge/) diff --git a/docs/tr/engines/table_engines/special/null.md b/docs/tr/engines/table_engines/special/null.md deleted file mode 100644 index 19d518f415f..00000000000 --- a/docs/tr/engines/table_engines/special/null.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 38 -toc_title: "Bo\u015F" ---- - -# Boş {#null} - -Boş bir tabloya yazarken, veri yoksayılır. Boş bir tablodan okurken, yanıt boştur. - -Ancak, boş bir tablo üzerinde materialized bir görünüm oluşturabilirsiniz. Böylece tabloya yazılan veriler görünümde sona erecek. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/null/) diff --git a/docs/tr/engines/table_engines/special/set.md b/docs/tr/engines/table_engines/special/set.md deleted file mode 100644 index af94ada6e12..00000000000 --- a/docs/tr/engines/table_engines/special/set.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 39 -toc_title: Koymak ---- - -# Koymak {#set} - -Her zaman RAM olan bir veri kümesi. In operatörünün sağ tarafında kullanılmak üzere tasarlanmıştır (bölüme bakın “IN operators”). - -Tabloya veri eklemek için INSERT kullanabilirsiniz. Veri kümesine yeni öğeler eklenirken, yinelenenler göz ardı edilir. -Ancak tablodan seçim yapamazsınız. Verileri almak için tek yol, IN operatörünün sağ yarısında kullanmaktır. - -Veri her zaman RAM yer almaktadır. INSERT için, eklenen veri blokları da diskteki tabloların dizinine yazılır. Sunucuyu başlatırken, bu veriler RAM'e yüklenir. Başka bir deyişle, yeniden başlattıktan sonra veriler yerinde kalır. - -Kaba bir sunucu yeniden başlatma için diskteki veri bloğu kaybolabilir veya zarar görebilir. İkinci durumda, dosyayı hasarlı verilerle el ile silmeniz gerekebilir. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/set/) diff --git a/docs/tr/engines/table_engines/special/url.md b/docs/tr/engines/table_engines/special/url.md deleted file mode 100644 index 51657248e75..00000000000 --- a/docs/tr/engines/table_engines/special/url.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 41 -toc_title: URL ---- - -# URL (URL, Biçim) {#table_engines-url} - -Uzak bir HTTP/HTTPS sunucusundaki verileri yönetir. Bu motor benzer -to the [Dosya](file.md) motor. - -## ClickHouse sunucusunda motoru kullanma {#using-the-engine-in-the-clickhouse-server} - -Bu `format` Clickhouse'un kullanabileceği bir tane olmalı -`SELECT` sorgular ve gerekirse `INSERTs`. Desteklenen formatların tam listesi için bkz. -[Biçimliler](../../../interfaces/formats.md#formats). - -Bu `URL` tekdüzen bir kaynak Bulucu yapısına uygun olmalıdır. Belirtilen URL bir sunucuya işaret etmelidir -bu HTTP veya HTTPS kullanır. Bu herhangi bir gerektirmez -sunucudan yanıt almak için ek başlıklar. - -`INSERT` ve `SELECT` sorgular dönüştürülür `POST` ve `GET` istemler, -sırasıyla. İşleme için `POST` istekleri, uzak sunucu desteklemesi gerekir -[Yığınlı aktarım kodlaması](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). - -Kullanarak HTTP get yönlendirme şerbetçiotu sayısını sınırlayabilirsiniz [max\_http\_get\_redirects](../../../operations/settings/settings.md#setting-max_http_get_redirects) ayar. - -**Örnek:** - -**1.** Create a `url_engine_table` sunucuda tablo : - -``` sql -CREATE TABLE url_engine_table (word String, value UInt64) -ENGINE=URL('http://127.0.0.1:12345/', CSV) -``` - -**2.** Standart Python 3 araçlarını kullanarak temel bir HTTP Sunucusu oluşturun ve -Başlat: - -``` python3 -from http.server import BaseHTTPRequestHandler, HTTPServer - -class CSVHTTPServer(BaseHTTPRequestHandler): - def do_GET(self): - self.send_response(200) - self.send_header('Content-type', 'text/csv') - self.end_headers() - - self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8")) - -if __name__ == "__main__": - server_address = ('127.0.0.1', 12345) - HTTPServer(server_address, CSVHTTPServer).serve_forever() -``` - -``` bash -$ python3 server.py -``` - -**3.** Veri iste: - -``` sql -SELECT * FROM url_engine_table -``` - -``` text -┌─word──┬─value─┐ -│ Hello │ 1 │ -│ World │ 2 │ -└───────┴───────┘ -``` - -## Uygulama Detayları {#details-of-implementation} - -- Okuma ve yazma paralel olabilir -- Desteklenmiyor: - - `ALTER` ve `SELECT...SAMPLE` harekat. - - Dizinler. - - Çoğalma. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/url/) diff --git a/docs/tr/engines/table_engines/special/view.md b/docs/tr/engines/table_engines/special/view.md deleted file mode 100644 index e3b46a7b926..00000000000 --- a/docs/tr/engines/table_engines/special/view.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 42 -toc_title: "G\xF6r\xFCn\xFCm" ---- - -# Görünüm {#table_engines-view} - -Görünümler uygulamak için kullanılır (Daha fazla bilgi için bkz. `CREATE VIEW query`). Verileri saklamaz, ancak yalnızca belirtilen `SELECT` sorgu. Bir tablodan okurken, bu sorguyu çalıştırır (ve gereksiz tüm sütunları sorgudan siler). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/view/) diff --git a/docs/tr/faq/general.md b/docs/tr/faq/general.md index 05779e132a9..f17baee24e9 100644 --- a/docs/tr/faq/general.md +++ b/docs/tr/faq/general.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 78 toc_title: Genel Sorular --- @@ -29,7 +29,7 @@ NLS_LANG=RUSSIAN_RUSSIA.UTF8 ### INTO OUTFİLE yan tümcesini kullanma {#using-into-outfile-clause} -Add an [INTO OUTFILE](../sql_reference/statements/select.md#into-outfile-clause) sorgunuza yan tümce. +Add an [INTO OUTFILE](../sql-reference/statements/select/into-outfile.md#into-outfile-clause) sorgunuza yan tümce. Mesela: @@ -37,7 +37,7 @@ Mesela: SELECT * FROM table INTO OUTFILE 'file' ``` -Varsayılan olarak, ClickHouse kullanır [TabSeparated](../interfaces/formats.md#tabseparated) çıktı verileri için Biçim. Seçmek için [Veri formatı](../interfaces/formats.md), use the [FORMAT CLA clauseuse](../sql_reference/statements/select.md#format-clause). +Varsayılan olarak, ClickHouse kullanır [TabSeparated](../interfaces/formats.md#tabseparated) çıktı verileri için Biçim. Seçmek için [Veri formatı](../interfaces/formats.md), use the [FORMAT CLA clauseuse](../sql-reference/statements/select/format.md#format-clause). Mesela: @@ -47,7 +47,7 @@ SELECT * FROM table INTO OUTFILE 'file' FORMAT CSV ### Dosya altyapısı tablosu kullanma {#using-a-file-engine-table} -Görmek [Dosya](../engines/table_engines/special/file.md). +Görmek [Dosya](../engines/table-engines/special/file.md). ### Komut Satırı Yeniden Yönlendirmesini Kullanma {#using-command-line-redirection} diff --git a/docs/tr/faq/index.md b/docs/tr/faq/index.md index 591011fb66d..a44dbb31e89 100644 --- a/docs/tr/faq/index.md +++ b/docs/tr/faq/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: F.A.Q. toc_priority: 76 --- diff --git a/docs/tr/getting-started/example-datasets/amplab-benchmark.md b/docs/tr/getting-started/example-datasets/amplab-benchmark.md new file mode 100644 index 00000000000..affeb465c84 --- /dev/null +++ b/docs/tr/getting-started/example-datasets/amplab-benchmark.md @@ -0,0 +1,129 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 17 +toc_title: "AMPLab B\xFCy\xFCk Veri Benchmark" +--- + +# AMPLab Büyük Veri Benchmark {#amplab-big-data-benchmark} + +Bkz. https://amplab.cs.berkeley.edu/benchmark/ + +Ücretsiz bir hesap için kaydolun https://aws.amazon.com. bir kredi kartı, e-posta ve telefon numarası gerektirir. Yeni bir erişim anahtarı alın https://console.aws.amazon.com/iam/home?nc2=h\_m\_sc\#security\_credential + +Konsolda aşağıdakileri çalıştırın: + +``` bash +$ sudo apt-get install s3cmd +$ mkdir tiny; cd tiny; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/tiny/ . +$ cd .. +$ mkdir 1node; cd 1node; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/1node/ . +$ cd .. +$ mkdir 5nodes; cd 5nodes; +$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . +$ cd .. +``` + +Aşağıdaki ClickHouse sorguları çalıştırın: + +``` sql +CREATE TABLE rankings_tiny +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_tiny +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); + +CREATE TABLE rankings_1node +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_1node +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); + +CREATE TABLE rankings_5nodes_on_single +( + pageURL String, + pageRank UInt32, + avgDuration UInt32 +) ENGINE = Log; + +CREATE TABLE uservisits_5nodes_on_single +( + sourceIP String, + destinationURL String, + visitDate Date, + adRevenue Float32, + UserAgent String, + cCode FixedString(3), + lCode FixedString(6), + searchWord String, + duration UInt32 +) ENGINE = MergeTree(visitDate, visitDate, 8192); +``` + +Konsola geri dön: + +``` bash +$ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done +$ for i in tiny/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_tiny FORMAT CSV"; done +$ for i in 1node/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_1node FORMAT CSV"; done +$ for i in 1node/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_1node FORMAT CSV"; done +$ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_5nodes_on_single FORMAT CSV"; done +$ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done +``` + +Veri örnekleri almak için sorgular: + +``` sql +SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 + +SELECT substring(sourceIP, 1, 8), sum(adRevenue) FROM uservisits_1node GROUP BY substring(sourceIP, 1, 8) + +SELECT + sourceIP, + sum(adRevenue) AS totalRevenue, + avg(pageRank) AS pageRank +FROM rankings_1node ALL INNER JOIN +( + SELECT + sourceIP, + destinationURL AS pageURL, + adRevenue + FROM uservisits_1node + WHERE (visitDate > '1980-01-01') AND (visitDate < '1980-04-01') +) USING pageURL +GROUP BY sourceIP +ORDER BY totalRevenue DESC +LIMIT 1 +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/amplab_benchmark/) diff --git a/docs/tr/getting-started/example-datasets/criteo.md b/docs/tr/getting-started/example-datasets/criteo.md new file mode 100644 index 00000000000..3351cf3e7fa --- /dev/null +++ b/docs/tr/getting-started/example-datasets/criteo.md @@ -0,0 +1,81 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 19 +toc_title: "Criteo'dan Terabyte t\u0131klama g\xFCnl\xFCkleri" +--- + +# Criteo'dan tıklama günlüklerinin terabayt {#terabyte-of-click-logs-from-criteo} + +Verileri indirin http://labs.criteo.com/downloads/download-terabyte-click-logs/ + +Günlük almak için bir tablo oluşturun: + +``` sql +CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log +``` + +Verileri indirin: + +``` bash +$ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done +``` + +Dönüştürülen veriler için bir tablo oluşturma: + +``` sql +CREATE TABLE criteo +( + date Date, + clicked UInt8, + int1 Int32, + int2 Int32, + int3 Int32, + int4 Int32, + int5 Int32, + int6 Int32, + int7 Int32, + int8 Int32, + int9 Int32, + int10 Int32, + int11 Int32, + int12 Int32, + int13 Int32, + icat1 UInt32, + icat2 UInt32, + icat3 UInt32, + icat4 UInt32, + icat5 UInt32, + icat6 UInt32, + icat7 UInt32, + icat8 UInt32, + icat9 UInt32, + icat10 UInt32, + icat11 UInt32, + icat12 UInt32, + icat13 UInt32, + icat14 UInt32, + icat15 UInt32, + icat16 UInt32, + icat17 UInt32, + icat18 UInt32, + icat19 UInt32, + icat20 UInt32, + icat21 UInt32, + icat22 UInt32, + icat23 UInt32, + icat24 UInt32, + icat25 UInt32, + icat26 UInt32 +) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192) +``` + +Verileri ham günlüğünden dönüştürün ve ikinci tabloya koyun: + +``` sql +INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log; + +DROP TABLE criteo_log; +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/criteo/) diff --git a/docs/tr/getting-started/example-datasets/index.md b/docs/tr/getting-started/example-datasets/index.md new file mode 100644 index 00000000000..b31b0faa6fd --- /dev/null +++ b/docs/tr/getting-started/example-datasets/index.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\xD6rnek Veri K\xFCmeleri" +toc_priority: 12 +toc_title: "Giri\u015F" +--- + +# Örnek Veri Kümeleri {#example-datasets} + +Bu bölümde, örnek veri kümelerinin nasıl elde edileceği ve bunları Clickhouse'a nasıl içe aktarılacağı açıklanmaktadır. +Bazı veri kümeleri için örnek sorgular da mevcuttur. + +- [Anonim Yandex.Metrica Veri Kümesi](metrica.md) +- [Yıldız Şema Ben Benchmarkch Benchmarkmark](star-schema.md) +- [WikiStat](wikistat.md) +- [Criteo'dan tıklama günlüklerinin terabayt](criteo.md) +- [AMPLab Büyük Veri Benchmark](amplab-benchmark.md) +- [New York Taksi Verileri](nyc-taxi.md) +- [OnTime](ontime.md) + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/tr/getting-started/example-datasets/metrica.md b/docs/tr/getting-started/example-datasets/metrica.md new file mode 100644 index 00000000000..22f96f6761a --- /dev/null +++ b/docs/tr/getting-started/example-datasets/metrica.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 14 +toc_title: "\xDCye.Metrica Verileri" +--- + +# Anonim Yandex.Metrica Verileri {#anonymized-yandex-metrica-data} + +Veri kümesi, isabetlerle ilgili anonimleştirilmiş verileri içeren iki tablodan oluşur (`hits_v1`) ve ziyaret visitsler (`visits_v1`(kayıt olmak için).Metrica. Yandex hakkında daha fazla bilgi edinebilirsiniz.Metrica içinde [ClickHouse geçmişi](../../introduction/history.md) bölme. + +Veri kümesi iki tablodan oluşur, bunlardan biri sıkıştırılmış olarak indirilebilir `tsv.xz` dosya veya hazırlanmış bölümler olarak. Buna ek olarak, genişletilmiş bir sürümü `hits` 100 milyon satır içeren tablo TSV olarak mevcuttur https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits\_100m\_obfuscated\_v1.tsv.xz ve hazırlanan bölümler olarak https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits\_100m\_obfuscated\_v1.tar.xz. + +## Hazırlanan bölümlerden tablolar elde etme {#obtaining-tables-from-prepared-partitions} + +İndirme ve ithalat tablo hits: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar +tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +İndirme ve ithalat ziyaretleri: + +``` bash +curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar +tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory +# check permissions on unpacked data, fix if required +sudo service clickhouse-server restart +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Sıkıştırılmış TSV dosyasından Tablo alma {#obtaining-tables-from-compressed-tsv-file} + +Sıkıştırılmış TSV dosyasından indir ve İçe Aktar: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" +``` + +Sıkıştırılmış tsv dosyasından ziyaretleri indirin ve içe aktarın: + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +# now create table +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" +clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" +# import data +cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 +# optionally you can optimize table +clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" +clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" +``` + +## Örnek Sorgular {#example-queries} + +[ClickHouse eğitimi](../../getting-started/tutorial.md) Yandex dayanmaktadır.Metrica veri kümesi ve bu veri kümesine başlamak için önerilen yol sadece öğreticiden geçmektir. + +Bu tablolara ek sorgu örnekleri arasında bulunabilir [durum bilgisi testleri](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) ClickHouse of (onlar adlandırılır `test.hists` ve `test.visits` oralarda). diff --git a/docs/tr/getting-started/example-datasets/nyc-taxi.md b/docs/tr/getting-started/example-datasets/nyc-taxi.md new file mode 100644 index 00000000000..70569d47542 --- /dev/null +++ b/docs/tr/getting-started/example-datasets/nyc-taxi.md @@ -0,0 +1,390 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 16 +toc_title: New York Taksi Verileri +--- + +# New York Taksi Verileri {#new-york-taxi-data} + +Bu veri kümesi iki şekilde elde edilebilir: + +- ham verilerden içe aktarma +- hazırlanan bölüm downloadlerin indir downloadilmesi + +## Ham veri nasıl alınır {#how-to-import-the-raw-data} + +Bkz. https://github.com/toddwschneider/nyc-taxi-data ve http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html bir veri kümesinin açıklaması ve indirme talimatları için. + +İndirme, CSV dosyalarında yaklaşık 227 GB sıkıştırılmamış veri ile sonuçlanacaktır. İndirme, 1 Gbit bağlantısı üzerinden yaklaşık bir saat sürer (paralel indirme s3.amazonaws.com 1 Gbit kanalın en az yarısını kurtarır). +Bazı dosyalar tam olarak indirilmeyebilir. Dosya boyutlarını kontrol edin ve şüpheli görünen herhangi birini yeniden indirin. + +Bazı dosyalar geçersiz satırlar içerebilir. Bunları aşağıdaki gibi düzeltebilirsiniz: + +``` bash +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ +sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ +mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv +mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv +``` + +Daha sonra veriler Postgresql'de önceden işlenmelidir. Bu, çokgenlerdeki noktaların seçimlerini oluşturacaktır (Haritadaki noktaları New York şehrinin ilçeleriyle eşleştirmek için) ve tüm verileri bir birleştirme kullanarak tek bir denormalize düz tabloda birleştirecektir. Bunu yapmak için Postgresql'i Postgıs desteği ile yüklemeniz gerekir. + +Çalışırken dikkatli olun `initialize_database.sh` ve tüm tabloların doğru şekilde oluşturulduğunu manuel olarak yeniden kontrol edin. + +Postgresql'deki her ayın verilerini işlemek yaklaşık 20-30 dakika sürer, toplam yaklaşık 48 saat sürer. + +İndirilen satır sayısını aşağıdaki gibi kontrol edebilirsiniz: + +``` bash +$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" +## Count + 1298979494 +(1 row) + +real 7m9.164s +``` + +(Bu, Mark Litwintschik tarafından bir dizi blog gönderisinde bildirilen 1.1 milyar satırdan biraz daha fazladır .) + +Postgresql'deki veriler 370 GB alan kullanıyor. + +PostgreSQL veri verme: + +``` sql +COPY +( + SELECT trips.id, + trips.vendor_id, + trips.pickup_datetime, + trips.dropoff_datetime, + trips.store_and_fwd_flag, + trips.rate_code_id, + trips.pickup_longitude, + trips.pickup_latitude, + trips.dropoff_longitude, + trips.dropoff_latitude, + trips.passenger_count, + trips.trip_distance, + trips.fare_amount, + trips.extra, + trips.mta_tax, + trips.tip_amount, + trips.tolls_amount, + trips.ehail_fee, + trips.improvement_surcharge, + trips.total_amount, + trips.payment_type, + trips.trip_type, + trips.pickup, + trips.dropoff, + + cab_types.type cab_type, + + weather.precipitation_tenths_of_mm rain, + weather.snow_depth_mm, + weather.snowfall_mm, + weather.max_temperature_tenths_degrees_celsius max_temp, + weather.min_temperature_tenths_degrees_celsius min_temp, + weather.average_wind_speed_tenths_of_meters_per_second wind, + + pick_up.gid pickup_nyct2010_gid, + pick_up.ctlabel pickup_ctlabel, + pick_up.borocode pickup_borocode, + pick_up.boroname pickup_boroname, + pick_up.ct2010 pickup_ct2010, + pick_up.boroct2010 pickup_boroct2010, + pick_up.cdeligibil pickup_cdeligibil, + pick_up.ntacode pickup_ntacode, + pick_up.ntaname pickup_ntaname, + pick_up.puma pickup_puma, + + drop_off.gid dropoff_nyct2010_gid, + drop_off.ctlabel dropoff_ctlabel, + drop_off.borocode dropoff_borocode, + drop_off.boroname dropoff_boroname, + drop_off.ct2010 dropoff_ct2010, + drop_off.boroct2010 dropoff_boroct2010, + drop_off.cdeligibil dropoff_cdeligibil, + drop_off.ntacode dropoff_ntacode, + drop_off.ntaname dropoff_ntaname, + drop_off.puma dropoff_puma + FROM trips + LEFT JOIN cab_types + ON trips.cab_type_id = cab_types.id + LEFT JOIN central_park_weather_observations_raw weather + ON weather.date = trips.pickup_datetime::date + LEFT JOIN nyct2010 pick_up + ON pick_up.gid = trips.pickup_nyct2010_gid + LEFT JOIN nyct2010 drop_off + ON drop_off.gid = trips.dropoff_nyct2010_gid +) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; +``` + +Veri anlık görüntüsü saniyede yaklaşık 50 MB hızında oluşturulur. Anlık görüntü oluştururken, PostgreSQL diskten saniyede yaklaşık 28 MB hızında okur. +Bu yaklaşık 5 saat sürer. Elde edilen TSV dosyası 590612904969 bayttır. + +Clickhouse'da geçici bir tablo oluşturma: + +``` sql +CREATE TABLE trips +( +trip_id UInt32, +vendor_id String, +pickup_datetime DateTime, +dropoff_datetime Nullable(DateTime), +store_and_fwd_flag Nullable(FixedString(1)), +rate_code_id Nullable(UInt8), +pickup_longitude Nullable(Float64), +pickup_latitude Nullable(Float64), +dropoff_longitude Nullable(Float64), +dropoff_latitude Nullable(Float64), +passenger_count Nullable(UInt8), +trip_distance Nullable(Float64), +fare_amount Nullable(Float32), +extra Nullable(Float32), +mta_tax Nullable(Float32), +tip_amount Nullable(Float32), +tolls_amount Nullable(Float32), +ehail_fee Nullable(Float32), +improvement_surcharge Nullable(Float32), +total_amount Nullable(Float32), +payment_type Nullable(String), +trip_type Nullable(UInt8), +pickup Nullable(String), +dropoff Nullable(String), +cab_type Nullable(String), +precipitation Nullable(UInt8), +snow_depth Nullable(UInt8), +snowfall Nullable(UInt8), +max_temperature Nullable(UInt8), +min_temperature Nullable(UInt8), +average_wind_speed Nullable(UInt8), +pickup_nyct2010_gid Nullable(UInt8), +pickup_ctlabel Nullable(String), +pickup_borocode Nullable(UInt8), +pickup_boroname Nullable(String), +pickup_ct2010 Nullable(String), +pickup_boroct2010 Nullable(String), +pickup_cdeligibil Nullable(FixedString(1)), +pickup_ntacode Nullable(String), +pickup_ntaname Nullable(String), +pickup_puma Nullable(String), +dropoff_nyct2010_gid Nullable(UInt8), +dropoff_ctlabel Nullable(String), +dropoff_borocode Nullable(UInt8), +dropoff_boroname Nullable(String), +dropoff_ct2010 Nullable(String), +dropoff_boroct2010 Nullable(String), +dropoff_cdeligibil Nullable(String), +dropoff_ntacode Nullable(String), +dropoff_ntaname Nullable(String), +dropoff_puma Nullable(String) +) ENGINE = Log; +``` + +Alanları daha doğru veri türlerine dönüştürmek ve mümkünse Boşları ortadan kaldırmak için gereklidir. + +``` bash +$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv + +real 75m56.214s +``` + +Veri 112-140 Mb/saniye hızında okunur. +Bir akışta bir günlük türü tablosuna veri yükleme 76 dakika sürdü. +Bu tablodaki veriler 142 GB kullanır. + +(Verileri doğrudan Postgres'ten içe aktarmak da mümkündür `COPY ... TO PROGRAM`.) + +Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. + +Başlamak için, tek bir sunucuda bir tablo oluşturacağız. Daha sonra tabloyu dağıtacağız. + +Özet Tablo oluşturma ve doldurma: + +``` sql +CREATE TABLE trips_mergetree +ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +AS SELECT + +trip_id, +CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, +toDate(pickup_datetime) AS pickup_date, +ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, +toDate(dropoff_datetime) AS dropoff_date, +ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, +assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, +assumeNotNull(rate_code_id) AS rate_code_id, +assumeNotNull(pickup_longitude) AS pickup_longitude, +assumeNotNull(pickup_latitude) AS pickup_latitude, +assumeNotNull(dropoff_longitude) AS dropoff_longitude, +assumeNotNull(dropoff_latitude) AS dropoff_latitude, +assumeNotNull(passenger_count) AS passenger_count, +assumeNotNull(trip_distance) AS trip_distance, +assumeNotNull(fare_amount) AS fare_amount, +assumeNotNull(extra) AS extra, +assumeNotNull(mta_tax) AS mta_tax, +assumeNotNull(tip_amount) AS tip_amount, +assumeNotNull(tolls_amount) AS tolls_amount, +assumeNotNull(ehail_fee) AS ehail_fee, +assumeNotNull(improvement_surcharge) AS improvement_surcharge, +assumeNotNull(total_amount) AS total_amount, +CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, +assumeNotNull(trip_type) AS trip_type, +ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, +ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, +CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, + +assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, +toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, +assumeNotNull(pickup_borocode) AS pickup_borocode, +CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, +toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, +toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, +CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, +toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, + +CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, + +toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, + +assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, +toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, +assumeNotNull(dropoff_borocode) AS dropoff_borocode, +CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, +toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, +toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, +CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, +toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, + +CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, + +toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma + +FROM trips +``` + +Bu, saniyede yaklaşık 428.000 satırlık bir hızda 3030 saniye sürer. +Daha hızlı yüklemek için, tablo ile oluşturabilirsiniz `Log` motor yerine `MergeTree`. Bu durumda, indirme 200 saniyeden daha hızlı çalışır. + +Tablo 126 GB disk alanı kullanır. + +``` sql +SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active +``` + +``` text +┌─formatReadableSize(sum(bytes))─┐ +│ 126.18 GiB │ +└────────────────────────────────┘ +``` + +Diğer şeylerin yanı sıra, MERGETREE üzerinde en iyi duruma getirme sorgusunu çalıştırabilirsiniz. Ama her şey onsuz iyi olacak çünkü gerekli değildir. + +## Hazırlanan Bölüm downloadlerin indir downloadilmesi {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar +$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" +``` + +!!! info "Bilgin" + Aşağıda açıklanan sorguları çalıştıracaksanız, tam tablo adını kullanmanız gerekir, `datasets.trips_mergetree`. + +## Tek Server ile ilgili sonuçlar {#results-on-single-server} + +Q1: + +``` sql +SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type +``` + +0.490 saniye. + +Q2: + +``` sql +SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count +``` + +1.224 saniye. + +Q3: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year +``` + +2.104 saniye. + +Q4: + +``` sql +SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) +FROM trips_mergetree +GROUP BY passenger_count, year, distance +ORDER BY year, count(*) DESC +``` + +3.593 saniye. + +Aşağıdaki sunucu kullanıldı: + +İki Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60 GHz, 16 fiziksel çekirdekler toplam,128 GiB RAM,8x6 TB HD donanım RAID-5 + +Yürütme süresi üç koşunun en iyisidir. Ancak ikinci çalıştırmadan başlayarak, sorgular dosya sistemi önbelleğinden verileri okur. Başka önbelleğe alma oluşur: veri okundu ve her vadede işlenir. + +Üç sunucuda tablo oluşturma: + +Her sunucuda: + +``` sql +CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) +``` + +Kaynak sunucuda: + +``` sql +CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) +``` + +Aşağıdaki sorgu verileri yeniden dağıtır: + +``` sql +INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree +``` + +Bu 2454 saniye sürer. + +Üç sunucuda: + +Q1: 0.212 saniye. +Q2: 0.438 saniye. +Q3: 0.733 saniye. +Q4: 1.241 saniye. + +Sorgular doğrusal olarak ölçeklendiğinden, burada sürpriz yok. + +Ayrıca 140 sunucu kümesinden elde edilen sonuçlara sahibiz: + +Q1: 0.028 sn. +Q2: 0.043 sn. +Q3: 0.051 sn. +Q4: 0.072 sn. + +Bu durumda, sorgu işleme süresi her şeyden önce ağ gecikmesi ile belirlenir. +Finlandiya'daki bir Yandex veri merkezinde bulunan ve Rusya'daki bir kümede bulunan ve yaklaşık 20 ms gecikme süresi ekleyen bir istemci kullanarak sorgular çalıştırdık. + +## Özet {#summary} + +| hizmetçiler | Q1 | Q2 | Q3 | Q4 | +|-------------|-------|-------|-------|-------| +| 1 | 0.490 | 1.224 | 2.104 | 3.593 | +| 3 | 0.212 | 0.438 | 0.733 | 1.241 | +| 140 | 0.028 | 0.043 | 0.051 | 0.072 | + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/tr/getting-started/example-datasets/ontime.md b/docs/tr/getting-started/example-datasets/ontime.md new file mode 100644 index 00000000000..f1d477dbc6e --- /dev/null +++ b/docs/tr/getting-started/example-datasets/ontime.md @@ -0,0 +1,412 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 15 +toc_title: OnTime +--- + +# OnTime {#ontime} + +Bu veri kümesi iki şekilde elde edilebilir: + +- ham verilerden içe aktarma +- hazırlanan bölüm downloadlerin indir downloadilmesi + +## Ham verilerden içe aktarma {#import-from-raw-data} + +Veri indirme: + +``` bash +for s in `seq 1987 2018` +do +for m in `seq 1 12` +do +wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip +done +done +``` + +(from https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) + +Tablo oluşturma: + +``` sql +CREATE TABLE `ontime` ( + `Year` UInt16, + `Quarter` UInt8, + `Month` UInt8, + `DayofMonth` UInt8, + `DayOfWeek` UInt8, + `FlightDate` Date, + `UniqueCarrier` FixedString(7), + `AirlineID` Int32, + `Carrier` FixedString(2), + `TailNum` String, + `FlightNum` String, + `OriginAirportID` Int32, + `OriginAirportSeqID` Int32, + `OriginCityMarketID` Int32, + `Origin` FixedString(5), + `OriginCityName` String, + `OriginState` FixedString(2), + `OriginStateFips` String, + `OriginStateName` String, + `OriginWac` Int32, + `DestAirportID` Int32, + `DestAirportSeqID` Int32, + `DestCityMarketID` Int32, + `Dest` FixedString(5), + `DestCityName` String, + `DestState` FixedString(2), + `DestStateFips` String, + `DestStateName` String, + `DestWac` Int32, + `CRSDepTime` Int32, + `DepTime` Int32, + `DepDelay` Int32, + `DepDelayMinutes` Int32, + `DepDel15` Int32, + `DepartureDelayGroups` String, + `DepTimeBlk` String, + `TaxiOut` Int32, + `WheelsOff` Int32, + `WheelsOn` Int32, + `TaxiIn` Int32, + `CRSArrTime` Int32, + `ArrTime` Int32, + `ArrDelay` Int32, + `ArrDelayMinutes` Int32, + `ArrDel15` Int32, + `ArrivalDelayGroups` Int32, + `ArrTimeBlk` String, + `Cancelled` UInt8, + `CancellationCode` FixedString(1), + `Diverted` UInt8, + `CRSElapsedTime` Int32, + `ActualElapsedTime` Int32, + `AirTime` Int32, + `Flights` Int32, + `Distance` Int32, + `DistanceGroup` UInt8, + `CarrierDelay` Int32, + `WeatherDelay` Int32, + `NASDelay` Int32, + `SecurityDelay` Int32, + `LateAircraftDelay` Int32, + `FirstDepTime` String, + `TotalAddGTime` String, + `LongestAddGTime` String, + `DivAirportLandings` String, + `DivReachedDest` String, + `DivActualElapsedTime` String, + `DivArrDelay` String, + `DivDistance` String, + `Div1Airport` String, + `Div1AirportID` Int32, + `Div1AirportSeqID` Int32, + `Div1WheelsOn` String, + `Div1TotalGTime` String, + `Div1LongestGTime` String, + `Div1WheelsOff` String, + `Div1TailNum` String, + `Div2Airport` String, + `Div2AirportID` Int32, + `Div2AirportSeqID` Int32, + `Div2WheelsOn` String, + `Div2TotalGTime` String, + `Div2LongestGTime` String, + `Div2WheelsOff` String, + `Div2TailNum` String, + `Div3Airport` String, + `Div3AirportID` Int32, + `Div3AirportSeqID` Int32, + `Div3WheelsOn` String, + `Div3TotalGTime` String, + `Div3LongestGTime` String, + `Div3WheelsOff` String, + `Div3TailNum` String, + `Div4Airport` String, + `Div4AirportID` Int32, + `Div4AirportSeqID` Int32, + `Div4WheelsOn` String, + `Div4TotalGTime` String, + `Div4LongestGTime` String, + `Div4WheelsOff` String, + `Div4TailNum` String, + `Div5Airport` String, + `Div5AirportID` Int32, + `Div5AirportSeqID` Int32, + `Div5WheelsOn` String, + `Div5TotalGTime` String, + `Div5LongestGTime` String, + `Div5WheelsOff` String, + `Div5TailNum` String +) ENGINE = MergeTree +PARTITION BY Year +ORDER BY (Carrier, FlightDate) +SETTINGS index_granularity = 8192; +``` + +Veri yükleme: + +``` bash +$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done +``` + +## Hazırlanan Bölüm downloadlerin indir downloadilmesi {#download-of-prepared-partitions} + +``` bash +$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar +$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory +$ # check permissions of unpacked data, fix if required +$ sudo service clickhouse-server restart +$ clickhouse-client --query "select count(*) from datasets.ontime" +``` + +!!! info "Bilgin" + Aşağıda açıklanan sorguları çalıştıracaksanız, tam tablo adını kullanmanız gerekir, `datasets.ontime`. + +## Sorgular {#queries} + +Q0. + +``` sql +SELECT avg(c1) +FROM +( + SELECT Year, Month, count(*) AS c1 + FROM ontime + GROUP BY Year, Month +); +``` + +Q1. 2000 yılından 2008 yılına kadar günlük uçuş sayısı + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +S2. 2000-2008 için haftanın gününe göre gruplandırılmış 10 dakikadan fazla geciken uçuş sayısı + +``` sql +SELECT DayOfWeek, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY DayOfWeek +ORDER BY c DESC; +``` + +Q3. 2000-2008 için havaalanı tarafından gecikme sayısı + +``` sql +SELECT Origin, count(*) AS c +FROM ontime +WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 +GROUP BY Origin +ORDER BY c DESC +LIMIT 10; +``` + +S4. 2007 yılı için taşıyıcı tarafından gecikme sayısı + +``` sql +SELECT Carrier, count(*) +FROM ontime +WHERE DepDelay>10 AND Year=2007 +GROUP BY Carrier +ORDER BY count(*) DESC; +``` + +Q5. 2007 yılı için taşıyıcı tarafından gecikme yüzdesi + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year=2007 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year=2007 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Aynı sorgunun daha iyi sürümü: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year=2007 +GROUP BY Carrier +ORDER BY c3 DESC +``` + +S6. Daha geniş bir yıl aralığı için önceki talep, 2000-2008 + +``` sql +SELECT Carrier, c, c2, c*100/c2 as c3 +FROM +( + SELECT + Carrier, + count(*) AS c + FROM ontime + WHERE DepDelay>10 + AND Year>=2000 AND Year<=2008 + GROUP BY Carrier +) +JOIN +( + SELECT + Carrier, + count(*) AS c2 + FROM ontime + WHERE Year>=2000 AND Year<=2008 + GROUP BY Carrier +) USING Carrier +ORDER BY c3 DESC; +``` + +Aynı sorgunun daha iyi sürümü: + +``` sql +SELECT Carrier, avg(DepDelay>10)*100 AS c3 +FROM ontime +WHERE Year>=2000 AND Year<=2008 +GROUP BY Carrier +ORDER BY c3 DESC; +``` + +Q7. Yıla göre 10 dakikadan fazla gecikmeli uçuş yüzdesi + +``` sql +SELECT Year, c1/c2 +FROM +( + select + Year, + count(*)*100 as c1 + from ontime + WHERE DepDelay>10 + GROUP BY Year +) +JOIN +( + select + Year, + count(*) as c2 + from ontime + GROUP BY Year +) USING (Year) +ORDER BY Year; +``` + +Aynı sorgunun daha iyi sürümü: + +``` sql +SELECT Year, avg(DepDelay>10)*100 +FROM ontime +GROUP BY Year +ORDER BY Year; +``` + +S8. Çeşitli yıl aralıkları için doğrudan bağlı şehirlerin sayısına göre en popüler yerler + +``` sql +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +WHERE Year >= 2000 and Year <= 2010 +GROUP BY DestCityName +ORDER BY u DESC LIMIT 10; +``` + +Q9. + +``` sql +SELECT Year, count(*) AS c1 +FROM ontime +GROUP BY Year; +``` + +Q10. + +``` sql +SELECT + min(Year), max(Year), Carrier, count(*) AS cnt, + sum(ArrDelayMinutes>30) AS flights_delayed, + round(sum(ArrDelayMinutes>30)/count(*),2) AS rate +FROM ontime +WHERE + DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') + AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') + AND FlightDate < '2010-01-01' +GROUP by Carrier +HAVING cnt>100000 and max(Year)>1990 +ORDER by rate DESC +LIMIT 1000; +``` + +Bonus: + +``` sql +SELECT avg(cnt) +FROM +( + SELECT Year,Month,count(*) AS cnt + FROM ontime + WHERE DepDel15=1 + GROUP BY Year,Month +); + +SELECT avg(c1) FROM +( + SELECT Year,Month,count(*) AS c1 + FROM ontime + GROUP BY Year,Month +); + +SELECT DestCityName, uniqExact(OriginCityName) AS u +FROM ontime +GROUP BY DestCityName +ORDER BY u DESC +LIMIT 10; + +SELECT OriginCityName, DestCityName, count() AS c +FROM ontime +GROUP BY OriginCityName, DestCityName +ORDER BY c DESC +LIMIT 10; + +SELECT OriginCityName, count() AS c +FROM ontime +GROUP BY OriginCityName +ORDER BY c DESC +LIMIT 10; +``` + +Bu performans testi Vadim Tkachenko tarafından oluşturuldu. Görmek: + +- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ +- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ +- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ +- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ +- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ +- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/tr/getting-started/example-datasets/star-schema.md b/docs/tr/getting-started/example-datasets/star-schema.md new file mode 100644 index 00000000000..a82bcd569f9 --- /dev/null +++ b/docs/tr/getting-started/example-datasets/star-schema.md @@ -0,0 +1,370 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 20 +toc_title: "Y\u0131ld\u0131z \u015Eema Ben Benchmarkch Benchmarkmark" +--- + +# Yıldız Şema Ben Benchmarkch Benchmarkmark {#star-schema-benchmark} + +Dbgen derleme: + +``` bash +$ git clone git@github.com:vadimtk/ssb-dbgen.git +$ cd ssb-dbgen +$ make +``` + +Veri oluşturma: + +!!! warning "Dikkat" + İle `-s 100` dbgen, 600 milyon satır (67 GB) üretir `-s 1000` 6 milyar satır üretir (bu çok zaman alır) + +``` bash +$ ./dbgen -s 1000 -T c +$ ./dbgen -s 1000 -T l +$ ./dbgen -s 1000 -T p +$ ./dbgen -s 1000 -T s +$ ./dbgen -s 1000 -T d +``` + +Clickhouse'da tablolar oluşturma: + +``` sql +CREATE TABLE customer +( + C_CUSTKEY UInt32, + C_NAME String, + C_ADDRESS String, + C_CITY LowCardinality(String), + C_NATION LowCardinality(String), + C_REGION LowCardinality(String), + C_PHONE String, + C_MKTSEGMENT LowCardinality(String) +) +ENGINE = MergeTree ORDER BY (C_CUSTKEY); + +CREATE TABLE lineorder +( + LO_ORDERKEY UInt32, + LO_LINENUMBER UInt8, + LO_CUSTKEY UInt32, + LO_PARTKEY UInt32, + LO_SUPPKEY UInt32, + LO_ORDERDATE Date, + LO_ORDERPRIORITY LowCardinality(String), + LO_SHIPPRIORITY UInt8, + LO_QUANTITY UInt8, + LO_EXTENDEDPRICE UInt32, + LO_ORDTOTALPRICE UInt32, + LO_DISCOUNT UInt8, + LO_REVENUE UInt32, + LO_SUPPLYCOST UInt32, + LO_TAX UInt8, + LO_COMMITDATE Date, + LO_SHIPMODE LowCardinality(String) +) +ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY); + +CREATE TABLE part +( + P_PARTKEY UInt32, + P_NAME String, + P_MFGR LowCardinality(String), + P_CATEGORY LowCardinality(String), + P_BRAND LowCardinality(String), + P_COLOR LowCardinality(String), + P_TYPE LowCardinality(String), + P_SIZE UInt8, + P_CONTAINER LowCardinality(String) +) +ENGINE = MergeTree ORDER BY P_PARTKEY; + +CREATE TABLE supplier +( + S_SUPPKEY UInt32, + S_NAME String, + S_ADDRESS String, + S_CITY LowCardinality(String), + S_NATION LowCardinality(String), + S_REGION LowCardinality(String), + S_PHONE String +) +ENGINE = MergeTree ORDER BY S_SUPPKEY; +``` + +Veri ekleme: + +``` bash +$ clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl +$ clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl +$ clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl +$ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl +``` + +Dönüşüm “star schema” denormalized için “flat schema”: + +``` sql +SET max_memory_usage = 20000000000; + +CREATE TABLE lineorder_flat +ENGINE = MergeTree +PARTITION BY toYear(LO_ORDERDATE) +ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS +SELECT + l.LO_ORDERKEY AS LO_ORDERKEY, + l.LO_LINENUMBER AS LO_LINENUMBER, + l.LO_CUSTKEY AS LO_CUSTKEY, + l.LO_PARTKEY AS LO_PARTKEY, + l.LO_SUPPKEY AS LO_SUPPKEY, + l.LO_ORDERDATE AS LO_ORDERDATE, + l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY, + l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY, + l.LO_QUANTITY AS LO_QUANTITY, + l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE, + l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE, + l.LO_DISCOUNT AS LO_DISCOUNT, + l.LO_REVENUE AS LO_REVENUE, + l.LO_SUPPLYCOST AS LO_SUPPLYCOST, + l.LO_TAX AS LO_TAX, + l.LO_COMMITDATE AS LO_COMMITDATE, + l.LO_SHIPMODE AS LO_SHIPMODE, + c.C_NAME AS C_NAME, + c.C_ADDRESS AS C_ADDRESS, + c.C_CITY AS C_CITY, + c.C_NATION AS C_NATION, + c.C_REGION AS C_REGION, + c.C_PHONE AS C_PHONE, + c.C_MKTSEGMENT AS C_MKTSEGMENT, + s.S_NAME AS S_NAME, + s.S_ADDRESS AS S_ADDRESS, + s.S_CITY AS S_CITY, + s.S_NATION AS S_NATION, + s.S_REGION AS S_REGION, + s.S_PHONE AS S_PHONE, + p.P_NAME AS P_NAME, + p.P_MFGR AS P_MFGR, + p.P_CATEGORY AS P_CATEGORY, + p.P_BRAND AS P_BRAND, + p.P_COLOR AS P_COLOR, + p.P_TYPE AS P_TYPE, + p.P_SIZE AS P_SIZE, + p.P_CONTAINER AS P_CONTAINER +FROM lineorder AS l +INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY +INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY +INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; +``` + +Sorguları çalıştırma: + +Q1.1 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toYear(LO_ORDERDATE) = 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25; +``` + +Q1.2 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toYYYYMM(LO_ORDERDATE) = 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35; +``` + +Q1.3 + +``` sql +SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue +FROM lineorder_flat +WHERE toISOWeek(LO_ORDERDATE) = 6 AND toYear(LO_ORDERDATE) = 1994 + AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35; +``` + +Q2.1 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q2.2 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_BRAND >= 'MFGR#2221' AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q2.3 + +``` sql +SELECT + sum(LO_REVENUE), + toYear(LO_ORDERDATE) AS year, + P_BRAND +FROM lineorder_flat +WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' +GROUP BY + year, + P_BRAND +ORDER BY + year, + P_BRAND; +``` + +Q3.1 + +``` sql +SELECT + C_NATION, + S_NATION, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year >= 1992 AND year <= 1997 +GROUP BY + C_NATION, + S_NATION, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.2 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE C_NATION = 'UNITED STATES' AND S_NATION = 'UNITED STATES' AND year >= 1992 AND year <= 1997 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.3 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND year >= 1992 AND year <= 1997 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q3.4 + +``` sql +SELECT + C_CITY, + S_CITY, + toYear(LO_ORDERDATE) AS year, + sum(LO_REVENUE) AS revenue +FROM lineorder_flat +WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND toYYYYMM(LO_ORDERDATE) = 199712 +GROUP BY + C_CITY, + S_CITY, + year +ORDER BY + year ASC, + revenue DESC; +``` + +Q4.1 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + C_NATION, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') +GROUP BY + year, + C_NATION +ORDER BY + year ASC, + C_NATION ASC; +``` + +Q4.2 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + S_NATION, + P_CATEGORY, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year = 1997 OR year = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') +GROUP BY + year, + S_NATION, + P_CATEGORY +ORDER BY + year ASC, + S_NATION ASC, + P_CATEGORY ASC; +``` + +Q4.3 + +``` sql +SELECT + toYear(LO_ORDERDATE) AS year, + S_CITY, + P_BRAND, + sum(LO_REVENUE - LO_SUPPLYCOST) AS profit +FROM lineorder_flat +WHERE S_NATION = 'UNITED STATES' AND (year = 1997 OR year = 1998) AND P_CATEGORY = 'MFGR#14' +GROUP BY + year, + S_CITY, + P_BRAND +ORDER BY + year ASC, + S_CITY ASC, + P_BRAND ASC; +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/star_schema/) diff --git a/docs/tr/getting-started/example-datasets/wikistat.md b/docs/tr/getting-started/example-datasets/wikistat.md new file mode 100644 index 00000000000..f171502afe7 --- /dev/null +++ b/docs/tr/getting-started/example-datasets/wikistat.md @@ -0,0 +1,35 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 18 +toc_title: WikiStat +--- + +# WikiStat {#wikistat} + +Bakınız: http://dumps.wikimedia.org/other/pagecounts-raw/ + +Tablo oluşturma: + +``` sql +CREATE TABLE wikistat +( + date Date, + time DateTime, + project String, + subproject String, + path String, + hits UInt64, + size UInt64 +) ENGINE = MergeTree(date, (path, time), 8192); +``` + +Veri yükleme: + +``` bash +$ for i in {2007..2016}; do for j in {01..12}; do echo $i-$j >&2; curl -sSL "http://dumps.wikimedia.org/other/pagecounts-raw/$i/$i-$j/" | grep -oE 'pagecounts-[0-9]+-[0-9]+\.gz'; done; done | sort | uniq | tee links.txt +$ cat links.txt | while read link; do wget http://dumps.wikimedia.org/other/pagecounts-raw/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1/')/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1-\2/')/$link; done +$ ls -1 /opt/wikistat/ | grep gz | while read i; do echo $i; gzip -cd /opt/wikistat/$i | ./wikistat-loader --time="$(echo -n $i | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})\.gz/\1-\2-\3 \4-00-00/')" | clickhouse-client --query="INSERT INTO wikistat FORMAT TabSeparated"; done +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/wikistat/) diff --git a/docs/tr/getting-started/index.md b/docs/tr/getting-started/index.md new file mode 100644 index 00000000000..7e2f649040b --- /dev/null +++ b/docs/tr/getting-started/index.md @@ -0,0 +1,17 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Ba\u015Flarken" +toc_hidden: true +toc_priority: 8 +toc_title: "gizlenmi\u015F" +--- + +# Başlarken {#getting-started} + +Eğer ClickHouse için yeni ve performans bir hands-on hissi almak istiyorsanız, her şeyden önce, sen [yükleme işlemi](install.md). Bundan sonra şunları yapabilirsiniz: + +- [Ayrıntılı öğretici geçmesi](tutorial.md) +- [Örnek veri kümeleri ile deneme](example-datasets/ontime.md) + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/tr/getting-started/install.md b/docs/tr/getting-started/install.md new file mode 100644 index 00000000000..361f59b3a10 --- /dev/null +++ b/docs/tr/getting-started/install.md @@ -0,0 +1,182 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 11 +toc_title: Kurulum +--- + +# Kurulum {#installation} + +## Sistem Gereksinimleri {#system-requirements} + +ClickHouse, x86\_64, AArch64 veya PowerPC64LE CPU mimarisine sahip herhangi bir Linux, FreeBSD veya Mac OS X üzerinde çalışabilir. + +Resmi önceden oluşturulmuş ikili dosyalar genellikle x86\_64 ve kaldıraç sse 4.2 komut seti için derlenir, bu nedenle destekleyen CPU'nun aksi belirtilmedikçe ek bir sistem gereksinimi haline gelir. Geçerli CPU'nun sse 4.2 desteği olup olmadığını kontrol etmek için komut: + +``` bash +$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" +``` + +SSE 4.2'yi desteklemeyen veya AArch64 veya PowerPC64LE mimarisine sahip işlemcilerde Clickhouse'u çalıştırmak için şunları yapmalısınız [kaynaklardan ClickHouse oluşturun](#from-sources) uygun yapılandırma ayarlamaları ile. + +## Mevcut Kurulum Seçenekleri {#available-installation-options} + +### DEB paket fromlerinden {#install-from-deb-packages} + +Resmi önceden derlenmiş kullanılması tavsiye edilir `deb` Debian veya Ubuntu için paketler. Paketleri yüklemek için bu komutları çalıştırın: + +``` bash +{% include 'install/deb.sh' %} +``` + +En son sürümü kullanmak istiyorsanız, değiştirin `stable` ile `testing` (bu, test ortamlarınız için önerilir). + +Ayrıca paketleri manuel olarak indirebilir ve yükleyebilirsiniz [burada](https://repo.clickhouse.tech/deb/stable/main/). + +#### Paketler {#packages} + +- `clickhouse-common-static` — Installs ClickHouse compiled binary files. +- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` ve varsayılan sunucu yapılandırmasını yükler. +- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` ve diğer istemci ile ilgili araçlar. ve istemci yapılandırma dosyalarını yükler. +- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. + +### RPM paket fromlerinden {#from-rpm-packages} + +Resmi önceden derlenmiş kullanılması tavsiye edilir `rpm` CentOS, RedHat ve diğer tüm rpm tabanlı Linux dağıtımları için paketler. + +İlk olarak, resmi depoyu eklemeniz gerekir: + +``` bash +sudo yum install yum-utils +sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG +sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 +``` + +En son sürümü kullanmak istiyorsanız, değiştirin `stable` ile `testing` (bu, test ortamlarınız için önerilir). Bu `prestable` etiket de bazen kullanılabilir. + +Sonra paketleri yüklemek için bu komutları çalıştırın: + +``` bash +sudo yum install clickhouse-server clickhouse-client +``` + +Ayrıca paketleri manuel olarak indirebilir ve yükleyebilirsiniz [burada](https://repo.clickhouse.tech/rpm/stable/x86_64). + +### Tgz Arşivlerinden {#from-tgz-archives} + +Resmi önceden derlenmiş kullanılması tavsiye edilir `tgz` Arch ,iv ,es for tüm Linux dağıtım installationları, kurulumu `deb` veya `rpm` paketler mümkün değildir. + +Gerekli sürümü ile indirilebilir `curl` veya `wget` depo fromdan https://repo.clickhouse.tech/tgz/. +Bundan sonra indirilen arşivler açılmalı ve kurulum komut dosyaları ile kurulmalıdır. En son sürüm için örnek: + +``` bash +export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz +curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz + +tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz +sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz +sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh + +tar -xzvf clickhouse-server-$LATEST_VERSION.tgz +sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh +sudo /etc/init.d/clickhouse-server start + +tar -xzvf clickhouse-client-$LATEST_VERSION.tgz +sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh +``` + +Üretim ortamları için en son teknolojiyi kullanmanız önerilir `stable`-sürüm. Numarasını GitHub sayfasında bulabilirsiniz https://github.com/ClickHouse/ClickHouse/tags postfix ile `-stable`. + +### Docker Görüntüden {#from-docker-image} + +Docker içinde ClickHouse çalıştırmak için kılavuzu izleyin [Docker Hub](https://hub.docker.com/r/yandex/clickhouse-server/). Bu görüntüler resmi `deb` paketler içinde. + +### Kaynaklardan {#from-sources} + +Clickhouse'u el ile derlemek için aşağıdaki talimatları izleyin [Linux](../development/build.md) veya [Mac OS X](../development/build-osx.md). + +Paketleri derleyebilir ve yükleyebilir veya paketleri yüklemeden programları kullanabilirsiniz. Ayrıca elle inşa ederek SSE 4.2 gereksinimini devre dışı bırakabilir veya AArch64 CPU'lar için oluşturabilirsiniz. + + Client: programs/clickhouse-client + Server: programs/clickhouse-server + +Bir veri ve meta veri klasörleri oluşturmanız gerekir ve `chown` onları istenen kullanıcı için. Yolları sunucu yapılandırmasında değiştirilebilir (src / programlar / sunucu / config.xml), varsayılan olarak: + + /opt/clickhouse/data/default/ + /opt/clickhouse/metadata/default/ + +Gentoo üzerinde, sadece kullanabilirsiniz `emerge clickhouse` Clickhouse'u kaynaklardan yüklemek için. + +## Başlatmak {#launch} + +Sunucuyu bir daemon olarak başlatmak için çalıştırın: + +``` bash +$ sudo service clickhouse-server start +``` + +Yok eğer `service` command, run as + +``` bash +$ sudo /etc/init.d/clickhouse-server start +``` + +Günlükleri görmek `/var/log/clickhouse-server/` dizin. + +Sunucu başlatılmazsa, dosyadaki yapılandırmaları kontrol edin `/etc/clickhouse-server/config.xml`. + +Ayrıca sunucuyu konsoldan manuel olarak başlatabilirsiniz: + +``` bash +$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml +``` + +Bu durumda, günlük geliştirme sırasında uygun olan konsola yazdırılacaktır. +Yapılandırma dosyası geçerli dizinde ise, `--config-file` parametre. Varsayılan olarak, kullanır `./config.xml`. + +ClickHouse erişim kısıtlama ayarlarını destekler. Bulun theurlar. `users.xml` dosya (yanındaki `config.xml`). +Varsayılan olarak, erişim için herhangi bir yerden izin verilir `default` Kullanıcı, şifre olmadan. Görmek `user/default/networks`. +Daha fazla bilgi için bölüme bakın [“Configuration Files”](../operations/configuration-files.md). + +Sunucuyu başlattıktan sonra, ona bağlanmak için komut satırı istemcisini kullanabilirsiniz: + +``` bash +$ clickhouse-client +``` + +Varsayılan olarak, bağlanır `localhost:9000` kullanıcı adına `default` şifre olmadan. Kullanarak uzak bir sunucuya bağlanmak için de kullanılabilir `--host` tartışma. + +Terminal UTF-8 kodlamasını kullanmalıdır. +Daha fazla bilgi için bölüme bakın [“Command-line client”](../interfaces/cli.md). + +Örnek: + +``` bash +$ ./clickhouse-client +ClickHouse client version 0.0.18749. +Connecting to localhost:9000. +Connected to ClickHouse server version 0.0.18749. + +:) SELECT 1 + +SELECT 1 + +┌─1─┐ +│ 1 │ +└───┘ + +1 rows in set. Elapsed: 0.003 sec. + +:) +``` + +**Tebrikler, sistem çalışıyor!** + +Denemeye devam etmek için, test veri kümelerinden birini indirebilir veya şunları yapabilirsiniz [öğretici](https://clickhouse.tech/tutorial.html). + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/tr/getting-started/playground.md b/docs/tr/getting-started/playground.md new file mode 100644 index 00000000000..5d23ac34b71 --- /dev/null +++ b/docs/tr/getting-started/playground.md @@ -0,0 +1,48 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 14 +toc_title: "Bah\xE7e" +--- + +# ClickHouse Oyun Alanı {#clickhouse-playground} + +[ClickHouse Oyun Alanı](https://play.clickhouse.tech?file=welcome) kullanıcıların kendi sunucu veya küme kurmadan, anında sorguları çalıştırarak ClickHouse ile deneme sağlar. +Oyun alanında çeşitli örnek veri kümelerinin yanı sıra ClickHouse özelliklerini gösteren örnek sorgular da mevcuttur. + +Sorgular salt okunur bir kullanıcı olarak yürütülür. Bazı sınırlamaları ima eder: + +- DDL sorgularına İzin Verilmiyor +- Sorgu Ekle izin verilmez + +Aşağıdaki ayarlar da uygulanır: +- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) +- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) +- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) +- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) + +ClickHouse oyun alanı m2 deneyimini sunar.küçükler +[ClickHouse için yönetilen hizmet](https://cloud.yandex.com/services/managed-clickhouse) +örnek host hosteded in [Üye.Bulut](https://cloud.yandex.com/). +Hakkında daha fazla bilgi [bulut sağlayıcıları](../commercial/cloud.md). + +ClickHouse Playground web arayüzü clickhouse üzerinden istekleri yapar [HTTP API](../interfaces/http.md). +Bahçesi arka uç herhangi bir ek sunucu tarafı uygulaması olmadan sadece bir ClickHouse kümesidir. +ClickHouse HTTPS bitiş noktası da oyun alanının bir parçası olarak kullanılabilir. + +Herhangi bir HTTP istemcisi kullanarak oyun alanına sorgu yapabilirsiniz, örneğin [kıvrılma](https://curl.haxx.se) veya [wget](https://www.gnu.org/software/wget/), veya kullanarak bir bağlantı kurmak [JDBC](../interfaces/jdbc.md) veya [ODBC](../interfaces/odbc.md) sürücüler. +Clickhouse'u destekleyen yazılım ürünleri hakkında daha fazla bilgi mevcuttur [burada](../interfaces/index.md). + +| Parametre | Değer | +|:----------|:----------------------------------------| +| Nokta | https://play-api.clickhouse.teknik:8443 | +| Kullanan | `playground` | +| Şifre | `clickhouse` | + +Bu bitiş noktasının güvenli bir bağlantı gerektirdiğini unutmayın. + +Örnek: + +``` bash +curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" +``` diff --git a/docs/tr/getting-started/tutorial.md b/docs/tr/getting-started/tutorial.md new file mode 100644 index 00000000000..5cca914fb35 --- /dev/null +++ b/docs/tr/getting-started/tutorial.md @@ -0,0 +1,666 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 12 +toc_title: "\xD6\u011Fretici" +--- + +# ClickHouse Eğitimi {#clickhouse-tutorial} + +## Bu Öğreticiden ne beklenir? {#what-to-expect-from-this-tutorial} + +Bu öğreticiden geçerek, basit bir ClickHouse kümesinin nasıl kurulacağını öğreneceksiniz. Küçük ama hataya dayanıklı ve ölçeklenebilir olacak. Ardından, verilerle doldurmak ve bazı demo sorguları yürütmek için örnek veri kümelerinden birini kullanacağız. + +## Tek Düğüm Kurulumu {#single-node-setup} + +Dağıtılmış bir ortamın karmaşıklığını ertelemek için, Clickhouse'u tek bir sunucu veya sanal makinede dağıtmaya başlayacağız. ClickHouse genellikle [deb](install.md#install-from-deb-packages) veya [rpm](install.md#from-rpm-packages) paketler, ama var [alternatifler](install.md#from-docker-image) onları desteklemeyen işletim sistemleri için. + +Örneğin, seçtiğiniz `deb` paketler ve yürütülen: + +``` bash +{% include 'install/deb.sh' %} +``` + +Yüklü olan paketlerde ne var: + +- `clickhouse-client` paket içerir [clickhouse-müşteri](../interfaces/cli.md) uygulama, interaktif ClickHouse konsol istemcisi. +- `clickhouse-common` paket clickhouse yürütülebilir dosya içerir. +- `clickhouse-server` paket bir sunucu olarak ClickHouse çalıştırmak için yapılandırma dosyalarını içerir. + +Sunucu yapılandırma dosyaları bulunur `/etc/clickhouse-server/`. Daha fazla gitmeden önce, fark lütfen `` element in `config.xml`. Path, veri depolama için konumu belirler, bu nedenle büyük disk kapasitesine sahip birimde bulunmalıdır; varsayılan değer `/var/lib/clickhouse/`. Yapılandırmayı ayarlamak istiyorsanız, doğrudan düzenlemek kullanışlı değildir `config.xml` dosya, gelecekteki paket güncellemelerinde yeniden yazılabileceğini düşünüyor. Yapılandırma öğelerini geçersiz kılmak için önerilen yol oluşturmaktır [config dosyaları.d dizin](../operations/configuration-files.md) hizmet olarak “patches” config için.xml. + +Fark etmiş olabileceğiniz gibi, `clickhouse-server` paket kurulumdan sonra otomatik olarak başlatılmaz. Güncellemelerden sonra otomatik olarak yeniden başlatılmaz. Sunucuyu başlatma şekliniz init sisteminize bağlıdır, genellikle: + +``` bash +sudo service clickhouse-server start +``` + +veya + +``` bash +sudo /etc/init.d/clickhouse-server start +``` + +Sunucu günlükleri için varsayılan konum `/var/log/clickhouse-server/`. Sunucu, oturum açtıktan sonra istemci bağlantılarını işlemeye hazırdır. `Ready for connections` ileti. + +Bir kez `clickhouse-server` yukarı ve çalışıyor, biz kullanabilirsiniz `clickhouse-client` sunucuya bağlanmak ve aşağıdaki gibi bazı test sorguları çalıştırmak için `SELECT "Hello, world!";`. + +
+ +Clickhouse-client için hızlı ipuçları + +İnteraktif mod: + +``` bash +clickhouse-client +clickhouse-client --host=... --port=... --user=... --password=... +``` + +Çok satırlı sorguları etkinleştirme: + +``` bash +clickhouse-client -m +clickhouse-client --multiline +``` + +Toplu iş modunda sorguları çalıştırma: + +``` bash +clickhouse-client --query='SELECT 1' +echo 'SELECT 1' | clickhouse-client +clickhouse-client <<< 'SELECT 1' +``` + +Belirtilen biçimde bir dosyadan veri ekleme: + +``` bash +clickhouse-client --query='INSERT INTO table VALUES' < data.txt +clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv +``` + +
+ +## Örnek Veri Kümesini İçe Aktar {#import-sample-dataset} + +Şimdi ClickHouse sunucumuzu bazı örnek verilerle doldurmanın zamanı geldi. Bu eğitimde, yandex'in anonim verilerini kullanacağız.Metrica, açık kaynak olmadan önce Clickhouse'u üretim yolunda çalıştıran ilk hizmet (daha fazlası [tarih bölümü](../introduction/history.md)). Var [Yandex'i içe aktarmanın birden fazla yolu.Metrica veri kümesi](example-datasets/metrica.md) ve öğretici uğruna, en gerçekçi olanı ile gideceğiz. + +### Tablo verilerini indirin ve ayıklayın {#download-and-extract-table-data} + +``` bash +curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv +curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv +``` + +Çıkarılan dosyalar yaklaşık 10GB boyutundadır. + +### Tablo Oluşturma {#create-tables} + +Çoğu veritabanı yönetim sisteminde olduğu gibi, ClickHouse tabloları mantıksal olarak gruplar “databases”. Bir `default` veritabanı, ancak adında yeni bir tane oluşturacağız `tutorial`: + +``` bash +clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" +``` + +Tablolar oluşturmak için sözdizimi veritabanlarına kıyasla çok daha karmaşıktır (bkz. [başvurma](../sql-reference/statements/create.md). Genelde `CREATE TABLE` deyimi üç önemli şeyi belirtmek zorundadır: + +1. Oluşturulacak tablonun adı. +2. Table schema, i.e. list of columns and their [veri türleri](../sql-reference/data-types/index.md). +3. [Masa motoru](../engines/table-engines/index.md) ve bu tabloya yapılan sorguların fiziksel olarak nasıl yürütüleceği ile ilgili tüm ayrıntıları belirleyen ayarları. + +Üye.Metrica bir web analitiği hizmetidir ve örnek veri kümesi tam işlevselliğini kapsamaz, bu nedenle oluşturmak için sadece iki tablo vardır: + +- `hits` hizmet kapsamındaki tüm web sitelerinde tüm kullanıcılar tarafından yapılan her eylem ile bir tablodur. +- `visits` bireysel eylemler yerine önceden oluşturulmuş oturumlar içeren bir tablodur. + +Bu tablolar için gerçek create table sorgularını görelim ve yürütelim: + +``` sql +CREATE TABLE tutorial.hits_v1 +( + `WatchID` UInt64, + `JavaEnable` UInt8, + `Title` String, + `GoodEvent` Int16, + `EventTime` DateTime, + `EventDate` Date, + `CounterID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RegionID` UInt32, + `UserID` UInt64, + `CounterClass` Int8, + `OS` UInt8, + `UserAgent` UInt8, + `URL` String, + `Referer` String, + `URLDomain` String, + `RefererDomain` String, + `Refresh` UInt8, + `IsRobot` UInt8, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `FlashMinor2` String, + `NetMajor` UInt8, + `NetMinor` UInt8, + `UserAgentMajor` UInt16, + `UserAgentMinor` FixedString(2), + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `MobilePhone` UInt8, + `MobilePhoneModel` String, + `Params` String, + `IPNetworkID` UInt32, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `IsArtifical` UInt8, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `ClientTimeZone` Int16, + `ClientEventTime` DateTime, + `SilverlightVersion1` UInt8, + `SilverlightVersion2` UInt8, + `SilverlightVersion3` UInt32, + `SilverlightVersion4` UInt16, + `PageCharset` String, + `CodeVersion` UInt32, + `IsLink` UInt8, + `IsDownload` UInt8, + `IsNotBounce` UInt8, + `FUniqID` UInt64, + `HID` UInt32, + `IsOldCounter` UInt8, + `IsEvent` UInt8, + `IsParameter` UInt8, + `DontCountHits` UInt8, + `WithHash` UInt8, + `HitColor` FixedString(1), + `UTCEventTime` DateTime, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `WindowName` Int32, + `OpenerName` Int32, + `HistoryLength` Int16, + `BrowserLanguage` FixedString(2), + `BrowserCountry` FixedString(2), + `SocialNetwork` String, + `SocialAction` String, + `HTTPError` UInt16, + `SendTiming` Int32, + `DNSTiming` Int32, + `ConnectTiming` Int32, + `ResponseStartTiming` Int32, + `ResponseEndTiming` Int32, + `FetchTiming` Int32, + `RedirectTiming` Int32, + `DOMInteractiveTiming` Int32, + `DOMContentLoadedTiming` Int32, + `DOMCompleteTiming` Int32, + `LoadEventStartTiming` Int32, + `LoadEventEndTiming` Int32, + `NSToDOMContentLoadedTiming` Int32, + `FirstPaintTiming` Int32, + `RedirectCount` Int8, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `ParamPrice` Int64, + `ParamOrderID` String, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `GoalsReached` Array(UInt32), + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `RefererHash` UInt64, + `URLHash` UInt64, + `CLID` UInt32, + `YCLID` UInt64, + `ShareService` String, + `ShareURL` String, + `ShareTitle` String, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `IslandID` FixedString(16), + `RequestNum` UInt32, + `RequestTry` UInt8 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +``` sql +CREATE TABLE tutorial.visits_v1 +( + `CounterID` UInt32, + `StartDate` Date, + `Sign` Int8, + `IsNew` UInt8, + `VisitID` UInt64, + `UserID` UInt64, + `StartTime` DateTime, + `Duration` UInt32, + `UTCStartTime` DateTime, + `PageViews` Int32, + `Hits` Int32, + `IsBounce` UInt8, + `Referer` String, + `StartURL` String, + `RefererDomain` String, + `StartURLDomain` String, + `EndURL` String, + `LinkURL` String, + `IsDownload` UInt8, + `TraficSourceID` Int8, + `SearchEngineID` UInt16, + `SearchPhrase` String, + `AdvEngineID` UInt8, + `PlaceID` Int32, + `RefererCategories` Array(UInt16), + `URLCategories` Array(UInt16), + `URLRegions` Array(UInt32), + `RefererRegions` Array(UInt32), + `IsYandex` UInt8, + `GoalReachesDepth` Int32, + `GoalReachesURL` Int32, + `GoalReachesAny` Int32, + `SocialSourceNetworkID` UInt8, + `SocialSourcePage` String, + `MobilePhoneModel` String, + `ClientEventTime` DateTime, + `RegionID` UInt32, + `ClientIP` UInt32, + `ClientIP6` FixedString(16), + `RemoteIP` UInt32, + `RemoteIP6` FixedString(16), + `IPNetworkID` UInt32, + `SilverlightVersion3` UInt32, + `CodeVersion` UInt32, + `ResolutionWidth` UInt16, + `ResolutionHeight` UInt16, + `UserAgentMajor` UInt16, + `UserAgentMinor` UInt16, + `WindowClientWidth` UInt16, + `WindowClientHeight` UInt16, + `SilverlightVersion2` UInt8, + `SilverlightVersion4` UInt16, + `FlashVersion3` UInt16, + `FlashVersion4` UInt16, + `ClientTimeZone` Int16, + `OS` UInt8, + `UserAgent` UInt8, + `ResolutionDepth` UInt8, + `FlashMajor` UInt8, + `FlashMinor` UInt8, + `NetMajor` UInt8, + `NetMinor` UInt8, + `MobilePhone` UInt8, + `SilverlightVersion1` UInt8, + `Age` UInt8, + `Sex` UInt8, + `Income` UInt8, + `JavaEnable` UInt8, + `CookieEnable` UInt8, + `JavascriptEnable` UInt8, + `IsMobile` UInt8, + `BrowserLanguage` UInt16, + `BrowserCountry` UInt16, + `Interests` UInt16, + `Robotness` UInt8, + `GeneralInterests` Array(UInt16), + `Params` Array(String), + `Goals` Nested( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32), + `WatchIDs` Array(UInt64), + `ParamSumPrice` Int64, + `ParamCurrency` FixedString(3), + `ParamCurrencyID` UInt16, + `ClickLogID` UInt64, + `ClickEventID` Int32, + `ClickGoodEvent` Int32, + `ClickEventTime` DateTime, + `ClickPriorityID` Int32, + `ClickPhraseID` Int32, + `ClickPageID` Int32, + `ClickPlaceID` Int32, + `ClickTypeID` Int32, + `ClickResourceID` Int32, + `ClickCost` UInt32, + `ClickClientIP` UInt32, + `ClickDomainID` UInt32, + `ClickURL` String, + `ClickAttempt` UInt8, + `ClickOrderID` UInt32, + `ClickBannerID` UInt32, + `ClickMarketCategoryID` UInt32, + `ClickMarketPP` UInt32, + `ClickMarketCategoryName` String, + `ClickMarketPPName` String, + `ClickAWAPSCampaignName` String, + `ClickPageName` String, + `ClickTargetType` UInt16, + `ClickTargetPhraseID` UInt64, + `ClickContextType` UInt8, + `ClickSelectType` Int8, + `ClickOptions` String, + `ClickGroupBannerID` Int32, + `OpenstatServiceName` String, + `OpenstatCampaignID` String, + `OpenstatAdID` String, + `OpenstatSourceID` String, + `UTMSource` String, + `UTMMedium` String, + `UTMCampaign` String, + `UTMContent` String, + `UTMTerm` String, + `FromTag` String, + `HasGCLID` UInt8, + `FirstVisit` DateTime, + `PredLastVisit` Date, + `LastVisit` Date, + `TotalVisits` UInt32, + `TraficSource` Nested( + ID Int8, + SearchEngineID UInt16, + AdvEngineID UInt8, + PlaceID UInt16, + SocialSourceNetworkID UInt8, + Domain String, + SearchPhrase String, + SocialSourcePage String), + `Attendance` FixedString(16), + `CLID` UInt32, + `YCLID` UInt64, + `NormalizedRefererHash` UInt64, + `SearchPhraseHash` UInt64, + `RefererDomainHash` UInt64, + `NormalizedStartURLHash` UInt64, + `StartURLDomainHash` UInt64, + `NormalizedEndURLHash` UInt64, + `TopLevelDomain` UInt64, + `URLScheme` UInt64, + `OpenstatServiceNameHash` UInt64, + `OpenstatCampaignIDHash` UInt64, + `OpenstatAdIDHash` UInt64, + `OpenstatSourceIDHash` UInt64, + `UTMSourceHash` UInt64, + `UTMMediumHash` UInt64, + `UTMCampaignHash` UInt64, + `UTMContentHash` UInt64, + `UTMTermHash` UInt64, + `FromHash` UInt64, + `WebVisorEnabled` UInt8, + `WebVisorActivity` UInt32, + `ParsedParams` Nested( + Key1 String, + Key2 String, + Key3 String, + Key4 String, + Key5 String, + ValueDouble Float64), + `Market` Nested( + Type UInt8, + GoalID UInt32, + OrderID String, + OrderPrice Int64, + PP UInt32, + DirectPlaceID UInt32, + DirectOrderID UInt32, + DirectBannerID UInt32, + GoodID String, + GoodName String, + GoodQuantity Int32, + GoodPrice Int64), + `IslandID` FixedString(16) +) +ENGINE = CollapsingMergeTree(Sign) +PARTITION BY toYYYYMM(StartDate) +ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) +SAMPLE BY intHash32(UserID) +SETTINGS index_granularity = 8192 +``` + +Etkileşimli modunu kullanarak bu sorguları yürütebilirsiniz `clickhouse-client` (sadece önceden bir sorgu belirtmeden bir terminalde başlatın) veya bazı deneyin [alternatif arayüz](../interfaces/index.md) Eğer isterseniz. + +Gördüğümüz gibi, `hits_v1` kullanır [temel MergeTree motoru](../engines/table-engines/mergetree-family/mergetree.md), WH whileile the `visits_v1` kullanır [Çökme](../engines/table-engines/mergetree-family/collapsingmergetree.md) varyant. + +### Verileri İçe Aktar {#import-data} + +Clickhouse'a veri aktarımı yapılır [INSERT INTO](../sql-reference/statements/insert-into.md) diğer birçok SQL veritabanlarında olduğu gibi sorgu. Bununla birlikte, veriler genellikle [desteklenen seri hale getirme biçimleri](../interfaces/formats.md) yerine `VALUES` fıkra clausesı (ayrıca desteklenmektedir). + +Onları almak için ne kadar daha önce indirdiğimiz dosyaları sekme ayrılmış biçimde, yani burada konsol istemci ile : + +``` bash +clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv +clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv +``` + +ClickHouse bir yeri vardır [ayarlan settingsacak ayarlar](../operations/settings/index.md) ve bunları konsol istemcisinde belirtmenin bir yolu, görebildiğimiz gibi argümanlar aracılığıyla `--max_insert_block_size`. Hangi ayarların mevcut olduğunu, ne anlama geldiğini ve varsayılanların ne olduğunu anlamanın en kolay yolu `system.settings` Tablo: + +``` sql +SELECT name, value, changed, description +FROM system.settings +WHERE name LIKE '%max_insert_b%' +FORMAT TSV + +max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." +``` + +İsteğe bağlı olarak şunları yapabilirsiniz [OPTIMIZE](../sql-reference/statements/misc.md#misc_operations-optimize) ithalattan sonra tablolar. MergeTree-family'den bir motorla yapılandırılmış tablolar, veri depolamayı en iyi duruma getirmek (veya en azından mantıklı olup olmadığını kontrol etmek) için her zaman arka planda veri parçalarının birleştirilmesini sağlar. Bu sorgular, tablo motorunu bir süre sonra yerine şu anda depolama optimizasyonu yapmaya zorlar: + +``` bash +clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" +clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" +``` + +Bu sorgular bir G/Ç ve CPU yoğun işlem başlatır, bu nedenle tablo sürekli olarak yeni veriler alırsa, onu yalnız bırakmak ve birleştirmelerin arka planda çalışmasına izin vermek daha iyidir. + +Şimdi tablo ithalatının başarılı olup olmadığını kontrol edebiliriz: + +``` bash +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" +clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" +``` + +## Örnek Sorgular {#example-queries} + +``` sql +SELECT + StartURL AS URL, + AVG(Duration) AS AvgDuration +FROM tutorial.visits_v1 +WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' +GROUP BY URL +ORDER BY AvgDuration DESC +LIMIT 10 +``` + +``` sql +SELECT + sum(Sign) AS visits, + sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, + (100. * goal_visits) / visits AS goal_percent +FROM tutorial.visits_v1 +WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') +``` + +## Küme Dağıtımı {#cluster-deployment} + +ClickHouse kümesi homojen bir kümedir. Kurulum adımları: + +1. Kümenin tüm makinelerine ClickHouse Server'ı yükleyin +2. Yapılandırma dosyalarında küme yapılandırmalarını ayarlama +3. Her örnekte yerel tablolar oluşturun +4. Create a [Dağıtılmış tablo](../engines/table-engines/special/distributed.md) + +[Dağıtılmış tablo](../engines/table-engines/special/distributed.md) aslında bir tür “view” ClickHouse kümesinin yerel tablolarına. Dağıtılmış bir tablodan sorgu seçin, tüm kümenin parçalarının kaynaklarını kullanarak yürütür. Birden çok küme için yapılandırmalar belirtebilir ve farklı kümelere görünümler sağlayan birden çok dağıtılmış tablo oluşturabilirsiniz. + +Her biri bir kopya olan üç parçalı bir küme için örnek yapılandırma: + +``` xml + + + + + example-perftest01j.yandex.ru + 9000 + + + + + example-perftest02j.yandex.ru + 9000 + + + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +Daha fazla gösteri için, aynı ile yeni bir yerel tablo oluşturalım `CREATE TABLE` için kullandığımız sorgu `hits_v1` ama farklı bir tablo adı: + +``` sql +CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... +``` + +Kümenin yerel tablolarına bir görünüm sağlayan dağıtılmış bir tablo oluşturma: + +``` sql +CREATE TABLE tutorial.hits_all AS tutorial.hits_local +ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); +``` + +Yaygın bir uygulama, kümenin tüm makinelerinde benzer dağıtılmış tablolar oluşturmaktır. Kümenin herhangi bir makinesinde dağıtılmış sorguları çalıştırmaya izin verir. Ayrıca, belirli bir SELECT sorgusu için geçici dağıtılmış tablo oluşturmak için alternatif bir seçenek vardır [uzak](../sql-reference/table-functions/remote.md) tablo işlevi. + +Hadi koşalım [INSERT SELECT](../sql-reference/statements/insert-into.md) tabloyu birden çok sunucuya yaymak için dağıtılmış tabloya. + +``` sql +INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; +``` + +!!! warning "Bildirim" + Bu yaklaşım büyük tabloların parçalanması için uygun değildir. Ayrı bir araç var [clickhouse-fotokopi makinesi](../operations/utilities/clickhouse-copier.md) bu keyfi büyük tabloları yeniden parçalayabilir. + +Tahmin edebileceğiniz gibi, hesaplamalı olarak ağır sorgular, bir yerine 3 sunucu kullanıyorsa n kat daha hızlı çalışır. + +Bu durumda, 3 parçaya sahip bir küme kullandık ve her biri tek bir kopya içeriyor. + +Bir üretim ortamında esneklik sağlamak için, her bir parçanın birden çok kullanılabilirlik bölgesi veya veri merkezleri (veya en azından raflar) arasında yayılmış 2-3 kopya içermesi önerilir. ClickHouse yinelemeler sınırsız sayıda desteklediğini unutmayın. + +Üç yineleme içeren bir parça kümesi için örnek yapılandırma: + +``` xml + + ... + + + + example-perftest01j.yandex.ru + 9000 + + + example-perftest02j.yandex.ru + 9000 + + + example-perftest03j.yandex.ru + 9000 + + + + +``` + +Yerel çoğaltmayı etkinleştirmek için [ZooKeeper](http://zookeeper.apache.org/) gereklidir. ClickHouse tüm yinelemeler üzerinde veri tutarlılığı ilgilenir ve otomatik olarak hatadan sonra prosedürü geri çalışır. ZooKeeper kümesinin ayrı sunuculara dağıtılması önerilir(ClickHouse dahil başka hiçbir işlem çalışmaz). + +!!! note "Not" + ZooKeeper sıkı bir gereklilik değildir: bazı basit durumlarda, verileri uygulama kodunuzdan tüm kopyalara yazarak çoğaltabilirsiniz. Bu yaklaşım **değil** önerilen, bu durumda, ClickHouse tüm yinelemelerde veri tutarlılığını garanti edemez. Böylece başvurunuzun sorumluluğu haline gelir. + +Zookeeper konumları yapılandırma dosyasında belirtilir: + +``` xml + + + zoo01.yandex.ru + 2181 + + + zoo02.yandex.ru + 2181 + + + zoo03.yandex.ru + 2181 + + +``` + +Ayrıca, tablo oluşturulmasında kullanılan her bir parça ve kopyayı tanımlamak için makrolar ayarlamamız gerekir: + +``` xml + + 01 + 01 + +``` + +Yinelenmiş tablo oluşturma şu anda hiçbir yinelemeler varsa, yeni bir ilk yineleme örneği. Zaten canlı yinelemeler varsa, yeni yineleme varolan verileri klonlar. Önce tüm çoğaltılmış tablolar oluşturmak ve sonra veri eklemek için bir seçeneğiniz vardır. Başka bir seçenek, bazı yinelemeler oluşturmak ve veri ekleme sırasında veya sonrasında diğerlerini eklemektir. + +``` sql +CREATE TABLE tutorial.hits_replica (...) +ENGINE = ReplcatedMergeTree( + '/clickhouse_perftest/tables/{shard}/hits', + '{replica}' +) +... +``` + +Burada kullanıyoruz [ReplicatedMergeTree](../engines/table-engines/mergetree-family/replication.md) masa motoru. Parametrelerde, Shard ve çoğaltma tanımlayıcılarını içeren ZooKeeper yolunu belirtiyoruz. + +``` sql +INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; +``` + +Çoğaltma çok ana modda çalışır. Veriler herhangi bir kopyaya yüklenebilir ve sistem daha sonra otomatik olarak diğer örneklerle eşitler. Çoğaltma zaman uyumsuz olduğundan, belirli bir anda, tüm yinelemeler son eklenen verileri içerebilir. Veri alımına izin vermek için en az bir kopya olmalıdır. Diğerleri verileri senkronize eder ve tekrar aktif hale geldiklerinde tutarlılığı onarır. Bu yaklaşımın, yakın zamanda eklenen veri kaybı olasılığının düşük olmasına izin verdiğini unutmayın. + +[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/tr/getting_started/example_datasets/amplab_benchmark.md b/docs/tr/getting_started/example_datasets/amplab_benchmark.md deleted file mode 100644 index e6f95df68b8..00000000000 --- a/docs/tr/getting_started/example_datasets/amplab_benchmark.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 17 -toc_title: "AMPLab B\xFCy\xFCk Veri Benchmark" ---- - -# AMPLab Büyük Veri Benchmark {#amplab-big-data-benchmark} - -Bkz. https://amplab.cs.berkeley.edu/benchmark/ - -Ücretsiz bir hesap için kaydolun https://aws.amazon.com. bir kredi kartı, e-posta ve telefon numarası gerektirir. Yeni bir erişim anahtarı alın https://console.aws.amazon.com/iam/home?nc2=h\_m\_sc\#security\_credential - -Konsolda aşağıdakileri çalıştırın: - -``` bash -$ sudo apt-get install s3cmd -$ mkdir tiny; cd tiny; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/tiny/ . -$ cd .. -$ mkdir 1node; cd 1node; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/1node/ . -$ cd .. -$ mkdir 5nodes; cd 5nodes; -$ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . -$ cd .. -``` - -Aşağıdaki ClickHouse sorguları çalıştırın: - -``` sql -CREATE TABLE rankings_tiny -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_tiny -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); - -CREATE TABLE rankings_1node -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_1node -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); - -CREATE TABLE rankings_5nodes_on_single -( - pageURL String, - pageRank UInt32, - avgDuration UInt32 -) ENGINE = Log; - -CREATE TABLE uservisits_5nodes_on_single -( - sourceIP String, - destinationURL String, - visitDate Date, - adRevenue Float32, - UserAgent String, - cCode FixedString(3), - lCode FixedString(6), - searchWord String, - duration UInt32 -) ENGINE = MergeTree(visitDate, visitDate, 8192); -``` - -Konsola geri dön: - -``` bash -$ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done -$ for i in tiny/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_tiny FORMAT CSV"; done -$ for i in 1node/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_1node FORMAT CSV"; done -$ for i in 1node/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_1node FORMAT CSV"; done -$ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_5nodes_on_single FORMAT CSV"; done -$ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done -``` - -Veri örnekleri almak için sorgular: - -``` sql -SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 - -SELECT substring(sourceIP, 1, 8), sum(adRevenue) FROM uservisits_1node GROUP BY substring(sourceIP, 1, 8) - -SELECT - sourceIP, - sum(adRevenue) AS totalRevenue, - avg(pageRank) AS pageRank -FROM rankings_1node ALL INNER JOIN -( - SELECT - sourceIP, - destinationURL AS pageURL, - adRevenue - FROM uservisits_1node - WHERE (visitDate > '1980-01-01') AND (visitDate < '1980-04-01') -) USING pageURL -GROUP BY sourceIP -ORDER BY totalRevenue DESC -LIMIT 1 -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/amplab_benchmark/) diff --git a/docs/tr/getting_started/example_datasets/criteo.md b/docs/tr/getting_started/example_datasets/criteo.md deleted file mode 100644 index 37cb2d2b0e6..00000000000 --- a/docs/tr/getting_started/example_datasets/criteo.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 19 -toc_title: "Criteo'dan Terabyte t\u0131klama g\xFCnl\xFCkleri" ---- - -# Criteo'dan tıklama günlüklerinin terabayt {#terabyte-of-click-logs-from-criteo} - -Verileri indirin http://labs.criteo.com/downloads/download-terabyte-click-logs/ - -Günlük almak için bir tablo oluşturun: - -``` sql -CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log -``` - -Verileri indirin: - -``` bash -$ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done -``` - -Dönüştürülen veriler için bir tablo oluşturma: - -``` sql -CREATE TABLE criteo -( - date Date, - clicked UInt8, - int1 Int32, - int2 Int32, - int3 Int32, - int4 Int32, - int5 Int32, - int6 Int32, - int7 Int32, - int8 Int32, - int9 Int32, - int10 Int32, - int11 Int32, - int12 Int32, - int13 Int32, - icat1 UInt32, - icat2 UInt32, - icat3 UInt32, - icat4 UInt32, - icat5 UInt32, - icat6 UInt32, - icat7 UInt32, - icat8 UInt32, - icat9 UInt32, - icat10 UInt32, - icat11 UInt32, - icat12 UInt32, - icat13 UInt32, - icat14 UInt32, - icat15 UInt32, - icat16 UInt32, - icat17 UInt32, - icat18 UInt32, - icat19 UInt32, - icat20 UInt32, - icat21 UInt32, - icat22 UInt32, - icat23 UInt32, - icat24 UInt32, - icat25 UInt32, - icat26 UInt32 -) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192) -``` - -Verileri ham günlüğünden dönüştürün ve ikinci tabloya koyun: - -``` sql -INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log; - -DROP TABLE criteo_log; -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/criteo/) diff --git a/docs/tr/getting_started/example_datasets/index.md b/docs/tr/getting_started/example_datasets/index.md deleted file mode 100644 index fecb39f219f..00000000000 --- a/docs/tr/getting_started/example_datasets/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "\xD6rnek Veri K\xFCmeleri" -toc_priority: 12 -toc_title: "Giri\u015F" ---- - -# Örnek Veri Kümeleri {#example-datasets} - -Bu bölümde, örnek veri kümelerinin nasıl elde edileceği ve bunları Clickhouse'a nasıl içe aktarılacağı açıklanmaktadır. -Bazı veri kümeleri için örnek sorgular da mevcuttur. - -- [Anonim Yandex.Metrica Veri Kümesi](metrica.md) -- [Yıldız Şema Ben Benchmarkch Benchmarkmark](star_schema.md) -- [WikiStat](wikistat.md) -- [Criteo'dan tıklama günlüklerinin terabayt](criteo.md) -- [AMPLab Büyük Veri Benchmark](amplab_benchmark.md) -- [New York Taksi Verileri](nyc_taxi.md) -- [OnTime](ontime.md) - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets) diff --git a/docs/tr/getting_started/example_datasets/metrica.md b/docs/tr/getting_started/example_datasets/metrica.md deleted file mode 100644 index a9d3d6743ee..00000000000 --- a/docs/tr/getting_started/example_datasets/metrica.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 21 -toc_title: "\xDCye.Metrica Verileri" ---- - -# Anonim Yandex.Metrica Verileri {#anonymized-yandex-metrica-data} - -Veri kümesi, isabetlerle ilgili anonimleştirilmiş verileri içeren iki tablodan oluşur (`hits_v1`) ve ziyaret visitsler (`visits_v1`(kayıt olmak için).Metrica. Yandex hakkında daha fazla bilgi edinebilirsiniz.Metrica içinde [ClickHouse geçmişi](../../introduction/history.md) bölme. - -Veri kümesi iki tablodan oluşur, bunlardan biri sıkıştırılmış olarak indirilebilir `tsv.xz` dosya veya hazırlanmış bölümler olarak. Buna ek olarak, genişletilmiş bir sürümü `hits` 100 milyon satır içeren tablo TSV olarak mevcuttur https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits\_100m\_obfuscated\_v1.tsv.xz ve hazırlanan bölümler olarak https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits\_100m\_obfuscated\_v1.tar.xz. - -## Hazırlanan bölümlerden tablolar elde etme {#obtaining-tables-from-prepared-partitions} - -İndirme ve ithalat tablo hits: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_v1.tar -tar xvf hits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -İndirme ve ithalat ziyaretleri: - -``` bash -curl -O https://clickhouse-datasets.s3.yandex.net/visits/partitions/visits_v1.tar -tar xvf visits_v1.tar -C /var/lib/clickhouse # path to ClickHouse data directory -# check permissions on unpacked data, fix if required -sudo service clickhouse-server restart -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Sıkıştırılmış TSV dosyasından Tablo alma {#obtaining-tables-from-compressed-tsv-file} - -Sıkıştırılmış TSV dosyasından indir ve İçe Aktar: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.hits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" -``` - -Sıkıştırılmış tsv dosyasından ziyaretleri indirin ve içe aktarın: - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -# now create table -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" -clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" -# import data -cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 -# optionally you can optimize table -clickhouse-client --query "OPTIMIZE TABLE datasets.visits_v1 FINAL" -clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" -``` - -## Örnek Sorgular {#example-queries} - -[ClickHouse eğitimi](../../getting_started/tutorial.md) Yandex dayanmaktadır.Metrica veri kümesi ve bu veri kümesine başlamak için önerilen yol sadece öğreticiden geçmektir. - -Bu tablolara ek sorgu örnekleri arasında bulunabilir [durum bilgisi testleri](https://github.com/ClickHouse/ClickHouse/tree/master/tests/queries/1_stateful) ClickHouse of (onlar adlandırılır `test.hists` ve `test.visits` oralarda). diff --git a/docs/tr/getting_started/example_datasets/nyc_taxi.md b/docs/tr/getting_started/example_datasets/nyc_taxi.md deleted file mode 100644 index 218a7f06f7a..00000000000 --- a/docs/tr/getting_started/example_datasets/nyc_taxi.md +++ /dev/null @@ -1,390 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 16 -toc_title: New York Taksi Verileri ---- - -# New York Taksi Verileri {#new-york-taxi-data} - -Bu veri kümesi iki şekilde elde edilebilir: - -- ham verilerden içe aktarma -- hazırlanan bölüm downloadlerin indir downloadilmesi - -## Ham veri nasıl alınır {#how-to-import-the-raw-data} - -Bkz. https://github.com/toddwschneider/nyc-taxi-data ve http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html bir veri kümesinin açıklaması ve indirme talimatları için. - -İndirme, CSV dosyalarında yaklaşık 227 GB sıkıştırılmamış veri ile sonuçlanacaktır. İndirme, 1 Gbit bağlantısı üzerinden yaklaşık bir saat sürer (paralel indirme s3.amazonaws.com 1 Gbit kanalın en az yarısını kurtarır). -Bazı dosyalar tam olarak indirilmeyebilir. Dosya boyutlarını kontrol edin ve şüpheli görünen herhangi birini yeniden indirin. - -Bazı dosyalar geçersiz satırlar içerebilir. Bunları aşağıdaki gibi düzeltebilirsiniz: - -``` bash -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-02.csv > data/yellow_tripdata_2010-02.csv_ -sed -E '/(.*,){18,}/d' data/yellow_tripdata_2010-03.csv > data/yellow_tripdata_2010-03.csv_ -mv data/yellow_tripdata_2010-02.csv_ data/yellow_tripdata_2010-02.csv -mv data/yellow_tripdata_2010-03.csv_ data/yellow_tripdata_2010-03.csv -``` - -Daha sonra veriler Postgresql'de önceden işlenmelidir. Bu, çokgenlerdeki noktaların seçimlerini oluşturacaktır (Haritadaki noktaları New York şehrinin ilçeleriyle eşleştirmek için) ve tüm verileri bir birleştirme kullanarak tek bir denormalize düz tabloda birleştirecektir. Bunu yapmak için Postgresql'i Postgıs desteği ile yüklemeniz gerekir. - -Çalışırken dikkatli olun `initialize_database.sh` ve tüm tabloların doğru şekilde oluşturulduğunu manuel olarak yeniden kontrol edin. - -Postgresql'deki her ayın verilerini işlemek yaklaşık 20-30 dakika sürer, toplam yaklaşık 48 saat sürer. - -İndirilen satır sayısını aşağıdaki gibi kontrol edebilirsiniz: - -``` bash -$ time psql nyc-taxi-data -c "SELECT count(*) FROM trips;" -## Count - 1298979494 -(1 row) - -real 7m9.164s -``` - -(Bu, Mark Litwintschik tarafından bir dizi blog gönderisinde bildirilen 1.1 milyar satırdan biraz daha fazladır .) - -Postgresql'deki veriler 370 GB alan kullanıyor. - -PostgreSQL veri verme: - -``` sql -COPY -( - SELECT trips.id, - trips.vendor_id, - trips.pickup_datetime, - trips.dropoff_datetime, - trips.store_and_fwd_flag, - trips.rate_code_id, - trips.pickup_longitude, - trips.pickup_latitude, - trips.dropoff_longitude, - trips.dropoff_latitude, - trips.passenger_count, - trips.trip_distance, - trips.fare_amount, - trips.extra, - trips.mta_tax, - trips.tip_amount, - trips.tolls_amount, - trips.ehail_fee, - trips.improvement_surcharge, - trips.total_amount, - trips.payment_type, - trips.trip_type, - trips.pickup, - trips.dropoff, - - cab_types.type cab_type, - - weather.precipitation_tenths_of_mm rain, - weather.snow_depth_mm, - weather.snowfall_mm, - weather.max_temperature_tenths_degrees_celsius max_temp, - weather.min_temperature_tenths_degrees_celsius min_temp, - weather.average_wind_speed_tenths_of_meters_per_second wind, - - pick_up.gid pickup_nyct2010_gid, - pick_up.ctlabel pickup_ctlabel, - pick_up.borocode pickup_borocode, - pick_up.boroname pickup_boroname, - pick_up.ct2010 pickup_ct2010, - pick_up.boroct2010 pickup_boroct2010, - pick_up.cdeligibil pickup_cdeligibil, - pick_up.ntacode pickup_ntacode, - pick_up.ntaname pickup_ntaname, - pick_up.puma pickup_puma, - - drop_off.gid dropoff_nyct2010_gid, - drop_off.ctlabel dropoff_ctlabel, - drop_off.borocode dropoff_borocode, - drop_off.boroname dropoff_boroname, - drop_off.ct2010 dropoff_ct2010, - drop_off.boroct2010 dropoff_boroct2010, - drop_off.cdeligibil dropoff_cdeligibil, - drop_off.ntacode dropoff_ntacode, - drop_off.ntaname dropoff_ntaname, - drop_off.puma dropoff_puma - FROM trips - LEFT JOIN cab_types - ON trips.cab_type_id = cab_types.id - LEFT JOIN central_park_weather_observations_raw weather - ON weather.date = trips.pickup_datetime::date - LEFT JOIN nyct2010 pick_up - ON pick_up.gid = trips.pickup_nyct2010_gid - LEFT JOIN nyct2010 drop_off - ON drop_off.gid = trips.dropoff_nyct2010_gid -) TO '/opt/milovidov/nyc-taxi-data/trips.tsv'; -``` - -Veri anlık görüntüsü saniyede yaklaşık 50 MB hızında oluşturulur. Anlık görüntü oluştururken, PostgreSQL diskten saniyede yaklaşık 28 MB hızında okur. -Bu yaklaşık 5 saat sürer. Elde edilen TSV dosyası 590612904969 bayttır. - -Clickhouse'da geçici bir tablo oluşturma: - -``` sql -CREATE TABLE trips -( -trip_id UInt32, -vendor_id String, -pickup_datetime DateTime, -dropoff_datetime Nullable(DateTime), -store_and_fwd_flag Nullable(FixedString(1)), -rate_code_id Nullable(UInt8), -pickup_longitude Nullable(Float64), -pickup_latitude Nullable(Float64), -dropoff_longitude Nullable(Float64), -dropoff_latitude Nullable(Float64), -passenger_count Nullable(UInt8), -trip_distance Nullable(Float64), -fare_amount Nullable(Float32), -extra Nullable(Float32), -mta_tax Nullable(Float32), -tip_amount Nullable(Float32), -tolls_amount Nullable(Float32), -ehail_fee Nullable(Float32), -improvement_surcharge Nullable(Float32), -total_amount Nullable(Float32), -payment_type Nullable(String), -trip_type Nullable(UInt8), -pickup Nullable(String), -dropoff Nullable(String), -cab_type Nullable(String), -precipitation Nullable(UInt8), -snow_depth Nullable(UInt8), -snowfall Nullable(UInt8), -max_temperature Nullable(UInt8), -min_temperature Nullable(UInt8), -average_wind_speed Nullable(UInt8), -pickup_nyct2010_gid Nullable(UInt8), -pickup_ctlabel Nullable(String), -pickup_borocode Nullable(UInt8), -pickup_boroname Nullable(String), -pickup_ct2010 Nullable(String), -pickup_boroct2010 Nullable(String), -pickup_cdeligibil Nullable(FixedString(1)), -pickup_ntacode Nullable(String), -pickup_ntaname Nullable(String), -pickup_puma Nullable(String), -dropoff_nyct2010_gid Nullable(UInt8), -dropoff_ctlabel Nullable(String), -dropoff_borocode Nullable(UInt8), -dropoff_boroname Nullable(String), -dropoff_ct2010 Nullable(String), -dropoff_boroct2010 Nullable(String), -dropoff_cdeligibil Nullable(String), -dropoff_ntacode Nullable(String), -dropoff_ntaname Nullable(String), -dropoff_puma Nullable(String) -) ENGINE = Log; -``` - -Alanları daha doğru veri türlerine dönüştürmek ve mümkünse Boşları ortadan kaldırmak için gereklidir. - -``` bash -$ time clickhouse-client --query="INSERT INTO trips FORMAT TabSeparated" < trips.tsv - -real 75m56.214s -``` - -Veri 112-140 Mb/saniye hızında okunur. -Bir akışta bir günlük türü tablosuna veri yükleme 76 dakika sürdü. -Bu tablodaki veriler 142 GB kullanır. - -(Verileri doğrudan Postgres'ten içe aktarmak da mümkündür `COPY ... TO PROGRAM`.) - -Unfortunately, all the fields associated with the weather (precipitation…average\_wind\_speed) were filled with NULL. Because of this, we will remove them from the final data set. - -Başlamak için, tek bir sunucuda bir tablo oluşturacağız. Daha sonra tabloyu dağıtacağız. - -Özet Tablo oluşturma ve doldurma: - -``` sql -CREATE TABLE trips_mergetree -ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -AS SELECT - -trip_id, -CAST(vendor_id AS Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14)) AS vendor_id, -toDate(pickup_datetime) AS pickup_date, -ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime, -toDate(dropoff_datetime) AS dropoff_date, -ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime, -assumeNotNull(store_and_fwd_flag) IN ('Y', '1', '2') AS store_and_fwd_flag, -assumeNotNull(rate_code_id) AS rate_code_id, -assumeNotNull(pickup_longitude) AS pickup_longitude, -assumeNotNull(pickup_latitude) AS pickup_latitude, -assumeNotNull(dropoff_longitude) AS dropoff_longitude, -assumeNotNull(dropoff_latitude) AS dropoff_latitude, -assumeNotNull(passenger_count) AS passenger_count, -assumeNotNull(trip_distance) AS trip_distance, -assumeNotNull(fare_amount) AS fare_amount, -assumeNotNull(extra) AS extra, -assumeNotNull(mta_tax) AS mta_tax, -assumeNotNull(tip_amount) AS tip_amount, -assumeNotNull(tolls_amount) AS tolls_amount, -assumeNotNull(ehail_fee) AS ehail_fee, -assumeNotNull(improvement_surcharge) AS improvement_surcharge, -assumeNotNull(total_amount) AS total_amount, -CAST((assumeNotNull(payment_type) AS pt) IN ('CSH', 'CASH', 'Cash', 'CAS', 'Cas', '1') ? 'CSH' : (pt IN ('CRD', 'Credit', 'Cre', 'CRE', 'CREDIT', '2') ? 'CRE' : (pt IN ('NOC', 'No Charge', 'No', '3') ? 'NOC' : (pt IN ('DIS', 'Dispute', 'Dis', '4') ? 'DIS' : 'UNK'))) AS Enum8('CSH' = 1, 'CRE' = 2, 'UNK' = 0, 'NOC' = 3, 'DIS' = 4)) AS payment_type_, -assumeNotNull(trip_type) AS trip_type, -ifNull(toFixedString(unhex(pickup), 25), toFixedString('', 25)) AS pickup, -ifNull(toFixedString(unhex(dropoff), 25), toFixedString('', 25)) AS dropoff, -CAST(assumeNotNull(cab_type) AS Enum8('yellow' = 1, 'green' = 2, 'uber' = 3)) AS cab_type, - -assumeNotNull(pickup_nyct2010_gid) AS pickup_nyct2010_gid, -toFloat32(ifNull(pickup_ctlabel, '0')) AS pickup_ctlabel, -assumeNotNull(pickup_borocode) AS pickup_borocode, -CAST(assumeNotNull(pickup_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS pickup_boroname, -toFixedString(ifNull(pickup_ct2010, '000000'), 6) AS pickup_ct2010, -toFixedString(ifNull(pickup_boroct2010, '0000000'), 7) AS pickup_boroct2010, -CAST(assumeNotNull(ifNull(pickup_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS pickup_cdeligibil, -toFixedString(ifNull(pickup_ntacode, '0000'), 4) AS pickup_ntacode, - -CAST(assumeNotNull(pickup_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS pickup_ntaname, - -toUInt16(ifNull(pickup_puma, '0')) AS pickup_puma, - -assumeNotNull(dropoff_nyct2010_gid) AS dropoff_nyct2010_gid, -toFloat32(ifNull(dropoff_ctlabel, '0')) AS dropoff_ctlabel, -assumeNotNull(dropoff_borocode) AS dropoff_borocode, -CAST(assumeNotNull(dropoff_boroname) AS Enum8('Manhattan' = 1, 'Queens' = 4, 'Brooklyn' = 3, '' = 0, 'Bronx' = 2, 'Staten Island' = 5)) AS dropoff_boroname, -toFixedString(ifNull(dropoff_ct2010, '000000'), 6) AS dropoff_ct2010, -toFixedString(ifNull(dropoff_boroct2010, '0000000'), 7) AS dropoff_boroct2010, -CAST(assumeNotNull(ifNull(dropoff_cdeligibil, ' ')) AS Enum8(' ' = 0, 'E' = 1, 'I' = 2)) AS dropoff_cdeligibil, -toFixedString(ifNull(dropoff_ntacode, '0000'), 4) AS dropoff_ntacode, - -CAST(assumeNotNull(dropoff_ntaname) AS Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195)) AS dropoff_ntaname, - -toUInt16(ifNull(dropoff_puma, '0')) AS dropoff_puma - -FROM trips -``` - -Bu, saniyede yaklaşık 428.000 satırlık bir hızda 3030 saniye sürer. -Daha hızlı yüklemek için, tablo ile oluşturabilirsiniz `Log` motor yerine `MergeTree`. Bu durumda, indirme 200 saniyeden daha hızlı çalışır. - -Tablo 126 GB disk alanı kullanır. - -``` sql -SELECT formatReadableSize(sum(bytes)) FROM system.parts WHERE table = 'trips_mergetree' AND active -``` - -``` text -┌─formatReadableSize(sum(bytes))─┐ -│ 126.18 GiB │ -└────────────────────────────────┘ -``` - -Diğer şeylerin yanı sıra, MERGETREE üzerinde en iyi duruma getirme sorgusunu çalıştırabilirsiniz. Ama her şey onsuz iyi olacak çünkü gerekli değildir. - -## Hazırlanan Bölüm downloadlerin indir downloadilmesi {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/trips_mergetree/partitions/trips_mergetree.tar -$ tar xvf trips_mergetree.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.trips_mergetree" -``` - -!!! info "Bilgin" - Aşağıda açıklanan sorguları çalıştıracaksanız, tam tablo adını kullanmanız gerekir, `datasets.trips_mergetree`. - -## Tek Server ile ilgili sonuçlar {#results-on-single-server} - -Q1: - -``` sql -SELECT cab_type, count(*) FROM trips_mergetree GROUP BY cab_type -``` - -0.490 saniye. - -Q2: - -``` sql -SELECT passenger_count, avg(total_amount) FROM trips_mergetree GROUP BY passenger_count -``` - -1.224 saniye. - -Q3: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, count(*) FROM trips_mergetree GROUP BY passenger_count, year -``` - -2.104 saniye. - -Q4: - -``` sql -SELECT passenger_count, toYear(pickup_date) AS year, round(trip_distance) AS distance, count(*) -FROM trips_mergetree -GROUP BY passenger_count, year, distance -ORDER BY year, count(*) DESC -``` - -3.593 saniye. - -Aşağıdaki sunucu kullanıldı: - -İki Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60 GHz, 16 fiziksel çekirdekler toplam,128 GiB RAM,8x6 TB HD donanım RAID-5 - -Yürütme süresi üç koşunun en iyisidir. Ancak ikinci çalıştırmadan başlayarak, sorgular dosya sistemi önbelleğinden verileri okur. Başka önbelleğe alma oluşur: veri okundu ve her vadede işlenir. - -Üç sunucuda tablo oluşturma: - -Her sunucuda: - -``` sql -CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192) -``` - -Kaynak sunucuda: - -``` sql -CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(perftest, default, trips_mergetree_third, rand()) -``` - -Aşağıdaki sorgu verileri yeniden dağıtır: - -``` sql -INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree -``` - -Bu 2454 saniye sürer. - -Üç sunucuda: - -Q1: 0.212 saniye. -Q2: 0.438 saniye. -Q3: 0.733 saniye. -Q4: 1.241 saniye. - -Sorgular doğrusal olarak ölçeklendiğinden, burada sürpriz yok. - -Ayrıca 140 sunucu kümesinden elde edilen sonuçlara sahibiz: - -Q1: 0.028 sn. -Q2: 0.043 sn. -Q3: 0.051 sn. -Q4: 0.072 sn. - -Bu durumda, sorgu işleme süresi her şeyden önce ağ gecikmesi ile belirlenir. -Finlandiya'daki bir Yandex veri merkezinde bulunan ve Rusya'daki bir kümede bulunan ve yaklaşık 20 ms gecikme süresi ekleyen bir istemci kullanarak sorgular çalıştırdık. - -## Özet {#summary} - -| hizmetçiler | Q1 | Q2 | Q3 | Q4 | -|-------------|-------|-------|-------|-------| -| 1 | 0.490 | 1.224 | 2.104 | 3.593 | -| 3 | 0.212 | 0.438 | 0.733 | 1.241 | -| 140 | 0.028 | 0.043 | 0.051 | 0.072 | - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/nyc_taxi/) diff --git a/docs/tr/getting_started/example_datasets/ontime.md b/docs/tr/getting_started/example_datasets/ontime.md deleted file mode 100644 index dc06b86189f..00000000000 --- a/docs/tr/getting_started/example_datasets/ontime.md +++ /dev/null @@ -1,412 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 15 -toc_title: OnTime ---- - -# OnTime {#ontime} - -Bu veri kümesi iki şekilde elde edilebilir: - -- ham verilerden içe aktarma -- hazırlanan bölüm downloadlerin indir downloadilmesi - -## Ham Verilerden İçe Aktarma {#import-from-raw-data} - -Veri indirme: - -``` bash -for s in `seq 1987 2018` -do -for m in `seq 1 12` -do -wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip -done -done -``` - -(from https://github.com/Percona-Lab/ontime-airline-performance/blob/master/download.sh ) - -Tablo oluşturma: - -``` sql -CREATE TABLE `ontime` ( - `Year` UInt16, - `Quarter` UInt8, - `Month` UInt8, - `DayofMonth` UInt8, - `DayOfWeek` UInt8, - `FlightDate` Date, - `UniqueCarrier` FixedString(7), - `AirlineID` Int32, - `Carrier` FixedString(2), - `TailNum` String, - `FlightNum` String, - `OriginAirportID` Int32, - `OriginAirportSeqID` Int32, - `OriginCityMarketID` Int32, - `Origin` FixedString(5), - `OriginCityName` String, - `OriginState` FixedString(2), - `OriginStateFips` String, - `OriginStateName` String, - `OriginWac` Int32, - `DestAirportID` Int32, - `DestAirportSeqID` Int32, - `DestCityMarketID` Int32, - `Dest` FixedString(5), - `DestCityName` String, - `DestState` FixedString(2), - `DestStateFips` String, - `DestStateName` String, - `DestWac` Int32, - `CRSDepTime` Int32, - `DepTime` Int32, - `DepDelay` Int32, - `DepDelayMinutes` Int32, - `DepDel15` Int32, - `DepartureDelayGroups` String, - `DepTimeBlk` String, - `TaxiOut` Int32, - `WheelsOff` Int32, - `WheelsOn` Int32, - `TaxiIn` Int32, - `CRSArrTime` Int32, - `ArrTime` Int32, - `ArrDelay` Int32, - `ArrDelayMinutes` Int32, - `ArrDel15` Int32, - `ArrivalDelayGroups` Int32, - `ArrTimeBlk` String, - `Cancelled` UInt8, - `CancellationCode` FixedString(1), - `Diverted` UInt8, - `CRSElapsedTime` Int32, - `ActualElapsedTime` Int32, - `AirTime` Int32, - `Flights` Int32, - `Distance` Int32, - `DistanceGroup` UInt8, - `CarrierDelay` Int32, - `WeatherDelay` Int32, - `NASDelay` Int32, - `SecurityDelay` Int32, - `LateAircraftDelay` Int32, - `FirstDepTime` String, - `TotalAddGTime` String, - `LongestAddGTime` String, - `DivAirportLandings` String, - `DivReachedDest` String, - `DivActualElapsedTime` String, - `DivArrDelay` String, - `DivDistance` String, - `Div1Airport` String, - `Div1AirportID` Int32, - `Div1AirportSeqID` Int32, - `Div1WheelsOn` String, - `Div1TotalGTime` String, - `Div1LongestGTime` String, - `Div1WheelsOff` String, - `Div1TailNum` String, - `Div2Airport` String, - `Div2AirportID` Int32, - `Div2AirportSeqID` Int32, - `Div2WheelsOn` String, - `Div2TotalGTime` String, - `Div2LongestGTime` String, - `Div2WheelsOff` String, - `Div2TailNum` String, - `Div3Airport` String, - `Div3AirportID` Int32, - `Div3AirportSeqID` Int32, - `Div3WheelsOn` String, - `Div3TotalGTime` String, - `Div3LongestGTime` String, - `Div3WheelsOff` String, - `Div3TailNum` String, - `Div4Airport` String, - `Div4AirportID` Int32, - `Div4AirportSeqID` Int32, - `Div4WheelsOn` String, - `Div4TotalGTime` String, - `Div4LongestGTime` String, - `Div4WheelsOff` String, - `Div4TailNum` String, - `Div5Airport` String, - `Div5AirportID` Int32, - `Div5AirportSeqID` Int32, - `Div5WheelsOn` String, - `Div5TotalGTime` String, - `Div5LongestGTime` String, - `Div5WheelsOff` String, - `Div5TailNum` String -) ENGINE = MergeTree -PARTITION BY Year -ORDER BY (Carrier, FlightDate) -SETTINGS index_granularity = 8192; -``` - -Veri yükleme: - -``` bash -$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done -``` - -## Hazırlanan Bölüm downloadlerin indir downloadilmesi {#download-of-prepared-partitions} - -``` bash -$ curl -O https://clickhouse-datasets.s3.yandex.net/ontime/partitions/ontime.tar -$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory -$ # check permissions of unpacked data, fix if required -$ sudo service clickhouse-server restart -$ clickhouse-client --query "select count(*) from datasets.ontime" -``` - -!!! info "Bilgin" - Aşağıda açıklanan sorguları çalıştıracaksanız, tam tablo adını kullanmanız gerekir, `datasets.ontime`. - -## Sorgular {#queries} - -Q0. - -``` sql -SELECT avg(c1) -FROM -( - SELECT Year, Month, count(*) AS c1 - FROM ontime - GROUP BY Year, Month -); -``` - -Q1. 2000 yılından 2008 yılına kadar günlük uçuş sayısı - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -S2. 2000-2008 için haftanın gününe göre gruplandırılmış 10 dakikadan fazla geciken uçuş sayısı - -``` sql -SELECT DayOfWeek, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY DayOfWeek -ORDER BY c DESC; -``` - -Q3. 2000-2008 için havaalanı tarafından gecikme sayısı - -``` sql -SELECT Origin, count(*) AS c -FROM ontime -WHERE DepDelay>10 AND Year>=2000 AND Year<=2008 -GROUP BY Origin -ORDER BY c DESC -LIMIT 10; -``` - -S4. 2007 yılı için taşıyıcı tarafından gecikme sayısı - -``` sql -SELECT Carrier, count(*) -FROM ontime -WHERE DepDelay>10 AND Year=2007 -GROUP BY Carrier -ORDER BY count(*) DESC; -``` - -Q5. 2007 yılı için taşıyıcı tarafından gecikme yüzdesi - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year=2007 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year=2007 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Aynı sorgunun daha iyi sürümü: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year=2007 -GROUP BY Carrier -ORDER BY c3 DESC -``` - -S6. Daha geniş bir yıl aralığı için önceki talep, 2000-2008 - -``` sql -SELECT Carrier, c, c2, c*100/c2 as c3 -FROM -( - SELECT - Carrier, - count(*) AS c - FROM ontime - WHERE DepDelay>10 - AND Year>=2000 AND Year<=2008 - GROUP BY Carrier -) -JOIN -( - SELECT - Carrier, - count(*) AS c2 - FROM ontime - WHERE Year>=2000 AND Year<=2008 - GROUP BY Carrier -) USING Carrier -ORDER BY c3 DESC; -``` - -Aynı sorgunun daha iyi sürümü: - -``` sql -SELECT Carrier, avg(DepDelay>10)*100 AS c3 -FROM ontime -WHERE Year>=2000 AND Year<=2008 -GROUP BY Carrier -ORDER BY c3 DESC; -``` - -Q7. Yıla göre 10 dakikadan fazla gecikmeli uçuş yüzdesi - -``` sql -SELECT Year, c1/c2 -FROM -( - select - Year, - count(*)*100 as c1 - from ontime - WHERE DepDelay>10 - GROUP BY Year -) -JOIN -( - select - Year, - count(*) as c2 - from ontime - GROUP BY Year -) USING (Year) -ORDER BY Year; -``` - -Aynı sorgunun daha iyi sürümü: - -``` sql -SELECT Year, avg(DepDelay>10)*100 -FROM ontime -GROUP BY Year -ORDER BY Year; -``` - -S8. Çeşitli yıl aralıkları için doğrudan bağlı şehirlerin sayısına göre en popüler yerler - -``` sql -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -WHERE Year >= 2000 and Year <= 2010 -GROUP BY DestCityName -ORDER BY u DESC LIMIT 10; -``` - -Q9. - -``` sql -SELECT Year, count(*) AS c1 -FROM ontime -GROUP BY Year; -``` - -Q10. - -``` sql -SELECT - min(Year), max(Year), Carrier, count(*) AS cnt, - sum(ArrDelayMinutes>30) AS flights_delayed, - round(sum(ArrDelayMinutes>30)/count(*),2) AS rate -FROM ontime -WHERE - DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') - AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') - AND FlightDate < '2010-01-01' -GROUP by Carrier -HAVING cnt>100000 and max(Year)>1990 -ORDER by rate DESC -LIMIT 1000; -``` - -Bonus: - -``` sql -SELECT avg(cnt) -FROM -( - SELECT Year,Month,count(*) AS cnt - FROM ontime - WHERE DepDel15=1 - GROUP BY Year,Month -); - -SELECT avg(c1) FROM -( - SELECT Year,Month,count(*) AS c1 - FROM ontime - GROUP BY Year,Month -); - -SELECT DestCityName, uniqExact(OriginCityName) AS u -FROM ontime -GROUP BY DestCityName -ORDER BY u DESC -LIMIT 10; - -SELECT OriginCityName, DestCityName, count() AS c -FROM ontime -GROUP BY OriginCityName, DestCityName -ORDER BY c DESC -LIMIT 10; - -SELECT OriginCityName, count() AS c -FROM ontime -GROUP BY OriginCityName -ORDER BY c DESC -LIMIT 10; -``` - -Bu performans testi Vadim Tkachenko tarafından oluşturuldu. Görmek: - -- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ -- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ -- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/ -- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/ -- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/ -- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/ontime/) diff --git a/docs/tr/getting_started/example_datasets/star_schema.md b/docs/tr/getting_started/example_datasets/star_schema.md deleted file mode 100644 index 1326aab7ab2..00000000000 --- a/docs/tr/getting_started/example_datasets/star_schema.md +++ /dev/null @@ -1,370 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 20 -toc_title: "Y\u0131ld\u0131z \u015Eema Ben Benchmarkch Benchmarkmark" ---- - -# Yıldız Şema Ben Benchmarkch Benchmarkmark {#star-schema-benchmark} - -Dbgen derleme: - -``` bash -$ git clone git@github.com:vadimtk/ssb-dbgen.git -$ cd ssb-dbgen -$ make -``` - -Veri oluşturma: - -!!! warning "Dikkat" - İle `-s 100` dbgen, 600 milyon satır (67 GB) üretir `-s 1000` 6 milyar satır üretir (bu çok zaman alır) - -``` bash -$ ./dbgen -s 1000 -T c -$ ./dbgen -s 1000 -T l -$ ./dbgen -s 1000 -T p -$ ./dbgen -s 1000 -T s -$ ./dbgen -s 1000 -T d -``` - -Clickhouse'da tablolar oluşturma: - -``` sql -CREATE TABLE customer -( - C_CUSTKEY UInt32, - C_NAME String, - C_ADDRESS String, - C_CITY LowCardinality(String), - C_NATION LowCardinality(String), - C_REGION LowCardinality(String), - C_PHONE String, - C_MKTSEGMENT LowCardinality(String) -) -ENGINE = MergeTree ORDER BY (C_CUSTKEY); - -CREATE TABLE lineorder -( - LO_ORDERKEY UInt32, - LO_LINENUMBER UInt8, - LO_CUSTKEY UInt32, - LO_PARTKEY UInt32, - LO_SUPPKEY UInt32, - LO_ORDERDATE Date, - LO_ORDERPRIORITY LowCardinality(String), - LO_SHIPPRIORITY UInt8, - LO_QUANTITY UInt8, - LO_EXTENDEDPRICE UInt32, - LO_ORDTOTALPRICE UInt32, - LO_DISCOUNT UInt8, - LO_REVENUE UInt32, - LO_SUPPLYCOST UInt32, - LO_TAX UInt8, - LO_COMMITDATE Date, - LO_SHIPMODE LowCardinality(String) -) -ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY); - -CREATE TABLE part -( - P_PARTKEY UInt32, - P_NAME String, - P_MFGR LowCardinality(String), - P_CATEGORY LowCardinality(String), - P_BRAND LowCardinality(String), - P_COLOR LowCardinality(String), - P_TYPE LowCardinality(String), - P_SIZE UInt8, - P_CONTAINER LowCardinality(String) -) -ENGINE = MergeTree ORDER BY P_PARTKEY; - -CREATE TABLE supplier -( - S_SUPPKEY UInt32, - S_NAME String, - S_ADDRESS String, - S_CITY LowCardinality(String), - S_NATION LowCardinality(String), - S_REGION LowCardinality(String), - S_PHONE String -) -ENGINE = MergeTree ORDER BY S_SUPPKEY; -``` - -Veri ekleme: - -``` bash -$ clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl -$ clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl -$ clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl -$ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl -``` - -Dönüşüm “star schema” denormalized için “flat schema”: - -``` sql -SET max_memory_usage = 20000000000; - -CREATE TABLE lineorder_flat -ENGINE = MergeTree -PARTITION BY toYear(LO_ORDERDATE) -ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS -SELECT - l.LO_ORDERKEY AS LO_ORDERKEY, - l.LO_LINENUMBER AS LO_LINENUMBER, - l.LO_CUSTKEY AS LO_CUSTKEY, - l.LO_PARTKEY AS LO_PARTKEY, - l.LO_SUPPKEY AS LO_SUPPKEY, - l.LO_ORDERDATE AS LO_ORDERDATE, - l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY, - l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY, - l.LO_QUANTITY AS LO_QUANTITY, - l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE, - l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE, - l.LO_DISCOUNT AS LO_DISCOUNT, - l.LO_REVENUE AS LO_REVENUE, - l.LO_SUPPLYCOST AS LO_SUPPLYCOST, - l.LO_TAX AS LO_TAX, - l.LO_COMMITDATE AS LO_COMMITDATE, - l.LO_SHIPMODE AS LO_SHIPMODE, - c.C_NAME AS C_NAME, - c.C_ADDRESS AS C_ADDRESS, - c.C_CITY AS C_CITY, - c.C_NATION AS C_NATION, - c.C_REGION AS C_REGION, - c.C_PHONE AS C_PHONE, - c.C_MKTSEGMENT AS C_MKTSEGMENT, - s.S_NAME AS S_NAME, - s.S_ADDRESS AS S_ADDRESS, - s.S_CITY AS S_CITY, - s.S_NATION AS S_NATION, - s.S_REGION AS S_REGION, - s.S_PHONE AS S_PHONE, - p.P_NAME AS P_NAME, - p.P_MFGR AS P_MFGR, - p.P_CATEGORY AS P_CATEGORY, - p.P_BRAND AS P_BRAND, - p.P_COLOR AS P_COLOR, - p.P_TYPE AS P_TYPE, - p.P_SIZE AS P_SIZE, - p.P_CONTAINER AS P_CONTAINER -FROM lineorder AS l -INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY -INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY -INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; -``` - -Sorguları çalıştırma: - -Q1.1 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toYear(LO_ORDERDATE) = 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25; -``` - -Q1.2 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toYYYYMM(LO_ORDERDATE) = 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35; -``` - -Q1.3 - -``` sql -SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue -FROM lineorder_flat -WHERE toISOWeek(LO_ORDERDATE) = 6 AND toYear(LO_ORDERDATE) = 1994 - AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35; -``` - -Q2.1 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q2.2 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_BRAND >= 'MFGR#2221' AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q2.3 - -``` sql -SELECT - sum(LO_REVENUE), - toYear(LO_ORDERDATE) AS year, - P_BRAND -FROM lineorder_flat -WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' -GROUP BY - year, - P_BRAND -ORDER BY - year, - P_BRAND; -``` - -Q3.1 - -``` sql -SELECT - C_NATION, - S_NATION, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year >= 1992 AND year <= 1997 -GROUP BY - C_NATION, - S_NATION, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.2 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE C_NATION = 'UNITED STATES' AND S_NATION = 'UNITED STATES' AND year >= 1992 AND year <= 1997 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.3 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND year >= 1992 AND year <= 1997 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q3.4 - -``` sql -SELECT - C_CITY, - S_CITY, - toYear(LO_ORDERDATE) AS year, - sum(LO_REVENUE) AS revenue -FROM lineorder_flat -WHERE (C_CITY = 'UNITED KI1' OR C_CITY = 'UNITED KI5') AND (S_CITY = 'UNITED KI1' OR S_CITY = 'UNITED KI5') AND toYYYYMM(LO_ORDERDATE) = 199712 -GROUP BY - C_CITY, - S_CITY, - year -ORDER BY - year ASC, - revenue DESC; -``` - -Q4.1 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - C_NATION, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') -GROUP BY - year, - C_NATION -ORDER BY - year ASC, - C_NATION ASC; -``` - -Q4.2 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - S_NATION, - P_CATEGORY, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year = 1997 OR year = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') -GROUP BY - year, - S_NATION, - P_CATEGORY -ORDER BY - year ASC, - S_NATION ASC, - P_CATEGORY ASC; -``` - -Q4.3 - -``` sql -SELECT - toYear(LO_ORDERDATE) AS year, - S_CITY, - P_BRAND, - sum(LO_REVENUE - LO_SUPPLYCOST) AS profit -FROM lineorder_flat -WHERE S_NATION = 'UNITED STATES' AND (year = 1997 OR year = 1998) AND P_CATEGORY = 'MFGR#14' -GROUP BY - year, - S_CITY, - P_BRAND -ORDER BY - year ASC, - S_CITY ASC, - P_BRAND ASC; -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/star_schema/) diff --git a/docs/tr/getting_started/example_datasets/wikistat.md b/docs/tr/getting_started/example_datasets/wikistat.md deleted file mode 100644 index 0fc24dd5bb1..00000000000 --- a/docs/tr/getting_started/example_datasets/wikistat.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 18 -toc_title: WikiStat ---- - -# WikiStat {#wikistat} - -Bakınız: http://dumps.wikimedia.org/other/pagecounts-raw/ - -Tablo oluşturma: - -``` sql -CREATE TABLE wikistat -( - date Date, - time DateTime, - project String, - subproject String, - path String, - hits UInt64, - size UInt64 -) ENGINE = MergeTree(date, (path, time), 8192); -``` - -Veri yükleme: - -``` bash -$ for i in {2007..2016}; do for j in {01..12}; do echo $i-$j >&2; curl -sSL "http://dumps.wikimedia.org/other/pagecounts-raw/$i/$i-$j/" | grep -oE 'pagecounts-[0-9]+-[0-9]+\.gz'; done; done | sort | uniq | tee links.txt -$ cat links.txt | while read link; do wget http://dumps.wikimedia.org/other/pagecounts-raw/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1/')/$(echo $link | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz/\1-\2/')/$link; done -$ ls -1 /opt/wikistat/ | grep gz | while read i; do echo $i; gzip -cd /opt/wikistat/$i | ./wikistat-loader --time="$(echo -n $i | sed -r 's/pagecounts-([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})\.gz/\1-\2-\3 \4-00-00/')" | clickhouse-client --query="INSERT INTO wikistat FORMAT TabSeparated"; done -``` - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/example_datasets/wikistat/) diff --git a/docs/tr/getting_started/index.md b/docs/tr/getting_started/index.md deleted file mode 100644 index e97f9add1f0..00000000000 --- a/docs/tr/getting_started/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "Ba\u015Flarken" -toc_hidden: true -toc_priority: 8 -toc_title: "gizlenmi\u015F" ---- - -# Başlarken {#getting-started} - -Eğer ClickHouse için yeni ve performans bir hands-on hissi almak istiyorsanız, her şeyden önce, sen [yükleme işlemi](install.md). Bundan sonra şunları yapabilirsiniz: - -- [Ayrıntılı öğretici geçmesi](tutorial.md) -- [Örnek veri kümeleri ile deneme](example_datasets/ontime.md) - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/) diff --git a/docs/tr/getting_started/install.md b/docs/tr/getting_started/install.md deleted file mode 100644 index 2896737dc4f..00000000000 --- a/docs/tr/getting_started/install.md +++ /dev/null @@ -1,191 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 11 -toc_title: Kurulum ---- - -# Kurulum {#installation} - -## Sistem Gereksinimleri {#system-requirements} - -ClickHouse, x86\_64, AArch64 veya PowerPC64LE CPU mimarisine sahip herhangi bir Linux, FreeBSD veya Mac OS X üzerinde çalışabilir. - -Resmi önceden oluşturulmuş ikili dosyalar genellikle x86\_64 ve kaldıraç sse 4.2 komut seti için derlenir, bu nedenle destekleyen CPU'nun aksi belirtilmedikçe ek bir sistem gereksinimi haline gelir. Geçerli CPU'nun sse 4.2 desteği olup olmadığını kontrol etmek için komut: - -``` bash -$ grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" -``` - -SSE 4.2'yi desteklemeyen veya AArch64 veya PowerPC64LE mimarisine sahip işlemcilerde Clickhouse'u çalıştırmak için şunları yapmalısınız [kaynaklardan ClickHouse oluşturun](#from-sources) uygun yapılandırma ayarlamaları ile. - -## Mevcut Kurulum Seçenekleri {#available-installation-options} - -### DEB paket fromlerinden {#install-from-deb-packages} - -Resmi önceden derlenmiş kullanılması tavsiye edilir `deb` Debian veya Ubuntu için paketler. - -Resmi paketleri yüklemek için Yandex deposunu ekleyin `/etc/apt/sources.list` veya ayrı bir `/etc/apt/sources.list.d/clickhouse.list` Dosya: - - deb https://repo.clickhouse.tech/deb/stable/ main/ - -En son sürümü kullanmak istiyorsanız, değiştirin `stable` ile `testing` (bu, test ortamlarınız için önerilir). - -Sonra paketleri yüklemek için bu komutları çalıştırın: - -``` bash -sudo apt-get install apt-transport-https ca-certificates dirmngr # optional -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4 # optional -sudo apt-get update -sudo apt-get install clickhouse-client clickhouse-server -``` - -Paketleri buradan manuel olarak indirebilir ve kurabilirsiniz: https://repo.yandex.ru/clickhouse/deb/stable/main/. - -#### Paketler {#packages} - -- `clickhouse-common-static` — Installs ClickHouse compiled binary files. -- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` ve varsayılan sunucu yapılandırmasını yükler. -- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` ve diğer istemci ile ilgili araçlar. ve istemci yapılandırma dosyalarını yükler. -- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info. - -### RPM paket fromlerinden {#from-rpm-packages} - -Resmi önceden derlenmiş kullanılması tavsiye edilir `rpm` CentOS, RedHat ve diğer tüm rpm tabanlı Linux dağıtımları için paketler. - -İlk olarak, resmi depoyu eklemeniz gerekir: - -``` bash -sudo yum install yum-utils -sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG -sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 -``` - -En son sürümü kullanmak istiyorsanız, değiştirin `stable` ile `testing` (bu, test ortamlarınız için önerilir). Bu `prestable` etiket de bazen kullanılabilir. - -Sonra paketleri yüklemek için bu komutları çalıştırın: - -``` bash -sudo yum install clickhouse-server clickhouse-client -``` - -Paketleri buradan manuel olarak indirebilir ve kurabilirsiniz: https://repo.clickhouse.teknoloji / rpm / kararlı / x86\_64. - -### Tgz Arşivlerinden {#from-tgz-archives} - -Resmi önceden derlenmiş kullanılması tavsiye edilir `tgz` Arch ,iv ,es for tüm Linux dağıtım installationları, kurulumu `deb` veya `rpm` paketler mümkün değildir. - -Gerekli sürümü ile indirilebilir `curl` veya `wget` depo fromdan https://repo.yandex.ru/clickhouse/tgz/. -Bundan sonra indirilen arşivler açılmalı ve kurulum komut dosyaları ile kurulmalıdır. En son sürüm için örnek: - -``` bash -export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1` -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz -curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz - -tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz -sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz -sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh - -tar -xzvf clickhouse-server-$LATEST_VERSION.tgz -sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh -sudo /etc/init.d/clickhouse-server start - -tar -xzvf clickhouse-client-$LATEST_VERSION.tgz -sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh -``` - -Üretim ortamları için en son teknolojiyi kullanmanız önerilir `stable`-sürüm. Numarasını GitHub sayfasında bulabilirsiniz https://github.com/ClickHouse/ClickHouse/tags postfix ile `-stable`. - -### Docker Görüntüden {#from-docker-image} - -Docker içinde ClickHouse çalıştırmak için kılavuzu izleyin [Docker Hub](https://hub.docker.com/r/yandex/clickhouse-server/). Bu görüntüler resmi `deb` paketler içinde. - -### Kaynaklardan {#from-sources} - -Clickhouse'u el ile derlemek için aşağıdaki talimatları izleyin [Linux](../development/build.md) veya [Mac OS X](../development/build_osx.md). - -Paketleri derleyebilir ve yükleyebilir veya paketleri yüklemeden programları kullanabilirsiniz. Ayrıca elle inşa ederek SSE 4.2 gereksinimini devre dışı bırakabilir veya AArch64 CPU'lar için oluşturabilirsiniz. - - Client: programs/clickhouse-client - Server: programs/clickhouse-server - -Bir veri ve meta veri klasörleri oluşturmanız gerekir ve `chown` onları istenen kullanıcı için. Yolları sunucu yapılandırmasında değiştirilebilir (src / programlar / sunucu / config.xml), varsayılan olarak: - - /opt/clickhouse/data/default/ - /opt/clickhouse/metadata/default/ - -Gentoo üzerinde, sadece kullanabilirsiniz `emerge clickhouse` Clickhouse'u kaynaklardan yüklemek için. - -## Başlamak {#launch} - -Sunucuyu bir daemon olarak başlatmak için çalıştırın: - -``` bash -$ sudo service clickhouse-server start -``` - -Yok eğer `service` command, run as - -``` bash -$ sudo /etc/init.d/clickhouse-server start -``` - -Günlükleri görmek `/var/log/clickhouse-server/` dizin. - -Sunucu başlatılmazsa, dosyadaki yapılandırmaları kontrol edin `/etc/clickhouse-server/config.xml`. - -Ayrıca sunucuyu konsoldan manuel olarak başlatabilirsiniz: - -``` bash -$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml -``` - -Bu durumda, günlük geliştirme sırasında uygun olan konsola yazdırılacaktır. -Yapılandırma dosyası geçerli dizinde ise, `--config-file` parametre. Varsayılan olarak, kullanır `./config.xml`. - -ClickHouse erişim kısıtlama ayarlarını destekler. Bulun theurlar. `users.xml` dosya (yanındaki `config.xml`). -Varsayılan olarak, erişim için herhangi bir yerden izin verilir `default` Kullanıcı, şifre olmadan. Görmek `user/default/networks`. -Daha fazla bilgi için bölüme bakın [“Configuration Files”](../operations/configuration_files.md). - -Sunucuyu başlattıktan sonra, ona bağlanmak için komut satırı istemcisini kullanabilirsiniz: - -``` bash -$ clickhouse-client -``` - -Varsayılan olarak, bağlanır `localhost:9000` kullanıcı adına `default` şifre olmadan. Kullanarak uzak bir sunucuya bağlanmak için de kullanılabilir `--host` değişken. - -Terminal UTF-8 kodlamasını kullanmalıdır. -Daha fazla bilgi için bölüme bakın [“Command-line client”](../interfaces/cli.md). - -Örnek: - -``` bash -$ ./clickhouse-client -ClickHouse client version 0.0.18749. -Connecting to localhost:9000. -Connected to ClickHouse server version 0.0.18749. - -:) SELECT 1 - -SELECT 1 - -┌─1─┐ -│ 1 │ -└───┘ - -1 rows in set. Elapsed: 0.003 sec. - -:) -``` - -**Tebrikler, sistem çalışıyor!** - -Denemeye devam etmek için, test veri kümelerinden birini indirebilir veya şunları yapabilirsiniz [öğretici](https://clickhouse.tech/tutorial.html). - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/install/) diff --git a/docs/tr/getting_started/playground.md b/docs/tr/getting_started/playground.md deleted file mode 100644 index 7c0f3641544..00000000000 --- a/docs/tr/getting_started/playground.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 14 -toc_title: "Bah\xE7e" ---- - -# ClickHouse Oyun Alanı {#clickhouse-playground} - -[ClickHouse Oyun Alanı](https://play.clickhouse.tech?file=welcome) kullanıcıların kendi sunucu veya küme kurmadan, anında sorguları çalıştırarak ClickHouse ile deneme sağlar. -Oyun alanında çeşitli örnek veri kümelerinin yanı sıra ClickHouse özelliklerini gösteren örnek sorgular da mevcuttur. - -Sorgular salt okunur bir kullanıcı olarak yürütülür. Bazı sınırlamaları ima eder: - -- DDL sorgularına İzin Verilmiyor -- Sorgu Ekle izin verilmez - -Aşağıdaki ayarlar da uygulanır: -- [`max_result_bytes=10485760`](../operations/settings/query_complexity/#max-result-bytes) -- [`max_result_rows=2000`](../operations/settings/query_complexity/#setting-max_result_rows) -- [`result_overflow_mode=break`](../operations/settings/query_complexity/#result-overflow-mode) -- [`max_execution_time=60000`](../operations/settings/query_complexity/#max-execution-time) - -ClickHouse oyun alanı m2 deneyimini sunar.küçükler -[ClickHouse için yönetilen hizmet](https://cloud.yandex.com/services/managed-clickhouse) -örnek host hosteded in [Üye.Bulut](https://cloud.yandex.com/). -Hakkında daha fazla bilgi [bulut sağlayıcıları](../commercial/cloud.md). - -ClickHouse Playground web arayüzü clickhouse üzerinden istekleri yapar [HTTP API](../interfaces/http.md). -Bahçesi arka uç herhangi bir ek sunucu tarafı uygulaması olmadan sadece bir ClickHouse kümesidir. -ClickHouse HTTPS bitiş noktası da oyun alanının bir parçası olarak kullanılabilir. - -Herhangi bir HTTP istemcisi kullanarak oyun alanına sorgu yapabilirsiniz, örneğin [kıvrılma](https://curl.haxx.se) veya [wget](https://www.gnu.org/software/wget/), veya kullanarak bir bağlantı kurmak [JDBC](../interfaces/jdbc.md) veya [ODBC](../interfaces/odbc.md) sürücüler. -Clickhouse'u destekleyen yazılım ürünleri hakkında daha fazla bilgi mevcuttur [burada](../interfaces/index.md). - -| Parametre | Değer | -|:----------|:----------------------------------------| -| Nokta | https://play-api.clickhouse.teknik:8443 | -| Kullanan | `playground` | -| Şifre | `clickhouse` | - -Bu bitiş noktasının güvenli bir bağlantı gerektirdiğini unutmayın. - -Örnek: - -``` bash -curl "https://play-api.clickhouse.tech:8443/?query=SELECT+'Play+ClickHouse!';&user=playground&password=clickhouse&database=datasets" -``` diff --git a/docs/tr/getting_started/tutorial.md b/docs/tr/getting_started/tutorial.md deleted file mode 100644 index e22a8c1ef5a..00000000000 --- a/docs/tr/getting_started/tutorial.md +++ /dev/null @@ -1,671 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 12 -toc_title: "\xD6\u011Fretici" ---- - -# ClickHouse Eğitimi {#clickhouse-tutorial} - -## Bu Öğreticiden ne beklenir? {#what-to-expect-from-this-tutorial} - -Bu öğreticiden geçerek, basit bir ClickHouse kümesinin nasıl kurulacağını öğreneceksiniz. Küçük ama hataya dayanıklı ve ölçeklenebilir olacak. Ardından, verilerle doldurmak ve bazı demo sorguları yürütmek için örnek veri kümelerinden birini kullanacağız. - -## Tek Düğüm Kurulumu {#single-node-setup} - -Dağıtılmış bir ortamın karmaşıklığını ertelemek için, Clickhouse'u tek bir sunucu veya sanal makinede dağıtmaya başlayacağız. ClickHouse genellikle [deb](index.md#install-from-deb-packages) veya [rpm](index.md#from-rpm-packages) paketler, ama var [alternatifler](index.md#from-docker-image) onları desteklemeyen işletim sistemleri için. - -Örneğin, seçtiğiniz `deb` paketler ve yürütülen: - -``` bash -sudo apt-get install apt-transport-https ca-certificates dirmngr -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4 - -echo "deb https://repo.clickhouse.tech/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list -sudo apt-get update - -sudo apt-get install -y clickhouse-server clickhouse-client -``` - -Yüklü olan paketlerde ne var: - -- `clickhouse-client` paket içerir [clickhouse-müşteri](../interfaces/cli.md) uygulama, interaktif ClickHouse konsol istemcisi. -- `clickhouse-common` paket clickhouse yürütülebilir dosya içerir. -- `clickhouse-server` paket bir sunucu olarak ClickHouse çalıştırmak için yapılandırma dosyalarını içerir. - -Sunucu yapılandırma dosyaları bulunur `/etc/clickhouse-server/`. Daha fazla gitmeden önce, fark lütfen `` element in `config.xml`. Path, veri depolama için konumu belirler, bu nedenle büyük disk kapasitesine sahip birimde bulunmalıdır; varsayılan değer `/var/lib/clickhouse/`. Yapılandırmayı ayarlamak istiyorsanız, doğrudan düzenlemek kullanışlı değildir `config.xml` dosya, gelecekteki paket güncellemelerinde yeniden yazılabileceğini düşünüyor. Yapılandırma öğelerini geçersiz kılmak için önerilen yol oluşturmaktır [config dosyaları.d dizin](../operations/configuration_files.md) hizmet olarak “patches” config için.xml. - -Fark etmiş olabileceğiniz gibi, `clickhouse-server` paket kurulumdan sonra otomatik olarak başlatılmaz. Güncellemelerden sonra otomatik olarak yeniden başlatılmaz. Sunucuyu başlatma şekliniz init sisteminize bağlıdır, genellikle: - -``` bash -sudo service clickhouse-server start -``` - -veya - -``` bash -sudo /etc/init.d/clickhouse-server start -``` - -Sunucu günlükleri için varsayılan konum `/var/log/clickhouse-server/`. Sunucu, oturum açtıktan sonra istemci bağlantılarını işlemeye hazırdır. `Ready for connections` ileti. - -Bir kez `clickhouse-server` yukarı ve çalışıyor, biz kullanabilirsiniz `clickhouse-client` sunucuya bağlanmak ve aşağıdaki gibi bazı test sorguları çalıştırmak için `SELECT "Hello, world!";`. - -
- -Clickhouse-client için hızlı ipuçları -İnteraktif mod: - -``` bash -clickhouse-client -clickhouse-client --host=... --port=... --user=... --password=... -``` - -Çok satırlı sorguları etkinleştirme: - -``` bash -clickhouse-client -m -clickhouse-client --multiline -``` - -Toplu iş modunda sorguları çalıştırma: - -``` bash -clickhouse-client --query='SELECT 1' -echo 'SELECT 1' | clickhouse-client -clickhouse-client <<< 'SELECT 1' -``` - -Belirtilen biçimde bir dosyadan veri ekleme: - -``` bash -clickhouse-client --query='INSERT INTO table VALUES' < data.txt -clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv -``` - -
- -## Örnek Veri Kümesini İçe Aktar {#import-sample-dataset} - -Şimdi ClickHouse sunucumuzu bazı örnek verilerle doldurmanın zamanı geldi. Bu eğitimde, yandex'in anonim verilerini kullanacağız.Metrica, açık kaynak olmadan önce Clickhouse'u üretim yolunda çalıştıran ilk hizmet (daha fazlası [tarih bölümü](../introduction/history.md)). Var [Yandex'i içe aktarmanın birden fazla yolu.Metrica veri kümesi](example_datasets/metrica.md) ve öğretici uğruna, en gerçekçi olanı ile gideceğiz. - -### Tablo verilerini indirin ve ayıklayın {#download-and-extract-table-data} - -``` bash -curl https://clickhouse-datasets.s3.yandex.net/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv -curl https://clickhouse-datasets.s3.yandex.net/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv -``` - -Çıkarılan dosyalar yaklaşık 10GB boyutundadır. - -### Tablo Oluşturma {#create-tables} - -Çoğu veritabanı yönetim sisteminde olduğu gibi, ClickHouse tabloları mantıksal olarak gruplar “databases”. Bir `default` veritabanı, ancak adında yeni bir tane oluşturacağız `tutorial`: - -``` bash -clickhouse-client --query "CREATE DATABASE IF NOT EXISTS tutorial" -``` - -Tablolar oluşturmak için sözdizimi veritabanlarına kıyasla çok daha karmaşıktır (bkz. [başvurma](../sql_reference/statements/create.md). Genelde `CREATE TABLE` deyimi üç önemli şeyi belirtmek zorundadır: - -1. Oluşturulacak tablonun adı. -2. Table schema, i.e. list of columns and their [veri türleri](../sql_reference/data_types/index.md). -3. [Masa motoru](../engines/table_engines/index.md) ve bu tabloya yapılan sorguların fiziksel olarak nasıl yürütüleceği ile ilgili tüm ayrıntıları belirleyen ayarları. - -Üye.Metrica bir web analitiği hizmetidir ve örnek veri kümesi tam işlevselliğini kapsamaz, bu nedenle oluşturmak için sadece iki tablo vardır: - -- `hits` hizmet kapsamındaki tüm web sitelerinde tüm kullanıcılar tarafından yapılan her eylem ile bir tablodur. -- `visits` bireysel eylemler yerine önceden oluşturulmuş oturumlar içeren bir tablodur. - -Bu tablolar için gerçek create table sorgularını görelim ve yürütelim: - -``` sql -CREATE TABLE tutorial.hits_v1 -( - `WatchID` UInt64, - `JavaEnable` UInt8, - `Title` String, - `GoodEvent` Int16, - `EventTime` DateTime, - `EventDate` Date, - `CounterID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RegionID` UInt32, - `UserID` UInt64, - `CounterClass` Int8, - `OS` UInt8, - `UserAgent` UInt8, - `URL` String, - `Referer` String, - `URLDomain` String, - `RefererDomain` String, - `Refresh` UInt8, - `IsRobot` UInt8, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `FlashMinor2` String, - `NetMajor` UInt8, - `NetMinor` UInt8, - `UserAgentMajor` UInt16, - `UserAgentMinor` FixedString(2), - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `MobilePhone` UInt8, - `MobilePhoneModel` String, - `Params` String, - `IPNetworkID` UInt32, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `IsArtifical` UInt8, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `ClientTimeZone` Int16, - `ClientEventTime` DateTime, - `SilverlightVersion1` UInt8, - `SilverlightVersion2` UInt8, - `SilverlightVersion3` UInt32, - `SilverlightVersion4` UInt16, - `PageCharset` String, - `CodeVersion` UInt32, - `IsLink` UInt8, - `IsDownload` UInt8, - `IsNotBounce` UInt8, - `FUniqID` UInt64, - `HID` UInt32, - `IsOldCounter` UInt8, - `IsEvent` UInt8, - `IsParameter` UInt8, - `DontCountHits` UInt8, - `WithHash` UInt8, - `HitColor` FixedString(1), - `UTCEventTime` DateTime, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `WindowName` Int32, - `OpenerName` Int32, - `HistoryLength` Int16, - `BrowserLanguage` FixedString(2), - `BrowserCountry` FixedString(2), - `SocialNetwork` String, - `SocialAction` String, - `HTTPError` UInt16, - `SendTiming` Int32, - `DNSTiming` Int32, - `ConnectTiming` Int32, - `ResponseStartTiming` Int32, - `ResponseEndTiming` Int32, - `FetchTiming` Int32, - `RedirectTiming` Int32, - `DOMInteractiveTiming` Int32, - `DOMContentLoadedTiming` Int32, - `DOMCompleteTiming` Int32, - `LoadEventStartTiming` Int32, - `LoadEventEndTiming` Int32, - `NSToDOMContentLoadedTiming` Int32, - `FirstPaintTiming` Int32, - `RedirectCount` Int8, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `ParamPrice` Int64, - `ParamOrderID` String, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `GoalsReached` Array(UInt32), - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `RefererHash` UInt64, - `URLHash` UInt64, - `CLID` UInt32, - `YCLID` UInt64, - `ShareService` String, - `ShareURL` String, - `ShareTitle` String, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `IslandID` FixedString(16), - `RequestNum` UInt32, - `RequestTry` UInt8 -) -ENGINE = MergeTree() -PARTITION BY toYYYYMM(EventDate) -ORDER BY (CounterID, EventDate, intHash32(UserID)) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -``` sql -CREATE TABLE tutorial.visits_v1 -( - `CounterID` UInt32, - `StartDate` Date, - `Sign` Int8, - `IsNew` UInt8, - `VisitID` UInt64, - `UserID` UInt64, - `StartTime` DateTime, - `Duration` UInt32, - `UTCStartTime` DateTime, - `PageViews` Int32, - `Hits` Int32, - `IsBounce` UInt8, - `Referer` String, - `StartURL` String, - `RefererDomain` String, - `StartURLDomain` String, - `EndURL` String, - `LinkURL` String, - `IsDownload` UInt8, - `TraficSourceID` Int8, - `SearchEngineID` UInt16, - `SearchPhrase` String, - `AdvEngineID` UInt8, - `PlaceID` Int32, - `RefererCategories` Array(UInt16), - `URLCategories` Array(UInt16), - `URLRegions` Array(UInt32), - `RefererRegions` Array(UInt32), - `IsYandex` UInt8, - `GoalReachesDepth` Int32, - `GoalReachesURL` Int32, - `GoalReachesAny` Int32, - `SocialSourceNetworkID` UInt8, - `SocialSourcePage` String, - `MobilePhoneModel` String, - `ClientEventTime` DateTime, - `RegionID` UInt32, - `ClientIP` UInt32, - `ClientIP6` FixedString(16), - `RemoteIP` UInt32, - `RemoteIP6` FixedString(16), - `IPNetworkID` UInt32, - `SilverlightVersion3` UInt32, - `CodeVersion` UInt32, - `ResolutionWidth` UInt16, - `ResolutionHeight` UInt16, - `UserAgentMajor` UInt16, - `UserAgentMinor` UInt16, - `WindowClientWidth` UInt16, - `WindowClientHeight` UInt16, - `SilverlightVersion2` UInt8, - `SilverlightVersion4` UInt16, - `FlashVersion3` UInt16, - `FlashVersion4` UInt16, - `ClientTimeZone` Int16, - `OS` UInt8, - `UserAgent` UInt8, - `ResolutionDepth` UInt8, - `FlashMajor` UInt8, - `FlashMinor` UInt8, - `NetMajor` UInt8, - `NetMinor` UInt8, - `MobilePhone` UInt8, - `SilverlightVersion1` UInt8, - `Age` UInt8, - `Sex` UInt8, - `Income` UInt8, - `JavaEnable` UInt8, - `CookieEnable` UInt8, - `JavascriptEnable` UInt8, - `IsMobile` UInt8, - `BrowserLanguage` UInt16, - `BrowserCountry` UInt16, - `Interests` UInt16, - `Robotness` UInt8, - `GeneralInterests` Array(UInt16), - `Params` Array(String), - `Goals` Nested( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32), - `WatchIDs` Array(UInt64), - `ParamSumPrice` Int64, - `ParamCurrency` FixedString(3), - `ParamCurrencyID` UInt16, - `ClickLogID` UInt64, - `ClickEventID` Int32, - `ClickGoodEvent` Int32, - `ClickEventTime` DateTime, - `ClickPriorityID` Int32, - `ClickPhraseID` Int32, - `ClickPageID` Int32, - `ClickPlaceID` Int32, - `ClickTypeID` Int32, - `ClickResourceID` Int32, - `ClickCost` UInt32, - `ClickClientIP` UInt32, - `ClickDomainID` UInt32, - `ClickURL` String, - `ClickAttempt` UInt8, - `ClickOrderID` UInt32, - `ClickBannerID` UInt32, - `ClickMarketCategoryID` UInt32, - `ClickMarketPP` UInt32, - `ClickMarketCategoryName` String, - `ClickMarketPPName` String, - `ClickAWAPSCampaignName` String, - `ClickPageName` String, - `ClickTargetType` UInt16, - `ClickTargetPhraseID` UInt64, - `ClickContextType` UInt8, - `ClickSelectType` Int8, - `ClickOptions` String, - `ClickGroupBannerID` Int32, - `OpenstatServiceName` String, - `OpenstatCampaignID` String, - `OpenstatAdID` String, - `OpenstatSourceID` String, - `UTMSource` String, - `UTMMedium` String, - `UTMCampaign` String, - `UTMContent` String, - `UTMTerm` String, - `FromTag` String, - `HasGCLID` UInt8, - `FirstVisit` DateTime, - `PredLastVisit` Date, - `LastVisit` Date, - `TotalVisits` UInt32, - `TraficSource` Nested( - ID Int8, - SearchEngineID UInt16, - AdvEngineID UInt8, - PlaceID UInt16, - SocialSourceNetworkID UInt8, - Domain String, - SearchPhrase String, - SocialSourcePage String), - `Attendance` FixedString(16), - `CLID` UInt32, - `YCLID` UInt64, - `NormalizedRefererHash` UInt64, - `SearchPhraseHash` UInt64, - `RefererDomainHash` UInt64, - `NormalizedStartURLHash` UInt64, - `StartURLDomainHash` UInt64, - `NormalizedEndURLHash` UInt64, - `TopLevelDomain` UInt64, - `URLScheme` UInt64, - `OpenstatServiceNameHash` UInt64, - `OpenstatCampaignIDHash` UInt64, - `OpenstatAdIDHash` UInt64, - `OpenstatSourceIDHash` UInt64, - `UTMSourceHash` UInt64, - `UTMMediumHash` UInt64, - `UTMCampaignHash` UInt64, - `UTMContentHash` UInt64, - `UTMTermHash` UInt64, - `FromHash` UInt64, - `WebVisorEnabled` UInt8, - `WebVisorActivity` UInt32, - `ParsedParams` Nested( - Key1 String, - Key2 String, - Key3 String, - Key4 String, - Key5 String, - ValueDouble Float64), - `Market` Nested( - Type UInt8, - GoalID UInt32, - OrderID String, - OrderPrice Int64, - PP UInt32, - DirectPlaceID UInt32, - DirectOrderID UInt32, - DirectBannerID UInt32, - GoodID String, - GoodName String, - GoodQuantity Int32, - GoodPrice Int64), - `IslandID` FixedString(16) -) -ENGINE = CollapsingMergeTree(Sign) -PARTITION BY toYYYYMM(StartDate) -ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) -SAMPLE BY intHash32(UserID) -SETTINGS index_granularity = 8192 -``` - -Etkileşimli modunu kullanarak bu sorguları yürütebilirsiniz `clickhouse-client` (sadece önceden bir sorgu belirtmeden bir terminalde başlatın) veya bazı deneyin [alternatif arayüz](../interfaces/index.md) Eğer isterseniz. - -Gördüğümüz gibi, `hits_v1` kullanır [temel MergeTree motoru](../engines/table_engines/mergetree_family/mergetree.md), WH whileile the `visits_v1` kullanır [Çökme](../engines/table_engines/mergetree_family/collapsingmergetree.md) varyant. - -### Verileri İçe Aktar {#import-data} - -Clickhouse'a veri aktarımı yapılır [INSERT INTO](../sql_reference/statements/insert_into.md) diğer birçok SQL veritabanlarında olduğu gibi sorgu. Bununla birlikte, veriler genellikle [desteklenen seri hale getirme biçimleri](../interfaces/formats.md) yerine `VALUES` fıkra clausesı (ayrıca desteklenmektedir). - -Onları almak için ne kadar daha önce indirdiğimiz dosyaları sekme ayrılmış biçimde, yani burada konsol istemci ile : - -``` bash -clickhouse-client --query "INSERT INTO tutorial.hits_v1 FORMAT TSV" --max_insert_block_size=100000 < hits_v1.tsv -clickhouse-client --query "INSERT INTO tutorial.visits_v1 FORMAT TSV" --max_insert_block_size=100000 < visits_v1.tsv -``` - -ClickHouse bir yeri vardır [ayarlan settingsacak ayarlar](../operations/settings/index.md) ve bunları konsol istemcisinde belirtmenin bir yolu, görebildiğimiz gibi argümanlar aracılığıyla `--max_insert_block_size`. Hangi ayarların mevcut olduğunu, ne anlama geldiğini ve varsayılanların ne olduğunu anlamanın en kolay yolu `system.settings` Tablo: - -``` sql -SELECT name, value, changed, description -FROM system.settings -WHERE name LIKE '%max_insert_b%' -FORMAT TSV - -max_insert_block_size 1048576 0 "The maximum block size for insertion, if we control the creation of blocks for insertion." -``` - -İsteğe bağlı olarak şunları yapabilirsiniz [OPTIMIZE](../sql_reference/statements/misc.md#misc_operations-optimize) ithalattan sonra tablolar. MergeTree-family'den bir motorla yapılandırılmış tablolar, veri depolamayı en iyi duruma getirmek (veya en azından mantıklı olup olmadığını kontrol etmek) için her zaman arka planda veri parçalarının birleştirilmesini sağlar. Bu sorgular, tablo motorunu bir süre sonra yerine şu anda depolama optimizasyonu yapmaya zorlar: - -``` bash -clickhouse-client --query "OPTIMIZE TABLE tutorial.hits_v1 FINAL" -clickhouse-client --query "OPTIMIZE TABLE tutorial.visits_v1 FINAL" -``` - -Bu sorgular bir G/Ç ve CPU yoğun işlem başlatır, bu nedenle tablo sürekli olarak yeni veriler alırsa, onu yalnız bırakmak ve birleştirmelerin arka planda çalışmasına izin vermek daha iyidir. - -Şimdi tablo ithalatının başarılı olup olmadığını kontrol edebiliriz: - -``` bash -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.hits_v1" -clickhouse-client --query "SELECT COUNT(*) FROM tutorial.visits_v1" -``` - -## Örnek Sorgular {#example-queries} - -``` sql -SELECT - StartURL AS URL, - AVG(Duration) AS AvgDuration -FROM tutorial.visits_v1 -WHERE StartDate BETWEEN '2014-03-23' AND '2014-03-30' -GROUP BY URL -ORDER BY AvgDuration DESC -LIMIT 10 -``` - -``` sql -SELECT - sum(Sign) AS visits, - sumIf(Sign, has(Goals.ID, 1105530)) AS goal_visits, - (100. * goal_visits) / visits AS goal_percent -FROM tutorial.visits_v1 -WHERE (CounterID = 912887) AND (toYYYYMM(StartDate) = 201403) AND (domain(StartURL) = 'yandex.ru') -``` - -## Küme Dağıtımı {#cluster-deployment} - -ClickHouse kümesi homojen bir kümedir. Kurulum adımları: - -1. Kümenin tüm makinelerine ClickHouse Server'ı yükleyin -2. Yapılandırma dosyalarında küme yapılandırmalarını ayarlama -3. Her örnekte yerel tablolar oluşturun -4. Create a [Dağıtılmış tablo](../engines/table_engines/special/distributed.md) - -[Dağıtılmış tablo](../engines/table_engines/special/distributed.md) aslında bir tür “view” ClickHouse kümesinin yerel tablolarına. Dağıtılmış bir tablodan sorgu seçin, tüm kümenin parçalarının kaynaklarını kullanarak yürütür. Birden çok küme için yapılandırmalar belirtebilir ve farklı kümelere görünümler sağlayan birden çok dağıtılmış tablo oluşturabilirsiniz. - -Her biri bir kopya olan üç parçalı bir küme için örnek yapılandırma: - -``` xml - - - - - example-perftest01j.yandex.ru - 9000 - - - - - example-perftest02j.yandex.ru - 9000 - - - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -Daha fazla gösteri için, aynı ile yeni bir yerel tablo oluşturalım `CREATE TABLE` için kullandığımız sorgu `hits_v1` ama farklı bir tablo adı: - -``` sql -CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... -``` - -Kümenin yerel tablolarına bir görünüm sağlayan dağıtılmış bir tablo oluşturma: - -``` sql -CREATE TABLE tutorial.hits_all AS tutorial.hits_local -ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); -``` - -Yaygın bir uygulama, kümenin tüm makinelerinde benzer dağıtılmış tablolar oluşturmaktır. Kümenin herhangi bir makinesinde dağıtılmış sorguları çalıştırmaya izin verir. Ayrıca, belirli bir SELECT sorgusu için geçici dağıtılmış tablo oluşturmak için alternatif bir seçenek vardır [uzak](../sql_reference/table_functions/remote.md) tablo işlevi. - -Hadi koşalım [INSERT SELECT](../sql_reference/statements/insert_into.md) tabloyu birden çok sunucuya yaymak için dağıtılmış tabloya. - -``` sql -INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; -``` - -!!! warning "Bildirim" - Bu yaklaşım büyük tabloların parçalanması için uygun değildir. Ayrı bir araç var [clickhouse-fotokopi makinesi](../operations/utilities/clickhouse-copier.md) bu keyfi büyük tabloları yeniden parçalayabilir. - -Tahmin edebileceğiniz gibi, hesaplamalı olarak ağır sorgular, bir yerine 3 sunucu kullanıyorsa n kat daha hızlı çalışır. - -Bu durumda, 3 parçaya sahip bir küme kullandık ve her biri tek bir kopya içeriyor. - -Bir üretim ortamında esneklik sağlamak için, her bir parçanın birden çok kullanılabilirlik bölgesi veya veri merkezleri (veya en azından raflar) arasında yayılmış 2-3 kopya içermesi önerilir. ClickHouse yinelemeler sınırsız sayıda desteklediğini unutmayın. - -Üç yineleme içeren bir parça kümesi için örnek yapılandırma: - -``` xml - - ... - - - - example-perftest01j.yandex.ru - 9000 - - - example-perftest02j.yandex.ru - 9000 - - - example-perftest03j.yandex.ru - 9000 - - - - -``` - -Yerel çoğaltmayı etkinleştirmek için [ZooKeeper](http://zookeeper.apache.org/) gereklidir. ClickHouse tüm yinelemeler üzerinde veri tutarlılığı ilgilenir ve otomatik olarak hatadan sonra prosedürü geri çalışır. ZooKeeper kümesinin ayrı sunuculara dağıtılması önerilir(ClickHouse dahil başka hiçbir işlem çalışmaz). - -!!! note "Not" - ZooKeeper sıkı bir gereklilik değildir: bazı basit durumlarda, verileri uygulama kodunuzdan tüm kopyalara yazarak çoğaltabilirsiniz. Bu yaklaşım **değil** önerilen, bu durumda, ClickHouse tüm yinelemelerde veri tutarlılığını garanti edemez. Böylece başvurunuzun sorumluluğu haline gelir. - -Zookeeper konumları yapılandırma dosyasında belirtilir: - -``` xml - - - zoo01.yandex.ru - 2181 - - - zoo02.yandex.ru - 2181 - - - zoo03.yandex.ru - 2181 - - -``` - -Ayrıca, tablo oluşturulmasında kullanılan her bir parça ve kopyayı tanımlamak için makrolar ayarlamamız gerekir: - -``` xml - - 01 - 01 - -``` - -Yinelenmiş tablo oluşturma şu anda hiçbir yinelemeler varsa, yeni bir ilk yineleme örneği. Zaten canlı yinelemeler varsa, yeni yineleme varolan verileri klonlar. Önce tüm çoğaltılmış tablolar oluşturmak ve sonra veri eklemek için bir seçeneğiniz vardır. Başka bir seçenek, bazı yinelemeler oluşturmak ve veri ekleme sırasında veya sonrasında diğerlerini eklemektir. - -``` sql -CREATE TABLE tutorial.hits_replica (...) -ENGINE = ReplcatedMergeTree( - '/clickhouse_perftest/tables/{shard}/hits', - '{replica}' -) -... -``` - -Burada kullanıyoruz [ReplicatedMergeTree](../engines/table_engines/mergetree_family/replication.md) masa motoru. Parametrelerde, Shard ve çoğaltma tanımlayıcılarını içeren ZooKeeper yolunu belirtiyoruz. - -``` sql -INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; -``` - -Çoğaltma çok ana modda çalışır. Veriler herhangi bir kopyaya yüklenebilir ve sistem daha sonra otomatik olarak diğer örneklerle eşitler. Çoğaltma zaman uyumsuz olduğundan, belirli bir anda, tüm yinelemeler son eklenen verileri içerebilir. Veri alımına izin vermek için en az bir kopya olmalıdır. Diğerleri verileri senkronize eder ve tekrar aktif hale geldiklerinde tutarlılığı onarır. Bu yaklaşımın, yakın zamanda eklenen veri kaybı olasılığının düşük olmasına izin verdiğini unutmayın. - -[Orijinal makale](https://clickhouse.tech/docs/en/getting_started/tutorial/) diff --git a/docs/tr/guides/apply-catboost-model.md b/docs/tr/guides/apply-catboost-model.md new file mode 100644 index 00000000000..2a22c36ab32 --- /dev/null +++ b/docs/tr/guides/apply-catboost-model.md @@ -0,0 +1,239 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: CatBoost Modellerini Uygulamak +--- + +# Clickhouse'da bir Catboost modeli uygulamak {#applying-catboost-model-in-clickhouse} + +[CatBoost](https://catboost.ai) geliştirilen ücretsiz ve açık kaynak kodlu bir GRA anddi libraryent kütüphan aesidir. [Yandex](https://yandex.com/company/) makine öğrenimi için. + +Bu Talimatla, Sql'den model çıkarımı çalıştırarak Clickhouse'da önceden eğitilmiş modelleri uygulamayı öğreneceksiniz. + +Clickhouse'da bir CatBoost modeli uygulamak için: + +1. [Tablo oluşturma](#create-table). +2. [Verileri tabloya ekleme](#insert-data-to-table). +3. [Catboost'u Clickhouse'a entegre edin](#integrate-catboost-into-clickhouse) (İsteğe bağlı adım). +4. [SQL'DEN Model Çıkarımını çalıştırın](#run-model-inference). + +Eğitim CatBoost modelleri hakkında daha fazla bilgi için bkz [Eğitim ve uygulama modelleri](https://catboost.ai/docs/features/training.html#training). + +## Önkoşullar {#prerequisites} + +Eğer yoksa [Docker](https://docs.docker.com/install/) yine de yükleyin. + +!!! note "Not" + [Docker](https://www.docker.com) sistemin geri kalanından bir CatBoost ve ClickHouse kurulumunu izole eden kaplar oluşturmanıza olanak sağlayan bir yazılım platformudur. + +Bir CatBoost modeli uygulamadan önce: + +**1.** P pullull the [Docker görüntü](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) kayıt defter theinden: + +``` bash +$ docker pull yandex/tutorial-catboost-clickhouse +``` + +Kod, çalışma zamanı, kütüphaneler, ortam değişkenleri ve Yapılandırma Dosyaları: bu Docker görüntü catboost ve ClickHouse çalıştırmak için gereken her şeyi içerir. + +**2.** Docker görüntüsünün başarıyla çekildiğinden emin olun: + +``` bash +$ docker image ls +REPOSITORY TAG IMAGE ID CREATED SIZE +yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB +``` + +**3.** Bu görüntüye dayalı bir Docker kabı başlatın: + +``` bash +$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse +``` + +## 1. Tablo oluşturma {#create-table} + +Eğitim örneği için bir ClickHouse tablosu oluşturmak için: + +**1.** Etkileşimli modda ClickHouse konsol istemcisini başlatın: + +``` bash +$ clickhouse client +``` + +!!! note "Not" + Clickhouse sunucusu Docker kapsayıcısı içinde zaten çalışıyor. + +**2.** Komutu kullanarak tablo oluşturun: + +``` sql +:) CREATE TABLE amazon_train +( + date Date MATERIALIZED today(), + ACTION UInt8, + RESOURCE UInt32, + MGR_ID UInt32, + ROLE_ROLLUP_1 UInt32, + ROLE_ROLLUP_2 UInt32, + ROLE_DEPTNAME UInt32, + ROLE_TITLE UInt32, + ROLE_FAMILY_DESC UInt32, + ROLE_FAMILY UInt32, + ROLE_CODE UInt32 +) +ENGINE = MergeTree ORDER BY date +``` + +**3.** ClickHouse konsol istemcisinden çıkış: + +``` sql +:) exit +``` + +## 2. Verileri tabloya ekleme {#insert-data-to-table} + +Verileri eklemek için: + +**1.** Aşağıdaki komutu çalıştırın: + +``` bash +$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv +``` + +**2.** Etkileşimli modda ClickHouse konsol istemcisini başlatın: + +``` bash +$ clickhouse client +``` + +**3.** Verilerin yüklendiğinden emin olun: + +``` sql +:) SELECT count() FROM amazon_train + +SELECT count() +FROM amazon_train + ++-count()-+ +| 65538 | ++-------+ +``` + +## 3. Catboost'u Clickhouse'a entegre edin {#integrate-catboost-into-clickhouse} + +!!! note "Not" + **İsteğe bağlı adım.** Docker görüntü catboost ve ClickHouse çalıştırmak için gereken her şeyi içerir. + +Catboost'u Clickhouse'a entegre etmek için: + +**1.** Değerlendirme kitaplığı oluşturun. + +Bir CatBoost modelini değerlendirmenin en hızlı yolu derlemedir `libcatboostmodel.` kitaplık. Kitaplığın nasıl oluşturulacağı hakkında daha fazla bilgi için bkz. [CatBoost belgeleri](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). + +**2.** Herhangi bir yerde ve herhangi bir adla yeni bir dizin oluşturun, örneğin, `data` ve oluşturulan kütüphaneyi içine koyun. Docker görüntüsü zaten kütüphaneyi içeriyor `data/libcatboostmodel.so`. + +**3.** Yapılandırma modeli için herhangi bir yerde ve herhangi bir adla yeni bir dizin oluşturun, örneğin, `models`. + +**4.** Örneğin, herhangi bir ada sahip bir model yapılandırma dosyası oluşturun, `models/amazon_model.xml`. + +**5.** Model yapılandırmasını açıklayın: + +``` xml + + + + catboost + + amazon + + /home/catboost/tutorial/catboost_model.bin + + 0 + + +``` + +**6.** Catboost yolunu ve model yapılandırmasını ClickHouse yapılandırmasına ekleyin: + +``` xml + +/home/catboost/data/libcatboostmodel.so +/home/catboost/models/*_model.xml +``` + +## 4. SQL'DEN Model Çıkarımını çalıştırın {#run-model-inference} + +Test modeli için ClickHouse istemcisini çalıştırın `$ clickhouse client`. + +Modelin çalıştığından emin olalım: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) > 0 AS prediction, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Not" + İşlev [modelEvaluate](../sql-reference/functions/other-functions.md#function-modelevaluate) multiclass modelleri için sınıf başına ham tahminleri ile tuple döndürür. + +Olasılığı tahmin edelim: + +``` sql +:) SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1 + exp(-prediction)) AS probability, + ACTION AS target +FROM amazon_train +LIMIT 10 +``` + +!!! note "Not" + Hakkında daha fazla bilgi [exp()](../sql-reference/functions/math-functions.md) İşlev. + +Örnek üzerinde LogLoss hesaplayalım: + +``` sql +:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss +FROM +( + SELECT + modelEvaluate('amazon', + RESOURCE, + MGR_ID, + ROLE_ROLLUP_1, + ROLE_ROLLUP_2, + ROLE_DEPTNAME, + ROLE_TITLE, + ROLE_FAMILY_DESC, + ROLE_FAMILY, + ROLE_CODE) AS prediction, + 1. / (1. + exp(-prediction)) AS prob, + ACTION AS tg + FROM amazon_train +) +``` + +!!! note "Not" + Hakkında daha fazla bilgi [avg()](../sql-reference/aggregate-functions/reference.md#agg_function-avg) ve [günlük()](../sql-reference/functions/math-functions.md) işlevler. + +[Orijinal makale](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/tr/guides/apply_catboost_model.md b/docs/tr/guides/apply_catboost_model.md deleted file mode 100644 index 92bfac226f2..00000000000 --- a/docs/tr/guides/apply_catboost_model.md +++ /dev/null @@ -1,239 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 41 -toc_title: CatBoost Modellerini Uygulamak ---- - -# Clickhouse'da bir Catboost modeli uygulamak {#applying-catboost-model-in-clickhouse} - -[CatBoost](https://catboost.ai) geliştirilen ücretsiz ve açık kaynak kodlu bir GRA anddi libraryent kütüphan aesidir. [Yandex](https://yandex.com/company/) makine öğrenimi için. - -Bu Talimatla, Sql'den model çıkarımı çalıştırarak Clickhouse'da önceden eğitilmiş modelleri uygulamayı öğreneceksiniz. - -Clickhouse'da bir CatBoost modeli uygulamak için: - -1. [Tablo oluşturma](#create-table). -2. [Verileri tabloya ekleme](#insert-data-to-table). -3. [Catboost'u Clickhouse'a entegre edin](#integrate-catboost-into-clickhouse) (İsteğe bağlı adım). -4. [SQL'DEN Model Çıkarımını çalıştırın](#run-model-inference). - -Eğitim CatBoost modelleri hakkında daha fazla bilgi için bkz [Eğitim ve uygulama modelleri](https://catboost.ai/docs/features/training.html#training). - -## Önkoşullar {#prerequisites} - -Eğer yoksa [Docker](https://docs.docker.com/install/) yine de yükleyin. - -!!! note "Not" - [Docker](https://www.docker.com) sistemin geri kalanından bir CatBoost ve ClickHouse kurulumunu izole eden kaplar oluşturmanıza olanak sağlayan bir yazılım platformudur. - -Bir CatBoost modeli uygulamadan önce: - -**1.** P pullull the [Docker görüntü](https://hub.docker.com/r/yandex/tutorial-catboost-clickhouse) kayıt defter theinden: - -``` bash -$ docker pull yandex/tutorial-catboost-clickhouse -``` - -Kod, çalışma zamanı, kütüphaneler, ortam değişkenleri ve Yapılandırma Dosyaları: bu Docker görüntü catboost ve ClickHouse çalıştırmak için gereken her şeyi içerir. - -**2.** Docker görüntüsünün başarıyla çekildiğinden emin olun: - -``` bash -$ docker image ls -REPOSITORY TAG IMAGE ID CREATED SIZE -yandex/tutorial-catboost-clickhouse latest 622e4d17945b 22 hours ago 1.37GB -``` - -**3.** Bu görüntüye dayalı bir Docker kabı başlatın: - -``` bash -$ docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse -``` - -## 1. Tablo oluşturma {#create-table} - -Eğitim örneği için bir ClickHouse tablosu oluşturmak için: - -**1.** Etkileşimli modda ClickHouse konsol istemcisini başlatın: - -``` bash -$ clickhouse client -``` - -!!! note "Not" - Clickhouse sunucusu Docker kapsayıcısı içinde zaten çalışıyor. - -**2.** Komutu kullanarak tablo oluşturun: - -``` sql -:) CREATE TABLE amazon_train -( - date Date MATERIALIZED today(), - ACTION UInt8, - RESOURCE UInt32, - MGR_ID UInt32, - ROLE_ROLLUP_1 UInt32, - ROLE_ROLLUP_2 UInt32, - ROLE_DEPTNAME UInt32, - ROLE_TITLE UInt32, - ROLE_FAMILY_DESC UInt32, - ROLE_FAMILY UInt32, - ROLE_CODE UInt32 -) -ENGINE = MergeTree ORDER BY date -``` - -**3.** ClickHouse konsol istemcisinden çıkış: - -``` sql -:) exit -``` - -## 2. Verileri tabloya ekleme {#insert-data-to-table} - -Verileri eklemek için: - -**1.** Aşağıdaki komutu çalıştırın: - -``` bash -$ clickhouse client --host 127.0.0.1 --query 'INSERT INTO amazon_train FORMAT CSVWithNames' < ~/amazon/train.csv -``` - -**2.** Etkileşimli modda ClickHouse konsol istemcisini başlatın: - -``` bash -$ clickhouse client -``` - -**3.** Verilerin yüklendiğinden emin olun: - -``` sql -:) SELECT count() FROM amazon_train - -SELECT count() -FROM amazon_train - -+-count()-+ -| 65538 | -+-------+ -``` - -## 3. Catboost'u Clickhouse'a entegre edin {#integrate-catboost-into-clickhouse} - -!!! note "Not" - **İsteğe bağlı adım.** Docker görüntü catboost ve ClickHouse çalıştırmak için gereken her şeyi içerir. - -Catboost'u Clickhouse'a entegre etmek için: - -**1.** Değerlendirme kitaplığı oluşturun. - -Bir CatBoost modelini değerlendirmenin en hızlı yolu derlemedir `libcatboostmodel.` kitaplık. Kitaplığın nasıl oluşturulacağı hakkında daha fazla bilgi için bkz. [CatBoost belgeleri](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html). - -**2.** Herhangi bir yerde ve herhangi bir adla yeni bir dizin oluşturun, örneğin, `data` ve oluşturulan kütüphaneyi içine koyun. Docker görüntüsü zaten kütüphaneyi içeriyor `data/libcatboostmodel.so`. - -**3.** Yapılandırma modeli için herhangi bir yerde ve herhangi bir adla yeni bir dizin oluşturun, örneğin, `models`. - -**4.** Örneğin, herhangi bir ada sahip bir model yapılandırma dosyası oluşturun, `models/amazon_model.xml`. - -**5.** Model yapılandırmasını açıklayın: - -``` xml - - - - catboost - - amazon - - /home/catboost/tutorial/catboost_model.bin - - 0 - - -``` - -**6.** Catboost yolunu ve model yapılandırmasını ClickHouse yapılandırmasına ekleyin: - -``` xml - -/home/catboost/data/libcatboostmodel.so -/home/catboost/models/*_model.xml -``` - -## 4. SQL'DEN Model Çıkarımını çalıştırın {#run-model-inference} - -Test modeli için ClickHouse istemcisini çalıştırın `$ clickhouse client`. - -Modelin çalıştığından emin olalım: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) > 0 AS prediction, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Not" - İşlev [modelEvaluate](../sql_reference/functions/other_functions.md#function-modelevaluate) multiclass modelleri için sınıf başına ham tahminleri ile tuple döndürür. - -Olasılığı tahmin edelim: - -``` sql -:) SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1 + exp(-prediction)) AS probability, - ACTION AS target -FROM amazon_train -LIMIT 10 -``` - -!!! note "Not" - Hakkında daha fazla bilgi [exp()](../sql_reference/functions/math_functions.md) işlev. - -Örnek üzerinde LogLoss hesaplayalım: - -``` sql -:) SELECT -avg(tg * log(prob) + (1 - tg) * log(1 - prob)) AS logloss -FROM -( - SELECT - modelEvaluate('amazon', - RESOURCE, - MGR_ID, - ROLE_ROLLUP_1, - ROLE_ROLLUP_2, - ROLE_DEPTNAME, - ROLE_TITLE, - ROLE_FAMILY_DESC, - ROLE_FAMILY, - ROLE_CODE) AS prediction, - 1. / (1. + exp(-prediction)) AS prob, - ACTION AS tg - FROM amazon_train -) -``` - -!!! note "Not" - Hakkında daha fazla bilgi [avg()](../sql_reference/aggregate_functions/reference.md#agg_function-avg) ve [günlük()](../sql_reference/functions/math_functions.md) işlevler. - -[Orijinal makale](https://clickhouse.tech/docs/en/guides/apply_catboost_model/) diff --git a/docs/tr/guides/index.md b/docs/tr/guides/index.md index 95ad65443b0..194fd02712b 100644 --- a/docs/tr/guides/index.md +++ b/docs/tr/guides/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: "K\u0131lavuzlar" toc_priority: 38 toc_title: "Genel bak\u0131\u015F" @@ -10,7 +10,7 @@ toc_title: "Genel bak\u0131\u015F" ClickHouse kullanarak çeşitli görevleri çözmeye yardımcı olan ayrıntılı adım adım talimatların listesi: -- [Basit küme kurulumu eğitimi](../getting_started/tutorial.md) -- [Clickhouse'da bir CatBoost modeli uygulamak](apply_catboost_model.md) +- [Basit küme kurulumu eğitimi](../getting-started/tutorial.md) +- [Clickhouse'da bir CatBoost modeli uygulamak](apply-catboost-model.md) [Orijinal makale](https://clickhouse.tech/docs/en/guides/) diff --git a/docs/tr/index.md b/docs/tr/index.md index 5cbf9330750..9ac619a1f8d 100644 --- a/docs/tr/index.md +++ b/docs/tr/index.md @@ -3,32 +3,32 @@ toc_priority: 0 toc_title: "Genel bak\u0131\u015F" --- -# ClickHouse nedir? {#what-is-clickhouse} +# ClickHouse Nedir? {#what-is-clickhouse} ClickHouse, sorguların çevrimiçi analitik işlenmesi (*Online Analytical Processing* - OLAP) için sütun odaklı bir Veritabanı Yönetim Sistemidir (*DataBase Management System* - DBMS). “Normal” bir satır odaklı DBMS içinde veriler şu şekilde saklanır: -| Satır | WatchId | JavaEnable | Başlık | İyiOlay | OlayZamanı | -|-------|-------------|------------|----------------------|-----------|---------------------| -| \#0 | 89354350662 | 1 | Yatırımcı İlişkileri | 1 | 2016-05-18 05:19:20 | -| \#1 | 90329509958 | 0 | Bize ulaşın | 1 | 2016-05-18 08:10:20 | -| \#2 | 89953706054 | 1 | Görev | 1 | 2016-05-18 07:38:00 | -| \#N | … | … | … | … | … | +| Satır | WatchId | JavaEnable | Başlık | İyiOlay | OlayZamanı | +|-------|-------------|------------|----------------------|---------|---------------------| +| \#0 | 89354350662 | 1 | Yatırımcı İlişkileri | 1 | 2016-05-18 05:19:20 | +| \#1 | 90329509958 | 0 | Bize ulaşın | 1 | 2016-05-18 08:10:20 | +| \#2 | 89953706054 | 1 | Görev | 1 | 2016-05-18 07:38:00 | +| \#N | … | … | … | … | … | Başka bir deyişle, bir satırla ilgili tüm değerler fiziksel olarak yan yana depolanır. MySQL, Postgres ve MS SQL Server gibi veritabanları satır odaklı DBMS örnekleridir. -Sütun odaklı bir DBMS'de ise veriler şu şekilde saklanır: +Sütun odaklı bir DBMS’de ise veriler şu şekilde saklanır: | Satır: | \#0 | \#1 | \#2 | \#N | |-------------|----------------------|---------------------|---------------------|-----| | WatchId: | 89354350662 | 90329509958 | 89953706054 | … | | JavaEnable: | 1 | 0 | 1 | … | | Başlık: | Yatırımcı İlişkileri | Bize ulaşın | Görev | … | -| İyiOlay: | 1 | 1 | 1 | … | -| OlayZamanı: | 2016-05-18 05:19:20 | 2016-05-18 08:10:20 | 2016-05-18 07:38:00 | … | +| İyiOlay: | 1 | 1 | 1 | … | +| OlayZamanı: | 2016-05-18 05:19:20 | 2016-05-18 08:10:20 | 2016-05-18 07:38:00 | … | Bu örnekler yalnızca verilerin düzenlendiği sırayı gösterir. Farklı sütunlardaki değerler ayrı olarak depolanır ve aynı sütundaki veriler birlikte depolanır. @@ -38,13 +38,13 @@ Verinin farklı bir şekilde sıralanarak depolanması, bazı veri erişim senar Sistem üzerindeki yük ne kadar fazlaysa, sistem ayarlarının kullanım senaryolarına uyarlanması ve bu ayarların ne kadar hassas olduğu da o kadar önemli hale gelir. Birbirinden büyük ölçüde farklı olan veri erişim senaryolarına tam uyum sağlayan, yani her işe ve yüke gelen bir sistem yoktur. Eğer bir sistem yük altında her türlü veri erişim senaryosuna adapte olabiliyorsa, o halde böyle bir sistem ya tüm senaryolara ya da senaryoların bir veya birkaçına karşı zayıp bir performans gösterir. -## OLAP senaryosunun temel özellikleri {#key-properties-of-olap-scenario} +## OLAP Senaryosunun Temel özellikleri {#key-properties-of-olap-scenario} - İsteklerin büyük çoğunluğu, okuma erişimi içindir. - Veriler, tek satırlarla değil, oldukça büyük gruplar halinde (\> 1000 satır) güncellenir; veya hiç güncellenmez. - Veri, veritabanına eklenir, ancak değiştirilmez. - Bazı sorgular için veritabanından den oldukça fazla sayıda satır çekilir, ancak sonuç sadece birkaç satır ve sütunludur. -- Tablolar "geniştir", yani bir tabloda çok sayıda kolon vardır(onlarca). +- Tablolar “geniştir”, yani bir tabloda çok sayıda kolon vardır(onlarca). - Sorgular sıkılığı diğer senaryolara göre daha azdır (genellikle sunucu başına saniyede 100 veya daha az sorgu gelir). - Basit sorgular için, 50 ms civarında gecikmelere izin verilir. - Saklanan veriler oldukça küçüktür: genelde sadece sayılar ve kısa metinler içerir(örneğin, URL başına 60 bayt). @@ -52,27 +52,27 @@ Sistem üzerindeki yük ne kadar fazlaysa, sistem ayarlarının kullanım senary - Veri değiş-tokuşu(transaction) gerekli değildir. - Veri tutarlılığı o kadar da önemli değildir. - Genelde bir tane çok büyük tablo vardır, gerisi küçük tablolardan oluşur -- Bir sorgu sonucu elde edilen veri, okuanan veri miktarından oldukça küçüktür. Başka bir deyişle, milyarlarca satır içinden veriler süzgeçlenerek veya birleştirilerek elde edilen verilerin tek bir sunucunun RAM'ine sığar. +- Bir sorgu sonucu elde edilen veri, okuanan veri miktarından oldukça küçüktür. Başka bir deyişle, milyarlarca satır içinden veriler süzgeçlenerek veya birleştirilerek elde edilen verilerin tek bir sunucunun RAM’ine sığar. OLAP senaryosunun diğer popüler senaryolardan (*Online Transactional Processing* - OLTP veya *Key-Value* veritabanı) çok farklı olduğu açıkça görülebilir. Bu nedenle, iyi bir performans elde etmek istiyorsanız, analitik sorguları işlemek için OLTP veya *Key-Value* veritabanlarını kullanmak pek mantıklı olmaz. Örneğin, analitik için MongoDB veya Redis kullanmaya çalışırsanız, OLAP veritabanlarına kıyasla çok düşük performans elde edersiniz. -## Sütun yönelimli veritabanları OLAP senaryosunda neden daha iyi çalışır {#why-column-oriented-databases-work-better-in-the-olap-scenario} +## Sütun yönelimli veritabanları OLAP Senaryosunda Neden Daha Iyi çalışır {#why-column-oriented-databases-work-better-in-the-olap-scenario} Sütun yönelimli veritabanları OLAP senaryolarına daha uygundur: hatta o kadar ki, çoğu sorgunun işlenmesi en az 100 kat daha hızlıdır. Her ne kadar OLAP veritabanlarının neden bu kadar hızlı olduğuna dair nedenler aşağıda ayrıntılı verilmiş olsa da görseller üzerinden anlatmak daha kolay olacakttır: **Satır yönelimli DBMS** -![Row-oriented](images/row_oriented.gif#) +![Row-oriented](images/row-oriented.gif#) **Sütun yönelimli DBMS** -![Column-oriented](images/column_oriented.gif#) +![Column-oriented](images/column-oriented.gif#) Farkı görüyor musunuz? ### Giriş/çıkış {#inputoutput} -1. Analitik bir sorgu için, yalnızca az sayıda tablo sütununun okunması gerekir. Sütun yönelimli bir veritabanında, yalnızca ihtiyacınız olan verileri okuyabilirsiniz. Örneğin, 100 üzerinden 5 sütun gerekiyorsa, g/Ç'de 20 kat azalma bekleyebilirsiniz. +1. Analitik bir sorgu için, yalnızca az sayıda tablo sütununun okunması gerekir. Sütun yönelimli bir veritabanında, yalnızca ihtiyacınız olan verileri okuyabilirsiniz. Örneğin, 100 üzerinden 5 sütun gerekiyorsa, g/Ç’de 20 kat azalma bekleyebilirsiniz. 2. Veri paketler halinde okunduğundan, sıkıştırılması daha kolaydır. Sütunlardaki verilerin sıkıştırılması da daha kolaydır. Bu, G/Ç hacmini daha da azaltır. 3. Azaltılmış G/Ç nedeniyle, sistem önbelleğine daha fazla veri sığar. @@ -80,7 +80,7 @@ Farkı görüyor musunuz? ### CPU {#cpu} -Bir sorguyu yürütmek çok sayıda satırı işlemeyi gerektirdiğinden, ayrı satırlar yerine tüm vektörler için tüm işlemlerin gönderilmesine veya sorgu motorunun neredeyse hiç gönderim maliyeti olmaması için uygulanmasına yardımcı olur. Bunu yapmazsanız, yarı iyi bir disk alt sistemi ile, sorgu yorumlayıcısı kaçınılmaz olarak CPU'yu durdurur. Hem verileri sütunlarda depolamak hem de mümkün olduğunda sütunlarla işlemek mantıklıdır. +Bir sorguyu yürütmek çok sayıda satırı işlemeyi gerektirdiğinden, ayrı satırlar yerine tüm vektörler için tüm işlemlerin gönderilmesine veya sorgu motorunun neredeyse hiç gönderim maliyeti olmaması için uygulanmasına yardımcı olur. Bunu yapmazsanız, yarı iyi bir disk alt sistemi ile, sorgu yorumlayıcısı kaçınılmaz olarak CPU’yu durdurur. Hem verileri sütunlarda depolamak hem de mümkün olduğunda sütunlarla işlemek mantıklıdır. Bunu yapmanın iki yolu vardır: @@ -88,7 +88,7 @@ Bunu yapmanın iki yolu vardır: 2. Kod üretimi. Sorgu için oluşturulan kod, içindeki tüm dolaylı çağrılara sahiptir. -Bu yapılmaz “normal” veritabanları, çünkü basit sorguları çalıştırırken mantıklı değil. Ancak, istisnalar vardır. Örneğin, MemSQL SQL sorgularını işlerken gecikmeyi azaltmak için kod oluşturma kullanır. (Karşılaştırma için, analitik Dbms'ler gecikme değil, verim optimizasyonunu gerektirir .) +Bu yapılmaz “normal” veritabanları, çünkü basit sorguları çalıştırırken mantıklı değil. Ancak, istisnalar vardır. Örneğin, MemSQL SQL sorgularını işlerken gecikmeyi azaltmak için kod oluşturma kullanır. (Karşılaştırma için, analitik Dbms’ler gecikme değil, verim optimizasyonunu gerektirir .) CPU verimliliği için sorgu dilinin bildirimsel (SQL veya MDX) veya en az bir vektör (J, K) olması gerektiğini unutmayın. Sorgu yalnızca en iyi duruma getirme için izin veren örtük döngüler içermelidir. diff --git a/docs/tr/interfaces/cli.md b/docs/tr/interfaces/cli.md index c526105dfe7..de62b3003af 100644 --- a/docs/tr/interfaces/cli.md +++ b/docs/tr/interfaces/cli.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 17 toc_title: "Komut Sat\u0131r\u0131 \u0130stemcisi" --- @@ -9,7 +9,7 @@ toc_title: "Komut Sat\u0131r\u0131 \u0130stemcisi" ClickHouse yerel bir komut satırı istemcisi sağlar: `clickhouse-client`. İstemci komut satırı seçeneklerini ve yapılandırma dosyalarını destekler. Daha fazla bilgi için, bkz. [Yapılandırma](#interfaces_cli_configuration). -[Yüklemek](../getting_started/index.md) ıt from the `clickhouse-client` paketleyin ve komutla çalıştırın `clickhouse-client`. +[Yüklemek](../getting-started/index.md) ıt from the `clickhouse-client` paketleyin ve komutla çalıştırın `clickhouse-client`. ``` bash $ clickhouse-client @@ -89,7 +89,7 @@ Bir sorguyu her zamanki gibi biçimlendirin, ardından uygulama parametrelerinde ``` - `name` — Placeholder identifier. In the console client it should be used in app parameters as `--param_ = value`. -- `data type` — [Veri türü](../sql_reference/data_types/index.md) app parametre değeri. Örneğin, aşağıdaki gibi bir veri yapısı `(integer, ('string', integer))` olabilir var `Tuple(UInt8, Tuple(String, UInt8))` veri türü (başka birini de kullanabilirsiniz [tamsayı](../sql_reference/data_types/int_uint.md) türler). +- `data type` — [Veri türü](../sql-reference/data-types/index.md) app parametre değeri. Örneğin, aşağıdaki gibi bir veri yapısı `(integer, ('string', integer))` olabilir var `Tuple(UInt8, Tuple(String, UInt8))` veri türü (başka birini de kullanabilirsiniz [tamsayı](../sql-reference/data-types/int-uint.md) türler). #### Örnek {#example} diff --git a/docs/tr/interfaces/cpp.md b/docs/tr/interfaces/cpp.md index 9ebf93286ff..f5c2227aba6 100644 --- a/docs/tr/interfaces/cpp.md +++ b/docs/tr/interfaces/cpp.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 24 toc_title: "C++ \u0130stemci Kitapl\u0131\u011F\u0131" --- diff --git a/docs/tr/interfaces/formats.md b/docs/tr/interfaces/formats.md index f522d697aa1..e031782d356 100644 --- a/docs/tr/interfaces/formats.md +++ b/docs/tr/interfaces/formats.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 21 toc_title: "Giri\u015F ve \xE7\u0131k\u0131\u015F bi\xE7imleri" --- @@ -42,7 +42,7 @@ Desteklenen formatlar şunlardır: | [ORC](#data-format-orc) | ✔ | ✗ | | [RowBinary](#rowbinary) | ✔ | ✔ | | [Rowbinarywithnames ve türleri](#rowbinarywithnamesandtypes) | ✔ | ✔ | -| [Yerel](#native) | ✔ | ✔ | +| [Yerli](#native) | ✔ | ✔ | | [Boş](#null) | ✗ | ✔ | | [XML](#xml) | ✗ | ✔ | | [CapnProto](#capnproto) | ✔ | ✗ | @@ -110,9 +110,9 @@ Sadece küçük bir sembol seti kaçtı. Terminalinizin çıktıda mahvedeceği Diziler köşeli parantez içinde virgülle ayrılmış değerlerin bir listesi olarak yazılır. Dizideki sayı öğeleri normal olarak biçimlendirilir. `Date` ve `DateTime` türleri tek tırnak yazılır. Diz .eler yukarıdaki gibi aynı kural quoteslarla tek tırnak içinde yazılır. -[NULL](../sql_reference/syntax.md) olarak format islanır `\N`. +[NULL](../sql-reference/syntax.md) olarak format islanır `\N`. -Her eleman [İçiçe](../sql_reference/data_types/nested_data_structures/nested.md) yapılar dizi olarak temsil edilir. +Her eleman [İçiçe](../sql-reference/data-types/nested-data-structures/nested.md) yapılar dizi olarak temsil edilir. Mesela: @@ -332,7 +332,7 @@ SearchPhrase=curtain designs count()=1064 SearchPhrase=baku count()=1000 ``` -[NULL](../sql_reference/syntax.md) olarak format islanır `\N`. +[NULL](../sql-reference/syntax.md) olarak format islanır `\N`. ``` sql SELECT * FROM t_null FORMAT TSKV @@ -464,7 +464,7 @@ Sorgu GROUP BY içeriyorsa, ROWS\_BEFORE\_LİMİT\_AT\_LEAST SINIRSIZDI olurdu s Bu biçim yalnızca bir sorgu sonucu çıktısı için uygundur, ancak ayrıştırma için değil (bir tabloya eklemek için veri alma). -ClickHouse destekler [NULL](../sql_reference/syntax.md) olarak görüntülenen `null` JSON çıkışında. +ClickHouse destekler [NULL](../sql-reference/syntax.md) olarak görüntülenen `null` JSON çıkışında. Ayrıca bakınız [JSONEachRow](#jsoneachrow) biçimli. @@ -541,7 +541,7 @@ ClickHouse, nesnelerden sonra öğeler ve virgüller arasındaki boşlukları yo **İhmal edilen değerler işleme** -ClickHouse, karşılık gelen değerler için varsayılan değerlerle atlanmış değerleri değiştirir [veri türleri](../sql_reference/data_types/index.md). +ClickHouse, karşılık gelen değerler için varsayılan değerlerle atlanmış değerleri değiştirir [veri türleri](../sql-reference/data-types/index.md). Eğer `DEFAULT expr` belirtilen, ClickHouse bağlı olarak farklı ikame kuralları kullanır [ınput\_format\_defaults\_for\_omitted\_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields) ayar. @@ -586,7 +586,7 @@ Aksine [JSON](#json) biçimi, geçersiz UTF-8 dizilerinin hiçbir ikame yoktur. ### İç içe yapıların kullanımı {#jsoneachrow-nested} -İle bir tablo varsa [İçiçe](../sql_reference/data_types/nested_data_structures/nested.md) veri türü sütunları, aynı yapıya sahip json verilerini ekleyebilirsiniz. İle bu özelliği etkinleştirin [ınput\_format\_ımport\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) ayar. +İle bir tablo varsa [İçiçe](../sql-reference/data-types/nested-data-structures/nested.md) veri türü sütunları, aynı yapıya sahip json verilerini ekleyebilirsiniz. İle bu özelliği etkinleştirin [ınput\_format\_ımport\_nested\_json](../operations/settings/settings.md#settings-input_format_import_nested_json) ayar. Örneğin, aşağıdaki tabloyu göz önünde bulundurun: @@ -643,7 +643,7 @@ SELECT * FROM json_each_row_nested └───────────────┴────────┘ ``` -## Yerel {#native} +## Yerli {#native} En verimli biçim. Veriler ikili formatta bloklar tarafından yazılır ve okunur. Her blok için satır sayısı, sütun sayısı, sütun adları ve türleri ve bu bloktaki sütunların parçaları birbiri ardına kaydedilir. Başka bir deyişle, bu format “columnar” – it doesn't convert columns to rows. This is the format used in the native interface for interaction between servers, for using the command-line client, and for C++ clients. @@ -660,7 +660,7 @@ Verileri Unicode-art tabloları olarak çıkarır, ayrıca TERMİNALDEKİ renkle Tablonun tam bir ızgarası çizilir ve her satır terminalde iki satır kaplar. Her sonuç bloğu ayrı bir tablo olarak çıktı. Bu, blokların arabelleğe alma sonuçları olmadan çıkabilmesi için gereklidir (tüm değerlerin görünür genişliğini önceden hesaplamak için arabelleğe alma gerekli olacaktır). -[NULL](../sql_reference/syntax.md) olarak çıktı `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) olarak çıktı `ᴺᵁᴸᴸ`. Örnek (gösterilen [PrettyCompact](#prettycompact) biçimli): @@ -764,7 +764,7 @@ FixedString sadece bir bayt dizisi olarak temsil edilir. Dizi varint uzunluğu (imzasız) olarak temsil edilir [LEB128](https://en.wikipedia.org/wiki/LEB128)), ardından dizinin ardışık elemanları. -İçin [NULL](../sql_reference/syntax.md#null-literal) destek, 1 veya 0 içeren ek bir bayt her önce eklenir [Nullable](../sql_reference/data_types/nullable.md) değer. 1 ise, o zaman değer `NULL` ve bu bayt ayrı bir değer olarak yorumlanır. 0 ise, bayttan sonraki değer değil `NULL`. +İçin [NULL](../sql-reference/syntax.md#null-literal) destek, 1 veya 0 içeren ek bir bayt her önce eklenir [Nullable](../sql-reference/data-types/nullable.md) değer. 1 ise, o zaman değer `NULL` ve bu bayt ayrı bir değer olarak yorumlanır. 0 ise, bayttan sonraki değer değil `NULL`. ## Rowbinarywithnames ve türleri {#rowbinarywithnamesandtypes} @@ -776,7 +776,7 @@ Benzer [RowBinary](#rowbinary), ancak eklenen Başlık ile: ## Değerler {#data-format-values} -Her satırı parantez içinde yazdırır. Satırlar virgülle ayrılır. Son satırdan sonra virgül yok. Parantez içindeki değerler de virgülle ayrılır. Sayılar tırnak işaretleri olmadan ondalık biçimde çıktıdır. Diziler köşeli parantez içinde çıktı. Kat tırnak içinde çıkış dizelerle, tarihleri ve tarihleri. Kaçan kurallar ve ayrıştırma benzer [TabSeparated](#tabseparated) biçimli. Biçimlendirme sırasında fazladan boşluk eklenmez, ancak ayrıştırma sırasında izin verilir ve atlanır (izin verilmeyen dizi değerleri içindeki boşluklar hariç). [NULL](../sql_reference/syntax.md) olarak temsil edilir `NULL`. +Her satırı parantez içinde yazdırır. Satırlar virgülle ayrılır. Son satırdan sonra virgül yok. Parantez içindeki değerler de virgülle ayrılır. Sayılar tırnak işaretleri olmadan ondalık biçimde çıktıdır. Diziler köşeli parantez içinde çıktı. Kat tırnak içinde çıkış dizelerle, tarihleri ve tarihleri. Kaçan kurallar ve ayrıştırma benzer [TabSeparated](#tabseparated) biçimli. Biçimlendirme sırasında fazladan boşluk eklenmez, ancak ayrıştırma sırasında izin verilir ve atlanır (izin verilmeyen dizi değerleri içindeki boşluklar hariç). [NULL](../sql-reference/syntax.md) olarak temsil edilir `NULL`. The minimum set of characters that you need to escape when passing data in Values ​​format: single quotes and backslashes. @@ -788,7 +788,7 @@ Ayrıca bakınız: [ınput\_format\_values\_interpret\_expressions](../operation Her değeri belirtilen sütun adıyla ayrı bir satıra yazdırır. Bu biçim, her satır çok sayıda sütundan oluşuyorsa, yalnızca bir veya birkaç satır yazdırmak için uygundur. -[NULL](../sql_reference/syntax.md) olarak çıktı `ᴺᵁᴸᴸ`. +[NULL](../sql-reference/syntax.md) olarak çıktı `ᴺᵁᴸᴸ`. Örnek: @@ -967,7 +967,7 @@ message MessageType { ``` ClickHouse adlı bir sütun bulmaya çalışır `x.y.z` (veya `x_y_z` veya `X.y_Z` ve benzeri). -İç içe mesajlar giriş veya çıkış a için uygundur [iç içe veri yapıları](../sql_reference/data_types/nested_data_structures/nested.md). +İç içe mesajlar giriş veya çıkış a için uygundur [iç içe veri yapıları](../sql-reference/data-types/nested-data-structures/nested.md). Böyle bir protobuf şemasında tanımlanan varsayılan değerler @@ -979,7 +979,7 @@ message MessageType { } ``` -uygulan ;mamaktadır; [tablo varsayılanları](../sql_reference/statements/create.md#create-default-values) bunların yerine kullanılır. +uygulan ;mamaktadır; [tablo varsayılanları](../sql-reference/statements/create.md#create-default-values) bunların yerine kullanılır. ClickHouse girişleri ve çıkışları protobuf mesajları `length-delimited` biçimli. Bu, her mesajın uzunluğunu bir olarak yazmadan önce anlamına gelir [varint](https://developers.google.com/protocol-buffers/docs/encoding#varints). @@ -993,23 +993,23 @@ ClickHouse Avro biçimi okuma ve yazma destekler [Avro veri dosyaları](http://a ### Veri Türleri Eşleştirme {#data_types-matching} -Aşağıdaki tablo, desteklenen veri türlerini ve Clickhouse'la nasıl eşleştiğini gösterir [veri türleri](../sql_reference/data_types/index.md) içinde `INSERT` ve `SELECT` sorgular. +Aşağıdaki tablo, desteklenen veri türlerini ve Clickhouse'la nasıl eşleştiğini gösterir [veri türleri](../sql-reference/data-types/index.md) içinde `INSERT` ve `SELECT` sorgular. | Avro veri türü `INSERT` | ClickHouse veri türü | Avro veri türü `SELECT` | |---------------------------------------------|-------------------------------------------------------------------------------------------------------------------|------------------------------| -| `boolean`, `int`, `long`, `float`, `double` | [Int(8/16/32)](../sql_reference/data_types/int_uint.md), [Uİnt(8/16/32)](../sql_reference/data_types/int_uint.md) | `int` | -| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql_reference/data_types/int_uint.md), [Uİnt64](../sql_reference/data_types/int_uint.md) | `long` | -| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql_reference/data_types/float.md) | `float` | -| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql_reference/data_types/float.md) | `double` | -| `bytes`, `string`, `fixed`, `enum` | [Dize](../sql_reference/data_types/string.md) | `bytes` | -| `bytes`, `string`, `fixed` | [FixedString(N)](../sql_reference/data_types/fixedstring.md) | `fixed(N)` | -| `enum` | [Enum (8/16)](../sql_reference/data_types/enum.md) | `enum` | -| `array(T)` | [Dizi(T)](../sql_reference/data_types/array.md) | `array(T)` | -| `union(null, T)`, `union(T, null)` | [Null (T)](../sql_reference/data_types/date.md) | `union(null, T)` | -| `null` | [Null (Hiçbir Şey)](../sql_reference/data_types/special_data_types/nothing.md) | `null` | -| `int (date)` \* | [Tarihli](../sql_reference/data_types/date.md) | `int (date)` \* | -| `long (timestamp-millis)` \* | [DateTime64 (3)](../sql_reference/data_types/datetime.md) | `long (timestamp-millis)` \* | -| `long (timestamp-micros)` \* | [DateTime64 (6)](../sql_reference/data_types/datetime.md) | `long (timestamp-micros)` \* | +| `boolean`, `int`, `long`, `float`, `double` | [Int(8/16/32)](../sql-reference/data-types/int-uint.md), [Uİnt(8/16/32)](../sql-reference/data-types/int-uint.md) | `int` | +| `boolean`, `int`, `long`, `float`, `double` | [Int64](../sql-reference/data-types/int-uint.md), [Uİnt64](../sql-reference/data-types/int-uint.md) | `long` | +| `boolean`, `int`, `long`, `float`, `double` | [Float32](../sql-reference/data-types/float.md) | `float` | +| `boolean`, `int`, `long`, `float`, `double` | [Float64](../sql-reference/data-types/float.md) | `double` | +| `bytes`, `string`, `fixed`, `enum` | [Dize](../sql-reference/data-types/string.md) | `bytes` | +| `bytes`, `string`, `fixed` | [FixedString(N)](../sql-reference/data-types/fixedstring.md) | `fixed(N)` | +| `enum` | [Enum (8/16)](../sql-reference/data-types/enum.md) | `enum` | +| `array(T)` | [Dizi(T)](../sql-reference/data-types/array.md) | `array(T)` | +| `union(null, T)`, `union(T, null)` | [Null (T)](../sql-reference/data-types/date.md) | `union(null, T)` | +| `null` | [Null (Hiçbir Şey)](../sql-reference/data-types/special-data-types/nothing.md) | `null` | +| `int (date)` \* | [Tarihli](../sql-reference/data-types/date.md) | `int (date)` \* | +| `long (timestamp-millis)` \* | [DateTime64 (3)](../sql-reference/data-types/datetime.md) | `long (timestamp-millis)` \* | +| `long (timestamp-micros)` \* | [DateTime64 (6)](../sql-reference/data-types/datetime.md) | `long (timestamp-micros)` \* | \* [Avro mantıksal türleri](http://avro.apache.org/docs/current/spec.html#Logical+Types) @@ -1030,7 +1030,7 @@ Giriş Avro dosyasının kök şeması olmalıdır `record` tür. ClickHouse tablo sütunları ve Avro şema alanları arasındaki yazışmaları bulmak için adlarını karşılaştırır. Bu karşılaştırma büyük / küçük harf duyarlıdır. Kullanılmayan alanlar atlanır. -ClickHouse tablo sütunlarının veri türleri, eklenen Avro verilerinin karşılık gelen alanlarından farklı olabilir. Veri eklerken, ClickHouse veri türlerini yukarıdaki tabloya göre yorumlar ve sonra [döküm](../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) karşılık gelen sütun türüne veri. +ClickHouse tablo sütunlarının veri türleri, eklenen Avro verilerinin karşılık gelen alanlarından farklı olabilir. Veri eklerken, ClickHouse veri türlerini yukarıdaki tabloya göre yorumlar ve sonra [döküm](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) karşılık gelen sütun türüne veri. ### Veri Seçme {#selecting-data-1} @@ -1072,7 +1072,7 @@ $ kafkacat -b kafka-broker -C -t topic1 -o beginning -f '%s' -c 3 | clickhouse- 3 c ``` -Kullanmak `AvroConfluent` ile [Kafka](../engines/table_engines/integrations/kafka.md): +Kullanmak `AvroConfluent` ile [Kafka](../engines/table-engines/integrations/kafka.md): ``` sql CREATE TABLE topic1_stream @@ -1101,25 +1101,25 @@ SELECT * FROM topic1_stream; ### Veri Türleri Eşleştirme {#data_types-matching-2} -Aşağıdaki tablo, desteklenen veri türlerini ve Clickhouse'la nasıl eşleştiğini gösterir [veri türleri](../sql_reference/data_types/index.md) içinde `INSERT` ve `SELECT` sorgular. +Aşağıdaki tablo, desteklenen veri türlerini ve Clickhouse'la nasıl eşleştiğini gösterir [veri türleri](../sql-reference/data-types/index.md) içinde `INSERT` ve `SELECT` sorgular. | Parke veri türü (`INSERT`) | ClickHouse veri türü | Parke veri türü (`SELECT`) | |----------------------------|-----------------------------------------------------------|----------------------------| -| `UINT8`, `BOOL` | [Uİnt8](../sql_reference/data_types/int_uint.md) | `UINT8` | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | `INT8` | -| `UINT16` | [Uınt16](../sql_reference/data_types/int_uint.md) | `UINT16` | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | `INT16` | -| `UINT32` | [Uİnt32](../sql_reference/data_types/int_uint.md) | `UINT32` | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | `INT32` | -| `UINT64` | [Uİnt64](../sql_reference/data_types/int_uint.md) | `UINT64` | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | `INT64` | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | `FLOAT` | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | `DOUBLE` | -| `DATE32` | [Tarihli](../sql_reference/data_types/date.md) | `UINT16` | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | `UINT32` | -| `STRING`, `BINARY` | [Dize](../sql_reference/data_types/string.md) | `STRING` | -| — | [FixedString](../sql_reference/data_types/fixedstring.md) | `STRING` | -| `DECIMAL` | [Ondalık](../sql_reference/data_types/decimal.md) | `DECIMAL` | +| `UINT8`, `BOOL` | [Uİnt8](../sql-reference/data-types/int-uint.md) | `UINT8` | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | `INT8` | +| `UINT16` | [Uınt16](../sql-reference/data-types/int-uint.md) | `UINT16` | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | `INT16` | +| `UINT32` | [Uİnt32](../sql-reference/data-types/int-uint.md) | `UINT32` | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | `INT32` | +| `UINT64` | [Uİnt64](../sql-reference/data-types/int-uint.md) | `UINT64` | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | `INT64` | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | `FLOAT` | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | `DOUBLE` | +| `DATE32` | [Tarihli](../sql-reference/data-types/date.md) | `UINT16` | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | `UINT32` | +| `STRING`, `BINARY` | [Dize](../sql-reference/data-types/string.md) | `STRING` | +| — | [FixedString](../sql-reference/data-types/fixedstring.md) | `STRING` | +| `DECIMAL` | [Ondalık](../sql-reference/data-types/decimal.md) | `DECIMAL` | ClickHouse yapılandırılabilir hassas destekler `Decimal` tür. Bu `INSERT` sorgu parke davranır `DECIMAL` ClickHouse olarak yazın `Decimal128` tür. @@ -1141,7 +1141,7 @@ Bir ClickHouse tablosundan veri seçin ve aşağıdaki komutla parke formatında $ clickhouse-client --query="SELECT * FROM {some_table} FORMAT Parquet" > {some_file.pq} ``` -Hadoop ile veri alışverişi yapmak için şunları kullanabilirsiniz [HDFS tablo motoru](../engines/table_engines/integrations/hdfs.md). +Hadoop ile veri alışverişi yapmak için şunları kullanabilirsiniz [HDFS tablo motoru](../engines/table-engines/integrations/hdfs.md). ## ORC {#data-format-orc} @@ -1149,30 +1149,30 @@ Hadoop ile veri alışverişi yapmak için şunları kullanabilirsiniz [HDFS tab ### Veri Türleri Eşleştirme {#data_types-matching-3} -Aşağıdaki tablo, desteklenen veri türlerini ve Clickhouse'la nasıl eşleştiğini gösterir [veri türleri](../sql_reference/data_types/index.md) içinde `INSERT` sorgular. +Aşağıdaki tablo, desteklenen veri türlerini ve Clickhouse'la nasıl eşleştiğini gösterir [veri türleri](../sql-reference/data-types/index.md) içinde `INSERT` sorgular. | Orc veri türü (`INSERT`) | ClickHouse veri türü | |--------------------------|-----------------------------------------------------| -| `UINT8`, `BOOL` | [Uİnt8](../sql_reference/data_types/int_uint.md) | -| `INT8` | [Int8](../sql_reference/data_types/int_uint.md) | -| `UINT16` | [Uınt16](../sql_reference/data_types/int_uint.md) | -| `INT16` | [Int16](../sql_reference/data_types/int_uint.md) | -| `UINT32` | [Uİnt32](../sql_reference/data_types/int_uint.md) | -| `INT32` | [Int32](../sql_reference/data_types/int_uint.md) | -| `UINT64` | [Uİnt64](../sql_reference/data_types/int_uint.md) | -| `INT64` | [Int64](../sql_reference/data_types/int_uint.md) | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql_reference/data_types/float.md) | -| `DOUBLE` | [Float64](../sql_reference/data_types/float.md) | -| `DATE32` | [Tarihli](../sql_reference/data_types/date.md) | -| `DATE64`, `TIMESTAMP` | [DateTime](../sql_reference/data_types/datetime.md) | -| `STRING`, `BINARY` | [Dize](../sql_reference/data_types/string.md) | -| `DECIMAL` | [Ondalık](../sql_reference/data_types/decimal.md) | +| `UINT8`, `BOOL` | [Uİnt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [Uınt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [Uİnt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [Uİnt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE32` | [Tarihli](../sql-reference/data-types/date.md) | +| `DATE64`, `TIMESTAMP` | [DateTime](../sql-reference/data-types/datetime.md) | +| `STRING`, `BINARY` | [Dize](../sql-reference/data-types/string.md) | +| `DECIMAL` | [Ondalık](../sql-reference/data-types/decimal.md) | ClickHouse yapılandırılabilir hassas destekler `Decimal` tür. Bu `INSERT` sorgu Orc davranır `DECIMAL` ClickHouse olarak yazın `Decimal128` tür. Desteklenmeyen Orc veri türleri: `DATE32`, `TIME32`, `FIXED_SIZE_BINARY`, `JSON`, `UUID`, `ENUM`. -ClickHouse tablo sütunlarının veri türlerinin karşılık gelen ORC veri alanları ile eşleşmesi gerekmez. Veri eklerken, ClickHouse veri türlerini yukarıdaki tabloya göre yorumlar ve sonra [döküm](../sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) veri türü için veri kümesi ClickHouse tablo sütun. +ClickHouse tablo sütunlarının veri türlerinin karşılık gelen ORC veri alanları ile eşleşmesi gerekmez. Veri eklerken, ClickHouse veri türlerini yukarıdaki tabloya göre yorumlar ve sonra [döküm](../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) veri türü için veri kümesi ClickHouse tablo sütun. ### Veri Ekleme {#inserting-data-2} @@ -1182,7 +1182,7 @@ Bir dosyadan Orc verilerini ClickHouse tablosuna aşağıdaki komutla ekleyebili $ cat filename.orc | clickhouse-client --query="INSERT INTO some_table FORMAT ORC" ``` -Hadoop ile veri alışverişi yapmak için şunları kullanabilirsiniz [HDFS tablo motoru](../engines/table_engines/integrations/hdfs.md). +Hadoop ile veri alışverişi yapmak için şunları kullanabilirsiniz [HDFS tablo motoru](../engines/table-engines/integrations/hdfs.md). ## Biçim Şeması {#formatschema} @@ -1198,7 +1198,7 @@ mutlak bir yol veya istemci üzerinde geçerli dizine göre bir yol içerebilir. Eğer istemci kullanıyorsanız [Toplu Modu](../interfaces/cli.md#cli_usage), şemanın yolu güvenlik nedeniyle göreceli olmalıdır. Eğer giriş veya çıkış veri üzerinden [HTTP arayüzü](../interfaces/http.md) biçim şemasında belirtilen dosya adı -belirtilen dizinde bulunmalıdır [format\_schema\_path](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-format_schema_path) +belirtilen dizinde bulunmalıdır [format\_schema\_path](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-format_schema_path) sunucu yapılandırmasında. ## Atlama Hataları {#skippingerrors} diff --git a/docs/tr/interfaces/http.md b/docs/tr/interfaces/http.md index a30e05418c8..2b92dd0ed9b 100644 --- a/docs/tr/interfaces/http.md +++ b/docs/tr/interfaces/http.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 19 toc_title: "HTTP aray\xFCz\xFC" --- @@ -11,7 +11,7 @@ HTTP arayüzü, herhangi bir programlama dilinden herhangi bir platformda Clickh Varsayılan olarak, clickhouse-server, 8123 numaralı bağlantı noktasında HTTP dinler (bu, yapılandırmada değiştirilebilir). -Parametreler olmadan bir GET / request yaparsanız, 200 yanıt kodunu ve tanımlanan dizeyi döndürür [http\_server\_default\_response](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-http_server_default_response) varsayılan değer “Ok.” (sonunda bir çizgi besleme ile) +Parametreler olmadan bir GET / request yaparsanız, 200 yanıt kodunu ve tanımlanan dizeyi döndürür [http\_server\_default\_response](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-http_server_default_response) varsayılan değer “Ok.” (sonunda bir çizgi besleme ile) ``` bash $ curl 'http://localhost:8123/' @@ -303,13 +303,16 @@ ClickHouse ayrıca gibi üçüncü parti araçları ile daha kolay entegrasyon y ``` xml - - /metrics - GET - + + /predefined_query + POST,GET + + predefined_query_handler SELECT * FROM system.metrics LIMIT 5 FORMAT Template SETTINGS format_template_resultset = 'prometheus_template_output_format_resultset', format_template_row = 'prometheus_template_output_format_row', format_template_rows_between_delimiter = '\n' - - + + + ... + ... ``` @@ -318,21 +321,23 @@ ClickHouse ayrıca gibi üçüncü parti araçları ile daha kolay entegrasyon y ``` bash -curl -vvv 'http://localhost:8123/metrics' +$ curl -v 'http://localhost:8123/predefined_query' * Trying ::1... * Connected to localhost (::1) port 8123 (#0) -> GET /metrics HTTP/1.1 +> GET /predefined_query HTTP/1.1 > Host: localhost:8123 > User-Agent: curl/7.47.0 > Accept: */* > < HTTP/1.1 200 OK -< Date: Wed, 27 Nov 2019 08:54:25 GMT +< Date: Tue, 28 Apr 2020 08:52:56 GMT < Connection: Keep-Alive < Content-Type: text/plain; charset=UTF-8 -< X-ClickHouse-Server-Display-Name: i-tl62qd0o +< X-ClickHouse-Server-Display-Name: i-mloy5trc < Transfer-Encoding: chunked -< X-ClickHouse-Query-Id: f39235f6-6ed7-488c-ae07-c7ceafb960f6 +< X-ClickHouse-Query-Id: 96fe0052-01e6-43ce-b12a-6b7370de6e8a +< X-ClickHouse-Format: Template +< X-ClickHouse-Timezone: Asia/Shanghai < Keep-Alive: timeout=3 < X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} < @@ -356,117 +361,62 @@ curl -vvv 'http://localhost:8123/metrics' # TYPE "ReplicatedSend" counter "ReplicatedSend" 0 +* Connection #0 to host localhost left intact + + * Connection #0 to host localhost left intact ``` -Örnekten görebileceğiniz gibi, Eğer `` yapılandırmada yapılandırılır.XML dosyası, ClickHouse önceden tanımlanmış türüne alınan HTTP istekleri eşleşecek `` Maç başarılı olursa, ClickHouse ilgili önceden tanımlanmış sorgu yürütecektir. +Örnekten görebileceğiniz gibi, Eğer `` yapılandırmada yapılandırılır.xml dosyası ve `` birçok içerebilir `s`. ClickHouse, önceden tanımlanmış türe alınan HTTP istekleriyle eşleşir `` ve ilk eşleşen işleyiciyi çalıştırır. Ardından, Maç başarılı olursa, ClickHouse ilgili önceden tanımlanmış sorguyu yürütecektir. -Şimdi `` Yapılandır configureılabilir ``, ``, ``, `` ve `` . +> Şimdi `` Yapılandır configureılabilir ``, ``, ``,``: +> `` HTTP isteğinin yöntem bölümünü eşleştirmekten sorumludur. `` tam tanımına uygundur [yöntem](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) HTTP protokolünde. İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanımlanmamışsa, HTTP isteğinin yöntem kısmıyla eşleşmez. +> +> `` HTTP isteğinin url bölümünü eşleştirmekten sorumludur. İle uyumludur [RE2](https://github.com/google/re2)'In düzenli ifadeleri. İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanımlanmamışsa, HTTP isteğinin url kısmıyla eşleşmez. +> +> `` HTTP isteğinin başlık kısmını eşleştirmekten sorumludur. Bu re2 düzenli ifadeler ile uyumludur. İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanımlanmamışsa, HTTP isteğinin üstbilgi bölümü eşleşmiyor. +> +> `` ana işleme bölümünü içerir. Şimdi `` Yapılandır configureılabilir ``, ``, ``, ``, ``, ``. +> \> `` şu anda üç tip destekler: **predefined\_query\_handler**, **dynamic\_query\_handler**, **sabit**. +> \> +> \> `` - işleyici çağrıldığında predefined\_query\_handler türü ile kullanın, sorgu yürütür. +> \> +> \> `` - dynamic\_query\_handler tipi ile kullanın, özler ve karşılık gelen değeri yürütür `` HTTP isteği params değeri. +> \> +> \> `` - statik tip, yanıt durum kodu ile kullanın. +> \> +> \> `` - statik tip, tepki ile kullanın [içerik türü](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type). +> \> +> \> `` - önek kullanırken, istemciye gönderilen statik tip, yanıt içeriği ile kullanın ‘file://’ veya ‘config://’, dosyadan içeriği bulun veya yapılandırma istemciye gönderin. -## root\_handler {#root_handler} - -`` kök yolu isteği için belirtilen içeriği döndürür. Belirli dönüş içeriği tarafından yapılandırılır `http_server_default_response` config.xml. belirtilmemişse, iade **Tamam.** - -`http_server_default_response` tanımlanmadı ve Clickhouse'a bir HTTP isteği gönderildi. Sonuç aşağıdaki gibidir: - -``` xml - - - -``` - - $ curl 'http://localhost:8123' - Ok. - -`http_server_default_response` tanımlanır ve Clickhouse'a bir HTTP isteği gönderilir. Sonuç aşağıdaki gibidir: - -``` xml -
]]>
- - - - -``` - - $ curl 'http://localhost:8123' -
% - -## ping\_handler {#ping_handler} - -`` geçerli ClickHouse sunucusunun durumunu araştırmak için kullanılabilir. ClickHouse HTTP Sunucusu normal olduğunda, Clickhouse'a erişme `` dön willecektir **Tamam.**. - -Örnek: - -``` xml - - /ping - -``` - -``` bash -$ curl 'http://localhost:8123/ping' -Ok. -``` - -## replicas\_status\_handler {#replicas_status_handler} - -`` çoğaltma düğümünün durumunu algılamak ve geri dönmek için kullanılır **Tamam.** çoğaltma düğümünde gecikme yoksa. Bir gecikme varsa, belirli bir gecikmeyi iade edin. Değeri `` özelleştirme destekler. Belirt specifymezseniz ``, ClickHouse varsayılan ayarı `` oluyor **/ replicas\_status**. - -Örnek: - -``` xml - - /replicas_status - -``` - -Hiçbir gecikme durumda: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -Ok. -``` - -Gecikmeli dava: - -``` bash -$ curl 'http://localhost:8123/replicas_status' -db.stats: Absolute delay: 22. Relative delay: 22. -``` +Sonraki farklı yapılandırma yöntemleri ``. ## predefined\_query\_handler {#predefined_query_handler} -Yapılandırabilirsiniz ``, ``, `` ve `` içinde ``. +`` ayar ayarları ve query\_params değerlerini destekler. Yapılandırabilirsiniz `` tip ininde ``. -`` HTTP isteğinin yöntem bölümünü eşleştirmekten sorumludur. `` tam tanımına uygundur [yöntem](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) HTTP protokolünde. İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanımlanmamışsa, HTTP isteğinin yöntem kısmıyla eşleşmez - -`` HTTP isteğinin url bölümünü eşleştirmekten sorumludur. İle uyumludur [RE2](https://github.com/google/re2)'In düzenli ifadeleri. İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanımlanmamışsa, HTTP isteğinin url kısmıyla eşleşmez - -`` HTTP isteğinin başlık kısmını eşleştirmekten sorumludur. Bu re2 düzenli ifadeler ile uyumludur. İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanımlanmamışsa, HTTP isteğinin başlık kısmıyla eşleşmez - -`` değer, önceden tanımlanmış bir sorgudur ``, bir HTTP isteği eşleştirildiğinde ve sorgunun sonucu döndürüldüğünde ClickHouse tarafından yürütülür. Bu bir zorunluluktur yapılandırma. - -`` ayar ayarları ve query\_params değerlerini destekler. +`` değer, önceden tanımlanmış bir sorgudur ``, bir HTTP isteği eşleştirildiğinde ve sorgunun sonucu döndürüldüğünde ClickHouse tarafından yürütülür. Bu bir zorunluluktur yapılandırma. Aşağıdaki örnek değerleri tanımlar `max_threads` ve `max_alter_threads` ayarlar, ardından bu ayarların başarıyla ayarlanıp ayarlanmadığını kontrol etmek için sistem tablosunu sorgular. Örnek: ``` xml - - + + + [^/]+)(/(?P[^/]+))?]]> GET TEST_HEADER_VALUE [^/]+)(/(?P[^/]+))?]]> - [^/]+)(/(?P[^/]+))?]]> - + + predefined_query_handler SELECT value FROM system.settings WHERE name = {name_1:String} SELECT name, value FROM system.settings WHERE name = {name_2:String} - - - +
+
+
``` ``` bash @@ -475,37 +425,193 @@ $ curl -H 'XXX:TEST_HEADER_VALUE' -H 'PARAMS_XXX:max_threads' 'http://localhost: max_alter_threads 2 ``` -!!! note "Not" - Birinde ``, biri `` sadece birini destekler `` bir ekleme türü. +!!! note "Dikkat" + Birinde `` sadece birini destekler `` bir ekleme türü. ## dynamic\_query\_handler {#dynamic_query_handler} -`` göre `` artmak `` . +İçinde ``, sorgu HTTP isteğinin param şeklinde yazılır. Fark şu ki ``, sorgu yapılandırma dosyasında yazılır. Yapılandırabilirsiniz `` içinde ``. -ClickHouse ayıklar ve karşılık gelen değeri yürütür `` HTTP isteğinin url'sindeki değer. -ClickHouse varsayılan ayarı `` oluyor `/query` . İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanım yoksa, param iletilmez. +ClickHouse ayıklar ve karşılık gelen değeri yürütür `` HTTP isteğinin url'sindeki değer. Varsayılan değer `` oluyor `/query` . İsteğe bağlı bir yapılandırmadır. Yapılandırma dosyasında tanım yoksa, param iletilmez. Bu işlevselliği denemek için örnek max\_threads ve max\_alter\_threads değerlerini tanımlar ve ayarların başarıyla ayarlanıp ayarlanmadığını sorgular. -Fark şu ki ``, sorgu yapılandırma dosyasında yazılır. Ama içinde ``, sorgu HTTP isteğinin param şeklinde yazılır. Örnek: ``` xml - - - - TEST_HEADER_VALUE_DYNAMIC - [^/]+)(/(?P[^/]+))?]]> - + + + + TEST_HEADER_VALUE_DYNAMIC + + dynamic_query_handler query_param - - + +
+
``` ``` bash -$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' -H 'PARAMS_XXX:max_threads' 'http://localhost:8123/?query_param=SELECT%20value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D&max_threads=1&max_alter_threads=2¶m_name_2=max_alter_threads' -1 -2 +$ curl -H 'XXX:TEST_HEADER_VALUE_DYNAMIC' 'http://localhost:8123/own?max_threads=1&max_alter_threads=2¶m_name_1=max_threads¶m_name_2=max_alter_threads&query_param=SELECT%20name,value%20FROM%20system.settings%20where%20name%20=%20%7Bname_1:String%7D%20OR%20name%20=%20%7Bname_2:String%7D' +max_threads 1 +max_alter_threads 2 +``` + +## sabit {#static} + +`` dön canebilir [content\_type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type), [durum](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) ve response\_content. response\_content belirtilen içeriği döndürebilir + +Örnek: + +Mesajı dönmektedir. + +``` xml + + + GET + xxx + /hi + + static + 402 + text/html; charset=UTF-8 + Say Hi! + + + +``` + +``` bash +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/hi' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /hi HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 402 Payment Required +< Date: Wed, 29 Apr 2020 03:51:26 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +Say Hi!% +``` + +Yapılandırmadan içeriği bulun istemciye gönder. + +``` xml +
]]>
+ + + + GET + xxx + /get_config_static_handler + + static + config://get_config_static_handler + + + +``` + +``` bash +$ curl -v -H 'XXX:xxx' 'http://localhost:8123/get_config_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_config_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:01:24 GMT +< Connection: Keep-Alive +< Content-Type: text/plain; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +* Connection #0 to host localhost left intact +
% +``` + +İstemciye gönder dosyadan içeriği bulun. + +``` xml + + + GET + xxx + /get_absolute_path_static_handler + + static + text/html; charset=UTF-8 + file:///absolute_path_file.html + + + + GET + xxx + /get_relative_path_static_handler + + static + text/html; charset=UTF-8 + file://./relative_path_file.html + + + +``` + +``` bash +$ user_files_path='/var/lib/clickhouse/user_files' +$ sudo echo "Relative Path File" > $user_files_path/relative_path_file.html +$ sudo echo "Absolute Path File" > $user_files_path/absolute_path_file.html +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_absolute_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_absolute_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:16 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Absolute Path File +* Connection #0 to host localhost left intact +$ curl -vv -H 'XXX:xxx' 'http://localhost:8123/get_relative_path_static_handler' +* Trying ::1... +* Connected to localhost (::1) port 8123 (#0) +> GET /get_relative_path_static_handler HTTP/1.1 +> Host: localhost:8123 +> User-Agent: curl/7.47.0 +> Accept: */* +> XXX:xxx +> +< HTTP/1.1 200 OK +< Date: Wed, 29 Apr 2020 04:18:31 GMT +< Connection: Keep-Alive +< Content-Type: text/html; charset=UTF-8 +< Transfer-Encoding: chunked +< Keep-Alive: timeout=3 +< X-ClickHouse-Summary: {"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"} +< +Relative Path File +* Connection #0 to host localhost left intact ``` [Orijinal makale](https://clickhouse.tech/docs/en/interfaces/http_interface/) diff --git a/docs/tr/interfaces/index.md b/docs/tr/interfaces/index.md index 6a89d8cce7e..4453135adfb 100644 --- a/docs/tr/interfaces/index.md +++ b/docs/tr/interfaces/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Arabirimler toc_priority: 14 toc_title: "Giri\u015F" @@ -22,7 +22,7 @@ ClickHouse iki ağ arabirimi sağlar (Her ikisi de isteğe bağlı olarak ek gü ClickHouse ile çalışmak için çok çeşitli üçüncü taraf kütüphaneleri de vardır: -- [İstemci kitaplıkları](third-party/client_libraries.md) +- [İstemci kitaplıkları](third-party/client-libraries.md) - [Entegrasyonlar](third-party/integrations.md) - [Görsel arayüzler](third-party/gui.md) diff --git a/docs/tr/interfaces/jdbc.md b/docs/tr/interfaces/jdbc.md index a7e69550c5a..b96cecf5116 100644 --- a/docs/tr/interfaces/jdbc.md +++ b/docs/tr/interfaces/jdbc.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 22 toc_title: "JDBC s\xFCr\xFCc\xFCs\xFC" --- diff --git a/docs/tr/interfaces/mysql.md b/docs/tr/interfaces/mysql.md index 4e60430f554..72df467d0ad 100644 --- a/docs/tr/interfaces/mysql.md +++ b/docs/tr/interfaces/mysql.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 20 toc_title: "MySQL Aray\xFCz\xFC" --- # MySQL Arayüzü {#mysql-interface} -ClickHouse MySQL Tel protokolünü destekler. Tarafından etkinleştir canilebilir [mysql\_port](../operations/server_configuration_parameters/settings.md#server_configuration_parameters-mysql_port) yapılandırma dosyasında ayarlama: +ClickHouse MySQL Tel protokolünü destekler. Tarafından etkinleştir canilebilir [mysql\_port](../operations/server-configuration-parameters/settings.md#server_configuration_parameters-mysql_port) yapılandırma dosyasında ayarlama: ``` xml 9004 @@ -37,8 +37,8 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` -Tüm MySQL istemcileri ile uyumluluk için, kullanıcı parolasını belirtmeniz önerilir [çift SHA1](../operations/settings/settings_users.md#password_double_sha1_hex) yapılandırma dosyasında. -Kullanarak kullanıcı şifresi belirt ifilirse [SHA256](../operations/settings/settings_users.md#password_sha256_hex), bazı istemciler (mysqljs ve komut satırı aracı mysql eski sürümleri) kimlik doğrulaması mümkün olmayacaktır. +Tüm MySQL istemcileri ile uyumluluk için, kullanıcı parolasını belirtmeniz önerilir [çift SHA1](../operations/settings/settings-users.md#password_double_sha1_hex) yapılandırma dosyasında. +Kullanarak kullanıcı şifresi belirt ifilirse [SHA256](../operations/settings/settings-users.md#password_sha256_hex), bazı istemciler (mysqljs ve komut satırı aracı mysql eski sürümleri) kimlik doğrulaması mümkün olmayacaktır. Kısıtlama: diff --git a/docs/tr/interfaces/odbc.md b/docs/tr/interfaces/odbc.md index 3cc0cc35700..0605a2a6aaa 100644 --- a/docs/tr/interfaces/odbc.md +++ b/docs/tr/interfaces/odbc.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 23 toc_title: "ODBC s\xFCr\xFCc\xFCs\xFC" --- diff --git a/docs/tr/interfaces/tcp.md b/docs/tr/interfaces/tcp.md index b1f712efd7d..6fbe2d34223 100644 --- a/docs/tr/interfaces/tcp.md +++ b/docs/tr/interfaces/tcp.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 18 toc_title: Yerel arabirim (TCP) --- diff --git a/docs/tr/interfaces/third-party/client-libraries.md b/docs/tr/interfaces/third-party/client-libraries.md new file mode 100644 index 00000000000..b9940b557b5 --- /dev/null +++ b/docs/tr/interfaces/third-party/client-libraries.md @@ -0,0 +1,60 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 26 +toc_title: "\u0130stemci Kitapl\u0131klar\u0131" +--- + +# Üçüncü taraf geliştiricilerin istemci kitaplıkları {#client-libraries-from-third-party-developers} + +!!! warning "Uyarı" + Yandex yapar **değil** Aşağıda listelenen kütüphaneleri koruyun ve kalitelerini sağlamak için kapsamlı bir test yapmadınız. + +- Piton + - [ınfi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) + - [clickhouse-sürücü](https://github.com/mymarilyn/clickhouse-driver) + - [clickhouse-müşteri](https://github.com/yurial/clickhouse-client) + - [aiochclient](https://github.com/maximdanilchenko/aiochclient) +- PHP + - [smı2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) + - [8bitov / clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) + - [bozerkins / clickhouse-müşteri](https://packagist.org/packages/bozerkins/clickhouse-client) + - [simpod / clickhouse-müşteri](https://packagist.org/packages/simpod/clickhouse-client) + - [seva-code / php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) + - [SeasClick c ++ istemcisi](https://github.com/SeasX/SeasClick) +- Gitmek + - [clickhouse](https://github.com/kshvakov/clickhouse/) + - [git-clickhouse](https://github.com/roistat/go-clickhouse) + - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) + - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) +- NodeJs + - [NodeJs) clickhouse)](https://github.com/TimonKK/clickhouse) + - [düğüm-clickhouse](https://github.com/apla/node-clickhouse) +- Per perll + - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) + - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) + - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) +- Yakut + - [ClickHouse (Ruby)](https://github.com/shlima/click_house) + - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) +- R + - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) + - [RClickHouse](https://github.com/IMSMWU/RClickHouse) +- Java + - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) + - [clickhouse-müşteri](https://github.com/Ecwid/clickhouse-client) +- SC scalaala + - [clickhouse-Scala-istemci](https://github.com/crobox/clickhouse-scala-client) +- Kotlin + - [AORM](https://github.com/TanVD/AORM) +- C\# + - [ClickHouse.Gürültü](https://github.com/killwort/ClickHouse-Net) + - [ClickHouse.Müşteri](https://github.com/DarkWanderer/ClickHouse.Client) + - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) +- İksir + - [clickhousex](https://github.com/appodeal/clickhousex/) + - [sütun](https://github.com/sofakingworld/pillar) +- Nim + - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) + +[Orijinal makale](https://clickhouse.tech/docs/en/interfaces/third-party/client_libraries/) diff --git a/docs/tr/interfaces/third-party/client_libraries.md b/docs/tr/interfaces/third-party/client_libraries.md deleted file mode 100644 index 2b89b1c4520..00000000000 --- a/docs/tr/interfaces/third-party/client_libraries.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 26 -toc_title: "\u0130stemci Kitapl\u0131klar\u0131" ---- - -# Üçüncü taraf geliştiricilerin istemci kitaplıkları {#client-libraries-from-third-party-developers} - -!!! warning "Uyarı" - Yandex yapar **değil** Aşağıda listelenen kütüphaneleri koruyun ve kalitelerini sağlamak için kapsamlı bir test yapmadınız. - -- Piton - - [ınfi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm) - - [clickhouse-sürücü](https://github.com/mymarilyn/clickhouse-driver) - - [clickhouse-müşteri](https://github.com/yurial/clickhouse-client) - - [aiochclient](https://github.com/maximdanilchenko/aiochclient) -- PHP - - [smı2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) - - [8bitov / clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) - - [bozerkins / clickhouse-müşteri](https://packagist.org/packages/bozerkins/clickhouse-client) - - [simpod / clickhouse-müşteri](https://packagist.org/packages/simpod/clickhouse-client) - - [seva-code / php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) - - [SeasClick c ++ istemcisi](https://github.com/SeasX/SeasClick) -- Gitmek - - [clickhouse](https://github.com/kshvakov/clickhouse/) - - [git-clickhouse](https://github.com/roistat/go-clickhouse) - - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) - - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) -- NodeJs - - [NodeJs) clickhouse)](https://github.com/TimonKK/clickhouse) - - [düğüm-clickhouse](https://github.com/apla/node-clickhouse) -- Per perll - - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) - - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) - - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) -- Yakut - - [ClickHouse (Ruby)](https://github.com/shlima/click_house) - - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) -- R - - [clickhouse-r](https://github.com/hannesmuehleisen/clickhouse-r) - - [RClickHouse](https://github.com/IMSMWU/RClickHouse) -- Java - - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) - - [clickhouse-müşteri](https://github.com/Ecwid/clickhouse-client) -- SC scalaala - - [clickhouse-Scala-istemci](https://github.com/crobox/clickhouse-scala-client) -- Kotlin - - [AORM](https://github.com/TanVD/AORM) -- C\# - - [ClickHouse.Gürültü](https://github.com/killwort/ClickHouse-Net) - - [ClickHouse.Müşteri](https://github.com/DarkWanderer/ClickHouse.Client) - - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) -- İksir - - [clickhousex](https://github.com/appodeal/clickhousex/) -- Nim - - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) - -[Orijinal makale](https://clickhouse.tech/docs/en/interfaces/third-party/client_libraries/) diff --git a/docs/tr/interfaces/third-party/gui.md b/docs/tr/interfaces/third-party/gui.md index cb41103563d..d67478fe2b4 100644 --- a/docs/tr/interfaces/third-party/gui.md +++ b/docs/tr/interfaces/third-party/gui.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 28 toc_title: "G\xF6rsel Aray\xFCzler" --- @@ -93,6 +93,10 @@ ClickHouse dahil olmak üzere birden fazla veri kaynağı için destekler, Redas [clickhouse-flamegraph](https://github.com/Slach/clickhouse-flamegraph) görselleştirmek için özel bir araçtır `system.trace_log` olarak [flamegraph](http://www.brendangregg.com/flamegraphs.html). +### clickhouse-plantuml {#clickhouse-plantuml} + +[cickhouse-plantuml](https://pypi.org/project/clickhouse-plantuml/) oluşturmak için bir komut dosyası mı [PlantUML](https://plantuml.com/) tablo şemalarının diyagramı. + ## Ticari {#commercial} ### Datriagrpip {#datagrip} diff --git a/docs/tr/interfaces/third-party/index.md b/docs/tr/interfaces/third-party/index.md index d8332c00c26..c9c66fc1c64 100644 --- a/docs/tr/interfaces/third-party/index.md +++ b/docs/tr/interfaces/third-party/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: "\xDC\xE7\xFCnc\xFC Taraf" toc_priority: 24 --- diff --git a/docs/tr/interfaces/third-party/integrations.md b/docs/tr/interfaces/third-party/integrations.md index 2216e68a4c4..8a1d5c239f6 100644 --- a/docs/tr/interfaces/third-party/integrations.md +++ b/docs/tr/interfaces/third-party/integrations.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 27 toc_title: Entegrasyonlar --- @@ -26,7 +26,11 @@ toc_title: Entegrasyonlar - [ClickHouseMigrator](https://github.com/zlzforever/ClickHouseMigrator) - Mesaj kuyrukları - [Kafka](https://kafka.apache.org) - - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (kullanma [Go client](https://github.com/kshvakov/clickhouse/)) + - [clickhouse\_sinker](https://github.com/housepower/clickhouse_sinker) (kullanma [Go client](https://github.com/ClickHouse/clickhouse-go/)) + - [stream-loader-clickhouse](https://github.com/adform/stream-loader) +- Akış işleme + - [Flink](https://flink.apache.org) + - [flink-clickhouse-lavabo](https://github.com/ivi-ru/flink-clickhouse-sink) - Nesne depoları - [S3](https://en.wikipedia.org/wiki/Amazon_S3) - [clickhouse-yedekleme](https://github.com/AlexAkulov/clickhouse-backup) @@ -42,7 +46,7 @@ toc_title: Entegrasyonlar - [graphouse](https://github.com/yandex/graphouse) - [karbon-clickhouse](https://github.com/lomik/carbon-clickhouse) + - [grafit-clickhouse](https://github.com/lomik/graphite-clickhouse) - - [grafit-ch-doktoru](https://github.com/innogames/graphite-ch-optimizer) - staled bölümleri optimize eder [\* Graphıtemergetree](../../engines/table_engines/mergetree_family/graphitemergetree.md#graphitemergetree) eğer kurallar [toplaması yapılandırması](../../engines/table_engines/mergetree_family/graphitemergetree.md#rollup-configuration) uygulanabilir + - [grafit-ch-doktoru](https://github.com/innogames/graphite-ch-optimizer) - staled bölümleri optimize eder [\* Graphıtemergetree](../../engines/table-engines/mergetree-family/graphitemergetree.md#graphitemergetree) eğer kurallar [toplaması yapılandırması](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) uygulanabilir - [Grafana](https://grafana.com/) - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) - [Prometheus](https://prometheus.io/) @@ -74,15 +78,15 @@ toc_title: Entegrasyonlar - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (kullanma [ınfi.clickhouse\_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - [Pandalar](https://pandas.pydata.org) - [pandahouse](https://github.com/kszucs/pandahouse) -- PHP - - [Doctrine](https://www.doctrine-project.org/) +- PHP + - [Doktrin](https://www.doctrine-project.org/) - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) - R - [dplyr](https://db.rstudio.com/dplyr/) - [RClickHouse](https://github.com/IMSMWU/RClickHouse) (kullanma [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) - Java - [Hadoop](http://hadoop.apache.org) - - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (kullanma [JDBC](../../sql_reference/table_functions/jdbc.md)) + - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (kullanma [JDBC](../../sql-reference/table-functions/jdbc.md)) - SC scalaala - [Akka](https://akka.io) - [clickhouse-Scala-istemci](https://github.com/crobox/clickhouse-scala-client) diff --git a/docs/tr/interfaces/third-party/proxy.md b/docs/tr/interfaces/third-party/proxy.md index 7ff9fc3642f..c326b432f7c 100644 --- a/docs/tr/interfaces/third-party/proxy.md +++ b/docs/tr/interfaces/third-party/proxy.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 29 toc_title: Vekiller --- diff --git a/docs/tr/introduction/adopters.md b/docs/tr/introduction/adopters.md index 0e180e161ec..444902e0b96 100644 --- a/docs/tr/introduction/adopters.md +++ b/docs/tr/introduction/adopters.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 8 toc_title: Benimseyenler --- @@ -10,74 +10,77 @@ toc_title: Benimseyenler !!! warning "Uyarı" ClickHouse ve onların Başarı Öyküleri kullanarak şirketlerin aşağıdaki liste kamu kaynaklarından monte edilir, böylece mevcut gerçeklikten farklı olabilir. Şirketinizde Clickhouse'u benimseme hikayesini paylaşırsanız memnun oluruz ve [listeye Ekle](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/introduction/adopters.md), ancak lütfen bunu yaparak herhangi bir NDA sorun yaşamayacağınızdan emin olun. Diğer şirketlerden gelen yayınlarla güncellemeler sağlamak da yararlıdır. -| Şirket | Sektör | Usecase | Küme Boyutu | (Un) Sıkıştırılmış Veri Boyutu\* | Başvurma | -|----------------------------------------------------------------------------------------------------------|---------------------------------|-----------------------------|------------------------------------------------|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [2gıs](https://2gis.ru) | Haritalar | İzleme | — | — | [Rusça konuşun, Temmuz 2019](https://youtu.be/58sPkXfq6nw) | -| [Aloha Tarayıcı](https://alohabrowser.com/) | Mobil Uygulama | Tarayıcı arka ucu | — | — | [Rusça slaytlar, Mayıs 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | -| [Amadeus](https://amadeus.com/) | Seyahat | Analiz | — | — | [Basın Bülteni, Nisan 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | -| [Appsflyer](https://www.appsflyer.com) | Mobil analitik | Ana ürün | — | — | [Rusça konuşun, Temmuz 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | -| [ArenaData](https://arenadata.tech/) | Veri Platformu | Ana ürün | — | — | [Rusça slaytlar, Aralık 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | -| [Badoo](https://badoo.com) | Çıkma | Timeseries | — | — | [Rusça slaytlar, Aralık 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | -| [Benocs](https://www.benocs.com/) | Ağ telemetri ve analitik | Ana Ürün | — | — | [İngilizce slaytlar, Ekim 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | -| [Bloomberg](https://www.bloomberg.com/) | Finans, Medya | İzleme | 102 sunucular | — | [Slaytlar, Mayıs 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | -| [Bloxy](https://bloxy.info) | Blockchain | Analiz | — | — | [Rusça slaytlar, Ağustos 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | -| `Dataliance/UltraPower` | Telekom | Analiz | — | — | [Çince slaytlar, Ocak 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | -| [CARTO](https://carto.com/) | İş Zek Businessası | G geoeo analyt analyticsics | — | — | [ClickHouse ile coğrafi işleme](https://carto.com/blog/geospatial-processing-with-clickhouse/) | -| [CERN](http://public.web.cern.ch/public/) | Araştırma | Deney | — | — | [Basın bülteni, Nisan 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | -| [Cisco](http://cisco.com/) | Ağ | Trafik analizi | — | — | [Yıldırım konuşması, Ekim 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | -| [Kale Menkul Değerler](https://www.citadelsecurities.com/) | Finansman | — | — | — | [Katkı, Mart 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | -| [Citymobil](https://city-mobil.ru) | Taksicilik | Analiz | — | — | [Rusça blog yazısı, Mart 2020](https://habr.com/en/company/citymobil/blog/490660/) | -| [ContentSquare](https://contentsquare.com) | Web analyt webics | Ana ürün | — | — | [Fransızca Blog yazısı, Kasım 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | -| [Cloudflare](https://cloudflare.com) | CDN | Trafik analizi | 36 sunucu | — | [Blog yazısı, Mayıs 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Blog yazısı, Mart 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | -| [Corunet](https://coru.net/) | Analiz | Ana ürün | — | — | [İngilizce slaytlar, Nisan 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | -| [CraiditX 氪信](https://creditx.com) | Finans AI | Analiz | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | -| [Criteo/Storetail](https://www.criteo.com/) | Perakendecilik | Ana ürün | — | — | [İngilizce slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | -| [Deut Banksche Bank](https://db.com) | Finansman | Bİ analitik | — | — | [İngilizce slaytlar, Ekim 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | -| [Diva-e](https://www.diva-e.com) | Dijital danışmanlık | Ana Ürün | — | — | [İngilizce slaytlar, Eylül 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | -| [Exness](https://www.exness.com) | Ticaret | Metrikler, Günlük Kaydı | — | — | [Rusça konuşun, Mayıs 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | -| [Geniee](https://geniee.co.jp) | Reklam Ağı | Ana ürün | — | — | [Japonca Blog yazısı, Temmuz 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | -| [HUYA](https://www.huya.com/) | Video Akışı | Analiz | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | -| [Idealista](https://www.idealista.com) | Emlak | Analiz | — | — | [İngilizce Blog yazısı, Nisan 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | -| [Infovista](https://www.infovista.com/) | Ağlar | Analiz | — | — | [İngilizce slaytlar, Ekim 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | -| [Innogames](https://www.innogames.com) | Oyun | Metrikler, Günlük Kaydı | — | — | [Rusça slaytlar, Eylül 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | -| [Integros](https://integros.com) | Video hizmetleri platformu | Analiz | — | — | [Rusça slaytlar, Mayıs 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Kodiak Verileri](https://www.kodiakdata.com/) | Bulutlar | Ana ürün | — | — | [Engish slaytlar, Nisan 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | -| [Kontur](https://kontur.ru) | Yazılım Geliştirme | Metrik | — | — | [Rusça konuşma, Kasım 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | -| [LifeStreet](https://lifestreet.com/) | Reklam Ağı | Ana ürün | 75 sunucu (3 kopya) | 5.27 Pıb | [Rusça Blog yazısı, Şubat 2017](https://habr.com/en/post/322620/) | -| [Mail.ru Bulut Çözümleri](https://mcs.mail.ru/) | Bulut hizmetleri | Ana ürün | — | — | [ClickHouse örneğini Rusça olarak çalıştırma](https://mcs.mail.ru/help/db-create/clickhouse#) | -| [MessageBird](https://www.messagebird.com) | Telekomünikasyonlar | İstatistik | — | — | [İngilizce slaytlar, Kasım 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | -| [MGID](https://www.mgid.com/) | Reklam Ağı | Web-analyt -ics | — | — | [Analitik DBMS ClickHouse uygulama deneyimimiz, Rusça](http://gs-studio.com/news-about-it/32777----clickhouse---c) | -| [OneAPM](https://www.oneapm.com/) | İzleme ve veri analizi | Ana ürün | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | -| [Pragma Yenilik](http://www.pragma-innovation.fr/) | Telemetri ve büyük veri analizi | Ana ürün | — | — | [İngilizce slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | -| [QINGCLOUD](https://www.qingcloud.com/) | Bulut hizmetleri | Ana ürün | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | -| [Qrator](https://qrator.net) | DDoS koruması | Ana ürün | — | — | [Blog Yazısı, Mart 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | -| [Beijing per PERCENTC İnformationent Information Technology Co., Ltd. Ltd.Şti.](https://www.percent.cn/) | Analiz | Ana Ürün | — | — | [Çince slaytlar, Haziran 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | -| [Serseri](https://rambler.ru) | İnternet Hizmetleri | Analiz | — | — | [Rusça konuşma, Nisan 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | -| [Tencent](https://www.tencent.com) | Mesaj | Günlük | — | — | [Çince konuşun, Kasım 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | -| [Trafik Yıldız Starsları](https://trafficstars.com/) | Reklam Ağı | — | — | — | [Rusça slaytlar, Mayıs 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | -| [S7 Havayolları](https://www.s7.ru) | Havayolular | Metrikler, Günlük Kaydı | — | — | [Rusça konuş, Mart 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | -| [SEMrush](https://www.semrush.com/) | Pazarlamacı | Ana ürün | — | — | [Rusça slaytlar, Ağustos 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | -| [scireum GmbH](https://www.scireum.de/) | e-ticaret | Ana ürün | — | — | [Almanca konuşma, Şubat 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | -| [Nöbet](https://sentry.io/) | Yazılımcı | Ürün için arka uç | — | — | [İngilizce Blog yazısı, Mayıs 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | -| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr) | Devlet Sosyal Güvenlik | Analiz | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | -| [seo.do](https://seo.do/) | Analiz | Ana ürün | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | -| [Sina](http://english.sina.com/index.html) | Haberci | — | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | -| [SMI2](https://smi2.ru/) | Haberci | Analiz | — | — | [Rusça blog yazısı, Kasım 2017](https://habr.com/ru/company/smi2/blog/314558/) | -| [Splunk](https://www.splunk.com/) | İş Analitiği | Ana ürün | — | — | [İngilizce slaytlar, Ocak 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | -| [Spotify](https://www.spotify.com) | Müzik | Deney | — | — | [Slaytlar, Temmuz 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | -| [Tencent](https://www.tencent.com) | Büyük Veri | Veri işleme | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | -| [Uber](https://www.uber.com) | Taksicilik | Günlük | — | — | [Slay ,tlar, Şubat 20 202020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | -| [VKontakte](https://vk.com) | Sosyal Ağ | İstatistik, Günlük | — | — | [Rusça slaytlar, Ağustos 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | -| [Wisebits](https://wisebits.com/) | BT çözümleri | Analiz | — | — | [Rusça slaytlar, Mayıs 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | -| [Xiaoxin Tech.](https://www.xiaoheiban.cn/) | Eğitici | Ortak amaç | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | -| [Ximalaya](https://www.ximalaya.com/) | Ses paylaşımı | OLAP | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | -| [Yandex Bulut](https://cloud.yandex.ru/services/managed-clickhouse) | Genel Bulut | Ana ürün | — | — | [Rusça konuşun, Aralık 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | -| [Yandex DataLens](https://cloud.yandex.ru/services/datalens) | İş Zek Businessası | Ana ürün | — | — | [Rusça slaytlar, Aralık 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | -| [Yandex Pazarı](https://market.yandex.ru/) | e-ticaret | Metrikler, Günlük Kaydı | — | — | [Rusça konuşma, Ocak 2019](https://youtu.be/_l1qP0DyBcA?t=478) | -| [Yandex Metrica](https://metrica.yandex.com) | Web analyt webics | Ana ürün | Bir kümede 360 sunucu, bir bölümde 1862 sunucu | 66.41 Pıb / 5.68 Pıb | [Slay ,tlar, Şubat 20 202020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | -| [ЦВТ](https://htc-cs.ru/) | Yazılım Geliştirme | Metrikler, Günlük Kaydı | — | — | [Blog yazısı, Mart 2019, Rusça](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | -| [МКБ](https://mkb.ru/) | Banka | Web-sistem izleme | — | — | [Rusça slaytlar, Eylül 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | -| [金数据](https://jinshuju.net) | Bİ analitik | Ana ürün | — | — | [Çince slaytlar, Ekim 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | -| [Instana](https://www.instana.com) | APM Platformu | Ana ürün | — | — | [Twitter mesaj](https://twitter.com/mieldonkers/status/1248884119158882304) | +| Şirket | Sektör | Usecase | Küme Boyutu | (Un) Sıkıştırılmış Veri Boyutu\* | Başvurma | +|------------------------------------------------------------------------------------------------|---------------------------------|-----------------------------|------------------------------------------------|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 2gıs | Haritalar | İzleme | — | — | [Rusça konuşun, Temmuz 2019](https://youtu.be/58sPkXfq6nw) | +| Aloha Browser | Mobil Uygulama | Tarayıcı arka ucu | — | — | [Rusça slaytlar, Mayıs 2019](https://github.com/yandex/clickhouse-presentations/blob/master/meetup22/aloha.pdf) | +| Amadeus | Seyahat | Analiz | — | — | [Basın Bülteni, Nisan 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | +| Appsflyer | Mobil analitik | Ana ürün | — | — | [Rusça konuşun, Temmuz 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | +| ArenaData | Veri Platformu | Ana ürün | — | — | [Rusça slaytlar, Aralık 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | +| Badoo | Çıkma | Timeseries | — | — | [Rusça slaytlar, Aralık 2019](https://presentations.clickhouse.tech/meetup38/forecast.pdf) | +| Benocs | Ağ telemetri ve analitik | Ana Ürün | — | — | [İngilizce slaytlar, Ekim 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | +| Bloomberg | Finans, Medya | İzleme | 102 sunucular | — | [Slaytlar, Mayıs 2018](https://www.slideshare.net/Altinity/http-analytics-for-6m-requests-per-second-using-clickhouse-by-alexander-bocharov) | +| Bloxy | Blockchain | Analiz | — | — | [Rusça slaytlar, Ağustos 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | +| Çin Telekom için Dataliance | Telekom | Analiz | — | — | [Çince slaytlar, Ocak 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | +| CARTO | İş Zek Businessası | G geoeo analyt analyticsics | — | — | [ClickHouse ile coğrafi işleme](https://carto.com/blog/geospatial-processing-with-clickhouse/) | +| CERN | Araştırma | Deney | — | — | [Basın bülteni, Nisan 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | +| Cisco | Ağ | Trafik analizi | — | — | [Yıldırım konuşması, Ekim 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | +| Citadel Securities | Finansman | — | — | — | [Katkı, Mart 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | +| Citymobil | Taksicilik | Analiz | — | — | [Rusça blog yazısı, Mart 2020](https://habr.com/en/company/citymobil/blog/490660/) | +| ContentSquare | Web analyt webics | Ana ürün | — | — | [Fransızca Blog yazısı, Kasım 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | +| Cloudflare | CDN | Trafik analizi | 36 sunucu | — | [Blog yazısı, Mayıs 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Blog yazısı, Mart 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | +| Corunet | Analiz | Ana ürün | — | — | [İngilizce slaytlar, Nisan 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | +| CraiditX 氪信 | Finans AI | Analiz | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | +| Criteo | Perakendecilik | Ana ürün | — | — | [İngilizce slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | +| Deutsche Bank | Finansman | Bİ analitik | — | — | [İngilizce slaytlar, Ekim 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | +| Diva-e | Dijital danışmanlık | Ana Ürün | — | — | [İngilizce slaytlar, Eylül 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | +| Exness | Ticaret | Metrikler, Günlük Kaydı | — | — | [Rusça konuşun, Mayıs 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | +| Geniee | Reklam Ağı | Ana ürün | — | — | [Japonca Blog yazısı, Temmuz 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | +| HUYA | Video Akışı | Analiz | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | +| Idealista | Emlak | Analiz | — | — | [İngilizce Blog yazısı, Nisan 2019](https://clickhouse.yandex/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | +| Infovista | Ağlar | Analiz | — | — | [İngilizce slaytlar, Ekim 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | +| Innogames | Oyun | Metrikler, Günlük Kaydı | — | — | [Rusça slaytlar, Eylül 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | +| Integros | Video hizmetleri platformu | Analiz | — | — | [Rusça slaytlar, Mayıs 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| Kodiak Verileri | Bulutlar | Ana ürün | — | — | [Engish slaytlar, Nisan 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | +| Kontur | Yazılım Geliştirme | Metrik | — | — | [Rusça konuşma, Kasım 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | +| LifeStreet | Reklam Ağı | Ana ürün | 75 sunucu (3 kopya) | 5.27 Pıb | [Rusça Blog yazısı, Şubat 2017](https://habr.com/en/post/322620/) | +| Mail.ru Bulut Çözümleri | Bulut hizmetleri | Ana ürün | — | — | [Rusça makale](https://mcs.mail.ru/help/db-create/clickhouse#) | +| MessageBird | Telekomünikasyonlar | İstatistik | — | — | [İngilizce slaytlar, Kasım 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | +| MGID | Reklam Ağı | Web-analyt -ics | — | — | [Rusça blog yazısı, Nisan 2020](http://gs-studio.com/news-about-it/32777----clickhouse---c) | +| OneAPM | İzleme ve veri analizi | Ana ürün | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | +| Pragma Innovation | Telemetri ve büyük veri analizi | Ana ürün | — | — | [İngilizce slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | +| QINGCLOUD | Bulut hizmetleri | Ana ürün | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | +| Qrator | DDoS koruması | Ana ürün | — | — | [Blog Yazısı, Mart 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | +| Percent 百分点 | Analiz | Ana Ürün | — | — | [Çince slaytlar, Haziran 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | +| Serseri | İnternet Hizmetleri | Analiz | — | — | [Rusça konuşma, Nisan 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | +| Tencent | Mesaj | Günlük | — | — | [Çince konuşun, Kasım 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | +| Traffic Stars | Reklam Ağı | — | — | — | [Rusça slaytlar, Mayıs 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | +| S7 Airlines | Havayolular | Metrikler, Günlük Kaydı | — | — | [Rusça konuş, Mart 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | +| SEMrush | Pazarlama | Ana ürün | — | — | [Rusça slaytlar, Ağustos 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | +| scireum GmbH | e-ticaret | Ana ürün | — | — | [Almanca konuşma, Şubat 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | +| Nöbet | Yazılımcı | Ürün için arka uç | — | — | [İngilizce Blog yazısı, Mayıs 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | +| SGK | Devlet Sosyal Güvenlik | Analiz | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | +| seo.do | Analiz | Ana ürün | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | +| Sina | Haberci | — | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | +| SMI2 | Haberci | Analiz | — | — | [Rusça blog yazısı, Kasım 2017](https://habr.com/ru/company/smi2/blog/314558/) | +| Splunk | İş Analitiği | Ana ürün | — | — | [İngilizce slaytlar, Ocak 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | +| Spotify | Müzik | Deney | — | — | [Slaytlar, Temmuz 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | +| Tencent | Büyük Veri | Veri işleme | — | — | [Çince slaytlar, Ekim 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | +| Uber | Taksicilik | Günlük | — | — | [Slay ,tlar, Şubat 20 202020](https://presentations.clickhouse.tech/meetup40/uber.pdf) | +| VKontakte | Sosyal Ağ | İstatistik, Günlük | — | — | [Rusça slaytlar, Ağustos 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | +| Wisebits | BT çözümleri | Analiz | — | — | [Rusça slaytlar, Mayıs 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | +| Xiaoxin Tech | Eğitici | Ortak amaç | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | +| Ximalaya | Ses paylaşımı | OLAP | — | — | [İngilizce slaytlar, Kasım 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | +| Yandex Cloud | Genel Bulut | Ana ürün | — | — | [Rusça konuşun, Aralık 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | +| Yandex DataLens | İş Zek Businessası | Ana ürün | — | — | [Rusça slaytlar, Aralık 2019](https://presentations.clickhouse.tech/meetup38/datalens.pdf) | +| Yandex Market | e-ticaret | Metrikler, Günlük Kaydı | — | — | [Rusça konuşma, Ocak 2019](https://youtu.be/_l1qP0DyBcA?t=478) | +| Yandex Metrica | Web analyt webics | Ana ürün | Bir kümede 360 sunucu, bir bölümde 1862 sunucu | 66.41 Pıb / 5.68 Pıb | [Slay ,tlar, Şubat 20 202020](https://presentations.clickhouse.tech/meetup40/introduction/#13) | +| ЦВТ | Yazılım Geliştirme | Metrikler, Günlük Kaydı | — | — | [Blog yazısı, Mart 2019, Rusça](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | +| МКБ | Banka | Web-sistem izleme | — | — | [Rusça slaytlar, Eylül 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | +| Jinshuju 金数据 | Bİ analitik | Ana ürün | — | — | [Çince slaytlar, Ekim 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | +| Instana | APM Platformu | Ana ürün | — | — | [Twitter mesaj](https://twitter.com/mieldonkers/status/1248884119158882304) | +| Wargaming | Oyun | | — | — | [Röportaj](https://habr.com/en/post/496954/) | +| Crazypanda | Oyun | | — | — | ClickHouse meetup canlı oturum | +| FunCorp | Oyun | | — | — | [Makale](https://www.altinity.com/blog/migrating-from-redshift-to-clickhouse) | [Orijinal makale](https://clickhouse.tech/docs/en/introduction/adopters/) diff --git a/docs/tr/introduction/distinctive-features.md b/docs/tr/introduction/distinctive-features.md new file mode 100644 index 00000000000..be7fd6ff160 --- /dev/null +++ b/docs/tr/introduction/distinctive-features.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 4 +toc_title: "Ay\u0131rt Edici \xD6zellikler" +--- + +# Clickhouse'un ayırt edici özellikleri {#distinctive-features-of-clickhouse} + +## Doğru sütun yönelimli DBMS {#true-column-oriented-dbms} + +Bir gerçek sütun yönelimli DBMS, hiçbir ek veri değerleri ile depolanır. Diğer şeylerin yanı sıra, bu, uzunluklarının saklanmasını önlemek için sabit uzunluk değerlerinin desteklenmesi gerektiği anlamına gelir “number” değerlerin yanında. Örnek olarak, bir milyar Uİnt8 tipi değerler yaklaşık 1 GB sıkıştırılmamış tüketmelidir veya bu CPU kullanımını güçlü bir şekilde etkiler. Verileri kompakt bir şekilde saklamak esastır (herhangi bir “garbage”) sıkıştırılmamış olsa bile, dekompresyon hızı (CPU kullanımı) esas olarak sıkıştırılmamış verilerin hacmine bağlıdır. + +Farklı sütunların değerlerini ayrı ayrı depolayabilen, ancak diğer senaryolar için optimizasyonları nedeniyle analitik sorguları etkili bir şekilde işleyemeyen sistemler olduğu için dikkat çekicidir. Örnekler HBase, BigTable, Cassandra ve HyperTable. Bu sistemlerde, saniyede yüz bin satır civarında verim elde edersiniz, ancak saniyede yüz milyonlarca satır olmaz. + +Clickhouse'un tek bir veritabanı değil, bir veritabanı yönetim sistemi olduğunu da belirtmek gerekir. ClickHouse, çalışma zamanında tablolar ve veritabanları oluşturmak, veri yüklemek ve sunucuyu yeniden yapılandırmadan ve yeniden başlatmadan sorguları çalıştırmaya izin verir. + +## Veri Sıkıştırma {#data-compression} + +Bazı sütun yönelimli DBMSs (InfiniDB CE ve MonetDB) veri sıkıştırma kullanmayın. Bununla birlikte, veri sıkıştırma mükemmel performans elde etmede önemli bir rol oynar. + +## Verilerin Disk Depolama {#disk-storage-of-data} + +Verileri fiziksel olarak birincil anahtara göre sıralamak, belirli değerleri veya değer aralıkları için düşük gecikme süresi ile birkaç düzine milisaniyeden daha az veri ayıklamayı mümkün kılar. Bazı sütun yönelimli Dbms'ler (SAP HANA ve Google PowerDrill gibi) yalnızca RAM'de çalışabilir. Bu yaklaşım, gerçek zamanlı analiz için gerekenden daha büyük bir donanım bütçesinin tahsisini teşvik eder. ClickHouse düzenli sabit diskler üzerinde çalışmak üzere tasarlanmıştır, bu da GB veri depolama başına maliyetin düşük olduğu anlamına gelir, ancak varsa SSD ve ek RAM de tamamen kullanılır. + +## Birden fazla çekirdekte paralel işleme {#parallel-processing-on-multiple-cores} + +Büyük sorgular, geçerli sunucuda bulunan tüm gerekli kaynakları alarak doğal olarak paralelleştirilir. + +## Birden çok sunucuda dağıtılmış işleme {#distributed-processing-on-multiple-servers} + +Yukarıda belirtilen sütunlu Dbms'lerin neredeyse hiçbiri dağıtılmış sorgu işleme desteğine sahip değildir. +Clickhouse'da, veriler farklı parçalarda bulunabilir. Her parça, hata toleransı için kullanılan bir grup kopya olabilir. Tüm kırıklar, kullanıcı için şeffaf olarak paralel bir sorgu çalıştırmak için kullanılır. + +## SQL desteği {#sql-support} + +ClickHouse, çoğu durumda SQL standardına özdeş olan sql'i temel alan bildirime dayalı bir sorgu dilini destekler. +Desteklenen sorgular arasında GROUP BY, ORDER BY, from, ın ve JOIN yan tümceleri ve skaler alt sorgular bulunur. +Bağımlı alt sorgular ve pencere işlevleri desteklenmez. + +## Vektör Motoru {#vector-engine} + +Veriler yalnızca sütunlar tarafından saklanmakla kalmaz, aynı zamanda yüksek CPU verimliliği elde etmeyi sağlayan vektörler (sütunların parçaları) tarafından işlenir. + +## Gerçek zamanlı veri güncellemeleri {#real-time-data-updates} + +ClickHouse, birincil anahtarlı tabloları destekler. Birincil anahtar aralığındaki sorguları hızlı bir şekilde gerçekleştirmek için, veriler birleştirme ağacını kullanarak aşamalı olarak sıralanır. Bu nedenle, veriler sürekli olarak tabloya eklenebilir. Yeni veri Yutulduğunda hiçbir kilit alınır. + +## Dizin {#index} + +Birincil anahtara göre fiziksel olarak sıralanmış bir veriye sahip olmak, belirli değerleri veya değer aralıkları için düşük gecikme süresi ile birkaç düzine milisaniyeden daha az veri çıkarmayı mümkün kılar. + +## Çevrimiçi sorgular için uygundur {#suitable-for-online-queries} + +Düşük gecikme süresi, kullanıcı arayüzü sayfası yüklenirken, sorguların gecikmeden ve önceden bir cevap hazırlamaya çalışmadan işlenebileceği anlamına gelir. Başka bir deyişle, çevrimiçi. + +## Yaklaşık hesaplamalar için destek {#support-for-approximated-calculations} + +ClickHouse performans için doğruluk ticaret için çeşitli yollar sağlar: + +1. Farklı değerler, medyan ve quantiles sayısı yaklaşık hesaplama için toplam işlevleri. +2. Verilerin bir bölümünü (örnek) temel alan bir sorguyu çalıştırmak ve yaklaşık bir sonuç almak. Bu durumda, diskten orantılı olarak daha az veri alınır. +3. Tüm anahtarlar yerine, sınırlı sayıda rastgele anahtar için bir toplama çalıştırma. Verilerde anahtar dağıtımı için belirli koşullar altında, bu daha az kaynak kullanırken makul derecede doğru bir sonuç sağlar. + +## Veri çoğaltma ve Veri Bütünlüğü desteği {#data-replication-and-data-integrity-support} + +ClickHouse zaman uyumsuz çoklu ana çoğaltma kullanır. Kullanılabilir herhangi bir yineleme için yazıldıktan sonra kalan tüm yinelemeler arka planda kendi kopyasını almak. Sistem, farklı yinelemelerde aynı verileri korur. Çoğu arızadan sonra kurtarma, karmaşık durumlarda otomatik olarak veya yarı otomatik olarak gerçekleştirilir. + +Daha fazla bilgi için bölüme bakın [Veri çoğaltma](../engines/table-engines/mergetree-family/replication.md). + +## Dezavantajları olarak kabul edilebilir özellikler {#clickhouse-features-that-can-be-considered-disadvantages} + +1. Tam teşekküllü işlemler yok. +2. Yüksek oranda ve düşük gecikme ile zaten eklenen verileri değiştirme veya silme yeteneği eksikliği. Verileri temizlemek veya değiştirmek için toplu silme ve güncellemeler vardır, örneğin Aşağıdakilere uymak için [GDPR](https://gdpr-info.eu). +3. Seyrek dizin, Clickhouse'u anahtarlarıyla tek satırları almak için nokta sorguları için çok uygun değildir. + +[Orijinal makale](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/tr/introduction/distinctive_features.md b/docs/tr/introduction/distinctive_features.md deleted file mode 100644 index 3b26dea645c..00000000000 --- a/docs/tr/introduction/distinctive_features.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 4 -toc_title: "Ay\u0131rt Edici \xD6zellikler" ---- - -# Clickhouse'un ayırt edici özellikleri {#distinctive-features-of-clickhouse} - -## Doğru sütun yönelimli DBMS {#true-column-oriented-dbms} - -Bir gerçek sütun yönelimli DBMS, hiçbir ek veri değerleri ile depolanır. Diğer şeylerin yanı sıra, bu, uzunluklarının saklanmasını önlemek için sabit uzunluk değerlerinin desteklenmesi gerektiği anlamına gelir “number” değerlerin yanında. Örnek olarak, bir milyar Uİnt8 tipi değerler yaklaşık 1 GB sıkıştırılmamış tüketmelidir veya bu CPU kullanımını güçlü bir şekilde etkiler. Verileri kompakt bir şekilde saklamak esastır (herhangi bir “garbage”) sıkıştırılmamış olsa bile, dekompresyon hızı (CPU kullanımı) esas olarak sıkıştırılmamış verilerin hacmine bağlıdır. - -Farklı sütunların değerlerini ayrı ayrı depolayabilen, ancak diğer senaryolar için optimizasyonları nedeniyle analitik sorguları etkili bir şekilde işleyemeyen sistemler olduğu için dikkat çekicidir. Örnekler HBase, BigTable, Cassandra ve HyperTable. Bu sistemlerde, saniyede yüz bin satır civarında verim elde edersiniz, ancak saniyede yüz milyonlarca satır olmaz. - -Clickhouse'un tek bir veritabanı değil, bir veritabanı yönetim sistemi olduğunu da belirtmek gerekir. ClickHouse, çalışma zamanında tablolar ve veritabanları oluşturmak, veri yüklemek ve sunucuyu yeniden yapılandırmadan ve yeniden başlatmadan sorguları çalıştırmaya izin verir. - -## Veri Sıkıştırma {#data-compression} - -Bazı sütun yönelimli DBMSs (InfiniDB CE ve MonetDB) veri sıkıştırma kullanmayın. Bununla birlikte, veri sıkıştırma mükemmel performans elde etmede önemli bir rol oynar. - -## Verilerin Disk Depolama {#disk-storage-of-data} - -Verileri fiziksel olarak birincil anahtara göre sıralamak, belirli değerleri veya değer aralıkları için düşük gecikme süresi ile birkaç düzine milisaniyeden daha az veri ayıklamayı mümkün kılar. Bazı sütun yönelimli Dbms'ler (SAP HANA ve Google PowerDrill gibi) yalnızca RAM'de çalışabilir. Bu yaklaşım, gerçek zamanlı analiz için gerekenden daha büyük bir donanım bütçesinin tahsisini teşvik eder. ClickHouse düzenli sabit diskler üzerinde çalışmak üzere tasarlanmıştır, bu da GB veri depolama başına maliyetin düşük olduğu anlamına gelir, ancak varsa SSD ve ek RAM de tamamen kullanılır. - -## Birden fazla çekirdekte paralel işleme {#parallel-processing-on-multiple-cores} - -Büyük sorgular, geçerli sunucuda bulunan tüm gerekli kaynakları alarak doğal olarak paralelleştirilir. - -## Birden çok sunucuda dağıtılmış işleme {#distributed-processing-on-multiple-servers} - -Yukarıda belirtilen sütunlu Dbms'lerin neredeyse hiçbiri dağıtılmış sorgu işleme desteğine sahip değildir. -Clickhouse'da, veriler farklı parçalarda bulunabilir. Her parça, hata toleransı için kullanılan bir grup kopya olabilir. Tüm kırıklar, kullanıcı için şeffaf olarak paralel bir sorgu çalıştırmak için kullanılır. - -## SQL desteği {#sql-support} - -ClickHouse, çoğu durumda SQL standardına özdeş olan sql'i temel alan bildirime dayalı bir sorgu dilini destekler. -Desteklenen sorgular arasında GROUP BY, ORDER BY, from, ın ve JOIN yan tümceleri ve skaler alt sorgular bulunur. -Bağımlı alt sorgular ve pencere işlevleri desteklenmez. - -## Vektör Motoru {#vector-engine} - -Veriler yalnızca sütunlar tarafından saklanmakla kalmaz, aynı zamanda yüksek CPU verimliliği elde etmeyi sağlayan vektörler (sütunların parçaları) tarafından işlenir. - -## Gerçek zamanlı veri güncellemeleri {#real-time-data-updates} - -ClickHouse, birincil anahtarlı tabloları destekler. Birincil anahtar aralığındaki sorguları hızlı bir şekilde gerçekleştirmek için, veriler birleştirme ağacını kullanarak aşamalı olarak sıralanır. Bu nedenle, veriler sürekli olarak tabloya eklenebilir. Yeni veri Yutulduğunda hiçbir kilit alınır. - -## Dizin {#index} - -Birincil anahtara göre fiziksel olarak sıralanmış bir veriye sahip olmak, belirli değerleri veya değer aralıkları için düşük gecikme süresi ile birkaç düzine milisaniyeden daha az veri çıkarmayı mümkün kılar. - -## Çevrimiçi sorgular için uygundur {#suitable-for-online-queries} - -Düşük gecikme süresi, kullanıcı arayüzü sayfası yüklenirken, sorguların gecikmeden ve önceden bir cevap hazırlamaya çalışmadan işlenebileceği anlamına gelir. Başka bir deyişle, çevrimiçi. - -## Yaklaşık hesaplamalar için destek {#support-for-approximated-calculations} - -ClickHouse performans için doğruluk ticaret için çeşitli yollar sağlar: - -1. Farklı değerler, medyan ve quantiles sayısı yaklaşık hesaplama için toplam işlevleri. -2. Verilerin bir bölümünü (örnek) temel alan bir sorguyu çalıştırmak ve yaklaşık bir sonuç almak. Bu durumda, diskten orantılı olarak daha az veri alınır. -3. Tüm anahtarlar yerine, sınırlı sayıda rastgele anahtar için bir toplama çalıştırma. Verilerde anahtar dağıtımı için belirli koşullar altında, bu daha az kaynak kullanırken makul derecede doğru bir sonuç sağlar. - -## Veri çoğaltma ve Veri Bütünlüğü desteği {#data-replication-and-data-integrity-support} - -ClickHouse zaman uyumsuz çoklu ana çoğaltma kullanır. Kullanılabilir herhangi bir yineleme için yazıldıktan sonra kalan tüm yinelemeler arka planda kendi kopyasını almak. Sistem, farklı yinelemelerde aynı verileri korur. Çoğu arızadan sonra kurtarma, karmaşık durumlarda otomatik olarak veya yarı otomatik olarak gerçekleştirilir. - -Daha fazla bilgi için bölüme bakın [Veri çoğaltma](../engines/table_engines/mergetree_family/replication.md). - -## Dezavantajları olarak kabul edilebilir özellikler {#clickhouse-features-that-can-be-considered-disadvantages} - -1. Tam teşekküllü işlemler yok. -2. Yüksek oranda ve düşük gecikme ile zaten eklenen verileri değiştirme veya silme yeteneği eksikliği. Verileri temizlemek veya değiştirmek için toplu silme ve güncellemeler vardır, örneğin Aşağıdakilere uymak için [GDPR](https://gdpr-info.eu). -3. Seyrek dizin, Clickhouse'u anahtarlarıyla tek satırları almak için nokta sorguları için çok uygun değildir. - -[Orijinal makale](https://clickhouse.tech/docs/en/introduction/distinctive_features/) diff --git a/docs/tr/introduction/history.md b/docs/tr/introduction/history.md index cfc18df2981..8d4e2cc3ed2 100644 --- a/docs/tr/introduction/history.md +++ b/docs/tr/introduction/history.md @@ -1,8 +1,8 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 7 -toc_title: "Tarih\xE7e" +toc_title: Tarih --- # ClickHouse Geçmişi {#clickhouse-history} diff --git a/docs/tr/introduction/index.md b/docs/tr/introduction/index.md index 9691671aefa..3296e8bcaf0 100644 --- a/docs/tr/introduction/index.md +++ b/docs/tr/introduction/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: "Giri\u015F" toc_priority: 1 --- diff --git a/docs/tr/introduction/performance.md b/docs/tr/introduction/performance.md index ce54825af98..ddbd4436748 100644 --- a/docs/tr/introduction/performance.md +++ b/docs/tr/introduction/performance.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 6 toc_title: Performans --- diff --git a/docs/tr/operations/access-rights.md b/docs/tr/operations/access-rights.md new file mode 100644 index 00000000000..87c7bf5a373 --- /dev/null +++ b/docs/tr/operations/access-rights.md @@ -0,0 +1,143 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 48 +toc_title: "Eri\u015Fim Kontrol\xFC ve hesap y\xF6netimi" +--- + +# Erişim Kontrolü ve hesap yönetimi {#access-control} + +ClickHouse dayalı erişim kontrol yönetimini destekler [RBAC](https://en.wikipedia.org/wiki/Role-based_access_control) yaklaşmak. + +ClickHouse erişim varlıkları: +- [Kullanıcı hesabı](#user-account-management) +- [Rol](#role-management) +- [Satır Politikası](#row-policy-management) +- [Ayarlar Profili](#settings-profiles-management) +- [Kota](#quotas-management) + +Kullanarak erişim varlıkları yapılandırabilirsiniz: + +- SQL odaklı iş akışı. + + İhtiyacın var [etkinleştirmek](#enabling-access-control) bu işlevsellik. + +- Hizmetçi [yapılandırma dosyaları](configuration-files.md) `users.xml` ve `config.xml`. + +SQL tabanlı iş akışı kullanmanızı öneririz. Her iki yapılandırma yöntemi de aynı anda çalışır; bu nedenle, hesapları ve erişim haklarını yönetmek için sunucu yapılandırma dosyalarını kullanırsanız, SQL tabanlı iş akışına yumuşak bir şekilde geçebilirsiniz. + +!!! note "Uyarıcı" + Aynı erişim varlığını her iki yapılandırma yöntemiyle aynı anda yönetemezsiniz. + +## Kullanma {#access-control-usage} + +Varsayılan olarak, ClickHouse sunucusu kullanıcı hesabını sağlar `default` SQL güdümlü erişim denetimi ve hesap yönetimi kullanılarak izin verilmez, ancak tüm haklara ve izinlere sahiptir. Bu `default` kullanıcı hesabı, kullanıcı adı tanımlanmadığında, örneğin istemciden girişte veya dağıtılmış sorgularda kullanılır. Dağıtılmış sorgu işleme varsayılan kullanıcı hesabı kullanılır, sunucu veya küme yapılandırması belirtmezse [kullanıcı ve şifre](../engines/table-engines/special/distributed.md) özellikler. + +Sadece ClickHouse kullanmaya başlarsanız, aşağıdaki senaryoyu kullanabilirsiniz: + +1. [Etkinleştirmek](#enabling-access-control) SQL-driven erişim kontrolü ve hesap yönetimi için `default` kullanan. +2. Log underin un underder the `default` kullanıcı hesabı ve gerekli tüm kullanıcıları oluşturun. Yönetici hesabı oluşturmayı unutmayın (`GRANT ALL ON *.* WITH GRANT OPTION TO admin_user_account`). +3. [İzinleri kısıtla](settings/permissions-for-queries.md#permissions_for_queries) için `default` kullanıcı ve devre dışı SQL odaklı erişim kontrolü ve bunun için hesap yönetimi. + +### Mevcut çözümün özellikleri {#access-control-properties} + +- Olmasa bile veritabanları ve tablolar için izinler verebilirsiniz. +- Bir tablo silindiyse, bu tabloya karşılık gelen tüm ayrıcalıklar iptal edilmez. Bu nedenle, daha sonra aynı ada sahip yeni bir tablo oluşturulursa, tüm ayrıcalıklar tekrar gerçek olur. Silinen tabloya karşılık gelen ayrıcalıkları iptal etmek için, örneğin, `REVOKE ALL PRIVILEGES ON db.table FROM ALL` sorgu. +- Ayrıcalıklar için ömür boyu ayarları yoktur. + +## Kullanıcı hesabı {#user-account-management} + +Bir kullanıcı hesabı, Clickhouse'da birisini yetkilendirmeye izin veren bir erişim varlığıdır. Bir kullanıcı hesabı içerir: + +- Kimlik bilgileri. +- [Ayrıcalıklar](../sql-reference/statements/grant.md#grant-privileges) kullanıcı gerçekleştirebilir sorgular kapsamı tanımlayın. +- ClickHouse sunucusuna bağlantının izin verildiği ana bilgisayarlar. +- Verilen ve varsayılan roller. +- Kullanıcının girişinde varsayılan olarak geçerli olan kısıtlamaları olan ayarlar. +- Atanan ayarlar profilleri. + +Bir kullanıcı hesabına ayrıcalıklar tarafından verilebilir [GRANT](../sql-reference/statements/grant.md) sorgu veya atama ile [roller](#role-management). Bir kullanıcının ayrıcalıklarını iptal etmek için, ClickHouse [REVOKE](../sql-reference/statements/revoke.md) sorgu. Bir kullanıcının ayrıcalıklarını listelemek için - [SHOW GRANTS](../sql-reference/statements/show.md#show-grants-statement) deyim. + +Yönetim sorguları: + +- [CREATE USER](../sql-reference/statements/create.md#create-user-statement) +- [ALTER USER](../sql-reference/statements/alter.md#alter-user-statement) +- [DROP USER](../sql-reference/statements/misc.md#drop-user-statement) +- [SHOW CREATE USER](../sql-reference/statements/show.md#show-create-user-statement) + +### Uygulama Ayarları {#access-control-settings-applying} + +Ayarlar farklı şekillerde ayarlanabilir: bir kullanıcı hesabı için, verilen roller ve ayarlar profillerinde. Bir kullanıcı girişinde, farklı erişim varlıklarında bir ayar ayarlanırsa, bu ayarın değeri ve kısıtlamaları aşağıdaki öncelikler tarafından uygulanır (yüksekten düşüğe): + +1. Kullanıcı hesabı ayarı. +2. Kullanıcı hesabının varsayılan rollerinin ayarları. Bazı rollerde bir ayar ayarlanmışsa, uygulama ayarının sırası tanımsızdır. +3. Bir kullanıcıya veya varsayılan rollerine atanan ayarlar profilleri'ndeki ayarlar. Bazı profillerde bir ayar ayarlanmışsa, uygulama ayarı sırası tanımsızdır. +4. Varsayılan olarak tüm sunucuya uygulanan ayarlar veya [varsayılan profil](server-configuration-parameters/settings.md#default-profile). + +## Rol {#role-management} + +Rol, bir kullanıcı hesabına verilebilecek erişim varlıkları için bir kapsayıcıdır. + +Rol içerir: + +- [Ayrıcalıklar](../sql-reference/statements/grant.md#grant-privileges) +- Ayarlar ve kısıtlamalar +- Verilen roller listesi + +Yönetim sorguları: + +- [CREATE ROLE](../sql-reference/statements/create.md#create-role-statement) +- [ALTER ROLE](../sql-reference/statements/alter.md#alter-role-statement) +- [DROP ROLE](../sql-reference/statements/misc.md#drop-role-statement) +- [SET ROLE](../sql-reference/statements/misc.md#set-role-statement) +- [SET DEFAULT ROLE](../sql-reference/statements/misc.md#set-default-role-statement) +- [SHOW CREATE ROLE](../sql-reference/statements/show.md#show-create-role-statement) + +Bir rol için ayrıcalıklar tarafından verilebilir [GRANT](../sql-reference/statements/grant.md) sorgu. Bir rolden ayrıcalıkları iptal etmek için ClickHouse şunları sağlar: [REVOKE](../sql-reference/statements/revoke.md) sorgu. + +## Satır Politikası {#row-policy-management} + +Satır ilkesi, bir kullanıcı veya rol için hangi veya satırların kullanılabilir olduğunu tanımlayan bir filtredir. Satır ilkesi, belirli bir tablo ve bu satır ilkesini kullanması gereken rollerin ve/veya kullanıcıların listesi için filtreler içerir. + +Yönetim sorguları: + +- [CREATE ROW POLICY](../sql-reference/statements/create.md#create-row-policy-statement) +- [ALTER ROW POLICY](../sql-reference/statements/alter.md#alter-row-policy-statement) +- [DROP ROW POLICY](../sql-reference/statements/misc.md#drop-row-policy-statement) +- [SHOW CREATE ROW POLICY](../sql-reference/statements/show.md#show-create-row-policy-statement) + +## Ayarlar Profili {#settings-profiles-management} + +Ayarlar profili bir koleksiyon [ayarlar](settings/index.md). Ayarlar profili, ayarları ve kısıtlamaları ve bu kotanın uygulandığı rollerin ve/veya kullanıcıların listesini içerir. + +Yönetim sorguları: + +- [CREATE SETTINGS PROFILE](../sql-reference/statements/create.md#create-settings-profile-statement) +- [ALTER SETTINGS PROFILE](../sql-reference/statements/alter.md#alter-settings-profile-statement) +- [DROP SETTINGS PROFILE](../sql-reference/statements/misc.md#drop-settings-profile-statement) +- [SHOW CREATE SETTINGS PROFILE](../sql-reference/statements/show.md#show-create-settings-profile-statement) + +## Kota {#quotas-management} + +Kota kaynak kullanımını sınırlar. Görmek [Kotalar](quotas.md). + +Kota, bazı süreler için bir dizi sınır ve bu kotayı kullanması gereken rollerin ve/veya kullanıcıların listesini içerir. + +Yönetim sorguları: + +- [CREATE QUOTA](../sql-reference/statements/create.md#create-quota-statement) +- [ALTER QUOTA](../sql-reference/statements/alter.md#alter-quota-statement) +- [DROP QUOTA](../sql-reference/statements/misc.md#drop-quota-statement) +- [SHOW CREATE QUOTA](../sql-reference/statements/show.md#show-create-quota-statement) + +## SQL tabanlı erişim denetimi ve hesap yönetimini etkinleştirme {#enabling-access-control} + +- Yapılandırmaları depolama için bir dizin Kur. + + ClickHouse, erişim varlık yapılandırmalarını, [access\_control\_path](server-configuration-parameters/settings.md#access_control_path) sunucu yapılandırma parametresi. + +- En az bir kullanıcı hesabı için SQL tabanlı erişim denetimi ve hesap yönetimini etkinleştirin. + + Varsayılan olarak SQL güdümlü erişim denetimi ve hesap yönetimi, tüm kullanıcılar için açık. En az bir kullanıcı yapılandırmanız gerekir `users.xml` yapılandırma dosyası ve atama 1 [access\_management](settings/settings-users.md#access_management-user-setting) ayar. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/tr/operations/access_rights.md b/docs/tr/operations/access_rights.md deleted file mode 100644 index b270c0ecbed..00000000000 --- a/docs/tr/operations/access_rights.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 48 -toc_title: "Eri\u015Fim Haklar\u0131" ---- - -# Erişim Hakları {#access-rights} - -Kullanıcılar ve erişim hakları kullanıcı yapılandırmasında ayarlanır. Bu genellikle `users.xml`. - -Kullanıcılar kaydedilir `users` bölme. İşte bir parçası `users.xml` Dosya: - -``` xml - - - - - - - - - - - - default - - - default - - - - - - - web - default - - test - - - test - - - -``` - -İki kullanıcıdan bir bildirim görebilirsiniz: `default`ve`web`. Ek weledik `web` kullanıcı ayrı ayrı. - -Bu `default` kullanıcı adı geçilmez durumlarda kullanıcı seçilir. Bu `default` kullanıcı, sunucu veya kümenin yapılandırması, sunucu veya kümenin yapılandırılmasını belirtmezse, dağıtılmış sorgu işleme için de kullanılır. `user` ve `password` (on bölümüne bakın [Dağılı](../engines/table_engines/special/distributed.md) motor). - -The user that is used for exchanging information between servers combined in a cluster must not have substantial restrictions or quotas – otherwise, distributed queries will fail. - -Parola, açık metin (önerilmez) veya SHA-256'da belirtilir. Haşhaş tuzlu değil. Bu bağlamda, bu şifreleri potansiyel kötü amaçlı saldırılara karşı güvenlik sağlamak olarak düşünmemelisiniz. Aksine, çalışanlardan korunmak için gereklidir. - -Erişime izin verilen ağların listesi belirtilir. Bu örnekte, her iki kullanıcı için ağ listesi ayrı bir dosyadan yüklenir (`/etc/metrika.xml`) içeren `networks` ikame. İşte bunun bir parçası: - -``` xml - - ... - - ::/64 - 203.0.113.0/24 - 2001:DB8::/32 - ... - - -``` - -Bu ağ listesini doğrudan tanımlayabilirsiniz `users.xml` veya bir dosyada `users.d` dizin (daha fazla bilgi için bölüme bakın “[Yapılandırma dosyaları](configuration_files.md#configuration_files)”). - -Yapılandırma, her yerden erişimin nasıl açılacağını açıklayan yorumları içerir. - -Üretimde kullanım için, sadece belirtin `ip` elemanları (IP adresleri ve maskeleri), kullanıl ,dığından beri `host` ve `hoost_regexp` ekstra gecikmeye neden olabilir. - -Daha sonra kullanıcı ayarları profili belirtilir (bölüme bakın “[Ayarlar profilleri](settings/settings_profiles.md)”. Varsayılan profili belirtebilirsiniz, `default'`. Profilin herhangi bir adı olabilir. Farklı kullanıcılar için aynı profili belirtebilirsiniz. Ayarlar profilinde yazabileceğiniz en önemli şey `readonly=1` sağlar okumak-sadece erişim. Ardından kullanılacak kotayı belirtin (bölüme bakın “[Kotalar](quotas.md#quotas)”). Varsayılan kotayı belirtebilirsiniz: `default`. It is set in the config by default to only count resource usage, without restricting it. The quota can have any name. You can specify the same quota for different users – in this case, resource usage is calculated for each user individually. - -İsteğe bağlı `` bölümünde, kullanıcının erişebileceği veritabanlarının bir listesini de belirtebilirsiniz. Varsayılan olarak, tüm veritabanları kullanıcı tarafından kullanılabilir. Belirtebilirsiniz `default` veritabanı. Bu durumda, kullanıcı varsayılan olarak veritabanına erişim alır. - -İsteğe bağlı `` bölümünde, kullanıcının erişebileceği sözlüklerin bir listesini de belirtebilirsiniz. Varsayılan olarak, tüm sözlükler kullanıcı tarafından kullanılabilir. - -Erişim `system` veritabanı her zaman izin verilir (bu veritabanı sorguları işlemek için kullanıldığından). - -Kullanıcı kullanarak onları tüm veritabanları ve tabloların bir listesini alabilirsiniz `SHOW` tek tek veritabanlarına erişime izin verilmese bile, sorgular veya sistem tabloları. - -Veritabanı erişimi ile ilgili değildir [readonly](settings/permissions_for_queries.md#settings_readonly) ayar. Bir veritabanına tam erişim izni veremezsiniz ve `readonly` başka birine erişim. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/access_rights/) diff --git a/docs/tr/operations/backup.md b/docs/tr/operations/backup.md index 5d1d806e5dd..23544539dac 100644 --- a/docs/tr/operations/backup.md +++ b/docs/tr/operations/backup.md @@ -1,13 +1,13 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 49 toc_title: Veri Yedekleme --- # Veri Yedekleme {#data-backup} -Karşın [çoğalma](../engines/table_engines/mergetree_family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [50 GB'den fazla veri içeren MergeTree benzeri bir motorla tabloları bırakamazsınız](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Ancak, bu önlemler olası tüm davaları kapsamaz ve atlatılabilir. +Karşın [çoğalma](../engines/table-engines/mergetree-family/replication.md) provides protection from hardware failures, it does not protect against human errors: accidental deletion of data, deletion of the wrong table or a table on the wrong cluster, and software bugs that result in incorrect data processing or data corruption. In many cases mistakes like these will affect all replicas. ClickHouse has built-in safeguards to prevent some types of mistakes — for example, by default [50 GB'den fazla veri içeren MergeTree benzeri bir motorla tabloları bırakamazsınız](https://github.com/ClickHouse/ClickHouse/blob/v18.14.18-stable/programs/server/config.xml#L322-L330). Ancak, bu önlemler olası tüm davaları kapsamaz ve atlatılabilir. Olası insan hatalarını etkili bir şekilde azaltmak için, verilerinizi yedeklemek ve geri yüklemek için dikkatli bir şekilde bir strateji hazırlamanız gerekir **önceden**. @@ -22,7 +22,7 @@ Genellikle Clickhouse'a alınan veriler, aşağıdaki gibi bir tür kalıcı sı ## Dosya Sistemi Anlık Görüntüleri {#filesystem-snapshots} -Bazı yerel dosya sistemleri anlık görüntü işlevselliği sağlar (örneğin, [ZFS](https://en.wikipedia.org/wiki/ZFS)), ancak canlı sorguları sunmak için en iyi seçenek olmayabilir. Olası bir çözüm, bu tür dosya sistemi ile ek kopyalar oluşturmak ve bunları [Dağılı](../engines/table_engines/special/distributed.md) için kullanılan tablolar `SELECT` sorgular. Bu tür yinelemelerdeki anlık görüntüler, verileri değiştiren sorguların erişemeyeceği bir yerde olacaktır. Bonus olarak, bu yinelemeler, sunucu başına daha fazla disk eklenmiş özel donanım yapılandırmalarına sahip olabilir ve bu da uygun maliyetli olabilir. +Bazı yerel dosya sistemleri anlık görüntü işlevselliği sağlar (örneğin, [ZFS](https://en.wikipedia.org/wiki/ZFS)), ancak canlı sorguları sunmak için en iyi seçenek olmayabilir. Olası bir çözüm, bu tür dosya sistemi ile ek kopyalar oluşturmak ve bunları [Dağılı](../engines/table-engines/special/distributed.md) için kullanılan tablolar `SELECT` sorgular. Bu tür yinelemelerdeki anlık görüntüler, verileri değiştiren sorguların erişemeyeceği bir yerde olacaktır. Bonus olarak, bu yinelemeler, sunucu başına daha fazla disk eklenmiş özel donanım yapılandırmalarına sahip olabilir ve bu da uygun maliyetli olabilir. ## clickhouse-fotokopi makinesi {#clickhouse-copier} @@ -34,7 +34,7 @@ Daha küçük veri hacimleri için, basit bir `INSERT INTO ... SELECT ...` uzak ClickHouse kullanarak sağlar `ALTER TABLE ... FREEZE PARTITION ...` tablo bölümleri yerel bir kopyasını oluşturmak için sorgu. Bu hardlinks kullanarak uygulanır `/var/lib/clickhouse/shadow/` klasör, bu yüzden genellikle eski veriler için ekstra disk alanı tüketmez. Oluşturulan dosyaların kopyaları ClickHouse server tarafından işlenmez, bu yüzden onları orada bırakabilirsiniz: herhangi bir ek harici sistem gerektirmeyen basit bir yedeklemeniz olacak, ancak yine de donanım sorunlarına eğilimli olacaktır. Bu nedenle, bunları uzaktan başka bir konuma kopyalamak ve ardından yerel kopyaları kaldırmak daha iyidir. Dağıtılmış dosya sistemleri ve nesne depoları bunun için hala iyi bir seçenektir, ancak yeterince büyük kapasiteye sahip normal ekli dosya sunucuları da işe yarayabilir (bu durumda aktarım ağ dosya sistemi veya belki de [rsync](https://en.wikipedia.org/wiki/Rsync)). -Bölüm işlemleriyle ilgili sorgular hakkında daha fazla bilgi için bkz. [ALTER belgeleri](../sql_reference/statements/alter.md#alter_manipulations-with-partitions). +Bölüm işlemleriyle ilgili sorgular hakkında daha fazla bilgi için bkz. [ALTER belgeleri](../sql-reference/statements/alter.md#alter_manipulations-with-partitions). Bu yaklaşımı otomatikleştirmek için üçüncü taraf bir araç kullanılabilir: [clickhouse-yedekleme](https://github.com/AlexAkulov/clickhouse-backup). diff --git a/docs/tr/operations/configuration-files.md b/docs/tr/operations/configuration-files.md new file mode 100644 index 00000000000..59f268981a3 --- /dev/null +++ b/docs/tr/operations/configuration-files.md @@ -0,0 +1,57 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 50 +toc_title: "Yap\u0131land\u0131rma Dosyalar\u0131" +--- + +# Yapılandırma Dosyaları {#configuration_files} + +ClickHouse Çoklu dosya yapılandırma yönetimini destekler. Ana sunucu yapılandırma dosyası `/etc/clickhouse-server/config.xml`. Diğer dosyalar içinde olmalıdır `/etc/clickhouse-server/config.d` dizin. + +!!! note "Not" + Tüm yapılandırma dosyaları XML biçiminde olmalıdır. Ayrıca, genellikle aynı kök öğeye sahip olmalıdırlar ``. + +Ana yapılandırma dosyasında belirtilen bazı ayarlar diğer yapılandırma dosyalarında geçersiz kılınabilir. Bu `replace` veya `remove` bu yapılandırma dosyalarının öğeleri için öznitelikler belirtilebilir. + +Her ikisi de belirtilmezse, yinelenen çocukların değerlerini değiştirerek öğelerin içeriğini yinelemeli olarak birleştirir. + +Eğer `replace` belirtilen, tüm öğeyi belirtilen ile değiştirir. + +Eğer `remove` belirt .ilirse, öğeyi siler. + +Yapılandırma ayrıca tanımlayabilir “substitutions”. Bir öğe varsa `incl` öznitelik, dosyadan karşılık gelen ikame değeri olarak kullanılacaktır. Varsayılan olarak, değiştirmeler ile dosyanın yolu `/etc/metrika.xml`. Bu değiştirilebilir [include\_from](server-configuration-parameters/settings.md#server_configuration_parameters-include_from) sunucu yapılandırmasında öğe. İkame değerleri belirtilen `/yandex/substitution_name` bu dosyadaki öğeler. Belirtilen bir ika Ame halinde `incl` yok, günlüğe kaydedilir. Clickhouse'un eksik değiştirmelerin günlüğe kaydedilmesini önlemek için `optional="true"` öznitelik (örneğin, ayarlar [makrolar](server-configuration-parameters/settings.md)). + +İkame da ZooKeeper yapılabilir. Bunu yapmak için özniteliği belirtin `from_zk = "/path/to/node"`. Eleman değeri, düğümün içeriği ile değiştirilir `/path/to/node` ZooKeeper. Ayrıca ZooKeeper düğümünde bir XML alt ağacının tamamını koyabilirsiniz ve kaynak öğeye tamamen eklenecektir. + +Bu `config.xml` dosya kullanıcı ayarları, profiller ve kotalar ile ayrı bir yapılandırma belirtebilirsiniz. Bu yapılandırmanın göreli yolu, `users_config` öğe. Varsayılan olarak, bu `users.xml`. Eğer `users_config` atlanır, kullanıcı ayarları, profiller ve kotalar doğrudan belirtilir `config.xml`. + +Kullanıcılar yapılandırma benzer ayrı dosyaları içine bölünmüş olabilir `config.xml` ve `config.d/`. +Dizin adı olarak tanımlanır `users_config` olmadan ayarı `.xml` postfix ile birleştirilmiş `.d`. +Dizin `users.d` varsayılan olarak kullanılır, gibi `users_config` varsayılan olarak `users.xml`. +Örneğin, bu gibi her kullanıcı için ayrı yapılandırma dosyasına sahip olabilirsiniz: + +``` bash +$ cat /etc/clickhouse-server/users.d/alice.xml +``` + +``` xml + + + + analytics + + ::/0 + + ... + analytics + + + +``` + +Her yapılandırma dosyası için sunucu da üretir `file-preprocessed.xml` başlatırken dosyalar. Bu dosyalar, tamamlanmış tüm değiştirmeleri ve geçersiz kılmaları içerir ve bunlar bilgi amaçlı kullanım içindir. Zookeeper değiştirmelerin yapılandırma dosyalarında kullanılan ancak ZooKeeper sunucu başlangıcında kullanılabilir değilse, sunucu yapılandırmayı önceden işlenmiş dosyadan yükler. + +Sunucu, yapılandırma dosyalarındaki değişikliklerin yanı sıra, değiştirmeleri ve geçersiz kılmaları gerçekleştirirken kullanılan dosya ve ZooKeeper düğümlerini izler ve anında kullanıcılar ve kümeler için ayarları yeniden yükler. Bu, sunucuyu yeniden başlatmadan kümeyi, kullanıcıları ve ayarlarını değiştirebileceğiniz anlamına gelir. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/tr/operations/configuration_files.md b/docs/tr/operations/configuration_files.md deleted file mode 100644 index fda72e6ba21..00000000000 --- a/docs/tr/operations/configuration_files.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 50 -toc_title: "Yap\u0131land\u0131rma Dosyalar\u0131" ---- - -# Yapılandırma Dosyaları {#configuration_files} - -ClickHouse Çoklu dosya yapılandırma yönetimini destekler. Ana sunucu yapılandırma dosyası `/etc/clickhouse-server/config.xml`. Diğer dosyalar içinde olmalıdır `/etc/clickhouse-server/config.d` dizin. - -!!! note "Not" - Tüm yapılandırma dosyaları XML biçiminde olmalıdır. Ayrıca, genellikle aynı kök öğeye sahip olmalıdırlar ``. - -Ana yapılandırma dosyasında belirtilen bazı ayarlar diğer yapılandırma dosyalarında geçersiz kılınabilir. Bu `replace` veya `remove` bu yapılandırma dosyalarının öğeleri için öznitelikler belirtilebilir. - -Her ikisi de belirtilmezse, yinelenen çocukların değerlerini değiştirerek öğelerin içeriğini yinelemeli olarak birleştirir. - -Eğer `replace` belirtilen, tüm öğeyi belirtilen ile değiştirir. - -Eğer `remove` belirt .ilirse, öğeyi siler. - -Yapılandırma ayrıca tanımlayabilir “substitutions”. Bir öğe varsa `incl` öznitelik, dosyadan karşılık gelen ikame değeri olarak kullanılacaktır. Varsayılan olarak, değiştirmeler ile dosyanın yolu `/etc/metrika.xml`. Bu değiştirilebilir [include\_from](server_configuration_parameters/settings.md#server_configuration_parameters-include_from) sunucu yapılandırmasında öğe. İkame değerleri belirtilen `/yandex/substitution_name` bu dosyadaki öğeler. Belirtilen bir ika Ame halinde `incl` yok, günlüğe kaydedilir. Clickhouse'un eksik değiştirmelerin günlüğe kaydedilmesini önlemek için `optional="true"` öznitelik (örneğin, ayarlar [makrolar](server_configuration_parameters/settings.md)). - -İkame da ZooKeeper yapılabilir. Bunu yapmak için özniteliği belirtin `from_zk = "/path/to/node"`. Eleman değeri, düğümün içeriği ile değiştirilir `/path/to/node` ZooKeeper. Ayrıca ZooKeeper düğümünde bir XML alt ağacının tamamını koyabilirsiniz ve kaynak öğeye tamamen eklenecektir. - -Bu `config.xml` dosya kullanıcı ayarları, profiller ve kotalar ile ayrı bir yapılandırma belirtebilirsiniz. Bu yapılandırmanın göreli yolu, `users_config` öğe. Varsayılan olarak, bu `users.xml`. Eğer `users_config` atlanır, kullanıcı ayarları, profiller ve kotalar doğrudan belirtilir `config.xml`. - -Kullanıcılar yapılandırma benzer ayrı dosyaları içine bölünmüş olabilir `config.xml` ve `config.d/`. -Dizin adı olarak tanımlanır `users_config` olmadan ayarı `.xml` postfix ile birleştirilmiş `.d`. -Dizin `users.d` varsayılan olarak kullanılır, gibi `users_config` varsayılan olarak `users.xml`. -Örneğin, bu gibi her kullanıcı için ayrı yapılandırma dosyasına sahip olabilirsiniz: - -``` bash -$ cat /etc/clickhouse-server/users.d/alice.xml -``` - -``` xml - - - - analytics - - ::/0 - - ... - analytics - - - -``` - -Her yapılandırma dosyası için sunucu da üretir `file-preprocessed.xml` başlatırken dosyalar. Bu dosyalar, tamamlanmış tüm değiştirmeleri ve geçersiz kılmaları içerir ve bunlar bilgi amaçlı kullanım içindir. Zookeeper değiştirmelerin yapılandırma dosyalarında kullanılan ancak ZooKeeper sunucu başlangıcında kullanılabilir değilse, sunucu yapılandırmayı önceden işlenmiş dosyadan yükler. - -Sunucu, yapılandırma dosyalarındaki değişikliklerin yanı sıra, değiştirmeleri ve geçersiz kılmaları gerçekleştirirken kullanılan dosya ve ZooKeeper düğümlerini izler ve anında kullanıcılar ve kümeler için ayarları yeniden yükler. Bu, sunucuyu yeniden başlatmadan kümeyi, kullanıcıları ve ayarlarını değiştirebileceğiniz anlamına gelir. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/configuration_files/) diff --git a/docs/tr/operations/index.md b/docs/tr/operations/index.md index e20eefc1ab0..d3639c42bf1 100644 --- a/docs/tr/operations/index.md +++ b/docs/tr/operations/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Harekat toc_priority: 41 toc_title: "Giri\u015F" @@ -15,14 +15,14 @@ ClickHouse işlemleri kılavuzu aşağıdaki ana bölümlerden oluşur: - [Arıza](troubleshooting.md) - [Kullanım Önerileri](tips.md) - [Güncelleme Prosedürü](update.md) -- [Erişim Hakları](access_rights.md) +- [Erişim Hakları](access-rights.md) - [Veri Yedekleme](backup.md) -- [Yapılandırma Dosyaları](configuration_files.md) +- [Yapılandırma Dosyaları](configuration-files.md) - [Kotalar](quotas.md) -- [Sistem Tabloları](system_tables.md) -- [Sunucu Yapılandırma Parametreleri](server_configuration_parameters/index.md) -- [Donanımınızı ClickHouse İle Test Etme](performance_test.md) +- [Sistem Tabloları](system-tables.md) +- [Sunucu Yapılandırma Parametreleri](server-configuration-parameters/index.md) +- [Donanımınızı ClickHouse İle Test Etme](performance-test.md) - [Ayarlar](settings/index.md) - [Programlar](utilities/index.md) -[Orijinal makale](https://clickhouse.tech/docs/en/operations/) +{## [Orijinal makale](https://clickhouse.tech/docs/en/operations/) ##} diff --git a/docs/tr/operations/monitoring.md b/docs/tr/operations/monitoring.md index eb5b7bd6dc8..bed1b9985ef 100644 --- a/docs/tr/operations/monitoring.md +++ b/docs/tr/operations/monitoring.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 45 toc_title: "\u0130zleme" --- @@ -28,18 +28,18 @@ ClickHouse, donanım kaynaklarının durumunu tek başına izlemez. ClickHouse sunucu kendini devlet izleme için araçlar gömülü vardır. -Sunucu olaylarını izlemek için sunucu günlüklerini kullanın. Görmek [kaydedici](server_configuration_parameters/settings.md#server_configuration_parameters-logger) yapılandırma dosyasının bölümü. +Sunucu olaylarını izlemek için sunucu günlüklerini kullanın. Görmek [kaydedici](server-configuration-parameters/settings.md#server_configuration_parameters-logger) yapılandırma dosyasının bölümü. ClickHouse toplar: - Sunucunun hesaplama kaynaklarını nasıl kullandığına dair farklı metrikler. - Sorgu işleme ile ilgili ortak istatistikler. -Metrikleri şu adreste bulabilirsiniz: [sistem.metrik](../operations/system_tables.md#system_tables-metrics), [sistem.etkinlik](../operations/system_tables.md#system_tables-events), ve [sistem.asynchronous\_metrics](../operations/system_tables.md#system_tables-asynchronous_metrics) Tablolar. +Metrikleri şu adreste bulabilirsiniz: [sistem.metrik](../operations/system-tables.md#system_tables-metrics), [sistem.etkinlik](../operations/system-tables.md#system_tables-events), ve [sistem.asynchronous\_metrics](../operations/system-tables.md#system_tables-asynchronous_metrics) Tablolar. -Clickhouse'u metrikleri dışa aktaracak şekilde yapılandırabilirsiniz [Grafit](https://github.com/graphite-project). Görmek [Graf sectionit bölümü](server_configuration_parameters/settings.md#server_configuration_parameters-graphite) ClickHouse sunucu yapılandırma dosyasında. Metriklerin dışa aktarımını yapılandırmadan önce, grafit'i resmi olarak takip ederek ayarlamanız gerekir [kılavuz](https://graphite.readthedocs.io/en/latest/install.html). +Clickhouse'u metrikleri dışa aktaracak şekilde yapılandırabilirsiniz [Grafit](https://github.com/graphite-project). Görmek [Graf sectionit bölümü](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) ClickHouse sunucu yapılandırma dosyasında. Metriklerin dışa aktarımını yapılandırmadan önce, grafit'i resmi olarak takip ederek ayarlamanız gerekir [kılavuz](https://graphite.readthedocs.io/en/latest/install.html). -Clickhouse'u metrikleri dışa aktaracak şekilde yapılandırabilirsiniz [Prometheus](https://prometheus.io). Görmek [Prometheus bölümü](server_configuration_parameters/settings.md#server_configuration_parameters-prometheus) ClickHouse sunucu yapılandırma dosyasında. Metriklerin dışa aktarılmasını yapılandırmadan önce, prometheus'u yetkililerini takip ederek ayarlamanız gerekir [kılavuz](https://prometheus.io/docs/prometheus/latest/installation/). +Clickhouse'u metrikleri dışa aktaracak şekilde yapılandırabilirsiniz [Prometheus](https://prometheus.io). Görmek [Prometheus bölümü](server-configuration-parameters/settings.md#server_configuration_parameters-prometheus) ClickHouse sunucu yapılandırma dosyasında. Metriklerin dışa aktarılmasını yapılandırmadan önce, prometheus'u yetkililerini takip ederek ayarlamanız gerekir [kılavuz](https://prometheus.io/docs/prometheus/latest/installation/). Ayrıca, http API aracılığıyla sunucu kullanılabilirliğini izleyebilirsiniz. Sen sendd the `HTTP GET` istek için `/ping`. Sunucu mevcutsa, yanıt verir `200 OK`. diff --git a/docs/tr/operations/optimizing-performance/index.md b/docs/tr/operations/optimizing-performance/index.md new file mode 100644 index 00000000000..4457d125c1f --- /dev/null +++ b/docs/tr/operations/optimizing-performance/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Performans\u0131 Optimize Etme" +toc_priority: 52 +--- + + diff --git a/docs/tr/operations/optimizing-performance/sampling-query-profiler.md b/docs/tr/operations/optimizing-performance/sampling-query-profiler.md new file mode 100644 index 00000000000..e73151397e9 --- /dev/null +++ b/docs/tr/operations/optimizing-performance/sampling-query-profiler.md @@ -0,0 +1,64 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Sorgu Profili Olu\u015Fturma" +--- + +# Örnekleme Sorgusu Profiler {#sampling-query-profiler} + +ClickHouse, sorgu yürütülmesini analiz etmeyi sağlayan örnekleme profiler'i çalıştırır. Profiler kullanarak sorgu yürütme sırasında en sık kullanılan kaynak kodu yordamları bulabilirsiniz. Boşta kalma süresi de dahil olmak üzere harcanan CPU zamanını ve duvar saati zamanını izleyebilirsiniz. + +Profiler kullanmak için: + +- Kurulum [trace\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) sunucu yapılandırması bölümü. + + Bu bölüm yapılandırır [trace\_log](../../operations/system-tables.md#system_tables-trace_log) profiler işleyişinin sonuçlarını içeren sistem tablosu. Varsayılan olarak yapılandırılmıştır. Bu tablodaki verilerin yalnızca çalışan bir sunucu için geçerli olduğunu unutmayın. Sunucu yeniden başlatıldıktan sonra ClickHouse tabloyu temizlemez ve depolanan tüm sanal bellek adresi geçersiz hale gelebilir. + +- Kurulum [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) veya [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) ayarlar. Her iki ayar da aynı anda kullanılabilir. + + Bu ayarlar, profiler zamanlayıcılarını yapılandırmanıza izin verir. Bunlar oturum ayarları olduğundan, tüm sunucu, bireysel kullanıcılar veya kullanıcı profilleri, etkileşimli oturumunuz ve her bir sorgu için farklı örnekleme sıklığı elde edebilirsiniz. + +Varsayılan örnekleme frekansı saniyede bir örnektir ve hem CPU hem de gerçek zamanlayıcılar etkindir. Bu frekans, ClickHouse kümesi hakkında yeterli bilgi toplamaya izin verir. Aynı zamanda, bu sıklıkla çalışan profiler, ClickHouse sunucusunun performansını etkilemez. Her bir sorguyu profillemeniz gerekiyorsa, daha yüksek örnekleme frekansı kullanmayı deneyin. + +Analiz etmek `trace_log` sistem tablosu: + +- Yüklemek `clickhouse-common-static-dbg` paket. Görmek [DEB paketlerinden yükleyin](../../getting-started/install.md#install-from-deb-packages). + +- Tarafından iç gözlem işlevlerine izin ver [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) ayar. + + Güvenlik nedenleriyle, iç gözlem işlevleri varsayılan olarak devre dışı bırakılır. + +- Kullan... `addressToLine`, `addressToSymbol` ve `demangle` [iç gözlem fonksiyonları](../../sql-reference/functions/introspection.md) ClickHouse kodu işlev adları ve konumlarını almak için. Bazı sorgu için bir profil almak için, `trace_log` Tablo. Bireysel fonksiyonları bütün yığın izleri ya da veri toplama yapabilirsiniz. + +Görselleştirmeniz gerekiyorsa `trace_log` bilgi, deneyin [flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) ve [speedscope](https://github.com/laplab/clickhouse-speedscope). + +## Örnek {#example} + +Bu örnekte biz: + +- Filtre `trace_log` bir sorgu tanımlayıcısı ve geçerli tarihe göre veri. + +- Yığın izleme ile toplama. + +- İç gözlem işlevlerini kullanarak, bir rapor alacağız: + + - Sembollerin isimleri ve karşılık gelen kaynak kodu işlevleri. + - Bu işlevlerin kaynak kodu konumları. + + + +``` sql +SELECT + count(), + arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym +FROM system.trace_log +WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) +GROUP BY trace +ORDER BY count() DESC +LIMIT 10 +``` + +``` text +{% include "examples/sampling_query_profiler_result.txt" %} +``` diff --git a/docs/tr/operations/optimizing_performance/index.md b/docs/tr/operations/optimizing_performance/index.md deleted file mode 100644 index 9d39c082a98..00000000000 --- a/docs/tr/operations/optimizing_performance/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "Performans\u0131 Optimize Etme" -toc_priority: 52 ---- - - diff --git a/docs/tr/operations/optimizing_performance/sampling_query_profiler.md b/docs/tr/operations/optimizing_performance/sampling_query_profiler.md deleted file mode 100644 index 120df6be7a6..00000000000 --- a/docs/tr/operations/optimizing_performance/sampling_query_profiler.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 54 -toc_title: "Sorgu Profili Olu\u015Fturma" ---- - -# Örnekleme Sorgusu Profiler {#sampling-query-profiler} - -ClickHouse, sorgu yürütülmesini analiz etmeyi sağlayan örnekleme profiler'i çalıştırır. Profiler kullanarak sorgu yürütme sırasında en sık kullanılan kaynak kodu yordamları bulabilirsiniz. Boşta kalma süresi de dahil olmak üzere harcanan CPU zamanını ve duvar saati zamanını izleyebilirsiniz. - -Profiler kullanmak için: - -- Kurulum [trace\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) sunucu yapılandırması bölümü. - - Bu bölüm yapılandırır [trace\_log](../../operations/system_tables.md#system_tables-trace_log) profiler işleyişinin sonuçlarını içeren sistem tablosu. Varsayılan olarak yapılandırılmıştır. Bu tablodaki verilerin yalnızca çalışan bir sunucu için geçerli olduğunu unutmayın. Sunucu yeniden başlatıldıktan sonra ClickHouse tabloyu temizlemez ve depolanan tüm sanal bellek adresi geçersiz hale gelebilir. - -- Kurulum [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) veya [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) ayarlar. Her iki ayar da aynı anda kullanılabilir. - - Bu ayarlar, profiler zamanlayıcılarını yapılandırmanıza izin verir. Bunlar oturum ayarları olduğundan, tüm sunucu, bireysel kullanıcılar veya kullanıcı profilleri, etkileşimli oturumunuz ve her bir sorgu için farklı örnekleme sıklığı elde edebilirsiniz. - -Varsayılan örnekleme frekansı saniyede bir örnektir ve hem CPU hem de gerçek zamanlayıcılar etkindir. Bu frekans, ClickHouse kümesi hakkında yeterli bilgi toplamaya izin verir. Aynı zamanda, bu sıklıkla çalışan profiler, ClickHouse sunucusunun performansını etkilemez. Her bir sorguyu profillemeniz gerekiyorsa, daha yüksek örnekleme frekansı kullanmayı deneyin. - -Analiz etmek `trace_log` sistem tablosu: - -- Yüklemek `clickhouse-common-static-dbg` paket. Görmek [DEB paketlerinden yükleyin](../../getting_started/install.md#install-from-deb-packages). - -- Tarafından iç gözlem işlevlerine izin ver [allow\_introspection\_functions](../settings/settings.md#settings-allow_introspection_functions) ayar. - - Güvenlik nedenleriyle, iç gözlem işlevleri varsayılan olarak devre dışı bırakılır. - -- Kullan... `addressToLine`, `addressToSymbol` ve `demangle` [iç gözlem fonksiyonları](../../sql_reference/functions/introspection.md) ClickHouse kodu işlev adları ve konumlarını almak için. Bazı sorgu için bir profil almak için, `trace_log` Tablo. Bireysel fonksiyonları bütün yığın izleri ya da veri toplama yapabilirsiniz. - -Görselleştirmeniz gerekiyorsa `trace_log` bilgi, deneyin [flamegraph](../../interfaces/third-party/gui/#clickhouse-flamegraph) ve [speedscope](https://github.com/laplab/clickhouse-speedscope). - -## Örnek {#example} - -Bu örnekte biz: - -- Filtre `trace_log` bir sorgu tanımlayıcısı ve geçerli tarihe göre veri. - -- Yığın izleme ile toplama. - -- İç gözlem işlevlerini kullanarak, bir rapor alacağız: - - - Sembollerin isimleri ve karşılık gelen kaynak kodu işlevleri. - - Bu işlevlerin kaynak kodu konumları. - - - -``` sql -SELECT - count(), - arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym -FROM system.trace_log -WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today()) -GROUP BY trace -ORDER BY count() DESC -LIMIT 10 -``` - -``` text -{% include "examples/sampling_query_profiler_result.txt" %} -``` diff --git a/docs/tr/operations/performance-test.md b/docs/tr/operations/performance-test.md new file mode 100644 index 00000000000..498f3851861 --- /dev/null +++ b/docs/tr/operations/performance-test.md @@ -0,0 +1,82 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 54 +toc_title: "Donan\u0131m Test" +--- + +# Donanımınızı ClickHouse ile Test etme {#how-to-test-your-hardware-with-clickhouse} + +Bu talimat ile ClickHouse paketlerinin kurulumu olmadan herhangi bir sunucuda temel ClickHouse performans testi çalıştırabilirsiniz. + +1. Gitmek “commits” sayfa: https://github.com/ClickHouse/ClickHouse/commits/master + +2. Yeşil ile ilk yeşil onay işareti veya kırmızı Haç tıklayın “ClickHouse Build Check” ve tıklayın “Details” link yakın “ClickHouse Build Check”. Bazı taahhütlerde böyle bir bağlantı yoktur, örneğin belgelerle taahhüt eder. Bu durumda, bu bağlantıya sahip en yakın taahhüt seçin. + +3. Bağlantıyı kopyala “clickhouse” amd64 veya aarch64 için ikili. + +4. sunucuya ssh ve wget ile indirin: + + + + # For amd64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse + # For aarch64: + wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse + # Then do: + chmod a+x clickhouse + +1. İndir yapılandırmaları: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml + mkdir config.d + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml + +1. Ben benchmarkch filesmark dosyaları indir: + + + + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh + chmod a+x benchmark-new.sh + wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql + +1. İndir göre test verileri [Üye.Metrica veri kümesi](../getting-started/example-datasets/metrica.md) talimat (“hits” 100 milyon satır içeren tablo). + + + + wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz + tar xvf hits_100m_obfuscated_v1.tar.xz -C . + mv hits_100m_obfuscated_v1/* . + +1. Sunucuyu Çalıştır: + + + + ./clickhouse server + +1. Verileri kontrol edin: başka bir terminaldeki sunucuya ssh + + + + ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" + 100000000 + +1. Edit the benchmark-new.sh, değişim `clickhouse-client` -e doğru `./clickhouse client` ve Ekle `–-max_memory_usage 100000000000` parametre. + + + + mcedit benchmark-new.sh + +1. Ben benchmarkch runmark Çalıştır: + + + + ./benchmark-new.sh hits_100m_obfuscated + +1. Donanım yapılandırmanız hakkındaki numaraları ve bilgileri şu adrese gönderin clickhouse-feedback@yandex-team.com + +Tüm sonuçlar burada yayınlanmaktadır: https://clickhouse.teknoloji / ben benchmarkch /mark / donanım/ diff --git a/docs/tr/operations/performance_test.md b/docs/tr/operations/performance_test.md deleted file mode 100644 index dbfbc39998d..00000000000 --- a/docs/tr/operations/performance_test.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 54 -toc_title: "Donan\u0131m Test" ---- - -# Donanımınızı ClickHouse ile Test etme {#how-to-test-your-hardware-with-clickhouse} - -Bu talimat ile ClickHouse paketlerinin kurulumu olmadan herhangi bir sunucuda temel ClickHouse performans testi çalıştırabilirsiniz. - -1. Gitmek “commits” sayfa: https://github.com/ClickHouse/ClickHouse/commits/master - -2. Yeşil ile ilk yeşil onay işareti veya kırmızı Haç tıklayın “ClickHouse Build Check” ve tıklayın “Details” link yakın “ClickHouse Build Check”. Bazı taahhütlerde böyle bir bağlantı yoktur, örneğin belgelerle taahhüt eder. Bu durumda, bu bağlantıya sahip en yakın taahhüt seçin. - -3. Bağlantıyı kopyala “clickhouse” amd64 veya aarch64 için ikili. - -4. sunucuya ssh ve wget ile indirin: - - - - # For amd64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578163263_binary/clickhouse - # For aarch64: - wget https://clickhouse-builds.s3.yandex.net/0/00ba767f5d2a929394ea3be193b1f79074a1c4bc/1578161264_binary/clickhouse - # Then do: - chmod a+x clickhouse - -1. İndir yapılandırmaları: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/users.xml - mkdir config.d - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/path.xml -O config.d/path.xml - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/programs/server/config.d/log_to_console.xml -O config.d/log_to_console.xml - -1. Ben benchmarkch filesmark dosyaları indir: - - - - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/benchmark-new.sh - chmod a+x benchmark-new.sh - wget https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/benchmark/clickhouse/queries.sql - -1. İndir göre test verileri [Üye.Metrica veri kümesi](../getting_started/example_datasets/metrica.md) talimat (“hits” 100 milyon satır içeren tablo). - - - - wget https://clickhouse-datasets.s3.yandex.net/hits/partitions/hits_100m_obfuscated_v1.tar.xz - tar xvf hits_100m_obfuscated_v1.tar.xz -C . - mv hits_100m_obfuscated_v1/* . - -1. Sunucuyu Çalıştır: - - - - ./clickhouse server - -1. Verileri kontrol edin: başka bir terminaldeki sunucuya ssh - - - - ./clickhouse client --query "SELECT count() FROM hits_100m_obfuscated" - 100000000 - -1. Edit the benchmark-new.sh, değişim `clickhouse-client` -e doğru `./clickhouse client` ve Ekle `–-max_memory_usage 100000000000` parametre. - - - - mcedit benchmark-new.sh - -1. Ben benchmarkch runmark Çalıştır: - - - - ./benchmark-new.sh hits_100m_obfuscated - -1. Donanım yapılandırmanız hakkındaki numaraları ve bilgileri şu adrese gönderin clickhouse-feedback@yandex-team.com - -Tüm sonuçlar burada yayınlanmaktadır: https://clickhouse.teknoloji / benchmark\_hardware.html diff --git a/docs/tr/operations/quotas.md b/docs/tr/operations/quotas.md index e6b1de2b7f8..b646e47e50c 100644 --- a/docs/tr/operations/quotas.md +++ b/docs/tr/operations/quotas.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 51 toc_title: Kotalar --- diff --git a/docs/tr/operations/requirements.md b/docs/tr/operations/requirements.md index c77159d11d7..c45fc93e068 100644 --- a/docs/tr/operations/requirements.md +++ b/docs/tr/operations/requirements.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 44 toc_title: Gereksinimler --- @@ -24,9 +24,9 @@ Gerekli RAM hacmi Aşağıdakilere bağlıdır: - Sorguların karmaşıklığı. - Sorgularda işlenen veri miktarı. -Gerekli RAM hacmini hesaplamak için, aşağıdakiler için geçici verilerin boyutunu tahmin etmelisiniz [GROUP BY](../sql_reference/statements/select.md#select-group-by-clause), [DISTINCT](../sql_reference/statements/select.md#select-distinct), [JOIN](../sql_reference/statements/select.md#select-join) ve kullandığınız diğer işlemler. +Gerekli RAM hacmini hesaplamak için, aşağıdakiler için geçici verilerin boyutunu tahmin etmelisiniz [GROUP BY](../sql-reference/statements/select/group-by.md#select-group-by-clause), [DISTINCT](../sql-reference/statements/select/distinct.md#select-distinct), [JOIN](../sql-reference/statements/select/join.md#select-join) ve kullandığınız diğer işlemler. -ClickHouse geçici veriler için harici bellek kullanabilirsiniz. Görmek [Harici bellekte grupla](../sql_reference/statements/select.md#select-group-by-in-external-memory) ayrıntılar için. +ClickHouse geçici veriler için harici bellek kullanabilirsiniz. Görmek [Harici bellekte grupla](../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory) ayrıntılar için. ## Takas Dosyası {#swap-file} @@ -58,4 +58,4 @@ Ağ bant genişliği, büyük miktarda Ara veriyle dağıtılmış sorguları i ClickHouse öncelikle Linux işletim sistemleri ailesi için geliştirilmiştir. Önerilen Linux dağıtımı Ubuntu'dur. Bu `tzdata` paket sisteme kurulmalıdır. -ClickHouse diğer işletim sistemi ailelerinde de çalışabilir. Ayrıntıları görün [Başlarken](../getting_started/index.md) belgelerin bölümü. +ClickHouse diğer işletim sistemi ailelerinde de çalışabilir. Ayrıntıları görün [Başlarken](../getting-started/index.md) belgelerin bölümü. diff --git a/docs/tr/operations/server-configuration-parameters/index.md b/docs/tr/operations/server-configuration-parameters/index.md new file mode 100644 index 00000000000..0531896bf39 --- /dev/null +++ b/docs/tr/operations/server-configuration-parameters/index.md @@ -0,0 +1,19 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Sunucu Yap\u0131land\u0131rma Parametreleri" +toc_priority: 54 +toc_title: "Giri\u015F" +--- + +# Sunucu Yapılandırma Parametreleri {#server-settings} + +Bu bölüm, oturum veya sorgu düzeyinde değiştirilemeyen sunucu ayarlarının açıklamalarını içerir. + +Bu ayarlar saklanır `config.xml` ClickHouse sunucusunda dosya. + +Diğer ayarlar aşağıda açıklanmıştır “[Ayarlar](../settings/index.md#session-settings-intro)” bölme. + +Ayarları incelemeden önce, [Yapılandırma dosyaları](../configuration-files.md#configuration_files) bölüm ve ikame kullanımı (not `incl` ve `optional` öznitelik). + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/tr/operations/server-configuration-parameters/settings.md b/docs/tr/operations/server-configuration-parameters/settings.md new file mode 100644 index 00000000000..cc5ef3e8e21 --- /dev/null +++ b/docs/tr/operations/server-configuration-parameters/settings.md @@ -0,0 +1,906 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 57 +toc_title: "Sunucu Ayarlar\u0131" +--- + +# Sunucu Ayarları {#server-settings} + +## buıltın\_dıctıonarıes\_reload\_ınterval {#builtin-dictionaries-reload-interval} + +Dahili sözlükleri yeniden yüklemeden önce saniye cinsinden Aralık. + +ClickHouse, her x saniyede bir yerleşik sözlükleri yeniden yükler. Bu, sözlükleri düzenlemeyi mümkün kılar “on the fly” sunucuyu yeniden başlatmadan. + +Varsayılan değer: 3600. + +**Örnek** + +``` xml +3600 +``` + +## sıkıştırma {#server-settings-compression} + +İçin veri sıkıştırma ayarları [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)- motor masaları. + +!!! warning "Uyarıcı" + Sadece ClickHouse kullanmaya başladıysanız kullanmayın. + +Yapılandırma şablonu: + +``` xml + + + ... + ... + ... + + ... + +``` + +`` alanlar: + +- `min_part_size` – The minimum size of a data part. +- `min_part_size_ratio` – The ratio of the data part size to the table size. +- `method` – Compression method. Acceptable values: `lz4` veya `zstd`. + +Birden fazla yapılandırabilirsiniz `` bölmeler. + +Koşullar yerine getirildiğinde eylemler: + +- Bir veri parçası bir koşul kümesiyle eşleşirse, ClickHouse belirtilen sıkıştırma yöntemini kullanır. +- Bir veri parçası birden çok koşul kümesiyle eşleşirse, ClickHouse ilk eşleşen koşul kümesini kullanır. + +Bir veri bölümü için herhangi bir koşul karşılanmazsa, ClickHouse `lz4` sıkıştırma. + +**Örnek** + +``` xml + + + 10000000000 + 0.01 + zstd + + +``` + +## default\_database {#default-database} + +Varsayılan veritabanı. + +Veritabanlarının bir listesini almak için [SHOW DATABASES](../../sql-reference/statements/show.md#show-databases) sorgu. + +**Örnek** + +``` xml +default +``` + +## default\_profile {#default-profile} + +Varsayılan ayarlar profili. + +Ayarlar profilleri parametrede belirtilen dosyada bulunur `user_config`. + +**Örnek** + +``` xml +default +``` + +## dictionaries\_config {#server_configuration_parameters-dictionaries_config} + +Dış sözlükler için yapılandırma dosyasının yolu. + +Yol: + +- Mutlak yolu veya sunucu yapılandırma dosyasına göre yolu belirtin. +- Yol joker karakterler içerebilir \* ve ?. + +Ayrıca bakınız “[Dış söz dictionarieslükler](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md)”. + +**Örnek** + +``` xml +*_dictionary.xml +``` + +## dictionaries\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} + +Sözlüklerin tembel yüklenmesi. + +Eğer `true`, sonra her sözlük ilk kullanımda oluşturulur. Sözlük oluşturma başarısız olursa, sözlüğü kullanan işlev bir özel durum atar. + +Eğer `false`, sunucu başladığında tüm sözlükler oluşturulur ve bir hata varsa, sunucu kapanır. + +Varsayılan değer `true`. + +**Örnek** + +``` xml +true +``` + +## format\_schema\_path {#server_configuration_parameters-format_schema_path} + +Dizin için şemalar gibi giriş verileri için şemaları ile yolu [CapnProto](../../interfaces/formats.md#capnproto) biçimli. + +**Örnek** + +``` xml + + format_schemas/ +``` + +## grafit {#server_configuration_parameters-graphite} + +Veri gönderme [Grafit](https://github.com/graphite-project). + +Ayarlar: + +- host – The Graphite server. +- port – The port on the Graphite server. +- interval – The interval for sending, in seconds. +- timeout – The timeout for sending data, in seconds. +- root\_path – Prefix for keys. +- metrics – Sending data from the [sistem.metrik](../../operations/system-tables.md#system_tables-metrics) Tablo. +- events – Sending deltas data accumulated for the time period from the [sistem.etkinlik](../../operations/system-tables.md#system_tables-events) Tablo. +- events\_cumulative – Sending cumulative data from the [sistem.etkinlik](../../operations/system-tables.md#system_tables-events) Tablo. +- asynchronous\_metrics – Sending data from the [sistem.asynchronous\_metrics](../../operations/system-tables.md#system_tables-asynchronous_metrics) Tablo. + +Birden fazla yapılandırabilirsiniz `` yanlar. Örneğin, bunu farklı aralıklarla farklı veri göndermek için kullanabilirsiniz. + +**Örnek** + +``` xml + + localhost + 42000 + 0.1 + 60 + one_min + true + true + false + true + +``` + +## graphite\_rollup {#server_configuration_parameters-graphite-rollup} + +Grafit için inceltme verileri için ayarlar. + +Daha fazla ayrıntı için bkz. [Graphıtemergetree](../../engines/table-engines/mergetree-family/graphitemergetree.md). + +**Örnek** + +``` xml + + + max + + 0 + 60 + + + 3600 + 300 + + + 86400 + 3600 + + + +``` + +## http\_port/https\_port {#http-porthttps-port} + +Http(ler) üzerinden sunucuya bağlanmak için bağlantı noktası. + +Eğer `https_port` belirtilen, [openSSL](#server_configuration_parameters-openssl) yapılandırılmalıdır. + +Eğer `http_port` belirtilmişse, OpenSSL yapılandırması ayarlanmış olsa bile göz ardı edilir. + +**Örnek** + +``` xml +9999 +``` + +## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} + +ClickHouse HTTP (s) sunucusuna eriştiğinizde varsayılan olarak gösterilen sayfa. +Varsayılan değer “Ok.” (sonunda bir çizgi besleme ile) + +**Örnek** + +Açıyor `https://tabix.io/` eriş whenirken `http://localhost: http_port`. + +``` xml + +
]]> +
+``` + +## include\_from {#server_configuration_parameters-include_from} + +Değiştirmeleri ile dosyanın yolu. + +Daha fazla bilgi için bölüme bakın “[Yapılandırma dosyaları](../configuration-files.md#configuration_files)”. + +**Örnek** + +``` xml +/etc/metrica.xml +``` + +## ınterserver\_http\_port {#interserver-http-port} + +ClickHouse sunucuları arasında veri alışverişi için bağlantı noktası. + +**Örnek** + +``` xml +9009 +``` + +## ınterserver\_http\_host {#interserver-http-host} + +Bu sunucuya erişmek için diğer sunucular tarafından kullanılabilecek ana bilgisayar adı. + +Eğer ihmal edilirse, aynı şekilde tanımlanır `hostname-f` komut. + +Belirli bir ağ arayüzünden kopmak için kullanışlıdır. + +**Örnek** + +``` xml +example.yandex.ru +``` + +## ınterserver\_http\_credentials {#server-settings-interserver-http-credentials} + +Sırasında kimlik doğrulaması için kullanılan kullanıcı adı ve şifre [çoğalma](../../engines/table-engines/mergetree-family/replication.md) çoğaltılan \* motorlarla. Bu kimlik bilgileri yalnızca yinelemeler arasındaki iletişim için kullanılır ve ClickHouse istemcileri için kimlik bilgileri ile ilgisizdir. Sunucu, yinelemeleri bağlamak için bu kimlik bilgilerini denetliyor ve diğer yinelemelere bağlanırken aynı kimlik bilgilerini kullanıyor. Bu nedenle, bu kimlik bilgileri kümedeki tüm yinelemeler için aynı şekilde ayarlanmalıdır. +Varsayılan olarak, kimlik doğrulama kullanılmaz. + +Bu bölüm aşağıdaki parametreleri içerir: + +- `user` — username. +- `password` — password. + +**Örnek** + +``` xml + + admin + 222 + +``` + +## keep\_alive\_timeout {#keep-alive-timeout} + +ClickHouse bağlantıyı kapatmadan önce gelen istekleri bekler saniye sayısı. Varsayılan 3 saniye. + +**Örnek** + +``` xml +3 +``` + +## listen\_host {#server_configuration_parameters-listen_host} + +İsteklerin gelebileceği ana bilgisayarlarda kısıtlama. Sunucunun hepsini yanıtlamasını istiyorsanız, belirtin `::`. + +Örnekler: + +``` xml +::1 +127.0.0.1 +``` + +## kaydedici {#server_configuration_parameters-logger} + +Günlük ayarları. + +Anahtarlar: + +- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. +- log – The log file. Contains all the entries according to `level`. +- errorlog – Error log file. +- size – Size of the file. Applies to `log`ve`errorlog`. Dosya ulaştıktan sonra `size`, ClickHouse arşivleri ve yeniden adlandırır ve onun yerine yeni bir günlük dosyası oluşturur. +- count – The number of archived log files that ClickHouse stores. + +**Örnek** + +``` xml + + trace + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 10 + +``` + +Syslog yazma da desteklenmektedir. Yapılandırma örneği: + +``` xml + + 1 + +
syslog.remote:10514
+ myhost.local + LOG_LOCAL6 + syslog +
+
+``` + +Anahtarlar: + +- use\_syslog — Required setting if you want to write to the syslog. +- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. +- hostname — Optional. The name of the host that logs are sent from. +- facility — [Syslog tesisi anahtar sözcüğü](https://en.wikipedia.org/wiki/Syslog#Facility) ile büyük harf inlerle “LOG\_” önek: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` vb.). + Varsayılan değer: `LOG_USER` eğer `address` belirtilen, `LOG_DAEMON otherwise.` +- format – Message format. Possible values: `bsd` ve `syslog.` + +## makrolar {#macros} + +Çoğaltılmış tablolar için parametre değiştirmeleri. + +Çoğaltılmış tablolar kullanılmazsa atlanabilir. + +Daha fazla bilgi için bölüme bakın “[Çoğaltılmış tablolar oluşturma](../../engines/table-engines/mergetree-family/replication.md)”. + +**Örnek** + +``` xml + +``` + +## mark\_cache\_size {#server-mark-cache-size} + +Tablo motorları tarafından kullanılan işaretlerin önbelleğinin yaklaşık boyutu (bayt cinsinden) [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) aile. + +Önbellek sunucu için paylaşılır ve bellek gerektiği gibi ayrılır. Önbellek boyutu en az 5368709120 olmalıdır. + +**Örnek** + +``` xml +5368709120 +``` + +## max\_concurrent\_queries {#max-concurrent-queries} + +Aynı anda işlenen isteklerin maksimum sayısı. + +**Örnek** + +``` xml +100 +``` + +## max\_connections {#max-connections} + +En fazla gelen bağlantı sayısı. + +**Örnek** + +``` xml +4096 +``` + +## max\_open\_files {#max-open-files} + +Maksimum açık dosya sayısı. + +Varsayılan olarak: `maximum`. + +Biz beri Mac OS X bu seçeneği kullanmanızı öneririz `getrlimit()` işlev yanlış bir değer döndürür. + +**Örnek** + +``` xml +262144 +``` + +## max\_table\_size\_to\_drop {#max-table-size-to-drop} + +Tabloları silme konusunda kısıtlama. + +Eğer bir boyutu [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) tablo aşıyor `max_table_size_to_drop` (bayt cinsinden), bir bırakma sorgusu kullanarak silemezsiniz. + +ClickHouse sunucusunu yeniden başlatmadan tabloyu silmeniz gerekiyorsa, `/flags/force_drop_table` dosya ve bırakma sorgusunu çalıştırın. + +Varsayılan değer: 50 GB. + +0 değeri, herhangi bir kısıtlama olmaksızın tüm tabloları silebileceğiniz anlamına gelir. + +**Örnek** + +``` xml +0 +``` + +## merge\_tree {#server_configuration_parameters-merge_tree} + +Tablolar için ince ayar [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). + +Daha fazla bilgi için bkz: MergeTreeSettings.h başlık dosyası. + +**Örnek** + +``` xml + + 5 + +``` + +## openSSL {#server_configuration_parameters-openssl} + +SSL istemci / sunucu yapılandırması. + +SSL desteği tarafından sağlanmaktadır `libpoco` kitaplık. Arayüz dosyada açıklanmıştır [SSLManager.sa](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) + +Sunucu/istemci ayarları için tuşlar: + +- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. +- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` sertifika içerir. +- caConfig – The path to the file or directory that contains trusted root certificates. +- verificationMode – The method for checking the node's certificates. Details are in the description of the [Bağlam](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) sınıf. Olası değerler: `none`, `relaxed`, `strict`, `once`. +- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. +- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| +- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. +- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Kabul edilebilir değerler: `true`, `false`. +- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. Bu parametre her zaman sunucu oturumu önbelleğe alır ve istemci önbellekleme istedi, sorunları önlemek yardımcı olduğundan önerilir. Varsayılan değer: `${application.name}`. +- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. +- sessionTimeout – Time for caching the session on the server. +- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. +- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. +- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. +- fips – Activates OpenSSL FIPS mode. Supported if the library's OpenSSL version supports FIPS. +- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. +- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . +- disableProtocols – Protocols that are not allowed to use. +- preferServerCiphers – Preferred server ciphers on the client. + +**Ayarlar örneği:** + +``` xml + + + + /etc/clickhouse-server/server.crt + /etc/clickhouse-server/server.key + + /etc/clickhouse-server/dhparam.pem + none + true + true + sslv2,sslv3 + true + + + true + true + sslv2,sslv3 + true + + + + RejectCertificateHandler + + + +``` + +## part\_log {#server_configuration_parameters-part-log} + +İlişkili olayları günlüğe kaydetme [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). Örneğin, veri ekleme veya birleştirme. Birleştirme algoritmalarını simüle etmek ve özelliklerini karşılaştırmak için günlüğü kullanabilirsiniz. Birleştirme işlemini görselleştirebilirsiniz. + +Sorgular günlüğe kaydedilir [sistem.part\_log](../../operations/system-tables.md#system_tables-part-log) tablo, ayrı bir dosyada değil. Bu tablonun adını aşağıdaki tabloda yapılandırabilirsiniz: `table` parametre (aşağıya bakınız). + +Günlüğü yapılandırmak için aşağıdaki parametreleri kullanın: + +- `database` – Name of the database. +- `table` – Name of the system table. +- `partition_by` – Sets a [özel bölümleme anahtarı](../../engines/table-engines/mergetree-family/custom-partitioning-key.md). +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +**Örnek** + +``` xml + + system + part_log
+ toMonday(event_date) + 7500 +
+``` + +## yol {#server_configuration_parameters-path} + +Veri içeren dizinin yolu. + +!!! note "Not" + Sondaki eğik çizgi zorunludur. + +**Örnek** + +``` xml +/var/lib/clickhouse/ +``` + +## prometheus {#server_configuration_parameters-prometheus} + +Kazıma için metrik verilerini açığa çıkarma [Prometheus](https://prometheus.io). + +Ayarlar: + +- `endpoint` – HTTP endpoint for scraping metrics by prometheus server. Start from ‘/’. +- `port` – Port for `endpoint`. +- `metrics` – Flag that sets to expose metrics from the [sistem.metrik](../system-tables.md#system_tables-metrics) Tablo. +- `events` – Flag that sets to expose metrics from the [sistem.etkinlik](../system-tables.md#system_tables-events) Tablo. +- `asynchronous_metrics` – Flag that sets to expose current metrics values from the [sistem.asynchronous\_metrics](../system-tables.md#system_tables-asynchronous_metrics) Tablo. + +**Örnek** + +``` xml + + /metrics + 8001 + true + true + true + +``` + +## query\_log {#server_configuration_parameters-query-log} + +İle alınan günlük sorgu settinglarının ayarlanması [log\_queries = 1](../settings/settings.md) ayar. + +Sorgular günlüğe kaydedilir [sistem.query\_log](../../operations/system-tables.md#system_tables-query_log) tablo, ayrı bir dosyada değil. Tablonun adını değiştirebilirsiniz. `table` parametre (aşağıya bakınız). + +Günlüğü yapılandırmak için aşağıdaki parametreleri kullanın: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [özel bölümleme anahtarı](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) bir masa için. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +Tablo yoksa, ClickHouse bunu oluşturur. ClickHouse sunucusu güncelleştirildiğinde sorgu günlüğünün yapısı değiştiyse, eski yapıya sahip tablo yeniden adlandırılır ve otomatik olarak yeni bir tablo oluşturulur. + +**Örnek** + +``` xml + + system + query_log
+ toMonday(event_date) + 7500 +
+``` + +## query\_thread\_log {#server_configuration_parameters-query-thread-log} + +İle alınan sorguların günlük iş parçacıklarının ayarlanması [log\_query\_threads = 1](../settings/settings.md#settings-log-query-threads) ayar. + +Sorgular günlüğe kaydedilir [sistem.query\_thread\_log](../../operations/system-tables.md#system_tables-query-thread-log) tablo, ayrı bir dosyada değil. Tablonun adını değiştirebilirsiniz. `table` parametre (aşağıya bakınız). + +Günlüğü yapılandırmak için aşağıdaki parametreleri kullanın: + +- `database` – Name of the database. +- `table` – Name of the system table the queries will be logged in. +- `partition_by` – Sets a [özel bölümleme anahtarı](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) bir sistem tablosu için. +- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. + +Tablo yoksa, ClickHouse bunu oluşturur. Sorgu iş parçacığı günlüğü yapısını değiştirdiyseniz ClickHouse sunucu güncelleştirildi, tablo eski yapısı ile yeniden adlandırılır ve yeni bir tablo otomatik olarak oluşturulur. + +**Örnek** + +``` xml + + system + query_thread_log
+ toMonday(event_date) + 7500 +
+``` + +## trace\_log {#server_configuration_parameters-trace_log} + +İçin ayarlar [trace\_log](../../operations/system-tables.md#system_tables-trace_log) sistem tablosu çalışması. + +Parametre: + +- `database` — Database for storing a table. +- `table` — Table name. +- `partition_by` — [Özel bölümleme anahtarı](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) bir sistem tablosu için. +- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. + +Varsayılan sunucu yapılandırma dosyası `config.xml` aşağıdaki ayarlar bölümünü içerir: + +``` xml + + system + trace_log
+ toYYYYMM(event_date) + 7500 +
+``` + +## query\_masking\_rules {#query-masking-rules} + +Regexp tabanlı kurallar, sorgulara ve tüm günlük iletilerine sunucu günlüklerinde depolamadan önce uygulanacak, +`system.query_log`, `system.text_log`, `system.processes` tablo ve istemciye gönderilen günlüklerde. Önlem allowseyi sağlayan +SQL sorgularından hassas veri sızıntısı (isimler, e-postalar, kişisel +kimlik veya kredi kartı numaraları) günlükleri için. + +**Örnek** + +``` xml + + + hide SSN + (^|\D)\d{3}-\d{2}-\d{4}($|\D) + 000-00-0000 + + +``` + +Config alanları: +- `name` - kuralın adı (isteğe bağlı) +- `regexp` - Re2 uyumlu düzenli ifade (zorunlu) +- `replace` - hassas veriler için ikame dizesi (isteğe bağlı, varsayılan olarak-altı Yıldız İşareti) + +Maskeleme kuralları tüm sorguya uygulanır (hatalı biçimlendirilmiş / ayrıştırılamayan sorgulardan hassas verilerin sızıntılarını önlemek için). + +`system.events` tablo sayacı var `QueryMaskingRulesMatch` hangi sorgu maskeleme kuralları maçları genel bir numarası var. + +Dağıtılmış sorgular için her sunucu ayrı ayrı yapılandırılmalıdır, aksi takdirde alt sorgular diğerine iletilir +düğümler maskeleme olmadan saklanır. + +## remote\_servers {#server-settings-remote-servers} + +Tarafından kullanılan küm ofelerin yapılandırması [Dağılı](../../engines/table-engines/special/distributed.md) tablo motoru ve `cluster` tablo işlevi. + +**Örnek** + +``` xml + +``` + +Değeri için `incl` öznitelik, bölümüne bakın “[Yapılandırma dosyaları](../configuration-files.md#configuration_files)”. + +**Ayrıca Bakınız** + +- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) + +## saat dilimi {#server_configuration_parameters-timezone} + +Sunucunun saat dilimi. + +UTC saat dilimi veya coğrafi konum (örneğin, Afrika / Abidjan) için bir IANA tanımlayıcısı olarak belirtilir. + +Saat dilimi, datetime alanları metin biçimine (ekranda veya dosyada yazdırıldığında) çıktığında ve datetime'ı bir dizeden alırken dize ve DateTime biçimleri arasındaki dönüşümler için gereklidir. Ayrıca, saat dilimi, giriş parametrelerinde saat dilimini almadıkları takdirde saat ve tarih ile çalışan işlevlerde kullanılır. + +**Örnek** + +``` xml +Europe/Moscow +``` + +## tcp\_port {#server_configuration_parameters-tcp_port} + +TCP protokolü üzerinden istemcilerle iletişim kurmak için bağlantı noktası. + +**Örnek** + +``` xml +9000 +``` + +## tcp\_port\_secure {#server_configuration_parameters-tcp_port_secure} + +İstemcilerle güvenli iletişim için TCP bağlantı noktası. İle kullanın [OpenSSL](#server_configuration_parameters-openssl) ayarlar. + +**Olası değerler** + +Pozitif tamsayı. + +**Varsayılan değer** + +``` xml +9440 +``` + +## mysql\_port {#server_configuration_parameters-mysql_port} + +MySQL protokolü üzerinden istemcilerle iletişim kurmak için bağlantı noktası. + +**Olası değerler** + +Pozitif tamsayı. + +Örnek + +``` xml +9004 +``` + +## tmp\_path {#server-settings-tmp_path} + +Büyük sorguları işlemek için geçici veri yolu. + +!!! note "Not" + Sondaki eğik çizgi zorunludur. + +**Örnek** + +``` xml +/var/lib/clickhouse/tmp/ +``` + +## tmp\_policy {#server-settings-tmp-policy} + +Politika dan [`storage_configuration`](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) geçici dosyaları saklamak için. +Set değilse [`tmp_path`](#server-settings-tmp_path) kullanılır, aksi takdirde göz ardı edilir. + +!!! note "Not" + - `move_factor` göz ardı edilir +- `keep_free_space_bytes` göz ardı edilir +- `max_data_part_size_bytes` göz ardı edilir +- bu Politikada tam olarak bir cilt olmalı + +## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} + +Tablo motorları tarafından kullanılan sıkıştırılmamış veriler için önbellek boyutu (bayt cinsinden) [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). + +Sunucu için bir paylaşılan önbellek var. Bellek talep üzerine tahsis edilir. Seçenek varsa önbellek kullanılır [use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) etkindir. + +Sıkıştırılmamış önbellek, tek tek durumlarda çok kısa sorgular için avantajlıdır. + +**Örnek** + +``` xml +8589934592 +``` + +## user\_files\_path {#server_configuration_parameters-user_files_path} + +Kullanıcı dosyaları ile dizin. Tablo işlevinde kullanılır [Dosya()](../../sql-reference/table-functions/file.md). + +**Örnek** + +``` xml +/var/lib/clickhouse/user_files/ +``` + +## users\_config {#users-config} + +İçeren dosyanın yolu: + +- Kullanıcı yapılandırmaları. +- Erişim hakları. +- Ayarlar profilleri. +- Kota ayarları. + +**Örnek** + +``` xml +users.xml +``` + +## zookeeper {#server-settings_zookeeper} + +ClickHouse ile etkileşim sağlayan ayarları içerir [ZooKeeper](http://zookeeper.apache.org/) küme. + +ClickHouse, çoğaltılmış tabloları kullanırken kopyaların meta verilerini depolamak için ZooKeeper kullanır. Çoğaltılmış tablolar kullanılmazsa, parametrelerin bu bölümü atlanabilir. + +Bu bölüm aşağıdaki parametreleri içerir: + +- `node` — ZooKeeper endpoint. You can set multiple endpoints. + + Mesela: + + + +``` xml + + example_host + 2181 + +``` + + The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. + +- `session_timeout` — Maximum timeout for the client session in milliseconds. +- `root` — The [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) bu, ClickHouse sunucusu tarafından kullanılan znodes için kök olarak kullanılır. İsteğe bağlı. +- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. + +**Örnek yapılandırma** + +``` xml + + + example1 + 2181 + + + example2 + 2181 + + 30000 + 10000 + + /path/to/zookeeper/node + + user:password + +``` + +**Ayrıca Bakınız** + +- [Çoğalma](../../engines/table-engines/mergetree-family/replication.md) +- [ZooKeeper programcı Kılavuzu](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) + +## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} + +ZooKeeper veri parçası başlıkları için depolama yöntemi. + +Bu ayar yalnızca `MergeTree` aile. Belirt specifiedilebilir: + +- Küresel olarak [merge\_tree](#server_configuration_parameters-merge_tree) bu bölüm `config.xml` Dosya. + + ClickHouse sunucudaki tüm tablolar için ayarı kullanır. Ayarı istediğiniz zaman değiştirebilirsiniz. Mevcut tablolar, ayar değiştiğinde davranışlarını değiştirir. + +- Her tablo için. + + Bir tablo oluştururken, karşılık gelen [motor ayarı](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table). Genel ayar değişse bile, bu ayara sahip varolan bir tablonun davranışı değişmez. + +**Olası değerler** + +- 0 — Functionality is turned off. +- 1 — Functionality is turned on. + +Eğer `use_minimalistic_part_header_in_zookeeper = 1`, sonraları [çoğaltıyordu](../../engines/table-engines/mergetree-family/replication.md) tablolar, veri parçalarının başlıklarını tek bir `znode`. Tablo çok sayıda sütun içeriyorsa, bu depolama yöntemi Zookeeper'da depolanan verilerin hacmini önemli ölçüde azaltır. + +!!! attention "Dikkat" + Uyguladıktan sonra `use_minimalistic_part_header_in_zookeeper = 1`, ClickHouse sunucusunu bu ayarı desteklemeyen bir sürüme düşüremezsiniz. Bir kümedeki sunucularda ClickHouse yükseltirken dikkatli olun. Tüm sunucuları bir kerede yükseltmeyin. Clickhouse'un yeni sürümlerini bir test ortamında veya bir kümenin yalnızca birkaç sunucusunda test etmek daha güvenlidir. + + Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. + +**Varsayılan değer:** 0. + +## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} + +İç DNS önbelleğini devre dışı bırakır. Sistemlerinde ClickHouse işletim için tavsiye +Kubernetes gibi sık sık değişen altyapı ile. + +**Varsayılan değer:** 0. + +## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} + +ClickHouse iç DNS önbelleğinde saklanan IP adreslerini güncelleme süresi (saniye cinsinden). +Güncelleştirme, ayrı bir sistem iş parçacığında zaman uyumsuz olarak gerçekleştirilir. + +**Varsayılan değer**: 15. + +## access\_control\_path {#access_control_path} + +ClickHouse sunucusunun SQL komutları tarafından oluşturulan kullanıcı ve rol yapılandırmalarını depoladığı bir klasörün yolu. + +Varsayılan değer: `/var/lib/clickhouse/access/`. + +**Ayrıca bakınız** + +- [Erişim Kontrolü ve hesap yönetimi](../access-rights.md#access-control) + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/tr/operations/server_configuration_parameters/index.md b/docs/tr/operations/server_configuration_parameters/index.md deleted file mode 100644 index f1a20b924f0..00000000000 --- a/docs/tr/operations/server_configuration_parameters/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_folder_title: "Sunucu Yap\u0131land\u0131rma Parametreleri" -toc_priority: 54 -toc_title: "Giri\u015F" ---- - -# Sunucu yapılandırma parametreleri {#server-settings} - -Bu bölüm, oturum veya sorgu düzeyinde değiştirilemeyen sunucu ayarlarının açıklamalarını içerir. - -Bu ayarlar saklanır `config.xml` ClickHouse sunucusunda dosya. - -Diğer ayarlar aşağıda açıklanmıştır “[Ayarlar](../settings/index.md#settings)” bölme. - -Ayarları incelemeden önce, [Yapılandırma dosyaları](../configuration_files.md#configuration_files) bölüm ve ikame kullanımı (not `incl` ve `optional` öznitelik). - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/) diff --git a/docs/tr/operations/server_configuration_parameters/settings.md b/docs/tr/operations/server_configuration_parameters/settings.md deleted file mode 100644 index bc0a464c511..00000000000 --- a/docs/tr/operations/server_configuration_parameters/settings.md +++ /dev/null @@ -1,896 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 57 -toc_title: "Sunucu Ayarlar\u0131" ---- - -# Sunucu Ayarları {#server-settings} - -## buıltın\_dıctıonarıes\_reload\_ınterval {#builtin-dictionaries-reload-interval} - -Dahili sözlükleri yeniden yüklemeden önce saniye cinsinden Aralık. - -ClickHouse, her x saniyede bir yerleşik sözlükleri yeniden yükler. Bu, sözlükleri düzenlemeyi mümkün kılar “on the fly” sunucuyu yeniden başlatmadan. - -Varsayılan değer: 3600. - -**Örnek** - -``` xml -3600 -``` - -## sıkıştırma {#server-settings-compression} - -İçin veri sıkıştırma ayarları [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)- motor masaları. - -!!! warning "Uyarıcı" - Sadece ClickHouse kullanmaya başladıysanız kullanmayın. - -Yapılandırma şablonu: - -``` xml - - - ... - ... - ... - - ... - -``` - -`` alanlar: - -- `min_part_size` – The minimum size of a data part. -- `min_part_size_ratio` – The ratio of the data part size to the table size. -- `method` – Compression method. Acceptable values: `lz4` veya `zstd`. - -Birden fazla yapılandırabilirsiniz `` bölmeler. - -Koşullar yerine getirildiğinde eylemler: - -- Bir veri parçası bir koşul kümesiyle eşleşirse, ClickHouse belirtilen sıkıştırma yöntemini kullanır. -- Bir veri parçası birden çok koşul kümesiyle eşleşirse, ClickHouse ilk eşleşen koşul kümesini kullanır. - -Bir veri bölümü için herhangi bir koşul karşılanmazsa, ClickHouse `lz4` sıkıştırma. - -**Örnek** - -``` xml - - - 10000000000 - 0.01 - zstd - - -``` - -## default\_database {#default-database} - -Varsayılan veritabanı. - -Veritabanlarının bir listesini almak için [SHOW DATABASES](../../sql_reference/statements/show.md#show-databases) sorgu. - -**Örnek** - -``` xml -default -``` - -## default\_profile {#default-profile} - -Varsayılan ayarlar profili. - -Ayarlar profilleri parametrede belirtilen dosyada bulunur `user_config`. - -**Örnek** - -``` xml -default -``` - -## dictionaries\_config {#server_configuration_parameters-dictionaries_config} - -Dış sözlükler için yapılandırma dosyasının yolu. - -Yol: - -- Mutlak yolu veya sunucu yapılandırma dosyasına göre yolu belirtin. -- Yol joker karakterler içerebilir \* ve ?. - -Ayrıca bakınız “[Dış söz dictionarieslükler](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md)”. - -**Örnek** - -``` xml -*_dictionary.xml -``` - -## dictionaries\_lazy\_load {#server_configuration_parameters-dictionaries_lazy_load} - -Sözlüklerin tembel yüklenmesi. - -Eğer `true`, sonra her sözlük ilk kullanımda oluşturulur. Sözlük oluşturma başarısız olursa, sözlüğü kullanan işlev bir özel durum atar. - -Eğer `false`, sunucu başladığında tüm sözlükler oluşturulur ve bir hata varsa, sunucu kapanır. - -Varsayılan değer `true`. - -**Örnek** - -``` xml -true -``` - -## format\_schema\_path {#server_configuration_parameters-format_schema_path} - -Dizin için şemalar gibi giriş verileri için şemaları ile yolu [CapnProto](../../interfaces/formats.md#capnproto) biçimli. - -**Örnek** - -``` xml - - format_schemas/ -``` - -## grafit {#server_configuration_parameters-graphite} - -Veri gönderme [Grafit](https://github.com/graphite-project). - -Ayarlar: - -- host – The Graphite server. -- port – The port on the Graphite server. -- interval – The interval for sending, in seconds. -- timeout – The timeout for sending data, in seconds. -- root\_path – Prefix for keys. -- metrics – Sending data from the [sistem.metrik](../../operations/system_tables.md#system_tables-metrics) Tablo. -- events – Sending deltas data accumulated for the time period from the [sistem.etkinlik](../../operations/system_tables.md#system_tables-events) Tablo. -- events\_cumulative – Sending cumulative data from the [sistem.etkinlik](../../operations/system_tables.md#system_tables-events) Tablo. -- asynchronous\_metrics – Sending data from the [sistem.asynchronous\_metrics](../../operations/system_tables.md#system_tables-asynchronous_metrics) Tablo. - -Birden fazla yapılandırabilirsiniz `` yanlar. Örneğin, bunu farklı aralıklarla farklı veri göndermek için kullanabilirsiniz. - -**Örnek** - -``` xml - - localhost - 42000 - 0.1 - 60 - one_min - true - true - false - true - -``` - -## graphite\_rollup {#server_configuration_parameters-graphite-rollup} - -Grafit için inceltme verileri için ayarlar. - -Daha fazla ayrıntı için bkz. [Graphıtemergetree](../../engines/table_engines/mergetree_family/graphitemergetree.md). - -**Örnek** - -``` xml - - - max - - 0 - 60 - - - 3600 - 300 - - - 86400 - 3600 - - - -``` - -## http\_port/https\_port {#http-porthttps-port} - -Http(ler) üzerinden sunucuya bağlanmak için bağlantı noktası. - -Eğer `https_port` belirtilen, [openSSL](#server_configuration_parameters-openssl) yapılandırılmalıdır. - -Eğer `http_port` belirtilmişse, OpenSSL yapılandırması ayarlanmış olsa bile göz ardı edilir. - -**Örnek** - -``` xml -0000 -``` - -## http\_server\_default\_response {#server_configuration_parameters-http_server_default_response} - -ClickHouse HTTP (s) sunucusuna eriştiğinizde varsayılan olarak gösterilen sayfa. -Varsayılan değer “Ok.” (sonunda bir çizgi besleme ile) - -**Örnek** - -Açıyor `https://tabix.io/` eriş whenirken `http://localhost: http_port`. - -``` xml - -
]]> -
-``` - -## include\_from {#server_configuration_parameters-include_from} - -Değiştirmeleri ile dosyanın yolu. - -Daha fazla bilgi için bölüme bakın “[Yapılandırma dosyaları](../configuration_files.md#configuration_files)”. - -**Örnek** - -``` xml -/etc/metrica.xml -``` - -## ınterserver\_http\_port {#interserver-http-port} - -ClickHouse sunucuları arasında veri alışverişi için bağlantı noktası. - -**Örnek** - -``` xml -9009 -``` - -## ınterserver\_http\_host {#interserver-http-host} - -Bu sunucuya erişmek için diğer sunucular tarafından kullanılabilecek ana bilgisayar adı. - -Eğer ihmal edilirse, aynı şekilde tanımlanır `hostname-f` komut. - -Belirli bir ağ arayüzünden kopmak için kullanışlıdır. - -**Örnek** - -``` xml -example.yandex.ru -``` - -## ınterserver\_http\_credentials {#server-settings-interserver-http-credentials} - -Sırasında kimlik doğrulaması için kullanılan kullanıcı adı ve şifre [çoğalma](../../engines/table_engines/mergetree_family/replication.md) çoğaltılan \* motorlarla. Bu kimlik bilgileri yalnızca yinelemeler arasındaki iletişim için kullanılır ve ClickHouse istemcileri için kimlik bilgileri ile ilgisizdir. Sunucu, yinelemeleri bağlamak için bu kimlik bilgilerini denetliyor ve diğer yinelemelere bağlanırken aynı kimlik bilgilerini kullanıyor. Bu nedenle, bu kimlik bilgileri kümedeki tüm yinelemeler için aynı şekilde ayarlanmalıdır. -Varsayılan olarak, kimlik doğrulama kullanılmaz. - -Bu bölüm aşağıdaki parametreleri içerir: - -- `user` — username. -- `password` — password. - -**Örnek** - -``` xml - - admin - 222 - -``` - -## keep\_alive\_timeout {#keep-alive-timeout} - -ClickHouse bağlantıyı kapatmadan önce gelen istekleri bekler saniye sayısı. Varsayılan 3 saniye. - -**Örnek** - -``` xml -3 -``` - -## listen\_host {#server_configuration_parameters-listen_host} - -İsteklerin gelebileceği ana bilgisayarlarda kısıtlama. Sunucunun hepsini yanıtlamasını istiyorsanız, belirtin `::`. - -Örnekler: - -``` xml -::1 -127.0.0.1 -``` - -## kaydedici {#server_configuration_parameters-logger} - -Günlük ayarları. - -Anahtarlar: - -- level – Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. -- log – The log file. Contains all the entries according to `level`. -- errorlog – Error log file. -- size – Size of the file. Applies to `log`ve`errorlog`. Dosya ulaştıktan sonra `size`, ClickHouse arşivleri ve yeniden adlandırır ve onun yerine yeni bir günlük dosyası oluşturur. -- count – The number of archived log files that ClickHouse stores. - -**Örnek** - -``` xml - - trace - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 10 - -``` - -Syslog yazma da desteklenmektedir. Yapılandırma örneği: - -``` xml - - 1 - -
syslog.remote:10514
- myhost.local - LOG_LOCAL6 - syslog -
-
-``` - -Anahtarlar: - -- use\_syslog — Required setting if you want to write to the syslog. -- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. -- hostname — Optional. The name of the host that logs are sent from. -- facility — [Syslog tesisi anahtar sözcüğü](https://en.wikipedia.org/wiki/Syslog#Facility) ile büyük harf inlerle “LOG\_” önek: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3` vb.). - Varsayılan değer: `LOG_USER` eğer `address` belirtilen, `LOG_DAEMON otherwise.` -- format – Message format. Possible values: `bsd` ve `syslog.` - -## makrolar {#macros} - -Çoğaltılmış tablolar için parametre değiştirmeleri. - -Çoğaltılmış tablolar kullanılmazsa atlanabilir. - -Daha fazla bilgi için bölüme bakın “[Çoğaltılmış tablolar oluşturma](../../engines/table_engines/mergetree_family/replication.md)”. - -**Örnek** - -``` xml - -``` - -## mark\_cache\_size {#server-mark-cache-size} - -Tablo motorları tarafından kullanılan işaretlerin önbelleğinin yaklaşık boyutu (bayt cinsinden) [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) aile. - -Önbellek sunucu için paylaşılır ve bellek gerektiği gibi ayrılır. Önbellek boyutu en az 5368709120 olmalıdır. - -**Örnek** - -``` xml -5368709120 -``` - -## max\_concurrent\_queries {#max-concurrent-queries} - -Aynı anda işlenen isteklerin maksimum sayısı. - -**Örnek** - -``` xml -100 -``` - -## max\_connections {#max-connections} - -En fazla gelen bağlantı sayısı. - -**Örnek** - -``` xml -4096 -``` - -## max\_open\_files {#max-open-files} - -Maksimum açık dosya sayısı. - -Varsayılan olarak: `maximum`. - -Biz beri Mac OS X bu seçeneği kullanmanızı öneririz `getrlimit()` işlev yanlış bir değer döndürür. - -**Örnek** - -``` xml -262144 -``` - -## max\_table\_size\_to\_drop {#max-table-size-to-drop} - -Tabloları silme konusunda kısıtlama. - -Eğer bir boyutu [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) tablo aşıyor `max_table_size_to_drop` (bayt cinsinden), bir bırakma sorgusu kullanarak silemezsiniz. - -ClickHouse sunucusunu yeniden başlatmadan tabloyu silmeniz gerekiyorsa, `/flags/force_drop_table` dosya ve bırakma sorgusunu çalıştırın. - -Varsayılan değer: 50 GB. - -0 değeri, herhangi bir kısıtlama olmaksızın tüm tabloları silebileceğiniz anlamına gelir. - -**Örnek** - -``` xml -0 -``` - -## merge\_tree {#server_configuration_parameters-merge_tree} - -Tablolar için ince ayar [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). - -Daha fazla bilgi için bkz: MergeTreeSettings.h başlık dosyası. - -**Örnek** - -``` xml - - 5 - -``` - -## openSSL {#server_configuration_parameters-openssl} - -SSL istemci / sunucu yapılandırması. - -SSL desteği tarafından sağlanmaktadır `libpoco` kitaplık. Arayüz dosyada açıklanmıştır [SSLManager.sa](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) - -Sunucu/istemci ayarları için tuşlar: - -- privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time. -- certificateFile – The path to the client/server certificate file in PEM format. You can omit it if `privateKeyFile` sertifika içerir. -- caConfig – The path to the file or directory that contains trusted root certificates. -- verificationMode – The method for checking the node's certificates. Details are in the description of the [Bağlama](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) sınıf. Olası değerler: `none`, `relaxed`, `strict`, `once`. -- verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value. -- loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: `true`, `false`. \| -- cipherList – Supported OpenSSL encryptions. For example: `ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH`. -- cacheSessions – Enables or disables caching sessions. Must be used in combination with `sessionIdContext`. Kabul edilebilir değerler: `true`, `false`. -- sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed `SSL_MAX_SSL_SESSION_ID_LENGTH`. Bu parametre her zaman sunucu oturumu önbelleğe alır ve istemci önbellekleme istedi, sorunları önlemek yardımcı olduğundan önerilir. Varsayılan değer: `${application.name}`. -- sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024\*20. 0 – Unlimited sessions. -- sessionTimeout – Time for caching the session on the server. -- extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1 connection. Acceptable values: `true`, `false`. -- requireTLSv1\_1 – Require a TLSv1.1 connection. Acceptable values: `true`, `false`. -- requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: `true`, `false`. -- fips – Activates OpenSSL FIPS mode. Supported if the library's OpenSSL version supports FIPS. -- privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: ``, `KeyFileHandler`, `test`, ``. -- invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: ` ConsoleCertificateHandler ` . -- disableProtocols – Protocols that are not allowed to use. -- preferServerCiphers – Preferred server ciphers on the client. - -**Ayarlar örneği:** - -``` xml - - - - /etc/clickhouse-server/server.crt - /etc/clickhouse-server/server.key - - /etc/clickhouse-server/dhparam.pem - none - true - true - sslv2,sslv3 - true - - - true - true - sslv2,sslv3 - true - - - - RejectCertificateHandler - - - -``` - -## part\_log {#server_configuration_parameters-part-log} - -İlişkili olayları günlüğe kaydetme [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). Örneğin, veri ekleme veya birleştirme. Birleştirme algoritmalarını simüle etmek ve özelliklerini karşılaştırmak için günlüğü kullanabilirsiniz. Birleştirme işlemini görselleştirebilirsiniz. - -Sorgular günlüğe kaydedilir [sistem.part\_log](../../operations/system_tables.md#system_tables-part-log) tablo, ayrı bir dosyada değil. Bu tablonun adını aşağıdaki tabloda yapılandırabilirsiniz: `table` parametre (aşağıya bakınız). - -Günlüğü yapılandırmak için aşağıdaki parametreleri kullanın: - -- `database` – Name of the database. -- `table` – Name of the system table. -- `partition_by` – Sets a [özel bölümleme anahtarı](../../engines/table_engines/mergetree_family/custom_partitioning_key.md). -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -**Örnek** - -``` xml - - system - part_log
- toMonday(event_date) - 7500 -
-``` - -## yol {#server_configuration_parameters-path} - -Veri içeren dizinin yolu. - -!!! note "Not" - Sondaki eğik çizgi zorunludur. - -**Örnek** - -``` xml -/var/lib/clickhouse/ -``` - -## prometheus {#server_configuration_parameters-prometheus} - -Kazıma için metrik verilerini açığa çıkarma [Prometheus](https://prometheus.io). - -Ayarlar: - -- `endpoint` – HTTP endpoint for scraping metrics by prometheus server. Start from ‘/’. -- `port` – Port for `endpoint`. -- `metrics` – Flag that sets to expose metrics from the [sistem.metrik](../system_tables.md#system_tables-metrics) Tablo. -- `events` – Flag that sets to expose metrics from the [sistem.etkinlik](../system_tables.md#system_tables-events) Tablo. -- `asynchronous_metrics` – Flag that sets to expose current metrics values from the [sistem.asynchronous\_metrics](../system_tables.md#system_tables-asynchronous_metrics) Tablo. - -**Örnek** - -``` xml - - /metrics - 8001 - true - true - true - -``` - -## query\_log {#server_configuration_parameters-query-log} - -İle alınan günlük sorgu settinglarının ayarlanması [log\_queries = 1](../settings/settings.md) ayar. - -Sorgular günlüğe kaydedilir [sistem.query\_log](../../operations/system_tables.md#system_tables-query_log) tablo, ayrı bir dosyada değil. Tablonun adını değiştirebilirsiniz. `table` parametre (aşağıya bakınız). - -Günlüğü yapılandırmak için aşağıdaki parametreleri kullanın: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [özel bölümleme anahtarı](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) bir masa için. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -Tablo yoksa, ClickHouse bunu oluşturur. ClickHouse sunucusu güncelleştirildiğinde sorgu günlüğünün yapısı değiştiyse, eski yapıya sahip tablo yeniden adlandırılır ve otomatik olarak yeni bir tablo oluşturulur. - -**Örnek** - -``` xml - - system - query_log
- toMonday(event_date) - 7500 -
-``` - -## query\_thread\_log {#server_configuration_parameters-query-thread-log} - -İle alınan sorguların günlük iş parçacıklarının ayarlanması [log\_query\_threads = 1](../settings/settings.md#settings-log-query-threads) ayar. - -Sorgular günlüğe kaydedilir [sistem.query\_thread\_log](../../operations/system_tables.md#system_tables-query-thread-log) tablo, ayrı bir dosyada değil. Tablonun adını değiştirebilirsiniz. `table` parametre (aşağıya bakınız). - -Günlüğü yapılandırmak için aşağıdaki parametreleri kullanın: - -- `database` – Name of the database. -- `table` – Name of the system table the queries will be logged in. -- `partition_by` – Sets a [özel bölümleme anahtarı](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) bir sistem tablosu için. -- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table. - -Tablo yoksa, ClickHouse bunu oluşturur. Sorgu iş parçacığı günlüğü yapısını değiştirdiyseniz ClickHouse sunucu güncelleştirildi, tablo eski yapısı ile yeniden adlandırılır ve yeni bir tablo otomatik olarak oluşturulur. - -**Örnek** - -``` xml - - system - query_thread_log
- toMonday(event_date) - 7500 -
-``` - -## trace\_log {#server_configuration_parameters-trace_log} - -İçin ayarlar [trace\_log](../../operations/system_tables.md#system_tables-trace_log) sistem tablosu çalışması. - -Parametre: - -- `database` — Database for storing a table. -- `table` — Table name. -- `partition_by` — [Özel bölümleme anahtarı](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) bir sistem tablosu için. -- `flush_interval_milliseconds` — Interval for flushing data from the buffer in memory to the table. - -Varsayılan sunucu yapılandırma dosyası `config.xml` aşağıdaki ayarlar bölümünü içerir: - -``` xml - - system - trace_log
- toYYYYMM(event_date) - 7500 -
-``` - -## query\_masking\_rules {#query-masking-rules} - -Regexp tabanlı kurallar, sorgulara ve tüm günlük iletilerine sunucu günlüklerinde depolamadan önce uygulanacak, -`system.query_log`, `system.text_log`, `system.processes` tablo ve istemciye gönderilen günlüklerde. Önlem allowseyi sağlayan -SQL sorgularından hassas veri sızıntısı (isimler, e-postalar, kişisel -kimlik veya kredi kartı numaraları) günlükleri için. - -**Örnek** - -``` xml - - - hide SSN - (^|\D)\d{3}-\d{2}-\d{4}($|\D) - 000-00-0000 - - -``` - -Config alanları: -- `name` - kuralın adı (isteğe bağlı) -- `regexp` - Re2 uyumlu düzenli ifade (zorunlu) -- `replace` - hassas veriler için ikame dizesi (isteğe bağlı, varsayılan olarak-altı Yıldız İşareti) - -Maskeleme kuralları tüm sorguya uygulanır (hatalı biçimlendirilmiş / ayrıştırılamayan sorgulardan hassas verilerin sızıntılarını önlemek için). - -`system.events` tablo sayacı var `QueryMaskingRulesMatch` hangi sorgu maskeleme kuralları maçları genel bir numarası var. - -Dağıtılmış sorgular için her sunucu ayrı ayrı yapılandırılmalıdır, aksi takdirde alt sorgular diğerine iletilir -düğümler maskeleme olmadan saklanır. - -## remote\_servers {#server-settings-remote-servers} - -Tarafından kullanılan küm ofelerin yapılandırması [Dağılı](../../engines/table_engines/special/distributed.md) tablo motoru ve `cluster` tablo işlevi. - -**Örnek** - -``` xml - -``` - -Değeri için `incl` öznitelik, bölümüne bakın “[Yapılandırma dosyaları](../configuration_files.md#configuration_files)”. - -**Ayrıca Bakınız** - -- [skip\_unavailable\_shards](../settings/settings.md#settings-skip_unavailable_shards) - -## saat dilimi {#server_configuration_parameters-timezone} - -Sunucunun saat dilimi. - -UTC saat dilimi veya coğrafi konum (örneğin, Afrika / Abidjan) için bir IANA tanımlayıcısı olarak belirtilir. - -Saat dilimi, datetime alanları metin biçimine (ekranda veya dosyada yazdırıldığında) çıktığında ve datetime'ı bir dizeden alırken dize ve DateTime biçimleri arasındaki dönüşümler için gereklidir. Ayrıca, saat dilimi, giriş parametrelerinde saat dilimini almadıkları takdirde saat ve tarih ile çalışan işlevlerde kullanılır. - -**Örnek** - -``` xml -Europe/Moscow -``` - -## tcp\_port {#server_configuration_parameters-tcp_port} - -TCP protokolü üzerinden istemcilerle iletişim kurmak için bağlantı noktası. - -**Örnek** - -``` xml -9000 -``` - -## tcp\_port\_secure {#server_configuration_parameters-tcp_port-secure} - -İstemcilerle güvenli iletişim için TCP bağlantı noktası. İle kullanın [OpenSSL](#server_configuration_parameters-openssl) ayarlar. - -**Olası değerler** - -Pozitif tamsayı. - -**Varsayılan değer** - -``` xml -9440 -``` - -## mysql\_port {#server_configuration_parameters-mysql_port} - -MySQL protokolü üzerinden istemcilerle iletişim kurmak için bağlantı noktası. - -**Olası değerler** - -Pozitif tamsayı. - -Örnek - -``` xml -9004 -``` - -## tmp\_path {#server-settings-tmp_path} - -Büyük sorguları işlemek için geçici veri yolu. - -!!! note "Not" - Sondaki eğik çizgi zorunludur. - -**Örnek** - -``` xml -/var/lib/clickhouse/tmp/ -``` - -## tmp\_policy {#server-settings-tmp-policy} - -Politika dan [`storage_configuration`](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) geçici dosyaları saklamak için. -Set değilse [`tmp_path`](#server-settings-tmp_path) kullanılır, aksi takdirde göz ardı edilir. - -!!! note "Not" - - `move_factor` göz ardı edilir -- `keep_free_space_bytes` göz ardı edilir -- `max_data_part_size_bytes` göz ardı edilir -- bu Politikada tam olarak bir cilt olmalı - -## uncompressed\_cache\_size {#server-settings-uncompressed_cache_size} - -Tablo motorları tarafından kullanılan sıkıştırılmamış veriler için önbellek boyutu (bayt cinsinden) [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). - -Sunucu için bir paylaşılan önbellek var. Bellek talep üzerine tahsis edilir. Seçenek varsa önbellek kullanılır [use\_uncompressed\_cache](../settings/settings.md#setting-use_uncompressed_cache) etkindir. - -Sıkıştırılmamış önbellek, tek tek durumlarda çok kısa sorgular için avantajlıdır. - -**Örnek** - -``` xml -8589934592 -``` - -## user\_files\_path {#server_configuration_parameters-user_files_path} - -Kullanıcı dosyaları ile dizin. Tablo işlevinde kullanılır [Dosya()](../../sql_reference/table_functions/file.md). - -**Örnek** - -``` xml -/var/lib/clickhouse/user_files/ -``` - -## users\_config {#users-config} - -İçeren dosyanın yolu: - -- Kullanıcı yapılandırmaları. -- Erişim hakları. -- Ayarlar profilleri. -- Kota ayarları. - -**Örnek** - -``` xml -users.xml -``` - -## zookeeper {#server-settings_zookeeper} - -ClickHouse ile etkileşim sağlayan ayarları içerir [ZooKeeper](http://zookeeper.apache.org/) küme. - -ClickHouse, çoğaltılmış tabloları kullanırken kopyaların meta verilerini depolamak için ZooKeeper kullanır. Çoğaltılmış tablolar kullanılmazsa, parametrelerin bu bölümü atlanabilir. - -Bu bölüm aşağıdaki parametreleri içerir: - -- `node` — ZooKeeper endpoint. You can set multiple endpoints. - - Mesela: - - - -``` xml - - example_host - 2181 - -``` - - The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. - -- `session_timeout` — Maximum timeout for the client session in milliseconds. -- `root` — The [znode](http://zookeeper.apache.org/doc/r3.5.5/zookeeperOver.html#Nodes+and+ephemeral+nodes) bu, ClickHouse sunucusu tarafından kullanılan znodes için kök olarak kullanılır. İsteğe bağlı. -- `identity` — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional. - -**Örnek yapılandırma** - -``` xml - - - example1 - 2181 - - - example2 - 2181 - - 30000 - 10000 - - /path/to/zookeeper/node - - user:password - -``` - -**Ayrıca Bakınız** - -- [Çoğalma](../../engines/table_engines/mergetree_family/replication.md) -- [ZooKeeper programcı Kılavuzu](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) - -## use\_minimalistic\_part\_header\_in\_zookeeper {#server-settings-use_minimalistic_part_header_in_zookeeper} - -ZooKeeper veri parçası başlıkları için depolama yöntemi. - -Bu ayar yalnızca `MergeTree` aile. Belirt specifiedilebilir: - -- Küresel olarak [merge\_tree](#server_configuration_parameters-merge_tree) bu bölüm `config.xml` Dosya. - - ClickHouse sunucudaki tüm tablolar için ayarı kullanır. Ayarı istediğiniz zaman değiştirebilirsiniz. Mevcut tablolar, ayar değiştiğinde davranışlarını değiştirir. - -- Her tablo için. - - Bir tablo oluştururken, karşılık gelen [motor ayarı](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-creating-a-table). Genel ayar değişse bile, bu ayara sahip varolan bir tablonun davranışı değişmez. - -**Olası değerler** - -- 0 — Functionality is turned off. -- 1 — Functionality is turned on. - -Eğer `use_minimalistic_part_header_in_zookeeper = 1`, sonraları [çoğaltıyordu](../../engines/table_engines/mergetree_family/replication.md) tablolar, veri parçalarının başlıklarını tek bir `znode`. Tablo çok sayıda sütun içeriyorsa, bu depolama yöntemi Zookeeper'da depolanan verilerin hacmini önemli ölçüde azaltır. - -!!! attention "Dikkat" - Uyguladıktan sonra `use_minimalistic_part_header_in_zookeeper = 1`, ClickHouse sunucusunu bu ayarı desteklemeyen bir sürüme düşüremezsiniz. Bir kümedeki sunucularda ClickHouse yükseltirken dikkatli olun. Tüm sunucuları bir kerede yükseltmeyin. Clickhouse'un yeni sürümlerini bir test ortamında veya bir kümenin yalnızca birkaç sunucusunda test etmek daha güvenlidir. - - Data part headers already stored with this setting can't be restored to their previous (non-compact) representation. - -**Varsayılan değer:** 0. - -## disable\_internal\_dns\_cache {#server-settings-disable-internal-dns-cache} - -İç DNS önbelleğini devre dışı bırakır. Sistemlerinde ClickHouse işletim için tavsiye -Kubernetes gibi sık sık değişen altyapı ile. - -**Varsayılan değer:** 0. - -## dns\_cache\_update\_period {#server-settings-dns-cache-update-period} - -ClickHouse iç DNS önbelleğinde saklanan IP adreslerini güncelleme süresi (saniye cinsinden). -Güncelleştirme, ayrı bir sistem iş parçacığında zaman uyumsuz olarak gerçekleştirilir. - -**Varsayılan değer**: 15. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/server_configuration_parameters/settings/) diff --git a/docs/tr/operations/settings/constraints-on-settings.md b/docs/tr/operations/settings/constraints-on-settings.md new file mode 100644 index 00000000000..d1e8aa58005 --- /dev/null +++ b/docs/tr/operations/settings/constraints-on-settings.md @@ -0,0 +1,75 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 62 +toc_title: "Ayarlardaki k\u0131s\u0131tlamalar" +--- + +# Ayarlardaki kısıtlamalar {#constraints-on-settings} + +Ayarlardaki kısıtlamalar, `profiles` bu bölüm `user.xml` yapılandırma dosyası ve kullanıcıların bazı ayarları değiştirmelerini yasakla `SET` sorgu. +Kısıtlamalar aşağıdaki gibi tanımlanır: + +``` xml + + + + + lower_boundary + + + upper_boundary + + + lower_boundary + upper_boundary + + + + + + + +``` + +Kullanıcı kısıtlamaları ihlal etmeye çalışırsa, bir istisna atılır ve ayar değiştirilmez. +Desteklenen üç tür kısıtlama vardır: `min`, `max`, `readonly`. Bu `min` ve `max` kısıtlamalar, sayısal bir ayar için üst ve alt sınırları belirtir ve birlikte kullanılabilir. Bu `readonly` kısıtlama, kullanıcının karşılık gelen ayarı hiç değiştiremeyeceğini belirtir. + +**Örnek:** İzin vermek `users.xml` hatları içerir: + +``` xml + + + 10000000000 + 0 + ... + + + 5000000000 + 20000000000 + + + + + + + +``` + +Aşağıdaki sorgular tüm atma istisnaları: + +``` sql +SET max_memory_usage=20000000001; +SET max_memory_usage=4999999999; +SET force_index_by_date=1; +``` + +``` text +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. +Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. +Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. +``` + +**Not:** bu `default` profil özel işleme sahiptir: tüm kısıtlamalar için tanımlanan `default` profil varsayılan kısıtlamalar haline gelir, bu nedenle bu kullanıcılar için açıkça geçersiz kılınana kadar tüm kullanıcıları kısıtlarlar. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/constraints_on_settings/) diff --git a/docs/tr/operations/settings/constraints_on_settings.md b/docs/tr/operations/settings/constraints_on_settings.md deleted file mode 100644 index a9319c2df69..00000000000 --- a/docs/tr/operations/settings/constraints_on_settings.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 62 -toc_title: "Ayarlardaki k\u0131s\u0131tlamalar" ---- - -# Ayarlardaki kısıtlamalar {#constraints-on-settings} - -Ayarlardaki kısıtlamalar, `profiles` bu bölüm `user.xml` yapılandırma dosyası ve kullanıcıların bazı ayarları değiştirmelerini yasakla `SET` sorgu. -Kısıtlamalar aşağıdaki gibi tanımlanır: - -``` xml - - - - - lower_boundary - - - upper_boundary - - - lower_boundary - upper_boundary - - - - - - - -``` - -Kullanıcı kısıtlamaları ihlal etmeye çalışırsa, bir istisna atılır ve ayar değiştirilmez. -Desteklenen üç tür kısıtlama vardır: `min`, `max`, `readonly`. Bu `min` ve `max` kısıtlamalar, sayısal bir ayar için üst ve alt sınırları belirtir ve birlikte kullanılabilir. Bu `readonly` kısıtlama, kullanıcının karşılık gelen ayarı hiç değiştiremeyeceğini belirtir. - -**Örnek:** İzin vermek `users.xml` hatları içerir: - -``` xml - - - 10000000000 - 0 - ... - - - 5000000000 - 20000000000 - - - - - - - -``` - -Aşağıdaki sorgular tüm atma istisnaları: - -``` sql -SET max_memory_usage=20000000001; -SET max_memory_usage=4999999999; -SET force_index_by_date=1; -``` - -``` text -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000. -Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000. -Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed. -``` - -**Not:** bu `default` profil özel işleme sahiptir: tüm kısıtlamalar için tanımlanan `default` profil varsayılan kısıtlamalar haline gelir, bu nedenle bu kullanıcılar için açıkça geçersiz kılınana kadar tüm kullanıcıları kısıtlarlar. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/constraints_on_settings/) diff --git a/docs/tr/operations/settings/index.md b/docs/tr/operations/settings/index.md index 72270b8a397..181a33d7fb3 100644 --- a/docs/tr/operations/settings/index.md +++ b/docs/tr/operations/settings/index.md @@ -1,14 +1,15 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Ayarlar toc_priority: 55 toc_title: "Giri\u015F" --- -# Ayarlar {#settings} +# Ayarlar {#session-settings-intro} + +Belgelerin bu bölümünde açıklanan tüm ayarları yapmanın birden çok yolu vardır. -Aşağıda açıklanan tüm ayarları yapmanın birden çok yolu vardır. Ayarlar katmanlar halinde yapılandırılır, böylece sonraki her katman önceki ayarları yeniden tanımlar. Öncelik sırasına göre ayarları yapılandırma yolları: diff --git a/docs/tr/operations/settings/permissions-for-queries.md b/docs/tr/operations/settings/permissions-for-queries.md new file mode 100644 index 00000000000..499d704230f --- /dev/null +++ b/docs/tr/operations/settings/permissions-for-queries.md @@ -0,0 +1,61 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 58 +toc_title: "Sorgular i\xE7in izinler" +--- + +# Sorgular için izinler {#permissions_for_queries} + +Clickhouse'daki sorgular birkaç türe ayrılabilir: + +1. Veri sorgularını oku: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. +2. Veri sorgularını yaz: `INSERT`, `OPTIMIZE`. +3. Ayarları değiştir sorgu: `SET`, `USE`. +4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) sorgular: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. +5. `KILL QUERY`. + +Aşağıdaki ayarlar, kullanıcı izinlerini sorgu Türüne göre düzenler: + +- [readonly](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. +- [allow\_ddl](#settings_allow_ddl) — Restricts permissions for DDL queries. + +`KILL QUERY` herhangi bir ayar ile yapılabilir. + +## readonly {#settings_readonly} + +Veri okuma, veri yazma ve ayar sorgularını değiştirme izinlerini kısıtlar. + +Sorguların türlere nasıl ayrıldığını görün [üzerinde](#permissions_for_queries). + +Olası değerler: + +- 0 — All queries are allowed. +- 1 — Only read data queries are allowed. +- 2 — Read data and change settings queries are allowed. + +Sonra ayarı `readonly = 1`, kullanıcı değiştir canemez `readonly` ve `allow_ddl` geçerli oturumda ayarlar. + +Kullanırken `GET` metho thed in the [HTTP arayüzü](../../interfaces/http.md), `readonly = 1` otomatik olarak ayarlanır. Değiştirmek için veri kullanın `POST` yöntem. + +Ayar `readonly = 1` kullanıcının tüm ayarları değiştirmesini yasaklayın. Kullanıcıyı yasaklamanın bir yolu var +sadece belirli ayarları değiştirmekten, ayrıntılar için bkz [ayarlardaki kısıtlamalar](constraints-on-settings.md). + +Varsayılan değer: 0 + +## allow\_ddl {#settings_allow_ddl} + +İzin verir veya reddeder [DDL](https://en.wikipedia.org/wiki/Data_definition_language) sorgular. + +Sorguların türlere nasıl ayrıldığını görün [üzerinde](#permissions_for_queries). + +Olası değerler: + +- 0 — DDL queries are not allowed. +- 1 — DDL queries are allowed. + +Yürüt canemezsiniz `SET allow_ddl = 1` eğer `allow_ddl = 0` geçerli oturum için. + +Varsayılan değer: 1 + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/tr/operations/settings/permissions_for_queries.md b/docs/tr/operations/settings/permissions_for_queries.md deleted file mode 100644 index 2f65630604c..00000000000 --- a/docs/tr/operations/settings/permissions_for_queries.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 58 -toc_title: "Sorgular i\xE7in izinler" ---- - -# Sorgular için izinler {#permissions_for_queries} - -Clickhouse'daki sorgular birkaç türe ayrılabilir: - -1. Veri sorgularını oku: `SELECT`, `SHOW`, `DESCRIBE`, `EXISTS`. -2. Veri sorgularını yaz: `INSERT`, `OPTIMIZE`. -3. Ayarları değiştir sorgu: `SET`, `USE`. -4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) sorgular: `CREATE`, `ALTER`, `RENAME`, `ATTACH`, `DETACH`, `DROP` `TRUNCATE`. -5. `KILL QUERY`. - -Aşağıdaki ayarlar, kullanıcı izinlerini sorgu Türüne göre düzenler: - -- [readonly](#settings_readonly) — Restricts permissions for all types of queries except DDL queries. -- [allow\_ddl](#settings_allow_ddl) — Restricts permissions for DDL queries. - -`KILL QUERY` herhangi bir ayar ile yapılabilir. - -## readonly {#settings_readonly} - -Veri okuma, veri yazma ve ayar sorgularını değiştirme izinlerini kısıtlar. - -Sorguların türlere nasıl ayrıldığını görün [üzerinde](#permissions_for_queries). - -Olası değerler: - -- 0 — All queries are allowed. -- 1 — Only read data queries are allowed. -- 2 — Read data and change settings queries are allowed. - -Sonra ayarı `readonly = 1`, kullanıcı değiştir canemez `readonly` ve `allow_ddl` geçerli oturumda ayarlar. - -Kullanırken `GET` metho thed in the [HTTP arayüzü](../../interfaces/http.md), `readonly = 1` otomatik olarak ayarlanır. Değiştirmek için veri kullanın `POST` yöntem. - -Ayar `readonly = 1` kullanıcının tüm ayarları değiştirmesini yasaklayın. Kullanıcıyı yasaklamanın bir yolu var -sadece belirli ayarları değiştirmekten, ayrıntılar için bkz [ayarlardaki kısıtlamalar](constraints_on_settings.md). - -Varsayılan değer: 0 - -## allow\_ddl {#settings_allow_ddl} - -İzin verir veya reddeder [DDL](https://en.wikipedia.org/wiki/Data_definition_language) sorgular. - -Sorguların türlere nasıl ayrıldığını görün [üzerinde](#permissions_for_queries). - -Olası değerler: - -- 0 — DDL queries are not allowed. -- 1 — DDL queries are allowed. - -Yürüt canemezsiniz `SET allow_ddl = 1` eğer `allow_ddl = 0` geçerli oturum için. - -Varsayılan değer: 1 - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/permissions_for_queries/) diff --git a/docs/tr/operations/settings/query-complexity.md b/docs/tr/operations/settings/query-complexity.md new file mode 100644 index 00000000000..c1880fc2ce7 --- /dev/null +++ b/docs/tr/operations/settings/query-complexity.md @@ -0,0 +1,302 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 59 +toc_title: "Sorgu karma\u015F\u0131kl\u0131\u011F\u0131 \xFCzerindeki k\u0131s\u0131\ + tlamalar" +--- + +# Sorgu karmaşıklığı üzerindeki kısıtlamalar {#restrictions-on-query-complexity} + +Sorgu karmaşıklığı üzerindeki kısıtlamalar ayarların bir parçasıdır. +Kullanıcı arabiriminden daha güvenli yürütme sağlamak için kullanılırlar. +Hemen hemen tüm kısıtlamalar sadece aşağıdakiler için geçerlidir `SELECT`. Dağıtılmış sorgu işleme için kısıtlamalar her sunucuda ayrı ayrı uygulanır. + +ClickHouse, her satır için değil, veri bölümleri için kısıtlamaları denetler. Bu, veri parçasının boyutu ile kısıtlama değerini aşabileceğiniz anlamına gelir. + +Üzerindeki kısıtlamalar “maximum amount of something” 0 değerini alabilir, yani “unrestricted”. +Çoğu kısıtlama da bir ‘overflow\_mode’ ayar, sınır aşıldığında ne yapılması gerektiği anlamına gelir. +İki değerden birini alabilir: `throw` veya `break`. Toplama (group\_by\_overflow\_mode) üzerindeki kısıtlamalar da değere sahiptir `any`. + +`throw` – Throw an exception (default). + +`break` – Stop executing the query and return the partial result, as if the source data ran out. + +`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don't add new keys to the set. + +## max\_memory\_usage {#settings_max_memory_usage} + +Tek bir sunucuda bir sorgu çalıştırmak için kullanılacak en fazla RAM miktarı. + +Varsayılan yapılandırma dosyasında maksimum 10 GB'DİR. + +Bu ayar, kullanılabilir belleğin hacmini veya makinedeki toplam bellek hacmini dikkate almaz. +Kısıtlama, tek bir sunucu içindeki tek bir sorgu için geçerlidir. +Kullanabilirsiniz `SHOW PROCESSLIST` her sorgu için geçerli bellek tüketimini görmek için. +Ayrıca, en yüksek bellek tüketimi her sorgu için izlenir ve günlüğe yazılır. + +Bellek kullanımı, belirli toplama işlevlerinin durumları için izlenmez. + +Toplam işlevlerin durumları için bellek kullanımı tam olarak izlenmiyor `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` itibaren `String` ve `Array` değişkenler. + +Bellek tüketimi de parametrelerle sınırlıdır `max_memory_usage_for_user` ve `max_memory_usage_for_all_queries`. + +## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} + +Tek bir sunucuda bir kullanıcının sorguları çalıştırmak için kullanılacak en fazla RAM miktarı. + +Varsayılan değerler [Ayarlar.sa](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). Varsayılan olarak, tutar sınırlı değildir (`max_memory_usage_for_user = 0`). + +Ayrıca açıklamasına bakın [max\_memory\_usage](#settings_max_memory_usage). + +## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} + +Tek bir sunucuda tüm sorguları çalıştırmak için kullanılacak en fazla RAM miktarı. + +Varsayılan değerler [Ayarlar.sa](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). Varsayılan olarak, tutar sınırlı değildir (`max_memory_usage_for_all_queries = 0`). + +Ayrıca açıklamasına bakın [max\_memory\_usage](#settings_max_memory_usage). + +## max\_rows\_to\_read {#max-rows-to-read} + +Aşağıdaki kısıtlamalar her blokta kontrol edilebilir (her satır yerine). Yani, kısıtlamalar biraz kırılabilir. +Birden çok iş parçacığında bir sorgu çalıştırırken, aşağıdaki kısıtlamalar her iş parçacığı için ayrı ayrı uygulanır. + +Bir sorgu çalıştırırken bir tablodan okunabilen satır sayısı. + +## max\_bytes\_to\_read {#max-bytes-to-read} + +Bir sorgu çalıştırırken bir tablodan okunabilen bayt sayısı (sıkıştırılmamış veri). + +## read\_overflow\_mode {#read-overflow-mode} + +Okunan veri hacmi sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} + +Toplama alınan benzersiz anahtarların maksimum sayısı. Bu ayar, toplama sırasında bellek tüketimini sınırlamanızı sağlar. + +## group\_by\_overflow\_mode {#group-by-overflow-mode} + +Toplama için benzersiz anahtarların sayısı sınırı aştığında ne yapmalı: ‘throw’, ‘break’, veya ‘any’. Varsayılan olarak, atın. +Kullanarak ‘any’ değer, GROUP BY'NİN bir yaklaşımını çalıştırmanızı sağlar. Bu yaklaşımın kalitesi, verilerin istatistiksel niteliğine bağlıdır. + +## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} + +Çalıştırmayı etkinleştirir veya devre dışı bırakır `GROUP BY` harici bellekte yan tümceleri. Görmek [Harici bellekte grupla](../../sql-reference/statements/select/group-by.md#select-group-by-in-external-memory). + +Olası değerler: + +- Tek tarafından kullanılabilecek maksimum RAM hacmi (bayt cinsinden) [GROUP BY](../../sql-reference/statements/select/group-by.md#select-group-by-clause) operasyon. +- 0 — `GROUP BY` harici bellekte devre dışı. + +Varsayılan değer: 0. + +## max\_rows\_to\_sort {#max-rows-to-sort} + +Sıralamadan önce en fazla satır sayısı. Bu, sıralama yaparken bellek tüketimini sınırlamanıza izin verir. + +## max\_bytes\_to\_sort {#max-bytes-to-sort} + +Sıralamadan önce en fazla bayt sayısı. + +## sort\_overflow\_mode {#sort-overflow-mode} + +Sıralamadan önce alınan satır sayısı sınırlardan birini aşarsa ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +## max\_result\_rows {#setting-max_result_rows} + +Sonuçtaki satır sayısını sınırlayın. Ayrıca, dağıtılmış bir sorgunun parçalarını çalıştırırken alt sorgular ve uzak sunucularda da kontrol edildi. + +## max\_result\_bytes {#max-result-bytes} + +Sonuçtaki bayt sayısını sınırlayın. Önceki ayar ile aynı. + +## result\_overflow\_mode {#result-overflow-mode} + +Sonucun hacmi sınırlardan birini aşarsa ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +Kullanım ‘break’ LİMİT kullanmaya benzer. `Break` yürütmeyi yalnızca blok düzeyinde keser. Bu, döndürülen satırların miktarının daha büyük olduğu anlamına gelir [max\_result\_rows](#setting-max_result_rows) birden çok [max\_block\_size](settings.md#setting-max_block_size) ve bağlıdır [max\_threads](settings.md#settings-max_threads). + +Örnek: + +``` sql +SET max_threads = 3, max_block_size = 3333; +SET max_result_rows = 3334, result_overflow_mode = 'break'; + +SELECT * +FROM numbers_mt(100000) +FORMAT Null; +``` + +Sonuç: + +``` text +6666 rows in set. ... +``` + +## max\_execution\_time {#max-execution-time} + +Saniye cinsinden maksimum sorgu yürütme süresi. +Şu anda, sıralama aşamalarından biri için veya toplama işlevlerini birleştirirken ve sonlandırırken kontrol edilmez. + +## timeout\_overflow\_mode {#timeout-overflow-mode} + +Sorgu daha uzun çalıştırılırsa ne yapmalı ‘max\_execution\_time’: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +## min\_execution\_speed {#min-execution-speed} + +Saniyede satırlarda minimum yürütme hızı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı düşükse, bir istisna atılır. + +## min\_execution\_speed\_bytes {#min-execution-speed-bytes} + +Saniyede en az yürütme bayt sayısı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı düşükse, bir istisna atılır. + +## max\_execution\_speed {#max-execution-speed} + +Saniyede en fazla yürütme satırı sayısı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı yüksekse, yürütme hızı azaltılır. + +## max\_execution\_speed\_bytes {#max-execution-speed-bytes} + +Saniyede en fazla yürütme bayt sayısı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı yüksekse, yürütme hızı azaltılır. + +## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} + +Yürütme hızının çok yavaş olmadığını kontrol eder (en az ‘min\_execution\_speed’), saniye içinde belirtilen süre dolduktan sonra. + +## max\_columns\_to\_read {#max-columns-to-read} + +Tek bir sorguda bir tablodan okunabilen sütun sayısı. Bir sorgu daha fazla sayıda sütun okuma gerektiriyorsa, bir özel durum atar. + +## max\_temporary\_columns {#max-temporary-columns} + +Sabit sütunlar da dahil olmak üzere bir sorgu çalıştırırken aynı anda RAM'de tutulması gereken geçici sütun sayısı. Bundan daha fazla geçici sütun varsa, bir istisna atar. + +## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} + +Aynı şey ‘max\_temporary\_columns’, ancak sabit sütunları saymadan. +Bir sorgu çalıştırırken sabit sütunların oldukça sık oluşturulduğunu, ancak yaklaşık sıfır bilgi işlem kaynağı gerektirdiğini unutmayın. + +## max\_subquery\_depth {#max-subquery-depth} + +Alt sorguların maksimum yuvalama derinliği. Alt sorgular daha derinse, bir istisna atılır. Varsayılan olarak, 100. + +## max\_pipeline\_depth {#max-pipeline-depth} + +Maksimum boru hattı derinliği. Sorgu işleme sırasında her veri bloğunun geçtiği dönüşümlerin sayısına karşılık gelir. Tek bir sunucunun sınırları içinde sayılır. Boru hattı derinliği büyükse, bir istisna atılır. Varsayılan olarak, 1000. + +## max\_ast\_depth {#max-ast-depth} + +Sorgu sözdizimsel ağacının en fazla yuvalama derinliği. Aşılırsa, bir istisna atılır. +Şu anda, ayrıştırma sırasında değil, yalnızca sorguyu ayrıştırdıktan sonra kontrol edilir. Yani, ayrıştırma sırasında çok derin bir sözdizimsel ağaç oluşturulabilir, ancak sorgu başarısız olur. Varsayılan olarak, 1000. + +## max\_ast\_elements {#max-ast-elements} + +Sorgu sözdizimsel ağacındaki en fazla öğe sayısı. Aşılırsa, bir istisna atılır. +Önceki ayarla aynı şekilde, yalnızca sorguyu ayrıştırdıktan sonra kontrol edilir. Varsayılan olarak, 50.000. + +## max\_rows\_in\_set {#max-rows-in-set} + +Bir alt sorgudan oluşturulan In yan tümcesinde bir veri kümesi için satır sayısı. + +## max\_bytes\_in\_set {#max-bytes-in-set} + +Bir alt sorgudan oluşturulan In yan tümcesinde bir set tarafından kullanılan en fazla bayt sayısı (sıkıştırılmamış veri). + +## set\_overflow\_mode {#set-overflow-mode} + +Veri miktarı sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +## max\_rows\_ın\_distinct {#max-rows-in-distinct} + +DISTINCT kullanırken en fazla sayıda farklı satır. + +## max\_bytes\_ın\_distinct {#max-bytes-in-distinct} + +DISTINCT kullanırken bir karma tablo tarafından kullanılan bayt sayısı. + +## distinct\_overflow\_mode {#distinct-overflow-mode} + +Veri miktarı sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +## max\_rows\_to\_transfer {#max-rows-to-transfer} + +Uzak bir sunucuya geçirilen veya GLOBAL In kullanırken geçici bir tabloya kaydedilen satır sayısı. + +## max\_bytes\_to\_transfer {#max-bytes-to-transfer} + +Uzak bir sunucuya geçirilen veya GLOBAL In kullanırken geçici bir tabloya kaydedilen bayt sayısı (sıkıştırılmamış veri). + +## transfer\_overflow\_mode {#transfer-overflow-mode} + +Veri miktarı sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. + +## max\_rows\_in\_join {#settings-max_rows_in_join} + +Tabloları birleştirirken kullanılan karma tablodaki satır sayısını sınırlar. + +Bu ayarlar aşağıdakiler için geçerlidir [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) işlemleri ve [Katmak](../../engines/table-engines/special/join.md) masa motoru. + +Bir sorgu birden çok birleşim içeriyorsa, ClickHouse her Ara sonuç için bu ayarı denetler. + +Limit ulaşıldığında ClickHouse farklı eylemlerle devam edebilirsiniz. Kullan... [join\_overflow\_mode](#settings-join_overflow_mode) eylemi seçmek için ayarlama. + +Olası değerler: + +- Pozitif tamsayı. +- 0 — Unlimited number of rows. + +Varsayılan değer: 0. + +## max\_bytes\_in\_join {#settings-max_bytes_in_join} + +Tabloları birleştirirken kullanılan karma tablonun bayt cinsinden boyutunu sınırlar. + +Bu ayarlar aşağıdakiler için geçerlidir [SELECT … JOIN](../../sql-reference/statements/select/join.md#select-join) işlemleri ve [Jo tablein table engine](../../engines/table-engines/special/join.md). + +Sorgu birleşimler içeriyorsa, ClickHouse her Ara sonuç için bu ayarı denetler. + +Limit ulaşıldığında ClickHouse farklı eylemlerle devam edebilirsiniz. Kullanmak [join\_overflow\_mode](#settings-join_overflow_mode) eylemi seçmek için ayarlar. + +Olası değerler: + +- Pozitif tamsayı. +- 0 — Memory control is disabled. + +Varsayılan değer: 0. + +## join\_overflow\_mode {#settings-join_overflow_mode} + +Tanımlar katılın aşağıdaki sınırlar her zaman eylem ClickHouse gerçekleştirdiği ulaştı: + +- [max\_bytes\_in\_join](#settings-max_bytes_in_join) +- [max\_rows\_in\_join](#settings-max_rows_in_join) + +Olası değerler: + +- `THROW` — ClickHouse throws an exception and breaks operation. +- `BREAK` — ClickHouse breaks operation and doesn't throw an exception. + +Varsayılan değer: `THROW`. + +**Ayrıca Bakınız** + +- [Jo](../../sql-reference/statements/select/join.md#select-join) +- [Jo tablein table engine](../../engines/table-engines/special/join.md) + +## max\_partitions\_per\_ınsert\_block {#max-partitions-per-insert-block} + +Eklenen tek bir bloktaki en fazla bölüm sayısını sınırlar. + +- Pozitif tamsayı. +- 0 — Unlimited number of partitions. + +Varsayılan değer: 100. + +**Ayrıntı** + +Veri eklerken, ClickHouse eklenen bloktaki bölüm sayısını hesaplar. Bölüm sayısı fazla ise `max_partitions_per_insert_block`, ClickHouse aşağıdaki metinle bir özel durum atar: + +> “Too many partitions for single INSERT block (more than” + toString (max\_parts) + “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/tr/operations/settings/query_complexity.md b/docs/tr/operations/settings/query_complexity.md deleted file mode 100644 index 54958b786ab..00000000000 --- a/docs/tr/operations/settings/query_complexity.md +++ /dev/null @@ -1,302 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 59 -toc_title: "Sorgu karma\u015F\u0131kl\u0131\u011F\u0131 \xFCzerindeki k\u0131s\u0131\ - tlamalar" ---- - -# Sorgu Karmaşıklığı Üzerindeki Kısıtlamalar {#restrictions-on-query-complexity} - -Sorgu karmaşıklığı üzerindeki kısıtlamalar ayarların bir parçasıdır. -Kullanıcı arabiriminden daha güvenli yürütme sağlamak için kullanılırlar. -Hemen hemen tüm kısıtlamalar sadece aşağıdakiler için geçerlidir `SELECT`. Dağıtılmış sorgu işleme için kısıtlamalar her sunucuda ayrı ayrı uygulanır. - -ClickHouse, her satır için değil, veri bölümleri için kısıtlamaları denetler. Bu, veri parçasının boyutu ile kısıtlama değerini aşabileceğiniz anlamına gelir. - -Üzerindeki kısıtlamalar “maximum amount of something” 0 değerini alabilir, yani “unrestricted”. -Çoğu kısıtlama da bir ‘overflow\_mode’ ayar, sınır aşıldığında ne yapılması gerektiği anlamına gelir. -İki değerden birini alabilir: `throw` veya `break`. Toplama (group\_by\_overflow\_mode) üzerindeki kısıtlamalar da değere sahiptir `any`. - -`throw` – Throw an exception (default). - -`break` – Stop executing the query and return the partial result, as if the source data ran out. - -`any (only for group_by_overflow_mode)` – Continuing aggregation for the keys that got into the set, but don't add new keys to the set. - -## max\_memory\_usage {#settings_max_memory_usage} - -Tek bir sunucuda bir sorgu çalıştırmak için kullanılacak en fazla RAM miktarı. - -Varsayılan yapılandırma dosyasında maksimum 10 GB'DİR. - -Bu ayar, kullanılabilir belleğin hacmini veya makinedeki toplam bellek hacmini dikkate almaz. -Kısıtlama, tek bir sunucu içindeki tek bir sorgu için geçerlidir. -Kullanabilirsiniz `SHOW PROCESSLIST` her sorgu için geçerli bellek tüketimini görmek için. -Ayrıca, en yüksek bellek tüketimi her sorgu için izlenir ve günlüğe yazılır. - -Bellek kullanımı, belirli toplama işlevlerinin durumları için izlenmez. - -Toplam işlevlerin durumları için bellek kullanımı tam olarak izlenmiyor `min`, `max`, `any`, `anyLast`, `argMin`, `argMax` itibaren `String` ve `Array` değişkenler. - -Bellek tüketimi de parametrelerle sınırlıdır `max_memory_usage_for_user` ve `max_memory_usage_for_all_queries`. - -## max\_memory\_usage\_for\_user {#max-memory-usage-for-user} - -Tek bir sunucuda bir kullanıcının sorguları çalıştırmak için kullanılacak en fazla RAM miktarı. - -Varsayılan değerler [Ayarlar.sa](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L288). Varsayılan olarak, tutar sınırlı değildir (`max_memory_usage_for_user = 0`). - -Ayrıca açıklamasına bakın [max\_memory\_usage](#settings_max_memory_usage). - -## max\_memory\_usage\_for\_all\_queries {#max-memory-usage-for-all-queries} - -Tek bir sunucuda tüm sorguları çalıştırmak için kullanılacak en fazla RAM miktarı. - -Varsayılan değerler [Ayarlar.sa](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h#L289). Varsayılan olarak, tutar sınırlı değildir (`max_memory_usage_for_all_queries = 0`). - -Ayrıca açıklamasına bakın [max\_memory\_usage](#settings_max_memory_usage). - -## max\_rows\_to\_read {#max-rows-to-read} - -Aşağıdaki kısıtlamalar her blokta kontrol edilebilir (her satır yerine). Yani, kısıtlamalar biraz kırılabilir. -Birden çok iş parçacığında bir sorgu çalıştırırken, aşağıdaki kısıtlamalar her iş parçacığı için ayrı ayrı uygulanır. - -Bir sorgu çalıştırırken bir tablodan okunabilen satır sayısı. - -## max\_bytes\_to\_read {#max-bytes-to-read} - -Bir sorgu çalıştırırken bir tablodan okunabilen bayt sayısı (sıkıştırılmamış veri). - -## read\_overflow\_mode {#read-overflow-mode} - -Okunan veri hacmi sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -## max\_rows\_to\_group\_by {#settings-max-rows-to-group-by} - -Toplama alınan benzersiz anahtarların maksimum sayısı. Bu ayar, toplama sırasında bellek tüketimini sınırlamanızı sağlar. - -## group\_by\_overflow\_mode {#group-by-overflow-mode} - -Toplama için benzersiz anahtarların sayısı sınırı aştığında ne yapmalı: ‘throw’, ‘break’, veya ‘any’. Varsayılan olarak, atın. -Kullanarak ‘any’ değer, GROUP BY'NİN bir yaklaşımını çalıştırmanızı sağlar. Bu yaklaşımın kalitesi, verilerin istatistiksel niteliğine bağlıdır. - -## max\_bytes\_before\_external\_group\_by {#settings-max_bytes_before_external_group_by} - -Çalıştırmayı etkinleştirir veya devre dışı bırakır `GROUP BY` harici bellekte yan tümceleri. Görmek [Harici bellekte grupla](../../sql_reference/statements/select.md#select-group-by-in-external-memory). - -Olası değerler: - -- Tek tarafından kullanılabilecek maksimum RAM hacmi (bayt cinsinden) [GROUP BY](../../sql_reference/statements/select.md#select-group-by-clause) işleyiş. -- 0 — `GROUP BY` harici bellekte devre dışı. - -Varsayılan değer: 0. - -## max\_rows\_to\_sort {#max-rows-to-sort} - -Sıralamadan önce en fazla satır sayısı. Bu, sıralama yaparken bellek tüketimini sınırlamanıza izin verir. - -## max\_bytes\_to\_sort {#max-bytes-to-sort} - -Sıralamadan önce en fazla bayt sayısı. - -## sort\_overflow\_mode {#sort-overflow-mode} - -Sıralamadan önce alınan satır sayısı sınırlardan birini aşarsa ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -## max\_result\_rows {#setting-max_result_rows} - -Sonuçtaki satır sayısını sınırlayın. Ayrıca, dağıtılmış bir sorgunun parçalarını çalıştırırken alt sorgular ve uzak sunucularda da kontrol edildi. - -## max\_result\_bytes {#max-result-bytes} - -Sonuçtaki bayt sayısını sınırlayın. Önceki ayar ile aynı. - -## result\_overflow\_mode {#result-overflow-mode} - -Sonucun hacmi sınırlardan birini aşarsa ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -Kullanım ‘break’ LİMİT kullanmaya benzer. `Break` yürütmeyi yalnızca blok düzeyinde keser. Bu, döndürülen satırların miktarının daha büyük olduğu anlamına gelir [max\_result\_rows](#setting-max_result_rows) birden çok [max\_block\_size](settings.md#setting-max_block_size) ve bağlıdır [max\_threads](settings.md#settings-max_threads). - -Örnek: - -``` sql -SET max_threads = 3, max_block_size = 3333; -SET max_result_rows = 3334, result_overflow_mode = 'break'; - -SELECT * -FROM numbers_mt(100000) -FORMAT Null; -``` - -Sonuç: - -``` text -6666 rows in set. ... -``` - -## max\_execution\_time {#max-execution-time} - -Saniye cinsinden maksimum sorgu yürütme süresi. -Şu anda, sıralama aşamalarından biri için veya toplama işlevlerini birleştirirken ve sonlandırırken kontrol edilmez. - -## timeout\_overflow\_mode {#timeout-overflow-mode} - -Sorgu daha uzun çalıştırılırsa ne yapmalı ‘max\_execution\_time’: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -## min\_execution\_speed {#min-execution-speed} - -Saniyede satırlarda minimum yürütme hızı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı düşükse, bir istisna atılır. - -## min\_execution\_speed\_bytes {#min-execution-speed-bytes} - -Saniyede en az yürütme bayt sayısı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı düşükse, bir istisna atılır. - -## max\_execution\_speed {#max-execution-speed} - -Saniyede en fazla yürütme satırı sayısı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı yüksekse, yürütme hızı azaltılır. - -## max\_execution\_speed\_bytes {#max-execution-speed-bytes} - -Saniyede en fazla yürütme bayt sayısı. Her veri bloğunda ne zaman kontrol edildi ‘timeout\_before\_checking\_execution\_speed’ doluyor. Yürütme hızı yüksekse, yürütme hızı azaltılır. - -## timeout\_before\_checking\_execution\_speed {#timeout-before-checking-execution-speed} - -Yürütme hızının çok yavaş olmadığını kontrol eder (en az ‘min\_execution\_speed’), saniye içinde belirtilen süre dolduktan sonra. - -## max\_columns\_to\_read {#max-columns-to-read} - -Tek bir sorguda bir tablodan okunabilen sütun sayısı. Bir sorgu daha fazla sayıda sütun okuma gerektiriyorsa, bir özel durum atar. - -## max\_temporary\_columns {#max-temporary-columns} - -Sabit sütunlar da dahil olmak üzere bir sorgu çalıştırırken aynı anda RAM'de tutulması gereken geçici sütun sayısı. Bundan daha fazla geçici sütun varsa, bir istisna atar. - -## max\_temporary\_non\_const\_columns {#max-temporary-non-const-columns} - -Aynı şey ‘max\_temporary\_columns’, ancak sabit sütunları saymadan. -Bir sorgu çalıştırırken sabit sütunların oldukça sık oluşturulduğunu, ancak yaklaşık sıfır bilgi işlem kaynağı gerektirdiğini unutmayın. - -## max\_subquery\_depth {#max-subquery-depth} - -Alt sorguların maksimum yuvalama derinliği. Alt sorgular daha derinse, bir istisna atılır. Varsayılan olarak, 100. - -## max\_pipeline\_depth {#max-pipeline-depth} - -Maksimum boru hattı derinliği. Sorgu işleme sırasında her veri bloğunun geçtiği dönüşümlerin sayısına karşılık gelir. Tek bir sunucunun sınırları içinde sayılır. Boru hattı derinliği büyükse, bir istisna atılır. Varsayılan olarak, 1000. - -## max\_ast\_depth {#max-ast-depth} - -Sorgu sözdizimsel ağacının en fazla yuvalama derinliği. Aşılırsa, bir istisna atılır. -Şu anda, ayrıştırma sırasında değil, yalnızca sorguyu ayrıştırdıktan sonra kontrol edilir. Yani, ayrıştırma sırasında çok derin bir sözdizimsel ağaç oluşturulabilir, ancak sorgu başarısız olur. Varsayılan olarak, 1000. - -## max\_ast\_elements {#max-ast-elements} - -Sorgu sözdizimsel ağacındaki en fazla öğe sayısı. Aşılırsa, bir istisna atılır. -Önceki ayarla aynı şekilde, yalnızca sorguyu ayrıştırdıktan sonra kontrol edilir. Varsayılan olarak, 50.000. - -## max\_rows\_in\_set {#max-rows-in-set} - -Bir alt sorgudan oluşturulan In yan tümcesinde bir veri kümesi için satır sayısı. - -## max\_bytes\_in\_set {#max-bytes-in-set} - -Bir alt sorgudan oluşturulan In yan tümcesinde bir set tarafından kullanılan en fazla bayt sayısı (sıkıştırılmamış veri). - -## set\_overflow\_mode {#set-overflow-mode} - -Veri miktarı sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -## max\_rows\_ın\_distinct {#max-rows-in-distinct} - -DISTINCT kullanırken en fazla sayıda farklı satır. - -## max\_bytes\_ın\_distinct {#max-bytes-in-distinct} - -DISTINCT kullanırken bir karma tablo tarafından kullanılan bayt sayısı. - -## distinct\_overflow\_mode {#distinct-overflow-mode} - -Veri miktarı sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -## max\_rows\_to\_transfer {#max-rows-to-transfer} - -Uzak bir sunucuya geçirilen veya GLOBAL In kullanırken geçici bir tabloya kaydedilen satır sayısı. - -## max\_bytes\_to\_transfer {#max-bytes-to-transfer} - -Uzak bir sunucuya geçirilen veya GLOBAL In kullanırken geçici bir tabloya kaydedilen bayt sayısı (sıkıştırılmamış veri). - -## transfer\_overflow\_mode {#transfer-overflow-mode} - -Veri miktarı sınırlardan birini aştığında ne yapmalı: ‘throw’ veya ‘break’. Varsayılan olarak, atın. - -## max\_rows\_in\_join {#settings-max_rows_in_join} - -Tabloları birleştirirken kullanılan karma tablodaki satır sayısını sınırlar. - -Bu ayarlar aşağıdakiler için geçerlidir [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) işlemleri ve [Katmak](../../engines/table_engines/special/join.md) masa motoru. - -Bir sorgu birden çok birleşim içeriyorsa, ClickHouse her Ara sonuç için bu ayarı denetler. - -Limit ulaşıldığında ClickHouse farklı eylemlerle devam edebilirsiniz. Kullan... [join\_overflow\_mode](#settings-join_overflow_mode) eylemi seçmek için ayarlama. - -Olası değerler: - -- Pozitif tamsayı. -- 0 — Unlimited number of rows. - -Varsayılan değer: 0. - -## max\_bytes\_in\_join {#settings-max_bytes_in_join} - -Tabloları birleştirirken kullanılan karma tablonun bayt cinsinden boyutunu sınırlar. - -Bu ayarlar aşağıdakiler için geçerlidir [SELECT … JOIN](../../sql_reference/statements/select.md#select-join) işlemleri ve [Jo tablein table engine](../../engines/table_engines/special/join.md). - -Sorgu birleşimler içeriyorsa, ClickHouse her Ara sonuç için bu ayarı denetler. - -Limit ulaşıldığında ClickHouse farklı eylemlerle devam edebilirsiniz. Kullanmak [join\_overflow\_mode](#settings-join_overflow_mode) eylemi seçmek için ayarlar. - -Olası değerler: - -- Pozitif tamsayı. -- 0 — Memory control is disabled. - -Varsayılan değer: 0. - -## join\_overflow\_mode {#settings-join_overflow_mode} - -Tanımlar katılın aşağıdaki sınırlar her zaman eylem ClickHouse gerçekleştirdiği ulaştı: - -- [max\_bytes\_in\_join](#settings-max_bytes_in_join) -- [max\_rows\_in\_join](#settings-max_rows_in_join) - -Olası değerler: - -- `THROW` — ClickHouse throws an exception and breaks operation. -- `BREAK` — ClickHouse breaks operation and doesn't throw an exception. - -Varsayılan değer: `THROW`. - -**Ayrıca Bakınız** - -- [Jo](../../sql_reference/statements/select.md#select-join) -- [Jo tablein table engine](../../engines/table_engines/special/join.md) - -## max\_partitions\_per\_ınsert\_block {#max-partitions-per-insert-block} - -Eklenen tek bir bloktaki en fazla bölüm sayısını sınırlar. - -- Pozitif tamsayı. -- 0 — Unlimited number of partitions. - -Varsayılan değer: 100. - -**Ayrıntı** - -Veri eklerken, ClickHouse eklenen bloktaki bölüm sayısını hesaplar. Bölüm sayısı fazla ise `max_partitions_per_insert_block`, ClickHouse aşağıdaki metinle bir özel durum atar: - -> “Too many partitions for single INSERT block (more than” + toString (max\_parts) + “). The limit is controlled by ‘max\_partitions\_per\_insert\_block’ setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).” - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/query_complexity/) diff --git a/docs/tr/operations/settings/settings-profiles.md b/docs/tr/operations/settings/settings-profiles.md new file mode 100644 index 00000000000..d5fa58384d7 --- /dev/null +++ b/docs/tr/operations/settings/settings-profiles.md @@ -0,0 +1,81 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: Ayarlar Profilleri +--- + +# Ayarlar Profilleri {#settings-profiles} + +Ayarlar profili, aynı ad altında gruplandırılmış ayarlar topluluğudur. + +!!! note "Bilgi" + ClickHouse da destekler [SQL tabanlı iş akışı](../access-rights.md#access-control) ayarları profilleri yönetmek için. Bunu kullanmanızı öneririz. + +Bir profilin herhangi bir adı olabilir. Profilin herhangi bir adı olabilir. Farklı kullanıcılar için aynı profili belirtebilirsiniz. Ayarlar profilinde yazabileceğiniz en önemli şey `readonly=1` sağlar okumak-sadece erişim. + +Ayarlar profilleri birbirinden miras alabilir. Kalıtım kullanmak için, bir veya birden fazla belirtiniz `profile` ayarlar profilde listelenen diğer ayarlardan önce. Farklı profillerde bir ayar tanımlandığında, en son tanımlı kullanılır. + +Bir profildeki tüm ayarları uygulamak için `profile` ayar. + +Örnek: + +Yüklemek `web` profilli. + +``` sql +SET profile = 'web' +``` + +Ayarlar profilleri kullanıcı yapılandırma dosyasında bildirilir. Bu genellikle `users.xml`. + +Örnek: + +``` xml + + + + + + 8 + + + + + 1000000000 + 100000000000 + + 1000000 + any + + 1000000 + 1000000000 + + 100000 + 100000000 + break + + 600 + 1000000 + 15 + + 25 + 100 + 50 + + 2 + 25 + 50 + 100 + + 1 + + +``` + +Örnek iki profili belirtir: `default` ve `web`. + +Bu `default` profilin özel bir amacı vardır: her zaman mevcut olmalı ve sunucuyu başlatırken uygulanır. Diğer bir deyişle, `default` profil varsayılan ayarları içerir. + +Bu `web` profil kullanılarak ayarlanabilir düzenli bir profil `SET` sorgu veya bir HTTP sorgusunda bir URL parametresi kullanma. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/tr/operations/settings/settings-users.md b/docs/tr/operations/settings/settings-users.md new file mode 100644 index 00000000000..eead71c0a77 --- /dev/null +++ b/docs/tr/operations/settings/settings-users.md @@ -0,0 +1,164 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 63 +toc_title: "Kullan\u0131c\u0131 Ayarlar\u0131" +--- + +# Kullanıcı Ayarları {#user-settings} + +Bu `users` bu bölüm `user.xml` yapılandırma dosyası kullanıcı ayarlarını içerir. + +!!! note "Bilgi" + ClickHouse da destekler [SQL tabanlı iş akışı](../access-rights.md#access-control) kullanıcıları yönetmek için. Bunu kullanmanızı öneririz. + +Bu yapı `users` bölme: + +``` xml + + + + + + + + 0|1 + + + + + profile_name + + default + + + + + expression + + + + + + +``` + +### home/şifre {#user-namepassword} + +Şifre düz metin veya SHA256 (hex formatında) belirtilebilir. + +- Düz metin içinde bir şifre atamak için (**tavsiye edilmez**bir koyun `password` öğe. + + Mesela, `qwerty`. Şifre boş bırakılabilir. + + + +- SHA256 karmasını kullanarak bir şifre atamak için, bir `password_sha256_hex` öğe. + + Mesela, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. + + Kabuktan bir parola oluşturma örneği: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' + + Sonucun ilk satırı şifredir. İkinci satır karşılık gelen SHA256 karmasıdır. + + + +- MySQL istemcileri ile uyumluluk için, şifre çift SHA1 karma belirtilebilir. İçine yerleştirin `password_double_sha1_hex` öğe. + + Mesela, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. + + Kabuktan bir parola oluşturma örneği: + + PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' + + Sonucun ilk satırı şifredir. İkinci satır karşılık gelen çift SHA1 karmasıdır. + +### access\_management {#access_management-user-setting} + +Bu ayar, SQL-driven kullanarak devre dışı bırakır sağlar [erişim kontrolü ve hesap yönetimi](../access-rights.md#access-control) kullanıcı için. + +Olası değerler: + +- 0 — Disabled. +- 1 — Enabled. + +Varsayılan değer: 0. + +### kullanıcı\_adı / ağlar {#user-namenetworks} + +Kullanıcının ClickHouse sunucusuna bağlanabileceği ağların listesi. + +Listenin her öğesi aşağıdaki formlardan birine sahip olabilir: + +- `` — IP address or network mask. + + Örnekler: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. + +- `` — Hostname. + + Örnek: `example01.host.ru`. + + Erişimi denetlemek için bir DNS sorgusu gerçekleştirilir ve döndürülen tüm IP adresleri eş adresiyle karşılaştırılır. + +- `` — Regular expression for hostnames. + + Örnek, `^example\d\d-\d\d-\d\.host\.ru$` + + Erişimi kontrol etmek için, bir [DNS ptr sorgusu](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) eş adresi için gerçekleştirilir ve sonra belirtilen regexp uygulanır. Daha sonra PTR sorgusunun sonuçları için başka bir DNS sorgusu gerçekleştirilir ve alınan tüm adresler eş adresine karşılaştırılır. Regexp'nin $ile bitmesini şiddetle tavsiye ederiz. + +Sunucu yeniden başlatılıncaya kadar DNS isteklerinin tüm sonuçları önbelleğe alınır. + +**Örnekler** + +Herhangi bir ağdan kullanıcı için erişimi açmak için şunları belirtin: + +``` xml +::/0 +``` + +!!! warning "Uyarıcı" + Düzgün yapılandırılmış bir güvenlik duvarınız yoksa veya sunucu doğrudan internete bağlı değilse, herhangi bir ağdan erişimi açmak güvensizdir. + +Erişimi yalnızca localhost'tan açmak için şunları belirtin: + +``` xml +::1 +127.0.0.1 +``` + +### kullanıcı\_adı / profil {#user-nameprofile} + +Kullanıcı için bir ayarlar profili atayabilirsiniz. Ayarlar profilleri ayrı bir bölümde yapılandırılır `users.xml` Dosya. Daha fazla bilgi için, bkz. [Ayarların profilleri](settings-profiles.md). + +### user\_name / kota {#user-namequota} + +Kotalar, belirli bir süre boyunca kaynak kullanımını izlemenize veya sınırlamanıza izin verir. Kotalar yapılandırılır `quotas` +bu bölüm `users.xml` yapılandırma dosyası. + +Kullanıcı için ayarlanmış bir kotalar atayabilirsiniz. Kotalar yapılandırmasının ayrıntılı bir açıklaması için bkz. [Kotalar](../quotas.md#quotas). + +### user\_name / veritabanları {#user-namedatabases} + +Bu bölümde, ClickHouse tarafından döndürülen satırları sınırlayabilirsiniz `SELECT` geçerli kullanıcı tarafından yapılan sorgular, böylece temel satır düzeyinde güvenlik uygular. + +**Örnek** + +Aşağıdaki yapılandırma bu kullanıcıyı zorlar `user1` sadece satırları görebilirsiniz `table1` sonucu olarak `SELECT` sorgular, burada değeri `id` alan 1000'dir. + +``` xml + + + + + id = 1000 + + + + +``` + +Bu `filter` bir sonuç veren herhangi bir ifade olabilir [Uİnt8](../../sql-reference/data-types/int-uint.md)- tip değeri. Genellikle karşılaştırmalar ve mantıksal operatörler içerir. Satır fromlardan `database_name.table1` burada filtre sonuçları 0 için bu kullanıcı için döndürülür. Filtreleme ile uyumsuz `PREWHERE` işlemler ve devre dışı bırakır `WHERE→PREWHERE` optimizasyon. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/tr/operations/settings/settings.md b/docs/tr/operations/settings/settings.md index 48e48ca00a6..342c35caab2 100644 --- a/docs/tr/operations/settings/settings.md +++ b/docs/tr/operations/settings/settings.md @@ -1,15 +1,13 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 60 -toc_title: Ayarlar +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd --- # Ayarlar {#settings} ## distributed\_product\_mode {#distributed-product-mode} -Davranışını değiştirir [dağıtılmış alt sorgular](../../sql_reference/statements/select.md). +Davranışını değiştirir [dağıtılmış alt sorgular](../../sql-reference/operators/in.md). ClickHouse applies this setting when the query contains the product of distributed tables, i.e. when the query for a distributed table contains a non-GLOBAL subquery for the distributed table. @@ -18,7 +16,7 @@ Kısıtlama: - Yalnızca ın ve JOIN alt sorguları için uygulanır. - Yalnızca FROM bölümü birden fazla parça içeren dağıtılmış bir tablo kullanıyorsa. - Alt sorgu birden fazla parça içeren dağıtılmış bir tablo ile ilgiliyse. -- Bir tablo için kullanılmaz-değerli [uzak](../../sql_reference/table_functions/remote.md) işlev. +- Bir tablo için kullanılmaz-değerli [uzak](../../sql-reference/table-functions/remote.md) İşlev. Olası değerler: @@ -53,7 +51,7 @@ Eğer `enable_optimize_predicate_expression = 0`, daha sonra ikinci sorgunun yü ## fallback\_to\_stale\_replicas\_for\_distributed\_queries {#settings-fallback_to_stale_replicas_for_distributed_queries} -Güncelleştirilmiş veriler mevcut değilse, bir sorgu için güncel olmayan bir yineleme zorlar. Görmek [Çoğalma](../../engines/table_engines/mergetree_family/replication.md). +Güncelleştirilmiş veriler mevcut değilse, bir sorgu için güncel olmayan bir yineleme zorlar. Görmek [Çoğalma](../../engines/table-engines/mergetree-family/replication.md). ClickHouse, tablonun eski kopyalarından en alakalı olanı seçer. @@ -67,7 +65,7 @@ Dizin tarihe göre kullanılamıyorsa, sorgu yürütülmesini devre dışı bır MergeTree ailesindeki tablolarla çalışır. -Eğer `force_index_by_date=1`, ClickHouse sorgunun veri aralıklarını kısıtlamak için kullanılabilecek bir tarih anahtarı koşulu olup olmadığını denetler. Uygun bir koşul yoksa, bir istisna atar. Ancak, koşul okumak için veri miktarını azaltır olup olmadığını denetlemez. Örneğin, durum `Date != ' 2000-01-01 '` tablodaki tüm verilerle eşleştiğinde bile kabul edilebilir (yani, sorguyu çalıştırmak tam bir tarama gerektirir). MergeTree tablolarındaki veri aralıkları hakkında daha fazla bilgi için bkz. [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +Eğer `force_index_by_date=1`, ClickHouse sorgunun veri aralıklarını kısıtlamak için kullanılabilecek bir tarih anahtarı koşulu olup olmadığını denetler. Uygun bir koşul yoksa, bir istisna atar. Ancak, koşul okumak için veri miktarını azaltır olup olmadığını denetlemez. Örneğin, durum `Date != ' 2000-01-01 '` tablodaki tüm verilerle eşleştiğinde bile kabul edilebilir (yani, sorguyu çalıştırmak tam bir tarama gerektirir). MergeTree tablolarındaki veri aralıkları hakkında daha fazla bilgi için bkz. [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## force\_primary\_key {#force-primary-key} @@ -75,7 +73,7 @@ Birincil anahtar tarafından dizin oluşturma mümkün değilse, sorgu yürütü MergeTree ailesindeki tablolarla çalışır. -Eğer `force_primary_key=1`, ClickHouse, sorgunun veri aralıklarını kısıtlamak için kullanılabilecek bir birincil anahtar koşulu olup olmadığını denetler. Uygun bir koşul yoksa, bir istisna atar. Ancak, koşul okumak için veri miktarını azaltır olup olmadığını denetlemez. MergeTree tablolarındaki veri aralıkları hakkında daha fazla bilgi için bkz. [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md). +Eğer `force_primary_key=1`, ClickHouse, sorgunun veri aralıklarını kısıtlamak için kullanılabilecek bir birincil anahtar koşulu olup olmadığını denetler. Uygun bir koşul yoksa, bir istisna atar. Ancak, koşul okumak için veri miktarını azaltır olup olmadığını denetlemez. MergeTree tablolarındaki veri aralıkları hakkında daha fazla bilgi için bkz. [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). ## format\_schema {#format-schema} @@ -136,7 +134,7 @@ Varsayılan değer: 0. ## max\_http\_get\_redirects {#setting-max_http_get_redirects} -Maksimum http get yönlendirme atlama sayısını sınırlar [URL](../../engines/table_engines/special/url.md)- motor masaları. Ayarı tablolar iki tür tarafından oluşturulan bu geçerlidir: [CREATE TABLE](../../sql_reference/statements/create.md#create-table-query) sorgu ve [url](../../sql_reference/table_functions/url.md) tablo işlevi. +Maksimum http get yönlendirme atlama sayısını sınırlar [URL](../../engines/table-engines/special/url.md)- motor masaları. Ayarı tablolar iki tür tarafından oluşturulan bu geçerlidir: [CREATE TABLE](../../sql-reference/statements/create.md#create-table-query) sorgu ve [url](../../sql-reference/table-functions/url.md) tablo işlevi. Olası değerler: @@ -172,7 +170,7 @@ Eğer her ikisi de `input_format_allow_errors_num` ve `input_format_allow_errors ## ınput\_format\_values\_interpret\_expressions {#settings-input_format_values_interpret_expressions} -Hızlı akış ayrıştırıcısı verileri ayrıştıramazsa, tam SQL ayrıştırıcısını etkinleştirir veya devre dışı bırakır. Bu ayar yalnızca için kullanılır [Değerler](../../interfaces/formats.md#data-format-values) veri ekleme sırasında biçimlendirin. Sözdizimi ayrıştırma hakkında daha fazla bilgi için bkz: [Sözdizimi](../../sql_reference/syntax.md) bölme. +Hızlı akış ayrıştırıcısı verileri ayrıştıramazsa, tam SQL ayrıştırıcısını etkinleştirir veya devre dışı bırakır. Bu ayar yalnızca için kullanılır [Değerler](../../interfaces/formats.md#data-format-values) veri ekleme sırasında biçimlendirin. Sözdizimi ayrıştırma hakkında daha fazla bilgi için bkz: [Sözdizimi](../../sql-reference/syntax.md) bölme. Olası değerler: @@ -188,7 +186,7 @@ Varsayılan değer: 1. Kullanım örneği -Ekle [DateTime](../../sql_reference/data_types/datetime.md) farklı ayarlarla değer yazın. +Ekle [DateTime](../../sql-reference/data-types/datetime.md) farklı ayarlarla değer yazın. ``` sql SET input_format_values_interpret_expressions = 0; @@ -348,7 +346,7 @@ Varsayılan değer: 1. Tarih ve saat metin gösterimi bir ayrıştırıcı seçme sağlar. -Ayar için geçerli değildir [tarih ve saat fonksiyonları](../../sql_reference/functions/date_time_functions.md). +Ayar için geçerli değildir [tarih ve saat fonksiyonları](../../sql-reference/functions/date-time-functions.md). Olası değerler: @@ -364,12 +362,12 @@ Varsayılan değer: `'basic'`. Ayrıca bakınız: -- [DateTime veri türü.](../../sql_reference/data_types/datetime.md) -- [Tarihler ve saatler ile çalışmak için fonksiyonlar.](../../sql_reference/functions/date_time_functions.md) +- [DateTime veri türü.](../../sql-reference/data-types/datetime.md) +- [Tarihler ve saatler ile çalışmak için fonksiyonlar.](../../sql-reference/functions/date-time-functions.md) ## join\_default\_strictness {#settings-join_default_strictness} -Ayarlar varsayılan strictness için [Maddeleri KATILIN ](../../sql_reference/statements/select.md#select-join). +Ayarlar varsayılan strictness için [Maddeleri KATILIN ](../../sql-reference/statements/select/join.md#select-join). Olası değerler: @@ -385,7 +383,7 @@ Varsayılan değer: `ALL`. İle birleştirme işlemlerinin davranışını değiştirir `ANY` katılık. !!! warning "Dikkat" - Bu ayar yalnızca aşağıdakiler için geçerlidir `JOIN` ile işlemler [Katmak](../../engines/table_engines/special/join.md) motor tabloları. + Bu ayar yalnızca aşağıdakiler için geçerlidir `JOIN` ile işlemler [Katmak](../../engines/table-engines/special/join.md) motor tabloları. Olası değerler: @@ -396,18 +394,18 @@ Varsayılan değer: 0. Ayrıca bakınız: -- [Jo](../../sql_reference/statements/select.md#select-join) -- [Jo tablein table engine](../../engines/table_engines/special/join.md) +- [Jo](../../sql-reference/statements/select/join.md#select-join) +- [Jo tablein table engine](../../engines/table-engines/special/join.md) - [join\_default\_strictness](#settings-join_default_strictness) ## join\_use\_nulls {#join_use_nulls} -Türünü ayarlar [JOIN](../../sql_reference/statements/select.md) davranış. Tabloları birleştirirken boş hücreler görünebilir. ClickHouse bu ayara göre onları farklı şekilde doldurur. +Türünü ayarlar [JOIN](../../sql-reference/statements/select/join.md) davranış. Tabloları birleştirirken boş hücreler görünebilir. ClickHouse bu ayara göre onları farklı şekilde doldurur. Olası değerler: - 0 — The empty cells are filled with the default value of the corresponding field type. -- 1 — `JOIN` standart SQL ile aynı şekilde davranır. Karşılık gelen alanın türü dönüştürülür [Nullable](../../sql_reference/data_types/nullable.md#data_type-nullable) ve boş hücreler ile doldurulur [NULL](../../sql_reference/syntax.md). +- 1 — `JOIN` standart SQL ile aynı şekilde davranır. Karşılık gelen alanın türü dönüştürülür [Nullable](../../sql-reference/data-types/nullable.md#data_type-nullable) ve boş hücreler ile doldurulur [NULL](../../sql-reference/syntax.md). Varsayılan değer: 0. @@ -427,7 +425,7 @@ Varsayılan olarak: 1.000.000. Sadece MergeTree motorlarından okurken çalış ## merge\_tree\_mın\_rows\_for\_concurrent\_read {#setting-merge-tree-min-rows-for-concurrent-read} -Bir dosyadan okunacak satır sayısı ise [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) tablo aşıyor `merge_tree_min_rows_for_concurrent_read` daha sonra ClickHouse, bu dosyadan birkaç iş parçacığı üzerinde eşzamanlı bir okuma gerçekleştirmeye çalışır. +Bir dosyadan okunacak satır sayısı ise [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) tablo aşıyor `merge_tree_min_rows_for_concurrent_read` daha sonra ClickHouse, bu dosyadan birkaç iş parçacığı üzerinde eşzamanlı bir okuma gerçekleştirmeye çalışır. Olası değerler: @@ -437,7 +435,7 @@ Varsayılan değer: 163840. ## merge\_tree\_min\_bytes\_for\_concurrent\_read {#setting-merge-tree-min-bytes-for-concurrent-read} -Eğer bir dosyadan okunacak bayt sayısı [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)- motor tablosu `merge_tree_min_bytes_for_concurrent_read`, daha sonra ClickHouse, bu dosyadan aynı anda birkaç iş parçacığında okumaya çalışır. +Eğer bir dosyadan okunacak bayt sayısı [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)- motor tablosu `merge_tree_min_bytes_for_concurrent_read`, daha sonra ClickHouse, bu dosyadan aynı anda birkaç iş parçacığında okumaya çalışır. Olası değer: @@ -479,7 +477,7 @@ Varsayılan değer: 8. ClickHouse daha fazla okumak gerekiyorsa `merge_tree_max_rows_to_use_cache` bir sorgudaki satırlar, sıkıştırılmamış blokların önbelleğini kullanmaz. -Sıkıştırılmamış blokların önbelleği, sorgular için ayıklanan verileri depolar. ClickHouse, tekrarlanan küçük sorgulara verilen yanıtları hızlandırmak için bu önbelleği kullanır. Bu ayar, önbelleğin büyük miktarda veri okuyan sorgularla çöpe atmasını önler. Bu [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) sunucu ayarı, sıkıştırılmamış blokların önbelleğinin boyutunu tanımlar. +Sıkıştırılmamış blokların önbelleği, sorgular için ayıklanan verileri depolar. ClickHouse, tekrarlanan küçük sorgulara verilen yanıtları hızlandırmak için bu önbelleği kullanır. Bu ayar, önbelleğin büyük miktarda veri okuyan sorgularla çöpe atmasını önler. Bu [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) sunucu ayarı, sıkıştırılmamış blokların önbelleğinin boyutunu tanımlar. Olası değerler: @@ -491,7 +489,7 @@ Default value: 128 ✕ 8192. ClickHouse daha fazla okumak gerekiyorsa `merge_tree_max_bytes_to_use_cache` bir sorguda bayt, sıkıştırılmamış blokların önbelleğini kullanmaz. -Sıkıştırılmamış blokların önbelleği, sorgular için ayıklanan verileri depolar. ClickHouse, tekrarlanan küçük sorgulara verilen yanıtları hızlandırmak için bu önbelleği kullanır. Bu ayar, önbelleğin büyük miktarda veri okuyan sorgularla çöpe atmasını önler. Bu [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) sunucu ayarı, sıkıştırılmamış blokların önbelleğinin boyutunu tanımlar. +Sıkıştırılmamış blokların önbelleği, sorgular için ayıklanan verileri depolar. ClickHouse, tekrarlanan küçük sorgulara verilen yanıtları hızlandırmak için bu önbelleği kullanır. Bu ayar, önbelleğin büyük miktarda veri okuyan sorgularla çöpe atmasını önler. Bu [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) sunucu ayarı, sıkıştırılmamış blokların önbelleğinin boyutunu tanımlar. Olası değer: @@ -516,7 +514,7 @@ Varsayılan değer: 0. Sorgu günlüğü ayarlama. -Bu kurulum ile Clickhouse'a gönderilen sorgular, [query\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-log) sunucu yapılandırma parametresi. +Bu kurulum ile Clickhouse'a gönderilen sorgular, [query\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query-log) sunucu yapılandırma parametresi. Örnek: @@ -546,7 +544,7 @@ log_queries_min_type='EXCEPTION_WHILE_PROCESSING' Sorgu iş parçacığı günlüğü ayarlama. -Bu kurulum ile ClickHouse tarafından çalıştırılan sorguların konuları, [query\_thread\_log](../server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu yapılandırma parametresi. +Bu kurulum ile ClickHouse tarafından çalıştırılan sorguların konuları, [query\_thread\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu yapılandırma parametresi. Örnek: @@ -566,9 +564,31 @@ Varsayılan değer: 1.048,576. Varsayılan biraz daha fazla `max_block_size`. Bunun nedeni, bazı tablo motorlarının (`*MergeTree`) oldukça büyük bir varlık olan eklenen her blok için diskte bir veri parçası oluşturun. Benzer bir şekilde, `*MergeTree` tablolar ekleme sırasında verileri sıralar ve yeterince büyük bir blok boyutu RAM'de daha fazla veriyi sıralamaya izin verir. +## min\_insert\_block\_size\_rows {#min-insert-block-size-rows} + +Bir tabloya eklenebilen blok içindeki minimum satır sayısını ayarlar. `INSERT` sorgu. Daha küçük boyutlu bloklar daha büyük olanlara ezilir. + +Olası değerler: + +- Pozitif tamsayı. +- 0 — Squashing disabled. + +Varsayılan değer: 1048576. + +## min\_insert\_block\_size\_bytes {#min-insert-block-size-bytes} + +Bir tabloya eklenebilen blok içindeki minimum bayt sayısını ayarlar. `INSERT` sorgu. Daha küçük boyutlu bloklar daha büyük olanlara ezilir. + +Olası değerler: + +- Pozitif tamsayı. +- 0 — Squashing disabled. + +Varsayılan değer: 268435456. + ## max\_replica\_delay\_for\_distributed\_queries {#settings-max_replica_delay_for_distributed_queries} -Dağıtılmış sorgular için gecikmeli yinelemeleri devre dışı bırakır. Görmek [Çoğalma](../../engines/table_engines/mergetree_family/replication.md). +Dağıtılmış sorgular için gecikmeli yinelemeleri devre dışı bırakır. Görmek [Çoğalma](../../engines/table-engines/mergetree-family/replication.md). Saati saniye olarak ayarlar. Bir çoğaltma ayarlanan değerden daha fazla kalıyorsa, Bu çoğaltma kullanılmaz. @@ -613,7 +633,7 @@ Sıkıştırma için blokları (bayttan oluşan bir bellek yığını) sorgu iş ## min\_compress\_block\_size {#min-compress-block-size} -İçin [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)" Tablolar. Sorguları işlerken gecikmeyi azaltmak için, boyutu en az bir sonraki işareti yazarken bir blok sıkıştırılır ‘min\_compress\_block\_size’. Varsayılan olarak, 65.536. +İçin [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)" Tablolar. Sorguları işlerken gecikmeyi azaltmak için, boyutu en az bir sonraki işareti yazarken bir blok sıkıştırılır ‘min\_compress\_block\_size’. Varsayılan olarak, 65.536. Sıkıştırılmamış veriler daha az ise, bloğun gerçek boyutu ‘max\_compress\_block\_size’, bu değerden daha az değildir ve bir işaret için veri hacminden daha az değildir. @@ -691,7 +711,7 @@ Daha fazla bilgi için bölüme bakın “Extreme values”. ## use\_uncompressed\_cache {#setting-use_uncompressed_cache} Sıkıştırılmamış blokların önbelleğinin kullanılıp kullanılmayacağı. 0 veya 1 kabul eder. Varsayılan olarak, 0 (devre dışı). -Sıkıştırılmamış önbelleği (yalnızca mergetree ailesindeki tablolar için) kullanmak, çok sayıda kısa Sorgu ile çalışırken gecikmeyi önemli ölçüde azaltabilir ve verimi artırabilir. Sık sık kısa istek Gönderen kullanıcılar için bu ayarı etkinleştirin. Ayrıca dikkat [uncompressed\_cache\_size](../server_configuration_parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. +Sıkıştırılmamış önbelleği (yalnızca mergetree ailesindeki tablolar için) kullanmak, çok sayıda kısa Sorgu ile çalışırken gecikmeyi önemli ölçüde azaltabilir ve verimi artırabilir. Sık sık kısa istek Gönderen kullanıcılar için bu ayarı etkinleştirin. Ayrıca dikkat [uncompressed\_cache\_size](../server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted. En azından biraz büyük bir veri hacmi (bir milyon satır veya daha fazla) okuyan sorgular için sıkıştırılmamış önbellek, gerçekten küçük sorgular için yer kazanmak için otomatik olarak devre dışı bırakılır. Bu tutmak anlamına gelir ‘use\_uncompressed\_cache’ ayar her zaman 1 olarak ayarlanır. @@ -860,7 +880,7 @@ Ayrıca bakınız: - [ınsert\_quorum\_timeout](#settings-insert_quorum_timeout) - [select\_sequential\_consistency](#settings-select_sequential_consistency) -## ınsert\_quorum\_timeout {#settings-insert_quorum-timeout} +## ınsert\_quorum\_timeout {#settings-insert_quorum_timeout} Çekirdek zaman aşımına saniyeler içinde yazın. Zaman aşımı geçti ve yazma henüz gerçekleşmedi, ClickHouse bir özel durum oluşturur ve istemci aynı bloğu aynı veya başka bir yineleme yazmak için sorguyu yinelemeniz gerekir. @@ -902,7 +922,7 @@ Olası değerler: Varsayılan değer: 1. -Varsayılan olarak, çoğaltılmış tablolara eklenen bloklar `INSERT` deyim tekilleştirilir (bkz. \[Data Replication\] (../engines/table\_engines/mergetree\_family/replication.md). +Varsayılan olarak, çoğaltılmış tablolara eklenen bloklar `INSERT` açıklama tekilleştirilmiştir (bkz [Veri Çoğaltma](../../engines/table-engines/mergetree-family/replication.md)). ## deduplicate\_blocks\_ın\_dependent\_materialized\_views {#settings-deduplicate-blocks-in-dependent-materialized-views} @@ -968,15 +988,15 @@ Varsayılan değer: 0. ## count\_distinct\_implementation {#settings-count_distinct_implementation} -Aşağıdakilerden hang theisinin `uniq*` işlevleri gerçekleştirmek için kullanılmalıdır [COUNT(DISTINCT …)](../../sql_reference/aggregate_functions/reference.md#agg_function-count) yapma. +Aşağıdakilerden hang theisinin `uniq*` işlevleri gerçekleştirmek için kullanılmalıdır [COUNT(DISTINCT …)](../../sql-reference/aggregate-functions/reference.md#agg_function-count) yapı. Olası değerler: -- [uniq](../../sql_reference/aggregate_functions/reference.md#agg_function-uniq) -- [uniqCombined](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined) -- [uniqCombined64](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqcombined64) -- [uniqHLL12](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqhll12) -- [uniqExact](../../sql_reference/aggregate_functions/reference.md#agg_function-uniqexact) +- [uniq](../../sql-reference/aggregate-functions/reference.md#agg_function-uniq) +- [uniqCombined](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined) +- [uniqCombined64](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqcombined64) +- [uniqHLL12](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqhll12) +- [uniqExact](../../sql-reference/aggregate-functions/reference.md#agg_function-uniqexact) Varsayılan değer: `uniqExact`. @@ -1041,7 +1061,7 @@ Varsayılan değer: 0. ## optimize\_throw\_if\_noop {#setting-optimize_throw_if_noop} -Bir özel durum atmayı etkinleştirir veya devre dışı bırakır. [OPTIMIZE](../../sql_reference/statements/misc.md#misc_operations-optimize) sorgu birleştirme gerçekleştirmedi. +Bir özel durum atmayı etkinleştirir veya devre dışı bırakır. [OPTIMIZE](../../sql-reference/statements/misc.md#misc_operations-optimize) sorgu birleştirme gerçekleştirmedi. Varsayılan olarak, `OPTIMIZE` eğer hiç bir şey yapmamış olsa bile, başarılı bir şekilde verir. Bu ayar, bu durumları ayırt etmenizi ve bir özel durum iletisinde nedeni almanızı sağlar. @@ -1061,7 +1081,7 @@ Dağıtılmış tablolardaki hataların ne kadar hızlı sıfırlandığını de Ayrıca bakınız: -- [Masa motoru Dağıt Distributedıldı](../../engines/table_engines/special/distributed.md) +- [Masa motoru Dağıt Distributedıldı](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_cap](#settings-distributed_replica_error_cap) ## distributed\_replica\_error\_cap {#settings-distributed_replica_error_cap} @@ -1073,12 +1093,12 @@ Her yineleme hata sayısı çok fazla hata biriken tek bir yineleme engelleyerek Ayrıca bakınız: -- [Masa motoru Dağıt Distributedıldı](../../engines/table_engines/special/distributed.md) +- [Masa motoru Dağıt Distributedıldı](../../engines/table-engines/special/distributed.md) - [distributed\_replica\_error\_half\_life](#settings-distributed_replica_error_half_life) ## distributed\_directory\_monitor\_sleep\_time\_ms {#distributed_directory_monitor_sleep_time_ms} -İçin taban aralığı [Dağılı](../../engines/table_engines/special/distributed.md) veri göndermek için tablo motoru. Gerçek Aralık, hatalar durumunda katlanarak büyür. +İçin taban aralığı [Dağılı](../../engines/table-engines/special/distributed.md) veri göndermek için tablo motoru. Gerçek Aralık, hatalar durumunda katlanarak büyür. Olası değerler: @@ -1088,7 +1108,7 @@ Varsayılan değer: 100 milisaniye. ## distributed\_directory\_monitor\_max\_sleep\_time\_ms {#distributed_directory_monitor_max_sleep_time_ms} -İçin Maksimum Aralık [Dağılı](../../engines/table_engines/special/distributed.md) veri göndermek için tablo motoru. Sınırları içinde belirlenen Aralık üstel büyüme [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) ayar. +İçin Maksimum Aralık [Dağılı](../../engines/table-engines/special/distributed.md) veri göndermek için tablo motoru. Sınırları içinde belirlenen Aralık üstel büyüme [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) ayar. Olası değerler: @@ -1100,7 +1120,7 @@ Varsayılan değer: 30000 milisaniye (30 saniye). Eklenen verilerin toplu olarak gönderilmesini etkinleştirir / devre dışı bırakır. -Toplu gönderme etkinleştirildiğinde, [Dağılı](../../engines/table_engines/special/distributed.md) table engine, eklenen verilerin birden çok dosyasını ayrı ayrı göndermek yerine tek bir işlemde göndermeye çalışır. Toplu gönderme, sunucu ve ağ kaynaklarını daha iyi kullanarak küme performansını artırır. +Toplu gönderme etkinleştirildiğinde, [Dağılı](../../engines/table-engines/special/distributed.md) table engine, eklenen verilerin birden çok dosyasını ayrı ayrı göndermek yerine tek bir işlemde göndermeye çalışır. Toplu gönderme, sunucu ve ağ kaynaklarını daha iyi kullanarak küme performansını artırır. Olası değerler: @@ -1126,7 +1146,7 @@ Varsayılan değer: 0. ## query\_profiler\_real\_time\_period\_ns {#query_profiler_real_time_period_ns} -Gerçek bir saat zamanlayıcı için süreyi ayarlar [sorgu profiler](../../operations/optimizing_performance/sampling_query_profiler.md). Gerçek saat zamanlayıcı duvar saati zaman sayar. +Gerçek bir saat zamanlayıcı için süreyi ayarlar [sorgu profiler](../../operations/optimizing-performance/sampling-query-profiler.md). Gerçek saat zamanlayıcı duvar saati zaman sayar. Olası değerler: @@ -1139,17 +1159,17 @@ Olası değerler: - Zamanlayıcıyı kapatmak için 0. -Tür: [Uİnt64](../../sql_reference/data_types/int_uint.md). +Tür: [Uİnt64](../../sql-reference/data-types/int-uint.md). Varsayılan değer: 1000000000 nanosaniye (saniyede bir kez). Ayrıca bakınız: -- Sistem tablosu [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- Sistem tablosu [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## query\_profiler\_cpu\_time\_period\_ns {#query_profiler_cpu_time_period_ns} -Bir CPU saat süreölçerinin dönemini ayarlar. [sorgu profiler](../../operations/optimizing_performance/sampling_query_profiler.md). Bu zamanlayıcı sadece CPU süresini sayar. +Bir CPU saat süreölçerinin dönemini ayarlar. [sorgu profiler](../../operations/optimizing-performance/sampling-query-profiler.md). Bu zamanlayıcı sadece CPU süresini sayar. Olası değerler: @@ -1162,17 +1182,17 @@ Olası değerler: - Zamanlayıcıyı kapatmak için 0. -Tür: [Uİnt64](../../sql_reference/data_types/int_uint.md). +Tür: [Uİnt64](../../sql-reference/data-types/int-uint.md). Varsayılan değer: 1000000000 nanosaniye. Ayrıca bakınız: -- Sistem tablosu [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- Sistem tablosu [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## allow\_introspection\_functions {#settings-allow_introspection_functions} -Devre dışı bırakmayı etkinleştirir [ıntrospections fonksiyonları](../../sql_reference/functions/introspection.md) sorgu profilleme için. +Devre dışı bırakmayı etkinleştirir [ıntrospections fonksiyonları](../../sql-reference/functions/introspection.md) sorgu profilleme için. Olası değerler: @@ -1183,8 +1203,8 @@ Varsayılan değer: 0. **Ayrıca Bakınız** -- [Örnekleme Sorgusu Profiler](../optimizing_performance/sampling_query_profiler.md) -- Sistem tablosu [trace\_log](../../operations/system_tables.md#system_tables-trace_log) +- [Örnekleme Sorgusu Profiler](../optimizing-performance/sampling-query-profiler.md) +- Sistem tablosu [trace\_log](../../operations/system-tables.md#system_tables-trace_log) ## ınput\_format\_parallel\_parsing {#input-format-parallel-parsing} @@ -1232,4 +1252,14 @@ Type: URL Varsayılan değer: boş +## background\_pool\_size {#background_pool_size} + +Tablo altyapılarında arka plan işlemlerini gerçekleştiren iş parçacıklarının sayısını ayarlar (örneğin, [MergeTree motoru](../../engines/table-engines/mergetree-family/index.md) Tablolar). Bu ayar ClickHouse sunucu başlangıcında uygulanır ve bir kullanıcı oturumunda değiştirilemez. Bu ayarı ayarlayarak, CPU ve disk yükünü yönetirsiniz. Daha küçük havuz boyutu daha az CPU ve disk kaynağı kullanır, ancak arka plan işlemleri daha yavaş ilerler ve bu da sorgu performansını etkileyebilir. + +Olası değerler: + +- Herhangi bir pozitif tamsayı. + +Varsayılan değer: 16. + [Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/settings/) diff --git a/docs/tr/operations/settings/settings_profiles.md b/docs/tr/operations/settings/settings_profiles.md deleted file mode 100644 index 318276ab6c8..00000000000 --- a/docs/tr/operations/settings/settings_profiles.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 61 -toc_title: Ayarlar Profilleri ---- - -# Ayarlar Profilleri {#settings-profiles} - -Ayarlar profili, aynı ad altında gruplandırılmış ayarlar topluluğudur. Her ClickHouse kullanıcısının bir profili vardır. -Bir profildeki tüm ayarları uygulamak için `profile` ayar. - -Örnek: - -Yüklemek `web` profilli. - -``` sql -SET profile = 'web' -``` - -Ayarlar profilleri kullanıcı yapılandırma dosyasında bildirilir. Bu genellikle `users.xml`. - -Örnek: - -``` xml - - - - - - 8 - - - - - 1000000000 - 100000000000 - - 1000000 - any - - 1000000 - 1000000000 - - 100000 - 100000000 - break - - 600 - 1000000 - 15 - - 25 - 100 - 50 - - 2 - 25 - 50 - 100 - - 1 - - -``` - -Örnek iki profili belirtir: `default` ve `web`. Bu `default` profilin özel bir amacı vardır: her zaman mevcut olmalı ve sunucuyu başlatırken uygulanır. Diğer bir deyişle, `default` profil varsayılan ayarları içerir. Bu `web` profil kullanılarak ayarlanabilir düzenli bir profil `SET` sorgu veya bir HTTP sorgusunda bir URL parametresi kullanma. - -Ayarlar profilleri birbirinden miras alabilir. Kalıtım kullanmak için, bir veya birden fazla belirtiniz `profile` ayarlar profilde listelenen diğer ayarlardan önce. Farklı profillerde bir ayar tanımlandığında, en son tanımlı kullanılır. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/settings_profiles/) diff --git a/docs/tr/operations/settings/settings_users.md b/docs/tr/operations/settings/settings_users.md deleted file mode 100644 index 0bc2b5ac1a5..00000000000 --- a/docs/tr/operations/settings/settings_users.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 63 -toc_title: "Kullan\u0131c\u0131 Ayarlar\u0131" ---- - -# Kullanıcı Ayarları {#user-settings} - -Bu `users` bu bölüm `user.xml` yapılandırma dosyası kullanıcı ayarlarını içerir. - -Bu yapı `users` bölme: - -``` xml - - - - - - - - - - - profile_name - - default - - - - - expression - - - - - - -``` - -### home/şifre {#user-namepassword} - -Şifre düz metin veya SHA256 (hex formatında) belirtilebilir. - -- Düz metin içinde bir şifre atamak için (**tavsiye edilmez**bir koyun `password` öğe. - - Mesela, `qwerty`. Şifre boş bırakılabilir. - - - -- SHA256 karmasını kullanarak bir şifre atamak için, bir `password_sha256_hex` öğe. - - Mesela, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. - - Kabuktan bir parola oluşturma örneği: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' - - Sonucun ilk satırı şifredir. İkinci satır karşılık gelen SHA256 karmasıdır. - - - -- MySQL istemcileri ile uyumluluk için, şifre çift SHA1 karma belirtilebilir. İçine yerleştirin `password_double_sha1_hex` öğe. - - Mesela, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. - - Kabuktan bir parola oluşturma örneği: - - PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' - - Sonucun ilk satırı şifredir. İkinci satır karşılık gelen çift SHA1 karmasıdır. - -### kullanıcı\_adı / ağlar {#user-namenetworks} - -Kullanıcının ClickHouse sunucusuna bağlanabileceği ağların listesi. - -Listenin her öğesi aşağıdaki formlardan birine sahip olabilir: - -- `` — IP address or network mask. - - Örnekler: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. - -- `` — Hostname. - - Örnek: `example01.host.ru`. - - Erişimi denetlemek için bir DNS sorgusu gerçekleştirilir ve döndürülen tüm IP adresleri eş adresiyle karşılaştırılır. - -- `` — Regular expression for hostnames. - - Örnek, `^example\d\d-\d\d-\d\.host\.ru$` - - Erişimi kontrol etmek için, bir [DNS ptr sorgusu](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) eş adresi için gerçekleştirilir ve sonra belirtilen regexp uygulanır. Daha sonra PTR sorgusunun sonuçları için başka bir DNS sorgusu gerçekleştirilir ve alınan tüm adresler eş adresine karşılaştırılır. Regexp'nin $ile bitmesini şiddetle tavsiye ederiz. - -Sunucu yeniden başlatılıncaya kadar DNS isteklerinin tüm sonuçları önbelleğe alınır. - -**Örnekler** - -Herhangi bir ağdan kullanıcı için erişimi açmak için şunları belirtin: - -``` xml -::/0 -``` - -!!! warning "Uyarıcı" - Düzgün yapılandırılmış bir güvenlik duvarınız yoksa veya sunucu doğrudan internete bağlı değilse, herhangi bir ağdan erişimi açmak güvensizdir. - -Erişimi yalnızca localhost'tan açmak için şunları belirtin: - -``` xml -::1 -127.0.0.1 -``` - -### kullanıcı\_adı / profil {#user-nameprofile} - -Kullanıcı için bir ayarlar profili atayabilirsiniz. Ayarlar profilleri ayrı bir bölümde yapılandırılır `users.xml` Dosya. Daha fazla bilgi için, bkz. [Ayarların profilleri](settings_profiles.md). - -### user\_name / kota {#user-namequota} - -Kotalar, belirli bir süre boyunca kaynak kullanımını izlemenize veya sınırlamanıza izin verir. Kotalar yapılandırılır `quotas` -bu bölüm `users.xml` yapılandırma dosyası. - -Kullanıcı için ayarlanmış bir kotalar atayabilirsiniz. Kotalar yapılandırmasının ayrıntılı bir açıklaması için bkz. [Kotalar](../quotas.md#quotas). - -### user\_name / veritabanları {#user-namedatabases} - -Bu bölümde, ClickHouse tarafından döndürülen satırları sınırlayabilirsiniz `SELECT` geçerli kullanıcı tarafından yapılan sorgular, böylece temel satır düzeyinde güvenlik uygular. - -**Örnek** - -Aşağıdaki yapılandırma bu kullanıcıyı zorlar `user1` sadece satırları görebilirsiniz `table1` sonucu olarak `SELECT` sorgular, burada değeri `id` alan 1000'dir. - -``` xml - - - - - id = 1000 - - - - -``` - -Bu `filter` bir sonuç veren herhangi bir ifade olabilir [Uİnt8](../../sql_reference/data_types/int_uint.md)- tip değeri. Genellikle karşılaştırmalar ve mantıksal operatörler içerir. Satır fromlardan `database_name.table1` burada filtre sonuçları 0 için bu kullanıcı için döndürülür. Filtreleme ile uyumsuz `PREWHERE` işlemler ve devre dışı bırakır `WHERE→PREWHERE` optimizasyon. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/settings/settings_users/) diff --git a/docs/tr/operations/system-tables.md b/docs/tr/operations/system-tables.md new file mode 100644 index 00000000000..6a98f15aded --- /dev/null +++ b/docs/tr/operations/system-tables.md @@ -0,0 +1,1168 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 52 +toc_title: "Sistem Tablolar\u0131" +--- + +# Sistem Tabloları {#system-tables} + +Sistem tabloları, sistemin işlevselliğinin bir kısmını uygulamak ve sistemin nasıl çalıştığı hakkında bilgilere erişim sağlamak için kullanılır. +Bir sistem tablosunu silemezsiniz (ancak ayırma işlemini gerçekleştirebilirsiniz). +Sistem tablolarında diskte veri bulunan dosyalar veya meta verilere sahip dosyalar yoktur. Sunucu, başlatıldığında tüm sistem tablolarını oluşturur. +Sistem tabloları salt okunur. +Bulun theurlar. ‘system’ veritabanı. + +## sistem.asynchronous\_metrics {#system_tables-asynchronous_metrics} + +Arka planda periyodik olarak hesaplanan metrikleri içerir. Örneğin, kullanılan RAM miktarı. + +Sütun: + +- `metric` ([Dize](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Float64](../sql-reference/data-types/float.md)) — Metric value. + +**Örnek** + +``` sql +SELECT * FROM system.asynchronous_metrics LIMIT 10 +``` + +``` text +┌─metric──────────────────────────────────┬──────value─┐ +│ jemalloc.background_thread.run_interval │ 0 │ +│ jemalloc.background_thread.num_runs │ 0 │ +│ jemalloc.background_thread.num_threads │ 0 │ +│ jemalloc.retained │ 422551552 │ +│ jemalloc.mapped │ 1682989056 │ +│ jemalloc.resident │ 1656446976 │ +│ jemalloc.metadata_thp │ 0 │ +│ jemalloc.metadata │ 10226856 │ +│ UncompressedCacheCells │ 0 │ +│ MarkCacheFiles │ 0 │ +└─────────────────────────────────────────┴────────────┘ +``` + +**Ayrıca Bakınız** + +- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. +- [sistem.metrik](#system_tables-metrics) — Contains instantly calculated metrics. +- [sistem.etkinlik](#system_tables-events) — Contains a number of events that have occurred. +- [sistem.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. + +## sistem.kümeler {#system-clusters} + +Yapılandırma dosyasında bulunan kümeler ve içindeki sunucular hakkında bilgi içerir. + +Sütun: + +- `cluster` (String) — The cluster name. +- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. +- `shard_weight` (UInt32) — The relative weight of the shard when writing data. +- `replica_num` (UInt32) — The replica number in the shard, starting from 1. +- `host_name` (String) — The host name, as specified in the config. +- `host_address` (String) — The host IP address obtained from DNS. +- `port` (UInt16) — The port to use for connecting to the server. +- `user` (String) — The name of the user for connecting to the server. +- `errors_count` (Uİnt32) - bu ana bilgisayarın çoğaltma ulaşamadı sayısı. +- `estimated_recovery_time` (Uİnt32) - çoğaltma hata sayısı sıfırlanana kadar saniye kaldı ve normale döndü olarak kabul edilir. + +Lütfen unutmayın `errors_count` küme için sorgu başına bir kez güncelleştirilir, ancak `estimated_recovery_time` isteğe bağlı olarak yeniden hesaplanır. Yani sıfır olmayan bir durum olabilir `errors_count` ve sıfır `estimated_recovery_time`, sonraki sorgu sıfır olacak `errors_count` ve hiçbir hata yokmuş gibi çoğaltma kullanmayı deneyin. + +**Ayrıca bakınız** + +- [Masa motoru Dağıt Distributedıldı](../engines/table-engines/special/distributed.md) +- [distributed\_replica\_error\_cap ayarı](settings/settings.md#settings-distributed_replica_error_cap) +- [distributed\_replica\_error\_half\_life ayarı](settings/settings.md#settings-distributed_replica_error_half_life) + +## sistem.sütun {#system-columns} + +Tüm tablolardaki sütunlar hakkında bilgi içerir. + +Benzer bilgileri almak için bu tabloyu kullanabilirsiniz [DESCRIBE TABLE](../sql-reference/statements/misc.md#misc-describe-table) sorgu, ancak aynı anda birden çok tablo için. + +Bu `system.columns` tablo aşağıdaki sütunları içerir (sütun türü parantez içinde gösterilir): + +- `database` (String) — Database name. +- `table` (String) — Table name. +- `name` (String) — Column name. +- `type` (String) — Column type. +- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) varsayılan değer veya tanımlanmamışsa boş bir dize için. +- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. +- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. +- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. +- `marks_bytes` (UInt64) — The size of marks, in bytes. +- `comment` (String) — Comment on the column, or an empty string if it is not defined. +- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. +- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. +- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. +- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. + +## sistem.katılımcılar {#system-contributors} + +Katkıda bulunanlar hakkında bilgi içerir. Rastgele sırayla tüm constributors. Sipariş, sorgu yürütme zamanında rasgele olur. + +Sütun: + +- `name` (String) — Contributor (author) name from git log. + +**Örnek** + +``` sql +SELECT * FROM system.contributors LIMIT 10 +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +│ Max Vetrov │ +│ LiuYangkuan │ +│ svladykin │ +│ zamulla │ +│ Šimon Podlipský │ +│ BayoNet │ +│ Ilya Khomutov │ +│ Amy Krishnevsky │ +│ Loud_Scream │ +└──────────────────┘ +``` + +Tabloda kendinizi bulmak için bir sorgu kullanın: + +``` sql +SELECT * FROM system.contributors WHERE name='Olga Khvostikova' +``` + +``` text +┌─name─────────────┐ +│ Olga Khvostikova │ +└──────────────────┘ +``` + +## sistem.veritabanılar {#system-databases} + +Bu tablo, adı verilen tek bir dize sütunu içerir ‘name’ – the name of a database. +Sunucunun bildiği her veritabanı, tabloda karşılık gelen bir girdiye sahiptir. +Bu sistem tablosu uygulamak için kullanılır `SHOW DATABASES` sorgu. + +## sistem.detached\_parts {#system_tables-detached_parts} + +Müstakil parçaları hakkında bilgiler içerir [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) Tablolar. Bu `reason` sütun, parçanın neden ayrıldığını belirtir. Kullanıcı tarafından ayrılmış parçalar için sebep boştur. Bu tür parçalar ile eklenebilir [ALTER TABLE ATTACH PARTITION\|PART](../sql-reference/statements/alter.md#alter_attach-partition) komut. Diğer sütunların açıklaması için bkz. [sistem.parçalar](#system_tables-parts). Bölüm adı geçersiz ise, bazı sütunların değerleri olabilir `NULL`. Bu tür parçalar ile silinebilir [ALTER TABLE DROP DETACHED PART](../sql-reference/statements/alter.md#alter_drop-detached). + +## sistem.sözlükler {#system_tables-dictionaries} + +Hakkında bilgi içerir [dış söz dictionarieslükler](../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +Sütun: + +- `database` ([Dize](../sql-reference/data-types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries. +- `name` ([Dize](../sql-reference/data-types/string.md)) — [Sözlük adı](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md). +- `status` ([Enum8](../sql-reference/data-types/enum.md)) — Dictionary status. Possible values: + - `NOT_LOADED` — Dictionary was not loaded because it was not used. + - `LOADED` — Dictionary loaded successfully. + - `FAILED` — Unable to load the dictionary as a result of an error. + - `LOADING` — Dictionary is loading now. + - `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../sql-reference/statements/system.md#query_language-system-reload-dictionary) sorgu, zaman aşımı, sözlük yapılandırması değişti). + - `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now. +- `origin` ([Dize](../sql-reference/data-types/string.md)) — Path to the configuration file that describes the dictionary. +- `type` ([Dize](../sql-reference/data-types/string.md)) — Type of a dictionary allocation. [Sözlükleri bellekte saklama](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md). +- `key` — [Anahtar tipi](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-key): Sayısal Tuş ([Uİnt64](../sql-reference/data-types/int-uint.md#uint-ranges)) or Сomposite key ([Dize](../sql-reference/data-types/string.md)) — form “(type 1, type 2, …, type n)”. +- `attribute.names` ([Dizi](../sql-reference/data-types/array.md)([Dize](../sql-reference/data-types/string.md))) — Array of [öznitelik adları](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) sözlük tarafından sağlanmıştır. +- `attribute.types` ([Dizi](../sql-reference/data-types/array.md)([Dize](../sql-reference/data-types/string.md))) — Corresponding array of [öznitelik türleri](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) sözlük tarafından sağlanmaktadır. +- `bytes_allocated` ([Uİnt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary. +- `query_count` ([Uİnt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot. +- `hit_rate` ([Float64](../sql-reference/data-types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache. +- `element_count` ([Uİnt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of items stored in the dictionary. +- `load_factor` ([Float64](../sql-reference/data-types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). +- `source` ([Dize](../sql-reference/data-types/string.md)) — Text describing the [veri kaynağı](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md) sözlük için. +- `lifetime_min` ([Uİnt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Minimum [ömür](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) bellekteki sözlüğün ardından ClickHouse sözlüğü yeniden yüklemeye çalışır (eğer `invalidate_query` ayarlanır, daha sonra sadece değiştiyse). Saniyeler içinde ayarlayın. +- `lifetime_max` ([Uİnt64](../sql-reference/data-types/int-uint.md#uint-ranges)) — Maximum [ömür](../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) bellekteki sözlüğün ardından ClickHouse sözlüğü yeniden yüklemeye çalışır (eğer `invalidate_query` ayarlanır, daha sonra sadece değiştiyse). Saniyeler içinde ayarlayın. +- `loading_start_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Start time for loading the dictionary. +- `last_successful_update_time` ([DateTime](../sql-reference/data-types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes. +- `loading_duration` ([Float32](../sql-reference/data-types/float.md)) — Duration of a dictionary loading. +- `last_exception` ([Dize](../sql-reference/data-types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. + +**Örnek** + +Sözlüğü yapılandırın. + +``` sql +CREATE DICTIONARY dictdb.dict +( + `key` Int64 DEFAULT -1, + `value_default` String DEFAULT 'world', + `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) +LIFETIME(MIN 0 MAX 1) +LAYOUT(FLAT()) +``` + +Sözlüğün yüklendiğinden emin olun. + +``` sql +SELECT * FROM system.dictionaries +``` + +``` text +┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ +│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ +└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ +``` + +## sistem.etkinlik {#system_tables-events} + +Sistemde meydana gelen olayların sayısı hakkında bilgi içerir. Örneğin, tabloda kaç tane bulabilirsiniz `SELECT` ClickHouse sunucusu başladığından beri sorgular işlendi. + +Sütun: + +- `event` ([Dize](../sql-reference/data-types/string.md)) — Event name. +- `value` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Number of events occurred. +- `description` ([Dize](../sql-reference/data-types/string.md)) — Event description. + +**Örnek** + +``` sql +SELECT * FROM system.events LIMIT 5 +``` + +``` text +┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ +│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ +│ FileOpen │ 73 │ Number of files opened. │ +│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ +│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ +└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [sistem.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [sistem.metrik](#system_tables-metrics) — Contains instantly calculated metrics. +- [sistem.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. + +## sistem.işlevler {#system-functions} + +Normal ve toplama işlevleri hakkında bilgi içerir. + +Sütun: + +- `name`(`String`) – The name of the function. +- `is_aggregate`(`UInt8`) — Whether the function is aggregate. + +## sistem.graphite\_retentions {#system-graphite-retentions} + +Parametreleri hakkında bilgi içerir [graphite\_rollup](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) tablo usedlarında kullanılan [\* Graphıtemergetree](../engines/table-engines/mergetree-family/graphitemergetree.md) motorlar. + +Sütun: + +- `config_name` (Dize) - `graphite_rollup` parametre adı. +- `regexp` (String) - metrik adı için bir desen. +- `function` (String) - toplama işlevinin adı. +- `age` (Uint64) - saniye cinsinden verilerin minimum yaş. +- `precision` (Uİnt64) - verilerin yaşını saniyeler içinde tam olarak tanımlamak için. +- `priority` (Uİnt16) - desen önceliği. +- `is_default` (Uİnt8) - desenin varsayılan olup olmadığı. +- `Tables.database` (Array (String)) - kullanılan veritabanı tablolarının adlarının dizisi `config_name` parametre. +- `Tables.table` (Array (String)) - kullanılan tablo adları dizisi `config_name` parametre. + +## sistem.birleştiriyor {#system-merges} + +Mergetree ailesindeki tablolar için şu anda işlemde olan birleştirme ve parça mutasyonları hakkında bilgi içerir. + +Sütun: + +- `database` (String) — The name of the database the table is in. +- `table` (String) — Table name. +- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. +- `progress` (Float64) — The percentage of completed work from 0 to 1. +- `num_parts` (UInt64) — The number of pieces to be merged. +- `result_part_name` (String) — The name of the part that will be formed as the result of merging. +- `is_mutation` (Uİnt8 ) - 1 Bu işlem bir parça mutasyonu ise. +- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. +- `total_size_marks` (UInt64) — The total number of marks in the merged parts. +- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. +- `rows_read` (UInt64) — Number of rows read. +- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. +- `rows_written` (UInt64) — Number of rows written. + +## sistem.metrik {#system_tables-metrics} + +Anında hesaplanan veya geçerli bir değere sahip olabilir metrikleri içerir. Örneğin, aynı anda işlenen sorguların sayısı veya geçerli yineleme gecikmesi. Bu tablo her zaman güncel. + +Sütun: + +- `metric` ([Dize](../sql-reference/data-types/string.md)) — Metric name. +- `value` ([Int64](../sql-reference/data-types/int-uint.md)) — Metric value. +- `description` ([Dize](../sql-reference/data-types/string.md)) — Metric description. + +Desteklenen metriklerin listesi [src / ortak / CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) ClickHouse kaynak dosyası. + +**Örnek** + +``` sql +SELECT * FROM system.metrics LIMIT 10 +``` + +``` text +┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Query │ 1 │ Number of executing queries │ +│ Merge │ 0 │ Number of executing background merges │ +│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ +│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ +│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ +│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ +│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ +│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ +│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ +│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ +└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [sistem.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [sistem.etkinlik](#system_tables-events) — Contains a number of events that occurred. +- [sistem.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. +- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. + +## sistem.metric\_log {#system_tables-metric_log} + +Tablolardan metrik değerlerinin geçmişini içerir `system.metrics` ve `system.events`, periyodik olarak diske boşaltılır. +Metrik geçmişi koleksiyonunu açmak için `system.metric_log`, oluşturmak `/etc/clickhouse-server/config.d/metric_log.xml` aşağıdaki içerik ile: + +``` xml + + + system + metric_log
+ 7500 + 1000 +
+
+``` + +**Örnek** + +``` sql +SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; +``` + +``` text +Row 1: +────── +event_date: 2020-02-18 +event_time: 2020-02-18 07:15:33 +milliseconds: 554 +ProfileEvent_Query: 0 +ProfileEvent_SelectQuery: 0 +ProfileEvent_InsertQuery: 0 +ProfileEvent_FileOpen: 0 +ProfileEvent_Seek: 0 +ProfileEvent_ReadBufferFromFileDescriptorRead: 1 +ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 +ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 +ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 +ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 +ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 +... +CurrentMetric_Query: 0 +CurrentMetric_Merge: 0 +CurrentMetric_PartMutation: 0 +CurrentMetric_ReplicatedFetch: 0 +CurrentMetric_ReplicatedSend: 0 +CurrentMetric_ReplicatedChecks: 0 +... +``` + +**Ayrıca bakınız** + +- [sistem.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. +- [sistem.etkinlik](#system_tables-events) — Contains a number of events that occurred. +- [sistem.metrik](#system_tables-metrics) — Contains instantly calculated metrics. +- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. + +## sistem.şiir {#system-numbers} + +Bu tablo adında tek bir uint64 sütunu içerir ‘number’ bu sıfırdan başlayarak hemen hemen tüm doğal sayıları içerir. +Bu tabloyu testler için veya kaba kuvvet araması yapmanız gerekiyorsa kullanabilirsiniz. +Bu tablodan okumalar parallelized değil. + +## sistem.numbers\_mt {#system-numbers-mt} + +Olarak aynı ‘system.numbers’ ancak okumalar paralelleştirilmiştir. Sayılar herhangi bir sırayla iade edilebilir. +Testler için kullanılır. + +## sistem.bir {#system-one} + +Bu tablo, tek bir satır içeren tek bir satır içerir ‘dummy’ 0 değerini içeren uint8 sütunu. +SELECT sorgusu FROM yan tümcesi belirtmezse, bu tablo kullanılır. +Bu, diğer Dbms'lerde bulunan ikili tabloya benzer. + +## sistem.parçalar {#system_tables-parts} + +Bölümleri hakkında bilgi içerir [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) Tablolar. + +Her satır bir veri bölümünü açıklar. + +Sütun: + +- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql-reference/statements/alter.md#query_language_queries_alter) sorgu. + + Biçimliler: + + - `YYYYMM` ay otomatik bölümleme için. + - `any_string` el ile bölümleme yaparken. + +- `name` (`String`) – Name of the data part. + +- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging. + +- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` dizin ayrıntısına göre (genellikle 8192) (bu ipucu uyarlanabilir ayrıntı için çalışmaz). + +- `rows` (`UInt64`) – The number of rows. + +- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. + +- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. + +- `marks_bytes` (`UInt64`) – The size of the file with marks. + +- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| + +- `remove_time` (`DateTime`) – The time when the data part became inactive. + +- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. + +- `min_date` (`Date`) – The minimum value of the date key in the data part. + +- `max_date` (`Date`) – The maximum value of the date key in the data part. + +- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. + +- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. + +- `partition_id` (`String`) – ID of the partition. + +- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. + +- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. + +- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. + +- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). + +- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. + +- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. + +- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../sql-reference/statements/alter.md#alter_freeze-partition) + +- `database` (`String`) – Name of the database. + +- `table` (`String`) – Name of the table. + +- `engine` (`String`) – Name of the table engine without parameters. + +- `path` (`String`) – Absolute path to the folder with data part files. + +- `disk` (`String`) – Name of a disk that stores the data part. + +- `hash_of_all_files` (`String`) – [sifash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) sıkıştırılmış dosyaların. + +- `hash_of_uncompressed_files` (`String`) – [sifash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) sıkıştırılmamış dosyaların (işaretli dosyalar, dizin dosyası vb.)). + +- `uncompressed_hash_of_compressed_files` (`String`) – [sifash128](../sql-reference/functions/hash-functions.md#hash_functions-siphash128) sıkıştırılmış dosyalardaki verilerin sıkıştırılmamış gibi. + +- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. + +- `marks_size` (`UInt64`) – Alias for `marks_bytes`. + +## sistem.part\_log {#system_tables-part-log} + +Bu `system.part_log` tablo yalnızca aşağıdaki durumlarda oluşturulur: [part\_log](server-configuration-parameters/settings.md#server_configuration_parameters-part-log) sunucu ayarı belirtilir. + +Bu tablo ile oluşan olaylar hakkında bilgi içerir [veri parçaları](../engines/table-engines/mergetree-family/custom-partitioning-key.md) in the [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) veri ekleme veya birleştirme gibi aile tabloları. + +Bu `system.part_log` tablo aşağıdaki sütunları içerir: + +- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: + - `NEW_PART` — Inserting of a new data part. + - `MERGE_PARTS` — Merging of data parts. + - `DOWNLOAD_PART` — Downloading a data part. + - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql-reference/statements/alter.md#alter_detach-partition). + - `MUTATE_PART` — Mutating of a data part. + - `MOVE_PART` — Moving the data part from the one disk to another one. +- `event_date` (Date) — Event date. +- `event_time` (DateTime) — Event time. +- `duration_ms` (UInt64) — Duration. +- `database` (String) — Name of the database the data part is in. +- `table` (String) — Name of the table the data part is in. +- `part_name` (String) — Name of the data part. +- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ bölümleme tarafından ise değer `tuple()`. +- `rows` (UInt64) — The number of rows in the data part. +- `size_in_bytes` (UInt64) — Size of the data part in bytes. +- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). +- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. +- `read_rows` (UInt64) — The number of rows was read during the merge. +- `read_bytes` (UInt64) — The number of bytes was read during the merge. +- `error` (UInt16) — The code number of the occurred error. +- `exception` (String) — Text message of the occurred error. + +Bu `system.part_log` tablo ilk veri ekleme sonra oluşturulur `MergeTree` Tablo. + +## sistem.işleyişler {#system_tables-processes} + +Bu sistem tablosu uygulamak için kullanılır `SHOW PROCESSLIST` sorgu. + +Sütun: + +- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` kullanan. Alan, bu sorgunun başlattığı bir sorgu için değil, belirli bir sorgunun kullanıcı adını içerir. +- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` sorgu istek sahibi sunucuda. +- `elapsed` (Float64) – The time in seconds since request execution started. +- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. +- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. +- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../operations/settings/query-complexity.md#settings_max_memory_usage) ayar. +- `query` (String) – The query text. For `INSERT`, eklemek için veri içermez. +- `query_id` (String) – Query ID, if defined. + +## sistem.text\_log {#system-tables-text-log} + +Günlük girişleri içerir. Bu tabloya giden günlük seviyesi ile sınırlı olabilir `text_log.level` sunucu ayarı. + +Sütun: + +- `event_date` (`Date`)- Giriş tarihi. +- `event_time` (`DateTime`)- Giriş zamanı. +- `microseconds` (`UInt32`)- Girişin mikrosaniye. +- `thread_name` (String) — Name of the thread from which the logging was done. +- `thread_id` (UInt64) — OS thread ID. +- `level` (`Enum8`)- Giriş seviyesi. + - `'Fatal' = 1` + - `'Critical' = 2` + - `'Error' = 3` + - `'Warning' = 4` + - `'Notice' = 5` + - `'Information' = 6` + - `'Debug' = 7` + - `'Trace' = 8` +- `query_id` (`String`)- Sorgunun kimliği. +- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) +- `message` (`String`)- Mesajın kendisi . +- `revision` (`UInt32`)- ClickHouse revizyon. +- `source_file` (`LowCardinality(String)`)- Günlüğü yapıldığı kaynak dosya. +- `source_line` (`UInt64`)- Kaynak satır hangi günlüğü yapıldı. + +## sistem.query\_log {#system_tables-query_log} + +Sorguların yürütülmesi hakkında bilgi içerir. Her sorgu için, işlem başlangıç saatini, işlem süresini, hata mesajlarını ve diğer bilgileri görebilirsiniz. + +!!! note "Not" + Tablo için giriş verileri içermiyor `INSERT` sorgular. + +ClickHouse bu tabloyu yalnızca [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) sunucu parametresi belirtilir. Bu parametre, günlük aralığı veya sorguların oturum açacağı tablonun adı gibi günlük kurallarını ayarlar. + +Sorgu günlüğünü etkinleştirmek için, [log\_queries](settings/settings.md#settings-log-queries) parametre 1. Ayrıntılar için, bkz. [Ayarlar](settings/settings.md) bölme. + +Bu `system.query_log` tablo iki tür sorgu kaydeder: + +1. Doğrudan istemci tarafından çalıştırılan ilk sorgular. +2. Diğer sorgular tarafından başlatılan alt sorgular (dağıtılmış sorgu yürütme için). Bu tür sorgular için, üst sorgular hakkında bilgi `initial_*` sütun. + +Sütun: + +- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: + - `'QueryStart' = 1` — Successful start of query execution. + - `'QueryFinish' = 2` — Successful end of query execution. + - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. + - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. +- `event_date` (Date) — Query starting date. +- `event_time` (DateTime) — Query starting time. +- `query_start_time` (DateTime) — Start time of query execution. +- `query_duration_ms` (UInt64) — Duration of query execution. +- `read_rows` (UInt64) — Number of read rows. +- `read_bytes` (UInt64) — Number of read bytes. +- `written_rows` (UInt64) — For `INSERT` sorgular, yazılı satır sayısı. Diğer sorgular için sütun değeri 0'dır. +- `written_bytes` (UInt64) — For `INSERT` sorgular, yazılı bayt sayısı. Diğer sorgular için sütun değeri 0'dır. +- `result_rows` (UInt64) — Number of rows in the result. +- `result_bytes` (UInt64) — Number of bytes in the result. +- `memory_usage` (UInt64) — Memory consumption by the query. +- `query` (String) — Query string. +- `exception` (String) — Exception message. +- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. +- `is_initial_query` (UInt8) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` (String) — Name of the user who initiated the current query. +- `query_id` (String) — ID of the query. +- `address` (IPv6) — IP address that was used to make the query. +- `port` (UInt16) — The client port that was used to make the query. +- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` (String) — ID of the initial query (for distributed query execution). +- `initial_address` (IPv6) — IP address that the parent query was launched from. +- `initial_port` (UInt16) — The client port that was used to make the parent query. +- `interface` (UInt8) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` (String) — OS's username who runs [clickhouse-müşteri](../interfaces/cli.md). +- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi çalıştırılır. +- `client_name` (String) — The [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci adı. +- `client_revision` (UInt32) — Revision of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. +- `client_version_major` (UInt32) — Major version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. +- `client_version_minor` (UInt32) — Minor version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. +- `client_version_patch` (UInt32) — Patch component of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci sürümü. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` yöntem kullanılmıştır. + - 2 — `POST` yöntem kullanılmıştır. +- `http_user_agent` (String) — The `UserAgent` başlık http isteğinde geçti. +- `quota_key` (String) — The “quota key” belirtilen [kotalar](quotas.md) ayarı (bakınız `keyed`). +- `revision` (UInt32) — ClickHouse revision. +- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. +- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [sistem.etkinlik](#system_tables-events) +- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` sütun. +- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parametre 1. +- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` sütun. + +Her sorgu bir veya iki satır oluşturur `query_log` tablo, sorgunun durumuna bağlı olarak: + +1. Sorgu yürütme başarılı olursa, tip 1 ve 2 ile iki olay oluşturulur (bkz. `type` sütun). +2. Sorgu işleme sırasında bir hata oluştu, iki olay türleri 1 ve 4 oluşturulur. +3. Sorguyu başlatmadan önce bir hata oluşmuşsa, 3 tipi olan tek bir olay oluşturulur. + +Varsayılan olarak, günlükleri 7.5 saniye aralıklarla tabloya eklenir. Bu aralığı ayarlayabilirsiniz [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) sunucu ayarı (bkz. `flush_interval_milliseconds` parametre). Günlükleri zorla bellek arabelleğinden tabloya temizlemek için `SYSTEM FLUSH LOGS` sorgu. + +Tablo elle silindiğinde, otomatik olarak anında oluşturulur. Önceki tüm günlüklerin silineceğini unutmayın. + +!!! note "Not" + Günlüklerin depolama süresi sınırsızdır. Günlükler tablodan otomatik olarak silinmez. Eski günlüklerin kaldırılmasını kendiniz düzenlemeniz gerekir. + +İçin keyfi bir bölümleme anahtarı belirtebilirsiniz `system.query_log` tablo içinde [query\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-log) sunucu ayarı (bkz. `partition_by` parametre). + +## sistem.query\_thread\_log {#system_tables-query-thread-log} + +Tablo, her sorgu yürütme iş parçacığı hakkında bilgi içerir. + +ClickHouse bu tabloyu yalnızca [query\_thread\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu parametresi belirtilir. Bu parametre, günlük aralığı veya sorguların oturum açacağı tablonun adı gibi günlük kurallarını ayarlar. + +Sorgu günlüğünü etkinleştirmek için, [log\_query\_threads](settings/settings.md#settings-log-query-threads) parametre 1. Ayrıntılar için, bkz. [Ayarlar](settings/settings.md) bölme. + +Sütun: + +- `event_date` (Date) — the date when the thread has finished execution of the query. +- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. +- `query_start_time` (DateTime) — Start time of query execution. +- `query_duration_ms` (UInt64) — Duration of query execution. +- `read_rows` (UInt64) — Number of read rows. +- `read_bytes` (UInt64) — Number of read bytes. +- `written_rows` (UInt64) — For `INSERT` sorgular, yazılı satır sayısı. Diğer sorgular için sütun değeri 0'dır. +- `written_bytes` (UInt64) — For `INSERT` sorgular, yazılı bayt sayısı. Diğer sorgular için sütun değeri 0'dır. +- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. +- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. +- `thread_name` (String) — Name of the thread. +- `thread_number` (UInt32) — Internal thread ID. +- `os_thread_id` (Int32) — OS thread ID. +- `master_thread_id` (UInt64) — OS initial ID of initial thread. +- `query` (String) — Query string. +- `is_initial_query` (UInt8) — Query type. Possible values: + - 1 — Query was initiated by the client. + - 0 — Query was initiated by another query for distributed query execution. +- `user` (String) — Name of the user who initiated the current query. +- `query_id` (String) — ID of the query. +- `address` (IPv6) — IP address that was used to make the query. +- `port` (UInt16) — The client port that was used to make the query. +- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). +- `initial_query_id` (String) — ID of the initial query (for distributed query execution). +- `initial_address` (IPv6) — IP address that the parent query was launched from. +- `initial_port` (UInt16) — The client port that was used to make the parent query. +- `interface` (UInt8) — Interface that the query was initiated from. Possible values: + - 1 — TCP. + - 2 — HTTP. +- `os_user` (String) — OS's username who runs [clickhouse-müşteri](../interfaces/cli.md). +- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi çalıştırılır. +- `client_name` (String) — The [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci adı. +- `client_revision` (UInt32) — Revision of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. +- `client_version_major` (UInt32) — Major version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. +- `client_version_minor` (UInt32) — Minor version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. +- `client_version_patch` (UInt32) — Patch component of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci sürümü. +- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: + - 0 — The query was launched from the TCP interface. + - 1 — `GET` yöntem kullanılmıştır. + - 2 — `POST` yöntem kullanılmıştır. +- `http_user_agent` (String) — The `UserAgent` başlık http isteğinde geçti. +- `quota_key` (String) — The “quota key” belirtilen [kotalar](quotas.md) ayarı (bakınız `keyed`). +- `revision` (UInt32) — ClickHouse revision. +- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [sistem.etkinlik](#system_tables-events) +- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` sütun. + +Varsayılan olarak, günlükleri 7.5 saniye aralıklarla tabloya eklenir. Bu aralığı ayarlayabilirsiniz [query\_thread\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu ayarı (bkz. `flush_interval_milliseconds` parametre). Günlükleri zorla bellek arabelleğinden tabloya temizlemek için `SYSTEM FLUSH LOGS` sorgu. + +Tablo elle silindiğinde, otomatik olarak anında oluşturulur. Önceki tüm günlüklerin silineceğini unutmayın. + +!!! note "Not" + Günlüklerin depolama süresi sınırsızdır. Günlükler tablodan otomatik olarak silinmez. Eski günlüklerin kaldırılmasını kendiniz düzenlemeniz gerekir. + +İçin keyfi bir bölümleme anahtarı belirtebilirsiniz `system.query_thread_log` tablo içinde [query\_thread\_log](server-configuration-parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu ayarı (bkz. `partition_by` parametre). + +## sistem.trace\_log {#system_tables-trace_log} + +Örnekleme sorgusu profiler tarafından toplanan yığın izlemeleri içerir. + +ClickHouse bu tabloyu oluşturduğunda [trace\_log](server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) sunucu yapılandırma bölümü ayarlanır. Ayrıca [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) ve [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) ayarlar ayarlan .malıdır. + +Günlükleri analiz etmek için `addressToLine`, `addressToSymbol` ve `demangle` iç gözlem fonksiyonları. + +Sütun: + +- `event_date` ([Tarihli](../sql-reference/data-types/date.md)) — Date of sampling moment. + +- `event_time` ([DateTime](../sql-reference/data-types/datetime.md)) — Timestamp of the sampling moment. + +- `timestamp_ns` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Timestamp of the sampling moment in nanoseconds. + +- `revision` ([Uİnt32](../sql-reference/data-types/int-uint.md)) — ClickHouse server build revision. + + Tarafından sunucuya Bağlan byırken `clickhouse-client`, benzer diz theg seeeyi görüyorsunuz `Connected to ClickHouse server version 19.18.1 revision 54429.`. Bu alan şunları içerir `revision` ama `version` bir sunucunun. + +- `timer_type` ([Enum8](../sql-reference/data-types/enum.md)) — Timer type: + + - `Real` duvar saati zamanını temsil eder. + - `CPU` CPU süresini temsil eder. + +- `thread_number` ([Uİnt32](../sql-reference/data-types/int-uint.md)) — Thread identifier. + +- `query_id` ([Dize](../sql-reference/data-types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) sistem tablosu. + +- `trace` ([Dizi (Uİnt64)](../sql-reference/data-types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. + +**Örnek** + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-15 +event_time: 2019-11-15 15:09:38 +revision: 54428 +timer_type: Real +thread_number: 48 +query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 +trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] +``` + +## sistem.yinelemeler {#system_tables-replicas} + +Yerel sunucuda bulunan çoğaltılmış tablolar için bilgi ve durum içerir. +Bu tablo izleme için kullanılabilir. Tablo, her çoğaltılmış \* tablo için bir satır içerir. + +Örnek: + +``` sql +SELECT * +FROM system.replicas +WHERE table = 'visits' +FORMAT Vertical +``` + +``` text +Row 1: +────── +database: merge +table: visits +engine: ReplicatedCollapsingMergeTree +is_leader: 1 +can_become_leader: 1 +is_readonly: 0 +is_session_expired: 0 +future_parts: 1 +parts_to_check: 0 +zookeeper_path: /clickhouse/tables/01-06/visits +replica_name: example01-06-1.yandex.ru +replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru +columns_version: 9 +queue_size: 1 +inserts_in_queue: 0 +merges_in_queue: 1 +part_mutations_in_queue: 0 +queue_oldest_time: 2020-02-20 08:34:30 +inserts_oldest_time: 0000-00-00 00:00:00 +merges_oldest_time: 2020-02-20 08:34:30 +part_mutations_oldest_time: 0000-00-00 00:00:00 +oldest_part_to_get: +oldest_part_to_merge_to: 20200220_20284_20840_7 +oldest_part_to_mutate_to: +log_max_index: 596273 +log_pointer: 596274 +last_queue_update: 2020-02-20 08:34:32 +absolute_delay: 0 +total_replicas: 2 +active_replicas: 2 +``` + +Sütun: + +- `database` (`String`)- Veritabanı adı +- `table` (`String`)- Tablo adı +- `engine` (`String`)- Tablo motor adı +- `is_leader` (`UInt8`)- Kopya lider olup olmadığı. + Bir seferde sadece bir kopya lider olabilir. Lider, gerçekleştirmek için arka plan birleştirmelerini seçmekten sorumludur. + Yazma kullanılabilir ve bir oturum ZK, bir lider olup olmadığına bakılmaksızın olan herhangi bir yineleme için gerçekleştirilebilir unutmayın. +- `can_become_leader` (`UInt8`)- Rep .lik leaderanın lider olarak seçil .ip seçil .emeyeceği. +- `is_readonly` (`UInt8`)- Yinelemenin salt okunur modda olup olmadığı. + Yapılandırmanın ZooKeeper ile bölümleri yoksa, zookeeper'daki oturumları yeniden başlatırken ve Zookeeper'daki oturum yeniden başlatılırken bilinmeyen bir hata oluşmuşsa bu mod açılır. +- `is_session_expired` (`UInt8`)- ZooKeeper ile oturum süresi doldu. Temelde aynı `is_readonly`. +- `future_parts` (`UInt32`)- Henüz yapılmamış ekler veya birleştirmelerin sonucu olarak görünecek veri parçalarının sayısı. +- `parts_to_check` (`UInt32`)- Doğrulama için kuyruktaki veri parçalarının sayısı. Hasar görebileceğinden şüphe varsa, bir parça doğrulama kuyruğuna konur. +- `zookeeper_path` (`String`)- ZooKeeper tablo verilerine yolu. +- `replica_name` (`String`)- Zookeeper çoğaltma adı. Aynı tablonun farklı kopyaları farklı adlara sahiptir. +- `replica_path` (`String`)- ZooKeeper çoğaltma veri yolu. Birleştirme ile aynı ‘zookeeper\_path/replicas/replica\_path’. +- `columns_version` (`Int32`)- Tablo yapısının sürüm numarası. ALTER kaç kez gerçekleştirildiğini gösterir. Kopyaların farklı sürümleri varsa, bazı kopyaların tüm değişiklikleri henüz yapmadığı anlamına gelir. +- `queue_size` (`UInt32`)- Yapılması beklenen işlemler için sıranın büyüklüğü. İşlemler, veri bloklarını, birleştirmeleri ve diğer bazı eylemleri eklemeyi içerir. Genellikle ile çakışmaktadır `future_parts`. +- `inserts_in_queue` (`UInt32`)- Yapılması gereken veri bloklarının eklerinin sayısı. Eklemeler genellikle oldukça hızlı bir şekilde çoğaltılır. Bu sayı büyükse, bir şeylerin yanlış olduğu anlamına gelir. +- `merges_in_queue` (`UInt32`)- Yapılmasını bekleyen birleştirme sayısı. Bazen birleştirmeler uzundur, bu nedenle bu değer uzun süre sıfırdan büyük olabilir. +- `part_mutations_in_queue` (`UInt32`)- Yapılması beklenen Mut numberasyon sayısı. +- `queue_oldest_time` (`DateTime`) - Eğer `queue_size` daha büyük 0, en eski işlem sıraya eklendiğinde gösterir. +- `inserts_oldest_time` (`DateTime`) - Görmek `queue_oldest_time` +- `merges_oldest_time` (`DateTime`) - Görmek `queue_oldest_time` +- `part_mutations_oldest_time` (`DateTime`) - Görmek `queue_oldest_time` + +Sonraki 4 sütun, yalnızca ZK ile aktif bir oturumun olduğu sıfır olmayan bir değere sahiptir. + +- `log_max_index` (`UInt64`)- Genel faaliyet günlüğüne maksimum giriş numarası. +- `log_pointer` (`UInt64`)- Çoğaltma yürütme kuyruğuna kopyalanan genel faaliyet günlüğüne maksimum giriş numarası, artı bir. Eğer `log_pointer` daha küçük `log_max_index` yanlış bir şey olduğunu. +- `last_queue_update` (`DateTime`)- Kuyruk son kez güncellendiğinde. +- `absolute_delay` (`UInt64`)- Geçerli kopyanın saniyeler içinde ne kadar büyük gecikme var. +- `total_replicas` (`UInt8`)- Bu tablonun bilinen kopyalarının toplam sayısı. +- `active_replicas` (`UInt8`)- ZooKeeper bir oturum var bu tablonun kopyaları sayısı (yani, işleyen kopyaları sayısı). + +Tüm sütunları talep ederseniz, Tablo biraz yavaş çalışabilir, çünkü ZooKeeper birkaç okuma her satır için yapılır. +Son 4 sütun (log\_max\_ındex, log\_pointer, total\_replicas, active\_replicas) istemiyorsanız, tablo hızlı bir şekilde çalışır. + +Örneğin, her şeyin böyle düzgün çalıştığını kontrol edebilirsiniz: + +``` sql +SELECT + database, + table, + is_leader, + is_readonly, + is_session_expired, + future_parts, + parts_to_check, + columns_version, + queue_size, + inserts_in_queue, + merges_in_queue, + log_max_index, + log_pointer, + total_replicas, + active_replicas +FROM system.replicas +WHERE + is_readonly + OR is_session_expired + OR future_parts > 20 + OR parts_to_check > 10 + OR queue_size > 20 + OR inserts_in_queue > 10 + OR log_max_index - log_pointer > 10 + OR total_replicas < 2 + OR active_replicas < total_replicas +``` + +Bu sorgu hiçbir şey döndürmezse, her şeyin yolunda olduğu anlamına gelir. + +## sistem.ayarlar {#system-tables-system-settings} + +Geçerli kullanıcı için oturum ayarları hakkında bilgi içerir. + +Sütun: + +- `name` ([Dize](../sql-reference/data-types/string.md)) — Setting name. +- `value` ([Dize](../sql-reference/data-types/string.md)) — Setting value. +- `changed` ([Uİnt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether a setting is changed from its default value. +- `description` ([Dize](../sql-reference/data-types/string.md)) — Short setting description. +- `min` ([Nullable](../sql-reference/data-types/nullable.md)([Dize](../sql-reference/data-types/string.md))) — Minimum value of the setting, if any is set via [kısıtlamalar](settings/constraints-on-settings.md#constraints-on-settings). Ayarın minimum değeri yoksa, şunları içerir [NULL](../sql-reference/syntax.md#null-literal). +- `max` ([Nullable](../sql-reference/data-types/nullable.md)([Dize](../sql-reference/data-types/string.md))) — Maximum value of the setting, if any is set via [kısıtlamalar](settings/constraints-on-settings.md#constraints-on-settings). Ayarın maksimum değeri yoksa, şunları içerir [NULL](../sql-reference/syntax.md#null-literal). +- `readonly` ([Uİnt8](../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether the current user can change the setting: + - `0` — Current user can change the setting. + - `1` — Current user can't change the setting. + +**Örnek** + +Aşağıdaki örnek, adı içeren ayarlar hakkında bilgi almak gösterilmiştir `min_i`. + +``` sql +SELECT * +FROM system.settings +WHERE name LIKE '%min_i%' +``` + +``` text +┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ +│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ +└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ +``` + +Kullanımı `WHERE changed` örneğin, kontrol etmek istediğinizde yararlı olabilir: + +- Olsun yapılandırma dosyaları, ayarları doğru şekilde yüklenmiş ve kullanımdadır. +- Geçerli oturumda değişen ayarlar. + + + +``` sql +SELECT * FROM system.settings WHERE changed AND name='load_balancing' +``` + +**Ayrıca bakınız** + +- [Ayarlar](settings/index.md#session-settings-intro) +- [Sorgular için izinler](settings/permissions-for-queries.md#settings_readonly) +- [Ayarlardaki kısıtlamalar](settings/constraints-on-settings.md) + +## sistem.table\_engines {#system.table_engines} + +``` text +┌─name───────────────────┬─value───────┐ +│ max_threads │ 8 │ +│ use_uncompressed_cache │ 0 │ +│ load_balancing │ random │ +│ max_memory_usage │ 10000000000 │ +└────────────────────────┴─────────────┘ +``` + +## sistem.merge\_tree\_settings {#system-merge_tree_settings} + +İçin ayarlar hakkında bilgi içerir `MergeTree` Tablolar. + +Sütun: + +- `name` (String) — Setting name. +- `value` (String) — Setting value. +- `description` (String) — Setting description. +- `type` (String) — Setting type (implementation specific string value). +- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. + +## sistem.table\_engines {#system-table-engines} + +Sunucu tarafından desteklenen tablo motorlarının açıklamasını ve özellik destek bilgilerini içerir. + +Bu tablo aşağıdaki sütunları içerir (sütun türü parantez içinde gösterilir): + +- `name` (String) — The name of table engine. +- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` yan. +- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [endeksleri atlama](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes). +- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl). +- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` ve `SAMPLE_BY`. +- `supports_replication` (UInt8) — Flag that indicates if table engine supports [veri çoğaltma](../engines/table-engines/mergetree-family/replication.md). +- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. + +Örnek: + +``` sql +SELECT * +FROM system.table_engines +WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') +``` + +``` text +┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ +│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ +│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ +│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ +└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ +``` + +**Ayrıca bakınız** + +- MergeTree ailesi [sorgu yan tümceleri](../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) +- Kafka [ayarlar](../engines/table-engines/integrations/kafka.md#table_engine-kafka-creating-a-table) +- Katmak [ayarlar](../engines/table-engines/special/join.md#join-limitations-and-settings) + +## sistem.Tablolar {#system-tables} + +Sunucunun bildiği her tablonun meta verilerini içerir. Müstakil tablolar gösterilmez `system.tables`. + +Bu tablo aşağıdaki sütunları içerir (sütun türü parantez içinde gösterilir): + +- `database` (String) — The name of the database the table is in. + +- `name` (String) — Table name. + +- `engine` (String) — Table engine name (without parameters). + +- `is_temporary` (Uİnt8) - tablonun geçici olup olmadığını gösteren bayrak. + +- `data_path` (String) - dosya sistemindeki tablo verilerinin yolu. + +- `metadata_path` (String) - dosya sistemindeki tablo Meta Veri Yolu. + +- `metadata_modification_time` (DateTime) - tablo meta son değişiklik zamanı. + +- `dependencies_database` (Array (String)) - veritabanı bağımlılıkları. + +- `dependencies_table` (Array (String)) - Tablo bağımlılıkları ([MaterializedView](../engines/table-engines/special/materializedview.md) geçerli tabloya dayalı tablolar). + +- `create_table_query` (String) - tablo oluşturmak için kullanılan sorgu. + +- `engine_full` (String) - tablo motorunun parametreleri. + +- `partition_key` (String) - tabloda belirtilen bölüm anahtarı ifadesi. + +- `sorting_key` (String) - tabloda belirtilen sıralama anahtarı ifadesi. + +- `primary_key` (String) - tabloda belirtilen birincil anahtar ifadesi. + +- `sampling_key` (String) - tabloda belirtilen örnekleme anahtar ifadesi. + +- `storage_policy` (String) - depolama politikası: + + - [MergeTree](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) + - [Dağılı](../engines/table-engines/special/distributed.md#distributed) + +- `total_rows` (Nullable (Uİnt64)) - tablodaki tam satır sayısını hızlı bir şekilde belirlemek mümkün ise, toplam satır sayısı `Null` (underying dahil `Buffer` Tablo). + +- `total_bytes` (Nullable (Uİnt64)) - toplam bayt sayısı, eğer depolama alanındaki tablo için tam bayt sayısını hızlı bir şekilde belirlemek mümkün ise, aksi takdirde `Null` (**do Notes not** herhangi bir temel depolama içerir). + + - If the table stores data on disk, returns used space on disk (i.e. compressed). + - Tablo verileri bellekte depolarsa, bellekte kullanılan bayt sayısını yaklaşık olarak döndürür. + +Bu `system.tables` tablo kullanılır `SHOW TABLES` sorgu uygulaması. + +## sistem.zookeeper {#system-zookeeper} + +ZooKeeper yapılandırılmamışsa, tablo yok. Yapılandırmada tanımlanan ZooKeeper kümesinden veri okumayı sağlar. +Sorgu bir olmalıdır ‘path’ WH .ere madd .esindeki eşitlik koşulu. Bu veri almak istediğiniz çocuklar için ZooKeeper yoludur. + +Sorgu `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` tüm çocuklar için veri çıkışı `/clickhouse` düğümlü. +Tüm kök düğümler için veri çıkışı yapmak için, path = yazın ‘/’. +Belirtilen yol ise ‘path’ yok, bir istisna atılır. + +Sütun: + +- `name` (String) — The name of the node. +- `path` (String) — The path to the node. +- `value` (String) — Node value. +- `dataLength` (Int32) — Size of the value. +- `numChildren` (Int32) — Number of descendants. +- `czxid` (Int64) — ID of the transaction that created the node. +- `mzxid` (Int64) — ID of the transaction that last changed the node. +- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. +- `ctime` (DateTime) — Time of node creation. +- `mtime` (DateTime) — Time of the last modification of the node. +- `version` (Int32) — Node version: the number of times the node was changed. +- `cversion` (Int32) — Number of added or removed descendants. +- `aversion` (Int32) — Number of changes to the ACL. +- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. + +Örnek: + +``` sql +SELECT * +FROM system.zookeeper +WHERE path = '/clickhouse/tables/01-08/visits/replicas' +FORMAT Vertical +``` + +``` text +Row 1: +────── +name: example01-08-1.yandex.ru +value: +czxid: 932998691229 +mzxid: 932998691229 +ctime: 2015-03-27 16:49:51 +mtime: 2015-03-27 16:49:51 +version: 0 +cversion: 47 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021031383 +path: /clickhouse/tables/01-08/visits/replicas + +Row 2: +────── +name: example01-08-2.yandex.ru +value: +czxid: 933002738135 +mzxid: 933002738135 +ctime: 2015-03-27 16:57:01 +mtime: 2015-03-27 16:57:01 +version: 0 +cversion: 37 +aversion: 0 +ephemeralOwner: 0 +dataLength: 0 +numChildren: 7 +pzxid: 987021252247 +path: /clickhouse/tables/01-08/visits/replicas +``` + +## sistem.mutasyonlar {#system_tables-mutations} + +Tablo hakkında bilgi içerir [mutasyonlar](../sql-reference/statements/alter.md#alter-mutations) MergeTree tabloları ve bunların ilerleme. Her mutasyon komutu tek bir satırla temsil edilir. Tablo aşağıdaki sütunlara sahiptir: + +**veritabanı**, **Tablo** - Mutasyonun uygulandığı veritabanı ve tablonun adı. + +**mutation\_id** - Mutasyonun kimliği. Çoğaltılmış tablolar için bu kimlikler znode adlarına karşılık gelir `/mutations/` ZooKeeper dizin. Yinelenmemiş tablolar için kimlikler, tablonun veri dizinindeki dosya adlarına karşılık gelir. + +**komut** - Mut commandasyon komut diz (gesi (sorgu afterdan sonra `ALTER TABLE [db.]table`). + +**create\_time** - Bu mutasyon komutu idam için sunulduğunda. + +**block\_numbers.partition\_id**, **block\_numbers.numara** - İç içe geçmiş bir sütun. Çoğaltılmış tabloların mutasyonları için, her bölüm için bir kayıt içerir: bölüm kimliği ve mutasyon tarafından elde edilen blok numarası (her bölümde, yalnızca bu bölümdeki mutasyon tarafından elde edilen blok sayısından daha az sayıda blok içeren parçalar mutasyona uğrayacaktır). Çoğaltılmamış tablolarda, tüm bölümlerdeki blok numaraları tek bir sıra oluşturur. Bu, çoğaltılmamış tabloların mutasyonları için, sütunun mutasyon tarafından elde edilen tek bir blok numarasına sahip bir kayıt içereceği anlamına gelir. + +**parts\_to\_do** - Mutasyonun bitmesi için mutasyona uğraması gereken veri parçalarının sayısı. + +**is\_done** - Mutasyon bitti mi? Not bile `parts_to_do = 0` çoğaltılmış bir tablonun mutasyonu, mutasyona uğraması gereken yeni bir veri parçası yaratacak uzun süren bir ekleme nedeniyle henüz yapılmamıştır. + +Bazı bölümleri mutasyon ile ilgili sorunlar varsa, aşağıdaki sütunlar ek bilgi içerir: + +**latest\_failed\_part** - Mutasyona uğramayan en son bölümün adı. + +**latest\_fail\_time** - En son bölüm mutasyon başarısızlığı zamanı. + +**latest\_fail\_reason** - En son bölüm mutasyon başarısızlığına neden olan istisna mesajı. + +## sistem.diskler {#system_tables-disks} + +İçinde tanımlanan diskler hakkında bilgi içerir [sunucu yapılandırması](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Sütun: + +- `name` ([Dize](../sql-reference/data-types/string.md)) — Name of a disk in the server configuration. +- `path` ([Dize](../sql-reference/data-types/string.md)) — Path to the mount point in the file system. +- `free_space` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Free space on disk in bytes. +- `total_space` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Disk volume in bytes. +- `keep_free_space` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` disk yapılandırması parametresi. + +## sistem.storage\_policies {#system_tables-storage_policies} + +Depolama ilkeleri ve birimlerinde tanımlanan bilgiler içerir. [sunucu yapılandırması](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). + +Sütun: + +- `policy_name` ([Dize](../sql-reference/data-types/string.md)) — Name of the storage policy. +- `volume_name` ([Dize](../sql-reference/data-types/string.md)) — Volume name defined in the storage policy. +- `volume_priority` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Volume order number in the configuration. +- `disks` ([Ar Arrayray (String)](../sql-reference/data-types/array.md)) — Disk names, defined in the storage policy. +- `max_data_part_size` ([Uİnt64](../sql-reference/data-types/int-uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). +- `move_factor` ([Float64](../sql-reference/data-types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. + +Depolama ilkesi birden fazla birim içeriyorsa, her birim için bilgiler tablonun tek tek satırında saklanır. + +[Orijinal makale](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/tr/operations/system_tables.md b/docs/tr/operations/system_tables.md deleted file mode 100644 index 17fd176cc58..00000000000 --- a/docs/tr/operations/system_tables.md +++ /dev/null @@ -1,1166 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 -toc_priority: 52 -toc_title: "Sistem Tablolar\u0131" ---- - -# Sistem Tabloları {#system-tables} - -Sistem tabloları, sistemin işlevselliğinin bir kısmını uygulamak ve sistemin nasıl çalıştığı hakkında bilgilere erişim sağlamak için kullanılır. -Bir sistem tablosunu silemezsiniz (ancak ayırma işlemini gerçekleştirebilirsiniz). -Sistem tablolarında diskte veri bulunan dosyalar veya meta verilere sahip dosyalar yoktur. Sunucu, başlatıldığında tüm sistem tablolarını oluşturur. -Sistem tabloları salt okunur. -Bulun theurlar. ‘system’ veritabanı. - -## sistem.asynchronous\_metrics {#system_tables-asynchronous_metrics} - -Arka planda periyodik olarak hesaplanan metrikleri içerir. Örneğin, kullanılan RAM miktarı. - -Sütun: - -- `metric` ([Dize](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Float64](../sql_reference/data_types/float.md)) — Metric value. - -**Örnek** - -``` sql -SELECT * FROM system.asynchronous_metrics LIMIT 10 -``` - -``` text -┌─metric──────────────────────────────────┬──────value─┐ -│ jemalloc.background_thread.run_interval │ 0 │ -│ jemalloc.background_thread.num_runs │ 0 │ -│ jemalloc.background_thread.num_threads │ 0 │ -│ jemalloc.retained │ 422551552 │ -│ jemalloc.mapped │ 1682989056 │ -│ jemalloc.resident │ 1656446976 │ -│ jemalloc.metadata_thp │ 0 │ -│ jemalloc.metadata │ 10226856 │ -│ UncompressedCacheCells │ 0 │ -│ MarkCacheFiles │ 0 │ -└─────────────────────────────────────────┴────────────┘ -``` - -**Ayrıca Bakınız** - -- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. -- [sistem.metrik](#system_tables-metrics) — Contains instantly calculated metrics. -- [sistem.etkinlik](#system_tables-events) — Contains a number of events that have occurred. -- [sistem.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. - -## sistem.kümeler {#system-clusters} - -Yapılandırma dosyasında bulunan kümeler ve içindeki sunucular hakkında bilgi içerir. - -Sütun: - -- `cluster` (String) — The cluster name. -- `shard_num` (UInt32) — The shard number in the cluster, starting from 1. -- `shard_weight` (UInt32) — The relative weight of the shard when writing data. -- `replica_num` (UInt32) — The replica number in the shard, starting from 1. -- `host_name` (String) — The host name, as specified in the config. -- `host_address` (String) — The host IP address obtained from DNS. -- `port` (UInt16) — The port to use for connecting to the server. -- `user` (String) — The name of the user for connecting to the server. -- `errors_count` (Uİnt32) - bu ana bilgisayarın çoğaltma ulaşamadı sayısı. -- `estimated_recovery_time` (Uİnt32) - çoğaltma hata sayısı sıfırlanana kadar saniye kaldı ve normale döndü olarak kabul edilir. - -Lütfen unutmayın `errors_count` küme için sorgu başına bir kez güncelleştirilir, ancak `estimated_recovery_time` isteğe bağlı olarak yeniden hesaplanır. Yani sıfır olmayan bir durum olabilir `errors_count` ve sıfır `estimated_recovery_time`, sonraki sorgu sıfır olacak `errors_count` ve hiçbir hata yokmuş gibi çoğaltma kullanmayı deneyin. - -**Ayrıca bakınız** - -- [Masa motoru Dağıt Distributedıldı](../engines/table_engines/special/distributed.md) -- [distributed\_replica\_error\_cap ayarı](settings/settings.md#settings-distributed_replica_error_cap) -- [distributed\_replica\_error\_half\_life ayarı](settings/settings.md#settings-distributed_replica_error_half_life) - -## sistem.sütun {#system-columns} - -Tüm tablolardaki sütunlar hakkında bilgi içerir. - -Benzer bilgileri almak için bu tabloyu kullanabilirsiniz [DESCRIBE TABLE](../sql_reference/statements/misc.md#misc-describe-table) sorgu, ancak aynı anda birden çok tablo için. - -Bu `system.columns` tablo aşağıdaki sütunları içerir (sütun türü parantez içinde gösterilir): - -- `database` (String) — Database name. -- `table` (String) — Table name. -- `name` (String) — Column name. -- `type` (String) — Column type. -- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) varsayılan değer veya tanımlanmamışsa boş bir dize için. -- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. -- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. -- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. -- `marks_bytes` (UInt64) — The size of marks, in bytes. -- `comment` (String) — Comment on the column, or an empty string if it is not defined. -- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. -- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. -- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. -- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. - -## sistem.katılımcılar {#system-contributors} - -Katkıda bulunanlar hakkında bilgi içerir. Rastgele sırayla tüm constributors. Sipariş, sorgu yürütme zamanında rasgele olur. - -Sütun: - -- `name` (String) — Contributor (author) name from git log. - -**Örnek** - -``` sql -SELECT * FROM system.contributors LIMIT 10 -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -│ Max Vetrov │ -│ LiuYangkuan │ -│ svladykin │ -│ zamulla │ -│ Šimon Podlipský │ -│ BayoNet │ -│ Ilya Khomutov │ -│ Amy Krishnevsky │ -│ Loud_Scream │ -└──────────────────┘ -``` - -Tabloda kendinizi bulmak için bir sorgu kullanın: - -``` sql -SELECT * FROM system.contributors WHERE name='Olga Khvostikova' -``` - -``` text -┌─name─────────────┐ -│ Olga Khvostikova │ -└──────────────────┘ -``` - -## sistem.veritabanılar {#system-databases} - -Bu tablo, adı verilen tek bir dize sütunu içerir ‘name’ – the name of a database. -Sunucunun bildiği her veritabanı, tabloda karşılık gelen bir girdiye sahiptir. -Bu sistem tablosu uygulamak için kullanılır `SHOW DATABASES` sorgu. - -## sistem.detached\_parts {#system_tables-detached_parts} - -Müstakil parçaları hakkında bilgiler içerir [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) Tablolar. Bu `reason` sütun, parçanın neden ayrıldığını belirtir. Kullanıcı tarafından ayrılmış parçalar için sebep boştur. Bu tür parçalar ile eklenebilir [ALTER TABLE ATTACH PARTITION\|PART](../sql_reference/statements/alter.md#alter_attach-partition) komut. Diğer sütunların açıklaması için bkz. [sistem.parçalar](#system_tables-parts). Bölüm adı geçersiz ise, bazı sütunların değerleri olabilir `NULL`. Bu tür parçalar ile silinebilir [ALTER TABLE DROP DETACHED PART](../sql_reference/statements/alter.md#alter_drop-detached). - -## sistem.sözlükler {#system_tables-dictionaries} - -Hakkında bilgi içerir [dış söz dictionarieslükler](../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -Sütun: - -- `database` ([Dize](../sql_reference/data_types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries. -- `name` ([Dize](../sql_reference/data_types/string.md)) — [Sözlük adı](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md). -- `status` ([Enum8](../sql_reference/data_types/enum.md)) — Dictionary status. Possible values: - - `NOT_LOADED` — Dictionary was not loaded because it was not used. - - `LOADED` — Dictionary loaded successfully. - - `FAILED` — Unable to load the dictionary as a result of an error. - - `LOADING` — Dictionary is loading now. - - `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../sql_reference/statements/system.md#query_language-system-reload-dictionary) sorgu, zaman aşımı, sözlük yapılandırması değişti). - - `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now. -- `origin` ([Dize](../sql_reference/data_types/string.md)) — Path to the configuration file that describes the dictionary. -- `type` ([Dize](../sql_reference/data_types/string.md)) — Type of a dictionary allocation. [Sözlükleri bellekte saklama](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md). -- `key` — [Anahtar tipi](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-key): Sayısal Tuş ([Uİnt64](../sql_reference/data_types/int_uint.md#uint-ranges)) or Сomposite key ([Dize](../sql_reference/data_types/string.md)) — form “(type 1, type 2, …, type n)”. -- `attribute.names` ([Dizi](../sql_reference/data_types/array.md)([Dize](../sql_reference/data_types/string.md))) — Array of [öznitelik adları](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes) sözlük tarafından sağlanmıştır. -- `attribute.types` ([Dizi](../sql_reference/data_types/array.md)([Dize](../sql_reference/data_types/string.md))) — Corresponding array of [öznitelik türleri](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md#ext_dict_structure-attributes) sözlük tarafından sağlanmaktadır. -- `bytes_allocated` ([Uİnt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary. -- `query_count` ([Uİnt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot. -- `hit_rate` ([Float64](../sql_reference/data_types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache. -- `element_count` ([Uİnt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Number of items stored in the dictionary. -- `load_factor` ([Float64](../sql_reference/data_types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table). -- `source` ([Dize](../sql_reference/data_types/string.md)) — Text describing the [veri kaynağı](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md) sözlük için. -- `lifetime_min` ([Uİnt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Minimum [ömür](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md) bellekteki sözlüğün ardından ClickHouse sözlüğü yeniden yüklemeye çalışır (eğer `invalidate_query` ayarlanır, daha sonra sadece değiştiyse). Saniyeler içinde ayarlayın. -- `lifetime_max` ([Uİnt64](../sql_reference/data_types/int_uint.md#uint-ranges)) — Maximum [ömür](../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md) bellekteki sözlüğün ardından ClickHouse sözlüğü yeniden yüklemeye çalışır (eğer `invalidate_query` ayarlanır, daha sonra sadece değiştiyse). Saniyeler içinde ayarlayın. -- `loading_start_time` ([DateTime](../sql_reference/data_types/datetime.md)) — Start time for loading the dictionary. -- `last_successful_update_time` ([DateTime](../sql_reference/data_types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes. -- `loading_duration` ([Float32](../sql_reference/data_types/float.md)) — Duration of a dictionary loading. -- `last_exception` ([Dize](../sql_reference/data_types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created. - -**Örnek** - -Sözlüğü yapılandırın. - -``` sql -CREATE DICTIONARY dictdb.dict -( - `key` Int64 DEFAULT -1, - `value_default` String DEFAULT 'world', - `value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)' -) -PRIMARY KEY key -SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb')) -LIFETIME(MIN 0 MAX 1) -LAYOUT(FLAT()) -``` - -Sözlüğün yüklendiğinden emin olun. - -``` sql -SELECT * FROM system.dictionaries -``` - -``` text -┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐ -│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │ -└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘ -``` - -## sistem.etkinlik {#system_tables-events} - -Sistemde meydana gelen olayların sayısı hakkında bilgi içerir. Örneğin, tabloda kaç tane bulabilirsiniz `SELECT` ClickHouse sunucusu başladığından beri sorgular işlendi. - -Sütun: - -- `event` ([Dize](../sql_reference/data_types/string.md)) — Event name. -- `value` ([Uİnt64](../sql_reference/data_types/int_uint.md)) — Number of events occurred. -- `description` ([Dize](../sql_reference/data_types/string.md)) — Event description. - -**Örnek** - -``` sql -SELECT * FROM system.events LIMIT 5 -``` - -``` text -┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │ -│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │ -│ FileOpen │ 73 │ Number of files opened. │ -│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │ -│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │ -└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Ayrıca Bakınız** - -- [sistem.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [sistem.metrik](#system_tables-metrics) — Contains instantly calculated metrics. -- [sistem.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. - -## sistem.işlevler {#system-functions} - -Normal ve toplama işlevleri hakkında bilgi içerir. - -Sütun: - -- `name`(`String`) – The name of the function. -- `is_aggregate`(`UInt8`) — Whether the function is aggregate. - -## sistem.graphite\_retentions {#system-graphite-retentions} - -Parametreleri hakkında bilgi içerir [graphite\_rollup](server_configuration_parameters/settings.md#server_configuration_parameters-graphite_rollup) tablo usedlarında kullanılan [\* Graphıtemergetree](../engines/table_engines/mergetree_family/graphitemergetree.md) motorlar. - -Sütun: - -- `config_name` (Dize) - `graphite_rollup` parametre adı. -- `regexp` (String) - metrik adı için bir desen. -- `function` (String) - toplama işlevinin adı. -- `age` (Uint64) - saniye cinsinden verilerin minimum yaş. -- `precision` (Uİnt64) - verilerin yaşını saniyeler içinde tam olarak tanımlamak için. -- `priority` (Uİnt16) - desen önceliği. -- `is_default` (Uİnt8) - desenin varsayılan olup olmadığı. -- `Tables.database` (Array (String)) - kullanılan veritabanı tablolarının adlarının dizisi `config_name` parametre. -- `Tables.table` (Array (String)) - kullanılan tablo adları dizisi `config_name` parametre. - -## sistem.birleştiriyor {#system-merges} - -Mergetree ailesindeki tablolar için şu anda işlemde olan birleştirme ve parça mutasyonları hakkında bilgi içerir. - -Sütun: - -- `database` (String) — The name of the database the table is in. -- `table` (String) — Table name. -- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started. -- `progress` (Float64) — The percentage of completed work from 0 to 1. -- `num_parts` (UInt64) — The number of pieces to be merged. -- `result_part_name` (String) — The name of the part that will be formed as the result of merging. -- `is_mutation` (Uİnt8 ) - 1 Bu işlem bir parça mutasyonu ise. -- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks. -- `total_size_marks` (UInt64) — The total number of marks in the merged parts. -- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed. -- `rows_read` (UInt64) — Number of rows read. -- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed. -- `rows_written` (UInt64) — Number of rows written. - -## sistem.metrik {#system_tables-metrics} - -Anında hesaplanan veya geçerli bir değere sahip olabilir metrikleri içerir. Örneğin, aynı anda işlenen sorguların sayısı veya geçerli yineleme gecikmesi. Bu tablo her zaman güncel. - -Sütun: - -- `metric` ([Dize](../sql_reference/data_types/string.md)) — Metric name. -- `value` ([Int64](../sql_reference/data_types/int_uint.md)) — Metric value. -- `description` ([Dize](../sql_reference/data_types/string.md)) — Metric description. - -Desteklenen metriklerin listesi [src / ortak / CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) ClickHouse kaynak dosyası. - -**Örnek** - -``` sql -SELECT * FROM system.metrics LIMIT 10 -``` - -``` text -┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Query │ 1 │ Number of executing queries │ -│ Merge │ 0 │ Number of executing background merges │ -│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │ -│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │ -│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │ -│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │ -│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │ -│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │ -│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │ -│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │ -└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**Ayrıca Bakınız** - -- [sistem.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [sistem.etkinlik](#system_tables-events) — Contains a number of events that occurred. -- [sistem.metric\_log](#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`. -- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. - -## sistem.metric\_log {#system_tables-metric_log} - -Tablolardan metrik değerlerinin geçmişini içerir `system.metrics` ve `system.events`, periyodik olarak diske boşaltılır. -Metrik geçmişi koleksiyonunu açmak için `system.metric_log`, oluşturmak `/etc/clickhouse-server/config.d/metric_log.xml` aşağıdaki içerik ile: - -``` xml - - - system - metric_log
- 7500 - 1000 -
-
-``` - -**Örnek** - -``` sql -SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical; -``` - -``` text -Row 1: -────── -event_date: 2020-02-18 -event_time: 2020-02-18 07:15:33 -milliseconds: 554 -ProfileEvent_Query: 0 -ProfileEvent_SelectQuery: 0 -ProfileEvent_InsertQuery: 0 -ProfileEvent_FileOpen: 0 -ProfileEvent_Seek: 0 -ProfileEvent_ReadBufferFromFileDescriptorRead: 1 -ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0 -ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0 -ProfileEvent_WriteBufferFromFileDescriptorWrite: 1 -ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0 -ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56 -... -CurrentMetric_Query: 0 -CurrentMetric_Merge: 0 -CurrentMetric_PartMutation: 0 -CurrentMetric_ReplicatedFetch: 0 -CurrentMetric_ReplicatedSend: 0 -CurrentMetric_ReplicatedChecks: 0 -... -``` - -**Ayrıca bakınız** - -- [sistem.asynchronous\_metrics](#system_tables-asynchronous_metrics) — Contains periodically calculated metrics. -- [sistem.etkinlik](#system_tables-events) — Contains a number of events that occurred. -- [sistem.metrik](#system_tables-metrics) — Contains instantly calculated metrics. -- [İzleme](monitoring.md) — Base concepts of ClickHouse monitoring. - -## sistem.şiir {#system-numbers} - -Bu tablo adında tek bir uint64 sütunu içerir ‘number’ bu sıfırdan başlayarak hemen hemen tüm doğal sayıları içerir. -Bu tabloyu testler için veya kaba kuvvet araması yapmanız gerekiyorsa kullanabilirsiniz. -Bu tablodan okumalar parallelized değil. - -## sistem.numbers\_mt {#system-numbers-mt} - -Olarak aynı ‘system.numbers’ ancak okumalar paralelleştirilmiştir. Sayılar herhangi bir sırayla iade edilebilir. -Testler için kullanılır. - -## sistem.bir {#system-one} - -Bu tablo, tek bir satır içeren tek bir satır içerir ‘dummy’ 0 değerini içeren uint8 sütunu. -SELECT sorgusu FROM yan tümcesi belirtmezse, bu tablo kullanılır. -Bu, diğer Dbms'lerde bulunan ikili tabloya benzer. - -## sistem.parçalar {#system_tables-parts} - -Bölümleri hakkında bilgi içerir [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) Tablolar. - -Her satır bir veri bölümünü açıklar. - -Sütun: - -- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../sql_reference/statements/alter.md#query_language_queries_alter) sorgu. - - Biçimliler: - - - `YYYYMM` ay otomatik bölümleme için. - - `any_string` el ile bölümleme yaparken. - -- `name` (`String`) – Name of the data part. - -- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging. - -- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` dizin ayrıntısına göre (genellikle 8192) (bu ipucu uyarlanabilir ayrıntı için çalışmaz). - -- `rows` (`UInt64`) – The number of rows. - -- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes. - -- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included. - -- `marks_bytes` (`UInt64`) – The size of the file with marks. - -- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\| - -- `remove_time` (`DateTime`) – The time when the data part became inactive. - -- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges. - -- `min_date` (`Date`) – The minimum value of the date key in the data part. - -- `max_date` (`Date`) – The maximum value of the date key in the data part. - -- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part. - -- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part. - -- `partition_id` (`String`) – ID of the partition. - -- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging. - -- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging. - -- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts. - -- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`). - -- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values. - -- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values. - -- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../sql_reference/statements/alter.md#alter_freeze-partition) - -- `database` (`String`) – Name of the database. - -- `table` (`String`) – Name of the table. - -- `engine` (`String`) – Name of the table engine without parameters. - -- `path` (`String`) – Absolute path to the folder with data part files. - -- `disk` (`String`) – Name of a disk that stores the data part. - -- `hash_of_all_files` (`String`) – [sifash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) sıkıştırılmış dosyaların. - -- `hash_of_uncompressed_files` (`String`) – [sifash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) sıkıştırılmamış dosyaların (işaretli dosyalar, dizin dosyası vb.)). - -- `uncompressed_hash_of_compressed_files` (`String`) – [sifash128](../sql_reference/functions/hash_functions.md#hash_functions-siphash128) sıkıştırılmış dosyalardaki verilerin sıkıştırılmamış gibi. - -- `bytes` (`UInt64`) – Alias for `bytes_on_disk`. - -- `marks_size` (`UInt64`) – Alias for `marks_bytes`. - -## sistem.part\_log {#system_tables-part-log} - -Bu `system.part_log` tablo yalnızca aşağıdaki durumlarda oluşturulur: [part\_log](server_configuration_parameters/settings.md#server_configuration_parameters-part-log) sunucu ayarı belirtilir. - -Bu tablo ile oluşan olaylar hakkında bilgi içerir [veri parçaları](../engines/table_engines/mergetree_family/custom_partitioning_key.md) in the [MergeTree](../engines/table_engines/mergetree_family/mergetree.md) veri ekleme veya birleştirme gibi aile tabloları. - -Bu `system.part_log` tablo aşağıdaki sütunları içerir: - -- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values: - - `NEW_PART` — Inserting of a new data part. - - `MERGE_PARTS` — Merging of data parts. - - `DOWNLOAD_PART` — Downloading a data part. - - `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../sql_reference/statements/alter.md#alter_detach-partition). - - `MUTATE_PART` — Mutating of a data part. - - `MOVE_PART` — Moving the data part from the one disk to another one. -- `event_date` (Date) — Event date. -- `event_time` (DateTime) — Event time. -- `duration_ms` (UInt64) — Duration. -- `database` (String) — Name of the database the data part is in. -- `table` (String) — Name of the table the data part is in. -- `part_name` (String) — Name of the data part. -- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ bölümleme tarafından ise değer `tuple()`. -- `rows` (UInt64) — The number of rows in the data part. -- `size_in_bytes` (UInt64) — Size of the data part in bytes. -- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge). -- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes. -- `read_rows` (UInt64) — The number of rows was read during the merge. -- `read_bytes` (UInt64) — The number of bytes was read during the merge. -- `error` (UInt16) — The code number of the occurred error. -- `exception` (String) — Text message of the occurred error. - -Bu `system.part_log` tablo ilk veri ekleme sonra oluşturulur `MergeTree` Tablo. - -## sistem.işleyişler {#system_tables-processes} - -Bu sistem tablosu uygulamak için kullanılır `SHOW PROCESSLIST` sorgu. - -Sütun: - -- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` kullanan. Alan, bu sorgunun başlattığı bir sorgu için değil, belirli bir sorgunun kullanıcı adını içerir. -- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` sorgu istek sahibi sunucuda. -- `elapsed` (Float64) – The time in seconds since request execution started. -- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers. -- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known. -- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../operations/settings/query_complexity.md#settings_max_memory_usage) ayar. -- `query` (String) – The query text. For `INSERT`, eklemek için veri içermez. -- `query_id` (String) – Query ID, if defined. - -## sistem.text\_log {#system-tables-text-log} - -Günlük girişleri içerir. Bu tabloya giden günlük seviyesi ile sınırlı olabilir `text_log.level` sunucu ayarı. - -Sütun: - -- `event_date` (`Date`)- Giriş tarihi. -- `event_time` (`DateTime`)- Giriş zamanı. -- `microseconds` (`UInt32`)- Girişin mikrosaniye. -- `thread_name` (String) — Name of the thread from which the logging was done. -- `thread_id` (UInt64) — OS thread ID. -- `level` (`Enum8`)- Giriş seviyesi. - - `'Fatal' = 1` - - `'Critical' = 2` - - `'Error' = 3` - - `'Warning' = 4` - - `'Notice' = 5` - - `'Information' = 6` - - `'Debug' = 7` - - `'Trace' = 8` -- `query_id` (`String`)- Sorgunun kimliği. -- `logger_name` (`LowCardinality(String)`) - Name of the logger (i.e. `DDLWorker`) -- `message` (`String`)- Mesajın kendisi . -- `revision` (`UInt32`)- ClickHouse revizyon. -- `source_file` (`LowCardinality(String)`)- Günlüğü yapıldığı kaynak dosya. -- `source_line` (`UInt64`)- Kaynak satır hangi günlüğü yapıldı. - -## sistem.query\_log {#system_tables-query_log} - -Sorguların yürütülmesi hakkında bilgi içerir. Her sorgu için, işlem başlangıç saatini, işlem süresini, hata mesajlarını ve diğer bilgileri görebilirsiniz. - -!!! note "Not" - Tablo için giriş verileri içermiyor `INSERT` sorgular. - -ClickHouse bu tabloyu yalnızca [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) sunucu parametresi belirtilir. Bu parametre, günlük aralığı veya sorguların oturum açacağı tablonun adı gibi günlük kurallarını ayarlar. - -Sorgu günlüğünü etkinleştirmek için, [log\_queries](settings/settings.md#settings-log-queries) parametre 1. Ayrıntılar için, bkz. [Ayarlar](settings/settings.md) bölme. - -Bu `system.query_log` tablo iki tür sorgu kaydeder: - -1. Doğrudan istemci tarafından çalıştırılan ilk sorgular. -2. Diğer sorgular tarafından başlatılan alt sorgular (dağıtılmış sorgu yürütme için). Bu tür sorgular için, üst sorgular hakkında bilgi `initial_*` sütun. - -Sütun: - -- `type` (`Enum8`) — Type of event that occurred when executing the query. Values: - - `'QueryStart' = 1` — Successful start of query execution. - - `'QueryFinish' = 2` — Successful end of query execution. - - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution. - - `'ExceptionWhileProcessing' = 4` — Exception during the query execution. -- `event_date` (Date) — Query starting date. -- `event_time` (DateTime) — Query starting time. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` sorgular, yazılı satır sayısı. Diğer sorgular için sütun değeri 0'dır. -- `written_bytes` (UInt64) — For `INSERT` sorgular, yazılı bayt sayısı. Diğer sorgular için sütun değeri 0'dır. -- `result_rows` (UInt64) — Number of rows in the result. -- `result_bytes` (UInt64) — Number of bytes in the result. -- `memory_usage` (UInt64) — Memory consumption by the query. -- `query` (String) — Query string. -- `exception` (String) — Exception message. -- `stack_trace` (String) — Stack trace (a list of methods called before the error occurred). An empty string, if the query is completed successfully. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS's username who runs [clickhouse-müşteri](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi çalıştırılır. -- `client_name` (String) — The [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci adı. -- `client_revision` (UInt32) — Revision of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. -- `client_version_major` (UInt32) — Major version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci sürümü. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` yöntem kullanılmıştır. - - 2 — `POST` yöntem kullanılmıştır. -- `http_user_agent` (String) — The `UserAgent` başlık http isteğinde geçti. -- `quota_key` (String) — The “quota key” belirtilen [kotalar](quotas.md) ayarı (bakınız `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `thread_numbers` (Array(UInt32)) — Number of threads that are participating in query execution. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics. The description of them could be found in the table [sistem.etkinlik](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the `ProfileEvents.Names` sütun. -- `Settings.Names` (Array(String)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` parametre 1. -- `Settings.Values` (Array(String)) — Values of settings that are listed in the `Settings.Names` sütun. - -Her sorgu bir veya iki satır oluşturur `query_log` tablo, sorgunun durumuna bağlı olarak: - -1. Sorgu yürütme başarılı olursa, tip 1 ve 2 ile iki olay oluşturulur (bkz. `type` sütun). -2. Sorgu işleme sırasında bir hata oluştu, iki olay türleri 1 ve 4 oluşturulur. -3. Sorguyu başlatmadan önce bir hata oluşmuşsa, 3 tipi olan tek bir olay oluşturulur. - -Varsayılan olarak, günlükleri 7.5 saniye aralıklarla tabloya eklenir. Bu aralığı ayarlayabilirsiniz [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) sunucu ayarı (bkz. `flush_interval_milliseconds` parametre). Günlükleri zorla bellek arabelleğinden tabloya temizlemek için `SYSTEM FLUSH LOGS` sorgu. - -Tablo elle silindiğinde, otomatik olarak anında oluşturulur. Önceki tüm günlüklerin silineceğini unutmayın. - -!!! note "Not" - Günlüklerin depolama süresi sınırsızdır. Günlükler tablodan otomatik olarak silinmez. Eski günlüklerin kaldırılmasını kendiniz düzenlemeniz gerekir. - -İçin keyfi bir bölümleme anahtarı belirtebilirsiniz `system.query_log` tablo içinde [query\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-log) sunucu ayarı (bkz. `partition_by` parametre). - -## sistem.query\_thread\_log {#system_tables-query-thread-log} - -Tablo, her sorgu yürütme iş parçacığı hakkında bilgi içerir. - -ClickHouse bu tabloyu yalnızca [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu parametresi belirtilir. Bu parametre, günlük aralığı veya sorguların oturum açacağı tablonun adı gibi günlük kurallarını ayarlar. - -Sorgu günlüğünü etkinleştirmek için, [log\_query\_threads](settings/settings.md#settings-log-query-threads) parametre 1. Ayrıntılar için, bkz. [Ayarlar](settings/settings.md) bölme. - -Sütun: - -- `event_date` (Date) — the date when the thread has finished execution of the query. -- `event_time` (DateTime) — the date and time when the thread has finished execution of the query. -- `query_start_time` (DateTime) — Start time of query execution. -- `query_duration_ms` (UInt64) — Duration of query execution. -- `read_rows` (UInt64) — Number of read rows. -- `read_bytes` (UInt64) — Number of read bytes. -- `written_rows` (UInt64) — For `INSERT` sorgular, yazılı satır sayısı. Diğer sorgular için sütun değeri 0'dır. -- `written_bytes` (UInt64) — For `INSERT` sorgular, yazılı bayt sayısı. Diğer sorgular için sütun değeri 0'dır. -- `memory_usage` (Int64) — The difference between the amount of allocated and freed memory in context of this thread. -- `peak_memory_usage` (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread. -- `thread_name` (String) — Name of the thread. -- `thread_number` (UInt32) — Internal thread ID. -- `os_thread_id` (Int32) — OS thread ID. -- `master_thread_id` (UInt64) — OS initial ID of initial thread. -- `query` (String) — Query string. -- `is_initial_query` (UInt8) — Query type. Possible values: - - 1 — Query was initiated by the client. - - 0 — Query was initiated by another query for distributed query execution. -- `user` (String) — Name of the user who initiated the current query. -- `query_id` (String) — ID of the query. -- `address` (IPv6) — IP address that was used to make the query. -- `port` (UInt16) — The client port that was used to make the query. -- `initial_user` (String) — Name of the user who ran the initial query (for distributed query execution). -- `initial_query_id` (String) — ID of the initial query (for distributed query execution). -- `initial_address` (IPv6) — IP address that the parent query was launched from. -- `initial_port` (UInt16) — The client port that was used to make the parent query. -- `interface` (UInt8) — Interface that the query was initiated from. Possible values: - - 1 — TCP. - - 2 — HTTP. -- `os_user` (String) — OS's username who runs [clickhouse-müşteri](../interfaces/cli.md). -- `client_hostname` (String) — Hostname of the client machine where the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi çalıştırılır. -- `client_name` (String) — The [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci adı. -- `client_revision` (UInt32) — Revision of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. -- `client_version_major` (UInt32) — Major version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. -- `client_version_minor` (UInt32) — Minor version of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemcisi. -- `client_version_patch` (UInt32) — Patch component of the [clickhouse-müşteri](../interfaces/cli.md) veya başka bir TCP istemci sürümü. -- `http_method` (UInt8) — HTTP method that initiated the query. Possible values: - - 0 — The query was launched from the TCP interface. - - 1 — `GET` yöntem kullanılmıştır. - - 2 — `POST` yöntem kullanılmıştır. -- `http_user_agent` (String) — The `UserAgent` başlık http isteğinde geçti. -- `quota_key` (String) — The “quota key” belirtilen [kotalar](quotas.md) ayarı (bakınız `keyed`). -- `revision` (UInt32) — ClickHouse revision. -- `ProfileEvents.Names` (Array(String)) — Counters that measure different metrics for this thread. The description of them could be found in the table [sistem.etkinlik](#system_tables-events) -- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` sütun. - -Varsayılan olarak, günlükleri 7.5 saniye aralıklarla tabloya eklenir. Bu aralığı ayarlayabilirsiniz [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu ayarı (bkz. `flush_interval_milliseconds` parametre). Günlükleri zorla bellek arabelleğinden tabloya temizlemek için `SYSTEM FLUSH LOGS` sorgu. - -Tablo elle silindiğinde, otomatik olarak anında oluşturulur. Önceki tüm günlüklerin silineceğini unutmayın. - -!!! note "Not" - Günlüklerin depolama süresi sınırsızdır. Günlükler tablodan otomatik olarak silinmez. Eski günlüklerin kaldırılmasını kendiniz düzenlemeniz gerekir. - -İçin keyfi bir bölümleme anahtarı belirtebilirsiniz `system.query_thread_log` tablo içinde [query\_thread\_log](server_configuration_parameters/settings.md#server_configuration_parameters-query-thread-log) sunucu ayarı (bkz. `partition_by` parametre). - -## sistem.trace\_log {#system_tables-trace_log} - -Örnekleme sorgusu profiler tarafından toplanan yığın izlemeleri içerir. - -ClickHouse bu tabloyu oluşturduğunda [trace\_log](server_configuration_parameters/settings.md#server_configuration_parameters-trace_log) sunucu yapılandırma bölümü ayarlanır. Ayrıca [query\_profiler\_real\_time\_period\_ns](settings/settings.md#query_profiler_real_time_period_ns) ve [query\_profiler\_cpu\_time\_period\_ns](settings/settings.md#query_profiler_cpu_time_period_ns) ayarlar ayarlan .malıdır. - -Günlükleri analiz etmek için `addressToLine`, `addressToSymbol` ve `demangle` iç gözlem fonksiyonları. - -Sütun: - -- `event_date`([Tarihli](../sql_reference/data_types/date.md)) — Date of sampling moment. - -- `event_time`([DateTime](../sql_reference/data_types/datetime.md)) — Timestamp of sampling moment. - -- `revision`([Uİnt32](../sql_reference/data_types/int_uint.md)) — ClickHouse server build revision. - - Tarafından sunucuya Bağlan byırken `clickhouse-client`, benzer diz theg seeeyi görüyorsunuz `Connected to ClickHouse server version 19.18.1 revision 54429.`. Bu alan şunları içerir `revision` ama `version` bir sunucunun. - -- `timer_type`([Enum8](../sql_reference/data_types/enum.md)) — Timer type: - - - `Real` duvar saati zamanını temsil eder. - - `CPU` CPU süresini temsil eder. - -- `thread_number`([Uİnt32](../sql_reference/data_types/int_uint.md)) — Thread identifier. - -- `query_id`([Dize](../sql_reference/data_types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) sistem tablosu. - -- `trace`([Dizi (Uİnt64)](../sql_reference/data_types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process. - -**Örnek** - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-15 -event_time: 2019-11-15 15:09:38 -revision: 54428 -timer_type: Real -thread_number: 48 -query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915 -trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935] -``` - -## sistem.yinelemeler {#system_tables-replicas} - -Yerel sunucuda bulunan çoğaltılmış tablolar için bilgi ve durum içerir. -Bu tablo izleme için kullanılabilir. Tablo, her çoğaltılmış \* tablo için bir satır içerir. - -Örnek: - -``` sql -SELECT * -FROM system.replicas -WHERE table = 'visits' -FORMAT Vertical -``` - -``` text -Row 1: -────── -database: merge -table: visits -engine: ReplicatedCollapsingMergeTree -is_leader: 1 -can_become_leader: 1 -is_readonly: 0 -is_session_expired: 0 -future_parts: 1 -parts_to_check: 0 -zookeeper_path: /clickhouse/tables/01-06/visits -replica_name: example01-06-1.yandex.ru -replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru -columns_version: 9 -queue_size: 1 -inserts_in_queue: 0 -merges_in_queue: 1 -part_mutations_in_queue: 0 -queue_oldest_time: 2020-02-20 08:34:30 -inserts_oldest_time: 0000-00-00 00:00:00 -merges_oldest_time: 2020-02-20 08:34:30 -part_mutations_oldest_time: 0000-00-00 00:00:00 -oldest_part_to_get: -oldest_part_to_merge_to: 20200220_20284_20840_7 -oldest_part_to_mutate_to: -log_max_index: 596273 -log_pointer: 596274 -last_queue_update: 2020-02-20 08:34:32 -absolute_delay: 0 -total_replicas: 2 -active_replicas: 2 -``` - -Sütun: - -- `database` (`String`)- Veritabanı adı -- `table` (`String`)- Tablo adı -- `engine` (`String`)- Tablo motor adı -- `is_leader` (`UInt8`)- Kopya lider olup olmadığı. - Bir seferde sadece bir kopya lider olabilir. Lider, gerçekleştirmek için arka plan birleştirmelerini seçmekten sorumludur. - Yazma kullanılabilir ve bir oturum ZK, bir lider olup olmadığına bakılmaksızın olan herhangi bir yineleme için gerçekleştirilebilir unutmayın. -- `can_become_leader` (`UInt8`)- Rep .lik leaderanın lider olarak seçil .ip seçil .emeyeceği. -- `is_readonly` (`UInt8`)- Yinelemenin salt okunur modda olup olmadığı. - Yapılandırmanın ZooKeeper ile bölümleri yoksa, zookeeper'daki oturumları yeniden başlatırken ve Zookeeper'daki oturum yeniden başlatılırken bilinmeyen bir hata oluşmuşsa bu mod açılır. -- `is_session_expired` (`UInt8`)- ZooKeeper ile oturum süresi doldu. Temelde aynı `is_readonly`. -- `future_parts` (`UInt32`)- Henüz yapılmamış ekler veya birleştirmelerin sonucu olarak görünecek veri parçalarının sayısı. -- `parts_to_check` (`UInt32`)- Doğrulama için kuyruktaki veri parçalarının sayısı. Hasar görebileceğinden şüphe varsa, bir parça doğrulama kuyruğuna konur. -- `zookeeper_path` (`String`)- ZooKeeper tablo verilerine yolu. -- `replica_name` (`String`)- Zookeeper çoğaltma adı. Aynı tablonun farklı kopyaları farklı adlara sahiptir. -- `replica_path` (`String`)- ZooKeeper çoğaltma veri yolu. Birleştirme ile aynı ‘zookeeper\_path/replicas/replica\_path’. -- `columns_version` (`Int32`)- Tablo yapısının sürüm numarası. ALTER kaç kez gerçekleştirildiğini gösterir. Kopyaların farklı sürümleri varsa, bazı kopyaların tüm değişiklikleri henüz yapmadığı anlamına gelir. -- `queue_size` (`UInt32`)- Yapılması beklenen işlemler için sıranın büyüklüğü. İşlemler, veri bloklarını, birleştirmeleri ve diğer bazı eylemleri eklemeyi içerir. Genellikle ile çakışmaktadır `future_parts`. -- `inserts_in_queue` (`UInt32`)- Yapılması gereken veri bloklarının eklerinin sayısı. Eklemeler genellikle oldukça hızlı bir şekilde çoğaltılır. Bu sayı büyükse, bir şeylerin yanlış olduğu anlamına gelir. -- `merges_in_queue` (`UInt32`)- Yapılmasını bekleyen birleştirme sayısı. Bazen birleştirmeler uzundur, bu nedenle bu değer uzun süre sıfırdan büyük olabilir. -- `part_mutations_in_queue` (`UInt32`)- Yapılması beklenen Mut numberasyon sayısı. -- `queue_oldest_time` (`DateTime`) - Eğer `queue_size` daha büyük 0, en eski işlem sıraya eklendiğinde gösterir. -- `inserts_oldest_time` (`DateTime`) - Görmek `queue_oldest_time` -- `merges_oldest_time` (`DateTime`) - Görmek `queue_oldest_time` -- `part_mutations_oldest_time` (`DateTime`) - Görmek `queue_oldest_time` - -Sonraki 4 sütun, yalnızca ZK ile aktif bir oturumun olduğu sıfır olmayan bir değere sahiptir. - -- `log_max_index` (`UInt64`)- Genel faaliyet günlüğüne maksimum giriş numarası. -- `log_pointer` (`UInt64`)- Çoğaltma yürütme kuyruğuna kopyalanan genel faaliyet günlüğüne maksimum giriş numarası, artı bir. Eğer `log_pointer` daha küçük `log_max_index` yanlış bir şey olduğunu. -- `last_queue_update` (`DateTime`)- Kuyruk son kez güncellendiğinde. -- `absolute_delay` (`UInt64`)- Geçerli kopyanın saniyeler içinde ne kadar büyük gecikme var. -- `total_replicas` (`UInt8`)- Bu tablonun bilinen kopyalarının toplam sayısı. -- `active_replicas` (`UInt8`)- ZooKeeper bir oturum var bu tablonun kopyaları sayısı (yani, işleyen kopyaları sayısı). - -Tüm sütunları talep ederseniz, Tablo biraz yavaş çalışabilir, çünkü ZooKeeper birkaç okuma her satır için yapılır. -Son 4 sütun (log\_max\_ındex, log\_pointer, total\_replicas, active\_replicas) istemiyorsanız, tablo hızlı bir şekilde çalışır. - -Örneğin, her şeyin böyle düzgün çalıştığını kontrol edebilirsiniz: - -``` sql -SELECT - database, - table, - is_leader, - is_readonly, - is_session_expired, - future_parts, - parts_to_check, - columns_version, - queue_size, - inserts_in_queue, - merges_in_queue, - log_max_index, - log_pointer, - total_replicas, - active_replicas -FROM system.replicas -WHERE - is_readonly - OR is_session_expired - OR future_parts > 20 - OR parts_to_check > 10 - OR queue_size > 20 - OR inserts_in_queue > 10 - OR log_max_index - log_pointer > 10 - OR total_replicas < 2 - OR active_replicas < total_replicas -``` - -Bu sorgu hiçbir şey döndürmezse, her şeyin yolunda olduğu anlamına gelir. - -## sistem.ayarlar {#system-tables-system-settings} - -Geçerli kullanıcı için oturum ayarları hakkında bilgi içerir. - -Sütun: - -- `name` ([Dize](../sql_reference/data_types/string.md)) — Setting name. -- `value` ([Dize](../sql_reference/data_types/string.md)) — Setting value. -- `changed` ([Uİnt8](../sql_reference/data_types/int_uint.md#uint-ranges)) — Shows whether a setting is changed from its default value. -- `description` ([Dize](../sql_reference/data_types/string.md)) — Short setting description. -- `min` ([Nullable](../sql_reference/data_types/nullable.md)([Dize](../sql_reference/data_types/string.md))) — Minimum value of the setting, if any is set via [kısıtlamalar](settings/constraints_on_settings.md#constraints-on-settings). Ayarın minimum değeri yoksa, şunları içerir [NULL](../sql_reference/syntax.md#null-literal). -- `max` ([Nullable](../sql_reference/data_types/nullable.md)([Dize](../sql_reference/data_types/string.md))) — Maximum value of the setting, if any is set via [kısıtlamalar](settings/constraints_on_settings.md#constraints-on-settings). Ayarın maksimum değeri yoksa, şunları içerir [NULL](../sql_reference/syntax.md#null-literal). -- `readonly` ([Uİnt8](../sql_reference/data_types/int_uint.md#uint-ranges)) — Shows whether the current user can change the setting: - - `0` — Current user can change the setting. - - `1` — Current user can't change the setting. - -**Örnek** - -Aşağıdaki örnek, adı içeren ayarlar hakkında bilgi almak gösterilmiştir `min_i`. - -``` sql -SELECT * -FROM system.settings -WHERE name LIKE '%min_i%' -``` - -``` text -┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐ -│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ -└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘ -``` - -Kullanımı `WHERE changed` örneğin, kontrol etmek istediğinizde yararlı olabilir: - -- Olsun yapılandırma dosyaları, ayarları doğru şekilde yüklenmiş ve kullanımdadır. -- Geçerli oturumda değişen ayarlar. - - - -``` sql -SELECT * FROM system.settings WHERE changed AND name='load_balancing' -``` - -**Ayrıca bakınız** - -- [Ayarlar](settings/index.md#settings) -- [Sorgular için izinler](settings/permissions_for_queries.md#settings_readonly) -- [Ayarlardaki kısıtlamalar](settings/constraints_on_settings.md) - -## sistem.table\_engines {#system.table_engines} - -``` text -┌─name───────────────────┬─value───────┐ -│ max_threads │ 8 │ -│ use_uncompressed_cache │ 0 │ -│ load_balancing │ random │ -│ max_memory_usage │ 10000000000 │ -└────────────────────────┴─────────────┘ -``` - -## sistem.merge\_tree\_settings {#system-merge_tree_settings} - -İçin ayarlar hakkında bilgi içerir `MergeTree` Tablolar. - -Sütun: - -- `name` (String) — Setting name. -- `value` (String) — Setting value. -- `description` (String) — Setting description. -- `type` (String) — Setting type (implementation specific string value). -- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed. - -## sistem.table\_engines {#system-table-engines} - -Sunucu tarafından desteklenen tablo motorlarının açıklamasını ve özellik destek bilgilerini içerir. - -Bu tablo aşağıdaki sütunları içerir (sütun türü parantez içinde gösterilir): - -- `name` (String) — The name of table engine. -- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` yan. -- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [endeksleri atlama](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-data_skipping-indexes). -- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-ttl). -- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` ve `SAMPLE_BY`. -- `supports_replication` (UInt8) — Flag that indicates if table engine supports [veri çoğaltma](../engines/table_engines/mergetree_family/replication.md). -- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication. - -Örnek: - -``` sql -SELECT * -FROM system.table_engines -WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') -``` - -``` text -┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐ -│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │ -│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │ -│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ -└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘ -``` - -**Ayrıca bakınız** - -- MergeTree ailesi [sorgu yan tümceleri](../engines/table_engines/mergetree_family/mergetree.md#mergetree-query-clauses) -- Kafka [ayarlar](../engines/table_engines/integrations/kafka.md#table_engine-kafka-creating-a-table) -- Katmak [ayarlar](../engines/table_engines/special/join.md#join-limitations-and-settings) - -## sistem.Tablolar {#system-tables} - -Sunucunun bildiği her tablonun meta verilerini içerir. Müstakil tablolar gösterilmez `system.tables`. - -Bu tablo aşağıdaki sütunları içerir (sütun türü parantez içinde gösterilir): - -- `database` (String) — The name of the database the table is in. - -- `name` (String) — Table name. - -- `engine` (String) — Table engine name (without parameters). - -- `is_temporary` (Uİnt8) - tablonun geçici olup olmadığını gösteren bayrak. - -- `data_path` (String) - dosya sistemindeki tablo verilerinin yolu. - -- `metadata_path` (String) - dosya sistemindeki tablo Meta Veri Yolu. - -- `metadata_modification_time` (DateTime) - tablo meta son değişiklik zamanı. - -- `dependencies_database` (Array (String)) - veritabanı bağımlılıkları. - -- `dependencies_table` (Array (String)) - Tablo bağımlılıkları ([MaterializedView](../engines/table_engines/special/materializedview.md) geçerli tabloya dayalı tablolar). - -- `create_table_query` (String) - tablo oluşturmak için kullanılan sorgu. - -- `engine_full` (String) - tablo motorunun parametreleri. - -- `partition_key` (String) - tabloda belirtilen bölüm anahtarı ifadesi. - -- `sorting_key` (String) - tabloda belirtilen sıralama anahtarı ifadesi. - -- `primary_key` (String) - tabloda belirtilen birincil anahtar ifadesi. - -- `sampling_key` (String) - tabloda belirtilen örnekleme anahtar ifadesi. - -- `storage_policy` (String) - depolama politikası: - - - [MergeTree](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes) - - [Dağılı](../engines/table_engines/special/distributed.md#distributed) - -- `total_rows` (Nullable (Uİnt64)) - tablodaki tam satır sayısını hızlı bir şekilde belirlemek mümkün ise, toplam satır sayısı `Null` (underying dahil `Buffer` Tablo). - -- `total_bytes` (Nullable (Uİnt64)) - toplam bayt sayısı, eğer depolama alanındaki tablo için tam bayt sayısını hızlı bir şekilde belirlemek mümkün ise, aksi takdirde `Null` (**do Notes not** herhangi bir temel depolama içerir). - - - If the table stores data on disk, returns used space on disk (i.e. compressed). - - Tablo verileri bellekte depolarsa, bellekte kullanılan bayt sayısını yaklaşık olarak döndürür. - -Bu `system.tables` tablo kullanılır `SHOW TABLES` sorgu uygulaması. - -## sistem.zookeeper {#system-zookeeper} - -ZooKeeper yapılandırılmamışsa, tablo yok. Yapılandırmada tanımlanan ZooKeeper kümesinden veri okumayı sağlar. -Sorgu bir olmalıdır ‘path’ WH .ere madd .esindeki eşitlik koşulu. Bu veri almak istediğiniz çocuklar için ZooKeeper yoludur. - -Sorgu `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` tüm çocuklar için veri çıkışı `/clickhouse` düğümlü. -Tüm kök düğümler için veri çıkışı yapmak için, path = yazın ‘/’. -Belirtilen yol ise ‘path’ yok, bir istisna atılır. - -Sütun: - -- `name` (String) — The name of the node. -- `path` (String) — The path to the node. -- `value` (String) — Node value. -- `dataLength` (Int32) — Size of the value. -- `numChildren` (Int32) — Number of descendants. -- `czxid` (Int64) — ID of the transaction that created the node. -- `mzxid` (Int64) — ID of the transaction that last changed the node. -- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants. -- `ctime` (DateTime) — Time of node creation. -- `mtime` (DateTime) — Time of the last modification of the node. -- `version` (Int32) — Node version: the number of times the node was changed. -- `cversion` (Int32) — Number of added or removed descendants. -- `aversion` (Int32) — Number of changes to the ACL. -- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node. - -Örnek: - -``` sql -SELECT * -FROM system.zookeeper -WHERE path = '/clickhouse/tables/01-08/visits/replicas' -FORMAT Vertical -``` - -``` text -Row 1: -────── -name: example01-08-1.yandex.ru -value: -czxid: 932998691229 -mzxid: 932998691229 -ctime: 2015-03-27 16:49:51 -mtime: 2015-03-27 16:49:51 -version: 0 -cversion: 47 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021031383 -path: /clickhouse/tables/01-08/visits/replicas - -Row 2: -────── -name: example01-08-2.yandex.ru -value: -czxid: 933002738135 -mzxid: 933002738135 -ctime: 2015-03-27 16:57:01 -mtime: 2015-03-27 16:57:01 -version: 0 -cversion: 37 -aversion: 0 -ephemeralOwner: 0 -dataLength: 0 -numChildren: 7 -pzxid: 987021252247 -path: /clickhouse/tables/01-08/visits/replicas -``` - -## sistem.mutasyonlar {#system_tables-mutations} - -Tablo hakkında bilgi içerir [mutasyonlar](../sql_reference/statements/alter.md#alter-mutations) MergeTree tabloları ve bunların ilerleme. Her mutasyon komutu tek bir satırla temsil edilir. Tablo aşağıdaki sütunlara sahiptir: - -**veritabanı**, **Tablo** - Mutasyonun uygulandığı veritabanı ve tablonun adı. - -**mutation\_id** - Mutasyonun kimliği. Çoğaltılmış tablolar için bu kimlikler znode adlarına karşılık gelir `/mutations/` ZooKeeper dizin. Yinelenmemiş tablolar için kimlikler, tablonun veri dizinindeki dosya adlarına karşılık gelir. - -**komut** - Mut commandasyon komut diz (gesi (sorgu afterdan sonra `ALTER TABLE [db.]table`). - -**create\_time** - Bu mutasyon komutu idam için sunulduğunda. - -**block\_numbers.partition\_id**, **block\_numbers.numara** - İç içe geçmiş bir sütun. Çoğaltılmış tabloların mutasyonları için, her bölüm için bir kayıt içerir: bölüm kimliği ve mutasyon tarafından elde edilen blok numarası (her bölümde, yalnızca bu bölümdeki mutasyon tarafından elde edilen blok sayısından daha az sayıda blok içeren parçalar mutasyona uğrayacaktır). Çoğaltılmamış tablolarda, tüm bölümlerdeki blok numaraları tek bir sıra oluşturur. Bu, çoğaltılmamış tabloların mutasyonları için, sütunun mutasyon tarafından elde edilen tek bir blok numarasına sahip bir kayıt içereceği anlamına gelir. - -**parts\_to\_do** - Mutasyonun bitmesi için mutasyona uğraması gereken veri parçalarının sayısı. - -**is\_done** - Mutasyon bitti mi? Not bile `parts_to_do = 0` çoğaltılmış bir tablonun mutasyonu, mutasyona uğraması gereken yeni bir veri parçası yaratacak uzun süren bir ekleme nedeniyle henüz yapılmamıştır. - -Bazı bölümleri mutasyon ile ilgili sorunlar varsa, aşağıdaki sütunlar ek bilgi içerir: - -**latest\_failed\_part** - Mutasyona uğramayan en son bölümün adı. - -**latest\_fail\_time** - En son bölüm mutasyon başarısızlığı zamanı. - -**latest\_fail\_reason** - En son bölüm mutasyon başarısızlığına neden olan istisna mesajı. - -## sistem.diskler {#system_tables-disks} - -İçinde tanımlanan diskler hakkında bilgi içerir [sunucu yapılandırması](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Sütun: - -- `name` ([Dize](../sql_reference/data_types/string.md)) — Name of a disk in the server configuration. -- `path` ([Dize](../sql_reference/data_types/string.md)) — Path to the mount point in the file system. -- `free_space` ([Uİnt64](../sql_reference/data_types/int_uint.md)) — Free space on disk in bytes. -- `total_space` ([Uİnt64](../sql_reference/data_types/int_uint.md)) — Disk volume in bytes. -- `keep_free_space` ([Uİnt64](../sql_reference/data_types/int_uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` disk yapılandırması parametresi. - -## sistem.storage\_policies {#system_tables-storage_policies} - -Depolama ilkeleri ve birimlerinde tanımlanan bilgiler içerir. [sunucu yapılandırması](../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes_configure). - -Sütun: - -- `policy_name` ([Dize](../sql_reference/data_types/string.md)) — Name of the storage policy. -- `volume_name` ([Dize](../sql_reference/data_types/string.md)) — Volume name defined in the storage policy. -- `volume_priority` ([Uİnt64](../sql_reference/data_types/int_uint.md)) — Volume order number in the configuration. -- `disks` ([Ar Arrayray (String)](../sql_reference/data_types/array.md)) — Disk names, defined in the storage policy. -- `max_data_part_size` ([Uİnt64](../sql_reference/data_types/int_uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit). -- `move_factor` ([Float64](../sql_reference/data_types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order. - -Depolama ilkesi birden fazla birim içeriyorsa, her birim için bilgiler tablonun tek tek satırında saklanır. - -[Orijinal makale](https://clickhouse.tech/docs/en/operations/system_tables/) diff --git a/docs/tr/operations/tips.md b/docs/tr/operations/tips.md index e6b02a239c5..50e78dc772f 100644 --- a/docs/tr/operations/tips.md +++ b/docs/tr/operations/tips.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 58 toc_title: "Kullan\u0131m \xD6nerileri" --- diff --git a/docs/tr/operations/troubleshooting.md b/docs/tr/operations/troubleshooting.md index f16a59767d6..fb547342b2f 100644 --- a/docs/tr/operations/troubleshooting.md +++ b/docs/tr/operations/troubleshooting.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 46 toc_title: "Ar\u0131za" --- @@ -17,7 +17,7 @@ toc_title: "Ar\u0131za" ### Apt-get ile ClickHouse deposundan Deb paketleri alınamıyor {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} - Güvenlik Duvarı ayarlarını kontrol edin. -- Depoya herhangi bir nedenle erişemiyorsanız, paketleri aşağıda açıklandığı gibi indirin [Başlarken](../getting_started/index.md) makale ve bunları kullanarak manuel olarak yükleyin `sudo dpkg -i ` komut. Ayrıca ihtiyacınız olacak `tzdata` paket. +- Depoya herhangi bir nedenle erişemiyorsanız, paketleri aşağıda açıklandığı gibi indirin [Başlarken](../getting-started/index.md) makale ve bunları kullanarak manuel olarak yükleyin `sudo dpkg -i ` komut. Ayrıca ihtiyacınız olacak `tzdata` paket. ## Sunucuya bağlanma {#troubleshooting-accepts-no-connections} @@ -105,7 +105,7 @@ Kontrol: - Bitiş noktası ayarları. - Kontrol [listen\_host](server_configuration_parameters/settings.md#server_configuration_parameters-listen_host) ve [tcp\_port](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port) ayarlar. + Kontrol [listen\_host](server-configuration-parameters/settings.md#server_configuration_parameters-listen_host) ve [tcp\_port](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port) ayarlar. ClickHouse server, yalnızca varsayılan olarak localhost bağlantılarını kabul eder. @@ -117,8 +117,8 @@ Kontrol: Kontrol: - - Bu [tcp\_port\_secure](server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) ayar. - - İçin ayarlar [SSL sertifikaları](server_configuration_parameters/settings.md#server_configuration_parameters-openssl). + - Bu [tcp\_port\_secure](server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) ayar. + - İçin ayarlar [SSL sertifikaları](server-configuration-parameters/settings.md#server_configuration_parameters-openssl). Bağlanırken uygun parametreleri kullanın. Örneğin, kullanın `port_secure` parametre ile `clickhouse_client`. diff --git a/docs/tr/operations/update.md b/docs/tr/operations/update.md index 1529729321e..08168cf4f64 100644 --- a/docs/tr/operations/update.md +++ b/docs/tr/operations/update.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 47 toc_title: "ClickHouse G\xFCncelleme" --- diff --git a/docs/tr/operations/utilities/clickhouse-benchmark.md b/docs/tr/operations/utilities/clickhouse-benchmark.md index 952852d880e..52c4d5c23ed 100644 --- a/docs/tr/operations/utilities/clickhouse-benchmark.md +++ b/docs/tr/operations/utilities/clickhouse-benchmark.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 61 toc_title: clickhouse-benchmark --- @@ -91,15 +91,15 @@ Raporda bulabilirsiniz: - ClickHouse sunucusunun bitiş noktası. - İşlenen sorgu sayısı. - - QPS: qps: kaç sorgu sunucusu saniyede belirtilen bir süre boyunca gerçekleştirilen `--delay` değişken. - - RPS: kaç satır sunucu saniyede belirtilen bir süre boyunca okuma `--delay` değişken. - - MıB / s: kaç mebibytes sunucu saniyede belirtilen bir süre boyunca okuma `--delay` değişken. - - sonuç RPS: sunucu tarafından belirtilen bir süre boyunca saniyede bir sorgunun sonucuna kaç satır yerleştirilir `--delay` değişken. - - sonuç MıB / s. kaç mebibytes sunucu tarafından belirtilen bir dönemde saniyede bir sorgu sonucu yerleştirilir `--delay` değişken. + - QPS: qps: kaç sorgu sunucusu saniyede belirtilen bir süre boyunca gerçekleştirilen `--delay` tartışma. + - RPS: kaç satır sunucu saniyede belirtilen bir süre boyunca okuma `--delay` tartışma. + - MıB / s: kaç mebibytes sunucu saniyede belirtilen bir süre boyunca okuma `--delay` tartışma. + - sonuç RPS: sunucu tarafından belirtilen bir süre boyunca saniyede bir sorgunun sonucuna kaç satır yerleştirilir `--delay` tartışma. + - sonuç MıB / s. kaç mebibytes sunucu tarafından belirtilen bir dönemde saniyede bir sorgu sonucu yerleştirilir `--delay` tartışma. - Sorgu yürütme süresi yüzdelik. -## Karşılaştırma modu {#clickhouse-benchmark-comparison-mode} +## Karşılaştırma Modu {#clickhouse-benchmark-comparison-mode} `clickhouse-benchmark` iki çalışan ClickHouse sunucuları için performansları karşılaştırabilirsiniz. diff --git a/docs/tr/operations/utilities/clickhouse-copier.md b/docs/tr/operations/utilities/clickhouse-copier.md index 932519086c1..04b93c41fd6 100644 --- a/docs/tr/operations/utilities/clickhouse-copier.md +++ b/docs/tr/operations/utilities/clickhouse-copier.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 59 toc_title: clickhouse-fotokopi makinesi --- diff --git a/docs/tr/operations/utilities/clickhouse-local.md b/docs/tr/operations/utilities/clickhouse-local.md index 5e47459b670..d39a642b830 100644 --- a/docs/tr/operations/utilities/clickhouse-local.md +++ b/docs/tr/operations/utilities/clickhouse-local.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_priority: 60 toc_title: clickhouse-yerel --- @@ -9,11 +9,11 @@ toc_title: clickhouse-yerel Bu `clickhouse-local` program, ClickHouse sunucusunu dağıtmak ve yapılandırmak zorunda kalmadan yerel dosyalar üzerinde hızlı işlem yapmanızı sağlar. -Tabloları temsil eden verileri kabul eder ve bunları kullanarak sorgular [ClickHouse SQL lehçesi](../../sql_reference/index.md). +Tabloları temsil eden verileri kabul eder ve bunları kullanarak sorgular [ClickHouse SQL lehçesi](../../sql-reference/index.md). `clickhouse-local` ClickHouse server ile aynı çekirdeği kullanır, bu nedenle özelliklerin çoğunu ve aynı format ve tablo motorlarını destekler. -Varsayılan olarak `clickhouse-local` aynı ana bilgisayarda verilere erişimi yok, ancak kullanarak yükleme sunucu yapılandırmasını destekler `--config-file` değişken. +Varsayılan olarak `clickhouse-local` aynı ana bilgisayarda verilere erişimi yok, ancak kullanarak yükleme sunucu yapılandırmasını destekler `--config-file` tartışma. !!! warning "Uyarıcı" İçine üretim sunucusu yapılandırmasını yüklemek için tavsiye edilmez `clickhouse-local` çünkü insan hatası durumunda veriler zarar görebilir. diff --git a/docs/tr/operations/utilities/index.md b/docs/tr/operations/utilities/index.md index 17d3849cc6a..cdd99610911 100644 --- a/docs/tr/operations/utilities/index.md +++ b/docs/tr/operations/utilities/index.md @@ -1,6 +1,6 @@ --- machine_translated: true -machine_translated_rev: e8cd92bba3269f47787db090899f7c242adf7818 +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd toc_folder_title: Programlar toc_priority: 56 toc_title: "Genel bak\u0131\u015F" diff --git a/docs/tr/sql-reference/aggregate-functions/combinators.md b/docs/tr/sql-reference/aggregate-functions/combinators.md new file mode 100644 index 00000000000..a085ef6595e --- /dev/null +++ b/docs/tr/sql-reference/aggregate-functions/combinators.md @@ -0,0 +1,245 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "Birle\u015Ftiriciler" +--- + +# Toplama Fonksiyonu Birleştiriciler {#aggregate_functions_combinators} + +Bir toplama işlevinin adı, ona eklenmiş bir sonek olabilir. Bu, toplama işlevinin çalışma şeklini değiştirir. + +## -Eğer {#agg-functions-combinator-if} + +The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). + +Örnekler: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` ve böyle devam eder. + +Koşullu toplama işlevleriyle, alt sorgular kullanmadan aynı anda birkaç koşul için toplamları hesaplayabilirsiniz ve `JOIN`s. Örneğin, Üye olarak.Metrica, koşullu toplama işlevleri segment karşılaştırma işlevselliğini uygulamak için kullanılır. + +## -Dizi {#agg-functions-combinator-array} + +\- Array soneki herhangi bir toplama işlevine eklenebilir. Bu durumda, toplama işlevi, ‘Array(T)’ type (ar arraysra )ys) yerine ‘T’ bağımsız değişkenleri yazın. Toplama işlevi birden çok bağımsız değişken kabul ederse, bu eşit uzunlukta diziler olmalıdır. Dizileri işlerken, toplama işlevi tüm dizi öğelerinde orijinal toplama işlevi gibi çalışır. + +Örnek 1: `sumArray(arr)` - Tüm unsurları toplamları ‘arr’ diziler. Bu örnekte, daha basit yazılmış olabilir: `sum(arraySum(arr))`. + +Örnek 2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ diziler. Bu daha kolay bir şekilde yapılabilir: `uniq(arrayJoin(arr))`, ancak eklemek her zaman mümkün değildir ‘arrayJoin’ bir sorguya. + +\- Eğer ve-dizi kombine edilebilir. Ancak, ‘Array’ önce gel mustmeli, sonra ‘If’. Örnekler: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. Nedeniyle bu sipariş için, ‘cond’ argüman bir dizi olmayacak. + +## -Devlet {#agg-functions-combinator-state} + +Bu birleştiriciyi uygularsanız, toplama işlevi elde edilen değeri döndürmez (örneğin, [uniq](reference.md#agg_function-uniq) fonksiyonu), ancak top aggreglamanın bir ara durumu (for `uniq`, bu benzersiz değerlerin sayısını hesaplamak için karma tablodur). Bu bir `AggregateFunction(...)` bu, daha fazla işlem için kullanılabilir veya daha sonra toplanmayı bitirmek için bir tabloda saklanabilir. + +Bu durumlarla çalışmak için şunları kullanın: + +- [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) masa motoru. +- [finalizeAggregation](../../sql-reference/functions/other-functions.md#function-finalizeaggregation) İşlev. +- [runningAccumulate](../../sql-reference/functions/other-functions.md#function-runningaccumulate) İşlev. +- [-Birleştirmek](#aggregate_functions_combinators-merge) birleştirici. +- [- MergeState](#aggregate_functions_combinators-mergestate) birleştirici. + +## -Birleştirmek {#aggregate_functions_combinators-merge} + +Bu birleştiriciyi uygularsanız, toplama işlevi Ara toplama durumunu bağımsız değişken olarak alır, toplama işlemini tamamlamak için durumları birleştirir ve elde edilen değeri döndürür. + +## - MergeState {#aggregate_functions_combinators-mergestate} + +Ara toplama durumlarını-birleştirme Birleştiricisi ile aynı şekilde birleştirir. Bununla birlikte, elde edilen değeri döndürmez, ancak-State combinator'a benzer bir ara toplama durumu döndürür. + +## - ForEach {#agg-functions-combinator-foreach} + +Tablolar için bir toplama işlevi, karşılık gelen dizi öğelerini toplayan ve bir dizi sonuç döndüren diziler için bir toplama işlevine dönüştürür. Mesela, `sumForEach` diz theiler için `[1, 2]`, `[3, 4, 5]`ve`[6, 7]`sonucu döndürür `[10, 13, 5]` karşılık gelen dizi öğelerini bir araya getirdikten sonra. + +## - OrDefault {#agg-functions-combinator-ordefault} + +Toplama işlevinin davranışını değiştirir. + +Bir toplama işlevinin giriş değerleri yoksa, bu birleştirici ile dönüş veri türü için varsayılan değeri döndürür. Boş giriş verilerini alabilen toplama işlevlerine uygulanır. + +`-OrDefault` diğer birleştiriciler ile kullanılabilir. + +**Sözdizimi** + +``` sql +OrDefault(x) +``` + +**Parametre** + +- `x` — Aggregate function parameters. + +**Döndürülen değerler** + +Toplamak için hiçbir şey yoksa, bir toplama işlevinin dönüş türünün Varsayılan değerini döndürür. + +Türü kullanılan toplama işlevine bağlıdır. + +**Örnek** + +Sorgu: + +``` sql +SELECT avg(number), avgOrDefault(number) FROM numbers(0) +``` + +Sonuç: + +``` text +┌─avg(number)─┬─avgOrDefault(number)─┐ +│ nan │ 0 │ +└─────────────┴──────────────────────┘ +``` + +Ayrıca `-OrDefault` başka bir birleştiriciler ile kullanılabilir. Toplama işlevi boş girişi kabul etmediğinde yararlıdır. + +Sorgu: + +``` sql +SELECT avgOrDefaultIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Sonuç: + +``` text +┌─avgOrDefaultIf(x, greater(x, 10))─┐ +│ 0.00 │ +└───────────────────────────────────┘ +``` + +## - OrNull {#agg-functions-combinator-ornull} + +Toplama işlevinin davranışını değiştirir. + +Bu birleştirici, bir toplama işlevinin sonucunu [Nullable](../data-types/nullable.md) veri türü. Toplama işlevi hesaplamak için değerleri yoksa döndürür [NULL](../syntax.md#null-literal). + +`-OrNull` diğer birleştiriciler ile kullanılabilir. + +**Sözdizimi** + +``` sql +OrNull(x) +``` + +**Parametre** + +- `x` — Aggregate function parameters. + +**Döndürülen değerler** + +- Toplama işlev resultinin sonucu, `Nullable` veri türü. +- `NULL`, toplamak için bir şey yoksa. + +Tür: `Nullable(aggregate function return type)`. + +**Örnek** + +Eklemek `-orNull` toplama işlevinin sonuna kadar. + +Sorgu: + +``` sql +SELECT sumOrNull(number), toTypeName(sumOrNull(number)) FROM numbers(10) WHERE number > 10 +``` + +Sonuç: + +``` text +┌─sumOrNull(number)─┬─toTypeName(sumOrNull(number))─┐ +│ ᴺᵁᴸᴸ │ Nullable(UInt64) │ +└───────────────────┴───────────────────────────────┘ +``` + +Ayrıca `-OrNull` başka bir birleştiriciler ile kullanılabilir. Toplama işlevi boş girişi kabul etmediğinde yararlıdır. + +Sorgu: + +``` sql +SELECT avgOrNullIf(x, x > 10) +FROM +( + SELECT toDecimal32(1.23, 2) AS x +) +``` + +Sonuç: + +``` text +┌─avgOrNullIf(x, greater(x, 10))─┐ +│ ᴺᵁᴸᴸ │ +└────────────────────────────────┘ +``` + +## - Resample {#agg-functions-combinator-resample} + +Verileri gruplara ayırmanızı sağlar ve ardından bu gruplardaki verileri ayrı ayrı toplar. Gruplar, değerleri bir sütundan aralıklara bölerek oluşturulur. + +``` sql +Resample(start, end, step)(, resampling_key) +``` + +**Parametre** + +- `start` — Starting value of the whole required interval for `resampling_key` değerler. +- `stop` — Ending value of the whole required interval for `resampling_key` değerler. Tüm Aralık içermez `stop` değer `[start, stop)`. +- `step` — Step for separating the whole interval into subintervals. The `aggFunction` bu alt aralıkların her biri üzerinde bağımsız olarak yürütülür. +- `resampling_key` — Column whose values are used for separating data into intervals. +- `aggFunction_params` — `aggFunction` parametre. + +**Döndürülen değerler** + +- Ar arrayray of `aggFunction` her subinterval için sonuçlar. + +**Örnek** + +Düşünün `people` aşağıdaki verilerle tablo: + +``` text +┌─name───┬─age─┬─wage─┐ +│ John │ 16 │ 10 │ +│ Alice │ 30 │ 15 │ +│ Mary │ 35 │ 8 │ +│ Evelyn │ 48 │ 11.5 │ +│ David │ 62 │ 9.9 │ +│ Brian │ 60 │ 16 │ +└────────┴─────┴──────┘ +``` + +Yaş aralığı içinde olan kişilerin isimlerini alalım `[30,60)` ve `[60,75)`. Yaş için tamsayı temsilini kullandığımızdan, yaşları `[30, 59]` ve `[60,74]` aralıklılar. + +Bir dizideki isimleri toplamak için, [groupArray](reference.md#agg_function-grouparray) toplama işlevi. Bir argüman alır. Bizim durumumuzda, bu `name` sütun. Bu `groupArrayResample` fonksiyon kullanmalıdır `age` yaşlara göre isimleri toplamak için sütun. Gerekli aralıkları tanımlamak için `30, 75, 30` argü themanlar içine `groupArrayResample` İşlev. + +``` sql +SELECT groupArrayResample(30, 75, 30)(name, age) FROM people +``` + +``` text +┌─groupArrayResample(30, 75, 30)(name, age)─────┐ +│ [['Alice','Mary','Evelyn'],['David','Brian']] │ +└───────────────────────────────────────────────┘ +``` + +Sonuçları düşünün. + +`Jonh` çok genç olduğu için numunenin dışında. Diğer insanlar belirtilen yaş aralıklarına göre dağıtılır. + +Şimdi toplam insan sayısını ve ortalama ücretlerini belirtilen yaş aralıklarında sayalım. + +``` sql +SELECT + countResample(30, 75, 30)(name, age) AS amount, + avgResample(30, 75, 30)(wage, age) AS avg_wage +FROM people +``` + +``` text +┌─amount─┬─avg_wage──────────────────┐ +│ [3,2] │ [11.5,12.949999809265137] │ +└────────┴───────────────────────────┘ +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/tr/sql-reference/aggregate-functions/index.md b/docs/tr/sql-reference/aggregate-functions/index.md new file mode 100644 index 00000000000..22853f32f17 --- /dev/null +++ b/docs/tr/sql-reference/aggregate-functions/index.md @@ -0,0 +1,62 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "Toplama Fonksiyonlar\u0131" +toc_priority: 33 +toc_title: "Giri\u015F" +--- + +# Toplama Fonksiyonları {#aggregate-functions} + +Toplama fonksiyonları [normal](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) veritabanı uzmanları tarafından beklendiği gibi. + +ClickHouse da destekler: + +- [Parametrik agrega fonksiyonları](parametric-functions.md#aggregate_functions_parametric), sütunlara ek olarak diğer parametreleri kabul eder. +- [Birleştiriciler](combinators.md#aggregate_functions_combinators) toplama işlevlerinin davranışını değiştiren. + +## NULL işleme {#null-processing} + +Toplama sırasında, tüm `NULL`s atlanır. + +**Örnekler:** + +Bu tabloyu düşünün: + +``` text +┌─x─┬────y─┐ +│ 1 │ 2 │ +│ 2 │ ᴺᵁᴸᴸ │ +│ 3 │ 2 │ +│ 3 │ 3 │ +│ 3 │ ᴺᵁᴸᴸ │ +└───┴──────┘ +``` + +Diyelim ki değerleri toplamanız gerekiyor `y` sütun: + +``` sql +SELECT sum(y) FROM t_null_big +``` + + ┌─sum(y)─┐ + │ 7 │ + └────────┘ + +Bu `sum` fonksiyon yorumlar `NULL` olarak `0`. Özellikle, bu, işlevin tüm değerlerin bulunduğu bir seçimin girişini aldığı anlamına gelir `NULL`, sonra sonuç olacak `0`, değil `NULL`. + +Şimdi kullanabilirsiniz `groupArray` bir dizi oluşturmak için işlev `y` sütun: + +``` sql +SELECT groupArray(y) FROM t_null_big +``` + +``` text +┌─groupArray(y)─┐ +│ [2,2,3] │ +└───────────────┘ +``` + +`groupArray` içermez `NULL` elde edilen dizi. + +[Orijinal makale](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/tr/sql-reference/aggregate-functions/parametric-functions.md b/docs/tr/sql-reference/aggregate-functions/parametric-functions.md new file mode 100644 index 00000000000..27c359c807c --- /dev/null +++ b/docs/tr/sql-reference/aggregate-functions/parametric-functions.md @@ -0,0 +1,499 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: Parametrik +--- + +# Parametrik Agrega Fonksiyonları {#aggregate_functions_parametric} + +Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. + +## çubuk {#histogram} + +Uyarlanabilir bir histogram hesaplar. Kesin sonuçları garanti etmez. + +``` sql +histogram(number_of_bins)(values) +``` + +İşlevleri kullanır [Bir Akış Paralel Karar Ağacı Algoritması](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). Histogram kutularının sınırları, yeni veriler bir işleve girdiğinde ayarlanır. Ortak durumda, kutu genişlikleri eşit değildir. + +**Parametre** + +`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. +`values` — [İfade](../syntax.md#syntax-expressions) giriş değerleri ile sonuçlanır. + +**Döndürülen değerler** + +- [Dizi](../../sql-reference/data-types/array.md) -den [Demetler](../../sql-reference/data-types/tuple.md) aşağıdaki format oftan: + + ``` + [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] + ``` + + - `lower` — Lower bound of the bin. + - `upper` — Upper bound of the bin. + - `height` — Calculated height of the bin. + +**Örnek** + +``` sql +SELECT histogram(5)(number + 1) +FROM ( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ +│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +Bir histogram ile görselleştirebilirsiniz [bar](../../sql-reference/functions/other-functions.md#function-bar) fonksiyon, örneğin: + +``` sql +WITH histogram(5)(rand() % 100) AS hist +SELECT + arrayJoin(hist).3 AS height, + bar(height, 0, 6, 5) AS bar +FROM +( + SELECT * + FROM system.numbers + LIMIT 20 +) +``` + +``` text +┌─height─┬─bar───┐ +│ 2.125 │ █▋ │ +│ 3.25 │ ██▌ │ +│ 5.625 │ ████▏ │ +│ 5.625 │ ████▏ │ +│ 3.375 │ ██▌ │ +└────────┴───────┘ +``` + +Bu durumda, histogram kutusu kenarlıklarını bilmediğinizi unutmamalısınız. + +## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} + +Dizinin desenle eşleşen bir olay zinciri içerip içermediğini denetler. + +``` sql +sequenceMatch(pattern)(timestamp, cond1, cond2, ...) +``` + +!!! warning "Uyarıcı" + Aynı saniyede meydana gelen olaylar sonucu etkileyen tanımsız bir sırada sırayla yatıyordu. + +**Parametre** + +- `pattern` — Pattern string. See [Desen sözdizimi](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` ve `DateTime`. Ayrıca desteklenen herhangi birini kullanabilirsiniz [Uİnt](../../sql-reference/data-types/int-uint.md) veri türleri. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. En fazla 32 koşul argümanını iletebilirsiniz. İşlev yalnızca bu koşullarda açıklanan olayları dikkate alır. Sıra, bir koşulda açıklanmayan veriler içeriyorsa, işlev bunları atlar. + +**Döndürülen değerler** + +- 1, Eğer desen eşleşti. +- Desen eşleşmezse 0. + +Tür: `UInt8`. + + +**Desen sözdizimi** + +- `(?N)` — Matches the condition argument at position `N`. Şartlar numaralandırılmıştır `[1, 32]` Aralık. Mesela, `(?1)` argü theman thela eşleş their `cond1` parametre. + +- `.*` — Matches any number of events. You don't need conditional arguments to match this element of the pattern. + +- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` birbirinden 1800 saniyeden fazla meydana gelen olayları eşleşir. Bu olaylar arasında herhangi bir olayın keyfi bir sayısı olabilir. Kullanabilirsiniz `>=`, `>`, `<`, `<=` operatörler. + +**Örnekler** + +Verileri göz önünde bulundurun `t` Tablo: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +└──────┴────────┘ +``` + +Sorguyu gerçekleştir: + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 1 │ +└───────────────────────────────────────────────────────────────────────┘ +``` + +İşlev, 2 numarasının 1 numarayı takip ettiği olay zincirini buldu. Sayı bir olay olarak tanımlanmadığı için aralarında 3 sayısını atladı. Örnekte verilen olay zincirini ararken bu numarayı dikkate almak istiyorsak, bunun için bir koşul oluşturmalıyız. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ +│ 0 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +Bu durumda, işlev desenle eşleşen olay zincirini bulamadı, çünkü 3 numaralı olay 1 ile 2 arasında gerçekleşti. Aynı durumda 4 numaralı koşulu kontrol edersek, sıra desenle eşleşir. + +``` sql +SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t +``` + +``` text +┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ +│ 1 │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [sequenceCount](#function-sequencecount) + +## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} + +Desenle eşleşen olay zincirlerinin sayısını sayar. İşlev, çakışmayan olay zincirlerini arar. Geçerli zincir eşleştirildikten sonra bir sonraki zinciri aramaya başlar. + +!!! warning "Uyarıcı" + Aynı saniyede meydana gelen olaylar sonucu etkileyen tanımsız bir sırada sırayla yatıyordu. + +``` sql +sequenceCount(pattern)(timestamp, cond1, cond2, ...) +``` + +**Parametre** + +- `pattern` — Pattern string. See [Desen sözdizimi](#sequence-function-pattern-syntax). + +- `timestamp` — Column considered to contain time data. Typical data types are `Date` ve `DateTime`. Ayrıca desteklenen herhangi birini kullanabilirsiniz [Uİnt](../../sql-reference/data-types/int-uint.md) veri türleri. + +- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. En fazla 32 koşul argümanını iletebilirsiniz. İşlev yalnızca bu koşullarda açıklanan olayları dikkate alır. Sıra, bir koşulda açıklanmayan veriler içeriyorsa, işlev bunları atlar. + +**Döndürülen değerler** + +- Eşleşen çakışmayan olay zincirlerinin sayısı. + +Tür: `UInt64`. + +**Örnek** + +Verileri göz önünde bulundurun `t` Tablo: + +``` text +┌─time─┬─number─┐ +│ 1 │ 1 │ +│ 2 │ 3 │ +│ 3 │ 2 │ +│ 4 │ 1 │ +│ 5 │ 3 │ +│ 6 │ 2 │ +└──────┴────────┘ +``` + +2 numara aralarında diğer sayıların herhangi bir miktarda 1 numaradan sonra meydana kaç kez Sayın: + +``` sql +SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t +``` + +``` text +┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ +│ 2 │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [sequenceMatch](#function-sequencematch) + +## windowFunnel {#windowfunnel} + +Kayan bir zaman penceresinde olay zincirlerini arar ve zincirden meydana gelen en fazla olay sayısını hesaplar. + +Fonksiyon algoritmaya göre çalışır: + +- İşlev, zincirdeki ilk koşulu tetikleyen ve olay sayacını 1'e ayarlayan verileri arar. Sürgülü pencerenin başladığı an budur. + +- Zincirdeki olaylar pencerede sırayla gerçekleşirse, sayaç artırılır. Olayların sırası bozulursa, sayaç artırılmaz. + +- Verilerin çeşitli tamamlanma noktalarında birden çok olay zinciri varsa, işlev yalnızca en uzun zincirin boyutunu çıkarır. + +**Sözdizimi** + +``` sql +windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) +``` + +**Parametre** + +- `window` — Length of the sliding window in seconds. +- `mode` - Bu isteğe bağlı bir argüman. + - `'strict'` - Zaman `'strict'` ayarlanırsa, windowFunnel () yalnızca benzersiz değerler için koşullar uygular. +- `timestamp` — Name of the column containing the timestamp. Data types supported: [Tarihli](../../sql-reference/data-types/date.md), [DateTime](../../sql-reference/data-types/datetime.md#data_type-datetime) ve diğer imzasız tamsayı türleri (timestamp'ın `UInt64` yazın, değeri 2^63 - 1 olan Int64 maksimum değerini aşamaz). +- `cond` — Conditions or data describing the chain of events. [Uİnt8](../../sql-reference/data-types/int-uint.md). + +**Döndürülen değer** + +Sürgülü zaman penceresi içindeki zincirden ardışık tetiklenen koşulların maksimum sayısı. +Seçimdeki tüm zincirler analiz edilir. + +Tür: `Integer`. + +**Örnek** + +Kullanıcının bir telefon seçmesi ve çevrimiçi mağazada iki kez satın alması için belirli bir süre yeterli olup olmadığını belirleyin. + +Aşağıdaki olaylar zincirini ayarlayın: + +1. Mağaz theadaki Hesabına giriş yapan kullanıcı (`eventID = 1003`). +2. Kullanıcı bir telefon arar (`eventID = 1007, product = 'phone'`). +3. Kullanıcı sipariş verdi (`eventID = 1009`). +4. Kullanıcı tekrar sipariş yaptı (`eventID = 1010`). + +Giriş tablosu: + +``` text +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ +│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ +└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ +``` + +Kullanıcının ne kadar uzakta olduğunu öğrenin `user_id` 2019 yılının Ocak-Şubat aylarında bir dönemde zincirden geçebilir. + +Sorgu: + +``` sql +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level + FROM trend + WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC +``` + +Sonuç: + +``` text +┌─level─┬─c─┐ +│ 4 │ 1 │ +└───────┴───┘ +``` + +## saklama {#retention} + +İşlev, bağımsız değişken olarak 1'den 32'ye kadar bir dizi koşul türünü alır `UInt8` bu, etkinlik için belirli bir koşulun karşılanıp karşılanmadığını gösterir. +Herhangi bir koşul bir argüman olarak belirtilebilir (aşağıdaki gibi [WHERE](../../sql-reference/statements/select/where.md#select-where)). + +İlk hariç, koşullar çiftler halinde geçerlidir: birinci ve ikinci doğruysa, ikincinin sonucu, birinci ve fird doğruysa, üçüncüsü doğru olacaktır. + +**Sözdizimi** + +``` sql +retention(cond1, cond2, ..., cond32); +``` + +**Parametre** + +- `cond` — an expression that returns a `UInt8` sonuç (1 veya 0). + +**Döndürülen değer** + +1 veya 0 dizisi. + +- 1 — condition was met for the event. +- 0 — condition wasn't met for the event. + +Tür: `UInt8`. + +**Örnek** + +Hesaplamanın bir örneğini düşünelim `retention` site trafiğini belirlemek için işlev. + +**1.** Сreate a table to illustrate an example. + +``` sql +CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; + +INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); +INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); +INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); +``` + +Giriş tablosu: + +Sorgu: + +``` sql +SELECT * FROM retention_test +``` + +Sonuç: + +``` text +┌───────date─┬─uid─┐ +│ 2020-01-01 │ 0 │ +│ 2020-01-01 │ 1 │ +│ 2020-01-01 │ 2 │ +│ 2020-01-01 │ 3 │ +│ 2020-01-01 │ 4 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-02 │ 0 │ +│ 2020-01-02 │ 1 │ +│ 2020-01-02 │ 2 │ +│ 2020-01-02 │ 3 │ +│ 2020-01-02 │ 4 │ +│ 2020-01-02 │ 5 │ +│ 2020-01-02 │ 6 │ +│ 2020-01-02 │ 7 │ +│ 2020-01-02 │ 8 │ +│ 2020-01-02 │ 9 │ +└────────────┴─────┘ +┌───────date─┬─uid─┐ +│ 2020-01-03 │ 0 │ +│ 2020-01-03 │ 1 │ +│ 2020-01-03 │ 2 │ +│ 2020-01-03 │ 3 │ +│ 2020-01-03 │ 4 │ +│ 2020-01-03 │ 5 │ +│ 2020-01-03 │ 6 │ +│ 2020-01-03 │ 7 │ +│ 2020-01-03 │ 8 │ +│ 2020-01-03 │ 9 │ +│ 2020-01-03 │ 10 │ +│ 2020-01-03 │ 11 │ +│ 2020-01-03 │ 12 │ +│ 2020-01-03 │ 13 │ +│ 2020-01-03 │ 14 │ +└────────────┴─────┘ +``` + +**2.** Kullanıcıları benzersiz kimliğe göre grupla `uid` kullanarak `retention` İşlev. + +Sorgu: + +``` sql +SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r +FROM retention_test +WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') +GROUP BY uid +ORDER BY uid ASC +``` + +Sonuç: + +``` text +┌─uid─┬─r───────┐ +│ 0 │ [1,1,1] │ +│ 1 │ [1,1,1] │ +│ 2 │ [1,1,1] │ +│ 3 │ [1,1,1] │ +│ 4 │ [1,1,1] │ +│ 5 │ [0,0,0] │ +│ 6 │ [0,0,0] │ +│ 7 │ [0,0,0] │ +│ 8 │ [0,0,0] │ +│ 9 │ [0,0,0] │ +│ 10 │ [0,0,0] │ +│ 11 │ [0,0,0] │ +│ 12 │ [0,0,0] │ +│ 13 │ [0,0,0] │ +│ 14 │ [0,0,0] │ +└─────┴─────────┘ +``` + +**3.** Günde toplam site ziyaret sayısını hesaplayın. + +Sorgu: + +``` sql +SELECT + sum(r[1]) AS r1, + sum(r[2]) AS r2, + sum(r[3]) AS r3 +FROM +( + SELECT + uid, + retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r + FROM retention_test + WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') + GROUP BY uid +) +``` + +Sonuç: + +``` text +┌─r1─┬─r2─┬─r3─┐ +│ 5 │ 5 │ 5 │ +└────┴────┴────┘ +``` + +Nerede: + +- `r1`- 2020-01-01 sırasında siteyi ziyaret eden tekil ziyaretçi sayısı ( `cond1` koşul). +- `r2`- 2020-01-01 ve 2020-01-02 arasında belirli bir süre boyunca siteyi ziyaret eden tekil ziyaretçi sayısı (`cond1` ve `cond2` şartlar). +- `r3`- 2020-01-01 ve 2020-01-03 arasında belirli bir süre boyunca siteyi ziyaret eden tekil ziyaretçi sayısı (`cond1` ve `cond3` şartlar). + +## uniqUpTo(N) (x) {#uniquptonx} + +Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. + +Küçük Ns ile kullanım için tavsiye, kadar 10. N'nin maksimum değeri 100'dür. + +Bir toplama işlevinin durumu için, 1 + n \* bir bayt değerinin boyutuna eşit bellek miktarını kullanır. +Dizeler için, 8 baytlık kriptografik olmayan bir karma saklar. Yani, hesaplama dizeler için yaklaşık olarak hesaplanır. + +İşlev ayrıca birkaç argüman için de çalışır. + +Büyük bir N değeri kullanıldığında ve benzersiz değerlerin sayısı n'den biraz daha az olduğu durumlar dışında mümkün olduğunca hızlı çalışır. + +Kullanım örneği: + +``` text +Problem: Generate a report that shows only keywords that produced at least 5 unique users. +Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) + +## sumMapFiltered (keys\_to\_keep) (anahtarlar, değerler) {#summapfilteredkeys-to-keepkeys-values} + +Aynı davranış [sumMap](reference.md#agg_functions-summap) dışında bir dizi anahtar parametre olarak geçirilir. Bu, özellikle yüksek bir Anahtarlık ile çalışırken yararlı olabilir. diff --git a/docs/tr/sql-reference/aggregate-functions/reference.md b/docs/tr/sql-reference/aggregate-functions/reference.md new file mode 100644 index 00000000000..9865fa914ed --- /dev/null +++ b/docs/tr/sql-reference/aggregate-functions/reference.md @@ -0,0 +1,1977 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: "Ba\u015Fvurma" +--- + +# Toplama Fonksiyonu Referansı {#aggregate-functions-reference} + +## sayma {#agg_function-count} + +Satır veya NOT-NULL değerleri sayar. + +ClickHouse için aşağıdaki sözdizimleri destekler `count`: +- `count(expr)` veya `COUNT(DISTINCT expr)`. +- `count()` veya `COUNT(*)`. Bu `count()` sözdizimi ClickHouse özeldir. + +**Parametre** + +Fonksiyon alabilir: + +- Sıfır parametreler. +- Bir [ifade](../syntax.md#syntax-expressions). + +**Döndürülen değer** + +- Fonksiyon parametreleri olmadan çağrılırsa, satır sayısını sayar. +- Eğer... [ifade](../syntax.md#syntax-expressions) geçirilir, daha sonra işlev bu ifadenin kaç kez NOT null döndürdüğünü sayar. İfad aede bir [Nullable](../../sql-reference/data-types/nullable.md)- type değeri, sonra sonucu `count` kalır değil `Nullable`. İfade döndürülürse işlev 0 döndürür `NULL` tüm satırlar için. + +Her iki durumda da döndürülen değerin türü [Uİnt64](../../sql-reference/data-types/int-uint.md). + +**Ayrıntı** + +ClickHouse destekler `COUNT(DISTINCT ...)` sözdizimi. Bu yapının davranışı Aşağıdakilere bağlıdır [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation) ayar. Aşağıdakilerden hang theisini tanımlar [uniq\*](#agg_function-uniq) fonksiyonlar işlemi gerçekleştirmek için kullanılır. Varsayılan değer [uniqExact](#agg_function-uniqexact) İşlev. + +Bu `SELECT count() FROM table` tablodaki girdi sayısı ayrı olarak depolanmadığı için sorgu en iyi duruma getirilmez. Tablodan küçük bir sütun seçer ve içindeki değerlerin sayısını sayar. + +**Örnekler** + +Örnek 1: + +``` sql +SELECT count() FROM t +``` + +``` text +┌─count()─┐ +│ 5 │ +└─────────┘ +``` + +Örnek 2: + +``` sql +SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' +``` + +``` text +┌─name──────────────────────────┬─value─────┐ +│ count_distinct_implementation │ uniqExact │ +└───────────────────────────────┴───────────┘ +``` + +``` sql +SELECT count(DISTINCT num) FROM t +``` + +``` text +┌─uniqExact(num)─┐ +│ 3 │ +└────────────────┘ +``` + +Bu örnek gösteriyor ki `count(DISTINCT num)` tarafından gerçekleştirilir `uniqExact` fonksiyonu göre `count_distinct_implementation` ayar değeri. + +## herhangi(x) {#agg_function-any} + +İlk karşılaşılan değeri seçer. +Sorgu herhangi bir sırada ve hatta her seferinde farklı bir sırada çalıştırılabilir, bu nedenle bu işlevin sonucu belirsizdir. +Belirli bir sonuç elde etmek için ‘min’ veya ‘max’ fonksiyon yerine ‘any’. + +Bazı durumlarda, yürütme sırasına güvenebilirsiniz. Bu, select ORDER BY kullanan bir alt sorgudan geldiğinde durumlar için geçerlidir. + +Ne zaman bir `SELECT` sorgu vardır `GROUP BY` yan tümce veya en az bir toplama işlevi, ClickHouse (Mysql'in aksine), tüm ifadelerin `SELECT`, `HAVING`, ve `ORDER BY` anahtar functionslardan veya toplama işlev .lerinden hesaplan .malıdır. Başka bir deyişle, tablodan seçilen her sütun, anahtarlarda veya toplama işlevlerinde kullanılmalıdır. Mysql'de olduğu gibi davranış elde etmek için, diğer sütunları `any` toplama işlevi. + +## anyHeavy (x) {#anyheavyx} + +Kullanarak sık oluşan bir değer seçer [ağır vurucular](http://www.cs.umd.edu/~samir/498/karp.pdf) algoritma. Sorgunun yürütme iş parçacığı her durumda yarısından fazlasını oluşan bir değer varsa, bu değer döndürülür. Normalde, sonuç belirsizdir. + +``` sql +anyHeavy(column) +``` + +**Değişkenler** + +- `column` – The column name. + +**Örnek** + +Tak thee the [OnTime](../../getting-started/example-datasets/ontime.md) veri kümesi ve herhangi bir sık oluşan değeri seçin `AirlineID` sütun. + +``` sql +SELECT anyHeavy(AirlineID) AS res +FROM ontime +``` + +``` text +┌───res─┐ +│ 19690 │ +└───────┘ +``` + +## anyLast(x) {#anylastx} + +Karşılaşılan son değeri seçer. +Sonuç için olduğu kadar belirsiz `any` İşlev. + +## groupBitAnd {#groupbitand} + +Bitwise uygular `AND` sayı serisi için. + +``` sql +groupBitAnd(expr) +``` + +**Parametre** + +`expr` – An expression that results in `UInt*` tür. + +**Dönüş değeri** + +Bu değer `UInt*` tür. + +**Örnek** + +Test verileri: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Sorgu: + +``` sql +SELECT groupBitAnd(num) FROM t +``` + +Nerede `num` test verileri ile sütundur. + +Sonuç: + +``` text +binary decimal +00000100 = 4 +``` + +## groupBitOr {#groupbitor} + +Bitwise uygular `OR` sayı serisi için. + +``` sql +groupBitOr(expr) +``` + +**Parametre** + +`expr` – An expression that results in `UInt*` tür. + +**Dönüş değeri** + +Bu değer `UInt*` tür. + +**Örnek** + +Test verileri: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Sorgu: + +``` sql +SELECT groupBitOr(num) FROM t +``` + +Nerede `num` test verileri ile sütundur. + +Sonuç: + +``` text +binary decimal +01111101 = 125 +``` + +## groupBitXor {#groupbitxor} + +Bitwise uygular `XOR` sayı serisi için. + +``` sql +groupBitXor(expr) +``` + +**Parametre** + +`expr` – An expression that results in `UInt*` tür. + +**Dönüş değeri** + +Bu değer `UInt*` tür. + +**Örnek** + +Test verileri: + +``` text +binary decimal +00101100 = 44 +00011100 = 28 +00001101 = 13 +01010101 = 85 +``` + +Sorgu: + +``` sql +SELECT groupBitXor(num) FROM t +``` + +Nerede `num` test verileri ile sütundur. + +Sonuç: + +``` text +binary decimal +01101000 = 104 +``` + +## groupBitmap {#groupbitmap} + +İşaretsiz tamsayı sütun, Uınt64 tür iade önem, gelen bit eşlem veya Toplama hesaplamaları suffix ekleme -Devlet, sonra iade [bitmap nesnesi](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmap(expr) +``` + +**Parametre** + +`expr` – An expression that results in `UInt*` tür. + +**Dönüş değeri** + +Bu değer `UInt64` tür. + +**Örnek** + +Test verileri: + +``` text +UserID +1 +1 +2 +3 +``` + +Sorgu: + +``` sql +SELECT groupBitmap(UserID) as num FROM t +``` + +Sonuç: + +``` text +num +3 +``` + +## min (x) {#agg_function-min} + +Minimum hesaplar. + +## max (x) {#agg_function-max} + +Maksimum hesaplar. + +## argMin (arg, val) {#agg-function-argmin} + +Hesaplar ‘arg’ minimum değer ‘val’ değer. Birkaç farklı değer varsa ‘arg’ minimum değerler için ‘val’, karşılaşılan bu değerlerin ilki çıktıdır. + +**Örnek:** + +``` text +┌─user─────┬─salary─┐ +│ director │ 5000 │ +│ manager │ 3000 │ +│ worker │ 1000 │ +└──────────┴────────┘ +``` + +``` sql +SELECT argMin(user, salary) FROM salary +``` + +``` text +┌─argMin(user, salary)─┐ +│ worker │ +└──────────────────────┘ +``` + +## argMax (arg, val) {#agg-function-argmax} + +Hesaplar ‘arg’ maksimum değer ‘val’ değer. Birkaç farklı değer varsa ‘arg’ maksimum değerler için ‘val’, karşılaşılan bu değerlerin ilki çıktıdır. + +## s (um (x) {#agg_function-sum} + +Toplamı hesaplar. +Sadece sayılar için çalışır. + +## sumWithOverflow(x) {#sumwithoverflowx} + +Giriş parametreleri için olduğu gibi sonuç için aynı veri türünü kullanarak sayıların toplamını hesaplar. Toplam bu veri türü için en büyük değeri aşarsa, işlev bir hata döndürür. + +Sadece sayılar için çalışır. + +## sumMap (anahtar, değer), sumMap(Tuple (anahtar, değer)) {#agg_functions-summap} + +Toplam thelar ‘value’ belirtilen tuş accordinglara göre dizi ‘key’ dizi. +Anahtarları ve değerleri diziler dizi geçen anahtarları ve değerleri iki dizi geçen synonymical var. +Eleman sayısı ‘key’ ve ‘value’ toplam her satır için aynı olmalıdır. +Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. + +Örnek: + +``` sql +CREATE TABLE sum_map( + date Date, + timeslot DateTime, + statusMap Nested( + status UInt16, + requests UInt64 + ), + statusMapTuple Tuple(Array(Int32), Array(Int32)) +) ENGINE = Log; +INSERT INTO sum_map VALUES + ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10], ([1, 2, 3], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10], ([3, 4, 5], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10], ([4, 5, 6], [10, 10, 10])), + ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10])); + +SELECT + timeslot, + sumMap(statusMap.status, statusMap.requests), + sumMap(statusMapTuple) +FROM sum_map +GROUP BY timeslot +``` + +``` text +┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┬─sumMap(statusMapTuple)─────────┐ +│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ ([1,2,3,4,5],[10,10,20,10,10]) │ +│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ ([4,5,6,7,8],[10,10,20,10,10]) │ +└─────────────────────┴──────────────────────────────────────────────┴────────────────────────────────┘ +``` + +## skewPop {#skewpop} + +Hesaplar [çarpıklık](https://en.wikipedia.org/wiki/Skewness) bir sıra. + +``` sql +skewPop(expr) +``` + +**Parametre** + +`expr` — [İfade](../syntax.md#syntax-expressions) bir numara döndürüyor. + +**Döndürülen değer** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Örnek** + +``` sql +SELECT skewPop(value) FROM series_with_value_column +``` + +## skewSamp {#skewsamp} + +Hesaplar [örnek çarpıklık](https://en.wikipedia.org/wiki/Skewness) bir sıra. + +Bir rassal değişkenin çarpıklığının tarafsız bir tahminini temsil eder. + +``` sql +skewSamp(expr) +``` + +**Parametre** + +`expr` — [İfade](../syntax.md#syntax-expressions) bir numara döndürüyor. + +**Döndürülen değer** + +The skewness of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). Eğer `n <= 1` (`n` örnek boyutudur), daha sonra işlev döner `nan`. + +**Örnek** + +``` sql +SELECT skewSamp(value) FROM series_with_value_column +``` + +## kurtPop {#kurtpop} + +Hesaplar [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) bir sıra. + +``` sql +kurtPop(expr) +``` + +**Parametre** + +`expr` — [İfade](../syntax.md#syntax-expressions) bir numara döndürüyor. + +**Döndürülen değer** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md) + +**Örnek** + +``` sql +SELECT kurtPop(value) FROM series_with_value_column +``` + +## kurtSamp {#kurtsamp} + +Hesaplar [örnek kurtoz](https://en.wikipedia.org/wiki/Kurtosis) bir sıra. + +Eğer geçen değerleri örnek oluşturur, eğer bir rassal değişken kurtosis tarafsız bir tahmini temsil eder. + +``` sql +kurtSamp(expr) +``` + +**Parametre** + +`expr` — [İfade](../syntax.md#syntax-expressions) bir numara döndürüyor. + +**Döndürülen değer** + +The kurtosis of the given distribution. Type — [Float64](../../sql-reference/data-types/float.md). Eğer `n <= 1` (`n` örnek bir boyutudur), daha sonra işlev döner `nan`. + +**Örnek** + +``` sql +SELECT kurtSamp(value) FROM series_with_value_column +``` + +## timeSeriesGroupSum(uıd, zaman damgası, değer) {#agg-function-timeseriesgroupsum} + +`timeSeriesGroupSum` örnek zaman damgası değil hizalama farklı zaman serileri toplayabilir. +İki örnek zaman damgası arasında doğrusal enterpolasyon kullanacak ve daha sonra zaman serilerini birlikte toplayacaktır. + +- `uid` zaman serisi benzersiz kimliği mi, `UInt64`. +- `timestamp` milisaniye veya mikrosaniye desteklemek için Int64 türüdür. +- `value` metr .iktir. + +İşlev, tuples dizisini döndürür `(timestamp, aggregated_value)` çiftliler. + +Bu işlevi kullanmadan önce emin olun `timestamp` artan düzende. + +Örnek: + +``` text +┌─uid─┬─timestamp─┬─value─┐ +│ 1 │ 2 │ 0.2 │ +│ 1 │ 7 │ 0.7 │ +│ 1 │ 12 │ 1.2 │ +│ 1 │ 17 │ 1.7 │ +│ 1 │ 25 │ 2.5 │ +│ 2 │ 3 │ 0.6 │ +│ 2 │ 8 │ 1.6 │ +│ 2 │ 12 │ 2.4 │ +│ 2 │ 18 │ 3.6 │ +│ 2 │ 24 │ 4.8 │ +└─────┴───────────┴───────┘ +``` + +``` sql +CREATE TABLE time_series( + uid UInt64, + timestamp Int64, + value Float64 +) ENGINE = Memory; +INSERT INTO time_series VALUES + (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), + (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); + +SELECT timeSeriesGroupSum(uid, timestamp, value) +FROM ( + SELECT * FROM time_series order by timestamp ASC +); +``` + +Ve sonuç olacak: + +``` text +[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] +``` + +## timeSeriesGroupRateSum(uıd, ts, val) {#agg-function-timeseriesgroupratesum} + +Benzer şekilde `timeSeriesGroupSum`, `timeSeriesGroupRateSum` zaman serilerinin oranını hesaplar ve daha sonra toplam oranları birlikte hesaplar. +Ayrıca, bu işlevi kullanmadan önce zaman damgası yükseliş sırasına göre olmalıdır. + +Bu fonksiyon dataun ver theiye uygulanması `timeSeriesGroupSum` örnek, aşağıdaki sonucu alırsınız: + +``` text +[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] +``` + +## avg (x) {#agg_function-avg} + +Ortalama hesaplar. +Sadece sayılar için çalışır. +Sonuç Her zaman Float64. + +## avgWeighted {#avgweighted} + +Hesaplar [ağırlıklı aritmetik ortalama](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean). + +**Sözdizimi** + +``` sql +avgWeighted(x, weight) +``` + +**Parametre** + +- `x` — Values. [Tamsayı](../data-types/int-uint.md) veya [kayan nokta](../data-types/float.md). +- `weight` — Weights of the values. [Tamsayı](../data-types/int-uint.md) veya [kayan nokta](../data-types/float.md). + +Türü `x` ve `weight` aynı olmalıdır. + +**Döndürülen değer** + +- Ağırlıklı ortalama. +- `NaN`. Tüm ağırlıklar 0'a eşitse. + +Tür: [Float64](../data-types/float.md). + +**Örnek** + +Sorgu: + +``` sql +SELECT avgWeighted(x, w) +FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) +``` + +Sonuç: + +``` text +┌─avgWeighted(x, weight)─┐ +│ 8 │ +└────────────────────────┘ +``` + +## uniq {#agg_function-uniq} + +Bağımsız değişken farklı değerlerin yaklaşık sayısını hesaplar. + +``` sql +uniq(x[, ...]) +``` + +**Parametre** + +Fonksiyon değişken sayıda parametre alır. Parametreler olabilir `Tuple`, `Array`, `Date`, `DateTime`, `String` veya sayısal türleri. + +**Döndürülen değer** + +- A [Uİnt64](../../sql-reference/data-types/int-uint.md)- tip numarası. + +**Uygulama Detayları** + +İşlev: + +- Toplamdaki tüm parametreler için bir karma hesaplar, daha sonra hesaplamalarda kullanır. + +- Bir adaptif örnekleme algoritması kullanır. Hesaplama durumu için işlev, 65536'ya kadar öğe karma değerlerinin bir örneğini kullanır. + + This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. + +- Sonucu deterministically sağlar (sorgu işleme sırasına bağlı değildir). + +Bu işlevi hemen hemen tüm senaryolarda kullanmanızı öneririz. + +**Ayrıca Bakınız** + +- [uniqCombined](#agg_function-uniqcombined) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined {#agg_function-uniqcombined} + +Farklı bağımsız değişken değerlerinin yaklaşık sayısını hesaplar. + +``` sql +uniqCombined(HLL_precision)(x[, ...]) +``` + +Bu `uniqCombined` fonksiyon, farklı değerlerin sayısını hesaplamak için iyi bir seçimdir. + +**Parametre** + +Fonksiyon değişken sayıda parametre alır. Parametreler olabilir `Tuple`, `Array`, `Date`, `DateTime`, `String` veya sayısal türleri. + +`HLL_precision` hücre sayısının baz-2 logaritmasıdır. [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). İsteğe bağlı olarak işlevi kullanabilirsiniz `uniqCombined(x[, ...])`. İçin varsayılan değer `HLL_precision` etkin bir şekilde 96 KiB alan olan 17'dir (2^17 hücre, her biri 6 bit). + +**Döndürülen değer** + +- Numara [Uİnt64](../../sql-reference/data-types/int-uint.md)- tip numarası. + +**Uygulama Detayları** + +İşlev: + +- Bir karma hesaplar (64-bit karma için `String` ve 32-bit aksi halde) agregadaki tüm parametreler için, hesaplamalarda kullanır. + +- Bir hata düzeltme tablosu ile dizi, karma tablo ve HyperLogLog: üç algoritmaları bir arada kullanır. + + For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. + +- Sonucu deterministically sağlar (sorgu işleme sırasına bağlı değildir). + +!!! note "Not" + Olmayan için 32-bit karma kullandığından-`String` tipi, sonuç cardinalities önemli ölçüde daha büyük için çok yüksek hata olacak `UINT_MAX` (birkaç on milyarlarca farklı değerden sonra hata hızla artacaktır), bu durumda kullanmanız gerekir [uniqCombined64](#agg_function-uniqcombined64) + +İle karşılaştırıldığında [uniq](#agg_function-uniq) fonksiyonu, `uniqCombined`: + +- Birkaç kez daha az bellek tüketir. +- Birkaç kat daha yüksek doğrulukla hesaplar. +- Genellikle biraz daha düşük performansa sahiptir. Bazı senaryolarda, `uniqCombined` daha iyi performans gösterebilir `uniq` örneğin, ağ üzerinden çok sayıda toplama durumu ileten dağıtılmış sorgularla. + +**Ayrıca Bakınız** + +- [uniq](#agg_function-uniq) +- [uniqCombined64](#agg_function-uniqcombined64) +- [uniqHLL12](#agg_function-uniqhll12) +- [uniqExact](#agg_function-uniqexact) + +## uniqCombined64 {#agg_function-uniqcombined64} + +Aynı olarak [uniqCombined](#agg_function-uniqcombined), ancak tüm veri türleri için 64 bit karma kullanır. + +## uniqHLL12 {#agg_function-uniqhll12} + +Farklı argüman değerlerinin yaklaşık sayısını hesaplar [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) algoritma. + +``` sql +uniqHLL12(x[, ...]) +``` + +**Parametre** + +Fonksiyon değişken sayıda parametre alır. Parametreler olabilir `Tuple`, `Array`, `Date`, `DateTime`, `String` veya sayısal türleri. + +**Döndürülen değer** + +- A [Uİnt64](../../sql-reference/data-types/int-uint.md)- tip numarası. + +**Uygulama Detayları** + +İşlev: + +- Toplamdaki tüm parametreler için bir karma hesaplar, daha sonra hesaplamalarda kullanır. + +- Farklı bağımsız değişken değerlerinin sayısını yaklaştırmak için HyperLogLog algoritmasını kullanır. + + 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). + +- Belirli sonucu sağlar (sorgu işleme sırasına bağlı değildir). + +Bu işlevi kullanmanızı önermiyoruz. Çoğu durumda, kullan [uniq](#agg_function-uniq) veya [uniqCombined](#agg_function-uniqcombined) İşlev. + +**Ayrıca Bakınız** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqExact](#agg_function-uniqexact) + +## uniqExact {#agg_function-uniqexact} + +Farklı bağımsız değişken değerlerinin tam sayısını hesaplar. + +``` sql +uniqExact(x[, ...]) +``` + +Kullan... `uniqExact` kesinlikle kesin bir sonuca ihtiyacınız varsa işlev. Aksi takdirde kullanın [uniq](#agg_function-uniq) İşlev. + +Bu `uniqExact` fonksiyonu daha fazla bellek kullanır `uniq`, çünkü farklı değerlerin sayısı arttıkça devletin büyüklüğü sınırsız büyümeye sahiptir. + +**Parametre** + +Fonksiyon değişken sayıda parametre alır. Parametreler olabilir `Tuple`, `Array`, `Date`, `DateTime`, `String` veya sayısal türleri. + +**Ayrıca Bakınız** + +- [uniq](#agg_function-uniq) +- [uniqCombined](#agg_function-uniqcombined) +- [uniqHLL12](#agg_function-uniqhll12) + +## groupArray (x), groupArray (max\_size)(x) {#agg_function-grouparray} + +Bağımsız değişken değerleri dizisi oluşturur. +Değerler diziye herhangi bir (belirsiz) sırayla eklenebilir. + +İkinci versiyonu (ile `max_size` parametre), elde edilen dizinin boyutunu sınırlar `max_size` öğeler. +Mesela, `groupArray (1) (x)` eşdeğ toer equivalentdir `[any (x)]`. + +Bazı durumlarda, hala yürütme sırasına güvenebilirsiniz. Bu, aşağıdaki durumlar için geçerlidir `SELECT` kullanan bir alt sorgudan gelir `ORDER BY`. + +## grouparrayınsertat {#grouparrayinsertat} + +Belirtilen konumda diziye bir değer ekler. + +**Sözdizimi** + +``` sql +groupArrayInsertAt(default_x, size)(x, pos); +``` + +Bir sorguda aynı konuma birkaç değer eklenirse, işlev aşağıdaki şekillerde davranır: + +- Bir sorgu tek bir iş parçacığında yürütülürse, eklenen değerlerden ilki kullanılır. +- Bir sorgu birden çok iş parçacığında yürütülürse, ortaya çıkan değer, eklenen değerlerden belirsiz bir değerdir. + +**Parametre** + +- `x` — Value to be inserted. [İfade](../syntax.md#syntax-expressions) biri sonuçta [desteklenen veri türleri](../../sql-reference/data-types/index.md). +- `pos` — Position at which the specified element `x` eklen .ecektir. Dizideki dizin numaralandırma sıfırdan başlar. [Uİnt32](../../sql-reference/data-types/int-uint.md#uint-ranges). +- `default_x`— Default value for substituting in empty positions. Optional parameter. [İfade](../syntax.md#syntax-expressions) için yapılandırılmış veri türü ile sonuçlanan `x` parametre. Eğer `default_x` tanımlan ,mamıştır, [varsayılan değerler](../../sql-reference/statements/create.md#create-default-values) kullanılır. +- `size`— Length of the resulting array. Optional parameter. When using this parameter, the default value `default_x` belirt .ilmelidir. [Uİnt32](../../sql-reference/data-types/int-uint.md#uint-ranges). + +**Döndürülen değer** + +- Eklenen değerlerle dizi. + +Tür: [Dizi](../../sql-reference/data-types/array.md#data-type-array). + +**Örnek** + +Sorgu: + +``` sql +SELECT groupArrayInsertAt(toString(number), number * 2) FROM numbers(5); +``` + +Sonuç: + +``` text +┌─groupArrayInsertAt(toString(number), multiply(number, 2))─┐ +│ ['0','','1','','2','','3','','4'] │ +└───────────────────────────────────────────────────────────┘ +``` + +Sorgu: + +``` sql +SELECT groupArrayInsertAt('-')(toString(number), number * 2) FROM numbers(5); +``` + +Sonuç: + +``` text +┌─groupArrayInsertAt('-')(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2','-','3','-','4'] │ +└────────────────────────────────────────────────────────────────┘ +``` + +Sorgu: + +``` sql +SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); +``` + +Sonuç: + +``` text +┌─groupArrayInsertAt('-', 5)(toString(number), multiply(number, 2))─┐ +│ ['0','-','1','-','2'] │ +└───────────────────────────────────────────────────────────────────┘ +``` + +Elemanların tek bir konuma çok dişli yerleştirilmesi. + +Sorgu: + +``` sql +SELECT groupArrayInsertAt(number, 0) FROM numbers_mt(10) SETTINGS max_block_size = 1; +``` + +Bu sorgu sonucunda rastgele tamsayı elde edersiniz `[0,9]` Aralık. Mesela: + +``` text +┌─groupArrayInsertAt(number, 0)─┐ +│ [7] │ +└───────────────────────────────┘ +``` + +## groupArrayMovingSum {#agg_function-grouparraymovingsum} + +Giriş değerlerinin hareketli toplamını hesaplar. + +``` sql +groupArrayMovingSum(numbers_for_summing) +groupArrayMovingSum(window_size)(numbers_for_summing) +``` + +İşlev, pencere boyutunu bir parametre olarak alabilir. Belirtilmemiş bırakılırsa, işlev, sütundaki satır sayısına eşit pencere boyutunu alır. + +**Parametre** + +- `numbers_for_summing` — [İfade](../syntax.md#syntax-expressions) sayısal veri türü değeri ile sonuçlanır. +- `window_size` — Size of the calculation window. + +**Döndürülen değerler** + +- Giriş verileri ile aynı boyut ve türdeki dizi. + +**Örnek** + +Örnek tablo: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Sorgu: + +``` sql +SELECT + groupArrayMovingSum(int) AS I, + groupArrayMovingSum(float) AS F, + groupArrayMovingSum(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingSum(2)(int) AS I, + groupArrayMovingSum(2)(float) AS F, + groupArrayMovingSum(2)(dec) AS D +FROM t +``` + +``` text +┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ +│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ +└────────────┴─────────────────────────────────┴────────────────────────┘ +``` + +## groupArrayMovingAvg {#agg_function-grouparraymovingavg} + +Giriş değerlerinin hareketli ortalamasını hesaplar. + +``` sql +groupArrayMovingAvg(numbers_for_summing) +groupArrayMovingAvg(window_size)(numbers_for_summing) +``` + +İşlev, pencere boyutunu bir parametre olarak alabilir. Belirtilmemiş bırakılırsa, işlev, sütundaki satır sayısına eşit pencere boyutunu alır. + +**Parametre** + +- `numbers_for_summing` — [İfade](../syntax.md#syntax-expressions) sayısal veri türü değeri ile sonuçlanır. +- `window_size` — Size of the calculation window. + +**Döndürülen değerler** + +- Giriş verileri ile aynı boyut ve türdeki dizi. + +İşlev kullanır [sıfıra doğru yuvarlama](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). Sonuç veri türü için önemsiz ondalık basamaklar keser. + +**Örnek** + +Örnek tablo `b`: + +``` sql +CREATE TABLE t +( + `int` UInt8, + `float` Float32, + `dec` Decimal32(2) +) +ENGINE = TinyLog +``` + +``` text +┌─int─┬─float─┬──dec─┐ +│ 1 │ 1.1 │ 1.10 │ +│ 2 │ 2.2 │ 2.20 │ +│ 4 │ 4.4 │ 4.40 │ +│ 7 │ 7.77 │ 7.77 │ +└─────┴───────┴──────┘ +``` + +Sorgu: + +``` sql +SELECT + groupArrayMovingAvg(int) AS I, + groupArrayMovingAvg(float) AS F, + groupArrayMovingAvg(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ +│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ +└───────────┴─────────────────────────────────────┴───────────────────────┘ +``` + +``` sql +SELECT + groupArrayMovingAvg(2)(int) AS I, + groupArrayMovingAvg(2)(float) AS F, + groupArrayMovingAvg(2)(dec) AS D +FROM t +``` + +``` text +┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ +│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ +└───────────┴──────────────────────────────────┴───────────────────────┘ +``` + +## groupUniqArray (x), groupUniqArray (max\_size)(x) {#groupuniqarrayx-groupuniqarraymax-sizex} + +Farklı bağımsız değişken değerlerinden bir dizi oluşturur. Bellek tüketimi için aynıdır `uniqExact` İşlev. + +İkinci versiyonu (ile `max_size` parametre), elde edilen dizinin boyutunu sınırlar `max_size` öğeler. +Mesela, `groupUniqArray(1)(x)` eşdeğ toer equivalentdir `[any(x)]`. + +## quantile {#quantile} + +Yaklaşık hesaplar [quantile](https://en.wikipedia.org/wiki/Quantile) sayısal veri dizisinin. + +Bu işlev geçerlidir [rezerv reservoiruar örnek samplinglemesi](https://en.wikipedia.org/wiki/Reservoir_sampling) 8192'ye kadar bir rezervuar boyutu ve örnekleme için rastgele sayı üreteci ile. Sonuç deterministik değildir. Tam bir miktar elde etmek için [quantileExact](#quantileexact) İşlev. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantile(level)(expr) +``` + +Takma ad: `median`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [veri türleri](../../sql-reference/data-types/index.md#data_types), [Tarihli](../../sql-reference/data-types/date.md) veya [DateTime](../../sql-reference/data-types/datetime.md). + +**Döndürülen değer** + +- Belirtilen seviyenin yaklaşık miktarı. + +Tür: + +- [Float64](../../sql-reference/data-types/float.md) sayısal veri türü girişi için. +- [Tarihli](../../sql-reference/data-types/date.md) giriş değerleri varsa `Date` tür. +- [DateTime](../../sql-reference/data-types/datetime.md) giriş değerleri varsa `DateTime` tür. + +**Örnek** + +Giriş tablosu: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Sorgu: + +``` sql +SELECT quantile(val) FROM t +``` + +Sonuç: + +``` text +┌─quantile(val)─┐ +│ 1.5 │ +└───────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## quantileDeterministic {#quantiledeterministic} + +Yaklaşık hesaplar [quantile](https://en.wikipedia.org/wiki/Quantile) sayısal veri dizisinin. + +Bu işlev geçerlidir [rezerv reservoiruar örnek samplinglemesi](https://en.wikipedia.org/wiki/Reservoir_sampling) 8192'ye kadar bir rezervuar boyutu ve örnekleme deterministik algoritması ile. Sonuç deterministiktir. Tam bir miktar elde etmek için [quantileExact](#quantileexact) İşlev. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileDeterministic(level)(expr, determinator) +``` + +Takma ad: `medianDeterministic`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [veri türleri](../../sql-reference/data-types/index.md#data_types), [Tarihli](../../sql-reference/data-types/date.md) veya [DateTime](../../sql-reference/data-types/datetime.md). +- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. + +**Döndürülen değer** + +- Belirtilen seviyenin yaklaşık miktarı. + +Tür: + +- [Float64](../../sql-reference/data-types/float.md) sayısal veri türü girişi için. +- [Tarihli](../../sql-reference/data-types/date.md) giriş değerleri varsa `Date` tür. +- [DateTime](../../sql-reference/data-types/datetime.md) giriş değerleri varsa `DateTime` tür. + +**Örnek** + +Giriş tablosu: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Sorgu: + +``` sql +SELECT quantileDeterministic(val, 1) FROM t +``` + +Sonuç: + +``` text +┌─quantileDeterministic(val, 1)─┐ +│ 1.5 │ +└───────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## quantileExact {#quantileexact} + +Tam olarak hesaplar [quantile](https://en.wikipedia.org/wiki/Quantile) sayısal veri dizisinin. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` bellek, nerede `n` geçirilen değerler say .ısıdır. Bununla birlikte, az sayıda değer için, işlev çok etkilidir. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileExact(level)(expr) +``` + +Takma ad: `medianExact`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [veri türleri](../../sql-reference/data-types/index.md#data_types), [Tarihli](../../sql-reference/data-types/date.md) veya [DateTime](../../sql-reference/data-types/datetime.md). + +**Döndürülen değer** + +- Belirtilen seviyenin miktarı. + +Tür: + +- [Float64](../../sql-reference/data-types/float.md) sayısal veri türü girişi için. +- [Tarihli](../../sql-reference/data-types/date.md) giriş değerleri varsa `Date` tür. +- [DateTime](../../sql-reference/data-types/datetime.md) giriş değerleri varsa `DateTime` tür. + +**Örnek** + +Sorgu: + +``` sql +SELECT quantileExact(number) FROM numbers(10) +``` + +Sonuç: + +``` text +┌─quantileExact(number)─┐ +│ 5 │ +└───────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## quantilexactweighted {#quantileexactweighted} + +Tam olarak hesaplar [quantile](https://en.wikipedia.org/wiki/Quantile) her elemanın ağırlığını dikkate alarak sayısal bir veri dizisinin. + +To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [quantileExact](#quantileexact). Bunun yerine bu işlevi kullanabilirsiniz `quantileExact` ve 1 ağırlığını belirtin. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileExactWeighted(level)(expr, weight) +``` + +Takma ad: `medianExactWeighted`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [veri türleri](../../sql-reference/data-types/index.md#data_types), [Tarihli](../../sql-reference/data-types/date.md) veya [DateTime](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. + +**Döndürülen değer** + +- Belirtilen seviyenin miktarı. + +Tür: + +- [Float64](../../sql-reference/data-types/float.md) sayısal veri türü girişi için. +- [Tarihli](../../sql-reference/data-types/date.md) giriş değerleri varsa `Date` tür. +- [DateTime](../../sql-reference/data-types/datetime.md) giriş değerleri varsa `DateTime` tür. + +**Örnek** + +Giriş tablosu: + +``` text +┌─n─┬─val─┐ +│ 0 │ 3 │ +│ 1 │ 2 │ +│ 2 │ 1 │ +│ 5 │ 4 │ +└───┴─────┘ +``` + +Sorgu: + +``` sql +SELECT quantileExactWeighted(n, val) FROM t +``` + +Sonuç: + +``` text +┌─quantileExactWeighted(n, val)─┐ +│ 1 │ +└───────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## quantileTiming {#quantiletiming} + +Belirlenen hassas hesaplar ile [quantile](https://en.wikipedia.org/wiki/Quantile) sayısal veri dizisinin. + +Sonuç deterministiktir (sorgu işleme sırasına bağlı değildir). Fonksiyon yükleme web sayfaları kez veya arka uç yanıt süreleri gibi dağılımları tanımlamak dizileri ile çalışmak için optimize edilmiştir. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileTiming(level)(expr) +``` + +Takma ad: `medianTiming`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). + +- `expr` — [İfade](../syntax.md#syntax-expressions) bir sütun değerleri üzerinde dönen bir [Yüzdürmek\*](../../sql-reference/data-types/float.md)- tip numarası. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +**Doğruluk** + +Hesaplama doğru ise: + +- Toplam değer sayısı 5670'i geçmez. +- Toplam değer sayısı 5670'i aşıyor, ancak sayfa yükleme süresi 1024 ms'den az. + +Aksi takdirde, hesaplamanın sonucu 16 MS'nin en yakın katlarına yuvarlanır. + +!!! note "Not" + Sayfa yükleme süresi nicelerini hesaplamak için, bu işlev daha etkili ve doğrudur [quantile](#quantile). + +**Döndürülen değer** + +- Belirtilen seviyenin miktarı. + +Tür: `Float32`. + +!!! note "Not" + İşlev valuese hiçbir değer geçir (ilmem (işse (kullanırken `quantileTimingIf`), [Nine](../../sql-reference/data-types/float.md#data_type-float-nan-inf) döndürülür. Bunun amacı, bu vakaları sıfır ile sonuçlanan vakalardan ayırmaktır. Görmek [ORDER BY FLA BYGE](../statements/select/order-by.md#select-order-by) sıralama ile ilgili notlar için `NaN` değerler. + +**Örnek** + +Giriş tablosu: + +``` text +┌─response_time─┐ +│ 72 │ +│ 112 │ +│ 126 │ +│ 145 │ +│ 104 │ +│ 242 │ +│ 313 │ +│ 168 │ +│ 108 │ +└───────────────┘ +``` + +Sorgu: + +``` sql +SELECT quantileTiming(response_time) FROM t +``` + +Sonuç: + +``` text +┌─quantileTiming(response_time)─┐ +│ 126 │ +└───────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## niceletimingweighted {#quantiletimingweighted} + +Belirlenen hassas hesaplar ile [quantile](https://en.wikipedia.org/wiki/Quantile) her sıra üyesi ağırlığına göre sayısal veri dizisi. + +Sonuç deterministiktir (sorgu işleme sırasına bağlı değildir). Fonksiyon yükleme web sayfaları kez veya arka uç yanıt süreleri gibi dağılımları tanımlamak dizileri ile çalışmak için optimize edilmiştir. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileTimingWeighted(level)(expr, weight) +``` + +Takma ad: `medianTimingWeighted`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). + +- `expr` — [İfade](../syntax.md#syntax-expressions) bir sütun değerleri üzerinde dönen bir [Yüzdürmek\*](../../sql-reference/data-types/float.md)- tip numarası. + + - If negative values are passed to the function, the behavior is undefined. + - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. + +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Doğruluk** + +Hesaplama doğru ise: + +- Toplam değer sayısı 5670'i geçmez. +- Toplam değer sayısı 5670'i aşıyor, ancak sayfa yükleme süresi 1024 ms'den az. + +Aksi takdirde, hesaplamanın sonucu 16 MS'nin en yakın katlarına yuvarlanır. + +!!! note "Not" + Sayfa yükleme süresi nicelerini hesaplamak için, bu işlev daha etkili ve doğrudur [quantile](#quantile). + +**Döndürülen değer** + +- Belirtilen seviyenin miktarı. + +Tür: `Float32`. + +!!! note "Not" + İşlev valuese hiçbir değer geçir (ilmem (işse (kullanırken `quantileTimingIf`), [Nine](../../sql-reference/data-types/float.md#data_type-float-nan-inf) döndürülür. Bunun amacı, bu vakaları sıfır ile sonuçlanan vakalardan ayırmaktır. Görmek [ORDER BY FLA BYGE](../statements/select/order-by.md#select-order-by) sıralama ile ilgili notlar için `NaN` değerler. + +**Örnek** + +Giriş tablosu: + +``` text +┌─response_time─┬─weight─┐ +│ 68 │ 1 │ +│ 104 │ 2 │ +│ 112 │ 3 │ +│ 126 │ 2 │ +│ 138 │ 1 │ +│ 162 │ 1 │ +└───────────────┴────────┘ +``` + +Sorgu: + +``` sql +SELECT quantileTimingWeighted(response_time, weight) FROM t +``` + +Sonuç: + +``` text +┌─quantileTimingWeighted(response_time, weight)─┐ +│ 112 │ +└───────────────────────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## quantileTDigest {#quantiletdigest} + +Yaklaşık hesaplar [quantile](https://en.wikipedia.org/wiki/Quantile) kullanarak sayısal veri diz ofisinin [t-dig -est](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algoritma. + +Maksimum hata %1'dir. Bellek tüketimi `log(n)`, nere `n` değer say isısıdır. Sonuç, sorguyu çalıştırma sırasına bağlıdır ve nondeterministic. + +Fonksiyonun performansı, performanstan daha düşüktür [quantile](#quantile) veya [quantileTiming](#quantiletiming). Durum boyutunun hassasiyete oranı açısından, bu işlev çok daha iyidir `quantile`. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileTDigest(level)(expr) +``` + +Takma ad: `medianTDigest`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [veri türleri](../../sql-reference/data-types/index.md#data_types), [Tarihli](../../sql-reference/data-types/date.md) veya [DateTime](../../sql-reference/data-types/datetime.md). + +**Döndürülen değer** + +- Belirtilen seviyenin yaklaşık miktarı. + +Tür: + +- [Float64](../../sql-reference/data-types/float.md) sayısal veri türü girişi için. +- [Tarihli](../../sql-reference/data-types/date.md) giriş değerleri varsa `Date` tür. +- [DateTime](../../sql-reference/data-types/datetime.md) giriş değerleri varsa `DateTime` tür. + +**Örnek** + +Sorgu: + +``` sql +SELECT quantileTDigest(number) FROM numbers(10) +``` + +Sonuç: + +``` text +┌─quantileTDigest(number)─┐ +│ 4.5 │ +└─────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## quantileTDigestWeighted {#quantiletdigestweighted} + +Yaklaşık hesaplar [quantile](https://en.wikipedia.org/wiki/Quantile) kullanarak sayısal veri diz ofisinin [t-dig -est](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) algoritma. İşlev, her sıra üyesinin ağırlığını dikkate alır. Maksimum hata %1'dir. Bellek tüketimi `log(n)`, nere `n` değer say isısıdır. + +Fonksiyonun performansı, performanstan daha düşüktür [quantile](#quantile) veya [quantileTiming](#quantiletiming). Durum boyutunun hassasiyete oranı açısından, bu işlev çok daha iyidir `quantile`. + +Sonuç, sorguyu çalıştırma sırasına bağlıdır ve nondeterministic. + +Çoklu kullanırken `quantile*` bir sorguda farklı düzeylerde işlevler, iç durumları birleştirilmez (diğer bir deyişle, sorgu olabilir daha az verimli çalışır). Bu durumda, kullan [quantiles](#quantiles) İşlev. + +**Sözdizimi** + +``` sql +quantileTDigest(level)(expr) +``` + +Takma ad: `medianTDigest`. + +**Parametre** + +- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` aralığında değer `[0.01, 0.99]`. Varsayılan değer: 0.5. Yanında `level=0.5` fonksiyon hesaplar [medyan](https://en.wikipedia.org/wiki/Median). +- `expr` — Expression over the column values resulting in numeric [veri türleri](../../sql-reference/data-types/index.md#data_types), [Tarihli](../../sql-reference/data-types/date.md) veya [DateTime](../../sql-reference/data-types/datetime.md). +- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. + +**Döndürülen değer** + +- Belirtilen seviyenin yaklaşık miktarı. + +Tür: + +- [Float64](../../sql-reference/data-types/float.md) sayısal veri türü girişi için. +- [Tarihli](../../sql-reference/data-types/date.md) giriş değerleri varsa `Date` tür. +- [DateTime](../../sql-reference/data-types/datetime.md) giriş değerleri varsa `DateTime` tür. + +**Örnek** + +Sorgu: + +``` sql +SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) +``` + +Sonuç: + +``` text +┌─quantileTDigestWeighted(number, 1)─┐ +│ 4.5 │ +└────────────────────────────────────┘ +``` + +**Ayrıca Bakınız** + +- [medyan](#median) +- [quantiles](#quantiles) + +## medyan {#median} + +Bu `median*` fonksiyonlar karşılık gelen takma adlardır `quantile*` işlevler. Sayısal bir veri örneğinin medyanını hesaplarlar. + +İşlevler: + +- `median` — Alias for [quantile](#quantile). +- `medianDeterministic` — Alias for [quantileDeterministic](#quantiledeterministic). +- `medianExact` — Alias for [quantileExact](#quantileexact). +- `medianExactWeighted` — Alias for [quantilexactweighted](#quantileexactweighted). +- `medianTiming` — Alias for [quantileTiming](#quantiletiming). +- `medianTimingWeighted` — Alias for [niceletimingweighted](#quantiletimingweighted). +- `medianTDigest` — Alias for [quantileTDigest](#quantiletdigest). +- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](#quantiletdigestweighted). + +**Örnek** + +Giriş tablosu: + +``` text +┌─val─┐ +│ 1 │ +│ 1 │ +│ 2 │ +│ 3 │ +└─────┘ +``` + +Sorgu: + +``` sql +SELECT medianDeterministic(val, 1) FROM t +``` + +Sonuç: + +``` text +┌─medianDeterministic(val, 1)─┐ +│ 1.5 │ +└─────────────────────────────┘ +``` + +## quantiles(level1, level2, …)(x) {#quantiles} + +Tüm quantile fonksiyonları da karşılık gelen quantile fonksiyonlarına sahiptir: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. Bu işlevler, listelenen seviyelerin tüm nicelerini tek geçişte hesaplar ve elde edilen değerlerin bir dizisini döndürür. + +## varSamp (x) {#varsampx} + +Miktarı hesaplar `Σ((x - x̅)^2) / (n - 1)`, nere `n` örneklem büyüklüğü ve `x̅`ortalama değer isidir `x`. + +Bir rassal değişkenin varyansının tarafsız bir tahminini temsil eder, eğer geçirilen değerler numunesini oluşturursa. + +Dönüşler `Float64`. Ne zaman `n <= 1`, dönüşler `+∞`. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `varSampStable` İşlev. Daha yavaş çalışır, ancak daha düşük hesaplama hatası sağlar. + +## varPop (x) {#varpopx} + +Miktarı hesaplar `Σ((x - x̅)^2) / n`, nere `n` örneklem büyüklüğü ve `x̅`ortalama değer isidir `x`. + +Başka bir deyişle, bir dizi değer için dağılım. Dönüşler `Float64`. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `varPopStable` İşlev. Daha yavaş çalışır, ancak daha düşük hesaplama hatası sağlar. + +## stddevSamp(x) {#stddevsampx} + +Sonuç kareköküne eşittir `varSamp(x)`. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `stddevSampStable` İşlev. Daha yavaş çalışır, ancak daha düşük hesaplama hatası sağlar. + +## stddevPop(x) {#stddevpopx} + +Sonuç kareköküne eşittir `varPop(x)`. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `stddevPopStable` İşlev. Daha yavaş çalışır, ancak daha düşük hesaplama hatası sağlar. + +## topK (N) (x) {#topknx} + +Belirtilen sütundaki yaklaşık en sık değerleri bir dizi döndürür. Elde edilen dizi, değerlerin yaklaşık frekansının azalan sırasına göre sıralanır (değerlerin kendileri tarafından değil). + +Uygular [Filtrelenmiş Yerden Tasarruf](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) TopK analiz etmek için algoritma, azaltmak ve birleştirmek algoritması dayalı [Paralel Alan Tasarrufu](https://arxiv.org/pdf/1401.0702.pdf). + +``` sql +topK(N)(column) +``` + +Bu işlev garantili bir sonuç sağlamaz. Bazı durumlarda, hatalar oluşabilir ve en sık kullanılan değerler olmayan sık değerler döndürebilir. + +Biz kullanmanızı öneririz `N < 10` değer; performans büyük ile azalır `N` değerler. Maksimum değeri `N = 65536`. + +**Parametre** + +- ‘N’ dönmek için Öğe sayısıdır. + +Parametre atlanırsa, varsayılan değer 10 kullanılır. + +**Değişkenler** + +- ' x ' – The value to calculate frequency. + +**Örnek** + +Tak thee the [OnTime](../../getting-started/example-datasets/ontime.md) veri kümesi ve üç en sık oluşan değerleri seçin `AirlineID` sütun. + +``` sql +SELECT topK(3)(AirlineID) AS res +FROM ontime +``` + +``` text +┌─res─────────────────┐ +│ [19393,19790,19805] │ +└─────────────────────┘ +``` + +## topKWeighted {#topkweighted} + +Benzer `topK` ancak tamsayı türünde bir ek argüman alır - `weight`. Her değer muhasebeleştirilir `weight` frekans hesaplaması için zamanlar. + +**Sözdizimi** + +``` sql +topKWeighted(N)(x, weight) +``` + +**Parametre** + +- `N` — The number of elements to return. + +**Değişkenler** + +- `x` – The value. +- `weight` — The weight. [Uİnt8](../../sql-reference/data-types/int-uint.md). + +**Döndürülen değer** + +Maksimum yaklaşık ağırlık toplamına sahip değerlerin bir dizisini döndürür. + +**Örnek** + +Sorgu: + +``` sql +SELECT topKWeighted(10)(number, number) FROM numbers(1000) +``` + +Sonuç: + +``` text +┌─topKWeighted(10)(number, number)──────────┐ +│ [999,998,997,996,995,994,993,992,991,990] │ +└───────────────────────────────────────────┘ +``` + +## covarSamp(x, y) {#covarsampx-y} + +Değerini hesaplar `Σ((x - x̅)(y - y̅)) / (n - 1)`. + +Float64 Döndürür. Ne zaman `n <= 1`, returns +∞. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `covarSampStable` İşlev. Daha yavaş çalışır, ancak daha düşük hesaplama hatası sağlar. + +## covarPop (x, y) {#covarpopx-y} + +Değerini hesaplar `Σ((x - x̅)(y - y̅)) / n`. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `covarPopStable` İşlev. Daha yavaş çalışır, ancak daha düşük bir hesaplama hatası sağlar. + +## corr(x, y) {#corrx-y} + +Pearson korelasyon katsayısını hesaplar: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. + +!!! note "Not" + Bu işlev sayısal olarak kararsız algoritma kullanır. İhtiyacınız varsa [sayısal kararlılık](https://en.wikipedia.org/wiki/Numerical_stability) hesaplamalarda kullan `corrStable` İşlev. Daha yavaş çalışır, ancak daha düşük hesaplama hatası sağlar. + +## categoricalınformationvalue {#categoricalinformationvalue} + +Değerini hesaplar `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` her kategori için. + +``` sql +categoricalInformationValue(category1, category2, ..., tag) +``` + +Sonuç, ayrık (kategorik) bir özelliğin nasıl olduğunu gösterir `[category1, category2, ...]` değerini öngör aen bir öğrenme modeline katkıda `tag`. + +## simpleLinearRegression {#simplelinearregression} + +Basit (tek boyutlu) doğrusal regresyon gerçekleştirir. + +``` sql +simpleLinearRegression(x, y) +``` + +Parametre: + +- `x` — Column with dependent variable values. +- `y` — Column with explanatory variable values. + +Döndürülen değerler: + +Devamlılar `(a, b)` ortaya çıkan hat linetın `y = a*x + b`. + +**Örnekler** + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ +│ (1,0) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) +``` + +``` text +┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ +│ (1,3) │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## stokastiklinearregression {#agg_functions-stochasticlinearregression} + +Bu fonksiyon stokastik doğrusal regresyon uygular. Öğrenme oranı, L2 regularization katsayısı, mini-batch boyutu için özel parametreleri destekler ve ağırlıkları güncellemek için birkaç yöntem vardır ([Adem](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (varsayılan olarak kullanılır), [basit SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [İvme](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). + +### Parametre {#agg_functions-stochasticlinearregression-parameters} + +4 özelleştirilebilir parametre vardır. Onlar sırayla işleve geçirilir, ancak dört varsayılan değerleri kullanılacak geçmek gerek yoktur, ancak iyi bir model bazı parametre ayarlama gerekli. + +``` text +stochasticLinearRegression(1.0, 1.0, 10, 'SGD') +``` + +1. `learning rate` Gradyan iniş adımı gerçekleştirildiğinde adım uzunluğundaki katsayıdır. Çok büyük öğrenme oranı, modelin sonsuz ağırlıklarına neden olabilir. Default is `0.00001`. +2. `l2 regularization coefficient` hangi overfitting önlemek için yardımcı olabilir. Default is `0.1`. +3. `mini-batch size` gradyanların hesaplanacağı ve Gradyan inişinin bir adımını gerçekleştirmek için toplanacağı öğelerin sayısını ayarlar. Saf stokastik iniş bir eleman kullanır, ancak küçük partilere(yaklaşık 10 eleman) sahip olmak degrade adımları daha kararlı hale getirir. Default is `15`. +4. `method for updating weights` onlar : `Adam` (varsayılan olarak), `SGD`, `Momentum`, `Nesterov`. `Momentum` ve `Nesterov` biraz daha fazla hesaplama ve bellek gerektirir, ancak stokastik Gradyan yöntemlerinin yakınsama hızı ve kararlılığı açısından yararlı olurlar. + +### Kullanma {#agg_functions-stochasticlinearregression-usage} + +`stochasticLinearRegression` iki adımda kullanılır: modelin takılması ve yeni verilerin tahmin edilmesi. Modeli sığdırmak ve daha sonra kullanım için durumunu kaydetmek için kullandığımız `-State` temel olarak durumu kurtaran birleştirici (model ağırlıkları, vb.). +Fonksiyonu kullan wedığımızı tahmin etmek [evalMLMethod](../functions/machine-learning-functions.md#machine_learning_methods-evalmlmethod), bir argüman olarak bir durumu yanı sıra tahmin etmek için özellikler alır. + + + +**1.** Uydurma + +Böyle bir sorgu kullanılabilir. + +``` sql +CREATE TABLE IF NOT EXISTS train_data +( + param1 Float64, + param2 Float64, + target Float64 +) ENGINE = Memory; + +CREATE TABLE your_model ENGINE = Memory AS SELECT +stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) +AS state FROM train_data; +``` + +Burada ayrıca veri eklememiz gerekiyor `train_data` Tablo. Parametrelerin sayısı sabit değildir, sadece argümanların sayısına bağlıdır, `linearRegressionState`. Hepsi sayısal değerler olmalıdır. +Hedef değere sahip sütunun(tahmin etmeyi öğrenmek istediğimiz) ilk argüman olarak eklendiğini unutmayın. + +**2.** Öngören + +Bir durumu tabloya kaydettikten sonra, tahmin için birden çok kez kullanabilir, hatta diğer durumlarla birleşebilir ve yeni daha iyi modeller oluşturabiliriz. + +``` sql +WITH (SELECT state FROM your_model) AS model SELECT +evalMLMethod(model, param1, param2) FROM test_data +``` + +Sorgu, tahmin edilen değerlerin bir sütununu döndürür. Not ilk argüman `evalMLMethod` oluyor `AggregateFunctionState` nesne, sonraki özelliklerin sütunlarıdır. + +`test_data` bir tablo gibi mi `train_data` ancak hedef değer içermeyebilir. + +### Not {#agg_functions-stochasticlinearregression-notes} + +1. İki modeli birleştirmek için Kullanıcı böyle bir sorgu oluşturabilir: + `sql SELECT state1 + state2 FROM your_models` + nerede `your_models` tablo her iki modeli de içerir. Bu sorgu yeni dönecektir `AggregateFunctionState` nesne. + +2. Kullanıcı, modeli kaydetmeden oluşturulan modelin ağırlıklarını kendi amaçları için alabilir `-State` birleştirici kullanılır. + `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` + Bu sorgu modele uyacak ve ağırlıklarını geri getirecektir-ilk önce modelin parametrelerine karşılık gelen ağırlıklar, sonuncusu önyargıdır. Yani yukarıdaki örnekte sorgu 3 değer içeren bir sütun döndürecektir. + +**Ayrıca Bakınız** + +- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) +- [Doğrusal ve lojistik regresyonlar arasındaki fark](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} + +Bu işlev stokastik lojistik regresyon uygular. İkili sınıflandırma problemi için kullanılabilir, stochasticLinearRegression ile aynı özel parametreleri destekler ve aynı şekilde çalışır. + +### Parametre {#agg_functions-stochasticlogisticregression-parameters} + +Parametreler tam olarak stochasticLinearRegression ile aynıdır: +`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. +Daha fazla bilgi için bkz. [parametre](#agg_functions-stochasticlinearregression-parameters). + +``` text +stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') +``` + +1. Uydurma + + + + See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. + + Predicted labels have to be in \[-1, 1\]. + +1. Öngören + + + + Using saved state we can predict probability of object having label `1`. + + ``` sql + WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) FROM test_data + ``` + + The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. + + We can also set a bound of probability, which assigns elements to different labels. + + ``` sql + SELECT ans < 1.1 AND ans > 0.5 FROM + (WITH (SELECT state FROM your_model) AS model SELECT + evalMLMethod(model, param1, param2) AS ans FROM test_data) + ``` + + Then the result will be labels. + + `test_data` is a table like `train_data` but may not contain target value. + +**Ayrıca Bakınız** + +- [stokastiklinearregression](#agg_functions-stochasticlinearregression) +- [Doğrusal ve lojistik regresyonlar arasındaki fark.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) + +## groupBitmapAnd {#groupbitmapand} + +Bu VE bir bitmap sütun, Uınt64 tür iade önem, hesaplamaları suffix ekleme -Devlet, sonra iade [bitmap nesnesi](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapAnd(expr) +``` + +**Parametre** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` tür. + +**Dönüş değeri** + +Bu değer `UInt64` tür. + +**Örnek** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapAnd(z)─┐ +│ 3 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ +│ [6,8,10] │ +└──────────────────────────────────────────────────┘ +``` + +## groupBitmapOr {#groupbitmapor} + +YA da bir bitmap sütun, Uınt64 tür iade önem, hesaplamaları suffix ekleme -Devlet, sonra iade [bitmap nesnesi](../../sql-reference/functions/bitmap-functions.md). Bu eşdeğerdir `groupBitmapMerge`. + +``` sql +groupBitmapOr(expr) +``` + +**Parametre** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` tür. + +**Dönüş değeri** + +Bu değer `UInt64` tür. + +**Örnek** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapOr(z)─┐ +│ 15 │ +└──────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ +│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ +└─────────────────────────────────────────────────┘ +``` + +## groupBitmapXor {#groupbitmapxor} + +Bir bitmap sütun, Uınt64 tür iade önem hesaplamaları XOR, suffix ekleme -Devlet, sonra iade [bitmap nesnesi](../../sql-reference/functions/bitmap-functions.md). + +``` sql +groupBitmapOr(expr) +``` + +**Parametre** + +`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` tür. + +**Dönüş değeri** + +Bu değer `UInt64` tür. + +**Örnek** + +``` sql +DROP TABLE IF EXISTS bitmap_column_expr_test2; +CREATE TABLE bitmap_column_expr_test2 +( + tag_id String, + z AggregateFunction(groupBitmap, UInt32) +) +ENGINE = MergeTree +ORDER BY tag_id; + +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); + +SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─groupBitmapXor(z)─┐ +│ 10 │ +└───────────────────┘ + +SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); +┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ +│ [1,3,5,6,8,10,11,13,14,15] │ +└──────────────────────────────────────────────────┘ +``` + +[Orijinal makale](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/tr/sql-reference/ansi.md b/docs/tr/sql-reference/ansi.md new file mode 100644 index 00000000000..5946da05ce2 --- /dev/null +++ b/docs/tr/sql-reference/ansi.md @@ -0,0 +1,180 @@ +--- +machine_translated: true +machine_translated_rev: ad252bbb4f7e2899c448eb42ecc39ff195c8faa1 +toc_priority: 40 +toc_title: "ANSI uyumlulu\u011Fu" +--- + +# ClickHouse SQL Lehçesinin ANSI SQL uyumluluğu {#ansi-sql-compatibility-of-clickhouse-sql-dialect} + +!!! note "Not" + Bu makale Tablo 38, “Feature taxonomy and definition for mandatory features”, Annex F of ISO/IEC CD 9075-2:2013. + +## Davranış farklılıkları {#differences-in-behaviour} + +Aşağıdaki tabloda, sorgu özelliği ClickHouse çalışır, ancak ANSI SQL'DE belirtildiği gibi davranır durumlarda listeler. + +| Feature ID | Özellik Adı | Fark | +|------------|---------------------------------------|----------------------------------------------------------------------------------------------------| +| E011 | Sayısal veri türleri | Dönem ile sayısal literal yaklaşık olarak yorumlanır (`Float64`) tam yerine (`Decimal`) | +| E051-05 | Seçme öğeler yeniden adlandırılabilir | Öğe yeniden adlandırmaları, yalnızca seçme sonucundan daha geniş bir görünürlük kapsamına sahiptir | +| E141-01 | NOT NULL kısıtlamaları | `NOT NULL` tablo sütunları için varsayılan olarak ima edilir | +| E011-04 | Aritmetik operat operatorsörler | ClickHouse işaretli aritmetik yerine taşar ve sonuç veri türünü özel kurallara göre değiştirir | + +## Özellik Durumu {#feature-status} + +| Feature ID | Özellik Adı | Durum | Yorum | +|------------|-----------------------------------------------------------------------------------------------------------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **E011** | **Sayısal veri türleri** | **Kısmi**{.text-warning} | | +| E011-01 | Tamsayı ve SMALLİNT veri türleri | Evet{.text-success} | | +| E011-02 | Gerçek, çift hassas ve FLOAT veri türleri veri türleri | Kısmi{.text-warning} | `FLOAT()`, `REAL` ve `DOUBLE PRECISION` desteklenmiyor | +| E011-03 | Ondalık ve sayısal veri türleri | Kısmi{.text-warning} | Sadece `DECIMAL(p,s)` desteklenir, değil `NUMERIC` | +| E011-04 | Aritmetik operat operatorsörler | Evet{.text-success} | | +| E011-05 | Sayısal karşılaştırma | Evet{.text-success} | | +| E011-06 | Sayısal veri türleri arasında örtülü döküm | Hayır{.text-danger} | ANSI SQL, sayısal türler arasında rasgele örtülü döküm yapılmasına izin verirken, ClickHouse, örtülü döküm yerine birden fazla aşırı yüke sahip işlevlere dayanır | +| **E021** | **Karakter dizesi türleri** | **Kısmi**{.text-warning} | | +| E021-01 | Karakter veri türü | Hayır{.text-danger} | | +| E021-02 | Karakter değişken veri türü | Hayır{.text-danger} | `String` benzer şekilde davranır, ancak parantez içinde uzunluk sınırı olmadan | +| E021-03 | Karakter değişmezleri | Kısmi{.text-warning} | Ardışık değişmezlerin ve karakter seti desteğinin otomatik olarak birleştirilmesi yok | +| E021-04 | CHARACTER\_LENGTH işlevi | Kısmi{.text-warning} | Hayır `USING` yan | +| E021-05 | OCTET\_LENGTH işlevi | Hayır{.text-danger} | `LENGTH` benzer şekilde davranır | +| E021-06 | SUBSTRING | Kısmi{.text-warning} | İçin destek yok `SIMILAR` ve `ESCAPE` CLA ,us ,es, no `SUBSTRING_REGEX` varyant | +| E021-07 | Karakter birleştirme | Kısmi{.text-warning} | Hayır `COLLATE` yan | +| E021-08 | Üst ve alt fonksiyonlar | Evet{.text-success} | | +| E021-09 | TRİM fonksiyonu | Evet{.text-success} | | +| E021-10 | Sabit uzunlukta ve değişken uzunlukta karakter dizesi türleri arasında örtülü döküm | Hayır{.text-danger} | ANSI SQL, dize türleri arasında rasgele örtük döküm yapılmasına izin verirken, ClickHouse, örtük döküm yerine birden fazla aşırı yüke sahip işlevlere dayanır | +| E021-11 | Pozisyon fonksiyonu | Kısmi{.text-warning} | İçin destek yok `IN` ve `USING` CLA ,us ,es, no `POSITION_REGEX` varyant | +| E021-12 | Karakter karşılaştırma | Evet{.text-success} | | +| **E031** | **Tanıtıcılar** | **Kısmi**{.text-warning} | | +| E031-01 | Ayrılmış tanımlayıcılar | Kısmi{.text-warning} | Unicode literal desteği sınırlıdır | +| E031-02 | Küçük harf tanımlayıcıları | Evet{.text-success} | | +| E031-03 | Sondaki alt çizgi | Evet{.text-success} | | +| **E051** | **Temel sorgu belirtimi** | **Kısmi**{.text-warning} | | +| E051-01 | SELECT DISTINCT | Evet{.text-success} | | +| E051-02 | GROUP BY fık clausera | Evet{.text-success} | | +| E051-04 | GROUP BY içinde olmayan sütunlar içerebilir `` | 是{.text-success} | | +| E051-05 | 选择项目可以重命名 | 是{.text-success} | | +| E051-06 | 有条款 | 是{.text-success} | | +| E051-07 | 合格\*在选择列表中 | 是{.text-success} | | +| E051-08 | FROM子句中的关联名称 | 是{.text-success} | | +| E051-09 | 重命名FROM子句中的列 | 非也。{.text-danger} | | +| **E061** | **基本谓词和搜索条件** | **部分**{.text-warning} | | +| E061-01 | 比较谓词 | 是{.text-success} | | +| E061-02 | 谓词之间 | 部分{.text-warning} | 非也。 `SYMMETRIC` 和 `ASYMMETRIC` 条款 | +| E061-03 | 在具有值列表的谓词中 | 是{.text-success} | | +| E061-04 | 像谓词 | 是{.text-success} | | +| E061-05 | LIKE谓词:逃避条款 | 非也。{.text-danger} | | +| E061-06 | 空谓词 | 是{.text-success} | | +| E061-07 | 量化比较谓词 | 非也。{.text-danger} | | +| E061-08 | 存在谓词 | 非也。{.text-danger} | | +| E061-09 | 比较谓词中的子查询 | 是{.text-success} | | +| E061-11 | 谓词中的子查询 | 是{.text-success} | | +| E061-12 | 量化比较谓词中的子查询 | 非也。{.text-danger} | | +| E061-13 | 相关子查询 | 非也。{.text-danger} | | +| E061-14 | 搜索条件 | 是{.text-success} | | +| **E071** | **基本查询表达式** | **部分**{.text-warning} | | +| E071-01 | UNION DISTINCT table运算符 | 非也。{.text-danger} | | +| E071-02 | 联合所有表运算符 | 是{.text-success} | | +| E071-03 | 除了不同的表运算符 | 非也。{.text-danger} | | +| E071-05 | 通过表运算符组合的列不必具有完全相同的数据类型 | 是{.text-success} | | +| E071-06 | 子查询中的表运算符 | 是{.text-success} | | +| **E081** | **基本特权** | **部分**{.text-warning} | 正在进行的工作 | +| **E091** | **设置函数** | **是**{.text-success} | | +| E091-01 | AVG | 是{.text-success} | | +| E091-02 | COUNT | 是{.text-success} | | +| E091-03 | MAX | 是{.text-success} | | +| E091-04 | MIN | 是{.text-success} | | +| E091-05 | SUM | 是{.text-success} | | +| E091-06 | 全部量词 | 非也。{.text-danger} | | +| E091-07 | 不同的量词 | 部分{.text-warning} | 并非所有聚合函数都受支持 | +| **E101** | **基本数据操作** | **部分**{.text-warning} | | +| E101-01 | 插入语句 | 是{.text-success} | 注:ClickHouse中的主键并不意味着 `UNIQUE` 约束 | +| E101-03 | 搜索更新语句 | 非也。{.text-danger} | 有一个 `ALTER UPDATE` 批量数据修改语句 | +| E101-04 | 搜索的删除语句 | 非也。{.text-danger} | 有一个 `ALTER DELETE` 批量数据删除声明 | +| **E111** | **单行SELECT语句** | **非也。**{.text-danger} | | +| **E121** | **基本光标支持** | **非也。**{.text-danger} | | +| E121-01 | DECLARE CURSOR | 非也。{.text-danger} | | +| E121-02 | 按列排序不需要在选择列表中 | 非也。{.text-danger} | | +| E121-03 | 按顺序排列的值表达式 | 非也。{.text-danger} | | +| E121-04 | 公开声明 | 非也。{.text-danger} | | +| E121-06 | 定位更新语句 | 非也。{.text-danger} | | +| E121-07 | 定位删除语句 | 非也。{.text-danger} | | +| E121-08 | 关闭声明 | 非也。{.text-danger} | | +| E121-10 | FETCH语句:隐式NEXT | 非也。{.text-danger} | | +| E121-17 | 使用保持游标 | 非也。{.text-danger} | | +| **E131** | **空值支持(空值代替值)** | **部分**{.text-warning} | 一些限制适用 | +| **E141** | **基本完整性约束** | **部分**{.text-warning} | | +| E141-01 | 非空约束 | 是{.text-success} | 注: `NOT NULL` 默认情况下,表列隐含 | +| E141-02 | 非空列的唯一约束 | 非也。{.text-danger} | | +| E141-03 | 主键约束 | 非也。{.text-danger} | | +| E141-04 | 对于引用删除操作和引用更新操作,具有默认无操作的基本外键约束 | 非也。{.text-danger} | | +| E141-06 | 检查约束 | 是{.text-success} | | +| E141-07 | 列默认值 | 是{.text-success} | | +| E141-08 | 在主键上推断为非NULL | 是{.text-success} | | +| E141-10 | 可以按任何顺序指定外键中的名称 | 非也。{.text-danger} | | +| **E151** | **交易支持** | **非也。**{.text-danger} | | +| E151-01 | 提交语句 | 非也。{.text-danger} | | +| E151-02 | 回滚语句 | 非也。{.text-danger} | | +| **E152** | **基本设置事务语句** | **非也。**{.text-danger} | | +| E152-01 | SET TRANSACTION语句:隔离级别SERIALIZABLE子句 | 非也。{.text-danger} | | +| E152-02 | SET TRANSACTION语句:只读和读写子句 | 非也。{.text-danger} | | +| **E153** | **具有子查询的可更新查询** | **非也。**{.text-danger} | | +| **E161** | **SQL注释使用前导双减** | **是**{.text-success} | | +| **E171** | **SQLSTATE支持** | **非也。**{.text-danger} | | +| **E182** | **主机语言绑定** | **非也。**{.text-danger} | | +| **F031** | **基本架构操作** | **部分**{.text-warning} | | +| F031-01 | CREATE TABLE语句创建持久基表 | 部分{.text-warning} | 非也。 `SYSTEM VERSIONING`, `ON COMMIT`, `GLOBAL`, `LOCAL`, `PRESERVE`, `DELETE`, `REF IS`, `WITH OPTIONS`, `UNDER`, `LIKE`, `PERIOD FOR` 子句,不支持用户解析的数据类型 | +| F031-02 | 创建视图语句 | 部分{.text-warning} | 非也。 `RECURSIVE`, `CHECK`, `UNDER`, `WITH OPTIONS` 子句,不支持用户解析的数据类型 | +| F031-03 | 赠款声明 | 是{.text-success} | | +| F031-04 | ALTER TABLE语句:ADD COLUMN子句 | 部分{.text-warning} | 不支持 `GENERATED` 条款和系统时间段 | +| F031-13 | DROP TABLE语句:RESTRICT子句 | 非也。{.text-danger} | | +| F031-16 | DROP VIEW语句:RESTRICT子句 | 非也。{.text-danger} | | +| F031-19 | REVOKE语句:RESTRICT子句 | 非也。{.text-danger} | | +| **F041** | **基本连接表** | **部分**{.text-warning} | | +| F041-01 | Inner join(但不一定是INNER关键字) | 是{.text-success} | | +| F041-02 | 内部关键字 | 是{.text-success} | | +| F041-03 | LEFT OUTER JOIN | 是{.text-success} | | +| F041-04 | RIGHT OUTER JOIN | 是{.text-success} | | +| F041-05 | 可以嵌套外部连接 | 是{.text-success} | | +| F041-07 | 左侧或右侧外部联接中的内部表也可用于内部联接 | 是{.text-success} | | +| F041-08 | 支持所有比较运算符(而不仅仅是=) | 非也。{.text-danger} | | +| **F051** | **基本日期和时间** | **部分**{.text-warning} | | +| F051-01 | 日期数据类型(包括对日期文字的支持) | 部分{.text-warning} | 没有文字 | +| F051-02 | 时间数据类型(包括对时间文字的支持),秒小数精度至少为0 | 非也。{.text-danger} | | +| F051-03 | 时间戳数据类型(包括对时间戳文字的支持),小数秒精度至少为0和6 | 非也。{.text-danger} | `DateTime64` 时间提供了类似的功能 | +| F051-04 | 日期、时间和时间戳数据类型的比较谓词 | 部分{.text-warning} | 只有一种数据类型可用 | +| F051-05 | Datetime类型和字符串类型之间的显式转换 | 是{.text-success} | | +| F051-06 | CURRENT\_DATE | 非也。{.text-danger} | `today()` 是相似的 | +| F051-07 | LOCALTIME | 非也。{.text-danger} | `now()` 是相似的 | +| F051-08 | LOCALTIMESTAMP | 非也。{.text-danger} | | +| **F081** | **联盟和视图除外** | **部分**{.text-warning} | | +| **F131** | **分组操作** | **部分**{.text-warning} | | +| F131-01 | WHERE、GROUP BY和HAVING子句在具有分组视图的查询中受支持 | 是{.text-success} | | +| F131-02 | 具有分组视图的查询中支持的多个表 | 是{.text-success} | | +| F131-03 | 设置具有分组视图的查询中支持的函数 | 是{.text-success} | | +| F131-04 | 具有分组依据和具有子句和分组视图的子查询 | 是{.text-success} | | +| F131-05 | 单行选择具有GROUP BY和具有子句和分组视图 | 非也。{.text-danger} | | +| **F181** | **多模块支持** | **非也。**{.text-danger} | | +| **F201** | **投函数** | **是**{.text-success} | | +| **F221** | **显式默认值** | **非也。**{.text-danger} | | +| **F261** | **案例表达式** | **是**{.text-success} | | +| F261-01 | 简单案例 | 是{.text-success} | | +| F261-02 | 检索案例 | 是{.text-success} | | +| F261-03 | NULLIF | 是{.text-success} | | +| F261-04 | COALESCE | 是{.text-success} | | +| **F311** | **架构定义语句** | **部分**{.text-warning} | | +| F311-01 | CREATE SCHEMA | 非也。{.text-danger} | | +| F311-02 | 为持久基表创建表 | 是{.text-success} | | +| F311-03 | CREATE VIEW | 是{.text-success} | | +| F311-04 | CREATE VIEW: WITH CHECK OPTION | 非也。{.text-danger} | | +| F311-05 | 赠款声明 | 是{.text-success} | | +| **F471** | **标量子查询值** | **是**{.text-success} | | +| **F481** | **扩展空谓词** | **是**{.text-success} | | +| **F812** | **基本标记** | **非也。**{.text-danger} | | +| **T321** | **基本的SQL调用例程** | **非也。**{.text-danger} | | +| T321-01 | 无重载的用户定义函数 | 非也。{.text-danger} | | +| T321-02 | 无重载的用户定义存储过程 | 非也。{.text-danger} | | +| T321-03 | 函数调用 | 非也。{.text-danger} | | +| T321-04 | 电话声明 | 非也。{.text-danger} | | +| T321-05 | 退货声明 | 非也。{.text-danger} | | +| **T631** | **在一个列表元素的谓词中** | **是**{.text-success} | | diff --git a/docs/zh/sql-reference/data-types/aggregatefunction.md b/docs/zh/sql-reference/data-types/aggregatefunction.md new file mode 100644 index 00000000000..a7e1ee35c16 --- /dev/null +++ b/docs/zh/sql-reference/data-types/aggregatefunction.md @@ -0,0 +1,63 @@ +# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} + +聚合函数的中间状态,可以通过聚合函数名称加`-State`后缀的形式得到它。与此同时,当您需要访问该类型的最终状态数据时,您需要以相同的聚合函数名加`-Merge`后缀的形式来得到最终状态数据。 + +`AggregateFunction` — 参数化的数据类型。 + +**参数** + +- 聚合函数名 + + 如果函数具备多个参数列表,请在此处指定其他参数列表中的值。 + +- 聚合函数参数的类型 + +**示例** + +``` sql +CREATE TABLE t +( + column1 AggregateFunction(uniq, UInt64), + column2 AggregateFunction(anyIf, String, UInt8), + column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) +) ENGINE = ... +``` + +上述中的[uniq](../../sql-reference/data-types/aggregatefunction.md#agg_function-uniq), anyIf ([任何](../../sql-reference/data-types/aggregatefunction.md#agg_function-any)+[如果](../../sql-reference/data-types/aggregatefunction.md#agg-functions-combinator-if)) 以及 [分位数](../../sql-reference/data-types/aggregatefunction.md) 都为ClickHouse中支持的聚合函数。 + +## 使用指南 {#shi-yong-zhi-nan} + +### 数据写入 {#shu-ju-xie-ru} + +当需要写入数据时,您需要将数据包含在`INSERT SELECT`语句中,同时对于`AggregateFunction`类型的数据,您需要使用对应的以`-State`为后缀的函数进行处理。 + +**函数使用示例** + +``` sql +uniqState(UserID) +quantilesState(0.5, 0.9)(SendTiming) +``` + +不同于`uniq`和`quantiles`函数返回聚合结果的最终值,以`-State`后缀的函数总是返回`AggregateFunction`类型的数据的中间状态。 + +对于`SELECT`而言,`AggregateFunction`类型总是以特定的二进制形式展现在所有的输出格式中。例如,您可以使用`SELECT`语句将函数的状态数据转储为`TabSeparated`格式的同时使用`INSERT`语句将数据转储回去。 + +### 数据查询 {#shu-ju-cha-xun} + +当从`AggregatingMergeTree`表中查询数据时,对于`AggregateFunction`类型的字段,您需要使用以`-Merge`为后缀的相同聚合函数来聚合数据。对于非`AggregateFunction`类型的字段,请将它们包含在`GROUP BY`子句中。 + +以`-Merge`为后缀的聚合函数,可以将多个`AggregateFunction`类型的中间状态组合计算为最终的聚合结果。 + +例如,如下的两个查询返回的结果总是一致: + +``` sql +SELECT uniq(UserID) FROM table + +SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) +``` + +## 使用示例 {#shi-yong-shi-li} + +请参阅 [AggregatingMergeTree](../../sql-reference/data-types/aggregatefunction.md) 的说明 + +[来源文章](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/zh/sql-reference/data-types/array.md b/docs/zh/sql-reference/data-types/array.md new file mode 100644 index 00000000000..41eeb72c045 --- /dev/null +++ b/docs/zh/sql-reference/data-types/array.md @@ -0,0 +1,72 @@ +# 阵列(T) {#data-type-array} + +由 `T` 类型元素组成的数组。 + +`T` 可以是任意类型,包含数组类型。 但不推荐使用多维数组,ClickHouse 对多维数组的支持有限。例如,不能存储在 `MergeTree` 表中存储多维数组。 + +## 创建数组 {#chuang-jian-shu-zu} + +您可以使用array函数来创建数组: + + array(T) + +您也可以使用方括号: + + [] + +创建数组示例: + + :) SELECT array(1, 2) AS x, toTypeName(x) + + SELECT + [1, 2] AS x, + toTypeName(x) + + ┌─x─────┬─toTypeName(array(1, 2))─┐ + │ [1,2] │ Array(UInt8) │ + └───────┴─────────────────────────┘ + + 1 rows in set. Elapsed: 0.002 sec. + + :) SELECT [1, 2] AS x, toTypeName(x) + + SELECT + [1, 2] AS x, + toTypeName(x) + + ┌─x─────┬─toTypeName([1, 2])─┐ + │ [1,2] │ Array(UInt8) │ + └───────┴────────────────────┘ + + 1 rows in set. Elapsed: 0.002 sec. + +## 使用数据类型 {#shi-yong-shu-ju-lei-xing} + +ClickHouse会自动检测数组元素,并根据元素计算出存储这些元素最小的数据类型。如果在元素中存在 [NULL](../../sql-reference/data-types/array.md#null-literal) 或存在 [可为空](nullable.md#data_type-nullable) 类型元素,那么数组的元素类型将会变成 [可为空](nullable.md)。 + +如果 ClickHouse 无法确定数据类型,它将产生异常。当尝试同时创建一个包含字符串和数字的数组时会发生这种情况 (`SELECT array(1, 'a')`)。 + +自动数据类型检测示例: + + :) SELECT array(1, 2, NULL) AS x, toTypeName(x) + + SELECT + [1, 2, NULL] AS x, + toTypeName(x) + + ┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ + │ [1,2,NULL] │ Array(Nullable(UInt8)) │ + └────────────┴───────────────────────────────┘ + + 1 rows in set. Elapsed: 0.002 sec. + +如果您尝试创建不兼容的数据类型数组,ClickHouse 将引发异常: + + :) SELECT array(1, 'a') + + SELECT [1, 'a'] + + Received exception from server (version 1.1.54388): + Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. + + 0 rows in set. Elapsed: 0.246 sec. diff --git a/docs/zh/sql-reference/data-types/boolean.md b/docs/zh/sql-reference/data-types/boolean.md new file mode 100644 index 00000000000..99aacad23a9 --- /dev/null +++ b/docs/zh/sql-reference/data-types/boolean.md @@ -0,0 +1,3 @@ +# 布尔值 {#boolean-values} + +没有单独的类型来存储布尔值。可以使用 UInt8 类型,取值限制为 0 或 1。 diff --git a/docs/zh/sql-reference/data-types/date.md b/docs/zh/sql-reference/data-types/date.md new file mode 100644 index 00000000000..dd70e5d7ef1 --- /dev/null +++ b/docs/zh/sql-reference/data-types/date.md @@ -0,0 +1,5 @@ +# 日期 {#date} + +日期类型,用两个字节存储,表示从 1970-01-01 (无符号) 到当前的日期值。允许存储从 Unix 纪元开始到编译阶段定义的上限阈值常量(目前上限是2106年,但最终完全支持的年份为2105)。最小值输出为0000-00-00。 + +日期中没有存储时区信息。 diff --git a/docs/zh/sql-reference/data-types/datetime.md b/docs/zh/sql-reference/data-types/datetime.md new file mode 100644 index 00000000000..a10eaa04c00 --- /dev/null +++ b/docs/zh/sql-reference/data-types/datetime.md @@ -0,0 +1,11 @@ +# 日期时间 {#data_type-datetime} + +时间戳类型。用四个字节(无符号的)存储 Unix 时间戳)。允许存储与日期类型相同的范围内的值。最小值为 0000-00-00 00:00:00。时间戳类型值精确到秒(没有闰秒)。 + +## 时区 {#shi-qu} + +使用启动客户端或服务器时的系统时区,时间戳是从文本(分解为组件)转换为二进制并返回。在文本格式中,有关夏令时的信息会丢失。 + +默认情况下,客户端连接到服务的时候会使用服务端时区。您可以通过启用客户端命令行选项 `--use_client_time_zone` 来设置使用客户端时间。 + +因此,在处理文本日期时(例如,在保存文本转储时),请记住在夏令时更改期间可能存在歧义,如果时区发生更改,则可能存在匹配数据的问题。 diff --git a/docs/zh/sql-reference/data-types/datetime64.md b/docs/zh/sql-reference/data-types/datetime64.md new file mode 100644 index 00000000000..2442972965a --- /dev/null +++ b/docs/zh/sql-reference/data-types/datetime64.md @@ -0,0 +1,104 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 49 +toc_title: DateTime64 +--- + +# Datetime64 {#data_type-datetime64} + +允许存储时间instant间,可以表示为日历日期和一天中的时间,具有定义的亚秒精度 + +刻度尺寸(精度):10-精度 秒 + +语法: + +``` sql +DateTime64(precision, [timezone]) +``` + +在内部,存储数据作为一些 ‘ticks’ 自纪元开始(1970-01-01 00:00:00UTC)作为Int64. 刻度分辨率由precision参数确定。 此外,该 `DateTime64` 类型可以存储时区是相同的整个列,影响如何的值 `DateTime64` 类型值以文本格式显示,以及如何解析指定为字符串的值 (‘2020-01-01 05:00:01.000’). 时区不存储在表的行中(或resultset中),而是存储在列元数据中。 查看详细信息 [日期时间](datetime.md). + +## 例 {#examples} + +**1.** 创建一个表 `DateTime64`-输入列并将数据插入其中: + +``` sql +CREATE TABLE dt +( + `timestamp` DateTime64(3, 'Europe/Moscow'), + `event_id` UInt8 +) +ENGINE = TinyLog +``` + +``` sql +INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) +``` + +``` sql +SELECT * FROM dt +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 03:00:00.000 │ 1 │ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +- 将日期时间作为整数插入时,将其视为适当缩放的Unix时间戳(UTC)。 `1546300800000` (精度为3)表示 `'2019-01-01 00:00:00'` UTC. 然而,作为 `timestamp` 列有 `Europe/Moscow` (UTC+3)指定的时区,当输出为字符串时,该值将显示为 `'2019-01-01 03:00:00'` +- 当插入字符串值作为日期时间时,它被视为处于列时区。 `'2019-01-01 00:00:00'` 将被视为 `Europe/Moscow` 时区并存储为 `1546290000000`. + +**2.** 过滤 `DateTime64` 值 + +``` sql +SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') +``` + +``` text +┌───────────────timestamp─┬─event_id─┐ +│ 2019-01-01 00:00:00.000 │ 2 │ +└─────────────────────────┴──────────┘ +``` + +不像 `DateTime`, `DateTime64` 值不转换为 `String` 自动 + +**3.** 获取一个时区 `DateTime64`-类型值: + +``` sql +SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x +``` + +``` text +┌──────────────────column─┬─x──────────────────────────────┐ +│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ +└─────────────────────────┴────────────────────────────────┘ +``` + +**4.** 时区转换 + +``` sql +SELECT +toDateTime64(timestamp, 3, 'Europe/London') as lon_time, +toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time +FROM dt +``` + +``` text +┌───────────────lon_time──┬────────────────mos_time─┐ +│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ +│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ +└─────────────────────────┴─────────────────────────┘ +``` + +## 另请参阅 {#see-also} + +- [类型转换函数](../../sql-reference/functions/type-conversion-functions.md) +- [用于处理日期和时间的函数](../../sql-reference/functions/date-time-functions.md) +- [用于处理数组的函数](../../sql-reference/functions/array-functions.md) +- [该 `date_time_input_format` 设置](../../operations/settings/settings.md#settings-date_time_input_format) +- [该 `timezone` 服务器配置参数](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone) +- [使用日期和时间的操作员](../../sql-reference/operators/index.md#operators-datetime) +- [`Date` 数据类型](date.md) +- [`DateTime` 数据类型](datetime.md) diff --git a/docs/zh/sql-reference/data-types/decimal.md b/docs/zh/sql-reference/data-types/decimal.md new file mode 100644 index 00000000000..b0a55de1685 --- /dev/null +++ b/docs/zh/sql-reference/data-types/decimal.md @@ -0,0 +1,80 @@ +# Decimal(P,S),Decimal32(S),Decimal64(S),Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} + +有符号的定点数,可在加、减和乘法运算过程中保持精度。对于除法,最低有效数字会被丢弃(不舍入)。 + +## 参数 {#can-shu} + +- P - 精度。有效范围:\[1:38\],决定可以有多少个十进制数字(包括分数)。 +- S - 规模。有效范围:\[0:P\],决定数字的小数部分中包含的小数位数。 + +对于不同的 P 参数值 Decimal 表示,以下例子都是同义的: +-P从\[1:9\]-对于Decimal32(S) +-P从\[10:18\]-对于Decimal64(小号) +-P从\[19:38\]-对于Decimal128(S) + +## 十进制值范围 {#shi-jin-zhi-zhi-fan-wei} + +- Decimal32(S) - ( -1 \* 10^(9 - S),1\*10^(9-S) ) +- Decimal64(S) - ( -1 \* 10^(18 - S),1\*10^(18-S) ) +- Decimal128(S) - ( -1 \* 10^(38 - S),1\*10^(38-S) ) + +例如,Decimal32(4) 可以表示 -99999.9999 至 99999.9999 的数值,步长为0.0001。 + +## 内部表示方式 {#nei-bu-biao-shi-fang-shi} + +数据采用与自身位宽相同的有符号整数存储。这个数在内存中实际范围会高于上述范围,从 String 转换到十进制数的时候会做对应的检查。 + +由于现代CPU不支持128位数字,因此 Decimal128 上的操作由软件模拟。所以 Decimal128 的运算速度明显慢于 Decimal32/Decimal64。 + +## 运算和结果类型 {#yun-suan-he-jie-guo-lei-xing} + +对Decimal的二进制运算导致更宽的结果类型(无论参数的顺序如何)。 + +- `Decimal64(S1) Decimal32(S2) -> Decimal64(S)` +- `Decimal128(S1) Decimal32(S2) -> Decimal128(S)` +- `Decimal128(S1) Decimal64(S2) -> Decimal128(S)` + +精度变化的规则: + +- 加法,减法:S = max(S1, S2)。 +- 乘法:S = S1 + S2。 +- 除法:S = S1。 + +对于 Decimal 和整数之间的类似操作,结果是与参数大小相同的十进制。 + +未定义Decimal和Float32/Float64之间的函数。要执行此类操作,您可以使用:toDecimal32、toDecimal64、toDecimal128 或 toFloat32,toFloat64,需要显式地转换其中一个参数。注意,结果将失去精度,类型转换是昂贵的操作。 + +Decimal上的一些函数返回结果为Float64(例如,var或stddev)。对于其中一些,中间计算发生在Decimal中。对于此类函数,尽管结果类型相同,但Float64和Decimal中相同数据的结果可能不同。 + +## 溢出检查 {#yi-chu-jian-cha} + +在对 Decimal 类型执行操作时,数值可能会发生溢出。分数中的过多数字被丢弃(不是舍入的)。整数中的过多数字将导致异常。 + + SELECT toDecimal32(2, 4) AS x, x / 3 + + ┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ + │ 2.0000 │ 0.6666 │ + └────────┴──────────────────────────────┘ + + SELECT toDecimal32(4.2, 8) AS x, x * x + + DB::Exception: Scale is out of bounds. + + SELECT toDecimal32(4.2, 8) AS x, 6 * x + + DB::Exception: Decimal math overflow. + +检查溢出会导致计算变慢。如果已知溢出不可能,则可以通过设置`decimal_check_overflow`来禁用溢出检查,在这种情况下,溢出将导致结果不正确: + + SET decimal_check_overflow = 0; + SELECT toDecimal32(4.2, 8) AS x, 6 * x + + ┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ + │ 4.20000000 │ -17.74967296 │ + └────────────┴──────────────────────────────────┘ + +溢出检查不仅发生在算术运算上,还发生在比较运算上: + + SELECT toDecimal32(1, 8) < 100 + + DB::Exception: Can't compare. diff --git a/docs/zh/sql-reference/data-types/domains/index.md b/docs/zh/sql-reference/data-types/domains/index.md new file mode 100644 index 00000000000..e05c61e0dbb --- /dev/null +++ b/docs/zh/sql-reference/data-types/domains/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u57DF" +toc_priority: 56 +--- + + diff --git a/docs/zh/sql-reference/data-types/domains/ipv4.md b/docs/zh/sql-reference/data-types/domains/ipv4.md new file mode 100644 index 00000000000..65c066fb487 --- /dev/null +++ b/docs/zh/sql-reference/data-types/domains/ipv4.md @@ -0,0 +1,68 @@ +## IPv4 {#ipv4} + +`IPv4`是与`UInt32`类型保持二进制兼容的Domain类型,其用于存储IPv4地址的值。它提供了更为紧凑的二进制存储的同时支持识别可读性更加友好的输入输出格式。 + +### 基本使用 {#ji-ben-shi-yong} + +``` sql +CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY url; + +DESCRIBE TABLE hits; +``` + + ┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ + │ url │ String │ │ │ │ │ + │ from │ IPv4 │ │ │ │ │ + └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ + +同时您也可以使用`IPv4`类型的列作为主键: + +``` sql +CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; +``` + +在写入与查询时,`IPv4`类型能够识别可读性更加友好的输入输出格式: + +``` sql +INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.tech', '183.247.232.58')('https://clickhouse.yandex/docs/en/', '116.106.34.242'); + +SELECT * FROM hits; +``` + + ┌─url────────────────────────────────┬───────────from─┐ + │ https://clickhouse.tech/docs/en/ │ 116.106.34.242 │ + │ https://wikipedia.org │ 116.253.40.133 │ + │ https://clickhouse.tech │ 183.247.232.58 │ + └────────────────────────────────────┴────────────────┘ + +同时它提供更为紧凑的二进制存储格式: + +``` sql +SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; +``` + + ┌─toTypeName(from)─┬─hex(from)─┐ + │ IPv4 │ B7F7E83A │ + └──────────────────┴───────────┘ + +不可隐式转换为除`UInt32`以外的其他类型类型。如果要将`IPv4`类型的值转换成字符串,你可以使用`IPv4NumToString()`显示的进行转换: + +``` sql +SELECT toTypeName(s), IPv4NumToString(from) as s FROM hits LIMIT 1; +``` + + ┌─toTypeName(IPv4NumToString(from))─┬─s──────────────┐ + │ String │ 183.247.232.58 │ + └───────────────────────────────────┴────────────────┘ + +或可以使用`CAST`将它转换为`UInt32`类型: + +``` sql +SELECT toTypeName(i), CAST(from as UInt32) as i FROM hits LIMIT 1; +``` + + ┌─toTypeName(CAST(from, 'UInt32'))─┬──────────i─┐ + │ UInt32 │ 3086477370 │ + └──────────────────────────────────┴────────────┘ + +[来源文章](https://clickhouse.tech/docs/en/data_types/domains/ipv4) diff --git a/docs/zh/sql-reference/data-types/domains/ipv6.md b/docs/zh/sql-reference/data-types/domains/ipv6.md new file mode 100644 index 00000000000..bc0f95932aa --- /dev/null +++ b/docs/zh/sql-reference/data-types/domains/ipv6.md @@ -0,0 +1,68 @@ +## IPv6 {#ipv6} + +`IPv6`是与`FixedString(16)`类型保持二进制兼容的Domain类型,其用于存储IPv6地址的值。它提供了更为紧凑的二进制存储的同时支持识别可读性更加友好的输入输出格式。 + +### 基本用法 {#ji-ben-yong-fa} + +``` sql +CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url; + +DESCRIBE TABLE hits; +``` + + ┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ + │ url │ String │ │ │ │ │ + │ from │ IPv6 │ │ │ │ │ + └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ + +同时您也可以使用`IPv6`类型的列作为主键: + +``` sql +CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from; +``` + +在写入与查询时,`IPv6`类型能够识别可读性更加友好的输入输出格式: + +``` sql +INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.tech', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.yandex/docs/en/', '2a02:e980:1e::1'); + +SELECT * FROM hits; +``` + + ┌─url────────────────────────────────┬─from──────────────────────────┐ + │ https://clickhouse.tech │ 2001:44c8:129:2632:33:0:252:2 │ + │ https://clickhouse.tech/docs/en/ │ 2a02:e980:1e::1 │ + │ https://wikipedia.org │ 2a02:aa08:e000:3100::2 │ + └────────────────────────────────────┴───────────────────────────────┘ + +同时它提供更为紧凑的二进制存储格式: + +``` sql +SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; +``` + + ┌─toTypeName(from)─┬─hex(from)────────────────────────┐ + │ IPv6 │ 200144C8012926320033000002520002 │ + └──────────────────┴──────────────────────────────────┘ + +不可隐式转换为除`FixedString(16)`以外的其他类型类型。如果要将`IPv6`类型的值转换成字符串,你可以使用`IPv6NumToString()`显示的进行转换: + +``` sql +SELECT toTypeName(s), IPv6NumToString(from) as s FROM hits LIMIT 1; +``` + + ┌─toTypeName(IPv6NumToString(from))─┬─s─────────────────────────────┐ + │ String │ 2001:44c8:129:2632:33:0:252:2 │ + └───────────────────────────────────┴───────────────────────────────┘ + +或使用`CAST`将其转换为`FixedString(16)`: + +``` sql +SELECT toTypeName(i), CAST(from as FixedString(16)) as i FROM hits LIMIT 1; +``` + + ┌─toTypeName(CAST(from, 'FixedString(16)'))─┬─i───────┐ + │ FixedString(16) │ ��� │ + └───────────────────────────────────────────┴─────────┘ + +[来源文章](https://clickhouse.tech/docs/en/data_types/domains/ipv6) diff --git a/docs/zh/sql-reference/data-types/domains/overview.md b/docs/zh/sql-reference/data-types/domains/overview.md new file mode 100644 index 00000000000..689acb9cb60 --- /dev/null +++ b/docs/zh/sql-reference/data-types/domains/overview.md @@ -0,0 +1,26 @@ +# 域 {#domains} + +Domain类型是特定实现的类型,它总是与某个现存的基础类型保持二进制兼容的同时添加一些额外的特性,以能够在维持磁盘数据不变的情况下使用这些额外的特性。目前ClickHouse暂不支持自定义domain类型。 + +如果你可以在一个地方使用与Domain类型二进制兼容的基础类型,那么在相同的地方您也可以使用Domain类型,例如: + +- 使用Domain类型作为表中列的类型 +- 对Domain类型的列进行读/写数据 +- 如果与Domain二进制兼容的基础类型可以作为索引,那么Domain类型也可以作为索引 +- 将Domain类型作为参数传递给函数使用 +- 其他 + +### Domains的额外特性 {#domainsde-e-wai-te-xing} + +- 在执行SHOW CREATE TABLE 或 DESCRIBE TABLE时,其对应的列总是展示为Domain类型的名称 +- 在INSERT INTO domain\_table(domain\_column) VALUES(…)中输入数据总是以更人性化的格式进行输入 +- 在SELECT domain\_column FROM domain\_table中数据总是以更人性化的格式输出 +- 在INSERT INTO domain\_table FORMAT CSV …中,实现外部源数据以更人性化的格式载入 + +### Domains类型的限制 {#domainslei-xing-de-xian-zhi} + +- 无法通过`ALTER TABLE`将基础类型的索引转换为Domain类型的索引。 +- 当从其他列或表插入数据时,无法将string类型的值隐式地转换为Domain类型的值。 +- 无法对存储为Domain类型的值添加约束。 + +[来源文章](https://clickhouse.tech/docs/en/data_types/domains/overview) diff --git a/docs/zh/sql-reference/data-types/enum.md b/docs/zh/sql-reference/data-types/enum.md new file mode 100644 index 00000000000..a362b60a81d --- /dev/null +++ b/docs/zh/sql-reference/data-types/enum.md @@ -0,0 +1,100 @@ +# Enum8,Enum16 {#enum8-enum16} + +包括 `Enum8` 和 `Enum16` 类型。`Enum` 保存 `'string'= integer` 的对应关系。在 ClickHouse 中,尽管用户使用的是字符串常量,但所有含有 `Enum` 数据类型的操作都是按照包含整数的值来执行。这在性能方面比使用 `String` 数据类型更有效。 + +- `Enum8` 用 `'String'= Int8` 对描述。 +- `Enum16` 用 `'String'= Int16` 对描述。 + +## 用法示例 {#yong-fa-shi-li} + +创建一个带有一个枚举 `Enum8('hello' = 1, 'world' = 2)` 类型的列: + + CREATE TABLE t_enum + ( + x Enum8('hello' = 1, 'world' = 2) + ) + ENGINE = TinyLog + +这个 `x` 列只能存储类型定义中列出的值:`'hello'`或`'world'`。如果您尝试保存任何其他值,ClickHouse 抛出异常。 + + :) INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') + + INSERT INTO t_enum VALUES + + Ok. + + 3 rows in set. Elapsed: 0.002 sec. + + :) insert into t_enum values('a') + + INSERT INTO t_enum VALUES + + + Exception on client: + Code: 49. DB::Exception: Unknown element 'a' for type Enum8('hello' = 1, 'world' = 2) + +当您从表中查询数据时,ClickHouse 从 `Enum` 中输出字符串值。 + + SELECT * FROM t_enum + + ┌─x─────┐ + │ hello │ + │ world │ + │ hello │ + └───────┘ + +如果需要看到对应行的数值,则必须将 `Enum` 值转换为整数类型。 + + SELECT CAST(x, 'Int8') FROM t_enum + + ┌─CAST(x, 'Int8')─┐ + │ 1 │ + │ 2 │ + │ 1 │ + └─────────────────┘ + +在查询中创建枚举值,您还需要使用 `CAST`。 + + SELECT toTypeName(CAST('a', 'Enum8(\'a\' = 1, \'b\' = 2)')) + + ┌─toTypeName(CAST('a', 'Enum8(\'a\' = 1, \'b\' = 2)'))─┐ + │ Enum8('a' = 1, 'b' = 2) │ + └──────────────────────────────────────────────────────┘ + +## 规则及用法 {#gui-ze-ji-yong-fa} + +`Enum8` 类型的每个值范围是 `-128 ... 127`,`Enum16` 类型的每个值范围是 `-32768 ... 32767`。所有的字符串或者数字都必须是不一样的。允许存在空字符串。如果某个 Enum 类型被指定了(在表定义的时候),数字可以是任意顺序。然而,顺序并不重要。 + +`Enum` 中的字符串和数值都不能是 [NULL](../../sql-reference/data-types/enum.md)。 + +`Enum` 包含在 [可为空](nullable.md) 类型中。因此,如果您使用此查询创建一个表 + + CREATE TABLE t_enum_nullable + ( + x Nullable( Enum8('hello' = 1, 'world' = 2) ) + ) + ENGINE = TinyLog + +不仅可以存储 `'hello'` 和 `'world'` ,还可以存储 `NULL`。 + + INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) + +在内存中,`Enum` 列的存储方式与相应数值的 `Int8` 或 `Int16` 相同。 + +当以文本方式读取的时候,ClickHouse 将值解析成字符串然后去枚举值的集合中搜索对应字符串。如果没有找到,会抛出异常。当读取文本格式的时候,会根据读取到的字符串去找对应的数值。如果没有找到,会抛出异常。 + +当以文本形式写入时,ClickHouse 将值解析成字符串写入。如果列数据包含垃圾数据(不是来自有效集合的数字),则抛出异常。Enum 类型以二进制读取和写入的方式与 `Int8` 和 `Int16` 类型一样的。 + +隐式默认值是数值最小的值。 + +在 `ORDER BY`,`GROUP BY`,`IN`,`DISTINCT` 等等中,Enum 的行为与相应的数字相同。例如,按数字排序。对于等式运算符和比较运算符,Enum 的工作机制与它们在底层数值上的工作机制相同。 + +枚举值不能与数字进行比较。枚举可以与常量字符串进行比较。如果与之比较的字符串不是有效Enum值,则将引发异常。可以使用 IN 运算符来判断一个 Enum 是否存在于某个 Enum 集合中,其中集合中的 Enum 需要用字符串表示。 + +大多数具有数字和字符串的运算并不适用于Enums;例如,Enum 类型不能和一个数值相加。但是,Enum有一个原生的 `toString` 函数,它返回它的字符串值。 + +Enum 值使用 `toT` 函数可以转换成数值类型,其中 T 是一个数值类型。若 `T` 恰好对应 Enum 的底层数值类型,这个转换是零消耗的。 + +Enum 类型可以被 `ALTER` 无成本地修改对应集合的值。可以通过 `ALTER` 操作来增加或删除 Enum 的成员(只要表没有用到该值,删除都是安全的)。作为安全保障,改变之前使用过的 Enum 成员将抛出异常。 + +通过 `ALTER` 操作,可以将 `Enum8` 转成 `Enum16`,反之亦然,就像 `Int8` 转 `Int16`一样。 diff --git a/docs/zh/sql-reference/data-types/fixedstring.md b/docs/zh/sql-reference/data-types/fixedstring.md new file mode 100644 index 00000000000..45550e12b4e --- /dev/null +++ b/docs/zh/sql-reference/data-types/fixedstring.md @@ -0,0 +1,56 @@ +# 固定字符串 {#fixedstring} + +固定长度 N 的字符串(N 必须是严格的正自然数)。 + +您可以使用下面的语法对列声明为`FixedString`类型: + +``` sql + FixedString(N) +``` + +其中`N`表示自然数。 + +当数据的长度恰好为N个字节时,`FixedString`类型是高效的。 在其他情况下,这可能会降低效率。 + +可以有效存储在`FixedString`类型的列中的值的示例: + +- 二进制表示的IP地址(IPv6使用`FixedString(16)`) +- 语言代码(ru\_RU, en\_US … ) +- 货币代码(USD, RUB … ) +- 二进制表示的哈希值(MD5使用`FixedString(16)`,SHA256使用`FixedString(32)`) + +请使用[UUID](uuid.md)数据类型来存储UUID值,。 + +当向ClickHouse中插入数据时, + +- 如果字符串包含的字节数少于\`N’,将对字符串末尾进行空字节填充。 +- 如果字符串包含的字节数大于`N`,将抛出`Too large value for FixedString(N)`异常。 + +当做数据查询时,ClickHouse不会删除字符串末尾的空字节。 如果使用`WHERE`子句,则须要手动添加空字节以匹配`FixedString`的值。 以下示例阐明了如何将`WHERE`子句与`FixedString`一起使用。 + +考虑带有`FixedString(2)`列的表: + +``` text +┌─name──┐ +│ b │ +└───────┘ +``` + +查询语句`SELECT * FROM FixedStringTable WHERE a = 'b'` 不会返回任何结果。请使用空字节来填充筛选条件。 + +``` sql +SELECT * FROM FixedStringTable +WHERE a = 'b\0' +``` + +``` text +┌─a─┐ +│ b │ +└───┘ +``` + +这种方式与MySQL的`CHAR`类型的方式不同(MySQL中使用空格填充字符串,并在输出时删除空格)。 + +请注意,`FixedString(N)`的长度是个常量。仅由空字符组成的字符串,函数[length](../../sql-reference/functions/array-functions.md#array_functions-length)返回值为`N`,而函数[empty](../../sql-reference/functions/string-functions.md#empty)的返回值为`1`。 + +[来源文章](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/zh/sql-reference/data-types/float.md b/docs/zh/sql-reference/data-types/float.md new file mode 100644 index 00000000000..e0924eb0178 --- /dev/null +++ b/docs/zh/sql-reference/data-types/float.md @@ -0,0 +1,70 @@ +# Float32,Float64 {#float32-float64} + +[浮点数](https://en.wikipedia.org/wiki/IEEE_754)。 + +类型与以下 C 语言中类型是相同的: + +- `Float32` - `float` +- `Float64` - `double` + +我们建议您尽可能以整数形式存储数据。例如,将固定精度的数字转换为整数值,例如货币数量或页面加载时间用毫秒为单位表示 + +## 使用浮点数 {#shi-yong-fu-dian-shu} + +- 对浮点数进行计算可能引起四舍五入的误差。 + + + +``` sql +SELECT 1 - 0.9 +``` + + ┌───────minus(1, 0.9)─┐ + │ 0.09999999999999998 │ + └─────────────────────┘ + +- 计算的结果取决于计算方法(计算机系统的处理器类型和体系结构) + +- 浮点计算结果可能是诸如无穷大(`INF`)和«非数字»(`NaN`)。对浮点数计算的时候应该考虑到这点。 + +- 当一行行阅读浮点数的时候,浮点数的结果可能不是机器最近显示的数值。 + +## 南和Inf {#data_type-float-nan-inf} + +与标准SQL相比,ClickHouse 支持以下类别的浮点数: + +- `Inf` – 正无穷 + + + +``` sql +SELECT 0.5 / 0 +``` + + ┌─divide(0.5, 0)─┐ + │ inf │ + └────────────────┘ + +- `-Inf` – 负无穷 + + + +``` sql +SELECT -0.5 / 0 +``` + + ┌─divide(-0.5, 0)─┐ + │ -inf │ + └─────────────────┘ + +- `NaN` – 非数字 + + + + SELECT 0 / 0 + + ┌─divide(0, 0)─┐ + │ nan │ + └──────────────┘ + +可以在 [ORDER BY 子句](../../sql-reference/data-types/float.md) 查看更多关于 `NaN` 排序的规则。 diff --git a/docs/zh/sql-reference/data-types/index.md b/docs/zh/sql-reference/data-types/index.md new file mode 100644 index 00000000000..70aa976cb11 --- /dev/null +++ b/docs/zh/sql-reference/data-types/index.md @@ -0,0 +1,5 @@ +# 数据类型 {#data_types} + +ClickHouse 可以在数据表中存储多种数据类型。 + +本节描述 ClickHouse 支持的数据类型,以及使用或者实现它们时(如果有的话)的注意事项。 diff --git a/docs/zh/sql-reference/data-types/int-uint.md b/docs/zh/sql-reference/data-types/int-uint.md new file mode 100644 index 00000000000..3fb482639e7 --- /dev/null +++ b/docs/zh/sql-reference/data-types/int-uint.md @@ -0,0 +1,17 @@ +# UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} + +固定长度的整型,包括有符号整型或无符号整型。 + +## 整型范围 {#int-ranges} + +- Int8-\[-128:127\] +- Int16-\[-32768:32767\] +- Int32-\[-2147483648:2147483647\] +- Int64-\[-9223372036854775808:9223372036854775807\] + +## 无符号整型范围 {#uint-ranges} + +- UInt8-\[0:255\] +- UInt16-\[0:65535\] +- UInt32-\[0:4294967295\] +- UInt64-\[0:18446744073709551615\] diff --git a/docs/zh/sql-reference/data-types/lowcardinality.md b/docs/zh/sql-reference/data-types/lowcardinality.md new file mode 100644 index 00000000000..b8985691f0f --- /dev/null +++ b/docs/zh/sql-reference/data-types/lowcardinality.md @@ -0,0 +1,59 @@ +--- +toc_priority: 51 +toc_title: 低基数类型 +--- + +# 低基数类型 {#lowcardinality-data-type} + +把其它数据类型转变为字典编码类型。 + +## 语法 {#lowcardinality-syntax} + +```sql +LowCardinality(data_type) +``` + +**参数** + +- `data_type` — [String](string.md), [FixedString](fixedstring.md), [Date](date.md), [DateTime](datetime.md),包括数字类型,但是[Decimal](decimal.md)除外。对一些数据类型来说,`LowCardinality` 并不高效,详查[allow_suspicious_low_cardinality_types](../../operations/settings/settings.md#allow_suspicious_low_cardinality_types)设置描述。 + +## 描述 {#lowcardinality-dscr} + +`LowCardinality` 是一种改变数据存储和数据处理方法的概念。 ClickHouse会把 `LowCardinality` 所在的列进行[dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)。对很多应用来说,处理字典编码的数据可以显著的增加[SELECT](../statements/select/index.md)查询速度。 + +使用 `LowCarditality` 数据类型的效率依赖于数据的多样性。如果一个字典包含少于10000个不同的值,那么ClickHouse可以进行更高效的数据存储和处理。反之如果字典多于10000,效率会表现的更差。 + +当使用字符类型的时候,可以考虑使用 `LowCardinality` 代替[Enum](enum.md)。 `LowCardinality` 通常更加灵活和高效。 + +## 例子 + +创建一个 `LowCardinality` 类型的列: + +```sql +CREATE TABLE lc_t +( + `id` UInt16, + `strings` LowCardinality(String) +) +ENGINE = MergeTree() +ORDER BY id +``` + +## 相关的设置和函数 + +设置: + +- [low_cardinality_max_dictionary_size](../../operations/settings/settings.md#low_cardinality_max_dictionary_size) +- [low_cardinality_use_single_dictionary_for_part](../../operations/settings/settings.md#low_cardinality_use_single_dictionary_for_part) +- [low_cardinality_allow_in_native_format](../../operations/settings/settings.md#low_cardinality_allow_in_native_format) +- [allow_suspicious_low_cardinality_types](../../operations/settings/settings.md#allow_suspicious_low_cardinality_types) + +函数: + +- [toLowCardinality](../functions/type-conversion-functions.md#tolowcardinality) + +## 参考 + +- [高效低基数类型](https://www.altinity.com/blog/2019/3/27/low-cardinality). +- [使用低基数类型减少ClickHouse的存储成本 – 来自Instana工程师的分享](https://www.instana.com/blog/reducing-clickhouse-storage-cost-with-the-low-cardinality-type-lessons-from-an-instana-engineer/). +- [字符优化 (俄语视频分享)](https://youtu.be/rqf-ILRgBdY?list=PL0Z2YDlm0b3iwXCpEFiOOYmwXzVmjJfEt). [英语分享](https://github.com/yandex/clickhouse-presentations/raw/master/meetup19/string_optimization.pdf). \ No newline at end of file diff --git a/docs/zh/sql-reference/data-types/nested-data-structures/index.md b/docs/zh/sql-reference/data-types/nested-data-structures/index.md new file mode 100644 index 00000000000..3914064674e --- /dev/null +++ b/docs/zh/sql-reference/data-types/nested-data-structures/index.md @@ -0,0 +1 @@ +# 嵌套数据结构 {#qian-tao-shu-ju-jie-gou} diff --git a/docs/zh/sql-reference/data-types/nested-data-structures/nested.md b/docs/zh/sql-reference/data-types/nested-data-structures/nested.md new file mode 100644 index 00000000000..d2fd1e3a630 --- /dev/null +++ b/docs/zh/sql-reference/data-types/nested-data-structures/nested.md @@ -0,0 +1,97 @@ +# Nested(Name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} + +嵌套数据结构类似于嵌套表。嵌套数据结构的参数(列名和类型)与 CREATE 查询类似。每个表可以包含任意多行嵌套数据结构。 + +示例: + +``` sql +CREATE TABLE test.visits +( + CounterID UInt32, + StartDate Date, + Sign Int8, + IsNew UInt8, + VisitID UInt64, + UserID UInt64, + ... + Goals Nested + ( + ID UInt32, + Serial UInt32, + EventTime DateTime, + Price Int64, + OrderID String, + CurrencyID UInt32 + ), + ... +) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) +``` + +上述示例声明了 `Goals` 这种嵌套数据结构,它包含访客转化相关的数据(访客达到的目标)。在 ‘visits’ 表中每一行都可以对应零个或者任意个转化数据。 + +只支持一级嵌套。嵌套结构的列中,若列的类型是数组类型,那么该列其实和多维数组是相同的,所以目前嵌套层级的支持很局限(MergeTree 引擎中不支持存储这样的列) + +大多数情况下,处理嵌套数据结构时,会指定一个单独的列。为了这样实现,列的名称会与点号连接起来。这些列构成了一组匹配类型。在同一条嵌套数据中,所有的列都具有相同的长度。 + +示例: + +``` sql +SELECT + Goals.ID, + Goals.EventTime +FROM test.visits +WHERE CounterID = 101500 AND length(Goals.ID) < 5 +LIMIT 10 +``` + +``` text +┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ +│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ +│ [1073752] │ ['2014-03-17 00:28:25'] │ +│ [1073752] │ ['2014-03-17 10:46:20'] │ +│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ +│ [] │ [] │ +│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ +│ [] │ [] │ +│ [] │ [] │ +│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ +│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ +└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +所以可以简单地把嵌套数据结构当做是所有列都是相同长度的多列数组。 + +SELECT 查询只有在使用 ARRAY JOIN 的时候才可以指定整个嵌套数据结构的名称。更多信息,参考 «ARRAY JOIN 子句»。示例: + +``` sql +SELECT + Goal.ID, + Goal.EventTime +FROM test.visits +ARRAY JOIN Goals AS Goal +WHERE CounterID = 101500 AND length(Goals.ID) < 5 +LIMIT 10 +``` + +``` text +┌─Goal.ID─┬──────Goal.EventTime─┐ +│ 1073752 │ 2014-03-17 16:38:10 │ +│ 591325 │ 2014-03-17 16:38:48 │ +│ 591325 │ 2014-03-17 16:42:27 │ +│ 1073752 │ 2014-03-17 00:28:25 │ +│ 1073752 │ 2014-03-17 10:46:20 │ +│ 1073752 │ 2014-03-17 13:59:20 │ +│ 591325 │ 2014-03-17 22:17:55 │ +│ 591325 │ 2014-03-17 22:18:07 │ +│ 591325 │ 2014-03-17 22:18:51 │ +│ 1073752 │ 2014-03-17 11:37:06 │ +└─────────┴─────────────────────┘ +``` + +不能对整个嵌套数据结构执行 SELECT。只能明确列出属于它一部分列。 + +对于 INSERT 查询,可以单独地传入所有嵌套数据结构中的列数组(假如它们是单独的列数组)。在插入过程中,系统会检查它们是否有相同的长度。 + +对于 DESCRIBE 查询,嵌套数据结构中的列会以相同的方式分别列出来。 + +ALTER 查询对嵌套数据结构的操作非常有限。 diff --git a/docs/zh/sql-reference/data-types/nullable.md b/docs/zh/sql-reference/data-types/nullable.md new file mode 100644 index 00000000000..8e8e9d3b0af --- /dev/null +++ b/docs/zh/sql-reference/data-types/nullable.md @@ -0,0 +1,41 @@ +# 可为空(类型名称) {#data_type-nullable} + +允许用特殊标记 ([NULL](../../sql-reference/data-types/nullable.md)) 表示«缺失值»,可以与 `TypeName` 的正常值存放一起。例如,`Nullable(Int8)` 类型的列可以存储 `Int8` 类型值,而没有值的行将存储 `NULL`。 + +对于 `TypeName`,不能使用复合数据类型 [阵列](array.md) 和 [元组](tuple.md)。复合数据类型可以包含 `Nullable` 类型值,例如`Array(Nullable(Int8))`。 + +`Nullable` 类型字段不能包含在表索引中。 + +除非在 ClickHouse 服务器配置中另有说明,否则 `NULL` 是任何 `Nullable` 类型的默认值。 + +## 存储特性 {#cun-chu-te-xing} + +要在表的列中存储 `Nullable` 类型值,ClickHouse 除了使用带有值的普通文件外,还使用带有 `NULL` 掩码的单独文件。 掩码文件中的条目允许 ClickHouse 区分每个表行的 `NULL` 和相应数据类型的默认值。 由于附加了新文件,`Nullable` 列与类似的普通文件相比消耗额外的存储空间。 + +!!! 注意点 "注意点" + 使用 `Nullable` 几乎总是对性能产生负面影响,在设计数据库时请记住这一点 + +掩码文件中的条目允许ClickHouse区分每个表行的对应数据类型的«NULL»和默认值由于有额外的文件,«Nullable»列比普通列消耗更多的存储空间 + +## 用法示例 {#yong-fa-shi-li} + +``` sql +CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog +``` + +``` sql +INSERT INTO t_null VALUES (1, NULL), (2, 3) +``` + +``` sql +SELECT x + y FROM t_null +``` + +``` text +┌─plus(x, y)─┐ +│ ᴺᵁᴸᴸ │ +│ 5 │ +└────────────┘ +``` + +[来源文章](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/zh/sql-reference/data-types/simpleaggregatefunction.md b/docs/zh/sql-reference/data-types/simpleaggregatefunction.md new file mode 120000 index 00000000000..76a7ef3b802 --- /dev/null +++ b/docs/zh/sql-reference/data-types/simpleaggregatefunction.md @@ -0,0 +1 @@ +../../../en/sql-reference/data-types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/zh/sql-reference/data-types/special-data-types/expression.md b/docs/zh/sql-reference/data-types/special-data-types/expression.md new file mode 100644 index 00000000000..e0618aa2aaa --- /dev/null +++ b/docs/zh/sql-reference/data-types/special-data-types/expression.md @@ -0,0 +1,3 @@ +# 表达式 {#expression} + +用于表示高阶函数中的Lambd表达式。 diff --git a/docs/zh/sql-reference/data-types/special-data-types/index.md b/docs/zh/sql-reference/data-types/special-data-types/index.md new file mode 100644 index 00000000000..1c104f51d43 --- /dev/null +++ b/docs/zh/sql-reference/data-types/special-data-types/index.md @@ -0,0 +1,3 @@ +# 特殊数据类型 {#special-data-types} + +特殊数据类型的值既不能存在表中也不能在结果中输出,但可用于查询的中间结果。 diff --git a/docs/zh/sql-reference/data-types/special-data-types/interval.md b/docs/zh/sql-reference/data-types/special-data-types/interval.md new file mode 100644 index 00000000000..df2ce097df0 --- /dev/null +++ b/docs/zh/sql-reference/data-types/special-data-types/interval.md @@ -0,0 +1,85 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 61 +toc_title: "\u95F4\u9694" +--- + +# 间隔 {#data-type-interval} + +表示时间和日期间隔的数据类型族。 由此产生的类型 [INTERVAL](../../../sql-reference/operators/index.md#operator-interval) 接线员 + +!!! warning "警告" + `Interval` 数据类型值不能存储在表中。 + +结构: + +- 时间间隔作为无符号整数值。 +- 间隔的类型。 + +支持的时间间隔类型: + +- `SECOND` +- `MINUTE` +- `HOUR` +- `DAY` +- `WEEK` +- `MONTH` +- `QUARTER` +- `YEAR` + +对于每个间隔类型,都有一个单独的数据类型。 例如, `DAY` 间隔对应于 `IntervalDay` 数据类型: + +``` sql +SELECT toTypeName(INTERVAL 4 DAY) +``` + +``` text +┌─toTypeName(toIntervalDay(4))─┐ +│ IntervalDay │ +└──────────────────────────────┘ +``` + +## 使用说明 {#data-type-interval-usage-remarks} + +您可以使用 `Interval`-在算术运算类型值 [日期](../../../sql-reference/data-types/date.md) 和 [日期时间](../../../sql-reference/data-types/datetime.md)-类型值。 例如,您可以将4天添加到当前时间: + +``` sql +SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY +``` + +``` text +┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ +│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ +└─────────────────────┴───────────────────────────────┘ +``` + +不同类型的间隔不能合并。 你不能使用间隔,如 `4 DAY 1 HOUR`. 以小于或等于间隔的最小单位的单位指定间隔,例如,间隔 `1 day and an hour` 间隔可以表示为 `25 HOUR` 或 `90000 SECOND`. + +你不能执行算术运算 `Interval`-类型值,但你可以添加不同类型的时间间隔,因此值 `Date` 或 `DateTime` 数据类型。 例如: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +以下查询将导致异常: + +``` sql +select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) +``` + +``` text +Received exception from server (version 19.14.1): +Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. +``` + +## 另请参阅 {#see-also} + +- [INTERVAL](../../../sql-reference/operators/index.md#operator-interval) 接线员 +- [toInterval](../../../sql-reference/functions/type-conversion-functions.md#function-tointerval) 类型转换函数 diff --git a/docs/zh/sql-reference/data-types/special-data-types/nothing.md b/docs/zh/sql-reference/data-types/special-data-types/nothing.md new file mode 100644 index 00000000000..52c705522e5 --- /dev/null +++ b/docs/zh/sql-reference/data-types/special-data-types/nothing.md @@ -0,0 +1,19 @@ +# 没什么 {#nothing} + +此数据类型的唯一目的是表示不是期望值的情况。 所以不能创建一个 `Nothing` 类型的值。 + +例如,文本 [NULL](../../../sql-reference/data-types/special-data-types/nothing.md#null-literal) 的类型为 `Nullable(Nothing)`。详情请见 [可为空](../../../sql-reference/data-types/special-data-types/nothing.md)。 + +`Nothing` 类型也可以用来表示空数组: + +``` bash +:) SELECT toTypeName(array()) + +SELECT toTypeName([]) + +┌─toTypeName(array())─┐ +│ Array(Nothing) │ +└─────────────────────┘ + +1 rows in set. Elapsed: 0.062 sec. +``` diff --git a/docs/zh/sql-reference/data-types/special-data-types/set.md b/docs/zh/sql-reference/data-types/special-data-types/set.md new file mode 100644 index 00000000000..f814ab04325 --- /dev/null +++ b/docs/zh/sql-reference/data-types/special-data-types/set.md @@ -0,0 +1,3 @@ +# 设置 {#set} + +可以用在 IN 表达式的右半部分。 diff --git a/docs/zh/sql-reference/data-types/string.md b/docs/zh/sql-reference/data-types/string.md new file mode 100644 index 00000000000..ab0fbc450e7 --- /dev/null +++ b/docs/zh/sql-reference/data-types/string.md @@ -0,0 +1,10 @@ +# 字符串 {#string} + +字符串可以任意长度的。它可以包含任意的字节集,包含空字节。因此,字符串类型可以代替其他 DBMSs 中的 VARCHAR、BLOB、CLOB 等类型。 + +## 编码 {#bian-ma} + +ClickHouse 没有编码的概念。字符串可以是任意的字节集,按它们原本的方式进行存储和输出。 +若需存储文本,我们建议使用 UTF-8 编码。至少,如果你的终端使用UTF-8(推荐),这样读写就不需要进行任何的转换了。 +同样,对不同的编码文本 ClickHouse 会有不同处理字符串的函数。 +比如,`length` 函数可以计算字符串包含的字节数组的长度,然而 `lengthUTF8` 函数是假设字符串以 UTF-8 编码,计算的是字符串包含的 Unicode 字符的长度。 diff --git a/docs/zh/sql-reference/data-types/tuple.md b/docs/zh/sql-reference/data-types/tuple.md new file mode 100644 index 00000000000..14e13e61d32 --- /dev/null +++ b/docs/zh/sql-reference/data-types/tuple.md @@ -0,0 +1,45 @@ +# Tuple(T1, T2, …) {#tuplet1-t2} + +元组,其中每个元素都有单独的 [类型](index.md#data_types)。 + +不能在表中存储元组(除了内存表)。它们可以用于临时列分组。在查询中,IN 表达式和带特定参数的 lambda 函数可以来对临时列进行分组。更多信息,请参阅 [IN 操作符](../../sql-reference/data-types/tuple.md) 和 [高阶函数](../../sql-reference/data-types/tuple.md)。 + +元组可以是查询的结果。在这种情况下,对于JSON以外的文本格式,括号中的值是逗号分隔的。在JSON格式中,元组作为数组输出(在方括号中)。 + +## 创建元组 {#chuang-jian-yuan-zu} + +可以使用函数来创建元组: + + tuple(T1, T2, ...) + +创建元组的示例: + + :) SELECT tuple(1,'a') AS x, toTypeName(x) + + SELECT + (1, 'a') AS x, + toTypeName(x) + + ┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ + │ (1,'a') │ Tuple(UInt8, String) │ + └─────────┴───────────────────────────┘ + + 1 rows in set. Elapsed: 0.021 sec. + +## 元组中的数据类型 {#yuan-zu-zhong-de-shu-ju-lei-xing} + +在动态创建元组时,ClickHouse 会自动为元组的每一个参数赋予最小可表达的类型。如果参数为 [NULL](../../sql-reference/data-types/tuple.md#null-literal),那这个元组对应元素是 [可为空](nullable.md)。 + +自动数据类型检测示例: + + SELECT tuple(1, NULL) AS x, toTypeName(x) + + SELECT + (1, NULL) AS x, + toTypeName(x) + + ┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ + │ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ + └──────────┴─────────────────────────────────┘ + + 1 rows in set. Elapsed: 0.002 sec. diff --git a/docs/zh/sql-reference/data-types/uuid.md b/docs/zh/sql-reference/data-types/uuid.md new file mode 100644 index 00000000000..2ff1e391e81 --- /dev/null +++ b/docs/zh/sql-reference/data-types/uuid.md @@ -0,0 +1,77 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: UUID +--- + +# UUID {#uuid-data-type} + +通用唯一标识符(UUID)是用于标识记录的16字节数。 有关UUID的详细信息,请参阅 [维基百科](https://en.wikipedia.org/wiki/Universally_unique_identifier). + +UUID类型值的示例如下所示: + +``` text +61f0c404-5cb3-11e7-907b-a6006ad3dba0 +``` + +如果在插入新记录时未指定UUID列值,则UUID值将用零填充: + +``` text +00000000-0000-0000-0000-000000000000 +``` + +## 如何生成 {#how-to-generate} + +要生成UUID值,ClickHouse提供了 [generateuidv4](../../sql-reference/functions/uuid-functions.md) 功能。 + +## 用法示例 {#usage-example} + +**示例1** + +此示例演示如何创建具有UUID类型列的表并将值插入到表中。 + +``` sql +CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog +``` + +``` sql +INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +└──────────────────────────────────────┴───────────┘ +``` + +**示例2** + +在此示例中,插入新记录时未指定UUID列值。 + +``` sql +INSERT INTO t_uuid (y) VALUES ('Example 2') +``` + +``` sql +SELECT * FROM t_uuid +``` + +``` text +┌────────────────────────────────────x─┬─y─────────┐ +│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ +│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ +└──────────────────────────────────────┴───────────┘ +``` + +## 限制 {#restrictions} + +UUID数据类型仅支持以下功能 [字符串](string.md) 数据类型也支持(例如, [min](../../sql-reference/aggregate-functions/reference.md#agg_function-min), [max](../../sql-reference/aggregate-functions/reference.md#agg_function-max),和 [计数](../../sql-reference/aggregate-functions/reference.md#agg_function-count)). + +算术运算不支持UUID数据类型(例如, [abs](../../sql-reference/functions/arithmetic-functions.md#arithm_func-abs))或聚合函数,例如 [sum](../../sql-reference/aggregate-functions/reference.md#agg_function-sum) 和 [avg](../../sql-reference/aggregate-functions/reference.md#agg_function-avg). + +[原始文章](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md new file mode 100644 index 00000000000..0b473f0c816 --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-hierarchical.md @@ -0,0 +1,70 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: "\u5206\u5C42\u5B57\u5178" +--- + +# 分层字典 {#hierarchical-dictionaries} + +ClickHouse支持分层字典与 [数字键](external-dicts-dict-structure.md#ext_dict-numeric-key). + +看看下面的层次结构: + +``` text +0 (Common parent) +│ +├── 1 (Russia) +│ │ +│ └── 2 (Moscow) +│ │ +│ └── 3 (Center) +│ +└── 4 (Great Britain) + │ + └── 5 (London) +``` + +这种层次结构可以表示为下面的字典表。 + +| region\_id | parent\_region | region\_name | +|------------|----------------|--------------| +| 1 | 0 | 俄罗斯 | +| 2 | 1 | 莫斯科 | +| 3 | 2 | 中心 | +| 4 | 0 | 英国 | +| 5 | 4 | 伦敦 | + +此表包含一列 `parent_region` 包含该元素的最近父项的键。 + +ClickHouse支持 [等级](external-dicts-dict-structure.md#hierarchical-dict-attr) 属性为 [外部字典](index.md) 属性。 此属性允许您配置类似于上述的分层字典。 + +该 [独裁主义](../../../sql-reference/functions/ext-dict-functions.md#dictgethierarchy) 函数允许您获取元素的父链。 + +对于我们的例子,dictionary的结构可以是以下内容: + +``` xml + + + + region_id + + + + parent_region + UInt64 + 0 + true + + + + region_name + String + + + + + +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md new file mode 100644 index 00000000000..0843a6a535a --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -0,0 +1,396 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u5728\u5185\u5B58\u4E2D\u5B58\u50A8\u5B57\u5178" +--- + +# 在内存中存储字典 {#dicts-external-dicts-dict-layout} + +有多种方法可以将字典存储在内存中。 + +我们建议 [平](#flat), [散列](#dicts-external_dicts_dict_layout-hashed) 和 [complex\_key\_hashed](#complex-key-hashed). 其提供最佳的处理速度。 + +不建议使用缓存,因为性能可能较差,并且难以选择最佳参数。 阅读更多的部分 “[缓存](#cache)”. + +有几种方法可以提高字典性能: + +- 调用该函数以使用后的字典 `GROUP BY`. +- 将要提取的属性标记为"注射"。 如果不同的属性值对应于不同的键,则称为注射属性。 所以当 `GROUP BY` 使用由键获取属性值的函数,此函数会自动取出 `GROUP BY`. + +ClickHouse为字典中的错误生成异常。 错误示例: + +- 无法加载正在访问的字典。 +- 查询错误 `cached` 字典 + +您可以查看外部字典的列表及其状态 `system.dictionaries` 桌子 + +配置如下所示: + +``` xml + + + ... + + + + + + ... + + +``` + +相应的 [DDL-查询](../../statements/create.md#create-dictionary-query): + +``` sql +CREATE DICTIONARY (...) +... +LAYOUT(LAYOUT_TYPE(param value)) -- layout settings +... +``` + +## 在内存中存储字典的方法 {#ways-to-store-dictionaries-in-memory} + +- [平](#flat) +- [散列](#dicts-external_dicts_dict_layout-hashed) +- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) +- [缓存](#cache) +- [直接](#direct) +- [range\_hashed](#range-hashed) +- [complex\_key\_hashed](#complex-key-hashed) +- [complex\_key\_cache](#complex-key-cache) +- [ip\_trie](#ip-trie) + +### 平 {#flat} + +字典以平面数组的形式完全存储在内存中。 字典使用多少内存? 量与最大键的大小(在使用的空间中)成正比。 + +字典键具有 `UInt64` 类型和值限制为500,000。 如果在创建字典时发现较大的键,ClickHouse将引发异常,不会创建字典。 + +支持所有类型的来源。 更新时,数据(来自文件或表)将完整读取。 + +此方法在存储字典的所有可用方法中提供了最佳性能。 + +配置示例: + +``` xml + + + +``` + +或 + +``` sql +LAYOUT(FLAT()) +``` + +### 散列 {#dicts-external_dicts_dict_layout-hashed} + +该字典以哈希表的形式完全存储在内存中。 字典中可以包含任意数量的带有任意标识符的元素,在实践中,键的数量可以达到数千万项。 + +支持所有类型的来源。 更新时,数据(来自文件或表)将完整读取。 + +配置示例: + +``` xml + + + +``` + +或 + +``` sql +LAYOUT(HASHED()) +``` + +### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} + +类似于 `hashed`,但使用更少的内存,有利于更多的CPU使用率。 + +配置示例: + +``` xml + + + +``` + +``` sql +LAYOUT(SPARSE_HASHED()) +``` + +### complex\_key\_hashed {#complex-key-hashed} + +这种类型的存储是用于复合 [键](external-dicts-dict-structure.md). 类似于 `hashed`. + +配置示例: + +``` xml + + + +``` + +``` sql +LAYOUT(COMPLEX_KEY_HASHED()) +``` + +### range\_hashed {#range-hashed} + +字典以哈希表的形式存储在内存中,其中包含有序范围及其相应值的数组。 + +此存储方法的工作方式与散列方式相同,除了键之外,还允许使用日期/时间(任意数字类型)范围。 + +示例:该表格包含每个广告客户的折扣,格式为: + +``` text ++---------|-------------|-------------|------+ +| advertiser id | discount start date | discount end date | amount | ++===============+=====================+===================+========+ +| 123 | 2015-01-01 | 2015-01-15 | 0.15 | ++---------|-------------|-------------|------+ +| 123 | 2015-01-16 | 2015-01-31 | 0.25 | ++---------|-------------|-------------|------+ +| 456 | 2015-01-01 | 2015-01-15 | 0.05 | ++---------|-------------|-------------|------+ +``` + +要对日期范围使用示例,请定义 `range_min` 和 `range_max` 中的元素 [结构](external-dicts-dict-structure.md). 这些元素必须包含元素 `name` 和`type` (如果 `type` 如果没有指定,则默认类型将使用-Date)。 `type` 可以是任何数字类型(Date/DateTime/UInt64/Int32/others)。 + +示例: + +``` xml + + + Id + + + first + Date + + + last + Date + + ... +``` + +或 + +``` sql +CREATE DICTIONARY somedict ( + id UInt64, + first Date, + last Date +) +PRIMARY KEY id +LAYOUT(RANGE_HASHED()) +RANGE(MIN first MAX last) +``` + +要使用这些字典,您需要将附加参数传递给 `dictGetT` 函数,为其选择一个范围: + +``` sql +dictGetT('dict_name', 'attr_name', id, date) +``` + +此函数返回指定的值 `id`s和包含传递日期的日期范围。 + +算法的详细信息: + +- 如果 `id` 未找到或范围未找到 `id`,它返回字典的默认值。 +- 如果存在重叠范围,则可以使用任意范围。 +- 如果范围分隔符是 `NULL` 或无效日期(如1900-01-01或2039-01-01),范围保持打开状态。 范围可以在两侧打开。 + +配置示例: + +``` xml + + + + ... + + + + + + + + Abcdef + + + StartTimeStamp + UInt64 + + + EndTimeStamp + UInt64 + + + XXXType + String + + + + + + +``` + +或 + +``` sql +CREATE DICTIONARY somedict( + Abcdef UInt64, + StartTimeStamp UInt64, + EndTimeStamp UInt64, + XXXType String DEFAULT '' +) +PRIMARY KEY Abcdef +RANGE(MIN StartTimeStamp MAX EndTimeStamp) +``` + +### 缓存 {#cache} + +字典存储在具有固定数量的单元格的缓存中。 这些单元格包含经常使用的元素。 + +搜索字典时,首先搜索缓存。 对于每个数据块,所有在缓存中找不到或过期的密钥都从源请求,使用 `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. 然后将接收到的数据写入高速缓存。 + +对于缓存字典,过期 [使用寿命](external-dicts-dict-lifetime.md) 可以设置高速缓存中的数据。 如果更多的时间比 `lifetime` 自从在单元格中加载数据以来,单元格的值不被使用,并且在下次需要使用时重新请求它。 +这是存储字典的所有方法中最不有效的。 缓存的速度在很大程度上取决于正确的设置和使用场景。 缓存类型字典只有在命中率足够高(推荐99%或更高)时才能表现良好。 您可以查看平均命中率 `system.dictionaries` 桌子 + +要提高缓存性能,请使用以下子查询 `LIMIT`,并从外部调用字典函数。 + +支持 [来源](external-dicts-dict-sources.md):MySQL的,ClickHouse的,可执行文件,HTTP. + +设置示例: + +``` xml + + + + 1000000000 + + +``` + +或 + +``` sql +LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) +``` + +设置足够大的缓存大小。 你需要尝试选择细胞的数量: + +1. 设置一些值。 +2. 运行查询,直到缓存完全满。 +3. 使用评估内存消耗 `system.dictionaries` 桌子 +4. 增加或减少单元数,直到达到所需的内存消耗。 + +!!! warning "警告" + 不要使用ClickHouse作为源,因为处理随机读取的查询速度很慢。 + +### complex\_key\_cache {#complex-key-cache} + +这种类型的存储是用于复合 [键](external-dicts-dict-structure.md). 类似于 `cache`. + +### 直接 {#direct} + +字典不存储在内存中,并且在处理请求期间直接转到源。 + +字典键具有 `UInt64` 类型。 + +所有类型的 [来源](external-dicts-dict-sources.md),除了本地文件,支持。 + +配置示例: + +``` xml + + + +``` + +或 + +``` sql +LAYOUT(DIRECT()) +``` + +### ip\_trie {#ip-trie} + +这种类型的存储用于将网络前缀(IP地址)映射到ASN等元数据。 + +示例:该表包含网络前缀及其对应的AS号码和国家代码: + +``` text + +-----------|-----|------+ + | prefix | asn | cca2 | + +=================+=======+========+ + | 202.79.32.0/20 | 17501 | NP | + +-----------|-----|------+ + | 2620:0:870::/48 | 3856 | US | + +-----------|-----|------+ + | 2a02:6b8:1::/48 | 13238 | RU | + +-----------|-----|------+ + | 2001:db8::/32 | 65536 | ZZ | + +-----------|-----|------+ +``` + +使用此类布局时,结构必须具有复合键。 + +示例: + +``` xml + + + + prefix + String + + + + asn + UInt32 + + + + cca2 + String + ?? + + ... +``` + +或 + +``` sql +CREATE DICTIONARY somedict ( + prefix String, + asn UInt32, + cca2 String DEFAULT '??' +) +PRIMARY KEY prefix +``` + +该键必须只有一个包含允许的IP前缀的字符串类型属性。 还不支持其他类型。 + +对于查询,必须使用相同的函数 (`dictGetT` 与元组)至于具有复合键的字典: + +``` sql +dictGetT('dict_name', 'attr_name', tuple(ip)) +``` + +该函数采用任一 `UInt32` 对于IPv4,或 `FixedString(16)` 碌莽禄Ipv6拢IPv6: + +``` sql +dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) +``` + +还不支持其他类型。 该函数返回与此IP地址对应的前缀的属性。 如果有重叠的前缀,则返回最具体的前缀。 + +数据存储在一个 `trie`. 它必须完全适合RAM。 + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md new file mode 100644 index 00000000000..af944fd9aea --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md @@ -0,0 +1,91 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: "\u5B57\u5178\u66F4\u65B0" +--- + +# 字典更新 {#dictionary-updates} + +ClickHouse定期更新字典。 完全下载字典的更新间隔和缓存字典的无效间隔在 `` 在几秒钟内标记。 + +字典更新(除首次使用的加载之外)不会阻止查询。 在更新期间,将使用旧版本的字典。 如果在更新过程中发生错误,则将错误写入服务器日志,并使用旧版本的字典继续查询。 + +设置示例: + +``` xml + + ... + 300 + ... + +``` + +``` sql +CREATE DICTIONARY (...) +... +LIFETIME(300) +... +``` + +设置 `0` (`LIFETIME(0)`)防止字典更新。 + +您可以设置升级的时间间隔,ClickHouse将在此范围内选择一个统一的随机时间。 为了在大量服务器上升级时分配字典源上的负载,这是必要的。 + +设置示例: + +``` xml + + ... + + 300 + 360 + + ... + +``` + +或 + +``` sql +LIFETIME(MIN 300 MAX 360) +``` + +如果 `0` 和 `0`,ClickHouse不会按超时重新加载字典。 +在这种情况下,如果字典配置文件已更改,ClickHouse可以更早地重新加载字典 `SYSTEM RELOAD DICTIONARY` 命令被执行。 + +升级字典时,ClickHouse服务器根据字典的类型应用不同的逻辑 [来源](external-dicts-dict-sources.md): + +升级字典时,ClickHouse服务器根据字典的类型应用不同的逻辑 [来源](external-dicts-dict-sources.md): + +- 对于文本文件,它检查修改的时间。 如果时间与先前记录的时间不同,则更新字典。 +- 对于MyISAM表,修改的时间使用检查 `SHOW TABLE STATUS` 查询。 +- 默认情况下,每次都会更新来自其他来源的字典。 + +对于MySQL(InnoDB),ODBC和ClickHouse源代码,您可以设置一个查询,只有在字典真正改变时才会更新字典,而不是每次都更新。 为此,请按照下列步骤操作: + +- 字典表必须具有在源数据更新时始终更改的字段。 +- 源的设置必须指定检索更改字段的查询。 ClickHouse服务器将查询结果解释为一行,如果此行相对于其以前的状态发生了更改,则更新字典。 指定查询 `` 字段中的设置 [来源](external-dicts-dict-sources.md). + +设置示例: + +``` xml + + ... + + ... + SELECT update_time FROM dictionary_source where id = 1 + + ... + +``` + +或 + +``` sql +... +SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) +... +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md new file mode 100644 index 00000000000..f981f442fb6 --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md @@ -0,0 +1,630 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: "\u5916\u90E8\u5B57\u5178\u7684\u6765\u6E90" +--- + +# 外部字典的来源 {#dicts-external-dicts-dict-sources} + +外部字典可以从许多不同的来源连接。 + +如果使用xml-file配置字典,则配置如下所示: + +``` xml + + + ... + + + + + + ... + + ... + +``` + +在情况下 [DDL-查询](../../statements/create.md#create-dictionary-query),相等的配置将看起来像: + +``` sql +CREATE DICTIONARY dict_name (...) +... +SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration +... +``` + +源配置在 `source` 科。 + +对于源类型 [本地文件](#dicts-external_dicts_dict_sources-local_file), [可执行文件](#dicts-external_dicts_dict_sources-executable), [HTTP(s)](#dicts-external_dicts_dict_sources-http), [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) +可选设置: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + + 0 + + +``` + +或 + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +SETTINGS(format_csv_allow_single_quotes = 0) +``` + +来源类型 (`source_type`): + +- [本地文件](#dicts-external_dicts_dict_sources-local_file) +- [可执行文件](#dicts-external_dicts_dict_sources-executable) +- [HTTP(s)](#dicts-external_dicts_dict_sources-http) +- DBMS + - [ODBC](#dicts-external_dicts_dict_sources-odbc) + - [MySQL](#dicts-external_dicts_dict_sources-mysql) + - [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) + - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) + - [Redis](#dicts-external_dicts_dict_sources-redis) + +## 本地文件 {#dicts-external_dicts_dict_sources-local_file} + +设置示例: + +``` xml + + + /opt/dictionaries/os.tsv + TabSeparated + + +``` + +或 + +``` sql +SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +设置字段: + +- `path` – The absolute path to the file. +- `format` – The file format. All the formats described in “[格式](../../../interfaces/formats.md#formats)” 支持。 + +## 可执行文件 {#dicts-external_dicts_dict_sources-executable} + +使用可执行文件取决于 [字典如何存储在内存中](external-dicts-dict-layout.md). 如果字典存储使用 `cache` 和 `complex_key_cache`,ClickHouse通过向可执行文件的STDIN发送请求来请求必要的密钥。 否则,ClickHouse将启动可执行文件并将其输出视为字典数据。 + +设置示例: + +``` xml + + + cat /opt/dictionaries/os.tsv + TabSeparated + + +``` + +或 + +``` sql +SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) +``` + +设置字段: + +- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). +- `format` – The file format. All the formats described in “[格式](../../../interfaces/formats.md#formats)” 支持。 + +## Http(s) {#dicts-external_dicts_dict_sources-http} + +使用HTTP(s)服务器取决于 [字典如何存储在内存中](external-dicts-dict-layout.md). 如果字典存储使用 `cache` 和 `complex_key_cache`,ClickHouse通过通过发送请求请求必要的密钥 `POST` 方法。 + +设置示例: + +``` xml + + + http://[::1]/os.tsv + TabSeparated + + user + password + + +
+ API-KEY + key +
+
+
+ +``` + +或 + +``` sql +SOURCE(HTTP( + url 'http://[::1]/os.tsv' + format 'TabSeparated' + credentials(user 'user' password 'password') + headers(header(name 'API-KEY' value 'key')) +)) +``` + +为了让ClickHouse访问HTTPS资源,您必须 [配置openSSL](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-openssl) 在服务器配置中。 + +设置字段: + +- `url` – The source URL. +- `format` – The file format. All the formats described in “[格式](../../../interfaces/formats.md#formats)” 支持。 +- `credentials` – Basic HTTP authentication. Optional parameter. + - `user` – Username required for the authentication. + - `password` – Password required for the authentication. +- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. + - `header` – Single HTTP header entry. + - `name` – Identifiant name used for the header send on the request. + - `value` – Value set for a specific identifiant name. + +## ODBC {#dicts-external_dicts_dict_sources-odbc} + +您可以使用此方法连接具有ODBC驱动程序的任何数据库。 + +设置示例: + +``` xml + + + DatabaseName + ShemaName.TableName
+ DSN=some_parameters + SQL_QUERY +
+ +``` + +或 + +``` sql +SOURCE(ODBC( + db 'DatabaseName' + table 'SchemaName.TableName' + connection_string 'DSN=some_parameters' + invalidate_query 'SQL_QUERY' +)) +``` + +设置字段: + +- `db` – Name of the database. Omit it if the database name is set in the `` 参数。 +- `table` – Name of the table and schema if exists. +- `connection_string` – Connection string. +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [更新字典](external-dicts-dict-lifetime.md). + +ClickHouse接收来自ODBC-driver的引用符号,并将查询中的所有设置引用到driver,因此有必要根据数据库中的表名大小写设置表名。 + +如果您在使用Oracle时遇到编码问题,请参阅相应的 [FAQ](../../../faq/general.md#oracle-odbc-encodings) 文章. + +### ODBC字典功能的已知漏洞 {#known-vulnerability-of-the-odbc-dictionary-functionality} + +!!! attention "注意" + 通过ODBC驱动程序连接参数连接到数据库时 `Servername` 可以取代。 在这种情况下,值 `USERNAME` 和 `PASSWORD` 从 `odbc.ini` 被发送到远程服务器,并且可能会受到损害。 + +**不安全使用示例** + +让我们为PostgreSQL配置unixODBC。 的内容 `/etc/odbc.ini`: + +``` text +[gregtest] +Driver = /usr/lib/psqlodbca.so +Servername = localhost +PORT = 5432 +DATABASE = test_db +#OPTION = 3 +USERNAME = test +PASSWORD = test +``` + +如果然后进行查询,例如 + +``` sql +SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); +``` + +ODBC驱动程序将发送的值 `USERNAME` 和 `PASSWORD` 从 `odbc.ini` 到 `some-server.com`. + +### 连接Postgresql的示例 {#example-of-connecting-postgresql} + +Ubuntu操作系统。 + +为PostgreSQL安装unixODBC和ODBC驱动程序: + +``` bash +$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql +``` + +配置 `/etc/odbc.ini` (或 `~/.odbc.ini`): + +``` text + [DEFAULT] + Driver = myconnection + + [myconnection] + Description = PostgreSQL connection to my_db + Driver = PostgreSQL Unicode + Database = my_db + Servername = 127.0.0.1 + UserName = username + Password = password + Port = 5432 + Protocol = 9.3 + ReadOnly = No + RowVersioning = No + ShowSystemTables = No + ConnSettings = +``` + +ClickHouse中的字典配置: + +``` xml + + + table_name + + + + + DSN=myconnection + postgresql_table
+
+ + + 300 + 360 + + + + + + + id + + + some_column + UInt64 + 0 + + +
+
+``` + +或 + +``` sql +CREATE DICTIONARY table_name ( + id UInt64, + some_column UInt64 DEFAULT 0 +) +PRIMARY KEY id +SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) +LAYOUT(HASHED()) +LIFETIME(MIN 300 MAX 360) +``` + +您可能需要编辑 `odbc.ini` 使用驱动程序指定库的完整路径 `DRIVER=/usr/local/lib/psqlodbcw.so`. + +### 连接MS SQL Server的示例 {#example-of-connecting-ms-sql-server} + +Ubuntu操作系统。 + +安装驱动程序: : + +``` bash +$ sudo apt-get install tdsodbc freetds-bin sqsh +``` + +配置驱动程序: + +``` bash + $ cat /etc/freetds/freetds.conf + ... + + [MSSQL] + host = 192.168.56.101 + port = 1433 + tds version = 7.0 + client charset = UTF-8 + + $ cat /etc/odbcinst.ini + ... + + [FreeTDS] + Description = FreeTDS + Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so + Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so + FileUsage = 1 + UsageCount = 5 + + $ cat ~/.odbc.ini + ... + + [MSSQL] + Description = FreeTDS + Driver = FreeTDS + Servername = MSSQL + Database = test + UID = test + PWD = test + Port = 1433 +``` + +在ClickHouse中配置字典: + +``` xml + + + test + + + dict
+ DSN=MSSQL;UID=test;PWD=test +
+ + + + 300 + 360 + + + + + + + + + k + + + s + String + + + +
+
+``` + +或 + +``` sql +CREATE DICTIONARY test ( + k UInt64, + s String DEFAULT '' +) +PRIMARY KEY k +SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) +LAYOUT(FLAT()) +LIFETIME(MIN 300 MAX 360) +``` + +## DBMS {#dbms} + +### Mysql {#dicts-external_dicts_dict_sources-mysql} + +设置示例: + +``` xml + + + 3306 + clickhouse + qwerty + + example01-1 + 1 + + + example01-2 + 1 + + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +或 + +``` sql +SOURCE(MYSQL( + port 3306 + user 'clickhouse' + password 'qwerty' + replica(host 'example01-1' priority 1) + replica(host 'example01-2' priority 1) + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +设置字段: + +- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). + +- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). + +- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). + +- `replica` – Section of replica configurations. There can be multiple sections. + + - `replica/host` – The MySQL host. + - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. + +- `db` – Name of the database. + +- `table` – Name of the table. + +- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` 例如,mysql中的子句, `id > 10 AND id < 20`. 可选参数。 + +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [更新字典](external-dicts-dict-lifetime.md). + +MySQL可以通过套接字在本地主机上连接。 要做到这一点,设置 `host` 和 `socket`. + +设置示例: + +``` xml + + + localhost + /path/to/socket/file.sock + clickhouse + qwerty + db_name + table_name
+ id=10 + SQL_QUERY +
+ +``` + +或 + +``` sql +SOURCE(MYSQL( + host 'localhost' + socket '/path/to/socket/file.sock' + user 'clickhouse' + password 'qwerty' + db 'db_name' + table 'table_name' + where 'id=10' + invalidate_query 'SQL_QUERY' +)) +``` + +### ClickHouse {#dicts-external_dicts_dict_sources-clickhouse} + +设置示例: + +``` xml + + + example01-01-1 + 9000 + default + + default + ids
+ id=10 +
+ +``` + +或 + +``` sql +SOURCE(CLICKHOUSE( + host 'example01-01-1' + port 9000 + user 'default' + password '' + db 'default' + table 'ids' + where 'id=10' +)) +``` + +设置字段: + +- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [分布](../../../engines/table-engines/special/distributed.md) 表并在后续配置中输入它。 +- `port` – The port on the ClickHouse server. +- `user` – Name of the ClickHouse user. +- `password` – Password of the ClickHouse user. +- `db` – Name of the database. +- `table` – Name of the table. +- `where` – The selection criteria. May be omitted. +- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [更新字典](external-dicts-dict-lifetime.md). + +### Mongodb {#dicts-external_dicts_dict_sources-mongodb} + +设置示例: + +``` xml + + + localhost + 27017 + + + test + dictionary_source + + +``` + +或 + +``` sql +SOURCE(MONGO( + host 'localhost' + port 27017 + user '' + password '' + db 'test' + collection 'dictionary_source' +)) +``` + +设置字段: + +- `host` – The MongoDB host. +- `port` – The port on the MongoDB server. +- `user` – Name of the MongoDB user. +- `password` – Password of the MongoDB user. +- `db` – Name of the database. +- `collection` – Name of the collection. + +### Redis {#dicts-external_dicts_dict_sources-redis} + +设置示例: + +``` xml + + + localhost + 6379 + simple + 0 + + +``` + +或 + +``` sql +SOURCE(REDIS( + host 'localhost' + port 6379 + storage_type 'simple' + db_index 0 +)) +``` + +设置字段: + +- `host` – The Redis host. +- `port` – The port on the Redis server. +- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` 适用于简单源和散列单键源, `hash_map` 用于具有两个键的散列源。 不支持具有复杂键的范围源和缓存源。 可以省略,默认值为 `simple`. +- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md new file mode 100644 index 00000000000..91497a5767a --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md @@ -0,0 +1,175 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: "\u5B57\u5178\u952E\u548C\u5B57\u6BB5" +--- + +# 字典键和字段 {#dictionary-key-and-fields} + +该 `` 子句描述可用于查询的字典键和字段。 + +XML描述: + +``` xml + + + + Id + + + + + + + ... + + + +``` + +属性在元素中描述: + +- `` — [键列](external-dicts-dict-structure.md#ext_dict_structure-key). +- `` — [数据列](external-dicts-dict-structure.md#ext_dict_structure-attributes). 可以有多个属性。 + +DDL查询: + +``` sql +CREATE DICTIONARY dict_name ( + Id UInt64, + -- attributes +) +PRIMARY KEY Id +... +``` + +查询正文中描述了属性: + +- `PRIMARY KEY` — [键列](external-dicts-dict-structure.md#ext_dict_structure-key) +- `AttrName AttrType` — [数据列](external-dicts-dict-structure.md#ext_dict_structure-attributes). 可以有多个属性。 + +## 键 {#ext_dict_structure-key} + +ClickHouse支持以下类型的键: + +- 数字键。 `UInt64`. 在定义 `` 标记或使用 `PRIMARY KEY` 关键字。 +- 复合密钥。 组不同类型的值。 在标签中定义 `` 或 `PRIMARY KEY` 关键字。 + +Xml结构可以包含 `` 或 ``. DDL-查询必须包含单个 `PRIMARY KEY`. + +!!! warning "警告" + 不能将键描述为属性。 + +### 数字键 {#ext_dict-numeric-key} + +类型: `UInt64`. + +配置示例: + +``` xml + + Id + +``` + +配置字段: + +- `name` – The name of the column with keys. + +对于DDL-查询: + +``` sql +CREATE DICTIONARY ( + Id UInt64, + ... +) +PRIMARY KEY Id +... +``` + +- `PRIMARY KEY` – The name of the column with keys. + +### 复合密钥 {#composite-key} + +关键可以是一个 `tuple` 从任何类型的字段。 该 [布局](external-dicts-dict-layout.md) 在这种情况下,必须是 `complex_key_hashed` 或 `complex_key_cache`. + +!!! tip "提示" + 复合键可以由单个元素组成。 例如,这使得可以使用字符串作为键。 + +键结构在元素中设置 ``. 键字段的格式与字典的格式相同 [属性](external-dicts-dict-structure.md). 示例: + +``` xml + + + + field1 + String + + + field2 + UInt32 + + ... + +... +``` + +或 + +``` sql +CREATE DICTIONARY ( + field1 String, + field2 String + ... +) +PRIMARY KEY field1, field2 +... +``` + +对于查询 `dictGet*` 函数中,一个元组作为键传递。 示例: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. + +## 属性 {#ext_dict_structure-attributes} + +配置示例: + +``` xml + + ... + + Name + ClickHouseDataType + + rand64() + true + true + true + + +``` + +或 + +``` sql +CREATE DICTIONARY somename ( + Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID +) +``` + +配置字段: + +| 标签 | 产品描述 | 必填项 | +|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| +| `name` | 列名称。 | 是 | +| `type` | ClickHouse数据类型。
ClickHouse尝试将字典中的值转换为指定的数据类型。 例如,对于MySQL,该字段可能是 `TEXT`, `VARCHAR`,或 `BLOB` 在MySQL源表中,但它可以上传为 `String` 在克里克豪斯
[可为空](../../../sql-reference/data-types/nullable.md) 不支持。 | 是 | +| `null_value` | 非现有元素的默认值。
在示例中,它是一个空字符串。 你不能使用 `NULL` 在这个领域。 | 是 | +| `expression` | [表达式](../../syntax.md#syntax-expressions) ClickHouse对该值执行。
表达式可以是远程SQL数据库中的列名。 因此,您可以使用它为远程列创建别名。

默认值:无表达式。 | 非也。 | +| `hierarchical` | 如果 `true`,该属性包含当前键的父键值。 看 [分层字典](external-dicts-dict-hierarchical.md).

默认值: `false`. | 非也。 | +| `injective` | 标志,显示是否 `id -> attribute` 图像是 [注射](https://en.wikipedia.org/wiki/Injective_function).
如果 `true`,ClickHouse可以自动放置后 `GROUP BY` 子句注入字典的请求。 通常它显着减少了这种请求的数量。

默认值: `false`. | 非也。 | +| `is_object_id` | 显示是否通过以下方式对MongoDB文档执行查询的标志 `ObjectID`.

默认值: `false`. | 非也。 | + +## 另请参阅 {#see-also} + +- [使用外部字典的函数](../../../sql-reference/functions/ext-dict-functions.md). + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md new file mode 100644 index 00000000000..843b9a5aa41 --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md @@ -0,0 +1,53 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u914D\u7F6E\u5916\u90E8\u5B57\u5178" +--- + +# 配置外部字典 {#dicts-external-dicts-dict} + +如果使用xml文件配置字典,则比字典配置具有以下结构: + +``` xml + + dict_name + + + + + + + + + + + + + + + + + +``` + +相应的 [DDL-查询](../../statements/create.md#create-dictionary-query) 具有以下结构: + +``` sql +CREATE DICTIONARY dict_name +( + ... -- attributes +) +PRIMARY KEY ... -- complex or single key configuration +SOURCE(...) -- Source configuration +LAYOUT(...) -- Memory layout configuration +LIFETIME(...) -- Lifetime of dictionary in memory +``` + +- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. +- [来源](external-dicts-dict-sources.md) — Source of the dictionary. +- [布局](external-dicts-dict-layout.md) — Dictionary layout in memory. +- [结构](external-dicts-dict-structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. +- [使用寿命](external-dicts-dict-lifetime.md) — Frequency of dictionary updates. + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts.md new file mode 100644 index 00000000000..c67deb55401 --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/external-dicts.md @@ -0,0 +1,62 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u6982\u8FF0" +--- + +# 外部字典 {#dicts-external-dicts} + +您可以从各种数据源添加自己的字典。 字典的数据源可以是本地文本或可执行文件、HTTP(s)资源或其他DBMS。 有关详细信息,请参阅 “[外部字典的来源](external-dicts-dict-sources.md)”. + +ClickHouse: + +- 完全或部分存储在RAM中的字典。 +- 定期更新字典并动态加载缺失的值。 换句话说,字典可以动态加载。 +- 允许创建外部字典与xml文件或 [DDL查询](../../statements/create.md#create-dictionary-query). + +外部字典的配置可以位于一个或多个xml文件中。 配置的路径在指定 [dictionaries\_config](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_config) 参数。 + +字典可以在服务器启动或首次使用时加载,具体取决于 [dictionaries\_lazy\_load](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) 设置。 + +该 [字典](../../../operations/system-tables.md#system_tables-dictionaries) 系统表包含有关在服务器上配置的字典的信息。 对于每个字典,你可以在那里找到: + +- 字典的状态。 +- 配置参数。 +- 度量指标,如为字典分配的RAM量或自成功加载字典以来的查询数量。 + +字典配置文件具有以下格式: + +``` xml + + An optional element with any content. Ignored by the ClickHouse server. + + + /etc/metrika.xml + + + + + + + + +``` + +你可以 [配置](external-dicts-dict.md) 同一文件中的任意数量的字典。 + +[字典的DDL查询](../../statements/create.md#create-dictionary-query) 在服务器配置中不需要任何其他记录。 它们允许使用字典作为一流的实体,如表或视图。 + +!!! attention "注意" + 您可以通过在一个小字典中描述它来转换小字典的值 `SELECT` 查询(见 [变换](../../../sql-reference/functions/other-functions.md) 功能)。 此功能与外部字典无关。 + +## 另请参阅 {#ext-dicts-see-also} + +- [配置外部字典](external-dicts-dict.md) +- [在内存中存储字典](external-dicts-dict-layout.md) +- [字典更新](external-dicts-dict-lifetime.md) +- [外部字典的来源](external-dicts-dict-sources.md) +- [字典键和字段](external-dicts-dict-structure.md) +- [使用外部字典的函数](../../../sql-reference/functions/ext-dict-functions.md) + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/zh/sql-reference/dictionaries/external-dictionaries/index.md b/docs/zh/sql-reference/dictionaries/external-dictionaries/index.md new file mode 100644 index 00000000000..8d8cc4f187d --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/external-dictionaries/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u5916\u90E8\u5B57\u5178" +toc_priority: 37 +--- + + diff --git a/docs/zh/sql-reference/dictionaries/index.md b/docs/zh/sql-reference/dictionaries/index.md new file mode 100644 index 00000000000..7e8f5e83aa7 --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/index.md @@ -0,0 +1,22 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u5B57\u5178" +toc_priority: 35 +toc_title: "\u5BFC\u8A00" +--- + +# 字典 {#dictionaries} + +字典是一个映射 (`key -> attributes`)这是方便各种类型的参考清单。 + +ClickHouse支持使用可用于查询的字典的特殊功能。 这是更容易和更有效地使用字典与功能比 `JOIN` 与参考表。 + +[NULL](../../sql-reference/syntax.md#null-literal) 值不能存储在字典中。 + +ClickHouse支持: + +- [内置字典](internal-dicts.md#internal_dicts) 具有特定的 [功能集](../../sql-reference/functions/ym-dict-functions.md). +- [插件(外部)字典](external-dictionaries/external-dicts.md#dicts-external-dicts) 用一个 [功能集](../../sql-reference/functions/ext-dict-functions.md). + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/zh/sql-reference/dictionaries/internal-dicts.md b/docs/zh/sql-reference/dictionaries/internal-dicts.md new file mode 100644 index 00000000000..706288e30ec --- /dev/null +++ b/docs/zh/sql-reference/dictionaries/internal-dicts.md @@ -0,0 +1,55 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u5185\u90E8\u5B57\u5178" +--- + +# 内部字典 {#internal_dicts} + +ClickHouse包含用于处理地理数据库的内置功能。 + +这使您可以: + +- 使用区域的ID以所需语言获取其名称。 +- 使用区域ID获取城市、地区、联邦区、国家或大陆的ID。 +- 检查一个区域是否属于另一个区域。 +- 获取父区域链。 + +所有功能支持 “translocality,” 能够同时使用不同的角度对区域所有权。 有关详细信息,请参阅部分 “Functions for working with Yandex.Metrica dictionaries”. + +在默认包中禁用内部字典。 +要启用它们,请取消注释参数 `path_to_regions_hierarchy_file` 和 `path_to_regions_names_files` 在服务器配置文件中。 + +Geobase从文本文件加载。 + +将 `regions_hierarchy*.txt` 文件到 `path_to_regions_hierarchy_file` 目录。 此配置参数必须包含指向 `regions_hierarchy.txt` 文件(默认区域层次结构)和其他文件 (`regions_hierarchy_ua.txt`)必须位于同一目录中。 + +把 `regions_names_*.txt` 在文件 `path_to_regions_names_files` 目录。 + +您也可以自己创建这些文件。 文件格式如下: + +`regions_hierarchy*.txt`:TabSeparated(无标题),列: + +- 地区ID (`UInt32`) +- 父区域ID (`UInt32`) +- 区域类型 (`UInt8`):1-大陆,3-国家,4-联邦区,5-地区,6-城市;其他类型没有价值 +- 人口 (`UInt32`) — optional column + +`regions_names_*.txt`:TabSeparated(无标题),列: + +- 地区ID (`UInt32`) +- 地区名称 (`String`) — Can't contain tabs or line feeds, even escaped ones. + +平面阵列用于存储在RAM中。 出于这个原因,Id不应该超过一百万。 + +字典可以在不重新启动服务器的情况下更新。 但是,不会更新可用字典集。 +对于更新,将检查文件修改时间。 如果文件已更改,则更新字典。 +检查更改的时间间隔在 `builtin_dictionaries_reload_interval` 参数。 +字典更新(首次使用时加载除外)不会阻止查询。 在更新期间,查询使用旧版本的字典。 如果在更新过程中发生错误,则将错误写入服务器日志,并使用旧版本的字典继续查询。 + +我们建议定期使用geobase更新字典。 在更新期间,生成新文件并将其写入单独的位置。 一切准备就绪后,将其重命名为服务器使用的文件。 + +还有与操作系统标识符和Yandex的工作功能。Metrica搜索引擎,但他们不应该被使用。 + +[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/zh/sql-reference/functions/arithmetic-functions.md b/docs/zh/sql-reference/functions/arithmetic-functions.md new file mode 100644 index 00000000000..b7cfa87ef94 --- /dev/null +++ b/docs/zh/sql-reference/functions/arithmetic-functions.md @@ -0,0 +1,81 @@ +--- +toc_priority: 35 +toc_title: 算术函数 +--- + +# 算术函数 {#suan-zhu-han-shu} + +对于所有算术函数,结果类型为结果适合的最小数字类型(如果存在这样的类型)。最小数字类型是根据数字的位数,是否有符号以及是否是浮点类型而同时进行的。如果没有足够的位,则采用最高位类型。 + +例如: + +``` sql +SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) +``` + + ┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ + │ UInt8 │ UInt16 │ UInt32 │ UInt64 │ + └───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ + +算术函数适用于UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64,Float32或Float64中的任何类型。 + +溢出的产生方式与C++相同。 + +## 加(a,b),a+b {#plusa-b-a-b} + +计算数字的总和。 +您还可以将Date或DateTime与整数进行相加。在Date的情况下,添加的整数意味着添加相应的天数。对于DateTime,这意味这添加相应的描述。 + +## 减(a,b),a-b {#minusa-b-a-b} + +计算数字之间的差,结果总是有符号的。 + +您还可以将Date或DateTime与整数进行相减。见上面的’plus’。 + +## 乘(a,b),a\*b {#multiplya-b-a-b} + +计算数字的乘积。 + +## 除以(a,b),a/b {#dividea-b-a-b} + +计算数字的商。结果类型始终是浮点类型。 +它不是整数除法。对于整数除法,请使用’intDiv’函数。 +当除以零时,你得到’inf’,‘- inf’或’nan’。 + +## intDiv(a,b) {#intdiva-b} + +计算整数数字的商,向下舍入(按绝对值)。 +除以零或将最小负数除以-1时抛出异常。 + +## intDivOrZero(a,b) {#intdivorzeroa-b} + +与’intDiv’的不同之处在于它在除以零或将最小负数除以-1时返回零。 + +## 模(a,b),a%b {#moduloa-b-a-b} + +计算除法后的余数。 +如果参数是浮点数,则通过删除小数部分将它们预转换为整数。 +其余部分与C++中的含义相同。截断除法用于负数。 +除以零或将最小负数除以-1时抛出异常。 + +## 否定(a),-a {#negatea-a} + +计算一个数字的 +用反转符号计算一个数字。结果始终是签名的。 +计算具有反向符号的数字。 结果始终签名。 + +## abs(a) {#arithm_func-abs} + +计算数字(a)的绝对值。也就是说,如果a &lt; 0,它返回-a。对于无符号类型,它不执行任何操作。对于有符号整数类型,它返回无符号数。 + +## gcd(a,b) {#gcda-b} + +返回数字的最大公约数。 +除以零或将最小负数除以-1时抛出异常。 + +## lcm(a,b) {#lcma-b} + +返回数字的最小公倍数。 +除以零或将最小负数除以-1时抛出异常。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/zh/sql-reference/functions/array-functions.md b/docs/zh/sql-reference/functions/array-functions.md new file mode 100644 index 00000000000..546b916b942 --- /dev/null +++ b/docs/zh/sql-reference/functions/array-functions.md @@ -0,0 +1,665 @@ +# 数组函数 {#shu-zu-han-shu} + +## 空 {#empty} + +对于空数组返回1,对于非空数组返回0。 +结果类型是UInt8。 +该函数也适用于字符串。 + +## notEmpty {#notempty} + +对于空数组返回0,对于非空数组返回1。 +结果类型是UInt8。 +该函数也适用于字符串。 + +## 长度 {#array_functions-length} + +返回数组中的元素个数。 +结果类型是UInt64。 +该函数也适用于字符串。 + +## emptyArrayUInt8,emptyArrayUInt16,emptyArrayUInt32,emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} + +## emptyArrayInt8,emptyArrayInt16,emptyArrayInt32,emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} + +## emptyArrayFloat32,emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} + +## 空空漫步,空空漫步时间 {#emptyarraydate-emptyarraydatetime} + +## 空字符串 {#emptyarraystring} + +不接受任何参数并返回适当类型的空数组。 + +## emptyArrayToSingle {#emptyarraytosingle} + +接受一个空数组并返回一个仅包含一个默认值元素的数组。 + +## 范围(N) {#rangen} + +返回从0到N-1的数字数组。 +以防万一,如果在数据块中创建总长度超过100,000,000个元素的数组,则抛出异常。 + +## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} + +使用函数的参数作为数组元素创建一个数组。 +参数必须是常量,并且具有最小公共类型的类型。必须至少传递一个参数,否则将不清楚要创建哪种类型的数组。也就是说,你不能使用这个函数来创建一个空数组(为此,使用上面描述的’emptyArray  \*’函数)。 +返回’Array(T)’类型的结果,其中’T’是传递的参数中最小的公共类型。 + +## arrayConcat {#arrayconcat} + +合并参数中传递的所有数组。 + + arrayConcat(arrays) + +**参数** + +- `arrays` – 任意数量的[阵列](../../sql-reference/functions/array-functions.md)类型的参数. + **示例** + + + +``` sql +SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res +``` + + ┌─res───────────┐ + │ [1,2,3,4,5,6] │ + └───────────────┘ + +## arrayElement(arr,n),运算符arr\[n\] {#arrayelementarr-n-operator-arrn} + +从数组`arr`中获取索引为«n»的元素。 `n`必须是任何整数类型。 +数组中的索引从一开始。 +支持负索引。在这种情况下,它选择从末尾开始编号的相应元素。例如,`arr [-1]`是数组中的最后一项。 + +如果索引超出数组的边界,则返回默认值(数字为0,字符串为空字符串等)。 + +## 有(arr,elem) {#hasarr-elem} + +检查’arr’数组是否具有’elem’元素。 +如果元素不在数组中,则返回0;如果在,则返回1。 + +`NULL` 值的处理。 + + SELECT has([1, 2, NULL], NULL) + + ┌─has([1, 2, NULL], NULL)─┐ + │ 1 │ + └─────────────────────────┘ + +## hasAll {#hasall} + +检查一个数组是否是另一个数组的子集。 + + hasAll(set, subset) + +**参数** + +- `set` – 具有一组元素的任何类型的数组。 +- `subset` – 任何类型的数组,其元素应该被测试为`set`的子集。 + +**返回值** + +- `1`, 如果`set`包含`subset`中的所有元素。 +- `0`, 否则。 + +**特殊的定义** + +- 空数组是任何数组的子集。 +- «Null»作为数组中的元素值进行处理。 +- 忽略两个数组中的元素值的顺序。 + +**示例** + +`SELECT hasAll([], [])` 返回1。 + +`SELECT hasAll([1, Null], [Null])` 返回1。 + +`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` 返回1。 + +`SELECT hasAll(['a', 'b'], ['a'])` 返回1。 + +`SELECT hasAll([1], ['a'])` 返回0。 + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` 返回0。 + +## hasAny {#hasany} + +检查两个数组是否存在交集。 + + hasAny(array1, array2) + +**参数** + +- `array1` – 具有一组元素的任何类型的数组。 +- `array2` – 具有一组元素的任何类型的数组。 + +**返回值** + +- `1`, 如果`array1`和`array2`存在交集。 +- `0`, 否则。 + +**特殊的定义** + +- «Null»作为数组中的元素值进行处理。 +- 忽略两个数组中的元素值的顺序。 + +**示例** + +`SELECT hasAny([1], [])` 返回 `0`. + +`SELECT hasAny([Null], [Null, 1])` 返回 `1`. + +`SELECT hasAny([-128, 1., 512], [1])` 返回 `1`. + +`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` 返回 `0`. + +`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` 返回 `1`. + +## indexOf(arr,x) {#indexofarr-x} + +返回数组中第一个’x’元素的索引(从1开始),如果’x’元素不存在在数组中,则返回0。 + +示例: + + :) SELECT indexOf([1,3,NULL,NULL],NULL) + + SELECT indexOf([1, 3, NULL, NULL], NULL) + + ┌─indexOf([1, 3, NULL, NULL], NULL)─┐ + │ 3 │ + └───────────────────────────────────┘ + +设置为«NULL»的元素将作为普通的元素值处理。 + +## countEqual(arr,x) {#countequalarr-x} + +返回数组中等于x的元素的个数。相当于arrayCount(elem - \> elem = x,arr)。 + +`NULL`值将作为单独的元素值处理。 + +示例: + + SELECT countEqual([1, 2, NULL, NULL], NULL) + + ┌─countEqual([1, 2, NULL, NULL], NULL)─┐ + │ 2 │ + └──────────────────────────────────────┘ + +## ツ暗ェツ氾环催ツ団ツ法ツ人) {#array_functions-arrayenumerate} + +返回 Array \[1, 2, 3, …, length (arr) \] + +此功能通常与ARRAY JOIN一起使用。它允许在应用ARRAY JOIN后为每个数组计算一次。例如: + +``` sql +SELECT + count() AS Reaches, + countIf(num = 1) AS Hits +FROM test.hits +ARRAY JOIN + GoalsReached, + arrayEnumerate(GoalsReached) AS num +WHERE CounterID = 160656 +LIMIT 10 +``` + + ┌─Reaches─┬──Hits─┐ + │ 95606 │ 31406 │ + └─────────┴───────┘ + +在此示例中,Reaches是转换次数(应用ARRAY JOIN后接收的字符串),Hits是浏览量(ARRAY JOIN之前的字符串)。在这种特殊情况下,您可以更轻松地获得相同的结果: + +``` sql +SELECT + sum(length(GoalsReached)) AS Reaches, + count() AS Hits +FROM test.hits +WHERE (CounterID = 160656) AND notEmpty(GoalsReached) +``` + + ┌─Reaches─┬──Hits─┐ + │ 95606 │ 31406 │ + └─────────┴───────┘ + +此功能也可用于高阶函数。例如,您可以使用它来获取与条件匹配的元素的数组索引。 + +## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} + +返回与源数组大小相同的数组,其中每个元素表示与其下标对应的源数组元素在源数组中出现的次数。 +例如:arrayEnumerateUniq( \[10,20,10,30 \])=  \[1,1,2,1 \]。 + +使用ARRAY JOIN和数组元素的聚合时,此函数很有用。 + +示例: + +``` sql +SELECT + Goals.ID AS GoalID, + sum(Sign) AS Reaches, + sumIf(Sign, num = 1) AS Visits +FROM test.visits +ARRAY JOIN + Goals, + arrayEnumerateUniq(Goals.ID) AS num +WHERE CounterID = 160656 +GROUP BY GoalID +ORDER BY Reaches DESC +LIMIT 10 +``` + + ┌──GoalID─┬─Reaches─┬─Visits─┐ + │ 53225 │ 3214 │ 1097 │ + │ 2825062 │ 3188 │ 1097 │ + │ 56600 │ 2803 │ 488 │ + │ 1989037 │ 2401 │ 365 │ + │ 2830064 │ 2396 │ 910 │ + │ 1113562 │ 2372 │ 373 │ + │ 3270895 │ 2262 │ 812 │ + │ 1084657 │ 2262 │ 345 │ + │ 56599 │ 2260 │ 799 │ + │ 3271094 │ 2256 │ 812 │ + └─────────┴─────────┴────────┘ + +在此示例中,每个GoalID都计算转换次数(目标嵌套数据结构中的每个元素都是达到的目标,我们称之为转换)和会话数。如果没有ARRAY JOIN,我们会将会话数计为总和(Sign)。但在这种特殊情况下,行乘以嵌套的Goals结构,因此为了在此之后计算每个会话一次,我们将一个条件应用于arrayEnumerateUniq(Goals.ID)函数的值。 + +arrayEnumerateUniq函数可以使用与参数大小相同的多个数组。在这种情况下,对于所有阵列中相同位置的元素元组,考虑唯一性。 + +``` sql +SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res +``` + + ┌─res───────────┐ + │ [1,2,1,1,2,1] │ + └───────────────┘ + +当使用带有嵌套数据结构的ARRAY JOIN并在此结构中跨多个元素进一步聚合时,这是必需的。 + +## arrayPopBack {#arraypopback} + +从数组中删除最后一项。 + + arrayPopBack(array) + +**参数** + +- `array` – 数组。 + +**示例** + +``` sql +SELECT arrayPopBack([1, 2, 3]) AS res +``` + + ┌─res───┐ + │ [1,2] │ + └───────┘ + +## arrayPopFront {#arraypopfront} + +从数组中删除第一项。 + + arrayPopFront(array) + +**参数** + +- `array` – 数组。 + +**示例** + +``` sql +SELECT arrayPopFront([1, 2, 3]) AS res +``` + + ┌─res───┐ + │ [2,3] │ + └───────┘ + +## arrayPushBack {#arraypushback} + +添加一个元素到数组的末尾。 + + arrayPushBack(array, single_value) + +**参数** + +- `array` – 数组。 +- `single_value` – 单个值。只能将数字添加到带数字的数组中,并且只能将字符串添加到字符串数组中。添加数字时,ClickHouse会自动为数组的数据类型设置`single_value`类型。有关ClickHouse中数据类型的更多信息,请参阅«[数据类型](../../sql-reference/functions/array-functions.md#data_types)»。可以是’NULL`。该函数向数组添加一个«NULL»元素,数组元素的类型转换为`Nullable\`。 + +**示例** + +``` sql +SELECT arrayPushBack(['a'], 'b') AS res +``` + + ┌─res───────┐ + │ ['a','b'] │ + └───────────┘ + +## arrayPushFront {#arraypushfront} + +将一个元素添加到数组的开头。 + + arrayPushFront(array, single_value) + +**参数** + +- `array` – 数组。 +- `single_value` – 单个值。只能将数字添加到带数字的数组中,并且只能将字符串添加到字符串数组中。添加数字时,ClickHouse会自动为数组的数据类型设置`single_value`类型。有关ClickHouse中数据类型的更多信息,请参阅«[数据类型](../../sql-reference/functions/array-functions.md#data_types)»。可以是’NULL`。该函数向数组添加一个«NULL»元素,数组元素的类型转换为`Nullable\`。 + +**示例** + +``` sql +SELECT arrayPushFront(['b'], 'a') AS res +``` + + ┌─res───────┐ + │ ['a','b'] │ + └───────────┘ + +## arrayResize {#arrayresize} + +更改数组的长度。 + + arrayResize(array, size[, extender]) + +**参数:** + +- `array` — 数组. +- `size` — 数组所需的长度。 + - 如果`size`小于数组的原始大小,则数组将从右侧截断。 +- 如果`size`大于数组的初始大小,则使用`extender`值或数组项的数据类型的默认值将数组扩展到右侧。 +- `extender` — 扩展数组的值。可以是’NULL\`。 + +**返回值:** + +一个`size`长度的数组。 + +**调用示例** + + SELECT arrayResize([1], 3) + + ┌─arrayResize([1], 3)─┐ + │ [1,0,0] │ + └─────────────────────┘ + + SELECT arrayResize([1], 3, NULL) + + ┌─arrayResize([1], 3, NULL)─┐ + │ [1,NULL,NULL] │ + └───────────────────────────┘ + +## arraySlice {#arrayslice} + +返回一个子数组,包含从指定位置的指定长度的元素。 + + arraySlice(array, offset[, length]) + +**参数** + +- `array` – 数组。 +- `offset` – 数组的偏移。正值表示左侧的偏移量,负值表示右侧的缩进值。数组下标从1开始。 +- `length` - 子数组的长度。如果指定负值,则该函数返回`[offset,array_length - length`。如果省略该值,则该函数返回`[offset,the_end_of_array]`。 + +**示例** + +``` sql +SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res +``` + + ┌─res────────┐ + │ [2,NULL,4] │ + └────────────┘ + +设置为«NULL»的数组元素作为普通的数组元素值处理。 + +## arraySort(\[func,\] arr, …) {#array_functions-reverse-sort} + +以升序对`arr`数组的元素进行排序。如果指定了`func`函数,则排序顺序由`func`函数的调用结果决定。如果`func`接受多个参数,那么`arraySort`函数也将解析与`func`函数参数相同数量的数组参数。更详细的示例在`arraySort`的末尾。 + +整数排序示例: + +``` sql +SELECT arraySort([1, 3, 3, 0]); +``` + + ┌─arraySort([1, 3, 3, 0])─┐ + │ [0,1,3,3] │ + └─────────────────────────┘ + +字符串排序示例: + +``` sql +SELECT arraySort(['hello', 'world', '!']); +``` + + ┌─arraySort(['hello', 'world', '!'])─┐ + │ ['!','hello','world'] │ + └────────────────────────────────────┘ + +`NULL`,`NaN`和`Inf`的排序顺序: + +``` sql +SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); +``` + + ┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ + │ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ + └───────────────────────────────────────────────────────────┘ + +- `-Inf` 是数组中的第一个。 +- `NULL` 是数组中的最后一个。 +- `NaN` 在`NULL`的前面。 +- `Inf` 在`NaN`的前面。 + +注意:`arraySort`是[高阶函数](higher-order-functions.md)。您可以将lambda函数作为第一个参数传递给它。在这种情况下,排序顺序由lambda函数的调用结果决定。 + +让我们来看一下如下示例: + +``` sql +SELECT arraySort((x) -> -x, [1, 2, 3]) as res; +``` + + ┌─res─────┐ + │ [3,2,1] │ + └─────────┘ + +对于源数组的每个元素,lambda函数返回排序键,即\[1 -\> -1, 2 -\> -2, 3 -\> -3\]。由于`arraySort`函数按升序对键进行排序,因此结果为\[3,2,1\]。因此,`(x) -> -x` lambda函数将排序设置为[降序](#array_functions-reverse-sort)。 + +lambda函数可以接受多个参数。在这种情况下,您需要为`arraySort`传递与lambda参数个数相同的数组。函数使用第一个输入的数组中的元素组成返回结果;使用接下来传入的数组作为排序键。例如: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + + ┌─res────────────────┐ + │ ['world', 'hello'] │ + └────────────────────┘ + +这里,在第二个数组(\[2, 1\])中定义了第一个数组(\[‘hello’,‘world’\])的相应元素的排序键,即\[‘hello’ -\> 2,‘world’ -\> 1\]。 由于lambda函数中没有使用`x`,因此源数组中的实际值不会影响结果的顺序。所以,’world’将是结果中的第一个元素,’hello’将是结果中的第二个元素。 + +其他示例如下所示。 + +``` sql +SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; +``` + +``` sql +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +``` sql +SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; +``` + +``` sql +┌─res─────┐ +│ [2,1,0] │ +└─────────┘ +``` + +!!! 注意 "注意" + 为了提高排序效率, 使用了[施瓦茨变换](https://en.wikipedia.org/wiki/Schwartzian_transform)。 + +## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} + +以降序对`arr`数组的元素进行排序。如果指定了`func`函数,则排序顺序由`func`函数的调用结果决定。如果`func`接受多个参数,那么`arrayReverseSort`函数也将解析与`func`函数参数相同数量的数组作为参数。更详细的示例在`arrayReverseSort`的末尾。 + +整数排序示例: + +``` sql +SELECT arrayReverseSort([1, 3, 3, 0]); +``` + + ┌─arrayReverseSort([1, 3, 3, 0])─┐ + │ [3,3,1,0] │ + └────────────────────────────────┘ + +字符串排序示例: + +``` sql +SELECT arrayReverseSort(['hello', 'world', '!']); +``` + + ┌─arrayReverseSort(['hello', 'world', '!'])─┐ + │ ['world','hello','!'] │ + └───────────────────────────────────────────┘ + +`NULL`,`NaN`和`Inf`的排序顺序: + +``` sql +SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; +``` + +``` sql +┌─res───────────────────────────────────┐ +│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ +└───────────────────────────────────────┘ +``` + +- `Inf` 是数组中的第一个。 +- `NULL` 是数组中的最后一个。 +- `NaN` 在`NULL`的前面。 +- `-Inf` 在`NaN`的前面。 + +注意:`arraySort`是[高阶函数](higher-order-functions.md)。您可以将lambda函数作为第一个参数传递给它。如下示例所示。 + +``` sql +SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; +``` + + ┌─res─────┐ + │ [1,2,3] │ + └─────────┘ + +数组按以下方式排序: +数组按以下方式排序: + +1. 首先,根据lambda函数的调用结果对源数组(\[1, 2, 3\])进行排序。 结果是\[3, 2, 1\]。 +2. 反转上一步获得的数组。 所以,最终的结果是\[1, 2, 3\]。 + +lambda函数可以接受多个参数。在这种情况下,您需要为`arrayReverseSort`传递与lambda参数个数相同的数组。函数使用第一个输入的数组中的元素组成返回结果;使用接下来传入的数组作为排序键。例如: + +``` sql +SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; +``` + +``` sql +┌─res───────────────┐ +│ ['hello','world'] │ +└───────────────────┘ +``` + +在这个例子中,数组按以下方式排序: + +1. 首先,根据lambda函数的调用结果对源数组(\[‘hello’,‘world’\])进行排序。 其中,在第二个数组(\[2,1\])中定义了源数组中相应元素的排序键。 所以,排序结果\[‘world’,‘hello’\]。 +2. 反转上一步骤中获得的排序数组。 所以,最终的结果是\[‘hello’,‘world’\]。 + +其他示例如下所示。 + +``` sql +SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; +``` + +``` sql +┌─res─────┐ +│ [5,3,4] │ +└─────────┘ +``` + +``` sql +SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; +``` + +``` sql +┌─res─────┐ +│ [4,3,5] │ +└─────────┘ +``` + +## arrayUniq(arr, …) {#arrayuniqarr} + +如果传递一个参数,则计算数组中不同元素的数量。 +如果传递了多个参数,则它计算多个数组中相应位置的不同元素元组的数量。 + +如果要获取数组中唯一项的列表,可以使用arrayReduce(‘groupUniqArray’,arr)。 + +## arryjoin(arr) {#array-functions-join} + +一个特殊的功能。请参见[«ArrayJoin函数»](array-join.md#functions_arrayjoin)部分。 + +## arrayDifference(arr) {#arraydifferencearr} + +返回一个数组,其中包含所有相邻元素对之间的差值。例如: + +``` sql +SELECT arrayDifference([1, 2, 3, 4]) +``` + + ┌─arrayDifference([1, 2, 3, 4])─┐ + │ [0,1,1,1] │ + └───────────────────────────────┘ + +## arrayDistinct(arr) {#arraydistinctarr} + +返回一个包含所有数组中不同元素的数组。例如: + +``` sql +SELECT arrayDistinct([1, 2, 2, 3, 1]) +``` + + ┌─arrayDistinct([1, 2, 2, 3, 1])─┐ + │ [1,2,3] │ + └────────────────────────────────┘ + +## arrayEnumerateDense(arr) {#arrayenumeratedensearr} + +返回与源数组大小相同的数组,指示每个元素首次出现在源数组中的位置。例如:arrayEnumerateDense(\[10,20,10,30\])= \[1,2,1,3\]。 + +## arrayIntersect(arr) {#arrayintersectarr} + +返回所有数组元素的交集。例如: + +``` sql +SELECT + arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, + arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect +``` + + ┌─no_intersect─┬─intersect─┐ + │ [] │ [1] │ + └──────────────┴───────────┘ + +## arrayReduce(agg\_func, arr1, …) {#arrayreduceagg-func-arr1} + +将聚合函数应用于数组并返回其结果。如果聚合函数具有多个参数,则此函数可应用于相同大小的多个数组。 + +arrayReduce(‘agg\_func’,arr1,…) - 将聚合函数`agg_func`应用于数组`arr1 ...`。如果传递了多个数组,则相应位置上的元素将作为多个参数传递给聚合函数。例如:SELECT arrayReduce(‘max’,\[1,2,3\])= 3 + +## ツ暗ェツ氾环催ツ団ツ法ツ人) {#arrayreversearr} + +返回与源数组大小相同的数组,包含反转源数组的所有元素的结果。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/zh/sql-reference/functions/array-join.md b/docs/zh/sql-reference/functions/array-join.md new file mode 100644 index 00000000000..b7a4855efa5 --- /dev/null +++ b/docs/zh/sql-reference/functions/array-join.md @@ -0,0 +1,28 @@ +# arrayJoin函数 {#functions_arrayjoin} + +这是一个非常有用的函数。 + +普通函数不会更改结果集的行数,而只是计算每行中的值(map)。 +聚合函数将多行压缩到一行中(fold或reduce)。 +’arrayJoin’函数获取每一行并将他们展开到多行(unfold)。 + +此函数将数组作为参数,并将该行在结果集中复制数组元素个数。 +除了应用此函数的列中的值之外,简单地复制列中的所有值;它被替换为相应的数组值。 + +查询可以使用多个`arrayJoin`函数。在这种情况下,转换被执行多次。 + +请注意SELECT查询中的ARRAY JOIN语法,它提供了更广泛的可能性。 + +示例: + +``` sql +SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src +``` + + ┌─dst─┬─\'Hello\'─┬─src─────┐ + │ 1 │ Hello │ [1,2,3] │ + │ 2 │ Hello │ [1,2,3] │ + │ 3 │ Hello │ [1,2,3] │ + └─────┴───────────┴─────────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/array_join/) diff --git a/docs/zh/sql-reference/functions/bit-functions.md b/docs/zh/sql-reference/functions/bit-functions.md new file mode 100644 index 00000000000..08a6739c206 --- /dev/null +++ b/docs/zh/sql-reference/functions/bit-functions.md @@ -0,0 +1,29 @@ +# 位操作函数 {#wei-cao-zuo-han-shu} + +位操作函数适用于UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64,Float32或Float64中的任何类型。 + +结果类型是一个整数,其位数等于其参数的最大位。如果至少有一个参数为有符数字,则结果为有符数字。如果参数是浮点数,则将其强制转换为Int64。 + +## bitAnd(a,b) {#bitanda-b} + +## bitOr(a,b) {#bitora-b} + +## bitXor(a,b) {#bitxora-b} + +## bitNot(a) {#bitnota} + +## bitShiftLeft(a,b) {#bitshiftlefta-b} + +## bitShiftRight(a,b) {#bitshiftrighta-b} + +## bitRotateLeft(a,b) {#bitrotatelefta-b} + +## bitRotateRight(a,b) {#bitrotaterighta-b} + +## bitTest(a,b) {#bittesta-b} + +## bitTestAll(a,b) {#bittestalla-b} + +## bitTestAny(a,b) {#bittestanya-b} + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/zh/sql-reference/functions/bitmap-functions.md b/docs/zh/sql-reference/functions/bitmap-functions.md new file mode 100644 index 00000000000..239cd8b7d2d --- /dev/null +++ b/docs/zh/sql-reference/functions/bitmap-functions.md @@ -0,0 +1,384 @@ +# 位图函数 {#wei-tu-han-shu} + +位图函数用于对两个位图对象进行计算,对于任何一个位图函数,它都将返回一个位图对象,例如and,or,xor,not等等。 + +位图对象有两种构造方法。一个是由聚合函数groupBitmapState构造的,另一个是由Array Object构造的。同时还可以将位图对象转化为数组对象。 + +我们使用RoaringBitmap实际存储位图对象,当基数小于或等于32时,它使用Set保存。当基数大于32时,它使用RoaringBitmap保存。这也是为什么低基数集的存储更快的原因。 + +有关RoaringBitmap的更多信息,请参阅:[呻吟声](https://github.com/RoaringBitmap/CRoaring)。 + +## bitmapBuild {#bitmapbuild} + +从无符号整数数组构建位图对象。 + + bitmapBuild(array) + +**参数** + +- `array` – 无符号整数数组. + +**示例** + +``` sql +SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res +``` + +## bitmapToArray {#bitmaptoarray} + +将位图转换为整数数组。 + + bitmapToArray(bitmap) + +**参数** + +- `bitmap` – 位图对象. + +**示例** + +``` sql +SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─────────┐ + │ [1,2,3,4,5] │ + └─────────────┘ + +## bitmapSubsetInRange {#bitmapsubsetinrange} + +将位图指定范围(不包含range\_end)转换为另一个位图。 + + bitmapSubsetInRange(bitmap, range_start, range_end) + +**参数** + +- `bitmap` – 位图对象. +- `range_start` – 范围起始点(含). +- `range_end` – 范围结束点(不含). + +**示例** + +``` sql +SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + + ┌─res───────────────┐ + │ [30,31,32,33,100] │ + └───────────────────┘ + +## bitmapSubsetLimit {#bitmapsubsetlimit} + +将位图指定范围(起始点和数目上限)转换为另一个位图。 + + bitmapSubsetLimit(bitmap, range_start, limit) + +**参数** + +- `bitmap` – 位图对象. +- `range_start` – 范围起始点(含). +- `limit` – 子位图基数上限. + +**示例** + +``` sql +SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res +``` + + ┌─res───────────────────────┐ + │ [30,31,32,33,100,200,500] │ + └───────────────────────────┘ + +## bitmapContains {#bitmapcontains} + +检查位图是否包含指定元素。 + + bitmapContains(haystack, needle) + +**参数** + +- `haystack` – 位图对象. +- `needle` – 元素,类型UInt32. + +**示例** + +``` sql +SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## bitmapHasAny {#bitmaphasany} + +与`hasAny(array,array)`类似,如果位图有任何公共元素则返回1,否则返回0。 +对于空位图,返回0。 + + bitmapHasAny(bitmap,bitmap) + +**参数** + +- `bitmap` – bitmap对象。 + +**示例** + +``` sql +SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + + ┌─res─┐ + │ 1 │ + └─────┘ + +## bitmapHasAll {#bitmaphasall} + +与`hasAll(array,array)`类似,如果第一个位图包含第二个位图的所有元素,则返回1,否则返回0。 +如果第二个参数是空位图,则返回1。 + + bitmapHasAll(bitmap,bitmap) + +**参数** + +- `bitmap` – bitmap 对象。 + +**示例** + +``` sql +SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res +``` + + ┌─res─┐ + │ 0 │ + └─────┘ + +## 位图和 {#bitmapand} + +为两个位图对象进行与操作,返回一个新的位图对象。 + + bitmapAnd(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + + ┌─res─┐ + │ [3] │ + └─────┘ + +## 位图 {#bitmapor} + +为两个位图对象进行或操作,返回一个新的位图对象。 + + bitmapOr(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + + ┌─res─────────┐ + │ [1,2,3,4,5] │ + └─────────────┘ + +## bitmapXor {#bitmapxor} + +为两个位图对象进行异或操作,返回一个新的位图对象。 + + bitmapXor(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + + ┌─res───────┐ + │ [1,2,4,5] │ + └───────────┘ + +## bitmapAndnot {#bitmapandnot} + +计算两个位图的差异,返回一个新的位图对象。 + + bitmapAndnot(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res +``` + + ┌─res───┐ + │ [1,2] │ + └───────┘ + +## bitmapCardinality {#bitmapcardinality} + +返回一个UInt64类型的数值,表示位图对象的基数。 + + bitmapCardinality(bitmap) + +**参数** + +- `bitmap` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 5 │ + └─────┘ + +## bitmapMin {#bitmapmin} + +返回一个UInt64类型的数值,表示位图中的最小值。如果位图为空则返回UINT32\_MAX。 + + bitmapMin(bitmap) + +**参数** + +- `bitmap` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 1 │ + └─────┘ + +## bitmapMax {#bitmapmax} + +返回一个UInt64类型的数值,表示位图中的最大值。如果位图为空则返回0。 + + bitmapMax(bitmap) + +**参数** + +- `bitmap` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res +``` + + ┌─res─┐ + │ 5 │ + └─────┘ + +## 位图和标准性 {#bitmapandcardinality} + +为两个位图对象进行与操作,返回结果位图的基数。 + + bitmapAndCardinality(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + + ┌─res─┐ + │ 1 │ + └─────┘ + +## bitmapOrCardinality {#bitmaporcardinality} + +为两个位图进行或运算,返回结果位图的基数。 + + bitmapOrCardinality(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + + ┌─res─┐ + │ 5 │ + └─────┘ + +## bitmapXorCardinality {#bitmapxorcardinality} + +为两个位图进行异或运算,返回结果位图的基数。 + + bitmapXorCardinality(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` – 位图对象。 + +**示例** + +``` sql +SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + + ┌─res─┐ + │ 4 │ + └─────┘ + +## 位图和非标准性 {#bitmapandnotcardinality} + +计算两个位图的差异,返回结果位图的基数。 + + bitmapAndnotCardinality(bitmap1,bitmap2) + +**参数** + +- `bitmap1` – 位图对象。 +- `bitmap2` - 位图对象。 + +**示例** + +``` sql +SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; +``` + + ┌─res─┐ + │ 2 │ + └─────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/zh/sql-reference/functions/comparison-functions.md b/docs/zh/sql-reference/functions/comparison-functions.md new file mode 100644 index 00000000000..8b5d72e64c2 --- /dev/null +++ b/docs/zh/sql-reference/functions/comparison-functions.md @@ -0,0 +1,35 @@ +--- +toc_priority: 36 +toc_title: 比较函数 +--- + +# 比较函数 {#bi-jiao-han-shu} + +比较函数始终返回0或1(UInt8)。 + +可以比较以下类型: + +- 数字 +- String 和 FixedString +- 日期 +- 日期时间 + +以上每个组内的类型均可互相比较,但是对于不同组的类型间不能够进行比较。 + +例如,您无法将日期与字符串进行比较。您必须使用函数将字符串转换为日期,反之亦然。 + +字符串按字节进行比较。较短的字符串小于以其开头并且至少包含一个字符的所有字符串。 + +## 等于,a=b和a==b 运算符 {#equals-a-b-and-a-b-operator} + +## 不等于,a!=b和a<>b 运算符 {#notequals-a-operator-b-and-a-b} + +## 少, < 运算符 {#less-operator} + +## 大于, > 运算符 {#greater-operator} + +## 小于等于, <= 运算符 {#lessorequals-operator} + +## 大于等于, >= 运算符 {#greaterorequals-operator} + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/zh/sql-reference/functions/conditional-functions.md b/docs/zh/sql-reference/functions/conditional-functions.md new file mode 100644 index 00000000000..eabe253ab1c --- /dev/null +++ b/docs/zh/sql-reference/functions/conditional-functions.md @@ -0,0 +1,44 @@ +# 条件函数 {#tiao-jian-han-shu} + +## 如果(cond,那么,否则),cond? 运算符然后:else {#ifcond-then-else-cond-operator-then-else} + +如果`cond != 0`则返回`then`,如果`cond = 0`则返回`else`。 +`cond`必须是`UInt8`类型,`then`和`else`必须存在最低的共同类型。 + +`then`和`else`可以是`NULL` + +## 多 {#multiif} + +允许您在查询中更紧凑地编写[CASE](../operators/index.md#operator_case)运算符。 + + multiIf(cond_1, then_1, cond_2, then_2...else) + +**参数:** + +- `cond_N` — 函数返回`then_N`的条件。 +- `then_N` — 执行时函数的结果。 +- `else` — 如果没有满足任何条件,则为函数的结果。 + +该函数接受`2N + 1`参数。 + +**返回值** + +该函数返回值«then\_N»或«else»之一,具体取决于条件`cond_N`。 + +**示例** + +存在如下一张表 + + ┌─x─┬────y─┐ + │ 1 │ ᴺᵁᴸᴸ │ + │ 2 │ 3 │ + └───┴──────┘ + +执行查询 `SELECT multiIf(isNull(y) x, y < 3, y, NULL) FROM t_null`。结果: + + ┌─multiIf(isNull(y), x, less(y, 3), y, NULL)─┐ + │ 1 │ + │ ᴺᵁᴸᴸ │ + └────────────────────────────────────────────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/zh/sql-reference/functions/date-time-functions.md b/docs/zh/sql-reference/functions/date-time-functions.md new file mode 100644 index 00000000000..a418379d4ec --- /dev/null +++ b/docs/zh/sql-reference/functions/date-time-functions.md @@ -0,0 +1,292 @@ +# 时间日期函数 {#shi-jian-ri-qi-han-shu} + +支持时区。 + +所有的时间日期函数都可以在第二个可选参数中接受时区参数。示例:Asia / Yekaterinburg。在这种情况下,它们使用指定的时区而不是本地(默认)时区。 + +``` sql +SELECT + toDateTime('2016-06-15 23:00:00') AS time, + toDate(time) AS date_local, + toDate(time, 'Asia/Yekaterinburg') AS date_yekat, + toString(time, 'US/Samoa') AS time_samoa +``` + + ┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ + │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ + └─────────────────────┴────────────┴────────────┴─────────────────────┘ + +仅支持与UTC相差一整小时的时区。 + +## toTimeZone {#totimezone} + +将Date或DateTime转换为指定的时区。 + +## toYear {#toyear} + +将Date或DateTime转换为包含年份编号(AD)的UInt16类型的数字。 + +## toQuarter {#toquarter} + +将Date或DateTime转换为包含季度编号的UInt8类型的数字。 + +## toMonth {#tomonth} + +将Date或DateTime转换为包含月份编号(1-12)的UInt8类型的数字。 + +## 今天一年 {#todayofyear} + +将Date或DateTime转换为包含一年中的某一天的编号的UInt16(1-366)类型的数字。 + +## 今天月 {#todayofmonth} + +将Date或DateTime转换为包含一月中的某一天的编号的UInt8(1-31)类型的数字。 + +## 今天一周 {#todayofweek} + +将Date或DateTime转换为包含一周中的某一天的编号的UInt8(周一是1, 周日是7)类型的数字。 + +## toHour {#tohour} + +将DateTime转换为包含24小时制(0-23)小时数的UInt8数字。 +这个函数假设如果时钟向前移动,它是一个小时,发生在凌晨2点,如果时钟被移回,它是一个小时,发生在凌晨3点(这并非总是如此 - 即使在莫斯科时钟在不同的时间两次改变)。 + +## toMinute {#tominute} + +将DateTime转换为包含一小时中分钟数(0-59)的UInt8数字。 + +## 秒 {#tosecond} + +将DateTime转换为包含一分钟中秒数(0-59)的UInt8数字。 +闰秒不计算在内。 + +## toUnixTimestamp {#tounixtimestamp} + +将DateTime转换为unix时间戳。 + +## 开始一年 {#tostartofyear} + +将Date或DateTime向前取整到本年的第一天。 +返回Date类型。 + +## 今年开始 {#tostartofisoyear} + +将Date或DateTime向前取整到ISO本年的第一天。 +返回Date类型。 + +## 四分之一开始 {#tostartofquarter} + +将Date或DateTime向前取整到本季度的第一天。 +返回Date类型。 + +## 到月份开始 {#tostartofmonth} + +将Date或DateTime向前取整到本月的第一天。 +返回Date类型。 + +!!! 注意 "注意" +     解析不正确日期的行为是特定于实现的。 ClickHouse可能会返回零日期,抛出异常或执行«natural»溢出。 + +## toMonday {#tomonday} + +将Date或DateTime向前取整到本周的星期一。 +返回Date类型。 + +## 今天开始 {#tostartofday} + +将DateTime向前取整到当日的开始。 + +## 开始一小时 {#tostartofhour} + +将DateTime向前取整到当前小时的开始。 + +## to startofminute {#tostartofminute} + +将DateTime向前取整到当前分钟的开始。 + +## to startoffiveminute {#tostartoffiveminute} + +将DateTime以五分钟为单位向前取整到最接近的时间点。 + +## 开始分钟 {#tostartoftenminutes} + +将DateTime以十分钟为单位向前取整到最接近的时间点。 + +## 开始几分钟 {#tostartoffifteenminutes} + +将DateTime以十五分钟为单位向前取整到最接近的时间点。 + +## toStartOfInterval(time\_or\_data,间隔x单位\[,time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} + +这是名为`toStartOf*`的所有函数的通用函数。例如, +`toStartOfInterval(t,INTERVAL 1 year)`返回与`toStartOfYear(t)`相同的结果, +`toStartOfInterval(t,INTERVAL 1 month)`返回与`toStartOfMonth(t)`相同的结果, +`toStartOfInterval(t,INTERVAL 1 day)`返回与`toStartOfDay(t)`相同的结果, +`toStartOfInterval(t,INTERVAL 15 minute)`返回与`toStartOfFifteenMinutes(t)`相同的结果。 + +## toTime {#totime} + +将DateTime中的日期转换为一个固定的日期,同时保留时间部分。 + +## toRelativeYearNum {#torelativeyearnum} + +将Date或DateTime转换为年份的编号,从过去的某个固定时间点开始。 + +## toRelativeQuarterNum {#torelativequarternum} + +将Date或DateTime转换为季度的数字,从过去的某个固定时间点开始。 + +## toRelativeMonthNum {#torelativemonthnum} + +将Date或DateTime转换为月份的编号,从过去的某个固定时间点开始。 + +## toRelativeWeekNum {#torelativeweeknum} + +将Date或DateTime转换为星期数,从过去的某个固定时间点开始。 + +## toRelativeDayNum {#torelativedaynum} + +将Date或DateTime转换为当天的编号,从过去的某个固定时间点开始。 + +## toRelativeHourNum {#torelativehournum} + +将DateTime转换为小时数,从过去的某个固定时间点开始。 + +## toRelativeMinuteNum {#torelativeminutenum} + +将DateTime转换为分钟数,从过去的某个固定时间点开始。 + +## toRelativeSecondNum {#torelativesecondnum} + +将DateTime转换为秒数,从过去的某个固定时间点开始。 + +## toISOYear {#toisoyear} + +将Date或DateTime转换为包含ISO年份的UInt16类型的编号。 + +## toISOWeek {#toisoweek} + +将Date或DateTime转换为包含ISO周数的UInt8类型的编号。 + +## 现在 {#now} + +不接受任何参数并在请求执行时的某一刻返回当前时间(DateTime)。 +此函数返回一个常量,即时请求需要很长时间能够完成。 + +## 今天 {#today} + +不接受任何参数并在请求执行时的某一刻返回当前日期(Date)。 +其功能与’toDate(now())’相同。 + +## 昨天 {#yesterday} + +不接受任何参数并在请求执行时的某一刻返回昨天的日期(Date)。 +其功能与’today() - 1’相同。 + +## 时隙 {#timeslot} + +将时间向前取整半小时。 +此功能用于Yandex.Metrica,因为如果跟踪标记显示单个用户的连续综合浏览量在时间上严格超过此数量,则半小时是将会话分成两个会话的最短时间。这意味着(tag id,user id,time slot)可用于搜索相应会话中包含的综合浏览量。 + +## toyyymm {#toyyyymm} + +将Date或DateTime转换为包含年份和月份编号的UInt32类型的数字(YYYY \* 100 + MM)。 + +## toyyymmdd {#toyyyymmdd} + +将Date或DateTime转换为包含年份和月份编号的UInt32类型的数字(YYYY \* 10000 + MM \* 100 + DD)。 + +## toYYYYMMDDhhmmss {#toyyyymmddhhmmss} + +将Date或DateTime转换为包含年份和月份编号的UInt64类型的数字(YYYY \* 10000000000 + MM \* 100000000 + DD \* 1000000 + hh \* 10000 + mm \* 100 + ss)。 + +## 隆隆隆隆路虏脢,,陇,貌,垄拢卢虏禄quar陇,貌路,隆拢脳枚脢虏,麓脢,脱,,,录,禄庐戮,utes, {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} + +函数将一段时间间隔添加到Date/DateTime,然后返回Date/DateTime。例如: + +``` sql +WITH + toDate('2018-01-01') AS date, + toDateTime('2018-01-01 00:00:00') AS date_time +SELECT + addYears(date, 1) AS add_years_with_date, + addYears(date_time, 1) AS add_years_with_date_time +``` + + ┌─add_years_with_date─┬─add_years_with_date_time─┐ + │ 2019-01-01 │ 2019-01-01 00:00:00 │ + └─────────────────────┴──────────────────────────┘ + +## subtractYears,subtractMonths,subtractWeeks,subtractDays,subtractours,subtractMinutes,subtractSeconds,subtractQuarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} + +函数将Date/DateTime减去一段时间间隔,然后返回Date/DateTime。例如: + +``` sql +WITH + toDate('2019-01-01') AS date, + toDateTime('2019-01-01 00:00:00') AS date_time +SELECT + subtractYears(date, 1) AS subtract_years_with_date, + subtractYears(date_time, 1) AS subtract_years_with_date_time +``` + + ┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ + │ 2018-01-01 │ 2018-01-01 00:00:00 │ + └──────────────────────────┴───────────────────────────────┘ + +## dateDiff(‘unit’,t1,t2,\[时区\]) {#datediffunit-t1-t2-timezone} + +返回以’unit’为单位表示的两个时间之间的差异,例如`'hours'`。 ‘t1’和’t2’可以是Date或DateTime,如果指定’timezone’,它将应用于两个参数。如果不是,则使用来自数据类型’t1’和’t2’的时区。如果时区不相同,则结果将是未定义的。 + +支持的单位值: + +| 单位 | +|------| +| 第二 | +| 分钟 | +| 小时 | +| 日 | +| 周 | +| 月 | +| 季 | +| 年 | + +## 时隙(开始时间,持续时间,\[,大小\]) {#timeslotsstarttime-duration-size} + +它返回一个时间数组,其中包括从从«StartTime»开始到«StartTime + Duration 秒»内的所有符合«size»(以秒为单位)步长的时间点。其中«size»是一个可选参数,默认为1800。 +例如,`timeSlots(toDateTime('2012-01-01 12:20:00'),600) = [toDateTime('2012-01-01 12:00:00'),toDateTime('2012-01-01 12:30:00' )]`。 +这对于搜索在相应会话中综合浏览量是非常有用的。 + +## formatDateTime(时间,格式\[,时区\]) {#formatdatetimetime-format-timezone} + +函数根据给定的格式字符串来格式化时间。请注意:格式字符串必须是常量表达式,例如:单个结果列不能有多种格式字符串。 + +支持的格式修饰符: +(«Example» 列是对`2018-01-02 22:33:44`的格式化结果) + +| 修饰符 | 产品描述 | 示例 | +|--------|-------------------------------------------|------------| +| %C | 年除以100并截断为整数(00-99) | 20 | +| %d | 月中的一天,零填充(01-31) | 02 | +| %D | 短MM/DD/YY日期,相当于%m/%d/%y | 01/02/2018 | +| %e | 月中的一天,空格填充(1-31) | 2 | +| %F | 短YYYY-MM-DD日期,相当于%Y-%m-%d | 2018-01-02 | +| %H | 24小时格式(00-23) | 22 | +| %I | 小时12h格式(01-12) | 10 | +| %j | 一年(001-366) | 002 | +| %m | 月份为十进制数(01-12) | 01 | +| %M | 分钟(00-59) | 33 | +| %n | 换行符(") | | +| %p | AM或PM指定 | PM | +| %R | 24小时HH:MM时间,相当于%H:%M | 22:33 | +| %S | 第二(00-59) | 44 | +| %t | 水平制表符(’) | | +| %T | ISO8601时间格式(HH:MM:SS),相当于%H:%M:%S | 22:33:44 | +| %u | ISO8601平日as编号,星期一为1(1-7) | 2 | +| %V | ISO8601周编号(01-53) | 01 | +| %w | 周日为十进制数,周日为0(0-6) | 2 | +| %y | 年份,最后两位数字(00-99) | 18 | +| %Y | 年 | 2018 | +| %% | %符号 | % | + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/zh/sql-reference/functions/encoding-functions.md b/docs/zh/sql-reference/functions/encoding-functions.md new file mode 100644 index 00000000000..39065f1d8b9 --- /dev/null +++ b/docs/zh/sql-reference/functions/encoding-functions.md @@ -0,0 +1,28 @@ +# 编码函数 {#bian-ma-han-shu} + +## hex {#hex} + +接受`String`,`unsigned integer`,`Date`或`DateTime`类型的参数。返回包含参数的十六进制表示的字符串。使用大写字母`A-F`。不使用`0x`前缀或`h`后缀。对于字符串,所有字节都简单地编码为两个十六进制数字。数字转换为大端(«易阅读»)格式。对于数字,去除其中较旧的零,但仅限整个字节。例如,`hex(1)='01'`。 `Date`被编码为自Unix时间开始以来的天数。 `DateTime`编码为自Unix时间开始以来的秒数。 + +## unhex(str) {#unhexstr} + +接受包含任意数量的十六进制数字的字符串,并返回包含相应字节的字符串。支持大写和小写字母A-F。十六进制数字的数量不必是偶数。如果是奇数,则最后一位数被解释为00-0F字节的低位。如果参数字符串包含除十六进制数字以外的任何内容,则返回一些实现定义的结果(不抛出异常)。 +如果要将结果转换为数字,可以使用«reverse»和«reinterpretAsType»函数。 + +## UUIDStringToNum(str) {#uuidstringtonumstr} + +接受包含36个字符的字符串,格式为«123e4567-e89b-12d3-a456-426655440000»,并将其转化为FixedString(16)返回。 + +## UUIDNumToString(str) {#uuidnumtostringstr} + +接受FixedString(16)值。返回包含36个字符的文本格式的字符串。 + +## 位掩码列表(num) {#bitmasktolistnum} + +接受一个整数。返回一个字符串,其中包含一组2的幂列表,其列表中的所有值相加等于这个整数。列表使用逗号分割,按升序排列。 + +## 位掩码阵列(num) {#bitmasktoarraynum} + +接受一个整数。返回一个UInt64类型数组,其中包含一组2的幂列表,其列表中的所有值相加等于这个整数。数组中的数字按升序排列。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/zh/sql-reference/functions/ext-dict-functions.md b/docs/zh/sql-reference/functions/ext-dict-functions.md new file mode 100644 index 00000000000..cae193b2e22 --- /dev/null +++ b/docs/zh/sql-reference/functions/ext-dict-functions.md @@ -0,0 +1,46 @@ +# 字典函数 {#zi-dian-han-shu} + +有关连接和配置外部词典的信息,请参阅[外部词典](../../sql-reference/functions/ext-dict-functions.md)。 + +## dictGetUInt8,dictGetUInt16,dictGetUInt32,dictGetUInt64 {#dictgetuint8-dictgetuint16-dictgetuint32-dictgetuint64} + +## dictGetInt8,dictGetInt16,dictGetInt32,dictGetInt64 {#dictgetint8-dictgetint16-dictgetint32-dictgetint64} + +## dictGetFloat32,dictGetFloat64 {#dictgetfloat32-dictgetfloat64} + +## dictGetDate,dictGetDateTime {#dictgetdate-dictgetdatetime} + +## dictgetuid {#dictgetuuid} + +## dictGetString {#dictgetstring} + +`dictGetT('dict_name', 'attr_name', id)` + +- 使用’id’键获取dict\_name字典中attr\_name属性的值。`dict_name`和`attr_name`是常量字符串。`id`必须是UInt64。 + 如果字典中没有`id`键,则返回字典描述中指定的默认值。 + +## dictGetTOrDefault {#ext_dict_functions-dictgettordefault} + +`dictGetTOrDefault('dict_name', 'attr_name', id, default)` + +与`dictGetT`函数相同,但默认值取自函数的最后一个参数。 + +## dictIsIn {#dictisin} + +`dictIsIn ('dict_name', child_id, ancestor_id)` + +- 对于’dict\_name’分层字典,查找’child\_id’键是否位于’ancestor\_id’内(或匹配’ancestor\_id’)。返回UInt8。 + +## 独裁主义 {#dictgethierarchy} + +`dictGetHierarchy('dict_name', id)` + +- 对于’dict\_name’分层字典,返回从’id’开始并沿父元素链继续的字典键数组。返回Array(UInt64) + +## dictHas {#dicthas} + +`dictHas('dict_name', id)` + +- 检查字典是否存在指定的`id`。如果不存在,则返回0;如果存在,则返回1。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/zh/sql-reference/functions/functions-for-nulls.md b/docs/zh/sql-reference/functions/functions-for-nulls.md new file mode 100644 index 00000000000..0fc563afa4c --- /dev/null +++ b/docs/zh/sql-reference/functions/functions-for-nulls.md @@ -0,0 +1,252 @@ +# Nullable处理函数 {#nullablechu-li-han-shu} + +## isNull {#isnull} + +检查参数是否为[NULL](../../sql-reference/syntax.md#null-literal)。 + + isNull(x) + +**参数** + +- `x` — 一个非复合数据类型的值。 + +**返回值** + +- `1` 如果`x`为`NULL`。 +- `0` 如果`x`不为`NULL`。 + +**示例** + +存在以下内容的表 + + ┌─x─┬────y─┐ + │ 1 │ ᴺᵁᴸᴸ │ + │ 2 │ 3 │ + └───┴──────┘ + +对其进行查询 + + :) SELECT x FROM t_null WHERE isNull(y) + + SELECT x + FROM t_null + WHERE isNull(y) + + ┌─x─┐ + │ 1 │ + └───┘ + + 1 rows in set. Elapsed: 0.010 sec. + +## isNotNull {#isnotnull} + +检查参数是否不为 [NULL](../../sql-reference/syntax.md#null-literal). + + isNotNull(x) + +**参数:** + +- `x` — 一个非复合数据类型的值。 + +**返回值** + +- `0` 如果`x`为`NULL`。 +- `1` 如果`x`不为`NULL`。 + +**示例** + +存在以下内容的表 + + ┌─x─┬────y─┐ + │ 1 │ ᴺᵁᴸᴸ │ + │ 2 │ 3 │ + └───┴──────┘ + +对其进行查询 + + :) SELECT x FROM t_null WHERE isNotNull(y) + + SELECT x + FROM t_null + WHERE isNotNull(y) + + ┌─x─┐ + │ 2 │ + └───┘ + + 1 rows in set. Elapsed: 0.010 sec. + +## 合并 {#coalesce} + +检查从左到右是否传递了«NULL»参数并返回第一个非`'NULL`参数。 + + coalesce(x,...) + +**参数:** + +- 任何数量的非复合类型的参数。所有参数必须与数据类型兼容。 + +**返回值** + +- 第一个非’NULL\`参数。 +- `NULL`,如果所有参数都是’NULL\`。 + +**示例** + +考虑可以指定多种联系客户的方式的联系人列表。 + + ┌─name─────┬─mail─┬─phone─────┬──icq─┐ + │ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ + │ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ + └──────────┴──────┴───────────┴──────┘ + +`mail`和`phone`字段是String类型,但`icq`字段是`UInt32`,所以它需要转换为`String`。 + +从联系人列表中获取客户的第一个可用联系方式: + + :) SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook + + SELECT coalesce(mail, phone, CAST(icq, 'Nullable(String)')) + FROM aBook + + ┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ + │ client 1 │ 123-45-67 │ + │ client 2 │ ᴺᵁᴸᴸ │ + └──────────┴──────────────────────────────────────────────────────┘ + + 2 rows in set. Elapsed: 0.006 sec. + +## ifNull {#ifnull} + +如果第一个参数为«NULL»,则返回第二个参数的值。 + + ifNull(x,alt) + +**参数:** + +- `x` — 要检查«NULL»的值。 +- `alt` — 如果`x`为’NULL\`,函数返回的值。 + +**返回值** + +- 价值 `x`,如果 `x` 不是 `NULL`. +- 价值 `alt`,如果 `x` 是 `NULL`. + +**示例** + + SELECT ifNull('a', 'b') + + ┌─ifNull('a', 'b')─┐ + │ a │ + └──────────────────┘ + + SELECT ifNull(NULL, 'b') + + ┌─ifNull(NULL, 'b')─┐ + │ b │ + └───────────────────┘ + +## nullIf {#nullif} + +如果参数相等,则返回`NULL`。 + + nullIf(x, y) + +**参数:** + +`x`, `y` — 用于比较的值。 它们必须是类型兼容的,否则将抛出异常。 + +**返回值** + +- 如果参数相等,则为`NULL`。 +- 如果参数不相等,则为`x`值。 + +**示例** + + SELECT nullIf(1, 1) + + ┌─nullIf(1, 1)─┐ + │ ᴺᵁᴸᴸ │ + └──────────────┘ + + SELECT nullIf(1, 2) + + ┌─nullIf(1, 2)─┐ + │ 1 │ + └──────────────┘ + +## assumeNotNull {#assumenotnull} + +将[可为空](../../sql-reference/functions/functions-for-nulls.md)类型的值转换为非`Nullable`类型的值。 + + assumeNotNull(x) + +**参数:** + +- `x` — 原始值。 + +**返回值** + +- 如果`x`不为`NULL`,返回非`Nullable`类型的原始值。 +- 如果`x`为`NULL`,返回对应非`Nullable`类型的默认值。 + +**示例** + +存在如下`t_null`表。 + + SHOW CREATE TABLE t_null + + ┌─statement─────────────────────────────────────────────────────────────────┐ + │ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ + └───────────────────────────────────────────────────────────────────────────┘ + + ┌─x─┬────y─┐ + │ 1 │ ᴺᵁᴸᴸ │ + │ 2 │ 3 │ + └───┴──────┘ + +将列`y`作为`assumeNotNull`函数的参数。 + + SELECT assumeNotNull(y) FROM t_null + + ┌─assumeNotNull(y)─┐ + │ 0 │ + │ 3 │ + └──────────────────┘ + + SELECT toTypeName(assumeNotNull(y)) FROM t_null + + ┌─toTypeName(assumeNotNull(y))─┐ + │ Int8 │ + │ Int8 │ + └──────────────────────────────┘ + +## 可调整 {#tonullable} + +将参数的类型转换为`Nullable`。 + + toNullable(x) + +**参数:** + +- `x` — 任何非复合类型的值。 + +**返回值** + +- 输入的值,但其类型为`Nullable`。 + +**示例** + + SELECT toTypeName(10) + + ┌─toTypeName(10)─┐ + │ UInt8 │ + └────────────────┘ + + SELECT toTypeName(toNullable(10)) + + ┌─toTypeName(toNullable(10))─┐ + │ Nullable(UInt8) │ + └────────────────────────────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/zh/sql-reference/functions/geo.md b/docs/zh/sql-reference/functions/geo.md new file mode 100644 index 00000000000..7cc094932fb --- /dev/null +++ b/docs/zh/sql-reference/functions/geo.md @@ -0,0 +1,222 @@ +# GEO函数 {#geohan-shu} + +## 大圆形距离 {#greatcircledistance} + +使用[great-circle distance公式](https://en.wikipedia.org/wiki/Great-circle_distance)计算地球表面两点之间的距离。 + +``` sql +greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) +``` + +**输入参数** + +- `lon1Deg` — 第一个点的经度,单位:度,范围: `[-180°, 180°]`。 +- `lat1Deg` — 第一个点的纬度,单位:度,范围: `[-90°, 90°]`。 +- `lon2Deg` — 第二个点的经度,单位:度,范围: `[-180°, 180°]`。 +- `lat2Deg` — 第二个点的纬度,单位:度,范围: `[-90°, 90°]`。 + +正值对应北纬和东经,负值对应南纬和西经。 + +**返回值** + +地球表面的两点之间的距离,以米为单位。 + +当输入参数值超出规定的范围时将抛出异常。 + +**示例** + +``` sql +SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) +``` + +``` text +┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ +│ 14132374.194975413 │ +└───────────────────────────────────────────────────────────────────┘ +``` + +## 尖尖的人 {#pointinellipses} + +检查指定的点是否至少包含在指定的一个椭圆中。 +下述中的坐标是几何图形在笛卡尔坐标系中的位置。 + +``` sql +pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) +``` + +**输入参数** + +- `x, y` — 平面上某个点的坐标。 +- `xᵢ, yᵢ` — 第i个椭圆的中心坐标。 +- `aᵢ, bᵢ` — 以x, y坐标为单位的第i个椭圆的轴。 + +输入参数的个数必须是`2+4⋅n`,其中`n`是椭圆的数量。 + +**返回值** + +如果该点至少包含在一个椭圆中,则返回`1`;否则,则返回`0`。 + +**示例** + +``` sql +SELECT pointInEllipses(55.755831, 37.617673, 55.755831, 37.617673, 1.0, 2.0) +``` + +``` text +┌─pointInEllipses(55.755831, 37.617673, 55.755831, 37.617673, 1., 2.)─┐ +│ 1 │ +└─────────────────────────────────────────────────────────────────────┘ +``` + +## pointInPolygon {#pointinpolygon} + +检查指定的点是否包含在指定的多边形中。 + +``` sql +pointInPolygon((x, y), [(a, b), (c, d) ...], ...) +``` + +**输入参数** + +- `(x, y)` — 平面上某个点的坐标。[元组](../../sql-reference/functions/geo.md)类型,包含坐标的两个数字。 +- `[(a, b), (c, d) ...]` — 多边形的顶点。[阵列](../../sql-reference/functions/geo.md)类型。每个顶点由一对坐标`(a, b)`表示。顶点可以按顺时针或逆时针指定。顶点的个数应该大于等于3。同时只能是常量的。 +- 该函数还支持镂空的多边形(切除部分)。如果需要,可以使用函数的其他参数定义需要切除部分的多边形。(The function does not support non-simply-connected polygons.) + +**返回值** + +如果坐标点存在在多边形范围内,则返回`1`。否则返回`0`。 +如果坐标位于多边形的边界上,则该函数可能返回`1`,或可能返回`0`。 + +**示例** + +``` sql +SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res +``` + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + +## geohashEncode {#geohashencode} + +将经度和纬度编码为geohash-string,请参阅(http://geohash.org/,https://en.wikipedia.org/wiki/Geohash)。 + +``` sql +geohashEncode(longitude, latitude, [precision]) +``` + +**输入值** + +- longitude - 要编码的坐标的经度部分。其值应在`[-180°,180°]`范围内 +- latitude - 要编码的坐标的纬度部分。其值应在`[-90°,90°]`范围内 +- precision - 可选,生成的geohash-string的长度,默认为`12`。取值范围为`[1,12]`。任何小于`1`或大于`12`的值都会默认转换为`12`。 + +**返回值** + +- 坐标编码的字符串(使用base32编码的修改版本)。 + +**示例** + +``` sql +SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res +``` + +``` text +┌─res──────────┐ +│ ezs42d000000 │ +└──────────────┘ +``` + +## geohashDecode {#geohashdecode} + +将任何geohash编码的字符串解码为经度和纬度。 + +**输入值** + +- encoded string - geohash编码的字符串。 + +**返回值** + +- (longitude, latitude) - 经度和纬度的`Float64`值的2元组。 + +**示例** + +``` sql +SELECT geohashDecode('ezs42') AS res +``` + +``` text +┌─res─────────────────────────────┐ +│ (-5.60302734375,42.60498046875) │ +└─────────────────────────────────┘ +``` + +## geoToH3 {#geotoh3} + +计算指定的分辨率的[H3](https://uber.github.io/h3/#/documentation/overview/introduction)索引`(lon, lat)`。 + +``` sql +geoToH3(lon, lat, resolution) +``` + +**输入值** + +- `lon` — 经度。 [Float64](../../sql-reference/functions/geo.md)类型。 +- `lat` — 纬度。 [Float64](../../sql-reference/functions/geo.md)类型。 +- `resolution` — 索引的分辨率。 取值范围为: `[0, 15]`。 [UInt8](../../sql-reference/functions/geo.md)类型。 + +**返回值** + +- H3中六边形的索引值。 +- 发生异常时返回0。 + +[UInt64](../../sql-reference/functions/geo.md)类型。 + +**示例** + +``` sql +SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index +``` + +``` text +┌────────────h3Index─┐ +│ 644325524701193974 │ +└────────────────────┘ +``` + +## geohashesInBox {#geohashesinbox} + +计算在指定精度下计算最小包含指定的经纬范围的最小图形的geohash数组。 + +**输入值** + +- longitude\_min - 最小经度。其值应在`[-180°,180°]`范围内 +- latitude\_min - 最小纬度。其值应在`[-90°,90°]`范围内 +- longitude\_max - 最大经度。其值应在`[-180°,180°]`范围内 +- latitude\_max - 最大纬度。其值应在`[-90°,90°]`范围内 +- precision - geohash的精度。其值应在`[1, 12]`内的`UInt8`类型的数字 + +请注意,上述所有的坐标参数必须同为`Float32`或`Float64`中的一种类型。 + +**返回值** + +- 包含指定范围内的指定精度的geohash字符串数组。注意,您不应该依赖返回数组中geohash的顺序。 +- \[\] - 当传入的最小经纬度大于最大经纬度时将返回一个空数组。 + +请注意,如果生成的数组长度超过10000时,则函数将抛出异常。 + +**示例** + +``` sql +SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos +``` + +``` text +┌─thasos──────────────────────────────────────┐ +│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ +└─────────────────────────────────────────────┘ +``` + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/zh/sql-reference/functions/hash-functions.md b/docs/zh/sql-reference/functions/hash-functions.md new file mode 100644 index 00000000000..5646eee6af8 --- /dev/null +++ b/docs/zh/sql-reference/functions/hash-functions.md @@ -0,0 +1,114 @@ +# Hash函数 {#hashhan-shu} + +Hash函数可以用于将元素不可逆的伪随机打乱。 + +## halfMD5 {#halfmd5} + +计算字符串的MD5。然后获取结果的前8个字节并将它们作为UInt64(大端)返回。 +此函数相当低效(500万个短字符串/秒/核心)。 +如果您不需要一定使用MD5,请使用’sipHash64’函数。 + +## MD5 {#md5} + +计算字符串的MD5并将结果放入FixedString(16)中返回。 +如果您只是需要一个128位的hash,同时不需要一定使用MD5,请使用’sipHash128’函数。 +如果您要获得与md5sum程序相同的输出结果,请使用lower(hex(MD5(s)))。 + +## sipHash64 {#siphash64} + +计算字符串的SipHash。 +接受String类型的参数,返回UInt64。 +SipHash是一种加密哈希函数。它的处理性能至少比MD5快三倍。 +有关详细信息,请参阅链接:https://131002.net/siphash/ + +## sipHash128 {#hash_functions-siphash128} + +计算字符串的SipHash。 +接受String类型的参数,返回FixedString(16)。 +与sipHash64函数的不同在于它的最终计算结果为128位。 + +## cityHash64 {#cityhash64} + +计算任意数量字符串的CityHash64或使用特定实现的Hash函数计算任意数量其他类型的Hash。 +对于字符串,使用CityHash算法。 这是一个快速的非加密哈希函数,用于字符串。 +对于其他类型的参数,使用特定实现的Hash函数,这是一种快速的非加密的散列函数。 +如果传递了多个参数,则使用CityHash组合这些参数的Hash结果。 +例如,您可以计算整个表的checksum,其结果取决于行的顺序:`SELECT sum(cityHash64(*)) FROM table`。 + +## intHash32 {#inthash32} + +为任何类型的整数计算32位的哈希。 +这是相对高效的非加密Hash函数。 + +## intHash64 {#inthash64} + +从任何类型的整数计算64位哈希码。 +它的工作速度比intHash32函数快。 + +## SHA1 {#sha1} + +## SHA224 {#sha224} + +## SHA256 {#sha256} + +计算字符串的SHA-1,SHA-224或SHA-256,并将结果字节集返回为FixedString(20),FixedString(28)或FixedString(32)。 +该函数相当低效(SHA-1大约500万个短字符串/秒/核心,而SHA-224和SHA-256大约220万个短字符串/秒/核心)。 +我们建议仅在必须使用这些Hash函数且无法更改的情况下使用这些函数。 +即使在这些情况下,我们仍建议将函数采用在写入数据时使用预计算的方式将其计算完毕。而不是在SELECT中计算它们。 + +## URLHash(url\[,N\]) {#urlhashurl-n} + +一种快速的非加密哈希函数,用于规范化的从URL获得的字符串。 +`URLHash(s)` - 从一个字符串计算一个哈希,如果结尾存在尾随符号`/`,`?`或`#`则忽略。 +`URLHash(s,N)` - 计算URL层次结构中字符串到N级别的哈希值,如果末尾存在尾随符号`/`,`?`或`#`则忽略。 +URL的层级与URLHierarchy中的层级相同。 此函数被用于Yandex.Metrica。 + +## farmHash64 {#farmhash64} + +计算字符串的FarmHash64。 +接受一个String类型的参数。返回UInt64。 +有关详细信息,请参阅链接:[FarmHash64](https://github.com/google/farmhash) + +## javaHash {#hash_functions-javahash} + +计算字符串的JavaHash。 +接受一个String类型的参数。返回Int32。 +有关更多信息,请参阅链接:[JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) + +## hiveHash {#hivehash} + +计算字符串的HiveHash。 +接受一个String类型的参数。返回Int32。 +与[JavaHash](#hash_functions-javahash)相同,但不会返回负数。 + +## metroHash64 {#metrohash64} + +计算字符串的MetroHash。 +接受一个String类型的参数。返回UInt64。 +有关详细信息,请参阅链接:[MetroHash64](http://www.jandrewrogers.com/2015/05/27/metrohash/) + +## jumpConsistentHash {#jumpconsistenthash} + +计算UInt64的JumpConsistentHash。 +接受UInt64类型的参数。返回Int32。 +有关更多信息,请参见链接:[JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) + +## murmurHash2\_32,murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} + +计算字符串的MurmurHash2。 +接受一个String类型的参数。返回UInt64或UInt32。 +有关更多信息,请参阅链接:[MurmurHash2](https://github.com/aappleby/smhasher) + +## murmurHash3\_32,murmurHash3\_64,murmurHash3\_128 {#murmurhash3-32-murmurhash3-64-murmurhash3-128} + +计算字符串的MurmurHash3。 +接受一个String类型的参数。返回UInt64或UInt32或FixedString(16)。 +有关更多信息,请参阅链接:[MurmurHash3](https://github.com/aappleby/smhasher) + +## xxHash32,xxHash64 {#xxhash32-xxhash64} + +计算字符串的xxHash。 +接受一个String类型的参数。返回UInt64或UInt32。 +有关更多信息,请参见链接:[xxHash](http://cyan4973.github.io/xxHash/) + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/zh/sql-reference/functions/higher-order-functions.md b/docs/zh/sql-reference/functions/higher-order-functions.md new file mode 100644 index 00000000000..fcf3ab3da15 --- /dev/null +++ b/docs/zh/sql-reference/functions/higher-order-functions.md @@ -0,0 +1,138 @@ +# 高阶函数 {#gao-jie-han-shu} + +## `->` 运算符, lambda(params, expr) 函数 {#yun-suan-fu-lambdaparams-expr-han-shu} + +用于描述一个lambda函数用来传递给其他高阶函数。箭头的左侧有一个形式参数,它可以是一个标识符或多个标识符所组成的元祖。箭头的右侧是一个表达式,在这个表达式中可以使用形式参数列表中的任何一个标识符或表的任何一个列名。 + +示例: `x -> 2 * x, str -> str != Referer.` + +高阶函数只能接受lambda函数作为其参数。 + +高阶函数可以接受多个参数的lambda函数作为其参数,在这种情况下,高阶函数需要同时传递几个长度相等的数组,这些数组将被传递给lambda参数。 + +除了’arrayMap’和’arrayFilter’以外的所有其他函数,都可以省略第一个参数(lambda函数)。在这种情况下,默认返回数组元素本身。 + +### arrayMap(func, arr1, …) {#higher_order_functions-array-map} + +将arr +将从’func’函数的原始应用程序获得的数组返回到’arr’数组中的每个元素。 +返回从原始应用程序获得的数组 ‘func’ 函数中的每个元素 ‘arr’ 阵列。 + +### arrayFilter(func, arr1, …) {#arrayfilterfunc-arr1} + +返回一个仅包含以下元素的数组 ‘arr1’ 对于哪个 ‘func’ 返回0以外的内容。 + +示例: + +``` sql +SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res +``` + + ┌─res───────────┐ + │ ['abc World'] │ + └───────────────┘ + +``` sql +SELECT + arrayFilter( + (i, x) -> x LIKE '%World%', + arrayEnumerate(arr), + ['Hello', 'abc World'] AS arr) + AS res +``` + + ┌─res─┐ + │ [2] │ + └─────┘ + +### arrayCount(\[func,\] arr1, …) {#arraycountfunc-arr1} + +返回数组arr中非零元素的数量,如果指定了’func’,则通过’func’的返回值确定元素是否为非零元素。 + +### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} + +返回数组’arr’中是否存在非零元素,如果指定了’func’,则使用’func’的返回值确定元素是否为非零元素。 + +### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} + +返回数组’arr’中是否存在为零的元素,如果指定了’func’,则使用’func’的返回值确定元素是否为零元素。 + +### arraySum(\[func,\] arr1, …) {#arraysumfunc-arr1} + +计算arr数组的总和,如果指定了’func’,则通过’func’的返回值计算数组的总和。 + +### arrayFirst(func, arr1, …) {#arrayfirstfunc-arr1} + +返回数组中第一个匹配的元素,函数使用’func’匹配所有元素,直到找到第一个匹配的元素。 + +### arrayFirstIndex(func, arr1, …) {#arrayfirstindexfunc-arr1} + +返回数组中第一个匹配的元素的下标索引,函数使用’func’匹配所有元素,直到找到第一个匹配的元素。 + +### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} + +返回源数组部分数据的总和,如果指定了`func`函数,则使用`func`的返回值计算总和。 + +示例: + +``` sql +SELECT arrayCumSum([1, 1, 1, 1]) AS res +``` + + ┌─res──────────┐ + │ [1, 2, 3, 4] │ + └──────────────┘ + +### arrayCumSumNonNegative(arr) {#arraycumsumnonnegativearr} + +与arrayCumSum相同,返回源数组部分数据的总和。不同于arrayCumSum,当返回值包含小于零的值时,该值替换为零,后续计算使用零继续计算。例如: + +``` sql +SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res +``` + + ┌─res───────┐ + │ [1,2,0,1] │ + └───────────┘ + +### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} + +返回升序排序`arr1`的结果。如果指定了`func`函数,则排序顺序由`func`的结果决定。 + +[Schwartzian变换](https://en.wikipedia.org/wiki/Schwartzian_transform)用于提高排序效率。 + +示例: + +``` sql +SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); +``` + + ┌─res────────────────┐ + │ ['world', 'hello'] │ + └────────────────────┘ + +请注意,NULL和NaN在最后(NaN在NULL之前)。例如: + +``` sql +SELECT arraySort([1, nan, 2, NULL, 3, nan, 4, NULL]) +``` + + ┌─arraySort([1, nan, 2, NULL, 3, nan, 4, NULL])─┐ + │ [1,2,3,4,nan,nan,NULL,NULL] │ + └───────────────────────────────────────────────┘ + +### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} + +返回降序排序`arr1`的结果。如果指定了`func`函数,则排序顺序由`func`的结果决定。 + +请注意,NULL和NaN在最后(NaN在NULL之前)。例如: + +``` sql +SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, 4, NULL]) +``` + + ┌─arrayReverseSort([1, nan, 2, NULL, 3, nan, 4, NULL])─┐ + │ [4,3,2,1,nan,nan,NULL,NULL] │ + └──────────────────────────────────────────────────────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/zh/sql-reference/functions/in-functions.md b/docs/zh/sql-reference/functions/in-functions.md new file mode 100644 index 00000000000..aeb46025c36 --- /dev/null +++ b/docs/zh/sql-reference/functions/in-functions.md @@ -0,0 +1,19 @@ +# IN运算符相关函数 {#inyun-suan-fu-xiang-guan-han-shu} + +## in,notIn,globalIn,globalNotIn {#in-notin-globalin-globalnotin} + +请参阅[IN 运算符](../operators/in.md#select-in-operators)部分。 + +## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} + +函数用于对多个列进行分组。 +对于具有类型T1,T2,…的列,它返回包含这些列的元组(T1,T2,…)。 执行该函数没有任何成本。 +元组通常用作IN运算符的中间参数值,或用于创建lambda函数的形参列表。 元组不能写入表。 + +## 元组元素(元组,n),运算符x.N {#tupleelementtuple-n-operator-x-n} + +函数用于从元组中获取列。 +’N’是列索引,从1开始。N必须是常量正整数常数,并且不大于元组的大小。 +执行该函数没有任何成本。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/zh/sql-reference/functions/index.md b/docs/zh/sql-reference/functions/index.md new file mode 100644 index 00000000000..52954c95cff --- /dev/null +++ b/docs/zh/sql-reference/functions/index.md @@ -0,0 +1,72 @@ +--- +toc_folder_title: 函数 +toc_priority: 32 +toc_title: 简介 +--- + +# 函数 {#han-shu} + +ClickHouse中至少存在两种类型的函数 - 常规函数(它们称之为«函数»)和聚合函数。 常规函数的工作就像分别为每一行执行一次函数计算一样(对于每一行,函数的结果不依赖于其他行)。 聚合函数则从各行累积一组值(即函数的结果以来整个结果集)。 + +在本节中,我们将讨论常规函数。 有关聚合函数,请参阅«聚合函数»一节。 + + \* - ’arrayJoin’函数与表函数均属于第三种类型的函数。 \* + +## 强类型 {#qiang-lei-xing} + +与标准SQL相比,ClickHouse具有强类型。 换句话说,它不会在类型之间进行隐式转换。 每个函数适用于特定的一组类型。 这意味着有时您需要使用类型转换函数。 + +## 常见的子表达式消除 {#chang-jian-de-zi-biao-da-shi-xiao-chu} + +查询中具有相同AST(相同语句或语法分析结果相同)的所有表达式都被视为具有相同的值。 这样的表达式被连接并执行一次。 通过这种方式也可以消除相同的子查询。 + +## 结果类型 {#jie-guo-lei-xing} + +所有函数都只能够返回一个返回值。 结果类型通常由参数的类型决定。 但tupleElement函数(a.N运算符)和toFixedString函数是例外的。 + +## 常量 {#chang-liang} + +为了简单起见,某些函数的某些参数只能是常量。 例如,LIKE运算符的右参数必须是常量。 +几乎所有函数都为常量参数返回常量。 除了用于生成随机数的函数。 +’now’函数为在不同时间运行的查询返回不同的值,但结果被视为常量,因为常量在单个查询中很重要。 +常量表达式也被视为常量(例如,LIKE运算符的右半部分可以由多个常量构造)。 + +对于常量和非常量参数,可以以不同方式实现函数(执行不同的代码)。 但是,对于包含相同数据的常量和非常量参数它们的结果应该是一致的。 + +## NULL值处理 {#nullzhi-chu-li} + +函数具有以下行为: + +- 如果函数的参数至少一个是«NULL»,则函数结果也是«NULL»。 +- 在每个函数的描述中单独指定的特殊行为。在ClickHouse源代码中,这些函数具有«UseDefaultImplementationForNulls = false»。 + +## 不可变性 {#bu-ke-bian-xing} + +函数不能更改其参数的值 - 任何更改都将作为结果返回。因此,计算单独函数的结果不依赖于在查询中写入函数的顺序。 + +## 错误处理 {#cuo-wu-chu-li} + +如果数据无效,某些函数可能会抛出异常。在这种情况下,将取消查询并将错误信息返回给客户端。对于分布式处理,当其中一个服务器发生异常时,其他服务器也会尝试中止查询。 + +## 表达式参数的计算 {#biao-da-shi-can-shu-de-ji-suan} + +在几乎所有编程语言中,某些函数可能无法预先计算其中一个参数。这通常是运算符`&&`,`||`和`? :`。 +但是在ClickHouse中,函数(运算符)的参数总是被预先计算。这是因为一次评估列的整个部分,而不是分别计算每一行。 + +## 执行分布式查询处理的功能 {#zhi-xing-fen-bu-shi-cha-xun-chu-li-de-gong-neng} + +对于分布式查询处理,在远程服务器上执行尽可能多的查询处理阶段,并且在请求者服务器上执行其余阶段(合并中间结果和之后的所有内容)。 + +这意味着可以在不同的服务器上执行功能。 +例如,在查询`SELECT f(sum(g(x)))FROM distributed_table GROUP BY h(y)中,` + +- 如果`distributed_table`至少有两个分片,则在远程服务器上执行函数’g’和’h’,并在请求服务器上执行函数’f’。 +- 如果`distributed_table`只有一个分片,则在该分片的服务器上执行所有’f’,’g’和’h’功能。 + +函数的结果通常不依赖于它在哪个服务器上执行。但是,有时这很重要。 +例如,使用字典的函数时将使用运行它们的服务器上存在的字典。 +另一个例子是`hostName`函数,它返回运行它的服务器的名称,以便在`SELECT`查询中对服务器进行`GROUP BY`。 + +如果查询中的函数在请求服务器上执行,但您需要在远程服务器上执行它,则可以将其包装在«any»聚合函数中,或将其添加到«GROUP BY»中。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/zh/sql-reference/functions/introspection.md b/docs/zh/sql-reference/functions/introspection.md new file mode 100644 index 00000000000..43d8b596dfb --- /dev/null +++ b/docs/zh/sql-reference/functions/introspection.md @@ -0,0 +1,310 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 65 +toc_title: "\u81EA\u7701" +--- + +# 内省功能 {#introspection-functions} + +您可以使用本章中描述的函数来反省 [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) 和 [DWARF](https://en.wikipedia.org/wiki/DWARF) 用于查询分析。 + +!!! warning "警告" + 这些功能很慢,可能会强加安全考虑。 + +对于内省功能的正确操作: + +- 安装 `clickhouse-common-static-dbg` 包。 + +- 设置 [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) 设置为1。 + + For security reasons introspection functions are disabled by default. + +ClickHouse将探查器报告保存到 [trace\_log](../../operations/system-tables.md#system_tables-trace_log) 系统表. 确保正确配置了表和探查器。 + +## addressToLine {#addresstoline} + +将ClickHouse服务器进程内的虚拟内存地址转换为ClickHouse源代码中的文件名和行号。 + +如果您使用官方的ClickHouse软件包,您需要安装 `clickhouse-common-static-dbg` 包。 + +**语法** + +``` sql +addressToLine(address_of_binary_instruction) +``` + +**参数** + +- `address_of_binary_instruction` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Address of instruction in a running process. + +**返回值** + +- 源代码文件名和此文件中用冒号分隔的行号。 + + For example, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, where `199` is a line number. + +- 二进制文件的名称,如果函数找不到调试信息。 + +- 空字符串,如果地址无效。 + +类型: [字符串](../../sql-reference/data-types/string.md). + +**示例** + +启用内省功能: + +``` sql +SET allow_introspection_functions=1 +``` + +从中选择第一个字符串 `trace_log` 系统表: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-19 +event_time: 2019-11-19 18:57:23 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 421b6855-1858-45a5-8f37-f383409d6d72 +trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] +``` + +该 `trace` 字段包含采样时的堆栈跟踪。 + +获取单个地址的源代码文件名和行号: + +``` sql +SELECT addressToLine(94784076370703) \G +``` + +``` text +Row 1: +────── +addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +``` + +将函数应用于整个堆栈跟踪: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines +FROM system.trace_log +LIMIT 1 +\G +``` + +该 [arrayMap](higher-order-functions.md#higher_order_functions-array-map) 功能允许处理的每个单独的元素 `trace` 阵列由 `addressToLine` 功能。 这种处理的结果,你在看 `trace_source_code_lines` 列的输出。 + +``` text +Row 1: +────── +trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so +/usr/lib/debug/usr/bin/clickhouse +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 +/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 +/usr/include/c++/9/bits/atomic_base.h:551 +/usr/lib/debug/usr/bin/clickhouse +/lib/x86_64-linux-gnu/libpthread-2.27.so +/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 +``` + +## addressToSymbol {#addresstosymbol} + +将ClickHouse服务器进程内的虚拟内存地址转换为ClickHouse对象文件中的符号。 + +**语法** + +``` sql +addressToSymbol(address_of_binary_instruction) +``` + +**参数** + +- `address_of_binary_instruction` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Address of instruction in a running process. + +**返回值** + +- 来自ClickHouse对象文件的符号。 +- 空字符串,如果地址无效。 + +类型: [字符串](../../sql-reference/data-types/string.md). + +**示例** + +启用内省功能: + +``` sql +SET allow_introspection_functions=1 +``` + +从中选择第一个字符串 `trace_log` 系统表: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +该 `trace` 字段包含采样时的堆栈跟踪。 + +获取单个地址的符号: + +``` sql +SELECT addressToSymbol(94138803686098) \G +``` + +``` text +Row 1: +────── +addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +``` + +将函数应用于整个堆栈跟踪: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols +FROM system.trace_log +LIMIT 1 +\G +``` + +该 [arrayMap](higher-order-functions.md#higher_order_functions-array-map) 功能允许处理的每个单独的元素 `trace` 阵列由 `addressToSymbols` 功能。 这种处理的结果,你在看 `trace_symbols` 列的输出。 + +``` text +Row 1: +────── +trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE +_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE +_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb +_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb +_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE +_ZN2DB27AggregatingBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB26ExpressionBlockInputStream8readImplEv +_ZN2DB17IBlockInputStream4readEv +_ZN2DB28AsynchronousBlockInputStream9calculateEv +_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data +_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E +_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv +_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E +execute_native_thread_routine +start_thread +clone +``` + +## demangle {#demangle} + +转换一个符号,您可以使用 [addressToSymbol](#addresstosymbol) 函数到C++函数名。 + +**语法** + +``` sql +demangle(symbol) +``` + +**参数** + +- `symbol` ([字符串](../../sql-reference/data-types/string.md)) — Symbol from an object file. + +**返回值** + +- C++函数的名称。 +- 如果符号无效,则为空字符串。 + +类型: [字符串](../../sql-reference/data-types/string.md). + +**示例** + +启用内省功能: + +``` sql +SET allow_introspection_functions=1 +``` + +从中选择第一个字符串 `trace_log` 系统表: + +``` sql +SELECT * FROM system.trace_log LIMIT 1 \G +``` + +``` text +Row 1: +────── +event_date: 2019-11-20 +event_time: 2019-11-20 16:57:59 +revision: 54429 +timer_type: Real +thread_number: 48 +query_id: 724028bf-f550-45aa-910d-2af6212b94ac +trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] +``` + +该 `trace` 字段包含采样时的堆栈跟踪。 + +获取单个地址的函数名称: + +``` sql +SELECT demangle(addressToSymbol(94138803686098)) \G +``` + +``` text +Row 1: +────── +demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +``` + +将函数应用于整个堆栈跟踪: + +``` sql +SELECT + arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions +FROM system.trace_log +LIMIT 1 +\G +``` + +该 [arrayMap](higher-order-functions.md#higher_order_functions-array-map) 功能允许处理的每个单独的元素 `trace` 阵列由 `demangle` 功能。 这种处理的结果,你在看 `trace_functions` 列的输出。 + +``` text +Row 1: +────── +trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const +DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const +DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) +DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) +DB::AggregatingBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::ExpressionBlockInputStream::readImpl() +DB::IBlockInputStream::read() +DB::AsynchronousBlockInputStream::calculate() +std::_Function_handler::_M_invoke(std::_Any_data const&) +ThreadPoolImpl::worker(std::_List_iterator) +ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const +ThreadPoolImpl::worker(std::_List_iterator) +execute_native_thread_routine +start_thread +clone +``` diff --git a/docs/zh/sql-reference/functions/ip-address-functions.md b/docs/zh/sql-reference/functions/ip-address-functions.md new file mode 100644 index 00000000000..d208e0e6939 --- /dev/null +++ b/docs/zh/sql-reference/functions/ip-address-functions.md @@ -0,0 +1,217 @@ +# IP函数 {#iphan-shu} + +## IPv4NumToString(num) {#ipv4numtostringnum} + +接受一个UInt32(大端)表示的IPv4的地址,返回相应IPv4的字符串表现形式,格式为A.B.C.D(以点分割的十进制数字)。 + +## IPv4StringToNum(s) {#ipv4stringtonums} + +与IPv4NumToString函数相反。如果IPv4地址格式无效,则返回0。 + +## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} + +与IPv4NumToString类似,但使用xxx替换最后一个字节。 + +示例: + +``` sql +SELECT + IPv4NumToStringClassC(ClientIP) AS k, + count() AS c +FROM test.hits +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + + ┌─k──────────────┬─────c─┐ + │ 83.149.9.xxx │ 26238 │ + │ 217.118.81.xxx │ 26074 │ + │ 213.87.129.xxx │ 25481 │ + │ 83.149.8.xxx │ 24984 │ + │ 217.118.83.xxx │ 22797 │ + │ 78.25.120.xxx │ 22354 │ + │ 213.87.131.xxx │ 21285 │ + │ 78.25.121.xxx │ 20887 │ + │ 188.162.65.xxx │ 19694 │ + │ 83.149.48.xxx │ 17406 │ + └────────────────┴───────┘ + +由于使用’xxx’是不规范的,因此将来可能会更改。我们建议您不要依赖此格式。 + +### IPv6NumToString(x) {#ipv6numtostringx} + +接受FixedString(16)类型的二进制格式的IPv6地址。以文本格式返回此地址的字符串。 +IPv6映射的IPv4地址以::ffff:111.222.33。例如: + +``` sql +SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr +``` + + ┌─addr─────────┐ + │ 2a02:6b8::11 │ + └──────────────┘ + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + + ┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ + │ 2a02:2168:aaa:bbbb::2 │ 24695 │ + │ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ + │ 2a02:6b8:0:fff::ff │ 16389 │ + │ 2a01:4f8:111:6666::2 │ 16016 │ + │ 2a02:2168:888:222::1 │ 15896 │ + │ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ + │ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ + │ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ + │ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ + │ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ + └─────────────────────────────────────────┴───────┘ + +``` sql +SELECT + IPv6NumToString(ClientIP6 AS k), + count() AS c +FROM hits_all +WHERE EventDate = today() +GROUP BY k +ORDER BY c DESC +LIMIT 10 +``` + + ┌─IPv6NumToString(ClientIP6)─┬──────c─┐ + │ ::ffff:94.26.111.111 │ 747440 │ + │ ::ffff:37.143.222.4 │ 529483 │ + │ ::ffff:5.166.111.99 │ 317707 │ + │ ::ffff:46.38.11.77 │ 263086 │ + │ ::ffff:79.105.111.111 │ 186611 │ + │ ::ffff:93.92.111.88 │ 176773 │ + │ ::ffff:84.53.111.33 │ 158709 │ + │ ::ffff:217.118.11.22 │ 154004 │ + │ ::ffff:217.118.11.33 │ 148449 │ + │ ::ffff:217.118.11.44 │ 148243 │ + └────────────────────────────┴────────┘ + +## IPv6StringToNum(s) {#ipv6stringtonums} + +与IPv6NumToString的相反。如果IPv6地址格式无效,则返回空字节字符串。 +十六进制可以是大写的或小写的。 + +## IPv4ToIPv6(x) {#ipv4toipv6x} + +接受一个UInt32类型的IPv4地址,返回FixedString(16)类型的IPv6地址。例如: + +``` sql +SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr +``` + + ┌─addr───────────────┐ + │ ::ffff:192.168.0.1 │ + └────────────────────┘ + +## cutIPv6(x,bitsToCutForIPv6,bitsToCutForIPv4) {#cutipv6x-bitstocutforipv6-bitstocutforipv4} + +接受一个FixedString(16)类型的IPv6地址,返回一个String,这个String中包含了删除指定位之后的地址的文本格式。例如: + +``` sql +WITH + IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, + IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 +SELECT + cutIPv6(ipv6, 2, 0), + cutIPv6(ipv4, 0, 2) +``` + + ┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ + │ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ + └─────────────────────────────────────┴─────────────────────┘ + +## ツ古カツ益ツ催ツ団ツ法ツ人), {#ipv4cidrtorangeipv4-cidr} + +接受一个IPv4地址以及一个UInt8类型的CIDR。返回包含子网最低范围以及最高范围的元组。 + +``` sql +SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) +``` + + ┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ + │ ('192.168.0.0','192.168.255.255') │ + └────────────────────────────────────────────┘ + +## ツ暗ェツ氾环催ツ団ツ法ツ人), {#ipv6cidrtorangeipv6-cidr} + +接受一个IPv6地址以及一个UInt8类型的CIDR。返回包含子网最低范围以及最高范围的元组。 + +``` sql +SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); +``` + + ┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ + │ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ + └────────────────────────────────────────────────────────────────────────┘ + +## toIPv4(字符串) {#toipv4string} + +`IPv4StringToNum()`的别名,它采用字符串形式的IPv4地址并返回[IPv4](../../sql-reference/functions/ip-address-functions.md)类型的值,该二进制值等于`IPv4StringToNum()`返回的值。 + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + toTypeName(IPv4StringToNum(IPv4_string)), + toTypeName(toIPv4(IPv4_string)) +``` + + ┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ + │ UInt32 │ IPv4 │ + └──────────────────────────────────────────┴─────────────────────────────────┘ + +``` sql +WITH + '171.225.130.45' as IPv4_string +SELECT + hex(IPv4StringToNum(IPv4_string)), + hex(toIPv4(IPv4_string)) +``` + + ┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ + │ ABE1822D │ ABE1822D │ + └───────────────────────────────────┴──────────────────────────┘ + +## toIPv6(字符串) {#toipv6string} + +`IPv6StringToNum()`的别名,它采用字符串形式的IPv6地址并返回[IPv6](../../sql-reference/functions/ip-address-functions.md)类型的值,该二进制值等于`IPv6StringToNum()`返回的值。 + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + toTypeName(IPv6StringToNum(IPv6_string)), + toTypeName(toIPv6(IPv6_string)) +``` + + ┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ + │ FixedString(16) │ IPv6 │ + └──────────────────────────────────────────┴─────────────────────────────────┘ + +``` sql +WITH + '2001:438:ffff::407d:1bc1' as IPv6_string +SELECT + hex(IPv6StringToNum(IPv6_string)), + hex(toIPv6(IPv6_string)) +``` + + ┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ + │ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ + └───────────────────────────────────┴──────────────────────────────────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/zh/sql-reference/functions/json-functions.md b/docs/zh/sql-reference/functions/json-functions.md new file mode 100644 index 00000000000..dcdbef6bb87 --- /dev/null +++ b/docs/zh/sql-reference/functions/json-functions.md @@ -0,0 +1,174 @@ +# JSON函数 {#jsonhan-shu} + +在Yandex.Metrica中,用户使用JSON作为访问参数。为了处理这些JSON,实现了一些函数。(尽管在大多数情况下,JSON是预先进行额外处理的,并将结果值放在单独的列中。)所有的这些函数都进行了尽可能的假设。以使函数能够尽快的完成工作。 + +我们对JSON格式做了如下假设: + +1. 字段名称(函数的参数)必须使常量。 +2. 字段名称必须使用规范的编码。例如:`visitParamHas('{"abc":"def"}', 'abc') = 1`,但是 `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` +3. 函数可以随意的在多层嵌套结构下查找字段。如果存在多个匹配字段,则返回第一个匹配字段。 +4. JSON除字符串文本外不存在空格字符。 + +## ツ环板(ョツ嘉ッツ偲青visャツ静ャツ青サツ催ャツ渉) {#visitparamhasparams-name} + +检查是否存在«name»名称的字段 + +## 访问paramextractuint(参数,名称) {#visitparamextractuintparams-name} + +将名为«name»的字段的值解析成UInt64。如果这是一个字符串字段,函数将尝试从字符串的开头解析一个数字。如果该字段不存在,或无法从它中解析到数字,则返回0。 + +## visitParamExtractInt(参数,名称) {#visitparamextractintparams-name} + +与visitParamExtractUInt相同,但返回Int64。 + +## 访问paramextractfloat(参数,名称) {#visitparamextractfloatparams-name} + +与visitParamExtractUInt相同,但返回Float64。 + +## ツ环板(ョツ嘉ッツ偲青妥-ツ姪(不ツ督ョツ産) {#visitparamextractboolparams-name} + +解析true/false值。其结果是UInt8类型的。 + +## 掳胫((禄脢鹿脷露胫鲁隆鹿((酶-11-16""\[脪陆(,,,) {#visitparamextractrawparams-name} + +返回字段的值,包含空格符。 + +示例: + + visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' + visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' + +## visitParamExtractString(参数,名称) {#visitparamextractstringparams-name} + +使用双引号解析字符串。这个值没有进行转义。如果转义失败,它将返回一个空白字符串。 + +示例: + + visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' + visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' + visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' + visitParamExtractString('{"abc":"hello}', 'abc') = '' + +目前不支持`\uXXXX\uYYYY`这些字符编码,这些编码不在基本多文种平面中(它们被转化为CESU-8而不是UTF-8)。 + +以下函数基于[simdjson](https://github.com/lemire/simdjson),专为更复杂的JSON解析要求而设计。但上述假设2仍然适用。 + +## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} + +如果JSON中存在该值,则返回`1`。 + +如果该值不存在,则返回`0`。 + +示例: + + select JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 + select JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 + +`indices_or_keys`可以是零个或多个参数的列表,每个参数可以是字符串或整数。 + +- String = 按成员名称访问JSON对象成员。 +- 正整数 = 从头开始访问第n个成员/成员名称。 +- 负整数 = 从末尾访问第n个成员/成员名称。 + +您可以使用整数来访问JSON数组和JSON对象。 + +例如: + + select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' + select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' + select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' + select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' + select JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' + +## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} + +返回JSON数组或JSON对象的长度。 + +如果该值不存在或类型错误,将返回`0`。 + +示例: + + select JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 + select JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 + +## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} + +返回JSON值的类型。 + +如果该值不存在,将返回`Null`。 + +示例: + + select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' + select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' + select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' + +## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} + +## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} + +## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} + +## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} + +解析JSON并提取值。这些函数类似于`visitParam*`函数。 + +如果该值不存在或类型错误,将返回`0`。 + +示例: + + select JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 + select JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 + select JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 + +## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} + +解析JSON并提取字符串。此函数类似于`visitParamExtractString`函数。 + +如果该值不存在或类型错误,则返回空字符串。 + +该值未转义。如果unescaping失败,则返回一个空字符串。 + +示例: + + select JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' + select JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' + select JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' + select JSONExtractString('{"abc":"\\u263"}', 'abc') = '' + select JSONExtractString('{"abc":"hello}', 'abc') = '' + +## JSONExtract(json\[, indices\_or\_keys…\], Return\_type) {#jsonextractjson-indices-or-keys-return-type} + +解析JSON并提取给定ClickHouse数据类型的值。 + +这是以前的`JSONExtract函数的变体。 这意味着`JSONExtract(…, ‘String’)`返回与`JSONExtractString()`返回完全相同。`JSONExtract(…, ‘Float64’)`返回于`JSONExtractFloat()\`返回完全相同。 + +示例: + + SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) + SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') + SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] + SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL + SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 + SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' + SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' + +## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], Value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} + +从JSON中解析键值对,其中值是给定的ClickHouse数据类型。 + +示例: + + SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; + +## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} + +返回JSON的部分。 + +如果部件不存在或类型错误,将返回空字符串。 + +示例: + + select JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) diff --git a/docs/zh/sql-reference/functions/logical-functions.md b/docs/zh/sql-reference/functions/logical-functions.md new file mode 100644 index 00000000000..cc168dbb1ed --- /dev/null +++ b/docs/zh/sql-reference/functions/logical-functions.md @@ -0,0 +1,20 @@ +--- +toc_priority: 37 +toc_title: 逻辑函数 +--- + +# 逻辑函数 {#luo-ji-han-shu} + +逻辑函数可以接受任何数字类型的参数,并返回UInt8类型的0或1。 + +当向函数传递零时,函数将判定为«false»,否则,任何其他非零的值都将被判定为«true»。 + +## 和,`AND` 运算符 {#and-and-operator} + +## 或,`OR` 运算符 {#or-or-operator} + +## 非,`NOT` 运算符 {#not-not-operator} + +## 异或,`XOR` 运算符 {#xor} + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/zh/sql-reference/functions/machine-learning-functions.md b/docs/zh/sql-reference/functions/machine-learning-functions.md new file mode 100644 index 00000000000..77f8d76a722 --- /dev/null +++ b/docs/zh/sql-reference/functions/machine-learning-functions.md @@ -0,0 +1,15 @@ +# 机器学习函数 {#ji-qi-xue-xi-han-shu} + +## evalMLMethod(预测) {#machine_learning_methods-evalmlmethod} + +使用拟合回归模型的预测请使用`evalMLMethod`函数。 请参阅`linearRegression`中的链接。 + +## 随机线性回归 {#stochastic-linear-regression} + +`stochasticLinearRegression`聚合函数使用线性模型和MSE损失函数实现随机梯度下降法。 使用`evalMLMethod`来预测新数据。 +请参阅示例和注释[此处](../../sql-reference/functions/machine-learning-functions.md#agg_functions-stochasticlinearregression)。 + +## 随机逻辑回归 {#stochastic-logistic-regression} + +`stochasticLogisticRegression`聚合函数实现了二元分类问题的随机梯度下降法。 使用`evalMLMethod`来预测新数据。 +请参阅示例和注释[此处](../../sql-reference/functions/machine-learning-functions.md#agg_functions-stochasticlogisticregression)。 diff --git a/docs/zh/sql-reference/functions/math-functions.md b/docs/zh/sql-reference/functions/math-functions.md new file mode 100644 index 00000000000..81c2fcecdbc --- /dev/null +++ b/docs/zh/sql-reference/functions/math-functions.md @@ -0,0 +1,107 @@ +# 数学函数 {#shu-xue-han-shu} + +以下所有的函数都返回一个Float64类型的数值。返回结果总是以尽可能最大精度返回,但还是可能与机器中可表示最接近该值的数字不同。 + +## e() {#e} + +返回一个接近数学常量e的Float64数字。 + +## pi() {#pi} + +返回一个接近数学常量π的Float64数字。 + +## exp(x) {#expx} + +接受一个数值类型的参数并返回它的指数。 + +## log(x),ln(x) {#logx-lnx} + +接受一个数值类型的参数并返回它的自然对数。 + +## exp2(x) {#exp2x} + +接受一个数值类型的参数并返回它的2的x次幂。 + +## log2(x) {#log2x} + +接受一个数值类型的参数并返回它的底2对数。 + +## exp10(x) {#exp10x} + +接受一个数值类型的参数并返回它的10的x次幂。 + +## log10(x) {#log10x} + +接受一个数值类型的参数并返回它的底10对数。 + +## sqrt(x) {#sqrtx} + +接受一个数值类型的参数并返回它的平方根。 + +## cbrt(x) {#cbrtx} + +接受一个数值类型的参数并返回它的立方根。 + +## erf(x) {#erfx} + +如果’x’是非负数,那么`erf(x / σ√2)`是具有正态分布且标准偏差为«σ»的随机变量的值与预期值之间的距离大于«x»。 + +示例 (三西格玛准则): + +``` sql +SELECT erf(3 / sqrt(2)) +``` + + ┌─erf(divide(3, sqrt(2)))─┐ + │ 0.9973002039367398 │ + └─────────────────────────┘ + +## erfc(x) {#erfcx} + +接受一个数值参数并返回一个接近1 - erf(x)的Float64数字,但不会丢失大«x»值的精度。 + +## lgamma(x) {#lgammax} + +返回x的绝对值的自然对数的伽玛函数。 + +## tgamma(x) {#tgammax} + +返回x的伽玛函数。 + +## sin(x) {#sinx} + +返回x的三角正弦值。 + +## cos(x) {#cosx} + +返回x的三角余弦值。 + +## 谭(x) {#tanx} + +返回x的三角正切值。 + +## asin(x) {#asinx} + +返回x的反三角正弦值。 + +## acos(x) {#acosx} + +返回x的反三角余弦值。 + +## 阿坦(x) {#atanx} + +返回x的反三角正切值。 + +## pow(x,y),power(x,y) {#powx-y-powerx-y} + +接受x和y两个参数。返回x的y次方。 + +## intExp2 {#intexp2} + +接受一个数值类型的参数并返回它的2的x次幂(UInt64)。 + +## intExp10 {#intexp10} + +接受一个数值类型的参数并返回它的10的x次幂(UInt64)。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/zh/sql-reference/functions/other-functions.md b/docs/zh/sql-reference/functions/other-functions.md new file mode 100644 index 00000000000..16ce90e6ced --- /dev/null +++ b/docs/zh/sql-reference/functions/other-functions.md @@ -0,0 +1,537 @@ +# 其他函数 {#qi-ta-han-shu} + +## 主机名() {#hostname} + +返回一个字符串,其中包含执行此函数的主机的名称。 对于分布式处理,如果在远程服务器上执行此函数,则将返回远程服务器主机的名称。 + +## basename {#basename} + +在最后一个斜杠或反斜杠后的字符串文本。 此函数通常用于从路径中提取文件名。 + + basename( expr ) + +**参数** + +- `expr` — 任何一个返回[字符串](../../sql-reference/functions/other-functions.md)结果的表达式。[字符串](../../sql-reference/functions/other-functions.md) + +**返回值** + +一个String类型的值,其包含: + +- 在最后一个斜杠或反斜杠后的字符串文本内容。 + + 如果输入的字符串以斜杆或反斜杆结尾,例如:`/`或`c:\`,函数将返回一个空字符串。 + +- 如果输入的字符串中不包含斜杆或反斜杠,函数返回输入字符串本身。 + +**示例** + +``` sql +SELECT 'some/long/path/to/file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some\\long\\path\\to\\file' AS a, basename(a) +``` + +``` text +┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ +│ some\long\path\to\file │ file │ +└────────────────────────┴────────────────────────────────────────┘ +``` + +``` sql +SELECT 'some-file-name' AS a, basename(a) +``` + +``` text +┌─a──────────────┬─basename('some-file-name')─┐ +│ some-file-name │ some-file-name │ +└────────────────┴────────────────────────────┘ +``` + +## visibleWidth(x) {#visiblewidthx} + +以文本格式(以制表符分隔)向控制台输出值时,计算近似宽度。 +系统使用此函数实现Pretty格式。 +以文本格式(制表符分隔)将值输出到控制台时,计算近似宽度。 +这个函数被系统用于实现漂亮的格式。 + +`NULL` 表示为对应于 `NULL` 在 `Pretty` 格式。 + + SELECT visibleWidth(NULL) + + ┌─visibleWidth(NULL)─┐ + │ 4 │ + └────────────────────┘ + +## toTypeName(x) {#totypenamex} + +返回包含参数的类型名称的字符串。 + +如果将`NULL`作为参数传递给函数,那么它返回`Nullable(Nothing)`类型,它对应于ClickHouse中的内部`NULL`。 + +## 块大小() {#function-blocksize} + +获取Block的大小。 +在ClickHouse中,查询始终工作在Block(包含列的部分的集合)上。此函数允许您获取调用其的块的大小。 + +## 实现(x) {#materializex} + +将一个常量列变为一个非常量列。 +在ClickHouse中,非常量列和常量列在内存中的表示方式不同。尽管函数对于常量列和非常量总是返回相同的结果,但它们的工作方式可能完全不同(执行不同的代码)。此函数用于调试这种行为。 + +## ignore(…) {#ignore} + +接受任何参数,包括`NULL`。始终返回0。 +但是,函数的参数总是被计算的。该函数可以用于基准测试。 + +## 睡眠(秒) {#sleepseconds} + +在每个Block上休眠’seconds’秒。可以是整数或浮点数。 + +## sleepEachRow(秒) {#sleepeachrowseconds} + +在每行上休眠’seconds’秒。可以是整数或浮点数。 + +## 当前数据库() {#currentdatabase} + +返回当前数据库的名称。 +当您需要在CREATE TABLE中的表引擎参数中指定数据库,您可以使用此函数。 + +## isFinite(x) {#isfinitex} + +接受Float32或Float64类型的参数,如果参数不是infinite且不是NaN,则返回1,否则返回0。 + +## isInfinite(x) {#isinfinitex} + +接受Float32或Float64类型的参数,如果参数是infinite,则返回1,否则返回0。注意NaN返回0。 + +## isNaN(x) {#isnanx} + +接受Float32或Float64类型的参数,如果参数是Nan,则返回1,否则返回0。 + +## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} + +接受常量字符串:数据库名称、表名称和列名称。 如果存在列,则返回等于1的UInt8常量表达式,否则返回0。 如果设置了hostname参数,则测试将在远程服务器上运行。 +如果表不存在,该函数将引发异常。 +对于嵌套数据结构中的元素,该函数检查是否存在列。 对于嵌套数据结构本身,函数返回0。 + +## 酒吧 {#function-bar} + +使用unicode构建图表。 + +`bar(x, min, max, width)` 当`x = max`时, 绘制一个宽度与`(x - min)`成正比且等于`width`的字符带。 + +参数: + +- `x` — 要显示的尺寸。 +- `min, max` — 整数常量,该值必须是`Int64`。 +- `width` — 常量,可以是正整数或小数。 + +字符带的绘制精度是符号的八分之一。 + +示例: + +``` sql +SELECT + toHour(EventTime) AS h, + count() AS c, + bar(c, 0, 600000, 20) AS bar +FROM test.hits +GROUP BY h +ORDER BY h ASC +``` + + ┌──h─┬──────c─┬─bar────────────────┐ + │ 0 │ 292907 │ █████████▋ │ + │ 1 │ 180563 │ ██████ │ + │ 2 │ 114861 │ ███▋ │ + │ 3 │ 85069 │ ██▋ │ + │ 4 │ 68543 │ ██▎ │ + │ 5 │ 78116 │ ██▌ │ + │ 6 │ 113474 │ ███▋ │ + │ 7 │ 170678 │ █████▋ │ + │ 8 │ 278380 │ █████████▎ │ + │ 9 │ 391053 │ █████████████ │ + │ 10 │ 457681 │ ███████████████▎ │ + │ 11 │ 493667 │ ████████████████▍ │ + │ 12 │ 509641 │ ████████████████▊ │ + │ 13 │ 522947 │ █████████████████▍ │ + │ 14 │ 539954 │ █████████████████▊ │ + │ 15 │ 528460 │ █████████████████▌ │ + │ 16 │ 539201 │ █████████████████▊ │ + │ 17 │ 523539 │ █████████████████▍ │ + │ 18 │ 506467 │ ████████████████▊ │ + │ 19 │ 520915 │ █████████████████▎ │ + │ 20 │ 521665 │ █████████████████▍ │ + │ 21 │ 542078 │ ██████████████████ │ + │ 22 │ 493642 │ ████████████████▍ │ + │ 23 │ 400397 │ █████████████▎ │ + └────┴────────┴────────────────────┘ + +## 变换 {#transform} + +根据定义,将某些元素转换为其他元素。 +此函数有两种使用方式: + +1. `transform(x, array_from, array_to, default)` + +`x` – 要转换的值。 + +`array_from` – 用于转换的常量数组。 + +`array_to` – 将’from’中的值转换为的常量数组。 + +`default` – 如果’x’不等于’from’中的任何值,则默认转换的值。 + +`array_from` 和 `array_to` – 拥有相同大小的数组。 + +类型约束: + +`transform(T, Array(T), Array(U), U) -> U` + +`T`和`U`可以是String,Date,DateTime或任意数值类型的。 +对于相同的字母(T或U),如果数值类型,那么它们不可不完全匹配的,只需要具备共同的类型即可。 +例如,第一个参数是Int64类型,第二个参数是Array(UInt16)类型。 + +如果’x’值等于’array\_from’数组中的一个元素,它将从’array\_to’数组返回一个对应的元素(下标相同)。否则,它返回’default’。如果’array\_from’匹配到了多个元素,则返回第一个匹配的元素。 + +示例: + +``` sql +SELECT + transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, + count() AS c +FROM test.hits +WHERE SearchEngineID != 0 +GROUP BY title +ORDER BY c DESC +``` + + ┌─title─────┬──────c─┐ + │ Yandex │ 498635 │ + │ Google │ 229872 │ + │ Other │ 104472 │ + └───────────┴────────┘ + +1. `transform(x, array_from, array_to)` + +与第一种不同在于省略了’default’参数。 +如果’x’值等于’array\_from’数组中的一个元素,它将从’array\_to’数组返回相应的元素(下标相同)。 否则,它返回’x’。 + +类型约束: + +`transform(T, Array(T), Array(T)) -> T` + +示例: + +``` sql +SELECT + transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, + count() AS c +FROM test.hits +GROUP BY domain(Referer) +ORDER BY count() DESC +LIMIT 10 +``` + + ┌─s──────────────┬───────c─┐ + │ │ 2906259 │ + │ www.yandex │ 867767 │ + │ ███████.ru │ 313599 │ + │ mail.yandex.ru │ 107147 │ + │ ██████.ru │ 100355 │ + │ █████████.ru │ 65040 │ + │ news.yandex.ru │ 64515 │ + │ ██████.net │ 59141 │ + │ example.com │ 57316 │ + └────────────────┴─────────┘ + +## formatReadableSize(x) {#formatreadablesizex} + +接受大小(字节数)。返回带有后缀(KiB, MiB等)的字符串。 + +示例: + +``` sql +SELECT + arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, + formatReadableSize(filesize_bytes) AS filesize +``` + + ┌─filesize_bytes─┬─filesize───┐ + │ 1 │ 1.00 B │ + │ 1024 │ 1.00 KiB │ + │ 1048576 │ 1.00 MiB │ + │ 192851925 │ 183.92 MiB │ + └────────────────┴────────────┘ + +## 至少(a,b) {#leasta-b} + +返回a和b中的最小值。 + +## 最伟大(a,b) {#greatesta-b} + +返回a和b的最大值。 + +## 碌莽禄time拢time() {#uptime} + +返回服务正常运行的秒数。 + +## 版本() {#version} + +以字符串形式返回服务器的版本。 + +## 时区() {#timezone} + +返回服务器的时区。 + +## blockNumber {#blocknumber} + +返回行所在的Block的序列号。 + +## rowNumberInBlock {#function-rownumberinblock} + +返回行所在Block中行的序列号。 针对不同的Block始终重新计算。 + +## rowNumberInAllBlocks() {#rownumberinallblocks} + +返回行所在结果集中的序列号。此函数仅考虑受影响的Block。 + +## 运行差异(x) {#other_functions-runningdifference} + +计算数据块中相邻行的值之间的差异。 +对于第一行返回0,并为每个后续行返回与前一行的差异。 + +函数的结果取决于受影响的Block和Block中的数据顺序。 +如果使用ORDER BY创建子查询并从子查询外部调用该函数,则可以获得预期结果。 + +示例: + +``` sql +SELECT + EventID, + EventTime, + runningDifference(EventTime) AS delta +FROM +( + SELECT + EventID, + EventTime + FROM events + WHERE EventDate = '2016-11-24' + ORDER BY EventTime ASC + LIMIT 5 +) +``` + + ┌─EventID─┬───────────EventTime─┬─delta─┐ + │ 1106 │ 2016-11-24 00:00:04 │ 0 │ + │ 1107 │ 2016-11-24 00:00:05 │ 1 │ + │ 1108 │ 2016-11-24 00:00:05 │ 0 │ + │ 1109 │ 2016-11-24 00:00:09 │ 4 │ + │ 1110 │ 2016-11-24 00:00:10 │ 1 │ + └─────────┴─────────────────────┴───────┘ + +## 运行差异启动与第一值 {#runningdifferencestartingwithfirstvalue} + +与[运行差异](./other-functions.md#other_functions-runningdifference)相同,区别在于第一行返回第一行的值,后续每个后续行返回与上一行的差值。 + +## MACNumToString(num) {#macnumtostringnum} + +接受一个UInt64类型的数字。 将其解释为big endian的MAC地址。 返回包含相应MAC地址的字符串,格式为AA:BB:CC:DD:EE:FF(以冒号分隔的十六进制形式的数字)。 + +## MACStringToNum(s) {#macstringtonums} + +与MACNumToString相反。 如果MAC地址格式无效,则返回0。 + +## MACStringToOUI(s) {#macstringtoouis} + +接受格式为AA:BB:CC:DD:EE:FF(十六进制形式的冒号分隔数字)的MAC地址。 返回前三个八位字节作为UInt64编号。 如果MAC地址格式无效,则返回0。 + +## getSizeOfEnumType {#getsizeofenumtype} + +返回[枚举](../../sql-reference/functions/other-functions.md)中的枚举数量。 + + getSizeOfEnumType(value) + +**参数:** + +- `value` — `Enum`类型的值。 + +**返回值** + +- `Enum`的枚举数量。 +- 如果类型不是`Enum`,则抛出异常。 + +**示例** + + SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x + + ┌─x─┐ + │ 2 │ + └───┘ + +## toColumnTypeName {#tocolumntypename} + +返回在RAM中列的数据类型的名称。 + + toColumnTypeName(value) + +**参数:** + +- `value` — 任何类型的值。 + +**返回值** + +- 一个字符串,其内容是`value`在RAM中的类型名称。 + +**`toTypeName ' 与 ' toColumnTypeName`的区别示例** + + :) select toTypeName(cast('2018-01-01 01:02:03' AS DateTime)) + + SELECT toTypeName(CAST('2018-01-01 01:02:03', 'DateTime')) + + ┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ + │ DateTime │ + └─────────────────────────────────────────────────────┘ + + 1 rows in set. Elapsed: 0.008 sec. + + :) select toColumnTypeName(cast('2018-01-01 01:02:03' AS DateTime)) + + SELECT toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime')) + + ┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ + │ Const(UInt32) │ + └───────────────────────────────────────────────────────────┘ + +该示例显示`DateTime`数据类型作为`Const(UInt32)`存储在内存中。 + +## dumpColumnStructure {#dumpcolumnstructure} + +输出在RAM中的数据结果的详细信息。 + + dumpColumnStructure(value) + +**参数:** + +- `value` — 任何类型的值. + +**返回值** + +- 一个字符串,其内容是`value`在RAM中的数据结构的详细描述。 + +**示例** + + SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) + + ┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ + │ DateTime, Const(size = 1, UInt32(size = 1)) │ + └──────────────────────────────────────────────────────────────┘ + +## defaultValueOfArgumentType {#defaultvalueofargumenttype} + +输出数据类型的默认值。 + +不包括用户设置的自定义列的默认值。 + + defaultValueOfArgumentType(expression) + +**参数:** + +- `expression` — 任意类型的值或导致任意类型值的表达式。 + +**返回值** + +- 数值类型返回`0`。 +- 字符串类型返回空的字符串。 +- [可为空](../../sql-reference/functions/other-functions.md)类型返回`ᴺᵁᴸᴸ`。 + +**示例** + + :) SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) + + SELECT defaultValueOfArgumentType(CAST(1, 'Int8')) + + ┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ + │ 0 │ + └─────────────────────────────────────────────┘ + + 1 rows in set. Elapsed: 0.002 sec. + + :) SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) + + SELECT defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)')) + + ┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ + │ ᴺᵁᴸᴸ │ + └───────────────────────────────────────────────────────┘ + + 1 rows in set. Elapsed: 0.002 sec. + +## 复制 {#replicate} + +使用单个值填充一个数组。 + +用于[arrayJoin](array-join.md#functions_arrayjoin)的内部实现。 + + replicate(x, arr) + +**参数:** + +- `arr` — 原始数组。 ClickHouse创建一个与原始数据长度相同的新数组,并用值`x`填充它。 +- `x` — 生成的数组将被填充的值。 + +**输出** + +- 一个被`x`填充的数组。 + +**示例** + + SELECT replicate(1, ['a', 'b', 'c']) + + ┌─replicate(1, ['a', 'b', 'c'])─┐ + │ [1,1,1] │ + └───────────────────────────────┘ + +## 文件系统可用 {#filesystemavailable} + +返回磁盘的剩余空间信息(以字节为单位)。使用配置文件中的path配置评估此信息。 + +## 文件系统容量 {#filesystemcapacity} + +返回磁盘的容量信息,以字节为单位。使用配置文件中的path配置评估此信息。 + +## 最后聚会 {#function-finalizeaggregation} + +获取聚合函数的状态。返回聚合结果(最终状态)。 + +## 跑累积 {#function-runningaccumulate} + +获取聚合函数的状态并返回其具体的值。这是从第一行到当前行的所有行累计的结果。 + +例如,获取聚合函数的状态(示例runningAccumulate(uniqState(UserID))),对于数据块的每一行,返回所有先前行和当前行的状态合并后的聚合函数的结果。 +因此,函数的结果取决于分区中数据块的顺序以及数据块中行的顺序。 + +## joinGet(‘join\_storage\_table\_name’, ‘get\_column’,join\_key) {#joingetjoin-storage-table-name-get-column-join-key} + +使用指定的连接键从Join类型引擎的表中获取数据。 + +## modelEvaluate(model\_name, …) {#function-modelevaluate} + +使用外部模型计算。 +接受模型的名称以及模型的参数。返回Float64类型的值。 + +## throwIf(x) {#throwifx} + +如果参数不为零则抛出异常。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/zh/sql-reference/functions/random-functions.md b/docs/zh/sql-reference/functions/random-functions.md new file mode 100644 index 00000000000..d2d9fdf87a6 --- /dev/null +++ b/docs/zh/sql-reference/functions/random-functions.md @@ -0,0 +1,21 @@ +# 随机函数 {#sui-ji-han-shu} + +随机函数使用非加密方式生成伪随机数字。 + +所有随机函数都只接受一个参数或不接受任何参数。 +您可以向它传递任何类型的参数,但传递的参数将不会使用在任何随机数生成过程中。 +此参数的唯一目的是防止公共子表达式消除,以便在相同的查询中使用相同的随机函数生成不同的随机数。 + +## 兰德 {#rand} + +返回一个UInt32类型的随机数字,所有UInt32类型的数字被生成的概率均相等。此函数线性同于的方式生成随机数。 + +## rand64 {#rand64} + +返回一个UInt64类型的随机数字,所有UInt64类型的数字被生成的概率均相等。此函数线性同于的方式生成随机数。 + +## randConstant {#randconstant} + +返回一个UInt32类型的随机数字,该函数不同之处在于仅为每个数据块参数一个随机数。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/zh/sql-reference/functions/rounding-functions.md b/docs/zh/sql-reference/functions/rounding-functions.md new file mode 100644 index 00000000000..c1bf6641135 --- /dev/null +++ b/docs/zh/sql-reference/functions/rounding-functions.md @@ -0,0 +1,86 @@ +# 取整函数 {#qu-zheng-han-shu} + +## 楼(x\[,N\]) {#floorx-n} + +返回小于或等于x的最大舍入数。该函数使用参数乘1/10N,如果1/10N不精确,则选择最接近的精确的适当数据类型的数。 +’N’是一个整数常量,可选参数。默认为0,这意味着不对其进行舍入。 +’N’可以是负数。 + +示例: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` + +`x`是任何数字类型。结果与其为相同类型。 +对于整数参数,使用负’N’值进行舍入是有意义的(对于非负«N»,该函数不执行任何操作)。 +如果取整导致溢出(例如,floor(-128,-1)),则返回特定于实现的结果。 + +## ceil(x\[,N\]),天花板(x\[,N\]) {#ceilx-n-ceilingx-n} + +返回大于或等于’x’的最小舍入数。在其他方面,它与’floor’功能相同(见上文)。 + +## 圆形(x\[,N\]) {#rounding_functions-round} + +将值取整到指定的小数位数。 + +该函数按顺序返回最近的数字。如果给定数字包含多个最近数字,则函数返回其中最接近偶数的数字(银行的取整方式)。 + + round(expression [, decimal_places]) + +**参数:** + +- `expression` — 要进行取整的数字。可以是任何返回数字[类型](../../sql-reference/functions/rounding-functions.md#data_types)的[表达式](../syntax.md#syntax-expressions)。 +- `decimal-places` — 整数类型。 + - 如果`decimal-places > 0`,则该函数将值舍入小数点右侧。 + - 如果`decimal-places < 0`,则该函数将小数点左侧的值四舍五入。 + - 如果`decimal-places = 0`,则该函数将该值舍入为整数。在这种情况下,可以省略参数。 + +**返回值:** + +与输入数字相同类型的取整后的数字。 + +### 示例 {#shi-li} + +**使用示例** + +``` sql +SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 +``` + + ┌───x─┬─round(divide(number, 2))─┐ + │ 0 │ 0 │ + │ 0.5 │ 0 │ + │ 1 │ 1 │ + └─────┴──────────────────────────┘ + +**取整的示例** + +取整到最近的数字。 + + round(3.2, 0) = 3 + round(4.1267, 2) = 4.13 + round(22,-1) = 20 + round(467,-2) = 500 + round(-467,-2) = -500 + +银行的取整。 + + round(3.5) = 4 + round(4.5) = 4 + round(3.55, 1) = 3.6 + round(3.65, 1) = 3.6 + +## roundToExp2(num) {#roundtoexp2num} + +接受一个数字。如果数字小于1,则返回0。否则,它将数字向下舍入到最接近的(整个非负)2的x次幂。 + +## 圆形饱和度(num) {#rounddurationnum} + +接受一个数字。如果数字小于1,则返回0。否则,它将数字向下舍入为集合中的数字:1,10,30,60,120,180,240,300,600,1200,1800,3600,7200,18000,36000。此函数用于Yandex.Metrica报表中计算会话的持续时长。 + +## 圆数(num) {#roundagenum} + +接受一个数字。如果数字小于18,则返回0。否则,它将数字向下舍入为集合中的数字:18,25,35,45,55。此函数用于Yandex.Metrica报表中用户年龄的计算。 + +## roundDown(num,arr) {#rounddownnum-arr} + +接受一个数字,将其向下舍入到指定数组中的元素。如果该值小于数组中的最低边界,则返回最低边界。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/zh/sql-reference/functions/splitting-merging-functions.md b/docs/zh/sql-reference/functions/splitting-merging-functions.md new file mode 100644 index 00000000000..a29f4057d55 --- /dev/null +++ b/docs/zh/sql-reference/functions/splitting-merging-functions.md @@ -0,0 +1,29 @@ +# 字符串拆分合并函数 {#zi-fu-chuan-chai-fen-he-bing-han-shu} + +## splitByChar(分隔符,s) {#splitbycharseparator-s} + +将字符串以’separator’拆分成多个子串。’separator’必须为仅包含一个字符的字符串常量。 +返回拆分后的子串的数组。 如果分隔符出现在字符串的开头或结尾,或者如果有多个连续的分隔符,则将在对应位置填充空的子串。 + +## splitByString(分隔符,s) {#splitbystringseparator-s} + +与上面相同,但它使用多个字符的字符串作为分隔符。 该字符串必须为非空。 + +## arrayStringConcat(arr\[,分隔符\]) {#arraystringconcatarr-separator} + +使用separator将数组中列出的字符串拼接起来。’separator’是一个可选参数:一个常量字符串,默认情况下设置为空字符串。 +返回拼接后的字符串。 + +## alphaTokens(s) {#alphatokenss} + +从范围a-z和A-Z中选择连续字节的子字符串。返回子字符串数组。 + +**示例:** + + SELECT alphaTokens('abca1abc') + + ┌─alphaTokens('abca1abc')─┐ + │ ['abca','abc'] │ + └─────────────────────────┘ + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/zh/sql-reference/functions/string-functions.md b/docs/zh/sql-reference/functions/string-functions.md new file mode 100644 index 00000000000..70b361ebf1b --- /dev/null +++ b/docs/zh/sql-reference/functions/string-functions.md @@ -0,0 +1,169 @@ +# 字符串函数 {#zi-fu-chuan-han-shu} + +## 空 {#string-functions-empty} + +对于空字符串返回1,对于非空字符串返回0。 +结果类型是UInt8。 +如果字符串包含至少一个字节,则该字符串被视为非空字符串,即使这是一个空格或空字符。 +该函数也适用于数组。 + +## notEmpty {#notempty} + +对于空字符串返回0,对于非空字符串返回1。 +结果类型是UInt8。 +该函数也适用于数组。 + +## 长度 {#length} + +返回字符串的字节长度。 +结果类型是UInt64。 +该函数也适用于数组。 + +## 长度8 {#lengthutf8} + +假定字符串以UTF-8编码组成的文本,返回此字符串的Unicode字符长度。如果传入的字符串不是UTF-8编码,则函数可能返回一个预期外的值(不会抛出异常)。 +结果类型是UInt64。 + +## char\_length,CHAR\_LENGTH {#char-length-char-length} + +假定字符串以UTF-8编码组成的文本,返回此字符串的Unicode字符长度。如果传入的字符串不是UTF-8编码,则函数可能返回一个预期外的值(不会抛出异常)。 +结果类型是UInt64。 + +## 字符长度,字符长度 {#character-length-character-length} + +假定字符串以UTF-8编码组成的文本,返回此字符串的Unicode字符长度。如果传入的字符串不是UTF-8编码,则函数可能返回一个预期外的值(不会抛出异常)。 +结果类型是UInt64。 + +## 低一点 {#lower-lcase} + +将字符串中的ASCII转换为小写。 + +## 上,ucase {#upper-ucase} + +将字符串中的ASCII转换为大写。 + +## lowerUTF8 {#lowerutf8} + +将字符串转换为小写,函数假设字符串是以UTF-8编码文本的字符集。 +同时函数不检测语言。因此对土耳其人来说,结果可能不完全正确。 +如果UTF-8字节序列的长度对于代码点的大写和小写不同,则该代码点的结果可能不正确。 +如果字符串包含一组非UTF-8的字节,则将引发未定义行为。 + +## upperUTF8 {#upperutf8} + +将字符串转换为大写,函数假设字符串是以UTF-8编码文本的字符集。 +同时函数不检测语言。因此对土耳其人来说,结果可能不完全正确。 +如果UTF-8字节序列的长度对于代码点的大写和小写不同,则该代码点的结果可能不正确。 +如果字符串包含一组非UTF-8的字节,则将引发未定义行为。 + +## isValidUTF8 {#isvalidutf8} + +检查字符串是否为有效的UTF-8编码,是则返回1,否则返回0。 + +## toValidUTF8 {#tovalidutf8} + +用`�`(U+FFFD)字符替换无效的UTF-8字符。所有连续的无效字符都会被替换为一个替换字符。 + + toValidUTF8( input_string ) + +参数: + +- input\_string — 任何一个[字符串](../../sql-reference/functions/string-functions.md)类型的对象。 + +返回值: 有效的UTF-8字符串。 + +### 示例 {#shi-li} + +``` sql +SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') +``` + +``` text +┌─toValidUTF8('a����b')─┐ +│ a�b │ +└───────────────────────┘ +``` + +## 反向 {#reverse} + +反转字符串。 + +## reverseUTF8 {#reverseutf8} + +以Unicode字符为单位反转UTF-8编码的字符串。如果字符串不是UTF-8编码,则可能获取到一个非预期的结果(不会抛出异常)。 + +## format(pattern, s0, s1, …) {#formatpattern-s0-s1} + +使用常量字符串`pattern`格式化其他参数。`pattern`字符串中包含由大括号`{}`包围的«替换字段»。 未被包含在大括号中的任何内容都被视为文本内容,它将原样保留在返回值中。 如果你需要在文本内容中包含一个大括号字符,它可以通过加倍来转义:`{{ '{{' }}`和`{{ '{{' }} '}}' }}`。 字段名称可以是数字(从零开始)或空(然后将它们视为连续数字) + +``` sql +SELECT format('{1} {0} {1}', 'World', 'Hello') + +┌─format('{1} {0} {1}', 'World', 'Hello')─┐ +│ Hello World Hello │ +└─────────────────────────────────────────┘ + +SELECT format('{} {}', 'Hello', 'World') + +┌─format('{} {}', 'Hello', 'World')─┐ +│ Hello World │ +└───────────────────────────────────┘ +``` + +## concat(s1, s2, …) {#concat-s1-s2} + +将参数中的多个字符串拼接,不带分隔符。 + +## concatAssumeInjective(s1, s2, …) {#concatassumeinjectives1-s2} + +与[concat](#concat-s1-s2)相同,区别在于,你需要保证concat(s1, s2, s3) -\> s4是单射的,它将用于GROUP BY的优化。 + +## 子串(s,offset,length),mid(s,offset,length),substr(s,offset,length) {#substrings-offset-length-mids-offset-length-substrs-offset-length} + +以字节为单位截取指定位置字符串,返回以’offset’位置为开头,长度为’length’的子串。’offset’从1开始(与标准SQL相同)。’offset’和’length’参数必须是常量。 + +## substringf8(s,offset,length) {#substringutf8s-offset-length} + +与’substring’相同,但其操作单位为Unicode字符,函数假设字符串是以UTF-8进行编码的文本。如果不是则可能返回一个预期外的结果(不会抛出异常)。 + +## appendTrailingCharIfAbsent(s,c) {#appendtrailingcharifabsents-c} + +如果’s’字符串非空并且末尾不包含’c’字符,则将’c’字符附加到末尾。 + +## convertCharset(s,from,to) {#convertcharsets-from-to} + +返回从’from’中的编码转换为’to’中的编码的字符串’s’。 + +## base64Encode(s) {#base64encodes} + +将字符串’s’编码成base64 + +## base64Decode(s) {#base64decodes} + +使用base64将字符串解码成原始字符串。如果失败则抛出异常。 + +## tryBase64Decode(s) {#trybase64decodes} + +使用base64将字符串解码成原始字符串。但如果出现错误,将返回空字符串。 + +## endsWith(s,后缀) {#endswiths-suffix} + +返回是否以指定的后缀结尾。如果字符串以指定的后缀结束,则返回1,否则返回0。 + +## 开始使用(s,前缀) {#startswiths-prefix} + +返回是否以指定的前缀开头。如果字符串以指定的前缀开头,则返回1,否则返回0。 + +## trimLeft(s) {#trimlefts} + +返回一个字符串,用于删除左侧的空白字符。 + +## trimRight(s) {#trimrights} + +返回一个字符串,用于删除右侧的空白字符。 + +## trimBoth(s) {#trimboths} + +返回一个字符串,用于删除任一侧的空白字符。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/zh/sql-reference/functions/string-replace-functions.md b/docs/zh/sql-reference/functions/string-replace-functions.md new file mode 100644 index 00000000000..67346f5c156 --- /dev/null +++ b/docs/zh/sql-reference/functions/string-replace-functions.md @@ -0,0 +1,79 @@ +# 字符串替换函数 {#zi-fu-chuan-ti-huan-han-shu} + +## replaceOne(大海捞针,模式,更换) {#replaceonehaystack-pattern-replacement} + +用’replacement’子串替换’haystack’中与’pattern’子串第一个匹配的匹配项(如果存在)。 +’pattern’和’replacement’必须是常量。 + +## replaceAll(大海捞针,模式,替换),替换(大海捞针,模式,替换) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} + +用’replacement’子串替换’haystack’中出现的所有’pattern’子串。 + +## replaceRegexpOne(大海捞针,模式,更换) {#replaceregexponehaystack-pattern-replacement} + +使用’pattern’正则表达式替换。 ‘pattern’可以是任意一个有效的re2正则表达式。 +如果存在与正则表达式匹配的匹配项,仅替换第一个匹配项。 +同时‘replacement’可以指定为正则表达式中的捕获组。可以包含`\0-\9`。 +在这种情况下,函数将使用正则表达式的整个匹配项替换‘\\0’。使用其他与之对应的子模式替换对应的’\\1-\\9’。要在模版中使用’‘字符,请使用’’将其转义。 +另外还请记住,字符串文字需要额外的转义。 + +示例1.将日期转换为美国格式: + +``` sql +SELECT DISTINCT + EventDate, + replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res +FROM test.hits +LIMIT 7 +FORMAT TabSeparated +``` + + 2014-03-17 03/17/2014 + 2014-03-18 03/18/2014 + 2014-03-19 03/19/2014 + 2014-03-20 03/20/2014 + 2014-03-21 03/21/2014 + 2014-03-22 03/22/2014 + 2014-03-23 03/23/2014 + +示例2.复制字符串十次: + +``` sql +SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res +``` + + ┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ + └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + +## replaceRegexpAll(大海捞针,模式,替换) {#replaceregexpallhaystack-pattern-replacement} + +与replaceRegexpOne相同,但会替换所有出现的匹配项。例如: + +``` sql +SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res +``` + + ┌─res────────────────────────┐ + │ HHeelllloo,, WWoorrlldd!! │ + └────────────────────────────┘ + +例外的是,如果使用正则表达式捕获空白子串,则仅会进行一次替换。 +示例: + +``` sql +SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res +``` + + ┌─res─────────────────┐ + │ here: Hello, World! │ + └─────────────────────┘ + +## regexpQuoteMeta(s) {#regexpquotemetas} + +该函数用于在字符串中的某些预定义字符之前添加反斜杠。 +预定义字符:‘0’,‘\\’,‘\|’,‘(’,‘)’,‘^’,‘$’,‘。’,‘\[’,‘\]’,‘?’,‘\*’,‘+’,‘{’,‘:’,’ - ’。 +这个实现与re2 :: RE2 :: QuoteMeta略有不同。它以\\0而不是00转义零字节,它只转义所需的字符。 +有关详细信息,请参阅链接:\[RE2\](https://github.com/google/re2/blob/master/re2/re2.cc\#L473) + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/zh/sql-reference/functions/string-search-functions.md b/docs/zh/sql-reference/functions/string-search-functions.md new file mode 100644 index 00000000000..2e1e4c784bd --- /dev/null +++ b/docs/zh/sql-reference/functions/string-search-functions.md @@ -0,0 +1,122 @@ +# 字符串搜索函数 {#zi-fu-chuan-sou-suo-han-shu} + +下列所有函数在默认的情况下区分大小写。对于不区分大小写的搜索,存在单独的变体。 + +## 位置(大海捞针),定位(大海捞针) {#positionhaystack-needle-locatehaystack-needle} + +在字符串`haystack`中搜索子串`needle`。 +返回子串的位置(以字节为单位),从1开始,如果未找到子串,则返回0。 + +对于不区分大小写的搜索,请使用函数`positionCaseInsensitive`。 + +## positionUTF8(大海捞针) {#positionutf8haystack-needle} + +与`position`相同,但位置以Unicode字符返回。此函数工作在UTF-8编码的文本字符集中。如非此编码的字符集,则返回一些非预期结果(他不会抛出异常)。 + +对于不区分大小写的搜索,请使用函数`positionCaseInsensitiveUTF8`。 + +## 多搜索分配(干草堆,\[针1,针2, …, needlen\]) {#multisearchallpositionshaystack-needle1-needle2-needlen} + +与`position`相同,但函数返回一个数组,其中包含所有匹配needle的位置。 + +对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchAllPositionsCaseInsensitive,multiSearchAllPositionsUTF8,multiSearchAllPositionsCaseInsensitiveUTF8`。 + +## multiSearchFirstPosition(大海捞针,\[针1,针2, …, needlen\]) {#multisearchfirstpositionhaystack-needle1-needle2-needlen} + +与`position`相同,但返回在`haystack`中与needles字符串匹配的最左偏移。 + +对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchFirstPositionCaseInsensitive,multiSearchFirstPositionUTF8,multiSearchFirstPositionCaseInsensitiveUTF8`。 + +## multiSearchFirstIndex(大海捞针,\[针1,针2, …, needlen\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} + +返回在字符串`haystack`中最先查找到的needle的索引`i`(从1开始),没有找到任何匹配项则返回0。 + +对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchFirstIndexCaseInsensitive,multiSearchFirstIndexUTF8,multiSearchFirstIndexCaseInsensitiveUTF8`。 + +## 多搜索(大海捞针,\[针1,针2, …, needlen\]) {#multisearchanyhaystack-needle1-needle2-needlen} + +如果`haystack`中至少存在一个needle匹配则返回1,否则返回0。 + +对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchAnyCaseInsensitive,multiSearchAnyUTF8,multiSearchAnyCaseInsensitiveUTF8`。 + +!!! note "注意" + 在所有`multiSearch*`函数中,由于实现规范,needles的数量应小于28。 + +## 匹配(大海捞针,模式) {#matchhaystack-pattern} + +检查字符串是否与`pattern`正则表达式匹配。`pattern`可以是一个任意的`re2`正则表达式。 `re2`正则表达式的[语法](https://github.com/google/re2/wiki/Syntax)比Perl正则表达式的语法存在更多限制。 + +如果不匹配返回0,否则返回1。 + +请注意,反斜杠符号(`\`)用于在正则表达式中转义。由于字符串中采用相同的符号来进行转义。因此,为了在正则表达式中转义符号,必须在字符串文字中写入两个反斜杠(\\)。 + +正则表达式与字符串一起使用,就像它是一组字节一样。正则表达式中不能包含空字节。 +对于在字符串中搜索子字符串的模式,最好使用LIKE或«position»,因为它们更加高效。 + +## multiMatchAny(大海捞针,\[模式1,模式2, …, patternn\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} + +与`match`相同,但如果所有正则表达式都不匹配,则返回0;如果任何模式匹配,则返回1。它使用[超扫描](https://github.com/intel/hyperscan)库。对于在字符串中搜索子字符串的模式,最好使用«multisearchany»,因为它更高效。 + +!!! note "注意" + 任何`haystack`字符串的长度必须小于232\字节,否则抛出异常。这种限制是因为hyperscan API而产生的。 + +## multiMatchAnyIndex(大海捞针,\[模式1,模式2, …, patternn\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} + +与`multiMatchAny`相同,但返回与haystack匹配的任何内容的索引位置。 + +## multiFuzzyMatchAny(干草堆,距离,\[模式1,模式2, …, patternn\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} + +与`multiMatchAny`相同,但如果在haystack能够查找到任何模式匹配能够在指定的[编辑距离](https://en.wikipedia.org/wiki/Edit_distance)内进行匹配,则返回1。此功能也处于实验模式,可能非常慢。有关更多信息,请参阅[hyperscan文档](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching)。 + +## multiFuzzyMatchAnyIndex(大海捞针,距离,\[模式1,模式2, …, patternn\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} + +与`multiFuzzyMatchAny`相同,但返回匹配项的匹配能容的索引位置。 + +!!! note "注意" + `multiFuzzyMatch*`函数不支持UTF-8正则表达式,由于hyperscan限制,这些表达式被按字节解析。 + +!!! note "注意" + 如要关闭所有hyperscan函数的使用,请设置`SET allow_hyperscan = 0;`。 + +## 提取(大海捞针,图案) {#extracthaystack-pattern} + +使用正则表达式截取字符串。如果’haystack’与’pattern’不匹配,则返回空字符串。如果正则表达式中不包含子模式,它将获取与整个正则表达式匹配的子串。否则,它将获取与第一个子模式匹配的子串。 + +## extractAll(大海捞针,图案) {#extractallhaystack-pattern} + +使用正则表达式提取字符串的所有片段。如果’haystack’与’pattern’正则表达式不匹配,则返回一个空字符串。否则返回所有与正则表达式匹配的字符串数组。通常,行为与’extract’函数相同(它采用第一个子模式,如果没有子模式,则采用整个表达式)。 + +## 像(干草堆,模式),干草堆像模式运算符 {#likehaystack-pattern-haystack-like-pattern-operator} + +检查字符串是否与简单正则表达式匹配。 +正则表达式可以包含的元符号有`%`和`_`。 + +`%` 表示任何字节数(包括零字符)。 + +`_` 表示任何一个字节。 + +可以使用反斜杠(`\`)来对元符号进行转义。请参阅«match»函数说明中有关转义的说明。 + +对于像`%needle%`这样的正则表达式,改函数与`position`函数一样快。 +对于其他正则表达式,函数与’match’函数相同。 + +## 不喜欢(干草堆,模式),干草堆不喜欢模式运算符 {#notlikehaystack-pattern-haystack-not-like-pattern-operator} + +与’like’函数返回相反的结果。 + +## 大海捞针) {#ngramdistancehaystack-needle} + +基于4-gram计算`haystack`和`needle`之间的距离:计算两个4-gram集合之间的对称差异,并用它们的基数和对其进行归一化。返回0到1之间的任何浮点数 – 越接近0则表示越多的字符串彼此相似。如果常量的`needle`或`haystack`超过32KB,函数将抛出异常。如果非常量的`haystack`或`needle`字符串超过32Kb,则距离始终为1。 + +对于不区分大小写的搜索或/和UTF-8格式,使用函数`ngramDistanceCaseInsensitive,ngramDistanceUTF8,ngramDistanceCaseInsensitiveUTF8`。 + +## ツ暗ェツ氾环催ツ団ツ法ツ人) {#ngramsearchhaystack-needle} + +与`ngramDistance`相同,但计算`needle`和`haystack`之间的非对称差异——`needle`的n-gram减去`needle`归一化n-gram。可用于模糊字符串搜索。 + +对于不区分大小写的搜索或/和UTF-8格式,使用函数`ngramSearchCaseInsensitive,ngramSearchUTF8,ngramSearchCaseInsensitiveUTF8`。 + +!!! note "注意" + 对于UTF-8,我们使用3-gram。所有这些都不是完全公平的n-gram距离。我们使用2字节哈希来散列n-gram,然后计算这些哈希表之间的(非)对称差异 - 可能会发生冲突。对于UTF-8不区分大小写的格式,我们不使用公平的`tolower`函数 - 我们将每个Unicode字符字节的第5位(从零开始)和字节的第一位归零 - 这适用于拉丁语,主要用于所有西里尔字母。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/zh/sql-reference/functions/type-conversion-functions.md b/docs/zh/sql-reference/functions/type-conversion-functions.md new file mode 100644 index 00000000000..6e3ed9afb78 --- /dev/null +++ b/docs/zh/sql-reference/functions/type-conversion-functions.md @@ -0,0 +1,638 @@ +--- +toc_priority: 38 +toc_title: 类型转换函数 +--- + +# 类型转换函数 {#lei-xing-zhuan-huan-han-shu} + +## 数值类型转换常见的问题 {#numeric-conversion-issues} + +当你把一个值从一个类型转换为另外一个类型的时候,你需要注意的是这是一个不安全的操作,可能导致数据的丢失。数据丢失一般发生在你将一个大的数据类型转换为小的数据类型的时候,或者你把两个不同的数据类型相互转换的时候。 + +ClickHouse和[C++](https://en.cppreference.com/w/cpp/language/implicit_conversion)有相同的类型转换行为。 + +## toInt(8\|16\|32\|64) {#touint8-touint16-touint32-touint64} + +转换一个输入值为[Int](../../sql-reference/data-types/int-uint.md)类型。这个函数包括: + +- `toInt8(expr)` — 结果为`Int8`数据类型。 +- `toInt16(expr)` — 结果为`Int16`数据类型。 +- `toInt32(expr)` — 结果为`Int32`数据类型。 +- `toInt64(expr)` — 结果为`Int64`数据类型。 + +**参数** + +- `expr` — [表达式](../syntax.md#syntax-expressions)返回一个数字或者代表数值类型的字符串。不支持二进制、八进制、十六进制的数字形式,有效数字之前的0也会被忽略。 + +**返回值** + +整形在`Int8`, `Int16`, `Int32`,或者 `Int64` 的数据类型。 + +函数使用[rounding towards zero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)原则,这意味着会截断丢弃小数部分的数值。 + +[NaN and Inf](../../sql-reference/data-types/float.md#data_type-float-nan-inf)转换是不确定的。具体使用的时候,请参考[数值类型转换常见的问题](#numeric-conversion-issues)。 + +**例子** + +``` sql +SELECT toInt64(nan), toInt32(32), toInt16('16'), toInt8(8.8) +``` + +``` text +┌─────────toInt64(nan)─┬─toInt32(32)─┬─toInt16('16')─┬─toInt8(8.8)─┐ +│ -9223372036854775808 │ 32 │ 16 │ 8 │ +└──────────────────────┴─────────────┴───────────────┴─────────────┘ +``` + +## toInt(8\|16\|32\|64)OrZero {#toint8163264orzero} + +这个函数需要一个字符类型的入参,然后尝试把它转为`Int (8 | 16 | 32 | 64)`,如果转换失败直接返回0。 + +**例子** + +``` sql +select toInt64OrZero('123123'), toInt8OrZero('123qwe123') +``` + +``` text +┌─toInt64OrZero('123123')─┬─toInt8OrZero('123qwe123')─┐ +│ 123123 │ 0 │ +└─────────────────────────┴───────────────────────────┘ +``` +## toInt(8\|16\|32\|64)OrNull {#toint8163264ornull} + +这个函数需要一个字符类型的入参,然后尝试把它转为`Int (8 | 16 | 32 | 64)`,如果转换失败直接返回`NULL`。 + +**例子** + +``` sql +select toInt64OrNull('123123'), toInt8OrNull('123qwe123') +``` + +``` text +┌─toInt64OrNull('123123')─┬─toInt8OrNull('123qwe123')─┐ +│ 123123 │ ᴺᵁᴸᴸ │ +└─────────────────────────┴───────────────────────────┘ +``` + +## toUInt(8\|16\|32\|64) {#touint8163264} + +转换一个输入值到[UInt](../../sql-reference/data-types/int-uint.md)类型。 这个函数包括: + +- `toUInt8(expr)` — 结果为`UInt8`数据类型。 +- `toUInt16(expr)` — 结果为`UInt16`数据类型。 +- `toUInt32(expr)` — 结果为`UInt32`数据类型。 +- `toUInt64(expr)` — 结果为`UInt64`数据类型。 + +**参数** + +- `expr` — [表达式](../syntax.md#syntax-expressions)返回一个数字或者代表数值类型的字符串。不支持二进制、八进制、十六进制的数字形式,有效数字之前的0也会被忽略。 + +**返回值** + +整形在`UInt8`, `UInt16`, `UInt32`,或者 `UInt64` 的数据类型。 + +函数使用[rounding towards zero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)原则,这意味着会截断丢弃小数部分的数值。 + +对于负数和[NaN and Inf](../../sql-reference/data-types/float.md#data_type-float-nan-inf)来说转换的结果是不确定的。如果你传入一个负数,比如:`'-32'`,ClickHouse会抛出异常。具体使用的时候,请参考[数值类型转换常见的问题](#numeric-conversion-issues)。 + +**例子** + +``` sql +SELECT toUInt64(nan), toUInt32(-32), toUInt16('16'), toUInt8(8.8) +``` + +``` text +┌───────toUInt64(nan)─┬─toUInt32(-32)─┬─toUInt16('16')─┬─toUInt8(8.8)─┐ +│ 9223372036854775808 │ 4294967264 │ 16 │ 8 │ +└─────────────────────┴───────────────┴────────────────┴──────────────┘ +``` + +## toUInt(8\|16\|32\|64)OrZero {#touint8163264orzero} + +## toUInt(8\|16\|32\|64)OrNull {#touint8163264ornull} + +## toFloat(32\|64) {#tofloat3264} + +## toFloat(32\|64)OrZero {#tofloat3264orzero} + +## toFloat(32\|64)OrNull {#tofloat3264ornull} + +## toDate {#todate} + +## toDateOrZero {#todateorzero} + +## toDateOrNull {#todateornull} + +## toDateTime {#todatetime} + +## toDateTimeOrZero {#todatetimeorzero} + +## toDateTimeOrNull {#todatetimeornull} + +## toDecimal(32\|64\|128) {#todecimal3264128} + +转换 `value` 到[Decimal](../../sql-reference/data-types/decimal.md)类型的值,其中精度为`S`。`value`可以是一个数字或者一个字符串。`S` 指定小数位的精度。 + +- `toDecimal32(value, S)` +- `toDecimal64(value, S)` +- `toDecimal128(value, S)` + +## toDecimal(32\|64\|128)OrNull {#todecimal3264128ornull} + +转换一个输入的字符到[Nullable(Decimal(P,S))](../../sql-reference/data-types/decimal.md)类型的数据。这个函数包括: + +- `toDecimal32OrNull(expr, S)` — 结果为`Nullable(Decimal32(S))`数据类型。 +- `toDecimal64OrNull(expr, S)` — 结果为`Nullable(Decimal64(S))`数据类型。 +- `toDecimal128OrNull(expr, S)` — 结果为`Nullable(Decimal128(S))`数据类型。 + +如果在解析输入值发生错误的时候你希望得到一个`NULL`值而不是抛出异常,你可以使用该函数。 + +**参数** + +- `expr` — [表达式](../syntax.md#syntax-expressions)返回一个[String](../../sql-reference/data-types/string.md)类型的数据。 ClickHouse倾向于文本类型的表示带小数类型的数值,比如`'1.111'`。 +- `S` — 小数位的精度。 + +**返回值** + +`Nullable(Decimal(P,S))`类型的数据,包括: + +- 如果有的话,小数位`S`。 +- 如果解析错误或者输入的数字的小数位多于`S`,那结果为`NULL`。 + +**例子** + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 5))─┐ +│ -1.11100 │ Nullable(Decimal(9, 5)) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrNull(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrNull(toString(-1.111), 2))─┐ +│ ᴺᵁᴸᴸ │ Nullable(Decimal(9, 2)) │ +└──────┴────────────────────────────────────────────────────┘ +``` + +## toDecimal(32\|64\|128)OrZero {#todecimal3264128orzero} + +转换输入值为[Decimal(P,S)](../../sql-reference/data-types/decimal.md)类型数据。这个函数包括: + +- `toDecimal32OrZero( expr, S)` — 结果为`Decimal32(S)` 数据类型。 +- `toDecimal64OrZero( expr, S)` — 结果为`Decimal64(S)` 数据类型。 +- `toDecimal128OrZero( expr, S)` — 结果为`Decimal128(S)` 数据类型。 + +当解析错误的时候,你不需要抛出异常而希望得到`0`值,你可以使用该函数。 + +**参数** + +- `expr` — [表达式](../syntax.md#syntax-expressions)返回一个[String](../../sql-reference/data-types/string.md)类型的数据。 ClickHouse倾向于文本类型的表示带小数类型的数值,比如`'1.111'`。 +- `S` — 小数位的精度。 + +**返回值** + +A value in the `Nullable(Decimal(P,S))` data type. The value contains: + +- 如果有的话,小数位`S`。 +- 如果解析错误或者输入的数字的小数位多于`S`,那结果为小数位精度为`S`的`0`。 +**例子** + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 5) AS val, toTypeName(val) +``` + +``` text +┌──────val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 5))─┐ +│ -1.11100 │ Decimal(9, 5) │ +└──────────┴────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT toDecimal32OrZero(toString(-1.111), 2) AS val, toTypeName(val) +``` + +``` text +┌──val─┬─toTypeName(toDecimal32OrZero(toString(-1.111), 2))─┐ +│ 0.00 │ Decimal(9, 2) │ +└──────┴────────────────────────────────────────────────────┘ +``` + + +## toString {#tostring} + +这些函数用于在数字、字符串(不包含FixedString)、Date以及DateTime之间互相转换。 +所有的函数都接受一个参数。 + +当将其他类型转换到字符串或从字符串转换到其他类型时,使用与TabSeparated格式相同的规则对字符串的值进行格式化或解析。如果无法解析字符串则抛出异常并取消查询。 + +当将Date转换为数字或反之,Date对应Unix时间戳的天数。 +将DataTime转换为数字或反之,DateTime对应Unix时间戳的秒数。 + +toDate/toDateTime函数的日期和日期时间格式定义如下: + + YYYY-MM-DD + YYYY-MM-DD hh:mm:ss + +例外的是,如果将UInt32、Int32、UInt64或Int64类型的数值转换为Date类型,并且其对应的值大于等于65536,则该数值将被解析成unix时间戳(而不是对应的天数)。这意味着允许写入’toDate(unix\_timestamp)‘这种常见情况,否则这将是错误的,并且需要便携更加繁琐的’toDate(toDateTime(unix\_timestamp))’。 + +Date与DateTime之间的转换以更为自然的方式进行:通过添加空的time或删除time。 + +数值类型之间的转换与C++中不同数字类型之间的赋值相同的规则。 + +此外,DateTime参数的toString函数可以在第二个参数中包含时区名称。 例如:`Asia/Yekaterinburg`在这种情况下,时间根据指定的时区进行格式化。 + +``` sql +SELECT + now() AS now_local, + toString(now(), 'Asia/Yekaterinburg') AS now_yekat +``` + + ┌───────────now_local─┬─now_yekat───────────┐ + │ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ + └─────────────────────┴─────────────────────┘ + +另请参阅`toUnixTimestamp`函数。 + +## toFixedString(s,N) {#tofixedstrings-n} + +将String类型的参数转换为FixedString(N)类型的值(具有固定长度N的字符串)。N必须是一个常量。 +如果字符串的字节数少于N,则向右填充空字节。如果字符串的字节数多于N,则抛出异常。 + +## toStringCutToZero(s) {#tostringcuttozeros} + +接受String或FixedString参数。返回String,其内容在找到的第一个零字节处被截断。 + +示例: + +``` sql +SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut +``` + + ┌─s─────────────┬─s_cut─┐ + │ foo\0\0\0\0\0 │ foo │ + └───────────────┴───────┘ + +``` sql +SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut +``` + + ┌─s──────────┬─s_cut─┐ + │ foo\0bar\0 │ foo │ + └────────────┴───────┘ + +## reinterpretAsUInt(8\|16\|32\|64) {#reinterpretasuint8163264} + +## reinterpretAsInt(8\|16\|32\|64) {#reinterpretasint8163264} + +## reinterpretAsFloat(32\|64) {#reinterpretasfloat3264} + +## reinterpretAsDate {#reinterpretasdate} + +## reinterpretAsDateTime {#reinterpretasdatetime} + +这些函数接受一个字符串,并将放在字符串开头的字节解释为主机顺序中的数字(little endian)。如果字符串不够长,则函数就像使用必要数量的空字节填充字符串一样。如果字符串比需要的长,则忽略额外的字节。Date被解释为Unix时间戳的天数,DateTime被解释为Unix时间戳。 + +## reinterpretAsString {#reinterpretasstring} + +此函数接受数字、Date或DateTime,并返回一个字符串,其中包含表示主机顺序(小端)的相应值的字节。从末尾删除空字节。例如,UInt32类型值255是一个字节长的字符串。 + +## reinterpretAsFixedString {#reinterpretasfixedstring} + +此函数接受数字、Date或DateTime,并返回包含表示主机顺序(小端)的相应值的字节的FixedString。从末尾删除空字节。例如,UInt32类型值255是一个长度为一个字节的FixedString。 + +## CAST(x, T) {#type_conversion_function-cast} + +将’x’转换为’t’数据类型。还支持语法CAST(x AS t) + +示例: + +``` sql +SELECT + '2016-06-15 23:00:00' AS timestamp, + CAST(timestamp AS DateTime) AS datetime, + CAST(timestamp AS Date) AS date, + CAST(timestamp, 'String') AS string, + CAST(timestamp, 'FixedString(22)') AS fixed_string +``` + + ┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ + │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ + └─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ + +将参数转换为FixedString(N),仅适用于String或FixedString(N)类型的参数。 + +支持将数据转换为[可为空](../../sql-reference/functions/type-conversion-functions.md)。例如: + + SELECT toTypeName(x) FROM t_null + + ┌─toTypeName(x)─┐ + │ Int8 │ + │ Int8 │ + └───────────────┘ + + SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null + + ┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ + │ Nullable(UInt16) │ + │ Nullable(UInt16) │ + └─────────────────────────────────────────┘ + +## toInterval(Year\|Quarter\|Month\|Week\|Day\|Hour\|Minute\|Second) {#function-tointerval} + +把一个数值类型的值转换为[Interval](../../sql-reference/data-types/special-data-types/interval.md)类型的数据。 + +**语法** + +``` sql +toIntervalSecond(number) +toIntervalMinute(number) +toIntervalHour(number) +toIntervalDay(number) +toIntervalWeek(number) +toIntervalMonth(number) +toIntervalQuarter(number) +toIntervalYear(number) +``` + +**参数** + +- `number` — 正整数,持续的时间。 + +**返回值** + +- 时间的`Interval`值。 + +**例子** + +``` sql +WITH + toDate('2019-01-01') AS date, + INTERVAL 1 WEEK AS interval_week, + toIntervalWeek(1) AS interval_to_week +SELECT + date + interval_week, + date + interval_to_week +``` + +``` text +┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ +│ 2019-01-08 │ 2019-01-08 │ +└───────────────────────────┴──────────────────────────────┘ +``` + +## parseDateTimeBestEffort {#parsedatetimebesteffort} + +把[String](../../sql-reference/data-types/string.md)类型的时间日期转换为[DateTime](../../sql-reference/data-types/datetime.md#data_type-datetime)数据类型。 + +该函数可以解析[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601),[RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55)或者ClickHouse的一些别的时间日期格式。 + +**语法** + +``` sql +parseDateTimeBestEffort(time_string [, time_zone]); +``` + +**参数** + +- `time_string` — 字符类型的时间和日期。 +- `time_zone` — 字符类型的时区。 + +**非标准格式的支持** + +- 9位或者10位的数字时间,[unix timestamp](https://en.wikipedia.org/wiki/Unix_time). +- 时间和日期组成的字符串: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss`等。 +- 只有日期的字符串: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` 等。 +- 只有天和时间: `DD`, `DD hh`, `DD hh:mm`。这种情况下 `YYYY-MM` 默认为 `2000-01`。 +- 包含时间日期以及时区信息: `YYYY-MM-DD hh:mm:ss ±h:mm`等。例如: `2020-12-12 17:36:00 -5:00`。 + +对于所有的格式来说,这个函数通过全称或者第一个三个字符的月份名称来解析月份,比如:`24/DEC/18`, `24-Dec-18`, `01-September-2018`。 + +**返回值** + +- `DateTime`类型数据。 + +**例子** + +查询: + +``` sql +SELECT parseDateTimeBestEffort('12/12/2020 12:12:57') +AS parseDateTimeBestEffort; +``` + +结果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2020-12-12 12:12:57 │ +└─────────────────────────┘ +``` + +查询: + +``` sql +SELECT parseDateTimeBestEffort('Sat, 18 Aug 2018 07:22:16 GMT', 'Europe/Moscow') +AS parseDateTimeBestEffort +``` + +结果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-08-18 10:22:16 │ +└─────────────────────────┘ +``` + +查询: + +``` sql +SELECT parseDateTimeBestEffort('1284101485') +AS parseDateTimeBestEffort +``` + +结果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2015-07-07 12:04:41 │ +└─────────────────────────┘ +``` + +查询: + +``` sql +SELECT parseDateTimeBestEffort('2018-12-12 10:12:12') +AS parseDateTimeBestEffort +``` + +结果: + +``` text +┌─parseDateTimeBestEffort─┐ +│ 2018-12-12 10:12:12 │ +└─────────────────────────┘ +``` + +查询: + +``` sql +SELECT parseDateTimeBestEffort('10 20:19') +``` + +结果: + +``` text +┌─parseDateTimeBestEffort('10 20:19')─┐ +│ 2000-01-10 20:19:00 │ +└─────────────────────────────────────┘ +``` + +**除此之外** + +- [ISO 8601 announcement by @xkcd](https://xkcd.com/1179/) +- [RFC 1123](https://tools.ietf.org/html/rfc1123) +- [toDate](#todate) +- [toDateTime](#todatetime) + +## parseDateTimeBestEffortOrNull {#parsedatetimebesteffortornull} + +这个函数和[parseDateTimeBestEffort](#parsedatetimebesteffort)基本一致,除了无法解析返回结果为`NULL`。 + +## parseDateTimeBestEffortOrZero {#parsedatetimebesteffortorzero} + +这个函数和[parseDateTimeBestEffort](#parsedatetimebesteffort)基本一致,除了无法解析返回结果为`0`。 + +## toLowCardinality {#tolowcardinality} + +把输入值转换为[LowCardianlity](../data-types/lowcardinality.md)的相同类型的数据。 + +如果要把`LowCardinality`类型的数据转换为其他类型,使用[CAST](#type_conversion_function-cast)函数。比如:`CAST(x as String)`。 + +**语法** + +```sql +toLowCardinality(expr) +``` + +**参数** + +- `expr` — [表达式](../syntax.md#syntax-expressions)为[支持的数据类型](../data-types/index.md#data_types)的一种。 + + +**返回值** + +- `expr`的结果。 + +类型: `LowCardinality(expr_result_type)` + +**例子** + +查询: + +```sql +SELECT toLowCardinality('1') +``` + +结果: + +```text +┌─toLowCardinality('1')─┐ +│ 1 │ +└───────────────────────┘ +``` + + +## toUnixTimestamp64Milli +## toUnixTimestamp64Micro +## toUnixTimestamp64Nano + +把一个`DateTime64`类型的数据转换为`Int64`类型的数据,结果包含固定亚秒的精度。输入的值是变大还是变低依赖于输入的精度。需要注意的是输出的值是一个UTC的时间戳, 不是同一个时区的`DateTime64`值。 + +**语法** + +``` sql +toUnixTimestamp64Milli(value) +``` + +**参数** + +- `value` — 任何精度的DateTime64类型的数据。 + +**返回值** + +- `value` `Int64`类型数据。 + +**例子** + +查询: + +``` sql +WITH toDateTime64('2019-09-16 19:20:12.345678910', 6) AS dt64 +SELECT toUnixTimestamp64Milli(dt64) +``` + +结果: + +``` text +┌─toUnixTimestamp64Milli(dt64)─┐ +│ 1568650812345 │ +└──────────────────────────────┘ +``` + +``` sql +WITH toDateTime64('2019-09-16 19:20:12.345678910', 6) AS dt64 +SELECT toUnixTimestamp64Nano(dt64) +``` + +结果: + +``` text +┌─toUnixTimestamp64Nano(dt64)─┐ +│ 1568650812345678000 │ +└─────────────────────────────┘ +``` + +## fromUnixTimestamp64Milli +## fromUnixTimestamp64Micro +## fromUnixTimestamp64Nano + +把`Int64`类型的数据转换为`DateTime64`类型的数据,结果包含固定的亚秒精度和可选的时区。 输入的值是变大还是变低依赖于输入的精度。需要注意的是输入的值是一个UTC的时间戳, 不是一个包含时区的时间戳。 + + +**语法** + +``` sql +fromUnixTimestamp64Milli(value [, ti]) +``` + +**参数** + +- `value` — `Int64`类型的数据,可以是任意精度。 +- `timezone` — `String`类型的时区 + +**返回值** + +- `value` DateTime64`类型的数据。 + +**例子** + +``` sql +WITH CAST(1234567891011, 'Int64') AS i64 +SELECT fromUnixTimestamp64Milli(i64, 'UTC') +``` + +``` text +┌─fromUnixTimestamp64Milli(i64, 'UTC')─┐ +│ 2009-02-13 23:31:31.011 │ +└──────────────────────────────────────┘ +``` + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/zh/sql-reference/functions/url-functions.md b/docs/zh/sql-reference/functions/url-functions.md new file mode 100644 index 00000000000..f967ccd4964 --- /dev/null +++ b/docs/zh/sql-reference/functions/url-functions.md @@ -0,0 +1,118 @@ +# URL函数 {#urlhan-shu} + +所有这些功能都不遵循RFC。它们被最大程度简化以提高性能。 + +## URL截取函数 {#urljie-qu-han-shu} + +如果URL中没有要截取的内容则返回空字符串。 + +### 协议 {#protocol} + +返回URL的协议。例如: http、ftp、mailto、magnet… + +### 域 {#domain} + +获取域名。 + +### domainwithoutww {#domainwithoutwww} + +返回域名并删除第一个’www.’。 + +### topLevelDomain {#topleveldomain} + +返回顶级域名。例如:.ru。 + +### 第一重要的元素分区域 {#firstsignificantsubdomain} + +返回«第一个有效子域名»。这并不是一个标准概念,仅用于Yandex.Metrica。如果顶级域名为’com’,‘net’,‘org’或者‘co’则第一个有效子域名为二级域名。否则则返回三级域名。例如,irstSignificantSubdomain (’https://news.yandex.ru/‘) = ’yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’。一些实现细节在未来可能会进行改变。 + +### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} + +返回包含顶级域名与第一个有效子域名之间的内容(请参阅上面的内容)。 + +例如, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. + +### 路径 {#path} + +返回URL路径。例如:`/top/news.html`,不包含请求参数。 + +### pathFull {#pathfull} + +与上面相同,但包括请求参数和fragment。例如:/top/news.html?page=2\#comments + +### 查询字符串 {#querystring} + +返回请求参数。例如:page=1&lr=213。请求参数不包含问号已经\# 以及\# 之后所有的内容。 + +### 片段 {#fragment} + +返回URL的fragment标识。fragment不包含\#。 + +### querystring andfragment {#querystringandfragment} + +返回请求参数和fragment标识。例如:page=1\#29390。 + +### extractURLParameter(URL,name) {#extracturlparameterurl-name} + +返回URL请求参数中名称为’name’的参数。如果不存在则返回一个空字符串。如果存在多个匹配项则返回第一个相匹配的。此函数假设参数名称与参数值在url中的编码方式相同。 + +### extractURLParameters(URL) {#extracturlparametersurl} + +返回一个数组,其中以name=value的字符串形式返回url的所有请求参数。不以任何编码解析任何内容。 + +### extractURLParameterNames(URL) {#extracturlparameternamesurl} + +返回一个数组,其中包含url的所有请求参数的名称。不以任何编码解析任何内容。 + +### URLHierarchy(URL) {#urlhierarchyurl} + +返回一个数组,其中包含以/切割的URL的所有内容。?将被包含在URL路径以及请求参数中。连续的分割符号被记为一个。 + +### Urlpathhierarchy(URL) {#urlpathhierarchyurl} + +与上面相同,但结果不包含协议和host部分。 /element(root)不包括在内。该函数用于在Yandex.Metric中实现导出URL的树形结构。 + + URLPathHierarchy('https://example.com/browse/CONV-6788') = + [ + '/browse/', + '/browse/CONV-6788' + ] + +### decodeURLComponent(URL) {#decodeurlcomponenturl} + +返回已经解码的URL。 +例如: + +``` sql +SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; +``` + + ┌─DecodedURL─────────────────────────────┐ + │ http://127.0.0.1:8123/?query=SELECT 1; │ + └────────────────────────────────────────┘ + +## 删除URL中的部分内容 {#shan-chu-urlzhong-de-bu-fen-nei-rong} + +如果URL中不包含指定的部分,则URL不变。 + +### cutWWW {#cutwww} + +删除开始的第一个’www.’。 + +### cutQueryString {#cutquerystring} + +删除请求参数。问号也将被删除。 + +### cutFragment {#cutfragment} + +删除fragment标识。\#同样也会被删除。 + +### cutquerystring andfragment {#cutquerystringandfragment} + +删除请求参数以及fragment标识。问号以及\#也会被删除。 + +### cutURLParameter(URL,name) {#cuturlparameterurl-name} + +删除URL中名称为’name’的参数。改函数假设参数名称以及参数值经过URL相同的编码。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/zh/sql-reference/functions/uuid-functions.md b/docs/zh/sql-reference/functions/uuid-functions.md new file mode 100644 index 00000000000..fb7cdcc4eff --- /dev/null +++ b/docs/zh/sql-reference/functions/uuid-functions.md @@ -0,0 +1,107 @@ +# UUID函数 {#uuidhan-shu} + +下面列出了所有UUID的相关函数 + +## generateuidv4 {#uuid-function-generate} + +生成一个UUID([版本4](https://tools.ietf.org/html/rfc4122#section-4.4))。 + +``` sql +generateUUIDv4() +``` + +**返回值** + +UUID类型的值。 + +**使用示例** + +此示例演示如何在表中创建UUID类型的列,并对其写入数据。 + +``` sql +:) CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog + +:) INSERT INTO t_uuid SELECT generateUUIDv4() + +:) SELECT * FROM t_uuid + +┌────────────────────────────────────x─┐ +│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ +└──────────────────────────────────────┘ +``` + +## toUUID(x) {#touuid-x} + +将String类型的值转换为UUID类型的值。 + +``` sql +toUUID(String) +``` + +**返回值** + +UUID类型的值 + +**使用示例** + +``` sql +:) SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid + +┌─────────────────────────────────uuid─┐ +│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ +└──────────────────────────────────────┘ +``` + +## UUIDStringToNum {#uuidstringtonum} + +接受一个String类型的值,其中包含36个字符且格式为`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,将其转换为UUID的数值并以[固定字符串(16)](../../sql-reference/functions/uuid-functions.md)将其返回。 + +``` sql +UUIDStringToNum(String) +``` + +**返回值** + +固定字符串(16) + +**使用示例** + +``` sql +:) SELECT + '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, + UUIDStringToNum(uuid) AS bytes + +┌─uuid─────────────────────────────────┬─bytes────────────┐ +│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ +└──────────────────────────────────────┴──────────────────┘ +``` + +## UUIDNumToString {#uuidnumtostring} + +接受一个[固定字符串(16)](../../sql-reference/functions/uuid-functions.md)类型的值,返回其对应的String表现形式。 + +``` sql +UUIDNumToString(FixedString(16)) +``` + +**返回值** + +字符串。 + +**使用示例** + +``` sql +SELECT + 'a/<@];!~p{jTj={)' AS bytes, + UUIDNumToString(toFixedString(bytes, 16)) AS uuid + +┌─bytes────────────┬─uuid─────────────────────────────────┐ +│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ +└──────────────────┴──────────────────────────────────────┘ +``` + +## 另请参阅 {#ling-qing-can-yue} + +- [dictgetuid](ext-dict-functions.md) + +[来源文章](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/zh/sql-reference/functions/ym-dict-functions.md b/docs/zh/sql-reference/functions/ym-dict-functions.md new file mode 100644 index 00000000000..c04405d81b4 --- /dev/null +++ b/docs/zh/sql-reference/functions/ym-dict-functions.md @@ -0,0 +1,120 @@ +# 功能与Yandex的工作。梅特里卡词典 {#functions-for-working-with-yandex-metrica-dictionaries} + +为了使下面的功能正常工作,服务器配置必须指定获取所有Yandex的路径和地址。梅特里卡字典. 字典在任何这些函数的第一次调用时加载。 如果无法加载引用列表,则会引发异常。 + +For information about creating reference lists, see the section «Dictionaries». + +## 多个地理基 {#multiple-geobases} + +ClickHouse支持同时使用多个备选地理基(区域层次结构),以支持某些地区所属国家的各种观点。 + +该 ‘clickhouse-server’ config指定具有区域层次结构的文件::`/opt/geo/regions_hierarchy.txt` + +除了这个文件,它还搜索附近有\_符号和任何后缀附加到名称(文件扩展名之前)的文件。 +例如,它还会找到该文件 `/opt/geo/regions_hierarchy_ua.txt`,如果存在。 + +`ua` 被称为字典键。 对于没有后缀的字典,键是空字符串。 + +所有字典都在运行时重新加载(每隔一定数量的秒重新加载一次,如builtin\_dictionaries\_reload\_interval config参数中定义,或默认情况下每小时一次)。 但是,可用字典列表在服务器启动时定义一次。 + +All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. +示例: + + regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt + regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt + regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt + +### ツ环板(ョツ嘉ッツ偲青regionシツ氾カツ鉄ツ工ツ渉\]) {#regiontocityid-geobase} + +Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. + +### 虏茅驴麓卤戮碌禄路戮鲁拢\]) {#regiontoareaid-geobase} + +将区域转换为区域(地理数据库中的类型5)。 在所有其他方式,这个功能是一样的 ‘regionToCity’. + +``` sql +SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + + ┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ + │ │ + │ Moscow and Moscow region │ + │ St. Petersburg and Leningrad region │ + │ Belgorod region │ + │ Ivanovsk region │ + │ Kaluga region │ + │ Kostroma region │ + │ Kursk region │ + │ Lipetsk region │ + │ Orlov region │ + │ Ryazan region │ + │ Smolensk region │ + │ Tambov region │ + │ Tver region │ + │ Tula region │ + └──────────────────────────────────────────────────────┘ + +### regionToDistrict(id\[,geobase\]) {#regiontodistrictid-geobase} + +将区域转换为联邦区(地理数据库中的类型4)。 在所有其他方式,这个功能是一样的 ‘regionToCity’. + +``` sql +SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) +FROM system.numbers +LIMIT 15 +``` + + ┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ + │ │ + │ Central federal district │ + │ Northwest federal district │ + │ South federal district │ + │ North Caucases federal district │ + │ Privolga federal district │ + │ Ural federal district │ + │ Siberian federal district │ + │ Far East federal district │ + │ Scotland │ + │ Faroe Islands │ + │ Flemish region │ + │ Brussels capital region │ + │ Wallonia │ + │ Federation of Bosnia and Herzegovina │ + └──────────────────────────────────────────────────────────┘ + +### 虏茅驴麓卤戮碌禄路戮鲁拢(陆毛隆隆(803)888-8325\]) {#regiontocountryid-geobase} + +将区域转换为国家。 在所有其他方式,这个功能是一样的 ‘regionToCity’. +示例: `regionToCountry(toUInt32(213)) = 225` 转换莫斯科(213)到俄罗斯(225)。 + +### 掳胫((禄脢鹿脷露胫鲁隆鹿((酶-11-16""\[脪陆,ase\]) {#regiontocontinentid-geobase} + +将区域转换为大陆。 在所有其他方式,这个功能是一样的 ‘regionToCity’. +示例: `regionToContinent(toUInt32(213)) = 10001` 将莫斯科(213)转换为欧亚大陆(10001)。 + +### ツ环板(ョツ嘉ッツ偲青regionャツ静ャツ青サツ催ャツ渉\]) {#regiontopopulationid-geobase} + +获取区域的人口。 +The population can be recorded in files with the geobase. See the section «External dictionaries». +如果没有为该区域记录人口,则返回0。 +在Yandex地理数据库中,可能会为子区域记录人口,但不会为父区域记录人口。 + +### regionIn(lhs,rhs\[,地理数据库\]) {#regioninlhs-rhs-geobase} + +检查是否 ‘lhs’ 属于一个区域 ‘rhs’ 区域。 如果属于UInt8,则返回等于1的数字,如果不属于则返回0。 +The relationship is reflexive – any region also belongs to itself. + +### ツ暗ェツ氾环催ツ団ツ法ツ人\]) {#regionhierarchyid-geobase} + +Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. +示例: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. + +### 地区名称(id\[,郎\]) {#regiontonameid-lang} + +Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn’t exist, an empty string is returned. + +`ua` 和 `uk` 都意味着乌克兰。 + +[原始文章](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/zh/sql-reference/index.md b/docs/zh/sql-reference/index.md new file mode 100644 index 00000000000..aed96c4b34f --- /dev/null +++ b/docs/zh/sql-reference/index.md @@ -0,0 +1,20 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "SQL\u53C2\u8003" +toc_hidden: true +toc_priority: 28 +toc_title: "\u9690\u85CF" +--- + +# SQL参考 {#sql-reference} + +ClickHouse支持以下类型的查询: + +- [SELECT](statements/select/index.md) +- [INSERT INTO](statements/insert-into.md) +- [CREATE](statements/create.md) +- [ALTER](statements/alter.md#query_language_queries_alter) +- [其他类型的查询](statements/misc.md) + +[原始文章](https://clickhouse.tech/docs/en/sql-reference/) diff --git a/docs/zh/sql-reference/operators/in.md b/docs/zh/sql-reference/operators/in.md new file mode 120000 index 00000000000..3a2feda2f61 --- /dev/null +++ b/docs/zh/sql-reference/operators/in.md @@ -0,0 +1 @@ +../../../en/sql-reference/operators/in.md \ No newline at end of file diff --git a/docs/zh/sql-reference/operators/index.md b/docs/zh/sql-reference/operators/index.md new file mode 100644 index 00000000000..77aa42755af --- /dev/null +++ b/docs/zh/sql-reference/operators/index.md @@ -0,0 +1,263 @@ +# 操作符 {#cao-zuo-fu} + +所有的操作符(运算符)都会在查询时依据他们的优先级及其结合顺序在被解析时转换为对应的函数。下面按优先级从高到低列出各组运算符及其对应的函数: + +## 下标运算符 {#xia-biao-yun-suan-fu} + +`a[N]` – 数组中的第N个元素; 对应函数 `arrayElement(a, N)` + +`a.N` – 元组中第N个元素; 对应函数 `tupleElement(a, N)` + +## 负号 {#fu-hao} + +`-a` – 对应函数 `negate(a)` + +## 乘号、除号和取余 {#cheng-hao-chu-hao-he-qu-yu} + +`a * b` – 对应函数 `multiply(a, b)` + +`a / b` – 对应函数 `divide(a, b)` + +`a % b` – 对应函数 `modulo(a, b)` + +## 加号和减号 {#jia-hao-he-jian-hao} + +`a + b` – 对应函数 `plus(a, b)` + +`a - b` – 对应函数 `minus(a, b)` + +## 关系运算符 {#guan-xi-yun-suan-fu} + +`a = b` – 对应函数 `equals(a, b)` + +`a == b` – 对应函数 `equals(a, b)` + +`a != b` – 对应函数 `notEquals(a, b)` + +`a <> b` – 对应函数 `notEquals(a, b)` + +`a <= b` – 对应函数 `lessOrEquals(a, b)` + +`a >= b` – 对应函数 `greaterOrEquals(a, b)` + +`a < b` – 对应函数 `less(a, b)` + +`a > b` – 对应函数 `greater(a, b)` + +`a LIKE s` – 对应函数 `like(a, b)` + +`a NOT LIKE s` – 对应函数 `notLike(a, b)` + +`a BETWEEN b AND c` – 等价于 `a >= b AND a <= c` + +## 集合关系运算符 {#ji-he-guan-xi-yun-suan-fu} + +*详见此节 [IN 相关操作符](in.md#select-in-operators) 。* + +`a IN ...` – 对应函数 `in(a, b)` + +`a NOT IN ...` – 对应函数 `notIn(a, b)` + +`a GLOBAL IN ...` – 对应函数 `globalIn(a, b)` + +`a GLOBAL NOT IN ...` – 对应函数 `globalNotIn(a, b)` + +## 逻辑非 {#luo-ji-fei} + +`NOT a` – 对应函数 `not(a)` + +## 逻辑与 {#luo-ji-yu} + +`a AND b` – 对应函数`and(a, b)` + +## 逻辑或 {#luo-ji-huo} + +`a OR b` – 对应函数 `or(a, b)` + +## 条件运算符 {#tiao-jian-yun-suan-fu} + +`a ? b : c` – 对应函数 `if(a, b, c)` + +注意: + +条件运算符会先计算表达式b和表达式c的值,再根据表达式a的真假,返回相应的值。如果表达式b和表达式c是 [arrayJoin()](../../sql-reference/functions/array-join.md#functions_arrayjoin) 函数,则不管表达式a是真是假,每行都会被复制展开。 + +## 使用日期和时间的操作员 {#operators-datetime} + +### EXTRACT {#operator-extract} + +``` sql +EXTRACT(part FROM date); +``` + +从给定日期中提取部件。 例如,您可以从给定日期检索一个月,或从时间检索一秒钟。 + +该 `part` 参数指定要检索的日期部分。 以下值可用: + +- `DAY` — The day of the month. Possible values: 1–31. +- `MONTH` — The number of a month. Possible values: 1–12. +- `YEAR` — The year. +- `SECOND` — The second. Possible values: 0–59. +- `MINUTE` — The minute. Possible values: 0–59. +- `HOUR` — The hour. Possible values: 0–23. + +该 `part` 参数不区分大小写。 + +该 `date` 参数指定要处理的日期或时间。 无论是 [日期](../../sql-reference/data-types/date.md) 或 [日期时间](../../sql-reference/data-types/datetime.md) 支持类型。 + +例: + +``` sql +SELECT EXTRACT(DAY FROM toDate('2017-06-15')); +SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); +SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); +``` + +在下面的例子中,我们创建一个表,并在其中插入一个值 `DateTime` 类型。 + +``` sql +CREATE TABLE test.Orders +( + OrderId UInt64, + OrderName String, + OrderDate DateTime +) +ENGINE = Log; +``` + +``` sql +INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); +``` + +``` sql +SELECT + toYear(OrderDate) AS OrderYear, + toMonth(OrderDate) AS OrderMonth, + toDayOfMonth(OrderDate) AS OrderDay, + toHour(OrderDate) AS OrderHour, + toMinute(OrderDate) AS OrderMinute, + toSecond(OrderDate) AS OrderSecond +FROM test.Orders; +``` + +``` text +┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ +│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ +└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ +``` + +你可以看到更多的例子 [测试](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). + +### INTERVAL {#operator-interval} + +创建一个 [间隔](../../sql-reference/operators/index.md)-应在算术运算中使用的类型值 [日期](../../sql-reference/data-types/date.md) 和 [日期时间](../../sql-reference/data-types/datetime.md)-类型值。 + +示例: + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +**另请参阅** + +- [间隔](../../sql-reference/operators/index.md) 数据类型 +- [toInterval](../../sql-reference/operators/index.md#function-tointerval) 类型转换函数 + +## CASE条件表达式 {#operator_case} + +``` sql +CASE [x] + WHEN a THEN b + [WHEN ... THEN ...] + [ELSE c] +END +``` + +如果指定了 `x` ,该表达式会转换为 `transform(x, [a, ...], [b, ...], c)` 函数。否则转换为 `multiIf(a, b, ..., c)` + +如果该表达式中没有 `ELSE c` 子句,则默认值就是 `NULL` + +但 `transform` 函数不支持 `NULL` + +## 连接运算符 {#lian-jie-yun-suan-fu} + +`s1 || s2` – 对应函数 `concat(s1, s2)` + +## 创建 Lambda 函数 {#chuang-jian-lambda-han-shu} + +`x -> expr` – 对应函数 `lambda(x, expr)` + +接下来的这些操作符因为其本身是括号没有优先级: + +## 创建数组 {#chuang-jian-shu-zu} + +`[x1, ...]` – 对应函数 `array(x1, ...)` + +## 创建元组 {#chuang-jian-yuan-zu} + +`(x1, x2, ...)` – 对应函数 `tuple(x2, x2, ...)` + +## 结合方式 {#jie-he-fang-shi} + +所有的同级操作符从左到右结合。例如, `1 + 2 + 3` 会转换成 `plus(plus(1, 2), 3)`。 +所以,有时他们会跟我们预期的不太一样。例如, `SELECT 4 > 2 > 3` 的结果是0。 + +为了高效, `and` 和 `or` 函数支持任意多参数,一连串的 `AND` 和 `OR` 运算符会转换成其对应的单个函数。 + +## 判断是否为 `NULL` {#pan-duan-shi-fou-wei-null} + +ClickHouse 支持 `IS NULL` 和 `IS NOT NULL` 。 + +### IS NULL {#operator-is-null} + +- 对于 [可为空](../../sql-reference/operators/index.md) 类型的值, `IS NULL` 会返回: + - `1` 值为 `NULL` + - `0` 否则 +- 对于其他类型的值, `IS NULL` 总会返回 `0` + + + +``` bash +:) SELECT x+100 FROM t_null WHERE y IS NULL + +SELECT x + 100 +FROM t_null +WHERE isNull(y) + +┌─plus(x, 100)─┐ +│ 101 │ +└──────────────┘ + +1 rows in set. Elapsed: 0.002 sec. +``` + +### IS NOT NULL {#is-not-null} + +- 对于 [可为空](../../sql-reference/operators/index.md) 类型的值, `IS NOT NULL` 会返回: + - `0` 值为 `NULL` + - `1` 否则 +- 对于其他类型的值,`IS NOT NULL` 总会返回 `1` + + + +``` bash +:) SELECT * FROM t_null WHERE y IS NOT NULL + +SELECT * +FROM t_null +WHERE isNotNull(y) + +┌─x─┬─y─┐ +│ 2 │ 3 │ +└───┴───┘ + +1 rows in set. Elapsed: 0.002 sec. +``` + +[来源文章](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/zh/sql-reference/statements/alter.md b/docs/zh/sql-reference/statements/alter.md new file mode 100644 index 00000000000..24ca1e47372 --- /dev/null +++ b/docs/zh/sql-reference/statements/alter.md @@ -0,0 +1,602 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 36 +toc_title: ALTER +--- + +## ALTER {#query_language_queries_alter} + +该 `ALTER` 查询仅支持 `*MergeTree` 表,以及 `Merge`和`Distributed`. 查询有几个变体。 + +### 列操作 {#column-manipulations} + +更改表结构。 + +``` sql +ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... +``` + +在查询中,指定一个或多个逗号分隔操作的列表。 +每个操作都是对列的操作。 + +支持以下操作: + +- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. +- [DROP COLUMN](#alter_drop-column) — Deletes the column. +- [CLEAR COLUMN](#alter_clear-column) — Resets column values. +- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. +- [MODIFY COLUMN](#alter_modify-column) — Changes column's type, default expression and TTL. + +下面详细描述这些动作。 + +#### ADD COLUMN {#alter_add-column} + +``` sql +ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] +``` + +将一个新列添加到表中,并指定 `name`, `type`, [`codec`](create.md#codecs) 和 `default_expr` (请参阅部分 [默认表达式](create.md#create-default-values)). + +如果 `IF NOT EXISTS` 如果列已经存在,则查询不会返回错误。 如果您指定 `AFTER name_after` (另一列的名称),该列被添加在表列表中指定的一列之后。 否则,该列将添加到表的末尾。 请注意,没有办法将列添加到表的开头。 为了一系列的行动, `name_after` 可以是在以前的操作之一中添加的列的名称。 + +添加列只是更改表结构,而不对数据执行任何操作。 数据不会出现在磁盘上后 `ALTER`. 如果从表中读取某一列的数据缺失,则将使用默认值填充该列(如果存在默认表达式,则执行默认表达式,或使用零或空字符串)。 合并数据部分后,该列将出现在磁盘上(请参阅 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)). + +这种方法使我们能够完成 `ALTER` 即时查询,不增加旧数据量。 + +示例: + +``` sql +ALTER TABLE visits ADD COLUMN browser String AFTER user_id +``` + +#### DROP COLUMN {#alter_drop-column} + +``` sql +DROP COLUMN [IF EXISTS] name +``` + +删除具有名称的列 `name`. 如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 + +从文件系统中删除数据。 由于这将删除整个文件,查询几乎立即完成。 + +示例: + +``` sql +ALTER TABLE visits DROP COLUMN browser +``` + +#### CLEAR COLUMN {#alter_clear-column} + +``` sql +CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name +``` + +重置指定分区的列中的所有数据。 了解有关设置分区名称的详细信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). + +如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 + +示例: + +``` sql +ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() +``` + +#### COMMENT COLUMN {#alter_comment-column} + +``` sql +COMMENT COLUMN [IF EXISTS] name 'comment' +``` + +向列添加注释。 如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 + +每列可以有一个注释。 如果列的注释已存在,则新注释将复盖以前的注释。 + +注释存储在 `comment_expression` 由返回的列 [DESCRIBE TABLE](misc.md#misc-describe-table) 查询。 + +示例: + +``` sql +ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' +``` + +#### MODIFY COLUMN {#alter_modify-column} + +``` sql +MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] +``` + +此查询更改 `name` 列属性: + +- 类型 + +- 默认表达式 + +- TTL + + For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). + +如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 + +更改类型时,值将被转换为 [toType](../../sql-reference/functions/type-conversion-functions.md) 函数被应用到它们。 如果仅更改默认表达式,则查询不会执行任何复杂的操作,并且几乎立即完成。 + +示例: + +``` sql +ALTER TABLE visits MODIFY COLUMN browser Array(String) +``` + +Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. + +有几个处理阶段: + +- 准备具有修改数据的临时(新)文件。 +- 重命名旧文件。 +- 将临时(新)文件重命名为旧名称。 +- 删除旧文件。 + +只有第一阶段需要时间。 如果在此阶段出现故障,则不会更改数据。 +如果在其中一个连续阶段中出现故障,可以手动恢复数据。 例外情况是,如果旧文件从文件系统中删除,但新文件的数据没有写入磁盘并丢失。 + +该 `ALTER` 复制更改列的查询。 这些指令保存在ZooKeeper中,然后每个副本应用它们。 全部 `ALTER` 查询以相同的顺序运行。 查询等待对其他副本完成适当的操作。 但是,更改复制表中的列的查询可能会中断,并且所有操作都将异步执行。 + +#### 更改查询限制 {#alter-query-limitations} + +该 `ALTER` query允许您在嵌套数据结构中创建和删除单独的元素(列),但不能创建整个嵌套数据结构。 要添加嵌套数据结构,可以添加名称如下的列 `name.nested_name` 和类型 `Array(T)`. 嵌套数据结构等效于名称在点之前具有相同前缀的多个数组列。 + +不支持删除主键或采样键中的列(在主键中使用的列 `ENGINE` 表达式)。 只有在此更改不会导致数据被修改时,才可以更改主键中包含的列的类型(例如,允许您向枚举添加值或更改类型 `DateTime` 到 `UInt32`). + +如果 `ALTER` 查询不足以使您需要的表更改,您可以创建一个新的表,使用 [INSERT SELECT](insert-into.md#insert_query_insert-select) 查询,然后使用切换表 [RENAME](misc.md#misc_operations-rename) 查询并删除旧表。 您可以使用 [ツ环板-ョツ嘉ッツ偲](../../operations/utilities/clickhouse-copier.md) 作为替代 `INSERT SELECT` 查询。 + +该 `ALTER` 查询阻止对表的所有读取和写入。 换句话说,如果长 `SELECT` 正在运行的时间 `ALTER` 查询,该 `ALTER` 查询将等待它完成。 同时,对同一个表的所有新查询将等待 `ALTER` 正在运行。 + +对于本身不存储数据的表(例如 `Merge` 和 `Distributed`), `ALTER` 只是改变了表结构,并且不改变从属表的结构。 例如,当运行ALTER时 `Distributed` 表,你还需要运行 `ALTER` 对于所有远程服务器上的表。 + +### 使用键表达式进行操作 {#manipulations-with-key-expressions} + +支持以下命令: + +``` sql +MODIFY ORDER BY new_expression +``` + +它只适用于在表 [`MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) 家庭(包括 +[复制](../../engines/table-engines/mergetree-family/replication.md) 表)。 该命令更改 +[排序键](../../engines/table-engines/mergetree-family/mergetree.md) 表 +到 `new_expression` (表达式或表达式元组)。 主键保持不变。 + +该命令是轻量级的,因为它只更改元数据。 要保持该数据部分的属性 +行按排序键表达式排序您不能添加包含现有列的表达式 +到排序键(仅由列添加 `ADD COLUMN` 命令在同一个 `ALTER` 查询)。 + +### 使用数据跳过索引进行操作 {#manipulations-with-data-skipping-indices} + +它只适用于在表 [`*MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) 家庭(包括 +[复制](../../engines/table-engines/mergetree-family/replication.md) 表)。 以下操作 +可用: + +- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` -将索引描述添加到表元数据。 + +- `ALTER TABLE [db].name DROP INDEX name` -从表元数据中删除索引描述并从磁盘中删除索引文件。 + +这些命令是轻量级的,因为它们只更改元数据或删除文件。 +此外,它们被复制(通过ZooKeeper同步索引元数据)。 + +### 使用约束进行操作 {#manipulations-with-constraints} + +查看更多 [制约因素](create.md#constraints) + +可以使用以下语法添加或删除约束: + +``` sql +ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; +ALTER TABLE [db].name DROP CONSTRAINT constraint_name; +``` + +查询将从表中添加或删除有关约束的元数据,以便立即处理它们。 + +约束检查 *不会被执行* 在现有数据上,如果它被添加。 + +复制表上的所有更改都广播到ZooKeeper,因此将应用于其他副本。 + +### 操作与分区和零件 {#alter_manipulations-with-partitions} + +下面的操作与 [分区](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 可用: + +- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` 目录和忘记它。 +- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. +- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` 目录到表。 +- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. +- [REPLACE PARTITION](#alter_replace-partition) -将数据分区从一个表复制到另一个表并替换。 +- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition)(\#alter\_move\_to\_table-partition)-将数据分区从一个表移动到另一个表。 +- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) -重置分区中指定列的值。 +- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) -重置分区中指定的二级索引。 +- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. +- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. +- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. + + + +#### DETACH PARTITION {#alter_detach-partition} + +``` sql +ALTER TABLE table_name DETACH PARTITION partition_expr +``` + +将指定分区的所有数据移动到 `detached` 目录。 服务器会忘记分离的数据分区,就好像它不存在一样。 服务器不会知道这个数据,直到你做 [ATTACH](#alter_attach-partition) 查询。 + +示例: + +``` sql +ALTER TABLE visits DETACH PARTITION 201901 +``` + +阅读有关在一节中设置分区表达式的信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). + +执行查询后,您可以对查询中的数据进行任何操作 `detached` directory — delete it from the file system, or just leave it. + +This query is replicated – it moves the data to the `detached` 所有副本上的目录。 请注意,您只能对领导副本执行此查询。 要确定副本是否为领导者,请执行 `SELECT` 查询到 [系统。副本](../../operations/system-tables.md#system_tables-replicas) 桌子 或者,它更容易使 `DETACH` 对所有副本进行查询-除了领导副本之外,所有副本都会引发异常。 + +#### DROP PARTITION {#alter_drop-partition} + +``` sql +ALTER TABLE table_name DROP PARTITION partition_expr +``` + +从表中删除指定的分区。 此查询将分区标记为非活动分区,并在大约10分钟内完全删除数据。 + +阅读有关在一节中设置分区表达式的信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). + +The query is replicated – it deletes data on all replicas. + +#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} + +``` sql +ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr +``` + +从中删除指定分区的指定部分或所有部分 `detached`. +了解有关在一节中设置分区表达式的详细信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). + +#### ATTACH PARTITION\|PART {#alter_attach-partition} + +``` sql +ALTER TABLE table_name ATTACH PARTITION|PART partition_expr +``` + +将数据从 `detached` 目录。 可以为整个分区或单独的部分添加数据。 例: + +``` sql +ALTER TABLE visits ATTACH PARTITION 201901; +ALTER TABLE visits ATTACH PART 201901_2_2_0; +``` + +了解有关在一节中设置分区表达式的详细信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). + +此查询被复制。 副本发起程序检查是否有数据在 `detached` 目录。 如果数据存在,则查询将检查其完整性。 如果一切正确,则查询将数据添加到表中。 所有其他副本都从副本发起程序下载数据。 + +所以你可以把数据到 `detached` 在一个副本上的目录,并使用 `ALTER ... ATTACH` 查询以将其添加到所有副本上的表中。 + +#### ATTACH PARTITION FROM {#alter_attach-partition-from} + +``` sql +ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 +``` + +此查询将数据分区从 `table1` 到 `table2` 将数据添加到存在 `table2`. 请注意,数据不会从中删除 `table1`. + +要使查询成功运行,必须满足以下条件: + +- 两个表必须具有相同的结构。 +- 两个表必须具有相同的分区键。 + +#### REPLACE PARTITION {#alter_replace-partition} + +``` sql +ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 +``` + +此查询将数据分区从 `table1` 到 `table2` 并替换在现有的分区 `table2`. 请注意,数据不会从中删除 `table1`. + +要使查询成功运行,必须满足以下条件: + +- 两个表必须具有相同的结构。 +- 两个表必须具有相同的分区键。 + +#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} + +``` sql +ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest +``` + +此查询将数据分区从 `table_source` 到 `table_dest` 删除数据 `table_source`. + +要使查询成功运行,必须满足以下条件: + +- 两个表必须具有相同的结构。 +- 两个表必须具有相同的分区键。 +- 两个表必须是相同的引擎系列。 (已复制或未复制) +- 两个表必须具有相同的存储策略。 + +#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} + +``` sql +ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr +``` + +重置分区中指定列中的所有值。 如果 `DEFAULT` 创建表时确定了子句,此查询将列值设置为指定的默认值。 + +示例: + +``` sql +ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 +``` + +#### FREEZE PARTITION {#alter_freeze-partition} + +``` sql +ALTER TABLE table_name FREEZE [PARTITION partition_expr] +``` + +此查询创建指定分区的本地备份。 如果 `PARTITION` 子句被省略,查询一次创建所有分区的备份。 + +!!! note "注" + 在不停止服务器的情况下执行整个备份过程。 + +请注意,对于旧式表,您可以指定分区名称的前缀(例如, ‘2019’)-然后查询为所有相应的分区创建备份。 阅读有关在一节中设置分区表达式的信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). + +在执行时,对于数据快照,查询将创建指向表数据的硬链接。 硬链接被放置在目录中 `/var/lib/clickhouse/shadow/N/...`,哪里: + +- `/var/lib/clickhouse/` 是配置中指定的工作ClickHouse目录。 +- `N` 是备份的增量编号。 + +!!! note "注" + 如果您使用 [用于在表中存储数据的一组磁盘](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes),该 `shadow/N` 目录出现在每个磁盘上,存储由匹配的数据部分 `PARTITION` 表达。 + +在备份内部创建的目录结构与在备份内部创建的目录结构相同 `/var/lib/clickhouse/`. 查询执行 ‘chmod’ 对于所有文件,禁止写入它们。 + +创建备份后,您可以从以下位置复制数据 `/var/lib/clickhouse/shadow/` 然后将其从本地服务器中删除。 请注意, `ALTER t FREEZE PARTITION` 不复制查询。 它仅在本地服务器上创建本地备份。 + +查询几乎立即创建备份(但首先它会等待对相应表的当前查询完成运行)。 + +`ALTER TABLE t FREEZE PARTITION` 仅复制数据,而不复制表元数据。 若要备份表元数据,请复制该文件 `/var/lib/clickhouse/metadata/database/table.sql` + +要从备份还原数据,请执行以下操作: + +1. 如果表不存在,则创建该表。 要查看查询,请使用。sql文件(替换 `ATTACH` 在它与 `CREATE`). +2. 从复制数据 `data/database/table/` 目录内的备份到 `/var/lib/clickhouse/data/database/table/detached/` 目录。 +3. 快跑 `ALTER TABLE t ATTACH PARTITION` 将数据添加到表的查询。 + +从备份还原不需要停止服务器。 + +有关备份和还原数据的详细信息,请参阅 [数据备份](../../operations/backup.md) 科。 + +#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} + +``` sql +ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr +``` + +查询的工作原理类似于 `CLEAR COLUMN`,但它重置索引而不是列数据。 + +#### FETCH PARTITION {#alter_fetch-partition} + +``` sql +ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' +``` + +从另一台服务器下载分区。 此查询仅适用于复制的表。 + +查询执行以下操作: + +1. 从指定的分片下载分区。 在 ‘path-in-zookeeper’ 您必须在ZooKeeper中指定分片的路径。 +2. 然后查询将下载的数据放到 `detached` 的目录 `table_name` 桌子 使用 [ATTACH PARTITION\|PART](#alter_attach-partition) 查询将数据添加到表中。 + +例如: + +``` sql +ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; +ALTER TABLE users ATTACH PARTITION 201902; +``` + +请注意: + +- 该 `ALTER ... FETCH PARTITION` 查询不被复制。 它将分区放置在 `detached` 仅在本地服务器上的目录。 +- 该 `ALTER TABLE ... ATTACH` 复制查询。 它将数据添加到所有副本。 数据被添加到从副本之一 `detached` 目录,以及其他-从相邻的副本。 + +在下载之前,系统会检查分区是否存在并且表结构匹配。 从正常副本中自动选择最合适的副本。 + +虽然查询被调用 `ALTER TABLE`,它不会更改表结构,并且不会立即更改表中可用的数据。 + +#### MOVE PARTITION\|PART {#alter_move-partition} + +将分区或数据部分移动到另一个卷或磁盘 `MergeTree`-发动机表。 看 [使用多个块设备进行数据存储](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes). + +``` sql +ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' +``` + +该 `ALTER TABLE t MOVE` 查询: + +- 不复制,因为不同的副本可能具有不同的存储策略。 +- 如果未配置指定的磁盘或卷,则返回错误。 如果无法应用存储策略中指定的数据移动条件,Query还会返回错误。 +- 可以在返回错误的情况下,当要移动的数据已经被后台进程移动时,并发 `ALTER TABLE t MOVE` 查询或作为后台数据合并的结果。 在这种情况下,用户不应该执行任何其他操作。 + +示例: + +``` sql +ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' +ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' +``` + +#### 如何设置分区表达式 {#alter-how-to-specify-part-expr} + +您可以在以下内容中指定分区表达式 `ALTER ... PARTITION` 以不同方式查询: + +- 作为从值 `partition` 列 `system.parts` 桌子 例如, `ALTER TABLE visits DETACH PARTITION 201901`. +- 作为来自表列的表达式。 支持常量和常量表达式。 例如, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. +- 使用分区ID。 分区ID是用作文件系统和ZooKeeper中分区名称的分区的字符串标识符(如果可能的话,人类可读)。 分区ID必须在指定 `PARTITION ID` 子句,用单引号。 例如, `ALTER TABLE visits DETACH PARTITION ID '201901'`. +- 在 [ALTER ATTACH PART](#alter_attach-partition) 和 [DROP DETACHED PART](#alter_drop-detached) 查询时,要指定部件的名称,请将字符串文字与来自 `name` 列 [系统。detached\_parts](../../operations/system-tables.md#system_tables-detached_parts) 桌子 例如, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. + +指定分区时引号的使用取决于分区表达式的类型。 例如,对于 `String` 类型,你必须在引号中指定其名称 (`'`). 为 `Date` 和 `Int*` 类型不需要引号。 + +对于旧式表,您可以将分区指定为数字 `201901` 或者一个字符串 `'201901'`. 对于类型,新样式表的语法更严格(类似于值输入格式的解析器)。 + +上述所有规则也适用于 [OPTIMIZE](misc.md#misc_operations-optimize) 查询。 如果在优化非分区表时需要指定唯一的分区,请设置表达式 `PARTITION tuple()`. 例如: + +``` sql +OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; +``` + +的例子 `ALTER ... PARTITION` 查询在测试中演示 [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) 和 [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). + +### 使用表TTL进行操作 {#manipulations-with-table-ttl} + +你可以改变 [表TTL](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) 请填写以下表格: + +``` sql +ALTER TABLE table-name MODIFY TTL ttl-expression +``` + +### ALTER查询的同步性 {#synchronicity-of-alter-queries} + +对于不可复制的表,所有 `ALTER` 查询是同步执行的。 对于可复制的表,查询仅添加相应操作的说明 `ZooKeeper`,并尽快执行操作本身。 但是,查询可以等待在所有副本上完成这些操作。 + +为 `ALTER ... ATTACH|DETACH|DROP` 查询,您可以使用 `replication_alter_partitions_sync` 设置设置等待。 +可能的值: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. + +### 突变 {#alter-mutations} + +突变是允许更改或删除表中的行的ALTER查询变体。 与标准相比 `UPDATE` 和 `DELETE` 用于点数据更改的查询,mutations适用于更改表中大量行的繁重操作。 支持的 `MergeTree` 表引擎系列,包括具有复制支持的引擎。 + +现有表可以按原样进行突变(无需转换),但是在将第一次突变应用于表之后,其元数据格式将与以前的服务器版本不兼容,并且无法回退到以前的版本。 + +当前可用的命令: + +``` sql +ALTER TABLE [db.]table DELETE WHERE filter_expr +``` + +该 `filter_expr` 必须是类型 `UInt8`. 查询删除表中此表达式采用非零值的行。 + +``` sql +ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr +``` + +该 `filter_expr` 必须是类型 `UInt8`. 此查询将指定列的值更新为行中相应表达式的值。 `filter_expr` 取非零值。 使用以下命令将值转换为列类型 `CAST` 接线员 不支持更新用于计算主键或分区键的列。 + +``` sql +ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name +``` + +查询将重新生成二级索引 `name` 在分区中 `partition_name`. + +一个查询可以包含多个用逗号分隔的命令。 + +For\*MergeTree表的突变通过重写整个数据部分来执行。 没有原子性-部分被取代为突变的部分,只要他们准备好和 `SELECT` 在突变期间开始执行的查询将看到来自已经突变的部件的数据以及来自尚未突变的部件的数据。 + +突变完全按其创建顺序排序,并以该顺序应用于每个部分。 突变也使用插入进行部分排序-在提交突变之前插入到表中的数据将被突变,之后插入的数据将不会被突变。 请注意,突变不会以任何方式阻止插入。 + +Mutation查询在添加mutation条目后立即返回(如果将复制的表复制到ZooKeeper,则将非复制的表复制到文件系统)。 突变本身使用系统配置文件设置异步执行。 要跟踪突变的进度,您可以使用 [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) 桌子 即使重新启动ClickHouse服务器,成功提交的突变仍将继续执行。 一旦提交,没有办法回滚突变,但如果突变由于某种原因被卡住,可以使用 [`KILL MUTATION`](misc.md#kill-mutation) 查询。 + +已完成突变的条目不会立即删除(保留条目的数量由 `finished_mutations_to_keep` 存储引擎参数)。 旧的突变条目将被删除。 + +## ALTER USER {#alter-user-statement} + +更改ClickHouse用户帐户. + +### 语法 {#alter-user-syntax} + +``` sql +ALTER USER [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}] + [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE] + [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +### 产品描述 {#alter-user-dscr} + +使用 `ALTER USER` 你必须有 [ALTER USER](grant.md#grant-access-management) 特权 + +### 例 {#alter-user-examples} + +将授予的角色设置为默认值: + +``` sql +ALTER USER user DEFAULT ROLE role1, role2 +``` + +如果以前未向用户授予角色,ClickHouse将引发异常。 + +将所有授予的角色设置为默认值: + +``` sql +ALTER USER user DEFAULT ROLE ALL +``` + +如果将来将某个角色授予某个用户,它将自动成为默认值。 + +将所有授予的角色设置为默认值,除非 `role1` 和 `role2`: + +``` sql +ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2 +``` + +## ALTER ROLE {#alter-role-statement} + +更改角色。 + +### 语法 {#alter-role-syntax} + +``` sql +ALTER ROLE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...] +``` + +## ALTER ROW POLICY {#alter-row-policy-statement} + +更改行策略。 + +### 语法 {#alter-row-policy-syntax} + +``` sql +ALTER [ROW] POLICY [IF EXISTS] name [ON CLUSTER cluster_name] ON [database.]table + [RENAME TO new_name] + [AS {PERMISSIVE | RESTRICTIVE}] + [FOR SELECT] + [USING {condition | NONE}][,...] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +## ALTER QUOTA {#alter-quota-statement} + +更改配额。 + +### 语法 {#alter-quota-syntax} + +``` sql +ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [KEYED BY {'none' | 'user name' | 'ip address' | 'client key' | 'client key or user name' | 'client key or ip address'}] + [FOR [RANDOMIZED] INTERVAL number {SECOND | MINUTE | HOUR | DAY} + {MAX { {QUERIES | ERRORS | RESULT ROWS | RESULT BYTES | READ ROWS | READ BYTES | EXECUTION TIME} = number } [,...] | + NO LIMITS | TRACKING ONLY} [,...]] + [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] +``` + +## ALTER SETTINGS PROFILE {#alter-settings-profile-statement} + +更改配额。 + +### 语法 {#alter-settings-profile-syntax} + +``` sql +ALTER SETTINGS PROFILE [IF EXISTS] name [ON CLUSTER cluster_name] + [RENAME TO new_name] + [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | INHERIT 'profile_name'] [,...] +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/zh/sql-reference/statements/create.md b/docs/zh/sql-reference/statements/create.md new file mode 100644 index 00000000000..37b9cbb734e --- /dev/null +++ b/docs/zh/sql-reference/statements/create.md @@ -0,0 +1,263 @@ +## CREATE DATABASE {#create-database} + +该查询用于根据指定名称创建数据库。 + +``` sql +CREATE DATABASE [IF NOT EXISTS] db_name +``` + +数据库其实只是用于存放表的一个目录。 +如果查询中存在`IF NOT EXISTS`,则当数据库已经存在时,该查询不会返回任何错误。 + +## CREATE TABLE {#create-table-query} + +对于`CREATE TABLE`,存在以下几种方式。 + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = engine +``` + +在指定的’db’数据库中创建一个名为’name’的表,如果查询中没有包含’db’,则默认使用当前选择的数据库作为’db’。后面的是包含在括号中的表结构以及表引擎的声明。 +其中表结构声明是一个包含一组列描述声明的组合。如果表引擎是支持索引的,那么可以在表引擎的参数中对其进行说明。 + +在最简单的情况下,列描述是指`名称 类型`这样的子句。例如: `RegionID UInt32`。 +但是也可以为列另外定义默认值表达式(见后文)。 + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] +``` + +创建一个与`db2.name2`具有相同结构的表,同时你可以对其指定不同的表引擎声明。如果没有表引擎声明,则创建的表将与`db2.name2`使用相同的表引擎。 + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... +``` + +使用指定的引擎创建一个与`SELECT`子句的结果具有相同结构的表,并使用`SELECT`子句的结果填充它。 + +以上所有情况,如果指定了`IF NOT EXISTS`,那么在该表已经存在的情况下,查询不会返回任何错误。在这种情况下,查询几乎不会做任何事情。 + +在`ENGINE`子句后还可能存在一些其他的子句,更详细的信息可以参考 [表引擎](../../sql-reference/statements/create.md) 中关于建表的描述。 + +### 默认值 {#create-default-values} + +在列描述中你可以通过以下方式之一为列指定默认表达式:`DEFAULT expr`,`MATERIALIZED expr`,`ALIAS expr`。 +示例:`URLDomain String DEFAULT domain(URL)`。 + +如果在列描述中未定义任何默认表达式,那么系统将会根据类型设置对应的默认值,如:数值类型为零、字符串类型为空字符串、数组类型为空数组、日期类型为’0000-00-00’以及时间类型为’0000-00-00 00:00:00’。不支持使用NULL作为普通类型的默认值。 + +如果定义了默认表达式,则可以不定义列的类型。如果没有明确的定义类的类型,则使用默认表达式的类型。例如:`EventDate DEFAULT toDate(EventTime)` - 最终’EventDate’将使用’Date’作为类型。 + +如果同时指定了默认表达式与列的类型,则将使用类型转换函数将默认表达式转换为指定的类型。例如:`Hits UInt32 DEFAULT 0`与`Hits UInt32 DEFAULT toUInt32(0)`意思相同。 + +默认表达式可以包含常量或表的任意其他列。当创建或更改表结构时,系统将会运行检查,确保不会包含循环依赖。对于INSERT, 它仅检查表达式是否是可以解析的 - 它们可以从中计算出所有需要的列的默认值。 + +`DEFAULT expr` + +普通的默认值,如果INSERT中不包含指定的列,那么将通过表达式计算它的默认值并填充它。 + +`MATERIALIZED expr` + +物化表达式,被该表达式指定的列不能包含在INSERT的列表中,因为它总是被计算出来的。 +对于INSERT而言,不需要考虑这些列。 +另外,在SELECT查询中如果包含星号,此列不会被用来替换星号,这是因为考虑到数据转储,在使用`SELECT *`查询出的结果总能够被’INSERT’回表。 + +`ALIAS expr` + +别名。这样的列不会存储在表中。 +它的值不能够通过INSERT写入,同时使用SELECT查询星号时,这些列也不会被用来替换星号。 +但是它们可以显示的用于SELECT中,在这种情况下,在查询分析中别名将被替换。 + +当使用ALTER查询对添加新的列时,不同于为所有旧数据添加这个列,对于需要在旧数据中查询新列,只会在查询时动态计算这个新列的值。但是如果新列的默认表示中依赖其他列的值进行计算,那么同样会加载这些依赖的列的数据。 + +如果你向表中添加一个新列,并在之后的一段时间后修改它的默认表达式,则旧数据中的值将会被改变。请注意,在运行后台合并时,缺少的列的值将被计算后写入到合并后的数据部分中。 + +不能够为nested类型的列设置默认值。 + +### 制约因素 {#constraints} + +随着列描述约束可以定义: + +``` sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], + ... + CONSTRAINT constraint_name_1 CHECK boolean_expr_1, + ... +) ENGINE = engine +``` + +`boolean_expr_1` 可以通过任何布尔表达式。 如果为表定义了约束,则将为表中的每一行检查它们中的每一行 `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. + +添加大量的约束会对big的性能产生负面影响 `INSERT` 查询。 + +### Ttl表达式 {#ttl-expression} + +定义值的存储时间。 只能为MergeTree系列表指定。 有关详细说明,请参阅 [列和表的TTL](../../sql-reference/statements/create.md#table_engine-mergetree-ttl). + +### 列压缩编解ecs {#codecs} + +默认情况下,ClickHouse应用以下定义的压缩方法 [服务器设置](../../sql-reference/statements/create.md#server-settings-compression),列。 您还可以定义在每个单独的列的压缩方法 `CREATE TABLE` 查询。 + +``` sql +CREATE TABLE codec_example +( + dt Date CODEC(ZSTD), + ts DateTime CODEC(LZ4HC), + float_value Float32 CODEC(NONE), + double_value Float64 CODEC(LZ4HC(9)) + value Float32 CODEC(Delta, ZSTD) +) +ENGINE = +... +``` + +如果指定了编解ec,则默认编解码器不适用。 编解码器可以组合在一个流水线中,例如, `CODEC(Delta, ZSTD)`. 要为您的项目选择最佳的编解码器组合,请通过类似于Altinity中描述的基准测试 [新编码提高ClickHouse效率](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) 文章. + +!!! warning "警告" + 您无法使用外部实用程序解压缩ClickHouse数据库文件,如 `lz4`. 相反,使用特殊的 [ツ环板compressorョツ嘉ッツ偲](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) 实用程序。 + +下表引擎支持压缩: + +- [MergeTree](../../sql-reference/statements/create.md) 家庭 +- [日志](../../sql-reference/statements/create.md) 家庭 +- [设置](../../sql-reference/statements/create.md) +- [加入我们](../../sql-reference/statements/create.md) + +ClickHouse支持通用编解码器和专用编解ecs。 + +#### 专业编解ecs {#create-query-specialized-codecs} + +这些编解码器旨在通过使用数据的特定功能使压缩更有效。 其中一些编解码器不压缩数据本身。 相反,他们准备的数据用于共同目的的编解ec,其压缩它比没有这种准备更好。 + +专业编解ecs: + +- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` 用于存储增量值,所以 `delta_bytes` 是原始值的最大大小。 可能 `delta_bytes` 值:1,2,4,8. 默认值 `delta_bytes` 是 `sizeof(type)` 如果等于1,2,4或8。 在所有其他情况下,它是1。 +- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [Gorilla:一个快速、可扩展的内存时间序列数据库](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [Gorilla:一个快速、可扩展的内存时间序列数据库](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). +- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` 和 `DateTime`). 在算法的每个步骤中,编解码器采用64个值块,将它们放入64x64位矩阵中,对其进行转置,裁剪未使用的值位并将其余部分作为序列返回。 未使用的位是使用压缩的整个数据部分的最大值和最小值之间没有区别的位。 + +`DoubleDelta` 和 `Gorilla` 编解码器在Gorilla TSDB中用作其压缩算法的组件。 大猩猩的方法是有效的情况下,当有缓慢变化的值与他们的时间戳序列。 时间戳是由有效地压缩 `DoubleDelta` 编解ec,和值有效地由压缩 `Gorilla` 编解ec 例如,要获取有效存储的表,可以在以下配置中创建它: + +``` sql +CREATE TABLE codec_example +( + timestamp DateTime CODEC(DoubleDelta), + slow_values Float32 CODEC(Gorilla) +) +ENGINE = MergeTree() +``` + +#### 通用编解ecs {#create-query-common-purpose-codecs} + +编解ecs: + +- `NONE` — No compression. +- `LZ4` — Lossless [数据压缩算法](https://github.com/lz4/lz4) 默认情况下使用。 应用LZ4快速压缩。 +- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` 应用默认级别。 可能的水平:\[1,12\]。 推荐级别范围:\[4,9\]。 +- `ZSTD[(level)]` — [ZSTD压缩算法](https://en.wikipedia.org/wiki/Zstandard) 可配置 `level`. 可能的水平:\[1,22\]。 默认值:1。 + +高压缩级别对于非对称场景非常有用,例如压缩一次,重复解压缩。 更高的级别意味着更好的压缩和更高的CPU使用率。 + +## 临时表 {#lin-shi-biao} + +ClickHouse支持临时表,其具有以下特征: + +- 当回话结束时,临时表将随会话一起消失,这包含链接中断。 +- 临时表仅能够使用Memory表引擎。 +- 无法为临时表指定数据库。它是在数据库之外创建的。 +- 如果临时表与另一个表名称相同,那么当在查询时没有显示的指定db的情况下,将优先使用临时表。 +- 对于分布式处理,查询中使用的临时表将被传递到远程服务器。 + +可以使用下面的语法创建一个临时表: + +``` sql +CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) +``` + +大多数情况下,临时表不是手动创建的,只有在分布式查询处理中使用`(GLOBAL) IN`时为外部数据创建。更多信息,可以参考相关章节。 + +## 分布式DDL查询 (ON CLUSTER 子句) {#fen-bu-shi-ddlcha-xun-on-cluster-zi-ju} + +对于 `CREATE`, `DROP`, `ALTER`,以及`RENAME`查询,系统支持其运行在整个集群上。 +例如,以下查询将在`cluster`集群的所有节点上创建名为`all_hits`的`Distributed`表: + +``` sql +CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) +``` + +为了能够正确的运行这种查询,每台主机必须具有相同的cluster声明(为了简化配置的同步,你可以使用zookeeper的方式进行配置)。同时这些主机还必须链接到zookeeper服务器。 +这个查询将最终在集群的每台主机上运行,即使一些主机当前处于不可用状态。同时它还保证了所有的查询在单台主机中的执行顺序。 + +## CREATE VIEW {#create-view} + +``` sql +CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... +``` + +创建一个视图。它存在两种可选择的类型:普通视图与物化视图。 + +普通视图不存储任何数据,只是执行从另一个表中的读取。换句话说,普通视图只是保存了视图的查询,当从视图中查询时,此查询被作为子查询用于替换FROM子句。 + +举个例子,假设你已经创建了一个视图: + +``` sql +CREATE VIEW view AS SELECT ... +``` + +还有一个查询: + +``` sql +SELECT a, b, c FROM view +``` + +这个查询完全等价于: + +``` sql +SELECT a, b, c FROM (SELECT ...) +``` + +物化视图存储的数据是由相应的SELECT查询转换得来的。 + +在创建物化视图时,你还必须指定表的引擎 - 将会使用这个表引擎存储数据。 + +目前物化视图的工作原理:当将数据写入到物化视图中SELECT子句所指定的表时,插入的数据会通过SELECT子句查询进行转换并将最终结果插入到视图中。 + +如果创建物化视图时指定了POPULATE子句,则在创建时将该表的数据插入到物化视图中。就像使用`CREATE TABLE ... AS SELECT ...`一样。否则,物化视图只会包含在物化视图创建后的新写入的数据。我们不推荐使用POPULATE,因为在视图创建期间写入的数据将不会写入其中。 + +当一个`SELECT`子句包含`DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`时,请注意,这些仅会在插入数据时在每个单独的数据块上执行。例如,如果你在其中包含了`GROUP BY`,则只会在查询期间进行聚合,但聚合范围仅限于单个批的写入数据。数据不会进一步被聚合。但是当你使用一些其他数据聚合引擎时这是例外的,如:`SummingMergeTree`。 + +目前对物化视图执行`ALTER`是不支持的,因此这可能是不方便的。如果物化视图是使用的`TO [db.]name`的方式进行构建的,你可以使用`DETACH`语句现将视图剥离,然后使用`ALTER`运行在目标表上,然后使用`ATTACH`将之前剥离的表重新加载进来。 + +视图看起来和普通的表相同。例如,你可以通过`SHOW TABLES`查看到它们。 + +没有单独的删除视图的语法。如果要删除视图,请使用`DROP TABLE`。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/create/) + +## CREATE DICTIONARY {#create-dictionary-query} + +``` sql +CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] +( + key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], + attr1 type2 [DEFAULT|EXPRESSION expr3], + attr2 type2 [DEFAULT|EXPRESSION expr4] +) +PRIMARY KEY key1, key2 +SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) +LAYOUT(LAYOUT_NAME([param_name param_value])) +LIFETIME([MIN val1] MAX val2) +``` diff --git a/docs/zh/sql-reference/statements/grant.md b/docs/zh/sql-reference/statements/grant.md new file mode 120000 index 00000000000..f2acbe125b4 --- /dev/null +++ b/docs/zh/sql-reference/statements/grant.md @@ -0,0 +1 @@ +../../../en/sql-reference/statements/grant.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/index.md b/docs/zh/sql-reference/statements/index.md new file mode 100644 index 00000000000..1c5f4e9a7ef --- /dev/null +++ b/docs/zh/sql-reference/statements/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u53D1\u8A00" +toc_priority: 31 +--- + + diff --git a/docs/zh/sql-reference/statements/insert-into.md b/docs/zh/sql-reference/statements/insert-into.md new file mode 100644 index 00000000000..e8b5edfdb37 --- /dev/null +++ b/docs/zh/sql-reference/statements/insert-into.md @@ -0,0 +1,67 @@ +## INSERT {#insert} + +INSERT查询主要用于向系统中添加数据. + +查询的基本格式: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... +``` + +您可以在查询中指定插入的列的列表,如:`[(c1, c2, c3)]`。对于存在于表结构中但不存在于插入列表中的列,它们将会按照如下方式填充数据: + +- 如果存在`DEFAULT`表达式,根据`DEFAULT`表达式计算被填充的值。 +- 如果没有定义`DEFAULT`表达式,则填充零或空字符串。 + +如果 [strict\_insert\_defaults=1](../../operations/settings/settings.md),你必须在查询中列出所有没有定义`DEFAULT`表达式的列。 + +数据可以以ClickHouse支持的任何 [输入输出格式](../../interfaces/formats.md#formats) 传递给INSERT。格式的名称必须显示的指定在查询中: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set +``` + +例如,下面的查询所使用的输入格式就与上面INSERT … VALUES的中使用的输入格式相同: + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... +``` + +ClickHouse会清除数据前所有的空白字符与一行摘要信息(如果需要的话)。所以在进行查询时,我们建议您将数据放入到输入输出格式名称后的新的一行中去(如果数据是以空白字符开始的,这将非常重要)。 + +示例: + +``` sql +INSERT INTO t FORMAT TabSeparated +11 Hello, world! +22 Qwerty +``` + +在使用命令行客户端或HTTP客户端时,你可以将具体的查询语句与数据分开发送。更多具体信息,请参考«[客户端](../../interfaces/index.md#interfaces)»部分。 + +### 使用`SELECT`的结果写入 {#insert_query_insert-select} + +``` sql +INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... +``` + +写入与SELECT的列的对应关系是使用位置来进行对应的,尽管它们在SELECT表达式与INSERT中的名称可能是不同的。如果需要,会对它们执行对应的类型转换。 + +除了VALUES格式之外,其他格式中的数据都不允许出现诸如`now()`,`1 + 2`等表达式。VALUES格式允许您有限度的使用这些表达式,但是不建议您这么做,因为执行这些表达式总是低效的。 + +系统不支持的其他用于修改数据的查询:`UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`。 +但是,您可以使用 `ALTER TABLE ... DROP PARTITION`查询来删除一些旧的数据。 + +### 性能的注意事项 {#xing-neng-de-zhu-yi-shi-xiang} + +在进行`INSERT`时将会对写入的数据进行一些处理,按照主键排序,按照月份对数据进行分区等。所以如果在您的写入数据中包含多个月份的混合数据时,将会显著的降低`INSERT`的性能。为了避免这种情况: + +- 数据总是以尽量大的batch进行写入,如每次写入100,000行。 +- 数据在写入ClickHouse前预先的对数据进行分组。 + +在以下的情况下,性能不会下降: + +- 数据总是被实时的写入。 +- 写入的数据已经按照时间排序。 + +[来源文章](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/zh/sql-reference/statements/misc.md b/docs/zh/sql-reference/statements/misc.md new file mode 100644 index 00000000000..aa10350280f --- /dev/null +++ b/docs/zh/sql-reference/statements/misc.md @@ -0,0 +1,358 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: "\u5176\u4ED6" +--- + +# 杂项查询 {#miscellaneous-queries} + +## ATTACH {#attach} + +这个查询是完全一样的 `CREATE`,但是 + +- 而不是这个词 `CREATE` 它使用这个词 `ATTACH`. +- 查询不会在磁盘上创建数据,但假定数据已经在适当的位置,只是将有关表的信息添加到服务器。 + 执行附加查询后,服务器将知道表的存在。 + +如果表之前已分离 (`DETACH`),意味着其结构是已知的,可以使用速记而不限定该结构。 + +``` sql +ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] +``` + +启动服务器时使用此查询。 服务器将表元数据作为文件存储 `ATTACH` 查询,它只是在启动时运行(除了在服务器上显式创建的系统表)。 + +## CHECK TABLE {#check-table} + +检查表中的数据是否已损坏。 + +``` sql +CHECK TABLE [db.]name +``` + +该 `CHECK TABLE` 查询将实际文件大小与存储在服务器上的预期值进行比较。 如果文件大小与存储的值不匹配,则表示数据已损坏。 例如,这可能是由查询执行期间的系统崩溃引起的。 + +查询响应包含 `result` 具有单行的列。 该行的值为 +[布尔值](../../sql-reference/data-types/boolean.md) 类型: + +- 0-表中的数据已损坏。 +- 1-数据保持完整性。 + +该 `CHECK TABLE` 查询支持下表引擎: + +- [日志](../../engines/table-engines/log-family/log.md) +- [TinyLog](../../engines/table-engines/log-family/tinylog.md) +- [StripeLog](../../engines/table-engines/log-family/stripelog.md) +- [梅树家族](../../engines/table-engines/mergetree-family/mergetree.md) + +使用另一个表引擎对表执行会导致异常。 + +从发动机 `*Log` 家庭不提供故障自动数据恢复。 使用 `CHECK TABLE` 查询以及时跟踪数据丢失。 + +为 `MergeTree` 家庭发动机, `CHECK TABLE` 查询显示本地服务器上表的每个单独数据部分的检查状态。 + +**如果数据已损坏** + +如果表已损坏,则可以将未损坏的数据复制到另一个表。 要做到这一点: + +1. 创建具有与损坏的表相同结构的新表。 要执行此操作,请执行查询 `CREATE TABLE AS `. +2. 设置 [max\_threads](../../operations/settings/settings.md#settings-max_threads) 值为1以在单个线程中处理下一个查询。 要执行此操作,请运行查询 `SET max_threads = 1`. +3. 执行查询 `INSERT INTO SELECT * FROM `. 此请求将未损坏的数据从损坏的表复制到另一个表。 只有损坏部分之前的数据才会被复制。 +4. 重新启动 `clickhouse-client` 要重置 `max_threads` 价值。 + +## DESCRIBE TABLE {#misc-describe-table} + +``` sql +DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +返回以下内容 `String` 类型列: + +- `name` — Column name. +- `type`— Column type. +- `default_type` — Clause that is used in [默认表达式](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` 或 `ALIAS`). 如果未指定默认表达式,则Column包含一个空字符串。 +- `default_expression` — Value specified in the `DEFAULT` 条款 +- `comment_expression` — Comment text. + +嵌套的数据结构输出 “expanded” 格式。 每列分别显示,名称后面有一个点。 + +## DETACH {#detach} + +删除有关 ‘name’ 表从服务器。 服务器停止了解表的存在。 + +``` sql +DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +这不会删除表的数据或元数据。 在下一次服务器启动时,服务器将读取元数据并再次查找有关表的信息。 +同样,一个 “detached” 表可以使用重新连接 `ATTACH` 查询(系统表除外,它们没有为它们存储元数据)。 + +没有 `DETACH DATABASE` 查询。 + +## DROP {#drop} + +此查询有两种类型: `DROP DATABASE` 和 `DROP TABLE`. + +``` sql +DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] +``` + +删除内部的所有表 ‘db’ 数据库,然后删除 ‘db’ 数据库本身。 +如果 `IF EXISTS` 如果数据库不存在,则不会返回错误。 + +``` sql +DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +删除表。 +如果 `IF EXISTS` 如果表不存在或数据库不存在,则不会返回错误。 + + DROP DICTIONARY [IF EXISTS] [db.]name + +删除字典。 +如果 `IF EXISTS` 如果表不存在或数据库不存在,则不会返回错误。 + +## DROP USER {#drop-user-statement} + +删除用户。 + +### 语法 {#drop-user-syntax} + +``` sql +DROP USER [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROLE {#drop-role-statement} + +删除角色。 + +已删除的角色将从授予该角色的所有实体撤销。 + +### 语法 {#drop-role-syntax} + +``` sql +DROP ROLE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP ROW POLICY {#drop-row-policy-statement} + +删除行策略。 + +已删除行策略将从分配该策略的所有实体撤销。 + +### 语法 {#drop-row-policy-syntax} + +``` sql +DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] +``` + +## DROP QUOTA {#drop-quota-statement} + +删除配额。 + +已删除的配额将从分配配额的所有实体撤销。 + +### 语法 {#drop-quota-syntax} + +``` sql +DROP QUOTA [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## DROP SETTINGS PROFILE {#drop-settings-profile-statement} + +删除配额。 + +已删除的配额将从分配配额的所有实体撤销。 + +### 语法 {#drop-settings-profile-syntax} + +``` sql +DROP [SETTINGS] PROFILE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] +``` + +## EXISTS {#exists-statement} + +``` sql +EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] +``` + +返回单 `UInt8`-type column,其中包含单个值 `0` 如果表或数据库不存在,或 `1` 如果该表存在于指定的数据库中。 + +## KILL QUERY {#kill-query-statement} + +``` sql +KILL QUERY [ON CLUSTER cluster] + WHERE + [SYNC|ASYNC|TEST] + [FORMAT format] +``` + +尝试强制终止当前正在运行的查询。 +要终止的查询是从系统中选择的。使用在定义的标准进程表 `WHERE` 《公约》条款 `KILL` 查询。 + +例: + +``` sql +-- Forcibly terminates all queries with the specified query_id: +KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' + +-- Synchronously terminates all queries run by 'username': +KILL QUERY WHERE user='username' SYNC +``` + +只读用户只能停止自己的查询。 + +默认情况下,使用异步版本的查询 (`ASYNC`),不等待确认查询已停止。 + +同步版本 (`SYNC`)等待所有查询停止,并在停止时显示有关每个进程的信息。 +响应包含 `kill_status` 列,它可以采用以下值: + +1. ‘finished’ – The query was terminated successfully. +2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. +3. The other values ​​explain why the query can't be stopped. + +测试查询 (`TEST`)仅检查用户的权限并显示要停止的查询列表。 + +## KILL MUTATION {#kill-mutation} + +``` sql +KILL MUTATION [ON CLUSTER cluster] + WHERE + [TEST] + [FORMAT format] +``` + +尝试取消和删除 [突变](alter.md#alter-mutations) 当前正在执行。 要取消的突变选自 [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) 表使用由指定的过滤器 `WHERE` 《公约》条款 `KILL` 查询。 + +测试查询 (`TEST`)仅检查用户的权限并显示要停止的查询列表。 + +例: + +``` sql +-- Cancel and remove all mutations of the single table: +KILL MUTATION WHERE database = 'default' AND table = 'table' + +-- Cancel the specific mutation: +KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' +``` + +The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). + +已经由突变所做的更改不会回滚。 + +## OPTIMIZE {#misc_operations-optimize} + +``` sql +OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] +``` + +此查询尝试使用来自表引擎的表初始化表的数据部分的非计划合并 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 家人 + +该 `OPTMIZE` 查询也支持 [MaterializedView](../../engines/table-engines/special/materializedview.md) 和 [缓冲区](../../engines/table-engines/special/buffer.md) 引擎 不支持其他表引擎。 + +当 `OPTIMIZE` 与使用 [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md) 表引擎的家族,ClickHouse创建合并任务,并等待在所有节点上执行(如果 `replication_alter_partitions_sync` 设置已启用)。 + +- 如果 `OPTIMIZE` 出于任何原因不执行合并,它不通知客户端。 要启用通知,请使用 [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop) 设置。 +- 如果您指定 `PARTITION`,仅优化指定的分区。 [如何设置分区表达式](alter.md#alter-how-to-specify-part-expr). +- 如果您指定 `FINAL`,即使所有数据已经在一个部分中,也会执行优化。 +- 如果您指定 `DEDUPLICATE`,然后完全相同的行将被重复数据删除(所有列进行比较),这仅适用于MergeTree引擎。 + +!!! warning "警告" + `OPTIMIZE` 无法修复 “Too many parts” 错误 + +## RENAME {#misc_operations-rename} + +重命名一个或多个表。 + +``` sql +RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] +``` + +所有表都在全局锁定下重命名。 重命名表是一个轻型操作。 如果您在TO之后指定了另一个数据库,则表将被移动到此数据库。 但是,包含数据库的目录必须位于同一文件系统中(否则,将返回错误)。 + +## SET {#query-set} + +``` sql +SET param = value +``` + +分配 `value` 到 `param` [设置](../../operations/settings/index.md) 对于当前会话。 你不能改变 [服务器设置](../../operations/server-configuration-parameters/index.md) 这边 + +您还可以在单个查询中设置指定设置配置文件中的所有值。 + +``` sql +SET profile = 'profile-name-from-the-settings-file' +``` + +有关详细信息,请参阅 [设置](../../operations/settings/settings.md). + +## SET ROLE {#set-role-statement} + +激活当前用户的角色。 + +### 语法 {#set-role-syntax} + +``` sql +SET ROLE {DEFAULT | NONE | role [,...] | ALL | ALL EXCEPT role [,...]} +``` + +## SET DEFAULT ROLE {#set-default-role-statement} + +将默认角色设置为用户。 + +默认角色在用户登录时自动激活。 您只能将以前授予的角色设置为默认值。 如果未向用户授予角色,ClickHouse将引发异常。 + +### 语法 {#set-default-role-syntax} + +``` sql +SET DEFAULT ROLE {NONE | role [,...] | ALL | ALL EXCEPT role [,...]} TO {user|CURRENT_USER} [,...] +``` + +### 例 {#set-default-role-examples} + +为用户设置多个默认角色: + +``` sql +SET DEFAULT ROLE role1, role2, ... TO user +``` + +将所有授予的角色设置为用户的默认值: + +``` sql +SET DEFAULT ROLE ALL TO user +``` + +从用户清除默认角色: + +``` sql +SET DEFAULT ROLE NONE TO user +``` + +将所有授予的角色设置为默认角色,其中一些角色除外: + +``` sql +SET DEFAULT ROLE ALL EXCEPT role1, role2 TO user +``` + +## TRUNCATE {#truncate-statement} + +``` sql +TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +``` + +从表中删除所有数据。 当条款 `IF EXISTS` 如果该表不存在,则查询返回错误。 + +该 `TRUNCATE` 查询不支持 [查看](../../engines/table-engines/special/view.md), [文件](../../engines/table-engines/special/file.md), [URL](../../engines/table-engines/special/url.md) 和 [Null](../../engines/table-engines/special/null.md) 表引擎. + +## USE {#use} + +``` sql +USE db +``` + +用于设置会话的当前数据库。 +当前数据库用于搜索表,如果数据库没有在查询中明确定义与表名之前的点。 +使用HTTP协议时无法进行此查询,因为没有会话的概念。 + +[原始文章](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/zh/sql-reference/statements/revoke.md b/docs/zh/sql-reference/statements/revoke.md new file mode 120000 index 00000000000..4321fdb14a7 --- /dev/null +++ b/docs/zh/sql-reference/statements/revoke.md @@ -0,0 +1 @@ +../../../en/sql-reference/statements/revoke.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/array-join.md b/docs/zh/sql-reference/statements/select/array-join.md new file mode 120000 index 00000000000..c341801e419 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/array-join.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/array-join.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/distinct.md b/docs/zh/sql-reference/statements/select/distinct.md new file mode 120000 index 00000000000..59319557dc1 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/distinct.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/distinct.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/format.md b/docs/zh/sql-reference/statements/select/format.md new file mode 120000 index 00000000000..106b2d9ebbc --- /dev/null +++ b/docs/zh/sql-reference/statements/select/format.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/format.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/from.md b/docs/zh/sql-reference/statements/select/from.md new file mode 120000 index 00000000000..f8ebfe655cc --- /dev/null +++ b/docs/zh/sql-reference/statements/select/from.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/from.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/group-by.md b/docs/zh/sql-reference/statements/select/group-by.md new file mode 120000 index 00000000000..cf519ad7781 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/group-by.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/group-by.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/having.md b/docs/zh/sql-reference/statements/select/having.md new file mode 120000 index 00000000000..4a038beb126 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/having.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/having.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/index.md b/docs/zh/sql-reference/statements/select/index.md new file mode 120000 index 00000000000..9c649322c82 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/index.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/index.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/into-outfile.md b/docs/zh/sql-reference/statements/select/into-outfile.md new file mode 120000 index 00000000000..2c9c812b3d5 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/into-outfile.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/into-outfile.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/join.md b/docs/zh/sql-reference/statements/select/join.md new file mode 120000 index 00000000000..5951a105137 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/join.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/join.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/limit-by.md b/docs/zh/sql-reference/statements/select/limit-by.md new file mode 120000 index 00000000000..f3a63e9fe22 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/limit-by.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/limit-by.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/limit.md b/docs/zh/sql-reference/statements/select/limit.md new file mode 120000 index 00000000000..e0a0c632dac --- /dev/null +++ b/docs/zh/sql-reference/statements/select/limit.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/limit.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/order-by.md b/docs/zh/sql-reference/statements/select/order-by.md new file mode 120000 index 00000000000..cc2567bce0b --- /dev/null +++ b/docs/zh/sql-reference/statements/select/order-by.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/order-by.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/prewhere.md b/docs/zh/sql-reference/statements/select/prewhere.md new file mode 120000 index 00000000000..567fc95356f --- /dev/null +++ b/docs/zh/sql-reference/statements/select/prewhere.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/prewhere.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/sample.md b/docs/zh/sql-reference/statements/select/sample.md new file mode 120000 index 00000000000..9df6e25d0f3 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/sample.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/sample.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/union-all.md b/docs/zh/sql-reference/statements/select/union-all.md new file mode 120000 index 00000000000..837caae2698 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/union-all.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/union-all.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/where.md b/docs/zh/sql-reference/statements/select/where.md new file mode 120000 index 00000000000..8ba28926879 --- /dev/null +++ b/docs/zh/sql-reference/statements/select/where.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/where.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/with.md b/docs/zh/sql-reference/statements/select/with.md new file mode 120000 index 00000000000..8b7ea4db44c --- /dev/null +++ b/docs/zh/sql-reference/statements/select/with.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/with.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/show.md b/docs/zh/sql-reference/statements/show.md new file mode 100644 index 00000000000..95404f3d416 --- /dev/null +++ b/docs/zh/sql-reference/statements/show.md @@ -0,0 +1,169 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: SHOW +--- + +# 显示查询 {#show-queries} + +## SHOW CREATE TABLE {#show-create-table} + +``` sql +SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] +``` + +返回单 `String`-类型 ‘statement’ column, which contains a single value – the `CREATE` 用于创建指定对象的查询。 + +## SHOW DATABASES {#show-databases} + +``` sql +SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] +``` + +打印所有数据库的列表。 +这个查询是相同的 `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. + +## SHOW PROCESSLIST {#show-processlist} + +``` sql +SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] +``` + +输出的内容 [系统。流程](../../operations/system-tables.md#system_tables-processes) 表,包含目前正在处理的查询列表,除了 `SHOW PROCESSLIST` 查询。 + +该 `SELECT * FROM system.processes` 查询返回有关所有当前查询的数据。 + +提示(在控制台中执行): + +``` bash +$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" +``` + +## SHOW TABLES {#show-tables} + +显示表的列表。 + +``` sql +SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +如果 `FROM` 如果未指定子句,则查询返回当前数据库中的表列表。 + +你可以得到相同的结果 `SHOW TABLES` 通过以下方式进行查询: + +``` sql +SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**示例** + +下面的查询从表的列表中选择前两行 `system` 数据库,其名称包含 `co`. + +``` sql +SHOW TABLES FROM system LIKE '%co%' LIMIT 2 +``` + +``` text +┌─name───────────────────────────┐ +│ aggregate_function_combinators │ +│ collations │ +└────────────────────────────────┘ +``` + +## SHOW DICTIONARIES {#show-dictionaries} + +显示列表 [外部字典](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). + +``` sql +SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +如果 `FROM` 如果未指定子句,则查询从当前数据库返回字典列表。 + +你可以得到相同的结果 `SHOW DICTIONARIES` 通过以下方式进行查询: + +``` sql +SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] +``` + +**示例** + +下面的查询从表的列表中选择前两行 `system` 数据库,其名称包含 `reg`. + +``` sql +SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 +``` + +``` text +┌─name─────────┐ +│ regions │ +│ region_names │ +└──────────────┘ +``` + +## SHOW GRANTS {#show-grants-statement} + +显示用户的权限。 + +### 语法 {#show-grants-syntax} + +``` sql +SHOW GRANTS [FOR user] +``` + +如果未指定user,则查询返回当前用户的权限。 + +## SHOW CREATE USER {#show-create-user-statement} + +显示了在使用的参数 [用户创建](create.md#create-user-statement). + +`SHOW CREATE USER` 不输出用户密码。 + +### 语法 {#show-create-user-syntax} + +``` sql +SHOW CREATE USER [name | CURRENT_USER] +``` + +## SHOW CREATE ROLE {#show-create-role-statement} + +显示了在使用的参数 [角色创建](create.md#create-role-statement) + +### 语法 {#show-create-role-syntax} + +``` sql +SHOW CREATE ROLE name +``` + +## SHOW CREATE ROW POLICY {#show-create-row-policy-statement} + +显示了在使用的参数 [创建行策略](create.md#create-row-policy-statement) + +### 语法 {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE [ROW] POLICY name ON [database.]table +``` + +## SHOW CREATE QUOTA {#show-create-quota-statement} + +显示了在使用的参数 [创建配额](create.md#create-quota-statement) + +### 语法 {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE QUOTA [name | CURRENT] +``` + +## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile-statement} + +显示了在使用的参数 [设置配置文件创建](create.md#create-settings-profile-statement) + +### 语法 {#show-create-row-policy-syntax} + +``` sql +SHOW CREATE [SETTINGS] PROFILE name +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/zh/sql-reference/statements/system.md b/docs/zh/sql-reference/statements/system.md new file mode 100644 index 00000000000..067368e02a8 --- /dev/null +++ b/docs/zh/sql-reference/statements/system.md @@ -0,0 +1,113 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: SYSTEM +--- + +# 系统查询 {#query-language-system} + +- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) +- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) +- [DROP DNS CACHE](#query_language-system-drop-dns-cache) +- [DROP MARK CACHE](#query_language-system-drop-mark-cache) +- [FLUSH LOGS](#query_language-system-flush_logs) +- [RELOAD CONFIG](#query_language-system-reload-config) +- [SHUTDOWN](#query_language-system-shutdown) +- [KILL](#query_language-system-kill) +- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) +- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) +- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) +- [STOP MERGES](#query_language-system-stop-merges) +- [START MERGES](#query_language-system-start-merges) + +## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} + +重新加载之前已成功加载的所有字典。 +默认情况下,字典是懒惰加载的(请参阅 [dictionaries\_lazy\_load](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load)),所以不是在启动时自动加载,而是通过dictGet函数在第一次访问时初始化,或者从ENGINE=Dictionary的表中选择。 该 `SYSTEM RELOAD DICTIONARIES` 查询重新加载这样的字典(加载)。 +总是返回 `Ok.` 无论字典更新的结果如何。 + +## 重新加载字典Dictionary\_name {#query_language-system-reload-dictionary} + +完全重新加载字典 `dictionary_name`,与字典的状态无关(LOADED/NOT\_LOADED/FAILED)。 +总是返回 `Ok.` 无论更新字典的结果如何。 +字典的状态可以通过查询 `system.dictionaries` 桌子 + +``` sql +SELECT name, status FROM system.dictionaries; +``` + +## DROP DNS CACHE {#query_language-system-drop-dns-cache} + +重置ClickHouse的内部DNS缓存。 有时(对于旧的ClickHouse版本)在更改基础架构(更改另一个ClickHouse服务器或字典使用的服务器的IP地址)时需要使用此命令。 + +有关更方便(自动)缓存管理,请参阅disable\_internal\_dns\_cache、dns\_cache\_update\_period参数。 + +## DROP MARK CACHE {#query_language-system-drop-mark-cache} + +重置标记缓存。 用于开发ClickHouse和性能测试。 + +## FLUSH LOGS {#query_language-system-flush_logs} + +Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. + +## RELOAD CONFIG {#query_language-system-reload-config} + +重新加载ClickHouse配置。 当配置存储在ZooKeeeper中时使用。 + +## SHUTDOWN {#query_language-system-shutdown} + +通常关闭ClickHouse(如 `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) + +## KILL {#query_language-system-kill} + +中止ClickHouse进程(如 `kill -9 {$ pid_clickhouse-server}`) + +## 管理分布式表 {#query-language-system-distributed} + +ClickHouse可以管理 [分布](../../engines/table-engines/special/distributed.md) 桌子 当用户将数据插入到这些表中时,ClickHouse首先创建应发送到群集节点的数据队列,然后异步发送它。 您可以使用 [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed),和 [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) 查询。 您也可以同步插入分布式数据与 `insert_distributed_sync` 设置。 + +### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} + +将数据插入分布式表时禁用后台数据分发。 + +``` sql +SYSTEM STOP DISTRIBUTED SENDS [db.] +``` + +### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} + +强制ClickHouse将数据同步发送到群集节点。 如果任何节点不可用,ClickHouse将引发异常并停止查询执行。 您可以重试查询,直到查询成功,这将在所有节点恢复联机时发生。 + +``` sql +SYSTEM FLUSH DISTRIBUTED [db.] +``` + +### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} + +将数据插入分布式表时启用后台数据分发。 + +``` sql +SYSTEM START DISTRIBUTED SENDS [db.] +``` + +### STOP MERGES {#query_language-system-stop-merges} + +提供停止MergeTree系列中表的后台合并的可能性: + +``` sql +SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] +``` + +!!! note "注" + `DETACH / ATTACH` 即使在之前所有MergeTree表的合并已停止的情况下,table也会为表启动后台合并。 + +### START MERGES {#query_language-system-start-merges} + +为MergeTree系列中的表提供启动后台合并的可能性: + +``` sql +SYSTEM START MERGES [[db.]merge_tree_family_table_name] +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/zh/sql-reference/syntax.md b/docs/zh/sql-reference/syntax.md new file mode 100644 index 00000000000..b0aa9e7364f --- /dev/null +++ b/docs/zh/sql-reference/syntax.md @@ -0,0 +1,187 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 31 +toc_title: "\u8BED\u6CD5" +--- + +# 语法 {#syntax} + +系统中有两种类型的解析器:完整SQL解析器(递归下降解析器)和数据格式解析器(快速流解析器)。 +在所有情况下,除了 `INSERT` 查询时,只使用完整的SQL解析器。 +该 `INSERT` 查询使用两个解析器: + +``` sql +INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') +``` + +该 `INSERT INTO t VALUES` 片段由完整的解析器解析,并且数据 `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 由快速流解析器解析。 您也可以通过使用 [input\_format\_values\_interpret\_expressions](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) 设置。 当 `input_format_values_interpret_expressions = 1`,ClickHouse首先尝试使用fast stream解析器解析值。 如果失败,ClickHouse将尝试对数据使用完整的解析器,将其视为SQL [表达式](#syntax-expressions). + +数据可以有任何格式。 当接收到查询时,服务器计算不超过 [max\_query\_size](../operations/settings/settings.md#settings-max_query_size) RAM中请求的字节(默认为1MB),其余的是流解析。 +它允许避免与大的问题 `INSERT` 查询。 + +使用时 `Values` 格式为 `INSERT` 查询,它可能看起来数据被解析相同的表达式 `SELECT` 查询,但事实并非如此。 该 `Values` 格式更为有限。 + +本文的其余部分将介绍完整的解析器。 有关格式解析器的详细信息,请参阅 [格式](../interfaces/formats.md) 科。 + +## 空间 {#spaces} + +语法结构之间可能有任意数量的空格符号(包括查询的开始和结束)。 空格符号包括空格、制表符、换行符、CR和换页符。 + +## 评论 {#comments} + +ClickHouse支持SQL风格和C风格的注释。 +SQL风格的注释以下开头 `--` 并继续到线的末尾,一个空格后 `--` 可以省略。 +C型是从 `/*` 到 `*/`并且可以是多行,也不需要空格。 + +## 关键词 {#syntax-keywords} + +当关键字对应于以下关键字时,不区分大小写: + +- SQL标准。 例如, `SELECT`, `select` 和 `SeLeCt` 都是有效的。 +- 在一些流行的DBMS(MySQL或Postgres)中实现。 例如, `DateTime` 是一样的 `datetime`. + +数据类型名称是否区分大小写可以在 `system.data_type_families` 桌子 + +与标准SQL相比,所有其他关键字(包括函数名称)都是 **区分大小写**. + +不保留关键字;它们仅在相应的上下文中被视为保留关键字。 如果您使用 [标识符](#syntax-identifiers) 使用与关键字相同的名称,将它们括在双引号或反引号中。 例如,查询 `SELECT "FROM" FROM table_name` 是有效的,如果表 `table_name` 具有名称的列 `"FROM"`. + +## 标识符 {#syntax-identifiers} + +标识符是: + +- 集群、数据库、表、分区和列名称。 +- 功能。 +- 数据类型。 +- [表达式别名](#syntax-expression_aliases). + +标识符可以是引号或非引号。 后者是优选的。 + +非引号标识符必须与正则表达式匹配 `^[a-zA-Z_][0-9a-zA-Z_]*$` 并且不能等于 [关键词](#syntax-keywords). 例: `x, _1, X_y__Z123_.` + +如果要使用与关键字相同的标识符,或者要在标识符中使用其他符号,请使用双引号或反引号对其进行引用,例如, `"id"`, `` `id` ``. + +## 文字数 {#literals} + +有数字,字符串,复合和 `NULL` 文字。 + +### 数字 {#numeric} + +数值文字尝试进行分析: + +- 首先,作为一个64位有符号的数字,使用 [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul) 功能。 +- 如果不成功,作为64位无符号数,使用 [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) 功能。 +- 如果不成功,作为一个浮点数使用 [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) 功能。 +- 否则,将返回错误。 + +文本值具有该值适合的最小类型。 +例如,1被解析为 `UInt8`,但256被解析为 `UInt16`. 有关详细信息,请参阅 [数据类型](../sql-reference/data-types/index.md). + +例: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. + +### 字符串 {#syntax-string-literal} + +仅支持单引号中的字符串文字。 封闭的字符可以反斜杠转义。 以下转义序列具有相应的特殊值: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. 在所有其他情况下,转义序列的格式为 `\c`,哪里 `c` 是任何字符,被转换为 `c`. 这意味着你可以使用序列 `\'`和`\\`. 该值将具有 [字符串](../sql-reference/data-types/string.md) 类型。 + +在字符串文字中,你至少需要转义 `'` 和 `\`. 单引号可以用单引号,文字转义 `'It\'s'` 和 `'It''s'` 是平等的。 + +### 化合物 {#compound} + +数组使用方括号构造 `[1, 2, 3]`. Nuples用圆括号构造 `(1, 'Hello, world!', 2)`. +从技术上讲,这些不是文字,而是分别具有数组创建运算符和元组创建运算符的表达式。 +数组必须至少包含一个项目,元组必须至少包含两个项目。 +有一个单独的情况下,当元组出现在 `IN` a条款 `SELECT` 查询。 查询结果可以包含元组,但元组不能保存到数据库(除了具有以下内容的表 [记忆](../engines/table-engines/special/memory.md) 发动机)。 + +### NULL {#null-literal} + +指示该值丢失。 + +为了存储 `NULL` 在表字段中,它必须是 [可为空](../sql-reference/data-types/nullable.md) 类型。 + +根据数据格式(输入或输出), `NULL` 可能有不同的表示。 有关详细信息,请参阅以下文档 [数据格式](../interfaces/formats.md#formats). + +处理有许多细微差别 `NULL`. 例如,如果比较操作的至少一个参数是 `NULL`,此操作的结果也是 `NULL`. 对于乘法,加法和其他操作也是如此。 有关详细信息,请阅读每个操作的文档。 + +在查询中,您可以检查 `NULL` 使用 [IS NULL](operators/index.md#operator-is-null) 和 [IS NOT NULL](operators/index.md) 运算符及相关功能 `isNull` 和 `isNotNull`. + +## 功能 {#functions} + +函数调用像一个标识符一样写入,并在圆括号中包含一个参数列表(可能是空的)。 与标准SQL相比,括号是必需的,即使是空的参数列表。 示例: `now()`. +有常规函数和聚合函数(请参阅部分 “Aggregate functions”). 某些聚合函数可以包含括号中的两个参数列表。 示例: `quantile (0.9) (x)`. 这些聚合函数被调用 “parametric” 函数,并在第一个列表中的参数被调用 “parameters”. 不带参数的聚合函数的语法与常规函数的语法相同。 + +## 运营商 {#operators} + +在查询解析过程中,运算符会转换为相应的函数,同时考虑它们的优先级和关联性。 +例如,表达式 `1 + 2 * 3 + 4` 转化为 `plus(plus(1, multiply(2, 3)), 4)`. + +## 数据类型和数据库表引擎 {#data_types-and-database-table-engines} + +数据类型和表引擎 `CREATE` 查询的编写方式与标识符或函数相同。 换句话说,它们可能包含也可能不包含括号中的参数列表。 有关详细信息,请参阅部分 “Data types,” “Table engines,” 和 “CREATE”. + +## 表达式别名 {#syntax-expression_aliases} + +别名是查询中表达式的用户定义名称。 + +``` sql +expr AS alias +``` + +- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` 子句不使用 `AS` 关键字。 + + For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. + + In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. + +- `expr` — Any expression supported by ClickHouse. + + For example, `SELECT column_name * 2 AS double FROM some_table`. + +- `alias` — Name for `expr`. 别名应符合 [标识符](#syntax-identifiers) 语法 + + For example, `SELECT "table t".column_name FROM table_name AS "table t"`. + +### 使用注意事项 {#notes-on-usage} + +别名对于查询或子查询是全局的,您可以在查询的任何部分中为任何表达式定义别名。 例如, `SELECT (1 AS n) + 2, n`. + +别名在子查询和子查询之间不可见。 例如,在执行查询时 `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouse生成异常 `Unknown identifier: num`. + +如果为结果列定义了别名 `SELECT` 子查询的子句,这些列在外部查询中可见。 例如, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. + +小心使用与列或表名相同的别名。 让我们考虑以下示例: + +``` sql +CREATE TABLE t +( + a Int, + b Int +) +ENGINE = TinyLog() +``` + +``` sql +SELECT + argMax(a, b), + sum(b) AS b +FROM t +``` + +``` text +Received exception from server (version 18.14.17): +Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. +``` + +在这个例子中,我们声明表 `t` 带柱 `b`. 然后,在选择数据时,我们定义了 `sum(b) AS b` 别名 由于别名是全局的,ClickHouse替换了文字 `b` 在表达式中 `argMax(a, b)` 用表达式 `sum(b)`. 这种替换导致异常。 + +## 星号 {#asterisk} + +在一个 `SELECT` 查询中,星号可以替换表达式。 有关详细信息,请参阅部分 “SELECT”. + +## 表达式 {#syntax-expressions} + +表达式是函数、标识符、文字、运算符的应用程序、括号中的表达式、子查询或星号。 它还可以包含别名。 +表达式列表是一个或多个用逗号分隔的表达式。 +函数和运算符,反过来,可以有表达式作为参数。 + +[原始文章](https://clickhouse.tech/docs/en/sql_reference/syntax/) diff --git a/docs/zh/sql-reference/table-functions/file.md b/docs/zh/sql-reference/table-functions/file.md new file mode 100644 index 00000000000..71f84d65f21 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/file.md @@ -0,0 +1,121 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 37 +toc_title: "\u6587\u4EF6" +--- + +# 文件 {#file} + +从文件创建表。 此表函数类似于 [url](url.md) 和 [hdfs](hdfs.md) 一些的。 + +``` sql +file(path, format, structure) +``` + +**输入参数** + +- `path` — The relative path to the file from [user\_files\_path](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-user_files_path). 只读模式下的globs后的文件支持路径: `*`, `?`, `{abc,def}` 和 `{N..M}` 哪里 `N`, `M` — numbers, \``'abc', 'def'` — strings. +- `format` — The [格式](../../interfaces/formats.md#formats) 的文件。 +- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. + +**返回值** + +具有指定结构的表,用于读取或写入指定文件中的数据。 + +**示例** + +设置 `user_files_path` 和文件的内容 `test.csv`: + +``` bash +$ grep user_files_path /etc/clickhouse-server/config.xml + /var/lib/clickhouse/user_files/ + +$ cat /var/lib/clickhouse/user_files/test.csv + 1,2,3 + 3,2,1 + 78,43,45 +``` + +表从`test.csv` 并从中选择前两行: + +``` sql +SELECT * +FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +``` sql +-- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file +SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 +``` + +**路径中的水珠** + +多个路径组件可以具有globs。 对于正在处理的文件应该存在并匹配到整个路径模式(不仅后缀或前缀)。 + +- `*` — Substitutes any number of any characters except `/` 包括空字符串。 +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +建筑与 `{}` 类似于 [远程表功能](../../sql-reference/table-functions/remote.md)). + +**示例** + +1. 假设我们有几个具有以下相对路径的文件: + +- ‘some\_dir/some\_file\_1’ +- ‘some\_dir/some\_file\_2’ +- ‘some\_dir/some\_file\_3’ +- ‘another\_dir/some\_file\_1’ +- ‘another\_dir/some\_file\_2’ +- ‘another\_dir/some\_file\_3’ + +1. 查询这些文件中的行数: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. 查询这两个目录的所有文件中的行数: + + + +``` sql +SELECT count(*) +FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "警告" + 如果您的文件列表包含带前导零的数字范围,请单独使用带大括号的构造或使用 `?`. + +**示例** + +从名为 `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## 虚拟列 {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**另请参阅** + +- [虚拟列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/zh/sql-reference/table-functions/generate.md b/docs/zh/sql-reference/table-functions/generate.md new file mode 100644 index 00000000000..1b535161acb --- /dev/null +++ b/docs/zh/sql-reference/table-functions/generate.md @@ -0,0 +1,44 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 47 +toc_title: generateRandom +--- + +# generateRandom {#generaterandom} + +使用给定的模式生成随机数据。 +允许用数据填充测试表。 +支持可以存储在表中的所有数据类型,除了 `LowCardinality` 和 `AggregateFunction`. + +``` sql +generateRandom('name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_string_length'[, 'max_array_length']]]); +``` + +**参数** + +- `name` — Name of corresponding column. +- `TypeName` — Type of corresponding column. +- `max_array_length` — Maximum array length for all generated arrays. Defaults to `10`. +- `max_string_length` — Maximum string length for all generated strings. Defaults to `10`. +- `random_seed` — Specify random seed manually to produce stable results. If NULL — seed is randomly generated. + +**返回值** + +具有请求架构的表对象。 + +## 用法示例 {#usage-example} + +``` sql +SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2) LIMIT 3; +``` + +``` text +┌─a────────┬────────────d─┬─c──────────────────────────────────────────────────────────────────┐ +│ [77] │ -124167.6723 │ ('2061-04-17 21:59:44.573','3f72f405-ec3e-13c8-44ca-66ef335f7835') │ +│ [32,110] │ -141397.7312 │ ('1979-02-09 03:43:48.526','982486d1-5a5d-a308-e525-7bd8b80ffa73') │ +│ [68] │ -67417.0770 │ ('2080-03-12 14:17:31.269','110425e5-413f-10a6-05ba-fa6b3e929f15') │ +└──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘ +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/generate/) diff --git a/docs/zh/sql-reference/table-functions/hdfs.md b/docs/zh/sql-reference/table-functions/hdfs.md new file mode 100644 index 00000000000..4ea4e71f8fc --- /dev/null +++ b/docs/zh/sql-reference/table-functions/hdfs.md @@ -0,0 +1,104 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 45 +toc_title: hdfs +--- + +# hdfs {#hdfs} + +从HDFS中的文件创建表。 此表函数类似于 [url](url.md) 和 [文件](file.md) 一些的。 + +``` sql +hdfs(URI, format, structure) +``` + +**输入参数** + +- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` 和 `{N..M}` 哪里 `N`, `M` — numbers, \``'abc', 'def'` — strings. +- `format` — The [格式](../../interfaces/formats.md#formats) 的文件。 +- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. + +**返回值** + +具有指定结构的表,用于读取或写入指定文件中的数据。 + +**示例** + +表从 `hdfs://hdfs1:9000/test` 并从中选择前两行: + +``` sql +SELECT * +FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') +LIMIT 2 +``` + +``` text +┌─column1─┬─column2─┬─column3─┐ +│ 1 │ 2 │ 3 │ +│ 3 │ 2 │ 1 │ +└─────────┴─────────┴─────────┘ +``` + +**路径中的水珠** + +多个路径组件可以具有globs。 对于正在处理的文件应该存在并匹配到整个路径模式(不仅后缀或前缀)。 + +- `*` — Substitutes any number of any characters except `/` 包括空字符串。 +- `?` — Substitutes any single character. +- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. +- `{N..M}` — Substitutes any number in range from N to M including both borders. + +建筑与 `{}` 类似于 [远程表功能](../../sql-reference/table-functions/remote.md)). + +**示例** + +1. 假设我们在HDFS上有几个具有以下Uri的文件: + +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ +- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ + +1. 查询这些文件中的行数: + + + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') +``` + +1. 查询这两个目录的所有文件中的行数: + + + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') +``` + +!!! warning "警告" + 如果您的文件列表包含带前导零的数字范围,请单独使用带大括号的构造或使用 `?`. + +**示例** + +从名为 `file000`, `file001`, … , `file999`: + +``` sql +SELECT count(*) +FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') +``` + +## 虚拟列 {#virtual-columns} + +- `_path` — Path to the file. +- `_file` — Name of the file. + +**另请参阅** + +- [虚拟列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/zh/sql-reference/table-functions/index.md b/docs/zh/sql-reference/table-functions/index.md new file mode 100644 index 00000000000..1fa985a529a --- /dev/null +++ b/docs/zh/sql-reference/table-functions/index.md @@ -0,0 +1,38 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u8868\u51FD\u6570" +toc_priority: 34 +toc_title: "\u5BFC\u8A00" +--- + +# 表函数 {#table-functions} + +表函数是构造表的方法。 + +您可以使用表函数: + +- [FROM](../statements/select/from.md) 《公约》条款 `SELECT` 查询。 + + The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. + +- [创建表为\](../statements/create.md#create-table-query) 查询。 + + It's one of the methods of creating a table. + +!!! warning "警告" + 你不能使用表函数,如果 [allow\_ddl](../../operations/settings/permissions-for-queries.md#settings_allow_ddl) 设置被禁用。 + +| 功能 | 产品描述 | +|--------------------|--------------------------------------------------------------------------------------------------------| +| [文件](file.md) | 创建一个 [文件](../../engines/table-engines/special/file.md)-发动机表。 | +| [合并](merge.md) | 创建一个 [合并](../../engines/table-engines/special/merge.md)-发动机表。 | +| [数字](numbers.md) | 创建一个包含整数填充的单列的表。 | +| [远程](remote.md) | 允许您访问远程服务器,而无需创建 [分布](../../engines/table-engines/special/distributed.md)-发动机表。 | +| [url](url.md) | 创建一个 [Url](../../engines/table-engines/special/url.md)-发动机表。 | +| [mysql](mysql.md) | 创建一个 [MySQL](../../engines/table-engines/integrations/mysql.md)-发动机表。 | +| [jdbc](jdbc.md) | 创建一个 [JDBC](../../engines/table-engines/integrations/jdbc.md)-发动机表。 | +| [odbc](odbc.md) | 创建一个 [ODBC](../../engines/table-engines/integrations/odbc.md)-发动机表。 | +| [hdfs](hdfs.md) | 创建一个 [HDFS](../../engines/table-engines/integrations/hdfs.md)-发动机表。 | + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/zh/sql-reference/table-functions/input.md b/docs/zh/sql-reference/table-functions/input.md new file mode 100644 index 00000000000..42b354dc935 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/input.md @@ -0,0 +1,47 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 46 +toc_title: "\u8F93\u5165" +--- + +# 输入 {#input} + +`input(structure)` -表功能,允许有效地转换和插入数据发送到 +服务器与给定结构的表与另一种结构。 + +`structure` -以下格式发送到服务器的数据结构 `'column1_name column1_type, column2_name column2_type, ...'`. +例如, `'id UInt32, name String'`. + +此功能只能用于 `INSERT SELECT` 查询,只有一次,但其他行为像普通表函数 +(例如,它可以用于子查询等。). + +数据可以以任何方式像普通发送 `INSERT` 查询并传递任何可用 [格式](../../interfaces/formats.md#formats) +必须在查询结束时指定(不像普通 `INSERT SELECT`). + +这个功能的主要特点是,当服务器从客户端接收数据时,它同时将其转换 +根据表达式中的列表 `SELECT` 子句并插入到目标表中。 临时表 +不创建所有传输的数据。 + +**例** + +- 让 `test` 表具有以下结构 `(a String, b String)` + 和数据 `data.csv` 具有不同的结构 `(col1 String, col2 Date, col3 Int32)`. 查询插入 + 从数据 `data.csv` 进 `test` 同时转换的表如下所示: + + + +``` bash +$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; +``` + +- 如果 `data.csv` 包含相同结构的数据 `test_structure` 作为表 `test` 那么这两个查询是相等的: + + + +``` bash +$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV" +$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV" +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/input/) diff --git a/docs/zh/sql-reference/table-functions/jdbc.md b/docs/zh/sql-reference/table-functions/jdbc.md new file mode 100644 index 00000000000..c1833462171 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/jdbc.md @@ -0,0 +1,29 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 43 +toc_title: jdbc +--- + +# jdbc {#table-function-jdbc} + +`jdbc(jdbc_connection_uri, schema, table)` -返回通过JDBC驱动程序连接的表。 + +此表函数需要单独的 `clickhouse-jdbc-bridge` 程序正在运行。 +它支持可空类型(基于查询的远程表的DDL)。 + +**例** + +``` sql +SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') +``` + +``` sql +SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'schema', 'table') +``` + +``` sql +SELECT * FROM jdbc('datasource://mysql-local', 'schema', 'table') +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/zh/sql-reference/table-functions/merge.md b/docs/zh/sql-reference/table-functions/merge.md new file mode 100644 index 00000000000..0e94dcc4d42 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/merge.md @@ -0,0 +1,14 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 38 +toc_title: "\u5408\u5E76" +--- + +# 合并 {#merge} + +`merge(db_name, 'tables_regexp')` – Creates a temporary Merge table. For more information, see the section “Table engines, Merge”. + +表结构取自与正则表达式匹配的第一个表。 + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/merge/) diff --git a/docs/zh/sql-reference/table-functions/mysql.md b/docs/zh/sql-reference/table-functions/mysql.md new file mode 100644 index 00000000000..c54cd7d2a06 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/mysql.md @@ -0,0 +1,86 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 42 +toc_title: mysql +--- + +# mysql {#mysql} + +允许 `SELECT` 要对存储在远程MySQL服务器上的数据执行的查询。 + +``` sql +mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); +``` + +**参数** + +- `host:port` — MySQL server address. + +- `database` — Remote database name. + +- `table` — Remote table name. + +- `user` — MySQL user. + +- `password` — User password. + +- `replace_query` — Flag that converts `INSERT INTO` 查询到 `REPLACE INTO`. 如果 `replace_query=1`,查询被替换。 + +- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` 表达式被添加到 `INSERT` 查询。 + + Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. + + To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. + +简单 `WHERE` 条款如 `=, !=, >, >=, <, <=` 当前在MySQL服务器上执行。 + +其余的条件和 `LIMIT` 只有在对MySQL的查询完成后,才会在ClickHouse中执行采样约束。 + +**返回值** + +与原始MySQL表具有相同列的table对象。 + +## 用法示例 {#usage-example} + +MySQL中的表: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +从ClickHouse中选择数据: + +``` sql +SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## 另请参阅 {#see-also} + +- [该 ‘MySQL’ 表引擎](../../engines/table-engines/integrations/mysql.md) +- [使用MySQL作为外部字典的来源](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-mysql) + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/zh/sql-reference/table-functions/numbers.md b/docs/zh/sql-reference/table-functions/numbers.md new file mode 100644 index 00000000000..e5f13d60791 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/numbers.md @@ -0,0 +1,30 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 39 +toc_title: "\u6570\u5B57" +--- + +# 数字 {#numbers} + +`numbers(N)` – Returns a table with the single ‘number’ 包含从0到N-1的整数的列(UInt64)。 +`numbers(N, M)` -返回一个表与单 ‘number’ 包含从N到(N+M-1)的整数的列(UInt64)。 + +类似于 `system.numbers` 表,它可以用于测试和生成连续的值, `numbers(N, M)` 比 `system.numbers`. + +以下查询是等效的: + +``` sql +SELECT * FROM numbers(10); +SELECT * FROM numbers(0, 10); +SELECT * FROM system.numbers LIMIT 10; +``` + +例: + +``` sql +-- Generate a sequence of dates from 2010-01-01 to 2010-12-31 +select toDate('2010-01-01') + number as d FROM numbers(365); +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/numbers/) diff --git a/docs/zh/sql-reference/table-functions/odbc.md b/docs/zh/sql-reference/table-functions/odbc.md new file mode 100644 index 00000000000..95fb2277474 --- /dev/null +++ b/docs/zh/sql-reference/table-functions/odbc.md @@ -0,0 +1,108 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 44 +toc_title: odbc +--- + +# odbc {#table-functions-odbc} + +返回通过连接的表 [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). + +``` sql +odbc(connection_settings, external_database, external_table) +``` + +参数: + +- `connection_settings` — Name of the section with connection settings in the `odbc.ini` 文件 +- `external_database` — Name of a database in an external DBMS. +- `external_table` — Name of a table in the `external_database`. + +为了安全地实现ODBC连接,ClickHouse使用单独的程序 `clickhouse-odbc-bridge`. 如果直接从ODBC驱动程序加载 `clickhouse-server`,驱动程序问题可能会导致ClickHouse服务器崩溃。 ClickHouse自动启动 `clickhouse-odbc-bridge` 当它是必需的。 ODBC桥程序是从相同的软件包作为安装 `clickhouse-server`. + +与字段 `NULL` 外部表中的值将转换为基数据类型的默认值。 例如,如果远程MySQL表字段具有 `INT NULL` 键入它将转换为0(ClickHouse的默认值 `Int32` 数据类型)。 + +## 用法示例 {#usage-example} + +**通过ODBC从本地MySQL安装获取数据** + +此示例检查Ubuntu Linux18.04和MySQL服务器5.7。 + +确保安装了unixODBC和MySQL连接器。 + +默认情况下(如果从软件包安装),ClickHouse以用户身份启动 `clickhouse`. 因此,您需要在MySQL服务器中创建和配置此用户。 + +``` bash +$ sudo mysql +``` + +``` sql +mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; +mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; +``` + +然后配置连接 `/etc/odbc.ini`. + +``` bash +$ cat /etc/odbc.ini +[mysqlconn] +DRIVER = /usr/local/lib/libmyodbc5w.so +SERVER = 127.0.0.1 +PORT = 3306 +DATABASE = test +USERNAME = clickhouse +PASSWORD = clickhouse +``` + +您可以使用 `isql` unixodbc安装中的实用程序。 + +``` bash +$ isql -v mysqlconn ++-------------------------+ +| Connected! | +| | +... +``` + +MySQL中的表: + +``` text +mysql> CREATE TABLE `test`.`test` ( + -> `int_id` INT NOT NULL AUTO_INCREMENT, + -> `int_nullable` INT NULL DEFAULT NULL, + -> `float` FLOAT NOT NULL, + -> `float_nullable` FLOAT NULL DEFAULT NULL, + -> PRIMARY KEY (`int_id`)); +Query OK, 0 rows affected (0,09 sec) + +mysql> insert into test (`int_id`, `float`) VALUES (1,2); +Query OK, 1 row affected (0,00 sec) + +mysql> select * from test; ++------+----------+-----+----------+ +| int_id | int_nullable | float | float_nullable | ++------+----------+-----+----------+ +| 1 | NULL | 2 | NULL | ++------+----------+-----+----------+ +1 row in set (0,00 sec) +``` + +从ClickHouse中的MySQL表中检索数据: + +``` sql +SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') +``` + +``` text +┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ +│ 1 │ 0 │ 2 │ 0 │ +└────────┴──────────────┴───────┴────────────────┘ +``` + +## 另请参阅 {#see-also} + +- [ODBC外部字典](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md#dicts-external_dicts_dict_sources-odbc) +- [ODBC表引擎](../../engines/table-engines/integrations/odbc.md). + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/zh/sql-reference/table-functions/remote.md b/docs/zh/sql-reference/table-functions/remote.md new file mode 100644 index 00000000000..1f3bc58111b --- /dev/null +++ b/docs/zh/sql-reference/table-functions/remote.md @@ -0,0 +1,83 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 40 +toc_title: "\u8FDC\u7A0B" +--- + +# 远程,远程安全 {#remote-remotesecure} + +允许您访问远程服务器,而无需创建 `Distributed` 桌子 + +签名: + +``` sql +remote('addresses_expr', db, table[, 'user'[, 'password']]) +remote('addresses_expr', db.table[, 'user'[, 'password']]) +``` + +`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port`,或者只是 `host`. 主机可以指定为服务器名称,也可以指定为IPv4或IPv6地址。 IPv6地址在方括号中指定。 端口是远程服务器上的TCP端口。 如果省略端口,它使用 `tcp_port` 从服务器的配置文件(默认情况下,9000)。 + +!!! important "重要事项" + IPv6地址需要该端口。 + +例: + +``` text +example01-01-1 +example01-01-1:9000 +localhost +127.0.0.1 +[::]:9000 +[2a02:6b8:0:1111::11]:9000 +``` + +多个地址可以用逗号分隔。 在这种情况下,ClickHouse将使用分布式处理,因此它将将查询发送到所有指定的地址(如具有不同数据的分片)。 + +示例: + +``` text +example01-01-1,example01-02-1 +``` + +表达式的一部分可以用大括号指定。 前面的示例可以写成如下: + +``` text +example01-0{1,2}-1 +``` + +大括号可以包含由两个点(非负整数)分隔的数字范围。 在这种情况下,范围将扩展为生成分片地址的一组值。 如果第一个数字以零开头,则使用相同的零对齐形成值。 前面的示例可以写成如下: + +``` text +example01-{01..02}-1 +``` + +如果您有多对大括号,它会生成相应集合的直接乘积。 + +大括号中的地址和部分地址可以用管道符号(\|)分隔。 在这种情况下,相应的地址集被解释为副本,并且查询将被发送到第一个正常副本。 但是,副本将按照当前设置的顺序进行迭代 [load\_balancing](../../operations/settings/settings.md) 设置。 + +示例: + +``` text +example01-{01..02}-{1|2} +``` + +此示例指定两个分片,每个分片都有两个副本。 + +生成的地址数由常量限制。 现在这是1000个地址。 + +使用 `remote` 表函数比创建一个不太优化 `Distributed` 表,因为在这种情况下,服务器连接被重新建立为每个请求。 此外,如果设置了主机名,则会解析这些名称,并且在使用各种副本时不会计算错误。 在处理大量查询时,始终创建 `Distributed` 表的时间提前,不要使用 `remote` 表功能。 + +该 `remote` 表函数可以在以下情况下是有用的: + +- 访问特定服务器进行数据比较、调试和测试。 +- 查询之间的各种ClickHouse群集用于研究目的。 +- 手动发出的罕见分布式请求。 +- 每次重新定义服务器集的分布式请求。 + +如果未指定用户, `default` 被使用。 +如果未指定密码,则使用空密码。 + +`remoteSecure` -相同 `remote` but with secured connection. Default port — [tcp\_port\_secure](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-tcp_port_secure) 从配置或9440. + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/zh/sql-reference/table-functions/url.md b/docs/zh/sql-reference/table-functions/url.md new file mode 100644 index 00000000000..c2efe09913a --- /dev/null +++ b/docs/zh/sql-reference/table-functions/url.md @@ -0,0 +1,26 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 41 +toc_title: url +--- + +# url {#url} + +`url(URL, format, structure)` -返回从创建的表 `URL` 与给定 +`format` 和 `structure`. + +URL-HTTP或HTTPS服务器地址,它可以接受 `GET` 和/或 `POST` 请求。 + +格式 - [格式](../../interfaces/formats.md#formats) 的数据。 + +结构-表结构 `'UserID UInt64, Name String'` 格式。 确定列名称和类型。 + +**示例** + +``` sql +-- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format. +SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3 +``` + +[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/url/) diff --git a/docs/zh/sql_reference/aggregate_functions/combinators.md b/docs/zh/sql_reference/aggregate_functions/combinators.md deleted file mode 100644 index a8be457ab23..00000000000 --- a/docs/zh/sql_reference/aggregate_functions/combinators.md +++ /dev/null @@ -1,166 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 37 -toc_title: "\u805A\u5408\u51FD\u6570\u7EC4\u5408\u5668" ---- - -# 聚合函数组合器 {#aggregate_functions_combinators} - -聚合函数的名称可以附加一个后缀。 这改变了聚合函数的工作方式。 - -## -如果 {#agg-functions-combinator-if} - -The suffix -If can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition (Uint8 type). The aggregate function processes only the rows that trigger the condition. If the condition was not triggered even once, it returns a default value (usually zeros or empty strings). - -例: `sumIf(column, cond)`, `countIf(cond)`, `avgIf(x, cond)`, `quantilesTimingIf(level1, level2)(x, cond)`, `argMinIf(arg, val, cond)` 等等。 - -使用条件聚合函数,您可以一次计算多个条件的聚合,而无需使用子查询和 `JOIN`例如,在Yandex的。Metrica,条件聚合函数用于实现段比较功能。 - -## -阵列 {#agg-functions-combinator-array} - --Array后缀可以附加到任何聚合函数。 在这种情况下,聚合函数采用的参数 ‘Array(T)’ 类型(数组)而不是 ‘T’ 类型参数。 如果聚合函数接受多个参数,则它必须是长度相等的数组。 在处理数组时,聚合函数的工作方式与所有数组元素的原始聚合函数类似。 - -示例1: `sumArray(arr)` -总计所有的所有元素 ‘arr’ 阵列。 在这个例子中,它可以更简单地编写: `sum(arraySum(arr))`. - -示例2: `uniqArray(arr)` – Counts the number of unique elements in all ‘arr’ 阵列。 这可以做一个更简单的方法: `uniq(arrayJoin(arr))`,但它并不总是可以添加 ‘arrayJoin’ 到查询。 - --如果和-阵列可以组合。 然而, ‘Array’ 必须先来,然后 ‘If’. 例: `uniqArrayIf(arr, cond)`, `quantilesTimingArrayIf(level1, level2)(arr, cond)`. 由于这个顺序,该 ‘cond’ 参数不会是数组。 - -## -州 {#agg-functions-combinator-state} - -如果应用此combinator,则聚合函数不会返回结果值(例如唯一值的数量 [uniq](reference.md#agg_function-uniq) 函数),但聚合的中间状态(用于 `uniq`,这是用于计算唯一值的数量的散列表)。 这是一个 `AggregateFunction(...)` 可用于进一步处理或存储在表中以完成聚合。 - -要使用这些状态,请使用: - -- [AggregatingMergeTree](../../engines/table_engines/mergetree_family/aggregatingmergetree.md) 表引擎。 -- [最后聚会](../../sql_reference/functions/other_functions.md#function-finalizeaggregation) 功能。 -- [跑累积](../../sql_reference/functions/other_functions.md#function-runningaccumulate) 功能。 -- [-合并](#aggregate_functions_combinators_merge) combinator -- [-MergeState](#aggregate_functions_combinators_mergestate) combinator - -## -合并 {#aggregate_functions_combinators-merge} - -如果应用此组合器,则聚合函数将中间聚合状态作为参数,组合状态以完成聚合,并返回结果值。 - -## -MergeState {#aggregate_functions_combinators-mergestate} - -以与-Merge combinator相同的方式合并中间聚合状态。 但是,它不会返回结果值,而是返回中间聚合状态,类似于-State combinator。 - -## -ForEach {#agg-functions-combinator-foreach} - -将表的聚合函数转换为聚合相应数组项并返回结果数组的数组的聚合函数。 例如, `sumForEach` 对于数组 `[1, 2]`, `[3, 4, 5]`和`[6, 7]`返回结果 `[10, 13, 5]` 之后将相应的数组项添加在一起。 - -## -OrDefault {#agg-functions-combinator-ordefault} - -如果没有要聚合的内容,则填充聚合函数的返回类型的默认值。 - -``` sql -SELECT avg(number), avgOrDefault(number) FROM numbers(0) -``` - -``` text -┌─avg(number)─┬─avgOrDefault(number)─┐ -│ nan │ 0 │ -└─────────────┴──────────────────────┘ -``` - -## -OrNull {#agg-functions-combinator-ornull} - -填充 `null` 如果没有什么聚合。 返回列将为空。 - -``` sql -SELECT avg(number), avgOrNull(number) FROM numbers(0) -``` - -``` text -┌─avg(number)─┬─avgOrNull(number)─┐ -│ nan │ ᴺᵁᴸᴸ │ -└─────────────┴───────────────────┘ -``` - --OrDefault和-OrNull可以与其他组合器相结合。 当聚合函数不接受空输入时,它很有用。 - -``` sql -SELECT avgOrNullIf(x, x > 10) -FROM -( - SELECT toDecimal32(1.23, 2) AS x -) -``` - -``` text -┌─avgOrNullIf(x, greater(x, 10))─┐ -│ ᴺᵁᴸᴸ │ -└────────────────────────────────┘ -``` - -## -重新采样 {#agg-functions-combinator-resample} - -允许您将数据划分为组,然后单独聚合这些组中的数据。 通过将一列中的值拆分为间隔来创建组。 - -``` sql -Resample(start, end, step)(, resampling_key) -``` - -**参数** - -- `start` — Starting value of the whole required interval for `resampling_key` 值。 -- `stop` — Ending value of the whole required interval for `resampling_key` 值。 整个时间间隔不包括 `stop` 价值 `[start, stop)`. -- `step` — Step for separating the whole interval into subintervals. The `aggFunction` 在每个子区间上独立执行。 -- `resampling_key` — Column whose values are used for separating data into intervals. -- `aggFunction_params` — `aggFunction` 参数。 - -**返回值** - -- 阵列 `aggFunction` 每个子区间的结果。 - -**示例** - -考虑一下 `people` 具有以下数据的表: - -``` text -┌─name───┬─age─┬─wage─┐ -│ John │ 16 │ 10 │ -│ Alice │ 30 │ 15 │ -│ Mary │ 35 │ 8 │ -│ Evelyn │ 48 │ 11.5 │ -│ David │ 62 │ 9.9 │ -│ Brian │ 60 │ 16 │ -└────────┴─────┴──────┘ -``` - -让我们得到的人的名字,他们的年龄在于的时间间隔 `[30,60)` 和 `[60,75)`. 由于我们使用整数表示的年龄,我们得到的年龄 `[30, 59]` 和 `[60,74]` 间隔。 - -要在数组中聚合名称,我们使用 [groupArray](reference.md#agg_function-grouparray) 聚合函数。 这需要一个参数。 在我们的例子中,它是 `name` 列。 该 `groupArrayResample` 函数应该使用 `age` 按年龄聚合名称的列。 要定义所需的时间间隔,我们通过 `30, 75, 30` 参数到 `groupArrayResample` 功能。 - -``` sql -SELECT groupArrayResample(30, 75, 30)(name, age) FROM people -``` - -``` text -┌─groupArrayResample(30, 75, 30)(name, age)─────┐ -│ [['Alice','Mary','Evelyn'],['David','Brian']] │ -└───────────────────────────────────────────────┘ -``` - -考虑结果。 - -`Jonh` 是因为他太年轻了 其他人按照指定的年龄间隔进行分配。 - -现在让我们计算指定年龄间隔内的总人数和平均工资。 - -``` sql -SELECT - countResample(30, 75, 30)(name, age) AS amount, - avgResample(30, 75, 30)(wage, age) AS avg_wage -FROM people -``` - -``` text -┌─amount─┬─avg_wage──────────────────┐ -│ [3,2] │ [11.5,12.949999809265137] │ -└────────┴───────────────────────────┘ -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/agg_functions/combinators/) diff --git a/docs/zh/sql_reference/aggregate_functions/index.md b/docs/zh/sql_reference/aggregate_functions/index.md deleted file mode 100644 index 7e53c8c8c53..00000000000 --- a/docs/zh/sql_reference/aggregate_functions/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u805A\u5408\u51FD\u6570" -toc_priority: 33 -toc_title: "\u5BFC\u8A00" ---- - -# 聚合函数 {#aggregate-functions} - -聚合函数在 [正常](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) 方式如预期的数据库专家。 - -ClickHouse还支持: - -- [参数聚合函数](parametric_functions.md#aggregate_functions_parametric),它接受除列之外的其他参数。 -- [组合器](combinators.md#aggregate_functions_combinators),这改变了聚合函数的行为。 - -## 空处理 {#null-processing} - -在聚合过程中,所有 `NULL`s被跳过。 - -**例:** - -考虑这个表: - -``` text -┌─x─┬────y─┐ -│ 1 │ 2 │ -│ 2 │ ᴺᵁᴸᴸ │ -│ 3 │ 2 │ -│ 3 │ 3 │ -│ 3 │ ᴺᵁᴸᴸ │ -└───┴──────┘ -``` - -比方说,你需要在总的值 `y` 列: - -``` sql -SELECT sum(y) FROM t_null_big -``` - - ┌─sum(y)─┐ - │ 7 │ - └────────┘ - -该 `sum` 函数解释 `NULL` 作为 `0`. 特别是,这意味着,如果函数接收输入的选择,其中所有的值 `NULL`,那么结果将是 `0`,不 `NULL`. - -现在你可以使用 `groupArray` 函数从创建一个数组 `y` 列: - -``` sql -SELECT groupArray(y) FROM t_null_big -``` - -``` text -┌─groupArray(y)─┐ -│ [2,2,3] │ -└───────────────┘ -``` - -`groupArray` 不包括 `NULL` 在生成的数组中。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/agg_functions/) diff --git a/docs/zh/sql_reference/aggregate_functions/parametric_functions.md b/docs/zh/sql_reference/aggregate_functions/parametric_functions.md deleted file mode 100644 index 18adcd93487..00000000000 --- a/docs/zh/sql_reference/aggregate_functions/parametric_functions.md +++ /dev/null @@ -1,499 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 38 -toc_title: "\u53C2\u6570\u805A\u5408\u51FD\u6570" ---- - -# 参数聚合函数 {#aggregate_functions_parametric} - -Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments. - -## 直方图 {#histogram} - -计算自适应直方图。 它不能保证精确的结果。 - -``` sql -histogram(number_of_bins)(values) -``` - -该函数使用 [流式并行决策树算法](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf). 当新数据输入函数时,hist图分区的边界将被调整。 在通常情况下,箱的宽度不相等。 - -**参数** - -`number_of_bins` — Upper limit for the number of bins in the histogram. The function automatically calculates the number of bins. It tries to reach the specified number of bins, but if it fails, it uses fewer bins. -`values` — [表达式](../syntax.md#syntax-expressions) 导致输入值。 - -**返回值** - -- [阵列](../../sql_reference/data_types/array.md) 的 [元组](../../sql_reference/data_types/tuple.md) 下面的格式: - - ``` - [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] - ``` - - - `lower` — Lower bound of the bin. - - `upper` — Upper bound of the bin. - - `height` — Calculated height of the bin. - -**示例** - -``` sql -SELECT histogram(5)(number + 1) -FROM ( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─histogram(5)(plus(number, 1))───────────────────────────────────────────┐ -│ [(1,4.5,4),(4.5,8.5,4),(8.5,12.75,4.125),(12.75,17,4.625),(17,20,3.25)] │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -您可以使用 [酒吧](../../sql_reference/functions/other_functions.md#function-bar) 功能,例如: - -``` sql -WITH histogram(5)(rand() % 100) AS hist -SELECT - arrayJoin(hist).3 AS height, - bar(height, 0, 6, 5) AS bar -FROM -( - SELECT * - FROM system.numbers - LIMIT 20 -) -``` - -``` text -┌─height─┬─bar───┐ -│ 2.125 │ █▋ │ -│ 3.25 │ ██▌ │ -│ 5.625 │ ████▏ │ -│ 5.625 │ ████▏ │ -│ 3.375 │ ██▌ │ -└────────┴───────┘ -``` - -在这种情况下,您应该记住您不知道直方图bin边界。 - -## sequenceMatch(pattern)(timestamp, cond1, cond2, …) {#function-sequencematch} - -检查序列是否包含与模式匹配的事件链。 - -``` sql -sequenceMatch(pattern)(timestamp, cond1, cond2, ...) -``` - -!!! warning "警告" - 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,影响结果。 - -**参数** - -- `pattern` — Pattern string. See [模式语法](#sequence-function-pattern-syntax). - -- `timestamp` — Column considered to contain time data. Typical data types are `Date` 和 `DateTime`. 您还可以使用任何支持的 [UInt](../../sql_reference/data_types/int_uint.md) 数据类型。 - -- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 - -**返回值** - -- 1,如果模式匹配。 -- 0,如果模式不匹配。 - -类型: `UInt8`. - - -**模式语法** - -- `(?N)` — Matches the condition argument at position `N`. 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 - -- `.*` — Matches any number of events. You don't need conditional arguments to match this element of the pattern. - -- `(?t operator value)` — Sets the time in seconds that should separate two events. For example, pattern `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=` 运营商。 - -**例** - -考虑在数据 `t` 表: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -└──────┴────────┘ -``` - -执行查询: - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 1 │ -└───────────────────────────────────────────────────────────────────────┘ -``` - -该函数找到了数字2跟随数字1的事件链。 它跳过了它们之间的数字3,因为该数字没有被描述为事件。 如果我们想在搜索示例中给出的事件链时考虑这个数字,我们应该为它创建一个条件。 - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 3))─┐ -│ 0 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -在这种情况下,函数找不到与模式匹配的事件链,因为数字3的事件发生在1和2之间。 如果在相同的情况下,我们检查了数字4的条件,则序列将与模式匹配。 - -``` sql -SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t -``` - -``` text -┌─sequenceMatch('(?1)(?2)')(time, equals(number, 1), equals(number, 2), equals(number, 4))─┐ -│ 1 │ -└──────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -**另请参阅** - -- [sequenceCount](#function-sequencecount) - -## sequenceCount(pattern)(time, cond1, cond2, …) {#function-sequencecount} - -计数与模式匹配的事件链的数量。 该函数搜索不重叠的事件链。 当前链匹配后,它开始搜索下一个链。 - -!!! warning "警告" - 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,影响结果。 - -``` sql -sequenceCount(pattern)(timestamp, cond1, cond2, ...) -``` - -**参数** - -- `pattern` — Pattern string. See [模式语法](#sequence-function-pattern-syntax). - -- `timestamp` — Column considered to contain time data. Typical data types are `Date` 和 `DateTime`. 您还可以使用任何支持的 [UInt](../../sql_reference/data_types/int_uint.md) 数据类型。 - -- `cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 - -**返回值** - -- 匹配的非重叠事件链数。 - -类型: `UInt64`. - -**示例** - -考虑在数据 `t` 表: - -``` text -┌─time─┬─number─┐ -│ 1 │ 1 │ -│ 2 │ 3 │ -│ 3 │ 2 │ -│ 4 │ 1 │ -│ 5 │ 3 │ -│ 6 │ 2 │ -└──────┴────────┘ -``` - -计算数字2在数字1之后出现的次数以及它们之间的任何其他数字: - -``` sql -SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t -``` - -``` text -┌─sequenceCount('(?1).*(?2)')(time, equals(number, 1), equals(number, 2))─┐ -│ 2 │ -└─────────────────────────────────────────────────────────────────────────┘ -``` - -**另请参阅** - -- [sequenceMatch](#function-sequencematch) - -## windowFunnel {#windowfunnel} - -搜索滑动时间窗中的事件链,并计算从链中发生的最大事件数。 - -该函数根据算法工作: - -- 该函数搜索触发链中的第一个条件并将事件计数器设置为1的数据。 这是滑动窗口启动的时刻。 - -- 如果来自链的事件在窗口内顺序发生,则计数器将递增。 如果事件序列中断,则计数器不会增加。 - -- 如果数据在不同的完成点具有多个事件链,则该函数将仅输出最长链的大小。 - -**语法** - -``` sql -windowFunnel(window, [mode])(timestamp, cond1, cond2, ..., condN) -``` - -**参数** - -- `window` — Length of the sliding window in seconds. -- `mode` -这是一个可选的参数。 - - `'strict'` -当 `'strict'` 设置时,windowFunnel()仅对唯一值应用条件。 -- `timestamp` — Name of the column containing the timestamp. Data types supported: [日期](../../sql_reference/data_types/date.md), [日期时间](../../sql_reference/data_types/datetime.md#data_type-datetime) 和其他无符号整数类型(请注意,即使时间戳支持 `UInt64` 类型,它的值不能超过Int64最大值,即2^63-1)。 -- `cond` — Conditions or data describing the chain of events. [UInt8](../../sql_reference/data_types/int_uint.md). - -**返回值** - -滑动时间窗口内连续触发条件链的最大数目。 -对选择中的所有链进行了分析。 - -类型: `Integer`. - -**示例** - -确定设定的时间段是否足以让用户选择手机并在在线商店中购买两次。 - -设置以下事件链: - -1. 用户登录到其在应用商店中的帐户 (`eventID = 1003`). -2. 用户搜索手机 (`eventID = 1007, product = 'phone'`). -3. 用户下了订单 (`eventID = 1009`). -4. 用户再次下订单 (`eventID = 1010`). - -输入表: - -``` text -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-28 │ 1 │ 2019-01-29 10:00:00 │ 1003 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-31 │ 1 │ 2019-01-31 09:00:00 │ 1007 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-01-30 │ 1 │ 2019-01-30 08:00:00 │ 1009 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -┌─event_date─┬─user_id─┬───────────timestamp─┬─eventID─┬─product─┐ -│ 2019-02-01 │ 1 │ 2019-02-01 08:00:00 │ 1010 │ phone │ -└────────────┴─────────┴─────────────────────┴─────────┴─────────┘ -``` - -了解用户有多远 `user_id` 可以在2019的1-2月期间通过链条。 - -查询: - -``` sql -SELECT - level, - count() AS c -FROM -( - SELECT - user_id, - windowFunnel(6048000000000000)(timestamp, eventID = 1003, eventID = 1009, eventID = 1007, eventID = 1010) AS level - FROM trend - WHERE (event_date >= '2019-01-01') AND (event_date <= '2019-02-02') - GROUP BY user_id -) -GROUP BY level -ORDER BY level ASC -``` - -结果: - -``` text -┌─level─┬─c─┐ -│ 4 │ 1 │ -└───────┴───┘ -``` - -## 保留 {#retention} - -该函数将一组条件作为参数,类型为1到32个参数 `UInt8` 表示事件是否满足特定条件。 -任何条件都可以指定为参数(如 [WHERE](../../sql_reference/statements/select.md#select-where)). - -除了第一个以外,条件成对适用:如果第一个和第二个是真的,第二个结果将是真的,如果第一个和fird是真的,第三个结果将是真的,等等。 - -**语法** - -``` sql -retention(cond1, cond2, ..., cond32); -``` - -**参数** - -- `cond` — an expression that returns a `UInt8` 结果(1或0)。 - -**返回值** - -数组为1或0。 - -- 1 — condition was met for the event. -- 0 — condition wasn't met for the event. - -类型: `UInt8`. - -**示例** - -让我们考虑计算的一个例子 `retention` 功能,以确定网站流量。 - -**1.** Сreate a table to illustrate an example. - -``` sql -CREATE TABLE retention_test(date Date, uid Int32) ENGINE = Memory; - -INSERT INTO retention_test SELECT '2020-01-01', number FROM numbers(5); -INSERT INTO retention_test SELECT '2020-01-02', number FROM numbers(10); -INSERT INTO retention_test SELECT '2020-01-03', number FROM numbers(15); -``` - -输入表: - -查询: - -``` sql -SELECT * FROM retention_test -``` - -结果: - -``` text -┌───────date─┬─uid─┐ -│ 2020-01-01 │ 0 │ -│ 2020-01-01 │ 1 │ -│ 2020-01-01 │ 2 │ -│ 2020-01-01 │ 3 │ -│ 2020-01-01 │ 4 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-02 │ 0 │ -│ 2020-01-02 │ 1 │ -│ 2020-01-02 │ 2 │ -│ 2020-01-02 │ 3 │ -│ 2020-01-02 │ 4 │ -│ 2020-01-02 │ 5 │ -│ 2020-01-02 │ 6 │ -│ 2020-01-02 │ 7 │ -│ 2020-01-02 │ 8 │ -│ 2020-01-02 │ 9 │ -└────────────┴─────┘ -┌───────date─┬─uid─┐ -│ 2020-01-03 │ 0 │ -│ 2020-01-03 │ 1 │ -│ 2020-01-03 │ 2 │ -│ 2020-01-03 │ 3 │ -│ 2020-01-03 │ 4 │ -│ 2020-01-03 │ 5 │ -│ 2020-01-03 │ 6 │ -│ 2020-01-03 │ 7 │ -│ 2020-01-03 │ 8 │ -│ 2020-01-03 │ 9 │ -│ 2020-01-03 │ 10 │ -│ 2020-01-03 │ 11 │ -│ 2020-01-03 │ 12 │ -│ 2020-01-03 │ 13 │ -│ 2020-01-03 │ 14 │ -└────────────┴─────┘ -``` - -**2.** 按唯一ID对用户进行分组 `uid` 使用 `retention` 功能。 - -查询: - -``` sql -SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r -FROM retention_test -WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') -GROUP BY uid -ORDER BY uid ASC -``` - -结果: - -``` text -┌─uid─┬─r───────┐ -│ 0 │ [1,1,1] │ -│ 1 │ [1,1,1] │ -│ 2 │ [1,1,1] │ -│ 3 │ [1,1,1] │ -│ 4 │ [1,1,1] │ -│ 5 │ [0,0,0] │ -│ 6 │ [0,0,0] │ -│ 7 │ [0,0,0] │ -│ 8 │ [0,0,0] │ -│ 9 │ [0,0,0] │ -│ 10 │ [0,0,0] │ -│ 11 │ [0,0,0] │ -│ 12 │ [0,0,0] │ -│ 13 │ [0,0,0] │ -│ 14 │ [0,0,0] │ -└─────┴─────────┘ -``` - -**3.** 计算每天的现场访问总数。 - -查询: - -``` sql -SELECT - sum(r[1]) AS r1, - sum(r[2]) AS r2, - sum(r[3]) AS r3 -FROM -( - SELECT - uid, - retention(date = '2020-01-01', date = '2020-01-02', date = '2020-01-03') AS r - FROM retention_test - WHERE date IN ('2020-01-01', '2020-01-02', '2020-01-03') - GROUP BY uid -) -``` - -结果: - -``` text -┌─r1─┬─r2─┬─r3─┐ -│ 5 │ 5 │ 5 │ -└────┴────┴────┘ -``` - -哪里: - -- `r1`-2020-01-01期间访问该网站的独立访问者数量( `cond1` 条件)。 -- `r2`-在2020-01-01和2020-01-02之间的特定时间段内访问该网站的唯一访问者的数量 (`cond1` 和 `cond2` 条件)。 -- `r3`-在2020-01-01和2020-01-03之间的特定时间段内访问该网站的唯一访问者的数量 (`cond1` 和 `cond3` 条件)。 - -## uniqUpTo(N)(x) {#uniquptonx} - -Calculates the number of different argument values ​​if it is less than or equal to N. If the number of different argument values is greater than N, it returns N + 1. - -建议使用小Ns,高达10。 N的最大值为100。 - -对于聚合函数的状态,它使用的内存量等于1+N\*一个字节值的大小。 -对于字符串,它存储8个字节的非加密哈希。 也就是说,计算是近似的字符串。 - -该函数也适用于多个参数。 - -它的工作速度尽可能快,除了使用较大的N值并且唯一值的数量略小于N的情况。 - -用法示例: - -``` text -Problem: Generate a report that shows only keywords that produced at least 5 unique users. -Solution: Write in the GROUP BY query SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/agg_functions/parametric_functions/) - -## sumMapFiltered(keys\_to\_keep)(键值) {#summapfilteredkeys-to-keepkeys-values} - -同样的行为 [sumMap](reference.md#agg_functions-summap) 除了一个键数组作为参数传递。 这在使用高基数密钥时尤其有用。 diff --git a/docs/zh/sql_reference/aggregate_functions/reference.md b/docs/zh/sql_reference/aggregate_functions/reference.md deleted file mode 100644 index b8071860d41..00000000000 --- a/docs/zh/sql_reference/aggregate_functions/reference.md +++ /dev/null @@ -1,1878 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 36 -toc_title: "\u53C2\u8003\u8D44\u6599" ---- - -# 函数参考 {#function-reference} - -## 计数 {#agg_function-count} - -计数行数或非空值。 - -ClickHouse支持以下语法 `count`: -- `count(expr)` 或 `COUNT(DISTINCT expr)`. -- `count()` 或 `COUNT(*)`. 该 `count()` 语法是ClickHouse特定的。 - -**参数** - -该功能可以采取: - -- 零参数。 -- 一 [表达式](../syntax.md#syntax-expressions). - -**返回值** - -- 如果没有参数调用函数,它会计算行数。 -- 如果 [表达式](../syntax.md#syntax-expressions) 被传递,则该函数计数此表达式返回的次数非null。 如果表达式返回 [可为空](../../sql_reference/data_types/nullable.md)-键入值,然后结果 `count` 保持不 `Nullable`. 如果返回表达式,则该函数返回0 `NULL` 对于所有的行。 - -在这两种情况下,返回值的类型为 [UInt64](../../sql_reference/data_types/int_uint.md). - -**详细信息** - -ClickHouse支持 `COUNT(DISTINCT ...)` 语法 这种结构的行为取决于 [count\_distinct\_implementation](../../operations/settings/settings.md#settings-count_distinct_implementation) 设置。 它定义了其中的 [uniq\*](#agg_function-uniq) 函数用于执行操作。 默认值为 [uniqExact](#agg_function-uniqexact) 功能。 - -该 `SELECT count() FROM table` 查询未被优化,因为表中的条目数没有单独存储。 它从表中选择一个小列并计算其中的值数。 - -**例** - -示例1: - -``` sql -SELECT count() FROM t -``` - -``` text -┌─count()─┐ -│ 5 │ -└─────────┘ -``` - -示例2: - -``` sql -SELECT name, value FROM system.settings WHERE name = 'count_distinct_implementation' -``` - -``` text -┌─name──────────────────────────┬─value─────┐ -│ count_distinct_implementation │ uniqExact │ -└───────────────────────────────┴───────────┘ -``` - -``` sql -SELECT count(DISTINCT num) FROM t -``` - -``` text -┌─uniqExact(num)─┐ -│ 3 │ -└────────────────┘ -``` - -这个例子表明 `count(DISTINCT num)` 由执行 `uniqExact` 根据功能 `count_distinct_implementation` 设定值。 - -## 任何(x) {#agg_function-any} - -选择第一个遇到的值。 -查询可以以任何顺序执行,甚至每次都以不同的顺序执行,因此此函数的结果是不确定的。 -要获得确定的结果,您可以使用 ‘min’ 或 ‘max’ 功能,而不是 ‘any’. - -在某些情况下,可以依靠执行的顺序。 这适用于SELECT来自使用ORDER BY的子查询的情况。 - -当一个 `SELECT` 查询具有 `GROUP BY` 子句或至少一个聚合函数,ClickHouse(相对于MySQL)要求在所有表达式 `SELECT`, `HAVING`,和 `ORDER BY` 子句可以从键或聚合函数计算。 换句话说,从表中选择的每个列必须在键或聚合函数内使用。 要获得像MySQL这样的行为,您可以将其他列放在 `any` 聚合函数。 - -## anyHeavy(x) {#anyheavyx} - -使用选择一个频繁出现的值 [重打者](http://www.cs.umd.edu/~samir/498/karp.pdf) 算法。 如果某个值在查询的每个执行线程中出现的情况超过一半,则返回此值。 通常情况下,结果是不确定的。 - -``` sql -anyHeavy(column) -``` - -**参数** - -- `column` – The column name. - -**示例** - -就拿 [时间](../../getting_started/example_datasets/ontime.md) 数据集,并选择在任何频繁出现的值 `AirlineID` 列。 - -``` sql -SELECT anyHeavy(AirlineID) AS res -FROM ontime -``` - -``` text -┌───res─┐ -│ 19690 │ -└───────┘ -``` - -## anyLast(x) {#anylastx} - -选择遇到的最后一个值。 -其结果是一样不确定的 `any` 功能。 - -## 集团比特 {#groupbitand} - -按位应用 `AND` 对于一系列的数字。 - -``` sql -groupBitAnd(expr) -``` - -**参数** - -`expr` – An expression that results in `UInt*` 类型。 - -**返回值** - -的价值 `UInt*` 类型。 - -**示例** - -测试数据: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -查询: - -``` sql -SELECT groupBitAnd(num) FROM t -``` - -哪里 `num` 是包含测试数据的列。 - -结果: - -``` text -binary decimal -00000100 = 4 -``` - -## groupBitOr {#groupbitor} - -按位应用 `OR` 对于一系列的数字。 - -``` sql -groupBitOr(expr) -``` - -**参数** - -`expr` – An expression that results in `UInt*` 类型。 - -**返回值** - -的价值 `UInt*` 类型。 - -**示例** - -测试数据: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -查询: - -``` sql -SELECT groupBitOr(num) FROM t -``` - -哪里 `num` 是包含测试数据的列。 - -结果: - -``` text -binary decimal -01111101 = 125 -``` - -## groupBitXor {#groupbitxor} - -按位应用 `XOR` 对于一系列的数字。 - -``` sql -groupBitXor(expr) -``` - -**参数** - -`expr` – An expression that results in `UInt*` 类型。 - -**返回值** - -的价值 `UInt*` 类型。 - -**示例** - -测试数据: - -``` text -binary decimal -00101100 = 44 -00011100 = 28 -00001101 = 13 -01010101 = 85 -``` - -查询: - -``` sql -SELECT groupBitXor(num) FROM t -``` - -哪里 `num` 是包含测试数据的列。 - -结果: - -``` text -binary decimal -01101000 = 104 -``` - -## groupBitmap {#groupbitmap} - -从无符号整数列的位图或聚合计算,返回UInt64类型的基数,如果添加后缀状态,则返回 [位图对象](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmap(expr) -``` - -**参数** - -`expr` – An expression that results in `UInt*` 类型。 - -**返回值** - -的价值 `UInt64` 类型。 - -**示例** - -测试数据: - -``` text -UserID -1 -1 -2 -3 -``` - -查询: - -``` sql -SELECT groupBitmap(UserID) as num FROM t -``` - -结果: - -``` text -num -3 -``` - -## min(x) {#agg_function-min} - -计算最小值。 - -## max(x) {#agg_function-max} - -计算最大值。 - -## argMin(arg,val) {#agg-function-argmin} - -计算 ‘arg’ 最小值的值 ‘val’ 价值。 如果有几个不同的值 ‘arg’ 对于最小值 ‘val’,遇到的第一个值是输出。 - -**示例:** - -``` text -┌─user─────┬─salary─┐ -│ director │ 5000 │ -│ manager │ 3000 │ -│ worker │ 1000 │ -└──────────┴────────┘ -``` - -``` sql -SELECT argMin(user, salary) FROM salary -``` - -``` text -┌─argMin(user, salary)─┐ -│ worker │ -└──────────────────────┘ -``` - -## argMax(arg,val) {#agg-function-argmax} - -计算 ‘arg’ 最大值 ‘val’ 价值。 如果有几个不同的值 ‘arg’ 对于最大值 ‘val’,遇到的第一个值是输出。 - -## sum(x) {#agg_function-sum} - -计算总和。 -只适用于数字。 - -## sumWithOverflow(x) {#sumwithoverflowx} - -使用与输入参数相同的数据类型计算数字的总和。 如果总和超过此数据类型的最大值,则函数返回错误。 - -只适用于数字。 - -## sumMap(key,value) {#agg_functions-summap} - -总计 ‘value’ 数组根据在指定的键 ‘key’ 阵列。 -元素的数量 ‘key’ 和 ‘value’ 总计的每一行必须相同。 -Returns a tuple of two arrays: keys in sorted order, and values ​​summed for the corresponding keys. - -示例: - -``` sql -CREATE TABLE sum_map( - date Date, - timeslot DateTime, - statusMap Nested( - status UInt16, - requests UInt64 - ) -) ENGINE = Log; -INSERT INTO sum_map VALUES - ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10]), - ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10]); -SELECT - timeslot, - sumMap(statusMap.status, statusMap.requests) -FROM sum_map -GROUP BY timeslot -``` - -``` text -┌────────────timeslot─┬─sumMap(statusMap.status, statusMap.requests)─┐ -│ 2000-01-01 00:00:00 │ ([1,2,3,4,5],[10,10,20,10,10]) │ -│ 2000-01-01 00:01:00 │ ([4,5,6,7,8],[10,10,20,10,10]) │ -└─────────────────────┴──────────────────────────────────────────────┘ -``` - -## skewPop {#skewpop} - -计算 [歪斜](https://en.wikipedia.org/wiki/Skewness) 的序列。 - -``` sql -skewPop(expr) -``` - -**参数** - -`expr` — [表达式](../syntax.md#syntax-expressions) 返回一个数字。 - -**返回值** - -The skewness of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md) - -**示例** - -``` sql -SELECT skewPop(value) FROM series_with_value_column -``` - -## skewSamp {#skewsamp} - -计算 [样品偏度](https://en.wikipedia.org/wiki/Skewness) 的序列。 - -它表示随机变量的偏度的无偏估计,如果传递的值形成其样本。 - -``` sql -skewSamp(expr) -``` - -**参数** - -`expr` — [表达式](../syntax.md#syntax-expressions) 返回一个数字。 - -**返回值** - -The skewness of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md). 如果 `n <= 1` (`n` 是样本的大小),则该函数返回 `nan`. - -**示例** - -``` sql -SELECT skewSamp(value) FROM series_with_value_column -``` - -## kurtPop {#kurtpop} - -计算 [峰度](https://en.wikipedia.org/wiki/Kurtosis) 的序列。 - -``` sql -kurtPop(expr) -``` - -**参数** - -`expr` — [表达式](../syntax.md#syntax-expressions) 返回一个数字。 - -**返回值** - -The kurtosis of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md) - -**示例** - -``` sql -SELECT kurtPop(value) FROM series_with_value_column -``` - -## kurtSamp {#kurtsamp} - -计算 [峰度样本](https://en.wikipedia.org/wiki/Kurtosis) 的序列。 - -它表示随机变量峰度的无偏估计,如果传递的值形成其样本。 - -``` sql -kurtSamp(expr) -``` - -**参数** - -`expr` — [表达式](../syntax.md#syntax-expressions) 返回一个数字。 - -**返回值** - -The kurtosis of the given distribution. Type — [Float64](../../sql_reference/data_types/float.md). 如果 `n <= 1` (`n` 是样本的大小),则该函数返回 `nan`. - -**示例** - -``` sql -SELECT kurtSamp(value) FROM series_with_value_column -``` - -## timeSeriesGroupSum(uid,timestamp,value) {#agg-function-timeseriesgroupsum} - -`timeSeriesGroupSum` 可以聚合不同的时间序列,即采样时间戳不对齐。 -它将在两个采样时间戳之间使用线性插值,然后将时间序列和在一起。 - -- `uid` 是时间序列唯一id, `UInt64`. -- `timestamp` 是Int64型,以支持毫秒或微秒。 -- `value` 是指标。 - -函数返回元组数组 `(timestamp, aggregated_value)` 对。 - -在使用此功能之前,请确保 `timestamp` 按升序排列 - -示例: - -``` text -┌─uid─┬─timestamp─┬─value─┐ -│ 1 │ 2 │ 0.2 │ -│ 1 │ 7 │ 0.7 │ -│ 1 │ 12 │ 1.2 │ -│ 1 │ 17 │ 1.7 │ -│ 1 │ 25 │ 2.5 │ -│ 2 │ 3 │ 0.6 │ -│ 2 │ 8 │ 1.6 │ -│ 2 │ 12 │ 2.4 │ -│ 2 │ 18 │ 3.6 │ -│ 2 │ 24 │ 4.8 │ -└─────┴───────────┴───────┘ -``` - -``` sql -CREATE TABLE time_series( - uid UInt64, - timestamp Int64, - value Float64 -) ENGINE = Memory; -INSERT INTO time_series VALUES - (1,2,0.2),(1,7,0.7),(1,12,1.2),(1,17,1.7),(1,25,2.5), - (2,3,0.6),(2,8,1.6),(2,12,2.4),(2,18,3.6),(2,24,4.8); - -SELECT timeSeriesGroupSum(uid, timestamp, value) -FROM ( - SELECT * FROM time_series order by timestamp ASC -); -``` - -其结果将是: - -``` text -[(2,0.2),(3,0.9),(7,2.1),(8,2.4),(12,3.6),(17,5.1),(18,5.4),(24,7.2),(25,2.5)] -``` - -## timeSeriesGroupRateSum(uid,ts,val) {#agg-function-timeseriesgroupratesum} - -同样,timeSeriesGroupRateSum,timeSeriesGroupRateSum将计算时间序列的速率,然后将速率总和在一起。 -此外,使用此函数之前,时间戳应该是上升顺序。 - -使用此函数,上述情况下的结果将是: - -``` text -[(2,0),(3,0.1),(7,0.3),(8,0.3),(12,0.3),(17,0.3),(18,0.3),(24,0.3),(25,0.1)] -``` - -## avg(x) {#agg_function-avg} - -计算平均值。 -只适用于数字。 -结果总是Float64。 - -## 平均加权 {#avgweighted} - -计算 [加权算术平均值](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean). - -**语法** - -``` sql -avgWeighted(x, weight) -``` - -**参数** - -- `x` — Values. [整数](../data_types/int_uint.md) 或 [浮点](../data_types/float.md). -- `weight` — Weights of the values. [整数](../data_types/int_uint.md) 或 [浮点](../data_types/float.md). - -类型 `x` 和 `weight` 一定是一样的 - -**返回值** - -- 加权平均值。 -- `NaN`. 如果所有的权重都等于0。 - -类型: [Float64](../data_types/float.md). - -**示例** - -查询: - -``` sql -SELECT avgWeighted(x, w) -FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) -``` - -结果: - -``` text -┌─avgWeighted(x, weight)─┐ -│ 8 │ -└────────────────────────┘ -``` - -## uniq {#agg_function-uniq} - -计算参数的不同值的近似数量。 - -``` sql -uniq(x[, ...]) -``` - -**参数** - -该函数采用可变数量的参数。 参数可以是 `Tuple`, `Array`, `Date`, `DateTime`, `String`,或数字类型。 - -**返回值** - -- A [UInt64](../../sql_reference/data_types/int_uint.md)-键入号码。 - -**实施细节** - -功能: - -- 计算聚合中所有参数的哈希值,然后在计算中使用它。 - -- 使用自适应采样算法。 对于计算状态,该函数使用最多65536个元素哈希值的样本。 - - This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using `uniq` is almost as fast as using other aggregate functions. - -- 确定性地提供结果(它不依赖于查询处理顺序)。 - -我们建议在几乎所有情况下使用此功能。 - -**另请参阅** - -- [uniqCombined](#agg_function-uniqcombined) -- [uniqCombined64](#agg_function-uniqcombined64) -- [uniqHLL12](#agg_function-uniqhll12) -- [uniqExact](#agg_function-uniqexact) - -## uniqCombined {#agg_function-uniqcombined} - -计算不同参数值的近似数量。 - -``` sql -uniqCombined(HLL_precision)(x[, ...]) -``` - -该 `uniqCombined` 函数是计算不同数值数量的不错选择。 - -**参数** - -该函数采用可变数量的参数。 参数可以是 `Tuple`, `Array`, `Date`, `DateTime`, `String`,或数字类型。 - -`HLL_precision` 是以2为底的单元格数的对数 [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog). 可选,您可以将该函数用作 `uniqCombined(x[, ...])`. 默认值 `HLL_precision` 是17,这是有效的96KiB的空间(2^17个单元,每个6比特)。 - -**返回值** - -- 一个数字 [UInt64](../../sql_reference/data_types/int_uint.md)-键入号码。 - -**实施细节** - -功能: - -- 计算散列(64位散列 `String` 否则32位)对于聚合中的所有参数,然后在计算中使用它。 - -- 使用三种算法的组合:数组、哈希表和HyperLogLog与error错表。 - - For a small number of distinct elements, an array is used. When the set size is larger, a hash table is used. For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory. - -- 确定性地提供结果(它不依赖于查询处理顺序)。 - -!!! note "注" - 因为它使用32位散列非-`String` 类型,结果将有非常高的误差基数显着大于 `UINT_MAX` (错误将在几百亿不同值之后迅速提高),因此在这种情况下,您应该使用 [uniqCombined64](#agg_function-uniqcombined64) - -相比于 [uniq](#agg_function-uniq) 功能,该 `uniqCombined`: - -- 消耗少几倍的内存。 -- 计算精度高出几倍。 -- 通常具有略低的性能。 在某些情况下, `uniqCombined` 可以表现得比 `uniq`,例如,使用通过网络传输大量聚合状态的分布式查询。 - -**另请参阅** - -- [uniq](#agg_function-uniq) -- [uniqCombined64](#agg_function-uniqcombined64) -- [uniqHLL12](#agg_function-uniqhll12) -- [uniqExact](#agg_function-uniqexact) - -## uniqCombined64 {#agg_function-uniqcombined64} - -和 [uniqCombined](#agg_function-uniqcombined),但对所有数据类型使用64位哈希。 - -## uniqHLL12 {#agg_function-uniqhll12} - -计算不同参数值的近似数量,使用 [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 算法。 - -``` sql -uniqHLL12(x[, ...]) -``` - -**参数** - -该函数采用可变数量的参数。 参数可以是 `Tuple`, `Array`, `Date`, `DateTime`, `String`,或数字类型。 - -**返回值** - -- A [UInt64](../../sql_reference/data_types/int_uint.md)-键入号码。 - -**实施细节** - -功能: - -- 计算聚合中所有参数的哈希值,然后在计算中使用它。 - -- 使用HyperLogLog算法来近似不同参数值的数量。 - - 212 5-bit cells are used. The size of the state is slightly more than 2.5 KB. The result is not very accurate (up to ~10% error) for small data sets (<10K elements). However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of ~1.6%. Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements). - -- 提供确定结果(它不依赖于查询处理顺序)。 - -我们不建议使用此功能。 在大多数情况下,使用 [uniq](#agg_function-uniq) 或 [uniqCombined](#agg_function-uniqcombined) 功能。 - -**另请参阅** - -- [uniq](#agg_function-uniq) -- [uniqCombined](#agg_function-uniqcombined) -- [uniqExact](#agg_function-uniqexact) - -## uniqExact {#agg_function-uniqexact} - -计算不同参数值的准确数目。 - -``` sql -uniqExact(x[, ...]) -``` - -使用 `uniqExact` 功能,如果你绝对需要一个确切的结果。 否则使用 [uniq](#agg_function-uniq) 功能。 - -该 `uniqExact` 功能使用更多的内存比 `uniq`,因为状态的大小随着不同值的数量的增加而无界增长。 - -**参数** - -该函数采用可变数量的参数。 参数可以是 `Tuple`, `Array`, `Date`, `DateTime`, `String`,或数字类型。 - -**另请参阅** - -- [uniq](#agg_function-uniq) -- [uniqCombined](#agg_function-uniqcombined) -- [uniqHLL12](#agg_function-uniqhll12) - -## 群交(x),群交(max\_size)(x) {#agg_function-grouparray} - -创建参数值的数组。 -值可以按任何(不确定)顺序添加到数组中。 - -第二个版本(与 `max_size` 参数)将结果数组的大小限制为 `max_size` 元素。 -例如, `groupArray (1) (x)` 相当于 `[any (x)]`. - -在某些情况下,您仍然可以依靠执行的顺序。 这适用于以下情况 `SELECT` 来自使用 `ORDER BY`. - -## groupArrayInsertAt(值,位置) {#grouparrayinsertatvalue-position} - -将值插入到数组中的指定位置中。 - -!!! note "注" - 此函数使用从零开始的位置,与传统SQL数组的从一开始的位置相反。 - -Accepts the value and position as input. If several values ​​are inserted into the same position, any of them might end up in the resulting array (the first one will be used in the case of single-threaded execution). If no value is inserted into a position, the position is assigned the default value. - -可选参数: - -- 在空位置替换的默认值。 -- 生成数组的长度。 这允许您接收所有聚合键的相同大小的数组。 使用此参数时,必须指定默认值。 - -## groupArrayMovingSum {#agg_function-grouparraymovingsum} - -计算输入值的移动和。 - -``` sql -groupArrayMovingSum(numbers_for_summing) -groupArrayMovingSum(window_size)(numbers_for_summing) -``` - -该函数可以将窗口大小作为参数。 如果未指定,则该函数的窗口大小等于列中的行数。 - -**参数** - -- `numbers_for_summing` — [表达式](../syntax.md#syntax-expressions) 生成数值数据类型值。 -- `window_size` — Size of the calculation window. - -**返回值** - -- 与输入数据大小和类型相同的数组。 - -**示例** - -样品表: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -查询: - -``` sql -SELECT - groupArrayMovingSum(int) AS I, - groupArrayMovingSum(float) AS F, - groupArrayMovingSum(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,7,14] │ [1.1,3.3000002,7.7000003,15.47] │ [1.10,3.30,7.70,15.47] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingSum(2)(int) AS I, - groupArrayMovingSum(2)(float) AS F, - groupArrayMovingSum(2)(dec) AS D -FROM t -``` - -``` text -┌─I──────────┬─F───────────────────────────────┬─D──────────────────────┐ -│ [1,3,6,11] │ [1.1,3.3000002,6.6000004,12.17] │ [1.10,3.30,6.60,12.17] │ -└────────────┴─────────────────────────────────┴────────────────────────┘ -``` - -## groupArrayMovingAvg {#agg_function-grouparraymovingavg} - -计算输入值的移动平均值。 - -``` sql -groupArrayMovingAvg(numbers_for_summing) -groupArrayMovingAvg(window_size)(numbers_for_summing) -``` - -该函数可以将窗口大小作为参数。 如果未指定,则该函数的窗口大小等于列中的行数。 - -**参数** - -- `numbers_for_summing` — [表达式](../syntax.md#syntax-expressions) 生成数值数据类型值。 -- `window_size` — Size of the calculation window. - -**返回值** - -- 与输入数据大小和类型相同的数组。 - -该函数使用 [四舍五入到零](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero). 它截断结果数据类型的小数位数。 - -**示例** - -样品表 `b`: - -``` sql -CREATE TABLE t -( - `int` UInt8, - `float` Float32, - `dec` Decimal32(2) -) -ENGINE = TinyLog -``` - -``` text -┌─int─┬─float─┬──dec─┐ -│ 1 │ 1.1 │ 1.10 │ -│ 2 │ 2.2 │ 2.20 │ -│ 4 │ 4.4 │ 4.40 │ -│ 7 │ 7.77 │ 7.77 │ -└─────┴───────┴──────┘ -``` - -查询: - -``` sql -SELECT - groupArrayMovingAvg(int) AS I, - groupArrayMovingAvg(float) AS F, - groupArrayMovingAvg(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F───────────────────────────────────┬─D─────────────────────┐ -│ [0,0,1,3] │ [0.275,0.82500005,1.9250001,3.8675] │ [0.27,0.82,1.92,3.86] │ -└───────────┴─────────────────────────────────────┴───────────────────────┘ -``` - -``` sql -SELECT - groupArrayMovingAvg(2)(int) AS I, - groupArrayMovingAvg(2)(float) AS F, - groupArrayMovingAvg(2)(dec) AS D -FROM t -``` - -``` text -┌─I─────────┬─F────────────────────────────────┬─D─────────────────────┐ -│ [0,1,3,5] │ [0.55,1.6500001,3.3000002,6.085] │ [0.55,1.65,3.30,6.08] │ -└───────────┴──────────────────────────────────┴───────────────────────┘ -``` - -## 禄,赂麓ta脌麓,):脡,,拢脢,group媒group)galaxy s8碌胫脢)禄煤)酶脱脩) {#groupuniqarrayx-groupuniqarraymax-sizex} - -从不同的参数值创建一个数组。 内存消耗是一样的 `uniqExact` 功能。 - -第二个版本(与 `max_size` 参数)将结果数组的大小限制为 `max_size` 元素。 -例如, `groupUniqArray(1)(x)` 相当于 `[any(x)]`. - -## 分位数 {#quantile} - -计算近似值 [分位数](https://en.wikipedia.org/wiki/Quantile) 的数字数据序列。 - -此功能适用 [油藏采样](https://en.wikipedia.org/wiki/Reservoir_sampling) 随着储存器大小高达8192和随机数发生器进行采样。 结果是非确定性的。 要获得精确的分位数,请使用 [quantileExact](#quantileexact) 功能。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantile(level)(expr) -``` - -别名: `median`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [数据类型](../../sql_reference/data_types/index.md#data_types), [日期](../../sql_reference/data_types/date.md) 或 [日期时间](../../sql_reference/data_types/datetime.md). - -**返回值** - -- 指定电平的近似分位数。 - -类型: - -- [Float64](../../sql_reference/data_types/float.md) 对于数字数据类型输入。 -- [日期](../../sql_reference/data_types/date.md) 如果输入值具有 `Date` 类型。 -- [日期时间](../../sql_reference/data_types/datetime.md) 如果输入值具有 `DateTime` 类型。 - -**示例** - -输入表: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -查询: - -``` sql -SELECT quantile(val) FROM t -``` - -结果: - -``` text -┌─quantile(val)─┐ -│ 1.5 │ -└───────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## 量化确定 {#quantiledeterministic} - -计算近似值 [分位数](https://en.wikipedia.org/wiki/Quantile) 的数字数据序列。 - -此功能适用 [油藏采样](https://en.wikipedia.org/wiki/Reservoir_sampling) 与储层大小高达8192和采样的确定性算法。 结果是确定性的。 要获得精确的分位数,请使用 [quantileExact](#quantileexact) 功能。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileDeterministic(level)(expr, determinator) -``` - -别名: `medianDeterministic`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [数据类型](../../sql_reference/data_types/index.md#data_types), [日期](../../sql_reference/data_types/date.md) 或 [日期时间](../../sql_reference/data_types/datetime.md). -- `determinator` — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. As a determinator you can use any deterministic positive number, for example, a user id or an event id. If the same determinator value occures too often, the function works incorrectly. - -**返回值** - -- 指定电平的近似分位数。 - -类型: - -- [Float64](../../sql_reference/data_types/float.md) 对于数字数据类型输入。 -- [日期](../../sql_reference/data_types/date.md) 如果输入值具有 `Date` 类型。 -- [日期时间](../../sql_reference/data_types/datetime.md) 如果输入值具有 `DateTime` 类型。 - -**示例** - -输入表: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -查询: - -``` sql -SELECT quantileDeterministic(val, 1) FROM t -``` - -结果: - -``` text -┌─quantileDeterministic(val, 1)─┐ -│ 1.5 │ -└───────────────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## quantileExact {#quantileexact} - -正是计算 [分位数](https://en.wikipedia.org/wiki/Quantile) 的数字数据序列。 - -To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Therefore, the function consumes `O(n)` 内存,其中 `n` 是传递的多个值。 然而,对于少量的值,该函数是非常有效的。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileExact(level)(expr) -``` - -别名: `medianExact`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [数据类型](../../sql_reference/data_types/index.md#data_types), [日期](../../sql_reference/data_types/date.md) 或 [日期时间](../../sql_reference/data_types/datetime.md). - -**返回值** - -- 指定电平的分位数。 - -类型: - -- [Float64](../../sql_reference/data_types/float.md) 对于数字数据类型输入。 -- [日期](../../sql_reference/data_types/date.md) 如果输入值具有 `Date` 类型。 -- [日期时间](../../sql_reference/data_types/datetime.md) 如果输入值具有 `DateTime` 类型。 - -**示例** - -查询: - -``` sql -SELECT quantileExact(number) FROM numbers(10) -``` - -结果: - -``` text -┌─quantileExact(number)─┐ -│ 5 │ -└───────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## 分位数加权 {#quantileexactweighted} - -正是计算 [分位数](https://en.wikipedia.org/wiki/Quantile) 数值数据序列,考虑到每个元素的权重。 - -To get exact value, all the passed values ​​are combined into an array, which is then partially sorted. Each value is counted with its weight, as if it is present `weight` times. A hash table is used in the algorithm. Because of this, if the passed values ​​are frequently repeated, the function consumes less RAM than [quantileExact](#quantileexact). 您可以使用此功能,而不是 `quantileExact` 并指定重量1。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileExactWeighted(level)(expr, weight) -``` - -别名: `medianExactWeighted`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [数据类型](../../sql_reference/data_types/index.md#data_types), [日期](../../sql_reference/data_types/date.md) 或 [日期时间](../../sql_reference/data_types/datetime.md). -- `weight` — Column with weights of sequence members. Weight is a number of value occurrences. - -**返回值** - -- 指定电平的分位数。 - -类型: - -- [Float64](../../sql_reference/data_types/float.md) 对于数字数据类型输入。 -- [日期](../../sql_reference/data_types/date.md) 如果输入值具有 `Date` 类型。 -- [日期时间](../../sql_reference/data_types/datetime.md) 如果输入值具有 `DateTime` 类型。 - -**示例** - -输入表: - -``` text -┌─n─┬─val─┐ -│ 0 │ 3 │ -│ 1 │ 2 │ -│ 2 │ 1 │ -│ 5 │ 4 │ -└───┴─────┘ -``` - -查询: - -``` sql -SELECT quantileExactWeighted(n, val) FROM t -``` - -结果: - -``` text -┌─quantileExactWeighted(n, val)─┐ -│ 1 │ -└───────────────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## 分位定时 {#quantiletiming} - -随着确定的精度计算 [分位数](https://en.wikipedia.org/wiki/Quantile) 的数字数据序列。 - -结果是确定性的(它不依赖于查询处理顺序)。 该函数针对描述加载网页时间或后端响应时间等分布的序列进行了优化。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileTiming(level)(expr) -``` - -别名: `medianTiming`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). - -- `expr` — [表达式](../syntax.md#syntax-expressions) 在一个列值返回 [浮动\*](../../sql_reference/data_types/float.md)-键入号码。 - - - If negative values are passed to the function, the behavior is undefined. - - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. - -**精度** - -计算是准确的,如果: - -- 值的总数不超过5670。 -- 总数值超过5670,但页面加载时间小于1024ms。 - -否则,计算结果将四舍五入到16毫秒的最接近倍数。 - -!!! note "注" - 对于计算页面加载时间分位数,此函数比 [分位数](#quantile). - -**返回值** - -- 指定电平的分位数。 - -类型: `Float32`. - -!!! note "注" - 如果没有值传递给函数(当使用 `quantileTimingIf`), [阿南](../../sql_reference/data_types/float.md#data_type-float-nan-inf) 被返回。 这样做的目的是将这些案例与导致零的案例区分开来。 看 [按条款订购](../statements/select.md#select-order-by) 对于排序注意事项 `NaN` 值。 - -**示例** - -输入表: - -``` text -┌─response_time─┐ -│ 72 │ -│ 112 │ -│ 126 │ -│ 145 │ -│ 104 │ -│ 242 │ -│ 313 │ -│ 168 │ -│ 108 │ -└───────────────┘ -``` - -查询: - -``` sql -SELECT quantileTiming(response_time) FROM t -``` - -结果: - -``` text -┌─quantileTiming(response_time)─┐ -│ 126 │ -└───────────────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## 分位时间加权 {#quantiletimingweighted} - -随着确定的精度计算 [分位数](https://en.wikipedia.org/wiki/Quantile) 根据每个序列成员的权重对数字数据序列进行处理。 - -结果是确定性的(它不依赖于查询处理顺序)。 该函数针对描述加载网页时间或后端响应时间等分布的序列进行了优化。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileTimingWeighted(level)(expr, weight) -``` - -别名: `medianTimingWeighted`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). - -- `expr` — [表达式](../syntax.md#syntax-expressions) 在一个列值返回 [浮动\*](../../sql_reference/data_types/float.md)-键入号码。 - - - If negative values are passed to the function, the behavior is undefined. - - If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. - -- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. - -**精度** - -计算是准确的,如果: - -- 值的总数不超过5670。 -- 总数值超过5670,但页面加载时间小于1024ms。 - -否则,计算结果将四舍五入到16毫秒的最接近倍数。 - -!!! note "注" - 对于计算页面加载时间分位数,此函数比 [分位数](#quantile). - -**返回值** - -- 指定电平的分位数。 - -类型: `Float32`. - -!!! note "注" - 如果没有值传递给函数(当使用 `quantileTimingIf`), [阿南](../../sql_reference/data_types/float.md#data_type-float-nan-inf) 被返回。 这样做的目的是将这些案例与导致零的案例区分开来。 看 [按条款订购](../statements/select.md#select-order-by) 对于排序注意事项 `NaN` 值。 - -**示例** - -输入表: - -``` text -┌─response_time─┬─weight─┐ -│ 68 │ 1 │ -│ 104 │ 2 │ -│ 112 │ 3 │ -│ 126 │ 2 │ -│ 138 │ 1 │ -│ 162 │ 1 │ -└───────────────┴────────┘ -``` - -查询: - -``` sql -SELECT quantileTimingWeighted(response_time, weight) FROM t -``` - -结果: - -``` text -┌─quantileTimingWeighted(response_time, weight)─┐ -│ 112 │ -└───────────────────────────────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## quantileTDigest {#quantiletdigest} - -计算近似值 [分位数](https://en.wikipedia.org/wiki/Quantile) 使用的数字数据序列 [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) 算法。 - -最大误差为1%。 内存消耗 `log(n)`,哪里 `n` 是多个值。 结果取决于运行查询的顺序,并且是不确定的。 - -该功能的性能低于性能 [分位数](#quantile) 或 [分位定时](#quantiletiming). 在状态大小与精度的比率方面,这个函数比 `quantile`. - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileTDigest(level)(expr) -``` - -别名: `medianTDigest`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [数据类型](../../sql_reference/data_types/index.md#data_types), [日期](../../sql_reference/data_types/date.md) 或 [日期时间](../../sql_reference/data_types/datetime.md). - -**返回值** - -- 指定电平的近似分位数。 - -类型: - -- [Float64](../../sql_reference/data_types/float.md) 对于数字数据类型输入。 -- [日期](../../sql_reference/data_types/date.md) 如果输入值具有 `Date` 类型。 -- [日期时间](../../sql_reference/data_types/datetime.md) 如果输入值具有 `DateTime` 类型。 - -**示例** - -查询: - -``` sql -SELECT quantileTDigest(number) FROM numbers(10) -``` - -结果: - -``` text -┌─quantileTDigest(number)─┐ -│ 4.5 │ -└─────────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## quantileTDigestWeighted {#quantiletdigestweighted} - -计算近似值 [分位数](https://en.wikipedia.org/wiki/Quantile) 使用的数字数据序列 [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) 算法。 该函数考虑了每个序列成员的权重。 最大误差为1%。 内存消耗 `log(n)`,哪里 `n` 是多个值。 - -该功能的性能低于性能 [分位数](#quantile) 或 [分位定时](#quantiletiming). 在状态大小与精度的比率方面,这个函数比 `quantile`. - -结果取决于运行查询的顺序,并且是不确定的。 - -当使用多个 `quantile*` 在查询中具有不同级别的函数,内部状态不会被组合(即查询的工作效率低于它可以)。 在这种情况下,使用 [分位数](#quantiles) 功能。 - -**语法** - -``` sql -quantileTDigest(level)(expr) -``` - -别名: `medianTDigest`. - -**参数** - -- `level` — Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a `level` 值的范围 `[0.01, 0.99]`. 默认值:0.5。 在 `level=0.5` 该函数计算 [中位数](https://en.wikipedia.org/wiki/Median). -- `expr` — Expression over the column values resulting in numeric [数据类型](../../sql_reference/data_types/index.md#data_types), [日期](../../sql_reference/data_types/date.md) 或 [日期时间](../../sql_reference/data_types/datetime.md). -- `weight` — Column with weights of sequence elements. Weight is a number of value occurrences. - -**返回值** - -- 指定电平的近似分位数。 - -类型: - -- [Float64](../../sql_reference/data_types/float.md) 对于数字数据类型输入。 -- [日期](../../sql_reference/data_types/date.md) 如果输入值具有 `Date` 类型。 -- [日期时间](../../sql_reference/data_types/datetime.md) 如果输入值具有 `DateTime` 类型。 - -**示例** - -查询: - -``` sql -SELECT quantileTDigestWeighted(number, 1) FROM numbers(10) -``` - -结果: - -``` text -┌─quantileTDigestWeighted(number, 1)─┐ -│ 4.5 │ -└────────────────────────────────────┘ -``` - -**另请参阅** - -- [中位数](#median) -- [分位数](#quantiles) - -## 中位数 {#median} - -该 `median*` 函数是相应的别名 `quantile*` 功能。 它们计算数字数据样本的中位数。 - -功能: - -- `median` — Alias for [分位数](#quantile). -- `medianDeterministic` — Alias for [量化确定](#quantiledeterministic). -- `medianExact` — Alias for [quantileExact](#quantileexact). -- `medianExactWeighted` — Alias for [分位数加权](#quantileexactweighted). -- `medianTiming` — Alias for [分位定时](#quantiletiming). -- `medianTimingWeighted` — Alias for [分位时间加权](#quantiletimingweighted). -- `medianTDigest` — Alias for [quantileTDigest](#quantiletdigest). -- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](#quantiletdigestweighted). - -**示例** - -输入表: - -``` text -┌─val─┐ -│ 1 │ -│ 1 │ -│ 2 │ -│ 3 │ -└─────┘ -``` - -查询: - -``` sql -SELECT medianDeterministic(val, 1) FROM t -``` - -结果: - -``` text -┌─medianDeterministic(val, 1)─┐ -│ 1.5 │ -└─────────────────────────────┘ -``` - -## quantiles(level1, level2, …)(x) {#quantiles} - -所有分位数函数也具有相应的分位数函数: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantilesTDigest`. 这些函数在一遍中计算所列电平的所有分位数,并返回结果值的数组。 - -## varSamp(x) {#varsampx} - -计算金额 `Σ((x - x̅)^2) / (n - 1)`,哪里 `n` 是样本大小和 `x̅`是平均值 `x`. - -它表示随机变量的方差的无偏估计,如果传递的值形成其样本。 - -返回 `Float64`. 当 `n <= 1`,返回 `+∞`. - -## varPop(x) {#varpopx} - -计算金额 `Σ((x - x̅)^2) / n`,哪里 `n` 是样本大小和 `x̅`是平均值 `x`. - -换句话说,分散为一组值。 返回 `Float64`. - -## stddevSamp(x) {#stddevsampx} - -结果等于平方根 `varSamp(x)`. - -## stddevPop(x) {#stddevpopx} - -结果等于平方根 `varPop(x)`. - -## topK(N)(x) {#topknx} - -返回指定列中近似最常见值的数组。 生成的数组按值的近似频率降序排序(而不是值本身)。 - -实现了 [过滤节省空间](http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf) 基于reduce-and-combine算法的TopK分析算法 [并行节省空间](https://arxiv.org/pdf/1401.0702.pdf). - -``` sql -topK(N)(column) -``` - -此函数不提供保证的结果。 在某些情况下,可能会发生错误,并且可能会返回不是最常见值的常见值。 - -我们建议使用 `N < 10` 值;性能降低了大 `N` 值。 的最大值 `N = 65536`. - -**参数** - -- ‘N’ 是要返回的元素数。 - -如果省略该参数,则使用默认值10。 - -**参数** - -- ' x ' – The value to calculate frequency. - -**示例** - -就拿 [时间](../../getting_started/example_datasets/ontime.md) 数据集,并选择在三个最频繁出现的值 `AirlineID` 列。 - -``` sql -SELECT topK(3)(AirlineID) AS res -FROM ontime -``` - -``` text -┌─res─────────────────┐ -│ [19393,19790,19805] │ -└─────────────────────┘ -``` - -## topKWeighted {#topkweighted} - -类似于 `topK` 但需要一个整数类型的附加参数 - `weight`. 每一价值是占 `weight` 次频率计算。 - -**语法** - -``` sql -topKWeighted(N)(x, weight) -``` - -**参数** - -- `N` — The number of elements to return. - -**参数** - -- `x` – The value. -- `weight` — The weight. [UInt8](../../sql_reference/data_types/int_uint.md). - -**返回值** - -返回具有最大近似权重总和的值数组。 - -**示例** - -查询: - -``` sql -SELECT topKWeighted(10)(number, number) FROM numbers(1000) -``` - -结果: - -``` text -┌─topKWeighted(10)(number, number)──────────┐ -│ [999,998,997,996,995,994,993,992,991,990] │ -└───────────────────────────────────────────┘ -``` - -## covarSamp(x,y) {#covarsampx-y} - -计算的值 `Σ((x - x̅)(y - y̅)) / (n - 1)`. - -返回Float64。 当 `n <= 1`, returns +∞. - -## covarPop(x,y) {#covarpopx-y} - -计算的值 `Σ((x - x̅)(y - y̅)) / n`. - -## corr(x,y) {#corrx-y} - -计算Pearson相关系数: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`. - -## categoricalInformationValue {#categoricalinformationvalue} - -计算的值 `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` 对于每个类别。 - -``` sql -categoricalInformationValue(category1, category2, ..., tag) -``` - -结果指示离散(分类)要素如何使用 `[category1, category2, ...]` 有助于预测的价值的学习模型 `tag`. - -## simpleLinearRegression {#simplelinearregression} - -执行简单(一维)线性回归。 - -``` sql -simpleLinearRegression(x, y) -``` - -参数: - -- `x` — Column with dependent variable values. -- `y` — Column with explanatory variable values. - -返回值: - -常量 `(a, b)` 结果行的 `y = a*x + b`. - -**例** - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐ -│ (1,0) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -``` sql -SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]) -``` - -``` text -┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐ -│ (1,3) │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## 随机指标线上回归 {#agg_functions-stochasticlinearregression} - -该函数实现随机线性回归。 它支持自定义参数的学习率,L2正则化系数,迷你批量大小,并具有更新权重的方法很少 ([亚当](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam) (默认使用), [简单SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [动量](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum), [Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf)). - -### 参数 {#agg_functions-stochasticlinearregression-parameters} - -有4个可自定义的参数。 它们按顺序传递给函数,但是没有必要传递所有四个默认值将被使用,但是好的模型需要一些参数调整。 - -``` text -stochasticLinearRegression(1.0, 1.0, 10, 'SGD') -``` - -1. `learning rate` 当执行梯度下降步骤时,步长上的系数。 过大的学习率可能会导致模型的权重无限大。 默认值为 `0.00001`. -2. `l2 regularization coefficient` 这可能有助于防止过度拟合。 默认值为 `0.1`. -3. `mini-batch size` 设置元素的数量,这些元素将被计算和求和以执行梯度下降的一个步骤。 纯随机下降使用一个元素,但是具有小批量(约10个元素)使梯度步骤更稳定。 默认值为 `15`. -4. `method for updating weights` 他们是: `Adam` (默认情况下), `SGD`, `Momentum`, `Nesterov`. `Momentum` 和 `Nesterov` 需要更多的计算和内存,但是它们恰好在收敛速度和随机梯度方法的稳定性方面是有用的。 - -### 用途 {#agg_functions-stochasticlinearregression-usage} - -`stochasticLinearRegression` 用于两个步骤:拟合模型和预测新数据。 为了拟合模型并保存其状态以供以后使用,我们使用 `-State` combinator,它基本上保存了状态(模型权重等)。 -为了预测我们使用函数 [evalMLMethod](../functions/machine_learning_functions.md#machine_learning_methods-evalmlmethod),这需要一个状态作为参数以及特征来预测。 - - - -**1.** 适合 - -可以使用这种查询。 - -``` sql -CREATE TABLE IF NOT EXISTS train_data -( - param1 Float64, - param2 Float64, - target Float64 -) ENGINE = Memory; - -CREATE TABLE your_model ENGINE = Memory AS SELECT -stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) -AS state FROM train_data; -``` - -在这里,我们还需要将数据插入到 `train_data` 桌子 参数的数量不是固定的,它只取决于参数的数量,传递到 `linearRegressionState`. 它们都必须是数值。 -请注意,带有目标值的列(我们想要学习预测)被插入作为第一个参数。 - -**2.** 预测 - -在将状态保存到表中之后,我们可以多次使用它进行预测,甚至与其他状态合并并创建新的更好的模型。 - -``` sql -WITH (SELECT state FROM your_model) AS model SELECT -evalMLMethod(model, param1, param2) FROM test_data -``` - -查询将返回一列预测值。 请注意,第一个参数 `evalMLMethod` 是 `AggregateFunctionState` 对象,接下来是要素列。 - -`test_data` 是一个像表 `train_data` 但可能不包含目标值。 - -### 注 {#agg_functions-stochasticlinearregression-notes} - -1. 要合并两个模型,用户可以创建这样的查询: - `sql SELECT state1 + state2 FROM your_models` - 哪里 `your_models` 表包含这两个模型。 此查询将返回new `AggregateFunctionState` 对象。 - -2. 如果没有,用户可以获取创建的模型的权重用于自己的目的,而不保存模型 `-State` 使用combinator。 - `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` - 这种查询将拟合模型并返回其权重-首先是权重,它对应于模型的参数,最后一个是偏差。 所以在上面的例子中,查询将返回一个具有3个值的列。 - -**另请参阅** - -- [stochasticLogisticRegression](#agg_functions-stochasticlogisticregression) -- [线性回归和逻辑回归之间的区别](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## stochasticLogisticRegression {#agg_functions-stochasticlogisticregression} - -该函数实现随机逻辑回归。 它可以用于二进制分类问题,支持与stochasticLinearRegression相同的自定义参数,并以相同的方式工作。 - -### 参数 {#agg_functions-stochasticlogisticregression-parameters} - -参数与stochasticLinearRegression中的参数完全相同: -`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`. -欲了解更多信息,请参阅 [参数](#agg_functions-stochasticlinearregression-parameters). - -``` text -stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') -``` - -1. 适合 - - - - See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description. - - Predicted labels have to be in \[-1, 1\]. - -1. 预测 - - - - Using saved state we can predict probability of object having label `1`. - - ``` sql - WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) FROM test_data - ``` - - The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features. - - We can also set a bound of probability, which assigns elements to different labels. - - ``` sql - SELECT ans < 1.1 AND ans > 0.5 FROM - (WITH (SELECT state FROM your_model) AS model SELECT - evalMLMethod(model, param1, param2) AS ans FROM test_data) - ``` - - Then the result will be labels. - - `test_data` is a table like `train_data` but may not contain target value. - -**另请参阅** - -- [随机指标线上回归](#agg_functions-stochasticlinearregression) -- [线性回归和逻辑回归之间的差异。](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression) - -## groupBitmapAnd {#groupbitmapand} - -计算位图列的AND,返回UInt64类型的基数,如果添加后缀状态,则返回 [位图对象](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmapAnd(expr) -``` - -**参数** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` 类型。 - -**返回值** - -的价值 `UInt64` 类型。 - -**示例** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapAnd(z)─┐ -│ 3 │ -└───────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐ -│ [6,8,10] │ -└──────────────────────────────────────────────────┘ -``` - -## groupBitmapOr {#groupbitmapor} - -计算位图列的OR,返回UInt64类型的基数,如果添加后缀状态,则返回 [位图对象](../../sql_reference/functions/bitmap_functions.md). 这相当于 `groupBitmapMerge`. - -``` sql -groupBitmapOr(expr) -``` - -**参数** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` 类型。 - -**返回值** - -的价值 `UInt64` 类型。 - -**示例** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapOr(z)─┐ -│ 15 │ -└──────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapOrState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapOrState(z)))─┐ -│ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] │ -└─────────────────────────────────────────────────┘ -``` - -## groupBitmapXor {#groupbitmapxor} - -计算位图列的XOR,返回UInt64类型的基数,如果添加后缀状态,则返回 [位图对象](../../sql_reference/functions/bitmap_functions.md). - -``` sql -groupBitmapOr(expr) -``` - -**参数** - -`expr` – An expression that results in `AggregateFunction(groupBitmap, UInt*)` 类型。 - -**返回值** - -的价值 `UInt64` 类型。 - -**示例** - -``` sql -DROP TABLE IF EXISTS bitmap_column_expr_test2; -CREATE TABLE bitmap_column_expr_test2 -( - tag_id String, - z AggregateFunction(groupBitmap, UInt32) -) -ENGINE = MergeTree -ORDER BY tag_id; - -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); - -SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─groupBitmapXor(z)─┐ -│ 10 │ -└───────────────────┘ - -SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); -┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐ -│ [1,3,5,6,8,10,11,13,14,15] │ -└──────────────────────────────────────────────────┘ -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/agg_functions/reference/) diff --git a/docs/zh/sql_reference/ansi.md b/docs/zh/sql_reference/ansi.md deleted file mode 120000 index ee0f9c8cb7e..00000000000 --- a/docs/zh/sql_reference/ansi.md +++ /dev/null @@ -1 +0,0 @@ -../../en/sql_reference/ansi.md \ No newline at end of file diff --git a/docs/zh/sql_reference/data_types/aggregatefunction.md b/docs/zh/sql_reference/data_types/aggregatefunction.md deleted file mode 100644 index e1fb7b1d133..00000000000 --- a/docs/zh/sql_reference/data_types/aggregatefunction.md +++ /dev/null @@ -1,64 +0,0 @@ - -# AggregateFunction(name, types\_of\_arguments…) {#data-type-aggregatefunction} - -聚合函数的中间状态,可以通过聚合函数名称加`-State`后缀的形式得到它。与此同时,当您需要访问该类型的最终状态数据时,您需要以相同的聚合函数名加`-Merge`后缀的形式来得到最终状态数据。 - -`AggregateFunction` — 参数化的数据类型。 - -**参数** - -- 聚合函数名 - - 如果函数具备多个参数列表,请在此处指定其他参数列表中的值。 - -- 聚合函数参数的类型 - -**示例** - -``` sql -CREATE TABLE t -( - column1 AggregateFunction(uniq, UInt64), - column2 AggregateFunction(anyIf, String, UInt8), - column3 AggregateFunction(quantiles(0.5, 0.9), UInt64) -) ENGINE = ... -``` - -上述中的[uniq](../../sql_reference/data_types/aggregatefunction.md#agg_function-uniq), anyIf ([任何](../../sql_reference/data_types/aggregatefunction.md#agg_function-any)+[如果](../../sql_reference/data_types/aggregatefunction.md#agg-functions-combinator-if)) 以及 [分位数](../../sql_reference/data_types/aggregatefunction.md) 都为ClickHouse中支持的聚合函数。 - -## 使用指南 {#shi-yong-zhi-nan} - -### 数据写入 {#shu-ju-xie-ru} - -当需要写入数据时,您需要将数据包含在`INSERT SELECT`语句中,同时对于`AggregateFunction`类型的数据,您需要使用对应的以`-State`为后缀的函数进行处理。 - -**函数使用示例** - -``` sql -uniqState(UserID) -quantilesState(0.5, 0.9)(SendTiming) -``` - -不同于`uniq`和`quantiles`函数返回聚合结果的最终值,以`-State`后缀的函数总是返回`AggregateFunction`类型的数据的中间状态。 - -对于`SELECT`而言,`AggregateFunction`类型总是以特定的二进制形式展现在所有的输出格式中。例如,您可以使用`SELECT`语句将函数的状态数据转储为`TabSeparated`格式的同时使用`INSERT`语句将数据转储回去。 - -### 数据查询 {#shu-ju-cha-xun} - -当从`AggregatingMergeTree`表中查询数据时,对于`AggregateFunction`类型的字段,您需要使用以`-Merge`为后缀的相同聚合函数来聚合数据。对于非`AggregateFunction`类型的字段,请将它们包含在`GROUP BY`子句中。 - -以`-Merge`为后缀的聚合函数,可以将多个`AggregateFunction`类型的中间状态组合计算为最终的聚合结果。 - -例如,如下的两个查询返回的结果总是一致: - -``` sql -SELECT uniq(UserID) FROM table - -SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) -``` - -## 使用示例 {#shi-yong-shi-li} - -请参阅 [AggregatingMergeTree](../../sql_reference/data_types/aggregatefunction.md) 的说明 - -[来源文章](https://clickhouse.tech/docs/en/data_types/nested_data_structures/aggregatefunction/) diff --git a/docs/zh/sql_reference/data_types/array.md b/docs/zh/sql_reference/data_types/array.md deleted file mode 100644 index 7a35647d20e..00000000000 --- a/docs/zh/sql_reference/data_types/array.md +++ /dev/null @@ -1,73 +0,0 @@ - -# 阵列(T) {#data-type-array} - -由 `T` 类型元素组成的数组。 - -`T` 可以是任意类型,包含数组类型。 但不推荐使用多维数组,ClickHouse 对多维数组的支持有限。例如,不能存储在 `MergeTree` 表中存储多维数组。 - -## 创建数组 {#chuang-jian-shu-zu} - -您可以使用array函数来创建数组: - - array(T) - -您也可以使用方括号: - - [] - -创建数组示例: - - :) SELECT array(1, 2) AS x, toTypeName(x) - - SELECT - [1, 2] AS x, - toTypeName(x) - - ┌─x─────┬─toTypeName(array(1, 2))─┐ - │ [1,2] │ Array(UInt8) │ - └───────┴─────────────────────────┘ - - 1 rows in set. Elapsed: 0.002 sec. - - :) SELECT [1, 2] AS x, toTypeName(x) - - SELECT - [1, 2] AS x, - toTypeName(x) - - ┌─x─────┬─toTypeName([1, 2])─┐ - │ [1,2] │ Array(UInt8) │ - └───────┴────────────────────┘ - - 1 rows in set. Elapsed: 0.002 sec. - -## 使用数据类型 {#shi-yong-shu-ju-lei-xing} - -ClickHouse会自动检测数组元素,并根据元素计算出存储这些元素最小的数据类型。如果在元素中存在 [NULL](../../sql_reference/data_types/array.md#null-literal) 或存在 [可为空](nullable.md#data_type-nullable) 类型元素,那么数组的元素类型将会变成 [可为空](nullable.md)。 - -如果 ClickHouse 无法确定数据类型,它将产生异常。当尝试同时创建一个包含字符串和数字的数组时会发生这种情况 (`SELECT array(1, 'a')`)。 - -自动数据类型检测示例: - - :) SELECT array(1, 2, NULL) AS x, toTypeName(x) - - SELECT - [1, 2, NULL] AS x, - toTypeName(x) - - ┌─x──────────┬─toTypeName(array(1, 2, NULL))─┐ - │ [1,2,NULL] │ Array(Nullable(UInt8)) │ - └────────────┴───────────────────────────────┘ - - 1 rows in set. Elapsed: 0.002 sec. - -如果您尝试创建不兼容的数据类型数组,ClickHouse 将引发异常: - - :) SELECT array(1, 'a') - - SELECT [1, 'a'] - - Received exception from server (version 1.1.54388): - Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. - - 0 rows in set. Elapsed: 0.246 sec. diff --git a/docs/zh/sql_reference/data_types/boolean.md b/docs/zh/sql_reference/data_types/boolean.md deleted file mode 100644 index 26c8ac5cdd5..00000000000 --- a/docs/zh/sql_reference/data_types/boolean.md +++ /dev/null @@ -1,4 +0,0 @@ - -# 布尔值 {#boolean-values} - -没有单独的类型来存储布尔值。可以使用 UInt8 类型,取值限制为 0 或 1。 diff --git a/docs/zh/sql_reference/data_types/date.md b/docs/zh/sql_reference/data_types/date.md deleted file mode 100644 index 18bdb507f37..00000000000 --- a/docs/zh/sql_reference/data_types/date.md +++ /dev/null @@ -1,6 +0,0 @@ - -# 日期 {#date} - -日期类型,用两个字节存储,表示从 1970-01-01 (无符号) 到当前的日期值。允许存储从 Unix 纪元开始到编译阶段定义的上限阈值常量(目前上限是2106年,但最终完全支持的年份为2105)。最小值输出为0000-00-00。 - -日期中没有存储时区信息。 diff --git a/docs/zh/sql_reference/data_types/datetime.md b/docs/zh/sql_reference/data_types/datetime.md deleted file mode 100644 index 1122131614b..00000000000 --- a/docs/zh/sql_reference/data_types/datetime.md +++ /dev/null @@ -1,12 +0,0 @@ - -# 日期时间 {#data_type-datetime} - -时间戳类型。用四个字节(无符号的)存储 Unix 时间戳)。允许存储与日期类型相同的范围内的值。最小值为 0000-00-00 00:00:00。时间戳类型值精确到秒(没有闰秒)。 - -## 时区 {#shi-qu} - -使用启动客户端或服务器时的系统时区,时间戳是从文本(分解为组件)转换为二进制并返回。在文本格式中,有关夏令时的信息会丢失。 - -默认情况下,客户端连接到服务的时候会使用服务端时区。您可以通过启用客户端命令行选项 `--use_client_time_zone` 来设置使用客户端时间。 - -因此,在处理文本日期时(例如,在保存文本转储时),请记住在夏令时更改期间可能存在歧义,如果时区发生更改,则可能存在匹配数据的问题。 diff --git a/docs/zh/sql_reference/data_types/datetime64.md b/docs/zh/sql_reference/data_types/datetime64.md deleted file mode 100644 index dd87486cee5..00000000000 --- a/docs/zh/sql_reference/data_types/datetime64.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 49 -toc_title: DateTime64 ---- - -# Datetime64 {#data_type-datetime64} - -允许存储时间instant间,可以表示为日历日期和一天中的时间,具有定义的亚秒精度 - -刻度尺寸(精度):10-精度 秒 - -语法: - -``` sql -DateTime64(precision, [timezone]) -``` - -在内部,存储数据作为一些 ‘ticks’ 自纪元开始(1970-01-01 00:00:00UTC)作为Int64. 刻度分辨率由precision参数确定。 此外,该 `DateTime64` 类型可以存储时区是相同的整个列,影响如何的值 `DateTime64` 类型值以文本格式显示,以及如何解析指定为字符串的值 (‘2020-01-01 05:00:01.000’). 时区不存储在表的行中(或resultset中),而是存储在列元数据中。 查看详细信息 [日期时间](datetime.md). - -## 例 {#examples} - -**1.** 创建一个表 `DateTime64`-输入列并将数据插入其中: - -``` sql -CREATE TABLE dt -( - `timestamp` DateTime64(3, 'Europe/Moscow'), - `event_id` UInt8 -) -ENGINE = TinyLog -``` - -``` sql -INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2) -``` - -``` sql -SELECT * FROM dt -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 03:00:00.000 │ 1 │ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -- 将日期时间作为整数插入时,将其视为适当缩放的Unix时间戳(UTC)。 `1546300800000` (精度为3)表示 `'2019-01-01 00:00:00'` UTC. 然而,作为 `timestamp` 列有 `Europe/Moscow` (UTC+3)指定的时区,当输出为字符串时,该值将显示为 `'2019-01-01 03:00:00'` -- 当插入字符串值作为日期时间时,它被视为处于列时区。 `'2019-01-01 00:00:00'` 将被视为 `Europe/Moscow` 时区并存储为 `1546290000000`. - -**2.** 过滤 `DateTime64` 值 - -``` sql -SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow') -``` - -``` text -┌───────────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00.000 │ 2 │ -└─────────────────────────┴──────────┘ -``` - -不像 `DateTime`, `DateTime64` 值不转换为 `String` 自动 - -**3.** 获取一个时区 `DateTime64`-类型值: - -``` sql -SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x -``` - -``` text -┌──────────────────column─┬─x──────────────────────────────┐ -│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │ -└─────────────────────────┴────────────────────────────────┘ -``` - -**4.** 时区转换 - -``` sql -SELECT -toDateTime64(timestamp, 3, 'Europe/London') as lon_time, -toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time -FROM dt -``` - -``` text -┌───────────────lon_time──┬────────────────mos_time─┐ -│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │ -│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │ -└─────────────────────────┴─────────────────────────┘ -``` - -## 另请参阅 {#see-also} - -- [类型转换函数](../../sql_reference/functions/type_conversion_functions.md) -- [用于处理日期和时间的函数](../../sql_reference/functions/date_time_functions.md) -- [用于处理数组的函数](../../sql_reference/functions/array_functions.md) -- [该 `date_time_input_format` 设置](../../operations/settings/settings.md#settings-date_time_input_format) -- [该 `timezone` 服务器配置参数](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-timezone) -- [使用日期和时间的操作员](../../sql_reference/operators.md#operators-datetime) -- [`Date` 数据类型](date.md) -- [`DateTime` 数据类型](datetime.md) diff --git a/docs/zh/sql_reference/data_types/decimal.md b/docs/zh/sql_reference/data_types/decimal.md deleted file mode 100644 index 24bc1f70415..00000000000 --- a/docs/zh/sql_reference/data_types/decimal.md +++ /dev/null @@ -1,81 +0,0 @@ - -# Decimal(P,S),Decimal32(S),Decimal64(S),Decimal128(S) {#decimalp-s-decimal32s-decimal64s-decimal128s} - -有符号的定点数,可在加、减和乘法运算过程中保持精度。对于除法,最低有效数字会被丢弃(不舍入)。 - -## 参数 {#can-shu} - -- P - 精度。有效范围:\[1:38\],决定可以有多少个十进制数字(包括分数)。 -- S - 规模。有效范围:\[0:P\],决定数字的小数部分中包含的小数位数。 - -对于不同的 P 参数值 Decimal 表示,以下例子都是同义的: --P从\[1:9\]-对于Decimal32(S) --P从\[10:18\]-对于Decimal64(小号) --P从\[19:38\]-对于Decimal128(S) - -## 十进制值范围 {#shi-jin-zhi-zhi-fan-wei} - -- Decimal32(S) - ( -1 \* 10^(9 - S),1\*10^(9-S) ) -- Decimal64(S) - ( -1 \* 10^(18 - S),1\*10^(18-S) ) -- Decimal128(S) - ( -1 \* 10^(38 - S),1\*10^(38-S) ) - -例如,Decimal32(4) 可以表示 -99999.9999 至 99999.9999 的数值,步长为0.0001。 - -## 内部表示方式 {#nei-bu-biao-shi-fang-shi} - -数据采用与自身位宽相同的有符号整数存储。这个数在内存中实际范围会高于上述范围,从 String 转换到十进制数的时候会做对应的检查。 - -由于现代CPU不支持128位数字,因此 Decimal128 上的操作由软件模拟。所以 Decimal128 的运算速度明显慢于 Decimal32/Decimal64。 - -## 运算和结果类型 {#yun-suan-he-jie-guo-lei-xing} - -对Decimal的二进制运算导致更宽的结果类型(无论参数的顺序如何)。 - -- Decimal64(S1) Decimal32(S2)-\>Decimal64(S) -- Decimal128(S1) Decimal32(S2)-\>Decimal128(S) -- Decimal128(S1) Decimal64(S2)-\>Decimal128(S) - -精度变化的规则: - -- 加法,减法:S = max(S1, S2)。 -- 乘法:S = S1 + S2。 -- 除法:S = S1。 - -对于 Decimal 和整数之间的类似操作,结果是与参数大小相同的十进制。 - -未定义Decimal和Float32/Float64之间的函数。要执行此类操作,您可以使用:toDecimal32、toDecimal64、toDecimal128 或 toFloat32,toFloat64,需要显式地转换其中一个参数。注意,结果将失去精度,类型转换是昂贵的操作。 - -Decimal上的一些函数返回结果为Float64(例如,var或stddev)。对于其中一些,中间计算发生在Decimal中。对于此类函数,尽管结果类型相同,但Float64和Decimal中相同数据的结果可能不同。 - -## 溢出检查 {#yi-chu-jian-cha} - -在对 Decimal 类型执行操作时,数值可能会发生溢出。分数中的过多数字被丢弃(不是舍入的)。整数中的过多数字将导致异常。 - - SELECT toDecimal32(2, 4) AS x, x / 3 - - ┌──────x─┬─divide(toDecimal32(2, 4), 3)─┐ - │ 2.0000 │ 0.6666 │ - └────────┴──────────────────────────────┘ - - SELECT toDecimal32(4.2, 8) AS x, x * x - - DB::Exception: Scale is out of bounds. - - SELECT toDecimal32(4.2, 8) AS x, 6 * x - - DB::Exception: Decimal math overflow. - -检查溢出会导致计算变慢。如果已知溢出不可能,则可以通过设置`decimal_check_overflow`来禁用溢出检查,在这种情况下,溢出将导致结果不正确: - - SET decimal_check_overflow = 0; - SELECT toDecimal32(4.2, 8) AS x, 6 * x - - ┌──────────x─┬─multiply(6, toDecimal32(4.2, 8))─┐ - │ 4.20000000 │ -17.74967296 │ - └────────────┴──────────────────────────────────┘ - -溢出检查不仅发生在算术运算上,还发生在比较运算上: - - SELECT toDecimal32(1, 8) < 100 - - DB::Exception: Can't compare. diff --git a/docs/zh/sql_reference/data_types/domains/index.md b/docs/zh/sql_reference/data_types/domains/index.md deleted file mode 100644 index 7df13d51e54..00000000000 --- a/docs/zh/sql_reference/data_types/domains/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u57DF" -toc_priority: 56 ---- - - diff --git a/docs/zh/sql_reference/data_types/domains/ipv4.md b/docs/zh/sql_reference/data_types/domains/ipv4.md deleted file mode 100644 index 26ed4d84922..00000000000 --- a/docs/zh/sql_reference/data_types/domains/ipv4.md +++ /dev/null @@ -1,69 +0,0 @@ - -## IPv4 {#ipv4} - -`IPv4`是与`UInt32`类型保持二进制兼容的Domain类型,其用于存储IPv4地址的值。它提供了更为紧凑的二进制存储的同时支持识别可读性更加友好的输入输出格式。 - -### 基本使用 {#ji-ben-shi-yong} - -``` sql -CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY url; - -DESCRIBE TABLE hits; -``` - - ┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ - │ url │ String │ │ │ │ │ - │ from │ IPv4 │ │ │ │ │ - └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ - -同时您也可以使用`IPv4`类型的列作为主键: - -``` sql -CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; -``` - -在写入与查询时,`IPv4`类型能够识别可读性更加友好的输入输出格式: - -``` sql -INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.tech', '183.247.232.58')('https://clickhouse.yandex/docs/en/', '116.106.34.242'); - -SELECT * FROM hits; -``` - - ┌─url────────────────────────────────┬───────────from─┐ - │ https://clickhouse.tech/docs/en/ │ 116.106.34.242 │ - │ https://wikipedia.org │ 116.253.40.133 │ - │ https://clickhouse.tech │ 183.247.232.58 │ - └────────────────────────────────────┴────────────────┘ - -同时它提供更为紧凑的二进制存储格式: - -``` sql -SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; -``` - - ┌─toTypeName(from)─┬─hex(from)─┐ - │ IPv4 │ B7F7E83A │ - └──────────────────┴───────────┘ - -不可隐式转换为除`UInt32`以外的其他类型类型。如果要将`IPv4`类型的值转换成字符串,你可以使用`IPv4NumToString()`显示的进行转换: - -``` sql -SELECT toTypeName(s), IPv4NumToString(from) as s FROM hits LIMIT 1; -``` - - ┌─toTypeName(IPv4NumToString(from))─┬─s──────────────┐ - │ String │ 183.247.232.58 │ - └───────────────────────────────────┴────────────────┘ - -或可以使用`CAST`将它转换为`UInt32`类型: - -``` sql -SELECT toTypeName(i), CAST(from as UInt32) as i FROM hits LIMIT 1; -``` - - ┌─toTypeName(CAST(from, 'UInt32'))─┬──────────i─┐ - │ UInt32 │ 3086477370 │ - └──────────────────────────────────┴────────────┘ - -[来源文章](https://clickhouse.tech/docs/en/data_types/domains/ipv4) diff --git a/docs/zh/sql_reference/data_types/domains/ipv6.md b/docs/zh/sql_reference/data_types/domains/ipv6.md deleted file mode 100644 index b147fb6db84..00000000000 --- a/docs/zh/sql_reference/data_types/domains/ipv6.md +++ /dev/null @@ -1,69 +0,0 @@ - -## IPv6 {#ipv6} - -`IPv6`是与`FixedString(16)`类型保持二进制兼容的Domain类型,其用于存储IPv6地址的值。它提供了更为紧凑的二进制存储的同时支持识别可读性更加友好的输入输出格式。 - -### 基本用法 {#ji-ben-yong-fa} - -``` sql -CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url; - -DESCRIBE TABLE hits; -``` - - ┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐ - │ url │ String │ │ │ │ │ - │ from │ IPv6 │ │ │ │ │ - └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ - -同时您也可以使用`IPv6`类型的列作为主键: - -``` sql -CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from; -``` - -在写入与查询时,`IPv6`类型能够识别可读性更加友好的输入输出格式: - -``` sql -INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.tech', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.yandex/docs/en/', '2a02:e980:1e::1'); - -SELECT * FROM hits; -``` - - ┌─url────────────────────────────────┬─from──────────────────────────┐ - │ https://clickhouse.tech │ 2001:44c8:129:2632:33:0:252:2 │ - │ https://clickhouse.tech/docs/en/ │ 2a02:e980:1e::1 │ - │ https://wikipedia.org │ 2a02:aa08:e000:3100::2 │ - └────────────────────────────────────┴───────────────────────────────┘ - -同时它提供更为紧凑的二进制存储格式: - -``` sql -SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; -``` - - ┌─toTypeName(from)─┬─hex(from)────────────────────────┐ - │ IPv6 │ 200144C8012926320033000002520002 │ - └──────────────────┴──────────────────────────────────┘ - -不可隐式转换为除`FixedString(16)`以外的其他类型类型。如果要将`IPv6`类型的值转换成字符串,你可以使用`IPv6NumToString()`显示的进行转换: - -``` sql -SELECT toTypeName(s), IPv6NumToString(from) as s FROM hits LIMIT 1; -``` - - ┌─toTypeName(IPv6NumToString(from))─┬─s─────────────────────────────┐ - │ String │ 2001:44c8:129:2632:33:0:252:2 │ - └───────────────────────────────────┴───────────────────────────────┘ - -或使用`CAST`将其转换为`FixedString(16)`: - -``` sql -SELECT toTypeName(i), CAST(from as FixedString(16)) as i FROM hits LIMIT 1; -``` - - ┌─toTypeName(CAST(from, 'FixedString(16)'))─┬─i───────┐ - │ FixedString(16) │ ��� │ - └───────────────────────────────────────────┴─────────┘ - -[来源文章](https://clickhouse.tech/docs/en/data_types/domains/ipv6) diff --git a/docs/zh/sql_reference/data_types/domains/overview.md b/docs/zh/sql_reference/data_types/domains/overview.md deleted file mode 100644 index b330bad18c0..00000000000 --- a/docs/zh/sql_reference/data_types/domains/overview.md +++ /dev/null @@ -1,27 +0,0 @@ - -# 域 {#domains} - -Domain类型是特定实现的类型,它总是与某个现存的基础类型保持二进制兼容的同时添加一些额外的特性,以能够在维持磁盘数据不变的情况下使用这些额外的特性。目前ClickHouse暂不支持自定义domain类型。 - -如果你可以在一个地方使用与Domain类型二进制兼容的基础类型,那么在相同的地方您也可以使用Domain类型,例如: - -- 使用Domain类型作为表中列的类型 -- 对Domain类型的列进行读/写数据 -- 如果与Domain二进制兼容的基础类型可以作为索引,那么Domain类型也可以作为索引 -- 将Domain类型作为参数传递给函数使用 -- 其他 - -### Domains的额外特性 {#domainsde-e-wai-te-xing} - -- 在执行SHOW CREATE TABLE 或 DESCRIBE TABLE时,其对应的列总是展示为Domain类型的名称 -- 在INSERT INTO domain\_table(domain\_column) VALUES(…)中输入数据总是以更人性化的格式进行输入 -- 在SELECT domain\_column FROM domain\_table中数据总是以更人性化的格式输出 -- 在INSERT INTO domain\_table FORMAT CSV …中,实现外部源数据以更人性化的格式载入 - -### Domains类型的限制 {#domainslei-xing-de-xian-zhi} - -- 无法通过`ALTER TABLE`将基础类型的索引转换为Domain类型的索引。 -- 当从其他列或表插入数据时,无法将string类型的值隐式地转换为Domain类型的值。 -- 无法对存储为Domain类型的值添加约束。 - -[来源文章](https://clickhouse.tech/docs/en/data_types/domains/overview) diff --git a/docs/zh/sql_reference/data_types/enum.md b/docs/zh/sql_reference/data_types/enum.md deleted file mode 100644 index 87ada143638..00000000000 --- a/docs/zh/sql_reference/data_types/enum.md +++ /dev/null @@ -1,101 +0,0 @@ - -# Enum8,Enum16 {#enum8-enum16} - -包括 `Enum8` 和 `Enum16` 类型。`Enum` 保存 `'string'= integer` 的对应关系。在 ClickHouse 中,尽管用户使用的是字符串常量,但所有含有 `Enum` 数据类型的操作都是按照包含整数的值来执行。这在性能方面比使用 `String` 数据类型更有效。 - -- `Enum8` 用 `'String'= Int8` 对描述。 -- `Enum16` 用 `'String'= Int16` 对描述。 - -## 用法示例 {#yong-fa-shi-li} - -创建一个带有一个枚举 `Enum8('hello' = 1, 'world' = 2)` 类型的列: - - CREATE TABLE t_enum - ( - x Enum8('hello' = 1, 'world' = 2) - ) - ENGINE = TinyLog - -这个 `x` 列只能存储类型定义中列出的值:`'hello'`或`'world'`。如果您尝试保存任何其他值,ClickHouse 抛出异常。 - - :) INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') - - INSERT INTO t_enum VALUES - - Ok. - - 3 rows in set. Elapsed: 0.002 sec. - - :) insert into t_enum values('a') - - INSERT INTO t_enum VALUES - - - Exception on client: - Code: 49. DB::Exception: Unknown element 'a' for type Enum8('hello' = 1, 'world' = 2) - -当您从表中查询数据时,ClickHouse 从 `Enum` 中输出字符串值。 - - SELECT * FROM t_enum - - ┌─x─────┐ - │ hello │ - │ world │ - │ hello │ - └───────┘ - -如果需要看到对应行的数值,则必须将 `Enum` 值转换为整数类型。 - - SELECT CAST(x, 'Int8') FROM t_enum - - ┌─CAST(x, 'Int8')─┐ - │ 1 │ - │ 2 │ - │ 1 │ - └─────────────────┘ - -在查询中创建枚举值,您还需要使用 `CAST`。 - - SELECT toTypeName(CAST('a', 'Enum8(\'a\' = 1, \'b\' = 2)')) - - ┌─toTypeName(CAST('a', 'Enum8(\'a\' = 1, \'b\' = 2)'))─┐ - │ Enum8('a' = 1, 'b' = 2) │ - └──────────────────────────────────────────────────────┘ - -## 规则及用法 {#gui-ze-ji-yong-fa} - -`Enum8` 类型的每个值范围是 `-128 ... 127`,`Enum16` 类型的每个值范围是 `-32768 ... 32767`。所有的字符串或者数字都必须是不一样的。允许存在空字符串。如果某个 Enum 类型被指定了(在表定义的时候),数字可以是任意顺序。然而,顺序并不重要。 - -`Enum` 中的字符串和数值都不能是 [NULL](../../sql_reference/data_types/enum.md)。 - -`Enum` 包含在 [可为空](nullable.md) 类型中。因此,如果您使用此查询创建一个表 - - CREATE TABLE t_enum_nullable - ( - x Nullable( Enum8('hello' = 1, 'world' = 2) ) - ) - ENGINE = TinyLog - -不仅可以存储 `'hello'` 和 `'world'` ,还可以存储 `NULL`。 - - INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) - -在内存中,`Enum` 列的存储方式与相应数值的 `Int8` 或 `Int16` 相同。 - -当以文本方式读取的时候,ClickHouse 将值解析成字符串然后去枚举值的集合中搜索对应字符串。如果没有找到,会抛出异常。当读取文本格式的时候,会根据读取到的字符串去找对应的数值。如果没有找到,会抛出异常。 - -当以文本形式写入时,ClickHouse 将值解析成字符串写入。如果列数据包含垃圾数据(不是来自有效集合的数字),则抛出异常。Enum 类型以二进制读取和写入的方式与 `Int8` 和 `Int16` 类型一样的。 - -隐式默认值是数值最小的值。 - -在 `ORDER BY`,`GROUP BY`,`IN`,`DISTINCT` 等等中,Enum 的行为与相应的数字相同。例如,按数字排序。对于等式运算符和比较运算符,Enum 的工作机制与它们在底层数值上的工作机制相同。 - -枚举值不能与数字进行比较。枚举可以与常量字符串进行比较。如果与之比较的字符串不是有效Enum值,则将引发异常。可以使用 IN 运算符来判断一个 Enum 是否存在于某个 Enum 集合中,其中集合中的 Enum 需要用字符串表示。 - -大多数具有数字和字符串的运算并不适用于Enums;例如,Enum 类型不能和一个数值相加。但是,Enum有一个原生的 `toString` 函数,它返回它的字符串值。 - -Enum 值使用 `toT` 函数可以转换成数值类型,其中 T 是一个数值类型。若 `T` 恰好对应 Enum 的底层数值类型,这个转换是零消耗的。 - -Enum 类型可以被 `ALTER` 无成本地修改对应集合的值。可以通过 `ALTER` 操作来增加或删除 Enum 的成员(只要表没有用到该值,删除都是安全的)。作为安全保障,改变之前使用过的 Enum 成员将抛出异常。 - -通过 `ALTER` 操作,可以将 `Enum8` 转成 `Enum16`,反之亦然,就像 `Int8` 转 `Int16`一样。 diff --git a/docs/zh/sql_reference/data_types/fixedstring.md b/docs/zh/sql_reference/data_types/fixedstring.md deleted file mode 100644 index c8e71e69303..00000000000 --- a/docs/zh/sql_reference/data_types/fixedstring.md +++ /dev/null @@ -1,57 +0,0 @@ - -# 固定字符串 {#fixedstring} - -固定长度 N 的字符串(N 必须是严格的正自然数)。 - -您可以使用下面的语法对列声明为`FixedString`类型: - -``` sql - FixedString(N) -``` - -其中`N`表示自然数。 - -当数据的长度恰好为N个字节时,`FixedString`类型是高效的。 在其他情况下,这可能会降低效率。 - -可以有效存储在`FixedString`类型的列中的值的示例: - -- 二进制表示的IP地址(IPv6使用`FixedString(16)`) -- 语言代码(ru\_RU, en\_US … ) -- 货币代码(USD, RUB … ) -- 二进制表示的哈希值(MD5使用`FixedString(16)`,SHA256使用`FixedString(32)`) - -请使用[UUID](uuid.md)数据类型来存储UUID值,。 - -当向ClickHouse中插入数据时, - -- 如果字符串包含的字节数少于\`N',将对字符串末尾进行空字节填充。 -- 如果字符串包含的字节数大于`N`,将抛出`Too large value for FixedString(N)`异常。 - -当做数据查询时,ClickHouse不会删除字符串末尾的空字节。 如果使用`WHERE`子句,则须要手动添加空字节以匹配`FixedString`的值。 以下示例阐明了如何将`WHERE`子句与`FixedString`一起使用。 - -考虑带有`FixedString(2)`列的表: - -``` text -┌─name──┐ -│ b │ -└───────┘ -``` - -查询语句`SELECT * FROM FixedStringTable WHERE a = 'b'` 不会返回任何结果。请使用空字节来填充筛选条件。 - -``` sql -SELECT * FROM FixedStringTable -WHERE a = 'b\0' -``` - -``` text -┌─a─┐ -│ b │ -└───┘ -``` - -这种方式与MySQL的`CHAR`类型的方式不同(MySQL中使用空格填充字符串,并在输出时删除空格)。 - -请注意,`FixedString(N)`的长度是个常量。仅由空字符组成的字符串,函数[长度](../../sql_reference/data_types/fixedstring.md#array_functions-length)返回值为`N`,而函数[空](../../sql_reference/data_types/fixedstring.md#string_functions-empty)的返回值为`1`。 - -[来源文章](https://clickhouse.tech/docs/en/data_types/fixedstring/) diff --git a/docs/zh/sql_reference/data_types/float.md b/docs/zh/sql_reference/data_types/float.md deleted file mode 100644 index bdc8093a9a9..00000000000 --- a/docs/zh/sql_reference/data_types/float.md +++ /dev/null @@ -1,71 +0,0 @@ - -# Float32,Float64 {#float32-float64} - -[浮点数](https://en.wikipedia.org/wiki/IEEE_754)。 - -类型与以下 C 语言中类型是相同的: - -- `Float32` - `float` -- `Float64` - `double` - -我们建议您尽可能以整数形式存储数据。例如,将固定精度的数字转换为整数值,例如货币数量或页面加载时间用毫秒为单位表示 - -## 使用浮点数 {#shi-yong-fu-dian-shu} - -- 对浮点数进行计算可能引起四舍五入的误差。 - - - -``` sql -SELECT 1 - 0.9 -``` - - ┌───────minus(1, 0.9)─┐ - │ 0.09999999999999998 │ - └─────────────────────┘ - -- 计算的结果取决于计算方法(计算机系统的处理器类型和体系结构) - -- 浮点计算结果可能是诸如无穷大(`INF`)和«非数字»(`NaN`)。对浮点数计算的时候应该考虑到这点。 - -- 当一行行阅读浮点数的时候,浮点数的结果可能不是机器最近显示的数值。 - -## 南和Inf {#data_type-float-nan-inf} - -与标准SQL相比,ClickHouse 支持以下类别的浮点数: - -- `Inf` – 正无穷 - - - -``` sql -SELECT 0.5 / 0 -``` - - ┌─divide(0.5, 0)─┐ - │ inf │ - └────────────────┘ - -- `-Inf` – 负无穷 - - - -``` sql -SELECT -0.5 / 0 -``` - - ┌─divide(-0.5, 0)─┐ - │ -inf │ - └─────────────────┘ - -- `NaN` – 非数字 - - - - SELECT 0 / 0 - - ┌─divide(0, 0)─┐ - │ nan │ - └──────────────┘ - -可以在 [ORDER BY 子句](../../sql_reference/data_types/float.md) 查看更多关于 `NaN` 排序的规则。 diff --git a/docs/zh/sql_reference/data_types/index.md b/docs/zh/sql_reference/data_types/index.md deleted file mode 100644 index 8df3911ab36..00000000000 --- a/docs/zh/sql_reference/data_types/index.md +++ /dev/null @@ -1,6 +0,0 @@ - -# 数据类型 {#data_types} - -ClickHouse 可以在数据表中存储多种数据类型。 - -本节描述 ClickHouse 支持的数据类型,以及使用或者实现它们时(如果有的话)的注意事项。 diff --git a/docs/zh/sql_reference/data_types/int_uint.md b/docs/zh/sql_reference/data_types/int_uint.md deleted file mode 100644 index b74bbcf178f..00000000000 --- a/docs/zh/sql_reference/data_types/int_uint.md +++ /dev/null @@ -1,18 +0,0 @@ - -# UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64 {#uint8-uint16-uint32-uint64-int8-int16-int32-int64} - -固定长度的整型,包括有符号整型或无符号整型。 - -## 整型范围 {#zheng-xing-fan-wei} - -- Int8-\[-128:127\] -- Int16-\[-32768:32767\] -- Int32-\[-2147483648:2147483647\] -- Int64-\[-9223372036854775808:9223372036854775807\] - -## 无符号整型范围 {#wu-fu-hao-zheng-xing-fan-wei} - -- UInt8-\[0:255\] -- UInt16-\[0:65535\] -- UInt32-\[0:4294967295\] -- UInt64-\[0:18446744073709551615\] diff --git a/docs/zh/sql_reference/data_types/nested_data_structures/index.md b/docs/zh/sql_reference/data_types/nested_data_structures/index.md deleted file mode 100644 index fdeb9fe6ac5..00000000000 --- a/docs/zh/sql_reference/data_types/nested_data_structures/index.md +++ /dev/null @@ -1,2 +0,0 @@ - -# 嵌套数据结构 {#qian-tao-shu-ju-jie-gou} diff --git a/docs/zh/sql_reference/data_types/nested_data_structures/nested.md b/docs/zh/sql_reference/data_types/nested_data_structures/nested.md deleted file mode 100644 index 6ac26c0eeba..00000000000 --- a/docs/zh/sql_reference/data_types/nested_data_structures/nested.md +++ /dev/null @@ -1,98 +0,0 @@ - -# Nested(Name1 Type1, Name2 Type2, …) {#nestedname1-type1-name2-type2} - -嵌套数据结构类似于嵌套表。嵌套数据结构的参数(列名和类型)与 CREATE 查询类似。每个表可以包含任意多行嵌套数据结构。 - -示例: - -``` sql -CREATE TABLE test.visits -( - CounterID UInt32, - StartDate Date, - Sign Int8, - IsNew UInt8, - VisitID UInt64, - UserID UInt64, - ... - Goals Nested - ( - ID UInt32, - Serial UInt32, - EventTime DateTime, - Price Int64, - OrderID String, - CurrencyID UInt32 - ), - ... -) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) -``` - -上述示例声明了 `Goals` 这种嵌套数据结构,它包含访客转化相关的数据(访客达到的目标)。在 ‘visits’ 表中每一行都可以对应零个或者任意个转化数据。 - -只支持一级嵌套。嵌套结构的列中,若列的类型是数组类型,那么该列其实和多维数组是相同的,所以目前嵌套层级的支持很局限(MergeTree 引擎中不支持存储这样的列) - -大多数情况下,处理嵌套数据结构时,会指定一个单独的列。为了这样实现,列的名称会与点号连接起来。这些列构成了一组匹配类型。在同一条嵌套数据中,所有的列都具有相同的长度。 - -示例: - -``` sql -SELECT - Goals.ID, - Goals.EventTime -FROM test.visits -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐ -│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │ -│ [1073752] │ ['2014-03-17 00:28:25'] │ -│ [1073752] │ ['2014-03-17 10:46:20'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │ -│ [] │ [] │ -│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │ -│ [] │ [] │ -│ [] │ [] │ -│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │ -│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │ -└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -所以可以简单地把嵌套数据结构当做是所有列都是相同长度的多列数组。 - -SELECT 查询只有在使用 ARRAY JOIN 的时候才可以指定整个嵌套数据结构的名称。更多信息,参考 «ARRAY JOIN 子句»。示例: - -``` sql -SELECT - Goal.ID, - Goal.EventTime -FROM test.visits -ARRAY JOIN Goals AS Goal -WHERE CounterID = 101500 AND length(Goals.ID) < 5 -LIMIT 10 -``` - -``` text -┌─Goal.ID─┬──────Goal.EventTime─┐ -│ 1073752 │ 2014-03-17 16:38:10 │ -│ 591325 │ 2014-03-17 16:38:48 │ -│ 591325 │ 2014-03-17 16:42:27 │ -│ 1073752 │ 2014-03-17 00:28:25 │ -│ 1073752 │ 2014-03-17 10:46:20 │ -│ 1073752 │ 2014-03-17 13:59:20 │ -│ 591325 │ 2014-03-17 22:17:55 │ -│ 591325 │ 2014-03-17 22:18:07 │ -│ 591325 │ 2014-03-17 22:18:51 │ -│ 1073752 │ 2014-03-17 11:37:06 │ -└─────────┴─────────────────────┘ -``` - -不能对整个嵌套数据结构执行 SELECT。只能明确列出属于它一部分列。 - -对于 INSERT 查询,可以单独地传入所有嵌套数据结构中的列数组(假如它们是单独的列数组)。在插入过程中,系统会检查它们是否有相同的长度。 - -对于 DESCRIBE 查询,嵌套数据结构中的列会以相同的方式分别列出来。 - -ALTER 查询对嵌套数据结构的操作非常有限。 diff --git a/docs/zh/sql_reference/data_types/nullable.md b/docs/zh/sql_reference/data_types/nullable.md deleted file mode 100644 index 6ece5f3c178..00000000000 --- a/docs/zh/sql_reference/data_types/nullable.md +++ /dev/null @@ -1,42 +0,0 @@ - -# 可为空(类型名称) {#data_type-nullable} - -允许用特殊标记 ([NULL](../../sql_reference/data_types/nullable.md)) 表示«缺失值»,可以与 `TypeName` 的正常值存放一起。例如,`Nullable(Int8)` 类型的列可以存储 `Int8` 类型值,而没有值的行将存储 `NULL`。 - -对于 `TypeName`,不能使用复合数据类型 [阵列](array.md) 和 [元组](tuple.md)。复合数据类型可以包含 `Nullable` 类型值,例如`Array(Nullable(Int8))`。 - -`Nullable` 类型字段不能包含在表索引中。 - -除非在 ClickHouse 服务器配置中另有说明,否则 `NULL` 是任何 `Nullable` 类型的默认值。 - -## 存储特性 {#cun-chu-te-xing} - -要在表的列中存储 `Nullable` 类型值,ClickHouse 除了使用带有值的普通文件外,还使用带有 `NULL` 掩码的单独文件。 掩码文件中的条目允许 ClickHouse 区分每个表行的 `NULL` 和相应数据类型的默认值。 由于附加了新文件,`Nullable` 列与类似的普通文件相比消耗额外的存储空间。 - -!!! 注意点 "注意点" - 使用 `Nullable` 几乎总是对性能产生负面影响,在设计数据库时请记住这一点 - -掩码文件中的条目允许ClickHouse区分每个表行的对应数据类型的«NULL»和默认值由于有额外的文件,«Nullable»列比普通列消耗更多的存储空间 - -## 用法示例 {#yong-fa-shi-li} - -``` sql -CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE TinyLog -``` - -``` sql -INSERT INTO t_null VALUES (1, NULL), (2, 3) -``` - -``` sql -SELECT x + y FROM t_null -``` - -``` text -┌─plus(x, y)─┐ -│ ᴺᵁᴸᴸ │ -│ 5 │ -└────────────┘ -``` - -[来源文章](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/zh/sql_reference/data_types/simpleaggregatefunction.md b/docs/zh/sql_reference/data_types/simpleaggregatefunction.md deleted file mode 120000 index 02fad64d50e..00000000000 --- a/docs/zh/sql_reference/data_types/simpleaggregatefunction.md +++ /dev/null @@ -1 +0,0 @@ -../../../en/sql_reference/data_types/simpleaggregatefunction.md \ No newline at end of file diff --git a/docs/zh/sql_reference/data_types/special_data_types/expression.md b/docs/zh/sql_reference/data_types/special_data_types/expression.md deleted file mode 100644 index d4fb3257f60..00000000000 --- a/docs/zh/sql_reference/data_types/special_data_types/expression.md +++ /dev/null @@ -1,4 +0,0 @@ - -# 表达式 {#expression} - -用于表示高阶函数中的Lambd表达式。 diff --git a/docs/zh/sql_reference/data_types/special_data_types/index.md b/docs/zh/sql_reference/data_types/special_data_types/index.md deleted file mode 100644 index 64d93783cb9..00000000000 --- a/docs/zh/sql_reference/data_types/special_data_types/index.md +++ /dev/null @@ -1,4 +0,0 @@ - -# 特殊数据类型 {#special-data-types} - -特殊数据类型的值既不能存在表中也不能在结果中输出,但可用于查询的中间结果。 diff --git a/docs/zh/sql_reference/data_types/special_data_types/interval.md b/docs/zh/sql_reference/data_types/special_data_types/interval.md deleted file mode 100644 index 7a7ac888775..00000000000 --- a/docs/zh/sql_reference/data_types/special_data_types/interval.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 61 -toc_title: "\u95F4\u9694" ---- - -# 间隔 {#data-type-interval} - -表示时间和日期间隔的数据类型族。 由此产生的类型 [INTERVAL](../../../sql_reference/operators.md#operator-interval) 接线员 - -!!! warning "警告" - `Interval` 数据类型值不能存储在表中。 - -结构: - -- 时间间隔作为无符号整数值。 -- 间隔的类型。 - -支持的时间间隔类型: - -- `SECOND` -- `MINUTE` -- `HOUR` -- `DAY` -- `WEEK` -- `MONTH` -- `QUARTER` -- `YEAR` - -对于每个间隔类型,都有一个单独的数据类型。 例如, `DAY` 间隔对应于 `IntervalDay` 数据类型: - -``` sql -SELECT toTypeName(INTERVAL 4 DAY) -``` - -``` text -┌─toTypeName(toIntervalDay(4))─┐ -│ IntervalDay │ -└──────────────────────────────┘ -``` - -## 使用说明 {#data-type-interval-usage-remarks} - -您可以使用 `Interval`-在算术运算类型值 [日期](../../../sql_reference/data_types/date.md) 和 [日期时间](../../../sql_reference/data_types/datetime.md)-类型值。 例如,您可以将4天添加到当前时间: - -``` sql -SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY -``` - -``` text -┌───current_date_time─┬─plus(now(), toIntervalDay(4))─┐ -│ 2019-10-23 10:58:45 │ 2019-10-27 10:58:45 │ -└─────────────────────┴───────────────────────────────┘ -``` - -不同类型的间隔不能合并。 你不能使用间隔,如 `4 DAY 1 HOUR`. 以小于或等于间隔的最小单位的单位指定间隔,例如,间隔 `1 day and an hour` 间隔可以表示为 `25 HOUR` 或 `90000 SECOND`. - -你不能执行算术运算 `Interval`-类型值,但你可以添加不同类型的时间间隔,因此值 `Date` 或 `DateTime` 数据类型。 例如: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -以下查询将导致异常: - -``` sql -select now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) -``` - -``` text -Received exception from server (version 19.14.1): -Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Wrong argument types for function plus: if one argument is Interval, then another must be Date or DateTime.. -``` - -## 另请参阅 {#see-also} - -- [INTERVAL](../../../sql_reference/operators.md#operator-interval) 接线员 -- [toInterval](../../../sql_reference/functions/type_conversion_functions.md#function-tointerval) 类型转换函数 diff --git a/docs/zh/sql_reference/data_types/special_data_types/nothing.md b/docs/zh/sql_reference/data_types/special_data_types/nothing.md deleted file mode 100644 index ebc2b572983..00000000000 --- a/docs/zh/sql_reference/data_types/special_data_types/nothing.md +++ /dev/null @@ -1,20 +0,0 @@ - -# 没什么 {#nothing} - -此数据类型的唯一目的是表示不是期望值的情况。 所以不能创建一个 `Nothing` 类型的值。 - -例如,文本 [NULL](../../../sql_reference/data_types/special_data_types/nothing.md#null-literal) 的类型为 `Nullable(Nothing)`。详情请见 [可为空](../../../sql_reference/data_types/special_data_types/nothing.md)。 - -`Nothing` 类型也可以用来表示空数组: - -``` bash -:) SELECT toTypeName(array()) - -SELECT toTypeName([]) - -┌─toTypeName(array())─┐ -│ Array(Nothing) │ -└─────────────────────┘ - -1 rows in set. Elapsed: 0.062 sec. -``` diff --git a/docs/zh/sql_reference/data_types/special_data_types/set.md b/docs/zh/sql_reference/data_types/special_data_types/set.md deleted file mode 100644 index 0e1f9c6cc35..00000000000 --- a/docs/zh/sql_reference/data_types/special_data_types/set.md +++ /dev/null @@ -1,4 +0,0 @@ - -# 设置 {#set} - -可以用在 IN 表达式的右半部分。 diff --git a/docs/zh/sql_reference/data_types/string.md b/docs/zh/sql_reference/data_types/string.md deleted file mode 100644 index 3c9226787a2..00000000000 --- a/docs/zh/sql_reference/data_types/string.md +++ /dev/null @@ -1,11 +0,0 @@ - -# 字符串 {#string} - -字符串可以任意长度的。它可以包含任意的字节集,包含空字节。因此,字符串类型可以代替其他 DBMSs 中的 VARCHAR、BLOB、CLOB 等类型。 - -## 编码 {#bian-ma} - -ClickHouse 没有编码的概念。字符串可以是任意的字节集,按它们原本的方式进行存储和输出。 -若需存储文本,我们建议使用 UTF-8 编码。至少,如果你的终端使用UTF-8(推荐),这样读写就不需要进行任何的转换了。 -同样,对不同的编码文本 ClickHouse 会有不同处理字符串的函数。 -比如,`length` 函数可以计算字符串包含的字节数组的长度,然而 `lengthUTF8` 函数是假设字符串以 UTF-8 编码,计算的是字符串包含的 Unicode 字符的长度。 diff --git a/docs/zh/sql_reference/data_types/tuple.md b/docs/zh/sql_reference/data_types/tuple.md deleted file mode 100644 index e3520722c97..00000000000 --- a/docs/zh/sql_reference/data_types/tuple.md +++ /dev/null @@ -1,46 +0,0 @@ - -# Tuple(T1, T2, …) {#tuplet1-t2} - -元组,其中每个元素都有单独的 [类型](index.md#data_types)。 - -不能在表中存储元组(除了内存表)。它们可以用于临时列分组。在查询中,IN 表达式和带特定参数的 lambda 函数可以来对临时列进行分组。更多信息,请参阅 [IN 操作符](../../sql_reference/data_types/tuple.md) 和 [高阶函数](../../sql_reference/data_types/tuple.md)。 - -元组可以是查询的结果。在这种情况下,对于JSON以外的文本格式,括号中的值是逗号分隔的。在JSON格式中,元组作为数组输出(在方括号中)。 - -## 创建元组 {#chuang-jian-yuan-zu} - -可以使用函数来创建元组: - - tuple(T1, T2, ...) - -创建元组的示例: - - :) SELECT tuple(1,'a') AS x, toTypeName(x) - - SELECT - (1, 'a') AS x, - toTypeName(x) - - ┌─x───────┬─toTypeName(tuple(1, 'a'))─┐ - │ (1,'a') │ Tuple(UInt8, String) │ - └─────────┴───────────────────────────┘ - - 1 rows in set. Elapsed: 0.021 sec. - -## 元组中的数据类型 {#yuan-zu-zhong-de-shu-ju-lei-xing} - -在动态创建元组时,ClickHouse 会自动为元组的每一个参数赋予最小可表达的类型。如果参数为 [NULL](../../sql_reference/data_types/tuple.md#null-literal),那这个元组对应元素是 [可为空](nullable.md)。 - -自动数据类型检测示例: - - SELECT tuple(1, NULL) AS x, toTypeName(x) - - SELECT - (1, NULL) AS x, - toTypeName(x) - - ┌─x────────┬─toTypeName(tuple(1, NULL))──────┐ - │ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │ - └──────────┴─────────────────────────────────┘ - - 1 rows in set. Elapsed: 0.002 sec. diff --git a/docs/zh/sql_reference/data_types/uuid.md b/docs/zh/sql_reference/data_types/uuid.md deleted file mode 100644 index 4c35fcf2d9c..00000000000 --- a/docs/zh/sql_reference/data_types/uuid.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 46 -toc_title: UUID ---- - -# UUID {#uuid-data-type} - -通用唯一标识符(UUID)是用于标识记录的16字节数。 有关UUID的详细信息,请参阅 [维基百科](https://en.wikipedia.org/wiki/Universally_unique_identifier). - -UUID类型值的示例如下所示: - -``` text -61f0c404-5cb3-11e7-907b-a6006ad3dba0 -``` - -如果在插入新记录时未指定UUID列值,则UUID值将用零填充: - -``` text -00000000-0000-0000-0000-000000000000 -``` - -## 如何生成 {#how-to-generate} - -要生成UUID值,ClickHouse提供了 [generateuidv4](../../sql_reference/functions/uuid_functions.md) 功能。 - -## 用法示例 {#usage-example} - -**示例1** - -此示例演示如何创建具有UUID类型列的表并将值插入到表中。 - -``` sql -CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog -``` - -``` sql -INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1' -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -└──────────────────────────────────────┴───────────┘ -``` - -**示例2** - -在此示例中,插入新记录时未指定UUID列值。 - -``` sql -INSERT INTO t_uuid (y) VALUES ('Example 2') -``` - -``` sql -SELECT * FROM t_uuid -``` - -``` text -┌────────────────────────────────────x─┬─y─────────┐ -│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │ -│ 00000000-0000-0000-0000-000000000000 │ Example 2 │ -└──────────────────────────────────────┴───────────┘ -``` - -## 限制 {#restrictions} - -UUID数据类型仅支持以下功能 [字符串](string.md) 数据类型也支持(例如, [min](../../sql_reference/aggregate_functions/reference.md#agg_function-min), [max](../../sql_reference/aggregate_functions/reference.md#agg_function-max),和 [计数](../../sql_reference/aggregate_functions/reference.md#agg_function-count)). - -算术运算不支持UUID数据类型(例如, [abs](../../sql_reference/functions/arithmetic_functions.md#arithm_func-abs))或聚合函数,例如 [sum](../../sql_reference/aggregate_functions/reference.md#agg_function-sum) 和 [avg](../../sql_reference/aggregate_functions/reference.md#agg_function-avg). - -[原始文章](https://clickhouse.tech/docs/en/data_types/uuid/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts.md deleted file mode 100644 index afbdd082576..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 39 -toc_title: "\u6982\u8FF0" ---- - -# 外部字典 {#dicts-external-dicts} - -您可以从各种数据源添加自己的字典。 字典的数据源可以是本地文本或可执行文件、HTTP(s)资源或其他DBMS。 有关详细信息,请参阅 “[外部字典的来源](external_dicts_dict_sources.md)”. - -ClickHouse: - -- 完全或部分存储在RAM中的字典。 -- 定期更新字典并动态加载缺失的值。 换句话说,字典可以动态加载。 -- 允许创建外部字典与xml文件或 [DDL查询](../../statements/create.md#create-dictionary-query). - -外部字典的配置可以位于一个或多个xml文件中。 配置的路径在指定 [dictionaries\_config](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_config) 参数。 - -字典可以在服务器启动或首次使用时加载,具体取决于 [dictionaries\_lazy\_load](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) 设置。 - -字典配置文件具有以下格式: - -``` xml - - An optional element with any content. Ignored by the ClickHouse server. - - - /etc/metrika.xml - - - - - - - - -``` - -你可以 [配置](external_dicts_dict.md) 同一文件中的任意数量的字典。 - -[字典的DDL查询](../../statements/create.md#create-dictionary-query) 在服务器配置中不需要任何其他记录。 它们允许使用字典作为一流的实体,如表或视图。 - -!!! attention "注意" - 您可以通过在一个小字典中描述它来转换小字典的值 `SELECT` 查询(见 [变换](../../../sql_reference/functions/other_functions.md) 功能)。 此功能与外部字典无关。 - -## 另请参阅 {#ext-dicts-see-also} - -- [配置外部字典](external_dicts_dict.md) -- [在内存中存储字典](external_dicts_dict_layout.md) -- [字典更新](external_dicts_dict_lifetime.md) -- [外部字典的来源](external_dicts_dict_sources.md) -- [字典键和字段](external_dicts_dict_structure.md) -- [使用外部字典的函数](../../../sql_reference/functions/ext_dict_functions.md) - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md deleted file mode 100644 index df64d31d2a9..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 40 -toc_title: "\u914D\u7F6E\u5916\u90E8\u5B57\u5178" ---- - -# 配置外部字典 {#dicts-external-dicts-dict} - -如果使用xml文件配置字典,则比字典配置具有以下结构: - -``` xml - - dict_name - - - - - - - - - - - - - - - - - -``` - -相应的 [DDL-查询](../../statements/create.md#create-dictionary-query) 具有以下结构: - -``` sql -CREATE DICTIONARY dict_name -( - ... -- attributes -) -PRIMARY KEY ... -- complex or single key configuration -SOURCE(...) -- Source configuration -LAYOUT(...) -- Memory layout configuration -LIFETIME(...) -- Lifetime of dictionary in memory -``` - -- `name` – The identifier that can be used to access the dictionary. Use the characters `[a-zA-Z0-9_\-]`. -- [来源](external_dicts_dict_sources.md) — Source of the dictionary. -- [布局](external_dicts_dict_layout.md) — Dictionary layout in memory. -- [结构](external_dicts_dict_structure.md) — Structure of the dictionary . A key and attributes that can be retrieved by this key. -- [使用寿命](external_dicts_dict_lifetime.md) — Frequency of dictionary updates. - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md deleted file mode 100644 index 925e5f6c8f4..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_hierarchical.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 45 -toc_title: "\u5206\u5C42\u5B57\u5178" ---- - -# 分层字典 {#hierarchical-dictionaries} - -ClickHouse支持分层字典与 [数字键](external_dicts_dict_structure.md#ext_dict-numeric-key). - -看看下面的层次结构: - -``` text -0 (Common parent) -│ -├── 1 (Russia) -│ │ -│ └── 2 (Moscow) -│ │ -│ └── 3 (Center) -│ -└── 4 (Great Britain) - │ - └── 5 (London) -``` - -这种层次结构可以表示为下面的字典表。 - -| region\_id | parent\_region | region\_name | -|------------|----------------|--------------| -| 1 | 0 | 俄罗斯 | -| 2 | 1 | 莫斯科 | -| 3 | 2 | 中心 | -| 4 | 0 | 英国 | -| 5 | 4 | 伦敦 | - -此表包含一列 `parent_region` 包含该元素的最近父项的键。 - -ClickHouse支持 [等级](external_dicts_dict_structure.md#hierarchical-dict-attr) 属性为 [外部字典](index.md) 属性。 此属性允许您配置类似于上述的分层字典。 - -该 [独裁主义](../../../sql_reference/functions/ext_dict_functions.md#dictgethierarchy) 函数允许您获取元素的父链。 - -对于我们的例子,dictionary的结构可以是以下内容: - -``` xml - - - - region_id - - - - parent_region - UInt64 - 0 - true - - - - region_name - String - - - - - -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_hierarchical/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md deleted file mode 100644 index 4dcf5f4c1b0..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_layout.md +++ /dev/null @@ -1,373 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 41 -toc_title: "\u5728\u5185\u5B58\u4E2D\u5B58\u50A8\u5B57\u5178" ---- - -# 在内存中存储字典 {#dicts-external-dicts-dict-layout} - -有多种方法可以将字典存储在内存中。 - -我们建议 [平](#flat), [散列](#dicts-external_dicts_dict_layout-hashed) 和 [complex\_key\_hashed](#complex-key-hashed). 其提供最佳的处理速度。 - -不建议使用缓存,因为性能可能较差,并且难以选择最佳参数。 阅读更多的部分 “[缓存](#cache)”. - -有几种方法可以提高字典性能: - -- 调用该函数以使用后的字典 `GROUP BY`. -- 将要提取的属性标记为"注射"。 如果不同的属性值对应于不同的键,则称为注射属性。 所以当 `GROUP BY` 使用由键获取属性值的函数,此函数会自动取出 `GROUP BY`. - -ClickHouse为字典中的错误生成异常。 错误示例: - -- 无法加载正在访问的字典。 -- 查询错误 `cached` 字典 - -您可以查看外部字典的列表及其状态 `system.dictionaries` 桌子 - -配置如下所示: - -``` xml - - - ... - - - - - - ... - - -``` - -相应的 [DDL-查询](../../statements/create.md#create-dictionary-query): - -``` sql -CREATE DICTIONARY (...) -... -LAYOUT(LAYOUT_TYPE(param value)) -- layout settings -... -``` - -## 在内存中存储字典的方法 {#ways-to-store-dictionaries-in-memory} - -- [平](#flat) -- [散列](#dicts-external_dicts_dict_layout-hashed) -- [sparse\_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) -- [缓存](#cache) -- [range\_hashed](#range-hashed) -- [complex\_key\_hashed](#complex-key-hashed) -- [complex\_key\_cache](#complex-key-cache) -- [ip\_trie](#ip-trie) - -### 平 {#flat} - -字典以平面数组的形式完全存储在内存中。 字典使用多少内存? 量与最大键的大小(在使用的空间中)成正比。 - -字典键具有 `UInt64` 类型和值限制为500,000。 如果在创建字典时发现较大的键,ClickHouse将引发异常,不会创建字典。 - -支持所有类型的来源。 更新时,数据(来自文件或表)将完整读取。 - -此方法在存储字典的所有可用方法中提供了最佳性能。 - -配置示例: - -``` xml - - - -``` - -或 - -``` sql -LAYOUT(FLAT()) -``` - -### 散列 {#dicts-external_dicts_dict_layout-hashed} - -该字典以哈希表的形式完全存储在内存中。 字典中可以包含任意数量的带有任意标识符的元素,在实践中,键的数量可以达到数千万项。 - -支持所有类型的来源。 更新时,数据(来自文件或表)将完整读取。 - -配置示例: - -``` xml - - - -``` - -或 - -``` sql -LAYOUT(HASHED()) -``` - -### sparse\_hashed {#dicts-external_dicts_dict_layout-sparse_hashed} - -类似于 `hashed`,但使用更少的内存,有利于更多的CPU使用率。 - -配置示例: - -``` xml - - - -``` - -``` sql -LAYOUT(SPARSE_HASHED()) -``` - -### complex\_key\_hashed {#complex-key-hashed} - -这种类型的存储是用于复合 [键](external_dicts_dict_structure.md). 类似于 `hashed`. - -配置示例: - -``` xml - - - -``` - -``` sql -LAYOUT(COMPLEX_KEY_HASHED()) -``` - -### range\_hashed {#range-hashed} - -字典以哈希表的形式存储在内存中,其中包含有序范围及其相应值的数组。 - -此存储方法的工作方式与散列方式相同,除了键之外,还允许使用日期/时间(任意数字类型)范围。 - -示例:该表格包含每个广告客户的折扣,格式为: - -``` text -+---------|-------------|-------------|------+ -| advertiser id | discount start date | discount end date | amount | -+===============+=====================+===================+========+ -| 123 | 2015-01-01 | 2015-01-15 | 0.15 | -+---------|-------------|-------------|------+ -| 123 | 2015-01-16 | 2015-01-31 | 0.25 | -+---------|-------------|-------------|------+ -| 456 | 2015-01-01 | 2015-01-15 | 0.05 | -+---------|-------------|-------------|------+ -``` - -要对日期范围使用示例,请定义 `range_min` 和 `range_max` 中的元素 [结构](external_dicts_dict_structure.md). 这些元素必须包含元素 `name` 和`type` (如果 `type` 如果没有指定,则默认类型将使用-Date)。 `type` 可以是任何数字类型(Date/DateTime/UInt64/Int32/others)。 - -示例: - -``` xml - - - Id - - - first - Date - - - last - Date - - ... -``` - -或 - -``` sql -CREATE DICTIONARY somedict ( - id UInt64, - first Date, - last Date -) -PRIMARY KEY id -LAYOUT(RANGE_HASHED()) -RANGE(MIN first MAX last) -``` - -要使用这些字典,您需要将附加参数传递给 `dictGetT` 函数,为其选择一个范围: - -``` sql -dictGetT('dict_name', 'attr_name', id, date) -``` - -此函数返回指定的值 `id`s和包含传递日期的日期范围。 - -算法的详细信息: - -- 如果 `id` 未找到或范围未找到 `id`,它返回字典的默认值。 -- 如果存在重叠范围,则可以使用任意范围。 -- 如果范围分隔符是 `NULL` 或无效日期(如1900-01-01或2039-01-01),范围保持打开状态。 范围可以在两侧打开。 - -配置示例: - -``` xml - - - - ... - - - - - - - - Abcdef - - - StartTimeStamp - UInt64 - - - EndTimeStamp - UInt64 - - - XXXType - String - - - - - - -``` - -或 - -``` sql -CREATE DICTIONARY somedict( - Abcdef UInt64, - StartTimeStamp UInt64, - EndTimeStamp UInt64, - XXXType String DEFAULT '' -) -PRIMARY KEY Abcdef -RANGE(MIN StartTimeStamp MAX EndTimeStamp) -``` - -### 缓存 {#cache} - -字典存储在具有固定数量的单元格的缓存中。 这些单元格包含经常使用的元素。 - -搜索字典时,首先搜索缓存。 对于每个数据块,所有在缓存中找不到或过期的密钥都从源请求,使用 `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)`. 然后将接收到的数据写入高速缓存。 - -对于缓存字典,过期 [使用寿命](external_dicts_dict_lifetime.md) 可以设置高速缓存中的数据。 如果更多的时间比 `lifetime` 自从在单元格中加载数据以来,单元格的值不被使用,并且在下次需要使用时重新请求它。 -这是存储字典的所有方法中最不有效的。 缓存的速度在很大程度上取决于正确的设置和使用场景。 缓存类型字典只有在命中率足够高(推荐99%或更高)时才能表现良好。 您可以查看平均命中率 `system.dictionaries` 桌子 - -要提高缓存性能,请使用以下子查询 `LIMIT`,并从外部调用字典函数。 - -支持 [来源](external_dicts_dict_sources.md):MySQL的,ClickHouse的,可执行文件,HTTP. - -设置示例: - -``` xml - - - - 1000000000 - - -``` - -或 - -``` sql -LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) -``` - -设置足够大的缓存大小。 你需要尝试选择细胞的数量: - -1. 设置一些值。 -2. 运行查询,直到缓存完全满。 -3. 使用评估内存消耗 `system.dictionaries` 桌子 -4. 增加或减少单元数,直到达到所需的内存消耗。 - -!!! warning "警告" - 不要使用ClickHouse作为源,因为处理随机读取的查询速度很慢。 - -### complex\_key\_cache {#complex-key-cache} - -这种类型的存储是用于复合 [键](external_dicts_dict_structure.md). 类似于 `cache`. - -### ip\_trie {#ip-trie} - -这种类型的存储用于将网络前缀(IP地址)映射到ASN等元数据。 - -示例:该表包含网络前缀及其对应的AS号码和国家代码: - -``` text - +-----------|-----|------+ - | prefix | asn | cca2 | - +=================+=======+========+ - | 202.79.32.0/20 | 17501 | NP | - +-----------|-----|------+ - | 2620:0:870::/48 | 3856 | US | - +-----------|-----|------+ - | 2a02:6b8:1::/48 | 13238 | RU | - +-----------|-----|------+ - | 2001:db8::/32 | 65536 | ZZ | - +-----------|-----|------+ -``` - -使用此类布局时,结构必须具有复合键。 - -示例: - -``` xml - - - - prefix - String - - - - asn - UInt32 - - - - cca2 - String - ?? - - ... -``` - -或 - -``` sql -CREATE DICTIONARY somedict ( - prefix String, - asn UInt32, - cca2 String DEFAULT '??' -) -PRIMARY KEY prefix -``` - -该键必须只有一个包含允许的IP前缀的字符串类型属性。 还不支持其他类型。 - -对于查询,必须使用相同的函数 (`dictGetT` 与元组)至于具有复合键的字典: - -``` sql -dictGetT('dict_name', 'attr_name', tuple(ip)) -``` - -该函数采用任一 `UInt32` 对于IPv4,或 `FixedString(16)` 碌莽禄Ipv6拢IPv6: - -``` sql -dictGetString('prefix', 'asn', tuple(IPv6StringToNum('2001:db8::1'))) -``` - -还不支持其他类型。 该函数返回与此IP地址对应的前缀的属性。 如果有重叠的前缀,则返回最具体的前缀。 - -数据存储在一个 `trie`. 它必须完全适合RAM。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_layout/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md deleted file mode 100644 index 66ff7124ba1..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_lifetime.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 42 -toc_title: "\u5B57\u5178\u66F4\u65B0" ---- - -# 字典更新 {#dictionary-updates} - -ClickHouse定期更新字典。 完全下载字典的更新间隔和缓存字典的无效间隔在 `` 在几秒钟内标记。 - -字典更新(除首次使用的加载之外)不会阻止查询。 在更新期间,将使用旧版本的字典。 如果在更新过程中发生错误,则将错误写入服务器日志,并使用旧版本的字典继续查询。 - -设置示例: - -``` xml - - ... - 300 - ... - -``` - -``` sql -CREATE DICTIONARY (...) -... -LIFETIME(300) -... -``` - -设置 `0` (`LIFETIME(0)`)防止字典更新。 - -您可以设置升级的时间间隔,ClickHouse将在此范围内选择一个统一的随机时间。 为了在大量服务器上升级时分配字典源上的负载,这是必要的。 - -设置示例: - -``` xml - - ... - - 300 - 360 - - ... - -``` - -或 - -``` sql -LIFETIME(MIN 300 MAX 360) -``` - -升级字典时,ClickHouse服务器根据字典的类型应用不同的逻辑 [来源](external_dicts_dict_sources.md): - -- 对于文本文件,它检查修改的时间。 如果时间与先前记录的时间不同,则更新字典。 -- 对于MyISAM表,修改的时间使用检查 `SHOW TABLE STATUS` 查询。 -- 默认情况下,每次都会更新来自其他来源的字典。 - -对于MySQL(InnoDB),ODBC和ClickHouse源代码,您可以设置一个查询,只有在字典真正改变时才会更新字典,而不是每次都更新。 为此,请按照下列步骤操作: - -- 字典表必须具有在源数据更新时始终更改的字段。 -- 源的设置必须指定检索更改字段的查询。 ClickHouse服务器将查询结果解释为一行,如果此行相对于其以前的状态发生了更改,则更新字典。 指定查询 `` 字段中的设置 [来源](external_dicts_dict_sources.md). - -设置示例: - -``` xml - - ... - - ... - SELECT update_time FROM dictionary_source where id = 1 - - ... - -``` - -或 - -``` sql -... -SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source where id = 1')) -... -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_lifetime/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md deleted file mode 100644 index c8173749b33..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md +++ /dev/null @@ -1,608 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 43 -toc_title: "\u5916\u90E8\u5B57\u5178\u7684\u6765\u6E90" ---- - -# 外部字典的来源 {#dicts-external-dicts-dict-sources} - -外部字典可以从许多不同的来源连接。 - -如果使用xml-file配置字典,则配置如下所示: - -``` xml - - - ... - - - - - - ... - - ... - -``` - -在情况下 [DDL-查询](../../statements/create.md#create-dictionary-query),相等的配置将看起来像: - -``` sql -CREATE DICTIONARY dict_name (...) -... -SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration -... -``` - -源配置在 `source` 科。 - -来源类型 (`source_type`): - -- [本地文件](#dicts-external_dicts_dict_sources-local_file) -- [可执行文件](#dicts-external_dicts_dict_sources-executable) -- [HTTP(s)](#dicts-external_dicts_dict_sources-http) -- DBMS - - [ODBC](#dicts-external_dicts_dict_sources-odbc) - - [MySQL](#dicts-external_dicts_dict_sources-mysql) - - [ClickHouse](#dicts-external_dicts_dict_sources-clickhouse) - - [MongoDB](#dicts-external_dicts_dict_sources-mongodb) - - [Redis](#dicts-external_dicts_dict_sources-redis) - -## 本地文件 {#dicts-external_dicts_dict_sources-local_file} - -设置示例: - -``` xml - - - /opt/dictionaries/os.tsv - TabSeparated - - -``` - -或 - -``` sql -SOURCE(FILE(path '/opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -设置字段: - -- `path` – The absolute path to the file. -- `format` – The file format. All the formats described in “[格式](../../../interfaces/formats.md#formats)” 支持。 - -## 可执行文件 {#dicts-external_dicts_dict_sources-executable} - -使用可执行文件取决于 [字典如何存储在内存中](external_dicts_dict_layout.md). 如果字典存储使用 `cache` 和 `complex_key_cache`,ClickHouse通过向可执行文件的STDIN发送请求来请求必要的密钥。 否则,ClickHouse将启动可执行文件并将其输出视为字典数据。 - -设置示例: - -``` xml - - - cat /opt/dictionaries/os.tsv - TabSeparated - - -``` - -或 - -``` sql -SOURCE(EXECUTABLE(command 'cat /opt/dictionaries/os.tsv' format 'TabSeparated')) -``` - -设置字段: - -- `command` – The absolute path to the executable file, or the file name (if the program directory is written to `PATH`). -- `format` – The file format. All the formats described in “[格式](../../../interfaces/formats.md#formats)” 支持。 - -## Http(s) {#dicts-external_dicts_dict_sources-http} - -使用HTTP(s)服务器取决于 [字典如何存储在内存中](external_dicts_dict_layout.md). 如果字典存储使用 `cache` 和 `complex_key_cache`,ClickHouse通过通过发送请求请求必要的密钥 `POST` 方法。 - -设置示例: - -``` xml - - - http://[::1]/os.tsv - TabSeparated - - user - password - - -
- API-KEY - key -
-
-
- -``` - -或 - -``` sql -SOURCE(HTTP( - url 'http://[::1]/os.tsv' - format 'TabSeparated' - credentials(user 'user' password 'password') - headers(header(name 'API-KEY' value 'key')) -)) -``` - -为了让ClickHouse访问HTTPS资源,您必须 [配置openSSL](../../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-openssl) 在服务器配置中。 - -设置字段: - -- `url` – The source URL. -- `format` – The file format. All the formats described in “[格式](../../../interfaces/formats.md#formats)” 支持。 -- `credentials` – Basic HTTP authentication. Optional parameter. - - `user` – Username required for the authentication. - - `password` – Password required for the authentication. -- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter. - - `header` – Single HTTP header entry. - - `name` – Identifiant name used for the header send on the request. - - `value` – Value set for a specific identifiant name. - -## ODBC {#dicts-external_dicts_dict_sources-odbc} - -您可以使用此方法连接具有ODBC驱动程序的任何数据库。 - -设置示例: - -``` xml - - - DatabaseName - ShemaName.TableName
- DSN=some_parameters - SQL_QUERY -
- -``` - -或 - -``` sql -SOURCE(ODBC( - db 'DatabaseName' - table 'SchemaName.TableName' - connection_string 'DSN=some_parameters' - invalidate_query 'SQL_QUERY' -)) -``` - -设置字段: - -- `db` – Name of the database. Omit it if the database name is set in the `` 参数。 -- `table` – Name of the table and schema if exists. -- `connection_string` – Connection string. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [更新字典](external_dicts_dict_lifetime.md). - -ClickHouse接收来自ODBC-driver的引用符号,并将查询中的所有设置引用到driver,因此有必要根据数据库中的表名大小写设置表名。 - -如果您在使用Oracle时遇到编码问题,请参阅相应的 [FAQ](../../../faq/general.md#oracle-odbc-encodings) 文章. - -### ODBC字典功能的已知漏洞 {#known-vulnerability-of-the-odbc-dictionary-functionality} - -!!! attention "注意" - 通过ODBC驱动程序连接参数连接到数据库时 `Servername` 可以取代。 在这种情况下,值 `USERNAME` 和 `PASSWORD` 从 `odbc.ini` 被发送到远程服务器,并且可能会受到损害。 - -**不安全使用示例** - -让我们为PostgreSQL配置unixODBC。 的内容 `/etc/odbc.ini`: - -``` text -[gregtest] -Driver = /usr/lib/psqlodbca.so -Servername = localhost -PORT = 5432 -DATABASE = test_db -#OPTION = 3 -USERNAME = test -PASSWORD = test -``` - -如果然后进行查询,例如 - -``` sql -SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); -``` - -ODBC驱动程序将发送的值 `USERNAME` 和 `PASSWORD` 从 `odbc.ini` 到 `some-server.com`. - -### 连接Postgresql的示例 {#example-of-connecting-postgresql} - -Ubuntu操作系统。 - -为PostgreSQL安装unixODBC和ODBC驱动程序: - -``` bash -$ sudo apt-get install -y unixodbc odbcinst odbc-postgresql -``` - -配置 `/etc/odbc.ini` (或 `~/.odbc.ini`): - -``` text - [DEFAULT] - Driver = myconnection - - [myconnection] - Description = PostgreSQL connection to my_db - Driver = PostgreSQL Unicode - Database = my_db - Servername = 127.0.0.1 - UserName = username - Password = password - Port = 5432 - Protocol = 9.3 - ReadOnly = No - RowVersioning = No - ShowSystemTables = No - ConnSettings = -``` - -ClickHouse中的字典配置: - -``` xml - - - table_name - - - - - DSN=myconnection - postgresql_table
-
- - - 300 - 360 - - - - - - - id - - - some_column - UInt64 - 0 - - -
-
-``` - -或 - -``` sql -CREATE DICTIONARY table_name ( - id UInt64, - some_column UInt64 DEFAULT 0 -) -PRIMARY KEY id -SOURCE(ODBC(connection_string 'DSN=myconnection' table 'postgresql_table')) -LAYOUT(HASHED()) -LIFETIME(MIN 300 MAX 360) -``` - -您可能需要编辑 `odbc.ini` 使用驱动程序指定库的完整路径 `DRIVER=/usr/local/lib/psqlodbcw.so`. - -### 连接MS SQL Server的示例 {#example-of-connecting-ms-sql-server} - -Ubuntu操作系统。 - -安装驱动程序: : - -``` bash -$ sudo apt-get install tdsodbc freetds-bin sqsh -``` - -配置驱动程序: - -``` bash - $ cat /etc/freetds/freetds.conf - ... - - [MSSQL] - host = 192.168.56.101 - port = 1433 - tds version = 7.0 - client charset = UTF-8 - - $ cat /etc/odbcinst.ini - ... - - [FreeTDS] - Description = FreeTDS - Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so - Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so - FileUsage = 1 - UsageCount = 5 - - $ cat ~/.odbc.ini - ... - - [MSSQL] - Description = FreeTDS - Driver = FreeTDS - Servername = MSSQL - Database = test - UID = test - PWD = test - Port = 1433 -``` - -在ClickHouse中配置字典: - -``` xml - - - test - - - dict
- DSN=MSSQL;UID=test;PWD=test -
- - - - 300 - 360 - - - - - - - - - k - - - s - String - - - -
-
-``` - -或 - -``` sql -CREATE DICTIONARY test ( - k UInt64, - s String DEFAULT '' -) -PRIMARY KEY k -SOURCE(ODBC(table 'dict' connection_string 'DSN=MSSQL;UID=test;PWD=test')) -LAYOUT(FLAT()) -LIFETIME(MIN 300 MAX 360) -``` - -## DBMS {#dbms} - -### Mysql {#dicts-external_dicts_dict_sources-mysql} - -设置示例: - -``` xml - - - 3306 - clickhouse - qwerty - - example01-1 - 1 - - - example01-2 - 1 - - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -或 - -``` sql -SOURCE(MYSQL( - port 3306 - user 'clickhouse' - password 'qwerty' - replica(host 'example01-1' priority 1) - replica(host 'example01-2' priority 1) - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -设置字段: - -- `port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside ``). - -- `user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside ``). - -- `replica` – Section of replica configurations. There can be multiple sections. - - - `replica/host` – The MySQL host. - - `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority. - -- `db` – Name of the database. - -- `table` – Name of the table. - -- `where` – The selection criteria. The syntax for conditions is the same as for `WHERE` 例如,mysql中的子句, `id > 10 AND id < 20`. 可选参数。 - -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [更新字典](external_dicts_dict_lifetime.md). - -MySQL可以通过套接字在本地主机上连接。 要做到这一点,设置 `host` 和 `socket`. - -设置示例: - -``` xml - - - localhost - /path/to/socket/file.sock - clickhouse - qwerty - db_name - table_name
- id=10 - SQL_QUERY -
- -``` - -或 - -``` sql -SOURCE(MYSQL( - host 'localhost' - socket '/path/to/socket/file.sock' - user 'clickhouse' - password 'qwerty' - db 'db_name' - table 'table_name' - where 'id=10' - invalidate_query 'SQL_QUERY' -)) -``` - -### ClickHouse {#dicts-external_dicts_dict_sources-clickhouse} - -设置示例: - -``` xml - - - example01-01-1 - 9000 - default - - default - ids
- id=10 -
- -``` - -或 - -``` sql -SOURCE(CLICKHOUSE( - host 'example01-01-1' - port 9000 - user 'default' - password '' - db 'default' - table 'ids' - where 'id=10' -)) -``` - -设置字段: - -- `host` – The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [分布](../../../engines/table_engines/special/distributed.md) 表并在后续配置中输入它。 -- `port` – The port on the ClickHouse server. -- `user` – Name of the ClickHouse user. -- `password` – Password of the ClickHouse user. -- `db` – Name of the database. -- `table` – Name of the table. -- `where` – The selection criteria. May be omitted. -- `invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [更新字典](external_dicts_dict_lifetime.md). - -### Mongodb {#dicts-external_dicts_dict_sources-mongodb} - -设置示例: - -``` xml - - - localhost - 27017 - - - test - dictionary_source - - -``` - -或 - -``` sql -SOURCE(MONGO( - host 'localhost' - port 27017 - user '' - password '' - db 'test' - collection 'dictionary_source' -)) -``` - -设置字段: - -- `host` – The MongoDB host. -- `port` – The port on the MongoDB server. -- `user` – Name of the MongoDB user. -- `password` – Password of the MongoDB user. -- `db` – Name of the database. -- `collection` – Name of the collection. - -### Redis {#dicts-external_dicts_dict_sources-redis} - -设置示例: - -``` xml - - - localhost - 6379 - simple - 0 - - -``` - -或 - -``` sql -SOURCE(REDIS( - host 'localhost' - port 6379 - storage_type 'simple' - db_index 0 -)) -``` - -设置字段: - -- `host` – The Redis host. -- `port` – The port on the Redis server. -- `storage_type` – The structure of internal Redis storage using for work with keys. `simple` 适用于简单源和散列单键源, `hash_map` 用于具有两个键的散列源。 不支持具有复杂键的范围源和缓存源。 可以省略,默认值为 `simple`. -- `db_index` – The specific numeric index of Redis logical database. May be omitted, default value is 0. - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_sources/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md deleted file mode 100644 index 0ac0226aa50..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/external_dicts_dict_structure.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 44 -toc_title: "\u5B57\u5178\u952E\u548C\u5B57\u6BB5" ---- - -# 字典键和字段 {#dictionary-key-and-fields} - -该 `` 子句描述可用于查询的字典键和字段。 - -XML描述: - -``` xml - - - - Id - - - - - - - ... - - - -``` - -属性在元素中描述: - -- `` — [键列](external_dicts_dict_structure.md#ext_dict_structure-key). -- `` — [数据列](external_dicts_dict_structure.md#ext_dict_structure-attributes). 可以有多个属性。 - -DDL查询: - -``` sql -CREATE DICTIONARY dict_name ( - Id UInt64, - -- attributes -) -PRIMARY KEY Id -... -``` - -查询正文中描述了属性: - -- `PRIMARY KEY` — [键列](external_dicts_dict_structure.md#ext_dict_structure-key) -- `AttrName AttrType` — [数据列](external_dicts_dict_structure.md#ext_dict_structure-attributes). 可以有多个属性。 - -## 键 {#ext_dict_structure-key} - -ClickHouse支持以下类型的键: - -- 数字键。 `UInt64`. 在定义 `` 标记或使用 `PRIMARY KEY` 关键字。 -- 复合密钥。 组不同类型的值。 在标签中定义 `` 或 `PRIMARY KEY` 关键字。 - -Xml结构可以包含 `` 或 ``. DDL-查询必须包含单个 `PRIMARY KEY`. - -!!! warning "警告" - 不能将键描述为属性。 - -### 数字键 {#ext_dict-numeric-key} - -类型: `UInt64`. - -配置示例: - -``` xml - - Id - -``` - -配置字段: - -- `name` – The name of the column with keys. - -对于DDL-查询: - -``` sql -CREATE DICTIONARY ( - Id UInt64, - ... -) -PRIMARY KEY Id -... -``` - -- `PRIMARY KEY` – The name of the column with keys. - -### 复合密钥 {#composite-key} - -关键可以是一个 `tuple` 从任何类型的字段。 该 [布局](external_dicts_dict_layout.md) 在这种情况下,必须是 `complex_key_hashed` 或 `complex_key_cache`. - -!!! tip "提示" - 复合键可以由单个元素组成。 例如,这使得可以使用字符串作为键。 - -键结构在元素中设置 ``. 键字段的格式与字典的格式相同 [属性](external_dicts_dict_structure.md). 示例: - -``` xml - - - - field1 - String - - - field2 - UInt32 - - ... - -... -``` - -或 - -``` sql -CREATE DICTIONARY ( - field1 String, - field2 String - ... -) -PRIMARY KEY field1, field2 -... -``` - -对于查询 `dictGet*` 函数中,一个元组作为键传递。 示例: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`. - -## 属性 {#ext_dict_structure-attributes} - -配置示例: - -``` xml - - ... - - Name - ClickHouseDataType - - rand64() - true - true - true - - -``` - -或 - -``` sql -CREATE DICTIONARY somename ( - Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID -) -``` - -配置字段: - -| 标签 | 产品描述 | 必填项 | -|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| -| `name` | 列名称。 | 是 | -| `type` | ClickHouse数据类型。
ClickHouse尝试将字典中的值转换为指定的数据类型。 例如,对于MySQL,该字段可能是 `TEXT`, `VARCHAR`,或 `BLOB` 在MySQL源表中,但它可以上传为 `String` 在克里克豪斯
[可为空](../../../sql_reference/data_types/nullable.md) 不支持。 | 是 | -| `null_value` | 非现有元素的默认值。
在示例中,它是一个空字符串。 你不能使用 `NULL` 在这个领域。 | 是 | -| `expression` | [表达式](../../syntax.md#syntax-expressions) ClickHouse对该值执行。
表达式可以是远程SQL数据库中的列名。 因此,您可以使用它为远程列创建别名。

默认值:无表达式。 | 非也。 | -| `hierarchical` | 如果 `true`,该属性包含当前键的父键值。 看 [分层字典](external_dicts_dict_hierarchical.md).

默认值: `false`. | 非也。 | -| `injective` | 标志,显示是否 `id -> attribute` 图像是 [注射](https://en.wikipedia.org/wiki/Injective_function).
如果 `true`,ClickHouse可以自动放置后 `GROUP BY` 子句注入字典的请求。 通常它显着减少了这种请求的数量。

默认值: `false`. | 非也。 | -| `is_object_id` | 显示是否通过以下方式对MongoDB文档执行查询的标志 `ObjectID`.

默认值: `false`. | 非也。 | - -## 另请参阅 {#see-also} - -- [使用外部字典的函数](../../../sql_reference/functions/ext_dict_functions.md). - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/external_dicts_dict_structure/) diff --git a/docs/zh/sql_reference/dictionaries/external_dictionaries/index.md b/docs/zh/sql_reference/dictionaries/external_dictionaries/index.md deleted file mode 100644 index 25d86ecda96..00000000000 --- a/docs/zh/sql_reference/dictionaries/external_dictionaries/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u5916\u90E8\u5B57\u5178" -toc_priority: 37 ---- - - diff --git a/docs/zh/sql_reference/dictionaries/index.md b/docs/zh/sql_reference/dictionaries/index.md deleted file mode 100644 index 9c9817ad0ad..00000000000 --- a/docs/zh/sql_reference/dictionaries/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u5B57\u5178" -toc_priority: 35 -toc_title: "\u5BFC\u8A00" ---- - -# 字典 {#dictionaries} - -字典是一个映射 (`key -> attributes`)这是方便各种类型的参考清单。 - -ClickHouse支持使用可用于查询的字典的特殊功能。 这是更容易和更有效地使用字典与功能比 `JOIN` 与参考表。 - -[NULL](../syntax.md#null) 值不能存储在字典中。 - -ClickHouse支持: - -- [内置字典](internal_dicts.md#internal_dicts) 具有特定的 [功能集](../../sql_reference/functions/ym_dict_functions.md). -- [插件(外部)字典](external_dictionaries/external_dicts.md) 用一个 [职能净额](../../sql_reference/functions/ext_dict_functions.md). - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/) diff --git a/docs/zh/sql_reference/dictionaries/internal_dicts.md b/docs/zh/sql_reference/dictionaries/internal_dicts.md deleted file mode 100644 index bcede3c14ad..00000000000 --- a/docs/zh/sql_reference/dictionaries/internal_dicts.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 39 -toc_title: "\u5185\u90E8\u5B57\u5178" ---- - -# 内部字典 {#internal_dicts} - -ClickHouse包含用于处理地理数据库的内置功能。 - -这使您可以: - -- 使用区域的ID以所需语言获取其名称。 -- 使用区域ID获取城市、地区、联邦区、国家或大陆的ID。 -- 检查一个区域是否属于另一个区域。 -- 获取父区域链。 - -所有功能支持 “translocality,” 能够同时使用不同的角度对区域所有权。 有关详细信息,请参阅部分 “Functions for working with Yandex.Metrica dictionaries”. - -在默认包中禁用内部字典。 -要启用它们,请取消注释参数 `path_to_regions_hierarchy_file` 和 `path_to_regions_names_files` 在服务器配置文件中。 - -Geobase从文本文件加载。 - -将 `regions_hierarchy*.txt` 文件到 `path_to_regions_hierarchy_file` 目录。 此配置参数必须包含指向 `regions_hierarchy.txt` 文件(默认区域层次结构)和其他文件 (`regions_hierarchy_ua.txt`)必须位于同一目录中。 - -把 `regions_names_*.txt` 在文件 `path_to_regions_names_files` 目录。 - -您也可以自己创建这些文件。 文件格式如下: - -`regions_hierarchy*.txt`:TabSeparated(无标题),列: - -- 地区ID (`UInt32`) -- 父区域ID (`UInt32`) -- 区域类型 (`UInt8`):1-大陆,3-国家,4-联邦区,5-地区,6-城市;其他类型没有价值 -- 人口 (`UInt32`) — optional column - -`regions_names_*.txt`:TabSeparated(无标题),列: - -- 地区ID (`UInt32`) -- 地区名称 (`String`) — Can't contain tabs or line feeds, even escaped ones. - -平面阵列用于存储在RAM中。 出于这个原因,Id不应该超过一百万。 - -字典可以在不重新启动服务器的情况下更新。 但是,不会更新可用字典集。 -对于更新,将检查文件修改时间。 如果文件已更改,则更新字典。 -检查更改的时间间隔在 `builtin_dictionaries_reload_interval` 参数。 -字典更新(首次使用时加载除外)不会阻止查询。 在更新期间,查询使用旧版本的字典。 如果在更新过程中发生错误,则将错误写入服务器日志,并使用旧版本的字典继续查询。 - -我们建议定期使用geobase更新字典。 在更新期间,生成新文件并将其写入单独的位置。 一切准备就绪后,将其重命名为服务器使用的文件。 - -还有与操作系统标识符和Yandex的工作功能。Metrica搜索引擎,但他们不应该被使用。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/dicts/internal_dicts/) diff --git a/docs/zh/sql_reference/functions/arithmetic_functions.md b/docs/zh/sql_reference/functions/arithmetic_functions.md deleted file mode 100644 index 66bd42ec63a..00000000000 --- a/docs/zh/sql_reference/functions/arithmetic_functions.md +++ /dev/null @@ -1,77 +0,0 @@ - -# 算术函数 {#suan-zhu-han-shu} - -对于所有算术函数,结果类型为结果适合的最小数字类型(如果存在这样的类型)。最小数字类型是根据数字的位数,是否有符号以及是否是浮点类型而同时进行的。如果没有足够的位,则采用最高位类型。 - -例如: - -``` sql -SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) -``` - - ┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ - │ UInt8 │ UInt16 │ UInt32 │ UInt64 │ - └───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ - -算术函数适用于UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64,Float32或Float64中的任何类型。 - -溢出的产生方式与C++相同。 - -## 加(a,b),a+b {#plusa-b-a-b} - -计算数字的总和。 -您还可以将Date或DateTime与整数进行相加。在Date的情况下,添加的整数意味着添加相应的天数。对于DateTime,这意味这添加相应的描述。 - -## 减(a,b),a-b {#minusa-b-a-b} - -计算数字之间的差,结果总是有符号的。 - -您还可以将Date或DateTime与整数进行相减。见上面的'plus'。 - -## 乘(a,b),a\*b {#multiplya-b-a-b} - -计算数字的乘积。 - -## 除以(a,b),a/b {#dividea-b-a-b} - -计算数字的商。结果类型始终是浮点类型。 -它不是整数除法。对于整数除法,请使用'intDiv'函数。 -当除以零时,你得到'inf',‘- inf’或’nan’。 - -## intDiv(a,b) {#intdiva-b} - -计算整数数字的商,向下舍入(按绝对值)。 -除以零或将最小负数除以-1时抛出异常。 - -## intDivOrZero(a,b) {#intdivorzeroa-b} - -与'intDiv'的不同之处在于它在除以零或将最小负数除以-1时返回零。 - -## 模(a,b),a%b {#moduloa-b-a-b} - -计算除法后的余数。 -如果参数是浮点数,则通过删除小数部分将它们预转换为整数。 -其余部分与C++中的含义相同。截断除法用于负数。 -除以零或将最小负数除以-1时抛出异常。 - -## 否定(a),-a {#negatea-a} - -计算一个数字的 -用反转符号计算一个数字。结果始终是签名的。 -计算具有反向符号的数字。 结果始终签名。 - -## abs(a) {#arithm_func-abs} - -计算数字(a)的绝对值。也就是说,如果a &lt; 0,它返回-a。对于无符号类型,它不执行任何操作。对于有符号整数类型,它返回无符号数。 - -## gcd(a,b) {#gcda-b} - -返回数字的最大公约数。 -除以零或将最小负数除以-1时抛出异常。 - -## lcm(a,b) {#lcma-b} - -返回数字的最小公倍数。 -除以零或将最小负数除以-1时抛出异常。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/arithmetic_functions/) diff --git a/docs/zh/sql_reference/functions/array_functions.md b/docs/zh/sql_reference/functions/array_functions.md deleted file mode 100644 index cb8f7347b72..00000000000 --- a/docs/zh/sql_reference/functions/array_functions.md +++ /dev/null @@ -1,666 +0,0 @@ - -# 数组函数 {#shu-zu-han-shu} - -## 空 {#empty} - -对于空数组返回1,对于非空数组返回0。 -结果类型是UInt8。 -该函数也适用于字符串。 - -## notEmpty {#notempty} - -对于空数组返回0,对于非空数组返回1。 -结果类型是UInt8。 -该函数也适用于字符串。 - -## 长度 {#array_functions-length} - -返回数组中的元素个数。 -结果类型是UInt64。 -该函数也适用于字符串。 - -## emptyArrayUInt8,emptyArrayUInt16,emptyArrayUInt32,emptyArrayUInt64 {#emptyarrayuint8-emptyarrayuint16-emptyarrayuint32-emptyarrayuint64} - -## emptyArrayInt8,emptyArrayInt16,emptyArrayInt32,emptyArrayInt64 {#emptyarrayint8-emptyarrayint16-emptyarrayint32-emptyarrayint64} - -## emptyArrayFloat32,emptyArrayFloat64 {#emptyarrayfloat32-emptyarrayfloat64} - -## 空空漫步,空空漫步时间 {#emptyarraydate-emptyarraydatetime} - -## 空字符串 {#emptyarraystring} - -不接受任何参数并返回适当类型的空数组。 - -## emptyArrayToSingle {#emptyarraytosingle} - -接受一个空数组并返回一个仅包含一个默认值元素的数组。 - -## 范围(N) {#rangen} - -返回从0到N-1的数字数组。 -以防万一,如果在数据块中创建总长度超过100,000,000个元素的数组,则抛出异常。 - -## array(x1, …), operator \[x1, …\] {#arrayx1-operator-x1} - -使用函数的参数作为数组元素创建一个数组。 -参数必须是常量,并且具有最小公共类型的类型。必须至少传递一个参数,否则将不清楚要创建哪种类型的数组。也就是说,你不能使用这个函数来创建一个空数组(为此,使用上面描述的'emptyArray  \*'函数)。 -返回'Array(T)'类型的结果,其中'T'是传递的参数中最小的公共类型。 - -## arrayConcat {#arrayconcat} - -合并参数中传递的所有数组。 - - arrayConcat(arrays) - -**参数** - -- `arrays` – 任意数量的[阵列](../../sql_reference/functions/array_functions.md)类型的参数. - **示例** - - - -``` sql -SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res -``` - - ┌─res───────────┐ - │ [1,2,3,4,5,6] │ - └───────────────┘ - -## arrayElement(arr,n),运算符arr\[n\] {#arrayelementarr-n-operator-arrn} - -从数组`arr`中获取索引为«n»的元素。 `n`必须是任何整数类型。 -数组中的索引从一开始。 -支持负索引。在这种情况下,它选择从末尾开始编号的相应元素。例如,`arr [-1]`是数组中的最后一项。 - -如果索引超出数组的边界,则返回默认值(数字为0,字符串为空字符串等)。 - -## 有(arr,elem) {#hasarr-elem} - -检查'arr'数组是否具有'elem'元素。 -如果元素不在数组中,则返回0;如果在,则返回1。 - -`NULL` 值的处理。 - - SELECT has([1, 2, NULL], NULL) - - ┌─has([1, 2, NULL], NULL)─┐ - │ 1 │ - └─────────────────────────┘ - -## hasAll {#hasall} - -检查一个数组是否是另一个数组的子集。 - - hasAll(set, subset) - -**参数** - -- `set` – 具有一组元素的任何类型的数组。 -- `subset` – 任何类型的数组,其元素应该被测试为`set`的子集。 - -**返回值** - -- `1`, 如果`set`包含`subset`中的所有元素。 -- `0`, 否则。 - -**特殊的定义** - -- 空数组是任何数组的子集。 -- «Null»作为数组中的元素值进行处理。 -- 忽略两个数组中的元素值的顺序。 - -**示例** - -`SELECT hasAll([], [])` 返回1。 - -`SELECT hasAll([1, Null], [Null])` 返回1。 - -`SELECT hasAll([1.0, 2, 3, 4], [1, 3])` 返回1。 - -`SELECT hasAll(['a', 'b'], ['a'])` 返回1。 - -`SELECT hasAll([1], ['a'])` 返回0。 - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])` 返回0。 - -## hasAny {#hasany} - -检查两个数组是否存在交集。 - - hasAny(array1, array2) - -**参数** - -- `array1` – 具有一组元素的任何类型的数组。 -- `array2` – 具有一组元素的任何类型的数组。 - -**返回值** - -- `1`, 如果`array1`和`array2`存在交集。 -- `0`, 否则。 - -**特殊的定义** - -- «Null»作为数组中的元素值进行处理。 -- 忽略两个数组中的元素值的顺序。 - -**示例** - -`SELECT hasAny([1], [])` 返回 `0`. - -`SELECT hasAny([Null], [Null, 1])` 返回 `1`. - -`SELECT hasAny([-128, 1., 512], [1])` 返回 `1`. - -`SELECT hasAny([[1, 2], [3, 4]], ['a', 'c'])` 返回 `0`. - -`SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]])` 返回 `1`. - -## indexOf(arr,x) {#indexofarr-x} - -返回数组中第一个'x'元素的索引(从1开始),如果'x'元素不存在在数组中,则返回0。 - -示例: - - :) SELECT indexOf([1,3,NULL,NULL],NULL) - - SELECT indexOf([1, 3, NULL, NULL], NULL) - - ┌─indexOf([1, 3, NULL, NULL], NULL)─┐ - │ 3 │ - └───────────────────────────────────┘ - -设置为«NULL»的元素将作为普通的元素值处理。 - -## countEqual(arr,x) {#countequalarr-x} - -返回数组中等于x的元素的个数。相当于arrayCount(elem - \> elem = x,arr)。 - -`NULL`值将作为单独的元素值处理。 - -示例: - - SELECT countEqual([1, 2, NULL, NULL], NULL) - - ┌─countEqual([1, 2, NULL, NULL], NULL)─┐ - │ 2 │ - └──────────────────────────────────────┘ - -## ツ暗ェツ氾环催ツ団ツ法ツ人) {#array_functions-arrayenumerate} - -返回 Array \[1, 2, 3, …, length (arr) \] - -此功能通常与ARRAY JOIN一起使用。它允许在应用ARRAY JOIN后为每个数组计算一次。例如: - -``` sql -SELECT - count() AS Reaches, - countIf(num = 1) AS Hits -FROM test.hits -ARRAY JOIN - GoalsReached, - arrayEnumerate(GoalsReached) AS num -WHERE CounterID = 160656 -LIMIT 10 -``` - - ┌─Reaches─┬──Hits─┐ - │ 95606 │ 31406 │ - └─────────┴───────┘ - -在此示例中,Reaches是转换次数(应用ARRAY JOIN后接收的字符串),Hits是浏览量(ARRAY JOIN之前的字符串)。在这种特殊情况下,您可以更轻松地获得相同的结果: - -``` sql -SELECT - sum(length(GoalsReached)) AS Reaches, - count() AS Hits -FROM test.hits -WHERE (CounterID = 160656) AND notEmpty(GoalsReached) -``` - - ┌─Reaches─┬──Hits─┐ - │ 95606 │ 31406 │ - └─────────┴───────┘ - -此功能也可用于高阶函数。例如,您可以使用它来获取与条件匹配的元素的数组索引。 - -## arrayEnumerateUniq(arr, …) {#arrayenumerateuniqarr} - -返回与源数组大小相同的数组,其中每个元素表示与其下标对应的源数组元素在源数组中出现的次数。 -例如:arrayEnumerateUniq( \[10,20,10,30 \])=  \[1,1,2,1 \]。 - -使用ARRAY JOIN和数组元素的聚合时,此函数很有用。 - -示例: - -``` sql -SELECT - Goals.ID AS GoalID, - sum(Sign) AS Reaches, - sumIf(Sign, num = 1) AS Visits -FROM test.visits -ARRAY JOIN - Goals, - arrayEnumerateUniq(Goals.ID) AS num -WHERE CounterID = 160656 -GROUP BY GoalID -ORDER BY Reaches DESC -LIMIT 10 -``` - - ┌──GoalID─┬─Reaches─┬─Visits─┐ - │ 53225 │ 3214 │ 1097 │ - │ 2825062 │ 3188 │ 1097 │ - │ 56600 │ 2803 │ 488 │ - │ 1989037 │ 2401 │ 365 │ - │ 2830064 │ 2396 │ 910 │ - │ 1113562 │ 2372 │ 373 │ - │ 3270895 │ 2262 │ 812 │ - │ 1084657 │ 2262 │ 345 │ - │ 56599 │ 2260 │ 799 │ - │ 3271094 │ 2256 │ 812 │ - └─────────┴─────────┴────────┘ - -在此示例中,每个GoalID都计算转换次数(目标嵌套数据结构中的每个元素都是达到的目标,我们称之为转换)和会话数。如果没有ARRAY JOIN,我们会将会话数计为总和(Sign)。但在这种特殊情况下,行乘以嵌套的Goals结构,因此为了在此之后计算每个会话一次,我们将一个条件应用于arrayEnumerateUniq(Goals.ID)函数的值。 - -arrayEnumerateUniq函数可以使用与参数大小相同的多个数组。在这种情况下,对于所有阵列中相同位置的元素元组,考虑唯一性。 - -``` sql -SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]) AS res -``` - - ┌─res───────────┐ - │ [1,2,1,1,2,1] │ - └───────────────┘ - -当使用带有嵌套数据结构的ARRAY JOIN并在此结构中跨多个元素进一步聚合时,这是必需的。 - -## arrayPopBack {#arraypopback} - -从数组中删除最后一项。 - - arrayPopBack(array) - -**参数** - -- `array` – 数组。 - -**示例** - -``` sql -SELECT arrayPopBack([1, 2, 3]) AS res -``` - - ┌─res───┐ - │ [1,2] │ - └───────┘ - -## arrayPopFront {#arraypopfront} - -从数组中删除第一项。 - - arrayPopFront(array) - -**参数** - -- `array` – 数组。 - -**示例** - -``` sql -SELECT arrayPopFront([1, 2, 3]) AS res -``` - - ┌─res───┐ - │ [2,3] │ - └───────┘ - -## arrayPushBack {#arraypushback} - -添加一个元素到数组的末尾。 - - arrayPushBack(array, single_value) - -**参数** - -- `array` – 数组。 -- `single_value` – 单个值。只能将数字添加到带数字的数组中,并且只能将字符串添加到字符串数组中。添加数字时,ClickHouse会自动为数组的数据类型设置`single_value`类型。有关ClickHouse中数据类型的更多信息,请参阅«[数据类型](../../sql_reference/functions/array_functions.md#data_types)»。可以是'NULL`。该函数向数组添加一个«NULL»元素,数组元素的类型转换为`Nullable\`。 - -**示例** - -``` sql -SELECT arrayPushBack(['a'], 'b') AS res -``` - - ┌─res───────┐ - │ ['a','b'] │ - └───────────┘ - -## arrayPushFront {#arraypushfront} - -将一个元素添加到数组的开头。 - - arrayPushFront(array, single_value) - -**参数** - -- `array` – 数组。 -- `single_value` – 单个值。只能将数字添加到带数字的数组中,并且只能将字符串添加到字符串数组中。添加数字时,ClickHouse会自动为数组的数据类型设置`single_value`类型。有关ClickHouse中数据类型的更多信息,请参阅«[数据类型](../../sql_reference/functions/array_functions.md#data_types)»。可以是'NULL`。该函数向数组添加一个«NULL»元素,数组元素的类型转换为`Nullable\`。 - -**示例** - -``` sql -SELECT arrayPushFront(['b'], 'a') AS res -``` - - ┌─res───────┐ - │ ['a','b'] │ - └───────────┘ - -## arrayResize {#arrayresize} - -更改数组的长度。 - - arrayResize(array, size[, extender]) - -**参数:** - -- `array` — 数组. -- `size` — 数组所需的长度。 - - 如果`size`小于数组的原始大小,则数组将从右侧截断。 -- 如果`size`大于数组的初始大小,则使用`extender`值或数组项的数据类型的默认值将数组扩展到右侧。 -- `extender` — 扩展数组的值。可以是'NULL\`。 - -**返回值:** - -一个`size`长度的数组。 - -**调用示例** - - SELECT arrayResize([1], 3) - - ┌─arrayResize([1], 3)─┐ - │ [1,0,0] │ - └─────────────────────┘ - - SELECT arrayResize([1], 3, NULL) - - ┌─arrayResize([1], 3, NULL)─┐ - │ [1,NULL,NULL] │ - └───────────────────────────┘ - -## arraySlice {#arrayslice} - -返回一个子数组,包含从指定位置的指定长度的元素。 - - arraySlice(array, offset[, length]) - -**参数** - -- `array` – 数组。 -- `offset` – 数组的偏移。正值表示左侧的偏移量,负值表示右侧的缩进值。数组下标从1开始。 -- `length` - 子数组的长度。如果指定负值,则该函数返回`[offset,array_length - length`。如果省略该值,则该函数返回`[offset,the_end_of_array]`。 - -**示例** - -``` sql -SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res -``` - - ┌─res────────┐ - │ [2,NULL,4] │ - └────────────┘ - -设置为«NULL»的数组元素作为普通的数组元素值处理。 - -## arraySort(\[func,\] arr, …) {#array_functions-reverse-sort} - -以升序对`arr`数组的元素进行排序。如果指定了`func`函数,则排序顺序由`func`函数的调用结果决定。如果`func`接受多个参数,那么`arraySort`函数也将解析与`func`函数参数相同数量的数组参数。更详细的示例在`arraySort`的末尾。 - -整数排序示例: - -``` sql -SELECT arraySort([1, 3, 3, 0]); -``` - - ┌─arraySort([1, 3, 3, 0])─┐ - │ [0,1,3,3] │ - └─────────────────────────┘ - -字符串排序示例: - -``` sql -SELECT arraySort(['hello', 'world', '!']); -``` - - ┌─arraySort(['hello', 'world', '!'])─┐ - │ ['!','hello','world'] │ - └────────────────────────────────────┘ - -`NULL`,`NaN`和`Inf`的排序顺序: - -``` sql -SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); -``` - - ┌─arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf])─┐ - │ [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] │ - └───────────────────────────────────────────────────────────┘ - -- `-Inf` 是数组中的第一个。 -- `NULL` 是数组中的最后一个。 -- `NaN` 在`NULL`的前面。 -- `Inf` 在`NaN`的前面。 - -注意:`arraySort`是[高阶函数](higher_order_functions.md)。您可以将lambda函数作为第一个参数传递给它。在这种情况下,排序顺序由lambda函数的调用结果决定。 - -让我们来看一下如下示例: - -``` sql -SELECT arraySort((x) -> -x, [1, 2, 3]) as res; -``` - - ┌─res─────┐ - │ [3,2,1] │ - └─────────┘ - -对于源数组的每个元素,lambda函数返回排序键,即\[1 -\> -1, 2 -\> -2, 3 -\> -3\]。由于`arraySort`函数按升序对键进行排序,因此结果为\[3,2,1\]。因此,`(x) -> -x` lambda函数将排序设置为[降序](#array_functions-reverse-sort)。 - -lambda函数可以接受多个参数。在这种情况下,您需要为`arraySort`传递与lambda参数个数相同的数组。函数使用第一个输入的数组中的元素组成返回结果;使用接下来传入的数组作为排序键。例如: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - - ┌─res────────────────┐ - │ ['world', 'hello'] │ - └────────────────────┘ - -这里,在第二个数组(\[2, 1\])中定义了第一个数组(\[‘hello’,‘world’\])的相应元素的排序键,即\[‘hello’ -\> 2,‘world’ -\> 1\]。 由于lambda函数中没有使用`x`,因此源数组中的实际值不会影响结果的顺序。所以,'world'将是结果中的第一个元素,'hello'将是结果中的第二个元素。 - -其他示例如下所示。 - -``` sql -SELECT arraySort((x, y) -> y, [0, 1, 2], ['c', 'b', 'a']) as res; -``` - -``` sql -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -``` sql -SELECT arraySort((x, y) -> -y, [0, 1, 2], [1, 2, 3]) as res; -``` - -``` sql -┌─res─────┐ -│ [2,1,0] │ -└─────────┘ -``` - -!!! 注意 "注意" - 为了提高排序效率, 使用了[施瓦茨变换](https://en.wikipedia.org/wiki/Schwartzian_transform)。 - -## arrayReverseSort(\[func,\] arr, …) {#array_functions-reverse-sort} - -以降序对`arr`数组的元素进行排序。如果指定了`func`函数,则排序顺序由`func`函数的调用结果决定。如果`func`接受多个参数,那么`arrayReverseSort`函数也将解析与`func`函数参数相同数量的数组作为参数。更详细的示例在`arrayReverseSort`的末尾。 - -整数排序示例: - -``` sql -SELECT arrayReverseSort([1, 3, 3, 0]); -``` - - ┌─arrayReverseSort([1, 3, 3, 0])─┐ - │ [3,3,1,0] │ - └────────────────────────────────┘ - -字符串排序示例: - -``` sql -SELECT arrayReverseSort(['hello', 'world', '!']); -``` - - ┌─arrayReverseSort(['hello', 'world', '!'])─┐ - │ ['world','hello','!'] │ - └───────────────────────────────────────────┘ - -`NULL`,`NaN`和`Inf`的排序顺序: - -``` sql -SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]) as res; -``` - -``` sql -┌─res───────────────────────────────────┐ -│ [inf,3,2,1,-4,-inf,nan,nan,NULL,NULL] │ -└───────────────────────────────────────┘ -``` - -- `Inf` 是数组中的第一个。 -- `NULL` 是数组中的最后一个。 -- `NaN` 在`NULL`的前面。 -- `-Inf` 在`NaN`的前面。 - -注意:`arraySort`是[高阶函数](higher_order_functions.md)。您可以将lambda函数作为第一个参数传递给它。如下示例所示。 - -``` sql -SELECT arrayReverseSort((x) -> -x, [1, 2, 3]) as res; -``` - - ┌─res─────┐ - │ [1,2,3] │ - └─────────┘ - -数组按以下方式排序: -数组按以下方式排序: - -1. 首先,根据lambda函数的调用结果对源数组(\[1, 2, 3\])进行排序。 结果是\[3, 2, 1\]。 -2. 反转上一步获得的数组。 所以,最终的结果是\[1, 2, 3\]。 - -lambda函数可以接受多个参数。在这种情况下,您需要为`arrayReverseSort`传递与lambda参数个数相同的数组。函数使用第一个输入的数组中的元素组成返回结果;使用接下来传入的数组作为排序键。例如: - -``` sql -SELECT arrayReverseSort((x, y) -> y, ['hello', 'world'], [2, 1]) as res; -``` - -``` sql -┌─res───────────────┐ -│ ['hello','world'] │ -└───────────────────┘ -``` - -在这个例子中,数组按以下方式排序: - -1. 首先,根据lambda函数的调用结果对源数组(\[‘hello’,‘world’\])进行排序。 其中,在第二个数组(\[2,1\])中定义了源数组中相应元素的排序键。 所以,排序结果\[‘world’,‘hello’\]。 -2. 反转上一步骤中获得的排序数组。 所以,最终的结果是\[‘hello’,‘world’\]。 - -其他示例如下所示。 - -``` sql -SELECT arrayReverseSort((x, y) -> y, [4, 3, 5], ['a', 'b', 'c']) AS res; -``` - -``` sql -┌─res─────┐ -│ [5,3,4] │ -└─────────┘ -``` - -``` sql -SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; -``` - -``` sql -┌─res─────┐ -│ [4,3,5] │ -└─────────┘ -``` - -## arrayUniq(arr, …) {#arrayuniqarr} - -如果传递一个参数,则计算数组中不同元素的数量。 -如果传递了多个参数,则它计算多个数组中相应位置的不同元素元组的数量。 - -如果要获取数组中唯一项的列表,可以使用arrayReduce(‘groupUniqArray’,arr)。 - -## arryjoin(arr) {#array-functions-join} - -一个特殊的功能。请参见[«ArrayJoin函数»](array_join.md#functions_arrayjoin)部分。 - -## arrayDifference(arr) {#arraydifferencearr} - -返回一个数组,其中包含所有相邻元素对之间的差值。例如: - -``` sql -SELECT arrayDifference([1, 2, 3, 4]) -``` - - ┌─arrayDifference([1, 2, 3, 4])─┐ - │ [0,1,1,1] │ - └───────────────────────────────┘ - -## arrayDistinct(arr) {#arraydistinctarr} - -返回一个包含所有数组中不同元素的数组。例如: - -``` sql -SELECT arrayDistinct([1, 2, 2, 3, 1]) -``` - - ┌─arrayDistinct([1, 2, 2, 3, 1])─┐ - │ [1,2,3] │ - └────────────────────────────────┘ - -## arrayEnumerateDense(arr) {#arrayenumeratedensearr} - -返回与源数组大小相同的数组,指示每个元素首次出现在源数组中的位置。例如:arrayEnumerateDense(\[10,20,10,30\])= \[1,2,1,3\]。 - -## arrayIntersect(arr) {#arrayintersectarr} - -返回所有数组元素的交集。例如: - -``` sql -SELECT - arrayIntersect([1, 2], [1, 3], [2, 3]) AS no_intersect, - arrayIntersect([1, 2], [1, 3], [1, 4]) AS intersect -``` - - ┌─no_intersect─┬─intersect─┐ - │ [] │ [1] │ - └──────────────┴───────────┘ - -## arrayReduce(agg\_func, arr1, …) {#arrayreduceagg-func-arr1} - -将聚合函数应用于数组并返回其结果。如果聚合函数具有多个参数,则此函数可应用于相同大小的多个数组。 - -arrayReduce(‘agg\_func’,arr1,…) - 将聚合函数`agg_func`应用于数组`arr1 ...`。如果传递了多个数组,则相应位置上的元素将作为多个参数传递给聚合函数。例如:SELECT arrayReduce(‘max’,\[1,2,3\])= 3 - -## ツ暗ェツ氾环催ツ団ツ法ツ人) {#arrayreversearr} - -返回与源数组大小相同的数组,包含反转源数组的所有元素的结果。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/array_functions/) diff --git a/docs/zh/sql_reference/functions/array_join.md b/docs/zh/sql_reference/functions/array_join.md deleted file mode 100644 index 1788b44f3e5..00000000000 --- a/docs/zh/sql_reference/functions/array_join.md +++ /dev/null @@ -1,29 +0,0 @@ - -# arrayJoin函数 {#functions_arrayjoin} - -这是一个非常有用的函数。 - -普通函数不会更改结果集的行数,而只是计算每行中的值(map)。 -聚合函数将多行压缩到一行中(fold或reduce)。 -'arrayJoin'函数获取每一行并将他们展开到多行(unfold)。 - -此函数将数组作为参数,并将该行在结果集中复制数组元素个数。 -除了应用此函数的列中的值之外,简单地复制列中的所有值;它被替换为相应的数组值。 - -查询可以使用多个`arrayJoin`函数。在这种情况下,转换被执行多次。 - -请注意SELECT查询中的ARRAY JOIN语法,它提供了更广泛的可能性。 - -示例: - -``` sql -SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src -``` - - ┌─dst─┬─\'Hello\'─┬─src─────┐ - │ 1 │ Hello │ [1,2,3] │ - │ 2 │ Hello │ [1,2,3] │ - │ 3 │ Hello │ [1,2,3] │ - └─────┴───────────┴─────────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/array_join/) diff --git a/docs/zh/sql_reference/functions/bit_functions.md b/docs/zh/sql_reference/functions/bit_functions.md deleted file mode 100644 index 1b280c8babd..00000000000 --- a/docs/zh/sql_reference/functions/bit_functions.md +++ /dev/null @@ -1,30 +0,0 @@ - -# 位操作函数 {#wei-cao-zuo-han-shu} - -位操作函数适用于UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64,Float32或Float64中的任何类型。 - -结果类型是一个整数,其位数等于其参数的最大位。如果至少有一个参数为有符数字,则结果为有符数字。如果参数是浮点数,则将其强制转换为Int64。 - -## bitAnd(a,b) {#bitanda-b} - -## bitOr(a,b) {#bitora-b} - -## bitXor(a,b) {#bitxora-b} - -## bitNot(a) {#bitnota} - -## bitShiftLeft(a,b) {#bitshiftlefta-b} - -## bitShiftRight(a,b) {#bitshiftrighta-b} - -## bitRotateLeft(a,b) {#bitrotatelefta-b} - -## bitRotateRight(a,b) {#bitrotaterighta-b} - -## bitTest(a,b) {#bittesta-b} - -## bitTestAll(a,b) {#bittestalla-b} - -## bitTestAny(a,b) {#bittestanya-b} - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/bit_functions/) diff --git a/docs/zh/sql_reference/functions/bitmap_functions.md b/docs/zh/sql_reference/functions/bitmap_functions.md deleted file mode 100644 index 3415b590644..00000000000 --- a/docs/zh/sql_reference/functions/bitmap_functions.md +++ /dev/null @@ -1,385 +0,0 @@ - -# 位图函数 {#wei-tu-han-shu} - -位图函数用于对两个位图对象进行计算,对于任何一个位图函数,它都将返回一个位图对象,例如and,or,xor,not等等。 - -位图对象有两种构造方法。一个是由聚合函数groupBitmapState构造的,另一个是由Array Object构造的。同时还可以将位图对象转化为数组对象。 - -我们使用RoaringBitmap实际存储位图对象,当基数小于或等于32时,它使用Set保存。当基数大于32时,它使用RoaringBitmap保存。这也是为什么低基数集的存储更快的原因。 - -有关RoaringBitmap的更多信息,请参阅:[呻吟声](https://github.com/RoaringBitmap/CRoaring)。 - -## bitmapBuild {#bitmapbuild} - -从无符号整数数组构建位图对象。 - - bitmapBuild(array) - -**参数** - -- `array` – 无符号整数数组. - -**示例** - -``` sql -SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res -``` - -## bitmapToArray {#bitmaptoarray} - -将位图转换为整数数组。 - - bitmapToArray(bitmap) - -**参数** - -- `bitmap` – 位图对象. - -**示例** - -``` sql -SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─────────┐ - │ [1,2,3,4,5] │ - └─────────────┘ - -## bitmapSubsetInRange {#bitmapsubsetinrange} - -将位图指定范围(不包含range\_end)转换为另一个位图。 - - bitmapSubsetInRange(bitmap, range_start, range_end) - -**参数** - -- `bitmap` – 位图对象. -- `range_start` – 范围起始点(含). -- `range_end` – 范围结束点(不含). - -**示例** - -``` sql -SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - - ┌─res───────────────┐ - │ [30,31,32,33,100] │ - └───────────────────┘ - -## bitmapSubsetLimit {#bitmapsubsetlimit} - -将位图指定范围(起始点和数目上限)转换为另一个位图。 - - bitmapSubsetLimit(bitmap, range_start, limit) - -**参数** - -- `bitmap` – 位图对象. -- `range_start` – 范围起始点(含). -- `limit` – 子位图基数上限. - -**示例** - -``` sql -SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res -``` - - ┌─res───────────────────────┐ - │ [30,31,32,33,100,200,500] │ - └───────────────────────────┘ - -## bitmapContains {#bitmapcontains} - -检查位图是否包含指定元素。 - - bitmapContains(haystack, needle) - -**参数** - -- `haystack` – 位图对象. -- `needle` – 元素,类型UInt32. - -**示例** - -``` sql -SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## bitmapHasAny {#bitmaphasany} - -与`hasAny(array,array)`类似,如果位图有任何公共元素则返回1,否则返回0。 -对于空位图,返回0。 - - bitmapHasAny(bitmap,bitmap) - -**参数** - -- `bitmap` – bitmap对象。 - -**示例** - -``` sql -SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - - ┌─res─┐ - │ 1 │ - └─────┘ - -## bitmapHasAll {#bitmaphasall} - -与`hasAll(array,array)`类似,如果第一个位图包含第二个位图的所有元素,则返回1,否则返回0。 -如果第二个参数是空位图,则返回1。 - - bitmapHasAll(bitmap,bitmap) - -**参数** - -- `bitmap` – bitmap 对象。 - -**示例** - -``` sql -SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res -``` - - ┌─res─┐ - │ 0 │ - └─────┘ - -## 位图和 {#bitmapand} - -为两个位图对象进行与操作,返回一个新的位图对象。 - - bitmapAnd(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - - ┌─res─┐ - │ [3] │ - └─────┘ - -## 位图 {#bitmapor} - -为两个位图对象进行或操作,返回一个新的位图对象。 - - bitmapOr(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - - ┌─res─────────┐ - │ [1,2,3,4,5] │ - └─────────────┘ - -## bitmapXor {#bitmapxor} - -为两个位图对象进行异或操作,返回一个新的位图对象。 - - bitmapXor(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - - ┌─res───────┐ - │ [1,2,4,5] │ - └───────────┘ - -## bitmapAndnot {#bitmapandnot} - -计算两个位图的差异,返回一个新的位图对象。 - - bitmapAndnot(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res -``` - - ┌─res───┐ - │ [1,2] │ - └───────┘ - -## bitmapCardinality {#bitmapcardinality} - -返回一个UInt64类型的数值,表示位图对象的基数。 - - bitmapCardinality(bitmap) - -**参数** - -- `bitmap` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 5 │ - └─────┘ - -## bitmapMin {#bitmapmin} - -返回一个UInt64类型的数值,表示位图中的最小值。如果位图为空则返回UINT32\_MAX。 - - bitmapMin(bitmap) - -**参数** - -- `bitmap` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 1 │ - └─────┘ - -## bitmapMax {#bitmapmax} - -返回一个UInt64类型的数值,表示位图中的最大值。如果位图为空则返回0。 - - bitmapMax(bitmap) - -**参数** - -- `bitmap` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res -``` - - ┌─res─┐ - │ 5 │ - └─────┘ - -## 位图和标准性 {#bitmapandcardinality} - -为两个位图对象进行与操作,返回结果位图的基数。 - - bitmapAndCardinality(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - - ┌─res─┐ - │ 1 │ - └─────┘ - -## bitmapOrCardinality {#bitmaporcardinality} - -为两个位图进行或运算,返回结果位图的基数。 - - bitmapOrCardinality(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - - ┌─res─┐ - │ 5 │ - └─────┘ - -## bitmapXorCardinality {#bitmapxorcardinality} - -为两个位图进行异或运算,返回结果位图的基数。 - - bitmapXorCardinality(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` – 位图对象。 - -**示例** - -``` sql -SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - - ┌─res─┐ - │ 4 │ - └─────┘ - -## 位图和非标准性 {#bitmapandnotcardinality} - -计算两个位图的差异,返回结果位图的基数。 - - bitmapAndnotCardinality(bitmap1,bitmap2) - -**参数** - -- `bitmap1` – 位图对象。 -- `bitmap2` - 位图对象。 - -**示例** - -``` sql -SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` - - ┌─res─┐ - │ 2 │ - └─────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/bitmap_functions/) diff --git a/docs/zh/sql_reference/functions/comparison_functions.md b/docs/zh/sql_reference/functions/comparison_functions.md deleted file mode 100644 index a73d983f386..00000000000 --- a/docs/zh/sql_reference/functions/comparison_functions.md +++ /dev/null @@ -1,33 +0,0 @@ - -# 比较函数 {#bi-jiao-han-shu} - -比较函数始终返回0或1(UInt8)。 - -可以比较以下类型: - -- 数字 -- String 和 FixedString -- 日期 -- 日期时间 - -以上每个组内的类型均可互相比较,但是对于不同组的类型间不能够进行比较。 - -例如,您无法将日期与字符串进行比较。您必须使用函数将字符串转换为日期,反之亦然。 - -字符串按字节进行比较。较短的字符串小于以其开头并且至少包含一个字符的所有字符串。 - -注意。直到1.1.54134版本,有符号和无符号数字的比较方式与C++相同。换句话说,在SELECT 9223372036854775807 &gt; -1 等情况下,您可能会得到错误的结果。 此行为在版本1.1.54134中已更改,现在在数学上是正确的。 - -## 等于,a=b和a==b运算符 {#equals-a-b-and-a-b-operator} - -## notEquals,a! 运算符=b和a `<>` b {#notequals-a-operator-b-and-a-b} - -## 少, `< operator` {#less-operator} - -## 更大, `> operator` {#greater-operator} - -## 出租等级, `<= operator` {#lessorequals-operator} - -## 伟大的等级, `>= operator` {#greaterorequals-operator} - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) diff --git a/docs/zh/sql_reference/functions/conditional_functions.md b/docs/zh/sql_reference/functions/conditional_functions.md deleted file mode 100644 index d9721fa3f60..00000000000 --- a/docs/zh/sql_reference/functions/conditional_functions.md +++ /dev/null @@ -1,45 +0,0 @@ - -# 条件函数 {#tiao-jian-han-shu} - -## 如果(cond,那么,否则),cond? 运算符然后:else {#ifcond-then-else-cond-operator-then-else} - -如果`cond != 0`则返回`then`,如果`cond = 0`则返回`else`。 -`cond`必须是`UInt8`类型,`then`和`else`必须存在最低的共同类型。 - -`then`和`else`可以是`NULL` - -## 多 {#multiif} - -允许您在查询中更紧凑地编写[CASE](../operators.md#operator_case)运算符。 - - multiIf(cond_1, then_1, cond_2, then_2...else) - -**参数:** - -- `cond_N` — 函数返回`then_N`的条件。 -- `then_N` — 执行时函数的结果。 -- `else` — 如果没有满足任何条件,则为函数的结果。 - -该函数接受`2N + 1`参数。 - -**返回值** - -该函数返回值«then\_N»或«else»之一,具体取决于条件`cond_N`。 - -**示例** - -存在如下一张表 - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 2 │ 3 │ - └───┴──────┘ - -执行查询 `SELECT multiIf(isNull(y) x, y < 3, y, NULL) FROM t_null`。结果: - - ┌─multiIf(isNull(y), x, less(y, 3), y, NULL)─┐ - │ 1 │ - │ ᴺᵁᴸᴸ │ - └────────────────────────────────────────────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/conditional_functions/) diff --git a/docs/zh/sql_reference/functions/date_time_functions.md b/docs/zh/sql_reference/functions/date_time_functions.md deleted file mode 100644 index ca974f563db..00000000000 --- a/docs/zh/sql_reference/functions/date_time_functions.md +++ /dev/null @@ -1,293 +0,0 @@ - -# 时间日期函数 {#shi-jian-ri-qi-han-shu} - -支持时区。 - -所有的时间日期函数都可以在第二个可选参数中接受时区参数。示例:Asia / Yekaterinburg。在这种情况下,它们使用指定的时区而不是本地(默认)时区。 - -``` sql -SELECT - toDateTime('2016-06-15 23:00:00') AS time, - toDate(time) AS date_local, - toDate(time, 'Asia/Yekaterinburg') AS date_yekat, - toString(time, 'US/Samoa') AS time_samoa -``` - - ┌────────────────time─┬─date_local─┬─date_yekat─┬─time_samoa──────────┐ - │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ - └─────────────────────┴────────────┴────────────┴─────────────────────┘ - -仅支持与UTC相差一整小时的时区。 - -## toTimeZone {#totimezone} - -将Date或DateTime转换为指定的时区。 - -## 玩一年 {#toyear} - -将Date或DateTime转换为包含年份编号(AD)的UInt16类型的数字。 - -## 到四分钟 {#toquarter} - -将Date或DateTime转换为包含季度编号的UInt8类型的数字。 - -## toMonth {#tomonth} - -将Date或DateTime转换为包含月份编号(1-12)的UInt8类型的数字。 - -## 今天一年 {#todayofyear} - -将Date或DateTime转换为包含一年中的某一天的编号的UInt16(1-366)类型的数字。 - -## 今天月 {#todayofmonth} - -将Date或DateTime转换为包含一月中的某一天的编号的UInt8(1-31)类型的数字。 - -## 今天一周 {#todayofweek} - -将Date或DateTime转换为包含一周中的某一天的编号的UInt8(周一是1, 周日是7)类型的数字。 - -## toHour {#tohour} - -将DateTime转换为包含24小时制(0-23)小时数的UInt8数字。 -这个函数假设如果时钟向前移动,它是一个小时,发生在凌晨2点,如果时钟被移回,它是一个小时,发生在凌晨3点(这并非总是如此 - 即使在莫斯科时钟在不同的时间两次改变)。 - -## toMinute {#tominute} - -将DateTime转换为包含一小时中分钟数(0-59)的UInt8数字。 - -## 秒 {#tosecond} - -将DateTime转换为包含一分钟中秒数(0-59)的UInt8数字。 -闰秒不计算在内。 - -## toUnixTimestamp {#tounixtimestamp} - -将DateTime转换为unix时间戳。 - -## 开始一年 {#tostartofyear} - -将Date或DateTime向前取整到本年的第一天。 -返回Date类型。 - -## 今年开始 {#tostartofisoyear} - -将Date或DateTime向前取整到ISO本年的第一天。 -返回Date类型。 - -## 四分之一开始 {#tostartofquarter} - -将Date或DateTime向前取整到本季度的第一天。 -返回Date类型。 - -## 到月份开始 {#tostartofmonth} - -将Date或DateTime向前取整到本月的第一天。 -返回Date类型。 - -!!! 注意 "注意" -     解析不正确日期的行为是特定于实现的。 ClickHouse可能会返回零日期,抛出异常或执行«natural»溢出。 - -## toMonday {#tomonday} - -将Date或DateTime向前取整到本周的星期一。 -返回Date类型。 - -## 今天开始 {#tostartofday} - -将DateTime向前取整到当日的开始。 - -## 开始一小时 {#tostartofhour} - -将DateTime向前取整到当前小时的开始。 - -## to startofminute {#tostartofminute} - -将DateTime向前取整到当前分钟的开始。 - -## to startoffiveminute {#tostartoffiveminute} - -将DateTime以五分钟为单位向前取整到最接近的时间点。 - -## 开始分钟 {#tostartoftenminutes} - -将DateTime以十分钟为单位向前取整到最接近的时间点。 - -## 开始几分钟 {#tostartoffifteenminutes} - -将DateTime以十五分钟为单位向前取整到最接近的时间点。 - -## toStartOfInterval(time\_or\_data,间隔x单位\[,time\_zone\]) {#tostartofintervaltime-or-data-interval-x-unit-time-zone} - -这是名为`toStartOf*`的所有函数的通用函数。例如, -`toStartOfInterval(t,INTERVAL 1 year)`返回与`toStartOfYear(t)`相同的结果, -`toStartOfInterval(t,INTERVAL 1 month)`返回与`toStartOfMonth(t)`相同的结果, -`toStartOfInterval(t,INTERVAL 1 day)`返回与`toStartOfDay(t)`相同的结果, -`toStartOfInterval(t,INTERVAL 15 minute)`返回与`toStartOfFifteenMinutes(t)`相同的结果。 - -## toTime {#totime} - -将DateTime中的日期转换为一个固定的日期,同时保留时间部分。 - -## toRelativeYearNum {#torelativeyearnum} - -将Date或DateTime转换为年份的编号,从过去的某个固定时间点开始。 - -## toRelativeQuarterNum {#torelativequarternum} - -将Date或DateTime转换为季度的数字,从过去的某个固定时间点开始。 - -## toRelativeMonthNum {#torelativemonthnum} - -将Date或DateTime转换为月份的编号,从过去的某个固定时间点开始。 - -## toRelativeWeekNum {#torelativeweeknum} - -将Date或DateTime转换为星期数,从过去的某个固定时间点开始。 - -## toRelativeDayNum {#torelativedaynum} - -将Date或DateTime转换为当天的编号,从过去的某个固定时间点开始。 - -## toRelativeHourNum {#torelativehournum} - -将DateTime转换为小时数,从过去的某个固定时间点开始。 - -## toRelativeMinuteNum {#torelativeminutenum} - -将DateTime转换为分钟数,从过去的某个固定时间点开始。 - -## toRelativeSecondNum {#torelativesecondnum} - -将DateTime转换为秒数,从过去的某个固定时间点开始。 - -## toISOYear {#toisoyear} - -将Date或DateTime转换为包含ISO年份的UInt16类型的编号。 - -## toISOWeek {#toisoweek} - -将Date或DateTime转换为包含ISO周数的UInt8类型的编号。 - -## 现在 {#now} - -不接受任何参数并在请求执行时的某一刻返回当前时间(DateTime)。 -此函数返回一个常量,即时请求需要很长时间能够完成。 - -## 今天 {#today} - -不接受任何参数并在请求执行时的某一刻返回当前日期(Date)。 -其功能与'toDate(now())'相同。 - -## 昨天 {#yesterday} - -不接受任何参数并在请求执行时的某一刻返回昨天的日期(Date)。 -其功能与'today() - 1'相同。 - -## 时隙 {#timeslot} - -将时间向前取整半小时。 -此功能用于Yandex.Metrica,因为如果跟踪标记显示单个用户的连续综合浏览量在时间上严格超过此数量,则半小时是将会话分成两个会话的最短时间。这意味着(tag id,user id,time slot)可用于搜索相应会话中包含的综合浏览量。 - -## toyyymm {#toyyyymm} - -将Date或DateTime转换为包含年份和月份编号的UInt32类型的数字(YYYY \* 100 + MM)。 - -## toyyymmdd {#toyyyymmdd} - -将Date或DateTime转换为包含年份和月份编号的UInt32类型的数字(YYYY \* 10000 + MM \* 100 + DD)。 - -## toYYYYMMDDhhmmss {#toyyyymmddhhmmss} - -将Date或DateTime转换为包含年份和月份编号的UInt64类型的数字(YYYY \* 10000000000 + MM \* 100000000 + DD \* 1000000 + hh \* 10000 + mm \* 100 + ss)。 - -## 隆隆隆隆路虏脢,,陇,貌,垄拢卢虏禄quar陇,貌路,隆拢脳枚脢虏,麓脢,脱,,,录,禄庐戮,utes, {#addyears-addmonths-addweeks-adddays-addhours-addminutes-addseconds-addquarters} - -函数将一段时间间隔添加到Date/DateTime,然后返回Date/DateTime。例如: - -``` sql -WITH - toDate('2018-01-01') AS date, - toDateTime('2018-01-01 00:00:00') AS date_time -SELECT - addYears(date, 1) AS add_years_with_date, - addYears(date_time, 1) AS add_years_with_date_time -``` - - ┌─add_years_with_date─┬─add_years_with_date_time─┐ - │ 2019-01-01 │ 2019-01-01 00:00:00 │ - └─────────────────────┴──────────────────────────┘ - -## subtractYears,subtractMonths,subtractWeeks,subtractDays,subtractours,subtractMinutes,subtractSeconds,subtractQuarters {#subtractyears-subtractmonths-subtractweeks-subtractdays-subtracthours-subtractminutes-subtractseconds-subtractquarters} - -函数将Date/DateTime减去一段时间间隔,然后返回Date/DateTime。例如: - -``` sql -WITH - toDate('2019-01-01') AS date, - toDateTime('2019-01-01 00:00:00') AS date_time -SELECT - subtractYears(date, 1) AS subtract_years_with_date, - subtractYears(date_time, 1) AS subtract_years_with_date_time -``` - - ┌─subtract_years_with_date─┬─subtract_years_with_date_time─┐ - │ 2018-01-01 │ 2018-01-01 00:00:00 │ - └──────────────────────────┴───────────────────────────────┘ - -## dateDiff(‘unit’,t1,t2,\[时区\]) {#datediffunit-t1-t2-timezone} - -返回以'unit'为单位表示的两个时间之间的差异,例如`'hours'`。 ‘t1’和’t2’可以是Date或DateTime,如果指定’timezone’,它将应用于两个参数。如果不是,则使用来自数据类型't1'和't2'的时区。如果时区不相同,则结果将是未定义的。 - -支持的单位值: - -| 单位 | -|------| -| 第二 | -| 分钟 | -| 小时 | -| 日 | -| 周 | -| 月 | -| 季 | -| 年 | - -## 时隙(开始时间,持续时间,\[,大小\]) {#timeslotsstarttime-duration-size} - -它返回一个时间数组,其中包括从从«StartTime»开始到«StartTime + Duration 秒»内的所有符合«size»(以秒为单位)步长的时间点。其中«size»是一个可选参数,默认为1800。 -例如,`timeSlots(toDateTime('2012-01-01 12:20:00'),600) = [toDateTime('2012-01-01 12:00:00'),toDateTime('2012-01-01 12:30:00' )]`。 -这对于搜索在相应会话中综合浏览量是非常有用的。 - -## formatDateTime(时间,格式\[,时区\]) {#formatdatetimetime-format-timezone} - -函数根据给定的格式字符串来格式化时间。请注意:格式字符串必须是常量表达式,例如:单个结果列不能有多种格式字符串。 - -支持的格式修饰符: -(«Example» 列是对`2018-01-02 22:33:44`的格式化结果) - -| 修饰符 | 产品描述 | 示例 | -|--------|-------------------------------------------|------------| -| %C | 年除以100并截断为整数(00-99) | 20 | -| %d | 月中的一天,零填充(01-31) | 02 | -| %D | 短MM/DD/YY日期,相当于%m/%d/%y | 01/02/2018 | -| %e | 月中的一天,空格填充(1-31) | 2 | -| %F | 短YYYY-MM-DD日期,相当于%Y-%m-%d | 2018-01-02 | -| %H | 24小时格式(00-23) | 22 | -| %I | 小时12h格式(01-12) | 10 | -| %j | 一年(001-366) | 002 | -| %m | 月份为十进制数(01-12) | 01 | -| %M | 分钟(00-59) | 33 | -| %n | 换行符(") | | -| %p | AM或PM指定 | PM | -| %R | 24小时HH:MM时间,相当于%H:%M | 22:33 | -| %S | 第二(00-59) | 44 | -| %t | 水平制表符(') | | -| %T | ISO8601时间格式(HH:MM:SS),相当于%H:%M:%S | 22:33:44 | -| %u | ISO8601平日as编号,星期一为1(1-7) | 2 | -| %V | ISO8601周编号(01-53) | 01 | -| %w | 周日为十进制数,周日为0(0-6) | 2 | -| %y | 年份,最后两位数字(00-99) | 18 | -| %Y | 年 | 2018 | -| %% | %符号 | % | - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/date_time_functions/) diff --git a/docs/zh/sql_reference/functions/encoding_functions.md b/docs/zh/sql_reference/functions/encoding_functions.md deleted file mode 100644 index 42d10c4408f..00000000000 --- a/docs/zh/sql_reference/functions/encoding_functions.md +++ /dev/null @@ -1,29 +0,0 @@ - -# 编码函数 {#bian-ma-han-shu} - -## hex {#hex} - -接受`String`,`unsigned integer`,`Date`或`DateTime`类型的参数。返回包含参数的十六进制表示的字符串。使用大写字母`A-F`。不使用`0x`前缀或`h`后缀。对于字符串,所有字节都简单地编码为两个十六进制数字。数字转换为大端(«易阅读»)格式。对于数字,去除其中较旧的零,但仅限整个字节。例如,`hex(1)='01'`。 `Date`被编码为自Unix时间开始以来的天数。 `DateTime`编码为自Unix时间开始以来的秒数。 - -## unhex(str) {#unhexstr} - -接受包含任意数量的十六进制数字的字符串,并返回包含相应字节的字符串。支持大写和小写字母A-F。十六进制数字的数量不必是偶数。如果是奇数,则最后一位数被解释为00-0F字节的低位。如果参数字符串包含除十六进制数字以外的任何内容,则返回一些实现定义的结果(不抛出异常)。 -如果要将结果转换为数字,可以使用«reverse»和«reinterpretAsType»函数。 - -## UUIDStringToNum(str) {#uuidstringtonumstr} - -接受包含36个字符的字符串,格式为«123e4567-e89b-12d3-a456-426655440000»,并将其转化为FixedString(16)返回。 - -## UUIDNumToString(str) {#uuidnumtostringstr} - -接受FixedString(16)值。返回包含36个字符的文本格式的字符串。 - -## 位掩码列表(num) {#bitmasktolistnum} - -接受一个整数。返回一个字符串,其中包含一组2的幂列表,其列表中的所有值相加等于这个整数。列表使用逗号分割,按升序排列。 - -## 位掩码阵列(num) {#bitmasktoarraynum} - -接受一个整数。返回一个UInt64类型数组,其中包含一组2的幂列表,其列表中的所有值相加等于这个整数。数组中的数字按升序排列。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/encoding_functions/) diff --git a/docs/zh/sql_reference/functions/ext_dict_functions.md b/docs/zh/sql_reference/functions/ext_dict_functions.md deleted file mode 100644 index 23077618722..00000000000 --- a/docs/zh/sql_reference/functions/ext_dict_functions.md +++ /dev/null @@ -1,47 +0,0 @@ - -# 字典函数 {#zi-dian-han-shu} - -有关连接和配置外部词典的信息,请参阅[外部词典](../../sql_reference/functions/ext_dict_functions.md)。 - -## dictGetUInt8,dictGetUInt16,dictGetUInt32,dictGetUInt64 {#dictgetuint8-dictgetuint16-dictgetuint32-dictgetuint64} - -## dictGetInt8,dictGetInt16,dictGetInt32,dictGetInt64 {#dictgetint8-dictgetint16-dictgetint32-dictgetint64} - -## dictGetFloat32,dictGetFloat64 {#dictgetfloat32-dictgetfloat64} - -## dictGetDate,dictGetDateTime {#dictgetdate-dictgetdatetime} - -## dictgetuid {#dictgetuuid} - -## dictGetString {#dictgetstring} - -`dictGetT('dict_name', 'attr_name', id)` - -- 使用'id'键获取dict\_name字典中attr\_name属性的值。`dict_name`和`attr_name`是常量字符串。`id`必须是UInt64。 - 如果字典中没有`id`键,则返回字典描述中指定的默认值。 - -## dictGetTOrDefault {#ext_dict_functions-dictgettordefault} - -`dictGetTOrDefault('dict_name', 'attr_name', id, default)` - -与`dictGetT`函数相同,但默认值取自函数的最后一个参数。 - -## dictIsIn {#dictisin} - -`dictIsIn ('dict_name', child_id, ancestor_id)` - -- 对于'dict\_name'分层字典,查找'child\_id'键是否位于'ancestor\_id'内(或匹配'ancestor\_id')。返回UInt8。 - -## 独裁主义 {#dictgethierarchy} - -`dictGetHierarchy('dict_name', id)` - -- 对于'dict\_name'分层字典,返回从'id'开始并沿父元素链继续的字典键数组。返回Array(UInt64) - -## dictHas {#dicthas} - -`dictHas('dict_name', id)` - -- 检查字典是否存在指定的`id`。如果不存在,则返回0;如果存在,则返回1。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) diff --git a/docs/zh/sql_reference/functions/functions_for_nulls.md b/docs/zh/sql_reference/functions/functions_for_nulls.md deleted file mode 100644 index 9252d8bfeb0..00000000000 --- a/docs/zh/sql_reference/functions/functions_for_nulls.md +++ /dev/null @@ -1,253 +0,0 @@ - -# Nullable处理函数 {#nullablechu-li-han-shu} - -## isNull {#isnull} - -检查参数是否为[NULL](../syntax.md#null)。 - - isNull(x) - -**参数** - -- `x` — 一个非复合数据类型的值。 - -**返回值** - -- `1` 如果`x`为`NULL`。 -- `0` 如果`x`不为`NULL`。 - -**示例** - -存在以下内容的表 - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 2 │ 3 │ - └───┴──────┘ - -对其进行查询 - - :) SELECT x FROM t_null WHERE isNull(y) - - SELECT x - FROM t_null - WHERE isNull(y) - - ┌─x─┐ - │ 1 │ - └───┘ - - 1 rows in set. Elapsed: 0.010 sec. - -## isNotNull {#isnotnull} - -检查参数是否不为 [NULL](../syntax.md#null). - - isNotNull(x) - -**参数:** - -- `x` — 一个非复合数据类型的值。 - -**返回值** - -- `0` 如果`x`为`NULL`。 -- `1` 如果`x`不为`NULL`。 - -**示例** - -存在以下内容的表 - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 2 │ 3 │ - └───┴──────┘ - -对其进行查询 - - :) SELECT x FROM t_null WHERE isNotNull(y) - - SELECT x - FROM t_null - WHERE isNotNull(y) - - ┌─x─┐ - │ 2 │ - └───┘ - - 1 rows in set. Elapsed: 0.010 sec. - -## 合并 {#coalesce} - -检查从左到右是否传递了«NULL»参数并返回第一个非`'NULL`参数。 - - coalesce(x,...) - -**参数:** - -- 任何数量的非复合类型的参数。所有参数必须与数据类型兼容。 - -**返回值** - -- 第一个非'NULL\`参数。 -- `NULL`,如果所有参数都是'NULL\`。 - -**示例** - -考虑可以指定多种联系客户的方式的联系人列表。 - - ┌─name─────┬─mail─┬─phone─────┬──icq─┐ - │ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ - │ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ - └──────────┴──────┴───────────┴──────┘ - -`mail`和`phone`字段是String类型,但`icq`字段是`UInt32`,所以它需要转换为`String`。 - -从联系人列表中获取客户的第一个可用联系方式: - - :) SELECT coalesce(mail, phone, CAST(icq,'Nullable(String)')) FROM aBook - - SELECT coalesce(mail, phone, CAST(icq, 'Nullable(String)')) - FROM aBook - - ┌─name─────┬─coalesce(mail, phone, CAST(icq, 'Nullable(String)'))─┐ - │ client 1 │ 123-45-67 │ - │ client 2 │ ᴺᵁᴸᴸ │ - └──────────┴──────────────────────────────────────────────────────┘ - - 2 rows in set. Elapsed: 0.006 sec. - -## ifNull {#ifnull} - -如果第一个参数为«NULL»,则返回第二个参数的值。 - - ifNull(x,alt) - -**参数:** - -- `x` — 要检查«NULL»的值。 -- `alt` — 如果`x`为'NULL\`,函数返回的值。 - -**返回值** - -- 价值 `x`,如果 `x` 不是 `NULL`. -- 价值 `alt`,如果 `x` 是 `NULL`. - -**示例** - - SELECT ifNull('a', 'b') - - ┌─ifNull('a', 'b')─┐ - │ a │ - └──────────────────┘ - - SELECT ifNull(NULL, 'b') - - ┌─ifNull(NULL, 'b')─┐ - │ b │ - └───────────────────┘ - -## nullIf {#nullif} - -如果参数相等,则返回`NULL`。 - - nullIf(x, y) - -**参数:** - -`x`, `y` — 用于比较的值。 它们必须是类型兼容的,否则将抛出异常。 - -**返回值** - -- 如果参数相等,则为`NULL`。 -- 如果参数不相等,则为`x`值。 - -**示例** - - SELECT nullIf(1, 1) - - ┌─nullIf(1, 1)─┐ - │ ᴺᵁᴸᴸ │ - └──────────────┘ - - SELECT nullIf(1, 2) - - ┌─nullIf(1, 2)─┐ - │ 1 │ - └──────────────┘ - -## assumeNotNull {#assumenotnull} - -将[可为空](../../sql_reference/functions/functions_for_nulls.md)类型的值转换为非`Nullable`类型的值。 - - assumeNotNull(x) - -**参数:** - -- `x` — 原始值。 - -**返回值** - -- 如果`x`不为`NULL`,返回非`Nullable`类型的原始值。 -- 如果`x`为`NULL`,返回对应非`Nullable`类型的默认值。 - -**示例** - -存在如下`t_null`表。 - - SHOW CREATE TABLE t_null - - ┌─statement─────────────────────────────────────────────────────────────────┐ - │ CREATE TABLE default.t_null ( x Int8, y Nullable(Int8)) ENGINE = TinyLog │ - └───────────────────────────────────────────────────────────────────────────┘ - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 2 │ 3 │ - └───┴──────┘ - -将列`y`作为`assumeNotNull`函数的参数。 - - SELECT assumeNotNull(y) FROM t_null - - ┌─assumeNotNull(y)─┐ - │ 0 │ - │ 3 │ - └──────────────────┘ - - SELECT toTypeName(assumeNotNull(y)) FROM t_null - - ┌─toTypeName(assumeNotNull(y))─┐ - │ Int8 │ - │ Int8 │ - └──────────────────────────────┘ - -## 可调整 {#tonullable} - -将参数的类型转换为`Nullable`。 - - toNullable(x) - -**参数:** - -- `x` — 任何非复合类型的值。 - -**返回值** - -- 输入的值,但其类型为`Nullable`。 - -**示例** - - SELECT toTypeName(10) - - ┌─toTypeName(10)─┐ - │ UInt8 │ - └────────────────┘ - - SELECT toTypeName(toNullable(10)) - - ┌─toTypeName(toNullable(10))─┐ - │ Nullable(UInt8) │ - └────────────────────────────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/functions_for_nulls/) diff --git a/docs/zh/sql_reference/functions/geo.md b/docs/zh/sql_reference/functions/geo.md deleted file mode 100644 index 3f6e6a3bb10..00000000000 --- a/docs/zh/sql_reference/functions/geo.md +++ /dev/null @@ -1,223 +0,0 @@ - -# GEO函数 {#geohan-shu} - -## 大圆形距离 {#greatcircledistance} - -使用[great-circle distance公式](https://en.wikipedia.org/wiki/Great-circle_distance)计算地球表面两点之间的距离。 - -``` sql -greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) -``` - -**输入参数** - -- `lon1Deg` — 第一个点的经度,单位:度,范围: `[-180°, 180°]`。 -- `lat1Deg` — 第一个点的纬度,单位:度,范围: `[-90°, 90°]`。 -- `lon2Deg` — 第二个点的经度,单位:度,范围: `[-180°, 180°]`。 -- `lat2Deg` — 第二个点的纬度,单位:度,范围: `[-90°, 90°]`。 - -正值对应北纬和东经,负值对应南纬和西经。 - -**返回值** - -地球表面的两点之间的距离,以米为单位。 - -当输入参数值超出规定的范围时将抛出异常。 - -**示例** - -``` sql -SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) -``` - -``` text -┌─greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673)─┐ -│ 14132374.194975413 │ -└───────────────────────────────────────────────────────────────────┘ -``` - -## 尖尖的人 {#pointinellipses} - -检查指定的点是否至少包含在指定的一个椭圆中。 -下述中的坐标是几何图形在笛卡尔坐标系中的位置。 - -``` sql -pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) -``` - -**输入参数** - -- `x, y` — 平面上某个点的坐标。 -- `xᵢ, yᵢ` — 第i个椭圆的中心坐标。 -- `aᵢ, bᵢ` — 以x, y坐标为单位的第i个椭圆的轴。 - -输入参数的个数必须是`2+4⋅n`,其中`n`是椭圆的数量。 - -**返回值** - -如果该点至少包含在一个椭圆中,则返回`1`;否则,则返回`0`。 - -**示例** - -``` sql -SELECT pointInEllipses(55.755831, 37.617673, 55.755831, 37.617673, 1.0, 2.0) -``` - -``` text -┌─pointInEllipses(55.755831, 37.617673, 55.755831, 37.617673, 1., 2.)─┐ -│ 1 │ -└─────────────────────────────────────────────────────────────────────┘ -``` - -## pointInPolygon {#pointinpolygon} - -检查指定的点是否包含在指定的多边形中。 - -``` sql -pointInPolygon((x, y), [(a, b), (c, d) ...], ...) -``` - -**输入参数** - -- `(x, y)` — 平面上某个点的坐标。[元组](../../sql_reference/functions/geo.md)类型,包含坐标的两个数字。 -- `[(a, b), (c, d) ...]` — 多边形的顶点。[阵列](../../sql_reference/functions/geo.md)类型。每个顶点由一对坐标`(a, b)`表示。顶点可以按顺时针或逆时针指定。顶点的个数应该大于等于3。同时只能是常量的。 -- 该函数还支持镂空的多边形(切除部分)。如果需要,可以使用函数的其他参数定义需要切除部分的多边形。(The function does not support non-simply-connected polygons.) - -**返回值** - -如果坐标点存在在多边形范围内,则返回`1`。否则返回`0`。 -如果坐标位于多边形的边界上,则该函数可能返回`1`,或可能返回`0`。 - -**示例** - -``` sql -SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res -``` - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - -## geohashEncode {#geohashencode} - -将经度和纬度编码为geohash-string,请参阅(http://geohash.org/,https://en.wikipedia.org/wiki/Geohash)。 - -``` sql -geohashEncode(longitude, latitude, [precision]) -``` - -**输入值** - -- longitude - 要编码的坐标的经度部分。其值应在`[-180°,180°]`范围内 -- latitude - 要编码的坐标的纬度部分。其值应在`[-90°,90°]`范围内 -- precision - 可选,生成的geohash-string的长度,默认为`12`。取值范围为`[1,12]`。任何小于`1`或大于`12`的值都会默认转换为`12`。 - -**返回值** - -- 坐标编码的字符串(使用base32编码的修改版本)。 - -**示例** - -``` sql -SELECT geohashEncode(-5.60302734375, 42.593994140625, 0) AS res -``` - -``` text -┌─res──────────┐ -│ ezs42d000000 │ -└──────────────┘ -``` - -## geohashDecode {#geohashdecode} - -将任何geohash编码的字符串解码为经度和纬度。 - -**输入值** - -- encoded string - geohash编码的字符串。 - -**返回值** - -- (longitude, latitude) - 经度和纬度的`Float64`值的2元组。 - -**示例** - -``` sql -SELECT geohashDecode('ezs42') AS res -``` - -``` text -┌─res─────────────────────────────┐ -│ (-5.60302734375,42.60498046875) │ -└─────────────────────────────────┘ -``` - -## geoToH3 {#geotoh3} - -计算指定的分辨率的[H3](https://uber.github.io/h3/#/documentation/overview/introduction)索引`(lon, lat)`。 - -``` sql -geoToH3(lon, lat, resolution) -``` - -**输入值** - -- `lon` — 经度。 [Float64](../../sql_reference/functions/geo.md)类型。 -- `lat` — 纬度。 [Float64](../../sql_reference/functions/geo.md)类型。 -- `resolution` — 索引的分辨率。 取值范围为: `[0, 15]`。 [UInt8](../../sql_reference/functions/geo.md)类型。 - -**返回值** - -- H3中六边形的索引值。 -- 发生异常时返回0。 - -[UInt64](../../sql_reference/functions/geo.md)类型。 - -**示例** - -``` sql -SELECT geoToH3(37.79506683, 55.71290588, 15) as h3Index -``` - -``` text -┌────────────h3Index─┐ -│ 644325524701193974 │ -└────────────────────┘ -``` - -## geohashesInBox {#geohashesinbox} - -计算在指定精度下计算最小包含指定的经纬范围的最小图形的geohash数组。 - -**输入值** - -- longitude\_min - 最小经度。其值应在`[-180°,180°]`范围内 -- latitude\_min - 最小纬度。其值应在`[-90°,90°]`范围内 -- longitude\_max - 最大经度。其值应在`[-180°,180°]`范围内 -- latitude\_max - 最大纬度。其值应在`[-90°,90°]`范围内 -- precision - geohash的精度。其值应在`[1, 12]`内的`UInt8`类型的数字 - -请注意,上述所有的坐标参数必须同为`Float32`或`Float64`中的一种类型。 - -**返回值** - -- 包含指定范围内的指定精度的geohash字符串数组。注意,您不应该依赖返回数组中geohash的顺序。 -- \[\] - 当传入的最小经纬度大于最大经纬度时将返回一个空数组。 - -请注意,如果生成的数组长度超过10000时,则函数将抛出异常。 - -**示例** - -``` sql -SELECT geohashesInBox(24.48, 40.56, 24.785, 40.81, 4) AS thasos -``` - -``` text -┌─thasos──────────────────────────────────────┐ -│ ['sx1q','sx1r','sx32','sx1w','sx1x','sx38'] │ -└─────────────────────────────────────────────┘ -``` - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/geo/) diff --git a/docs/zh/sql_reference/functions/hash_functions.md b/docs/zh/sql_reference/functions/hash_functions.md deleted file mode 100644 index 9dc4aa9b794..00000000000 --- a/docs/zh/sql_reference/functions/hash_functions.md +++ /dev/null @@ -1,115 +0,0 @@ - -# Hash函数 {#hashhan-shu} - -Hash函数可以用于将元素不可逆的伪随机打乱。 - -## halfMD5 {#halfmd5} - -计算字符串的MD5。然后获取结果的前8个字节并将它们作为UInt64(大端)返回。 -此函数相当低效(500万个短字符串/秒/核心)。 -如果您不需要一定使用MD5,请使用'sipHash64'函数。 - -## MD5 {#md5} - -计算字符串的MD5并将结果放入FixedString(16)中返回。 -如果您只是需要一个128位的hash,同时不需要一定使用MD5,请使用'sipHash128'函数。 -如果您要获得与md5sum程序相同的输出结果,请使用lower(hex(MD5(s)))。 - -## sipHash64 {#siphash64} - -计算字符串的SipHash。 -接受String类型的参数,返回UInt64。 -SipHash是一种加密哈希函数。它的处理性能至少比MD5快三倍。 -有关详细信息,请参阅链接:https://131002.net/siphash/ - -## sipHash128 {#hash_functions-siphash128} - -计算字符串的SipHash。 -接受String类型的参数,返回FixedString(16)。 -与sipHash64函数的不同在于它的最终计算结果为128位。 - -## cityHash64 {#cityhash64} - -计算任意数量字符串的CityHash64或使用特定实现的Hash函数计算任意数量其他类型的Hash。 -对于字符串,使用CityHash算法。 这是一个快速的非加密哈希函数,用于字符串。 -对于其他类型的参数,使用特定实现的Hash函数,这是一种快速的非加密的散列函数。 -如果传递了多个参数,则使用CityHash组合这些参数的Hash结果。 -例如,您可以计算整个表的checksum,其结果取决于行的顺序:`SELECT sum(cityHash64(*)) FROM table`。 - -## intHash32 {#inthash32} - -为任何类型的整数计算32位的哈希。 -这是相对高效的非加密Hash函数。 - -## intHash64 {#inthash64} - -从任何类型的整数计算64位哈希码。 -它的工作速度比intHash32函数快。 - -## SHA1 {#sha1} - -## SHA224 {#sha224} - -## SHA256 {#sha256} - -计算字符串的SHA-1,SHA-224或SHA-256,并将结果字节集返回为FixedString(20),FixedString(28)或FixedString(32)。 -该函数相当低效(SHA-1大约500万个短字符串/秒/核心,而SHA-224和SHA-256大约220万个短字符串/秒/核心)。 -我们建议仅在必须使用这些Hash函数且无法更改的情况下使用这些函数。 -即使在这些情况下,我们仍建议将函数采用在写入数据时使用预计算的方式将其计算完毕。而不是在SELECT中计算它们。 - -## URLHash(url\[,N\]) {#urlhashurl-n} - -一种快速的非加密哈希函数,用于规范化的从URL获得的字符串。 -`URLHash(s)` - 从一个字符串计算一个哈希,如果结尾存在尾随符号`/`,`?`或`#`则忽略。 -`URLHash(s,N)` - 计算URL层次结构中字符串到N级别的哈希值,如果末尾存在尾随符号`/`,`?`或`#`则忽略。 -URL的层级与URLHierarchy中的层级相同。 此函数被用于Yandex.Metrica。 - -## farmHash64 {#farmhash64} - -计算字符串的FarmHash64。 -接受一个String类型的参数。返回UInt64。 -有关详细信息,请参阅链接:[FarmHash64](https://github.com/google/farmhash) - -## javaHash {#hash_functions-javahash} - -计算字符串的JavaHash。 -接受一个String类型的参数。返回Int32。 -有关更多信息,请参阅链接:[JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) - -## hiveHash {#hivehash} - -计算字符串的HiveHash。 -接受一个String类型的参数。返回Int32。 -与[JavaHash](#hash_functions-javahash)相同,但不会返回负数。 - -## metroHash64 {#metrohash64} - -计算字符串的MetroHash。 -接受一个String类型的参数。返回UInt64。 -有关详细信息,请参阅链接:[MetroHash64](http://www.jandrewrogers.com/2015/05/27/metrohash/) - -## jumpConsistentHash {#jumpconsistenthash} - -计算UInt64的JumpConsistentHash。 -接受UInt64类型的参数。返回Int32。 -有关更多信息,请参见链接:[JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) - -## murmurHash2\_32,murmurHash2\_64 {#murmurhash2-32-murmurhash2-64} - -计算字符串的MurmurHash2。 -接受一个String类型的参数。返回UInt64或UInt32。 -有关更多信息,请参阅链接:[MurmurHash2](https://github.com/aappleby/smhasher) - -## murmurHash3\_32,murmurHash3\_64,murmurHash3\_128 {#murmurhash3-32-murmurhash3-64-murmurhash3-128} - -计算字符串的MurmurHash3。 -接受一个String类型的参数。返回UInt64或UInt32或FixedString(16)。 -有关更多信息,请参阅链接:[MurmurHash3](https://github.com/aappleby/smhasher) - -## xxHash32,xxHash64 {#xxhash32-xxhash64} - -计算字符串的xxHash。 -接受一个String类型的参数。返回UInt64或UInt32。 -有关更多信息,请参见链接:[xxHash](http://cyan4973.github.io/xxHash/) - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/hash_functions/) diff --git a/docs/zh/sql_reference/functions/higher_order_functions.md b/docs/zh/sql_reference/functions/higher_order_functions.md deleted file mode 100644 index 6d090e7330d..00000000000 --- a/docs/zh/sql_reference/functions/higher_order_functions.md +++ /dev/null @@ -1,139 +0,0 @@ - -# 高阶函数 {#gao-jie-han-shu} - -## `->` 运算符, lambda(params, expr) 函数 {#yun-suan-fu-lambdaparams-expr-han-shu} - -用于描述一个lambda函数用来传递给其他高阶函数。箭头的左侧有一个形式参数,它可以是一个标识符或多个标识符所组成的元祖。箭头的右侧是一个表达式,在这个表达式中可以使用形式参数列表中的任何一个标识符或表的任何一个列名。 - -示例: `x -> 2 * x, str -> str != Referer.` - -高阶函数只能接受lambda函数作为其参数。 - -高阶函数可以接受多个参数的lambda函数作为其参数,在这种情况下,高阶函数需要同时传递几个长度相等的数组,这些数组将被传递给lambda参数。 - -除了'arrayMap'和'arrayFilter'以外的所有其他函数,都可以省略第一个参数(lambda函数)。在这种情况下,默认返回数组元素本身。 - -### arrayMap(func, arr1, …) {#higher_order_functions-array-map} - -将arr -将从'func'函数的原始应用程序获得的数组返回到'arr'数组中的每个元素。 -返回从原始应用程序获得的数组 ‘func’ 函数中的每个元素 ‘arr’ 阵列。 - -### arrayFilter(func, arr1, …) {#arrayfilterfunc-arr1} - -返回一个仅包含以下元素的数组 ‘arr1’ 对于哪个 ‘func’ 返回0以外的内容。 - -示例: - -``` sql -SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res -``` - - ┌─res───────────┐ - │ ['abc World'] │ - └───────────────┘ - -``` sql -SELECT - arrayFilter( - (i, x) -> x LIKE '%World%', - arrayEnumerate(arr), - ['Hello', 'abc World'] AS arr) - AS res -``` - - ┌─res─┐ - │ [2] │ - └─────┘ - -### arrayCount(\[func,\] arr1, …) {#arraycountfunc-arr1} - -返回数组arr中非零元素的数量,如果指定了'func',则通过'func'的返回值确定元素是否为非零元素。 - -### arrayExists(\[func,\] arr1, …) {#arrayexistsfunc-arr1} - -返回数组'arr'中是否存在非零元素,如果指定了'func',则使用'func'的返回值确定元素是否为非零元素。 - -### arrayAll(\[func,\] arr1, …) {#arrayallfunc-arr1} - -返回数组'arr'中是否存在为零的元素,如果指定了'func',则使用'func'的返回值确定元素是否为零元素。 - -### arraySum(\[func,\] arr1, …) {#arraysumfunc-arr1} - -计算arr数组的总和,如果指定了'func',则通过'func'的返回值计算数组的总和。 - -### arrayFirst(func, arr1, …) {#arrayfirstfunc-arr1} - -返回数组中第一个匹配的元素,函数使用'func'匹配所有元素,直到找到第一个匹配的元素。 - -### arrayFirstIndex(func, arr1, …) {#arrayfirstindexfunc-arr1} - -返回数组中第一个匹配的元素的下标索引,函数使用'func'匹配所有元素,直到找到第一个匹配的元素。 - -### arrayCumSum(\[func,\] arr1, …) {#arraycumsumfunc-arr1} - -返回源数组部分数据的总和,如果指定了`func`函数,则使用`func`的返回值计算总和。 - -示例: - -``` sql -SELECT arrayCumSum([1, 1, 1, 1]) AS res -``` - - ┌─res──────────┐ - │ [1, 2, 3, 4] │ - └──────────────┘ - -### arrayCumSumNonNegative(arr) {#arraycumsumnonnegativearr} - -与arrayCumSum相同,返回源数组部分数据的总和。不同于arrayCumSum,当返回值包含小于零的值时,该值替换为零,后续计算使用零继续计算。例如: - -``` sql -SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res -``` - - ┌─res───────┐ - │ [1,2,0,1] │ - └───────────┘ - -### arraySort(\[func,\] arr1, …) {#arraysortfunc-arr1} - -返回升序排序`arr1`的结果。如果指定了`func`函数,则排序顺序由`func`的结果决定。 - -[Schwartzian变换](https://en.wikipedia.org/wiki/Schwartzian_transform)用于提高排序效率。 - -示例: - -``` sql -SELECT arraySort((x, y) -> y, ['hello', 'world'], [2, 1]); -``` - - ┌─res────────────────┐ - │ ['world', 'hello'] │ - └────────────────────┘ - -请注意,NULL和NaN在最后(NaN在NULL之前)。例如: - -``` sql -SELECT arraySort([1, nan, 2, NULL, 3, nan, 4, NULL]) -``` - - ┌─arraySort([1, nan, 2, NULL, 3, nan, 4, NULL])─┐ - │ [1,2,3,4,nan,nan,NULL,NULL] │ - └───────────────────────────────────────────────┘ - -### arrayReverseSort(\[func,\] arr1, …) {#arrayreversesortfunc-arr1} - -返回降序排序`arr1`的结果。如果指定了`func`函数,则排序顺序由`func`的结果决定。 - -请注意,NULL和NaN在最后(NaN在NULL之前)。例如: - -``` sql -SELECT arrayReverseSort([1, nan, 2, NULL, 3, nan, 4, NULL]) -``` - - ┌─arrayReverseSort([1, nan, 2, NULL, 3, nan, 4, NULL])─┐ - │ [4,3,2,1,nan,nan,NULL,NULL] │ - └──────────────────────────────────────────────────────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/higher_order_functions/) diff --git a/docs/zh/sql_reference/functions/in_functions.md b/docs/zh/sql_reference/functions/in_functions.md deleted file mode 100644 index f4f358bad9a..00000000000 --- a/docs/zh/sql_reference/functions/in_functions.md +++ /dev/null @@ -1,20 +0,0 @@ - -# IN运算符相关函数 {#inyun-suan-fu-xiang-guan-han-shu} - -## in,notIn,globalIn,globalNotIn {#in-notin-globalin-globalnotin} - -请参阅[IN 运算符](../statements/select.md#select-in-operators)部分。 - -## tuple(x, y, …), operator (x, y, …) {#tuplex-y-operator-x-y} - -函数用于对多个列进行分组。 -对于具有类型T1,T2,…的列,它返回包含这些列的元组(T1,T2,…)。 执行该函数没有任何成本。 -元组通常用作IN运算符的中间参数值,或用于创建lambda函数的形参列表。 元组不能写入表。 - -## 元组元素(元组,n),运算符x.N {#tupleelementtuple-n-operator-x-n} - -函数用于从元组中获取列。 -'N'是列索引,从1开始。N必须是常量正整数常数,并且不大于元组的大小。 -执行该函数没有任何成本。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/in_functions/) diff --git a/docs/zh/sql_reference/functions/index.md b/docs/zh/sql_reference/functions/index.md deleted file mode 100644 index 1f61a1f2919..00000000000 --- a/docs/zh/sql_reference/functions/index.md +++ /dev/null @@ -1,67 +0,0 @@ - -# 函数 {#han-shu} - -ClickHouse中至少存在两种类型的函数 - 常规函数(它们称之为«函数»)和聚合函数。 常规函数的工作就像分别为每一行执行一次函数计算一样(对于每一行,函数的结果不依赖于其他行)。 聚合函数则从各行累积一组值(即函数的结果以来整个结果集)。 - -在本节中,我们将讨论常规函数。 有关聚合函数,请参阅«聚合函数»一节。 - - \* - 'arrayJoin'函数与表函数均属于第三种类型的函数。 \* - -## 强类型 {#qiang-lei-xing} - -与标准SQL相比,ClickHouse具有强类型。 换句话说,它不会在类型之间进行隐式转换。 每个函数适用于特定的一组类型。 这意味着有时您需要使用类型转换函数。 - -## 常见的子表达式消除 {#chang-jian-de-zi-biao-da-shi-xiao-chu} - -查询中具有相同AST(相同语句或语法分析结果相同)的所有表达式都被视为具有相同的值。 这样的表达式被连接并执行一次。 通过这种方式也可以消除相同的子查询。 - -## 结果类型 {#jie-guo-lei-xing} - -所有函数都只能够返回一个返回值。 结果类型通常由参数的类型决定。 但tupleElement函数(a.N运算符)和toFixedString函数是例外的。 - -## 常量 {#chang-liang} - -为了简单起见,某些函数的某些参数只能是常量。 例如,LIKE运算符的右参数必须是常量。 -几乎所有函数都为常量参数返回常量。 除了用于生成随机数的函数。 -'now'函数为在不同时间运行的查询返回不同的值,但结果被视为常量,因为常量在单个查询中很重要。 -常量表达式也被视为常量(例如,LIKE运算符的右半部分可以由多个常量构造)。 - -对于常量和非常量参数,可以以不同方式实现函数(执行不同的代码)。 但是,对于包含相同数据的常量和非常量参数它们的结果应该是一致的。 - -## NULL值处理 {#nullzhi-chu-li} - -函数具有以下行为: - -- 如果函数的参数至少一个是«NULL»,则函数结果也是«NULL»。 -- 在每个函数的描述中单独指定的特殊行为。在ClickHouse源代码中,这些函数具有«UseDefaultImplementationForNulls = false»。 - -## 不可变性 {#bu-ke-bian-xing} - -函数不能更改其参数的值 - 任何更改都将作为结果返回。因此,计算单独函数的结果不依赖于在查询中写入函数的顺序。 - -## 错误处理 {#cuo-wu-chu-li} - -如果数据无效,某些函数可能会抛出异常。在这种情况下,将取消查询并将错误信息返回给客户端。对于分布式处理,当其中一个服务器发生异常时,其他服务器也会尝试中止查询。 - -## 表达式参数的计算 {#biao-da-shi-can-shu-de-ji-suan} - -在几乎所有编程语言中,某些函数可能无法预先计算其中一个参数。这通常是运算符`&&`,`||`和`? :`。 -但是在ClickHouse中,函数(运算符)的参数总是被预先计算。这是因为一次评估列的整个部分,而不是分别计算每一行。 - -## 执行分布式查询处理的功能 {#zhi-xing-fen-bu-shi-cha-xun-chu-li-de-gong-neng} - -对于分布式查询处理,在远程服务器上执行尽可能多的查询处理阶段,并且在请求者服务器上执行其余阶段(合并中间结果和之后的所有内容)。 - -这意味着可以在不同的服务器上执行功能。 -例如,在查询`SELECT f(sum(g(x)))FROM distributed_table GROUP BY h(y)中,` - -- 如果`distributed_table`至少有两个分片,则在远程服务器上执行函数'g'和'h',并在请求服务器上执行函数'f'。 -- 如果`distributed_table`只有一个分片,则在该分片的服务器上执行所有'f','g'和'h'功能。 - -函数的结果通常不依赖于它在哪个服务器上执行。但是,有时这很重要。 -例如,使用字典的函数时将使用运行它们的服务器上存在的字典。 -另一个例子是`hostName`函数,它返回运行它的服务器的名称,以便在`SELECT`查询中对服务器进行`GROUP BY`。 - -如果查询中的函数在请求服务器上执行,但您需要在远程服务器上执行它,则可以将其包装在«any»聚合函数中,或将其添加到«GROUP BY»中。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/) diff --git a/docs/zh/sql_reference/functions/introspection.md b/docs/zh/sql_reference/functions/introspection.md deleted file mode 100644 index f0c907b3e67..00000000000 --- a/docs/zh/sql_reference/functions/introspection.md +++ /dev/null @@ -1,310 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 65 -toc_title: "\u81EA\u7701" ---- - -# 内省功能 {#introspection-functions} - -您可以使用本章中描述的函数来反省 [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) 和 [DWARF](https://en.wikipedia.org/wiki/DWARF) 用于查询分析。 - -!!! warning "警告" - 这些功能很慢,可能会强加安全考虑。 - -对于内省功能的正确操作: - -- 安装 `clickhouse-common-static-dbg` 包。 - -- 设置 [allow\_introspection\_functions](../../operations/settings/settings.md#settings-allow_introspection_functions) 设置为1。 - - For security reasons introspection functions are disabled by default. - -ClickHouse将探查器报告保存到 [trace\_log](../../operations/system_tables.md#system_tables-trace_log) 系统表. 确保正确配置了表和探查器。 - -## addressToLine {#addresstoline} - -将ClickHouse服务器进程内的虚拟内存地址转换为ClickHouse源代码中的文件名和行号。 - -如果您使用官方的ClickHouse软件包,您需要安装 `clickhouse-common-static-dbg` 包。 - -**语法** - -``` sql -addressToLine(address_of_binary_instruction) -``` - -**参数** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**返回值** - -- 源代码文件名和此文件中用冒号分隔的行号。 - - For example, `/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`, where `199` is a line number. - -- 二进制文件的名称,如果函数找不到调试信息。 - -- 空字符串,如果地址无效。 - -类型: [字符串](../../sql_reference/data_types/string.md). - -**示例** - -启用内省功能: - -``` sql -SET allow_introspection_functions=1 -``` - -从中选择第一个字符串 `trace_log` 系统表: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-19 -event_time: 2019-11-19 18:57:23 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 421b6855-1858-45a5-8f37-f383409d6d72 -trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] -``` - -该 `trace` 字段包含采样时的堆栈跟踪。 - -获取单个地址的源代码文件名和行号: - -``` sql -SELECT addressToLine(94784076370703) \G -``` - -``` text -Row 1: -────── -addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -``` - -将函数应用于整个堆栈跟踪: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines -FROM system.trace_log -LIMIT 1 -\G -``` - -该 [arrayMap](higher_order_functions.md#higher_order_functions-array-map) 功能允许处理的每个单独的元素 `trace` 阵列由 `addressToLine` 功能。 这种处理的结果,你在看 `trace_source_code_lines` 列的输出。 - -``` text -Row 1: -────── -trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so -/usr/lib/debug/usr/bin/clickhouse -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 -/usr/include/c++/9/bits/atomic_base.h:551 -/usr/lib/debug/usr/bin/clickhouse -/lib/x86_64-linux-gnu/libpthread-2.27.so -/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -``` - -## addressToSymbol {#addresstosymbol} - -将ClickHouse服务器进程内的虚拟内存地址转换为ClickHouse对象文件中的符号。 - -**语法** - -``` sql -addressToSymbol(address_of_binary_instruction) -``` - -**参数** - -- `address_of_binary_instruction` ([UInt64](../../sql_reference/data_types/int_uint.md)) — Address of instruction in a running process. - -**返回值** - -- 来自ClickHouse对象文件的符号。 -- 空字符串,如果地址无效。 - -类型: [字符串](../../sql_reference/data_types/string.md). - -**示例** - -启用内省功能: - -``` sql -SET allow_introspection_functions=1 -``` - -从中选择第一个字符串 `trace_log` 系统表: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -该 `trace` 字段包含采样时的堆栈跟踪。 - -获取单个地址的符号: - -``` sql -SELECT addressToSymbol(94138803686098) \G -``` - -``` text -Row 1: -────── -addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -``` - -将函数应用于整个堆栈跟踪: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols -FROM system.trace_log -LIMIT 1 -\G -``` - -该 [arrayMap](higher_order_functions.md#higher_order_functions-array-map) 功能允许处理的每个单独的元素 `trace` 阵列由 `addressToSymbols` 功能。 这种处理的结果,你在看 `trace_symbols` 列的输出。 - -``` text -Row 1: -────── -trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE -_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb -_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb -_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE -_ZN2DB27AggregatingBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB28AsynchronousBlockInputStream9calculateEv -_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data -_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E -_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv -_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E -execute_native_thread_routine -start_thread -clone -``` - -## demangle {#demangle} - -转换一个符号,您可以使用 [addressToSymbol](#addresstosymbol) 函数到C++函数名。 - -**语法** - -``` sql -demangle(symbol) -``` - -**参数** - -- `symbol` ([字符串](../../sql_reference/data_types/string.md)) — Symbol from an object file. - -**返回值** - -- C++函数的名称。 -- 如果符号无效,则为空字符串。 - -类型: [字符串](../../sql_reference/data_types/string.md). - -**示例** - -启用内省功能: - -``` sql -SET allow_introspection_functions=1 -``` - -从中选择第一个字符串 `trace_log` 系统表: - -``` sql -SELECT * FROM system.trace_log LIMIT 1 \G -``` - -``` text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -该 `trace` 字段包含采样时的堆栈跟踪。 - -获取单个地址的函数名称: - -``` sql -SELECT demangle(addressToSymbol(94138803686098)) \G -``` - -``` text -Row 1: -────── -demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -``` - -将函数应用于整个堆栈跟踪: - -``` sql -SELECT - arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions -FROM system.trace_log -LIMIT 1 -\G -``` - -该 [arrayMap](higher_order_functions.md#higher_order_functions-array-map) 功能允许处理的每个单独的元素 `trace` 阵列由 `demangle` 功能。 这种处理的结果,你在看 `trace_functions` 列的输出。 - -``` text -Row 1: -────── -trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const -DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const -DB::Aggregator::executeOnBlock(std::vector::immutable_ptr, std::allocator::immutable_ptr > >, unsigned long, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::executeOnBlock(DB::Block const&, DB::AggregatedDataVariants&, std::vector >&, std::vector >, std::allocator > > >&, bool&) -DB::Aggregator::execute(std::shared_ptr const&, DB::AggregatedDataVariants&) -DB::AggregatingBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::ExpressionBlockInputStream::readImpl() -DB::IBlockInputStream::read() -DB::AsynchronousBlockInputStream::calculate() -std::_Function_handler::_M_invoke(std::_Any_data const&) -ThreadPoolImpl::worker(std::_List_iterator) -ThreadFromGlobalPool::ThreadFromGlobalPool::scheduleImpl(std::function, int, std::optional)::{lambda()#3}>(ThreadPoolImpl::scheduleImpl(std::function, int, std::optional)::{lambda()#3}&&)::{lambda()#1}::operator()() const -ThreadPoolImpl::worker(std::_List_iterator) -execute_native_thread_routine -start_thread -clone -``` diff --git a/docs/zh/sql_reference/functions/ip_address_functions.md b/docs/zh/sql_reference/functions/ip_address_functions.md deleted file mode 100644 index 17f4c4a5991..00000000000 --- a/docs/zh/sql_reference/functions/ip_address_functions.md +++ /dev/null @@ -1,218 +0,0 @@ - -# IP函数 {#iphan-shu} - -## IPv4NumToString(num) {#ipv4numtostringnum} - -接受一个UInt32(大端)表示的IPv4的地址,返回相应IPv4的字符串表现形式,格式为A.B.C.D(以点分割的十进制数字)。 - -## IPv4StringToNum(s) {#ipv4stringtonums} - -与IPv4NumToString函数相反。如果IPv4地址格式无效,则返回0。 - -## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} - -与IPv4NumToString类似,但使用xxx替换最后一个字节。 - -示例: - -``` sql -SELECT - IPv4NumToStringClassC(ClientIP) AS k, - count() AS c -FROM test.hits -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - - ┌─k──────────────┬─────c─┐ - │ 83.149.9.xxx │ 26238 │ - │ 217.118.81.xxx │ 26074 │ - │ 213.87.129.xxx │ 25481 │ - │ 83.149.8.xxx │ 24984 │ - │ 217.118.83.xxx │ 22797 │ - │ 78.25.120.xxx │ 22354 │ - │ 213.87.131.xxx │ 21285 │ - │ 78.25.121.xxx │ 20887 │ - │ 188.162.65.xxx │ 19694 │ - │ 83.149.48.xxx │ 17406 │ - └────────────────┴───────┘ - -由于使用'xxx'是不规范的,因此将来可能会更改。我们建议您不要依赖此格式。 - -### IPv6NumToString(x) {#ipv6numtostringx} - -接受FixedString(16)类型的二进制格式的IPv6地址。以文本格式返回此地址的字符串。 -IPv6映射的IPv4地址以::ffff:111.222.33。例如: - -``` sql -SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr -``` - - ┌─addr─────────┐ - │ 2a02:6b8::11 │ - └──────────────┘ - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() AND substring(ClientIP6, 1, 12) != unhex('00000000000000000000FFFF') -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - - ┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ - │ 2a02:2168:aaa:bbbb::2 │ 24695 │ - │ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ - │ 2a02:6b8:0:fff::ff │ 16389 │ - │ 2a01:4f8:111:6666::2 │ 16016 │ - │ 2a02:2168:888:222::1 │ 15896 │ - │ 2a01:7e00::ffff:ffff:ffff:222 │ 14774 │ - │ 2a02:8109:eee:ee:eeee:eeee:eeee:eeee │ 14443 │ - │ 2a02:810b:8888:888:8888:8888:8888:8888 │ 14345 │ - │ 2a02:6b8:0:444:4444:4444:4444:4444 │ 14279 │ - │ 2a01:7e00::ffff:ffff:ffff:ffff │ 13880 │ - └─────────────────────────────────────────┴───────┘ - -``` sql -SELECT - IPv6NumToString(ClientIP6 AS k), - count() AS c -FROM hits_all -WHERE EventDate = today() -GROUP BY k -ORDER BY c DESC -LIMIT 10 -``` - - ┌─IPv6NumToString(ClientIP6)─┬──────c─┐ - │ ::ffff:94.26.111.111 │ 747440 │ - │ ::ffff:37.143.222.4 │ 529483 │ - │ ::ffff:5.166.111.99 │ 317707 │ - │ ::ffff:46.38.11.77 │ 263086 │ - │ ::ffff:79.105.111.111 │ 186611 │ - │ ::ffff:93.92.111.88 │ 176773 │ - │ ::ffff:84.53.111.33 │ 158709 │ - │ ::ffff:217.118.11.22 │ 154004 │ - │ ::ffff:217.118.11.33 │ 148449 │ - │ ::ffff:217.118.11.44 │ 148243 │ - └────────────────────────────┴────────┘ - -## IPv6StringToNum(s) {#ipv6stringtonums} - -与IPv6NumToString的相反。如果IPv6地址格式无效,则返回空字节字符串。 -十六进制可以是大写的或小写的。 - -## IPv4ToIPv6(x) {#ipv4toipv6x} - -接受一个UInt32类型的IPv4地址,返回FixedString(16)类型的IPv6地址。例如: - -``` sql -SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr -``` - - ┌─addr───────────────┐ - │ ::ffff:192.168.0.1 │ - └────────────────────┘ - -## cutIPv6(x,bitsToCutForIPv6,bitsToCutForIPv4) {#cutipv6x-bitstocutforipv6-bitstocutforipv4} - -接受一个FixedString(16)类型的IPv6地址,返回一个String,这个String中包含了删除指定位之后的地址的文本格式。例如: - -``` sql -WITH - IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, - IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 -SELECT - cutIPv6(ipv6, 2, 0), - cutIPv6(ipv4, 0, 2) -``` - - ┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ - │ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ - └─────────────────────────────────────┴─────────────────────┘ - -## ツ古カツ益ツ催ツ団ツ法ツ人), {#ipv4cidrtorangeipv4-cidr} - -接受一个IPv4地址以及一个UInt8类型的CIDR。返回包含子网最低范围以及最高范围的元组。 - -``` sql -SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16) -``` - - ┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ - │ ('192.168.0.0','192.168.255.255') │ - └────────────────────────────────────────────┘ - -## ツ暗ェツ氾环催ツ団ツ法ツ人), {#ipv6cidrtorangeipv6-cidr} - -接受一个IPv6地址以及一个UInt8类型的CIDR。返回包含子网最低范围以及最高范围的元组。 - -``` sql -SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); -``` - - ┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ - │ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ - └────────────────────────────────────────────────────────────────────────┘ - -## toIPv4(字符串) {#toipv4string} - -`IPv4StringToNum()`的别名,它采用字符串形式的IPv4地址并返回[IPv4](../../sql_reference/functions/ip_address_functions.md)类型的值,该二进制值等于`IPv4StringToNum()`返回的值。 - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - toTypeName(IPv4StringToNum(IPv4_string)), - toTypeName(toIPv4(IPv4_string)) -``` - - ┌─toTypeName(IPv4StringToNum(IPv4_string))─┬─toTypeName(toIPv4(IPv4_string))─┐ - │ UInt32 │ IPv4 │ - └──────────────────────────────────────────┴─────────────────────────────────┘ - -``` sql -WITH - '171.225.130.45' as IPv4_string -SELECT - hex(IPv4StringToNum(IPv4_string)), - hex(toIPv4(IPv4_string)) -``` - - ┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ - │ ABE1822D │ ABE1822D │ - └───────────────────────────────────┴──────────────────────────┘ - -## toIPv6(字符串) {#toipv6string} - -`IPv6StringToNum()`的别名,它采用字符串形式的IPv6地址并返回[IPv6](../../sql_reference/functions/ip_address_functions.md)类型的值,该二进制值等于`IPv6StringToNum()`返回的值。 - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - toTypeName(IPv6StringToNum(IPv6_string)), - toTypeName(toIPv6(IPv6_string)) -``` - - ┌─toTypeName(IPv6StringToNum(IPv6_string))─┬─toTypeName(toIPv6(IPv6_string))─┐ - │ FixedString(16) │ IPv6 │ - └──────────────────────────────────────────┴─────────────────────────────────┘ - -``` sql -WITH - '2001:438:ffff::407d:1bc1' as IPv6_string -SELECT - hex(IPv6StringToNum(IPv6_string)), - hex(toIPv6(IPv6_string)) -``` - - ┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ - │ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ - └───────────────────────────────────┴──────────────────────────────────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) diff --git a/docs/zh/sql_reference/functions/json_functions.md b/docs/zh/sql_reference/functions/json_functions.md deleted file mode 100644 index ca76edde09c..00000000000 --- a/docs/zh/sql_reference/functions/json_functions.md +++ /dev/null @@ -1,175 +0,0 @@ - -# JSON函数 {#jsonhan-shu} - -在Yandex.Metrica中,用户使用JSON作为访问参数。为了处理这些JSON,实现了一些函数。(尽管在大多数情况下,JSON是预先进行额外处理的,并将结果值放在单独的列中。)所有的这些函数都进行了尽可能的假设。以使函数能够尽快的完成工作。 - -我们对JSON格式做了如下假设: - -1. 字段名称(函数的参数)必须使常量。 -2. 字段名称必须使用规范的编码。例如:`visitParamHas('{"abc":"def"}', 'abc') = 1`,但是 `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -3. 函数可以随意的在多层嵌套结构下查找字段。如果存在多个匹配字段,则返回第一个匹配字段。 -4. JSON除字符串文本外不存在空格字符。 - -## ツ环板(ョツ嘉ッツ偲青visャツ静ャツ青サツ催ャツ渉) {#visitparamhasparams-name} - -检查是否存在«name»名称的字段 - -## 访问paramextractuint(参数,名称) {#visitparamextractuintparams-name} - -将名为«name»的字段的值解析成UInt64。如果这是一个字符串字段,函数将尝试从字符串的开头解析一个数字。如果该字段不存在,或无法从它中解析到数字,则返回0。 - -## visitParamExtractInt(参数,名称) {#visitparamextractintparams-name} - -与visitParamExtractUInt相同,但返回Int64。 - -## 访问paramextractfloat(参数,名称) {#visitparamextractfloatparams-name} - -与visitParamExtractUInt相同,但返回Float64。 - -## ツ环板(ョツ嘉ッツ偲青妥-ツ姪(不ツ督ョツ産) {#visitparamextractboolparams-name} - -解析true/false值。其结果是UInt8类型的。 - -## 掳胫((禄脢鹿脷露胫鲁隆鹿((酶-11-16""\[脪陆(,,,) {#visitparamextractrawparams-name} - -返回字段的值,包含空格符。 - -示例: - - visitParamExtractRaw('{"abc":"\\n\\u0000"}', 'abc') = '"\\n\\u0000"' - visitParamExtractRaw('{"abc":{"def":[1,2,3]}}', 'abc') = '{"def":[1,2,3]}' - -## visitParamExtractString(参数,名称) {#visitparamextractstringparams-name} - -使用双引号解析字符串。这个值没有进行转义。如果转义失败,它将返回一个空白字符串。 - -示例: - - visitParamExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' - visitParamExtractString('{"abc":"\\u263a"}', 'abc') = '☺' - visitParamExtractString('{"abc":"\\u263"}', 'abc') = '' - visitParamExtractString('{"abc":"hello}', 'abc') = '' - -目前不支持`\uXXXX\uYYYY`这些字符编码,这些编码不在基本多文种平面中(它们被转化为CESU-8而不是UTF-8)。 - -以下函数基于[simdjson](https://github.com/lemire/simdjson),专为更复杂的JSON解析要求而设计。但上述假设2仍然适用。 - -## JSONHas(json\[, indices\_or\_keys\]…) {#jsonhasjson-indices-or-keys} - -如果JSON中存在该值,则返回`1`。 - -如果该值不存在,则返回`0`。 - -示例: - - select JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 - select JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 - -`indices_or_keys`可以是零个或多个参数的列表,每个参数可以是字符串或整数。 - -- String = 按成员名称访问JSON对象成员。 -- 正整数 = 从头开始访问第n个成员/成员名称。 -- 负整数 = 从末尾访问第n个成员/成员名称。 - -您可以使用整数来访问JSON数组和JSON对象。 - -例如: - - select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' - select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' - select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' - select JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' - select JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' - -## JSONLength(json\[, indices\_or\_keys\]…) {#jsonlengthjson-indices-or-keys} - -返回JSON数组或JSON对象的长度。 - -如果该值不存在或类型错误,将返回`0`。 - -示例: - - select JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 - select JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 - -## JSONType(json\[, indices\_or\_keys\]…) {#jsontypejson-indices-or-keys} - -返回JSON值的类型。 - -如果该值不存在,将返回`Null`。 - -示例: - - select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' - select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' - select JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' - -## JSONExtractUInt(json\[, indices\_or\_keys\]…) {#jsonextractuintjson-indices-or-keys} - -## JSONExtractInt(json\[, indices\_or\_keys\]…) {#jsonextractintjson-indices-or-keys} - -## JSONExtractFloat(json\[, indices\_or\_keys\]…) {#jsonextractfloatjson-indices-or-keys} - -## JSONExtractBool(json\[, indices\_or\_keys\]…) {#jsonextractbooljson-indices-or-keys} - -解析JSON并提取值。这些函数类似于`visitParam*`函数。 - -如果该值不存在或类型错误,将返回`0`。 - -示例: - - select JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) = -100 - select JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) = 200.0 - select JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) = 300 - -## JSONExtractString(json\[, indices\_or\_keys\]…) {#jsonextractstringjson-indices-or-keys} - -解析JSON并提取字符串。此函数类似于`visitParamExtractString`函数。 - -如果该值不存在或类型错误,则返回空字符串。 - -该值未转义。如果unescaping失败,则返回一个空字符串。 - -示例: - - select JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' - select JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' - select JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' - select JSONExtractString('{"abc":"\\u263"}', 'abc') = '' - select JSONExtractString('{"abc":"hello}', 'abc') = '' - -## JSONExtract(json\[, indices\_or\_keys…\], return\_type) {#jsonextractjson-indices-or-keys-return-type} - -解析JSON并提取给定ClickHouse数据类型的值。 - -这是以前的`JSONExtract函数的变体。 这意味着`JSONExtract(…, ‘String’)`返回与`JSONExtractString()`返回完全相同。`JSONExtract(…, ‘Float64’)`返回于`JSONExtractFloat()\`返回完全相同。 - -示例: - - SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) - SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') - SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] - SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL - SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 - SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' - SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' - -## JSONExtractKeysAndValues(json\[, indices\_or\_keys…\], value\_type) {#jsonextractkeysandvaluesjson-indices-or-keys-value-type} - -从JSON中解析键值对,其中值是给定的ClickHouse数据类型。 - -示例: - - SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; - -## JSONExtractRaw(json\[, indices\_or\_keys\]…) {#jsonextractrawjson-indices-or-keys} - -返回JSON的部分。 - -如果部件不存在或类型错误,将返回空字符串。 - -示例: - - select JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]' - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/json_functions/) diff --git a/docs/zh/sql_reference/functions/logical_functions.md b/docs/zh/sql_reference/functions/logical_functions.md deleted file mode 100644 index 18a383edbdb..00000000000 --- a/docs/zh/sql_reference/functions/logical_functions.md +++ /dev/null @@ -1,16 +0,0 @@ - -# 逻辑函数 {#luo-ji-han-shu} - -逻辑函数可以接受任何数字类型的参数,并返回UInt8类型的0或1。 - -当向函数传递零时,函数将判定为«false»,否则,任何其他非零的值都将被判定为«true»。 - -## 和,和运营商 {#and-and-operator} - -## 或,或运营商 {#or-or-operator} - -## 不是,不是运营商 {#not-not-operator} - -## 异或 {#xor} - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/logical_functions/) diff --git a/docs/zh/sql_reference/functions/machine_learning_functions.md b/docs/zh/sql_reference/functions/machine_learning_functions.md deleted file mode 100644 index 0bdea52c59f..00000000000 --- a/docs/zh/sql_reference/functions/machine_learning_functions.md +++ /dev/null @@ -1,16 +0,0 @@ - -# 机器学习函数 {#ji-qi-xue-xi-han-shu} - -## evalMLMethod(预测) {#machine_learning_methods-evalmlmethod} - -使用拟合回归模型的预测请使用`evalMLMethod`函数。 请参阅`linearRegression`中的链接。 - -## 随机线性回归 {#stochastic-linear-regression} - -`stochasticLinearRegression`聚合函数使用线性模型和MSE损失函数实现随机梯度下降法。 使用`evalMLMethod`来预测新数据。 -请参阅示例和注释[此处](../../sql_reference/functions/machine_learning_functions.md#agg_functions-stochasticlinearregression)。 - -## 随机逻辑回归 {#stochastic-logistic-regression} - -`stochasticLogisticRegression`聚合函数实现了二元分类问题的随机梯度下降法。 使用`evalMLMethod`来预测新数据。 -请参阅示例和注释[此处](../../sql_reference/functions/machine_learning_functions.md#agg_functions-stochasticlogisticregression)。 diff --git a/docs/zh/sql_reference/functions/math_functions.md b/docs/zh/sql_reference/functions/math_functions.md deleted file mode 100644 index fef88389b86..00000000000 --- a/docs/zh/sql_reference/functions/math_functions.md +++ /dev/null @@ -1,108 +0,0 @@ - -# 数学函数 {#shu-xue-han-shu} - -以下所有的函数都返回一个Float64类型的数值。返回结果总是以尽可能最大精度返回,但还是可能与机器中可表示最接近该值的数字不同。 - -## e() {#e} - -返回一个接近数学常量e的Float64数字。 - -## pi() {#pi} - -返回一个接近数学常量π的Float64数字。 - -## exp(x) {#expx} - -接受一个数值类型的参数并返回它的指数。 - -## log(x),ln(x) {#logx-lnx} - -接受一个数值类型的参数并返回它的自然对数。 - -## exp2(x) {#exp2x} - -接受一个数值类型的参数并返回它的2的x次幂。 - -## log2(x) {#log2x} - -接受一个数值类型的参数并返回它的底2对数。 - -## exp10(x) {#exp10x} - -接受一个数值类型的参数并返回它的10的x次幂。 - -## log10(x) {#log10x} - -接受一个数值类型的参数并返回它的底10对数。 - -## sqrt(x) {#sqrtx} - -接受一个数值类型的参数并返回它的平方根。 - -## cbrt(x) {#cbrtx} - -接受一个数值类型的参数并返回它的立方根。 - -## erf(x) {#erfx} - -如果'x'是非负数,那么erf(x / σ√2)是具有正态分布且标准偏差为«σ»的随机变量的值与预期值之间的距离大于«x»。 - -示例 (三西格玛准则): - -``` sql -SELECT erf(3 / sqrt(2)) -``` - - ┌─erf(divide(3, sqrt(2)))─┐ - │ 0.9973002039367398 │ - └─────────────────────────┘ - -## erfc(x) {#erfcx} - -接受一个数值参数并返回一个接近1 - erf(x)的Float64数字,但不会丢失大«x»值的精度。 - -## lgamma(x) {#lgammax} - -返回x的绝对值的自然对数的伽玛函数。 - -## tgamma(x) {#tgammax} - -返回x的伽玛函数。 - -## sin(x) {#sinx} - -返回x的三角正弦值。 - -## cos(x) {#cosx} - -返回x的三角余弦值。 - -## 谭(x) {#tanx} - -返回x的三角正切值。 - -## asin(x) {#asinx} - -返回x的反三角正弦值。 - -## acos(x) {#acosx} - -返回x的反三角余弦值。 - -## 阿坦(x) {#atanx} - -返回x的反三角正切值。 - -## pow(x,y),power(x,y) {#powx-y-powerx-y} - -接受x和y两个参数。返回x的y次方。 - -## intExp2 {#intexp2} - -接受一个数值类型的参数并返回它的2的x次幂(UInt64)。 - -## intExp10 {#intexp10} - -接受一个数值类型的参数并返回它的10的x次幂(UInt64)。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/math_functions/) diff --git a/docs/zh/sql_reference/functions/other_functions.md b/docs/zh/sql_reference/functions/other_functions.md deleted file mode 100644 index e0c7e47be58..00000000000 --- a/docs/zh/sql_reference/functions/other_functions.md +++ /dev/null @@ -1,538 +0,0 @@ - -# 其他函数 {#qi-ta-han-shu} - -## 主机名() {#hostname} - -返回一个字符串,其中包含执行此函数的主机的名称。 对于分布式处理,如果在远程服务器上执行此函数,则将返回远程服务器主机的名称。 - -## basename {#basename} - -在最后一个斜杠或反斜杠后的字符串文本。 此函数通常用于从路径中提取文件名。 - - basename( expr ) - -**参数** - -- `expr` — 任何一个返回[字符串](../../sql_reference/functions/other_functions.md)结果的表达式。[字符串](../../sql_reference/functions/other_functions.md) - -**返回值** - -一个String类型的值,其包含: - -- 在最后一个斜杠或反斜杠后的字符串文本内容。 - - 如果输入的字符串以斜杆或反斜杆结尾,例如:`/`或`c:\`,函数将返回一个空字符串。 - -- 如果输入的字符串中不包含斜杆或反斜杠,函数返回输入字符串本身。 - -**示例** - -``` sql -SELECT 'some/long/path/to/file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some\\long\\path\\to\\file' AS a, basename(a) -``` - -``` text -┌─a──────────────────────┬─basename('some\\long\\path\\to\\file')─┐ -│ some\long\path\to\file │ file │ -└────────────────────────┴────────────────────────────────────────┘ -``` - -``` sql -SELECT 'some-file-name' AS a, basename(a) -``` - -``` text -┌─a──────────────┬─basename('some-file-name')─┐ -│ some-file-name │ some-file-name │ -└────────────────┴────────────────────────────┘ -``` - -## visibleWidth(x) {#visiblewidthx} - -以文本格式(以制表符分隔)向控制台输出值时,计算近似宽度。 -系统使用此函数实现Pretty格式。 -以文本格式(制表符分隔)将值输出到控制台时,计算近似宽度。 -这个函数被系统用于实现漂亮的格式。 - -`NULL` 表示为对应于 `NULL` 在 `Pretty` 格式。 - - SELECT visibleWidth(NULL) - - ┌─visibleWidth(NULL)─┐ - │ 4 │ - └────────────────────┘ - -## toTypeName(x) {#totypenamex} - -返回包含参数的类型名称的字符串。 - -如果将`NULL`作为参数传递给函数,那么它返回`Nullable(Nothing)`类型,它对应于ClickHouse中的内部`NULL`。 - -## 块大小() {#function-blocksize} - -获取Block的大小。 -在ClickHouse中,查询始终工作在Block(包含列的部分的集合)上。此函数允许您获取调用其的块的大小。 - -## 实现(x) {#materializex} - -将一个常量列变为一个非常量列。 -在ClickHouse中,非常量列和常量列在内存中的表示方式不同。尽管函数对于常量列和非常量总是返回相同的结果,但它们的工作方式可能完全不同(执行不同的代码)。此函数用于调试这种行为。 - -## ignore(…) {#ignore} - -接受任何参数,包括`NULL`。始终返回0。 -但是,函数的参数总是被计算的。该函数可以用于基准测试。 - -## 睡眠(秒) {#sleepseconds} - -在每个Block上休眠'seconds'秒。可以是整数或浮点数。 - -## sleepEachRow(秒) {#sleepeachrowseconds} - -在每行上休眠'seconds'秒。可以是整数或浮点数。 - -## 当前数据库() {#currentdatabase} - -返回当前数据库的名称。 -当您需要在CREATE TABLE中的表引擎参数中指定数据库,您可以使用此函数。 - -## isFinite(x) {#isfinitex} - -接受Float32或Float64类型的参数,如果参数不是infinite且不是NaN,则返回1,否则返回0。 - -## isInfinite(x) {#isinfinitex} - -接受Float32或Float64类型的参数,如果参数是infinite,则返回1,否则返回0。注意NaN返回0。 - -## isNaN(x) {#isnanx} - -接受Float32或Float64类型的参数,如果参数是Nan,则返回1,否则返回0。 - -## hasColumnInTable(\[‘hostname’\[, ‘username’\[, ‘password’\]\],\] ‘database’, ‘table’, ‘column’) {#hascolumnintablehostname-username-password-database-table-column} - -接受常量字符串:数据库名称、表名称和列名称。 如果存在列,则返回等于1的UInt8常量表达式,否则返回0。 如果设置了hostname参数,则测试将在远程服务器上运行。 -如果表不存在,该函数将引发异常。 -对于嵌套数据结构中的元素,该函数检查是否存在列。 对于嵌套数据结构本身,函数返回0。 - -## 酒吧 {#function-bar} - -使用unicode构建图表。 - -`bar(x, min, max, width)` 当`x = max`时, 绘制一个宽度与`(x - min)`成正比且等于`width`的字符带。 - -参数: - -- `x` — 要显示的尺寸。 -- `min, max` — 整数常量,该值必须是`Int64`。 -- `width` — 常量,可以是正整数或小数。 - -字符带的绘制精度是符号的八分之一。 - -示例: - -``` sql -SELECT - toHour(EventTime) AS h, - count() AS c, - bar(c, 0, 600000, 20) AS bar -FROM test.hits -GROUP BY h -ORDER BY h ASC -``` - - ┌──h─┬──────c─┬─bar────────────────┐ - │ 0 │ 292907 │ █████████▋ │ - │ 1 │ 180563 │ ██████ │ - │ 2 │ 114861 │ ███▋ │ - │ 3 │ 85069 │ ██▋ │ - │ 4 │ 68543 │ ██▎ │ - │ 5 │ 78116 │ ██▌ │ - │ 6 │ 113474 │ ███▋ │ - │ 7 │ 170678 │ █████▋ │ - │ 8 │ 278380 │ █████████▎ │ - │ 9 │ 391053 │ █████████████ │ - │ 10 │ 457681 │ ███████████████▎ │ - │ 11 │ 493667 │ ████████████████▍ │ - │ 12 │ 509641 │ ████████████████▊ │ - │ 13 │ 522947 │ █████████████████▍ │ - │ 14 │ 539954 │ █████████████████▊ │ - │ 15 │ 528460 │ █████████████████▌ │ - │ 16 │ 539201 │ █████████████████▊ │ - │ 17 │ 523539 │ █████████████████▍ │ - │ 18 │ 506467 │ ████████████████▊ │ - │ 19 │ 520915 │ █████████████████▎ │ - │ 20 │ 521665 │ █████████████████▍ │ - │ 21 │ 542078 │ ██████████████████ │ - │ 22 │ 493642 │ ████████████████▍ │ - │ 23 │ 400397 │ █████████████▎ │ - └────┴────────┴────────────────────┘ - -## 变换 {#transform} - -根据定义,将某些元素转换为其他元素。 -此函数有两种使用方式: - -1. `transform(x, array_from, array_to, default)` - -`x` – 要转换的值。 - -`array_from` – 用于转换的常量数组。 - -`array_to` – 将'from'中的值转换为的常量数组。 - -`default` – 如果'x'不等于'from'中的任何值,则默认转换的值。 - -`array_from` 和 `array_to` – 拥有相同大小的数组。 - -类型约束: - -`transform(T, Array(T), Array(U), U) -> U` - -`T`和`U`可以是String,Date,DateTime或任意数值类型的。 -对于相同的字母(T或U),如果数值类型,那么它们不可不完全匹配的,只需要具备共同的类型即可。 -例如,第一个参数是Int64类型,第二个参数是Array(UInt16)类型。 - -如果'x'值等于'array\_from'数组中的一个元素,它将从'array\_to'数组返回一个对应的元素(下标相同)。否则,它返回'default'。如果'array\_from'匹配到了多个元素,则返回第一个匹配的元素。 - -示例: - -``` sql -SELECT - transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title, - count() AS c -FROM test.hits -WHERE SearchEngineID != 0 -GROUP BY title -ORDER BY c DESC -``` - - ┌─title─────┬──────c─┐ - │ Yandex │ 498635 │ - │ Google │ 229872 │ - │ Other │ 104472 │ - └───────────┴────────┘ - -1. `transform(x, array_from, array_to)` - -与第一种不同在于省略了'default'参数。 -如果'x'值等于'array\_from'数组中的一个元素,它将从'array\_to'数组返回相应的元素(下标相同)。 否则,它返回'x'。 - -类型约束: - -`transform(T, Array(T), Array(T)) -> T` - -示例: - -``` sql -SELECT - transform(domain(Referer), ['yandex.ru', 'google.ru', 'vk.com'], ['www.yandex', 'example.com']) AS s, - count() AS c -FROM test.hits -GROUP BY domain(Referer) -ORDER BY count() DESC -LIMIT 10 -``` - - ┌─s──────────────┬───────c─┐ - │ │ 2906259 │ - │ www.yandex │ 867767 │ - │ ███████.ru │ 313599 │ - │ mail.yandex.ru │ 107147 │ - │ ██████.ru │ 100355 │ - │ █████████.ru │ 65040 │ - │ news.yandex.ru │ 64515 │ - │ ██████.net │ 59141 │ - │ example.com │ 57316 │ - └────────────────┴─────────┘ - -## formatReadableSize(x) {#formatreadablesizex} - -接受大小(字节数)。返回带有后缀(KiB, MiB等)的字符串。 - -示例: - -``` sql -SELECT - arrayJoin([1, 1024, 1024*1024, 192851925]) AS filesize_bytes, - formatReadableSize(filesize_bytes) AS filesize -``` - - ┌─filesize_bytes─┬─filesize───┐ - │ 1 │ 1.00 B │ - │ 1024 │ 1.00 KiB │ - │ 1048576 │ 1.00 MiB │ - │ 192851925 │ 183.92 MiB │ - └────────────────┴────────────┘ - -## 至少(a,b) {#leasta-b} - -返回a和b中的最小值。 - -## 最伟大(a,b) {#greatesta-b} - -返回a和b的最大值。 - -## 碌莽禄time拢time() {#uptime} - -返回服务正常运行的秒数。 - -## 版本() {#version} - -以字符串形式返回服务器的版本。 - -## 时区() {#timezone} - -返回服务器的时区。 - -## blockNumber {#blocknumber} - -返回行所在的Block的序列号。 - -## rowNumberInBlock {#function-rownumberinblock} - -返回行所在Block中行的序列号。 针对不同的Block始终重新计算。 - -## rowNumberInAllBlocks() {#rownumberinallblocks} - -返回行所在结果集中的序列号。此函数仅考虑受影响的Block。 - -## 运行差异(x) {#other_functions-runningdifference} - -计算数据块中相邻行的值之间的差异。 -对于第一行返回0,并为每个后续行返回与前一行的差异。 - -函数的结果取决于受影响的Block和Block中的数据顺序。 -如果使用ORDER BY创建子查询并从子查询外部调用该函数,则可以获得预期结果。 - -示例: - -``` sql -SELECT - EventID, - EventTime, - runningDifference(EventTime) AS delta -FROM -( - SELECT - EventID, - EventTime - FROM events - WHERE EventDate = '2016-11-24' - ORDER BY EventTime ASC - LIMIT 5 -) -``` - - ┌─EventID─┬───────────EventTime─┬─delta─┐ - │ 1106 │ 2016-11-24 00:00:04 │ 0 │ - │ 1107 │ 2016-11-24 00:00:05 │ 1 │ - │ 1108 │ 2016-11-24 00:00:05 │ 0 │ - │ 1109 │ 2016-11-24 00:00:09 │ 4 │ - │ 1110 │ 2016-11-24 00:00:10 │ 1 │ - └─────────┴─────────────────────┴───────┘ - -## 运行差异启动与第一值 {#runningdifferencestartingwithfirstvalue} - -与[运行差异](./other_functions.md#other_functions-runningdifference)相同,区别在于第一行返回第一行的值,后续每个后续行返回与上一行的差值。 - -## MACNumToString(num) {#macnumtostringnum} - -接受一个UInt64类型的数字。 将其解释为big endian的MAC地址。 返回包含相应MAC地址的字符串,格式为AA:BB:CC:DD:EE:FF(以冒号分隔的十六进制形式的数字)。 - -## MACStringToNum(s) {#macstringtonums} - -与MACNumToString相反。 如果MAC地址格式无效,则返回0。 - -## MACStringToOUI(s) {#macstringtoouis} - -接受格式为AA:BB:CC:DD:EE:FF(十六进制形式的冒号分隔数字)的MAC地址。 返回前三个八位字节作为UInt64编号。 如果MAC地址格式无效,则返回0。 - -## getSizeOfEnumType {#getsizeofenumtype} - -返回[枚举](../../sql_reference/functions/other_functions.md)中的枚举数量。 - - getSizeOfEnumType(value) - -**参数:** - -- `value` — `Enum`类型的值。 - -**返回值** - -- `Enum`的枚举数量。 -- 如果类型不是`Enum`,则抛出异常。 - -**示例** - - SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x - - ┌─x─┐ - │ 2 │ - └───┘ - -## toColumnTypeName {#tocolumntypename} - -返回在RAM中列的数据类型的名称。 - - toColumnTypeName(value) - -**参数:** - -- `value` — 任何类型的值。 - -**返回值** - -- 一个字符串,其内容是`value`在RAM中的类型名称。 - -**`toTypeName ' 与 ' toColumnTypeName`的区别示例** - - :) select toTypeName(cast('2018-01-01 01:02:03' AS DateTime)) - - SELECT toTypeName(CAST('2018-01-01 01:02:03', 'DateTime')) - - ┌─toTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ - │ DateTime │ - └─────────────────────────────────────────────────────┘ - - 1 rows in set. Elapsed: 0.008 sec. - - :) select toColumnTypeName(cast('2018-01-01 01:02:03' AS DateTime)) - - SELECT toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime')) - - ┌─toColumnTypeName(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ - │ Const(UInt32) │ - └───────────────────────────────────────────────────────────┘ - -该示例显示`DateTime`数据类型作为`Const(UInt32)`存储在内存中。 - -## dumpColumnStructure {#dumpcolumnstructure} - -输出在RAM中的数据结果的详细信息。 - - dumpColumnStructure(value) - -**参数:** - -- `value` — 任何类型的值. - -**返回值** - -- 一个字符串,其内容是`value`在RAM中的数据结构的详细描述。 - -**示例** - - SELECT dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime')) - - ┌─dumpColumnStructure(CAST('2018-01-01 01:02:03', 'DateTime'))─┐ - │ DateTime, Const(size = 1, UInt32(size = 1)) │ - └──────────────────────────────────────────────────────────────┘ - -## defaultValueOfArgumentType {#defaultvalueofargumenttype} - -输出数据类型的默认值。 - -不包括用户设置的自定义列的默认值。 - - defaultValueOfArgumentType(expression) - -**参数:** - -- `expression` — 任意类型的值或导致任意类型值的表达式。 - -**返回值** - -- 数值类型返回`0`。 -- 字符串类型返回空的字符串。 -- [可为空](../../sql_reference/functions/other_functions.md)类型返回`ᴺᵁᴸᴸ`。 - -**示例** - - :) SELECT defaultValueOfArgumentType( CAST(1 AS Int8) ) - - SELECT defaultValueOfArgumentType(CAST(1, 'Int8')) - - ┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐ - │ 0 │ - └─────────────────────────────────────────────┘ - - 1 rows in set. Elapsed: 0.002 sec. - - :) SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) - - SELECT defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)')) - - ┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐ - │ ᴺᵁᴸᴸ │ - └───────────────────────────────────────────────────────┘ - - 1 rows in set. Elapsed: 0.002 sec. - -## 复制 {#replicate} - -使用单个值填充一个数组。 - -用于[arrayJoin](array_join.md#functions_arrayjoin)的内部实现。 - - replicate(x, arr) - -**参数:** - -- `arr` — 原始数组。 ClickHouse创建一个与原始数据长度相同的新数组,并用值`x`填充它。 -- `x` — 生成的数组将被填充的值。 - -**输出** - -- 一个被`x`填充的数组。 - -**示例** - - SELECT replicate(1, ['a', 'b', 'c']) - - ┌─replicate(1, ['a', 'b', 'c'])─┐ - │ [1,1,1] │ - └───────────────────────────────┘ - -## 文件系统可用 {#filesystemavailable} - -返回磁盘的剩余空间信息(以字节为单位)。使用配置文件中的path配置评估此信息。 - -## 文件系统容量 {#filesystemcapacity} - -返回磁盘的容量信息,以字节为单位。使用配置文件中的path配置评估此信息。 - -## 最后聚会 {#function-finalizeaggregation} - -获取聚合函数的状态。返回聚合结果(最终状态)。 - -## 跑累积 {#function-runningaccumulate} - -获取聚合函数的状态并返回其具体的值。这是从第一行到当前行的所有行累计的结果。 - -例如,获取聚合函数的状态(示例runningAccumulate(uniqState(UserID))),对于数据块的每一行,返回所有先前行和当前行的状态合并后的聚合函数的结果。 -因此,函数的结果取决于分区中数据块的顺序以及数据块中行的顺序。 - -## joinGet(‘join\_storage\_table\_name’, ‘get\_column’,join\_key) {#joingetjoin-storage-table-name-get-column-join-key} - -使用指定的连接键从Join类型引擎的表中获取数据。 - -## modelEvaluate(model\_name, …) {#function-modelevaluate} - -使用外部模型计算。 -接受模型的名称以及模型的参数。返回Float64类型的值。 - -## throwIf(x) {#throwifx} - -如果参数不为零则抛出异常。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/docs/zh/sql_reference/functions/random_functions.md b/docs/zh/sql_reference/functions/random_functions.md deleted file mode 100644 index 1db2f4a8438..00000000000 --- a/docs/zh/sql_reference/functions/random_functions.md +++ /dev/null @@ -1,22 +0,0 @@ - -# 随机函数 {#sui-ji-han-shu} - -随机函数使用非加密方式生成伪随机数字。 - -所有随机函数都只接受一个参数或不接受任何参数。 -您可以向它传递任何类型的参数,但传递的参数将不会使用在任何随机数生成过程中。 -此参数的唯一目的是防止公共子表达式消除,以便在相同的查询中使用相同的随机函数生成不同的随机数。 - -## 兰德 {#rand} - -返回一个UInt32类型的随机数字,所有UInt32类型的数字被生成的概率均相等。此函数线性同于的方式生成随机数。 - -## rand64 {#rand64} - -返回一个UInt64类型的随机数字,所有UInt64类型的数字被生成的概率均相等。此函数线性同于的方式生成随机数。 - -## randConstant {#randconstant} - -返回一个UInt32类型的随机数字,该函数不同之处在于仅为每个数据块参数一个随机数。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/random_functions/) diff --git a/docs/zh/sql_reference/functions/rounding_functions.md b/docs/zh/sql_reference/functions/rounding_functions.md deleted file mode 100644 index 773f969090d..00000000000 --- a/docs/zh/sql_reference/functions/rounding_functions.md +++ /dev/null @@ -1,87 +0,0 @@ - -# 取整函数 {#qu-zheng-han-shu} - -## 楼(x\[,N\]) {#floorx-n} - -返回小于或等于x的最大舍入数。该函数使用参数乘1/10N,如果1/10N不精确,则选择最接近的精确的适当数据类型的数。 -'N'是一个整数常量,可选参数。默认为0,这意味着不对其进行舍入。 -'N'可以是负数。 - -示例: `floor(123.45, 1) = 123.4, floor(123.45, -1) = 120.` - -`x`是任何数字类型。结果与其为相同类型。 -对于整数参数,使用负'N'值进行舍入是有意义的(对于非负«N»,该函数不执行任何操作)。 -如果取整导致溢出(例如,floor(-128,-1)),则返回特定于实现的结果。 - -## ceil(x\[,N\]),天花板(x\[,N\]) {#ceilx-n-ceilingx-n} - -返回大于或等于'x'的最小舍入数。在其他方面,它与'floor'功能相同(见上文)。 - -## 圆形(x\[,N\]) {#rounding_functions-round} - -将值取整到指定的小数位数。 - -该函数按顺序返回最近的数字。如果给定数字包含多个最近数字,则函数返回其中最接近偶数的数字(银行的取整方式)。 - - round(expression [, decimal_places]) - -**参数:** - -- `expression` — 要进行取整的数字。可以是任何返回数字[类型](../../sql_reference/functions/rounding_functions.md#data_types)的[表达式](../syntax.md#syntax-expressions)。 -- `decimal-places` — 整数类型。 - - 如果`decimal-places > 0`,则该函数将值舍入小数点右侧。 - - 如果`decimal-places < 0`,则该函数将小数点左侧的值四舍五入。 - - 如果`decimal-places = 0`,则该函数将该值舍入为整数。在这种情况下,可以省略参数。 - -**返回值:** - -与输入数字相同类型的取整后的数字。 - -### 示例 {#shi-li} - -**使用示例** - -``` sql -SELECT number / 2 AS x, round(x) FROM system.numbers LIMIT 3 -``` - - ┌───x─┬─round(divide(number, 2))─┐ - │ 0 │ 0 │ - │ 0.5 │ 0 │ - │ 1 │ 1 │ - └─────┴──────────────────────────┘ - -**取整的示例** - -取整到最近的数字。 - - round(3.2, 0) = 3 - round(4.1267, 2) = 4.13 - round(22,-1) = 20 - round(467,-2) = 500 - round(-467,-2) = -500 - -银行的取整。 - - round(3.5) = 4 - round(4.5) = 4 - round(3.55, 1) = 3.6 - round(3.65, 1) = 3.6 - -## roundToExp2(num) {#roundtoexp2num} - -接受一个数字。如果数字小于1,则返回0。否则,它将数字向下舍入到最接近的(整个非负)2的x次幂。 - -## 圆形饱和度(num) {#rounddurationnum} - -接受一个数字。如果数字小于1,则返回0。否则,它将数字向下舍入为集合中的数字:1,10,30,60,120,180,240,300,600,1200,1800,3600,7200,18000,36000。此函数用于Yandex.Metrica报表中计算会话的持续时长。 - -## 圆数(num) {#roundagenum} - -接受一个数字。如果数字小于18,则返回0。否则,它将数字向下舍入为集合中的数字:18,25,35,45,55。此函数用于Yandex.Metrica报表中用户年龄的计算。 - -## roundDown(num,arr) {#rounddownnum-arr} - -接受一个数字,将其向下舍入到指定数组中的元素。如果该值小于数组中的最低边界,则返回最低边界。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/rounding_functions/) diff --git a/docs/zh/sql_reference/functions/splitting_merging_functions.md b/docs/zh/sql_reference/functions/splitting_merging_functions.md deleted file mode 100644 index d217ea19f0d..00000000000 --- a/docs/zh/sql_reference/functions/splitting_merging_functions.md +++ /dev/null @@ -1,30 +0,0 @@ - -# 字符串拆分合并函数 {#zi-fu-chuan-chai-fen-he-bing-han-shu} - -## splitByChar(分隔符,s) {#splitbycharseparator-s} - -将字符串以'separator'拆分成多个子串。'separator'必须为仅包含一个字符的字符串常量。 -返回拆分后的子串的数组。 如果分隔符出现在字符串的开头或结尾,或者如果有多个连续的分隔符,则将在对应位置填充空的子串。 - -## splitByString(分隔符,s) {#splitbystringseparator-s} - -与上面相同,但它使用多个字符的字符串作为分隔符。 该字符串必须为非空。 - -## arrayStringConcat(arr\[,分隔符\]) {#arraystringconcatarr-separator} - -使用separator将数组中列出的字符串拼接起来。'separator'是一个可选参数:一个常量字符串,默认情况下设置为空字符串。 -返回拼接后的字符串。 - -## alphaTokens(s) {#alphatokenss} - -从范围a-z和A-Z中选择连续字节的子字符串。返回子字符串数组。 - -**示例:** - - SELECT alphaTokens('abca1abc') - - ┌─alphaTokens('abca1abc')─┐ - │ ['abca','abc'] │ - └─────────────────────────┘ - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/splitting_merging_functions/) diff --git a/docs/zh/sql_reference/functions/string_functions.md b/docs/zh/sql_reference/functions/string_functions.md deleted file mode 100644 index c04305b9d67..00000000000 --- a/docs/zh/sql_reference/functions/string_functions.md +++ /dev/null @@ -1,170 +0,0 @@ - -# 字符串函数 {#zi-fu-chuan-han-shu} - -## 空 {#string-functions-empty} - -对于空字符串返回1,对于非空字符串返回0。 -结果类型是UInt8。 -如果字符串包含至少一个字节,则该字符串被视为非空字符串,即使这是一个空格或空字符。 -该函数也适用于数组。 - -## notEmpty {#notempty} - -对于空字符串返回0,对于非空字符串返回1。 -结果类型是UInt8。 -该函数也适用于数组。 - -## 长度 {#length} - -返回字符串的字节长度。 -结果类型是UInt64。 -该函数也适用于数组。 - -## 长度8 {#lengthutf8} - -假定字符串以UTF-8编码组成的文本,返回此字符串的Unicode字符长度。如果传入的字符串不是UTF-8编码,则函数可能返回一个预期外的值(不会抛出异常)。 -结果类型是UInt64。 - -## char\_length,CHAR\_LENGTH {#char-length-char-length} - -假定字符串以UTF-8编码组成的文本,返回此字符串的Unicode字符长度。如果传入的字符串不是UTF-8编码,则函数可能返回一个预期外的值(不会抛出异常)。 -结果类型是UInt64。 - -## 字符长度,字符长度 {#character-length-character-length} - -假定字符串以UTF-8编码组成的文本,返回此字符串的Unicode字符长度。如果传入的字符串不是UTF-8编码,则函数可能返回一个预期外的值(不会抛出异常)。 -结果类型是UInt64。 - -## 低一点 {#lower-lcase} - -将字符串中的ASCII转换为小写。 - -## 上,ucase {#upper-ucase} - -将字符串中的ASCII转换为大写。 - -## lowerUTF8 {#lowerutf8} - -将字符串转换为小写,函数假设字符串是以UTF-8编码文本的字符集。 -同时函数不检测语言。因此对土耳其人来说,结果可能不完全正确。 -如果UTF-8字节序列的长度对于代码点的大写和小写不同,则该代码点的结果可能不正确。 -如果字符串包含一组非UTF-8的字节,则将引发未定义行为。 - -## upperUTF8 {#upperutf8} - -将字符串转换为大写,函数假设字符串是以UTF-8编码文本的字符集。 -同时函数不检测语言。因此对土耳其人来说,结果可能不完全正确。 -如果UTF-8字节序列的长度对于代码点的大写和小写不同,则该代码点的结果可能不正确。 -如果字符串包含一组非UTF-8的字节,则将引发未定义行为。 - -## isValidUTF8 {#isvalidutf8} - -检查字符串是否为有效的UTF-8编码,是则返回1,否则返回0。 - -## toValidUTF8 {#tovalidutf8} - -用`�`(U+FFFD)字符替换无效的UTF-8字符。所有连续的无效字符都会被替换为一个替换字符。 - - toValidUTF8( input_string ) - -参数: - -- input\_string — 任何一个[字符串](../../sql_reference/functions/string_functions.md)类型的对象。 - -返回值: 有效的UTF-8字符串。 - -### 示例 {#shi-li} - -``` sql -SELECT toValidUTF8('\x61\xF0\x80\x80\x80b') -``` - -``` text -┌─toValidUTF8('a����b')─┐ -│ a�b │ -└───────────────────────┘ -``` - -## 反向 {#reverse} - -反转字符串。 - -## reverseUTF8 {#reverseutf8} - -以Unicode字符为单位反转UTF-8编码的字符串。如果字符串不是UTF-8编码,则可能获取到一个非预期的结果(不会抛出异常)。 - -## format(pattern, s0, s1, …) {#formatpattern-s0-s1} - -使用常量字符串`pattern`格式化其他参数。`pattern`字符串中包含由大括号`{}`包围的«替换字段»。 未被包含在大括号中的任何内容都被视为文本内容,它将原样保留在返回值中。 如果你需要在文本内容中包含一个大括号字符,它可以通过加倍来转义:`{{ '{{' }}`和`{{ '{{' }} '}}' }}`。 字段名称可以是数字(从零开始)或空(然后将它们视为连续数字) - -``` sql -SELECT format('{1} {0} {1}', 'World', 'Hello') - -┌─format('{1} {0} {1}', 'World', 'Hello')─┐ -│ Hello World Hello │ -└─────────────────────────────────────────┘ - -SELECT format('{} {}', 'Hello', 'World') - -┌─format('{} {}', 'Hello', 'World')─┐ -│ Hello World │ -└───────────────────────────────────┘ -``` - -## concat(s1, s2, …) {#concats1-s2} - -将参数中的多个字符串拼接,不带分隔符。 - -## concatAssumeInjective(s1, s2, …) {#concatassumeinjectives1-s2} - -与[concat](./string_functions.md#concat-s1-s2)相同,区别在于,你需要保证concat(s1, s2, s3) -\> s4是单射的,它将用于GROUP BY的优化。 - -## 子串(s,offset,length),mid(s,offset,length),substr(s,offset,length) {#substrings-offset-length-mids-offset-length-substrs-offset-length} - -以字节为单位截取指定位置字符串,返回以'offset'位置为开头,长度为'length'的子串。'offset'从1开始(与标准SQL相同)。'offset'和'length'参数必须是常量。 - -## substringf8(s,offset,length) {#substringutf8s-offset-length} - -与'substring'相同,但其操作单位为Unicode字符,函数假设字符串是以UTF-8进行编码的文本。如果不是则可能返回一个预期外的结果(不会抛出异常)。 - -## appendTrailingCharIfAbsent(s,c) {#appendtrailingcharifabsents-c} - -如果's'字符串非空并且末尾不包含'c'字符,则将'c'字符附加到末尾。 - -## convertCharset(s,from,to) {#convertcharsets-from-to} - -返回从'from'中的编码转换为'to'中的编码的字符串's'。 - -## base64Encode(s) {#base64encodes} - -将字符串's'编码成base64 - -## base64Decode(s) {#base64decodes} - -使用base64将字符串解码成原始字符串。如果失败则抛出异常。 - -## tryBase64Decode(s) {#trybase64decodes} - -使用base64将字符串解码成原始字符串。但如果出现错误,将返回空字符串。 - -## endsWith(s,后缀) {#endswiths-suffix} - -返回是否以指定的后缀结尾。如果字符串以指定的后缀结束,则返回1,否则返回0。 - -## 开始使用(s,前缀) {#startswiths-prefix} - -返回是否以指定的前缀开头。如果字符串以指定的前缀开头,则返回1,否则返回0。 - -## trimLeft(s) {#trimlefts} - -返回一个字符串,用于删除左侧的空白字符。 - -## trimRight(s) {#trimrights} - -返回一个字符串,用于删除右侧的空白字符。 - -## trimBoth(s) {#trimboths} - -返回一个字符串,用于删除任一侧的空白字符。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/string_functions/) diff --git a/docs/zh/sql_reference/functions/string_replace_functions.md b/docs/zh/sql_reference/functions/string_replace_functions.md deleted file mode 100644 index 04b110a2cef..00000000000 --- a/docs/zh/sql_reference/functions/string_replace_functions.md +++ /dev/null @@ -1,80 +0,0 @@ - -# 字符串替换函数 {#zi-fu-chuan-ti-huan-han-shu} - -## replaceOne(大海捞针,模式,更换) {#replaceonehaystack-pattern-replacement} - -用'replacement'子串替换'haystack'中与'pattern'子串第一个匹配的匹配项(如果存在)。 -'pattern'和'replacement'必须是常量。 - -## replaceAll(大海捞针,模式,替换),替换(大海捞针,模式,替换) {#replaceallhaystack-pattern-replacement-replacehaystack-pattern-replacement} - -用'replacement'子串替换'haystack'中出现的所有'pattern'子串。 - -## replaceRegexpOne(大海捞针,模式,更换) {#replaceregexponehaystack-pattern-replacement} - -使用'pattern'正则表达式替换。 ‘pattern’可以是任意一个有效的re2正则表达式。 -如果存在与正则表达式匹配的匹配项,仅替换第一个匹配项。 -同时‘replacement’可以指定为正则表达式中的捕获组。可以包含`\0-\9`。 -在这种情况下,函数将使用正则表达式的整个匹配项替换‘\\0’。使用其他与之对应的子模式替换对应的'\\1-\\9'。要在模版中使用''字符,请使用''将其转义。 -另外还请记住,字符串文字需要额外的转义。 - -示例1.将日期转换为美国格式: - -``` sql -SELECT DISTINCT - EventDate, - replaceRegexpOne(toString(EventDate), '(\\d{4})-(\\d{2})-(\\d{2})', '\\2/\\3/\\1') AS res -FROM test.hits -LIMIT 7 -FORMAT TabSeparated -``` - - 2014-03-17 03/17/2014 - 2014-03-18 03/18/2014 - 2014-03-19 03/19/2014 - 2014-03-20 03/20/2014 - 2014-03-21 03/21/2014 - 2014-03-22 03/22/2014 - 2014-03-23 03/23/2014 - -示例2.复制字符串十次: - -``` sql -SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res -``` - - ┌─res────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World! │ - └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - -## replaceRegexpAll(大海捞针,模式,替换) {#replaceregexpallhaystack-pattern-replacement} - -与replaceRegexpOne相同,但会替换所有出现的匹配项。例如: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res -``` - - ┌─res────────────────────────┐ - │ HHeelllloo,, WWoorrlldd!! │ - └────────────────────────────┘ - -例外的是,如果使用正则表达式捕获空白子串,则仅会进行一次替换。 -示例: - -``` sql -SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res -``` - - ┌─res─────────────────┐ - │ here: Hello, World! │ - └─────────────────────┘ - -## regexpQuoteMeta(s) {#regexpquotemetas} - -该函数用于在字符串中的某些预定义字符之前添加反斜杠。 -预定义字符:‘0’,‘\\’,‘\|’,‘(’,‘)’,‘^’,‘$’,‘。’,‘\[’,'\]',‘?’,‘\*’,‘+’,‘{’,‘:’,' - '。 -这个实现与re2 :: RE2 :: QuoteMeta略有不同。它以\\0而不是00转义零字节,它只转义所需的字符。 -有关详细信息,请参阅链接:\[RE2\](https://github.com/google/re2/blob/master/re2/re2.cc\#L473) - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/string_replace_functions/) diff --git a/docs/zh/sql_reference/functions/string_search_functions.md b/docs/zh/sql_reference/functions/string_search_functions.md deleted file mode 100644 index e0f5e06a357..00000000000 --- a/docs/zh/sql_reference/functions/string_search_functions.md +++ /dev/null @@ -1,123 +0,0 @@ - -# 字符串搜索函数 {#zi-fu-chuan-sou-suo-han-shu} - -下列所有函数在默认的情况下区分大小写。对于不区分大小写的搜索,存在单独的变体。 - -## 位置(大海捞针),定位(大海捞针) {#positionhaystack-needle-locatehaystack-needle} - -在字符串`haystack`中搜索子串`needle`。 -返回子串的位置(以字节为单位),从1开始,如果未找到子串,则返回0。 - -对于不区分大小写的搜索,请使用函数`positionCaseInsensitive`。 - -## positionUTF8(大海捞针) {#positionutf8haystack-needle} - -与`position`相同,但位置以Unicode字符返回。此函数工作在UTF-8编码的文本字符集中。如非此编码的字符集,则返回一些非预期结果(他不会抛出异常)。 - -对于不区分大小写的搜索,请使用函数`positionCaseInsensitiveUTF8`。 - -## 多搜索分配(干草堆,\[针1,针2, …, needlen\]) {#multisearchallpositionshaystack-needle1-needle2-needlen} - -与`position`相同,但函数返回一个数组,其中包含所有匹配needle的位置。 - -对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchAllPositionsCaseInsensitive,multiSearchAllPositionsUTF8,multiSearchAllPositionsCaseInsensitiveUTF8`。 - -## multiSearchFirstPosition(大海捞针,\[针1,针2, …, needlen\]) {#multisearchfirstpositionhaystack-needle1-needle2-needlen} - -与`position`相同,但返回在`haystack`中与needles字符串匹配的最左偏移。 - -对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchFirstPositionCaseInsensitive,multiSearchFirstPositionUTF8,multiSearchFirstPositionCaseInsensitiveUTF8`。 - -## multiSearchFirstIndex(大海捞针,\[针1,针2, …, needlen\]) {#multisearchfirstindexhaystack-needle1-needle2-needlen} - -返回在字符串`haystack`中最先查找到的needle的索引`i`(从1开始),没有找到任何匹配项则返回0。 - -对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchFirstIndexCaseInsensitive,multiSearchFirstIndexUTF8,multiSearchFirstIndexCaseInsensitiveUTF8`。 - -## 多搜索(大海捞针,\[针1,针2, …, needlen\]) {#multisearchanyhaystack-needle1-needle2-needlen} - -如果`haystack`中至少存在一个needle匹配则返回1,否则返回0。 - -对于不区分大小写的搜索或/和UTF-8格式,使用函数`multiSearchAnyCaseInsensitive,multiSearchAnyUTF8,multiSearchAnyCaseInsensitiveUTF8`。 - -!!! note "注意" - 在所有`multiSearch*`函数中,由于实现规范,needles的数量应小于28。 - -## 匹配(大海捞针,模式) {#matchhaystack-pattern} - -检查字符串是否与`pattern`正则表达式匹配。`pattern`可以是一个任意的`re2`正则表达式。 `re2`正则表达式的[语法](https://github.com/google/re2/wiki/Syntax)比Perl正则表达式的语法存在更多限制。 - -如果不匹配返回0,否则返回1。 - -请注意,反斜杠符号(`\`)用于在正则表达式中转义。由于字符串中采用相同的符号来进行转义。因此,为了在正则表达式中转义符号,必须在字符串文字中写入两个反斜杠(\\)。 - -正则表达式与字符串一起使用,就像它是一组字节一样。正则表达式中不能包含空字节。 -对于在字符串中搜索子字符串的模式,最好使用LIKE或«position»,因为它们更加高效。 - -## multiMatchAny(大海捞针,\[模式1,模式2, …, patternn\]) {#multimatchanyhaystack-pattern1-pattern2-patternn} - -与`match`相同,但如果所有正则表达式都不匹配,则返回0;如果任何模式匹配,则返回1。它使用[超扫描](https://github.com/intel/hyperscan)库。对于在字符串中搜索子字符串的模式,最好使用«multisearchany»,因为它更高效。 - -!!! note "注意" - 任何`haystack`字符串的长度必须小于232\字节,否则抛出异常。这种限制是因为hyperscan API而产生的。 - -## multiMatchAnyIndex(大海捞针,\[模式1,模式2, …, patternn\]) {#multimatchanyindexhaystack-pattern1-pattern2-patternn} - -与`multiMatchAny`相同,但返回与haystack匹配的任何内容的索引位置。 - -## multiFuzzyMatchAny(干草堆,距离,\[模式1,模式2, …, patternn\]) {#multifuzzymatchanyhaystack-distance-pattern1-pattern2-patternn} - -与`multiMatchAny`相同,但如果在haystack能够查找到任何模式匹配能够在指定的[编辑距离](https://en.wikipedia.org/wiki/Edit_distance)内进行匹配,则返回1。此功能也处于实验模式,可能非常慢。有关更多信息,请参阅[hyperscan文档](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching)。 - -## multiFuzzyMatchAnyIndex(大海捞针,距离,\[模式1,模式2, …, patternn\]) {#multifuzzymatchanyindexhaystack-distance-pattern1-pattern2-patternn} - -与`multiFuzzyMatchAny`相同,但返回匹配项的匹配能容的索引位置。 - -!!! note "注意" - `multiFuzzyMatch*`函数不支持UTF-8正则表达式,由于hyperscan限制,这些表达式被按字节解析。 - -!!! note "注意" - 如要关闭所有hyperscan函数的使用,请设置`SET allow_hyperscan = 0;`。 - -## 提取(大海捞针,图案) {#extracthaystack-pattern} - -使用正则表达式截取字符串。如果'haystack'与'pattern'不匹配,则返回空字符串。如果正则表达式中不包含子模式,它将获取与整个正则表达式匹配的子串。否则,它将获取与第一个子模式匹配的子串。 - -## extractAll(大海捞针,图案) {#extractallhaystack-pattern} - -使用正则表达式提取字符串的所有片段。如果'haystack'与'pattern'正则表达式不匹配,则返回一个空字符串。否则返回所有与正则表达式匹配的字符串数组。通常,行为与'extract'函数相同(它采用第一个子模式,如果没有子模式,则采用整个表达式)。 - -## 像(干草堆,模式),干草堆像模式运算符 {#likehaystack-pattern-haystack-like-pattern-operator} - -检查字符串是否与简单正则表达式匹配。 -正则表达式可以包含的元符号有`%`和`_`。 - -`%` 表示任何字节数(包括零字符)。 - -`_` 表示任何一个字节。 - -可以使用反斜杠(`\`)来对元符号进行转义。请参阅«match»函数说明中有关转义的说明。 - -对于像`%needle%`这样的正则表达式,改函数与`position`函数一样快。 -对于其他正则表达式,函数与'match'函数相同。 - -## 不喜欢(干草堆,模式),干草堆不喜欢模式运算符 {#notlikehaystack-pattern-haystack-not-like-pattern-operator} - -与'like'函数返回相反的结果。 - -## 大海捞针) {#ngramdistancehaystack-needle} - -基于4-gram计算`haystack`和`needle`之间的距离:计算两个4-gram集合之间的对称差异,并用它们的基数和对其进行归一化。返回0到1之间的任何浮点数 – 越接近0则表示越多的字符串彼此相似。如果常量的`needle`或`haystack`超过32KB,函数将抛出异常。如果非常量的`haystack`或`needle`字符串超过32Kb,则距离始终为1。 - -对于不区分大小写的搜索或/和UTF-8格式,使用函数`ngramDistanceCaseInsensitive,ngramDistanceUTF8,ngramDistanceCaseInsensitiveUTF8`。 - -## ツ暗ェツ氾环催ツ団ツ法ツ人) {#ngramsearchhaystack-needle} - -与`ngramDistance`相同,但计算`needle`和`haystack`之间的非对称差异——`needle`的n-gram减去`needle`归一化n-gram。可用于模糊字符串搜索。 - -对于不区分大小写的搜索或/和UTF-8格式,使用函数`ngramSearchCaseInsensitive,ngramSearchUTF8,ngramSearchCaseInsensitiveUTF8`。 - -!!! note "注意" - 对于UTF-8,我们使用3-gram。所有这些都不是完全公平的n-gram距离。我们使用2字节哈希来散列n-gram,然后计算这些哈希表之间的(非)对称差异 - 可能会发生冲突。对于UTF-8不区分大小写的格式,我们不使用公平的`tolower`函数 - 我们将每个Unicode字符字节的第5位(从零开始)和字节的第一位归零 - 这适用于拉丁语,主要用于所有西里尔字母。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/string_search_functions/) diff --git a/docs/zh/sql_reference/functions/type_conversion_functions.md b/docs/zh/sql_reference/functions/type_conversion_functions.md deleted file mode 100644 index 56375eabc07..00000000000 --- a/docs/zh/sql_reference/functions/type_conversion_functions.md +++ /dev/null @@ -1,170 +0,0 @@ - -# 类型转换函数 {#lei-xing-zhuan-huan-han-shu} - -## toUInt8,toUInt16,toUInt32,toUInt64 {#touint8-touint16-touint32-touint64} - -## toInt8,toInt16,toInt32,toInt64 {#toint8-toint16-toint32-toint64} - -## toFloat32,toFloat64 {#tofloat32-tofloat64} - -## 今天,今天 {#todate-todatetime} - -## toUInt8OrZero,toUInt16OrZero,toUInt32OrZero,toUInt64OrZero,toInt8OrZero,toInt16OrZero,toInt32OrZero,toInt64OrZero,toFloat32OrZero,toFloat64OrZero,toDateOrZero,toDateTimeOrZero {#touint8orzero-touint16orzero-touint32orzero-touint64orzero-toint8orzero-toint16orzero-toint32orzero-toint64orzero-tofloat32orzero-tofloat64orzero-todateorzero-todatetimeorzero} - -## toUInt8OrNull,toUInt16OrNull,toUInt32OrNull,toUInt64OrNull,toInt8OrNull,toInt16OrNull,toInt32OrNull,toInt64OrNull,toFloat32OrNull,toFloat64OrNull,toDateOrNull,toDateTimeOrNull {#touint8ornull-touint16ornull-touint32ornull-touint64ornull-toint8ornull-toint16ornull-toint32ornull-toint64ornull-tofloat32ornull-tofloat64ornull-todateornull-todatetimeornull} - -## toString {#tostring} - -这些函数用于在数字、字符串(不包含FixedString)、Date以及DateTime之间互相转换。 -所有的函数都接受一个参数。 - -当将其他类型转换到字符串或从字符串转换到其他类型时,使用与TabSeparated格式相同的规则对字符串的值进行格式化或解析。如果无法解析字符串则抛出异常并取消查询。 - -当将Date转换为数字或反之,Date对应Unix时间戳的天数。 -将DataTime转换为数字或反之,DateTime对应Unix时间戳的秒数。 - -toDate/toDateTime函数的日期和日期时间格式定义如下: - - YYYY-MM-DD - YYYY-MM-DD hh:mm:ss - -例外的是,如果将UInt32、Int32、UInt64或Int64类型的数值转换为Date类型,并且其对应的值大于等于65536,则该数值将被解析成unix时间戳(而不是对应的天数)。这意味着允许写入'toDate(unix\_timestamp)'这种常见情况,否则这将是错误的,并且需要便携更加繁琐的'toDate(toDateTime(unix\_timestamp))'。 - -Date与DateTime之间的转换以更为自然的方式进行:通过添加空的time或删除time。 - -数值类型之间的转换与C++中不同数字类型之间的赋值相同的规则。 - -此外,DateTime参数的toString函数可以在第二个参数中包含时区名称。 例如:`Asia/Yekaterinburg`在这种情况下,时间根据指定的时区进行格式化。 - -``` sql -SELECT - now() AS now_local, - toString(now(), 'Asia/Yekaterinburg') AS now_yekat -``` - - ┌───────────now_local─┬─now_yekat───────────┐ - │ 2016-06-15 00:11:21 │ 2016-06-15 02:11:21 │ - └─────────────────────┴─────────────────────┘ - -另请参阅`toUnixTimestamp`函数。 - -## toDecimal32(value,S),toDecimal64(value,S),toDecimal128(value,S) {#todecimal32value-s-todecimal64value-s-todecimal128value-s} - -将`value`转换为精度为`S`的[十进制](../../sql_reference/functions/type_conversion_functions.md)。`value`可以是数字或字符串。`S`参数为指定的小数位数。 - -## toFixedString(s,N) {#tofixedstrings-n} - -将String类型的参数转换为FixedString(N)类型的值(具有固定长度N的字符串)。N必须是一个常量。 -如果字符串的字节数少于N,则向右填充空字节。如果字符串的字节数多于N,则抛出异常。 - -## toStringCutToZero(s) {#tostringcuttozeros} - -接受String或FixedString参数。返回String,其内容在找到的第一个零字节处被截断。 - -示例: - -``` sql -SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut -``` - - ┌─s─────────────┬─s_cut─┐ - │ foo\0\0\0\0\0 │ foo │ - └───────────────┴───────┘ - -``` sql -SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut -``` - - ┌─s──────────┬─s_cut─┐ - │ foo\0bar\0 │ foo │ - └────────────┴───────┘ - -## reinterpretAsUInt8,reinterpretAsUInt16,reinterpretAsUInt32,reinterpretAsUInt64 {#reinterpretasuint8-reinterpretasuint16-reinterpretasuint32-reinterpretasuint64} - -## reinterpretAsInt8,reinterpretAsInt16,reinterpretAsInt32,reinterpretAsInt64 {#reinterpretasint8-reinterpretasint16-reinterpretasint32-reinterpretasint64} - -## reinterpretAsFloat32,reinterpretAsFloat64 {#reinterpretasfloat32-reinterpretasfloat64} - -## 重新解释日期,重新解释日期时间 {#reinterpretasdate-reinterpretasdatetime} - -这些函数接受一个字符串,并将放在字符串开头的字节解释为主机顺序中的数字(little endian)。如果字符串不够长,则函数就像使用必要数量的空字节填充字符串一样。如果字符串比需要的长,则忽略额外的字节。Date被解释为Unix时间戳的天数,DateTime被解释为Unix时间戳。 - -## 重新解释字符串 {#reinterpretasstring} - -此函数接受数字、Date或DateTime,并返回一个字符串,其中包含表示主机顺序(小端)的相应值的字节。从末尾删除空字节。例如,UInt32类型值255是一个字节长的字符串。 - -## reinterpretAsFixedString {#reinterpretasfixedstring} - -此函数接受数字、Date或DateTime,并返回包含表示主机顺序(小端)的相应值的字节的FixedString。从末尾删除空字节。例如,UInt32类型值255是一个长度为一个字节的FixedString。 - -## 演员(x,t) {#type_conversion_function-cast} - -将'x'转换为't'数据类型。还支持语法CAST(x AS t) - -示例: - -``` sql -SELECT - '2016-06-15 23:00:00' AS timestamp, - CAST(timestamp AS DateTime) AS datetime, - CAST(timestamp AS Date) AS date, - CAST(timestamp, 'String') AS string, - CAST(timestamp, 'FixedString(22)') AS fixed_string -``` - - ┌─timestamp───────────┬────────────datetime─┬───────date─┬─string──────────────┬─fixed_string──────────────┐ - │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-15 23:00:00 │ 2016-06-15 23:00:00\0\0\0 │ - └─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘ - -将参数转换为FixedString(N),仅适用于String或FixedString(N)类型的参数。 - -支持将数据转换为[可为空](../../sql_reference/functions/type_conversion_functions.md)。例如: - - SELECT toTypeName(x) FROM t_null - - ┌─toTypeName(x)─┐ - │ Int8 │ - │ Int8 │ - └───────────────┘ - - SELECT toTypeName(CAST(x, 'Nullable(UInt16)')) FROM t_null - - ┌─toTypeName(CAST(x, 'Nullable(UInt16)'))─┐ - │ Nullable(UInt16) │ - │ Nullable(UInt16) │ - └─────────────────────────────────────────┘ - -## 每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每天每 {#function-tointerval} - -将数字类型参数转换为Interval类型(时间区间)。 -Interval类型实际上是非常有用的,您可以使用此类型的数据直接与Date或DateTime执行算术运算。同时,ClickHouse为Interval类型数据的声明提供了更方便的语法。例如: - -``` sql -WITH - toDate('2019-01-01') AS date, - INTERVAL 1 WEEK AS interval_week, - toIntervalWeek(1) AS interval_to_week -SELECT - date + interval_week, - date + interval_to_week -``` - - ┌─plus(date, interval_week)─┬─plus(date, interval_to_week)─┐ - │ 2019-01-08 │ 2019-01-08 │ - └───────────────────────────┴──────────────────────────────┘ - -## parsedatetimebestefort {#type_conversion_functions-parsedatetimebesteffort} - -将数字类型参数解析为Date或DateTime类型。 -与toDate和toDateTime不同,parseDateTimeBestEffort可以进行更复杂的日期格式。 -有关详细信息,请参阅链接:[复杂日期格式](https://xkcd.com/1179/)。 - -## parsedatetimebestefortornull {#parsedatetimebesteffortornull} - -与[parsedatetimebestefort](#type_conversion_functions-parsedatetimebesteffort)相同,但它遇到无法处理的日期格式时返回null。 - -## parsedatetimebestefortorzero {#parsedatetimebesteffortorzero} - -与[parsedatetimebestefort](#type_conversion_functions-parsedatetimebesteffort)相同,但它遇到无法处理的日期格式时返回零Date或零DateTime。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/zh/sql_reference/functions/url_functions.md b/docs/zh/sql_reference/functions/url_functions.md deleted file mode 100644 index 53295221e51..00000000000 --- a/docs/zh/sql_reference/functions/url_functions.md +++ /dev/null @@ -1,119 +0,0 @@ - -# URL函数 {#urlhan-shu} - -所有这些功能都不遵循RFC。它们被最大程度简化以提高性能。 - -## URL截取函数 {#urljie-qu-han-shu} - -如果URL中没有要截取的内容则返回空字符串。 - -### 协议 {#protocol} - -返回URL的协议。例如: http、ftp、mailto、magnet… - -### 域 {#domain} - -获取域名。 - -### domainwithoutww {#domainwithoutwww} - -返回域名并删除第一个'www.'。 - -### topLevelDomain {#topleveldomain} - -返回顶级域名。例如:.ru。 - -### 第一重要的元素分区域 {#firstsignificantsubdomain} - -返回«第一个有效子域名»。这并不是一个标准概念,仅用于Yandex.Metrica。如果顶级域名为'com',‘net’,‘org’或者‘co’则第一个有效子域名为二级域名。否则则返回三级域名。例如,irstSignificantSubdomain (’https://news.yandex.ru/‘) = ’yandex’, firstSignificantSubdomain (‘https://news.yandex.com.tr/’) = ‘yandex’。一些实现细节在未来可能会进行改变。 - -### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} - -返回包含顶级域名与第一个有效子域名之间的内容(请参阅上面的内容)。 - -例如, `cutToFirstSignificantSubdomain('https://news.yandex.com.tr/') = 'yandex.com.tr'`. - -### 路径 {#path} - -返回URL路径。例如:`/top/news.html`,不包含请求参数。 - -### pathFull {#pathfull} - -与上面相同,但包括请求参数和fragment。例如:/top/news.html?page=2\#comments - -### 查询字符串 {#querystring} - -返回请求参数。例如:page=1&lr=213。请求参数不包含问号已经\# 以及\# 之后所有的内容。 - -### 片段 {#fragment} - -返回URL的fragment标识。fragment不包含\#。 - -### querystring andfragment {#querystringandfragment} - -返回请求参数和fragment标识。例如:page=1\#29390。 - -### extractURLParameter(URL,name) {#extracturlparameterurl-name} - -返回URL请求参数中名称为'name'的参数。如果不存在则返回一个空字符串。如果存在多个匹配项则返回第一个相匹配的。此函数假设参数名称与参数值在url中的编码方式相同。 - -### extractURLParameters(URL) {#extracturlparametersurl} - -返回一个数组,其中以name=value的字符串形式返回url的所有请求参数。不以任何编码解析任何内容。 - -### extractURLParameterNames(URL) {#extracturlparameternamesurl} - -返回一个数组,其中包含url的所有请求参数的名称。不以任何编码解析任何内容。 - -### URLHierarchy(URL) {#urlhierarchyurl} - -返回一个数组,其中包含以/切割的URL的所有内容。?将被包含在URL路径以及请求参数中。连续的分割符号被记为一个。 - -### Urlpathhierarchy(URL) {#urlpathhierarchyurl} - -与上面相同,但结果不包含协议和host部分。 /element(root)不包括在内。该函数用于在Yandex.Metric中实现导出URL的树形结构。 - - URLPathHierarchy('https://example.com/browse/CONV-6788') = - [ - '/browse/', - '/browse/CONV-6788' - ] - -### decodeURLComponent(URL) {#decodeurlcomponenturl} - -返回已经解码的URL。 -例如: - -``` sql -SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL; -``` - - ┌─DecodedURL─────────────────────────────┐ - │ http://127.0.0.1:8123/?query=SELECT 1; │ - └────────────────────────────────────────┘ - -## 删除URL中的部分内容 {#shan-chu-urlzhong-de-bu-fen-nei-rong} - -如果URL中不包含指定的部分,则URL不变。 - -### cutWWW {#cutwww} - -删除开始的第一个'www.'。 - -### cutQueryString {#cutquerystring} - -删除请求参数。问号也将被删除。 - -### cutFragment {#cutfragment} - -删除fragment标识。\#同样也会被删除。 - -### cutquerystring andfragment {#cutquerystringandfragment} - -删除请求参数以及fragment标识。问号以及\#也会被删除。 - -### cutURLParameter(URL,name) {#cuturlparameterurl-name} - -删除URL中名称为'name'的参数。改函数假设参数名称以及参数值经过URL相同的编码。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/zh/sql_reference/functions/uuid_functions.md b/docs/zh/sql_reference/functions/uuid_functions.md deleted file mode 100644 index 306a55f08a0..00000000000 --- a/docs/zh/sql_reference/functions/uuid_functions.md +++ /dev/null @@ -1,108 +0,0 @@ - -# UUID函数 {#uuidhan-shu} - -下面列出了所有UUID的相关函数 - -## generateuidv4 {#uuid-function-generate} - -生成一个UUID([版本4](https://tools.ietf.org/html/rfc4122#section-4.4))。 - -``` sql -generateUUIDv4() -``` - -**返回值** - -UUID类型的值。 - -**使用示例** - -此示例演示如何在表中创建UUID类型的列,并对其写入数据。 - -``` sql -:) CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog - -:) INSERT INTO t_uuid SELECT generateUUIDv4() - -:) SELECT * FROM t_uuid - -┌────────────────────────────────────x─┐ -│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │ -└──────────────────────────────────────┘ -``` - -## toUUID(x) {#touuid-x} - -将String类型的值转换为UUID类型的值。 - -``` sql -toUUID(String) -``` - -**返回值** - -UUID类型的值 - -**使用示例** - -``` sql -:) SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid - -┌─────────────────────────────────uuid─┐ -│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ -└──────────────────────────────────────┘ -``` - -## UUIDStringToNum {#uuidstringtonum} - -接受一个String类型的值,其中包含36个字符且格式为`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,将其转换为UUID的数值并以[固定字符串(16)](../../sql_reference/functions/uuid_functions.md)将其返回。 - -``` sql -UUIDStringToNum(String) -``` - -**返回值** - -固定字符串(16) - -**使用示例** - -``` sql -:) SELECT - '612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, - UUIDStringToNum(uuid) AS bytes - -┌─uuid─────────────────────────────────┬─bytes────────────┐ -│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ -└──────────────────────────────────────┴──────────────────┘ -``` - -## UUIDNumToString {#uuidnumtostring} - -接受一个[固定字符串(16)](../../sql_reference/functions/uuid_functions.md)类型的值,返回其对应的String表现形式。 - -``` sql -UUIDNumToString(FixedString(16)) -``` - -**返回值** - -字符串。 - -**使用示例** - -``` sql -SELECT - 'a/<@];!~p{jTj={)' AS bytes, - UUIDNumToString(toFixedString(bytes, 16)) AS uuid - -┌─bytes────────────┬─uuid─────────────────────────────────┐ -│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ -└──────────────────┴──────────────────────────────────────┘ -``` - -## 另请参阅 {#ling-qing-can-yue} - -- [dictgetuid](ext_dict_functions.md) - -[来源文章](https://clickhouse.tech/docs/en/query_language/functions/uuid_function/) diff --git a/docs/zh/sql_reference/functions/ym_dict_functions.md b/docs/zh/sql_reference/functions/ym_dict_functions.md deleted file mode 100644 index 87492ec9d12..00000000000 --- a/docs/zh/sql_reference/functions/ym_dict_functions.md +++ /dev/null @@ -1,121 +0,0 @@ - -# 功能与Yandex的工作。梅特里卡词典 {#functions-for-working-with-yandex-metrica-dictionaries} - -为了使下面的功能正常工作,服务器配置必须指定获取所有Yandex的路径和地址。梅特里卡字典. 字典在任何这些函数的第一次调用时加载。 如果无法加载引用列表,则会引发异常。 - -For information about creating reference lists, see the section «Dictionaries». - -## 多个地理基 {#multiple-geobases} - -ClickHouse支持同时使用多个备选地理基(区域层次结构),以支持某些地区所属国家的各种观点。 - -该 ‘clickhouse-server’ config指定具有区域层次结构的文件::`/opt/geo/regions_hierarchy.txt` - -除了这个文件,它还搜索附近有\_符号和任何后缀附加到名称(文件扩展名之前)的文件。 -例如,它还会找到该文件 `/opt/geo/regions_hierarchy_ua.txt`,如果存在。 - -`ua` 被称为字典键。 对于没有后缀的字典,键是空字符串。 - -所有字典都在运行时重新加载(每隔一定数量的秒重新加载一次,如builtin\_dictionaries\_reload\_interval config参数中定义,或默认情况下每小时一次)。 但是,可用字典列表在服务器启动时定义一次。 - -All functions for working with regions have an optional argument at the end – the dictionary key. It is referred to as the geobase. -示例: - - regionToCountry(RegionID) – Uses the default dictionary: /opt/geo/regions_hierarchy.txt - regionToCountry(RegionID, '') – Uses the default dictionary: /opt/geo/regions_hierarchy.txt - regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt - -### ツ环板(ョツ嘉ッツ偲青regionシツ氾カツ鉄ツ工ツ渉\]) {#regiontocityid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0. - -### 虏茅驴麓卤戮碌禄路戮鲁拢\]) {#regiontoareaid-geobase} - -将区域转换为区域(地理数据库中的类型5)。 在所有其他方式,这个功能是一样的 ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - - ┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐ - │ │ - │ Moscow and Moscow region │ - │ St. Petersburg and Leningrad region │ - │ Belgorod region │ - │ Ivanovsk region │ - │ Kaluga region │ - │ Kostroma region │ - │ Kursk region │ - │ Lipetsk region │ - │ Orlov region │ - │ Ryazan region │ - │ Smolensk region │ - │ Tambov region │ - │ Tver region │ - │ Tula region │ - └──────────────────────────────────────────────────────┘ - -### regionToDistrict(id\[,geobase\]) {#regiontodistrictid-geobase} - -将区域转换为联邦区(地理数据库中的类型4)。 在所有其他方式,这个功能是一样的 ‘regionToCity’. - -``` sql -SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua')) -FROM system.numbers -LIMIT 15 -``` - - ┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐ - │ │ - │ Central federal district │ - │ Northwest federal district │ - │ South federal district │ - │ North Caucases federal district │ - │ Privolga federal district │ - │ Ural federal district │ - │ Siberian federal district │ - │ Far East federal district │ - │ Scotland │ - │ Faroe Islands │ - │ Flemish region │ - │ Brussels capital region │ - │ Wallonia │ - │ Federation of Bosnia and Herzegovina │ - └──────────────────────────────────────────────────────────┘ - -### 虏茅驴麓卤戮碌禄路戮鲁拢(陆毛隆隆(803)888-8325\]) {#regiontocountryid-geobase} - -将区域转换为国家。 在所有其他方式,这个功能是一样的 ‘regionToCity’. -示例: `regionToCountry(toUInt32(213)) = 225` 转换莫斯科(213)到俄罗斯(225)。 - -### 掳胫((禄脢鹿脷露胫鲁隆鹿((酶-11-16""\[脪陆,ase\]) {#regiontocontinentid-geobase} - -将区域转换为大陆。 在所有其他方式,这个功能是一样的 ‘regionToCity’. -示例: `regionToContinent(toUInt32(213)) = 10001` 将莫斯科(213)转换为欧亚大陆(10001)。 - -### ツ环板(ョツ嘉ッツ偲青regionャツ静ャツ青サツ催ャツ渉\]) {#regiontopopulationid-geobase} - -获取区域的人口。 -The population can be recorded in files with the geobase. See the section «External dictionaries». -如果没有为该区域记录人口,则返回0。 -在Yandex地理数据库中,可能会为子区域记录人口,但不会为父区域记录人口。 - -### regionIn(lhs,rhs\[,地理数据库\]) {#regioninlhs-rhs-geobase} - -检查是否 ‘lhs’ 属于一个区域 ‘rhs’ 区域。 如果属于UInt8,则返回等于1的数字,如果不属于则返回0。 -The relationship is reflexive – any region also belongs to itself. - -### ツ暗ェツ氾环催ツ団ツ法ツ人\]) {#regionhierarchyid-geobase} - -Accepts a UInt32 number – the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. -示例: `regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000]`. - -### 地区名称(id\[,郎\]) {#regiontonameid-lang} - -Accepts a UInt32 number – the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ‘ru’ is used. If the language is not supported, an exception is thrown. Returns a string – the name of the region in the corresponding language. If the region with the specified ID doesn't exist, an empty string is returned. - -`ua` 和 `uk` 都意味着乌克兰。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/functions/ym_dict_functions/) diff --git a/docs/zh/sql_reference/index.md b/docs/zh/sql_reference/index.md deleted file mode 100644 index aed704442ab..00000000000 --- a/docs/zh/sql_reference/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "SQL\u53C2\u8003" -toc_hidden: true -toc_priority: 28 -toc_title: "\u9690\u85CF" ---- - -# SQL参考 {#sql-reference} - -- [SELECT](statements/select.md) -- [INSERT INTO](statements/insert_into.md) -- [CREATE](statements/create.md) -- [ALTER](statements/alter.md#query_language_queries_alter) -- [其他类型的查询](statements/misc.md) - -[原始文章](https://clickhouse.tech/docs/en/query_language/) diff --git a/docs/zh/sql_reference/operators.md b/docs/zh/sql_reference/operators.md deleted file mode 100644 index fb5c7d0ee38..00000000000 --- a/docs/zh/sql_reference/operators.md +++ /dev/null @@ -1,264 +0,0 @@ - -# 操作符 {#cao-zuo-fu} - -所有的操作符(运算符)都会在查询时依据他们的优先级及其结合顺序在被解析时转换为对应的函数。下面按优先级从高到低列出各组运算符及其对应的函数: - -## 下标运算符 {#xia-biao-yun-suan-fu} - -`a[N]` – 数组中的第N个元素; 对应函数 `arrayElement(a, N)` - -`a.N` – 元组中第N个元素; 对应函数 `tupleElement(a, N)` - -## 负号 {#fu-hao} - -`-a` – 对应函数 `negate(a)` - -## 乘号、除号和取余 {#cheng-hao-chu-hao-he-qu-yu} - -`a * b` – 对应函数 `multiply(a, b)` - -`a / b` – 对应函数 `divide(a, b)` - -`a % b` – 对应函数 `modulo(a, b)` - -## 加号和减号 {#jia-hao-he-jian-hao} - -`a + b` – 对应函数 `plus(a, b)` - -`a - b` – 对应函数 `minus(a, b)` - -## 关系运算符 {#guan-xi-yun-suan-fu} - -`a = b` – 对应函数 `equals(a, b)` - -`a == b` – 对应函数 `equals(a, b)` - -`a != b` – 对应函数 `notEquals(a, b)` - -`a <> b` – 对应函数 `notEquals(a, b)` - -`a <= b` – 对应函数 `lessOrEquals(a, b)` - -`a >= b` – 对应函数 `greaterOrEquals(a, b)` - -`a < b` – 对应函数 `less(a, b)` - -`a > b` – 对应函数 `greater(a, b)` - -`a LIKE s` – 对应函数 `like(a, b)` - -`a NOT LIKE s` – 对应函数 `notLike(a, b)` - -`a BETWEEN b AND c` – 等价于 `a >= b AND a <= c` - -## 集合关系运算符 {#ji-he-guan-xi-yun-suan-fu} - -*详见此节 [IN 相关操作符](statements/select.md#select-in-operators) 。* - -`a IN ...` – 对应函数 `in(a, b)` - -`a NOT IN ...` – 对应函数 `notIn(a, b)` - -`a GLOBAL IN ...` – 对应函数 `globalIn(a, b)` - -`a GLOBAL NOT IN ...` – 对应函数 `globalNotIn(a, b)` - -## 逻辑非 {#luo-ji-fei} - -`NOT a` – 对应函数 `not(a)` - -## 逻辑与 {#luo-ji-yu} - -`a AND b` – 对应函数`and(a, b)` - -## 逻辑或 {#luo-ji-huo} - -`a OR b` – 对应函数 `or(a, b)` - -## 条件运算符 {#tiao-jian-yun-suan-fu} - -`a ? b : c` – 对应函数 `if(a, b, c)` - -注意: - -条件运算符会先计算表达式b和表达式c的值,再根据表达式a的真假,返回相应的值。如果表达式b和表达式c是 [arrayJoin()](../sql_reference/functions/array_join.md#functions_arrayjoin) 函数,则不管表达式a是真是假,每行都会被复制展开。 - -## 使用日期和时间的操作员 {#operators-datetime} - -### EXTRACT {#operator-extract} - -``` sql -EXTRACT(part FROM date); -``` - -从给定日期中提取部件。 例如,您可以从给定日期检索一个月,或从时间检索一秒钟。 - -该 `part` 参数指定要检索的日期部分。 以下值可用: - -- `DAY` — The day of the month. Possible values: 1–31. -- `MONTH` — The number of a month. Possible values: 1–12. -- `YEAR` — The year. -- `SECOND` — The second. Possible values: 0–59. -- `MINUTE` — The minute. Possible values: 0–59. -- `HOUR` — The hour. Possible values: 0–23. - -该 `part` 参数不区分大小写。 - -该 `date` 参数指定要处理的日期或时间。 无论是 [日期](../sql_reference/data_types/date.md) 或 [日期时间](../sql_reference/data_types/datetime.md) 支持类型。 - -例: - -``` sql -SELECT EXTRACT(DAY FROM toDate('2017-06-15')); -SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); -SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); -``` - -在下面的例子中,我们创建一个表,并在其中插入一个值 `DateTime` 类型。 - -``` sql -CREATE TABLE test.Orders -( - OrderId UInt64, - OrderName String, - OrderDate DateTime -) -ENGINE = Log; -``` - -``` sql -INSERT INTO test.Orders VALUES (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44')); -``` - -``` sql -SELECT - toYear(OrderDate) AS OrderYear, - toMonth(OrderDate) AS OrderMonth, - toDayOfMonth(OrderDate) AS OrderDay, - toHour(OrderDate) AS OrderHour, - toMinute(OrderDate) AS OrderMinute, - toSecond(OrderDate) AS OrderSecond -FROM test.Orders; -``` - -``` text -┌─OrderYear─┬─OrderMonth─┬─OrderDay─┬─OrderHour─┬─OrderMinute─┬─OrderSecond─┐ -│ 2008 │ 10 │ 11 │ 13 │ 23 │ 44 │ -└───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ -``` - -你可以看到更多的例子 [测试](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql). - -### INTERVAL {#operator-interval} - -创建一个 [间隔](../sql_reference/operators.md)-应在算术运算中使用的类型值 [日期](../sql_reference/data_types/date.md) 和 [日期时间](../sql_reference/data_types/datetime.md)-类型值。 - -示例: - -``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR -``` - -``` text -┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ -└─────────────────────┴────────────────────────────────────────────────────────┘ -``` - -**另请参阅** - -- [间隔](../sql_reference/operators.md) 数据类型 -- [toInterval](../sql_reference/operators.md#function-tointerval) 类型转换函数 - -## CASE条件表达式 {#operator_case} - -``` sql -CASE [x] - WHEN a THEN b - [WHEN ... THEN ...] - [ELSE c] -END -``` - -如果指定了 `x` ,该表达式会转换为 `transform(x, [a, ...], [b, ...], c)` 函数。否则转换为 `multiIf(a, b, ..., c)` - -如果该表达式中没有 `ELSE c` 子句,则默认值就是 `NULL` - -但 `transform` 函数不支持 `NULL` - -## 连接运算符 {#lian-jie-yun-suan-fu} - -`s1 || s2` – 对应函数 `concat(s1, s2)` - -## 创建 Lambda 函数 {#chuang-jian-lambda-han-shu} - -`x -> expr` – 对应函数 `lambda(x, expr)` - -接下来的这些操作符因为其本身是括号没有优先级: - -## 创建数组 {#chuang-jian-shu-zu} - -`[x1, ...]` – 对应函数 `array(x1, ...)` - -## 创建元组 {#chuang-jian-yuan-zu} - -`(x1, x2, ...)` – 对应函数 `tuple(x2, x2, ...)` - -## 结合方式 {#jie-he-fang-shi} - -所有的同级操作符从左到右结合。例如, `1 + 2 + 3` 会转换成 `plus(plus(1, 2), 3)`。 -所以,有时他们会跟我们预期的不太一样。例如, `SELECT 4 > 2 > 3` 的结果是0。 - -为了高效, `and` 和 `or` 函数支持任意多参数,一连串的 `AND` 和 `OR` 运算符会转换成其对应的单个函数。 - -## 判断是否为 `NULL` {#pan-duan-shi-fou-wei-null} - -ClickHouse 支持 `IS NULL` 和 `IS NOT NULL` 。 - -### IS NULL {#operator-is-null} - -- 对于 [可为空](../sql_reference/operators.md) 类型的值, `IS NULL` 会返回: - - `1` 值为 `NULL` - - `0` 否则 -- 对于其他类型的值, `IS NULL` 总会返回 `0` - - - -``` bash -:) SELECT x+100 FROM t_null WHERE y IS NULL - -SELECT x + 100 -FROM t_null -WHERE isNull(y) - -┌─plus(x, 100)─┐ -│ 101 │ -└──────────────┘ - -1 rows in set. Elapsed: 0.002 sec. -``` - -### IS NOT NULL {#is-not-null} - -- 对于 [可为空](../sql_reference/operators.md) 类型的值, `IS NOT NULL` 会返回: - - `0` 值为 `NULL` - - `1` 否则 -- 对于其他类型的值,`IS NOT NULL` 总会返回 `1` - - - -``` bash -:) SELECT * FROM t_null WHERE y IS NOT NULL - -SELECT * -FROM t_null -WHERE isNotNull(y) - -┌─x─┬─y─┐ -│ 2 │ 3 │ -└───┴───┘ - -1 rows in set. Elapsed: 0.002 sec. -``` - -[来源文章](https://clickhouse.tech/docs/en/query_language/operators/) diff --git a/docs/zh/sql_reference/statements/alter.md b/docs/zh/sql_reference/statements/alter.md deleted file mode 100644 index ee8911edea2..00000000000 --- a/docs/zh/sql_reference/statements/alter.md +++ /dev/null @@ -1,505 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 36 -toc_title: ALTER ---- - -## ALTER {#query_language_queries_alter} - -该 `ALTER` 查询仅支持 `*MergeTree` 表,以及 `Merge`和`Distributed`. 查询有几个变体。 - -### 列操作 {#column-manipulations} - -更改表结构。 - -``` sql -ALTER TABLE [db].name [ON CLUSTER cluster] ADD|DROP|CLEAR|COMMENT|MODIFY COLUMN ... -``` - -在查询中,指定一个或多个逗号分隔操作的列表。 -每个操作都是对列的操作。 - -支持以下操作: - -- [ADD COLUMN](#alter_add-column) — Adds a new column to the table. -- [DROP COLUMN](#alter_drop-column) — Deletes the column. -- [CLEAR COLUMN](#alter_clear-column) — Resets column values. -- [COMMENT COLUMN](#alter_comment-column) — Adds a text comment to the column. -- [MODIFY COLUMN](#alter_modify-column) — Changes column's type, default expression and TTL. - -下面详细描述这些动作。 - -#### ADD COLUMN {#alter_add-column} - -``` sql -ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after] -``` - -将一个新列添加到表中,并指定 `name`, `type`, [`codec`](create.md#codecs) 和 `default_expr` (请参阅部分 [默认表达式](create.md#create-default-values)). - -如果 `IF NOT EXISTS` 如果列已经存在,则查询不会返回错误。 如果您指定 `AFTER name_after` (另一列的名称),该列被添加在表列表中指定的一列之后。 否则,该列将添加到表的末尾。 请注意,没有办法将列添加到表的开头。 为了一系列的行动, `name_after` 可将该名称一栏,加入一个以前的行动。 - -添加列只是更改表结构,而不对数据执行任何操作。 数据不会出现在磁盘上后 `ALTER`. 如果从表中读取某一列的数据缺失,则将使用默认值填充该列(如果存在默认表达式,则执行默认表达式,或使用零或空字符串)。 合并数据部分后,该列将出现在磁盘上(请参阅 [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md)). - -这种方法使我们能够完成 `ALTER` 即时查询,不增加旧数据量。 - -示例: - -``` sql -ALTER TABLE visits ADD COLUMN browser String AFTER user_id -``` - -#### DROP COLUMN {#alter_drop-column} - -``` sql -DROP COLUMN [IF EXISTS] name -``` - -删除具有名称的列 `name`. 如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 - -从文件系统中删除数据。 由于这将删除整个文件,查询几乎立即完成。 - -示例: - -``` sql -ALTER TABLE visits DROP COLUMN browser -``` - -#### CLEAR COLUMN {#alter_clear-column} - -``` sql -CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name -``` - -重置指定分区的列中的所有数据。 了解有关设置分区名称的详细信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). - -如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 - -示例: - -``` sql -ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() -``` - -#### COMMENT COLUMN {#alter_comment-column} - -``` sql -COMMENT COLUMN [IF EXISTS] name 'comment' -``` - -向列添加注释。 如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 - -每列可以有一个注释。 如果列的注释已存在,则新注释将复盖以前的注释。 - -注释存储在 `comment_expression` 由返回的列 [DESCRIBE TABLE](misc.md#misc-describe-table) 查询。 - -示例: - -``` sql -ALTER TABLE visits COMMENT COLUMN browser 'The table shows the browser used for accessing the site.' -``` - -#### MODIFY COLUMN {#alter_modify-column} - -``` sql -MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL] -``` - -此查询更改 `name` 列属性: - -- 类型 - -- 默认表达式 - -- TTL - - For examples of columns TTL modifying, see [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl). - -如果 `IF EXISTS` 如果指定了子句,如果该列不存在,则查询不会返回错误。 - -更改类型时,值将被转换为 [toType](../../sql_reference/functions/type_conversion_functions.md) 函数被应用到它们。 如果仅更改默认表达式,则查询不会执行任何复杂的操作,并且几乎立即完成。 - -示例: - -``` sql -ALTER TABLE visits MODIFY COLUMN browser Array(String) -``` - -Changing the column type is the only complex action – it changes the contents of files with data. For large tables, this may take a long time. - -有几个处理阶段: - -- 准备具有修改数据的临时(新)文件。 -- 重命名旧文件。 -- 将临时(新)文件重命名为旧名称。 -- 删除旧文件。 - -只有第一阶段需要时间。 如果在此阶段出现故障,则不会更改数据。 -如果在其中一个连续阶段中出现故障,可以手动恢复数据。 例外情况是,如果旧文件从文件系统中删除,但新文件的数据没有写入磁盘并丢失。 - -该 `ALTER` 复制更改列的查询。 这些指令保存在ZooKeeper中,然后每个副本应用它们。 全部 `ALTER` 查询以相同的顺序运行。 查询等待对其他副本完成适当的操作。 但是,更改复制表中的列的查询可能会中断,并且所有操作都将异步执行。 - -#### 更改查询限制 {#alter-query-limitations} - -该 `ALTER` query允许您在嵌套数据结构中创建和删除单独的元素(列),但不能创建整个嵌套数据结构。 要添加嵌套数据结构,可以添加名称如下的列 `name.nested_name` 和类型 `Array(T)`. 嵌套数据结构等效于名称在点之前具有相同前缀的多个数组列。 - -不支持删除主键或采样键中的列(在主键中使用的列 `ENGINE` 表达式)。 只有在此更改不会导致数据被修改时,才可以更改主键中包含的列的类型(例如,允许您向枚举添加值或更改类型 `DateTime` 到 `UInt32`). - -如果 `ALTER` 查询不足以使您需要的表更改,您可以创建一个新的表,使用 [INSERT SELECT](insert_into.md#insert_query_insert-select) 查询,然后使用切换表 [RENAME](misc.md#misc_operations-rename) 查询并删除旧表。 您可以使用 [ツ环板-ョツ嘉ッツ偲](../../operations/utilities/clickhouse-copier.md) 作为替代 `INSERT SELECT` 查询。 - -该 `ALTER` 查询阻止对表的所有读取和写入。 换句话说,如果长 `SELECT` 正在运行的时间 `ALTER` 查询,该 `ALTER` 查询将等待它完成。 同时,对同一个表的所有新查询将等待 `ALTER` 正在运行。 - -对于本身不存储数据的表(例如 `Merge` 和 `Distributed`), `ALTER` 只是改变了表结构,并且不改变从属表的结构。 例如,当运行ALTER时 `Distributed` 表,你还需要运行 `ALTER` 对于所有远程服务器上的表。 - -### 使用键表达式进行操作 {#manipulations-with-key-expressions} - -支持以下命令: - -``` sql -MODIFY ORDER BY new_expression -``` - -它只适用于在表 [`MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) 家庭(包括 -[复制](../../engines/table_engines/mergetree_family/replication.md) 表)。 该命令更改 -[排序键](../../engines/table_engines/mergetree_family/mergetree.md) 表 -到 `new_expression` (表达式或表达式元组)。 主键保持不变。 - -该命令是轻量级的,因为它只更改元数据。 要保持该数据部分的属性 -行按排序键表达式排序您不能添加包含现有列的表达式 -到排序键(仅由列添加 `ADD COLUMN` 命令在同一个 `ALTER` 查询)。 - -### 使用数据跳过索引进行操作 {#manipulations-with-data-skipping-indices} - -它只适用于在表 [`*MergeTree`](../../engines/table_engines/mergetree_family/mergetree.md) 家庭(包括 -[复制](../../engines/table_engines/mergetree_family/replication.md) 表)。 以下操作 -可用: - -- `ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value AFTER name [AFTER name2]` -将索引描述添加到表元数据。 - -- `ALTER TABLE [db].name DROP INDEX name` -从表元数据中删除索引描述并从磁盘中删除索引文件。 - -这些命令是轻量级的,因为它们只更改元数据或删除文件。 -此外,它们被复制(通过ZooKeeper同步索引元数据)。 - -### 使用约束进行操作 {#manipulations-with-constraints} - -查看更多 [制约因素](create.md#constraints) - -可以使用以下语法添加或删除约束: - -``` sql -ALTER TABLE [db].name ADD CONSTRAINT constraint_name CHECK expression; -ALTER TABLE [db].name DROP CONSTRAINT constraint_name; -``` - -查询将从表中添加或删除有关约束的元数据,以便立即处理它们。 - -约束检查 *不会被执行* 在现有数据上,如果它被添加。 - -复制表上的所有更改都广播到ZooKeeper,因此将应用于其他副本。 - -### 操作与分区和零件 {#alter_manipulations-with-partitions} - -下面的操作与 [分区](../../engines/table_engines/mergetree_family/custom_partitioning_key.md) 可用: - -- [DETACH PARTITION](#alter_detach-partition) – Moves a partition to the `detached` 目录和忘记它。 -- [DROP PARTITION](#alter_drop-partition) – Deletes a partition. -- [ATTACH PART\|PARTITION](#alter_attach-partition) – Adds a part or partition from the `detached` 目录到表。 -- [REPLACE PARTITION](#alter_replace-partition) -将数据分区从一个表复制到另一个表。 -- [ATTACH PARTITION FROM](#alter_attach-partition-from) – Copies the data partition from one table to another and adds. -- [REPLACE PARTITION](#alter_replace-partition) -将数据分区从一个表复制到另一个表并替换。 -- [MOVE PARTITION TO TABLE](#alter_move_to_table-partition) (\#alter\_move\_to\_table-partition)-将数据分区从一个表移动到另一个表。 -- [CLEAR COLUMN IN PARTITION](#alter_clear-column-partition) -重置分区中指定列的值。 -- [CLEAR INDEX IN PARTITION](#alter_clear-index-partition) -重置分区中指定的二级索引。 -- [FREEZE PARTITION](#alter_freeze-partition) – Creates a backup of a partition. -- [FETCH PARTITION](#alter_fetch-partition) – Downloads a partition from another server. -- [MOVE PARTITION\|PART](#alter_move-partition) – Move partition/data part to another disk or volume. - - - -#### 分离分区{\#alter\_detach-partition} {#detach-partition-alter-detach-partition} - -``` sql -ALTER TABLE table_name DETACH PARTITION partition_expr -``` - -将指定分区的所有数据移动到 `detached` 目录。 服务器会忘记分离的数据分区,就好像它不存在一样。 服务器不会知道这个数据,直到你做 [ATTACH](#alter_attach-partition) 查询。 - -示例: - -``` sql -ALTER TABLE visits DETACH PARTITION 201901 -``` - -阅读有关在一节中设置分区表达式的信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). - -执行查询后,您可以对查询中的数据进行任何操作 `detached` directory — delete it from the file system, or just leave it. - -This query is replicated – it moves the data to the `detached` 所有副本上的目录。 请注意,您只能对领导副本执行此查询。 要确定副本是否为领导者,请执行 `SELECT` 查询到 [系统。副本](../../operations/system_tables.md#system_tables-replicas) 桌子 或者,它更容易使 `DETACH` 对所有副本进行查询-除了领导副本之外,所有副本都会引发异常。 - -#### DROP PARTITION {#alter_drop-partition} - -``` sql -ALTER TABLE table_name DROP PARTITION partition_expr -``` - -从表中删除指定的分区。 此查询将分区标记为非活动分区,并在大约10分钟内完全删除数据。 - -阅读有关在一节中设置分区表达式的信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). - -The query is replicated – it deletes data on all replicas. - -#### DROP DETACHED PARTITION\|PART {#alter_drop-detached} - -``` sql -ALTER TABLE table_name DROP DETACHED PARTITION|PART partition_expr -``` - -从中删除指定分区的指定部分或所有部分 `detached`. -了解有关在一节中设置分区表达式的详细信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). - -#### ATTACH PARTITION\|PART {#alter_attach-partition} - -``` sql -ALTER TABLE table_name ATTACH PARTITION|PART partition_expr -``` - -将数据从 `detached` 目录。 可以为整个分区或单独的部分添加数据。 例: - -``` sql -ALTER TABLE visits ATTACH PARTITION 201901; -ALTER TABLE visits ATTACH PART 201901_2_2_0; -``` - -了解有关在一节中设置分区表达式的详细信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). - -此查询被复制。 副本发起程序检查是否有数据在 `detached` 目录。 如果数据存在,则查询将检查其完整性。 如果一切正确,则查询将数据添加到表中。 所有其他副本都从副本发起程序下载数据。 - -所以你可以把数据到 `detached` 在一个副本上的目录,并使用 `ALTER ... ATTACH` 查询以将其添加到所有副本上的表中。 - -#### ATTACH PARTITION FROM {#alter_attach-partition-from} - -``` sql -ALTER TABLE table2 ATTACH PARTITION partition_expr FROM table1 -``` - -此查询将数据分区从 `table1` 到 `table2` 将数据添加到存在 `table2`. 请注意,数据不会从中删除 `table1`. - -要使查询成功运行,必须满足以下条件: - -- 两个表必须具有相同的结构。 -- 两个表必须具有相同的分区键。 - -#### REPLACE PARTITION {#alter_replace-partition} - -``` sql -ALTER TABLE table2 REPLACE PARTITION partition_expr FROM table1 -``` - -此查询将数据分区从 `table1` 到 `table2` 并替换在现有的分区 `table2`. 请注意,数据不会从中删除 `table1`. - -要使查询成功运行,必须满足以下条件: - -- 两个表必须具有相同的结构。 -- 两个表必须具有相同的分区键。 - -#### MOVE PARTITION TO TABLE {#alter_move_to_table-partition} - -``` sql -ALTER TABLE table_source MOVE PARTITION partition_expr TO TABLE table_dest -``` - -此查询将数据分区从 `table_source` 到 `table_dest` 删除数据 `table_source`. - -要使查询成功运行,必须满足以下条件: - -- 两个表必须具有相同的结构。 -- 两个表必须具有相同的分区键。 -- 两个表必须是相同的引擎系列。 (已复制或未复制) -- 两个表必须具有相同的存储策略。 - -#### CLEAR COLUMN IN PARTITION {#alter_clear-column-partition} - -``` sql -ALTER TABLE table_name CLEAR COLUMN column_name IN PARTITION partition_expr -``` - -重置分区中指定列中的所有值。 如果 `DEFAULT` 创建表时确定了子句,此查询将列值设置为指定的默认值。 - -示例: - -``` sql -ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 -``` - -#### FREEZE PARTITION {#alter_freeze-partition} - -``` sql -ALTER TABLE table_name FREEZE [PARTITION partition_expr] -``` - -此查询创建指定分区的本地备份。 如果 `PARTITION` 子句被省略,查询一次创建所有分区的备份。 - -!!! note "注" - 在不停止服务器的情况下执行整个备份过程。 - -请注意,对于旧式表,您可以指定分区名称的前缀(例如, ‘2019’)-然后查询为所有相应的分区创建备份。 阅读有关在一节中设置分区表达式的信息 [如何指定分区表达式](#alter-how-to-specify-part-expr). - -在执行时,对于数据快照,查询将创建指向表数据的硬链接。 硬链接被放置在目录中 `/var/lib/clickhouse/shadow/N/...`,哪里: - -- `/var/lib/clickhouse/` 是配置中指定的工作ClickHouse目录。 -- `N` 是备份的增量编号。 - -!!! note "注" - 如果您使用 [用于在表中存储数据的一组磁盘](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes),该 `shadow/N` 目录出现在每个磁盘上,存储由匹配的数据部分 `PARTITION` 表达。 - -在备份内部创建的目录结构与在备份内部创建的目录结构相同 `/var/lib/clickhouse/`. 查询执行 ‘chmod’ 对于所有文件,禁止写入它们。 - -创建备份后,您可以从以下位置复制数据 `/var/lib/clickhouse/shadow/` 然后将其从本地服务器中删除。 请注意, `ALTER t FREEZE PARTITION` 不复制查询。 它仅在本地服务器上创建本地备份。 - -查询几乎立即创建备份(但首先它会等待对相应表的当前查询完成运行)。 - -`ALTER TABLE t FREEZE PARTITION` 仅复制数据,而不复制表元数据。 若要备份表元数据,请复制该文件 `/var/lib/clickhouse/metadata/database/table.sql` - -要从备份还原数据,请执行以下操作: - -1. 如果表不存在,则创建该表。 要查看查询,请使用。sql文件(替换 `ATTACH` 在它与 `CREATE`). -2. 从复制数据 `data/database/table/` 目录内的备份到 `/var/lib/clickhouse/data/database/table/detached/` 目录。 -3. 快跑 `ALTER TABLE t ATTACH PARTITION` 将数据添加到表的查询。 - -从备份还原不需要停止服务器。 - -有关备份和还原数据的详细信息,请参阅 [数据备份](../../operations/backup.md) 科。 - -#### CLEAR INDEX IN PARTITION {#alter_clear-index-partition} - -``` sql -ALTER TABLE table_name CLEAR INDEX index_name IN PARTITION partition_expr -``` - -查询的工作原理类似于 `CLEAR COLUMN`,但它重置索引而不是列数据。 - -#### FETCH PARTITION {#alter_fetch-partition} - -``` sql -ALTER TABLE table_name FETCH PARTITION partition_expr FROM 'path-in-zookeeper' -``` - -从另一台服务器下载分区。 此查询仅适用于复制的表。 - -查询执行以下操作: - -1. 从指定的分片下载分区。 在 ‘path-in-zookeeper’ 您必须在ZooKeeper中指定分片的路径。 -2. 然后查询将下载的数据放到 `detached` 的目录 `table_name` 桌子 使用 [ATTACH PARTITION\|PART](#alter_attach-partition) 查询将数据添加到表中。 - -例如: - -``` sql -ALTER TABLE users FETCH PARTITION 201902 FROM '/clickhouse/tables/01-01/visits'; -ALTER TABLE users ATTACH PARTITION 201902; -``` - -请注意: - -- 该 `ALTER ... FETCH PARTITION` 查询不被复制。 它将分区放置在 `detached` 仅在本地服务器上的目录。 -- 该 `ALTER TABLE ... ATTACH` 复制查询。 它将数据添加到所有副本。 数据被添加到从副本之一 `detached` 目录,以及其他-从相邻的副本。 - -在下载之前,系统会检查分区是否存在并且表结构匹配。 从正常副本中自动选择最合适的副本。 - -虽然查询被调用 `ALTER TABLE`,它不会更改表结构,并且不会立即更改表中可用的数据。 - -#### MOVE PARTITION\|PART {#alter_move-partition} - -将分区或数据部分移动到另一个卷或磁盘 `MergeTree`-发动机表。 看 [使用多个块设备进行数据存储](../../engines/table_engines/mergetree_family/mergetree.md#table_engine-mergetree-multiple-volumes). - -``` sql -ALTER TABLE table_name MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' -``` - -该 `ALTER TABLE t MOVE` 查询: - -- 不复制,因为不同的副本可能具有不同的存储策略。 -- 如果未配置指定的磁盘或卷,则返回错误。 如果无法应用存储策略中指定的数据移动条件,Query还会返回错误。 -- 可以在返回错误的情况下,当要移动的数据已经被后台进程移动时,并发 `ALTER TABLE t MOVE` 查询或作为后台数据合并的结果。 在这种情况下,用户不应该执行任何其他操作。 - -示例: - -``` sql -ALTER TABLE hits MOVE PART '20190301_14343_16206_438' TO VOLUME 'slow' -ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' -``` - -#### 如何设置分区表达式 {#alter-how-to-specify-part-expr} - -您可以在以下内容中指定分区表达式 `ALTER ... PARTITION` 以不同方式查询: - -- 作为从值 `partition` 列 `system.parts` 桌子 例如, `ALTER TABLE visits DETACH PARTITION 201901`. -- 作为来自表列的表达式。 支持常量和常量表达式。 例如, `ALTER TABLE visits DETACH PARTITION toYYYYMM(toDate('2019-01-25'))`. -- 使用分区ID。 分区ID是用作文件系统和ZooKeeper中分区名称的分区的字符串标识符(如果可能的话,人类可读)。 分区ID必须在指定 `PARTITION ID` 子句,用单引号。 例如, `ALTER TABLE visits DETACH PARTITION ID '201901'`. -- 在 [ALTER ATTACH PART](#alter_attach-partition) 和 [DROP DETACHED PART](#alter_drop-detached) 查询时,要指定部件的名称,请将字符串文字与来自 `name` 列 [系统。detached\_parts](../../operations/system_tables.md#system_tables-detached_parts) 桌子 例如, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`. - -指定分区时引号的使用取决于分区表达式的类型。 例如,对于 `String` 类型,你必须在引号中指定其名称 (`'`). 为 `Date` 和 `Int*` 类型不需要引号。 - -对于旧式表,您可以将分区指定为数字 `201901` 或者一个字符串 `'201901'`. 对于类型,新样式表的语法更严格(类似于值输入格式的解析器)。 - -上述所有规则也适用于 [OPTIMIZE](misc.md#misc_operations-optimize) 查询。 如果在优化非分区表时需要指定唯一的分区,请设置表达式 `PARTITION tuple()`. 例如: - -``` sql -OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; -``` - -的例子 `ALTER ... PARTITION` 查询在测试中演示 [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) 和 [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql). - -### 使用表TTL进行操作 {#manipulations-with-table-ttl} - -你可以改变 [表TTL](../../engines/table_engines/mergetree_family/mergetree.md#mergetree-table-ttl) 请填写以下表格: - -``` sql -ALTER TABLE table-name MODIFY TTL ttl-expression -``` - -### ALTER查询的同步性 {#synchronicity-of-alter-queries} - -对于不可复制的表,所有 `ALTER` 查询是同步执行的。 对于可复制的表,查询仅添加相应操作的说明 `ZooKeeper`,并尽快执行操作本身。 但是,查询可以等待在所有副本上完成这些操作。 - -为 `ALTER ... ATTACH|DETACH|DROP` 查询,您可以使用 `replication_alter_partitions_sync` 设置设置等待。 -可能的值: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. - -### 突变 {#alter-mutations} - -突变是允许更改或删除表中的行的ALTER查询变体。 与标准相比 `UPDATE` 和 `DELETE` 用于点数据更改的查询,mutations适用于更改表中大量行的繁重操作。 支持的 `MergeTree` 表引擎系列,包括具有复制支持的引擎。 - -现有表可以按原样进行突变(无需转换),但是在将第一次突变应用于表之后,其元数据格式将与以前的服务器版本不兼容,并且无法回退到以前的版本。 - -当前可用的命令: - -``` sql -ALTER TABLE [db.]table DELETE WHERE filter_expr -``` - -该 `filter_expr` 必须是类型 `UInt8`. 查询删除表中此表达式采用非零值的行。 - -``` sql -ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr -``` - -该 `filter_expr` 必须是类型 `UInt8`. 此查询将指定列的值更新为行中相应表达式的值。 `filter_expr` 取非零值。 使用以下命令将值转换为列类型 `CAST` 接线员 不支持更新用于计算主键或分区键的列。 - -``` sql -ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name -``` - -查询将重新生成二级索引 `name` 在分区中 `partition_name`. - -一个查询可以包含多个用逗号分隔的命令。 - -For\*MergeTree表的突变通过重写整个数据部分来执行。 没有原子性-部分被取代为突变的部分,只要他们准备好和 `SELECT` 在突变期间开始执行的查询将看到来自已经突变的部件的数据以及来自尚未突变的部件的数据。 - -突变完全按其创建顺序排序,并以该顺序应用于每个部分。 突变也使用插入进行部分排序-在提交突变之前插入到表中的数据将被突变,之后插入的数据将不会被突变。 请注意,突变不会以任何方式阻止插入。 - -Mutation查询在添加mutation条目后立即返回(如果将复制的表复制到ZooKeeper,则将非复制的表复制到文件系统)。 突变本身使用系统配置文件设置异步执行。 要跟踪突变的进度,您可以使用 [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) 桌子 即使重新启动ClickHouse服务器,成功提交的突变仍将继续执行。 一旦提交,没有办法回滚突变,但如果突变由于某种原因被卡住,可以使用 [`KILL MUTATION`](misc.md#kill-mutation) 查询。 - -已完成突变的条目不会立即删除(保留条目的数量由 `finished_mutations_to_keep` 存储引擎参数)。 旧的突变条目将被删除。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/alter/) diff --git a/docs/zh/sql_reference/statements/create.md b/docs/zh/sql_reference/statements/create.md deleted file mode 100644 index 1697df692b5..00000000000 --- a/docs/zh/sql_reference/statements/create.md +++ /dev/null @@ -1,264 +0,0 @@ - -## CREATE DATABASE {#create-database} - -该查询用于根据指定名称创建数据库。 - -``` sql -CREATE DATABASE [IF NOT EXISTS] db_name -``` - -数据库其实只是用于存放表的一个目录。 -如果查询中存在`IF NOT EXISTS`,则当数据库已经存在时,该查询不会返回任何错误。 - -## CREATE TABLE {#create-table-query} - -对于`CREATE TABLE`,存在以下几种方式。 - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) ENGINE = engine -``` - -在指定的'db'数据库中创建一个名为'name'的表,如果查询中没有包含'db',则默认使用当前选择的数据库作为'db'。后面的是包含在括号中的表结构以及表引擎的声明。 -其中表结构声明是一个包含一组列描述声明的组合。如果表引擎是支持索引的,那么可以在表引擎的参数中对其进行说明。 - -在最简单的情况下,列描述是指`名称 类型`这样的子句。例如: `RegionID UInt32`。 -但是也可以为列另外定义默认值表达式(见后文)。 - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] -``` - -创建一个与`db2.name2`具有相同结构的表,同时你可以对其指定不同的表引擎声明。如果没有表引擎声明,则创建的表将与`db2.name2`使用相同的表引擎。 - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name ENGINE = engine AS SELECT ... -``` - -使用指定的引擎创建一个与`SELECT`子句的结果具有相同结构的表,并使用`SELECT`子句的结果填充它。 - -以上所有情况,如果指定了`IF NOT EXISTS`,那么在该表已经存在的情况下,查询不会返回任何错误。在这种情况下,查询几乎不会做任何事情。 - -在`ENGINE`子句后还可能存在一些其他的子句,更详细的信息可以参考 [表引擎](../../sql_reference/statements/create.md) 中关于建表的描述。 - -### 默认值 {#create-default-values} - -在列描述中你可以通过以下方式之一为列指定默认表达式:`DEFAULT expr`,`MATERIALIZED expr`,`ALIAS expr`。 -示例:`URLDomain String DEFAULT domain(URL)`。 - -如果在列描述中未定义任何默认表达式,那么系统将会根据类型设置对应的默认值,如:数值类型为零、字符串类型为空字符串、数组类型为空数组、日期类型为'0000-00-00'以及时间类型为'0000-00-00 00:00:00'。不支持使用NULL作为普通类型的默认值。 - -如果定义了默认表达式,则可以不定义列的类型。如果没有明确的定义类的类型,则使用默认表达式的类型。例如:`EventDate DEFAULT toDate(EventTime)` - 最终'EventDate'将使用'Date'作为类型。 - -如果同时指定了默认表达式与列的类型,则将使用类型转换函数将默认表达式转换为指定的类型。例如:`Hits UInt32 DEFAULT 0`与`Hits UInt32 DEFAULT toUInt32(0)`意思相同。 - -默认表达式可以包含常量或表的任意其他列。当创建或更改表结构时,系统将会运行检查,确保不会包含循环依赖。对于INSERT, 它仅检查表达式是否是可以解析的 - 它们可以从中计算出所有需要的列的默认值。 - -`DEFAULT expr` - -普通的默认值,如果INSERT中不包含指定的列,那么将通过表达式计算它的默认值并填充它。 - -`MATERIALIZED expr` - -物化表达式,被该表达式指定的列不能包含在INSERT的列表中,因为它总是被计算出来的。 -对于INSERT而言,不需要考虑这些列。 -另外,在SELECT查询中如果包含星号,此列不会被用来替换星号,这是因为考虑到数据转储,在使用`SELECT *`查询出的结果总能够被'INSERT'回表。 - -`ALIAS expr` - -别名。这样的列不会存储在表中。 -它的值不能够通过INSERT写入,同时使用SELECT查询星号时,这些列也不会被用来替换星号。 -但是它们可以显示的用于SELECT中,在这种情况下,在查询分析中别名将被替换。 - -当使用ALTER查询对添加新的列时,不同于为所有旧数据添加这个列,对于需要在旧数据中查询新列,只会在查询时动态计算这个新列的值。但是如果新列的默认表示中依赖其他列的值进行计算,那么同样会加载这些依赖的列的数据。 - -如果你向表中添加一个新列,并在之后的一段时间后修改它的默认表达式,则旧数据中的值将会被改变。请注意,在运行后台合并时,缺少的列的值将被计算后写入到合并后的数据部分中。 - -不能够为nested类型的列设置默认值。 - -### 制约因素 {#constraints} - -随着列描述约束可以定义: - -``` sql -CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [compression_codec] [TTL expr1], - ... - CONSTRAINT constraint_name_1 CHECK boolean_expr_1, - ... -) ENGINE = engine -``` - -`boolean_expr_1` 可以通过任何布尔表达式。 如果为表定义了约束,则将为表中的每一行检查它们中的每一行 `INSERT` query. If any constraint is not satisfied — server will raise an exception with constraint name and checking expression. - -添加大量的约束会对big的性能产生负面影响 `INSERT` 查询。 - -### Ttl表达式 {#ttl-expression} - -定义值的存储时间。 只能为MergeTree系列表指定。 有关详细说明,请参阅 [列和表的TTL](../../sql_reference/statements/create.md#table_engine-mergetree-ttl). - -### 列压缩编解ecs {#codecs} - -默认情况下,ClickHouse应用以下定义的压缩方法 [服务器设置](../../sql_reference/statements/create.md#server-settings-compression),列。 您还可以定义在每个单独的列的压缩方法 `CREATE TABLE` 查询。 - -``` sql -CREATE TABLE codec_example -( - dt Date CODEC(ZSTD), - ts DateTime CODEC(LZ4HC), - float_value Float32 CODEC(NONE), - double_value Float64 CODEC(LZ4HC(9)) - value Float32 CODEC(Delta, ZSTD) -) -ENGINE = -... -``` - -如果指定了编解ec,则默认编解码器不适用。 编解码器可以组合在一个流水线中,例如, `CODEC(Delta, ZSTD)`. 要为您的项目选择最佳的编解码器组合,请通过类似于Altinity中描述的基准测试 [新编码提高ClickHouse效率](https://www.altinity.com/blog/2019/7/new-encodings-to-improve-clickhouse) 文章. - -!!! warning "警告" - 您无法使用外部实用程序解压缩ClickHouse数据库文件,如 `lz4`. 相反,使用特殊的 [ツ环板compressorョツ嘉ッツ偲](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) 实用程序。 - -下表引擎支持压缩: - -- [MergeTree](../../sql_reference/statements/create.md) 家庭 -- [日志](../../sql_reference/statements/create.md) 家庭 -- [设置](../../sql_reference/statements/create.md) -- [加入我们](../../sql_reference/statements/create.md) - -ClickHouse支持通用编解码器和专用编解ecs。 - -#### 专业编解ecs {#create-query-specialized-codecs} - -这些编解码器旨在通过使用数据的特定功能使压缩更有效。 其中一些编解码器不压缩数据本身。 相反,他们准备的数据用于共同目的的编解ec,其压缩它比没有这种准备更好。 - -专业编解ecs: - -- `Delta(delta_bytes)` — Compression approach in which raw values are replaced by the difference of two neighboring values, except for the first value that stays unchanged. Up to `delta_bytes` 用于存储增量值,所以 `delta_bytes` 是原始值的最大大小。 可能 `delta_bytes` 值:1,2,4,8. 默认值 `delta_bytes` 是 `sizeof(type)` 如果等于1,2,4或8。 在所有其他情况下,它是1。 -- `DoubleDelta` — Calculates delta of deltas and writes it in compact binary form. Optimal compression rates are achieved for monotonic sequences with a constant stride, such as time series data. Can be used with any fixed-width type. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. Uses 1 extra bit for 32-byte deltas: 5-bit prefixes instead of 4-bit prefixes. For additional information, see Compressing Time Stamps in [Gorilla:一个快速、可扩展的内存时间序列数据库](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `Gorilla` — Calculates XOR between current and previous value and writes it in compact binary form. Efficient when storing a series of floating point values that change slowly, because the best compression rate is achieved when neighboring values are binary equal. Implements the algorithm used in Gorilla TSDB, extending it to support 64-bit types. For additional information, see Compressing Values in [Gorilla:一个快速、可扩展的内存时间序列数据库](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf). -- `T64` — Compression approach that crops unused high bits of values in integer data types (including `Enum`, `Date` 和 `DateTime`). 在算法的每个步骤中,编解码器采用64个值块,将它们放入64x64位矩阵中,对其进行转置,裁剪未使用的值位并将其余部分作为序列返回。 未使用的位是使用压缩的整个数据部分的最大值和最小值之间没有区别的位。 - -`DoubleDelta` 和 `Gorilla` 编解码器在Gorilla TSDB中用作其压缩算法的组件。 大猩猩的方法是有效的情况下,当有缓慢变化的值与他们的时间戳序列。 时间戳是由有效地压缩 `DoubleDelta` 编解ec,和值有效地由压缩 `Gorilla` 编解ec 例如,要获取有效存储的表,可以在以下配置中创建它: - -``` sql -CREATE TABLE codec_example -( - timestamp DateTime CODEC(DoubleDelta), - slow_values Float32 CODEC(Gorilla) -) -ENGINE = MergeTree() -``` - -#### 通用编解ecs {#create-query-common-purpose-codecs} - -编解ecs: - -- `NONE` — No compression. -- `LZ4` — Lossless [数据压缩算法](https://github.com/lz4/lz4) 默认情况下使用。 应用LZ4快速压缩。 -- `LZ4HC[(level)]` — LZ4 HC (high compression) algorithm with configurable level. Default level: 9. Setting `level <= 0` 应用默认级别。 可能的水平:\[1,12\]。 推荐级别范围:\[4,9\]。 -- `ZSTD[(level)]` — [ZSTD压缩算法](https://en.wikipedia.org/wiki/Zstandard) 可配置 `level`. 可能的水平:\[1,22\]。 默认值:1。 - -高压缩级别对于非对称场景非常有用,例如压缩一次,重复解压缩。 更高的级别意味着更好的压缩和更高的CPU使用率。 - -## 临时表 {#lin-shi-biao} - -ClickHouse支持临时表,其具有以下特征: - -- 当回话结束时,临时表将随会话一起消失,这包含链接中断。 -- 临时表仅能够使用Memory表引擎。 -- 无法为临时表指定数据库。它是在数据库之外创建的。 -- 如果临时表与另一个表名称相同,那么当在查询时没有显示的指定db的情况下,将优先使用临时表。 -- 对于分布式处理,查询中使用的临时表将被传递到远程服务器。 - -可以使用下面的语法创建一个临时表: - -``` sql -CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name [ON CLUSTER cluster] -( - name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], - name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], - ... -) -``` - -大多数情况下,临时表不是手动创建的,只有在分布式查询处理中使用`(GLOBAL) IN`时为外部数据创建。更多信息,可以参考相关章节。 - -## 分布式DDL查询 (ON CLUSTER 子句) {#fen-bu-shi-ddlcha-xun-on-cluster-zi-ju} - -对于 `CREATE`, `DROP`, `ALTER`,以及`RENAME`查询,系统支持其运行在整个集群上。 -例如,以下查询将在`cluster`集群的所有节点上创建名为`all_hits`的`Distributed`表: - -``` sql -CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) -``` - -为了能够正确的运行这种查询,每台主机必须具有相同的cluster声明(为了简化配置的同步,你可以使用zookeeper的方式进行配置)。同时这些主机还必须链接到zookeeper服务器。 -这个查询将最终在集群的每台主机上运行,即使一些主机当前处于不可用状态。同时它还保证了所有的查询在单台主机中的执行顺序。 - -## CREATE VIEW {#create-view} - -``` sql -CREATE [MATERIALIZED] VIEW [IF NOT EXISTS] [db.]table_name [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ... -``` - -创建一个视图。它存在两种可选择的类型:普通视图与物化视图。 - -普通视图不存储任何数据,只是执行从另一个表中的读取。换句话说,普通视图只是保存了视图的查询,当从视图中查询时,此查询被作为子查询用于替换FROM子句。 - -举个例子,假设你已经创建了一个视图: - -``` sql -CREATE VIEW view AS SELECT ... -``` - -还有一个查询: - -``` sql -SELECT a, b, c FROM view -``` - -这个查询完全等价于: - -``` sql -SELECT a, b, c FROM (SELECT ...) -``` - -物化视图存储的数据是由相应的SELECT查询转换得来的。 - -在创建物化视图时,你还必须指定表的引擎 - 将会使用这个表引擎存储数据。 - -目前物化视图的工作原理:当将数据写入到物化视图中SELECT子句所指定的表时,插入的数据会通过SELECT子句查询进行转换并将最终结果插入到视图中。 - -如果创建物化视图时指定了POPULATE子句,则在创建时将该表的数据插入到物化视图中。就像使用`CREATE TABLE ... AS SELECT ...`一样。否则,物化视图只会包含在物化视图创建后的新写入的数据。我们不推荐使用POPULATE,因为在视图创建期间写入的数据将不会写入其中。 - -当一个`SELECT`子句包含`DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`时,请注意,这些仅会在插入数据时在每个单独的数据块上执行。例如,如果你在其中包含了`GROUP BY`,则只会在查询期间进行聚合,但聚合范围仅限于单个批的写入数据。数据不会进一步被聚合。但是当你使用一些其他数据聚合引擎时这是例外的,如:`SummingMergeTree`。 - -目前对物化视图执行`ALTER`是不支持的,因此这可能是不方便的。如果物化视图是使用的`TO [db.]name`的方式进行构建的,你可以使用`DETACH`语句现将视图剥离,然后使用`ALTER`运行在目标表上,然后使用`ATTACH`将之前剥离的表重新加载进来。 - -视图看起来和普通的表相同。例如,你可以通过`SHOW TABLES`查看到它们。 - -没有单独的删除视图的语法。如果要删除视图,请使用`DROP TABLE`。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/create/) - -## CREATE DICTIONARY {#create-dictionary-query} - -``` sql -CREATE DICTIONARY [IF NOT EXISTS] [db.]dictionary_name [ON CLUSTER cluster] -( - key1 type1 [DEFAULT|EXPRESSION expr1] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - key2 type2 [DEFAULT|EXPRESSION expr2] [HIERARCHICAL|INJECTIVE|IS_OBJECT_ID], - attr1 type2 [DEFAULT|EXPRESSION expr3], - attr2 type2 [DEFAULT|EXPRESSION expr4] -) -PRIMARY KEY key1, key2 -SOURCE(SOURCE_NAME([param1 value1 ... paramN valueN])) -LAYOUT(LAYOUT_NAME([param_name param_value])) -LIFETIME([MIN val1] MAX val2) -``` diff --git a/docs/zh/sql_reference/statements/index.md b/docs/zh/sql_reference/statements/index.md deleted file mode 100644 index bb04551dea1..00000000000 --- a/docs/zh/sql_reference/statements/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u53D1\u8A00" -toc_priority: 31 ---- - - diff --git a/docs/zh/sql_reference/statements/insert_into.md b/docs/zh/sql_reference/statements/insert_into.md deleted file mode 100644 index a59730f5750..00000000000 --- a/docs/zh/sql_reference/statements/insert_into.md +++ /dev/null @@ -1,68 +0,0 @@ - -## INSERT {#insert} - -INSERT查询主要用于向系统中添加数据. - -查询的基本格式: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ... -``` - -您可以在查询中指定插入的列的列表,如:`[(c1, c2, c3)]`。对于存在于表结构中但不存在于插入列表中的列,它们将会按照如下方式填充数据: - -- 如果存在`DEFAULT`表达式,根据`DEFAULT`表达式计算被填充的值。 -- 如果没有定义`DEFAULT`表达式,则填充零或空字符串。 - -如果 [strict\_insert\_defaults=1](../../operations/settings/settings.md),你必须在查询中列出所有没有定义`DEFAULT`表达式的列。 - -数据可以以ClickHouse支持的任何 [输入输出格式](../../interfaces/formats.md#formats) 传递给INSERT。格式的名称必须显示的指定在查询中: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set -``` - -例如,下面的查询所使用的输入格式就与上面INSERT … VALUES的中使用的输入格式相同: - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... -``` - -ClickHouse会清除数据前所有的空白字符与一行摘要信息(如果需要的话)。所以在进行查询时,我们建议您将数据放入到输入输出格式名称后的新的一行中去(如果数据是以空白字符开始的,这将非常重要)。 - -示例: - -``` sql -INSERT INTO t FORMAT TabSeparated -11 Hello, world! -22 Qwerty -``` - -在使用命令行客户端或HTTP客户端时,你可以将具体的查询语句与数据分开发送。更多具体信息,请参考«[客户端](../../interfaces/index.md#interfaces)»部分。 - -### 使用`SELECT`的结果写入 {#insert_query_insert-select} - -``` sql -INSERT INTO [db.]table [(c1, c2, c3)] SELECT ... -``` - -写入与SELECT的列的对应关系是使用位置来进行对应的,尽管它们在SELECT表达式与INSERT中的名称可能是不同的。如果需要,会对它们执行对应的类型转换。 - -除了VALUES格式之外,其他格式中的数据都不允许出现诸如`now()`,`1 + 2`等表达式。VALUES格式允许您有限度的使用这些表达式,但是不建议您这么做,因为执行这些表达式总是低效的。 - -系统不支持的其他用于修改数据的查询:`UPDATE`, `DELETE`, `REPLACE`, `MERGE`, `UPSERT`, `INSERT UPDATE`。 -但是,您可以使用 `ALTER TABLE ... DROP PARTITION`查询来删除一些旧的数据。 - -### 性能的注意事项 {#xing-neng-de-zhu-yi-shi-xiang} - -在进行`INSERT`时将会对写入的数据进行一些处理,按照主键排序,按照月份对数据进行分区等。所以如果在您的写入数据中包含多个月份的混合数据时,将会显著的降低`INSERT`的性能。为了避免这种情况: - -- 数据总是以尽量大的batch进行写入,如每次写入100,000行。 -- 数据在写入ClickHouse前预先的对数据进行分组。 - -在以下的情况下,性能不会下降: - -- 数据总是被实时的写入。 -- 写入的数据已经按照时间排序。 - -[来源文章](https://clickhouse.tech/docs/en/query_language/insert_into/) diff --git a/docs/zh/sql_reference/statements/misc.md b/docs/zh/sql_reference/statements/misc.md deleted file mode 100644 index e50f08464b7..00000000000 --- a/docs/zh/sql_reference/statements/misc.md +++ /dev/null @@ -1,252 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 39 -toc_title: "\u5176\u4ED6" ---- - -# 杂项查询 {#miscellaneous-queries} - -## ATTACH {#attach} - -这个查询是完全一样的 `CREATE`,但是 - -- 而不是这个词 `CREATE` 它使用这个词 `ATTACH`. -- 查询不会在磁盘上创建数据,但假定数据已经在适当的位置,只是将有关表的信息添加到服务器。 - 执行附加查询后,服务器将知道表的存在。 - -如果表之前已分离 (`DETACH`),意味着其结构是已知的,可以使用速记而不限定该结构。 - -``` sql -ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] -``` - -启动服务器时使用此查询。 服务器将表元数据作为文件存储 `ATTACH` 查询,它只是在启动时运行(除了在服务器上显式创建的系统表)。 - -## CHECK TABLE {#check-table} - -检查表中的数据是否已损坏。 - -``` sql -CHECK TABLE [db.]name -``` - -该 `CHECK TABLE` 查询将实际文件大小与存储在服务器上的预期值进行比较。 如果文件大小与存储的值不匹配,则表示数据已损坏。 例如,这可能是由查询执行期间的系统崩溃引起的。 - -查询响应包含 `result` 具有单行的列。 该行的值为 -[布尔值](../../sql_reference/data_types/boolean.md) 类型: - -- 0-表中的数据已损坏。 -- 1-数据保持完整性。 - -该 `CHECK TABLE` 查询支持下表引擎: - -- [日志](../../engines/table_engines/log_family/log.md) -- [TinyLog](../../engines/table_engines/log_family/tinylog.md) -- [StripeLog](../../engines/table_engines/log_family/stripelog.md) -- [梅树家族](../../engines/table_engines/mergetree_family/mergetree.md) - -使用另一个表引擎对表执行会导致异常。 - -从发动机 `*Log` 家庭不提供故障自动数据恢复。 使用 `CHECK TABLE` 查询以及时跟踪数据丢失。 - -为 `MergeTree` 家庭发动机, `CHECK TABLE` 查询显示本地服务器上表的每个单独数据部分的检查状态。 - -**如果数据已损坏** - -如果表已损坏,则可以将未损坏的数据复制到另一个表。 要做到这一点: - -1. 创建具有与损坏的表相同结构的新表。 要执行此操作,请执行查询 `CREATE TABLE AS `. -2. 设置 [max\_threads](../../operations/settings/settings.md#settings-max_threads) 值为1以在单个线程中处理下一个查询。 要执行此操作,请运行查询 `SET max_threads = 1`. -3. 执行查询 `INSERT INTO SELECT * FROM `. 此请求将未损坏的数据从损坏的表复制到另一个表。 只有损坏部分之前的数据才会被复制。 -4. 重新启动 `clickhouse-client` 要重置 `max_threads` 价值。 - -## DESCRIBE TABLE {#misc-describe-table} - -``` sql -DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -返回以下内容 `String` 类型列: - -- `name` — Column name. -- `type`— Column type. -- `default_type` — Clause that is used in [默认表达式](create.md#create-default-values) (`DEFAULT`, `MATERIALIZED` 或 `ALIAS`). 如果未指定默认表达式,则Column包含一个空字符串。 -- `default_expression` — Value specified in the `DEFAULT` 条款 -- `comment_expression` — Comment text. - -嵌套的数据结构输出 “expanded” 格式。 每列分别显示,名称后面有一个点。 - -## DETACH {#detach} - -删除有关 ‘name’ 表从服务器。 服务器停止了解表的存在。 - -``` sql -DETACH TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -这不会删除表的数据或元数据。 在下一次服务器启动时,服务器将读取元数据并再次查找有关表的信息。 -同样,一个 “detached” 表可以使用重新连接 `ATTACH` 查询(系统表除外,它们没有为它们存储元数据)。 - -没有 `DETACH DATABASE` 查询。 - -## DROP {#drop} - -此查询有两种类型: `DROP DATABASE` 和 `DROP TABLE`. - -``` sql -DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] -``` - -删除内部的所有表 ‘db’ 数据库,然后删除 ‘db’ 数据库本身。 -如果 `IF EXISTS` 如果数据库不存在,则不会返回错误。 - -``` sql -DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -删除表。 -如果 `IF EXISTS` 如果表不存在或数据库不存在,则不会返回错误。 - - DROP DICTIONARY [IF EXISTS] [db.]name - -删除字典。 -如果 `IF EXISTS` 如果表不存在或数据库不存在,则不会返回错误。 - -## EXISTS {#exists} - -``` sql -EXISTS [TEMPORARY] [TABLE|DICTIONARY] [db.]name [INTO OUTFILE filename] [FORMAT format] -``` - -返回单 `UInt8`-type column,其中包含单个值 `0` 如果表或数据库不存在,或 `1` 如果该表存在于指定的数据库中。 - -## KILL QUERY {#kill-query} - -``` sql -KILL QUERY [ON CLUSTER cluster] - WHERE - [SYNC|ASYNC|TEST] - [FORMAT format] -``` - -尝试强制终止当前正在运行的查询。 -要终止的查询是从系统中选择的。使用在定义的标准进程表 `WHERE` 《公约》条款 `KILL` 查询。 - -例: - -``` sql --- Forcibly terminates all queries with the specified query_id: -KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - --- Synchronously terminates all queries run by 'username': -KILL QUERY WHERE user='username' SYNC -``` - -只读用户只能停止自己的查询。 - -默认情况下,使用异步版本的查询 (`ASYNC`),不等待确认查询已停止。 - -同步版本 (`SYNC`)等待所有查询停止,并在停止时显示有关每个进程的信息。 -响应包含 `kill_status` 列,它可以采用以下值: - -1. ‘finished’ – The query was terminated successfully. -2. ‘waiting’ – Waiting for the query to end after sending it a signal to terminate. -3. The other values ​​explain why the query can't be stopped. - -测试查询 (`TEST`)仅检查用户的权限并显示要停止的查询列表。 - -## KILL MUTATION {#kill-mutation} - -``` sql -KILL MUTATION [ON CLUSTER cluster] - WHERE - [TEST] - [FORMAT format] -``` - -尝试取消和删除 [突变](alter.md#alter-mutations) 当前正在执行。 要取消的突变选自 [`system.mutations`](../../operations/system_tables.md#system_tables-mutations) 表使用由指定的过滤器 `WHERE` 《公约》条款 `KILL` 查询。 - -测试查询 (`TEST`)仅检查用户的权限并显示要停止的查询列表。 - -例: - -``` sql --- Cancel and remove all mutations of the single table: -KILL MUTATION WHERE database = 'default' AND table = 'table' - --- Cancel the specific mutation: -KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' -``` - -The query is useful when a mutation is stuck and cannot finish (e.g. if some function in the mutation query throws an exception when applied to the data contained in the table). - -已经由突变所做的更改不会回滚。 - -## OPTIMIZE {#misc_operations-optimize} - -``` sql -OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE] -``` - -此查询尝试使用来自表引擎的表初始化表的数据部分的非计划合并 [MergeTree](../../engines/table_engines/mergetree_family/mergetree.md) 家人 - -该 `OPTMIZE` 查询也支持 [MaterializedView](../../engines/table_engines/special/materializedview.md) 和 [缓冲区](../../engines/table_engines/special/buffer.md) 引擎 不支持其他表引擎。 - -当 `OPTIMIZE` 与使用 [ReplicatedMergeTree](../../engines/table_engines/mergetree_family/replication.md) 表引擎的家族,ClickHouse创建合并任务,并等待在所有节点上执行(如果 `replication_alter_partitions_sync` 设置已启用)。 - -- 如果 `OPTIMIZE` 出于任何原因不执行合并,它不通知客户端。 要启用通知,请使用 [optimize\_throw\_if\_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop) 设置。 -- 如果您指定 `PARTITION`,仅优化指定的分区。 [如何设置分区表达式](alter.md#alter-how-to-specify-part-expr). -- 如果您指定 `FINAL`,即使所有数据已经在一个部分中,也会执行优化。 -- 如果您指定 `DEDUPLICATE`,然后完全相同的行将被重复数据删除(所有列进行比较),这仅适用于MergeTree引擎。 - -!!! warning "警告" - `OPTIMIZE` 无法修复 “Too many parts” 错误 - -## RENAME {#misc_operations-rename} - -重命名一个或多个表。 - -``` sql -RENAME TABLE [db11.]name11 TO [db12.]name12, [db21.]name21 TO [db22.]name22, ... [ON CLUSTER cluster] -``` - -所有表都在全局锁定下重命名。 重命名表是一个轻型操作。 如果您在TO之后指定了另一个数据库,则表将被移动到此数据库。 但是,包含数据库的目录必须位于同一文件系统中(否则,将返回错误)。 - -## SET {#query-set} - -``` sql -SET param = value -``` - -分配 `value` 到 `param` [设置](../../operations/settings/index.md) 对于当前会话。 你不能改变 [服务器设置](../../operations/server_configuration_parameters/index.md) 这边 - -您还可以在单个查询中设置指定设置配置文件中的所有值。 - -``` sql -SET profile = 'profile-name-from-the-settings-file' -``` - -有关详细信息,请参阅 [设置](../../operations/settings/settings.md). - -## TRUNCATE {#truncate} - -``` sql -TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] -``` - -从表中删除所有数据。 当条款 `IF EXISTS` 如果该表不存在,则查询返回错误。 - -该 `TRUNCATE` 查询不支持 [查看](../../engines/table_engines/special/view.md), [文件](../../engines/table_engines/special/file.md), [URL](../../engines/table_engines/special/url.md) 和 [Null](../../engines/table_engines/special/null.md) 表引擎. - -## USE {#use} - -``` sql -USE db -``` - -用于设置会话的当前数据库。 -当前数据库用于搜索表,如果数据库没有在查询中明确定义与表名之前的点。 -使用HTTP协议时无法进行此查询,因为没有会话的概念。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/misc/) diff --git a/docs/zh/sql_reference/statements/select.md b/docs/zh/sql_reference/statements/select.md deleted file mode 100644 index 9f4e71c3343..00000000000 --- a/docs/zh/sql_reference/statements/select.md +++ /dev/null @@ -1,937 +0,0 @@ - -# SELECT 查询语法 {#select-cha-xun-yu-fa} - -`SELECT` 语句用于执行数据的检索。 - -``` sql -SELECT [DISTINCT] expr_list - [FROM [db.]table | (subquery) | table_function] [FINAL] - [SAMPLE sample_coeff] - [ARRAY JOIN ...] - [GLOBAL] ANY|ALL INNER|LEFT JOIN (subquery)|table USING columns_list - [PREWHERE expr] - [WHERE expr] - [GROUP BY expr_list] [WITH TOTALS] - [HAVING expr] - [ORDER BY expr_list] - [LIMIT n BY columns] - [LIMIT [n, ]m] - [UNION ALL ...] - [INTO OUTFILE filename] - [FORMAT format] -``` - -所有的子句都是可选的,除了SELECT之后的表达式列表(expr\_list)。 -下面将按照查询运行的顺序逐一对各个子句进行说明。 - -如果查询中不包含`DISTINCT`,`GROUP BY`,`ORDER BY`子句以及`IN`和`JOIN`子查询,那么它将仅使用O(1)数量的内存来完全流式的处理查询 -否则,这个查询将消耗大量的内存,除非你指定了这些系统配置:`max_memory_usage`, `max_rows_to_group_by`, `max_rows_to_sort`, `max_rows_in_distinct`, `max_bytes_in_distinct`, `max_rows_in_set`, `max_bytes_in_set`, `max_rows_in_join`, `max_bytes_in_join`, `max_bytes_before_external_sort`, `max_bytes_before_external_group_by`。它们规定了可以使用外部排序(将临时表存储到磁盘中)以及外部聚合,`目前系统不存在关于Join的配置`,更多关于它们的信息,可以参见«配置»部分。 - -### FROM 子句 {#select-from} - -如果查询中不包含FROM子句,那么将读取`system.one`。 -`system.one`中仅包含一行数据(此表实现了与其他数据库管理系统中的DUAL相同的功能)。 - -FROM子句规定了将从哪个表、或子查询、或表函数中读取数据;同时ARRAY JOIN子句和JOIN子句也可以出现在这里(见后文)。 - -可以使用包含在括号里的子查询来替代表。 -在这种情况下,子查询的处理将会构建在外部的查询内部。 -不同于SQL标准,子查询后无需指定别名。为了兼容,你可以在子查询后添加'AS 别名',但是指定的名字不能被使用在任何地方。 - -也可以使用表函数来代替表,有关信息,参见«表函数»。 - -执行查询时,在查询中列出的所有列都将从对应的表中提取数据;如果你使用的是子查询的方式,则任何在外部查询中没有使用的列,子查询将从查询中忽略它们; -如果你的查询没有列出任何的列(例如,SELECT count() FROM t),则将额外的从表中提取一些列(最好的情况下是最小的列),以便计算行数。 - -最后的FINAL修饰符仅能够被使用在SELECT from CollapsingMergeTree场景中。当你为FROM指定了FINAL修饰符时,你的查询结果将会在查询过程中被聚合。需要注意的是,在这种情况下,查询将在单个流中读取所有相关的主键列,同时对需要的数据进行合并。这意味着,当使用FINAL修饰符时,查询将会处理的更慢。在大多数情况下,你应该避免使用FINAL修饰符。更多信息,请参阅«CollapsingMergeTree引擎»部分。 - -### SAMPLE 子句 {#select-sample-clause} - -通过SAMPLE子句用户可以进行近似查询处理,近似查询处理仅能工作在MergeTree\*类型的表中,并且在创建表时需要您指定采样表达式(参见«MergeTree 引擎»部分)。 - -`SAMPLE`子句可以使用`SAMPLE k`来表示,其中k可以是0到1的小数值,或者是一个足够大的正整数值。 - -当k为0到1的小数时,查询将使用'k'作为百分比选取数据。例如,`SAMPLE 0.1`查询只会检索数据总量的10%。 -当k为一个足够大的正整数时,查询将使用'k'作为最大样本数。例如, `SAMPLE 10000000`查询只会检索最多10,000,000行数据。 - -示例: - -``` sql -SELECT - Title, - count() * 10 AS PageViews -FROM hits_distributed -SAMPLE 0.1 -WHERE - CounterID = 34 - AND toDate(EventDate) >= toDate('2013-01-29') - AND toDate(EventDate) <= toDate('2013-02-04') - AND NOT DontCountHits - AND NOT Refresh - AND Title != '' -GROUP BY Title -ORDER BY PageViews DESC LIMIT 1000 -``` - -在这个例子中,查询将检索数据总量的0.1 (10%)的数据。值得注意的是,查询不会自动校正聚合函数最终的结果,所以为了得到更加精确的结果,需要将`count()`的结果手动乘以10。 - -当使用像`SAMPLE 10000000`这样的方式进行近似查询时,由于没有了任何关于将会处理了哪些数据或聚合函数应该被乘以几的信息,所以这种方式不适合在这种场景下使用。 - -使用相同的采样率得到的结果总是一致的:如果我们能够看到所有可能存在在表中的数据,那么相同的采样率总是能够得到相同的结果(在建表时使用相同的采样表达式),换句话说,系统在不同的时间,不同的服务器,不同表上总以相同的方式对数据进行采样。 - -例如,我们可以使用采样的方式获取到与不进行采样相同的用户ID的列表。这将表明,你可以在IN子查询中使用采样,或者使用采样的结果与其他查询进行关联。 - -### ARRAY JOIN 子句 {#select-array-join-clause} - -ARRAY JOIN子句可以帮助查询进行与数组和nested数据类型的连接。它有点类似arrayJoin函数,但它的功能更广泛。 - -`ARRAY JOIN` 本质上等同于`INNERT JOIN`数组。 例如: - - :) CREATE TABLE arrays_test (s String, arr Array(UInt8)) ENGINE = Memory - - CREATE TABLE arrays_test - ( - s String, - arr Array(UInt8) - ) ENGINE = Memory - - Ok. - - 0 rows in set. Elapsed: 0.001 sec. - - :) INSERT INTO arrays_test VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []) - - INSERT INTO arrays_test VALUES - - Ok. - - 3 rows in set. Elapsed: 0.001 sec. - - :) SELECT * FROM arrays_test - - SELECT * - FROM arrays_test - - ┌─s───────┬─arr─────┐ - │ Hello │ [1,2] │ - │ World │ [3,4,5] │ - │ Goodbye │ [] │ - └─────────┴─────────┘ - - 3 rows in set. Elapsed: 0.001 sec. - - :) SELECT s, arr FROM arrays_test ARRAY JOIN arr - - SELECT s, arr - FROM arrays_test - ARRAY JOIN arr - - ┌─s─────┬─arr─┐ - │ Hello │ 1 │ - │ Hello │ 2 │ - │ World │ 3 │ - │ World │ 4 │ - │ World │ 5 │ - └───────┴─────┘ - - 5 rows in set. Elapsed: 0.001 sec. - -你还可以为ARRAY JOIN子句指定一个别名,这时你可以通过这个别名来访问数组中的数据,但是数据本身仍然可以通过原来的名称进行访问。例如: - - :) SELECT s, arr, a FROM arrays_test ARRAY JOIN arr AS a - - SELECT s, arr, a - FROM arrays_test - ARRAY JOIN arr AS a - - ┌─s─────┬─arr─────┬─a─┐ - │ Hello │ [1,2] │ 1 │ - │ Hello │ [1,2] │ 2 │ - │ World │ [3,4,5] │ 3 │ - │ World │ [3,4,5] │ 4 │ - │ World │ [3,4,5] │ 5 │ - └───────┴─────────┴───┘ - - 5 rows in set. Elapsed: 0.001 sec. - -当多个具有相同大小的数组使用逗号分割出现在ARRAY JOIN子句中时,ARRAY JOIN会将它们同时执行(直接合并,而不是它们的笛卡尔积)。例如: - - :) SELECT s, arr, a, num, mapped FROM arrays_test ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped - - SELECT s, arr, a, num, mapped - FROM arrays_test - ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(lambda(tuple(x), plus(x, 1)), arr) AS mapped - - ┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐ - │ Hello │ [1,2] │ 1 │ 1 │ 2 │ - │ Hello │ [1,2] │ 2 │ 2 │ 3 │ - │ World │ [3,4,5] │ 3 │ 1 │ 4 │ - │ World │ [3,4,5] │ 4 │ 2 │ 5 │ - │ World │ [3,4,5] │ 5 │ 3 │ 6 │ - └───────┴─────────┴───┴─────┴────────┘ - - 5 rows in set. Elapsed: 0.002 sec. - - :) SELECT s, arr, a, num, arrayEnumerate(arr) FROM arrays_test ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num - - SELECT s, arr, a, num, arrayEnumerate(arr) - FROM arrays_test - ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num - - ┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐ - │ Hello │ [1,2] │ 1 │ 1 │ [1,2] │ - │ Hello │ [1,2] │ 2 │ 2 │ [1,2] │ - │ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │ - │ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │ - │ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │ - └───────┴─────────┴───┴─────┴─────────────────────┘ - - 5 rows in set. Elapsed: 0.002 sec. - -另外ARRAY JOIN也可以工作在nested数据结构上。例如: - - :) CREATE TABLE nested_test (s String, nest Nested(x UInt8, y UInt32)) ENGINE = Memory - - CREATE TABLE nested_test - ( - s String, - nest Nested( - x UInt8, - y UInt32) - ) ENGINE = Memory - - Ok. - - 0 rows in set. Elapsed: 0.006 sec. - - :) INSERT INTO nested_test VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []) - - INSERT INTO nested_test VALUES - - Ok. - - 3 rows in set. Elapsed: 0.001 sec. - - :) SELECT * FROM nested_test - - SELECT * - FROM nested_test - - ┌─s───────┬─nest.x──┬─nest.y─────┐ - │ Hello │ [1,2] │ [10,20] │ - │ World │ [3,4,5] │ [30,40,50] │ - │ Goodbye │ [] │ [] │ - └─────────┴─────────┴────────────┘ - - 3 rows in set. Elapsed: 0.001 sec. - - :) SELECT s, nest.x, nest.y FROM nested_test ARRAY JOIN nest - - SELECT s, `nest.x`, `nest.y` - FROM nested_test - ARRAY JOIN nest - - ┌─s─────┬─nest.x─┬─nest.y─┐ - │ Hello │ 1 │ 10 │ - │ Hello │ 2 │ 20 │ - │ World │ 3 │ 30 │ - │ World │ 4 │ 40 │ - │ World │ 5 │ 50 │ - └───────┴────────┴────────┘ - - 5 rows in set. Elapsed: 0.001 sec. - -当你在ARRAY JOIN指定nested数据类型的名称时,其作用与与包含所有数组元素的ARRAY JOIN相同,例如: - - :) SELECT s, nest.x, nest.y FROM nested_test ARRAY JOIN nest.x, nest.y - - SELECT s, `nest.x`, `nest.y` - FROM nested_test - ARRAY JOIN `nest.x`, `nest.y` - - ┌─s─────┬─nest.x─┬─nest.y─┐ - │ Hello │ 1 │ 10 │ - │ Hello │ 2 │ 20 │ - │ World │ 3 │ 30 │ - │ World │ 4 │ 40 │ - │ World │ 5 │ 50 │ - └───────┴────────┴────────┘ - - 5 rows in set. Elapsed: 0.001 sec. - -这种方式也是可以运行的: - - :) SELECT s, nest.x, nest.y FROM nested_test ARRAY JOIN nest.x - - SELECT s, `nest.x`, `nest.y` - FROM nested_test - ARRAY JOIN `nest.x` - - ┌─s─────┬─nest.x─┬─nest.y─────┐ - │ Hello │ 1 │ [10,20] │ - │ Hello │ 2 │ [10,20] │ - │ World │ 3 │ [30,40,50] │ - │ World │ 4 │ [30,40,50] │ - │ World │ 5 │ [30,40,50] │ - └───────┴────────┴────────────┘ - - 5 rows in set. Elapsed: 0.001 sec. - -为了方便使用原来的nested类型的数组,你可以为nested类型定义一个别名。例如: - - :) SELECT s, n.x, n.y, nest.x, nest.y FROM nested_test ARRAY JOIN nest AS n - - SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` - FROM nested_test - ARRAY JOIN nest AS n - - ┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐ - │ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ - │ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ - │ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ - │ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ - │ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ - └───────┴─────┴─────┴─────────┴────────────┘ - - 5 rows in set. Elapsed: 0.001 sec. - -使用arrayEnumerate函数的示例: - - :) SELECT s, n.x, n.y, nest.x, nest.y, num FROM nested_test ARRAY JOIN nest AS n, arrayEnumerate(nest.x) AS num - - SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num - FROM nested_test - ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num - - ┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐ - │ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │ - │ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │ - │ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │ - │ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │ - │ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │ - └───────┴─────┴─────┴─────────┴────────────┴─────┘ - - 5 rows in set. Elapsed: 0.002 sec. - -在一个查询中只能出现一个ARRAY JOIN子句。 - -如果在WHERE/PREWHERE子句中使用了ARRAY JOIN子句的结果,它将优先于WHERE/PREWHERE子句执行,否则它将在WHERE/PRWHERE子句之后执行,以便减少计算。 - -### JOIN 子句 {#select-join} - -JOIN子句用于连接数据,作用与[SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL))的定义相同。 - -!!! info "注意" - 与 [ARRAY JOIN](#select-array-join-clause) 没有关系. - -``` sql -SELECT -FROM -[GLOBAL] [ANY|ALL] INNER|LEFT|RIGHT|FULL|CROSS [OUTER] JOIN -(ON )|(USING ) ... -``` - -可以使用具体的表名来代替``与``。但这与使用`SELECT * FROM table`子查询的方式相同。除非你的表是\[Join\](../operations/table\_engines/join.md -**支持的`JOIN`类型** - -- `INNER JOIN` -- `LEFT OUTER JOIN` -- `RIGHT OUTER JOIN` -- `FULL OUTER JOIN` -- `CROSS JOIN` - -你可以跳过默认的`OUTER`关键字。 - -**`ANY` 与 `ALL`** - -在使用`ALL`修饰符对JOIN进行修饰时,如果右表中存在多个与左表关联的数据,那么系统则将右表中所有可以与左表关联的数据全部返回在结果中。这与SQL标准的JOIN行为相同。 -在使用`ANY`修饰符对JOIN进行修饰时,如果右表中存在多个与左表关联的数据,那么系统仅返回第一个与左表匹配的结果。如果左表与右表一一对应,不存在多余的行时,`ANY`与`ALL`的结果相同。 - -你可以在会话中通过设置 [join\_default\_strictness](../../operations/settings/settings.md) 来指定默认的JOIN修饰符。 - -**`GLOBAL` 分布** - -当使用普通的`JOIN`时,查询将被发送给远程的服务器。并在这些远程服务器上生成右表并与它们关联。换句话说,右表来自于各个服务器本身。 - -当使用`GLOBAL ... JOIN`,首先会在请求服务器上计算右表并以临时表的方式将其发送到所有服务器。这时每台服务器将直接使用它进行计算。 - -使用`GLOBAL`时需要小心。更多信息,参阅 [分布式子查询](#select-distributed-subqueries) 部分。 - -**使用建议** - -从子查询中删除所有`JOIN`不需要的列。 - -当执行`JOIN`查询时,因为与其他阶段相比没有进行执行顺序的优化:JOIN优先于WHERE与聚合执行。因此,为了显示的指定执行顺序,我们推荐你使用子查询的方式执行`JOIN`。 - -示例: - -``` sql -SELECT - CounterID, - hits, - visits -FROM -( - SELECT - CounterID, - count() AS hits - FROM test.hits - GROUP BY CounterID -) ANY LEFT JOIN -( - SELECT - CounterID, - sum(Sign) AS visits - FROM test.visits - GROUP BY CounterID -) USING CounterID -ORDER BY hits DESC -LIMIT 10 -``` - - ┌─CounterID─┬───hits─┬─visits─┐ - │ 1143050 │ 523264 │ 13665 │ - │ 731962 │ 475698 │ 102716 │ - │ 722545 │ 337212 │ 108187 │ - │ 722889 │ 252197 │ 10547 │ - │ 2237260 │ 196036 │ 9522 │ - │ 23057320 │ 147211 │ 7689 │ - │ 722818 │ 90109 │ 17847 │ - │ 48221 │ 85379 │ 4652 │ - │ 19762435 │ 77807 │ 7026 │ - │ 722884 │ 77492 │ 11056 │ - └───────────┴────────┴────────┘ - -子查询不允许您设置别名或在其他地方引用它们。 -`USING`中指定的列必须在两个子查询中具有相同的名称,而其他列必须具有不同的名称。您可以通过使用别名的方式来更改子查询中的列名(示例中就分别使用了'hits'与'visits'别名)。 - -`USING`子句用于指定要进行链接的一个或多个列,系统会将这些列在两张表中相等的值连接起来。如果列是一个列表,不需要使用括号包裹。同时JOIN不支持其他更复杂的Join方式。 - -右表(子查询的结果)将会保存在内存中。如果没有足够的内存,则无法运行`JOIN`。 - -只能在查询中指定一个`JOIN`。若要运行多个`JOIN`,你可以将它们放入子查询中。 - -每次运行相同的`JOIN`查询,总是会再次计算 - 没有缓存结果。 为了避免这种情况,可以使用'Join'引擎,它是一个预处理的Join数据结构,总是保存在内存中。更多信息,参见«Join引擎»部分。 - -在一些场景下,使用`IN`代替`JOIN`将会得到更高的效率。在各种类型的JOIN中,最高效的是`ANY LEFT JOIN`,然后是`ANY INNER JOIN`,效率最差的是`ALL LEFT JOIN`以及`ALL INNER JOIN`。 - -如果你需要使用`JOIN`来关联一些纬度表(包含纬度属性的一些相对比较小的表,例如广告活动的名称),那么`JOIN`可能不是好的选择,因为语法负责,并且每次查询都将重新访问这些表。对于这种情况,您应该使用«外部字典»的功能来替换`JOIN`。更多信息,参见 [外部字典](../../sql_reference/statements/select.md) 部分。 - -#### Null的处理 {#nullde-chu-li} - -JOIN的行为受 [join\_use\_nulls](../../operations/settings/settings.md) 的影响。当`join_use_nulls=1`时,`JOIN`的工作与SQL标准相同。 - -如果JOIN的key是 [可为空](../../sql_reference/statements/select.md) 类型的字段,则其中至少一个存在 [NULL](../syntax.md) 值的key不会被关联。 - -### WHERE 子句 {#select-where} - -如果存在WHERE子句, 则在该子句中必须包含一个UInt8类型的表达式。 这个表达是通常是一个带有比较和逻辑的表达式。 -这个表达式将会在所有数据转换前用来过滤数据。 - -如果在支持索引的数据库表引擎中,这个表达式将被评估是否使用索引。 - -### PREWHERE 子句 {#prewhere-zi-ju} - -这个子句与WHERE子句的意思相同。主要的不同之处在于表数据的读取。 -当使用PREWHERE时,首先只读取PREWHERE表达式中需要的列。然后在根据PREWHERE执行的结果读取其他需要的列。 - -如果在过滤条件中有少量不适合索引过滤的列,但是它们又可以提供很强的过滤能力。这时使用PREWHERE是有意义的,因为它将帮助减少数据的读取。 - -例如,在一个需要提取大量列的查询中为少部分列编写PREWHERE是很有作用的。 - -PREWHERE 仅支持`*MergeTree`系列引擎。 - -在一个查询中可以同时指定PREWHERE和WHERE,在这种情况下,PREWHERE优先于WHERE执行。 - -值得注意的是,PREWHERE不适合用于已经存在于索引中的列,因为当列已经存在于索引中的情况下,只有满足索引的数据块才会被读取。 - -如果将'optimize\_move\_to\_prewhere'设置为1,并且在查询中不包含PREWHERE,则系统将自动的把适合PREWHERE表达式的部分从WHERE中抽离到PREWHERE中。 - -### GROUP BY 子句 {#select-group-by-clause} - -这是列式数据库管理系统中最重要的一部分。 - -如果存在GROUP BY子句,则在该子句中必须包含一个表达式列表。其中每个表达式将会被称之为«key»。 -SELECT,HAVING,ORDER BY子句中的表达式列表必须来自于这些«key»或聚合函数。简而言之,被选择的列中不能包含非聚合函数或key之外的其他列。 - -如果查询表达式列表中仅包含聚合函数,则可以省略GROUP BY子句,这时会假定将所有数据聚合成一组空«key»。 - -示例: - -``` sql -SELECT - count(), - median(FetchTiming > 60 ? 60 : FetchTiming), - count() - sum(Refresh) -FROM hits -``` - -与SQL标准不同的是,如果表中不存在任何数据(可能表本身中就不存在任何数据,或者由于被WHERE条件过滤掉了),将返回一个空结果,而不是一个包含聚合函数初始值的结果。 - -与MySQL不同的是(实际上这是符合SQL标准的),你不能够获得一个不在key中的非聚合函数列(除了常量表达式)。但是你可以使用'any'(返回遇到的第一个值)、max、min等聚合函数使它工作。 - -示例: - -``` sql -SELECT - domainWithoutWWW(URL) AS domain, - count(), - any(Title) AS title -- getting the first occurred page header for each domain. -FROM hits -GROUP BY domain -``` - -GROUP BY子句会为遇到的每一个不同的key计算一组聚合函数的值。 - -在GROUP BY子句中不支持使用Array类型的列。 - -常量不能作为聚合函数的参数传入聚合函数中。例如: sum(1)。这种情况下你可以省略常量。例如:`count()`。 - -#### NULL 处理 {#null-chu-li} - -对于GROUP BY子句,ClickHouse将 [NULL](../syntax.md) 解释为一个值,并且支持`NULL=NULL`。 - -下面这个例子将说明这将意味着什么。 - -假设你有这样一张表: - - ┌─x─┬────y─┐ - │ 1 │ 2 │ - │ 2 │ ᴺᵁᴸᴸ │ - │ 3 │ 2 │ - │ 3 │ 3 │ - │ 3 │ ᴺᵁᴸᴸ │ - └───┴──────┘ - -运行`SELECT sum(x), y FROM t_null_big GROUP BY y`你将得到如下结果: - - ┌─sum(x)─┬────y─┐ - │ 4 │ 2 │ - │ 3 │ 3 │ - │ 5 │ ᴺᵁᴸᴸ │ - └────────┴──────┘ - -你可以看到GROUP BY为`y=NULL`的聚合了x。 - -如果你在向`GROUP BY`中放入几个key,结果将列出所有的组合可能。就像`NULL`是一个特定的值一样。 - -#### WITH TOTALS 修饰符 {#with-totals-xiu-shi-fu} - -如果你指定了WITH TOTALS修饰符,你将会在结果中得到一个被额外计算出的行。在这一行中将包含所有key的默认值(零或者空值),以及所有聚合函数对所有被选择数据行的聚合结果。 - -该行仅在JSON\*, TabSeparated\*, Pretty\*输出格式中与其他行分开输出。 - -在JSON\*输出格式中,这行将出现在Json的'totals'字段中。在TabSeparated\*输出格式中,这行将位于其他结果之后,同时与其他结果使用空白行分隔。在Pretty\*输出格式中,这行将作为单独的表在所有结果之后输出。 - -当`WITH TOTALS`与HAVING子句同时存在时,它的行为受'totals\_mode'配置的影响。 -默认情况下,`totals_mode = 'before_having'`,这时`WITH TOTALS`将会在HAVING前计算最多不超过`max_rows_to_group_by`行的数据。 - -在`group_by_overflow_mode = 'any'`并指定了`max_rows_to_group_by`的情况下,`WITH TOTALS`的行为受`totals_mode`的影响。 - -`after_having_exclusive` - 在HAVING后进行计算,计算不超过`max_rows_to_group_by`行的数据。 - -`after_having_inclusive` - 在HAVING后进行计算,计算不少于`max_rows_to_group_by`行的数据。 - -`after_having_auto` - 在HAVING后进行计算,采用统计通过HAVING的行数,在超过不超过'max\_rows\_to\_group\_by'指定值(默认为50%)的情况下,包含所有行的结果。否则排除这些结果。 - -`totals_auto_threshold` - 默认 0.5,是`after_having_auto`的参数。 - -如果`group_by_overflow_mode != 'any'`并没有指定`max_rows_to_group_by`情况下,所有的模式都与`after_having`相同。 - -你可以在子查询,包含子查询的JOIN子句中使用WITH TOTALS(在这种情况下,它们各自的总值会被组合在一起)。 - -#### GROUP BY 使用外部存储设备 {#select-group-by-in-external-memory} - -你可以在GROUP BY中允许将临时数据转存到磁盘上,以限制对内存的使用。 -`max_bytes_before_external_group_by`这个配置确定了在GROUP BY中启动将临时数据转存到磁盘上的内存阈值。如果你将它设置为0(这是默认值),这项功能将被禁用。 - -当使用`max_bytes_before_external_group_by`时,我们建议将max\_memory\_usage设置为它的两倍。这是因为一个聚合需要两个阶段来完成:(1)读取数据并形成中间数据 (2)合并中间数据。临时数据的转存只会发生在第一个阶段。如果没有发生临时文件的转存,那么阶段二将最多消耗与1阶段相同的内存大小。 - -例如:如果将`max_memory_usage`设置为10000000000并且你想要开启外部聚合,那么你需要将`max_bytes_before_external_group_by`设置为10000000000的同时将`max_memory_usage`设置为20000000000。当外部聚合被触发时(如果刚好只形成了一份临时数据),它的内存使用量将会稍高与`max_bytes_before_external_group_by`。 - -在分布式查询处理中,外部聚合将会在远程的服务器中执行。为了使请求服务器只使用较少的内存,可以设置`distributed_aggregation_memory_efficient`为1。 - -当合并被刷到磁盘的临时数据以及合并远程的服务器返回的结果时,如果在启动`distributed_aggregation_memory_efficient`的情况下,将会消耗1/256 \* 线程数的总内存大小。 - -当启动外部聚合时,如果数据的大小小于`max_bytes_before_external_group_by`设置的值(数据没有被刷到磁盘中),那么数据的聚合速度将会和没有启动外部聚合时一样快。如果有临时数据被刷到了磁盘中,那么这个查询的运行时间将会被延长几倍(大约是3倍)。 - -如果你在GROUP BY后面存在ORDER BY子句,并且ORDER BY后面存在一个极小限制的LIMIT,那么ORDER BY子句将不会使用太多内存。 -否则请不要忘记启动外部排序(`max_bytes_before_external_sort`)。 - -### LIMIT N BY 子句 {#limit-n-by-zi-ju} - -LIMIT N BY子句和LIMIT没有关系, LIMIT N BY COLUMNS 子句可以用来在每一个COLUMNS分组中求得最大的N行数据。我们可以将它们同时用在一个查询中。LIMIT N BY子句中可以包含任意多个分组字段表达式列表。 - -示例: - -``` sql -SELECT - domainWithoutWWW(URL) AS domain, - domainWithoutWWW(REFERRER_URL) AS referrer, - device_type, - count() cnt -FROM hits -GROUP BY domain, referrer, device_type -ORDER BY cnt DESC -LIMIT 5 BY domain, device_type -LIMIT 100 -``` - -查询将会为每个`domain, device_type`的组合选出前5个访问最多的数据,但是结果最多将不超过100行(`LIMIT n BY + LIMIT`)。 - -### HAVING 子句 {#having-zi-ju} - -HAVING子句可以用来过滤GROUP BY之后的数据,类似于WHERE子句。 -WHERE于HAVING不同之处在于WHERE在聚合前(GROUP BY)执行,HAVING在聚合后执行。 -如果不存在聚合,则不能使用HAVING。 - -### ORDER BY 子句 {#select-order-by} - -如果存在ORDER BY 子句,则该子句中必须存在一个表达式列表,表达式列表中每一个表达式都可以分配一个DESC或ASC(排序的方向)。如果没有指明排序的方向,将假定以ASC的方式进行排序。其中ASC表示按照升序排序,DESC按照降序排序。示例:`ORDER BY Visits DESC, SearchPhrase` - -对于字符串的排序来讲,你可以为其指定一个排序规则,在指定排序规则时,排序总是不会区分大小写。并且如果与ASC或DESC同时出现时,排序规则必须在它们的后面指定。例如:`ORDER BY SearchPhrase COLLATE 'tr'` - 使用土耳其字母表对它进行升序排序,同时排序时不会区分大小写,并按照UTF-8字符集进行编码。 - -我们推荐只在少量的数据集中使用COLLATE,因为COLLATE的效率远低于正常的字节排序。 - -针对排序表达式中相同值的行将以任意的顺序进行输出,这是不确定的(每次都可能不同)。 -如果省略ORDER BY子句,则结果的顺序也是不固定的。 - -`NaN` 和 `NULL` 的排序规则: - -- 当使用`NULLS FIRST`修饰符时,将会先输出`NULL`,然后是`NaN`,最后才是其他值。 -- 当使用`NULLS LAST`修饰符时,将会先输出其他值,然后是`NaN`,最后才是`NULL`。 -- 默认情况下与使用`NULLS LAST`修饰符相同。 - -示例: - -假设存在如下一张表 - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 2 │ 2 │ - │ 1 │ nan │ - │ 2 │ 2 │ - │ 3 │ 4 │ - │ 5 │ 6 │ - │ 6 │ nan │ - │ 7 │ ᴺᵁᴸᴸ │ - │ 6 │ 7 │ - │ 8 │ 9 │ - └───┴──────┘ - -运行查询 `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` 将获得如下结果: - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 7 │ ᴺᵁᴸᴸ │ - │ 1 │ nan │ - │ 6 │ nan │ - │ 2 │ 2 │ - │ 2 │ 2 │ - │ 3 │ 4 │ - │ 5 │ 6 │ - │ 6 │ 7 │ - │ 8 │ 9 │ - └───┴──────┘ - -当使用浮点类型的数值进行排序时,不管排序的顺序如何,NaNs总是出现在所有值的后面。换句话说,当你使用升序排列一个浮点数值列时,NaNs好像比所有值都要大。反之,当你使用降序排列一个浮点数值列时,NaNs好像比所有值都小。 - -如果你在ORDER BY子句后面存在LIMIT并给定了较小的数值,则将会使用较少的内存。否则,内存的使用量将与需要排序的数据成正比。对于分布式查询,如果省略了GROUP BY,则在远程服务器上执行部分排序,最后在请求服务器上合并排序结果。这意味这对于分布式查询而言,要排序的数据量可以大于单台服务器的内存。 - -如果没有足够的内存,可以使用外部排序(在磁盘中创建一些临时文件)。可以使用`max_bytes_before_external_sort`来设置外部排序,如果你讲它设置为0(默认),则表示禁用外部排序功能。如果启用该功能。当要排序的数据量达到所指定的字节数时,当前排序的结果会被转存到一个临时文件中去。当全部数据读取完毕后,所有的临时文件将会合并成最终输出结果。这些临时文件将会写到config文件配置的/var/lib/clickhouse/tmp/目录中(默认值,你可以通过修改'tmp\_path'配置调整该目录的位置)。 - -查询运行使用的内存要高于'max\_bytes\_before\_external\_sort',为此,这个配置必须要远远小于'max\_memory\_usage'配置的值。例如,如果你的服务器有128GB的内存去运行一个查询,那么推荐你将'max\_memory\_usage'设置为100GB,'max\_bytes\_before\_external\_sort'设置为80GB。 - -外部排序效率要远低于在内存中排序。 - -### SELECT 子句 {#select-zi-ju} - -在完成上述列出的所有子句后,将对SELECT子句中的表达式进行分析。 -具体来讲,如果在存在聚合函数的情况下,将对聚合函数之前的表达式进行分析。 -聚合函数与聚合函数之前的表达式都将在聚合期间完成计算(GROUP BY)。 -就像他们本身就已经存在结果上一样。 - -### DISTINCT 子句 {#select-distinct} - -如果存在DISTINCT子句,则会对结果中的完全相同的行进行去重。 -在GROUP BY不包含聚合函数,并对全部SELECT部分都包含在GROUP BY中时的作用一样。但该子句还是与GROUP BY子句存在以下几点不同: - -- 可以与GROUP BY配合使用。 -- 当不存在ORDER BY子句并存在LIMIT子句时,查询将在同时满足DISTINCT与LIMIT的情况下立即停止查询。 -- 在处理数据的同时输出结果,并不是等待整个查询全部完成。 - -在SELECT表达式中存在Array类型的列时,不能使用DISTINCT。 - -`DISTINCT`可以与 [NULL](../syntax.md)一起工作,就好像`NULL`仅是一个特殊的值一样,并且`NULL=NULL`。换而言之,在`DISTINCT`的结果中,与`NULL`不同的组合仅能出现一次。 - -### LIMIT 子句 {#limit-zi-ju} - -LIMIT m 用于在查询结果中选择前m行数据。 -LIMIT n, m 用于在查询结果中选择从n行开始的m行数据。 - -'n'与'm'必须是正整数。 - -如果没有指定ORDER BY子句,则结果可能是任意的顺序,并且是不确定的。 - -### UNION ALL 子句 {#union-all-zi-ju} - -UNION ALL子句可以组合任意数量的查询,例如: - -``` sql -SELECT CounterID, 1 AS table, toInt64(count()) AS c - FROM test.hits - GROUP BY CounterID - -UNION ALL - -SELECT CounterID, 2 AS table, sum(Sign) AS c - FROM test.visits - GROUP BY CounterID - HAVING c > 0 -``` - -仅支持UNION ALL,不支持其他UNION规则(UNION DISTINCT)。如果你需要UNION DISTINCT,你可以使用UNION ALL中包含SELECT DISTINCT的子查询的方式。 - -UNION ALL中的查询可以同时运行,它们的结果将被混合到一起。 - -这些查询的结果结果必须相同(列的数量和类型)。列名可以是不同的。在这种情况下,最终结果的列名将从第一个查询中获取。UNION会为查询之间进行类型转换。例如,如果组合的两个查询中包含相同的字段,并且是类型兼容的`Nullable`和non-`Nullable`,则结果将会将该字段转换为`Nullable`类型的字段。 - -作为UNION ALL查询的部分不能包含在括号内。ORDER BY与LIMIT子句应该被应用在每个查询中,而不是最终的查询中。如果你需要做最终结果转换,你可以将UNION ALL作为一个子查询包含在FROM子句中。 - -### INTO OUTFILE 子句 {#into-outfile-zi-ju} - -`INTO OUTFILE filename` 子句用于将查询结果重定向输出到指定文件中(filename是一个字符串类型的值)。 -与MySQL不同,执行的结果文件将在客户端建立,如果文件已存在,查询将会失败。 -此命令可以工作在命令行客户端与clickhouse-local中(通过HTTP借口发送将会失败)。 - -默认的输出格式是TabSeparated(与命令行客户端的批处理模式相同)。 - -### FORMAT 子句 {#format-zi-ju} - -‘FORMAT format’ 子句用于指定返回数据的格式。 -你可以使用它方便的转换或创建数据的转储。 -更多信息,参见«输入输出格式»部分。 -如果不存在FORMAT子句,则使用默认的格式,这将取决与DB的配置以及所使用的客户端。对于批量模式的HTTP客户端和命令行客户端而言,默认的格式是TabSeparated。对于交互模式下的命令行客户端,默认的格式是PrettyCompact(它有更加美观的格式)。 - -当使用命令行客户端时,数据以内部高效的格式在服务器和客户端之间进行传递。客户端将单独的解析FORMAT子句,以帮助数据格式的转换(这将减轻网络和服务器的负载)。 - -### IN 运算符 {#select-in-operators} - -对于`IN`、`NOT IN`、`GLOBAL IN`、`GLOBAL NOT IN`操作符被分别实现,因为它们的功能非常丰富。 - -运算符的左侧是单列或列的元组。 - -示例: - -``` sql -SELECT UserID IN (123, 456) FROM ... -SELECT (CounterID, UserID) IN ((34, 123), (101500, 456)) FROM ... -``` - -如果左侧是单个列并且是一个索引,并且右侧是一组常量时,系统将使用索引来处理查询。 - -不要在列表中列出太多的值(百万)。如果数据集很大,将它们放入临时表中(可以参考«»), 然后使用子查询。 -Don't list too many values explicitly (i.e. millions). If a data set is large, put it in a temporary table (for example, see the section «External data for query processing»), then use a subquery. - -右侧可以是一个由常量表达式组成的元组列表(像上面的例子一样),或者是一个数据库中的表的名称,或是一个包含在括号中的子查询。 - -如果右侧是一个表的名字(例如,`UserID IN users`),这相当于`UserID IN (SELECT * FROM users)`。在查询与外部数据表组合使用时可以使用该方法。例如,查询与包含user IDS的'users'临时表一起被发送的同时需要对结果进行过滤时。 - -如果操作符的右侧是一个Set引擎的表时(数据总是在内存中准备好),则不会每次都为查询创建新的数据集。 - -子查询可以指定一个列以上的元组来进行过滤。 -示例: - -``` sql -SELECT (CounterID, UserID) IN (SELECT CounterID, UserID FROM ...) FROM ... -``` - -IN操作符的左右两侧应具有相同的类型。 - -IN操作符的子查询中可以出现任意子句,包含聚合函数与lambda函数。 -示例: - -``` sql -SELECT - EventDate, - avg(UserID IN - ( - SELECT UserID - FROM test.hits - WHERE EventDate = toDate('2014-03-17') - )) AS ratio -FROM test.hits -GROUP BY EventDate -ORDER BY EventDate ASC -``` - - ┌──EventDate─┬────ratio─┐ - │ 2014-03-17 │ 1 │ - │ 2014-03-18 │ 0.807696 │ - │ 2014-03-19 │ 0.755406 │ - │ 2014-03-20 │ 0.723218 │ - │ 2014-03-21 │ 0.697021 │ - │ 2014-03-22 │ 0.647851 │ - │ 2014-03-23 │ 0.648416 │ - └────────────┴──────────┘ - -为3月17日之后的每一天计算与3月17日访问该网站的用户浏览网页的百分比。 -IN子句中的子查询仅在单个服务器上运行一次。不能够是相关子查询。 - -#### NULL 处理 {#null-chu-li-1} - -在处理中,IN操作符总是假定 [NULL](../syntax.md) 值的操作结果总是等于`0`,而不管`NULL`位于左侧还是右侧。`NULL`值不应该包含在任何数据集中,它们彼此不能够对应,并且不能够比较。 - -下面的示例中有一个`t_null`表: - - ┌─x─┬────y─┐ - │ 1 │ ᴺᵁᴸᴸ │ - │ 2 │ 3 │ - └───┴──────┘ - -运行查询`SELECT x FROM t_null WHERE y IN (NULL,3)`将得到如下结果: - - ┌─x─┐ - │ 2 │ - └───┘ - -你可以看到在查询结果中不存在`y = NULL`的结果。这是因为ClickHouse无法确定`NULL`是否包含在`(NULL,3)`数据集中,对于这次比较操作返回了`0`,并且在`SELECT`的最终输出中排除了这行。 - - SELECT y IN (NULL, 3) - FROM t_null - - ┌─in(y, tuple(NULL, 3))─┐ - │ 0 │ - │ 1 │ - └───────────────────────┘ - -#### 分布式子查询 {#select-distributed-subqueries} - -对于带有子查询的(类似与JOINs)IN中,有两种选择:普通的`IN`/`JOIN`与`GLOBAL IN` / `GLOBAL JOIN`。它们对于分布式查询的处理运行方式是不同的。 - -!!! 注意 "注意" - 请记住,下面描述的算法可能因为根据 [设置](../../operations/settings/settings.md) 配置的不同而不同。 - -当使用普通的IN时,查询总是被发送到远程的服务器,并且在每个服务器中运行«IN»或«JOIN»子句中的子查询。 - -当使用`GLOBAL IN` / `GLOBAL JOIN`时,首先会为`GLOBAL IN` / `GLOBAL JOIN`运行所有子查询,并将结果收集到临时表中,并将临时表发送到每个远程服务器,并使用该临时表运行查询。 - -对于非分布式查询,请使用普通的`IN` / `JOIN`。 - -在分布式查询中使用`IN` / `JOIN`子句中使用子查询需要小心。 - -让我们来看一些例子。假设集群中的每个服务器都存在一个正常表**local\_table**。与一个分布式表**distributed\_table**。 - -对于所有查询**distributed\_table**的查询,查询会被发送到所有的远程服务器并使用**local\_table**表运行查询。 - -例如,查询 - -``` sql -SELECT uniq(UserID) FROM distributed_table -``` - -将发送如下查询到所有远程服务器 - -``` sql -SELECT uniq(UserID) FROM local_table -``` - -这时将并行的执行它们,直到达到可以组合数据的中间结果状态。然后中间结果将返回到请求服务器并在请求服务器上进行合并,最终将结果发送给客户端。 - -现在让我运行一个带有IN的查询: - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) -``` - -- 计算两个站点的用户交集。 - -此查询将被发送给所有的远程服务器 - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) -``` - -换句话说,IN子句中的数据集将被在每台服务器上被独立的收集,仅与每台服务器上的本地存储上的数据计算交集。 - -如果您已经将数据分散到了集群的每台服务器上,并且单个UserID的数据完全分布在单个服务器上,那么这将是正确且最佳的查询方式。在这种情况下,所有需要的数据都可以在每台服务器的本地进行获取。否则,结果将是不准确的。我们将这种查询称为«local IN»。 - -为了修正这种在数据随机分布的集群中的工作,你可以在子查询中使用**distributed\_table**。查询将更改为这样: - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -此查询将被发送给所有的远程服务器 - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -子查询将在每个远程服务器上执行。因为子查询使用分布式表,所有每个远程服务器上的子查询将查询再次发送给所有的远程服务器 - -``` sql -SELECT UserID FROM local_table WHERE CounterID = 34 -``` - -例如,如果你拥有100台服务器的集群,执行整个查询将需要10,000次请求,这通常被认为是不可接受的。 - -在这种情况下,你应该使用GLOBAL IN来替代IN。让我们看一下它是如何工作的。 - -``` sql -SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID GLOBAL IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) -``` - -在请求服务器上运行子查询 - -``` sql -SELECT UserID FROM distributed_table WHERE CounterID = 34 -``` - -将结果放入内存中的临时表中。然后将请求发送到每一台远程服务器 - -``` sql -SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID GLOBAL IN _data1 -``` - -临时表`_data1`也会随着查询一起发送到每一台远程服务器(临时表的名称由具体实现定义)。 - -这比使用普通的IN更加理想,但是,请注意以下几点: - -1. 创建临时表时,数据不是唯一的,为了减少通过网络传输的数据量,请在子查询中使用DISTINCT(你不需要在普通的IN中这么做) -2. 临时表将发送到所有远程服务器。其中传输不考虑网络的拓扑结构。例如,如果你有10个远程服务器存在与请求服务器非常远的数据中心中,则数据将通过通道发送数据到远程数据中心10次。使用GLOBAL IN时应避免大数据集。 -3. 当向远程服务器发送数据时,网络带宽的限制是不可配置的,这可能会网络的负载造成压力。 -4. 尝试将数据跨服务器分布,这样你将不需要使用GLOBAL IN。 -5. 如果你需要经常使用GLOBAL IN,请规划你的ClickHouse集群位置,以便副本之间不存在跨数据中心,并且它们之间具有快速的网络交换能力,以便查询可以完全在一个数据中心内完成。 - -另外,在`GLOBAL IN`子句中使用本地表也是有用的,比如,本地表仅在请求服务器上可用,并且您希望在远程服务器上使用来自本地表的数据。 - -### 极端值 {#extreme-values} - -除了结果外,你还可以获得结果列的最大值与最小值,可以将**极端**配置设置成1来做到这一点。最大值最小值的计算是针对于数字类型,日期类型进行计算的,对于其他列,将会输出默认值。 - -额外计算的两行结果 - 最大值与最小值,这两行额外的结果仅在JSON\*, TabSeparated\*, and Pretty\* 格式与其他行分开的输出方式输出,不支持其他输出格式。 - -在JSON\*格式中,Extreme值在单独的'extremes'字段中。在TabSeparated\*格式中,在其他结果与'totals'之后输出,并使用空行与其分隔。在Pretty\* 格式中,将在其他结果与'totals'后以单独的表格输出。 - -如果在计算Extreme值的同时包含LIMIT。extremes的计算结果将包含offset跳过的行。在流式的请求中,它可能还包含多余LIMIT的少量行的值。 - -### 注意事项 {#zhu-yi-shi-xiang} - -不同于MySQL, `GROUP BY`与`ORDER BY`子句不支持使用列的位置信息作为参数,但这实际上是符合SQL标准的。 -例如,`GROUP BY 1, 2`将被解释为按照常量进行分组(即,所有的行将会被聚合成一行)。 - -可以在查询的任何部分使用AS。 - -可以在查询的任何部分添加星号,而不仅仅是表达式。在分析查询时,星号被替换为所有的列(不包含`MATERIALIZED`与`ALIAS`的列)。 -只有少数情况下使用星号是合理的: - -- 创建表转储时。 -- 对于仅包含几个列的表,如系统表. -- 获取表中的列信息。在这种情况下应该使用`LIMIT 1`。但是,更好的办法是使用`DESC TABLE`。 -- 当使用`PREWHERE`在少数的几个列上做强过滤时。 -- 在子查询中(因为外部查询不需要的列被排除在子查询之外)。 - -在所有的其他情况下,我们不建议使用星号,因为它是列式数据库的缺点而不是优点。 - -[来源文章](https://clickhouse.tech/docs/zh/query_language/select/) diff --git a/docs/zh/sql_reference/statements/show.md b/docs/zh/sql_reference/statements/show.md deleted file mode 100644 index f60452f97a3..00000000000 --- a/docs/zh/sql_reference/statements/show.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 38 -toc_title: SHOW ---- - -# 显示查询 {#show-queries} - -## SHOW CREATE TABLE {#show-create-table} - -``` sql -SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format] -``` - -返回单 `String`-类型 ‘statement’ column, which contains a single value – the `CREATE` 用于创建指定对象的查询。 - -## SHOW DATABASES {#show-databases} - -``` sql -SHOW DATABASES [INTO OUTFILE filename] [FORMAT format] -``` - -打印所有数据库的列表。 -这个查询是相同的 `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`. - -## SHOW PROCESSLIST {#show-processlist} - -``` sql -SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] -``` - -输出的内容 [系统。流程](../../operations/system_tables.md#system_tables-processes) 表,包含目前正在处理的查询列表,除了 `SHOW PROCESSLIST` 查询。 - -该 `SELECT * FROM system.processes` 查询返回有关所有当前查询的数据。 - -提示(在控制台中执行): - -``` bash -$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'" -``` - -## SHOW TABLES {#show-tables} - -显示表的列表。 - -``` sql -SHOW [TEMPORARY] TABLES [{FROM | IN} ] [LIKE '' | WHERE expr] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -如果 `FROM` 如果未指定子句,则查询返回当前数据库中的表列表。 - -你可以得到相同的结果 `SHOW TABLES` 通过以下方式进行查询: - -``` sql -SELECT name FROM system.tables WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**示例** - -下面的查询从表的列表中选择前两行 `system` 数据库,其名称包含 `co`. - -``` sql -SHOW TABLES FROM system LIKE '%co%' LIMIT 2 -``` - -``` text -┌─name───────────────────────────┐ -│ aggregate_function_combinators │ -│ collations │ -└────────────────────────────────┘ -``` - -## SHOW DICTIONARIES {#show-dictionaries} - -显示列表 [外部字典](../../sql_reference/dictionaries/external_dictionaries/external_dicts.md). - -``` sql -SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -如果 `FROM` 如果未指定子句,则查询从当前数据库返回字典列表。 - -你可以得到相同的结果 `SHOW DICTIONARIES` 通过以下方式进行查询: - -``` sql -SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] -``` - -**示例** - -下面的查询从表的列表中选择前两行 `system` 数据库,其名称包含 `reg`. - -``` sql -SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2 -``` - -``` text -┌─name─────────┐ -│ regions │ -│ region_names │ -└──────────────┘ -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/show/) diff --git a/docs/zh/sql_reference/statements/system.md b/docs/zh/sql_reference/statements/system.md deleted file mode 100644 index 06d4f6dc1cb..00000000000 --- a/docs/zh/sql_reference/statements/system.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 37 -toc_title: SYSTEM ---- - -# 系统查询 {#query-language-system} - -- [RELOAD DICTIONARIES](#query_language-system-reload-dictionaries) -- [RELOAD DICTIONARY](#query_language-system-reload-dictionary) -- [DROP DNS CACHE](#query_language-system-drop-dns-cache) -- [DROP MARK CACHE](#query_language-system-drop-mark-cache) -- [FLUSH LOGS](#query_language-system-flush_logs) -- [RELOAD CONFIG](#query_language-system-reload-config) -- [SHUTDOWN](#query_language-system-shutdown) -- [KILL](#query_language-system-kill) -- [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends) -- [FLUSH DISTRIBUTED](#query_language-system-flush-distributed) -- [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) -- [STOP MERGES](#query_language-system-stop-merges) -- [START MERGES](#query_language-system-start-merges) - -## RELOAD DICTIONARIES {#query_language-system-reload-dictionaries} - -重新加载之前已成功加载的所有字典。 -默认情况下,字典是懒惰加载的(请参阅 [dictionaries\_lazy\_load](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load)),所以不是在启动时自动加载,而是通过dictGet函数在第一次访问时初始化,或者从ENGINE=Dictionary的表中选择。 该 `SYSTEM RELOAD DICTIONARIES` 查询重新加载这样的字典(加载)。 -总是返回 `Ok.` 无论字典更新的结果如何。 - -## 重新加载字典Dictionary\_name {#query_language-system-reload-dictionary} - -完全重新加载字典 `dictionary_name`,与字典的状态无关(LOADED/NOT\_LOADED/FAILED)。 -总是返回 `Ok.` 无论更新字典的结果如何。 -字典的状态可以通过查询 `system.dictionaries` 桌子 - -``` sql -SELECT name, status FROM system.dictionaries; -``` - -## DROP DNS CACHE {#query_language-system-drop-dns-cache} - -重置ClickHouse的内部DNS缓存。 有时(对于旧的ClickHouse版本)在更改基础架构(更改另一个ClickHouse服务器或字典使用的服务器的IP地址)时需要使用此命令。 - -有关更方便(自动)缓存管理,请参阅disable\_internal\_dns\_cache、dns\_cache\_update\_period参数。 - -## DROP MARK CACHE {#query_language-system-drop-mark-cache} - -重置标记缓存。 用于开发ClickHouse和性能测试。 - -## FLUSH LOGS {#query_language-system-flush_logs} - -Flushes buffers of log messages to system tables (e.g. system.query\_log). Allows you to not wait 7.5 seconds when debugging. - -## RELOAD CONFIG {#query_language-system-reload-config} - -重新加载ClickHouse配置。 当配置存储在ZooKeeeper中时使用。 - -## SHUTDOWN {#query_language-system-shutdown} - -通常关闭ClickHouse(如 `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) - -## KILL {#query_language-system-kill} - -中止ClickHouse进程(如 `kill -9 {$ pid_clickhouse-server}`) - -## 管理分布式表 {#query-language-system-distributed} - -ClickHouse可以管理 [分布](../../engines/table_engines/special/distributed.md) 桌子 当用户将数据插入到这些表中时,ClickHouse首先创建应发送到群集节点的数据队列,然后异步发送它。 您可以使用 [STOP DISTRIBUTED SENDS](#query_language-system-stop-distributed-sends), [FLUSH DISTRIBUTED](#query_language-system-flush-distributed),和 [START DISTRIBUTED SENDS](#query_language-system-start-distributed-sends) 查询。 您也可以同步插入分布式数据与 `insert_distributed_sync` 设置。 - -### STOP DISTRIBUTED SENDS {#query_language-system-stop-distributed-sends} - -将数据插入分布式表时禁用后台数据分发。 - -``` sql -SYSTEM STOP DISTRIBUTED SENDS [db.] -``` - -### FLUSH DISTRIBUTED {#query_language-system-flush-distributed} - -强制ClickHouse将数据同步发送到群集节点。 如果任何节点不可用,ClickHouse将引发异常并停止查询执行。 您可以重试查询,直到查询成功,这将在所有节点恢复联机时发生。 - -``` sql -SYSTEM FLUSH DISTRIBUTED [db.] -``` - -### START DISTRIBUTED SENDS {#query_language-system-start-distributed-sends} - -将数据插入分布式表时启用后台数据分发。 - -``` sql -SYSTEM START DISTRIBUTED SENDS [db.] -``` - -### STOP MERGES {#query_language-system-stop-merges} - -提供停止MergeTree系列中表的后台合并的可能性: - -``` sql -SYSTEM STOP MERGES [[db.]merge_tree_family_table_name] -``` - -!!! note "注" - `DETACH / ATTACH` 即使在之前所有MergeTree表的合并已停止的情况下,table也会为表启动后台合并。 - -### START MERGES {#query_language-system-start-merges} - -为MergeTree系列中的表提供启动后台合并的可能性: - -``` sql -SYSTEM START MERGES [[db.]merge_tree_family_table_name] -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/system/) diff --git a/docs/zh/sql_reference/syntax.md b/docs/zh/sql_reference/syntax.md deleted file mode 100644 index ab9009def47..00000000000 --- a/docs/zh/sql_reference/syntax.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 31 -toc_title: "\u8BED\u6CD5" ---- - -# 语法 {#syntax} - -系统中有两种类型的解析器:完整SQL解析器(递归下降解析器)和数据格式解析器(快速流解析器)。 -在所有情况下,除了 `INSERT` 查询时,只使用完整的SQL解析器。 -该 `INSERT` 查询使用的分析程序: - -``` sql -INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') -``` - -该 `INSERT INTO t VALUES` 片段由完整的解析器解析,并且数据 `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 由快速流解析器解析。 您也可以通过使用 [input\_format\_values\_interpret\_expressions](../operations/settings/settings.md#settings-input_format_values_interpret_expressions) 设置。 当 `input_format_values_interpret_expressions = 1`,ClickHouse首先尝试使用fast stream解析器解析值。 如果失败,ClickHouse将尝试对数据使用完整的解析器,将其视为SQL [表达式](#syntax-expressions). - -数据可以有任何格式。 当接收到查询时,服务器计算不超过 [max\_query\_size](../operations/settings/settings.md#settings-max_query_size) RAM中请求的字节(默认为1MB),其余的是流解析。 -这意味着系统没有大的问题 `INSERT` 查询,就像MySQL一样。 - -使用时 `Values` 格式为 `INSERT` 查询,它可能看起来数据被解析相同的表达式 `SELECT` 查询,但事实并非如此。 该 `Values` 格式更为有限。 - -接下来我们将介绍完整的解析器。 有关格式解析器的详细信息,请参阅 [格式](../interfaces/formats.md) 科。 - -## 空间 {#spaces} - -语法结构之间可能有任意数量的空格符号(包括查询的开始和结束)。 空格符号包括空格、制表符、换行符、CR和换页符。 - -## 评论 {#comments} - -支持SQL样式和C样式注释。 -SQL风格的评论:来自 `--` 直到最后 后的空间 `--` 可以省略。 -C风格的评论:来自 `/*` 到 `*/`. 这些注释可以是多行。 这里也不需要空格。 - -## 关键词 {#syntax-keywords} - -当关键字对应于以下关键字时,不区分大小写: - -- SQL标准。 例如, `SELECT`, `select` 和 `SeLeCt` 都是有效的。 -- 在一些流行的DBMS(MySQL或Postgres)中实现。 例如, `DateTime` 是一样的 `datetime`. - -数据类型名称是否区分大小写可以在 `system.data_type_families` 桌子 - -与标准SQL相比,所有其他关键字(包括函数名称)都是 **区分大小写**. - -不保留关键字(它们只是在相应的上下文中解析为关键字)。 如果您使用 [标识符](#syntax-identifiers) 与关键字相同,将它们括在引号中。 例如,查询 `SELECT "FROM" FROM table_name` 是有效的,如果表 `table_name` 具有名称的列 `"FROM"`. - -## 标识符 {#syntax-identifiers} - -标识符是: - -- 集群、数据库、表、分区和列名称。 -- 功能。 -- 数据类型。 -- [表达式别名](#syntax-expression_aliases). - -标识符可以是引号或非引号。 建议使用非引号标识符。 - -非引号标识符必须与正则表达式匹配 `^[a-zA-Z_][0-9a-zA-Z_]*$` 并且不能等于 [关键词](#syntax-keywords). 例: `x, _1, X_y__Z123_.` - -如果要使用与关键字相同的标识符,或者要在标识符中使用其他符号,请使用双引号或反引号对其进行引用,例如, `"id"`, `` `id` ``. - -## 文字数 {#literals} - -有:数字,字符串,复合和 `NULL` 文字。 - -### 数字 {#numeric} - -数值文本尝试进行分析: - -- 首先作为一个64位有符号的数字,使用 [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul) 功能。 -- 如果不成功,作为64位无符号数,使用 [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) 功能。 -- 如果不成功,作为一个浮点数使用 [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) 功能。 -- 否则,将返回错误。 - -相应的值将具有该值适合的最小类型。 -例如,1被解析为 `UInt8`,但256被解析为 `UInt16`. 有关详细信息,请参阅 [数据类型](../sql_reference/data_types/index.md). - -例: `1`, `18446744073709551615`, `0xDEADBEEF`, `01`, `0.1`, `1e100`, `-1e-100`, `inf`, `nan`. - -### 字符串 {#syntax-string-literal} - -仅支持单引号中的字符串文字。 封闭的字符可以反斜杠转义。 以下转义序列具有相应的特殊值: `\b`, `\f`, `\r`, `\n`, `\t`, `\0`, `\a`, `\v`, `\xHH`. 在所有其他情况下,转义序列的格式为 `\c`,哪里 `c` 是任何字符,被转换为 `c`. 这意味着您可以使用序列 `\'`和`\\`. 该值将具有 [字符串](../sql_reference/data_types/string.md) 类型。 - -在字符串文字中需要转义的最小字符集: `'` 和 `\`. 单引号可以用单引号,文字转义 `'It\'s'` 和 `'It''s'` 是平等的。 - -### 化合物 {#compound} - -数组支持构造: `[1, 2, 3]` 和元组: `(1, 'Hello, world!', 2)`.. -实际上,这些不是文字,而是分别具有数组创建运算符和元组创建运算符的表达式。 -数组必须至少包含一个项目,元组必须至少包含两个项目。 -元组有一个特殊的用途用于 `IN` a条款 `SELECT` 查询。 元组可以作为查询的结果获得,但它们不能保存到数据库(除了 [记忆](../engines/table_engines/special/memory.md) 表)。 - -### NULL {#null-literal} - -指示该值丢失。 - -为了存储 `NULL` 在表字段中,它必须是 [可为空](../sql_reference/data_types/nullable.md) 类型。 - -根据数据格式(输入或输出), `NULL` 可能有不同的表示。 有关详细信息,请参阅以下文档 [数据格式](../interfaces/formats.md#formats). - -处理有许多细微差别 `NULL`. 例如,如果比较操作的至少一个参数是 `NULL`,此操作的结果也将是 `NULL`. 对于乘法,加法和其他操作也是如此。 有关详细信息,请阅读每个操作的文档。 - -在查询中,您可以检查 `NULL` 使用 [IS NULL](operators.md#operator-is-null) 和 [IS NOT NULL](operators.md) 运算符及相关功能 `isNull` 和 `isNotNull`. - -## 功能 {#functions} - -函数像标识符一样写入,并在括号中包含一个参数列表(可能是空的)。 与标准SQL相比,括号是必需的,即使是空的参数列表。 示例: `now()`. -有常规函数和聚合函数(请参阅部分 “Aggregate functions”). 某些聚合函数可以包含括号中的两个参数列表。 示例: `quantile (0.9) (x)`. 这些聚合函数被调用 “parametric” 函数,并在第一个列表中的参数被调用 “parameters”. 不带参数的聚合函数的语法与常规函数的语法相同。 - -## 运营商 {#operators} - -在查询解析过程中,运算符会转换为相应的函数,同时考虑它们的优先级和关联性。 -例如,表达式 `1 + 2 * 3 + 4` 转化为 `plus(plus(1, multiply(2, 3)), 4)`. - -## 数据类型和数据库表引擎 {#data_types-and-database-table-engines} - -数据类型和表引擎 `CREATE` 查询的编写方式与标识符或函数相同。 换句话说,它们可能包含也可能不包含括在括号中的参数列表。 有关详细信息,请参阅部分 “Data types,” “Table engines,” 和 “CREATE”. - -## 表达式别名 {#syntax-expression_aliases} - -别名是查询中表达式的用户定义名称。 - -``` sql -expr AS alias -``` - -- `AS` — The keyword for defining aliases. You can define the alias for a table name or a column name in a `SELECT` 子句不使用 `AS` 关键字。 - - For example, `SELECT table_name_alias.column_name FROM table_name table_name_alias`. - - In the [CAST](sql_reference/functions/type_conversion_functions.md#type_conversion_function-cast) function, the `AS` keyword has another meaning. See the description of the function. - -- `expr` — Any expression supported by ClickHouse. - - For example, `SELECT column_name * 2 AS double FROM some_table`. - -- `alias` — Name for `expr`. 别名应符合 [标识符](#syntax-identifiers) 语法 - - For example, `SELECT "table t".column_name FROM table_name AS "table t"`. - -### 使用注意事项 {#notes-on-usage} - -别名对于查询或子查询是全局的,您可以在查询的任何部分中为任何表达式定义别名。 例如, `SELECT (1 AS n) + 2, n`. - -别名在子查询和子查询之间不可见。 例如,在执行查询时 `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ClickHouse生成异常 `Unknown identifier: num`. - -如果为结果列定义了别名 `SELECT` 子查询的子句,这些列在外部查询中可见。 例如, `SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. - -小心使用与列或表名相同的别名。 让我们考虑以下示例: - -``` sql -CREATE TABLE t -( - a Int, - b Int -) -ENGINE = TinyLog() -``` - -``` sql -SELECT - argMax(a, b), - sum(b) AS b -FROM t -``` - -``` text -Received exception from server (version 18.14.17): -Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. -``` - -在这个例子中,我们声明表 `t` 带柱 `b`. 然后,在选择数据时,我们定义了 `sum(b) AS b` 别名 由于别名是全局的,ClickHouse替换了文字 `b` 在表达式中 `argMax(a, b)` 用表达式 `sum(b)`. 这种替换导致异常。 - -## 星号 {#asterisk} - -在一个 `SELECT` 查询中,星号可以替换表达式。 有关详细信息,请参阅部分 “SELECT”. - -## 表达式 {#syntax-expressions} - -表达式是函数、标识符、文字、运算符的应用程序、括号中的表达式、子查询或星号。 它还可以包含别名。 -表达式列表是一个或多个用逗号分隔的表达式。 -函数和运算符,反过来,可以有表达式作为参数。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/syntax/) diff --git a/docs/zh/sql_reference/table_functions/file.md b/docs/zh/sql_reference/table_functions/file.md deleted file mode 100644 index b3c93f7f1fd..00000000000 --- a/docs/zh/sql_reference/table_functions/file.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 37 -toc_title: "\u6587\u4EF6" ---- - -# 文件 {#file} - -从文件创建表。 此表函数类似于 [url](url.md) 和 [hdfs](hdfs.md) 一些的。 - -``` sql -file(path, format, structure) -``` - -**输入参数** - -- `path` — The relative path to the file from [user\_files\_path](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-user_files_path). 只读模式下的globs后的文件支持路径: `*`, `?`, `{abc,def}` 和 `{N..M}` 哪里 `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [格式](../../interfaces/formats.md#formats) 的文件。 -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**返回值** - -具有指定结构的表,用于读取或写入指定文件中的数据。 - -**示例** - -设置 `user_files_path` 和文件的内容 `test.csv`: - -``` bash -$ grep user_files_path /etc/clickhouse-server/config.xml - /var/lib/clickhouse/user_files/ - -$ cat /var/lib/clickhouse/user_files/test.csv - 1,2,3 - 3,2,1 - 78,43,45 -``` - -表从`test.csv` 并从中选择前两行: - -``` sql -SELECT * -FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -``` sql --- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file -SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10 -``` - -**路径中的水珠** - -多个路径组件可以具有globs。 对于正在处理的文件应该存在并匹配到整个路径模式(不仅后缀或前缀)。 - -- `*` — Substitutes any number of any characters except `/` 包括空字符串。 -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -建筑与 `{}` 类似于 [远程表功能](../../sql_reference/table_functions/remote.md)). - -**示例** - -1. 假设我们有几个具有以下相对路径的文件: - -- ‘some\_dir/some\_file\_1’ -- ‘some\_dir/some\_file\_2’ -- ‘some\_dir/some\_file\_3’ -- ‘another\_dir/some\_file\_1’ -- ‘another\_dir/some\_file\_2’ -- ‘another\_dir/some\_file\_3’ - -1. 查询这些文件中的行数: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. 查询这两个目录的所有文件中的行数: - - - -``` sql -SELECT count(*) -FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "警告" - 如果您的文件列表包含带前导零的数字范围,请单独使用带大括号的构造或使用 `?`. - -**示例** - -从名为 `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## 虚拟列 {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**另请参阅** - -- [虚拟列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/file/) diff --git a/docs/zh/sql_reference/table_functions/generate.md b/docs/zh/sql_reference/table_functions/generate.md deleted file mode 100644 index 84c711711d5..00000000000 --- a/docs/zh/sql_reference/table_functions/generate.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 47 -toc_title: generateRandom ---- - -# generateRandom {#generaterandom} - -使用给定的模式生成随机数据。 -允许用数据填充测试表。 -支持可以存储在表中的所有数据类型,除了 `LowCardinality` 和 `AggregateFunction`. - -``` sql -generateRandom('name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_string_length'[, 'max_array_length']]]); -``` - -**参数** - -- `name` — Name of corresponding column. -- `TypeName` — Type of corresponding column. -- `limit` — Number of rows to generate. -- `max_array_length` — Maximum array length for all generated arrays. Defaults to `10`. -- `max_string_length` — Maximum string length for all generated strings. Defaults to `10`. -- `random_seed` — Specify random seed manually to produce stable results. If NULL — seed is randomly generated. - -**返回值** - -具有请求架构的表对象。 - -## 用法示例 {#usage-example} - -``` sql -SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2); -``` - -``` text -┌─a────────┬────────────d─┬─c──────────────────────────────────────────────────────────────────┐ -│ [77] │ -124167.6723 │ ('2061-04-17 21:59:44.573','3f72f405-ec3e-13c8-44ca-66ef335f7835') │ -│ [32,110] │ -141397.7312 │ ('1979-02-09 03:43:48.526','982486d1-5a5d-a308-e525-7bd8b80ffa73') │ -│ [68] │ -67417.0770 │ ('2080-03-12 14:17:31.269','110425e5-413f-10a6-05ba-fa6b3e929f15') │ -└──────────┴──────────────┴────────────────────────────────────────────────────────────────────┘ -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/generate/) diff --git a/docs/zh/sql_reference/table_functions/hdfs.md b/docs/zh/sql_reference/table_functions/hdfs.md deleted file mode 100644 index 2cf79c31c83..00000000000 --- a/docs/zh/sql_reference/table_functions/hdfs.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 45 -toc_title: hdfs ---- - -# hdfs {#hdfs} - -从HDFS中的文件创建表。 此表函数类似于 [url](url.md) 和 [文件](file.md) 一些的。 - -``` sql -hdfs(URI, format, structure) -``` - -**输入参数** - -- `URI` — The relative URI to the file in HDFS. Path to file support following globs in readonly mode: `*`, `?`, `{abc,def}` 和 `{N..M}` 哪里 `N`, `M` — numbers, \``'abc', 'def'` — strings. -- `format` — The [格式](../../interfaces/formats.md#formats) 的文件。 -- `structure` — Structure of the table. Format `'column1_name column1_type, column2_name column2_type, ...'`. - -**返回值** - -具有指定结构的表,用于读取或写入指定文件中的数据。 - -**示例** - -表从 `hdfs://hdfs1:9000/test` 并从中选择前两行: - -``` sql -SELECT * -FROM hdfs('hdfs://hdfs1:9000/test', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') -LIMIT 2 -``` - -``` text -┌─column1─┬─column2─┬─column3─┐ -│ 1 │ 2 │ 3 │ -│ 3 │ 2 │ 1 │ -└─────────┴─────────┴─────────┘ -``` - -**路径中的水珠** - -多个路径组件可以具有globs。 对于正在处理的文件应该存在并匹配到整个路径模式(不仅后缀或前缀)。 - -- `*` — Substitutes any number of any characters except `/` 包括空字符串。 -- `?` — Substitutes any single character. -- `{some_string,another_string,yet_another_one}` — Substitutes any of strings `'some_string', 'another_string', 'yet_another_one'`. -- `{N..M}` — Substitutes any number in range from N to M including both borders. - -建筑与 `{}` 类似于 [远程表功能](../../sql_reference/table_functions/remote.md)). - -**示例** - -1. 假设我们在HDFS上有几个具有以下Uri的文件: - -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/some\_dir/some\_file\_3’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_1’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_2’ -- ‘hdfs://hdfs1:9000/another\_dir/some\_file\_3’ - -1. 查询这些文件中的行数: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32') -``` - -1. 查询这两个目录的所有文件中的行数: - - - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value UInt32') -``` - -!!! warning "警告" - 如果您的文件列表包含带前导零的数字范围,请单独使用带大括号的构造或使用 `?`. - -**示例** - -从名为 `file000`, `file001`, … , `file999`: - -``` sql -SELECT count(*) -FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, value UInt32') -``` - -## 虚拟列 {#virtual-columns} - -- `_path` — Path to the file. -- `_file` — Name of the file. - -**另请参阅** - -- [虚拟列](https://clickhouse.tech/docs/en/operations/table_engines/#table_engines-virtual_columns) - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/hdfs/) diff --git a/docs/zh/sql_reference/table_functions/index.md b/docs/zh/sql_reference/table_functions/index.md deleted file mode 100644 index 38ef9bf1f4b..00000000000 --- a/docs/zh/sql_reference/table_functions/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u8868\u51FD\u6570" -toc_priority: 34 -toc_title: "\u5BFC\u8A00" ---- - -# 表函数 {#table-functions} - -表函数是构造表的方法。 - -您可以使用表函数: - -- [FROM](../statements/select.md#select-from) 《公约》条款 `SELECT` 查询。 - - The method for creating a temporary table that is available only in the current query. The table is deleted when the query finishes. - -- [创建表为\](../statements/create.md#create-table-query) 查询。 - - It's one of the methods of creating a table. - -!!! warning "警告" - 你不能使用表函数,如果 [allow\_ddl](../../operations/settings/permissions_for_queries.md#settings_allow_ddl) 设置被禁用。 - -| 功能 | 产品描述 | -|--------------------|--------------------------------------------------------------------------------------------------------| -| [文件](file.md) | 创建一个 [文件](../../engines/table_engines/special/file.md)-发动机表。 | -| [合并](merge.md) | 创建一个 [合并](../../engines/table_engines/special/merge.md)-发动机表。 | -| [数字](numbers.md) | 创建一个包含整数填充的单列的表。 | -| [远程](remote.md) | 允许您访问远程服务器,而无需创建 [分布](../../engines/table_engines/special/distributed.md)-发动机表。 | -| [url](url.md) | 创建一个 [Url](../../engines/table_engines/special/url.md)-发动机表。 | -| [mysql](mysql.md) | 创建一个 [MySQL](../../engines/table_engines/integrations/mysql.md)-发动机表。 | -| [jdbc](jdbc.md) | 创建一个 [JDBC](../../engines/table_engines/integrations/jdbc.md)-发动机表。 | -| [odbc](odbc.md) | 创建一个 [ODBC](../../engines/table_engines/integrations/odbc.md)-发动机表。 | -| [hdfs](hdfs.md) | 创建一个 [HDFS](../../engines/table_engines/integrations/hdfs.md)-发动机表。 | - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/) diff --git a/docs/zh/sql_reference/table_functions/input.md b/docs/zh/sql_reference/table_functions/input.md deleted file mode 100644 index 72f71576729..00000000000 --- a/docs/zh/sql_reference/table_functions/input.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 46 -toc_title: "\u8F93\u5165" ---- - -# 输入 {#input} - -`input(structure)` -表功能,允许有效地转换和插入数据发送到 -服务器与给定结构的表与另一种结构。 - -`structure` -以下格式发送到服务器的数据结构 `'column1_name column1_type, column2_name column2_type, ...'`. -例如, `'id UInt32, name String'`. - -此功能只能用于 `INSERT SELECT` 查询,只有一次,但其他行为像普通表函数 -(例如,它可以用于子查询等。). - -数据可以以任何方式像普通发送 `INSERT` 查询并传递任何可用 [格式](../../interfaces/formats.md#formats) -必须在查询结束时指定(不像普通 `INSERT SELECT`). - -这个功能的主要特点是,当服务器从客户端接收数据时,它同时将其转换 -根据表达式中的列表 `SELECT` 子句并插入到目标表中。 临时表 -不创建所有传输的数据。 - -**例** - -- 让 `test` 表具有以下结构 `(a String, b String)` - 和数据 `data.csv` 具有不同的结构 `(col1 String, col2 Date, col3 Int32)`. 查询插入 - 从数据 `data.csv` 进 `test` 同时转换的表如下所示: - - - -``` bash -$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; -``` - -- 如果 `data.csv` 包含相同结构的数据 `test_structure` 作为表 `test` 那么这两个查询是相等的: - - - -``` bash -$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV" -$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV" -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/input/) diff --git a/docs/zh/sql_reference/table_functions/jdbc.md b/docs/zh/sql_reference/table_functions/jdbc.md deleted file mode 100644 index e2268b42e28..00000000000 --- a/docs/zh/sql_reference/table_functions/jdbc.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 43 -toc_title: jdbc ---- - -# jdbc {#table-function-jdbc} - -`jdbc(jdbc_connection_uri, schema, table)` -返回通过JDBC驱动程序连接的表。 - -此表函数需要单独的 `clickhouse-jdbc-bridge` 程序正在运行。 -它支持可空类型(基于查询的远程表的DDL)。 - -**例** - -``` sql -SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') -``` - -``` sql -SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'schema', 'table') -``` - -``` sql -SELECT * FROM jdbc('datasource://mysql-local', 'schema', 'table') -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/zh/sql_reference/table_functions/merge.md b/docs/zh/sql_reference/table_functions/merge.md deleted file mode 100644 index 7304c447b1f..00000000000 --- a/docs/zh/sql_reference/table_functions/merge.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 38 -toc_title: "\u5408\u5E76" ---- - -# 合并 {#merge} - -`merge(db_name, 'tables_regexp')` – Creates a temporary Merge table. For more information, see the section “Table engines, Merge”. - -表结构取自与正则表达式匹配的第一个表。 - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/merge/) diff --git a/docs/zh/sql_reference/table_functions/mysql.md b/docs/zh/sql_reference/table_functions/mysql.md deleted file mode 100644 index 3cdf3047aac..00000000000 --- a/docs/zh/sql_reference/table_functions/mysql.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 42 -toc_title: mysql ---- - -# mysql {#mysql} - -允许 `SELECT` 要对存储在远程MySQL服务器上的数据执行的查询。 - -``` sql -mysql('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); -``` - -**参数** - -- `host:port` — MySQL server address. - -- `database` — Remote database name. - -- `table` — Remote table name. - -- `user` — MySQL user. - -- `password` — User password. - -- `replace_query` — Flag that converts `INSERT INTO` 查询到 `REPLACE INTO`. 如果 `replace_query=1`,查询被替换。 - -- `on_duplicate_clause` — The `ON DUPLICATE KEY on_duplicate_clause` 表达式被添加到 `INSERT` 查询。 - - Example: `INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`, where `on_duplicate_clause` is `UPDATE c2 = c2 + 1`. See the MySQL documentation to find which `on_duplicate_clause` you can use with the `ON DUPLICATE KEY` clause. - - To specify `on_duplicate_clause` you need to pass `0` to the `replace_query` parameter. If you simultaneously pass `replace_query = 1` and `on_duplicate_clause`, ClickHouse generates an exception. - -简单 `WHERE` 条款如 `=, !=, >, >=, <, <=` 当前在MySQL服务器上执行。 - -其余的条件和 `LIMIT` 只有在对MySQL的查询完成后,才会在ClickHouse中执行采样约束。 - -**返回值** - -与原始MySQL表具有相同列的table对象。 - -## 用法示例 {#usage-example} - -MySQL中的表: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -从ClickHouse中选择数据: - -``` sql -SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## 另请参阅 {#see-also} - -- [该 ‘MySQL’ 表引擎](../../engines/table_engines/integrations/mysql.md) -- [使用MySQL作为外部字典的来源](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-mysql) - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/mysql/) diff --git a/docs/zh/sql_reference/table_functions/numbers.md b/docs/zh/sql_reference/table_functions/numbers.md deleted file mode 100644 index aaee632d5dc..00000000000 --- a/docs/zh/sql_reference/table_functions/numbers.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 39 -toc_title: "\u6570\u5B57" ---- - -# 数字 {#numbers} - -`numbers(N)` – Returns a table with the single ‘number’ 包含从0到N-1的整数的列(UInt64)。 -`numbers(N, M)` -返回一个表与单 ‘number’ 包含从N到(N+M-1)的整数的列(UInt64)。 - -类似于 `system.numbers` 表,它可以用于测试和生成连续的值, `numbers(N, M)` 比 `system.numbers`. - -以下查询是等效的: - -``` sql -SELECT * FROM numbers(10); -SELECT * FROM numbers(0, 10); -SELECT * FROM system.numbers LIMIT 10; -``` - -例: - -``` sql --- Generate a sequence of dates from 2010-01-01 to 2010-12-31 -select toDate('2010-01-01') + number as d FROM numbers(365); -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/numbers/) diff --git a/docs/zh/sql_reference/table_functions/odbc.md b/docs/zh/sql_reference/table_functions/odbc.md deleted file mode 100644 index ad7503fd551..00000000000 --- a/docs/zh/sql_reference/table_functions/odbc.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 44 -toc_title: odbc ---- - -# odbc {#table-functions-odbc} - -返回通过连接的表 [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity). - -``` sql -odbc(connection_settings, external_database, external_table) -``` - -参数: - -- `connection_settings` — Name of the section with connection settings in the `odbc.ini` 文件 -- `external_database` — Name of a database in an external DBMS. -- `external_table` — Name of a table in the `external_database`. - -为了安全地实现ODBC连接,ClickHouse使用单独的程序 `clickhouse-odbc-bridge`. 如果直接从ODBC驱动程序加载 `clickhouse-server`,驱动程序问题可能会导致ClickHouse服务器崩溃。 ClickHouse自动启动 `clickhouse-odbc-bridge` 当它是必需的。 ODBC桥程序是从相同的软件包作为安装 `clickhouse-server`. - -与字段 `NULL` 外部表中的值将转换为基数据类型的默认值。 例如,如果远程MySQL表字段具有 `INT NULL` 键入它将转换为0(ClickHouse的默认值 `Int32` 数据类型)。 - -## 用法示例 {#usage-example} - -**通过ODBC从本地MySQL安装获取数据** - -此示例检查Ubuntu Linux18.04和MySQL服务器5.7。 - -确保安装了unixODBC和MySQL连接器。 - -默认情况下(如果从软件包安装),ClickHouse以用户身份启动 `clickhouse`. 因此,您需要在MySQL服务器中创建和配置此用户。 - -``` bash -$ sudo mysql -``` - -``` sql -mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse'; -mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION; -``` - -然后配置连接 `/etc/odbc.ini`. - -``` bash -$ cat /etc/odbc.ini -[mysqlconn] -DRIVER = /usr/local/lib/libmyodbc5w.so -SERVER = 127.0.0.1 -PORT = 3306 -DATABASE = test -USERNAME = clickhouse -PASSWORD = clickhouse -``` - -您可以使用 `isql` unixodbc安装中的实用程序。 - -``` bash -$ isql -v mysqlconn -+-------------------------+ -| Connected! | -| | -... -``` - -MySQL中的表: - -``` text -mysql> CREATE TABLE `test`.`test` ( - -> `int_id` INT NOT NULL AUTO_INCREMENT, - -> `int_nullable` INT NULL DEFAULT NULL, - -> `float` FLOAT NOT NULL, - -> `float_nullable` FLOAT NULL DEFAULT NULL, - -> PRIMARY KEY (`int_id`)); -Query OK, 0 rows affected (0,09 sec) - -mysql> insert into test (`int_id`, `float`) VALUES (1,2); -Query OK, 1 row affected (0,00 sec) - -mysql> select * from test; -+------+----------+-----+----------+ -| int_id | int_nullable | float | float_nullable | -+------+----------+-----+----------+ -| 1 | NULL | 2 | NULL | -+------+----------+-----+----------+ -1 row in set (0,00 sec) -``` - -从ClickHouse中的MySQL表中检索数据: - -``` sql -SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') -``` - -``` text -┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐ -│ 1 │ 0 │ 2 │ 0 │ -└────────┴──────────────┴───────┴────────────────┘ -``` - -## 另请参阅 {#see-also} - -- [ODBC外部字典](../../sql_reference/dictionaries/external_dictionaries/external_dicts_dict_sources.md#dicts-external_dicts_dict_sources-odbc) -- [ODBC表引擎](../../engines/table_engines/integrations/odbc.md). - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) diff --git a/docs/zh/sql_reference/table_functions/remote.md b/docs/zh/sql_reference/table_functions/remote.md deleted file mode 100644 index be6e9138fb4..00000000000 --- a/docs/zh/sql_reference/table_functions/remote.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 40 -toc_title: "\u8FDC\u7A0B" ---- - -# 远程,远程安全 {#remote-remotesecure} - -允许您访问远程服务器,而无需创建 `Distributed` 桌子 - -签名: - -``` sql -remote('addresses_expr', db, table[, 'user'[, 'password']]) -remote('addresses_expr', db.table[, 'user'[, 'password']]) -``` - -`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port`,或者只是 `host`. 主机可以指定为服务器名称,也可以指定为IPv4或IPv6地址。 IPv6地址在方括号中指定。 端口是远程服务器上的TCP端口。 如果省略端口,它使用 `tcp_port` 从服务器的配置文件(默认情况下,9000)。 - -!!! important "重要事项" - IPv6地址需要该端口。 - -例: - -``` text -example01-01-1 -example01-01-1:9000 -localhost -127.0.0.1 -[::]:9000 -[2a02:6b8:0:1111::11]:9000 -``` - -多个地址可以用逗号分隔。 在这种情况下,ClickHouse将使用分布式处理,因此它将将查询发送到所有指定的地址(如具有不同数据的分片)。 - -示例: - -``` text -example01-01-1,example01-02-1 -``` - -表达式的一部分可以用大括号指定。 前面的示例可以写成如下: - -``` text -example01-0{1,2}-1 -``` - -大括号可以包含由两个点(非负整数)分隔的数字范围。 在这种情况下,范围将扩展为生成分片地址的一组值。 如果第一个数字以零开头,则使用相同的零对齐形成值。 前面的示例可以写成如下: - -``` text -example01-{01..02}-1 -``` - -如果您有多对大括号,它会生成相应集合的直接乘积。 - -大括号中的地址和部分地址可以用管道符号(\|)分隔。 在这种情况下,相应的地址集被解释为副本,并且查询将被发送到第一个正常副本。 但是,副本将按照当前设置的顺序进行迭代 [load\_balancing](../../operations/settings/settings.md) 设置。 - -示例: - -``` text -example01-{01..02}-{1|2} -``` - -此示例指定两个分片,每个分片都有两个副本。 - -生成的地址数由常量限制。 现在这是1000个地址。 - -使用 `remote` 表函数比创建一个不太优化 `Distributed` 表,因为在这种情况下,服务器连接被重新建立为每个请求。 此外,如果设置了主机名,则会解析这些名称,并且在使用各种副本时不会计算错误。 在处理大量查询时,始终创建 `Distributed` 表的时间提前,不要使用 `remote` 表功能。 - -该 `remote` 表函数可以在以下情况下是有用的: - -- 访问特定服务器进行数据比较、调试和测试。 -- 查询之间的各种ClickHouse群集用于研究目的。 -- 手动发出的罕见分布式请求。 -- 每次重新定义服务器集的分布式请求。 - -如果未指定用户, `default` 被使用。 -如果未指定密码,则使用空密码。 - -`remoteSecure` -相同 `remote` but with secured connection. Default port — [tcp\_port\_secure](../../operations/server_configuration_parameters/settings.md#server_configuration_parameters-tcp_port_secure) 从配置或9440. - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/remote/) diff --git a/docs/zh/sql_reference/table_functions/url.md b/docs/zh/sql_reference/table_functions/url.md deleted file mode 100644 index d220bb05c2c..00000000000 --- a/docs/zh/sql_reference/table_functions/url.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 41 -toc_title: url ---- - -# url {#url} - -`url(URL, format, structure)` -返回从创建的表 `URL` 与给定 -`format` 和 `structure`. - -URL-HTTP或HTTPS服务器地址,它可以接受 `GET` 和/或 `POST` 请求。 - -格式 - [格式](../../interfaces/formats.md#formats) 的数据。 - -结构-表结构 `'UserID UInt64, Name String'` 格式。 确定列名称和类型。 - -**示例** - -``` sql --- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format. -SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3 -``` - -[原始文章](https://clickhouse.tech/docs/en/query_language/table_functions/url/) diff --git a/docs/zh/whats-new/changelog/2017.md b/docs/zh/whats-new/changelog/2017.md new file mode 100644 index 00000000000..de62730b093 --- /dev/null +++ b/docs/zh/whats-new/changelog/2017.md @@ -0,0 +1,268 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 79 +toc_title: '2017' +--- + +### ClickHouse释放1.1.54327,2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} + +此版本包含以前版本1.1.54318的错误修复: + +- 修复了可能导致数据丢失的复制中可能存在的争用条件的错误。 此问题影响版本1.1.54310和1.1.54318。 如果将其中一个版本用于复制的表,则强烈建议进行更新。 此问题显示在日志中的警告消息,如 `Part ... from own log doesn't exist.` 即使您在日志中没有看到这些消息,问题也是相关的。 + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54318-2017-11-30} + +此版本包含以前版本1.1.54310的错误修复: + +- 修复了SummingMergeTree引擎中合并过程中错误的行删除 +- 修复了未复制的MergeTree引擎中的内存泄漏 +- 修复了MergeTree引擎中频繁插入的性能下降 +- 修复了导致复制队列停止运行的问题 +- 固定服务器日志的轮换和归档 + +### ClickHouse释放1.1.54310,2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} + +#### 新功能: {#new-features} + +- MergeTree表引擎系列的自定义分区键。 +- [卡夫卡](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) 表引擎。 +- 增加了对加载的支持 [CatBoost](https://catboost.yandex/) 模型并将其应用到ClickHouse中存储的数据。 +- 增加了对UTC非整数偏移的时区的支持。 +- 增加了对具有时间间隔的算术运算的支持。 +- 日期和日期时间类型的值范围扩展到2105年。 +- 添加了 `CREATE MATERIALIZED VIEW x TO y` 查询(指定用于存储实例化视图数据的现有表)。 +- 添加了 `ATTACH TABLE` 不带参数的查询。 +- 将SummingMergeTree表中名称以-Map结尾的嵌套列的处理逻辑提取到sumMap聚合函数中。 现在,您可以显式指定此类列。 +- IP trie字典的最大大小增加到128M条目。 +- 添加了getSizeOfEnumType函数。 +- 添加了sumWithOverflow聚合函数。 +- 增加了对Cap'n Proto输入格式的支持。 +- 使用zstd算法时,您现在可以自定义压缩级别。 + +#### 向后不兼容的更改: {#backward-incompatible-changes} + +- 不允许使用内存以外的引擎创建临时表。 +- 不允许使用View或MaterializedView引擎显式创建表。 +- 在创建表期间,新检查将验证采样键表达式是否包含在主键中。 + +#### 错误修复: {#bug-fixes} + +- 修复了同步插入到分布式表中时的挂断问题。 +- 修复了复制表中部分的非原子添加和删除。 +- 插入到实例化视图中的数据不会遭受不必要的重复数据删除。 +- 对本地副本滞后且远程副本不可用的分布式表执行查询不会再导致错误。 +- 用户不需要访问权限 `default` 数据库创建临时表了。 +- 修复了在指定数组类型时不带参数的崩溃。 +- 修复了包含服务器日志的磁盘卷已满时的挂机问题。 +- 修复了unix时代的第一周toRelativeWeekNum函数的溢出。 + +#### 构建改进: {#build-improvements} + +- 几个第三方库(特别是Poco)被更新并转换为git子模块。 + +### ClickHouse释放1.1.54304,2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} + +#### 新功能: {#new-features-1} + +- 本机协议中的TLS支持(要启用,请设置 `tcp_ssl_port` 在 `config.xml` ). + +#### 错误修复: {#bug-fixes-1} + +- `ALTER` 对于复制的表现在尝试尽快开始运行。 +- 使用设置读取数据时修复崩溃 `preferred_block_size_bytes=0.` +- 固定的崩溃 `clickhouse-client` 按下时 `Page Down` +- 正确解释某些复杂的查询 `GLOBAL IN` 和 `UNION ALL` +- `FREEZE PARTITION` 现在总是以原子方式工作。 +- 空POST请求现在返回代码411的响应。 +- 修正了像表达式的解释错误 `CAST(1 AS Nullable(UInt8)).` +- 修正了读取时的错误 `Array(Nullable(String))` 从列 `MergeTree` 桌子 +- 修正了解析查询时崩溃,如 `SELECT dummy AS dummy, dummy AS b` +- 用户正确更新无效 `users.xml` +- 可执行字典返回非零响应代码时的正确处理。 + +### ClickHouse释放1.1.54292,2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} + +#### 新功能: {#new-features-2} + +- 添加了 `pointInPolygon` 用于处理坐标平面上的坐标的函数。 +- 添加了 `sumMap` 用于计算数组总和的聚合函数,类似于 `SummingMergeTree`. +- 添加了 `trunc` 功能。 改进舍入函数的性能 (`round`, `floor`, `ceil`, `roundToExp2`)并corrected正了他们如何工作的逻辑。 改变的逻辑 `roundToExp2` 分数和负数的功能。 +- ClickHouse可执行文件现在对libc版本的依赖性较低。 同样的ClickHouse可执行文件可以在各种各样的Linux系统上运行。 使用编译的查询(使用设置)时仍然存在依赖关系 `compile = 1` ,默认情况下不使用)。 +- 减少了动态编译查询所需的时间。 + +#### 错误修复: {#bug-fixes-2} + +- 修正了有时产生的错误 `part ... intersects previous part` 消息和副本的一致性减弱。 +- 修正了一个错误,导致服务器锁定,如果ZooKeeper在关闭过程中不可用。 +- 恢复副本时删除了过多的日志记录。 +- 修复了UNION ALL实现中的错误。 +- 修复了在块中的第一列具有数组类型时发生的concat函数中的错误。 +- 进度现在在系统中正确显示。合并表。 + +### ClickHouse释放1.1.54289,2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} + +#### 新功能: {#new-features-3} + +- `SYSTEM` 服务器管理查询: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. +- 添加了用于处理数组的函数: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. +- 已添加 `root` 和 `identity` ZooKeeper配置的参数。 这允许您隔离同一个ZooKeeper集群上的单个用户。 +- 添加聚合函数 `groupBitAnd`, `groupBitOr`,和 `groupBitXor` (为了兼容,它们也可以在名称下使用 `BIT_AND`, `BIT_OR`,和 `BIT_XOR`). +- 通过在文件系统中指定套接字,可以从MySQL加载外部字典。 +- 外部字典可以通过SSL从MySQL加载 (`ssl_cert`, `ssl_key`, `ssl_ca` 参数)。 +- 添加了 `max_network_bandwidth_for_user` 设置为限制每个用户查询的总带宽使用。 +- 支持 `DROP TABLE` 对于临时表。 +- 支持阅读 `DateTime` 从Unix时间戳格式的值 `CSV` 和 `JSONEachRow` 格式。 +- 分布式查询中的滞后副本现在默认排除(默认阈值为5分钟)。 +- 在ALTER期间使用FIFO锁定:对于连续运行的查询,ALTER查询不会无限期地阻止。 +- 选项设置 `umask` 在配置文件中。 +- 改进了查询的性能 `DISTINCT` . + +#### 错误修复: {#bug-fixes-3} + +- 改进了在ZooKeeper中删除旧节点的过程。 以前,如果插入非常频繁,旧节点有时不会被删除,这导致服务器关闭速度缓慢等等。 +- 修正了选择主机连接到ZooKeeper时的随机化。 +- 修复了在分布式查询中排除滞后副本,如果副本是localhost。 +- 修正了一个错误,其中在一个数据部分 `ReplicatedMergeTree` 运行后表可能会被打破 `ALTER MODIFY` 在一个元素 `Nested` 结构。 +- 修复了可能导致SELECT查询执行以下操作的错误 “hang”. +- 对分布式DDL查询的改进。 +- 修正了查询 `CREATE TABLE ... AS `. +- 解决了在僵局 `ALTER ... CLEAR COLUMN IN PARTITION` 查询为 `Buffer` 桌子 +- 修正了无效的默认值 `Enum` s(0,而不是最小)使用时 `JSONEachRow` 和 `TSKV` 格式。 +- 解决了使用字典时僵尸进程的外观 `executable` 资料来源。 +- 修正了HEAD查询的段错误。 + +#### 改进开发和组装ClickHouse的工作流程: {#improved-workflow-for-developing-and-assembling-clickhouse} + +- 您可以使用 `pbuilder` 建造克里克豪斯 +- 您可以使用 `libc++` 而不是 `libstdc++` 对于构建在Linux上。 +- 添加了使用静态代码分析工具的说明: `Coverage`, `clang-tidy`, `cppcheck`. + +#### 升级时请注意: {#please-note-when-upgrading} + +- MergeTree设置现在有一个更高的默认值 `max_bytes_to_merge_at_max_space_in_pool` (要合并的数据部分的最大总大小,以字节为单位):它已从100GiB增加到150GiB。 这可能会导致服务器升级后运行大型合并,这可能会导致磁盘子系统的负载增加。 如果服务器上的可用空间小于正在运行的合并总量的两倍,这将导致所有其他合并停止运行,包括小数据部分的合并。 因此,插入查询将失败,并显示消息 “Merges are processing significantly slower than inserts.” 使用 `SELECT * FROM system.merges` 查询监控情况。 您还可以检查 `DiskSpaceReservedForMerge` 度量在 `system.metrics` 表,或石墨。 你不需要做任何事情来解决这个问题,因为一旦大合并完成,问题就会自行解决。 如果您发现这是不可接受的,则可以恢复以前的值 `max_bytes_to_merge_at_max_space_in_pool` 设置。 要做到这一点,请转到 `` 在配置部分。xml,设置 ``` ``107374182400 ``` 并重新启动服务器。 + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54284-2017-08-29} + +- 这是一个错误修正版本,以前的1.1.54282版本。 它修复了ZooKeeper中部件目录中的泄漏。 + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54282-2017-08-23} + +此版本包含以前版本1.1.54276的错误修复: + +- 固定 `DB::Exception: Assertion violation: !_path.empty()` 当插入到分布式表中。 +- 如果输入数据以";"开头,则以RowBinary格式插入时修复了解析。 +- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54276-2017-08-16} + +#### 新功能: {#new-features-4} + +- 为选择查询添加了一个可选的WITH部分。 查询示例: `WITH 1+1 AS a SELECT a, a*a` +- INSERT可以在分布式表中同步执行:仅在所有分片上保存所有数据后才返回OK。 这是由设置insert\_distributed\_sync=1激活的。 +- 添加了用于处理16字节标识符的UUID数据类型。 +- 添加了CHAR,FLOAT和其他类型的别名,以便与Tableau兼容。 +- 添加了toyyyymm,toYYYYMMDD和toyyyyymmddhhmmss将时间转换为数字的功能。 +- 您可以使用IP地址(与主机名一起使用)来标识群集DDL查询的服务器。 +- 增加了对函数中非常量参数和负偏移的支持 `substring(str, pos, len).` +- 添加了max\_size参数 `groupArray(max_size)(column)` 聚合函数,并优化了其性能。 + +#### 主要变化: {#main-changes} + +- 安全性改进:所有服务器文件都使用0640权限创建(可以通过更改 `` 配置参数)。 +- 改进了语法无效的查询的错误消息。 +- 在合并mergetree大部分数据时,显着降低了内存消耗并提高了性能。 +- 显着提高了ReplacingMergeTree引擎的数据合并性能。 +- 通过组合多个源插入来改进来自分布式表的异步插入的性能。 要启用此功能,请使用设置distributed\_directory\_monitor\_batch\_inserts=1。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-1} + +- 改变聚合状态的二进制格式 `groupArray(array_column)` 数组的函数。 + +#### 更改的完整列表: {#complete-list-of-changes} + +- 添加了 `output_format_json_quote_denormals` 设置,允许以JSON格式输出nan和inf值。 +- 从分布式表读取时优化流分配。 +- 如果值没有更改,可以在只读模式下配置设置。 +- 添加了检索MergeTree引擎的非整数颗粒的功能,以满足preferred\_block\_size\_bytes设置中指定的块大小的限制。 其目的是在处理来自具有大列的表的查询时减少RAM消耗并增加缓存局部性。 +- 高效使用包含如下表达式的索引 `toStartOfHour(x)` 对于像条件 `toStartOfHour(x) op сonstexpr.` +- 添加了MergeTree引擎的新设置(配置中的merge\_tree部分。xml): + - replicated\_deduplication\_window\_seconds设置复制表中重复数据删除插入所允许的秒数。 + - cleanup\_delay\_period设置启动清理以删除过时数据的频率。 + - replicated\_can\_become\_leader可以防止副本成为领导者(并分配合并)。 +- 加速清理,从ZooKeeper中删除过时的数据。 +- 针对群集DDL查询的多个改进和修复。 特别令人感兴趣的是新设置distributed\_ddl\_task\_timeout,它限制了等待群集中服务器响应的时间。 如果未在所有主机上执行ddl请求,则响应将包含超时错误,并且请求将以异步模式执行。 +- 改进了服务器日志中堆栈跟踪的显示。 +- 添加了 “none” 压缩方法的值。 +- 您可以在config中使用多个dictionaries\_config部分。xml +- 可以通过文件系统中的套接字连接到MySQL。 +- 系统。部件表有一个新的列,其中包含有关标记大小的信息,以字节为单位。 + +#### 错误修复: {#bug-fixes-4} + +- 使用合并表的分布式表现在可以正确地用于具有条件的SELECT查询 `_table` 场。 +- 修复了检查数据部分时ReplicatedMergeTree中罕见的争用条件。 +- 固定可能冻结 “leader election” 启动服务器时。 +- 使用数据源的本地副本时,将忽略max\_replica\_delay\_for\_distributed\_queries设置。 这已被修复。 +- 修正了不正确的行为 `ALTER TABLE CLEAR COLUMN IN PARTITION` 尝试清除不存在的列时。 +- 修复了multif函数中使用空数组或字符串时的异常。 +- 修正了反序列化本机格式时过多的内存分配。 +- 修正了Trie字典的不正确的自动更新。 +- 修复了使用SAMPLE从合并表中使用GROUP BY子句运行查询时的异常。 +- 修复了使用distributed\_aggregation\_memory\_efficient=1时组的崩溃。 +- 现在,您可以指定数据库。表在右侧的IN和JOIN。 +- 用于并行聚合的线程太多。 这已被修复。 +- 固定如何 “if” 函数与FixedString参数一起使用。 +- 为权重为0的分片从分布式表中选择工作不正确。 这已被修复。 +- 运行 `CREATE VIEW IF EXISTS no longer causes crashes.` +- 修正了input\_format\_skip\_unknown\_fields=1设置并且有负数时的不正确行为。 +- 修正了一个无限循环 `dictGetHierarchy()` 如果字典中有一些无效的数据,则函数。 +- 固定 `Syntax error: unexpected (...)` 在IN或JOIN子句和合并表中使用子查询运行分布式查询时出错。 +- 修复了从字典表中选择查询的不正确解释。 +- 修正了 “Cannot mremap” 在IN和JOIN子句中使用包含超过20亿个元素的数组时出错。 +- 修复了以MySQL为源的字典的故障转移。 + +#### 改进开发和组装ClickHouse的工作流程: {#improved-workflow-for-developing-and-assembling-clickhouse-1} + +- 构建可以在阿卡迪亚组装。 +- 您可以使用gcc7来编译ClickHouse。 +- 现在使用ccache+distcc的并行构建速度更快。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54245-2017-07-04} + +#### 新功能: {#new-features-5} + +- 分布式的DDL(例如, `CREATE TABLE ON CLUSTER`) +- 复制的查询 `ALTER TABLE CLEAR COLUMN IN PARTITION.` +- 字典表的引擎(以表格形式访问字典数据)。 +- 字典数据库引擎(这种类型的数据库会自动为所有连接的外部字典提供字典表)。 +- 您可以通过向源发送请求来检查字典的更新。 +- 限定列名称 +- 使用双引号引用标识符。 +- Http接口中的会话。 +- 复制表的优化查询不仅可以在leader上运行。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-2} + +- 删除设置全局。 + +#### 小的变化: {#minor-changes} + +- 现在,在触发警报之后,日志将打印完整的堆栈跟踪。 +- 在启动时放宽对损坏/额外数据部件数量的验证(有太多误报)。 + +#### 错误修复: {#bug-fixes-5} + +- 修复了连接错误 “sticking” 当插入到分布式表中。 +- GLOBAL IN现在适用于查看分布式表的合并表中的查询。 +- 在Google Compute Engine虚拟机上检测到不正确的内核数。 这已被修复。 +- 缓存外部字典的可执行源如何工作的更改。 +- 修复了包含空字符的字符串的比较。 +- 修正了Float32主键字段与常量的比较。 +- 以前,对字段大小的不正确估计可能导致分配过大。 +- 修复了使用ALTER查询添加到表中的可空列时的崩溃。 +- 修复了按可空列排序时的崩溃,如果行数小于限制。 +- 修复了仅由常量值组成的子查询的顺序。 +- 以前,复制的表在丢弃表失败后可能仍处于无效状态。 +- 具有空结果的标量子查询的别名不再丢失。 +- 现在如果.so文件被损坏,使用编译的查询不会失败并出现错误。 diff --git a/docs/zh/whats-new/changelog/2018.md b/docs/zh/whats-new/changelog/2018.md new file mode 100644 index 00000000000..f5f4502925a --- /dev/null +++ b/docs/zh/whats-new/changelog/2018.md @@ -0,0 +1,1063 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 78 +toc_title: '2018' +--- + +## ClickHouse释放18.16 {#clickhouse-release-18-16} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-16-1-2018-12-21} + +#### 错误修复: {#bug-fixes} + +- 修复了导致使用ODBC源更新字典时出现问题的错误。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- 聚集函数的JIT编译现在适用于低心率列。 [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) + +#### 改进: {#improvements} + +- 添加了 `low_cardinality_allow_in_native_format` 设置(默认情况下启用)。 如果禁用,则选择查询的LowCardinality列将转换为普通列,插入查询将需要普通列。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) + +#### 构建改进: {#build-improvements} + +- 修复了基于macOS和ARM的构建。 + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-16-0-2018-12-14} + +#### 新功能: {#new-features} + +- `DEFAULT` 在以半结构化输入格式加载数据时,会计算表达式是否缺少字段 (`JSONEachRow`, `TSKV`). 该功能与启用 `insert_sample_with_metadata` 设置。 [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) +- 该 `ALTER TABLE` 查询现在有 `MODIFY ORDER BY` 用于在添加或删除表列时更改排序键的操作。 这是在表有用 `MergeTree` 基于此排序键合并时执行其他任务的系列,例如 `SummingMergeTree`, `AggregatingMergeTree`,等等。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) +- 对于在表 `MergeTree` 家庭,现在你可以指定一个不同的排序键 (`ORDER BY`)和索引 (`PRIMARY KEY`). 排序键可以长于索引。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) +- 添加了 `hdfs` 表功能和 `HDFS` 用于将数据导入和导出到HDFS的表引擎。 [晨兴-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) +- 增加了使用base64的功能: `base64Encode`, `base64Decode`, `tryBase64Decode`. [Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3350) +- 现在,您可以使用一个参数来配置的精度 `uniqCombined` 聚合函数(选择HyperLogLog单元格的数量)。 [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) +- 添加了 `system.contributors` 包含在ClickHouse中进行提交的所有人的名称的表。 [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) +- 增加了省略分区的能力 `ALTER TABLE ... FREEZE` 查询以便一次备份所有分区。 [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) +- 已添加 `dictGet` 和 `dictGetOrDefault` 不需要指定返回值类型的函数。 该类型是从字典描述自动确定的。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3564) +- 现在,您可以在表描述中为列指定注释,并使用以下方式对其进行更改 `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) +- 阅读支持 `Join` 使用简单键键入表格。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3728) +- 现在,您可以指定选项 `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join`,和 `join_overflow_mode` 当创建一个 `Join` 键入表。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3728) +- 添加了 `joinGet` 功能,允许您使用 `Join` 像字典一样键入表格。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3728) +- 添加了 `partition_key`, `sorting_key`, `primary_key`,和 `sampling_key` 列到 `system.tables` 表以便提供关于表键的信息。 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- 添加了 `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key`,和 `is_in_sampling_key` 列到 `system.columns` 桌子 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) +- 添加了 `min_time` 和 `max_time` 列到 `system.parts` 桌子 当分区键是由以下表达式组成的表达式时,将填充这些列 `DateTime` 列。 [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) + +#### 错误修复: {#bug-fixes-1} + +- 修复和性能改进 `LowCardinality` 数据类型。 `GROUP BY` 使用 `LowCardinality(Nullable(...))`. 获取的值 `extremes`. 处理高阶函数。 `LEFT ARRAY JOIN`. 分布 `GROUP BY`. 返回的函数 `Array`. 执行 `ORDER BY`. 写入 `Distributed` 表(nicelulu)。 向后兼容 `INSERT` 从实现旧客户端的查询 `Native` 协议 支持 `LowCardinality` 为 `JOIN`. 在单个流中工作时提高性能。 [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) +- 固定如何 `select_sequential_consistency` 选项工作。 以前,启用此设置时,在开始写入新分区后,有时会返回不完整的结果。 [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) +- 执行DDL时正确指定数据库 `ON CLUSTER` 查询和 `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- 为视图中的子查询正确指定了数据库。 [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) +- 修正了一个错误 `PREWHERE` 与 `FINAL` 为 `VersionedCollapsingMergeTree`. [7167bfd7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) +- 现在你可以使用 `KILL QUERY` 取消尚未启动的查询,因为它们正在等待锁定表。 [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) +- 更正日期和时间计算,如果时钟被移回午夜(这发生在伊朗,并发生在莫斯科1981年至1983年)。 以前,这导致时间比必要的时间早一天重置,并且还导致文本格式的日期和时间格式不正确。 [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) +- 修正了某些情况下的错误 `VIEW` 和省略数据库的子查询。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3521) +- 修正了一个争用条件时,同时从读取 `MATERIALIZED VIEW` 和删除 `MATERIALIZED VIEW` 由于不锁定内部 `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) +- 修正了错误 `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) +- 固定查询处理时 `compile_expressions` 选项已启用(默认情况下启用)。 非确定性常量表达式,如 `now` 功能不再展开。 [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) +- 修复了在指定非常量比例参数时发生的崩溃 `toDecimal32/64/128` 功能。 +- 修复了尝试插入数组时的错误 `NULL` 中的元素 `Values` 格式化为类型的列 `Array` 没有 `Nullable` (如果 `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) +- 固定连续错误登录 `DDLWorker` 如果动物园管理员不可用。 [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) +- 修正了返回类型 `quantile*` 从功能 `Date` 和 `DateTime` 参数的类型。 [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) +- 修正了 `WITH` 子句,如果它指定了一个没有表达式的简单别名。 [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) +- 固定处理具有命名子查询和限定列名的查询时 `enable_optimize_predicate_expression` 被启用。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3588) +- 修正了错误 `Attempt to attach to nullptr thread group` 使用实例化视图时。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) +- 修正了传递某些不正确的参数时崩溃 `arrayReverse` 功能。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- 修正了缓冲区溢出 `extractURLParameter` 功能。 改进的性能。 添加了包含零字节的字符串的正确处理。 [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) +- 在固定缓冲区溢出 `lowerUTF8` 和 `upperUTF8` 功能。 删除了执行这些功能的能力 `FixedString` 类型参数。 [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) +- 修复了删除时罕见的竞争条件 `MergeTree` 桌子 [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) +- 修正了从读取时的争用条件 `Buffer` 表和同时执行 `ALTER` 或 `DROP` 在目标桌上。 [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) +- 修正了一个段错误,如果 `max_temporary_non_const_columns` 超过限制。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### 改进: {#improvements-1} + +- 服务器不会将处理后的配置文件写入 `/etc/clickhouse-server/` 目录。 相反,它将它们保存在 `preprocessed_configs` 里面的目录 `path`. 这意味着 `/etc/clickhouse-server/` 目录没有写访问权限 `clickhouse` 用户,从而提高了安全性。 [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) +- 该 `min_merge_bytes_to_use_direct_io` 默认情况下,选项设置为10GiB。 将在MergeTree系列中执行形成大部分表的合并 `O_DIRECT` 模式,这可以防止过多的页高速缓存逐出。 [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) +- 当表数量非常多时,加速服务器启动。 [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) +- 添加了连接池和HTTP `Keep-Alive` 用于副本之间的连接。 [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) +- 如果查询语法无效,则 `400 Bad Request` 代码在返回 `HTTP` 接口(500以前返回)。 [31bc680a](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) +- 该 `join_default_strictness` 选项设置为 `ALL` 默认情况下为兼容性。 [120e2cbe](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) +- 删除日志记录 `stderr` 从 `re2` 无效或复杂正则表达式的库。 [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) +- 添加的 `Kafka` 表引擎:在开始从Kafka读取之前检查订阅;表的kafka\_max\_block\_size设置。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) +- 该 `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32`,和 `murmurHash3_64` 函数现在适用于任意数量的参数和元组形式的参数。 [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) +- 该 `arrayReverse` 函数现在适用于任何类型的数组。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) +- 增加了一个可选参数:插槽大小的 `timeSlots` 功能。 [基里尔\*什瓦科夫](https://github.com/ClickHouse/ClickHouse/pull/3724) +- 为 `FULL` 和 `RIGHT JOIN`,该 `max_block_size` 设置用于右表中未连接的数据流。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3699) +- 添加了 `--secure` 命令行参数 `clickhouse-benchmark` 和 `clickhouse-performance-test` 启用TLS。 [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) +- 类型转换时的结构 `Buffer` 表的类型与目标表的结构不匹配。 [维塔利\*巴拉诺夫](https://github.com/ClickHouse/ClickHouse/pull/3603) +- 添加了 `tcp_keep_alive_timeout` 在指定的时间间隔内不活动后启用保持活动数据包的选项。 [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) +- 删除不必要的引用值的分区键中 `system.parts` 表,如果它由单列组成。 [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) +- 模函数适用于 `Date` 和 `DateTime` 数据类型。 [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) +- 添加同义词的 `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR`,和 `MID` 功能。 [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) 为了与SQL标准兼容,某些函数名称不区分大小写。 添加语法糖 `SUBSTRING(expr FROM start FOR length)` 对于与SQL的兼容性。 [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) +- 增加了以下能力 `mlock` 对应于存储器页 `clickhouse-server` 可执行代码,以防止它被强制出内存。 默认情况下禁用此功能。 [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) +- 从读取时改进的性能 `O_DIRECT` (与 `min_bytes_to_use_direct_io` 选项启用)。 [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) +- 的改进的性能 `dictGet...OrDefault` 常量键参数和非常量默认参数的函数。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3563) +- 该 `firstSignificantSubdomain` 功能现在处理域 `gov`, `mil`,和 `edu`. [Igor Hatarist](https://github.com/ClickHouse/ClickHouse/pull/3601) 改进的性能。 [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) +- 能够指定用于启动的自定义环境变量 `clickhouse-server` 使用 `SYS-V init.d` 通过定义脚本 `CLICKHOUSE_PROGRAM_ENV` 在 `/etc/default/clickhouse`. + [Pavlo Bashynskyi](https://github.com/ClickHouse/ClickHouse/pull/3612) +- Clickhouse-server init脚本的正确返回代码。 [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) +- 该 `system.metrics` 表现在有 `VersionInteger` 公制和 `system.build_options` 有添加的行 `VERSION_INTEGER`,其中包含ClickHouse版本的数字形式,例如 `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) +- 删除比较的能力 `Date` 输入一个数字,以避免潜在的错误,如 `date = 2018-12-17`,其中日期周围的引号被错误省略。 [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) +- 修正了有状态函数的行为,如 `rowNumberInAllBlocks`. 他们之前输出的结果是由于在查询分析期间启动而大一个数字。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3729) +- 如果 `force_restore_data` 文件无法删除,将显示错误消息。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3794) + +#### 构建改进: {#build-improvements-1} + +- 更新了 `jemalloc` 库,它修复了潜在的内存泄漏。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3557) +- 分析与 `jemalloc` 默认情况下为了调试生成启用。 [2cc82f5c](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) +- 增加了运行集成测试的能力,当只 `Docker` 安装在系统上。 [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) +- 在SELECT查询中添加了模糊表达式测试。 [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) +- 为提交添加了一个压力测试,它以并行和随机顺序执行功能测试,以检测更多的竞争条件。 [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) +- 改进了在Docker映像中启动clickhouse-server的方法。 [Elghazal Ahmed](https://github.com/ClickHouse/ClickHouse/pull/3663) +- 对于Docker映像,增加了对使用数据库中的文件初始化数据库的支持 `/docker-entrypoint-initdb.d` 目录。 [康斯坦丁\*列别杰夫](https://github.com/ClickHouse/ClickHouse/pull/3695) +- 修复了基于ARM的构建。 [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) + +#### 向后不兼容的更改: {#backward-incompatible-changes} + +- 删除比较的能力 `Date` 用数字键入。 而不是 `toDate('2018-12-18') = 17883`,必须使用显式类型转换 `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) + +## ClickHouse释放18.14 {#clickhouse-release-18-14} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-14-19-2018-12-19} + +#### 错误修复: {#bug-fixes-2} + +- 修复了导致使用ODBC源更新字典时出现问题的错误。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) +- 执行DDL时正确指定数据库 `ON CLUSTER` 查询。 [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) +- 修正了一个段错误,如果 `max_temporary_non_const_columns` 超过限制。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) + +#### 构建改进: {#build-improvements-2} + +- 修复了基于ARM的构建。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-18-2018-12-04} + +#### 错误修复: {#bug-fixes-3} + +- 修正错误 `dictGet...` 类型字典的函数 `range`,如果其中一个参数是恒定的,而另一个则不是。 [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) +- 修复了导致消息的错误 `netlink: '...': attribute type 1 has an invalid length` 要打印在Linux内核日志中,这只发生在足够新鲜的Linux内核版本上。 [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) +- 在功能固定段错误 `empty` 对于争论 `FixedString` 类型。 [丹尼尔,道广明](https://github.com/ClickHouse/ClickHouse/pull/3703) +- 修正了使用大值时过多的内存分配 `max_query_size` 设置(内存块 `max_query_size` 字节被预先分配一次)。 [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) + +#### 构建更改: {#build-changes} + +- 使用操作系统包中的版本7的LLVM/Clang库修复构建(这些库用于运行时查询编译)。 [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-17-2018-11-30} + +#### 错误修复: {#bug-fixes-4} + +- 修复了ODBC桥进程未与主服务器进程终止的情况。 [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) +- 固定同步插入 `Distributed` 具有不同于远程表的列列表的列列表的表。 [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) +- 修复了丢弃MergeTree表时可能导致崩溃的罕见竞争条件。 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- 修复了查询线程创建失败时的查询死锁 `Resource temporarily unavailable` 错误 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) +- 修正了解析 `ENGINE` 条款时 `CREATE AS table` 语法被使用和 `ENGINE` 子句之前指定 `AS table` (错误导致忽略指定的引擎)。 [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-15-2018-11-21} + +#### 错误修复: {#bug-fixes-5} + +- 反序列化类型的列时,高估了内存块的大小 `Array(String)` 这导致 “Memory limit exceeded” 错误。 该问题出现在版本18.12.13中。 [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-14-2018-11-20} + +#### 错误修复: {#bug-fixes-6} + +- 固定 `ON CLUSTER` 当群集配置为安全时进行查询(标志 ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) + +#### 构建更改: {#build-changes-1} + +- 固定的问题(llvm-7从系统,macos) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-13-2018-11-08} + +#### 错误修复: {#bug-fixes-7} + +- 修正了 `Block structure mismatch in MergingSorted stream` 错误 [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) +- 固定 `ON CLUSTER` 查询的情况下,当安全连接被打开的群集配置( `` 标志)。 [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) +- 修复了查询中使用的错误 `SAMPLE`, `PREWHERE` 和别名列。 [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) +- 修正了一个罕见的 `unknown compression method` 错误时 `min_bytes_to_use_direct_io` 设置已启用。 [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) + +#### 性能改进: {#performance-improvements} + +- 查询的固定性能回归 `GROUP BY` 在AMD EPYC处理器上执行时,uint16或Date类型的列。 [Igor Lapko](https://github.com/ClickHouse/ClickHouse/pull/3512) +- 修正了处理长字符串的查询的性能回归。 [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) + +#### 构建改进: {#build-improvements-3} + +- 简化阿卡迪亚构建的改进。 [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-12-2018-11-02} + +#### 错误修复: {#bug-fixes-8} + +- 修复了加入两个未命名的子查询时的崩溃。 [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) +- 修正了生成不正确的查询(用空 `WHERE` 子句)查询外部数据库时。 [hotid](https://github.com/ClickHouse/ClickHouse/pull/3477) +- 修正了在ODBC字典中使用不正确的超时值。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-11-2018-10-29} + +#### 错误修复: {#bug-fixes-9} + +- 修正了错误 `Block structure mismatch in UNION stream: different number of columns` 在限制查询。 [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) +- 修复了在嵌套结构中包含数组的表中合并数据时出现的错误。 [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) +- 修正了不正确的查询结果,如果 `merge_tree_uniform_read_distribution` 设置被禁用(默认情况下启用)。 [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) +- 修复了在本机格式的分布式表中插入错误。 [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-10-2018-10-23} + +- 该 `compile_expressions` 默认情况下禁用设置(表达式的JIT编译)。 [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) +- 该 `enable_optimize_predicate_expression` 默认情况下禁用设置。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-9-2018-10-16} + +#### 新功能: {#new-features-1} + +- 该 `WITH CUBE` 修饰符 `GROUP BY` (替代语法 `GROUP BY CUBE(...)` 也可用)。 [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) +- 添加了 `formatDateTime` 功能。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2770) +- 添加了 `JDBC` 表引擎和 `jdbc` 表功能(需要安装clickhouse-jdbc桥)。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) +- 增加了使用ISO周编号的功能: `toISOWeek`, `toISOYear`, `toStartOfISOYear`,和 `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) +- 现在你可以使用 `Nullable` 列 `MySQL` 和 `ODBC` 桌子 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- 嵌套的数据结构可以被读取为嵌套的对象 `JSONEachRow` 格式。 添加了 `input_format_import_nested_json` 设置。 [维罗曼\*云坎](https://github.com/ClickHouse/ClickHouse/pull/3144) +- 并行处理可用于许多 `MATERIALIZED VIEW`s插入数据时。 见 `parallel_view_processing` 设置。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) +- 添加了 `SYSTEM FLUSH LOGS` 查询(强制日志刷新到系统表,如 `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) +- 现在,您可以使用预定义 `database` 和 `table` 声明时的宏 `Replicated` 桌子 [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) +- 增加了阅读的能力 `Decimal` 工程表示法中的类型值(表示十的幂)。 [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) + +#### 实验特点: {#experimental-features} + +- 对GROUP BY子句进行优化 `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) +- 表达式的优化计算 `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) + +#### 改进: {#improvements-2} + +- 显着减少查询的内存消耗 `ORDER BY` 和 `LIMIT`. 见 `max_bytes_before_remerge_sort` 设置。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- 在没有 `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` 是假定的。 [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) +- 限定星号在以下查询中正常工作 `JOIN`. [张冬](https://github.com/ClickHouse/ClickHouse/pull/3202) +- 该 `ODBC` 表引擎正确地选择用于引用远程数据库的SQL方言中的标识符的方法。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) +- 该 `compile_expressions` 默认情况下启用设置(表达式的JIT编译)。 +- 修复了同时删除数据库/表(如果存在)和创建数据库/表(如果不存在)的行为。 前情提要 `CREATE DATABASE ... IF NOT EXISTS` 查询可能会返回错误消息 “File … already exists” 和 `CREATE TABLE ... IF NOT EXISTS` 和 `DROP TABLE IF EXISTS` 查询可能会返回 `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) +- 当从MySQL或ODBC表中查询时,LIKE和IN表达式具有常量右半部分被传递到远程服务器。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- 当从MySQL和ODBC表查询时,与WHERE子句中常量表达式的比较会传递给远程服务器。 以前,只通过与常量的比较。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) +- 正确计算终端中的行宽 `Pretty` 格式,包括带有象形文字的字符串。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3257). +- `ON CLUSTER` 可以指定 `ALTER UPDATE` 查询。 +- 提高了读取数据的性能 `JSONEachRow` 格式。 [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) +- 添加同义词的 `LENGTH` 和 `CHARACTER_LENGTH` 功能的兼容性。 该 `CONCAT` 函数不再区分大小写。 [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) +- 添加了 `TIMESTAMP` 的同义词 `DateTime` 类型。 [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) +- 服务器日志中始终为query\_id保留空间,即使日志行与查询无关。 这使得使用第三方工具更容易分析服务器文本日志。 +- 当查询超过整数千兆字节的下一级别时,会记录查询的内存消耗。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) +- 为使用本机协议的客户端库错误发送的列少于服务器预期的插入查询时的情况添加了兼容模式。 使用clickhouse-cpp库时,这种情况是可能的。 以前,此方案会导致服务器崩溃。 [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) +- 在用户定义的WHERE表达式中 `clickhouse-copier`,您现在可以使用 `partition_key` 别名(用于按源表分区进行其他过滤)。 如果分区方案在复制过程中发生更改,但仅稍有更改,这很有用。 [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) +- 的工作流程 `Kafka` 引擎已被移动到后台线程池中,以便在高负载下自动降低数据读取速度。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- 支持阅读 `Tuple` 和 `Nested` 结构的值,如 `struct` 在 `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) +- 顶级域名列表 `firstSignificantSubdomain` 功能现在包括域 `biz`. [decaseal](https://github.com/ClickHouse/ClickHouse/pull/3219) +- 在外部字典的配置, `null_value` 被解释为默认数据类型的值。 [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) +- 支持 `intDiv` 和 `intDivOrZero` 功能 `Decimal`. [b48402e8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) +- 支持 `Date`, `DateTime`, `UUID`,和 `Decimal` 类型作为键 `sumMap` 聚合函数。 [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) +- 支持 `Decimal` 外部字典中的数据类型。 [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) +- 支持 `Decimal` 数据类型in `SummingMergeTree` 桌子 [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) +- 增加了专业化 `UUID` 在 `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) +- 减少的数量 `open` 和 `close` 从读取时系统调用 `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) +- A `TRUNCATE TABLE` 查询可以在任何副本上执行(将查询传递给领导副本)。 [基里尔\*什瓦科夫](https://github.com/ClickHouse/ClickHouse/pull/3375) + +#### 错误修复: {#bug-fixes-10} + +- 修正了一个问题 `Dictionary` 表 `range_hashed` 字典 此错误发生在版本18.12.17中。 [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) +- 修正了加载时的错误 `range_hashed` 字典(消息 `Unsupported type Nullable (...)`). 此错误发生在版本18.12.17中。 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) +- 在固定的错误 `pointInPolygon` 函数由于不准确的计算的多边形与大量的顶点位于彼此靠近的积累。 [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) +- 如果在合并数据部分之后,结果部分的校验和与另一个副本中相同合并的结果不同,则删除合并的结果并从另一个副本下载数据部分(这是正确的行为)。 但是在下载数据部分之后,由于该部分已经存在的错误(因为合并后数据部分被删除了一些延迟),因此无法将其添加到工作集中。 这导致周期性尝试下载相同的数据。 [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) +- 修正了查询总内存消耗的不正确计算(由于计算不正确, `max_memory_usage_for_all_queries` 设置工作不正确, `MemoryTracking` 度量值不正确)。 此错误发生在版本18.12.13中。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) +- 修正的功能 `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` 此错误发生在版本18.12.13中。 [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) +- 修正了数据结构的不必要的准备 `JOIN`如果发起查询的服务器上 `JOIN` 仅在远程服务器上执行。 [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) +- 在固定的错误 `Kafka` 引擎:开始读取数据时异常后的死锁,并在完成时锁定 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). +- 为 `Kafka` 表,可选 `schema` 参数未被传递(的架构 `Cap'n'Proto` 格式)。 [Vojtech Splichal](https://github.com/ClickHouse/ClickHouse/pull/3150) +- 如果ZooKeeper服务器的整体服务器接受连接,但随后立即关闭它,而不是响应握手,ClickHouse选择连接另一台服务器。 以前,这会产生错误 `Cannot read all data. Bytes read: 0. Bytes expected: 4.` 服务器无法启动。 [8218cf3a](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) +- 如果ZooKeeper服务器的整体包含DNS查询返回错误的服务器,则忽略这些服务器。 [17b8e209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) +- 固定类型之间的转换 `Date` 和 `DateTime` 当在插入数据 `VALUES` 格式(如果 `input_format_values_interpret_expressions = 1`). 以前,转换是在Unix Epoch时间中的天数和Unix时间戳的数值之间进行的,这会导致意外的结果。 [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) +- 修正类型之间的转换 `Decimal` 和整数。 [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) +- 在固定的错误 `enable_optimize_predicate_expression` 设置。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3231) +- 如果使用非默认的CSV分隔符,则修复了CSV格式的浮点数解析错误,例如 `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) +- 修正了 `arrayCumSumNonNegative` 函数(它不累加负值,如果累加器小于零)。 [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/3163) +- 固定如何 `Merge` 表工作的顶部 `Distributed` 使用时的表 `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) +- 在错误修复 `ALTER UPDATE` 查询。 +- 在固定的错误 `odbc` 表功能,出现在版本18.12。 [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) +- 修正了聚合函数的操作 `StateArray` 组合子 [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) +- 修正了划分时崩溃 `Decimal` 值为零。 [69dd6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) +- 使用固定输出类型的操作 `Decimal` 和整数参数。 [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) +- 修正了在段错误 `GROUP BY` 上 `Decimal128`. [3359ba06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) +- 该 `log_query_threads` 设置(关于查询执行的每个线程的日志记录信息)现在生效,只有当 `log_queries` 选项(有关查询的日志记录信息)设置为1。 由于 `log_query_threads` 默认情况下,即使禁用了查询日志记录,也会先前记录有关线程的信息。 [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) +- 修正了分位数聚合函数的分布式操作中的错误(错误消息 `Not found column quantile...`). [292a8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) +- 修复了同时在18.12.17版服务器和旧服务器的集群上工作时的兼容性问题。 对于具有固定和非固定长度的GROUP BY键的分布式查询,如果要聚合大量数据,则返回的数据并不总是完全聚合(两个不同的行包含相同的聚合键)。 [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) +- 固定处理替换 `clickhouse-performance-test`,如果查询只包含测试中声明的替换的一部分。 [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) +- 修复了使用时的错误 `FINAL` 与 `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- 修复了使用时的错误 `PREWHERE` 在过程中添加的列 `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) +- 增加了一个检查没有 `arrayJoin` 为 `DEFAULT` 和 `MATERIALIZED` 表达式。 前情提要, `arrayJoin` 插入数据时导致错误。 [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) +- 增加了一个检查没有 `arrayJoin` 在一个 `PREWHERE` 条款 以前,这导致了类似的消息 `Size ... doesn't match` 或 `Unknown compression method` 执行查询时。 [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) +- 修复了优化后可能发生的极少数情况下的段错误,并将相等性评估与相应的IN表达式链接起来。 [刘一民-字节舞](https://github.com/ClickHouse/ClickHouse/pull/3339) +- 小幅更正 `clickhouse-benchmark`:以前,客户端信息没有发送到服务器;现在关闭时更准确地计算执行的查询数量,并限制迭代次数。 [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) + +#### 向后不兼容的更改: {#backward-incompatible-changes-1} + +- 删除了 `allow_experimental_decimal_type` 选项。 该 `Decimal` 数据类型可供默认使用。 [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) + +## ClickHouse释放18.12 {#clickhouse-release-18-12} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-12-17-2018-09-16} + +#### 新功能: {#new-features-2} + +- `invalidate_query` (指定查询来检查是否需要更新外部字典的能力)实现了 `clickhouse` 资料来源。 [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) +- 增加了使用的能力 `UInt*`, `Int*`,和 `DateTime` 数据类型(与 `Date` 类型)作为 `range_hashed` 定义范围边界的外部字典键。 现在 `NULL` 可用于指定开放范围。 [瓦西里\*内姆科夫](https://github.com/ClickHouse/ClickHouse/pull/3123) +- 该 `Decimal` 类型现在支持 `var*` 和 `stddev*` 聚合函数。 [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- 该 `Decimal` 类型现在支持数学函数 (`exp`, `sin` 等等。) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) +- 该 `system.part_log` 表现在有 `partition_id` 列。 [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### 错误修复: {#bug-fixes-11} + +- `Merge` 现在正常工作 `Distributed` 桌子 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3159) +- 修复了不兼容(不必要的依赖 `glibc` 版本),这使得它不可能运行ClickHouse的 `Ubuntu Precise` 和旧版本。 在版本18.12.13中出现了不兼容。 [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) +- 在固定的错误 `enable_optimize_predicate_expression` 设置。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3107) +- 修复了在早于18.12.13的版本上使用副本集群并同时在具有较新版本的服务器上创建表的新副本时出现的向后兼容性的一个小问题(如消息中所示 `Can not clone replica, because the ... updated to new ClickHouse version`,这是合乎逻辑的,但不应该发生)。 [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) + +#### 向后不兼容的更改: {#backward-incompatible-changes-2} + +- 该 `enable_optimize_predicate_expression` 默认情况下启用选项(这是相当乐观的)。 如果发生与搜索列名相关的查询分析错误,请设置 `enable_optimize_predicate_expression` 为0。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3107) + +### 碌莽禄,拢,0755-88888888 {#clickhouse-release-18-12-14-2018-09-13} + +#### 新功能: {#new-features-3} + +- 增加了对 `ALTER UPDATE` 查询。 [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) +- 添加了 `allow_ddl` 选项,它限制用户对DDL查询的访问。 [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) +- 添加了 `min_merge_bytes_to_use_direct_io` 备选案文 `MergeTree` 引擎允许您为合并的总大小设置阈值(当超过阈值时,将使用O\_DIRECT处理数据部分文件)。 [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) +- 该 `system.merges` 系统表现在包含 `partition_id` 列。 [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) + +#### 改进 {#improvements-3} + +- 如果数据部分在变异期间保持不变,则副本不会下载该数据部分。 [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) +- 使用时,自动完成可用于设置名称 `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) + +#### 错误修复: {#bug-fixes-12} + +- 添加了一个检查是元素的数组的大小 `Nested` 插入时的类型字段。 [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) +- 修正了一个错误更新外部字典与 `ODBC` 来源和 `hashed` 存储。 此错误发生在版本18.12.13中。 +- 修复了使用以下命令从查询创建临时表时出现的崩溃 `IN` 条件。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3098) +- 修复了聚合函数中可能具有的数组的错误 `NULL` 元素。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3097) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-12-13-2018-09-10} + +#### 新功能: {#new-features-4} + +- 添加了 `DECIMAL(digits, scale)` 数据类型 (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). 要启用它,请使用以下设置 `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) +- 新 `WITH ROLLUP` 修饰符 `GROUP BY` (替代语法: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) +- 在具有JOIN的查询中,星形字符将扩展为符合SQL标准的所有表中的列列表。 您可以通过设置恢复旧行为 `asterisk_left_columns_only` 在用户配置级别上为1。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2787) +- 增加了对连接表函数的支持。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2907) +- 在clickhouse-client中按Tab键进行自动完成。 [谢尔盖\*谢尔宾](https://github.com/ClickHouse/ClickHouse/pull/2447) +- Clickhouse-client中的Ctrl+C清除输入的查询。 [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) +- 添加了 `join_default_strictness` 设置(值: `"`, `'any'`, `'all'`). 这允许您不指定 `ANY` 或 `ALL` 为 `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) +- 与查询处理相关的服务器日志的每一行都显示了查询ID。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 现在,您可以在clickhouse-client中获取查询执行日志(使用 `send_logs_level` 设置)。 通过分布式查询处理,日志从所有服务器级联。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 该 `system.query_log` 和 `system.processes` (`SHOW PROCESSLIST`)表现在有关所有更改的设置信息,当你运行一个查询(的嵌套结构 `Settings` 数据)。 添加了 `log_query_settings` 设置。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 该 `system.query_log` 和 `system.processes` 表现在显示有关参与查询执行的线程数的信息(请参阅 `thread_numbers` 列)。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 已添加 `ProfileEvents` 用于度量通过网络读取和写入磁盘以及读取和写入磁盘所花费的时间、网络错误的数量以及在网络带宽受限时所花费的等待时间。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 已添加 `ProfileEvents`包含来自rusage的系统指标的计数器(您可以使用它们获取有关用户空间和内核、页面错误和上下文切换的CPU使用率的信息),以及taskstats指标(使用它们获取有关I/O等待时间、CPU等待时间以及读取和记录的数据量的信息,无论是否包含页面缓存)。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 该 `ProfileEvents` 计数器应用于全局和每个查询,以及每个查询执行线程,它允许您按查询详细分析资源消耗情况。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 添加了 `system.query_thread_log` 表,其中包含有关每个查询执行线程的信息。 添加了 `log_query_threads` 设置。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) +- 该 `system.metrics` 和 `system.events` 表现在有内置文档。 [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) +- 添加了 `arrayEnumerateDense` 功能。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2975) +- 添加了 `arrayCumSumNonNegative` 和 `arrayDifference` 功能。 [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/2942) +- 添加了 `retention` 聚合函数。 [李尚迪](https://github.com/ClickHouse/ClickHouse/pull/2887) +- 现在,您可以使用plus运算符添加(合并)聚合函数的状态,并将聚合函数的状态乘以非负常数。 [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) +- MergeTree系列中的表现在具有虚拟列 `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) + +#### 实验特点: {#experimental-features-1} + +- 添加了 `LowCardinality(T)` 数据类型。 此数据类型自动创建值的本地字典,并允许数据处理而无需解压字典。 [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) +- 添加了JIT编译函数的缓存和编译前使用次数的计数器。 要JIT编译表达式,请启用 `compile_expressions` 设置。 [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) + +#### 改进: {#improvements-4} + +- 修复了放弃副本时复制日志无限积累的问题。 为延迟较长的副本添加了有效的恢复模式。 +- 改进的性能 `GROUP BY` 当其中一个是string,其他是固定长度时,具有多个聚合字段。 +- 使用时提高性能 `PREWHERE` 并与表达式的隐式转移 `PREWHERE`. +- 改进文本格式的解析性能 (`CSV`, `TSV`). [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) +- 改进了读取二进制格式字符串和数组的性能。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2955) +- 提高性能和减少内存消耗的查询 `system.tables` 和 `system.columns` 当单个服务器上有非常大量的表时。 [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) +- 修复了大量查询导致错误的情况下的性能问题( `_dl_addr` 功能是可见的 `perf top`,但服务器没有使用太多的CPU)。 [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) +- 条件被转换到视图中(当 `enable_optimize_predicate_expression` 被启用)。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2907) +- 改进的功能 `UUID` 数据类型。 [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) +- 该 `UUID` -Alchemist字典支持数据类型。 [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) +- 该 `visitParamExtractRaw` 函数与嵌套结构正常工作。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2974) +- 当 `input_format_skip_unknown_fields` 启用设置,在对象字段 `JSONEachRow` 格式被正确跳过。 [BlahGeek](https://github.com/ClickHouse/ClickHouse/pull/2958) +- 对于一个 `CASE` 表达式与条件,你现在可以省略 `ELSE`,这相当于 `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) +- 现在可以在使用ZooKeeper时配置操作超时。 [urykhy](https://github.com/ClickHouse/ClickHouse/pull/2971) +- 您可以指定偏移量 `LIMIT n, m` 作为 `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- 您可以使用 `SELECT TOP n` 语法作为替代 `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) +- 增加了队列的大小写入系统表,因此 `SystemLog parameter queue is full` 错误不经常发生。 +- 该 `windowFunnel` aggregate函数现在支持满足多个条件的事件。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2801) +- 重复的列可以用于 `USING` 条款 `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) +- `Pretty` 格式现在对列对齐宽度有限制。 使用 `output_format_pretty_max_column_pad_width` 设置。 如果一个值较宽,它仍将完整显示,但表中的其他单元格不会太宽。 [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) +- 该 `odbc` 表函数现在允许您指定数据库/模式名称。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2885) +- 增加了使用在指定的用户名的能力 `clickhouse-client` 配置文件。 [弗拉基米尔\*科兹宾](https://github.com/ClickHouse/ClickHouse/pull/2909) +- 该 `ZooKeeperExceptions` 计数器已被分成三个计数器: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions`,和 `ZooKeeperOtherExceptions`. +- `ALTER DELETE` 查询适用于实例化视图。 +- 在定期运行清理线程时添加了随机化 `ReplicatedMergeTree` 表,以避免周期性负载尖峰时有一个非常大的数量 `ReplicatedMergeTree` 桌子 +- 支持 `ATTACH TABLE ... ON CLUSTER` 查询。 [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) + +#### 错误修复: {#bug-fixes-13} + +- 修正了一个问题 `Dictionary` 表(抛出 `Size of offsets doesn't match size of column` 或 `Unknown compression method` 例外)。 此错误出现在版本18.10.3中。 [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) +- 修复了合并时的错误 `CollapsingMergeTree` 如果其中一个数据部分为空(这些部分在合并或合并期间形成 `ALTER DELETE` 如果所有数据被删除),和 `vertical` 算法被用于合并。 [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) +- 在固定的竞争条件 `DROP` 或 `TRUNCATE` 为 `Memory` 表与同时 `SELECT`,这可能导致服务器崩溃。 此错误出现在版本1.1.54388中。 [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) +- 修正了插入时数据丢失的可能性 `Replicated` 表如果 `Session is expired` 错误返回(数据丢失可以通过检测 `ReplicatedDataLoss` 公制)。 此错误发生在版本1.1.54378。 [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) +- 在修复段错误 `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) +- 修正了错误搜索列名时 `WHERE` 表达式完全由限定列名组成,例如 `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) +- 修正了 “Not found column” 如果从远程服务器请求由IN表达式和子查询组成的单个列,则在执行分布式查询时发生错误。 [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) +- 修正了 `Block structure mismatch in UNION stream: different number of columns` 如果其中一个分片是本地的,而另一个分片不是,则发生分布式查询的错误,并优化移动到 `PREWHERE` 被触发。 [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) +- 修正了 `pointInPolygon` 非凸多边形的某些情况下的函数。 [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) +- 修正了比较时不正确的结果 `nan` 与整数。 [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) +- 修正了一个错误 `zlib-ng` 在极少数情况下可能导致segfault的库。 [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) +- 修复了插入到表中时的内存泄漏 `AggregateFunction` 列,如果聚合函数的状态不简单(分别分配内存),并且如果单个插入请求导致多个小块。 [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) +- 修复了创建和删除相同的竞争条件 `Buffer` 或 `MergeTree` 同时表。 +- 修复了比较由某些非平凡类型(如元组)组成的元组时出现段错误的可能性。 [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) +- 修正了运行某些时段错误的可能性 `ON CLUSTER` 查询。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2960) +- 修正了一个错误 `arrayDistinct` 功能 `Nullable` 数组元素。 [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) +- 该 `enable_optimize_predicate_expression` 选项现在正确支持的情况下 `SELECT *`. [张冬](https://github.com/ClickHouse/ClickHouse/pull/2929) +- 修复了重新初始化ZooKeeper会话时的段错误。 [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) +- 与ZooKeeper工作时固定的潜在阻塞。 +- 修正了不正确的代码添加嵌套的数据结构中 `SummingMergeTree`. +- 在为聚合函数的状态分配内存时,会正确考虑对齐,这使得在实现聚合函数的状态时可以使用需要对齐的操作。 [晨兴-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) + +#### 安全修复: {#security-fix} + +- 安全使用ODBC数据源。 与ODBC驱动程序的交互使用单独的 `clickhouse-odbc-bridge` 过程。 第三方ODBC驱动程序中的错误不再导致服务器稳定性问题或漏洞。 [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) +- 修正了在文件路径的不正确的验证 `catBoostPool` 表功能。 [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) +- 系统表的内容 (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas`,和 `replication_queue`)根据用户对数据库的配置访问权限进行过滤 (`allow_databases`). [张冬](https://github.com/ClickHouse/ClickHouse/pull/2856) + +#### 向后不兼容的更改: {#backward-incompatible-changes-3} + +- 在具有JOIN的查询中,星形字符将扩展为符合SQL标准的所有表中的列列表。 您可以通过设置恢复旧行为 `asterisk_left_columns_only` 在用户配置级别上为1。 + +#### 构建更改: {#build-changes-2} + +- 大多数集成测试现在可以通过commit运行。 +- 代码样式检查也可以通过提交运行。 +- 该 `memcpy` 在CentOS7/Fedora上构建时,正确选择实现。 [Etienne Champetier](https://github.com/ClickHouse/ClickHouse/pull/2912) +- 当使用clang来构建时,来自一些警告 `-Weverything` 已添加,除了常规 `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) +- 调试生成使用 `jemalloc` 调试选项。 +- 用于与ZooKeeper交互的库接口被声明为抽象。 [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) + +## ClickHouse释放18.10 {#clickhouse-release-18-10} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-10-3-2018-08-13} + +#### 新功能: {#new-features-5} + +- HTTPS可用于复制。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) +- 新增功能 `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64`,和 `murmurHash3_128` 除了现有的 `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) +- 支持ClickHouse ODBC驱动程序中的可空类型 (`ODBCDriver2` 输出格式)。 [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) +- 支持 `UUID` 在关键列。 + +#### 改进: {#improvements-5} + +- 当群集从配置文件中删除时,可以在不重新启动服务器的情况下删除群集。 [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) +- 从配置文件中删除外部字典时,可以在不重新启动服务器的情况下删除它们。 [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) +- 已添加 `SETTINGS` 支持 `Kafka` 表引擎。 [Alexander Marshalov](https://github.com/ClickHouse/ClickHouse/pull/2781) +- 改进的 `UUID` 数据类型(尚未完成)。 [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) +- 支持合并后的空部件 `SummingMergeTree`, `CollapsingMergeTree` 和 `VersionedCollapsingMergeTree` 引擎 [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) +- 已完成突变的旧记录将被删除 (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) +- 添加了 `system.merge_tree_settings` 桌子 [基里尔\*什瓦科夫](https://github.com/ClickHouse/ClickHouse/pull/2841) +- 该 `system.tables` 表现在具有依赖列: `dependencies_database` 和 `dependencies_table`. [张冬](https://github.com/ClickHouse/ClickHouse/pull/2851) +- 添加了 `max_partition_size_to_drop` 配置选项。 [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) +- 添加了 `output_format_json_escape_forward_slashes` 选项。 [Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2812) +- 添加了 `max_fetch_partition_retries_count` 设置。 [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) +- 添加了 `prefer_localhost_replica` 用于禁用本地副本的首选项以及在不进程间交互的情况下转到本地副本的设置。 [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) +- 该 `quantileExact` 聚合函数返回 `nan` 在聚合在一个空的情况下 `Float32` 或 `Float64` 预备 [李尚迪](https://github.com/ClickHouse/ClickHouse/pull/2855) + +#### 错误修复: {#bug-fixes-14} + +- 删除了ODBC的连接字符串参数的不必要的转义,这使得无法建立连接。 此错误发生在版本18.6.0中。 +- 修正了处理逻辑 `REPLACE PARTITION` 复制队列中的命令。 如果有两个 `REPLACE` 对于同一个分区的命令,不正确的逻辑可能会导致其中一个保留在复制队列中而无法执行。 [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) +- 修正了一个合并错误,当所有的数据部分都是空的(从合并或从形成的部分 `ALTER DELETE` 如果所有数据都被删除)。 此错误出现在18.1.0版本。 [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) +- 修复了并发错误 `Set` 或 `Join`. [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2823) +- 修正了 `Block structure mismatch in UNION stream: different number of columns` 发生的错误 `UNION ALL` 子查询内的查询,如果一个 `SELECT` 查询包含重复的列名。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2094) +- 修复了连接到MySQL服务器时发生异常时的内存泄漏。 +- 在查询错误的情况下修复了不正确的clickhouse客户端响应代码。 +- 修正了包含DISTINCT的实例化视图的不正确行为。 [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) + +#### 向后不兼容的更改 {#backward-incompatible-changes-4} + +- 删除了对分布式表的检查表查询的支持。 + +#### 构建更改: {#build-changes-3} + +- 分配器已被替换: `jemalloc` 现在用来代替 `tcmalloc`. 在某些情况下,这增加了速度高达20%。 但是,有些查询已经减慢了20%。 在某些情况下,内存消耗减少了大约10%,稳定性得到了提高。 由于竞争激烈的负载,用户空间和系统中的CPU使用率略有增加。 [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) +- 从子模块使用libressl。 [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) +- 从子模块使用unixodbc。 [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) +- 从子模块中使用mariadb-connector-c。 [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) +- 将功能性测试文件添加到存储库中,这些文件取决于测试数据的可用性(暂时不包含测试数据本身)。 + +## ClickHouse释放18.6 {#clickhouse-release-18-6} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-6-0-2018-08-02} + +#### 新功能: {#new-features-6} + +- 增加了对ON表达式的支持,以便在语法上加入: + `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` + 表达式必须是由AND运算符连接的等式链。 等式的每一侧都可以是其中一个表的列上的任意表达式。 支持使用完全限定的列名 (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`)对于正确的表。 [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) +- 可以启用HTTPS进行复制。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) + +#### 改进: {#improvements-6} + +- 服务器将其版本的补丁组件传递给客户端。 有关修补程序版本组件的数据位于 `system.processes` 和 `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) + +## ClickHouse释放18.5 {#clickhouse-release-18-5} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-5-1-2018-07-31} + +#### 新功能: {#new-features-7} + +- 添加了哈希函数 `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). + +#### 改进: {#improvements-7} + +- 现在你可以使用 `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) 从环境变量设置配置文件中的值的属性。 +- 增加了不区分大小写的版本 `coalesce`, `ifNull`,和 `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). + +#### 错误修复: {#bug-fixes-15} + +- 修复了启动副本时可能出现的错误 [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). + +## ClickHouse释放18.4 {#clickhouse-release-18-4} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-4-0-2018-07-28} + +#### 新功能: {#new-features-8} + +- 添加系统表: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). +- 增加了使用表函数代替表作为参数的能力 `remote` 或 `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). +- 支持 `HTTP Basic` 复制协议中的身份验证 [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). +- 该 `has` 函数现在允许搜索数组中的数值 `Enum` 值 [Maxim Khrisanfov](https://github.com/ClickHouse/ClickHouse/pull/2699). +- 支持添加任意消息分隔符从读取时 `Kafka` [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2701). + +#### 改进: {#improvements-8} + +- 该 `ALTER TABLE t DELETE WHERE` 查询不会重写未受WHERE条件影响的数据部分 [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). +- 该 `use_minimalistic_checksums_in_zookeeper` 备选案文 `ReplicatedMergeTree` 默认情况下启用表。 此设置在版本1.1.54378,2018-04-16中添加。 不能再安装超过1.1.54378的版本。 +- 支持运行 `KILL` 和 `OPTIMIZE` 指定的查询 `ON CLUSTER` [张冬](https://github.com/ClickHouse/ClickHouse/pull/2689). + +#### 错误修复: {#bug-fixes-16} + +- 修正了错误 `Column ... is not under an aggregate function and not in GROUP BY` 用于具有IN表达式的聚合。 此错误出现在18.1.0版本。 ([bbdd780b](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) +- 修正了一个错误 `windowFunnel aggregate function` [张冬](https://github.com/ClickHouse/ClickHouse/pull/2735). +- 修正了一个错误 `anyHeavy` 聚合函数 ([a2101df2](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) +- 使用时固定服务器崩溃 `countArray()` 聚合函数。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-5} + +- 参数 `Kafka` 发动机从改变 `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` 到 `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. 如果你的表使用 `kafka_schema` 或 `kafka_num_consumers` 参数,你必须手动编辑元数据文件 `path/metadata/database/table.sql` 并添加 `kafka_row_delimiter` 参数 `''` 价值。 + +## ClickHouse释放18.1 {#clickhouse-release-18-1} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-1-0-2018-07-23} + +#### 新功能: {#new-features-9} + +- 支持 `ALTER TABLE t DELETE WHERE` 非复制MergeTree表的查询 ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). +- 支持任意类型的 `uniq*` 聚合函数族 ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). +- 支持比较运算符中的任意类型 ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). +- 该 `users.xml` 文件允许设置子网掩码的格式 `10.0.0.1/255.255.255.0`. 这对于在中间使用零的IPv6网络使用掩码是必要的 ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). +- 添加了 `arrayDistinct` 功能 ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). +- SummingMergeTree引擎现在可以使用AggregateFunction类型列 ([康斯坦丁\*潘](https://github.com/ClickHouse/ClickHouse/pull/2566)). + +#### 改进: {#improvements-9} + +- 更改了发布版本的编号方案。 现在第一部分包含发布年份(公元,莫斯科时区,减去2000),第二部分包含主要更改的数量(大多数版本的增加),第三部分是补丁版本。 除非在更新日志中另有说明,否则版本仍然向后兼容。 +- 更快地将浮点数转换为字符串 ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2664)). +- 如果在插入过程中由于解析错误而跳过某些行(这可能与 `input_allow_errors_num` 和 `input_allow_errors_ratio` 启用设置),跳过的行数现在写入服务器日志 ([列奥纳多\*切奇](https://github.com/ClickHouse/ClickHouse/pull/2669)). + +#### 错误修复: {#bug-fixes-17} + +- 修复了临时表的截断命令 ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2624)). +- 修复了读取响应时出现网络错误时ZooKeeper客户端库中罕见的死锁 ([c315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). +- 修复了转换为可空类型期间的错误 ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). +- 修正了不正确的结果 `maxIntersection()` 函数时间间隔的边界重合 ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2657)). +- 修复了函数参数中OR表达式链的不正确转换 ([晨兴-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). +- 修复了包含 `IN (subquery)` 另一个子查询中的表达式 ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). +- 修复了分布式查询中使用不同版本的服务器之间的不兼容性 `CAST` 不是大写字母的函数 ([fe8c4d6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). +- 添加了对外部数据库管理系统查询的缺少标识符引用 ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). + +#### 向后不兼容的更改: {#backward-incompatible-changes-6} + +- 将包含数字零的字符串转换为DateTime不起作用。 示例: `SELECT toDateTime('0')`. 这也是原因 `DateTime DEFAULT '0'` 在表中不起作用,以及 `0` 在字典里 解决方案:替换 `0` 与 `0000-00-00 00:00:00`. + +## ClickHouse释放1.1 {#clickhouse-release-1-1} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54394-2018-07-12} + +#### 新功能: {#new-features-10} + +- 添加了 `histogram` 聚合函数 ([米哈伊尔\*苏林](https://github.com/ClickHouse/ClickHouse/pull/2521)). +- 现在 `OPTIMIZE TABLE ... FINAL` 可以在不指定分区的情况下使用 `ReplicatedMergeTree` ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2600)). + +#### 错误修复: {#bug-fixes-18} + +- 修复了在发送和下载复制数据时读取和写入套接字超时非常小的问题(一秒钟),这使得在网络或磁盘上存在负载时无法下载更大的部分(导致周期性尝试下载部分)。 此错误发生在版本1.1.54388。 +- 修复了在ZooKeeper中使用chroot时在表中插入重复数据块的问题。 +- 该 `has` 函数现在可以正常工作用于具有可为空元素的数组 ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). +- 该 `system.tables` 在分布式查询中使用表现在可以正常工作。 该 `metadata_modification_time` 和 `engine_full` 列现在是非虚拟的。 修复了仅从表中查询这些列时发生的错误。 +- 固定如何空 `TinyLog` 表插入一个空数据块后工作 ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). +- 该 `system.zookeeper` 如果ZooKeeper中节点的值为NULL,表就可以工作。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54390-2018-07-06} + +#### 新功能: {#new-features-11} + +- 查询可以在发送 `multipart/form-data` 格式(在 `query` 字段),如果外部数据也被发送用于查询处理,这是有用的 ([Olga Hvostikova](https://github.com/ClickHouse/ClickHouse/pull/2490)). +- 增加了在读取CSV格式数据时启用或禁用处理单引号或双引号的功能。 您可以在 `format_csv_allow_single_quotes` 和 `format_csv_allow_double_quotes` 设置 ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2574)). +- 现在 `OPTIMIZE TABLE ... FINAL` 可以在不指定非复制变体的分区的情况下使用 `MergeTree` ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2599)). + +#### 改进: {#improvements-10} + +- 在可以使用表索引时使用IN运算符提高性能、减少内存消耗并正确跟踪内存消耗 ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). +- 删除添加数据部分时校验和的冗余检查。 当存在大量副本时,这一点很重要,因为在这些情况下,检查的总数等于N^2。 +- 增加了对 `Array(Tuple(...))` 对于参数 `arrayEnumerateUniq` 功能 ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). +- 已添加 `Nullable` 支持 `runningDifference` 功能 ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). +- 当存在大量表达式时,改进了查询分析性能 ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). +- 更快地选择用于合并的数据部分 `ReplicatedMergeTree` 桌子 更快地恢复ZooKeeper会话 ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). +- 该 `format_version.txt` 文件 `MergeTree` 如果表丢失,则重新创建表,如果在没有文件的情况下复制目录结构后启动ClickHouse,这是有意义的 ([Ciprian Hacman](https://github.com/ClickHouse/ClickHouse/pull/2593)). + +#### 错误修复: {#bug-fixes-19} + +- 修复了与ZooKeeper一起工作时的错误,这可能会导致无法在重新启动服务器之前恢复表的会话和只读状态。 +- 修复了与ZooKeeper一起工作时的错误,如果会话中断,可能会导致旧节点不被删除。 +- 修正了一个错误 `quantileTDigest` Float参数的函数(此错误在版本1.1.54388中引入) ([米哈伊尔\*苏林](https://github.com/ClickHouse/ClickHouse/pull/2553)). +- 修复了MergeTree表索引中的一个错误,如果主键列位于函数内部,用于在相同大小的有符号和无符号整数之间转换类型 ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). +- 如果修复段错误 `macros` 使用,但它们不在配置文件中 ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). +- 修复了重新连接客户端时切换到默认数据库的问题 ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). +- 修正了当发生的错误 `use_index_for_in_with_subqueries` 设置被禁用。 + +#### 安全修复: {#security-fix-1} + +- 当连接到MySQL时,发送文件不再可能 (`LOAD DATA LOCAL INFILE`). + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54388-2018-06-28} + +#### 新功能: {#new-features-12} + +- 支持 `ALTER TABLE t DELETE WHERE` 查询复制的表。 添加了 `system.mutations` 表来跟踪这种类型的查询的进度。 +- 支持 `ALTER TABLE t [REPLACE|ATTACH] PARTITION` 查询\*MergeTree表。 +- 支持 `TRUNCATE TABLE` 查询 ([张冬](https://github.com/ClickHouse/ClickHouse/pull/2260)) +- 几个新的 `SYSTEM` 复制表的查询 (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). +- 增加了使用MySQL引擎和相应的表函数写入表的能力 ([三弟](https://github.com/ClickHouse/ClickHouse/pull/2294)). +- 添加了 `url()` 表功能和 `URL` 表引擎 ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). +- 添加了 `windowFunnel` 聚合函数 ([三弟](https://github.com/ClickHouse/ClickHouse/pull/2352)). +- 新 `startsWith` 和 `endsWith` 字符串的函数 ([Vadim Plakhtinsky](https://github.com/ClickHouse/ClickHouse/pull/2429)). +- 该 `numbers()` 表函数现在允许您指定偏移量 ([张冬](https://github.com/ClickHouse/ClickHouse/pull/2535)). +- 密码 `clickhouse-client` 可以交互输入。 +- 服务器日志现在可以发送到系统日志 ([Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2459)). +- 支持使用共享库源登录字典 ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). +- 支持自定义CSV分隔符 ([伊万\*朱可夫](https://github.com/ClickHouse/ClickHouse/pull/2263)) +- 添加了 `date_time_input_format` 设置。 如果将此设置切换到 `'best_effort'`,日期时间值将以各种格式读取。 +- 添加了 `clickhouse-obfuscator` 用于数据混ob的实用程序。 用法示例:发布性能测试中使用的数据。 + +#### 实验特点: {#experimental-features-2} + +- 增加了计算能力 `and` 只有在需要的地方才能参数 ([阿纳斯塔西娅Tsarkova](https://github.com/ClickHouse/ClickHouse/pull/2272)) +- Jit编译为本机代码现在可用于某些表达式 ([pyos](https://github.com/ClickHouse/ClickHouse/pull/2277)). + +#### 错误修复: {#bug-fixes-20} + +- 对于具有以下内容的查询,不再显示重复项 `DISTINCT` 和 `ORDER BY`. +- 查询与 `ARRAY JOIN` 和 `arrayFilter` 不再返回不正确的结果。 +- 修复了从嵌套结构读取数组列时的错误 ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). +- 修复了使用HAVING子句分析查询时出现的错误,如 `HAVING tuple IN (...)`. +- 修复了使用递归别名分析查询时出现的错误。 +- 修复了从REPLACINGMERGETREE读取过滤所有行的PREWHERE中的条件时出现的错误 ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). +- 在HTTP界面中使用会话时,未应用用户配置文件设置。 +- 修复了如何从clickhouse-local中的命令行参数应用设置。 +- ZooKeeper客户端库现在使用从服务器接收的会话超时。 +- 修正了ZooKeeper客户端库中的一个错误,当客户端等待服务器响应时间超过超时时间。 +- 修剪部分的查询与分区键列的条件 ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). +- 合并后,现在可以 `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). +- ODBC表函数中的类型映射已修复 ([三弟](https://github.com/ClickHouse/ClickHouse/pull/2268)). +- 类型比较已修复 `DateTime` 有和没有时区 ([Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2400)). +- 修正了语法解析和格式化的 `CAST` 接线员 +- 固定插入到分布式表引擎的实例化视图中 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). +- 修正了从写入数据时的争用条件 `Kafka` 引擎到实例化视图 ([刘杨宽](https://github.com/ClickHouse/ClickHouse/pull/2448)). +- 固定ssrf中的remote()表函数。 +- 固定退出行为 `clickhouse-client` 在多行模式下 ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). + +#### 改进: {#improvements-11} + +- 复制表中的后台任务现在在线程池中执行,而不是在单独的线程中执行 ([Silviu Caragea](https://github.com/ClickHouse/ClickHouse/pull/1722)). +- 改进的LZ4压缩性能。 +- 更快地分析具有大量联接和子查询的查询。 +- 当有太多的网络错误时,DNS缓存现在会自动更新。 +- 如果由于其中一个实例化视图包含太多部件而无法插入表格插入,则不再发生表格插入。 +- 纠正了事件计数器中的差异 `Query`, `SelectQuery`,和 `InsertQuery`. +- 像这样的表达式 `tuple IN (SELECT tuple)` 如果元组类型匹配,则允许。 +- 即使您没有配置ZooKeeper,具有复制表的服务器也可以启动。 +- 在计算可用CPU内核数时,现在考虑了cgroups的限制 ([Atri Sharma](https://github.com/ClickHouse/ClickHouse/pull/2325)). +- 在systemd配置文件中添加了配置目录的chown ([米哈伊尔Shiryaev](https://github.com/ClickHouse/ClickHouse/pull/2421)). + +#### 构建更改: {#build-changes-4} + +- Gcc8编译器可用于构建。 +- 增加了从子模块构建llvm的能力。 +- Librdkafka库的版本已更新为v0.11.4。 +- 增加了使用系统libcpuid库的能力。 库版本已更新为0.4.0。 +- 使用vectorclass库修复了构建 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). +- Cmake现在默认情况下为ninja生成文件(如使用 `-G Ninja`). +- 添加了使用libtinfo库而不是libtermcap的功能 ([Georgy Kondratiev](https://github.com/ClickHouse/ClickHouse/pull/2519)). +- 修复了Fedora Rawhide中的头文件冲突 ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). + +#### 向后不兼容的更改: {#backward-incompatible-changes-7} + +- 删除逃逸 `Vertical` 和 `Pretty*` 格式和删除 `VerticalRaw` 格式。 +- 如果在分布式查询中同时使用版本1.1.54388(或更高版本)的服务器和版本较旧的服务器,并且查询具有 `cast(x, 'Type')` 表达式没有 `AS` 关键字并没有这个词 `cast` 以大写形式,将引发一个异常,并显示如下消息 `Not found column cast(0, 'UInt8') in block`. 解决方案:更新整个群集上的服务器。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682 {#clickhouse-release-1-1-54385-2018-06-01} + +#### 错误修复: {#bug-fixes-21} + +- 修复了在某些情况下导致ZooKeeper操作阻塞的错误。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54383-2018-05-22} + +#### 错误修复: {#bug-fixes-22} + +- 修正了如果一个表有许多副本,复制队列的放缓。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54381-2018-05-14} + +#### 错误修复: {#bug-fixes-23} + +- 修复了ClickHouse与ZooKeeper服务器断开连接时,ZooKeeper中的节点泄漏问题。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54380-2018-04-21} + +#### 新功能: {#new-features-13} + +- 增加了表功能 `file(path, format, structure)`. 从读取字节的示例 `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. + +#### 改进: {#improvements-12} + +- 子查询可以包装在 `()` 括号以增强查询的可读性。 例如: `(SELECT 1) UNION ALL (SELECT 1)`. +- 简单 `SELECT` 从查询 `system.processes` 表不包括在 `max_concurrent_queries` 限制。 + +#### 错误修复: {#bug-fixes-24} + +- 修正了不正确的行为 `IN` 从中选择时的运算符 `MATERIALIZED VIEW`. +- 修正了不正确的过滤分区索引的表达式,如 `partition_key_column IN (...)`. +- 固定无法执行 `OPTIMIZE` 在以下情况下对非领导副本进行查询 `REANAME` 在桌子上进行。 +- 修复了执行时的授权错误 `OPTIMIZE` 或 `ALTER` 对非领导副本的查询。 +- 固定的冻结 `KILL QUERY`. +- 修复了ZooKeeper客户端库中的错误,这导致了手表丢失,分布式的DDL队列冻结,并在复制队列中的速度变慢,如果非空 `chroot` 前缀在ZooKeeper配置中使用。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-8} + +- 删除对如下表达式的支持 `(a, b) IN (SELECT (a, b))` (可以使用等效表达式 `(a, b) IN (SELECT a, b)`). 在以前的版本中,这些表达式导致未确定 `WHERE` 过滤或导致的错误。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54378-2018-04-16} + +#### 新功能: {#new-features-14} + +- 可以在不重新启动服务器的情况下更改日志记录级别。 +- 添加了 `SHOW CREATE DATABASE` 查询。 +- 该 `query_id` 可以传递给 `clickhouse-client` (肘部空间)。 +- 新设置: `max_network_bandwidth_for_all_users`. +- 增加了对 `ALTER TABLE ... PARTITION ...` 为 `MATERIALIZED VIEW`. +- 在系统表中以未压缩形式添加有关数据部件大小的信息。 +- 对分布式表的服务器到服务器加密支持 (`1` 在副本配置中 ``). +- 表级别的配置 `ReplicatedMergeTree` 家庭,以最大限度地减少存储在Zookeeper的数据量: : `use_minimalistic_checksums_in_zookeeper = 1` +- 的配置 `clickhouse-client` 提示。 默认情况下,服务器名称现在输出到提示符。 可以更改服务器的显示名称。 它也发送了 `X-ClickHouse-Display-Name` HTTP头(基里尔Shvakov)。 +- 多个逗号分隔 `topics` 可为指定 `Kafka` 发动机(托比亚斯\*亚当森) +- 当查询停止时 `KILL QUERY` 或 `replace_running_query`,客户端接收 `Query was canceled` 异常而不是不完整的结果。 + +#### 改进: {#improvements-13} + +- `ALTER TABLE ... DROP/DETACH PARTITION` 查询在复制队列的前面运行。 +- `SELECT ... FINAL` 和 `OPTIMIZE ... FINAL` 即使表具有单个数据部分,也可以使用。 +- A `query_log` 如果手动删除(基里尔Shvakov),则会在飞行中重新创建表格。 +- 该 `lengthUTF8` 功能运行速度更快(zhang2014)。 +- 在同步刀片的性能提高 `Distributed` 表 (`insert_distributed_sync = 1`)当有一个非常大的数量的碎片。 +- 服务器接受 `send_timeout` 和 `receive_timeout` 从客户端设置并在连接到客户端时应用它们(它们以相反的顺序应用:服务器套接字的 `send_timeout` 被设置为 `receive_timeout` 值,反之亦然)。 +- 更强大的崩溃恢复异步插入 `Distributed` 桌子 +- 的返回类型 `countEqual` 功能从更改 `UInt32` 到 `UInt64` (谢磊). + +#### 错误修复: {#bug-fixes-25} + +- 修正了一个错误 `IN` 当表达式的左侧是 `Nullable`. +- 使用元组时,现在返回正确的结果 `IN` 当某些元组组件位于表索引中时。 +- 该 `max_execution_time` limit现在可以正常使用分布式查询。 +- 在计算复合列的大小时修正错误 `system.columns` 桌子 +- 修复了创建临时表时的错误 `CREATE TEMPORARY TABLE IF NOT EXISTS.` +- 修正错误 `StorageKafka` (\#\#2075) +- 修复了某些聚合函数的无效参数导致的服务器崩溃。 +- 修正了防止错误 `DETACH DATABASE` 查询停止后台任务 `ReplicatedMergeTree` 桌子 +- `Too many parts` 插入到聚合实例化视图时,状态不太可能发生(\#\#2084)。 +- 如果替换必须在同一级别上跟随另一个替换,则更正了配置中替换的递归处理。 +- 更正了创建元数据文件时的语法 `VIEW` 这使用一个查询 `UNION ALL`. +- `SummingMergeTree` 现在可以正常使用复合键对嵌套数据结构进行求和。 +- 修复了在选择领导者时出现竞争条件的可能性 `ReplicatedMergeTree` 桌子 + +#### 构建更改: {#build-changes-5} + +- 构建支持 `ninja` 而不是 `make` 和用途 `ninja` 默认情况下,构建版本。 +- 重命名的软件包: `clickhouse-server-base` 在 `clickhouse-common-static`; `clickhouse-server-common` 在 `clickhouse-server`; `clickhouse-common-dbg` 在 `clickhouse-common-static-dbg`. 要安装,请使用 `clickhouse-server clickhouse-client`. 具有旧名称的软件包仍将加载到存储库中,以便向后兼容。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-9} + +- 如果在左侧指定了数组,则删除了IN表达式的特殊解释。 以前,表达式 `arr IN (set)` 被解释为 “at least one `arr` element belongs to the `set`”. 要在新版本中获得相同的行为,请编写 `arrayExists(x -> x IN (set), arr)`. +- 禁用套接字选项的不正确使用 `SO_REUSEPORT`,默认情况下,Poco库中未正确启用。 请注意,在Linux上,不再有任何理由同时指定地址 `::` 和 `0.0.0.0` for listen – use just `::`,它允许监听通过IPv4和IPv6的连接(使用默认的内核配置设置)。 您还可以通过指定以下命令恢复到以前版本中的行为 `1` 在配置。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54370-2018-03-16} + +#### 新功能: {#new-features-15} + +- 添加了 `system.macros` 更改配置文件时,宏的表和自动更新。 +- 添加了 `SYSTEM RELOAD CONFIG` 查询。 +- 添加了 `maxIntersections(left_col, right_col)` 聚合函数,它返回同时相交间隔的最大数目 `[left; right]`. 该 `maxIntersectionsPosition(left, right)` 函数返回的开始 “maximum” 间隔。 ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2012)). + +#### 改进: {#improvements-14} + +- 当在一个插入数据 `Replicated` 表,较少的请求是由 `ZooKeeper` (和大多数用户级错误已经从消失 `ZooKeeper` 日志)。 +- 添加了为数据集创建别名的功能。 示例: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. + +#### 错误修复: {#bug-fixes-26} + +- 修正了 `Illegal PREWHERE` 从合并表读取时出错 `Distributed`桌子 +- 添加了修复,允许您在仅支持IPv4的Docker容器中启动clickhouse-server。 +- 修正了从系统读取时的争用条件 `system.parts_columns tables.` +- 同步插入到一个过程中删除双缓冲 `Distributed` 表,这可能导致连接超时。 +- 修正了一个错误,导致过长的等待不可用的副本开始之前 `SELECT` 查询。 +- 在固定不正确的日期 `system.parts` 桌子 +- 修正了一个错误,使得它无法在插入数据 `Replicated` 表if `chroot` 是非空的配置 `ZooKeeper` 集群。 +- 修正了一个空的垂直合并算法 `ORDER BY` 桌子 +- 恢复了在对远程表的查询中使用字典的能力,即使这些字典不存在于请求者服务器上。 此功能在版本1.1.54362中丢失。 +- 恢复查询的行为,如 `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` 当右侧的 `IN` 应该使用远程 `default.table` 而不是当地的 此行为在版本1.1.54358中被破坏。 +- 删除了无关的错误级别日志记录 `Not found column ... in block`. + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54362-2018-03-11} + +#### 新功能: {#new-features-16} + +- 聚合不 `GROUP BY` 对于一个空集(如 `SELECT count(*) FROM table WHERE 0`)现在返回一个结果,其中一行为聚合函数带有null值,符合SQL标准。 要恢复旧行为(返回一个空结果),请设置 `empty_result_for_aggregation_by_empty_set` 到1。 +- 增加了类型转换 `UNION ALL`. 不同的别名被允许 `SELECT` 在职位 `UNION ALL`,符合SQL标准。 +- 任意表达式支持 `LIMIT BY` 条款 以前,只能使用以下内容产生的列 `SELECT`. +- 的索引 `MergeTree` 表用于以下情况 `IN` 应用于来自主键列的表达式元组。 示例: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` (Anastasiya Tsarkova) +- 添加了 `clickhouse-copier` 用于在群集之间复制和重新分布数据的工具(测试版)。 +- 添加了一致的哈希函数: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. 它们可以用作分片密钥,以减少后续重新分片期间的网络流量。 +- 新增功能: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. +- 添加了 `arrayCumSum` 功能(哈维桑塔纳)。 +- 添加了 `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero`,和 `parseDateTimeBestEffortOrNull` 用于从包含各种可能格式的文本的字符串中读取DateTime的函数。 +- 数据可以在更新期间从外部字典部分重新加载(加载只是记录,其中指定字段的值大于先前的下载)(Arsen Hakobyan)。 +- 添加了 `cluster` 表功能。 示例: `cluster(cluster_name, db, table)`. 该 `remote` 表函数可以接受集群名称作为第一个参数,如果它被指定为标识符。 +- 该 `remote` 和 `cluster` 表函数可用于 `INSERT` 查询。 +- 添加了 `create_table_query` 和 `engine_full` 虚拟列到 `system.tables`桌子 该 `metadata_modification_time` 列是虚拟的。 +- 添加了 `data_path` 和 `metadata_path` 列 `system.tables`和`system.databases` 表,并添加了 `path` 列到 `system.parts` 和 `system.parts_columns` 桌子 +- 添加了关于合并的其他信息 `system.part_log` 桌子 +- 一个任意的分区键可以用于 `system.query_log` 表(基里尔Shvakov)。 +- 该 `SHOW TABLES` 查询现在还显示临时表。 添加临时表和 `is_temporary` 列到 `system.tables` (张2014)。 +- 已添加 `DROP TEMPORARY TABLE` 和 `EXISTS TEMPORARY TABLE` 查询(zhang2014)。 +- 支持 `SHOW CREATE TABLE` 对于临时表(zhang2014)。 +- 添加了 `system_profile` 内部进程使用的设置的配置参数。 +- 支持加载 `object_id` 作为一个属性 `MongoDB` 字典(帕维尔\*利特维年科)。 +- 阅读 `null` 作为加载数据的外部字典与时的默认值 `MongoDB` 资料来源(帕维尔\*利特维年科)。 +- 阅读 `DateTime` 在值 `Values` 从不带单引号的Unix时间戳格式化。 +- 故障转移支持 `remote` 当某些副本缺少请求的表时,表函数。 +- 运行时可以在命令行中复盖配置设置 `clickhouse-server`. 示例: `clickhouse-server -- --logger.level=information`. +- 实施了 `empty` 从功能 `FixedString` 参数:如果字符串完全由空字节组成,则函数返回1(zhang2014)。 +- 添加了 `listen_try`如果某些地址无法侦听,则在不退出的情况下侦听至少一个侦听地址的配置参数(对于禁用IPv4或IPv6支持的系统非常有用)。 +- 添加了 `VersionedCollapsingMergeTree` 表引擎。 +- 对于行和任意数字类型的支持 `library` 字典源. +- `MergeTree` 表可以在没有主键的情况下使用(您需要指定 `ORDER BY tuple()`). +- A `Nullable` 类型可以是 `CAST` 到非-`Nullable` 如果参数不是,则键入 `NULL`. +- `RENAME TABLE` 可以进行 `VIEW`. +- 添加了 `throwIf` 功能。 +- 添加了 `odbc_default_field_size` 选项,它允许您扩展从ODBC源加载的值的最大大小(默认情况下为1024)。 +- 该 `system.processes` 表和 `SHOW PROCESSLIST` 现在有 `is_cancelled` 和 `peak_memory_usage` 列。 + +#### 改进: {#improvements-15} + +- 结果的限制和配额不再应用于以下内容的中间数据 `INSERT SELECT` 查询或 `SELECT` 子查询。 +- 更少的虚假触发 `force_restore_data` 当检查的状态 `Replicated` 服务器启动时的表。 +- 添加了 `allow_distributed_ddl` 选项。 +- 表达式中不允许使用非确定性函数 `MergeTree` 表键。 +- 从替换文件 `config.d` 目录按字母顺序加载。 +- 的改进的性能 `arrayElement` 函数在常量多维数组的情况下,以空数组作为元素之一。 示例: `[[1], []][x]`. +- 当使用具有非常大的替换(例如,非常大的IP网络列表)的配置文件时,服务器现在启动速度更快。 +- 运行查询时,表值函数运行一次。 前情提要, `remote` 和 `mysql` 表值函数执行两次相同的查询以从远程服务器检索表结构。 +- 该 `MkDocs` 使用文档生成器。 +- 当您尝试删除表列时 `DEFAULT`/`MATERIALIZED` 取决于其他列的表达式,会抛出异常(zhang2014)。 +- 增加了解析文本格式的空行作为数字0的能力 `Float` 数据类型。 此功能以前可用,但在版本1.1.54342中丢失。 +- `Enum` 值可以用于 `min`, `max`, `sum` 和其他一些功能。 在这些情况下,它使用相应的数值。 此功能以前可用,但在版本1.1.54337中丢失。 +- 已添加 `max_expanded_ast_elements` 递归扩展别名后限制AST的大小。 + +#### 错误修复: {#bug-fixes-27} + +- 修复了错误地从子查询中删除不必要的列或未从包含以下内容的子查询中删除不必要列的情况 `UNION ALL`. +- 修正了合并的错误 `ReplacingMergeTree` 桌子 +- 在固定的同步插入 `Distributed` 表 (`insert_distributed_sync = 1`). +- 固定段错误的某些用途 `FULL` 和 `RIGHT JOIN` 在子查询中使用重复的列。 +- 固定段错误的某些用途 `replace_running_query` 和 `KILL QUERY`. +- 固定的顺序 `source` 和 `last_exception` 在列 `system.dictionaries` 桌子 +- 修正了一个错误,当 `DROP DATABASE` 查询没有删除带有元数据的文件。 +- 修正了 `DROP DATABASE` 查询为 `Dictionary` 数据库。 +- 固定的低精度 `uniqHLL12` 和 `uniqCombined` 功能基数大于100万个项目(Alex克斯Bocharov)。 +- 修复了在必要时计算隐式默认值,以便同时计算默认显式表达式 `INSERT` 查询(zhang2014)。 +- 修正了一个罕见的情况下,当一个查询 `MergeTree` 表不能完成(陈星-xc)。 +- 修正了运行时发生的崩溃 `CHECK` 查询为 `Distributed` 如果所有分片都是本地的(chenxing.xc)。 +- 修复了使用正则表达式的函数的轻微性能回归。 +- 修复了从复杂表达式创建多维数组时的性能回归。 +- 修正了一个错误,可能会导致一个额外的 `FORMAT` 部分出现在一个 `.sql` 具有元数据的文件。 +- 修复了导致 `max_table_size_to_drop` 尝试删除时应用的限制 `MATERIALIZED VIEW` 查看显式指定的表。 +- 修复了与旧客户端的不兼容性(旧客户端有时会发送数据 `DateTime('timezone')` 类型,他们不明白)。 +- 修复了阅读时的错误 `Nested` 使用以下方式添加的结构的列元素 `ALTER` 但是,这是空的旧分区,当这些列的条件移动到 `PREWHERE`. +- 修正了通过虚拟过滤表时的错误 `_table` 查询中的列 `Merge` 桌子 +- 修复了使用时的错误 `ALIAS` 列 `Distributed` 桌子 +- 修正了一个错误,使得动态编译不可能从聚合函数的查询 `quantile` 家人 +- 修复了查询执行管道中极少数情况下使用时发生的争用条件 `Merge` 具有大量表的表,并且当使用 `GLOBAL` 子查询。 +- 修复了将不同大小的数组传递给 `arrayReduce` 使用来自多个参数的聚合函数时的函数。 +- 禁止使用与查询 `UNION ALL` 在一个 `MATERIALIZED VIEW`. +- 修正了初始化过程中的错误 `part_log` 服务器启动时的系统表(默认情况下, `part_log` 被禁用)。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-10} + +- 删除了 `distributed_ddl_allow_replicated_alter` 选项。 默认情况下启用此行为。 +- 删除了 `strict_insert_defaults` 设置。 如果您使用此功能,请写入 `clickhouse-feedback@yandex-team.com`. +- 删除了 `UnsortedMergeTree` 引擎 + +### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102005602 {#clickhouse-release-1-1-54343-2018-02-05} + +- 在分布式DDL查询和分布式表的构造函数中添加了用于定义集群名称的宏支持: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. +- 现在像查询 `SELECT ... FROM table WHERE expr IN (subquery)` 使用处理 `table` 指数。 +- 在插入到复制表时改进了重复项的处理,因此它们不再减慢复制队列的执行速度。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682 {#clickhouse-release-1-1-54342-2018-01-22} + +此版本包含以前版本1.1.54337的错误修复: + +- 修正了1.1.54337中的回归:如果默认用户具有只读访问权限,则服务器拒绝启动消息 `Cannot create database in readonly mode`. +- 修正了1.1.54337中的回归:在具有systemd的系统上,无论配置如何,日志总是写入syslog;看门狗脚本仍然使用init。d。 +- 修正了1.1.54337中的回归:Docker映像中错误的默认配置。 +- 修正GraphiteMergeTree的非确定性行为(您可以在日志消息中看到它 `Data after merge is not byte-identical to the data on another replicas`). +- 修复了优化查询到复制表后可能导致合并不一致的错误(您可能会在日志消息中看到它 `Part ... intersects the previous part`). +- 当目标表中存在具体化列时,缓冲区表现在可以正常工作(by zhang2014)。 +- 修复了实现NULL的错误。 + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54337-2018-01-18} + +#### 新功能: {#new-features-17} + +- 增加了对多维数组和元组存储的支持 (`Tuple` 表中的数据类型)。 +- 支持表函数 `DESCRIBE` 和 `INSERT` 查询。 增加了对子查询的支持 `DESCRIBE`. 例: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. 支持 `INSERT INTO TABLE` 除了 `INSERT INTO`. +- 改进了对时区的支持。 该 `DateTime` 数据类型可以使用用于以文本格式进行分析和格式化的时区进行注释。 示例: `DateTime('Europe/Moscow')`. 当在函数中指定时区时 `DateTime` 参数,返回类型将跟踪时区,并且值将按预期显示。 +- 新增功能 `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. 该 `toRelativeHour`/`Minute`/`Second` 函数可以采用类型的值 `Date` 作为参数。 该 `now` 函数名称区分大小写。 +- 添加了 `toStartOfFifteenMinutes` 功能(基里尔Shvakov)。 +- 添加了 `clickhouse format` 用于格式化查询的工具。 +- 添加了 `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` 格式。 架构文件只能位于指定的目录中。 +- 增加了对配置替换的支持 (`incl` 和 `conf.d`)外部字典和模型的配置(帕维尔\*亚库宁)。 +- 添加了一列文档 `system.settings` 表(基里尔Shvakov)。 +- 添加了 `system.parts_columns` 表中的每个数据部分的列大小信息 `MergeTree` 桌子 +- 添加了 `system.models` 包含已加载信息的表 `CatBoost` 机器学习模型。 +- 添加了 `mysql` 和 `odbc` 表函数和对应 `MySQL` 和 `ODBC` 用于访问远程数据库的表引擎。 此功能处于测试阶段。 +- 增加了传递类型参数的可能性 `AggregateFunction` 为 `groupArray` 聚合函数(这样你就可以创建一些聚合函数的状态数组)。 +- 删除了对聚合函数组合器的各种组合的限制。 例如,您可以使用 `avgForEachIf` 以及 `avgIfForEach` 聚合函数,它们具有不同的行为。 +- 该 `-ForEach` 聚合函数combinator是针对多个参数的聚合函数的情况进行扩展的。 +- 增加了对聚合函数的支持 `Nullable` 即使是函数返回非参数的情况-`Nullable` 结果(添加Silviu Caragea的贡献)。 示例: `groupArray`, `groupUniqArray`, `topK`. +- 添加了 `max_client_network_bandwidth` 为 `clickhouse-client` (基里尔\*什瓦科夫)。 +- 用户与 `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). +- 增加了对使用多个消费者的支持 `Kafka` 引擎 扩展的配置选项 `Kafka` (Marek Vavruša). +- 添加了 `intExp3` 和 `intExp4` 功能。 +- 添加了 `sumKahan` 聚合函数。 +- 添加了to\*Number\*OrNull函数,其中\*Number\*是数字类型。 +- 增加了对 `WITH` a的子句 `INSERT SELECT` 查询(作者:zhang2014)。 +- 添加设置: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. 特别是,这些设置用于下载用于复制的数据部分。 如果网络过载,更改这些设置可以更快地进行故障转移。 +- 增加了对 `ALTER` 对于类型的表 `Null` (Anastasiya Tsarkova) +- 该 `reinterpretAsString` 函数扩展为连续存储在内存中的所有数据类型。 +- 添加了 `--silent` 选项的 `clickhouse-local` 工具 它禁止在stderr中打印查询执行信息。 +- 增加了对读取类型值的支持 `Date` 从使用单个数字而不是两个数字(Amos Bird)指定月份和/或月份日的格式的文本。 + +#### 性能优化: {#performance-optimizations} + +- 改进聚合函数的性能 `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` 从字符串参数。 +- 改进功能的性能 `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. +- 改进了解析和格式化的性能 `Date` 和 `DateTime` 以文本格式键入值。 +- 改进了解析浮点数的性能和精度。 +- 降低内存使用量 `JOIN` 在左部分和右部分具有不包含在相同名称的列的情况下 `USING` . +- 改进聚合函数的性能 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` 通过降低计算稳定性。 旧函数的名称下可用 `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. + +#### 错误修复: {#bug-fixes-28} + +- 固定数据重复数据删除运行后 `DROP` 或 `DETACH PARTITION` 查询。 在以前的版本中,删除分区并再次插入相同的数据不起作用,因为插入的块被认为是重复的。 +- 修复了可能导致错误解释的错误 `WHERE` 条款 `CREATE MATERIALIZED VIEW` 查询与 `POPULATE` . +- 修正了在使用 `root_path` 在参数 `zookeeper_servers` 配置。 +- 通过固定意外的结果 `Date` 论据 `toStartOfDay` . +- 修正了 `addMonths` 和 `subtractMonths` 函数和算术 `INTERVAL n MONTH` 在情况下,当结果有前一年。 +- 增加了缺少的支持 `UUID` 数据类型 `DISTINCT` , `JOIN` ,和 `uniq` 聚合函数和外部字典(叶夫根尼伊万诺夫)。 支持 `UUID` 仍然是不完整的。 +- 固定 `SummingMergeTree` 行为的情况下,当行相加为零。 +- 各种修复 `Kafka` engine (Marek Vavruša). +- 修正了不正确的行为 `Join` 表引擎(阿莫斯鸟)。 +- 修复了FreeBSD和OS X下不正确的分配器行为。 +- 该 `extractAll` 函数现在支持空匹配。 +- 修复了阻止使用的错误 `libressl` 而不是 `openssl` . +- 修正了 `CREATE TABLE AS SELECT` 从临时表查询。 +- 修复了更新复制队列的非原子性。 这可能导致副本在服务器重新启动之前不同步。 +- 修正了可能的溢出 `gcd` , `lcm` 和 `modulo` (`%` 运营商)(Maks Skorokhod)。 +- `-preprocessed` 现在更改后创建文件 `umask` (`umask` 可以在配置中更改)。 +- 修正了部分的背景检查中的错误 (`MergeTreePartChecker` )使用自定义分区密钥时。 +- 元组的固定解析(的值 `Tuple` 数据类型)的文本格式。 +- 改进了有关传递到的不兼容类型的错误消息 `multiIf` , `array` 和其他一些功能。 +- 重新设计的支持 `Nullable` 类型。 修复了可能导致服务器崩溃的错误。 修正了与几乎所有其他错误 `NULL` 支持:insert SELECT中的类型转换不正确,HAVING和PREWHERE中对Nullable的支持不足, `join_use_nulls` 模式,可以为Null的类型作为参数 `OR` 操作员等。 +- 修正了与数据类型的内部语义相关的各种错误。 例子:不必要的总结 `Enum` 输入字段 `SummingMergeTree` ;对齐 `Enum` 类型 `Pretty` 格式等。 +- 对复合列的允许组合进行更严格的检查。 +- 修复了指定一个非常大的参数时的溢出 `FixedString` 数据类型。 +- 修正了一个错误 `topK` 一般情况下的聚合函数。 +- 在聚合函数的n元变体的参数中添加了对数组大小相等性的缺失检查。 `-Array` combinator +- 修正了一个错误 `--pager` 为 `clickhouse-client` (作者:ks1322)。 +- 固定的精度 `exp10` 功能。 +- 固定的行为 `visitParamExtract` 功能更好地符合文档。 +- 修复了指定不正确的数据类型时的崩溃。 +- 固定的行为 `DISTINCT` 在所有列都是常量的情况下。 +- 在使用的情况下固定的查询格式 `tupleElement` 使用复数常量表达式作为元组元素索引的函数。 +- 修正了一个错误 `Dictionary` 表 `range_hashed` 字典 +- 修正了导致结果中的过多行的错误 `FULL` 和 `RIGHT JOIN` (阿莫斯鸟)。 +- 修复了在创建和删除临时文件时的服务器崩溃 `config.d` 配置重新加载期间的目录。 +- 修正了 `SYSTEM DROP DNS CACHE` 查询:缓存已刷新,但群集节点的地址未更新。 +- 固定的行为 `MATERIALIZED VIEW` 执行后 `DETACH TABLE` for the table under the view (Marek Vavruša). + +#### 构建改进: {#build-improvements-4} + +- 该 `pbuilder` 工具用于构建。 构建过程几乎完全独立于构建主机环境。 +- 单个构建用于不同的操作系统版本。 软件包和二进制文件已经与各种Linux系统兼容。 +- 添加了 `clickhouse-test` 包。 它可用于运行功能测试。 +- 现在可以将源代码包发布到存储库。 它可以用来在不使用GitHub的情况下重现构建。 +- 增加了有限的集成与特拉维斯CI。 由于Travis中的构建时间限制,仅测试调试构建并运行有限的测试子集。 +- 增加了对 `Cap'n'Proto` 在默认构建中。 +- 更改文档来源的格式 `Restricted Text` 到 `Markdown`. +- 增加了对 `systemd` (弗拉基米尔\*斯米尔诺夫)。 默认情况下,由于与某些操作系统映像不兼容,它被禁用,并且可以手动启用。 +- 用于动态代码生成, `clang` 和 `lld` 嵌入到 `clickhouse` 二进制 它们也可以被调用为 `clickhouse clang` 和 `clickhouse lld` . +- 从代码中删除GNU扩展的使用。 启用 `-Wextra` 选项。 当与建设 `clang` 默认值为 `libc++` 而不是 `libstdc++`. +- 提取 `clickhouse_parsers` 和 `clickhouse_common_io` 库,以加快各种工具的构建。 + +#### 向后不兼容的更改: {#backward-incompatible-changes-11} + +- 标记的格式 `Log` 键入包含以下内容的表 `Nullable` 列以向后不兼容的方式进行了更改。 如果你有这些表,你应该将它们转换为 `TinyLog` 在启动新服务器版本之前键入。 要做到这一点,替换 `ENGINE = Log` 与 `ENGINE = TinyLog` 在相应的 `.sql` 文件中的 `metadata` 目录。 如果你的桌子没有 `Nullable` 列或表的类型不是 `Log`,那么你什么都不需要做。 +- 删除了 `experimental_allow_extended_storage_definition_syntax` 设置。 现在,此功能默认启用。 +- 该 `runningIncome` 函数重命名为 `runningDifferenceStartingWithFirstvalue` 为了避免混confusion。 +- 删除了 `FROM ARRAY JOIN arr` 在FROM with no table(Amos Bird)之后直接指定数组连接时的语法。 +- 删除了 `BlockTabSeparated` 仅用于演示目的的格式。 +- 更改聚合函数的状态格式 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. 如果您已将这些聚合函数的状态存储在表中(使用 `AggregateFunction` 数据类型或具体化视图与相应的状态),请写信给clickhouse-feedback@yandex-team.com. +- 在以前的服务器版本中,有一个未记录的功能:如果聚合函数依赖于参数,则仍然可以在AggregateFunction数据类型中指定它而不带参数。 示例: `AggregateFunction(quantiles, UInt64)` 而不是 `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. 此功能已丢失。 虽然它没有记录,但我们计划在未来的版本中再次支持它。 +- 枚举数据类型不能用于最小/最大聚合函数。 这种能力将在下一个版本中返回。 + +#### 升级时请注意: {#please-note-when-upgrading} + +- 当在群集上执行滚动更新时,当某些副本运行旧版本的ClickHouse,而某些副本运行新版本时,复制会暂时停止,并且消息 `unknown parameter 'shard'` 出现在日志中。 更新集群的所有副本后,复制将继续。 +- 如果群集服务器上运行不同版本的ClickHouse,则使用以下函数的分布式查询可能会产生不正确的结果: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. 您应该更新所有群集节点。 + +## [更新日志2017](./2017.md#clickhouse-release-1-1-54327-2017-12-21) {#changelog-for-2017} diff --git a/docs/zh/whats-new/changelog/2019.md b/docs/zh/whats-new/changelog/2019.md new file mode 100644 index 00000000000..154c92c1d23 --- /dev/null +++ b/docs/zh/whats-new/changelog/2019.md @@ -0,0 +1,2074 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_priority: 77 +toc_title: '2019' +--- + +## ClickHouse释放19.17 {#clickhouse-release-v19-17} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-v19-17-6-36-2019-12-27} + +#### 错误修复 {#bug-fix} + +- 在解压缩固定潜在的缓冲区溢出。 恶意用户可以传递制造的压缩数据,可能导致缓冲区后读取。 这个问题是由Yandex信息安全团队的Eldar Zaitov发现的。 [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了可能的服务器崩溃 (`std::terminate`)当服务器不能发送或写入JSON或XML格式的数据与字符串数据类型的值(需要UTF-8验证),或者当压缩结果数据与Brotli算法或在其他一些罕见的情况下。 [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 从clickhouse源固定字典 `VIEW`,现在阅读这样的字典不会导致错误 `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复了用户中指定的host\_regexp是否允许客户端主机的检查。xml [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- `RENAME TABLE` 对于分布式表,现在在发送到分片之前重命名包含插入数据的文件夹。 这解决了连续重命名的问题 `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) +- `range_hashed` DDL查询创建的外部字典现在允许任意数字类型的范围。 [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([阿利沙平](https://github.com/alesapin)) +- 固定 `INSERT INTO table SELECT ... FROM mysql(...)` 表功能。 [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) +- 修复段错误 `INSERT INTO TABLE FUNCTION file()` 同时插入到一个不存在的文件。 现在在这种情况下,文件将被创建,然后插入将被处理。 [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) +- 修正了聚合位图和标量位图相交时的位图和错误。 [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([黄月](https://github.com/moon03432)) +- 修复段错误时 `EXISTS` 查询没有使用 `TABLE` 或 `DICTIONARY` 预选赛,就像 `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 函数的固定返回类型 `rand` 和 `randConstant` 在可为空的参数的情况下。 现在函数总是返回 `UInt32` 而且从来没有 `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 固定 `DROP DICTIONARY IF EXISTS db.dict`,现在它不会抛出异常,如果 `db` 根本不存在 [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 如果由于服务器崩溃而未完全删除表,服务器将尝试恢复并加载它 [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) +- 修正了一个简单的计数查询分布式表,如果有两个以上的分片本地表。 [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) +- 修正了导致DB::BlockStreamProfileInfo::calculateRowsBeforeLimit数据竞赛的错误() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) +- 固定 `ALTER table MOVE part` 在合并指定部件后立即执行,这可能导致移动指定部件合并到的部件。 现在它正确地移动指定的部分。 [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 字典的表达式现在可以指定为字符串。 这对于从非ClickHouse源中提取数据时计算属性非常有用,因为它允许对这些表达式使用非ClickHouse语法。 [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([阿利沙平](https://github.com/alesapin)) +- 修正了一个非常罕见的比赛 `clickhouse-copier` 由于ZXid的溢出。 [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([丁香飞](https://github.com/dingxiangfei2009)) +- 修复了查询失败后的错误(由于 “Too many simultaneous queries” 例如)它不会读取外部表信息,并且 + 下一个请求会将此信息解释为下一个查询的开始,导致如下错误 `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) +- 避免空取消引用后 “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) +- 恢复对所有ICU区域设置的支持,添加对常量表达式应用排序规则的能力,并将语言名称添加到系统。排序规则表。 [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([阿利沙平](https://github.com/alesapin)) +- 用于读取的流数 `StorageFile` 和 `StorageHDFS` 现在是有限的,以避免超过内存限制。 [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([阿利沙平](https://github.com/alesapin)) +- 固定 `CHECK TABLE` 查询为 `*MergeTree` 表没有关键. [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([阿利沙平](https://github.com/alesapin)) +- 如果没有突变,则从部件名称中删除突变编号。 这种删除提高了与旧版本的兼容性。 [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([阿利沙平](https://github.com/alesapin)) +- 修复了某些附加部分因data\_version大于表突变版本而跳过突变的问题。 [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([余志昌](https://github.com/yuzhichang)) +- 允许在将部件移动到其他设备后使用冗余副本启动服务器。 [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 修正了错误 “Sizes of columns doesn’t match” 使用聚合函数列时可能会出现。 [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) +- 现在在使用WITH TIES和LIMIT BY的情况下,将抛出一个异常。 现在可以使用TOP with LIMIT BY。 [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) +- 修复字典重新加载,如果它有 `invalidate_query`,停止更新,并在以前的更新尝试一些异常。 [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([阿利沙平](https://github.com/alesapin)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-v19-17-4-11-2019-11-22} + +#### 向后不兼容的更改 {#backward-incompatible-change} + +- 使用列而不是AST来存储标量子查询结果以获得更好的性能。 设置 `enable_scalar_subquery_optimization` 在19.17中添加,默认情况下启用。 它会导致以下错误 [这](https://github.com/ClickHouse/ClickHouse/issues/7851) 在从以前的版本升级到19.17.2或19.17.3期间。 默认情况下,19.17.4中禁用此设置,以便可以从19.16及更早版本升级而不会出现错误。 [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([阿莫斯鸟](https://github.com/amosbird)) + +#### 新功能 {#new-feature} + +- 添加使用DDL查询创建字典的功能。 [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([阿利沙平](https://github.com/alesapin)) +- 赂眉露\>\> `bloom_filter` 支持的索引类型 `LowCardinality` 和 `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 添加功能 `isValidJSON` 要检查传递的字符串是否是有效的json。 [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([Vdimir](https://github.com/Vdimir)) +- 执行 `arrayCompact` 功能 [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([备忘录](https://github.com/Joeywzr)) +- 创建函数 `hex` 对于十进制数。 它的工作原理如下 `hex(reinterpretAsString())`,但不会删除最后的零字节。 [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([米哈伊尔\*科罗托夫](https://github.com/millb)) +- 添加 `arrayFill` 和 `arrayReverseFill` 函数,用数组中其他元素替换它们前面/后面的元素。 [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([hcz](https://github.com/hczhcz)) +- 添加 `CRC32IEEE()`/`CRC64()` 碌莽禄support: [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([Azat Khuzhin](https://github.com/azat)) +- 执行 `char` 功能类似于一个 [mysql](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([sundyli](https://github.com/sundy-li)) +- 添加 `bitmapTransform` 功能。 它将位图中的值数组转换为另一个值数组,结果是一个新的位图 [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([余志昌](https://github.com/yuzhichang)) +- 已实施 `javaHashUTF16LE()` 功能 [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([achimbab](https://github.com/achimbab)) +- 添加 `_shard_num` 分布式引擎的虚拟列 [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([Azat Khuzhin](https://github.com/azat)) + +#### 实验特点 {#experimental-feature} + +- 支持处理器(新的查询执行管道) `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) + +#### 错误修复 {#bug-fix-1} + +- 修复不正确的浮点解析 `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) +- 修复启用trace\_log时可能发生的罕见死锁。 [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([filimonov](https://github.com/filimonov)) +- 当生成Kafka表时有任何从中选择的Mv时,防止消息重复 [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([伊万](https://github.com/abyss7)) +- 支持 `Array(LowCardinality(Nullable(String)))` 在 `IN`. 决定 [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([achimbab](https://github.com/achimbab)) +- 添加处理 `SQL_TINYINT` 和 `SQL_BIGINT`,并修复处理 `SQL_FLOAT` ODBC桥中的数据源类型。 [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) +- 修复聚合 (`avg` 和分位数)在空的十进制列 [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([安德烈\*科尼亚耶夫](https://github.com/akonyaev90)) +- 修复 `INSERT` 变成分布式 `MATERIALIZED` 列 [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) +- 赂眉露\>\> `MOVE PARTITION` 如果分区的某些部分已经在目标磁盘或卷上,则可以工作 [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 修正了在突变过程中无法创建硬链接的错误 `ReplicatedMergeTree` 在多磁盘配置。 [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 修复了当整个部分保持不变并且在另一个磁盘上找到最佳空间时,MergeTree上出现突变的错误 [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 修正错误 `keep_free_space_ratio` 未从磁盘读取配置 [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 修正错误与表只包含 `Tuple` 列或具有复杂路径的列。 修复 [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([阿利沙平](https://github.com/alesapin)) +- 在max\_memory\_usage限制中不考虑缓冲区引擎的内存 [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([Azat Khuzhin](https://github.com/azat)) +- 修复最终标记用法 `MergeTree` 表排序 `tuple()`. 在极少数情况下,它可能会导致 `Can't adjust last granule` 选择时出错。 [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复了需要上下文操作(例如json函数)的谓词突变中的错误,这可能会导致崩溃或奇怪的异常。 [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([阿利沙平](https://github.com/alesapin)) +- 修复转义的数据库和表名称不匹配 `data/` 和 `shadow/` 目录 [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([Alexander Burmak](https://github.com/Alex-Burmak)) +- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. 在这种情况下修复崩溃。 [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复 `Not found column in block` 当加入表达式与权利或完全连接。 [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([Artem Zuikov](https://github.com/4ertus2)) +- 再次尝试修复无限循环 `PrettySpace` 格式 [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([Olga Khvostikova](https://github.com/stavrolia)) +- 修复bug `concat` 函数时,所有的参数 `FixedString` 同样大小的 [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([阿利沙平](https://github.com/alesapin)) +- 在定义S3,URL和HDFS存储时使用1个参数的情况下修复了异常。 [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 修复查询视图的InterpreterSelectQuery的范围 [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([Azat Khuzhin](https://github.com/azat)) + +#### 改进 {#improvement} + +- `Nullable` ODBC-bridge可识别的列和正确处理的NULL值 [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 以原子方式写入分布式发送的当前批次 [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([Azat Khuzhin](https://github.com/azat)) +- 如果我们无法在查询中检测到列名称的表,则引发异常。 [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([Artem Zuikov](https://github.com/4ertus2)) +- 添加 `merge_max_block_size` 设置为 `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([Artem Zuikov](https://github.com/4ertus2)) +- 查询与 `HAVING` 而没有 `GROUP BY` 假设按常量分组。 所以, `SELECT 1 HAVING 1` 现在返回一个结果。 [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([阿莫斯鸟](https://github.com/amosbird)) +- 支持解析 `(X,)` 作为类似python的元组。 [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([阿莫斯鸟](https://github.com/amosbird)) +- 赂眉露\>\> `range` 函数行为几乎像pythonic。 [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([sundyli](https://github.com/sundy-li)) +- 添加 `constraints` 列到表 `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- Tcp处理程序的更好的Null格式,以便可以使用 `select ignore() from table format Null` 通过clickhouse-client进行性能测量 [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([阿莫斯鸟](https://github.com/amosbird)) +- 查询如 `CREATE TABLE ... AS (SELECT (1, 2))` 正确解析 [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([hcz](https://github.com/hczhcz)) + +#### 性能改进 {#performance-improvement} + +- 改进了对短字符串键的聚合性能。 [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([Alexander Kuzmenkov](https://github.com/akuzm), [阿莫斯鸟](https://github.com/amosbird)) +- 运行另一次语法/表达式分析以在常量谓词折叠后获得潜在的优化。 [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([阿莫斯鸟](https://github.com/amosbird)) +- 使用存储元信息来评估琐碎 `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([阿莫斯鸟](https://github.com/amosbird), [阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 矢量化处理 `arrayReduce` 与聚合器类似 `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([阿莫斯鸟](https://github.com/amosbird)) +- 在性能的小改进 `Kafka` 消费 [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([伊万](https://github.com/abyss7)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement} + +- 添加对交叉编译的支持到CPU架构AARCH64。 重构打包器脚本。 [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([伊万](https://github.com/abyss7)) +- 在构建软件包时,将darwin-x86\_64和linux-aarch64工具链解压缩到已挂载的Docker卷中 [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([伊万](https://github.com/abyss7)) +- 更新二进制打包器的Docker映像 [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([伊万](https://github.com/abyss7)) +- 修复了MacOS Catalina上的编译错误 [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([欧内斯特\*波列塔耶夫](https://github.com/ernestp)) +- 查询分析逻辑中的一些重构:将复杂的类拆分为几个简单的类。 [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复没有子模块的构建 [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([proller](https://github.com/proller)) +- 更好 `add_globs` 在CMake文件中 [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([阿莫斯鸟](https://github.com/amosbird)) +- 删除硬编码路径 `unwind` 目标 [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([Konstantin Podshumok](https://github.com/podshumok)) +- 允许在没有ssl的情况下使用mysql格式 [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([proller](https://github.com/proller)) + +#### 其他 {#other} + +- 为ClickHouse SQL方言添加了ANTLR4语法 [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +## ClickHouse释放19.16 {#clickhouse-release-v19-16} + +#### ClickHouse释放19.16.14.65,2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} + +- 修复了多个参数(超过10)的三元逻辑运算批量计算中的错误。 [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([亚历山大\*卡扎科夫](https://github.com/Akazz))这个错误修正是由Altinity的特殊要求回移到版本19.16的。 + +#### ClickHouse释放19.16.14.65,2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} + +- 修复分布式子查询与旧版本的CH不兼容。 修复 [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) + [(tabplubix)](https://github.com/tavplubix) +- 执行时 `CREATE` 查询,在存储引擎参数中折叠常量表达式。 将空数据库名称替换为当前数据库。 修复 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). 还修复检查本地地址 `ClickHouseDictionarySource`. + [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) +- 现在背景合并 `*MergeTree` 表引擎家族更准确地保留存储策略卷顺序。 + [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 防止丢失数据 `Kafka` 在极少数情况下,在读取后缀之后但在提交之前发生异常。 修复 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). 相关: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) + [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(菲利蒙诺夫)](https://github.com/filimonov) +- 修复尝试使用/删除时导致服务器终止的错误 `Kafka` 使用错误的参数创建的表。 修复 [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). 结合 [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). + [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(菲利蒙诺夫)](https://github.com/filimonov) +- 允许使用 `MaterializedView` 与上面的子查询 `Kafka` 桌子 + [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([filimonov](https://github.com/filimonov)) + +#### 新功能 {#new-feature-1} + +- 添加 `deduplicate_blocks_in_dependent_materialized_views` 用于控制具有实例化视图的表中幂等插入的行为的选项。 这个新功能是由Altinity的特殊要求添加到错误修正版本中的。 + [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-v19-16-2-2-2019-10-30} + +#### 向后不兼容的更改 {#backward-incompatible-change-1} + +- 为count/counIf添加缺失的验证。 + [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) + [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([Vdimir](https://github.com/Vdimir)) +- 删除旧版 `asterisk_left_columns_only` 设置(默认情况下禁用)。 + [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([阿尔乔姆 + Zuikov](https://github.com/4ertus2)) +- 模板数据格式的格式字符串现在在文件中指定。 + [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([tavplubix](https://github.com/tavplubix)) + +#### 新功能 {#new-feature-2} + +- 引入uniqCombined64()来计算大于UINT\_MAX的基数。 + [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), + [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([Azat + Khuzhin](https://github.com/azat)) +- 支持数组列上的Bloom filter索引。 + [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) + ([achimbab](https://github.com/achimbab)) +- 添加函数 `getMacro(name)` 返回与相应值的字符串 `` + 从服务器配置. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) + ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 为基于HTTP源的字典设置两个配置选项: `credentials` 和 + `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([纪尧姆 + Tassery](https://github.com/YiuRULE)) +- 添加新的ProfileEvent `Merge` 这计算启动的背景合并的数量。 + [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([米哈伊尔 + 科罗托夫](https://github.com/millb)) +- 添加返回完全限定域名的fullHostName函数。 + [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) + [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([sundyli](https://github.com/sundy-li)) +- 添加功能 `arraySplit` 和 `arrayReverseSplit` 通过拆分数组 “cut off” + 条件。 它们在时间序列处理中非常有用。 + [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([hcz](https://github.com/hczhcz)) +- 添加返回multiMatch函数系列中所有匹配索引的数组的新函数。 + [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([Danila + 库特宁](https://github.com/danlark1)) +- 添加新的数据库引擎 `Lazy` 即针对存储大量小日志进行了优化 + 桌子 [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([尼基塔 + Vasilev](https://github.com/nikvas0)) +- 为位图列添加聚合函数groupBitmapAnd,-或-Xor。 [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([知昌 + 阿优](https://github.com/yuzhichang)) +- 添加聚合函数组合器-OrNull和-OrDefault,它们返回null + 或默认值时没有任何聚合。 + [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) + ([hcz](https://github.com/hczhcz)) +- 引入支持自定义转义的CustomSeparated数据格式 + 分隔符规则。 [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) + ([tavplubix](https://github.com/tavplubix)) +- 支持Redis作为外部字典的来源。 [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([comunodi](https://github.com/comunodi), [安东 + 波波夫](https://github.com/CurtizJ)) + +#### 错误修复 {#bug-fix-2} + +- 修复错误的查询结果,如果它有 `WHERE IN (SELECT ...)` 部分和 `optimize_read_in_order` 是 + 使用。 [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([安东 + 波波夫](https://github.com/CurtizJ)) +- 禁用MariaDB身份验证插件,这取决于项目之外的文件。 + [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([尤里 + 巴拉诺夫](https://github.com/yurriy)) +- 修复异常 `Cannot convert column ... because it is constant but values of constants are different in source and result` 这可能很少发生,当功能 `now()`, `today()`, + `yesterday()`, `randConstant()` 被使用。 + [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([尼古拉 + Kochetov](https://github.com/KochetovNicolai)) +- 修复了使用HTTP保持活动超时而不是TCP保持活动超时的问题。 + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([瓦西里 + Nemkov](https://github.com/Enmk)) +- 修复了groupBitmapOr中的分段错误(问题 [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). + [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([知昌 + 阿优](https://github.com/yuzhichang)) +- 对于实例化视图,在写入所有数据之后调用kafka的提交。 + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([伊万](https://github.com/abyss7)) +- 修复错误 `duration_ms` 值 `system.part_log` 桌子 这是十次关闭。 + [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([弗拉基米尔 + Chebotarev](https://github.com/excitoon)) +- 快速修复解决实时查看表中的崩溃并重新启用所有实时查看测试。 + [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) + ([vzakaznikov](https://github.com/vzakaznikov)) +- 在MergeTree部件的最小/最大索引中正确序列化NULL值。 + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([亚历山大 + 库兹门科夫](https://github.com/akuzm)) +- 不要把虚拟列。创建表时的sql元数据 `CREATE TABLE AS`. + [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([伊万](https://github.com/abyss7)) +- 修复分段故障 `ATTACH PART` 查询。 + [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) + ([阿利沙平](https://github.com/alesapin)) +- 修复了子查询中empty和empty优化给出的某些查询的错误结果 + INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([尼古拉 + Kochetov](https://github.com/KochetovNicolai)) +- 修复LIVE VIEW getHeader()方法中的AddressSanitizer错误。 + [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) + ([vzakaznikov](https://github.com/vzakaznikov)) + +#### 改进 {#improvement-1} + +- 在queue\_wait\_max\_ms等待发生的情况下添加消息。 + [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([Azat + Khuzhin](https://github.com/azat)) +- 制作设置 `s3_min_upload_part_size` 表级别。 + [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([弗拉基米尔 + Chebotarev](https://github.com/excitoon)) +- 检查Ttl在StorageFactory。 [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) + ([sundyli](https://github.com/sundy-li)) +- 在部分合并连接(优化)中压缩左侧块。 + [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([阿尔乔姆 + Zuikov](https://github.com/4ertus2)) +- 不允许在复制表引擎的突变中使用非确定性函数,因为这 + 可能会在副本之间引入不一致。 + [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([亚历山大 + 卡扎科夫](https://github.com/Akazz)) +- 将异常堆栈跟踪转换为字符串时禁用内存跟踪器。 它可以防止损失 + 类型的错误消息 `Memory limit exceeded` 在服务器上,这导致了 `Attempt to read after eof` 客户端上的例外。 [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) + ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 其他格式改进。 决定 + [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), + [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), + [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), + [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) + [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) + ([tavplubix](https://github.com/tavplubix)) +- ClickHouse将忽略IN运算符右侧不可转换为左侧的值 + side type. Make it work properly for compound types – Array and Tuple. + [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([亚历山大 + 库兹门科夫](https://github.com/akuzm)) +- 支持ASOF加入缺失的不平等。 它可以加入小于或等于变体和严格 + 在语法上,ASOF列的变体越来越多。 + [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([阿尔乔姆 + Zuikov](https://github.com/4ertus2)) +- 优化部分合并连接。 [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) + ([Artem Zuikov](https://github.com/4ertus2)) +- 不要在uniqCombined函数中使用超过98K的内存。 + [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), + [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([Azat + Khuzhin](https://github.com/azat)) +- 在PartialMergeJoin中刷新磁盘上右连接表的部分(如果没有足够的 + 记忆)。 需要时加载数据。 [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) + ([Artem Zuikov](https://github.com/4ertus2)) + +#### 性能改进 {#performance-improvement-1} + +- 通过避免数据重复加快使用const参数的joinGet。 + [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([阿莫斯 + 鸟](https://github.com/amosbird)) +- 如果子查询为空,请提前返回。 + [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) +- 优化值中SQL表达式的解析。 + [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) + ([tavplubix](https://github.com/tavplubix)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-1} + +- 禁用交叉编译到Mac OS的一些贡献。 + [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([伊万](https://github.com/abyss7)) +- 为clickhouse\_common\_io添加与PocoXML缺少的链接。 + [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([Azat + Khuzhin](https://github.com/azat)) +- 在clickhouse-test中接受多个测试过滤器参数。 + [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([亚历山大 + 库兹门科夫](https://github.com/akuzm)) +- 为ARM启用musl和jemalloc。 [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) + ([阿莫斯鸟](https://github.com/amosbird)) +- 已添加 `--client-option` 参数 `clickhouse-test` 将其他参数传递给客户端。 + [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([尼古拉 + Kochetov](https://github.com/KochetovNicolai)) +- 在rpm软件包升级时保留现有配置。 + [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) + ([filimonov](https://github.com/filimonov)) +- 修复PVS检测到的错误。 [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([阿尔乔姆 + Zuikov](https://github.com/4ertus2)) +- 修复达尔文的构建。 [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) + ([伊万](https://github.com/abyss7)) +- glibc2.29兼容性. [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([阿莫斯 + 鸟](https://github.com/amosbird)) +- 确保dh\_clean不会触及潜在的源文件。 + [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([阿莫斯 + 鸟](https://github.com/amosbird)) +- 尝试避免从altinity rpm更新时发生冲突-它有单独打包的配置文件 + 在clickhouse服务器-常见. [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) + ([filimonov](https://github.com/filimonov)) +- 优化一些头文件,以便更快地重建。 + [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), + [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([亚历山大 + 库兹门科夫](https://github.com/akuzm)) +- 添加日期和日期时间的性能测试。 [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([瓦西里 + Nemkov](https://github.com/Enmk)) +- 修复一些包含非确定性突变的测试。 + [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([亚历山大 + 卡扎科夫](https://github.com/Akazz)) +- 添加构建与MemorySanitizer CI。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) + ([Alexander Kuzmenkov](https://github.com/akuzm)) +- 避免在MetricsTransmitter中使用未初始化的值。 + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat + Khuzhin](https://github.com/azat)) +- 修复MemorySanitizer发现的字段中的一些问题。 + [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), + [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([亚历山大 + 库兹门科夫](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) + ([阿莫斯鸟](https://github.com/amosbird)) +- 修复murmurhash32中未定义的行为。 [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([阿莫斯 + 鸟](https://github.com/amosbird)) +- 修复StoragesInfoStream中未定义的行为。 [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) + ([tavplubix](https://github.com/tavplubix)) +- 固定常量表达式折叠外部数据库引擎(MySQL,ODBC,JDBC)。 在上一页 + 版本它不适用于多个常量表达式,并且根本不适用于日期, + 日期时间和UUID。 这修复 [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) + ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在访问no\_users\_thread变量时修复实时查看中的ThreadSanitizer数据竞争错误。 + [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) + ([vzakaznikov](https://github.com/vzakaznikov)) +- 在libcommon中摆脱malloc符号 + [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), + [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([阿莫斯 + 鸟](https://github.com/amosbird)) +- 添加全局标志ENABLE\_LIBRARY以禁用所有库。 + [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) + ([proller](https://github.com/proller)) + +#### 代码清理 {#code-cleanup} + +- 概括配置存储库以准备字典的DDL。 [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) + ([阿利沙平](https://github.com/alesapin)) +- 解析器字典DDL没有任何语义。 + [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) + ([阿利沙平](https://github.com/alesapin)) +- 将ParserCreateQuery拆分为不同的较小的解析器。 + [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) + ([阿利沙平](https://github.com/alesapin)) +- 在外部字典附近进行小型重构和重命名。 + [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) + ([阿利沙平](https://github.com/alesapin)) +- 重构一些代码以准备基于角色的访问控制。 [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([维塔利 + 巴拉诺夫](https://github.com/vitlibar)) +- DatabaseOrdinary代码中的一些改进。 + [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([尼基塔 + Vasilev](https://github.com/nikvas0)) +- 不要在哈希表的find()和emplace()方法中使用迭代器。 + [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([亚历山大 + 库兹门科夫](https://github.com/akuzm)) +- 修正getMultipleValuesFromConfig的情况下,当参数根不为空。 [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) + ([米哈伊尔\*科罗托夫](https://github.com/millb)) +- 删除一些复制粘贴(TemporaryFile和TemporaryFileStream) + [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([阿尔乔姆 + Zuikov](https://github.com/4ertus2)) +- 改进了代码的可读性一点点 (`MergeTreeData::getActiveContainingPart`). + [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([弗拉基米尔 + Chebotarev](https://github.com/excitoon)) +- 等待使用本地对象的所有计划作业,如果 `ThreadPool::schedule(...)` 投掷 + 一个例外 重命名 `ThreadPool::schedule(...)` 到 `ThreadPool::scheduleOrThrowOnError(...)` 和 + 修复注释,使明显的,它可能会抛出。 + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) + ([tavplubix](https://github.com/tavplubix)) + +## ClickHouse释放19.15 {#clickhouse-release-19-15} + +### ClickHouse释放19.15.4.10,2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} + +#### 错误修复 {#bug-fix-3} + +- 增加了sql\_tinyint和SQL\_BIGINT的处理,并修复了ODBC桥中SQL\_FLOAT数据源类型的处理。 + [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) +- 允许在移动分区中的目标磁盘或卷上有一些部分。 + [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 通过ODBC桥固定可空列中的NULL值。 + [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 固定插入到具体化列的分布式非本地节点。 + [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) +- 固定函数getMultipleValuesFromConfig。 + [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([米哈伊尔\*科罗托夫](https://github.com/millb)) +- 修复了使用HTTP保持活动超时而不是TCP保持活动超时的问题。 + [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 等待所有作业在异常时完成(修复罕见的段错误)。 + [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([tavplubix](https://github.com/tavplubix)) +- 在插入Kafka表时不要推送MVs。 + [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([伊万](https://github.com/abyss7)) +- 禁用异常堆栈的内存跟踪器。 + [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复了外部数据库转换查询中的错误代码。 + [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 避免在MetricsTransmitter中使用未初始化的值。 + [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat Khuzhin](https://github.com/azat)) +- 添加了用于测试的宏的示例配置 ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### ClickHouse释放19.15.3.6,2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} + +#### 错误修复 {#bug-fix-4} + +- 修正了哈希字典中的bad\_variant。 + ([阿利沙平](https://github.com/alesapin)) +- 修复了附加部件查询中分段故障的错误。 + ([阿利沙平](https://github.com/alesapin)) +- 固定时间计算 `MergeTreeData`. + ([Vladimir Chebotarev](https://github.com/excitoon)) +- 写作完成后明确提交给Kafka。 + [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([伊万](https://github.com/abyss7)) +- 在MergeTree部件的最小/最大索引中正确序列化NULL值。 + [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander Kuzmenkov](https://github.com/akuzm)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-15-2-2-2019-10-01} + +#### 新功能 {#new-feature-3} + +- 分层存储:支持使用MergeTree引擎对表使用多个存储卷。 可以将新数据存储在SSD上,并自动将旧数据移动到HDD。 ([示例](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([Igr](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([阿利沙平](https://github.com/alesapin)) +- 添加表函数 `input` 用于读取传入的数据 `INSERT SELECT` 查询。 [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([palasonic1](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([安东\*波波夫](https://github.com/CurtizJ)) +- 添加一个 `sparse_hashed` 字典布局,即在功能上等同于 `hashed` 布局,但更高效的内存。 它使用的内存减少了大约两倍,代价是较慢的值检索。 [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([Azat Khuzhin](https://github.com/azat)) +- 实现定义用户列表以访问字典的能力。 仅使用当前连接的数据库。 [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 添加 `LIMIT` 选项 `SHOW` 查询。 [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([Philipp Malkovsky](https://github.com/malkfilipp)) +- 添加 `bitmapSubsetLimit(bitmap, range_start, limit)` 函数,返回最小的子集 `limit` 设置中的值不小于 `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([余志昌](https://github.com/yuzhichang)) +- 添加 `bitmapMin` 和 `bitmapMax` 功能。 [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([余志昌](https://github.com/yuzhichang)) +- 添加功能 `repeat` 有关 [问题-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([弗林](https://github.com/ucasFL)) + +#### 实验特点 {#experimental-feature-1} + +- 实现(在内存中)不更改当前管道的合并联接变体。 结果按合并键进行部分排序。 设置 `partial_merge_join = 1` 要使用此功能。 合并联接仍在开发中。 [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([Artem Zuikov](https://github.com/4ertus2)) +- 添加 `S3` 发动机和表功能. 它仍在开发中(还没有身份验证支持)。 [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([Vladimir Chebotarev](https://github.com/excitoon)) + +#### 改进 {#improvement-2} + +- 从Kafka读取的每条消息都是以原子方式插入的。 这解决了Kafka引擎的几乎所有已知问题。 [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([伊万](https://github.com/abyss7)) +- 对分布式查询故障转移的改进。 缩短恢复时间,也是现在可配置的,可以看出 `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 直接支持枚举的数值 `IN` 科。 \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([dimarub2000](https://github.com/dimarub2000)) +- 支持(可选,默认情况下禁用)对URL存储进行重定向。 [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([maqroll](https://github.com/maqroll)) +- 当具有较旧版本的客户端连接到服务器时添加信息消息。 [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([Philipp Malkovsky](https://github.com/malkfilipp)) +- 删除在分布式表中发送数据的最大退避睡眠时间限制 [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([Azat Khuzhin](https://github.com/azat)) +- 添加将配置文件事件(计数器)与累积值发送到graphite的能力。 它可以在启用 `` 在服务器 `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([Azat Khuzhin](https://github.com/azat)) +- 添加自动转换类型 `T` 到 `LowCardinality(T)` 在类型的列中插入数据 `LowCardinality(T)` 在本机格式通过HTTP。 [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 添加使用功能的能力 `hex` 不使用 `reinterpretAsString` 为 `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([米哈伊尔\*科罗托夫](https://github.com/millb)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-2} + +- 将gdb-index添加到带有调试信息的clickhouse二进制文件。 这将加快启动时间 `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([阿利沙平](https://github.com/alesapin)) +- 加速deb包装与补丁dpkg-deb它使用 `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([阿利沙平](https://github.com/alesapin)) +- 设置 `enable_fuzzing = 1` 启用所有项目代码的libfuzzer检测功能。 [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([kyprizel](https://github.com/kyprizel)) +- 在CI中添加拆分构建烟雾测试。 [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([阿利沙平](https://github.com/alesapin)) +- 添加构建与MemorySanitizer CI。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([Alexander Kuzmenkov](https://github.com/akuzm)) +- 替换 `libsparsehash` 与 `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([Azat Khuzhin](https://github.com/azat)) + +#### 错误修复 {#bug-fix-5} + +- 修复了大型表上复杂键的索引分析的性能下降。 这修复了#6924。 [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复从Kafka空主题中选择时导致段错误的逻辑错误。 [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([伊万](https://github.com/abyss7)) +- 修复过早的MySQL连接关闭 `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- 返回对非常旧的Linux内核的支持(修复 [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复可能的数据丢失 `insert select` 在输入流中的空块的情况下进行查询。 \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复功能 `АrrayEnumerateUniqRanked` 在参数中使用空数组 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) +- 使用数组联接和全局子查询修复复杂的查询。 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([伊万](https://github.com/abyss7)) +- 修复 `Unknown identifier` 按顺序排列和按多个联接分组的错误 [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) +- 固定 `MSan` 执行函数时发出警告 `LowCardinality` 争论。 [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) + +#### 向后不兼容的更改 {#backward-incompatible-change-2} + +- 更改了位图\*聚合函数状态的序列化格式,以提高性能。 无法读取以前版本的位图\*的序列化状态。 [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([余志昌](https://github.com/yuzhichang)) + +## ClickHouse释放19.14 {#clickhouse-release-19-14} + +### ClickHouse释放19.14.7.15,2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} + +#### 错误修复 {#bug-fix-6} + +- 此版本还包含19.11.12.69的所有错误修复。 +- 修复了19.14和早期版本之间分布式查询的兼容性。 这修复 [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### ClickHouse释放19.14.6.12,2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} + +#### 错误修复 {#bug-fix-7} + +- 修复功能 `АrrayEnumerateUniqRanked` 在参数中使用空数组。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) +- 修复了查询中的子查询名称 `ARRAY JOIN` 和 `GLOBAL IN subquery` 用化名。 如果指定了外部表名,请使用子查询别名。 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([伊万](https://github.com/abyss7)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-3} + +- 修复 [拍打](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) 测试 `00715_fetch_merged_or_mutated_part_zookeeper` 通过将其重写为shell脚本,因为它需要等待突变应用。 [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) +- 修正了UBSan和MemSan功能失败 `groupUniqArray` 使用emtpy数组参数。 这是由于放置空 `PaddedPODArray` 因为没有调用零单元格值的构造函数,所以将其转换为哈希表零单元格。 [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([阿莫斯鸟](https://github.com/amosbird)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-14-3-3-2019-09-10} + +#### 新功能 {#new-feature-4} + +- `WITH FILL` 修饰符 `ORDER BY`. (继续 [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([安东\*波波夫](https://github.com/CurtizJ)) +- `WITH TIES` 修饰符 `LIMIT`. (继续 [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([安东\*波波夫](https://github.com/CurtizJ)) +- 解析无引号 `NULL` 文字为NULL(如果设置 `format_csv_unquoted_null_literal_as_null=1`). 如果此字段的数据类型不可为空,则使用默认值初始化null字段(如果设置 `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([tavplubix](https://github.com/tavplubix)) +- 支持表函数路径中的通配符 `file` 和 `hdfs`. 如果路径包含通配符,则表将为只读。 使用示例: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` 和 `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([Olga Khvostikova](https://github.com/stavrolia)) +- 新 `system.metric_log` 表存储的值 `system.events` 和 `system.metrics` 具有指定的时间间隔。 [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 允许将ClickHouse文本日志写入 `system.text_log` 桌子 [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在堆栈跟踪中显示私有符号(这是通过解析ELF文件的符号表来完成的)。 如果存在调试信息,则在堆栈跟踪中添加有关文件和行号的信息。 使用程序中存在的索引符号加速符号名称查找。 增加了新的SQL函数的反省: `demangle` 和 `addressToLine`. 重命名函数 `symbolizeAddress` 到 `addressToSymbol` 为了一致性。 功能 `addressToSymbol` 将返回错位的名称出于性能原因,你必须申请 `demangle`. 添加设置 `allow_introspection_functions` 默认情况下,这是关闭的。 [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 表函数 `values` (名称不区分大小写)。 它允许从读取 `VALUES` 建议的名单 [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). 示例: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) +- 增加了改变存储设置的功能。 语法: `ALTER TABLE MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([阿利沙平](https://github.com/alesapin)) +- 用于拆卸分离部件的支撑。 语法: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([tavplubix](https://github.com/tavplubix)) +- 表约束。 允许将约束添加到将在插入时检查的表定义。 [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 支持级联实例化视图。 [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([阿莫斯鸟](https://github.com/amosbird)) +- 默认情况下,打开查询探查器以每秒对每个查询执行线程进行一次采样。 [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 输入格式 `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([akonyaev90](https://github.com/akonyaev90)) +- 增加了两个新功能: `sigmoid` 和 `tanh` (这对于机器学习应用程序非常有用)。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 功能 `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` 检查给定的令牌是否在干草堆中。 Token是两个非字母数字ASCII字符(或干草堆的边界)之间的最大长度子串。 Token必须是常量字符串。 由tokenbf\_v1索引专业化支持。 [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 新功能 `neighbor(value, offset[, default_value])`. 允许在一个数据块中的列中达到上一个/下一个值。 [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([Alex Krash](https://github.com/alex-krash)) [6685365ab8c5b74f9650492c88a012596eb1b0c6](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341e2e4587a18065c2da1ca888c73389f48ce36c](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [Alexey Milovidov](https://github.com/alexey-milovidov) +- 创建了一个函数 `currentUser()`,返回授权用户的登录。 添加别名 `user()` 对于与MySQL的兼容性。 [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([Alex Krash](https://github.com/alex-krash)) +- 新的聚合函数 `quantilesExactInclusive` 和 `quantilesExactExclusive` 这是在提出 [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([dimarub2000](https://github.com/dimarub2000)) +- 功能 `bitmapRange(bitmap, range_begin, range_end)` 返回具有指定范围的新集(不包括 `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([余志昌](https://github.com/yuzhichang)) +- 功能 `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` 它创建了一系列精确的长串geohash盒复盖提供的区域。 [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 实现对插入查询的支持 `Kafka` 桌子 [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([伊万](https://github.com/abyss7)) +- 增加了对 `_partition` 和 `_timestamp` 虚拟列到Kafka引擎。 [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([伊万](https://github.com/abyss7)) +- 可以从中删除敏感数据 `query_log`,服务器日志,基于正则表达式的规则的进程列表。 [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([filimonov](https://github.com/filimonov)) + +#### 实验特点 {#experimental-feature-2} + +- 输入和输出数据格式 `Template`. 它允许为输入和输出指定自定义格式字符串。 [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([tavplubix](https://github.com/tavplubix)) +- 执行 `LIVE VIEW` 最初提出的表 [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898),准备 [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925),然后更新 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). 看 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) 详细描述。 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([vzakaznikov](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([vzakaznikov](https://github.com/vzakaznikov))请注意 `LIVE VIEW` 功能可能会在下一个版本中删除。 + +#### 错误修复 {#bug-fix-8} + +- 此版本还包含19.13和19.11的所有错误修复。 +- 修复表有跳过索引和垂直合并发生时的分段错误。 [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([阿利沙平](https://github.com/alesapin)) +- 使用非平凡的列默认值修复每列TTL。 以前在强制TTL合并的情况下 `OPTIMIZE ... FINAL` 查询,过期的值被替换为类型默认值,而不是用户指定的列默认值。 [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复kafka服务器正常重启时的消息重复问题。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([伊万](https://github.com/abyss7)) +- 修正了读取Kafka消息时的无限循环。 根本不要暂停/恢复订阅消费者-否则在某些情况下可能会无限期暂停。 [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([伊万](https://github.com/abyss7)) +- 修复 `Key expression contains comparison between inconvertible types` 例外 `bitmapContains` 功能。 [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([dimarub2000](https://github.com/dimarub2000)) +- 修复已启用的段错误 `optimize_skip_unused_shards` 还丢失了分片钥匙 [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复了可能导致内存损坏的突变中的错误代码。 修复了读取地址的段错误 `0x14c0` 这可能发生由于并发 `DROP TABLE` 和 `SELECT` 从 `system.parts` 或 `system.parts_columns`. 在准备突变查询时修复了竞争条件。 修复了由于 `OPTIMIZE` 复制的表和并发修改操作,如改变。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在MySQL界面中删除了额外的详细日志记录 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 返回解析布尔设置的能力 ‘true’ 和 ‘false’ 在配置文件中。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([阿利沙平](https://github.com/alesapin)) +- 修复崩溃 `quantile` 和 `median` 功能结束 `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([Artem Zuikov](https://github.com/4ertus2)) +- 修正了可能不完整的结果返回 `SELECT` 查询与 `WHERE` 主键上的条件包含转换为浮点类型。 它是由不正确的单调性检查引起的 `toFloat` 功能。 [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) +- 检查 `max_expanded_ast_elements` 设置为突变。 明确突变后 `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([张冬](https://github.com/zhang2014)) +- 修复使用键列时的联接结果 `join_use_nulls`. 附加空值而不是列默认值。 [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([Artem Zuikov](https://github.com/4ertus2)) +- 修正了跳过索引与垂直合并和改变。 修复 `Bad size of marks file` 例外。 [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([阿利沙平](https://github.com/alesapin)) +- 修复罕见的崩溃 `ALTER MODIFY COLUMN` 和垂直合并,当合并/改变的部分之一是空的(0行) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([阿利沙平](https://github.com/alesapin)) +- 修正错误的转换 `LowCardinality` 类型 `AggregateFunctionFactory`. 这修复 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复错误的行为和可能的段错误 `topK` 和 `topKWeighted` 聚合函数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([安东\*波波夫](https://github.com/CurtizJ)) +- 固定周围的不安全代码 `getIdentifier` 功能。 [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在MySQL线协议(连接到ClickHouse的形式MySQL客户端时使用)修正了错误。 引起的堆缓冲区溢出 `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 固定内存泄漏 `bitmapSubsetInRange` 功能。 [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([余志昌](https://github.com/yuzhichang)) +- 修复粒度变化后执行突变时的罕见错误。 [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([阿利沙平](https://github.com/alesapin)) +- 默认情况下允许包含所有字段的protobuf消息。 [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 解决错误 `nullIf` 功能,当我们发送 `NULL` 第二个参数的参数。 [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 修正了错误的内存分配/解除分配在复杂的键高速缓存字典与字符串字段,导致无限的内存消耗罕见的错误(看起来像内存泄漏)。 当字符串大小为8(8,16,32等)开始的2的幂时,错误会重现。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([阿利沙平](https://github.com/alesapin)) +- 修复了导致异常的小序列上的大猩猩编码 `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 允许在连接中使用不可为空的类型 `join_use_nulls` 已启用。 [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([Artem Zuikov](https://github.com/4ertus2)) +- 禁用 `Poco::AbstractConfiguration` 查询中的替换 `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 避免死锁 `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使用 `arrayReduce` 对于不变的参数可能会导致段错误。 [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复可能出现的不一致的部分,如果副本恢复后 `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- 固定挂起 `JSONExtractRaw` 功能。 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误跳过索引序列化和聚合与自适应粒度。 [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([阿利沙平](https://github.com/alesapin)) +- 修复 `WITH ROLLUP` 和 `WITH CUBE` 修饰符 `GROUP BY` 具有两级聚合。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复编写具有自适应粒度的二级索引标记的错误。 [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([阿利沙平](https://github.com/alesapin)) +- 修复服务器启动时的初始化顺序。 由于 `StorageMergeTree::background_task_handle` 在初始化 `startup()` 该 `MergeTreeBlockOutputStream::write()` 可以尝试在初始化之前使用它。 只需检查它是否被初始化。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([伊万](https://github.com/abyss7)) +- 从以前的读取操作中清除数据缓冲区,该操作完成时出现错误。 [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([尼古拉](https://github.com/bopohaa)) +- 修复为复制\*MergeTree表创建新副本时启用自适应粒度的错误。 [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([阿利沙平](https://github.com/alesapin)) +- 修复了在服务器启动过程中发生异常的情况下可能发生的崩溃 `libunwind` 在异常访问未初始化 `ThreadStatus` 结构。 [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) +- 修复崩溃 `yandexConsistentHash` 功能。 通过模糊测试发现。 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了服务器过载和全局线程池接近满时挂起查询的可能性。 这在具有大量分片(数百个)的集群上发生的机会更高,因为分布式查询为每个分片分配每个连接的线程。 例如,如果集群330分片正在处理30个并发分布式查询,则此问题可能再现。 此问题会影响从19.2开始的所有版本。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 的固定逻辑 `arrayEnumerateUniqRanked` 功能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 解码符号表时修复段错误。 [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([阿莫斯鸟](https://github.com/amosbird)) +- 在固定不相关的异常转换 `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 删除描述中的额外引用 `system.settings` 桌子 [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 避免可能的死锁 `TRUNCATE` 复制的表。 [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复读取排序键的顺序。 [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复 `ALTER TABLE ... UPDATE` 查询表 `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([阿利沙平](https://github.com/alesapin)) +- 修复错误打开 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (自19.4.0)。 当我们不查询任何列时,在对MergeTree表的分布式表的查询中复制 (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([阿利沙平](https://github.com/alesapin)) +- 在有符号类型的整数划分为无符号类型的固定溢出。 这种行为与C或C++语言(整数升级规则)完全相同,这可能令人惊讶。 请注意,当将大型有符号数字划分为大型无符号数字或反之亦然时,溢出仍然是可能的(但这种情况不太常见)。 所有服务器版本都存在此问题。 [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 限制最大睡眠时间限制时 `max_execution_speed` 或 `max_execution_speed_bytes` 已设置。 修正错误,如 `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 关于使用固定的问题 `MATERIALIZED` 列和别名 `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([阿莫斯鸟](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复 `FormatFactory` 未实现为处理器的输入流的行为。 [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 固定错字。 [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([Alex Ryndin](https://github.com/alexryndin)) +- 错字在错误消息(是-\>是)。 [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([Denis Zhuravlev](https://github.com/den-crane)) +- 修复了从字符串中解析列列表时的错误,如果类型包含逗号(这个问题与 `File`, `URL`, `HDFS` 储存) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) + +#### 安全修复 {#security-fix} + +- 此版本还包含19.13和19.11的所有错误安全修复。 +- 修复了由于SQL解析器中的堆栈溢出而导致服务器崩溃的制造查询的可能性。 修复了合并和分布式表,实例化视图和涉及子查询的行级安全性条件中堆栈溢出的可能性。 [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 改进 {#improvement-3} + +- 三元逻辑的正确实现 `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) +- 现在,值和行与过期的TTL将被删除后 `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` 查询。 添加查询 `SYSTEM STOP/START TTL MERGES` 要禁止/允许使用TTL分配合并,并在所有合并中过滤过期值。 [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([安东\*波波夫](https://github.com/CurtizJ)) +- 可以更改ClickHouse历史文件的位置为客户端使用 `CLICKHOUSE_HISTORY_FILE` env [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([filimonov](https://github.com/filimonov)) +- 删除 `dry_run` 从标志 `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 碌莽禄Support: `ASOF JOIN` 与 `ON` 科。 [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([Artem Zuikov](https://github.com/4ertus2)) +- 更好地支持用于突变和复制的跳过索引。 支持 `MATERIALIZE/CLEAR INDEX ... IN PARTITION` 查询。 `UPDATE x = x` 重新计算使用列的所有索引 `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 允许 `ATTACH` 实时视图(例如,在服务器启动时),无论 `allow_experimental_live_view` 设置。 [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 对于由查询探查器收集的堆栈跟踪,不包括由查询探查器本身生成的堆栈帧。 [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 现在表函数 `values`, `file`, `url`, `hdfs` 支持别名列。 [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 如果抛出异常 `config.d` 文件没有相应的根元素作为配置文件。 [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) +- 在异常消息中打印额外的信息 `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([tavplubix](https://github.com/tavplubix)) +- 当确定一个碎片 `Distributed` 要被读取查询复盖的表(用于 `optimize_skip_unused_shards` =1)ClickHouse现在从两个检查条件 `prewhere` 和 `where` select语句的子句。 [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) +- 已启用 `SIMDJSON` 对于没有AVX2,但与SSE4.2和PCLMUL指令集的机器。 [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- ClickHouse可以在文件系统上工作,而无需 `O_DIRECT` 支持(如ZFS和BtrFS),无需额外的调整。 [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 支持最终子查询的下推谓词。 [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([TCeason](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 更好 `JOIN ON` 密钥提取 [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([Artem Zuikov](https://github.com/4ertus2)) +- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 优化最小列的选择 `SELECT count()` 查询。 [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([阿莫斯鸟](https://github.com/amosbird)) +- 已添加 `strict` 参数in `windowFunnel()`. 当 `strict` 设置,该 `windowFunnel()` 仅对唯一值应用条件。 [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([achimbab](https://github.com/achimbab)) +- 更安全的界面 `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([avasiliev](https://github.com/avasiliev)) +- 执行时选项行大小 `--help` 选项现在与终端大小对应。 [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([dimarub2000](https://github.com/dimarub2000)) +- 禁用 “read in order” 优化无键的聚合。 [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([安东\*波波夫](https://github.com/CurtizJ)) +- Http状态代码 `INCORRECT_DATA` 和 `TYPE_MISMATCH` 错误代码已从默认值更改 `500 Internal Server Error` 到 `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([亚历山大\*罗丹](https://github.com/a-rodin)) +- 从移动连接对象 `ExpressionAction` 成 `AnalyzedJoin`. `ExpressionAnalyzer` 和 `ExpressionAction` 不知道 `Join` 不再上课了 它的逻辑被隐藏 `AnalyzedJoin` 伊菲斯 [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复了当其中一个分片是localhost但查询通过网络连接发送时可能出现的分布式查询死锁。 [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 更改多个表的语义 `RENAME` 为了避免可能的死锁。 [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 重写MySQL兼容性服务器以防止在内存中加载完整的数据包有效负载。 每个连接的内存消耗减少到大约 `2 * DBMS_DEFAULT_BUFFER_SIZE` (读/写缓冲区)。 [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 将AST别名解释逻辑移出不必了解查询语义的解析器。 [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([Artem Zuikov](https://github.com/4ertus2)) +- 稍微更安全的解析 `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `clickhouse-copier`:允许使用 `where_condition` 从配置 `partition_key` 查询中用于检查分区存在的别名(以前它仅用于读取数据查询)。 [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([proller](https://github.com/proller)) +- 在添加可选的消息参数 `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([Vdimir](https://github.com/Vdimir)) +- 在发送插入数据时,服务器异常也正在客户端中处理。 [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([dimarub2000](https://github.com/dimarub2000)) +- 添加了指标 `DistributedFilesToInsert` 这显示了文件系统中选择通过分布式表发送到远程服务器的文件总数。 该数字在所有分片之间相加。 [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 将大部分连接准备逻辑从 `ExpressionAction/ExpressionAnalyzer` 到 `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复曾 [警告](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 关于缺乏Linux功能的更好的信息消息。 记录致命错误 “fatal” 水平,这将使它更容易找到 `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 当启用转储临时数据到磁盘,以限制内存使用期间 `GROUP BY`, `ORDER BY`,它没有检查可用磁盘空间。 修复程序添加新设置 `min_free_disk_space`,当可用磁盘空间小于阈值时,查询将停止并抛出 `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([徐伟清](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 通过线程删除递归rwlock。 这是没有意义的,因为线程在查询之间重用。 `SELECT` 查询可以在一个线程中获取锁,从另一个线程持有锁并从第一个线程退出。 在同一时间,第一个线程可以通过重复使用 `DROP` 查询。 这将导致虚假 “Attempt to acquire exclusive lock recursively” 消息 [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 斯普利特 `ExpressionAnalyzer.appendJoin()`. 准备一个地方 `ExpressionAnalyzer` 为 `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([Artem Zuikov](https://github.com/4ertus2)) +- 已添加 `mysql_native_password` mysql兼容性服务器的身份验证插件。 [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 更少的数量 `clock_gettime` 调用;调试/发布之间的固定ABI兼容性 `Allocator` (微不足道的问题)。 [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 移动 `collectUsedColumns` 从 `ExpressionAnalyzer` 到 `SyntaxAnalyzer`. `SyntaxAnalyzer` 赂眉露\>\> `required_source_columns` 现在本身。 [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([Artem Zuikov](https://github.com/4ertus2)) +- 添加设置 `joined_subquery_requires_alias` 要求子选择和表函数的别名 `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([Artem Zuikov](https://github.com/4ertus2)) +- 提取物 `GetAggregatesVisitor` 从类 `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([Artem Zuikov](https://github.com/4ertus2)) +- `system.query_log`:更改数据类型 `type` 列到 `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) +- 静态链接 `sha256_password` 身份验证插件。 [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 避免对设置的额外依赖 `compile` 去工作 在以前的版本中,用户可能会得到如下错误 `cannot open crti.o`, `unable to find library -lc` 等。 [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 对可能来自恶意副本的输入进行更多验证。 [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 现在 `clickhouse-obfuscator` 文件是可用的 `clickhouse-client` 包。 在以前的版本中,它可以作为 `clickhouse obfuscator` (带空格)。 [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([dimarub2000](https://github.com/dimarub2000)) +- 当我们至少有两个查询以不同的顺序读取至少两个表,另一个查询对其中一个表执行DDL操作时,修复了死锁。 修复了另一个非常罕见的死锁。 [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 已添加 `os_thread_ids` 列到 `system.processes` 和 `system.query_log` 为了更好的调试可能性。 [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 当发生PHP mysqlnd扩展错误的解决方法 `sha256_password` 用作默认身份验证插件(在描述 [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 删除不需要的地方与更改为空列。 [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([Artem Zuikov](https://github.com/4ertus2)) +- 设置默认值 `queue_max_wait_ms` 为零,因为当前值(五秒)是没有意义的。 在极少数情况下,此设置有任何用途。 添加设置 `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` 和 `connection_pool_max_wait_ms` 用于消除歧义。 [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 提取物 `SelectQueryExpressionAnalyzer` 从 `ExpressionAnalyzer`. 保留最后一个用于非select查询。 [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([Artem Zuikov](https://github.com/4ertus2)) +- 删除重复输入和输出格式。 [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 允许用户复盖 `poll_interval` 和 `idle_connection_timeout` 连接设置。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `MergeTree` 现在有一个额外的选项 `ttl_only_drop_parts` (默认情况下禁用),以避免部分的部分修剪,以便在部分中的所有行都过期时完全删除它们。 [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([塞尔吉\*弗拉季金](https://github.com/svladykin)) +- 类型检查set索引函数。 如果函数类型错误,则引发异常。 这修复了模糊测试与UBSan。 [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) + +#### 性能改进 {#performance-improvement-2} + +- 优化查询 `ORDER BY expressions` 条款,其中 `expressions` 有重合前缀与排序键 `MergeTree` 桌子 此优化由以下方式控制 `optimize_read_in_order` 设置。 [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([安东\*波波夫](https://github.com/CurtizJ)) +- 允许在零件装载和拆卸期间使用多个螺纹。 [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 实现了更新聚合函数状态的批处理变体。 这可能导致性能优势。 [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使用 `FastOps` 函数库 `exp`, `log`, `sigmoid`, `tanh`. FastOps是迈克尔\*帕拉欣(Yandex的首席技术官)的快速矢量数学库。 改进的性能 `exp` 和 `log` 功能超过6倍。 功能 `exp` 和 `log` 从 `Float32` 参数将返回 `Float32` (在以前的版本中,他们总是返回 `Float64`). 现在 `exp(nan)` 可能会回来 `inf`. 的结果 `exp` 和 `log` 函数可能不是最接近机器可代表的数字到真正的答案。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov))使用Danila Kutenin变体使fastops工作 [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 禁用连续密钥优化 `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([akuzm](https://github.com/akuzm)) +- 改进的性能 `simdjson` 库通过摆脱动态分配 `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 预故障页分配内存时 `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([akuzm](https://github.com/akuzm)) +- 修复性能错误 `Decimal` 比较。 [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-4} + +- 删除编译器(运行时模板实例化),因为我们已经赢得了它的性能。 [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了性能测试,以显示gcc-9以更隔离的方式性能下降。 [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加表功能 `numbers_mt`,这是多线程版本 `numbers`. 使用哈希函数更新性能测试。 [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 比较模式 `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([dimarub2000](https://github.com/dimarub2000)) +- 尽最大努力打印堆栈痕迹。 还添加了 `SIGPROF` 作为调试信号,打印正在运行的线程的堆栈跟踪。 [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 每个函数都在自己的文件中,第10部分。 [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 删除两倍常量 `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([filimonov](https://github.com/filimonov)) +- 格式化更改 `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([akuzm](https://github.com/akuzm)) +- 更好的联接创建子查询 `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([Artem Zuikov](https://github.com/4ertus2)) +- 删除冗余条件(由PVS Studio找到)。 [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([akuzm](https://github.com/akuzm)) +- 分隔散列表接口 `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([akuzm](https://github.com/akuzm)) +- 重构设置。 [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([阿利沙平](https://github.com/alesapin)) +- 添加注释 `set` 索引函数。 [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 在Linux上的调试版本中增加OOM分数。 [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([akuzm](https://github.com/akuzm)) +- HDFS HA现在在调试版本中工作。 [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([徐伟清](https://github.com/weiqxu)) +- 添加了一个测试 `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 为Kafka表添加多个实例化视图的测试。 [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([伊万](https://github.com/abyss7)) +- 制定一个更好的构建计划。 [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([伊万](https://github.com/abyss7)) +- 固定 `test_external_dictionaries` 集成的情况下,它是在非root用户下执行。 [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 当写入的数据包的总大小超过 `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 增加了一个测试 `RENAME` 表竞争条件 [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 避免在设置数据竞赛 `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 通过缓存字典添加处理错误的集成测试。 [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 在Mac OS上禁用ELF对象文件的解析,因为这是没有意义的。 [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 尝试使更新日志生成器更好。 [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加 `-Wshadow` 切换到海湾合作委员会。 [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) +- 删除过时的代码 `mimalloc` 支持。 [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `zlib-ng` 确定x86功能并将此信息保存到全局变量。 这是在defalteInit调用中完成的,它可以由不同的线程同时进行。 为了避免多线程写入,请在库启动时执行此操作。 [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([akuzm](https://github.com/akuzm)) +- 回归测试一个错误,在连接这是固定的 [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([Bakhtiyor Ruziev](https://github.com/theruziev)) +- 修正MSan报告。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复扑ttl测试。 [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修正了虚假数据竞赛 `MergeTreeDataPart::is_frozen` 场。 [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了模糊测试中的超时。 在以前的版本中,它设法在查询中找到虚假挂断 `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加了调试检查 `static_cast` 列。 [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在官方RPM软件包中支持Oracle Linux。 [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 从更改json perftests `once` 到 `loop` 类型。 [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- `odbc-bridge.cpp` 定义 `main()` 所以它不应该被包括在 `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([Origej Desh](https://github.com/orivej)) +- 测试碰撞 `FULL|RIGHT JOIN` 右表的键中有空值。 [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([Artem Zuikov](https://github.com/4ertus2)) +- 为了以防万一,增加了对别名扩展限制的测试。 [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 从切换 `boost::filesystem` 到 `std::filesystem` 在适当的情况下。 [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 将RPM包添加到网站。 [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 为固定添加测试 `Unknown identifier` 例外 `IN` 科。 [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([Artem Zuikov](https://github.com/4ertus2)) +- 简化操作 `shared_ptr_helper` 因为人们面临困难理解它。 [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了固定大猩猩和DoubleDelta编解码器的性能测试。 [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 拆分集成测试 `test_dictionaries` 分成四个单独的测试。 [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复PVS-Studio中的警告 `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 允许使用 `library` 与ASan字典源. [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了从Pr列表生成更新日志的选项。 [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 锁定 `TinyLog` 读取时存储。 [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([akuzm](https://github.com/akuzm)) +- 检查CI中损坏的符号链接。 [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加超时时间 “stack overflow” 测试,因为它可能需要很长的时间在调试构建。 [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加了双空格检查。 [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复 `new/delete` 使用消毒剂构建时的内存跟踪。 跟踪不清楚。 它只防止测试中的内存限制异常。 [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([Artem Zuikov](https://github.com/4ertus2)) +- 启用链接时对未定义符号的检查。 [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([伊万](https://github.com/abyss7)) +- 避免重建 `hyperscan` 每天 [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在固定的瑞银报告 `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 不要允许将查询探查器与消毒器一起使用,因为它不兼容。 [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加测试计时器失败后重新加载字典。 [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复不一致 `PipelineExecutor::prepareProcessor` 参数类型。 [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 添加了对坏Uri的测试。 [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了更多的检查 `CAST` 功能。 这应该获得更多关于模糊测试中分割故障的信息。 [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 已添加 `gcc-9` 支持 `docker/builder` 本地生成映像的容器。 [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) +- 测试主键 `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([dimarub2000](https://github.com/dimarub2000)) +- 修复了缓慢堆栈跟踪打印影响的测试。 [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加崩溃的测试用例 `groupUniqArray` 固定在 [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([akuzm](https://github.com/akuzm)) +- 固定指数突变测试。 [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 在性能测试中,不要读取我们没有运行的查询的查询日志。 [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([akuzm](https://github.com/akuzm)) +- 现在可以使用任何低基数类型创建实例化视图,而不考虑关于可疑低基数类型的设置。 [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([Olga Khvostikova](https://github.com/stavrolia)) +- 更新的测试 `send_logs_level` 设置。 [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复gcc-8.2下的构建。 [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([Max Akhmedov](https://github.com/zlobober)) +- 修复构建与内部libc++。 [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([伊万](https://github.com/abyss7)) +- 修复共享构建 `rdkafka` 图书馆 [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([伊万](https://github.com/abyss7)) +- 修复Mac OS构建(不完整)。 [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([alex-zaitsev](https://github.com/alex-zaitsev)) +- 修复 “splitted” 碌莽禄.拢. [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 其他构建修复: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([阿莫斯鸟](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([vxider](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([伊万](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([proller](https://github.com/proller)) + +#### 向后不兼容的更改 {#backward-incompatible-change-3} + +- 删除很少使用的表函数 `catBoostPool` 和存储 `CatBoostPool`. 如果您使用了此表功能,请写电子邮件至 `clickhouse-feedback@yandex-team.com`. 请注意,CatBoost集成仍然存在,并将受到支持。 [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 禁用 `ANY RIGHT JOIN` 和 `ANY FULL JOIN` 默认情况下。 设置 `any_join_distinct_right_table_keys` 设置启用它们。 [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([Artem Zuikov](https://github.com/4ertus2)) + +## ClickHouse释放19.13 {#clickhouse-release-19-13} + +### ClickHouse释放19.13.6.51,2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} + +#### 错误修复 {#bug-fix-9} + +- 此版本还包含19.11.12.69的所有错误修复。 + +### ClickHouse释放19.13.5.44,2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} + +#### 错误修复 {#bug-fix-10} + +- 此版本还包含19.14.6.12的所有错误修复。 +- 修复了在执行时表的可能不一致的状态 `DROP` 在zookeeper无法访问时查询复制的表。 [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) +- 修复了StorageMerge中的数据竞赛 [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复查询分析器中引入的错误,从而导致套接字无休止的recv。 [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([阿利沙平](https://github.com/alesapin)) +- 修复执行时过多的CPU使用率 `JSONExtractRaw` 函数在一个布尔值。 [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 在推送到实例化视图时修复回归。 [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([伊万](https://github.com/abyss7)) +- 表函数 `url` 该漏洞是否允许攻击者在请求中注入任意HTTP头。 这个问题被发现 [尼基塔\*季霍米罗夫](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复无用 `AST` 检查设置索引。 [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 修正了解析 `AggregateFunction` 查询中嵌入的值。 [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([余志昌](https://github.com/yuzhichang)) +- 修正了错误的行为 `trim` 功能家庭。 [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### ClickHouse释放19.13.4.32,2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} + +#### 错误修复 {#bug-fix-11} + +- 此版本还包含19.11.9.52和19.11.10.54的所有错误安全修复。 +- 固定数据竞赛 `system.parts` 表和 `ALTER` 查询。 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了从带有sample和prewhere的空分布式表中读取流中发生的不匹配标题。 [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([钱丽祥](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复使用时的崩溃 `IN` 子句带有一个元组的子查询。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- 修复具有相同列名的大小写 `GLOBAL JOIN ON` 科。 [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复强制转换类型时的崩溃 `Decimal` 这不支持它。 抛出异常代替。 [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复了崩溃 `extractAll()` 功能。 [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([Artem Zuikov](https://github.com/4ertus2)) +- 查询转换 `MySQL`, `ODBC`, `JDBC` 表函数现在正常工作 `SELECT WHERE` 具有多个查询 `AND` 表达式。 [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([dimarub2000](https://github.com/dimarub2000)) +- 添加了以前的声明检查MySQL8集成。 [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([拉斐尔\*大卫\*蒂诺科](https://github.com/rafaeldtinoco)) + +#### 安全修复 {#security-fix-1} + +- 修复解压缩阶段编解码器中的两个漏洞(恶意用户可以制造压缩数据,导致解压缩中的缓冲区溢出)。 [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([Artem Zuikov](https://github.com/4ertus2)) + +### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102005602 {#clickhouse-release-19-13-3-26-2019-08-22} + +#### 错误修复 {#bug-fix-12} + +- 修复 `ALTER TABLE ... UPDATE` 查询表 `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([阿利沙平](https://github.com/alesapin)) +- 在使用IN子句时修复带有元组的子查询。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- 修复了一个问题,即如果一个陈旧的副本变为活动的,它可能仍然有被删除分区的数据部分。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- 修正了解析CSV的问题 [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) +- 修正了系统中的数据竞赛。部件表和ALTER查询。 这修复 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了可能导致内存损坏的突变中的错误代码。 修复了读取地址的段错误 `0x14c0` 这可能发生由于并发 `DROP TABLE` 和 `SELECT` 从 `system.parts` 或 `system.parts_columns`. 在准备突变查询时修复了竞争条件。 修复了由于 `OPTIMIZE` 复制的表和并发修改操作,如改变。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复后可能的数据丢失 `ALTER DELETE` 查询表跳过索引。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) + +#### 安全修复 {#security-fix-2} + +- 如果攻击者具有对ZooKeeper的写入访问权限,并且能够从ClickHouse运行的网络中运行可用的自定义服务器,则可以创建自定义构建的恶意服务器,该服务器将充当ClickHouse副本并将其注册到ZooKeeper中。 当另一个副本从恶意副本中获取数据部分时,它可以强制clickhouse-server写入文件系统上的任意路径。 由Yandex的信息安全团队Eldar Zaitov发现。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-13-2-19-2019-08-14} + +#### 新功能 {#new-feature-5} + +- 查询级别上的采样探查器。 [示例](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) +- 允许指定列的列表 `COLUMNS('regexp')` 表达的工作原理就像一个更复杂的变体 `*` 星号 [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([mfridental](https://github.com/mfridental)), ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `CREATE TABLE AS table_function()` 现在是可能的 [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([dimarub2000](https://github.com/dimarub2000)) +- 亚当优化随机梯度下降默认情况下使用 `stochasticLinearRegression()` 和 `stochasticLogisticRegression()` 聚合函数,因为它显示了良好的质量,几乎没有任何调整。 [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([Quid37](https://github.com/Quid37)) +- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([杨小姐](https://github.com/andyyzh)) +- `RENAME` 查询现在适用于所有存储。 [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([伊万](https://github.com/abyss7)) +- 现在客户端通过设置从服务器接收任何所需级别的日志 `send_logs_level` 无论服务器设置中指定的日志级别如何。 [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) + +#### 向后不兼容的更改 {#backward-incompatible-change-4} + +- 设置 `input_format_defaults_for_omitted_fields` 默认情况下启用。 分布式表中的插入需要此设置在集群上相同(您需要在滚动更新之前设置它)。 它允许计算复杂的默认表达式的省略字段 `JSONEachRow` 和 `CSV*` 格式。 它应该是预期的行为,但可能导致可忽略不计的性能差异。 [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([Artem Zuikov](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) + +#### 实验特点 {#experimental-features} + +- 新的查询处理管道。 使用 `experimental_use_processors=1` 选项来启用它。 用你自己的麻烦。 [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) + +#### 错误修复 {#bug-fix-13} + +- Kafka集成已在此版本中修复。 +- 固定 `DoubleDelta` 编码 `Int64` 对于大 `DoubleDelta` 值,改进 `DoubleDelta` 编码为随机数据 `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 固定的高估 `max_rows_to_read` 如果设置 `merge_tree_uniform_read_distribution` 置为0。 [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 改进 {#improvement-4} + +- 如果抛出异常 `config.d` 文件没有相应的根元素作为配置文件 [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) + +#### 性能改进 {#performance-improvement-3} + +- 优化 `count()`. 现在它使用最小的列(如果可能的话)。 [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([阿莫斯鸟](https://github.com/amosbird)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-5} + +- 在性能测试中报告内存使用情况。 [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([akuzm](https://github.com/akuzm)) +- 修复构建与外部 `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([伊万](https://github.com/abyss7)) +- 修复共享构建 `rdkafka` 图书馆 [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([伊万](https://github.com/abyss7)) + +## ClickHouse释放19.11 {#clickhouse-release-19-11} + +### ClickHouse释放19.11.13.74,2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} + +#### 错误修复 {#bug-fix-14} + +- 修复了罕见的崩溃 `ALTER MODIFY COLUMN` 当合并/更改部分之一为空(0行)时,垂直合并。 [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([阿利沙平](https://github.com/alesapin)) +- 手动更新 `SIMDJSON`. 这修复了stderr文件可能泛滥的错误json诊断消息。 [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) +- 修正错误 `mrk` 突变的文件扩展名 ([阿利沙平](https://github.com/alesapin)) + +### ClickHouse释放19.11.12.69,2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} + +#### 错误修复 {#bug-fix-15} + +- 修复了大型表上复杂键的索引分析的性能下降。 这修复 [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使用分布式引擎在表中发送数据时避免罕见的SIGSEGV (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([Azat Khuzhin](https://github.com/azat)) +- 修复 `Unknown identifier` 有多个连接。 这修复 [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-11-57-2019-09-13} + +- 修复从Kafka空主题中选择时导致段错误的逻辑错误。 [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([伊万](https://github.com/abyss7)) +- 修复功能 `АrrayEnumerateUniqRanked` 在参数中使用空数组。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) + +### ClickHouse释放19.11.10.54,2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} + +#### 错误修复 {#bug-fix-16} + +- 手动存储Kafka消息的偏移量,以便能够一次性为所有分区提交它们。 修复潜在的重复 “one consumer - many partitions” 场景。 [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([伊万](https://github.com/abyss7)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682 {#clickhouse-release-19-11-9-52-2019-09-6} + +- 改进缓存字典中的错误处理。 [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 在功能固定错误 `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([proller](https://github.com/proller)) +- 修复 `JSONExtract` 功能,同时提取 `Tuple` 从JSON。 [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复后可能的数据丢失 `ALTER DELETE` 查询表跳过索引。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 固定性能测试。 [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 实木复合地板:修复读取布尔列。 [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了错误的行为 `nullIf` 常量参数的函数。 [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复kafka服务器正常重启时的消息重复问题。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([伊万](https://github.com/abyss7)) +- 修正了一个问题,当长 `ALTER UPDATE` 或 `ALTER DELETE` 可能会阻止常规合并运行。 如果没有足够的可用线程,则防止突变执行。 [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([tavplubix](https://github.com/tavplubix)) +- 修正了处理错误 “timezone” 在服务器配置文件中。 [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复卡夫卡测试。 [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([伊万](https://github.com/abyss7)) + +#### 安全修复 {#security-fix-3} + +- 如果攻击者具有对ZooKeeper的写入访问权限,并且能够从运行ClickHouse的网络中运行可用的自定义服务器,则可以创建自定义构建的恶意服务器,该服务器将充当ClickHouse副本并将其注册到ZooKeeper中。 当另一个副本从恶意副本中获取数据部分时,它可以强制clickhouse-server写入文件系统上的任意路径。 由Yandex的信息安全团队Eldar Zaitov发现。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-8-46-2019-08-22} + +#### 错误修复 {#bug-fix-17} + +- 修复 `ALTER TABLE ... UPDATE` 查询表 `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([阿利沙平](https://github.com/alesapin)) +- 在使用IN子句时修复带有元组的子查询。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) +- 修复了一个问题,即如果一个陈旧的副本变为活动的,它可能仍然有被删除分区的数据部分。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) +- 修正了解析CSV的问题 [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) +- 修正了系统中的数据竞赛。部件表和ALTER查询。 这修复 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了可能导致内存损坏的突变中的错误代码。 修复了读取地址的段错误 `0x14c0` 这可能发生由于并发 `DROP TABLE` 和 `SELECT` 从 `system.parts` 或 `system.parts_columns`. 在准备突变查询时修复了竞争条件。 修复了由于 `OPTIMIZE` 复制的表和并发修改操作,如改变。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-7-40-2019-08-14} + +#### 错误修复 {#bug-fix-18} + +- Kafka集成已在此版本中修复。 +- 使用时修复段错误 `arrayReduce` 对于不断的参数。 [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定 `toFloat()` 单调性。 [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) +- 修复已启用的段错误 `optimize_skip_unused_shards` 还丢失了分片钥匙 [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([CurtizJ](https://github.com/CurtizJ)) +- 的固定逻辑 `arrayEnumerateUniqRanked` 功能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 从MySQL处理程序中删除了额外的详细日志记录。 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复错误的行为和可能的段错误 `topK` 和 `topKWeighted` 聚合函数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([CurtizJ](https://github.com/CurtizJ)) +- 不要公开虚拟列 `system.columns` 桌子 这是向后兼容所必需的。 [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复复杂键缓存字典中字符串字段的内存分配错误。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([阿利沙平](https://github.com/alesapin)) +- 修复创建新副本时启用自适应粒度的错误 `Replicated*MergeTree` 桌子 [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([阿利沙平](https://github.com/alesapin)) +- 阅读Kafka消息时修复无限循环。 [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([abyss7](https://github.com/abyss7)) +- 修复了由于SQL解析器中的堆栈溢出和堆栈溢出的可能性而导致服务器崩溃的编造查询的可能性 `Merge` 和 `Distributed` 表 [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在小序列固定大猩猩编码错误。 [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Enmk](https://github.com/Enmk)) + +#### 改进 {#improvement-5} + +- 允许用户复盖 `poll_interval` 和 `idle_connection_timeout` 连接设置。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102003042 {#clickhouse-release-19-11-5-28-2019-08-05} + +#### 错误修复 {#bug-fix-19} + +- 修复了服务器超载时挂起查询的可能性。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复yandexConsistentHash函数中的FPE。 这修复 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误的转换 `LowCardinality` 类型 `AggregateFunctionFactory`. 这修复 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复解析 `bool` 从设置 `true` 和 `false` 配置文件中的字符串。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([阿利沙平](https://github.com/alesapin)) +- 修复查询中不兼容的流头的罕见错误 `Distributed` 桌子结束 `MergeTree` 表时的一部分 `WHERE` 移动到 `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([阿利沙平](https://github.com/alesapin)) +- 在有符号类型的整数划分为无符号类型的固定溢出。 这修复 [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 向后不兼容的更改 {#backward-incompatible-change-5} + +- `Kafka` 还是坏了 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-4-24-2019-08-01} + +#### 错误修复 {#bug-fix-20} + +- 修复编写具有自适应粒度的二级索引标记的错误。 [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([阿利沙平](https://github.com/alesapin)) +- 修复 `WITH ROLLUP` 和 `WITH CUBE` 修饰符 `GROUP BY` 具有两级聚合。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([安东\*波波夫](https://github.com/CurtizJ)) +- 固定挂起 `JSONExtractRaw` 功能。 固定 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复ExternalLoader::reloadOutdated()中的段错误。 [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复了服务器可能关闭侦听套接字但不关闭并继续提供剩余查询的情况。 您最终可能会有两个正在运行的clickhouse服务器进程。 有时,服务器可能会返回错误 `bad_function_call` 对于剩余的查询。 [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了通过ODBC,MySQL,ClickHouse和HTTP初始加载外部字典的更新字段无用和不正确的条件。 这修复 [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在固定不相关的异常转换 `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复非确定性结果 “uniq” 在极少数情况下聚合函数。 该错误存在于所有ClickHouse版本。 [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- Segfault当我们在函数上设置了一点点太高的CIDR `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 修复了服务器从许多不同上下文中抛出许多异常时的小内存泄漏。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复消费者在订阅之前暂停而之后未恢复的情况。 [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([伊万](https://github.com/abyss7))请注意,卡夫卡在这个版本中被打破。 +- 从以前的读取操作中清除Kafka数据缓冲区,并且完成了错误操作 [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([尼古拉](https://github.com/bopohaa))请注意,卡夫卡在这个版本中被打破。 +- 由于 `StorageMergeTree::background_task_handle` 在初始化 `startup()` 该 `MergeTreeBlockOutputStream::write()` 可以尝试在初始化之前使用它。 只需检查它是否被初始化。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([伊万](https://github.com/abyss7)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-6} + +- 新增官方 `rpm` 包. [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([proller](https://github.com/proller)) ([阿利沙平](https://github.com/alesapin)) +- 添加构建能力 `.rpm` 和 `.tgz` 包 `packager` 脚本 [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([阿利沙平](https://github.com/alesapin)) +- 修复了 “Arcadia” 构建系统。 [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([proller](https://github.com/proller)) + +#### 向后不兼容的更改 {#backward-incompatible-change-6} + +- `Kafka` 在这个版本中被打破。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-3-11-2019-07-18} + +#### 新功能 {#new-feature-6} + +- 增加了对准备好的语句的支持。 [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([亚历山大](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `DoubleDelta` 和 `Gorilla` 列编解ecs [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 已添加 `os_thread_priority` 设置,允许控制 “nice” 操作系统用于调整动态调度优先级的查询处理线程的值。 它需要 `CAP_SYS_NICE` 能力的工作。 这实现了 [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 执行 `_topic`, `_offset`, `_key` kafka引擎的列 [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([伊万](https://github.com/abyss7))请注意,卡夫卡在这个版本中被打破。 +- 添加聚合函数组合 `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([hcz](https://github.com/hczhcz)) +- 聚合函数 `groupArrayMovingSum(win_size)(x)` 和 `groupArrayMovingAvg(win_size)(x)`,计算移动和/平均有或没有窗口大小限制。 [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([inv2004](https://github.com/inv2004)) +- 添加synonim `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([hcz](https://github.com/hczhcz)) +- Intergate H3功能 `geoToH3` 从尤伯杯. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen Ivan](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 错误修复 {#bug-fix-21} + +- 使用异步更新实现DNS缓存。 单独的线程解析所有主机并更新dns缓存(设置 `dns_cache_update_period`). 当主机的ip频繁更改时,它应该有所帮助。 [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复段错误 `Delta` 影响值小于32位大小的列的编解ec。 该错误导致随机内存损坏。 [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([阿利沙平](https://github.com/alesapin)) +- 修复ttl合并中的段错误与块中的非物理列。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复在检查部分罕见的错误 `LowCardinality` 列。 前情提要 `checkDataPart` 总是失败的一部分 `LowCardinality` 列。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([阿利沙平](https://github.com/alesapin)) +- 避免在服务器线程池已满时挂起连接。 它是从连接重要 `remote` 当连接超时时,表函数或连接到没有副本的分片。 这修复 [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 支持常量参数 `evalMLModel` 功能。 这修复 [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了ClickHouse将默认时区确定为 `UCT` 而不是 `UTC`. 这修复 [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定缓冲区下溢 `visitParamExtractRaw`. 这修复 [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 现在分发 `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` 查询将直接在leader副本上执行。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([阿利沙平](https://github.com/alesapin)) +- 修复 `coalesce` 为 `ColumnConst` 与 `ColumnNullable` +相关变化. [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复 `ReadBufferFromKafkaConsumer` 所以它不断阅读新的消息后 `commit()` 即使它之前停滞不前 [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([伊万](https://github.com/abyss7)) +- 修复 `FULL` 和 `RIGHT` 加入时加入结果 `Nullable` 键在右表. [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([Artem Zuikov](https://github.com/4ertus2)) +- 可能修复低优先级查询的无限休眠。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复争用条件,这导致某些查询可能不会出现在query\_log后 `SYSTEM FLUSH LOGS` 查询。 [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([安东\*波波夫](https://github.com/CurtizJ)) +- 固定 `heap-use-after-free` 由手表引起的ClusterCopier中的警告尝试使用已经删除的复印机对象。 [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复错误 `StringRef` 由一些实现返回的指针 `IColumn::deserializeAndInsertFromArena`. 这个错误只影响单元测试。 [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 防止源数组和中间数组连接掩蔽相同名称列的列。 [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复插入并选择查询MySQL引擎与MySQL样式标识符引用。 [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([张冬](https://github.com/zhang2014)) +- 现在 `CHECK TABLE` 查询可以与MergeTree引擎系列一起使用。 它返回检查状态和消息,如果任何为每个部分(或文件在simplier引擎的情况下)。 此外,修复获取损坏部分的错误。 [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([阿利沙平](https://github.com/alesapin)) +- 修复SPLIT\_SHARED\_LIBRARY运行时 [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([Danila Kutenin](https://github.com/danlark1)) +- 固定时区初始化时 `/etc/localtime` 是一个相对的符号链接,如 `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- clickhouse复印机:修复使用-关机后免费 [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([proller](https://github.com/proller)) +- 更新 `simdjson`. 修复了一些无效的零字节Json成功解析的问题。 [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复系统日志的关机 [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复当invalidate\_query中的条件取决于字典时挂起。 [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) + +#### 改进 {#improvement-6} + +- 允许群集配置中的无法解析的地址。 它们将被视为不可用,并尝试在每次连接尝试时解决。 这对Kubernetes特别有用。 这修复 [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 关闭空闲TCP连接(默认情况下为一小时超时)。 这对于每台服务器上具有多个分布式表的大型集群尤其重要,因为每台服务器都可能保留与其他服务器的连接池,并且在高峰查询并发之后,连接将停 这修复 [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 更好的质量 `topK` 功能。 如果新元素具有更大的权重,则更改了SavingSpace set行为以删除最后一个元素。 [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 与域一起使用的URL函数现在可以在没有方案的情况下适用于不完整的Url [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([阿利沙平](https://github.com/alesapin)) +- 校验和添加到 `system.parts_columns` 桌子 [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) +- 已添加 `Enum` 数据类型作为synonim `Enum8` 或 `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([dimarub2000](https://github.com/dimarub2000)) +- 全位转置变种 `T64` 编解ec 可能会导致更好的压缩 `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([Artem Zuikov](https://github.com/4ertus2)) +- 条件 `startsWith` 函数现在可以使用主键。 这修复 [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) 和 [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([dimarub2000](https://github.com/dimarub2000)) +- 允许使用 `clickhouse-copier` 通过允许空数据库名称来实现具有交叉复制的群集拓扑。 [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([纳瓦托洛梅](https://github.com/nvartolomei)) +- 使用 `UTC` 作为系统上的默认时区,而不 `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` 被打印并且服务器或客户机拒绝启动。 [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 返回对函数中浮点参数的支持 `quantileTiming` 为了向后兼容性。 [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在错误消息中显示哪个表缺少列。 [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([伊万](https://github.com/abyss7)) +- 不允许不同用户使用相同的query\_id运行查询 [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([proller](https://github.com/proller)) +- 用于向Graphite发送指标的更强大的代码。 它甚至可以在长时间的多重工作 `RENAME TABLE` 操作。 [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 当ThreadPool无法计划执行任务时,将显示更多信息错误消息。 这修复 [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 反转ngramSearch更直观 [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([Danila Kutenin](https://github.com/danlark1)) +- 在HDFS引擎生成器中添加用户解析 [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([akonyaev90](https://github.com/akonyaev90)) +- 更新默认值 `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([Artem Konovalov](https://github.com/izebit)) +- 增加了过时设置的概念。 过时的设置 `allow_experimental_low_cardinality_type` 可以没有效果使用。 [0f15c01c6802f7ce1a1494c12c846be8c98944cd](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [Alexey Milovidov](https://github.com/alexey-milovidov) + +#### 性能改进 {#performance-improvement-4} + +- 增加从合并表中选择的流数量,以便更均匀地分布线程。 添加设置 `max_streams_multiplier_for_merge_tables`. 这修复 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-7} + +- 为与不同版本的clickhouse的客户端-服务器交互添加向后兼容性测试。 [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([阿利沙平](https://github.com/alesapin)) +- 每个提交和拉取请求中的测试复盖率信息。 [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([阿利沙平](https://github.com/alesapin)) +- 与address sanitizer合作,支持我们的自定义分alloc (`Arena` 和 `ArenaWithFreeLists`)为了更好地调试 “use-after-free” 错误。 [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([akuzm](https://github.com/akuzm)) +- 切换到 [LLVM libunwind实现](https://github.com/llvm-mirror/libunwind) 用于C++异常处理和堆栈跟踪打印 [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([尼基塔\*拉普科夫](https://github.com/laplab)) +- 添加来自-Weverything的两个警告 [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 允许用内存消毒剂建立ClickHouse。 [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 关于固定的ubsan报告 `bitTest` 在模糊测试功能。 [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- Docker:增加了初始化需要身份验证的ClickHouse实例的可能性。 [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([科尔维亚科夫\*安德烈](https://github.com/shurshun)) +- 将librdkafka更新到版本1.1.0 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([伊万](https://github.com/abyss7)) +- 为集成测试添加全局超时,并在测试代码中禁用其中一些。 [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([阿利沙平](https://github.com/alesapin)) +- 修复一些ThreadSanitizer故障。 [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([akuzm](https://github.com/akuzm)) +- 该 `--no-undefined` 选项强制链接器在链接时检查所有外部名称是否存在。 在拆分构建模式下跟踪库之间的真实依赖关系非常有用。 [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([伊万](https://github.com/abyss7)) +- 增加了性能测试 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 与gcc-7固定兼容性。 [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了对gcc-9的支持。 这修复 [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了libunwind链接不正确时的错误。 [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了PVS-Studio发现的一些警告。 [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了初始支持 `clang-tidy` 静态分析仪。 [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 转换BSD/Linux endian宏( ‘be64toh’ 和 ‘htobe64’)到Mac OS x当量 [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([傅辰](https://github.com/fredchenbj)) +- 改进的集成测试指南. [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 在macosx+gcc9修复构建 [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([filimonov](https://github.com/filimonov)) +- 修复难以识别的错字:aggreAGte-\>aggregate。 [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([akuzm](https://github.com/akuzm)) +- 修复freebsd构建 [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([proller](https://github.com/proller)) +- 添加链接到实验YouTube频道的网站 [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([伊万\*布林科夫](https://github.com/blinkov)) +- CMake:为复盖率标志添加选项:WITH\_COVERAGE [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([proller](https://github.com/proller)) +- 修复一些内联PODArray的初始大小。 [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([akuzm](https://github.com/akuzm)) +- clickhouse服务器.postinst:修复centos6的操作系统检测 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([proller](https://github.com/proller)) +- 添加Arch linux软件包生成。 [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([Vladimir Chebotarev](https://github.com/excitoon)) +- 拆分常见/配置.h by libs(dbms) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([proller](https://github.com/proller)) +- 修复了 “Arcadia” 构建平台 [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([proller](https://github.com/proller)) +- 修复了非常规构建(gcc9,没有子模块) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([proller](https://github.com/proller)) +- 在unalignedStore中需要显式类型,因为它被证明容易出现错误 [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([akuzm](https://github.com/akuzm)) +- 修复MacOS构建 [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([filimonov](https://github.com/filimonov)) +- 关于具有更大数据集的新JIT功能的性能测试,请参阅此处 [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 在压力测试中运行有状态测试 [12693e568722f11e19859742f56428455501fd2a](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([阿利沙平](https://github.com/alesapin)) + +#### 向后不兼容的更改 {#backward-incompatible-change-7} + +- `Kafka` 在这个版本中被打破。 +- 启用 `adaptive_index_granularity` =10mb默认为新 `MergeTree` 桌子 如果您在19.11+版本上创建了新的MergeTree表,则不可能降级到19.6之前的版本。 [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([阿利沙平](https://github.com/alesapin)) +- 删除了Yandex使用的过时无证嵌入式字典。梅特里卡 功能 `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` 不再可用。 如果您正在使用这些功能,请写电子邮件至clickhouse-feedback@yandex-team.com注:在最后时刻,我们决定保持这些功能一段时间。 [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +## ClickHouse释放19.10 {#clickhouse-release-19-10} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-10-1-5-2019-07-12} + +#### 新功能 {#new-feature-7} + +- 添加新列编解ec: `T64`. 为(U)IntX/EnumX/Data(时间)/DecimalX列制作。 它应该适用于具有常量或小范围值的列。 编解码器本身允许放大或缩小数据类型而无需重新压缩。 [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([Artem Zuikov](https://github.com/4ertus2)) +- 添加数据库引擎 `MySQL` 允许查看远程MySQL服务器中的所有表 [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([张冬](https://github.com/zhang2014)) +- `bitmapContains` 执行。 这是2倍的速度比 `bitmapHasAny` 如果第二个位图包含一个元素。 [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([余志昌](https://github.com/yuzhichang)) +- 支持 `crc32` 功能(与MySQL或PHP中的行为完全相同)。 如果您需要散列函数,请不要使用它。 [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen Ivan](https://github.com/BHYCHIK)) +- 已实施 `SYSTEM START/STOP DISTRIBUTED SENDS` 查询控制异步插入到 `Distributed` 桌子 [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([张冬](https://github.com/zhang2014)) + +#### 错误修复 {#bug-fix-22} + +- 在执行突变时忽略查询执行限制和合并限制的最大部件大小。 [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复可能导致重复数据删除正常块(极其罕见)和插入重复块(更常见)的错误。 [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([阿利沙平](https://github.com/alesapin)) +- 功能修复 `arrayEnumerateUniqRanked` 对于具有空数组的参数 [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([proller](https://github.com/proller)) +- 不要在没有轮询任何消息的情况下订阅Kafka主题。 [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([伊万](https://github.com/abyss7)) +- 使设置 `join_use_nulls` 对于不能在Nullable内的类型不起作用 [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([Olga Khvostikova](https://github.com/stavrolia)) +- 固定 `Incorrect size of index granularity` 错误 [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([coraxster](https://github.com/coraxster)) +- 修正浮动到十进制转换溢出 [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([coraxster](https://github.com/coraxster)) +- 冲洗缓冲区时 `WriteBufferFromHDFS`的析构函数被调用。 这修复了写入 `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([新东鹏](https://github.com/eejoin)) + +#### 改进 {#improvement-7} + +- 对待空单元格 `CSV` 作为默认值时的设置 `input_format_defaults_for_omitted_fields` 被启用。 [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) +- 外部字典的非阻塞加载。 [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 可以根据设置动态更改已建立的连接的网络超时。 [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([Konstantin Podshumok](https://github.com/podshumok)) +- 使用 “public\_suffix\_list” 对于功能 `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. 它使用一个完美的哈希表生成 `gperf` 从文件生成的列表:https://publicsuffix.org/list/public\_suffix\_list.dat(例如,现在我们认识到域 `ac.uk` 作为非显着)。 [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 通过 `IPv6` 系统表中的数据类型;统一客户端信息列 `system.processes` 和 `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使用会话与MySQL兼容性协议的连接。 \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 支持更多 `ALTER` 查询 `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([sundyli](https://github.com/sundy-li)) +- 碌莽禄Support: `` 第1节 `clickhouse-local` 配置文件。 [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([proller](https://github.com/proller)) +- 允许运行查询 `remote` 表函数 `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([proller](https://github.com/proller)) + +#### 性能改进 {#performance-improvement-5} + +- 添加在MergeTree列末尾写最后标记的可能性。 它允许避免对超出表数据范围的键进行无用的读取。 仅当使用自适应索引粒度时才启用此功能。 [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([阿利沙平](https://github.com/alesapin)) +- 通过减少非常慢的文件系统上的MergeTree表的性能 `stat` syscalls [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了从版本19.6中引入的MergeTree表读取时的性能下降。 修复#5631。 [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-8} + +- 已实施 `TestKeeper` 作为用于测试的ZooKeeper接口的实现 [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) ([levushkin aleksej](https://github.com/alexey-milovidov)) +- 从现在起 `.sql` 测试可以通过服务器隔离,并行运行,并使用随机数据库。 它允许更快地运行它们,使用自定义服务器配置添加新的测试,并确保不同的测试不会相互影响。 [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([伊万](https://github.com/abyss7)) +- 删除 `` 和 `` 从性能测试 [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([Olga Khvostikova](https://github.com/stavrolia)) +- 固定 “select\_format” 性能测试 `Pretty` 格式 [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +## ClickHouse释放19.9 {#clickhouse-release-19-9} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-9-3-31-2019-07-05} + +#### 错误修复 {#bug-fix-23} + +- 修复增量编解码器中的段错误,这会影响值小于32位大小的列。 该错误导致随机内存损坏。 [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([阿利沙平](https://github.com/alesapin)) +- 修复在检查部分低心率列中罕见的错误。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([阿利沙平](https://github.com/alesapin)) +- 修复ttl合并中的段错误与块中的非物理列。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复低优先级查询的潜在无限休眠。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复ClickHouse如何将默认时区确定为UCT而不是UTC。 [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复在领导者副本之前的跟随者副本上执行分布式删除/更改/截断/优化集群查询的错误。 现在他们将直接在领导者副本上执行。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([阿利沙平](https://github.com/alesapin)) +- 修复了系统刷新日志查询后某些查询可能不会立即出现在query\_log中的竞争条件。 [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([安东\*波波夫](https://github.com/CurtizJ)) +- 增加了对常量参数的缺失支持 `evalMLModel` 功能。 [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-9-2-4-2019-06-24} + +#### 新功能 {#new-feature-8} + +- 打印有关冷冻部件的信息 `system.parts` 桌子 [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([proller](https://github.com/proller)) +- 在clickhouse上询问客户端密码-如果未在参数中设置,则在tty上启动客户端 [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([proller](https://github.com/proller)) +- 执行 `dictGet` 和 `dictGetOrDefault` 十进制类型的函数。 [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 改进 {#improvement-8} + +- Debian的初始化:添加服务停止超时 [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([proller](https://github.com/proller)) +- 默认情况下添加禁止设置,以创建具有可疑类型的表格 [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([Olga Khvostikova](https://github.com/stavrolia)) +- 当不用作函数中的状态时,回归函数返回模型权重 `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([Quid37](https://github.com/Quid37)) +- 重命名和改进回归方法。 [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([Quid37](https://github.com/Quid37)) +- 更清晰的字符串搜索界面。 [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([Danila Kutenin](https://github.com/danlark1)) + +#### 错误修复 {#bug-fix-24} + +- 修复Kafka中潜在的数据丢失 [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([伊万](https://github.com/abyss7)) +- 修复潜在的无限循环 `PrettySpace` 使用零列调用时的格式 [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([Olga Khvostikova](https://github.com/stavrolia)) +- 修正了线性模型中的UInt32溢出错误。 允许对非常量模型参数的eval ML模型。 [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- `ALTER TABLE ... DROP INDEX IF EXISTS ...` 如果提供的索引不存在,则不应引发异常 [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) +- 修复段错误 `bitmapHasAny` 在标量子查询中 [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([余志昌](https://github.com/yuzhichang)) +- 修复了复制连接池不重试解析主机时的错误,即使删除了DNS缓存。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([阿利沙平](https://github.com/alesapin)) +- 固定 `ALTER ... MODIFY TTL` 在ReplicatedMergeTree上。 [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([安东\*波波夫](https://github.com/CurtizJ)) +- 修复插入到具体化列的分布式表中 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) +- 修复截断联接存储时的错误alloc [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([TCeason](https://github.com/TCeason)) +- 在最近版本的包tzdata中,现在有些文件是符号链接。 当前用于检测默认时区的机制被打破,并为某些时区提供错误的名称。 现在至少我们强制时区名称到TZ的内容,如果提供。 [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([伊万](https://github.com/abyss7)) +- 修复一些极为罕见的情况下,MultiVolnitsky搜索器时,在总和恒定针至少16KB长。 该算法错过或复盖以前的结果,这可能导致错误的结果 `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([Danila Kutenin](https://github.com/danlark1)) +- 修复ExternalData请求的设置无法使用ClickHouse设置时的问题。 此外,现在,设置 `date_time_input_format` 和 `low_cardinality_allow_in_native_format` 由于名称的歧义,无法使用(在外部数据中,它可以解释为表格式,在查询中它可以是一个设置)。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila Kutenin](https://github.com/danlark1)) +- 修复只从FS中删除部件而不从Zookeeper中删除部件时的错误。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([阿利沙平](https://github.com/alesapin)) +- 从MySQL协议中删除调试日志记录 [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在DDL查询处理过程中跳过ZNONODE [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) +- 修复混合 `UNION ALL` 结果列类型。 有些情况下,结果列的数据和列类型不一致。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) +- 在错误的整数上抛出异常 `dictGetT` 功能,而不是崩溃。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复散列字典中错误的element\_count和load\_factor `system.dictionaries` 桌子 [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-9} + +- 固定构建没有 `Brotli` HTTP压缩支持 (`ENABLE_BROTLI=OFF` cmake变量)。 [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([Anton Yuzhaninov](https://github.com/citrin)) +- 包括ro哮。h为ro哮/咆哮。h [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([Origej Desh](https://github.com/orivej)) +- 修复超扫描中的gcc9警告(#行指令是邪恶的!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([Danila Kutenin](https://github.com/danlark1)) +- 使用gcc-9编译时修复所有警告。 修复一些contrib问题。 修复gcc9ICE并将其提交给bugzilla。 [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([Danila Kutenin](https://github.com/danlark1)) +- 与lld固定链接 [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 删除字典中未使用的专业化 [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([Artem Zuikov](https://github.com/4ertus2)) +- 针对不同类型的文件进行格式化和解析表的改进性能测试 [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([Olga Khvostikova](https://github.com/stavrolia)) +- 修复并行测试运行 [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([proller](https://github.com/proller)) +- Docker:使用clickhouse-test中的configs [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([proller](https://github.com/proller)) +- 修复编译为FreeBSD [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([proller](https://github.com/proller)) +- 升级提升到1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([proller](https://github.com/proller)) +- 修复构建clickhouse作为子模块 [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([proller](https://github.com/proller)) +- 改进JSONExtract性能测试 [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) + +## ClickHouse释放19.8 {#clickhouse-release-19-8} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-8-3-8-2019-06-11} + +#### 新功能 {#new-features} + +- 添加了与JSON一起使用的函数 [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([hcz](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 添加一个函数basename,具有类似于basename函数的行为,它存在于许多语言中 (`os.path.basename` 在python中, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 已添加 `LIMIT n, m BY` 或 `LIMIT m OFFSET n BY` 为LIMIT BY子句设置n偏移量的语法。 [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([安东\*波波夫](https://github.com/CurtizJ)) +- 增加了新的数据类型 `SimpleAggregateFunction`,它允许在一个具有光聚集的列 `AggregatingMergeTree`. 这只能用于简单的功能,如 `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([Boris Granveaud](https://github.com/bgranvea)) +- 增加了对函数中非常量参数的支持 `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([Danila Kutenin](https://github.com/danlark1)) +- 新增功能 `skewPop`, `skewSamp`, `kurtPop` 和 `kurtSamp` 分别计算序列偏度、样本偏度、峰度和样本峰度。 [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([hcz](https://github.com/hczhcz)) +- 支持重命名操作 `MaterializeView` 存储。 [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 添加了允许使用MySQL客户端连接到ClickHouse的服务器。 [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 添加 `toDecimal*OrZero` 和 `toDecimal*OrNull` 功能。 [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([Artem Zuikov](https://github.com/4ertus2)) +- 支持函数中的十进制类型: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted` 媒体加权。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) +- 已添加 `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([Danila Kutenin](https://github.com/danlark1)) +- 已添加 `format` 功能。 使用参数中列出的字符串格式化常量模式(简化的Python格式模式)。 [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([Danila Kutenin](https://github.com/danlark1)) +- 已添加 `system.detached_parts` 表包含有关分离部分的信息 `MergeTree` 桌子 [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([akuzm](https://github.com/akuzm)) +- 已添加 `ngramSearch` 函数来计算针和大海捞针之间的非对称差异。 [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([Danila Kutenin](https://github.com/danlark1)) +- 使用聚合函数接口实现基本的机器学习方法(随机线性回归和逻辑回归)。 有不同的策略,用于更新模型权重(简单梯度下降,动量法,涅斯捷罗夫法)。 还支持自定义大小的小批次。 [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([Quid37](https://github.com/Quid37)) +- 执行 `geohashEncode` 和 `geohashDecode` 功能。 [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 添加聚合功能 `timeSeriesGroupSum`,从而可以聚合不同的时间序列,即采样时间戳不对齐。 它将在两个采样时间戳之间使用线性插值,然后将时间序列和在一起。 添加聚合功能 `timeSeriesGroupRateSum`,它计算时间序列的速率,然后将速率总和在一起。 [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([刘杨宽](https://github.com/LiuYangkuan)) +- 新增功能 `IPv4CIDRtoIPv4Range` 和 `IPv6CIDRtoIPv6Range` 使用CIDR计算子网中IP的下限和上限。 [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) +- 添加一个X-ClickHouse-Summary头,当我们发送查询使用HTTP启用设置 `send_progress_in_http_headers`. 返回X-ClickHouse-Progress的常用信息,以及其他信息,例如在查询中插入了多少行和字节。 [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) + +#### 改进 {#improvements} + +- 已添加 `max_parts_in_total` 设置表的MergeTree家族(默认:100 000)防止分区键的不安全规范\#5166. [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `clickhouse-obfuscator`:通过将初始种子与列名(而不是列位置)组合来派生单个列的种子。 这用于转换具有多个相关表的数据集,以便在转换后表将保持可联接。 [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 新增功能 `JSONExtractRaw`, `JSONExtractKeyAndValues`. 重命名函数 `jsonExtract` 到 `JSONExtract`. 当出现问题时,这些函数返回对应的值,而不是 `NULL`. 修改功能 `JSONExtract`,现在它从最后一个参数中获取返回类型,并且不会注入nullables。 在AVX2指令不可用的情况下实现了回退到RapidJSON。 Simdjson库更新到新版本。 [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 现在 `if` 和 `multiIf` 功能不依赖于条件的 `Nullable`,但依靠分支来实现sql兼容性。 [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([吴健](https://github.com/janplus)) +- `In` 谓词现在生成 `Null` 结果来自 `Null` 输入像 `Equal` 功能。 [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([吴健](https://github.com/janplus)) +- 检查来自Kafka的每个(flush\_interval/poll\_timeout)行数的时间限制。 这允许更频繁地中断Kafka consumer的读取,并检查顶级流的时间限制 [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([伊万](https://github.com/abyss7)) +- 链接rdkafka捆绑的SASL。 它应该允许使用SASL SCRAM身份验证 [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([伊万](https://github.com/abyss7)) +- 所有联接的RowRefList的批处理版本。 [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([Artem Zuikov](https://github.com/4ertus2)) +- clickhouse服务器:更多信息侦听错误消息。 [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([proller](https://github.com/proller)) +- 在clickhouse-复印机的功能支持字典 `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([proller](https://github.com/proller)) +- 添加新设置 `kafka_commit_every_batch` 来规范卡夫卡的承诺政策。 + 它允许设置提交模式:在处理每批消息之后,或者在整个块写入存储之后。 这是在某些极端情况下丢失一些消息或阅读两次之间的权衡。 [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([伊万](https://github.com/abyss7)) +- 赂眉露\>\> `windowFunnel` 支持其他无符号整数类型。 [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([sundyli](https://github.com/sundy-li)) +- 允许对虚拟列进行阴影 `_table` 在合并引擎。 [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([伊万](https://github.com/abyss7)) +- 赂眉露\>\> `sequenceMatch` 聚合函数支持其他无符号整数类型 [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([sundyli](https://github.com/sundy-li)) +- 如果校验和不匹配很可能是由硬件故障引起的,则更好的错误消息。 [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 检查基础表是否支持以下内容的采样 `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([伊万](https://github.com/abyss7)) +- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) +- MySQL线协议的改进。 将格式名称更改为MySQLWire。 使用RAII调用RSA\_free。 如果无法创建上下文,则禁用SSL。 [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([proller](https://github.com/proller)) +- 尊重异步插入到分布式表中的查询设置。 [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([TCeason](https://github.com/TCeason)) +- 重命名函数 `leastSqr` 到 `simpleLinearRegression`, `LinearRegression` 到 `linearRegression`, `LogisticRegression` 到 `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) + +#### 性能改进 {#performance-improvements} + +- 在ALTER MODIFY查询中并行处理非复制MergeTree表的部分。 [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([伊万库什](https://github.com/IvanKush)) +- Regular达式提取中的优化。 [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([Danila Kutenin](https://github.com/danlark1)) +- 如果仅在join on部分中使用,则不要将右连接键列添加到join result。 [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([Artem Zuikov](https://github.com/4ertus2)) +- 在第一个空响应之后冻结Kafka缓冲区。 它避免了多次调用 `ReadBuffer::next()` 对于一些行解析流的空结果。 [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([伊万](https://github.com/abyss7)) +- `concat` 多个参数的函数优化。 [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([Danila Kutenin](https://github.com/danlark1)) +- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([Artem Zuikov](https://github.com/4ertus2)) +- 使用reference one升级我们的LZ4实现以获得更快的解压缩。 [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([Danila Kutenin](https://github.com/danlark1)) +- 实现了MSD基数排序(基于kxsort)和部分排序。 [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([Evgenii Pravda](https://github.com/kvinty)) + +#### 错误修复 {#bug-fixes} + +- 修复推送需要列与联接 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([张冬](https://github.com/zhang2014)) +- 修正了当ClickHouse由systemd运行时,命令 `sudo service clickhouse-server forcerestart` 没有按预期工作。 [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([proller](https://github.com/proller)) +- 修复DataPartsExchange中的http错误代码(9009端口上的服务器间http服务器始终返回代码200,即使是错误)。 [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([proller](https://github.com/proller)) +- 修复SimpleAggregateFunction字符串长于MAX\_SMALL\_STRING\_SIZE [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([Azat Khuzhin](https://github.com/azat)) +- 修复错误 `Decimal` 到 `Nullable(Decimal)` 转换中。 支持其他十进制到十进制转换(包括不同的比例)。 [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([Artem Zuikov](https://github.com/4ertus2)) +- 修正了simdjson库中导致错误计算的FPU clobbering `uniqHLL` 和 `uniqCombined` 聚合函数和数学函数,如 `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定处理JSON函数中的混合常量/非常量情况。 [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复 `retention` 功能。 现在所有满足一行数据的条件都被添加到数据状态。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) +- 修复结果类型 `quantileExact` 用小数。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 文件 {#documentation} + +- 翻译文档 `CollapsingMergeTree` 到中国。 [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) +- 将一些关于表格引擎的文档翻译成中文。 + [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) + [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) + ([永远不会李](https://github.com/neverlee)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements} + +- 修复一些显示可能使用后免费的消毒剂报告。[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([伊万](https://github.com/abyss7)) +- 为了方便起见,将性能测试从单独的目录中移出。 [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复不正确的性能测试。 [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([阿利沙平](https://github.com/alesapin)) +- 增加了一个工具来计算由位翻转引起的校验和,以调试硬件问题。 [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使亚军脚本更有用。 [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([filimonov](https://github.com/filimonov)) +- 添加如何编写性能测试的小指令。 [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([阿利沙平](https://github.com/alesapin)) +- 添加在性能测试中创建,填写和删除查询中进行替换的功能 [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([Olga Khvostikova](https://github.com/stavrolia)) + +## ClickHouse释放19.7 {#clickhouse-release-19-7} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-7-5-29-2019-07-05} + +#### 错误修复 {#bug-fix-25} + +- 使用JOIN修复某些查询中的性能回归。 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([张冬](https://github.com/zhang2014)) + +### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102003042 {#clickhouse-release-19-7-5-27-2019-06-09} + +#### 新功能 {#new-features-1} + +- 添加位图相关功能 `bitmapHasAny` 和 `bitmapHasAll` 类似于 `hasAny` 和 `hasAll` 数组的函数。 [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([塞尔吉\*弗拉季金](https://github.com/svladykin)) + +#### 错误修复 {#bug-fixes-1} + +- 修复段错误 `minmax` 具有空值的索引。 [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 根据需要输出标记"LIMIT BY"中的所有输入列。 它修复 ‘Not found column’ 某些分布式查询中出错。 [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([康斯坦丁\*潘](https://github.com/kvap)) +- 修复 “Column ‘0’ already exists” 错误 `SELECT .. PREWHERE` 在具有默认值的列上 [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([proller](https://github.com/proller)) +- 修复 `ALTER MODIFY TTL` 查询开 `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([安东\*波波夫](https://github.com/CurtizJ)) +- 当Kafka消费者无法启动时,不要使服务器崩溃。 [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([伊万](https://github.com/abyss7)) +- 固定位图函数产生错误的结果。 [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([杨小姐](https://github.com/andyyzh)) +- 修复散列字典的element\_count(不包括重复项) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) +- 使用环境变量TZ的内容作为时区的名称。 在某些情况下,它有助于正确检测默认时区。[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([伊万](https://github.com/abyss7)) +- 不要试图将整数转换为 `dictGetT` 功能,因为它不能正常工作。 而是抛出一个异常。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) +- 在ExternalData HTTP请求修复设置。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila + 库特宁](https://github.com/danlark1)) +- 修复只从FS中删除部件而不从Zookeeper中删除部件时的错误。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([阿利沙平](https://github.com/alesapin)) +- 修复分段故障 `bitmapHasAny` 功能。 [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([余志昌](https://github.com/yuzhichang)) +- 修复了复制连接池不重试解析主机时的错误,即使删除了DNS缓存。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([阿利沙平](https://github.com/alesapin)) +- 固定 `DROP INDEX IF EXISTS` 查询。 现在 `ALTER TABLE ... DROP INDEX IF EXISTS ...` 如果提供的索引不存在,查询不会引发异常。 [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) +- 修复联合所有超类型列。 有些情况下,结果列的数据和列类型不一致。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) +- 在DDL查询处理过程中跳过ZNONODE。 之前,如果另一个节点删除znode在任务队列中,那一个 + 没有处理它,但已经得到子列表,将终止DDLWorker线程。 [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) +- 修复插入到具体化列的分布式()表中。 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-7-3-9-2019-05-30} + +#### 新功能 {#new-features-2} + +- 允许限制用户可以指定的设置的范围。 + 这些约束可以在用户设置配置文件中设置。 + [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([维塔利 + 巴拉诺夫](https://github.com/vitlibar)) +- 添加该函数的第二个版本 `groupUniqArray` 用一个可选的 + `max_size` 限制结果数组大小的参数。 这 + 行为类似于 `groupArray(max_size)(x)` 功能。 + [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([纪尧姆 + Tassery](https://github.com/YiuRULE)) +- 对于TSVWithNames/CSVWithNames输入文件格式,列顺序现在可以是 + 从文件头确定。 这是由控制 + `input_format_with_names_use_header` 参数。 + [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) + ([亚历山大](https://github.com/Akazz)) + +#### 错误修复 {#bug-fixes-2} + +- 在合并过程中uncompressed\_cache+JOIN崩溃(#5197) + [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([Danila + 库特宁](https://github.com/danlark1)) +- Clickhouse客户端查询到系统表上的分段错误。 \#5066 + [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) + ([伊万](https://github.com/abyss7)) +- 通过KafkaEngine重负载数据丢失(#4736) + [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) + ([伊万](https://github.com/abyss7)) +- 修复了在执行UNION查询时可能发生的非常罕见的数据争用条件,所有查询都涉及至少两个来自系统的选择。列,系统。表,系统。部件,系统。parts\_tables或Merge系列的表,并同时执行相关表的列的更改。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 性能改进 {#performance-improvements-1} + +- 使用基数排序按单个数字列进行排序 `ORDER BY` 没有 + `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), + [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) + ([Evgenii Pravda](https://github.com/kvinty), + [阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 文件 {#documentation-1} + +- 将某些表格引擎的文档翻译为中文。 + [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), + [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), + [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) + ([张风啸](https://github.com/AlexZFX)), + [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([从来没有 + 李](https://github.com/neverlee)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-1} + +- 正确打印UTF-8字符 `clickhouse-test`. + [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) + ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 为clickhouse-client添加命令行参数以始终加载建议 + 戴达 [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) + ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 解决一些PVS-Studio警告。 + [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) + ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 更新LZ4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([Danila + 库特宁](https://github.com/danlark1)) +- 添加gperf以构建即将到来的拉取请求#5030的requirements。 + [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) + ([proller](https://github.com/proller)) + +## ClickHouse释放19.6 {#clickhouse-release-19-6} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-6-3-18-2019-06-13} + +#### 错误修复 {#bug-fixes-3} + +- 修复了来自表函数的查询的条件下推 `mysql` 和 `odbc` 和相应的表引擎。 这修复了#3540和#2384。 [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复动物园管理员的死锁。 [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([github1youlc](https://github.com/github1youlc)) +- 允许在CSV中引用小数。 [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([Artem Zuikov](https://github.com/4ertus2) +- 禁止从float Inf/NaN转换为小数(抛出异常)。 [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复重命名查询中的数据竞赛。 [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([张冬](https://github.com/zhang2014)) +- 暂时禁用LFAlloc。 使用LFAlloc可能会导致大量MAP\_FAILED在分配UncompressedCache时,并导致高负载服务器上的查询崩溃。 [cfdba93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([Danila Kutenin](https://github.com/danlark1)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-6-2-11-2019-05-13} + +#### 新功能 {#new-features-3} + +- 列和表的TTL表达式。 [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([安东\*波波夫](https://github.com/CurtizJ)) +- 增加了对 `brotli` http响应的压缩(接受编码:br) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([米哈伊尔](https://github.com/fandyushin)) +- 增加了新功能 `isValidUTF8` 用于检查一组字节是否被正确地utf-8编码。 [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([Danila Kutenin](https://github.com/danlark1)) +- 添加新的负载平衡策略 `first_or_random` 它将查询发送到第一个指定的主机,如果无法访问,则向分片的随机主机发送查询。 对于跨复制拓扑设置非常有用。 [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([纳瓦托洛梅](https://github.com/nvartolomei)) + +#### 实验特点 {#experimental-features-1} + +- 添加设置 `index_granularity_bytes` (自适应索引粒度)对于MergeTree\*表族. [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([阿利沙平](https://github.com/alesapin)) + +#### 改进 {#improvements-1} + +- 增加了对函数的非常量和负大小和长度参数的支持 `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在左联接中禁用向下推到右表,在右联接中禁用左表,并在完全联接中禁用两个表。 在某些情况下,这可以修复错误的连接结果。 [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([伊万](https://github.com/abyss7)) +- `clickhouse-copier`:从自动上传任务配置 `--task-file` 备选案文 [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([proller](https://github.com/proller)) +- 为存储工厂和表函数工厂添加了错别字处理程序。 [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([Danila Kutenin](https://github.com/danlark1)) +- 支持不带子查询的多个联接的星号和限定星号 [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([Artem Zuikov](https://github.com/4ertus2)) +- 使缺少列错误消息更加用户友好。 [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 性能改进 {#performance-improvements-2} + +- ASOF加速显着 [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([Martijn Bakker](https://github.com/Gladdy)) + +#### 向后不兼容的更改 {#backward-incompatible-changes} + +- HTTP头 `Query-Id` 改名为 `X-ClickHouse-Query-Id` 为了一致性。 [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([米哈伊尔](https://github.com/fandyushin)) + +#### 错误修复 {#bug-fixes-4} + +- 修正了潜在的空指针取消引用 `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([proller](https://github.com/proller)) +- 修复了使用JOIN+ARRAY JOIN查询的错误 [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([Artem Zuikov](https://github.com/4ertus2)) +- 固定挂在服务器的启动时,字典依赖于另一个字典通过引擎数据库=字典。 [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- Partially fix distributed\_product\_mode = local. It's possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There's not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复潜在的错误结果 `SELECT DISTINCT` 与 `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复了在执行UNION查询时可能发生的非常罕见的数据争用条件,所有查询都涉及至少两个来自系统的选择。列,系统。表,系统。部件,系统。parts\_tables或Merge系列的表,并同时执行相关表的列的更改。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-2} + +- 在不同的主机上运行clickhouse服务器时修复测试失败 [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- clickhouse-test:在非tty环境中禁用颜色控制序列。 [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([阿利沙平](https://github.com/alesapin)) +- clickhouse-test:允许使用任何测试数据库(删除 `test.` 在可能的情况下获得资格) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([proller](https://github.com/proller)) +- 修复ubsan错误 [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- Yandex LFAlloc被添加到ClickHouse中,以不同的方式分配MarkCache和UncompressedCache数据,以更可靠地捕获段错误 [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([Danila Kutenin](https://github.com/danlark1)) +- Python util帮助反向移植和更改日志。 [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([伊万](https://github.com/abyss7)) + +## ClickHouse释放19.5 {#clickhouse-release-19-5} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-5-4-22-2019-05-13} + +#### 错误修复 {#bug-fixes-5} + +- 修正了位图\*功能中可能出现的崩溃 [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([杨小姐](https://github.com/andyyzh)) +- 修复了在执行UNION查询时可能发生的非常罕见的数据争用条件,所有查询都涉及至少两个来自系统的选择。列,系统。表,系统。部件,系统。parts\_tables或Merge系列的表,并同时执行相关表的列的更改。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误 `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. 如果lowcardinality列是主键的一部分,则会发生此错误。 \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修改保留函数:如果一行同时满足第一个和第N个条件,则只有第一个满足的条件被添加到数据状态。 现在所有满足一行数据的条件都被添加到数据状态。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-5-3-8-2019-04-18} + +#### 错误修复 {#bug-fixes-6} + +- 固定设置类型 `max_partitions_per_insert_block` 从布尔到UInt64。 [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([2.Mohammad Hossein Sekhavat](https://github.com/mhsekhavat)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-5-2-6-2019-04-15} + +#### 新功能 {#new-features-4} + +- [超扫描](https://github.com/intel/hyperscan) 添加了多个正则表达式匹配(函数 `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([Danila Kutenin](https://github.com/danlark1)) +- `multiSearchFirstPosition` 添加了功能。 [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) +- 为表实现每行的预定义表达式筛选器。 [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([伊万](https://github.com/abyss7)) +- 一种基于bloom过滤器的新型数据跳过索引(可用于 `equal`, `in` 和 `like` 功能)。 [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 已添加 `ASOF JOIN` 它允许运行连接到最新已知值的查询。 [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([Martijn Bakker](https://github.com/Gladdy), [Artem Zuikov](https://github.com/4ertus2)) +- 重写多个 `COMMA JOIN` 到 `CROSS JOIN`. 然后将它们重写为 `INNER JOIN` 如果可能的话 [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 改进 {#improvement-9} + +- `topK` 和 `topKWeighted` 现在支持自定义 `loadFactor` (修复问题 [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([基里尔丹信](https://github.com/kirillDanshin)) +- 允许使用 `parallel_replicas_count > 1` 即使对于没有采样的表(设置简单地忽略它们)。 在以前的版本中,它导致异常。 [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([Alexey Elymanov](https://github.com/digitalist)) +- 支持 `CREATE OR REPLACE VIEW`. 允许在单个语句中创建视图或设置新定义。 [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([Boris Granveaud](https://github.com/bgranvea)) +- `Buffer` 表引擎现在支持 `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([刘杨宽](https://github.com/LiuYangkuan)) +- 添加在zookeeper中启动没有元数据的复制表的能力 `readonly` 模式 [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([阿利沙平](https://github.com/alesapin)) +- 在clickhouse客户端固定进度条闪烁。 使用时,这个问题最明显 `FORMAT Null` 随着流查询。 [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 允许禁用功能 `hyperscan` 基于每个用户的库,以限制潜在的过度和不受控制的资源使用。 [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加版本号记录所有错误。 [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([proller](https://github.com/proller)) +- 增加了限制 `multiMatch` 需要字符串大小以适应的函数 `unsigned int`. 还增加了参数的数量限制 `multiSearch` 功能。 [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([Danila Kutenin](https://github.com/danlark1)) +- 改进了超扫描暂存空间的使用和错误处理。 [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([Danila Kutenin](https://github.com/danlark1)) +- 填充 `system.graphite_detentions` 从表配置 `*GraphiteMergeTree` 发动机表. [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- 重命名 `trigramDistance` 功能 `ngramDistance` 并添加更多的功能 `CaseInsensitive` 和 `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([Danila Kutenin](https://github.com/danlark1)) +- 改进的数据跳过指数计算。 [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 保持平凡, `DEFAULT`, `MATERIALIZED` 和 `ALIAS` 在一个列表中的列(修复问题 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) + +#### 错误修复 {#bug-fix-26} + +- 避免 `std::terminate` 在内存分配失败的情况下。 现在 `std::bad_alloc` 按预期引发异常。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复capnproto从缓冲区读取。 有时文件没有通过HTTP成功加载。 [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([弗拉季斯拉夫](https://github.com/smirnov-vs)) +- 修复错误 `Unknown log entry type: 0` 后 `OPTIMIZE TABLE FINAL` 查询。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([阿莫斯鸟](https://github.com/amosbird)) +- 错误的参数 `hasAny` 或 `hasAll` 函数可能会导致段错误。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 执行时可能会发生死锁 `DROP DATABASE dictionary` 查询。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复未定义的行为 `median` 和 `quantile` 功能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +- 修复压缩级别检测时 `network_compression_method` 小写。 在19.1节中被打破。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) +- 固定的无知 `UTC` 设置(修复问题 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) +- 修复 `histogram` 函数行为 `Distributed` 桌子 [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) +- 固定tsan报告 `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了由于系统日志使用中的争用条件而关闭的TSan报告。 修复了当part\_log启用时关机后的潜在使用。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复重新检查零件 `ReplicatedMergeTreeAlterThread` 在错误的情况下。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 对中间聚合函数状态的算术运算不适用于常量参数(如子查询结果)。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 始终在元数据中反引用列名。 否则,不可能创建一个名为列的表 `index` (由于格式错误,服务器无法重新启动 `ATTACH` 元数据中的查询)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复崩溃 `ALTER ... MODIFY ORDER BY` 上 `Distributed` 桌子 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) +- 修复段错误 `JOIN ON` 已启用 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([张冬](https://github.com/zhang2014)) +- 修复kafka使用protobuf消息后添加无关行的错误。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复崩溃 `JOIN` 在不可为空的vs可为空的列上。 修复 `NULLs` 在右键 `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) +- 在固定的竞争条件 `SELECT` 从 `system.tables` 如果同时重命名或更改表。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 获取已经过时的数据部分时修复了数据竞赛。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定罕见的数据竞赛,可以在发生 `RENAME` MergeTree家族的表. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正功能中的分段故障 `arrayIntersect`. 如果函数使用常量和普通参数混合调用,则可能会发生分段错误。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([钱丽祥](https://github.com/fancyqlx)) +- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复崩溃 `FULL/RIGHT JOIN` 当我们加入可为空vs不可为空时。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复 `No message received` 在副本之间获取部件时出现异常。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([阿利沙平](https://github.com/alesapin)) +- 固定 `arrayIntersect` 函数错误导致在单个数组中的几个重复值的情况下。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 在并发期间修复争用条件 `ALTER COLUMN` 可能导致服务器崩溃的查询(修复问题 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修复不正确的结果 `FULL/RIGHT JOIN` 与常量列。 [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复重复 `GLOBAL JOIN` 用星号。 [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复参数扣除 `ALTER MODIFY` 列 `CODEC` 未指定列类型时。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([阿利沙平](https://github.com/alesapin)) +- 功能 `cutQueryStringAndFragment()` 和 `queryStringAndFragment()` 现在正常工作时 `URL` 包含一个片段,没有查询。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复设置时罕见的错误 `min_bytes_to_use_direct_io` 大于零,这发生在线程必须在列文件中向后寻找时。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([阿利沙平](https://github.com/alesapin)) +- 修复聚合函数的错误参数类型 `LowCardinality` 参数(修复问题 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复错误的名称资格 `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复功能 `toISOWeek` 1970年的结果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复 `DROP`, `TRUNCATE` 和 `OPTIMIZE` 查询重复,在执行时 `ON CLUSTER` 为 `ReplicatedMergeTree*` 表家庭. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([阿利沙平](https://github.com/alesapin)) + +#### 向后不兼容的更改 {#backward-incompatible-change-8} + +- 重命名设置 `insert_sample_with_metadata` 到设置 `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([Artem Zuikov](https://github.com/4ertus2)) +- 添加设置 `max_partitions_per_insert_block` (默认值为100)。 如果插入的块包含较大数量的分区,则会引发异常。 如果要删除限制(不推荐),请将其设置为0。 [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 多搜索功能被重命名 (`multiPosition` 到 `multiSearchAllPositions`, `multiSearch` 到 `multiSearchAny`, `firstMatch` 到 `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) + +#### 性能改进 {#performance-improvement-6} + +- 通过内联优化Volnitsky搜索器,为许多针或许多类似bigrams的查询提供约5-10%的搜索改进。 [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([Danila Kutenin](https://github.com/danlark1)) +- 修复设置时的性能问题 `use_uncompressed_cache` 大于零时,即出现在所有读取缓存中包含的数据时。 [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([阿利沙平](https://github.com/alesapin)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-10} + +- 强化调试构建:更精细的内存映射和ASLR;为标记缓存和索引添加内存保护。 这允许在ASan和MSan无法做到这一点的情况下找到更多的内存st脚错误。 [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加对cmake变量的支持 `ENABLE_PROTOBUF`, `ENABLE_PARQUET` 和 `ENABLE_BROTLI` 它允许启用/禁用上述功能(与我们对librdkafka,mysql等所做的相同)。 [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([Silviu Caragea](https://github.com/silviucpp)) +- 添加打印进程列表和堆栈跟踪的所有线程的能力,如果一些查询测试运行后挂起。 [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([阿利沙平](https://github.com/alesapin)) +- 添加重试 `Connection loss` 错误 `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([阿利沙平](https://github.com/alesapin)) +- 在打包程序脚本中添加使用vagrant的freebsd build和使用thread sanitizer的build。 [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([阿利沙平](https://github.com/alesapin)) +- 现在用户要求用户密码 `'default'` 在安装过程中。 [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([proller](https://github.com/proller)) +- 禁止在警告 `rdkafka` 图书馆. [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 允许在没有ssl的情况下构建。 [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([proller](https://github.com/proller)) +- 添加从自定义用户启动clickhouse服务器映像的方法。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- 升级contrib升压到1.69. [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([proller](https://github.com/proller)) +- 禁用使用 `mremap` 使用线程消毒剂编译时。 令人惊讶的是,TSan并没有拦截 `mremap` (虽然它确实拦截 `mmap`, `munmap` 这会导致误报。 修复了有状态测试中的TSan报告。 [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 通过HTTP接口使用格式模式添加测试检查。 [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) + +## ClickHouse释放19.4 {#clickhouse-release-19-4} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-4-33-2019-04-17} + +#### 错误修复 {#bug-fixes-7} + +- 避免 `std::terminate` 在内存分配失败的情况下。 现在 `std::bad_alloc` 按预期引发异常。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复capnproto从缓冲区读取。 有时文件没有通过HTTP成功加载。 [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([弗拉季斯拉夫](https://github.com/smirnov-vs)) +- 修复错误 `Unknown log entry type: 0` 后 `OPTIMIZE TABLE FINAL` 查询。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([阿莫斯鸟](https://github.com/amosbird)) +- 错误的参数 `hasAny` 或 `hasAll` 函数可能会导致段错误。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 执行时可能会发生死锁 `DROP DATABASE dictionary` 查询。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复未定义的行为 `median` 和 `quantile` 功能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) +- 修复压缩级别检测时 `network_compression_method` 小写。 在19.1节中被打破。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) +- 固定的无知 `UTC` 设置(修复问题 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) +- 修复 `histogram` 函数行为 `Distributed` 桌子 [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) +- 固定tsan报告 `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了由于系统日志使用中的争用条件而关闭的TSan报告。 修复了当part\_log启用时关机后的潜在使用。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复重新检查零件 `ReplicatedMergeTreeAlterThread` 在错误的情况下。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 对中间聚合函数状态的算术运算不适用于常量参数(如子查询结果)。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 始终在元数据中反引用列名。 否则,不可能创建一个名为列的表 `index` (由于格式错误,服务器无法重新启动 `ATTACH` 元数据中的查询)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复崩溃 `ALTER ... MODIFY ORDER BY` 上 `Distributed` 桌子 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) +- 修复段错误 `JOIN ON` 已启用 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([张冬](https://github.com/zhang2014)) +- 修复kafka使用protobuf消息后添加无关行的错误。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) +- 在固定的竞争条件 `SELECT` 从 `system.tables` 如果同时重命名或更改表。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 获取已经过时的数据部分时修复了数据竞赛。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定罕见的数据竞赛,可以在发生 `RENAME` MergeTree家族的表. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正功能中的分段故障 `arrayIntersect`. 如果函数使用常量和普通参数混合调用,则可能会发生分段错误。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([钱丽祥](https://github.com/fancyqlx)) +- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复 `No message received` 在副本之间获取部件时出现异常。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([阿利沙平](https://github.com/alesapin)) +- 固定 `arrayIntersect` 函数错误导致在单个数组中的几个重复值的情况下。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 在并发期间修复争用条件 `ALTER COLUMN` 可能导致服务器崩溃的查询(修复问题 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修复参数扣除 `ALTER MODIFY` 列 `CODEC` 未指定列类型时。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([阿利沙平](https://github.com/alesapin)) +- 功能 `cutQueryStringAndFragment()` 和 `queryStringAndFragment()` 现在正常工作时 `URL` 包含一个片段,没有查询。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 修复设置时罕见的错误 `min_bytes_to_use_direct_io` 大于零,这发生在线程必须在列文件中向后寻找时。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([阿利沙平](https://github.com/alesapin)) +- 修复聚合函数的错误参数类型 `LowCardinality` 参数(修复问题 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 修复功能 `toISOWeek` 1970年的结果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复 `DROP`, `TRUNCATE` 和 `OPTIMIZE` 查询重复,在执行时 `ON CLUSTER` 为 `ReplicatedMergeTree*` 表家庭. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([阿利沙平](https://github.com/alesapin)) + +#### 改进 {#improvements-2} + +- 保持平凡, `DEFAULT`, `MATERIALIZED` 和 `ALIAS` 在一个列表中的列(修复问题 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-3-11-2019-04-02} + +#### 错误修复 {#bug-fixes-8} + +- 修复崩溃 `FULL/RIGHT JOIN` 当我们加入可为空vs不可为空时。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-11} + +- 添加从自定义用户启动clickhouse服务器映像的方法。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-2-7-2019-03-30} + +#### 错误修复 {#bug-fixes-9} + +- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-1-3-2019-03-19} + +#### 错误修复 {#bug-fixes-10} + +- 包含两个固定的远程查询 `LIMIT BY` 和 `LIMIT`. 以前,如果 `LIMIT BY` 和 `LIMIT` 用于远程查询, `LIMIT` 可能发生之前 `LIMIT BY`,这导致过滤的结果。 [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([康斯坦丁\*潘](https://github.com/kvap)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-0-49-2019-03-09} + +#### 新功能 {#new-features-5} + +- 增加了全面支持 `Protobuf` 格式(输入和输出,嵌套数据结构)。 [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 添加位图功能与Ro哮的位图。 [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([杨小姐](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 实木复合地板格式支持。 [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([proller](https://github.com/proller)) +- 为模糊字符串比较添加了N-gram距离。 它类似于R语言中的q-gram指标。 [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([Danila Kutenin](https://github.com/danlark1)) +- 结合专用聚合和保留模式中的石墨汇总规则。 [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) +- 已添加 `max_execution_speed` 和 `max_execution_speed_bytes` 限制资源使用。 已添加 `min_execution_speed_bytes` 设置以补充 `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([张冬](https://github.com/zhang2014)) +- 实现功能 `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov), [kzon](https://github.com/kzon)) +- 新增功能 `arrayEnumerateDenseRanked` 和 `arrayEnumerateUniqRanked` (这就像 `arrayEnumerateUniq` 但是允许微调数组深度以查看多维数组内部)。 [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([proller](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 错误修复 {#bug-fixes-11} + +- 此版本还包含19.3和19.1中的所有错误修复。 +- 修正了数据跳过索引的错误:插入后颗粒顺序不正确。 [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 固定 `set` ツ环板forョ `Nullable` 和 `LowCardinality` 列。 在它之前, `set` 索引与 `Nullable` 或 `LowCardinality` 列导致错误 `Data type must be deserialized with multiple streams` 同时选择。 [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 正确设置完整的update\_time `executable` 字典更新. [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([Tema Novikov](https://github.com/temoon)) +- 修复19.3中损坏的进度条。 [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([filimonov](https://github.com/filimonov)) +- 在某些情况下,修复了内存区域收缩时MemoryTracker的不一致值。 [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了ThreadPool中未定义的行为。 [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了一个非常罕见的崩溃的消息 `mutex lock failed: Invalid argument` 当MergeTree表与SELECT同时删除时,可能会发生这种情况。 [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([Alex Zatelepin](https://github.com/ztlpn)) +- ODBC驱动程序兼容 `LowCardinality` 数据类型。 [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([proller](https://github.com/proller)) +- FreeBSD:修复程序 `AIOcontextPool: Found io_event with unknown id 0` 错误 [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([urgordeadbeef](https://github.com/urgordeadbeef)) +- `system.part_log` 无论配置如何,都会创建表。 [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复未定义的行为 `dictIsIn` 缓存字典功能。 [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([阿利沙平](https://github.com/alesapin)) +- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([Alex Zatelepin](https://github.com/ztlpn)) +- 默认情况下禁用compile\_expressions,直到我们得到自己 `llvm` contrib并且可以测试它 `clang` 和 `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([阿利沙平](https://github.com/alesapin)) +- 预防 `std::terminate` 当 `invalidate_query` 为 `clickhouse` 外部字典源返回了错误的结果集(空或一行以上或一列以上)。 固定的问题,当 `invalidate_query` 执行每五秒钟,无论到 `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 避免死锁时 `invalidate_query` 对于与字典 `clickhouse` 资料来源涉及 `system.dictionaries` 表或 `Dictionaries` 数据库(罕见的情况)。 [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了交叉连接与空在哪里。 [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([Artem Zuikov](https://github.com/4ertus2)) +- 在功能固定段错误 “replicate” 传递常量参数时。 [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使用谓词优化器修复lambda函数。 [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([张冬](https://github.com/zhang2014)) +- 多个联接多个修复。 [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 改进 {#improvements-3} + +- 在右表列的连接上部分支持别名。 [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([Artem Zuikov](https://github.com/4ertus2)) +- 多个联接的结果需要在子选择中使用正确的结果名称。 将平面别名替换为result中的源名称。 [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([Artem Zuikov](https://github.com/4ertus2)) +- 改进连接语句的下推逻辑。 [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([伊万](https://github.com/abyss7)) + +#### 性能改进 {#performance-improvements-3} + +- 改进的启发式 “move to PREWHERE” 优化。 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 使用适当的查找表,使用HashTable的api用于8位和16位密钥。 [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([阿莫斯鸟](https://github.com/amosbird)) +- 改进字符串比较的性能。 [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在单独的线程中清理分布式DDL队列,以便它不会减慢处理分布式DDL任务的主循环。 [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([Alex Zatelepin](https://github.com/ztlpn)) +- 当 `min_bytes_to_use_direct_io` 如果设置为1,则不是每个文件都使用O\_DIRECT模式打开,因为要读取的数据大小有时被一个压缩块的大小所低估。 [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-12} + +- 增加了对clang-9的支持 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复错误 `__asm__` 说明(再次) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([Konstantin Podshumok](https://github.com/podshumok)) +- 添加指定设置的能力 `clickhouse-performance-test` 从命令行。 [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([阿利沙平](https://github.com/alesapin)) +- 将字典测试添加到集成测试。 [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([阿利沙平](https://github.com/alesapin)) +- 在网站上添加了来自基准测试的查询,以自动化性能测试。 [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `xxhash.h` 在外部lz4中不存在,因为它是一个实现细节,并且它的符号是命名空间的 `XXH_NAMESPACE` 麦克罗 当lz4是外部的,xxHash也必须是外部的,并且依赖者必须链接到它。 [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([Origej Desh](https://github.com/orivej)) +- 固定的情况下,当 `quantileTiming` 聚合函数可以用负或浮点参数调用(这修复了使用未定义的行为消毒器的模糊测试)。 [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 拼写错误更正。 [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) +- 在Mac上修复编译。 [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- Freebsd和各种不寻常的构建配置的构建修复程序。 [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([proller](https://github.com/proller)) + +## ClickHouse释放19.3 {#clickhouse-release-19-3} + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-3-9-1-2019-04-02} + +#### 错误修复 {#bug-fixes-12} + +- 修复崩溃 `FULL/RIGHT JOIN` 当我们加入可为空vs不可为空时。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) +- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) + +#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-13} + +- 添加从自定义用户启动clickhouse服务器映像的方法 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-7-2019-03-12} + +#### 错误修复 {#bug-fixes-13} + +- 修正了#3920中的错误。 此错误表现为随机缓存损坏(消息 `Unknown codec family code`, `Cannot seek through file`)和段错误。 这个错误最早出现在19.1版本中,并且存在于19.1.10和19.3.6之前的版本中。 [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-3-6-2019-03-02} + +#### 错误修复 {#bug-fixes-14} + +- 当线程池中有超过1000个线程时, `std::terminate` 线程退出时可能发生。 [Azat Khuzhin](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 现在可以创建 `ReplicatedMergeTree*` 对没有默认值的列进行注释的表和对没有注释和默认值的列进行编解码的表。 还修复编解码器的比较。 [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([阿利沙平](https://github.com/alesapin)) +- 修复了与数组或元组联接时的崩溃。 [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([Artem Zuikov](https://github.com/4ertus2)) +- 修复了clickhouse-复印机中的消息崩溃 `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([Artem Zuikov](https://github.com/4ertus2)) +- 如果使用分布式Ddl,则在服务器关闭时修复了挂机问题。 [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([Alex Zatelepin](https://github.com/ztlpn)) +- 错误的列编号打印在有关文本格式分析的列数大于10的错误消息中。 [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-3} + +- 固定构建与启用AVX。 [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 基于已知版本而不是编译它的内核启用扩展记帐和IO记帐。 [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([纳瓦托洛梅](https://github.com/nvartolomei)) +- 允许跳过core\_dump的设置。size\_limit,如果限制设置失败,则警告而不是throw。 [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([proller](https://github.com/proller)) +- 删除了 `inline` 标签 `void readBinary(...)` 在 `Field.cpp`. 也合并冗余 `namespace DB` 块。 [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([hcz](https://github.com/hczhcz)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-5-2019-02-21} + +#### 错误修复 {#bug-fixes-15} + +- 修正了大型http插入查询处理的错误。 [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([阿利沙平](https://github.com/alesapin)) +- 修正了向后不兼容的旧版本,由于错误的实现 `send_logs_level` 设置。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了表函数的向后不兼容性 `remote` 与列注释介绍. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-4-2019-02-16} + +#### 改进 {#improvements-4} + +- 执行以下操作时,表索引大小不考虑内存限制 `ATTACH TABLE` 查询。 避免了分离后无法连接表的可能性。 [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 稍微提高了从ZooKeeper接收的最大字符串和数组大小的限制。 它允许继续与增加的尺寸工作 `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` 在动物园管理员。 [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 允许修复被遗弃的副本,即使它已经在其队列中拥有大量的节点。 [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加一个必需的参数 `SET` 索引(最大存储行数)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) + +#### 错误修复 {#bug-fixes-16} + +- 固定 `WITH ROLLUP` 单组结果 `LowCardinality` 钥匙 [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 在设置索引固定错误(删除颗粒,如果它包含超过 `max_rows` 行)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 很多的FreeBSD构建修复。 [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([proller](https://github.com/proller)) +- 固定别名替换查询与子查询包含相同的别名(问题 [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-4} + +- 添加运行能力 `clickhouse-server` 对于docker镜像中的无状态测试。 [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([瓦西里\*内姆科夫](https://github.com/Enmk)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-3-2019-02-13} + +#### 新功能 {#new-features-6} + +- 添加了 `KILL MUTATION` 允许删除由于某些原因卡住的突变的声明。 已添加 `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` 字段到 `system.mutations` 表更容易排除故障。 [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([Alex Zatelepin](https://github.com/ztlpn)) +- 添加聚合功能 `entropy` 计算香农熵 [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) +- 添加发送查询的功能 `INSERT INTO tbl VALUES (....` 到服务器而不拆分 `query` 和 `data` 零件。 [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([阿利沙平](https://github.com/alesapin)) +- 通用实现 `arrayWithConstant` 添加了功能。 [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 已实施 `NOT BETWEEN` 比较运算符。 [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([Dmitry Naumov](https://github.com/nezed)) +- 执行 `sumMapFiltered` 为了能够限制其值将被求和的键的数量 `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- 增加了支持 `Nullable` 类型 `mysql` 表功能。 [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) +- 支持任意常量表达式 `LIMIT` 条款 [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) +- 已添加 `topKWeighted` 采用带有(无符号整数)权重的附加参数的聚合函数。 [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([安德鲁\*戈尔曼](https://github.com/andrewgolman)) +- `StorageJoin` 现在支持 `join_any_take_last_row` 允许复盖同一键的现有值的设置。 [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([阿莫斯鸟](https://github.com/amosbird) +- 添加功能 `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 已添加 `RowBinaryWithNamesAndTypes` 格式。 [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([Oleg V.Kozlyuk](https://github.com/DarkWanderer)) +- 已添加 `IPv4` 和 `IPv6` 数据类型。 更有效的实现 `IPv*` 功能。 [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([瓦西里\*内姆科夫](https://github.com/Enmk)) +- 添加功能 `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 已添加 `Protobuf` 输出格式。 [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) +- 增加了对数据导入(插入)HTTP接口的brotli支持。 [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([米哈伊尔](https://github.com/fandyushin)) +- 增加了提示,而用户做出错字的函数名称或键入命令行客户端。 [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([Danila Kutenin](https://github.com/danlark1)) +- 已添加 `Query-Id` 到服务器的HTTP响应头。 [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([米哈伊尔](https://github.com/fandyushin)) + +#### 实验特点 {#experimental-features-2} + +- 已添加 `minmax` 和 `set` MergeTree表引擎系列的数据跳过索引。 [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- 增加了转换 `CROSS JOIN` 到 `INNER JOIN` 如果可能的话 [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 错误修复 {#bug-fixes-17} + +- 固定 `Not found column` 对于重复的列 `JOIN ON` 科。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) +- 赂眉露\>\> `START REPLICATED SENDS` 命令开始复制发送。 [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([纳瓦托洛梅](https://github.com/nvartolomei)) +- 固定聚合函数执行 `Array(LowCardinality)` 争论。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 修正了错误的行为,当做 `INSERT ... SELECT ... FROM file(...)` 查询和文件有 `CSVWithNames` 或 `TSVWIthNames` 格式和第一个数据行丢失。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 如果字典不可用,则修复了字典重新加载时的崩溃。 此错误出现在19.1.6中。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) +- 固定 `ALL JOIN` 右表中有重复项。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) +- 修正了分段故障 `use_uncompressed_cache=1` 和异常与错误的未压缩大小。 此错误出现在19.1.6中。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([阿利沙平](https://github.com/alesapin)) +- 固定 `compile_expressions` 错误与大(超过int16)日期的比较。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([阿利沙平](https://github.com/alesapin)) +- 从表函数选择时固定无限循环 `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 暂时禁用谓词优化 `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([张冬](https://github.com/zhang2014)) +- 固定 `Illegal instruction` 在旧Cpu上使用base64函数时出错。 仅当ClickHouse使用gcc-8编译时,才会重现此错误。 [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定 `No message received` 通过TLS连接与PostgreSQL ODBC驱动程序交互时出错。 还修复了使用MySQL ODBC驱动程序时的段错误。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误的结果时 `Date` 和 `DateTime` 参数用于条件运算符(函数)的分支 `if`). 增加了函数的通用案例 `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- ClickHouse字典现在加载内 `clickhouse` 过程。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复死锁时 `SELECT` 从一个表 `File` 引擎被重试后 `No such file or directory` 错误 [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 从选择时固定的竞争条件 `system.tables` 可能会给 `table doesn't exist` 错误 [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `clickhouse-client` 如果在交互模式下运行,则在加载命令行建议的数据时可以在退出时段错误。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了一个错误,当包含突变的执行 `IN` 操作员产生了不正确的结果。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修正错误:如果有一个数据库 `Dictionary` 引擎中,所有字典在服务器启动时强制加载,如果有来自localhost的ClickHouse源字典,则字典无法加载。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了在服务器关闭时尝试再次创建系统日志时的错误。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 正确返回正确的类型和正确处理锁 `joinGet` 功能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([阿莫斯鸟](https://github.com/amosbird)) +- 已添加 `sumMapWithOverflow` 功能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- 固定段错误 `allow_experimental_multiple_joins_emulation`. [52de2c](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([Artem Zuikov](https://github.com/4ertus2)) +- 修正错误与不正确 `Date` 和 `DateTime` 比较。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) +- 在未定义的行为消毒固定模糊测试:增加了参数类型检查 `quantile*Weighted` 家庭的功能。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了在删除旧数据部分时罕见的争用条件可能会失败 `File not found` 错误 [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复缺少/etc/clickhouse-server/config的安装包。xml [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-5} + +- Debian软件包:根据配置正确的/etc/clickhouse-server/预处理链接。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) +- Freebsd的各种构建修复程序。 [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([proller](https://github.com/proller)) +- 增加了在perftest中创建,填充和删除表的能力。 [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([阿利沙平](https://github.com/alesapin)) +- 添加了一个脚本来检查重复的包括。 [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了在性能测试中通过索引运行查询的能力。 [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([阿利沙平](https://github.com/alesapin)) +- 建议安装带有调试符号的软件包。 [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 重构性能测试。 更好的记录和信号处理。 [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([阿利沙平](https://github.com/alesapin)) +- 将文档添加到匿名Yandex。Metrika数据集. [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([阿利沙平](https://github.com/alesapin)) +- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([Alex Zatelepin](https://github.com/ztlpn)) +- 添加了有关s3中两个数据集的文档。 [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([阿利沙平](https://github.com/alesapin)) +- 增加了从拉请求描述创建更新日志的脚本。 [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([KochetovNicolai](https://github.com/KochetovNicolai)) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 为ClickHouse添加了木偶模块。 [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([Maxim Fedotov](https://github.com/MaxFedotov)) +- 添加了一组无证函数的文档。 [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([张冬](https://github.com/zhang2014)) +- ARM构建修复。 [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([proller](https://github.com/proller)) ([proller](https://github.com/proller)) +- 字典测试现在能够从运行 `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([proller](https://github.com/proller)) +- 现在 `/etc/ssl` 用作带有SSL证书的默认目录。 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在开始时添加了检查SSE和AVX指令。 [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([Igr](https://github.com/igron99)) +- 初始化脚本将等待服务器,直到启动。 [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([proller](https://github.com/proller)) + +#### 向后不兼容的更改 {#backward-incompatible-changes-1} + +- 已删除 `allow_experimental_low_cardinality_type` 设置。 `LowCardinality` 数据类型已准备就绪。 [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 根据可用内存量减少标记高速缓存大小和未压缩高速缓存大小。 [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([Lopatin Konstantin](https://github.com/k-lopatin) +- 添加关键字 `INDEX` 在 `CREATE TABLE` 查询。 具有名称的列 `index` 必须使用反引号或双引号引用: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) +- `sumMap` 现在提升结果类型而不是溢出。 老 `sumMap` 行为可以通过使用获得 `sumMapWithOverflow` 功能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) + +#### 性能改进 {#performance-improvements-4} + +- `std::sort` 改为 `pdqsort` 对于没有 `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([Evgenii Pravda](https://github.com/kvinty)) +- 现在服务器重用全局线程池中的线程。 这会影响某些角落情况下的性能。 [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 改进 {#improvements-5} + +- 实现了对FreeBSD的AIO支持。 [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([urgordeadbeef](https://github.com/urgordeadbeef)) +- `SELECT * FROM a JOIN b USING a, b` 现在回来 `a` 和 `b` 列仅从左表。 [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([Artem Zuikov](https://github.com/4ertus2)) +- 允许 `-C` 客户端的选项作为工作 `-c` 选项。 [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([syominsergey](https://github.com/syominsergey)) +- 现在选项 `--password` 无值使用需要从标准输入的密码。 [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([BSD\_Conqueror](https://github.com/bsd-conqueror)) +- 在包含字符串文字中添加了非转义元字符的突出显示 `LIKE` 表达式或正则表达式。 [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加取消HTTP只读查询,如果客户端套接字消失。 [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([纳瓦托洛梅](https://github.com/nvartolomei)) +- 现在,服务器报告进度,以保持客户端连接活跃。 [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([伊万](https://github.com/abyss7)) +- 稍微好一点的消息与优化查询的原因 `optimize_throw_if_noop` 设置已启用。 [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了支持 `--version` clickhouse服务器的选项。 [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([Lopatin Konstantin](https://github.com/k-lopatin)) +- 已添加 `--help/-h` 选项 `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([尤里\*巴拉诺夫](https://github.com/yurriy)) +- 增加了对具有聚合函数状态结果的标量子查询的支持。 [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) +- 改进服务器关闭时间并改变等待时间。 [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 添加了有关replicated\_can\_become\_leader设置到系统的信息。如果副本不会尝试成为领导者,则添加日志记录。 [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([Alex Zatelepin](https://github.com/ztlpn)) + +## ClickHouse释放19.1 {#clickhouse-release-19-1} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-14-2019-03-14} + +- 修正错误 `Column ... queried more than once` 这可能发生,如果设置 `asterisk_left_columns_only` 在使用的情况下设置为1 `GLOBAL JOIN` 与 `SELECT *` (罕见的情况)。 该问题在19.3及更新版本中不存在。 [6bac7d8d](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([Artem Zuikov](https://github.com/4ertus2)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-13-2019-03-12} + +此版本包含与19.3.7完全相同的补丁集。 + +### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-1-10-2019-03-03} + +此版本包含与19.3.6完全相同的补丁集。 + +## ClickHouse释放19.1 {#clickhouse-release-19-1-1} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-9-2019-02-21} + +#### 错误修复 {#bug-fixes-18} + +- 修正了向后不兼容的旧版本,由于错误的实现 `send_logs_level` 设置。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了表函数的向后不兼容性 `remote` 与列注释介绍. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-8-2019-02-16} + +#### 错误修复 {#bug-fixes-19} + +- 修复缺少/etc/clickhouse-server/config的安装包。xml [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) + +## ClickHouse释放19.1 {#clickhouse-release-19-1-2} + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-7-2019-02-15} + +#### 错误修复 {#bug-fixes-20} + +- 正确返回正确的类型和正确处理锁 `joinGet` 功能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([阿莫斯鸟](https://github.com/amosbird)) +- 修复了在服务器关闭时尝试再次创建系统日志时的错误。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误:如果有一个数据库 `Dictionary` 引擎中,所有字典在服务器启动时强制加载,如果有来自localhost的ClickHouse源字典,则字典无法加载。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了一个错误,当包含突变的执行 `IN` 操作员产生了不正确的结果。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) +- `clickhouse-client` 如果在交互模式下运行,则在加载命令行建议的数据时可以在退出时段错误。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 从选择时固定的竞争条件 `system.tables` 可能会给 `table doesn't exist` 错误 [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复死锁时 `SELECT` 从一个表 `File` 引擎被重试后 `No such file or directory` 错误 [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了一个问题:本地ClickHouse字典通过TCP加载,但应该在进程中加载。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定 `No message received` 通过TLS连接与PostgreSQL ODBC驱动程序交互时出错。 还修复了使用MySQL ODBC驱动程序时的段错误。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 暂时禁用谓词优化 `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([张冬](https://github.com/zhang2014)) +- 从表函数选择时固定无限循环 `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定 `compile_expressions` 错误与大(超过int16)日期的比较。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([阿利沙平](https://github.com/alesapin)) +- 修正了分段故障 `uncompressed_cache=1` 和异常与错误的未压缩大小。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([阿利沙平](https://github.com/alesapin)) +- 固定 `ALL JOIN` 右表中有重复项。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) +- 修正了错误的行为,当做 `INSERT ... SELECT ... FROM file(...)` 查询和文件有 `CSVWithNames` 或 `TSVWIthNames` 格式和第一个数据行丢失。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 固定聚合函数执行 `Array(LowCardinality)` 争论。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- Debian软件包:根据配置正确的/etc/clickhouse-server/预处理链接。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) +- 在未定义的行为消毒固定模糊测试:增加了参数类型检查 `quantile*Weighted` 家庭的功能。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 赂眉露\>\> `START REPLICATED SENDS` 命令开始复制发送。 [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([纳瓦托洛梅](https://github.com/nvartolomei)) +- 固定 `Not found column` 对于联接部分中的重复列。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) +- 现在 `/etc/ssl` 用作带有SSL证书的默认目录。 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 如果字典不可用,则修复了字典重新加载时的崩溃。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) +- 修正错误与不正确 `Date` 和 `DateTime` 比较。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) +- 修正错误的结果时 `Date` 和 `DateTime` 参数用于条件运算符(函数)的分支 `if`). 增加了函数的通用案例 `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-6-2019-01-24} + +#### 新功能 {#new-features-7} + +- 自定义每列压缩编解码器的表。 [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([阿利沙平](https://github.com/alesapin), [张冬](https://github.com/zhang2014), [阿纳托利](https://github.com/Sindbag)) +- 添加压缩编解ec `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([阿利沙平](https://github.com/alesapin)) +- 允许 `ALTER` 压缩编解ecs。 [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([阿利沙平](https://github.com/alesapin)) +- 新增功能 `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` 对于SQL标准的兼容性。 [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([伊万\*布林科夫](https://github.com/blinkov)) +- 支持写入 `HDFS` 表和 `hdfs` 表功能。 [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([阿利沙平](https://github.com/alesapin)) +- 增加了从big haystack中搜索多个常量字符串的功能: `multiPosition`, `multiSearch` ,`firstMatch` 也与 `-UTF8`, `-CaseInsensitive`,和 `-CaseInsensitiveUTF8` 变体。 [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([Danila Kutenin](https://github.com/danlark1)) +- 修剪未使用的碎片,如果 `SELECT` 通过分片键查询过滤器(设置 `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([Gleb Kanterov](https://github.com/kanterov), [伊万](https://github.com/abyss7)) +- 允许 `Kafka` 引擎忽略每个块的解析错误数。 [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([伊万](https://github.com/abyss7)) +- 增加了对 `CatBoost` 多类模型评估。 功能 `modelEvaluate` 返回带有多类模型的每类原始预测的元组。 `libcatboostmodel.so` 应建立与 [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 新增功能 `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([Boris Granveaud](https://github.com/bgranvea)) +- 添加了哈希函数 `xxHash64` 和 `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([filimonov](https://github.com/filimonov)) +- 已添加 `gccMurmurHash` 散列函数(GCC风味杂音散列),它使用相同的散列种子 [海湾合作委员会](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([sundyli](https://github.com/sundy-li)) +- 添加了哈希函数 `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([上书结365](https://github.com/shangshujie365)) +- 添加表功能 `remoteSecure`. 函数的工作原理为 `remote`,但使用安全连接。 [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([proller](https://github.com/proller)) + +#### 实验特点 {#experimental-features-3} + +- 添加了多个联接仿真 (`allow_experimental_multiple_joins_emulation` 设置)。 [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([Artem Zuikov](https://github.com/4ertus2)) + +#### 错误修复 {#bug-fixes-21} + +- 赂眉露\>\> `compiled_expression_cache_size` 默认情况下设置有限,以降低内存消耗。 [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([阿利沙平](https://github.com/alesapin)) +- 修复导致执行更改复制表的线程和从ZooKeeper更新配置的线程中挂断的错误。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修复了执行分布式ALTER任务时的争用条件。 争用条件导致多个副本试图执行任务和所有副本,除了一个失败与ZooKeeper错误。 [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修复错误时 `from_zk` 在对ZooKeeper的请求超时后,配置元素没有刷新。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修复IPv4子网掩码错误前缀的错误。 [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([阿利沙平](https://github.com/alesapin)) +- 固定崩溃 (`std::terminate`)在极少数情况下,由于资源耗尽而无法创建新线程。 [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误时 `remote` 表函数执行时,错误的限制被用于 `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([阿利沙平](https://github.com/alesapin)) +- 修复netlink套接字的泄漏。 它们被放置在一个池中,在那里它们永远不会被删除,并且当所有当前套接字都在使用时,在新线程开始时创建了新的套接字。 [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([Alex Zatelepin](https://github.com/ztlpn)) +- 修复关闭错误 `/proc/self/fd` 目录早于所有fds被读取 `/proc` 分叉后 `odbc-bridge` 子进程。 [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([阿利沙平](https://github.com/alesapin)) +- 在主键中使用字符串的情况下,固定字符串到UInt单调转换。 [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([张冬](https://github.com/zhang2014)) +- 整数转换函数单调性计算中的固定误差。 [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复段错误 `arrayEnumerateUniq`, `arrayEnumerateDense` 函数在一些无效的参数的情况下。 [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 在StorageMerge修复UB。 [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([阿莫斯鸟](https://github.com/amosbird)) +- 修正函数中的段错误 `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正错误:功能 `round`, `floor`, `trunc`, `ceil` 在整数参数和大负比例执行时可能会返回虚假结果。 [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了一个错误引起的 ‘kill query sync’ 从而导致核心转储。 [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([muVulDeePecker](https://github.com/fancyqlx)) +- 修复空复制队列后延迟较长的bug。 [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([阿利沙平](https://github.com/alesapin)) +- 修复了插入到表中的过多内存使用情况 `LowCardinality` 主键。 [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 固定 `LowCardinality` 序列化 `Native` 在空数组的情况下格式化。 [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 固定不正确的结果,而使用distinct通过单LowCardinality数字列。 [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 固定专门的聚合与LowCardinality键(以防万一 `compile` 设置已启用)。 [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 修复复制表查询的用户和密码转发。 [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([阿利沙平](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) +- 修复了在重新加载字典时在字典数据库中列出表时可能发生的非常罕见的争用条件。 [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了与ROLLUP或CUBE一起使用时的错误结果。 [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([周三](https://github.com/reflection)) +- 用于查询的固定列别名 `JOIN ON` 语法和分布式表。 [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([张冬](https://github.com/zhang2014)) +- 在内部实现固定的错误 `quantileTDigest` (由阿尔乔姆Vakhrushev发现)。 这个错误从来没有发生在ClickHouse中,只有那些直接使用ClickHouse代码库作为库的人才有关。 [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 改进 {#improvements-6} + +- 支持 `IF NOT EXISTS` 在 `ALTER TABLE ADD COLUMN` 发言以及 `IF EXISTS` 在 `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([Boris Granveaud](https://github.com/bgranvea)) +- 功能 `parseDateTimeBestEffort`:支持格式 `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` 和相似。 [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- `CapnProtoInputStream` 现在支持锯齿结构。 [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) +- 可用性改进:增加了从数据目录的所有者启动服务器进程的检查。 如果数据属于非root用户,则不允许从root用户启动服务器。 [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([谢尔盖-v-加尔采夫](https://github.com/sergey-v-galtsev)) +- 在分析具有联接的查询期间检查所需列的更好的逻辑。 [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([Artem Zuikov](https://github.com/4ertus2)) +- 减少在单个服务器中有大量分布式表的情况下的连接数。 [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([张冬](https://github.com/zhang2014)) +- 支持的总计行 `WITH TOTALS` 查询ODBC驱动程序。 [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([Maksim Koritckiy](https://github.com/nightweb)) +- 允许使用 `Enum`s为if函数内的整数。 [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([伊万](https://github.com/abyss7)) +- 已添加 `low_cardinality_allow_in_native_format` 设置。 如果禁用,请不要使用 `LowCadrinality` 输入 `Native` 格式。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([KochetovNicolai](https://github.com/KochetovNicolai)) +- 从编译表达式缓存中删除了一些冗余对象以降低内存使用率。 [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([阿利沙平](https://github.com/alesapin)) +- 添加检查 `SET send_logs_level = 'value'` 查询接受适当的值。 [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([Sabyanin马克西姆](https://github.com/s-mx)) +- 固定数据类型检查类型转换功能。 [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([张冬](https://github.com/zhang2014)) + +#### 性能改进 {#performance-improvements-5} + +- 添加MergeTree设置 `use_minimalistic_part_header_in_zookeeper`. 如果启用,复制的表将在单个零件znode中存储紧凑零件元数据。 这可以显着减少ZooKeeper快照大小(特别是如果表有很多列)。 请注意,启用此设置后,您将无法降级到不支持它的版本。 [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([Alex Zatelepin](https://github.com/ztlpn)) +- 为函数添加基于DFA的实现 `sequenceMatch` 和 `sequenceCount` 以防模式不包含时间。 [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) +- 整数序列化的性能改进。 [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([阿莫斯鸟](https://github.com/amosbird)) +- 零左填充PODArray,使-1元素始终有效并归零。 它用于无分支计算偏移量。 [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([阿莫斯鸟](https://github.com/amosbird)) +- 还原 `jemalloc` 版本导致性能下降。 [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) + +#### 向后不兼容的更改 {#backward-incompatible-changes-2} + +- 删除无证功能 `ALTER MODIFY PRIMARY KEY` 因为它被 `ALTER MODIFY ORDER BY` 指挥部 [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([Alex Zatelepin](https://github.com/ztlpn)) +- 删除功能 `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 禁止使用具有结果类型的标量子查询 `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([伊万](https://github.com/abyss7)) + +#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-6} + +- 增加了对PowerPC的支持 (`ppc64le`)建设。 [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([Danila Kutenin](https://github.com/danlark1)) +- 有状态功能测试在公共可用数据集上运行。 [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修复了服务器无法启动时的错误 `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` Docker或systemd-nspawn中的消息。 [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 更新 `rdkafka` 库v1.0.0-RC5。 使用cppkafka而不是原始的C接口。 [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([伊万](https://github.com/abyss7)) +- 更新 `mariadb-client` 图书馆. 修复了UBSan发现的问题之一。 [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- UBSan版本的一些修复。 [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了使用UBSan构建的每次提交运行的测试。 +- 增加了PVS-Studio静态分析器的每次提交运行。 +- 修复了PVS-Studio发现的错误。 [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了glibc兼容性问题。 [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 将Docker映像移动到18.10并为glibc\>=2.28添加兼容性文件 [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([阿利沙平](https://github.com/alesapin)) +- 如果用户不想在服务器码头镜像中播放目录,请添加env变量。 [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([阿利沙平](https://github.com/alesapin)) +- 启用了大多数来自警告 `-Weverything` 在叮当声。 已启用 `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 增加了一些只在clang8中可用的警告。 [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 链接到 `libLLVM` 在使用共享链接时,而不是单独的LLVM库。 [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([Origej Desh](https://github.com/orivej)) +- 为测试图像添加了消毒变量。 [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([阿利沙平](https://github.com/alesapin)) +- `clickhouse-server` debian软件包会推荐 `libcap2-bin` 使用包 `setcap` 设置功能的工具。 这是可选的。 [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 改进的编译时间,固定包括。 [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([proller](https://github.com/proller)) +- 添加了哈希函数的性能测试。 [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([filimonov](https://github.com/filimonov)) +- 固定循环库依赖。 [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([proller](https://github.com/proller)) +- 改进的编译与低可用内存。 [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([proller](https://github.com/proller)) +- 添加了测试脚本,以重现性能下降 `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) +- 修正了在下面的注释和字符串文字拼写错误 `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([maiha](https://github.com/maiha)) +- 修正了错别字的评论。 [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([Evgenii Pravda](https://github.com/kvinty)) + +## [2018年的更新日志](./2018.md#clickhouse-release-18-16) {#changelog-for-2018} diff --git a/docs/zh/whats-new/changelog/index.md b/docs/zh/whats-new/changelog/index.md new file mode 100644 index 00000000000..8a708afa698 --- /dev/null +++ b/docs/zh/whats-new/changelog/index.md @@ -0,0 +1,9 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u66F4\u65B0\u65E5\u5FD7" +toc_priority: 74 +toc_title: '2020' +--- + +{% include "content/changelog.md" %} diff --git a/docs/zh/whats-new/index.md b/docs/zh/whats-new/index.md new file mode 100644 index 00000000000..0f248773402 --- /dev/null +++ b/docs/zh/whats-new/index.md @@ -0,0 +1,8 @@ +--- +machine_translated: true +machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd +toc_folder_title: "\u65B0\u589E\u5185\u5BB9" +toc_priority: 72 +--- + + diff --git a/docs/zh/whats-new/roadmap.md b/docs/zh/whats-new/roadmap.md new file mode 100644 index 00000000000..49532c046f5 --- /dev/null +++ b/docs/zh/whats-new/roadmap.md @@ -0,0 +1,9 @@ +# 规划 {#gui-hua} + +## Q1 2020 {#q1-2020} + +- 更精确的用户资源池,可以在用户之间合理分配集群资源 +- 细粒度的授权管理 +- 与外部认证服务集成 + +[来源文章](https://clickhouse.tech/docs/en/roadmap/) diff --git a/docs/zh/whats-new/security-changelog.md b/docs/zh/whats-new/security-changelog.md new file mode 100644 index 00000000000..e35d6a7c632 --- /dev/null +++ b/docs/zh/whats-new/security-changelog.md @@ -0,0 +1,41 @@ +## 修复于 ClickHouse Release 18.12.13, 2018-09-10 {#xiu-fu-yu-clickhouse-release-18-12-13-2018-09-10} + +### CVE-2018-14672 {#cve-2018-14672} + +加载CatBoost模型的功能,允许遍历路径并通过错误消息读取任意文件。 + +来源: Yandex信息安全团队的Andrey Krasichkov + +## 修复于 ClickHouse Release 18.10.3, 2018-08-13 {#xiu-fu-yu-clickhouse-release-18-10-3-2018-08-13} + +### CVE-2018-14671 {#cve-2018-14671} + +unixODBC允许从文件系统加载任意共享对象,从而导致«远程执行代码»漏洞。 + +来源:Yandex信息安全团队的Andrey Krasichkov和Evgeny Sidorov + +## 修复于 ClickHouse Release 1.1.54388, 2018-06-28 {#xiu-fu-yu-clickhouse-release-1-1-54388-2018-06-28} + +### CVE-2018-14668 {#cve-2018-14668} + +远程表函数功能允许在 «user», «password» 及 «default\_database» 字段中使用任意符号,从而导致跨协议请求伪造攻击。 + +来源:Yandex信息安全团队的Andrey Krasichkov + +## 修复于 ClickHouse Release 1.1.54390, 2018-07-06 {#xiu-fu-yu-clickhouse-release-1-1-54390-2018-07-06} + +### CVE-2018-14669 {#cve-2018-14669} + +ClickHouse MySQL客户端启用了 «LOAD DATA LOCAL INFILE» 功能,该功能允许恶意MySQL数据库从连接的ClickHouse服务器读取任意文件。 + +来源:Yandex信息安全团队的Andrey Krasichkov和Evgeny Sidorov + +## 修复于 ClickHouse Release 1.1.54131, 2017-01-10 {#xiu-fu-yu-clickhouse-release-1-1-54131-2017-01-10} + +### CVE-2018-14670 {#cve-2018-14670} + +deb软件包中的错误配置可能导致使用未经授权的数据库。 + +来源:英国国家网络安全中心(NCSC) + +[来源文章](https://clickhouse.tech/docs/en/security_changelog/) diff --git a/docs/zh/whats_new/changelog/2017.md b/docs/zh/whats_new/changelog/2017.md deleted file mode 100644 index ed77ead9023..00000000000 --- a/docs/zh/whats_new/changelog/2017.md +++ /dev/null @@ -1,268 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 79 -toc_title: '2017' ---- - -### ClickHouse释放1.1.54327,2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} - -此版本包含以前版本1.1.54318的错误修复: - -- 修复了可能导致数据丢失的复制中可能存在的争用条件的错误。 此问题影响版本1.1.54310和1.1.54318。 如果将其中一个版本用于复制的表,则强烈建议进行更新。 此问题显示在日志中的警告消息,如 `Part ... from own log doesn't exist.` 即使您在日志中没有看到这些消息,问题也是相关的。 - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54318-2017-11-30} - -此版本包含以前版本1.1.54310的错误修复: - -- 修复了SummingMergeTree引擎中合并过程中错误的行删除 -- 修复了未复制的MergeTree引擎中的内存泄漏 -- 修复了MergeTree引擎中频繁插入的性能下降 -- 修复了导致复制队列停止运行的问题 -- 固定服务器日志的轮换和归档 - -### ClickHouse释放1.1.54310,2017-11-01 {#clickhouse-release-1-1-54310-2017-11-01} - -#### 新功能: {#new-features} - -- MergeTree表引擎系列的自定义分区键。 -- [卡夫卡](https://clickhouse.yandex/docs/en/operations/table_engines/kafka/) 表引擎。 -- 增加了对加载的支持 [CatBoost](https://catboost.yandex/) 模型并将其应用到ClickHouse中存储的数据。 -- 增加了对UTC非整数偏移的时区的支持。 -- 增加了对具有时间间隔的算术运算的支持。 -- 日期和日期时间类型的值范围扩展到2105年。 -- 添加了 `CREATE MATERIALIZED VIEW x TO y` 查询(指定用于存储实例化视图数据的现有表)。 -- 添加了 `ATTACH TABLE` 不带参数的查询。 -- 将SummingMergeTree表中名称以-Map结尾的嵌套列的处理逻辑提取到sumMap聚合函数中。 现在,您可以显式指定此类列。 -- IP trie字典的最大大小增加到128M条目。 -- 添加了getSizeOfEnumType函数。 -- 添加了sumWithOverflow聚合函数。 -- 增加了对Cap'n Proto输入格式的支持。 -- 使用zstd算法时,您现在可以自定义压缩级别。 - -#### 向后不兼容的更改: {#backward-incompatible-changes} - -- 不允许使用内存以外的引擎创建临时表。 -- 不允许使用View或MaterializedView引擎显式创建表。 -- 在创建表期间,新检查将验证采样键表达式是否包含在主键中。 - -#### 错误修复: {#bug-fixes} - -- 修复了同步插入到分布式表中时的挂断问题。 -- 修复了复制表中部分的非原子添加和删除。 -- 插入到实例化视图中的数据不会遭受不必要的重复数据删除。 -- 对本地副本滞后且远程副本不可用的分布式表执行查询不会再导致错误。 -- 用户不需要访问权限 `default` 数据库创建临时表了。 -- 修复了在指定数组类型时不带参数的崩溃。 -- 修复了包含服务器日志的磁盘卷已满时的挂机问题。 -- 修复了unix时代的第一周toRelativeWeekNum函数的溢出。 - -#### 构建改进: {#build-improvements} - -- 几个第三方库(特别是Poco)被更新并转换为git子模块。 - -### ClickHouse释放1.1.54304,2017-10-19 {#clickhouse-release-1-1-54304-2017-10-19} - -#### 新功能: {#new-features-1} - -- 本机协议中的TLS支持(要启用,请设置 `tcp_ssl_port` 在 `config.xml` ). - -#### 错误修复: {#bug-fixes-1} - -- `ALTER` 对于复制的表现在尝试尽快开始运行。 -- 使用设置读取数据时修复崩溃 `preferred_block_size_bytes=0.` -- 固定的崩溃 `clickhouse-client` 按下时 `Page Down` -- 正确解释某些复杂的查询 `GLOBAL IN` 和 `UNION ALL` -- `FREEZE PARTITION` 现在总是以原子方式工作。 -- 空POST请求现在返回代码411的响应。 -- 修正了像表达式的解释错误 `CAST(1 AS Nullable(UInt8)).` -- 修正了读取时的错误 `Array(Nullable(String))` 从列 `MergeTree` 桌子 -- 修正了解析查询时崩溃,如 `SELECT dummy AS dummy, dummy AS b` -- 用户正确更新无效 `users.xml` -- 可执行字典返回非零响应代码时的正确处理。 - -### ClickHouse释放1.1.54292,2017-09-20 {#clickhouse-release-1-1-54292-2017-09-20} - -#### 新功能: {#new-features-2} - -- 添加了 `pointInPolygon` 用于处理坐标平面上的坐标的函数。 -- 添加了 `sumMap` 用于计算数组总和的聚合函数,类似于 `SummingMergeTree`. -- 添加了 `trunc` 功能。 改进舍入函数的性能 (`round`, `floor`, `ceil`, `roundToExp2`)并corrected正了他们如何工作的逻辑。 改变的逻辑 `roundToExp2` 分数和负数的功能。 -- ClickHouse可执行文件现在对libc版本的依赖性较低。 同样的ClickHouse可执行文件可以在各种各样的Linux系统上运行。 使用编译的查询(使用设置)时仍然存在依赖关系 `compile = 1` ,默认情况下不使用)。 -- 减少了动态编译查询所需的时间。 - -#### 错误修复: {#bug-fixes-2} - -- 修正了有时产生的错误 `part ... intersects previous part` 消息和副本的一致性减弱。 -- 修正了一个错误,导致服务器锁定,如果ZooKeeper在关闭过程中不可用。 -- 恢复副本时删除了过多的日志记录。 -- 修复了UNION ALL实现中的错误。 -- 修复了在块中的第一列具有数组类型时发生的concat函数中的错误。 -- 进度现在在系统中正确显示。合并表。 - -### ClickHouse释放1.1.54289,2017-09-13 {#clickhouse-release-1-1-54289-2017-09-13} - -#### 新功能: {#new-features-3} - -- `SYSTEM` 服务器管理查询: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`. -- 添加了用于处理数组的函数: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`. -- 已添加 `root` 和 `identity` ZooKeeper配置的参数。 这允许您隔离同一个ZooKeeper集群上的单个用户。 -- 添加聚合函数 `groupBitAnd`, `groupBitOr`,和 `groupBitXor` (为了兼容,它们也可以在名称下使用 `BIT_AND`, `BIT_OR`,和 `BIT_XOR`). -- 通过在文件系统中指定套接字,可以从MySQL加载外部字典。 -- 外部字典可以通过SSL从MySQL加载 (`ssl_cert`, `ssl_key`, `ssl_ca` 参数)。 -- 添加了 `max_network_bandwidth_for_user` 设置为限制每个用户查询的总带宽使用。 -- 支持 `DROP TABLE` 对于临时表。 -- 支持阅读 `DateTime` 从Unix时间戳格式的值 `CSV` 和 `JSONEachRow` 格式。 -- 分布式查询中的滞后副本现在默认排除(默认阈值为5分钟)。 -- 在ALTER期间使用FIFO锁定:对于连续运行的查询,ALTER查询不会无限期地阻止。 -- 选项设置 `umask` 在配置文件中。 -- 改进了查询的性能 `DISTINCT` . - -#### 错误修复: {#bug-fixes-3} - -- 改进了在ZooKeeper中删除旧节点的过程。 以前,如果插入非常频繁,旧节点有时不会被删除,这导致服务器关闭速度缓慢等等。 -- 修正了选择主机连接到ZooKeeper时的随机化。 -- 修复了在分布式查询中排除滞后副本,如果副本是localhost。 -- 修正了一个错误,其中在一个数据部分 `ReplicatedMergeTree` 运行后表可能会被打破 `ALTER MODIFY` 在一个元素 `Nested` 结构。 -- 修复了可能导致SELECT查询执行以下操作的错误 “hang”. -- 对分布式DDL查询的改进。 -- 修正了查询 `CREATE TABLE ... AS `. -- 解决了在僵局 `ALTER ... CLEAR COLUMN IN PARTITION` 查询为 `Buffer` 桌子 -- 修正了无效的默认值 `Enum` s(0,而不是最小)使用时 `JSONEachRow` 和 `TSKV` 格式。 -- 解决了使用字典时僵尸进程的外观 `executable` 资料来源。 -- 修正了HEAD查询的段错误。 - -#### 改进开发和组装ClickHouse的工作流程: {#improved-workflow-for-developing-and-assembling-clickhouse} - -- 您可以使用 `pbuilder` 建造克里克豪斯 -- 您可以使用 `libc++` 而不是 `libstdc++` 对于构建在Linux上。 -- 添加了使用静态代码分析工具的说明: `Coverage`, `clang-tidy`, `cppcheck`. - -#### 升级时请注意: {#please-note-when-upgrading} - -- MergeTree设置现在有一个更高的默认值 `max_bytes_to_merge_at_max_space_in_pool` (要合并的数据部分的最大总大小,以字节为单位):它已从100GiB增加到150GiB。 这可能会导致服务器升级后运行大型合并,这可能会导致磁盘子系统的负载增加。 如果服务器上的可用空间小于正在运行的合并总量的两倍,这将导致所有其他合并停止运行,包括小数据部分的合并。 因此,插入查询将失败,并显示消息 “Merges are processing significantly slower than inserts.” 使用 `SELECT * FROM system.merges` 查询监控情况。 您还可以检查 `DiskSpaceReservedForMerge` 度量在 `system.metrics` 表,或石墨。 你不需要做任何事情来解决这个问题,因为一旦大合并完成,问题就会自行解决。 如果您发现这是不可接受的,则可以恢复以前的值 `max_bytes_to_merge_at_max_space_in_pool` 设置。 要做到这一点,请转到 在配置部分。xml,设置 ``` ``107374182400 ``` 并重新启动服务器。 - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54284-2017-08-29} - -- 这是一个错误修正版本,以前的1.1.54282版本。 它修复了ZooKeeper中部件目录中的泄漏。 - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54282-2017-08-23} - -此版本包含以前版本1.1.54276的错误修复: - -- 固定 `DB::Exception: Assertion violation: !_path.empty()` 当插入到分布式表中。 -- 如果输入数据以";"开头,则以RowBinary格式插入时修复了解析。 -- Errors during runtime compilation of certain aggregate functions (e.g. `groupArray()`). - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54276-2017-08-16} - -#### 新功能: {#new-features-4} - -- 为选择查询添加了一个可选的WITH部分。 查询示例: `WITH 1+1 AS a SELECT a, a*a` -- INSERT可以在分布式表中同步执行:仅在所有分片上保存所有数据后才返回OK。 这是由设置insert\_distributed\_sync=1激活的。 -- 添加了用于处理16字节标识符的UUID数据类型。 -- 添加了CHAR,FLOAT和其他类型的别名,以便与Tableau兼容。 -- 添加了toyyyymm,toYYYYMMDD和toyyyyymmddhhmmss将时间转换为数字的功能。 -- 您可以使用IP地址(与主机名一起使用)来标识群集DDL查询的服务器。 -- 增加了对函数中非常量参数和负偏移的支持 `substring(str, pos, len).` -- 添加了max\_size参数 `groupArray(max_size)(column)` 聚合函数,并优化了其性能。 - -#### 主要变化: {#main-changes} - -- 安全性改进:所有服务器文件都使用0640权限创建(可以通过更改 配置参数)。 -- 改进了语法无效的查询的错误消息。 -- 在合并mergetree大部分数据时,显着降低了内存消耗并提高了性能。 -- 显着提高了ReplacingMergeTree引擎的数据合并性能。 -- 通过组合多个源插入来改进来自分布式表的异步插入的性能。 要启用此功能,请使用设置distributed\_directory\_monitor\_batch\_inserts=1。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-1} - -- 改变聚合状态的二进制格式 `groupArray(array_column)` 数组的函数。 - -#### 更改的完整列表: {#complete-list-of-changes} - -- 添加了 `output_format_json_quote_denormals` 设置,允许以JSON格式输出nan和inf值。 -- 从分布式表读取时优化流分配。 -- 如果值没有更改,可以在只读模式下配置设置。 -- 添加了检索MergeTree引擎的非整数颗粒的功能,以满足preferred\_block\_size\_bytes设置中指定的块大小的限制。 其目的是在处理来自具有大列的表的查询时减少RAM消耗并增加缓存局部性。 -- 高效使用包含如下表达式的索引 `toStartOfHour(x)` 对于像条件 `toStartOfHour(x) op сonstexpr.` -- 添加了MergeTree引擎的新设置(配置中的merge\_tree部分。xml): - - replicated\_deduplication\_window\_seconds设置复制表中重复数据删除插入所允许的秒数。 - - cleanup\_delay\_period设置启动清理以删除过时数据的频率。 - - replicated\_can\_become\_leader可以防止副本成为领导者(并分配合并)。 -- 加速清理,从ZooKeeper中删除过时的数据。 -- 针对群集DDL查询的多个改进和修复。 特别令人感兴趣的是新设置distributed\_ddl\_task\_timeout,它限制了等待群集中服务器响应的时间。 如果未在所有主机上执行ddl请求,则响应将包含超时错误,并且请求将以异步模式执行。 -- 改进了服务器日志中堆栈跟踪的显示。 -- 添加了 “none” 压缩方法的值。 -- 您可以在config中使用多个dictionaries\_config部分。xml -- 可以通过文件系统中的套接字连接到MySQL。 -- 系统。部件表有一个新的列,其中包含有关标记大小的信息,以字节为单位。 - -#### 错误修复: {#bug-fixes-4} - -- 使用合并表的分布式表现在可以正确地用于具有条件的SELECT查询 `_table` 场。 -- 修复了检查数据部分时ReplicatedMergeTree中罕见的争用条件。 -- 固定可能冻结 “leader election” 启动服务器时。 -- 使用数据源的本地副本时,将忽略max\_replica\_delay\_for\_distributed\_queries设置。 这已被修复。 -- 修正了不正确的行为 `ALTER TABLE CLEAR COLUMN IN PARTITION` 尝试清除不存在的列时。 -- 修复了multif函数中使用空数组或字符串时的异常。 -- 修正了反序列化本机格式时过多的内存分配。 -- 修正了Trie字典的不正确的自动更新。 -- 修复了使用SAMPLE从合并表中使用GROUP BY子句运行查询时的异常。 -- 修复了使用distributed\_aggregation\_memory\_efficient=1时组的崩溃。 -- 现在,您可以指定数据库。表在右侧的IN和JOIN。 -- 用于并行聚合的线程太多。 这已被修复。 -- 固定如何 “if” 函数与FixedString参数一起使用。 -- 为权重为0的分片从分布式表中选择工作不正确。 这已被修复。 -- 运行 `CREATE VIEW IF EXISTS no longer causes crashes.` -- 修正了input\_format\_skip\_unknown\_fields=1设置并且有负数时的不正确行为。 -- 修正了一个无限循环 `dictGetHierarchy()` 如果字典中有一些无效的数据,则函数。 -- 固定 `Syntax error: unexpected (...)` 在IN或JOIN子句和合并表中使用子查询运行分布式查询时出错。 -- 修复了从字典表中选择查询的不正确解释。 -- 修正了 “Cannot mremap” 在IN和JOIN子句中使用包含超过20亿个元素的数组时出错。 -- 修复了以MySQL为源的字典的故障转移。 - -#### 改进开发和组装ClickHouse的工作流程: {#improved-workflow-for-developing-and-assembling-clickhouse-1} - -- 构建可以在阿卡迪亚组装。 -- 您可以使用gcc7来编译ClickHouse。 -- 现在使用ccache+distcc的并行构建速度更快。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54245-2017-07-04} - -#### 新功能: {#new-features-5} - -- 分布式的DDL(例如, `CREATE TABLE ON CLUSTER`) -- 复制的查询 `ALTER TABLE CLEAR COLUMN IN PARTITION.` -- 字典表的引擎(以表格形式访问字典数据)。 -- 字典数据库引擎(这种类型的数据库会自动为所有连接的外部字典提供字典表)。 -- 您可以通过向源发送请求来检查字典的更新。 -- 限定列名称 -- 使用双引号引用标识符。 -- Http接口中的会话。 -- 复制表的优化查询不仅可以在leader上运行。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-2} - -- 删除设置全局。 - -#### 小的变化: {#minor-changes} - -- 现在,在触发警报之后,日志将打印完整的堆栈跟踪。 -- 在启动时放宽对损坏/额外数据部件数量的验证(有太多误报)。 - -#### 错误修复: {#bug-fixes-5} - -- 修复了连接错误 “sticking” 当插入到分布式表中。 -- GLOBAL IN现在适用于查看分布式表的合并表中的查询。 -- 在Google Compute Engine虚拟机上检测到不正确的内核数。 这已被修复。 -- 缓存外部字典的可执行源如何工作的更改。 -- 修复了包含空字符的字符串的比较。 -- 修正了Float32主键字段与常量的比较。 -- 以前,对字段大小的不正确估计可能导致分配过大。 -- 修复了使用ALTER查询添加到表中的可空列时的崩溃。 -- 修复了按可空列排序时的崩溃,如果行数小于限制。 -- 修复了仅由常量值组成的子查询的顺序。 -- 以前,复制的表在丢弃表失败后可能仍处于无效状态。 -- 具有空结果的标量子查询的别名不再丢失。 -- 现在如果.so文件被损坏,使用编译的查询不会失败并出现错误。 diff --git a/docs/zh/whats_new/changelog/2018.md b/docs/zh/whats_new/changelog/2018.md deleted file mode 100644 index b62d8372d1a..00000000000 --- a/docs/zh/whats_new/changelog/2018.md +++ /dev/null @@ -1,1063 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 78 -toc_title: '2018' ---- - -## ClickHouse释放18.16 {#clickhouse-release-18-16} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-16-1-2018-12-21} - -#### 错误修复: {#bug-fixes} - -- 修复了导致使用ODBC源更新字典时出现问题的错误。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- 聚集函数的JIT编译现在适用于低心率列。 [\#3838](https://github.com/ClickHouse/ClickHouse/issues/3838) - -#### 改进: {#improvements} - -- 添加了 `low_cardinality_allow_in_native_format` 设置(默认情况下启用)。 如果禁用,则选择查询的LowCardinality列将转换为普通列,插入查询将需要普通列。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) - -#### 构建改进: {#build-improvements} - -- 修复了基于macOS和ARM的构建。 - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-16-0-2018-12-14} - -#### 新功能: {#new-features} - -- `DEFAULT` 在以半结构化输入格式加载数据时,会计算表达式是否缺少字段 (`JSONEachRow`, `TSKV`). 该功能与启用 `insert_sample_with_metadata` 设置。 [\#3555](https://github.com/ClickHouse/ClickHouse/pull/3555) -- 该 `ALTER TABLE` 查询现在有 `MODIFY ORDER BY` 用于在添加或删除表列时更改排序键的操作。 这是在表有用 `MergeTree` 基于此排序键合并时执行其他任务的系列,例如 `SummingMergeTree`, `AggregatingMergeTree`,等等。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) [\#3755](https://github.com/ClickHouse/ClickHouse/pull/3755) -- 对于在表 `MergeTree` 家庭,现在你可以指定一个不同的排序键 (`ORDER BY`)和索引 (`PRIMARY KEY`). 排序键可以长于索引。 [\#3581](https://github.com/ClickHouse/ClickHouse/pull/3581) -- 添加了 `hdfs` 表功能和 `HDFS` 用于将数据导入和导出到HDFS的表引擎。 [晨兴-xc](https://github.com/ClickHouse/ClickHouse/pull/3617) -- 增加了使用base64的功能: `base64Encode`, `base64Decode`, `tryBase64Decode`. [Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3350) -- 现在,您可以使用一个参数来配置的精度 `uniqCombined` 聚合函数(选择HyperLogLog单元格的数量)。 [\#3406](https://github.com/ClickHouse/ClickHouse/pull/3406) -- 添加了 `system.contributors` 包含在ClickHouse中进行提交的所有人的名称的表。 [\#3452](https://github.com/ClickHouse/ClickHouse/pull/3452) -- 增加了省略分区的能力 `ALTER TABLE ... FREEZE` 查询以便一次备份所有分区。 [\#3514](https://github.com/ClickHouse/ClickHouse/pull/3514) -- 已添加 `dictGet` 和 `dictGetOrDefault` 不需要指定返回值类型的函数。 该类型是从字典描述自动确定的。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3564) -- 现在,您可以在表描述中为列指定注释,并使用以下方式对其进行更改 `ALTER`. [\#3377](https://github.com/ClickHouse/ClickHouse/pull/3377) -- 阅读支持 `Join` 使用简单键键入表格。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3728) -- 现在,您可以指定选项 `join_use_nulls`, `max_rows_in_join`, `max_bytes_in_join`,和 `join_overflow_mode` 当创建一个 `Join` 键入表。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3728) -- 添加了 `joinGet` 功能,允许您使用 `Join` 像字典一样键入表格。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3728) -- 添加了 `partition_key`, `sorting_key`, `primary_key`,和 `sampling_key` 列到 `system.tables` 表以便提供关于表键的信息。 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- 添加了 `is_in_partition_key`, `is_in_sorting_key`, `is_in_primary_key`,和 `is_in_sampling_key` 列到 `system.columns` 桌子 [\#3609](https://github.com/ClickHouse/ClickHouse/pull/3609) -- 添加了 `min_time` 和 `max_time` 列到 `system.parts` 桌子 当分区键是由以下表达式组成的表达式时,将填充这些列 `DateTime` 列。 [Emmanuel Donin de Rosière](https://github.com/ClickHouse/ClickHouse/pull/3800) - -#### 错误修复: {#bug-fixes-1} - -- 修复和性能改进 `LowCardinality` 数据类型。 `GROUP BY` 使用 `LowCardinality(Nullable(...))`. 获取的值 `extremes`. 处理高阶函数。 `LEFT ARRAY JOIN`. 分布 `GROUP BY`. 返回的函数 `Array`. 执行 `ORDER BY`. 写入 `Distributed` 表(nicelulu)。 向后兼容 `INSERT` 从实现旧客户端的查询 `Native` 协议 支持 `LowCardinality` 为 `JOIN`. 在单个流中工作时提高性能。 [\#3823](https://github.com/ClickHouse/ClickHouse/pull/3823) [\#3803](https://github.com/ClickHouse/ClickHouse/pull/3803) [\#3799](https://github.com/ClickHouse/ClickHouse/pull/3799) [\#3769](https://github.com/ClickHouse/ClickHouse/pull/3769) [\#3744](https://github.com/ClickHouse/ClickHouse/pull/3744) [\#3681](https://github.com/ClickHouse/ClickHouse/pull/3681) [\#3651](https://github.com/ClickHouse/ClickHouse/pull/3651) [\#3649](https://github.com/ClickHouse/ClickHouse/pull/3649) [\#3641](https://github.com/ClickHouse/ClickHouse/pull/3641) [\#3632](https://github.com/ClickHouse/ClickHouse/pull/3632) [\#3568](https://github.com/ClickHouse/ClickHouse/pull/3568) [\#3523](https://github.com/ClickHouse/ClickHouse/pull/3523) [\#3518](https://github.com/ClickHouse/ClickHouse/pull/3518) -- 固定如何 `select_sequential_consistency` 选项工作。 以前,启用此设置时,在开始写入新分区后,有时会返回不完整的结果。 [\#2863](https://github.com/ClickHouse/ClickHouse/pull/2863) -- 执行DDL时正确指定数据库 `ON CLUSTER` 查询和 `ALTER UPDATE/DELETE`. [\#3772](https://github.com/ClickHouse/ClickHouse/pull/3772) [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- 为视图中的子查询正确指定了数据库。 [\#3521](https://github.com/ClickHouse/ClickHouse/pull/3521) -- 修正了一个错误 `PREWHERE` 与 `FINAL` 为 `VersionedCollapsingMergeTree`. [7167bfd7](https://github.com/ClickHouse/ClickHouse/commit/7167bfd7b365538f7a91c4307ad77e552ab4e8c1) -- 现在你可以使用 `KILL QUERY` 取消尚未启动的查询,因为它们正在等待锁定表。 [\#3517](https://github.com/ClickHouse/ClickHouse/pull/3517) -- 更正日期和时间计算,如果时钟被移回午夜(这发生在伊朗,并发生在莫斯科1981年至1983年)。 以前,这导致时间比必要的时间早一天重置,并且还导致文本格式的日期和时间格式不正确。 [\#3819](https://github.com/ClickHouse/ClickHouse/pull/3819) -- 修正了某些情况下的错误 `VIEW` 和省略数据库的子查询。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3521) -- 修正了一个争用条件时,同时从读取 `MATERIALIZED VIEW` 和删除 `MATERIALIZED VIEW` 由于不锁定内部 `MATERIALIZED VIEW`. [\#3404](https://github.com/ClickHouse/ClickHouse/pull/3404) [\#3694](https://github.com/ClickHouse/ClickHouse/pull/3694) -- 修正了错误 `Lock handler cannot be nullptr.` [\#3689](https://github.com/ClickHouse/ClickHouse/pull/3689) -- 固定查询处理时 `compile_expressions` 选项已启用(默认情况下启用)。 非确定性常量表达式,如 `now` 功能不再展开。 [\#3457](https://github.com/ClickHouse/ClickHouse/pull/3457) -- 修复了在指定非常量比例参数时发生的崩溃 `toDecimal32/64/128` 功能。 -- 修复了尝试插入数组时的错误 `NULL` 中的元素 `Values` 格式化为类型的列 `Array` 没有 `Nullable` (如果 `input_format_values_interpret_expressions` = 1). [\#3487](https://github.com/ClickHouse/ClickHouse/pull/3487) [\#3503](https://github.com/ClickHouse/ClickHouse/pull/3503) -- 固定连续错误登录 `DDLWorker` 如果动物园管理员不可用。 [8f50c620](https://github.com/ClickHouse/ClickHouse/commit/8f50c620334988b28018213ec0092fe6423847e2) -- 修正了返回类型 `quantile*` 从功能 `Date` 和 `DateTime` 参数的类型。 [\#3580](https://github.com/ClickHouse/ClickHouse/pull/3580) -- 修正了 `WITH` 子句,如果它指定了一个没有表达式的简单别名。 [\#3570](https://github.com/ClickHouse/ClickHouse/pull/3570) -- 固定处理具有命名子查询和限定列名的查询时 `enable_optimize_predicate_expression` 被启用。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3588) -- 修正了错误 `Attempt to attach to nullptr thread group` 使用实例化视图时。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3623) -- 修正了传递某些不正确的参数时崩溃 `arrayReverse` 功能。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- 修正了缓冲区溢出 `extractURLParameter` 功能。 改进的性能。 添加了包含零字节的字符串的正确处理。 [141e9799](https://github.com/ClickHouse/ClickHouse/commit/141e9799e49201d84ea8e951d1bed4fb6d3dacb5) -- 在固定缓冲区溢出 `lowerUTF8` 和 `upperUTF8` 功能。 删除了执行这些功能的能力 `FixedString` 类型参数。 [\#3662](https://github.com/ClickHouse/ClickHouse/pull/3662) -- 修复了删除时罕见的竞争条件 `MergeTree` 桌子 [\#3680](https://github.com/ClickHouse/ClickHouse/pull/3680) -- 修正了从读取时的争用条件 `Buffer` 表和同时执行 `ALTER` 或 `DROP` 在目标桌上。 [\#3719](https://github.com/ClickHouse/ClickHouse/pull/3719) -- 修正了一个段错误,如果 `max_temporary_non_const_columns` 超过限制。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### 改进: {#improvements-1} - -- 服务器不会将处理后的配置文件写入 `/etc/clickhouse-server/` 目录。 相反,它将它们保存在 `preprocessed_configs` 里面的目录 `path`. 这意味着 `/etc/clickhouse-server/` 目录没有写访问权限 `clickhouse` 用户,从而提高了安全性。 [\#2443](https://github.com/ClickHouse/ClickHouse/pull/2443) -- 该 `min_merge_bytes_to_use_direct_io` 默认情况下,选项设置为10GiB。 将在MergeTree系列中执行形成大部分表的合并 `O_DIRECT` 模式,这可以防止过多的页高速缓存逐出。 [\#3504](https://github.com/ClickHouse/ClickHouse/pull/3504) -- 当表数量非常多时,加速服务器启动。 [\#3398](https://github.com/ClickHouse/ClickHouse/pull/3398) -- 添加了连接池和HTTP `Keep-Alive` 用于副本之间的连接。 [\#3594](https://github.com/ClickHouse/ClickHouse/pull/3594) -- 如果查询语法无效,则 `400 Bad Request` 代码在返回 `HTTP` 接口(500以前返回)。 [31bc680a](https://github.com/ClickHouse/ClickHouse/commit/31bc680ac5f4bb1d0360a8ba4696fa84bb47d6ab) -- 该 `join_default_strictness` 选项设置为 `ALL` 默认情况下为兼容性。 [120e2cbe](https://github.com/ClickHouse/ClickHouse/commit/120e2cbe2ff4fbad626c28042d9b28781c805afe) -- 删除日志记录 `stderr` 从 `re2` 无效或复杂正则表达式的库。 [\#3723](https://github.com/ClickHouse/ClickHouse/pull/3723) -- 添加的 `Kafka` 表引擎:在开始从Kafka读取之前检查订阅;表的kafka\_max\_block\_size设置。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3396) -- 该 `cityHash64`, `farmHash64`, `metroHash64`, `sipHash64`, `halfMD5`, `murmurHash2_32`, `murmurHash2_64`, `murmurHash3_32`,和 `murmurHash3_64` 函数现在适用于任意数量的参数和元组形式的参数。 [\#3451](https://github.com/ClickHouse/ClickHouse/pull/3451) [\#3519](https://github.com/ClickHouse/ClickHouse/pull/3519) -- 该 `arrayReverse` 函数现在适用于任何类型的数组。 [73e3a7b6](https://github.com/ClickHouse/ClickHouse/commit/73e3a7b662161d6005e7727d8a711b930386b871) -- 增加了一个可选参数:插槽大小的 `timeSlots` 功能。 [基里尔\*什瓦科夫](https://github.com/ClickHouse/ClickHouse/pull/3724) -- 为 `FULL` 和 `RIGHT JOIN`,该 `max_block_size` 设置用于右表中未连接的数据流。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3699) -- 添加了 `--secure` 命令行参数 `clickhouse-benchmark` 和 `clickhouse-performance-test` 启用TLS。 [\#3688](https://github.com/ClickHouse/ClickHouse/pull/3688) [\#3690](https://github.com/ClickHouse/ClickHouse/pull/3690) -- 类型转换时的结构 `Buffer` 表的类型与目标表的结构不匹配。 [维塔利\*巴拉诺夫](https://github.com/ClickHouse/ClickHouse/pull/3603) -- 添加了 `tcp_keep_alive_timeout` 在指定的时间间隔内不活动后启用保持活动数据包的选项。 [\#3441](https://github.com/ClickHouse/ClickHouse/pull/3441) -- 删除不必要的引用值的分区键中 `system.parts` 表,如果它由单列组成。 [\#3652](https://github.com/ClickHouse/ClickHouse/pull/3652) -- 模函数适用于 `Date` 和 `DateTime` 数据类型。 [\#3385](https://github.com/ClickHouse/ClickHouse/pull/3385) -- 添加同义词的 `POWER`, `LN`, `LCASE`, `UCASE`, `REPLACE`, `LOCATE`, `SUBSTR`,和 `MID` 功能。 [\#3774](https://github.com/ClickHouse/ClickHouse/pull/3774) [\#3763](https://github.com/ClickHouse/ClickHouse/pull/3763) 为了与SQL标准兼容,某些函数名称不区分大小写。 添加语法糖 `SUBSTRING(expr FROM start FOR length)` 对于与SQL的兼容性。 [\#3804](https://github.com/ClickHouse/ClickHouse/pull/3804) -- 增加了以下能力 `mlock` 对应于存储器页 `clickhouse-server` 可执行代码,以防止它被强制出内存。 默认情况下禁用此功能。 [\#3553](https://github.com/ClickHouse/ClickHouse/pull/3553) -- 从读取时改进的性能 `O_DIRECT` (与 `min_bytes_to_use_direct_io` 选项启用)。 [\#3405](https://github.com/ClickHouse/ClickHouse/pull/3405) -- 的改进的性能 `dictGet...OrDefault` 常量键参数和非常量默认参数的函数。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3563) -- 该 `firstSignificantSubdomain` 功能现在处理域 `gov`, `mil`,和 `edu`. [Igor Hatarist](https://github.com/ClickHouse/ClickHouse/pull/3601) 改进的性能。 [\#3628](https://github.com/ClickHouse/ClickHouse/pull/3628) -- 能够指定用于启动的自定义环境变量 `clickhouse-server` 使用 `SYS-V init.d` 通过定义脚本 `CLICKHOUSE_PROGRAM_ENV` 在 `/etc/default/clickhouse`. - [Pavlo Bashynskyi](https://github.com/ClickHouse/ClickHouse/pull/3612) -- Clickhouse-server init脚本的正确返回代码。 [\#3516](https://github.com/ClickHouse/ClickHouse/pull/3516) -- 该 `system.metrics` 表现在有 `VersionInteger` 公制和 `system.build_options` 有添加的行 `VERSION_INTEGER`,其中包含ClickHouse版本的数字形式,例如 `18016000`. [\#3644](https://github.com/ClickHouse/ClickHouse/pull/3644) -- 删除比较的能力 `Date` 输入一个数字,以避免潜在的错误,如 `date = 2018-12-17`,其中日期周围的引号被错误省略。 [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) -- 修正了有状态函数的行为,如 `rowNumberInAllBlocks`. 他们之前输出的结果是由于在查询分析期间启动而大一个数字。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3729) -- 如果 `force_restore_data` 文件无法删除,将显示错误消息。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3794) - -#### 构建改进: {#build-improvements-1} - -- 更新了 `jemalloc` 库,它修复了潜在的内存泄漏。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3557) -- 分析与 `jemalloc` 默认情况下为了调试生成启用。 [2cc82f5c](https://github.com/ClickHouse/ClickHouse/commit/2cc82f5cbe266421cd4c1165286c2c47e5ffcb15) -- 增加了运行集成测试的能力,当只 `Docker` 安装在系统上。 [\#3650](https://github.com/ClickHouse/ClickHouse/pull/3650) -- 在SELECT查询中添加了模糊表达式测试。 [\#3442](https://github.com/ClickHouse/ClickHouse/pull/3442) -- 为提交添加了一个压力测试,它以并行和随机顺序执行功能测试,以检测更多的竞争条件。 [\#3438](https://github.com/ClickHouse/ClickHouse/pull/3438) -- 改进了在Docker映像中启动clickhouse-server的方法。 [Elghazal Ahmed](https://github.com/ClickHouse/ClickHouse/pull/3663) -- 对于Docker映像,增加了对使用数据库中的文件初始化数据库的支持 `/docker-entrypoint-initdb.d` 目录。 [康斯坦丁\*列别杰夫](https://github.com/ClickHouse/ClickHouse/pull/3695) -- 修复了基于ARM的构建。 [\#3709](https://github.com/ClickHouse/ClickHouse/pull/3709) - -#### 向后不兼容的更改: {#backward-incompatible-changes} - -- 删除比较的能力 `Date` 用数字键入。 而不是 `toDate('2018-12-18') = 17883`,必须使用显式类型转换 `= toDate(17883)` [\#3687](https://github.com/ClickHouse/ClickHouse/pull/3687) - -## ClickHouse释放18.14 {#clickhouse-release-18-14} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-14-19-2018-12-19} - -#### 错误修复: {#bug-fixes-2} - -- 修复了导致使用ODBC源更新字典时出现问题的错误。 [\#3825](https://github.com/ClickHouse/ClickHouse/issues/3825), [\#3829](https://github.com/ClickHouse/ClickHouse/issues/3829) -- 执行DDL时正确指定数据库 `ON CLUSTER` 查询。 [\#3460](https://github.com/ClickHouse/ClickHouse/pull/3460) -- 修正了一个段错误,如果 `max_temporary_non_const_columns` 超过限制。 [\#3788](https://github.com/ClickHouse/ClickHouse/pull/3788) - -#### 构建改进: {#build-improvements-2} - -- 修复了基于ARM的构建。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-18-2018-12-04} - -#### 错误修复: {#bug-fixes-3} - -- 修正错误 `dictGet...` 类型字典的函数 `range`,如果其中一个参数是恒定的,而另一个则不是。 [\#3751](https://github.com/ClickHouse/ClickHouse/pull/3751) -- 修复了导致消息的错误 `netlink: '...': attribute type 1 has an invalid length` 要打印在Linux内核日志中,这只发生在足够新鲜的Linux内核版本上。 [\#3749](https://github.com/ClickHouse/ClickHouse/pull/3749) -- 在功能固定段错误 `empty` 对于争论 `FixedString` 类型。 [丹尼尔,道广明](https://github.com/ClickHouse/ClickHouse/pull/3703) -- 修正了使用大值时过多的内存分配 `max_query_size` 设置(内存块 `max_query_size` 字节被预先分配一次)。 [\#3720](https://github.com/ClickHouse/ClickHouse/pull/3720) - -#### 构建更改: {#build-changes} - -- 使用操作系统包中的版本7的LLVM/Clang库修复构建(这些库用于运行时查询编译)。 [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-17-2018-11-30} - -#### 错误修复: {#bug-fixes-4} - -- 修复了ODBC桥进程未与主服务器进程终止的情况。 [\#3642](https://github.com/ClickHouse/ClickHouse/pull/3642) -- 固定同步插入 `Distributed` 具有不同于远程表的列列表的列列表的表。 [\#3673](https://github.com/ClickHouse/ClickHouse/pull/3673) -- 修复了丢弃MergeTree表时可能导致崩溃的罕见竞争条件。 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- 修复了查询线程创建失败时的查询死锁 `Resource temporarily unavailable` 错误 [\#3643](https://github.com/ClickHouse/ClickHouse/pull/3643) -- 修正了解析 `ENGINE` 条款时 `CREATE AS table` 语法被使用和 `ENGINE` 子句之前指定 `AS table` (错误导致忽略指定的引擎)。 [\#3692](https://github.com/ClickHouse/ClickHouse/pull/3692) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-15-2018-11-21} - -#### 错误修复: {#bug-fixes-5} - -- 反序列化类型的列时,高估了内存块的大小 `Array(String)` 这导致 “Memory limit exceeded” 错误。 该问题出现在版本18.12.13中。 [\#3589](https://github.com/ClickHouse/ClickHouse/issues/3589) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-14-2018-11-20} - -#### 错误修复: {#bug-fixes-6} - -- 固定 `ON CLUSTER` 当群集配置为安全时进行查询(标志 ``). [\#3599](https://github.com/ClickHouse/ClickHouse/pull/3599) - -#### 构建更改: {#build-changes-1} - -- 固定的问题(llvm-7从系统,macos) [\#3582](https://github.com/ClickHouse/ClickHouse/pull/3582) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-13-2018-11-08} - -#### 错误修复: {#bug-fixes-7} - -- 修正了 `Block structure mismatch in MergingSorted stream` 错误 [\#3162](https://github.com/ClickHouse/ClickHouse/issues/3162) -- 固定 `ON CLUSTER` 查询的情况下,当安全连接被打开的群集配置( `` 标志)。 [\#3465](https://github.com/ClickHouse/ClickHouse/pull/3465) -- 修复了查询中使用的错误 `SAMPLE`, `PREWHERE` 和别名列。 [\#3543](https://github.com/ClickHouse/ClickHouse/pull/3543) -- 修正了一个罕见的 `unknown compression method` 错误时 `min_bytes_to_use_direct_io` 设置已启用。 [3544](https://github.com/ClickHouse/ClickHouse/pull/3544) - -#### 性能改进: {#performance-improvements} - -- 查询的固定性能回归 `GROUP BY` 在AMD EPYC处理器上执行时,uint16或Date类型的列。 [Igor Lapko](https://github.com/ClickHouse/ClickHouse/pull/3512) -- 修正了处理长字符串的查询的性能回归。 [\#3530](https://github.com/ClickHouse/ClickHouse/pull/3530) - -#### 构建改进: {#build-improvements-3} - -- 简化阿卡迪亚构建的改进。 [\#3475](https://github.com/ClickHouse/ClickHouse/pull/3475), [\#3535](https://github.com/ClickHouse/ClickHouse/pull/3535) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-12-2018-11-02} - -#### 错误修复: {#bug-fixes-8} - -- 修复了加入两个未命名的子查询时的崩溃。 [\#3505](https://github.com/ClickHouse/ClickHouse/pull/3505) -- 修正了生成不正确的查询(用空 `WHERE` 子句)查询外部数据库时。 [hotid](https://github.com/ClickHouse/ClickHouse/pull/3477) -- 修正了在ODBC字典中使用不正确的超时值。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3511) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-11-2018-10-29} - -#### 错误修复: {#bug-fixes-9} - -- 修正了错误 `Block structure mismatch in UNION stream: different number of columns` 在限制查询。 [\#2156](https://github.com/ClickHouse/ClickHouse/issues/2156) -- 修复了在嵌套结构中包含数组的表中合并数据时出现的错误。 [\#3397](https://github.com/ClickHouse/ClickHouse/pull/3397) -- 修正了不正确的查询结果,如果 `merge_tree_uniform_read_distribution` 设置被禁用(默认情况下启用)。 [\#3429](https://github.com/ClickHouse/ClickHouse/pull/3429) -- 修复了在本机格式的分布式表中插入错误。 [\#3411](https://github.com/ClickHouse/ClickHouse/issues/3411) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-10-2018-10-23} - -- 该 `compile_expressions` 默认情况下禁用设置(表达式的JIT编译)。 [\#3410](https://github.com/ClickHouse/ClickHouse/pull/3410) -- 该 `enable_optimize_predicate_expression` 默认情况下禁用设置。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-14-9-2018-10-16} - -#### 新功能: {#new-features-1} - -- 该 `WITH CUBE` 修饰符 `GROUP BY` (替代语法 `GROUP BY CUBE(...)` 也可用)。 [\#3172](https://github.com/ClickHouse/ClickHouse/pull/3172) -- 添加了 `formatDateTime` 功能。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2770) -- 添加了 `JDBC` 表引擎和 `jdbc` 表功能(需要安装clickhouse-jdbc桥)。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) -- 增加了使用ISO周编号的功能: `toISOWeek`, `toISOYear`, `toStartOfISOYear`,和 `toDayOfYear`. [\#3146](https://github.com/ClickHouse/ClickHouse/pull/3146) -- 现在你可以使用 `Nullable` 列 `MySQL` 和 `ODBC` 桌子 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- 嵌套的数据结构可以被读取为嵌套的对象 `JSONEachRow` 格式。 添加了 `input_format_import_nested_json` 设置。 [维罗曼\*云坎](https://github.com/ClickHouse/ClickHouse/pull/3144) -- 并行处理可用于许多 `MATERIALIZED VIEW`s插入数据时。 见 `parallel_view_processing` 设置。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3208) -- 添加了 `SYSTEM FLUSH LOGS` 查询(强制日志刷新到系统表,如 `query_log`) [\#3321](https://github.com/ClickHouse/ClickHouse/pull/3321) -- 现在,您可以使用预定义 `database` 和 `table` 声明时的宏 `Replicated` 桌子 [\#3251](https://github.com/ClickHouse/ClickHouse/pull/3251) -- 增加了阅读的能力 `Decimal` 工程表示法中的类型值(表示十的幂)。 [\#3153](https://github.com/ClickHouse/ClickHouse/pull/3153) - -#### 实验特点: {#experimental-features} - -- 对GROUP BY子句进行优化 `LowCardinality data types.` [\#3138](https://github.com/ClickHouse/ClickHouse/pull/3138) -- 表达式的优化计算 `LowCardinality data types.` [\#3200](https://github.com/ClickHouse/ClickHouse/pull/3200) - -#### 改进: {#improvements-2} - -- 显着减少查询的内存消耗 `ORDER BY` 和 `LIMIT`. 见 `max_bytes_before_remerge_sort` 设置。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- 在没有 `JOIN` (`LEFT`, `INNER`, …), `INNER JOIN` 是假定的。 [\#3147](https://github.com/ClickHouse/ClickHouse/pull/3147) -- 限定星号在以下查询中正常工作 `JOIN`. [张冬](https://github.com/ClickHouse/ClickHouse/pull/3202) -- 该 `ODBC` 表引擎正确地选择用于引用远程数据库的SQL方言中的标识符的方法。 [Alexandr Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/3210) -- 该 `compile_expressions` 默认情况下启用设置(表达式的JIT编译)。 -- 修复了同时删除数据库/表(如果存在)和创建数据库/表(如果不存在)的行为。 前情提要 `CREATE DATABASE ... IF NOT EXISTS` 查询可能会返回错误消息 “File … already exists” 和 `CREATE TABLE ... IF NOT EXISTS` 和 `DROP TABLE IF EXISTS` 查询可能会返回 `Table ... is creating or attaching right now`. [\#3101](https://github.com/ClickHouse/ClickHouse/pull/3101) -- 当从MySQL或ODBC表中查询时,LIKE和IN表达式具有常量右半部分被传递到远程服务器。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- 当从MySQL和ODBC表查询时,与WHERE子句中常量表达式的比较会传递给远程服务器。 以前,只通过与常量的比较。 [\#3182](https://github.com/ClickHouse/ClickHouse/pull/3182) -- 正确计算终端中的行宽 `Pretty` 格式,包括带有象形文字的字符串。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/3257). -- `ON CLUSTER` 可以指定 `ALTER UPDATE` 查询。 -- 提高了读取数据的性能 `JSONEachRow` 格式。 [\#3332](https://github.com/ClickHouse/ClickHouse/pull/3332) -- 添加同义词的 `LENGTH` 和 `CHARACTER_LENGTH` 功能的兼容性。 该 `CONCAT` 函数不再区分大小写。 [\#3306](https://github.com/ClickHouse/ClickHouse/pull/3306) -- 添加了 `TIMESTAMP` 的同义词 `DateTime` 类型。 [\#3390](https://github.com/ClickHouse/ClickHouse/pull/3390) -- 服务器日志中始终为query\_id保留空间,即使日志行与查询无关。 这使得使用第三方工具更容易分析服务器文本日志。 -- 当查询超过整数千兆字节的下一级别时,会记录查询的内存消耗。 [\#3205](https://github.com/ClickHouse/ClickHouse/pull/3205) -- 为使用本机协议的客户端库错误发送的列少于服务器预期的插入查询时的情况添加了兼容模式。 使用clickhouse-cpp库时,这种情况是可能的。 以前,此方案会导致服务器崩溃。 [\#3171](https://github.com/ClickHouse/ClickHouse/pull/3171) -- 在用户定义的WHERE表达式中 `clickhouse-copier`,您现在可以使用 `partition_key` 别名(用于按源表分区进行其他过滤)。 如果分区方案在复制过程中发生更改,但仅稍有更改,这很有用。 [\#3166](https://github.com/ClickHouse/ClickHouse/pull/3166) -- 的工作流程 `Kafka` 引擎已被移动到后台线程池中,以便在高负载下自动降低数据读取速度。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- 支持阅读 `Tuple` 和 `Nested` 结构的值,如 `struct` 在 `Cap'n'Proto format`. [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3216) -- 顶级域名列表 `firstSignificantSubdomain` 功能现在包括域 `biz`. [decaseal](https://github.com/ClickHouse/ClickHouse/pull/3219) -- 在外部字典的配置, `null_value` 被解释为默认数据类型的值。 [\#3330](https://github.com/ClickHouse/ClickHouse/pull/3330) -- 支持 `intDiv` 和 `intDivOrZero` 功能 `Decimal`. [b48402e8](https://github.com/ClickHouse/ClickHouse/commit/b48402e8712e2b9b151e0eef8193811d433a1264) -- 支持 `Date`, `DateTime`, `UUID`,和 `Decimal` 类型作为键 `sumMap` 聚合函数。 [\#3281](https://github.com/ClickHouse/ClickHouse/pull/3281) -- 支持 `Decimal` 外部字典中的数据类型。 [\#3324](https://github.com/ClickHouse/ClickHouse/pull/3324) -- 支持 `Decimal` 数据类型in `SummingMergeTree` 桌子 [\#3348](https://github.com/ClickHouse/ClickHouse/pull/3348) -- 增加了专业化 `UUID` 在 `if`. [\#3366](https://github.com/ClickHouse/ClickHouse/pull/3366) -- 减少的数量 `open` 和 `close` 从读取时系统调用 `MergeTree table`. [\#3283](https://github.com/ClickHouse/ClickHouse/pull/3283) -- A `TRUNCATE TABLE` 查询可以在任何副本上执行(将查询传递给领导副本)。 [基里尔\*什瓦科夫](https://github.com/ClickHouse/ClickHouse/pull/3375) - -#### 错误修复: {#bug-fixes-10} - -- 修正了一个问题 `Dictionary` 表 `range_hashed` 字典 此错误发生在版本18.12.17中。 [\#1702](https://github.com/ClickHouse/ClickHouse/pull/1702) -- 修正了加载时的错误 `range_hashed` 字典(消息 `Unsupported type Nullable (...)`). 此错误发生在版本18.12.17中。 [\#3362](https://github.com/ClickHouse/ClickHouse/pull/3362) -- 在固定的错误 `pointInPolygon` 函数由于不准确的计算的多边形与大量的顶点位于彼此靠近的积累。 [\#3331](https://github.com/ClickHouse/ClickHouse/pull/3331) [\#3341](https://github.com/ClickHouse/ClickHouse/pull/3341) -- 如果在合并数据部分之后,结果部分的校验和与另一个副本中相同合并的结果不同,则删除合并的结果并从另一个副本下载数据部分(这是正确的行为)。 但是在下载数据部分之后,由于该部分已经存在的错误(因为合并后数据部分被删除了一些延迟),因此无法将其添加到工作集中。 这导致周期性尝试下载相同的数据。 [\#3194](https://github.com/ClickHouse/ClickHouse/pull/3194) -- 修正了查询总内存消耗的不正确计算(由于计算不正确, `max_memory_usage_for_all_queries` 设置工作不正确, `MemoryTracking` 度量值不正确)。 此错误发生在版本18.12.13中。 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3344) -- 修正的功能 `CREATE TABLE ... ON CLUSTER ... AS SELECT ...` 此错误发生在版本18.12.13中。 [\#3247](https://github.com/ClickHouse/ClickHouse/pull/3247) -- 修正了数据结构的不必要的准备 `JOIN`如果发起查询的服务器上 `JOIN` 仅在远程服务器上执行。 [\#3340](https://github.com/ClickHouse/ClickHouse/pull/3340) -- 在固定的错误 `Kafka` 引擎:开始读取数据时异常后的死锁,并在完成时锁定 [Marek Vavruša](https://github.com/ClickHouse/ClickHouse/pull/3215). -- 为 `Kafka` 表,可选 `schema` 参数未被传递(的架构 `Cap'n'Proto` 格式)。 [Vojtech Splichal](https://github.com/ClickHouse/ClickHouse/pull/3150) -- 如果ZooKeeper服务器的整体服务器接受连接,但随后立即关闭它,而不是响应握手,ClickHouse选择连接另一台服务器。 以前,这会产生错误 `Cannot read all data. Bytes read: 0. Bytes expected: 4.` 服务器无法启动。 [8218cf3a](https://github.com/ClickHouse/ClickHouse/commit/8218cf3a5f39a43401953769d6d12a0bb8d29da9) -- 如果ZooKeeper服务器的整体包含DNS查询返回错误的服务器,则忽略这些服务器。 [17b8e209](https://github.com/ClickHouse/ClickHouse/commit/17b8e209221061325ad7ba0539f03c6e65f87f29) -- 固定类型之间的转换 `Date` 和 `DateTime` 当在插入数据 `VALUES` 格式(如果 `input_format_values_interpret_expressions = 1`). 以前,转换是在Unix Epoch时间中的天数和Unix时间戳的数值之间进行的,这会导致意外的结果。 [\#3229](https://github.com/ClickHouse/ClickHouse/pull/3229) -- 修正类型之间的转换 `Decimal` 和整数。 [\#3211](https://github.com/ClickHouse/ClickHouse/pull/3211) -- 在固定的错误 `enable_optimize_predicate_expression` 设置。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3231) -- 如果使用非默认的CSV分隔符,则修复了CSV格式的浮点数解析错误,例如 `;` [\#3155](https://github.com/ClickHouse/ClickHouse/pull/3155) -- 修正了 `arrayCumSumNonNegative` 函数(它不累加负值,如果累加器小于零)。 [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/3163) -- 固定如何 `Merge` 表工作的顶部 `Distributed` 使用时的表 `PREWHERE`. [\#3165](https://github.com/ClickHouse/ClickHouse/pull/3165) -- 在错误修复 `ALTER UPDATE` 查询。 -- 在固定的错误 `odbc` 表功能,出现在版本18.12。 [\#3197](https://github.com/ClickHouse/ClickHouse/pull/3197) -- 修正了聚合函数的操作 `StateArray` 组合子 [\#3188](https://github.com/ClickHouse/ClickHouse/pull/3188) -- 修正了划分时崩溃 `Decimal` 值为零。 [69dd6609](https://github.com/ClickHouse/ClickHouse/commit/69dd6609193beb4e7acd3e6ad216eca0ccfb8179) -- 使用固定输出类型的操作 `Decimal` 和整数参数。 [\#3224](https://github.com/ClickHouse/ClickHouse/pull/3224) -- 修正了在段错误 `GROUP BY` 上 `Decimal128`. [3359ba06](https://github.com/ClickHouse/ClickHouse/commit/3359ba06c39fcd05bfdb87d6c64154819621e13a) -- 该 `log_query_threads` 设置(关于查询执行的每个线程的日志记录信息)现在生效,只有当 `log_queries` 选项(有关查询的日志记录信息)设置为1。 由于 `log_query_threads` 默认情况下,即使禁用了查询日志记录,也会先前记录有关线程的信息。 [\#3241](https://github.com/ClickHouse/ClickHouse/pull/3241) -- 修正了分位数聚合函数的分布式操作中的错误(错误消息 `Not found column quantile...`). [292a8855](https://github.com/ClickHouse/ClickHouse/commit/292a885533b8e3b41ce8993867069d14cbd5a664) -- 修复了同时在18.12.17版服务器和旧服务器的集群上工作时的兼容性问题。 对于具有固定和非固定长度的GROUP BY键的分布式查询,如果要聚合大量数据,则返回的数据并不总是完全聚合(两个不同的行包含相同的聚合键)。 [\#3254](https://github.com/ClickHouse/ClickHouse/pull/3254) -- 固定处理替换 `clickhouse-performance-test`,如果查询只包含测试中声明的替换的一部分。 [\#3263](https://github.com/ClickHouse/ClickHouse/pull/3263) -- 修复了使用时的错误 `FINAL` 与 `PREWHERE`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- 修复了使用时的错误 `PREWHERE` 在过程中添加的列 `ALTER`. [\#3298](https://github.com/ClickHouse/ClickHouse/pull/3298) -- 增加了一个检查没有 `arrayJoin` 为 `DEFAULT` 和 `MATERIALIZED` 表达式。 前情提要, `arrayJoin` 插入数据时导致错误。 [\#3337](https://github.com/ClickHouse/ClickHouse/pull/3337) -- 增加了一个检查没有 `arrayJoin` 在一个 `PREWHERE` 条款 以前,这导致了类似的消息 `Size ... doesn't match` 或 `Unknown compression method` 执行查询时。 [\#3357](https://github.com/ClickHouse/ClickHouse/pull/3357) -- 修复了优化后可能发生的极少数情况下的段错误,并将相等性评估与相应的IN表达式链接起来。 [刘一民-字节舞](https://github.com/ClickHouse/ClickHouse/pull/3339) -- 小幅更正 `clickhouse-benchmark`:以前,客户端信息没有发送到服务器;现在关闭时更准确地计算执行的查询数量,并限制迭代次数。 [\#3351](https://github.com/ClickHouse/ClickHouse/pull/3351) [\#3352](https://github.com/ClickHouse/ClickHouse/pull/3352) - -#### 向后不兼容的更改: {#backward-incompatible-changes-1} - -- 删除了 `allow_experimental_decimal_type` 选项。 该 `Decimal` 数据类型可供默认使用。 [\#3329](https://github.com/ClickHouse/ClickHouse/pull/3329) - -## ClickHouse释放18.12 {#clickhouse-release-18-12} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-12-17-2018-09-16} - -#### 新功能: {#new-features-2} - -- `invalidate_query` (指定查询来检查是否需要更新外部字典的能力)实现了 `clickhouse` 资料来源。 [\#3126](https://github.com/ClickHouse/ClickHouse/pull/3126) -- 增加了使用的能力 `UInt*`, `Int*`,和 `DateTime` 数据类型(与 `Date` 类型)作为 `range_hashed` 定义范围边界的外部字典键。 现在 `NULL` 可用于指定开放范围。 [瓦西里\*内姆科夫](https://github.com/ClickHouse/ClickHouse/pull/3123) -- 该 `Decimal` 类型现在支持 `var*` 和 `stddev*` 聚合函数。 [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- 该 `Decimal` 类型现在支持数学函数 (`exp`, `sin` 等等。) [\#3129](https://github.com/ClickHouse/ClickHouse/pull/3129) -- 该 `system.part_log` 表现在有 `partition_id` 列。 [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### 错误修复: {#bug-fixes-11} - -- `Merge` 现在正常工作 `Distributed` 桌子 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3159) -- 修复了不兼容(不必要的依赖 `glibc` 版本),这使得它不可能运行ClickHouse的 `Ubuntu Precise` 和旧版本。 在版本18.12.13中出现了不兼容。 [\#3130](https://github.com/ClickHouse/ClickHouse/pull/3130) -- 在固定的错误 `enable_optimize_predicate_expression` 设置。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3107) -- 修复了在早于18.12.13的版本上使用副本集群并同时在具有较新版本的服务器上创建表的新副本时出现的向后兼容性的一个小问题(如消息中所示 `Can not clone replica, because the ... updated to new ClickHouse version`,这是合乎逻辑的,但不应该发生)。 [\#3122](https://github.com/ClickHouse/ClickHouse/pull/3122) - -#### 向后不兼容的更改: {#backward-incompatible-changes-2} - -- 该 `enable_optimize_predicate_expression` 默认情况下启用选项(这是相当乐观的)。 如果发生与搜索列名相关的查询分析错误,请设置 `enable_optimize_predicate_expression` 为0。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3107) - -### 碌莽禄,拢,0755-88888888 {#clickhouse-release-18-12-14-2018-09-13} - -#### 新功能: {#new-features-3} - -- 增加了对 `ALTER UPDATE` 查询。 [\#3035](https://github.com/ClickHouse/ClickHouse/pull/3035) -- 添加了 `allow_ddl` 选项,它限制用户对DDL查询的访问。 [\#3104](https://github.com/ClickHouse/ClickHouse/pull/3104) -- 添加了 `min_merge_bytes_to_use_direct_io` 备选案文 `MergeTree` 引擎允许您为合并的总大小设置阈值(当超过阈值时,将使用O\_DIRECT处理数据部分文件)。 [\#3117](https://github.com/ClickHouse/ClickHouse/pull/3117) -- 该 `system.merges` 系统表现在包含 `partition_id` 列。 [\#3099](https://github.com/ClickHouse/ClickHouse/pull/3099) - -#### 改进 {#improvements-3} - -- 如果数据部分在变异期间保持不变,则副本不会下载该数据部分。 [\#3103](https://github.com/ClickHouse/ClickHouse/pull/3103) -- 使用时,自动完成可用于设置名称 `clickhouse-client`. [\#3106](https://github.com/ClickHouse/ClickHouse/pull/3106) - -#### 错误修复: {#bug-fixes-12} - -- 添加了一个检查是元素的数组的大小 `Nested` 插入时的类型字段。 [\#3118](https://github.com/ClickHouse/ClickHouse/pull/3118) -- 修正了一个错误更新外部字典与 `ODBC` 来源和 `hashed` 存储。 此错误发生在版本18.12.13中。 -- 修复了使用以下命令从查询创建临时表时出现的崩溃 `IN` 条件。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3098) -- 修复了聚合函数中可能具有的数组的错误 `NULL` 元素。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/3097) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-12-13-2018-09-10} - -#### 新功能: {#new-features-4} - -- 添加了 `DECIMAL(digits, scale)` 数据类型 (`Decimal32(scale)`, `Decimal64(scale)`, `Decimal128(scale)`). 要启用它,请使用以下设置 `allow_experimental_decimal_type`. [\#2846](https://github.com/ClickHouse/ClickHouse/pull/2846) [\#2970](https://github.com/ClickHouse/ClickHouse/pull/2970) [\#3008](https://github.com/ClickHouse/ClickHouse/pull/3008) [\#3047](https://github.com/ClickHouse/ClickHouse/pull/3047) -- 新 `WITH ROLLUP` 修饰符 `GROUP BY` (替代语法: `GROUP BY ROLLUP(...)`). [\#2948](https://github.com/ClickHouse/ClickHouse/pull/2948) -- 在具有JOIN的查询中,星形字符将扩展为符合SQL标准的所有表中的列列表。 您可以通过设置恢复旧行为 `asterisk_left_columns_only` 在用户配置级别上为1。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2787) -- 增加了对连接表函数的支持。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2907) -- 在clickhouse-client中按Tab键进行自动完成。 [谢尔盖\*谢尔宾](https://github.com/ClickHouse/ClickHouse/pull/2447) -- Clickhouse-client中的Ctrl+C清除输入的查询。 [\#2877](https://github.com/ClickHouse/ClickHouse/pull/2877) -- 添加了 `join_default_strictness` 设置(值: `"`, `'any'`, `'all'`). 这允许您不指定 `ANY` 或 `ALL` 为 `JOIN`. [\#2982](https://github.com/ClickHouse/ClickHouse/pull/2982) -- 与查询处理相关的服务器日志的每一行都显示了查询ID。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 现在,您可以在clickhouse-client中获取查询执行日志(使用 `send_logs_level` 设置)。 通过分布式查询处理,日志从所有服务器级联。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 该 `system.query_log` 和 `system.processes` (`SHOW PROCESSLIST`)表现在有关所有更改的设置信息,当你运行一个查询(的嵌套结构 `Settings` 数据)。 添加了 `log_query_settings` 设置。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 该 `system.query_log` 和 `system.processes` 表现在显示有关参与查询执行的线程数的信息(请参阅 `thread_numbers` 列)。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 已添加 `ProfileEvents` 用于度量通过网络读取和写入磁盘以及读取和写入磁盘所花费的时间、网络错误的数量以及在网络带宽受限时所花费的等待时间。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 已添加 `ProfileEvents`包含来自rusage的系统指标的计数器(您可以使用它们获取有关用户空间和内核、页面错误和上下文切换的CPU使用率的信息),以及taskstats指标(使用它们获取有关I/O等待时间、CPU等待时间以及读取和记录的数据量的信息,无论是否包含页面缓存)。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 该 `ProfileEvents` 计数器应用于全局和每个查询,以及每个查询执行线程,它允许您按查询详细分析资源消耗情况。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 添加了 `system.query_thread_log` 表,其中包含有关每个查询执行线程的信息。 添加了 `log_query_threads` 设置。 [\#2482](https://github.com/ClickHouse/ClickHouse/pull/2482) -- 该 `system.metrics` 和 `system.events` 表现在有内置文档。 [\#3016](https://github.com/ClickHouse/ClickHouse/pull/3016) -- 添加了 `arrayEnumerateDense` 功能。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2975) -- 添加了 `arrayCumSumNonNegative` 和 `arrayDifference` 功能。 [Aleksey Studnev](https://github.com/ClickHouse/ClickHouse/pull/2942) -- 添加了 `retention` 聚合函数。 [李尚迪](https://github.com/ClickHouse/ClickHouse/pull/2887) -- 现在,您可以使用plus运算符添加(合并)聚合函数的状态,并将聚合函数的状态乘以非负常数。 [\#3062](https://github.com/ClickHouse/ClickHouse/pull/3062) [\#3034](https://github.com/ClickHouse/ClickHouse/pull/3034) -- MergeTree系列中的表现在具有虚拟列 `_partition_id`. [\#3089](https://github.com/ClickHouse/ClickHouse/pull/3089) - -#### 实验特点: {#experimental-features-1} - -- 添加了 `LowCardinality(T)` 数据类型。 此数据类型自动创建值的本地字典,并允许数据处理而无需解压字典。 [\#2830](https://github.com/ClickHouse/ClickHouse/pull/2830) -- 添加了JIT编译函数的缓存和编译前使用次数的计数器。 要JIT编译表达式,请启用 `compile_expressions` 设置。 [\#2990](https://github.com/ClickHouse/ClickHouse/pull/2990) [\#3077](https://github.com/ClickHouse/ClickHouse/pull/3077) - -#### 改进: {#improvements-4} - -- 修复了放弃副本时复制日志无限积累的问题。 为延迟较长的副本添加了有效的恢复模式。 -- 改进的性能 `GROUP BY` 当其中一个是string,其他是固定长度时,具有多个聚合字段。 -- 使用时提高性能 `PREWHERE` 并与表达式的隐式转移 `PREWHERE`. -- 改进文本格式的解析性能 (`CSV`, `TSV`). [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2977) [\#2980](https://github.com/ClickHouse/ClickHouse/pull/2980) -- 改进了读取二进制格式字符串和数组的性能。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2955) -- 提高性能和减少内存消耗的查询 `system.tables` 和 `system.columns` 当单个服务器上有非常大量的表时。 [\#2953](https://github.com/ClickHouse/ClickHouse/pull/2953) -- 修复了大量查询导致错误的情况下的性能问题( `_dl_addr` 功能是可见的 `perf top`,但服务器没有使用太多的CPU)。 [\#2938](https://github.com/ClickHouse/ClickHouse/pull/2938) -- 条件被转换到视图中(当 `enable_optimize_predicate_expression` 被启用)。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2907) -- 改进的功能 `UUID` 数据类型。 [\#3074](https://github.com/ClickHouse/ClickHouse/pull/3074) [\#2985](https://github.com/ClickHouse/ClickHouse/pull/2985) -- 该 `UUID` -Alchemist字典支持数据类型。 [\#2822](https://github.com/ClickHouse/ClickHouse/pull/2822) -- 该 `visitParamExtractRaw` 函数与嵌套结构正常工作。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2974) -- 当 `input_format_skip_unknown_fields` 启用设置,在对象字段 `JSONEachRow` 格式被正确跳过。 [BlahGeek](https://github.com/ClickHouse/ClickHouse/pull/2958) -- 对于一个 `CASE` 表达式与条件,你现在可以省略 `ELSE`,这相当于 `ELSE NULL`. [\#2920](https://github.com/ClickHouse/ClickHouse/pull/2920) -- 现在可以在使用ZooKeeper时配置操作超时。 [urykhy](https://github.com/ClickHouse/ClickHouse/pull/2971) -- 您可以指定偏移量 `LIMIT n, m` 作为 `LIMIT n OFFSET m`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- 您可以使用 `SELECT TOP n` 语法作为替代 `LIMIT`. [\#2840](https://github.com/ClickHouse/ClickHouse/pull/2840) -- 增加了队列的大小写入系统表,因此 `SystemLog parameter queue is full` 错误不经常发生。 -- 该 `windowFunnel` aggregate函数现在支持满足多个条件的事件。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2801) -- 重复的列可以用于 `USING` 条款 `JOIN`. [\#3006](https://github.com/ClickHouse/ClickHouse/pull/3006) -- `Pretty` 格式现在对列对齐宽度有限制。 使用 `output_format_pretty_max_column_pad_width` 设置。 如果一个值较宽,它仍将完整显示,但表中的其他单元格不会太宽。 [\#3003](https://github.com/ClickHouse/ClickHouse/pull/3003) -- 该 `odbc` 表函数现在允许您指定数据库/模式名称。 [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2885) -- 增加了使用在指定的用户名的能力 `clickhouse-client` 配置文件。 [弗拉基米尔\*科兹宾](https://github.com/ClickHouse/ClickHouse/pull/2909) -- 该 `ZooKeeperExceptions` 计数器已被分成三个计数器: `ZooKeeperUserExceptions`, `ZooKeeperHardwareExceptions`,和 `ZooKeeperOtherExceptions`. -- `ALTER DELETE` 查询适用于实例化视图。 -- 在定期运行清理线程时添加了随机化 `ReplicatedMergeTree` 表,以避免周期性负载尖峰时有一个非常大的数量 `ReplicatedMergeTree` 桌子 -- 支持 `ATTACH TABLE ... ON CLUSTER` 查询。 [\#3025](https://github.com/ClickHouse/ClickHouse/pull/3025) - -#### 错误修复: {#bug-fixes-13} - -- 修正了一个问题 `Dictionary` 表(抛出 `Size of offsets doesn't match size of column` 或 `Unknown compression method` 例外)。 此错误出现在版本18.10.3中。 [\#2913](https://github.com/ClickHouse/ClickHouse/issues/2913) -- 修复了合并时的错误 `CollapsingMergeTree` 如果其中一个数据部分为空(这些部分在合并或合并期间形成 `ALTER DELETE` 如果所有数据被删除),和 `vertical` 算法被用于合并。 [\#3049](https://github.com/ClickHouse/ClickHouse/pull/3049) -- 在固定的竞争条件 `DROP` 或 `TRUNCATE` 为 `Memory` 表与同时 `SELECT`,这可能导致服务器崩溃。 此错误出现在版本1.1.54388中。 [\#3038](https://github.com/ClickHouse/ClickHouse/pull/3038) -- 修正了插入时数据丢失的可能性 `Replicated` 表如果 `Session is expired` 错误返回(数据丢失可以通过检测 `ReplicatedDataLoss` 公制)。 此错误发生在版本1.1.54378。 [\#2939](https://github.com/ClickHouse/ClickHouse/pull/2939) [\#2949](https://github.com/ClickHouse/ClickHouse/pull/2949) [\#2964](https://github.com/ClickHouse/ClickHouse/pull/2964) -- 在修复段错误 `JOIN ... ON`. [\#3000](https://github.com/ClickHouse/ClickHouse/pull/3000) -- 修正了错误搜索列名时 `WHERE` 表达式完全由限定列名组成,例如 `WHERE table.column`. [\#2994](https://github.com/ClickHouse/ClickHouse/pull/2994) -- 修正了 “Not found column” 如果从远程服务器请求由IN表达式和子查询组成的单个列,则在执行分布式查询时发生错误。 [\#3087](https://github.com/ClickHouse/ClickHouse/pull/3087) -- 修正了 `Block structure mismatch in UNION stream: different number of columns` 如果其中一个分片是本地的,而另一个分片不是,则发生分布式查询的错误,并优化移动到 `PREWHERE` 被触发。 [\#2226](https://github.com/ClickHouse/ClickHouse/pull/2226) [\#3037](https://github.com/ClickHouse/ClickHouse/pull/3037) [\#3055](https://github.com/ClickHouse/ClickHouse/pull/3055) [\#3065](https://github.com/ClickHouse/ClickHouse/pull/3065) [\#3073](https://github.com/ClickHouse/ClickHouse/pull/3073) [\#3090](https://github.com/ClickHouse/ClickHouse/pull/3090) [\#3093](https://github.com/ClickHouse/ClickHouse/pull/3093) -- 修正了 `pointInPolygon` 非凸多边形的某些情况下的函数。 [\#2910](https://github.com/ClickHouse/ClickHouse/pull/2910) -- 修正了比较时不正确的结果 `nan` 与整数。 [\#3024](https://github.com/ClickHouse/ClickHouse/pull/3024) -- 修正了一个错误 `zlib-ng` 在极少数情况下可能导致segfault的库。 [\#2854](https://github.com/ClickHouse/ClickHouse/pull/2854) -- 修复了插入到表中时的内存泄漏 `AggregateFunction` 列,如果聚合函数的状态不简单(分别分配内存),并且如果单个插入请求导致多个小块。 [\#3084](https://github.com/ClickHouse/ClickHouse/pull/3084) -- 修复了创建和删除相同的竞争条件 `Buffer` 或 `MergeTree` 同时表。 -- 修复了比较由某些非平凡类型(如元组)组成的元组时出现段错误的可能性。 [\#2989](https://github.com/ClickHouse/ClickHouse/pull/2989) -- 修正了运行某些时段错误的可能性 `ON CLUSTER` 查询。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2960) -- 修正了一个错误 `arrayDistinct` 功能 `Nullable` 数组元素。 [\#2845](https://github.com/ClickHouse/ClickHouse/pull/2845) [\#2937](https://github.com/ClickHouse/ClickHouse/pull/2937) -- 该 `enable_optimize_predicate_expression` 选项现在正确支持的情况下 `SELECT *`. [张冬](https://github.com/ClickHouse/ClickHouse/pull/2929) -- 修复了重新初始化ZooKeeper会话时的段错误。 [\#2917](https://github.com/ClickHouse/ClickHouse/pull/2917) -- 与ZooKeeper工作时固定的潜在阻塞。 -- 修正了不正确的代码添加嵌套的数据结构中 `SummingMergeTree`. -- 在为聚合函数的状态分配内存时,会正确考虑对齐,这使得在实现聚合函数的状态时可以使用需要对齐的操作。 [晨兴-xc](https://github.com/ClickHouse/ClickHouse/pull/2808) - -#### 安全修复: {#security-fix} - -- 安全使用ODBC数据源。 与ODBC驱动程序的交互使用单独的 `clickhouse-odbc-bridge` 过程。 第三方ODBC驱动程序中的错误不再导致服务器稳定性问题或漏洞。 [\#2828](https://github.com/ClickHouse/ClickHouse/pull/2828) [\#2879](https://github.com/ClickHouse/ClickHouse/pull/2879) [\#2886](https://github.com/ClickHouse/ClickHouse/pull/2886) [\#2893](https://github.com/ClickHouse/ClickHouse/pull/2893) [\#2921](https://github.com/ClickHouse/ClickHouse/pull/2921) -- 修正了在文件路径的不正确的验证 `catBoostPool` 表功能。 [\#2894](https://github.com/ClickHouse/ClickHouse/pull/2894) -- 系统表的内容 (`tables`, `databases`, `parts`, `columns`, `parts_columns`, `merges`, `mutations`, `replicas`,和 `replication_queue`)根据用户对数据库的配置访问权限进行过滤 (`allow_databases`). [张冬](https://github.com/ClickHouse/ClickHouse/pull/2856) - -#### 向后不兼容的更改: {#backward-incompatible-changes-3} - -- 在具有JOIN的查询中,星形字符将扩展为符合SQL标准的所有表中的列列表。 您可以通过设置恢复旧行为 `asterisk_left_columns_only` 在用户配置级别上为1。 - -#### 构建更改: {#build-changes-2} - -- 大多数集成测试现在可以通过commit运行。 -- 代码样式检查也可以通过提交运行。 -- 该 `memcpy` 在CentOS7/Fedora上构建时,正确选择实现。 [Etienne Champetier](https://github.com/ClickHouse/ClickHouse/pull/2912) -- 当使用clang来构建时,来自一些警告 `-Weverything` 已添加,除了常规 `-Wall-Wextra -Werror`. [\#2957](https://github.com/ClickHouse/ClickHouse/pull/2957) -- 调试生成使用 `jemalloc` 调试选项。 -- 用于与ZooKeeper交互的库接口被声明为抽象。 [\#2950](https://github.com/ClickHouse/ClickHouse/pull/2950) - -## ClickHouse释放18.10 {#clickhouse-release-18-10} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-10-3-2018-08-13} - -#### 新功能: {#new-features-5} - -- HTTPS可用于复制。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) -- 新增功能 `murmurHash2_64`, `murmurHash3_32`, `murmurHash3_64`,和 `murmurHash3_128` 除了现有的 `murmurHash2_32`. [\#2791](https://github.com/ClickHouse/ClickHouse/pull/2791) -- 支持ClickHouse ODBC驱动程序中的可空类型 (`ODBCDriver2` 输出格式)。 [\#2834](https://github.com/ClickHouse/ClickHouse/pull/2834) -- 支持 `UUID` 在关键列。 - -#### 改进: {#improvements-5} - -- 当群集从配置文件中删除时,可以在不重新启动服务器的情况下删除群集。 [\#2777](https://github.com/ClickHouse/ClickHouse/pull/2777) -- 从配置文件中删除外部字典时,可以在不重新启动服务器的情况下删除它们。 [\#2779](https://github.com/ClickHouse/ClickHouse/pull/2779) -- 已添加 `SETTINGS` 支持 `Kafka` 表引擎。 [Alexander Marshalov](https://github.com/ClickHouse/ClickHouse/pull/2781) -- 改进的 `UUID` 数据类型(尚未完成)。 [\#2618](https://github.com/ClickHouse/ClickHouse/pull/2618) -- 支持合并后的空部件 `SummingMergeTree`, `CollapsingMergeTree` 和 `VersionedCollapsingMergeTree` 引擎 [\#2815](https://github.com/ClickHouse/ClickHouse/pull/2815) -- 已完成突变的旧记录将被删除 (`ALTER DELETE`). [\#2784](https://github.com/ClickHouse/ClickHouse/pull/2784) -- 添加了 `system.merge_tree_settings` 桌子 [基里尔\*什瓦科夫](https://github.com/ClickHouse/ClickHouse/pull/2841) -- 该 `system.tables` 表现在具有依赖列: `dependencies_database` 和 `dependencies_table`. [张冬](https://github.com/ClickHouse/ClickHouse/pull/2851) -- 添加了 `max_partition_size_to_drop` 配置选项。 [\#2782](https://github.com/ClickHouse/ClickHouse/pull/2782) -- 添加了 `output_format_json_escape_forward_slashes` 选项。 [Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2812) -- 添加了 `max_fetch_partition_retries_count` 设置。 [\#2831](https://github.com/ClickHouse/ClickHouse/pull/2831) -- 添加了 `prefer_localhost_replica` 用于禁用本地副本的首选项以及在不进程间交互的情况下转到本地副本的设置。 [\#2832](https://github.com/ClickHouse/ClickHouse/pull/2832) -- 该 `quantileExact` 聚合函数返回 `nan` 在聚合在一个空的情况下 `Float32` 或 `Float64` 预备 [李尚迪](https://github.com/ClickHouse/ClickHouse/pull/2855) - -#### 错误修复: {#bug-fixes-14} - -- 删除了ODBC的连接字符串参数的不必要的转义,这使得无法建立连接。 此错误发生在版本18.6.0中。 -- 修正了处理逻辑 `REPLACE PARTITION` 复制队列中的命令。 如果有两个 `REPLACE` 对于同一个分区的命令,不正确的逻辑可能会导致其中一个保留在复制队列中而无法执行。 [\#2814](https://github.com/ClickHouse/ClickHouse/pull/2814) -- 修正了一个合并错误,当所有的数据部分都是空的(从合并或从形成的部分 `ALTER DELETE` 如果所有数据都被删除)。 此错误出现在18.1.0版本。 [\#2930](https://github.com/ClickHouse/ClickHouse/pull/2930) -- 修复了并发错误 `Set` 或 `Join`. [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2823) -- 修正了 `Block structure mismatch in UNION stream: different number of columns` 发生的错误 `UNION ALL` 子查询内的查询,如果一个 `SELECT` 查询包含重复的列名。 [张冬](https://github.com/ClickHouse/ClickHouse/pull/2094) -- 修复了连接到MySQL服务器时发生异常时的内存泄漏。 -- 在查询错误的情况下修复了不正确的clickhouse客户端响应代码。 -- 修正了包含DISTINCT的实例化视图的不正确行为。 [\#2795](https://github.com/ClickHouse/ClickHouse/issues/2795) - -#### 向后不兼容的更改 {#backward-incompatible-changes-4} - -- 删除了对分布式表的检查表查询的支持。 - -#### 构建更改: {#build-changes-3} - -- 分配器已被替换: `jemalloc` 现在用来代替 `tcmalloc`. 在某些情况下,这增加了速度高达20%。 但是,有些查询已经减慢了20%。 在某些情况下,内存消耗减少了大约10%,稳定性得到了提高。 由于竞争激烈的负载,用户空间和系统中的CPU使用率略有增加。 [\#2773](https://github.com/ClickHouse/ClickHouse/pull/2773) -- 从子模块使用libressl。 [\#1983](https://github.com/ClickHouse/ClickHouse/pull/1983) [\#2807](https://github.com/ClickHouse/ClickHouse/pull/2807) -- 从子模块使用unixodbc。 [\#2789](https://github.com/ClickHouse/ClickHouse/pull/2789) -- 从子模块中使用mariadb-connector-c。 [\#2785](https://github.com/ClickHouse/ClickHouse/pull/2785) -- 将功能性测试文件添加到存储库中,这些文件取决于测试数据的可用性(暂时不包含测试数据本身)。 - -## ClickHouse释放18.6 {#clickhouse-release-18-6} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-6-0-2018-08-02} - -#### 新功能: {#new-features-6} - -- 增加了对ON表达式的支持,以便在语法上加入: - `JOIN ON Expr([table.]column ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]` - 表达式必须是由AND运算符连接的等式链。 等式的每一侧都可以是其中一个表的列上的任意表达式。 支持使用完全限定的列名 (`table.name`, `database.table.name`, `table_alias.name`, `subquery_alias.name`)对于正确的表。 [\#2742](https://github.com/ClickHouse/ClickHouse/pull/2742) -- 可以启用HTTPS进行复制。 [\#2760](https://github.com/ClickHouse/ClickHouse/pull/2760) - -#### 改进: {#improvements-6} - -- 服务器将其版本的补丁组件传递给客户端。 有关修补程序版本组件的数据位于 `system.processes` 和 `query_log`. [\#2646](https://github.com/ClickHouse/ClickHouse/pull/2646) - -## ClickHouse释放18.5 {#clickhouse-release-18-5} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-18-5-1-2018-07-31} - -#### 新功能: {#new-features-7} - -- 添加了哈希函数 `murmurHash2_32` [\#2756](https://github.com/ClickHouse/ClickHouse/pull/2756). - -#### 改进: {#improvements-7} - -- 现在你可以使用 `from_env` [\#2741](https://github.com/ClickHouse/ClickHouse/pull/2741) 从环境变量设置配置文件中的值的属性。 -- 增加了不区分大小写的版本 `coalesce`, `ifNull`,和 `nullIf functions` [\#2752](https://github.com/ClickHouse/ClickHouse/pull/2752). - -#### 错误修复: {#bug-fixes-15} - -- 修复了启动副本时可能出现的错误 [\#2759](https://github.com/ClickHouse/ClickHouse/pull/2759). - -## ClickHouse释放18.4 {#clickhouse-release-18-4} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-4-0-2018-07-28} - -#### 新功能: {#new-features-8} - -- 添加系统表: `formats`, `data_type_families`, `aggregate_function_combinators`, `table_functions`, `table_engines`, `collations` [\#2721](https://github.com/ClickHouse/ClickHouse/pull/2721). -- 增加了使用表函数代替表作为参数的能力 `remote` 或 `cluster table function` [\#2708](https://github.com/ClickHouse/ClickHouse/pull/2708). -- 支持 `HTTP Basic` 复制协议中的身份验证 [\#2727](https://github.com/ClickHouse/ClickHouse/pull/2727). -- 该 `has` 函数现在允许搜索数组中的数值 `Enum` 值 [Maxim Khrisanfov](https://github.com/ClickHouse/ClickHouse/pull/2699). -- 支持添加任意消息分隔符从读取时 `Kafka` [阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2701). - -#### 改进: {#improvements-8} - -- 该 `ALTER TABLE t DELETE WHERE` 查询不会重写未受WHERE条件影响的数据部分 [\#2694](https://github.com/ClickHouse/ClickHouse/pull/2694). -- 该 `use_minimalistic_checksums_in_zookeeper` 备选案文 `ReplicatedMergeTree` 默认情况下启用表。 此设置在版本1.1.54378,2018-04-16中添加。 不能再安装超过1.1.54378的版本。 -- 支持运行 `KILL` 和 `OPTIMIZE` 指定的查询 `ON CLUSTER` [张冬](https://github.com/ClickHouse/ClickHouse/pull/2689). - -#### 错误修复: {#bug-fixes-16} - -- 修正了错误 `Column ... is not under an aggregate function and not in GROUP BY` 用于具有IN表达式的聚合。 此错误出现在18.1.0版本。 ([bbdd780b](https://github.com/ClickHouse/ClickHouse/commit/bbdd780be0be06a0f336775941cdd536878dd2c2)) -- 修正了一个错误 `windowFunnel aggregate function` [张冬](https://github.com/ClickHouse/ClickHouse/pull/2735). -- 修正了一个错误 `anyHeavy` 聚合函数 ([a2101df2](https://github.com/ClickHouse/ClickHouse/commit/a2101df25a6a0fba99aa71f8793d762af2b801ee)) -- 使用时固定服务器崩溃 `countArray()` 聚合函数。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-5} - -- 参数 `Kafka` 发动机从改变 `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_schema, kafka_num_consumers])` 到 `Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format[, kafka_row_delimiter, kafka_schema, kafka_num_consumers])`. 如果你的表使用 `kafka_schema` 或 `kafka_num_consumers` 参数,你必须手动编辑元数据文件 `path/metadata/database/table.sql` 并添加 `kafka_row_delimiter` 参数 `''` 价值。 - -## ClickHouse释放18.1 {#clickhouse-release-18-1} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-18-1-0-2018-07-23} - -#### 新功能: {#new-features-9} - -- 支持 `ALTER TABLE t DELETE WHERE` 非复制MergeTree表的查询 ([\#2634](https://github.com/ClickHouse/ClickHouse/pull/2634)). -- 支持任意类型的 `uniq*` 聚合函数族 ([\#2010](https://github.com/ClickHouse/ClickHouse/issues/2010)). -- 支持比较运算符中的任意类型 ([\#2026](https://github.com/ClickHouse/ClickHouse/issues/2026)). -- 该 `users.xml` 文件允许设置子网掩码的格式 `10.0.0.1/255.255.255.0`. 这对于在中间使用零的IPv6网络使用掩码是必要的 ([\#2637](https://github.com/ClickHouse/ClickHouse/pull/2637)). -- 添加了 `arrayDistinct` 功能 ([\#2670](https://github.com/ClickHouse/ClickHouse/pull/2670)). -- SummingMergeTree引擎现在可以使用AggregateFunction类型列 ([康斯坦丁\*潘](https://github.com/ClickHouse/ClickHouse/pull/2566)). - -#### 改进: {#improvements-9} - -- 更改了发布版本的编号方案。 现在第一部分包含发布年份(公元,莫斯科时区,减去2000),第二部分包含主要更改的数量(大多数版本的增加),第三部分是补丁版本。 除非在更新日志中另有说明,否则版本仍然向后兼容。 -- 更快地将浮点数转换为字符串 ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2664)). -- 如果在插入过程中由于解析错误而跳过某些行(这可能与 `input_allow_errors_num` 和 `input_allow_errors_ratio` 启用设置),跳过的行数现在写入服务器日志 ([列奥纳多\*切奇](https://github.com/ClickHouse/ClickHouse/pull/2669)). - -#### 错误修复: {#bug-fixes-17} - -- 修复了临时表的截断命令 ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2624)). -- 修复了读取响应时出现网络错误时ZooKeeper客户端库中罕见的死锁 ([c315200](https://github.com/ClickHouse/ClickHouse/commit/c315200e64b87e44bdf740707fc857d1fdf7e947)). -- 修复了转换为可空类型期间的错误 ([\#1322](https://github.com/ClickHouse/ClickHouse/issues/1322)). -- 修正了不正确的结果 `maxIntersection()` 函数时间间隔的边界重合 ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2657)). -- 修复了函数参数中OR表达式链的不正确转换 ([晨兴-xc](https://github.com/ClickHouse/ClickHouse/pull/2663)). -- 修复了包含 `IN (subquery)` 另一个子查询中的表达式 ([\#2571](https://github.com/ClickHouse/ClickHouse/issues/2571)). -- 修复了分布式查询中使用不同版本的服务器之间的不兼容性 `CAST` 不是大写字母的函数 ([fe8c4d6](https://github.com/ClickHouse/ClickHouse/commit/fe8c4d64e434cacd4ceef34faa9005129f2190a5)). -- 添加了对外部数据库管理系统查询的缺少标识符引用 ([\#2635](https://github.com/ClickHouse/ClickHouse/issues/2635)). - -#### 向后不兼容的更改: {#backward-incompatible-changes-6} - -- 将包含数字零的字符串转换为DateTime不起作用。 示例: `SELECT toDateTime('0')`. 这也是原因 `DateTime DEFAULT '0'` 在表中不起作用,以及 `0` 在字典里 解决方案:替换 `0` 与 `0000-00-00 00:00:00`. - -## ClickHouse释放1.1 {#clickhouse-release-1-1} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54394-2018-07-12} - -#### 新功能: {#new-features-10} - -- 添加了 `histogram` 聚合函数 ([米哈伊尔\*苏林](https://github.com/ClickHouse/ClickHouse/pull/2521)). -- 现在 `OPTIMIZE TABLE ... FINAL` 可以在不指定分区的情况下使用 `ReplicatedMergeTree` ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2600)). - -#### 错误修复: {#bug-fixes-18} - -- 修复了在发送和下载复制数据时读取和写入套接字超时非常小的问题(一秒钟),这使得在网络或磁盘上存在负载时无法下载更大的部分(导致周期性尝试下载部分)。 此错误发生在版本1.1.54388。 -- 修复了在ZooKeeper中使用chroot时在表中插入重复数据块的问题。 -- 该 `has` 函数现在可以正常工作用于具有可为空元素的数组 ([\#2115](https://github.com/ClickHouse/ClickHouse/issues/2115)). -- 该 `system.tables` 在分布式查询中使用表现在可以正常工作。 该 `metadata_modification_time` 和 `engine_full` 列现在是非虚拟的。 修复了仅从表中查询这些列时发生的错误。 -- 固定如何空 `TinyLog` 表插入一个空数据块后工作 ([\#2563](https://github.com/ClickHouse/ClickHouse/issues/2563)). -- 该 `system.zookeeper` 如果ZooKeeper中节点的值为NULL,表就可以工作。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54390-2018-07-06} - -#### 新功能: {#new-features-11} - -- 查询可以在发送 `multipart/form-data` 格式(在 `query` 字段),如果外部数据也被发送用于查询处理,这是有用的 ([Olga Hvostikova](https://github.com/ClickHouse/ClickHouse/pull/2490)). -- 增加了在读取CSV格式数据时启用或禁用处理单引号或双引号的功能。 您可以在 `format_csv_allow_single_quotes` 和 `format_csv_allow_double_quotes` 设置 ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2574)). -- 现在 `OPTIMIZE TABLE ... FINAL` 可以在不指定非复制变体的分区的情况下使用 `MergeTree` ([阿莫斯鸟](https://github.com/ClickHouse/ClickHouse/pull/2599)). - -#### 改进: {#improvements-10} - -- 在可以使用表索引时使用IN运算符提高性能、减少内存消耗并正确跟踪内存消耗 ([\#2584](https://github.com/ClickHouse/ClickHouse/pull/2584)). -- 删除添加数据部分时校验和的冗余检查。 当存在大量副本时,这一点很重要,因为在这些情况下,检查的总数等于N^2。 -- 增加了对 `Array(Tuple(...))` 对于参数 `arrayEnumerateUniq` 功能 ([\#2573](https://github.com/ClickHouse/ClickHouse/pull/2573)). -- 已添加 `Nullable` 支持 `runningDifference` 功能 ([\#2594](https://github.com/ClickHouse/ClickHouse/pull/2594)). -- 当存在大量表达式时,改进了查询分析性能 ([\#2572](https://github.com/ClickHouse/ClickHouse/pull/2572)). -- 更快地选择用于合并的数据部分 `ReplicatedMergeTree` 桌子 更快地恢复ZooKeeper会话 ([\#2597](https://github.com/ClickHouse/ClickHouse/pull/2597)). -- 该 `format_version.txt` 文件 `MergeTree` 如果表丢失,则重新创建表,如果在没有文件的情况下复制目录结构后启动ClickHouse,这是有意义的 ([Ciprian Hacman](https://github.com/ClickHouse/ClickHouse/pull/2593)). - -#### 错误修复: {#bug-fixes-19} - -- 修复了与ZooKeeper一起工作时的错误,这可能会导致无法在重新启动服务器之前恢复表的会话和只读状态。 -- 修复了与ZooKeeper一起工作时的错误,如果会话中断,可能会导致旧节点不被删除。 -- 修正了一个错误 `quantileTDigest` Float参数的函数(此错误在版本1.1.54388中引入) ([米哈伊尔\*苏林](https://github.com/ClickHouse/ClickHouse/pull/2553)). -- 修复了MergeTree表索引中的一个错误,如果主键列位于函数内部,用于在相同大小的有符号和无符号整数之间转换类型 ([\#2603](https://github.com/ClickHouse/ClickHouse/pull/2603)). -- 如果修复段错误 `macros` 使用,但它们不在配置文件中 ([\#2570](https://github.com/ClickHouse/ClickHouse/pull/2570)). -- 修复了重新连接客户端时切换到默认数据库的问题 ([\#2583](https://github.com/ClickHouse/ClickHouse/pull/2583)). -- 修正了当发生的错误 `use_index_for_in_with_subqueries` 设置被禁用。 - -#### 安全修复: {#security-fix-1} - -- 当连接到MySQL时,发送文件不再可能 (`LOAD DATA LOCAL INFILE`). - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54388-2018-06-28} - -#### 新功能: {#new-features-12} - -- 支持 `ALTER TABLE t DELETE WHERE` 查询复制的表。 添加了 `system.mutations` 表来跟踪这种类型的查询的进度。 -- 支持 `ALTER TABLE t [REPLACE|ATTACH] PARTITION` 查询\*MergeTree表。 -- 支持 `TRUNCATE TABLE` 查询 ([张冬](https://github.com/ClickHouse/ClickHouse/pull/2260)) -- 几个新的 `SYSTEM` 复制表的查询 (`RESTART REPLICAS`, `SYNC REPLICA`, `[STOP|START] [MERGES|FETCHES|SENDS REPLICATED|REPLICATION QUEUES]`). -- 增加了使用MySQL引擎和相应的表函数写入表的能力 ([三弟](https://github.com/ClickHouse/ClickHouse/pull/2294)). -- 添加了 `url()` 表功能和 `URL` 表引擎 ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2501)). -- 添加了 `windowFunnel` 聚合函数 ([三弟](https://github.com/ClickHouse/ClickHouse/pull/2352)). -- 新 `startsWith` 和 `endsWith` 字符串的函数 ([Vadim Plakhtinsky](https://github.com/ClickHouse/ClickHouse/pull/2429)). -- 该 `numbers()` 表函数现在允许您指定偏移量 ([张冬](https://github.com/ClickHouse/ClickHouse/pull/2535)). -- 密码 `clickhouse-client` 可以交互输入。 -- 服务器日志现在可以发送到系统日志 ([Alexander Krasheninnikov](https://github.com/ClickHouse/ClickHouse/pull/2459)). -- 支持使用共享库源登录字典 ([Alexander Sapin](https://github.com/ClickHouse/ClickHouse/pull/2472)). -- 支持自定义CSV分隔符 ([伊万\*朱可夫](https://github.com/ClickHouse/ClickHouse/pull/2263)) -- 添加了 `date_time_input_format` 设置。 如果将此设置切换到 `'best_effort'`,日期时间值将以各种格式读取。 -- 添加了 `clickhouse-obfuscator` 用于数据混ob的实用程序。 用法示例:发布性能测试中使用的数据。 - -#### 实验特点: {#experimental-features-2} - -- 增加了计算能力 `and` 只有在需要的地方才能参数 ([阿纳斯塔西娅Tsarkova](https://github.com/ClickHouse/ClickHouse/pull/2272)) -- Jit编译为本机代码现在可用于某些表达式 ([pyos](https://github.com/ClickHouse/ClickHouse/pull/2277)). - -#### 错误修复: {#bug-fixes-20} - -- 对于具有以下内容的查询,不再显示重复项 `DISTINCT` 和 `ORDER BY`. -- 查询与 `ARRAY JOIN` 和 `arrayFilter` 不再返回不正确的结果。 -- 修复了从嵌套结构读取数组列时的错误 ([\#2066](https://github.com/ClickHouse/ClickHouse/issues/2066)). -- 修复了使用HAVING子句分析查询时出现的错误,如 `HAVING tuple IN (...)`. -- 修复了使用递归别名分析查询时出现的错误。 -- 修复了从REPLACINGMERGETREE读取过滤所有行的PREWHERE中的条件时出现的错误 ([\#2525](https://github.com/ClickHouse/ClickHouse/issues/2525)). -- 在HTTP界面中使用会话时,未应用用户配置文件设置。 -- 修复了如何从clickhouse-local中的命令行参数应用设置。 -- ZooKeeper客户端库现在使用从服务器接收的会话超时。 -- 修正了ZooKeeper客户端库中的一个错误,当客户端等待服务器响应时间超过超时时间。 -- 修剪部分的查询与分区键列的条件 ([\#2342](https://github.com/ClickHouse/ClickHouse/issues/2342)). -- 合并后,现在可以 `CLEAR COLUMN IN PARTITION` ([\#2315](https://github.com/ClickHouse/ClickHouse/issues/2315)). -- ODBC表函数中的类型映射已修复 ([三弟](https://github.com/ClickHouse/ClickHouse/pull/2268)). -- 类型比较已修复 `DateTime` 有和没有时区 ([Alexander Bocharov](https://github.com/ClickHouse/ClickHouse/pull/2400)). -- 修正了语法解析和格式化的 `CAST` 接线员 -- 固定插入到分布式表引擎的实例化视图中 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2411)). -- 修正了从写入数据时的争用条件 `Kafka` 引擎到实例化视图 ([刘杨宽](https://github.com/ClickHouse/ClickHouse/pull/2448)). -- 固定ssrf中的remote()表函数。 -- 固定退出行为 `clickhouse-client` 在多行模式下 ([\#2510](https://github.com/ClickHouse/ClickHouse/issues/2510)). - -#### 改进: {#improvements-11} - -- 复制表中的后台任务现在在线程池中执行,而不是在单独的线程中执行 ([Silviu Caragea](https://github.com/ClickHouse/ClickHouse/pull/1722)). -- 改进的LZ4压缩性能。 -- 更快地分析具有大量联接和子查询的查询。 -- 当有太多的网络错误时,DNS缓存现在会自动更新。 -- 如果由于其中一个实例化视图包含太多部件而无法插入表格插入,则不再发生表格插入。 -- 纠正了事件计数器中的差异 `Query`, `SelectQuery`,和 `InsertQuery`. -- 像这样的表达式 `tuple IN (SELECT tuple)` 如果元组类型匹配,则允许。 -- 即使您没有配置ZooKeeper,具有复制表的服务器也可以启动。 -- 在计算可用CPU内核数时,现在考虑了cgroups的限制 ([Atri Sharma](https://github.com/ClickHouse/ClickHouse/pull/2325)). -- 在systemd配置文件中添加了配置目录的chown ([米哈伊尔Shiryaev](https://github.com/ClickHouse/ClickHouse/pull/2421)). - -#### 构建更改: {#build-changes-4} - -- Gcc8编译器可用于构建。 -- 增加了从子模块构建llvm的能力。 -- Librdkafka库的版本已更新为v0.11.4。 -- 增加了使用系统libcpuid库的能力。 库版本已更新为0.4.0。 -- 使用vectorclass库修复了构建 ([Babacar Diassé](https://github.com/ClickHouse/ClickHouse/pull/2274)). -- Cmake现在默认情况下为ninja生成文件(如使用 `-G Ninja`). -- 添加了使用libtinfo库而不是libtermcap的功能 ([Georgy Kondratiev](https://github.com/ClickHouse/ClickHouse/pull/2519)). -- 修复了Fedora Rawhide中的头文件冲突 ([\#2520](https://github.com/ClickHouse/ClickHouse/issues/2520)). - -#### 向后不兼容的更改: {#backward-incompatible-changes-7} - -- 删除逃逸 `Vertical` 和 `Pretty*` 格式和删除 `VerticalRaw` 格式。 -- 如果在分布式查询中同时使用版本1.1.54388(或更高版本)的服务器和版本较旧的服务器,并且查询具有 `cast(x, 'Type')` 表达式没有 `AS` 关键字并没有这个词 `cast` 以大写形式,将引发一个异常,并显示如下消息 `Not found column cast(0, 'UInt8') in block`. 解决方案:更新整个群集上的服务器。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682 {#clickhouse-release-1-1-54385-2018-06-01} - -#### 错误修复: {#bug-fixes-21} - -- 修复了在某些情况下导致ZooKeeper操作阻塞的错误。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54383-2018-05-22} - -#### 错误修复: {#bug-fixes-22} - -- 修正了如果一个表有许多副本,复制队列的放缓。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54381-2018-05-14} - -#### 错误修复: {#bug-fixes-23} - -- 修复了ClickHouse与ZooKeeper服务器断开连接时,ZooKeeper中的节点泄漏问题。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54380-2018-04-21} - -#### 新功能: {#new-features-13} - -- 增加了表功能 `file(path, format, structure)`. 从读取字节的示例 `/dev/urandom`: ``` ln -s /dev/urandom /var/lib/clickhouse/user_files/random``clickhouse-client -q "SELECT * FROM file('random', 'RowBinary', 'd UInt8') LIMIT 10" ```. - -#### 改进: {#improvements-12} - -- 子查询可以包装在 `()` 括号以增强查询的可读性。 例如: `(SELECT 1) UNION ALL (SELECT 1)`. -- 简单 `SELECT` 从查询 `system.processes` 表不包括在 `max_concurrent_queries` 限制。 - -#### 错误修复: {#bug-fixes-24} - -- 修正了不正确的行为 `IN` 从中选择时的运算符 `MATERIALIZED VIEW`. -- 修正了不正确的过滤分区索引的表达式,如 `partition_key_column IN (...)`. -- 固定无法执行 `OPTIMIZE` 在以下情况下对非领导副本进行查询 `REANAME` 在桌子上进行。 -- 修复了执行时的授权错误 `OPTIMIZE` 或 `ALTER` 对非领导副本的查询。 -- 固定的冻结 `KILL QUERY`. -- 修复了ZooKeeper客户端库中的错误,这导致了手表丢失,分布式的DDL队列冻结,并在复制队列中的速度变慢,如果非空 `chroot` 前缀在ZooKeeper配置中使用。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-8} - -- 删除对如下表达式的支持 `(a, b) IN (SELECT (a, b))` (可以使用等效表达式 `(a, b) IN (SELECT a, b)`). 在以前的版本中,这些表达式导致未确定 `WHERE` 过滤或导致的错误。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54378-2018-04-16} - -#### 新功能: {#new-features-14} - -- 可以在不重新启动服务器的情况下更改日志记录级别。 -- 添加了 `SHOW CREATE DATABASE` 查询。 -- 该 `query_id` 可以传递给 `clickhouse-client` (肘部空间)。 -- 新设置: `max_network_bandwidth_for_all_users`. -- 增加了对 `ALTER TABLE ... PARTITION ...` 为 `MATERIALIZED VIEW`. -- 在系统表中以未压缩形式添加有关数据部件大小的信息。 -- 对分布式表的服务器到服务器加密支持 (`1` 在副本配置中 ``). -- 表级别的配置 `ReplicatedMergeTree` 家庭,以最大限度地减少存储在Zookeeper的数据量: : `use_minimalistic_checksums_in_zookeeper = 1` -- 的配置 `clickhouse-client` 提示。 默认情况下,服务器名称现在输出到提示符。 可以更改服务器的显示名称。 它也发送了 `X-ClickHouse-Display-Name` HTTP头(基里尔Shvakov)。 -- 多个逗号分隔 `topics` 可为指定 `Kafka` 发动机(托比亚斯\*亚当森) -- 当查询停止时 `KILL QUERY` 或 `replace_running_query`,客户端接收 `Query was canceled` 异常而不是不完整的结果。 - -#### 改进: {#improvements-13} - -- `ALTER TABLE ... DROP/DETACH PARTITION` 查询在复制队列的前面运行。 -- `SELECT ... FINAL` 和 `OPTIMIZE ... FINAL` 即使表具有单个数据部分,也可以使用。 -- A `query_log` 如果手动删除(基里尔Shvakov),则会在飞行中重新创建表格。 -- 该 `lengthUTF8` 功能运行速度更快(zhang2014)。 -- 在同步刀片的性能提高 `Distributed` 表 (`insert_distributed_sync = 1`)当有一个非常大的数量的碎片。 -- 服务器接受 `send_timeout` 和 `receive_timeout` 从客户端设置并在连接到客户端时应用它们(它们以相反的顺序应用:服务器套接字的 `send_timeout` 被设置为 `receive_timeout` 值,反之亦然)。 -- 更强大的崩溃恢复异步插入 `Distributed` 桌子 -- 的返回类型 `countEqual` 功能从更改 `UInt32` 到 `UInt64` (谢磊). - -#### 错误修复: {#bug-fixes-25} - -- 修正了一个错误 `IN` 当表达式的左侧是 `Nullable`. -- 使用元组时,现在返回正确的结果 `IN` 当某些元组组件位于表索引中时。 -- 该 `max_execution_time` limit现在可以正常使用分布式查询。 -- 在计算复合列的大小时修正错误 `system.columns` 桌子 -- 修复了创建临时表时的错误 `CREATE TEMPORARY TABLE IF NOT EXISTS.` -- 修正错误 `StorageKafka` (\#\#2075) -- 修复了某些聚合函数的无效参数导致的服务器崩溃。 -- 修正了防止错误 `DETACH DATABASE` 查询停止后台任务 `ReplicatedMergeTree` 桌子 -- `Too many parts` 插入到聚合实例化视图时,状态不太可能发生(\#\#2084)。 -- 如果替换必须在同一级别上跟随另一个替换,则更正了配置中替换的递归处理。 -- 更正了创建元数据文件时的语法 `VIEW` 这使用一个查询 `UNION ALL`. -- `SummingMergeTree` 现在可以正常使用复合键对嵌套数据结构进行求和。 -- 修复了在选择领导者时出现竞争条件的可能性 `ReplicatedMergeTree` 桌子 - -#### 构建更改: {#build-changes-5} - -- 构建支持 `ninja` 而不是 `make` 和用途 `ninja` 默认情况下,构建版本。 -- 重命名的软件包: `clickhouse-server-base` 在 `clickhouse-common-static`; `clickhouse-server-common` 在 `clickhouse-server`; `clickhouse-common-dbg` 在 `clickhouse-common-static-dbg`. 要安装,请使用 `clickhouse-server clickhouse-client`. 具有旧名称的软件包仍将加载到存储库中,以便向后兼容。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-9} - -- 如果在左侧指定了数组,则删除了IN表达式的特殊解释。 以前,表达式 `arr IN (set)` 被解释为 “at least one `arr` element belongs to the `set`”. 要在新版本中获得相同的行为,请编写 `arrayExists(x -> x IN (set), arr)`. -- 禁用套接字选项的不正确使用 `SO_REUSEPORT`,默认情况下,Poco库中未正确启用。 请注意,在Linux上,不再有任何理由同时指定地址 `::` 和 `0.0.0.0` for listen – use just `::`,它允许监听通过IPv4和IPv6的连接(使用默认的内核配置设置)。 您还可以通过指定以下命令恢复到以前版本中的行为 `1` 在配置。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54370-2018-03-16} - -#### 新功能: {#new-features-15} - -- 添加了 `system.macros` 更改配置文件时,宏的表和自动更新。 -- 添加了 `SYSTEM RELOAD CONFIG` 查询。 -- 添加了 `maxIntersections(left_col, right_col)` 聚合函数,它返回同时相交间隔的最大数目 `[left; right]`. 该 `maxIntersectionsPosition(left, right)` 函数返回的开始 “maximum” 间隔。 ([Michael Furmur](https://github.com/ClickHouse/ClickHouse/pull/2012)). - -#### 改进: {#improvements-14} - -- 当在一个插入数据 `Replicated` 表,较少的请求是由 `ZooKeeper` (和大多数用户级错误已经从消失 `ZooKeeper` 日志)。 -- 添加了为数据集创建别名的功能。 示例: `WITH (1, 2, 3) AS set SELECT number IN set FROM system.numbers LIMIT 10`. - -#### 错误修复: {#bug-fixes-26} - -- 修正了 `Illegal PREWHERE` 从合并表读取时出错 `Distributed`桌子 -- 添加了修复,允许您在仅支持IPv4的Docker容器中启动clickhouse-server。 -- 修正了从系统读取时的争用条件 `system.parts_columns tables.` -- 同步插入到一个过程中删除双缓冲 `Distributed` 表,这可能导致连接超时。 -- 修正了一个错误,导致过长的等待不可用的副本开始之前 `SELECT` 查询。 -- 在固定不正确的日期 `system.parts` 桌子 -- 修正了一个错误,使得它无法在插入数据 `Replicated` 表if `chroot` 是非空的配置 `ZooKeeper` 集群。 -- 修正了一个空的垂直合并算法 `ORDER BY` 桌子 -- 恢复了在对远程表的查询中使用字典的能力,即使这些字典不存在于请求者服务器上。 此功能在版本1.1.54362中丢失。 -- 恢复查询的行为,如 `SELECT * FROM remote('server2', default.table) WHERE col IN (SELECT col2 FROM default.table)` 当右侧的 `IN` 应该使用远程 `default.table` 而不是当地的 此行为在版本1.1.54358中被破坏。 -- 删除了无关的错误级别日志记录 `Not found column ... in block`. - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-1-1-54362-2018-03-11} - -#### 新功能: {#new-features-16} - -- 聚合不 `GROUP BY` 对于一个空集(如 `SELECT count(*) FROM table WHERE 0`)现在返回一个结果,其中一行为聚合函数带有null值,符合SQL标准。 要恢复旧行为(返回一个空结果),请设置 `empty_result_for_aggregation_by_empty_set` 到1。 -- 增加了类型转换 `UNION ALL`. 不同的别名被允许 `SELECT` 在职位 `UNION ALL`,符合SQL标准。 -- 任意表达式支持 `LIMIT BY` 条款 以前,只能使用以下内容产生的列 `SELECT`. -- 的索引 `MergeTree` 表用于以下情况 `IN` 应用于来自主键列的表达式元组。 示例: `WHERE (UserID, EventDate) IN ((123, '2000-01-01'), ...)` (Anastasiya Tsarkova) -- 添加了 `clickhouse-copier` 用于在群集之间复制和重新分布数据的工具(测试版)。 -- 添加了一致的哈希函数: `yandexConsistentHash`, `jumpConsistentHash`, `sumburConsistentHash`. 它们可以用作分片密钥,以减少后续重新分片期间的网络流量。 -- 新增功能: `arrayAny`, `arrayAll`, `hasAny`, `hasAll`, `arrayIntersect`, `arrayResize`. -- 添加了 `arrayCumSum` 功能(哈维桑塔纳)。 -- 添加了 `parseDateTimeBestEffort`, `parseDateTimeBestEffortOrZero`,和 `parseDateTimeBestEffortOrNull` 用于从包含各种可能格式的文本的字符串中读取DateTime的函数。 -- 数据可以在更新期间从外部字典部分重新加载(加载只是记录,其中指定字段的值大于先前的下载)(Arsen Hakobyan)。 -- 添加了 `cluster` 表功能。 示例: `cluster(cluster_name, db, table)`. 该 `remote` 表函数可以接受集群名称作为第一个参数,如果它被指定为标识符。 -- 该 `remote` 和 `cluster` 表函数可用于 `INSERT` 查询。 -- 添加了 `create_table_query` 和 `engine_full` 虚拟列到 `system.tables`桌子 该 `metadata_modification_time` 列是虚拟的。 -- 添加了 `data_path` 和 `metadata_path` 列 `system.tables`和`system.databases` 表,并添加了 `path` 列到 `system.parts` 和 `system.parts_columns` 桌子 -- 添加了关于合并的其他信息 `system.part_log` 桌子 -- 一个任意的分区键可以用于 `system.query_log` 表(基里尔Shvakov)。 -- 该 `SHOW TABLES` 查询现在还显示临时表。 添加临时表和 `is_temporary` 列到 `system.tables` (张2014)。 -- 已添加 `DROP TEMPORARY TABLE` 和 `EXISTS TEMPORARY TABLE` 查询(zhang2014)。 -- 支持 `SHOW CREATE TABLE` 对于临时表(zhang2014)。 -- 添加了 `system_profile` 内部进程使用的设置的配置参数。 -- 支持加载 `object_id` 作为一个属性 `MongoDB` 字典(帕维尔\*利特维年科)。 -- 阅读 `null` 作为加载数据的外部字典与时的默认值 `MongoDB` 资料来源(帕维尔\*利特维年科)。 -- 阅读 `DateTime` 在值 `Values` 从不带单引号的Unix时间戳格式化。 -- 故障转移支持 `remote` 当某些副本缺少请求的表时,表函数。 -- 运行时可以在命令行中复盖配置设置 `clickhouse-server`. 示例: `clickhouse-server -- --logger.level=information`. -- 实施了 `empty` 从功能 `FixedString` 参数:如果字符串完全由空字节组成,则函数返回1(zhang2014)。 -- 添加了 `listen_try`如果某些地址无法侦听,则在不退出的情况下侦听至少一个侦听地址的配置参数(对于禁用IPv4或IPv6支持的系统非常有用)。 -- 添加了 `VersionedCollapsingMergeTree` 表引擎。 -- 对于行和任意数字类型的支持 `library` 字典源. -- `MergeTree` 表可以在没有主键的情况下使用(您需要指定 `ORDER BY tuple()`). -- A `Nullable` 类型可以是 `CAST` 到非-`Nullable` 如果参数不是,则键入 `NULL`. -- `RENAME TABLE` 可以进行 `VIEW`. -- 添加了 `throwIf` 功能。 -- 添加了 `odbc_default_field_size` 选项,它允许您扩展从ODBC源加载的值的最大大小(默认情况下为1024)。 -- 该 `system.processes` 表和 `SHOW PROCESSLIST` 现在有 `is_cancelled` 和 `peak_memory_usage` 列。 - -#### 改进: {#improvements-15} - -- 结果的限制和配额不再应用于以下内容的中间数据 `INSERT SELECT` 查询或 `SELECT` 子查询。 -- 更少的虚假触发 `force_restore_data` 当检查的状态 `Replicated` 服务器启动时的表。 -- 添加了 `allow_distributed_ddl` 选项。 -- 表达式中不允许使用非确定性函数 `MergeTree` 表键。 -- 从替换文件 `config.d` 目录按字母顺序加载。 -- 的改进的性能 `arrayElement` 函数在常量多维数组的情况下,以空数组作为元素之一。 示例: `[[1], []][x]`. -- 当使用具有非常大的替换(例如,非常大的IP网络列表)的配置文件时,服务器现在启动速度更快。 -- 运行查询时,表值函数运行一次。 前情提要, `remote` 和 `mysql` 表值函数执行两次相同的查询以从远程服务器检索表结构。 -- 该 `MkDocs` 使用文档生成器。 -- 当您尝试删除表列时 `DEFAULT`/`MATERIALIZED` 取决于其他列的表达式,会抛出异常(zhang2014)。 -- 增加了解析文本格式的空行作为数字0的能力 `Float` 数据类型。 此功能以前可用,但在版本1.1.54342中丢失。 -- `Enum` 值可以用于 `min`, `max`, `sum` 和其他一些功能。 在这些情况下,它使用相应的数值。 此功能以前可用,但在版本1.1.54337中丢失。 -- 已添加 `max_expanded_ast_elements` 递归扩展别名后限制AST的大小。 - -#### 错误修复: {#bug-fixes-27} - -- 修复了错误地从子查询中删除不必要的列或未从包含以下内容的子查询中删除不必要列的情况 `UNION ALL`. -- 修正了合并的错误 `ReplacingMergeTree` 桌子 -- 在固定的同步插入 `Distributed` 表 (`insert_distributed_sync = 1`). -- 固定段错误的某些用途 `FULL` 和 `RIGHT JOIN` 在子查询中使用重复的列。 -- 固定段错误的某些用途 `replace_running_query` 和 `KILL QUERY`. -- 固定的顺序 `source` 和 `last_exception` 在列 `system.dictionaries` 桌子 -- 修正了一个错误,当 `DROP DATABASE` 查询没有删除带有元数据的文件。 -- 修正了 `DROP DATABASE` 查询为 `Dictionary` 数据库。 -- 固定的低精度 `uniqHLL12` 和 `uniqCombined` 功能基数大于100万个项目(Alex克斯Bocharov)。 -- 修复了在必要时计算隐式默认值,以便同时计算默认显式表达式 `INSERT` 查询(zhang2014)。 -- 修正了一个罕见的情况下,当一个查询 `MergeTree` 表不能完成(陈星-xc)。 -- 修正了运行时发生的崩溃 `CHECK` 查询为 `Distributed` 如果所有分片都是本地的(chenxing.xc)。 -- 修复了使用正则表达式的函数的轻微性能回归。 -- 修复了从复杂表达式创建多维数组时的性能回归。 -- 修正了一个错误,可能会导致一个额外的 `FORMAT` 部分出现在一个 `.sql` 具有元数据的文件。 -- 修复了导致 `max_table_size_to_drop` 尝试删除时应用的限制 `MATERIALIZED VIEW` 查看显式指定的表。 -- 修复了与旧客户端的不兼容性(旧客户端有时会发送数据 `DateTime('timezone')` 类型,他们不明白)。 -- 修复了阅读时的错误 `Nested` 使用以下方式添加的结构的列元素 `ALTER` 但是,这是空的旧分区,当这些列的条件移动到 `PREWHERE`. -- 修正了通过虚拟过滤表时的错误 `_table` 查询中的列 `Merge` 桌子 -- 修复了使用时的错误 `ALIAS` 列 `Distributed` 桌子 -- 修正了一个错误,使得动态编译不可能从聚合函数的查询 `quantile` 家人 -- 修复了查询执行管道中极少数情况下使用时发生的争用条件 `Merge` 具有大量表的表,并且当使用 `GLOBAL` 子查询。 -- 修复了将不同大小的数组传递给 `arrayReduce` 使用来自多个参数的聚合函数时的函数。 -- 禁止使用与查询 `UNION ALL` 在一个 `MATERIALIZED VIEW`. -- 修正了初始化过程中的错误 `part_log` 服务器启动时的系统表(默认情况下, `part_log` 被禁用)。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-10} - -- 删除了 `distributed_ddl_allow_replicated_alter` 选项。 默认情况下启用此行为。 -- 删除了 `strict_insert_defaults` 设置。 如果您使用此功能,请写入 `clickhouse-feedback@yandex-team.com`. -- 删除了 `UnsortedMergeTree` 引擎 - -### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102005602 {#clickhouse-release-1-1-54343-2018-02-05} - -- 在分布式DDL查询和分布式表的构造函数中添加了用于定义集群名称的宏支持: `CREATE TABLE distr ON CLUSTER '{cluster}' (...) ENGINE = Distributed('{cluster}', 'db', 'table')`. -- 现在像查询 `SELECT ... FROM table WHERE expr IN (subquery)` 使用处理 `table` 指数。 -- 在插入到复制表时改进了重复项的处理,因此它们不再减慢复制队列的执行速度。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682 {#clickhouse-release-1-1-54342-2018-01-22} - -此版本包含以前版本1.1.54337的错误修复: - -- 修正了1.1.54337中的回归:如果默认用户具有只读访问权限,则服务器拒绝启动消息 `Cannot create database in readonly mode`. -- 修正了1.1.54337中的回归:在具有systemd的系统上,无论配置如何,日志总是写入syslog;看门狗脚本仍然使用init。d。 -- 修正了1.1.54337中的回归:Docker映像中错误的默认配置。 -- 修正GraphiteMergeTree的非确定性行为(您可以在日志消息中看到它 `Data after merge is not byte-identical to the data on another replicas`). -- 修复了优化查询到复制表后可能导致合并不一致的错误(您可能会在日志消息中看到它 `Part ... intersects the previous part`). -- 当目标表中存在具体化列时,缓冲区表现在可以正常工作(by zhang2014)。 -- 修复了实现NULL的错误。 - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-1-1-54337-2018-01-18} - -#### 新功能: {#new-features-17} - -- 增加了对多维数组和元组存储的支持 (`Tuple` 表中的数据类型)。 -- 支持表函数 `DESCRIBE` 和 `INSERT` 查询。 增加了对子查询的支持 `DESCRIBE`. 例: `DESC TABLE remote('host', default.hits)`; `DESC TABLE (SELECT 1)`; `INSERT INTO TABLE FUNCTION remote('host', default.hits)`. 支持 `INSERT INTO TABLE` 除了 `INSERT INTO`. -- 改进了对时区的支持。 该 `DateTime` 数据类型可以使用用于以文本格式进行分析和格式化的时区进行注释。 示例: `DateTime('Europe/Moscow')`. 当在函数中指定时区时 `DateTime` 参数,返回类型将跟踪时区,并且值将按预期显示。 -- 新增功能 `toTimeZone`, `timeDiff`, `toQuarter`, `toRelativeQuarterNum`. 该 `toRelativeHour`/`Minute`/`Second` 函数可以采用类型的值 `Date` 作为参数。 该 `now` 函数名称区分大小写。 -- 添加了 `toStartOfFifteenMinutes` 功能(基里尔Shvakov)。 -- 添加了 `clickhouse format` 用于格式化查询的工具。 -- 添加了 `format_schema_path` configuration parameter (Marek Vavruşa). It is used for specifying a schema in `Cap'n Proto` 格式。 架构文件只能位于指定的目录中。 -- 增加了对配置替换的支持 (`incl` 和 `conf.d`)外部字典和模型的配置(帕维尔\*亚库宁)。 -- 添加了一列文档 `system.settings` 表(基里尔Shvakov)。 -- 添加了 `system.parts_columns` 表中的每个数据部分的列大小信息 `MergeTree` 桌子 -- 添加了 `system.models` 包含已加载信息的表 `CatBoost` 机器学习模型。 -- 添加了 `mysql` 和 `odbc` 表函数和对应 `MySQL` 和 `ODBC` 用于访问远程数据库的表引擎。 此功能处于测试阶段。 -- 增加了传递类型参数的可能性 `AggregateFunction` 为 `groupArray` 聚合函数(这样你就可以创建一些聚合函数的状态数组)。 -- 删除了对聚合函数组合器的各种组合的限制。 例如,您可以使用 `avgForEachIf` 以及 `avgIfForEach` 聚合函数,它们具有不同的行为。 -- 该 `-ForEach` 聚合函数combinator是针对多个参数的聚合函数的情况进行扩展的。 -- 增加了对聚合函数的支持 `Nullable` 即使是函数返回非参数的情况-`Nullable` 结果(添加Silviu Caragea的贡献)。 示例: `groupArray`, `groupUniqArray`, `topK`. -- 添加了 `max_client_network_bandwidth` 为 `clickhouse-client` (基里尔\*什瓦科夫)。 -- 用户与 `readonly = 2` setting are allowed to work with TEMPORARY tables (CREATE, DROP, INSERT…) (Kirill Shvakov). -- 增加了对使用多个消费者的支持 `Kafka` 引擎 扩展的配置选项 `Kafka` (Marek Vavruša). -- 添加了 `intExp3` 和 `intExp4` 功能。 -- 添加了 `sumKahan` 聚合函数。 -- 添加了to\*Number\*OrNull函数,其中\*Number\*是数字类型。 -- 增加了对 `WITH` a的子句 `INSERT SELECT` 查询(作者:zhang2014)。 -- 添加设置: `http_connection_timeout`, `http_send_timeout`, `http_receive_timeout`. 特别是,这些设置用于下载用于复制的数据部分。 如果网络过载,更改这些设置可以更快地进行故障转移。 -- 增加了对 `ALTER` 对于类型的表 `Null` (Anastasiya Tsarkova) -- 该 `reinterpretAsString` 函数扩展为连续存储在内存中的所有数据类型。 -- 添加了 `--silent` 选项的 `clickhouse-local` 工具 它禁止在stderr中打印查询执行信息。 -- 增加了对读取类型值的支持 `Date` 从使用单个数字而不是两个数字(Amos Bird)指定月份和/或月份日的格式的文本。 - -#### 性能优化: {#performance-optimizations} - -- 改进聚合函数的性能 `min`, `max`, `any`, `anyLast`, `anyHeavy`, `argMin`, `argMax` 从字符串参数。 -- 改进功能的性能 `isInfinite`, `isFinite`, `isNaN`, `roundToExp2`. -- 改进了解析和格式化的性能 `Date` 和 `DateTime` 以文本格式键入值。 -- 改进了解析浮点数的性能和精度。 -- 降低内存使用量 `JOIN` 在左部分和右部分具有不包含在相同名称的列的情况下 `USING` . -- 改进聚合函数的性能 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr` 通过降低计算稳定性。 旧函数的名称下可用 `varSampStable`, `varPopStable`, `stddevSampStable`, `stddevPopStable`, `covarSampStable`, `covarPopStable`, `corrStable`. - -#### 错误修复: {#bug-fixes-28} - -- 固定数据重复数据删除运行后 `DROP` 或 `DETACH PARTITION` 查询。 在以前的版本中,删除分区并再次插入相同的数据不起作用,因为插入的块被认为是重复的。 -- 修复了可能导致错误解释的错误 `WHERE` 条款 `CREATE MATERIALIZED VIEW` 查询与 `POPULATE` . -- 修正了在使用 `root_path` 在参数 `zookeeper_servers` 配置。 -- 通过固定意外的结果 `Date` 论据 `toStartOfDay` . -- 修正了 `addMonths` 和 `subtractMonths` 函数和算术 `INTERVAL n MONTH` 在情况下,当结果有前一年。 -- 增加了缺少的支持 `UUID` 数据类型 `DISTINCT` , `JOIN` ,和 `uniq` 聚合函数和外部字典(叶夫根尼伊万诺夫)。 支持 `UUID` 仍然是不完整的。 -- 固定 `SummingMergeTree` 行为的情况下,当行相加为零。 -- 各种修复 `Kafka` engine (Marek Vavruša). -- 修正了不正确的行为 `Join` 表引擎(阿莫斯鸟)。 -- 修复了FreeBSD和OS X下不正确的分配器行为。 -- 该 `extractAll` 函数现在支持空匹配。 -- 修复了阻止使用的错误 `libressl` 而不是 `openssl` . -- 修正了 `CREATE TABLE AS SELECT` 从临时表查询。 -- 修复了更新复制队列的非原子性。 这可能导致副本在服务器重新启动之前不同步。 -- 修正了可能的溢出 `gcd` , `lcm` 和 `modulo` (`%` 运营商)(Maks Skorokhod)。 -- `-preprocessed` 现在更改后创建文件 `umask` (`umask` 可以在配置中更改)。 -- 修正了部分的背景检查中的错误 (`MergeTreePartChecker` )使用自定义分区密钥时。 -- 元组的固定解析(的值 `Tuple` 数据类型)的文本格式。 -- 改进了有关传递到的不兼容类型的错误消息 `multiIf` , `array` 和其他一些功能。 -- 重新设计的支持 `Nullable` 类型。 修复了可能导致服务器崩溃的错误。 修正了与几乎所有其他错误 `NULL` 支持:insert SELECT中的类型转换不正确,HAVING和PREWHERE中对Nullable的支持不足, `join_use_nulls` 模式,可以为Null的类型作为参数 `OR` 操作员等。 -- 修正了与数据类型的内部语义相关的各种错误。 例子:不必要的总结 `Enum` 输入字段 `SummingMergeTree` ;对齐 `Enum` 类型 `Pretty` 格式等。 -- 对复合列的允许组合进行更严格的检查。 -- 修复了指定一个非常大的参数时的溢出 `FixedString` 数据类型。 -- 修正了一个错误 `topK` 一般情况下的聚合函数。 -- 在聚合函数的n元变体的参数中添加了对数组大小相等性的缺失检查。 `-Array` combinator -- 修正了一个错误 `--pager` 为 `clickhouse-client` (作者:ks1322)。 -- 固定的精度 `exp10` 功能。 -- 固定的行为 `visitParamExtract` 功能更好地符合文档。 -- 修复了指定不正确的数据类型时的崩溃。 -- 固定的行为 `DISTINCT` 在所有列都是常量的情况下。 -- 在使用的情况下固定的查询格式 `tupleElement` 使用复数常量表达式作为元组元素索引的函数。 -- 修正了一个错误 `Dictionary` 表 `range_hashed` 字典 -- 修正了导致结果中的过多行的错误 `FULL` 和 `RIGHT JOIN` (阿莫斯鸟)。 -- 修复了在创建和删除临时文件时的服务器崩溃 `config.d` 配置重新加载期间的目录。 -- 修正了 `SYSTEM DROP DNS CACHE` 查询:缓存已刷新,但群集节点的地址未更新。 -- 固定的行为 `MATERIALIZED VIEW` 执行后 `DETACH TABLE` for the table under the view (Marek Vavruša). - -#### 构建改进: {#build-improvements-4} - -- 该 `pbuilder` 工具用于构建。 构建过程几乎完全独立于构建主机环境。 -- 单个构建用于不同的操作系统版本。 软件包和二进制文件已经与各种Linux系统兼容。 -- 添加了 `clickhouse-test` 包。 它可用于运行功能测试。 -- 现在可以将源代码包发布到存储库。 它可以用来在不使用GitHub的情况下重现构建。 -- 增加了有限的集成与特拉维斯CI。 由于Travis中的构建时间限制,仅测试调试构建并运行有限的测试子集。 -- 增加了对 `Cap'n'Proto` 在默认构建中。 -- 更改文档来源的格式 `Restricted Text` 到 `Markdown`. -- 增加了对 `systemd` (弗拉基米尔\*斯米尔诺夫)。 默认情况下,由于与某些操作系统映像不兼容,它被禁用,并且可以手动启用。 -- 用于动态代码生成, `clang` 和 `lld` 嵌入到 `clickhouse` 二进制 它们也可以被调用为 `clickhouse clang` 和 `clickhouse lld` . -- 从代码中删除GNU扩展的使用。 启用 `-Wextra` 选项。 当与建设 `clang` 默认值为 `libc++` 而不是 `libstdc++`. -- 提取 `clickhouse_parsers` 和 `clickhouse_common_io` 库,以加快各种工具的构建。 - -#### 向后不兼容的更改: {#backward-incompatible-changes-11} - -- 标记的格式 `Log` 键入包含以下内容的表 `Nullable` 列以向后不兼容的方式进行了更改。 如果你有这些表,你应该将它们转换为 `TinyLog` 在启动新服务器版本之前键入。 要做到这一点,替换 `ENGINE = Log` 与 `ENGINE = TinyLog` 在相应的 `.sql` 文件中的 `metadata` 目录。 如果你的桌子没有 `Nullable` 列或表的类型不是 `Log`,那么你什么都不需要做。 -- 删除了 `experimental_allow_extended_storage_definition_syntax` 设置。 现在,此功能默认启用。 -- 该 `runningIncome` 函数重命名为 `runningDifferenceStartingWithFirstvalue` 为了避免混confusion。 -- 删除了 `FROM ARRAY JOIN arr` 在FROM with no table(Amos Bird)之后直接指定数组连接时的语法。 -- 删除了 `BlockTabSeparated` 仅用于演示目的的格式。 -- 更改聚合函数的状态格式 `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. 如果您已将这些聚合函数的状态存储在表中(使用 `AggregateFunction` 数据类型或具体化视图与相应的状态),请写信给clickhouse-feedback@yandex-team.com. -- 在以前的服务器版本中,有一个未记录的功能:如果聚合函数依赖于参数,则仍然可以在AggregateFunction数据类型中指定它而不带参数。 示例: `AggregateFunction(quantiles, UInt64)` 而不是 `AggregateFunction(quantiles(0.5, 0.9), UInt64)`. 此功能已丢失。 虽然它没有记录,但我们计划在未来的版本中再次支持它。 -- 枚举数据类型不能用于最小/最大聚合函数。 这种能力将在下一个版本中返回。 - -#### 升级时请注意: {#please-note-when-upgrading} - -- 当在群集上执行滚动更新时,当某些副本运行旧版本的ClickHouse,而某些副本运行新版本时,复制会暂时停止,并且消息 `unknown parameter 'shard'` 出现在日志中。 更新集群的所有副本后,复制将继续。 -- 如果群集服务器上运行不同版本的ClickHouse,则使用以下函数的分布式查询可能会产生不正确的结果: `varSamp`, `varPop`, `stddevSamp`, `stddevPop`, `covarSamp`, `covarPop`, `corr`. 您应该更新所有群集节点。 - -## [更新日志2017](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2017.md) {#changelog-for-2017} diff --git a/docs/zh/whats_new/changelog/2019.md b/docs/zh/whats_new/changelog/2019.md deleted file mode 100644 index f776141b14a..00000000000 --- a/docs/zh/whats_new/changelog/2019.md +++ /dev/null @@ -1,2074 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_priority: 77 -toc_title: '2019' ---- - -## 碌莽禄.拢.0755-88888888 {#clickhouse-release-v19-17} - -### ClickHouse释放v19.17.6.36,2019-12-27 {#clickhouse-release-v19-17-6-36-2019-12-27} - -#### 错误修复 {#bug-fix} - -- 在解压缩固定潜在的缓冲区溢出。 恶意用户可以传递制造的压缩数据,可能导致缓冲区后读取。 这个问题是由Yandex信息安全团队的Eldar Zaitov发现的。 [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了可能的服务器崩溃 (`std::terminate`)当服务器不能发送或写入JSON或XML格式的数据与字符串数据类型的值(需要UTF-8验证),或者当压缩结果数据与Brotli算法或在其他一些罕见的情况下。 [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从clickhouse源固定字典 `VIEW`,现在阅读这样的字典不会导致错误 `There is no query`. [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复了用户中指定的host\_regexp是否允许客户端主机的检查。xml [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241), [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- `RENAME TABLE` 对于分布式表,现在在发送到分片之前重命名包含插入数据的文件夹。 这解决了连续重命名的问题 `tableA->tableB`, `tableC->tableA`. [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) -- `range_hashed` DDL查询创建的外部字典现在允许任意数字类型的范围。 [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([阿利沙平](https://github.com/alesapin)) -- 固定 `INSERT INTO table SELECT ... FROM mysql(...)` 表功能。 [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) -- 修复段错误 `INSERT INTO TABLE FUNCTION file()` 同时插入到一个不存在的文件。 现在在这种情况下,文件将被创建,然后插入将被处理。 [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) -- 修正了聚合位图和标量位图相交时的位图和错误。 [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([黄月](https://github.com/moon03432)) -- 修复段错误时 `EXISTS` 查询没有使用 `TABLE` 或 `DICTIONARY` 预选赛,就像 `EXISTS t`. [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 函数的固定返回类型 `rand` 和 `randConstant` 在可为空的参数的情况下。 现在函数总是返回 `UInt32` 而且从来没有 `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 固定 `DROP DICTIONARY IF EXISTS db.dict`,现在它不会抛出异常,如果 `db` 根本不存在 [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 如果由于服务器崩溃而未完全删除表,服务器将尝试恢复并加载它 [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) -- 修正了一个简单的计数查询分布式表,如果有两个以上的分片本地表。 [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- 修正了导致DB::BlockStreamProfileInfo::calculateRowsBeforeLimit数据竞赛的错误() [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 固定 `ALTER table MOVE part` 在合并指定部件后立即执行,这可能导致移动指定部件合并到的部件。 现在它正确地移动指定的部分。 [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 字典的表达式现在可以指定为字符串。 这对于从非ClickHouse源中提取数据时计算属性非常有用,因为它允许对这些表达式使用非ClickHouse语法。 [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([阿利沙平](https://github.com/alesapin)) -- 修正了一个非常罕见的比赛 `clickhouse-copier` 由于ZXid的溢出。 [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([丁香飞](https://github.com/dingxiangfei2009)) -- 修复了查询失败后的错误(由于 “Too many simultaneous queries” 例如)它不会读取外部表信息,并且 - 下一个请求会将此信息解释为下一个查询的开始,导致如下错误 `Unknown packet from client`. [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) -- 避免空取消引用后 “Unknown packet X from server” [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) -- 恢复对所有ICU区域设置的支持,添加对常量表达式应用排序规则的能力,并将语言名称添加到系统。排序规则表。 [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([阿利沙平](https://github.com/alesapin)) -- 用于读取的流数 `StorageFile` 和 `StorageHDFS` 现在是有限的,以避免超过内存限制。 [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([阿利沙平](https://github.com/alesapin)) -- 固定 `CHECK TABLE` 查询为 `*MergeTree` 表没有关键. [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([阿利沙平](https://github.com/alesapin)) -- 如果没有突变,则从部件名称中删除突变编号。 这种删除提高了与旧版本的兼容性。 [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([阿利沙平](https://github.com/alesapin)) -- 修复了某些附加部分因data\_version大于表突变版本而跳过突变的问题。 [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([余志昌](https://github.com/yuzhichang)) -- 允许在将部件移动到其他设备后使用冗余副本启动服务器。 [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正了错误 “Sizes of columns doesn’t match” 使用聚合函数列时可能会出现。 [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) -- 现在在使用WITH TIES和LIMIT BY的情况下,将抛出一个异常。 现在可以使用TOP with LIMIT BY。 [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 修复字典重新加载,如果它有 `invalidate_query`,停止更新,并在以前的更新尝试一些异常。 [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([阿利沙平](https://github.com/alesapin)) - -### ClickHouse释放v19.17.4.11时,2019-11-22 {#clickhouse-release-v19-17-4-11-2019-11-22} - -#### 向后不兼容的更改 {#backward-incompatible-change} - -- 使用列而不是AST来存储标量子查询结果以获得更好的性能。 设置 `enable_scalar_subquery_optimization` 在19.17中添加,默认情况下启用。 它会导致以下错误 [这](https://github.com/ClickHouse/ClickHouse/issues/7851) 在从以前的版本升级到19.17.2或19.17.3期间。 默认情况下,19.17.4中禁用此设置,以便可以从19.16及更早版本升级而不会出现错误。 [\#7392](https://github.com/ClickHouse/ClickHouse/pull/7392) ([阿莫斯鸟](https://github.com/amosbird)) - -#### 新功能 {#new-feature} - -- 添加使用DDL查询创建字典的功能。 [\#7360](https://github.com/ClickHouse/ClickHouse/pull/7360) ([阿利沙平](https://github.com/alesapin)) -- 赂眉露\>\> `bloom_filter` 支持的索引类型 `LowCardinality` 和 `Nullable` [\#7363](https://github.com/ClickHouse/ClickHouse/issues/7363) [\#7561](https://github.com/ClickHouse/ClickHouse/pull/7561) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 添加功能 `isValidJSON` 要检查传递的字符串是否是有效的json。 [\#5910](https://github.com/ClickHouse/ClickHouse/issues/5910) [\#7293](https://github.com/ClickHouse/ClickHouse/pull/7293) ([Vdimir](https://github.com/Vdimir)) -- 执行 `arrayCompact` 功能 [\#7328](https://github.com/ClickHouse/ClickHouse/pull/7328) ([备忘录](https://github.com/Joeywzr)) -- 创建函数 `hex` 对于十进制数。 它的工作原理如下 `hex(reinterpretAsString())`,但不会删除最后的零字节。 [\#7355](https://github.com/ClickHouse/ClickHouse/pull/7355) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 添加 `arrayFill` 和 `arrayReverseFill` 函数,用数组中其他元素替换它们前面/后面的元素。 [\#7380](https://github.com/ClickHouse/ClickHouse/pull/7380) ([hcz](https://github.com/hczhcz)) -- 添加 `CRC32IEEE()`/`CRC64()` 碌莽禄support: [\#7480](https://github.com/ClickHouse/ClickHouse/pull/7480) ([Azat Khuzhin](https://github.com/azat)) -- 执行 `char` 功能类似于一个 [mysql](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) [\#7486](https://github.com/ClickHouse/ClickHouse/pull/7486) ([sundyli](https://github.com/sundy-li)) -- 添加 `bitmapTransform` 功能。 它将位图中的值数组转换为另一个值数组,结果是一个新的位图 [\#7598](https://github.com/ClickHouse/ClickHouse/pull/7598) ([余志昌](https://github.com/yuzhichang)) -- 已实施 `javaHashUTF16LE()` 功能 [\#7651](https://github.com/ClickHouse/ClickHouse/pull/7651) ([achimbab](https://github.com/achimbab)) -- 添加 `_shard_num` 分布式引擎的虚拟列 [\#7624](https://github.com/ClickHouse/ClickHouse/pull/7624) ([Azat Khuzhin](https://github.com/azat)) - -#### 实验特点 {#experimental-feature} - -- 支持处理器(新的查询执行管道) `MergeTree`. [\#7181](https://github.com/ClickHouse/ClickHouse/pull/7181) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -#### 错误修复 {#bug-fix-1} - -- 修复不正确的浮点解析 `Values` [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817) [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) -- 修复启用trace\_log时可能发生的罕见死锁。 [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([filimonov](https://github.com/filimonov)) -- 当生成Kafka表时有任何从中选择的Mv时,防止消息重复 [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([伊万](https://github.com/abyss7)) -- 支持 `Array(LowCardinality(Nullable(String)))` 在 `IN`. 决定 [\#7364](https://github.com/ClickHouse/ClickHouse/issues/7364) [\#7366](https://github.com/ClickHouse/ClickHouse/pull/7366) ([achimbab](https://github.com/achimbab)) -- 添加处理 `SQL_TINYINT` 和 `SQL_BIGINT`,并修复处理 `SQL_FLOAT` ODBC桥中的数据源类型。 [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) -- 修复聚合 (`avg` 和分位数)在空的十进制列 [\#7431](https://github.com/ClickHouse/ClickHouse/pull/7431) ([安德烈\*科尼亚耶夫](https://github.com/akonyaev90)) -- 修复 `INSERT` 变成分布式 `MATERIALIZED` 列 [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) -- 赂眉露\>\> `MOVE PARTITION` 如果分区的某些部分已经在目标磁盘或卷上,则可以工作 [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正了在突变过程中无法创建硬链接的错误 `ReplicatedMergeTree` 在多磁盘配置。 [\#7558](https://github.com/ClickHouse/ClickHouse/pull/7558) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复了当整个部分保持不变并且在另一个磁盘上找到最佳空间时,MergeTree上出现突变的错误 [\#7602](https://github.com/ClickHouse/ClickHouse/pull/7602) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正错误 `keep_free_space_ratio` 未从磁盘读取配置 [\#7645](https://github.com/ClickHouse/ClickHouse/pull/7645) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正错误与表只包含 `Tuple` 列或具有复杂路径的列。 修复 [7541](https://github.com/ClickHouse/ClickHouse/issues/7541). [\#7545](https://github.com/ClickHouse/ClickHouse/pull/7545) ([阿利沙平](https://github.com/alesapin)) -- 在max\_memory\_usage限制中不考虑缓冲区引擎的内存 [\#7552](https://github.com/ClickHouse/ClickHouse/pull/7552) ([Azat Khuzhin](https://github.com/azat)) -- 修复最终标记用法 `MergeTree` 表排序 `tuple()`. 在极少数情况下,它可能会导致 `Can't adjust last granule` 选择时出错。 [\#7639](https://github.com/ClickHouse/ClickHouse/pull/7639) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复了需要上下文操作(例如json函数)的谓词突变中的错误,这可能会导致崩溃或奇怪的异常。 [\#7664](https://github.com/ClickHouse/ClickHouse/pull/7664) ([阿利沙平](https://github.com/alesapin)) -- 修复转义的数据库和表名称不匹配 `data/` 和 `shadow/` 目录 [\#7575](https://github.com/ClickHouse/ClickHouse/pull/7575) ([Alexander Burmak](https://github.com/Alex-Burmak)) -- Support duplicated keys in RIGHT\|FULL JOINs, e.g. `ON t.x = u.x AND t.x = u.y`. 在这种情况下修复崩溃。 [\#7586](https://github.com/ClickHouse/ClickHouse/pull/7586) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复 `Not found column in block` 当加入表达式与权利或完全连接。 [\#7641](https://github.com/ClickHouse/ClickHouse/pull/7641) ([Artem Zuikov](https://github.com/4ertus2)) -- 再次尝试修复无限循环 `PrettySpace` 格式 [\#7591](https://github.com/ClickHouse/ClickHouse/pull/7591) ([Olga Khvostikova](https://github.com/stavrolia)) -- 修复bug `concat` 函数时,所有的参数 `FixedString` 同样大小的 [\#7635](https://github.com/ClickHouse/ClickHouse/pull/7635) ([阿利沙平](https://github.com/alesapin)) -- 在定义S3,URL和HDFS存储时使用1个参数的情况下修复了异常。 [\#7618](https://github.com/ClickHouse/ClickHouse/pull/7618) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复查询视图的InterpreterSelectQuery的范围 [\#7601](https://github.com/ClickHouse/ClickHouse/pull/7601) ([Azat Khuzhin](https://github.com/azat)) - -#### 改进 {#improvement} - -- `Nullable` ODBC-bridge可识别的列和正确处理的NULL值 [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 以原子方式写入分布式发送的当前批次 [\#7600](https://github.com/ClickHouse/ClickHouse/pull/7600) ([Azat Khuzhin](https://github.com/azat)) -- 如果我们无法在查询中检测到列名称的表,则引发异常。 [\#7358](https://github.com/ClickHouse/ClickHouse/pull/7358) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加 `merge_max_block_size` 设置为 `MergeTreeSettings` [\#7412](https://github.com/ClickHouse/ClickHouse/pull/7412) ([Artem Zuikov](https://github.com/4ertus2)) -- 查询与 `HAVING` 而没有 `GROUP BY` 假设按常量分组。 所以, `SELECT 1 HAVING 1` 现在返回一个结果。 [\#7496](https://github.com/ClickHouse/ClickHouse/pull/7496) ([阿莫斯鸟](https://github.com/amosbird)) -- 支持解析 `(X,)` 作为类似python的元组。 [\#7501](https://github.com/ClickHouse/ClickHouse/pull/7501), [\#7562](https://github.com/ClickHouse/ClickHouse/pull/7562) ([阿莫斯鸟](https://github.com/amosbird)) -- 赂眉露\>\> `range` 函数行为几乎像pythonic。 [\#7518](https://github.com/ClickHouse/ClickHouse/pull/7518) ([sundyli](https://github.com/sundy-li)) -- 添加 `constraints` 列到表 `system.settings` [\#7553](https://github.com/ClickHouse/ClickHouse/pull/7553) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- Tcp处理程序的更好的Null格式,以便可以使用 `select ignore() from table format Null` 通过clickhouse-client进行性能测量 [\#7606](https://github.com/ClickHouse/ClickHouse/pull/7606) ([阿莫斯鸟](https://github.com/amosbird)) -- 查询如 `CREATE TABLE ... AS (SELECT (1, 2))` 正确解析 [\#7542](https://github.com/ClickHouse/ClickHouse/pull/7542) ([hcz](https://github.com/hczhcz)) - -#### 性能改进 {#performance-improvement} - -- 改进了对短字符串键的聚合性能。 [\#6243](https://github.com/ClickHouse/ClickHouse/pull/6243) ([Alexander Kuzmenkov](https://github.com/akuzm), [阿莫斯鸟](https://github.com/amosbird)) -- 运行另一次语法/表达式分析以在常量谓词折叠后获得潜在的优化。 [\#7497](https://github.com/ClickHouse/ClickHouse/pull/7497) ([阿莫斯鸟](https://github.com/amosbird)) -- 使用存储元信息来评估琐碎 `SELECT count() FROM table;` [\#7510](https://github.com/ClickHouse/ClickHouse/pull/7510) ([阿莫斯鸟](https://github.com/amosbird), [阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 矢量化处理 `arrayReduce` 与聚合器类似 `addBatch`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([阿莫斯鸟](https://github.com/amosbird)) -- 在性能的小改进 `Kafka` 消费 [\#7475](https://github.com/ClickHouse/ClickHouse/pull/7475) ([伊万](https://github.com/abyss7)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement} - -- 添加对交叉编译的支持到CPU架构AARCH64。 重构打包器脚本。 [\#7370](https://github.com/ClickHouse/ClickHouse/pull/7370) [\#7539](https://github.com/ClickHouse/ClickHouse/pull/7539) ([伊万](https://github.com/abyss7)) -- 在构建软件包时,将darwin-x86\_64和linux-aarch64工具链解压缩到已挂载的Docker卷中 [\#7534](https://github.com/ClickHouse/ClickHouse/pull/7534) ([伊万](https://github.com/abyss7)) -- 更新二进制打包器的Docker映像 [\#7474](https://github.com/ClickHouse/ClickHouse/pull/7474) ([伊万](https://github.com/abyss7)) -- 修复了MacOS Catalina上的编译错误 [\#7585](https://github.com/ClickHouse/ClickHouse/pull/7585) ([欧内斯特\*波列塔耶夫](https://github.com/ernestp)) -- 查询分析逻辑中的一些重构:将复杂的类拆分为几个简单的类。 [\#7454](https://github.com/ClickHouse/ClickHouse/pull/7454) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复没有子模块的构建 [\#7295](https://github.com/ClickHouse/ClickHouse/pull/7295) ([proller](https://github.com/proller)) -- 更好 `add_globs` 在CMake文件中 [\#7418](https://github.com/ClickHouse/ClickHouse/pull/7418) ([阿莫斯鸟](https://github.com/amosbird)) -- 删除硬编码路径 `unwind` 目标 [\#7460](https://github.com/ClickHouse/ClickHouse/pull/7460) ([Konstantin Podshumok](https://github.com/podshumok)) -- 允许在没有ssl的情况下使用mysql格式 [\#7524](https://github.com/ClickHouse/ClickHouse/pull/7524) ([proller](https://github.com/proller)) - -#### 其他 {#other} - -- 为ClickHouse SQL方言添加了ANTLR4语法 [\#7595](https://github.com/ClickHouse/ClickHouse/issues/7595) [\#7596](https://github.com/ClickHouse/ClickHouse/pull/7596) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -## 碌莽禄.拢.0755-88888888 {#clickhouse-release-v19-16} - -#### ClickHouse版本v19.16.14.65,2020-03-25 {#clickhouse-release-v19-16-14-65-2020-03-25} - -- 修复了多个参数(超过10)的三元逻辑运算批量计算中的错误。 [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([亚历山大\*卡扎科夫](https://github.com/Akazz))这个错误修正是由Altinity的特殊要求回移到版本19.16的。 - -#### ClickHouse释放v19.16.14.65,2020-03-05 {#clickhouse-release-v19-16-14-65-2020-03-05} - -- 修复分布式子查询与旧版本的CH不兼容。 修复 [\#7851](https://github.com/ClickHouse/ClickHouse/issues/7851) - [(tabplubix)](https://github.com/tavplubix) -- 执行时 `CREATE` 查询,在存储引擎参数中折叠常量表达式。 将空数据库名称替换为当前数据库。 修复 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). 还修复检查本地地址 `ClickHouseDictionarySource`. - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) -- 现在背景合并 `*MergeTree` 表引擎家族更准确地保留存储策略卷顺序。 - [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 防止丢失数据 `Kafka` 在极少数情况下,在读取后缀之后但在提交之前发生异常。 修复 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). 相关: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(菲利蒙诺夫)](https://github.com/filimonov) -- 修复尝试使用/删除时导致服务器终止的错误 `Kafka` 使用错误的参数创建的表。 修复 [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). 结合 [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(菲利蒙诺夫)](https://github.com/filimonov) -- 允许使用 `MaterializedView` 与上面的子查询 `Kafka` 桌子 - [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([filimonov](https://github.com/filimonov)) - -#### 新功能 {#new-feature-1} - -- 添加 `deduplicate_blocks_in_dependent_materialized_views` 用于控制具有实例化视图的表中幂等插入的行为的选项。 这个新功能是由Altinity的特殊要求添加到错误修正版本中的。 - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) - -### ClickHouse发布版本v19.16.2.2,2019-10-30 {#clickhouse-release-v19-16-2-2-2019-10-30} - -#### 向后不兼容的更改 {#backward-incompatible-change-1} - -- 为count/counIf添加缺失的验证。 - [\#7095](https://github.com/ClickHouse/ClickHouse/issues/7095) - [\#7298](https://github.com/ClickHouse/ClickHouse/pull/7298) ([Vdimir](https://github.com/Vdimir)) -- 删除旧版 `asterisk_left_columns_only` 设置(默认情况下禁用)。 - [\#7335](https://github.com/ClickHouse/ClickHouse/pull/7335) ([阿尔乔姆 - Zuikov](https://github.com/4ertus2)) -- 模板数据格式的格式字符串现在在文件中指定。 - [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([tavplubix](https://github.com/tavplubix)) - -#### 新功能 {#new-feature-2} - -- 引入uniqCombined64()来计算大于UINT\_MAX的基数。 - [\#7213](https://github.com/ClickHouse/ClickHouse/pull/7213), - [\#7222](https://github.com/ClickHouse/ClickHouse/pull/7222) ([Azat - Khuzhin](https://github.com/azat)) -- 支持数组列上的Bloom filter索引。 - [\#6984](https://github.com/ClickHouse/ClickHouse/pull/6984) - ([achimbab](https://github.com/achimbab)) -- 添加函数 `getMacro(name)` 返回与相应值的字符串 `` - 从服务器配置. [\#7240](https://github.com/ClickHouse/ClickHouse/pull/7240) - ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 为基于HTTP源的字典设置两个配置选项: `credentials` 和 - `http-headers`. [\#7092](https://github.com/ClickHouse/ClickHouse/pull/7092) ([纪尧姆 - Tassery](https://github.com/YiuRULE)) -- 添加新的ProfileEvent `Merge` 这计算启动的背景合并的数量。 - [\#7093](https://github.com/ClickHouse/ClickHouse/pull/7093) ([米哈伊尔 - 科罗托夫](https://github.com/millb)) -- 添加返回完全限定域名的fullHostName函数。 - [\#7263](https://github.com/ClickHouse/ClickHouse/issues/7263) - [\#7291](https://github.com/ClickHouse/ClickHouse/pull/7291) ([sundyli](https://github.com/sundy-li)) -- 添加功能 `arraySplit` 和 `arrayReverseSplit` 通过拆分数组 “cut off” - 条件。 它们在时间序列处理中非常有用。 - [\#7294](https://github.com/ClickHouse/ClickHouse/pull/7294) ([hcz](https://github.com/hczhcz)) -- 添加返回multiMatch函数系列中所有匹配索引的数组的新函数。 - [\#7299](https://github.com/ClickHouse/ClickHouse/pull/7299) ([Danila - 库特宁](https://github.com/danlark1)) -- 添加新的数据库引擎 `Lazy` 即针对存储大量小日志进行了优化 - 桌子 [\#7171](https://github.com/ClickHouse/ClickHouse/pull/7171) ([尼基塔 - Vasilev](https://github.com/nikvas0)) -- 为位图列添加聚合函数groupBitmapAnd,-或-Xor。 [\#7109](https://github.com/ClickHouse/ClickHouse/pull/7109) ([知昌 - 阿优](https://github.com/yuzhichang)) -- 添加聚合函数组合器-OrNull和-OrDefault,它们返回null - 或默认值时没有任何聚合。 - [\#7331](https://github.com/ClickHouse/ClickHouse/pull/7331) - ([hcz](https://github.com/hczhcz)) -- 引入支持自定义转义的CustomSeparated数据格式 - 分隔符规则。 [\#7118](https://github.com/ClickHouse/ClickHouse/pull/7118) - ([tavplubix](https://github.com/tavplubix)) -- 支持Redis作为外部字典的来源。 [\#4361](https://github.com/ClickHouse/ClickHouse/pull/4361) [\#6962](https://github.com/ClickHouse/ClickHouse/pull/6962) ([comunodi](https://github.com/comunodi), [安东 - 波波夫](https://github.com/CurtizJ)) - -#### 错误修复 {#bug-fix-2} - -- 修复错误的查询结果,如果它有 `WHERE IN (SELECT ...)` 部分和 `optimize_read_in_order` 是 - 使用。 [\#7371](https://github.com/ClickHouse/ClickHouse/pull/7371) ([安东 - 波波夫](https://github.com/CurtizJ)) -- 禁用MariaDB身份验证插件,这取决于项目之外的文件。 - [\#7140](https://github.com/ClickHouse/ClickHouse/pull/7140) ([尤里 - 巴拉诺夫](https://github.com/yurriy)) -- 修复异常 `Cannot convert column ... because it is constant but values of constants are different in source and result` 这可能很少发生,当功能 `now()`, `today()`, - `yesterday()`, `randConstant()` 被使用。 - [\#7156](https://github.com/ClickHouse/ClickHouse/pull/7156) ([尼古拉 - Kochetov](https://github.com/KochetovNicolai)) -- 修复了使用HTTP保持活动超时而不是TCP保持活动超时的问题。 - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([瓦西里 - Nemkov](https://github.com/Enmk)) -- 修复了groupBitmapOr中的分段错误(问题 [\#7109](https://github.com/ClickHouse/ClickHouse/issues/7109)). - [\#7289](https://github.com/ClickHouse/ClickHouse/pull/7289) ([知昌 - 阿优](https://github.com/yuzhichang)) -- 对于实例化视图,在写入所有数据之后调用kafka的提交。 - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([伊万](https://github.com/abyss7)) -- 修复错误 `duration_ms` 值 `system.part_log` 桌子 这是十次关闭。 - [\#7172](https://github.com/ClickHouse/ClickHouse/pull/7172) ([弗拉基米尔 - Chebotarev](https://github.com/excitoon)) -- 快速修复解决实时查看表中的崩溃并重新启用所有实时查看测试。 - [\#7201](https://github.com/ClickHouse/ClickHouse/pull/7201) - ([vzakaznikov](https://github.com/vzakaznikov)) -- 在MergeTree部件的最小/最大索引中正确序列化NULL值。 - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([亚历山大 - 库兹门科夫](https://github.com/akuzm)) -- 不要把虚拟列。创建表时的sql元数据 `CREATE TABLE AS`. - [\#7183](https://github.com/ClickHouse/ClickHouse/pull/7183) ([伊万](https://github.com/abyss7)) -- 修复分段故障 `ATTACH PART` 查询。 - [\#7185](https://github.com/ClickHouse/ClickHouse/pull/7185) - ([阿利沙平](https://github.com/alesapin)) -- 修复了子查询中empty和empty优化给出的某些查询的错误结果 - INNER/RIGHT JOIN. [\#7284](https://github.com/ClickHouse/ClickHouse/pull/7284) ([尼古拉 - Kochetov](https://github.com/KochetovNicolai)) -- 修复LIVE VIEW getHeader()方法中的AddressSanitizer错误。 - [\#7271](https://github.com/ClickHouse/ClickHouse/pull/7271) - ([vzakaznikov](https://github.com/vzakaznikov)) - -#### 改进 {#improvement-1} - -- 在queue\_wait\_max\_ms等待发生的情况下添加消息。 - [\#7390](https://github.com/ClickHouse/ClickHouse/pull/7390) ([Azat - Khuzhin](https://github.com/azat)) -- 制作设置 `s3_min_upload_part_size` 表级别。 - [\#7059](https://github.com/ClickHouse/ClickHouse/pull/7059) ([弗拉基米尔 - Chebotarev](https://github.com/excitoon)) -- 检查Ttl在StorageFactory。 [\#7304](https://github.com/ClickHouse/ClickHouse/pull/7304) - ([sundyli](https://github.com/sundy-li)) -- 在部分合并连接(优化)中压缩左侧块。 - [\#7122](https://github.com/ClickHouse/ClickHouse/pull/7122) ([阿尔乔姆 - Zuikov](https://github.com/4ertus2)) -- 不允许在复制表引擎的突变中使用非确定性函数,因为这 - 可能会在副本之间引入不一致。 - [\#7247](https://github.com/ClickHouse/ClickHouse/pull/7247) ([亚历山大 - 卡扎科夫](https://github.com/Akazz)) -- 将异常堆栈跟踪转换为字符串时禁用内存跟踪器。 它可以防止损失 - 类型的错误消息 `Memory limit exceeded` 在服务器上,这导致了 `Attempt to read after eof` 客户端上的例外。 [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) - ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 其他格式改进。 决定 - [\#6033](https://github.com/ClickHouse/ClickHouse/issues/6033), - [\#2633](https://github.com/ClickHouse/ClickHouse/issues/2633), - [\#6611](https://github.com/ClickHouse/ClickHouse/issues/6611), - [\#6742](https://github.com/ClickHouse/ClickHouse/issues/6742) - [\#7215](https://github.com/ClickHouse/ClickHouse/pull/7215) - ([tavplubix](https://github.com/tavplubix)) -- ClickHouse将忽略IN运算符右侧不可转换为左侧的值 - side type. Make it work properly for compound types – Array and Tuple. - [\#7283](https://github.com/ClickHouse/ClickHouse/pull/7283) ([亚历山大 - 库兹门科夫](https://github.com/akuzm)) -- 支持ASOF加入缺失的不平等。 它可以加入小于或等于变体和严格 - 在语法上,ASOF列的变体越来越多。 - [\#7282](https://github.com/ClickHouse/ClickHouse/pull/7282) ([阿尔乔姆 - Zuikov](https://github.com/4ertus2)) -- 优化部分合并连接。 [\#7070](https://github.com/ClickHouse/ClickHouse/pull/7070) - ([Artem Zuikov](https://github.com/4ertus2)) -- 不要在uniqCombined函数中使用超过98K的内存。 - [\#7236](https://github.com/ClickHouse/ClickHouse/pull/7236), - [\#7270](https://github.com/ClickHouse/ClickHouse/pull/7270) ([Azat - Khuzhin](https://github.com/azat)) -- 在PartialMergeJoin中刷新磁盘上右连接表的部分(如果没有足够的 - 记忆)。 需要时加载数据。 [\#7186](https://github.com/ClickHouse/ClickHouse/pull/7186) - ([Artem Zuikov](https://github.com/4ertus2)) - -#### 性能改进 {#performance-improvement-1} - -- 通过避免数据重复加快使用const参数的joinGet。 - [\#7359](https://github.com/ClickHouse/ClickHouse/pull/7359) ([阿莫斯 - 鸟](https://github.com/amosbird)) -- 如果子查询为空,请提前返回。 - [\#7007](https://github.com/ClickHouse/ClickHouse/pull/7007) ([小路](https://github.com/nicelulu)) -- 优化值中SQL表达式的解析。 - [\#6781](https://github.com/ClickHouse/ClickHouse/pull/6781) - ([tavplubix](https://github.com/tavplubix)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-1} - -- 禁用交叉编译到Mac OS的一些贡献。 - [\#7101](https://github.com/ClickHouse/ClickHouse/pull/7101) ([伊万](https://github.com/abyss7)) -- 为clickhouse\_common\_io添加与PocoXML缺少的链接。 - [\#7200](https://github.com/ClickHouse/ClickHouse/pull/7200) ([Azat - Khuzhin](https://github.com/azat)) -- 在clickhouse-test中接受多个测试过滤器参数。 - [\#7226](https://github.com/ClickHouse/ClickHouse/pull/7226) ([亚历山大 - 库兹门科夫](https://github.com/akuzm)) -- 为ARM启用musl和jemalloc。 [\#7300](https://github.com/ClickHouse/ClickHouse/pull/7300) - ([阿莫斯鸟](https://github.com/amosbird)) -- 已添加 `--client-option` 参数 `clickhouse-test` 将其他参数传递给客户端。 - [\#7277](https://github.com/ClickHouse/ClickHouse/pull/7277) ([尼古拉 - Kochetov](https://github.com/KochetovNicolai)) -- 在rpm软件包升级时保留现有配置。 - [\#7103](https://github.com/ClickHouse/ClickHouse/pull/7103) - ([filimonov](https://github.com/filimonov)) -- 修复PVS检测到的错误。 [\#7153](https://github.com/ClickHouse/ClickHouse/pull/7153) ([阿尔乔姆 - Zuikov](https://github.com/4ertus2)) -- 修复达尔文的构建。 [\#7149](https://github.com/ClickHouse/ClickHouse/pull/7149) - ([伊万](https://github.com/abyss7)) -- glibc2.29兼容性. [\#7142](https://github.com/ClickHouse/ClickHouse/pull/7142) ([阿莫斯 - 鸟](https://github.com/amosbird)) -- 确保dh\_clean不会触及潜在的源文件。 - [\#7205](https://github.com/ClickHouse/ClickHouse/pull/7205) ([阿莫斯 - 鸟](https://github.com/amosbird)) -- 尝试避免从altinity rpm更新时发生冲突-它有单独打包的配置文件 - 在clickhouse服务器-常见. [\#7073](https://github.com/ClickHouse/ClickHouse/pull/7073) - ([filimonov](https://github.com/filimonov)) -- 优化一些头文件,以便更快地重建。 - [\#7212](https://github.com/ClickHouse/ClickHouse/pull/7212), - [\#7231](https://github.com/ClickHouse/ClickHouse/pull/7231) ([亚历山大 - 库兹门科夫](https://github.com/akuzm)) -- 添加日期和日期时间的性能测试。 [\#7332](https://github.com/ClickHouse/ClickHouse/pull/7332) ([瓦西里 - Nemkov](https://github.com/Enmk)) -- 修复一些包含非确定性突变的测试。 - [\#7132](https://github.com/ClickHouse/ClickHouse/pull/7132) ([亚历山大 - 卡扎科夫](https://github.com/Akazz)) -- 添加构建与MemorySanitizer CI。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) - ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 避免在MetricsTransmitter中使用未初始化的值。 - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat - Khuzhin](https://github.com/azat)) -- 修复MemorySanitizer发现的字段中的一些问题。 - [\#7135](https://github.com/ClickHouse/ClickHouse/pull/7135), - [\#7179](https://github.com/ClickHouse/ClickHouse/pull/7179) ([亚历山大 - 库兹门科夫](https://github.com/akuzm)), [\#7376](https://github.com/ClickHouse/ClickHouse/pull/7376) - ([阿莫斯鸟](https://github.com/amosbird)) -- 修复murmurhash32中未定义的行为。 [\#7388](https://github.com/ClickHouse/ClickHouse/pull/7388) ([阿莫斯 - 鸟](https://github.com/amosbird)) -- 修复StoragesInfoStream中未定义的行为。 [\#7384](https://github.com/ClickHouse/ClickHouse/pull/7384) - ([tavplubix](https://github.com/tavplubix)) -- 固定常量表达式折叠外部数据库引擎(MySQL,ODBC,JDBC)。 在上一页 - 版本它不适用于多个常量表达式,并且根本不适用于日期, - 日期时间和UUID。 这修复 [\#7245](https://github.com/ClickHouse/ClickHouse/issues/7245) - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) - ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在访问no\_users\_thread变量时修复实时查看中的ThreadSanitizer数据竞争错误。 - [\#7353](https://github.com/ClickHouse/ClickHouse/pull/7353) - ([vzakaznikov](https://github.com/vzakaznikov)) -- 在libcommon中摆脱malloc符号 - [\#7134](https://github.com/ClickHouse/ClickHouse/pull/7134), - [\#7065](https://github.com/ClickHouse/ClickHouse/pull/7065) ([阿莫斯 - 鸟](https://github.com/amosbird)) -- 添加全局标志ENABLE\_LIBRARY以禁用所有库。 - [\#7063](https://github.com/ClickHouse/ClickHouse/pull/7063) - ([proller](https://github.com/proller)) - -#### 代码清理 {#code-cleanup} - -- 概括配置存储库以准备字典的DDL。 [\#7155](https://github.com/ClickHouse/ClickHouse/pull/7155) - ([阿利沙平](https://github.com/alesapin)) -- 解析器字典DDL没有任何语义。 - [\#7209](https://github.com/ClickHouse/ClickHouse/pull/7209) - ([阿利沙平](https://github.com/alesapin)) -- 将ParserCreateQuery拆分为不同的较小的解析器。 - [\#7253](https://github.com/ClickHouse/ClickHouse/pull/7253) - ([阿利沙平](https://github.com/alesapin)) -- 在外部字典附近进行小型重构和重命名。 - [\#7111](https://github.com/ClickHouse/ClickHouse/pull/7111) - ([阿利沙平](https://github.com/alesapin)) -- 重构一些代码以准备基于角色的访问控制。 [\#7235](https://github.com/ClickHouse/ClickHouse/pull/7235) ([维塔利 - 巴拉诺夫](https://github.com/vitlibar)) -- DatabaseOrdinary代码中的一些改进。 - [\#7086](https://github.com/ClickHouse/ClickHouse/pull/7086) ([尼基塔 - Vasilev](https://github.com/nikvas0)) -- 不要在哈希表的find()和emplace()方法中使用迭代器。 - [\#7026](https://github.com/ClickHouse/ClickHouse/pull/7026) ([亚历山大 - 库兹门科夫](https://github.com/akuzm)) -- 修正getMultipleValuesFromConfig的情况下,当参数根不为空。 [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) - ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 删除一些复制粘贴(TemporaryFile和TemporaryFileStream) - [\#7166](https://github.com/ClickHouse/ClickHouse/pull/7166) ([阿尔乔姆 - Zuikov](https://github.com/4ertus2)) -- 改进了代码的可读性一点点 (`MergeTreeData::getActiveContainingPart`). - [\#7361](https://github.com/ClickHouse/ClickHouse/pull/7361) ([弗拉基米尔 - Chebotarev](https://github.com/excitoon)) -- 等待使用本地对象的所有计划作业,如果 `ThreadPool::schedule(...)` 投掷 - 一个例外 重命名 `ThreadPool::schedule(...)` 到 `ThreadPool::scheduleOrThrowOnError(...)` 和 - 修复注释,使明显的,它可能会抛出。 - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) - ([tavplubix](https://github.com/tavplubix)) - -## ClickHouse释放19.15 {#clickhouse-release-19-15} - -### ClickHouse释放19.15.4.10,2019-10-31 {#clickhouse-release-19-15-4-10-2019-10-31} - -#### 错误修复 {#bug-fix-3} - -- 增加了sql\_tinyint和SQL\_BIGINT的处理,并修复了ODBC桥中SQL\_FLOAT数据源类型的处理。 - [\#7491](https://github.com/ClickHouse/ClickHouse/pull/7491) ([Denis Glazachev](https://github.com/traceon)) -- 允许在移动分区中的目标磁盘或卷上有一些部分。 - [\#7434](https://github.com/ClickHouse/ClickHouse/pull/7434) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 通过ODBC桥固定可空列中的NULL值。 - [\#7402](https://github.com/ClickHouse/ClickHouse/pull/7402) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 固定插入到具体化列的分布式非本地节点。 - [\#7377](https://github.com/ClickHouse/ClickHouse/pull/7377) ([Azat Khuzhin](https://github.com/azat)) -- 固定函数getMultipleValuesFromConfig。 - [\#7374](https://github.com/ClickHouse/ClickHouse/pull/7374) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 修复了使用HTTP保持活动超时而不是TCP保持活动超时的问题。 - [\#7351](https://github.com/ClickHouse/ClickHouse/pull/7351) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 等待所有作业在异常时完成(修复罕见的段错误)。 - [\#7350](https://github.com/ClickHouse/ClickHouse/pull/7350) ([tavplubix](https://github.com/tavplubix)) -- 在插入Kafka表时不要推送MVs。 - [\#7265](https://github.com/ClickHouse/ClickHouse/pull/7265) ([伊万](https://github.com/abyss7)) -- 禁用异常堆栈的内存跟踪器。 - [\#7264](https://github.com/ClickHouse/ClickHouse/pull/7264) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复了外部数据库转换查询中的错误代码。 - [\#7252](https://github.com/ClickHouse/ClickHouse/pull/7252) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免在MetricsTransmitter中使用未初始化的值。 - [\#7158](https://github.com/ClickHouse/ClickHouse/pull/7158) ([Azat Khuzhin](https://github.com/azat)) -- 添加了用于测试的宏的示例配置 ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### ClickHouse释放19.15.3.6,2019-10-09 {#clickhouse-release-19-15-3-6-2019-10-09} - -#### 错误修复 {#bug-fix-4} - -- 修正了哈希字典中的bad\_variant。 - ([阿利沙平](https://github.com/alesapin)) -- 修复了附加部件查询中分段故障的错误。 - ([阿利沙平](https://github.com/alesapin)) -- 固定时间计算 `MergeTreeData`. - ([Vladimir Chebotarev](https://github.com/excitoon)) -- 写作完成后明确提交给Kafka。 - [\#7175](https://github.com/ClickHouse/ClickHouse/pull/7175) ([伊万](https://github.com/abyss7)) -- 在MergeTree部件的最小/最大索引中正确序列化NULL值。 - [\#7234](https://github.com/ClickHouse/ClickHouse/pull/7234) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-15-2-2-2019-10-01} - -#### 新功能 {#new-feature-3} - -- 分层存储:支持使用MergeTree引擎对表使用多个存储卷。 可以将新数据存储在SSD上,并自动将旧数据移动到HDD。 ([示例](https://clickhouse.github.io/clickhouse-presentations/meetup30/new_features/#12)). [\#4918](https://github.com/ClickHouse/ClickHouse/pull/4918) ([Igr](https://github.com/ObjatieGroba)) [\#6489](https://github.com/ClickHouse/ClickHouse/pull/6489) ([阿利沙平](https://github.com/alesapin)) -- 添加表函数 `input` 用于读取传入的数据 `INSERT SELECT` 查询。 [\#5450](https://github.com/ClickHouse/ClickHouse/pull/5450) ([palasonic1](https://github.com/palasonic1)) [\#6832](https://github.com/ClickHouse/ClickHouse/pull/6832) ([安东\*波波夫](https://github.com/CurtizJ)) -- 添加一个 `sparse_hashed` 字典布局,即在功能上等同于 `hashed` 布局,但更高效的内存。 它使用的内存减少了大约两倍,代价是较慢的值检索。 [\#6894](https://github.com/ClickHouse/ClickHouse/pull/6894) ([Azat Khuzhin](https://github.com/azat)) -- 实现定义用户列表以访问字典的能力。 仅使用当前连接的数据库。 [\#6907](https://github.com/ClickHouse/ClickHouse/pull/6907) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 添加 `LIMIT` 选项 `SHOW` 查询。 [\#6944](https://github.com/ClickHouse/ClickHouse/pull/6944) ([Philipp Malkovsky](https://github.com/malkfilipp)) -- 添加 `bitmapSubsetLimit(bitmap, range_start, limit)` 函数,返回最小的子集 `limit` 设置中的值不小于 `range_start`. [\#6957](https://github.com/ClickHouse/ClickHouse/pull/6957) ([余志昌](https://github.com/yuzhichang)) -- 添加 `bitmapMin` 和 `bitmapMax` 功能。 [\#6970](https://github.com/ClickHouse/ClickHouse/pull/6970) ([余志昌](https://github.com/yuzhichang)) -- 添加功能 `repeat` 有关 [问题-6648](https://github.com/ClickHouse/ClickHouse/issues/6648) [\#6999](https://github.com/ClickHouse/ClickHouse/pull/6999) ([弗林](https://github.com/ucasFL)) - -#### 实验特点 {#experimental-feature-1} - -- 实现(在内存中)不更改当前管道的合并联接变体。 结果按合并键进行部分排序。 设置 `partial_merge_join = 1` 要使用此功能。 合并联接仍在开发中。 [\#6940](https://github.com/ClickHouse/ClickHouse/pull/6940) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加 `S3` 发动机和表功能. 它仍在开发中(还没有身份验证支持)。 [\#5596](https://github.com/ClickHouse/ClickHouse/pull/5596) ([Vladimir Chebotarev](https://github.com/excitoon)) - -#### 改进 {#improvement-2} - -- 从Kafka读取的每条消息都是以原子方式插入的。 这解决了Kafka引擎的几乎所有已知问题。 [\#6950](https://github.com/ClickHouse/ClickHouse/pull/6950) ([伊万](https://github.com/abyss7)) -- 对分布式查询故障转移的改进。 缩短恢复时间,也是现在可配置的,可以看出 `system.clusters`. [\#6399](https://github.com/ClickHouse/ClickHouse/pull/6399) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 直接支持枚举的数值 `IN` 科。 \#6766 [\#6941](https://github.com/ClickHouse/ClickHouse/pull/6941) ([dimarub2000](https://github.com/dimarub2000)) -- 支持(可选,默认情况下禁用)对URL存储进行重定向。 [\#6914](https://github.com/ClickHouse/ClickHouse/pull/6914) ([maqroll](https://github.com/maqroll)) -- 当具有较旧版本的客户端连接到服务器时添加信息消息。 [\#6893](https://github.com/ClickHouse/ClickHouse/pull/6893) ([Philipp Malkovsky](https://github.com/malkfilipp)) -- 删除在分布式表中发送数据的最大退避睡眠时间限制 [\#6895](https://github.com/ClickHouse/ClickHouse/pull/6895) ([Azat Khuzhin](https://github.com/azat)) -- 添加将配置文件事件(计数器)与累积值发送到graphite的能力。 它可以在启用 `` 在服务器 `config.xml`. [\#6969](https://github.com/ClickHouse/ClickHouse/pull/6969) ([Azat Khuzhin](https://github.com/azat)) -- 添加自动转换类型 `T` 到 `LowCardinality(T)` 在类型的列中插入数据 `LowCardinality(T)` 在本机格式通过HTTP。 [\#6891](https://github.com/ClickHouse/ClickHouse/pull/6891) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 添加使用功能的能力 `hex` 不使用 `reinterpretAsString` 为 `Float32`, `Float64`. [\#7024](https://github.com/ClickHouse/ClickHouse/pull/7024) ([米哈伊尔\*科罗托夫](https://github.com/millb)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-2} - -- 将gdb-index添加到带有调试信息的clickhouse二进制文件。 这将加快启动时间 `gdb`. [\#6947](https://github.com/ClickHouse/ClickHouse/pull/6947) ([阿利沙平](https://github.com/alesapin)) -- 加速deb包装与补丁dpkg-deb它使用 `pigz`. [\#6960](https://github.com/ClickHouse/ClickHouse/pull/6960) ([阿利沙平](https://github.com/alesapin)) -- 设置 `enable_fuzzing = 1` 启用所有项目代码的libfuzzer检测功能。 [\#7042](https://github.com/ClickHouse/ClickHouse/pull/7042) ([kyprizel](https://github.com/kyprizel)) -- 在CI中添加拆分构建烟雾测试。 [\#7061](https://github.com/ClickHouse/ClickHouse/pull/7061) ([阿利沙平](https://github.com/alesapin)) -- 添加构建与MemorySanitizer CI。 [\#7066](https://github.com/ClickHouse/ClickHouse/pull/7066) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 替换 `libsparsehash` 与 `sparsehash-c11` [\#6965](https://github.com/ClickHouse/ClickHouse/pull/6965) ([Azat Khuzhin](https://github.com/azat)) - -#### 错误修复 {#bug-fix-5} - -- 修复了大型表上复杂键的索引分析的性能下降。 这修复了#6924。 [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复从Kafka空主题中选择时导致段错误的逻辑错误。 [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([伊万](https://github.com/abyss7)) -- 修复过早的MySQL连接关闭 `MySQLBlockInputStream.cpp`. [\#6882](https://github.com/ClickHouse/ClickHouse/pull/6882) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- 返回对非常旧的Linux内核的支持(修复 [\#6841](https://github.com/ClickHouse/ClickHouse/issues/6841)) [\#6853](https://github.com/ClickHouse/ClickHouse/pull/6853) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复可能的数据丢失 `insert select` 在输入流中的空块的情况下进行查询。 \#6834 \#6862 [\#6911](https://github.com/ClickHouse/ClickHouse/pull/6911) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复功能 `АrrayEnumerateUniqRanked` 在参数中使用空数组 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) -- 使用数组联接和全局子查询修复复杂的查询。 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([伊万](https://github.com/abyss7)) -- 修复 `Unknown identifier` 按顺序排列和按多个联接分组的错误 [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定 `MSan` 执行函数时发出警告 `LowCardinality` 争论。 [\#7062](https://github.com/ClickHouse/ClickHouse/pull/7062) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -#### 向后不兼容的更改 {#backward-incompatible-change-2} - -- 更改了位图\*聚合函数状态的序列化格式,以提高性能。 无法读取以前版本的位图\*的序列化状态。 [\#6908](https://github.com/ClickHouse/ClickHouse/pull/6908) ([余志昌](https://github.com/yuzhichang)) - -## ClickHouse释放19.14 {#clickhouse-release-19-14} - -### ClickHouse释放19.14.7.15,2019-10-02 {#clickhouse-release-19-14-7-15-2019-10-02} - -#### 错误修复 {#bug-fix-6} - -- 此版本还包含19.11.12.69的所有错误修复。 -- 修复了19.14和早期版本之间分布式查询的兼容性。 这修复 [\#7068](https://github.com/ClickHouse/ClickHouse/issues/7068). [\#7069](https://github.com/ClickHouse/ClickHouse/pull/7069) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### ClickHouse释放19.14.6.12,2019-09-19 {#clickhouse-release-19-14-6-12-2019-09-19} - -#### 错误修复 {#bug-fix-7} - -- 修复功能 `АrrayEnumerateUniqRanked` 在参数中使用空数组。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) -- 修复了查询中的子查询名称 `ARRAY JOIN` 和 `GLOBAL IN subquery` 用化名。 如果指定了外部表名,请使用子查询别名。 [\#6934](https://github.com/ClickHouse/ClickHouse/pull/6934) ([伊万](https://github.com/abyss7)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-3} - -- 修复 [拍打](https://clickhouse-test-reports.s3.yandex.net/6944/aab95fd5175a513413c7395a73a82044bdafb906/functional_stateless_tests_(debug).html) 测试 `00715_fetch_merged_or_mutated_part_zookeeper` 通过将其重写为shell脚本,因为它需要等待突变应用。 [\#6977](https://github.com/ClickHouse/ClickHouse/pull/6977) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 修正了UBSan和MemSan功能失败 `groupUniqArray` 使用emtpy数组参数。 这是由于放置空 `PaddedPODArray` 因为没有调用零单元格值的构造函数,所以将其转换为哈希表零单元格。 [\#6937](https://github.com/ClickHouse/ClickHouse/pull/6937) ([阿莫斯鸟](https://github.com/amosbird)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-14-3-3-2019-09-10} - -#### 新功能 {#new-feature-4} - -- `WITH FILL` 修饰符 `ORDER BY`. (继续 [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([安东\*波波夫](https://github.com/CurtizJ)) -- `WITH TIES` 修饰符 `LIMIT`. (继续 [\#5069](https://github.com/ClickHouse/ClickHouse/issues/5069)) [\#6610](https://github.com/ClickHouse/ClickHouse/pull/6610) ([安东\*波波夫](https://github.com/CurtizJ)) -- 解析无引号 `NULL` 文字为NULL(如果设置 `format_csv_unquoted_null_literal_as_null=1`). 如果此字段的数据类型不可为空,则使用默认值初始化null字段(如果设置 `input_format_null_as_default=1`). [\#5990](https://github.com/ClickHouse/ClickHouse/issues/5990) [\#6055](https://github.com/ClickHouse/ClickHouse/pull/6055) ([tavplubix](https://github.com/tavplubix)) -- 支持表函数路径中的通配符 `file` 和 `hdfs`. 如果路径包含通配符,则表将为只读。 使用示例: `select * from hdfs('hdfs://hdfs1:9000/some_dir/another_dir/*/file{0..9}{0..9}')` 和 `select * from file('some_dir/{some_file,another_file,yet_another}.tsv', 'TSV', 'value UInt32')`. [\#6092](https://github.com/ClickHouse/ClickHouse/pull/6092) ([Olga Khvostikova](https://github.com/stavrolia)) -- 新 `system.metric_log` 表存储的值 `system.events` 和 `system.metrics` 具有指定的时间间隔。 [\#6363](https://github.com/ClickHouse/ClickHouse/issues/6363) [\#6467](https://github.com/ClickHouse/ClickHouse/pull/6467) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) [\#6530](https://github.com/ClickHouse/ClickHouse/pull/6530) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 允许将ClickHouse文本日志写入 `system.text_log` 桌子 [\#6037](https://github.com/ClickHouse/ClickHouse/issues/6037) [\#6103](https://github.com/ClickHouse/ClickHouse/pull/6103) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) [\#6164](https://github.com/ClickHouse/ClickHouse/pull/6164) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在堆栈跟踪中显示私有符号(这是通过解析ELF文件的符号表来完成的)。 如果存在调试信息,则在堆栈跟踪中添加有关文件和行号的信息。 使用程序中存在的索引符号加速符号名称查找。 增加了新的SQL函数的反省: `demangle` 和 `addressToLine`. 重命名函数 `symbolizeAddress` 到 `addressToSymbol` 为了一致性。 功能 `addressToSymbol` 将返回错位的名称出于性能原因,你必须申请 `demangle`. 添加设置 `allow_introspection_functions` 默认情况下,这是关闭的。 [\#6201](https://github.com/ClickHouse/ClickHouse/pull/6201) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 表函数 `values` (名称不区分大小写)。 它允许从读取 `VALUES` 建议的名单 [\#5984](https://github.com/ClickHouse/ClickHouse/issues/5984). 示例: `SELECT * FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))`. [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) -- 增加了改变存储设置的功能。 语法: `ALTER TABLE
MODIFY SETTING = `. [\#6366](https://github.com/ClickHouse/ClickHouse/pull/6366) [\#6669](https://github.com/ClickHouse/ClickHouse/pull/6669) [\#6685](https://github.com/ClickHouse/ClickHouse/pull/6685) ([阿利沙平](https://github.com/alesapin)) -- 用于拆卸分离部件的支撑。 语法: `ALTER TABLE DROP DETACHED PART ''`. [\#6158](https://github.com/ClickHouse/ClickHouse/pull/6158) ([tavplubix](https://github.com/tavplubix)) -- 表约束。 允许将约束添加到将在插入时检查的表定义。 [\#5273](https://github.com/ClickHouse/ClickHouse/pull/5273) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) [\#6652](https://github.com/ClickHouse/ClickHouse/pull/6652) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 支持级联实例化视图。 [\#6324](https://github.com/ClickHouse/ClickHouse/pull/6324) ([阿莫斯鸟](https://github.com/amosbird)) -- 默认情况下,打开查询探查器以每秒对每个查询执行线程进行一次采样。 [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 输入格式 `ORC`. [\#6454](https://github.com/ClickHouse/ClickHouse/pull/6454) [\#6703](https://github.com/ClickHouse/ClickHouse/pull/6703) ([akonyaev90](https://github.com/akonyaev90)) -- 增加了两个新功能: `sigmoid` 和 `tanh` (这对于机器学习应用程序非常有用)。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 功能 `hasToken(haystack, token)`, `hasTokenCaseInsensitive(haystack, token)` 检查给定的令牌是否在干草堆中。 Token是两个非字母数字ASCII字符(或干草堆的边界)之间的最大长度子串。 Token必须是常量字符串。 由tokenbf\_v1索引专业化支持。 [\#6596](https://github.com/ClickHouse/ClickHouse/pull/6596), [\#6662](https://github.com/ClickHouse/ClickHouse/pull/6662) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 新功能 `neighbor(value, offset[, default_value])`. 允许在一个数据块中的列中达到上一个/下一个值。 [\#5925](https://github.com/ClickHouse/ClickHouse/pull/5925) ([Alex Krash](https://github.com/alex-krash)) [6685365ab8c5b74f9650492c88a012596eb1b0c6](https://github.com/ClickHouse/ClickHouse/commit/6685365ab8c5b74f9650492c88a012596eb1b0c6) [341e2e4587a18065c2da1ca888c73389f48ce36c](https://github.com/ClickHouse/ClickHouse/commit/341e2e4587a18065c2da1ca888c73389f48ce36c) [Alexey Milovidov](https://github.com/alexey-milovidov) -- 创建了一个函数 `currentUser()`,返回授权用户的登录。 添加别名 `user()` 对于与MySQL的兼容性。 [\#6470](https://github.com/ClickHouse/ClickHouse/pull/6470) ([Alex Krash](https://github.com/alex-krash)) -- 新的聚合函数 `quantilesExactInclusive` 和 `quantilesExactExclusive` 这是在提出 [\#5885](https://github.com/ClickHouse/ClickHouse/issues/5885). [\#6477](https://github.com/ClickHouse/ClickHouse/pull/6477) ([dimarub2000](https://github.com/dimarub2000)) -- 功能 `bitmapRange(bitmap, range_begin, range_end)` 返回具有指定范围的新集(不包括 `range_end`). [\#6314](https://github.com/ClickHouse/ClickHouse/pull/6314) ([余志昌](https://github.com/yuzhichang)) -- 功能 `geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precision)` 它创建了一系列精确的长串geohash盒复盖提供的区域。 [\#6127](https://github.com/ClickHouse/ClickHouse/pull/6127) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 实现对插入查询的支持 `Kafka` 桌子 [\#6012](https://github.com/ClickHouse/ClickHouse/pull/6012) ([伊万](https://github.com/abyss7)) -- 增加了对 `_partition` 和 `_timestamp` 虚拟列到Kafka引擎。 [\#6400](https://github.com/ClickHouse/ClickHouse/pull/6400) ([伊万](https://github.com/abyss7)) -- 可以从中删除敏感数据 `query_log`,服务器日志,基于正则表达式的规则的进程列表。 [\#5710](https://github.com/ClickHouse/ClickHouse/pull/5710) ([filimonov](https://github.com/filimonov)) - -#### 实验特点 {#experimental-feature-2} - -- 输入和输出数据格式 `Template`. 它允许为输入和输出指定自定义格式字符串。 [\#4354](https://github.com/ClickHouse/ClickHouse/issues/4354) [\#6727](https://github.com/ClickHouse/ClickHouse/pull/6727) ([tavplubix](https://github.com/tavplubix)) -- 执行 `LIVE VIEW` 最初提出的表 [\#2898](https://github.com/ClickHouse/ClickHouse/pull/2898),准备 [\#3925](https://github.com/ClickHouse/ClickHouse/issues/3925),然后更新 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541). 看 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) 详细描述。 [\#5541](https://github.com/ClickHouse/ClickHouse/issues/5541) ([vzakaznikov](https://github.com/vzakaznikov)) [\#6425](https://github.com/ClickHouse/ClickHouse/pull/6425) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) [\#6656](https://github.com/ClickHouse/ClickHouse/pull/6656) ([vzakaznikov](https://github.com/vzakaznikov))请注意 `LIVE VIEW` 功能可能会在下一个版本中删除。 - -#### 错误修复 {#bug-fix-8} - -- 此版本还包含19.13和19.11的所有错误修复。 -- 修复表有跳过索引和垂直合并发生时的分段错误。 [\#6723](https://github.com/ClickHouse/ClickHouse/pull/6723) ([阿利沙平](https://github.com/alesapin)) -- 使用非平凡的列默认值修复每列TTL。 以前在强制TTL合并的情况下 `OPTIMIZE ... FINAL` 查询,过期的值被替换为类型默认值,而不是用户指定的列默认值。 [\#6796](https://github.com/ClickHouse/ClickHouse/pull/6796) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复kafka服务器正常重启时的消息重复问题。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([伊万](https://github.com/abyss7)) -- 修正了读取Kafka消息时的无限循环。 根本不要暂停/恢复订阅消费者-否则在某些情况下可能会无限期暂停。 [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([伊万](https://github.com/abyss7)) -- 修复 `Key expression contains comparison between inconvertible types` 例外 `bitmapContains` 功能。 [\#6136](https://github.com/ClickHouse/ClickHouse/issues/6136) [\#6146](https://github.com/ClickHouse/ClickHouse/issues/6146) [\#6156](https://github.com/ClickHouse/ClickHouse/pull/6156) ([dimarub2000](https://github.com/dimarub2000)) -- 修复已启用的段错误 `optimize_skip_unused_shards` 还丢失了分片钥匙 [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复了可能导致内存损坏的突变中的错误代码。 修复了读取地址的段错误 `0x14c0` 这可能发生由于并发 `DROP TABLE` 和 `SELECT` 从 `system.parts` 或 `system.parts_columns`. 在准备突变查询时修复了竞争条件。 修复了由于 `OPTIMIZE` 复制的表和并发修改操作,如改变。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在MySQL界面中删除了额外的详细日志记录 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 返回解析布尔设置的能力 ‘true’ 和 ‘false’ 在配置文件中。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([阿利沙平](https://github.com/alesapin)) -- 修复崩溃 `quantile` 和 `median` 功能结束 `Nullable(Decimal128)`. [\#6378](https://github.com/ClickHouse/ClickHouse/pull/6378) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正了可能不完整的结果返回 `SELECT` 查询与 `WHERE` 主键上的条件包含转换为浮点类型。 它是由不正确的单调性检查引起的 `toFloat` 功能。 [\#6248](https://github.com/ClickHouse/ClickHouse/issues/6248) [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) -- 检查 `max_expanded_ast_elements` 设置为突变。 明确突变后 `TRUNCATE TABLE`. [\#6205](https://github.com/ClickHouse/ClickHouse/pull/6205) ([张冬](https://github.com/zhang2014)) -- 修复使用键列时的联接结果 `join_use_nulls`. 附加空值而不是列默认值。 [\#6249](https://github.com/ClickHouse/ClickHouse/pull/6249) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正了跳过索引与垂直合并和改变。 修复 `Bad size of marks file` 例外。 [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594) [\#6713](https://github.com/ClickHouse/ClickHouse/pull/6713) ([阿利沙平](https://github.com/alesapin)) -- 修复罕见的崩溃 `ALTER MODIFY COLUMN` 和垂直合并,当合并/改变的部分之一是空的(0行) [\#6746](https://github.com/ClickHouse/ClickHouse/issues/6746) [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([阿利沙平](https://github.com/alesapin)) -- 修正错误的转换 `LowCardinality` 类型 `AggregateFunctionFactory`. 这修复 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复错误的行为和可能的段错误 `topK` 和 `topKWeighted` 聚合函数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([安东\*波波夫](https://github.com/CurtizJ)) -- 固定周围的不安全代码 `getIdentifier` 功能。 [\#6401](https://github.com/ClickHouse/ClickHouse/issues/6401) [\#6409](https://github.com/ClickHouse/ClickHouse/pull/6409) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在MySQL线协议(连接到ClickHouse的形式MySQL客户端时使用)修正了错误。 引起的堆缓冲区溢出 `PacketPayloadWriteBuffer`. [\#6212](https://github.com/ClickHouse/ClickHouse/pull/6212) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 固定内存泄漏 `bitmapSubsetInRange` 功能。 [\#6819](https://github.com/ClickHouse/ClickHouse/pull/6819) ([余志昌](https://github.com/yuzhichang)) -- 修复粒度变化后执行突变时的罕见错误。 [\#6816](https://github.com/ClickHouse/ClickHouse/pull/6816) ([阿利沙平](https://github.com/alesapin)) -- 默认情况下允许包含所有字段的protobuf消息。 [\#6132](https://github.com/ClickHouse/ClickHouse/pull/6132) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 解决错误 `nullIf` 功能,当我们发送 `NULL` 第二个参数的参数。 [\#6446](https://github.com/ClickHouse/ClickHouse/pull/6446) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 修正了错误的内存分配/解除分配在复杂的键高速缓存字典与字符串字段,导致无限的内存消耗罕见的错误(看起来像内存泄漏)。 当字符串大小为8(8,16,32等)开始的2的幂时,错误会重现。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([阿利沙平](https://github.com/alesapin)) -- 修复了导致异常的小序列上的大猩猩编码 `Cannot write after end of buffer`. [\#6398](https://github.com/ClickHouse/ClickHouse/issues/6398) [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 允许在连接中使用不可为空的类型 `join_use_nulls` 已启用。 [\#6705](https://github.com/ClickHouse/ClickHouse/pull/6705) ([Artem Zuikov](https://github.com/4ertus2)) -- 禁用 `Poco::AbstractConfiguration` 查询中的替换 `clickhouse-client`. [\#6706](https://github.com/ClickHouse/ClickHouse/pull/6706) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免死锁 `REPLACE PARTITION`. [\#6677](https://github.com/ClickHouse/ClickHouse/pull/6677) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用 `arrayReduce` 对于不变的参数可能会导致段错误。 [\#6242](https://github.com/ClickHouse/ClickHouse/issues/6242) [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复可能出现的不一致的部分,如果副本恢复后 `DROP PARTITION`. [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- 固定挂起 `JSONExtractRaw` 功能。 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误跳过索引序列化和聚合与自适应粒度。 [\#6594](https://github.com/ClickHouse/ClickHouse/issues/6594). [\#6748](https://github.com/ClickHouse/ClickHouse/pull/6748) ([阿利沙平](https://github.com/alesapin)) -- 修复 `WITH ROLLUP` 和 `WITH CUBE` 修饰符 `GROUP BY` 具有两级聚合。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复编写具有自适应粒度的二级索引标记的错误。 [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([阿利沙平](https://github.com/alesapin)) -- 修复服务器启动时的初始化顺序。 由于 `StorageMergeTree::background_task_handle` 在初始化 `startup()` 该 `MergeTreeBlockOutputStream::write()` 可以尝试在初始化之前使用它。 只需检查它是否被初始化。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([伊万](https://github.com/abyss7)) -- 从以前的读取操作中清除数据缓冲区,该操作完成时出现错误。 [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([尼古拉](https://github.com/bopohaa)) -- 修复为复制\*MergeTree表创建新副本时启用自适应粒度的错误。 [\#6394](https://github.com/ClickHouse/ClickHouse/issues/6394) [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([阿利沙平](https://github.com/alesapin)) -- 修复了在服务器启动过程中发生异常的情况下可能发生的崩溃 `libunwind` 在异常访问未初始化 `ThreadStatus` 结构。 [\#6456](https://github.com/ClickHouse/ClickHouse/pull/6456) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 修复崩溃 `yandexConsistentHash` 功能。 通过模糊测试发现。 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304) [\#6305](https://github.com/ClickHouse/ClickHouse/pull/6305) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了服务器过载和全局线程池接近满时挂起查询的可能性。 这在具有大量分片(数百个)的集群上发生的机会更高,因为分布式查询为每个分片分配每个连接的线程。 例如,如果集群330分片正在处理30个并发分布式查询,则此问题可能再现。 此问题会影响从19.2开始的所有版本。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 的固定逻辑 `arrayEnumerateUniqRanked` 功能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 解码符号表时修复段错误。 [\#6603](https://github.com/ClickHouse/ClickHouse/pull/6603) ([阿莫斯鸟](https://github.com/amosbird)) -- 在固定不相关的异常转换 `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 删除描述中的额外引用 `system.settings` 桌子 [\#6696](https://github.com/ClickHouse/ClickHouse/issues/6696) [\#6699](https://github.com/ClickHouse/ClickHouse/pull/6699) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免可能的死锁 `TRUNCATE` 复制的表。 [\#6695](https://github.com/ClickHouse/ClickHouse/pull/6695) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复读取排序键的顺序。 [\#6189](https://github.com/ClickHouse/ClickHouse/pull/6189) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复 `ALTER TABLE ... UPDATE` 查询表 `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([阿利沙平](https://github.com/alesapin)) -- 修复错误打开 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) (自19.4.0)。 当我们不查询任何列时,在对MergeTree表的分布式表的查询中复制 (`SELECT 1`). [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([阿利沙平](https://github.com/alesapin)) -- 在有符号类型的整数划分为无符号类型的固定溢出。 这种行为与C或C++语言(整数升级规则)完全相同,这可能令人惊讶。 请注意,当将大型有符号数字划分为大型无符号数字或反之亦然时,溢出仍然是可能的(但这种情况不太常见)。 所有服务器版本都存在此问题。 [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214) [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 限制最大睡眠时间限制时 `max_execution_speed` 或 `max_execution_speed_bytes` 已设置。 修正错误,如 `Estimated query execution time (inf seconds) is too long`. [\#5547](https://github.com/ClickHouse/ClickHouse/issues/5547) [\#6232](https://github.com/ClickHouse/ClickHouse/pull/6232) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 关于使用固定的问题 `MATERIALIZED` 列和别名 `MaterializedView`. [\#448](https://github.com/ClickHouse/ClickHouse/issues/448) [\#3484](https://github.com/ClickHouse/ClickHouse/issues/3484) [\#3450](https://github.com/ClickHouse/ClickHouse/issues/3450) [\#2878](https://github.com/ClickHouse/ClickHouse/issues/2878) [\#2285](https://github.com/ClickHouse/ClickHouse/issues/2285) [\#3796](https://github.com/ClickHouse/ClickHouse/pull/3796) ([阿莫斯鸟](https://github.com/amosbird)) [\#6316](https://github.com/ClickHouse/ClickHouse/pull/6316) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `FormatFactory` 未实现为处理器的输入流的行为。 [\#6495](https://github.com/ClickHouse/ClickHouse/pull/6495) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 固定错字。 [\#6631](https://github.com/ClickHouse/ClickHouse/pull/6631) ([Alex Ryndin](https://github.com/alexryndin)) -- 错字在错误消息(是-\>是)。 [\#6839](https://github.com/ClickHouse/ClickHouse/pull/6839) ([Denis Zhuravlev](https://github.com/den-crane)) -- 修复了从字符串中解析列列表时的错误,如果类型包含逗号(这个问题与 `File`, `URL`, `HDFS` 储存) [\#6217](https://github.com/ClickHouse/ClickHouse/issues/6217). [\#6209](https://github.com/ClickHouse/ClickHouse/pull/6209) ([dimarub2000](https://github.com/dimarub2000)) - -#### 安全修复 {#security-fix} - -- 此版本还包含19.13和19.11的所有错误安全修复。 -- 修复了由于SQL解析器中的堆栈溢出而导致服务器崩溃的制造查询的可能性。 修复了合并和分布式表,实例化视图和涉及子查询的行级安全性条件中堆栈溢出的可能性。 [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 改进 {#improvement-3} - -- 三元逻辑的正确实现 `AND/OR`. [\#6048](https://github.com/ClickHouse/ClickHouse/pull/6048) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 现在,值和行与过期的TTL将被删除后 `OPTIMIZE ... FINAL` query from old parts without TTL infos or with outdated TTL infos, e.g. after `ALTER ... MODIFY TTL` 查询。 添加查询 `SYSTEM STOP/START TTL MERGES` 要禁止/允许使用TTL分配合并,并在所有合并中过滤过期值。 [\#6274](https://github.com/ClickHouse/ClickHouse/pull/6274) ([安东\*波波夫](https://github.com/CurtizJ)) -- 可以更改ClickHouse历史文件的位置为客户端使用 `CLICKHOUSE_HISTORY_FILE` env [\#6840](https://github.com/ClickHouse/ClickHouse/pull/6840) ([filimonov](https://github.com/filimonov)) -- 删除 `dry_run` 从标志 `InterpreterSelectQuery`. … [\#6375](https://github.com/ClickHouse/ClickHouse/pull/6375) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 碌莽禄Support: `ASOF JOIN` 与 `ON` 科。 [\#6211](https://github.com/ClickHouse/ClickHouse/pull/6211) ([Artem Zuikov](https://github.com/4ertus2)) -- 更好地支持用于突变和复制的跳过索引。 支持 `MATERIALIZE/CLEAR INDEX ... IN PARTITION` 查询。 `UPDATE x = x` 重新计算使用列的所有索引 `x`. [\#5053](https://github.com/ClickHouse/ClickHouse/pull/5053) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 允许 `ATTACH` 实时视图(例如,在服务器启动时),无论 `allow_experimental_live_view` 设置。 [\#6754](https://github.com/ClickHouse/ClickHouse/pull/6754) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 对于由查询探查器收集的堆栈跟踪,不包括由查询探查器本身生成的堆栈帧。 [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在表函数 `values`, `file`, `url`, `hdfs` 支持别名列。 [\#6255](https://github.com/ClickHouse/ClickHouse/pull/6255) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 如果抛出异常 `config.d` 文件没有相应的根元素作为配置文件。 [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) -- 在异常消息中打印额外的信息 `no space left on device`. [\#6182](https://github.com/ClickHouse/ClickHouse/issues/6182), [\#6252](https://github.com/ClickHouse/ClickHouse/issues/6252) [\#6352](https://github.com/ClickHouse/ClickHouse/pull/6352) ([tavplubix](https://github.com/tavplubix)) -- 当确定一个碎片 `Distributed` 要被读取查询复盖的表(用于 `optimize_skip_unused_shards` =1)ClickHouse现在从两个检查条件 `prewhere` 和 `where` select语句的子句。 [\#6521](https://github.com/ClickHouse/ClickHouse/pull/6521) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 已启用 `SIMDJSON` 对于没有AVX2,但与SSE4.2和PCLMUL指令集的机器。 [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285) [\#6320](https://github.com/ClickHouse/ClickHouse/pull/6320) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- ClickHouse可以在文件系统上工作,而无需 `O_DIRECT` 支持(如ZFS和BtrFS),无需额外的调整。 [\#4449](https://github.com/ClickHouse/ClickHouse/issues/4449) [\#6730](https://github.com/ClickHouse/ClickHouse/pull/6730) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 支持最终子查询的下推谓词。 [\#6120](https://github.com/ClickHouse/ClickHouse/pull/6120) ([TCeason](https://github.com/TCeason)) [\#6162](https://github.com/ClickHouse/ClickHouse/pull/6162) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更好 `JOIN ON` 密钥提取 [\#6131](https://github.com/ClickHouse/ClickHouse/pull/6131) ([Artem Zuikov](https://github.com/4ertus2)) -- Upated `SIMDJSON`. [\#6285](https://github.com/ClickHouse/ClickHouse/issues/6285). [\#6306](https://github.com/ClickHouse/ClickHouse/pull/6306) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 优化最小列的选择 `SELECT count()` 查询。 [\#6344](https://github.com/ClickHouse/ClickHouse/pull/6344) ([阿莫斯鸟](https://github.com/amosbird)) -- 已添加 `strict` 参数in `windowFunnel()`. 当 `strict` 设置,该 `windowFunnel()` 仅对唯一值应用条件。 [\#6548](https://github.com/ClickHouse/ClickHouse/pull/6548) ([achimbab](https://github.com/achimbab)) -- 更安全的界面 `mysqlxx::Pool`. [\#6150](https://github.com/ClickHouse/ClickHouse/pull/6150) ([avasiliev](https://github.com/avasiliev)) -- 执行时选项行大小 `--help` 选项现在与终端大小对应。 [\#6590](https://github.com/ClickHouse/ClickHouse/pull/6590) ([dimarub2000](https://github.com/dimarub2000)) -- 禁用 “read in order” 优化无键的聚合。 [\#6599](https://github.com/ClickHouse/ClickHouse/pull/6599) ([安东\*波波夫](https://github.com/CurtizJ)) -- Http状态代码 `INCORRECT_DATA` 和 `TYPE_MISMATCH` 错误代码已从默认值更改 `500 Internal Server Error` 到 `400 Bad Request`. [\#6271](https://github.com/ClickHouse/ClickHouse/pull/6271) ([亚历山大\*罗丹](https://github.com/a-rodin)) -- 从移动连接对象 `ExpressionAction` 成 `AnalyzedJoin`. `ExpressionAnalyzer` 和 `ExpressionAction` 不知道 `Join` 不再上课了 它的逻辑被隐藏 `AnalyzedJoin` 伊菲斯 [\#6801](https://github.com/ClickHouse/ClickHouse/pull/6801) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复了当其中一个分片是localhost但查询通过网络连接发送时可能出现的分布式查询死锁。 [\#6759](https://github.com/ClickHouse/ClickHouse/pull/6759) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更改多个表的语义 `RENAME` 为了避免可能的死锁。 [\#6757](https://github.com/ClickHouse/ClickHouse/issues/6757). [\#6756](https://github.com/ClickHouse/ClickHouse/pull/6756) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 重写MySQL兼容性服务器以防止在内存中加载完整的数据包有效负载。 每个连接的内存消耗减少到大约 `2 * DBMS_DEFAULT_BUFFER_SIZE` (读/写缓冲区)。 [\#5811](https://github.com/ClickHouse/ClickHouse/pull/5811) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 将AST别名解释逻辑移出不必了解查询语义的解析器。 [\#6108](https://github.com/ClickHouse/ClickHouse/pull/6108) ([Artem Zuikov](https://github.com/4ertus2)) -- 稍微更安全的解析 `NamesAndTypesList`. [\#6408](https://github.com/ClickHouse/ClickHouse/issues/6408). [\#6410](https://github.com/ClickHouse/ClickHouse/pull/6410) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `clickhouse-copier`:允许使用 `where_condition` 从配置 `partition_key` 查询中用于检查分区存在的别名(以前它仅用于读取数据查询)。 [\#6577](https://github.com/ClickHouse/ClickHouse/pull/6577) ([proller](https://github.com/proller)) -- 在添加可选的消息参数 `throwIf`. ([\#5772](https://github.com/ClickHouse/ClickHouse/issues/5772)) [\#6329](https://github.com/ClickHouse/ClickHouse/pull/6329) ([Vdimir](https://github.com/Vdimir)) -- 在发送插入数据时,服务器异常也正在客户端中处理。 [\#5891](https://github.com/ClickHouse/ClickHouse/issues/5891) [\#6711](https://github.com/ClickHouse/ClickHouse/pull/6711) ([dimarub2000](https://github.com/dimarub2000)) -- 添加了指标 `DistributedFilesToInsert` 这显示了文件系统中选择通过分布式表发送到远程服务器的文件总数。 该数字在所有分片之间相加。 [\#6600](https://github.com/ClickHouse/ClickHouse/pull/6600) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 将大部分连接准备逻辑从 `ExpressionAction/ExpressionAnalyzer` 到 `AnalyzedJoin`. [\#6785](https://github.com/ClickHouse/ClickHouse/pull/6785) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复曾 [警告](https://clickhouse-test-reports.s3.yandex.net/6399/c1c1d1daa98e199e620766f1bd06a5921050a00d/functional_stateful_tests_(thread).html) ‘lock-order-inversion’. [\#6740](https://github.com/ClickHouse/ClickHouse/pull/6740) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 关于缺乏Linux功能的更好的信息消息。 记录致命错误 “fatal” 水平,这将使它更容易找到 `system.text_log`. [\#6441](https://github.com/ClickHouse/ClickHouse/pull/6441) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 当启用转储临时数据到磁盘,以限制内存使用期间 `GROUP BY`, `ORDER BY`,它没有检查可用磁盘空间。 修复程序添加新设置 `min_free_disk_space`,当可用磁盘空间小于阈值时,查询将停止并抛出 `ErrorCodes::NOT_ENOUGH_SPACE`. [\#6678](https://github.com/ClickHouse/ClickHouse/pull/6678) ([徐伟清](https://github.com/weiqxu)) [\#6691](https://github.com/ClickHouse/ClickHouse/pull/6691) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 通过线程删除递归rwlock。 这是没有意义的,因为线程在查询之间重用。 `SELECT` 查询可以在一个线程中获取锁,从另一个线程持有锁并从第一个线程退出。 在同一时间,第一个线程可以通过重复使用 `DROP` 查询。 这将导致虚假 “Attempt to acquire exclusive lock recursively” 消息 [\#6771](https://github.com/ClickHouse/ClickHouse/pull/6771) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 斯普利特 `ExpressionAnalyzer.appendJoin()`. 准备一个地方 `ExpressionAnalyzer` 为 `MergeJoin`. [\#6524](https://github.com/ClickHouse/ClickHouse/pull/6524) ([Artem Zuikov](https://github.com/4ertus2)) -- 已添加 `mysql_native_password` mysql兼容性服务器的身份验证插件。 [\#6194](https://github.com/ClickHouse/ClickHouse/pull/6194) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 更少的数量 `clock_gettime` 调用;调试/发布之间的固定ABI兼容性 `Allocator` (微不足道的问题)。 [\#6197](https://github.com/ClickHouse/ClickHouse/pull/6197) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 移动 `collectUsedColumns` 从 `ExpressionAnalyzer` 到 `SyntaxAnalyzer`. `SyntaxAnalyzer` 赂眉露\>\> `required_source_columns` 现在本身。 [\#6416](https://github.com/ClickHouse/ClickHouse/pull/6416) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加设置 `joined_subquery_requires_alias` 要求子选择和表函数的别名 `FROM` that more than one table is present (i.e. queries with JOINs). [\#6733](https://github.com/ClickHouse/ClickHouse/pull/6733) ([Artem Zuikov](https://github.com/4ertus2)) -- 提取物 `GetAggregatesVisitor` 从类 `ExpressionAnalyzer`. [\#6458](https://github.com/ClickHouse/ClickHouse/pull/6458) ([Artem Zuikov](https://github.com/4ertus2)) -- `system.query_log`:更改数据类型 `type` 列到 `Enum`. [\#6265](https://github.com/ClickHouse/ClickHouse/pull/6265) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 静态链接 `sha256_password` 身份验证插件。 [\#6512](https://github.com/ClickHouse/ClickHouse/pull/6512) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 避免对设置的额外依赖 `compile` 去工作 在以前的版本中,用户可能会得到如下错误 `cannot open crti.o`, `unable to find library -lc` 等。 [\#6309](https://github.com/ClickHouse/ClickHouse/pull/6309) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 对可能来自恶意副本的输入进行更多验证。 [\#6303](https://github.com/ClickHouse/ClickHouse/pull/6303) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在 `clickhouse-obfuscator` 文件是可用的 `clickhouse-client` 包。 在以前的版本中,它可以作为 `clickhouse obfuscator` (带空格)。 [\#5816](https://github.com/ClickHouse/ClickHouse/issues/5816) [\#6609](https://github.com/ClickHouse/ClickHouse/pull/6609) ([dimarub2000](https://github.com/dimarub2000)) -- 当我们至少有两个查询以不同的顺序读取至少两个表,另一个查询对其中一个表执行DDL操作时,修复了死锁。 修复了另一个非常罕见的死锁。 [\#6764](https://github.com/ClickHouse/ClickHouse/pull/6764) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 已添加 `os_thread_ids` 列到 `system.processes` 和 `system.query_log` 为了更好的调试可能性。 [\#6763](https://github.com/ClickHouse/ClickHouse/pull/6763) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 当发生PHP mysqlnd扩展错误的解决方法 `sha256_password` 用作默认身份验证插件(在描述 [\#6031](https://github.com/ClickHouse/ClickHouse/issues/6031)). [\#6113](https://github.com/ClickHouse/ClickHouse/pull/6113) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 删除不需要的地方与更改为空列。 [\#6693](https://github.com/ClickHouse/ClickHouse/pull/6693) ([Artem Zuikov](https://github.com/4ertus2)) -- 设置默认值 `queue_max_wait_ms` 为零,因为当前值(五秒)是没有意义的。 在极少数情况下,此设置有任何用途。 添加设置 `replace_running_query_max_wait_ms`, `kafka_max_wait_ms` 和 `connection_pool_max_wait_ms` 用于消除歧义。 [\#6692](https://github.com/ClickHouse/ClickHouse/pull/6692) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 提取物 `SelectQueryExpressionAnalyzer` 从 `ExpressionAnalyzer`. 保留最后一个用于非select查询。 [\#6499](https://github.com/ClickHouse/ClickHouse/pull/6499) ([Artem Zuikov](https://github.com/4ertus2)) -- 删除重复输入和输出格式。 [\#6239](https://github.com/ClickHouse/ClickHouse/pull/6239) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 允许用户复盖 `poll_interval` 和 `idle_connection_timeout` 连接设置。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `MergeTree` 现在有一个额外的选项 `ttl_only_drop_parts` (默认情况下禁用),以避免部分的部分修剪,以便在部分中的所有行都过期时完全删除它们。 [\#6191](https://github.com/ClickHouse/ClickHouse/pull/6191) ([塞尔吉\*弗拉季金](https://github.com/svladykin)) -- 类型检查set索引函数。 如果函数类型错误,则引发异常。 这修复了模糊测试与UBSan。 [\#6511](https://github.com/ClickHouse/ClickHouse/pull/6511) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) - -#### 性能改进 {#performance-improvement-2} - -- 优化查询 `ORDER BY expressions` 条款,其中 `expressions` 有重合前缀与排序键 `MergeTree` 桌子 此优化由以下方式控制 `optimize_read_in_order` 设置。 [\#6054](https://github.com/ClickHouse/ClickHouse/pull/6054) [\#6629](https://github.com/ClickHouse/ClickHouse/pull/6629) ([安东\*波波夫](https://github.com/CurtizJ)) -- 允许在零件装载和拆卸期间使用多个螺纹。 [\#6372](https://github.com/ClickHouse/ClickHouse/issues/6372) [\#6074](https://github.com/ClickHouse/ClickHouse/issues/6074) [\#6438](https://github.com/ClickHouse/ClickHouse/pull/6438) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 实现了更新聚合函数状态的批处理变体。 这可能导致性能优势。 [\#6435](https://github.com/ClickHouse/ClickHouse/pull/6435) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用 `FastOps` 函数库 `exp`, `log`, `sigmoid`, `tanh`. FastOps是迈克尔\*帕拉欣(Yandex的首席技术官)的快速矢量数学库。 改进的性能 `exp` 和 `log` 功能超过6倍。 功能 `exp` 和 `log` 从 `Float32` 参数将返回 `Float32` (在以前的版本中,他们总是返回 `Float64`). 现在 `exp(nan)` 可能会回来 `inf`. 的结果 `exp` 和 `log` 函数可能不是最接近机器可代表的数字到真正的答案。 [\#6254](https://github.com/ClickHouse/ClickHouse/pull/6254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov))使用Danila Kutenin变体使fastops工作 [\#6317](https://github.com/ClickHouse/ClickHouse/pull/6317) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 禁用连续密钥优化 `UInt8/16`. [\#6298](https://github.com/ClickHouse/ClickHouse/pull/6298) [\#6701](https://github.com/ClickHouse/ClickHouse/pull/6701) ([akuzm](https://github.com/akuzm)) -- 改进的性能 `simdjson` 库通过摆脱动态分配 `ParsedJson::Iterator`. [\#6479](https://github.com/ClickHouse/ClickHouse/pull/6479) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 预故障页分配内存时 `mmap()`. [\#6667](https://github.com/ClickHouse/ClickHouse/pull/6667) ([akuzm](https://github.com/akuzm)) -- 修复性能错误 `Decimal` 比较。 [\#6380](https://github.com/ClickHouse/ClickHouse/pull/6380) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-4} - -- 删除编译器(运行时模板实例化),因为我们已经赢得了它的性能。 [\#6646](https://github.com/ClickHouse/ClickHouse/pull/6646) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了性能测试,以显示gcc-9以更隔离的方式性能下降。 [\#6302](https://github.com/ClickHouse/ClickHouse/pull/6302) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加表功能 `numbers_mt`,这是多线程版本 `numbers`. 使用哈希函数更新性能测试。 [\#6554](https://github.com/ClickHouse/ClickHouse/pull/6554) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 比较模式 `clickhouse-benchmark` [\#6220](https://github.com/ClickHouse/ClickHouse/issues/6220) [\#6343](https://github.com/ClickHouse/ClickHouse/pull/6343) ([dimarub2000](https://github.com/dimarub2000)) -- 尽最大努力打印堆栈痕迹。 还添加了 `SIGPROF` 作为调试信号,打印正在运行的线程的堆栈跟踪。 [\#6529](https://github.com/ClickHouse/ClickHouse/pull/6529) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 每个函数都在自己的文件中,第10部分。 [\#6321](https://github.com/ClickHouse/ClickHouse/pull/6321) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除两倍常量 `TABLE_IS_READ_ONLY`. [\#6566](https://github.com/ClickHouse/ClickHouse/pull/6566) ([filimonov](https://github.com/filimonov)) -- 格式化更改 `StringHashMap` PR [\#5417](https://github.com/ClickHouse/ClickHouse/issues/5417). [\#6700](https://github.com/ClickHouse/ClickHouse/pull/6700) ([akuzm](https://github.com/akuzm)) -- 更好的联接创建子查询 `ExpressionAnalyzer`. [\#6824](https://github.com/ClickHouse/ClickHouse/pull/6824) ([Artem Zuikov](https://github.com/4ertus2)) -- 删除冗余条件(由PVS Studio找到)。 [\#6775](https://github.com/ClickHouse/ClickHouse/pull/6775) ([akuzm](https://github.com/akuzm)) -- 分隔散列表接口 `ReverseIndex`. [\#6672](https://github.com/ClickHouse/ClickHouse/pull/6672) ([akuzm](https://github.com/akuzm)) -- 重构设置。 [\#6689](https://github.com/ClickHouse/ClickHouse/pull/6689) ([阿利沙平](https://github.com/alesapin)) -- 添加注释 `set` 索引函数。 [\#6319](https://github.com/ClickHouse/ClickHouse/pull/6319) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 在Linux上的调试版本中增加OOM分数。 [\#6152](https://github.com/ClickHouse/ClickHouse/pull/6152) ([akuzm](https://github.com/akuzm)) -- HDFS HA现在在调试版本中工作。 [\#6650](https://github.com/ClickHouse/ClickHouse/pull/6650) ([徐伟清](https://github.com/weiqxu)) -- 添加了一个测试 `transform_query_for_external_database`. [\#6388](https://github.com/ClickHouse/ClickHouse/pull/6388) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 为Kafka表添加多个实例化视图的测试。 [\#6509](https://github.com/ClickHouse/ClickHouse/pull/6509) ([伊万](https://github.com/abyss7)) -- 制定一个更好的构建计划。 [\#6500](https://github.com/ClickHouse/ClickHouse/pull/6500) ([伊万](https://github.com/abyss7)) -- 固定 `test_external_dictionaries` 集成的情况下,它是在非root用户下执行。 [\#6507](https://github.com/ClickHouse/ClickHouse/pull/6507) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 当写入的数据包的总大小超过 `DBMS_DEFAULT_BUFFER_SIZE`. [\#6204](https://github.com/ClickHouse/ClickHouse/pull/6204) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 增加了一个测试 `RENAME` 表竞争条件 [\#6752](https://github.com/ClickHouse/ClickHouse/pull/6752) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免在设置数据竞赛 `KILL QUERY`. [\#6753](https://github.com/ClickHouse/ClickHouse/pull/6753) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 通过缓存字典添加处理错误的集成测试。 [\#6755](https://github.com/ClickHouse/ClickHouse/pull/6755) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 在Mac OS上禁用ELF对象文件的解析,因为这是没有意义的。 [\#6578](https://github.com/ClickHouse/ClickHouse/pull/6578) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 尝试使更新日志生成器更好。 [\#6327](https://github.com/ClickHouse/ClickHouse/pull/6327) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加 `-Wshadow` 切换到海湾合作委员会。 [\#6325](https://github.com/ClickHouse/ClickHouse/pull/6325) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- 删除过时的代码 `mimalloc` 支持。 [\#6715](https://github.com/ClickHouse/ClickHouse/pull/6715) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `zlib-ng` 确定x86功能并将此信息保存到全局变量。 这是在defalteInit调用中完成的,它可以由不同的线程同时进行。 为了避免多线程写入,请在库启动时执行此操作。 [\#6141](https://github.com/ClickHouse/ClickHouse/pull/6141) ([akuzm](https://github.com/akuzm)) -- 回归测试一个错误,在连接这是固定的 [\#5192](https://github.com/ClickHouse/ClickHouse/issues/5192). [\#6147](https://github.com/ClickHouse/ClickHouse/pull/6147) ([Bakhtiyor Ruziev](https://github.com/theruziev)) -- 修正MSan报告。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复扑ttl测试。 [\#6782](https://github.com/ClickHouse/ClickHouse/pull/6782) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修正了虚假数据竞赛 `MergeTreeDataPart::is_frozen` 场。 [\#6583](https://github.com/ClickHouse/ClickHouse/pull/6583) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了模糊测试中的超时。 在以前的版本中,它设法在查询中找到虚假挂断 `SELECT * FROM numbers_mt(gccMurmurHash(''))`. [\#6582](https://github.com/ClickHouse/ClickHouse/pull/6582) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加了调试检查 `static_cast` 列。 [\#6581](https://github.com/ClickHouse/ClickHouse/pull/6581) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在官方RPM软件包中支持Oracle Linux。 [\#6356](https://github.com/ClickHouse/ClickHouse/issues/6356) [\#6585](https://github.com/ClickHouse/ClickHouse/pull/6585) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从更改json perftests `once` 到 `loop` 类型。 [\#6536](https://github.com/ClickHouse/ClickHouse/pull/6536) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- `odbc-bridge.cpp` 定义 `main()` 所以它不应该被包括在 `clickhouse-lib`. [\#6538](https://github.com/ClickHouse/ClickHouse/pull/6538) ([Origej Desh](https://github.com/orivej)) -- 测试碰撞 `FULL|RIGHT JOIN` 右表的键中有空值。 [\#6362](https://github.com/ClickHouse/ClickHouse/pull/6362) ([Artem Zuikov](https://github.com/4ertus2)) -- 为了以防万一,增加了对别名扩展限制的测试。 [\#6442](https://github.com/ClickHouse/ClickHouse/pull/6442) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从切换 `boost::filesystem` 到 `std::filesystem` 在适当的情况下。 [\#6253](https://github.com/ClickHouse/ClickHouse/pull/6253) [\#6385](https://github.com/ClickHouse/ClickHouse/pull/6385) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 将RPM包添加到网站。 [\#6251](https://github.com/ClickHouse/ClickHouse/pull/6251) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 为固定添加测试 `Unknown identifier` 例外 `IN` 科。 [\#6708](https://github.com/ClickHouse/ClickHouse/pull/6708) ([Artem Zuikov](https://github.com/4ertus2)) -- 简化操作 `shared_ptr_helper` 因为人们面临困难理解它。 [\#6675](https://github.com/ClickHouse/ClickHouse/pull/6675) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了固定大猩猩和DoubleDelta编解码器的性能测试。 [\#6179](https://github.com/ClickHouse/ClickHouse/pull/6179) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 拆分集成测试 `test_dictionaries` 分成四个单独的测试。 [\#6776](https://github.com/ClickHouse/ClickHouse/pull/6776) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复PVS-Studio中的警告 `PipelineExecutor`. [\#6777](https://github.com/ClickHouse/ClickHouse/pull/6777) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 允许使用 `library` 与ASan字典源. [\#6482](https://github.com/ClickHouse/ClickHouse/pull/6482) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了从Pr列表生成更新日志的选项。 [\#6350](https://github.com/ClickHouse/ClickHouse/pull/6350) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 锁定 `TinyLog` 读取时存储。 [\#6226](https://github.com/ClickHouse/ClickHouse/pull/6226) ([akuzm](https://github.com/akuzm)) -- 检查CI中损坏的符号链接。 [\#6634](https://github.com/ClickHouse/ClickHouse/pull/6634) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加超时时间 “stack overflow” 测试,因为它可能需要很长的时间在调试构建。 [\#6637](https://github.com/ClickHouse/ClickHouse/pull/6637) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加了双空格检查。 [\#6643](https://github.com/ClickHouse/ClickHouse/pull/6643) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `new/delete` 使用消毒剂构建时的内存跟踪。 跟踪不清楚。 它只防止测试中的内存限制异常。 [\#6450](https://github.com/ClickHouse/ClickHouse/pull/6450) ([Artem Zuikov](https://github.com/4ertus2)) -- 启用链接时对未定义符号的检查。 [\#6453](https://github.com/ClickHouse/ClickHouse/pull/6453) ([伊万](https://github.com/abyss7)) -- 避免重建 `hyperscan` 每天 [\#6307](https://github.com/ClickHouse/ClickHouse/pull/6307) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在固定的瑞银报告 `ProtobufWriter`. [\#6163](https://github.com/ClickHouse/ClickHouse/pull/6163) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 不要允许将查询探查器与消毒器一起使用,因为它不兼容。 [\#6769](https://github.com/ClickHouse/ClickHouse/pull/6769) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加测试计时器失败后重新加载字典。 [\#6114](https://github.com/ClickHouse/ClickHouse/pull/6114) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复不一致 `PipelineExecutor::prepareProcessor` 参数类型。 [\#6494](https://github.com/ClickHouse/ClickHouse/pull/6494) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 添加了对坏Uri的测试。 [\#6493](https://github.com/ClickHouse/ClickHouse/pull/6493) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了更多的检查 `CAST` 功能。 这应该获得更多关于模糊测试中分割故障的信息。 [\#6346](https://github.com/ClickHouse/ClickHouse/pull/6346) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 已添加 `gcc-9` 支持 `docker/builder` 本地生成映像的容器。 [\#6333](https://github.com/ClickHouse/ClickHouse/pull/6333) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) -- 测试主键 `LowCardinality(String)`. [\#5044](https://github.com/ClickHouse/ClickHouse/issues/5044) [\#6219](https://github.com/ClickHouse/ClickHouse/pull/6219) ([dimarub2000](https://github.com/dimarub2000)) -- 修复了缓慢堆栈跟踪打印影响的测试。 [\#6315](https://github.com/ClickHouse/ClickHouse/pull/6315) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加崩溃的测试用例 `groupUniqArray` 固定在 [\#6029](https://github.com/ClickHouse/ClickHouse/pull/6029). [\#4402](https://github.com/ClickHouse/ClickHouse/issues/4402) [\#6129](https://github.com/ClickHouse/ClickHouse/pull/6129) ([akuzm](https://github.com/akuzm)) -- 固定指数突变测试。 [\#6645](https://github.com/ClickHouse/ClickHouse/pull/6645) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 在性能测试中,不要读取我们没有运行的查询的查询日志。 [\#6427](https://github.com/ClickHouse/ClickHouse/pull/6427) ([akuzm](https://github.com/akuzm)) -- 现在可以使用任何低基数类型创建实例化视图,而不考虑关于可疑低基数类型的设置。 [\#6428](https://github.com/ClickHouse/ClickHouse/pull/6428) ([Olga Khvostikova](https://github.com/stavrolia)) -- 更新的测试 `send_logs_level` 设置。 [\#6207](https://github.com/ClickHouse/ClickHouse/pull/6207) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复gcc-8.2下的构建。 [\#6196](https://github.com/ClickHouse/ClickHouse/pull/6196) ([Max Akhmedov](https://github.com/zlobober)) -- 修复构建与内部libc++。 [\#6724](https://github.com/ClickHouse/ClickHouse/pull/6724) ([伊万](https://github.com/abyss7)) -- 修复共享构建 `rdkafka` 图书馆 [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([伊万](https://github.com/abyss7)) -- 修复Mac OS构建(不完整)。 [\#6390](https://github.com/ClickHouse/ClickHouse/pull/6390) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#6429](https://github.com/ClickHouse/ClickHouse/pull/6429) ([alex-zaitsev](https://github.com/alex-zaitsev)) -- 修复 “splitted” 碌莽禄.拢. [\#6618](https://github.com/ClickHouse/ClickHouse/pull/6618) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 其他构建修复: [\#6186](https://github.com/ClickHouse/ClickHouse/pull/6186) ([阿莫斯鸟](https://github.com/amosbird)) [\#6486](https://github.com/ClickHouse/ClickHouse/pull/6486) [\#6348](https://github.com/ClickHouse/ClickHouse/pull/6348) ([vxider](https://github.com/Vxider)) [\#6744](https://github.com/ClickHouse/ClickHouse/pull/6744) ([伊万](https://github.com/abyss7)) [\#6016](https://github.com/ClickHouse/ClickHouse/pull/6016) [\#6421](https://github.com/ClickHouse/ClickHouse/pull/6421) [\#6491](https://github.com/ClickHouse/ClickHouse/pull/6491) ([proller](https://github.com/proller)) - -#### 向后不兼容的更改 {#backward-incompatible-change-3} - -- 删除很少使用的表函数 `catBoostPool` 和存储 `CatBoostPool`. 如果您使用了此表功能,请写电子邮件至 `clickhouse-feedback@yandex-team.com`. 请注意,CatBoost集成仍然存在,并将受到支持。 [\#6279](https://github.com/ClickHouse/ClickHouse/pull/6279) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 禁用 `ANY RIGHT JOIN` 和 `ANY FULL JOIN` 默认情况下。 设置 `any_join_distinct_right_table_keys` 设置启用它们。 [\#5126](https://github.com/ClickHouse/ClickHouse/issues/5126) [\#6351](https://github.com/ClickHouse/ClickHouse/pull/6351) ([Artem Zuikov](https://github.com/4ertus2)) - -## ClickHouse释放19.13 {#clickhouse-release-19-13} - -### ClickHouse释放19.13.6.51,2019-10-02 {#clickhouse-release-19-13-6-51-2019-10-02} - -#### 错误修复 {#bug-fix-9} - -- 此版本还包含19.11.12.69的所有错误修复。 - -### ClickHouse释放19.13.5.44,2019-09-20 {#clickhouse-release-19-13-5-44-2019-09-20} - -#### 错误修复 {#bug-fix-10} - -- 此版本还包含19.14.6.12的所有错误修复。 -- 修复了在执行时表的可能不一致的状态 `DROP` 在zookeeper无法访问时查询复制的表。 [\#6045](https://github.com/ClickHouse/ClickHouse/issues/6045) [\#6413](https://github.com/ClickHouse/ClickHouse/pull/6413) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 修复了StorageMerge中的数据竞赛 [\#6717](https://github.com/ClickHouse/ClickHouse/pull/6717) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复查询分析器中引入的错误,从而导致套接字无休止的recv。 [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) ([阿利沙平](https://github.com/alesapin)) -- 修复执行时过多的CPU使用率 `JSONExtractRaw` 函数在一个布尔值。 [\#6208](https://github.com/ClickHouse/ClickHouse/pull/6208) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 在推送到实例化视图时修复回归。 [\#6415](https://github.com/ClickHouse/ClickHouse/pull/6415) ([伊万](https://github.com/abyss7)) -- 表函数 `url` 该漏洞是否允许攻击者在请求中注入任意HTTP头。 这个问题被发现 [尼基塔\*季霍米罗夫](https://github.com/NSTikhomirov). [\#6466](https://github.com/ClickHouse/ClickHouse/pull/6466) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复无用 `AST` 检查设置索引。 [\#6510](https://github.com/ClickHouse/ClickHouse/issues/6510) [\#6651](https://github.com/ClickHouse/ClickHouse/pull/6651) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 修正了解析 `AggregateFunction` 查询中嵌入的值。 [\#6575](https://github.com/ClickHouse/ClickHouse/issues/6575) [\#6773](https://github.com/ClickHouse/ClickHouse/pull/6773) ([余志昌](https://github.com/yuzhichang)) -- 修正了错误的行为 `trim` 功能家庭。 [\#6647](https://github.com/ClickHouse/ClickHouse/pull/6647) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### ClickHouse释放19.13.4.32,2019-09-10 {#clickhouse-release-19-13-4-32-2019-09-10} - -#### 错误修复 {#bug-fix-11} - -- 此版本还包含19.11.9.52和19.11.10.54的所有错误安全修复。 -- 固定数据竞赛 `system.parts` 表和 `ALTER` 查询。 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245) [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了从带有sample和prewhere的空分布式表中读取流中发生的不匹配标题。 [\#6167](https://github.com/ClickHouse/ClickHouse/issues/6167) ([钱丽祥](https://github.com/fancyqlx)) [\#6823](https://github.com/ClickHouse/ClickHouse/pull/6823) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复使用时的崩溃 `IN` 子句带有一个元组的子查询。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- 修复具有相同列名的大小写 `GLOBAL JOIN ON` 科。 [\#6181](https://github.com/ClickHouse/ClickHouse/pull/6181) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复强制转换类型时的崩溃 `Decimal` 这不支持它。 抛出异常代替。 [\#6297](https://github.com/ClickHouse/ClickHouse/pull/6297) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复了崩溃 `extractAll()` 功能。 [\#6644](https://github.com/ClickHouse/ClickHouse/pull/6644) ([Artem Zuikov](https://github.com/4ertus2)) -- 查询转换 `MySQL`, `ODBC`, `JDBC` 表函数现在正常工作 `SELECT WHERE` 具有多个查询 `AND` 表达式。 [\#6381](https://github.com/ClickHouse/ClickHouse/issues/6381) [\#6676](https://github.com/ClickHouse/ClickHouse/pull/6676) ([dimarub2000](https://github.com/dimarub2000)) -- 添加了以前的声明检查MySQL8集成。 [\#6569](https://github.com/ClickHouse/ClickHouse/pull/6569) ([拉斐尔\*大卫\*蒂诺科](https://github.com/rafaeldtinoco)) - -#### 安全修复 {#security-fix-1} - -- 修复解压缩阶段编解码器中的两个漏洞(恶意用户可以制造压缩数据,导致解压缩中的缓冲区溢出)。 [\#6670](https://github.com/ClickHouse/ClickHouse/pull/6670) ([Artem Zuikov](https://github.com/4ertus2)) - -### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102005602 {#clickhouse-release-19-13-3-26-2019-08-22} - -#### 错误修复 {#bug-fix-12} - -- 修复 `ALTER TABLE ... UPDATE` 查询表 `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([阿利沙平](https://github.com/alesapin)) -- 在使用IN子句时修复带有元组的子查询。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- 修复了一个问题,即如果一个陈旧的副本变为活动的,它可能仍然有被删除分区的数据部分。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- 修正了解析CSV的问题 [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) -- 修正了系统中的数据竞赛。部件表和ALTER查询。 这修复 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了可能导致内存损坏的突变中的错误代码。 修复了读取地址的段错误 `0x14c0` 这可能发生由于并发 `DROP TABLE` 和 `SELECT` 从 `system.parts` 或 `system.parts_columns`. 在准备突变查询时修复了竞争条件。 修复了由于 `OPTIMIZE` 复制的表和并发修改操作,如改变。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复后可能的数据丢失 `ALTER DELETE` 查询表跳过索引。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) - -#### 安全修复 {#security-fix-2} - -- 如果攻击者具有对ZooKeeper的写入访问权限,并且能够从ClickHouse运行的网络中运行可用的自定义服务器,则可以创建自定义构建的恶意服务器,该服务器将充当ClickHouse副本并将其注册到ZooKeeper中。 当另一个副本从恶意副本中获取数据部分时,它可以强制clickhouse-server写入文件系统上的任意路径。 由Yandex的信息安全团队Eldar Zaitov发现。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-13-2-19-2019-08-14} - -#### 新功能 {#new-feature-5} - -- 查询级别上的采样探查器。 [示例](https://gist.github.com/alexey-milovidov/92758583dd41c24c360fdb8d6a4da194). [\#4247](https://github.com/ClickHouse/ClickHouse/issues/4247) ([laplab](https://github.com/laplab)) [\#6124](https://github.com/ClickHouse/ClickHouse/pull/6124) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#6250](https://github.com/ClickHouse/ClickHouse/pull/6250) [\#6283](https://github.com/ClickHouse/ClickHouse/pull/6283) [\#6386](https://github.com/ClickHouse/ClickHouse/pull/6386) -- 允许指定列的列表 `COLUMNS('regexp')` 表达的工作原理就像一个更复杂的变体 `*` 星号 [\#5951](https://github.com/ClickHouse/ClickHouse/pull/5951) ([mfridental](https://github.com/mfridental)), ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `CREATE TABLE AS table_function()` 现在是可能的 [\#6057](https://github.com/ClickHouse/ClickHouse/pull/6057) ([dimarub2000](https://github.com/dimarub2000)) -- 亚当优化随机梯度下降默认情况下使用 `stochasticLinearRegression()` 和 `stochasticLogisticRegression()` 聚合函数,因为它显示了良好的质量,几乎没有任何调整。 [\#6000](https://github.com/ClickHouse/ClickHouse/pull/6000) ([Quid37](https://github.com/Quid37)) -- Added functions for working with the сustom week number [\#5212](https://github.com/ClickHouse/ClickHouse/pull/5212) ([杨小姐](https://github.com/andyyzh)) -- `RENAME` 查询现在适用于所有存储。 [\#5953](https://github.com/ClickHouse/ClickHouse/pull/5953) ([伊万](https://github.com/abyss7)) -- 现在客户端通过设置从服务器接收任何所需级别的日志 `send_logs_level` 无论服务器设置中指定的日志级别如何。 [\#5964](https://github.com/ClickHouse/ClickHouse/pull/5964) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) - -#### 向后不兼容的更改 {#backward-incompatible-change-4} - -- 设置 `input_format_defaults_for_omitted_fields` 默认情况下启用。 分布式表中的插入需要此设置在集群上相同(您需要在滚动更新之前设置它)。 它允许计算复杂的默认表达式的省略字段 `JSONEachRow` 和 `CSV*` 格式。 它应该是预期的行为,但可能导致可忽略不计的性能差异。 [\#6043](https://github.com/ClickHouse/ClickHouse/pull/6043) ([Artem Zuikov](https://github.com/4ertus2)), [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) - -#### 实验特点 {#experimental-features} - -- 新的查询处理管道。 使用 `experimental_use_processors=1` 选项来启用它。 用你自己的麻烦。 [\#4914](https://github.com/ClickHouse/ClickHouse/pull/4914) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -#### 错误修复 {#bug-fix-13} - -- Kafka集成已在此版本中修复。 -- 固定 `DoubleDelta` 编码 `Int64` 对于大 `DoubleDelta` 值,改进 `DoubleDelta` 编码为随机数据 `Int32`. [\#5998](https://github.com/ClickHouse/ClickHouse/pull/5998) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 固定的高估 `max_rows_to_read` 如果设置 `merge_tree_uniform_read_distribution` 置为0。 [\#6019](https://github.com/ClickHouse/ClickHouse/pull/6019) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 改进 {#improvement-4} - -- 如果抛出异常 `config.d` 文件没有相应的根元素作为配置文件 [\#6123](https://github.com/ClickHouse/ClickHouse/pull/6123) ([dimarub2000](https://github.com/dimarub2000)) - -#### 性能改进 {#performance-improvement-3} - -- 优化 `count()`. 现在它使用最小的列(如果可能的话)。 [\#6028](https://github.com/ClickHouse/ClickHouse/pull/6028) ([阿莫斯鸟](https://github.com/amosbird)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-5} - -- 在性能测试中报告内存使用情况。 [\#5899](https://github.com/ClickHouse/ClickHouse/pull/5899) ([akuzm](https://github.com/akuzm)) -- 修复构建与外部 `libcxx` [\#6010](https://github.com/ClickHouse/ClickHouse/pull/6010) ([伊万](https://github.com/abyss7)) -- 修复共享构建 `rdkafka` 图书馆 [\#6101](https://github.com/ClickHouse/ClickHouse/pull/6101) ([伊万](https://github.com/abyss7)) - -## ClickHouse释放19.11 {#clickhouse-release-19-11} - -### ClickHouse释放19.11.13.74,2019-11-01 {#clickhouse-release-19-11-13-74-2019-11-01} - -#### 错误修复 {#bug-fix-14} - -- 修复了罕见的崩溃 `ALTER MODIFY COLUMN` 当合并/更改部分之一为空(0行)时,垂直合并。 [\#6780](https://github.com/ClickHouse/ClickHouse/pull/6780) ([阿利沙平](https://github.com/alesapin)) -- 手动更新 `SIMDJSON`. 这修复了stderr文件可能泛滥的错误json诊断消息。 [\#7548](https://github.com/ClickHouse/ClickHouse/pull/7548) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 修正错误 `mrk` 突变的文件扩展名 ([阿利沙平](https://github.com/alesapin)) - -### ClickHouse释放19.11.12.69,2019-10-02 {#clickhouse-release-19-11-12-69-2019-10-02} - -#### 错误修复 {#bug-fix-15} - -- 修复了大型表上复杂键的索引分析的性能下降。 这修复 [\#6924](https://github.com/ClickHouse/ClickHouse/issues/6924). [\#7075](https://github.com/ClickHouse/ClickHouse/pull/7075) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用分布式引擎在表中发送数据时避免罕见的SIGSEGV (`Failed to send batch: file with index XXXXX is absent`). [\#7032](https://github.com/ClickHouse/ClickHouse/pull/7032) ([Azat Khuzhin](https://github.com/azat)) -- 修复 `Unknown identifier` 有多个连接。 这修复 [\#5254](https://github.com/ClickHouse/ClickHouse/issues/5254). [\#7022](https://github.com/ClickHouse/ClickHouse/pull/7022) ([Artem Zuikov](https://github.com/4ertus2)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-11-57-2019-09-13} - -- 修复从Kafka空主题中选择时导致段错误的逻辑错误。 [\#6902](https://github.com/ClickHouse/ClickHouse/issues/6902) [\#6909](https://github.com/ClickHouse/ClickHouse/pull/6909) ([伊万](https://github.com/abyss7)) -- 修复功能 `АrrayEnumerateUniqRanked` 在参数中使用空数组。 [\#6928](https://github.com/ClickHouse/ClickHouse/pull/6928) ([proller](https://github.com/proller)) - -### ClickHouse释放19.11.10.54,2019-09-10 {#clickhouse-release-19-11-10-54-2019-09-10} - -#### 错误修复 {#bug-fix-16} - -- 手动存储Kafka消息的偏移量,以便能够一次性为所有分区提交它们。 修复潜在的重复 “one consumer - many partitions” 场景。 [\#6872](https://github.com/ClickHouse/ClickHouse/pull/6872) ([伊万](https://github.com/abyss7)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682 {#clickhouse-release-19-11-9-52-2019-09-6} - -- 改进缓存字典中的错误处理。 [\#6737](https://github.com/ClickHouse/ClickHouse/pull/6737) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 在功能固定错误 `arrayEnumerateUniqRanked`. [\#6779](https://github.com/ClickHouse/ClickHouse/pull/6779) ([proller](https://github.com/proller)) -- 修复 `JSONExtract` 功能,同时提取 `Tuple` 从JSON。 [\#6718](https://github.com/ClickHouse/ClickHouse/pull/6718) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复后可能的数据丢失 `ALTER DELETE` 查询表跳过索引。 [\#6224](https://github.com/ClickHouse/ClickHouse/issues/6224) [\#6282](https://github.com/ClickHouse/ClickHouse/pull/6282) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 固定性能测试。 [\#6392](https://github.com/ClickHouse/ClickHouse/pull/6392) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 实木复合地板:修复读取布尔列。 [\#6579](https://github.com/ClickHouse/ClickHouse/pull/6579) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了错误的行为 `nullIf` 常量参数的函数。 [\#6518](https://github.com/ClickHouse/ClickHouse/pull/6518) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) [\#6580](https://github.com/ClickHouse/ClickHouse/pull/6580) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复kafka服务器正常重启时的消息重复问题。 [\#6597](https://github.com/ClickHouse/ClickHouse/pull/6597) ([伊万](https://github.com/abyss7)) -- 修正了一个问题,当长 `ALTER UPDATE` 或 `ALTER DELETE` 可能会阻止常规合并运行。 如果没有足够的可用线程,则防止突变执行。 [\#6502](https://github.com/ClickHouse/ClickHouse/issues/6502) [\#6617](https://github.com/ClickHouse/ClickHouse/pull/6617) ([tavplubix](https://github.com/tavplubix)) -- 修正了处理错误 “timezone” 在服务器配置文件中。 [\#6709](https://github.com/ClickHouse/ClickHouse/pull/6709) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复卡夫卡测试。 [\#6805](https://github.com/ClickHouse/ClickHouse/pull/6805) ([伊万](https://github.com/abyss7)) - -#### 安全修复 {#security-fix-3} - -- 如果攻击者具有对ZooKeeper的写入访问权限,并且能够从运行ClickHouse的网络中运行可用的自定义服务器,则可以创建自定义构建的恶意服务器,该服务器将充当ClickHouse副本并将其注册到ZooKeeper中。 当另一个副本从恶意副本中获取数据部分时,它可以强制clickhouse-server写入文件系统上的任意路径。 由Yandex的信息安全团队Eldar Zaitov发现。 [\#6247](https://github.com/ClickHouse/ClickHouse/pull/6247) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-8-46-2019-08-22} - -#### 错误修复 {#bug-fix-17} - -- 修复 `ALTER TABLE ... UPDATE` 查询表 `enable_mixed_granularity_parts=1`. [\#6543](https://github.com/ClickHouse/ClickHouse/pull/6543) ([阿利沙平](https://github.com/alesapin)) -- 在使用IN子句时修复带有元组的子查询。 [\#6125](https://github.com/ClickHouse/ClickHouse/issues/6125) [\#6550](https://github.com/ClickHouse/ClickHouse/pull/6550) ([tavplubix](https://github.com/tavplubix)) -- 修复了一个问题,即如果一个陈旧的副本变为活动的,它可能仍然有被删除分区的数据部分。 [\#6522](https://github.com/ClickHouse/ClickHouse/issues/6522) [\#6523](https://github.com/ClickHouse/ClickHouse/pull/6523) ([tavplubix](https://github.com/tavplubix)) -- 修正了解析CSV的问题 [\#6426](https://github.com/ClickHouse/ClickHouse/issues/6426) [\#6559](https://github.com/ClickHouse/ClickHouse/pull/6559) ([tavplubix](https://github.com/tavplubix)) -- 修正了系统中的数据竞赛。部件表和ALTER查询。 这修复 [\#6245](https://github.com/ClickHouse/ClickHouse/issues/6245). [\#6513](https://github.com/ClickHouse/ClickHouse/pull/6513) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了可能导致内存损坏的突变中的错误代码。 修复了读取地址的段错误 `0x14c0` 这可能发生由于并发 `DROP TABLE` 和 `SELECT` 从 `system.parts` 或 `system.parts_columns`. 在准备突变查询时修复了竞争条件。 修复了由于 `OPTIMIZE` 复制的表和并发修改操作,如改变。 [\#6514](https://github.com/ClickHouse/ClickHouse/pull/6514) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-7-40-2019-08-14} - -#### 错误修复 {#bug-fix-18} - -- Kafka集成已在此版本中修复。 -- 使用时修复段错误 `arrayReduce` 对于不断的参数。 [\#6326](https://github.com/ClickHouse/ClickHouse/pull/6326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定 `toFloat()` 单调性。 [\#6374](https://github.com/ClickHouse/ClickHouse/pull/6374) ([dimarub2000](https://github.com/dimarub2000)) -- 修复已启用的段错误 `optimize_skip_unused_shards` 还丢失了分片钥匙 [\#6384](https://github.com/ClickHouse/ClickHouse/pull/6384) ([CurtizJ](https://github.com/CurtizJ)) -- 的固定逻辑 `arrayEnumerateUniqRanked` 功能。 [\#6423](https://github.com/ClickHouse/ClickHouse/pull/6423) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从MySQL处理程序中删除了额外的详细日志记录。 [\#6389](https://github.com/ClickHouse/ClickHouse/pull/6389) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复错误的行为和可能的段错误 `topK` 和 `topKWeighted` 聚合函数。 [\#6404](https://github.com/ClickHouse/ClickHouse/pull/6404) ([CurtizJ](https://github.com/CurtizJ)) -- 不要公开虚拟列 `system.columns` 桌子 这是向后兼容所必需的。 [\#6406](https://github.com/ClickHouse/ClickHouse/pull/6406) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复复杂键缓存字典中字符串字段的内存分配错误。 [\#6447](https://github.com/ClickHouse/ClickHouse/pull/6447) ([阿利沙平](https://github.com/alesapin)) -- 修复创建新副本时启用自适应粒度的错误 `Replicated*MergeTree` 桌子 [\#6452](https://github.com/ClickHouse/ClickHouse/pull/6452) ([阿利沙平](https://github.com/alesapin)) -- 阅读Kafka消息时修复无限循环。 [\#6354](https://github.com/ClickHouse/ClickHouse/pull/6354) ([abyss7](https://github.com/abyss7)) -- 修复了由于SQL解析器中的堆栈溢出和堆栈溢出的可能性而导致服务器崩溃的编造查询的可能性 `Merge` 和 `Distributed` 表 [\#6433](https://github.com/ClickHouse/ClickHouse/pull/6433) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在小序列固定大猩猩编码错误。 [\#6444](https://github.com/ClickHouse/ClickHouse/pull/6444) ([Enmk](https://github.com/Enmk)) - -#### 改进 {#improvement-5} - -- 允许用户复盖 `poll_interval` 和 `idle_connection_timeout` 连接设置。 [\#6230](https://github.com/ClickHouse/ClickHouse/pull/6230) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102003042 {#clickhouse-release-19-11-5-28-2019-08-05} - -#### 错误修复 {#bug-fix-19} - -- 修复了服务器超载时挂起查询的可能性。 [\#6301](https://github.com/ClickHouse/ClickHouse/pull/6301) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复yandexConsistentHash函数中的FPE。 这修复 [\#6304](https://github.com/ClickHouse/ClickHouse/issues/6304). [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误的转换 `LowCardinality` 类型 `AggregateFunctionFactory`. 这修复 [\#6257](https://github.com/ClickHouse/ClickHouse/issues/6257). [\#6281](https://github.com/ClickHouse/ClickHouse/pull/6281) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复解析 `bool` 从设置 `true` 和 `false` 配置文件中的字符串。 [\#6278](https://github.com/ClickHouse/ClickHouse/pull/6278) ([阿利沙平](https://github.com/alesapin)) -- 修复查询中不兼容的流头的罕见错误 `Distributed` 桌子结束 `MergeTree` 表时的一部分 `WHERE` 移动到 `PREWHERE`. [\#6236](https://github.com/ClickHouse/ClickHouse/pull/6236) ([阿利沙平](https://github.com/alesapin)) -- 在有符号类型的整数划分为无符号类型的固定溢出。 这修复 [\#6214](https://github.com/ClickHouse/ClickHouse/issues/6214). [\#6233](https://github.com/ClickHouse/ClickHouse/pull/6233) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 向后不兼容的更改 {#backward-incompatible-change-5} - -- `Kafka` 还是坏了 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-4-24-2019-08-01} - -#### 错误修复 {#bug-fix-20} - -- 修复编写具有自适应粒度的二级索引标记的错误。 [\#6126](https://github.com/ClickHouse/ClickHouse/pull/6126) ([阿利沙平](https://github.com/alesapin)) -- 修复 `WITH ROLLUP` 和 `WITH CUBE` 修饰符 `GROUP BY` 具有两级聚合。 [\#6225](https://github.com/ClickHouse/ClickHouse/pull/6225) ([安东\*波波夫](https://github.com/CurtizJ)) -- 固定挂起 `JSONExtractRaw` 功能。 固定 [\#6195](https://github.com/ClickHouse/ClickHouse/issues/6195) [\#6198](https://github.com/ClickHouse/ClickHouse/pull/6198) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复ExternalLoader::reloadOutdated()中的段错误。 [\#6082](https://github.com/ClickHouse/ClickHouse/pull/6082) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复了服务器可能关闭侦听套接字但不关闭并继续提供剩余查询的情况。 您最终可能会有两个正在运行的clickhouse服务器进程。 有时,服务器可能会返回错误 `bad_function_call` 对于剩余的查询。 [\#6231](https://github.com/ClickHouse/ClickHouse/pull/6231) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了通过ODBC,MySQL,ClickHouse和HTTP初始加载外部字典的更新字段无用和不正确的条件。 这修复 [\#6069](https://github.com/ClickHouse/ClickHouse/issues/6069) [\#6083](https://github.com/ClickHouse/ClickHouse/pull/6083) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在固定不相关的异常转换 `LowCardinality(Nullable)` to not-Nullable column in case if it doesn't contain Nulls (e.g. in query like `SELECT CAST(CAST('Hello' AS LowCardinality(Nullable(String))) AS String)`. [\#6094](https://github.com/ClickHouse/ClickHouse/issues/6094) [\#6119](https://github.com/ClickHouse/ClickHouse/pull/6119) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复非确定性结果 “uniq” 在极少数情况下聚合函数。 该错误存在于所有ClickHouse版本。 [\#6058](https://github.com/ClickHouse/ClickHouse/pull/6058) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- Segfault当我们在函数上设置了一点点太高的CIDR `IPv6CIDRToRange`. [\#6068](https://github.com/ClickHouse/ClickHouse/pull/6068) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 修复了服务器从许多不同上下文中抛出许多异常时的小内存泄漏。 [\#6144](https://github.com/ClickHouse/ClickHouse/pull/6144) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复消费者在订阅之前暂停而之后未恢复的情况。 [\#6075](https://github.com/ClickHouse/ClickHouse/pull/6075) ([伊万](https://github.com/abyss7))请注意,卡夫卡在这个版本中被打破。 -- 从以前的读取操作中清除Kafka数据缓冲区,并且完成了错误操作 [\#6026](https://github.com/ClickHouse/ClickHouse/pull/6026) ([尼古拉](https://github.com/bopohaa))请注意,卡夫卡在这个版本中被打破。 -- 由于 `StorageMergeTree::background_task_handle` 在初始化 `startup()` 该 `MergeTreeBlockOutputStream::write()` 可以尝试在初始化之前使用它。 只需检查它是否被初始化。 [\#6080](https://github.com/ClickHouse/ClickHouse/pull/6080) ([伊万](https://github.com/abyss7)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-6} - -- 新增官方 `rpm` 包. [\#5740](https://github.com/ClickHouse/ClickHouse/pull/5740) ([proller](https://github.com/proller)) ([阿利沙平](https://github.com/alesapin)) -- 添加构建能力 `.rpm` 和 `.tgz` 包 `packager` 脚本 [\#5769](https://github.com/ClickHouse/ClickHouse/pull/5769) ([阿利沙平](https://github.com/alesapin)) -- 修复了 “Arcadia” 构建系统。 [\#6223](https://github.com/ClickHouse/ClickHouse/pull/6223) ([proller](https://github.com/proller)) - -#### 向后不兼容的更改 {#backward-incompatible-change-6} - -- `Kafka` 在这个版本中被打破。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-11-3-11-2019-07-18} - -#### 新功能 {#new-feature-6} - -- 增加了对准备好的语句的支持。 [\#5331](https://github.com/ClickHouse/ClickHouse/pull/5331/) ([亚历山大](https://github.com/sanych73)) [\#5630](https://github.com/ClickHouse/ClickHouse/pull/5630) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `DoubleDelta` 和 `Gorilla` 列编解ecs [\#5600](https://github.com/ClickHouse/ClickHouse/pull/5600) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 已添加 `os_thread_priority` 设置,允许控制 “nice” 操作系统用于调整动态调度优先级的查询处理线程的值。 它需要 `CAP_SYS_NICE` 能力的工作。 这实现了 [\#5858](https://github.com/ClickHouse/ClickHouse/issues/5858) [\#5909](https://github.com/ClickHouse/ClickHouse/pull/5909) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 执行 `_topic`, `_offset`, `_key` kafka引擎的列 [\#5382](https://github.com/ClickHouse/ClickHouse/pull/5382) ([伊万](https://github.com/abyss7))请注意,卡夫卡在这个版本中被打破。 -- 添加聚合函数组合 `-Resample` [\#5590](https://github.com/ClickHouse/ClickHouse/pull/5590) ([hcz](https://github.com/hczhcz)) -- 聚合函数 `groupArrayMovingSum(win_size)(x)` 和 `groupArrayMovingAvg(win_size)(x)`,计算移动和/平均有或没有窗口大小限制。 [\#5595](https://github.com/ClickHouse/ClickHouse/pull/5595) ([inv2004](https://github.com/inv2004)) -- 添加synonim `arrayFlatten` \<-\> `flatten` [\#5764](https://github.com/ClickHouse/ClickHouse/pull/5764) ([hcz](https://github.com/hczhcz)) -- Intergate H3功能 `geoToH3` 从尤伯杯. [\#4724](https://github.com/ClickHouse/ClickHouse/pull/4724) ([Remen Ivan](https://github.com/BHYCHIK)) [\#5805](https://github.com/ClickHouse/ClickHouse/pull/5805) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 错误修复 {#bug-fix-21} - -- 使用异步更新实现DNS缓存。 单独的线程解析所有主机并更新dns缓存(设置 `dns_cache_update_period`). 当主机的ip频繁更改时,它应该有所帮助。 [\#5857](https://github.com/ClickHouse/ClickHouse/pull/5857) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复段错误 `Delta` 影响值小于32位大小的列的编解ec。 该错误导致随机内存损坏。 [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([阿利沙平](https://github.com/alesapin)) -- 修复ttl合并中的段错误与块中的非物理列。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复在检查部分罕见的错误 `LowCardinality` 列。 前情提要 `checkDataPart` 总是失败的一部分 `LowCardinality` 列。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([阿利沙平](https://github.com/alesapin)) -- 避免在服务器线程池已满时挂起连接。 它是从连接重要 `remote` 当连接超时时,表函数或连接到没有副本的分片。 这修复 [\#5878](https://github.com/ClickHouse/ClickHouse/issues/5878) [\#5881](https://github.com/ClickHouse/ClickHouse/pull/5881) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 支持常量参数 `evalMLModel` 功能。 这修复 [\#5817](https://github.com/ClickHouse/ClickHouse/issues/5817) [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了ClickHouse将默认时区确定为 `UCT` 而不是 `UTC`. 这修复 [\#5804](https://github.com/ClickHouse/ClickHouse/issues/5804). [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定缓冲区下溢 `visitParamExtractRaw`. 这修复 [\#5901](https://github.com/ClickHouse/ClickHouse/issues/5901) [\#5902](https://github.com/ClickHouse/ClickHouse/pull/5902) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在分发 `DROP/ALTER/TRUNCATE/OPTIMIZE ON CLUSTER` 查询将直接在leader副本上执行。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([阿利沙平](https://github.com/alesapin)) -- 修复 `coalesce` 为 `ColumnConst` 与 `ColumnNullable` +相关变化. [\#5755](https://github.com/ClickHouse/ClickHouse/pull/5755) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复 `ReadBufferFromKafkaConsumer` 所以它不断阅读新的消息后 `commit()` 即使它之前停滞不前 [\#5852](https://github.com/ClickHouse/ClickHouse/pull/5852) ([伊万](https://github.com/abyss7)) -- 修复 `FULL` 和 `RIGHT` 加入时加入结果 `Nullable` 键在右表. [\#5859](https://github.com/ClickHouse/ClickHouse/pull/5859) ([Artem Zuikov](https://github.com/4ertus2)) -- 可能修复低优先级查询的无限休眠。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复争用条件,这导致某些查询可能不会出现在query\_log后 `SYSTEM FLUSH LOGS` 查询。 [\#5456](https://github.com/ClickHouse/ClickHouse/issues/5456) [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([安东\*波波夫](https://github.com/CurtizJ)) -- 固定 `heap-use-after-free` 由手表引起的ClusterCopier中的警告尝试使用已经删除的复印机对象。 [\#5871](https://github.com/ClickHouse/ClickHouse/pull/5871) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复错误 `StringRef` 由一些实现返回的指针 `IColumn::deserializeAndInsertFromArena`. 这个错误只影响单元测试。 [\#5973](https://github.com/ClickHouse/ClickHouse/pull/5973) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 防止源数组和中间数组连接掩蔽相同名称列的列。 [\#5941](https://github.com/ClickHouse/ClickHouse/pull/5941) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复插入并选择查询MySQL引擎与MySQL样式标识符引用。 [\#5704](https://github.com/ClickHouse/ClickHouse/pull/5704) ([张冬](https://github.com/zhang2014)) -- 现在 `CHECK TABLE` 查询可以与MergeTree引擎系列一起使用。 它返回检查状态和消息,如果任何为每个部分(或文件在simplier引擎的情况下)。 此外,修复获取损坏部分的错误。 [\#5865](https://github.com/ClickHouse/ClickHouse/pull/5865) ([阿利沙平](https://github.com/alesapin)) -- 修复SPLIT\_SHARED\_LIBRARY运行时 [\#5793](https://github.com/ClickHouse/ClickHouse/pull/5793) ([Danila Kutenin](https://github.com/danlark1)) -- 固定时区初始化时 `/etc/localtime` 是一个相对的符号链接,如 `../usr/share/zoneinfo/Europe/Moscow` [\#5922](https://github.com/ClickHouse/ClickHouse/pull/5922) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- clickhouse复印机:修复使用-关机后免费 [\#5752](https://github.com/ClickHouse/ClickHouse/pull/5752) ([proller](https://github.com/proller)) -- 更新 `simdjson`. 修复了一些无效的零字节Json成功解析的问题。 [\#5938](https://github.com/ClickHouse/ClickHouse/pull/5938) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复系统日志的关机 [\#5802](https://github.com/ClickHouse/ClickHouse/pull/5802) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复当invalidate\_query中的条件取决于字典时挂起。 [\#6011](https://github.com/ClickHouse/ClickHouse/pull/6011) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) - -#### 改进 {#improvement-6} - -- 允许群集配置中的无法解析的地址。 它们将被视为不可用,并尝试在每次连接尝试时解决。 这对Kubernetes特别有用。 这修复 [\#5714](https://github.com/ClickHouse/ClickHouse/issues/5714) [\#5924](https://github.com/ClickHouse/ClickHouse/pull/5924) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 关闭空闲TCP连接(默认情况下为一小时超时)。 这对于每台服务器上具有多个分布式表的大型集群尤其重要,因为每台服务器都可能保留与其他服务器的连接池,并且在高峰查询并发之后,连接将停 这修复 [\#5879](https://github.com/ClickHouse/ClickHouse/issues/5879) [\#5880](https://github.com/ClickHouse/ClickHouse/pull/5880) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更好的质量 `topK` 功能。 如果新元素具有更大的权重,则更改了SavingSpace set行为以删除最后一个元素。 [\#5833](https://github.com/ClickHouse/ClickHouse/issues/5833) [\#5850](https://github.com/ClickHouse/ClickHouse/pull/5850) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 与域一起使用的URL函数现在可以在没有方案的情况下适用于不完整的Url [\#5725](https://github.com/ClickHouse/ClickHouse/pull/5725) ([阿利沙平](https://github.com/alesapin)) -- 校验和添加到 `system.parts_columns` 桌子 [\#5874](https://github.com/ClickHouse/ClickHouse/pull/5874) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 已添加 `Enum` 数据类型作为synonim `Enum8` 或 `Enum16`. [\#5886](https://github.com/ClickHouse/ClickHouse/pull/5886) ([dimarub2000](https://github.com/dimarub2000)) -- 全位转置变种 `T64` 编解ec 可能会导致更好的压缩 `zstd`. [\#5742](https://github.com/ClickHouse/ClickHouse/pull/5742) ([Artem Zuikov](https://github.com/4ertus2)) -- 条件 `startsWith` 函数现在可以使用主键。 这修复 [\#5310](https://github.com/ClickHouse/ClickHouse/issues/5310) 和 [\#5882](https://github.com/ClickHouse/ClickHouse/issues/5882) [\#5919](https://github.com/ClickHouse/ClickHouse/pull/5919) ([dimarub2000](https://github.com/dimarub2000)) -- 允许使用 `clickhouse-copier` 通过允许空数据库名称来实现具有交叉复制的群集拓扑。 [\#5745](https://github.com/ClickHouse/ClickHouse/pull/5745) ([纳瓦托洛梅](https://github.com/nvartolomei)) -- 使用 `UTC` 作为系统上的默认时区,而不 `tzdata` (e.g. bare Docker container). Before this patch, error message `Could not determine local time zone` 被打印并且服务器或客户机拒绝启动。 [\#5827](https://github.com/ClickHouse/ClickHouse/pull/5827) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 返回对函数中浮点参数的支持 `quantileTiming` 为了向后兼容性。 [\#5911](https://github.com/ClickHouse/ClickHouse/pull/5911) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在错误消息中显示哪个表缺少列。 [\#5768](https://github.com/ClickHouse/ClickHouse/pull/5768) ([伊万](https://github.com/abyss7)) -- 不允许不同用户使用相同的query\_id运行查询 [\#5430](https://github.com/ClickHouse/ClickHouse/pull/5430) ([proller](https://github.com/proller)) -- 用于向Graphite发送指标的更强大的代码。 它甚至可以在长时间的多重工作 `RENAME TABLE` 操作。 [\#5875](https://github.com/ClickHouse/ClickHouse/pull/5875) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 当ThreadPool无法计划执行任务时,将显示更多信息错误消息。 这修复 [\#5305](https://github.com/ClickHouse/ClickHouse/issues/5305) [\#5801](https://github.com/ClickHouse/ClickHouse/pull/5801) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 反转ngramSearch更直观 [\#5807](https://github.com/ClickHouse/ClickHouse/pull/5807) ([Danila Kutenin](https://github.com/danlark1)) -- 在HDFS引擎生成器中添加用户解析 [\#5946](https://github.com/ClickHouse/ClickHouse/pull/5946) ([akonyaev90](https://github.com/akonyaev90)) -- 更新默认值 `max_ast_elements parameter` [\#5933](https://github.com/ClickHouse/ClickHouse/pull/5933) ([Artem Konovalov](https://github.com/izebit)) -- 增加了过时设置的概念。 过时的设置 `allow_experimental_low_cardinality_type` 可以没有效果使用。 [0f15c01c6802f7ce1a1494c12c846be8c98944cd](https://github.com/ClickHouse/ClickHouse/commit/0f15c01c6802f7ce1a1494c12c846be8c98944cd) [Alexey Milovidov](https://github.com/alexey-milovidov) - -#### 性能改进 {#performance-improvement-4} - -- 增加从合并表中选择的流数量,以便更均匀地分布线程。 添加设置 `max_streams_multiplier_for_merge_tables`. 这修复 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5915](https://github.com/ClickHouse/ClickHouse/pull/5915) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-7} - -- 为与不同版本的clickhouse的客户端-服务器交互添加向后兼容性测试。 [\#5868](https://github.com/ClickHouse/ClickHouse/pull/5868) ([阿利沙平](https://github.com/alesapin)) -- 每个提交和拉取请求中的测试复盖率信息。 [\#5896](https://github.com/ClickHouse/ClickHouse/pull/5896) ([阿利沙平](https://github.com/alesapin)) -- 与address sanitizer合作,支持我们的自定义分alloc (`Arena` 和 `ArenaWithFreeLists`)为了更好地调试 “use-after-free” 错误。 [\#5728](https://github.com/ClickHouse/ClickHouse/pull/5728) ([akuzm](https://github.com/akuzm)) -- 切换到 [LLVM libunwind实现](https://github.com/llvm-mirror/libunwind) 用于C++异常处理和堆栈跟踪打印 [\#4828](https://github.com/ClickHouse/ClickHouse/pull/4828) ([尼基塔\*拉普科夫](https://github.com/laplab)) -- 添加来自-Weverything的两个警告 [\#5923](https://github.com/ClickHouse/ClickHouse/pull/5923) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 允许用内存消毒剂建立ClickHouse。 [\#3949](https://github.com/ClickHouse/ClickHouse/pull/3949) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 关于固定的ubsan报告 `bitTest` 在模糊测试功能。 [\#5943](https://github.com/ClickHouse/ClickHouse/pull/5943) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- Docker:增加了初始化需要身份验证的ClickHouse实例的可能性。 [\#5727](https://github.com/ClickHouse/ClickHouse/pull/5727) ([科尔维亚科夫\*安德烈](https://github.com/shurshun)) -- 将librdkafka更新到版本1.1.0 [\#5872](https://github.com/ClickHouse/ClickHouse/pull/5872) ([伊万](https://github.com/abyss7)) -- 为集成测试添加全局超时,并在测试代码中禁用其中一些。 [\#5741](https://github.com/ClickHouse/ClickHouse/pull/5741) ([阿利沙平](https://github.com/alesapin)) -- 修复一些ThreadSanitizer故障。 [\#5854](https://github.com/ClickHouse/ClickHouse/pull/5854) ([akuzm](https://github.com/akuzm)) -- 该 `--no-undefined` 选项强制链接器在链接时检查所有外部名称是否存在。 在拆分构建模式下跟踪库之间的真实依赖关系非常有用。 [\#5855](https://github.com/ClickHouse/ClickHouse/pull/5855) ([伊万](https://github.com/abyss7)) -- 增加了性能测试 [\#5797](https://github.com/ClickHouse/ClickHouse/issues/5797) [\#5914](https://github.com/ClickHouse/ClickHouse/pull/5914) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 与gcc-7固定兼容性。 [\#5840](https://github.com/ClickHouse/ClickHouse/pull/5840) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了对gcc-9的支持。 这修复 [\#5717](https://github.com/ClickHouse/ClickHouse/issues/5717) [\#5774](https://github.com/ClickHouse/ClickHouse/pull/5774) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了libunwind链接不正确时的错误。 [\#5948](https://github.com/ClickHouse/ClickHouse/pull/5948) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了PVS-Studio发现的一些警告。 [\#5921](https://github.com/ClickHouse/ClickHouse/pull/5921) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了初始支持 `clang-tidy` 静态分析仪。 [\#5806](https://github.com/ClickHouse/ClickHouse/pull/5806) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 转换BSD/Linux endian宏( ‘be64toh’ 和 ‘htobe64’)到Mac OS x当量 [\#5785](https://github.com/ClickHouse/ClickHouse/pull/5785) ([傅辰](https://github.com/fredchenbj)) -- 改进的集成测试指南. [\#5796](https://github.com/ClickHouse/ClickHouse/pull/5796) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 在macosx+gcc9修复构建 [\#5822](https://github.com/ClickHouse/ClickHouse/pull/5822) ([filimonov](https://github.com/filimonov)) -- 修复难以识别的错字:aggreAGte-\>aggregate。 [\#5753](https://github.com/ClickHouse/ClickHouse/pull/5753) ([akuzm](https://github.com/akuzm)) -- 修复freebsd构建 [\#5760](https://github.com/ClickHouse/ClickHouse/pull/5760) ([proller](https://github.com/proller)) -- 添加链接到实验YouTube频道的网站 [\#5845](https://github.com/ClickHouse/ClickHouse/pull/5845) ([伊万\*布林科夫](https://github.com/blinkov)) -- CMake:为复盖率标志添加选项:WITH\_COVERAGE [\#5776](https://github.com/ClickHouse/ClickHouse/pull/5776) ([proller](https://github.com/proller)) -- 修复一些内联PODArray的初始大小。 [\#5787](https://github.com/ClickHouse/ClickHouse/pull/5787) ([akuzm](https://github.com/akuzm)) -- clickhouse服务器.postinst:修复centos6的操作系统检测 [\#5788](https://github.com/ClickHouse/ClickHouse/pull/5788) ([proller](https://github.com/proller)) -- 添加Arch linux软件包生成。 [\#5719](https://github.com/ClickHouse/ClickHouse/pull/5719) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 拆分常见/配置.h by libs(dbms) [\#5715](https://github.com/ClickHouse/ClickHouse/pull/5715) ([proller](https://github.com/proller)) -- 修复了 “Arcadia” 构建平台 [\#5795](https://github.com/ClickHouse/ClickHouse/pull/5795) ([proller](https://github.com/proller)) -- 修复了非常规构建(gcc9,没有子模块) [\#5792](https://github.com/ClickHouse/ClickHouse/pull/5792) ([proller](https://github.com/proller)) -- 在unalignedStore中需要显式类型,因为它被证明容易出现错误 [\#5791](https://github.com/ClickHouse/ClickHouse/pull/5791) ([akuzm](https://github.com/akuzm)) -- 修复MacOS构建 [\#5830](https://github.com/ClickHouse/ClickHouse/pull/5830) ([filimonov](https://github.com/filimonov)) -- 关于具有更大数据集的新JIT功能的性能测试,请参阅此处 [\#5263](https://github.com/ClickHouse/ClickHouse/issues/5263) [\#5887](https://github.com/ClickHouse/ClickHouse/pull/5887) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 在压力测试中运行有状态测试 [12693e568722f11e19859742f56428455501fd2a](https://github.com/ClickHouse/ClickHouse/commit/12693e568722f11e19859742f56428455501fd2a) ([阿利沙平](https://github.com/alesapin)) - -#### 向后不兼容的更改 {#backward-incompatible-change-7} - -- `Kafka` 在这个版本中被打破。 -- 启用 `adaptive_index_granularity` =10mb默认为新 `MergeTree` 桌子 如果您在19.11+版本上创建了新的MergeTree表,则不可能降级到19.6之前的版本。 [\#5628](https://github.com/ClickHouse/ClickHouse/pull/5628) ([阿利沙平](https://github.com/alesapin)) -- 删除了Yandex使用的过时无证嵌入式字典。梅特里卡 功能 `OSIn`, `SEIn`, `OSToRoot`, `SEToRoot`, `OSHierarchy`, `SEHierarchy` 不再可用。 如果您正在使用这些功能,请写电子邮件至clickhouse-feedback@yandex-team.com注:在最后时刻,我们决定保持这些功能一段时间。 [\#5780](https://github.com/ClickHouse/ClickHouse/pull/5780) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -## ClickHouse释放19.10 {#clickhouse-release-19-10} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-10-1-5-2019-07-12} - -#### 新功能 {#new-feature-7} - -- 添加新列编解ec: `T64`. 为(U)IntX/EnumX/Data(时间)/DecimalX列制作。 它应该适用于具有常量或小范围值的列。 编解码器本身允许放大或缩小数据类型而无需重新压缩。 [\#5557](https://github.com/ClickHouse/ClickHouse/pull/5557) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加数据库引擎 `MySQL` 允许查看远程MySQL服务器中的所有表 [\#5599](https://github.com/ClickHouse/ClickHouse/pull/5599) ([张冬](https://github.com/zhang2014)) -- `bitmapContains` 执行。 这是2倍的速度比 `bitmapHasAny` 如果第二个位图包含一个元素。 [\#5535](https://github.com/ClickHouse/ClickHouse/pull/5535) ([余志昌](https://github.com/yuzhichang)) -- 支持 `crc32` 功能(与MySQL或PHP中的行为完全相同)。 如果您需要散列函数,请不要使用它。 [\#5661](https://github.com/ClickHouse/ClickHouse/pull/5661) ([Remen Ivan](https://github.com/BHYCHIK)) -- 已实施 `SYSTEM START/STOP DISTRIBUTED SENDS` 查询控制异步插入到 `Distributed` 桌子 [\#4935](https://github.com/ClickHouse/ClickHouse/pull/4935) ([张冬](https://github.com/zhang2014)) - -#### 错误修复 {#bug-fix-22} - -- 在执行突变时忽略查询执行限制和合并限制的最大部件大小。 [\#5659](https://github.com/ClickHouse/ClickHouse/pull/5659) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复可能导致重复数据删除正常块(极其罕见)和插入重复块(更常见)的错误。 [\#5549](https://github.com/ClickHouse/ClickHouse/pull/5549) ([阿利沙平](https://github.com/alesapin)) -- 功能修复 `arrayEnumerateUniqRanked` 对于具有空数组的参数 [\#5559](https://github.com/ClickHouse/ClickHouse/pull/5559) ([proller](https://github.com/proller)) -- 不要在没有轮询任何消息的情况下订阅Kafka主题。 [\#5698](https://github.com/ClickHouse/ClickHouse/pull/5698) ([伊万](https://github.com/abyss7)) -- 使设置 `join_use_nulls` 对于不能在Nullable内的类型不起作用 [\#5700](https://github.com/ClickHouse/ClickHouse/pull/5700) ([Olga Khvostikova](https://github.com/stavrolia)) -- 固定 `Incorrect size of index granularity` 错误 [\#5720](https://github.com/ClickHouse/ClickHouse/pull/5720) ([coraxster](https://github.com/coraxster)) -- 修正浮动到十进制转换溢出 [\#5607](https://github.com/ClickHouse/ClickHouse/pull/5607) ([coraxster](https://github.com/coraxster)) -- 冲洗缓冲区时 `WriteBufferFromHDFS`的析构函数被调用。 这修复了写入 `HDFS`. [\#5684](https://github.com/ClickHouse/ClickHouse/pull/5684) ([新东鹏](https://github.com/eejoin)) - -#### 改进 {#improvement-7} - -- 对待空单元格 `CSV` 作为默认值时的设置 `input_format_defaults_for_omitted_fields` 被启用。 [\#5625](https://github.com/ClickHouse/ClickHouse/pull/5625) ([akuzm](https://github.com/akuzm)) -- 外部字典的非阻塞加载。 [\#5567](https://github.com/ClickHouse/ClickHouse/pull/5567) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 可以根据设置动态更改已建立的连接的网络超时。 [\#4558](https://github.com/ClickHouse/ClickHouse/pull/4558) ([Konstantin Podshumok](https://github.com/podshumok)) -- 使用 “public\_suffix\_list” 对于功能 `firstSignificantSubdomain`, `cutToFirstSignificantSubdomain`. 它使用一个完美的哈希表生成 `gperf` 从文件生成的列表:https://publicsuffix.org/list/public\_suffix\_list.dat(例如,现在我们认识到域 `ac.uk` 作为非显着)。 [\#5030](https://github.com/ClickHouse/ClickHouse/pull/5030) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 通过 `IPv6` 系统表中的数据类型;统一客户端信息列 `system.processes` 和 `system.query_log` [\#5640](https://github.com/ClickHouse/ClickHouse/pull/5640) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用会话与MySQL兼容性协议的连接。 \#5476 [\#5646](https://github.com/ClickHouse/ClickHouse/pull/5646) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 支持更多 `ALTER` 查询 `ON CLUSTER`. [\#5593](https://github.com/ClickHouse/ClickHouse/pull/5593) [\#5613](https://github.com/ClickHouse/ClickHouse/pull/5613) ([sundyli](https://github.com/sundy-li)) -- 碌莽禄Support: `` 第1节 `clickhouse-local` 配置文件。 [\#5540](https://github.com/ClickHouse/ClickHouse/pull/5540) ([proller](https://github.com/proller)) -- 允许运行查询 `remote` 表函数 `clickhouse-local` [\#5627](https://github.com/ClickHouse/ClickHouse/pull/5627) ([proller](https://github.com/proller)) - -#### 性能改进 {#performance-improvement-5} - -- 添加在MergeTree列末尾写最后标记的可能性。 它允许避免对超出表数据范围的键进行无用的读取。 仅当使用自适应索引粒度时才启用此功能。 [\#5624](https://github.com/ClickHouse/ClickHouse/pull/5624) ([阿利沙平](https://github.com/alesapin)) -- 通过减少非常慢的文件系统上的MergeTree表的性能 `stat` syscalls [\#5648](https://github.com/ClickHouse/ClickHouse/pull/5648) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了从版本19.6中引入的MergeTree表读取时的性能下降。 修复#5631。 [\#5633](https://github.com/ClickHouse/ClickHouse/pull/5633) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-8} - -- 已实施 `TestKeeper` 作为用于测试的ZooKeeper接口的实现 [\#5643](https://github.com/ClickHouse/ClickHouse/pull/5643) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) ([levushkin aleksej](https://github.com/alexey-milovidov)) -- 从现在起 `.sql` 测试可以通过服务器隔离,并行运行,并使用随机数据库。 它允许更快地运行它们,使用自定义服务器配置添加新的测试,并确保不同的测试不会相互影响。 [\#5554](https://github.com/ClickHouse/ClickHouse/pull/5554) ([伊万](https://github.com/abyss7)) -- 删除 `` 和 `` 从性能测试 [\#5672](https://github.com/ClickHouse/ClickHouse/pull/5672) ([Olga Khvostikova](https://github.com/stavrolia)) -- 固定 “select\_format” 性能测试 `Pretty` 格式 [\#5642](https://github.com/ClickHouse/ClickHouse/pull/5642) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -## ClickHouse释放19.9 {#clickhouse-release-19-9} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-9-3-31-2019-07-05} - -#### 错误修复 {#bug-fix-23} - -- 修复增量编解码器中的段错误,这会影响值小于32位大小的列。 该错误导致随机内存损坏。 [\#5786](https://github.com/ClickHouse/ClickHouse/pull/5786) ([阿利沙平](https://github.com/alesapin)) -- 修复在检查部分低心率列中罕见的错误。 [\#5832](https://github.com/ClickHouse/ClickHouse/pull/5832) ([阿利沙平](https://github.com/alesapin)) -- 修复ttl合并中的段错误与块中的非物理列。 [\#5819](https://github.com/ClickHouse/ClickHouse/pull/5819) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复低优先级查询的潜在无限休眠。 [\#5842](https://github.com/ClickHouse/ClickHouse/pull/5842) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复ClickHouse如何将默认时区确定为UCT而不是UTC。 [\#5828](https://github.com/ClickHouse/ClickHouse/pull/5828) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复在领导者副本之前的跟随者副本上执行分布式删除/更改/截断/优化集群查询的错误。 现在他们将直接在领导者副本上执行。 [\#5757](https://github.com/ClickHouse/ClickHouse/pull/5757) ([阿利沙平](https://github.com/alesapin)) -- 修复了系统刷新日志查询后某些查询可能不会立即出现在query\_log中的竞争条件。 [\#5685](https://github.com/ClickHouse/ClickHouse/pull/5685) ([安东\*波波夫](https://github.com/CurtizJ)) -- 增加了对常量参数的缺失支持 `evalMLModel` 功能。 [\#5820](https://github.com/ClickHouse/ClickHouse/pull/5820) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-9-2-4-2019-06-24} - -#### 新功能 {#new-feature-8} - -- 打印有关冷冻部件的信息 `system.parts` 桌子 [\#5471](https://github.com/ClickHouse/ClickHouse/pull/5471) ([proller](https://github.com/proller)) -- 在clickhouse上询问客户端密码-如果未在参数中设置,则在tty上启动客户端 [\#5092](https://github.com/ClickHouse/ClickHouse/pull/5092) ([proller](https://github.com/proller)) -- 执行 `dictGet` 和 `dictGetOrDefault` 十进制类型的函数。 [\#5394](https://github.com/ClickHouse/ClickHouse/pull/5394) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 改进 {#improvement-8} - -- Debian的初始化:添加服务停止超时 [\#5522](https://github.com/ClickHouse/ClickHouse/pull/5522) ([proller](https://github.com/proller)) -- 默认情况下添加禁止设置,以创建具有可疑类型的表格 [\#5448](https://github.com/ClickHouse/ClickHouse/pull/5448) ([Olga Khvostikova](https://github.com/stavrolia)) -- 当不用作函数中的状态时,回归函数返回模型权重 `evalMLMethod`. [\#5411](https://github.com/ClickHouse/ClickHouse/pull/5411) ([Quid37](https://github.com/Quid37)) -- 重命名和改进回归方法。 [\#5492](https://github.com/ClickHouse/ClickHouse/pull/5492) ([Quid37](https://github.com/Quid37)) -- 更清晰的字符串搜索界面。 [\#5586](https://github.com/ClickHouse/ClickHouse/pull/5586) ([Danila Kutenin](https://github.com/danlark1)) - -#### 错误修复 {#bug-fix-24} - -- 修复Kafka中潜在的数据丢失 [\#5445](https://github.com/ClickHouse/ClickHouse/pull/5445) ([伊万](https://github.com/abyss7)) -- 修复潜在的无限循环 `PrettySpace` 使用零列调用时的格式 [\#5560](https://github.com/ClickHouse/ClickHouse/pull/5560) ([Olga Khvostikova](https://github.com/stavrolia)) -- 修正了线性模型中的UInt32溢出错误。 允许对非常量模型参数的eval ML模型。 [\#5516](https://github.com/ClickHouse/ClickHouse/pull/5516) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- `ALTER TABLE ... DROP INDEX IF EXISTS ...` 如果提供的索引不存在,则不应引发异常 [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) -- 修复段错误 `bitmapHasAny` 在标量子查询中 [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([余志昌](https://github.com/yuzhichang)) -- 修复了复制连接池不重试解析主机时的错误,即使删除了DNS缓存。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([阿利沙平](https://github.com/alesapin)) -- 固定 `ALTER ... MODIFY TTL` 在ReplicatedMergeTree上。 [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复插入到具体化列的分布式表中 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) -- 修复截断联接存储时的错误alloc [\#5437](https://github.com/ClickHouse/ClickHouse/pull/5437) ([TCeason](https://github.com/TCeason)) -- 在最近版本的包tzdata中,现在有些文件是符号链接。 当前用于检测默认时区的机制被打破,并为某些时区提供错误的名称。 现在至少我们强制时区名称到TZ的内容,如果提供。 [\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([伊万](https://github.com/abyss7)) -- 修复一些极为罕见的情况下,MultiVolnitsky搜索器时,在总和恒定针至少16KB长。 该算法错过或复盖以前的结果,这可能导致错误的结果 `multiSearchAny`. [\#5588](https://github.com/ClickHouse/ClickHouse/pull/5588) ([Danila Kutenin](https://github.com/danlark1)) -- 修复ExternalData请求的设置无法使用ClickHouse设置时的问题。 此外,现在,设置 `date_time_input_format` 和 `low_cardinality_allow_in_native_format` 由于名称的歧义,无法使用(在外部数据中,它可以解释为表格式,在查询中它可以是一个设置)。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila Kutenin](https://github.com/danlark1)) -- 修复只从FS中删除部件而不从Zookeeper中删除部件时的错误。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([阿利沙平](https://github.com/alesapin)) -- 从MySQL协议中删除调试日志记录 [\#5478](https://github.com/ClickHouse/ClickHouse/pull/5478) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在DDL查询处理过程中跳过ZNONODE [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) -- 修复混合 `UNION ALL` 结果列类型。 有些情况下,结果列的数据和列类型不一致。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) -- 在错误的整数上抛出异常 `dictGetT` 功能,而不是崩溃。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复散列字典中错误的element\_count和load\_factor `system.dictionaries` 桌子 [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-9} - -- 固定构建没有 `Brotli` HTTP压缩支持 (`ENABLE_BROTLI=OFF` cmake变量)。 [\#5521](https://github.com/ClickHouse/ClickHouse/pull/5521) ([Anton Yuzhaninov](https://github.com/citrin)) -- 包括ro哮。h为ro哮/咆哮。h [\#5523](https://github.com/ClickHouse/ClickHouse/pull/5523) ([Origej Desh](https://github.com/orivej)) -- 修复超扫描中的gcc9警告(#行指令是邪恶的!) [\#5546](https://github.com/ClickHouse/ClickHouse/pull/5546) ([Danila Kutenin](https://github.com/danlark1)) -- 使用gcc-9编译时修复所有警告。 修复一些contrib问题。 修复gcc9ICE并将其提交给bugzilla。 [\#5498](https://github.com/ClickHouse/ClickHouse/pull/5498) ([Danila Kutenin](https://github.com/danlark1)) -- 与lld固定链接 [\#5477](https://github.com/ClickHouse/ClickHouse/pull/5477) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除字典中未使用的专业化 [\#5452](https://github.com/ClickHouse/ClickHouse/pull/5452) ([Artem Zuikov](https://github.com/4ertus2)) -- 针对不同类型的文件进行格式化和解析表的改进性能测试 [\#5497](https://github.com/ClickHouse/ClickHouse/pull/5497) ([Olga Khvostikova](https://github.com/stavrolia)) -- 修复并行测试运行 [\#5506](https://github.com/ClickHouse/ClickHouse/pull/5506) ([proller](https://github.com/proller)) -- Docker:使用clickhouse-test中的configs [\#5531](https://github.com/ClickHouse/ClickHouse/pull/5531) ([proller](https://github.com/proller)) -- 修复编译为FreeBSD [\#5447](https://github.com/ClickHouse/ClickHouse/pull/5447) ([proller](https://github.com/proller)) -- 升级提升到1.70 [\#5570](https://github.com/ClickHouse/ClickHouse/pull/5570) ([proller](https://github.com/proller)) -- 修复构建clickhouse作为子模块 [\#5574](https://github.com/ClickHouse/ClickHouse/pull/5574) ([proller](https://github.com/proller)) -- 改进JSONExtract性能测试 [\#5444](https://github.com/ClickHouse/ClickHouse/pull/5444) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) - -## ClickHouse释放19.8 {#clickhouse-release-19-8} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-8-3-8-2019-06-11} - -#### 新功能 {#new-features} - -- 添加了与JSON一起使用的函数 [\#4686](https://github.com/ClickHouse/ClickHouse/pull/4686) ([hcz](https://github.com/hczhcz)) [\#5124](https://github.com/ClickHouse/ClickHouse/pull/5124). ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 添加一个函数basename,具有类似于basename函数的行为,它存在于许多语言中 (`os.path.basename` 在python中, `basename` in PHP, etc…). Work with both an UNIX-like path or a Windows path. [\#5136](https://github.com/ClickHouse/ClickHouse/pull/5136) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 已添加 `LIMIT n, m BY` 或 `LIMIT m OFFSET n BY` 为LIMIT BY子句设置n偏移量的语法。 [\#5138](https://github.com/ClickHouse/ClickHouse/pull/5138) ([安东\*波波夫](https://github.com/CurtizJ)) -- 增加了新的数据类型 `SimpleAggregateFunction`,它允许在一个具有光聚集的列 `AggregatingMergeTree`. 这只能用于简单的功能,如 `any`, `anyLast`, `sum`, `min`, `max`. [\#4629](https://github.com/ClickHouse/ClickHouse/pull/4629) ([Boris Granveaud](https://github.com/bgranvea)) -- 增加了对函数中非常量参数的支持 `ngramDistance` [\#5198](https://github.com/ClickHouse/ClickHouse/pull/5198) ([Danila Kutenin](https://github.com/danlark1)) -- 新增功能 `skewPop`, `skewSamp`, `kurtPop` 和 `kurtSamp` 分别计算序列偏度、样本偏度、峰度和样本峰度。 [\#5200](https://github.com/ClickHouse/ClickHouse/pull/5200) ([hcz](https://github.com/hczhcz)) -- 支持重命名操作 `MaterializeView` 存储。 [\#5209](https://github.com/ClickHouse/ClickHouse/pull/5209) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 添加了允许使用MySQL客户端连接到ClickHouse的服务器。 [\#4715](https://github.com/ClickHouse/ClickHouse/pull/4715) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 添加 `toDecimal*OrZero` 和 `toDecimal*OrNull` 功能。 [\#5291](https://github.com/ClickHouse/ClickHouse/pull/5291) ([Artem Zuikov](https://github.com/4ertus2)) -- 支持函数中的十进制类型: `quantile`, `quantiles`, `median`, `quantileExactWeighted`, `quantilesExactWeighted` 媒体加权。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) -- 已添加 `toValidUTF8` function, which replaces all invalid UTF-8 characters by replacement character � (U+FFFD). [\#5322](https://github.com/ClickHouse/ClickHouse/pull/5322) ([Danila Kutenin](https://github.com/danlark1)) -- 已添加 `format` 功能。 使用参数中列出的字符串格式化常量模式(简化的Python格式模式)。 [\#5330](https://github.com/ClickHouse/ClickHouse/pull/5330) ([Danila Kutenin](https://github.com/danlark1)) -- 已添加 `system.detached_parts` 表包含有关分离部分的信息 `MergeTree` 桌子 [\#5353](https://github.com/ClickHouse/ClickHouse/pull/5353) ([akuzm](https://github.com/akuzm)) -- 已添加 `ngramSearch` 函数来计算针和大海捞针之间的非对称差异。 [\#5418](https://github.com/ClickHouse/ClickHouse/pull/5418)[\#5422](https://github.com/ClickHouse/ClickHouse/pull/5422) ([Danila Kutenin](https://github.com/danlark1)) -- 使用聚合函数接口实现基本的机器学习方法(随机线性回归和逻辑回归)。 有不同的策略,用于更新模型权重(简单梯度下降,动量法,涅斯捷罗夫法)。 还支持自定义大小的小批次。 [\#4943](https://github.com/ClickHouse/ClickHouse/pull/4943) ([Quid37](https://github.com/Quid37)) -- 执行 `geohashEncode` 和 `geohashDecode` 功能。 [\#5003](https://github.com/ClickHouse/ClickHouse/pull/5003) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 添加聚合功能 `timeSeriesGroupSum`,从而可以聚合不同的时间序列,即采样时间戳不对齐。 它将在两个采样时间戳之间使用线性插值,然后将时间序列和在一起。 添加聚合功能 `timeSeriesGroupRateSum`,它计算时间序列的速率,然后将速率总和在一起。 [\#4542](https://github.com/ClickHouse/ClickHouse/pull/4542) ([刘杨宽](https://github.com/LiuYangkuan)) -- 新增功能 `IPv4CIDRtoIPv4Range` 和 `IPv6CIDRtoIPv6Range` 使用CIDR计算子网中IP的下限和上限。 [\#5095](https://github.com/ClickHouse/ClickHouse/pull/5095) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 添加一个X-ClickHouse-Summary头,当我们发送查询使用HTTP启用设置 `send_progress_in_http_headers`. 返回X-ClickHouse-Progress的常用信息,以及其他信息,例如在查询中插入了多少行和字节。 [\#5116](https://github.com/ClickHouse/ClickHouse/pull/5116) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) - -#### 改进 {#improvements} - -- 已添加 `max_parts_in_total` 设置表的MergeTree家族(默认:100 000)防止分区键的不安全规范\#5166. [\#5171](https://github.com/ClickHouse/ClickHouse/pull/5171) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `clickhouse-obfuscator`:通过将初始种子与列名(而不是列位置)组合来派生单个列的种子。 这用于转换具有多个相关表的数据集,以便在转换后表将保持可联接。 [\#5178](https://github.com/ClickHouse/ClickHouse/pull/5178) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 新增功能 `JSONExtractRaw`, `JSONExtractKeyAndValues`. 重命名函数 `jsonExtract` 到 `JSONExtract`. 当出现问题时,这些函数返回对应的值,而不是 `NULL`. 修改功能 `JSONExtract`,现在它从最后一个参数中获取返回类型,并且不会注入nullables。 在AVX2指令不可用的情况下实现了回退到RapidJSON。 Simdjson库更新到新版本。 [\#5235](https://github.com/ClickHouse/ClickHouse/pull/5235) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 现在 `if` 和 `multiIf` 功能不依赖于条件的 `Nullable`,但依靠分支来实现sql兼容性。 [\#5238](https://github.com/ClickHouse/ClickHouse/pull/5238) ([吴健](https://github.com/janplus)) -- `In` 谓词现在生成 `Null` 结果来自 `Null` 输入像 `Equal` 功能。 [\#5152](https://github.com/ClickHouse/ClickHouse/pull/5152) ([吴健](https://github.com/janplus)) -- 检查来自Kafka的每个(flush\_interval/poll\_timeout)行数的时间限制。 这允许更频繁地中断Kafka consumer的读取,并检查顶级流的时间限制 [\#5249](https://github.com/ClickHouse/ClickHouse/pull/5249) ([伊万](https://github.com/abyss7)) -- 链接rdkafka捆绑的SASL。 它应该允许使用SASL SCRAM身份验证 [\#5253](https://github.com/ClickHouse/ClickHouse/pull/5253) ([伊万](https://github.com/abyss7)) -- 所有联接的RowRefList的批处理版本。 [\#5267](https://github.com/ClickHouse/ClickHouse/pull/5267) ([Artem Zuikov](https://github.com/4ertus2)) -- clickhouse服务器:更多信息侦听错误消息。 [\#5268](https://github.com/ClickHouse/ClickHouse/pull/5268) ([proller](https://github.com/proller)) -- 在clickhouse-复印机的功能支持字典 `` [\#5270](https://github.com/ClickHouse/ClickHouse/pull/5270) ([proller](https://github.com/proller)) -- 添加新设置 `kafka_commit_every_batch` 来规范卡夫卡的承诺政策。 - 它允许设置提交模式:在处理每批消息之后,或者在整个块写入存储之后。 这是在某些极端情况下丢失一些消息或阅读两次之间的权衡。 [\#5308](https://github.com/ClickHouse/ClickHouse/pull/5308) ([伊万](https://github.com/abyss7)) -- 赂眉露\>\> `windowFunnel` 支持其他无符号整数类型。 [\#5320](https://github.com/ClickHouse/ClickHouse/pull/5320) ([sundyli](https://github.com/sundy-li)) -- 允许对虚拟列进行阴影 `_table` 在合并引擎。 [\#5325](https://github.com/ClickHouse/ClickHouse/pull/5325) ([伊万](https://github.com/abyss7)) -- 赂眉露\>\> `sequenceMatch` 聚合函数支持其他无符号整数类型 [\#5339](https://github.com/ClickHouse/ClickHouse/pull/5339) ([sundyli](https://github.com/sundy-li)) -- 如果校验和不匹配很可能是由硬件故障引起的,则更好的错误消息。 [\#5355](https://github.com/ClickHouse/ClickHouse/pull/5355) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 检查基础表是否支持以下内容的采样 `StorageMerge` [\#5366](https://github.com/ClickHouse/ClickHouse/pull/5366) ([伊万](https://github.com/abyss7)) -- Сlose MySQL connections after their usage in external dictionaries. It is related to issue \#893. [\#5395](https://github.com/ClickHouse/ClickHouse/pull/5395) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- MySQL线协议的改进。 将格式名称更改为MySQLWire。 使用RAII调用RSA\_free。 如果无法创建上下文,则禁用SSL。 [\#5419](https://github.com/ClickHouse/ClickHouse/pull/5419) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- clickhouse-client: allow to run with unaccessable history file (read-only, no disk space, file is directory, …). [\#5431](https://github.com/ClickHouse/ClickHouse/pull/5431) ([proller](https://github.com/proller)) -- 尊重异步插入到分布式表中的查询设置。 [\#4936](https://github.com/ClickHouse/ClickHouse/pull/4936) ([TCeason](https://github.com/TCeason)) -- 重命名函数 `leastSqr` 到 `simpleLinearRegression`, `LinearRegression` 到 `linearRegression`, `LogisticRegression` 到 `logisticRegression`. [\#5391](https://github.com/ClickHouse/ClickHouse/pull/5391) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -#### 性能改进 {#performance-improvements} - -- 在ALTER MODIFY查询中并行处理非复制MergeTree表的部分。 [\#4639](https://github.com/ClickHouse/ClickHouse/pull/4639) ([伊万库什](https://github.com/IvanKush)) -- Regular达式提取中的优化。 [\#5193](https://github.com/ClickHouse/ClickHouse/pull/5193) [\#5191](https://github.com/ClickHouse/ClickHouse/pull/5191) ([Danila Kutenin](https://github.com/danlark1)) -- 如果仅在join on部分中使用,则不要将右连接键列添加到join result。 [\#5260](https://github.com/ClickHouse/ClickHouse/pull/5260) ([Artem Zuikov](https://github.com/4ertus2)) -- 在第一个空响应之后冻结Kafka缓冲区。 它避免了多次调用 `ReadBuffer::next()` 对于一些行解析流的空结果。 [\#5283](https://github.com/ClickHouse/ClickHouse/pull/5283) ([伊万](https://github.com/abyss7)) -- `concat` 多个参数的函数优化。 [\#5357](https://github.com/ClickHouse/ClickHouse/pull/5357) ([Danila Kutenin](https://github.com/danlark1)) -- Query optimisation. Allow push down IN statement while rewriting commа/cross join into inner one. [\#5396](https://github.com/ClickHouse/ClickHouse/pull/5396) ([Artem Zuikov](https://github.com/4ertus2)) -- 使用reference one升级我们的LZ4实现以获得更快的解压缩。 [\#5070](https://github.com/ClickHouse/ClickHouse/pull/5070) ([Danila Kutenin](https://github.com/danlark1)) -- 实现了MSD基数排序(基于kxsort)和部分排序。 [\#5129](https://github.com/ClickHouse/ClickHouse/pull/5129) ([Evgenii Pravda](https://github.com/kvinty)) - -#### 错误修复 {#bug-fixes} - -- 修复推送需要列与联接 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([张冬](https://github.com/zhang2014)) -- 修正了当ClickHouse由systemd运行时,命令 `sudo service clickhouse-server forcerestart` 没有按预期工作。 [\#5204](https://github.com/ClickHouse/ClickHouse/pull/5204) ([proller](https://github.com/proller)) -- 修复DataPartsExchange中的http错误代码(9009端口上的服务器间http服务器始终返回代码200,即使是错误)。 [\#5216](https://github.com/ClickHouse/ClickHouse/pull/5216) ([proller](https://github.com/proller)) -- 修复SimpleAggregateFunction字符串长于MAX\_SMALL\_STRING\_SIZE [\#5311](https://github.com/ClickHouse/ClickHouse/pull/5311) ([Azat Khuzhin](https://github.com/azat)) -- 修复错误 `Decimal` 到 `Nullable(Decimal)` 转换中。 支持其他十进制到十进制转换(包括不同的比例)。 [\#5350](https://github.com/ClickHouse/ClickHouse/pull/5350) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正了simdjson库中导致错误计算的FPU clobbering `uniqHLL` 和 `uniqCombined` 聚合函数和数学函数,如 `log`. [\#5354](https://github.com/ClickHouse/ClickHouse/pull/5354) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定处理JSON函数中的混合常量/非常量情况。 [\#5435](https://github.com/ClickHouse/ClickHouse/pull/5435) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复 `retention` 功能。 现在所有满足一行数据的条件都被添加到数据状态。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) -- 修复结果类型 `quantileExact` 用小数。 [\#5304](https://github.com/ClickHouse/ClickHouse/pull/5304) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 文件 {#documentation} - -- 翻译文档 `CollapsingMergeTree` 到中国。 [\#5168](https://github.com/ClickHouse/ClickHouse/pull/5168) ([张风啸](https://github.com/AlexZFX)) -- 将一些关于表格引擎的文档翻译成中文。 - [\#5134](https://github.com/ClickHouse/ClickHouse/pull/5134) - [\#5328](https://github.com/ClickHouse/ClickHouse/pull/5328) - ([永远不会李](https://github.com/neverlee)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements} - -- 修复一些显示可能使用后免费的消毒剂报告。[\#5139](https://github.com/ClickHouse/ClickHouse/pull/5139) [\#5143](https://github.com/ClickHouse/ClickHouse/pull/5143) [\#5393](https://github.com/ClickHouse/ClickHouse/pull/5393) ([伊万](https://github.com/abyss7)) -- 为了方便起见,将性能测试从单独的目录中移出。 [\#5158](https://github.com/ClickHouse/ClickHouse/pull/5158) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复不正确的性能测试。 [\#5255](https://github.com/ClickHouse/ClickHouse/pull/5255) ([阿利沙平](https://github.com/alesapin)) -- 增加了一个工具来计算由位翻转引起的校验和,以调试硬件问题。 [\#5334](https://github.com/ClickHouse/ClickHouse/pull/5334) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使亚军脚本更有用。 [\#5340](https://github.com/ClickHouse/ClickHouse/pull/5340)[\#5360](https://github.com/ClickHouse/ClickHouse/pull/5360) ([filimonov](https://github.com/filimonov)) -- 添加如何编写性能测试的小指令。 [\#5408](https://github.com/ClickHouse/ClickHouse/pull/5408) ([阿利沙平](https://github.com/alesapin)) -- 添加在性能测试中创建,填写和删除查询中进行替换的功能 [\#5367](https://github.com/ClickHouse/ClickHouse/pull/5367) ([Olga Khvostikova](https://github.com/stavrolia)) - -## ClickHouse释放19.7 {#clickhouse-release-19-7} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-7-5-29-2019-07-05} - -#### 错误修复 {#bug-fix-25} - -- 使用JOIN修复某些查询中的性能回归。 [\#5192](https://github.com/ClickHouse/ClickHouse/pull/5192) ([张冬](https://github.com/zhang2014)) - -### 碌莽禄,拢,010-68520682\戮漏鹿芦,酶,虏卤赂拢,110102003042 {#clickhouse-release-19-7-5-27-2019-06-09} - -#### 新功能 {#new-features-1} - -- 添加位图相关功能 `bitmapHasAny` 和 `bitmapHasAll` 类似于 `hasAny` 和 `hasAll` 数组的函数。 [\#5279](https://github.com/ClickHouse/ClickHouse/pull/5279) ([塞尔吉\*弗拉季金](https://github.com/svladykin)) - -#### 错误修复 {#bug-fixes-1} - -- 修复段错误 `minmax` 具有空值的索引。 [\#5246](https://github.com/ClickHouse/ClickHouse/pull/5246) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 根据需要输出标记"LIMIT BY"中的所有输入列。 它修复 ‘Not found column’ 某些分布式查询中出错。 [\#5407](https://github.com/ClickHouse/ClickHouse/pull/5407) ([康斯坦丁\*潘](https://github.com/kvap)) -- 修复 “Column ‘0’ already exists” 错误 `SELECT .. PREWHERE` 在具有默认值的列上 [\#5397](https://github.com/ClickHouse/ClickHouse/pull/5397) ([proller](https://github.com/proller)) -- 修复 `ALTER MODIFY TTL` 查询开 `ReplicatedMergeTree`. [\#5539](https://github.com/ClickHouse/ClickHouse/pull/5539/commits) ([安东\*波波夫](https://github.com/CurtizJ)) -- 当Kafka消费者无法启动时,不要使服务器崩溃。 [\#5285](https://github.com/ClickHouse/ClickHouse/pull/5285) ([伊万](https://github.com/abyss7)) -- 固定位图函数产生错误的结果。 [\#5359](https://github.com/ClickHouse/ClickHouse/pull/5359) ([杨小姐](https://github.com/andyyzh)) -- 修复散列字典的element\_count(不包括重复项) [\#5440](https://github.com/ClickHouse/ClickHouse/pull/5440) ([Azat Khuzhin](https://github.com/azat)) -- 使用环境变量TZ的内容作为时区的名称。 在某些情况下,它有助于正确检测默认时区。[\#5443](https://github.com/ClickHouse/ClickHouse/pull/5443) ([伊万](https://github.com/abyss7)) -- 不要试图将整数转换为 `dictGetT` 功能,因为它不能正常工作。 而是抛出一个异常。 [\#5446](https://github.com/ClickHouse/ClickHouse/pull/5446) ([Artem Zuikov](https://github.com/4ertus2)) -- 在ExternalData HTTP请求修复设置。 [\#5455](https://github.com/ClickHouse/ClickHouse/pull/5455) ([Danila - 库特宁](https://github.com/danlark1)) -- 修复只从FS中删除部件而不从Zookeeper中删除部件时的错误。 [\#5520](https://github.com/ClickHouse/ClickHouse/pull/5520) ([阿利沙平](https://github.com/alesapin)) -- 修复分段故障 `bitmapHasAny` 功能。 [\#5528](https://github.com/ClickHouse/ClickHouse/pull/5528) ([余志昌](https://github.com/yuzhichang)) -- 修复了复制连接池不重试解析主机时的错误,即使删除了DNS缓存。 [\#5534](https://github.com/ClickHouse/ClickHouse/pull/5534) ([阿利沙平](https://github.com/alesapin)) -- 固定 `DROP INDEX IF EXISTS` 查询。 现在 `ALTER TABLE ... DROP INDEX IF EXISTS ...` 如果提供的索引不存在,查询不会引发异常。 [\#5524](https://github.com/ClickHouse/ClickHouse/pull/5524) ([格列布\*诺维科夫](https://github.com/NanoBjorn)) -- 修复联合所有超类型列。 有些情况下,结果列的数据和列类型不一致。 [\#5503](https://github.com/ClickHouse/ClickHouse/pull/5503) ([Artem Zuikov](https://github.com/4ertus2)) -- 在DDL查询处理过程中跳过ZNONODE。 之前,如果另一个节点删除znode在任务队列中,那一个 - 没有处理它,但已经得到子列表,将终止DDLWorker线程。 [\#5489](https://github.com/ClickHouse/ClickHouse/pull/5489) ([Azat Khuzhin](https://github.com/azat)) -- 修复插入到具体化列的分布式()表中。 [\#5429](https://github.com/ClickHouse/ClickHouse/pull/5429) ([Azat Khuzhin](https://github.com/azat)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-7-3-9-2019-05-30} - -#### 新功能 {#new-features-2} - -- 允许限制用户可以指定的设置的范围。 - 这些约束可以在用户设置配置文件中设置。 - [\#4931](https://github.com/ClickHouse/ClickHouse/pull/4931) ([维塔利 - 巴拉诺夫](https://github.com/vitlibar)) -- 添加该函数的第二个版本 `groupUniqArray` 用一个可选的 - `max_size` 限制结果数组大小的参数。 这 - 行为类似于 `groupArray(max_size)(x)` 功能。 - [\#5026](https://github.com/ClickHouse/ClickHouse/pull/5026) ([纪尧姆 - Tassery](https://github.com/YiuRULE)) -- 对于TSVWithNames/CSVWithNames输入文件格式,列顺序现在可以是 - 从文件头确定。 这是由控制 - `input_format_with_names_use_header` 参数。 - [\#5081](https://github.com/ClickHouse/ClickHouse/pull/5081) - ([亚历山大](https://github.com/Akazz)) - -#### 错误修复 {#bug-fixes-2} - -- 在合并过程中uncompressed\_cache+JOIN崩溃(#5197) - [\#5133](https://github.com/ClickHouse/ClickHouse/pull/5133) ([Danila - 库特宁](https://github.com/danlark1)) -- Clickhouse客户端查询到系统表上的分段错误。 \#5066 - [\#5127](https://github.com/ClickHouse/ClickHouse/pull/5127) - ([伊万](https://github.com/abyss7)) -- 通过KafkaEngine重负载数据丢失(#4736) - [\#5080](https://github.com/ClickHouse/ClickHouse/pull/5080) - ([伊万](https://github.com/abyss7)) -- 修复了在执行UNION查询时可能发生的非常罕见的数据争用条件,所有查询都涉及至少两个来自系统的选择。列,系统。表,系统。部件,系统。parts\_tables或Merge系列的表,并同时执行相关表的列的更改。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 性能改进 {#performance-improvements-1} - -- 使用基数排序按单个数字列进行排序 `ORDER BY` 没有 - `LIMIT`. [\#5106](https://github.com/ClickHouse/ClickHouse/pull/5106), - [\#4439](https://github.com/ClickHouse/ClickHouse/pull/4439) - ([Evgenii Pravda](https://github.com/kvinty), - [阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 文件 {#documentation-1} - -- 将某些表格引擎的文档翻译为中文。 - [\#5107](https://github.com/ClickHouse/ClickHouse/pull/5107), - [\#5094](https://github.com/ClickHouse/ClickHouse/pull/5094), - [\#5087](https://github.com/ClickHouse/ClickHouse/pull/5087) - ([张风啸](https://github.com/AlexZFX)), - [\#5068](https://github.com/ClickHouse/ClickHouse/pull/5068) ([从来没有 - 李](https://github.com/neverlee)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-1} - -- 正确打印UTF-8字符 `clickhouse-test`. - [\#5084](https://github.com/ClickHouse/ClickHouse/pull/5084) - ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 为clickhouse-client添加命令行参数以始终加载建议 - 戴达 [\#5102](https://github.com/ClickHouse/ClickHouse/pull/5102) - ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 解决一些PVS-Studio警告。 - [\#5082](https://github.com/ClickHouse/ClickHouse/pull/5082) - ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新LZ4 [\#5040](https://github.com/ClickHouse/ClickHouse/pull/5040) ([Danila - 库特宁](https://github.com/danlark1)) -- 添加gperf以构建即将到来的拉取请求#5030的requirements。 - [\#5110](https://github.com/ClickHouse/ClickHouse/pull/5110) - ([proller](https://github.com/proller)) - -## ClickHouse释放19.6 {#clickhouse-release-19-6} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-6-3-18-2019-06-13} - -#### 错误修复 {#bug-fixes-3} - -- 修复了来自表函数的查询的条件下推 `mysql` 和 `odbc` 和相应的表引擎。 这修复了#3540和#2384。 [\#5313](https://github.com/ClickHouse/ClickHouse/pull/5313) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复动物园管理员的死锁。 [\#5297](https://github.com/ClickHouse/ClickHouse/pull/5297) ([github1youlc](https://github.com/github1youlc)) -- 允许在CSV中引用小数。 [\#5284](https://github.com/ClickHouse/ClickHouse/pull/5284) ([Artem Zuikov](https://github.com/4ertus2) -- 禁止从float Inf/NaN转换为小数(抛出异常)。 [\#5282](https://github.com/ClickHouse/ClickHouse/pull/5282) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复重命名查询中的数据竞赛。 [\#5247](https://github.com/ClickHouse/ClickHouse/pull/5247) ([张冬](https://github.com/zhang2014)) -- 暂时禁用LFAlloc。 使用LFAlloc可能会导致大量MAP\_FAILED在分配UncompressedCache时,并导致高负载服务器上的查询崩溃。 [cfdba93](https://github.com/ClickHouse/ClickHouse/commit/cfdba938ce22f16efeec504f7f90206a515b1280)([Danila Kutenin](https://github.com/danlark1)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-6-2-11-2019-05-13} - -#### 新功能 {#new-features-3} - -- 列和表的TTL表达式。 [\#4212](https://github.com/ClickHouse/ClickHouse/pull/4212) ([安东\*波波夫](https://github.com/CurtizJ)) -- 增加了对 `brotli` http响应的压缩(接受编码:br) [\#4388](https://github.com/ClickHouse/ClickHouse/pull/4388) ([米哈伊尔](https://github.com/fandyushin)) -- 增加了新功能 `isValidUTF8` 用于检查一组字节是否被正确地utf-8编码。 [\#4934](https://github.com/ClickHouse/ClickHouse/pull/4934) ([Danila Kutenin](https://github.com/danlark1)) -- 添加新的负载平衡策略 `first_or_random` 它将查询发送到第一个指定的主机,如果无法访问,则向分片的随机主机发送查询。 对于跨复制拓扑设置非常有用。 [\#5012](https://github.com/ClickHouse/ClickHouse/pull/5012) ([纳瓦托洛梅](https://github.com/nvartolomei)) - -#### 实验特点 {#experimental-features-1} - -- 添加设置 `index_granularity_bytes` (自适应索引粒度)对于MergeTree\*表族. [\#4826](https://github.com/ClickHouse/ClickHouse/pull/4826) ([阿利沙平](https://github.com/alesapin)) - -#### 改进 {#improvements-1} - -- 增加了对函数的非常量和负大小和长度参数的支持 `substringUTF8`. [\#4989](https://github.com/ClickHouse/ClickHouse/pull/4989) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在左联接中禁用向下推到右表,在右联接中禁用左表,并在完全联接中禁用两个表。 在某些情况下,这可以修复错误的连接结果。 [\#4846](https://github.com/ClickHouse/ClickHouse/pull/4846) ([伊万](https://github.com/abyss7)) -- `clickhouse-copier`:从自动上传任务配置 `--task-file` 备选案文 [\#4876](https://github.com/ClickHouse/ClickHouse/pull/4876) ([proller](https://github.com/proller)) -- 为存储工厂和表函数工厂添加了错别字处理程序。 [\#4891](https://github.com/ClickHouse/ClickHouse/pull/4891) ([Danila Kutenin](https://github.com/danlark1)) -- 支持不带子查询的多个联接的星号和限定星号 [\#4898](https://github.com/ClickHouse/ClickHouse/pull/4898) ([Artem Zuikov](https://github.com/4ertus2)) -- 使缺少列错误消息更加用户友好。 [\#4915](https://github.com/ClickHouse/ClickHouse/pull/4915) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 性能改进 {#performance-improvements-2} - -- ASOF加速显着 [\#4924](https://github.com/ClickHouse/ClickHouse/pull/4924) ([Martijn Bakker](https://github.com/Gladdy)) - -#### 向后不兼容的更改 {#backward-incompatible-changes} - -- HTTP头 `Query-Id` 改名为 `X-ClickHouse-Query-Id` 为了一致性。 [\#4972](https://github.com/ClickHouse/ClickHouse/pull/4972) ([米哈伊尔](https://github.com/fandyushin)) - -#### 错误修复 {#bug-fixes-4} - -- 修正了潜在的空指针取消引用 `clickhouse-copier`. [\#4900](https://github.com/ClickHouse/ClickHouse/pull/4900) ([proller](https://github.com/proller)) -- 修复了使用JOIN+ARRAY JOIN查询的错误 [\#4938](https://github.com/ClickHouse/ClickHouse/pull/4938) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定挂在服务器的启动时,字典依赖于另一个字典通过引擎数据库=字典。 [\#4962](https://github.com/ClickHouse/ClickHouse/pull/4962) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- Partially fix distributed\_product\_mode = local. It's possible to allow columns of local tables in where/having/order by/… via table aliases. Throw exception if table does not have alias. There's not possible to access to the columns without table aliases yet. [\#4986](https://github.com/ClickHouse/ClickHouse/pull/4986) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复潜在的错误结果 `SELECT DISTINCT` 与 `JOIN` [\#5001](https://github.com/ClickHouse/ClickHouse/pull/5001) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复了在执行UNION查询时可能发生的非常罕见的数据争用条件,所有查询都涉及至少两个来自系统的选择。列,系统。表,系统。部件,系统。parts\_tables或Merge系列的表,并同时执行相关表的列的更改。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-2} - -- 在不同的主机上运行clickhouse服务器时修复测试失败 [\#4713](https://github.com/ClickHouse/ClickHouse/pull/4713) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- clickhouse-test:在非tty环境中禁用颜色控制序列。 [\#4937](https://github.com/ClickHouse/ClickHouse/pull/4937) ([阿利沙平](https://github.com/alesapin)) -- clickhouse-test:允许使用任何测试数据库(删除 `test.` 在可能的情况下获得资格) [\#5008](https://github.com/ClickHouse/ClickHouse/pull/5008) ([proller](https://github.com/proller)) -- 修复ubsan错误 [\#5037](https://github.com/ClickHouse/ClickHouse/pull/5037) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- Yandex LFAlloc被添加到ClickHouse中,以不同的方式分配MarkCache和UncompressedCache数据,以更可靠地捕获段错误 [\#4995](https://github.com/ClickHouse/ClickHouse/pull/4995) ([Danila Kutenin](https://github.com/danlark1)) -- Python util帮助反向移植和更改日志。 [\#4949](https://github.com/ClickHouse/ClickHouse/pull/4949) ([伊万](https://github.com/abyss7)) - -## ClickHouse释放19.5 {#clickhouse-release-19-5} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-5-4-22-2019-05-13} - -#### 错误修复 {#bug-fixes-5} - -- 修正了位图\*功能中可能出现的崩溃 [\#5220](https://github.com/ClickHouse/ClickHouse/pull/5220) [\#5228](https://github.com/ClickHouse/ClickHouse/pull/5228) ([杨小姐](https://github.com/andyyzh)) -- 修复了在执行UNION查询时可能发生的非常罕见的数据争用条件,所有查询都涉及至少两个来自系统的选择。列,系统。表,系统。部件,系统。parts\_tables或Merge系列的表,并同时执行相关表的列的更改。 [\#5189](https://github.com/ClickHouse/ClickHouse/pull/5189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误 `Set for IN is not created yet in case of using single LowCardinality column in the left part of IN`. 如果lowcardinality列是主键的一部分,则会发生此错误。 \#5031 [\#5154](https://github.com/ClickHouse/ClickHouse/pull/5154) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修改保留函数:如果一行同时满足第一个和第N个条件,则只有第一个满足的条件被添加到数据状态。 现在所有满足一行数据的条件都被添加到数据状态。 [\#5119](https://github.com/ClickHouse/ClickHouse/pull/5119) ([小路](https://github.com/nicelulu)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-5-3-8-2019-04-18} - -#### 错误修复 {#bug-fixes-6} - -- 固定设置类型 `max_partitions_per_insert_block` 从布尔到UInt64。 [\#5028](https://github.com/ClickHouse/ClickHouse/pull/5028) ([2.Mohammad Hossein Sekhavat](https://github.com/mhsekhavat)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-5-2-6-2019-04-15} - -#### 新功能 {#new-features-4} - -- [超扫描](https://github.com/intel/hyperscan) 添加了多个正则表达式匹配(函数 `multiMatchAny`, `multiMatchAnyIndex`, `multiFuzzyMatchAny`, `multiFuzzyMatchAnyIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780), [\#4841](https://github.com/ClickHouse/ClickHouse/pull/4841) ([Danila Kutenin](https://github.com/danlark1)) -- `multiSearchFirstPosition` 添加了功能。 [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) -- 为表实现每行的预定义表达式筛选器。 [\#4792](https://github.com/ClickHouse/ClickHouse/pull/4792) ([伊万](https://github.com/abyss7)) -- 一种基于bloom过滤器的新型数据跳过索引(可用于 `equal`, `in` 和 `like` 功能)。 [\#4499](https://github.com/ClickHouse/ClickHouse/pull/4499) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 已添加 `ASOF JOIN` 它允许运行连接到最新已知值的查询。 [\#4774](https://github.com/ClickHouse/ClickHouse/pull/4774) [\#4867](https://github.com/ClickHouse/ClickHouse/pull/4867) [\#4863](https://github.com/ClickHouse/ClickHouse/pull/4863) [\#4875](https://github.com/ClickHouse/ClickHouse/pull/4875) ([Martijn Bakker](https://github.com/Gladdy), [Artem Zuikov](https://github.com/4ertus2)) -- 重写多个 `COMMA JOIN` 到 `CROSS JOIN`. 然后将它们重写为 `INNER JOIN` 如果可能的话 [\#4661](https://github.com/ClickHouse/ClickHouse/pull/4661) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 改进 {#improvement-9} - -- `topK` 和 `topKWeighted` 现在支持自定义 `loadFactor` (修复问题 [\#4252](https://github.com/ClickHouse/ClickHouse/issues/4252)). [\#4634](https://github.com/ClickHouse/ClickHouse/pull/4634) ([基里尔丹信](https://github.com/kirillDanshin)) -- 允许使用 `parallel_replicas_count > 1` 即使对于没有采样的表(设置简单地忽略它们)。 在以前的版本中,它导致异常。 [\#4637](https://github.com/ClickHouse/ClickHouse/pull/4637) ([Alexey Elymanov](https://github.com/digitalist)) -- 支持 `CREATE OR REPLACE VIEW`. 允许在单个语句中创建视图或设置新定义。 [\#4654](https://github.com/ClickHouse/ClickHouse/pull/4654) ([Boris Granveaud](https://github.com/bgranvea)) -- `Buffer` 表引擎现在支持 `PREWHERE`. [\#4671](https://github.com/ClickHouse/ClickHouse/pull/4671) ([刘杨宽](https://github.com/LiuYangkuan)) -- 添加在zookeeper中启动没有元数据的复制表的能力 `readonly` 模式 [\#4691](https://github.com/ClickHouse/ClickHouse/pull/4691) ([阿利沙平](https://github.com/alesapin)) -- 在clickhouse客户端固定进度条闪烁。 使用时,这个问题最明显 `FORMAT Null` 随着流查询。 [\#4811](https://github.com/ClickHouse/ClickHouse/pull/4811) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 允许禁用功能 `hyperscan` 基于每个用户的库,以限制潜在的过度和不受控制的资源使用。 [\#4816](https://github.com/ClickHouse/ClickHouse/pull/4816) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加版本号记录所有错误。 [\#4824](https://github.com/ClickHouse/ClickHouse/pull/4824) ([proller](https://github.com/proller)) -- 增加了限制 `multiMatch` 需要字符串大小以适应的函数 `unsigned int`. 还增加了参数的数量限制 `multiSearch` 功能。 [\#4834](https://github.com/ClickHouse/ClickHouse/pull/4834) ([Danila Kutenin](https://github.com/danlark1)) -- 改进了超扫描暂存空间的使用和错误处理。 [\#4866](https://github.com/ClickHouse/ClickHouse/pull/4866) ([Danila Kutenin](https://github.com/danlark1)) -- 填充 `system.graphite_detentions` 从表配置 `*GraphiteMergeTree` 发动机表. [\#4584](https://github.com/ClickHouse/ClickHouse/pull/4584) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 重命名 `trigramDistance` 功能 `ngramDistance` 并添加更多的功能 `CaseInsensitive` 和 `UTF`. [\#4602](https://github.com/ClickHouse/ClickHouse/pull/4602) ([Danila Kutenin](https://github.com/danlark1)) -- 改进的数据跳过指数计算。 [\#4640](https://github.com/ClickHouse/ClickHouse/pull/4640) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 保持平凡, `DEFAULT`, `MATERIALIZED` 和 `ALIAS` 在一个列表中的列(修复问题 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) - -#### 错误修复 {#bug-fix-26} - -- 避免 `std::terminate` 在内存分配失败的情况下。 现在 `std::bad_alloc` 按预期引发异常。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复capnproto从缓冲区读取。 有时文件没有通过HTTP成功加载。 [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([弗拉季斯拉夫](https://github.com/smirnov-vs)) -- 修复错误 `Unknown log entry type: 0` 后 `OPTIMIZE TABLE FINAL` 查询。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([阿莫斯鸟](https://github.com/amosbird)) -- 错误的参数 `hasAny` 或 `hasAll` 函数可能会导致段错误。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 执行时可能会发生死锁 `DROP DATABASE dictionary` 查询。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复未定义的行为 `median` 和 `quantile` 功能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) -- 修复压缩级别检测时 `network_compression_method` 小写。 在19.1节中被打破。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) -- 固定的无知 `UTC` 设置(修复问题 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) -- 修复 `histogram` 函数行为 `Distributed` 桌子 [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) -- 固定tsan报告 `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了由于系统日志使用中的争用条件而关闭的TSan报告。 修复了当part\_log启用时关机后的潜在使用。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复重新检查零件 `ReplicatedMergeTreeAlterThread` 在错误的情况下。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 对中间聚合函数状态的算术运算不适用于常量参数(如子查询结果)。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 始终在元数据中反引用列名。 否则,不可能创建一个名为列的表 `index` (由于格式错误,服务器无法重新启动 `ATTACH` 元数据中的查询)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复崩溃 `ALTER ... MODIFY ORDER BY` 上 `Distributed` 桌子 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) -- 修复段错误 `JOIN ON` 已启用 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([张冬](https://github.com/zhang2014)) -- 修复kafka使用protobuf消息后添加无关行的错误。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复崩溃 `JOIN` 在不可为空的vs可为空的列上。 修复 `NULLs` 在右键 `ANY JOIN` + `join_use_nulls`. [\#4815](https://github.com/ClickHouse/ClickHouse/pull/4815) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- 在固定的竞争条件 `SELECT` 从 `system.tables` 如果同时重命名或更改表。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 获取已经过时的数据部分时修复了数据竞赛。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定罕见的数据竞赛,可以在发生 `RENAME` MergeTree家族的表. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正功能中的分段故障 `arrayIntersect`. 如果函数使用常量和普通参数混合调用,则可能会发生分段错误。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([钱丽祥](https://github.com/fancyqlx)) -- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复崩溃 `FULL/RIGHT JOIN` 当我们加入可为空vs不可为空时。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复 `No message received` 在副本之间获取部件时出现异常。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([阿利沙平](https://github.com/alesapin)) -- 固定 `arrayIntersect` 函数错误导致在单个数组中的几个重复值的情况下。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 在并发期间修复争用条件 `ALTER COLUMN` 可能导致服务器崩溃的查询(修复问题 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修复不正确的结果 `FULL/RIGHT JOIN` 与常量列。 [\#4723](https://github.com/ClickHouse/ClickHouse/pull/4723) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复重复 `GLOBAL JOIN` 用星号。 [\#4705](https://github.com/ClickHouse/ClickHouse/pull/4705) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复参数扣除 `ALTER MODIFY` 列 `CODEC` 未指定列类型时。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([阿利沙平](https://github.com/alesapin)) -- 功能 `cutQueryStringAndFragment()` 和 `queryStringAndFragment()` 现在正常工作时 `URL` 包含一个片段,没有查询。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复设置时罕见的错误 `min_bytes_to_use_direct_io` 大于零,这发生在线程必须在列文件中向后寻找时。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([阿利沙平](https://github.com/alesapin)) -- 修复聚合函数的错误参数类型 `LowCardinality` 参数(修复问题 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复错误的名称资格 `GLOBAL JOIN`. [\#4969](https://github.com/ClickHouse/ClickHouse/pull/4969) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复功能 `toISOWeek` 1970年的结果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `DROP`, `TRUNCATE` 和 `OPTIMIZE` 查询重复,在执行时 `ON CLUSTER` 为 `ReplicatedMergeTree*` 表家庭. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([阿利沙平](https://github.com/alesapin)) - -#### 向后不兼容的更改 {#backward-incompatible-change-8} - -- 重命名设置 `insert_sample_with_metadata` 到设置 `input_format_defaults_for_omitted_fields`. [\#4771](https://github.com/ClickHouse/ClickHouse/pull/4771) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加设置 `max_partitions_per_insert_block` (默认值为100)。 如果插入的块包含较大数量的分区,则会引发异常。 如果要删除限制(不推荐),请将其设置为0。 [\#4845](https://github.com/ClickHouse/ClickHouse/pull/4845) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 多搜索功能被重命名 (`multiPosition` 到 `multiSearchAllPositions`, `multiSearch` 到 `multiSearchAny`, `firstMatch` 到 `multiSearchFirstIndex`). [\#4780](https://github.com/ClickHouse/ClickHouse/pull/4780) ([Danila Kutenin](https://github.com/danlark1)) - -#### 性能改进 {#performance-improvement-6} - -- 通过内联优化Volnitsky搜索器,为许多针或许多类似bigrams的查询提供约5-10%的搜索改进。 [\#4862](https://github.com/ClickHouse/ClickHouse/pull/4862) ([Danila Kutenin](https://github.com/danlark1)) -- 修复设置时的性能问题 `use_uncompressed_cache` 大于零时,即出现在所有读取缓存中包含的数据时。 [\#4913](https://github.com/ClickHouse/ClickHouse/pull/4913) ([阿利沙平](https://github.com/alesapin)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-10} - -- 强化调试构建:更精细的内存映射和ASLR;为标记缓存和索引添加内存保护。 这允许在ASan和MSan无法做到这一点的情况下找到更多的内存st脚错误。 [\#4632](https://github.com/ClickHouse/ClickHouse/pull/4632) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加对cmake变量的支持 `ENABLE_PROTOBUF`, `ENABLE_PARQUET` 和 `ENABLE_BROTLI` 它允许启用/禁用上述功能(与我们对librdkafka,mysql等所做的相同)。 [\#4669](https://github.com/ClickHouse/ClickHouse/pull/4669) ([Silviu Caragea](https://github.com/silviucpp)) -- 添加打印进程列表和堆栈跟踪的所有线程的能力,如果一些查询测试运行后挂起。 [\#4675](https://github.com/ClickHouse/ClickHouse/pull/4675) ([阿利沙平](https://github.com/alesapin)) -- 添加重试 `Connection loss` 错误 `clickhouse-test`. [\#4682](https://github.com/ClickHouse/ClickHouse/pull/4682) ([阿利沙平](https://github.com/alesapin)) -- 在打包程序脚本中添加使用vagrant的freebsd build和使用thread sanitizer的build。 [\#4712](https://github.com/ClickHouse/ClickHouse/pull/4712) [\#4748](https://github.com/ClickHouse/ClickHouse/pull/4748) ([阿利沙平](https://github.com/alesapin)) -- 现在用户要求用户密码 `'default'` 在安装过程中。 [\#4725](https://github.com/ClickHouse/ClickHouse/pull/4725) ([proller](https://github.com/proller)) -- 禁止在警告 `rdkafka` 图书馆. [\#4740](https://github.com/ClickHouse/ClickHouse/pull/4740) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 允许在没有ssl的情况下构建。 [\#4750](https://github.com/ClickHouse/ClickHouse/pull/4750) ([proller](https://github.com/proller)) -- 添加从自定义用户启动clickhouse服务器映像的方法。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 升级contrib升压到1.69. [\#4793](https://github.com/ClickHouse/ClickHouse/pull/4793) ([proller](https://github.com/proller)) -- 禁用使用 `mremap` 使用线程消毒剂编译时。 令人惊讶的是,TSan并没有拦截 `mremap` (虽然它确实拦截 `mmap`, `munmap` 这会导致误报。 修复了有状态测试中的TSan报告。 [\#4859](https://github.com/ClickHouse/ClickHouse/pull/4859) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 通过HTTP接口使用格式模式添加测试检查。 [\#4864](https://github.com/ClickHouse/ClickHouse/pull/4864) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) - -## ClickHouse释放19.4 {#clickhouse-release-19-4} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-4-33-2019-04-17} - -#### 错误修复 {#bug-fixes-7} - -- 避免 `std::terminate` 在内存分配失败的情况下。 现在 `std::bad_alloc` 按预期引发异常。 [\#4665](https://github.com/ClickHouse/ClickHouse/pull/4665) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复capnproto从缓冲区读取。 有时文件没有通过HTTP成功加载。 [\#4674](https://github.com/ClickHouse/ClickHouse/pull/4674) ([弗拉季斯拉夫](https://github.com/smirnov-vs)) -- 修复错误 `Unknown log entry type: 0` 后 `OPTIMIZE TABLE FINAL` 查询。 [\#4683](https://github.com/ClickHouse/ClickHouse/pull/4683) ([阿莫斯鸟](https://github.com/amosbird)) -- 错误的参数 `hasAny` 或 `hasAll` 函数可能会导致段错误。 [\#4698](https://github.com/ClickHouse/ClickHouse/pull/4698) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 执行时可能会发生死锁 `DROP DATABASE dictionary` 查询。 [\#4701](https://github.com/ClickHouse/ClickHouse/pull/4701) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复未定义的行为 `median` 和 `quantile` 功能。 [\#4702](https://github.com/ClickHouse/ClickHouse/pull/4702) ([hcz](https://github.com/hczhcz)) -- 修复压缩级别检测时 `network_compression_method` 小写。 在19.1节中被打破。 [\#4706](https://github.com/ClickHouse/ClickHouse/pull/4706) ([proller](https://github.com/proller)) -- 固定的无知 `UTC` 设置(修复问题 [\#4658](https://github.com/ClickHouse/ClickHouse/issues/4658)). [\#4718](https://github.com/ClickHouse/ClickHouse/pull/4718) ([proller](https://github.com/proller)) -- 修复 `histogram` 函数行为 `Distributed` 桌子 [\#4741](https://github.com/ClickHouse/ClickHouse/pull/4741) ([olegkv](https://github.com/olegkv)) -- 固定tsan报告 `destroy of a locked mutex`. [\#4742](https://github.com/ClickHouse/ClickHouse/pull/4742) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了由于系统日志使用中的争用条件而关闭的TSan报告。 修复了当part\_log启用时关机后的潜在使用。 [\#4758](https://github.com/ClickHouse/ClickHouse/pull/4758) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复重新检查零件 `ReplicatedMergeTreeAlterThread` 在错误的情况下。 [\#4772](https://github.com/ClickHouse/ClickHouse/pull/4772) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 对中间聚合函数状态的算术运算不适用于常量参数(如子查询结果)。 [\#4776](https://github.com/ClickHouse/ClickHouse/pull/4776) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 始终在元数据中反引用列名。 否则,不可能创建一个名为列的表 `index` (由于格式错误,服务器无法重新启动 `ATTACH` 元数据中的查询)。 [\#4782](https://github.com/ClickHouse/ClickHouse/pull/4782) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复崩溃 `ALTER ... MODIFY ORDER BY` 上 `Distributed` 桌子 [\#4790](https://github.com/ClickHouse/ClickHouse/pull/4790) ([TCeason](https://github.com/TCeason)) -- 修复段错误 `JOIN ON` 已启用 `enable_optimize_predicate_expression`. [\#4794](https://github.com/ClickHouse/ClickHouse/pull/4794) ([张冬](https://github.com/zhang2014)) -- 修复kafka使用protobuf消息后添加无关行的错误。 [\#4808](https://github.com/ClickHouse/ClickHouse/pull/4808) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- 在固定的竞争条件 `SELECT` 从 `system.tables` 如果同时重命名或更改表。 [\#4836](https://github.com/ClickHouse/ClickHouse/pull/4836) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 获取已经过时的数据部分时修复了数据竞赛。 [\#4839](https://github.com/ClickHouse/ClickHouse/pull/4839) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定罕见的数据竞赛,可以在发生 `RENAME` MergeTree家族的表. [\#4844](https://github.com/ClickHouse/ClickHouse/pull/4844) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正功能中的分段故障 `arrayIntersect`. 如果函数使用常量和普通参数混合调用,则可能会发生分段错误。 [\#4847](https://github.com/ClickHouse/ClickHouse/pull/4847) ([钱丽祥](https://github.com/fancyqlx)) -- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复 `No message received` 在副本之间获取部件时出现异常。 [\#4856](https://github.com/ClickHouse/ClickHouse/pull/4856) ([阿利沙平](https://github.com/alesapin)) -- 固定 `arrayIntersect` 函数错误导致在单个数组中的几个重复值的情况下。 [\#4871](https://github.com/ClickHouse/ClickHouse/pull/4871) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 在并发期间修复争用条件 `ALTER COLUMN` 可能导致服务器崩溃的查询(修复问题 [\#3421](https://github.com/ClickHouse/ClickHouse/issues/3421)). [\#4592](https://github.com/ClickHouse/ClickHouse/pull/4592) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修复参数扣除 `ALTER MODIFY` 列 `CODEC` 未指定列类型时。 [\#4883](https://github.com/ClickHouse/ClickHouse/pull/4883) ([阿利沙平](https://github.com/alesapin)) -- 功能 `cutQueryStringAndFragment()` 和 `queryStringAndFragment()` 现在正常工作时 `URL` 包含一个片段,没有查询。 [\#4894](https://github.com/ClickHouse/ClickHouse/pull/4894) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复设置时罕见的错误 `min_bytes_to_use_direct_io` 大于零,这发生在线程必须在列文件中向后寻找时。 [\#4897](https://github.com/ClickHouse/ClickHouse/pull/4897) ([阿利沙平](https://github.com/alesapin)) -- 修复聚合函数的错误参数类型 `LowCardinality` 参数(修复问题 [\#4919](https://github.com/ClickHouse/ClickHouse/issues/4919)). [\#4922](https://github.com/ClickHouse/ClickHouse/pull/4922) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复功能 `toISOWeek` 1970年的结果。 [\#4988](https://github.com/ClickHouse/ClickHouse/pull/4988) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `DROP`, `TRUNCATE` 和 `OPTIMIZE` 查询重复,在执行时 `ON CLUSTER` 为 `ReplicatedMergeTree*` 表家庭. [\#4991](https://github.com/ClickHouse/ClickHouse/pull/4991) ([阿利沙平](https://github.com/alesapin)) - -#### 改进 {#improvements-2} - -- 保持平凡, `DEFAULT`, `MATERIALIZED` 和 `ALIAS` 在一个列表中的列(修复问题 [\#2867](https://github.com/ClickHouse/ClickHouse/issues/2867)). [\#4707](https://github.com/ClickHouse/ClickHouse/pull/4707) ([Alex Zatelepin](https://github.com/ztlpn)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-3-11-2019-04-02} - -#### 错误修复 {#bug-fixes-8} - -- 修复崩溃 `FULL/RIGHT JOIN` 当我们加入可为空vs不可为空时。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-11} - -- 添加从自定义用户启动clickhouse服务器映像的方法。 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-2-7-2019-03-30} - -#### 错误修复 {#bug-fixes-9} - -- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-1-3-2019-03-19} - -#### 错误修复 {#bug-fixes-10} - -- 包含两个固定的远程查询 `LIMIT BY` 和 `LIMIT`. 以前,如果 `LIMIT BY` 和 `LIMIT` 用于远程查询, `LIMIT` 可能发生之前 `LIMIT BY`,这导致过滤的结果。 [\#4708](https://github.com/ClickHouse/ClickHouse/pull/4708) ([康斯坦丁\*潘](https://github.com/kvap)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-4-0-49-2019-03-09} - -#### 新功能 {#new-features-5} - -- 增加了全面支持 `Protobuf` 格式(输入和输出,嵌套数据结构)。 [\#4174](https://github.com/ClickHouse/ClickHouse/pull/4174) [\#4493](https://github.com/ClickHouse/ClickHouse/pull/4493) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 添加位图功能与Ro哮的位图。 [\#4207](https://github.com/ClickHouse/ClickHouse/pull/4207) ([杨小姐](https://github.com/andyyzh)) [\#4568](https://github.com/ClickHouse/ClickHouse/pull/4568) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 实木复合地板格式支持。 [\#4448](https://github.com/ClickHouse/ClickHouse/pull/4448) ([proller](https://github.com/proller)) -- 为模糊字符串比较添加了N-gram距离。 它类似于R语言中的q-gram指标。 [\#4466](https://github.com/ClickHouse/ClickHouse/pull/4466) ([Danila Kutenin](https://github.com/danlark1)) -- 结合专用聚合和保留模式中的石墨汇总规则。 [\#4426](https://github.com/ClickHouse/ClickHouse/pull/4426) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 已添加 `max_execution_speed` 和 `max_execution_speed_bytes` 限制资源使用。 已添加 `min_execution_speed_bytes` 设置以补充 `min_execution_speed`. [\#4430](https://github.com/ClickHouse/ClickHouse/pull/4430) ([张冬](https://github.com/zhang2014)) -- 实现功能 `flatten`. [\#4555](https://github.com/ClickHouse/ClickHouse/pull/4555) [\#4409](https://github.com/ClickHouse/ClickHouse/pull/4409) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov), [kzon](https://github.com/kzon)) -- 新增功能 `arrayEnumerateDenseRanked` 和 `arrayEnumerateUniqRanked` (这就像 `arrayEnumerateUniq` 但是允许微调数组深度以查看多维数组内部)。 [\#4475](https://github.com/ClickHouse/ClickHouse/pull/4475) ([proller](https://github.com/proller)) [\#4601](https://github.com/ClickHouse/ClickHouse/pull/4601) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- Multiple JOINS with some restrictions: no asterisks, no complex aliases in ON/WHERE/GROUP BY/… [\#4462](https://github.com/ClickHouse/ClickHouse/pull/4462) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 错误修复 {#bug-fixes-11} - -- 此版本还包含19.3和19.1中的所有错误修复。 -- 修正了数据跳过索引的错误:插入后颗粒顺序不正确。 [\#4407](https://github.com/ClickHouse/ClickHouse/pull/4407) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 固定 `set` ツ环板forョ `Nullable` 和 `LowCardinality` 列。 在它之前, `set` 索引与 `Nullable` 或 `LowCardinality` 列导致错误 `Data type must be deserialized with multiple streams` 同时选择。 [\#4594](https://github.com/ClickHouse/ClickHouse/pull/4594) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 正确设置完整的update\_time `executable` 字典更新. [\#4551](https://github.com/ClickHouse/ClickHouse/pull/4551) ([Tema Novikov](https://github.com/temoon)) -- 修复19.3中损坏的进度条。 [\#4627](https://github.com/ClickHouse/ClickHouse/pull/4627) ([filimonov](https://github.com/filimonov)) -- 在某些情况下,修复了内存区域收缩时MemoryTracker的不一致值。 [\#4619](https://github.com/ClickHouse/ClickHouse/pull/4619) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了ThreadPool中未定义的行为。 [\#4612](https://github.com/ClickHouse/ClickHouse/pull/4612) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了一个非常罕见的崩溃的消息 `mutex lock failed: Invalid argument` 当MergeTree表与SELECT同时删除时,可能会发生这种情况。 [\#4608](https://github.com/ClickHouse/ClickHouse/pull/4608) ([Alex Zatelepin](https://github.com/ztlpn)) -- ODBC驱动程序兼容 `LowCardinality` 数据类型。 [\#4381](https://github.com/ClickHouse/ClickHouse/pull/4381) ([proller](https://github.com/proller)) -- FreeBSD:修复程序 `AIOcontextPool: Found io_event with unknown id 0` 错误 [\#4438](https://github.com/ClickHouse/ClickHouse/pull/4438) ([urgordeadbeef](https://github.com/urgordeadbeef)) -- `system.part_log` 无论配置如何,都会创建表。 [\#4483](https://github.com/ClickHouse/ClickHouse/pull/4483) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复未定义的行为 `dictIsIn` 缓存字典功能。 [\#4515](https://github.com/ClickHouse/ClickHouse/pull/4515) ([阿利沙平](https://github.com/alesapin)) -- Fixed a deadlock when a SELECT query locks the same table multiple times (e.g. from different threads or when executing multiple subqueries) and there is a concurrent DDL query. [\#4535](https://github.com/ClickHouse/ClickHouse/pull/4535) ([Alex Zatelepin](https://github.com/ztlpn)) -- 默认情况下禁用compile\_expressions,直到我们得到自己 `llvm` contrib并且可以测试它 `clang` 和 `asan`. [\#4579](https://github.com/ClickHouse/ClickHouse/pull/4579) ([阿利沙平](https://github.com/alesapin)) -- 预防 `std::terminate` 当 `invalidate_query` 为 `clickhouse` 外部字典源返回了错误的结果集(空或一行以上或一列以上)。 固定的问题,当 `invalidate_query` 执行每五秒钟,无论到 `lifetime`. [\#4583](https://github.com/ClickHouse/ClickHouse/pull/4583) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免死锁时 `invalidate_query` 对于与字典 `clickhouse` 资料来源涉及 `system.dictionaries` 表或 `Dictionaries` 数据库(罕见的情况)。 [\#4599](https://github.com/ClickHouse/ClickHouse/pull/4599) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了交叉连接与空在哪里。 [\#4598](https://github.com/ClickHouse/ClickHouse/pull/4598) ([Artem Zuikov](https://github.com/4ertus2)) -- 在功能固定段错误 “replicate” 传递常量参数时。 [\#4603](https://github.com/ClickHouse/ClickHouse/pull/4603) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用谓词优化器修复lambda函数。 [\#4408](https://github.com/ClickHouse/ClickHouse/pull/4408) ([张冬](https://github.com/zhang2014)) -- 多个联接多个修复。 [\#4595](https://github.com/ClickHouse/ClickHouse/pull/4595) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 改进 {#improvements-3} - -- 在右表列的连接上部分支持别名。 [\#4412](https://github.com/ClickHouse/ClickHouse/pull/4412) ([Artem Zuikov](https://github.com/4ertus2)) -- 结果多加入了需要正确的结果,名称为使用中子选择. 替换平的别名来源中的名称结果。 [\#4474](https://github.com/ClickHouse/ClickHouse/pull/4474) ([Artem Zuikov](https://github.com/4ertus2)) -- 改进连接语句的下推逻辑。 [\#4387](https://github.com/ClickHouse/ClickHouse/pull/4387) ([伊万](https://github.com/abyss7)) - -#### 性能改进 {#performance-improvements-3} - -- 改进的启发式 “move to PREWHERE” 优化。 [\#4405](https://github.com/ClickHouse/ClickHouse/pull/4405) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用适当的查找表,使用HashTable的api用于8位和16位密钥。 [\#4536](https://github.com/ClickHouse/ClickHouse/pull/4536) ([阿莫斯鸟](https://github.com/amosbird)) -- 改进字符串比较的性能。 [\#4564](https://github.com/ClickHouse/ClickHouse/pull/4564) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在单独的线程中清理分布式DDL队列,以便它不会减慢处理分布式DDL任务的主循环。 [\#4502](https://github.com/ClickHouse/ClickHouse/pull/4502) ([Alex Zatelepin](https://github.com/ztlpn)) -- 当 `min_bytes_to_use_direct_io` 如果设置为1,则不是每个文件都使用O\_DIRECT模式打开,因为要读取的数据大小有时被一个压缩块的大小所低估。 [\#4526](https://github.com/ClickHouse/ClickHouse/pull/4526) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-12} - -- 增加了对clang-9的支持 [\#4604](https://github.com/ClickHouse/ClickHouse/pull/4604) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复错误 `__asm__` 说明(再次) [\#4621](https://github.com/ClickHouse/ClickHouse/pull/4621) ([Konstantin Podshumok](https://github.com/podshumok)) -- 添加指定设置的能力 `clickhouse-performance-test` 从命令行。 [\#4437](https://github.com/ClickHouse/ClickHouse/pull/4437) ([阿利沙平](https://github.com/alesapin)) -- 将字典测试添加到集成测试。 [\#4477](https://github.com/ClickHouse/ClickHouse/pull/4477) ([阿利沙平](https://github.com/alesapin)) -- 在网站上添加了来自基准测试的查询,以自动化性能测试。 [\#4496](https://github.com/ClickHouse/ClickHouse/pull/4496) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `xxhash.h` 在外部lz4中不存在,因为它是一个实现细节,并且它的符号是命名空间的 `XXH_NAMESPACE` 麦克罗 当lz4是外部的,xxHash也必须是外部的,并且依赖者必须链接到它。 [\#4495](https://github.com/ClickHouse/ClickHouse/pull/4495) ([Origej Desh](https://github.com/orivej)) -- 固定的情况下,当 `quantileTiming` 聚合函数可以用负或浮点参数调用(这修复了使用未定义的行为消毒器的模糊测试)。 [\#4506](https://github.com/ClickHouse/ClickHouse/pull/4506) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 拼写错误更正。 [\#4531](https://github.com/ClickHouse/ClickHouse/pull/4531) ([sdk2](https://github.com/sdk2)) -- 在Mac上修复编译。 [\#4371](https://github.com/ClickHouse/ClickHouse/pull/4371) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- Freebsd和各种不寻常的构建配置的构建修复程序。 [\#4444](https://github.com/ClickHouse/ClickHouse/pull/4444) ([proller](https://github.com/proller)) - -## ClickHouse释放19.3 {#clickhouse-release-19-3} - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-3-9-1-2019-04-02} - -#### 错误修复 {#bug-fixes-12} - -- 修复崩溃 `FULL/RIGHT JOIN` 当我们加入可为空vs不可为空时。 [\#4855](https://github.com/ClickHouse/ClickHouse/pull/4855) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复分段故障 `clickhouse-copier`. [\#4835](https://github.com/ClickHouse/ClickHouse/pull/4835) ([proller](https://github.com/proller)) -- 固定读取 `Array(LowCardinality)` column在极少数情况下,当column包含一个长序列的空数组时。 [\#4850](https://github.com/ClickHouse/ClickHouse/pull/4850) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-13} - -- 添加从自定义用户启动clickhouse服务器映像的方法 [\#4753](https://github.com/ClickHouse/ClickHouse/pull/4753) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-7-2019-03-12} - -#### 错误修复 {#bug-fixes-13} - -- 修正了#3920中的错误。 此错误表现为随机缓存损坏(消息 `Unknown codec family code`, `Cannot seek through file`)和段错误。 这个错误最早出现在19.1版本中,并且存在于19.1.10和19.3.6之前的版本中。 [\#4623](https://github.com/ClickHouse/ClickHouse/pull/4623) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-3-6-2019-03-02} - -#### 错误修复 {#bug-fixes-14} - -- 当线程池中有超过1000个线程时, `std::terminate` 线程退出时可能发生。 [Azat Khuzhin](https://github.com/azat) [\#4485](https://github.com/ClickHouse/ClickHouse/pull/4485) [\#4505](https://github.com/ClickHouse/ClickHouse/pull/4505) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在可以创建 `ReplicatedMergeTree*` 对没有默认值的列进行注释的表和对没有注释和默认值的列进行编解码的表。 还修复编解码器的比较。 [\#4523](https://github.com/ClickHouse/ClickHouse/pull/4523) ([阿利沙平](https://github.com/alesapin)) -- 修复了与数组或元组联接时的崩溃。 [\#4552](https://github.com/ClickHouse/ClickHouse/pull/4552) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复了clickhouse-复印机中的消息崩溃 `ThreadStatus not created`. [\#4540](https://github.com/ClickHouse/ClickHouse/pull/4540) ([Artem Zuikov](https://github.com/4ertus2)) -- 如果使用分布式Ddl,则在服务器关闭时修复了挂机问题。 [\#4472](https://github.com/ClickHouse/ClickHouse/pull/4472) ([Alex Zatelepin](https://github.com/ztlpn)) -- 错误的列编号打印在有关文本格式分析的列数大于10的错误消息中。 [\#4484](https://github.com/ClickHouse/ClickHouse/pull/4484) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-3} - -- 固定构建与启用AVX。 [\#4527](https://github.com/ClickHouse/ClickHouse/pull/4527) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 基于已知版本而不是编译它的内核启用扩展记帐和IO记帐。 [\#4541](https://github.com/ClickHouse/ClickHouse/pull/4541) ([纳瓦托洛梅](https://github.com/nvartolomei)) -- 允许跳过core\_dump的设置。size\_limit,如果限制设置失败,则警告而不是throw。 [\#4473](https://github.com/ClickHouse/ClickHouse/pull/4473) ([proller](https://github.com/proller)) -- 删除了 `inline` 标签 `void readBinary(...)` 在 `Field.cpp`. 也合并冗余 `namespace DB` 块。 [\#4530](https://github.com/ClickHouse/ClickHouse/pull/4530) ([hcz](https://github.com/hczhcz)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-5-2019-02-21} - -#### 错误修复 {#bug-fixes-15} - -- 修正了大型http插入查询处理的错误。 [\#4454](https://github.com/ClickHouse/ClickHouse/pull/4454) ([阿利沙平](https://github.com/alesapin)) -- 修正了向后不兼容的旧版本,由于错误的实现 `send_logs_level` 设置。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了表函数的向后不兼容性 `remote` 与列注释介绍. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-4-2019-02-16} - -#### 改进 {#improvements-4} - -- 执行以下操作时,表索引大小不考虑内存限制 `ATTACH TABLE` 查询。 避免了分离后无法连接表的可能性。 [\#4396](https://github.com/ClickHouse/ClickHouse/pull/4396) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 稍微提高了从ZooKeeper接收的最大字符串和数组大小的限制。 它允许继续与增加的尺寸工作 `CLIENT_JVMFLAGS=-Djute.maxbuffer=...` 在动物园管理员。 [\#4398](https://github.com/ClickHouse/ClickHouse/pull/4398) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 允许修复被遗弃的副本,即使它已经在其队列中拥有大量的节点。 [\#4399](https://github.com/ClickHouse/ClickHouse/pull/4399) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加一个必需的参数 `SET` 索引(最大存储行数)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) - -#### 错误修复 {#bug-fixes-16} - -- 固定 `WITH ROLLUP` 单组结果 `LowCardinality` 钥匙 [\#4384](https://github.com/ClickHouse/ClickHouse/pull/4384) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 在设置索引固定错误(删除颗粒,如果它包含超过 `max_rows` 行)。 [\#4386](https://github.com/ClickHouse/ClickHouse/pull/4386) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 很多的FreeBSD构建修复。 [\#4397](https://github.com/ClickHouse/ClickHouse/pull/4397) ([proller](https://github.com/proller)) -- 固定别名替换查询与子查询包含相同的别名(问题 [\#4110](https://github.com/ClickHouse/ClickHouse/issues/4110)). [\#4351](https://github.com/ClickHouse/ClickHouse/pull/4351) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-4} - -- 添加运行能力 `clickhouse-server` 对于docker镜像中的无状态测试。 [\#4347](https://github.com/ClickHouse/ClickHouse/pull/4347) ([瓦西里\*内姆科夫](https://github.com/Enmk)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-3-3-2019-02-13} - -#### 新功能 {#new-features-6} - -- 添加了 `KILL MUTATION` 允许删除由于某些原因卡住的突变的声明。 已添加 `latest_failed_part`, `latest_fail_time`, `latest_fail_reason` 字段到 `system.mutations` 表更容易排除故障。 [\#4287](https://github.com/ClickHouse/ClickHouse/pull/4287) ([Alex Zatelepin](https://github.com/ztlpn)) -- 添加聚合功能 `entropy` 计算香农熵 [\#4238](https://github.com/ClickHouse/ClickHouse/pull/4238) ([Quid37](https://github.com/Quid37)) -- 添加发送查询的功能 `INSERT INTO tbl VALUES (....` 到服务器而不拆分 `query` 和 `data` 零件。 [\#4301](https://github.com/ClickHouse/ClickHouse/pull/4301) ([阿利沙平](https://github.com/alesapin)) -- 通用实现 `arrayWithConstant` 添加了功能。 [\#4322](https://github.com/ClickHouse/ClickHouse/pull/4322) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 已实施 `NOT BETWEEN` 比较运算符。 [\#4228](https://github.com/ClickHouse/ClickHouse/pull/4228) ([Dmitry Naumov](https://github.com/nezed)) -- 执行 `sumMapFiltered` 为了能够限制其值将被求和的键的数量 `sumMap`. [\#4129](https://github.com/ClickHouse/ClickHouse/pull/4129) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- 增加了支持 `Nullable` 类型 `mysql` 表功能。 [\#4198](https://github.com/ClickHouse/ClickHouse/pull/4198) ([Emmanuel Donin de Rosière](https://github.com/edonin)) -- 支持任意常量表达式 `LIMIT` 条款 [\#4246](https://github.com/ClickHouse/ClickHouse/pull/4246) ([k3box](https://github.com/k3box)) -- 已添加 `topKWeighted` 采用带有(无符号整数)权重的附加参数的聚合函数。 [\#4245](https://github.com/ClickHouse/ClickHouse/pull/4245) ([安德鲁\*戈尔曼](https://github.com/andrewgolman)) -- `StorageJoin` 现在支持 `join_any_take_last_row` 允许复盖同一键的现有值的设置。 [\#3973](https://github.com/ClickHouse/ClickHouse/pull/3973) ([阿莫斯鸟](https://github.com/amosbird) -- 添加功能 `toStartOfInterval`. [\#4304](https://github.com/ClickHouse/ClickHouse/pull/4304) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 已添加 `RowBinaryWithNamesAndTypes` 格式。 [\#4200](https://github.com/ClickHouse/ClickHouse/pull/4200) ([Oleg V.Kozlyuk](https://github.com/DarkWanderer)) -- 已添加 `IPv4` 和 `IPv6` 数据类型。 更有效的实现 `IPv*` 功能。 [\#3669](https://github.com/ClickHouse/ClickHouse/pull/3669) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 添加功能 `toStartOfTenMinutes()`. [\#4298](https://github.com/ClickHouse/ClickHouse/pull/4298) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 已添加 `Protobuf` 输出格式。 [\#4005](https://github.com/ClickHouse/ClickHouse/pull/4005) [\#4158](https://github.com/ClickHouse/ClickHouse/pull/4158) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 增加了对数据导入(插入)HTTP接口的brotli支持。 [\#4235](https://github.com/ClickHouse/ClickHouse/pull/4235) ([米哈伊尔](https://github.com/fandyushin)) -- 增加了提示,而用户做出错字的函数名称或键入命令行客户端。 [\#4239](https://github.com/ClickHouse/ClickHouse/pull/4239) ([Danila Kutenin](https://github.com/danlark1)) -- 已添加 `Query-Id` 到服务器的HTTP响应头。 [\#4231](https://github.com/ClickHouse/ClickHouse/pull/4231) ([米哈伊尔](https://github.com/fandyushin)) - -#### 实验特点 {#experimental-features-2} - -- 已添加 `minmax` 和 `set` MergeTree表引擎系列的数据跳过索引。 [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 增加了转换 `CROSS JOIN` 到 `INNER JOIN` 如果可能的话 [\#4221](https://github.com/ClickHouse/ClickHouse/pull/4221) [\#4266](https://github.com/ClickHouse/ClickHouse/pull/4266) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 错误修复 {#bug-fixes-17} - -- 固定 `Not found column` 对于重复的列 `JOIN ON` 科。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) -- 赂眉露\>\> `START REPLICATED SENDS` 命令开始复制发送。 [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([纳瓦托洛梅](https://github.com/nvartolomei)) -- 固定聚合函数执行 `Array(LowCardinality)` 争论。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 修正了错误的行为,当做 `INSERT ... SELECT ... FROM file(...)` 查询和文件有 `CSVWithNames` 或 `TSVWIthNames` 格式和第一个数据行丢失。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 如果字典不可用,则修复了字典重新加载时的崩溃。 此错误出现在19.1.6中。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) -- 固定 `ALL JOIN` 右表中有重复项。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正了分段故障 `use_uncompressed_cache=1` 和异常与错误的未压缩大小。 此错误出现在19.1.6中。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([阿利沙平](https://github.com/alesapin)) -- 固定 `compile_expressions` 错误与大(超过int16)日期的比较。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([阿利沙平](https://github.com/alesapin)) -- 从表函数选择时固定无限循环 `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 暂时禁用谓词优化 `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([张冬](https://github.com/zhang2014)) -- 固定 `Illegal instruction` 在旧Cpu上使用base64函数时出错。 仅当ClickHouse使用gcc-8编译时,才会重现此错误。 [\#4275](https://github.com/ClickHouse/ClickHouse/pull/4275) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定 `No message received` 通过TLS连接与PostgreSQL ODBC驱动程序交互时出错。 还修复了使用MySQL ODBC驱动程序时的段错误。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误的结果时 `Date` 和 `DateTime` 参数用于条件运算符(函数)的分支 `if`). 增加了函数的通用案例 `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- ClickHouse字典现在加载内 `clickhouse` 过程。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复死锁时 `SELECT` 从一个表 `File` 引擎被重试后 `No such file or directory` 错误 [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从选择时固定的竞争条件 `system.tables` 可能会给 `table doesn't exist` 错误 [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `clickhouse-client` 如果在交互模式下运行,则在加载命令行建议的数据时可以在退出时段错误。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了一个错误,当包含突变的执行 `IN` 操作员产生了不正确的结果。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修正错误:如果有一个数据库 `Dictionary` 引擎中,所有字典在服务器启动时强制加载,如果有来自localhost的ClickHouse源字典,则字典无法加载。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了在服务器关闭时尝试再次创建系统日志时的错误。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 正确返回正确的类型和正确处理锁 `joinGet` 功能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([阿莫斯鸟](https://github.com/amosbird)) -- 已添加 `sumMapWithOverflow` 功能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- 固定段错误 `allow_experimental_multiple_joins_emulation`. [52de2c](https://github.com/ClickHouse/ClickHouse/commit/52de2cd927f7b5257dd67e175f0a5560a48840d0) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正错误与不正确 `Date` 和 `DateTime` 比较。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) -- 在未定义的行为消毒固定模糊测试:增加了参数类型检查 `quantile*Weighted` 家庭的功能。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了在删除旧数据部分时罕见的争用条件可能会失败 `File not found` 错误 [\#4378](https://github.com/ClickHouse/ClickHouse/pull/4378) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复缺少/etc/clickhouse-server/config的安装包。xml [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-5} - -- Debian软件包:根据配置正确的/etc/clickhouse-server/预处理链接。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) -- Freebsd的各种构建修复程序。 [\#4225](https://github.com/ClickHouse/ClickHouse/pull/4225) ([proller](https://github.com/proller)) -- 增加了在perftest中创建,填充和删除表的能力。 [\#4220](https://github.com/ClickHouse/ClickHouse/pull/4220) ([阿利沙平](https://github.com/alesapin)) -- 添加了一个脚本来检查重复的包括。 [\#4326](https://github.com/ClickHouse/ClickHouse/pull/4326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了在性能测试中通过索引运行查询的能力。 [\#4264](https://github.com/ClickHouse/ClickHouse/pull/4264) ([阿利沙平](https://github.com/alesapin)) -- 建议安装带有调试符号的软件包。 [\#4274](https://github.com/ClickHouse/ClickHouse/pull/4274) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 重构性能测试。 更好的记录和信号处理。 [\#4171](https://github.com/ClickHouse/ClickHouse/pull/4171) ([阿利沙平](https://github.com/alesapin)) -- 将文档添加到匿名Yandex。Metrika数据集. [\#4164](https://github.com/ClickHouse/ClickHouse/pull/4164) ([阿利沙平](https://github.com/alesapin)) -- Аdded tool for converting an old month-partitioned part to the custom-partitioned format. [\#4195](https://github.com/ClickHouse/ClickHouse/pull/4195) ([Alex Zatelepin](https://github.com/ztlpn)) -- 添加了有关s3中两个数据集的文档。 [\#4144](https://github.com/ClickHouse/ClickHouse/pull/4144) ([阿利沙平](https://github.com/alesapin)) -- 增加了从拉请求描述创建更新日志的脚本。 [\#4169](https://github.com/ClickHouse/ClickHouse/pull/4169) [\#4173](https://github.com/ClickHouse/ClickHouse/pull/4173) ([KochetovNicolai](https://github.com/KochetovNicolai)) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 为ClickHouse添加了木偶模块。 [\#4182](https://github.com/ClickHouse/ClickHouse/pull/4182) ([Maxim Fedotov](https://github.com/MaxFedotov)) -- 添加了一组无证函数的文档。 [\#4168](https://github.com/ClickHouse/ClickHouse/pull/4168) ([张冬](https://github.com/zhang2014)) -- ARM构建修复。 [\#4210](https://github.com/ClickHouse/ClickHouse/pull/4210)[\#4306](https://github.com/ClickHouse/ClickHouse/pull/4306) [\#4291](https://github.com/ClickHouse/ClickHouse/pull/4291) ([proller](https://github.com/proller)) ([proller](https://github.com/proller)) -- 字典测试现在能够从运行 `ctest`. [\#4189](https://github.com/ClickHouse/ClickHouse/pull/4189) ([proller](https://github.com/proller)) -- 现在 `/etc/ssl` 用作带有SSL证书的默认目录。 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在开始时添加了检查SSE和AVX指令。 [\#4234](https://github.com/ClickHouse/ClickHouse/pull/4234) ([Igr](https://github.com/igron99)) -- 初始化脚本将等待服务器,直到启动。 [\#4281](https://github.com/ClickHouse/ClickHouse/pull/4281) ([proller](https://github.com/proller)) - -#### 向后不兼容的更改 {#backward-incompatible-changes-1} - -- 已删除 `allow_experimental_low_cardinality_type` 设置。 `LowCardinality` 数据类型已准备就绪。 [\#4323](https://github.com/ClickHouse/ClickHouse/pull/4323) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 根据可用内存量减少标记高速缓存大小和未压缩高速缓存大小。 [\#4240](https://github.com/ClickHouse/ClickHouse/pull/4240) ([Lopatin Konstantin](https://github.com/k-lopatin) -- 添加关键字 `INDEX` 在 `CREATE TABLE` 查询。 具有名称的列 `index` 必须使用反引号或双引号引用: `` `index` ``. [\#4143](https://github.com/ClickHouse/ClickHouse/pull/4143) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- `sumMap` 现在提升结果类型而不是溢出。 老 `sumMap` 行为可以通过使用获得 `sumMapWithOverflow` 功能。 [\#4151](https://github.com/ClickHouse/ClickHouse/pull/4151) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) - -#### 性能改进 {#performance-improvements-4} - -- `std::sort` 改为 `pdqsort` 对于没有 `LIMIT`. [\#4236](https://github.com/ClickHouse/ClickHouse/pull/4236) ([Evgenii Pravda](https://github.com/kvinty)) -- 现在服务器重用全局线程池中的线程。 这会影响某些角落情况下的性能。 [\#4150](https://github.com/ClickHouse/ClickHouse/pull/4150) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 改进 {#improvements-5} - -- 实现了对FreeBSD的AIO支持。 [\#4305](https://github.com/ClickHouse/ClickHouse/pull/4305) ([urgordeadbeef](https://github.com/urgordeadbeef)) -- `SELECT * FROM a JOIN b USING a, b` 现在回来 `a` 和 `b` 列仅从左表。 [\#4141](https://github.com/ClickHouse/ClickHouse/pull/4141) ([Artem Zuikov](https://github.com/4ertus2)) -- 允许 `-C` 客户端的选项作为工作 `-c` 选项。 [\#4232](https://github.com/ClickHouse/ClickHouse/pull/4232) ([syominsergey](https://github.com/syominsergey)) -- 现在选项 `--password` 无值使用需要从标准输入的密码。 [\#4230](https://github.com/ClickHouse/ClickHouse/pull/4230) ([BSD\_Conqueror](https://github.com/bsd-conqueror)) -- 在包含字符串文字中添加了非转义元字符的突出显示 `LIKE` 表达式或正则表达式。 [\#4327](https://github.com/ClickHouse/ClickHouse/pull/4327) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加取消HTTP只读查询,如果客户端套接字消失。 [\#4213](https://github.com/ClickHouse/ClickHouse/pull/4213) ([纳瓦托洛梅](https://github.com/nvartolomei)) -- 现在,服务器报告进度,以保持客户端连接活跃。 [\#4215](https://github.com/ClickHouse/ClickHouse/pull/4215) ([伊万](https://github.com/abyss7)) -- 稍微好一点的消息与优化查询的原因 `optimize_throw_if_noop` 设置已启用。 [\#4294](https://github.com/ClickHouse/ClickHouse/pull/4294) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了支持 `--version` clickhouse服务器的选项。 [\#4251](https://github.com/ClickHouse/ClickHouse/pull/4251) ([Lopatin Konstantin](https://github.com/k-lopatin)) -- 已添加 `--help/-h` 选项 `clickhouse-server`. [\#4233](https://github.com/ClickHouse/ClickHouse/pull/4233) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 增加了对具有聚合函数状态结果的标量子查询的支持。 [\#4348](https://github.com/ClickHouse/ClickHouse/pull/4348) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 改进服务器关闭时间并改变等待时间。 [\#4372](https://github.com/ClickHouse/ClickHouse/pull/4372) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加了有关replicated\_can\_become\_leader设置到系统的信息。如果副本不会尝试成为领导者,则添加日志记录。 [\#4379](https://github.com/ClickHouse/ClickHouse/pull/4379) ([Alex Zatelepin](https://github.com/ztlpn)) - -## ClickHouse释放19.1 {#clickhouse-release-19-1} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-14-2019-03-14} - -- 修正错误 `Column ... queried more than once` 这可能发生,如果设置 `asterisk_left_columns_only` 在使用的情况下设置为1 `GLOBAL JOIN` 与 `SELECT *` (罕见的情况)。 该问题在19.3及更新版本中不存在。 [6bac7d8d](https://github.com/ClickHouse/ClickHouse/pull/4692/commits/6bac7d8d11a9b0d6de0b32b53c47eb2f6f8e7062) ([Artem Zuikov](https://github.com/4ertus2)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-13-2019-03-12} - -此版本包含与19.3.7完全相同的补丁集。 - -### 碌莽禄,拢,010-68520682\戮卤篓拢,010-68520682\ {#clickhouse-release-19-1-10-2019-03-03} - -此版本包含与19.3.6完全相同的补丁集。 - -## ClickHouse释放19.1 {#clickhouse-release-19-1-1} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-9-2019-02-21} - -#### 错误修复 {#bug-fixes-18} - -- 修正了向后不兼容的旧版本,由于错误的实现 `send_logs_level` 设置。 [\#4445](https://github.com/ClickHouse/ClickHouse/pull/4445) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了表函数的向后不兼容性 `remote` 与列注释介绍. [\#4446](https://github.com/ClickHouse/ClickHouse/pull/4446) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-8-2019-02-16} - -#### 错误修复 {#bug-fixes-19} - -- 修复缺少/etc/clickhouse-server/config的安装包。xml [\#4343](https://github.com/ClickHouse/ClickHouse/pull/4343) ([proller](https://github.com/proller)) - -## ClickHouse释放19.1 {#clickhouse-release-19-1-2} - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-7-2019-02-15} - -#### 错误修复 {#bug-fixes-20} - -- 正确返回正确的类型和正确处理锁 `joinGet` 功能。 [\#4153](https://github.com/ClickHouse/ClickHouse/pull/4153) ([阿莫斯鸟](https://github.com/amosbird)) -- 修复了在服务器关闭时尝试再次创建系统日志时的错误。 [\#4254](https://github.com/ClickHouse/ClickHouse/pull/4254) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误:如果有一个数据库 `Dictionary` 引擎中,所有字典在服务器启动时强制加载,如果有来自localhost的ClickHouse源字典,则字典无法加载。 [\#4255](https://github.com/ClickHouse/ClickHouse/pull/4255) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了一个错误,当包含突变的执行 `IN` 操作员产生了不正确的结果。 [\#4099](https://github.com/ClickHouse/ClickHouse/pull/4099) ([Alex Zatelepin](https://github.com/ztlpn)) -- `clickhouse-client` 如果在交互模式下运行,则在加载命令行建议的数据时可以在退出时段错误。 [\#4317](https://github.com/ClickHouse/ClickHouse/pull/4317) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从选择时固定的竞争条件 `system.tables` 可能会给 `table doesn't exist` 错误 [\#4313](https://github.com/ClickHouse/ClickHouse/pull/4313) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复死锁时 `SELECT` 从一个表 `File` 引擎被重试后 `No such file or directory` 错误 [\#4161](https://github.com/ClickHouse/ClickHouse/pull/4161) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了一个问题:本地ClickHouse字典通过TCP加载,但应该在进程中加载。 [\#4166](https://github.com/ClickHouse/ClickHouse/pull/4166) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定 `No message received` 通过TLS连接与PostgreSQL ODBC驱动程序交互时出错。 还修复了使用MySQL ODBC驱动程序时的段错误。 [\#4170](https://github.com/ClickHouse/ClickHouse/pull/4170) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 暂时禁用谓词优化 `ORDER BY`. [\#3890](https://github.com/ClickHouse/ClickHouse/pull/3890) ([张冬](https://github.com/zhang2014)) -- 从表函数选择时固定无限循环 `numbers(0)`. [\#4280](https://github.com/ClickHouse/ClickHouse/pull/4280) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定 `compile_expressions` 错误与大(超过int16)日期的比较。 [\#4341](https://github.com/ClickHouse/ClickHouse/pull/4341) ([阿利沙平](https://github.com/alesapin)) -- 修正了分段故障 `uncompressed_cache=1` 和异常与错误的未压缩大小。 [\#4186](https://github.com/ClickHouse/ClickHouse/pull/4186) ([阿利沙平](https://github.com/alesapin)) -- 固定 `ALL JOIN` 右表中有重复项。 [\#4184](https://github.com/ClickHouse/ClickHouse/pull/4184) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正了错误的行为,当做 `INSERT ... SELECT ... FROM file(...)` 查询和文件有 `CSVWithNames` 或 `TSVWIthNames` 格式和第一个数据行丢失。 [\#4297](https://github.com/ClickHouse/ClickHouse/pull/4297) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定聚合函数执行 `Array(LowCardinality)` 争论。 [\#4055](https://github.com/ClickHouse/ClickHouse/pull/4055) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- Debian软件包:根据配置正确的/etc/clickhouse-server/预处理链接。 [\#4205](https://github.com/ClickHouse/ClickHouse/pull/4205) ([proller](https://github.com/proller)) -- 在未定义的行为消毒固定模糊测试:增加了参数类型检查 `quantile*Weighted` 家庭的功能。 [\#4145](https://github.com/ClickHouse/ClickHouse/pull/4145) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 赂眉露\>\> `START REPLICATED SENDS` 命令开始复制发送。 [\#4229](https://github.com/ClickHouse/ClickHouse/pull/4229) ([纳瓦托洛梅](https://github.com/nvartolomei)) -- 固定 `Not found column` 对于联接部分中的重复列。 [\#4279](https://github.com/ClickHouse/ClickHouse/pull/4279) ([Artem Zuikov](https://github.com/4ertus2)) -- 现在 `/etc/ssl` 用作带有SSL证书的默认目录。 [\#4167](https://github.com/ClickHouse/ClickHouse/pull/4167) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 如果字典不可用,则修复了字典重新加载时的崩溃。 [\#4188](https://github.com/ClickHouse/ClickHouse/pull/4188) ([proller](https://github.com/proller)) -- 修正错误与不正确 `Date` 和 `DateTime` 比较。 [\#4237](https://github.com/ClickHouse/ClickHouse/pull/4237) ([valexey](https://github.com/valexey)) -- 修正错误的结果时 `Date` 和 `DateTime` 参数用于条件运算符(函数)的分支 `if`). 增加了函数的通用案例 `if`. [\#4243](https://github.com/ClickHouse/ClickHouse/pull/4243) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -### 碌莽禄,拢,010-68520682\ {#clickhouse-release-19-1-6-2019-01-24} - -#### 新功能 {#new-features-7} - -- 自定义每列压缩编解码器的表。 [\#3899](https://github.com/ClickHouse/ClickHouse/pull/3899) [\#4111](https://github.com/ClickHouse/ClickHouse/pull/4111) ([阿利沙平](https://github.com/alesapin), [张冬](https://github.com/zhang2014), [阿纳托利](https://github.com/Sindbag)) -- 添加压缩编解ec `Delta`. [\#4052](https://github.com/ClickHouse/ClickHouse/pull/4052) ([阿利沙平](https://github.com/alesapin)) -- 允许 `ALTER` 压缩编解ecs。 [\#4054](https://github.com/ClickHouse/ClickHouse/pull/4054) ([阿利沙平](https://github.com/alesapin)) -- 新增功能 `left`, `right`, `trim`, `ltrim`, `rtrim`, `timestampadd`, `timestampsub` 对于SQL标准的兼容性。 [\#3826](https://github.com/ClickHouse/ClickHouse/pull/3826) ([伊万\*布林科夫](https://github.com/blinkov)) -- 支持写入 `HDFS` 表和 `hdfs` 表功能。 [\#4084](https://github.com/ClickHouse/ClickHouse/pull/4084) ([阿利沙平](https://github.com/alesapin)) -- 增加了从big haystack中搜索多个常量字符串的功能: `multiPosition`, `multiSearch` ,`firstMatch` 也与 `-UTF8`, `-CaseInsensitive`,和 `-CaseInsensitiveUTF8` 变体。 [\#4053](https://github.com/ClickHouse/ClickHouse/pull/4053) ([Danila Kutenin](https://github.com/danlark1)) -- 修剪未使用的碎片,如果 `SELECT` 通过分片键查询过滤器(设置 `optimize_skip_unused_shards`). [\#3851](https://github.com/ClickHouse/ClickHouse/pull/3851) ([Gleb Kanterov](https://github.com/kanterov), [伊万](https://github.com/abyss7)) -- 允许 `Kafka` 引擎忽略每个块的解析错误数。 [\#4094](https://github.com/ClickHouse/ClickHouse/pull/4094) ([伊万](https://github.com/abyss7)) -- 增加了对 `CatBoost` 多类模型评估。 功能 `modelEvaluate` 返回带有多类模型的每类原始预测的元组。 `libcatboostmodel.so` 应建立与 [\#607](https://github.com/catboost/catboost/pull/607). [\#3959](https://github.com/ClickHouse/ClickHouse/pull/3959) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 新增功能 `filesystemAvailable`, `filesystemFree`, `filesystemCapacity`. [\#4097](https://github.com/ClickHouse/ClickHouse/pull/4097) ([Boris Granveaud](https://github.com/bgranvea)) -- 添加了哈希函数 `xxHash64` 和 `xxHash32`. [\#3905](https://github.com/ClickHouse/ClickHouse/pull/3905) ([filimonov](https://github.com/filimonov)) -- 已添加 `gccMurmurHash` 散列函数(GCC风味杂音散列),它使用相同的散列种子 [海湾合作委员会](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) [\#4000](https://github.com/ClickHouse/ClickHouse/pull/4000) ([sundyli](https://github.com/sundy-li)) -- 添加了哈希函数 `javaHash`, `hiveHash`. [\#3811](https://github.com/ClickHouse/ClickHouse/pull/3811) ([上书结365](https://github.com/shangshujie365)) -- 添加表功能 `remoteSecure`. 函数的工作原理为 `remote`,但使用安全连接。 [\#4088](https://github.com/ClickHouse/ClickHouse/pull/4088) ([proller](https://github.com/proller)) - -#### 实验特点 {#experimental-features-3} - -- 添加了多个联接仿真 (`allow_experimental_multiple_joins_emulation` 设置)。 [\#3946](https://github.com/ClickHouse/ClickHouse/pull/3946) ([Artem Zuikov](https://github.com/4ertus2)) - -#### 错误修复 {#bug-fixes-21} - -- 赂眉露\>\> `compiled_expression_cache_size` 默认情况下设置有限,以降低内存消耗。 [\#4041](https://github.com/ClickHouse/ClickHouse/pull/4041) ([阿利沙平](https://github.com/alesapin)) -- 修复导致执行更改复制表的线程和从ZooKeeper更新配置的线程中挂断的错误。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3891](https://github.com/ClickHouse/ClickHouse/issues/3891) [\#3934](https://github.com/ClickHouse/ClickHouse/pull/3934) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修复了执行分布式ALTER任务时的争用条件。 争用条件导致多个副本试图执行任务和所有副本,除了一个失败与ZooKeeper错误。 [\#3904](https://github.com/ClickHouse/ClickHouse/pull/3904) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修复错误时 `from_zk` 在对ZooKeeper的请求超时后,配置元素没有刷新。 [\#2947](https://github.com/ClickHouse/ClickHouse/issues/2947) [\#3947](https://github.com/ClickHouse/ClickHouse/pull/3947) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修复IPv4子网掩码错误前缀的错误。 [\#3945](https://github.com/ClickHouse/ClickHouse/pull/3945) ([阿利沙平](https://github.com/alesapin)) -- 固定崩溃 (`std::terminate`)在极少数情况下,由于资源耗尽而无法创建新线程。 [\#3956](https://github.com/ClickHouse/ClickHouse/pull/3956) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误时 `remote` 表函数执行时,错误的限制被用于 `getStructureOfRemoteTable`. [\#4009](https://github.com/ClickHouse/ClickHouse/pull/4009) ([阿利沙平](https://github.com/alesapin)) -- 修复netlink套接字的泄漏。 它们被放置在一个池中,在那里它们永远不会被删除,并且当所有当前套接字都在使用时,在新线程开始时创建了新的套接字。 [\#4017](https://github.com/ClickHouse/ClickHouse/pull/4017) ([Alex Zatelepin](https://github.com/ztlpn)) -- 修复关闭错误 `/proc/self/fd` 目录早于所有fds被读取 `/proc` 分叉后 `odbc-bridge` 子进程。 [\#4120](https://github.com/ClickHouse/ClickHouse/pull/4120) ([阿利沙平](https://github.com/alesapin)) -- 在主键中使用字符串的情况下,固定字符串到UInt单调转换。 [\#3870](https://github.com/ClickHouse/ClickHouse/pull/3870) ([张冬](https://github.com/zhang2014)) -- 整数转换函数单调性计算中的固定误差。 [\#3921](https://github.com/ClickHouse/ClickHouse/pull/3921) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复段错误 `arrayEnumerateUniq`, `arrayEnumerateDense` 函数在一些无效的参数的情况下。 [\#3909](https://github.com/ClickHouse/ClickHouse/pull/3909) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在StorageMerge修复UB。 [\#3910](https://github.com/ClickHouse/ClickHouse/pull/3910) ([阿莫斯鸟](https://github.com/amosbird)) -- 修正函数中的段错误 `addDays`, `subtractDays`. [\#3913](https://github.com/ClickHouse/ClickHouse/pull/3913) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正错误:功能 `round`, `floor`, `trunc`, `ceil` 在整数参数和大负比例执行时可能会返回虚假结果。 [\#3914](https://github.com/ClickHouse/ClickHouse/pull/3914) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了一个错误引起的 ‘kill query sync’ 从而导致核心转储。 [\#3916](https://github.com/ClickHouse/ClickHouse/pull/3916) ([muVulDeePecker](https://github.com/fancyqlx)) -- 修复空复制队列后延迟较长的bug。 [\#3928](https://github.com/ClickHouse/ClickHouse/pull/3928) [\#3932](https://github.com/ClickHouse/ClickHouse/pull/3932) ([阿利沙平](https://github.com/alesapin)) -- 修复了插入到表中的过多内存使用情况 `LowCardinality` 主键。 [\#3955](https://github.com/ClickHouse/ClickHouse/pull/3955) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 固定 `LowCardinality` 序列化 `Native` 在空数组的情况下格式化。 [\#3907](https://github.com/ClickHouse/ClickHouse/issues/3907) [\#4011](https://github.com/ClickHouse/ClickHouse/pull/4011) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 固定不正确的结果,而使用distinct通过单LowCardinality数字列。 [\#3895](https://github.com/ClickHouse/ClickHouse/issues/3895) [\#4012](https://github.com/ClickHouse/ClickHouse/pull/4012) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 固定专门的聚合与LowCardinality键(以防万一 `compile` 设置已启用)。 [\#3886](https://github.com/ClickHouse/ClickHouse/pull/3886) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 修复复制表查询的用户和密码转发。 [\#3957](https://github.com/ClickHouse/ClickHouse/pull/3957) ([阿利沙平](https://github.com/alesapin)) ([小路](https://github.com/nicelulu)) -- 修复了在重新加载字典时在字典数据库中列出表时可能发生的非常罕见的争用条件。 [\#3970](https://github.com/ClickHouse/ClickHouse/pull/3970) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了与ROLLUP或CUBE一起使用时的错误结果。 [\#3756](https://github.com/ClickHouse/ClickHouse/issues/3756) [\#3837](https://github.com/ClickHouse/ClickHouse/pull/3837) ([周三](https://github.com/reflection)) -- 用于查询的固定列别名 `JOIN ON` 语法和分布式表。 [\#3980](https://github.com/ClickHouse/ClickHouse/pull/3980) ([张冬](https://github.com/zhang2014)) -- 在内部实现固定的错误 `quantileTDigest` (由阿尔乔姆Vakhrushev发现)。 这个错误从来没有发生在ClickHouse中,只有那些直接使用ClickHouse代码库作为库的人才有关。 [\#3935](https://github.com/ClickHouse/ClickHouse/pull/3935) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 改进 {#improvements-6} - -- 支持 `IF NOT EXISTS` 在 `ALTER TABLE ADD COLUMN` 发言以及 `IF EXISTS` 在 `DROP/MODIFY/CLEAR/COMMENT COLUMN`. [\#3900](https://github.com/ClickHouse/ClickHouse/pull/3900) ([Boris Granveaud](https://github.com/bgranvea)) -- 功能 `parseDateTimeBestEffort`:支持格式 `DD.MM.YYYY`, `DD.MM.YY`, `DD-MM-YYYY`, `DD-Mon-YYYY`, `DD/Month/YYYY` 和相似。 [\#3922](https://github.com/ClickHouse/ClickHouse/pull/3922) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- `CapnProtoInputStream` 现在支持锯齿结构。 [\#4063](https://github.com/ClickHouse/ClickHouse/pull/4063) ([Odin Hultgren Van Der Horst](https://github.com/Miniwoffer)) -- 可用性改进:增加了从数据目录的所有者启动服务器进程的检查。 如果数据属于非root用户,则不允许从root用户启动服务器。 [\#3785](https://github.com/ClickHouse/ClickHouse/pull/3785) ([谢尔盖-v-加尔采夫](https://github.com/sergey-v-galtsev)) -- 在分析具有联接的查询期间检查所需列的更好的逻辑。 [\#3930](https://github.com/ClickHouse/ClickHouse/pull/3930) ([Artem Zuikov](https://github.com/4ertus2)) -- 减少在单个服务器中有大量分布式表的情况下的连接数。 [\#3726](https://github.com/ClickHouse/ClickHouse/pull/3726) ([张冬](https://github.com/zhang2014)) -- 支持的总计行 `WITH TOTALS` 查询ODBC驱动程序。 [\#3836](https://github.com/ClickHouse/ClickHouse/pull/3836) ([Maksim Koritckiy](https://github.com/nightweb)) -- 允许使用 `Enum`s为if函数内的整数。 [\#3875](https://github.com/ClickHouse/ClickHouse/pull/3875) ([伊万](https://github.com/abyss7)) -- 已添加 `low_cardinality_allow_in_native_format` 设置。 如果禁用,请不要使用 `LowCadrinality` 输入 `Native` 格式。 [\#3879](https://github.com/ClickHouse/ClickHouse/pull/3879) ([KochetovNicolai](https://github.com/KochetovNicolai)) -- 从编译表达式缓存中删除了一些冗余对象以降低内存使用率。 [\#4042](https://github.com/ClickHouse/ClickHouse/pull/4042) ([阿利沙平](https://github.com/alesapin)) -- 添加检查 `SET send_logs_level = 'value'` 查询接受适当的值。 [\#3873](https://github.com/ClickHouse/ClickHouse/pull/3873) ([Sabyanin马克西姆](https://github.com/s-mx)) -- 固定数据类型检查类型转换功能。 [\#3896](https://github.com/ClickHouse/ClickHouse/pull/3896) ([张冬](https://github.com/zhang2014)) - -#### 性能改进 {#performance-improvements-5} - -- 添加MergeTree设置 `use_minimalistic_part_header_in_zookeeper`. 如果启用,复制的表将在单个零件znode中存储紧凑零件元数据。 这可以显着减少ZooKeeper快照大小(特别是如果表有很多列)。 请注意,启用此设置后,您将无法降级到不支持它的版本。 [\#3960](https://github.com/ClickHouse/ClickHouse/pull/3960) ([Alex Zatelepin](https://github.com/ztlpn)) -- 为函数添加基于DFA的实现 `sequenceMatch` 和 `sequenceCount` 以防模式不包含时间。 [\#4004](https://github.com/ClickHouse/ClickHouse/pull/4004) ([Léo Ercolanelli](https://github.com/ercolanelli-leo)) -- 整数序列化的性能改进。 [\#3968](https://github.com/ClickHouse/ClickHouse/pull/3968) ([阿莫斯鸟](https://github.com/amosbird)) -- 零左填充PODArray,使-1元素始终有效并归零。 它用于无分支计算偏移量。 [\#3920](https://github.com/ClickHouse/ClickHouse/pull/3920) ([阿莫斯鸟](https://github.com/amosbird)) -- 还原 `jemalloc` 版本导致性能下降。 [\#4018](https://github.com/ClickHouse/ClickHouse/pull/4018) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 向后不兼容的更改 {#backward-incompatible-changes-2} - -- 删除无证功能 `ALTER MODIFY PRIMARY KEY` 因为它被 `ALTER MODIFY ORDER BY` 指挥部 [\#3887](https://github.com/ClickHouse/ClickHouse/pull/3887) ([Alex Zatelepin](https://github.com/ztlpn)) -- 删除功能 `shardByHash`. [\#3833](https://github.com/ClickHouse/ClickHouse/pull/3833) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 禁止使用具有结果类型的标量子查询 `AggregateFunction`. [\#3865](https://github.com/ClickHouse/ClickHouse/pull/3865) ([伊万](https://github.com/abyss7)) - -#### 构建/测试/打包改进 {#buildtestingpackaging-improvements-6} - -- 增加了对PowerPC的支持 (`ppc64le`)建设。 [\#4132](https://github.com/ClickHouse/ClickHouse/pull/4132) ([Danila Kutenin](https://github.com/danlark1)) -- 有状态功能测试在公共可用数据集上运行。 [\#3969](https://github.com/ClickHouse/ClickHouse/pull/3969) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了服务器无法启动时的错误 `bash: /usr/bin/clickhouse-extract-from-config: Operation not permitted` Docker或systemd-nspawn中的消息。 [\#4136](https://github.com/ClickHouse/ClickHouse/pull/4136) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新 `rdkafka` 库v1.0.0-RC5。 使用cppkafka而不是原始的C接口。 [\#4025](https://github.com/ClickHouse/ClickHouse/pull/4025) ([伊万](https://github.com/abyss7)) -- 更新 `mariadb-client` 图书馆. 修复了UBSan发现的问题之一。 [\#3924](https://github.com/ClickHouse/ClickHouse/pull/3924) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- UBSan版本的一些修复。 [\#3926](https://github.com/ClickHouse/ClickHouse/pull/3926) [\#3021](https://github.com/ClickHouse/ClickHouse/pull/3021) [\#3948](https://github.com/ClickHouse/ClickHouse/pull/3948) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了使用UBSan构建的每次提交运行的测试。 -- 增加了PVS-Studio静态分析器的每次提交运行。 -- 修复了PVS-Studio发现的错误。 [\#4013](https://github.com/ClickHouse/ClickHouse/pull/4013) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了glibc兼容性问题。 [\#4100](https://github.com/ClickHouse/ClickHouse/pull/4100) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 将Docker映像移动到18.10并为glibc\>=2.28添加兼容性文件 [\#3965](https://github.com/ClickHouse/ClickHouse/pull/3965) ([阿利沙平](https://github.com/alesapin)) -- 如果用户不想在服务器码头镜像中播放目录,请添加env变量。 [\#3967](https://github.com/ClickHouse/ClickHouse/pull/3967) ([阿利沙平](https://github.com/alesapin)) -- 启用了大多数来自警告 `-Weverything` 在叮当声。 已启用 `-Wpedantic`. [\#3986](https://github.com/ClickHouse/ClickHouse/pull/3986) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了一些只在clang8中可用的警告。 [\#3993](https://github.com/ClickHouse/ClickHouse/pull/3993) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 链接到 `libLLVM` 在使用共享链接时,而不是单独的LLVM库。 [\#3989](https://github.com/ClickHouse/ClickHouse/pull/3989) ([Origej Desh](https://github.com/orivej)) -- 为测试图像添加了消毒变量。 [\#4072](https://github.com/ClickHouse/ClickHouse/pull/4072) ([阿利沙平](https://github.com/alesapin)) -- `clickhouse-server` debian软件包会推荐 `libcap2-bin` 使用包 `setcap` 设置功能的工具。 这是可选的。 [\#4093](https://github.com/ClickHouse/ClickHouse/pull/4093) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 改进的编译时间,固定包括。 [\#3898](https://github.com/ClickHouse/ClickHouse/pull/3898) ([proller](https://github.com/proller)) -- 添加了哈希函数的性能测试。 [\#3918](https://github.com/ClickHouse/ClickHouse/pull/3918) ([filimonov](https://github.com/filimonov)) -- 固定循环库依赖。 [\#3958](https://github.com/ClickHouse/ClickHouse/pull/3958) ([proller](https://github.com/proller)) -- 改进的编译与低可用内存。 [\#4030](https://github.com/ClickHouse/ClickHouse/pull/4030) ([proller](https://github.com/proller)) -- 添加了测试脚本,以重现性能下降 `jemalloc`. [\#4036](https://github.com/ClickHouse/ClickHouse/pull/4036) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了在下面的注释和字符串文字拼写错误 `dbms`. [\#4122](https://github.com/ClickHouse/ClickHouse/pull/4122) ([maiha](https://github.com/maiha)) -- 修正了错别字的评论。 [\#4089](https://github.com/ClickHouse/ClickHouse/pull/4089) ([Evgenii Pravda](https://github.com/kvinty)) - -## [2018年的更新日志](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2018.md) {#changelog-for-2018} diff --git a/docs/zh/whats_new/changelog/index.md b/docs/zh/whats_new/changelog/index.md deleted file mode 100644 index 33bb7bfd5f1..00000000000 --- a/docs/zh/whats_new/changelog/index.md +++ /dev/null @@ -1,665 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 ---- - -## 碌莽禄release拢.0755-88888888 {#clickhouse-release-v20-3} - -### ClickHouse版本v20.3.4.10,2020-03-20 {#clickhouse-release-v20-3-4-10-2020-03-20} - -#### 错误修复 {#bug-fix} - -- 此版本还包含20.1.8.41的所有错误修复 -- 修复丢失 `rows_before_limit_at_least` 用于通过http进行查询(使用处理器管道)。 这修复 [\#9730](https://github.com/ClickHouse/ClickHouse/issues/9730). [\#9757](https://github.com/ClickHouse/ClickHouse/pull/9757) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -### ClickHouse释放v20.3.3.6,2020-03-17 {#clickhouse-release-v20-3-3-6-2020-03-17} - -#### 错误修复 {#bug-fix-1} - -- 此版本还包含20.1.7.38的所有错误修复 -- 修复复制中的错误,如果用户在以前的版本上执行了突变,则不允许复制工作。 这修复 [\#9645](https://github.com/ClickHouse/ClickHouse/issues/9645). [\#9652](https://github.com/ClickHouse/ClickHouse/pull/9652) ([阿利沙平](https://github.com/alesapin)). 它使版本20.3再次向后兼容。 -- 添加设置 `use_compact_format_in_distributed_parts_names` 它允许写文件 `INSERT` 查询到 `Distributed` 表格格式更紧凑。 这修复 [\#9647](https://github.com/ClickHouse/ClickHouse/issues/9647). [\#9653](https://github.com/ClickHouse/ClickHouse/pull/9653) ([阿利沙平](https://github.com/alesapin)). 它使版本20.3再次向后兼容。 - -### ClickHouse版本v20.3.2.1,2020-03-12 {#clickhouse-release-v20-3-2-1-2020-03-12} - -#### 向后不兼容的更改 {#backward-incompatible-change} - -- 修正了这个问题 `file name too long` 当发送数据 `Distributed` 大量副本的表。 修复了服务器日志中显示副本凭据的问题。 磁盘上的目录名格式已更改为 `[shard{shard_index}[_replica{replica_index}]]`. [\#8911](https://github.com/ClickHouse/ClickHouse/pull/8911) ([米哈伊尔\*科罗托夫](https://github.com/millb))升级到新版本后,您将无法在没有人工干预的情况下降级,因为旧的服务器版本无法识别新的目录格式。 如果要降级,则必须手动将相应的目录重命名为旧格式。 仅当您使用了异步时,此更改才相关 `INSERT`s到 `Distributed` 桌子 在版本20.3.3中,我们将介绍一个设置,让您逐渐启用新格式。 -- 更改了mutation命令的复制日志条目的格式。 在安装新版本之前,您必须等待旧的突变处理。 -- 实现简单的内存分析器,将堆栈跟踪转储到 `system.trace_log` 超过软分配限制的每N个字节 [\#8765](https://github.com/ClickHouse/ClickHouse/pull/8765) ([伊万](https://github.com/abyss7)) [\#9472](https://github.com/ClickHouse/ClickHouse/pull/9472) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov))列 `system.trace_log` 从改名 `timer_type` 到 `trace_type`. 这将需要改变第三方性能分析和flamegraph处理工具。 -- 在任何地方使用操作系统线程id,而不是内部线程编号。 这修复 [\#7477](https://github.com/ClickHouse/ClickHouse/issues/7477) 老 `clickhouse-client` 无法接收从服务器发送的日志,当设置 `send_logs_level` 已启用,因为结构化日志消息的名称和类型已更改。 另一方面,不同的服务器版本可以相互发送不同类型的日志。 当你不使用 `send_logs_level` 设置,你不应该关心。 [\#8954](https://github.com/ClickHouse/ClickHouse/pull/8954) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除 `indexHint` 功能 [\#9542](https://github.com/ClickHouse/ClickHouse/pull/9542) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除 `findClusterIndex`, `findClusterValue` 功能。 这修复 [\#8641](https://github.com/ClickHouse/ClickHouse/issues/8641). 如果您正在使用这些功能,请发送电子邮件至 `clickhouse-feedback@yandex-team.com` [\#9543](https://github.com/ClickHouse/ClickHouse/pull/9543) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在不允许创建列或添加列 `SELECT` 子查询作为默认表达式。 [\#9481](https://github.com/ClickHouse/ClickHouse/pull/9481) ([阿利沙平](https://github.com/alesapin)) -- 需要联接中的子查询的别名。 [\#9274](https://github.com/ClickHouse/ClickHouse/pull/9274) ([Artem Zuikov](https://github.com/4ertus2)) -- 改进 `ALTER MODIFY/ADD` 查询逻辑。 现在你不能 `ADD` 不带类型的列, `MODIFY` 默认表达式不改变列的类型和 `MODIFY` type不会丢失默认表达式值。 修复 [\#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). [\#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) ([阿利沙平](https://github.com/alesapin)) -- 要求重新启动服务器以应用日志记录配置中的更改。 这是一种临时解决方法,可以避免服务器将日志记录到已删除的日志文件中的错误(请参阅 [\#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [\#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 设置 `experimental_use_processors` 默认情况下启用。 此设置允许使用新的查询管道。 这是内部重构,我们期望没有明显的变化。 如果您将看到任何问题,请将其设置为返回零。 [\#8768](https://github.com/ClickHouse/ClickHouse/pull/8768) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 新功能 {#new-feature} - -- 添加 `Avro` 和 `AvroConfluent` 输入/输出格式 [\#8571](https://github.com/ClickHouse/ClickHouse/pull/8571) ([安德鲁Onyshchuk](https://github.com/oandrew)) [\#8957](https://github.com/ClickHouse/ClickHouse/pull/8957) ([安德鲁Onyshchuk](https://github.com/oandrew)) [\#8717](https://github.com/ClickHouse/ClickHouse/pull/8717) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 过期密钥的多线程和非阻塞更新 `cache` 字典(可选的权限读取旧的)。 [\#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 添加查询 `ALTER ... MATERIALIZE TTL`. 它运行突变,强制通过TTL删除过期的数据,并重新计算所有部分有关ttl的元信息。 [\#8775](https://github.com/ClickHouse/ClickHouse/pull/8775) ([安东\*波波夫](https://github.com/CurtizJ)) -- 如果需要,从HashJoin切换到MergeJoin(在磁盘上 [\#9082](https://github.com/ClickHouse/ClickHouse/pull/9082) ([Artem Zuikov](https://github.com/4ertus2)) -- 已添加 `MOVE PARTITION` 命令 `ALTER TABLE` [\#4729](https://github.com/ClickHouse/ClickHouse/issues/4729) [\#6168](https://github.com/ClickHouse/ClickHouse/pull/6168) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 动态地从配置文件重新加载存储配置。 [\#8594](https://github.com/ClickHouse/ClickHouse/pull/8594) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 允许更改 `storage_policy` 为了不那么富有的人。 [\#8107](https://github.com/ClickHouse/ClickHouse/pull/8107) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 增加了对s3存储和表功能的globs/通配符的支持。 [\#8851](https://github.com/ClickHouse/ClickHouse/pull/8851) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 执行 `bitAnd`, `bitOr`, `bitXor`, `bitNot` 为 `FixedString(N)` 数据类型。 [\#9091](https://github.com/ClickHouse/ClickHouse/pull/9091) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 添加功能 `bitCount`. 这修复 [\#8702](https://github.com/ClickHouse/ClickHouse/issues/8702). [\#8708](https://github.com/ClickHouse/ClickHouse/pull/8708) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#8749](https://github.com/ClickHouse/ClickHouse/pull/8749) ([ikopylov](https://github.com/ikopylov)) -- 添加 `generateRandom` 表函数生成具有给定模式的随机行。 允许用数据填充任意测试表。 [\#8994](https://github.com/ClickHouse/ClickHouse/pull/8994) ([Ilya Yatsishin](https://github.com/qoega)) -- `JSONEachRowFormat`:当对象包含在顶层数组中时,支持特殊情况。 [\#8860](https://github.com/ClickHouse/ClickHouse/pull/8860) ([克鲁格洛夫\*帕维尔](https://github.com/Avogar)) -- 现在可以创建一个列 `DEFAULT` 取决于默认列的表达式 `ALIAS` 表达。 [\#9489](https://github.com/ClickHouse/ClickHouse/pull/9489) ([阿利沙平](https://github.com/alesapin)) -- 允许指定 `--limit` 超过源数据大小 `clickhouse-obfuscator`. 数据将以不同的随机种子重复。 [\#9155](https://github.com/ClickHouse/ClickHouse/pull/9155) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 已添加 `groupArraySample` 功能(类似于 `groupArray`)与reservior采样算法。 [\#8286](https://github.com/ClickHouse/ClickHouse/pull/8286) ([阿莫斯鸟](https://github.com/amosbird)) -- 现在,您可以监视更新队列的大小 `cache`/`complex_key_cache` 通过系统指标字典。 [\#9413](https://github.com/ClickHouse/ClickHouse/pull/9413) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 允许使用CRLF作为CSV输出格式的行分隔符与设置 `output_format_csv_crlf_end_of_line` 设置为1 [\#8934](https://github.com/ClickHouse/ClickHouse/pull/8934) [\#8935](https://github.com/ClickHouse/ClickHouse/pull/8935) [\#8963](https://github.com/ClickHouse/ClickHouse/pull/8963) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 实现的更多功能 [H3](https://github.com/uber/h3) API: `h3GetBaseCell`, `h3HexAreaM2`, `h3IndexesAreNeighbors`, `h3ToChildren`, `h3ToString` 和 `stringToH3` [\#8938](https://github.com/ClickHouse/ClickHouse/pull/8938) ([Nico Mandery](https://github.com/nmandery)) -- 引入新设置: `max_parser_depth` 控制最大堆栈大小并允许大型复杂查询。 这修复 [\#6681](https://github.com/ClickHouse/ClickHouse/issues/6681) 和 [\#7668](https://github.com/ClickHouse/ClickHouse/issues/7668). [\#8647](https://github.com/ClickHouse/ClickHouse/pull/8647) ([马克西姆\*斯米尔诺夫](https://github.com/qMBQx8GH)) -- 添加设置 `force_optimize_skip_unused_shards` 如果无法跳过未使用的分片,则设置为抛出 [\#8805](https://github.com/ClickHouse/ClickHouse/pull/8805) ([Azat Khuzhin](https://github.com/azat)) -- 允许配置多个磁盘/卷用于存储数据发送 `Distributed` 发动机 [\#8756](https://github.com/ClickHouse/ClickHouse/pull/8756) ([Azat Khuzhin](https://github.com/azat)) -- 支持存储策略 (``)用于存储临时数据。 [\#8750](https://github.com/ClickHouse/ClickHouse/pull/8750) ([Azat Khuzhin](https://github.com/azat)) -- 已添加 `X-ClickHouse-Exception-Code` 如果在发送数据之前引发异常,则设置的HTTP头。 这实现了 [\#4971](https://github.com/ClickHouse/ClickHouse/issues/4971). [\#8786](https://github.com/ClickHouse/ClickHouse/pull/8786) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 添加功能 `ifNotFinite`. 这只是一个句法糖: `ifNotFinite(x, y) = isFinite(x) ? x : y`. [\#8710](https://github.com/ClickHouse/ClickHouse/pull/8710) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 已添加 `last_successful_update_time` 列中 `system.dictionaries` 表 [\#9394](https://github.com/ClickHouse/ClickHouse/pull/9394) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 添加 `blockSerializedSize` 功能(磁盘大小不压缩) [\#8952](https://github.com/ClickHouse/ClickHouse/pull/8952) ([Azat Khuzhin](https://github.com/azat)) -- 添加功能 `moduloOrZero` [\#9358](https://github.com/ClickHouse/ClickHouse/pull/9358) ([hcz](https://github.com/hczhcz)) -- 添加系统表 `system.zeros` 和 `system.zeros_mt` 以及故事功能 `zeros()` 和 `zeros_mt()`. 表(和表函数)包含具有名称的单列 `zero` 和类型 `UInt8`. 此列包含零。 为了测试目的,需要它作为生成许多行的最快方法。 这修复 [\#6604](https://github.com/ClickHouse/ClickHouse/issues/6604) [\#9593](https://github.com/ClickHouse/ClickHouse/pull/9593) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) - -#### 实验特点 {#experimental-feature} - -- 添加新的紧凑格式的部件 `MergeTree`-家庭表中的所有列都存储在一个文件中。 它有助于提高小型和频繁插入的性能。 旧的格式(每列一个文件)现在被称为wide。 数据存储格式由设置控制 `min_bytes_for_wide_part` 和 `min_rows_for_wide_part`. [\#8290](https://github.com/ClickHouse/ClickHouse/pull/8290) ([安东\*波波夫](https://github.com/CurtizJ)) -- 支持S3存储 `Log`, `TinyLog` 和 `StripeLog` 桌子 [\#8862](https://github.com/ClickHouse/ClickHouse/pull/8862) ([帕维尔\*科瓦连科](https://github.com/Jokser)) - -#### 错误修复 {#bug-fix-2} - -- 修正了日志消息中不一致的空格。 [\#9322](https://github.com/ClickHouse/ClickHouse/pull/9322) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复在创建表时将未命名元组数组展平为嵌套结构的错误。 [\#8866](https://github.com/ClickHouse/ClickHouse/pull/8866) ([achulkov2](https://github.com/achulkov2)) -- 修复了以下问题 “Too many open files” 如果有太多的文件匹配glob模式可能会发生错误 `File` 表或 `file` 表功能。 现在文件懒洋洋地打开。 这修复 [\#8857](https://github.com/ClickHouse/ClickHouse/issues/8857) [\#8861](https://github.com/ClickHouse/ClickHouse/pull/8861) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除临时表现在只删除临时表。 [\#8907](https://github.com/ClickHouse/ClickHouse/pull/8907) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 当我们关闭服务器或分离/附加表时删除过时的分区。 [\#8602](https://github.com/ClickHouse/ClickHouse/pull/8602) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 默认磁盘如何计算可用空间 `data` 子目录。 修复了可用空间量计算不正确的问题,如果 `data` 目录被安装到一个单独的设备(罕见的情况)。 这修复 [\#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) [\#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 允许逗号(交叉)与IN()内部连接。 [\#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) ([Artem Zuikov](https://github.com/4ertus2)) -- 如果在WHERE部分中有\[NOT\]LIKE运算符,则允许将CROSS重写为INNER JOIN。 [\#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复后可能不正确的结果 `GROUP BY` 启用设置 `distributed_aggregation_memory_efficient`. 修复 [\#9134](https://github.com/ClickHouse/ClickHouse/issues/9134). [\#9289](https://github.com/ClickHouse/ClickHouse/pull/9289) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 找到的键在缓存字典的指标中被计为错过。 [\#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 修复引入的复制协议不兼容 [\#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [\#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([阿利沙平](https://github.com/alesapin)) -- 在固定的竞争条件 `queue_task_handle` 在启动 `ReplicatedMergeTree` 桌子 [\#9552](https://github.com/ClickHouse/ClickHouse/pull/9552) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 令牌 `NOT` 没有工作 `SHOW TABLES NOT LIKE` 查询 [\#8727](https://github.com/ClickHouse/ClickHouse/issues/8727) [\#8940](https://github.com/ClickHouse/ClickHouse/pull/8940) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加范围检查功能 `h3EdgeLengthM`. 如果没有这个检查,缓冲区溢出是可能的。 [\#8945](https://github.com/ClickHouse/ClickHouse/pull/8945) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了多个参数(超过10)的三元逻辑运算批量计算中的错误。 [\#8718](https://github.com/ClickHouse/ClickHouse/pull/8718) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 修复PREWHERE优化的错误,这可能导致段错误或 `Inconsistent number of columns got from MergeTreeRangeReader` 例外。 [\#9024](https://github.com/ClickHouse/ClickHouse/pull/9024) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复意外 `Timeout exceeded while reading from socket` 异常,在实际超时之前以及启用查询探查器时,在安全连接上随机发生。 还添加 `connect_timeout_with_failover_secure_ms` 设置(默认100ms),这是类似于 `connect_timeout_with_failover_ms`,但用于安全连接(因为SSL握手比普通TCP连接慢) [\#9026](https://github.com/ClickHouse/ClickHouse/pull/9026) ([tavplubix](https://github.com/tavplubix)) -- 修复突变最终确定的错误,当突变可能处于以下状态时 `parts_to_do=0` 和 `is_done=0`. [\#9022](https://github.com/ClickHouse/ClickHouse/pull/9022) ([阿利沙平](https://github.com/alesapin)) -- 使用新的任何连接逻辑 `partial_merge_join` 设置。 有可能使 `ANY|ALL|SEMI LEFT` 和 `ALL INNER` 加入与 `partial_merge_join=1` 现在 [\#8932](https://github.com/ClickHouse/ClickHouse/pull/8932) ([Artem Zuikov](https://github.com/4ertus2)) -- Shard现在将从发起者获得的设置夹到shard的constaints,而不是抛出异常。 此修补程序允许将查询发送到具有另一个约束的分片。 [\#9447](https://github.com/ClickHouse/ClickHouse/pull/9447) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修正了内存管理问题 `MergeTreeReadPool`. [\#8791](https://github.com/ClickHouse/ClickHouse/pull/8791) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复 `toDecimal*OrNull()` 使用字符串调用时的函数系列 `e`. 修复 [\#8312](https://github.com/ClickHouse/ClickHouse/issues/8312) [\#8764](https://github.com/ClickHouse/ClickHouse/pull/8764) ([Artem Zuikov](https://github.com/4ertus2)) -- 请确保 `FORMAT Null` 不向客户端发送数据。 [\#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 修复时间戳中的错误 `LiveViewBlockInputStream` 不会更新。 `LIVE VIEW` 是一个实验特征。 [\#8644](https://github.com/ClickHouse/ClickHouse/pull/8644) ([vxider](https://github.com/Vxider)) [\#8625](https://github.com/ClickHouse/ClickHouse/pull/8625) ([vxider](https://github.com/Vxider)) -- 固定 `ALTER MODIFY TTL` 不允许删除旧ttl表达式的错误行为。 [\#8422](https://github.com/ClickHouse/ClickHouse/pull/8422) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复了MergeTreeIndexSet中的UBSan报告。 这修复 [\#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) [\#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定的行为 `match` 和 `extract` 当干草堆有零字节的函数。 当干草堆不变时,这种行为是错误的。 这修复 [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免从apache Avro第三方库中的析构函数抛出。 [\#9066](https://github.com/ClickHouse/ClickHouse/pull/9066) ([安德鲁Onyshchuk](https://github.com/oandrew)) -- 不要提交从轮询的批次 `Kafka` 部分,因为它可能会导致数据漏洞。 [\#8876](https://github.com/ClickHouse/ClickHouse/pull/8876) ([filimonov](https://github.com/filimonov)) -- 修复 `joinGet` 使用可为空的返回类型。 https://github.com/ClickHouse/ClickHouse/issues/8919 [\#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) ([阿莫斯鸟](https://github.com/amosbird)) -- 修复压缩时的数据不兼容 `T64` 编解ec [\#9016](https://github.com/ClickHouse/ClickHouse/pull/9016) ([Artem Zuikov](https://github.com/4ertus2))修复数据类型id `T64` 在受影响的版本中导致错误(de)压缩的压缩编解ec。 [\#9033](https://github.com/ClickHouse/ClickHouse/pull/9033) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加设置 `enable_early_constant_folding` 并禁用它在某些情况下,导致错误。 [\#9010](https://github.com/ClickHouse/ClickHouse/pull/9010) ([Artem Zuikov](https://github.com/4ertus2)) -- 使用VIEW修复下推谓词优化器并启用测试 [\#9011](https://github.com/ClickHouse/ClickHouse/pull/9011) ([张冬](https://github.com/zhang2014)) -- 修复段错误 `Merge` 表,从读取时可能发生 `File` 储存 [\#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) ([tavplubix](https://github.com/tavplubix)) -- 添加了对存储策略的检查 `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE`. 否则,它可以使部分数据重新启动后无法访问,并阻止ClickHouse启动。 [\#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复改变,如果有TTL设置表。 [\#8800](https://github.com/ClickHouse/ClickHouse/pull/8800) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复在以下情况下可能发生的竞争条件 `SYSTEM RELOAD ALL DICTIONARIES` 在某些字典被修改/添加/删除时执行。 [\#8801](https://github.com/ClickHouse/ClickHouse/pull/8801) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 在以前的版本 `Memory` 数据库引擎使用空数据路径,因此在以下位置创建表 `path` directory (e.g. `/var/lib/clickhouse/`), not in data directory of database (e.g. `/var/lib/clickhouse/db_name`). [\#8753](https://github.com/ClickHouse/ClickHouse/pull/8753) ([tavplubix](https://github.com/tavplubix)) -- 修复了关于缺少默认磁盘或策略的错误日志消息。 [\#9530](https://github.com/ClickHouse/ClickHouse/pull/9530) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复数组类型的bloom\_filter索引的not(has())。 [\#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([achimbab](https://github.com/achimbab)) -- 允许表中的第一列 `Log` 引擎是别名 [\#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) ([伊万](https://github.com/abyss7)) -- 从读取时修复范围的顺序 `MergeTree` 表中的一个线程。 它可能会导致例外 `MergeTreeRangeReader` 或错误的查询结果。 [\#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) ([安东\*波波夫](https://github.com/CurtizJ)) -- 赂眉露\>\> `reinterpretAsFixedString` 返回 `FixedString` 而不是 `String`. [\#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) ([安德鲁Onyshchuk](https://github.com/oandrew)) -- 避免极少数情况下,当用户可以得到错误的错误消息 (`Success` 而不是详细的错误描述)。 [\#9457](https://github.com/ClickHouse/ClickHouse/pull/9457) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用时不要崩溃 `Template` 使用空行模板格式化。 [\#8785](https://github.com/ClickHouse/ClickHouse/pull/8785) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 系统表的元数据文件可能在错误的位置创建 [\#8653](https://github.com/ClickHouse/ClickHouse/pull/8653) ([tavplubix](https://github.com/tavplubix))修复 [\#8581](https://github.com/ClickHouse/ClickHouse/issues/8581). -- 修复缓存字典中exception\_ptr上的数据竞赛 [\#8303](https://github.com/ClickHouse/ClickHouse/issues/8303). [\#9379](https://github.com/ClickHouse/ClickHouse/pull/9379) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 不要为查询引发异常 `ATTACH TABLE IF NOT EXISTS`. 以前它是抛出,如果表已经存在,尽管 `IF NOT EXISTS` 条款 [\#8967](https://github.com/ClickHouse/ClickHouse/pull/8967) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复了异常消息中丢失的关闭paren。 [\#8811](https://github.com/ClickHouse/ClickHouse/pull/8811) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免消息 `Possible deadlock avoided` 在clickhouse客户端在交互模式下启动。 [\#9455](https://github.com/ClickHouse/ClickHouse/pull/9455) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了base64编码值末尾填充格式错误的问题。 更新base64库。 这修复 [\#9491](https://github.com/ClickHouse/ClickHouse/issues/9491),关闭 [\#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [\#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 防止丢失数据 `Kafka` 在极少数情况下,在读取后缀之后但在提交之前发生异常。 修复 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378) [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) ([filimonov](https://github.com/filimonov)) -- 在固定的异常 `DROP TABLE IF EXISTS` [\#8663](https://github.com/ClickHouse/ClickHouse/pull/8663) ([尼基塔\*瓦西列夫](https://github.com/nikvas0)) -- 修复当用户尝试崩溃 `ALTER MODIFY SETTING` 对于老格式化 `MergeTree` 表引擎家族. [\#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([阿利沙平](https://github.com/alesapin)) -- 支持在JSON相关函数中不适合Int64的UInt64号码。 更新SIMDJSON掌握。 这修复 [\#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) [\#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 当使用非严格单调函数索引时,固定执行反转谓词。 [\#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 不要试图折叠 `IN` 常量在 `GROUP BY` [\#8868](https://github.com/ClickHouse/ClickHouse/pull/8868) ([阿莫斯鸟](https://github.com/amosbird)) -- 修复bug `ALTER DELETE` 突变导致索引损坏。 这修复 [\#9019](https://github.com/ClickHouse/ClickHouse/issues/9019) 和 [\#8982](https://github.com/ClickHouse/ClickHouse/issues/8982). 另外修复极其罕见的竞争条件 `ReplicatedMergeTree` `ALTER` 查询。 [\#9048](https://github.com/ClickHouse/ClickHouse/pull/9048) ([阿利沙平](https://github.com/alesapin)) -- 当设置 `compile_expressions` 被启用,你可以得到 `unexpected column` 在 `LLVMExecutableFunction` 当我们使用 `Nullable` 类型 [\#8910](https://github.com/ClickHouse/ClickHouse/pull/8910) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 多个修复 `Kafka` 引擎:1)修复在消费者组重新平衡期间出现的重复项。 2)修复罕见 ‘holes’ 当数据从一个轮询的几个分区轮询并部分提交时出现(现在我们总是处理/提交整个轮询的消息块)。 3)通过块大小修复刷新(在此之前,只有超时刷新才能正常工作)。 4)更好的订阅程序(与分配反馈)。 5)使测试工作得更快(默认时间间隔和超时)。 由于数据之前没有被块大小刷新(根据文档),pr可能会导致默认设置的性能下降(由于更频繁和更小的刷新不太理想)。 如果您在更改后遇到性能问题-请增加 `kafka_max_block_size` 在表中的更大的值(例如 `CREATE TABLE ...Engine=Kafka ... SETTINGS ... kafka_max_block_size=524288`). 修复 [\#7259](https://github.com/ClickHouse/ClickHouse/issues/7259) [\#8917](https://github.com/ClickHouse/ClickHouse/pull/8917) ([filimonov](https://github.com/filimonov)) -- 修复 `Parameter out of bound` 在PREWHERE优化之后的某些查询中出现异常。 [\#8914](https://github.com/ClickHouse/ClickHouse/pull/8914) ([Baudouin Giard](https://github.com/bgiard)) -- 修正了函数参数混合常量的情况 `arrayZip`. [\#8705](https://github.com/ClickHouse/ClickHouse/pull/8705) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 执行时 `CREATE` 查询,在存储引擎参数中折叠常量表达式。 将空数据库名称替换为当前数据库。 修复 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492) [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) ([tavplubix](https://github.com/tavplubix)) -- 现在不可能创建或添加具有简单循环别名的列,如 `a DEFAULT b, b DEFAULT a`. [\#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([阿利沙平](https://github.com/alesapin)) -- 修正了双重移动可能会损坏原始部分的错误。 这是相关的,如果你使用 `ALTER TABLE MOVE` [\#8680](https://github.com/ClickHouse/ClickHouse/pull/8680) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 允许 `interval` 用于正确解析的标识符,而无需反引号。 当一个查询不能被执行,即使固定的问题 `interval` 标识符用反引号或双引号括起来。 这修复 [\#9124](https://github.com/ClickHouse/ClickHouse/issues/9124). [\#9142](https://github.com/ClickHouse/ClickHouse/pull/9142) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了模糊测试和不正确的行为 `bitTestAll`/`bitTestAny` 功能。 [\#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复可能的崩溃/错误的行数 `LIMIT n WITH TIES` 当有很多行等于第n行时。 [\#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([tavplubix](https://github.com/tavplubix)) -- 使用enabled编写的部件修复突变 `insert_quorum`. [\#9463](https://github.com/ClickHouse/ClickHouse/pull/9463) ([阿利沙平](https://github.com/alesapin)) -- 修复数据竞赛破坏 `Poco::HTTPServer`. 当服务器启动并立即关闭时,可能会发生这种情况。 [\#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复运行时显示误导性错误消息的错误 `SHOW CREATE TABLE a_table_that_does_not_exist`. [\#8899](https://github.com/ClickHouse/ClickHouse/pull/8899) ([achulkov2](https://github.com/achulkov2)) -- 固定 `Parameters are out of bound` 例外在一些罕见的情况下,当我们在一个常数 `SELECT` 条款时,我们有一个 `ORDER BY` 和一个 `LIMIT` 条款 [\#8892](https://github.com/ClickHouse/ClickHouse/pull/8892) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 修复突变定稿,当已经完成突变可以有状态 `is_done=0`. [\#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) ([阿利沙平](https://github.com/alesapin)) -- 防止执行 `ALTER ADD INDEX` 对于旧语法的MergeTree表,因为它不起作用。 [\#8822](https://github.com/ClickHouse/ClickHouse/pull/8822) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 在服务器启动时不要访问表,这 `LIVE VIEW` 取决于,所以服务器将能够启动。 也删除 `LIVE VIEW` 分离时的依赖关系 `LIVE VIEW`. `LIVE VIEW` 是一个实验特征。 [\#8824](https://github.com/ClickHouse/ClickHouse/pull/8824) ([tavplubix](https://github.com/tavplubix)) -- 修复可能的段错误 `MergeTreeRangeReader`,同时执行 `PREWHERE`. [\#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复与列Ttl可能不匹配的校验和。 [\#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修正了一个错误,当部分没有被移动的情况下,只有一个卷的TTL规则在后台。 [\#8672](https://github.com/ClickHouse/ClickHouse/pull/8672) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修正了这个问题 `Method createColumn() is not implemented for data type Set`. 这修复 [\#7799](https://github.com/ClickHouse/ClickHouse/issues/7799). [\#8674](https://github.com/ClickHouse/ClickHouse/pull/8674) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在我们将尝试更频繁地完成突变。 [\#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([阿利沙平](https://github.com/alesapin)) -- 修复 `intDiv` 减一个常数 [\#9351](https://github.com/ClickHouse/ClickHouse/pull/9351) ([hcz](https://github.com/hczhcz)) -- 修复可能的竞争条件 `BlockIO`. [\#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复尝试使用/删除时导致服务器终止的错误 `Kafka` 使用错误的参数创建的表。 [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) ([filimonov](https://github.com/filimonov)) -- 增加了解决方法,如果操作系统返回错误的结果 `timer_create` 功能。 [\#8837](https://github.com/ClickHouse/ClickHouse/pull/8837) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在使用固定错误 `min_marks_for_seek` 参数。 修复了分布式表中没有分片键时的错误消息,并且我们尝试跳过未使用的分片。 [\#8908](https://github.com/ClickHouse/ClickHouse/pull/8908) ([Azat Khuzhin](https://github.com/azat)) - -#### 改进 {#improvement} - -- 执行 `ALTER MODIFY/DROP` 对突变的顶部查询 `ReplicatedMergeTree*` 引擎家族. 现在 `ALTERS` 仅在元数据更新阶段阻止,之后不阻止。 [\#8701](https://github.com/ClickHouse/ClickHouse/pull/8701) ([阿利沙平](https://github.com/alesapin)) -- 添加重写交叉到内部连接的能力 `WHERE` 包含未编译名称的部分。 [\#9512](https://github.com/ClickHouse/ClickHouse/pull/9512) ([Artem Zuikov](https://github.com/4ertus2)) -- 赂眉露\>\> `SHOW TABLES` 和 `SHOW DATABASES` 查询支持 `WHERE` 表达式和 `FROM`/`IN` [\#9076](https://github.com/ClickHouse/ClickHouse/pull/9076) ([sundyli](https://github.com/sundy-li)) -- 添加了一个设置 `deduplicate_blocks_in_dependent_materialized_views`. [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) ([urykhy](https://github.com/urykhy)) -- 在最近的变化之后,MySQL客户端开始以十六进制打印二进制字符串,从而使它们不可读 ([\#9032](https://github.com/ClickHouse/ClickHouse/issues/9032)). ClickHouse中的解决方法是将字符串列标记为UTF-8,这并不总是如此,但通常是这种情况。 [\#9079](https://github.com/ClickHouse/ClickHouse/pull/9079) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 添加对字符串和FixedString键的支持 `sumMap` [\#8903](https://github.com/ClickHouse/ClickHouse/pull/8903) ([Baudouin Giard](https://github.com/bgiard)) -- 支持SummingMergeTree地图中的字符串键 [\#8933](https://github.com/ClickHouse/ClickHouse/pull/8933) ([Baudouin Giard](https://github.com/bgiard)) -- 即使线程已抛出异常,也向线程池发送线程终止信号 [\#8736](https://github.com/ClickHouse/ClickHouse/pull/8736) ([丁香飞](https://github.com/dingxiangfei2009)) -- 允许设置 `query_id` 在 `clickhouse-benchmark` [\#9416](https://github.com/ClickHouse/ClickHouse/pull/9416) ([安东\*波波夫](https://github.com/CurtizJ)) -- 不要让奇怪的表达 `ALTER TABLE ... PARTITION partition` 查询。 这个地址 [\#7192](https://github.com/ClickHouse/ClickHouse/issues/7192) [\#8835](https://github.com/ClickHouse/ClickHouse/pull/8835) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 表 `system.table_engines` 现在提供有关功能支持的信息(如 `supports_ttl` 或 `supports_sort_order`). [\#8830](https://github.com/ClickHouse/ClickHouse/pull/8830) ([Max Akhmedov](https://github.com/zlobober)) -- 启用 `system.metric_log` 默认情况下。 它将包含具有ProfileEvents值的行,CurrentMetrics收集与 “collect\_interval\_milliseconds” 间隔(默认情况下为一秒)。 该表非常小(通常以兆字节为单位),默认情况下收集此数据是合理的。 [\#9225](https://github.com/ClickHouse/ClickHouse/pull/9225) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries. Fixes [\#6964](https://github.com/ClickHouse/ClickHouse/issues/6964) [\#8874](https://github.com/ClickHouse/ClickHouse/pull/8874) ([伊万](https://github.com/abyss7)) -- 现在是暂时的 `LIVE VIEW` 创建者 `CREATE LIVE VIEW name WITH TIMEOUT [42] ...` 而不是 `CREATE TEMPORARY LIVE VIEW ...`,因为以前的语法不符合 `CREATE TEMPORARY TABLE ...` [\#9131](https://github.com/ClickHouse/ClickHouse/pull/9131) ([tavplubix](https://github.com/tavplubix)) -- 添加text\_log。级别配置参数,以限制进入 `system.text_log` 表 [\#8809](https://github.com/ClickHouse/ClickHouse/pull/8809) ([Azat Khuzhin](https://github.com/azat)) -- 允许根据TTL规则将下载的部分放入磁盘/卷 [\#8598](https://github.com/ClickHouse/ClickHouse/pull/8598) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 对于外部MySQL字典,允许将MySQL连接池共同化为 “share” 他们在字典中。 此选项显着减少到MySQL服务器的连接数。 [\#9409](https://github.com/ClickHouse/ClickHouse/pull/9409) ([Clément Rodriguez](https://github.com/clemrodriguez)) -- 显示分位数的最近查询执行时间 `clickhouse-benchmark` 输出而不是插值值。 最好显示与某些查询的执行时间相对应的值。 [\#8712](https://github.com/ClickHouse/ClickHouse/pull/8712) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 可以在将数据插入到Kafka时为消息添加密钥和时间戳。 修复 [\#7198](https://github.com/ClickHouse/ClickHouse/issues/7198) [\#8969](https://github.com/ClickHouse/ClickHouse/pull/8969) ([filimonov](https://github.com/filimonov)) -- 如果服务器从终端运行,请按颜色突出显示线程号,查询id和日志优先级。 这是为了提高开发人员相关日志消息的可读性。 [\#8961](https://github.com/ClickHouse/ClickHouse/pull/8961) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更好的异常消息,同时加载表 `Ordinary` 数据库。 [\#9527](https://github.com/ClickHouse/ClickHouse/pull/9527) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 执行 `arraySlice` 对于具有聚合函数状态的数组。 这修复 [\#9388](https://github.com/ClickHouse/ClickHouse/issues/9388) [\#9391](https://github.com/ClickHouse/ClickHouse/pull/9391) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 允许在in运算符的右侧使用常量函数和常量数组。 [\#8813](https://github.com/ClickHouse/ClickHouse/pull/8813) ([安东\*波波夫](https://github.com/CurtizJ)) -- 如果在获取系统数据时发生了zookeeper异常。副本,将其显示在单独的列中。 这实现了 [\#9137](https://github.com/ClickHouse/ClickHouse/issues/9137) [\#9138](https://github.com/ClickHouse/ClickHouse/pull/9138) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 原子删除destroy上的MergeTree数据部分。 [\#8402](https://github.com/ClickHouse/ClickHouse/pull/8402) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 支持分布式表的行级安全性。 [\#8926](https://github.com/ClickHouse/ClickHouse/pull/8926) ([伊万](https://github.com/abyss7)) -- Now we recognize suffix (like KB, KiB…) in settings values. [\#8072](https://github.com/ClickHouse/ClickHouse/pull/8072) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 在构建大型连接的结果时防止内存不足。 [\#8637](https://github.com/ClickHouse/ClickHouse/pull/8637) ([Artem Zuikov](https://github.com/4ertus2)) -- 在交互模式下为建议添加群集名称 `clickhouse-client`. [\#8709](https://github.com/ClickHouse/ClickHouse/pull/8709) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- Initialize query profiler for all threads in a group, e.g. it allows to fully profile insert-queries [\#8820](https://github.com/ClickHouse/ClickHouse/pull/8820) ([伊万](https://github.com/abyss7)) -- 添加列 `exception_code` 在 `system.query_log` 桌子 [\#8770](https://github.com/ClickHouse/ClickHouse/pull/8770) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 在端口上启用MySQL兼容服务器 `9004` 在默认服务器配置文件中。 在配置的例子固定密码生成命令。 [\#8771](https://github.com/ClickHouse/ClickHouse/pull/8771) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 如果文件系统是只读的,请防止在关闭时中止。 这修复 [\#9094](https://github.com/ClickHouse/ClickHouse/issues/9094) [\#9100](https://github.com/ClickHouse/ClickHouse/pull/9100) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 当HTTP POST查询中需要长度时,更好的异常消息。 [\#9453](https://github.com/ClickHouse/ClickHouse/pull/9453) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加 `_path` 和 `_file` 虚拟列 `HDFS` 和 `File` 发动机和 `hdfs` 和 `file` 表函数 [\#8489](https://github.com/ClickHouse/ClickHouse/pull/8489) ([Olga Khvostikova](https://github.com/stavrolia)) -- 修复错误 `Cannot find column` 同时插入到 `MATERIALIZED VIEW` 在情况下,如果新列被添加到视图的内部表。 [\#8766](https://github.com/ClickHouse/ClickHouse/pull/8766) [\#8788](https://github.com/ClickHouse/ClickHouse/pull/8788) ([vzakaznikov](https://github.com/vzakaznikov)) [\#8788](https://github.com/ClickHouse/ClickHouse/issues/8788) [\#8806](https://github.com/ClickHouse/ClickHouse/pull/8806) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) [\#8803](https://github.com/ClickHouse/ClickHouse/pull/8803) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 通过最终更新后发送进度(如日志)修复本机客户端-服务器协议的进度。 这可能仅与使用本机协议的某些第三方工具相关。 [\#9495](https://github.com/ClickHouse/ClickHouse/pull/9495) ([Azat Khuzhin](https://github.com/azat)) -- 添加系统指标跟踪使用MySQL协议的客户端连接数 ([\#9013](https://github.com/ClickHouse/ClickHouse/issues/9013)). [\#9015](https://github.com/ClickHouse/ClickHouse/pull/9015) ([尤金\*克里莫夫](https://github.com/Slach)) -- 从现在开始,HTTP响应将有 `X-ClickHouse-Timezone` 标题设置为相同的时区值 `SELECT timezone()` 会报告。 [\#9493](https://github.com/ClickHouse/ClickHouse/pull/9493) ([Denis Glazachev](https://github.com/traceon)) - -#### 性能改进 {#performance-improvement} - -- 使用IN提高分析指标的性能 [\#9261](https://github.com/ClickHouse/ClickHouse/pull/9261) ([安东\*波波夫](https://github.com/CurtizJ)) -- 逻辑函数+代码清理更简单,更有效的代码。 跟进到 [\#8718](https://github.com/ClickHouse/ClickHouse/issues/8718) [\#8728](https://github.com/ClickHouse/ClickHouse/pull/8728) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 整体性能改善(范围为5%。.通过确保使用C++20功能进行更严格的别名处理,对于受影响的查询来说,这是200%)。 [\#9304](https://github.com/ClickHouse/ClickHouse/pull/9304) ([阿莫斯鸟](https://github.com/amosbird)) -- 比较函数的内部循环更严格的别名。 [\#9327](https://github.com/ClickHouse/ClickHouse/pull/9327) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 对于算术函数的内部循环更严格的别名。 [\#9325](https://github.com/ClickHouse/ClickHouse/pull/9325) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- ColumnVector::replicate()的实现速度快约3倍,通过该实现ColumnConst::convertToFullColumn()。 在实现常数时,也将在测试中有用。 [\#9293](https://github.com/ClickHouse/ClickHouse/pull/9293) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 另一个小的性能改进 `ColumnVector::replicate()` (这加快了 `materialize` 函数和高阶函数),甚至进一步改进 [\#9293](https://github.com/ClickHouse/ClickHouse/issues/9293) [\#9442](https://github.com/ClickHouse/ClickHouse/pull/9442) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 改进的性能 `stochasticLinearRegression` 聚合函数。 此补丁由英特尔贡献。 [\#8652](https://github.com/ClickHouse/ClickHouse/pull/8652) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 提高性能 `reinterpretAsFixedString` 功能。 [\#9342](https://github.com/ClickHouse/ClickHouse/pull/9342) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 不要向客户端发送块 `Null` 处理器管道中的格式。 [\#8797](https://github.com/ClickHouse/ClickHouse/pull/8797) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) [\#8767](https://github.com/ClickHouse/ClickHouse/pull/8767) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement} - -- 异常处理现在可以在适用于Linux的Windows子系统上正常工作。 看https://github.com/ClickHouse-Extras/libunwind/pull/3 这修复 [\#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [\#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) -- 替换 `readline` 与 `replxx` 对于在交互式线编辑 `clickhouse-client` [\#8416](https://github.com/ClickHouse/ClickHouse/pull/8416) ([伊万](https://github.com/abyss7)) -- 在FunctionsComparison中更好的构建时间和更少的模板实例化。 [\#9324](https://github.com/ClickHouse/ClickHouse/pull/9324) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了与集成 `clang-tidy` 在线人 另请参阅 [\#6044](https://github.com/ClickHouse/ClickHouse/issues/6044) [\#9566](https://github.com/ClickHouse/ClickHouse/pull/9566) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在我们使用CI链接ClickHouse `lld` 即使是 `gcc`. [\#9049](https://github.com/ClickHouse/ClickHouse/pull/9049) ([阿利沙平](https://github.com/alesapin)) -- 允许随机线程调度和插入毛刺时 `THREAD_FUZZER_*` 设置环境变量。 这有助于测试。 [\#9459](https://github.com/ClickHouse/ClickHouse/pull/9459) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在无状态测试中启用安全套接字 [\#9288](https://github.com/ClickHouse/ClickHouse/pull/9288) ([tavplubix](https://github.com/tavplubix)) -- 使SPLIT\_SHARED\_LIBRARIES=OFF更强大 [\#9156](https://github.com/ClickHouse/ClickHouse/pull/9156) ([Azat Khuzhin](https://github.com/azat)) -- 赂眉露\>\> “performance\_introspection\_and\_logging” 测试可靠的随机服务器卡住。 这可能发生在CI环境中。 另请参阅 [\#9515](https://github.com/ClickHouse/ClickHouse/issues/9515) [\#9528](https://github.com/ClickHouse/ClickHouse/pull/9528) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在样式检查中验证XML。 [\#9550](https://github.com/ClickHouse/ClickHouse/pull/9550) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修正了测试中的竞争条件 `00738_lock_for_inner_table`. 这个测试依赖于睡眠。 [\#9555](https://github.com/ClickHouse/ClickHouse/pull/9555) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除类型的性能测试 `once`. 这是在统计比较模式下运行所有性能测试(更可靠)所需的。 [\#9557](https://github.com/ClickHouse/ClickHouse/pull/9557) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了算术函数的性能测试。 [\#9326](https://github.com/ClickHouse/ClickHouse/pull/9326) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了性能测试 `sumMap` 和 `sumMapWithOverflow` 聚合函数。 后续行动 [\#8933](https://github.com/ClickHouse/ClickHouse/issues/8933) [\#8947](https://github.com/ClickHouse/ClickHouse/pull/8947) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 通过样式检查确保错误代码的样式。 [\#9370](https://github.com/ClickHouse/ClickHouse/pull/9370) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 为测试历史添加脚本。 [\#8796](https://github.com/ClickHouse/ClickHouse/pull/8796) ([阿利沙平](https://github.com/alesapin)) -- 添加GCC警告 `-Wsuggest-override` 找到并修复所有地方 `override` 必须使用关键字。 [\#8760](https://github.com/ClickHouse/ClickHouse/pull/8760) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- 在Mac OS X下忽略弱符号,因为它必须被定义 [\#9538](https://github.com/ClickHouse/ClickHouse/pull/9538) ([已删除用户](https://github.com/ghost)) -- 规范性能测试中某些查询的运行时间。 这是在准备在比较模式下运行所有性能测试时完成的。 [\#9565](https://github.com/ClickHouse/ClickHouse/pull/9565) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复一些测试,以支持pytest与查询测试 [\#9062](https://github.com/ClickHouse/ClickHouse/pull/9062) ([伊万](https://github.com/abyss7)) -- 使用MSan在生成中启用SSL,因此在运行无状态测试时,服务器不会在启动时失败 [\#9531](https://github.com/ClickHouse/ClickHouse/pull/9531) ([tavplubix](https://github.com/tavplubix)) -- 修复测试结果中的数据库替换 [\#9384](https://github.com/ClickHouse/ClickHouse/pull/9384) ([Ilya Yatsishin](https://github.com/qoega)) -- 针对其他平台构建修复程序 [\#9381](https://github.com/ClickHouse/ClickHouse/pull/9381) ([proller](https://github.com/proller)) [\#8755](https://github.com/ClickHouse/ClickHouse/pull/8755) ([proller](https://github.com/proller)) [\#8631](https://github.com/ClickHouse/ClickHouse/pull/8631) ([proller](https://github.com/proller)) -- 将磁盘部分添加到无状态复盖率测试docker映像 [\#9213](https://github.com/ClickHouse/ClickHouse/pull/9213) ([帕维尔\*科瓦连科](https://github.com/Jokser)) -- 使用GRPC构建时,摆脱源代码树中的文件 [\#9588](https://github.com/ClickHouse/ClickHouse/pull/9588) ([阿莫斯鸟](https://github.com/amosbird)) -- 通过从上下文中删除SessionCleaner来缩短构建时间。 让SessionCleaner的代码更简单。 [\#9232](https://github.com/ClickHouse/ClickHouse/pull/9232) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新了clickhouse-test脚本中挂起查询的检查 [\#8858](https://github.com/ClickHouse/ClickHouse/pull/8858) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 从存储库中删除了一些无用的文件。 [\#8843](https://github.com/ClickHouse/ClickHouse/pull/8843) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更改类型的数学perftests从 `once` 到 `loop`. [\#8783](https://github.com/ClickHouse/ClickHouse/pull/8783) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 添加码头镜像,它允许为我们的代码库构建交互式代码浏览器HTML报告。 [\#8781](https://github.com/ClickHouse/ClickHouse/pull/8781) ([阿利沙平](https://github.com/alesapin))见 [Woboq代码浏览器](https://clickhouse.tech/codebrowser/html_report///ClickHouse/dbms/index.html) -- 抑制MSan下的一些测试失败。 [\#8780](https://github.com/ClickHouse/ClickHouse/pull/8780) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 加速 “exception while insert” 测试 此测试通常在具有复盖率的调试版本中超时。 [\#8711](https://github.com/ClickHouse/ClickHouse/pull/8711) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新 `libcxx` 和 `libcxxabi` 为了主人 在准备 [\#9304](https://github.com/ClickHouse/ClickHouse/issues/9304) [\#9308](https://github.com/ClickHouse/ClickHouse/pull/9308) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复flacky测试 `00910_zookeeper_test_alter_compression_codecs`. [\#9525](https://github.com/ClickHouse/ClickHouse/pull/9525) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 清理重复的链接器标志。 确保链接器不会查找意想不到的符号。 [\#9433](https://github.com/ClickHouse/ClickHouse/pull/9433) ([阿莫斯鸟](https://github.com/amosbird)) -- 添加 `clickhouse-odbc` 驱动程序进入测试图像。 这允许通过自己的ODBC驱动程序测试ClickHouse与ClickHouse的交互。 [\#9348](https://github.com/ClickHouse/ClickHouse/pull/9348) ([filimonov](https://github.com/filimonov)) -- 修复单元测试中的几个错误。 [\#9047](https://github.com/ClickHouse/ClickHouse/pull/9047) ([阿利沙平](https://github.com/alesapin)) -- 启用 `-Wmissing-include-dirs` GCC警告消除所有不存在的包括-主要是由于CMake脚本错误 [\#8704](https://github.com/ClickHouse/ClickHouse/pull/8704) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- 描述查询探查器无法工作的原因。 这是用于 [\#9049](https://github.com/ClickHouse/ClickHouse/issues/9049) [\#9144](https://github.com/ClickHouse/ClickHouse/pull/9144) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 将OpenSSL更新到上游主机。 修复了TLS连接可能会失败并显示消息的问题 `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error` 和 `SSL Exception: error:2400006E:random number generator::error retrieving entropy`. 该问题出现在版本20.1中。 [\#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新服务器的Dockerfile [\#8893](https://github.com/ClickHouse/ClickHouse/pull/8893) ([Ilya Mazaev](https://github.com/ne-ray)) -- Build-gcc-from-sources脚本中的小修复 [\#8774](https://github.com/ClickHouse/ClickHouse/pull/8774) ([Michael Nacharov](https://github.com/mnach)) -- 替换 `numbers` 到 `zeros` 在perftests其中 `number` 不使用列。 这将导致更干净的测试结果。 [\#9600](https://github.com/ClickHouse/ClickHouse/pull/9600) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复列构造函数中使用initializer\_list时堆栈溢出问题。 [\#9367](https://github.com/ClickHouse/ClickHouse/pull/9367) ([已删除用户](https://github.com/ghost)) -- 将librdkafka升级到v1.3.0。 启用bund绑 `rdkafka` 和 `gsasl` mac OS X上的库 [\#9000](https://github.com/ClickHouse/ClickHouse/pull/9000) ([安德鲁Onyshchuk](https://github.com/oandrew)) -- 在GCC9.2.0上构建修复程序 [\#9306](https://github.com/ClickHouse/ClickHouse/pull/9306) ([vxider](https://github.com/Vxider)) - -## 碌莽禄.拢.0755-88888888 {#clickhouse-release-v20-1} - -### ClickHouse版本v20.1.8.41,2020-03-20 {#clickhouse-release-v20-1-8-41-2020-03-20} - -#### 错误修复 {#bug-fix-3} - -- 修复可能的永久性 `Cannot schedule a task` 错误(由于未处理的异常 `ParallelAggregatingBlockInputStream::Handler::onFinish/onFinishThread`). 这修复 [\#6833](https://github.com/ClickHouse/ClickHouse/issues/6833). [\#9154](https://github.com/ClickHouse/ClickHouse/pull/9154) ([Azat Khuzhin](https://github.com/azat)) -- 修复过多的内存消耗 `ALTER` 查询(突变)。 这修复 [\#9533](https://github.com/ClickHouse/ClickHouse/issues/9533) 和 [\#9670](https://github.com/ClickHouse/ClickHouse/issues/9670). [\#9754](https://github.com/ClickHouse/ClickHouse/pull/9754) ([阿利沙平](https://github.com/alesapin)) -- 修复外部字典DDL中反引用的错误。 这修复 [\#9619](https://github.com/ClickHouse/ClickHouse/issues/9619). [\#9734](https://github.com/ClickHouse/ClickHouse/pull/9734) ([阿利沙平](https://github.com/alesapin)) - -### ClickHouse释放v20.1.7.38,2020-03-18 {#clickhouse-release-v20-1-7-38-2020-03-18} - -#### 错误修复 {#bug-fix-4} - -- 修正了不正确的内部函数名称 `sumKahan` 和 `sumWithOverflow`. 在远程查询中使用此函数时,我会导致异常。 [\#9636](https://github.com/ClickHouse/ClickHouse/pull/9636) ([Azat Khuzhin](https://github.com/azat)). 这个问题是在所有ClickHouse版本。 -- 允许 `ALTER ON CLUSTER` 的 `Distributed` 具有内部复制的表。 这修复 [\#3268](https://github.com/ClickHouse/ClickHouse/issues/3268). [\#9617](https://github.com/ClickHouse/ClickHouse/pull/9617) ([shinoi2](https://github.com/shinoi2)). 这个问题是在所有ClickHouse版本。 -- 修复可能的异常 `Size of filter doesn't match size of column` 和 `Invalid number of rows in Chunk` 在 `MergeTreeRangeReader`. 它们可能在执行时出现 `PREWHERE` 在某些情况下。 修复 [\#9132](https://github.com/ClickHouse/ClickHouse/issues/9132). [\#9612](https://github.com/ClickHouse/ClickHouse/pull/9612) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复了这个问题:如果你编写一个简单的算术表达式,则不会保留时区 `time + 1` (与像这样的表达形成对比 `time + INTERVAL 1 SECOND`). 这修复 [\#5743](https://github.com/ClickHouse/ClickHouse/issues/5743). [\#9323](https://github.com/ClickHouse/ClickHouse/pull/9323) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)). 这个问题是在所有ClickHouse版本。 -- 现在不可能创建或添加具有简单循环别名的列,如 `a DEFAULT b, b DEFAULT a`. [\#9603](https://github.com/ClickHouse/ClickHouse/pull/9603) ([阿利沙平](https://github.com/alesapin)) -- 修复了base64编码值末尾填充格式错误的问题。 更新base64库。 这修复 [\#9491](https://github.com/ClickHouse/ClickHouse/issues/9491),关闭 [\#9492](https://github.com/ClickHouse/ClickHouse/issues/9492) [\#9500](https://github.com/ClickHouse/ClickHouse/pull/9500) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复数据竞赛破坏 `Poco::HTTPServer`. 当服务器启动并立即关闭时,可能会发生这种情况。 [\#9468](https://github.com/ClickHouse/ClickHouse/pull/9468) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复可能的崩溃/错误的行数 `LIMIT n WITH TIES` 当有很多行等于第n行时。 [\#9464](https://github.com/ClickHouse/ClickHouse/pull/9464) ([tavplubix](https://github.com/tavplubix)) -- 修复与列Ttl可能不匹配的校验和。 [\#9451](https://github.com/ClickHouse/ClickHouse/pull/9451) ([安东\*波波夫](https://github.com/CurtizJ)) -- 修复当用户尝试崩溃 `ALTER MODIFY SETTING` 对于老格式化 `MergeTree` 表引擎家族. [\#9435](https://github.com/ClickHouse/ClickHouse/pull/9435) ([阿利沙平](https://github.com/alesapin)) -- 现在我们将尝试更频繁地完成突变。 [\#9427](https://github.com/ClickHouse/ClickHouse/pull/9427) ([阿利沙平](https://github.com/alesapin)) -- 修复引入的复制协议不兼容 [\#8598](https://github.com/ClickHouse/ClickHouse/issues/8598). [\#9412](https://github.com/ClickHouse/ClickHouse/pull/9412) ([阿利沙平](https://github.com/alesapin)) -- 修复数组类型的bloom\_filter索引的not(has())。 [\#9407](https://github.com/ClickHouse/ClickHouse/pull/9407) ([achimbab](https://github.com/achimbab)) -- 固定的行为 `match` 和 `extract` 当干草堆有零字节的函数。 当干草堆不变时,这种行为是错误的。 这修复 [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) [\#9345](https://github.com/ClickHouse/ClickHouse/pull/9345) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-1} - -- 异常处理现在可以在适用于Linux的Windows子系统上正常工作。 看https://github.com/ClickHouse-Extras/libunwind/pull/3 这修复 [\#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [\#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) - -### ClickHouse释放v20.1.6.30,2020-03-05 {#clickhouse-release-v20-1-6-30-2020-03-05} - -#### 错误修复 {#bug-fix-5} - -- 修复压缩时的数据不兼容 `T64` 编解ec - [\#9039](https://github.com/ClickHouse/ClickHouse/pull/9039) [(abyss7)](https://github.com/abyss7) -- 在一个线程中从MergeTree表中读取时修复范围顺序。 修复 [\#8964](https://github.com/ClickHouse/ClickHouse/issues/8964). - [\#9050](https://github.com/ClickHouse/ClickHouse/pull/9050) [(CurtizJ))](https://github.com/CurtizJ) -- 修复可能的段错误 `MergeTreeRangeReader`,同时执行 `PREWHERE`. 修复 [\#9064](https://github.com/ClickHouse/ClickHouse/issues/9064). - [\#9106](https://github.com/ClickHouse/ClickHouse/pull/9106) [(CurtizJ))](https://github.com/CurtizJ) -- 修复 `reinterpretAsFixedString` 返回 `FixedString` 而不是 `String`. - [\#9052](https://github.com/ClickHouse/ClickHouse/pull/9052) [(oandrew)](https://github.com/oandrew) -- 修复 `joinGet` 使用可为空的返回类型。 修复 [\#8919](https://github.com/ClickHouse/ClickHouse/issues/8919) - [\#9014](https://github.com/ClickHouse/ClickHouse/pull/9014) [(amosbird)](https://github.com/amosbird) -- 修复bittestall/bitTestAny函数的模糊测试和不正确的行为。 - [\#9143](https://github.com/ClickHouse/ClickHouse/pull/9143) [(阿列克谢-米洛维多夫)](https://github.com/alexey-milovidov) -- 修复当干草堆有零字节时匹配和提取函数的行为。 当干草堆不变时,这种行为是错误的。 修复 [\#9160](https://github.com/ClickHouse/ClickHouse/issues/9160) - [\#9163](https://github.com/ClickHouse/ClickHouse/pull/9163) [(阿列克谢-米洛维多夫)](https://github.com/alexey-milovidov) -- 当使用非严格单调函数索引时,固定执行反转谓词。 修复 [\#9034](https://github.com/ClickHouse/ClickHouse/issues/9034) - [\#9223](https://github.com/ClickHouse/ClickHouse/pull/9223) [(Akazz)](https://github.com/Akazz) -- 允许重写 `CROSS` 到 `INNER JOIN` 如果有 `[NOT] LIKE` 操作员在 `WHERE` 科。 修复 [\#9191](https://github.com/ClickHouse/ClickHouse/issues/9191) - [\#9229](https://github.com/ClickHouse/ClickHouse/pull/9229) [(4ertus2)](https://github.com/4ertus2) -- 允许使用日志引擎的表中的第一列成为别名。 - [\#9231](https://github.com/ClickHouse/ClickHouse/pull/9231) [(abyss7)](https://github.com/abyss7) -- 允许逗号加入 `IN()` 进去 修复 [\#7314](https://github.com/ClickHouse/ClickHouse/issues/7314). - [\#9251](https://github.com/ClickHouse/ClickHouse/pull/9251) [(4ertus2)](https://github.com/4ertus2) -- 改进 `ALTER MODIFY/ADD` 查询逻辑。 现在你不能 `ADD` 不带类型的列, `MODIFY` 默认表达式不改变列的类型和 `MODIFY` type不会丢失默认表达式值。 修复 [\#8669](https://github.com/ClickHouse/ClickHouse/issues/8669). - [\#9227](https://github.com/ClickHouse/ClickHouse/pull/9227) [(alesapin)](https://github.com/alesapin) -- 修复突变最终确定,当已经完成突变时可以具有状态is\_done=0。 - [\#9217](https://github.com/ClickHouse/ClickHouse/pull/9217) [(alesapin)](https://github.com/alesapin) -- 碌莽禄Support: “Processors” 管道系统.数字和系统.numbers\_mt 这也修复了错误时 `max_execution_time` 不被尊重。 - [\#7796](https://github.com/ClickHouse/ClickHouse/pull/7796) [(KochetovNicolai)](https://github.com/KochetovNicolai) -- 修复错误的计数 `DictCacheKeysRequestedFound` 公制。 - [\#9411](https://github.com/ClickHouse/ClickHouse/pull/9411) [(nikitamikhaylov)](https://github.com/nikitamikhaylov) -- 添加了对存储策略的检查 `ATTACH PARTITION FROM`, `REPLACE PARTITION`, `MOVE TO TABLE` 否则可能使部分数据在重新启动后无法访问,并阻止ClickHouse启动。 - [\#9383](https://github.com/ClickHouse/ClickHouse/pull/9383) [(excitoon)](https://github.com/excitoon) -- 在固定的瑞银报告 `MergeTreeIndexSet`. 这修复 [\#9250](https://github.com/ClickHouse/ClickHouse/issues/9250) - [\#9365](https://github.com/ClickHouse/ClickHouse/pull/9365) [(阿列克谢-米洛维多夫)](https://github.com/alexey-milovidov) -- 在BlockIO中修复可能的数据集。 - [\#9356](https://github.com/ClickHouse/ClickHouse/pull/9356) [(KochetovNicolai)](https://github.com/KochetovNicolai) -- 支持 `UInt64` 在JSON相关函数中不适合Int64的数字。 更新 `SIMDJSON` 为了主人 这修复 [\#9209](https://github.com/ClickHouse/ClickHouse/issues/9209) - [\#9344](https://github.com/ClickHouse/ClickHouse/pull/9344) [(阿列克谢-米洛维多夫)](https://github.com/alexey-milovidov) -- 如果将数据目录挂载到单独的设备,则修复可用空间量计算不正确时的问题。 对于默认磁盘,计算数据子目录的可用空间。 这修复 [\#7441](https://github.com/ClickHouse/ClickHouse/issues/7441) - [\#9257](https://github.com/ClickHouse/ClickHouse/pull/9257) [(米尔布)](https://github.com/millb) -- 修复TLS连接可能会失败并显示消息时的问题 `OpenSSL SSL_read: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error and SSL Exception: error:2400006E:random number generator::error retrieving entropy.` 将OpenSSL更新到上游主机。 - [\#8956](https://github.com/ClickHouse/ClickHouse/pull/8956) [(阿列克谢-米洛维多夫)](https://github.com/alexey-milovidov) -- 执行时 `CREATE` 查询,在存储引擎参数中折叠常量表达式。 将空数据库名称替换为当前数据库。 修复 [\#6508](https://github.com/ClickHouse/ClickHouse/issues/6508), [\#3492](https://github.com/ClickHouse/ClickHouse/issues/3492). 还修复了ClickHouseDictionarySource中检查本地地址。 - [\#9262](https://github.com/ClickHouse/ClickHouse/pull/9262) [(tabplubix)](https://github.com/tavplubix) -- 修复段错误 `StorageMerge`,从StorageFile读取时可能发生。 - [\#9387](https://github.com/ClickHouse/ClickHouse/pull/9387) [(tabplubix)](https://github.com/tavplubix) -- 防止丢失数据 `Kafka` 在极少数情况下,在读取后缀之后但在提交之前发生异常。 修复 [\#9378](https://github.com/ClickHouse/ClickHouse/issues/9378). 相关: [\#7175](https://github.com/ClickHouse/ClickHouse/issues/7175) - [\#9507](https://github.com/ClickHouse/ClickHouse/pull/9507) [(菲利蒙诺夫)](https://github.com/filimonov) -- 修复尝试使用/删除时导致服务器终止的错误 `Kafka` 使用错误的参数创建的表。 修复 [\#9494](https://github.com/ClickHouse/ClickHouse/issues/9494). 结合 [\#9507](https://github.com/ClickHouse/ClickHouse/issues/9507). - [\#9513](https://github.com/ClickHouse/ClickHouse/pull/9513) [(菲利蒙诺夫)](https://github.com/filimonov) - -#### 新功能 {#new-feature-1} - -- 添加 `deduplicate_blocks_in_dependent_materialized_views` 用于控制具有实例化视图的表中幂等插入的行为的选项。 这个新功能是由Altinity的特殊要求添加到错误修正版本中的。 - [\#9070](https://github.com/ClickHouse/ClickHouse/pull/9070) [(urykhy)](https://github.com/urykhy) - -### ClickHouse版本v20.1.2.4,2020-01-22 {#clickhouse-release-v20-1-2-4-2020-01-22} - -#### 向后不兼容的更改 {#backward-incompatible-change-1} - -- 使设置 `merge_tree_uniform_read_distribution` 过时了 服务器仍可识别此设置,但无效。 [\#8308](https://github.com/ClickHouse/ClickHouse/pull/8308) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更改函数的返回类型 `greatCircleDistance` 到 `Float32` 因为现在计算的结果是 `Float32`. [\#7993](https://github.com/ClickHouse/ClickHouse/pull/7993) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在预计查询参数表示为 “escaped” 格式。 例如,要传递字符串 `ab` 你必须写 `a\tb` 或 `a\b` 并分别, `a%5Ctb` 或 `a%5C%09b` 在URL中。 这是需要添加传递NULL作为的可能性 `\N`. 这修复 [\#7488](https://github.com/ClickHouse/ClickHouse/issues/7488). [\#8517](https://github.com/ClickHouse/ClickHouse/pull/8517) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 启用 `use_minimalistic_part_header_in_zookeeper` 设置 `ReplicatedMergeTree` 默认情况下。 这将显着减少存储在ZooKeeper中的数据量。 自19.1版本以来支持此设置,我们已经在多个服务的生产中使用它,半年以上没有任何问题。 如果您有机会降级到19.1以前的版本,请禁用此设置。 [\#6850](https://github.com/ClickHouse/ClickHouse/pull/6850) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 数据跳过索引已准备就绪并默认启用。 设置 `allow_experimental_data_skipping_indices`, `allow_experimental_cross_to_join_conversion` 和 `allow_experimental_multiple_joins_emulation` 现在已经过时,什么也不做。 [\#7974](https://github.com/ClickHouse/ClickHouse/pull/7974) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加新建 `ANY JOIN` 逻辑 `StorageJoin` 符合 `JOIN` 操作。 要在不改变行为的情况下进行升级,您需要添加 `SETTINGS any_join_distinct_right_table_keys = 1` 引擎联接表元数据或在升级后重新创建这些表。 [\#8400](https://github.com/ClickHouse/ClickHouse/pull/8400) ([Artem Zuikov](https://github.com/4ertus2)) -- 要求重新启动服务器以应用日志记录配置中的更改。 这是一种临时解决方法,可以避免服务器将日志记录到已删除的日志文件中的错误(请参阅 [\#8696](https://github.com/ClickHouse/ClickHouse/issues/8696)). [\#8707](https://github.com/ClickHouse/ClickHouse/pull/8707) ([Alexander Kuzmenkov](https://github.com/akuzm)) - -#### 新功能 {#new-feature-2} - -- 添加了有关部件路径的信息 `system.merges`. [\#8043](https://github.com/ClickHouse/ClickHouse/pull/8043) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 添加执行能力 `SYSTEM RELOAD DICTIONARY` 查询中 `ON CLUSTER` 模式 [\#8288](https://github.com/ClickHouse/ClickHouse/pull/8288) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) -- 添加执行能力 `CREATE DICTIONARY` 查询中 `ON CLUSTER` 模式 [\#8163](https://github.com/ClickHouse/ClickHouse/pull/8163) ([阿利沙平](https://github.com/alesapin)) -- 现在用户的个人资料 `users.xml` 可以继承多个配置文件。 [\#8343](https://github.com/ClickHouse/ClickHouse/pull/8343) ([Mikhail f. Shiryaev](https://github.com/Felixoid)) -- 已添加 `system.stack_trace` 允许查看所有服务器线程的堆栈跟踪的表。 这对于开发人员反省服务器状态非常有用。 这修复 [\#7576](https://github.com/ClickHouse/ClickHouse/issues/7576). [\#8344](https://github.com/ClickHouse/ClickHouse/pull/8344) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加 `DateTime64` 具有可配置子秒精度的数据类型。 [\#7170](https://github.com/ClickHouse/ClickHouse/pull/7170) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 添加表函数 `clusterAllReplicas` 这允许查询集群中的所有节点。 [\#8493](https://github.com/ClickHouse/ClickHouse/pull/8493) ([kiran sunkari](https://github.com/kiransunkari)) -- 添加聚合函数 `categoricalInformationValue` 其计算出离散特征的信息值。 [\#8117](https://github.com/ClickHouse/ClickHouse/pull/8117) ([hcz](https://github.com/hczhcz)) -- 加快数据文件的解析 `CSV`, `TSV` 和 `JSONEachRow` 通过并行进行格式化。 [\#7780](https://github.com/ClickHouse/ClickHouse/pull/7780) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 添加功能 `bankerRound` 它执行银行家的四舍五入。 [\#8112](https://github.com/ClickHouse/ClickHouse/pull/8112) ([hcz](https://github.com/hczhcz)) -- 支持区域名称的嵌入式字典中的更多语言: ‘ru’, ‘en’, ‘ua’, ‘uk’, ‘by’, ‘kz’, ‘tr’, ‘de’, ‘uz’, ‘lv’, ‘lt’, ‘et’, ‘pt’, ‘he’, ‘vi’. [\#8189](https://github.com/ClickHouse/ClickHouse/pull/8189) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 改进的一致性 `ANY JOIN` 逻辑 现在 `t1 ANY LEFT JOIN t2` 等于 `t2 ANY RIGHT JOIN t1`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加设置 `any_join_distinct_right_table_keys` 这使旧的行为 `ANY INNER JOIN`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -- 添加新建 `SEMI` 和 `ANTI JOIN`. 老 `ANY INNER JOIN` 行为现在可作为 `SEMI LEFT JOIN`. [\#7665](https://github.com/ClickHouse/ClickHouse/pull/7665) ([Artem Zuikov](https://github.com/4ertus2)) -- 已添加 `Distributed` 格式 `File` 发动机和 `file` 表函数,它允许从读 `.bin` 通过异步插入生成的文件 `Distributed` 桌子 [\#8535](https://github.com/ClickHouse/ClickHouse/pull/8535) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 添加可选的重置列参数 `runningAccumulate` 这允许为每个新的键值重置聚合结果。 [\#8326](https://github.com/ClickHouse/ClickHouse/pull/8326) ([谢尔盖\*科诺年科](https://github.com/kononencheg)) -- 添加使用ClickHouse作为普罗米修斯端点的能力。 [\#7900](https://github.com/ClickHouse/ClickHouse/pull/7900) ([vdimir](https://github.com/Vdimir)) -- 添加部分 `` 在 `config.xml` 这将限制允许的主机用于远程表引擎和表函数 `URL`, `S3`, `HDFS`. [\#7154](https://github.com/ClickHouse/ClickHouse/pull/7154) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 添加功能 `greatCircleAngle` 它计算球体上的距离(以度为单位)。 [\#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 改变地球半径与h3库一致。 [\#8105](https://github.com/ClickHouse/ClickHouse/pull/8105) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 已添加 `JSONCompactEachRow` 和 `JSONCompactEachRowWithNamesAndTypes` 输入和输出格式。 [\#7841](https://github.com/ClickHouse/ClickHouse/pull/7841) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 增加了与文件相关的表引擎和表函数的功能 (`File`, `S3`, `URL`, `HDFS`)它允许读取和写入 `gzip` 基于附加引擎参数或文件扩展名的文件。 [\#7840](https://github.com/ClickHouse/ClickHouse/pull/7840) ([安德烈\*博德罗夫](https://github.com/apbodrov)) -- 添加了 `randomASCII(length)` 函数,生成一个字符串与一个随机集 [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 可打印字符。 [\#8401](https://github.com/ClickHouse/ClickHouse/pull/8401) ([刺刀](https://github.com/BayoNet)) -- 添加功能 `JSONExtractArrayRaw` 它返回从未解析的json数组元素上的数组 `JSON` 字符串。 [\#8081](https://github.com/ClickHouse/ClickHouse/pull/8081) ([Oleg Matrokhin](https://github.com/errx)) -- 添加 `arrayZip` 函数允许将多个长度相等的数组合成一个元组数组。 [\#8149](https://github.com/ClickHouse/ClickHouse/pull/8149) ([张冬](https://github.com/zhang2014)) -- 添加根据配置的磁盘之间移动数据的能力 `TTL`-表达式为 `*MergeTree` 表引擎家族. [\#8140](https://github.com/ClickHouse/ClickHouse/pull/8140) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 增加了新的聚合功能 `avgWeighted` 其允许计算加权平均值。 [\#7898](https://github.com/ClickHouse/ClickHouse/pull/7898) ([安德烈\*博德罗夫](https://github.com/apbodrov)) -- 现在并行解析默认启用 `TSV`, `TSKV`, `CSV` 和 `JSONEachRow` 格式。 [\#7894](https://github.com/ClickHouse/ClickHouse/pull/7894) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 从添加几个地理功能 `H3` 图书馆: `h3GetResolution`, `h3EdgeAngle`, `h3EdgeLength`, `h3IsValid` 和 `h3kRing`. [\#8034](https://github.com/ClickHouse/ClickHouse/pull/8034) ([Konstantin Malanchev](https://github.com/hombit)) -- 增加了对brotli的支持 (`br`)压缩文件相关的存储和表函数。 这修复 [\#8156](https://github.com/ClickHouse/ClickHouse/issues/8156). [\#8526](https://github.com/ClickHouse/ClickHouse/pull/8526) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 添加 `groupBit*` 功能的 `SimpleAggregationFunction` 类型。 [\#8485](https://github.com/ClickHouse/ClickHouse/pull/8485) ([纪尧姆\*塔瑟里](https://github.com/YiuRULE)) - -#### 错误修复 {#bug-fix-6} - -- 修复重命名表 `Distributed` 引擎 修复问题 [\#7868](https://github.com/ClickHouse/ClickHouse/issues/7868). [\#8306](https://github.com/ClickHouse/ClickHouse/pull/8306) ([tavplubix](https://github.com/tavplubix)) -- 现在字典支持 `EXPRESSION` 对于非ClickHouse SQL方言中任意字符串中的属性。 [\#8098](https://github.com/ClickHouse/ClickHouse/pull/8098) ([阿利沙平](https://github.com/alesapin)) -- 修复损坏 `INSERT SELECT FROM mysql(...)` 查询。 这修复 [\#8070](https://github.com/ClickHouse/ClickHouse/issues/8070) 和 [\#7960](https://github.com/ClickHouse/ClickHouse/issues/7960). [\#8234](https://github.com/ClickHouse/ClickHouse/pull/8234) ([tavplubix](https://github.com/tavplubix)) -- 修复错误 “Mismatch column sizes” 插入默认值时 `Tuple` 从 `JSONEachRow`. 这修复 [\#5653](https://github.com/ClickHouse/ClickHouse/issues/5653). [\#8606](https://github.com/ClickHouse/ClickHouse/pull/8606) ([tavplubix](https://github.com/tavplubix)) -- 现在将在使用的情况下抛出一个异常 `WITH TIES` 旁边的 `LIMIT BY`. 还增加了使用能力 `TOP` 与 `LIMIT BY`. 这修复 [\#7472](https://github.com/ClickHouse/ClickHouse/issues/7472). [\#7637](https://github.com/ClickHouse/ClickHouse/pull/7637) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 从新鲜的glibc版本中修复unintendent依赖关系 `clickhouse-odbc-bridge` 二进制 [\#8046](https://github.com/ClickHouse/ClickHouse/pull/8046) ([阿莫斯鸟](https://github.com/amosbird)) -- 修正错误的检查功能 `*MergeTree` 引擎家族. 现在,当我们在最后一个颗粒和最后一个标记(非最终)中有相同数量的行时,它不会失败。 [\#8047](https://github.com/ClickHouse/ClickHouse/pull/8047) ([阿利沙平](https://github.com/alesapin)) -- 修复插入 `Enum*` 列后 `ALTER` 查询,当基础数值类型等于表指定类型时。 这修复 [\#7836](https://github.com/ClickHouse/ClickHouse/issues/7836). [\#7908](https://github.com/ClickHouse/ClickHouse/pull/7908) ([安东\*波波夫](https://github.com/CurtizJ)) -- 允许非常数负 “size” 函数的参数 `substring`. 这是不允许的错误。 这修复 [\#4832](https://github.com/ClickHouse/ClickHouse/issues/4832). [\#7703](https://github.com/ClickHouse/ClickHouse/pull/7703) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复当错误数量的参数传递到解析错误 `(O|J)DBC` 表引擎。 [\#7709](https://github.com/ClickHouse/ClickHouse/pull/7709) ([阿利沙平](https://github.com/alesapin)) -- 将日志发送到syslog时使用正在运行的clickhouse进程的命令名。 在以前的版本中,使用空字符串而不是命令名称。 [\#8460](https://github.com/ClickHouse/ClickHouse/pull/8460) ([Michael Nacharov](https://github.com/mnach)) -- 修复检查允许的主机 `localhost`. 这个公关修复了在提供的解决方案 [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241). [\#8342](https://github.com/ClickHouse/ClickHouse/pull/8342) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复罕见的崩溃 `argMin` 和 `argMax` 长字符串参数的函数,当结果被用于 `runningAccumulate` 功能。 这修复 [\#8325](https://github.com/ClickHouse/ClickHouse/issues/8325) [\#8341](https://github.com/ClickHouse/ClickHouse/pull/8341) ([恐龙](https://github.com/769344359)) -- 修复表的内存过度使用 `Buffer` 引擎 [\#8345](https://github.com/ClickHouse/ClickHouse/pull/8345) ([Azat Khuzhin](https://github.com/azat)) -- 修正了可以采取的功能中的潜在错误 `NULL` 作为参数之一,并返回非NULL。 [\#8196](https://github.com/ClickHouse/ClickHouse/pull/8196) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在线程池中更好地计算后台进程的指标 `MergeTree` 表引擎. [\#8194](https://github.com/ClickHouse/ClickHouse/pull/8194) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复功能 `IN` 里面 `WHERE` 存在行级表筛选器时的语句。 修复 [\#6687](https://github.com/ClickHouse/ClickHouse/issues/6687) [\#8357](https://github.com/ClickHouse/ClickHouse/pull/8357) ([伊万](https://github.com/abyss7)) -- 现在,如果整数值没有完全解析设置值,则会引发异常。 [\#7678](https://github.com/ClickHouse/ClickHouse/pull/7678) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 修复当聚合函数用于查询具有两个以上本地分片的分布式表时出现的异常。 [\#8164](https://github.com/ClickHouse/ClickHouse/pull/8164) ([小路](https://github.com/nicelulu)) -- 现在,bloom filter可以处理零长度数组,并且不执行冗余计算。 [\#8242](https://github.com/ClickHouse/ClickHouse/pull/8242) ([achimbab](https://github.com/achimbab)) -- 修正了通过匹配客户端主机来检查客户端主机是否允许 `host_regexp` 在指定 `users.xml`. [\#8241](https://github.com/ClickHouse/ClickHouse/pull/8241) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 放松不明确的列检查,导致多个误报 `JOIN ON` 科。 [\#8385](https://github.com/ClickHouse/ClickHouse/pull/8385) ([Artem Zuikov](https://github.com/4ertus2)) -- 修正了可能的服务器崩溃 (`std::terminate`)当服务器不能发送或写入数据 `JSON` 或 `XML` 格式与值 `String` 数据类型(需要 `UTF-8` 验证)或使用Brotli算法或其他一些罕见情况下压缩结果数据时。 这修复 [\#7603](https://github.com/ClickHouse/ClickHouse/issues/7603) [\#8384](https://github.com/ClickHouse/ClickHouse/pull/8384) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复竞争条件 `StorageDistributedDirectoryMonitor` 被线人发现 这修复 [\#8364](https://github.com/ClickHouse/ClickHouse/issues/8364). [\#8383](https://github.com/ClickHouse/ClickHouse/pull/8383) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 现在背景合并 `*MergeTree` 表引擎家族更准确地保留存储策略卷顺序。 [\#8549](https://github.com/ClickHouse/ClickHouse/pull/8549) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 现在表引擎 `Kafka` 与正常工作 `Native` 格式。 这修复 [\#6731](https://github.com/ClickHouse/ClickHouse/issues/6731) [\#7337](https://github.com/ClickHouse/ClickHouse/issues/7337) [\#8003](https://github.com/ClickHouse/ClickHouse/issues/8003). [\#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([filimonov](https://github.com/filimonov)) -- 固定格式与标题(如 `CSVWithNames`)这是抛出关于EOF表引擎的异常 `Kafka`. [\#8016](https://github.com/ClickHouse/ClickHouse/pull/8016) ([filimonov](https://github.com/filimonov)) -- 修复了从子查询右侧部分制作set的错误 `IN` 科。 这修复 [\#5767](https://github.com/ClickHouse/ClickHouse/issues/5767) 和 [\#2542](https://github.com/ClickHouse/ClickHouse/issues/2542). [\#7755](https://github.com/ClickHouse/ClickHouse/pull/7755) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 从存储读取时修复可能的崩溃 `File`. [\#7756](https://github.com/ClickHouse/ClickHouse/pull/7756) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 在固定的文件读取 `Parquet` 包含类型列的格式 `list`. [\#8334](https://github.com/ClickHouse/ClickHouse/pull/8334) ([马苏兰](https://github.com/maxulan)) -- 修复错误 `Not found column` 对于分布式查询 `PREWHERE` 条件取决于采样键if `max_parallel_replicas > 1`. [\#7913](https://github.com/ClickHouse/ClickHouse/pull/7913) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复错误 `Not found column` 如果使用查询 `PREWHERE` 依赖于表的别名,结果集由于主键条件而为空。 [\#7911](https://github.com/ClickHouse/ClickHouse/pull/7911) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 函数的固定返回类型 `rand` 和 `randConstant` 在情况下 `Nullable` 争论。 现在函数总是返回 `UInt32` 而且从来没有 `Nullable(UInt32)`. [\#8204](https://github.com/ClickHouse/ClickHouse/pull/8204) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 禁用谓词下推 `WITH FILL` 表达。 这修复 [\#7784](https://github.com/ClickHouse/ClickHouse/issues/7784). [\#7789](https://github.com/ClickHouse/ClickHouse/pull/7789) ([张冬](https://github.com/zhang2014)) -- 修正错误 `count()` 结果 `SummingMergeTree` 当 `FINAL` 部分被使用。 [\#3280](https://github.com/ClickHouse/ClickHouse/issues/3280) [\#7786](https://github.com/ClickHouse/ClickHouse/pull/7786) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 修复来自远程服务器的常量函数可能不正确的结果。 它发生在具有以下功能的查询中 `version()`, `uptime()` 等。 它为不同的服务器返回不同的常量值。 这修复 [\#7666](https://github.com/ClickHouse/ClickHouse/issues/7666). [\#7689](https://github.com/ClickHouse/ClickHouse/pull/7689) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复下推谓词优化中导致错误结果的复杂错误。 这解决了下推谓词优化的很多问题。 [\#8503](https://github.com/ClickHouse/ClickHouse/pull/8503) ([张冬](https://github.com/zhang2014)) -- 修复崩溃 `CREATE TABLE .. AS dictionary` 查询。 [\#8508](https://github.com/ClickHouse/ClickHouse/pull/8508) ([Azat Khuzhin](https://github.com/azat)) -- 一些改进ClickHouse语法 `.g4` 文件 [\#8294](https://github.com/ClickHouse/ClickHouse/pull/8294) ([太阳里](https://github.com/taiyang-li)) -- 修复导致崩溃的错误 `JOIN`s与表与发动机 `Join`. 这修复 [\#7556](https://github.com/ClickHouse/ClickHouse/issues/7556) [\#8254](https://github.com/ClickHouse/ClickHouse/issues/8254) [\#7915](https://github.com/ClickHouse/ClickHouse/issues/7915) [\#8100](https://github.com/ClickHouse/ClickHouse/issues/8100). [\#8298](https://github.com/ClickHouse/ClickHouse/pull/8298) ([Artem Zuikov](https://github.com/4ertus2)) -- 修复冗余字典重新加载 `CREATE DATABASE`. [\#7916](https://github.com/ClickHouse/ClickHouse/pull/7916) ([Azat Khuzhin](https://github.com/azat)) -- 限制从读取流的最大数量 `StorageFile` 和 `StorageHDFS`. 修复https://github.com/ClickHouse/ClickHouse/issues/7650. [\#7981](https://github.com/ClickHouse/ClickHouse/pull/7981) ([阿利沙平](https://github.com/alesapin)) -- 修复bug `ALTER ... MODIFY ... CODEC` 查询,当用户同时指定默认表达式和编解ec。 修复 [8593](https://github.com/ClickHouse/ClickHouse/issues/8593). [\#8614](https://github.com/ClickHouse/ClickHouse/pull/8614) ([阿利沙平](https://github.com/alesapin)) -- 修复列的后台合并错误 `SimpleAggregateFunction(LowCardinality)` 类型。 [\#8613](https://github.com/ClickHouse/ClickHouse/pull/8613) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 固定类型签入功能 `toDateTime64`. [\#8375](https://github.com/ClickHouse/ClickHouse/pull/8375) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 现在服务器不崩溃 `LEFT` 或 `FULL JOIN` 与和加入引擎和不支持 `join_use_nulls` 设置。 [\#8479](https://github.com/ClickHouse/ClickHouse/pull/8479) ([Artem Zuikov](https://github.com/4ertus2)) -- 现在 `DROP DICTIONARY IF EXISTS db.dict` 查询不会抛出异常,如果 `db` 根本不存在 [\#8185](https://github.com/ClickHouse/ClickHouse/pull/8185) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 修复表函数中可能出现的崩溃 (`file`, `mysql`, `remote`)引用删除引起的 `IStorage` 对象。 修复插入表函数时指定的列的不正确解析。 [\#7762](https://github.com/ClickHouse/ClickHouse/pull/7762) ([tavplubix](https://github.com/tavplubix)) -- 确保网络启动前 `clickhouse-server`. 这修复 [\#7507](https://github.com/ClickHouse/ClickHouse/issues/7507). [\#8570](https://github.com/ClickHouse/ClickHouse/pull/8570) ([余志昌](https://github.com/yuzhichang)) -- 修复安全连接的超时处理,因此查询不会无限挂起。 这修复 [\#8126](https://github.com/ClickHouse/ClickHouse/issues/8126). [\#8128](https://github.com/ClickHouse/ClickHouse/pull/8128) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `clickhouse-copier`并发工人之间的冗余争用。 [\#7816](https://github.com/ClickHouse/ClickHouse/pull/7816) ([丁香飞](https://github.com/dingxiangfei2009)) -- 现在突变不会跳过附加的部分,即使它们的突变版本比当前的突变版本大。 [\#7812](https://github.com/ClickHouse/ClickHouse/pull/7812) ([余志昌](https://github.com/yuzhichang)) [\#8250](https://github.com/ClickHouse/ClickHouse/pull/8250) ([阿利沙平](https://github.com/alesapin)) -- 忽略冗余副本 `*MergeTree` 数据部分移动到另一个磁盘和服务器重新启动后。 [\#7810](https://github.com/ClickHouse/ClickHouse/pull/7810) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复崩溃 `FULL JOIN` 与 `LowCardinality` 在 `JOIN` 钥匙 [\#8252](https://github.com/ClickHouse/ClickHouse/pull/8252) ([Artem Zuikov](https://github.com/4ertus2)) -- 禁止在插入查询中多次使用列名,如 `INSERT INTO tbl (x, y, x)`. 这修复 [\#5465](https://github.com/ClickHouse/ClickHouse/issues/5465), [\#7681](https://github.com/ClickHouse/ClickHouse/issues/7681). [\#7685](https://github.com/ClickHouse/ClickHouse/pull/7685) ([阿利沙平](https://github.com/alesapin)) -- 增加了回退,用于检测未知Cpu的物理CPU内核数量(使用逻辑CPU内核数量)。 这修复 [\#5239](https://github.com/ClickHouse/ClickHouse/issues/5239). [\#7726](https://github.com/ClickHouse/ClickHouse/pull/7726) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `There's no column` 实例化列和别名列出错。 [\#8210](https://github.com/ClickHouse/ClickHouse/pull/8210) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定切断崩溃时 `EXISTS` 查询没有使用 `TABLE` 或 `DICTIONARY` 预选赛 就像 `EXISTS t`. 这修复 [\#8172](https://github.com/ClickHouse/ClickHouse/issues/8172). 此错误在版本19.17中引入。 [\#8213](https://github.com/ClickHouse/ClickHouse/pull/8213) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复罕见错误 `"Sizes of columns doesn't match"` 使用时可能会出现 `SimpleAggregateFunction` 列。 [\#7790](https://github.com/ClickHouse/ClickHouse/pull/7790) ([Boris Granveaud](https://github.com/bgranvea)) -- 修正错误,其中用户空 `allow_databases` 可以访问所有数据库(和相同的 `allow_dictionaries`). [\#7793](https://github.com/ClickHouse/ClickHouse/pull/7793) ([DeifyTheGod](https://github.com/DeifyTheGod)) -- 修复客户端崩溃时,服务器已经从客户端断开连接。 [\#8071](https://github.com/ClickHouse/ClickHouse/pull/8071) ([Azat Khuzhin](https://github.com/azat)) -- 修复 `ORDER BY` 在按主键前缀和非主键后缀排序的情况下的行为。 [\#7759](https://github.com/ClickHouse/ClickHouse/pull/7759) ([安东\*波波夫](https://github.com/CurtizJ)) -- 检查表中是否存在合格列。 这修复 [\#6836](https://github.com/ClickHouse/ClickHouse/issues/6836). [\#7758](https://github.com/ClickHouse/ClickHouse/pull/7758) ([Artem Zuikov](https://github.com/4ertus2)) -- 固定行为 `ALTER MOVE` 合并完成后立即运行移动指定的超部分。 修复 [\#8103](https://github.com/ClickHouse/ClickHouse/issues/8103). [\#8104](https://github.com/ClickHouse/ClickHouse/pull/8104) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 使用时修复可能的服务器崩溃 `UNION` 具有不同数量的列。 修复 [\#7279](https://github.com/ClickHouse/ClickHouse/issues/7279). [\#7929](https://github.com/ClickHouse/ClickHouse/pull/7929) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复函数结果子字符串的大小 `substr` 负大小。 [\#8589](https://github.com/ClickHouse/ClickHouse/pull/8589) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 现在服务器不执行部分突变 `MergeTree` 如果后台池中没有足够的可用线程。 [\#8588](https://github.com/ClickHouse/ClickHouse/pull/8588) ([tavplubix](https://github.com/tavplubix)) -- 修复格式化时的小错字 `UNION ALL` AST. [\#7999](https://github.com/ClickHouse/ClickHouse/pull/7999) ([litao91](https://github.com/litao91)) -- 修正了负数不正确的布隆过滤结果。 这修复 [\#8317](https://github.com/ClickHouse/ClickHouse/issues/8317). [\#8566](https://github.com/ClickHouse/ClickHouse/pull/8566) ([张冬](https://github.com/zhang2014)) -- 在解压缩固定潜在的缓冲区溢出。 恶意用户可以传递捏造的压缩数据,这将导致缓冲区后读取。 这个问题是由Yandex信息安全团队的Eldar Zaitov发现的。 [\#8404](https://github.com/ClickHouse/ClickHouse/pull/8404) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复因整数溢出而导致的错误结果 `arrayIntersect`. [\#7777](https://github.com/ClickHouse/ClickHouse/pull/7777) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 现在 `OPTIMIZE TABLE` query不会等待脱机副本执行该操作。 [\#8314](https://github.com/ClickHouse/ClickHouse/pull/8314) ([javi santana](https://github.com/javisantana)) -- 固定 `ALTER TTL` 解析器 `Replicated*MergeTree` 桌子 [\#8318](https://github.com/ClickHouse/ClickHouse/pull/8318) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复服务器和客户端之间的通信,以便服务器在查询失败后读取临时表信息。 [\#8084](https://github.com/ClickHouse/ClickHouse/pull/8084) ([Azat Khuzhin](https://github.com/azat)) -- 修复 `bitmapAnd` 在聚合位图和标量位图相交时出现函数错误。 [\#8082](https://github.com/ClickHouse/ClickHouse/pull/8082) ([黄月](https://github.com/moon03432)) -- 完善的定义 `ZXid` 根据动物园管理员的程序员指南,它修复了错误 `clickhouse-cluster-copier`. [\#8088](https://github.com/ClickHouse/ClickHouse/pull/8088) ([丁香飞](https://github.com/dingxiangfei2009)) -- `odbc` 表函数现在尊重 `external_table_functions_use_nulls` 设置。 [\#7506](https://github.com/ClickHouse/ClickHouse/pull/7506) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 修正了导致罕见的数据竞赛的错误。 [\#8143](https://github.com/ClickHouse/ClickHouse/pull/8143) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 现在 `SYSTEM RELOAD DICTIONARY` 完全重新加载字典,忽略 `update_field`. 这修复 [\#7440](https://github.com/ClickHouse/ClickHouse/issues/7440). [\#8037](https://github.com/ClickHouse/ClickHouse/pull/8037) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 添加检查字典是否存在于创建查询的能力。 [\#8032](https://github.com/ClickHouse/ClickHouse/pull/8032) ([阿利沙平](https://github.com/alesapin)) -- 修复 `Float*` 解析中 `Values` 格式。 这修复 [\#7817](https://github.com/ClickHouse/ClickHouse/issues/7817). [\#7870](https://github.com/ClickHouse/ClickHouse/pull/7870) ([tavplubix](https://github.com/tavplubix)) -- 修复崩溃时,我们不能在一些后台操作保留空间 `*MergeTree` 表引擎家族. [\#7873](https://github.com/ClickHouse/ClickHouse/pull/7873) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复表包含合并操作时的崩溃 `SimpleAggregateFunction(LowCardinality)` 列。 这修复 [\#8515](https://github.com/ClickHouse/ClickHouse/issues/8515). [\#8522](https://github.com/ClickHouse/ClickHouse/pull/8522) ([Azat Khuzhin](https://github.com/azat)) -- 恢复对所有ICU区域设置的支持,并添加对常量表达式应用排序规则的功能。 还添加语言名称 `system.collations` 桌子 [\#8051](https://github.com/ClickHouse/ClickHouse/pull/8051) ([阿利沙平](https://github.com/alesapin)) -- 修正错误时,外部字典与零最小寿命 (`LIFETIME(MIN 0 MAX N)`, `LIFETIME(N)`)不要在后台更新。 [\#7983](https://github.com/ClickHouse/ClickHouse/pull/7983) ([阿利沙平](https://github.com/alesapin)) -- 修复当clickhouse源外部字典在查询中有子查询时崩溃。 [\#8351](https://github.com/ClickHouse/ClickHouse/pull/8351) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 修复文件扩展名不正确的解析表与引擎 `URL`. 这修复 [\#8157](https://github.com/ClickHouse/ClickHouse/issues/8157). [\#8419](https://github.com/ClickHouse/ClickHouse/pull/8419) ([安德烈\*博德罗夫](https://github.com/apbodrov)) -- 修复 `CHECK TABLE` 查询为 `*MergeTree` 表没有关键. 修复 [\#7543](https://github.com/ClickHouse/ClickHouse/issues/7543). [\#7979](https://github.com/ClickHouse/ClickHouse/pull/7979) ([阿利沙平](https://github.com/alesapin)) -- 固定转换 `Float64` 到MySQL类型。 [\#8079](https://github.com/ClickHouse/ClickHouse/pull/8079) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 现在,如果表没有完全删除,因为服务器崩溃,服务器将尝试恢复并加载它。 [\#8176](https://github.com/ClickHouse/ClickHouse/pull/8176) ([tavplubix](https://github.com/tavplubix)) -- 修复了表函数中的崩溃 `file` 同时插入到不存在的文件。 现在在这种情况下,文件将被创建,然后插入将被处理。 [\#8177](https://github.com/ClickHouse/ClickHouse/pull/8177) ([Olga Khvostikova](https://github.com/stavrolia)) -- 修复罕见的死锁时,可能发生 `trace_log` 处于启用状态。 [\#7838](https://github.com/ClickHouse/ClickHouse/pull/7838) ([filimonov](https://github.com/filimonov)) -- 添加能力与不同类型的工作,除了 `Date` 在 `RangeHashed` 从DDL查询创建的外部字典。 修复 [7899](https://github.com/ClickHouse/ClickHouse/issues/7899). [\#8275](https://github.com/ClickHouse/ClickHouse/pull/8275) ([阿利沙平](https://github.com/alesapin)) -- 修复崩溃时 `now64()` 用另一个函数的结果调用。 [\#8270](https://github.com/ClickHouse/ClickHouse/pull/8270) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 修正了通过mysql有线协议检测客户端IP连接的错误。 [\#7743](https://github.com/ClickHouse/ClickHouse/pull/7743) ([Dmitry Muzyka](https://github.com/dmitriy-myz)) -- 修复空阵列处理 `arraySplit` 功能。 这修复 [\#7708](https://github.com/ClickHouse/ClickHouse/issues/7708). [\#7747](https://github.com/ClickHouse/ClickHouse/pull/7747) ([hcz](https://github.com/hczhcz)) -- 修复了以下问题 `pid-file` 另一个运行 `clickhouse-server` 可能会被删除。 [\#8487](https://github.com/ClickHouse/ClickHouse/pull/8487) ([徐伟清](https://github.com/weiqxu)) -- 修复字典重新加载,如果它有 `invalidate_query`,停止更新,并在以前的更新尝试一些异常。 [\#8029](https://github.com/ClickHouse/ClickHouse/pull/8029) ([阿利沙平](https://github.com/alesapin)) -- 修正了功能错误 `arrayReduce` 这可能会导致 “double free” 和聚合函数组合器中的错误 `Resample` 这可能会导致内存泄漏。 添加聚合功能 `aggThrow`. 此功能可用于测试目的。 [\#8446](https://github.com/ClickHouse/ClickHouse/pull/8446) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 改进 {#improvement-1} - -- 改进了使用时的日志记录 `S3` 表引擎。 [\#8251](https://github.com/ClickHouse/ClickHouse/pull/8251) ([Grigory Pervakov](https://github.com/GrigoryPervakov)) -- 在调用时未传递任何参数时打印帮助消息 `clickhouse-local`. 这修复 [\#5335](https://github.com/ClickHouse/ClickHouse/issues/5335). [\#8230](https://github.com/ClickHouse/ClickHouse/pull/8230) ([安德烈\*纳戈尔尼](https://github.com/Melancholic)) -- 添加设置 `mutations_sync` 这允许等待 `ALTER UPDATE/DELETE` 同步查询。 [\#8237](https://github.com/ClickHouse/ClickHouse/pull/8237) ([阿利沙平](https://github.com/alesapin)) -- 允许设置相对 `user_files_path` 在 `config.xml` (在类似的方式 `format_schema_path`). [\#7632](https://github.com/ClickHouse/ClickHouse/pull/7632) ([hcz](https://github.com/hczhcz)) -- 为转换函数添加非法类型的异常 `-OrZero` 后缀 [\#7880](https://github.com/ClickHouse/ClickHouse/pull/7880) ([安德烈\*科尼亚耶夫](https://github.com/akonyaev90)) -- 简化在分布式查询中发送到分片的数据头的格式。 [\#8044](https://github.com/ClickHouse/ClickHouse/pull/8044) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- `Live View` 表引擎重构。 [\#8519](https://github.com/ClickHouse/ClickHouse/pull/8519) ([vzakaznikov](https://github.com/vzakaznikov)) -- 为从DDL查询创建的外部字典添加额外的检查。 [\#8127](https://github.com/ClickHouse/ClickHouse/pull/8127) ([阿利沙平](https://github.com/alesapin)) -- 修复错误 `Column ... already exists` 使用时 `FINAL` 和 `SAMPLE` together, e.g. `select count() from table final sample 1/2`. 修复 [\#5186](https://github.com/ClickHouse/ClickHouse/issues/5186). [\#7907](https://github.com/ClickHouse/ClickHouse/pull/7907) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 现在表的第一个参数 `joinGet` 函数可以是表标识符。 [\#7707](https://github.com/ClickHouse/ClickHouse/pull/7707) ([阿莫斯鸟](https://github.com/amosbird)) -- 允许使用 `MaterializedView` 与上面的子查询 `Kafka` 桌子 [\#8197](https://github.com/ClickHouse/ClickHouse/pull/8197) ([filimonov](https://github.com/filimonov)) -- 现在后台在磁盘之间移动,运行它的seprate线程池。 [\#7670](https://github.com/ClickHouse/ClickHouse/pull/7670) ([Vladimir Chebotarev](https://github.com/excitoon)) -- `SYSTEM RELOAD DICTIONARY` 现在同步执行。 [\#8240](https://github.com/ClickHouse/ClickHouse/pull/8240) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 堆栈跟踪现在显示物理地址(对象文件中的偏移量),而不是虚拟内存地址(加载对象文件的位置)。 这允许使用 `addr2line` 当二进制独立于位置并且ASLR处于活动状态时。 这修复 [\#8360](https://github.com/ClickHouse/ClickHouse/issues/8360). [\#8387](https://github.com/ClickHouse/ClickHouse/pull/8387) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 支持行级安全筛选器的新语法: `
`. 修复 [\#5779](https://github.com/ClickHouse/ClickHouse/issues/5779). [\#8381](https://github.com/ClickHouse/ClickHouse/pull/8381) ([伊万](https://github.com/abyss7)) -- 现在 `cityHash` 功能可以与工作 `Decimal` 和 `UUID` 类型。 修复 [\#5184](https://github.com/ClickHouse/ClickHouse/issues/5184). [\#7693](https://github.com/ClickHouse/ClickHouse/pull/7693) ([米哈伊尔\*科罗托夫](https://github.com/millb)) -- 从系统日志中删除了固定的索引粒度(它是1024),因为它在实现自适应粒度之后已经过时。 [\#7698](https://github.com/ClickHouse/ClickHouse/pull/7698) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 当ClickHouse在没有SSL的情况下编译时,启用MySQL兼容服务器。 [\#7852](https://github.com/ClickHouse/ClickHouse/pull/7852) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 现在服务器校验和分布式批处理,这在批处理中损坏数据的情况下提供了更多详细的错误。 [\#7914](https://github.com/ClickHouse/ClickHouse/pull/7914) ([Azat Khuzhin](https://github.com/azat)) -- 碌莽禄Support: `DROP DATABASE`, `DETACH TABLE`, `DROP TABLE` 和 `ATTACH TABLE` 为 `MySQL` 数据库引擎。 [\#8202](https://github.com/ClickHouse/ClickHouse/pull/8202) ([张冬](https://github.com/zhang2014)) -- 在S3表功能和表引擎中添加身份验证。 [\#7623](https://github.com/ClickHouse/ClickHouse/pull/7623) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 增加了检查额外的部分 `MergeTree` 在不同的磁盘上,为了不允许错过未定义磁盘上的数据部分。 [\#8118](https://github.com/ClickHouse/ClickHouse/pull/8118) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 启用Mac客户端和服务器的SSL支持。 [\#8297](https://github.com/ClickHouse/ClickHouse/pull/8297) ([伊万](https://github.com/abyss7)) -- 现在ClickHouse可以作为MySQL联合服务器(参见https://dev.mysql.com/doc/refman/5.7/en/federated-create-server.html)。 [\#7717](https://github.com/ClickHouse/ClickHouse/pull/7717) ([Maxim Fedotov](https://github.com/MaxFedotov)) -- `clickhouse-client` 现在只能启用 `bracketed-paste` 当多查询处于打开状态且多行处于关闭状态时。 这修复(#7757)\[https://github.com/ClickHouse/ClickHouse/issues/7757。 [\#7761](https://github.com/ClickHouse/ClickHouse/pull/7761) ([阿莫斯鸟](https://github.com/amosbird)) -- 碌莽禄Support: `Array(Decimal)` 在 `if` 功能。 [\#7721](https://github.com/ClickHouse/ClickHouse/pull/7721) ([Artem Zuikov](https://github.com/4ertus2)) -- 支持小数 `arrayDifference`, `arrayCumSum` 和 `arrayCumSumNegative` 功能。 [\#7724](https://github.com/ClickHouse/ClickHouse/pull/7724) ([Artem Zuikov](https://github.com/4ertus2)) -- 已添加 `lifetime` 列到 `system.dictionaries` 桌子 [\#6820](https://github.com/ClickHouse/ClickHouse/issues/6820) [\#7727](https://github.com/ClickHouse/ClickHouse/pull/7727) ([kekekekule](https://github.com/kekekekule)) -- 改进了检查不同磁盘上的现有部件 `*MergeTree` 表引擎. 地址 [\#7660](https://github.com/ClickHouse/ClickHouse/issues/7660). [\#8440](https://github.com/ClickHouse/ClickHouse/pull/8440) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 集成与 `AWS SDK` 为 `S3` 交互允许使用开箱即用的所有S3功能。 [\#8011](https://github.com/ClickHouse/ClickHouse/pull/8011) ([帕维尔\*科瓦连科](https://github.com/Jokser)) -- 增加了对子查询的支持 `Live View` 桌子 [\#7792](https://github.com/ClickHouse/ClickHouse/pull/7792) ([vzakaznikov](https://github.com/vzakaznikov)) -- 检查使用 `Date` 或 `DateTime` 从列 `TTL` 表达式已删除。 [\#7920](https://github.com/ClickHouse/ClickHouse/pull/7920) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 有关磁盘的信息已添加到 `system.detached_parts` 桌子 [\#7833](https://github.com/ClickHouse/ClickHouse/pull/7833) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 现在设置 `max_(table|partition)_size_to_drop` 无需重新启动即可更改。 [\#7779](https://github.com/ClickHouse/ClickHouse/pull/7779) ([Grigory Pervakov](https://github.com/GrigoryPervakov)) -- 错误消息的可用性略好。 要求用户不要删除下面的行 `Stack trace:`. [\#7897](https://github.com/ClickHouse/ClickHouse/pull/7897) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更好地阅读消息 `Kafka` 引擎在各种格式后 [\#7935](https://github.com/ClickHouse/ClickHouse/issues/7935). [\#8035](https://github.com/ClickHouse/ClickHouse/pull/8035) ([伊万](https://github.com/abyss7)) -- 与不支持MySQL客户端更好的兼容性 `sha2_password` 验证插件。 [\#8036](https://github.com/ClickHouse/ClickHouse/pull/8036) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 支持MySQL兼容性服务器中的更多列类型。 [\#7975](https://github.com/ClickHouse/ClickHouse/pull/7975) ([尤里\*巴拉诺夫](https://github.com/yurriy)) -- 执行 `ORDER BY` 优化 `Merge`, `Buffer` 和 `Materilized View` 存储与底层 `MergeTree` 桌子 [\#8130](https://github.com/ClickHouse/ClickHouse/pull/8130) ([安东\*波波夫](https://github.com/CurtizJ)) -- 现在我们总是使用POSIX实现 `getrandom` 与旧内核更好的兼容性(\<3.17)。 [\#7940](https://github.com/ClickHouse/ClickHouse/pull/7940) ([阿莫斯鸟](https://github.com/amosbird)) -- 更好地检查移动ttl规则中的有效目标。 [\#8410](https://github.com/ClickHouse/ClickHouse/pull/8410) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 更好地检查损坏的刀片批次 `Distributed` 表引擎。 [\#7933](https://github.com/ClickHouse/ClickHouse/pull/7933) ([Azat Khuzhin](https://github.com/azat)) -- 添加带有部件名称数组的列,这些部件将来必须处理突变 `system.mutations` 桌子 [\#8179](https://github.com/ClickHouse/ClickHouse/pull/8179) ([阿利沙平](https://github.com/alesapin)) -- 处理器的并行合并排序优化。 [\#8552](https://github.com/ClickHouse/ClickHouse/pull/8552) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 设置 `mark_cache_min_lifetime` 现在已经过时了,什么也不做。 在以前的版本中,标记缓存可以在内存中增长大于 `mark_cache_size` 以容纳内的数据 `mark_cache_min_lifetime` 秒。 这导致了混乱和比预期更高的内存使用率,这在内存受限的系统上尤其糟糕。 如果您在安装此版本后会看到性能下降,则应增加 `mark_cache_size`. [\#8484](https://github.com/ClickHouse/ClickHouse/pull/8484) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 准备使用 `tid` 到处都是 这是必要的 [\#7477](https://github.com/ClickHouse/ClickHouse/issues/7477). [\#8276](https://github.com/ClickHouse/ClickHouse/pull/8276) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -#### 性能改进 {#performance-improvement-1} - -- 处理器管道中的性能优化。 [\#7988](https://github.com/ClickHouse/ClickHouse/pull/7988) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 缓存字典中过期密钥的非阻塞更新(具有读取旧密钥的权限)。 [\#8303](https://github.com/ClickHouse/ClickHouse/pull/8303) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 没有编译ClickHouse `-fno-omit-frame-pointer` 在全球范围内多余一个寄存器。 [\#8097](https://github.com/ClickHouse/ClickHouse/pull/8097) ([阿莫斯鸟](https://github.com/amosbird)) -- 加速 `greatCircleDistance` 功能,并为它添加性能测试。 [\#7307](https://github.com/ClickHouse/ClickHouse/pull/7307) ([Olga Khvostikova](https://github.com/stavrolia)) -- 改进的功能性能 `roundDown`. [\#8465](https://github.com/ClickHouse/ClickHouse/pull/8465) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 改进的性能 `max`, `min`, `argMin`, `argMax` 为 `DateTime64` 数据类型。 [\#8199](https://github.com/ClickHouse/ClickHouse/pull/8199) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 改进了无限制或大限制和外部排序的排序性能。 [\#8545](https://github.com/ClickHouse/ClickHouse/pull/8545) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 改进的性能格式化浮点数高达6倍。 [\#8542](https://github.com/ClickHouse/ClickHouse/pull/8542) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 改进的性能 `modulo` 功能。 [\#7750](https://github.com/ClickHouse/ClickHouse/pull/7750) ([阿莫斯鸟](https://github.com/amosbird)) -- 优化 `ORDER BY` 并与单列键合并。 [\#8335](https://github.com/ClickHouse/ClickHouse/pull/8335) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更好地实施 `arrayReduce`, `-Array` 和 `-State` 组合子 [\#7710](https://github.com/ClickHouse/ClickHouse/pull/7710) ([阿莫斯鸟](https://github.com/amosbird)) -- 现在 `PREWHERE` 应优化为至少一样高效 `WHERE`. [\#7769](https://github.com/ClickHouse/ClickHouse/pull/7769) ([阿莫斯鸟](https://github.com/amosbird)) -- 改进方式 `round` 和 `roundBankers` 处理负数。 [\#8229](https://github.com/ClickHouse/ClickHouse/pull/8229) ([hcz](https://github.com/hczhcz)) -- 改进的解码性能 `DoubleDelta` 和 `Gorilla` 编解码器大约30-40%。 这修复 [\#7082](https://github.com/ClickHouse/ClickHouse/issues/7082). [\#8019](https://github.com/ClickHouse/ClickHouse/pull/8019) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 改进的性能 `base64` 相关功能。 [\#8444](https://github.com/ClickHouse/ClickHouse/pull/8444) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 增加了一个功能 `geoDistance`. 它类似于 `greatCircleDistance` 但使用近似于WGS-84椭球模型。 两个功能的性能几乎相同。 [\#8086](https://github.com/ClickHouse/ClickHouse/pull/8086) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更快 `min` 和 `max` 聚合函数 `Decimal` 数据类型。 [\#8144](https://github.com/ClickHouse/ClickHouse/pull/8144) ([Artem Zuikov](https://github.com/4ertus2)) -- 矢量化处理 `arrayReduce`. [\#7608](https://github.com/ClickHouse/ClickHouse/pull/7608) ([阿莫斯鸟](https://github.com/amosbird)) -- `if` 链现在优化为 `multiIf`. [\#8355](https://github.com/ClickHouse/ClickHouse/pull/8355) ([kamalov-ruslan](https://github.com/kamalov-ruslan)) -- 修复性能回归 `Kafka` 表引擎在19.15中引入。 这修复 [\#7261](https://github.com/ClickHouse/ClickHouse/issues/7261). [\#7935](https://github.com/ClickHouse/ClickHouse/pull/7935) ([filimonov](https://github.com/filimonov)) -- 已删除 “pie” 代码生成 `gcc` 从Debian软件包偶尔带来默认情况下。 [\#8483](https://github.com/ClickHouse/ClickHouse/pull/8483) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 并行解析数据格式 [\#6553](https://github.com/ClickHouse/ClickHouse/pull/6553) ([尼基塔\*米哈伊洛夫](https://github.com/nikitamikhaylov)) -- 启用优化的解析器 `Values` 默认使用表达式 (`input_format_values_deduce_templates_of_expressions=1`). [\#8231](https://github.com/ClickHouse/ClickHouse/pull/8231) ([tavplubix](https://github.com/tavplubix)) - -#### 构建/测试/包装改进 {#buildtestingpackaging-improvement-2} - -- 构建修复 `ARM` 而在最小模式。 [\#8304](https://github.com/ClickHouse/ClickHouse/pull/8304) ([proller](https://github.com/proller)) -- 添加复盖文件刷新 `clickhouse-server` 当不调用std::atexit时。 还略微改进了无状态测试的复盖率日志记录。 [\#8267](https://github.com/ClickHouse/ClickHouse/pull/8267) ([阿利沙平](https://github.com/alesapin)) -- 更新contrib中的LLVM库。 避免从操作系统包中使用LLVM。 [\#8258](https://github.com/ClickHouse/ClickHouse/pull/8258) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使bund绑 `curl` 建立完全安静。 [\#8232](https://github.com/ClickHouse/ClickHouse/pull/8232) [\#8203](https://github.com/ClickHouse/ClickHouse/pull/8203) ([帕维尔\*科瓦连科](https://github.com/Jokser)) -- 修复一些 `MemorySanitizer` 警告。 [\#8235](https://github.com/ClickHouse/ClickHouse/pull/8235) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 使用 `add_warning` 和 `no_warning` 宏 `CMakeLists.txt`. [\#8604](https://github.com/ClickHouse/ClickHouse/pull/8604) ([伊万](https://github.com/abyss7)) -- 添加对Minio S3兼容对象的支持(https://min.io/)为了更好的集成测试。 [\#7863](https://github.com/ClickHouse/ClickHouse/pull/7863) [\#7875](https://github.com/ClickHouse/ClickHouse/pull/7875) ([帕维尔\*科瓦连科](https://github.com/Jokser)) -- 导入 `libc` 标题到contrib。 它允许在各种系统中使构建更加一致(仅适用于 `x86_64-linux-gnu`). [\#5773](https://github.com/ClickHouse/ClickHouse/pull/5773) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除 `-fPIC` 从一些图书馆。 [\#8464](https://github.com/ClickHouse/ClickHouse/pull/8464) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 清洁 `CMakeLists.txt` 对于卷曲。 看https://github.com/ClickHouse/ClickHouse/pull/8011\#issuecomment-569478910 [\#8459](https://github.com/ClickHouse/ClickHouse/pull/8459) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 无声警告 `CapNProto` 图书馆. [\#8220](https://github.com/ClickHouse/ClickHouse/pull/8220) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 为短字符串优化哈希表添加性能测试。 [\#7679](https://github.com/ClickHouse/ClickHouse/pull/7679) ([阿莫斯鸟](https://github.com/amosbird)) -- 现在ClickHouse将建立在 `AArch64` 即使 `MADV_FREE` 不可用。 这修复 [\#8027](https://github.com/ClickHouse/ClickHouse/issues/8027). [\#8243](https://github.com/ClickHouse/ClickHouse/pull/8243) ([阿莫斯鸟](https://github.com/amosbird)) -- 更新 `zlib-ng` 来解决记忆消毒的问题 [\#7182](https://github.com/ClickHouse/ClickHouse/pull/7182) [\#8206](https://github.com/ClickHouse/ClickHouse/pull/8206) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 在非Linux系统上启用内部MySQL库,因为操作系统包的使用非常脆弱,通常根本不起作用。 这修复 [\#5765](https://github.com/ClickHouse/ClickHouse/issues/5765). [\#8426](https://github.com/ClickHouse/ClickHouse/pull/8426) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复了启用后在某些系统上构建的问题 `libc++`. 这取代了 [\#8374](https://github.com/ClickHouse/ClickHouse/issues/8374). [\#8380](https://github.com/ClickHouse/ClickHouse/pull/8380) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 赂眉露\>\> `Field` 方法更类型安全,以找到更多的错误。 [\#7386](https://github.com/ClickHouse/ClickHouse/pull/7386) [\#8209](https://github.com/ClickHouse/ClickHouse/pull/8209) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 添加丢失的文件到 `libc-headers` 子模块。 [\#8507](https://github.com/ClickHouse/ClickHouse/pull/8507) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复错误 `JSON` 引用性能测试输出。 [\#8497](https://github.com/ClickHouse/ClickHouse/pull/8497) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 现在堆栈跟踪显示 `std::exception` 和 `Poco::Exception`. 在以前的版本中,它仅适用于 `DB::Exception`. 这改进了诊断。 [\#8501](https://github.com/ClickHouse/ClickHouse/pull/8501) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 移植 `clock_gettime` 和 `clock_nanosleep` 对于新鲜的glibc版本。 [\#8054](https://github.com/ClickHouse/ClickHouse/pull/8054) ([阿莫斯鸟](https://github.com/amosbird)) -- 启用 `part_log` 在示例配置开发人员。 [\#8609](https://github.com/ClickHouse/ClickHouse/pull/8609) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复重新加载的异步性质 `01036_no_superfluous_dict_reload_on_create_database*`. [\#8111](https://github.com/ClickHouse/ClickHouse/pull/8111) ([Azat Khuzhin](https://github.com/azat)) -- 固定编解码器性能测试。 [\#8615](https://github.com/ClickHouse/ClickHouse/pull/8615) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 添加安装脚本 `.tgz` 为他们构建和文档。 [\#8612](https://github.com/ClickHouse/ClickHouse/pull/8612) [\#8591](https://github.com/ClickHouse/ClickHouse/pull/8591) ([阿利沙平](https://github.com/alesapin)) -- 删除旧 `ZSTD` 测试(它是在2016年创建的,以重现zstd1.0版本之前的错误)。 这修复 [\#8618](https://github.com/ClickHouse/ClickHouse/issues/8618). [\#8619](https://github.com/ClickHouse/ClickHouse/pull/8619) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 固定构建在Mac OS卡特琳娜。 [\#8600](https://github.com/ClickHouse/ClickHouse/pull/8600) ([meo](https://github.com/meob)) -- 增加编解码器性能测试中的行数,以使结果显着。 [\#8574](https://github.com/ClickHouse/ClickHouse/pull/8574) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- 在调试版本中,处理 `LOGICAL_ERROR` 异常作为断言失败,使得它们更容易被注意到。 [\#8475](https://github.com/ClickHouse/ClickHouse/pull/8475) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 使与格式相关的性能测试更具确定性。 [\#8477](https://github.com/ClickHouse/ClickHouse/pull/8477) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新 `lz4` 来修复记忆消毒器的故障 [\#8181](https://github.com/ClickHouse/ClickHouse/pull/8181) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 在异常处理中抑制已知MemorySanitizer误报。 [\#8182](https://github.com/ClickHouse/ClickHouse/pull/8182) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 更新 `gcc` 和 `g++` 到版本9在 `build/docker/build.sh` [\#7766](https://github.com/ClickHouse/ClickHouse/pull/7766) ([TLightSky](https://github.com/tlightsky)) -- 添加性能测试用例来测试 `PREWHERE` 比 `WHERE`. [\#7768](https://github.com/ClickHouse/ClickHouse/pull/7768) ([阿莫斯鸟](https://github.com/amosbird)) -- 在修复一个笨拙的测试方面取得了进展。 [\#8621](https://github.com/ClickHouse/ClickHouse/pull/8621) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 避免从MemorySanitizer报告数据 `libunwind`. [\#8539](https://github.com/ClickHouse/ClickHouse/pull/8539) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 更新 `libc++` 到最新版本。 [\#8324](https://github.com/ClickHouse/ClickHouse/pull/8324) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从源头构建ICU库。 这修复 [\#6460](https://github.com/ClickHouse/ClickHouse/issues/6460). [\#8219](https://github.com/ClickHouse/ClickHouse/pull/8219) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 从切换 `libressl` 到 `openssl`. ClickHouse应在此更改后支持TLS1.3和SNI。 这修复 [\#8171](https://github.com/ClickHouse/ClickHouse/issues/8171). [\#8218](https://github.com/ClickHouse/ClickHouse/pull/8218) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用时固定的UBSan报告 `chacha20_poly1305` 从SSL(发生在连接到https://yandex.ru/)。 [\#8214](https://github.com/ClickHouse/ClickHouse/pull/8214) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复默认密码文件的模式 `.deb` linux发行版。 [\#8075](https://github.com/ClickHouse/ClickHouse/pull/8075) ([proller](https://github.com/proller)) -- 改进的表达式获取 `clickhouse-server` PID输入 `clickhouse-test`. [\#8063](https://github.com/ClickHouse/ClickHouse/pull/8063) ([亚历山大\*卡扎科夫](https://github.com/Akazz)) -- 更新contrib/googletest到v1.10.0。 [\#8587](https://github.com/ClickHouse/ClickHouse/pull/8587) ([Alexander Burmak](https://github.com/Alex-Burmak)) -- 修复了ThreadSaninitizer报告 `base64` 图书馆. 还将此库更新到最新版本,但无关紧要。 这修复 [\#8397](https://github.com/ClickHouse/ClickHouse/issues/8397). [\#8403](https://github.com/ClickHouse/ClickHouse/pull/8403) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 修复 `00600_replace_running_query` 对于处理器。 [\#8272](https://github.com/ClickHouse/ClickHouse/pull/8272) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 删除支持 `tcmalloc` 为了使 `CMakeLists.txt` 更简单 [\#8310](https://github.com/ClickHouse/ClickHouse/pull/8310) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 发布海湾合作委员会构建现在使用 `libc++` 而不是 `libstdc++`. 最近 `libc++` 只与叮当一起使用。 这将提高构建配置的一致性和可移植性。 [\#8311](https://github.com/ClickHouse/ClickHouse/pull/8311) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 使用MemorySanitizer启用ICU库进行构建。 [\#8222](https://github.com/ClickHouse/ClickHouse/pull/8222) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 禁止从警告 `CapNProto` 图书馆. [\#8224](https://github.com/ClickHouse/ClickHouse/pull/8224) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 删除代码的特殊情况 `tcmalloc`,因为它不再受支持。 [\#8225](https://github.com/ClickHouse/ClickHouse/pull/8225) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在CI coverage任务中,优雅地终止服务器以允许它保存coverage报告。 这修复了我们最近看到的不完整的复盖率报告。 [\#8142](https://github.com/ClickHouse/ClickHouse/pull/8142) ([阿利沙平](https://github.com/alesapin)) -- 针对所有编解码器的性能测试 `Float64` 和 `UInt64` 值。 [\#8349](https://github.com/ClickHouse/ClickHouse/pull/8349) ([瓦西里\*内姆科夫](https://github.com/Enmk)) -- `termcap` 非常不推荐使用,并导致各种问题(f.g.missing “up” 帽和呼应 `^J` 而不是多行)。 帮个忙 `terminfo` 或bund绑 `ncurses`. [\#7737](https://github.com/ClickHouse/ClickHouse/pull/7737) ([阿莫斯鸟](https://github.com/amosbird)) -- 修复 `test_storage_s3` 集成测试。 [\#7734](https://github.com/ClickHouse/ClickHouse/pull/7734) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 碌莽禄Support: `StorageFile(, null)` 将块插入给定格式的文件而不实际写入磁盘。 这是性能测试所必需的。 [\#8455](https://github.com/ClickHouse/ClickHouse/pull/8455) ([阿莫斯鸟](https://github.com/amosbird)) -- 添加参数 `--print-time` 功能测试打印每个测试的执行时间。 [\#8001](https://github.com/ClickHouse/ClickHouse/pull/8001) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 添加断言 `KeyCondition` 同时评估RPN。 这将修复来自gcc-9的警告。 [\#8279](https://github.com/ClickHouse/ClickHouse/pull/8279) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 在CI构建中转储cmake选项。 [\#8273](https://github.com/ClickHouse/ClickHouse/pull/8273) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 不要为某些fat库生成调试信息。 [\#8271](https://github.com/ClickHouse/ClickHouse/pull/8271) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 赂眉露\>\> `log_to_console.xml` 始终登录到stderr,无论它是否交互。 [\#8395](https://github.com/ClickHouse/ClickHouse/pull/8395) ([Alexander Kuzmenkov](https://github.com/akuzm)) -- 删除了一些未使用的功能 `clickhouse-performance-test` 工具 [\#8555](https://github.com/ClickHouse/ClickHouse/pull/8555) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 现在我们也将搜索 `lld-X` 与相应的 `clang-X` 版本。 [\#8092](https://github.com/ClickHouse/ClickHouse/pull/8092) ([阿利沙平](https://github.com/alesapin)) -- 实木复合地板建设改善。 [\#8421](https://github.com/ClickHouse/ClickHouse/pull/8421) ([马苏兰](https://github.com/maxulan)) -- 更多海湾合作委员会警告 [\#8221](https://github.com/ClickHouse/ClickHouse/pull/8221) ([kreuzerkrieg](https://github.com/kreuzerkrieg)) -- Arch Linux的软件包现在允许运行ClickHouse服务器,而不仅仅是客户端。 [\#8534](https://github.com/ClickHouse/ClickHouse/pull/8534) ([Vladimir Chebotarev](https://github.com/excitoon)) -- 修复与处理器的测试。 微小的性能修复。 [\#7672](https://github.com/ClickHouse/ClickHouse/pull/7672) ([尼古拉\*科切托夫](https://github.com/KochetovNicolai)) -- 更新contrib/protobuf。 [\#8256](https://github.com/ClickHouse/ClickHouse/pull/8256) ([Matwey V.Kornilov](https://github.com/matwey)) -- 在准备切换到c++20作为新年庆祝活动。 “May the C++ force be with ClickHouse.” [\#8447](https://github.com/ClickHouse/ClickHouse/pull/8447) ([阿莫斯鸟](https://github.com/amosbird)) - -#### 实验特点 {#experimental-feature-1} - -- 增加了实验设置 `min_bytes_to_use_mmap_io`. 它允许读取大文件,而无需将数据从内核复制到用户空间。 默认情况下禁用该设置。 建议的阈值大约是64MB,因为mmap/munmap很慢。 [\#8520](https://github.com/ClickHouse/ClickHouse/pull/8520) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) -- 返工配额作为访问控制系统的一部分。 增加了新表 `system.quotas`,新功能 `currentQuota`, `currentQuotaKey`,新的SQL语法 `CREATE QUOTA`, `ALTER QUOTA`, `DROP QUOTA`, `SHOW QUOTA`. [\#7257](https://github.com/ClickHouse/ClickHouse/pull/7257) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 允许跳过带有警告的未知设置,而不是引发异常。 [\#7653](https://github.com/ClickHouse/ClickHouse/pull/7653) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) -- 重新设计的行策略作为访问控制系统的一部分。 增加了新表 `system.row_policies`,新功能 `currentRowPolicies()`,新的SQL语法 `CREATE POLICY`, `ALTER POLICY`, `DROP POLICY`, `SHOW CREATE POLICY`, `SHOW POLICIES`. [\#7808](https://github.com/ClickHouse/ClickHouse/pull/7808) ([维塔利\*巴拉诺夫](https://github.com/vitlibar)) - -#### 安全修复 {#security-fix} - -- 修正了读取目录结构中的表的可能性 `File` 表引擎。 这修复 [\#8536](https://github.com/ClickHouse/ClickHouse/issues/8536). [\#8537](https://github.com/ClickHouse/ClickHouse/pull/8537) ([阿列克谢-米洛维多夫](https://github.com/alexey-milovidov)) - -## [更新日志2019](https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/changelog/2019.md) {#changelog-for-2019} diff --git a/docs/zh/whats_new/index.md b/docs/zh/whats_new/index.md deleted file mode 100644 index 75a13a72bac..00000000000 --- a/docs/zh/whats_new/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: b111334d6614a02564cf32f379679e9ff970d9b1 -toc_folder_title: "\u65B0\u589E\u5185\u5BB9" -toc_priority: 72 ---- - - diff --git a/docs/zh/whats_new/roadmap.md b/docs/zh/whats_new/roadmap.md deleted file mode 100644 index 47e09bc3c78..00000000000 --- a/docs/zh/whats_new/roadmap.md +++ /dev/null @@ -1,10 +0,0 @@ - -# 规划 {#gui-hua} - -## Q1 2020 {#q1-2020} - -- 更精确的用户资源池,可以在用户之间合理分配集群资源 -- 细粒度的授权管理 -- 与外部认证服务集成 - -[来源文章](https://clickhouse.tech/docs/en/roadmap/) diff --git a/docs/zh/whats_new/security_changelog.md b/docs/zh/whats_new/security_changelog.md deleted file mode 100644 index 6315398371f..00000000000 --- a/docs/zh/whats_new/security_changelog.md +++ /dev/null @@ -1,42 +0,0 @@ - -## 修复于 ClickHouse Release 18.12.13, 2018-09-10 {#xiu-fu-yu-clickhouse-release-18-12-13-2018-09-10} - -### CVE-2018-14672 {#cve-2018-14672} - -加载CatBoost模型的功能,允许遍历路径并通过错误消息读取任意文件。 - -来源: Yandex信息安全团队的Andrey Krasichkov - -## 修复于 ClickHouse Release 18.10.3, 2018-08-13 {#xiu-fu-yu-clickhouse-release-18-10-3-2018-08-13} - -### CVE-2018-14671 {#cve-2018-14671} - -unixODBC允许从文件系统加载任意共享对象,从而导致«远程执行代码»漏洞。 - -来源:Yandex信息安全团队的Andrey Krasichkov和Evgeny Sidorov - -## 修复于 ClickHouse Release 1.1.54388, 2018-06-28 {#xiu-fu-yu-clickhouse-release-1-1-54388-2018-06-28} - -### CVE-2018-14668 {#cve-2018-14668} - -远程表函数功能允许在 «user», «password» 及 «default\_database» 字段中使用任意符号,从而导致跨协议请求伪造攻击。 - -来源:Yandex信息安全团队的Andrey Krasichkov - -## 修复于 ClickHouse Release 1.1.54390, 2018-07-06 {#xiu-fu-yu-clickhouse-release-1-1-54390-2018-07-06} - -### CVE-2018-14669 {#cve-2018-14669} - -ClickHouse MySQL客户端启用了 «LOAD DATA LOCAL INFILE» 功能,该功能允许恶意MySQL数据库从连接的ClickHouse服务器读取任意文件。 - -来源:Yandex信息安全团队的Andrey Krasichkov和Evgeny Sidorov - -## 修复于 ClickHouse Release 1.1.54131, 2017-01-10 {#xiu-fu-yu-clickhouse-release-1-1-54131-2017-01-10} - -### CVE-2018-14670 {#cve-2018-14670} - -deb软件包中的错误配置可能导致使用未经授权的数据库。 - -来源:英国国家网络安全中心(NCSC) - -[来源文章](https://clickhouse.tech/docs/en/security_changelog/) diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 7cbe2e7a2a6..b36a2ff8194 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,3 +1,7 @@ +if (USE_CLANG_TIDY) + set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}") +endif () + # 'clickhouse' binary is a multi purpose tool, # that contain multiple execution modes (client, server, etc.) # each of them is built and linked as a separate library, defined below. @@ -201,3 +205,9 @@ endif () if (TARGET clickhouse-server AND TARGET copy-headers) add_dependencies(clickhouse-server copy-headers) endif () + +if (ENABLE_TESTS AND USE_GTEST) + set (CLICKHOUSE_UNIT_TESTS_TARGETS unit_tests_libcommon unit_tests_dbms) + add_custom_target (clickhouse-tests ALL DEPENDS ${CLICKHOUSE_UNIT_TESTS_TARGETS}) + add_dependencies(clickhouse-bundle clickhouse-tests) +endif() diff --git a/programs/benchmark/Benchmark.cpp b/programs/benchmark/Benchmark.cpp index ce59f5cac7f..e17320b39ea 100644 --- a/programs/benchmark/Benchmark.cpp +++ b/programs/benchmark/Benchmark.cpp @@ -289,7 +289,7 @@ private: connection_entries.emplace_back(std::make_shared( connection->get(ConnectionTimeouts::getTCPTimeoutsWithoutFailover(settings)))); - pool.scheduleOrThrowOnError(std::bind(&Benchmark::thread, this, connection_entries)); + pool.scheduleOrThrowOnError([this, connection_entries]() mutable { thread(connection_entries); }); } } catch (...) @@ -424,7 +424,7 @@ private: std::cerr << percent << "%\t\t"; for (const auto & info : infos) { - std::cerr << info->sampler.quantileNearest(percent / 100.0) << " sec." << "\t"; + std::cerr << info->sampler.quantileNearest(percent / 100.0) << " sec.\t"; } std::cerr << "\n"; }; @@ -459,7 +459,7 @@ private: auto print_percentile = [&json_out](Stats & info, auto percent, bool with_comma = true) { - json_out << "\"" << percent << "\"" << ": " << info.sampler.quantileNearest(percent / 100.0) << (with_comma ? ",\n" : "\n"); + json_out << "\"" << percent << "\": " << info.sampler.quantileNearest(percent / 100.0) << (with_comma ? ",\n" : "\n"); }; json_out << "{\n"; diff --git a/programs/benchmark/CMakeLists.txt b/programs/benchmark/CMakeLists.txt index be999aafe80..3fa8deb6bd9 100644 --- a/programs/benchmark/CMakeLists.txt +++ b/programs/benchmark/CMakeLists.txt @@ -1,5 +1,12 @@ -set(CLICKHOUSE_BENCHMARK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Benchmark.cpp) -set(CLICKHOUSE_BENCHMARK_LINK PRIVATE dbms clickhouse_aggregate_functions clickhouse_common_config ${Boost_PROGRAM_OPTIONS_LIBRARY}) +set (CLICKHOUSE_BENCHMARK_SOURCES Benchmark.cpp) + +set (CLICKHOUSE_BENCHMARK_LINK + PRIVATE + boost::program_options + clickhouse_aggregate_functions + clickhouse_common_config + dbms +) clickhouse_program_add(benchmark) diff --git a/programs/client/CMakeLists.txt b/programs/client/CMakeLists.txt index 11ade559a8d..6ded6a94f3a 100644 --- a/programs/client/CMakeLists.txt +++ b/programs/client/CMakeLists.txt @@ -1,19 +1,23 @@ -set(CLICKHOUSE_CLIENT_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/Client.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ConnectionParameters.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Suggest.cpp +set (CLICKHOUSE_CLIENT_SOURCES + Client.cpp + ConnectionParameters.cpp + Suggest.cpp ) -set(CLICKHOUSE_CLIENT_LINK PRIVATE clickhouse_common_config clickhouse_functions clickhouse_aggregate_functions clickhouse_common_io clickhouse_parsers string_utils ${Boost_PROGRAM_OPTIONS_LIBRARY}) +set (CLICKHOUSE_CLIENT_LINK + PRIVATE + boost::program_options + clickhouse_aggregate_functions + clickhouse_common_config + clickhouse_common_io + clickhouse_functions + clickhouse_parsers + string_utils +) -include(CheckSymbolExists) -check_symbol_exists(readpassphrase readpassphrase.h HAVE_READPASSPHRASE) -configure_file(config_client.h.in ${ConfigIncludePath}/config_client.h) - -if(NOT HAVE_READPASSPHRASE) - add_subdirectory(readpassphrase) - list(APPEND CLICKHOUSE_CLIENT_LINK PRIVATE readpassphrase) -endif() +# Always use internal readpassphrase +add_subdirectory(readpassphrase) +list(APPEND CLICKHOUSE_CLIENT_LINK PRIVATE readpassphrase) clickhouse_program_add(client) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 86e51ee396f..7808120d09e 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -76,6 +75,11 @@ #include #include #include +#include + +#if !defined(ARCADIA_BUILD) +# include +#endif #ifndef __clang__ #pragma GCC optimize("-fno-var-tracking-assignments") @@ -354,6 +358,78 @@ private: return false; } +#if USE_REPLXX + static void highlight(const String & query, std::vector & colors) + { + using namespace replxx; + + static const std::unordered_map token_to_color = + { + { TokenType::Whitespace, Replxx::Color::DEFAULT }, + { TokenType::Comment, Replxx::Color::GRAY }, + { TokenType::BareWord, Replxx::Color::DEFAULT }, + { TokenType::Number, Replxx::Color::GREEN }, + { TokenType::StringLiteral, Replxx::Color::CYAN }, + { TokenType::QuotedIdentifier, Replxx::Color::MAGENTA }, + { TokenType::OpeningRoundBracket, Replxx::Color::BROWN }, + { TokenType::ClosingRoundBracket, Replxx::Color::BROWN }, + { TokenType::OpeningSquareBracket, Replxx::Color::BROWN }, + { TokenType::ClosingSquareBracket, Replxx::Color::BROWN }, + { TokenType::OpeningCurlyBrace, Replxx::Color::INTENSE }, + { TokenType::ClosingCurlyBrace, Replxx::Color::INTENSE }, + + { TokenType::Comma, Replxx::Color::INTENSE }, + { TokenType::Semicolon, Replxx::Color::INTENSE }, + { TokenType::Dot, Replxx::Color::INTENSE }, + { TokenType::Asterisk, Replxx::Color::INTENSE }, + { TokenType::Plus, Replxx::Color::INTENSE }, + { TokenType::Minus, Replxx::Color::INTENSE }, + { TokenType::Slash, Replxx::Color::INTENSE }, + { TokenType::Percent, Replxx::Color::INTENSE }, + { TokenType::Arrow, Replxx::Color::INTENSE }, + { TokenType::QuestionMark, Replxx::Color::INTENSE }, + { TokenType::Colon, Replxx::Color::INTENSE }, + { TokenType::Equals, Replxx::Color::INTENSE }, + { TokenType::NotEquals, Replxx::Color::INTENSE }, + { TokenType::Less, Replxx::Color::INTENSE }, + { TokenType::Greater, Replxx::Color::INTENSE }, + { TokenType::LessOrEquals, Replxx::Color::INTENSE }, + { TokenType::GreaterOrEquals, Replxx::Color::INTENSE }, + { TokenType::Concatenation, Replxx::Color::INTENSE }, + { TokenType::At, Replxx::Color::INTENSE }, + + { TokenType::EndOfStream, Replxx::Color::DEFAULT }, + + { TokenType::Error, Replxx::Color::RED }, + { TokenType::ErrorMultilineCommentIsNotClosed, Replxx::Color::RED }, + { TokenType::ErrorSingleQuoteIsNotClosed, Replxx::Color::RED }, + { TokenType::ErrorDoubleQuoteIsNotClosed, Replxx::Color::RED }, + { TokenType::ErrorSinglePipeMark, Replxx::Color::RED }, + { TokenType::ErrorWrongNumber, Replxx::Color::RED }, + { TokenType::ErrorMaxQuerySizeExceeded, Replxx::Color::RED } + }; + + const Replxx::Color unknown_token_color = Replxx::Color::RED; + + Lexer lexer(query.data(), query.data() + query.size()); + size_t pos = 0; + + for (Token token = lexer.nextToken(); !token.isEnd(); token = lexer.nextToken()) + { + size_t utf8_len = UTF8::countCodePoints(reinterpret_cast(token.begin), token.size()); + for (size_t code_point_index = 0; code_point_index < utf8_len; ++code_point_index) + { + if (token_to_color.find(token.type) != token_to_color.end()) + colors[pos + code_point_index] = token_to_color.at(token.type); + else + colors[pos + code_point_index] = unknown_token_color; + } + + pos += utf8_len; + } + } +#endif + int mainImpl() { UseSSL use_ssl; @@ -398,6 +474,10 @@ private: ignore_error = config().getBool("ignore-error", false); } + ClientInfo & client_info = context.getClientInfo(); + client_info.setInitialQuery(); + client_info.quota_key = config().getString("quota_key", ""); + connect(); /// Initialize DateLUT here to avoid counting time spent here as query execution time. @@ -481,7 +561,7 @@ private: history_file = config().getString("history_file"); else { - auto history_file_from_env = getenv("CLICKHOUSE_HISTORY_FILE"); + auto * history_file_from_env = getenv("CLICKHOUSE_HISTORY_FILE"); if (history_file_from_env) history_file = history_file_from_env; else if (!home_path.empty()) @@ -491,12 +571,26 @@ private: if (!history_file.empty() && !Poco::File(history_file).exists()) Poco::File(history_file).createFile(); + LineReader::Patterns query_extenders = {"\\"}; + LineReader::Patterns query_delimiters = {";", "\\G"}; + #if USE_REPLXX - ReplxxLineReader lr(Suggest::instance(), history_file, '\\', config().has("multiline") ? ';' : 0); + replxx::Replxx::highlighter_callback_t highlight_callback{}; + if (config().getBool("highlight")) + highlight_callback = highlight; + + ReplxxLineReader lr( + Suggest::instance(), + history_file, + config().has("multiline"), + query_extenders, + query_delimiters, + highlight_callback); + #elif defined(USE_READLINE) && USE_READLINE - ReadlineLineReader lr(Suggest::instance(), history_file, '\\', config().has("multiline") ? ';' : 0); + ReadlineLineReader lr(Suggest::instance(), history_file, config().has("multiline"), query_extenders, query_delimiters); #else - LineReader lr(history_file, '\\', config().has("multiline") ? ';' : 0); + LineReader lr(history_file, config().has("multiline"), query_extenders, query_delimiters); #endif /// Enable bracketed-paste-mode only when multiquery is enabled and multiline is @@ -606,9 +700,7 @@ private: server_version = toString(server_version_major) + "." + toString(server_version_minor) + "." + toString(server_version_patch); - if ( - server_display_name = connection->getServerDisplayName(connection_parameters.timeouts); - server_display_name.length() == 0) + if (server_display_name = connection->getServerDisplayName(connection_parameters.timeouts); server_display_name.empty()) { server_display_name = config().getString("host", "localhost"); } @@ -620,13 +712,21 @@ private: << " revision " << server_revision << "." << std::endl << std::endl; - if (std::make_tuple(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) - < std::make_tuple(server_version_major, server_version_minor, server_version_patch)) + auto client_version_tuple = std::make_tuple(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); + auto server_version_tuple = std::make_tuple(server_version_major, server_version_minor, server_version_patch); + + if (client_version_tuple < server_version_tuple) { std::cout << "ClickHouse client version is older than ClickHouse server. " << "It may lack support for new features." << std::endl << std::endl; } + else if (client_version_tuple > server_version_tuple) + { + std::cout << "ClickHouse server version is older than ClickHouse client. " + << "It may indicate that the server is out of date and can be upgraded." + << std::endl << std::endl; + } } } @@ -906,7 +1006,7 @@ private: query_id, QueryProcessingStage::Complete, &context.getSettingsRef(), - nullptr, + &context.getClientInfo(), true); sendExternalTables(); @@ -938,7 +1038,15 @@ private: if (!parsed_insert_query.data && (is_interactive || (!stdin_is_a_tty && std_in.eof()))) throw Exception("No data to insert", ErrorCodes::NO_DATA_TO_INSERT); - connection->sendQuery(connection_parameters.timeouts, query_without_data, query_id, QueryProcessingStage::Complete, &context.getSettingsRef(), nullptr, true); + connection->sendQuery( + connection_parameters.timeouts, + query_without_data, + query_id, + QueryProcessingStage::Complete, + &context.getSettingsRef(), + &context.getClientInfo(), + true); + sendExternalTables(); /// Receive description of table structure. @@ -1154,10 +1262,10 @@ private: /// Poll for changes after a cancellation check, otherwise it never reached /// because of progress updates from server. if (connection->poll(poll_interval)) - break; + break; } - if (!receiveAndProcessPacket()) + if (!receiveAndProcessPacket(cancelled)) break; } @@ -1168,14 +1276,16 @@ private: /// Receive a part of the result, or progress info or an exception and process it. /// Returns true if one should continue receiving packets. - bool receiveAndProcessPacket() + /// Output of result is suppressed if query was cancelled. + bool receiveAndProcessPacket(bool cancelled) { Packet packet = connection->receivePacket(); switch (packet.type) { case Protocol::Server::Data: - onData(packet.block); + if (!cancelled) + onData(packet.block); return true; case Protocol::Server::Progress: @@ -1187,11 +1297,13 @@ private: return true; case Protocol::Server::Totals: - onTotals(packet.block); + if (!cancelled) + onTotals(packet.block); return true; case Protocol::Server::Extremes: - onExtremes(packet.block); + if (!cancelled) + onExtremes(packet.block); return true; case Protocol::Server::Exception: @@ -1283,7 +1395,7 @@ private: while (packet_type && *packet_type == Protocol::Server::Log) { - receiveAndProcessPacket(); + receiveAndProcessPacket(false); packet_type = connection->checkPacket(); } } @@ -1462,7 +1574,7 @@ private: "\033[1m↗\033[0m", }; - auto indicator = indicators[increment % 8]; + const char * indicator = indicators[increment % 8]; if (!send_logs && written_progress_chars) message << '\r'; @@ -1562,6 +1674,11 @@ private: if (std::string::npos != embedded_stack_trace_pos && !config().getBool("stacktrace", false)) text.resize(embedded_stack_trace_pos); + /// If we probably have progress bar, we should add additional newline, + /// otherwise exception may display concatenated with the progress bar. + if (need_render_progress) + std::cerr << '\n'; + std::cerr << "Received exception from server (version " << server_version << "):" << std::endl << "Code: " << e.code() << ". " << text << std::endl; } @@ -1711,6 +1828,7 @@ public: */ ("password", po::value()->implicit_value("\n", ""), "password") ("ask-password", "ask-password") + ("quota_key", po::value(), "A string to differentiate quotas when the user have keyed quotas configured on server") ("query_id", po::value(), "query_id") ("query,q", po::value(), "query") ("database,d", po::value(), "database") @@ -1732,6 +1850,7 @@ public: ("echo", "in batch mode, print query before execution") ("max_client_network_bandwidth", po::value(), "the maximum speed of data exchange over the network for the client in bytes per second.") ("compression", po::value(), "enable or disable compression") + ("highlight", po::value()->default_value(true), "enable or disable basic syntax highlight in interactive command line") ("log-level", po::value(), "client log level") ("server_logs_file", po::value(), "put server logs into specified file") ; @@ -1801,7 +1920,11 @@ public: std::string text = e.displayText(); std::cerr << "Code: " << e.code() << ". " << text << std::endl; std::cerr << "Table №" << i << std::endl << std::endl; - exit(e.code()); + /// Avoid the case when error exit code can possibly overflow to normal (zero). + auto exit_code = e.code() % 256; + if (exit_code == 0) + exit_code = 255; + exit(exit_code); } } @@ -1846,6 +1969,8 @@ public: config().setString("password", options["password"].as()); if (options.count("ask-password")) config().setBool("ask-password", true); + if (options.count("quota_key")) + config().setString("quota_key", options["quota_key"].as()); if (options.count("multiline")) config().setBool("multiline", true); if (options.count("multiquery")) @@ -1876,6 +2001,8 @@ public: config().setBool("disable_suggestion", true); if (options.count("suggestion_limit")) config().setInt("suggestion_limit", options["suggestion_limit"].as()); + if (options.count("highlight")) + config().setBool("highlight", options["highlight"].as()); argsToConfig(common_arguments, config(), 100); diff --git a/programs/client/ConnectionParameters.cpp b/programs/client/ConnectionParameters.cpp index e1611af249d..d8b4d0f1add 100644 --- a/programs/client/ConnectionParameters.cpp +++ b/programs/client/ConnectionParameters.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include "readpassphrase/readpassphrase.h" namespace DB { @@ -29,8 +29,10 @@ ConnectionParameters::ConnectionParameters(const Poco::Util::AbstractConfigurati "port", config.getInt(is_secure ? "tcp_port_secure" : "tcp_port", is_secure ? DBMS_DEFAULT_SECURE_PORT : DBMS_DEFAULT_PORT)); default_database = config.getString("database", ""); + /// changed the default value to "default" to fix the issue when the user in the prompt is blank user = config.getString("user", "default"); + bool password_prompt = false; if (config.getBool("ask-password", false)) { @@ -49,9 +51,10 @@ ConnectionParameters::ConnectionParameters(const Poco::Util::AbstractConfigurati { std::string prompt{"Password for user (" + user + "): "}; char buf[1000] = {}; - if (auto result = readpassphrase(prompt.c_str(), buf, sizeof(buf), 0)) + if (auto * result = readpassphrase(prompt.c_str(), buf, sizeof(buf), 0)) password = result; } + compression = config.getBool("compression", true) ? Protocol::Compression::Enable : Protocol::Compression::Disable; timeouts = ConnectionTimeouts( diff --git a/programs/client/ConnectionParameters.h b/programs/client/ConnectionParameters.h index 834f08df9cb..a169df8390a 100644 --- a/programs/client/ConnectionParameters.h +++ b/programs/client/ConnectionParameters.h @@ -23,7 +23,6 @@ struct ConnectionParameters ConnectionTimeouts timeouts; ConnectionParameters() {} - ConnectionParameters(const Poco::Util::AbstractConfiguration & config); }; diff --git a/programs/client/Suggest.cpp b/programs/client/Suggest.cpp index 8fffbec4fab..4ac5e735fd5 100644 --- a/programs/client/Suggest.cpp +++ b/programs/client/Suggest.cpp @@ -114,6 +114,8 @@ void Suggest::loadImpl(Connection & connection, const ConnectionTimeouts & timeo << " UNION ALL " "SELECT DISTINCT name FROM system.tables LIMIT " << limit_str << " UNION ALL " + "SELECT DISTINCT name FROM system.dictionaries LIMIT " << limit_str + << " UNION ALL " "SELECT DISTINCT name FROM system.columns LIMIT " << limit_str; } diff --git a/programs/client/Suggest.h b/programs/client/Suggest.h index 6c81a388ea7..b13289ac322 100644 --- a/programs/client/Suggest.h +++ b/programs/client/Suggest.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace DB diff --git a/programs/client/config_client.h.in b/programs/client/config_client.h.in deleted file mode 100644 index 5ad788ff54c..00000000000 --- a/programs/client/config_client.h.in +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#cmakedefine HAVE_READPASSPHRASE diff --git a/programs/client/readpassphrase/CMakeLists.txt b/programs/client/readpassphrase/CMakeLists.txt index a10b54c377d..dd1bf2c91b9 100644 --- a/programs/client/readpassphrase/CMakeLists.txt +++ b/programs/client/readpassphrase/CMakeLists.txt @@ -1,13 +1,7 @@ - # wget https://raw.githubusercontent.com/openssh/openssh-portable/master/openbsd-compat/readpassphrase.c # wget https://raw.githubusercontent.com/openssh/openssh-portable/master/openbsd-compat/readpassphrase.h -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result -Wno-reserved-id-macro") +add_library(readpassphrase readpassphrase.c) -configure_file(includes.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/includes.h) -add_library(readpassphrase ${CMAKE_CURRENT_SOURCE_DIR}/readpassphrase.c) -set_target_properties(readpassphrase - PROPERTIES LINKER_LANGUAGE C - ) -# . to allow #include -target_include_directories(readpassphrase PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}/include) +set_target_properties(readpassphrase PROPERTIES LINKER_LANGUAGE C) +target_compile_options(readpassphrase PRIVATE -Wno-unused-result -Wno-reserved-id-macro) diff --git a/programs/client/readpassphrase/includes.h b/programs/client/readpassphrase/includes.h new file mode 100644 index 00000000000..3ca5eb2bff8 --- /dev/null +++ b/programs/client/readpassphrase/includes.h @@ -0,0 +1,9 @@ +#pragma once + +/* #undef HAVE_READPASSPHRASE */ + +#if !defined(HAVE_READPASSPHRASE) +# ifndef _PATH_TTY +# define _PATH_TTY "/dev/tty" +# endif +#endif diff --git a/programs/client/readpassphrase/includes.h.in b/programs/client/readpassphrase/includes.h.in deleted file mode 100644 index 44580d1ed95..00000000000 --- a/programs/client/readpassphrase/includes.h.in +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#cmakedefine HAVE_READPASSPHRASE - -#if !defined(HAVE_READPASSPHRASE) -# ifndef _PATH_TTY -# define _PATH_TTY "/dev/tty" -# endif -#endif diff --git a/programs/client/readpassphrase/readpassphrase.c b/programs/client/readpassphrase/readpassphrase.c index 243701239bf..21b48e7efc3 100644 --- a/programs/client/readpassphrase/readpassphrase.c +++ b/programs/client/readpassphrase/readpassphrase.c @@ -25,13 +25,11 @@ #include "includes.h" -#ifndef HAVE_READPASSPHRASE - #include #include #include #include -#include +#include "readpassphrase.h" #include #include #include @@ -193,19 +191,7 @@ restart: } //DEF_WEAK(readpassphrase); -#if 0 -char * -getpass(const char *prompt) -{ - static char buf[_PASSWORD_LEN + 1]; - - return(readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF)); -} -#endif - static void handler(int s) { - signo[s] = 1; } -#endif /* HAVE_READPASSPHRASE */ diff --git a/programs/client/readpassphrase/readpassphrase.h b/programs/client/readpassphrase/readpassphrase.h index 0782a1773ea..399eb7b062c 100644 --- a/programs/client/readpassphrase/readpassphrase.h +++ b/programs/client/readpassphrase/readpassphrase.h @@ -23,39 +23,22 @@ /* OPENBSD ORIGINAL: include/readpassphrase.h */ #pragma once -// #ifndef _READPASSPHRASE_H_ -// #define _READPASSPHRASE_H_ -//#include "includes.h" -#include "config_client.h" - -// Should not be included on BSD systems, but if it happen... -#ifdef HAVE_READPASSPHRASE -# include_next +#if defined(__cplusplus) +extern "C" { #endif -#ifndef HAVE_READPASSPHRASE -# ifdef __cplusplus -extern "C" { -# endif - - -# define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ -# define RPP_ECHO_ON 0x01 /* Leave echo on. */ -# define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ -# define RPP_FORCELOWER 0x04 /* Force input to lower case. */ -# define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ -# define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ -# define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */ +#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ +#define RPP_ECHO_ON 0x01 /* Leave echo on. */ +#define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ +#define RPP_FORCELOWER 0x04 /* Force input to lower case. */ +#define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ +#define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ +#define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */ char * readpassphrase(const char *, char *, size_t, int); -# ifdef __cplusplus +#if defined(__cplusplus) } -# endif - - -#endif /* HAVE_READPASSPHRASE */ - -// #endif /* !_READPASSPHRASE_H_ */ +#endif diff --git a/programs/client/readpassphrase/ya.make b/programs/client/readpassphrase/ya.make new file mode 100644 index 00000000000..80ad197e5d4 --- /dev/null +++ b/programs/client/readpassphrase/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + readpassphrase.c +) + +END() diff --git a/programs/compressor/CMakeLists.txt b/programs/compressor/CMakeLists.txt index c009bb55f76..ff642a32fd4 100644 --- a/programs/compressor/CMakeLists.txt +++ b/programs/compressor/CMakeLists.txt @@ -1,7 +1,12 @@ # Also in utils -set(CLICKHOUSE_COMPRESSOR_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Compressor.cpp) -set(CLICKHOUSE_COMPRESSOR_LINK PRIVATE dbms clickhouse_parsers ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#set(CLICKHOUSE_COMPRESSOR_INCLUDE SYSTEM PRIVATE ...) +set (CLICKHOUSE_COMPRESSOR_SOURCES Compressor.cpp) + +set (CLICKHOUSE_COMPRESSOR_LINK + PRIVATE + boost::program_options + clickhouse_parsers + dbms +) clickhouse_program_add(compressor) diff --git a/programs/compressor/Compressor.cpp b/programs/compressor/Compressor.cpp index fecdad9bcea..701e8ea2d1c 100644 --- a/programs/compressor/Compressor.cpp +++ b/programs/compressor/Compressor.cpp @@ -63,6 +63,8 @@ void checkAndWriteHeader(DB::ReadBuffer & in, DB::WriteBuffer & out) int mainEntryClickHouseCompressor(int argc, char ** argv) { + using namespace DB; + boost::program_options::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth()); desc.add_options() ("help,h", "produce help message") @@ -99,10 +101,10 @@ int mainEntryClickHouseCompressor(int argc, char ** argv) codecs = options["codec"].as>(); if ((use_lz4hc || use_zstd || use_none) && !codecs.empty()) - throw DB::Exception("Wrong options, codec flags like --zstd and --codec options are mutually exclusive", DB::ErrorCodes::BAD_ARGUMENTS); + throw Exception("Wrong options, codec flags like --zstd and --codec options are mutually exclusive", ErrorCodes::BAD_ARGUMENTS); if (!codecs.empty() && options.count("level")) - throw DB::Exception("Wrong options, --level is not compatible with --codec list", DB::ErrorCodes::BAD_ARGUMENTS); + throw Exception("Wrong options, --level is not compatible with --codec list", ErrorCodes::BAD_ARGUMENTS); std::string method_family = "LZ4"; @@ -117,22 +119,21 @@ int mainEntryClickHouseCompressor(int argc, char ** argv) if (options.count("level")) level = options["level"].as(); - - DB::CompressionCodecPtr codec; + CompressionCodecPtr codec; if (!codecs.empty()) { - DB::ParserCodec codec_parser; + ParserCodec codec_parser; std::string codecs_line = boost::algorithm::join(codecs, ","); - auto ast = DB::parseQuery(codec_parser, "(" + codecs_line + ")", 0, DBMS_DEFAULT_MAX_PARSER_DEPTH); - codec = DB::CompressionCodecFactory::instance().get(ast, nullptr); + auto ast = parseQuery(codec_parser, "(" + codecs_line + ")", 0, DBMS_DEFAULT_MAX_PARSER_DEPTH); + codec = CompressionCodecFactory::instance().get(ast, nullptr, false); } else - codec = DB::CompressionCodecFactory::instance().get(method_family, level); + codec = CompressionCodecFactory::instance().get(method_family, level, false); - DB::ReadBufferFromFileDescriptor rb(STDIN_FILENO); - DB::WriteBufferFromFileDescriptor wb(STDOUT_FILENO); + ReadBufferFromFileDescriptor rb(STDIN_FILENO); + WriteBufferFromFileDescriptor wb(STDOUT_FILENO); if (stat_mode) { @@ -142,20 +143,20 @@ int mainEntryClickHouseCompressor(int argc, char ** argv) else if (decompress) { /// Decompression - DB::CompressedReadBuffer from(rb); - DB::copyData(from, wb); + CompressedReadBuffer from(rb); + copyData(from, wb); } else { /// Compression - DB::CompressedWriteBuffer to(wb, codec, block_size); - DB::copyData(rb, to); + CompressedWriteBuffer to(wb, codec, block_size); + copyData(rb, to); } } catch (...) { - std::cerr << DB::getCurrentExceptionMessage(true); - return DB::getCurrentExceptionCode(); + std::cerr << getCurrentExceptionMessage(true); + return getCurrentExceptionCode(); } return 0; diff --git a/programs/copier/CMakeLists.txt b/programs/copier/CMakeLists.txt index 76db6ce1ffc..f69b30f3f43 100644 --- a/programs/copier/CMakeLists.txt +++ b/programs/copier/CMakeLists.txt @@ -3,14 +3,20 @@ set(CLICKHOUSE_COPIER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ClusterCopier.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Internals.cpp) -set(CLICKHOUSE_COPIER_LINK PRIVATE - clickhouse_common_zookeeper - clickhouse_parsers - clickhouse_functions - clickhouse_table_functions - clickhouse_aggregate_functions - clickhouse_dictionaries - string_utils ${Poco_XML_LIBRARY} PUBLIC daemon) +set (CLICKHOUSE_COPIER_LINK + PRIVATE + clickhouse_common_zookeeper + clickhouse_common_config + clickhouse_parsers + clickhouse_functions + clickhouse_table_functions + clickhouse_aggregate_functions + clickhouse_dictionaries + string_utils + + PUBLIC + daemon +) set(CLICKHOUSE_COPIER_INCLUDE SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/programs/copier/ClusterCopier.cpp b/programs/copier/ClusterCopier.cpp index e8b999534e2..7fa0f663295 100644 --- a/programs/copier/ClusterCopier.cpp +++ b/programs/copier/ClusterCopier.cpp @@ -4,6 +4,8 @@ #include #include +#include + namespace DB { @@ -23,10 +25,10 @@ void ClusterCopier::init() task_description_watch_callback = [this] (const Coordination::WatchResponse & response) { - if (response.error != Coordination::ZOK) + if (response.error != Coordination::Error::ZOK) return; UInt64 version = ++task_description_version; - LOG_DEBUG(log, "Task description should be updated, local version " << version); + LOG_DEBUG(log, "Task description should be updated, local version {}", version); }; task_description_path = task_zookeeper_path + "/description"; @@ -47,7 +49,7 @@ void ClusterCopier::init() task_table.initShards(task_cluster->random_engine); } - LOG_DEBUG(log, "Will process " << task_cluster->table_tasks.size() << " table tasks"); + LOG_DEBUG(log, "Will process {} table tasks", task_cluster->table_tasks.size()); /// Do not initialize tables, will make deferred initialization in process() @@ -85,7 +87,7 @@ void ClusterCopier::discoverShardPartitions(const ConnectionTimeouts & timeouts, { TaskTable & task_table = task_shard->task_table; - LOG_INFO(log, "Discover partitions of shard " << task_shard->getDescription()); + LOG_INFO(log, "Discover partitions of shard {}", task_shard->getDescription()); auto get_partitions = [&] () { return getShardPartitions(timeouts, *task_shard); }; auto existing_partitions_names = retry(get_partitions, 60); @@ -132,8 +134,7 @@ void ClusterCopier::discoverShardPartitions(const ConnectionTimeouts & timeouts, { if (!task_table.enabled_partitions_set.count(partition_name)) { - LOG_DEBUG(log, "Partition " << partition_name << " will not be processed, since it is not in " - << "enabled_partitions of " << task_table.table_id); + LOG_DEBUG(log, "Partition {} will not be processed, since it is not in enabled_partitions of {}", partition_name, task_table.table_id); } } } @@ -165,11 +166,10 @@ void ClusterCopier::discoverShardPartitions(const ConnectionTimeouts & timeouts, for (const String & missing_partition : missing_partitions) ss << " " << missing_partition; - LOG_WARNING(log, "There are no " << missing_partitions.size() << " partitions from enabled_partitions in shard " - << task_shard->getDescription() << " :" << ss.str()); + LOG_WARNING(log, "There are no {} partitions from enabled_partitions in shard {} :{}", missing_partitions.size(), task_shard->getDescription(), ss.str()); } - LOG_DEBUG(log, "Will copy " << task_shard->partition_tasks.size() << " partitions from shard " << task_shard->getDescription()); + LOG_DEBUG(log, "Will copy {} partitions from shard {}", task_shard->partition_tasks.size(), task_shard->getDescription()); } void ClusterCopier::discoverTablePartitions(const ConnectionTimeouts & timeouts, TaskTable & task_table, UInt64 num_threads) @@ -179,9 +179,13 @@ void ClusterCopier::discoverTablePartitions(const ConnectionTimeouts & timeouts, ThreadPool thread_pool(num_threads ? num_threads : 2 * getNumberOfPhysicalCPUCores()); for (const TaskShardPtr & task_shard : task_table.all_shards) - thread_pool.scheduleOrThrowOnError([this, timeouts, task_shard]() { discoverShardPartitions(timeouts, task_shard); }); + thread_pool.scheduleOrThrowOnError([this, timeouts, task_shard]() + { + setThreadName("DiscoverPartns"); + discoverShardPartitions(timeouts, task_shard); + }); - LOG_DEBUG(log, "Waiting for " << thread_pool.active() << " setup jobs"); + LOG_DEBUG(log, "Waiting for {} setup jobs", thread_pool.active()); thread_pool.wait(); } } @@ -202,10 +206,11 @@ void ClusterCopier::uploadTaskDescription(const std::string & task_path, const s zookeeper->createAncestors(local_task_description_path); auto code = zookeeper->tryCreate(local_task_description_path, task_config_str, zkutil::CreateMode::Persistent); - if (code && force) + if (code != Coordination::Error::ZOK && force) zookeeper->createOrUpdate(local_task_description_path, task_config_str, zkutil::CreateMode::Persistent); - LOG_DEBUG(log, "Task description " << ((code && !force) ? "not " : "") << "uploaded to " << local_task_description_path << " with result " << code << " ("<< zookeeper->error2string(code) << ")"); + LOG_DEBUG(log, "Task description {} uploaded to {} with result {} ({})", + ((code != Coordination::Error::ZOK && !force) ? "not " : ""), local_task_description_path, code, Coordination::errorMessage(code)); } void ClusterCopier::reloadTaskDescription() @@ -215,13 +220,13 @@ void ClusterCopier::reloadTaskDescription() String task_config_str; Coordination::Stat stat{}; - int code; + Coordination::Error code; zookeeper->tryGetWatch(task_description_path, task_config_str, &stat, task_description_watch_callback, &code); - if (code) + if (code != Coordination::Error::ZOK) throw Exception("Can't get description node " + task_description_path, ErrorCodes::BAD_ARGUMENTS); - LOG_DEBUG(log, "Loading description, zxid=" << task_description_current_stat.czxid); + LOG_DEBUG(log, "Loading description, zxid={}", task_description_current_stat.czxid); auto config = getConfigurationFromXMLString(task_config_str); /// Setup settings @@ -251,9 +256,7 @@ void ClusterCopier::process(const ConnectionTimeouts & timeouts) { for (TaskTable & task_table : task_cluster->table_tasks) { - LOG_INFO(log, "Process table task " << task_table.table_id << " with " - << task_table.all_shards.size() << " shards, " - << task_table.local_shards.size() << " of them are local ones"); + LOG_INFO(log, "Process table task {} with {} shards, {} of them are local ones", task_table.table_id, task_table.all_shards.size(), task_table.local_shards.size()); if (task_table.all_shards.empty()) continue; @@ -357,8 +360,7 @@ zkutil::EphemeralNodeHolder::Ptr ClusterCopier::createTaskWorkerNodeAndWaitIfNee if (static_cast(stat.numChildren) >= task_cluster->max_workers) { - LOG_DEBUG(log, "Too many workers (" << stat.numChildren << ", maximum " << task_cluster->max_workers << ")" - << ". Postpone processing " << description); + LOG_DEBUG(log, "Too many workers ({}, maximum {}). Postpone processing {}", stat.numChildren, task_cluster->max_workers, description); if (unprioritized) current_sleep_time = std::min(max_sleep_time, current_sleep_time + default_sleep_time); @@ -374,10 +376,10 @@ zkutil::EphemeralNodeHolder::Ptr ClusterCopier::createTaskWorkerNodeAndWaitIfNee Coordination::Responses responses; auto code = zookeeper->tryMulti(ops, responses); - if (code == Coordination::ZOK || code == Coordination::ZNODEEXISTS) + if (code == Coordination::Error::ZOK || code == Coordination::Error::ZNODEEXISTS) return std::make_shared(current_worker_path, *zookeeper, false, false, description); - if (code == Coordination::ZBADVERSION) + if (code == Coordination::Error::ZBADVERSION) { ++num_bad_version_errors; @@ -419,7 +421,7 @@ bool ClusterCopier::checkAllPiecesInPartitionAreDone(const TaskTable & task_tabl { bool piece_is_done = checkPartitionPieceIsDone(task_table, partition_name, piece_number, shards_with_partition); if (!piece_is_done) - LOG_DEBUG(log, "Partition " << partition_name << " piece " + toString(piece_number) + " is not already done."); + LOG_DEBUG(log, "Partition {} piece {} is not already done.", partition_name, piece_number); answer &= piece_is_done; } @@ -435,14 +437,13 @@ bool ClusterCopier::checkAllPiecesInPartitionAreDone(const TaskTable & task_tabl bool ClusterCopier::checkPartitionPieceIsDone(const TaskTable & task_table, const String & partition_name, size_t piece_number, const TasksShard & shards_with_partition) { - LOG_DEBUG(log, "Check that all shards processed partition " << partition_name - << " piece " + toString(piece_number) + " successfully"); + LOG_DEBUG(log, "Check that all shards processed partition {} piece {} successfully", partition_name, piece_number); auto zookeeper = context.getZooKeeper(); /// Collect all shards that contain partition piece number piece_number. Strings piece_status_paths; - for (auto & shard : shards_with_partition) + for (const auto & shard : shards_with_partition) { ShardPartition & task_shard_partition = shard->partition_tasks.find(partition_name)->second; ShardPartitionPiece & shard_partition_piece = task_shard_partition.pieces[piece_number]; @@ -465,8 +466,7 @@ bool ClusterCopier::checkPartitionPieceIsDone(const TaskTable & task_table, cons TaskStateWithOwner status = TaskStateWithOwner::fromString(res.data); if (status.state != TaskState::Finished) { - LOG_INFO(log, "The task " << res.data << " is being rewritten by " - << status.owner << ". Partition piece will be rechecked"); + LOG_INFO(log, "The task {} is being rewritten by {}. Partition piece will be rechecked", res.data, status.owner); return false; } @@ -484,7 +484,7 @@ bool ClusterCopier::checkPartitionPieceIsDone(const TaskTable & task_table, cons if (!is_clean) { - LOG_INFO(log, "Partition " << partition_name << " become dirty"); + LOG_INFO(log, "Partition {} become dirty", partition_name); return false; } @@ -501,8 +501,7 @@ bool ClusterCopier::checkPartitionPieceIsDone(const TaskTable & task_table, cons } catch (const Coordination::Exception & e) { - LOG_INFO(log, "A ZooKeeper error occurred while checking partition " << partition_name << " piece number " - << toString(piece_number) << ". Will recheck the partition. Error: " << e.displayText()); + LOG_INFO(log, "A ZooKeeper error occurred while checking partition {} piece number {}. Will recheck the partition. Error: {}", partition_name, toString(piece_number), e.displayText()); return false; } @@ -511,12 +510,12 @@ bool ClusterCopier::checkPartitionPieceIsDone(const TaskTable & task_table, cons { if (zxid1[shard_num] != zxid2[shard_num]) { - LOG_INFO(log, "The task " << piece_status_paths[shard_num] << " is being modified now. Partition piece will be rechecked"); + LOG_INFO(log, "The task {} is being modified now. Partition piece will be rechecked", piece_status_paths[shard_num]); return false; } } - LOG_INFO(log, "Partition " << partition_name << " piece number " << toString(piece_number) << " is copied successfully"); + LOG_INFO(log, "Partition {} piece number {} is copied successfully", partition_name, toString(piece_number)); return true; } @@ -530,7 +529,7 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t inject_fault = value < move_fault_probability; } - LOG_DEBUG(log, "Try to move " << partition_name << " to destionation table"); + LOG_DEBUG(log, "Try to move {} to destionation table", partition_name); auto zookeeper = context.getZooKeeper(); @@ -546,9 +545,9 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t } catch (const Coordination::Exception & e) { - if (e.code == Coordination::ZNODEEXISTS) + if (e.code == Coordination::Error::ZNODEEXISTS) { - LOG_DEBUG(log, "Someone is already moving pieces " << current_partition_attach_is_active); + LOG_DEBUG(log, "Someone is already moving pieces {}", current_partition_attach_is_active); return TaskStatus::Active; } @@ -565,16 +564,13 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t TaskStateWithOwner status = TaskStateWithOwner::fromString(status_data); if (status.state == TaskState::Finished) { - LOG_DEBUG(log, "All pieces for partition from this task " << current_partition_attach_is_active - << " has been successfully moved to destination table by " << status.owner); + LOG_DEBUG(log, "All pieces for partition from this task {} has been successfully moved to destination table by {}", current_partition_attach_is_active, status.owner); return TaskStatus::Finished; } /// Task is abandoned, because previously we created ephemeral node, possibly in other copier's process. /// Initialize DROP PARTITION - LOG_DEBUG(log, "Moving piece for partition " << current_partition_attach_is_active - << " has not been successfully finished by " << status.owner - << ". Will try to move by myself."); + LOG_DEBUG(log, "Moving piece for partition {} has not been successfully finished by {}. Will try to move by myself.", current_partition_attach_is_active, status.owner); /// Remove is_done marker. zookeeper->remove(current_partition_attach_is_done); @@ -591,9 +587,7 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t /// Move partition to original destination table. for (size_t current_piece_number = 0; current_piece_number < task_table.number_of_splits; ++current_piece_number) { - LOG_DEBUG(log, "Trying to move partition " << partition_name - << " piece " << toString(current_piece_number) - << " to original table"); + LOG_DEBUG(log, "Trying to move partition {} piece {} to original table", partition_name, toString(current_piece_number)); ASTPtr query_alter_ast; String query_alter_ast_string; @@ -614,25 +608,22 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t " ATTACH PARTITION " + partition_name + " FROM " + getQuotedTable(helping_table); - LOG_DEBUG(log, "Executing ALTER query: " << query_alter_ast_string); + LOG_DEBUG(log, "Executing ALTER query: {}", query_alter_ast_string); try { size_t num_nodes = executeQueryOnCluster( task_table.cluster_push, query_alter_ast_string, - nullptr, - &settings_push, + settings_push, PoolMode::GET_MANY, ClusterExecutionMode::ON_EACH_NODE); - LOG_INFO(log, "Number of nodes that executed ALTER query successfully : " << toString(num_nodes)); + LOG_INFO(log, "Number of nodes that executed ALTER query successfully : {}", toString(num_nodes)); } catch (...) { - LOG_DEBUG(log, "Error while moving partition " << partition_name - << " piece " << toString(current_piece_number) - << "to original table"); + LOG_DEBUG(log, "Error while moving partition {} piece {} to original table", partition_name, toString(current_piece_number)); throw; } @@ -647,23 +638,20 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t query_deduplicate_ast_string += " OPTIMIZE TABLE " + getQuotedTable(original_table) + " PARTITION " + partition_name + " DEDUPLICATE;"; - LOG_DEBUG(log, "Executing OPTIMIZE DEDUPLICATE query: " << query_alter_ast_string); + LOG_DEBUG(log, "Executing OPTIMIZE DEDUPLICATE query: {}", query_alter_ast_string); UInt64 num_nodes = executeQueryOnCluster( task_table.cluster_push, query_deduplicate_ast_string, - nullptr, - &task_cluster->settings_push, + task_cluster->settings_push, PoolMode::GET_MANY); - LOG_INFO(log, "Number of shard that executed OPTIMIZE DEDUPLICATE query successfully : " - << toString(num_nodes)); + LOG_INFO(log, "Number of shard that executed OPTIMIZE DEDUPLICATE query successfully : {}", toString(num_nodes)); } } catch (...) { - LOG_DEBUG(log, "Error while executing OPTIMIZE DEDUPLICATE partition " << partition_name - << "in the original table"); + LOG_DEBUG(log, "Error while executing OPTIMIZE DEDUPLICATE partition {}in the original table", partition_name); throw; } } @@ -702,7 +690,7 @@ ASTPtr ClusterCopier::removeAliasColumnsFromCreateQuery(const ASTPtr & query_ast auto new_columns_list = std::make_shared(); new_columns_list->set(new_columns_list->columns, new_columns); - if (auto indices = query_ast->as()->columns_list->indices) + if (const auto * indices = query_ast->as()->columns_list->indices) new_columns_list->set(new_columns_list->indices, indices->clone()); new_query.replace(new_query.columns_list, new_columns_list); @@ -757,10 +745,9 @@ bool ClusterCopier::tryDropPartitionPiece( } catch (const Coordination::Exception & e) { - if (e.code == Coordination::ZNODEEXISTS) + if (e.code == Coordination::Error::ZNODEEXISTS) { - LOG_DEBUG(log, "Partition " << task_partition.name << " piece " - << toString(current_piece_number) << " is cleaning now by somebody, sleep"); + LOG_DEBUG(log, "Partition {} piece {} is cleaning now by somebody, sleep", task_partition.name, toString(current_piece_number)); std::this_thread::sleep_for(default_sleep_time); return false; } @@ -773,8 +760,7 @@ bool ClusterCopier::tryDropPartitionPiece( { if (stat.numChildren != 0) { - LOG_DEBUG(log, "Partition " << task_partition.name << " contains " << stat.numChildren - << " active workers while trying to drop it. Going to sleep."); + LOG_DEBUG(log, "Partition {} contains {} active workers while trying to drop it. Going to sleep.", task_partition.name, stat.numChildren); std::this_thread::sleep_for(default_sleep_time); return false; } @@ -792,9 +778,9 @@ bool ClusterCopier::tryDropPartitionPiece( } catch (const Coordination::Exception & e) { - if (e.code == Coordination::ZNODEEXISTS) + if (e.code == Coordination::Error::ZNODEEXISTS) { - LOG_DEBUG(log, "Partition " << task_partition.name << " is being filled now by somebody, sleep"); + LOG_DEBUG(log, "Partition {} is being filled now by somebody, sleep", task_partition.name); return false; } @@ -809,7 +795,7 @@ bool ClusterCopier::tryDropPartitionPiece( /// Remove all status nodes { Strings children; - if (zookeeper->tryGetChildren(current_shards_path, children) == Coordination::ZOK) + if (zookeeper->tryGetChildren(current_shards_path, children) == Coordination::Error::ZOK) for (const auto & child : children) { zookeeper->removeRecursive(current_shards_path + "/" + child); @@ -832,16 +818,15 @@ bool ClusterCopier::tryDropPartitionPiece( /// It is important, DROP PARTITION must be done synchronously settings_push.replication_alter_partitions_sync = 2; - LOG_DEBUG(log, "Execute distributed DROP PARTITION: " << query); + LOG_DEBUG(log, "Execute distributed DROP PARTITION: {}", query); /// We have to drop partition_piece on each replica size_t num_shards = executeQueryOnCluster( cluster_push, query, - nullptr, - &settings_push, + settings_push, PoolMode::GET_MANY, ClusterExecutionMode::ON_EACH_NODE); - LOG_INFO(log, "DROP PARTITION was successfully executed on " << num_shards << " nodes of a cluster."); + LOG_INFO(log, "DROP PARTITION was successfully executed on {} nodes of a cluster.", num_shards); /// Update the locking node if (!my_clock.is_stale()) @@ -859,13 +844,12 @@ bool ClusterCopier::tryDropPartitionPiece( return false; } - LOG_INFO(log, "Partition " << task_partition.name << " piece " << toString(current_piece_number) - << " was dropped on cluster " << task_table.cluster_push_name); - if (zookeeper->tryCreate(current_shards_path, host_id, zkutil::CreateMode::Persistent) == Coordination::ZNODEEXISTS) + LOG_INFO(log, "Partition {} piece {} was dropped on cluster {}", task_partition.name, toString(current_piece_number), task_table.cluster_push_name); + if (zookeeper->tryCreate(current_shards_path, host_id, zkutil::CreateMode::Persistent) == Coordination::Error::ZNODEEXISTS) zookeeper->set(current_shards_path, host_id); } - LOG_INFO(log, "Partition " << task_partition.name << " piece " << toString(current_piece_number) << " is safe for work now."); + LOG_INFO(log, "Partition {} piece {} is safe for work now.", task_partition.name, toString(current_piece_number)); return true; } @@ -889,7 +873,7 @@ bool ClusterCopier::tryProcessTable(const ConnectionTimeouts & timeouts, TaskTab ++cluster_partition.total_tries; - LOG_DEBUG(log, "Processing partition " << partition_name << " for the whole cluster"); + LOG_DEBUG(log, "Processing partition {} for the whole cluster", partition_name); /// Process each source shard having current partition and copy current partition /// NOTE: shards are sorted by "distance" to current host @@ -911,7 +895,7 @@ bool ClusterCopier::tryProcessTable(const ConnectionTimeouts & timeouts, TaskTab { const size_t number_of_splits = task_table.number_of_splits; shard->partition_tasks.emplace(partition_name, ShardPartition(*shard, partition_name, number_of_splits)); - LOG_DEBUG(log, "Discovered partition " << partition_name << " in shard " << shard->getDescription()); + LOG_DEBUG(log, "Discovered partition {} in shard {}", partition_name, shard->getDescription()); /// To save references in the future. auto shard_partition_it = shard->partition_tasks.find(partition_name); PartitionPieces & shard_partition_pieces = shard_partition_it->second.pieces; @@ -924,7 +908,7 @@ bool ClusterCopier::tryProcessTable(const ConnectionTimeouts & timeouts, TaskTab } else { - LOG_DEBUG(log, "Found that shard " << shard->getDescription() << " does not contain current partition " << partition_name); + LOG_DEBUG(log, "Found that shard {} does not contain current partition {}", shard->getDescription(), partition_name); continue; } } @@ -1030,21 +1014,20 @@ bool ClusterCopier::tryProcessTable(const ConnectionTimeouts & timeouts, TaskTab task_table.rows_copied += cluster_partition.rows_copied; double elapsed = cluster_partition.elapsed_time_seconds; - LOG_INFO(log, "It took " << std::fixed << std::setprecision(2) << elapsed << " seconds to copy partition " << partition_name - << ": " << formatReadableSizeWithDecimalSuffix(cluster_partition.bytes_copied) << " uncompressed bytes" - << ", " << formatReadableQuantity(cluster_partition.rows_copied) << " rows" - << " and " << cluster_partition.blocks_copied << " source blocks are copied"); + LOG_INFO(log, "It took {} seconds to copy partition {}: {} uncompressed bytes, {} rows and {} source blocks are copied", + elapsed, partition_name, + formatReadableSizeWithDecimalSuffix(cluster_partition.bytes_copied), + formatReadableQuantity(cluster_partition.rows_copied), + cluster_partition.blocks_copied); if (cluster_partition.rows_copied) { - LOG_INFO(log, "Average partition speed: " - << formatReadableSizeWithDecimalSuffix(cluster_partition.bytes_copied / elapsed) << " per second."); + LOG_INFO(log, "Average partition speed: {} per second.", formatReadableSizeWithDecimalSuffix(cluster_partition.bytes_copied / elapsed)); } if (task_table.rows_copied) { - LOG_INFO(log, "Average table " << task_table.table_id << " speed: " - << formatReadableSizeWithDecimalSuffix(task_table.bytes_copied / elapsed) << " per second."); + LOG_INFO(log, "Average table {} speed: {} per second.", task_table.table_id, formatReadableSizeWithDecimalSuffix(task_table.bytes_copied / elapsed)); } } } @@ -1055,8 +1038,7 @@ bool ClusterCopier::tryProcessTable(const ConnectionTimeouts & timeouts, TaskTab if (!table_is_done) { - LOG_INFO(log, "Table " + task_table.table_id + " is not processed yet." - << "Copied " << finished_partitions << " of " << required_partitions << ", will retry"); + LOG_INFO(log, "Table {} is not processed yet.Copied {} of {}, will retry", task_table.table_id, finished_partitions, required_partitions); } return table_is_done; @@ -1104,9 +1086,11 @@ TaskStatus ClusterCopier::iterateThroughAllPiecesInPartition(const ConnectionTim { for (UInt64 try_num = 0; try_num < max_shard_partition_tries; ++try_num) { - LOG_INFO(log, "Attempt number " << try_num << " to process partition " << task_partition.name - << " piece number " << piece_number << " on shard number " << task_partition.task_shard.numberInCluster() - << " with index " << task_partition.task_shard.indexInCluster()); + LOG_INFO(log, "Attempt number {} to process partition {} piece number {} on shard number {} with index {}.", + try_num, task_partition.name, piece_number, + task_partition.task_shard.numberInCluster(), + task_partition.task_shard.indexInCluster()); + res = processPartitionPieceTaskImpl(timeouts, task_partition, piece_number, is_unprioritized_task); /// Exit if success @@ -1210,7 +1194,7 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( /// Load balancing auto worker_node_holder = createTaskWorkerNodeAndWaitIfNeed(zookeeper, current_task_piece_status_path, is_unprioritized_task); - LOG_DEBUG(log, "Processing " << current_task_piece_status_path); + LOG_DEBUG(log, "Processing {}", current_task_piece_status_path); const String piece_status_path = partition_piece.getPartitionPieceShardsPath(); @@ -1221,14 +1205,12 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( /// Do not start if partition piece is dirty, try to clean it if (is_clean) { - LOG_DEBUG(log, "Partition " << task_partition.name - << " piece " + toString(current_piece_number) + " appears to be clean"); + LOG_DEBUG(log, "Partition {} piece {} appears to be clean", task_partition.name, current_piece_number); zookeeper->createAncestors(current_task_piece_status_path); } else { - LOG_DEBUG(log, "Partition " << task_partition.name - << " piece " + toString(current_piece_number) + " is dirty, try to drop it"); + LOG_DEBUG(log, "Partition {} piece {} is dirty, try to drop it", task_partition.name, current_piece_number); try { @@ -1251,9 +1233,9 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( } catch (const Coordination::Exception & e) { - if (e.code == Coordination::ZNODEEXISTS) + if (e.code == Coordination::Error::ZNODEEXISTS) { - LOG_DEBUG(log, "Someone is already processing " << current_task_piece_is_active_path); + LOG_DEBUG(log, "Someone is already processing {}", current_task_piece_is_active_path); return TaskStatus::Active; } @@ -1269,16 +1251,13 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( TaskStateWithOwner status = TaskStateWithOwner::fromString(status_data); if (status.state == TaskState::Finished) { - LOG_DEBUG(log, "Task " << current_task_piece_status_path - << " has been successfully executed by " << status.owner); + LOG_DEBUG(log, "Task {} has been successfully executed by {}", current_task_piece_status_path, status.owner); return TaskStatus::Finished; } /// Task is abandoned, because previously we created ephemeral node, possibly in other copier's process. /// Initialize DROP PARTITION - LOG_DEBUG(log, "Task " << current_task_piece_status_path - << " has not been successfully finished by " << status.owner - << ". Partition will be dropped and refilled."); + LOG_DEBUG(log, "Task {} has not been successfully finished by {}. Partition will be dropped and refilled.", current_task_piece_status_path, status.owner); create_is_dirty_node(clean_state_clock); return TaskStatus::Error; @@ -1292,12 +1271,10 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( { String state_finished = TaskStateWithOwner::getData(TaskState::Finished, host_id); auto res = zookeeper->tryCreate(current_task_piece_status_path, state_finished, zkutil::CreateMode::Persistent); - if (res == Coordination::ZNODEEXISTS) - LOG_DEBUG(log, "Partition " << task_partition.name << " piece " - + toString(current_piece_number) + " is absent on current replica of a shard. But other replicas have already marked it as done."); - if (res == Coordination::ZOK) - LOG_DEBUG(log, "Partition " << task_partition.name << " piece " - + toString(current_piece_number) + " is absent on current replica of a shard. Will mark it as done. Other replicas will do the same."); + if (res == Coordination::Error::ZNODEEXISTS) + LOG_DEBUG(log, "Partition {} piece {} is absent on current replica of a shard. But other replicas have already marked it as done.", task_partition.name, current_piece_number); + if (res == Coordination::Error::ZOK) + LOG_DEBUG(log, "Partition {} piece {} is absent on current replica of a shard. Will mark it as done. Other replicas will do the same.", task_partition.name, current_piece_number); return TaskStatus::Finished; } @@ -1319,24 +1296,20 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( local_context.setSettings(task_cluster->settings_pull); local_context.setSetting("skip_unavailable_shards", true); - Block block = getBlockWithAllStreamData(InterpreterFactory::get(query_select_ast, local_context)->execute().in); + Block block = getBlockWithAllStreamData(InterpreterFactory::get(query_select_ast, local_context)->execute().getInputStream()); count = (block) ? block.safeGetByPosition(0).column->getUInt(0) : 0; } if (count != 0) { - LOG_INFO(log, "Partition " << task_partition.name << " piece " - << current_piece_number << "is not empty. In contains " << count << " rows."); + LOG_INFO(log, "Partition {} piece {}is not empty. In contains {} rows.", task_partition.name, current_piece_number, count); Coordination::Stat stat_shards{}; zookeeper->get(partition_piece.getPartitionPieceShardsPath(), &stat_shards); /// NOTE: partition is still fresh if dirt discovery happens before cleaning if (stat_shards.numChildren == 0) { - LOG_WARNING(log, "There are no workers for partition " << task_partition.name - << " piece " << toString(current_piece_number) - << ", but destination table contains " << count << " rows" - << ". Partition will be dropped and refilled."); + LOG_WARNING(log, "There are no workers for partition {} piece {}, but destination table contains {} rows. Partition will be dropped and refilled.", task_partition.name, toString(current_piece_number), count); create_is_dirty_node(clean_state_clock); return TaskStatus::Error; @@ -1353,14 +1326,12 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( CleanStateClock new_clean_state_clock (zookeeper, piece_is_dirty_flag_path, piece_is_dirty_cleaned_path); if (clean_state_clock != new_clean_state_clock) { - LOG_INFO(log, "Partition " << task_partition.name << " piece " - << toString(current_piece_number) << " clean state changed, cowardly bailing"); + LOG_INFO(log, "Partition {} piece {} clean state changed, cowardly bailing", task_partition.name, toString(current_piece_number)); return TaskStatus::Error; } else if (!new_clean_state_clock.is_clean()) { - LOG_INFO(log, "Partition " << task_partition.name << " piece " - << toString(current_piece_number) << " is dirty and will be dropped and refilled"); + LOG_INFO(log, "Partition {} piece {} is dirty and will be dropped and refilled", task_partition.name, toString(current_piece_number)); create_is_dirty_node(new_clean_state_clock); return TaskStatus::Error; } @@ -1387,12 +1358,9 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( create_query_push_ast->as().if_not_exists = true; String query = queryToString(create_query_push_ast); - LOG_DEBUG(log, "Create destination tables. Query: " << query); - UInt64 shards = executeQueryOnCluster(task_table.cluster_push, query, - create_query_push_ast, &task_cluster->settings_push, - PoolMode::GET_MANY); - LOG_DEBUG(log, "Destination tables " << getQuotedTable(task_table.table_push) - << " have been created on " << shards << " shards of " << task_table.cluster_push->getShardCount()); + LOG_DEBUG(log, "Create destination tables. Query: {}", query); + UInt64 shards = executeQueryOnCluster(task_table.cluster_push, query, task_cluster->settings_push, PoolMode::GET_MANY); + LOG_DEBUG(log, "Destination tables {} have been created on {} shards of {}", getQuotedTable(task_table.table_push), shards, task_table.cluster_push->getShardCount()); } /// Do the copying @@ -1407,8 +1375,7 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( // Select all fields ASTPtr query_select_ast = get_select_query(task_shard.table_read_shard, "*", /*enable_splitting*/ true, inject_fault ? "1" : ""); - LOG_DEBUG(log, "Executing SELECT query and pull from " << task_shard.getDescription() - << " : " << queryToString(query_select_ast)); + LOG_DEBUG(log, "Executing SELECT query and pull from {} : {}", task_shard.getDescription(), queryToString(query_select_ast)); ASTPtr query_insert_ast; { @@ -1419,7 +1386,7 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( const auto & settings = context.getSettingsRef(); query_insert_ast = parseQuery(p_query, query, settings.max_query_size, settings.max_parser_depth); - LOG_DEBUG(log, "Executing INSERT query: " << query); + LOG_DEBUG(log, "Executing INSERT query: {}", query); } try @@ -1437,7 +1404,7 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( BlockIO io_select = InterpreterFactory::get(query_select_ast, context_select)->execute(); BlockIO io_insert = InterpreterFactory::get(query_insert_ast, context_insert)->execute(); - input = io_select.in; + input = io_select.getInputStream(); output = io_insert.out; } @@ -1462,7 +1429,7 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( { Coordination::ExistsResponse status = future_is_dirty_checker.get(); - if (status.error != Coordination::ZNONODE) + if (status.error != Coordination::Error::ZNONODE) { LogicalClock dirt_discovery_epoch (status.stat.mzxid); if (dirt_discovery_epoch == clean_state_clock.discovery_zxid) @@ -1501,8 +1468,7 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( } } - LOG_INFO(log, "Partition " << task_partition.name << " piece " - << toString(current_piece_number) << " copied. But not moved to original destination table."); + LOG_INFO(log, "Partition {} piece {} copied. But not moved to original destination table.", task_partition.name, toString(current_piece_number)); /// Try create original table (if not exists) on each shard @@ -1513,12 +1479,9 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( create_query_push_ast->as().if_not_exists = true; String query = queryToString(create_query_push_ast); - LOG_DEBUG(log, "Create destination tables. Query: " << query); - UInt64 shards = executeQueryOnCluster(task_table.cluster_push, query, - create_query_push_ast, &task_cluster->settings_push, - PoolMode::GET_MANY); - LOG_DEBUG(log, "Destination tables " << getQuotedTable(task_table.table_push) - << " have been created on " << shards << " shards of " << task_table.cluster_push->getShardCount()); + LOG_DEBUG(log, "Create destination tables. Query: {}", query); + UInt64 shards = executeQueryOnCluster(task_table.cluster_push, query, task_cluster->settings_push, PoolMode::GET_MANY); + LOG_DEBUG(log, "Destination tables {} have been created on {} shards of {}", getQuotedTable(task_table.table_push), shards, task_table.cluster_push->getShardCount()); } catch (...) { @@ -1531,14 +1494,12 @@ TaskStatus ClusterCopier::processPartitionPieceTaskImpl( CleanStateClock new_clean_state_clock (zookeeper, piece_is_dirty_flag_path, piece_is_dirty_cleaned_path); if (clean_state_clock != new_clean_state_clock) { - LOG_INFO(log, "Partition " << task_partition.name << " piece " - << toString(current_piece_number) << " clean state changed, cowardly bailing"); + LOG_INFO(log, "Partition {} piece {} clean state changed, cowardly bailing", task_partition.name, toString(current_piece_number)); return TaskStatus::Error; } else if (!new_clean_state_clock.is_clean()) { - LOG_INFO(log, "Partition " << task_partition.name << " piece " - << toString(current_piece_number) << " became dirty and will be dropped and refilled"); + LOG_INFO(log, "Partition {} piece {} became dirty and will be dropped and refilled", task_partition.name, toString(current_piece_number)); create_is_dirty_node(new_clean_state_clock); return TaskStatus::Error; } @@ -1582,16 +1543,15 @@ void ClusterCopier::dropHelpingTables(const TaskTable & task_table) const ClusterPtr & cluster_push = task_table.cluster_push; Settings settings_push = task_cluster->settings_push; - LOG_DEBUG(log, "Execute distributed DROP TABLE: " << query); + LOG_DEBUG(log, "Execute distributed DROP TABLE: {}", query); /// We have to drop partition_piece on each replica UInt64 num_nodes = executeQueryOnCluster( cluster_push, query, - nullptr, - &settings_push, + settings_push, PoolMode::GET_MANY, ClusterExecutionMode::ON_EACH_NODE); - LOG_DEBUG(log, "DROP TABLE query was successfully executed on " << toString(num_nodes) << " nodes."); + LOG_DEBUG(log, "DROP TABLE query was successfully executed on {} nodes.", toString(num_nodes)); } } @@ -1609,18 +1569,17 @@ void ClusterCopier::dropParticularPartitionPieceFromAllHelpingTables(const TaskT const ClusterPtr & cluster_push = task_table.cluster_push; Settings settings_push = task_cluster->settings_push; - LOG_DEBUG(log, "Execute distributed DROP PARTITION: " << query); + LOG_DEBUG(log, "Execute distributed DROP PARTITION: {}", query); /// We have to drop partition_piece on each replica UInt64 num_nodes = executeQueryOnCluster( cluster_push, query, - nullptr, - &settings_push, + settings_push, PoolMode::GET_MANY, ClusterExecutionMode::ON_EACH_NODE); - LOG_DEBUG(log, "DROP PARTITION query was successfully executed on " << toString(num_nodes) << " nodes."); + LOG_DEBUG(log, "DROP PARTITION query was successfully executed on {} nodes.", toString(num_nodes)); } - LOG_DEBUG(log, "All helping tables dropped partition " << partition_name); + LOG_DEBUG(log, "All helping tables dropped partition {}", partition_name); } String ClusterCopier::getRemoteCreateTable(const DatabaseAndTableName & table, Connection & connection, const Settings * settings) @@ -1724,11 +1683,11 @@ std::set ClusterCopier::getShardPartitions(const ConnectionTimeouts & ti const auto & settings = context.getSettingsRef(); ASTPtr query_ast = parseQuery(parser_query, query, settings.max_query_size, settings.max_parser_depth); - LOG_DEBUG(log, "Computing destination partition set, executing query: " << query); + LOG_DEBUG(log, "Computing destination partition set, executing query: {}", query); Context local_context = context; local_context.setSettings(task_cluster->settings_pull); - Block block = getBlockWithAllStreamData(InterpreterFactory::get(query_ast, local_context)->execute().in); + Block block = getBlockWithAllStreamData(InterpreterFactory::get(query_ast, local_context)->execute().getInputStream()); std::set res; if (block) @@ -1744,7 +1703,7 @@ std::set ClusterCopier::getShardPartitions(const ConnectionTimeouts & ti } } - LOG_DEBUG(log, "There are " << res.size() << " destination partitions in shard " << task_shard.getDescription()); + LOG_DEBUG(log, "There are {} destination partitions in shard {}", res.size(), task_shard.getDescription()); return res; } @@ -1765,8 +1724,7 @@ bool ClusterCopier::checkShardHasPartition(const ConnectionTimeouts & timeouts, query += " LIMIT 1"; - LOG_DEBUG(log, "Checking shard " << task_shard.getDescription() << " for partition " - << partition_quoted_name << " existence, executing query: " << query); + LOG_DEBUG(log, "Checking shard {} for partition {} existence, executing query: {}", task_shard.getDescription(), partition_quoted_name, query); ParserQuery parser_query(query.data() + query.size()); const auto & settings = context.getSettingsRef(); @@ -1774,7 +1732,7 @@ const auto & settings = context.getSettingsRef(); Context local_context = context; local_context.setSettings(task_cluster->settings_pull); - return InterpreterFactory::get(query_ast, local_context)->execute().in->read().rows() != 0; + return InterpreterFactory::get(query_ast, local_context)->execute().getInputStream()->read().rows() != 0; } bool ClusterCopier::checkPresentPartitionPiecesOnCurrentShard(const ConnectionTimeouts & timeouts, @@ -1805,9 +1763,7 @@ bool ClusterCopier::checkPresentPartitionPiecesOnCurrentShard(const ConnectionTi query += " LIMIT 1"; - LOG_DEBUG(log, "Checking shard " << task_shard.getDescription() << " for partition " - << partition_quoted_name << " piece " << std::to_string(current_piece_number) - << "existence, executing query: " << query); + LOG_DEBUG(log, "Checking shard {} for partition {} piece {} existence, executing query: {}", task_shard.getDescription(), partition_quoted_name, std::to_string(current_piece_number), query); ParserQuery parser_query(query.data() + query.size()); const auto & settings = context.getSettingsRef(); @@ -1815,13 +1771,11 @@ bool ClusterCopier::checkPresentPartitionPiecesOnCurrentShard(const ConnectionTi Context local_context = context; local_context.setSettings(task_cluster->settings_pull); - auto result = InterpreterFactory::get(query_ast, local_context)->execute().in->read().rows(); + auto result = InterpreterFactory::get(query_ast, local_context)->execute().getInputStream()->read().rows(); if (result != 0) - LOG_DEBUG(log, "Partition " << partition_quoted_name << " piece number " - << std::to_string(current_piece_number) << " is PRESENT on shard " << task_shard.getDescription()); + LOG_DEBUG(log, "Partition {} piece number {} is PRESENT on shard {}", partition_quoted_name, std::to_string(current_piece_number), task_shard.getDescription()); else - LOG_DEBUG(log, "Partition " << partition_quoted_name << " piece number " - << std::to_string(current_piece_number) << " is ABSENT on shard " << task_shard.getDescription()); + LOG_DEBUG(log, "Partition {} piece number {} is ABSENT on shard {}", partition_quoted_name, std::to_string(current_piece_number), task_shard.getDescription()); return result != 0; } @@ -1831,8 +1785,7 @@ bool ClusterCopier::checkPresentPartitionPiecesOnCurrentShard(const ConnectionTi UInt64 ClusterCopier::executeQueryOnCluster( const ClusterPtr & cluster, const String & query, - const ASTPtr & query_ast_, - const Settings * settings, + const Settings & current_settings, PoolMode pool_mode, ClusterExecutionMode execution_mode, UInt64 max_successful_executions_per_shard) const @@ -1840,15 +1793,8 @@ UInt64 ClusterCopier::executeQueryOnCluster( auto num_shards = cluster->getShardsInfo().size(); std::vector per_shard_num_successful_replicas(num_shards, 0); - ASTPtr query_ast; - if (query_ast_ == nullptr) - { - ParserQuery p_query(query.data() + query.size()); - const auto & settings = context.getSettingsRef(); - query_ast = parseQuery(p_query, query, settings.max_query_size, settings.max_parser_depth); - } - else - query_ast = query_ast_; + ParserQuery p_query(query.data() + query.size()); + ASTPtr query_ast = parseQuery(p_query, query, current_settings.max_query_size, current_settings.max_parser_depth); /// We will have to execute query on each replica of a shard. if (execution_mode == ClusterExecutionMode::ON_EACH_NODE) @@ -1857,8 +1803,10 @@ UInt64 ClusterCopier::executeQueryOnCluster( std::atomic origin_replicas_number; /// We need to execute query on one replica at least - auto do_for_shard = [&] (UInt64 shard_index) + auto do_for_shard = [&] (UInt64 shard_index, Settings shard_settings) { + setThreadName("QueryForShard"); + const Cluster::ShardInfo & shard = cluster->getShardsInfo().at(shard_index); UInt64 & num_successful_executions = per_shard_num_successful_replicas.at(shard_index); num_successful_executions = 0; @@ -1888,11 +1836,10 @@ UInt64 ClusterCopier::executeQueryOnCluster( /// Will try to make as many as possible queries if (shard.hasRemoteConnections()) { - Settings current_settings = settings ? *settings : task_cluster->settings_common; - current_settings.max_parallel_replicas = num_remote_replicas ? num_remote_replicas : 1; + shard_settings.max_parallel_replicas = num_remote_replicas ? num_remote_replicas : 1; - auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(current_settings).getSaturated(current_settings.max_execution_time); - auto connections = shard.pool->getMany(timeouts, ¤t_settings, pool_mode); + auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(shard_settings).getSaturated(shard_settings.max_execution_time); + auto connections = shard.pool->getMany(timeouts, &shard_settings, pool_mode); for (auto & connection : connections) { @@ -1902,7 +1849,7 @@ UInt64 ClusterCopier::executeQueryOnCluster( try { /// CREATE TABLE and DROP PARTITION queries return empty block - RemoteBlockInputStream stream{*connection, query, Block{}, context, ¤t_settings}; + RemoteBlockInputStream stream{*connection, query, Block{}, context, &shard_settings}; NullBlockOutputStream output{Block{}}; copyData(stream, output); @@ -1921,7 +1868,7 @@ UInt64 ClusterCopier::executeQueryOnCluster( ThreadPool thread_pool(std::min(num_shards, getNumberOfPhysicalCPUCores())); for (UInt64 shard_index = 0; shard_index < num_shards; ++shard_index) - thread_pool.scheduleOrThrowOnError([=] { do_for_shard(shard_index); }); + thread_pool.scheduleOrThrowOnError([=, shard_settings = current_settings] { do_for_shard(shard_index, std::move(shard_settings)); }); thread_pool.wait(); } @@ -1938,11 +1885,10 @@ UInt64 ClusterCopier::executeQueryOnCluster( if (execution_mode == ClusterExecutionMode::ON_EACH_NODE && successful_nodes != origin_replicas_number) { - LOG_INFO(log, "There was an error while executing ALTER on each node. Query was executed on " - << toString(successful_nodes) << " nodes. But had to be executed on " << toString(origin_replicas_number.load())); + LOG_INFO(log, "There was an error while executing ALTER on each node. Query was executed on {} nodes. But had to be executed on {}", toString(successful_nodes), toString(origin_replicas_number.load())); } - return successful_nodes; } + } diff --git a/programs/copier/ClusterCopier.h b/programs/copier/ClusterCopier.h index 3d6400f51d4..beaf247dfc8 100644 --- a/programs/copier/ClusterCopier.h +++ b/programs/copier/ClusterCopier.h @@ -15,7 +15,6 @@ namespace DB class ClusterCopier { public: - ClusterCopier(const String & task_path_, const String & host_id_, const String & proxy_database_name_, @@ -187,8 +186,7 @@ protected: UInt64 executeQueryOnCluster( const ClusterPtr & cluster, const String & query, - const ASTPtr & query_ast_ = nullptr, - const Settings * settings = nullptr, + const Settings & current_settings, PoolMode pool_mode = PoolMode::GET_ALL, ClusterExecutionMode execution_mode = ClusterExecutionMode::ON_EACH_SHARD, UInt64 max_successful_executions_per_shard = 0) const; diff --git a/programs/copier/ClusterCopierApp.cpp b/programs/copier/ClusterCopierApp.cpp index 52a37c75c72..ce4bf94589e 100644 --- a/programs/copier/ClusterCopierApp.cpp +++ b/programs/copier/ClusterCopierApp.cpp @@ -94,12 +94,8 @@ void ClusterCopierApp::mainImpl() StatusFile status_file(process_path + "/status"); ThreadStatus thread_status; - auto log = &logger(); - LOG_INFO(log, "Starting clickhouse-copier (" - << "id " << process_id << ", " - << "host_id " << host_id << ", " - << "path " << process_path << ", " - << "revision " << ClickHouseRevision::get() << ")"); + auto * log = &logger(); + LOG_INFO(log, "Starting clickhouse-copier (id {}, host_id {}, path {}, revision {})", process_id, host_id, process_path, ClickHouseRevision::get()); SharedContextHolder shared_context = Context::createShared(); auto context = std::make_unique(Context::createGlobal(shared_context.get())); @@ -118,7 +114,7 @@ void ClusterCopierApp::mainImpl() registerDisks(); static const std::string default_database = "_local"; - DatabaseCatalog::instance().attachDatabase(default_database, std::make_shared(default_database)); + DatabaseCatalog::instance().attachDatabase(default_database, std::make_shared(default_database, *context)); context->setCurrentDatabase(default_database); /// Initialize query scope just in case. diff --git a/programs/copier/Internals.cpp b/programs/copier/Internals.cpp index 545df2e779c..0613381a763 100644 --- a/programs/copier/Internals.cpp +++ b/programs/copier/Internals.cpp @@ -260,7 +260,7 @@ ShardPriority getReplicasPriority(const Cluster::Addresses & replicas, const std return res; res.is_remote = 1; - for (auto & replica : replicas) + for (const auto & replica : replicas) { if (isLocalAddress(DNSResolver::instance().resolveHost(replica.host_name))) { @@ -270,7 +270,7 @@ ShardPriority getReplicasPriority(const Cluster::Addresses & replicas, const std } res.hostname_difference = std::numeric_limits::max(); - for (auto & replica : replicas) + for (const auto & replica : replicas) { size_t difference = getHostNameDifference(local_hostname, replica.host_name); res.hostname_difference = std::min(difference, res.hostname_difference); diff --git a/programs/copier/ZooKeeperStaff.h b/programs/copier/ZooKeeperStaff.h index 2fc4d35400d..66036ae2f27 100644 --- a/programs/copier/ZooKeeperStaff.h +++ b/programs/copier/ZooKeeperStaff.h @@ -178,16 +178,16 @@ public: [stale = stale] (const Coordination::WatchResponse & rsp) { auto logger = &Poco::Logger::get("ClusterCopier"); - if (rsp.error == Coordination::ZOK) + if (rsp.error == Coordination::Error::ZOK) { switch (rsp.type) { case Coordination::CREATED: - LOG_DEBUG(logger, "CleanStateClock change: CREATED, at " << rsp.path); + LOG_DEBUG(logger, "CleanStateClock change: CREATED, at {}", rsp.path); stale->store(true); break; case Coordination::CHANGED: - LOG_DEBUG(logger, "CleanStateClock change: CHANGED, at" << rsp.path); + LOG_DEBUG(logger, "CleanStateClock change: CHANGED, at {}", rsp.path); stale->store(true); } } diff --git a/programs/extract-from-config/CMakeLists.txt b/programs/extract-from-config/CMakeLists.txt index b82cbb966ae..ff2d7937117 100644 --- a/programs/extract-from-config/CMakeLists.txt +++ b/programs/extract-from-config/CMakeLists.txt @@ -1,5 +1,11 @@ -set(CLICKHOUSE_EXTRACT_FROM_CONFIG_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ExtractFromConfig.cpp) -set(CLICKHOUSE_EXTRACT_FROM_CONFIG_LINK PRIVATE clickhouse_common_config clickhouse_common_io clickhouse_common_zookeeper ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#set(CLICKHOUSE_EXTRACT_FROM_CONFIG_INCLUDE SYSTEM PRIVATE ...) +set (CLICKHOUSE_EXTRACT_FROM_CONFIG_SOURCES ExtractFromConfig.cpp) + +set (CLICKHOUSE_EXTRACT_FROM_CONFIG_LINK + PRIVATE + boost::program_options + clickhouse_common_config + clickhouse_common_io + clickhouse_common_zookeeper +) clickhouse_program_add(extract-from-config) diff --git a/programs/format/CMakeLists.txt b/programs/format/CMakeLists.txt index aac72d641e6..ab06708cd3a 100644 --- a/programs/format/CMakeLists.txt +++ b/programs/format/CMakeLists.txt @@ -1,5 +1,11 @@ -set(CLICKHOUSE_FORMAT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Format.cpp) -set(CLICKHOUSE_FORMAT_LINK PRIVATE dbms clickhouse_common_io clickhouse_parsers ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#set(CLICKHOUSE_FORMAT_INCLUDE SYSTEM PRIVATE ...) +set (CLICKHOUSE_FORMAT_SOURCES Format.cpp) + +set (CLICKHOUSE_FORMAT_LINK + PRIVATE + boost::program_options + clickhouse_common_io + clickhouse_parsers + dbms +) clickhouse_program_add(format) diff --git a/programs/format/Format.cpp b/programs/format/Format.cpp index b5a4e2d1603..daf2d671568 100644 --- a/programs/format/Format.cpp +++ b/programs/format/Format.cpp @@ -21,6 +21,7 @@ int mainEntryClickHouseFormat(int argc, char ** argv) ("hilite", "add syntax highlight with ANSI terminal escape sequences") ("oneline", "format in single line") ("quiet,q", "just check syntax, no output on success") + ("multiquery,n", "allow multiple queries in the same file") ; boost::program_options::variables_map options; @@ -38,6 +39,7 @@ int mainEntryClickHouseFormat(int argc, char ** argv) bool hilite = options.count("hilite"); bool oneline = options.count("oneline"); bool quiet = options.count("quiet"); + bool multiple = options.count("multiquery"); if (quiet && (hilite || oneline)) { @@ -53,13 +55,17 @@ int mainEntryClickHouseFormat(int argc, char ** argv) const char * end = pos + query.size(); ParserQuery parser(end); - ASTPtr res = parseQuery(parser, pos, end, "query", 0, DBMS_DEFAULT_MAX_PARSER_DEPTH); - - if (!quiet) + do { - formatAST(*res, std::cout, hilite, oneline); - std::cout << std::endl; - } + ASTPtr res = parseQueryAndMovePosition(parser, pos, end, "query", multiple, 0, DBMS_DEFAULT_MAX_PARSER_DEPTH); + if (!quiet) + { + formatAST(*res, std::cout, hilite, oneline); + if (multiple) + std::cout << "\n;\n"; + std::cout << std::endl; + } + } while (multiple && pos != end); } catch (...) { diff --git a/programs/local/CMakeLists.txt b/programs/local/CMakeLists.txt index d066fd53277..b61f0ea33b7 100644 --- a/programs/local/CMakeLists.txt +++ b/programs/local/CMakeLists.txt @@ -1,6 +1,17 @@ -set(CLICKHOUSE_LOCAL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/LocalServer.cpp) -set(CLICKHOUSE_LOCAL_LINK PRIVATE clickhouse_storages_system clickhouse_dictionaries clickhouse_common_config clickhouse_common_io clickhouse_functions clickhouse_aggregate_functions clickhouse_parsers clickhouse_table_functions ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#set(CLICKHOUSE_LOCAL_INCLUDE SYSTEM PRIVATE ...) +set (CLICKHOUSE_LOCAL_SOURCES LocalServer.cpp) + +set (CLICKHOUSE_LOCAL_LINK + PRIVATE + boost::program_options + clickhouse_aggregate_functions + clickhouse_common_config + clickhouse_common_io + clickhouse_dictionaries + clickhouse_functions + clickhouse_parsers + clickhouse_storages_system + clickhouse_table_functions +) clickhouse_program_add(local) diff --git a/programs/local/LocalServer.cpp b/programs/local/LocalServer.cpp index d2d19a395bb..8ce03ac0867 100644 --- a/programs/local/LocalServer.cpp +++ b/programs/local/LocalServer.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -119,13 +118,13 @@ void LocalServer::tryInitPath() } -static void attachSystemTables() +static void attachSystemTables(const Context & context) { DatabasePtr system_database = DatabaseCatalog::instance().tryGetDatabase(DatabaseCatalog::SYSTEM_DATABASE); if (!system_database) { /// TODO: add attachTableDelayed into DatabaseMemory to speedup loading - system_database = std::make_shared(DatabaseCatalog::SYSTEM_DATABASE); + system_database = std::make_shared(DatabaseCatalog::SYSTEM_DATABASE, context); DatabaseCatalog::instance().attachDatabase(DatabaseCatalog::SYSTEM_DATABASE, system_database); } @@ -136,7 +135,7 @@ static void attachSystemTables() int LocalServer::main(const std::vector & /*args*/) try { - Logger * log = &logger(); + Poco::Logger * log = &logger(); ThreadStatus thread_status; UseSSL use_ssl; @@ -203,7 +202,7 @@ try * if such tables will not be dropped, clickhouse-server will not be able to load them due to security reasons. */ std::string default_database = config().getString("default_database", "_local"); - DatabaseCatalog::instance().attachDatabase(default_database, std::make_shared(default_database)); + DatabaseCatalog::instance().attachDatabase(default_database, std::make_shared(default_database, *context)); context->setCurrentDatabase(default_database); applyCmdOptions(); @@ -212,16 +211,16 @@ try /// Lock path directory before read status.emplace(context->getPath() + "status"); - LOG_DEBUG(log, "Loading metadata from " << context->getPath()); + LOG_DEBUG(log, "Loading metadata from {}", context->getPath()); loadMetadataSystem(*context); - attachSystemTables(); + attachSystemTables(*context); loadMetadata(*context); DatabaseCatalog::instance().loadDatabases(); LOG_DEBUG(log, "Loaded metadata."); } else { - attachSystemTables(); + attachSystemTables(*context); } processQueries(); @@ -279,7 +278,7 @@ void LocalServer::processQueries() context->makeSessionContext(); context->makeQueryContext(); - context->setUser("default", "", Poco::Net::SocketAddress{}, ""); + context->setUser("default", "", Poco::Net::SocketAddress{}); context->setCurrentQueryId(""); applyCmdSettings(); diff --git a/programs/local/LocalServer.h b/programs/local/LocalServer.h index 77d0b9ff5dc..5733bbc1a7c 100644 --- a/programs/local/LocalServer.h +++ b/programs/local/LocalServer.h @@ -4,13 +4,12 @@ #include #include #include +#include namespace DB { -class Context; - /// Lightweight Application for clickhouse-local /// No networking, no extra configs and working directories, no pid and status files, no dictionaries, no logging. /// Quiet mode by default diff --git a/programs/main.cpp b/programs/main.cpp index 3c16fb64a57..382a104b798 100644 --- a/programs/main.cpp +++ b/programs/main.cpp @@ -8,14 +8,8 @@ #include #include /// pair -#if __has_include("config_tools.h") -#include "config_tools.h" -#endif -#if __has_include() /// "Arcadia" build system lacks configure files. -#include -#endif -#if __has_include("config_core.h") -#include "config_core.h" +#if !defined(ARCADIA_BUILD) +# include "config_tools.h" #endif #include @@ -25,31 +19,31 @@ /// Universal executable for various clickhouse applications -#if ENABLE_CLICKHOUSE_SERVER || !defined(ENABLE_CLICKHOUSE_SERVER) +#if ENABLE_CLICKHOUSE_SERVER int mainEntryClickHouseServer(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_CLIENT || !defined(ENABLE_CLICKHOUSE_CLIENT) +#if ENABLE_CLICKHOUSE_CLIENT int mainEntryClickHouseClient(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_LOCAL || !defined(ENABLE_CLICKHOUSE_LOCAL) +#if ENABLE_CLICKHOUSE_LOCAL int mainEntryClickHouseLocal(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_BENCHMARK || !defined(ENABLE_CLICKHOUSE_BENCHMARK) +#if ENABLE_CLICKHOUSE_BENCHMARK int mainEntryClickHouseBenchmark(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG || !defined(ENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG) +#if ENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG int mainEntryClickHouseExtractFromConfig(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_COMPRESSOR || !defined(ENABLE_CLICKHOUSE_COMPRESSOR) +#if ENABLE_CLICKHOUSE_COMPRESSOR int mainEntryClickHouseCompressor(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_FORMAT || !defined(ENABLE_CLICKHOUSE_FORMAT) +#if ENABLE_CLICKHOUSE_FORMAT int mainEntryClickHouseFormat(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_COPIER || !defined(ENABLE_CLICKHOUSE_COPIER) +#if ENABLE_CLICKHOUSE_COPIER int mainEntryClickHouseClusterCopier(int argc, char ** argv); #endif -#if ENABLE_CLICKHOUSE_OBFUSCATOR || !defined(ENABLE_CLICKHOUSE_OBFUSCATOR) +#if ENABLE_CLICKHOUSE_OBFUSCATOR int mainEntryClickHouseObfuscator(int argc, char ** argv); #endif @@ -63,31 +57,31 @@ using MainFunc = int (*)(int, char**); /// Add an item here to register new application std::pair clickhouse_applications[] = { -#if ENABLE_CLICKHOUSE_LOCAL || !defined(ENABLE_CLICKHOUSE_LOCAL) +#if ENABLE_CLICKHOUSE_LOCAL {"local", mainEntryClickHouseLocal}, #endif -#if ENABLE_CLICKHOUSE_CLIENT || !defined(ENABLE_CLICKHOUSE_CLIENT) +#if ENABLE_CLICKHOUSE_CLIENT {"client", mainEntryClickHouseClient}, #endif -#if ENABLE_CLICKHOUSE_BENCHMARK || !defined(ENABLE_CLICKHOUSE_BENCHMARK) +#if ENABLE_CLICKHOUSE_BENCHMARK {"benchmark", mainEntryClickHouseBenchmark}, #endif -#if ENABLE_CLICKHOUSE_SERVER || !defined(ENABLE_CLICKHOUSE_SERVER) +#if ENABLE_CLICKHOUSE_SERVER {"server", mainEntryClickHouseServer}, #endif -#if ENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG || !defined(ENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG) +#if ENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG {"extract-from-config", mainEntryClickHouseExtractFromConfig}, #endif -#if ENABLE_CLICKHOUSE_COMPRESSOR || !defined(ENABLE_CLICKHOUSE_COMPRESSOR) +#if ENABLE_CLICKHOUSE_COMPRESSOR {"compressor", mainEntryClickHouseCompressor}, #endif -#if ENABLE_CLICKHOUSE_FORMAT || !defined(ENABLE_CLICKHOUSE_FORMAT) +#if ENABLE_CLICKHOUSE_FORMAT {"format", mainEntryClickHouseFormat}, #endif -#if ENABLE_CLICKHOUSE_COPIER || !defined(ENABLE_CLICKHOUSE_COPIER) +#if ENABLE_CLICKHOUSE_COPIER {"copier", mainEntryClickHouseClusterCopier}, #endif -#if ENABLE_CLICKHOUSE_OBFUSCATOR || !defined(ENABLE_CLICKHOUSE_OBFUSCATOR) +#if ENABLE_CLICKHOUSE_OBFUSCATOR {"obfuscator", mainEntryClickHouseObfuscator}, #endif }; @@ -130,9 +124,10 @@ enum class InstructionFail SSSE3 = 2, SSE4_1 = 3, SSE4_2 = 4, - AVX = 5, - AVX2 = 6, - AVX512 = 7 + POPCNT = 5, + AVX = 6, + AVX2 = 7, + AVX512 = 8 }; const char * instructionFailToString(InstructionFail fail) @@ -149,6 +144,8 @@ const char * instructionFailToString(InstructionFail fail) return "SSE4.1"; case InstructionFail::SSE4_2: return "SSE4.2"; + case InstructionFail::POPCNT: + return "POPCNT"; case InstructionFail::AVX: return "AVX"; case InstructionFail::AVX2: @@ -192,6 +189,16 @@ void checkRequiredInstructionsImpl(volatile InstructionFail & fail) __asm__ volatile ("pcmpgtq %%xmm0, %%xmm0" : : : "xmm0"); #endif + /// Defined by -msse4.2 +#if defined(__POPCNT__) + fail = InstructionFail::POPCNT; + { + uint64_t a = 0; + uint64_t b = 0; + __asm__ volatile ("popcnt %1, %0" : "=r"(a) :"r"(b) :); + } +#endif + #if defined(__AVX__) fail = InstructionFail::AVX; __asm__ volatile ("vaddpd %%ymm0, %%ymm0, %%ymm0" : : : "ymm0"); diff --git a/programs/obfuscator/CMakeLists.txt b/programs/obfuscator/CMakeLists.txt index 19dba2be95c..d1179b3718c 100644 --- a/programs/obfuscator/CMakeLists.txt +++ b/programs/obfuscator/CMakeLists.txt @@ -1,5 +1,9 @@ -set(CLICKHOUSE_OBFUSCATOR_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Obfuscator.cpp) -set(CLICKHOUSE_OBFUSCATOR_LINK PRIVATE dbms ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#set(CLICKHOUSE_OBFUSCATOR_INCLUDE SYSTEM PRIVATE ...) +set (CLICKHOUSE_OBFUSCATOR_SOURCES Obfuscator.cpp) + +set (CLICKHOUSE_OBFUSCATOR_LINK + PRIVATE + boost::program_options + dbms +) clickhouse_program_add(obfuscator) diff --git a/programs/obfuscator/Obfuscator.cpp b/programs/obfuscator/Obfuscator.cpp index 9a80dc8d035..f3ac0549573 100644 --- a/programs/obfuscator/Obfuscator.cpp +++ b/programs/obfuscator/Obfuscator.cpp @@ -858,7 +858,7 @@ public: ColumnPtr new_nested_column = nested_model->generate(nested_column); - return ColumnArray::create((*std::move(new_nested_column)).mutate(), (*std::move(column_array.getOffsetsPtr())).mutate()); + return ColumnArray::create(IColumn::mutate(std::move(new_nested_column)), IColumn::mutate(std::move(column_array.getOffsetsPtr()))); } void updateSeed() override @@ -896,7 +896,7 @@ public: ColumnPtr new_nested_column = nested_model->generate(nested_column); - return ColumnNullable::create((*std::move(new_nested_column)).mutate(), (*std::move(column_nullable.getNullMapColumnPtr())).mutate()); + return ColumnNullable::create(IColumn::mutate(std::move(new_nested_column)), IColumn::mutate(std::move(column_nullable.getNullMapColumnPtr()))); } void updateSeed() override @@ -937,10 +937,10 @@ public: if (typeid_cast(&data_type)) return std::make_unique(seed); - if (auto type = typeid_cast(&data_type)) + if (const auto * type = typeid_cast(&data_type)) return std::make_unique(get(*type->getNestedType(), seed, markov_model_params)); - if (auto type = typeid_cast(&data_type)) + if (const auto * type = typeid_cast(&data_type)) return std::make_unique(get(*type->getNestedType(), seed, markov_model_params)); throw Exception("Unsupported data type", ErrorCodes::NOT_IMPLEMENTED); diff --git a/programs/odbc-bridge/CMakeLists.txt b/programs/odbc-bridge/CMakeLists.txt index 7bb128902e0..ab8d94f2a0c 100644 --- a/programs/odbc-bridge/CMakeLists.txt +++ b/programs/odbc-bridge/CMakeLists.txt @@ -1,39 +1,25 @@ -set(CLICKHOUSE_ODBC_BRIDGE_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/ColumnInfoHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/getIdentifierQuote.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HandlerFactory.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/IdentifierQuoteHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MainHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ODBCBlockInputStream.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ODBCBridge.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PingHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/validateODBCConnectionString.cpp +set (CLICKHOUSE_ODBC_BRIDGE_SOURCES + ColumnInfoHandler.cpp + getIdentifierQuote.cpp + HandlerFactory.cpp + IdentifierQuoteHandler.cpp + MainHandler.cpp + ODBCBlockInputStream.cpp + ODBCBlockOutputStream.cpp + ODBCBridge.cpp + PingHandler.cpp + validateODBCConnectionString.cpp ) -set(CLICKHOUSE_ODBC_BRIDGE_LINK PRIVATE dbms clickhouse_parsers PUBLIC daemon) -set(CLICKHOUSE_ODBC_BRIDGE_INCLUDE PUBLIC ${ClickHouse_SOURCE_DIR}/base) - -if (USE_POCO_SQLODBC) - set(CLICKHOUSE_ODBC_BRIDGE_LINK ${CLICKHOUSE_ODBC_BRIDGE_LINK} PRIVATE ${Poco_SQLODBC_LIBRARY}) - # Wouldnt work anyway because of the way list variable got expanded in `target_include_directories` - # set(CLICKHOUSE_ODBC_BRIDGE_INCLUDE ${CLICKHOUSE_ODBC_BRIDGE_INCLUDE} SYSTEM PRIVATE ${ODBC_INCLUDE_DIRS} ${Poco_SQLODBC_INCLUDE_DIR}) -endif () -if (Poco_SQL_FOUND) - set(CLICKHOUSE_ODBC_BRIDGE_LINK ${CLICKHOUSE_ODBC_BRIDGE_LINK} PRIVATE ${Poco_SQL_LIBRARY}) - # Wouldnt work anyway because of the way list variable got expanded in `target_include_directories` - # set(CLICKHOUSE_ODBC_BRIDGE_INCLUDE ${CLICKHOUSE_ODBC_BRIDGE_INCLUDE} SYSTEM PRIVATE ${Poco_SQL_INCLUDE_DIR}) -endif () - -if (USE_POCO_DATAODBC) - set(CLICKHOUSE_ODBC_BRIDGE_LINK ${CLICKHOUSE_ODBC_BRIDGE_LINK} PRIVATE ${Poco_DataODBC_LIBRARY}) - # Wouldnt work anyway because of the way list variable got expanded in `target_include_directories` - # set(CLICKHOUSE_ODBC_BRIDGE_INCLUDE ${CLICKHOUSE_ODBC_BRIDGE_INCLUDE} SYSTEM PRIVATE ${ODBC_INCLUDE_DIRS} ${Poco_DataODBC_INCLUDE_DIR}) -endif() -if (Poco_Data_FOUND) - set(CLICKHOUSE_ODBC_BRIDGE_LINK ${CLICKHOUSE_ODBC_BRIDGE_LINK} PRIVATE ${Poco_Data_LIBRARY}) - # Wouldnt work anyway because of the way list variable got expanded in `target_include_directories` - # set(CLICKHOUSE_ODBC_BRIDGE_INCLUDE ${CLICKHOUSE_ODBC_BRIDGE_INCLUDE} SYSTEM PRIVATE ${Poco_Data_INCLUDE_DIR}) -endif () +set (CLICKHOUSE_ODBC_BRIDGE_LINK + PRIVATE + clickhouse_parsers + daemon + dbms + Poco::Data + PUBLIC + Poco::Data::ODBC +) clickhouse_program_add_library(odbc-bridge) diff --git a/programs/odbc-bridge/ColumnInfoHandler.cpp b/programs/odbc-bridge/ColumnInfoHandler.cpp index c5fb149284b..33723b4cc8e 100644 --- a/programs/odbc-bridge/ColumnInfoHandler.cpp +++ b/programs/odbc-bridge/ColumnInfoHandler.cpp @@ -1,33 +1,27 @@ #include "ColumnInfoHandler.h" -#include "getIdentifierQuote.h" -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC -#if USE_POCO_SQLODBC -#include -#include -#include -#define POCO_SQL_ODBC_CLASS Poco::SQL::ODBC -#endif -#if USE_POCO_DATAODBC -#include -#include -#include -#define POCO_SQL_ODBC_CLASS Poco::Data::ODBC -#endif +#if USE_ODBC -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "validateODBCConnectionString.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include "getIdentifierQuote.h" +# include "validateODBCConnectionString.h" + +# define POCO_SQL_ODBC_CLASS Poco::Data::ODBC namespace DB { @@ -65,15 +59,10 @@ namespace } } -namespace ErrorCodes -{ - extern const int ILLEGAL_TYPE_OF_ARGUMENT; -} - void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) { Poco::Net::HTMLForm params(request, request.stream()); - LOG_TRACE(log, "Request URI: " + request.getURI()); + LOG_TRACE(log, "Request URI: {}", request.getURI()); auto process_error = [&response, this](const std::string & message) { @@ -100,11 +89,11 @@ void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & reques if (params.has("schema")) { schema_name = params.get("schema"); - LOG_TRACE(log, "Will fetch info for table '" << schema_name + "." + table_name << "'"); + LOG_TRACE(log, "Will fetch info for table '{}'", schema_name + "." + table_name); } else - LOG_TRACE(log, "Will fetch info for table '" << table_name << "'"); - LOG_TRACE(log, "Got connection str '" << connection_string << "'"); + LOG_TRACE(log, "Will fetch info for table '{}'", table_name); + LOG_TRACE(log, "Got connection str '{}'", connection_string); try { @@ -123,7 +112,7 @@ void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & reques const auto & context_settings = context.getSettingsRef(); /// TODO Why not do SQLColumns instead? - std::string name = schema_name.empty() ? table_name : schema_name + "." + table_name; + std::string name = schema_name.empty() ? backQuoteIfNeed(table_name) : backQuoteIfNeed(schema_name) + "." + backQuoteIfNeed(table_name); std::stringstream ss; std::string input = "SELECT * FROM " + name + " WHERE 1 = 0"; ParserQueryWithOutput parser; @@ -131,21 +120,11 @@ void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & reques IAST::FormatSettings settings(ss, true); settings.always_quote_identifiers = true; - - auto identifier_quote = getIdentifierQuote(hdbc); - if (identifier_quote.length() == 0) - settings.identifier_quoting_style = IdentifierQuotingStyle::None; - else if (identifier_quote[0] == '`') - settings.identifier_quoting_style = IdentifierQuotingStyle::Backticks; - else if (identifier_quote[0] == '"') - settings.identifier_quoting_style = IdentifierQuotingStyle::DoubleQuotes; - else - throw Exception("Can not map quote identifier '" + identifier_quote + "' to IdentifierQuotingStyle value", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - + settings.identifier_quoting_style = getQuotingStyle(hdbc); select->format(settings); std::string query = ss.str(); - LOG_TRACE(log, "Inferring structure with query '" << query << "'"); + LOG_TRACE(log, "Inferring structure with query '{}'", query); if (POCO_SQL_ODBC_CLASS::Utility::isError(POCO_SQL_ODBC_CLASS::SQLPrepare(hstmt, reinterpret_cast(query.data()), query.size()))) throw POCO_SQL_ODBC_CLASS::DescriptorException(session.dbc()); @@ -189,5 +168,7 @@ void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & reques tryLogCurrentException(log); } } + } + #endif diff --git a/programs/odbc-bridge/ColumnInfoHandler.h b/programs/odbc-bridge/ColumnInfoHandler.h index e1a5ad33b32..04b4c06693b 100644 --- a/programs/odbc-bridge/ColumnInfoHandler.h +++ b/programs/odbc-bridge/ColumnInfoHandler.h @@ -1,16 +1,19 @@ #pragma once -#include -#include -#include -#include -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC +#if USE_ODBC + +# include +# include +# include +# include + /** The structure of the table is taken from the query "SELECT * FROM table WHERE 1=0". * TODO: It would be much better to utilize ODBC methods dedicated for columns description. * If there is no such table, an exception is thrown. */ namespace DB { + class ODBCColumnsInfoHandler : public Poco::Net::HTTPRequestHandler { public: @@ -26,5 +29,7 @@ private: size_t keep_alive_timeout; Context & context; }; + } + #endif diff --git a/programs/odbc-bridge/HandlerFactory.cpp b/programs/odbc-bridge/HandlerFactory.cpp index 55c2c8d7637..a02fcadea52 100644 --- a/programs/odbc-bridge/HandlerFactory.cpp +++ b/programs/odbc-bridge/HandlerFactory.cpp @@ -10,7 +10,7 @@ namespace DB Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & request) { Poco::URI uri{request.getURI()}; - LOG_TRACE(log, "Request URI: " + uri.toString()); + LOG_TRACE(log, "Request URI: {}", uri.toString()); if (uri.getPath() == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET) return new PingHandler(keep_alive_timeout); @@ -19,19 +19,21 @@ Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco: { if (uri.getPath() == "/columns_info") -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC +#if USE_ODBC return new ODBCColumnsInfoHandler(keep_alive_timeout, context); #else return nullptr; #endif else if (uri.getPath() == "/identifier_quote") -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC +#if USE_ODBC return new IdentifierQuoteHandler(keep_alive_timeout, context); #else return nullptr; #endif + else if (uri.getPath() == "/write") + return new ODBCHandler(pool_map, keep_alive_timeout, context, "write"); else - return new ODBCHandler(pool_map, keep_alive_timeout, context); + return new ODBCHandler(pool_map, keep_alive_timeout, context, "read"); } return nullptr; } diff --git a/programs/odbc-bridge/IdentifierQuoteHandler.cpp b/programs/odbc-bridge/IdentifierQuoteHandler.cpp index 303165a4d45..2c3701cfff9 100644 --- a/programs/odbc-bridge/IdentifierQuoteHandler.cpp +++ b/programs/odbc-bridge/IdentifierQuoteHandler.cpp @@ -1,38 +1,31 @@ #include "IdentifierQuoteHandler.h" -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC -#if USE_POCO_SQLODBC -#include -#include -#include -#define POCO_SQL_ODBC_CLASS Poco::SQL::ODBC -#endif -#if USE_POCO_DATAODBC -#include -#include -#include -#define POCO_SQL_ODBC_CLASS Poco::Data::ODBC -#endif +#if USE_ODBC -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "getIdentifierQuote.h" -#include "validateODBCConnectionString.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include "getIdentifierQuote.h" +# include "validateODBCConnectionString.h" + +# define POCO_SQL_ODBC_CLASS Poco::Data::ODBC namespace DB { void IdentifierQuoteHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) { Poco::Net::HTMLForm params(request, request.stream()); - LOG_TRACE(log, "Request URI: " + request.getURI()); + LOG_TRACE(log, "Request URI: {}", request.getURI()); auto process_error = [&response, this](const std::string & message) { @@ -65,5 +58,7 @@ void IdentifierQuoteHandler::handleRequest(Poco::Net::HTTPServerRequest & reques tryLogCurrentException(log); } } + } + #endif diff --git a/programs/odbc-bridge/IdentifierQuoteHandler.h b/programs/odbc-bridge/IdentifierQuoteHandler.h index 86230d8ad17..fd357e32786 100644 --- a/programs/odbc-bridge/IdentifierQuoteHandler.h +++ b/programs/odbc-bridge/IdentifierQuoteHandler.h @@ -1,14 +1,15 @@ #pragma once + #include #include #include -#include -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC -/** This handler establish connection to database, and retrieve quote style identifier - */ +#if USE_ODBC + +/// This handler establishes connection to database, and retrieve quote style identifier namespace DB { + class IdentifierQuoteHandler : public Poco::Net::HTTPRequestHandler { public: @@ -23,5 +24,7 @@ private: Poco::Logger * log; size_t keep_alive_timeout; }; + } + #endif diff --git a/programs/odbc-bridge/MainHandler.cpp b/programs/odbc-bridge/MainHandler.cpp index 15954c63e47..9bbffed3e23 100644 --- a/programs/odbc-bridge/MainHandler.cpp +++ b/programs/odbc-bridge/MainHandler.cpp @@ -5,17 +5,25 @@ #include #include #include "ODBCBlockInputStream.h" +#include "ODBCBlockOutputStream.h" #include #include #include #include -#include #include #include #include #include #include #include +#include +#include +#include "getIdentifierQuote.h" + +#if USE_ODBC +#include +#define POCO_SQL_ODBC_CLASS Poco::Data::ODBC +#endif namespace DB { @@ -63,34 +71,36 @@ ODBCHandler::PoolPtr ODBCHandler::getPool(const std::string & connection_str) return pool_map->at(connection_str); } +void ODBCHandler::processError(Poco::Net::HTTPServerResponse & response, const std::string & message) +{ + response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); + if (!response.sent()) + response.send() << message << std::endl; + LOG_WARNING(log, message); +} + void ODBCHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) { - Poco::Net::HTMLForm params(request, request.stream()); - LOG_TRACE(log, "Request URI: " + request.getURI()); + Poco::Net::HTMLForm params(request); + if (mode == "read") + params.read(request.stream()); + LOG_TRACE(log, "Request URI: {}", request.getURI()); - auto process_error = [&response, this](const std::string & message) + if (mode == "read" && !params.has("query")) { - response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); - if (!response.sent()) - response.send() << message << std::endl; - LOG_WARNING(log, message); - }; - - if (!params.has("query")) - { - process_error("No 'query' in request body"); + processError(response, "No 'query' in request body"); return; } if (!params.has("columns")) { - process_error("No 'columns' in request URL"); + processError(response, "No 'columns' in request URL"); return; } if (!params.has("connection_string")) { - process_error("No 'connection_string' in request URL"); + processError(response, "No 'connection_string' in request URL"); return; } @@ -100,7 +110,7 @@ void ODBCHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne std::string max_block_size_str = params.get("max_block_size", ""); if (max_block_size_str.empty()) { - process_error("Empty max_block_size specified"); + processError(response, "Empty max_block_size specified"); return; } max_block_size = parse(max_block_size_str); @@ -114,33 +124,70 @@ void ODBCHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne } catch (const Exception & ex) { - process_error("Invalid 'columns' parameter in request body '" + ex.message() + "'"); + processError(response, "Invalid 'columns' parameter in request body '" + ex.message() + "'"); LOG_WARNING(log, ex.getStackTraceString()); return; } std::string format = params.get("format", "RowBinary"); - std::string query = params.get("query"); - LOG_TRACE(log, "Query: " << query); std::string connection_string = params.get("connection_string"); - LOG_TRACE(log, "Connection string: '" << connection_string << "'"); + LOG_TRACE(log, "Connection string: '{}'", connection_string); WriteBufferFromHTTPServerResponse out(request, response, keep_alive_timeout); + try { - BlockOutputStreamPtr writer = FormatFactory::instance().getOutput(format, out, *sample_block, context); - auto pool = getPool(connection_string); - ODBCBlockInputStream inp(pool->get(), query, *sample_block, max_block_size); - copyData(inp, *writer); + if (mode == "write") + { + if (!params.has("db_name")) + { + processError(response, "No 'db_name' in request URL"); + return; + } + if (!params.has("table_name")) + { + processError(response, "No 'table_name' in request URL"); + return; + } + std::string db_name = params.get("db_name"); + std::string table_name = params.get("table_name"); + LOG_TRACE(log, "DB name: '{}', table name: '{}'", db_name, table_name); + + auto quoting_style = IdentifierQuotingStyle::None; +#if USE_ODBC + POCO_SQL_ODBC_CLASS::SessionImpl session(validateODBCConnectionString(connection_string), DBMS_DEFAULT_CONNECT_TIMEOUT_SEC); + quoting_style = getQuotingStyle(session.dbc().handle()); +#endif + + auto pool = getPool(connection_string); + ReadBufferFromIStream read_buf(request.stream()); + BlockInputStreamPtr input_stream = FormatFactory::instance().getInput(format, read_buf, *sample_block, + context, max_block_size); + ODBCBlockOutputStream output_stream(pool->get(), db_name, table_name, *sample_block, quoting_style); + copyData(*input_stream, output_stream); + writeStringBinary("Ok.", out); + } + else + { + std::string query = params.get("query"); + LOG_TRACE(log, "Query: {}", query); + + BlockOutputStreamPtr writer = FormatFactory::instance().getOutput(format, out, *sample_block, context); + auto pool = getPool(connection_string); + ODBCBlockInputStream inp(pool->get(), query, *sample_block, max_block_size); + copyData(inp, *writer); + } } catch (...) { auto message = getCurrentExceptionMessage(true); response.setStatusAndReason( - Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); // can't call process_error, because of too soon response sending + Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); // can't call process_error, because of too soon response sending writeStringBinary(message, out); tryLogCurrentException(log); + } } + } diff --git a/programs/odbc-bridge/MainHandler.h b/programs/odbc-bridge/MainHandler.h index 806313fc9b2..ec5e6693a60 100644 --- a/programs/odbc-bridge/MainHandler.h +++ b/programs/odbc-bridge/MainHandler.h @@ -24,11 +24,13 @@ public: ODBCHandler(std::shared_ptr pool_map_, size_t keep_alive_timeout_, - Context & context_) + Context & context_, + const String & mode_) : log(&Poco::Logger::get("ODBCHandler")) , pool_map(pool_map_) , keep_alive_timeout(keep_alive_timeout_) , context(context_) + , mode(mode_) { } @@ -40,10 +42,12 @@ private: std::shared_ptr pool_map; size_t keep_alive_timeout; Context & context; + String mode; static inline std::mutex mutex; PoolPtr getPool(const std::string & connection_str); + void processError(Poco::Net::HTTPServerResponse & response, const std::string & message); }; } diff --git a/programs/odbc-bridge/ODBCBlockInputStream.cpp b/programs/odbc-bridge/ODBCBlockInputStream.cpp index 6ada6dd3a2d..1316ff8f4c6 100644 --- a/programs/odbc-bridge/ODBCBlockInputStream.cpp +++ b/programs/odbc-bridge/ODBCBlockInputStream.cpp @@ -25,7 +25,7 @@ ODBCBlockInputStream::ODBCBlockInputStream( , result{statement} , iterator{result.begin()} , max_block_size{max_block_size_} - , log(&Logger::get("ODBCBlockInputStream")) + , log(&Poco::Logger::get("ODBCBlockInputStream")) { if (sample_block.columns() != result.columnCount()) throw Exception{"RecordSet contains " + toString(result.columnCount()) + " columns while " + toString(sample_block.columns()) diff --git a/programs/odbc-bridge/ODBCBlockOutputStream.cpp b/programs/odbc-bridge/ODBCBlockOutputStream.cpp new file mode 100644 index 00000000000..b5bffc58c55 --- /dev/null +++ b/programs/odbc-bridge/ODBCBlockOutputStream.cpp @@ -0,0 +1,133 @@ +#include "ODBCBlockOutputStream.h" + +#include +#include +#include +#include +#include +#include +#include +#include "getIdentifierQuote.h" + + +namespace DB +{ + +namespace +{ + using ValueType = ExternalResultDescription::ValueType; + + std::string getInsertQuery(const std::string & db_name, const std::string & table_name, const ColumnsWithTypeAndName & columns, IdentifierQuotingStyle quoting) + { + ASTInsertQuery query; + query.table_id.database_name = db_name; + query.table_id.table_name = table_name; + query.columns = std::make_shared(','); + query.children.push_back(query.columns); + for (const auto & column : columns) + query.columns->children.emplace_back(std::make_shared(column.name)); + + std::stringstream ss; + IAST::FormatSettings settings(ss, true); + settings.always_quote_identifiers = true; + settings.identifier_quoting_style = quoting; + query.IAST::format(settings); + return ss.str(); + } + + std::string getQuestionMarks(size_t n) + { + std::string result = "("; + for (size_t i = 0; i < n; ++i) + { + if (i > 0) + result += ","; + result += "?"; + } + return result + ")"; + } + + Poco::Dynamic::Var getVarFromField(const Field & field, const ValueType type) + { + switch (type) + { + case ValueType::vtUInt8: + return Poco::Dynamic::Var(static_cast(field.get())).convert(); + case ValueType::vtUInt16: + return Poco::Dynamic::Var(static_cast(field.get())).convert(); + case ValueType::vtUInt32: + return Poco::Dynamic::Var(static_cast(field.get())).convert(); + case ValueType::vtUInt64: + return Poco::Dynamic::Var(field.get()).convert(); + case ValueType::vtInt8: + return Poco::Dynamic::Var(static_cast(field.get())).convert(); + case ValueType::vtInt16: + return Poco::Dynamic::Var(static_cast(field.get())).convert(); + case ValueType::vtInt32: + return Poco::Dynamic::Var(static_cast(field.get())).convert(); + case ValueType::vtInt64: + return Poco::Dynamic::Var(field.get()).convert(); + case ValueType::vtFloat32: + return Poco::Dynamic::Var(field.get()).convert(); + case ValueType::vtFloat64: + return Poco::Dynamic::Var(field.get()).convert(); + case ValueType::vtString: + return Poco::Dynamic::Var(field.get()).convert(); + case ValueType::vtDate: + return Poco::Dynamic::Var(LocalDate(DayNum(field.get())).toString()).convert(); + case ValueType::vtDateTime: + return Poco::Dynamic::Var(std::to_string(LocalDateTime(time_t(field.get())))).convert(); + case ValueType::vtUUID: + return Poco::Dynamic::Var(UUID(field.get()).toUnderType().toHexString()).convert(); + } + __builtin_unreachable(); + } +} + +ODBCBlockOutputStream::ODBCBlockOutputStream(Poco::Data::Session && session_, + const std::string & remote_database_name_, + const std::string & remote_table_name_, + const Block & sample_block_, + IdentifierQuotingStyle quoting_) + : session(session_) + , db_name(remote_database_name_) + , table_name(remote_table_name_) + , sample_block(sample_block_) + , quoting(quoting_) + , log(&Poco::Logger::get("ODBCBlockOutputStream")) +{ + description.init(sample_block); +} + +Block ODBCBlockOutputStream::getHeader() const +{ + return sample_block; +} + +void ODBCBlockOutputStream::write(const Block & block) +{ + ColumnsWithTypeAndName columns; + for (size_t i = 0; i < block.columns(); ++i) + columns.push_back({block.getColumns()[i], sample_block.getDataTypes()[i], sample_block.getNames()[i]}); + + std::vector row_to_insert(block.columns()); + Poco::Data::Statement statement(session << getInsertQuery(db_name, table_name, columns, quoting) + getQuestionMarks(block.columns())); + for (size_t i = 0; i < block.columns(); ++i) + statement.addBind(Poco::Data::Keywords::use(row_to_insert[i])); + + for (size_t i = 0; i < block.rows(); ++i) + { + for (size_t col_idx = 0; col_idx < block.columns(); ++col_idx) + { + Field val; + columns[col_idx].column->get(i, val); + if (val.isNull()) + row_to_insert[col_idx] = Poco::Dynamic::Var(); + else + row_to_insert[col_idx] = getVarFromField(val, description.types[col_idx].first); + } + statement.execute(); + } +} + +} diff --git a/programs/odbc-bridge/ODBCBlockOutputStream.h b/programs/odbc-bridge/ODBCBlockOutputStream.h new file mode 100644 index 00000000000..39e1d6f77ac --- /dev/null +++ b/programs/odbc-bridge/ODBCBlockOutputStream.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace DB +{ +class ODBCBlockOutputStream : public IBlockOutputStream +{ +public: + ODBCBlockOutputStream(Poco::Data::Session && session_, const std::string & remote_database_name_, + const std::string & remote_table_name_, const Block & sample_block_, IdentifierQuotingStyle quoting); + + Block getHeader() const override; + void write(const Block & block) override; + +private: + Poco::Data::Session session; + std::string db_name; + std::string table_name; + Block sample_block; + IdentifierQuotingStyle quoting; + + ExternalResultDescription description; + Poco::Logger * log; +}; + +} diff --git a/programs/odbc-bridge/ODBCBridge.cpp b/programs/odbc-bridge/ODBCBridge.cpp index 1cfba4b3aa8..3f119fbf7ba 100644 --- a/programs/odbc-bridge/ODBCBridge.cpp +++ b/programs/odbc-bridge/ODBCBridge.cpp @@ -6,10 +6,9 @@ #include #include -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC -// It doesn't make much sense to build this bridge without ODBC, but we -// still do this. -#include +#if USE_ODBC +// It doesn't make much sense to build this bridge without ODBC, but we still do this. +# include #endif #include @@ -49,12 +48,7 @@ namespace #endif ) { - LOG_ERROR(log, - "Cannot resolve listen_host (" << host << "), error " << e.code() << ": " << e.message() - << ". " - "If it is an IPv6 address and your host has disabled IPv6, then consider to " - "specify IPv4 address to listen in element of configuration " - "file. Example: 0.0.0.0"); + LOG_ERROR(log, "Cannot resolve listen_host ({}), error {}: {}. If it is an IPv6 address and your host has disabled IPv6, then consider to specify IPv4 address to listen in element of configuration file. Example: 0.0.0.0", host, e.code(), e.message()); } throw; @@ -147,7 +141,7 @@ void ODBCBridge::initialize(Application & self) initializeTerminationAndSignalProcessing(); -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC +#if USE_ODBC // It doesn't make much sense to build this bridge without ODBC, but we // still do this. Poco::Data::ODBC::Connector::registerConnector(); @@ -189,7 +183,7 @@ int ODBCBridge::main(const std::vector & /*args*/) new HandlerFactory("ODBCRequestHandlerFactory-factory", keep_alive_timeout, context), server_pool, socket, http_params); server.start(); - LOG_INFO(log, "Listening http://" + address.toString()); + LOG_INFO(log, "Listening http://{}", address.toString()); SCOPE_EXIT({ LOG_DEBUG(log, "Received termination signal."); @@ -199,7 +193,7 @@ int ODBCBridge::main(const std::vector & /*args*/) { if (server.currentConnections() == 0) break; - LOG_DEBUG(log, "Waiting for " << server.currentConnections() << " connections, try " << count); + LOG_DEBUG(log, "Waiting for {} connections, try {}", server.currentConnections(), count); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } }); diff --git a/programs/odbc-bridge/getIdentifierQuote.cpp b/programs/odbc-bridge/getIdentifierQuote.cpp index 9ac0a56bfc6..15b3749d37d 100644 --- a/programs/odbc-bridge/getIdentifierQuote.cpp +++ b/programs/odbc-bridge/getIdentifierQuote.cpp @@ -1,22 +1,22 @@ #include "getIdentifierQuote.h" -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC -#if USE_POCO_SQLODBC -#include -#include -#include -#define POCO_SQL_ODBC_CLASS Poco::SQL::ODBC -#endif -#if USE_POCO_DATAODBC -#include -#include -#include -#define POCO_SQL_ODBC_CLASS Poco::Data::ODBC -#endif +#if USE_ODBC + +# include +# include +# include + +# define POCO_SQL_ODBC_CLASS Poco::Data::ODBC namespace DB { + +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + std::string getIdentifierQuote(SQLHDBC hdbc) { std::string identifier; @@ -40,5 +40,20 @@ std::string getIdentifierQuote(SQLHDBC hdbc) } return identifier; } + +IdentifierQuotingStyle getQuotingStyle(SQLHDBC hdbc) +{ + auto identifier_quote = getIdentifierQuote(hdbc); + if (identifier_quote.length() == 0) + return IdentifierQuotingStyle::None; + else if (identifier_quote[0] == '`') + return IdentifierQuotingStyle::Backticks; + else if (identifier_quote[0] == '"') + return IdentifierQuotingStyle::DoubleQuotes; + else + throw Exception("Can not map quote identifier '" + identifier_quote + "' to IdentifierQuotingStyle value", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } + +} + #endif diff --git a/programs/odbc-bridge/getIdentifierQuote.h b/programs/odbc-bridge/getIdentifierQuote.h index 30371b4060d..0fb4c3bddb1 100644 --- a/programs/odbc-bridge/getIdentifierQuote.h +++ b/programs/odbc-bridge/getIdentifierQuote.h @@ -1,22 +1,22 @@ #pragma once -#include -#include -#include -#include +#if USE_ODBC -#if USE_POCO_SQLODBC || USE_POCO_DATAODBC +# include +# include +# include -#if USE_POCO_SQLODBC -#include -#endif -#if USE_POCO_DATAODBC -#include -#endif +# include + +#include namespace DB { std::string getIdentifierQuote(SQLHDBC hdbc); + +IdentifierQuotingStyle getQuotingStyle(SQLHDBC hdbc); + } + #endif diff --git a/programs/server/CMakeLists.txt b/programs/server/CMakeLists.txt index a252310cc93..1563f5ac51e 100644 --- a/programs/server/CMakeLists.txt +++ b/programs/server/CMakeLists.txt @@ -1,27 +1,24 @@ set(CLICKHOUSE_SERVER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/HTTPHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HTTPHandlerFactory.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/InterserverIOHTTPHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MetricsTransmitter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/NotFoundHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PrometheusMetricsWriter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PrometheusRequestHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ReplicasStatusHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/StaticRequestHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Server.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/TCPHandler.cpp + MetricsTransmitter.cpp + Server.cpp ) -set(CLICKHOUSE_SERVER_SOURCES - ${CLICKHOUSE_SERVER_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/MySQLHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MySQLHandlerFactory.cpp -) +set (CLICKHOUSE_SERVER_LINK + PRIVATE + clickhouse_aggregate_functions + clickhouse_common_config + clickhouse_common_io + clickhouse_common_zookeeper + clickhouse_dictionaries + clickhouse_functions + clickhouse_parsers + clickhouse_storages_system + clickhouse_table_functions + string_utils -set(CLICKHOUSE_SERVER_LINK PRIVATE clickhouse_dictionaries clickhouse_common_io clickhouse_common_config clickhouse_common_zookeeper clickhouse_parsers string_utils PUBLIC daemon PRIVATE clickhouse_storages_system clickhouse_functions clickhouse_aggregate_functions clickhouse_table_functions ${Poco_Net_LIBRARY}) -if (USE_POCO_NETSSL) - set(CLICKHOUSE_SERVER_LINK ${CLICKHOUSE_SERVER_LINK} PRIVATE ${Poco_NetSSL_LIBRARY} ${Poco_Crypto_LIBRARY}) -endif () + PUBLIC + daemon +) clickhouse_program_add(server) diff --git a/programs/server/HTTPHandlerFactory.cpp b/programs/server/HTTPHandlerFactory.cpp deleted file mode 100644 index 91cf9ddf25b..00000000000 --- a/programs/server/HTTPHandlerFactory.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include "HTTPHandlerFactory.h" - -#include -#include -#include -#include - -#include "HTTPHandler.h" -#include "NotFoundHandler.h" -#include "StaticRequestHandler.h" -#include "ReplicasStatusHandler.h" -#include "InterserverIOHTTPHandler.h" -#include "PrometheusRequestHandler.h" - - -namespace DB -{ - -namespace ErrorCodes -{ - extern const int LOGICAL_ERROR; - extern const int UNKNOWN_ELEMENT_IN_CONFIG; - extern const int INVALID_CONFIG_PARAMETER; -} - -HTTPRequestHandlerFactoryMain::HTTPRequestHandlerFactoryMain(const std::string & name_) - : log(&Logger::get(name_)), name(name_) -{ -} - -Poco::Net::HTTPRequestHandler * HTTPRequestHandlerFactoryMain::createRequestHandler(const Poco::Net::HTTPServerRequest & request) // override -{ - LOG_TRACE(log, "HTTP Request for " << name << ". " - << "Method: " << request.getMethod() - << ", Address: " << request.clientAddress().toString() - << ", User-Agent: " << (request.has("User-Agent") ? request.get("User-Agent") : "none") - << (request.hasContentLength() ? (", Length: " + std::to_string(request.getContentLength())) : ("")) - << ", Content Type: " << request.getContentType() - << ", Transfer Encoding: " << request.getTransferEncoding()); - - for (auto & handler_factory : child_factories) - { - auto handler = handler_factory->createRequestHandler(request); - if (handler != nullptr) - return handler; - } - - if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET - || request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD - || request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST) - { - return new NotFoundHandler; - } - - return nullptr; -} - -HTTPRequestHandlerFactoryMain::~HTTPRequestHandlerFactoryMain() -{ - while (!child_factories.empty()) - { - delete child_factories.back(); - child_factories.pop_back(); - } -} - -HTTPRequestHandlerFactoryMain::TThis * HTTPRequestHandlerFactoryMain::addHandler(Poco::Net::HTTPRequestHandlerFactory * child_factory) -{ - child_factories.emplace_back(child_factory); - return this; -} - -static inline auto createHandlersFactoryFromConfig(IServer & server, const std::string & name, const String & prefix) -{ - auto main_handler_factory = new HTTPRequestHandlerFactoryMain(name); - - try - { - Poco::Util::AbstractConfiguration::Keys keys; - server.config().keys(prefix, keys); - - for (const auto & key : keys) - { - if (!startsWith(key, "rule")) - throw Exception("Unknown element in config: " + prefix + "." + key + ", must be 'rule'", ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG); - - const auto & handler_type = server.config().getString(prefix + "." + key + ".handler.type", ""); - - if (handler_type == "static") - main_handler_factory->addHandler(createStaticHandlerFactory(server, prefix + "." + key)); - else if (handler_type == "dynamic_query_handler") - main_handler_factory->addHandler(createDynamicHandlerFactory(server, prefix + "." + key)); - else if (handler_type == "predefined_query_handler") - main_handler_factory->addHandler(createPredefinedHandlerFactory(server, prefix + "." + key)); - else if (handler_type.empty()) - throw Exception("Handler type in config is not specified here: " + - prefix + "." + key + ".handler.type", ErrorCodes::INVALID_CONFIG_PARAMETER); - else - throw Exception("Unknown handler type '" + handler_type +"' in config here: " + - prefix + "." + key + ".handler.type",ErrorCodes::INVALID_CONFIG_PARAMETER); - } - - return main_handler_factory; - } - catch (...) - { - delete main_handler_factory; - throw; - } -} - -static const auto ping_response_expression = "Ok.\n"; -static const auto root_response_expression = "config://http_server_default_response"; - -static inline Poco::Net::HTTPRequestHandlerFactory * createHTTPHandlerFactory(IServer & server, const std::string & name, AsynchronousMetrics & async_metrics) -{ - if (server.config().has("http_handlers")) - return createHandlersFactoryFromConfig(server, name, "http_handlers"); - else - { - auto factory = (new HTTPRequestHandlerFactoryMain(name)) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server, root_response_expression)) - ->attachStrictPath("/")->allowGetAndHeadRequest()) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server, ping_response_expression)) - ->attachStrictPath("/ping")->allowGetAndHeadRequest()) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server)) - ->attachNonStrictPath("/replicas_status")->allowGetAndHeadRequest()) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server, "query"))->allowPostAndGetParamsRequest()); - - if (server.config().has("prometheus") && server.config().getInt("prometheus.port", 0) == 0) - factory->addHandler((new HandlingRuleHTTPHandlerFactory( - server, PrometheusMetricsWriter(server.config(), "prometheus", async_metrics))) - ->attachStrictPath(server.config().getString("prometheus.endpoint", "/metrics"))->allowGetAndHeadRequest()); - - return factory; - } -} - -static inline Poco::Net::HTTPRequestHandlerFactory * createInterserverHTTPHandlerFactory(IServer & server, const std::string & name) -{ - return (new HTTPRequestHandlerFactoryMain(name)) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server, root_response_expression)) - ->attachStrictPath("/")->allowGetAndHeadRequest()) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server, ping_response_expression)) - ->attachStrictPath("/ping")->allowGetAndHeadRequest()) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server)) - ->attachNonStrictPath("/replicas_status")->allowGetAndHeadRequest()) - ->addHandler((new HandlingRuleHTTPHandlerFactory(server))->allowPostAndGetParamsRequest()); -} - -Poco::Net::HTTPRequestHandlerFactory * createHandlerFactory(IServer & server, AsynchronousMetrics & async_metrics, const std::string & name) -{ - if (name == "HTTPHandler-factory" || name == "HTTPSHandler-factory") - return createHTTPHandlerFactory(server, name, async_metrics); - else if (name == "InterserverIOHTTPHandler-factory" || name == "InterserverIOHTTPSHandler-factory") - return createInterserverHTTPHandlerFactory(server, name); - else if (name == "PrometheusHandler-factory") - return (new HTTPRequestHandlerFactoryMain(name))->addHandler((new HandlingRuleHTTPHandlerFactory( - server, PrometheusMetricsWriter(server.config(), "prometheus", async_metrics))) - ->attachStrictPath(server.config().getString("prometheus.endpoint", "/metrics"))->allowGetAndHeadRequest()); - - throw Exception("LOGICAL ERROR: Unknown HTTP handler factory name.", ErrorCodes::LOGICAL_ERROR); -} - -} diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index bc444014a3c..9734bafe30e 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -53,18 +54,20 @@ #include #include #include -#include "HTTPHandlerFactory.h" +#include #include "MetricsTransmitter.h" #include -#include "TCPHandlerFactory.h" +#include #include #include -#include "MySQLHandlerFactory.h" +#include #if !defined(ARCADIA_BUILD) -# include -# include "config_core.h" -# include "Common/config_version.h" +# include "config_core.h" +# include "Common/config_version.h" +# if USE_OPENCL +# include "Common/BitonicSort.h" // Y_IGNORE +# endif #endif #if defined(OS_LINUX) @@ -72,7 +75,7 @@ # include #endif -#if USE_POCO_NETSSL +#if USE_SSL # include # include #endif @@ -87,9 +90,9 @@ namespace CurrentMetrics namespace { -void setupTmpPath(Logger * log, const std::string & path) +void setupTmpPath(Poco::Logger * log, const std::string & path) { - LOG_DEBUG(log, "Setting up " << path << " to store temporary data in it"); + LOG_DEBUG(log, "Setting up {} to store temporary data in it", path); Poco::File(path).createDirectories(); @@ -99,11 +102,11 @@ void setupTmpPath(Logger * log, const std::string & path) { if (it->isFile() && startsWith(it.name(), "tmp")) { - LOG_DEBUG(log, "Removing old temporary file " << it->path()); + LOG_DEBUG(log, "Removing old temporary file {}", it->path()); it->remove(); } else - LOG_DEBUG(log, "Skipped file in temporary path " << it->path()); + LOG_DEBUG(log, "Skipped file in temporary path {}", it->path()); } } @@ -123,6 +126,7 @@ namespace ErrorCodes extern const int FAILED_TO_GETPWUID; extern const int MISMATCHING_USERS_FOR_PROCESS_AND_DATA; extern const int NETWORK_ERROR; + extern const int UNKNOWN_ELEMENT_IN_CONFIG; } @@ -208,9 +212,55 @@ void Server::defineOptions(Poco::Util::OptionSet & options) BaseDaemon::defineOptions(options); } + +/// Check that there is no user-level settings at the top level in config. +/// This is a common source of mistake (user don't know where to write user-level setting). +void checkForUserSettingsAtTopLevel(const Poco::Util::AbstractConfiguration & config, const std::string & path) +{ + if (config.getBool("skip_check_for_incorrect_settings", false)) + return; + + Settings settings; + for (const auto & setting : settings) + { + std::string name = setting.getName().toString(); + if (config.has(name)) + { + throw Exception(fmt::format("A setting '{}' appeared at top level in config {}." + " But it is user-level setting that should be located in users.xml inside section for specific profile." + " You can add it to if you want to change default value of this setting." + " You can also disable the check - specify 1" + " in the main configuration file.", + name, path), + ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG); + } + } +} + +void checkForUsersNotInMainConfig( + const Poco::Util::AbstractConfiguration & config, + const std::string & config_path, + const std::string & users_config_path, + Poco::Logger * log) +{ + if (config.getBool("skip_check_for_incorrect_settings", false)) + return; + + if (config.has("users") || config.has("profiles") || config.has("quotas")) + { + /// We cannot throw exception here, because we have support for obsolete 'conf.d' directory + /// (that does not correspond to config.d or users.d) but substitute configuration to both of them. + + LOG_ERROR(log, "The , and elements should be located in users config file: {} not in main config {}." + " Also note that you should place configuration changes to the appropriate *.d directory like 'users.d'.", + users_config_path, config_path); + } +} + + int Server::main(const std::vector & /*args*/) { - Logger * log = &logger(); + Poco::Logger * log = &logger(); UseSSL use_ssl; ThreadStatus thread_status; @@ -222,12 +272,26 @@ int Server::main(const std::vector & /*args*/) registerDictionaries(); registerDisks(); +#if !defined(ARCADIA_BUILD) +#if USE_OPENCL + BitonicSort::getInstance().configure(); +#endif +#endif + CurrentMetrics::set(CurrentMetrics::Revision, ClickHouseRevision::get()); CurrentMetrics::set(CurrentMetrics::VersionInteger, ClickHouseRevision::getVersionInteger()); if (ThreadFuzzer::instance().isEffective()) LOG_WARNING(log, "ThreadFuzzer is enabled. Application will run slowly and unstable."); +#if !defined(NDEBUG) || !defined(__OPTIMIZE__) + LOG_WARNING(log, "Server was built in debug mode. It will work slowly."); +#endif + +#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) + LOG_WARNING(log, "Server was built with sanitizer. It will work slowly."); +#endif + /** Context contains all that query execution is dependent: * settings, available functions, data types, aggregate functions, databases... */ @@ -253,6 +317,8 @@ int Server::main(const std::vector & /*args*/) config().add(loaded_config.configuration.duplicate(), PRIO_DEFAULT, false); } + checkForUserSettingsAtTopLevel(config(), config_path); + const auto memory_amount = getMemoryAmount(); #if defined(OS_LINUX) @@ -268,7 +334,7 @@ int Server::main(const std::vector & /*args*/) { LOG_TRACE(log, "Will mlockall to prevent executable memory from being paged out. It may take a few seconds."); if (0 != mlockall(MCL_CURRENT)) - LOG_WARNING(log, "Failed mlockall: " + errnoToString(ErrorCodes::SYSTEM_ERROR)); + LOG_WARNING(log, "Failed mlockall: {}", errnoToString(ErrorCodes::SYSTEM_ERROR)); else LOG_TRACE(log, "The memory map of clickhouse executable has been mlock'ed"); } @@ -276,8 +342,8 @@ int Server::main(const std::vector & /*args*/) { LOG_INFO(log, "It looks like the process has no CAP_IPC_LOCK capability, binary mlock will be disabled." " It could happen due to incorrect ClickHouse package installation." - " You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep " << executable_path << "'." - " Note that it will not work on 'nosuid' mounted filesystems."); + " You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep {}'." + " Note that it will not work on 'nosuid' mounted filesystems.", executable_path); } } } @@ -341,7 +407,7 @@ int Server::main(const std::vector & /*args*/) if (rlim.rlim_cur == rlim.rlim_max) { - LOG_DEBUG(log, "rlimit on number of file descriptors is " << rlim.rlim_cur); + LOG_DEBUG(log, "rlimit on number of file descriptors is {}", rlim.rlim_cur); } else { @@ -349,12 +415,9 @@ int Server::main(const std::vector & /*args*/) rlim.rlim_cur = config().getUInt("max_open_files", rlim.rlim_max); int rc = setrlimit(RLIMIT_NOFILE, &rlim); if (rc != 0) - LOG_WARNING(log, - "Cannot set max number of file descriptors to " << rlim.rlim_cur - << ". Try to specify max_open_files according to your system limits. error: " - << strerror(errno)); + LOG_WARNING(log, "Cannot set max number of file descriptors to {}. Try to specify max_open_files according to your system limits. error: {}", rlim.rlim_cur, strerror(errno)); else - LOG_DEBUG(log, "Set max number of file descriptors to " << rlim.rlim_cur << " (was " << old << ")."); + LOG_DEBUG(log, "Set max number of file descriptors to {} (was {}).", rlim.rlim_cur, old); } } @@ -364,7 +427,7 @@ int Server::main(const std::vector & /*args*/) /// Initialize DateLUT early, to not interfere with running time of first query. LOG_DEBUG(log, "Initializing DateLUT."); DateLUT::instance(); - LOG_TRACE(log, "Initialized DateLUT with time zone '" << DateLUT::instance().getTimeZone() << "'."); + LOG_TRACE(log, "Initialized DateLUT with time zone '{}'.", DateLUT::instance().getTimeZone()); /// Storage with temporary data for processing of heavy queries. @@ -372,7 +435,7 @@ int Server::main(const std::vector & /*args*/) std::string tmp_path = config().getString("tmp_path", path + "tmp/"); std::string tmp_policy = config().getString("tmp_policy", ""); const VolumePtr & volume = global_context->setTemporaryStorage(tmp_path, tmp_policy); - for (const DiskPtr & disk : volume->disks) + for (const DiskPtr & disk : volume->getDisks()) setupTmpPath(log, disk->getPath()); } @@ -423,9 +486,8 @@ int Server::main(const std::vector & /*args*/) if (this_host.empty()) { this_host = getFQDNOrHostName(); - LOG_DEBUG(log, - "Configuration parameter '" + String(host_tag) + "' doesn't exist or exists and empty. Will use '" + this_host - + "' as replica host."); + LOG_DEBUG(log, "Configuration parameter '{}' doesn't exist or exists and empty. Will use '{}' as replica host.", + host_tag, this_host); } String port_str = config().getString(port_tag); @@ -461,13 +523,16 @@ int Server::main(const std::vector & /*args*/) SensitiveDataMasker::setInstance(std::make_unique(config(), "query_masking_rules")); } - auto main_config_reloader = std::make_unique(config_path, + auto main_config_reloader = std::make_unique( + config_path, include_from_path, config().getString("path", ""), std::move(main_config_zk_node_cache), main_config_zk_changed_event, [&](ConfigurationPtr config) { + checkForUserSettingsAtTopLevel(*config, config_path); + // FIXME logging-related things need synchronization -- see the 'Logger * log' saved // in a lot of places. For now, disable updating log configuration without server restart. //setTextLog(global_context->getTextLog()); @@ -496,12 +561,21 @@ int Server::main(const std::vector & /*args*/) if (Poco::File(config_dir + users_config_path).exists()) users_config_path = config_dir + users_config_path; } - auto users_config_reloader = std::make_unique(users_config_path, + + if (users_config_path != config_path) + checkForUsersNotInMainConfig(config(), config_path, users_config_path, log); + + auto users_config_reloader = std::make_unique( + users_config_path, include_from_path, config().getString("path", ""), zkutil::ZooKeeperNodeCache([&] { return global_context->getZooKeeper(); }), std::make_shared(), - [&](ConfigurationPtr config) { global_context->setUsersConfig(config); }, + [&](ConfigurationPtr config) + { + global_context->setUsersConfig(config); + checkForUserSettingsAtTopLevel(*config, users_config_path); + }, /* already_loaded = */ false); /// Reload config in SYSTEM RELOAD CONFIG query. @@ -530,8 +604,8 @@ int Server::main(const std::vector & /*args*/) if (uncompressed_cache_size > max_cache_size) { uncompressed_cache_size = max_cache_size; - LOG_INFO(log, "Uncompressed cache size was lowered to " << formatReadableSizeWithBinarySuffix(uncompressed_cache_size) - << " because the system has low amount of memory"); + LOG_INFO(log, "Uncompressed cache size was lowered to {} because the system has low amount of memory", + formatReadableSizeWithBinarySuffix(uncompressed_cache_size)); } global_context->setUncompressedCache(uncompressed_cache_size); @@ -546,8 +620,8 @@ int Server::main(const std::vector & /*args*/) if (mark_cache_size > max_cache_size) { mark_cache_size = max_cache_size; - LOG_INFO(log, "Mark cache size was lowered to " << formatReadableSizeWithBinarySuffix(uncompressed_cache_size) - << " because the system has low amount of memory"); + LOG_INFO(log, "Mark cache size was lowered to {} because the system has low amount of memory", + formatReadableSizeWithBinarySuffix(mark_cache_size)); } global_context->setMarkCache(mark_cache_size); @@ -571,20 +645,19 @@ int Server::main(const std::vector & /*args*/) if (max_server_memory_usage == 0) { max_server_memory_usage = default_max_server_memory_usage; - LOG_INFO(log, "Setting max_server_memory_usage was set to " << formatReadableSizeWithBinarySuffix(max_server_memory_usage)); + LOG_INFO(log, "Setting max_server_memory_usage was set to {}", formatReadableSizeWithBinarySuffix(max_server_memory_usage)); } else if (max_server_memory_usage > default_max_server_memory_usage) { max_server_memory_usage = default_max_server_memory_usage; - LOG_INFO(log, "Setting max_server_memory_usage was lowered to " << formatReadableSizeWithBinarySuffix(max_server_memory_usage) - << " because the system has low amount of memory"); + LOG_INFO(log, "Setting max_server_memory_usage was lowered to {} because the system has low amount of memory", formatReadableSizeWithBinarySuffix(max_server_memory_usage)); } total_memory_tracker.setOrRaiseHardLimit(max_server_memory_usage); total_memory_tracker.setDescription("(total)"); total_memory_tracker.setMetric(CurrentMetrics::MemoryTracking); - LOG_INFO(log, "Loading metadata from " + path); + LOG_INFO(log, "Loading metadata from {}", path); try { @@ -630,6 +703,12 @@ int Server::main(const std::vector & /*args*/) total_memory_tracker.setOrRaiseProfilerLimit(total_memory_profiler_step); total_memory_tracker.setProfilerStep(total_memory_profiler_step); } + + double total_memory_tracker_sample_probability = config().getDouble("total_memory_tracker_sample_probability", 0); + if (total_memory_tracker_sample_probability) + { + total_memory_tracker.setSampleProbability(total_memory_tracker_sample_probability); + } } #endif @@ -674,21 +753,25 @@ int Server::main(const std::vector & /*args*/) } #if defined(OS_LINUX) - if (!TaskStatsInfoGetter::checkPermissions()) + if (!TasksStatsCounters::checkIfAvailable()) { - LOG_INFO(log, "It looks like the process has no CAP_NET_ADMIN capability, 'taskstats' performance statistics will be disabled." + LOG_INFO(log, "It looks like this system does not have procfs mounted at /proc location," + " neither clickhouse-server process has CAP_NET_ADMIN capability." + " 'taskstats' performance statistics will be disabled." " It could happen due to incorrect ClickHouse package installation." - " You could resolve the problem manually with 'sudo setcap cap_net_admin=+ep " << executable_path << "'." + " You can try to resolve the problem manually with 'sudo setcap cap_net_admin=+ep {}'." " Note that it will not work on 'nosuid' mounted filesystems." - " It also doesn't work if you run clickhouse-server inside network namespace as it happens in some containers."); + " It also doesn't work if you run clickhouse-server inside network namespace as it happens in some containers.", + executable_path); } if (!hasLinuxCapability(CAP_SYS_NICE)) { LOG_INFO(log, "It looks like the process has no CAP_SYS_NICE capability, the setting 'os_thread_nice' will have no effect." " It could happen due to incorrect ClickHouse package installation." - " You could resolve the problem manually with 'sudo setcap cap_sys_nice=+ep " << executable_path << "'." - " Note that it will not work on 'nosuid' mounted filesystems."); + " You could resolve the problem manually with 'sudo setcap cap_sys_nice=+ep {}'." + " Note that it will not work on 'nosuid' mounted filesystems.", + executable_path); } #else LOG_INFO(log, "TaskStats is not implemented for this OS. IO accounting will be disabled."); @@ -730,11 +813,11 @@ int Server::main(const std::vector & /*args*/) #endif ) { - LOG_ERROR(log, - "Cannot resolve listen_host (" << host << "), error " << e.code() << ": " << e.message() << ". " + LOG_ERROR(log, "Cannot resolve listen_host ({}), error {}: {}. " "If it is an IPv6 address and your host has disabled IPv6, then consider to " "specify IPv4 address to listen in element of configuration " - "file. Example: 0.0.0.0"); + "file. Example: 0.0.0.0", + host, e.code(), e.message()); } throw; @@ -786,11 +869,11 @@ int Server::main(const std::vector & /*args*/) if (listen_try) { - LOG_ERROR(log, message - << ". If it is an IPv6 or IPv4 address and your host has disabled IPv6 or IPv4, then consider to " + LOG_ERROR(log, "{}. If it is an IPv6 or IPv4 address and your host has disabled IPv6 or IPv4, then consider to " "specify not disabled IPv4 or IPv6 address to listen in element of configuration " "file. Example for disabled IPv6: 0.0.0.0 ." - " Example for disabled IPv4: ::"); + " Example for disabled IPv4: ::", + message); } else { @@ -810,13 +893,13 @@ int Server::main(const std::vector & /*args*/) servers.emplace_back(std::make_unique( createHandlerFactory(*this, async_metrics, "HTTPHandler-factory"), server_pool, socket, http_params)); - LOG_INFO(log, "Listening for http://" + address.toString()); + LOG_INFO(log, "Listening for http://{}", address.toString()); }); /// HTTPS create_server("https_port", [&](UInt16 port) { -#if USE_POCO_NETSSL +#if USE_SSL Poco::Net::SecureServerSocket socket; auto address = socket_bind_listen(socket, listen_host, port, /* secure = */ true); socket.setReceiveTimeout(settings.http_receive_timeout); @@ -824,7 +907,7 @@ int Server::main(const std::vector & /*args*/) servers.emplace_back(std::make_unique( createHandlerFactory(*this, async_metrics, "HTTPSHandler-factory"), server_pool, socket, http_params)); - LOG_INFO(log, "Listening for https://" + address.toString()); + LOG_INFO(log, "Listening for https://{}", address.toString()); #else UNUSED(port); throw Exception{"HTTPS protocol is disabled because Poco library was built without NetSSL support.", @@ -845,13 +928,13 @@ int Server::main(const std::vector & /*args*/) socket, new Poco::Net::TCPServerParams)); - LOG_INFO(log, "Listening for connections with native protocol (tcp): " + address.toString()); + LOG_INFO(log, "Listening for connections with native protocol (tcp): {}", address.toString()); }); /// TCP with SSL create_server("tcp_port_secure", [&](UInt16 port) { -#if USE_POCO_NETSSL +#if USE_SSL Poco::Net::SecureServerSocket socket; auto address = socket_bind_listen(socket, listen_host, port, /* secure = */ true); socket.setReceiveTimeout(settings.receive_timeout); @@ -861,7 +944,7 @@ int Server::main(const std::vector & /*args*/) server_pool, socket, new Poco::Net::TCPServerParams)); - LOG_INFO(log, "Listening for connections with secure native protocol (tcp_secure): " + address.toString()); + LOG_INFO(log, "Listening for connections with secure native protocol (tcp_secure): {}", address.toString()); #else UNUSED(port); throw Exception{"SSL support for TCP protocol is disabled because Poco library was built without NetSSL support.", @@ -879,12 +962,12 @@ int Server::main(const std::vector & /*args*/) servers.emplace_back(std::make_unique( createHandlerFactory(*this, async_metrics, "InterserverIOHTTPHandler-factory"), server_pool, socket, http_params)); - LOG_INFO(log, "Listening for replica communication (interserver): http://" + address.toString()); + LOG_INFO(log, "Listening for replica communication (interserver): http://{}", address.toString()); }); create_server("interserver_https_port", [&](UInt16 port) { -#if USE_POCO_NETSSL +#if USE_SSL Poco::Net::SecureServerSocket socket; auto address = socket_bind_listen(socket, listen_host, port, /* secure = */ true); socket.setReceiveTimeout(settings.http_receive_timeout); @@ -892,7 +975,7 @@ int Server::main(const std::vector & /*args*/) servers.emplace_back(std::make_unique( createHandlerFactory(*this, async_metrics, "InterserverIOHTTPSHandler-factory"), server_pool, socket, http_params)); - LOG_INFO(log, "Listening for secure replica communication (interserver): https://" + address.toString()); + LOG_INFO(log, "Listening for secure replica communication (interserver): https://{}", address.toString()); #else UNUSED(port); throw Exception{"SSL support for TCP protocol is disabled because Poco library was built without NetSSL support.", @@ -912,7 +995,7 @@ int Server::main(const std::vector & /*args*/) socket, new Poco::Net::TCPServerParams)); - LOG_INFO(log, "Listening for MySQL compatibility protocol: " + address.toString()); + LOG_INFO(log, "Listening for MySQL compatibility protocol: {}", address.toString()); }); /// Prometheus (if defined and not setup yet with http_port) @@ -925,7 +1008,7 @@ int Server::main(const std::vector & /*args*/) servers.emplace_back(std::make_unique( createHandlerFactory(*this, async_metrics, "PrometheusHandler-factory"), server_pool, socket, http_params)); - LOG_INFO(log, "Listening for Prometheus: http://" + address.toString()); + LOG_INFO(log, "Listening for Prometheus: http://{}", address.toString()); }); } @@ -950,12 +1033,10 @@ int Server::main(const std::vector & /*args*/) dns_cache_updater->start(); { - std::stringstream message; - message << "Available RAM: " << formatReadableSizeWithBinarySuffix(memory_amount) << ";" - << " physical cores: " << getNumberOfPhysicalCPUCores() << ";" - // on ARM processors it can show only enabled at current moment cores - << " logical cores: " << std::thread::hardware_concurrency() << "."; - LOG_INFO(log, message.str()); + LOG_INFO(log, "Available RAM: {}; physical cores: {}; logical cores: {}.", + formatReadableSizeWithBinarySuffix(memory_amount), + getNumberOfPhysicalCPUCores(), // on ARM processors it can show only enabled at current moment cores + std::thread::hardware_concurrency()); } LOG_INFO(log, "Ready for connections."); @@ -973,9 +1054,10 @@ int Server::main(const std::vector & /*args*/) current_connections += server->currentConnections(); } - LOG_INFO(log, - "Closed all listening sockets." - << (current_connections ? " Waiting for " + toString(current_connections) + " outstanding connections." : "")); + if (current_connections) + LOG_INFO(log, "Closed all listening sockets. Waiting for {} outstanding connections.", current_connections); + else + LOG_INFO(log, "Closed all listening sockets."); /// Killing remaining queries. global_context->getProcessList().killAllQueries(); @@ -997,9 +1079,11 @@ int Server::main(const std::vector & /*args*/) } } - LOG_INFO( - log, "Closed connections." << (current_connections ? " But " + toString(current_connections) + " remains." - " Tip: To increase wait time add to config: 60" : "")); + if (current_connections) + LOG_INFO(log, "Closed connections. But {} remain." + " Tip: To increase wait time add to config: 60", current_connections); + else + LOG_INFO(log, "Closed connections."); dns_cache_updater.reset(); main_config_reloader.reset(); diff --git a/programs/server/Server.h b/programs/server/Server.h index ffd89df6af4..ad9e51c881c 100644 --- a/programs/server/Server.h +++ b/programs/server/Server.h @@ -1,6 +1,6 @@ #pragma once -#include "IServer.h" +#include #include diff --git a/programs/server/config.xml b/programs/server/config.xml index 58c6a77395b..0ceba85593a 100644 --- a/programs/server/config.xml +++ b/programs/server/config.xml @@ -1,6 +1,9 @@ @@ -139,10 +142,18 @@ 4194304 + + 0 + @@ -183,7 +194,7 @@ /var/lib/clickhouse/access/ - + users.xml @@ -219,7 +230,7 @@ and to prevent clickhouse executable from being paged out under high IO load. Enabling this option is recommended but will lead to increased startup time for up to a few seconds. --> - false + true + + localhost 9000 @@ -468,6 +481,20 @@ 1000 + + + system + asynchronous_metric_log
+ + 60000 +
+ diff --git a/programs/server/users.d/access_management.xml b/programs/server/users.d/access_management.xml new file mode 100644 index 00000000000..7e799cb7b10 --- /dev/null +++ b/programs/server/users.d/access_management.xml @@ -0,0 +1,7 @@ + + + + 1 + + + diff --git a/programs/server/users.d/allow_introspection_functions.xml b/programs/server/users.d/allow_introspection_functions.xml new file mode 100644 index 00000000000..b94e95bc043 --- /dev/null +++ b/programs/server/users.d/allow_introspection_functions.xml @@ -0,0 +1,8 @@ + + + + + 1 + + + diff --git a/programs/server/ya.make b/programs/server/ya.make index 2c74c01c7cb..2e13267f715 100644 --- a/programs/server/ya.make +++ b/programs/server/ya.make @@ -11,19 +11,8 @@ PEERDIR( SRCS( clickhouse-server.cpp - HTTPHandler.cpp - HTTPHandlerFactory.cpp - InterserverIOHTTPHandler.cpp MetricsTransmitter.cpp - MySQLHandler.cpp - MySQLHandlerFactory.cpp - NotFoundHandler.cpp - PrometheusMetricsWriter.cpp - PrometheusRequestHandler.cpp - ReplicasStatusHandler.cpp - StaticRequestHandler.cpp Server.cpp - TCPHandler.cpp ) END() diff --git a/programs/ya.make b/programs/ya.make index 6c773c312b8..f4a61850212 100644 --- a/programs/ya.make +++ b/programs/ya.make @@ -1,3 +1,27 @@ -RECURSE( - server +PROGRAM(clickhouse) + +CFLAGS( + -DENABLE_CLICKHOUSE_CLIENT + -DENABLE_CLICKHOUSE_EXTRACT_FROM_CONFIG + -DENABLE_CLICKHOUSE_SERVER ) + +PEERDIR( + clickhouse/base/daemon + clickhouse/base/loggers + clickhouse/programs/client/readpassphrase + clickhouse/src +) + +SRCS( + main.cpp + + client/Client.cpp + client/ConnectionParameters.cpp + client/Suggest.cpp + extract-from-config/ExtractFromConfig.cpp + server/Server.cpp + server/MetricsTransmitter.cpp +) + +END() diff --git a/release b/release index b5e3f05cd95..ec762b234fb 100755 --- a/release +++ b/release @@ -106,9 +106,8 @@ elif [[ $BUILD_TYPE == 'debug' ]]; then VERSION_POSTFIX+="+debug" fi -CMAKE_FLAGS=" $MALLOC_OPTS -DSANITIZE=$SANITIZER -DENABLE_EMBEDDED_COMPILER=1 $CMAKE_FLAGS" +CMAKE_FLAGS=" $MALLOC_OPTS -DSANITIZE=$SANITIZER $CMAKE_FLAGS" [[ -n "$CMAKE_BUILD_TYPE" ]] && CMAKE_FLAGS=" -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE $CMAKE_FLAGS" -#[[ "$CMAKE_FLAGS" =~ "USE_INTERNAL_LLVM_LIBRARY" ]] || CMAKE_FLAGS=" -DUSE_INTERNAL_LLVM_LIBRARY=1 $CMAKE_FLAGS" export CMAKE_FLAGS export EXTRAPACKAGES diff --git a/src/Access/AccessControlManager.cpp b/src/Access/AccessControlManager.cpp index f8f15e425ed..1c1215a0e28 100644 --- a/src/Access/AccessControlManager.cpp +++ b/src/Access/AccessControlManager.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ public: std::shared_ptr getContextAccess( const UUID & user_id, - const std::vector & current_roles, + const boost::container::flat_set & current_roles, bool use_default_roles, const Settings & settings, const String & current_database, @@ -113,7 +113,7 @@ void AccessControlManager::setDefaultProfileName(const String & default_profile_ std::shared_ptr AccessControlManager::getContextAccess( const UUID & user_id, - const std::vector & current_roles, + const boost::container::flat_set & current_roles, bool use_default_roles, const Settings & settings, const String & current_database, @@ -124,36 +124,36 @@ std::shared_ptr AccessControlManager::getContextAccess( std::shared_ptr AccessControlManager::getEnabledRoles( - const std::vector & current_roles, - const std::vector & current_roles_with_admin_option) const + const boost::container::flat_set & current_roles, + const boost::container::flat_set & current_roles_with_admin_option) const { return role_cache->getEnabledRoles(current_roles, current_roles_with_admin_option); } -std::shared_ptr AccessControlManager::getEnabledRowPolicies(const UUID & user_id, const std::vector & enabled_roles) const +std::shared_ptr AccessControlManager::getEnabledRowPolicies(const UUID & user_id, const boost::container::flat_set & enabled_roles) const { return row_policy_cache->getEnabledRowPolicies(user_id, enabled_roles); } std::shared_ptr AccessControlManager::getEnabledQuota( - const UUID & user_id, const String & user_name, const std::vector & enabled_roles, const Poco::Net::IPAddress & address, const String & custom_quota_key) const + const UUID & user_id, const String & user_name, const boost::container::flat_set & enabled_roles, const Poco::Net::IPAddress & address, const String & custom_quota_key) const { return quota_cache->getEnabledQuota(user_id, user_name, enabled_roles, address, custom_quota_key); } -std::vector AccessControlManager::getQuotaUsageInfo() const +std::vector AccessControlManager::getAllQuotasUsage() const { - return quota_cache->getUsageInfo(); + return quota_cache->getAllQuotasUsage(); } std::shared_ptr AccessControlManager::getEnabledSettings( const UUID & user_id, const SettingsProfileElements & settings_from_user, - const std::vector & enabled_roles, + const boost::container::flat_set & enabled_roles, const SettingsProfileElements & settings_from_enabled_roles) const { return settings_profiles_cache->getEnabledSettings(user_id, settings_from_user, enabled_roles, settings_from_enabled_roles); diff --git a/src/Access/AccessControlManager.h b/src/Access/AccessControlManager.h index 810970a8379..6bcf8d7c504 100644 --- a/src/Access/AccessControlManager.h +++ b/src/Access/AccessControlManager.h @@ -2,6 +2,7 @@ #include #include +#include #include @@ -28,7 +29,7 @@ class EnabledRowPolicies; class RowPolicyCache; class EnabledQuota; class QuotaCache; -struct QuotaUsageInfo; +struct QuotaUsage; struct SettingsProfile; using SettingsProfilePtr = std::shared_ptr; class EnabledSettings; @@ -51,32 +52,32 @@ public: std::shared_ptr getContextAccess( const UUID & user_id, - const std::vector & current_roles, + const boost::container::flat_set & current_roles, bool use_default_roles, const Settings & settings, const String & current_database, const ClientInfo & client_info) const; std::shared_ptr getEnabledRoles( - const std::vector & current_roles, - const std::vector & current_roles_with_admin_option) const; + const boost::container::flat_set & current_roles, + const boost::container::flat_set & current_roles_with_admin_option) const; std::shared_ptr getEnabledRowPolicies( const UUID & user_id, - const std::vector & enabled_roles) const; + const boost::container::flat_set & enabled_roles) const; std::shared_ptr getEnabledQuota( const UUID & user_id, const String & user_name, - const std::vector & enabled_roles, + const boost::container::flat_set & enabled_roles, const Poco::Net::IPAddress & address, const String & custom_quota_key) const; - std::vector getQuotaUsageInfo() const; + std::vector getAllQuotasUsage() const; std::shared_ptr getEnabledSettings(const UUID & user_id, const SettingsProfileElements & settings_from_user, - const std::vector & enabled_roles, + const boost::container::flat_set & enabled_roles, const SettingsProfileElements & settings_from_enabled_roles) const; std::shared_ptr getProfileSettings(const String & profile_name) const; diff --git a/src/Access/AccessFlags.h b/src/Access/AccessFlags.h index cbba295be1a..9b801fd88a3 100644 --- a/src/Access/AccessFlags.h +++ b/src/Access/AccessFlags.h @@ -61,12 +61,19 @@ public: friend bool operator ==(const AccessFlags & left, const AccessFlags & right) { return left.flags == right.flags; } friend bool operator !=(const AccessFlags & left, const AccessFlags & right) { return !(left == right); } + friend bool operator <(const AccessFlags & left, const AccessFlags & right) { return memcmp(&left.flags, &right.flags, sizeof(Flags)) < 0; } + friend bool operator >(const AccessFlags & left, const AccessFlags & right) { return right < left; } + friend bool operator <=(const AccessFlags & left, const AccessFlags & right) { return !(right < left); } + friend bool operator >=(const AccessFlags & left, const AccessFlags & right) { return !(left < right); } void clear() { flags.reset(); } /// Returns a comma-separated list of keywords, like "SELECT, CREATE USER, UPDATE". String toString() const; + /// Returns a list of access types. + std::vector toAccessTypes() const; + /// Returns a list of keywords. std::vector toKeywords() const; @@ -151,21 +158,27 @@ public: return res; } + std::vector flagsToAccessTypes(const Flags & flags_) const + { + std::vector access_types; + flagsToAccessTypesRec(flags_, access_types, *all_node); + return access_types; + } + std::vector flagsToKeywords(const Flags & flags_) const { std::vector keywords; - flagsToKeywordsRec(flags_, keywords, *flags_to_keyword_tree); - - if (keywords.empty()) - keywords.push_back("USAGE"); - + flagsToKeywordsRec(flags_, keywords, *all_node); return keywords; } String flagsToString(const Flags & flags_) const { + auto keywords = flagsToKeywords(flags_); + if (keywords.empty()) + return "USAGE"; String str; - for (const auto & keyword : flagsToKeywords(flags_)) + for (const auto & keyword : keywords) { if (!str.empty()) str += ", "; @@ -201,7 +214,7 @@ private: { const String keyword; NodeType node_type; - AccessType type = AccessType::NONE; + AccessType access_type = AccessType::NONE; Strings aliases; Flags flags; std::vector children; @@ -233,8 +246,8 @@ private: return aliases; } - static void makeFlagsToKeywordTreeNode( - AccessType type, + static void makeNode( + AccessType access_type, const std::string_view & name, const std::string_view & aliases, NodeType node_type, @@ -259,13 +272,13 @@ private: nodes[node->keyword] = node.get(); } - node->type = type; + node->access_type = access_type; node->node_type = node_type; node->aliases = splitAliases(aliases); if (node_type != GROUP) node->setFlag(next_flag++); - bool has_parent_group = (parent_group_name != "NONE"); + bool has_parent_group = (parent_group_name != std::string_view{"NONE"}); if (!has_parent_group) { std::string_view keyword_as_string_view = node->keyword; @@ -286,25 +299,25 @@ private: it_parent->second->addChild(std::move(node)); } - void makeFlagsToKeywordTree() + void makeNodes() { std::unordered_map owned_nodes; std::unordered_map nodes; size_t next_flag = 0; -#define MAKE_ACCESS_FLAGS_TO_KEYWORD_TREE_NODE(name, aliases, node_type, parent_group_name) \ - makeFlagsToKeywordTreeNode(AccessType::name, #name, aliases, node_type, #parent_group_name, nodes, owned_nodes, next_flag); +#define MAKE_ACCESS_FLAGS_NODE(name, aliases, node_type, parent_group_name) \ + makeNode(AccessType::name, #name, aliases, node_type, #parent_group_name, nodes, owned_nodes, next_flag); - APPLY_FOR_ACCESS_TYPES(MAKE_ACCESS_FLAGS_TO_KEYWORD_TREE_NODE) + APPLY_FOR_ACCESS_TYPES(MAKE_ACCESS_FLAGS_NODE) -#undef MAKE_ACCESS_FLAGS_TO_KEYWORD_TREE_NODE +#undef MAKE_ACCESS_FLAGS_NODE if (!owned_nodes.count("NONE")) throw Exception("'NONE' not declared", ErrorCodes::LOGICAL_ERROR); if (!owned_nodes.count("ALL")) throw Exception("'ALL' not declared", ErrorCodes::LOGICAL_ERROR); - flags_to_keyword_tree = std::move(owned_nodes["ALL"]); + all_node = std::move(owned_nodes["ALL"]); none_node = std::move(owned_nodes["NONE"]); owned_nodes.erase("ALL"); owned_nodes.erase("NONE"); @@ -324,7 +337,7 @@ private: if (!start_node) { makeKeywordToFlagsMap(none_node.get()); - start_node = flags_to_keyword_tree.get(); + start_node = all_node.get(); } start_node->aliases.emplace_back(start_node->keyword); @@ -343,10 +356,10 @@ private: if (!start_node) { makeAccessTypeToFlagsMapping(none_node.get()); - start_node = flags_to_keyword_tree.get(); + start_node = all_node.get(); } - size_t index = static_cast(start_node->type); + size_t index = static_cast(start_node->access_type); access_type_to_flags_mapping.resize(std::max(index + 1, access_type_to_flags_mapping.size())); access_type_to_flags_mapping[index] = start_node->flags; @@ -358,7 +371,7 @@ private: { if (!start_node) { - start_node = flags_to_keyword_tree.get(); + start_node = all_node.get(); all_flags = start_node->flags; } if (start_node->node_type != GROUP) @@ -372,12 +385,29 @@ private: Impl() { - makeFlagsToKeywordTree(); + makeNodes(); makeKeywordToFlagsMap(); makeAccessTypeToFlagsMapping(); collectAllFlags(); } + static void flagsToAccessTypesRec(const Flags & flags_, std::vector & access_types, const Node & start_node) + { + Flags matching_flags = (flags_ & start_node.flags); + if (matching_flags.any()) + { + if (matching_flags == start_node.flags) + { + access_types.push_back(start_node.access_type); + } + else + { + for (const auto & child : start_node.children) + flagsToAccessTypesRec(flags_, access_types, *child); + } + } + } + static void flagsToKeywordsRec(const Flags & flags_, std::vector & keywords, const Node & start_node) { Flags matching_flags = (flags_ & start_node.flags); @@ -395,7 +425,7 @@ private: } } - NodePtr flags_to_keyword_tree; + NodePtr all_node; NodePtr none_node; std::unordered_map keyword_to_flags_map; std::vector access_type_to_flags_mapping; @@ -409,6 +439,7 @@ inline AccessFlags::AccessFlags(const std::string_view & keyword) : flags(Impl<> inline AccessFlags::AccessFlags(const std::vector & keywords) : flags(Impl<>::instance().keywordsToFlags(keywords)) {} inline AccessFlags::AccessFlags(const Strings & keywords) : flags(Impl<>::instance().keywordsToFlags(keywords)) {} inline String AccessFlags::toString() const { return Impl<>::instance().flagsToString(flags); } +inline std::vector AccessFlags::toAccessTypes() const { return Impl<>::instance().flagsToAccessTypes(flags); } inline std::vector AccessFlags::toKeywords() const { return Impl<>::instance().flagsToKeywords(flags); } inline AccessFlags AccessFlags::allFlags() { return Impl<>::instance().getAllFlags(); } inline AccessFlags AccessFlags::allGlobalFlags() { return Impl<>::instance().getGlobalFlags(); } diff --git a/src/Access/AccessRights.cpp b/src/Access/AccessRights.cpp index 79d77e3f352..a4e446750a7 100644 --- a/src/Access/AccessRights.cpp +++ b/src/Access/AccessRights.cpp @@ -251,12 +251,11 @@ public: void logTree(Poco::Logger * log) const { - LOG_TRACE(log, "Tree(" << level << "): name=" << (node_name ? *node_name : "NULL") - << ", access=" << access.toString() - << ", final_access=" << final_access.toString() - << ", min_access=" << min_access.toString() - << ", max_access=" << max_access.toString() - << ", num_children=" << (children ? children->size() : 0)); + LOG_TRACE(log, "Tree({}): name={}, access={}, final_access={}, min_access={}, max_access={}, num_children={}", + level, node_name ? *node_name : "NULL", access.toString(), + final_access.toString(), min_access.toString(), max_access.toString(), + (children ? children->size() : 0)); + if (children) { for (auto & child : *children | boost::adaptors::map_values) @@ -606,69 +605,102 @@ void AccessRights::revoke(const AccessRightsElements & elements, std::string_vie } -AccessRights::Elements AccessRights::getElements() const +AccessRightsElements AccessRights::getGrants() const +{ + AccessRightsElements grants; + getGrantsAndPartialRevokesImpl(&grants, nullptr); + return grants; +} + +AccessRightsElements AccessRights::getPartialRevokes() const +{ + AccessRightsElements partial_revokes; + getGrantsAndPartialRevokesImpl(nullptr, &partial_revokes); + return partial_revokes; +} + +AccessRights::GrantsAndPartialRevokes AccessRights::getGrantsAndPartialRevokes() const +{ + GrantsAndPartialRevokes res; + getGrantsAndPartialRevokesImpl(&res.grants, &res.revokes); + return res; +} + + +void AccessRights::getGrantsAndPartialRevokesImpl(AccessRightsElements * out_grants, AccessRightsElements * out_partial_revokes) const { if (!root) - return {}; - Elements res; + return; auto global_access = root->access; - if (global_access) - res.grants.push_back({global_access}); + if (out_grants && global_access) + out_grants->push_back({global_access}); if (root->children) { for (const auto & [db_name, db_node] : *root->children) { - auto db_grants = db_node.access - global_access; - auto db_partial_revokes = global_access - db_node.access; - if (db_partial_revokes) - res.partial_revokes.push_back({db_partial_revokes, db_name}); - if (db_grants) - res.grants.push_back({db_grants, db_name}); + if (out_grants) + { + if (auto db_grants = db_node.access - global_access) + out_grants->push_back({db_grants, db_name}); + } + if (out_partial_revokes) + { + if (auto db_partial_revokes = global_access - db_node.access) + out_partial_revokes->push_back({db_partial_revokes, db_name}); + } if (db_node.children) { for (const auto & [table_name, table_node] : *db_node.children) { - auto table_grants = table_node.access - db_node.access; - auto table_partial_revokes = db_node.access - table_node.access; - if (table_partial_revokes) - res.partial_revokes.push_back({table_partial_revokes, db_name, table_name}); - if (table_grants) - res.grants.push_back({table_grants, db_name, table_name}); + if (out_grants) + { + if (auto table_grants = table_node.access - db_node.access) + out_grants->push_back({table_grants, db_name, table_name}); + } + if (out_partial_revokes) + { + if (auto table_partial_revokes = db_node.access - table_node.access) + out_partial_revokes->push_back({table_partial_revokes, db_name, table_name}); + } if (table_node.children) { for (const auto & [column_name, column_node] : *table_node.children) { - auto column_grants = column_node.access - table_node.access; - auto column_partial_revokes = table_node.access - column_node.access; - if (column_partial_revokes) - res.partial_revokes.push_back({column_partial_revokes, db_name, table_name, column_name}); - if (column_grants) - res.grants.push_back({column_grants, db_name, table_name, column_name}); + if (out_grants) + { + if (auto column_grants = column_node.access - table_node.access) + out_grants->push_back({column_grants, db_name, table_name, column_name}); + } + if (out_partial_revokes) + { + if (auto column_partial_revokes = table_node.access - column_node.access) + out_partial_revokes->push_back({column_partial_revokes, db_name, table_name, column_name}); + } } + } } } } } - return res; } String AccessRights::toString() const { - auto elements = getElements(); String res; - if (!elements.grants.empty()) + auto gr = getGrantsAndPartialRevokes(); + if (!gr.grants.empty()) { res += "GRANT "; - res += elements.grants.toString(); + res += gr.grants.toString(); } - if (!elements.partial_revokes.empty()) + if (!gr.revokes.empty()) { if (!res.empty()) res += ", "; res += "REVOKE "; - res += elements.partial_revokes.toString(); + res += gr.revokes.toString(); } if (res.empty()) res = "GRANT USAGE ON *.*"; diff --git a/src/Access/AccessRights.h b/src/Access/AccessRights.h index 133038f2d44..c32514e8feb 100644 --- a/src/Access/AccessRights.h +++ b/src/Access/AccessRights.h @@ -49,12 +49,14 @@ public: void revoke(const AccessRightsElements & elements, std::string_view current_database = {}); /// Returns the information about all the access granted. - struct Elements + struct GrantsAndPartialRevokes { AccessRightsElements grants; - AccessRightsElements partial_revokes; + AccessRightsElements revokes; }; - Elements getElements() const; + AccessRightsElements getGrants() const; + AccessRightsElements getPartialRevokes() const; + GrantsAndPartialRevokes getGrantsAndPartialRevokes() const; /// Returns the information about all the access granted as a string. String toString() const; @@ -92,6 +94,8 @@ private: template AccessFlags getAccessImpl(const Args &... args) const; + void getGrantsAndPartialRevokesImpl(AccessRightsElements * grants, AccessRightsElements * partial_revokes) const; + void logTree() const; struct Node; diff --git a/src/Access/AccessRightsElement.cpp b/src/Access/AccessRightsElement.cpp index 81237a334e2..db1ea5d3d5c 100644 --- a/src/Access/AccessRightsElement.cpp +++ b/src/Access/AccessRightsElement.cpp @@ -1,10 +1,124 @@ #include #include #include +#include +#include +#include +#include +#include namespace DB { +namespace +{ + size_t groupElements(AccessRightsElements & elements, size_t start) + { + auto & start_element = elements[start]; + auto it = std::find_if(elements.begin() + start + 1, elements.end(), + [&](const AccessRightsElement & element) + { + return (element.database != start_element.database) || + (element.any_database != start_element.any_database) || + (element.table != start_element.table) || + (element.any_table != start_element.any_table) || + (element.any_column != start_element.any_column); + }); + size_t end = it - elements.begin(); + + /// All the elements at indices from start to end here specify + /// the same database and table. + + if (start_element.any_column) + { + /// Easy case: the elements don't specify columns. + /// All we need is to combine the access flags. + for (size_t i = start + 1; i != end; ++i) + { + start_element.access_flags |= elements[i].access_flags; + elements[i].access_flags = {}; + } + return end; + } + + /// Difficult case: the elements specify columns. + /// We have to find groups of columns with common access flags. + for (size_t i = start; i != end; ++i) + { + if (!elements[i].access_flags) + continue; + + AccessFlags common_flags = elements[i].access_flags; + size_t num_elements_with_common_flags = 1; + for (size_t j = i + 1; j != end; ++j) + { + auto new_common_flags = common_flags & elements[j].access_flags; + if (new_common_flags) + { + common_flags = new_common_flags; + ++num_elements_with_common_flags; + } + } + + if (num_elements_with_common_flags == 1) + continue; + + if (elements[i].access_flags != common_flags) + { + elements.insert(elements.begin() + i + 1, elements[i]); + elements[i].access_flags = common_flags; + elements[i].columns.clear(); + ++end; + } + + for (size_t j = i + 1; j != end; ++j) + { + if ((elements[j].access_flags & common_flags) == common_flags) + { + boost::range::push_back(elements[i].columns, elements[j].columns); + elements[j].access_flags -= common_flags; + } + } + } + + return end; + } + + /// Tries to combine elements to decrease their number. + void groupElements(AccessRightsElements & elements) + { + if (!boost::range::is_sorted(elements)) + boost::range::sort(elements); /// Algorithm in groupElement() requires elements to be sorted. + for (size_t start = 0; start != elements.size();) + start = groupElements(elements, start); + } + + /// Removes unnecessary elements, sorts elements and makes them unique. + void sortElementsAndMakeUnique(AccessRightsElements & elements) + { + /// Remove empty elements. + boost::range::remove_erase_if(elements, [](const AccessRightsElement & element) + { + return !element.access_flags || (!element.any_column && element.columns.empty()); + }); + + /// Sort columns and make them unique. + for (auto & element : elements) + { + if (element.any_column) + continue; + + if (!boost::range::is_sorted(element.columns)) + boost::range::sort(element.columns); + element.columns.erase(std::unique(element.columns.begin(), element.columns.end()), element.columns.end()); + } + + /// Sort elements themselves. + boost::range::sort(elements); + elements.erase(std::unique(elements.begin(), elements.end()), elements.end()); + } +} + void AccessRightsElement::setDatabase(const String & new_database) { database = new_database; @@ -26,10 +140,29 @@ bool AccessRightsElement::isEmptyDatabase() const String AccessRightsElement::toString() const +{ + String msg = toStringWithoutON(); + msg += " ON "; + + if (any_database) + msg += "*."; + else if (!database.empty()) + msg += backQuoteIfNeed(database) + "."; + + if (any_table) + msg += "*"; + else + msg += backQuoteIfNeed(table); + return msg; +} + +String AccessRightsElement::toStringWithoutON() const { String columns_in_parentheses; if (!any_column) { + if (columns.empty()) + return "USAGE"; for (const auto & column : columns) { columns_in_parentheses += columns_in_parentheses.empty() ? "(" : ", "; @@ -38,25 +171,17 @@ String AccessRightsElement::toString() const columns_in_parentheses += ")"; } + auto keywords = access_flags.toKeywords(); + if (keywords.empty()) + return "USAGE"; + String msg; - for (const std::string_view & keyword : access_flags.toKeywords()) + for (const std::string_view & keyword : keywords) { if (!msg.empty()) msg += ", "; msg += String{keyword} + columns_in_parentheses; } - - msg += " ON "; - - if (any_database) - msg += "*."; - else if (!database.empty() && (database != IDictionary::NO_DATABASE_TAG)) - msg += backQuoteIfNeed(database) + "."; - - if (any_table) - msg += "*"; - else - msg += backQuoteIfNeed(table); return msg; } @@ -68,19 +193,41 @@ void AccessRightsElements::replaceEmptyDatabase(const String & new_database) } -String AccessRightsElements::toString() const +String AccessRightsElements::toString() { - String res; - bool need_comma = false; - for (const auto & element : *this) - { - if (std::exchange(need_comma, true)) - res += ", "; - res += element.toString(); - } + normalize(); - if (res.empty()) - res = "USAGE ON *.*"; - return res; + if (empty()) + return "USAGE ON *.*"; + + String msg; + bool need_comma = false; + for (size_t i = 0; i != size(); ++i) + { + const auto & element = (*this)[i]; + if (std::exchange(need_comma, true)) + msg += ", "; + bool next_element_on_same_db_and_table = false; + if (i != size() - 1) + { + const auto & next_element = (*this)[i + 1]; + if ((element.database == next_element.database) && (element.any_database == next_element.any_database) + && (element.table == next_element.table) && (element.any_table == next_element.any_table)) + next_element_on_same_db_and_table = true; + } + if (next_element_on_same_db_and_table) + msg += element.toStringWithoutON(); + else + msg += element.toString(); + } + return msg; } + + +void AccessRightsElements::normalize() +{ + groupElements(*this); + sortElementsAndMakeUnique(*this); +} + } diff --git a/src/Access/AccessRightsElement.h b/src/Access/AccessRightsElement.h index 3894b6f5157..70eb95c2d17 100644 --- a/src/Access/AccessRightsElement.h +++ b/src/Access/AccessRightsElement.h @@ -71,6 +71,14 @@ struct AccessRightsElement { } + auto toTuple() const { return std::tie(access_flags, database, any_database, table, any_table, columns, any_column); } + friend bool operator==(const AccessRightsElement & left, const AccessRightsElement & right) { return left.toTuple() == right.toTuple(); } + friend bool operator!=(const AccessRightsElement & left, const AccessRightsElement & right) { return left.toTuple() != right.toTuple(); } + friend bool operator<(const AccessRightsElement & left, const AccessRightsElement & right) { return left.toTuple() < right.toTuple(); } + friend bool operator>(const AccessRightsElement & left, const AccessRightsElement & right) { return left.toTuple() > right.toTuple(); } + friend bool operator<=(const AccessRightsElement & left, const AccessRightsElement & right) { return left.toTuple() <= right.toTuple(); } + friend bool operator>=(const AccessRightsElement & left, const AccessRightsElement & right) { return left.toTuple() >= right.toTuple(); } + /// Sets the database. void setDatabase(const String & new_database); @@ -82,6 +90,7 @@ struct AccessRightsElement /// Returns a human-readable representation like "SELECT, UPDATE(x, y) ON db.table". /// The returned string isn't prefixed with the "GRANT" keyword. String toString() const; + String toStringWithoutON() const; }; @@ -94,7 +103,11 @@ public: /// Returns a human-readable representation like "SELECT, UPDATE(x, y) ON db.table". /// The returned string isn't prefixed with the "GRANT" keyword. - String toString() const; + String toString() const { return AccessRightsElements(*this).toString(); } + String toString(); + + /// Reorder and group elements to show them in more readable form. + void normalize(); }; } diff --git a/src/Access/AccessType.h b/src/Access/AccessType.h index d0665a6e55f..c4fdbc46b71 100644 --- a/src/Access/AccessType.h +++ b/src/Access/AccessType.h @@ -167,50 +167,48 @@ enum class AccessType #undef DECLARE_ACCESS_TYPE_ENUM_CONST }; -std::string_view toString(AccessType type); - namespace impl { template - class AccessTypeToKeywordConverter + class AccessTypeToStringConverter { public: - static const AccessTypeToKeywordConverter & instance() + static const AccessTypeToStringConverter & instance() { - static const AccessTypeToKeywordConverter res; + static const AccessTypeToStringConverter res; return res; } std::string_view convert(AccessType type) const { - return access_type_to_keyword_mapping[static_cast(type)]; + return access_type_to_string_mapping[static_cast(type)]; } private: - AccessTypeToKeywordConverter() + AccessTypeToStringConverter() { -#define INSERT_ACCESS_TYPE_KEYWORD_PAIR_TO_MAPPING(name, aliases, node_type, parent_group_name) \ - insertToMapping(AccessType::name, #name); +#define ACCESS_TYPE_TO_STRING_CONVERTER_ADD_TO_MAPPING(name, aliases, node_type, parent_group_name) \ + addToMapping(AccessType::name, #name); - APPLY_FOR_ACCESS_TYPES(INSERT_ACCESS_TYPE_KEYWORD_PAIR_TO_MAPPING) + APPLY_FOR_ACCESS_TYPES(ACCESS_TYPE_TO_STRING_CONVERTER_ADD_TO_MAPPING) -#undef INSERT_ACCESS_TYPE_KEYWORD_PAIR_TO_MAPPING +#undef ACCESS_TYPE_TO_STRING_CONVERTER_ADD_TO_MAPPING } - void insertToMapping(AccessType type, const std::string_view & str) + void addToMapping(AccessType type, const std::string_view & str) { String str2{str}; boost::replace_all(str2, "_", " "); size_t index = static_cast(type); - access_type_to_keyword_mapping.resize(std::max(index + 1, access_type_to_keyword_mapping.size())); - access_type_to_keyword_mapping[index] = str2; + access_type_to_string_mapping.resize(std::max(index + 1, access_type_to_string_mapping.size())); + access_type_to_string_mapping[index] = str2; } - Strings access_type_to_keyword_mapping; + Strings access_type_to_string_mapping; }; } -inline std::string_view toKeyword(AccessType type) { return impl::AccessTypeToKeywordConverter<>::instance().convert(type); } +inline std::string_view toString(AccessType type) { return impl::AccessTypeToStringConverter<>::instance().convert(type); } } diff --git a/src/Access/AllowedClientHosts.cpp b/src/Access/AllowedClientHosts.cpp index 8ef2a868acc..1cee8a2f782 100644 --- a/src/Access/AllowedClientHosts.cpp +++ b/src/Access/AllowedClientHosts.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace DB @@ -44,61 +45,22 @@ namespace return IPSubnet(toIPv6(subnet.getPrefix()), subnet.getMask()); } - - /// Helper function for isAddressOfHost(). - bool isAddressOfHostImpl(const IPAddress & address, const String & host) - { - IPAddress addr_v6 = toIPv6(address); - - /// Resolve by hand, because Poco don't use AI_ALL flag but we need it. - addrinfo * ai_begin = nullptr; - SCOPE_EXIT( - { - if (ai_begin) - freeaddrinfo(ai_begin); - }); - - addrinfo hints; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_flags |= AI_V4MAPPED | AI_ALL; - - int err = getaddrinfo(host.c_str(), nullptr, &hints, &ai_begin); - if (err) - throw Exception("Cannot getaddrinfo(" + host + "): " + gai_strerror(err), ErrorCodes::DNS_ERROR); - - for (const addrinfo * ai = ai_begin; ai; ai = ai->ai_next) - { - if (ai->ai_addrlen && ai->ai_addr) - { - if (ai->ai_family == AF_INET) - { - const auto & sin = *reinterpret_cast(ai->ai_addr); - if (addr_v6 == toIPv6(IPAddress(&sin.sin_addr, sizeof(sin.sin_addr)))) - { - return true; - } - } - else if (ai->ai_family == AF_INET6) - { - const auto & sin = *reinterpret_cast(ai->ai_addr); - if (addr_v6 == IPAddress(&sin.sin6_addr, sizeof(sin.sin6_addr), sin.sin6_scope_id)) - { - return true; - } - } - } - } - - return false; - } - /// Whether a specified address is one of the addresses of a specified host. bool isAddressOfHost(const IPAddress & address, const String & host) { - /// We need to cache DNS requests. - static SimpleCache cache; - return cache(address, host); + IPAddress addr_v6 = toIPv6(address); + + auto host_addresses = DNSResolver::instance().resolveHostAll(host); + + for (const auto & addr : host_addresses) + { + if (addr.family() == IPAddress::Family::IPv4 && addr_v6 == toIPv6(addr)) + return true; + else if (addr.family() == IPAddress::Family::IPv6 && addr_v6 == addr) + return true; + } + + return false; } /// Helper function for isAddressOfLocalhost(). @@ -142,16 +104,10 @@ namespace return boost::range::find(local_addresses, toIPv6(address)) != local_addresses.end(); } - /// Helper function for getHostByAddress(). - String getHostByAddressImpl(const IPAddress & address) + /// Returns the host name by its address. + String getHostByAddress(const IPAddress & address) { - Poco::Net::SocketAddress sock_addr(address, 0); - - /// Resolve by hand, because Poco library doesn't have such functionality. - char host[1024]; - int err = getnameinfo(sock_addr.addr(), sock_addr.length(), host, sizeof(host), nullptr, 0, NI_NAMEREQD); - if (err) - throw Exception("Cannot getnameinfo(" + address.toString() + "): " + gai_strerror(err), ErrorCodes::DNS_ERROR); + String host = DNSResolver::instance().reverseResolve(address); /// Check that PTR record is resolved back to client address if (!isAddressOfHost(address, host)) @@ -160,14 +116,6 @@ namespace return host; } - /// Returns the host name by its address. - String getHostByAddress(const IPAddress & address) - { - /// We need to cache DNS requests. - static SimpleCache cache; - return cache(address); - } - void parseLikePatternIfIPSubnet(const String & pattern, IPSubnet & subnet, IPAddress::Family address_family) { @@ -299,9 +247,9 @@ bool AllowedClientHosts::contains(const IPAddress & client_address) const throw; /// Try to ignore DNS errors: if host cannot be resolved, skip it and try next. LOG_WARNING( - &Logger::get("AddressPatterns"), - "Failed to check if the allowed client hosts contain address " << client_address.toString() << ". " << e.displayText() - << ", code = " << e.code()); + &Poco::Logger::get("AddressPatterns"), + "Failed to check if the allowed client hosts contain address {}. {}, code = {}", + client_address.toString(), e.displayText(), e.code()); return false; } }; @@ -332,9 +280,9 @@ bool AllowedClientHosts::contains(const IPAddress & client_address) const throw; /// Try to ignore DNS errors: if host cannot be resolved, skip it and try next. LOG_WARNING( - &Logger::get("AddressPatterns"), - "Failed to check if the allowed client hosts contain address " << client_address.toString() << ". " << e.displayText() - << ", code = " << e.code()); + &Poco::Logger::get("AddressPatterns"), + "Failed to check if the allowed client hosts contain address {}. {}, code = {}", + client_address.toString(), e.displayText(), e.code()); return false; } }; diff --git a/src/Access/Authentication.cpp b/src/Access/Authentication.cpp index f435d6e6336..cb2c9e7a256 100644 --- a/src/Access/Authentication.cpp +++ b/src/Access/Authentication.cpp @@ -7,8 +7,8 @@ namespace DB { namespace ErrorCodes { - extern const int LOGICAL_ERROR; extern const int BAD_ARGUMENTS; + extern const int NOT_IMPLEMENTED; } @@ -36,8 +36,11 @@ Authentication::Digest Authentication::getPasswordDoubleSHA1() const case DOUBLE_SHA1_PASSWORD: return password_hash; + + case MAX_TYPE: + break; } - throw Exception("Unknown authentication type: " + std::to_string(static_cast(type)), ErrorCodes::LOGICAL_ERROR); + throw Exception("getPasswordDoubleSHA1(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED); } @@ -71,8 +74,11 @@ bool Authentication::isCorrectPassword(const String & password_) const return encodeSHA1(first_sha1) == password_hash; } + + case MAX_TYPE: + break; } - throw Exception("Unknown authentication type: " + std::to_string(static_cast(type)), ErrorCodes::LOGICAL_ERROR); + throw Exception("Cannot check if the password is correct for authentication type " + toString(type), ErrorCodes::NOT_IMPLEMENTED); } } diff --git a/src/Access/Authentication.h b/src/Access/Authentication.h index 3f16dc56de3..c410a101cdd 100644 --- a/src/Access/Authentication.h +++ b/src/Access/Authentication.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace DB @@ -14,6 +15,7 @@ namespace ErrorCodes extern const int SUPPORT_IS_DISABLED; extern const int BAD_ARGUMENTS; extern const int LOGICAL_ERROR; + extern const int NOT_IMPLEMENTED; } @@ -35,6 +37,15 @@ public: /// SHA1(SHA1(password)). /// This kind of hash is used by the `mysql_native_password` authentication plugin. DOUBLE_SHA1_PASSWORD, + + MAX_TYPE, + }; + + struct TypeInfo + { + const char * const raw_name; + const String name; /// Lowercased with underscores, e.g. "sha256_password". + static const TypeInfo & get(Type type_); }; using Digest = std::vector; @@ -85,6 +96,48 @@ private: }; +inline const Authentication::TypeInfo & Authentication::TypeInfo::get(Type type_) +{ + static constexpr auto make_info = [](const char * raw_name_) + { + String init_name = raw_name_; + boost::to_lower(init_name); + return TypeInfo{raw_name_, std::move(init_name)}; + }; + + switch (type_) + { + case NO_PASSWORD: + { + static const auto info = make_info("NO_PASSWORD"); + return info; + } + case PLAINTEXT_PASSWORD: + { + static const auto info = make_info("PLAINTEXT_PASSWORD"); + return info; + } + case SHA256_PASSWORD: + { + static const auto info = make_info("SHA256_PASSWORD"); + return info; + } + case DOUBLE_SHA1_PASSWORD: + { + static const auto info = make_info("DOUBLE_SHA1_PASSWORD"); + return info; + } + case MAX_TYPE: break; + } + throw Exception("Unknown authentication type: " + std::to_string(static_cast(type_)), ErrorCodes::LOGICAL_ERROR); +} + +inline String toString(Authentication::Type type_) +{ + return Authentication::TypeInfo::get(type_).raw_name; +} + + inline Authentication::Digest Authentication::encodeSHA256(const std::string_view & text [[maybe_unused]]) { #if USE_SSL @@ -122,8 +175,10 @@ inline void Authentication::setPassword(const String & password_) case DOUBLE_SHA1_PASSWORD: return setPasswordHashBinary(encodeDoubleSHA1(password_)); + + case MAX_TYPE: break; } - throw Exception("Unknown authentication type: " + std::to_string(static_cast(type)), ErrorCodes::LOGICAL_ERROR); + throw Exception("setPassword(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED); } @@ -186,8 +241,10 @@ inline void Authentication::setPasswordHashBinary(const Digest & hash) password_hash = hash; return; } + + case MAX_TYPE: break; } - throw Exception("Unknown authentication type: " + std::to_string(static_cast(type)), ErrorCodes::LOGICAL_ERROR); + throw Exception("setPasswordHashBinary(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED); } } diff --git a/src/Access/ContextAccess.cpp b/src/Access/ContextAccess.cpp index ab504e32579..82ed5920243 100644 --- a/src/Access/ContextAccess.cpp +++ b/src/Access/ContextAccess.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -121,7 +122,6 @@ void ContextAccess::setUser(const UserPtr & user_) const subscription_for_roles_changes = {}; enabled_roles = nullptr; roles_info = nullptr; - roles_with_admin_option = nullptr; enabled_row_policies = nullptr; enabled_quota = nullptr; enabled_settings = nullptr; @@ -131,29 +131,28 @@ void ContextAccess::setUser(const UserPtr & user_) const user_name = user->getName(); trace_log = &Poco::Logger::get("ContextAccess (" + user_name + ")"); - std::vector current_roles, current_roles_with_admin_option; + boost::container::flat_set current_roles, current_roles_with_admin_option; if (params.use_default_roles) { - for (const UUID & id : user->granted_roles) + for (const UUID & id : user->granted_roles.roles) { if (user->default_roles.match(id)) - current_roles.push_back(id); + current_roles.emplace(id); } - boost::range::set_intersection(current_roles, user->granted_roles_with_admin_option, - std::back_inserter(current_roles_with_admin_option)); } else { - current_roles.reserve(params.current_roles.size()); - for (const auto & id : params.current_roles) - { - if (user->granted_roles.count(id)) - current_roles.push_back(id); - if (user->granted_roles_with_admin_option.count(id)) - current_roles_with_admin_option.push_back(id); - } + boost::range::set_intersection( + params.current_roles, + user->granted_roles.roles, + std::inserter(current_roles, current_roles.end())); } + boost::range::set_intersection( + current_roles, + user->granted_roles.roles_with_admin_option, + std::inserter(current_roles_with_admin_option, current_roles_with_admin_option.end())); + subscription_for_roles_changes = {}; enabled_roles = manager->getEnabledRoles(current_roles, current_roles_with_admin_option); subscription_for_roles_changes = enabled_roles->subscribeForChanges([this](const std::shared_ptr & roles_info_) @@ -170,7 +169,6 @@ void ContextAccess::setRolesInfo(const std::shared_ptr & { assert(roles_info_); roles_info = roles_info_; - roles_with_admin_option.store(boost::make_shared>(roles_info->enabled_roles_with_admin_option.begin(), roles_info->enabled_roles_with_admin_option.end())); boost::range::fill(result_access, nullptr /* need recalculate */); enabled_row_policies = manager->getEnabledRowPolicies(*params.user_id, roles_info->enabled_roles); enabled_quota = manager->getEnabledQuota(*params.user_id, user_name, roles_info->enabled_roles, params.address, params.quota_key); @@ -202,7 +200,7 @@ bool ContextAccess::calculateResultAccessAndCheck(Poco::Logger * log_, const Acc bool is_granted = access->isGranted(flags, args...); if (trace_log) - LOG_TRACE(trace_log, "Access " << (is_granted ? "granted" : "denied") << ": " << (AccessRightsElement{flags, args...}.toString())); + LOG_TRACE(trace_log, "Access {}: {}", (is_granted ? "granted" : "denied"), (AccessRightsElement{flags, args...}.toString())); if (is_granted) return true; @@ -221,7 +219,7 @@ bool ContextAccess::calculateResultAccessAndCheck(Poco::Logger * log_, const Acc if constexpr (mode == THROW_IF_ACCESS_DENIED) throw Exception(user_name + ": " + msg, error_code); else if constexpr (mode == LOG_WARNING_IF_ACCESS_DENIED) - LOG_WARNING(log_, user_name + ": " + msg + formatSkippedMessage(args...)); + LOG_WARNING(log_, "{}: {}{}", user_name, msg, formatSkippedMessage(args...)); }; if (!user) @@ -357,10 +355,13 @@ void ContextAccess::checkAdminOption(const UUID & role_id) const if (isGranted(AccessType::ROLE_ADMIN)) return; - auto roles_with_admin_option_loaded = roles_with_admin_option.load(); - if (roles_with_admin_option_loaded && roles_with_admin_option_loaded->count(role_id)) + auto info = getRolesInfo(); + if (info && info->enabled_roles_with_admin_option.count(role_id)) return; + if (!user) + throw Exception(user_name + ": User has been dropped", ErrorCodes::UNKNOWN_USER); + std::optional role_name = manager->readName(role_id); if (!role_name) role_name = "ID {" + toString(role_id) + "}"; @@ -397,13 +398,13 @@ boost::shared_ptr ContextAccess::calculateResultAccess(bool if (grant_option) { - *merged_access = user->access_with_grant_option; + *merged_access = user->access.access_with_grant_option; if (roles_info) merged_access->merge(roles_info->access_with_grant_option); } else { - *merged_access = user->access; + *merged_access = user->access.access; if (roles_info) merged_access->merge(roles_info->access); } @@ -450,15 +451,18 @@ boost::shared_ptr ContextAccess::calculateResultAccess(bool if (trace_log && (params.readonly == readonly_) && (params.allow_ddl == allow_ddl_) && (params.allow_introspection == allow_introspection_)) { - LOG_TRACE(trace_log, "List of all grants: " << merged_access->toString() << (grant_option ? " WITH GRANT OPTION" : "")); + if (grant_option) + LOG_TRACE(trace_log, "List of all grants: {} WITH GRANT OPTION", merged_access->toString()); + else + LOG_TRACE(trace_log, "List of all grants: {}", merged_access->toString()); + if (roles_info && !roles_info->getCurrentRolesNames().empty()) { - LOG_TRACE( - trace_log, - "Current_roles: " << boost::algorithm::join(roles_info->getCurrentRolesNames(), ", ") - << ", enabled_roles: " << boost::algorithm::join(roles_info->getEnabledRolesNames(), ", ")); + LOG_TRACE(trace_log, "Current_roles: {}, enabled_roles: {}", + boost::algorithm::join(roles_info->getCurrentRolesNames(), ", "), + boost::algorithm::join(roles_info->getEnabledRolesNames(), ", ")); } - LOG_TRACE(trace_log, "Settings: readonly=" << readonly_ << ", allow_ddl=" << allow_ddl_ << ", allow_introspection_functions=" << allow_introspection_); + LOG_TRACE(trace_log, "Settings: readonly={}, allow_ddl={}, allow_introspection_functions={}", readonly_, allow_ddl_, allow_introspection_); } res = std::move(merged_access); @@ -485,31 +489,7 @@ std::shared_ptr ContextAccess::getRolesInfo() const return roles_info; } -std::vector ContextAccess::getCurrentRoles() const -{ - std::lock_guard lock{mutex}; - return roles_info ? roles_info->current_roles : std::vector{}; -} - -Strings ContextAccess::getCurrentRolesNames() const -{ - std::lock_guard lock{mutex}; - return roles_info ? roles_info->getCurrentRolesNames() : Strings{}; -} - -std::vector ContextAccess::getEnabledRoles() const -{ - std::lock_guard lock{mutex}; - return roles_info ? roles_info->enabled_roles : std::vector{}; -} - -Strings ContextAccess::getEnabledRolesNames() const -{ - std::lock_guard lock{mutex}; - return roles_info ? roles_info->getEnabledRolesNames() : Strings{}; -} - -std::shared_ptr ContextAccess::getRowPolicies() const +std::shared_ptr ContextAccess::getEnabledRowPolicies() const { std::lock_guard lock{mutex}; return enabled_row_policies; @@ -528,6 +508,13 @@ std::shared_ptr ContextAccess::getQuota() const } +std::optional ContextAccess::getQuotaUsage() const +{ + std::lock_guard lock{mutex}; + return enabled_quota ? enabled_quota->getUsage() : std::optional{}; +} + + std::shared_ptr ContextAccess::getFullAccess() { static const std::shared_ptr res = [] diff --git a/src/Access/ContextAccess.h b/src/Access/ContextAccess.h index e0fbf58dbe8..27bb29a878c 100644 --- a/src/Access/ContextAccess.h +++ b/src/Access/ContextAccess.h @@ -22,6 +22,7 @@ class EnabledRoles; class EnabledRowPolicies; class EnabledQuota; class EnabledSettings; +struct QuotaUsage; struct Settings; class SettingsConstraints; class AccessControlManager; @@ -35,7 +36,7 @@ public: struct Params { std::optional user_id; - std::vector current_roles; + boost::container::flat_set current_roles; bool use_default_roles = false; UInt64 readonly = 0; bool allow_ddl = false; @@ -56,22 +57,37 @@ public: }; const Params & getParams() const { return params; } + + /// Returns the current user. The function can return nullptr. UserPtr getUser() const; String getUserName() const; bool isCorrectPassword(const String & password) const; bool isClientHostAllowed() const; + /// Returns information about current and enabled roles. + /// The function can return nullptr. std::shared_ptr getRolesInfo() const; - std::vector getCurrentRoles() const; - Strings getCurrentRolesNames() const; - std::vector getEnabledRoles() const; - Strings getEnabledRolesNames() const; - std::shared_ptr getRowPolicies() const; + /// Returns information about enabled row policies. + /// The function can return nullptr. + std::shared_ptr getEnabledRowPolicies() const; + + /// Returns the row policy filter for a specified table. + /// The function returns nullptr if there is no filter to apply. ASTPtr getRowPolicyCondition(const String & database, const String & table_name, RowPolicy::ConditionType index, const ASTPtr & extra_condition = nullptr) const; + + /// Returns the quota to track resource consumption. + /// The function returns nullptr if no tracking or limitation is needed. std::shared_ptr getQuota() const; + std::optional getQuotaUsage() const; + + /// Returns the default settings, i.e. the settings to apply on user's login. + /// The function returns nullptr if it's no need to apply settings. std::shared_ptr getDefaultSettings() const; + + /// Returns the settings' constraints. + /// The function returns nullptr if there are no constraints. std::shared_ptr getSettingsConstraints() const; /// Checks if a specified access is granted, and throws an exception if not. @@ -118,7 +134,8 @@ public: /// Checks if a specified role is granted with admin option, and throws an exception if not. void checkAdminOption(const UUID & role_id) const; - /// Returns an instance of ContextAccess which has full access to everything. + /// Makes an instance of ContextAccess which provides full access to everything + /// without any limitations. This is used for the global context. static std::shared_ptr getFullAccess(); private: @@ -157,7 +174,6 @@ private: mutable std::shared_ptr enabled_roles; mutable ext::scope_guard subscription_for_roles_changes; mutable std::shared_ptr roles_info; - mutable boost::atomic_shared_ptr> roles_with_admin_option; mutable boost::atomic_shared_ptr result_access[7]; mutable std::shared_ptr enabled_row_policies; mutable std::shared_ptr enabled_quota; diff --git a/src/Access/DiskAccessStorage.cpp b/src/Access/DiskAccessStorage.cpp index bf4316cc195..1195bcf842c 100644 --- a/src/Access/DiskAccessStorage.cpp +++ b/src/Access/DiskAccessStorage.cpp @@ -53,6 +53,9 @@ namespace ErrorCodes namespace { + using EntityType = IAccessStorage::EntityType; + using EntityTypeInfo = IAccessStorage::EntityTypeInfo; + /// Special parser for the 'ATTACH access entity' queries. class ParserAttachAccessEntity : public IParserBase { @@ -79,7 +82,7 @@ namespace /// Reads a file containing ATTACH queries and then parses it to build an access entity. - AccessEntityPtr readAccessEntityFile(const std::filesystem::path & file_path) + AccessEntityPtr readEntityFile(const std::filesystem::path & file_path) { /// Read the file. ReadBufferFromFile in{file_path}; @@ -164,11 +167,11 @@ namespace } - AccessEntityPtr tryReadAccessEntityFile(const std::filesystem::path & file_path, Poco::Logger & log) + AccessEntityPtr tryReadEntityFile(const std::filesystem::path & file_path, Poco::Logger & log) { try { - return readAccessEntityFile(file_path); + return readEntityFile(file_path); } catch (...) { @@ -179,12 +182,12 @@ namespace /// Writes ATTACH queries for building a specified access entity to a file. - void writeAccessEntityFile(const std::filesystem::path & file_path, const IAccessEntity & entity) + void writeEntityFile(const std::filesystem::path & file_path, const IAccessEntity & entity) { /// Build list of ATTACH queries. ASTs queries; queries.push_back(InterpreterShowCreateAccessEntityQuery::getAttachQuery(entity)); - if (entity.getType() == typeid(User) || entity.getType() == typeid(Role)) + if ((entity.getType() == EntityType::USER) || (entity.getType() == EntityType::ROLE)) boost::range::push_back(queries, InterpreterShowGrantsQuery::getAttachGrantQueries(entity)); /// Serialize the list of ATTACH queries to a string. @@ -213,21 +216,21 @@ namespace /// Calculates the path to a file named .sql for saving an access entity. - std::filesystem::path getAccessEntityFilePath(const String & directory_path, const UUID & id) + std::filesystem::path getEntityFilePath(const String & directory_path, const UUID & id) { return std::filesystem::path(directory_path).append(toString(id)).replace_extension(".sql"); } /// Reads a map of name of access entity to UUID for access entities of some type from a file. - std::unordered_map readListFile(const std::filesystem::path & file_path) + std::vector> readListFile(const std::filesystem::path & file_path) { ReadBufferFromFile in(file_path); size_t num; readVarUInt(num, in); - std::unordered_map res; - res.reserve(num); + std::vector> id_name_pairs; + id_name_pairs.reserve(num); for (size_t i = 0; i != num; ++i) { @@ -235,19 +238,19 @@ namespace readStringBinary(name, in); UUID id; readUUIDText(id, in); - res[name] = id; + id_name_pairs.emplace_back(id, std::move(name)); } - return res; + return id_name_pairs; } /// Writes a map of name of access entity to UUID for access entities of some type to a file. - void writeListFile(const std::filesystem::path & file_path, const std::unordered_map & map) + void writeListFile(const std::filesystem::path & file_path, const std::vector> & id_name_pairs) { WriteBufferFromFile out(file_path); - writeVarUInt(map.size(), out); - for (const auto & [name, id] : map) + writeVarUInt(id_name_pairs.size(), out); + for (const auto & [id, name] : id_name_pairs) { writeStringBinary(name, out); writeUUIDText(id, out); @@ -256,24 +259,10 @@ namespace /// Calculates the path for storing a map of name of access entity to UUID for access entities of some type. - std::filesystem::path getListFilePath(const String & directory_path, std::type_index type) + std::filesystem::path getListFilePath(const String & directory_path, EntityType type) { - std::string_view file_name; - if (type == typeid(User)) - file_name = "users"; - else if (type == typeid(Role)) - file_name = "roles"; - else if (type == typeid(Quota)) - file_name = "quotas"; - else if (type == typeid(RowPolicy)) - file_name = "row_policies"; - else if (type == typeid(SettingsProfile)) - file_name = "settings_profiles"; - else - throw Exception("Unexpected type of access entity: " + IAccessEntity::getTypeName(type), - ErrorCodes::LOGICAL_ERROR); - - return std::filesystem::path(directory_path).append(file_name).replace_extension(".list"); + std::string_view file_name = EntityTypeInfo::get(type).list_filename; + return std::filesystem::path(directory_path).append(file_name); } @@ -297,21 +286,12 @@ namespace return false; } } - - - const std::vector & getAllAccessEntityTypes() - { - static const std::vector res = {typeid(User), typeid(Role), typeid(RowPolicy), typeid(Quota), typeid(SettingsProfile)}; - return res; - } } DiskAccessStorage::DiskAccessStorage() : IAccessStorage("disk") { - for (auto type : getAllAccessEntityTypes()) - name_to_id_maps[type]; } @@ -363,29 +343,45 @@ void DiskAccessStorage::initialize(const String & directory_path_, Notifications writeLists(); } - for (const auto & [id, entry] : id_to_entry_map) + for (const auto & [id, entry] : entries_by_id) prepareNotifications(id, entry, false, notifications); } +void DiskAccessStorage::clear() +{ + entries_by_id.clear(); + for (auto type : ext::range(EntityType::MAX)) + entries_by_name_and_type[static_cast(type)].clear(); +} + + bool DiskAccessStorage::readLists() { - assert(id_to_entry_map.empty()); + clear(); + bool ok = true; - for (auto type : getAllAccessEntityTypes()) + for (auto type : ext::range(EntityType::MAX)) { - auto & name_to_id_map = name_to_id_maps.at(type); + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; auto file_path = getListFilePath(directory_path, type); if (!std::filesystem::exists(file_path)) { - LOG_WARNING(getLogger(), "File " + file_path.string() + " doesn't exist"); + LOG_WARNING(getLogger(), "File {} doesn't exist", file_path.string()); ok = false; break; } try { - name_to_id_map = readListFile(file_path); + for (const auto & [id, name] : readListFile(file_path)) + { + auto & entry = entries_by_id[id]; + entry.id = id; + entry.type = type; + entry.name = name; + entries_by_name[entry.name] = &entry; + } } catch (...) { @@ -393,17 +389,10 @@ bool DiskAccessStorage::readLists() ok = false; break; } - - for (const auto & [name, id] : name_to_id_map) - id_to_entry_map.emplace(id, Entry{name, type}); } if (!ok) - { - id_to_entry_map.clear(); - for (auto & name_to_id_map : name_to_id_maps | boost::adaptors::map_values) - name_to_id_map.clear(); - } + clear(); return ok; } @@ -419,11 +408,15 @@ bool DiskAccessStorage::writeLists() for (const auto & type : types_of_lists_to_write) { - const auto & name_to_id_map = name_to_id_maps.at(type); + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; auto file_path = getListFilePath(directory_path, type); try { - writeListFile(file_path, name_to_id_map); + std::vector> id_name_pairs; + id_name_pairs.reserve(entries_by_name.size()); + for (const auto * entry : entries_by_name | boost::adaptors::map_values) + id_name_pairs.emplace_back(entry->id, entry->name); + writeListFile(file_path, id_name_pairs); } catch (...) { @@ -441,7 +434,7 @@ bool DiskAccessStorage::writeLists() } -void DiskAccessStorage::scheduleWriteLists(std::type_index type) +void DiskAccessStorage::scheduleWriteLists(EntityType type) { if (failed_to_write_lists) return; @@ -503,8 +496,8 @@ void DiskAccessStorage::listsWritingThreadFunc() /// and then saves the files "users.list", "roles.list", etc. to the same directory. bool DiskAccessStorage::rebuildLists() { - LOG_WARNING(getLogger(), "Recovering lists in directory " + directory_path); - assert(id_to_entry_map.empty()); + LOG_WARNING(getLogger(), "Recovering lists in directory {}", directory_path); + clear(); for (const auto & directory_entry : std::filesystem::directory_iterator(directory_path)) { @@ -518,58 +511,64 @@ bool DiskAccessStorage::rebuildLists() if (!tryParseUUID(path.stem(), id)) continue; - const auto access_entity_file_path = getAccessEntityFilePath(directory_path, id); - auto entity = tryReadAccessEntityFile(access_entity_file_path, *getLogger()); + const auto access_entity_file_path = getEntityFilePath(directory_path, id); + auto entity = tryReadEntityFile(access_entity_file_path, *getLogger()); if (!entity) continue; + const String & name = entity->getName(); auto type = entity->getType(); - auto & name_to_id_map = name_to_id_maps.at(type); - auto it_by_name = name_to_id_map.emplace(entity->getFullName(), id).first; - id_to_entry_map.emplace(id, Entry{it_by_name->first, type}); + auto & entry = entries_by_id[id]; + entry.id = id; + entry.type = type; + entry.name = name; + entry.entity = entity; + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + entries_by_name[entry.name] = &entry; } - for (auto type : getAllAccessEntityTypes()) + for (auto type : ext::range(EntityType::MAX)) types_of_lists_to_write.insert(type); return true; } -std::optional DiskAccessStorage::findImpl(std::type_index type, const String & name) const +std::optional DiskAccessStorage::findImpl(EntityType type, const String & name) const { std::lock_guard lock{mutex}; - const auto & name_to_id_map = name_to_id_maps.at(type); - auto it = name_to_id_map.find(name); - if (it == name_to_id_map.end()) + const auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + auto it = entries_by_name.find(name); + if (it == entries_by_name.end()) return {}; - return it->second; + return it->second->id; } -std::vector DiskAccessStorage::findAllImpl(std::type_index type) const +std::vector DiskAccessStorage::findAllImpl(EntityType type) const { std::lock_guard lock{mutex}; - const auto & name_to_id_map = name_to_id_maps.at(type); + const auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; std::vector res; - res.reserve(name_to_id_map.size()); - boost::range::copy(name_to_id_map | boost::adaptors::map_values, std::back_inserter(res)); + res.reserve(entries_by_name.size()); + for (const auto * entry : entries_by_name | boost::adaptors::map_values) + res.emplace_back(entry->id); return res; } bool DiskAccessStorage::existsImpl(const UUID & id) const { std::lock_guard lock{mutex}; - return id_to_entry_map.count(id); + return entries_by_id.count(id); } AccessEntityPtr DiskAccessStorage::readImpl(const UUID & id) const { std::lock_guard lock{mutex}; - auto it = id_to_entry_map.find(id); - if (it == id_to_entry_map.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); const auto & entry = it->second; @@ -582,8 +581,8 @@ AccessEntityPtr DiskAccessStorage::readImpl(const UUID & id) const String DiskAccessStorage::readNameImpl(const UUID & id) const { std::lock_guard lock{mutex}; - auto it = id_to_entry_map.find(id); - if (it == id_to_entry_map.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); return String{it->second.name}; } @@ -609,25 +608,25 @@ UUID DiskAccessStorage::insertImpl(const AccessEntityPtr & new_entity, bool repl void DiskAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & new_entity, bool replace_if_exists, Notifications & notifications) { - const String & name = new_entity->getFullName(); - std::type_index type = new_entity->getType(); + const String & name = new_entity->getName(); + EntityType type = new_entity->getType(); if (!initialized) throw Exception( - "Cannot insert " + new_entity->getTypeName() + " " + backQuote(name) + " to " + getStorageName() - + " because the output directory is not set", + "Cannot insert " + new_entity->outputTypeAndName() + " to storage [" + getStorageName() + + "] because the output directory is not set", ErrorCodes::LOGICAL_ERROR); /// Check that we can insert. - auto it_by_id = id_to_entry_map.find(id); - if (it_by_id != id_to_entry_map.end()) + auto it_by_id = entries_by_id.find(id); + if (it_by_id != entries_by_id.end()) { const auto & existing_entry = it_by_id->second; - throwIDCollisionCannotInsert(id, type, name, existing_entry.entity->getType(), existing_entry.entity->getFullName()); + throwIDCollisionCannotInsert(id, type, name, existing_entry.entity->getType(), existing_entry.entity->getName()); } - auto & name_to_id_map = name_to_id_maps.at(type); - auto it_by_name = name_to_id_map.find(name); - bool name_collision = (it_by_name != name_to_id_map.end()); + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + auto it_by_name = entries_by_name.find(name); + bool name_collision = (it_by_name != entries_by_name.end()); if (name_collision && !replace_if_exists) throwNameCollisionCannotInsert(type, name); @@ -636,13 +635,15 @@ void DiskAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & ne writeAccessEntityToDisk(id, *new_entity); if (name_collision && replace_if_exists) - removeNoLock(it_by_name->second, notifications); + removeNoLock(it_by_name->second->id, notifications); /// Do insertion. - it_by_name = name_to_id_map.emplace(name, id).first; - it_by_id = id_to_entry_map.emplace(id, Entry{it_by_name->first, type}).first; - auto & entry = it_by_id->second; + auto & entry = entries_by_id[id]; + entry.id = id; + entry.type = type; + entry.name = name; entry.entity = new_entity; + entries_by_name[entry.name] = &entry; prepareNotifications(id, entry, false, notifications); } @@ -659,22 +660,21 @@ void DiskAccessStorage::removeImpl(const UUID & id) void DiskAccessStorage::removeNoLock(const UUID & id, Notifications & notifications) { - auto it = id_to_entry_map.find(id); - if (it == id_to_entry_map.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); Entry & entry = it->second; - String name{it->second.name}; - std::type_index type = it->second.type; + EntityType type = entry.type; scheduleWriteLists(type); deleteAccessEntityOnDisk(id); /// Do removing. prepareNotifications(id, entry, true, notifications); - id_to_entry_map.erase(it); - auto & name_to_id_map = name_to_id_maps.at(type); - name_to_id_map.erase(name); + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + entries_by_name.erase(entry.name); + entries_by_id.erase(it); } @@ -690,8 +690,8 @@ void DiskAccessStorage::updateImpl(const UUID & id, const UpdateFunc & update_fu void DiskAccessStorage::updateNoLock(const UUID & id, const UpdateFunc & update_func, Notifications & notifications) { - auto it = id_to_entry_map.find(id); - if (it == id_to_entry_map.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); Entry & entry = it->second; @@ -700,18 +700,22 @@ void DiskAccessStorage::updateNoLock(const UUID & id, const UpdateFunc & update_ auto old_entity = entry.entity; auto new_entity = update_func(old_entity); + if (!new_entity->isTypeOf(old_entity->getType())) + throwBadCast(id, new_entity->getType(), new_entity->getName(), old_entity->getType()); + if (*new_entity == *old_entity) return; - String new_name = new_entity->getFullName(); - auto old_name = entry.name; - const std::type_index type = entry.type; + const String & new_name = new_entity->getName(); + const String & old_name = old_entity->getName(); + const EntityType type = entry.type; + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + bool name_changed = (new_name != old_name); if (name_changed) { - const auto & name_to_id_map = name_to_id_maps.at(type); - if (name_to_id_map.count(new_name)) - throwNameCollisionCannotRename(type, String{old_name}, new_name); + if (entries_by_name.count(new_name)) + throwNameCollisionCannotRename(type, old_name, new_name); scheduleWriteLists(type); } @@ -720,10 +724,9 @@ void DiskAccessStorage::updateNoLock(const UUID & id, const UpdateFunc & update_ if (name_changed) { - auto & name_to_id_map = name_to_id_maps.at(type); - name_to_id_map.erase(String{old_name}); - auto it_by_name = name_to_id_map.emplace(new_name, id).first; - entry.name = it_by_name->first; + entries_by_name.erase(entry.name); + entry.name = new_name; + entries_by_name[entry.name] = &entry; } prepareNotifications(id, entry, false, notifications); @@ -732,19 +735,19 @@ void DiskAccessStorage::updateNoLock(const UUID & id, const UpdateFunc & update_ AccessEntityPtr DiskAccessStorage::readAccessEntityFromDisk(const UUID & id) const { - return readAccessEntityFile(getAccessEntityFilePath(directory_path, id)); + return readEntityFile(getEntityFilePath(directory_path, id)); } void DiskAccessStorage::writeAccessEntityToDisk(const UUID & id, const IAccessEntity & entity) const { - writeAccessEntityFile(getAccessEntityFilePath(directory_path, id), entity); + writeEntityFile(getEntityFilePath(directory_path, id), entity); } void DiskAccessStorage::deleteAccessEntityOnDisk(const UUID & id) const { - auto file_path = getAccessEntityFilePath(directory_path, id); + auto file_path = getEntityFilePath(directory_path, id); if (!std::filesystem::remove(file_path)) throw Exception("Couldn't delete " + file_path.string(), ErrorCodes::FILE_DOESNT_EXIST); } @@ -759,17 +762,16 @@ void DiskAccessStorage::prepareNotifications(const UUID & id, const Entry & entr for (const auto & handler : entry.handlers_by_id) notifications.push_back({handler, id, entity}); - auto range = handlers_by_type.equal_range(entry.type); - for (auto it = range.first; it != range.second; ++it) - notifications.push_back({it->second, id, entity}); + for (const auto & handler : handlers_by_type[static_cast(entry.type)]) + notifications.push_back({handler, id, entity}); } ext::scope_guard DiskAccessStorage::subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const { std::lock_guard lock{mutex}; - auto it = id_to_entry_map.find(id); - if (it == id_to_entry_map.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) return {}; const Entry & entry = it->second; auto handler_it = entry.handlers_by_id.insert(entry.handlers_by_id.end(), handler); @@ -777,8 +779,8 @@ ext::scope_guard DiskAccessStorage::subscribeForChangesImpl(const UUID & id, con return [this, id, handler_it] { std::lock_guard lock2{mutex}; - auto it2 = id_to_entry_map.find(id); - if (it2 != id_to_entry_map.end()) + auto it2 = entries_by_id.find(id); + if (it2 != entries_by_id.end()) { const Entry & entry2 = it2->second; entry2.handlers_by_id.erase(handler_it); @@ -786,23 +788,26 @@ ext::scope_guard DiskAccessStorage::subscribeForChangesImpl(const UUID & id, con }; } -ext::scope_guard DiskAccessStorage::subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const +ext::scope_guard DiskAccessStorage::subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const { std::lock_guard lock{mutex}; - auto handler_it = handlers_by_type.emplace(type, handler); + auto & handlers = handlers_by_type[static_cast(type)]; + handlers.push_back(handler); + auto handler_it = std::prev(handlers.end()); - return [this, handler_it] + return [this, type, handler_it] { std::lock_guard lock2{mutex}; - handlers_by_type.erase(handler_it); + auto & handlers2 = handlers_by_type[static_cast(type)]; + handlers2.erase(handler_it); }; } bool DiskAccessStorage::hasSubscriptionImpl(const UUID & id) const { std::lock_guard lock{mutex}; - auto it = id_to_entry_map.find(id); - if (it != id_to_entry_map.end()) + auto it = entries_by_id.find(id); + if (it != entries_by_id.end()) { const Entry & entry = it->second; return !entry.handlers_by_id.empty(); @@ -810,11 +815,11 @@ bool DiskAccessStorage::hasSubscriptionImpl(const UUID & id) const return false; } -bool DiskAccessStorage::hasSubscriptionImpl(std::type_index type) const +bool DiskAccessStorage::hasSubscriptionImpl(EntityType type) const { std::lock_guard lock{mutex}; - auto range = handlers_by_type.equal_range(type); - return range.first != range.second; + const auto & handlers = handlers_by_type[static_cast(type)]; + return !handlers.empty(); } } diff --git a/src/Access/DiskAccessStorage.h b/src/Access/DiskAccessStorage.h index 104c0f1fa38..79a11195318 100644 --- a/src/Access/DiskAccessStorage.h +++ b/src/Access/DiskAccessStorage.h @@ -17,8 +17,8 @@ public: void setDirectory(const String & directory_path_); private: - std::optional findImpl(std::type_index type, const String & name) const override; - std::vector findAllImpl(std::type_index type) const override; + std::optional findImpl(EntityType type, const String & name) const override; + std::vector findAllImpl(EntityType type) const override; bool existsImpl(const UUID & id) const override; AccessEntityPtr readImpl(const UUID & id) const override; String readNameImpl(const UUID & id) const override; @@ -27,14 +27,15 @@ private: void removeImpl(const UUID & id) override; void updateImpl(const UUID & id, const UpdateFunc & update_func) override; ext::scope_guard subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const override; - ext::scope_guard subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const override; + ext::scope_guard subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const override; bool hasSubscriptionImpl(const UUID & id) const override; - bool hasSubscriptionImpl(std::type_index type) const override; + bool hasSubscriptionImpl(EntityType type) const override; void initialize(const String & directory_path_, Notifications & notifications); + void clear(); bool readLists(); bool writeLists(); - void scheduleWriteLists(std::type_index type); + void scheduleWriteLists(EntityType type); bool rebuildLists(); void startListsWritingThread(); @@ -52,9 +53,9 @@ private: using NameToIDMap = std::unordered_map; struct Entry { - Entry(const std::string_view & name_, std::type_index type_) : name(name_), type(type_) {} - std::string_view name; /// view points to a string in `name_to_id_maps`. - std::type_index type; + UUID id; + String name; + EntityType type; mutable AccessEntityPtr entity; /// may be nullptr, if the entity hasn't been loaded yet. mutable std::list handlers_by_id; }; @@ -63,14 +64,14 @@ private: String directory_path; bool initialized = false; - std::unordered_map name_to_id_maps; - std::unordered_map id_to_entry_map; - boost::container::flat_set types_of_lists_to_write; + std::unordered_map entries_by_id; + std::unordered_map entries_by_name_and_type[static_cast(EntityType::MAX)]; + boost::container::flat_set types_of_lists_to_write; bool failed_to_write_lists = false; /// Whether writing of the list files has been failed since the recent restart of the server. ThreadFromGlobalPool lists_writing_thread; /// List files are written in a separate thread. std::condition_variable lists_writing_thread_should_exit; /// Signals `lists_writing_thread` to exit. std::atomic lists_writing_thread_exited = false; - mutable std::unordered_multimap handlers_by_type; + mutable std::list handlers_by_type[static_cast(EntityType::MAX)]; mutable std::mutex mutex; }; } diff --git a/src/Access/EnabledQuota.cpp b/src/Access/EnabledQuota.cpp index 92257ce0002..e9d586a692f 100644 --- a/src/Access/EnabledQuota.cpp +++ b/src/Access/EnabledQuota.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -30,9 +30,10 @@ struct EnabledQuota::Impl if (resource_type == Quota::EXECUTION_TIME) amount_to_string = [&](UInt64 amount) { return ext::to_string(std::chrono::nanoseconds(amount)); }; + const auto & type_info = Quota::ResourceTypeInfo::get(resource_type); throw Exception( "Quota for user " + backQuote(user_name) + " for " + ext::to_string(duration) + " has been exceeded: " - + Quota::getNameOfResourceType(resource_type) + " = " + amount_to_string(used) + "/" + amount_to_string(max) + ". " + + type_info.outputWithAmount(used) + "/" + type_info.amountToString(max) + ". " + "Interval will end at " + ext::to_string(end_of_interval) + ". " + "Name of quota template: " + backQuote(quota_name), ErrorCodes::QUOTA_EXPIRED); } @@ -83,7 +84,7 @@ struct EnabledQuota::Impl { ResourceAmount used = (interval.used[resource_type] += amount); ResourceAmount max = interval.max[resource_type]; - if (max == Quota::UNLIMITED) + if (!max) continue; if (used > max) { @@ -111,7 +112,7 @@ struct EnabledQuota::Impl { ResourceAmount used = interval.used[resource_type]; ResourceAmount max = interval.max[resource_type]; - if (max == Quota::UNLIMITED) + if (!max) continue; if (used > max) { @@ -128,12 +129,22 @@ struct EnabledQuota::Impl const Intervals & intervals, std::chrono::system_clock::time_point current_time) { - for (auto resource_type : ext::range_with_static_cast(Quota::MAX_RESOURCE_TYPE)) + for (auto resource_type : ext::range(Quota::MAX_RESOURCE_TYPE)) checkExceeded(user_name, intervals, resource_type, current_time); } }; +EnabledQuota::Interval::Interval() +{ + for (auto resource_type : ext::range(MAX_RESOURCE_TYPE)) + { + used[resource_type].store(0); + max[resource_type] = 0; + } +} + + EnabledQuota::Interval & EnabledQuota::Interval::operator =(const Interval & src) { if (this == &src) @@ -151,27 +162,30 @@ EnabledQuota::Interval & EnabledQuota::Interval::operator =(const Interval & src } -QuotaUsageInfo EnabledQuota::Intervals::getUsageInfo(std::chrono::system_clock::time_point current_time) const +std::optional EnabledQuota::Intervals::getUsage(std::chrono::system_clock::time_point current_time) const { - QuotaUsageInfo info; - info.quota_id = quota_id; - info.quota_name = quota_name; - info.quota_key = quota_key; - info.intervals.reserve(intervals.size()); + if (!quota_id) + return {}; + QuotaUsage usage; + usage.quota_id = *quota_id; + usage.quota_name = quota_name; + usage.quota_key = quota_key; + usage.intervals.reserve(intervals.size()); for (const auto & in : intervals) { - info.intervals.push_back({}); - auto & out = info.intervals.back(); + usage.intervals.push_back({}); + auto & out = usage.intervals.back(); out.duration = in.duration; out.randomize_interval = in.randomize_interval; out.end_of_interval = Impl::getEndOfInterval(in, current_time); for (auto resource_type : ext::range(MAX_RESOURCE_TYPE)) { - out.max[resource_type] = in.max[resource_type]; + if (in.max[resource_type]) + out.max[resource_type] = in.max[resource_type]; out.used[resource_type] = in.used[resource_type]; } } - return info; + return usage; } @@ -238,10 +252,10 @@ void EnabledQuota::checkExceeded(ResourceType resource_type) const } -QuotaUsageInfo EnabledQuota::getUsageInfo() const +std::optional EnabledQuota::getUsage() const { auto loaded = intervals.load(); - return loaded->getUsageInfo(std::chrono::system_clock::now()); + return loaded->getUsage(std::chrono::system_clock::now()); } diff --git a/src/Access/EnabledQuota.h b/src/Access/EnabledQuota.h index 5a624c651af..25e804dd050 100644 --- a/src/Access/EnabledQuota.h +++ b/src/Access/EnabledQuota.h @@ -12,7 +12,7 @@ namespace DB { -struct QuotaUsageInfo; +struct QuotaUsage; /// Instances of `EnabledQuota` are used to track resource consumption. @@ -23,7 +23,7 @@ public: { UUID user_id; String user_name; - std::vector enabled_roles; + boost::container::flat_set enabled_roles; Poco::Net::IPAddress client_address; String client_key; @@ -53,7 +53,7 @@ public: void checkExceeded(ResourceType resource_type) const; /// Returns the information about quota consumption. - QuotaUsageInfo getUsageInfo() const; + std::optional getUsage() const; /// Returns an instance of EnabledQuota which is never exceeded. static std::shared_ptr getUnlimitedQuota(); @@ -65,17 +65,17 @@ private: const String & getUserName() const { return params.user_name; } - static constexpr size_t MAX_RESOURCE_TYPE = Quota::MAX_RESOURCE_TYPE; + static constexpr auto MAX_RESOURCE_TYPE = Quota::MAX_RESOURCE_TYPE; struct Interval { mutable std::atomic used[MAX_RESOURCE_TYPE]; ResourceAmount max[MAX_RESOURCE_TYPE]; - std::chrono::seconds duration; - bool randomize_interval; + std::chrono::seconds duration = std::chrono::seconds::zero(); + bool randomize_interval = false; mutable std::atomic end_of_interval; - Interval() {} + Interval(); Interval(const Interval & src) { *this = src; } Interval & operator =(const Interval & src); }; @@ -83,11 +83,11 @@ private: struct Intervals { std::vector intervals; - UUID quota_id; + std::optional quota_id; String quota_name; String quota_key; - QuotaUsageInfo getUsageInfo(std::chrono::system_clock::time_point current_time) const; + std::optional getUsage(std::chrono::system_clock::time_point current_time) const; }; struct Impl; diff --git a/src/Access/EnabledRoles.h b/src/Access/EnabledRoles.h index 122b1a16fe3..0c5b799a30b 100644 --- a/src/Access/EnabledRoles.h +++ b/src/Access/EnabledRoles.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -16,8 +17,8 @@ class EnabledRoles public: struct Params { - std::vector current_roles; - std::vector current_roles_with_admin_option; + boost::container::flat_set current_roles; + boost::container::flat_set current_roles_with_admin_option; auto toTuple() const { return std::tie(current_roles, current_roles_with_admin_option); } friend bool operator ==(const Params & lhs, const Params & rhs) { return lhs.toTuple() == rhs.toTuple(); } diff --git a/src/Access/EnabledRolesInfo.h b/src/Access/EnabledRolesInfo.h index 837d4b74ad5..45e1bfd9057 100644 --- a/src/Access/EnabledRolesInfo.h +++ b/src/Access/EnabledRolesInfo.h @@ -3,8 +3,8 @@ #include #include #include +#include #include -#include namespace DB @@ -13,9 +13,9 @@ namespace DB /// Information about a role. struct EnabledRolesInfo { - std::vector current_roles; - std::vector enabled_roles; - std::vector enabled_roles_with_admin_option; + boost::container::flat_set current_roles; + boost::container::flat_set enabled_roles; + boost::container::flat_set enabled_roles_with_admin_option; std::unordered_map names_of_roles; AccessRights access; AccessRights access_with_grant_option; diff --git a/src/Access/EnabledRowPolicies.cpp b/src/Access/EnabledRowPolicies.cpp index 56c73aaf40d..efd5ed4ae10 100644 --- a/src/Access/EnabledRowPolicies.cpp +++ b/src/Access/EnabledRowPolicies.cpp @@ -6,9 +6,9 @@ namespace DB { -size_t EnabledRowPolicies::Hash::operator()(const DatabaseAndTableNameRef & database_and_table_name) const +size_t EnabledRowPolicies::Hash::operator()(const MixedConditionKey & key) const { - return std::hash{}(database_and_table_name.first) - std::hash{}(database_and_table_name.second); + return std::hash{}(key.database) - std::hash{}(key.table_name) + static_cast(key.condition_type); } @@ -20,16 +20,22 @@ EnabledRowPolicies::EnabledRowPolicies(const Params & params_) EnabledRowPolicies::~EnabledRowPolicies() = default; -ASTPtr EnabledRowPolicies::getCondition(const String & database, const String & table_name, ConditionType type) const +ASTPtr EnabledRowPolicies::getCondition(const String & database, const String & table_name, ConditionType condition_type) const { /// We don't lock `mutex` here. auto loaded = map_of_mixed_conditions.load(); - auto it = loaded->find({database, table_name}); + auto it = loaded->find({database, table_name, condition_type}); if (it == loaded->end()) return {}; - return it->second.mixed_conditions[type]; -} + auto condition = it->second.ast; + + bool value; + if (tryGetLiteralBool(condition.get(), value) && value) + return nullptr; /// The condition is always true, no need to check it. + + return condition; +} ASTPtr EnabledRowPolicies::getCondition(const String & database, const String & table_name, ConditionType type, const ASTPtr & extra_condition) const { @@ -41,31 +47,9 @@ ASTPtr EnabledRowPolicies::getCondition(const String & database, const String & bool value; if (tryGetLiteralBool(condition.get(), value) && value) - condition = nullptr; /// The condition is always true, no need to check it. + return nullptr; /// The condition is always true, no need to check it. return condition; } - -std::vector EnabledRowPolicies::getCurrentPolicyIDs() const -{ - /// We don't lock `mutex` here. - auto loaded = map_of_mixed_conditions.load(); - std::vector policy_ids; - for (const auto & mixed_conditions : *loaded | boost::adaptors::map_values) - boost::range::copy(mixed_conditions.policy_ids, std::back_inserter(policy_ids)); - return policy_ids; -} - - -std::vector EnabledRowPolicies::getCurrentPolicyIDs(const String & database, const String & table_name) const -{ - /// We don't lock `mutex` here. - auto loaded = map_of_mixed_conditions.load(); - auto it = loaded->find({database, table_name}); - if (it == loaded->end()) - return {}; - return it->second.policy_ids; -} - } diff --git a/src/Access/EnabledRowPolicies.h b/src/Access/EnabledRowPolicies.h index 9befb65ff0b..b92939afb03 100644 --- a/src/Access/EnabledRowPolicies.h +++ b/src/Access/EnabledRowPolicies.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include namespace DB @@ -21,7 +21,7 @@ public: struct Params { UUID user_id; - std::vector enabled_roles; + boost::container::flat_set enabled_roles; auto toTuple() const { return std::tie(user_id, enabled_roles); } friend bool operator ==(const Params & lhs, const Params & rhs) { return lhs.toTuple() == rhs.toTuple(); } @@ -42,31 +42,32 @@ public: ASTPtr getCondition(const String & database, const String & table_name, ConditionType type) const; ASTPtr getCondition(const String & database, const String & table_name, ConditionType type, const ASTPtr & extra_condition) const; - /// Returns IDs of all the policies used by the current user. - std::vector getCurrentPolicyIDs() const; - - /// Returns IDs of the policies used by a concrete table. - std::vector getCurrentPolicyIDs(const String & database, const String & table_name) const; - private: friend class RowPolicyCache; EnabledRowPolicies(const Params & params_); - using DatabaseAndTableName = std::pair; - using DatabaseAndTableNameRef = std::pair; + struct MixedConditionKey + { + std::string_view database; + std::string_view table_name; + ConditionType condition_type; + + auto toTuple() const { return std::tie(database, table_name, condition_type); } + friend bool operator==(const MixedConditionKey & left, const MixedConditionKey & right) { return left.toTuple() == right.toTuple(); } + friend bool operator!=(const MixedConditionKey & left, const MixedConditionKey & right) { return left.toTuple() != right.toTuple(); } + }; + struct Hash { - size_t operator()(const DatabaseAndTableNameRef & database_and_table_name) const; + size_t operator()(const MixedConditionKey & key) const; }; - static constexpr size_t MAX_CONDITION_TYPE = RowPolicy::MAX_CONDITION_TYPE; - using ParsedConditions = std::array; - struct MixedConditions + + struct MixedCondition { - std::unique_ptr database_and_table_name_keeper; - ParsedConditions mixed_conditions; - std::vector policy_ids; + ASTPtr ast; + std::shared_ptr> database_and_table_name; }; - using MapOfMixedConditions = std::unordered_map; + using MapOfMixedConditions = std::unordered_map; const Params params; mutable boost::atomic_shared_ptr map_of_mixed_conditions; diff --git a/src/Access/EnabledSettings.h b/src/Access/EnabledSettings.h index d8e969d685d..8e92298328c 100644 --- a/src/Access/EnabledSettings.h +++ b/src/Access/EnabledSettings.h @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -17,7 +18,7 @@ public: struct Params { UUID user_id; - std::vector enabled_roles; + boost::container::flat_set enabled_roles; SettingsProfileElements settings_from_enabled_roles; SettingsProfileElements settings_from_user; diff --git a/src/Access/ExtendedRoleSet.cpp b/src/Access/ExtendedRoleSet.cpp index 145bd0fe7e5..a8e674b3722 100644 --- a/src/Access/ExtendedRoleSet.cpp +++ b/src/Access/ExtendedRoleSet.cpp @@ -1,3 +1,4 @@ + #include #include #include @@ -43,12 +44,6 @@ ExtendedRoleSet::ExtendedRoleSet(const std::vector & ids_) } -ExtendedRoleSet::ExtendedRoleSet(const boost::container::flat_set & ids_) -{ - add(ids_); -} - - ExtendedRoleSet::ExtendedRoleSet(const ASTExtendedRoleSet & ast) { init(ast, nullptr); @@ -73,15 +68,27 @@ void ExtendedRoleSet::init(const ASTExtendedRoleSet & ast, const AccessControlMa { all = ast.all; - auto name_to_id = [id_mode{ast.id_mode}, manager](const String & name) -> UUID + auto name_to_id = [&ast, manager](const String & name) -> UUID { - if (id_mode) + if (ast.id_mode) return parse(name); assert(manager); - auto id = manager->find(name); - if (id) - return *id; - return manager->getID(name); + if (ast.can_contain_users && ast.can_contain_roles) + { + auto id = manager->find(name); + if (id) + return *id; + return manager->getID(name); + } + else if (ast.can_contain_users) + { + return manager->getID(name); + } + else + { + assert(ast.can_contain_roles); + return manager->getID(name); + } }; if (!ast.names.empty() && !all) @@ -126,6 +133,7 @@ std::shared_ptr ExtendedRoleSet::toAST() const ast->names.reserve(ids.size()); for (const UUID & id : ids) ast->names.emplace_back(::DB::toString(id)); + boost::range::sort(ast->names); } if (!except_ids.empty()) @@ -133,32 +141,13 @@ std::shared_ptr ExtendedRoleSet::toAST() const ast->except_names.reserve(except_ids.size()); for (const UUID & except_id : except_ids) ast->except_names.emplace_back(::DB::toString(except_id)); + boost::range::sort(ast->except_names); } return ast; } -String ExtendedRoleSet::toString() const -{ - auto ast = toAST(); - return serializeAST(*ast); -} - - -Strings ExtendedRoleSet::toStrings() const -{ - if (all || !except_ids.empty()) - return {toString()}; - - Strings names; - names.reserve(ids.size()); - for (const UUID & id : ids) - names.emplace_back(::DB::toString(id)); - return names; -} - - std::shared_ptr ExtendedRoleSet::toASTWithNames(const AccessControlManager & manager) const { auto ast = std::make_shared(); @@ -192,6 +181,13 @@ std::shared_ptr ExtendedRoleSet::toASTWithNames(const Access } +String ExtendedRoleSet::toString() const +{ + auto ast = toAST(); + return serializeAST(*ast); +} + + String ExtendedRoleSet::toStringWithNames(const AccessControlManager & manager) const { auto ast = toASTWithNames(manager); @@ -201,19 +197,39 @@ String ExtendedRoleSet::toStringWithNames(const AccessControlManager & manager) Strings ExtendedRoleSet::toStringsWithNames(const AccessControlManager & manager) const { - if (all || !except_ids.empty()) - return {toStringWithNames(manager)}; + if (!all && ids.empty()) + return {}; - Strings names; - names.reserve(ids.size()); - for (const UUID & id : ids) + Strings res; + res.reserve(ids.size() + except_ids.size()); + + if (all) + res.emplace_back("ALL"); + else { - auto name = manager.tryReadName(id); - if (name) - names.emplace_back(std::move(*name)); + for (const UUID & id : ids) + { + auto name = manager.tryReadName(id); + if (name) + res.emplace_back(std::move(*name)); + } + std::sort(res.begin(), res.end()); } - boost::range::sort(names); - return names; + + if (!except_ids.empty()) + { + res.emplace_back("EXCEPT"); + size_t old_size = res.size(); + for (const UUID & id : except_ids) + { + auto name = manager.tryReadName(id); + if (name) + res.emplace_back(std::move(*name)); + } + std::sort(res.begin() + old_size, res.end()); + } + + return res; } @@ -244,38 +260,12 @@ void ExtendedRoleSet::add(const std::vector & ids_) } -void ExtendedRoleSet::add(const boost::container::flat_set & ids_) -{ - for (const auto & id : ids_) - add(id); -} - - bool ExtendedRoleSet::match(const UUID & id) const { return (all || ids.count(id)) && !except_ids.count(id); } -bool ExtendedRoleSet::match(const UUID & user_id, const std::vector & enabled_roles) const -{ - if (!all && !ids.count(user_id)) - { - bool found_enabled_role = std::any_of( - enabled_roles.begin(), enabled_roles.end(), [this](const UUID & enabled_role) { return ids.count(enabled_role); }); - if (!found_enabled_role) - return false; - } - - if (except_ids.count(user_id)) - return false; - - bool in_except_list = std::any_of( - enabled_roles.begin(), enabled_roles.end(), [this](const UUID & enabled_role) { return except_ids.count(enabled_role); }); - return !in_except_list; -} - - bool ExtendedRoleSet::match(const UUID & user_id, const boost::container::flat_set & enabled_roles) const { if (!all && !ids.count(user_id)) diff --git a/src/Access/ExtendedRoleSet.h b/src/Access/ExtendedRoleSet.h index 486b4277337..eeb4af84f78 100644 --- a/src/Access/ExtendedRoleSet.h +++ b/src/Access/ExtendedRoleSet.h @@ -28,7 +28,6 @@ struct ExtendedRoleSet ExtendedRoleSet(const UUID & id); ExtendedRoleSet(const std::vector & ids_); - ExtendedRoleSet(const boost::container::flat_set & ids_); /// The constructor from AST requires the AccessControlManager if `ast.id_mode == false`. ExtendedRoleSet(const ASTExtendedRoleSet & ast); @@ -37,10 +36,9 @@ struct ExtendedRoleSet ExtendedRoleSet(const ASTExtendedRoleSet & ast, const AccessControlManager & manager, const std::optional & current_user_id); std::shared_ptr toAST() const; - String toString() const; - Strings toStrings() const; - std::shared_ptr toASTWithNames(const AccessControlManager & manager) const; + + String toString() const; String toStringWithNames(const AccessControlManager & manager) const; Strings toStringsWithNames(const AccessControlManager & manager) const; @@ -48,11 +46,9 @@ struct ExtendedRoleSet void clear(); void add(const UUID & id); void add(const std::vector & ids_); - void add(const boost::container::flat_set & ids_); /// Checks if a specified ID matches this ExtendedRoleSet. bool match(const UUID & id) const; - bool match(const UUID & user_id, const std::vector & enabled_roles) const; bool match(const UUID & user_id, const boost::container::flat_set & enabled_roles) const; /// Returns a list of matching IDs. The function must not be called if `all` == `true`. diff --git a/src/Access/GrantedAccess.cpp b/src/Access/GrantedAccess.cpp new file mode 100644 index 00000000000..2af1e0b44ec --- /dev/null +++ b/src/Access/GrantedAccess.cpp @@ -0,0 +1,22 @@ +#include + + +namespace DB +{ + +GrantedAccess::GrantsAndPartialRevokes GrantedAccess::getGrantsAndPartialRevokes() const +{ + GrantsAndPartialRevokes res; + res.grants_with_grant_option = access_with_grant_option.getGrants(); + AccessRights access_without_gg = access; + access_without_gg.revoke(res.grants_with_grant_option); + auto gr = access_without_gg.getGrantsAndPartialRevokes(); + res.grants = std::move(gr.grants); + res.revokes = std::move(gr.revokes); + AccessRights access_with_grant_options_without_r = access_with_grant_option; + access_with_grant_options_without_r.grant(res.revokes); + res.revokes_grant_option = access_with_grant_options_without_r.getPartialRevokes(); + return res; +} + +} diff --git a/src/Access/GrantedAccess.h b/src/Access/GrantedAccess.h new file mode 100644 index 00000000000..b8f6bdfe8fb --- /dev/null +++ b/src/Access/GrantedAccess.h @@ -0,0 +1,55 @@ +#pragma once + +#include + + +namespace DB +{ +/// Access rights as they are granted to a role or user. +/// Stores both the access rights themselves and the access rights with grant option. +struct GrantedAccess +{ + AccessRights access; + AccessRights access_with_grant_option; + + template + void grant(const Args &... args) + { + access.grant(args...); + } + + template + void grantWithGrantOption(const Args &... args) + { + access.grant(args...); + access_with_grant_option.grant(args...); + } + + template + void revoke(const Args &... args) + { + access.revoke(args...); + access_with_grant_option.revoke(args...); + } + + template + void revokeGrantOption(const Args &... args) + { + access_with_grant_option.revoke(args...); + } + + struct GrantsAndPartialRevokes + { + AccessRightsElements grants; + AccessRightsElements revokes; + AccessRightsElements grants_with_grant_option; + AccessRightsElements revokes_grant_option; + }; + + /// Retrieves the information about grants and partial revokes. + GrantsAndPartialRevokes getGrantsAndPartialRevokes() const; + + friend bool operator ==(const GrantedAccess & left, const GrantedAccess & right) { return (left.access == right.access) && (left.access_with_grant_option == right.access_with_grant_option); } + friend bool operator !=(const GrantedAccess & left, const GrantedAccess & right) { return !(left == right); } +}; +} diff --git a/src/Access/GrantedRoles.cpp b/src/Access/GrantedRoles.cpp new file mode 100644 index 00000000000..4d7007c4db6 --- /dev/null +++ b/src/Access/GrantedRoles.cpp @@ -0,0 +1,64 @@ +#include +#include + + +namespace DB +{ +void GrantedRoles::grant(const UUID & role) +{ + roles.insert(role); +} + +void GrantedRoles::grant(const std::vector & roles_) +{ + for (const UUID & role : roles_) + grant(role); +} + +void GrantedRoles::grantWithAdminOption(const UUID & role) +{ + roles.insert(role); + roles_with_admin_option.insert(role); +} + +void GrantedRoles::grantWithAdminOption(const std::vector & roles_) +{ + for (const UUID & role : roles_) + grantWithAdminOption(role); +} + + +void GrantedRoles::revoke(const UUID & role) +{ + roles.erase(role); + roles_with_admin_option.erase(role); +} + +void GrantedRoles::revoke(const std::vector & roles_) +{ + for (const UUID & role : roles_) + revoke(role); +} + +void GrantedRoles::revokeAdminOption(const UUID & role) +{ + roles_with_admin_option.erase(role); +} + +void GrantedRoles::revokeAdminOption(const std::vector & roles_) +{ + for (const UUID & role : roles_) + revokeAdminOption(role); +} + + +GrantedRoles::Grants GrantedRoles::getGrants() const +{ + Grants res; + res.grants_with_admin_option.insert(res.grants_with_admin_option.end(), roles_with_admin_option.begin(), roles_with_admin_option.end()); + res.grants.reserve(roles.size() - roles_with_admin_option.size()); + boost::range::set_difference(roles, roles_with_admin_option, std::back_inserter(res.grants)); + return res; +} + +} diff --git a/src/Access/GrantedRoles.h b/src/Access/GrantedRoles.h new file mode 100644 index 00000000000..fd091755a80 --- /dev/null +++ b/src/Access/GrantedRoles.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include + + +namespace DB +{ +/// Roles when they are granted to a role or user. +/// Stores both the roles themselves and the roles with admin option. +struct GrantedRoles +{ + boost::container::flat_set roles; + boost::container::flat_set roles_with_admin_option; + + void grant(const UUID & role); + void grant(const std::vector & roles_); + void grantWithAdminOption(const UUID & role); + void grantWithAdminOption(const std::vector & roles_); + + void revoke(const UUID & role); + void revoke(const std::vector & roles_); + void revokeAdminOption(const UUID & role); + void revokeAdminOption(const std::vector & roles_); + + struct Grants + { + std::vector grants; + std::vector grants_with_admin_option; + }; + + /// Retrieves the information about grants. + Grants getGrants() const; + + friend bool operator ==(const GrantedRoles & left, const GrantedRoles & right) { return (left.roles == right.roles) && (left.roles_with_admin_option == right.roles_with_admin_option); } + friend bool operator !=(const GrantedRoles & left, const GrantedRoles & right) { return !(left == right); } +}; +} diff --git a/src/Access/IAccessEntity.cpp b/src/Access/IAccessEntity.cpp index 5dbc056b71c..5dc566fe456 100644 --- a/src/Access/IAccessEntity.cpp +++ b/src/Access/IAccessEntity.cpp @@ -1,48 +1,12 @@ #include -#include -#include -#include -#include -#include -#include namespace DB { -String IAccessEntity::getTypeName(std::type_index type) -{ - if (type == typeid(User)) - return "User"; - if (type == typeid(Quota)) - return "Quota"; - if (type == typeid(RowPolicy)) - return "Row policy"; - if (type == typeid(Role)) - return "Role"; - if (type == typeid(SettingsProfile)) - return "Settings profile"; - return demangle(type.name()); -} - - -const char * IAccessEntity::getKeyword(std::type_index type) -{ - if (type == typeid(User)) - return "USER"; - if (type == typeid(Quota)) - return "QUOTA"; - if (type == typeid(RowPolicy)) - return "ROW POLICY"; - if (type == typeid(Role)) - return "ROLE"; - if (type == typeid(SettingsProfile)) - return "SETTINGS PROFILE"; - __builtin_unreachable(); -} - bool IAccessEntity::equal(const IAccessEntity & other) const { - return (full_name == other.full_name) && (getType() == other.getType()); + return (name == other.name) && (getType() == other.getType()); } + } diff --git a/src/Access/IAccessEntity.h b/src/Access/IAccessEntity.h index 9214d64aa8c..39a5cefa7d7 100644 --- a/src/Access/IAccessEntity.h +++ b/src/Access/IAccessEntity.h @@ -2,12 +2,24 @@ #include #include +#include +#include #include -#include namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_USER; + extern const int UNKNOWN_ROLE; + extern const int UNKNOWN_ROW_POLICY; + extern const int UNKNOWN_QUOTA; + extern const int THERE_IS_NO_PROFILE; + extern const int LOGICAL_ERROR; +} + + /// Access entity is a set of data which have a name and a type. Access entity control something related to the access control. /// Entities can be stored to a file or another storage, see IAccessStorage. struct IAccessEntity @@ -17,35 +29,120 @@ struct IAccessEntity virtual ~IAccessEntity() = default; virtual std::shared_ptr clone() const = 0; - std::type_index getType() const { return typeid(*this); } - static String getTypeName(std::type_index type); - const String getTypeName() const { return getTypeName(getType()); } - static const char * getKeyword(std::type_index type); - const char * getKeyword() const { return getKeyword(getType()); } + enum class Type + { + USER, + ROLE, + SETTINGS_PROFILE, + ROW_POLICY, + QUOTA, - template - bool isTypeOf() const { return isTypeOf(typeid(EntityType)); } - bool isTypeOf(std::type_index type) const { return type == getType(); } + MAX, + }; - virtual void setName(const String & name_) { full_name = name_; } - virtual String getName() const { return full_name; } - String getFullName() const { return full_name; } + virtual Type getType() const = 0; + + struct TypeInfo + { + const char * const raw_name; + const String name; /// Uppercased with spaces instead of underscores, e.g. "SETTINGS PROFILE". + const String alias; /// Alias of the keyword or empty string, e.g. "PROFILE". + const String name_for_output_with_entity_name; /// Lowercased with spaces instead of underscores, e.g. "settings profile". + const char unique_char; /// Unique character for this type. E.g. 'P' for SETTINGS_PROFILE. + const String list_filename; /// Name of the file containing list of objects of this type, including the file extension ".list". + const int not_found_error_code; + + static const TypeInfo & get(Type type_); + String outputWithEntityName(const String & entity_name) const; + }; + + const TypeInfo & getTypeInfo() const { return TypeInfo::get(getType()); } + String outputTypeAndName() const { return getTypeInfo().outputWithEntityName(getName()); } + + template + bool isTypeOf() const { return isTypeOf(EntityClassT::TYPE); } + bool isTypeOf(Type type) const { return type == getType(); } + + virtual void setName(const String & name_) { name = name_; } + const String & getName() const { return name; } friend bool operator ==(const IAccessEntity & lhs, const IAccessEntity & rhs) { return lhs.equal(rhs); } friend bool operator !=(const IAccessEntity & lhs, const IAccessEntity & rhs) { return !(lhs == rhs); } protected: - String full_name; + String name; virtual bool equal(const IAccessEntity & other) const; /// Helper function to define clone() in the derived classes. - template + template std::shared_ptr cloneImpl() const { - return std::make_shared(typeid_cast(*this)); + return std::make_shared(typeid_cast(*this)); } }; using AccessEntityPtr = std::shared_ptr; + + +inline const IAccessEntity::TypeInfo & IAccessEntity::TypeInfo::get(Type type_) +{ + static constexpr auto make_info = [](const char * raw_name_, char unique_char_, const char * list_filename_, int not_found_error_code_) + { + String init_name = raw_name_; + boost::to_upper(init_name); + boost::replace_all(init_name, "_", " "); + String init_alias; + if (auto underscore_pos = init_name.find_first_of(" "); underscore_pos != String::npos) + init_alias = init_name.substr(underscore_pos + 1); + String init_name_for_output_with_entity_name = init_name; + boost::to_lower(init_name_for_output_with_entity_name); + return TypeInfo{raw_name_, std::move(init_name), std::move(init_alias), std::move(init_name_for_output_with_entity_name), unique_char_, list_filename_, not_found_error_code_}; + }; + + switch (type_) + { + case Type::USER: + { + static const auto info = make_info("USER", 'U', "users.list", ErrorCodes::UNKNOWN_USER); + return info; + } + case Type::ROLE: + { + static const auto info = make_info("ROLE", 'R', "roles.list", ErrorCodes::UNKNOWN_ROLE); + return info; + } + case Type::SETTINGS_PROFILE: + { + static const auto info = make_info("SETTINGS_PROFILE", 'S', "settings_profiles.list", ErrorCodes::THERE_IS_NO_PROFILE); + return info; + } + case Type::ROW_POLICY: + { + static const auto info = make_info("ROW_POLICY", 'P', "row_policies.list", ErrorCodes::UNKNOWN_ROW_POLICY); + return info; + } + case Type::QUOTA: + { + static const auto info = make_info("QUOTA", 'Q', "quotas.list", ErrorCodes::UNKNOWN_QUOTA); + return info; + } + case Type::MAX: break; + } + throw Exception("Unknown type: " + std::to_string(static_cast(type_)), ErrorCodes::LOGICAL_ERROR); +} + +inline String IAccessEntity::TypeInfo::outputWithEntityName(const String & entity_name) const +{ + String msg = name_for_output_with_entity_name; + msg += " "; + msg += backQuote(entity_name); + return msg; +} + +inline String toString(IAccessEntity::Type type) +{ + return IAccessEntity::TypeInfo::get(type).name; +} + } diff --git a/src/Access/IAccessStorage.cpp b/src/Access/IAccessStorage.cpp index 3dfc3e232ba..a7af61c7712 100644 --- a/src/Access/IAccessStorage.cpp +++ b/src/Access/IAccessStorage.cpp @@ -12,28 +12,45 @@ namespace DB { namespace ErrorCodes { - extern const int BAD_CAST; - extern const int ACCESS_ENTITY_NOT_FOUND; extern const int ACCESS_ENTITY_ALREADY_EXISTS; + extern const int ACCESS_ENTITY_NOT_FOUND; extern const int ACCESS_STORAGE_READONLY; - extern const int UNKNOWN_USER; - extern const int UNKNOWN_ROLE; + extern const int LOGICAL_ERROR; } -std::vector IAccessStorage::findAll(std::type_index type) const +namespace +{ + using EntityType = IAccessStorage::EntityType; + using EntityTypeInfo = IAccessStorage::EntityTypeInfo; + + bool isNotFoundErrorCode(int error_code) + { + if (error_code == ErrorCodes::ACCESS_ENTITY_NOT_FOUND) + return true; + + for (auto type : ext::range(EntityType::MAX)) + if (error_code == EntityTypeInfo::get(type).not_found_error_code) + return true; + + return false; + } +} + + +std::vector IAccessStorage::findAll(EntityType type) const { return findAllImpl(type); } -std::optional IAccessStorage::find(std::type_index type, const String & name) const +std::optional IAccessStorage::find(EntityType type, const String & name) const { return findImpl(type, name); } -std::vector IAccessStorage::find(std::type_index type, const Strings & names) const +std::vector IAccessStorage::find(EntityType type, const Strings & names) const { std::vector ids; ids.reserve(names.size()); @@ -47,7 +64,7 @@ std::vector IAccessStorage::find(std::type_index type, const Strings & nam } -UUID IAccessStorage::getID(std::type_index type, const String & name) const +UUID IAccessStorage::getID(EntityType type, const String & name) const { auto id = findImpl(type, name); if (id) @@ -56,7 +73,7 @@ UUID IAccessStorage::getID(std::type_index type, const String & name) const } -std::vector IAccessStorage::getIDs(std::type_index type, const Strings & names) const +std::vector IAccessStorage::getIDs(EntityType type, const Strings & names) const { std::vector ids; ids.reserve(names.size()); @@ -190,6 +207,7 @@ void IAccessStorage::remove(const UUID & id) void IAccessStorage::remove(const std::vector & ids) { String error_message; + std::optional error_code; for (const auto & id : ids) { try @@ -198,13 +216,17 @@ void IAccessStorage::remove(const std::vector & ids) } catch (Exception & e) { - if (e.code() != ErrorCodes::ACCESS_ENTITY_NOT_FOUND) + if (!isNotFoundErrorCode(e.code())) throw; error_message += (error_message.empty() ? "" : ". ") + e.message(); + if (error_code && (*error_code != e.code())) + error_code = ErrorCodes::ACCESS_ENTITY_NOT_FOUND; + else + error_code = e.code(); } } if (!error_message.empty()) - throw Exception(error_message, ErrorCodes::ACCESS_ENTITY_NOT_FOUND); + throw Exception(error_message, *error_code); } @@ -250,6 +272,7 @@ void IAccessStorage::update(const UUID & id, const UpdateFunc & update_func) void IAccessStorage::update(const std::vector & ids, const UpdateFunc & update_func) { String error_message; + std::optional error_code; for (const auto & id : ids) { try @@ -258,13 +281,17 @@ void IAccessStorage::update(const std::vector & ids, const UpdateFunc & up } catch (Exception & e) { - if (e.code() != ErrorCodes::ACCESS_ENTITY_NOT_FOUND) + if (!isNotFoundErrorCode(e.code())) throw; error_message += (error_message.empty() ? "" : ". ") + e.message(); + if (error_code && (*error_code != e.code())) + error_code = ErrorCodes::ACCESS_ENTITY_NOT_FOUND; + else + error_code = e.code(); } } if (!error_message.empty()) - throw Exception(error_message, ErrorCodes::ACCESS_ENTITY_NOT_FOUND); + throw Exception(error_message, *error_code); } @@ -301,7 +328,7 @@ std::vector IAccessStorage::tryUpdate(const std::vector & ids, const } -ext::scope_guard IAccessStorage::subscribeForChanges(std::type_index type, const OnChangedHandler & handler) const +ext::scope_guard IAccessStorage::subscribeForChanges(EntityType type, const OnChangedHandler & handler) const { return subscribeForChangesImpl(type, handler); } @@ -322,7 +349,7 @@ ext::scope_guard IAccessStorage::subscribeForChanges(const std::vector & i } -bool IAccessStorage::hasSubscription(std::type_index type) const +bool IAccessStorage::hasSubscription(EntityType type) const { return hasSubscriptionImpl(type); } @@ -361,79 +388,72 @@ Poco::Logger * IAccessStorage::getLogger() const void IAccessStorage::throwNotFound(const UUID & id) const { - throw Exception("ID {" + toString(id) + "} not found in " + getStorageName(), ErrorCodes::ACCESS_ENTITY_NOT_FOUND); + throw Exception("ID {" + toString(id) + "} not found in [" + getStorageName() + "]", ErrorCodes::ACCESS_ENTITY_NOT_FOUND); } -void IAccessStorage::throwNotFound(std::type_index type, const String & name) const +void IAccessStorage::throwNotFound(EntityType type, const String & name) const { - int error_code; - if (type == typeid(User)) - error_code = ErrorCodes::UNKNOWN_USER; - else if (type == typeid(Role)) - error_code = ErrorCodes::UNKNOWN_ROLE; - else - error_code = ErrorCodes::ACCESS_ENTITY_NOT_FOUND; - - throw Exception(getTypeName(type) + " " + backQuote(name) + " not found in " + getStorageName(), error_code); + int error_code = EntityTypeInfo::get(type).not_found_error_code; + throw Exception("There is no " + outputEntityTypeAndName(type, name) + " in [" + getStorageName() + "]", error_code); } -void IAccessStorage::throwBadCast(const UUID & id, std::type_index type, const String & name, std::type_index required_type) +void IAccessStorage::throwBadCast(const UUID & id, EntityType type, const String & name, EntityType required_type) { throw Exception( - "ID {" + toString(id) + "}: " + getTypeName(type) + backQuote(name) + " expected to be of type " + getTypeName(required_type), - ErrorCodes::BAD_CAST); + "ID {" + toString(id) + "}: " + outputEntityTypeAndName(type, name) + " expected to be of type " + toString(required_type), + ErrorCodes::LOGICAL_ERROR); } -void IAccessStorage::throwIDCollisionCannotInsert(const UUID & id, std::type_index type, const String & name, std::type_index existing_type, const String & existing_name) const +void IAccessStorage::throwIDCollisionCannotInsert(const UUID & id, EntityType type, const String & name, EntityType existing_type, const String & existing_name) const { throw Exception( - getTypeName(type) + " " + backQuote(name) + ": cannot insert because the ID {" + toString(id) + "} is already used by " - + getTypeName(existing_type) + " " + backQuote(existing_name) + " in " + getStorageName(), + outputEntityTypeAndName(type, name) + ": cannot insert because the ID {" + toString(id) + "} is already used by " + + outputEntityTypeAndName(existing_type, existing_name) + " in [" + getStorageName() + "]", ErrorCodes::ACCESS_ENTITY_ALREADY_EXISTS); } -void IAccessStorage::throwNameCollisionCannotInsert(std::type_index type, const String & name) const +void IAccessStorage::throwNameCollisionCannotInsert(EntityType type, const String & name) const { throw Exception( - getTypeName(type) + " " + backQuote(name) + ": cannot insert because " + getTypeName(type) + " " + backQuote(name) - + " already exists in " + getStorageName(), + outputEntityTypeAndName(type, name) + ": cannot insert because " + outputEntityTypeAndName(type, name) + " already exists in [" + + getStorageName() + "]", ErrorCodes::ACCESS_ENTITY_ALREADY_EXISTS); } -void IAccessStorage::throwNameCollisionCannotRename(std::type_index type, const String & old_name, const String & new_name) const +void IAccessStorage::throwNameCollisionCannotRename(EntityType type, const String & old_name, const String & new_name) const { throw Exception( - getTypeName(type) + " " + backQuote(old_name) + ": cannot rename to " + backQuote(new_name) + " because " + getTypeName(type) + " " - + backQuote(new_name) + " already exists in " + getStorageName(), + outputEntityTypeAndName(type, old_name) + ": cannot rename to " + backQuote(new_name) + " because " + + outputEntityTypeAndName(type, new_name) + " already exists in [" + getStorageName() + "]", ErrorCodes::ACCESS_ENTITY_ALREADY_EXISTS); } -void IAccessStorage::throwReadonlyCannotInsert(std::type_index type, const String & name) const +void IAccessStorage::throwReadonlyCannotInsert(EntityType type, const String & name) const { throw Exception( - "Cannot insert " + getTypeName(type) + " " + backQuote(name) + " to " + getStorageName() + " because this storage is readonly", + "Cannot insert " + outputEntityTypeAndName(type, name) + " to [" + getStorageName() + "] because this storage is readonly", ErrorCodes::ACCESS_STORAGE_READONLY); } -void IAccessStorage::throwReadonlyCannotUpdate(std::type_index type, const String & name) const +void IAccessStorage::throwReadonlyCannotUpdate(EntityType type, const String & name) const { throw Exception( - "Cannot update " + getTypeName(type) + " " + backQuote(name) + " in " + getStorageName() + " because this storage is readonly", + "Cannot update " + outputEntityTypeAndName(type, name) + " in [" + getStorageName() + "] because this storage is readonly", ErrorCodes::ACCESS_STORAGE_READONLY); } -void IAccessStorage::throwReadonlyCannotRemove(std::type_index type, const String & name) const +void IAccessStorage::throwReadonlyCannotRemove(EntityType type, const String & name) const { throw Exception( - "Cannot remove " + getTypeName(type) + " " + backQuote(name) + " from " + getStorageName() + " because this storage is readonly", + "Cannot remove " + outputEntityTypeAndName(type, name) + " from [" + getStorageName() + "] because this storage is readonly", ErrorCodes::ACCESS_STORAGE_READONLY); } } diff --git a/src/Access/IAccessStorage.h b/src/Access/IAccessStorage.h index 30a1a6bdc32..081fed87bd2 100644 --- a/src/Access/IAccessStorage.h +++ b/src/Access/IAccessStorage.h @@ -25,50 +25,53 @@ public: /// Returns the name of this storage. const String & getStorageName() const { return storage_name; } - /// Returns the identifiers of all the entities of a specified type contained in the storage. - std::vector findAll(std::type_index type) const; + using EntityType = IAccessEntity::Type; + using EntityTypeInfo = IAccessEntity::TypeInfo; - template - std::vector findAll() const { return findAll(typeid(EntityType)); } + /// Returns the identifiers of all the entities of a specified type contained in the storage. + std::vector findAll(EntityType type) const; + + template + std::vector findAll() const { return findAll(EntityClassT::TYPE); } /// Searchs for an entity with specified type and name. Returns std::nullopt if not found. - std::optional find(std::type_index type, const String & name) const; + std::optional find(EntityType type, const String & name) const; - template - std::optional find(const String & name) const { return find(typeid(EntityType), name); } + template + std::optional find(const String & name) const { return find(EntityClassT::TYPE, name); } - std::vector find(std::type_index type, const Strings & names) const; + std::vector find(EntityType type, const Strings & names) const; - template - std::vector find(const Strings & names) const { return find(typeid(EntityType), names); } + template + std::vector find(const Strings & names) const { return find(EntityClassT::TYPE, names); } /// Searchs for an entity with specified name and type. Throws an exception if not found. - UUID getID(std::type_index type, const String & name) const; + UUID getID(EntityType type, const String & name) const; - template - UUID getID(const String & name) const { return getID(typeid(EntityType), name); } + template + UUID getID(const String & name) const { return getID(EntityClassT::TYPE, name); } - std::vector getIDs(std::type_index type, const Strings & names) const; + std::vector getIDs(EntityType type, const Strings & names) const; - template - std::vector getIDs(const Strings & names) const { return getIDs(typeid(EntityType), names); } + template + std::vector getIDs(const Strings & names) const { return getIDs(EntityClassT::TYPE, names); } /// Returns whether there is an entity with such identifier in the storage. bool exists(const UUID & id) const; /// Reads an entity. Throws an exception if not found. - template - std::shared_ptr read(const UUID & id) const; + template + std::shared_ptr read(const UUID & id) const; - template - std::shared_ptr read(const String & name) const; + template + std::shared_ptr read(const String & name) const; /// Reads an entity. Returns nullptr if not found. - template - std::shared_ptr tryRead(const UUID & id) const; + template + std::shared_ptr tryRead(const UUID & id) const; - template - std::shared_ptr tryRead(const String & name) const; + template + std::shared_ptr tryRead(const String & name) const; /// Reads only name of an entity. String readName(const UUID & id) const; @@ -118,22 +121,22 @@ public: /// Subscribes for all changes. /// Can return nullptr if cannot subscribe (identifier not found) or if it doesn't make sense (the storage is read-only). - ext::scope_guard subscribeForChanges(std::type_index type, const OnChangedHandler & handler) const; + ext::scope_guard subscribeForChanges(EntityType type, const OnChangedHandler & handler) const; - template - ext::scope_guard subscribeForChanges(OnChangedHandler handler) const { return subscribeForChanges(typeid(EntityType), handler); } + template + ext::scope_guard subscribeForChanges(OnChangedHandler handler) const { return subscribeForChanges(EntityClassT::TYPE, handler); } /// Subscribes for changes of a specific entry. /// Can return nullptr if cannot subscribe (identifier not found) or if it doesn't make sense (the storage is read-only). ext::scope_guard subscribeForChanges(const UUID & id, const OnChangedHandler & handler) const; ext::scope_guard subscribeForChanges(const std::vector & ids, const OnChangedHandler & handler) const; - bool hasSubscription(std::type_index type) const; + bool hasSubscription(EntityType type) const; bool hasSubscription(const UUID & id) const; protected: - virtual std::optional findImpl(std::type_index type, const String & name) const = 0; - virtual std::vector findAllImpl(std::type_index type) const = 0; + virtual std::optional findImpl(EntityType type, const String & name) const = 0; + virtual std::vector findAllImpl(EntityType type) const = 0; virtual bool existsImpl(const UUID & id) const = 0; virtual AccessEntityPtr readImpl(const UUID & id) const = 0; virtual String readNameImpl(const UUID & id) const = 0; @@ -142,23 +145,23 @@ protected: virtual void removeImpl(const UUID & id) = 0; virtual void updateImpl(const UUID & id, const UpdateFunc & update_func) = 0; virtual ext::scope_guard subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const = 0; - virtual ext::scope_guard subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const = 0; + virtual ext::scope_guard subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const = 0; virtual bool hasSubscriptionImpl(const UUID & id) const = 0; - virtual bool hasSubscriptionImpl(std::type_index type) const = 0; + virtual bool hasSubscriptionImpl(EntityType type) const = 0; static UUID generateRandomID(); Poco::Logger * getLogger() const; - static String getTypeName(std::type_index type) { return IAccessEntity::getTypeName(type); } + static String outputEntityTypeAndName(EntityType type, const String & name) { return EntityTypeInfo::get(type).outputWithEntityName(name); } [[noreturn]] void throwNotFound(const UUID & id) const; - [[noreturn]] void throwNotFound(std::type_index type, const String & name) const; - [[noreturn]] static void throwBadCast(const UUID & id, std::type_index type, const String & name, std::type_index required_type); + [[noreturn]] void throwNotFound(EntityType type, const String & name) const; + [[noreturn]] static void throwBadCast(const UUID & id, EntityType type, const String & name, EntityType required_type); [[noreturn]] void throwIDCollisionCannotInsert( - const UUID & id, std::type_index type, const String & name, std::type_index existing_type, const String & existing_name) const; - [[noreturn]] void throwNameCollisionCannotInsert(std::type_index type, const String & name) const; - [[noreturn]] void throwNameCollisionCannotRename(std::type_index type, const String & old_name, const String & new_name) const; - [[noreturn]] void throwReadonlyCannotInsert(std::type_index type, const String & name) const; - [[noreturn]] void throwReadonlyCannotUpdate(std::type_index type, const String & name) const; - [[noreturn]] void throwReadonlyCannotRemove(std::type_index type, const String & name) const; + const UUID & id, EntityType type, const String & name, EntityType existing_type, const String & existing_name) const; + [[noreturn]] void throwNameCollisionCannotInsert(EntityType type, const String & name) const; + [[noreturn]] void throwNameCollisionCannotRename(EntityType type, const String & old_name, const String & new_name) const; + [[noreturn]] void throwReadonlyCannotInsert(EntityType type, const String & name) const; + [[noreturn]] void throwReadonlyCannotUpdate(EntityType type, const String & name) const; + [[noreturn]] void throwReadonlyCannotRemove(EntityType type, const String & name) const; using Notification = std::tuple; using Notifications = std::vector; @@ -172,38 +175,43 @@ private: }; -template -std::shared_ptr IAccessStorage::read(const UUID & id) const +template +std::shared_ptr IAccessStorage::read(const UUID & id) const { auto entity = readImpl(id); - auto ptr = typeid_cast>(entity); - if (ptr) - return ptr; - throwBadCast(id, entity->getType(), entity->getFullName(), typeid(EntityType)); + if constexpr (std::is_same_v) + return entity; + else + { + auto ptr = typeid_cast>(entity); + if (ptr) + return ptr; + throwBadCast(id, entity->getType(), entity->getName(), EntityClassT::TYPE); + } } -template -std::shared_ptr IAccessStorage::read(const String & name) const +template +std::shared_ptr IAccessStorage::read(const String & name) const { - return read(getID(name)); + return read(getID(name)); } -template -std::shared_ptr IAccessStorage::tryRead(const UUID & id) const +template +std::shared_ptr IAccessStorage::tryRead(const UUID & id) const { auto entity = tryReadBase(id); if (!entity) return nullptr; - return typeid_cast>(entity); + return typeid_cast>(entity); } -template -std::shared_ptr IAccessStorage::tryRead(const String & name) const +template +std::shared_ptr IAccessStorage::tryRead(const String & name) const { - auto id = find(name); - return id ? tryRead(*id) : nullptr; + auto id = find(name); + return id ? tryRead(*id) : nullptr; } } diff --git a/src/Access/MemoryAccessStorage.cpp b/src/Access/MemoryAccessStorage.cpp index ce668bcd8b3..720b82796b7 100644 --- a/src/Access/MemoryAccessStorage.cpp +++ b/src/Access/MemoryAccessStorage.cpp @@ -1,6 +1,8 @@ #include #include -#include +#include +#include +#include namespace DB @@ -11,11 +13,12 @@ MemoryAccessStorage::MemoryAccessStorage(const String & storage_name_) } -std::optional MemoryAccessStorage::findImpl(std::type_index type, const String & name) const +std::optional MemoryAccessStorage::findImpl(EntityType type, const String & name) const { std::lock_guard lock{mutex}; - auto it = names.find({name, type}); - if (it == names.end()) + const auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + auto it = entries_by_name.find(name); + if (it == entries_by_name.end()) return {}; Entry & entry = *(it->second); @@ -23,12 +26,12 @@ std::optional MemoryAccessStorage::findImpl(std::type_index type, const St } -std::vector MemoryAccessStorage::findAllImpl(std::type_index type) const +std::vector MemoryAccessStorage::findAllImpl(EntityType type) const { std::lock_guard lock{mutex}; std::vector result; - result.reserve(entries.size()); - for (const auto & [id, entry] : entries) + result.reserve(entries_by_id.size()); + for (const auto & [id, entry] : entries_by_id) if (entry.entity->isTypeOf(type)) result.emplace_back(id); return result; @@ -38,15 +41,15 @@ std::vector MemoryAccessStorage::findAllImpl(std::type_index type) const bool MemoryAccessStorage::existsImpl(const UUID & id) const { std::lock_guard lock{mutex}; - return entries.count(id); + return entries_by_id.count(id); } AccessEntityPtr MemoryAccessStorage::readImpl(const UUID & id) const { std::lock_guard lock{mutex}; - auto it = entries.find(id); - if (it == entries.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); const Entry & entry = it->second; return entry.entity; @@ -55,7 +58,7 @@ AccessEntityPtr MemoryAccessStorage::readImpl(const UUID & id) const String MemoryAccessStorage::readNameImpl(const UUID & id) const { - return readImpl(id)->getFullName(); + return readImpl(id)->getName(); } @@ -73,19 +76,20 @@ UUID MemoryAccessStorage::insertImpl(const AccessEntityPtr & new_entity, bool re void MemoryAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & new_entity, bool replace_if_exists, Notifications & notifications) { - const String & name = new_entity->getFullName(); - std::type_index type = new_entity->getType(); + const String & name = new_entity->getName(); + EntityType type = new_entity->getType(); /// Check that we can insert. - auto it = entries.find(id); - if (it != entries.end()) + auto it = entries_by_id.find(id); + if (it != entries_by_id.end()) { const auto & existing_entry = it->second; - throwIDCollisionCannotInsert(id, type, name, existing_entry.entity->getType(), existing_entry.entity->getFullName()); + throwIDCollisionCannotInsert(id, type, name, existing_entry.entity->getType(), existing_entry.entity->getName()); } - auto it2 = names.find({name, type}); - if (it2 != names.end()) + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + auto it2 = entries_by_name.find(name); + if (it2 != entries_by_name.end()) { const auto & existing_entry = *(it2->second); if (replace_if_exists) @@ -95,10 +99,10 @@ void MemoryAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & } /// Do insertion. - auto & entry = entries[id]; + auto & entry = entries_by_id[id]; entry.id = id; entry.entity = new_entity; - names[std::pair{name, type}] = &entry; + entries_by_name[name] = &entry; prepareNotifications(entry, false, notifications); } @@ -115,19 +119,20 @@ void MemoryAccessStorage::removeImpl(const UUID & id) void MemoryAccessStorage::removeNoLock(const UUID & id, Notifications & notifications) { - auto it = entries.find(id); - if (it == entries.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); Entry & entry = it->second; - const String & name = entry.entity->getFullName(); - std::type_index type = entry.entity->getType(); + const String & name = entry.entity->getName(); + EntityType type = entry.entity->getType(); prepareNotifications(entry, true, notifications); /// Do removing. - names.erase({name, type}); - entries.erase(it); + auto & entries_by_name = entries_by_name_and_type[static_cast(type)]; + entries_by_name.erase(name); + entries_by_id.erase(it); } @@ -143,27 +148,30 @@ void MemoryAccessStorage::updateImpl(const UUID & id, const UpdateFunc & update_ void MemoryAccessStorage::updateNoLock(const UUID & id, const UpdateFunc & update_func, Notifications & notifications) { - auto it = entries.find(id); - if (it == entries.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) throwNotFound(id); Entry & entry = it->second; auto old_entity = entry.entity; auto new_entity = update_func(old_entity); + if (!new_entity->isTypeOf(old_entity->getType())) + throwBadCast(id, new_entity->getType(), new_entity->getName(), old_entity->getType()); + if (*new_entity == *old_entity) return; entry.entity = new_entity; - if (new_entity->getFullName() != old_entity->getFullName()) + if (new_entity->getName() != old_entity->getName()) { - auto it2 = names.find({new_entity->getFullName(), new_entity->getType()}); - if (it2 != names.end()) - throwNameCollisionCannotRename(old_entity->getType(), old_entity->getFullName(), new_entity->getFullName()); + auto & entries_by_name = entries_by_name_and_type[static_cast(old_entity->getType())]; + auto it2 = entries_by_name.find(new_entity->getName()); + if (it2 != entries_by_name.end()) + throwNameCollisionCannotRename(old_entity->getType(), old_entity->getName(), new_entity->getName()); - names.erase({old_entity->getFullName(), old_entity->getType()}); - names[std::pair{new_entity->getFullName(), new_entity->getType()}] = &entry; + entries_by_name[new_entity->getName()] = &entry; } prepareNotifications(entry, false, notifications); @@ -192,43 +200,47 @@ void MemoryAccessStorage::setAll(const std::vector> & all_entities, Notifications & notifications) { - /// Get list of the currently used IDs. Later we will remove those of them which are not used anymore. - std::unordered_set not_used_ids; - for (const auto & id_and_entry : entries) - not_used_ids.emplace(id_and_entry.first); + boost::container::flat_set not_used_ids; + std::vector conflicting_ids; - /// Remove conflicting entities. + /// Get the list of currently used IDs. Later we will remove those of them which are not used anymore. + for (const auto & id : entries_by_id | boost::adaptors::map_keys) + not_used_ids.emplace(id); + + /// Get the list of conflicting IDs and update the list of currently used ones. for (const auto & [id, entity] : all_entities) { - auto it = entries.find(id); - if (it != entries.end()) + auto it = entries_by_id.find(id); + if (it != entries_by_id.end()) { not_used_ids.erase(id); /// ID is used. + Entry & entry = it->second; if (entry.entity->getType() != entity->getType()) - { - removeNoLock(id, notifications); - continue; - } + conflicting_ids.emplace_back(id); /// Conflict: same ID, different type. } - auto it2 = names.find({entity->getFullName(), entity->getType()}); - if (it2 != names.end()) + + const auto & entries_by_name = entries_by_name_and_type[static_cast(entity->getType())]; + auto it2 = entries_by_name.find(entity->getName()); + if (it2 != entries_by_name.end()) { Entry & entry = *(it2->second); if (entry.id != id) - removeNoLock(id, notifications); + conflicting_ids.emplace_back(entry.id); /// Conflict: same name and type, different ID. } } - /// Remove entities which are not used anymore. - for (const auto & id : not_used_ids) + /// Remove entities which are not used anymore and which are in conflict with new entities. + boost::container::flat_set ids_to_remove = std::move(not_used_ids); + boost::range::copy(conflicting_ids, std::inserter(ids_to_remove, ids_to_remove.end())); + for (const auto & id : ids_to_remove) removeNoLock(id, notifications); /// Insert or update entities. for (const auto & [id, entity] : all_entities) { - auto it = entries.find(id); - if (it != entries.end()) + auto it = entries_by_id.find(id); + if (it != entries_by_id.end()) { if (*(it->second.entity) != *entity) { @@ -244,24 +256,27 @@ void MemoryAccessStorage::setAllNoLock(const std::vectorgetType()); - for (auto it = range.first; it != range.second; ++it) - notifications.push_back({it->second, entry.id, remove ? nullptr : entry.entity}); + for (const auto & handler : handlers_by_type[static_cast(entry.entity->getType())]) + notifications.push_back({handler, entry.id, entity}); } -ext::scope_guard MemoryAccessStorage::subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const +ext::scope_guard MemoryAccessStorage::subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const { std::lock_guard lock{mutex}; - auto handler_it = handlers_by_type.emplace(type, handler); + auto & handlers = handlers_by_type[static_cast(type)]; + handlers.push_back(handler); + auto handler_it = std::prev(handlers.end()); - return [this, handler_it] + return [this, type, handler_it] { std::lock_guard lock2{mutex}; - handlers_by_type.erase(handler_it); + auto & handlers2 = handlers_by_type[static_cast(type)]; + handlers2.erase(handler_it); }; } @@ -269,8 +284,8 @@ ext::scope_guard MemoryAccessStorage::subscribeForChangesImpl(std::type_index ty ext::scope_guard MemoryAccessStorage::subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const { std::lock_guard lock{mutex}; - auto it = entries.find(id); - if (it == entries.end()) + auto it = entries_by_id.find(id); + if (it == entries_by_id.end()) return {}; const Entry & entry = it->second; auto handler_it = entry.handlers_by_id.insert(entry.handlers_by_id.end(), handler); @@ -278,8 +293,8 @@ ext::scope_guard MemoryAccessStorage::subscribeForChangesImpl(const UUID & id, c return [this, id, handler_it] { std::lock_guard lock2{mutex}; - auto it2 = entries.find(id); - if (it2 != entries.end()) + auto it2 = entries_by_id.find(id); + if (it2 != entries_by_id.end()) { const Entry & entry2 = it2->second; entry2.handlers_by_id.erase(handler_it); @@ -291,8 +306,8 @@ ext::scope_guard MemoryAccessStorage::subscribeForChangesImpl(const UUID & id, c bool MemoryAccessStorage::hasSubscriptionImpl(const UUID & id) const { std::lock_guard lock{mutex}; - auto it = entries.find(id); - if (it != entries.end()) + auto it = entries_by_id.find(id); + if (it != entries_by_id.end()) { const Entry & entry = it->second; return !entry.handlers_by_id.empty(); @@ -301,10 +316,10 @@ bool MemoryAccessStorage::hasSubscriptionImpl(const UUID & id) const } -bool MemoryAccessStorage::hasSubscriptionImpl(std::type_index type) const +bool MemoryAccessStorage::hasSubscriptionImpl(EntityType type) const { std::lock_guard lock{mutex}; - auto range = handlers_by_type.equal_range(type); - return range.first != range.second; + const auto & handlers = handlers_by_type[static_cast(type)]; + return !handlers.empty(); } } diff --git a/src/Access/MemoryAccessStorage.h b/src/Access/MemoryAccessStorage.h index b93c2868d34..a2fdd0d0044 100644 --- a/src/Access/MemoryAccessStorage.h +++ b/src/Access/MemoryAccessStorage.h @@ -20,8 +20,8 @@ public: void setAll(const std::vector> & all_entities); private: - std::optional findImpl(std::type_index type, const String & name) const override; - std::vector findAllImpl(std::type_index type) const override; + std::optional findImpl(EntityType type, const String & name) const override; + std::vector findAllImpl(EntityType type) const override; bool existsImpl(const UUID & id) const override; AccessEntityPtr readImpl(const UUID & id) const override; String readNameImpl(const UUID & id) const override; @@ -30,9 +30,9 @@ private: void removeImpl(const UUID & id) override; void updateImpl(const UUID & id, const UpdateFunc & update_func) override; ext::scope_guard subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const override; - ext::scope_guard subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const override; + ext::scope_guard subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const override; bool hasSubscriptionImpl(const UUID & id) const override; - bool hasSubscriptionImpl(std::type_index type) const override; + bool hasSubscriptionImpl(EntityType type) const override; struct Entry { @@ -47,18 +47,9 @@ private: void setAllNoLock(const std::vector> & all_entities, Notifications & notifications); void prepareNotifications(const Entry & entry, bool remove, Notifications & notifications) const; - using NameTypePair = std::pair; - struct Hash - { - size_t operator()(const NameTypePair & key) const - { - return std::hash{}(key.first) - std::hash{}(key.second); - } - }; - mutable std::mutex mutex; - std::unordered_map entries; /// We want to search entries both by ID and by the pair of name and type. - std::unordered_map names; /// and by the pair of name and type. - mutable std::unordered_multimap handlers_by_type; + std::unordered_map entries_by_id; /// We want to search entries both by ID and by the pair of name and type. + std::unordered_map entries_by_name_and_type[static_cast(EntityType::MAX)]; + mutable std::list handlers_by_type[static_cast(EntityType::MAX)]; }; } diff --git a/src/Access/MultipleAccessStorage.cpp b/src/Access/MultipleAccessStorage.cpp index 740fe1dac04..9b80c16e487 100644 --- a/src/Access/MultipleAccessStorage.cpp +++ b/src/Access/MultipleAccessStorage.cpp @@ -38,7 +38,7 @@ MultipleAccessStorage::MultipleAccessStorage( } -std::vector MultipleAccessStorage::findMultiple(std::type_index type, const String & name) const +std::vector MultipleAccessStorage::findMultiple(EntityType type, const String & name) const { std::vector ids; for (const auto & nested_storage : nested_storages) @@ -55,7 +55,7 @@ std::vector MultipleAccessStorage::findMultiple(std::type_index type, cons } -std::optional MultipleAccessStorage::findImpl(std::type_index type, const String & name) const +std::optional MultipleAccessStorage::findImpl(EntityType type, const String & name) const { auto ids = findMultiple(type, name); if (ids.empty()) @@ -72,13 +72,13 @@ std::optional MultipleAccessStorage::findImpl(std::type_index type, const } throw Exception( - "Found " + getTypeName(type) + " " + backQuote(name) + " in " + std::to_string(ids.size()) - + " storages: " + joinStorageNames(storages_with_duplicates), + "Found " + outputEntityTypeAndName(type, name) + " in " + std::to_string(ids.size()) + + " storages [" + joinStorageNames(storages_with_duplicates) + "]", ErrorCodes::ACCESS_ENTITY_FOUND_DUPLICATES); } -std::vector MultipleAccessStorage::findAllImpl(std::type_index type) const +std::vector MultipleAccessStorage::findAllImpl(EntityType type) const { std::vector all_ids; for (const auto & nested_storage : nested_storages) @@ -143,6 +143,14 @@ const IAccessStorage & MultipleAccessStorage::getStorage(const UUID & id) const return const_cast(this)->getStorage(id); } +void MultipleAccessStorage::addStorage(std::unique_ptr nested_storage) +{ + /// Note that IStorage::storage_name is not changed. It is ok as this method + /// is considered as a temporary solution allowing third-party Arcadia applications + /// using CH as a library to register their own access storages. Do not remove + /// this method without providing any alternative :) + nested_storages.emplace_back(std::move(nested_storage)); +} AccessEntityPtr MultipleAccessStorage::readImpl(const UUID & id) const { @@ -180,11 +188,7 @@ UUID MultipleAccessStorage::insertImpl(const AccessEntityPtr & entity, bool repl } if (!nested_storage_for_insertion) - { - throw Exception( - "Not found a storage to insert " + entity->getTypeName() + backQuote(entity->getName()), - ErrorCodes::ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND); - } + throw Exception("Not found a storage to insert " + entity->outputTypeAndName(), ErrorCodes::ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND); auto id = replace_if_exists ? nested_storage_for_insertion->insertOrReplace(entity) : nested_storage_for_insertion->insert(entity); std::lock_guard lock{ids_cache_mutex}; @@ -214,7 +218,7 @@ ext::scope_guard MultipleAccessStorage::subscribeForChangesImpl(const UUID & id, } -ext::scope_guard MultipleAccessStorage::subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const +ext::scope_guard MultipleAccessStorage::subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const { ext::scope_guard subscriptions; for (const auto & nested_storage : nested_storages) @@ -234,7 +238,7 @@ bool MultipleAccessStorage::hasSubscriptionImpl(const UUID & id) const } -bool MultipleAccessStorage::hasSubscriptionImpl(std::type_index type) const +bool MultipleAccessStorage::hasSubscriptionImpl(EntityType type) const { for (const auto & nested_storage : nested_storages) { diff --git a/src/Access/MultipleAccessStorage.h b/src/Access/MultipleAccessStorage.h index 898d55d30de..06fb3d45c05 100644 --- a/src/Access/MultipleAccessStorage.h +++ b/src/Access/MultipleAccessStorage.h @@ -15,7 +15,7 @@ public: MultipleAccessStorage(std::vector> nested_storages_); - std::vector findMultiple(std::type_index type, const String & name) const; + std::vector findMultiple(EntityType type, const String & name) const; template std::vector findMultiple(const String & name) const { return findMultiple(EntityType::TYPE, name); } @@ -25,12 +25,14 @@ public: const Storage & getStorage(const UUID & id) const; Storage & getStorage(const UUID & id); + void addStorage(std::unique_ptr nested_storage); + Storage & getStorageByIndex(size_t i) { return *(nested_storages[i]); } const Storage & getStorageByIndex(size_t i) const { return *(nested_storages[i]); } protected: - std::optional findImpl(std::type_index type, const String & name) const override; - std::vector findAllImpl(std::type_index type) const override; + std::optional findImpl(EntityType type, const String & name) const override; + std::vector findAllImpl(EntityType type) const override; bool existsImpl(const UUID & id) const override; AccessEntityPtr readImpl(const UUID & id) const override; String readNameImpl(const UUID &id) const override; @@ -39,9 +41,9 @@ protected: void removeImpl(const UUID & id) override; void updateImpl(const UUID & id, const UpdateFunc & update_func) override; ext::scope_guard subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const override; - ext::scope_guard subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const override; + ext::scope_guard subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const override; bool hasSubscriptionImpl(const UUID & id) const override; - bool hasSubscriptionImpl(std::type_index type) const override; + bool hasSubscriptionImpl(EntityType type) const override; private: std::vector> nested_storages; diff --git a/src/Access/Quota.cpp b/src/Access/Quota.cpp index e3a9e11eb10..dc855599999 100644 --- a/src/Access/Quota.cpp +++ b/src/Access/Quota.cpp @@ -1,16 +1,9 @@ #include #include -#include namespace DB { -Quota::Limits::Limits() -{ - boost::range::fill(max, 0); -} - - bool operator ==(const Quota::Limits & lhs, const Quota::Limits & rhs) { return boost::range::equal(lhs.max, rhs.max) && (lhs.duration == rhs.duration) @@ -26,20 +19,5 @@ bool Quota::equal(const IAccessEntity & other) const return (all_limits == other_quota.all_limits) && (key_type == other_quota.key_type) && (to_roles == other_quota.to_roles); } - -const char * Quota::resourceTypeToColumnName(ResourceType resource_type) -{ - switch (resource_type) - { - case Quota::QUERIES: return "queries"; - case Quota::ERRORS: return "errors"; - case Quota::RESULT_ROWS: return "result_rows"; - case Quota::RESULT_BYTES: return "result_bytes"; - case Quota::READ_ROWS: return "read_rows"; - case Quota::READ_BYTES: return "read_bytes"; - case Quota::EXECUTION_TIME: return "execution_time"; - } - __builtin_unreachable(); -} } diff --git a/src/Access/Quota.h b/src/Access/Quota.h index 714d582e98f..25b56756dc1 100644 --- a/src/Access/Quota.h +++ b/src/Access/Quota.h @@ -2,11 +2,18 @@ #include #include +#include #include namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + + /** Quota for resources consumption for specific interval. * Used to limit resource usage by user. * Quota is applied "softly" - could be slightly exceed, because it is checked usually only on each block of processed data. @@ -17,6 +24,8 @@ namespace DB */ struct Quota : public IAccessEntity { + using ResourceAmount = UInt64; + enum ResourceType { QUERIES, /// Number of queries. @@ -26,22 +35,32 @@ struct Quota : public IAccessEntity READ_ROWS, /// Number of rows read from tables. READ_BYTES, /// Number of bytes read from tables. EXECUTION_TIME, /// Total amount of query execution time in nanoseconds. - }; - static constexpr size_t MAX_RESOURCE_TYPE = 7; - using ResourceAmount = UInt64; - static constexpr ResourceAmount UNLIMITED = 0; /// 0 means unlimited. + MAX_RESOURCE_TYPE + }; + + struct ResourceTypeInfo + { + const char * const raw_name; + const String name; /// Lowercased with underscores, e.g. "result_rows". + const String keyword; /// Uppercased with spaces, e.g. "RESULT ROWS". + const bool output_as_float = false; + const UInt64 output_denominator = 1; + String amountToString(ResourceAmount amount) const; + ResourceAmount amountFromString(const String & str) const; + String outputWithAmount(ResourceAmount amount) const; + static const ResourceTypeInfo & get(ResourceType type); + }; /// Amount of resources available to consume for each duration. struct Limits { - ResourceAmount max[MAX_RESOURCE_TYPE]; + std::optional max[MAX_RESOURCE_TYPE]; std::chrono::seconds duration = std::chrono::seconds::zero(); /// Intervals can be randomized (to avoid DoS if intervals for many users end at one time). bool randomize_interval = false; - Limits(); friend bool operator ==(const Limits & lhs, const Limits & rhs); friend bool operator !=(const Limits & lhs, const Limits & rhs) { return !(lhs == rhs); } }; @@ -58,8 +77,17 @@ struct Quota : public IAccessEntity CLIENT_KEY, /// Client should explicitly supply a key to use. CLIENT_KEY_OR_USER_NAME, /// Same as CLIENT_KEY, but use USER_NAME if the client doesn't supply a key. CLIENT_KEY_OR_IP_ADDRESS, /// Same as CLIENT_KEY, but use IP_ADDRESS if the client doesn't supply a key. + + MAX }; - static constexpr size_t MAX_KEY_TYPE = 6; + + struct KeyTypeInfo + { + const char * const raw_name; + const String name; /// Lowercased with spaces, e.g. "client key". + static const KeyTypeInfo & get(KeyType type); + }; + KeyType key_type = KeyType::NONE; /// Which roles or users should use this quota. @@ -67,73 +95,146 @@ struct Quota : public IAccessEntity bool equal(const IAccessEntity & other) const override; std::shared_ptr clone() const override { return cloneImpl(); } - - static const char * getNameOfResourceType(ResourceType resource_type); - static const char * resourceTypeToKeyword(ResourceType resource_type); - static const char * resourceTypeToColumnName(ResourceType resource_type); - static const char * getNameOfKeyType(KeyType key_type); - static double executionTimeToSeconds(ResourceAmount ns); - static ResourceAmount secondsToExecutionTime(double s); + static constexpr const Type TYPE = Type::QUOTA; + Type getType() const override { return TYPE; } }; -inline const char * Quota::getNameOfResourceType(ResourceType resource_type) +inline String Quota::ResourceTypeInfo::amountToString(ResourceAmount amount) const { - switch (resource_type) + if (!(amount % output_denominator)) + return std::to_string(amount / output_denominator); + else + return boost::lexical_cast(static_cast(amount) / output_denominator); +} + +inline Quota::ResourceAmount Quota::ResourceTypeInfo::amountFromString(const String & str) const +{ + if (output_denominator == 1) + return static_cast(std::strtoul(str.c_str(), nullptr, 10)); + else + return static_cast(std::strtod(str.c_str(), nullptr) * output_denominator); +} + +inline String Quota::ResourceTypeInfo::outputWithAmount(ResourceAmount amount) const +{ + String res = name; + res += " = "; + res += amountToString(amount); + return res; +} + +inline String toString(Quota::ResourceType type) +{ + return Quota::ResourceTypeInfo::get(type).raw_name; +} + +inline const Quota::ResourceTypeInfo & Quota::ResourceTypeInfo::get(ResourceType type) +{ + static constexpr auto make_info = [](const char * raw_name_, UInt64 output_denominator_) { - case Quota::QUERIES: return "queries"; - case Quota::ERRORS: return "errors"; - case Quota::RESULT_ROWS: return "result rows"; - case Quota::RESULT_BYTES: return "result bytes"; - case Quota::READ_ROWS: return "read rows"; - case Quota::READ_BYTES: return "read bytes"; - case Quota::EXECUTION_TIME: return "execution time"; - } - __builtin_unreachable(); -} + String init_name = raw_name_; + boost::to_lower(init_name); + String init_keyword = raw_name_; + boost::replace_all(init_keyword, "_", " "); + bool init_output_as_float = (output_denominator_ != 1); + return ResourceTypeInfo{raw_name_, std::move(init_name), std::move(init_keyword), init_output_as_float, output_denominator_}; + }; - -inline const char * Quota::resourceTypeToKeyword(ResourceType resource_type) -{ - switch (resource_type) + switch (type) { - case Quota::QUERIES: return "QUERIES"; - case Quota::ERRORS: return "ERRORS"; - case Quota::RESULT_ROWS: return "RESULT ROWS"; - case Quota::RESULT_BYTES: return "RESULT BYTES"; - case Quota::READ_ROWS: return "READ ROWS"; - case Quota::READ_BYTES: return "READ BYTES"; - case Quota::EXECUTION_TIME: return "EXECUTION TIME"; + case Quota::QUERIES: + { + static const auto info = make_info("QUERIES", 1); + return info; + } + case Quota::ERRORS: + { + static const auto info = make_info("ERRORS", 1); + return info; + } + case Quota::RESULT_ROWS: + { + static const auto info = make_info("RESULT_ROWS", 1); + return info; + } + case Quota::RESULT_BYTES: + { + static const auto info = make_info("RESULT_BYTES", 1); + return info; + } + case Quota::READ_ROWS: + { + static const auto info = make_info("READ_ROWS", 1); + return info; + } + case Quota::READ_BYTES: + { + static const auto info = make_info("READ_BYTES", 1); + return info; + } + case Quota::EXECUTION_TIME: + { + static const auto info = make_info("EXECUTION_TIME", 1000000000 /* execution_time is stored in nanoseconds */); + return info; + } + case Quota::MAX_RESOURCE_TYPE: break; } - __builtin_unreachable(); + throw Exception("Unexpected resource type: " + std::to_string(static_cast(type)), ErrorCodes::LOGICAL_ERROR); } -inline const char * Quota::getNameOfKeyType(KeyType key_type) +inline String toString(Quota::KeyType type) { - switch (key_type) + return Quota::KeyTypeInfo::get(type).raw_name; +} + +inline const Quota::KeyTypeInfo & Quota::KeyTypeInfo::get(KeyType type) +{ + static constexpr auto make_info = [](const char * raw_name_) { - case KeyType::NONE: return "none"; - case KeyType::USER_NAME: return "user name"; - case KeyType::IP_ADDRESS: return "ip address"; - case KeyType::CLIENT_KEY: return "client key"; - case KeyType::CLIENT_KEY_OR_USER_NAME: return "client key or user name"; - case KeyType::CLIENT_KEY_OR_IP_ADDRESS: return "client key or ip address"; + String init_name = raw_name_; + boost::to_lower(init_name); + boost::replace_all(init_name, "_", " "); + return KeyTypeInfo{raw_name_, std::move(init_name)}; + }; + + switch (type) + { + case KeyType::NONE: + { + static const auto info = make_info("NONE"); + return info; + } + case KeyType::USER_NAME: + { + static const auto info = make_info("USER_NAME"); + return info; + } + case KeyType::IP_ADDRESS: + { + static const auto info = make_info("IP_ADDRESS"); + return info; + } + case KeyType::CLIENT_KEY: + { + static const auto info = make_info("CLIENT_KEY"); + return info; + } + case KeyType::CLIENT_KEY_OR_USER_NAME: + { + static const auto info = make_info("CLIENT_KEY_OR_USER_NAME"); + return info; + } + case KeyType::CLIENT_KEY_OR_IP_ADDRESS: + { + static const auto info = make_info("CLIENT_KEY_OR_IP_ADDRESS"); + return info; + } + case KeyType::MAX: break; } - __builtin_unreachable(); + throw Exception("Unexpected quota key type: " + std::to_string(static_cast(type)), ErrorCodes::LOGICAL_ERROR); } - -inline double Quota::executionTimeToSeconds(ResourceAmount ns) -{ - return std::chrono::duration_cast>(std::chrono::nanoseconds{ns}).count(); -} - -inline Quota::ResourceAmount Quota::secondsToExecutionTime(double s) -{ - return std::chrono::duration_cast(std::chrono::duration(s)).count(); -} - - using QuotaPtr = std::shared_ptr; } diff --git a/src/Access/QuotaCache.cpp b/src/Access/QuotaCache.cpp index dca844bf746..d3ebca9529c 100644 --- a/src/Access/QuotaCache.cpp +++ b/src/Access/QuotaCache.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -17,6 +17,7 @@ namespace DB namespace ErrorCodes { extern const int QUOTA_REQUIRES_CLIENT_KEY; + extern const int LOGICAL_ERROR; } @@ -72,8 +73,9 @@ String QuotaCache::QuotaInfo::calculateKey(const EnabledQuota & enabled) const return params.client_key; return params.client_address.toString(); } + case KeyType::MAX: break; } - __builtin_unreachable(); + throw Exception("Unexpected quota key type: " + std::to_string(static_cast(quota->key_type)), ErrorCodes::LOGICAL_ERROR); } @@ -101,7 +103,7 @@ boost::shared_ptr QuotaCache::QuotaInfo::rebuildI new_intervals->quota_key = key; auto & intervals = new_intervals->intervals; intervals.reserve(quota->all_limits.size()); - static constexpr size_t MAX_RESOURCE_TYPE = Quota::MAX_RESOURCE_TYPE; + static constexpr auto MAX_RESOURCE_TYPE = Quota::MAX_RESOURCE_TYPE; for (const auto & limits : quota->all_limits) { intervals.emplace_back(); @@ -114,7 +116,8 @@ boost::shared_ptr QuotaCache::QuotaInfo::rebuildI interval.end_of_interval = end_of_interval.time_since_epoch(); for (auto resource_type : ext::range(MAX_RESOURCE_TYPE)) { - interval.max[resource_type] = limits.max[resource_type]; + if (limits.max[resource_type]) + interval.max[resource_type] = *limits.max[resource_type]; interval.used[resource_type] = 0; } } @@ -167,12 +170,7 @@ QuotaCache::QuotaCache(const AccessControlManager & access_control_manager_) QuotaCache::~QuotaCache() = default; -std::shared_ptr QuotaCache::getEnabledQuota( - const UUID & user_id, - const String & user_name, - const std::vector & enabled_roles, - const Poco::Net::IPAddress & client_address, - const String & client_key) +std::shared_ptr QuotaCache::getEnabledQuota(const UUID & user_id, const String & user_name, const boost::container::flat_set & enabled_roles, const Poco::Net::IPAddress & client_address, const String & client_key) { std::lock_guard lock{mutex}; ensureAllQuotasRead(); @@ -290,16 +288,20 @@ void QuotaCache::chooseQuotaToConsumeFor(EnabledQuota & enabled) } -std::vector QuotaCache::getUsageInfo() const +std::vector QuotaCache::getAllQuotasUsage() const { std::lock_guard lock{mutex}; - std::vector all_infos; + std::vector all_usage; auto current_time = std::chrono::system_clock::now(); for (const auto & info : all_quotas | boost::adaptors::map_values) { for (const auto & intervals : info.key_to_intervals | boost::adaptors::map_values) - all_infos.push_back(intervals->getUsageInfo(current_time)); + { + auto usage = intervals->getUsage(current_time); + if (usage) + all_usage.push_back(std::move(usage).value()); + } } - return all_infos; + return all_usage; } } diff --git a/src/Access/QuotaCache.h b/src/Access/QuotaCache.h index 8399c5f73eb..6e794f0bbd2 100644 --- a/src/Access/QuotaCache.h +++ b/src/Access/QuotaCache.h @@ -20,14 +20,8 @@ public: QuotaCache(const AccessControlManager & access_control_manager_); ~QuotaCache(); - std::shared_ptr getEnabledQuota( - const UUID & user_id, - const String & user_name, - const std::vector & enabled_roles, - const Poco::Net::IPAddress & address, - const String & client_key); - - std::vector getUsageInfo() const; + std::shared_ptr getEnabledQuota(const UUID & user_id, const String & user_name, const boost::container::flat_set & enabled_roles, const Poco::Net::IPAddress & address, const String & client_key); + std::vector getAllQuotasUsage() const; private: using Interval = EnabledQuota::Interval; diff --git a/src/Access/QuotaUsage.cpp b/src/Access/QuotaUsage.cpp new file mode 100644 index 00000000000..cf03c4f478a --- /dev/null +++ b/src/Access/QuotaUsage.cpp @@ -0,0 +1,16 @@ +#include +#include + + +namespace DB +{ +QuotaUsage::QuotaUsage() : quota_id(UUID(UInt128(0))) +{ +} + + +QuotaUsage::Interval::Interval() +{ + boost::range::fill(used, 0); +} +} diff --git a/src/Access/QuotaUsage.h b/src/Access/QuotaUsage.h new file mode 100644 index 00000000000..9e53c0cf7d7 --- /dev/null +++ b/src/Access/QuotaUsage.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include + + +namespace DB +{ +/// The information about a quota consumption. +struct QuotaUsage +{ + using ResourceType = Quota::ResourceType; + using ResourceAmount = Quota::ResourceAmount; + static constexpr auto MAX_RESOURCE_TYPE = Quota::MAX_RESOURCE_TYPE; + + struct Interval + { + ResourceAmount used[MAX_RESOURCE_TYPE]; + std::optional max[MAX_RESOURCE_TYPE]; + std::chrono::seconds duration = std::chrono::seconds::zero(); + bool randomize_interval = false; + std::chrono::system_clock::time_point end_of_interval; + Interval(); + }; + + std::vector intervals; + UUID quota_id; + String quota_name; + String quota_key; + QuotaUsage(); +}; +} diff --git a/src/Access/QuotaUsageInfo.cpp b/src/Access/QuotaUsageInfo.cpp deleted file mode 100644 index bcdf2b50062..00000000000 --- a/src/Access/QuotaUsageInfo.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - - -namespace DB -{ -QuotaUsageInfo::QuotaUsageInfo() : quota_id(UUID(UInt128(0))) -{ -} - - -QuotaUsageInfo::Interval::Interval() -{ - boost::range::fill(used, 0); - boost::range::fill(max, 0); -} -} diff --git a/src/Access/QuotaUsageInfo.h b/src/Access/QuotaUsageInfo.h deleted file mode 100644 index 94e16fb9f69..00000000000 --- a/src/Access/QuotaUsageInfo.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include - - -namespace DB -{ -/// The information about a quota consumption. -struct QuotaUsageInfo -{ - using ResourceType = Quota::ResourceType; - using ResourceAmount = Quota::ResourceAmount; - static constexpr size_t MAX_RESOURCE_TYPE = Quota::MAX_RESOURCE_TYPE; - - struct Interval - { - ResourceAmount used[MAX_RESOURCE_TYPE]; - ResourceAmount max[MAX_RESOURCE_TYPE]; - std::chrono::seconds duration = std::chrono::seconds::zero(); - bool randomize_interval = false; - std::chrono::system_clock::time_point end_of_interval; - Interval(); - }; - - std::vector intervals; - UUID quota_id; - String quota_name; - String quota_key; - QuotaUsageInfo(); -}; -} diff --git a/src/Access/Role.cpp b/src/Access/Role.cpp index f20ef9b9bfa..3df562ad1f0 100644 --- a/src/Access/Role.cpp +++ b/src/Access/Role.cpp @@ -9,9 +9,7 @@ bool Role::equal(const IAccessEntity & other) const if (!IAccessEntity::equal(other)) return false; const auto & other_role = typeid_cast(other); - return (access == other_role.access) && (access_with_grant_option == other_role.access_with_grant_option) - && (granted_roles == other_role.granted_roles) && (granted_roles_with_admin_option == other_role.granted_roles_with_admin_option) - && (settings == other_role.settings); + return (access == other_role.access) && (granted_roles == other_role.granted_roles) && (settings == other_role.settings); } } diff --git a/src/Access/Role.h b/src/Access/Role.h index 04330ba85f5..9acb97bdfbd 100644 --- a/src/Access/Role.h +++ b/src/Access/Role.h @@ -1,10 +1,9 @@ #pragma once #include -#include +#include +#include #include -#include -#include namespace DB @@ -12,14 +11,14 @@ namespace DB struct Role : public IAccessEntity { - AccessRights access; - AccessRights access_with_grant_option; - boost::container::flat_set granted_roles; - boost::container::flat_set granted_roles_with_admin_option; + GrantedAccess access; + GrantedRoles granted_roles; SettingsProfileElements settings; bool equal(const IAccessEntity & other) const override; std::shared_ptr clone() const override { return cloneImpl(); } + static constexpr const Type TYPE = Type::ROLE; + Type getType() const override { return TYPE; } }; using RolePtr = std::shared_ptr; diff --git a/src/Access/RoleCache.cpp b/src/Access/RoleCache.cpp index 0263b793017..ca8065145f3 100644 --- a/src/Access/RoleCache.cpp +++ b/src/Access/RoleCache.cpp @@ -2,68 +2,56 @@ #include #include #include -#include +#include namespace DB { namespace { - struct CollectedRoleInfo - { - RolePtr role; - bool is_current_role = false; - bool with_admin_option = false; - }; - - - void collectRoles(boost::container::flat_map & collected_roles, + void collectRoles(EnabledRolesInfo & roles_info, + boost::container::flat_set & skip_ids, const std::function & get_role_function, const UUID & role_id, bool is_current_role, bool with_admin_option) { - auto it = collected_roles.find(role_id); - if (it != collected_roles.end()) + if (roles_info.enabled_roles.count(role_id)) { - it->second.is_current_role |= is_current_role; - it->second.with_admin_option |= with_admin_option; + if (is_current_role) + roles_info.current_roles.emplace(role_id); + if (with_admin_option) + roles_info.enabled_roles_with_admin_option.emplace(role_id); return; } + if (skip_ids.count(role_id)) + return; + auto role = get_role_function(role_id); - collected_roles[role_id] = CollectedRoleInfo{role, is_current_role, with_admin_option}; if (!role) - return; - - for (const auto & granted_role : role->granted_roles) - collectRoles(collected_roles, get_role_function, granted_role, false, false); - - for (const auto & granted_role : role->granted_roles_with_admin_option) - collectRoles(collected_roles, get_role_function, granted_role, false, true); - } - - - std::shared_ptr collectInfoForRoles(const boost::container::flat_map & roles) - { - auto new_info = std::make_shared(); - for (const auto & [role_id, collect_info] : roles) { - const auto & role = collect_info.role; - if (!role) - continue; - if (collect_info.is_current_role) - new_info->current_roles.emplace_back(role_id); - new_info->enabled_roles.emplace_back(role_id); - if (collect_info.with_admin_option) - new_info->enabled_roles_with_admin_option.emplace_back(role_id); - new_info->names_of_roles[role_id] = role->getName(); - new_info->access.merge(role->access); - new_info->access_with_grant_option.merge(role->access_with_grant_option); - new_info->settings_from_enabled_roles.merge(role->settings); + skip_ids.emplace(role_id); + return; } - return new_info; + + roles_info.enabled_roles.emplace(role_id); + if (is_current_role) + roles_info.current_roles.emplace(role_id); + if (with_admin_option) + roles_info.enabled_roles_with_admin_option.emplace(role_id); + + roles_info.names_of_roles[role_id] = role->getName(); + roles_info.access.merge(role->access.access); + roles_info.access_with_grant_option.merge(role->access.access_with_grant_option); + roles_info.settings_from_enabled_roles.merge(role->settings); + + for (const auto & granted_role : role->granted_roles.roles) + collectRoles(roles_info, skip_ids, get_role_function, granted_role, false, false); + + for (const auto & granted_role : role->granted_roles.roles_with_admin_option) + collectRoles(roles_info, skip_ids, get_role_function, granted_role, false, true); } } @@ -75,8 +63,8 @@ RoleCache::RoleCache(const AccessControlManager & manager_) RoleCache::~RoleCache() = default; -std::shared_ptr RoleCache::getEnabledRoles( - const std::vector & roles, const std::vector & roles_with_admin_option) +std::shared_ptr +RoleCache::getEnabledRoles(const boost::container::flat_set & roles, const boost::container::flat_set & roles_with_admin_option) { std::lock_guard lock{mutex}; @@ -93,13 +81,13 @@ std::shared_ptr RoleCache::getEnabledRoles( } auto res = std::shared_ptr(new EnabledRoles(params)); - collectRolesInfoFor(*res); + collectEnabledRoles(*res); enabled_roles.emplace(std::move(params), res); return res; } -void RoleCache::collectRolesInfo() +void RoleCache::collectEnabledRoles() { /// `mutex` is already locked. @@ -110,28 +98,29 @@ void RoleCache::collectRolesInfo() i = enabled_roles.erase(i); else { - collectRolesInfoFor(*elem); + collectEnabledRoles(*elem); ++i; } } } -void RoleCache::collectRolesInfoFor(EnabledRoles & enabled) +void RoleCache::collectEnabledRoles(EnabledRoles & enabled) { /// `mutex` is already locked. - /// Collect roles in use. That includes the current roles, the roles granted to the current roles, and so on. - boost::container::flat_map collected_roles; + /// Collect enabled roles. That includes the current roles, the roles granted to the current roles, and so on. + auto new_info = std::make_shared(); + boost::container::flat_set skip_ids; auto get_role_function = [this](const UUID & id) { return getRole(id); }; for (const auto & current_role : enabled.params.current_roles) - collectRoles(collected_roles, get_role_function, current_role, true, false); + collectRoles(*new_info, skip_ids, get_role_function, current_role, true, false); for (const auto & current_role : enabled.params.current_roles_with_admin_option) - collectRoles(collected_roles, get_role_function, current_role, true, true); + collectRoles(*new_info, skip_ids, get_role_function, current_role, true, true); /// Collect data from the collected roles. - enabled.setRolesInfo(collectInfoForRoles(collected_roles)); + enabled.setRolesInfo(new_info); } @@ -174,7 +163,7 @@ void RoleCache::roleChanged(const UUID & role_id, const RolePtr & changed_role) return; role_from_cache->first = changed_role; cache.update(role_id, role_from_cache); - collectRolesInfo(); + collectEnabledRoles(); } @@ -182,7 +171,7 @@ void RoleCache::roleRemoved(const UUID & role_id) { std::lock_guard lock{mutex}; cache.remove(role_id); - collectRolesInfo(); + collectEnabledRoles(); } } diff --git a/src/Access/RoleCache.h b/src/Access/RoleCache.h index 69f4cb2ebe8..f1ef783b5c4 100644 --- a/src/Access/RoleCache.h +++ b/src/Access/RoleCache.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -18,11 +19,12 @@ public: RoleCache(const AccessControlManager & manager_); ~RoleCache(); - std::shared_ptr getEnabledRoles(const std::vector & current_roles, const std::vector & current_roles_with_admin_option); + std::shared_ptr getEnabledRoles( + const boost::container::flat_set & current_roles, const boost::container::flat_set & current_roles_with_admin_option); private: - void collectRolesInfo(); - void collectRolesInfoFor(EnabledRoles & enabled); + void collectEnabledRoles(); + void collectEnabledRoles(EnabledRoles & enabled); RolePtr getRole(const UUID & role_id); void roleChanged(const UUID & role_id, const RolePtr & changed_role); void roleRemoved(const UUID & role_id); diff --git a/src/Access/RowPolicy.cpp b/src/Access/RowPolicy.cpp index 65b9451a453..4249f351eae 100644 --- a/src/Access/RowPolicy.cpp +++ b/src/Access/RowPolicy.cpp @@ -1,72 +1,67 @@ #include -#include #include #include namespace DB { -namespace +namespace ErrorCodes { - void generateFullNameImpl(const String & database_, const String & table_name_, const String & policy_name_, String & full_name_) + extern const int NOT_IMPLEMENTED; +} + + +String RowPolicy::NameParts::getName() const +{ + String name; + name.reserve(database.length() + table_name.length() + short_name.length() + 6); + name += backQuoteIfNeed(short_name); + name += " ON "; + if (!name.empty()) { - full_name_.clear(); - full_name_.reserve(database_.length() + table_name_.length() + policy_name_.length() + 6); - full_name_ += backQuoteIfNeed(policy_name_); - full_name_ += " ON "; - if (!database_.empty()) - { - full_name_ += backQuoteIfNeed(database_); - full_name_ += '.'; - } - full_name_ += backQuoteIfNeed(table_name_); + name += backQuoteIfNeed(database); + name += '.'; } + name += backQuoteIfNeed(table_name); + return name; } -String RowPolicy::FullNameParts::getFullName() const +void RowPolicy::setDatabase(const String & database) { - String full_name; - generateFullNameImpl(database, table_name, policy_name, full_name); - return full_name; + name_parts.database = database; + IAccessEntity::setName(name_parts.getName()); } - -String RowPolicy::FullNameParts::getFullName(const Context & context) const +void RowPolicy::setTableName(const String & table_name) { - String full_name; - generateFullNameImpl(database.empty() ? context.getCurrentDatabase() : database, table_name, policy_name, full_name); - return full_name; + name_parts.table_name = table_name; + IAccessEntity::setName(name_parts.getName()); } - -void RowPolicy::setDatabase(const String & database_) +void RowPolicy::setShortName(const String & short_name) { - database = database_; - generateFullNameImpl(database, table_name, policy_name, full_name); + name_parts.short_name = short_name; + IAccessEntity::setName(name_parts.getName()); } - -void RowPolicy::setTableName(const String & table_name_) +void RowPolicy::setNameParts(const String & short_name, const String & database, const String & table_name) { - table_name = table_name_; - generateFullNameImpl(database, table_name, policy_name, full_name); + name_parts.short_name = short_name; + name_parts.database = database; + name_parts.table_name = table_name; + IAccessEntity::setName(name_parts.getName()); } - -void RowPolicy::setName(const String & policy_name_) +void RowPolicy::setNameParts(const NameParts & name_parts_) { - policy_name = policy_name_; - generateFullNameImpl(database, table_name, policy_name, full_name); + name_parts = name_parts_; + IAccessEntity::setName(name_parts.getName()); } - -void RowPolicy::setFullName(const String & database_, const String & table_name_, const String & policy_name_) +void RowPolicy::setName(const String &) { - database = database_; - table_name = table_name_; - policy_name = policy_name_; - generateFullNameImpl(database, table_name, policy_name, full_name); + throw Exception("RowPolicy::setName() is not implemented", ErrorCodes::NOT_IMPLEMENTED); } @@ -75,37 +70,8 @@ bool RowPolicy::equal(const IAccessEntity & other) const if (!IAccessEntity::equal(other)) return false; const auto & other_policy = typeid_cast(other); - return (database == other_policy.database) && (table_name == other_policy.table_name) && (policy_name == other_policy.policy_name) - && boost::range::equal(conditions, other_policy.conditions) && restrictive == other_policy.restrictive - && (to_roles == other_policy.to_roles); -} - - -const char * RowPolicy::conditionTypeToString(ConditionType index) -{ - switch (index) - { - case SELECT_FILTER: return "SELECT_FILTER"; - case INSERT_CHECK: return "INSERT_CHECK"; - case UPDATE_FILTER: return "UPDATE_FILTER"; - case UPDATE_CHECK: return "UPDATE_CHECK"; - case DELETE_FILTER: return "DELETE_FILTER"; - } - __builtin_unreachable(); -} - - -const char * RowPolicy::conditionTypeToColumnName(ConditionType index) -{ - switch (index) - { - case SELECT_FILTER: return "select_filter"; - case INSERT_CHECK: return "insert_check"; - case UPDATE_FILTER: return "update_filter"; - case UPDATE_CHECK: return "update_check"; - case DELETE_FILTER: return "delete_filter"; - } - __builtin_unreachable(); + return (name_parts == other_policy.name_parts) && boost::range::equal(conditions, other_policy.conditions) + && restrictive == other_policy.restrictive && (to_roles == other_policy.to_roles); } } diff --git a/src/Access/RowPolicy.h b/src/Access/RowPolicy.h index 08219edb46b..7febf5991fb 100644 --- a/src/Access/RowPolicy.h +++ b/src/Access/RowPolicy.h @@ -2,35 +2,44 @@ #include #include +#include namespace DB { -class Context; +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} /** Represents a row level security policy for a table. */ struct RowPolicy : public IAccessEntity { - void setDatabase(const String & database_); - void setTableName(const String & table_name_); - void setName(const String & policy_name_) override; - void setFullName(const String & database_, const String & table_name_, const String & policy_name_); - - String getDatabase() const { return database; } - String getTableName() const { return table_name; } - String getName() const override { return policy_name; } - - struct FullNameParts + struct NameParts { + String short_name; String database; String table_name; - String policy_name; - String getFullName() const; - String getFullName(const Context & context) const; + + String getName() const; + auto toTuple() const { return std::tie(short_name, database, table_name); } + friend bool operator ==(const NameParts & left, const NameParts & right) { return left.toTuple() == right.toTuple(); } + friend bool operator !=(const NameParts & left, const NameParts & right) { return left.toTuple() != right.toTuple(); } }; + void setShortName(const String & short_name); + void setDatabase(const String & database); + void setTableName(const String & table_name); + void setNameParts(const String & short_name, const String & database, const String & table_name); + void setNameParts(const NameParts & name_parts); + + const String & getDatabase() const { return name_parts.database; } + const String & getTableName() const { return name_parts.table_name; } + const String & getShortName() const { return name_parts.short_name; } + const NameParts & getNameParts() const { return name_parts; } + /// Filter is a SQL conditional expression used to figure out which rows should be visible /// for user or available for modification. If the expression returns NULL or false for some rows /// those rows are silently suppressed. @@ -40,16 +49,27 @@ struct RowPolicy : public IAccessEntity enum ConditionType { SELECT_FILTER, + +#if 0 /// Row-level security for INSERT, UPDATE, DELETE is not implemented yet. INSERT_CHECK, UPDATE_FILTER, UPDATE_CHECK, DELETE_FILTER, - }; - static constexpr size_t MAX_CONDITION_TYPE = 5; - static const char * conditionTypeToString(ConditionType index); - static const char * conditionTypeToColumnName(ConditionType index); +#endif - String conditions[MAX_CONDITION_TYPE]; + MAX_CONDITION_TYPE + }; + + struct ConditionTypeInfo + { + const char * const raw_name; + const String name; /// Lowercased with underscores, e.g. "select_filter". + const String command; /// Uppercased without last word, e.g. "SELECT". + const bool is_check; /// E.g. false for SELECT_FILTER. + static const ConditionTypeInfo & get(ConditionType type); + }; + + std::array conditions; /// Sets that the policy is permissive. /// A row is only accessible if at least one of the permissive policies passes, @@ -65,16 +85,72 @@ struct RowPolicy : public IAccessEntity bool equal(const IAccessEntity & other) const override; std::shared_ptr clone() const override { return cloneImpl(); } + static constexpr const Type TYPE = Type::ROW_POLICY; + Type getType() const override { return TYPE; } /// Which roles or users should use this row policy. ExtendedRoleSet to_roles; private: - String database; - String table_name; - String policy_name; + void setName(const String & name_) override; + + NameParts name_parts; bool restrictive = false; }; using RowPolicyPtr = std::shared_ptr; + + +inline const RowPolicy::ConditionTypeInfo & RowPolicy::ConditionTypeInfo::get(ConditionType type_) +{ + static constexpr auto make_info = [](const char * raw_name_) + { + String init_name = raw_name_; + boost::to_lower(init_name); + size_t underscore_pos = init_name.find('_'); + String init_command = init_name.substr(0, underscore_pos); + boost::to_upper(init_command); + bool init_is_check = (std::string_view{init_name}.substr(underscore_pos + 1) == "check"); + return ConditionTypeInfo{raw_name_, std::move(init_name), std::move(init_command), init_is_check}; + }; + + switch (type_) + { + case SELECT_FILTER: + { + static const ConditionTypeInfo info = make_info("SELECT_FILTER"); + return info; + } +#if 0 /// Row-level security for INSERT, UPDATE, DELETE is not implemented yet. + case INSERT_CHECK: + { + static const ConditionTypeInfo info = make_info("INSERT_CHECK"); + return info; + } + case UPDATE_FILTER: + { + static const ConditionTypeInfo info = make_info("UPDATE_FILTER"); + return info; + } + case UPDATE_CHECK: + { + static const ConditionTypeInfo info = make_info("UPDATE_CHECK"); + return info; + } + case DELETE_FILTER: + { + static const ConditionTypeInfo info = make_info("DELETE_FILTER"); + return info; + } +#endif + case MAX_CONDITION_TYPE: break; + } + throw Exception("Unknown type: " + std::to_string(static_cast(type_)), ErrorCodes::LOGICAL_ERROR); +} + +inline String toString(RowPolicy::ConditionType type) +{ + return RowPolicy::ConditionTypeInfo::get(type).raw_name; +} + } diff --git a/src/Access/RowPolicyCache.cpp b/src/Access/RowPolicyCache.cpp index 0c9fea69dc4..243f9c85d70 100644 --- a/src/Access/RowPolicyCache.cpp +++ b/src/Access/RowPolicyCache.cpp @@ -16,7 +16,7 @@ namespace DB namespace { using ConditionType = RowPolicy::ConditionType; - constexpr size_t MAX_CONDITION_TYPE = RowPolicy::MAX_CONDITION_TYPE; + constexpr auto MAX_CONDITION_TYPE = RowPolicy::MAX_CONDITION_TYPE; /// Accumulates conditions from multiple row policies and joins them using the AND logical operation. @@ -57,8 +57,9 @@ void RowPolicyCache::PolicyInfo::setPolicy(const RowPolicyPtr & policy_) { policy = policy_; roles = &policy->to_roles; + database_and_table_name = std::make_shared>(policy->getDatabase(), policy->getTableName()); - for (auto type : ext::range_with_static_cast(0, MAX_CONDITION_TYPE)) + for (auto type : ext::range(0, MAX_CONDITION_TYPE)) { parsed_conditions[type] = nullptr; const String & condition = policy->conditions[type]; @@ -84,8 +85,8 @@ void RowPolicyCache::PolicyInfo::setPolicy(const RowPolicyPtr & policy_) { tryLogCurrentException( &Poco::Logger::get("RowPolicy"), - String("Could not parse the condition ") + RowPolicy::conditionTypeToString(type) + " of row policy " - + backQuote(policy->getFullName())); + String("Could not parse the condition ") + toString(type) + " of row policy " + + backQuote(policy->getName())); } } } @@ -99,7 +100,7 @@ RowPolicyCache::RowPolicyCache(const AccessControlManager & access_control_manag RowPolicyCache::~RowPolicyCache() = default; -std::shared_ptr RowPolicyCache::getEnabledRowPolicies(const UUID & user_id, const std::vector & enabled_roles) +std::shared_ptr RowPolicyCache::getEnabledRowPolicies(const UUID & user_id, const boost::container::flat_set & enabled_roles) { std::lock_guard lock{mutex}; ensureAllRowPoliciesRead(); @@ -196,43 +197,45 @@ void RowPolicyCache::mixConditions() void RowPolicyCache::mixConditionsFor(EnabledRowPolicies & enabled) { /// `mutex` is already locked. - struct Mixers - { - ConditionsMixer mixers[MAX_CONDITION_TYPE]; - std::vector policy_ids; - }; + using MapOfMixedConditions = EnabledRowPolicies::MapOfMixedConditions; - using DatabaseAndTableName = EnabledRowPolicies::DatabaseAndTableName; - using DatabaseAndTableNameRef = EnabledRowPolicies::DatabaseAndTableNameRef; + using MixedConditionKey = EnabledRowPolicies::MixedConditionKey; using Hash = EnabledRowPolicies::Hash; - std::unordered_map map_of_mixers; + struct MixerWithNames + { + ConditionsMixer mixer; + std::shared_ptr> database_and_table_name; + }; + + std::unordered_map map_of_mixers; for (const auto & [policy_id, info] : all_policies) { const auto & policy = *info.policy; - auto & mixers = map_of_mixers[std::pair{policy.getDatabase(), policy.getTableName()}]; - if (info.roles->match(enabled.params.user_id, enabled.params.enabled_roles)) + bool match = info.roles->match(enabled.params.user_id, enabled.params.enabled_roles); + MixedConditionKey key; + key.database = info.database_and_table_name->first; + key.table_name = info.database_and_table_name->second; + for (auto type : ext::range(0, MAX_CONDITION_TYPE)) { - mixers.policy_ids.push_back(policy_id); - for (auto type : ext::range(0, MAX_CONDITION_TYPE)) - if (info.parsed_conditions[type]) - mixers.mixers[type].add(info.parsed_conditions[type], policy.isRestrictive()); + if (info.parsed_conditions[type]) + { + key.condition_type = type; + auto & mixer = map_of_mixers[key]; + mixer.database_and_table_name = info.database_and_table_name; + if (match) + mixer.mixer.add(info.parsed_conditions[type], policy.isRestrictive()); + } } } auto map_of_mixed_conditions = boost::make_shared(); - for (auto & [database_and_table_name, mixers] : map_of_mixers) + for (auto & [key, mixer] : map_of_mixers) { - auto database_and_table_name_keeper = std::make_unique(); - database_and_table_name_keeper->first = database_and_table_name.first; - database_and_table_name_keeper->second = database_and_table_name.second; - auto & mixed_conditions = (*map_of_mixed_conditions)[DatabaseAndTableNameRef{database_and_table_name_keeper->first, - database_and_table_name_keeper->second}]; - mixed_conditions.database_and_table_name_keeper = std::move(database_and_table_name_keeper); - mixed_conditions.policy_ids = std::move(mixers.policy_ids); - for (auto type : ext::range(0, MAX_CONDITION_TYPE)) - mixed_conditions.mixed_conditions[type] = std::move(mixers.mixers[type]).getResult(); + auto & mixed_condition = (*map_of_mixed_conditions)[key]; + mixed_condition.database_and_table_name = mixer.database_and_table_name; + mixed_condition.ast = std::move(mixer.mixer).getResult(); } enabled.map_of_mixed_conditions.store(map_of_mixed_conditions); diff --git a/src/Access/RowPolicyCache.h b/src/Access/RowPolicyCache.h index d0ec74b9ab8..139949ae815 100644 --- a/src/Access/RowPolicyCache.h +++ b/src/Access/RowPolicyCache.h @@ -18,11 +18,9 @@ public: RowPolicyCache(const AccessControlManager & access_control_manager_); ~RowPolicyCache(); - std::shared_ptr getEnabledRowPolicies(const UUID & user_id, const std::vector & enabled_roles); + std::shared_ptr getEnabledRowPolicies(const UUID & user_id, const boost::container::flat_set & enabled_roles); private: - using ParsedConditions = EnabledRowPolicies::ParsedConditions; - struct PolicyInfo { PolicyInfo(const RowPolicyPtr & policy_) { setPolicy(policy_); } @@ -30,7 +28,8 @@ private: RowPolicyPtr policy; const ExtendedRoleSet * roles = nullptr; - ParsedConditions parsed_conditions; + std::shared_ptr> database_and_table_name; + ASTPtr parsed_conditions[RowPolicy::MAX_CONDITION_TYPE]; }; void ensureAllRowPoliciesRead(); diff --git a/src/Access/SettingsConstraints.cpp b/src/Access/SettingsConstraints.cpp index 21ca2c8ab26..11dbd016e64 100644 --- a/src/Access/SettingsConstraints.cpp +++ b/src/Access/SettingsConstraints.cpp @@ -30,16 +30,23 @@ void SettingsConstraints::clear() } -void SettingsConstraints::setMinValue(const StringRef & name, const Field & min_value) +void SettingsConstraints::setMinValue(const StringRef & setting_name, const Field & min_value) +{ + setMinValue(Settings::findIndexStrict(setting_name), min_value); +} + +void SettingsConstraints::setMinValue(size_t setting_index, const Field & min_value) { - size_t setting_index = Settings::findIndexStrict(name); getConstraintRef(setting_index).min_value = Settings::valueToCorrespondingType(setting_index, min_value); } - -Field SettingsConstraints::getMinValue(const StringRef & name) const +Field SettingsConstraints::getMinValue(const StringRef & setting_name) const +{ + return getMinValue(Settings::findIndexStrict(setting_name)); +} + +Field SettingsConstraints::getMinValue(size_t setting_index) const { - size_t setting_index = Settings::findIndexStrict(name); const auto * ptr = tryGetConstraint(setting_index); if (ptr) return ptr->min_value; @@ -50,14 +57,21 @@ Field SettingsConstraints::getMinValue(const StringRef & name) const void SettingsConstraints::setMaxValue(const StringRef & name, const Field & max_value) { - size_t setting_index = Settings::findIndexStrict(name); + setMaxValue(Settings::findIndexStrict(name), max_value); +} + +void SettingsConstraints::setMaxValue(size_t setting_index, const Field & max_value) +{ getConstraintRef(setting_index).max_value = Settings::valueToCorrespondingType(setting_index, max_value); } - -Field SettingsConstraints::getMaxValue(const StringRef & name) const +Field SettingsConstraints::getMaxValue(const StringRef & setting_name) const +{ + return getMaxValue(Settings::findIndexStrict(setting_name)); +} + +Field SettingsConstraints::getMaxValue(size_t setting_index) const { - size_t setting_index = Settings::findIndexStrict(name); const auto * ptr = tryGetConstraint(setting_index); if (ptr) return ptr->max_value; @@ -66,16 +80,23 @@ Field SettingsConstraints::getMaxValue(const StringRef & name) const } -void SettingsConstraints::setReadOnly(const StringRef & name, bool read_only) +void SettingsConstraints::setReadOnly(const StringRef & setting_name, bool read_only) +{ + setReadOnly(Settings::findIndexStrict(setting_name), read_only); +} + +void SettingsConstraints::setReadOnly(size_t setting_index, bool read_only) { - size_t setting_index = Settings::findIndexStrict(name); getConstraintRef(setting_index).read_only = read_only; } - -bool SettingsConstraints::isReadOnly(const StringRef & name) const +bool SettingsConstraints::isReadOnly(const StringRef & setting_name) const +{ + return isReadOnly(Settings::findIndexStrict(setting_name)); +} + +bool SettingsConstraints::isReadOnly(size_t setting_index) const { - size_t setting_index = Settings::findIndexStrict(name); const auto * ptr = tryGetConstraint(setting_index); if (ptr) return ptr->read_only; @@ -83,20 +104,26 @@ bool SettingsConstraints::isReadOnly(const StringRef & name) const return false; } - -void SettingsConstraints::set(const StringRef & name, const Field & min_value, const Field & max_value, bool read_only) +void SettingsConstraints::set(const StringRef & setting_name, const Field & min_value, const Field & max_value, bool read_only) +{ + set(Settings::findIndexStrict(setting_name), min_value, max_value, read_only); +} + +void SettingsConstraints::set(size_t setting_index, const Field & min_value, const Field & max_value, bool read_only) { - size_t setting_index = Settings::findIndexStrict(name); auto & ref = getConstraintRef(setting_index); ref.min_value = min_value; ref.max_value = max_value; ref.read_only = read_only; } - -void SettingsConstraints::get(const StringRef & name, Field & min_value, Field & max_value, bool & read_only) const +void SettingsConstraints::get(const StringRef & setting_name, Field & min_value, Field & max_value, bool & read_only) const +{ + get(Settings::findIndexStrict(setting_name), min_value, max_value, read_only); +} + +void SettingsConstraints::get(size_t setting_index, Field & min_value, Field & max_value, bool & read_only) const { - size_t setting_index = Settings::findIndexStrict(name); const auto * ptr = tryGetConstraint(setting_index); if (ptr) { @@ -112,7 +139,6 @@ void SettingsConstraints::get(const StringRef & name, Field & min_value, Field & } } - void SettingsConstraints::merge(const SettingsConstraints & other) { for (const auto & [setting_index, other_constraint] : other.constraints_by_index) diff --git a/src/Access/SettingsConstraints.h b/src/Access/SettingsConstraints.h index 074dc66d123..65537250957 100644 --- a/src/Access/SettingsConstraints.h +++ b/src/Access/SettingsConstraints.h @@ -1,7 +1,10 @@ #pragma once +#include #include -#include +#include +#include + namespace Poco { @@ -60,17 +63,25 @@ public: void clear(); bool empty() const { return constraints_by_index.empty(); } - void setMinValue(const StringRef & name, const Field & min_value); - Field getMinValue(const StringRef & name) const; + void setMinValue(const StringRef & setting_name, const Field & min_value); + void setMinValue(size_t setting_index, const Field & min_value); + Field getMinValue(const StringRef & setting_name) const; + Field getMinValue(size_t setting_index) const; - void setMaxValue(const StringRef & name, const Field & max_value); - Field getMaxValue(const StringRef & name) const; + void setMaxValue(const StringRef & setting_name, const Field & max_value); + void setMaxValue(size_t setting_index, const Field & max_value); + Field getMaxValue(const StringRef & setting_name) const; + Field getMaxValue(size_t setting_index) const; - void setReadOnly(const StringRef & name, bool read_only); - bool isReadOnly(const StringRef & name) const; + void setReadOnly(const StringRef & setting_name, bool read_only); + void setReadOnly(size_t setting_index, bool read_only); + bool isReadOnly(const StringRef & setting_name) const; + bool isReadOnly(size_t setting_index) const; - void set(const StringRef & name, const Field & min_value, const Field & max_value, bool read_only); - void get(const StringRef & name, Field & min_value, Field & max_value, bool & read_only) const; + void set(const StringRef & setting_name, const Field & min_value, const Field & max_value, bool read_only); + void set(size_t setting_index, const Field & min_value, const Field & max_value, bool read_only); + void get(const StringRef & setting_name, Field & min_value, Field & max_value, bool & read_only) const; + void get(size_t setting_index, Field & min_value, Field & max_value, bool & read_only) const; void merge(const SettingsConstraints & other); diff --git a/src/Access/SettingsProfile.cpp b/src/Access/SettingsProfile.cpp index c2f868502c0..64fb91eb66b 100644 --- a/src/Access/SettingsProfile.cpp +++ b/src/Access/SettingsProfile.cpp @@ -3,6 +3,7 @@ namespace DB { + bool SettingsProfile::equal(const IAccessEntity & other) const { if (!IAccessEntity::equal(other)) @@ -10,4 +11,5 @@ bool SettingsProfile::equal(const IAccessEntity & other) const const auto & other_profile = typeid_cast(other); return (elements == other_profile.elements) && (to_roles == other_profile.to_roles); } + } diff --git a/src/Access/SettingsProfile.h b/src/Access/SettingsProfile.h index b73b45d57cf..9589b5b3eb5 100644 --- a/src/Access/SettingsProfile.h +++ b/src/Access/SettingsProfile.h @@ -18,6 +18,8 @@ struct SettingsProfile : public IAccessEntity bool equal(const IAccessEntity & other) const override; std::shared_ptr clone() const override { return cloneImpl(); } + static constexpr const Type TYPE = Type::SETTINGS_PROFILE; + Type getType() const override { return TYPE; } }; using SettingsProfilePtr = std::shared_ptr; diff --git a/src/Access/SettingsProfileElement.cpp b/src/Access/SettingsProfileElement.cpp index b052f8b5e75..d4f6ff5d0f2 100644 --- a/src/Access/SettingsProfileElement.cpp +++ b/src/Access/SettingsProfileElement.cpp @@ -33,21 +33,20 @@ void SettingsProfileElement::init(const ASTSettingsProfileElement & ast, const A if (!ast.parent_profile.empty()) parent_profile = name_to_id(ast.parent_profile); - if (!ast.name.empty()) + if (!ast.setting_name.empty()) { - name = ast.name; + setting_index = Settings::findIndexStrict(ast.setting_name); value = ast.value; min_value = ast.min_value; max_value = ast.max_value; readonly = ast.readonly; - size_t index = Settings::findIndexStrict(name); if (!value.isNull()) - value = Settings::valueToCorrespondingType(index, value); + value = Settings::valueToCorrespondingType(setting_index, value); if (!min_value.isNull()) - min_value = Settings::valueToCorrespondingType(index, min_value); + min_value = Settings::valueToCorrespondingType(setting_index, min_value); if (!max_value.isNull()) - max_value = Settings::valueToCorrespondingType(index, max_value); + max_value = Settings::valueToCorrespondingType(setting_index, max_value); } } @@ -60,7 +59,9 @@ std::shared_ptr SettingsProfileElement::toAST() const if (parent_profile) ast->parent_profile = ::DB::toString(*parent_profile); - ast->name = name; + if (setting_index != static_cast(-1)) + ast->setting_name = Settings::getName(setting_index).toString(); + ast->value = value; ast->min_value = min_value; ast->max_value = max_value; @@ -81,7 +82,9 @@ std::shared_ptr SettingsProfileElement::toASTWithName ast->parent_profile = *parent_profile_name; } - ast->name = name; + if (setting_index != static_cast(-1)) + ast->setting_name = Settings::getName(setting_index).toString(); + ast->value = value; ast->min_value = min_value; ast->max_value = max_value; @@ -132,8 +135,8 @@ Settings SettingsProfileElements::toSettings() const Settings res; for (const auto & elem : *this) { - if (!elem.name.empty() && !elem.value.isNull()) - res.set(elem.name, elem.value); + if ((elem.setting_index != static_cast(-1)) && !elem.value.isNull()) + res.set(elem.setting_index, elem.value); } return res; } @@ -143,8 +146,8 @@ SettingsChanges SettingsProfileElements::toSettingsChanges() const SettingsChanges res; for (const auto & elem : *this) { - if (!elem.name.empty() && !elem.value.isNull()) - res.push_back({elem.name, elem.value}); + if ((elem.setting_index != static_cast(-1)) && !elem.value.isNull()) + res.push_back({Settings::getName(elem.setting_index).toString(), elem.value}); } return res; } @@ -154,14 +157,14 @@ SettingsConstraints SettingsProfileElements::toSettingsConstraints() const SettingsConstraints res; for (const auto & elem : *this) { - if (!elem.name.empty()) + if (elem.setting_index != static_cast(-1)) { if (!elem.min_value.isNull()) - res.setMinValue(elem.name, elem.min_value); + res.setMinValue(elem.setting_index, elem.min_value); if (!elem.max_value.isNull()) - res.setMaxValue(elem.name, elem.max_value); + res.setMaxValue(elem.setting_index, elem.max_value); if (elem.readonly) - res.setReadOnly(elem.name, *elem.readonly); + res.setReadOnly(elem.setting_index, *elem.readonly); } } return res; diff --git a/src/Access/SettingsProfileElement.h b/src/Access/SettingsProfileElement.h index abcac2567c8..f64317344b8 100644 --- a/src/Access/SettingsProfileElement.h +++ b/src/Access/SettingsProfileElement.h @@ -20,13 +20,13 @@ class AccessControlManager; struct SettingsProfileElement { std::optional parent_profile; - String name; + size_t setting_index = static_cast(-1); Field value; Field min_value; Field max_value; std::optional readonly; - auto toTuple() const { return std::tie(parent_profile, name, value, min_value, max_value, readonly); } + auto toTuple() const { return std::tie(parent_profile, setting_index, value, min_value, max_value, readonly); } friend bool operator==(const SettingsProfileElement & lhs, const SettingsProfileElement & rhs) { return lhs.toTuple() == rhs.toTuple(); } friend bool operator!=(const SettingsProfileElement & lhs, const SettingsProfileElement & rhs) { return !(lhs == rhs); } friend bool operator <(const SettingsProfileElement & lhs, const SettingsProfileElement & rhs) { return lhs.toTuple() < rhs.toTuple(); } diff --git a/src/Access/SettingsProfilesCache.cpp b/src/Access/SettingsProfilesCache.cpp index f283715e129..95074ff7d0b 100644 --- a/src/Access/SettingsProfilesCache.cpp +++ b/src/Access/SettingsProfilesCache.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -149,32 +150,34 @@ void SettingsProfilesCache::mergeSettingsAndConstraintsFor(EnabledSettings & ena void SettingsProfilesCache::substituteProfiles(SettingsProfileElements & elements) const { - bool stop_substituting = false; boost::container::flat_set already_substituted; - while (!stop_substituting) + for (size_t i = 0; i != elements.size();) { - stop_substituting = true; - for (size_t i = 0; i != elements.size(); ++i) + auto & element = elements[i]; + if (!element.parent_profile) { - auto & element = elements[i]; - if (!element.parent_profile) - continue; - - auto parent_profile_id = *element.parent_profile; - element.parent_profile.reset(); - if (already_substituted.count(parent_profile_id)) - continue; - - already_substituted.insert(parent_profile_id); - auto parent_profile = all_profiles.find(parent_profile_id); - if (parent_profile == all_profiles.end()) - continue; - - const auto & parent_profile_elements = parent_profile->second->elements; - elements.insert(elements.begin() + i + 1, parent_profile_elements.begin(), parent_profile_elements.end()); - i += parent_profile_elements.size(); - stop_substituting = false; + ++i; + continue; } + + auto parent_profile_id = *element.parent_profile; + element.parent_profile.reset(); + if (already_substituted.count(parent_profile_id)) + { + ++i; + continue; + } + + already_substituted.insert(parent_profile_id); + auto parent_profile = all_profiles.find(parent_profile_id); + if (parent_profile == all_profiles.end()) + { + ++i; + continue; + } + + const auto & parent_profile_elements = parent_profile->second->elements; + elements.insert(elements.begin() + i, parent_profile_elements.begin(), parent_profile_elements.end()); } } @@ -182,7 +185,7 @@ void SettingsProfilesCache::substituteProfiles(SettingsProfileElements & element std::shared_ptr SettingsProfilesCache::getEnabledSettings( const UUID & user_id, const SettingsProfileElements & settings_from_user, - const std::vector & enabled_roles, + const boost::container::flat_set & enabled_roles, const SettingsProfileElements & settings_from_enabled_roles) { std::lock_guard lock{mutex}; diff --git a/src/Access/SettingsProfilesCache.h b/src/Access/SettingsProfilesCache.h index 656ffc6fce6..42dd05df351 100644 --- a/src/Access/SettingsProfilesCache.h +++ b/src/Access/SettingsProfilesCache.h @@ -29,7 +29,7 @@ public: std::shared_ptr getEnabledSettings( const UUID & user_id, const SettingsProfileElements & settings_from_user_, - const std::vector & enabled_roles, + const boost::container::flat_set & enabled_roles, const SettingsProfileElements & settings_from_enabled_roles_); std::shared_ptr getProfileSettings(const String & profile_name); diff --git a/src/Access/User.cpp b/src/Access/User.cpp index 4a751c31e25..f57ec7c1359 100644 --- a/src/Access/User.cpp +++ b/src/Access/User.cpp @@ -10,9 +10,8 @@ bool User::equal(const IAccessEntity & other) const return false; const auto & other_user = typeid_cast(other); return (authentication == other_user.authentication) && (allowed_client_hosts == other_user.allowed_client_hosts) - && (access == other_user.access) && (access_with_grant_option == other_user.access_with_grant_option) - && (granted_roles == other_user.granted_roles) && (granted_roles_with_admin_option == other_user.granted_roles_with_admin_option) - && (default_roles == other_user.default_roles) && (settings == other_user.settings); + && (access == other_user.access) && (granted_roles == other_user.granted_roles) && (default_roles == other_user.default_roles) + && (settings == other_user.settings); } } diff --git a/src/Access/User.h b/src/Access/User.h index 6df3b3e4d3c..da2fb14e131 100644 --- a/src/Access/User.h +++ b/src/Access/User.h @@ -3,11 +3,10 @@ #include #include #include -#include +#include +#include #include #include -#include -#include namespace DB @@ -18,15 +17,15 @@ struct User : public IAccessEntity { Authentication authentication; AllowedClientHosts allowed_client_hosts = AllowedClientHosts::AnyHostTag{}; - AccessRights access; - AccessRights access_with_grant_option; - boost::container::flat_set granted_roles; - boost::container::flat_set granted_roles_with_admin_option; + GrantedAccess access; + GrantedRoles granted_roles; ExtendedRoleSet default_roles = ExtendedRoleSet::AllTag{}; SettingsProfileElements settings; bool equal(const IAccessEntity & other) const override; std::shared_ptr clone() const override { return cloneImpl(); } + static constexpr const Type TYPE = Type::USER; + Type getType() const override { return TYPE; } }; using UserPtr = std::shared_ptr; diff --git a/src/Access/UsersConfigAccessStorage.cpp b/src/Access/UsersConfigAccessStorage.cpp index 0842839dec8..f5f48a2390e 100644 --- a/src/Access/UsersConfigAccessStorage.cpp +++ b/src/Access/UsersConfigAccessStorage.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -26,34 +27,23 @@ namespace ErrorCodes namespace { - char getTypeChar(std::type_index type) - { - if (type == typeid(User)) - return 'U'; - if (type == typeid(Quota)) - return 'Q'; - if (type == typeid(RowPolicy)) - return 'P'; - if (type == typeid(SettingsProfile)) - return 'S'; - return 0; - } + using EntityType = IAccessStorage::EntityType; + using EntityTypeInfo = IAccessStorage::EntityTypeInfo; - - UUID generateID(std::type_index type, const String & name) + UUID generateID(EntityType type, const String & name) { Poco::MD5Engine md5; md5.update(name); char type_storage_chars[] = " USRSXML"; - type_storage_chars[0] = getTypeChar(type); + type_storage_chars[0] = EntityTypeInfo::get(type).unique_char; md5.update(type_storage_chars, strlen(type_storage_chars)); UUID result; memcpy(&result, md5.digest().data(), md5.digestLength()); return result; } + UUID generateID(const IAccessEntity & entity) { return generateID(entity.getType(), entity.getName()); } - UUID generateID(const IAccessEntity & entity) { return generateID(entity.getType(), entity.getFullName()); } UserPtr parseUser(const Poco::Util::AbstractConfiguration & config, const String & user_name) { @@ -62,18 +52,20 @@ namespace String user_config = "users." + user_name; - bool has_password = config.has(user_config + ".password"); + bool has_no_password = config.has(user_config + ".no_password"); + bool has_password_plaintext = config.has(user_config + ".password"); bool has_password_sha256_hex = config.has(user_config + ".password_sha256_hex"); bool has_password_double_sha1_hex = config.has(user_config + ".password_double_sha1_hex"); - if (has_password + has_password_sha256_hex + has_password_double_sha1_hex > 1) - throw Exception("More than one field of 'password', 'password_sha256_hex', 'password_double_sha1_hex' is used to specify password for user " + user_name + ". Must be only one of them.", + size_t num_password_fields = has_no_password + has_password_plaintext + has_password_sha256_hex + has_password_double_sha1_hex; + if (num_password_fields > 1) + throw Exception("More than one field of 'password', 'password_sha256_hex', 'password_double_sha1_hex', 'no_password' are used to specify password for user " + user_name + ". Must be only one of them.", ErrorCodes::BAD_ARGUMENTS); - if (!has_password && !has_password_sha256_hex && !has_password_double_sha1_hex) - throw Exception("Either 'password' or 'password_sha256_hex' or 'password_double_sha1_hex' must be specified for user " + user_name + ".", ErrorCodes::BAD_ARGUMENTS); + if (num_password_fields < 1) + throw Exception("Either 'password' or 'password_sha256_hex' or 'password_double_sha1_hex' or 'no_password' must be specified for user " + user_name + ".", ErrorCodes::BAD_ARGUMENTS); - if (has_password) + if (has_password_plaintext) { user->authentication = Authentication{Authentication::PLAINTEXT_PASSWORD}; user->authentication.setPassword(config.getString(user_config + ".password")); @@ -94,7 +86,7 @@ namespace { auto profile_name = config.getString(profile_name_config); SettingsProfileElement profile_element; - profile_element.parent_profile = generateID(typeid(SettingsProfile), profile_name); + profile_element.parent_profile = generateID(EntityType::SETTINGS_PROFILE, profile_name); user->settings.push_back(std::move(profile_element)); } @@ -151,30 +143,30 @@ namespace } } - user->access.grant(AccessType::ALL); /// By default all databases are accessible. + /// By default all databases are accessible + /// and the user can grant everything he has. + user->access.grantWithGrantOption(AccessType::ALL); if (databases) { user->access.revoke(AccessFlags::allFlags() - AccessFlags::allGlobalFlags()); - user->access.grant(AccessFlags::allDictionaryFlags(), IDictionary::NO_DATABASE_TAG); + user->access.grantWithGrantOption(AccessFlags::allDictionaryFlags(), IDictionary::NO_DATABASE_TAG); for (const String & database : *databases) - user->access.grant(AccessFlags::allFlags(), database); + user->access.grantWithGrantOption(AccessFlags::allFlags(), database); } if (dictionaries) { user->access.revoke(AccessFlags::allDictionaryFlags(), IDictionary::NO_DATABASE_TAG); for (const String & dictionary : *dictionaries) - user->access.grant(AccessFlags::allDictionaryFlags(), IDictionary::NO_DATABASE_TAG, dictionary); + user->access.grantWithGrantOption(AccessFlags::allDictionaryFlags(), IDictionary::NO_DATABASE_TAG, dictionary); } - user->access_with_grant_option = user->access; /// By default the user can grant everything he has. - bool access_management = config.getBool(user_config + ".access_management", false); if (!access_management) { user->access.revoke(AccessType::ACCESS_MANAGEMENT); - user->access_with_grant_option.clear(); + user->access.revokeGrantOption(AccessType::ALL); } return user; @@ -235,14 +227,13 @@ namespace limits.duration = duration; limits.randomize_interval = config.getBool(interval_config + ".randomize", false); - using ResourceType = Quota::ResourceType; - limits.max[ResourceType::QUERIES] = config.getUInt64(interval_config + ".queries", Quota::UNLIMITED); - limits.max[ResourceType::ERRORS] = config.getUInt64(interval_config + ".errors", Quota::UNLIMITED); - limits.max[ResourceType::RESULT_ROWS] = config.getUInt64(interval_config + ".result_rows", Quota::UNLIMITED); - limits.max[ResourceType::RESULT_BYTES] = config.getUInt64(interval_config + ".result_bytes", Quota::UNLIMITED); - limits.max[ResourceType::READ_ROWS] = config.getUInt64(interval_config + ".read_rows", Quota::UNLIMITED); - limits.max[ResourceType::READ_BYTES] = config.getUInt64(interval_config + ".read_bytes", Quota::UNLIMITED); - limits.max[ResourceType::EXECUTION_TIME] = Quota::secondsToExecutionTime(config.getUInt64(interval_config + ".execution_time", Quota::UNLIMITED)); + for (auto resource_type : ext::range(Quota::MAX_RESOURCE_TYPE)) + { + const auto & type_info = Quota::ResourceTypeInfo::get(resource_type); + auto value = config.getString(interval_config + "." + type_info.name, "0"); + if (value != "0") + limits.max[resource_type] = type_info.amountFromString(value); + } } quota->to_roles.add(user_ids); @@ -259,7 +250,7 @@ namespace for (const auto & user_name : user_names) { if (config.has("users." + user_name + ".quota")) - quota_to_user_ids[config.getString("users." + user_name + ".quota")].push_back(generateID(typeid(User), user_name)); + quota_to_user_ids[config.getString("users." + user_name + ".quota")].push_back(generateID(EntityType::USER, user_name)); } Poco::Util::AbstractConfiguration::Keys quota_names; @@ -343,9 +334,9 @@ namespace String filter = (it != user_to_filters.end()) ? it->second : "1"; auto policy = std::make_shared(); - policy->setFullName(database, table_name, user_name); + policy->setNameParts(user_name, database, table_name); policy->conditions[RowPolicy::SELECT_FILTER] = filter; - policy->to_roles.add(generateID(typeid(User), user_name)); + policy->to_roles.add(generateID(EntityType::USER, user_name)); policies.push_back(policy); } } @@ -362,7 +353,7 @@ namespace for (const String & name : names) { SettingsProfileElement profile_element; - profile_element.name = name; + profile_element.setting_index = Settings::findIndexStrict(name); Poco::Util::AbstractConfiguration::Keys constraint_types; String path_to_name = path_to_constraints + "." + name; config.keys(path_to_name, constraint_types); @@ -399,7 +390,7 @@ namespace { String parent_profile_name = config.getString(profile_config + "." + key); SettingsProfileElement profile_element; - profile_element.parent_profile = generateID(typeid(SettingsProfile), parent_profile_name); + profile_element.parent_profile = generateID(EntityType::SETTINGS_PROFILE, parent_profile_name); profile->elements.emplace_back(std::move(profile_element)); continue; } @@ -411,7 +402,7 @@ namespace } SettingsProfileElement profile_element; - profile_element.name = key; + profile_element.setting_index = Settings::findIndexStrict(key); profile_element.value = config.getString(profile_config + "." + key); profile->elements.emplace_back(std::move(profile_element)); } @@ -461,13 +452,13 @@ void UsersConfigAccessStorage::setConfiguration(const Poco::Util::AbstractConfig } -std::optional UsersConfigAccessStorage::findImpl(std::type_index type, const String & name) const +std::optional UsersConfigAccessStorage::findImpl(EntityType type, const String & name) const { return memory_storage.find(type, name); } -std::vector UsersConfigAccessStorage::findAllImpl(std::type_index type) const +std::vector UsersConfigAccessStorage::findAllImpl(EntityType type) const { return memory_storage.findAll(type); } @@ -493,21 +484,21 @@ String UsersConfigAccessStorage::readNameImpl(const UUID & id) const UUID UsersConfigAccessStorage::insertImpl(const AccessEntityPtr & entity, bool) { - throwReadonlyCannotInsert(entity->getType(), entity->getFullName()); + throwReadonlyCannotInsert(entity->getType(), entity->getName()); } void UsersConfigAccessStorage::removeImpl(const UUID & id) { auto entity = read(id); - throwReadonlyCannotRemove(entity->getType(), entity->getFullName()); + throwReadonlyCannotRemove(entity->getType(), entity->getName()); } void UsersConfigAccessStorage::updateImpl(const UUID & id, const UpdateFunc &) { auto entity = read(id); - throwReadonlyCannotUpdate(entity->getType(), entity->getFullName()); + throwReadonlyCannotUpdate(entity->getType(), entity->getName()); } @@ -517,7 +508,7 @@ ext::scope_guard UsersConfigAccessStorage::subscribeForChangesImpl(const UUID & } -ext::scope_guard UsersConfigAccessStorage::subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const +ext::scope_guard UsersConfigAccessStorage::subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const { return memory_storage.subscribeForChanges(type, handler); } @@ -529,7 +520,7 @@ bool UsersConfigAccessStorage::hasSubscriptionImpl(const UUID & id) const } -bool UsersConfigAccessStorage::hasSubscriptionImpl(std::type_index type) const +bool UsersConfigAccessStorage::hasSubscriptionImpl(EntityType type) const { return memory_storage.hasSubscription(type); } diff --git a/src/Access/UsersConfigAccessStorage.h b/src/Access/UsersConfigAccessStorage.h index 773d8caa570..d7012cda4ff 100644 --- a/src/Access/UsersConfigAccessStorage.h +++ b/src/Access/UsersConfigAccessStorage.h @@ -23,8 +23,8 @@ public: void setConfiguration(const Poco::Util::AbstractConfiguration & config); private: - std::optional findImpl(std::type_index type, const String & name) const override; - std::vector findAllImpl(std::type_index type) const override; + std::optional findImpl(EntityType type, const String & name) const override; + std::vector findAllImpl(EntityType type) const override; bool existsImpl(const UUID & id) const override; AccessEntityPtr readImpl(const UUID & id) const override; String readNameImpl(const UUID & id) const override; @@ -33,9 +33,9 @@ private: void removeImpl(const UUID & id) override; void updateImpl(const UUID & id, const UpdateFunc & update_func) override; ext::scope_guard subscribeForChangesImpl(const UUID & id, const OnChangedHandler & handler) const override; - ext::scope_guard subscribeForChangesImpl(std::type_index type, const OnChangedHandler & handler) const override; + ext::scope_guard subscribeForChangesImpl(EntityType type, const OnChangedHandler & handler) const override; bool hasSubscriptionImpl(const UUID & id) const override; - bool hasSubscriptionImpl(std::type_index type) const override; + bool hasSubscriptionImpl(EntityType type) const override; MemoryAccessStorage memory_storage; }; diff --git a/src/Access/ya.make b/src/Access/ya.make index fb2e23e0684..970c0714a93 100644 --- a/src/Access/ya.make +++ b/src/Access/ya.make @@ -18,13 +18,15 @@ SRCS( EnabledRowPolicies.cpp EnabledSettings.cpp ExtendedRoleSet.cpp + GrantedAccess.cpp + GrantedRoles.cpp IAccessEntity.cpp IAccessStorage.cpp MemoryAccessStorage.cpp MultipleAccessStorage.cpp Quota.cpp QuotaCache.cpp - QuotaUsageInfo.cpp + QuotaUsage.cpp Role.cpp RoleCache.cpp RowPolicy.cpp diff --git a/src/AggregateFunctions/AggregateFunctionAggThrow.cpp b/src/AggregateFunctions/AggregateFunctionAggThrow.cpp index 2bf00676d77..ea3eb9b1a20 100644 --- a/src/AggregateFunctions/AggregateFunctionAggThrow.cpp +++ b/src/AggregateFunctions/AggregateFunctionAggThrow.cpp @@ -93,7 +93,7 @@ public: buf.read(c); } - void insertResultInto(ConstAggregateDataPtr, IColumn & to) const override + void insertResultInto(AggregateDataPtr, IColumn & to) const override { to.insertDefault(); } diff --git a/src/AggregateFunctions/AggregateFunctionArgMinMax.h b/src/AggregateFunctions/AggregateFunctionArgMinMax.h index 88ad9430bf0..9a0c428d75b 100644 --- a/src/AggregateFunctions/AggregateFunctionArgMinMax.h +++ b/src/AggregateFunctions/AggregateFunctionArgMinMax.h @@ -85,7 +85,7 @@ public: return Data::allocatesMemoryInArena(); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { this->data(place).result.insertResultInto(to); } diff --git a/src/AggregateFunctions/AggregateFunctionArray.h b/src/AggregateFunctions/AggregateFunctionArray.h index cc4d5ffebb2..4fe5e459ae1 100644 --- a/src/AggregateFunctions/AggregateFunctionArray.h +++ b/src/AggregateFunctions/AggregateFunctionArray.h @@ -119,7 +119,7 @@ public: nested_func->deserialize(place, buf, arena); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { nested_func->insertResultInto(place, to); } diff --git a/src/AggregateFunctions/AggregateFunctionAvg.h b/src/AggregateFunctions/AggregateFunctionAvg.h index 06cc8c3bd7d..d9ef8647b82 100644 --- a/src/AggregateFunctions/AggregateFunctionAvg.h +++ b/src/AggregateFunctions/AggregateFunctionAvg.h @@ -71,16 +71,16 @@ public: void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override { writeBinary(this->data(place).numerator, buf); - writeVarUInt(this->data(place).denominator, buf); + writeBinary(this->data(place).denominator, buf); } void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena *) const override { readBinary(this->data(place).numerator, buf); - readVarUInt(this->data(place).denominator, buf); + readBinary(this->data(place).denominator, buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { auto & column = static_cast(to); column.getData().push_back(this->data(place).template result()); diff --git a/src/AggregateFunctions/AggregateFunctionBitwise.h b/src/AggregateFunctions/AggregateFunctionBitwise.h index 29afa7db8d5..a4e5f7ddafa 100644 --- a/src/AggregateFunctions/AggregateFunctionBitwise.h +++ b/src/AggregateFunctions/AggregateFunctionBitwise.h @@ -74,7 +74,7 @@ public: readBinary(this->data(place).value, buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { assert_cast &>(to).getData().push_back(this->data(place).value); } diff --git a/src/AggregateFunctions/AggregateFunctionBoundingRatio.h b/src/AggregateFunctions/AggregateFunctionBoundingRatio.h index 8451d6532f6..81846db4bac 100644 --- a/src/AggregateFunctions/AggregateFunctionBoundingRatio.h +++ b/src/AggregateFunctions/AggregateFunctionBoundingRatio.h @@ -150,7 +150,7 @@ public: data(place).deserialize(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { assert_cast(to).getData().push_back(getBoundingRatio(data(place))); } diff --git a/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h b/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h index 25e5c2d1f1a..1c397c26631 100644 --- a/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h +++ b/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h @@ -118,7 +118,7 @@ public: } void insertResultInto( - ConstAggregateDataPtr place, + AggregateDataPtr place, IColumn & to ) const override { diff --git a/src/AggregateFunctions/AggregateFunctionCount.h b/src/AggregateFunctions/AggregateFunctionCount.h index 3e153d89d01..092ffc6b6cf 100644 --- a/src/AggregateFunctions/AggregateFunctionCount.h +++ b/src/AggregateFunctions/AggregateFunctionCount.h @@ -57,7 +57,7 @@ public: readVarUInt(data(place).count, buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { assert_cast(to).getData().push_back(data(place).count); } @@ -108,7 +108,7 @@ public: readVarUInt(data(place).count, buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { assert_cast(to).getData().push_back(data(place).count); } diff --git a/src/AggregateFunctions/AggregateFunctionEntropy.h b/src/AggregateFunctions/AggregateFunctionEntropy.h index 942de8ffe98..ff233a5ac93 100644 --- a/src/AggregateFunctions/AggregateFunctionEntropy.h +++ b/src/AggregateFunctions/AggregateFunctionEntropy.h @@ -23,18 +23,10 @@ struct EntropyData { using Weight = UInt64; - using HashingMap = HashMap< - Value, Weight, - HashCRC32, - HashTableGrower<4>, - HashTableAllocatorWithStackMemory) * (1 << 3)>>; + using HashingMap = HashMapWithStackMemory, 4>; /// For the case of pre-hashed values. - using TrivialMap = HashMap< - Value, Weight, - UInt128TrivialHash, - HashTableGrower<4>, - HashTableAllocatorWithStackMemory) * (1 << 3)>>; + using TrivialMap = HashMapWithStackMemory; using Map = std::conditional_t, TrivialMap, HashingMap>; @@ -140,7 +132,7 @@ public: this->data(place).deserialize(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { auto & column = assert_cast &>(to); column.getData().push_back(this->data(place).get()); diff --git a/src/AggregateFunctions/AggregateFunctionForEach.h b/src/AggregateFunctions/AggregateFunctionForEach.h index 94e60c75382..23a3487de47 100644 --- a/src/AggregateFunctions/AggregateFunctionForEach.h +++ b/src/AggregateFunctions/AggregateFunctionForEach.h @@ -225,15 +225,15 @@ public: } } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { - const AggregateFunctionForEachData & state = data(place); + AggregateFunctionForEachData & state = data(place); ColumnArray & arr_to = assert_cast(to); ColumnArray::Offsets & offsets_to = arr_to.getOffsets(); IColumn & elems_to = arr_to.getData(); - const char * nested_state = state.array_of_aggregate_datas; + char * nested_state = state.array_of_aggregate_datas; for (size_t i = 0; i < state.dynamic_array_size; ++i) { nested_func->insertResultInto(nested_state, elems_to); diff --git a/src/AggregateFunctions/AggregateFunctionGroupArray.h b/src/AggregateFunctions/AggregateFunctionGroupArray.h index 2d345cff1f7..b76efd9f6c2 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArray.h @@ -282,7 +282,7 @@ public: // if constexpr (Trait::sampler == Sampler::DETERMINATOR) } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { const auto & value = this->data(place).value; size_t size = value.size(); @@ -600,7 +600,7 @@ public: // if constexpr (Trait::sampler == Sampler::DETERMINATOR) } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { auto & column_array = assert_cast(to); @@ -815,7 +815,7 @@ public: data(place).last = prev; } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { auto & column_array = assert_cast(to); diff --git a/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h b/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h index 395d13f7d34..0eec38c51a7 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h @@ -179,7 +179,7 @@ public: } } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { ColumnArray & to_array = assert_cast(to); IColumn & to_data = to_array.getData(); diff --git a/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h b/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h index 2c5c56999b2..8f93a7eb25a 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h @@ -158,7 +158,7 @@ public: this->data(place).sum = value.back(); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { const auto & data = this->data(place); size_t size = data.value.size(); diff --git a/src/AggregateFunctions/AggregateFunctionGroupBitmap.h b/src/AggregateFunctions/AggregateFunctionGroupBitmap.h index 56901e28e01..766479cc08d 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupBitmap.h +++ b/src/AggregateFunctions/AggregateFunctionGroupBitmap.h @@ -48,7 +48,7 @@ public: this->data(place).rbs.read(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { assert_cast &>(to).getData().push_back(this->data(place).rbs.size()); } @@ -113,7 +113,7 @@ public: this->data(place).rbs.read(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { assert_cast &>(to).getData().push_back(this->data(place).rbs.size()); } diff --git a/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h b/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h index 344ce7045dd..0a9bcec698b 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h +++ b/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h @@ -11,10 +11,8 @@ // garbage that breaks the build (e.g. it changes _POSIX_C_SOURCE). // TODO: find out what it is. On github, they have proper inteface headers like // this one: https://github.com/RoaringBitmap/CRoaring/blob/master/include/roaring/roaring.h -#pragma GCC diagnostic push -#pragma GCC diagnostic warning "-Wold-style-cast" #include -#pragma GCC diagnostic pop + namespace DB { diff --git a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h index 09585ecd38c..88b1c87f526 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include @@ -26,12 +28,7 @@ template struct AggregateFunctionGroupUniqArrayData { /// When creating, the hash table must be small. - using Set = HashSet< - T, - DefaultHash, - HashTableGrower<4>, - HashTableAllocatorWithStackMemory - >; + using Set = HashSetWithStackMemory, 4>; Set value; }; @@ -100,7 +97,7 @@ public: this->data(place).value.read(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { ColumnArray & arr_to = assert_cast(to); ColumnArray::Offsets & offsets_to = arr_to.getOffsets(); @@ -124,9 +121,10 @@ public: /// Generic implementation, it uses serialized representation as object descriptor. struct AggregateFunctionGroupUniqArrayGenericData { - static constexpr size_t INIT_ELEMS = 2; /// adjustable - static constexpr size_t ELEM_SIZE = sizeof(HashSetCellWithSavedHash); - using Set = HashSetWithSavedHash, HashTableAllocatorWithStackMemory>; + static constexpr size_t INITIAL_SIZE_DEGREE = 3; /// adjustable + + using Set = HashSetWithSavedHashWithStackMemory; Set value; }; @@ -139,7 +137,8 @@ static void deserializeAndInsertImpl(StringRef str, IColumn & data_to); */ template class AggregateFunctionGroupUniqArrayGeneric - : public IAggregateFunctionDataHelper> + : public IAggregateFunctionDataHelper> { DataTypePtr & input_data_type; @@ -158,6 +157,7 @@ class AggregateFunctionGroupUniqArrayGeneric { const char * begin = nullptr; StringRef serialized = column.serializeValueIntoArena(row_num, arena, begin); + assert(serialized.data != nullptr); return SerializedKeyHolder{serialized, arena}; } } @@ -204,9 +204,7 @@ public: //TODO: set.reserve(size); for (size_t i = 0; i < size; ++i) - { set.insert(readStringBinaryInto(*arena, buf)); - } } void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena) const override @@ -239,7 +237,7 @@ public: } } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { ColumnArray & arr_to = assert_cast(to); ColumnArray::Offsets & offsets_to = arr_to.getOffsets(); @@ -249,9 +247,7 @@ public: offsets_to.push_back(offsets_to.back() + set.size()); for (auto & elem : set) - { deserializeAndInsert(elem.getValue(), data_to); - } } }; diff --git a/src/AggregateFunctions/AggregateFunctionHistogram.h b/src/AggregateFunctions/AggregateFunctionHistogram.h index 96ee01652de..8eaa42fdac4 100644 --- a/src/AggregateFunctions/AggregateFunctionHistogram.h +++ b/src/AggregateFunctions/AggregateFunctionHistogram.h @@ -353,9 +353,9 @@ public: this->data(place).read(buf, max_bins); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { - auto & data = this->data(const_cast(place)); + auto & data = this->data(place); auto & to_array = assert_cast(to); ColumnArray::Offsets & offsets_to = to_array.getOffsets(); diff --git a/src/AggregateFunctions/AggregateFunctionIf.h b/src/AggregateFunctions/AggregateFunctionIf.h index e33fb1df53d..bf4f0b24de3 100644 --- a/src/AggregateFunctions/AggregateFunctionIf.h +++ b/src/AggregateFunctions/AggregateFunctionIf.h @@ -95,7 +95,7 @@ public: nested_func->deserialize(place, buf, arena); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { nested_func->insertResultInto(place, to); } diff --git a/src/AggregateFunctions/AggregateFunctionMLMethod.h b/src/AggregateFunctions/AggregateFunctionMLMethod.h index bb241074a1e..a11ca9032a5 100644 --- a/src/AggregateFunctions/AggregateFunctionMLMethod.h +++ b/src/AggregateFunctions/AggregateFunctionMLMethod.h @@ -15,7 +15,6 @@ namespace ErrorCodes { extern const int LOGICAL_ERROR; extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; - extern const int BAD_CAST; } /** @@ -381,7 +380,7 @@ public: auto * column = typeid_cast(&to); if (!column) throw Exception("Cast of column of predictions is incorrect. getReturnTypeToPredict must return same value as it is casted to", - ErrorCodes::BAD_CAST); + ErrorCodes::LOGICAL_ERROR); this->data(place).predict(column->getData(), block, offset, limit, arguments, context); } @@ -389,7 +388,7 @@ public: /** This function is called if aggregate function without State modifier is selected in a query. * Inserts all weights of the model into the column 'to', so user may use such information if needed */ - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { this->data(place).returnWeights(to); } diff --git a/src/AggregateFunctions/AggregateFunctionMaxIntersections.h b/src/AggregateFunctions/AggregateFunctionMaxIntersections.h index 13ed6ae42fe..050c5fd78ea 100644 --- a/src/AggregateFunctions/AggregateFunctionMaxIntersections.h +++ b/src/AggregateFunctions/AggregateFunctionMaxIntersections.h @@ -129,14 +129,14 @@ public: buf.read(reinterpret_cast(value.data()), size * sizeof(value[0])); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { Int64 current_intersections = 0; Int64 max_intersections = 0; PointType position_of_max_intersections = 0; /// const_cast because we will sort the array - auto & array = const_cast::Array &>(this->data(place).value); + auto & array = this->data(place).value; /// Sort by position; for equal position, sort by weight to get deterministic result. std::sort(array.begin(), array.end()); diff --git a/src/AggregateFunctions/AggregateFunctionMerge.h b/src/AggregateFunctions/AggregateFunctionMerge.h index 2e803211e8f..51a3c11118f 100644 --- a/src/AggregateFunctions/AggregateFunctionMerge.h +++ b/src/AggregateFunctions/AggregateFunctionMerge.h @@ -93,7 +93,7 @@ public: nested_func->deserialize(place, buf, arena); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { nested_func->insertResultInto(place, to); } diff --git a/src/AggregateFunctions/AggregateFunctionMinMaxAny.h b/src/AggregateFunctions/AggregateFunctionMinMaxAny.h index e2f204e1c07..69504f7b249 100644 --- a/src/AggregateFunctions/AggregateFunctionMinMaxAny.h +++ b/src/AggregateFunctions/AggregateFunctionMinMaxAny.h @@ -746,7 +746,7 @@ public: return Data::allocatesMemoryInArena(); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { this->data(place).insertResultInto(to); } diff --git a/src/AggregateFunctions/AggregateFunctionNothing.h b/src/AggregateFunctions/AggregateFunctionNothing.h index d9c8f9cea19..511dbbecd38 100644 --- a/src/AggregateFunctions/AggregateFunctionNothing.h +++ b/src/AggregateFunctions/AggregateFunctionNothing.h @@ -67,7 +67,7 @@ public: { } - void insertResultInto(ConstAggregateDataPtr, IColumn & to) const override + void insertResultInto(AggregateDataPtr, IColumn & to) const override { to.insertDefault(); } diff --git a/src/AggregateFunctions/AggregateFunctionNull.h b/src/AggregateFunctions/AggregateFunctionNull.h index a0fe96b6f62..55d610207f1 100644 --- a/src/AggregateFunctions/AggregateFunctionNull.h +++ b/src/AggregateFunctions/AggregateFunctionNull.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -53,13 +54,13 @@ protected: static void initFlag(AggregateDataPtr place) noexcept { - if (result_is_nullable) + if constexpr (result_is_nullable) place[0] = 0; } static void setFlag(AggregateDataPtr place) noexcept { - if (result_is_nullable) + if constexpr (result_is_nullable) place[0] = 1; } @@ -72,7 +73,7 @@ public: AggregateFunctionNullBase(AggregateFunctionPtr nested_function_, const DataTypes & arguments, const Array & params) : IAggregateFunctionHelper(arguments, params), nested_function{nested_function_} { - if (result_is_nullable) + if constexpr (result_is_nullable) prefix_size = nested_function->alignOfData(); else prefix_size = 0; @@ -128,7 +129,7 @@ public: void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override { bool flag = getFlag(place); - if (result_is_nullable) + if constexpr (result_is_nullable) writeBinary(flag, buf); if (flag) nested_function->serialize(nestedPlace(place), buf); @@ -137,7 +138,7 @@ public: void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena * arena) const override { bool flag = 1; - if (result_is_nullable) + if constexpr (result_is_nullable) readBinary(flag, buf); if (flag) { @@ -146,9 +147,9 @@ public: } } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { - if (result_is_nullable) + if constexpr (result_is_nullable) { ColumnNullable & to_concrete = assert_cast(to); if (getFlag(place)) @@ -194,13 +195,26 @@ public: void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena) const override { const ColumnNullable * column = assert_cast(columns[0]); + const IColumn * nested_column = &column->getNestedColumn(); if (!column->isNullAt(row_num)) { this->setFlag(place); - const IColumn * nested_column = &column->getNestedColumn(); this->nested_function->add(this->nestedPlace(place), &nested_column, row_num, arena); } } + + void addBatchSinglePlace(size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena) const override + { + const ColumnNullable * column = assert_cast(columns[0]); + const IColumn * nested_column = &column->getNestedColumn(); + const UInt8 * null_map = column->getNullMapData().data(); + + this->nested_function->addBatchSinglePlaceNotNull(batch_size, this->nestedPlace(place), &nested_column, null_map, arena); + + if constexpr (result_is_nullable) + if (!memoryIsByte(null_map, batch_size, 1)) + this->setFlag(place); + } }; diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.h b/src/AggregateFunctions/AggregateFunctionOrFill.h index f69404ea393..1bbf2ea3135 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.h +++ b/src/AggregateFunctions/AggregateFunctionOrFill.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include namespace DB @@ -102,6 +104,8 @@ public: Arena * arena) const override { nested_function->merge(place, rhs, arena); + + place[size_of_data] |= rhs[size_of_data]; } void serialize( @@ -109,6 +113,8 @@ public: WriteBuffer & buf) const override { nested_function->serialize(place, buf); + + writeChar(place[size_of_data], buf); } void deserialize( @@ -117,6 +123,8 @@ public: Arena * arena) const override { nested_function->deserialize(place, buf, arena); + + readChar(place[size_of_data], buf); } DataTypePtr getReturnType() const override @@ -139,7 +147,7 @@ public: } void insertResultInto( - ConstAggregateDataPtr place, + AggregateDataPtr place, IColumn & to) const override { if (place[size_of_data]) diff --git a/src/AggregateFunctions/AggregateFunctionQuantile.cpp b/src/AggregateFunctions/AggregateFunctionQuantile.cpp index 993b25d6a6e..816fabad222 100644 --- a/src/AggregateFunctions/AggregateFunctionQuantile.cpp +++ b/src/AggregateFunctions/AggregateFunctionQuantile.cpp @@ -70,17 +70,17 @@ AggregateFunctionPtr createAggregateFunctionQuantile(const std::string & name, c WhichDataType which(argument_type); #define DISPATCH(TYPE) \ - if (which.idx == TypeIndex::TYPE) return std::make_shared>(argument_type, params); + if (which.idx == TypeIndex::TYPE) return std::make_shared>(argument_types, params); FOR_NUMERIC_TYPES(DISPATCH) #undef DISPATCH - if (which.idx == TypeIndex::Date) return std::make_shared>(argument_type, params); - if (which.idx == TypeIndex::DateTime) return std::make_shared>(argument_type, params); + if (which.idx == TypeIndex::Date) return std::make_shared>(argument_types, params); + if (which.idx == TypeIndex::DateTime) return std::make_shared>(argument_types, params); if constexpr (supportDecimal()) { - if (which.idx == TypeIndex::Decimal32) return std::make_shared>(argument_type, params); - if (which.idx == TypeIndex::Decimal64) return std::make_shared>(argument_type, params); - if (which.idx == TypeIndex::Decimal128) return std::make_shared>(argument_type, params); + if (which.idx == TypeIndex::Decimal32) return std::make_shared>(argument_types, params); + if (which.idx == TypeIndex::Decimal64) return std::make_shared>(argument_types, params); + if (which.idx == TypeIndex::Decimal128) return std::make_shared>(argument_types, params); } throw Exception("Illegal type " + argument_type->getName() + " of argument for aggregate function " + name, diff --git a/src/AggregateFunctions/AggregateFunctionQuantile.h b/src/AggregateFunctions/AggregateFunctionQuantile.h index f85eb15b3ab..7bdfc13295c 100644 --- a/src/AggregateFunctions/AggregateFunctionQuantile.h +++ b/src/AggregateFunctions/AggregateFunctionQuantile.h @@ -78,8 +78,8 @@ private: DataTypePtr & argument_type; public: - AggregateFunctionQuantile(const DataTypePtr & argument_type_, const Array & params) - : IAggregateFunctionDataHelper>({argument_type_}, params) + AggregateFunctionQuantile(const DataTypes & argument_types_, const Array & params) + : IAggregateFunctionDataHelper>(argument_types_, params) , levels(params, returns_many), level(levels.levels[0]), argument_type(this->argument_types[0]) { if (!returns_many && levels.size() > 1) @@ -138,10 +138,10 @@ public: this->data(place).deserialize(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { /// const_cast is required because some data structures apply finalizaton (like sorting) for obtain a result. - auto & data = this->data(const_cast(place)); + auto & data = this->data(place); if constexpr (returns_many) { diff --git a/src/AggregateFunctions/AggregateFunctionResample.h b/src/AggregateFunctions/AggregateFunctionResample.h index 0f348899884..49cc312287e 100644 --- a/src/AggregateFunctions/AggregateFunctionResample.h +++ b/src/AggregateFunctions/AggregateFunctionResample.h @@ -173,7 +173,7 @@ public: } void insertResultInto( - ConstAggregateDataPtr place, + AggregateDataPtr place, IColumn & to) const override { auto & col = assert_cast(to); diff --git a/src/AggregateFunctions/AggregateFunctionRetention.h b/src/AggregateFunctions/AggregateFunctionRetention.h index dd75007726e..3a76ba9f055 100644 --- a/src/AggregateFunctions/AggregateFunctionRetention.h +++ b/src/AggregateFunctions/AggregateFunctionRetention.h @@ -123,7 +123,7 @@ public: this->data(place).deserialize(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { auto & data_to = assert_cast(assert_cast(to).getData()).getData(); auto & offsets_to = assert_cast(to).getOffsets(); diff --git a/src/AggregateFunctions/AggregateFunctionSequenceMatch.h b/src/AggregateFunctions/AggregateFunctionSequenceMatch.h index 5d4a7098951..416786f8fcb 100644 --- a/src/AggregateFunctions/AggregateFunctionSequenceMatch.h +++ b/src/AggregateFunctions/AggregateFunctionSequenceMatch.h @@ -560,9 +560,9 @@ public: DataTypePtr getReturnType() const override { return std::make_shared(); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { - const_cast(this->data(place)).sort(); + this->data(place).sort(); const auto & data_ref = this->data(place); @@ -588,7 +588,7 @@ public: DataTypePtr getReturnType() const override { return std::make_shared(); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { const_cast(this->data(place)).sort(); assert_cast(to).getData().push_back(count(place)); diff --git a/src/AggregateFunctions/AggregateFunctionSimpleLinearRegression.h b/src/AggregateFunctions/AggregateFunctionSimpleLinearRegression.h index db4e57c0c6c..d1405172e27 100644 --- a/src/AggregateFunctions/AggregateFunctionSimpleLinearRegression.h +++ b/src/AggregateFunctions/AggregateFunctionSimpleLinearRegression.h @@ -169,7 +169,7 @@ public: } void insertResultInto( - ConstAggregateDataPtr place, + AggregateDataPtr place, IColumn & to ) const override { diff --git a/src/AggregateFunctions/AggregateFunctionState.h b/src/AggregateFunctions/AggregateFunctionState.h index 8879a324827..126d63573af 100644 --- a/src/AggregateFunctions/AggregateFunctionState.h +++ b/src/AggregateFunctions/AggregateFunctionState.h @@ -80,9 +80,9 @@ public: nested_func->deserialize(place, buf, arena); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { - assert_cast(to).getData().push_back(const_cast(place)); + assert_cast(to).getData().push_back(place); } /// Aggregate function or aggregate function state. diff --git a/src/AggregateFunctions/AggregateFunctionStatistics.h b/src/AggregateFunctions/AggregateFunctionStatistics.h index 1614e265ccb..7f6de43f5e1 100644 --- a/src/AggregateFunctions/AggregateFunctionStatistics.h +++ b/src/AggregateFunctions/AggregateFunctionStatistics.h @@ -143,7 +143,7 @@ public: this->data(place).deserialize(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { this->data(place).publish(to); } @@ -153,7 +153,7 @@ public: */ struct AggregateFunctionVarSampImpl { - static constexpr auto name = "varSamp"; + static constexpr auto name = "varSampStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -168,7 +168,7 @@ struct AggregateFunctionVarSampImpl */ struct AggregateFunctionStdDevSampImpl { - static constexpr auto name = "stddevSamp"; + static constexpr auto name = "stddevSampStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -180,7 +180,7 @@ struct AggregateFunctionStdDevSampImpl */ struct AggregateFunctionVarPopImpl { - static constexpr auto name = "varPop"; + static constexpr auto name = "varPopStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -197,7 +197,7 @@ struct AggregateFunctionVarPopImpl */ struct AggregateFunctionStdDevPopImpl { - static constexpr auto name = "stddevPop"; + static constexpr auto name = "stddevPopStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -395,7 +395,7 @@ public: this->data(place).deserialize(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { this->data(place).publish(to); } @@ -405,7 +405,7 @@ public: */ struct AggregateFunctionCovarSampImpl { - static constexpr auto name = "covarSamp"; + static constexpr auto name = "covarSampStable"; static inline Float64 apply(Float64 co_moment, UInt64 count) { @@ -420,7 +420,7 @@ struct AggregateFunctionCovarSampImpl */ struct AggregateFunctionCovarPopImpl { - static constexpr auto name = "covarPop"; + static constexpr auto name = "covarPopStable"; static inline Float64 apply(Float64 co_moment, UInt64 count) { @@ -437,7 +437,7 @@ struct AggregateFunctionCovarPopImpl */ struct AggregateFunctionCorrImpl { - static constexpr auto name = "corr"; + static constexpr auto name = "corrStable"; static inline Float64 apply(Float64 co_moment, Float64 left_m2, Float64 right_m2, UInt64 count) { diff --git a/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h b/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h index 185ef3594dd..96c07cc3d41 100644 --- a/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h +++ b/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h @@ -80,20 +80,28 @@ struct VarMoments readPODBinary(*this, buf); } - T NO_SANITIZE_UNDEFINED getPopulation() const - { - return (m[2] - m[1] * m[1] / m[0]) / m[0]; - } - - T NO_SANITIZE_UNDEFINED getSample() const + T getPopulation() const { if (m[0] == 0) return std::numeric_limits::quiet_NaN(); - return (m[2] - m[1] * m[1] / m[0]) / (m[0] - 1); + + /// Due to numerical errors, the result can be slightly less than zero, + /// but it should be impossible. Trim to zero. + + return std::max(T{}, (m[2] - m[1] * m[1] / m[0]) / m[0]); } - T NO_SANITIZE_UNDEFINED getMoment3() const + T getSample() const { + if (m[0] <= 1) + return std::numeric_limits::quiet_NaN(); + return std::max(T{}, (m[2] - m[1] * m[1] / m[0]) / (m[0] - 1)); + } + + T getMoment3() const + { + if (m[0] == 0) + return std::numeric_limits::quiet_NaN(); // to avoid accuracy problem if (m[0] == 1) return 0; @@ -104,8 +112,10 @@ struct VarMoments ) / m[0]; } - T NO_SANITIZE_UNDEFINED getMoment4() const + T getMoment4() const { + if (m[0] == 0) + return std::numeric_limits::quiet_NaN(); // to avoid accuracy problem if (m[0] == 1) return 0; @@ -180,7 +190,7 @@ struct VarMomentsDecimal if (common::mulOverflow(getM(1), getM(1), tmp) || common::subOverflow(getM(2), NativeType(tmp / m0), tmp)) throw Exception("Decimal math overflow", ErrorCodes::DECIMAL_OVERFLOW); - return convertFromDecimal, DataTypeNumber>(tmp / m0, scale); + return std::max(Float64{}, convertFromDecimal, DataTypeNumber>(tmp / m0, scale)); } Float64 getSample(UInt32 scale) const @@ -194,7 +204,7 @@ struct VarMomentsDecimal if (common::mulOverflow(getM(1), getM(1), tmp) || common::subOverflow(getM(2), NativeType(tmp / m0), tmp)) throw Exception("Decimal math overflow", ErrorCodes::DECIMAL_OVERFLOW); - return convertFromDecimal, DataTypeNumber>(tmp / (m0 - 1), scale); + return std::max(Float64{}, convertFromDecimal, DataTypeNumber>(tmp / (m0 - 1), scale)); } Float64 getMoment3(UInt32 scale) const @@ -445,7 +455,7 @@ public: this->data(place).read(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { const auto & data = this->data(place); auto & dst = static_cast(to).getData(); diff --git a/src/AggregateFunctions/AggregateFunctionSum.h b/src/AggregateFunctions/AggregateFunctionSum.h index 46b90555c27..9d3d559ecee 100644 --- a/src/AggregateFunctions/AggregateFunctionSum.h +++ b/src/AggregateFunctions/AggregateFunctionSum.h @@ -20,11 +20,72 @@ struct AggregateFunctionSumData { T sum{}; - void add(T value) + void ALWAYS_INLINE add(T value) { sum += value; } + /// Vectorized version + template + void NO_INLINE addMany(const Value * __restrict ptr, size_t count) + { + /// Compiler cannot unroll this loop, do it manually. + /// (at least for floats, most likely due to the lack of -fassociative-math) + + /// Something around the number of SSE registers * the number of elements fit in register. + constexpr size_t unroll_count = 128 / sizeof(T); + T partial_sums[unroll_count]{}; + + const auto * end = ptr + count; + const auto * unrolled_end = ptr + (count / unroll_count * unroll_count); + + while (ptr < unrolled_end) + { + for (size_t i = 0; i < unroll_count; ++i) + partial_sums[i] += ptr[i]; + ptr += unroll_count; + } + + for (size_t i = 0; i < unroll_count; ++i) + sum += partial_sums[i]; + + while (ptr < end) + { + sum += *ptr; + ++ptr; + } + } + + template + void NO_INLINE addManyNotNull(const Value * __restrict ptr, const UInt8 * __restrict null_map, size_t count) + { + constexpr size_t unroll_count = 128 / sizeof(T); + T partial_sums[unroll_count]{}; + + const auto * end = ptr + count; + const auto * unrolled_end = ptr + (count / unroll_count * unroll_count); + + while (ptr < unrolled_end) + { + for (size_t i = 0; i < unroll_count; ++i) + if (!null_map[i]) + partial_sums[i] += ptr[i]; + ptr += unroll_count; + null_map += unroll_count; + } + + for (size_t i = 0; i < unroll_count; ++i) + sum += partial_sums[i]; + + while (ptr < end) + { + if (!*null_map) + sum += *ptr; + ++ptr; + ++null_map; + } + } + void merge(const AggregateFunctionSumData & rhs) { sum += rhs.sum; @@ -55,21 +116,95 @@ struct AggregateFunctionSumKahanData T sum{}; T compensation{}; - void add(T value) + template + void ALWAYS_INLINE addImpl(Value value, T & out_sum, T & out_compensation) { - auto compensated_value = value - compensation; - auto new_sum = sum + compensated_value; - compensation = (new_sum - sum) - compensated_value; - sum = new_sum; + auto compensated_value = value - out_compensation; + auto new_sum = out_sum + compensated_value; + out_compensation = (new_sum - out_sum) - compensated_value; + out_sum = new_sum; + } + + void ALWAYS_INLINE add(T value) + { + addImpl(value, sum, compensation); + } + + /// Vectorized version + template + void NO_INLINE addMany(const Value * __restrict ptr, size_t count) + { + /// Less than in ordinary sum, because the algorithm is more complicated and too large loop unrolling is questionable. + /// But this is just a guess. + constexpr size_t unroll_count = 4; + T partial_sums[unroll_count]{}; + T partial_compensations[unroll_count]{}; + + const auto * end = ptr + count; + const auto * unrolled_end = ptr + (count / unroll_count * unroll_count); + + while (ptr < unrolled_end) + { + for (size_t i = 0; i < unroll_count; ++i) + addImpl(ptr[i], partial_sums[i], partial_compensations[i]); + ptr += unroll_count; + } + + for (size_t i = 0; i < unroll_count; ++i) + mergeImpl(sum, compensation, partial_sums[i], partial_compensations[i]); + + while (ptr < end) + { + addImpl(*ptr, sum, compensation); + ++ptr; + } + } + + template + void NO_INLINE addManyNotNull(const Value * __restrict ptr, const UInt8 * __restrict null_map, size_t count) + { + constexpr size_t unroll_count = 4; + T partial_sums[unroll_count]{}; + T partial_compensations[unroll_count]{}; + + const auto * end = ptr + count; + const auto * unrolled_end = ptr + (count / unroll_count * unroll_count); + + while (ptr < unrolled_end) + { + for (size_t i = 0; i < unroll_count; ++i) + if (!null_map[i]) + addImpl(ptr[i], partial_sums[i], partial_compensations[i]); + ptr += unroll_count; + null_map += unroll_count; + } + + for (size_t i = 0; i < unroll_count; ++i) + mergeImpl(sum, compensation, partial_sums[i], partial_compensations[i]); + + while (ptr < end) + { + if (!*null_map) + addImpl(*ptr, sum, compensation); + ++ptr; + ++null_map; + } + } + + void ALWAYS_INLINE mergeImpl(T & to_sum, T & to_compensation, T from_sum, T from_compensation) + { + auto raw_sum = to_sum + from_sum; + auto rhs_compensated = raw_sum - to_sum; + /// Kahan summation is tricky because it depends on non-associativity of float arithmetic. + /// Do not simplify this expression if you are not sure. + auto compensations = ((from_sum - rhs_compensated) + (to_sum - (raw_sum - rhs_compensated))) + compensation + from_compensation; + to_sum = raw_sum + compensations; + to_compensation = compensations - (to_sum - raw_sum); } void merge(const AggregateFunctionSumKahanData & rhs) { - auto raw_sum = sum + rhs.sum; - auto rhs_compensated = raw_sum - sum; - auto compensations = ((rhs.sum - rhs_compensated) + (sum - (raw_sum - rhs_compensated))) + compensation + rhs.compensation; - sum = raw_sum + compensations; - compensation = compensations - (sum - raw_sum); + mergeImpl(sum, compensation, rhs.sum, rhs.compensation); } void write(WriteBuffer & buf) const @@ -141,6 +276,20 @@ public: this->data(place).add(column.getData()[row_num]); } + /// Vectorized version when there is no GROUP BY keys. + void addBatchSinglePlace(size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena *) const override + { + const auto & column = static_cast(*columns[0]); + this->data(place).addMany(column.getData().data(), batch_size); + } + + void addBatchSinglePlaceNotNull( + size_t batch_size, AggregateDataPtr place, const IColumn ** columns, const UInt8 * null_map, Arena *) const override + { + const auto & column = static_cast(*columns[0]); + this->data(place).addManyNotNull(column.getData().data(), null_map, batch_size); + } + void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override { this->data(place).merge(this->data(rhs)); @@ -156,7 +305,7 @@ public: this->data(place).read(buf); } - void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override + void insertResultInto(AggregateDataPtr place, IColumn & to) const override { auto & column = static_cast(to); column.getData().push_back(this->data(place).get()); diff --git a/src/AggregateFunctions/AggregateFunctionSumMap.cpp b/src/AggregateFunctions/AggregateFunctionSumMap.cpp index 5bedf72c39b..f4e299fe7c9 100644 --- a/src/AggregateFunctions/AggregateFunctionSumMap.cpp +++ b/src/AggregateFunctions/AggregateFunctionSumMap.cpp @@ -18,85 +18,105 @@ namespace ErrorCodes namespace { -struct WithOverflowPolicy +template +struct SumMap { - /// Overflow, meaning that the returned type is the same as the input type. - static DataTypePtr promoteType(const DataTypePtr & data_type) { return data_type; } + template + using F = AggregateFunctionSumMap; }; -struct WithoutOverflowPolicy +template +struct SumMapFiltered { - /// No overflow, meaning we promote the types if necessary. - static DataTypePtr promoteType(const DataTypePtr & data_type) + template + using F = AggregateFunctionSumMapFiltered; +}; + + +auto parseArguments(const std::string & name, const DataTypes & arguments) +{ + DataTypes args; + bool tuple_argument = false; + + if (arguments.size() == 1) { - if (!data_type->canBePromoted()) - throw Exception{"Values to be summed are expected to be Numeric, Float or Decimal.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; + // sumMap state is fully given by its result, so it can be stored in + // SimpleAggregateFunction columns. There is a caveat: it must support + // sumMap(sumMap(...)), e.g. it must be able to accept its own output as + // an input. This is why it also accepts a Tuple(keys, values) argument. + const auto * tuple_type = checkAndGetDataType(arguments[0].get()); + if (!tuple_type) + throw Exception("When function " + name + " gets one argument it must be a tuple", + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - return data_type->promoteNumericType(); + const auto elems = tuple_type->getElements(); + args.insert(args.end(), elems.begin(), elems.end()); + tuple_argument = true; + } + else + { + args.insert(args.end(), arguments.begin(), arguments.end()); + tuple_argument = false; } -}; -template -using SumMapWithOverflow = AggregateFunctionSumMap; - -template -using SumMapWithoutOverflow = AggregateFunctionSumMap; - -template -using SumMapFilteredWithOverflow = AggregateFunctionSumMapFiltered; - -template -using SumMapFilteredWithoutOverflow = AggregateFunctionSumMapFiltered; - -using SumMapArgs = std::pair; - -SumMapArgs parseArguments(const std::string & name, const DataTypes & arguments) -{ - if (arguments.size() < 2) - throw Exception("Aggregate function " + name + " requires at least two arguments of Array type.", + if (args.size() < 2) + throw Exception("Aggregate function " + name + " requires at least two arguments of Array type or one argument of tuple of two arrays", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - const auto * array_type = checkAndGetDataType(arguments[0].get()); + const auto * array_type = checkAndGetDataType(args[0].get()); if (!array_type) - throw Exception("First argument for function " + name + " must be an array.", + throw Exception("First argument for function " + name + " must be an array, not " + args[0]->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - DataTypePtr keys_type = array_type->getNestedType(); DataTypes values_types; - values_types.reserve(arguments.size() - 1); - for (size_t i = 1; i < arguments.size(); ++i) + values_types.reserve(args.size() - 1); + for (size_t i = 1; i < args.size(); ++i) { - array_type = checkAndGetDataType(arguments[i].get()); + array_type = checkAndGetDataType(args[i].get()); if (!array_type) throw Exception("Argument #" + toString(i) + " for function " + name + " must be an array.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); values_types.push_back(array_type->getNestedType()); } - return {std::move(keys_type), std::move(values_types)}; + return std::tuple{std::move(keys_type), std::move(values_types), + tuple_argument}; } -template